From 04d8f41f530066e71b9e463678325c8390c0a629 Mon Sep 17 00:00:00 2001 From: Vincent Delecroix Date: Thu, 12 Oct 2023 09:30:10 +0200 Subject: [PATCH 01/41] automatic generation of flint headers --- src/sage/libs/flint/flint_wrap.h | 147 +- src/sage/libs/flint/fmpq.pxd | 518 +++++- src/sage/libs/flint/fmpq_mat.pxd | 364 +++- src/sage/libs/flint/fmpz.pxd | 1203 +++++++++++-- src/sage/libs/flint/fmpz_factor.pxd | 221 ++- src/sage/libs/flint/fmpz_factor.pyx | 27 - src/sage/libs/flint/fmpz_factor_extra.pxd | 3 + src/sage/libs/flint/fmpz_factor_extra.pyx | 28 + src/sage/libs/flint/fmpz_mat.pxd | 994 ++++++++++- src/sage/libs/flint/fmpz_mod.pxd | 82 +- src/sage/libs/flint/fmpz_mod_poly.pxd | 1716 +++++++++++++----- src/sage/libs/flint/fmpz_poly_q.pxd | 138 +- src/sage/libs/flint/fq.pxd | 357 +++- src/sage/libs/flint/fq_nmod.pxd | 350 +++- src/sage/libs/flint/nmod_poly.pxd | 1955 +++++++++++++++++++-- src/sage/libs/flint/nmod_poly_factor.pxd | 162 ++ src/sage/libs/flint/nmod_poly_linkage.pxi | 2 + src/sage/libs/flint/padic.pxd | 406 ++++- src/sage/libs/flint/padic_poly.pxd | 468 +++-- src/sage/libs/flint/qadic.pxd | 428 ++++- src/sage/libs/flint/qsieve.pyx | 6 +- src/sage/libs/flint/thread_pool.pxd | 14 +- src/sage/libs/flint/types.pxd | 291 ++- src/sage/rings/factorint_flint.pyx | 1 + 24 files changed, 8572 insertions(+), 1309 deletions(-) create mode 100644 src/sage/libs/flint/fmpz_factor_extra.pxd create mode 100644 src/sage/libs/flint/fmpz_factor_extra.pyx create mode 100644 src/sage/libs/flint/nmod_poly_factor.pxd diff --git a/src/sage/libs/flint/flint_wrap.h b/src/sage/libs/flint/flint_wrap.h index 4db72b97660..d411bde44db 100644 --- a/src/sage/libs/flint/flint_wrap.h +++ b/src/sage/libs/flint/flint_wrap.h @@ -15,7 +15,6 @@ */ #include -#include /* Save previous definition of ulong if any, as pari also uses it */ /* Should work on GCC, clang, MSVC */ @@ -32,30 +31,140 @@ #define slong mp_limb_signed_t #endif -#include -#include -#include -#include -#include -#include -#include -#include -#include #include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include -#include -#include -#include +#include +#include +#include #include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #undef ulong #undef slong diff --git a/src/sage/libs/flint/fmpq.pxd b/src/sage/libs/flint/fmpq.pxd index 0616c0a7408..a0f708c7f08 100644 --- a/src/sage/libs/flint/fmpq.pxd +++ b/src/sage/libs/flint/fmpq.pxd @@ -1,78 +1,508 @@ # distutils: libraries = flint # distutils: depends = flint/fmpq.h +################################################################################ +# This file is auto-generated. Do not modify by hand +################################################################################ + from libc.stdio cimport FILE -from sage.libs.gmp.types cimport mpq_t -from sage.libs.flint.types cimport fmpz_t, fmpq_t, flint_rand_t, mp_bitcnt_t, fmpz -from sage.libs.mpfr.types cimport mpfr_t, mpfr_rnd_t +from sage.libs.gmp.types cimport * +from sage.libs.mpfr.types cimport * +from sage.libs.flint.types cimport * -# flint/fmpq.h cdef extern from "flint_wrap.h": - fmpz * fmpq_numref(fmpq_t) - fmpz * fmpq_denref(fmpq_t) - void fmpq_init(fmpq_t) - void fmpq_clear(fmpq_t) - void fmpq_init_set_readonly(fmpq_t, const mpq_t) - void fmpq_clear_readonly(fmpq_t) - void fmpq_one(fmpq_t) - void fmpq_zero(fmpq_t) - bint fmpq_is_zero(fmpq_t) - bint fmpq_is_one(fmpq_t) - int fmpq_sgn(const fmpq_t x) + + fmpz * fmpq_numref(const fmpq_t x) + fmpz * fmpq_denref(const fmpq_t x) + # Returns respectively a pointer to the numerator and denominator of x. + + void fmpq_init(fmpq_t x) + # Initialises the ``fmpq_t`` variable ``x`` for use. Its value + # is set to 0. + + void fmpq_clear(fmpq_t x) + # Clears the ``fmpq_t`` variable ``x``. To use the variable again, + # it must be re-initialised with ``fmpq_init``. + + void fmpq_canonicalise(fmpq_t res) + # Puts ``res`` in canonical form: the numerator and denominator are + # reduced to lowest terms, and the denominator is made positive. + # If the numerator is zero, the denominator is set to one. + # If the denominator is zero, the outcome of calling this function is + # undefined, regardless of the value of the numerator. + + void _fmpq_canonicalise(fmpz_t num, fmpz_t den) + # Does the same thing as ``fmpq_canonicalise``, but for numerator + # and denominator given explicitly as ``fmpz_t`` variables. Aliasing + # of ``num`` and ``den`` is not allowed. + + int fmpq_is_canonical(const fmpq_t x) + # Returns nonzero if ``fmpq_t`` x is in canonical form + # (as produced by ``fmpq_canonicalise``), and zero otherwise. + + int _fmpq_is_canonical(const fmpz_t num, const fmpz_t den) + # Does the same thing as ``fmpq_is_canonical``, but for numerator + # and denominator given explicitly as ``fmpz_t`` variables. + void fmpq_set(fmpq_t dest, const fmpq_t src) + # Sets ``dest`` to a copy of ``src``. No canonicalisation + # is performed. + void fmpq_swap(fmpq_t op1, fmpq_t op2) + # Swaps the two rational numbers ``op1`` and ``op2``. + void fmpq_neg(fmpq_t dest, const fmpq_t src) + # Sets ``dest`` to the additive inverse of ``src``. + void fmpq_abs(fmpq_t dest, const fmpq_t src) + # Sets ``dest`` to the absolute value of ``src``. + + void fmpq_zero(fmpq_t res) + # Sets the value of ``res`` to 0. + + void fmpq_one(fmpq_t res) + # Sets the value of ``res`` to `1`. + + int fmpq_is_zero(const fmpq_t res) + # Returns nonzero if ``res`` has value 0, and returns zero otherwise. + + int fmpq_is_one(const fmpq_t res) + # Returns nonzero if ``res`` has value `1`, and returns zero otherwise. + + int fmpq_is_pm1(const fmpq_t res) + # Returns nonzero if ``res`` has value `\pm{1}` and zero otherwise. + + int fmpq_equal(const fmpq_t x, const fmpq_t y) + # Returns nonzero if ``x`` and ``y`` are equal, and zero otherwise. + # Assumes that ``x`` and ``y`` are both in canonical form. + + int fmpq_sgn(const fmpq_t x) + # Returns the sign of the rational number `x`. + int fmpq_cmp(const fmpq_t x, const fmpq_t y) - void fmpq_canonicalise(fmpq_t res) - int fmpq_is_canonical(const fmpq_t x) - void fmpq_set_si(fmpq_t res, long p, unsigned long q) + int fmpq_cmp_fmpz(const fmpq_t x, const fmpz_t y) + int fmpq_cmp_ui(const fmpq_t x, unsigned long y) + # Returns negative if `x < y`, zero if `x = y`, and positive if `x > y`. + + int fmpq_cmp_si(const fmpq_t x, long y) + # Returns negative if `x < y`, zero if `x = y`, and positive if `x > y`. + + int fmpq_equal_ui(fmpq_t x, unsigned long y) + # Returns `1` if `x = y`, otherwise returns `0`. + + int fmpq_equal_si(fmpq_t x, long y) + # Returns `1` if `x = y`, otherwise returns `0`. + + void fmpq_height(fmpz_t height, const fmpq_t x) + # Sets ``height`` to the height of `x`, defined as the larger of + # the absolute values of the numerator and denominator of `x`. + + flint_bitcnt_t fmpq_height_bits(const fmpq_t x) + # Returns the number of bits in the height of `x`. + void fmpq_set_fmpz_frac(fmpq_t res, const fmpz_t p, const fmpz_t q) + # Sets ``res`` to the canonical form of the fraction ``p / q``. + # This is equivalent to assigning the numerator and denominator + # separately and calling ``fmpq_canonicalise``. + + void fmpq_get_mpz_frac(mpz_t a, mpz_t b, fmpq_t c) + # Sets ``a``, ``b`` to the numerator and denominator of ``c`` + # respectively. + + void fmpq_set_si(fmpq_t res, long p, unsigned long q) + # Sets ``res`` to the canonical form of the fraction ``p / q``. + + void _fmpq_set_si(fmpz_t rnum, fmpz_t rden, long p, unsigned long q) + # Sets ``(rnum, rden)`` to the canonical form of the fraction + # ``p / q``. ``rnum`` and ``rden`` may not be aliased. + + void fmpq_set_ui(fmpq_t res, unsigned long p, unsigned long q) + # Sets ``res`` to the canonical form of the fraction ``p / q``. + + void _fmpq_set_ui(fmpz_t rnum, fmpz_t rden, unsigned long p, unsigned long q) + # Sets ``(rnum, rden)`` to the canonical form of the fraction + # ``p / q``. ``rnum`` and ``rden`` may not be aliased. + void fmpq_set_mpq(fmpq_t dest, const mpq_t src) + # Sets the value of ``dest`` to that of the ``mpq_t`` variable + # ``src``. + + int fmpq_set_str(fmpq_t dest, const char * s, int base) + # Sets the value of ``dest`` to the value represented in the string + # ``s`` in base ``base``. + # Returns 0 if no error occurs. Otherwise returns -1 and ``dest`` is + # set to zero. + + void fmpq_init_set_mpz_frac_readonly(fmpq_t z, const mpz_t p, const mpz_t q) + # Assuming ``z`` is an ``fmpz_t`` which will not be cleaned up, + # this temporarily copies ``p`` and ``q`` into the numerator and + # denominator of ``z`` for read only operations only. The user must not + # run ``fmpq_clear`` on ``z``. + + double fmpq_get_d(const fmpq_t f) + # Returns `f` as a ``double``, rounding towards zero if ``f`` cannot be represented exactly. The return is system dependent if ``f`` is too large or too small to fit in a ``double``. + void fmpq_get_mpq(mpq_t dest, const fmpq_t src) - int fmpq_get_mpfr(mpfr_t r, const fmpq_t x, mpfr_rnd_t rnd) + # Sets the value of ``dest`` + + int fmpq_get_mpfr(mpfr_t dest, const fmpq_t src, mpfr_rnd_t rnd) + # Sets the MPFR variable ``dest`` to the value of ``src``, + # rounded to the nearest representable binary floating-point value + # in direction ``rnd``. Returns the sign of the rounding, + # according to MPFR conventions. + # **Note:** Requires that ``mpfr.h`` has been included before any FLINT + # header is included. + + char * _fmpq_get_str(char * str, int b, const fmpz_t num, const fmpz_t den) + char * fmpq_get_str(char * str, int b, const fmpq_t x) + # Prints the string representation of `x` in base `b \in [2, 36]` + # to a suitable buffer. + # If ``str`` is not ``NULL``, this is used as the buffer and + # also the return value. If ``str`` is ``NULL``, allocates + # sufficient space and returns a pointer to the string. + void flint_mpq_init_set_readonly(mpq_t z, const fmpq_t f) + # Sets the uninitialised ``mpq_t`` `z` to the value of the + # readonly ``fmpq_t`` `f`. + # Note that it is assumed that `f` does not change during + # the lifetime of `z`. + # The rational `z` has to be cleared by a call to + # :func:`flint_mpq_clear_readonly`. + # The suggested use of the two functions is as follows:: + # fmpq_t f; + # ... + # { + # mpq_t z; + # flint_mpq_init_set_readonly(z, f); + # foo(..., z); + # flint_mpq_clear_readonly(z); + # } + # This provides a convenient function for user code, only + # requiring to work with the types ``fmpq_t`` and ``mpq_t``. + void flint_mpq_clear_readonly(mpq_t z) + # Clears the readonly ``mpq_t`` `z`. + void fmpq_init_set_readonly(fmpq_t f, const mpq_t z) + # Sets the uninitialised ``fmpq_t`` `f` to a readonly + # version of the rational `z`. + # Note that the value of `z` is assumed to remain constant + # throughout the lifetime of `f`. + # The ``fmpq_t`` `f` has to be cleared by calling the + # function :func:`fmpq_clear_readonly`. + # The suggested use of the two functions is as follows:: + # mpq_t z; + # ... + # { + # fmpq_t f; + # fmpq_init_set_readonly(f, z); + # foo(..., f); + # fmpq_clear_readonly(f); + # } + void fmpq_clear_readonly(fmpq_t f) - char * fmpq_get_str(char * str, int b, const fmpq_t x) - void fmpq_fprint(FILE * file, const fmpq_t x) - void fmpq_print(const fmpq_t x) - void fmpq_randtest(fmpq_t res, flint_rand_t state, mp_bitcnt_t bits) - void fmpq_randtest_not_zero(fmpq_t res, flint_rand_t state, mp_bitcnt_t bits) - void fmpq_randbits(fmpq_t res, flint_rand_t state, mp_bitcnt_t bits) + # Clears the readonly ``fmpq_t`` `f`. + + int fmpq_fprint(FILE * file, const fmpq_t x) + # Prints ``x`` as a fraction to the stream ``file``. + # The numerator and denominator are printed verbatim as integers, + # with a forward slash (/) printed in between. + # In case of success, returns a positive number. In case of failure, + # returns a non-positive number. + + int _fmpq_fprint(FILE * file, const fmpz_t num, const fmpz_t den) + # Does the same thing as ``fmpq_fprint``, but for numerator + # and denominator given explicitly as ``fmpz_t`` variables. + # In case of success, returns a positive number. In case of failure, + # returns a non-positive number. + + int fmpq_print(const fmpq_t x) + # Prints ``x`` as a fraction. The numerator and denominator are + # printed verbatim as integers, with a forward slash (/) printed in + # between. + # In case of success, returns a positive number. In case of failure, + # returns a non-positive number. + + int _fmpq_print(const fmpz_t num, const fmpz_t den) + # Does the same thing as ``fmpq_print``, but for numerator + # and denominator given explicitly as ``fmpz_t`` variables. + # In case of success, returns a positive number. In case of failure, + # returns a non-positive number. + + void fmpq_randtest(fmpq_t res, flint_rand_t state, flint_bitcnt_t bits) + # Sets ``res`` to a random value, with numerator and denominator + # having up to ``bits`` bits. The fraction will be in canonical + # form. This function has an increased probability of generating + # special values which are likely to trigger corner cases. + + void _fmpq_randtest(fmpz_t num, fmpz_t den, flint_rand_t state, flint_bitcnt_t bits) + # Does the same thing as ``fmpq_randtest``, but for numerator + # and denominator given explicitly as ``fmpz_t`` variables. Aliasing + # of ``num`` and ``den`` is not allowed. + + void fmpq_randtest_not_zero(fmpq_t res, flint_rand_t state, flint_bitcnt_t bits) + # As per ``fmpq_randtest``, but the result will not be `0`. + # If ``bits`` is set to `0`, an exception will result. + + void fmpq_randbits(fmpq_t res, flint_rand_t state, flint_bitcnt_t bits) + # Sets ``res`` to a random value, with numerator and denominator + # both having exactly ``bits`` bits before canonicalisation, + # and then puts ``res`` in canonical form. Note that as a result + # of the canonicalisation, the resulting numerator and denominator can + # be slightly smaller than ``bits`` bits. + + void _fmpq_randbits(fmpz_t num, fmpz_t den, flint_rand_t state, flint_bitcnt_t bits) + # Does the same thing as ``fmpq_randbits``, but for numerator + # and denominator given explicitly as ``fmpz_t`` variables. Aliasing + # of ``num`` and ``den`` is not allowed. + void fmpq_add(fmpq_t res, const fmpq_t op1, const fmpq_t op2) - void fmpq_add_si(fmpq_t res, const fmpq_t op1, long c) - void fmpq_add_fmpz(fmpq_t res, const fmpq_t op1, const fmpz_t c) void fmpq_sub(fmpq_t res, const fmpq_t op1, const fmpq_t op2) + void fmpq_mul(fmpq_t res, const fmpq_t op1, const fmpq_t op2) + void fmpq_div(fmpq_t res, const fmpq_t op1, const fmpq_t op2) + # Sets ``res`` respectively to ``op1 + op2``, ``op1 - op2``, + # ``op1 * op2``, or ``op1 / op2``. Assumes that the inputs + # are in canonical form, and produces output in canonical form. + # Division by zero results in an error. + # Aliasing between any combination of the variables is allowed. + + void _fmpq_add(fmpz_t rnum, fmpz_t rden, const fmpz_t op1num, const fmpz_t op1den, const fmpz_t op2num, const fmpz_t op2den) + void _fmpq_sub(fmpz_t rnum, fmpz_t rden, const fmpz_t op1num, const fmpz_t op1den, const fmpz_t op2num, const fmpz_t op2den) + void _fmpq_mul(fmpz_t rnum, fmpz_t rden, const fmpz_t op1num, const fmpz_t op1den, const fmpz_t op2num, const fmpz_t op2den) + void _fmpq_div(fmpz_t rnum, fmpz_t rden, const fmpz_t op1num, const fmpz_t op1den, const fmpz_t op2num, const fmpz_t op2den) + # Sets ``(rnum, rden)`` to the canonical form of the sum, + # difference, product or quotient respectively of the fractions + # represented by ``(op1num, op1den)`` and ``(op2num, op2den)``. + # Aliasing between any combination of the variables is allowed, + # whilst no numerator is aliased with a denominator. + + void _fmpq_add_si(fmpz_t rnum, fmpz_t rden, const fmpz_t p, const fmpz_t q, long r) + void _fmpq_sub_si(fmpz_t rnum, fmpz_t rden, const fmpz_t p, const fmpz_t q, long r) + void _fmpq_add_ui(fmpz_t rnum, fmpz_t rden, const fmpz_t p, const fmpz_t q, unsigned long r) + void _fmpq_sub_ui(fmpz_t rnum, fmpz_t rden, const fmpz_t p, const fmpz_t q, unsigned long r) + void _fmpq_add_fmpz(fmpz_t rnum, fmpz_t rden, const fmpz_t p, const fmpz_t q, const fmpz_t r) + void _fmpq_sub_fmpz(fmpz_t rnum, fmpz_t rden, const fmpz_t p, const fmpz_t q, const fmpz_t r) + # Sets ``(rnum, rden)`` to the canonical form of the sum or difference + # respectively of the fractions represented by ``(p, q)`` and + # ``(r, 1)``. Numerators may not be aliased with denominators. + + void fmpq_add_si(fmpq_t res, const fmpq_t op1, long c) void fmpq_sub_si(fmpq_t res, const fmpq_t op1, long c) + void fmpq_add_ui(fmpq_t res, const fmpq_t op1, unsigned long c) + void fmpq_sub_ui(fmpq_t res, const fmpq_t op1, unsigned long c) + void fmpq_add_fmpz(fmpq_t res, const fmpq_t op1, const fmpz_t c) void fmpq_sub_fmpz(fmpq_t res, const fmpq_t op1, const fmpz_t c) - void fmpq_mul(fmpq_t res, const fmpq_t op1, const fmpq_t op2) - void fmpq_mul_fmpz(fmpq_t res, const fmpq_t op, const fmpz_t x) - void fmpq_pow_si(fmpq_t rop, const fmpq_t op, long e) + + void _fmpq_mul_si(fmpz_t rnum, fmpz_t rden, const fmpz_t p, const fmpz_t q, long r) + + void fmpq_mul_si(fmpq_t res, const fmpq_t op1, long c) + + void _fmpq_mul_ui(fmpz_t rnum, fmpz_t rden, const fmpz_t p, const fmpz_t q, unsigned long r) + + void fmpq_mul_ui(fmpq_t res, const fmpq_t op1, unsigned long c) + void fmpq_addmul(fmpq_t res, const fmpq_t op1, const fmpq_t op2) void fmpq_submul(fmpq_t res, const fmpq_t op1, const fmpq_t op2) + # Sets ``res`` to ``res + op1 * op2`` or ``res - op1 * op2`` + # respectively, placing the result in canonical form. Aliasing + # between any combination of the variables is allowed. + + void _fmpq_addmul(fmpz_t rnum, fmpz_t rden, const fmpz_t op1num, const fmpz_t op1den, const fmpz_t op2num, const fmpz_t op2den) + void _fmpq_submul(fmpz_t rnum, fmpz_t rden, const fmpz_t op1num, const fmpz_t op1den, const fmpz_t op2num, const fmpz_t op2den) + # Sets ``(rnum, rden)`` to the canonical form of the fraction + # ``(rnum, rden)`` + ``(op1num, op1den)`` * ``(op2num, op2den)`` or + # ``(rnum, rden)`` - ``(op1num, op1den)`` * ``(op2num, op2den)`` + # respectively. Aliasing between any combination of the variables is allowed, + # whilst no numerator is aliased with a denominator. + void fmpq_inv(fmpq_t dest, const fmpq_t src) - void fmpq_div(fmpq_t res, const fmpq_t op1, const fmpq_t op2) + # Sets ``dest`` to ``1 / src``. The result is placed in canonical + # form, assuming that ``src`` is already in canonical form. + + void _fmpq_pow_si(fmpz_t rnum, fmpz_t rden, const fmpz_t opnum, const fmpz_t opden, long e) + void fmpq_pow_si(fmpq_t res, const fmpq_t op, long e) + # Sets ``res`` to ``op`` raised to the power `e`, where `e` + # is a ``slong``. If `e` is `0` and ``op`` is `0`, then + # ``res`` will be set to `1`. + + int fmpq_pow_fmpz(fmpq_t a, const fmpq_t b, const fmpz_t e) + # Set ``res`` to ``op`` raised to the power `e`. + # Return `1` for success and `0` for failure. + + void fmpq_mul_fmpz(fmpq_t res, const fmpq_t op, const fmpz_t x) + # Sets ``res`` to the product of the rational number ``op`` + # and the integer ``x``. + void fmpq_div_fmpz(fmpq_t res, const fmpq_t op, const fmpz_t x) - void fmpq_mul_2exp(fmpq_t res, const fmpq_t x, mp_bitcnt_t exp) - void fmpq_div_2exp(fmpq_t res, const fmpq_t x, mp_bitcnt_t exp) - int fmpq_mod_fmpz(fmpz_t res, const fmpq_t x, const fmpz_t mod) + # Sets ``res`` to the quotient of the rational number ``op`` + # and the integer ``x``. + + void fmpq_mul_2exp(fmpq_t res, const fmpq_t x, flint_bitcnt_t exp) + # Sets ``res`` to ``x`` multiplied by ``2^exp``. + + void fmpq_div_2exp(fmpq_t res, const fmpq_t x, flint_bitcnt_t exp) + # Sets ``res`` to ``x`` divided by ``2^exp``. + + void _fmpq_gcd(fmpz_t rnum, fmpz_t rden, const fmpz_t p, const fmpz_t q, const fmpz_t r, const fmpz_t s) + # Set ``(rnum, rden)`` to the gcd of ``(p, q)`` and ``(r, s)`` + # which we define to be the canonicalisation of `\operatorname{gcd}(ps, qr)/(qs)`. + # (This is apparently Euclid's original definition and is stable under scaling of + # numerator and denominator. It also agrees with the gcd on the integers. + # Note that it does not agree with gcd as defined in ``fmpq_poly``.) + # This definition agrees with the result as output by Sage and Pari/GP. + void fmpq_gcd(fmpq_t res, const fmpq_t op1, const fmpq_t op2) - int fmpq_reconstruct_fmpz(fmpq_t res, const fmpz_t a, const fmpz_t m) + # Set ``res`` to the gcd of ``op1`` and ``op2``. See the low + # level function ``_fmpq_gcd`` for our definition of gcd. + + void _fmpq_gcd_cofactors(fmpz_t gnum, fmpz_t gden, fmpz_t abar, fmpz_t bbar, const fmpz_t anum, const fmpz_t aden, const fmpz_t bnum, const fmpz_t bden) + void fmpq_gcd_cofactors(fmpq_t g, fmpz_t abar, fmpz_t bbar, const fmpq_t a, const fmpq_t b) + # Set `g` to `\operatorname{gcd}(a,b)` as per :func:`fmpq_gcd` and also compute `\overline{a} = a/g` and `\overline{b} = b/g`. + # Unlike :func:`fmpq_gcd`, this function requires canonical inputs. + + void _fmpq_add_small(fmpz_t rnum, fmpz_t rden, long p1, unsigned long q1, long p2, unsigned long q2) + # Sets ``(rnum, rden)`` to the sum of ``(p1, q1)`` and ``(p2, q2)``. + # Assumes that ``(p1, q1)`` and ``(p2, q2)`` are in canonical form + # and that all inputs are between ``COEFF_MIN`` and ``COEFF_MAX``. + + void _fmpq_mul_small(fmpz_t rnum, fmpz_t rden, long p1, unsigned long q1, long p2, unsigned long q2) + # Sets ``(rnum, rden)`` to the product of ``(p1, q1)`` and ``(p2, q2)``. + # Assumes that ``(p1, q1)`` and ``(p2, q2)`` are in canonical form + # and that all inputs are between ``COEFF_MIN`` and ``COEFF_MAX``. + + int _fmpq_mod_fmpz(fmpz_t res, const fmpz_t num, const fmpz_t den, const fmpz_t mod) + int fmpq_mod_fmpz(fmpz_t res, const fmpq_t x, const fmpz_t mod) + # Sets the integer ``res`` to the residue `a` of + # `x = n/d` = ``(num, den)`` modulo the positive integer `m` = ``mod``, + # defined as the `0 \le a < m` satisfying `n \equiv a d \pmod m`. + # If such an `a` exists, 1 will be returned, otherwise 0 will + # be returned. + + int _fmpq_reconstruct_fmpz_2_naive(fmpz_t n, fmpz_t d, const fmpz_t a, const fmpz_t m, const fmpz_t N, const fmpz_t D) + int _fmpq_reconstruct_fmpz_2(fmpz_t n, fmpz_t d, const fmpz_t a, const fmpz_t m, const fmpz_t N, const fmpz_t D) int fmpq_reconstruct_fmpz_2(fmpq_t res, const fmpz_t a, const fmpz_t m, const fmpz_t N, const fmpz_t D) - mp_bitcnt_t fmpq_height_bits(const fmpq_t x) - void fmpq_height(fmpz_t height, const fmpq_t x) - void fmpq_next_calkin_wilf(fmpq_t res, const fmpq_t x) - void fmpq_next_signed_calkin_wilf(fmpq_t res, const fmpq_t x) + # Reconstructs a rational number from its residue `a` modulo `m`. + # Given a modulus `m > 2`, a residue `0 \le a < m`, and positive `N, D` + # satisfying `2ND < m`, this function attempts to find a fraction `n/d` with + # `0 \le |n| \le N` and `0 < d \le D` such that `\gcd(n,d) = 1` and + # `n \equiv ad \pmod m`. If a solution exists, then it is also unique. + # The function returns 1 if successful, and 0 to indicate that no solution + # exists. + + int _fmpq_reconstruct_fmpz(fmpz_t n, fmpz_t d, const fmpz_t a, const fmpz_t m) + int fmpq_reconstruct_fmpz(fmpq_t res, const fmpz_t a, const fmpz_t m) + # Reconstructs a rational number from its residue `a` modulo `m`, + # returning 1 if successful and 0 if no solution exists. + # Uses the balanced bounds `N = D = \lfloor\sqrt{\frac{m-1}{2}}\rfloor`. + + void _fmpq_next_minimal(fmpz_t rnum, fmpz_t rden, const fmpz_t num, const fmpz_t den) void fmpq_next_minimal(fmpq_t res, const fmpq_t x) + # Given `x` which is assumed to be nonnegative and in canonical form, sets + # ``res`` to the next rational number in the sequence obtained by + # enumerating all positive denominators `q`, for each `q` enumerating + # the numerators `1 \le p < q` in order and generating both `p/q` and `q/p`, + # but skipping all `\gcd(p,q) \ne 1`. Starting with zero, this generates + # every nonnegative rational number once and only once, with the first + # few entries being: + # `0, 1, 1/2, 2, 1/3, 3, 2/3, 3/2, 1/4, 4, 3/4, 4/3, 1/5, 5, 2/5, \ldots.` + # This enumeration produces the rational numbers in order of + # minimal height. It has the disadvantage of being somewhat slower to + # compute than the Calkin-Wilf enumeration. + + void _fmpq_next_signed_minimal(fmpz_t rnum, fmpz_t rden, const fmpz_t num, const fmpz_t den) void fmpq_next_signed_minimal(fmpq_t res, const fmpq_t x) + # Given a signed rational number `x` assumed to be in canonical form, sets + # ``res`` to the next element in the minimal-height sequence + # generated by ``fmpq_next_minimal`` but with negative numbers + # interleaved: + # `0, 1, -1, 1/2, -1/2, 2, -2, 1/3, -1/3, \ldots.` + # Starting with zero, this generates every rational number once + # and only once, in order of minimal height. + + void _fmpq_next_calkin_wilf(fmpz_t rnum, fmpz_t rden, const fmpz_t num, const fmpz_t den) + void fmpq_next_calkin_wilf(fmpq_t res, const fmpq_t x) + # Given `x` which is assumed to be nonnegative and in canonical form, sets + # ``res`` to the next number in the breadth-first traversal of the + # Calkin-Wilf tree. Starting with zero, this generates every nonnegative + # rational number once and only once, with the first few entries being: + # `0, 1, 1/2, 2, 1/3, 3/2, 2/3, 3, 1/4, 4/3, 3/5, 5/2, 2/5, \ldots.` + # Despite the appearance of the initial entries, the Calkin-Wilf + # enumeration does not produce the rational numbers in order of height: + # some small fractions will appear late in the sequence. This order + # has the advantage of being faster to produce than the minimal-height + # order. + + void _fmpq_next_signed_calkin_wilf(fmpz_t rnum, fmpz_t rden, const fmpz_t num, const fmpz_t den) + void fmpq_next_signed_calkin_wilf(fmpq_t res, const fmpq_t x) + # Given a signed rational number `x` assumed to be in canonical form, sets + # ``res`` to the next element in the Calkin-Wilf sequence with + # negative numbers interleaved: + # `0, 1, -1, 1/2, -1/2, 2, -2, 1/3, -1/3, \ldots.` + # Starting with zero, this generates every rational number once + # and only once, but not in order of minimal height. + + void fmpq_farey_neighbors(fmpq_t l, fmpq_t r, const fmpq_t x, const fmpz_t Q) + # Set `l` and `r` to the fractions directly below and above `x` in the Farey sequence of order `Q`. + # This function will throw if `x` is not canonical or `Q` is less than the denominator of `x`. + + void fmpq_simplest_between(fmpq_t x, const fmpq_t l, const fmpq_t r) + void _fmpq_simplest_between(fmpz_t x_num, fmpz_t x_den, const fmpz_t l_num, const fmpz_t l_den, const fmpz_t r_num, const fmpz_t r_den) + # Set `x` to the simplest fraction in the closed interval `[l, r]`. The underscore version makes the additional assumption that `l \le r`. + # The endpoints `l` and `r` do not need to be reduced, but their denominators do need to be positive. + # `x` will always be returned in canonical form. A canonical fraction `a_1/b_1` is defined to be simpler than `a_2/b_2` iff `b_1 0`), ``rem`` will finite and the return is `0 < k \le n`. + # Essentially, if this function is called with canonical `x` and `n > 0`, then ``rem`` will be canonical. + # Therefore, applications relying on canonical ``fmpq_t``'s should not call this function with `n \le 0`. + void fmpq_set_cfrac(fmpq_t x, const fmpz * c, long n) + # Sets `x` to the value of the continued fraction + # .. math :: + # x = c_0 + \cfrac{1}{c_1 + \cfrac{1}{c_2 + + # \cfrac{1}{ \ddots + \cfrac{1}{c_{n-1}}}}} + # where all `c_i` except `c_0` should be nonnegative. + # It is assumed that `n > 0`. + # For large `n`, this function implements a subquadratic algorithm. + # The convergents are given by a chain product of 2 by 2 matrices. + # This product is split in half recursively to balance the size + # of the coefficients. + long fmpq_cfrac_bound(const fmpq_t x) - void fmpq_dedekind_sum_naive(fmpq_t s, const fmpz_t h, const fmpz_t k) - void fmpq_dedekind_sum_coprime_large(fmpq_t s, const fmpz_t h, const fmpz_t k) - double fmpq_dedekind_sum_coprime_d(double h, double k) - void fmpq_dedekind_sum_coprime(fmpq_t s, const fmpz_t h, const fmpz_t k) - void fmpq_dedekind_sum(fmpq_t s, const fmpz_t h, const fmpz_t k) + # Returns an upper bound for the number of terms in the continued + # fraction expansion of `x`. The computed bound is not necessarily sharp. + # We use the fact that the smallest denominator + # that can give a continued fraction of length `n` is the Fibonacci + # number `F_{n+1}`. + + void _fmpq_harmonic_ui(fmpz_t num, fmpz_t den, unsigned long n) void fmpq_harmonic_ui(fmpq_t x, unsigned long n) + # Computes the harmonic number `H_n = 1 + 1/2 + 1/3 + \dotsb + 1/n`. + # Table lookup is used for `H_n` whose numerator and denominator + # fit in single limb. For larger `n`, a divide and conquer strategy is used. + + void fmpq_dedekind_sum(fmpq_t s, const fmpz_t h, const fmpz_t k) + void fmpq_dedekind_sum_naive(fmpq_t s, const fmpz_t h, const fmpz_t k) + # Computes `s(h,k)` for arbitrary `h` and `k`. The naive version uses a straightforward + # implementation of the defining sum using ``fmpz`` arithmetic and is slow for large `k`. diff --git a/src/sage/libs/flint/fmpq_mat.pxd b/src/sage/libs/flint/fmpq_mat.pxd index ccd90c251a8..56f96157199 100644 --- a/src/sage/libs/flint/fmpq_mat.pxd +++ b/src/sage/libs/flint/fmpq_mat.pxd @@ -1,64 +1,386 @@ # distutils: libraries = flint # distutils: depends = flint/fmpq_mat.h -from sage.libs.flint.types cimport fmpz_t, fmpz, fmpq_t, fmpq, fmpz_mat_t, fmpq_mat_t, flint_rand_t, mp_bitcnt_t +################################################################################ +# This file is auto-generated. Do not modify by hand +################################################################################ + +from libc.stdio cimport FILE +from sage.libs.gmp.types cimport * +from sage.libs.mpfr.types cimport * +from sage.libs.flint.types cimport * -# flint/fmpq_mat.h cdef extern from "flint_wrap.h": + + void fmpq_mat_init(fmpq_mat_t mat, long rows, long cols) + # Initialises a matrix with the given number of rows and columns for use. + + void fmpq_mat_init_set(fmpq_mat_t mat1, const fmpq_mat_t mat2) + # Initialises ``mat1`` and sets it equal to ``mat2``. + + void fmpq_mat_clear(fmpq_mat_t mat) + # Frees all memory associated with the matrix. The matrix must be + # reinitialised if it is to be used again. + + void fmpq_mat_swap(fmpq_mat_t mat1, fmpq_mat_t mat2) + # Swaps two matrices. The dimensions of ``mat1`` and ``mat2`` + # are allowed to be different. + + void fmpq_mat_swap_entrywise(fmpq_mat_t mat1, fmpq_mat_t mat2) + # Swaps two matrices by swapping the individual entries rather than swapping + # the contents of the structs. + fmpq * fmpq_mat_entry(const fmpq_mat_t mat, long i, long j) + # Gives a reference to the entry at row ``i`` and column ``j``. + # The reference can be passed as an input or output variable to any + # ``fmpq`` function for direct manipulation of the matrix element. + # No bounds checking is performed. + fmpz * fmpq_mat_entry_num(const fmpq_mat_t mat, long i, long j) + # Gives a reference to the numerator of the entry at row ``i`` and + # column ``j``. The reference can be passed as an input or output + # variable to any ``fmpz`` function for direct manipulation of the + # matrix element. No bounds checking is performed. + fmpz * fmpq_mat_entry_den(const fmpq_mat_t mat, long i, long j) + # Gives a reference to the denominator of the entry at row ``i`` and + # column ``j``. The reference can be passed as an input or output + # variable to any ``fmpz`` function for direct manipulation of the + # matrix element. No bounds checking is performed. + long fmpq_mat_nrows(const fmpq_mat_t mat) + # Return the number of rows of the matrix ``mat``. + long fmpq_mat_ncols(const fmpq_mat_t mat) - void fmpq_mat_init(fmpq_mat_t mat, long rows, long cols) - void fmpq_mat_clear(fmpq_mat_t mat) - void fmpq_mat_swap(fmpq_mat_t mat1, fmpq_mat_t mat2) - void fmpq_mat_window_init(fmpq_mat_t window, const fmpq_mat_t mat, long r1, long c1, long r2, long c2) - void fmpq_mat_window_clear(fmpq_mat_t window) - void fmpq_mat_concat_horizontal(fmpq_mat_t res, const fmpq_mat_t mat1, const fmpq_mat_t mat2) - void fmpq_mat_concat_vertical(fmpq_mat_t res, const fmpq_mat_t mat1, const fmpq_mat_t mat2) - void fmpq_mat_print(const fmpq_mat_t mat) - void fmpq_mat_randbits(fmpq_mat_t mat, flint_rand_t state, mp_bitcnt_t bits) - void fmpq_mat_randtest(fmpq_mat_t mat, flint_rand_t state, mp_bitcnt_t bits) - void fmpq_mat_hilbert_matrix(fmpq_mat_t mat) + # Return the number of columns of the matrix ``mat``. + void fmpq_mat_set(fmpq_mat_t dest, const fmpq_mat_t src) + # Sets the entries in ``dest`` to the same values as in ``src``, + # assuming the two matrices have the same dimensions. + void fmpq_mat_zero(fmpq_mat_t mat) + # Sets ``mat`` to the zero matrix. + void fmpq_mat_one(fmpq_mat_t mat) + # Let `m` be the minimum of the number of rows and columns + # in the matrix ``mat``. This function sets the first + # `m \times m` block to the identity matrix, and the remaining + # block to zero. + void fmpq_mat_transpose(fmpq_mat_t rop, const fmpq_mat_t op) + # Sets the matrix ``rop`` to the transpose of the matrix ``op``, + # assuming that their dimensions are compatible. + + void fmpq_mat_swap_rows(fmpq_mat_t mat, long * perm, long r, long s) + # Swaps rows ``r`` and ``s`` of ``mat``. If ``perm`` is non-``NULL``, the + # permutation of the rows will also be applied to ``perm``. + + void fmpq_mat_swap_cols(fmpq_mat_t mat, long * perm, long r, long s) + # Swaps columns ``r`` and ``s`` of ``mat``. If ``perm`` is non-``NULL``, the + # permutation of the columns will also be applied to ``perm``. + + void fmpq_mat_invert_rows(fmpq_mat_t mat, long * perm) + # Swaps rows ``i`` and ``r - i`` of ``mat`` for ``0 <= i < r/2``, where + # ``r`` is the number of rows of ``mat``. If ``perm`` is non-``NULL``, the + # permutation of the rows will also be applied to ``perm``. + + void fmpq_mat_invert_cols(fmpq_mat_t mat, long * perm) + # Swaps columns ``i`` and ``c - i`` of ``mat`` for ``0 <= i < c/2``, where + # ``c`` is the number of columns of ``mat``. If ``perm`` is non-``NULL``, the + # permutation of the columns will also be applied to ``perm``. + void fmpq_mat_add(fmpq_mat_t mat, const fmpq_mat_t mat1, const fmpq_mat_t mat2) + # Sets ``mat`` to the sum of ``mat1`` and ``mat2``, + # assuming that all three matrices have the same dimensions. + void fmpq_mat_sub(fmpq_mat_t mat, const fmpq_mat_t mat1, const fmpq_mat_t mat2) + # Sets ``mat`` to the difference of ``mat1`` and ``mat2``, + # assuming that all three matrices have the same dimensions. + void fmpq_mat_neg(fmpq_mat_t rop, const fmpq_mat_t op) + # Sets ``rop`` to the negative of ``op``, assuming that + # the two matrices have the same dimensions. + + void fmpq_mat_scalar_mul_fmpq(fmpq_mat_t rop, const fmpq_mat_t op, const fmpq_t x) + # Sets ``rop`` to ``op`` multiplied by the rational `x`, + # assuming that the two matrices have the same dimensions. + # Note that the rational ``x`` may not be aliased with any part of the + # entries of ``rop``. + void fmpq_mat_scalar_mul_fmpz(fmpq_mat_t rop, const fmpq_mat_t op, const fmpz_t x) + # Sets ``rop`` to ``op`` multiplied by the integer `x`, + # assuming that the two matrices have the same dimensions. + # Note that the integer `x` may not be aliased with any part of + # the entries of ``rop``. + void fmpq_mat_scalar_div_fmpz(fmpq_mat_t rop, const fmpq_mat_t op, const fmpz_t x) - bint fmpq_mat_equal(const fmpq_mat_t mat1, const fmpq_mat_t mat2) - bint fmpq_mat_is_integral(const fmpq_mat_t mat) - bint fmpq_mat_is_zero(const fmpq_mat_t mat) - bint fmpq_mat_is_empty(const fmpq_mat_t mat) - bint fmpq_mat_is_square(const fmpq_mat_t mat) + # Sets ``rop`` to ``op`` divided by the integer `x`, + # assuming that the two matrices have the same dimensions + # and that `x` is non-zero. + # Note that the integer `x` may not be aliased with any part of + # the entries of ``rop``. + + void fmpq_mat_print(const fmpq_mat_t mat) + # Prints the matrix ``mat`` to standard output. + + void fmpq_mat_randbits(fmpq_mat_t mat, flint_rand_t state, flint_bitcnt_t bits) + # This is equivalent to applying ``fmpq_randbits`` to all entries + # in the matrix. + + void fmpq_mat_randtest(fmpq_mat_t mat, flint_rand_t state, flint_bitcnt_t bits) + # This is equivalent to applying ``fmpq_randtest`` to all entries + # in the matrix. + + void fmpq_mat_window_init(fmpq_mat_t window, const fmpq_mat_t mat, long r1, long c1, long r2, long c2) + # Initializes the matrix ``window`` to be an ``r2 - r1`` by + # ``c2 - c1`` submatrix of ``mat`` whose ``(0,0)`` entry + # is the ``(r1, c1)`` entry of ``mat``. The memory for the + # elements of ``window`` is shared with ``mat``. + + void fmpq_mat_window_clear(fmpq_mat_t window) + # Clears the matrix ``window`` and releases any memory that it + # uses. Note that the memory to the underlying matrix that + # ``window`` points to is not freed. + + void fmpq_mat_concat_vertical(fmpq_mat_t res, const fmpq_mat_t mat1, const fmpq_mat_t mat2) + # Sets ``res`` to vertical concatenation of (``mat1``, ``mat2``) in that order. Matrix dimensions: ``mat1``: `m \times n`, ``mat2``: `k \times n`, ``res``: `(m + k) \times n`. + + void fmpq_mat_concat_horizontal(fmpq_mat_t res, const fmpq_mat_t mat1, const fmpq_mat_t mat2) + # Sets ``res`` to horizontal concatenation of (``mat1``, ``mat2``) in that order. Matrix dimensions: ``mat1``: `m \times n`, ``mat2``: `m \times k`, ``res``: `m \times (n + k)`. + + void fmpq_mat_hilbert_matrix(fmpq_mat_t mat) + # Sets ``mat`` to a Hilbert matrix of the given size. That is, + # the entry at row `i` and column `j` is set to `1/(i+j+1)`. + + int fmpq_mat_equal(const fmpq_mat_t mat1, const fmpq_mat_t mat2) + # Returns nonzero if ``mat1`` and ``mat2`` have the same shape and + # all their entries agree, and returns zero otherwise. Assumes the + # entries in both ``mat1`` and ``mat2`` are in canonical form. + + int fmpq_mat_is_integral(const fmpq_mat_t mat) + # Returns nonzero if all entries in ``mat`` are integer-valued, and + # returns zero otherwise. Assumes that the entries in ``mat`` + # are in canonical form. + + int fmpq_mat_is_zero(const fmpq_mat_t mat) + # Returns nonzero if all entries in ``mat`` are zero, and returns + # zero otherwise. + + int fmpq_mat_is_one(const fmpq_mat_t mat) + # Returns nonzero if ``mat`` ones along the diagonal and zeros elsewhere, + # and returns zero otherwise. + + int fmpq_mat_is_empty(const fmpq_mat_t mat) + # Returns a non-zero value if the number of rows or the number of + # columns in ``mat`` is zero, and otherwise returns + # zero. + + int fmpq_mat_is_square(const fmpq_mat_t mat) + # Returns a non-zero value if the number of rows is equal to the + # number of columns in ``mat``, and otherwise returns zero. + int fmpq_mat_get_fmpz_mat(fmpz_mat_t dest, const fmpq_mat_t mat) + # Sets ``dest`` to ``mat`` and returns nonzero if all entries + # in ``mat`` are integer-valued. If not all entries in ``mat`` + # are integer-valued, sets ``dest`` to an undefined matrix + # and returns zero. Assumes that the entries in ``mat`` are + # in canonical form. + void fmpq_mat_get_fmpz_mat_entrywise(fmpz_mat_t num, fmpz_mat_t den, const fmpq_mat_t mat) + # Sets the integer matrices ``num`` and ``den`` respectively + # to the numerators and denominators of the entries in ``mat``. + void fmpq_mat_get_fmpz_mat_matwise(fmpz_mat_t num, fmpz_t den, const fmpq_mat_t mat) + # Converts all entries in ``mat`` to a common denominator, + # storing the rescaled numerators in ``num`` and the + # denominator in ``den``. The denominator will be minimal + # if the entries in ``mat`` are in canonical form. + void fmpq_mat_get_fmpz_mat_rowwise(fmpz_mat_t num, fmpz * den, const fmpq_mat_t mat) - void fmpq_mat_get_fmpz_mat_colwise(fmpz_mat_t num, fmpz * den, const fmpq_mat_t mat) + # Clears denominators in ``mat`` row by row. The rescaled + # numerators are written to ``num``, and the denominator + # of row ``i`` is written to position ``i`` in ``den`` + # which can be a preinitialised ``fmpz`` vector. Alternatively, + # ``NULL`` can be passed as the ``den`` variable, in which + # case the denominators will not be stored. + void fmpq_mat_get_fmpz_mat_rowwise_2(fmpz_mat_t num, fmpz_mat_t num2, fmpz * den, const fmpq_mat_t mat, const fmpq_mat_t mat2) - void fmpq_mat_get_fmpz_mat_mod_fmpz(fmpz_mat_t dest, const fmpq_mat_t mat, const fmpz_t mod) + # Clears denominators row by row of both ``mat`` and ``mat2``, + # writing the respective numerators to ``num`` and ``num2``. + # This is equivalent to concatenating ``mat`` and ``mat2`` + # horizontally, calling ``fmpq_mat_get_fmpz_mat_rowwise``, + # and extracting the two submatrices in the result. + + void fmpq_mat_get_fmpz_mat_colwise(fmpz_mat_t num, fmpz * den, const fmpq_mat_t mat) + # Clears denominators in ``mat`` column by column. The rescaled + # numerators are written to ``num``, and the denominator + # of column ``i`` is written to position ``i`` in ``den`` + # which can be a preinitialised ``fmpz`` vector. Alternatively, + # ``NULL`` can be passed as the ``den`` variable, in which + # case the denominators will not be stored. + void fmpq_mat_set_fmpz_mat(fmpq_mat_t dest, const fmpz_mat_t src) - void fmpq_mat_set_fmpz_mat_div_fmpz(fmpq_mat_t X, const fmpz_mat_t Xmod, const fmpz_t div) + # Sets ``dest`` to ``src``. + + void fmpq_mat_set_fmpz_mat_div_fmpz(fmpq_mat_t mat, const fmpz_mat_t num, const fmpz_t den) + # Sets ``mat`` to the integer matrix ``num`` divided by the + # common denominator ``den``. + + void fmpq_mat_get_fmpz_mat_mod_fmpz(fmpz_mat_t dest, const fmpq_mat_t mat, const fmpz_t mod) + # Sets each entry in ``dest`` to the corresponding entry in ``mat``, + # reduced modulo ``mod``. + int fmpq_mat_set_fmpz_mat_mod_fmpz(fmpq_mat_t X, const fmpz_mat_t Xmod, const fmpz_t mod) + # Sets ``X`` to the entrywise rational reconstruction integer matrix + # ``Xmod`` modulo ``mod``, and returns nonzero if the reconstruction + # is successful. If rational reconstruction fails for any element, + # returns zero and sets the entries in ``X`` to undefined values. + void fmpq_mat_mul_direct(fmpq_mat_t C, const fmpq_mat_t A, const fmpq_mat_t B) + # Sets ``C`` to the matrix product ``AB``, computed + # naively using rational arithmetic. This is typically very slow and + # should only be used in circumstances where clearing denominators + # would consume too much memory. + void fmpq_mat_mul_cleared(fmpq_mat_t C, const fmpq_mat_t A, const fmpq_mat_t B) + # Sets ``C`` to the matrix product ``AB``, computed + # by clearing denominators and multiplying over the integers. + void fmpq_mat_mul(fmpq_mat_t C, const fmpq_mat_t A, const fmpq_mat_t B) + # Sets ``C`` to the matrix product ``AB``. This + # simply calls ``fmpq_mat_mul_cleared``. + void fmpq_mat_mul_fmpz_mat(fmpq_mat_t C, const fmpq_mat_t A, const fmpz_mat_t B) + # Sets ``C`` to the matrix product ``AB``, with ``B`` + # an integer matrix. This function works efficiently by clearing + # denominators of ``A``. + void fmpq_mat_mul_r_fmpz_mat(fmpq_mat_t C, const fmpz_mat_t A, const fmpq_mat_t B) + # Sets ``C`` to the matrix product ``AB``, with ``A`` + # an integer matrix. This function works efficiently by clearing + # denominators of ``B``. + + void fmpq_mat_mul_fmpq_vec(fmpq * c, const fmpq_mat_t A, const fmpq * b, long blen) + void fmpq_mat_mul_fmpz_vec(fmpq * c, const fmpq_mat_t A, const fmpz * b, long blen) + void fmpq_mat_mul_fmpq_vec_ptr(fmpq * const * c, const fmpq_mat_t A, const fmpq * const * b, long blen) + void fmpq_mat_mul_fmpz_vec_ptr(fmpq * const * c, const fmpq_mat_t A, const fmpz * const * b, long blen) + # Compute a matrix-vector product of ``A`` and ``(b, blen)`` and store the result in ``c``. + # The vector ``(b, blen)`` is either truncated or zero-extended to the number of columns of ``A``. + # The number entries written to ``c`` is always equal to the number of rows of ``A``. + + void fmpq_mat_fmpq_vec_mul(fmpq * c, const fmpq * a, long alen, const fmpq_mat_t B) + void fmpq_mat_fmpz_vec_mul(fmpq * c, const fmpz * a, long alen, const fmpq_mat_t B) + void fmpq_mat_fmpq_vec_mul_ptr(fmpq * const * c, const fmpq * const * a, long alen, const fmpq_mat_t B) + void fmpq_mat_fmpz_vec_mul_ptr(fmpq * const * c, const fmpz * const * a, long alen, const fmpq_mat_t B) + # Compute a vector-matrix product of ``(a, alen)`` and ``B`` and and store the result in ``c``. + # The vector ``(a, alen)`` is either truncated or zero-extended to the number of rows of ``B``. + # The number entries written to ``c`` is always equal to the number of columns of ``B``. + + void fmpq_mat_kronecker_product(fmpq_mat_t C, const fmpq_mat_t A, const fmpq_mat_t B) + # Sets ``C`` to the Kronecker product of ``A`` and ``B``. + void fmpq_mat_trace(fmpq_t trace, const fmpq_mat_t mat) + # Computes the trace of the matrix, i.e. the sum of the entries on + # the main diagonal. The matrix is required to be square. + void fmpq_mat_det(fmpq_t det, const fmpq_mat_t mat) + # Sets ``det`` to the determinant of ``mat``. In the general case, + # the determinant is computed by clearing denominators and computing a + # determinant over the integers. Matrices of size 0, 1 or 2 are handled + # directly. + int fmpq_mat_solve_fraction_free(fmpq_mat_t X, const fmpq_mat_t A, const fmpq_mat_t B) int fmpq_mat_solve_dixon(fmpq_mat_t X, const fmpq_mat_t A, const fmpq_mat_t B) + int fmpq_mat_solve_multi_mod(fmpq_mat_t X, const fmpq_mat_t A, const fmpq_mat_t B) + int fmpq_mat_solve(fmpq_mat_t X, const fmpq_mat_t A, const fmpq_mat_t B) + # Solves ``AX = B`` for nonsingular ``A``. + # Returns nonzero if ``A`` is nonsingular or if the right hand side + # is empty, and zero otherwise. + # All algorithms clear denominators to obtain a rescaled system over the integers. + # The *fraction_free* algorithm uses FFLU solving over the integers. + # The *dixon* and *multi_mod* algorithms use Dixon p-adic lifting + # or multimodular solving, followed by rational reconstruction + # with an adaptive stopping test. The *dixon* and *multi_mod* algorithms + # are generally the best choice for large systems. + # The default method chooses an algorithm automatically. + + int fmpq_mat_solve_fmpz_mat_fraction_free(fmpq_mat_t X, const fmpz_mat_t A, const fmpz_mat_t B) + int fmpq_mat_solve_fmpz_mat_dixon(fmpq_mat_t X, const fmpz_mat_t A, const fmpz_mat_t B) + int fmpq_mat_solve_fmpz_mat_multi_mod(fmpq_mat_t X, const fmpz_mat_t A, const fmpz_mat_t B) int fmpq_mat_solve_fmpz_mat(fmpq_mat_t X, const fmpz_mat_t A, const fmpz_mat_t B) + # Solves ``AX = B`` for nonsingular ``A``, where *A* and *B* are integer + # matrices. Returns nonzero if ``A`` is nonsingular or if the right hand side + # is empty, and zero otherwise. + + int fmpq_mat_can_solve_multi_mod(fmpq_mat_t X, const fmpq_mat_t A, const fmpq_mat_t B) + # Returns `1` if ``AX = B`` has a solution and if so, sets ``X`` to one such + # solution. The matrices can have any shape but must have the same number of + # rows. + + int fmpq_mat_can_solve_fraction_free(fmpq_mat_t X, const fmpq_mat_t A, const fmpq_mat_t B) + # Returns `1` if ``AX = B`` has a solution and if so, sets ``X`` to one such + # solution. The matrices can have any shape but must have the same number of + # rows. + + int fmpq_mat_can_solve(fmpq_mat_t X, const fmpq_mat_t A, const fmpq_mat_t B) + # Returns `1` if ``AX = B`` has a solution and if so, sets ``X`` to one such + # solution. The matrices can have any shape but must have the same number of + # rows. + int fmpq_mat_inv(fmpq_mat_t B, const fmpq_mat_t A) + # Sets ``B`` to the inverse matrix of ``A`` and returns nonzero. + # Returns zero if ``A`` is singular. ``A`` must be a square matrix. + int fmpq_mat_pivot(long * perm, fmpq_mat_t mat, long r, long c) + # Helper function for row reduction. Returns 1 if the entry of ``mat`` + # at row `r` and column `c` is nonzero. Otherwise searches for a nonzero + # entry in the same column among rows `r+1, r+2, \ldots`. If a nonzero + # entry is found at row `s`, swaps rows `r` and `s` and the corresponding + # entries in ``perm`` (unless ``NULL``) and returns -1. If no + # nonzero pivot entry is found, leaves the inputs unchanged and returns 0. + long fmpq_mat_rref_classical(fmpq_mat_t B, const fmpq_mat_t A) + # Sets ``B`` to the reduced row echelon form of ``A`` and returns + # the rank. Performs Gauss-Jordan elimination directly over the rational + # numbers. This algorithm is usually inefficient and is mainly intended + # to be used for testing purposes. + long fmpq_mat_rref_fraction_free(fmpq_mat_t B, const fmpq_mat_t A) + # Sets ``B`` to the reduced row echelon form of ``A`` and returns + # the rank. Clears denominators and performs fraction-free Gauss-Jordan + # elimination using ``fmpz_mat`` functions. + long fmpq_mat_rref(fmpq_mat_t B, const fmpq_mat_t A) + # Sets ``B`` to the reduced row echelon form of ``A`` and returns + # the rank. This function automatically chooses between the classical and + # fraction-free algorithms depending on the size of the matrix. + void fmpq_mat_gso(fmpq_mat_t B, const fmpq_mat_t A) + # Takes a subset of `\mathbb{Q}^m` `S = \{a_1, a_2, \ldots ,a_n\}` (as the + # columns of a `m \times n` matrix ``A``) and generates an orthogonal set + # `S' = \{b_1, b_2, \ldots ,b_n\}` (as the columns of the `m \times n` matrix + # ``B``) that spans the same subspace of `\mathbb{Q}^m` as `S`. + + void fmpq_mat_similarity(fmpq_mat_t A, long r, fmpq_t d) + # Applies a similarity transform to the `n\times n` matrix `M` in-place. + # If `P` is the `n\times n` identity matrix the zero entries of whose row + # `r` (`0`-indexed) have been replaced by `d`, this transform is equivalent + # to `M = P^{-1}MP`. + # Similarity transforms preserve the determinant, characteristic polynomial + # and minimal polynomial. + + void _fmpq_mat_charpoly(fmpz * coeffs, fmpz_t den, const fmpq_mat_t mat) + # Set ``(coeffs, den)`` to the characteristic polynomial of the given + # `n\times n` matrix. + + void fmpq_mat_charpoly(fmpq_poly_t pol, const fmpq_mat_t mat) + # Set ``pol`` to the characteristic polynomial of the given `n\times n` + # matrix. If ``mat`` is not square, an exception is raised. + + long _fmpq_mat_minpoly(fmpz * coeffs, fmpz_t den, const fmpq_mat_t mat) + # Set ``(coeffs, den)`` to the minimal polynomial of the given + # `n\times n` matrix and return the length of the polynomial. + void fmpq_mat_minpoly(fmpq_poly_t pol, const fmpq_mat_t mat) + # Set ``pol`` to the minimal polynomial of the given `n\times n` + # matrix. If ``mat`` is not square, an exception is raised. diff --git a/src/sage/libs/flint/fmpz.pxd b/src/sage/libs/flint/fmpz.pxd index b97fbe1eae0..f260cc6a2a4 100644 --- a/src/sage/libs/flint/fmpz.pxd +++ b/src/sage/libs/flint/fmpz.pxd @@ -1,195 +1,1126 @@ # distutils: libraries = flint # distutils: depends = flint/fmpz.h +################################################################################ +# This file is auto-generated. Do not modify by hand +################################################################################ + from libc.stdio cimport FILE -from sage.libs.gmp.types cimport mpz_t +from sage.libs.gmp.types cimport * +from sage.libs.mpfr.types cimport * from sage.libs.flint.types cimport * -# flint/fmpz.h cdef extern from "flint_wrap.h": - # Memory management - void fmpz_init(fmpz_t) - void fmpz_init2(fmpz_t, ulong limbs) - void fmpz_clear(fmpz_t) + fmpz PTR_TO_COEFF(__mpz_struct * ptr) + + __mpz_struct * COEFF_TO_PTR(fmpz f) + + int COEFF_IS_MPZ(fmpz f) + + __mpz_struct * _fmpz_new_mpz() + + void _fmpz_clear_mpz(fmpz f) + + void _fmpz_cleanup_mpz_content() + + void _fmpz_cleanup() + + __mpz_struct * _fmpz_promote(fmpz_t f) + + __mpz_struct * _fmpz_promote_val(fmpz_t f) + + void _fmpz_demote(fmpz_t f) + + void _fmpz_demote_val(fmpz_t f) + + void fmpz_init(fmpz_t f) + # A small ``fmpz_t`` is initialised, i.e. just a ``slong``. + # The value is set to zero. + + void fmpz_init2(fmpz_t f, unsigned long limbs) + # Initialises the given ``fmpz_t`` to have space for the given + # number of limbs. + # If ``limbs`` is zero then a small ``fmpz_t`` is allocated, + # i.e. just a ``slong``. The value is also set to zero. It is + # not necessary to call this function except to save time. A call + # to ``fmpz_init`` will do just fine. + + void fmpz_clear(fmpz_t f) + # Clears the given ``fmpz_t``, releasing any memory associated + # with it, either back to the stack or the OS, depending on + # whether the reentrant or non-reentrant version of FLINT is built. + + void fmpz_init_set(fmpz_t f, const fmpz_t g) + + void fmpz_init_set_ui(fmpz_t f, unsigned long g) + + void fmpz_init_set_si(fmpz_t f, long g) + # Initialises `f` and sets it to the value of `g`. + + void fmpz_randbits(fmpz_t f, flint_rand_t state, flint_bitcnt_t bits) + # Generates a random signed integer whose absolute value has precisely + # the given number of bits. + + void fmpz_randtest(fmpz_t f, flint_rand_t state, flint_bitcnt_t bits) + # Generates a random signed integer whose absolute value has a number + # of bits which is random from `0` up to ``bits`` inclusive. + + void fmpz_randtest_unsigned(fmpz_t f, flint_rand_t state, flint_bitcnt_t bits) + # Generates a random unsigned integer whose value has a number + # of bits which is random from `0` up to ``bits`` inclusive. + + void fmpz_randtest_not_zero(fmpz_t f, flint_rand_t state, flint_bitcnt_t bits) + # As per ``fmpz_randtest``, but the result will not be `0`. + # If ``bits`` is set to `0`, an exception will result. + + void fmpz_randm(fmpz_t f, flint_rand_t state, const fmpz_t m) + # Generates a random integer in the range `0` to `m - 1` inclusive. + + void fmpz_randtest_mod(fmpz_t f, flint_rand_t state, const fmpz_t m) + # Generates a random integer in the range `0` to `m - 1` inclusive, + # with an increased probability of generating values close to + # the endpoints. + + void fmpz_randtest_mod_signed(fmpz_t f, flint_rand_t state, const fmpz_t m) + # Generates a random integer in the range `(-m/2, m/2]`, with an + # increased probability of generating values close to the + # endpoints or close to zero. + + void fmpz_randprime(fmpz_t f, flint_rand_t state, flint_bitcnt_t bits, int proved) + # Generates a random prime number with the given number of bits. + # The generation is performed by choosing a random number and then + # finding the next largest prime, and therefore does not quite + # give a uniform distribution over the set of primes with that + # many bits. + # Random number generation is performed using the standard Flint + # random number generator, which is not suitable for cryptographic use. + # If ``proved`` is nonzero, then the integer returned is + # guaranteed to actually be prime. + + long fmpz_get_si(const fmpz_t f) + # Returns `f` as a ``slong``. The result is undefined + # if `f` does not fit into a ``slong``. + + unsigned long fmpz_get_ui(const fmpz_t f) + # Returns `f` as an ``ulong``. The result is undefined + # if `f` does not fit into an ``ulong`` or is negative. + + void fmpz_get_uiui(mp_limb_t * hi, mp_limb_t * low, const fmpz_t f) + # If `f` consists of two limbs, then ``*hi`` and ``*low`` are set to the high + # and low limbs, otherwise ``*low`` is set to the low limb and ``*hi`` is set + # to `0`. + + mp_limb_t fmpz_get_nmod(const fmpz_t f, nmod_t mod) + # Returns `f \mod n`. + + double fmpz_get_d(const fmpz_t f) + # Returns `f` as a ``double``, rounding down towards zero if + # `f` cannot be represented exactly. The outcome is undefined + # if `f` is too large to fit in the normal range of a double. + + void fmpz_set_mpf(fmpz_t f, const mpf_t x) + # Sets `f` to the ``mpf_t`` `x`, rounding down towards zero if + # the value of `x` is fractional. + + void fmpz_get_mpf(mpf_t x, const fmpz_t f) + # Sets the value of the ``mpf_t`` `x` to the value of `f`. + + void fmpz_get_mpfr(mpfr_t x, const fmpz_t f, mpfr_rnd_t rnd) + # Sets the value of `x` from `f`, rounded toward the given + # direction ``rnd``. + # **Note:** Requires that ``mpfr.h`` has been included before any FLINT + # header is included. + + double fmpz_get_d_2exp(long * exp, const fmpz_t f) + # Returns `f` as a normalized ``double`` along with a `2`-exponent + # ``exp``, i.e. if `r` is the return value then `f = r 2^{exp}`, + # to within 1 ULP. + + void fmpz_get_mpz(mpz_t x, const fmpz_t f) + # Sets the ``mpz_t`` `x` to the same value as `f`. + + int fmpz_get_mpn(mp_ptr *n, fmpz_t n_in) + # Sets the ``mp_ptr`` `n` to the same value as `n_{in}`. Returned + # integer is number of limbs allocated to `n`, minimum number of limbs + # required to hold the value stored in `n_{in}`. + + char * fmpz_get_str(char * str, int b, const fmpz_t f) + # Returns the representation of `f` in base `b`, which can vary + # between `2` and `62`, inclusive. + # If ``str`` is ``NULL``, the result string is allocated by + # the function. Otherwise, it is up to the caller to ensure that + # the allocated block of memory is sufficiently large. + + void fmpz_set_si(fmpz_t f, long val) + # Sets `f` to the given ``slong`` value. + + void fmpz_set_ui(fmpz_t f, unsigned long val) + # Sets `f` to the given ``ulong`` value. + + void fmpz_set_d(fmpz_t f, double c) + # Sets `f` to the ``double`` `c`, rounding down towards zero if + # the value of `c` is fractional. The outcome is undefined if `c` is + # infinite, not-a-number, or subnormal. + + void fmpz_set_d_2exp(fmpz_t f, double d, long exp) + # Sets `f` to the nearest integer to `d 2^{exp}`. + + void fmpz_neg_ui(fmpz_t f, unsigned long val) + # Sets `f` to the given ``ulong`` value, and then negates `f`. + + void fmpz_set_uiui(fmpz_t f, mp_limb_t hi, mp_limb_t lo) + # Sets `f` to ``lo``, plus ``hi`` shifted to the left by + # ``FLINT_BITS``. - void fmpz_init_set(fmpz_t, fmpz_t) - void fmpz_init_set_ui(fmpz_t, ulong) + void fmpz_neg_uiui(fmpz_t f, mp_limb_t hi, mp_limb_t lo) + # Sets `f` to ``lo``, plus ``hi`` shifted to the left by + # ``FLINT_BITS``, and then negates `f`. - void fmpz_init_set_readonly(fmpz_t, const mpz_t) - void fmpz_clear_readonly(fmpz_t) + void fmpz_set_signed_uiui(fmpz_t f, unsigned long hi, unsigned long lo) + # Sets `f` to ``lo``, plus ``hi`` shifted to the left by + # ``FLINT_BITS``, interpreted as a signed two's complement + # integer with ``2 * FLINT_BITS`` bits. - # Conversion - void fmpz_set(fmpz_t f, fmpz_t g) - void fmpz_set_ui(fmpz_t, ulong) - void fmpz_neg_ui(fmpz_t, ulong) - ulong fmpz_get_ui(fmpz_t) + void fmpz_set_signed_uiuiui(fmpz_t f, unsigned long hi, unsigned long mid, unsigned long lo) + # Sets `f` to ``lo``, plus ``mid`` shifted to the left by + # ``FLINT_BITS``, plus ``hi`` shifted to the left by + # ``2*FLINT_BITS`` bits, interpreted as a signed two's complement + # integer with ``3 * FLINT_BITS`` bits. - void fmpz_set_si(fmpz_t, slong) - slong fmpz_get_si(fmpz_t) + void fmpz_set_ui_array(fmpz_t out, const unsigned long * input, long n) + # Sets ``out`` to the nonnegative integer + # ``in[0] + in[1]*X + ... + in[n - 1]*X^(n - 1)`` + # where ``X = 2^FLINT_BITS``. It is assumed that ``n > 0``. - void fmpz_set_d(fmpz_t, double) - double fmpz_get_d(fmpz_t) - double fmpz_get_d_2exp(slong *, fmpz_t) + void fmpz_set_signed_ui_array(fmpz_t out, const unsigned long * input, long n) + # Sets ``out`` to the integer represented in ``in[0], ..., in[n - 1]`` + # as a signed two's complement integer with ``n * FLINT_BITS`` bits. + # It is assumed that ``n > 0``. The function operates as a call to + # :func:`fmpz_set_ui_array` followed by a symmetric remainder modulo + # `2^{n\cdot FLINT\_BITS}`. - void fmpz_set_mpz(fmpz_t, mpz_t) - void fmpz_get_mpz(mpz_t, fmpz_t) + void fmpz_get_ui_array(unsigned long * out, long n, const fmpz_t input) + # Assuming that the nonnegative integer ``in`` can be represented in the + # form ``out[0] + out[1]*X + ... + out[n - 1]*X^(n - 1)``, + # where `X = 2^{FLINT\_BITS}`, sets the corresponding elements of ``out`` + # so that this is true. It is assumed that ``n > 0``. - int fmpz_set_str(fmpz_t, char *, int) - char *fmpz_get_str(char *, int, fmpz_t) + void fmpz_get_signed_ui_array(unsigned long * out, long n, const fmpz_t input) + # Retrieves the value of `in` modulo `2^{n * FLINT\_BITS}` and puts the `n` + # words of the result in ``out[0], ..., out[n-1]``. This will give a signed + # two's complement representation of `in` (assuming `in` doesn't overflow the array). - void fmpz_set_uiui(fmpz_t, mp_limb_t, mp_limb_t) - void fmpz_neg_uiui(fmpz_t, mp_limb_t, mp_limb_t) - void fmpz_set_ui_smod(fmpz_t, mp_limb_t, mp_limb_t) + void fmpz_get_signed_uiui(unsigned long * hi, unsigned long * lo, const fmpz_t input) + # Retrieves the value of `in` modulo `2^{2 * FLINT\_BITS}` and puts the high + # and low words into ``*hi`` and ``*lo`` respectively. - void flint_mpz_init_set_readonly(mpz_t, fmpz_t) - void flint_mpz_clear_readonly(mpz_t) + void fmpz_set_mpz(fmpz_t f, const mpz_t x) + # Sets `f` to the given ``mpz_t`` value. - void fmpz_init_set_readonly(fmpz_t, mpz_t) - void fmpz_clear_readonly(fmpz_t) + int fmpz_set_str(fmpz_t f, const char * str, int b) + # Sets `f` to the value given in the null-terminated string ``str``, + # in base `b`. The base `b` can vary between `2` and `62`, inclusive. + # Returns `0` if the string contains a valid input and `-1` otherwise. + + void fmpz_set_ui_smod(fmpz_t f, mp_limb_t x, mp_limb_t m) + # Sets `f` to the signed remainder `y \equiv x \bmod m` satisfying + # `-m/2 < y \leq m/2`, given `x` which is assumed to satisfy + # `0 \leq x < m`. + + void flint_mpz_init_set_readonly(mpz_t z, const fmpz_t f) + # Sets the uninitialised ``mpz_t`` `z` to the value of the + # readonly ``fmpz_t`` `f`. + # Note that it is assumed that `f` does not change during + # the lifetime of `z`. + # The integer `z` has to be cleared by a call to + # :func:`flint_mpz_clear_readonly`. + # The suggested use of the two functions is as follows:: + # fmpz_t f; + # ... + # { + # mpz_t z; + # flint_mpz_init_set_readonly(z, f); + # foo(..., z); + # flint_mpz_clear_readonly(z); + # } + # This provides a convenient function for user code, only + # requiring to work with the types ``fmpz_t`` and ``mpz_t``. + # In critical code, the following approach may be favourable:: + # fmpz_t f; + # ... + # { + # __mpz_struct *z; + # z = _fmpz_promote_val(f); + # foo(..., z); + # _fmpz_demote_val(f); + # } + + void flint_mpz_clear_readonly(mpz_t z) + # Clears the readonly ``mpz_t`` `z`. + + void fmpz_init_set_readonly(fmpz_t f, const mpz_t z) + # Sets the uninitialised ``fmpz_t`` `f` to a readonly + # version of the integer `z`. + # Note that the value of `z` is assumed to remain constant + # throughout the lifetime of `f`. + # The ``fmpz_t`` `f` has to be cleared by calling the + # function :func:`fmpz_clear_readonly`. + # The suggested use of the two functions is as follows:: + # mpz_t z; + # ... + # { + # fmpz_t f; + # fmpz_init_set_readonly(f, z); + # foo(..., f); + # fmpz_clear_readonly(f); + # } + + void fmpz_clear_readonly(fmpz_t f) + # Clears the readonly ``fmpz_t`` `f`. + + int fmpz_read(fmpz_t f) + # Reads a multiprecision integer from ``stdin``. The format is + # an optional minus sign, followed by one or more digits. The + # first digit should be non-zero unless it is the only digit. + # In case of success, returns a positive number. In case of failure, + # returns a non-positive number. + # This convention is adopted in light of the return values of + # ``scanf`` from the standard library and ``mpz_inp_str`` + # from MPIR. + + int fmpz_fread(FILE * file, fmpz_t f) + # Reads a multiprecision integer from the stream ``file``. The + # format is an optional minus sign, followed by one or more digits. + # The first digit should be non-zero unless it is the only digit. + # In case of success, returns a positive number. In case of failure, + # returns a non-positive number. + # This convention is adopted in light of the return values of + # ``scanf`` from the standard library and ``mpz_inp_str`` + # from MPIR. + + size_t fmpz_inp_raw(fmpz_t x, FILE *fin ) + # Reads a multiprecision integer from the stream ``file``. The + # format is raw binary format write by :func:`fmpz_out_raw`. + # In case of success, return a positive number, indicating number of bytes read. + # In case of failure 0. + # This function calls the ``mpz_inp_raw`` function in library gmp. So that it + # can read the raw data written by ``mpz_inp_raw`` directly. + + int fmpz_print(const fmpz_t x) + # Prints the value `x` to ``stdout``, without a carriage return (CR). + # The value is printed as either `0`, the decimal digits of a + # positive integer, or a minus sign followed by the digits of + # a negative integer. + # In case of success, returns a positive number. In case of failure, + # returns a non-positive number. + # This convention is adopted in light of the return values of + # ``flint_printf`` from the standard library and ``mpz_out_str`` + # from MPIR. + + int fmpz_fprint(FILE * file, const fmpz_t x) + # Prints the value `x` to ``file``, without a carriage return (CR). + # The value is printed as either `0`, the decimal digits of a + # positive integer, or a minus sign followed by the digits of + # a negative integer. + # In case of success, returns a positive number. In case of failure, + # returns a non-positive number. + # This convention is adopted in light of the return values of + # ``flint_printf`` from the standard library and ``mpz_out_str`` + # from MPIR. + + size_t fmpz_out_raw(FILE *fout, const fmpz_t x ) + # Writes the value `x` to ``file``. + # The value is written in raw binary format. The integer is written in + # portable format, with 4 bytes of size information, and that many bytes + # of limbs. Both the size and the limbs are written in decreasing + # significance order (i.e., in big-endian). + # The output can be read with ``fmpz_inp_raw``. + # In case of success, return a positive number, indicating number of bytes written. + # In case of failure, return 0. + # The output of this can also be read by ``mpz_inp_raw`` from GMP >= 2, + # since this function calls the ``mpz_inp_raw`` function in library gmp. + + size_t fmpz_sizeinbase(const fmpz_t f, int b) + # Returns the size of the absolute value of `f` in base `b`, measured in + # numbers of digits. The base `b` can be between `2` and `62`, inclusive. + + flint_bitcnt_t fmpz_bits(const fmpz_t f) + # Returns the number of bits required to store the absolute + # value of `f`. If `f` is `0` then `0` is returned. + + mp_size_t fmpz_size(const fmpz_t f) + # Returns the number of limbs required to store the absolute + # value of `f`. If `f` is zero then `0` is returned. + + int fmpz_sgn(const fmpz_t f) + # Returns `-1` if the sign of `f` is negative, `+1` if it is positive, + # otherwise returns `0`. + + flint_bitcnt_t fmpz_val2(const fmpz_t f) + # Returns the exponent of the largest power of two dividing `f`, or + # equivalently the number of trailing zeros in the binary expansion of `f`. + # If `f` is zero then `0` is returned. + + void fmpz_swap(fmpz_t f, fmpz_t g) + # Efficiently swaps `f` and `g`. No data is copied. + + void fmpz_set(fmpz_t f, const fmpz_t g) + # Sets `f` to the same value as `g`. - int fmpz_abs_fits_ui(fmpz_t f) - int fmpz_fits_si(fmpz_t f) void fmpz_zero(fmpz_t f) + # Sets `f` to zero. + void fmpz_one(fmpz_t f) - void fmpz_setbit(fmpz_t f, ulong i) - int fmpz_tstbit(fmpz_t f, ulong i) + # Sets `f` to one. - # Input and output - int fmpz_read(fmpz_t) - int fmpz_fread(FILE *, fmpz_t) - size_t fmpz_inp_raw(fmpz_t, FILE *) + int fmpz_abs_fits_ui(const fmpz_t f) + # Returns whether the absolute value of `f` + # fits into an ``ulong``. - int fmpz_print(fmpz_t) - int fmpz_fprint(FILE *, fmpz_t) - size_t fmpz_out_raw(FILE *, fmpz_t) + int fmpz_fits_si(const fmpz_t f) + # Returns whether the value of `f` fits into a ``slong``. - size_t fmpz_sizeinbase(fmpz_t f, int b) + void fmpz_setbit(fmpz_t f, unsigned long i) + # Sets bit index `i` of `f`. - # Comparison - int fmpz_cmp(fmpz_t, fmpz_t) - int fmpz_cmp_ui(fmpz_t, ulong) - int fmpz_cmp_si(fmpz_t, slong) + int fmpz_tstbit(const fmpz_t f, unsigned long i) + # Test bit index `i` of `f` and return `0` or `1`, accordingly. - int fmpz_sgn(fmpz_t f) - int fmpz_cmpabs(fmpz_t, fmpz_t) + mp_limb_t fmpz_abs_lbound_ui_2exp(long * exp, const fmpz_t x, int bits) + # For nonzero `x`, returns a mantissa `m` with exactly ``bits`` bits and + # sets ``exp`` to an exponent `e`, such that `|x| \ge m 2^e`. The number + # of bits must be between 1 and ``FLINT_BITS`` inclusive. + # The mantissa is guaranteed to be correctly rounded. - int fmpz_equal(fmpz_t, fmpz_t) - int fmpz_equal_ui(fmpz_t, ulong) - int fmpz_equal_si(fmpz_t, slong) + mp_limb_t fmpz_abs_ubound_ui_2exp(long * exp, const fmpz_t x, int bits) + # For nonzero `x`, returns a mantissa `m` with exactly ``bits`` bits + # and sets ``exp`` to an exponent `e`, such that `|x| \le m 2^e`. + # The number of bits must be between 1 and ``FLINT_BITS`` inclusive. + # The mantissa is either correctly rounded or one unit too large + # (possibly meaning that the exponent is one too large, + # if the mantissa is a power of two). - int fmpz_is_zero(fmpz_t) - int fmpz_is_one(fmpz_t) - int fmpz_is_pm1(fmpz_t) - int fmpz_is_even(fmpz_t) - int fmpz_is_odd(fmpz_t) + int fmpz_cmp(const fmpz_t f, const fmpz_t g) - # Basic arithmetic - void fmpz_neg(fmpz_t, fmpz_t) - void fmpz_abs(fmpz_t, fmpz_t) + int fmpz_cmp_ui(const fmpz_t f, unsigned long g) - void fmpz_add(fmpz_t, fmpz_t, fmpz_t) - void fmpz_add_ui(fmpz_t, fmpz_t, ulong) + int fmpz_cmp_si(const fmpz_t f, long g) + # Returns a negative value if `f < g`, positive value if `g < f`, + # otherwise returns `0`. - void fmpz_sub(fmpz_t, fmpz_t, fmpz_t) - void fmpz_sub_ui(fmpz_t, fmpz_t, ulong) + int fmpz_cmpabs(const fmpz_t f, const fmpz_t g) + # Returns a negative value if `\lvert f\rvert < \lvert g\rvert`, positive value if + # `\lvert g\rvert < \lvert f \rvert`, otherwise returns `0`. - void fmpz_mul(fmpz_t, fmpz_t, fmpz_t) - void fmpz_mul_ui(fmpz_t, fmpz_t, ulong) - void fmpz_mul_si(fmpz_t, fmpz_t, slong) - void fmpz_mul2_uiui(fmpz_t, fmpz_t, ulong, ulong) - void fmpz_mul_2exp(fmpz_t, fmpz_t, ulong) + int fmpz_cmp2abs(const fmpz_t f, const fmpz_t g) + # Returns a negative value if `\lvert f\rvert < \lvert 2g\rvert`, positive value if + # `\lvert 2g\rvert < \lvert f \rvert`, otherwise returns `0`. - void fmpz_addmul(fmpz_t, fmpz_t, fmpz_t) - void fmpz_addmul_ui(fmpz_t, fmpz_t, ulong) + int fmpz_equal(const fmpz_t f, const fmpz_t g) - void fmpz_submul(fmpz_t, fmpz_t, fmpz_t) - void fmpz_submul_ui(fmpz_t, fmpz_t, ulong) + int fmpz_equal_ui(const fmpz_t f, unsigned long g) - void fmpz_cdiv_q(fmpz_t, fmpz_t, fmpz_t) - void fmpz_cdiv_q_ui(fmpz_t, fmpz_t, ulong) - void fmpz_cdiv_q_si(fmpz_t, fmpz_t, slong) - void fmpz_cdiv_q_2exp(fmpz_t, fmpz_t, ulong) + int fmpz_equal_si(const fmpz_t f, long g) + # Returns `1` if `f` is equal to `g`, otherwise returns `0`. - void fmpz_fdiv_q(fmpz_t, fmpz_t, fmpz_t) - void fmpz_fdiv_q_ui(fmpz_t, fmpz_t, ulong) - void fmpz_fdiv_q_si(fmpz_t, fmpz_t, slong) - void fmpz_fdiv_q_2exp(fmpz_t, fmpz_t, ulong) + int fmpz_is_zero(const fmpz_t f) + # Returns `1` if `f` is `0`, otherwise returns `0`. - ulong fmpz_fdiv_ui(fmpz_t, ulong) + int fmpz_is_one(const fmpz_t f) + # Returns `1` if `f` is equal to one, otherwise returns `0`. - void fmpz_fdiv_r(fmpz_t, fmpz_t, fmpz_t) - void fmpz_fdiv_r_2exp(fmpz_t, fmpz_t, ulong) + int fmpz_is_pm1(const fmpz_t f) + # Returns `1` if `f` is equal to one or minus one, otherwise returns `0`. - void fmpz_fdiv_qr(fmpz_t, fmpz_t, fmpz_t, fmpz_t) - void fmpz_fdiv_qr_preinvn(fmpz_t f, fmpz_t s, fmpz_t g, - fmpz_t h, fmpz_preinvn_t inv) + int fmpz_is_even(const fmpz_t f) + # Returns whether the integer `f` is even. - void fmpz_tdiv_q(fmpz_t, fmpz_t, fmpz_t) - void fmpz_tdiv_q_ui(fmpz_t, fmpz_t, ulong) - void fmpz_tdiv_q_si(fmpz_t, fmpz_t, slong) - void fmpz_tdiv_q_2exp(fmpz_t, fmpz_t, ulong) + int fmpz_is_odd(const fmpz_t f) + # Returns whether the integer `f` is odd. - ulong fmpz_tdiv_ui(fmpz_t, ulong) + void fmpz_neg(fmpz_t f1, const fmpz_t f2) + # Sets `f_1` to `-f_2`. - void fmpz_tdiv_qr(fmpz_t, fmpz_t, fmpz_t, fmpz_t) + void fmpz_abs(fmpz_t f1, const fmpz_t f2) + # Sets `f_1` to the absolute value of `f_2`. - void fmpz_divexact(fmpz_t, fmpz_t, fmpz_t) - void fmpz_divexact_ui(fmpz_t, fmpz_t, ulong) - void fmpz_divexact_si(fmpz_t, fmpz_t, slong) - void fmpz_divexact2_uiui(fmpz_t, fmpz_t, ulong, ulong) + void fmpz_add(fmpz_t f, const fmpz_t g, const fmpz_t h) + void fmpz_add_ui(fmpz_t f, const fmpz_t g, unsigned long h) + void fmpz_add_si(fmpz_t f, const fmpz_t g, long h) + # Sets `f` to `g + h`. - void fmpz_mul_tdiv_q_2exp(fmpz_t, fmpz_t, fmpz_t, ulong) - void fmpz_mul_si_tdiv_q_2exp(fmpz_t, fmpz_t, slong, ulong) + void fmpz_sub(fmpz_t f, const fmpz_t g, const fmpz_t h) + void fmpz_sub_ui(fmpz_t f, const fmpz_t g, unsigned long h) + void fmpz_sub_si(fmpz_t f, const fmpz_t g, long h) + # Sets `f` to `g - h`. - int fmpz_divisible(fmpz_t, fmpz_t) - int fmpz_divisible_si(fmpz_t, slong) + void fmpz_mul(fmpz_t f, const fmpz_t g, const fmpz_t h) + void fmpz_mul_ui(fmpz_t f, const fmpz_t g, unsigned long h) + void fmpz_mul_si(fmpz_t f, const fmpz_t g, long h) + # Sets `f` to `g \times h`. - void fmpz_mod(fmpz_t, fmpz_t, fmpz_t) - void fmpz_mod_ui(fmpz_t, fmpz_t, ulong) - void fmpz_negmod(fmpz_t r, fmpz_t a, fmpz_t mod) + void fmpz_mul2_uiui(fmpz_t f, const fmpz_t g, unsigned long x, unsigned long y) + # Sets `f` to `g \times x \times y` where `x` and `y` are of type ``ulong``. - void fmpz_gcd(fmpz_t f, fmpz_t g, fmpz_t h) - void fmpz_lcm(fmpz_t f, fmpz_t g, fmpz_t h) - void fmpz_gcdinv(fmpz_t d, fmpz_t a, fmpz_t f, fmpz_t g) - void fmpz_xgcd(fmpz_t d, fmpz_t a, fmpz_t b, fmpz_t f, fmpz_t g) - void fmpz_xgcd_partial(fmpz_t co2, fmpz_t co1, fmpz_t r2, fmpz_t r1, fmpz_t L) - int fmpz_invmod(fmpz_t f, fmpz_t g, fmpz_t h) - int fmpz_jacobi(fmpz_t a, fmpz_t p) - long fmpz_remove(fmpz_t rop, fmpz_t op, fmpz_t f) + void fmpz_mul_2exp(fmpz_t f, const fmpz_t g, unsigned long e) + # Sets `f` to `g \times 2^e`. + # Note: Assumes that ``e + FLINT_BITS`` does not overflow. - void fmpz_preinvn_init(fmpz_preinvn_t, fmpz_t) - void fmpz_preinvn_clear(fmpz_preinvn_t) + void fmpz_one_2exp(fmpz_t f, unsigned long e) + # Sets `f` to `2^e`. - void fmpz_fdiv_preinvn(fmpz_t, fmpz_t, fmpz_t, fmpz_t, fmpz_preinvn_t) + void fmpz_addmul(fmpz_t f, const fmpz_t g, const fmpz_t h) + void fmpz_addmul_ui(fmpz_t f, const fmpz_t g, unsigned long h) + void fmpz_addmul_si(fmpz_t f, const fmpz_t g, long h) + # Sets `f` to `f + g \times h`. - void fmpz_pow_ui(fmpz_t, fmpz_t, ulong) + void fmpz_submul(fmpz_t f, const fmpz_t g, const fmpz_t h) + void fmpz_submul_ui(fmpz_t f, const fmpz_t g, unsigned long h) + void fmpz_submul_si(fmpz_t f, const fmpz_t g, long h) + # Sets `f` to `f - g \times h`. - void fmpz_powm(fmpz_t, fmpz_t, fmpz_t, fmpz_t) - void fmpz_powm_ui(fmpz_t, fmpz_t, ulong, ulong) + void fmpz_fmma(fmpz_t f, const fmpz_t a, const fmpz_t b, const fmpz_t c, const fmpz_t d) + # Sets `f` to `a \times b + c \times d`. - slong fmpz_clog(fmpz_t, fmpz_t) - slong fmpz_clog_ui(fmpz_t, ulong) + void fmpz_fmms(fmpz_t f, const fmpz_t a, const fmpz_t b, const fmpz_t c, const fmpz_t d) + # Sets `f` to `a \times b - c \times d`. - slong fmpz_flog(fmpz_t, fmpz_t) - slong fmpz_flog_ui(fmpz_t, ulong) + void fmpz_cdiv_qr(fmpz_t f, fmpz_t s, const fmpz_t g, const fmpz_t h) - double fmpz_dlog(fmpz_t) + void fmpz_fdiv_qr(fmpz_t f, fmpz_t s, const fmpz_t g, const fmpz_t h) - int fmpz_sqrtmod(fmpz_t, fmpz_t, fmpz_t) + void fmpz_tdiv_qr(fmpz_t f, fmpz_t s, const fmpz_t g, const fmpz_t h) - int fmpz_is_square(fmpz_t) - void fmpz_sqrt(fmpz_t, fmpz_t) - void fmpz_sqrtrem(fmpz_t, fmpz_t, fmpz_t) + void fmpz_ndiv_qr(fmpz_t f, fmpz_t s, const fmpz_t g, const fmpz_t h) - void fmpz_root(fmpz_t, fmpz_t, slong) + void fmpz_cdiv_q(fmpz_t f, const fmpz_t g, const fmpz_t h) - void fmpz_fac_ui(fmpz_t, ulong) - void fmpz_fib_ui(fmpz_t, ulong) - void fmpz_bin_uiui(fmpz_t, ulong, ulong) - void fmpz_rfac_ui(fmpz_t, fmpz_t, ulong) - void fmpz_rfac_uiui(fmpz_t, ulong, ulong) + void fmpz_fdiv_q(fmpz_t f, const fmpz_t g, const fmpz_t h) - # Random Generators - void fmpz_randbits(fmpz_t f, flint_rand_t state, mp_bitcnt_t bits) - void fmpz_randm(fmpz_t f, flint_rand_t state, const fmpz_t m) + void fmpz_tdiv_q(fmpz_t f, const fmpz_t g, const fmpz_t h) + + void fmpz_cdiv_q_si(fmpz_t f, const fmpz_t g, long h) + + void fmpz_fdiv_q_si(fmpz_t f, const fmpz_t g, long h) + + void fmpz_tdiv_q_si(fmpz_t f, const fmpz_t g, long h) + + void fmpz_cdiv_q_ui(fmpz_t f, const fmpz_t g, unsigned long h) + + void fmpz_fdiv_q_ui(fmpz_t f, const fmpz_t g, unsigned long h) + + void fmpz_tdiv_q_ui(fmpz_t f, const fmpz_t g, unsigned long h) + + void fmpz_cdiv_q_2exp(fmpz_t f, const fmpz_t g, unsigned long exp) + + void fmpz_fdiv_q_2exp(fmpz_t f, const fmpz_t g, unsigned long exp) + + void fmpz_tdiv_q_2exp(fmpz_t f, const fmpz_t g, unsigned long exp) + + void fmpz_fdiv_r(fmpz_t s, const fmpz_t g, const fmpz_t h) + + void fmpz_cdiv_r_2exp(fmpz_t s, const fmpz_t g, unsigned long exp) + + void fmpz_fdiv_r_2exp(fmpz_t s, const fmpz_t g, unsigned long exp) + + void fmpz_tdiv_r_2exp(fmpz_t s, const fmpz_t g, unsigned long exp) + # Sets `f` to the quotient of `g` by `h` and/or `s` to the remainder. For the + # ``2exp`` functions, ``g = 2^exp``. `If `h` is `0` an exception is raised. + # Rounding is made in the following way: + # * ``fdiv`` rounds the quotient via floor rounding. + # * ``cdiv`` rounds the quotient via ceil rounding. + # * ``tdiv`` rounds the quotient via truncation, i.e. rounding towards zero. + # * ``ndiv`` rounds the quotient such that the remainder has the smallest + # absolute value. In case of ties, it rounds the quotient towards zero. + + unsigned long fmpz_cdiv_ui(const fmpz_t g, unsigned long h) + + unsigned long fmpz_fdiv_ui(const fmpz_t g, unsigned long h) + + unsigned long fmpz_tdiv_ui(const fmpz_t g, unsigned long h) + + void fmpz_divexact(fmpz_t f, const fmpz_t g, const fmpz_t h) + + void fmpz_divexact_si(fmpz_t f, const fmpz_t g, long h) + + void fmpz_divexact_ui(fmpz_t f, const fmpz_t g, unsigned long h) + # Sets `f` to the quotient of `g` and `h`, assuming that the + # division is exact, i.e. `g` is a multiple of `h`. If `h` + # is `0` an exception is raised. + + void fmpz_divexact2_uiui(fmpz_t f, const fmpz_t g, unsigned long x, unsigned long y) + # Sets `f` to the quotient of `g` and `h = x \times y`, assuming that + # the division is exact, i.e. `g` is a multiple of `h`. + # If `x` or `y` is `0` an exception is raised. + + int fmpz_divisible(const fmpz_t f, const fmpz_t g) + + int fmpz_divisible_si(const fmpz_t f, long g) + # Returns `1` if there is an integer `q` with `f = q g` and `0` if there is + # none. + + int fmpz_divides(fmpz_t q, const fmpz_t g, const fmpz_t h) + # Returns `1` if there is an integer `q` with `f = q g` and sets `q` to the + # quotient. Otherwise returns `0` and sets `q` to `0`. + + void fmpz_mod(fmpz_t f, const fmpz_t g, const fmpz_t h) + # Sets `f` to the remainder of `g` divided by `h` such that the remainder is + # positive. Assumes that `h` is not zero. + + unsigned long fmpz_mod_ui(fmpz_t f, const fmpz_t g, unsigned long h) + # Sets `f` to the remainder of `g` divided by `h` such that the remainder is + # positive and also returns this value. Raises an exception if `h` is zero. + + void fmpz_smod(fmpz_t f, const fmpz_t g, const fmpz_t h) + # Sets `f` to the signed remainder `y \equiv g \bmod h` satisfying + # `-\lvert h \rvert/2 < y \leq \lvert h\rvert/2`. + + void fmpz_preinvn_init(fmpz_preinvn_t inv, const fmpz_t f) + # Compute a precomputed inverse ``inv`` of ``f`` for use in the + # ``preinvn`` functions listed below. + + void fmpz_preinvn_clear(fmpz_preinvn_t inv) + # Clean up the resources used by a precomputed inverse created with the + # :func:`fmpz_preinvn_init` function. + + void fmpz_fdiv_qr_preinvn(fmpz_t f, fmpz_t s, const fmpz_t g, const fmpz_t h, const fmpz_preinvn_t hinv) + # As per :func:`fmpz_fdiv_qr`, but takes a precomputed inverse ``hinv`` + # of `h` constructed using :func:`fmpz_preinvn`. + # This function will be faster than :func:`fmpz_fdiv_qr_preinvn` when the + # number of limbs of `h` is at least ``PREINVN_CUTOFF``. + + void fmpz_pow_ui(fmpz_t f, const fmpz_t g, unsigned long x) + void fmpz_ui_pow_ui(fmpz_t f, unsigned long g, unsigned long x) + # Sets `f` to `g^x`. Defines `0^0 = 1`. + + int fmpz_pow_fmpz(fmpz_t f, const fmpz_t g, const fmpz_t x) + # Sets `f` to `g^x`. Defines `0^0 = 1`. Return `1` for success and `0` for + # failure. The function throws only if `x` is negative. + + void fmpz_powm_ui(fmpz_t f, const fmpz_t g, unsigned long e, const fmpz_t m) + + void fmpz_powm(fmpz_t f, const fmpz_t g, const fmpz_t e, const fmpz_t m) + # Sets `f` to `g^e \bmod{m}`. If `e = 0`, sets `f` to `1`. + # Assumes that `m \neq 0`, raises an ``abort`` signal otherwise. + + long fmpz_clog(const fmpz_t x, const fmpz_t b) + long fmpz_clog_ui(const fmpz_t x, unsigned long b) + # Returns `\lceil\log_b x\rceil`. + # Assumes that `x \geq 1` and `b \geq 2` and that + # the return value fits into a signed ``slong``. + + long fmpz_flog(const fmpz_t x, const fmpz_t b) + long fmpz_flog_ui(const fmpz_t x, unsigned long b) + # Returns `\lfloor\log_b x\rfloor`. + # Assumes that `x \geq 1` and `b \geq 2` and that + # the return value fits into a signed ``slong``. + + double fmpz_dlog(const fmpz_t x) + # Returns a double precision approximation of the + # natural logarithm of `x`. + # The accuracy depends on the implementation of the floating-point + # logarithm provided by the C standard library. The result can + # typically be expected to have a relative error no greater than 1-2 bits. + + int fmpz_sqrtmod(fmpz_t b, const fmpz_t a, const fmpz_t p) + # If `p` is prime, set `b` to a square root of `a` modulo `p` if `a` is a + # quadratic residue modulo `p` and return `1`, otherwise return `0`. + # If `p` is not prime the return value is with high probability `0`, + # indicating that `p` is not prime, or `a` is not a square modulo `p`. + # If `p` is not prime and the return value is `1`, the value of `b` is + # meaningless. + + void fmpz_sqrt(fmpz_t f, const fmpz_t g) + # Sets `f` to the integer part of the square root of `g`, where + # `g` is assumed to be non-negative. If `g` is negative, an exception + # is raised. + + void fmpz_sqrtrem(fmpz_t f, fmpz_t r, const fmpz_t g) + # Sets `f` to the integer part of the square root of `g`, where `g` is + # assumed to be non-negative, and sets `r` to the remainder, that is, + # the difference `g - f^2`. If `g` is negative, an exception is raised. + # The behaviour is undefined if `f` and `r` are aliases. + + int fmpz_is_square(const fmpz_t f) + # Returns nonzero if `f` is a perfect square and zero otherwise. + + int fmpz_root(fmpz_t r, const fmpz_t f, long n) + # Set `r` to the integer part of the `n`-th root of `f`. Requires that + # `n > 0` and that if `n` is even then `f` be non-negative, otherwise an + # exception is raised. The function returns `1` if the root was exact, + # otherwise `0`. + + int fmpz_is_perfect_power(fmpz_t root, const fmpz_t f) + # If `f` is a perfect power `r^k` set ``root`` to `r` and return `k`, + # otherwise return `0`. Note that `-1, 0, 1` are all considered perfect + # powers. No guarantee is made about `r` or `k` being the smallest + # possible value. Negative values of `f` are permitted. + + void fmpz_fac_ui(fmpz_t f, unsigned long n) + # Sets `f` to the factorial `n!` where `n` is an ``ulong``. + + void fmpz_fib_ui(fmpz_t f, unsigned long n) + # Sets `f` to the Fibonacci number `F_n` where `n` is an + # ``ulong``. + + void fmpz_bin_uiui(fmpz_t f, unsigned long n, unsigned long k) + # Sets `f` to the binomial coefficient `{n \choose k}`. + + void _fmpz_rfac_ui(fmpz_t r, const fmpz_t x, unsigned long a, unsigned long b) + # Sets `r` to the rising factorial `(x+a) (x+a+1) (x+a+2) \cdots (x+b-1)`. + # Assumes `b > a`. + + void fmpz_rfac_ui(fmpz_t r, const fmpz_t x, unsigned long k) + # Sets `r` to the rising factorial `x (x+1) (x+2) \cdots (x+k-1)`. + + void fmpz_rfac_uiui(fmpz_t r, unsigned long x, unsigned long k) + # Sets `r` to the rising factorial `x (x+1) (x+2) \cdots (x+k-1)`. + + void fmpz_mul_tdiv_q_2exp(fmpz_t f, const fmpz_t g, const fmpz_t h, unsigned long exp) + # Sets `f` to the product of `g` and `h` divided by ``2^exp``, rounding + # down towards zero. + + void fmpz_mul_si_tdiv_q_2exp(fmpz_t f, const fmpz_t g, long x, unsigned long exp) + # Sets `f` to the product of `g` and `x` divided by ``2^exp``, rounding + # down towards zero. + + void fmpz_gcd_ui(fmpz_t f, const fmpz_t g, unsigned long h) + + void fmpz_gcd(fmpz_t f, const fmpz_t g, const fmpz_t h) + # Sets `f` to the greatest common divisor of `g` and `h`. The + # result is always positive, even if one of `g` and `h` is + # negative. + + void fmpz_gcd3(fmpz_t f, const fmpz_t a, const fmpz_t b, const fmpz_t c) + # Sets `f` to the greatest common divisor of `a`, `b` and `c`. + # This is equivalent to calling ``fmpz_gcd`` twice, but may be faster. + + void fmpz_lcm(fmpz_t f, const fmpz_t g, const fmpz_t h) + # Sets `f` to the least common multiple of `g` and `h`. The + # result is always nonnegative, even if one of `g` and `h` is + # negative. + + void fmpz_gcdinv(fmpz_t d, fmpz_t a, const fmpz_t f, const fmpz_t g) + # Given integers `f, g` with `0 \leq f < g`, computes the + # greatest common divisor `d = \gcd(f, g)` and the modular + # inverse `a = f^{-1} \pmod{g}`, whenever `f \neq 0`. + # Assumes that `d` and `a` are not aliased. + + void fmpz_xgcd(fmpz_t d, fmpz_t a, fmpz_t b, const fmpz_t f, const fmpz_t g) + # Computes the extended GCD of `f` and `g`, i.e. the values `a` and `b` such + # that `af + bg = d`, where `d = \gcd(f, g)`. Here `a` will be the same as + # calling ``fmpz_gcdinv`` when `f < g` (or vice versa for `b` when `g < f`). + # To obtain the canonical solution to Bézout's identity, call + # ``fmpz_xgcd_canonical_bezout`` instead. This is also faster. + # Assumes that there is no aliasing among the outputs. + + void fmpz_xgcd_canonical_bezout(fmpz_t d, fmpz_t a, fmpz_t b, const fmpz_t f, const fmpz_t g) + # Computes the extended GCD `\operatorname{xgcd}(f, g) = (d, a, b)` such that + # the solution is the canonical solution to Bézout's identity. We define the + # canonical solution to satisfy one of the following if one of the given + # conditions apply: + # .. math :: + # \operatorname{xgcd}(\pm g, g) &= \bigl(|g|, 0, \operatorname{sgn}(g)\bigr) + # \operatorname{xgcd}(f, 0) &= \bigl(|f|, \operatorname{sgn}(f), 0\bigr) + # \operatorname{xgcd}(0, g) &= \bigl(|g|, 0, \operatorname{sgn}(g)\bigr) + # \operatorname{xgcd}(f, \mp 1) &= (1, 0, \mp 1) + # \operatorname{xgcd}(\mp 1, g) &= (1, \mp 1, 0)\quad g \neq 0, \pm 1 + # \operatorname{xgcd}(\mp 2 d, g) &= + # \bigl(d, {\textstyle\frac{d - |g|}{\mp 2 d}}, \operatorname{sgn}(g)\bigr) + # \operatorname{xgcd}(f, \mp 2 d) &= + # \bigl(d, \operatorname{sgn}(f), {\textstyle\frac{d - |g|}{\mp 2 d}}\bigr). + # If the pair `(f, g)` does not satisfy any of these conditions, the solution + # `(d, a, b)` will satisfy the following: + # .. math :: + # |a| < \Bigl| \frac{g}{2 d} \Bigr|, + # \qquad |b| < \Bigl| \frac{f}{2 d} \Bigr|. + # Assumes that there is no aliasing among the outputs. + + void fmpz_xgcd_partial(fmpz_t co2, fmpz_t co1, fmpz_t r2, fmpz_t r1, const fmpz_t L) + # This function is an implementation of Lehmer extended GCD with early + # termination, as used in the ``qfb`` module. It terminates early when + # remainders fall below the specified bound. The initial values ``r1`` + # and ``r2`` are treated as successive remainders in the Euclidean + # algorithm and are replaced with the last two remainders computed. The + # values ``co1`` and ``co2`` are the last two cofactors and satisfy + # the identity ``co2*r1 - co1*r2 == +/- r2_orig`` upon termination, where + # ``r2_orig`` is the starting value of ``r2`` supplied, and ``r1`` + # and ``r2`` are the final values. + # Aliasing of inputs is not allowed. Similarly aliasing of inputs and outputs + # is not allowed. + + long _fmpz_remove(fmpz_t x, const fmpz_t f, double finv) + # Removes all factors `f` from `x` and returns the number of such. + # Assumes that `x` is non-zero, that `f > 1` and that ``finv`` + # is the precomputed ``double`` inverse of `f` whenever `f` is + # a small integer and `0` otherwise. + # Does not support aliasing. + + long fmpz_remove(fmpz_t rop, const fmpz_t op, const fmpz_t f) + # Remove all occurrences of the factor `f > 1` from the + # integer ``op`` and sets ``rop`` to the resulting + # integer. + # If ``op`` is zero, sets ``rop`` to ``op`` and + # returns `0`. + # Returns an ``abort`` signal if any of the assumptions + # are violated. + + int fmpz_invmod(fmpz_t f, const fmpz_t g, const fmpz_t h) + # Sets `f` to the inverse of `g` modulo `h`. The value of `h` may + # not be `0` otherwise an exception results. If the inverse exists + # the return value will be non-zero, otherwise the return value will + # be `0` and the value of `f` undefined. As a special case, we + # consider any number invertible modulo `h = \pm 1`, with inverse 0. + + void fmpz_negmod(fmpz_t f, const fmpz_t g, const fmpz_t h) + # Sets `f` to `-g \pmod{h}`, assuming `g` is reduced modulo `h`. + + int fmpz_jacobi(const fmpz_t a, const fmpz_t n) + # Computes the Jacobi symbol `\left(\frac{a}{n}\right)` for any `a` and odd positive `n`. + + int fmpz_kronecker(const fmpz_t a, const fmpz_t n) + # Computes the Kronecker symbol `\left(\frac{a}{n}\right)` for any `a` and any `n`. + + void fmpz_divides_mod_list(fmpz_t xstart, fmpz_t xstride, fmpz_t xlength, const fmpz_t a, const fmpz_t b, const fmpz_t n) + # Set `xstart`, `xstride`, and `xlength` so that the solution set for `x` modulo `n` in `a x = b \bmod n` is exactly `\{xstart + xstride\,i \mid 0 \le i < xlength\}`. + # This function essentially gives a list of possibilities for the fraction `a/b` modulo `n`. + # The outputs may not be aliased, and `n` should be positive. + + int fmpz_bit_pack(mp_limb_t * arr, flint_bitcnt_t shift, flint_bitcnt_t bits, const fmpz_t coeff, int negate, int borrow) + # Shifts the given coefficient to the left by ``shift`` bits and adds + # it to the integer in ``arr`` in a field of the given number of bits:: + # shift bits -------------- + # X X X C C C C 0 0 0 0 0 0 0 + # An optional borrow of `1` can be subtracted from ``coeff`` before + # it is packed. If ``coeff`` is negative after the borrow, then a + # borrow will be returned by the function. + # The value of ``shift`` is assumed to be less than ``FLINT_BITS``. + # All but the first ``shift`` bits of ``arr`` are assumed to be zero + # on entry to the function. + # The value of ``coeff`` may also be optionally (and notionally) negated + # before it is used, by setting the ``negate`` parameter to `-1`. + + int fmpz_bit_unpack(fmpz_t coeff, mp_limb_t * arr, flint_bitcnt_t shift, flint_bitcnt_t bits, int negate, int borrow) + # A bit field of the given number of bits is extracted from ``arr``, + # starting after ``shift`` bits, and placed into ``coeff``. An + # optional borrow of `1` may be added to the coefficient. If the result + # is negative, a borrow of `1` is returned. Finally, the resulting + # ``coeff`` may be negated by setting the ``negate`` parameter to `-1`. + # The value of ``shift`` is expected to be less than ``FLINT_BITS``. + + void fmpz_bit_unpack_unsigned(fmpz_t coeff, const mp_limb_t * arr, flint_bitcnt_t shift, flint_bitcnt_t bits) + # A bit field of the given number of bits is extracted from ``arr``, + # starting after ``shift`` bits, and placed into ``coeff``. + # The value of ``shift`` is expected to be less than ``FLINT_BITS``. + + void fmpz_complement(fmpz_t r, const fmpz_t f) + # The variable ``r`` is set to the ones-complement of ``f``. + + void fmpz_clrbit(fmpz_t f, unsigned long i) + # Sets the ``i``\th bit in ``f`` to zero. + + void fmpz_combit(fmpz_t f, unsigned long i) + # Complements the ``i``\th bit in ``f``. + + void fmpz_and(fmpz_t r, const fmpz_t a, const fmpz_t b) + # Sets ``r`` to the bit-wise logical ``and`` of ``a`` and ``b``. + + void fmpz_or(fmpz_t r, const fmpz_t a, const fmpz_t b) + # Sets ``r`` to the bit-wise logical (inclusive) ``or`` of + # ``a`` and ``b``. + + void fmpz_xor(fmpz_t r, const fmpz_t a, const fmpz_t b) + # Sets ``r`` to the bit-wise logical exclusive ``or`` of + # ``a`` and ``b``. + + unsigned long fmpz_popcnt(const fmpz_t a) + # Returns the number of '1' bits in the given Z (aka Hamming weight or + # population count). + # The return value is undefined if the input is negative. + + void fmpz_CRT_ui(fmpz_t out, const fmpz_t r1, const fmpz_t m1, unsigned long r2, unsigned long m2, int sign) + # Uses the Chinese Remainder Theorem to compute the unique integer + # `0 \le x < M` (if sign = 0) or `-M/2 < x \le M/2` (if sign = 1) + # congruent to `r_1` modulo `m_1` and `r_2` modulo `m_2`, + # where `M = m_1 \times m_2`. The result `x` is stored in ``out``. + # It is assumed that `m_1` and `m_2` are positive integers greater + # than `1` and coprime. + # If sign = 0, it is assumed that `0 \le r_1 < m_1` and `0 \le r_2 < m_2`. + # Otherwise, it is assumed that `-m_1 \le r_1 < m_1` and `0 \le r_2 < m_2`. + + void fmpz_CRT(fmpz_t out, const fmpz_t r1, const fmpz_t m1, fmpz_t r2, fmpz_t m2, int sign) + # Use the Chinese Remainder Theorem to set ``out`` to the unique value + # `0 \le x < M` (if sign = 0) or `-M/2 < x \le M/2` (if sign = 1) + # congruent to `r_1` modulo `m_1` and `r_2` modulo `m_2`, + # where `M = m_1 \times m_2`. + # It is assumed that `m_1` and `m_2` are positive integers greater + # than `1` and coprime. + # If sign = 0, it is assumed that `0 \le r_1 < m_1` and `0 \le r_2 < m_2`. + # Otherwise, it is assumed that `-m_1 \le r_1 < m_1` and `0 \le r_2 < m_2`. + + void fmpz_multi_mod_ui(mp_limb_t * out, const fmpz_t input, const fmpz_comb_t comb, fmpz_comb_temp_t temp) + # Reduces the multiprecision integer ``in`` modulo each of the primes + # stored in the ``comb`` structure. The array ``out`` will be filled + # with the residues modulo these primes. The structure ``temp`` is + # temporary space which must be provided by :func:`fmpz_comb_temp_init` and + # cleared by :func:`fmpz_comb_temp_clear`. + + void fmpz_multi_CRT_ui(fmpz_t output, mp_srcptr residues, const fmpz_comb_t comb, fmpz_comb_temp_t ctemp, int sign) + # This function takes a set of residues modulo the list of primes + # contained in the ``comb`` structure and reconstructs a multiprecision + # integer modulo the product of the primes which has + # these residues modulo the corresponding primes. + # If `N` is the product of all the primes then ``out`` is normalised to + # be in the range `[0, N)` if sign = 0 and the range `[-(N-1)/2, N/2]` + # if sign = 1. The array ``temp`` is temporary + # space which must be provided by :func:`fmpz_comb_temp_init` and + # cleared by :func:`fmpz_comb_temp_clear`. + + void fmpz_comb_init(fmpz_comb_t comb, mp_srcptr primes, long num_primes) + # Initialises a ``comb`` structure for multimodular reduction and + # recombination. The array ``primes`` is assumed to contain + # ``num_primes`` primes each of ``FLINT_BITS - 1`` bits. Modular + # reductions and recombinations will be done modulo this list of primes. + # The ``primes`` array must not be ``free``'d until the ``comb`` + # structure is no longer required and must be cleared by the user. + + void fmpz_comb_temp_init(fmpz_comb_temp_t temp, const fmpz_comb_t comb) + # Creates temporary space to be used by multimodular and CRT functions + # based on an initialised ``comb`` structure. + + void fmpz_comb_clear(fmpz_comb_t comb) + # Clears the given ``comb`` structure, releasing any memory it uses. + + void fmpz_comb_temp_clear(fmpz_comb_temp_t temp) + # Clears temporary space ``temp`` used by multimodular and CRT functions + # using the given ``comb`` structure. + + void fmpz_multi_CRT_init(fmpz_multi_CRT_t CRT) + # Initialize ``CRT`` for Chinese remaindering. + + int fmpz_multi_CRT_precompute(fmpz_multi_CRT_t CRT, const fmpz * moduli, long len) + # Configure ``CRT`` for repeated Chinese remaindering of ``moduli``. The number of moduli, ``len``, should be positive. + # A return of ``0`` indicates that the compilation failed and future + # calls to :func:`fmpz_multi_CRT_precomp` will leave the output undefined. + # A return of ``1`` indicates that the compilation was successful, which occurs if and only + # if either (1) ``len == 1`` and ``modulus + 0`` is nonzero, or (2) no modulus is `0,1,-1` and all moduli are pairwise relatively prime. + + void fmpz_multi_CRT_precomp(fmpz_t output, const fmpz_multi_CRT_t P, const fmpz * inputs, int sign) + # Set ``output`` to an integer of smallest absolute value that is congruent to ``values + i`` modulo the ``moduli + i`` + # in ``P``. + + int fmpz_multi_CRT(fmpz_t output, const fmpz * moduli, const fmpz * values, long len, int sign) + # Perform the same operation as :func:`fmpz_multi_CRT_precomp` while internally constructing and destroying the precomputed data. + # All of the remarks in :func:`fmpz_multi_CRT_precompute` apply. + + void fmpz_multi_CRT_clear(fmpz_multi_CRT_t P) + # Free all space used by ``CRT``. + + int fmpz_is_strong_probabprime(const fmpz_t n, const fmpz_t a) + # Returns `1` if `n` is a strong probable prime to base `a`, otherwise it + # returns `0`. + + int fmpz_is_probabprime_lucas(const fmpz_t n) + # Performs a Lucas probable prime test with parameters chosen by Selfridge's + # method `A` as per [BaiWag1980]_. + # Return `1` if `n` is a Lucas probable prime, otherwise return `0`. This + # function declares some composites probably prime, but no primes composite. + + int fmpz_is_probabprime_BPSW(const fmpz_t n) + # Perform a Baillie-PSW probable prime test with parameters chosen by + # Selfridge's method `A` as per [BaiWag1980]_. + # Return `1` if `n` is a Lucas probable prime, otherwise return `0`. + # There are no known composites passed as prime by this test, though + # infinitely many probably exist. The test will declare no primes + # composite. + + int fmpz_is_probabprime(const fmpz_t p) + # Performs some trial division and then some probabilistic primality tests. + # If `p` is definitely composite, the function returns `0`, otherwise it + # is declared probably prime, i.e. prime for most practical purposes, and + # the function returns `1`. The chance of declaring a composite prime is + # very small. + # Subsequent calls to the same function do not increase the probability of + # the number being prime. + + int fmpz_is_prime_pseudosquare(const fmpz_t n) + # Return `0` is `n` is composite. If `n` is too large (greater than about + # `94` bits) the function fails silently and returns `-1`, otherwise, if + # `n` is proven prime by the pseudosquares method, return `1`. + # Tests if `n` is a prime according to [Theorem 2.7] [LukPatWil1996]_. + # We first factor `N` using trial division up to some limit `B`. + # In fact, the number of primes used in the trial factoring is at + # most ``FLINT_PSEUDOSQUARES_CUTOFF``. + # Next we compute `N/B` and find the next pseudosquare `L_p` above + # this value, using a static table as per + # https://oeis.org/A002189/b002189.txt. + # As noted in the text, if `p` is prime then Step 3 will pass. This + # test rejects many composites, and so by this time we suspect + # that `p` is prime. If `N` is `3` or `7` modulo `8`, we are done, + # and `N` is prime. + # We now run a probable prime test, for which no known + # counterexamples are known, to reject any composites. We then + # proceed to prove `N` prime by executing Step 4. In the case that + # `N` is `1` modulo `8`, if Step 4 fails, we extend the number of primes + # `p_i` at Step 3 and hope to find one which passes Step 4. We take + # the test one past the largest `p` for which we have pseudosquares + # `L_p` tabulated, as this already corresponds to the next `L_p` which + # is bigger than `2^{64}` and hence larger than any prime we might be + # testing. + # As explained in the text, Condition 4 cannot fail if `N` is prime. + # The possibility exists that the probable prime test declares a + # composite prime. However in that case an error is printed, as + # that would be of independent interest. + + int fmpz_is_prime_pocklington(fmpz_t F, fmpz_t R, const fmpz_t n, mp_ptr pm1, long num_pm1) + # Applies the Pocklington primality test. The test computes a product + # `F` of prime powers which divide `n - 1`. + # The function then returns either `0` if `n` is definitely composite + # or it returns `1` if all factors of `n` are `1 \pmod{F}`. Also in + # that case, `R` is set to `(n - 1)/F`. + # NB: a return value of `1` only proves `n` prime if `F \ge \sqrt{n}`. + # The function does not compute which primes divide `n - 1`. Instead, + # these must be supplied as an array ``pm1`` of length ``num_pm1``. + # It does not matter how many prime factors are supplied, but the more + # that are supplied, the larger F will be. + # There is a balance between the amount of time spent looking for + # factors of `n - 1` and the usefulness of the output (`F` may be as low + # as `2` in some cases). + # A reasonable heuristic seems to be to choose ``limit`` to be some + # small multiple of `\log^3(n)/10` (e.g. `1, 2, 5` or `10`) depending + # on how long one is prepared to wait, then to trial factor up to the + # limit. (See ``_fmpz_nm1_trial_factors``.) + # Requires `n` to be odd. + + void _fmpz_nm1_trial_factors(const fmpz_t n, mp_ptr pm1, long * num_pm1, unsigned long limit) + # Trial factors `n - 1` up to the given limit (approximately) and stores + # the factors in an array ``pm1`` whose length is written out to + # ``num_pm1``. + # One can use `\log(n) + 2` as a bound on the number of factors which might + # be produced (and hence on the length of the array that needs to be + # supplied). + + int fmpz_is_prime_morrison(fmpz_t F, fmpz_t R, const fmpz_t n, mp_ptr pp1, long num_pp1) + # Applies the Morrison `p + 1` primality test. The test computes a + # product `F` of primes which divide `n + 1`. + # The function then returns either `0` if `n` is definitely composite + # or it returns `1` if all factors of `n` are `\pm 1 \pmod{F}`. Also in + # that case, `R` is set to `(n + 1)/F`. + # NB: a return value of `1` only proves `n` prime if + # `F > \sqrt{n} + 1`. + # The function does not compute which primes divide `n + 1`. Instead, + # these must be supplied as an array ``pp1`` of length ``num_pp1``. + # It does not matter how many prime factors are supplied, but the more + # that are supplied, the larger `F` will be. + # There is a balance between the amount of time spent looking for + # factors of `n + 1` and the usefulness of the output (`F` may be as low + # as `2` in some cases). + # A reasonable heuristic seems to be to choose ``limit`` to be some + # small multiple of `\log^3(n)/10` (e.g. `1, 2, 5` or `10`) depending + # on how long one is prepared to wait, then to trial factor up to the + # limit. (See ``_fmpz_np1_trial_factors``.) + # Requires `n` to be odd and non-square. + + void _fmpz_np1_trial_factors(const fmpz_t n, mp_ptr pp1, long * num_pp1, unsigned long limit) + # Trial factors `n + 1` up to the given limit (approximately) and stores + # the factors in an array ``pp1`` whose length is written out to + # ``num_pp1``. + # One can use `\log(n) + 2` as a bound on the number of factors which might + # be produced (and hence on the length of the array that needs to be + # supplied). + + int fmpz_is_prime(const fmpz_t n) + # Attempts to prove `n` prime. If `n` is proven prime, the function + # returns `1`. If `n` is definitely composite, the function returns `0`. + # This function calls :func:`n_is_prime` for `n` that fits in a single word. + # For `n` larger than one word, it tests divisibility by a few small primes + # and whether `n` is a perfect square to rule out trivial composites. + # For `n` up to about 81 bits, it then uses a strong probable prime test + # (Miller-Rabin test) with the first 13 primes as witnesses. This has + # been shown to prove primality [SorWeb2016]_. + # For larger `n`, it does a single base-2 strong probable prime test + # to eliminate most composite numbers. If `n` passes, it does a + # combination of Pocklington, Morrison and Brillhart, Lehmer, Selfridge + # tests. If any of these tests fails to give a proof, it falls back to + # performing an APRCL test. + # The APRCL test could theoretically fail to prove that `n` is prime + # or composite. In that case, the program aborts. This is not expected to + # occur in practice. + + void fmpz_lucas_chain(fmpz_t Vm, fmpz_t Vm1, const fmpz_t A, const fmpz_t m, const fmpz_t n) + # Given `V_0 = 2`, `V_1 = A` compute `V_m, V_{m + 1} \pmod{n}` from the + # recurrences `V_j = AV_{j - 1} - V_{j - 2} \pmod{n}`. + # This is computed efficiently using `V_{2j} = V_j^2 - 2 \pmod{n}` and + # `V_{2j + 1} = V_jV_{j + 1} - A \pmod{n}`. + # No aliasing is permitted. + + void fmpz_lucas_chain_full(fmpz_t Vm, fmpz_t Vm1, const fmpz_t A, const fmpz_t B, const fmpz_t m, const fmpz_t n) + # Given `V_0 = 2`, `V_1 = A` compute `V_m, V_{m + 1} \pmod{n}` from the + # recurrences `V_j = AV_{j - 1} - BV_{j - 2} \pmod{n}`. + # This is computed efficiently using double and add formulas. + # No aliasing is permitted. + + void fmpz_lucas_chain_double(fmpz_t U2m, fmpz_t U2m1, const fmpz_t Um, const fmpz_t Um1, const fmpz_t A, const fmpz_t B, const fmpz_t n) + # Given `U_m, U_{m + 1} \pmod{n}` compute `U_{2m}, U_{2m + 1} \pmod{n}`. + # Aliasing of `U_{2m}` and `U_m` and aliasing of `U_{2m + 1}` and `U_{m + 1}` + # is permitted. No other aliasing is allowed. + + void fmpz_lucas_chain_add(fmpz_t Umn, fmpz_t Umn1, const fmpz_t Um, const fmpz_t Um1, const fmpz_t Un, const fmpz_t Un1, const fmpz_t A, const fmpz_t B, const fmpz_t n) + # Given `U_m, U_{m + 1} \pmod{n}` and `U_n, U_{n + 1} \pmod{n}` compute + # `U_{m + n}, U_{m + n + 1} \pmod{n}`. + # Aliasing of `U_{m + n}` with `U_m` or `U_n` and aliasing of `U_{m + n + 1}` + # with `U_{m + 1}` or `U_{n + 1}` is permitted. No other aliasing is allowed. + + void fmpz_lucas_chain_mul(fmpz_t Ukm, fmpz_t Ukm1, const fmpz_t Um, const fmpz_t Um1, const fmpz_t A, const fmpz_t B, const fmpz_t k, const fmpz_t n) + # Given `U_m, U_{m + 1} \pmod{n}` compute `U_{km}, U_{km + 1} \pmod{n}`. + # Aliasing of `U_{km}` and `U_m` and aliasing of `U_{km + 1}` and `U_{m + 1}` + # is permitted. No other aliasing is allowed. + + void fmpz_lucas_chain_VtoU(fmpz_t Um, fmpz_t Um1, const fmpz_t Vm, const fmpz_t Vm1, const fmpz_t A, const fmpz_t B, const fmpz_t Dinv, const fmpz_t n) + # Given `V_m, V_{m + 1} \pmod{n}` compute `U_m, U_{m + 1} \pmod{n}`. + # Aliasing of `V_m` and `U_m` and aliasing of `V_{m + 1}` and `U_{m + 1}` + # is permitted. No other aliasing is allowed. + + int fmpz_divisor_in_residue_class_lenstra(fmpz_t fac, const fmpz_t n, const fmpz_t r, const fmpz_t s) + # If there exists a proper divisor of `n` which is `r \pmod{s}` for + # `0 < r < s < n`, this function returns `1` and sets ``fac`` to such a + # divisor. Otherwise the function returns `0` and the value of ``fac`` is + # undefined. + # We require `\gcd(r, s) = 1`. + # This is efficient if `s^3 > n`. + + void fmpz_nextprime(fmpz_t res, const fmpz_t n, int proved) + # Finds the next prime number larger than `n`. + # If ``proved`` is nonzero, then the integer returned is + # guaranteed to actually be prime. Otherwise if `n` fits in + # ``FLINT_BITS - 3`` bits ``n_nextprime`` is called, and if not then + # the GMP ``mpz_nextprime`` function is called. Up to and including + # GMP 6.1.2 this used Miller-Rabin iterations, and thereafter uses + # a BPSW test. + + void fmpz_primorial(fmpz_t res, unsigned long n) + # Sets ``res`` to ``n`` primorial or `n \#`, the product of all prime + # numbers less than or equal to `n`. + + void fmpz_factor_euler_phi(fmpz_t res, const fmpz_factor_t fac) + void fmpz_euler_phi(fmpz_t res, const fmpz_t n) + # Sets ``res`` to the Euler totient function `\phi(n)`, counting the + # number of positive integers less than or equal to `n` that are coprime + # to `n`. The factor version takes a precomputed + # factorisation of `n`. + + int fmpz_factor_moebius_mu(const fmpz_factor_t fac) + int fmpz_moebius_mu(const fmpz_t n) + # Computes the Moebius function `\mu(n)`, which is defined as `\mu(n) = 0` + # if `n` has a prime factor of multiplicity greater than `1`, `\mu(n) = -1` + # if `n` has an odd number of distinct prime factors, and `\mu(n) = 1` if + # `n` has an even number of distinct prime factors. By convention, + # `\mu(0) = 0`. The factor version takes a precomputed + # factorisation of `n`. + + void fmpz_factor_divisor_sigma(fmpz_t res, unsigned long k, const fmpz_factor_t fac) + void fmpz_divisor_sigma(fmpz_t res, unsigned long k, const fmpz_t n) + # Sets ``res`` to `\sigma_k(n)`, the sum of `k`\th powers of all + # divisors of `n`. The factor version takes a precomputed + # factorisation of `n`. diff --git a/src/sage/libs/flint/fmpz_factor.pxd b/src/sage/libs/flint/fmpz_factor.pxd index 7d28c2795b4..73461ec3854 100644 --- a/src/sage/libs/flint/fmpz_factor.pxd +++ b/src/sage/libs/flint/fmpz_factor.pxd @@ -1,12 +1,223 @@ # distutils: libraries = flint # distutils: depends = flint/fmpz_factor.h +################################################################################ +# This file is auto-generated. Do not modify by hand +################################################################################ + +from libc.stdio cimport FILE +from sage.libs.gmp.types cimport * +from sage.libs.mpfr.types cimport * from sage.libs.flint.types cimport * -# flint/fmpz_factor.h cdef extern from "flint_wrap.h": - void fmpz_factor_clear(fmpz_factor_t) - void fmpz_factor_init(fmpz_factor_t) - void fmpz_factor(fmpz_factor_t, const fmpz_t) -cdef fmpz_factor_to_pairlist(const fmpz_factor_t) noexcept + void fmpz_factor_init(fmpz_factor_t factor) + # Initialises an ``fmpz_factor_t`` structure. + + void fmpz_factor_clear(fmpz_factor_t factor) + # Clears an ``fmpz_factor_t`` structure. + + void _fmpz_factor_append_ui(fmpz_factor_t factor, mp_limb_t p, unsigned long exp) + # Append a factor `p` to the given exponent to the + # ``fmpz_factor_t`` structure ``factor``. + + void _fmpz_factor_append(fmpz_factor_t factor, const fmpz_t p, unsigned long exp) + # Append a factor `p` to the given exponent to the + # ``fmpz_factor_t`` structure ``factor``. + + void fmpz_factor(fmpz_factor_t factor, const fmpz_t n) + # Factors `n` into prime numbers. If `n` is zero or negative, the + # sign field of the ``factor`` object will be set accordingly. + + int fmpz_factor_smooth(fmpz_factor_t factor, const fmpz_t n, long bits, int proved) + # Factors `n` into prime numbers up to approximately the given number of + # bits and possibly one additional cofactor, which may or may not be prime. + # If the number is definitely factored fully, the return value is `1`, + # otherwise the final factor (which may have exponent greater than `1`) + # is composite and needs to be factored further. + # If the number has a factor of around the given number of bits, there is + # at least a two-thirds chance of finding it. Smaller factors should be + # found with a much higher probability. + # The amount of time spent factoring can be controlled by lowering or + # increasing ``bits``. However, the quadratic sieve may be faster if + # ``bits`` is set to more than one third of the number of bits of `n`. + # The function uses trial factoring up to ``bits = 15``, followed by + # a primality test and a perfect power test to check if the factorisation + # is complete. If ``bits`` is at least 16, it proceeds to use the + # elliptic curve method to look for larger factors. + # The behavior of primality testing is determined by the ``proved`` + # parameter: + # If ``proved`` is set to `1` the function will prove all factors prime + # (other than the last factor, if the return value is `0`). + # If ``proved`` is set to `0`, the function will only check that factors are + # probable primes. + # If ``proved`` is set to `-1`, the function will not test primality + # after performing trial division. A perfect power test is still performed. + # As an exception to the rules stated above, this function will call + # ``n_factor`` internally if `n` or the remainder after trial division + # is smaller than one word, guaranteeing a complete factorisation. + + void fmpz_factor_si(fmpz_factor_t factor, long n) + # Like ``fmpz_factor``, but takes a machine integer `n` as input. + + int fmpz_factor_trial_range(fmpz_factor_t factor, const fmpz_t n, unsigned long start, unsigned long num_primes) + # Factors `n` into prime factors using trial division. If `n` is + # zero or negative, the sign field of the ``factor`` object will be + # set accordingly. + # The algorithm starts with the given start index in the ``flint_primes`` + # table and uses at most ``num_primes`` primes from that point. + # The function returns 1 if `n` is completely factored, otherwise it returns + # `0`. + + int fmpz_factor_trial(fmpz_factor_t factor, const fmpz_t n, long num_primes) + # Factors `n` into prime factors using trial division. If `n` is + # zero or negative, the sign field of the ``factor`` object will be + # set accordingly. + # The algorithm uses the given number of primes, which must be in the range + # `[0, 3512]`. An exception is raised if a number outside this range is + # passed. + # The function returns 1 if `n` is completely factored, otherwise it returns + # `0`. + # The final entry in the factor struct is set to the cofactor after removing + # prime factors, if this is not `1`. + + void fmpz_factor_refine(fmpz_factor_t res, const fmpz_factor_t f) + # Attempts to improve a partial factorization of an integer by "refining" + # the factorization ``f`` to a more complete factorization ``res`` + # whose bases are pairwise relatively prime. + # This function does not require its input to be in canonical form, + # nor does it guarantee that the resulting factorization will be canonical. + + void fmpz_factor_expand_iterative(fmpz_t n, const fmpz_factor_t factor) + # Evaluates an integer in factored form back to an ``fmpz_t``. + # This currently exponentiates the bases separately and multiplies + # them together one by one, although much more efficient algorithms + # exist. + + int fmpz_factor_pp1(fmpz_t factor, const fmpz_t n, unsigned long B1, unsigned long B2_sqrt, unsigned long c) + # Use Williams' `p + 1` method to factor `n`, using a prime bound in + # stage 1 of ``B1`` and a prime limit in stage 2 of at least the square + # of ``B2_sqrt``. If a factor is found, the function returns `1` and + # ``factor`` is set to the factor that is found. Otherwise, the function + # returns `0`. + # The value `c` should be a random value greater than `2`. Successive + # calls to the function with different values of `c` give additional + # chances to factor `n` with roughly exponentially decaying probability + # of finding a factor which has been missed (if `p+1` or `p-1` is not + # smooth for any prime factors `p` of `n` then the function will + # not ever succeed). + + int fmpz_factor_pollard_brent_single(fmpz_t p_factor, fmpz_t n_in, fmpz_t yi, fmpz_t ai, mp_limb_t max_iters) + # Pollard Rho algorithm for integer factorization. Assumes that the `n` is + # not prime. ``factor`` is set as the factor if found. Takes as input the initial + # value `y`, to start polynomial evaluation, and `a`, the constant of the polynomial + # used. It is not assured that the factor found will be prime. Does not compute + # the complete factorization, just one factor. Returns the number of limbs of + # factor if factorization is successful (non trivial factor is found), else returns 0. + # ``max_iters`` is the number of iterations tried in process of finding the cycle. + # If the algorithm fails to find a non trivial factor in one call, it tries again + # (this time with a different set of random values). + + int fmpz_factor_pollard_brent(fmpz_t factor, flint_rand_t state, fmpz_t n, mp_limb_t max_tries, mp_limb_t max_iters) + # Pollard Rho algorithm for integer factorization. Assumes that the `n` is + # not prime. ``factor`` is set as the factor if found. It is not assured that the + # factor found will be prime. Does not compute the complete factorization, + # just one factor. Returns the number of limbs of factor if factorization is + # successful (non trivial factor is found), else returns 0. + # ``max_iters`` is the number of iterations tried in process of finding the cycle. + # If the algorithm fails to find a non trivial factor in one call, it tries again + # (this time with a different set of random values). This process is repeated a + # maximum of ``max_tries`` times. + # The algorithm used is a modification of the original Pollard Rho algorithm, + # suggested by Richard Brent. It can be found in the paper available at + # https://maths-people.anu.edu.au/~brent/pd/rpb051i.pdf + + void fmpz_factor_ecm_init(ecm_t ecm_inf, mp_limb_t sz) + # Initializes the ``ecm_t`` struct. This is needed in some functions + # and carries data between subsequent calls. + + void fmpz_factor_ecm_clear(ecm_t ecm_inf) + # Clears the ``ecm_t`` struct. + + void fmpz_factor_ecm_addmod(mp_ptr a, mp_ptr b, mp_ptr c, mp_ptr n, mp_limb_t n_size) + # Sets `a` to `(b + c)` ``%`` `n`. This is not a normal add mod function, + # it assumes `n` is normalized (highest bit set) and `b` and `c` are reduced + # modulo `n`. + # Used for arithmetic operations in ``fmpz_factor_ecm``. + + void fmpz_factor_ecm_submod(mp_ptr x, mp_ptr a, mp_ptr b, mp_ptr n, mp_limb_t n_size) + # Sets `x` to `(a - b)` ``%`` `n`. This is not a normal subtract mod + # function, it assumes `n` is normalized (highest bit set) + # and `b` and `c` are reduced modulo `n`. + # Used for arithmetic operations in ``fmpz_factor_ecm``. + + void fmpz_factor_ecm_double(mp_ptr x, mp_ptr z, mp_ptr x0, mp_ptr z0, mp_ptr n, ecm_t ecm_inf) + # Sets the point `(x : z)` to two times `(x_0 : z_0)` modulo `n` according + # to the formula + # .. math :: + # x = (x_0 + z_0)^2 \cdot (x_0 - z_0)^2 \mod n, + # .. math :: + # z = 4 x_0 z_0 \left((x_0 - z_0)^2 + 4a_{24}x_0z_0\right) \mod n. + # ``ecm_inf`` is used just to use temporary ``mp_ptr``'s in the + # structure. This group doubling is valid only for points expressed in + # Montgomery projective coordinates. + + void fmpz_factor_ecm_add(mp_ptr x, mp_ptr z, mp_ptr x1, mp_ptr z1, mp_ptr x2, mp_ptr z2, mp_ptr x0, mp_ptr z0, mp_ptr n, ecm_t ecm_inf) + # Sets the point `(x : z)` to the sum of `(x_1 : z_1)` and `(x_2 : z_2)` + # modulo `n`, given the difference `(x_0 : z_0)` according to the formula + # .. math :: + # x = 4z_0(x_1x_2 - z_1z_2)^2 \mod n, \\ z = 4x_0(x_2z_1 - x_1z_2)^2 \mod n. + # ``ecm_inf`` is used just to use temporary ``mp_ptr``'s in the + # structure. This group addition is valid only for points expressed in + # Montgomery projective coordinates. + + void fmpz_factor_ecm_mul_montgomery_ladder(mp_ptr x, mp_ptr z, mp_ptr x0, mp_ptr z0, mp_limb_t k, mp_ptr n, ecm_t ecm_inf) + # Montgomery ladder algorithm for scalar multiplication of elliptic points. + # Sets the point `(x : z)` to `k(x_0 : z_0)` modulo `n`. + # ``ecm_inf`` is used just to use temporary ``mp_ptr``'s in the + # structure. Valid only for points expressed in Montgomery projective + # coordinates. + + int fmpz_factor_ecm_select_curve(mp_ptr f, mp_ptr sigma, mp_ptr n, ecm_t ecm_inf) + # Selects a random elliptic curve given a random integer ``sigma``, + # according to Suyama's parameterization. If the factor is found while + # selecting the curve, the number of limbs required to store the factor + # is returned, otherwise `0`. + # It could be possible that the selected curve is unsuitable for further + # computations, in such a case, `-1` is returned. + # Also selects the initial point `x_0`, and the value of `(a + 2)/4`, where `a` + # is a curve parameter. Sets `z_0` as `1`. All these are stored in the + # ``ecm_t`` struct. + # The curve selected is of Montgomery form, the points selected satisfy the + # curve and are projective coordinates. + + int fmpz_factor_ecm_stage_I(mp_ptr f, const mp_limb_t *prime_array, mp_limb_t num, mp_limb_t B1, mp_ptr n, ecm_t ecm_inf) + # Stage I implementation of the ECM algorithm. + # ``f`` is set as the factor if found. ``num`` is number of prime numbers + # `\le` the bound ``B1``. ``prime_array`` is an array of first ``B1`` + # primes. `n` is the number being factored. + # If the factor is found, number of words required to store the factor is + # returned, otherwise `0`. + + int fmpz_factor_ecm_stage_II(mp_ptr f, mp_limb_t B1, mp_limb_t B2, mp_limb_t P, mp_ptr n, ecm_t ecm_inf) + # Stage II implementation of the ECM algorithm. + # ``f`` is set as the factor if found. ``B1``, ``B2`` are the two + # bounds. ``P`` is the primorial (approximately equal to `\sqrt{B2}`). + # `n` is the number being factored. + # If the factor is found, number of words required to store the factor is + # returned, otherwise `0`. + + int fmpz_factor_ecm(fmpz_t f, mp_limb_t curves, mp_limb_t B1, mp_limb_t B2, flint_rand_t state, const fmpz_t n_in) + # Outer wrapper function for the ECM algorithm. In case ``f`` can fit + # in a single unsigned word, a call to ``n_factor_ecm`` is made. + # The function calls stage I and II, and + # the precomputations (builds ``prime_array`` for stage I, + # ``GCD_table`` and ``prime_table`` for stage II). + # ``f`` is set as the factor if found. ``curves`` is the number of + # random curves being tried. ``B1``, ``B2`` are the two bounds or + # stage I and stage II. `n` is the number being factored. + # If a factor is found in stage I, `1` is returned. + # If a factor is found in stage II, `2` is returned. + # If a factor is found while selecting the curve, `-1` is returned. + # Otherwise `0` is returned. diff --git a/src/sage/libs/flint/fmpz_factor.pyx b/src/sage/libs/flint/fmpz_factor.pyx index aeb9c76f9e3..8b137891791 100644 --- a/src/sage/libs/flint/fmpz_factor.pyx +++ b/src/sage/libs/flint/fmpz_factor.pyx @@ -1,28 +1 @@ -from cysignals.signals cimport sig_check -from sage.libs.flint.fmpz cimport fmpz_get_mpz -from sage.rings.integer cimport Integer -cdef fmpz_factor_to_pairlist(const fmpz_factor_t factors) noexcept: - r""" - Helper function that converts a fmpz_factor_t into a list of - (factor, exponent) pairs. The factors are Integers, and the - exponents are Python ints. This is used and indirectly tested by - both :func:`qsieve` and - :func:`sage.rings.factorint_flint.factor_using_flint`. The output - format was ultimately based on that of - :func:`sage.rings.factorint_pari.factor_using_pari`. - """ - cdef list pairs = [] - - if factors.sign < 0: - # FLINT doesn't return the plus/minus one factor. - pairs.append((Integer(-1), int(1))) - - for i in range(factors.num): - f = Integer() - fmpz_get_mpz(f.value, &factors.p[i]) - e = int(factors.exp[i]) - pairs.append((f, e)) - sig_check() - - return pairs diff --git a/src/sage/libs/flint/fmpz_factor_extra.pxd b/src/sage/libs/flint/fmpz_factor_extra.pxd new file mode 100644 index 00000000000..e91931005c7 --- /dev/null +++ b/src/sage/libs/flint/fmpz_factor_extra.pxd @@ -0,0 +1,3 @@ +from .types cimport * + +cdef fmpz_factor_to_pairlist(const fmpz_factor_t factors) noexcept diff --git a/src/sage/libs/flint/fmpz_factor_extra.pyx b/src/sage/libs/flint/fmpz_factor_extra.pyx new file mode 100644 index 00000000000..aeb9c76f9e3 --- /dev/null +++ b/src/sage/libs/flint/fmpz_factor_extra.pyx @@ -0,0 +1,28 @@ +from cysignals.signals cimport sig_check +from sage.libs.flint.fmpz cimport fmpz_get_mpz +from sage.rings.integer cimport Integer + +cdef fmpz_factor_to_pairlist(const fmpz_factor_t factors) noexcept: + r""" + Helper function that converts a fmpz_factor_t into a list of + (factor, exponent) pairs. The factors are Integers, and the + exponents are Python ints. This is used and indirectly tested by + both :func:`qsieve` and + :func:`sage.rings.factorint_flint.factor_using_flint`. The output + format was ultimately based on that of + :func:`sage.rings.factorint_pari.factor_using_pari`. + """ + cdef list pairs = [] + + if factors.sign < 0: + # FLINT doesn't return the plus/minus one factor. + pairs.append((Integer(-1), int(1))) + + for i in range(factors.num): + f = Integer() + fmpz_get_mpz(f.value, &factors.p[i]) + e = int(factors.exp[i]) + pairs.append((f, e)) + sig_check() + + return pairs diff --git a/src/sage/libs/flint/fmpz_mat.pxd b/src/sage/libs/flint/fmpz_mat.pxd index 91457930213..1aa6bac6b9d 100644 --- a/src/sage/libs/flint/fmpz_mat.pxd +++ b/src/sage/libs/flint/fmpz_mat.pxd @@ -1,39 +1,987 @@ # distutils: libraries = flint # distutils: depends = flint/fmpz_mat.h -from sage.libs.flint.types cimport fmpz_t, fmpz_poly_t, fmpz_mat_t +################################################################################ +# This file is auto-generated. Do not modify by hand +################################################################################ + +from libc.stdio cimport FILE +from sage.libs.gmp.types cimport * +from sage.libs.mpfr.types cimport * +from sage.libs.flint.types cimport * -# flint/fmpz_mat.h cdef extern from "flint_wrap.h": - void fmpz_mat_init(fmpz_mat_t mat, unsigned long rows, unsigned long cols) - void fmpz_mat_init_set(fmpz_mat_t mat, const fmpz_mat_t src) - void fmpz_mat_set(fmpz_mat_t result, fmpz_mat_t mat) + + void fmpz_mat_init(fmpz_mat_t mat, long rows, long cols) + # Initialises a matrix with the given number of rows and columns for use. + void fmpz_mat_clear(fmpz_mat_t mat) - int fmpz_mat_print_pretty(const fmpz_mat_t mat) - fmpz_t fmpz_mat_entry(fmpz_mat_t mat, long i, long j) - long fmpz_mat_nrows(fmpz_mat_t mat) - long fmpz_mat_ncols(fmpz_mat_t mat) - void fmpz_mat_one(fmpz_mat_t mat) + # Clears the given matrix. + + void fmpz_mat_set(fmpz_mat_t mat1, const fmpz_mat_t mat2) + # Sets ``mat1`` to a copy of ``mat2``. The dimensions of + # ``mat1`` and ``mat2`` must be the same. + + void fmpz_mat_init_set(fmpz_mat_t mat, const fmpz_mat_t src) + # Initialises the matrix ``mat`` to the same size as ``src`` and + # sets it to a copy of ``src``. + + long fmpz_mat_nrows(const fmpz_mat_t mat) + long fmpz_mat_ncols(const fmpz_mat_t mat) + # Returns respectively the number of rows and columns of the matrix. + + void fmpz_mat_swap(fmpz_mat_t mat1, fmpz_mat_t mat2) + # Swaps two matrices. The dimensions of ``mat1`` and ``mat2`` + # are allowed to be different. + + void fmpz_mat_swap_entrywise(fmpz_mat_t mat1, fmpz_mat_t mat2) + # Swaps two matrices by swapping the individual entries rather than swapping + # the contents of the structs. + + fmpz * fmpz_mat_entry(const fmpz_mat_t mat, long i, long j) + # Returns a reference to the entry of ``mat`` at row `i` and column `j`. + # This reference can be passed as an input or output variable to any + # function in the ``fmpz`` module for direct manipulation. + # Both `i` and `j` must not exceed the dimensions of the matrix. + # This function is implemented as a macro. + void fmpz_mat_zero(fmpz_mat_t mat) - void fmpz_mat_neg(fmpz_mat_t f, fmpz_mat_t g) + # Sets all entries of ``mat`` to 0. + + void fmpz_mat_one(fmpz_mat_t mat) + # Sets ``mat`` to the unit matrix, having ones on the main diagonal + # and zeroes elsewhere. If ``mat`` is nonsquare, it is set to the + # truncation of a unit matrix. + + void fmpz_mat_swap_rows(fmpz_mat_t mat, long * perm, long r, long s) + # Swaps rows ``r`` and ``s`` of ``mat``. If ``perm`` is non-``NULL``, the + # permutation of the rows will also be applied to ``perm``. + + void fmpz_mat_swap_cols(fmpz_mat_t mat, long * perm, long r, long s) + # Swaps columns ``r`` and ``s`` of ``mat``. If ``perm`` is non-``NULL``, the + # permutation of the columns will also be applied to ``perm``. + + void fmpz_mat_invert_rows(fmpz_mat_t mat, long * perm) + # Swaps rows ``i`` and ``r - i`` of ``mat`` for ``0 <= i < r/2``, where + # ``r`` is the number of rows of ``mat``. If ``perm`` is non-``NULL``, the + # permutation of the rows will also be applied to ``perm``. + + void fmpz_mat_invert_cols(fmpz_mat_t mat, long * perm) + # Swaps columns ``i`` and ``c - i`` of ``mat`` for ``0 <= i < c/2``, where + # ``c`` is the number of columns of ``mat``. If ``perm`` is non-``NULL``, the + # permutation of the columns will also be applied to ``perm``. + + void fmpz_mat_window_init(fmpz_mat_t window, const fmpz_mat_t mat, long r1, long c1, long r2, long c2) + # Initializes the matrix ``window`` to be an ``r2 - r1`` by + # ``c2 - c1`` submatrix of ``mat`` whose ``(0,0)`` entry + # is the ``(r1, c1)`` entry of ``mat``. The memory for the + # elements of ``window`` is shared with ``mat``. + + void fmpz_mat_window_clear(fmpz_mat_t window) + # Clears the matrix ``window`` and releases any memory that it + # uses. Note that the memory to the underlying matrix that + # ``window`` points to is not freed. + + void fmpz_mat_randbits(fmpz_mat_t mat, flint_rand_t state, flint_bitcnt_t bits) + # Sets the entries of ``mat`` to random signed integers whose absolute + # values have the given number of binary bits. + + void fmpz_mat_randtest(fmpz_mat_t mat, flint_rand_t state, flint_bitcnt_t bits) + # Sets the entries of ``mat`` to random signed integers whose + # absolute values have a random number of bits up to the given number + # of bits inclusive. + + void fmpz_mat_randintrel(fmpz_mat_t mat, flint_rand_t state, flint_bitcnt_t bits) + # Sets ``mat`` to be a random *integer relations* matrix, with + # signed entries up to the given number of bits. + # The number of columns of ``mat`` must be equal to one more than + # the number of rows. The format of the matrix is a set of random integers + # in the left hand column and an identity matrix in the remaining square + # submatrix. + + void fmpz_mat_randsimdioph(fmpz_mat_t mat, flint_rand_t state, flint_bitcnt_t bits, flint_bitcnt_t bits2) + # Sets ``mat`` to a random *simultaneous diophantine* matrix. + # The matrix must be square. The top left entry is set to ``2^bits2``. + # The remainder of that row is then set to signed random integers of the + # given number of binary bits. The remainder of the first column is zero. + # Running down the rest of the diagonal are the values ``2^bits`` with + # all remaining entries zero. + + void fmpz_mat_randntrulike(fmpz_mat_t mat, flint_rand_t state, flint_bitcnt_t bits, unsigned long q) + # Sets a square matrix ``mat`` of even dimension to a random + # *NTRU like* matrix. + # The matrix is broken into four square submatrices. The top left submatrix + # is set to the identity. The bottom left submatrix is set to the zero + # matrix. The bottom right submatrix is set to `q` times the identity matrix. + # Finally the top right submatrix has the following format. A random vector + # `h` of length `r/2` is created, with random signed entries of the given + # number of bits. Then entry `(i, j)` of the submatrix is set to + # `h[i + j \bmod{r/2}]`. + + void fmpz_mat_randntrulike2(fmpz_mat_t mat, flint_rand_t state, flint_bitcnt_t bits, unsigned long q) + # Sets a square matrix ``mat`` of even dimension to a random + # *NTRU like* matrix. + # The matrix is broken into four square submatrices. The top left submatrix + # is set to `q` times the identity matrix. The top right submatrix is set to + # the zero matrix. The bottom right submatrix is set to the identity matrix. + # Finally the bottom left submatrix has the following format. A random vector + # `h` of length `r/2` is created, with random signed entries of the given + # number of bits. Then entry `(i, j)` of the submatrix is set to + # `h[i + j \bmod{r/2}]`. + + void fmpz_mat_randajtai(fmpz_mat_t mat, flint_rand_t state, double alpha) + # Sets a square matrix ``mat`` to a random *ajtai* matrix. + # The diagonal entries `(i, i)` are set to a random entry in the range + # `[1, 2^{b-1}]` inclusive where `b = \lfloor(2 r - i)^\alpha\rfloor` for some + # double parameter `\alpha`. The entries below the diagonal in column `i` + # are set to a random entry in the range `(-2^b + 1, 2^b - 1)` whilst the + # entries to the right of the diagonal in row `i` are set to zero. + + int fmpz_mat_randpermdiag(fmpz_mat_t mat, flint_rand_t state, const fmpz * diag, long n) + # Sets ``mat`` to a random permutation of the rows and columns of a + # given diagonal matrix. The diagonal matrix is specified in the form of + # an array of the `n` initial entries on the main diagonal. + # The return value is `0` or `1` depending on whether the permutation is + # even or odd. + + void fmpz_mat_randrank(fmpz_mat_t mat, flint_rand_t state, long rank, flint_bitcnt_t bits) + # Sets ``mat`` to a random sparse matrix with the given rank, + # having exactly as many non-zero elements as the rank, with the + # nonzero elements being random integers of the given bit size. + # The matrix can be transformed into a dense matrix with unchanged + # rank by subsequently calling :func:`fmpz_mat_randops`. + + void fmpz_mat_randdet(fmpz_mat_t mat, flint_rand_t state, const fmpz_t det) + # Sets ``mat`` to a random sparse matrix with minimal number of + # nonzero entries such that its determinant has the given value. + # Note that the matrix will be zero if ``det`` is zero. + # In order to generate a non-zero singular matrix, the function + # :func:`fmpz_mat_randrank` can be used. + # The matrix can be transformed into a dense matrix with unchanged + # determinant by subsequently calling :func:`fmpz_mat_randops`. + + void fmpz_mat_randops(fmpz_mat_t mat, flint_rand_t state, long count) + # Randomises ``mat`` by performing elementary row or column operations. + # More precisely, at most ``count`` random additions or subtractions of + # distinct rows and columns will be performed. This leaves the rank + # (and for square matrices, the determinant) unchanged. + + int fmpz_mat_fprint(FILE * file, const fmpz_mat_t mat) + # Prints the given matrix to the stream ``file``. The format is + # the number of rows, a space, the number of columns, two spaces, then + # a space separated list of coefficients, one row after the other. + # In case of success, returns a positive value; otherwise, returns + # a non-positive value. + + int fmpz_mat_fprint_pretty(FILE * file, const fmpz_mat_t mat) + # Prints the given matrix to the stream ``file``. The format is an + # opening square bracket, then on each line a row of the matrix, followed + # by a closing square bracket. Each row is written as an opening square + # bracket followed by a space separated list of coefficients followed + # by a closing square bracket. + # In case of success, returns a positive value; otherwise, returns + # a non-positive value. + + int fmpz_mat_print(const fmpz_mat_t mat) + # Prints the given matrix to the stream ``stdout``. For further + # details, see :func:`fmpz_mat_fprint`. + + int fmpz_mat_print_pretty(const fmpz_mat_t mat) + # Prints the given matrix to ``stdout``. For further details, + # see :func:`fmpz_mat_fprint_pretty`. + + int fmpz_mat_fread(FILE* file, fmpz_mat_t mat) + # Reads a matrix from the stream ``file``, storing the result + # in ``mat``. The expected format is the number of rows, a + # space, the number of columns, two spaces, then a space separated + # list of coefficients, one row after the other. + # In case of success, returns a positive number. In case of failure, + # returns a non-positive value. + + int fmpz_mat_read(fmpz_mat_t mat) + # Reads a matrix from ``stdin``, storing the result + # in ``mat``. + # In case of success, returns a positive number. In case of failure, + # returns a non-positive value. + + int fmpz_mat_equal(const fmpz_mat_t mat1, const fmpz_mat_t mat2) + # Returns a non-zero value if ``mat1`` and ``mat2`` have + # the same dimensions and entries, and zero otherwise. + + int fmpz_mat_is_zero(const fmpz_mat_t mat) + # Returns a non-zero value if all entries ``mat`` are zero, and + # otherwise returns zero. + + int fmpz_mat_is_one(const fmpz_mat_t mat) + # Returns a non-zero value if ``mat`` is the unit matrix or the truncation + # of a unit matrix, and otherwise returns zero. + + int fmpz_mat_is_empty(const fmpz_mat_t mat) + # Returns a non-zero value if the number of rows or the number of + # columns in ``mat`` is zero, and otherwise returns + # zero. + + int fmpz_mat_is_square(const fmpz_mat_t mat) + # Returns a non-zero value if the number of rows is equal to the + # number of columns in ``mat``, and otherwise returns zero. + + int fmpz_mat_is_zero_row(const fmpz_mat_t mat, long i) + # Returns a non-zero value if row `i` of ``mat`` is zero. + + int fmpz_mat_equal_col(fmpz_mat_t M, long m, long n) + # Returns `1` if columns `m` and `n` of the matrix `M` are equal, otherwise + # returns `0`. + + int fmpz_mat_equal_row(fmpz_mat_t M, long m, long n) + # Returns `1` if rows `m` and `n` of the matrix `M` are equal, otherwise + # returns `0`. + + void fmpz_mat_transpose(fmpz_mat_t B, const fmpz_mat_t A) + # Sets `B` to `A^T`, the transpose of `A`. Dimensions must be compatible. + # `A` and `B` are allowed to be the same object if `A` is a square matrix. + + void fmpz_mat_concat_vertical(fmpz_mat_t res, const fmpz_mat_t mat1, const fmpz_mat_t mat2) + # Sets ``res`` to vertical concatenation of (``mat1``, ``mat2``) + # in that order. Matrix dimensions: ``mat1``: `m \times n`, + # ``mat2``: `k \times n`, ``res``: `(m + k) \times n`. + + void fmpz_mat_concat_horizontal(fmpz_mat_t res, const fmpz_mat_t mat1, const fmpz_mat_t mat2) + # Sets ``res`` to horizontal concatenation of (``mat1``, ``mat2``) + # in that order. Matrix dimensions: ``mat1``: `m \times n`, + # ``mat2``: `m \times k`, ``res``: `m \times (n + k)`. + + void fmpz_mat_get_nmod_mat(nmod_mat_t Amod, const fmpz_mat_t A) + # Sets the entries of ``Amod`` to the entries of ``A`` reduced + # by the modulus of ``Amod``. + + void fmpz_mat_set_nmod_mat(fmpz_mat_t A, const nmod_mat_t Amod) + # Sets the entries of ``Amod`` to the residues in ``Amod``, + # normalised to the interval `-m/2 <= r < m/2` where `m` is the modulus. + + void fmpz_mat_set_nmod_mat_unsigned(fmpz_mat_t A, const nmod_mat_t Amod) + # Sets the entries of ``Amod`` to the residues in ``Amod``, + # normalised to the interval `0 <= r < m` where `m` is the modulus. + + void fmpz_mat_CRT_ui(fmpz_mat_t res, const fmpz_mat_t mat1, const fmpz_t m1, const nmod_mat_t mat2, int sign) + # Given ``mat1`` with entries modulo ``m`` and ``mat2`` + # with modulus `n`, sets ``res`` to the CRT reconstruction modulo `mn` + # with entries satisfying `-mn/2 <= c < mn/2` (if sign = 1) + # or `0 <= c < mn` (if sign = 0). + + void fmpz_mat_multi_mod_ui_precomp(nmod_mat_t * residues, long nres, const fmpz_mat_t mat, const fmpz_comb_t comb, fmpz_comb_temp_t temp) + # Sets each of the ``nres`` matrices in ``residues`` to ``mat`` reduced modulo + # the modulus of the respective matrix, given precomputed ``comb`` and + # ``comb_temp`` structures. + # Note: ``fmpz.h`` must be included **before** ``fmpz_mat.h`` in order for + # this function to be declared. + + void fmpz_mat_multi_mod_ui(nmod_mat_t * residues, long nres, const fmpz_mat_t mat) + # Sets each of the ``nres`` matrices in ``residues`` to ``mat`` + # reduced modulo the modulus of the respective matrix. + # This function is provided for convenience purposes. + # For reducing or reconstructing multiple integer matrices over the same + # set of moduli, it is faster to use ``fmpz_mat_multi_mod_precomp``. + + void fmpz_mat_multi_CRT_ui_precomp(fmpz_mat_t mat, nmod_mat_t * const residues, long nres, const fmpz_comb_t comb, fmpz_comb_temp_t temp, int sign) + # Reconstructs ``mat`` from its images modulo the ``nres`` matrices in + # ``residues``, given precomputed ``comb`` and ``comb_temp`` structures. + # Note: ``fmpz.h`` must be included **before** ``fmpz_mat.h`` in order for + # this function to be declared. + + void fmpz_mat_multi_CRT_ui(fmpz_mat_t mat, nmod_mat_t * const residues, long nres, int sign) + # Reconstructs ``mat`` from its images modulo the ``nres`` matrices + # in ``residues``. + # This function is provided for convenience purposes. + # For reducing or reconstructing multiple integer matrices over the same + # set of moduli, it is faster to use :func:`fmpz_mat_multi_CRT_ui_precomp`. + + void fmpz_mat_add(fmpz_mat_t C, const fmpz_mat_t A, const fmpz_mat_t B) + # Sets ``C`` to the elementwise sum `A + B`. All inputs must + # be of the same size. Aliasing is allowed. + + void fmpz_mat_sub(fmpz_mat_t C, const fmpz_mat_t A, const fmpz_mat_t B) + # Sets ``C`` to the elementwise difference `A - B`. All inputs must + # be of the same size. Aliasing is allowed. + + void fmpz_mat_neg(fmpz_mat_t B, const fmpz_mat_t A) + # Sets ``B`` to the elementwise negation of ``A``. Both inputs + # must be of the same size. Aliasing is allowed. + void fmpz_mat_scalar_mul_si(fmpz_mat_t B, const fmpz_mat_t A, long c) + void fmpz_mat_scalar_mul_ui(fmpz_mat_t B, const fmpz_mat_t A, unsigned long c) void fmpz_mat_scalar_mul_fmpz(fmpz_mat_t B, const fmpz_mat_t A, const fmpz_t c) + # Set ``B = A*c`` where ``A`` is an ``fmpz_mat_t`` and ``c`` + # is a scalar respectively of type ``slong``, ``ulong``, + # or ``fmpz_t``. The dimensions of ``A`` and ``B`` must + # be compatible. + + void fmpz_mat_scalar_addmul_si(fmpz_mat_t B, const fmpz_mat_t A, long c) + void fmpz_mat_scalar_addmul_ui(fmpz_mat_t B, const fmpz_mat_t A, unsigned long c) + void fmpz_mat_scalar_addmul_fmpz(fmpz_mat_t B, const fmpz_mat_t A, const fmpz_t c) + # Set ``B = B + A*c`` where ``A`` is an ``fmpz_mat_t`` and ``c`` + # is a scalar respectively of type ``slong``, ``ulong``, + # or ``fmpz_t``. The dimensions of ``A`` and ``B`` must + # be compatible. + + void fmpz_mat_scalar_submul_si(fmpz_mat_t B, const fmpz_mat_t A, long c) + void fmpz_mat_scalar_submul_ui(fmpz_mat_t B, const fmpz_mat_t A, unsigned long c) + void fmpz_mat_scalar_submul_fmpz(fmpz_mat_t B, const fmpz_mat_t A, const fmpz_t c) + # Set ``B = B - A*c`` where ``A`` is an ``fmpz_mat_t`` and ``c`` + # is a scalar respectively of type ``slong``, ``ulong``, + # or ``fmpz_t``. The dimensions of ``A`` and ``B`` must + # be compatible. + + void fmpz_mat_scalar_addmul_nmod_mat_ui(fmpz_mat_t B, const nmod_mat_t A, unsigned long c) + void fmpz_mat_scalar_addmul_nmod_mat_fmpz(fmpz_mat_t B, const nmod_mat_t A, const fmpz_t c) + # Set ``B = B + A*c`` where ``A`` is an ``nmod_mat_t`` and ``c`` + # is a scalar respectively of type ``ulong`` or ``fmpz_t``. + # The dimensions of ``A`` and ``B`` must be compatible. + + void fmpz_mat_scalar_divexact_si(fmpz_mat_t B, const fmpz_mat_t A, long c) + void fmpz_mat_scalar_divexact_ui(fmpz_mat_t B, const fmpz_mat_t A, unsigned long c) + void fmpz_mat_scalar_divexact_fmpz(fmpz_mat_t B, const fmpz_mat_t A, const fmpz_t c) + # Set ``A = B / c``, where ``B`` is an ``fmpz_mat_t`` and ``c`` + # is a scalar respectively of type ``slong``, ``ulong``, + # or ``fmpz_t``, which is assumed to divide all elements of + # ``B`` exactly. + + void fmpz_mat_scalar_mul_2exp(fmpz_mat_t B, const fmpz_mat_t A, unsigned long exp) + # Set the matrix ``B`` to the matrix ``A``, of the same dimensions, + # multiplied by `2^{exp}`. + + void fmpz_mat_scalar_tdiv_q_2exp(fmpz_mat_t B, const fmpz_mat_t A, unsigned long exp) + # Set the matrix ``B`` to the matrix ``A``, of the same dimensions, + # divided by `2^{exp}`, rounding down towards zero. + + void fmpz_mat_scalar_smod(fmpz_mat_t B, const fmpz_mat_t A, const fmpz_t P) + # Set the matrix ``B`` to the matrix ``A``, of the same dimensions, + # with each entry reduced modulo `P` in the symmetric moduli system. We + # require `P > 0`. + void fmpz_mat_mul(fmpz_mat_t C, const fmpz_mat_t A, const fmpz_mat_t B) + # Sets ``C`` to the matrix product `C = A B`. The matrices must have + # compatible dimensions for matrix multiplication. Aliasing + # is allowed. + # This function automatically switches between classical and + # multimodular multiplication, based on a heuristic comparison of + # the dimensions and entry sizes. + + void fmpz_mat_mul_classical(fmpz_mat_t C, const fmpz_mat_t A, const fmpz_mat_t B) + # Sets ``C`` to the matrix product `C = A B` computed using + # classical matrix algorithm. + # The matrices must have compatible dimensions for matrix multiplication. + # No aliasing is allowed. + + void fmpz_mat_mul_strassen(fmpz_mat_t C, const fmpz_mat_t A, const fmpz_mat_t B) + # Sets `C = AB`. Dimensions must be compatible for matrix multiplication. + # `C` is not allowed to be aliased with `A` or `B`. Uses Strassen + # multiplication (the Strassen-Winograd variant). + + void _fmpz_mat_mul_multi_mod(fmpz_mat_t C, const fmpz_mat_t A, const fmpz_mat_t B, int sign, flint_bitcnt_t bits) + void fmpz_mat_mul_multi_mod(fmpz_mat_t C, const fmpz_mat_t A, const fmpz_mat_t B) + # Sets ``C`` to the matrix product `C = AB` computed using a multimodular + # algorithm. `C` is computed modulo several small prime numbers + # and reconstructed using the Chinese Remainder Theorem. This generally + # becomes more efficient than classical multiplication for large matrices. + # The absolute value of the elements of `C` should be `< 2^{\text{bits}}`, + # and ``sign`` should be `0` if the entries of `C` are known to be nonnegative + # and `1` otherwise. The function + # :func:`fmpz_mat_mul_multi_mod` calculates a rigorous bound automatically. + # If the default bound is too pessimistic, :func:`_fmpz_mat_mul_multi_mod` + # can be used with a custom bound. + # The matrices must have compatible dimensions for matrix multiplication. + # No aliasing is allowed. + + int fmpz_mat_mul_blas(fmpz_mat_t C, const fmpz_mat_t A, const fmpz_mat_t B) + # Tries to set `C = AB` using BLAS and returns `1` for success and `0` for failure. + # Dimensions must be compatible for matrix multiplication. No aliasing is allowed. + # This function currently will fail if the matrices are empty, their dimensions are too large, or their max bits size is over one million bits. + + void fmpz_mat_mul_fft(fmpz_mat_t C, const fmpz_mat_t A, const fmpz_mat_t B) + # Aliasing is allowed. + void fmpz_mat_sqr(fmpz_mat_t B, const fmpz_mat_t A) - void fmpz_mat_add(fmpz_mat_t C, const fmpz_mat_t A, const fmpz_mat_t B) - void fmpz_mat_sub(fmpz_mat_t C, const fmpz_mat_t A, const fmpz_mat_t B) - void fmpz_mat_pow(fmpz_mat_t C, const fmpz_mat_t A, unsigned long n) - bint fmpz_mat_is_zero(const fmpz_mat_t mat) - bint fmpz_mat_is_one(const fmpz_mat_t mat) - void fmpz_mat_charpoly(fmpz_poly_t cp, const fmpz_mat_t mat) - void fmpz_mat_det(fmpz_t det, const fmpz_mat_t A) + # Sets ``B`` to the square of the matrix ``A``, which must be + # a square matrix. Aliasing is allowed. + # The function calls :func:`fmpz_mat_mul` for dimensions less than 12 and + # calls :func:`fmpz_mat_sqr_bodrato` for cases in which the latter is faster. + + void fmpz_mat_sqr_bodrato(fmpz_mat_t B, const fmpz_mat_t A) + # Sets ``B`` to the square of the matrix ``A``, which must be + # a square matrix. Aliasing is allowed. + # The Bodrato algorithm is described in [Bodrato2010]_. + # It is highly efficient for squaring matrices which satisfy both the + # following conditions: (a) large elements, (b) dimensions less than 150. + + void fmpz_mat_pow(fmpz_mat_t B, const fmpz_mat_t A, unsigned long e) + # Sets ``B`` to the matrix ``A`` raised to the power ``e``, + # where ``A`` must be a square matrix. Aliasing is allowed. + + void _fmpz_mat_mul_small(fmpz_mat_t C, const fmpz_mat_t A, const fmpz_mat_t B) + # This internal function sets `C` to the matrix product `C = A B` computed + # using classical matrix algorithm assuming that all entries of `A` and `B` + # are small, that is, have bits `\le FLINT\_BITS - 2`. No aliasing is allowed. + + void _fmpz_mat_mul_double_word(fmpz_mat_t C, const fmpz_mat_t A, const fmpz_mat_t B) + # This function is only for internal use and assumes that either: + # - the entries of `A` and `B` are all nonnegative and strictly less than `2^{2*FLINT\_BITS}`, or + # - the entries of `A` and `B` are all strictly less than `2^{2*FLINT\_BITS - 1}` in absolute value. + + void fmpz_mat_mul_fmpz_vec(fmpz * c, const fmpz_mat_t A, const fmpz * b, long blen) + void fmpz_mat_mul_fmpz_vec_ptr(fmpz * const * c, const fmpz_mat_t A, const fmpz * const * b, long blen) + # Compute a matrix-vector product of ``A`` and ``(b, blen)`` and store the result in ``c``. + # The vector ``(b, blen)`` is either truncated or zero-extended to the number of columns of ``A``. + # The number of entries written to ``c`` is always equal to the number of rows of ``A``. + + void fmpz_mat_fmpz_vec_mul(fmpz * c, const fmpz * a, long alen, const fmpz_mat_t B) + void fmpz_mat_fmpz_vec_mul_ptr(fmpz * const * c, const fmpz * const * a, long alen, const fmpz_mat_t B) + # Compute a vector-matrix product of ``(a, alen)`` and ``B`` and store the result in ``c``. + # The vector ``(a, alen)`` is either truncated or zero-extended to the number of rows of ``B``. + # The number of entries written to ``c`` is always equal to the number of columns of ``B``. + int fmpz_mat_inv(fmpz_mat_t Ainv, fmpz_t den, const fmpz_mat_t A) - void fmpz_mat_transpose(fmpz_mat_t B, const fmpz_mat_t A) - long fmpz_mat_rref(fmpz_mat_t B, fmpz_t den, const fmpz_mat_t A) - long fmpz_mat_fflu(fmpz_mat_t B, fmpz_poly_t den, long *perm, const fmpz_mat_t A, int rank_check) - long fmpz_mat_rref_fraction_free(long * perm, fmpz_mat_t B, fmpz_t den, const fmpz_mat_t A) + # Sets (``Ainv``, ``den``) to the inverse matrix of ``A``. + # Returns 1 if ``A`` is nonsingular and 0 if ``A`` is singular. + # Aliasing of ``Ainv`` and ``A`` is allowed. + # The denominator is not guaranteed to be minimal, but is guaranteed + # to be a divisor of the determinant of ``A``. + # This function uses a direct formula for matrices of size two or less, + # and otherwise solves for the identity matrix using + # fraction-free LU decomposition. + + void fmpz_mat_kronecker_product(fmpz_mat_t C, const fmpz_mat_t A, const fmpz_mat_t B) + # Sets ``C`` to the Kronecker product of ``A`` and ``B``. + + void fmpz_mat_content(fmpz_t mat_gcd, const fmpz_mat_t A) + # Sets ``mat_gcd`` as the gcd of all the elements of the matrix ``A``. + # Returns 0 if the matrix is empty. + + void fmpz_mat_trace(fmpz_t trace, const fmpz_mat_t mat) + # Computes the trace of the matrix, i.e. the sum of the entries on + # the main diagonal. The matrix is required to be square. + + void fmpz_mat_det(fmpz_t det, const fmpz_mat_t A) + # Sets ``det`` to the determinant of the square matrix `A`. + # The matrix of dimension `0 \times 0` is defined to have determinant 1. + # This function automatically chooses between :func:`fmpz_mat_det_cofactor`, + # :func:`fmpz_mat_det_bareiss`, :func:`fmpz_mat_det_modular` and + # :func:`fmpz_mat_det_modular_accelerated` + # (with ``proved`` = 1), depending on the size of the matrix + # and its entries. + + void fmpz_mat_det_cofactor(fmpz_t det, const fmpz_mat_t A) + # Sets ``det`` to the determinant of the square matrix `A` + # computed using direct cofactor expansion. This function only + # supports matrices up to size `4 \times 4`. + + void fmpz_mat_det_bareiss(fmpz_t det, const fmpz_mat_t A) + # Sets ``det`` to the determinant of the square matrix `A` + # computed using the Bareiss algorithm. A copy of the input matrix is + # row reduced using fraction-free Gaussian elimination, and the + # determinant is read off from the last element on the main + # diagonal. + + void fmpz_mat_det_modular(fmpz_t det, const fmpz_mat_t A, int proved) + # Sets ``det`` to the determinant of the square matrix `A` + # (if ``proved`` = 1), or a probabilistic value for the + # determinant (``proved`` = 0), computed using a multimodular + # algorithm. + # The determinant is computed modulo several small primes and + # reconstructed using the Chinese Remainder Theorem. + # With ``proved`` = 1, sufficiently many primes are chosen + # to satisfy the bound computed by ``fmpz_mat_det_bound``. + # With ``proved`` = 0, the determinant is considered determined + # if it remains unchanged modulo several consecutive primes + # (currently if their product exceeds `2^{100}`). + + void fmpz_mat_det_modular_accelerated(fmpz_t det, const fmpz_mat_t A, int proved) + # Sets ``det`` to the determinant of the square matrix `A` + # (if ``proved`` = 1), or a probabilistic value for the + # determinant (``proved`` = 0), computed using a multimodular + # algorithm. + # This function uses the same basic algorithm as ``fmpz_mat_det_modular``, + # but instead of computing `\det(A)` directly, it generates a divisor `d` + # of `\det(A)` and then computes `x = \det(A) / d` modulo several + # small primes not dividing `d`. This typically accelerates the + # computation by requiring fewer primes for large matrices, since `d` + # with high probability will be nearly as large as the determinant. + # This trick is described in [AbbottBronsteinMulders1999]_. + + void fmpz_mat_det_modular_given_divisor(fmpz_t det, const fmpz_mat_t A, const fmpz_t d, int proved) + # Given a positive divisor `d` of `\det(A)`, sets ``det`` to the + # determinant of the square matrix `A` (if ``proved`` = 1), or a + # probabilistic value for the determinant (``proved`` = 0), computed + # using a multimodular algorithm. + + void fmpz_mat_det_bound(fmpz_t bound, const fmpz_mat_t A) + # Sets ``bound`` to a nonnegative integer `B` such that + # `|\det(A)| \le B`. Assumes `A` to be a square matrix. + # The bound is computed from the Hadamard inequality + # `|\det(A)| \le \prod \|a_i\|_2` where the product is taken + # over the rows `a_i` of `A`. + + void fmpz_mat_det_bound_nonzero(fmpz_t bound, const fmpz_mat_t A) + # As per ``fmpz_mat_det_bound()`` but excludes zero columns. For use with + # non-square matrices. + + void fmpz_mat_det_divisor(fmpz_t d, const fmpz_mat_t A) + # Sets `d` to some positive divisor of the determinant of the given + # square matrix `A`, if the determinant is nonzero. If `|\det(A)| = 0`, + # `d` will always be set to zero. + # A divisor is obtained by solving `Ax = b` for an arbitrarily chosen + # right-hand side `b` using Dixon's algorithm and computing the least + # common multiple of the denominators in `x`. This yields a divisor `d` + # such that `|\det(A)| / d` is tiny with very high probability. + + void fmpz_mat_similarity(fmpz_mat_t A, long r, fmpz_t d) + # Applies a similarity transform to the `n\times n` matrix `M` in-place. + # If `P` is the `n\times n` identity matrix the zero entries of whose row + # `r` (`0`-indexed) have been replaced by `d`, this transform is equivalent + # to `M = P^{-1}MP`. + # Similarity transforms preserve the determinant, characteristic polynomial + # and minimal polynomial. + + void _fmpz_mat_charpoly_berkowitz(fmpz * cp, const fmpz_mat_t mat) + # Sets ``(cp, n+1)`` to the characteristic polynomial of + # an `n \times n` square matrix. + + void fmpz_mat_charpoly_berkowitz(fmpz_poly_t cp, const fmpz_mat_t mat) + # Computes the characteristic polynomial of length `n + 1` of + # an `n \times n` square matrix. Uses an `O(n^4)` algorithm based on the + # method of Berkowitz. + + void _fmpz_mat_charpoly_modular(fmpz * cp, const fmpz_mat_t mat) + # Sets ``(cp, n+1)`` to the characteristic polynomial of + # an `n \times n` square matrix. + + void fmpz_mat_charpoly_modular(fmpz_poly_t cp, const fmpz_mat_t mat) + # Computes the characteristic polynomial of length `n + 1` of + # an `n \times n` square matrix. Uses a modular method based on an `O(n^3)` + # method over `\mathbb{Z}/n\mathbb{Z}`. + + void _fmpz_mat_charpoly(fmpz * cp, const fmpz_mat_t mat) + # Sets ``(cp, n+1)`` to the characteristic polynomial of + # an `n \times n` square matrix. + + void fmpz_mat_charpoly(fmpz_poly_t cp, const fmpz_mat_t mat) + # Computes the characteristic polynomial of length `n + 1` of + # an `n \times n` square matrix. + + long _fmpz_mat_minpoly_modular(fmpz * cp, const fmpz_mat_t mat) + # Sets ``(cp, n+1)`` to the modular polynomial of + # an `n \times n` square matrix and returns its length. + + void fmpz_mat_minpoly_modular(fmpz_poly_t cp, const fmpz_mat_t mat) + # Computes the minimal polynomial of an `n \times n` square matrix. + # Uses a modular method based on an average time `O(n^3)`, worst case + # `O(n^4)` method over `\mathbb{Z}/n\mathbb{Z}`. + + long _fmpz_mat_minpoly(fmpz * cp, const fmpz_mat_t mat) + # Sets ``cp`` to the minimal polynomial of an `n \times n` square + # matrix and returns its length. + + void fmpz_mat_minpoly(fmpz_poly_t cp, const fmpz_mat_t mat) + # Computes the minimal polynomial of an `n \times n` square matrix. + long fmpz_mat_rank(const fmpz_mat_t A) + # Returns the rank, that is, the number of linearly independent columns + # (equivalently, rows), of `A`. The rank is computed by row reducing + # a copy of `A`. + + int fmpz_mat_col_partition(long * part, fmpz_mat_t M, int short_circuit) + # Returns the number `p` of distinct columns of `M` (or `0` if the flag + # ``short_circuit`` is set and this number is greater than the number + # of rows of `M`). The entries of array ``part`` are set to values in + # `[0, p)` such that two entries of part are equal iff the corresponding + # columns of `M` are equal. This function is used in van Hoeij polynomial + # factoring. + int fmpz_mat_solve(fmpz_mat_t X, fmpz_t den, const fmpz_mat_t A, const fmpz_mat_t B) + # Solves the equation `AX = B` for nonsingular `A`. More precisely, computes + # (``X``, ``den``) such that `AX = B \times \operatorname{den}`. + # Returns 1 if `A` is nonsingular and 0 if `A` is singular. + # The computed denominator will not generally be minimal. + # This function uses Cramer's rule for small systems and + # fraction-free LU decomposition followed by fraction-free forward + # and back substitution for larger systems. + # Note that for very large systems, it is faster to compute a modular + # solution using ``fmpz_mat_solve_dixon``. + + int fmpz_mat_solve_fflu(fmpz_mat_t X, fmpz_t den, const fmpz_mat_t A, const fmpz_mat_t B) + # Solves the equation `AX = B` for nonsingular `A`. More precisely, computes + # (``X``, ``den``) such that `AX = B \times \operatorname{den}`. + # Returns 1 if `A` is nonsingular and 0 if `A` is singular. + # The computed denominator will not generally be minimal. + # Uses fraction-free LU decomposition followed by fraction-free + # forward and back substitution. + + int fmpz_mat_solve_fflu_precomp(fmpz_mat_t X, const long * perm, const fmpz_mat_t FFLU, const fmpz_mat_t B) + # Performs fraction-free forward and back substitution given a precomputed + # fraction-free LU decomposition and corresponding permutation. If no + # impossible division is encountered, the function returns `1`. This does not + # mean the system has a solution, however a return value of `0` can only + # occur if the system is insoluble. + # If the return value is `1` and `r` is the rank of the matrix `A` whose FFLU + # we have, then the first `r` rows of `p(A)y = p(b)d` hold, where `d` is the + # denominator of the FFLU. The remaining rows must be checked by the caller. + + int fmpz_mat_solve_cramer(fmpz_mat_t X, fmpz_t den, const fmpz_mat_t A, const fmpz_mat_t B) + # Solves the equation `AX = B` for nonsingular `A`. More precisely, computes + # (``X``, ``den``) such that `AX = B \times \operatorname{den}`. + # Returns 1 if `A` is nonsingular and 0 if `A` is singular. + # Uses Cramer's rule. Only systems of size up to `3 \times 3` are allowed. + + void fmpz_mat_solve_bound(fmpz_t N, fmpz_t D, const fmpz_mat_t A, const fmpz_mat_t B) + # Assuming that `A` is nonsingular, computes integers `N` and `D` + # such that the reduced numerators and denominators `n/d` in + # `A^{-1} B` satisfy the bounds `0 \le |n| \le N` and `0 \le d \le D`. + + int fmpz_mat_solve_dixon(fmpz_mat_t X, fmpz_t M, const fmpz_mat_t A, const fmpz_mat_t B) + # Solves `AX = B` given a nonsingular square matrix `A` and a matrix `B` of + # compatible dimensions, using a modular algorithm. In particular, + # Dixon's p-adic lifting algorithm is used (currently a non-adaptive version). + # This is generally the preferred method for large dimensions. + # More precisely, this function computes an integer `M` and an integer + # matrix `X` such that `AX = B \bmod M` and such that all the reduced + # numerators and denominators of the elements `x = p/q` in the full + # solution satisfy `2|p|q < M`. As such, the explicit rational solution + # matrix can be recovered uniquely by passing the output of this + # function to ``fmpq_mat_set_fmpz_mat_mod``. + # A nonzero value is returned if `A` is nonsingular. If `A` is singular, + # zero is returned and the values of the output variables will be + # undefined. + # Aliasing between input and output matrices is allowed. + + void _fmpz_mat_solve_dixon_den(fmpz_mat_t X, fmpz_t den, const fmpz_mat_t A, const fmpz_mat_t B, const nmod_mat_t Ainv, mp_limb_t p, const fmpz_t N, const fmpz_t D) + # Solves the equation `AX = B` for nonsingular `A`. More precisely, computes + # (``X``, ``den``) such that `AX = B \times \operatorname{den}` using a + # ``p``-adic algorithm for the supplied prime ``p``. The values ``N`` and + # ``D`` are absolute value bounds for the numerator and denominator of the + # solution. + # Uses the Dixon lifting algorithm with early termination once the lifting + # stabilises. + + int fmpz_mat_solve_dixon_den(fmpz_mat_t X, fmpz_t den, const fmpz_mat_t A, const fmpz_mat_t B) + # Solves the equation `AX = B` for nonsingular `A`. More precisely, computes + # (``X``, ``den``) such that `AX = B \times \operatorname{den}`. + # Returns 1 if `A` is nonsingular and 0 if `A` is singular. + # The computed denominator will not generally be minimal. + # Uses the Dixon lifting algorithm with early termination once the lifting + # stabilises. + + int fmpz_mat_solve_multi_mod_den(fmpz_mat_t X, fmpz_t den, const fmpz_mat_t A, const fmpz_mat_t B) + # Solves the equation `AX = B` for nonsingular `A`. More precisely, computes + # (``X``, ``den``) such that `AX = B \times \operatorname{den}`. + # Returns 1 if `A` is nonsingular and 0 if `A` is singular. + # The computed denominator will not generally be minimal. + # Uses a Chinese remainder algorithm with early termination once the lifting + # stabilises. + + int fmpz_mat_can_solve_multi_mod_den(fmpz_mat_t X, fmpz_t den, const fmpz_mat_t A, const fmpz_mat_t B) + # Returns `1` if the system `AX = B` can be solved. If so it computes + # (``X``, ``den``) such that `AX = B \times \operatorname{den}`. The + # computed denominator will not generally be minimal. + # Uses a Chinese remainder algorithm. + # Note that the matrices `A` and `B` may have any shape as long as they have + # the same number of rows. + + int fmpz_mat_can_solve_fflu(fmpz_mat_t X, fmpz_t den, const fmpz_mat_t A, const fmpz_mat_t B) + # Returns `1` if the system `AX = B` can be solved. If so it computes + # (``X``, ``den``) such that `AX = B \times \operatorname{den}`. The + # computed denominator will not generally be minimal. + # Uses a fraction free LU decomposition algorithm. + # Note that the matrices `A` and `B` may have any shape as long as they have + # the same number of rows. + + int fmpz_mat_can_solve(fmpz_mat_t X, fmpz_t den, const fmpz_mat_t A, const fmpz_mat_t B) + # Returns `1` if the system `AX = B` can be solved. If so it computes + # (``X``, ``den``) such that `AX = B \times \operatorname{den}`. The + # computed denominator will not generally be minimal. + # Note that the matrices `A` and `B` may have any shape as long as they have + # the same number of rows. + + long fmpz_mat_find_pivot_any(const fmpz_mat_t mat, long start_row, long end_row, long c) + # Attempts to find a pivot entry for row reduction. + # Returns a row index `r` between ``start_row`` (inclusive) and + # ``stop_row`` (exclusive) such that column `c` in ``mat`` has + # a nonzero entry on row `r`, or returns -1 if no such entry exists. + # This implementation simply chooses the first nonzero entry + # it encounters. This is likely to be a nearly optimal choice if all + # entries in the matrix have roughly the same size, but can lead to + # unnecessary coefficient growth if the entries vary in size. + + long fmpz_mat_fflu(fmpz_mat_t B, fmpz_t den, long * perm, const fmpz_mat_t A, int rank_check) + # Uses fraction-free Gaussian elimination to set (``B``, ``den``) to a + # fraction-free LU decomposition of ``A`` and returns the + # rank of ``A``. Aliasing of ``A`` and ``B`` is allowed. + # Pivot elements are chosen with ``fmpz_mat_find_pivot_any``. + # If ``perm`` is non-``NULL``, the permutation of + # rows in the matrix will also be applied to ``perm``. + # If ``rank_check`` is set, the function aborts and returns 0 if the + # matrix is detected not to have full rank without completing the + # elimination. + # The denominator ``den`` is set to `\pm \operatorname{det}(S)` where + # `S` is an appropriate submatrix of `A` (`S = A` if `A` is square) + # and the sign is decided by the parity of the permutation. Note that the + # determinant is not generally the minimal denominator. + # The fraction-free LU decomposition is defined in [NakTurWil1997]_. + + long fmpz_mat_rref(fmpz_mat_t B, fmpz_t den, const fmpz_mat_t A) + # Sets (``B``, ``den``) to the reduced row echelon form of ``A`` + # and returns the rank of ``A``. Aliasing of ``A`` and ``B`` + # is allowed. + # The algorithm used chooses between ``fmpz_mat_rref_fflu`` and + # ``fmpz_mat_rref_mul`` based on the dimensions of the input matrix. + + long fmpz_mat_rref_fflu(fmpz_mat_t B, fmpz_t den, const fmpz_mat_t A) + # Sets (``B``, ``den``) to the reduced row echelon form of ``A`` + # and returns the rank of ``A``. Aliasing of ``A`` and ``B`` + # is allowed. + # The algorithm proceeds by first computing a row echelon form using + # ``fmpz_mat_fflu``. Letting the upper part of this matrix be + # `(U | V) P` where `U` is full rank upper triangular and `P` is a + # permutation matrix, we obtain the rref by setting `V` to `U^{-1} V` + # using back substitution. Scaling each completed row in the back + # substitution to the denominator ``den``, we avoid introducing + # new fractions. This strategy is equivalent to the fraction-free + # Gauss-Jordan elimination in [NakTurWil1997]_, but faster since + # only the part `V` corresponding to the null space has to be updated. + # The denominator ``den`` is set to `\pm \operatorname{det}(S)` where + # `S` is an appropriate submatrix of `A` (`S = A` if `A` is square). + # Note that the determinant is not generally the minimal denominator. + + long fmpz_mat_rref_mul(fmpz_mat_t B, fmpz_t den, const fmpz_mat_t A) + # Sets (``B``, ``den``) to the reduced row echelon form of ``A`` + # and returns the rank of ``A``. Aliasing of ``A`` and ``B`` + # is allowed. + # The algorithm works by computing the reduced row echelon form of ``A`` + # modulo a prime `p` using ``nmod_mat_rref``. The pivot columns and rows + # of this matrix will then define a non-singular submatrix of ``A``, + # nonsingular solving and matrix multiplication can then be used to determine + # the reduced row echelon form of the whole of ``A``. This procedure is + # described in [Stein2007]_. + + int fmpz_mat_is_in_rref_with_rank(const fmpz_mat_t A, const fmpz_t den, long rank) + # Checks that the matrix `A/den` is in reduced row echelon form of rank + # ``rank``, returns 1 if so and 0 otherwise. + + long fmpz_mat_rref_mod(long * perm, fmpz_mat_t A, const fmpz_t p) + # Uses fraction-free Gauss-Jordan elimination to set ``A`` + # to its reduced row echelon form and returns the rank of ``A``. + # All computations are done modulo p. + # Pivot elements are chosen with ``fmpz_mat_find_pivot_any``. + # If ``perm`` is non-``NULL``, the permutation of + # rows in the matrix will also be applied to ``perm``. + + void fmpz_mat_strong_echelon_form_mod(fmpz_mat_t A, const fmpz_t mod) + # Transforms `A` such that `A` modulo ``mod`` is the strong echelon form + # of the input matrix modulo ``mod``. The Howell form and the strong + # echelon form are equal up to permutation of the rows, see [FieHof2014]_ + # for a definition of the strong echelon form and the algorithm used here. + # `A` must have at least as many rows as columns. + + long fmpz_mat_howell_form_mod(fmpz_mat_t A, const fmpz_t mod) + # Transforms `A` such that `A` modulo ``mod`` is the Howell form of the + # input matrix modulo ``mod``. + # For a definition of the Howell form see [StoMul1998]_. The Howell form + # is computed by first putting `A` into strong echelon form and then ordering + # the rows. + # `A` must have at least as many rows as columns. + long fmpz_mat_nullspace(fmpz_mat_t B, const fmpz_mat_t A) - void fmpz_mat_hnf(fmpz_mat_t H , const fmpz_mat_t A) + # Computes a basis for the right rational nullspace of `A` and returns + # the dimension of the nullspace (or nullity). `B` is set to a matrix with + # linearly independent columns and maximal rank such that `AB = 0` + # (i.e. `Ab = 0` for each column `b` in `B`), and the rank of `B` is + # returned. + # In general, the entries in `B` will not be minimal: in particular, + # the pivot entries in `B` will generally differ from unity. + # `B` must be allocated with sufficient space to represent the result + # (at most `n \times n` where `n` is the number of columns of `A`). + + long fmpz_mat_rref_fraction_free(long * perm, fmpz_mat_t B, fmpz_t den, const fmpz_mat_t A) + # Computes an integer matrix ``B`` and an integer ``den`` such that + # ``B / den`` is the unique row reduced echelon form (RREF) of ``A`` + # and returns the rank, i.e. the number of nonzero rows in ``B``. + # Aliasing of ``B`` and ``A`` is allowed, with an in-place + # computation being more efficient. The size of ``B`` must be + # the same as that of ``A``. + # The permutation order will be written to ``perm`` unless this + # argument is ``NULL``. That is, row ``i`` of the output matrix will + # correspond to row ``perm[i]`` of the input matrix. + # The denominator will always be a divisor of the determinant of (some + # submatrix of) `A`, but is not guaranteed to be minimal or canonical in + # any other sense. + + void fmpz_mat_hnf(fmpz_mat_t H, const fmpz_mat_t A) + # Computes an integer matrix ``H`` such that ``H`` is the unique (row) + # Hermite normal form of ``A``. The algorithm used is selected from the + # implementations in FLINT to be the one most likely to be optimal, based on + # the characteristics of the input matrix. + # Aliasing of ``H`` and ``A`` is allowed. The size of ``H`` must be + # the same as that of ``A``. + void fmpz_mat_hnf_transform(fmpz_mat_t H, fmpz_mat_t U, const fmpz_mat_t A) + # Computes an integer matrix ``H`` such that ``H`` is the unique (row) + # Hermite normal form of ``A`` along with the transformation matrix + # ``U`` such that `UA = H`. The algorithm used is selected from the + # implementations in FLINT as per ``fmpz_mat_hnf``. + # Aliasing of ``H`` and ``A`` is allowed. The size of ``H`` must be + # the same as that of ``A`` and ``U`` must be square of \compatible + # dimension (having the same number of rows as ``A``). + + void fmpz_mat_hnf_classical(fmpz_mat_t H, const fmpz_mat_t A) + # Computes an integer matrix ``H`` such that ``H`` is the unique (row) + # Hermite normal form of ``A``. The algorithm used is straightforward and + # is described, for example, in [Algorithm 2.4.4] [Coh1996]_. + # Aliasing of ``H`` and ``A`` is allowed. The size of ``H`` must be + # the same as that of ``A``. + + void fmpz_mat_hnf_xgcd(fmpz_mat_t H, const fmpz_mat_t A) + # Computes an integer matrix ``H`` such that ``H`` is the unique (row) + # Hermite normal form of ``A``. The algorithm used is an improvement on the + # basic algorithm and uses extended gcds to speed up computation, this method + # is described, for example, in [Algorithm 2.4.5] [Coh1996]_. + # Aliasing of ``H`` and ``A`` is allowed. The size of ``H`` must be + # the same as that of ``A``. + + void fmpz_mat_hnf_modular(fmpz_mat_t H, const fmpz_mat_t A, const fmpz_t D) + # Computes an integer matrix ``H`` such that ``H`` is the unique (row) + # Hermite normal form of the `m\times n` matrix ``A``, where ``A`` is + # assumed to be of rank `n` and ``D`` is known to be a positive multiple of + # the determinant of the non-zero rows of ``H``. The algorithm used here is + # due to Domich, Kannan and Trotter [DomKanTro1987]_ and is also described + # in [Algorithm 2.4.8] [Coh1996]_. + # Aliasing of ``H`` and ``A`` is allowed. The size of ``H`` must be + # the same as that of ``A``. + + void fmpz_mat_hnf_modular_eldiv(fmpz_mat_t A, const fmpz_t D) + # Transforms the `m\times n` matrix ``A`` into Hermite normal form, + # where ``A`` is assumed to be of rank `n` and ``D`` is known to be a + # positive multiple of the largest elementary divisor of ``A``. + # The algorithm used here is described in [FieHof2014]_. + + void fmpz_mat_hnf_minors(fmpz_mat_t H, const fmpz_mat_t A) + # Computes an integer matrix ``H`` such that ``H`` is the unique (row) + # Hermite normal form of the `m\times n` matrix ``A``, where ``A`` is + # assumed to be of rank `n`. The algorithm used here is due to Kannan and + # Bachem [KanBac1979]_ and takes the principal minors to Hermite normal + # form in turn. + # Aliasing of ``H`` and ``A`` is allowed. The size of ``H`` must be + # the same as that of ``A``. + + void fmpz_mat_hnf_pernet_stein(fmpz_mat_t H, const fmpz_mat_t A, flint_rand_t state) + # Computes an integer matrix ``H`` such that ``H`` is the unique (row) + # Hermite normal form of the `m\times n` matrix ``A``. The algorithm used + # here is due to Pernet and Stein [PernetStein2010]_. + # Aliasing of ``H`` and ``A`` is allowed. The size of ``H`` must be + # the same as that of ``A``. + + int fmpz_mat_is_in_hnf(const fmpz_mat_t A) + # Checks that the given matrix is in Hermite normal form, returns 1 if so and + # 0 otherwise. + + void fmpz_mat_snf(fmpz_mat_t S, const fmpz_mat_t A) + # Computes an integer matrix ``S`` such that ``S`` is the unique Smith + # normal form of ``A``. The algorithm used is selected from the + # implementations in FLINT to be the one most likely to be optimal, based on + # the characteristics of the input matrix. + # Aliasing of ``S`` and ``A`` is allowed. The size of ``S`` must be + # the same as that of ``A``. + + void fmpz_mat_snf_diagonal(fmpz_mat_t S, const fmpz_mat_t A) + # Computes an integer matrix ``S`` such that ``S`` is the unique Smith + # normal form of the diagonal matrix ``A``. The algorithm used simply takes + # gcds of pairs on the diagonal in turn until the Smith form is obtained. + # Aliasing of ``S`` and ``A`` is allowed. The size of ``S`` must be + # the same as that of ``A``. + + void fmpz_mat_snf_kannan_bachem(fmpz_mat_t S, const fmpz_mat_t A) + # Computes an integer matrix ``S`` such that ``S`` is the unique Smith + # normal form of the diagonal matrix ``A``. The algorithm used here is due + # to Kannan and Bachem [KanBac1979]_ + # Aliasing of ``S`` and ``A`` is allowed. The size of ``S`` must be + # the same as that of ``A``. + + void fmpz_mat_snf_iliopoulos(fmpz_mat_t S, const fmpz_mat_t A, const fmpz_t mod) + # Computes an integer matrix ``S`` such that ``S`` is the unique Smith + # normal form of the nonsingular `n\times n` matrix ``A``. The algorithm + # used is due to Iliopoulos [Iliopoulos1989]_. + # Aliasing of ``S`` and ``A`` is allowed. The size of ``S`` must be + # the same as that of ``A``. + + int fmpz_mat_is_in_snf(const fmpz_mat_t A) + # Checks that the given matrix is in Smith normal form, returns 1 if so and 0 + # otherwise. + + void fmpz_mat_gram(fmpz_mat_t B, const fmpz_mat_t A) + # Sets ``B`` to the Gram matrix of the `m`-dimensional lattice ``L`` in + # `n`-dimensional Euclidean space `R^n` spanned by the rows of + # the `m \times n` matrix ``A``. Dimensions must be compatible. + # ``A`` and ``B`` are allowed to be the same object if ``A`` is a + # square matrix. + + int fmpz_mat_is_hadamard(const fmpz_mat_t H) + # Returns nonzero iff `H` is a Hadamard matrix, meaning + # that it is a square matrix, only has entries that are `\pm 1`, + # and satisfies `H^T = n H^{-1}` where `n` is the matrix size. + + int fmpz_mat_hadamard(fmpz_mat_t H) + # Attempts to set the matrix `H` to a Hadamard matrix, returning 1 if + # successful and 0 if unsuccessful. + # A Hadamard matrix of size `n` can only exist if `n` is 1, 2, + # or a multiple of 4. It is not known whether a + # Hadamard matrix exists for every size that is a multiple of 4. + # This function uses the Paley construction, which + # succeeds for all `n` of the form `n = 2^e` or `n = 2^e (q + 1)` where + # `q` is an odd prime power. Orders `n` for which Hadamard matrices are + # known to exist but for which this construction fails are + # 92, 116, 156, ... (OEIS A046116). + + int fmpz_mat_get_d_mat(d_mat_t B, const fmpz_mat_t A) + # Sets the entries of ``B`` as doubles corresponding to the entries of + # ``A``, rounding down towards zero if the latter cannot be represented + # exactly. The return value is -1 if any entry of ``A`` is too large to + # fit in the normal range of a double, and 0 otherwise. + + int fmpz_mat_get_d_mat_transpose(d_mat_t B, const fmpz_mat_t A) + # Sets the entries of ``B`` as doubles corresponding to the entries of + # the transpose of ``A``, rounding down towards zero if the latter cannot + # be represented exactly. The return value is -1 if any entry of ``A`` is + # too large to fit in the normal range of a double, and 0 otherwise. + + void fmpz_mat_chol_d(d_mat_t R, const fmpz_mat_t A) + # Computes ``R``, the Cholesky factor of a symmetric, positive definite + # matrix ``A`` using the Cholesky decomposition process. (Sets ``R`` + # such that `A = RR^{T}` where ``R`` is a lower triangular matrix.) + + int fmpz_mat_is_reduced(const fmpz_mat_t A, double delta, double eta) + int fmpz_mat_is_reduced_gram(const fmpz_mat_t A, double delta, double eta) + # Returns a non-zero value if the basis ``A`` is LLL-reduced with factor + # (``delta``, ``eta``), and otherwise returns zero. + # The second version assumes ``A`` is the Gram matrix of the basis. + + int fmpz_mat_is_reduced_with_removal(const fmpz_mat_t A, double delta, double eta, const fmpz_t gs_B, int newd) + int fmpz_mat_is_reduced_gram_with_removal(const fmpz_mat_t A, double delta, double eta, const fmpz_t gs_B, int newd) + # Returns a non-zero value if the basis ``A`` is LLL-reduced with factor + # (``delta``, ``eta``) for each of the first ``newd`` vectors and the squared + # Gram-Schmidt length of each of the remaining `i`-th vectors + # (where `i \ge` ``newd``) is greater than ``gs_B``, and otherwise returns zero. + # The second version assumes ``A`` is the Gram matrix of the basis. + + void fmpz_mat_lll_original(fmpz_mat_t A, const fmpq_t delta, const fmpq_t eta) + # Takes a basis `x_1, x_2, \ldots, x_m` of the lattice `L \subset R^n` (as + # the rows of a `m \times n` matrix ``A``). The output is a (``delta``, + # ``eta``)-reduced basis `y_1, y_2, \ldots, y_m` of the lattice `L` (as + # the rows of the same `m \times n` matrix ``A``). + + void fmpz_mat_lll_storjohann(fmpz_mat_t A, const fmpq_t delta, const fmpq_t eta) + # Takes a basis `x_1, x_2, \ldots, x_m` of the lattice `L \subset R^n` (as + # the rows of a `m \times n` matrix ``A``). The output is an (``delta``, + # ``eta``)-reduced basis `y_1, y_2, \ldots, y_m` of the lattice `L` (as + # the rows of the same `m \times n` matrix ``A``). Uses a modified version of + # LLL, which has better complexity in terms of the lattice dimension, + # introduced by Storjohann. + # See "Faster Algorithms for Integer Lattice Basis Reduction." Technical + # Report 249. Zurich, Switzerland: Department Informatik, ETH. July 30, + # 1996. diff --git a/src/sage/libs/flint/fmpz_mod.pxd b/src/sage/libs/flint/fmpz_mod.pxd index 555b3123398..54df929e69a 100644 --- a/src/sage/libs/flint/fmpz_mod.pxd +++ b/src/sage/libs/flint/fmpz_mod.pxd @@ -1,46 +1,94 @@ # distutils: libraries = flint # distutils: depends = flint/fmpz_mod.h -# flint/fmpz_mod.h +################################################################################ +# This file is auto-generated. Do not modify by hand +################################################################################ + +from libc.stdio cimport FILE +from sage.libs.gmp.types cimport * +from sage.libs.mpfr.types cimport * +from sage.libs.flint.types cimport * + cdef extern from "flint_wrap.h": + void fmpz_mod_ctx_init(fmpz_mod_ctx_t ctx, const fmpz_t n) - void fmpz_mod_ctx_init_ui(fmpz_mod_ctx_t ctx, ulong n) - void fmpz_mod_ctx_clear(fmpz_mod_ctx_t ctx) + # Initialise ``ctx`` for arithmetic modulo ``n``, which is expected to be positive. - const fmpz * fmpz_mod_ctx_modulus(const fmpz_mod_ctx_t ctx) + void fmpz_mod_ctx_clear(fmpz_mod_ctx_t ctx) + # Free any memory used by ``ctx``. void fmpz_mod_ctx_set_modulus(fmpz_mod_ctx_t ctx, const fmpz_t n) - void fmpz_mod_ctx_set_modulus_ui(fmpz_mod_ctx_t ctx, ulong n) + # Reconfigure ``ctx`` for arithmetic modulo ``n``. + + void fmpz_mod_set_fmpz(fmpz_t a, const fmpz_t b, const fmpz_mod_ctx_t ctx) + # Set ``a`` to ``b`` after reduction modulo the modulus. int fmpz_mod_is_canonical(const fmpz_t a, const fmpz_mod_ctx_t ctx) - void fmpz_mod_assert_canonical(const fmpz_t a, const fmpz_mod_ctx_t ctx) + # Return ``1`` if `a` is in the canonical range `[0,n)` and ``0`` otherwise. int fmpz_mod_is_one(const fmpz_t a, const fmpz_mod_ctx_t ctx) + # Return ``1`` if `a` is `1` modulo `n` and return ``0`` otherwise. + void fmpz_mod_add(fmpz_t a, const fmpz_t b, const fmpz_t c, const fmpz_mod_ctx_t ctx) + # Set `a` to `b+c` modulo `n`. + + void fmpz_mod_add_fmpz(fmpz_t a, const fmpz_t b, const fmpz_t c, const fmpz_mod_ctx_t ctx) + void fmpz_mod_add_ui(fmpz_t a, const fmpz_t b, unsigned long c, const fmpz_mod_ctx_t ctx) + void fmpz_mod_add_si(fmpz_t a, const fmpz_t b, long c, const fmpz_mod_ctx_t ctx) + # Set `a` to `b+c` modulo `n` where only `b` is assumed to be canonical. + void fmpz_mod_sub(fmpz_t a, const fmpz_t b, const fmpz_t c, const fmpz_mod_ctx_t ctx) + # Set `a` to `b-c` modulo `n`. + + void fmpz_mod_sub_fmpz(fmpz_t a, const fmpz_t b, const fmpz_t c, const fmpz_mod_ctx_t ctx) + void fmpz_mod_sub_ui(fmpz_t a, const fmpz_t b, unsigned long c, const fmpz_mod_ctx_t ctx) + void fmpz_mod_sub_si(fmpz_t a, const fmpz_t b, long c, const fmpz_mod_ctx_t ctx) + # Set `a` to `b-c` modulo `n` where only `b` is assumed to be canonical. + + void fmpz_mod_fmpz_sub(fmpz_t a, const fmpz_t b, const fmpz_t c, const fmpz_mod_ctx_t ctx) + void fmpz_mod_ui_sub(fmpz_t a, unsigned long b, const fmpz_t c, const fmpz_mod_ctx_t ctx) + void fmpz_mod_si_sub(fmpz_t a, long b, const fmpz_t c, const fmpz_mod_ctx_t ctx) + # Set `a` to `b-c` modulo `n` where only `c` is assumed to be canonical. + void fmpz_mod_neg(fmpz_t a, const fmpz_t b, const fmpz_mod_ctx_t ctx) + # Set `a` to `-b` modulo `n`. void fmpz_mod_mul(fmpz_t a, const fmpz_t b, const fmpz_t c, const fmpz_mod_ctx_t ctx) + # Set `a` to `b\cdot c` modulo `n`. + void fmpz_mod_inv(fmpz_t a, const fmpz_t b, const fmpz_mod_ctx_t ctx) + # Set `a` to `b^{-1}` modulo `n`. + # This function expects that `b` is invertible modulo `n` and throws if this not the case. + # Invertibility may be tested with :func:`fmpz_mod_pow_fmpz` or :func:`fmpz_mod_divides`. int fmpz_mod_divides(fmpz_t a, const fmpz_t b, const fmpz_t c, const fmpz_mod_ctx_t ctx) - void fmpz_mod_pow_ui(fmpz_t a, const fmpz_t b, ulong pow, const fmpz_mod_ctx_t ctx) - int fmpz_mod_pow_fmpz(fmpz_t a, const fmpz_t b, const fmpz_t pow, const fmpz_mod_ctx_t ctx) + # If `a\cdot c = b \mod n` has a solution for `a` return `1` and set `a` to such a solution. Otherwise return `0` and leave `a` undefined. + + void fmpz_mod_pow_ui(fmpz_t a, const fmpz_t b, unsigned long e, const fmpz_mod_ctx_t ctx) + # Set `a` to `b^e` modulo `n`. + + int fmpz_mod_pow_fmpz(fmpz_t a, const fmpz_t b, const fmpz_t e, const fmpz_mod_ctx_t ctx) + # Try to set `a` to `b^e` modulo `n`. + # If `e < 0` and `b` is not invertible modulo `n`, the return is `0`. Otherwise, the return is `1`. void fmpz_mod_discrete_log_pohlig_hellman_init(fmpz_mod_discrete_log_pohlig_hellman_t L) + # Initialize ``L``. Upon initialization ``L`` is not ready for computation. void fmpz_mod_discrete_log_pohlig_hellman_clear(fmpz_mod_discrete_log_pohlig_hellman_t L) + # Free any space used by ``L``. - double fmpz_mod_discrete_log_pohlig_hellman_precompute_prime( - fmpz_mod_discrete_log_pohlig_hellman_t L, - const fmpz_t p) + double fmpz_mod_discrete_log_pohlig_hellman_precompute_prime(fmpz_mod_discrete_log_pohlig_hellman_t L, const fmpz_t p) + # Configure ``L`` for discrete logarithms modulo ``p`` to an internally chosen base. It is assumed that ``p`` is prime. + # The return is an estimate on the number of multiplications needed for one run. - void fmpz_mod_discrete_log_pohlig_hellman_run( - fmpz_t x, - const fmpz_mod_discrete_log_pohlig_hellman_t L, - const fmpz_t y) + const fmpz * fmpz_mod_discrete_log_pohlig_hellman_primitive_root(fmpz_mod_discrete_log_pohlig_hellman_t L) + # Return the internally stored base. - const fmpz * fmpz_mod_discrete_log_pohlig_hellman_primitive_root( - fmpz_mod_discrete_log_pohlig_hellman_t L) + void fmpz_mod_discrete_log_pohlig_hellman_run(fmpz_t x, const fmpz_mod_discrete_log_pohlig_hellman_t L, const fmpz_t y) + # Set ``x`` to the logarithm of ``y`` with respect to the internally stored base. ``y`` is expected to be reduced modulo the ``p``. + # The function is undefined if the logarithm does not exist. int fmpz_next_smooth_prime(fmpz_t a, const fmpz_t b) + # Either return `1` and set `a` to a smooth prime strictly greater than `b`, or return `0` and set `a` to `0`. + # The smooth primes returned by this function currently have no prime factor of `a-1` greater than `23`, but this should not be relied upon. diff --git a/src/sage/libs/flint/fmpz_mod_poly.pxd b/src/sage/libs/flint/fmpz_mod_poly.pxd index 2727246da98..f9644855389 100644 --- a/src/sage/libs/flint/fmpz_mod_poly.pxd +++ b/src/sage/libs/flint/fmpz_mod_poly.pxd @@ -1,453 +1,1349 @@ # distutils: libraries = flint # distutils: depends = flint/fmpz_mod_poly.h +################################################################################ +# This file is auto-generated. Do not modify by hand +################################################################################ + +from libc.stdio cimport FILE +from sage.libs.gmp.types cimport * +from sage.libs.mpfr.types cimport * from sage.libs.flint.types cimport * -from sage.libs.flint.thread_pool cimport * -# flint/fmpz_mod_poly.h cdef extern from "flint_wrap.h": - void fmpz_mod_poly_init(fmpz_mod_poly_t poly, const fmpz_t p, const fmpz_mod_ctx_t ctx) - void fmpz_mod_poly_clear(fmpz_mod_poly_t poly, const fmpz_mod_ctx_t ctx) - void fmpz_mod_poly_realloc(fmpz_mod_poly_t poly, slong alloc, - const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_init(fmpz_mod_poly_t poly, const fmpz_mod_ctx_t ctx) + # Initialises ``poly`` for use with context ``ctx`` and set it to zero. + # A corresponding call to :func:`fmpz_mod_poly_clear` must be made to free the memory used by the polynomial. - void fmpz_mod_poly_fit_length(fmpz_mod_poly_t poly, slong len, - const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_init2(fmpz_mod_poly_t poly, long alloc, const fmpz_mod_ctx_t ctx) + # Initialises ``poly`` with space for at least ``alloc`` coefficients + # and sets the length to zero. The allocated coefficients are all set to + # zero. - void fmpz_mod_poly_truncate(fmpz_mod_poly_t poly, slong len, const fmpz_mod_ctx_t ctx) - void fmpz_mod_poly_set_trunc(fmpz_mod_poly_t res, - const fmpz_mod_poly_t poly, slong n, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_clear(fmpz_mod_poly_t poly, const fmpz_mod_ctx_t ctx) + # Clears the given polynomial, releasing any memory used. It must + # be reinitialised in order to be used again. + + void fmpz_mod_poly_realloc(fmpz_mod_poly_t poly, long alloc, const fmpz_mod_ctx_t ctx) + # Reallocates the given polynomial to have space for ``alloc`` + # coefficients. If ``alloc`` is zero the polynomial is cleared + # and then reinitialised. If the current length is greater than + # ``alloc`` the polynomial is first truncated to length ``alloc``. + + void fmpz_mod_poly_fit_length(fmpz_mod_poly_t poly, long len, const fmpz_mod_ctx_t ctx) + # If ``len`` is greater than the number of coefficients currently + # allocated, then the polynomial is reallocated to have space for at + # least ``len`` coefficients. No data is lost when calling this + # function. + # The function efficiently deals with the case where it is called + # many times in small increments by at least doubling the number of + # allocated coefficients when length is larger than the number of + # coefficients currently allocated. + + void _fmpz_mod_poly_normalise(fmpz_mod_poly_t poly) + # Sets the length of ``poly`` so that the top coefficient is non-zero. + # If all coefficients are zero, the length is set to zero. This function + # is mainly used internally, as all functions guarantee normalisation. + + void _fmpz_mod_poly_set_length(fmpz_mod_poly_t poly, long len) + # Demotes the coefficients of ``poly`` beyond ``len`` and sets + # the length of ``poly`` to ``len``. + + void fmpz_mod_poly_truncate(fmpz_mod_poly_t poly, long len, const fmpz_mod_ctx_t ctx) + # If the current length of ``poly`` is greater than ``len``, it + # is truncated to have the given length. Discarded coefficients are + # not necessarily set to zero. + + void fmpz_mod_poly_set_trunc(fmpz_mod_poly_t res, const fmpz_mod_poly_t poly, long n, const fmpz_mod_ctx_t ctx) + # Notionally truncate ``poly`` to length `n` and set ``res`` to the + # result. The result is normalised. + + void fmpz_mod_poly_randtest(fmpz_mod_poly_t f, flint_rand_t state, long len, const fmpz_mod_ctx_t ctx) + # Sets the polynomial~`f` to a random polynomial of length up~``len``. + + void fmpz_mod_poly_randtest_irreducible(fmpz_mod_poly_t f, flint_rand_t state, long len, const fmpz_mod_ctx_t ctx) + # Sets the polynomial~`f` to a random irreducible polynomial of length + # up~``len``, assuming ``len`` is positive. + + void fmpz_mod_poly_randtest_not_zero(fmpz_mod_poly_t f, flint_rand_t state, long len, const fmpz_mod_ctx_t ctx) + # Sets the polynomial~`f` to a random polynomial of length up~``len``, + # assuming ``len`` is positive. + + void fmpz_mod_poly_randtest_monic(fmpz_mod_poly_t poly, flint_rand_t state, long len, const fmpz_mod_ctx_t ctx) + # Generates a random monic polynomial with length ``len``. + + void fmpz_mod_poly_randtest_monic_irreducible(fmpz_mod_poly_t poly, flint_rand_t state, long len, const fmpz_mod_ctx_t ctx) + # Generates a random monic irreducible polynomial with length ``len``. + + void fmpz_mod_poly_randtest_monic_primitive(fmpz_mod_poly_t poly, flint_rand_t state, long len, const fmpz_mod_ctx_t ctx) + # Generates a random monic irreducible primitive polynomial with + # length ``len``. + + void fmpz_mod_poly_randtest_trinomial(fmpz_mod_poly_t poly, flint_rand_t state, long len, const fmpz_mod_ctx_t ctx) + # Generates a random monic trinomial of length ``len``. + + int fmpz_mod_poly_randtest_trinomial_irreducible(fmpz_mod_poly_t poly, flint_rand_t state, long len, long max_attempts, const fmpz_mod_ctx_t ctx) + # Attempts to set ``poly`` to a monic irreducible trinomial of + # length ``len``. It will generate up to ``max_attempts`` + # trinomials in attempt to find an irreducible one. If + # ``max_attempts`` is ``0``, then it will keep generating + # trinomials until an irreducible one is found. Returns `1` if one + # is found and `0` otherwise. + + void fmpz_mod_poly_randtest_pentomial(fmpz_mod_poly_t poly, flint_rand_t state, long len, const fmpz_mod_ctx_t ctx) + # Generates a random monic pentomial of length ``len``. + + int fmpz_mod_poly_randtest_pentomial_irreducible(fmpz_mod_poly_t poly, flint_rand_t state, long len, long max_attempts, const fmpz_mod_ctx_t ctx) + # Attempts to set ``poly`` to a monic irreducible pentomial of + # length ``len``. It will generate up to ``max_attempts`` + # pentomials in attempt to find an irreducible one. If + # ``max_attempts`` is ``0``, then it will keep generating + # pentomials until an irreducible one is found. Returns `1` if one + # is found and `0` otherwise. + + void fmpz_mod_poly_randtest_sparse_irreducible(fmpz_mod_poly_t poly, flint_rand_t state, long len, const fmpz_mod_ctx_t ctx) + # Attempts to set ``poly`` to a sparse, monic irreducible polynomial + # with length ``len``. It attempts to find an irreducible + # trinomial. If that does not succeed, it attempts to find a + # irreducible pentomial. If that fails, then ``poly`` is just + # set to a random monic irreducible polynomial. + + long fmpz_mod_poly_degree(const fmpz_mod_poly_t poly, const fmpz_mod_ctx_t ctx) + # Returns the degree of the polynomial. The degree of the zero + # polynomial is defined to be `-1`. + + long fmpz_mod_poly_length(const fmpz_mod_poly_t poly, const fmpz_mod_ctx_t ctx) + # Returns the length of the polynomial, which is one more than + # its degree. - slong fmpz_mod_poly_degree(const fmpz_mod_poly_t poly, const fmpz_mod_ctx_t ctx) - slong fmpz_mod_poly_length(const fmpz_mod_poly_t poly, const fmpz_mod_ctx_t ctx) fmpz * fmpz_mod_poly_lead(const fmpz_mod_poly_t poly, const fmpz_mod_ctx_t ctx) - int fmpz_mod_poly_is_one(const fmpz_mod_poly_t poly, const fmpz_mod_ctx_t ctx) - int fmpz_mod_poly_is_gen(const fmpz_mod_poly_t op, const fmpz_mod_ctx_t ctx) - - void fmpz_mod_poly_set(fmpz_mod_poly_t poly1, - const fmpz_mod_poly_t poly2, const fmpz_mod_ctx_t ctx) - void fmpz_mod_poly_swap(fmpz_mod_poly_t poly1, - fmpz_mod_poly_t poly2, const fmpz_mod_ctx_t ctx) - void fmpz_mod_poly_reverse(fmpz_mod_poly_t res, - const fmpz_mod_poly_t poly, slong n, const fmpz_mod_ctx_t ctx) - void fmpz_mod_poly_zero(fmpz_mod_poly_t poly, const fmpz_mod_ctx_t ctx) - void fmpz_mod_poly_one(fmpz_mod_poly_t poly, const fmpz_mod_ctx_t ctx) - void fmpz_mod_poly_zero_coeffs(fmpz_mod_poly_t poly, - slong i, slong j, const fmpz_mod_ctx_t ctx) - - void fmpz_mod_poly_set_ui(fmpz_mod_poly_t f, ulong x, const fmpz_mod_ctx_t ctx) - - void fmpz_mod_poly_set_fmpz(fmpz_mod_poly_t poly, const fmpz_t c, - const fmpz_mod_ctx_t ctx) - - void fmpz_mod_poly_set_fmpz_poly(fmpz_mod_poly_t f, - const fmpz_poly_t g, const fmpz_mod_ctx_t ctx) - - void fmpz_mod_poly_get_fmpz_poly(fmpz_poly_t f, - const fmpz_mod_poly_t g, const fmpz_mod_ctx_t ctx) - - int fmpz_mod_poly_equal(const fmpz_mod_poly_t poly1, - const fmpz_mod_poly_t poly2, const fmpz_mod_ctx_t ctx) - - int fmpz_mod_poly_equal_trunc(const fmpz_mod_poly_t poly1, - const fmpz_mod_poly_t poly2, slong n, const fmpz_mod_ctx_t ctx) - - int fmpz_mod_poly_is_zero(const fmpz_mod_poly_t poly, const fmpz_mod_ctx_t ctx) - - void fmpz_mod_poly_set_coeff_fmpz(fmpz_mod_poly_t poly, slong n, - const fmpz_t x, const fmpz_mod_ctx_t ctx) - - void fmpz_mod_poly_set_coeff_ui(fmpz_mod_poly_t poly, slong n, - ulong x, const fmpz_mod_ctx_t ctx) - - void fmpz_mod_poly_set_coeff_si(fmpz_mod_poly_t poly, slong n, - slong x, const fmpz_mod_ctx_t ctx) - - void fmpz_mod_poly_get_coeff_fmpz(fmpz_t x, const fmpz_mod_poly_t poly, - slong n, const fmpz_mod_ctx_t ctx) - - void _fmpz_mod_poly_shift_left(fmpz * res, const fmpz * poly, - slong len, slong n) - - void fmpz_mod_poly_shift_left(fmpz_mod_poly_t f, - const fmpz_mod_poly_t g, slong n, const fmpz_mod_ctx_t ctx) - - void fmpz_mod_poly_shift_right(fmpz_mod_poly_t f, - const fmpz_mod_poly_t g, slong n, const fmpz_mod_ctx_t ctx) - - void fmpz_mod_poly_add(fmpz_mod_poly_t res, const fmpz_mod_poly_t poly1, - const fmpz_mod_poly_t poly2, const fmpz_mod_ctx_t ctx) - - void fmpz_mod_poly_add_series(fmpz_mod_poly_t res, - const fmpz_mod_poly_t poly1, const fmpz_mod_poly_t poly2, - slong n, const fmpz_mod_ctx_t ctx) - - void fmpz_mod_poly_sub(fmpz_mod_poly_t res, const fmpz_mod_poly_t poly1, - const fmpz_mod_poly_t poly2, const fmpz_mod_ctx_t ctx) - - void fmpz_mod_poly_sub_series(fmpz_mod_poly_t res, - const fmpz_mod_poly_t poly1, const fmpz_mod_poly_t poly2, - slong n, const fmpz_mod_ctx_t ctx) - - void fmpz_mod_poly_neg(fmpz_mod_poly_t res, - const fmpz_mod_poly_t poly, const fmpz_mod_ctx_t ctx) - - void fmpz_mod_poly_scalar_mul_fmpz(fmpz_mod_poly_t res, - const fmpz_mod_poly_t poly, const fmpz_t x, const fmpz_mod_ctx_t ctx) - - void fmpz_mod_poly_scalar_mul_ui(fmpz_mod_poly_t res, - const fmpz_mod_poly_t poly, ulong x, const fmpz_mod_ctx_t ctx) - - void fmpz_mod_poly_scalar_div_fmpz(fmpz_mod_poly_t res, - const fmpz_mod_poly_t poly, const fmpz_t x, const fmpz_mod_ctx_t ctx) - - void fmpz_mod_poly_mul(fmpz_mod_poly_t res, const fmpz_mod_poly_t poly1, - const fmpz_mod_poly_t poly2, const fmpz_mod_ctx_t ctx) - - void fmpz_mod_poly_mullow(fmpz_mod_poly_t res, - const fmpz_mod_poly_t poly1, const fmpz_mod_poly_t poly2, - slong n, const fmpz_mod_ctx_t ctx) - - void fmpz_mod_poly_sqr(fmpz_mod_poly_t res, - const fmpz_mod_poly_t poly, const fmpz_mod_ctx_t ctx) - - void fmpz_mod_poly_mulmod(fmpz_mod_poly_t res, - const fmpz_mod_poly_t poly1, const fmpz_mod_poly_t poly2, - const fmpz_mod_poly_t f, const fmpz_mod_ctx_t ctx) - - void fmpz_mod_poly_mulmod_preinv(fmpz_mod_poly_t res, - const fmpz_mod_poly_t poly1, const fmpz_mod_poly_t poly2, - const fmpz_mod_poly_t f, const fmpz_mod_poly_t finv, - const fmpz_mod_ctx_t ctx) - - void fmpz_mod_poly_pow(fmpz_mod_poly_t rop, const fmpz_mod_poly_t op, - ulong e, const fmpz_mod_ctx_t ctx) - - void fmpz_mod_poly_pow_trunc(fmpz_mod_poly_t res, - const fmpz_mod_poly_t poly, ulong e, slong trunc, - const fmpz_mod_ctx_t ctx) - - void fmpz_mod_poly_pow_trunc_binexp(fmpz_mod_poly_t res, - const fmpz_mod_poly_t poly, ulong e, slong trunc, - const fmpz_mod_ctx_t ctx) - - void fmpz_mod_poly_powmod_ui_binexp(fmpz_mod_poly_t res, - const fmpz_mod_poly_t poly, ulong e, - const fmpz_mod_poly_t f, const fmpz_mod_ctx_t ctx) - - void fmpz_mod_poly_powmod_ui_binexp_preinv(fmpz_mod_poly_t res, - const fmpz_mod_poly_t poly, ulong e, - const fmpz_mod_poly_t f, const fmpz_mod_poly_t finv, - const fmpz_mod_ctx_t ctx) - - void fmpz_mod_poly_powmod_fmpz_binexp(fmpz_mod_poly_t res, - const fmpz_mod_poly_t poly, const fmpz_t e, - const fmpz_mod_poly_t f, const fmpz_mod_ctx_t ctx) - - void fmpz_mod_poly_powmod_fmpz_binexp_preinv(fmpz_mod_poly_t res, - const fmpz_mod_poly_t poly, const fmpz_t e, - const fmpz_mod_poly_t f, const fmpz_mod_poly_t finv, - const fmpz_mod_ctx_t ctx) - - void fmpz_mod_poly_powmod_x_fmpz_preinv(fmpz_mod_poly_t res, - const fmpz_t e, const fmpz_mod_poly_t f, const fmpz_mod_poly_t finv, - const fmpz_mod_ctx_t ctx) - - - void fmpz_mod_poly_powers_mod_naive(fmpz_mod_poly_struct * res, - const fmpz_mod_poly_t f, slong n, const fmpz_mod_poly_t g, - const fmpz_mod_ctx_t ctx) - - void fmpz_mod_poly_powers_mod_bsgs(fmpz_mod_poly_struct * res, - const fmpz_mod_poly_t f, slong n, const fmpz_mod_poly_t g, - const fmpz_mod_ctx_t ctx) - - void fmpz_mod_poly_frobenius_powers_2exp_precomp( - fmpz_mod_poly_frobenius_powers_2exp_t pow, const fmpz_mod_poly_t f, - const fmpz_mod_poly_t finv, ulong m, const fmpz_mod_ctx_t ctx) - - - void fmpz_mod_poly_frobenius_powers_2exp_clear( - fmpz_mod_poly_frobenius_powers_2exp_t pow, const fmpz_mod_ctx_t ctx) - - void fmpz_mod_poly_frobenius_power(fmpz_mod_poly_t res, - fmpz_mod_poly_frobenius_powers_2exp_t pow, - const fmpz_mod_poly_t f, ulong m, const fmpz_mod_ctx_t ctx) - - void fmpz_mod_poly_frobenius_powers_precomp( - fmpz_mod_poly_frobenius_powers_t pow, const fmpz_mod_poly_t f, - const fmpz_mod_poly_t finv, ulong m, const fmpz_mod_ctx_t ctx) - - void fmpz_mod_poly_frobenius_powers_clear( - fmpz_mod_poly_frobenius_powers_t pow, const fmpz_mod_ctx_t ctx) - - - void fmpz_mod_poly_divrem_basecase(fmpz_mod_poly_t Q, fmpz_mod_poly_t R, - const fmpz_mod_poly_t A, const fmpz_mod_poly_t B, - const fmpz_mod_ctx_t ctx) - - void fmpz_mod_poly_divrem_newton_n_preinv(fmpz_mod_poly_t Q, - fmpz_mod_poly_t R, const fmpz_mod_poly_t A, const fmpz_mod_poly_t B, - const fmpz_mod_poly_t Binv, const fmpz_mod_ctx_t ctx) - - ulong fmpz_mod_poly_remove(fmpz_mod_poly_t f, - const fmpz_mod_poly_t p, const fmpz_mod_ctx_t ctx) + # Returns a pointer to the first leading coefficient of ``poly`` + # if this is non-zero, otherwise returns ``NULL``. - void fmpz_mod_poly_rem_basecase(fmpz_mod_poly_t R, - const fmpz_mod_poly_t A, const fmpz_mod_poly_t B, - const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_set(fmpz_mod_poly_t poly1, const fmpz_mod_poly_t poly2, const fmpz_mod_ctx_t ctx) + # Sets the polynomial ``poly1`` to the value of ``poly2``. - void fmpz_mod_poly_divrem(fmpz_mod_poly_t Q, fmpz_mod_poly_t R, - const fmpz_mod_poly_t A, const fmpz_mod_poly_t B, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_swap(fmpz_mod_poly_t poly1, fmpz_mod_poly_t poly2, const fmpz_mod_ctx_t ctx) + # Swaps the two polynomials. This is done efficiently by swapping + # pointers rather than individual coefficients. - void fmpz_mod_poly_divrem_f(fmpz_t f, fmpz_mod_poly_t Q, - fmpz_mod_poly_t R, const fmpz_mod_poly_t A, const fmpz_mod_poly_t B, - const fmpz_mod_ctx_t ctx) - - void fmpz_mod_poly_rem(fmpz_mod_poly_t R, const fmpz_mod_poly_t A, - const fmpz_mod_poly_t B, const fmpz_mod_ctx_t ctx) - - - void fmpz_mod_poly_rem_f(fmpz_t f, fmpz_mod_poly_t R, const fmpz_mod_poly_t A, - const fmpz_mod_poly_t B, const fmpz_mod_ctx_t ctx) - - - void fmpz_mod_poly_inv_series_newton(fmpz_mod_poly_t Qinv, - const fmpz_mod_poly_t Q, slong n, const fmpz_mod_ctx_t ctx) - - void fmpz_mod_poly_inv_series_newton_f(fmpz_t f, fmpz_mod_poly_t Qinv, - const fmpz_mod_poly_t Q, slong n, const fmpz_mod_ctx_t ctx) - - void fmpz_mod_poly_inv_series(fmpz_mod_poly_t Qinv, const fmpz_mod_poly_t Q, - slong n, const fmpz_mod_ctx_t ctx) - - void fmpz_mod_poly_inv_series_f(fmpz_t f, fmpz_mod_poly_t Qinv, - const fmpz_mod_poly_t Q, slong n, const fmpz_mod_ctx_t ctx) - - void fmpz_mod_poly_div_series(fmpz_mod_poly_t Q, - const fmpz_mod_poly_t A, const fmpz_mod_poly_t B, slong n, - const fmpz_mod_ctx_t ctx) - - void fmpz_mod_poly_make_monic(fmpz_mod_poly_t res, - const fmpz_mod_poly_t poly, const fmpz_mod_ctx_t ctx) - - void fmpz_mod_poly_make_monic_f(fmpz_t f, fmpz_mod_poly_t res, - const fmpz_mod_poly_t poly, const fmpz_mod_ctx_t ctx) - - void fmpz_mod_poly_gcd_f(fmpz_t f, fmpz_mod_poly_t G, const fmpz_mod_poly_t A, - const fmpz_mod_poly_t B, const fmpz_mod_ctx_t ctx) - - void fmpz_mod_poly_gcd(fmpz_mod_poly_t G, const fmpz_mod_poly_t A, - const fmpz_mod_poly_t B, const fmpz_mod_ctx_t ctx) - - - void fmpz_mod_poly_xgcd(fmpz_mod_poly_t G, fmpz_mod_poly_t S, fmpz_mod_poly_t T, - const fmpz_mod_poly_t A, const fmpz_mod_poly_t B, - const fmpz_mod_ctx_t ctx) - - void fmpz_mod_poly_xgcd_f(fmpz_t f, fmpz_mod_poly_t G, fmpz_mod_poly_t S, - fmpz_mod_poly_t T, const fmpz_mod_poly_t A, const fmpz_mod_poly_t B, - const fmpz_mod_ctx_t ctx) - - void fmpz_mod_poly_gcdinv_euclidean_f(fmpz_t f, fmpz_mod_poly_t G, - fmpz_mod_poly_t S, const fmpz_mod_poly_t A, const fmpz_mod_poly_t B, - const fmpz_mod_ctx_t ctx) - - void fmpz_mod_poly_gcdinv_euclidean(fmpz_mod_poly_t G, - fmpz_mod_poly_t S, const fmpz_mod_poly_t A, const fmpz_mod_poly_t B, - const fmpz_mod_ctx_t ctx) - - void fmpz_mod_poly_gcdinv(fmpz_mod_poly_t G, fmpz_mod_poly_t S, - const fmpz_mod_poly_t A, const fmpz_mod_poly_t B, - const fmpz_mod_ctx_t ctx) - - void fmpz_mod_poly_gcdinv_f(fmpz_t f, fmpz_mod_poly_t G, - fmpz_mod_poly_t S, const fmpz_mod_poly_t A, const fmpz_mod_poly_t B, - const fmpz_mod_ctx_t ctx) - - int fmpz_mod_poly_invmod(fmpz_mod_poly_t A, const fmpz_mod_poly_t B, - const fmpz_mod_poly_t P, const fmpz_mod_ctx_t ctx) - - int fmpz_mod_poly_invmod_f(fmpz_t f, fmpz_mod_poly_t A, - const fmpz_mod_poly_t B, const fmpz_mod_poly_t P, - const fmpz_mod_ctx_t ctx) - - void fmpz_mod_poly_minpoly_bm(fmpz_mod_poly_t poly, const fmpz* seq, slong len, - const fmpz_mod_ctx_t ctx) - void fmpz_mod_poly_minpoly_hgcd(fmpz_mod_poly_t poly, const fmpz* seq, slong len, - const fmpz_mod_ctx_t ctx) - - void fmpz_mod_poly_minpoly(fmpz_mod_poly_t poly, const fmpz* seq, slong len, - const fmpz_mod_ctx_t ctx) - - void fmpz_mod_poly_resultant_euclidean(fmpz_t r, - const fmpz_mod_poly_t f, const fmpz_mod_poly_t g, - const fmpz_mod_ctx_t ctx) - - void fmpz_mod_poly_resultant_hgcd(fmpz_t res, const fmpz_mod_poly_t A, - const fmpz_mod_poly_t B, const fmpz_mod_ctx_t ctx) - - void fmpz_mod_poly_resultant(fmpz_t res, const fmpz_mod_poly_t f, - const fmpz_mod_poly_t g, const fmpz_mod_ctx_t ctx) - - void fmpz_mod_poly_discriminant(fmpz_t d, const fmpz_mod_poly_t f, - const fmpz_mod_ctx_t ctx) - - void fmpz_mod_poly_derivative(fmpz_mod_poly_t res, - const fmpz_mod_poly_t poly, const fmpz_mod_ctx_t ctx) - - void fmpz_mod_poly_evaluate_fmpz(fmpz_t res, - const fmpz_mod_poly_t poly, const fmpz_t a, - const fmpz_mod_ctx_t ctx) - - fmpz_poly_struct ** _fmpz_mod_poly_tree_alloc(slong len) - - void fmpz_mod_poly_evaluate_fmpz_vec_iter(fmpz * ys, - const fmpz_mod_poly_t poly, const fmpz * xs, slong n, - const fmpz_mod_ctx_t ctx) - - void fmpz_mod_poly_evaluate_fmpz_vec_fast(fmpz * ys, - const fmpz_mod_poly_t poly, const fmpz * xs, slong n, - const fmpz_mod_ctx_t ctx) - - void fmpz_mod_poly_evaluate_fmpz_vec(fmpz * ys, - const fmpz_mod_poly_t poly, const fmpz * xs, slong n, - const fmpz_mod_ctx_t ctx) - - void fmpz_mod_poly_compose(fmpz_mod_poly_t res, const fmpz_mod_poly_t poly1, - const fmpz_mod_poly_t poly2, const fmpz_mod_ctx_t ctx) - - void fmpz_mod_poly_compose_mod(fmpz_mod_poly_t res, - const fmpz_mod_poly_t poly1, const fmpz_mod_poly_t poly2, - const fmpz_mod_poly_t poly3, const fmpz_mod_ctx_t ctx) - - void fmpz_mod_poly_compose_mod_brent_kung(fmpz_mod_poly_t res, - const fmpz_mod_poly_t poly1, const fmpz_mod_poly_t poly2, - const fmpz_mod_poly_t poly3, const fmpz_mod_ctx_t ctx) - - void fmpz_mod_poly_precompute_matrix(fmpz_mat_t A, - const fmpz_mod_poly_t poly1, const fmpz_mod_poly_t poly2, - const fmpz_mod_poly_t poly2inv, const fmpz_mod_ctx_t ctx) - - void fmpz_mod_poly_compose_mod_brent_kung_precomp_preinv(fmpz_mod_poly_t res, - const fmpz_mod_poly_t poly1, const fmpz_mat_t A, - const fmpz_mod_poly_t poly3, const fmpz_mod_poly_t poly3inv, - const fmpz_mod_ctx_t ctx) - - void fmpz_mod_poly_compose_mod_brent_kung_preinv(fmpz_mod_poly_t res, - const fmpz_mod_poly_t poly1, const fmpz_mod_poly_t poly2, - const fmpz_mod_poly_t poly3, const fmpz_mod_poly_t poly3inv, - const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_zero(fmpz_mod_poly_t poly, const fmpz_mod_ctx_t ctx) + # Sets ``poly`` to the zero polynomial. - void fmpz_mod_poly_compose_mod_horner(fmpz_mod_poly_t res, - const fmpz_mod_poly_t poly1, const fmpz_mod_poly_t poly2, - const fmpz_mod_poly_t poly3, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_one(fmpz_mod_poly_t poly, const fmpz_mod_ctx_t ctx) + # Sets ``poly`` to the constant polynomial `1`. - void fmpz_mod_poly_compose_mod_brent_kung_vec_preinv( - fmpz_mod_poly_struct * res, const fmpz_mod_poly_struct * polys, - slong len1,slong n, const fmpz_mod_poly_t g, const fmpz_mod_poly_t poly, - const fmpz_mod_poly_t polyinv, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_zero_coeffs(fmpz_mod_poly_t poly, long i, long j, const fmpz_mod_ctx_t ctx) + # Sets the coefficients of `X^k` for `k \in [i, j)` in the polynomial + # to zero. - void fmpz_mod_poly_compose_mod_brent_kung_vec_preinv_threaded_pool(fmpz_mod_poly_struct * res, - const fmpz_mod_poly_struct * polys, slong len1, slong n, - const fmpz_mod_poly_t g, const fmpz_mod_poly_t poly, - const fmpz_mod_poly_t polyinv, const fmpz_mod_ctx_t ctx, - thread_pool_handle * threads, slong num_threads) + void fmpz_mod_poly_reverse(fmpz_mod_poly_t res, const fmpz_mod_poly_t poly, long n, const fmpz_mod_ctx_t ctx) + # This function considers the polynomial ``poly`` to be of length `n`, + # notionally truncating and zero padding if required, and reverses + # the result. Since the function normalises its result ``res`` may be + # of length less than `n`. - void fmpz_mod_poly_compose_mod_brent_kung_vec_preinv_threaded(fmpz_mod_poly_struct * res, - const fmpz_mod_poly_struct * polys, slong len1, slong n, - const fmpz_mod_poly_t g, const fmpz_mod_poly_t poly, - const fmpz_mod_poly_t polyinv, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_set_ui(fmpz_mod_poly_t f, unsigned long c, const fmpz_mod_ctx_t ctx) + # Sets the polynomial `f` to the constant `c` reduced modulo `p`. - void fmpz_mod_poly_radix_init(fmpz_mod_poly_radix_t D, - const fmpz_mod_poly_t R, slong degF, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_set_fmpz(fmpz_mod_poly_t f, const fmpz_t c, const fmpz_mod_ctx_t ctx) + # Sets the polynomial `f` to the constant `c` reduced modulo `p`. - void fmpz_mod_poly_radix_clear(fmpz_mod_poly_radix_t D) + void fmpz_mod_poly_set_fmpz_poly(fmpz_mod_poly_t f, const fmpz_poly_t g, const fmpz_mod_ctx_t ctx) + # Sets `f` to `g` reduced modulo `p`, where `p` is the modulus that + # is part of the data structure of `f`. - void fmpz_mod_poly_radix(fmpz_mod_poly_struct **B, const fmpz_mod_poly_t F, - const fmpz_mod_poly_radix_t D, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_get_fmpz_poly(fmpz_poly_t f, const fmpz_mod_poly_t g, const fmpz_mod_ctx_t ctx) + # Sets `f` to `g`. This is done simply by lifting the coefficients + # of `g` taking representatives `[0, p) \subset \mathbf{Z}`. - int fmpz_mod_poly_fprint(FILE * file, const fmpz_mod_poly_t poly, - const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_get_nmod_poly(nmod_poly_t f, const fmpz_mod_poly_t g) - int fmpz_mod_poly_fread(FILE * file, fmpz_mod_poly_t poly, - fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_set_nmod_poly(fmpz_mod_poly_t f, const nmod_poly_t g) + int fmpz_mod_poly_equal(const fmpz_mod_poly_t poly1, const fmpz_mod_poly_t poly2, const fmpz_mod_ctx_t ctx) + # Returns non-zero if the two polynomials are equal, otherwise returns zero. - int fmpz_mod_poly_fprint_pretty(FILE * file, const fmpz_mod_poly_t poly, - const char * x, const fmpz_mod_ctx_t ctx) + int fmpz_mod_poly_equal_trunc(const fmpz_mod_poly_t poly1, const fmpz_mod_poly_t poly2, long n, const fmpz_mod_ctx_t ctx) + # Notionally truncates the two polynomials to length `n` and returns non-zero + # if the two polynomials are equal, otherwise returns zero. + int fmpz_mod_poly_is_zero(const fmpz_mod_poly_t poly, const fmpz_mod_ctx_t ctx) + # Returns non-zero if the polynomial is zero. + int fmpz_mod_poly_is_one(const fmpz_mod_poly_t poly, const fmpz_mod_ctx_t ctx) + # Returns non-zero if the polynomial is the constant `1`. + + int fmpz_mod_poly_is_gen(const fmpz_mod_poly_t poly, const fmpz_mod_ctx_t ctx) + # Returns non-zero if the polynomial is the degree `1` polynomial `x`. + + void fmpz_mod_poly_set_coeff_fmpz(fmpz_mod_poly_t poly, long n, const fmpz_t x, const fmpz_mod_ctx_t ctx) + # Sets the coefficient of `X^n` in the polynomial to `x`, + # assuming `n \geq 0`. + + void fmpz_mod_poly_set_coeff_ui(fmpz_mod_poly_t poly, long n, unsigned long x, const fmpz_mod_ctx_t ctx) + # Sets the coefficient of `X^n` in the polynomial to `x`, + # assuming `n \geq 0`. + + void fmpz_mod_poly_get_coeff_fmpz(fmpz_t x, const fmpz_mod_poly_t poly, long n, const fmpz_mod_ctx_t ctx) + # Sets `x` to the coefficient of `X^n` in the polynomial, + # assuming `n \geq 0`. + + void fmpz_mod_poly_set_coeff_mpz(fmpz_mod_poly_t poly, long n, const mpz_t x, const fmpz_mod_ctx_t ctx) + # Sets the coefficient of `X^n` in the polynomial to `x`, + # assuming `n \geq 0`. + + void fmpz_mod_poly_get_coeff_mpz(mpz_t x, const fmpz_mod_poly_t poly, long n, const fmpz_mod_ctx_t ctx) + # Sets `x` to the coefficient of `X^n` in the polynomial, + # assuming `n \geq 0`. + + void _fmpz_mod_poly_shift_left(fmpz * res, const fmpz * poly, long len, long n) + # Sets ``(res, len + n)`` to ``(poly, len)`` shifted left by + # `n` coefficients. + # Inserts zero coefficients at the lower end. Assumes that ``len`` + # and `n` are positive, and that ``res`` fits ``len + n`` elements. + # Supports aliasing between ``res`` and ``poly``. + + void fmpz_mod_poly_shift_left(fmpz_mod_poly_t f, const fmpz_mod_poly_t g, long n, const fmpz_mod_ctx_t ctx) + # Sets ``res`` to ``poly`` shifted left by `n` coeffs. Zero + # coefficients are inserted. + + void _fmpz_mod_poly_shift_right(fmpz * res, const fmpz * poly, long len, long n) + # Sets ``(res, len - n)`` to ``(poly, len)`` shifted right by + # `n` coefficients. + # Assumes that ``len`` and `n` are positive, that ``len > n``, + # and that ``res`` fits ``len - n`` elements. Supports aliasing + # between ``res`` and ``poly``, although in this case the top + # coefficients of ``poly`` are not set to zero. + + void fmpz_mod_poly_shift_right(fmpz_mod_poly_t f, const fmpz_mod_poly_t g, long n, const fmpz_mod_ctx_t ctx) + # Sets ``res`` to ``poly`` shifted right by `n` coefficients. If `n` + # is equal to or greater than the current length of ``poly``, ``res`` + # is set to the zero polynomial. + + void _fmpz_mod_poly_add(fmpz *res, const fmpz *poly1, long len1, const fmpz *poly2, long len2, const fmpz_mod_ctx_t ctx) + # Sets ``res`` to the sum of ``(poly1, len1)`` and + # ``(poly2, len2)``. It is assumed that ``res`` has + # sufficient space for the longer of the two polynomials. + + void fmpz_mod_poly_add(fmpz_mod_poly_t res, const fmpz_mod_poly_t poly1, const fmpz_mod_poly_t poly2, const fmpz_mod_ctx_t ctx) + # Sets ``res`` to the sum of ``poly1`` and ``poly2``. + + void fmpz_mod_poly_add_series(fmpz_mod_poly_t res, const fmpz_mod_poly_t poly1, const fmpz_mod_poly_t poly2, long n, const fmpz_mod_ctx_t ctx) + # Notionally truncate ``poly1`` and ``poly2`` to length `n` and set + # ``res`` to the sum. + + void _fmpz_mod_poly_sub(fmpz *res, const fmpz *poly1, long len1, const fmpz *poly2, long len2, const fmpz_mod_ctx_t ctx) + # Sets ``res`` to ``(poly1, len1)`` minus ``(poly2, len2)``. It + # is assumed that ``res`` has sufficient space for the longer of the + # two polynomials. + + void fmpz_mod_poly_sub(fmpz_mod_poly_t res, const fmpz_mod_poly_t poly1, const fmpz_mod_poly_t poly2, const fmpz_mod_ctx_t ctx) + # Sets ``res`` to ``poly1`` minus ``poly2``. + + void fmpz_mod_poly_sub_series(fmpz_mod_poly_t res, const fmpz_mod_poly_t poly1, const fmpz_mod_poly_t poly2, long n, const fmpz_mod_ctx_t ctx) + # Notionally truncate ``poly1`` and ``poly2`` to length `n` and set + # ``res`` to the difference. + + void _fmpz_mod_poly_neg(fmpz *res, const fmpz *poly, long len, const fmpz_mod_ctx_t ctx) + # Sets ``(res, len)`` to the negative of ``(poly, len)`` + # modulo `p`. + + void fmpz_mod_poly_neg(fmpz_mod_poly_t res, const fmpz_mod_poly_t poly, const fmpz_mod_ctx_t ctx) + # Sets ``res`` to the negative of ``poly`` modulo `p`. + + void _fmpz_mod_poly_scalar_mul_fmpz(fmpz *res, const fmpz *poly, long len, const fmpz_t x, const fmpz_mod_ctx_t ctx) + # Sets ``(res, len``) to ``(poly, len)`` multiplied by `x`, + # reduced modulo `p`. + + void fmpz_mod_poly_scalar_mul_fmpz(fmpz_mod_poly_t res, const fmpz_mod_poly_t poly, const fmpz_t x, const fmpz_mod_ctx_t ctx) + # Sets ``res`` to ``poly`` multiplied by `x`. + + void fmpz_mod_poly_scalar_addmul_fmpz(fmpz_mod_poly_t rop, const fmpz_mod_poly_t op, const fmpz_t x, const fmpz_mod_ctx_t ctx) + # Adds to ``rop`` the product of ``op`` by the scalar ``x``. + + void _fmpz_mod_poly_scalar_div_fmpz(fmpz *res, const fmpz *poly, long len, const fmpz_t x, const fmpz_mod_ctx_t ctx) + # Sets ``(res, len``) to ``(poly, len)`` divided by `x` (i.e. + # multiplied by the inverse of `x \pmod{p}`). The result is reduced modulo + # `p`. + + void fmpz_mod_poly_scalar_div_fmpz(fmpz_mod_poly_t res, const fmpz_mod_poly_t poly, const fmpz_t x, const fmpz_mod_ctx_t ctx) + # Sets ``res`` to ``poly`` divided by `x`, (i.e. multiplied by the + # inverse of `x \pmod{p}`). The result is reduced modulo `p`. + + void _fmpz_mod_poly_mul(fmpz *res, const fmpz *poly1, long len1, const fmpz *poly2, long len2, const fmpz_mod_ctx_t ctx) + # Sets ``(res, len1 + len2 - 1)`` to the product of ``(poly1, len1)`` + # and ``(poly2, len2)``. Assumes ``len1 >= len2 > 0``. Allows + # zero-padding of the two input polynomials. + + void fmpz_mod_poly_mul(fmpz_mod_poly_t res, const fmpz_mod_poly_t poly1, const fmpz_mod_poly_t poly2, const fmpz_mod_ctx_t ctx) + # Sets ``res`` to the product of ``poly1`` and ``poly2``. + + void _fmpz_mod_poly_mullow(fmpz *res, const fmpz *poly1, long len1, const fmpz *poly2, long len2, long n, const fmpz_mod_ctx_t ctx) + # Sets ``(res, n)`` to the lowest `n` coefficients of the product of + # ``(poly1, len1)`` and ``(poly2, len2)``. + # Assumes ``len1 >= len2 > 0`` and ``0 < n <= len1 + len2 - 1``. + # Allows for zero-padding in the inputs. Does not support aliasing between + # the inputs and the output. + + void fmpz_mod_poly_mullow(fmpz_mod_poly_t res, const fmpz_mod_poly_t poly1, const fmpz_mod_poly_t poly2, long n, const fmpz_mod_ctx_t ctx) + # Sets ``res`` to the lowest `n` coefficients of the product of + # ``poly1`` and ``poly2``. + + void _fmpz_mod_poly_sqr(fmpz *res, const fmpz *poly, long len, const fmpz_mod_ctx_t ctx) + # Sets ``res`` to the square of ``poly``. + + void fmpz_mod_poly_sqr(fmpz_mod_poly_t res, const fmpz_mod_poly_t poly, const fmpz_mod_ctx_t ctx) + # Computes ``res`` as the square of ``poly``. + + void fmpz_mod_poly_mulhigh(fmpz_mod_poly_t res, const fmpz_mod_poly_t poly1, const fmpz_mod_poly_t poly2, long start, const fmpz_mod_ctx_t ctx) + # Computes the product of ``poly1`` and ``poly2`` and writes the + # coefficients from ``start`` onwards into the high coefficients of + # ``res``, the remaining coefficients being arbitrary. + + void _fmpz_mod_poly_mulmod(fmpz * res, const fmpz * poly1, long len1, const fmpz * poly2, long len2, const fmpz * f, long lenf, const fmpz_mod_ctx_t ctx) + # Sets ``res, len1 + len2 - 1`` to the remainder of the product of + # ``poly1`` and ``poly2`` upon polynomial division by ``f``. + # It is required that ``len1 + len2 - lenf > 0``, which is equivalent + # to requiring that the result will actually be reduced. Otherwise, simply + # use ``_fmpz_mod_poly_mul`` instead. + # Aliasing of ``f`` and ``res`` is not permitted. + + void fmpz_mod_poly_mulmod(fmpz_mod_poly_t res, const fmpz_mod_poly_t poly1, const fmpz_mod_poly_t poly2, const fmpz_mod_poly_t f, const fmpz_mod_ctx_t ctx) + # Sets ``res`` to the remainder of the product of ``poly1`` and + # ``poly2`` upon polynomial division by ``f``. + + void _fmpz_mod_poly_mulmod_preinv(fmpz * res, const fmpz * poly1, long len1, const fmpz * poly2, long len2, const fmpz * f, long lenf, const fmpz* finv, long lenfinv, const fmpz_mod_ctx_t ctx) + # Sets ``res, len1 + len2 - 1`` to the remainder of the product of + # ``poly1`` and ``poly2`` upon polynomial division by ``f``. + # It is required that ``finv`` is the inverse of the reverse of ``f`` + # mod ``x^lenf``. It is required that ``len1 + len2 - lenf > 0``, + # which is equivalent to requiring that the result will actually be reduced. + # It is required that ``len1 < lenf`` and ``len2 < lenf``. + # Otherwise, simply use ``_fmpz_mod_poly_mul`` instead. + # Aliasing of ``f`` or ``finv`` and ``res`` is not permitted. + + void fmpz_mod_poly_mulmod_preinv(fmpz_mod_poly_t res, const fmpz_mod_poly_t poly1, const fmpz_mod_poly_t poly2, const fmpz_mod_poly_t f, const fmpz_mod_poly_t finv, const fmpz_mod_ctx_t ctx) + # Sets ``res`` to the remainder of the product of ``poly1`` and + # ``poly2`` upon polynomial division by ``f``. ``finv`` is the + # inverse of the reverse of ``f``. It is required that ``poly1`` and + # ``poly2`` are reduced modulo ``f``. + + void _fmpz_mod_poly_product_roots_fmpz_vec(fmpz * poly, const fmpz * xs, long n, const fmpz_mod_ctx_t ctx) + # Sets ``(poly, n + 1)`` to the monic polynomial which is the product + # of `(x - x_0)(x - x_1) \cdots (x - x_{n-1})`, the roots `x_i` being + # given by ``xs``. It is required that the roots are canonical. + # Aliasing of the input and output is not allowed. + + void fmpz_mod_poly_product_roots_fmpz_vec(fmpz_mod_poly_t poly, const fmpz * xs, long n, const fmpz_mod_ctx_t ctx) + # Sets ``poly`` to the monic polynomial which is the product + # of `(x - x_0)(x - x_1) \cdots (x - x_{n-1})`, the roots `x_i` being + # given by ``xs``. It is required that the roots are canonical. + + int fmpz_mod_poly_find_distinct_nonzero_roots(fmpz * roots, const fmpz_mod_poly_t A, const fmpz_mod_ctx_t ctx) + # If ``A`` has `\deg(A)` distinct nonzero roots in `\mathbb{F}_p`, write these roots out to ``roots[0]`` to ``roots[deg(A) - 1]`` and return ``1``. + # Otherwise, return ``0``. It is assumed that ``A`` is nonzero and that the modulus of ``A`` is prime. + # This function uses Rabin's probabilistic method via gcd's with `(x + \delta)^{\frac{p-1}{2}} - 1`. + + void _fmpz_mod_poly_pow(fmpz *rop, const fmpz *op, long len, unsigned long e, const fmpz_mod_ctx_t ctx) + # Sets ``rop = poly^e``, assuming that `e > 1` and ``elen > 0``, + # and that ``res`` has space for ``e*(len - 1) + 1`` coefficients. + # Does not support aliasing. + + void fmpz_mod_poly_pow(fmpz_mod_poly_t rop, const fmpz_mod_poly_t op, unsigned long e, const fmpz_mod_ctx_t ctx) + # Computes ``rop = poly^e``. If `e` is zero, returns one, + # so that in particular ``0^0 = 1``. + + void _fmpz_mod_poly_pow_trunc(fmpz * res, const fmpz * poly, unsigned long e, long trunc, const fmpz_mod_ctx_t ctx) + # Sets ``res`` to the low ``trunc`` coefficients of ``poly`` + # (assumed to be zero padded if necessary to length ``trunc``) to + # the power ``e``. This is equivalent to doing a powering followed + # by a truncation. We require that ``res`` has enough space for + # ``trunc`` coefficients, that ``trunc > 0`` and that + # ``e > 1``. Aliasing is not permitted. + + void fmpz_mod_poly_pow_trunc(fmpz_mod_poly_t res, const fmpz_mod_poly_t poly, unsigned long e, long trunc, const fmpz_mod_ctx_t ctx) + # Sets ``res`` to the low ``trunc`` coefficients of ``poly`` + # to the power ``e``. This is equivalent to doing a powering + # followed by a truncation. + + void _fmpz_mod_poly_pow_trunc_binexp(fmpz * res, const fmpz * poly, unsigned long e, long trunc, const fmpz_mod_ctx_t ctx) + # Sets ``res`` to the low ``trunc`` coefficients of ``poly`` + # (assumed to be zero padded if necessary to length ``trunc``) to + # the power ``e``. This is equivalent to doing a powering followed + # by a truncation. We require that ``res`` has enough space for + # ``trunc`` coefficients, that ``trunc > 0`` and that + # ``e > 1``. Aliasing is not permitted. Uses the binary + # exponentiation method. + + void fmpz_mod_poly_pow_trunc_binexp(fmpz_mod_poly_t res, const fmpz_mod_poly_t poly, unsigned long e, long trunc, const fmpz_mod_ctx_t ctx) + # Sets ``res`` to the low ``trunc`` coefficients of ``poly`` + # to the power ``e``. This is equivalent to doing a powering + # followed by a truncation. Uses the binary exponentiation method. + + void _fmpz_mod_poly_powmod_ui_binexp(fmpz * res, const fmpz * poly, unsigned long e, const fmpz * f, long lenf, const fmpz_mod_ctx_t ctx) + # Sets ``res`` to ``poly`` raised to the power ``e`` + # modulo ``f``, using binary exponentiation. We require ``e > 0``. + # We require ``lenf > 1``. It is assumed that ``poly`` is already + # reduced modulo ``f`` and zero-padded as necessary to have length + # exactly ``lenf - 1``. The output ``res`` must have room for + # ``lenf - 1`` coefficients. + + void fmpz_mod_poly_powmod_ui_binexp(fmpz_mod_poly_t res, const fmpz_mod_poly_t poly, unsigned long e, const fmpz_mod_poly_t f, const fmpz_mod_ctx_t ctx) + # Sets ``res`` to ``poly`` raised to the power ``e`` + # modulo ``f``, using binary exponentiation. We require ``e >= 0``. + + void _fmpz_mod_poly_powmod_ui_binexp_preinv(fmpz * res, const fmpz * poly, unsigned long e, const fmpz * f, long lenf, const fmpz * finv, long lenfinv, const fmpz_mod_ctx_t ctx) + # Sets ``res`` to ``poly`` raised to the power ``e`` + # modulo ``f``, using binary exponentiation. We require ``e > 0``. + # We require ``finv`` to be the inverse of the reverse of ``f``. + # We require ``lenf > 1``. It is assumed that ``poly`` is already + # reduced modulo ``f`` and zero-padded as necessary to have length + # exactly ``lenf - 1``. The output ``res`` must have room for + # ``lenf - 1`` coefficients. + + void fmpz_mod_poly_powmod_ui_binexp_preinv(fmpz_mod_poly_t res, const fmpz_mod_poly_t poly, unsigned long e, const fmpz_mod_poly_t f, const fmpz_mod_poly_t finv, const fmpz_mod_ctx_t ctx) + # Sets ``res`` to ``poly`` raised to the power ``e`` + # modulo ``f``, using binary exponentiation. We require ``e >= 0``. + # We require ``finv`` to be the inverse of the reverse of ``f``. + + void _fmpz_mod_poly_powmod_fmpz_binexp(fmpz * res, const fmpz * poly, const fmpz_t e, const fmpz * f, long lenf, const fmpz_mod_ctx_t ctx) + # Sets ``res`` to ``poly`` raised to the power ``e`` + # modulo ``f``, using binary exponentiation. We require ``e > 0``. + # We require ``lenf > 1``. It is assumed that ``poly`` is already + # reduced modulo ``f`` and zero-padded as necessary to have length + # exactly ``lenf - 1``. The output ``res`` must have room for + # ``lenf - 1`` coefficients. + + void fmpz_mod_poly_powmod_fmpz_binexp(fmpz_mod_poly_t res, const fmpz_mod_poly_t poly, const fmpz_t e, const fmpz_mod_poly_t f, const fmpz_mod_ctx_t ctx) + # Sets ``res`` to ``poly`` raised to the power ``e`` + # modulo ``f``, using binary exponentiation. We require ``e >= 0``. + + void _fmpz_mod_poly_powmod_fmpz_binexp_preinv(fmpz * res, const fmpz * poly, const fmpz_t e, const fmpz * f, long lenf, const fmpz* finv, long lenfinv, const fmpz_mod_ctx_t ctx) + # Sets ``res`` to ``poly`` raised to the power ``e`` + # modulo ``f``, using binary exponentiation. We require ``e > 0``. + # We require ``finv`` to be the inverse of the reverse of ``f``. + # We require ``lenf > 1``. It is assumed that ``poly`` is already + # reduced modulo ``f`` and zero-padded as necessary to have length + # exactly ``lenf - 1``. The output ``res`` must have room for + # ``lenf - 1`` coefficients. + + void fmpz_mod_poly_powmod_fmpz_binexp_preinv(fmpz_mod_poly_t res, const fmpz_mod_poly_t poly, const fmpz_t e, const fmpz_mod_poly_t f, const fmpz_mod_poly_t finv, const fmpz_mod_ctx_t ctx) + # Sets ``res`` to ``poly`` raised to the power ``e`` + # modulo ``f``, using binary exponentiation. We require ``e >= 0``. + # We require ``finv`` to be the inverse of the reverse of ``f``. + + void _fmpz_mod_poly_powmod_x_fmpz_preinv(fmpz * res, const fmpz_t e, const fmpz * f, long lenf, const fmpz* finv, long lenfinv, const fmpz_mod_ctx_t ctx) + # Sets ``res`` to ``x`` raised to the power ``e`` modulo ``f``, + # using sliding window exponentiation. We require ``e > 0``. + # We require ``finv`` to be the inverse of the reverse of ``f``. + # We require ``lenf > 2``. The output ``res`` must have room for + # ``lenf - 1`` coefficients. + + void fmpz_mod_poly_powmod_x_fmpz_preinv(fmpz_mod_poly_t res, const fmpz_t e, const fmpz_mod_poly_t f, const fmpz_mod_poly_t finv, const fmpz_mod_ctx_t ctx) + # Sets ``res`` to ``x`` raised to the power ``e`` + # modulo ``f``, using sliding window exponentiation. We require + # ``e >= 0``. We require ``finv`` to be the inverse of the reverse of + # `` + + void _fmpz_mod_poly_powers_mod_preinv_naive(fmpz ** res, const fmpz * f, long flen, long n, const fmpz * g, long glen, const fmpz * ginv, long ginvlen, const fmpz_mod_ctx_t ctx) + # Compute ``f^0, f^1, ..., f^(n-1) mod g``, where ``g`` has length ``glen`` + # and ``f`` is reduced mod ``g`` and has length ``flen`` (possibly zero + # spaced). Assumes ``res`` is an array of ``n`` arrays each with space for + # at least ``glen - 1`` coefficients and that ``flen > 0``. We require that + # ``ginv`` of length ``ginvlen`` is set to the power series inverse of the + # reverse of ``g``. + + void fmpz_mod_poly_powers_mod_naive(fmpz_mod_poly_struct * res, const fmpz_mod_poly_t f, long n, const fmpz_mod_poly_t g, const fmpz_mod_ctx_t ctx) + # Set the entries of the array ``res`` to ``f^0, f^1, ..., f^(n-1) mod g``. + # No aliasing is permitted between the entries of ``res`` and either of the + # inputs. + + void _fmpz_mod_poly_powers_mod_preinv_threaded_pool(fmpz ** res, const fmpz * f, long flen, long n, const fmpz * g, long glen, const fmpz * ginv, long ginvlen, const fmpz_mod_ctx_t p, thread_pool_handle * threads, long num_threads) + # Compute ``f^0, f^1, ..., f^(n-1) mod g``, where ``g`` has length ``glen`` + # and ``f`` is reduced mod ``g`` and has length ``flen`` (possibly zero + # spaced). Assumes ``res`` is an array of ``n`` arrays each with space for + # at least ``glen - 1`` coefficients and that ``flen > 0``. We require that + # ``ginv`` of length ``ginvlen`` is set to the power series inverse of the + # reverse of ``g``. + + void fmpz_mod_poly_powers_mod_bsgs(fmpz_mod_poly_struct * res, const fmpz_mod_poly_t f, long n, const fmpz_mod_poly_t g, const fmpz_mod_ctx_t ctx) + # Set the entries of the array ``res`` to ``f^0, f^1, ..., f^(n-1) mod g``. + # No aliasing is permitted between the entries of ``res`` and either of the + # inputs. + + void fmpz_mod_poly_frobenius_powers_2exp_precomp(fmpz_mod_poly_frobenius_powers_2exp_t pow, const fmpz_mod_poly_t f, const fmpz_mod_poly_t finv, unsigned long m, const fmpz_mod_ctx_t ctx) + # If ``p = f->p``, compute `x^{(p^1)}`, `x^{(p^2)}`, `x^{(p^4)}`, ..., + # `x^{(p^{(2^l)})} \pmod{f}` where `2^l` is the greatest power of `2` less than + # or equal to `m`. + # Allows construction of `x^{(p^k)}` for `k = 0`, `1`, ..., `x^{(p^m)} \pmod{f}` + # using :func:`fmpz_mod_poly_frobenius_power`. + # Requires precomputed inverse of `f`, i.e. newton inverse. + + void fmpz_mod_poly_frobenius_powers_2exp_clear(fmpz_mod_poly_frobenius_powers_2exp_t pow, const fmpz_mod_ctx_t ctx) + # Clear resources used by the ``fmpz_mod_poly_frobenius_powers_2exp_t`` + # struct. + + void fmpz_mod_poly_frobenius_power(fmpz_mod_poly_t res, fmpz_mod_poly_frobenius_powers_2exp_t pow, const fmpz_mod_poly_t f, unsigned long m, const fmpz_mod_ctx_t ctx) + # If ``p = f->p``, compute `x^{(p^m)} \pmod{f}`. + # Requires precomputed frobenius powers supplied by + # ``fmpz_mod_poly_frobenius_powers_2exp_precomp``. + # If `m == 0` and `f` has degree `0` or `1`, this performs a division. + # However an impossible inverse by the leading coefficient of `f` will have + # been caught by ``fmpz_mod_poly_frobenius_powers_2exp_precomp``. + + void fmpz_mod_poly_frobenius_powers_precomp(fmpz_mod_poly_frobenius_powers_t pow, const fmpz_mod_poly_t f, const fmpz_mod_poly_t finv, unsigned long m, const fmpz_mod_ctx_t ctx) + # If ``p = f->p``, compute `x^{(p^0)}`, `x^{(p^1)}`, `x^{(p^2)}`, `x^{(p^3)}`, + # ..., `x^{(p^m)} \pmod{f}`. + # Requires precomputed inverse of `f`, i.e. newton inverse. + + void fmpz_mod_poly_frobenius_powers_clear(fmpz_mod_poly_frobenius_powers_t pow, const fmpz_mod_ctx_t ctx) + # Clear resources used by the ``fmpz_mod_poly_frobenius_powers_t`` + # struct. + + void _fmpz_mod_poly_divrem_basecase(fmpz * Q, fmpz * R, const fmpz * A, long lenA, const fmpz * B, long lenB, const fmpz_t invB, const fmpz_mod_ctx_t ctx) + # Computes ``(Q, lenA - lenB + 1)``, ``(R, lenA)`` such that + # `A = B Q + R` with `0 \leq \operatorname{len}(R) < \operatorname{len}(B)`. + # Assumes that the leading coefficient of `B` is invertible + # modulo `p`, and that ``invB`` is the inverse. + # Assumes that `\operatorname{len}(A), \operatorname{len}(B) > 0`. Allows zero-padding in + # ``(A, lenA)``. `R` and `A` may be aliased, but apart from this no + # aliasing of input and output operands is allowed. + + void fmpz_mod_poly_divrem_basecase(fmpz_mod_poly_t Q, fmpz_mod_poly_t R, const fmpz_mod_poly_t A, const fmpz_mod_poly_t B, const fmpz_mod_ctx_t ctx) + # Computes `Q`, `R` such that `A = B Q + R` with + # `0 \leq \operatorname{len}(R) < \operatorname{len}(B)`. + # Assumes that the leading coefficient of `B` is invertible + # modulo `p`. + + void _fmpz_mod_poly_divrem_newton_n_preinv (fmpz* Q, fmpz* R, const fmpz* A, long lenA, const fmpz* B, long lenB, const fmpz* Binv, long lenBinv, const fmpz_mod_ctx_t ctx) + # Computes `Q` and `R` such that `A = BQ + R` with `\operatorname{len}(R)` less than + # ``lenB``, where `A` is of length ``lenA`` and `B` is of length + # ``lenB``. We require that `Q` have space for ``lenA - lenB + 1`` + # coefficients. Furthermore, we assume that `Binv` is the inverse of the + # reverse of `B` mod `x^{\operatorname{len}(B)}`. The algorithm used is to call + # :func:`div_newton_n_preinv` and then multiply out and compute + # the remainder. + + void fmpz_mod_poly_divrem_newton_n_preinv(fmpz_mod_poly_t Q, fmpz_mod_poly_t R, const fmpz_mod_poly_t A, const fmpz_mod_poly_t B, const fmpz_mod_poly_t Binv, const fmpz_mod_ctx_t ctx) + # Computes `Q` and `R` such that `A = BQ + R` with `\operatorname{len}(R) < \operatorname{len}(B)`. + # We assume `Binv` is the inverse of the reverse of `B` mod `x^{\operatorname{len}(B)}`. + # It is required that the length of `A` is less than or equal to + # 2*the length of `B` - 2. + # The algorithm used is to call :func:`div_newton_n` and then multiply out + # and compute the remainder. + + void _fmpz_mod_poly_div_newton_n_preinv (fmpz* Q, const fmpz* A, long lenA, const fmpz* B, long lenB, const fmpz* Binv, long lenBinv, const fmpz_mod_ctx_t ctx) + # Notionally computes polynomials `Q` and `R` such that `A = BQ + R` with + # `\operatorname{len}(R)` less than ``lenB``, where ``A`` is of length ``lenA`` + # and ``B`` is of length ``lenB``, but return only `Q`. + # We require that `Q` have space for ``lenA - lenB + 1`` coefficients + # and assume that the leading coefficient of `B` is a unit. Furthermore, we + # assume that `Binv` is the inverse of the reverse of `B` mod `x^{\operatorname{len}(B)}`. + # The algorithm used is to reverse the polynomials and divide the + # resulting power series, then reverse the result. + + void fmpz_mod_poly_div_newton_n_preinv(fmpz_mod_poly_t Q, const fmpz_mod_poly_t A, const fmpz_mod_poly_t B, const fmpz_mod_poly_t Binv, const fmpz_mod_ctx_t ctx) + # Notionally computes `Q` and `R` such that `A = BQ + R` with + # `\operatorname{len}(R) < \operatorname{len}(B)`, but returns only `Q`. + # We assume that the leading coefficient of `B` is a unit and that `Binv` is + # the inverse of the reverse of `B` mod `x^{\operatorname{len}(B)}`. + # It is required that the length of `A` is less than or equal to + # 2*the length of `B` - 2. + # The algorithm used is to reverse the polynomials and divide the + # resulting power series, then reverse the result. + + unsigned long fmpz_mod_poly_remove(fmpz_mod_poly_t f, const fmpz_mod_poly_t g, const fmpz_mod_ctx_t ctx) + # Removes the highest possible power of ``g`` from ``f`` and + # returns the exponent. + + void _fmpz_mod_poly_rem_basecase(fmpz * R, const fmpz * A, long lenA, const fmpz * B, long lenB, const fmpz_t invB, const fmpz_mod_ctx_t ctx) + # Notationally, computes `Q`, `R` such that `A = B Q + R` with + # `0 \leq \operatorname{len}(R) < \operatorname{len}(B)` but only sets ``(R, lenB - 1)``. + # Allows aliasing only between `A` and `R`. Allows zero-padding + # in `A` but not in `B`. Assumes that the leading coefficient + # of `B` is a unit modulo `p`. + + void fmpz_mod_poly_rem_basecase(fmpz_mod_poly_t R, const fmpz_mod_poly_t A, const fmpz_mod_poly_t B, const fmpz_mod_ctx_t ctx) + # Notationally, computes `Q`, `R` such that `A = B Q + R` with + # `0 \leq \operatorname{len}(R) < \operatorname{len}(B)` assuming that the leading term + # of `B` is a unit. + + void _fmpz_mod_poly_div(fmpz * Q, const fmpz * A, long lenA, const fmpz * B, long lenB, const fmpz_t invB, const fmpz_mod_ctx_t ctx) + # Notationally, computes `Q`, `R` such that `A = B Q + R` with + # `0 \leq \operatorname{len}(R) < \operatorname{len}(B)` but only sets ``(Q, lenA - lenB + 1)``. + # Assumes that the leading coefficient of `B` is a unit modulo `p`. + + void fmpz_mod_poly_div(fmpz_mod_poly_t Q, const fmpz_mod_poly_t A, const fmpz_mod_poly_t B, const fmpz_mod_ctx_t ctx) + # Notationally, computes `Q`, `R` such that `A = B Q + R` with + # `0 \leq \operatorname{len}(R) < \operatorname{len}(B)` assuming that the leading term + # of `B` is a unit. + + void _fmpz_mod_poly_divrem(fmpz * Q, fmpz * R, const fmpz * A, long lenA, const fmpz * B, long lenB, const fmpz_t invB, const fmpz_mod_ctx_t ctx) + # Computes ``(Q, lenA - lenB + 1)``, ``(R, lenB - 1)`` such that + # `A = B Q + R` and `0 \leq \operatorname{len}(R) < \operatorname{len}(B)`. + # Assumes that `B` is non-zero, that the leading coefficient + # of `B` is invertible modulo `p` and that ``invB`` is + # the inverse. + # Assumes `\operatorname{len}(A) \geq \operatorname{len}(B) > 0`. Allows zero-padding in + # ``(A, lenA)``. No aliasing of input and output operands is + # allowed. + + void fmpz_mod_poly_divrem(fmpz_mod_poly_t Q, fmpz_mod_poly_t R, const fmpz_mod_poly_t A, const fmpz_mod_poly_t B, const fmpz_mod_ctx_t ctx) + # Computes `Q`, `R` such that `A = B Q + R` and + # `0 \leq \operatorname{len}(R) < \operatorname{len}(B)`. + # Assumes that `B` is non-zero and that the leading coefficient + # of `B` is invertible modulo `p`. + + void fmpz_mod_poly_divrem_f(fmpz_t f, fmpz_mod_poly_t Q, fmpz_mod_poly_t R, const fmpz_mod_poly_t A, const fmpz_mod_poly_t B, const fmpz_mod_ctx_t ctx) + # Either finds a non-trivial factor~`f` of the modulus~`p`, or computes + # `Q`, `R` such that `A = B Q + R` and `0 \leq \operatorname{len}(R) < \operatorname{len}(B)`. + # If the leading coefficient of `B` is invertible in `\mathbf{Z}/(p)`, + # the division with remainder operation is carried out, `Q` and `R` are + # computed correctly, and `f` is set to `1`. Otherwise, `f` is set to + # a non-trivial factor of `p` and `Q` and `R` are not touched. + # Assumes that `B` is non-zero. + + void _fmpz_mod_poly_rem(fmpz *R, const fmpz *A, long lenA, const fmpz *B, long lenB, const fmpz_t invB, const fmpz_mod_ctx_t ctx) + # Notationally, computes ``(Q, lenA - lenB + 1)``, ``(R, lenB - 1)`` + # such that `A = B Q + R` and `0 \leq \operatorname{len}(R) < \operatorname{len}(B)`, returning + # only the remainder part. + # Assumes that `B` is non-zero, that the leading coefficient + # of `B` is invertible modulo `p` and that ``invB`` is + # the inverse. + # Assumes `\operatorname{len}(A) \geq \operatorname{len}(B) > 0`. Allows zero-padding in + # ``(A, lenA)``. No aliasing of input and output operands is + # allowed. + + void fmpz_mod_poly_rem_f(fmpz_t f, fmpz_mod_poly_t R, const fmpz_mod_poly_t A, const fmpz_mod_poly_t B, const fmpz_mod_ctx_t ctx) + # If `f` returns with the value `1` then the function operates as + # ``_fmpz_mod_poly_rem``, otherwise `f` will be set to a nontrivial + # factor of `p`. + + void fmpz_mod_poly_rem(fmpz_mod_poly_t R, const fmpz_mod_poly_t A, const fmpz_mod_poly_t B, const fmpz_mod_ctx_t ctx) + # Notationally, computes `Q`, `R` such that `A = B Q + R` + # and `0 \leq \operatorname{len}(R) < \operatorname{len}(B)`, returning only the remainder + # part. + # Assumes that `B` is non-zero and that the leading coefficient + # of `B` is invertible modulo `p`. + + int _fmpz_mod_poly_divides_classical(fmpz * Q, const fmpz * A, long lenA, const fmpz * B, long lenB, const fmpz_mod_ctx_t ctx) + # Returns `1` if `(B, lenB)` divides `(A, lenA)` and sets + # `(Q, lenA - lenB + 1)` to the quotient. Otherwise, returns `0` and sets + # `(Q, lenA - lenB + 1)` to zero. We require that `lenA >= lenB > 0`. + + int fmpz_mod_poly_divides_classical(fmpz_mod_poly_t Q, const fmpz_mod_poly_t A, const fmpz_mod_poly_t B, const fmpz_mod_ctx_t ctx) + # Returns `1` if `B` divides `A` and sets `Q` to the quotient. Otherwise + # returns `0` and sets `Q` to zero. + + int _fmpz_mod_poly_divides(fmpz * Q, const fmpz * A, long lenA, const fmpz * B, long lenB, const fmpz_mod_ctx_t ctx) + # Returns `1` if `(B, lenB)` divides `(A, lenA)` and sets + # `(Q, lenA - lenB + 1)` to the quotient. Otherwise, returns `0` and sets + # `(Q, lenA - lenB + 1)` to zero. We require that `lenA >= lenB > 0`. + + int fmpz_mod_poly_divides(fmpz_mod_poly_t Q, const fmpz_mod_poly_t A, const fmpz_mod_poly_t B, const fmpz_mod_ctx_t ctx) + # Returns `1` if `B` divides `A` and sets `Q` to the quotient. Otherwise + # returns `0` and sets `Q` to zero. + + void _fmpz_mod_poly_inv_series(fmpz * Qinv, const fmpz * Q, long Qlen, long n, const fmpz_mod_ctx_t ctx) + # Sets ``(Qinv, n)`` to the inverse of ``(Q, n)`` modulo `x^n`, + # where `n \geq 1`, assuming that the bottom coefficient of `Q` is + # invertible modulo `p` and that its inverse is ``cinv``. + + void fmpz_mod_poly_inv_series(fmpz_mod_poly_t Qinv, const fmpz_mod_poly_t Q, long n, const fmpz_mod_ctx_t ctx) + # Sets ``Qinv`` to the inverse of ``Q`` modulo `x^n`, + # where `n \geq 1`, assuming that the bottom coefficient of + # `Q` is a unit. + + void fmpz_mod_poly_inv_series_f(fmpz_t f, fmpz_mod_poly_t Qinv, const fmpz_mod_poly_t Q, long n, const fmpz_mod_ctx_t ctx) + # Either sets `f` to a nontrivial factor of `p` with the value of + # ``Qinv`` undefined, or sets ``Qinv`` to the inverse of ``Q`` + # modulo `x^n`, where `n \geq 1`. + + void _fmpz_mod_poly_div_series(fmpz * Q, const fmpz * A, long Alen, const fmpz * B, long Blen, long n, const fmpz_mod_ctx_t ctx) + # Set ``(Q, n)`` to the quotient of the series ``(A, Alen``) and + # ``(B, Blen)`` assuming ``Alen, Blen <= n``. We assume the bottom + # coefficient of ``B`` is invertible modulo `p`. + + void fmpz_mod_poly_div_series(fmpz_mod_poly_t Q, const fmpz_mod_poly_t A, const fmpz_mod_poly_t B, long n, const fmpz_mod_ctx_t ctx) + # Set `Q` to the quotient of the series `A` by `B`, thinking of the series as + # though they were of length `n`. We assume that the bottom coefficient of + # `B` is a unit. + + void fmpz_mod_poly_make_monic(fmpz_mod_poly_t res, const fmpz_mod_poly_t poly, const fmpz_mod_ctx_t ctx) + # If ``poly`` is non-zero, sets ``res`` to ``poly`` divided + # by its leading coefficient. This assumes that the leading coefficient + # of ``poly`` is invertible modulo `p`. + # Otherwise, if ``poly`` is zero, sets ``res`` to zero. + + void fmpz_mod_poly_make_monic_f(fmpz_t f, fmpz_mod_poly_t res, const fmpz_mod_poly_t poly, const fmpz_mod_ctx_t ctx) + # Either set `f` to `1` and ``res`` to ``poly`` divided by its leading + # coefficient or set `f` to a nontrivial factor of `p` and leave ``res`` + # undefined. + + long _fmpz_mod_poly_gcd(fmpz *G, const fmpz *A, long lenA, const fmpz *B, long lenB, const fmpz_mod_ctx_t ctx) + # Sets `G` to the greatest common divisor of `(A, \operatorname{len}(A))` + # and `(B, \operatorname{len}(B))` and returns its length. + # Assumes that `\operatorname{len}(A) \geq \operatorname{len}(B) > 0` and that the vector `G` has + # space for sufficiently many coefficients. + # Assumes that ``invB`` is the inverse of the leading coefficients + # of `B` modulo the prime number `p`. + + void fmpz_mod_poly_gcd(fmpz_mod_poly_t G, const fmpz_mod_poly_t A, const fmpz_mod_poly_t B, const fmpz_mod_ctx_t ctx) + # Sets `G` to the greatest common divisor of `A` and `B`. + # In general, the greatest common divisor is defined in the polynomial + # ring `(\mathbf{Z}/(p \mathbf{Z}))[X]` if and only if `p` is a prime + # number. Thus, this function assumes that `p` is prime. + + long _fmpz_mod_poly_gcd_euclidean_f(fmpz_t f, fmpz *G, const fmpz *A, long lenA, const fmpz *B, long lenB, const fmpz_mod_ctx_t ctx) + # Either sets `f = 1` and `G` to the greatest common divisor + # of `(A, \operatorname{len}(A))` and `(B, \operatorname{len}(B))` and returns its length, + # or sets `f \in (1,p)` to a non-trivial factor of `p` and + # leaves the contents of the vector `(G, lenB)` undefined. + # Assumes that `\operatorname{len}(A) \geq \operatorname{len}(B) > 0` and that the vector `G` has + # space for sufficiently many coefficients. + # Does not support aliasing of any of the input arguments + # with any of the output argument. + + void fmpz_mod_poly_gcd_euclidean_f(fmpz_t f, fmpz_mod_poly_t G, const fmpz_mod_poly_t A, const fmpz_mod_poly_t B, const fmpz_mod_ctx_t ctx) + # Either sets `f = 1` and `G` to the greatest common divisor + # of `A` and `B`, or ` \in (1,p)` to a non-trivial factor of `p`. + # In general, the greatest common divisor is defined in the polynomial + # ring `(\mathbf{Z}/(p \mathbf{Z}))[X]` if and only if `p` is a prime + # number. + + long _fmpz_mod_poly_gcd_f(fmpz_t f, fmpz *G, const fmpz *A, long lenA, const fmpz *B, long lenB, const fmpz_mod_ctx_t ctx) + # Either sets `f = 1` and `G` to the greatest common divisor + # of `(A, \operatorname{len}(A))` and `(B, \operatorname{len}(B))` and returns its length, + # or sets `f \in (1,p)` to a non-trivial factor of `p` and + # leaves the contents of the vector `(G, lenB)` undefined. + # Assumes that `\operatorname{len}(A) \geq \operatorname{len}(B) > 0` and that the vector `G` has + # space for sufficiently many coefficients. + # Does not support aliasing of any of the input arguments + # with any of the output arguments. + + void fmpz_mod_poly_gcd_f(fmpz_t f, fmpz_mod_poly_t G, const fmpz_mod_poly_t A, const fmpz_mod_poly_t B, const fmpz_mod_ctx_t ctx) + # Either sets `f = 1` and `G` to the greatest common divisor + # of `A` and `B`, or `f \in (1,p)` to a non-trivial factor of `p`. + # In general, the greatest common divisor is defined in the polynomial + # ring `(\mathbf{Z}/(p \mathbf{Z}))[X]` if and only if `p` is a prime + # number. + + long _fmpz_mod_poly_hgcd(fmpz **M, long *lenM, fmpz *A, long *lenA, fmpz *B, long *lenB, const fmpz *a, long lena, const fmpz *b, long lenb, const fmpz_mod_ctx_t ctx) + # Computes the HGCD of `a` and `b`, that is, a matrix~`M`, a sign~`\sigma` + # and two polynomials `A` and `B` such that + # .. math :: + # (A,B)^t = \sigma M^{-1} (a,b)^t. + # Assumes that `\operatorname{len}(a) > \operatorname{len}(b) > 0`. + # Assumes that `A` and `B` have space of size at least `\operatorname{len}(a)` + # and `\operatorname{len}(b)`, respectively. On exit, ``*lenA`` and ``*lenB`` + # will contain the correct lengths of `A` and `B`. + # Assumes that ``M[0]``, ``M[1]``, ``M[2]``, and ``M[3]`` + # each point to a vector of size at least `\operatorname{len}(a)`. + + long _fmpz_mod_poly_xgcd_euclidean_f(fmpz_t f, fmpz *G, fmpz *S, fmpz *T, const fmpz *A, long lenA, const fmpz *B, long lenB, const fmpz_t invB, const fmpz_mod_ctx_t ctx) + # If `f` returns with the value `1` then the function operates as per + # ``_fmpz_mod_poly_xgcd_euclidean``, otherwise `f` is set to a nontrivial + # factor of `p`. + + void fmpz_mod_poly_xgcd_euclidean_f(fmpz_t f, fmpz_mod_poly_t G, fmpz_mod_poly_t S, fmpz_mod_poly_t T, const fmpz_mod_poly_t A, const fmpz_mod_poly_t B, const fmpz_mod_ctx_t ctx) + # If `f` returns with the value `1` then the function operates as per + # ``fmpz_mod_poly_xgcd_euclidean``, otherwise `f` is set to a nontrivial + # factor of `p`. + + long _fmpz_mod_poly_xgcd(fmpz *G, fmpz *S, fmpz *T, const fmpz *A, long lenA, const fmpz *B, long lenB, const fmpz_t invB, const fmpz_mod_ctx_t ctx) + # Computes the GCD of `A` and `B` together with cofactors `S` and `T` + # such that `S A + T B = G`. Returns the length of `G`. + # Assumes that `\operatorname{len}(A) \geq \operatorname{len}(B) \geq 1` and + # `(\operatorname{len}(A),\operatorname{len}(B)) \neq (1,1)`. + # No attempt is made to make the GCD monic. + # Requires that `G` have space for `\operatorname{len}(B)` coefficients. Writes + # `\operatorname{len}(B)-1` and `\operatorname{len}(A)-1` coefficients to `S` and `T`, respectively. + # Note that, in fact, `\operatorname{len}(S) \leq \max(\operatorname{len}(B) - \operatorname{len}(G), 1)` and + # `\operatorname{len}(T) \leq \max(\operatorname{len}(A) - \operatorname{len}(G), 1)`. + # No aliasing of input and output operands is permitted. + + void fmpz_mod_poly_xgcd(fmpz_mod_poly_t G, fmpz_mod_poly_t S, fmpz_mod_poly_t T, const fmpz_mod_poly_t A, const fmpz_mod_poly_t B, const fmpz_mod_ctx_t ctx) + # Computes the GCD of `A` and `B`. The GCD of zero polynomials is + # defined to be zero, whereas the GCD of the zero polynomial and some other + # polynomial `P` is defined to be `P`. Except in the case where + # the GCD is zero, the GCD `G` is made monic. + # Polynomials ``S`` and ``T`` are computed such that + # ``S*A + T*B = G``. The length of ``S`` will be at most + # ``lenB`` and the length of ``T`` will be at most ``lenA``. + + void fmpz_mod_poly_xgcd_f(fmpz_t f, fmpz_mod_poly_t G, fmpz_mod_poly_t S, fmpz_mod_poly_t T, const fmpz_mod_poly_t A, const fmpz_mod_poly_t B, const fmpz_mod_ctx_t ctx) + # If `f` returns with the value `1` then the function operates as per + # ``fmpz_mod_poly_xgcd``, otherwise `f` is set to a nontrivial + # factor of `p`. + + long _fmpz_mod_poly_gcdinv_euclidean(fmpz *G, fmpz *S, const fmpz *A, long lenA, const fmpz *B, long lenB, const fmpz_t invA, const fmpz_mod_ctx_t ctx) + # Computes ``(G, lenA)``, ``(S, lenB-1)`` such that + # `G \cong S A \pmod{B}`, returning the actual length of `G`. + # Assumes that `0 < \operatorname{len}(A) < \operatorname{len}(B)`. + + void fmpz_mod_poly_gcdinv_euclidean(fmpz_mod_poly_t G, fmpz_mod_poly_t S, const fmpz_mod_poly_t A, const fmpz_mod_poly_t B, const fmpz_mod_ctx_t ctx) + # Computes polynomials `G` and `S`, both reduced modulo~`B`, + # such that `G \cong S A \pmod{B}`, where `B` is assumed to + # have `\operatorname{len}(B) \geq 2`. + # In the case that `A = 0 \pmod{B}`, returns `G = S = 0`. + + long _fmpz_mod_poly_gcdinv_euclidean_f(fmpz_t f, fmpz *G, fmpz *S, const fmpz *A, long lenA, const fmpz *B, long lenB, const fmpz_t invA, const fmpz_mod_ctx_t ctx) + # If `f` returns with value `1` then the function operates as per + # :func:`_fmpz_mod_poly_gcdinv_euclidean`, otherwise `f` is set to a + # nontrivial factor of `p`. + + void fmpz_mod_poly_gcdinv_euclidean_f(fmpz_t f, fmpz_mod_poly_t G, fmpz_mod_poly_t S, const fmpz_mod_poly_t A, const fmpz_mod_poly_t B, const fmpz_mod_ctx_t ctx) + # If `f` returns with value `1` then the function operates as per + # :func:`fmpz_mod_poly_gcdinv_euclidean`, otherwise `f` is set to a + # nontrivial factor of the modulus of `A`. + + long _fmpz_mod_poly_gcdinv(fmpz *G, fmpz *S, const fmpz *A, long lenA, const fmpz *B, long lenB, const fmpz_mod_ctx_t ctx) + # Computes ``(G, lenA)``, ``(S, lenB-1)`` such that + # `G \cong S A \pmod{B}`, returning the actual length of `G`. + # Assumes that `0 < \operatorname{len}(A) < \operatorname{len}(B)`. + + long _fmpz_mod_poly_gcdinv_f(fmpz_t f, fmpz *G, fmpz *S, const fmpz *A, long lenA, const fmpz *B, long lenB, const fmpz_mod_ctx_t ctx) + # If `f` returns with value `1` then the function operates as per + # :func:`_fmpz_mod_poly_gcdinv`, otherwise `f` will be set to a nontrivial + # factor of `p`. + + void fmpz_mod_poly_gcdinv(fmpz_mod_poly_t G, fmpz_mod_poly_t S, const fmpz_mod_poly_t A, const fmpz_mod_poly_t B, const fmpz_mod_ctx_t ctx) + # Computes polynomials `G` and `S`, both reduced modulo~`B`, + # such that `G \cong S A \pmod{B}`, where `B` is assumed to + # have `\operatorname{len}(B) \geq 2`. + # In the case that `A = 0 \pmod{B}`, returns `G = S = 0`. + + void fmpz_mod_poly_gcdinv_f(fmpz_t f, fmpz_mod_poly_t G, fmpz_mod_poly_t S, const fmpz_mod_poly_t A, const fmpz_mod_poly_t B, const fmpz_mod_ctx_t ctx) + # If `f` returns with value `1` then the function operates as per + # :func:`fmpz_mod_poly_gcdinv`, otherwise `f` will be set to a nontrivial + # factor of `p`. + + int _fmpz_mod_poly_invmod(fmpz *A, const fmpz *B, long lenB, const fmpz *P, long lenP, const fmpz_mod_ctx_t ctx) + # Attempts to set ``(A, lenP-1)`` to the inverse of ``(B, lenB)`` + # modulo the polynomial ``(P, lenP)``. Returns `1` if ``(B, lenB)`` + # is invertible and `0` otherwise. + # Assumes that `0 < \operatorname{len}(B) < \operatorname{len}(P)`, and hence also `\operatorname{len}(P) \geq 2`, + # but supports zero-padding in ``(B, lenB)``. + # Does not support aliasing. + # Assumes that `p` is a prime number. + + int _fmpz_mod_poly_invmod_f(fmpz_t f, fmpz *A, const fmpz *B, long lenB, const fmpz *P, long lenP, const fmpz_mod_ctx_t ctx) + # If `f` returns with the value `1`, then the function operates as per + # :func:`_fmpz_mod_poly_invmod`. Otherwise `f` is set to a nontrivial + # factor of `p`. + + int fmpz_mod_poly_invmod(fmpz_mod_poly_t A, const fmpz_mod_poly_t B, const fmpz_mod_poly_t P, const fmpz_mod_ctx_t ctx) + # Attempts to set `A` to the inverse of `B` modulo `P` in the polynomial + # ring `(\mathbf{Z}/p\mathbf{Z})[X]`, where we assume that `p` is a prime + # number. + # If `\deg(P) < 2`, raises an exception. + # If the greatest common divisor of `B` and `P` is~`1`, returns~`1` and + # sets `A` to the inverse of `B`. Otherwise, returns~`0` and the value + # of `A` on exit is undefined. + + int fmpz_mod_poly_invmod_f(fmpz_t f, fmpz_mod_poly_t A, const fmpz_mod_poly_t B, const fmpz_mod_poly_t P, const fmpz_mod_ctx_t ctx) + # If `f` returns with the value `1`, then the function operates as per + # :func:`fmpz_mod_poly_invmod`. Otherwise `f` is set to a nontrivial + # factor of `p`. + + long _fmpz_mod_poly_minpoly_bm(fmpz* poly, const fmpz* seq, long len, const fmpz_mod_ctx_t ctx) + # Sets ``poly`` to the coefficients of a minimal generating + # polynomial for sequence ``(seq, len)`` modulo `p`. + # The return value equals the length of ``poly``. + # It is assumed that `p` is prime and ``poly`` has space for at least + # `len+1` coefficients. No aliasing between inputs and outputs is + # allowed. + + void fmpz_mod_poly_minpoly_bm(fmpz_mod_poly_t poly, const fmpz* seq, long len, const fmpz_mod_ctx_t ctx) + # Sets ``poly`` to a minimal generating polynomial for sequence + # ``seq`` of length ``len``. + # Assumes that the modulus is prime. + # This version uses the Berlekamp-Massey algorithm, whose running time + # is proportional to ``len`` times the size of the minimal generator. + + long _fmpz_mod_poly_minpoly_hgcd(fmpz* poly, const fmpz* seq, long len, const fmpz_mod_ctx_t ctx) + # Sets ``poly`` to the coefficients of a minimal generating + # polynomial for sequence ``(seq, len)`` modulo `p`. + # The return value equals the length of ``poly``. + # It is assumed that `p` is prime and ``poly`` has space for at least + # `len+1` coefficients. No aliasing between inputs and outputs is + # allowed. + + void fmpz_mod_poly_minpoly_hgcd(fmpz_mod_poly_t poly, const fmpz* seq, long len, const fmpz_mod_ctx_t ctx) + # Sets ``poly`` to a minimal generating polynomial for sequence + # ``seq`` of length ``len``. + # Assumes that the modulus is prime. + # This version uses the HGCD algorithm, whose running time is + # `O(n \log^2 n)` field operations, regardless of the actual size of + # the minimal generator. + + long _fmpz_mod_poly_minpoly(fmpz* poly, const fmpz* seq, long len, const fmpz_mod_ctx_t ctx) + # Sets ``poly`` to the coefficients of a minimal generating + # polynomial for sequence ``(seq, len)`` modulo `p`. + # The return value equals the length of ``poly``. + # It is assumed that `p` is prime and ``poly`` has space for at least + # `len+1` coefficients. No aliasing between inputs and outputs is + # allowed. + + void fmpz_mod_poly_minpoly(fmpz_mod_poly_t poly, const fmpz* seq, long len, const fmpz_mod_ctx_t ctx) + # Sets ``poly`` to a minimal generating polynomial for sequence + # ``seq`` of length ``len``. + # A minimal generating polynomial is a monic polynomial + # `f = x^d + c_{d-1}x^{d-1} + \cdots + c_1 x + c_0`, + # of minimal degree `d`, that annihilates any consecutive `d+1` terms + # in ``seq``. That is, for any `i < len - d`, + # `seq_i = -\sum_{j=0}^{d-1} seq_{i+j}*f_j.` + # Assumes that the modulus is prime. + # This version automatically chooses the fastest underlying + # implementation based on ``len`` and the size of the modulus. + + void _fmpz_mod_poly_resultant_euclidean(fmpz_t res, const fmpz *poly1, long len1, const fmpz *poly2, long len2, const fmpz_mod_ctx_t ctx) + # Sets `r` to the resultant of ``(poly1, len1)`` and + # ``(poly2, len2)`` using the Euclidean algorithm. + # Assumes that ``len1 >= len2 > 0``. + # Assumes that the modulus is prime. + + void fmpz_mod_poly_resultant_euclidean(fmpz_t r, const fmpz_mod_poly_t f, const fmpz_mod_poly_t g, const fmpz_mod_ctx_t ctx) + # Computes the resultant of `f` and `g` using the Euclidean algorithm. + # For two non-zero polynomials `f(x) = a_m x^m + \dotsb + a_0` and + # `g(x) = b_n x^n + \dotsb + b_0` of degrees `m` and `n`, the resultant + # is defined to be + # .. math :: + # a_m^n b_n^m \prod_{(x, y) : f(x) = g(y) = 0} (x - y). + # For convenience, we define the resultant to be equal to zero if either + # of the two polynomials is zero. + + void _fmpz_mod_poly_resultant_hgcd(fmpz_t res, const fmpz *A, long lenA, const fmpz *B, long lenB, const fmpz_mod_ctx_t ctx) + # Sets ``res`` to the resultant of ``(A, lenA)`` and + # ``(B, lenB)`` using the half-gcd algorithm. + # This algorithm computes the half-gcd as per + # :func:`_fmpz_mod_poly_gcd_hgcd` + # but additionally updates the resultant every time a division occurs. The + # half-gcd algorithm computes the GCD recursively. Given inputs `a` and `b` + # it lets ``m = len(a)/2`` and (recursively) performs all quotients in + # the Euclidean algorithm which do not require the low `m` coefficients of + # `a` and `b`. + # This performs quotients in exactly the same order as the ordinary + # Euclidean algorithm except that the low `m` coefficients of the polynomials + # in the remainder sequence are not computed. A correction step after hgcd + # has been called computes these low `m` coefficients (by matrix + # multiplication by a transformation matrix also computed by hgcd). + # This means that from the point of view of the resultant, all but the last + # quotient performed by a recursive call to hgcd is an ordinary quotient as + # per the usual Euclidean algorithm. However, the final quotient may give + # a remainder of less than `m + 1` coefficients, which won't be corrected + # until the hgcd correction step is performed afterwards. + # To compute the adjustments to the resultant coming from this corrected + # quotient, we save the relevant information in an ``nmod_poly_res_t`` + # struct at the time the quotient is performed so that when the correction + # step is performed later, the adjustments to the resultant can be computed + # at that time also. + # The only time an adjustment to the resultant is not required after a + # call to hgcd is if hgcd does nothing (the remainder may already have had + # less than `m + 1` coefficients when hgcd was called). + # Assumes that ``lenA >= lenB > 0``. + # Assumes that the modulus is prime. + + void fmpz_mod_poly_resultant_hgcd(fmpz_t res, const fmpz_mod_poly_t f, const fmpz_mod_poly_t g, const fmpz_mod_ctx_t ctx) + # Computes the resultant of `f` and `g` using the half-gcd algorithm. + # For two non-zero polynomials `f(x) = a_m x^m + \dotsb + a_0` and + # `g(x) = b_n x^n + \dotsb + b_0` of degrees `m` and `n`, the resultant + # is defined to be + # .. math :: + # a_m^n b_n^m \prod_{(x, y) : f(x) = g(y) = 0} (x - y). + # For convenience, we define the resultant to be equal to zero if either + # of the two polynomials is zero. + + void _fmpz_mod_poly_resultant(fmpz_t res, const fmpz *poly1, long len1, const fmpz *poly2, long len2, const fmpz_mod_ctx_t ctx) + # Returns the resultant of ``(poly1, len1)`` and + # ``(poly2, len2)``. + # Assumes that ``len1 >= len2 > 0``. + # Assumes that the modulus is prime. + + void fmpz_mod_poly_resultant(fmpz_t res, const fmpz_mod_poly_t f, const fmpz_mod_poly_t g, const fmpz_mod_ctx_t ctx) + # Computes the resultant of $f$ and $g$. + # For two non-zero polynomials `f(x) = a_m x^m + \dotsb + a_0` and + # `g(x) = b_n x^n + \dotsb + b_0` of degrees `m` and `n`, the resultant + # is defined to be + # .. math :: + # a_m^n b_n^m \prod_{(x, y) : f(x) = g(y) = 0} (x - y). + # For convenience, we define the resultant to be equal to zero if either + # of the two polynomials is zero. + + void _fmpz_mod_poly_discriminant(fmpz_t d, const fmpz *poly, long len, const fmpz_mod_ctx_t ctx) + # Set `d` to the discriminant of ``(poly, len)``. Assumes ``len > 1``. + + void fmpz_mod_poly_discriminant(fmpz_t d, const fmpz_mod_poly_t f, const fmpz_mod_ctx_t ctx) + # Set `d` to the discriminant of `f`. + # We normalise the discriminant so that + # `\operatorname{disc}(f) = (-1)^(n(n-1)/2) \operatorname{res}(f, f') / + # \operatorname{lc}(f)^(n - m - 2)`, where ``n = len(f)`` and + # ``m = len(f')``. Thus `\operatorname{disc}(f) = + # \operatorname{lc}(f)^(2n - 2) \prod_{i < j} (r_i - r_j)^2`, where + # `\operatorname{lc}(f)` is the leading coefficient of `f` and `r_i` are the + # roots of `f`. + + void _fmpz_mod_poly_derivative(fmpz *res, const fmpz *poly, long len, const fmpz_mod_ctx_t ctx) + # Sets ``(res, len - 1)`` to the derivative of ``(poly, len)``. + # Also handles the cases where ``len`` is `0` or `1` correctly. + # Supports aliasing of ``res`` and ``poly``. + + void fmpz_mod_poly_derivative(fmpz_mod_poly_t res, const fmpz_mod_poly_t poly, const fmpz_mod_ctx_t ctx) + # Sets ``res`` to the derivative of ``poly``. + + void _fmpz_mod_poly_evaluate_fmpz(fmpz_t res, const fmpz *poly, long len, const fmpz_t a, const fmpz_mod_ctx_t ctx) + # Evaluates the polynomial ``(poly, len)`` at the integer `a` and sets + # ``res`` to the result. Aliasing between ``res`` and `a` or any + # of the coefficients of ``poly`` is not supported. + + void fmpz_mod_poly_evaluate_fmpz(fmpz_t res, const fmpz_mod_poly_t poly, const fmpz_t a, const fmpz_mod_ctx_t ctx) + # Evaluates the polynomial ``poly`` at the integer `a` and sets + # ``res`` to the result. + # As expected, aliasing between ``res`` and `a` is supported. However, + # ``res`` may not be aliased with a coefficient of ``poly``. + + void _fmpz_mod_poly_evaluate_fmpz_vec_iter(fmpz * ys, const fmpz * coeffs, long len, const fmpz * xs, long n, const fmpz_mod_ctx_t ctx) + # Evaluates (``coeffs``, ``len``) at the ``n`` values + # given in the vector ``xs``, writing the output values + # to ``ys``. The values in ``xs`` should be reduced + # modulo the modulus. + # Uses Horner's method iteratively. + + void fmpz_mod_poly_evaluate_fmpz_vec_iter(fmpz * ys, const fmpz_mod_poly_t poly, const fmpz * xs, long n, const fmpz_mod_ctx_t ctx) + # Evaluates ``poly`` at the ``n`` values given in the vector + # ``xs``, writing the output values to ``ys``. The values in + # ``xs`` should be reduced modulo the modulus. + # Uses Horner's method iteratively. + + void _fmpz_mod_poly_evaluate_fmpz_vec_fast_precomp(fmpz * vs, const fmpz * poly, long plen, fmpz_poly_struct * const * tree, long len, const fmpz_mod_ctx_t ctx) + # Evaluates (``poly``, ``plen``) at the ``len`` values given by the precomputed subproduct tree ``tree``. + + void _fmpz_mod_poly_evaluate_fmpz_vec_fast(fmpz * ys, const fmpz * poly, long plen, const fmpz * xs, long n, const fmpz_mod_ctx_t ctx) + # Evaluates (``coeffs``, ``len``) at the ``n`` values + # given in the vector ``xs``, writing the output values + # to ``ys``. The values in ``xs`` should be reduced + # modulo the modulus. + # Uses fast multipoint evaluation, building a temporary subproduct tree. + + void fmpz_mod_poly_evaluate_fmpz_vec_fast(fmpz * ys, const fmpz_mod_poly_t poly, const fmpz * xs, long n, const fmpz_mod_ctx_t ctx) + # Evaluates ``poly`` at the ``n`` values given in the vector + # ``xs``, writing the output values to ``ys``. The values in + # ``xs`` should be reduced modulo the modulus. + # Uses fast multipoint evaluation, building a temporary subproduct tree. + + void _fmpz_mod_poly_evaluate_fmpz_vec(fmpz * ys, const fmpz * coeffs, long len, const fmpz * xs, long n, const fmpz_mod_ctx_t ctx) + # Evaluates (``coeffs``, ``len``) at the ``n`` values + # given in the vector ``xs``, writing the output values + # to ``ys``. The values in ``xs`` should be reduced + # modulo the modulus. + + void fmpz_mod_poly_evaluate_fmpz_vec(fmpz * ys, const fmpz_mod_poly_t poly, const fmpz * xs, long n, const fmpz_mod_ctx_t ctx) + # Evaluates ``poly`` at the ``n`` values given in the vector + # ``xs``, writing the output values to ``ys``. The values in + # ``xs`` should be reduced modulo the modulus. + + void _fmpz_mod_poly_compose(fmpz *res, const fmpz *poly1, long len1, const fmpz *poly2, long len2, const fmpz_mod_ctx_t ctx) + # Sets ``res`` to the composition of ``(poly1, len1)`` and + # ``(poly2, len2)``. + # Assumes that ``res`` has space for ``(len1-1)*(len2-1) + 1`` + # coefficients, although in `\mathbf{Z}_p[X]` this might not actually + # be the length of the resulting polynomial when `p` is not a prime. + # Assumes that ``poly1`` and ``poly2`` are non-zero polynomials. + # Does not support aliasing between any of the inputs and the output. + + void fmpz_mod_poly_compose(fmpz_mod_poly_t res, const fmpz_mod_poly_t poly1, const fmpz_mod_poly_t poly2, const fmpz_mod_ctx_t ctx) + # Sets ``res`` to the composition of ``poly1`` and ``poly2``. + # To be precise about the order of composition, denoting ``res``, + # ``poly1``, and ``poly2`` by `f`, `g`, and `h`, respectively, + # sets `f(t) = g(h(t))`. + + void _fmpz_mod_poly_invsqrt_series(fmpz * g, const fmpz * h, long hlen, long n, const fmpz_mod_ctx_t ctx) + # Set the first `n` terms of `g` to the series expansion of `1/\sqrt{h}`. + # It is assumed that `n > 0` and `h > 0`. Aliasing is not permitted. + + void fmpz_mod_poly_invsqrt_series(fmpz_mod_poly_t g, const fmpz_mod_poly_t h, long n, const fmpz_mod_ctx_t ctx) + # Set `g` to the series expansion of `1/\sqrt{h}` to order `O(x^n)`. + # It is assumed that `h` has constant term 1. + + void _fmpz_mod_poly_sqrt_series(fmpz * g, const fmpz * h, long hlen, long n, const fmpz_mod_ctx_t ctx) + # Set the first `n` terms of `g` to the series expansion of `\sqrt{h}`. + # It is assumed that `n > 0` and `h > 0`. Aliasing is not permitted. + + void fmpz_mod_poly_sqrt_series(fmpz_mod_poly_t g, const fmpz_mod_poly_t h, long n, const fmpz_mod_ctx_t ctx) + # Set `g` to the series expansion of `\sqrt{h}` to order `O(x^n)`. + # It is assumed that `h` has constant term 1. + + int _fmpz_mod_poly_sqrt(fmpz * s, const fmpz * p, long n, const fmpz_mod_ctx_t ctx) + # If ``(p, n)`` is a perfect square, sets ``(s, n / 2 + 1)`` + # to a square root of `p` and returns 1. Otherwise returns 0. + + int fmpz_mod_poly_sqrt(fmpz_mod_poly_t s, const fmpz_mod_poly_t p, const fmpz_mod_ctx_t ctx) + # If `p` is a perfect square, sets `s` to a square root of `p` + # and returns 1. Otherwise returns 0. + + void _fmpz_mod_poly_compose_mod(fmpz * res, const fmpz * f, long lenf, const fmpz * g, const fmpz * h, long lenh, const fmpz_mod_ctx_t ctx) + # Sets ``res`` to the composition `f(g)` modulo `h`. We require that + # `h` is nonzero and that the length of `g` is one less than the + # length of `h` (possibly with zero padding). The output is not allowed + # to be aliased with any of the inputs. + + void fmpz_mod_poly_compose_mod(fmpz_mod_poly_t res, const fmpz_mod_poly_t f, const fmpz_mod_poly_t g, const fmpz_mod_poly_t h, const fmpz_mod_ctx_t ctx) + # Sets ``res`` to the composition `f(g)` modulo `h`. We require that + # `h` is nonzero. + + void _fmpz_mod_poly_compose_mod_horner(fmpz * res, const fmpz * f, long lenf, const fmpz * g, const fmpz * h, long lenh, const fmpz_mod_ctx_t ctx) + # Sets ``res`` to the composition `f(g)` modulo `h`. We require that + # `h` is nonzero and that the length of `g` is one less than the + # length of `h` (possibly with zero padding). The output is not allowed + # to be aliased with any of the inputs. + # The algorithm used is Horner's rule. + + void fmpz_mod_poly_compose_mod_horner(fmpz_mod_poly_t res, const fmpz_mod_poly_t f, const fmpz_mod_poly_t g, const fmpz_mod_poly_t h, const fmpz_mod_ctx_t ctx) + # Sets ``res`` to the composition `f(g)` modulo `h`. We require that + # `h` is nonzero. The algorithm used is Horner's rule. + + void _fmpz_mod_poly_compose_mod_brent_kung(fmpz * res, const fmpz * f, long len1, const fmpz * g, const fmpz * h, long len3, const fmpz_mod_ctx_t ctx) + # Sets ``res`` to the composition `f(g)` modulo `h`. We require that + # `h` is nonzero and that the length of `g` is one less than the + # length of `h` (possibly with zero padding). We also require that + # the length of `f` is less than the length of `h`. The output is not + # allowed to be aliased with any of the inputs. + # The algorithm used is the Brent-Kung matrix algorithm. + + void fmpz_mod_poly_compose_mod_brent_kung(fmpz_mod_poly_t res, const fmpz_mod_poly_t f, const fmpz_mod_poly_t g, const fmpz_mod_poly_t h, const fmpz_mod_ctx_t ctx) + # Sets ``res`` to the composition `f(g)` modulo `h`. We require that + # `h` is nonzero and that `f` has smaller degree than `h`. + # The algorithm used is the Brent-Kung matrix algorithm. + + void _fmpz_mod_poly_reduce_matrix_mod_poly (fmpz_mat_t A, const fmpz_mat_t B, const fmpz_mod_poly_t f, const fmpz_mod_ctx_t ctx) + # Sets the ith row of ``A`` to the reduction of the ith row of `B` modulo + # `f` for `i=1,\ldots,\sqrt{\deg(f)}`. We require `B` to be at least + # a `\sqrt{\deg(f)}\times \deg(f)` matrix and `f` to be nonzero. + + void _fmpz_mod_poly_precompute_matrix_worker(void * arg_ptr) + # Worker function version of ``_fmpz_mod_poly_precompute_matrix``. + # Input/output is stored in ``fmpz_mod_poly_matrix_precompute_arg_t``. + + void _fmpz_mod_poly_precompute_matrix (fmpz_mat_t A, const fmpz * f, const fmpz * g, long leng, const fmpz * ginv, long lenginv, const fmpz_mod_ctx_t ctx) + # Sets the ith row of ``A`` to `f^i` modulo `g` for + # `i=1,\ldots,\sqrt{\deg(g)}`. We require `A` to be + # a `\sqrt{\deg(g)}\times \deg(g)` matrix. We require + # ``ginv`` to be the inverse of the reverse of ``g`` and `g` to be + # nonzero. ``f`` has to be reduced modulo ``g`` and of length one less + # than ``leng`` (possibly with zero padding). + + void fmpz_mod_poly_precompute_matrix(fmpz_mat_t A, const fmpz_mod_poly_t f, const fmpz_mod_poly_t g, const fmpz_mod_poly_t ginv, const fmpz_mod_ctx_t ctx) + # Sets the ith row of ``A`` to `f^i` modulo `g` for + # `i=1,\ldots,\sqrt{\deg(g)}`. We require `A` to be + # a `\sqrt{\deg(g)}\times \deg(g)` matrix. We require + # ``ginv`` to be the inverse of the reverse of ``g``. + + void _fmpz_mod_poly_compose_mod_brent_kung_precomp_preinv_worker(void * arg_ptr) + # Worker function version of + # :func:`_fmpz_mod_poly_compose_mod_brent_kung_precomp_preinv`. + # Input/output is stored in + # ``fmpz_mod_poly_compose_mod_precomp_preinv_arg_t``. + + void _fmpz_mod_poly_compose_mod_brent_kung_precomp_preinv(fmpz * res, const fmpz * f, long lenf, const fmpz_mat_t A, const fmpz * h, long lenh, const fmpz * hinv, long lenhinv, const fmpz_mod_ctx_t ctx) + # Sets ``res`` to the composition `f(g)` modulo `h`. We require that + # `h` is nonzero. We require that the ith row of `A` contains `g^i` for + # `i=1,\ldots,\sqrt{\deg(h)}`, i.e. `A` is a + # `\sqrt{\deg(h)}\times \deg(h)` matrix. We also require that + # the length of `f` is less than the length of `h`. Furthermore, we require + # ``hinv`` to be the inverse of the reverse of ``h``. + # The output is not allowed to be aliased with any of the inputs. + # The algorithm used is the Brent-Kung matrix algorithm. + + void fmpz_mod_poly_compose_mod_brent_kung_precomp_preinv(fmpz_mod_poly_t res, const fmpz_mod_poly_t f, const fmpz_mat_t A, const fmpz_mod_poly_t h, const fmpz_mod_poly_t hinv, const fmpz_mod_ctx_t ctx) + # Sets ``res`` to the composition `f(g)` modulo `h`. We require that the + # ith row of `A` contains `g^i` for `i=1,\ldots,\sqrt{\deg(h)}`, i.e. `A` is + # a `\sqrt{\deg(h)}\times \deg(h)` matrix. We require that `h` is nonzero and + # that `f` has smaller degree than `h`. Furthermore, we require ``hinv`` + # to be the inverse of the reverse of ``h``. This version of Brent-Kung + # modular composition is particularly useful if one has to perform several + # modular composition of the form `f(g)` modulo `h` for fixed `g` and `h`. + + void _fmpz_mod_poly_compose_mod_brent_kung_preinv(fmpz * res, const fmpz * f, long lenf, const fmpz * g, const fmpz * h, long lenh, const fmpz * hinv, long lenhinv, const fmpz_mod_ctx_t ctx) + # Sets ``res`` to the composition `f(g)` modulo `h`. We require that + # `h` is nonzero and that the length of `g` is one less than the + # length of `h` (possibly with zero padding). We also require that + # the length of `f` is less than the length of `h`. Furthermore, we require + # ``hinv`` to be the inverse of the reverse of ``h``. + # The output is not allowed to be aliased with any of the inputs. + # The algorithm used is the Brent-Kung matrix algorithm. + + void fmpz_mod_poly_compose_mod_brent_kung_preinv(fmpz_mod_poly_t res, const fmpz_mod_poly_t f, const fmpz_mod_poly_t g, const fmpz_mod_poly_t h, const fmpz_mod_poly_t hinv, const fmpz_mod_ctx_t ctx) + # Sets ``res`` to the composition `f(g)` modulo `h`. We require that + # `h` is nonzero and that `f` has smaller degree than `h`. Furthermore, + # we require ``hinv`` to be the inverse of the reverse of ``h``. + # The algorithm used is the Brent-Kung matrix algorithm. + + void _fmpz_mod_poly_compose_mod_brent_kung_vec_preinv(fmpz_mod_poly_struct * res, const fmpz_mod_poly_struct * polys, long len1, long l, const fmpz * g, long glen, const fmpz * h, long lenh, const fmpz * hinv, long lenhinv, const fmpz_mod_ctx_t ctx) + # Sets ``res`` to the composition `f_i(g)` modulo `h` for `1\leq i \leq l`, + # where `f_i` are the ``l`` elements of ``polys``. We require that `h` is + # nonzero and that the length of `g` is less than the length of `h`. We + # also require that the length of `f_i` is less than the length of `h`. We + # require ``res`` to have enough memory allocated to hold ``l`` + # ``fmpz_mod_poly_struct``'s. The entries of ``res`` need to be initialised + # and ``l`` needs to be less than ``len1`` Furthermore, we require ``hinv`` + # to be the inverse of the reverse of ``h``. The output is not allowed to be + # aliased with any of the inputs. + # The algorithm used is the Brent-Kung matrix algorithm. + + void fmpz_mod_poly_compose_mod_brent_kung_vec_preinv(fmpz_mod_poly_struct * res, const fmpz_mod_poly_struct * polys, long len1, long n, const fmpz_mod_poly_t g, const fmpz_mod_poly_t h, const fmpz_mod_poly_t hinv, const fmpz_mod_ctx_t ctx) + # Sets ``res`` to the composition `f_i(g)` modulo `h` for `1\leq i \leq n` + # where `f_i` are the ``n`` elements of ``polys``. We require ``res`` to + # have enough memory allocated to hold ``n`` ``fmpz_mod_poly_struct``'s. + # The entries of ``res`` need to be initialised and ``n`` needs to be less + # than ``len1``. We require that `h` is nonzero and that `f_i` and `g` have + # smaller degree than `h`. Furthermore, we require ``hinv`` to be the + # inverse of the reverse of ``h``. No aliasing of ``res`` and + # ``polys`` is allowed. + # The algorithm used is the Brent-Kung matrix algorithm. + + void _fmpz_mod_poly_compose_mod_brent_kung_vec_preinv_threaded_pool(fmpz_mod_poly_struct * res, const fmpz_mod_poly_struct * polys, long lenpolys, long l, const fmpz * g, long glen, const fmpz * poly, long len, const fmpz * polyinv, long leninv, const fmpz_mod_ctx_t ctx, thread_pool_handle * threads, long num_threads) + # Multithreaded version of + # :func:`_fmpz_mod_poly_compose_mod_brent_kung_vec_preinv`. Distributing the + # Horner evaluations across :func:`flint_get_num_threads` threads. + + void fmpz_mod_poly_compose_mod_brent_kung_vec_preinv_threaded_pool(fmpz_mod_poly_struct * res, const fmpz_mod_poly_struct * polys, long len1, long n, const fmpz_mod_poly_t g, const fmpz_mod_poly_t poly, const fmpz_mod_poly_t polyinv, const fmpz_mod_ctx_t ctx, thread_pool_handle * threads, long num_threads) + # Multithreaded version of + # :func:`fmpz_mod_poly_compose_mod_brent_kung_vec_preinv`. Distributing the + # Horner evaluations across :func:`flint_get_num_threads` threads. + + void fmpz_mod_poly_compose_mod_brent_kung_vec_preinv_threaded(fmpz_mod_poly_struct * res, const fmpz_mod_poly_struct * polys, long len1, long n, const fmpz_mod_poly_t g, const fmpz_mod_poly_t poly, const fmpz_mod_poly_t polyinv, const fmpz_mod_ctx_t ctx) + # Multithreaded version of + # :func:`fmpz_mod_poly_compose_mod_brent_kung_vec_preinv`. Distributing the + # Horner evaluations across :func:`flint_get_num_threads` threads. + + fmpz_poly_struct ** _fmpz_mod_poly_tree_alloc(long len) + # Allocates space for a subproduct tree of the given length, having + # linear factors at the lowest level. + + void _fmpz_mod_poly_tree_free(fmpz_poly_struct ** tree, long len) + # Free the allocated space for the subproduct. + + void _fmpz_mod_poly_tree_build(fmpz_poly_struct ** tree, const fmpz * roots, long len, const fmpz_mod_ctx_t ctx) + # Builds a subproduct tree in the preallocated space from + # the ``len`` monic linear factors `(x-r_i)` where `r_i` are given by + # ``roots``. The top level product is not computed. + + void _fmpz_mod_poly_radix_init(fmpz **Rpow, fmpz **Rinv, const fmpz *R, long lenR, long k, const fmpz_t invL, const fmpz_mod_ctx_t ctx) + # Computes powers of `R` of the form `R^{2^i}` and their Newton inverses + # modulo `x^{2^{i} \deg(R)}` for `i = 0, \dotsc, k-1`. + # Assumes that the vectors ``Rpow[i]`` and ``Rinv[i]`` have space + # for `2^i \deg(R) + 1` and `2^i \deg(R)` coefficients, respectively. + # Assumes that the polynomial `R` is non-constant, i.e. `\deg(R) \geq 1`. + # Assumes that the leading coefficient of `R` is a unit and that the + # argument ``invL`` is the inverse of the coefficient modulo~`p`. + # The argument~`p` is the modulus, which in `p`-adic applications is + # typically a prime power, although this is not necessary. Here, we + # only assume that `p \geq 2`. + # Note that this precomputed data can be used for any `F` such that + # `\operatorname{len}(F) \leq 2^k \deg(R)`. + + void fmpz_mod_poly_radix_init(fmpz_mod_poly_radix_t D, const fmpz_mod_poly_t R, long degF, const fmpz_mod_ctx_t ctx) + # Carries out the precomputation necessary to perform radix conversion + # to radix~`R` for polynomials~`F` of degree at most ``degF``. + # Assumes that `R` is non-constant, i.e. `\deg(R) \geq 1`, + # and that the leading coefficient is a unit. + + void _fmpz_mod_poly_radix(fmpz **B, const fmpz *F, fmpz **Rpow, fmpz **Rinv, long degR, long k, long i, fmpz *W, const fmpz_mod_ctx_t ctx) + # This is the main recursive function used by the + # function :func:`fmpz_mod_poly_radix`. + # Assumes that, for all `i = 0, \dotsc, N`, the vector + # ``B[i]`` has space for `\deg(R)` coefficients. + # The variable `k` denotes the factors of `r` that have + # previously been counted for the polynomial `F`, which + # is assumed to have length `2^{i+1} \deg(R)`, possibly + # including zero-padding. + # Assumes that `W` is a vector providing temporary space + # of length `\operatorname{len}(F) = 2^{i+1} \deg(R)`. + # The entire computation takes place over `\mathbf{Z} / p \mathbf{Z}`, + # where `p \geq 2` is a natural number. + # Thus, the top level call will have `F` as in the original + # problem, and `k = 0`. + + void fmpz_mod_poly_radix(fmpz_mod_poly_struct **B, const fmpz_mod_poly_t F, const fmpz_mod_poly_radix_t D, const fmpz_mod_ctx_t ctx) + # Given a polynomial `F` and the precomputed data `D` for the radix `R`, + # computes polynomials `B_0, \dotsc, B_N` of degree less than `\deg(R)` + # such that + # .. math :: + # F = B_0 + B_1 R + \dotsb + B_N R^N, + # where necessarily `N = \lfloor\deg(F) / \deg(R)\rfloor`. + # Assumes that `R` is non-constant, i.e.\ `\deg(R) \geq 1`, + # and that the leading coefficient is a unit. + + int _fmpz_mod_poly_fprint(FILE * file, const fmpz *poly, long len, const fmpz_t p) + # Prints the polynomial ``(poly, len)`` to the stream ``file``. + # In case of success, returns a positive value. In case of failure, + # returns a non-positive value. + + int fmpz_mod_poly_fprint(FILE * file, const fmpz_mod_poly_t poly, const fmpz_mod_ctx_t ctx) + # Prints the polynomial to the stream ``file``. + # In case of success, returns a positive value. In case of failure, + # returns a non-positive value. + + int fmpz_mod_poly_fprint_pretty(FILE * file, const fmpz_mod_poly_t poly, const char * x, const fmpz_mod_ctx_t ctx) + # Prints the pretty representation of ``(poly, len)`` to the stream + # ``file``, using the string ``x`` to represent the indeterminate. + # In case of success, returns a positive value. In case of failure, + # returns a non-positive value. int fmpz_mod_poly_print(const fmpz_mod_poly_t poly, const fmpz_mod_ctx_t ctx) - + # Prints the polynomial to ``stdout``. + # In case of success, returns a positive value. In case of failure, + # returns a non-positive value. int fmpz_mod_poly_print_pretty(const fmpz_mod_poly_t poly, const char * x, const fmpz_mod_ctx_t ctx) + # Prints the pretty representation of ``poly`` to ``stdout``, + # using the string ``x`` to represent the indeterminate. + # In case of success, returns a positive value. In case of failure, + # returns a non-positive value. - void fmpz_mod_poly_product_roots_fmpz_vec(fmpz_poly_t poly, const fmpz * xs, - slong n, const fmpz_t mod) - - int fmpz_mod_poly_find_distinct_nonzero_roots(fmpz * roots, - const fmpz_mod_poly_t P, const fmpz_mod_ctx_t ctx) - - void fmpz_mod_berlekamp_massey_init( - fmpz_mod_berlekamp_massey_t B, const fmpz_mod_ctx_t ctx) - - void fmpz_mod_berlekamp_massey_start_over( - fmpz_mod_berlekamp_massey_t B, const fmpz_mod_ctx_t ctx) - - void fmpz_mod_berlekamp_massey_clear(fmpz_mod_berlekamp_massey_t B, - const fmpz_mod_ctx_t ctx) - - void fmpz_mod_berlekamp_massey_print( - const fmpz_mod_berlekamp_massey_t B, const fmpz_mod_ctx_t ctx) - - void fmpz_mod_berlekamp_massey_add_points( - fmpz_mod_berlekamp_massey_t B, const fmpz * a, slong count, - const fmpz_mod_ctx_t ctx) - - void fmpz_mod_berlekamp_massey_add_zeros( - fmpz_mod_berlekamp_massey_t B, slong count, - const fmpz_mod_ctx_t ctx) - - void fmpz_mod_berlekamp_massey_add_point( - fmpz_mod_berlekamp_massey_t B, const fmpz_t a, - const fmpz_mod_ctx_t ctx) - - void fmpz_mod_berlekamp_massey_add_point_ui( - fmpz_mod_berlekamp_massey_t B, ulong a, - const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_inflate(fmpz_mod_poly_t result, const fmpz_mod_poly_t input, unsigned long inflation, const fmpz_mod_ctx_t ctx) + # Sets ``result`` to the inflated polynomial `p(x^n)` where + # `p` is given by ``input`` and `n` is given by ``inflation``. - int fmpz_mod_berlekamp_massey_reduce( - fmpz_mod_berlekamp_massey_t B, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_deflate(fmpz_mod_poly_t result, const fmpz_mod_poly_t input, unsigned long deflation, const fmpz_mod_ctx_t ctx) + # Sets ``result`` to the deflated polynomial `p(x^{1/n})` where + # `p` is given by ``input`` and `n` is given by ``deflation``. + # Requires `n > 0`. - const fmpz * fmpz_mod_berlekamp_massey_points( - const fmpz_mod_berlekamp_massey_t B) + unsigned long fmpz_mod_poly_deflation(const fmpz_mod_poly_t input, const fmpz_mod_ctx_t ctx) + # Returns the largest integer by which ``input`` can be deflated. + # As special cases, returns 0 if ``input`` is the zero polynomial + # and 1 of ``input`` is a constant polynomial. - slong fmpz_mod_berlekamp_massey_point_count( - const fmpz_mod_berlekamp_massey_t B) + void fmpz_mod_berlekamp_massey_init(fmpz_mod_berlekamp_massey_t B, const fmpz_mod_ctx_t ctx) + # Initialize ``B`` with an empty stream. - const fmpz_mod_poly_struct * fmpz_mod_berlekamp_massey_V_poly( - const fmpz_mod_berlekamp_massey_t B) + void fmpz_mod_berlekamp_massey_clear(fmpz_mod_berlekamp_massey_t B, const fmpz_mod_ctx_t ctx) + # Free any space used by ``B``. - const fmpz_mod_poly_struct * fmpz_mod_berlekamp_massey_R_poly( - const fmpz_mod_berlekamp_massey_t B) + void fmpz_mod_berlekamp_massey_start_over(fmpz_mod_berlekamp_massey_t B, const fmpz_mod_ctx_t ctx) + # Empty the stream of points in ``B``. - void fmpz_mod_poly_add_si(fmpz_mod_poly_t res, - const fmpz_mod_poly_t poly, slong c, const fmpz_mod_ctx_t ctx) + void fmpz_mod_berlekamp_massey_add_points(fmpz_mod_berlekamp_massey_t B, const fmpz * a, long count, const fmpz_mod_ctx_t ctx) + void fmpz_mod_berlekamp_massey_add_zeros(fmpz_mod_berlekamp_massey_t B, long count, const fmpz_mod_ctx_t ctx) + void fmpz_mod_berlekamp_massey_add_point(fmpz_mod_berlekamp_massey_t B, const fmpz_t a, const fmpz_mod_ctx_t ctx) + # Add point(s) to the stream processed by ``B``. The addition of any number of points will not update the `V` and `R` polynomial. - void fmpz_mod_poly_sub_si(fmpz_mod_poly_t res, - const fmpz_mod_poly_t poly, slong c, const fmpz_mod_ctx_t ctx) + int fmpz_mod_berlekamp_massey_reduce(fmpz_mod_berlekamp_massey_t B, const fmpz_mod_ctx_t ctx) + # Ensure that the polynomials `V` and `R` are up to date. The return value is ``1`` if this function changed `V` and ``0`` otherwise. + # For example, if this function is called twice in a row without adding any points in between, the return of the second call should be ``0``. + # As another example, suppose the object is emptied, the points `1, 1, 2, 3` are added, then reduce is called. This reduce should return ``1`` with `\deg(R) < \deg(V) = 2` because the Fibonacci sequence has been recognized. The further addition of the two points `5, 8` and a reduce will result in a return value of ``0``. - void fmpz_mod_poly_si_sub(fmpz_mod_poly_t res, slong c, - const fmpz_mod_poly_t poly, const fmpz_mod_ctx_t ctx) + long fmpz_mod_berlekamp_massey_point_count(const fmpz_mod_berlekamp_massey_t B) + # Return the number of points stored in ``B``. - void fmpz_mod_poly_add_fmpz(fmpz_mod_poly_t res, - const fmpz_mod_poly_t poly, fmpz_t c, const fmpz_mod_ctx_t ctx) + const fmpz * fmpz_mod_berlekamp_massey_points(const fmpz_mod_berlekamp_massey_t B) + # Return a pointer the array of points stored in ``B``. This may be ``NULL`` if func::fmpz_mod_berlekamp_massey_point_count returns ``0``. - void fmpz_mod_poly_sub_fmpz(fmpz_mod_poly_t res, - const fmpz_mod_poly_t poly, fmpz_t c, const fmpz_mod_ctx_t ctx) + const fmpz_mod_poly_struct * fmpz_mod_berlekamp_massey_V_poly(const fmpz_mod_berlekamp_massey_t B) + # Return the polynomial ``V`` in ``B``. - void fmpz_mod_poly_fmpz_sub(fmpz_mod_poly_t res, fmpz_t c, - const fmpz_mod_poly_t poly, const fmpz_mod_ctx_t ctx) + const fmpz_mod_poly_struct * fmpz_mod_berlekamp_massey_R_poly(const fmpz_mod_berlekamp_massey_t B) + # Return the polynomial ``R`` in ``B``. diff --git a/src/sage/libs/flint/fmpz_poly_q.pxd b/src/sage/libs/flint/fmpz_poly_q.pxd index 63c13355bf6..9dbc7adfdb1 100644 --- a/src/sage/libs/flint/fmpz_poly_q.pxd +++ b/src/sage/libs/flint/fmpz_poly_q.pxd @@ -1,71 +1,149 @@ # distutils: libraries = flint -# distutils: depends = flint/qadic.h +# distutils: depends = flint/fmpz_poly_q.h +################################################################################ +# This file is auto-generated. Do not modify by hand +################################################################################ + +from libc.stdio cimport FILE +from sage.libs.gmp.types cimport * +from sage.libs.mpfr.types cimport * from sage.libs.flint.types cimport * -# flint/qadic.h cdef extern from "flint_wrap.h": - #* Accessing numerator and denominator ***************************************/ - # macros - fmpz_poly_struct* fmpz_poly_q_numref(fmpz_poly_q_t op) - fmpz_poly_struct* fmpz_poly_q_denref(fmpz_poly_q_t op) + + void fmpz_poly_q_init(fmpz_poly_q_t rop) + # Initialises ``rop``. + + void fmpz_poly_q_clear(fmpz_poly_q_t rop) + # Clears the object ``rop``. + + fmpz_poly_struct * fmpz_poly_q_numref(const fmpz_poly_q_t op) + # Returns a reference to the numerator of ``op``. + + fmpz_poly_struct * fmpz_poly_q_denref(const fmpz_poly_q_t op) + # Returns a reference to the denominator of ``op``. void fmpz_poly_q_canonicalise(fmpz_poly_q_t rop) + # Brings ``rop`` into canonical form, only assuming that + # the denominator is non-zero. + int fmpz_poly_q_is_canonical(const fmpz_poly_q_t op) + # Checks whether the rational function ``op`` is in + # canonical form. - #* Memory management *********************************************************/ - void fmpz_poly_q_init(fmpz_poly_q_t rop) - void fmpz_poly_q_clear(fmpz_poly_q_t rop) + void fmpz_poly_q_randtest(fmpz_poly_q_t poly, flint_rand_t state, long len1, flint_bitcnt_t bits1, long len2, flint_bitcnt_t bits2) + # Sets ``poly`` to a random rational function. - #* Randomisation *************************************************************/ - void fmpz_poly_q_randtest(fmpz_poly_q_t poly, flint_rand_t state, - long len1, mp_bitcnt_t bits1, - long len2, mp_bitcnt_t bits2) - void fmpz_poly_q_randtest_not_zero(fmpz_poly_q_t poly, flint_rand_t state, - long len1, mp_bitcnt_t bits1, - long len2, mp_bitcnt_t bits2) + void fmpz_poly_q_randtest_not_zero(fmpz_poly_q_t poly, flint_rand_t state, long len1, flint_bitcnt_t bits1, long len2, flint_bitcnt_t bits2) + # Sets ``poly`` to a random non-zero rational function. - #* Assignment ****************************************************************/ void fmpz_poly_q_set(fmpz_poly_q_t rop, const fmpz_poly_q_t op) + # Sets the element ``rop`` to the same value as the element ``op``. + void fmpz_poly_q_set_si(fmpz_poly_q_t rop, long op) + # Sets the element ``rop`` to the value given by the ``slong`` + # ``op``. + void fmpz_poly_q_swap(fmpz_poly_q_t op1, fmpz_poly_q_t op2) + # Swaps the elements ``op1`` and ``op2``. + # This is done efficiently by swapping pointers. + void fmpz_poly_q_zero(fmpz_poly_q_t rop) + # Sets ``rop`` to zero. + void fmpz_poly_q_one(fmpz_poly_q_t rop) + # Sets ``rop`` to one. + void fmpz_poly_q_neg(fmpz_poly_q_t rop, const fmpz_poly_q_t op) + # Sets the element ``rop`` to the additive inverse of ``op``. + void fmpz_poly_q_inv(fmpz_poly_q_t rop, const fmpz_poly_q_t op) + # Sets the element ``rop`` to the multiplicative inverse of ``op``. + # Assumes that the element ``op`` is non-zero. - #* Comparison ****************************************************************/ int fmpz_poly_q_is_zero(const fmpz_poly_q_t op) + # Returns whether the element ``op`` is zero. + int fmpz_poly_q_is_one(const fmpz_poly_q_t op) + # Returns whether the element ``rop`` is equal to the constant + # polynomial `1`. + int fmpz_poly_q_equal(const fmpz_poly_q_t op1, const fmpz_poly_q_t op2) + # Returns whether the two elements ``op1`` and ``op2`` are equal. - #* Addition and subtraction **************************************************/ - void fmpz_poly_q_add_in_place(fmpz_poly_q_t rop, const fmpz_poly_q_t op) - void fmpz_poly_q_sub_in_place(fmpz_poly_q_t rop, const fmpz_poly_q_t op) void fmpz_poly_q_add(fmpz_poly_q_t rop, const fmpz_poly_q_t op1, const fmpz_poly_q_t op2) + # Sets ``rop`` to the sum of ``op1`` and ``op2``. + void fmpz_poly_q_sub(fmpz_poly_q_t rop, const fmpz_poly_q_t op1, const fmpz_poly_q_t op2) + # Sets ``rop`` to the difference of ``op1`` and ``op2``. + void fmpz_poly_q_addmul(fmpz_poly_q_t rop, const fmpz_poly_q_t op1, const fmpz_poly_q_t op2) + # Adds the product of ``op1`` and ``op2`` to ``rop``. + void fmpz_poly_q_submul(fmpz_poly_q_t rop, const fmpz_poly_q_t op1, const fmpz_poly_q_t op2) + # Subtracts the product of ``op1`` and ``op2`` from ``rop``. - #* Scalar multiplication and division ****************************************/ void fmpz_poly_q_scalar_mul_si(fmpz_poly_q_t rop, const fmpz_poly_q_t op, long x) + # Sets ``rop`` to the product of the rational function ``op`` + # and the ``slong`` integer `x`. + + void fmpz_poly_q_scalar_mul_fmpz(fmpz_poly_q_t rop, const fmpz_poly_q_t op, const fmpz_t x) + # Sets ``rop`` to the product of the rational function ``op`` + # and the ``fmpz_t`` integer `x`. + + void fmpz_poly_q_scalar_mul_fmpq(fmpz_poly_q_t rop, const fmpz_poly_q_t op, const fmpq_t x) + # Sets ``rop`` to the product of the rational function ``op`` + # and the ``fmpq_t`` rational `x`. + void fmpz_poly_q_scalar_div_si(fmpz_poly_q_t rop, const fmpz_poly_q_t op, long x) + # Sets ``rop`` to the quotient of the rational function ``op`` + # and the ``slong`` integer `x`. - #* Multiplication and division ***********************************************/ - void fmpz_poly_q_mul(fmpz_poly_q_t rop, - const fmpz_poly_q_t op1, const fmpz_poly_q_t op2) - void fmpz_poly_q_div(fmpz_poly_q_t rop, - const fmpz_poly_q_t op1, const fmpz_poly_q_t op2) + void fmpz_poly_q_scalar_div_fmpz(fmpz_poly_q_t rop, const fmpz_poly_q_t op, const fmpz_t x) + # Sets ``rop`` to the quotient of the rational function ``op`` + # and the ``fmpz_t`` integer `x`. + + void fmpz_poly_q_scalar_div_fmpq(fmpz_poly_q_t rop, const fmpz_poly_q_t op, const fmpq_t x) + # Sets ``rop`` to the quotient of the rational function ``op`` + # and the ``fmpq_t`` rational `x`. + + void fmpz_poly_q_mul(fmpz_poly_q_t rop, const fmpz_poly_q_t op1, const fmpz_poly_q_t op2) + # Sets ``rop`` to the product of ``op1`` and ``op2``. + + void fmpz_poly_q_div(fmpz_poly_q_t rop, const fmpz_poly_q_t op1, const fmpz_poly_q_t op2) + # Sets ``rop`` to the quotient of ``op1`` and ``op2``. - #* Powering ******************************************************************/ void fmpz_poly_q_pow(fmpz_poly_q_t rop, const fmpz_poly_q_t op, unsigned long exp) + # Sets ``rop`` to the ``exp``-th power of ``op``. + # The corner case of ``exp == 0`` is handled by setting ``rop`` to + # the constant function `1`. Note that this includes the case `0^0 = 1`. - #* Derivative ****************************************************************/ void fmpz_poly_q_derivative(fmpz_poly_q_t rop, const fmpz_poly_q_t op) + # Sets ``rop`` to the derivative of ``op``. + + int fmpz_poly_q_evaluate_fmpq(fmpq_t rop, const fmpz_poly_q_t f, const fmpq_t a) + # Sets ``rop`` to `f` evaluated at the rational `a`. + # If the denominator evaluates to zero at `a`, returns non-zero and + # does not modify any of the variables. Otherwise, returns `0` and + # sets ``rop`` to the rational `f(a)`. - #* Input and output **********************************************************/ int fmpz_poly_q_set_str(fmpz_poly_q_t rop, const char *s) + # Sets ``rop`` to the rational function given + # by the string ``s``. + char * fmpz_poly_q_get_str(const fmpz_poly_q_t op) + # Returns the string representation of + # the rational function ``op``. + char * fmpz_poly_q_get_str_pretty(const fmpz_poly_q_t op, const char *x) + # Returns the pretty string representation of + # the rational function ``op``. + int fmpz_poly_q_print(const fmpz_poly_q_t op) + # Prints the representation of the rational + # function ``op`` to ``stdout``. + int fmpz_poly_q_print_pretty(const fmpz_poly_q_t op, const char *x) + # Prints the pretty representation of the rational + # function ``op`` to ``stdout``. diff --git a/src/sage/libs/flint/fq.pxd b/src/sage/libs/flint/fq.pxd index 7c7565a38d8..f03d61258f7 100644 --- a/src/sage/libs/flint/fq.pxd +++ b/src/sage/libs/flint/fq.pxd @@ -1,76 +1,363 @@ # distutils: libraries = flint # distutils: depends = flint/fq.h -from sage.libs.flint.types cimport fq_ctx_t, fq_t, fmpz_t, fmpz_mod_poly_t, slong, ulong +################################################################################ +# This file is auto-generated. Do not modify by hand +################################################################################ + +from libc.stdio cimport FILE +from sage.libs.gmp.types cimport * +from sage.libs.mpfr.types cimport * +from sage.libs.flint.types cimport * -# flint/fq.h cdef extern from "flint_wrap.h": - void fq_ctx_init(fq_ctx_t ctx, const fmpz_t p, slong d, const char *var) - void fq_ctx_init_conway(fq_ctx_t ctx, const fmpz_t p, slong d, const char *var) - void fq_ctx_init_modulus(fq_ctx_t ctx, - fmpz_mod_poly_t modulus, - const char *var) + + void fq_ctx_init(fq_ctx_t ctx, const fmpz_t p, long d, const char *var) + # Initialises the context for prime `p` and extension degree `d`, + # with name ``var`` for the generator. By default, it will try + # use a Conway polynomial; if one is not available, a random + # irreducible polynomial will be used. + # Assumes that `p` is a prime. + # Assumes that the string ``var`` is a null-terminated string + # of length at least one. + + int _fq_ctx_init_conway(fq_ctx_t ctx, const fmpz_t p, long d, const char *var) + # Attempts to initialise the context for prime `p` and extension + # degree `d`, with name ``var`` for the generator using a Conway + # polynomial for the modulus. + # Returns `1` if the Conway polynomial is in the database for the + # given size and the initialization is successful; otherwise, + # returns `0`. + # Assumes that `p` is a prime. + # Assumes that the string ``var`` is a null-terminated string + # of length at least one. + + void fq_ctx_init_conway(fq_ctx_t ctx, const fmpz_t p, long d, const char *var) + # Initialises the context for prime `p` and extension degree `d`, + # with name ``var`` for the generator using a Conway polynomial + # for the modulus. + # Assumes that `p` is a prime. + # Assumes that the string ``var`` is a null-terminated string + # of length at least one. + + void fq_ctx_init_modulus(fq_ctx_t ctx, const fmpz_mod_poly_t modulus, const fmpz_mod_ctx_t ctxp, const char *var) + # Initialises the context for given ``modulus`` with name + # ``var`` for the generator. + # Assumes that ``modulus`` is an irreducible polynomial over the finite field `\mathbf{F}_{p}` in ``ctxp``. + # Assumes that the string ``var`` is a null-terminated string + # of length at least one. void fq_ctx_clear(fq_ctx_t ctx) + # Clears all memory that has been allocated as part of the context. + + const fmpz_mod_poly_struct* fq_ctx_modulus(const fq_ctx_t ctx) + # Returns a pointer to the modulus in the context. + + long fq_ctx_degree(const fq_ctx_t ctx) + # Returns the degree of the field extension + # `[\mathbf{F}_{q} : \mathbf{F}_{p}]`, which + # is equal to `\log_{p} q`. + + const fmpz * fq_ctx_prime(const fq_ctx_t ctx) + # Returns a pointer to the prime `p` in the context. - fmpz_t fq_ctx_prime(fq_ctx_t ctx) - slong fq_ctx_degree(const fq_ctx_t ctx) void fq_ctx_order(fmpz_t f, const fq_ctx_t ctx) + # Sets `f` to be the size of the finite field. + + int fq_ctx_fprint(FILE * file, const fq_ctx_t ctx) + # Prints the context information to ``file``. Returns 1 for a + # success and a negative number for an error. void fq_ctx_print(const fq_ctx_t ctx) + # Prints the context information to ``stdout``. - # Memory managment + void fq_ctx_randtest(fq_ctx_t ctx, flint_rand_t state) + # Initializes ``ctx`` to a random finite field. Assumes that + # ``fq_ctx_init`` has not been called on ``ctx`` already. + + void fq_ctx_randtest_reducible(fq_ctx_t ctx, flint_rand_t state) + # Initializes ``ctx`` to a random extension of a prime field. + # The modulus may or may not be irreducible. Assumes that + # ``fq_ctx_init`` has not been called on ``ctx`` already. void fq_init(fq_t rop, const fq_ctx_t ctx) + # Initialises the element ``rop``, setting its value to `0`. + + void fq_init2(fq_t rop, const fq_ctx_t ctx) + # Initialises ``poly`` with at least enough space for it to be an element + # of ``ctx`` and sets it to `0`. + void fq_clear(fq_t rop, const fq_ctx_t ctx) - void fq_reduce(fq_t rop, const fq_ctx_t ctx) + # Clears the element ``rop``. + + void _fq_sparse_reduce(fmpz *R, long lenR, const fq_ctx_t ctx) + # Reduces ``(R, lenR)`` modulo the polynomial `f` given by the + # modulus of ``ctx``. + + void _fq_dense_reduce(fmpz *R, long lenR, const fq_ctx_t ctx) + # Reduces ``(R, lenR)`` modulo the polynomial `f` given by the + # modulus of ``ctx`` using Newton division. + + void _fq_reduce(fmpz *r, long lenR, const fq_ctx_t ctx) + # Reduces ``(R, lenR)`` modulo the polynomial `f` given by the + # modulus of ``ctx``. Does either sparse or dense reduction + # based on ``ctx->sparse_modulus``. - # Basic arithmetic + void fq_reduce(fq_t rop, const fq_ctx_t ctx) + # Reduces the polynomial ``rop`` as an element of + # `\mathbf{F}_p[X] / (f(X))`. void fq_add(fq_t rop, const fq_t op1, const fq_t op2, const fq_ctx_t ctx) + # Sets ``rop`` to the sum of ``op1`` and ``op2``. + void fq_sub(fq_t rop, const fq_t op1, const fq_t op2, const fq_ctx_t ctx) + # Sets ``rop`` to the difference of ``op1`` and ``op2``. + void fq_sub_one(fq_t rop, const fq_t op1, const fq_ctx_t ctx) - void fq_neg(fq_t rop, const fq_t op1, const fq_ctx_t ctx) + # Sets ``rop`` to the difference of ``op1`` and `1`. + + void fq_neg(fq_t rop, const fq_t op, const fq_ctx_t ctx) + # Sets ``rop`` to the negative of ``op``. + void fq_mul(fq_t rop, const fq_t op1, const fq_t op2, const fq_ctx_t ctx) + # Sets ``rop`` to the product of ``op1`` and ``op2``, + # reducing the output in the given context. + void fq_mul_fmpz(fq_t rop, const fq_t op, const fmpz_t x, const fq_ctx_t ctx) - void fq_mul_si(fq_t rop, const fq_t op, slong x, const fq_ctx_t ctx) - void fq_mul_ui(fq_t rop, const fq_t op, ulong x, const fq_ctx_t ctx) - void fq_div(fq_t rop, const fq_t op1, const fq_t op2, const fq_ctx_t ctx) + # Sets ``rop`` to the product of ``op`` and `x`, + # reducing the output in the given context. + + void fq_mul_si(fq_t rop, const fq_t op, long x, const fq_ctx_t ctx) + # Sets ``rop`` to the product of ``op`` and `x`, + # reducing the output in the given context. + + void fq_mul_ui(fq_t rop, const fq_t op, unsigned long x, const fq_ctx_t ctx) + # Sets ``rop`` to the product of ``op`` and `x`, + # reducing the output in the given context. + void fq_sqr(fq_t rop, const fq_t op, const fq_ctx_t ctx) - void fq_inv(fq_t rop, const fq_t op1, const fq_ctx_t ctx) - void fq_gcdinv(fq_t rop, fq_t inv, const fq_t op, const fq_ctx_t ctx) - void fq_pow(fq_t rop, const fq_t op1, const fmpz_t e, const fq_ctx_t ctx) - void fq_pow_ui(fq_t rop, const fq_t op, const ulong e, const fq_ctx_t ctx) + # Sets ``rop`` to the square of ``op``, + # reducing the output in the given context. + + void fq_div(fq_t rop, const fq_t op1, const fq_t op2, const fq_ctx_t ctx) + # Sets ``rop`` to the quotient of ``op1`` and ``op2``, + # reducing the output in the given context. + + void _fq_inv(fmpz *rop, const fmpz *op, long len, const fq_ctx_t ctx) + # Sets ``(rop, d)`` to the inverse of the non-zero element + # ``(op, len)``. + + void fq_inv(fq_t rop, const fq_t op, const fq_ctx_t ctx) + # Sets ``rop`` to the inverse of the non-zero element ``op``. + + void fq_gcdinv(fq_t f, fq_t inv, const fq_t op, const fq_ctx_t ctx) + # Sets ``inv`` to be the inverse of ``op`` modulo the modulus + # of ``ctx``. If ``op`` is not invertible, then ``f`` is + # set to a factor of the modulus; otherwise, it is set to one. + + void _fq_pow(fmpz *rop, const fmpz *op, long len, const fmpz_t e, const fq_ctx_t ctx) + # Sets ``(rop, 2*d-1)`` to ``(op,len)`` raised to the power `e`, + # reduced modulo `f(X)`, the modulus of ``ctx``. + # Assumes that `e \geq 0` and that ``len`` is positive and at most `d`. + # Although we require that ``rop`` provides space for + # `2d - 1` coefficients, the output will be reduced modulo + # `f(X)`, which is a polynomial of degree `d`. + # Does not support aliasing. + + void fq_pow(fq_t rop, const fq_t op, const fmpz_t e, const fq_ctx_t ctx) + # Sets ``rop`` the ``op`` raised to the power `e`. + # Currently assumes that `e \geq 0`. + # Note that for any input ``op``, ``rop`` is set to `1` + # whenever `e = 0`. + + void fq_pow_ui(fq_t rop, const fq_t op, const unsigned long e, const fq_ctx_t ctx) + # Sets ``rop`` the ``op`` raised to the power `e`. + # Currently assumes that `e \geq 0`. + # Note that for any input ``op``, ``rop`` is set to `1` + # whenever `e = 0`. + + int fq_sqrt(fq_t rop, const fq_t op1, const fq_ctx_t ctx) + # Sets ``rop`` to the square root of ``op1`` if it is a square, and return + # `1`, otherwise return `0`. + void fq_pth_root(fq_t rop, const fq_t op1, const fq_ctx_t ctx) + # Sets ``rop`` to a `p^{th}` root root of ``op1``. Currently, + # this computes the root by raising ``op1`` to `p^{d-1}` where + # `d` is the degree of the extension. - # Comparison + int fq_is_square(const fq_t op, const fq_ctx_t ctx) + # Return ``1`` if ``op`` is a square. - int fq_equal(const fq_t op1, const fq_t op2, const fq_ctx_t ctx) - int fq_is_zero(const fq_t op, const fq_ctx_t ctx) - int fq_is_one(const fq_t op, const fq_ctx_t ctx) + int fq_fprint_pretty(FILE *file, const fq_t op, const fq_ctx_t ctx) + # Prints a pretty representation of ``op`` to ``file``. + # In the current implementation, always returns `1`. The return code is + # part of the function's signature to allow for a later implementation to + # return the number of characters printed or a non-positive error code. - # Assignments and conversions + int fq_print_pretty(const fq_t op, const fq_ctx_t ctx) + # Prints a pretty representation of ``op`` to ``stdout``. + # In the current implementation, always returns `1`. The return code is + # part of the function's signature to allow for a later implementation to + # return the number of characters printed or a non-positive error code. + + int fq_fprint(FILE * file, const fq_t op, const fq_ctx_t ctx) + # Prints a representation of ``op`` to ``file``. + # For further details on the representation used, see + # :func:`fmpz_mod_poly_fprint`. + + void fq_print(const fq_t op, const fq_ctx_t ctx) + # Prints a representation of ``op`` to ``stdout``. + # For further details on the representation used, see + # :func:`fmpz_mod_poly_print`. + + char * fq_get_str(const fq_t op, const fq_ctx_t ctx) + # Returns the plain FLINT string representation of the element + # ``op``. + + char * fq_get_str_pretty(const fq_t op, const fq_ctx_t ctx) + # Returns a pretty representation of the element ``op`` using the + # null-terminated string ``x`` as the variable name. + + void fq_randtest(fq_t rop, flint_rand_t state, const fq_ctx_t ctx) + # Generates a random element of `\mathbf{F}_q`. + + void fq_randtest_not_zero(fq_t rop, flint_rand_t state, const fq_ctx_t ctx) + # Generates a random non-zero element of `\mathbf{F}_q`. + + void fq_randtest_dense(fq_t rop, flint_rand_t state, const fq_ctx_t ctx) + # Generates a random element of `\mathbf{F}_q` which has an + # underlying polynomial with dense coefficients. + + void fq_rand(fq_t rop, flint_rand_t state, const fq_ctx_t ctx) + # Generates a high quality random element of `\mathbf{F}_q`. + + void fq_rand_not_zero(fq_t rop, flint_rand_t state, const fq_ctx_t ctx) + # Generates a high quality non-zero random element of `\mathbf{F}_q`. void fq_set(fq_t rop, const fq_t op, const fq_ctx_t ctx) + # Sets ``rop`` to ``op``. + + void fq_set_si(fq_t rop, const long x, const fq_ctx_t ctx) + # Sets ``rop`` to ``x``, considered as an element of + # `\mathbf{F}_p`. + + void fq_set_ui(fq_t rop, const unsigned long x, const fq_ctx_t ctx) + # Sets ``rop`` to ``x``, considered as an element of + # `\mathbf{F}_p`. + void fq_set_fmpz(fq_t rop, const fmpz_t x, const fq_ctx_t ctx) - void fq_set_ui(fq_t rop, const ulong x, const fq_ctx_t ctx) - void fq_set_si(fq_t rop, const slong x, const fq_ctx_t ctx) - void fq_set_coeff_fmpz(fq_t rop, const fmpz_t x, const ulong n, const fq_ctx_t ctx) + # Sets ``rop`` to ``x``, considered as an element of + # `\mathbf{F}_p`. + void fq_swap(fq_t op1, fq_t op2, const fq_ctx_t ctx) + # Swaps the two elements ``op1`` and ``op2``. + void fq_zero(fq_t rop, const fq_ctx_t ctx) + # Sets ``rop`` to zero. + void fq_one(fq_t rop, const fq_ctx_t ctx) + # Sets ``rop`` to one, reduced in the given context. + void fq_gen(fq_t rop, const fq_ctx_t ctx) + # Sets ``rop`` to a generator for the finite field. + # There is no guarantee this is a multiplicative generator of + # the finite field. - # Output + int fq_get_fmpz(fmpz_t rop, const fq_t op, const fq_ctx_t ctx) + # If ``op`` has a lift to the integers, return `1` and set ``rop`` to the lift in `[0,p)`. + # Otherwise, return `0` and leave `rop` undefined. - void fq_print(const fq_t op, const fq_ctx_t ctx) - int fq_print_pretty(const fq_t op, const fq_ctx_t ctx) + void fq_get_fmpz_poly(fmpz_poly_t a, const fq_t b, const fq_ctx_t ctx) - char * fq_get_str(const fq_t op, const fq_ctx_t ctx) - char * fq_get_str_pretty(const fq_t op, const fq_ctx_t ctx) + void fq_get_fmpz_mod_poly(fmpz_mod_poly_t a, const fq_t b, const fq_ctx_t ctx) + # Set ``a`` to a representative of ``b`` in ``ctx``. + # The representatives are taken in `(\mathbb{Z}/p\mathbb{Z})[x]/h(x)` where `h(x)` is the defining polynomial in ``ctx``. - # Special functions + void fq_set_fmpz_poly(fq_t a, const fmpz_poly_t b, const fq_ctx_t ctx) + + void fq_set_fmpz_mod_poly(fq_t a, const fmpz_mod_poly_t b, const fq_ctx_t ctx) + # Set ``a`` to the element in ``ctx`` with representative ``b``. + # The representatives are taken in `(\mathbb{Z}/p\mathbb{Z})[x]/h(x)` where `h(x)` is the defining polynomial in ``ctx``. + + void fq_get_fmpz_mod_mat(fmpz_mod_mat_t col, const fq_t a, const fq_ctx_t ctx) + # Convert ``a`` to a column vector of length ``degree(ctx)``. + + void fq_set_fmpz_mod_mat(fq_t a, const fmpz_mod_mat_t col, const fq_ctx_t ctx) + # Convert a column vector ``col`` of length ``degree(ctx)`` to an element of ``ctx``. + + int fq_is_zero(const fq_t op, const fq_ctx_t ctx) + # Returns whether ``op`` is equal to zero. + + int fq_is_one(const fq_t op, const fq_ctx_t ctx) + # Returns whether ``op`` is equal to one. + + int fq_equal(const fq_t op1, const fq_t op2, const fq_ctx_t ctx) + # Returns whether ``op1`` and ``op2`` are equal. + + int fq_is_invertible(const fq_t op, const fq_ctx_t ctx) + # Returns whether ``op`` is an invertible element. + + int fq_is_invertible_f(fq_t f, const fq_t op, const fq_ctx_t ctx) + # Returns whether ``op`` is an invertible element. If it is not, + # then ``f`` is set of a factor of the modulus. + + void _fq_trace(fmpz_t rop, const fmpz *op, long len, const fq_ctx_t ctx) + # Sets ``rop`` to the trace of the non-zero element ``(op, len)`` + # in `\mathbf{F}_{q}`. void fq_trace(fmpz_t rop, const fq_t op, const fq_ctx_t ctx) - void fq_frobenius(fq_t rop, const fq_t op, slong e, const fq_ctx_t ctx) + # Sets ``rop`` to the trace of ``op``. + # For an element `a \in \mathbf{F}_q`, multiplication by `a` defines + # a `\mathbf{F}_p`-linear map on `\mathbf{F}_q`. We define the + # trace of `a` as the trace of this map. Equivalently, if `\Sigma` + # generates `\operatorname{Gal}(\mathbf{F}_q / \mathbf{F}_p)` then the trace of + # `a` is equal to `\sum_{i=0}^{d-1} \Sigma^i (a)`, where `d = + # \log_{p} q`. + + void _fq_norm(fmpz_t rop, const fmpz *op, long len, const fq_ctx_t ctx) + # Sets ``rop`` to the norm of the non-zero element ``(op, len)`` + # in `\mathbf{F}_{q}`. + void fq_norm(fmpz_t rop, const fq_t op, const fq_ctx_t ctx) + # Computes the norm of ``op``. + # For an element `a \in \mathbf{F}_q`, multiplication by `a` defines + # a `\mathbf{F}_p`-linear map on `\mathbf{F}_q`. We define the norm + # of `a` as the determinant of this map. Equivalently, if `\Sigma` generates + # `\operatorname{Gal}(\mathbf{F}_q / \mathbf{F}_p)` then the trace of `a` is equal to + # `\prod_{i=0}^{d-1} \Sigma^i (a)`, where + # `d = \text{dim}_{\mathbf{F}_p}(\mathbf{F}_q)`. + # Algorithm selection is automatic depending on the input. + + void _fq_frobenius(fmpz *rop, const fmpz *op, long len, long e, const fq_ctx_t ctx) + # Sets ``(rop, 2d-1)`` to the image of ``(op, len)`` under the + # Frobenius operator raised to the e-th power, assuming that neither + # ``op`` nor ``e`` are zero. + + void fq_frobenius(fq_t rop, const fq_t op, long e, const fq_ctx_t ctx) + # Evaluates the homomorphism `\Sigma^e` at ``op``. + # Recall that `\mathbf{F}_q / \mathbf{F}_p` is Galois with Galois group + # `\langle \sigma \rangle`, which is also isomorphic to + # `\mathbf{Z}/d\mathbf{Z}`, where + # `\sigma \in \operatorname{Gal}(\mathbf{F}_q/\mathbf{F}_p)` is the Frobenius element + # `\sigma \colon x \mapsto x^p`. + + int fq_multiplicative_order(fmpz * ord, const fq_t op, const fq_ctx_t ctx) + # Computes the order of ``op`` as an element of the + # multiplicative group of ``ctx``. + # Returns 0 if ``op`` is 0, otherwise it returns 1 if ``op`` + # is a generator of the multiplicative group, and -1 if it is not. + # This function can also be used to check primitivity of a generator of + # a finite field whose defining polynomial is not primitive. + + int fq_is_primitive(const fq_t op, const fq_ctx_t ctx) + # Returns whether ``op`` is primitive, i.e., whether it is a + # generator of the multiplicative group of ``ctx``. + + void fq_bit_pack(fmpz_t f, const fq_t op, flint_bitcnt_t bit_size, const fq_ctx_t ctx) + # Packs ``op`` into bitfields of size ``bit_size``, writing the + # result to ``f``. + + void fq_bit_unpack(fq_t rop, const fmpz_t f, flint_bitcnt_t bit_size, const fq_ctx_t ctx) + # Unpacks into ``rop`` the element with coefficients packed into + # fields of size ``bit_size`` as represented by the integer + # ``f``. diff --git a/src/sage/libs/flint/fq_nmod.pxd b/src/sage/libs/flint/fq_nmod.pxd index 159aa4e4077..dda3ec58de7 100644 --- a/src/sage/libs/flint/fq_nmod.pxd +++ b/src/sage/libs/flint/fq_nmod.pxd @@ -1,75 +1,357 @@ # distutils: libraries = flint # distutils: depends = flint/fq_nmod.h -from sage.libs.flint.types cimport fq_nmod_ctx_t, fq_nmod_t, fmpz_t, nmod_poly_t, slong, ulong +################################################################################ +# This file is auto-generated. Do not modify by hand +################################################################################ + +from libc.stdio cimport FILE +from sage.libs.gmp.types cimport * +from sage.libs.mpfr.types cimport * +from sage.libs.flint.types cimport * -# flint/fq_nmod.h cdef extern from "flint_wrap.h": - void fq_nmod_ctx_init(fq_nmod_ctx_t ctx, const fmpz_t p, slong d, const char *var) - void fq_nmod_ctx_init_conway(fq_nmod_ctx_t ctx, const fmpz_t p, slong d, const char *var) - void fq_nmod_ctx_init_modulus(fq_nmod_ctx_t ctx, - nmod_poly_t modulus, - const char *var) + + void fq_nmod_ctx_init(fq_nmod_ctx_t ctx, const fmpz_t p, long d, const char *var) + # Initialises the context for prime `p` and extension degree `d`, + # with name ``var`` for the generator. By default, it will try + # use a Conway polynomial; if one is not available, a random + # irreducible polynomial will be used. + # Assumes that `p` is a prime. + # Assumes that the string ``var`` is a null-terminated string + # of length at least one. + + int _fq_nmod_ctx_init_conway(fq_nmod_ctx_t ctx, const fmpz_t p, long d, const char *var) + # Attempts to initialise the context for prime `p` and extension + # degree `d`, with name ``var`` for the generator using a Conway + # polynomial for the modulus. + # Returns `1` if the Conway polynomial is in the database for the + # given size and the initialization is successful; otherwise, + # returns `0`. + # Assumes that `p` is a prime. + # Assumes that the string ``var`` is a null-terminated string + # of length at least one. + + void fq_nmod_ctx_init_conway(fq_nmod_ctx_t ctx, const fmpz_t p, long d, const char *var) + # Initialises the context for prime `p` and extension degree `d`, + # with name ``var`` for the generator using a Conway polynomial + # for the modulus. + # Assumes that `p` is a prime. + # Assumes that the string ``var`` is a null-terminated string + # of length at least one. + + void fq_nmod_ctx_init_modulus(fq_nmod_ctx_t ctx, const nmod_poly_t modulus, const char *var) + # Initialises the context for given ``modulus`` with name + # ``var`` for the generator. + # Assumes that ``modulus`` is an irreducible polynomial over + # `\mathbf{F}_{p}`. + # Assumes that the string ``var`` is a null-terminated string + # of length at least one. void fq_nmod_ctx_clear(fq_nmod_ctx_t ctx) + # Clears all memory that has been allocated as part of the context. + + const nmod_poly_struct* fq_nmod_ctx_modulus(const fq_nmod_ctx_t ctx) + # Returns a pointer to the modulus in the context. + + long fq_nmod_ctx_degree(const fq_nmod_ctx_t ctx) + # Returns the degree of the field extension + # `[\mathbf{F}_{q} : \mathbf{F}_{p}]`, which + # is equal to `\log_{p} q`. + + fmpz * fq_nmod_ctx_prime(const fq_nmod_ctx_t ctx) + # Returns a pointer to the prime `p` in the context. - fmpz_t fq_nmod_ctx_prime(fq_nmod_ctx_t ctx) - slong fq_nmod_ctx_degree(const fq_nmod_ctx_t ctx) void fq_nmod_ctx_order(fmpz_t f, const fq_nmod_ctx_t ctx) + # Sets `f` to be the size of the finite field. + + int fq_nmod_ctx_fprint(FILE * file, const fq_nmod_ctx_t ctx) + # Prints the context information to ``file``. Returns 1 for a + # success and a negative number for an error. void fq_nmod_ctx_print(const fq_nmod_ctx_t ctx) + # Prints the context information to ``stdout``. + + void fq_nmod_ctx_randtest(fq_nmod_ctx_t ctx, flint_rand_t state) + # Initializes ``ctx`` to a random finite field. Assumes that + # ``fq_nmod_ctx_init`` has not been called on ``ctx`` already. - # Memory managment + void fq_nmod_ctx_randtest_reducible(fq_nmod_ctx_t ctx, flint_rand_t state) + # Initializes ``ctx`` to a random extension of a word-sized prime + # field. The modulus may or may not be irreducible. Assumes that + # ``fq_nmod_ctx_init`` has not been called on ``ctx`` already. void fq_nmod_init(fq_nmod_t rop, const fq_nmod_ctx_t ctx) + # Initialises the element ``rop``, setting its value to `0`. Currently, the behaviour is identical to ``fq_nmod_init2``, as it also ensures ``rop`` has enough space for it to be an element of ``ctx``, this may change in the future. + + void fq_nmod_init2(fq_nmod_t rop, const fq_nmod_ctx_t ctx) + # Initialises ``rop`` with at least enough space for it to be an element + # of ``ctx`` and sets it to `0`. + void fq_nmod_clear(fq_nmod_t rop, const fq_nmod_ctx_t ctx) - void fq_nmod_reduce(fq_nmod_t rop, const fq_nmod_ctx_t ctx) + # Clears the element ``rop``. + + void _fq_nmod_sparse_reduce(mp_limb_t * R, long lenR, const fq_nmod_ctx_t ctx) + # Reduces ``(R, lenR)`` modulo the polynomial `f` given by the + # modulus of ``ctx``. + + void _fq_nmod_dense_reduce(mp_limb_t * R, long lenR, const fq_nmod_ctx_t ctx) + # Reduces ``(R, lenR)`` modulo the polynomial `f` given by the + # modulus of ``ctx`` using Newton division. - # Basic arithmetic + void _fq_nmod_reduce(mp_limb_t * r, long lenR, const fq_nmod_ctx_t ctx) + # Reduces ``(R, lenR)`` modulo the polynomial `f` given by the + # modulus of ``ctx``. Does either sparse or dense reduction + # based on ``ctx->sparse_modulus``. + + void fq_nmod_reduce(fq_nmod_t rop, const fq_nmod_ctx_t ctx) + # Reduces the polynomial ``rop`` as an element of + # `\mathbf{F}_p[X] / (f(X))`. void fq_nmod_add(fq_nmod_t rop, const fq_nmod_t op1, const fq_nmod_t op2, const fq_nmod_ctx_t ctx) + # Sets ``rop`` to the sum of ``op1`` and ``op2``. + void fq_nmod_sub(fq_nmod_t rop, const fq_nmod_t op1, const fq_nmod_t op2, const fq_nmod_ctx_t ctx) + # Sets ``rop`` to the difference of ``op1`` and ``op2``. + void fq_nmod_sub_one(fq_nmod_t rop, const fq_nmod_t op1, const fq_nmod_ctx_t ctx) - void fq_nmod_neg(fq_nmod_t rop, const fq_nmod_t op1, const fq_nmod_ctx_t ctx) + # Sets ``rop`` to the difference of ``op1`` and `1`. + + void fq_nmod_neg(fq_nmod_t rop, const fq_nmod_t op, const fq_nmod_ctx_t ctx) + # Sets ``rop`` to the negative of ``op``. + void fq_nmod_mul(fq_nmod_t rop, const fq_nmod_t op1, const fq_nmod_t op2, const fq_nmod_ctx_t ctx) + # Sets ``rop`` to the product of ``op1`` and ``op2``, + # reducing the output in the given context. + void fq_nmod_mul_fmpz(fq_nmod_t rop, const fq_nmod_t op, const fmpz_t x, const fq_nmod_ctx_t ctx) - void fq_nmod_mul_si(fq_nmod_t rop, const fq_nmod_t op, slong x, const fq_nmod_ctx_t ctx) - void fq_nmod_mul_ui(fq_nmod_t rop, const fq_nmod_t op, ulong x, const fq_nmod_ctx_t ctx) + # Sets ``rop`` to the product of ``op`` and `x`, + # reducing the output in the given context. + + void fq_nmod_mul_si(fq_nmod_t rop, const fq_nmod_t op, long x, const fq_nmod_ctx_t ctx) + # Sets ``rop`` to the product of ``op`` and `x`, + # reducing the output in the given context. + + void fq_nmod_mul_ui(fq_nmod_t rop, const fq_nmod_t op, unsigned long x, const fq_nmod_ctx_t ctx) + # Sets ``rop`` to the product of ``op`` and `x`, + # reducing the output in the given context. + void fq_nmod_sqr(fq_nmod_t rop, const fq_nmod_t op, const fq_nmod_ctx_t ctx) - void fq_nmod_inv(fq_nmod_t rop, const fq_nmod_t op1, const fq_nmod_ctx_t ctx) - void fq_nmod_gcdinv(fq_nmod_t rop, fq_nmod_t inv, const fq_nmod_t op, const fq_nmod_ctx_t ctx) - void fq_nmod_pow(fq_nmod_t rop, const fq_nmod_t op1, const fmpz_t e, const fq_nmod_ctx_t ctx) - void fq_nmod_pow_ui(fq_nmod_t rop, const fq_nmod_t op, const ulong e, const fq_nmod_ctx_t ctx) + # Sets ``rop`` to the square of ``op``, + # reducing the output in the given context. + + void _fq_nmod_inv(mp_ptr * rop, mp_srcptr * op, long len, const fq_nmod_ctx_t ctx) + # Sets ``(rop, d)`` to the inverse of the non-zero element + # ``(op, len)``. + + void fq_nmod_inv(fq_nmod_t rop, const fq_nmod_t op, const fq_nmod_ctx_t ctx) + # Sets ``rop`` to the inverse of the non-zero element ``op``. + + void fq_nmod_gcdinv(fq_nmod_t f, fq_nmod_t inv, const fq_nmod_t op, const fq_nmod_ctx_t ctx) + # Sets ``inv`` to be the inverse of ``op`` modulo the modulus + # of ``ctx``. If ``op`` is not invertible, then ``f`` is + # set to a factor of the modulus; otherwise, it is set to one. + + void _fq_nmod_pow(mp_limb_t * rop, const mp_limb_t * op, long len, const fmpz_t e, const fq_nmod_ctx_t ctx) + # Sets ``(rop, 2*d-1)`` to ``(op,len)`` raised to the power `e`, + # reduced modulo `f(X)`, the modulus of ``ctx``. + # Assumes that `e \geq 0` and that ``len`` is positive and at most `d`. + # Although we require that ``rop`` provides space for + # `2d - 1` coefficients, the output will be reduced modulo + # `f(X)`, which is a polynomial of degree `d`. + # Does not support aliasing. + + void fq_nmod_pow(fq_nmod_t rop, const fq_nmod_t op, const fmpz_t e, const fq_nmod_ctx_t ctx) + # Sets ``rop`` to ``op`` raised to the power `e`. + # Currently assumes that `e \geq 0`. + # Note that for any input ``op``, ``rop`` is set to `1` + # whenever `e = 0`. + + void fq_nmod_pow_ui(fq_nmod_t rop, const fq_nmod_t op, const unsigned long e, const fq_nmod_ctx_t ctx) + # Sets ``rop`` to ``op`` raised to the power `e`. + # Currently assumes that `e \geq 0`. + # Note that for any input ``op``, ``rop`` is set to `1` + # whenever `e = 0`. + + int fq_nmod_sqrt(fq_nmod_t rop, const fq_nmod_t op1, const fq_nmod_ctx_t ctx) + # Sets ``rop`` to the square root of ``op1`` if it is a square, and return + # `1`, otherwise return `0`. + void fq_nmod_pth_root(fq_nmod_t rop, const fq_nmod_t op1, const fq_nmod_ctx_t ctx) + # Sets ``rop`` to a `p^{\textrm{th}}` root of ``op1``. Currently, + # this computes the root by raising ``op1`` to `p^{d-1}` where + # `d` is the degree of the extension. - # Comparison + int fq_nmod_is_square(const fq_nmod_t op, const fq_nmod_ctx_t ctx) + # Return ``1`` if ``op`` is a square. - int fq_nmod_equal(const fq_nmod_t op1, const fq_nmod_t op2, const fq_nmod_ctx_t ctx) - int fq_nmod_is_zero(const fq_nmod_t op, const fq_nmod_ctx_t ctx) - int fq_nmod_is_one(const fq_nmod_t op, const fq_nmod_ctx_t ctx) + int fq_nmod_fprint_pretty(FILE * file, const fq_nmod_t op, const fq_nmod_ctx_t ctx) + # Prints a pretty representation of ``op`` to ``file``. + # In case of success, returns a positive value. In case of failure, + # returns a non-positive value. + + void fq_nmod_print_pretty(const fq_nmod_t op, const fq_nmod_ctx_t ctx) + # Prints a pretty representation of ``op`` to ``stdout``. + # In case of success, returns a positive value. In case of failure, + # returns a non-positive value. - # Assignments and conversions + int fq_nmod_fprint(FILE * file, const fq_nmod_t op, const fq_nmod_ctx_t ctx) + # Prints a representation of ``op`` to ``file``. + # For further details on the representation used, see + # ``nmod_poly_fprint()``. + + void fq_nmod_print(const fq_nmod_t op, const fq_nmod_ctx_t ctx) + # Prints a representation of ``op`` to ``stdout``. + # For further details on the representation used, see + # ``nmod_poly_print()``. + + char * fq_nmod_get_str(const fq_nmod_t op, const fq_nmod_ctx_t ctx) + # Returns the plain FLINT string representation of the element + # ``op``. + + char * fq_nmod_get_str_pretty(const fq_nmod_t op, const fq_nmod_ctx_t ctx) + # Returns a pretty representation of the element ``op`` using the + # null-terminated string ``x`` as the variable name. + + void fq_nmod_randtest(fq_nmod_t rop, flint_rand_t state, const fq_nmod_ctx_t ctx) + # Generates a random element of `\mathbf{F}_q`. + + void fq_nmod_randtest_not_zero(fq_nmod_t rop, flint_rand_t state, const fq_nmod_ctx_t ctx) + # Generates a random non-zero element of `\mathbf{F}_q`. + + void fq_nmod_randtest_dense(fq_nmod_t rop, flint_rand_t state, const fq_nmod_ctx_t ctx) + # Generates a random element of `\mathbf{F}_q` which has an + # underlying polynomial with dense coefficients. + + void fq_nmod_rand(fq_nmod_t rop, flint_rand_t state, const fq_nmod_ctx_t ctx) + # Generates a high quality random element of `\mathbf{F}_q`. + + void fq_nmod_rand_not_zero(fq_nmod_t rop, flint_rand_t state, const fq_nmod_ctx_t ctx) + # Generates a high quality non-zero random element of `\mathbf{F}_q`. void fq_nmod_set(fq_nmod_t rop, const fq_nmod_t op, const fq_nmod_ctx_t ctx) + # Sets ``rop`` to ``op``. + + void fq_nmod_set_si(fq_nmod_t rop, const long x, const fq_nmod_ctx_t ctx) + # Sets ``rop`` to ``x``, considered as an element of + # `\mathbf{F}_p`. + + void fq_nmod_set_ui(fq_nmod_t rop, const unsigned long x, const fq_nmod_ctx_t ctx) + # Sets ``rop`` to ``x``, considered as an element of + # `\mathbf{F}_p`. + void fq_nmod_set_fmpz(fq_nmod_t rop, const fmpz_t x, const fq_nmod_ctx_t ctx) - void fq_nmod_set_ui(fq_nmod_t rop, const ulong x, const fq_nmod_ctx_t ctx) - void fq_nmod_set_si(fq_nmod_t rop, const slong x, const fq_nmod_ctx_t ctx) - void fq_nmod_set_coeff_fmpz(fq_nmod_t rop, const fmpz_t x, const ulong n, const fq_nmod_ctx_t ctx) + # Sets ``rop`` to ``x``, considered as an element of + # `\mathbf{F}_p`. + void fq_nmod_swap(fq_nmod_t op1, fq_nmod_t op2, const fq_nmod_ctx_t ctx) + # Swaps the two elements ``op1`` and ``op2``. + void fq_nmod_zero(fq_nmod_t rop, const fq_nmod_ctx_t ctx) + # Sets ``rop`` to zero. + void fq_nmod_one(fq_nmod_t rop, const fq_nmod_ctx_t ctx) + # Sets ``rop`` to one, reduced in the given context. + void fq_nmod_gen(fq_nmod_t rop, const fq_nmod_ctx_t ctx) + # Sets ``rop`` to a generator for the finite field. + # There is no guarantee this is a multiplicative generator of + # the finite field. - # Output + int fq_nmod_get_fmpz(fmpz_t rop, const fq_nmod_t op, const fq_nmod_ctx_t ctx) + # If ``op`` has a lift to the integers, return `1` and set ``rop`` to the lift in `[0,p)`. + # Otherwise, return `0` and leave `rop` undefined. - void fq_nmod_print(const fq_nmod_t op, const fq_nmod_ctx_t ctx) - int fq_nmod_print_pretty(const fq_nmod_t op, const fq_nmod_ctx_t ctx) + void fq_nmod_get_nmod_poly(nmod_poly_t a, const fq_nmod_t b, const fq_nmod_ctx_t ctx) + # Set ``a`` to a representative of ``b`` in ``ctx``. + # The representatives are taken in `(\mathbb{Z}/p\mathbb{Z})[x]/h(x)` where `h(x)` is the defining polynomial in ``ctx``. - char * fq_nmod_get_str(const fq_nmod_t op, const fq_nmod_ctx_t ctx) - char * fq_nmod_get_str_pretty(const fq_nmod_t op, const fq_nmod_ctx_t ctx) + void fq_nmod_set_nmod_poly(fq_nmod_t a, const nmod_poly_t b, const fq_nmod_ctx_t ctx) + # Set ``a`` to the element in ``ctx`` with representative ``b``. + # The representatives are taken in `(\mathbb{Z}/p\mathbb{Z})[x]/h(x)` where `h(x)` is the defining polynomial in ``ctx``. - # Special functions + void fq_nmod_get_nmod_mat(nmod_mat_t col, const fq_nmod_t a, const fq_nmod_ctx_t ctx) + # Convert ``a`` to a column vector of length ``degree(ctx)``. + + void fq_nmod_set_nmod_mat(fq_nmod_t a, const nmod_mat_t col, const fq_nmod_ctx_t ctx) + # Convert a column vector ``col`` of length ``degree(ctx)`` to an element of ``ctx``. + + int fq_nmod_is_zero(const fq_nmod_t op, const fq_nmod_ctx_t ctx) + # Returns whether ``op`` is equal to zero. + + int fq_nmod_is_one(const fq_nmod_t op, const fq_nmod_ctx_t ctx) + # Returns whether ``op`` is equal to one. + + int fq_nmod_equal(const fq_nmod_t op1, const fq_nmod_t op2, const fq_nmod_ctx_t ctx) + # Returns whether ``op1`` and ``op2`` are equal. + + int fq_nmod_is_invertible(const fq_nmod_t op, const fq_nmod_ctx_t ctx) + # Returns whether ``op`` is an invertible element. + + int fq_nmod_is_invertible_f(fq_nmod_t f, const fq_nmod_t op, const fq_nmod_ctx_t ctx) + # Returns whether ``op`` is an invertible element. If it is not, + # then ``f`` is set to a factor of the modulus. + + int fq_nmod_cmp(const fq_nmod_t a, const fq_nmod_t b, const fq_nmod_ctx_t ctx) + # Return ``1`` (resp. ``-1``, or ``0``) if ``a`` is after (resp. before, same as) ``b`` in some arbitrary but fixed total ordering of the elements. + + void _fq_nmod_trace(fmpz_t rop, const mp_limb_t * op, long len, const fq_nmod_ctx_t ctx) + # Sets ``rop`` to the trace of the non-zero element ``(op, len)`` + # in `\mathbf{F}_{q}`. void fq_nmod_trace(fmpz_t rop, const fq_nmod_t op, const fq_nmod_ctx_t ctx) - void fq_nmod_frobenius(fq_nmod_t rop, const fq_nmod_t op, slong e, const fq_nmod_ctx_t ctx) + # Sets ``rop`` to the trace of ``op``. + # For an element `a \in \mathbf{F}_q`, multiplication by `a` defines + # a `\mathbf{F}_p`-linear map on `\mathbf{F}_q`. We define the + # trace of `a` as the trace of this map. Equivalently, if `\Sigma` + # generates `\operatorname{Gal}(\mathbf{F}_q / \mathbf{F}_p)` then the trace of + # `a` is equal to `\sum_{i=0}^{d-1} \Sigma^i (a)`, where `d = + # \log_{p} q`. + + void _fq_nmod_norm(fmpz_t rop, const mp_limb_t * op, long len, const fq_nmod_ctx_t ctx) + # Sets ``rop`` to the norm of the non-zero element ``(op, len)`` + # in `\mathbf{F}_{q}`. + void fq_nmod_norm(fmpz_t rop, const fq_nmod_t op, const fq_nmod_ctx_t ctx) + # Computes the norm of ``op``. + # For an element `a \in \mathbf{F}_q`, multiplication by `a` defines + # a `\mathbf{F}_p`-linear map on `\mathbf{F}_q`. We define the norm + # of `a` as the determinant of this map. Equivalently, if `\Sigma` generates + # `\operatorname{Gal}(\mathbf{F}_q / \mathbf{F}_p)` then the trace of `a` is equal to + # `\prod_{i=0}^{d-1} \Sigma^i (a)`, where + # `d = \text{dim}_{\mathbf{F}_p}(\mathbf{F}_q)`. + # Algorithm selection is automatic depending on the input. + + void _fq_nmod_frobenius(mp_limb_t * rop, const mp_limb_t * op, long len, long e, const fq_nmod_ctx_t ctx) + # Sets ``(rop, 2d-1)`` to the image of ``(op, len)`` under the + # Frobenius operator raised to the e-th power, assuming that neither + # ``op`` nor ``e`` are zero. + + void fq_nmod_frobenius(fq_nmod_t rop, const fq_nmod_t op, long e, const fq_nmod_ctx_t ctx) + # Evaluates the homomorphism `\Sigma^e` at ``op``. + # Recall that `\mathbf{F}_q / \mathbf{F}_p` is Galois with Galois group + # `\langle \sigma \rangle`, which is also isomorphic to + # `\mathbf{Z}/d\mathbf{Z}`, where + # `\sigma \in \operatorname{Gal}(\mathbf{F}_q/\mathbf{F}_p)` is the Frobenius element + # `\sigma \colon x \mapsto x^p`. + + int fq_nmod_multiplicative_order(fmpz * ord, const fq_nmod_t op, const fq_nmod_ctx_t ctx) + # Computes the order of ``op`` as an element of the + # multiplicative group of ``ctx``. + # Returns 0 if ``op`` is 0, otherwise it returns 1 if ``op`` + # is a generator of the multiplicative group, and -1 if it is not. + # This function can also be used to check primitivity of a generator of + # a finite field whose defining polynomial is not primitive. + + int fq_nmod_is_primitive(const fq_nmod_t op, const fq_nmod_ctx_t ctx) + # Returns whether ``op`` is primitive, i.e., whether it is a + # generator of the multiplicative group of ``ctx``. + + void fq_nmod_bit_pack(fmpz_t f, const fq_nmod_t op, flint_bitcnt_t bit_size, const fq_nmod_ctx_t ctx) + # Packs ``op`` into bitfields of size ``bit_size``, writing the + # result to ``f``. + + void fq_nmod_bit_unpack(fq_nmod_t rop, const fmpz_t f, flint_bitcnt_t bit_size, const fq_nmod_ctx_t ctx) + # Unpacks into ``rop`` the element with coefficients packed into + # fields of size ``bit_size`` as represented by the integer + # ``f``. diff --git a/src/sage/libs/flint/nmod_poly.pxd b/src/sage/libs/flint/nmod_poly.pxd index d11ef304ca2..727982a80a7 100644 --- a/src/sage/libs/flint/nmod_poly.pxd +++ b/src/sage/libs/flint/nmod_poly.pxd @@ -1,148 +1,1821 @@ # distutils: libraries = flint # distutils: depends = flint/nmod_poly.h +################################################################################ +# This file is auto-generated. Do not modify by hand +################################################################################ + +from libc.stdio cimport FILE from sage.libs.gmp.types cimport * +from sage.libs.mpfr.types cimport * from sage.libs.flint.types cimport * -# flint/nmod_poly.h cdef extern from "flint_wrap.h": - # Memory management - cdef void nmod_poly_init(nmod_poly_t poly, mp_limb_t n) - cdef void nmod_poly_init_preinv(nmod_poly_t poly, mp_limb_t n, mp_limb_t ninv) - cdef void nmod_poly_init2(nmod_poly_t poly, mp_limb_t n, long alloc) - cdef void nmod_poly_init2_preinv(nmod_poly_t poly, mp_limb_t n, mp_limb_t ninv, long alloc) - - cdef void nmod_poly_clear(nmod_poly_t poly) - - cdef void nmod_poly_realloc(nmod_poly_t poly, long alloc) - - cdef void nmod_poly_fit_length(nmod_poly_t poly, long alloc) - cdef void _nmod_poly_normalise(nmod_poly_t poly) - - # Getting and setting coefficients - cdef unsigned long nmod_poly_get_coeff_ui(nmod_poly_t poly, unsigned long j) - cdef void nmod_poly_set_coeff_ui(nmod_poly_t poly, unsigned long j, unsigned long c) - - # Input and output - cdef char * nmod_poly_get_str(nmod_poly_t poly) - cdef int nmod_poly_set_str(char * s, nmod_poly_t poly) - cdef int nmod_poly_print(nmod_poly_t a) - cdef int nmod_poly_fread(FILE * f, nmod_poly_t poly) - cdef int nmod_poly_fprint(FILE * f, nmod_poly_t poly) - cdef int nmod_poly_read(nmod_poly_t poly) - - # Polynomial parameters - cdef long nmod_poly_length(nmod_poly_t poly) - cdef long nmod_poly_degree(nmod_poly_t poly) - cdef mp_limb_t nmod_poly_modulus(nmod_poly_t poly) - cdef mp_bitcnt_t nmod_poly_max_bits(nmod_poly_t poly) - - # Assignment and basic manipulation - cdef void nmod_poly_set(nmod_poly_t a, nmod_poly_t b) - cdef void nmod_poly_swap(nmod_poly_t poly1, nmod_poly_t poly2) - cdef void nmod_poly_zero(nmod_poly_t res) - cdef void nmod_poly_one(nmod_poly_t res) - cdef void nmod_poly_truncate(nmod_poly_t poly, long len) - cdef void nmod_poly_reverse(nmod_poly_t output, nmod_poly_t input, long m) - cdef void nmod_poly_revert_series(nmod_poly_t output, nmod_poly_t intput, long m) - - cdef int nmod_poly_equal(nmod_poly_t a, nmod_poly_t b) - - # Powering - cdef void nmod_poly_pow(nmod_poly_t res, nmod_poly_t poly, unsigned long e) - cdef void nmod_poly_pow_trunc(nmod_poly_t res, nmod_poly_t poly, unsigned long e, long trunc) - cdef void nmod_poly_powmod_ui_binexp(nmod_poly_t res, const nmod_poly_t poly, ulong e, const nmod_poly_t f) - - # Inflation and deflation - cdef unsigned long nmod_poly_deflation(nmod_poly_t input) - cdef void nmod_poly_deflate(nmod_poly_t result, nmod_poly_t input, unsigned long deflation) - cdef void nmod_poly_inflate(nmod_poly_t result, nmod_poly_t input, unsigned long inflation) - - # Comparison - cdef int nmod_poly_is_zero(nmod_poly_t poly) - cdef int nmod_poly_is_one(nmod_poly_t poly) - - # Addition and subtraction - cdef void nmod_poly_add(nmod_poly_t res, nmod_poly_t poly1, nmod_poly_t poly2) - cdef void nmod_poly_sub(nmod_poly_t res, nmod_poly_t poly1, nmod_poly_t poly2) - cdef void nmod_poly_neg(nmod_poly_t res, nmod_poly_t poly1) - - # Shifting - cdef void nmod_poly_shift_left(nmod_poly_t res, nmod_poly_t poly, long k) - cdef void nmod_poly_shift_right(nmod_poly_t res, nmod_poly_t poly, long k) - - # Multiplication - cdef void nmod_poly_mul(nmod_poly_t res, nmod_poly_t poly1, nmod_poly_t poly2) - cdef void nmod_poly_mullow(nmod_poly_t res, nmod_poly_t poly1, nmod_poly_t poly2, long trunc) - cdef void nmod_poly_mulhigh(nmod_poly_t res, nmod_poly_t poly1, nmod_poly_t poly2, long n) - cdef void nmod_poly_mulmod(nmod_poly_t res, nmod_poly_t poly1, nmod_poly_t poly2, nmod_poly_t f) - - # Square roots - cdef void nmod_poly_invsqrt_series(nmod_poly_t g, nmod_poly_t h, long n) - cdef void nmod_poly_sqrt_series(nmod_poly_t g, nmod_poly_t h, long n) - int nmod_poly_sqrt(nmod_poly_t b, nmod_poly_t a) - - # Scalar multiplication and division - cdef void nmod_poly_scalar_mul_nmod(nmod_poly_t res, nmod_poly_t poly1, mp_limb_t c) - cdef void nmod_poly_make_monic(nmod_poly_t output, nmod_poly_t input) - - # Division - cdef void nmod_poly_divrem(nmod_poly_t Q, nmod_poly_t R, nmod_poly_t A, nmod_poly_t B) - cdef void nmod_poly_div(nmod_poly_t Q, nmod_poly_t A, nmod_poly_t B) - cdef void nmod_poly_inv_series(nmod_poly_t Qinv, nmod_poly_t Q, long n) - cdef void nmod_poly_div_series(nmod_poly_t Q, nmod_poly_t A, nmod_poly_t B, long n) - - # GCD - cdef void nmod_poly_gcd(nmod_poly_t G, nmod_poly_t A, nmod_poly_t B) - cdef void nmod_poly_xgcd(nmod_poly_t G, nmod_poly_t S, nmod_poly_t T, nmod_poly_t A, nmod_poly_t B) - mp_limb_t nmod_poly_resultant(nmod_poly_t f, nmod_poly_t g) - - - # Evaluation - cdef mp_limb_t nmod_poly_evaluate_nmod(nmod_poly_t poly, mp_limb_t c) - cdef void nmod_poly_evaluate_nmod_vec(mp_ptr ys, nmod_poly_t poly, mp_srcptr xs, long n) - - # Interpolation - cdef void nmod_poly_interpolate_nmod_vec(nmod_poly_t poly, mp_srcptr xs, mp_srcptr ys, long n) - - # Composition - cdef void nmod_poly_compose(nmod_poly_t res, nmod_poly_t poly1, nmod_poly_t poly2) - - # Power series composition and reversion - cdef void nmod_poly_compose_series(nmod_poly_t res, nmod_poly_t poly1, nmod_poly_t poly2, long n) - cdef void nmod_poly_reverse_series(nmod_poly_t Qinv, nmod_poly_t Q, long n) - - # Factoring - cdef void nmod_poly_factor_clear(nmod_poly_factor_t fac) - cdef void nmod_poly_factor_init(nmod_poly_factor_t fac) - cdef void nmod_poly_factor_insert(nmod_poly_factor_t fac, nmod_poly_t poly, unsigned long exp) - cdef void nmod_poly_factor_print(nmod_poly_factor_t fac) - cdef void nmod_poly_factor_concat(nmod_poly_factor_t res, nmod_poly_factor_t fac) - cdef void nmod_poly_factor_pow(nmod_poly_factor_t fac, unsigned long exp) - cdef unsigned long nmod_poly_remove(nmod_poly_t f, nmod_poly_t p) - cdef int nmod_poly_is_irreducible(nmod_poly_t f) - cdef int nmod_poly_is_squarefree(nmod_poly_t f) - cdef void nmod_poly_factor_cantor_zassenhaus(nmod_poly_factor_t res, nmod_poly_t f) - cdef void nmod_poly_factor_berlekamp(nmod_poly_factor_t factors, nmod_poly_t f) - cdef void nmod_poly_factor_squarefree(nmod_poly_factor_t res, nmod_poly_t f) - cdef mp_limb_t nmod_poly_factor_with_berlekamp(nmod_poly_factor_t result, nmod_poly_t input) - cdef mp_limb_t nmod_poly_factor_with_cantor_zassenhaus(nmod_poly_factor_t result, nmod_poly_t input) - cdef mp_limb_t nmod_poly_factor(nmod_poly_factor_t result, nmod_poly_t input) - - # Derivative - cdef void nmod_poly_derivative(nmod_poly_t x_prime, nmod_poly_t x) - cdef void nmod_poly_integral(nmod_poly_t x_int, nmod_poly_t x) - - # Transcendental functions - cdef void nmod_poly_atan_series(nmod_poly_t g, nmod_poly_t h, long n) - cdef void nmod_poly_tan_series(nmod_poly_t g, nmod_poly_t h, long n) - cdef void nmod_poly_asin_series(nmod_poly_t g, nmod_poly_t h, long n) - cdef void nmod_poly_sin_series(nmod_poly_t g, nmod_poly_t h, long n) - cdef void nmod_poly_cos_series(nmod_poly_t g, nmod_poly_t h, long n) - cdef void nmod_poly_asinh_series(nmod_poly_t g, nmod_poly_t h, long n) - cdef void nmod_poly_atanh_series(nmod_poly_t g, nmod_poly_t h, long n) - cdef void nmod_poly_sinh_series(nmod_poly_t g, nmod_poly_t h, long n) - cdef void nmod_poly_cosh_series(nmod_poly_t g, nmod_poly_t h, long n) - cdef void nmod_poly_tanh_series(nmod_poly_t g, nmod_poly_t h, long n) - cdef void nmod_poly_log_series(nmod_poly_t res, nmod_poly_t f, long n) - cdef void nmod_poly_exp_series(nmod_poly_t f, nmod_poly_t h, long) + + int signed_mpn_sub_n(mp_ptr res, mp_srcptr op1, mp_srcptr op2, long n) + # If ``op1 >= op2`` return 0 and set ``res`` to ``op1 - op2`` + # else return 1 and set ``res`` to ``op2 - op1``. + + void nmod_poly_init(nmod_poly_t poly, mp_limb_t n) + # Initialises ``poly``. It will have coefficients modulo~`n`. + + void nmod_poly_init_preinv(nmod_poly_t poly, mp_limb_t n, mp_limb_t ninv) + # Initialises ``poly``. It will have coefficients modulo~`n`. + # The caller supplies a precomputed inverse limb generated by + # :func:`n_preinvert_limb`. + + void nmod_poly_init_mod(nmod_poly_t poly, const nmod_t mod) + # Initialises ``poly`` using an already initialised modulus ``mod``. + + void nmod_poly_init2(nmod_poly_t poly, mp_limb_t n, long alloc) + # Initialises ``poly``. It will have coefficients modulo~`n`. + # Up to ``alloc`` coefficients may be stored in ``poly``. + + void nmod_poly_init2_preinv(nmod_poly_t poly, mp_limb_t n, mp_limb_t ninv, long alloc) + # Initialises ``poly``. It will have coefficients modulo~`n`. + # The caller supplies a precomputed inverse limb generated by + # :func:`n_preinvert_limb`. Up to ``alloc`` coefficients may + # be stored in ``poly``. + + void nmod_poly_realloc(nmod_poly_t poly, long alloc) + # Reallocates ``poly`` to the given length. If the current + # length is less than ``alloc``, the polynomial is truncated + # and normalised. If ``alloc`` is zero, the polynomial is + # cleared. + + void nmod_poly_clear(nmod_poly_t poly) + # Clears the polynomial and releases any memory it used. The polynomial + # cannot be used again until it is initialised. + + void nmod_poly_fit_length(nmod_poly_t poly, long alloc) + # Ensures ``poly`` has space for at least ``alloc`` coefficients. + # This function only ever grows the allocated space, so no data loss can + # occur. + + void _nmod_poly_normalise(nmod_poly_t poly) + # Internal function for normalising a polynomial so that the top + # coefficient, if there is one at all, is not zero. + + long nmod_poly_length(const nmod_poly_t poly) + # Returns the length of the polynomial ``poly``. The zero polynomial + # has length zero. + + long nmod_poly_degree(const nmod_poly_t poly) + # Returns the degree of the polynomial ``poly``. The zero polynomial + # is deemed to have degree~`-1`. + + mp_limb_t nmod_poly_modulus(const nmod_poly_t poly) + # Returns the modulus of the polynomial ``poly``. This will be a + # positive integer. + + flint_bitcnt_t nmod_poly_max_bits(const nmod_poly_t poly) + # Returns the maximum number of bits of any coefficient of ``poly``. + + void nmod_poly_set(nmod_poly_t a, const nmod_poly_t b) + # Sets ``a`` to a copy of ``b``. + + void nmod_poly_swap(nmod_poly_t poly1, nmod_poly_t poly2) + # Efficiently swaps ``poly1`` and ``poly2`` by swapping pointers + # internally. + + void nmod_poly_zero(nmod_poly_t res) + # Sets ``res`` to the zero polynomial. + + void nmod_poly_truncate(nmod_poly_t poly, long len) + # Truncates ``poly`` to the given length and normalises it. + # If ``len`` is greater than the current length of ``poly``, + # then nothing happens. + + void nmod_poly_set_trunc(nmod_poly_t res, const nmod_poly_t poly, long n) + # Notionally truncate ``poly`` to length `n` and set ``res`` to the + # result. The result is normalised. + + void _nmod_poly_reverse(mp_ptr output, mp_srcptr input, long len, long m) + # Sets ``output`` to the reverse of ``input``, which is of length + # ``len``, but thinking of it as a polynomial of length~``m``, + # notionally zero-padded if necessary. The length~``m`` must be + # non-negative, but there are no other restrictions. The polynomial + # ``output`` must have space for ``m`` coefficients. Supports + # aliasing of ``output`` and ``input``, but the behaviour is + # undefined in case of partial overlap. + + void nmod_poly_reverse(nmod_poly_t output, const nmod_poly_t input, long m) + # Sets ``output`` to the reverse of ``input``, thinking of it as + # a polynomial of length~``m``, notionally zero-padded if necessary). + # The length~``m`` must be non-negative, but there are no other + # restrictions. The output polynomial will be set to length~``m`` + # and then normalised. + + void nmod_poly_randtest(nmod_poly_t poly, flint_rand_t state, long len) + # Generates a random polynomial with length up to ``len``. + + void nmod_poly_randtest_irreducible(nmod_poly_t poly, flint_rand_t state, long len) + # Generates a random irreducible polynomial with length up to ``len``. + + void nmod_poly_randtest_monic(nmod_poly_t poly, flint_rand_t state, long len) + # Generates a random monic polynomial with length ``len``. + + void nmod_poly_randtest_monic_irreducible(nmod_poly_t poly, flint_rand_t state, long len) + # Generates a random monic irreducible polynomial with length ``len``. + + void nmod_poly_randtest_monic_primitive(nmod_poly_t poly, flint_rand_t state, long len) + # Generates a random monic irreducible primitive polynomial with + # length ``len``. + + void nmod_poly_randtest_trinomial(nmod_poly_t poly, flint_rand_t state, long len) + # Generates a random monic trinomial of length ``len``. + + int nmod_poly_randtest_trinomial_irreducible(nmod_poly_t poly, flint_rand_t state, long len, long max_attempts) + # Attempts to set ``poly`` to a monic irreducible trinomial of + # length ``len``. It will generate up to ``max_attempts`` + # trinomials in attempt to find an irreducible one. If + # ``max_attempts`` is ``0``, then it will keep generating + # trinomials until an irreducible one is found. Returns `1` if one + # is found and `0` otherwise. + + void nmod_poly_randtest_pentomial(nmod_poly_t poly, flint_rand_t state, long len) + # Generates a random monic pentomial of length ``len``. + + int nmod_poly_randtest_pentomial_irreducible(nmod_poly_t poly, flint_rand_t state, long len, long max_attempts) + # Attempts to set ``poly`` to a monic irreducible pentomial of + # length ``len``. It will generate up to ``max_attempts`` + # pentomials in attempt to find an irreducible one. If + # ``max_attempts`` is ``0``, then it will keep generating + # pentomials until an irreducible one is found. Returns `1` if one + # is found and `0` otherwise. + + void nmod_poly_randtest_sparse_irreducible(nmod_poly_t poly, flint_rand_t state, long len) + # Attempts to set ``poly`` to a sparse, monic irreducible polynomial + # with length ``len``. It attempts to find an irreducible + # trinomial. If that does not succeed, it attempts to find a + # irreducible pentomial. If that fails, then ``poly`` is just + # set to a random monic irreducible polynomial. + + unsigned long nmod_poly_get_coeff_ui(const nmod_poly_t poly, long j) + # Returns the coefficient of ``poly`` at index~``j``, where + # coefficients are numbered with zero being the constant coefficient, + # and returns it as an ``ulong``. If ``j`` refers to a + # coefficient beyond the end of ``poly``, zero is returned. + + void nmod_poly_set_coeff_ui(nmod_poly_t poly, long j, unsigned long c) + # Sets the coefficient of ``poly`` at index ``j``, where + # coefficients are numbered with zero being the constant coefficient, + # to the value ``c`` reduced modulo the modulus of ``poly``. + # If ``j`` refers to a coefficient beyond the current end of ``poly``, + # the polynomial is first resized, with intervening coefficients being + # set to zero. + + char * nmod_poly_get_str(const nmod_poly_t poly) + # Writes ``poly`` to a string representation. The format is as + # described for :func:`nmod_poly_print`. The string must be freed by the + # user when finished. For this it is sufficient to call :func:`flint_free`. + + char * nmod_poly_get_str_pretty(const nmod_poly_t poly, const char * x) + # Writes ``poly`` to a pretty string representation. The format is as + # described for :func:`nmod_poly_print_pretty`. The string must be freed + # by the user when finished. For this it is sufficient to call + # :func:`flint_free`. + # It is assumed that the top coefficient is non-zero. + + int nmod_poly_set_str(nmod_poly_t poly, const char * s) + # Reads ``poly`` from a string ``s``. The format is as described + # for :func:`nmod_poly_print`. If a polynomial in the correct format + # is read, a positive value is returned, otherwise a non-positive value + # is returned. + + int nmod_poly_print(const nmod_poly_t a) + # Prints the polynomial to ``stdout``. The length is printed, + # followed by a space, then the modulus. If the length is zero this is + # all that is printed, otherwise two spaces followed by a space + # separated list of coefficients is printed, beginning with the constant + # coefficient. + # In case of success, returns a positive value. In case of failure, + # returns a non-positive value. + + int nmod_poly_print_pretty(const nmod_poly_t a, const char * x) + # Prints the polynomial to ``stdout`` using the string ``x`` to + # represent the indeterminate. + # It is assumed that the top coefficient is non-zero. + # In case of success, returns a positive value. In case of failure, + # returns a non-positive value. + + int nmod_poly_fread(FILE * f, nmod_poly_t poly) + # Reads ``poly`` from the file stream ``f``. If this is a file + # that has just been written, the file should be closed then opened + # again. The format is as described for :func:`nmod_poly_print`. If a + # polynomial in the correct format is read, a positive value is returned, + # otherwise a non-positive value is returned. + + int nmod_poly_fprint(FILE * f, const nmod_poly_t poly) + # Writes a polynomial to the file stream ``f``. If this is a file + # then the file should be closed and reopened before being read. + # The format is as described for :func:`nmod_poly_print`. If the + # polynomial is written correctly, a positive value is returned, + # otherwise a non-positive value is returned. + # In case of success, returns a positive value. In case of failure, + # returns a non-positive value. + + int nmod_poly_fprint_pretty(FILE * f, const nmod_poly_t poly, const char * x) + # Writes a polynomial to the file stream ``f``. If this is a file + # then the file should be closed and reopened before being read. + # The format is as described for :func:`nmod_poly_print_pretty`. If the + # polynomial is written correctly, a positive value is returned, + # otherwise a non-positive value is returned. + # It is assumed that the top coefficient is non-zero. + # In case of success, returns a positive value. In case of failure, + # returns a non-positive value. + + int nmod_poly_read(nmod_poly_t poly) + # Read ``poly`` from ``stdin``. The format is as described for + # :func:`nmod_poly_print`. If a polynomial in the correct format is read, a + # positive value is returned, otherwise a non-positive value is returned. + + int nmod_poly_equal(const nmod_poly_t a, const nmod_poly_t b) + # Returns~`1` if the polynomials are equal, otherwise~`0`. + + int nmod_poly_equal_trunc(const nmod_poly_t poly1, const nmod_poly_t poly2, long n) + # Notionally truncate ``poly1`` and ``poly2`` to length `n` and return + # `1` if the truncations are equal, otherwise return `0`. + + int nmod_poly_is_zero(const nmod_poly_t poly) + # Returns~`1` if the polynomial ``poly`` is the zero polynomial, + # otherwise returns~`0`. + + int nmod_poly_is_one(const nmod_poly_t poly) + # Returns~`1` if the polynomial ``poly`` is the constant polynomial 1, + # otherwise returns~`0`. + + void _nmod_poly_shift_left(mp_ptr res, mp_srcptr poly, long len, long k) + # Sets ``(res, len + k)`` to ``(poly, len)`` shifted left by + # ``k`` coefficients. Assumes that ``res`` has space for + # ``len + k`` coefficients. + + void nmod_poly_shift_left(nmod_poly_t res, const nmod_poly_t poly, long k) + # Sets ``res`` to ``poly`` shifted left by ``k`` coefficients, + # i.e.\ multiplied by `x^k`. + + void _nmod_poly_shift_right(mp_ptr res, mp_srcptr poly, long len, long k) + # Sets ``(res, len - k)`` to ``(poly, len)`` shifted left by + # ``k`` coefficients. It is assumed that ``k <= len`` and that + # ``res`` has space for at least ``len - k`` coefficients. + + void nmod_poly_shift_right(nmod_poly_t res, const nmod_poly_t poly, long k) + # Sets ``res`` to ``poly`` shifted right by ``k`` coefficients, + # i.e.\ divide by `x^k` and throws away the remainder. If ``k`` is + # greater than or equal to the length of ``poly``, the result is the + # zero polynomial. + + void _nmod_poly_add(mp_ptr res, mp_srcptr poly1, long len1, mp_srcptr poly2, long len2, nmod_t mod) + # Sets ``res`` to the sum of ``(poly1, len1)`` and + # ``(poly2, len2)``. There are no restrictions on the lengths. + + void nmod_poly_add(nmod_poly_t res, const nmod_poly_t poly1, const nmod_poly_t poly2) + # Sets ``res`` to the sum of ``poly1`` and ``poly2``. + + void nmod_poly_add_series(nmod_poly_t res, const nmod_poly_t poly1, const nmod_poly_t poly2, long n) + # Notionally truncate ``poly1`` and ``poly2`` to length `n` and set + # ``res`` to the sum. + + void _nmod_poly_sub(mp_ptr res, mp_srcptr poly1, long len1, mp_srcptr poly2, long len2, nmod_t mod) + # Sets ``res`` to the difference of ``(poly1, len1)`` and + # ``(poly2, len2)``. There are no restrictions on the lengths. + + void nmod_poly_sub(nmod_poly_t res, const nmod_poly_t poly1, const nmod_poly_t poly2) + # Sets ``res`` to the difference of ``poly1`` and ``poly2``. + + void nmod_poly_sub_series(nmod_poly_t res, const nmod_poly_t poly1, const nmod_poly_t poly2, long n) + # Notionally truncate ``poly1`` and ``poly2`` to length `n` and set + # ``res`` to the difference. + + void nmod_poly_neg(nmod_poly_t res, const nmod_poly_t poly) + # Sets ``res`` to the negation of ``poly``. + + void nmod_poly_scalar_mul_nmod(nmod_poly_t res, const nmod_poly_t poly, unsigned long c) + # Sets ``res`` to ``(poly, len)`` multiplied by~`c`, + # where~`c` is reduced modulo the modulus of ``poly``. + + void _nmod_poly_make_monic(mp_ptr output, mp_srcptr input, long len, nmod_t mod) + # Sets ``output`` to be the scalar multiple of ``input`` of + # length ``len > 0`` that has leading coefficient one, if such a + # polynomial exists. If the leading coefficient of ``input`` is not + # invertible, ``output`` is set to the multiple of ``input`` whose + # leading coefficient is the greatest common divisor of the leading + # coefficient and the modulus of ``input``. + + void nmod_poly_make_monic(nmod_poly_t output, const nmod_poly_t input) + # Sets ``output`` to be the scalar multiple of ``input`` with leading + # coefficient one, if such a polynomial exists. If ``input`` is zero + # an exception is raised. If the leading coefficient of ``input`` is not + # invertible, ``output`` is set to the multiple of ``input`` whose + # leading coefficient is the greatest common divisor of the leading + # coefficient and the modulus of ``input``. + + void _nmod_poly_bit_pack(mp_ptr res, mp_srcptr poly, long len, flint_bitcnt_t bits) + # Packs ``len`` coefficients of ``poly`` into fields of the given + # number of bits in the large integer ``res``, i.e.\ evaluates + # ``poly`` at ``2^bits`` and store the result in ``res``. + # Assumes ``len > 0`` and ``bits > 0``. Also assumes that no + # coefficient of ``poly`` is bigger than ``bits/2`` bits. We + # also assume ``bits < 3 * FLINT_BITS``. + + void _nmod_poly_bit_unpack(mp_ptr res, long len, mp_srcptr mpn, unsigned long bits, nmod_t mod) + # Unpacks ``len`` coefficients stored in the big integer ``mpn`` + # in bit fields of the given number of bits, reduces them modulo the + # given modulus, then stores them in the polynomial ``res``. + # We assume ``len > 0`` and ``3 * FLINT_BITS > bits > 0``. + # There are no restrictions on the size of the actual coefficients as + # stored within the bitfields. + + void nmod_poly_bit_pack(fmpz_t f, const nmod_poly_t poly, flint_bitcnt_t bit_size) + # Packs ``poly`` into bitfields of size ``bit_size``, writing the + # result to ``f``. + + void nmod_poly_bit_unpack(nmod_poly_t poly, const fmpz_t f, flint_bitcnt_t bit_size) + # Unpacks the polynomial from fields of size ``bit_size`` as + # represented by the integer ``f``. + + void _nmod_poly_KS2_pack1(mp_ptr res, mp_srcptr op, long n, long s, unsigned long b, unsigned long k, long r) + # Same as ``_nmod_poly_KS2_pack``, but requires ``b <= FLINT_BITS``. + + void _nmod_poly_KS2_pack(mp_ptr res, mp_srcptr op, long n, long s, unsigned long b, unsigned long k, long r) + # Bit packing routine used by KS2 and KS4 multiplication. + + void _nmod_poly_KS2_unpack1(mp_ptr res, mp_srcptr op, long n, unsigned long b, unsigned long k) + # Same as ``_nmod_poly_KS2_unpack``, but requires ``b <= FLINT_BITS`` + # (i.e. writes one word per coefficient). + + void _nmod_poly_KS2_unpack2(mp_ptr res, mp_srcptr op, long n, unsigned long b, unsigned long k) + # Same as ``_nmod_poly_KS2_unpack``, but requires + # ``FLINT_BITS < b <= 2 * FLINT_BITS`` (i.e. writes two words per + # coefficient). + + void _nmod_poly_KS2_unpack3(mp_ptr res, mp_srcptr op, long n, unsigned long b, unsigned long k) + # Same as ``_nmod_poly_KS2_unpack``, but requires + # ``2 * FLINT_BITS < b < 3 * FLINT_BITS`` (i.e. writes three words per + # coefficient). + + void _nmod_poly_KS2_unpack(mp_ptr res, mp_srcptr op, long n, unsigned long b, unsigned long k) + # Bit unpacking code used by KS2 and KS4 multiplication. + + void _nmod_poly_KS2_reduce(mp_ptr res, long s, mp_srcptr op, long n, unsigned long w, nmod_t mod) + # Reduction code used by KS2 and KS4 multiplication. + + void _nmod_poly_KS2_recover_reduce1(mp_ptr res, long s, mp_srcptr op1, mp_srcptr op2, long n, unsigned long b, nmod_t mod) + # Same as ``_nmod_poly_KS2_recover_reduce``, but requires + # ``0 < 2 * b <= FLINT_BITS``. + + void _nmod_poly_KS2_recover_reduce2(mp_ptr res, long s, mp_srcptr op1, mp_srcptr op2, long n, unsigned long b, nmod_t mod) + # Same as ``_nmod_poly_KS2_recover_reduce``, but requires + # ``FLINT_BITS < 2 * b < 2*FLINT_BITS``. + + void _nmod_poly_KS2_recover_reduce2b(mp_ptr res, long s, mp_srcptr op1, mp_srcptr op2, long n, unsigned long b, nmod_t mod) + # Same as ``_nmod_poly_KS2_recover_reduce``, but requires + # ``b == FLINT_BITS``. + + void _nmod_poly_KS2_recover_reduce3(mp_ptr res, long s, mp_srcptr op1, mp_srcptr op2, long n, unsigned long b, nmod_t mod) + # Same as ``_nmod_poly_KS2_recover_reduce``, but requires + # ``2 * FLINT_BITS < 2 * b <= 3 * FLINT_BITS``. + + void _nmod_poly_KS2_recover_reduce(mp_ptr res, long s, mp_srcptr op1, mp_srcptr op2, long n, unsigned long b, nmod_t mod) + # Reduction code used by KS4 multiplication. + + void _nmod_poly_mul_classical(mp_ptr res, mp_srcptr poly1, long len1, mp_srcptr poly2, long len2, nmod_t mod) + # Sets ``(res, len1 + len2 - 1)`` to the product of ``(poly1, len1)`` + # and ``(poly2, len2)``. Assumes ``len1 >= len2 > 0``. Aliasing of + # inputs and output is not permitted. + + void nmod_poly_mul_classical(nmod_poly_t res, const nmod_poly_t poly1, const nmod_poly_t poly2) + # Sets ``res`` to the product of ``poly1`` and ``poly2``. + + void _nmod_poly_mullow_classical(mp_ptr res, mp_srcptr poly1, long len1, mp_srcptr poly2, long len2, long trunc, nmod_t mod) + # Sets ``res`` to the lower ``trunc`` coefficients of the product of + # ``(poly1, len1)`` and ``(poly2, len2)``. Assumes that + # ``len1 >= len2 > 0`` and ``trunc > 0``. Aliasing of inputs and + # output is not permitted. + + void nmod_poly_mullow_classical(nmod_poly_t res, const nmod_poly_t poly1, const nmod_poly_t poly2, long trunc) + # Sets ``res`` to the lower ``trunc`` coefficients of the product + # of ``poly1`` and ``poly2``. + + void _nmod_poly_mulhigh_classical(mp_ptr res, mp_srcptr poly1, long len1, mp_srcptr poly2, long len2, long start, nmod_t mod) + # Computes the product of ``(poly1, len1)`` and ``(poly2, len2)`` + # and writes the coefficients from ``start`` onwards into the high + # coefficients of ``res``, the remaining coefficients being arbitrary + # but reduced. Assumes that ``len1 >= len2 > 0``. Aliasing of inputs + # and output is not permitted. + + void nmod_poly_mulhigh_classical(nmod_poly_t res, const nmod_poly_t poly1, const nmod_poly_t poly2, long start) + # Computes the product of ``poly1`` and ``poly2`` and writes the + # coefficients from ``start`` onwards into the high coefficients of + # ``res``, the remaining coefficients being arbitrary but reduced. + + void _nmod_poly_mul_KS(mp_ptr out, mp_srcptr in1, long len1, mp_srcptr in2, long len2, flint_bitcnt_t bits, nmod_t mod) + # Sets ``res`` to the product of ``in1`` and ``in2`` + # assuming the output coefficients are at most the given number of + # bits wide. If ``bits`` is set to `0` an appropriate value is + # computed automatically. Assumes that ``len1 >= len2 > 0``. + + void nmod_poly_mul_KS(nmod_poly_t res, const nmod_poly_t poly1, const nmod_poly_t poly2, flint_bitcnt_t bits) + # Sets ``res`` to the product of ``poly1`` and ``poly2`` + # assuming the output coefficients are at most the given number of + # bits wide. If ``bits`` is set to `0` an appropriate value + # is computed automatically. + + void _nmod_poly_mul_KS2(mp_ptr res, mp_srcptr op1, long n1, mp_srcptr op2, long n2, nmod_t mod) + # Sets ``res`` to the product of ``op1`` and ``op2``. + # Assumes that ``len1 >= len2 > 0``. + + void nmod_poly_mul_KS2(nmod_poly_t res, const nmod_poly_t poly1, const nmod_poly_t poly2) + # Sets ``res`` to the product of ``poly1`` and ``poly2``. + + void _nmod_poly_mul_KS4(mp_ptr res, mp_srcptr op1, long n1, mp_srcptr op2, long n2, nmod_t mod) + # Sets ``res`` to the product of ``op1`` and ``op2``. + # Assumes that ``len1 >= len2 > 0``. + + void nmod_poly_mul_KS4(nmod_poly_t res, const nmod_poly_t poly1, const nmod_poly_t poly2) + # Sets ``res`` to the product of ``poly1`` and ``poly2``. + + void _nmod_poly_mullow_KS(mp_ptr out, mp_srcptr in1, long len1, mp_srcptr in2, long len2, flint_bitcnt_t bits, long n, nmod_t mod) + # Sets ``out`` to the low `n` coefficients of ``in1`` of length + # ``len1`` times ``in2`` of length ``len2``. The output must have + # space for ``n`` coefficients. We assume that ``len1 >= len2 > 0`` + # and that ``0 < n <= len1 + len2 - 1``. + + void nmod_poly_mullow_KS(nmod_poly_t res, const nmod_poly_t poly1, const nmod_poly_t poly2, flint_bitcnt_t bits, long n) + # Set ``res`` to the low `n` coefficients of ``in1`` of length + # ``len1`` times ``in2`` of length ``len2``. + + void _nmod_poly_mul(mp_ptr res, mp_srcptr poly1, long len1, mp_srcptr poly2, long len2, nmod_t mod) + # Sets ``res`` to the product of ``poly1`` of length ``len1`` + # and ``poly2`` of length ``len2``. Assumes ``len1 >= len2 > 0``. + # No aliasing is permitted between the inputs and the output. + + void nmod_poly_mul(nmod_poly_t res, const nmod_poly_t poly, const nmod_poly_t poly2) + # Sets ``res`` to the product of ``poly1`` and ``poly2``. + + void _nmod_poly_mullow(mp_ptr res, mp_srcptr poly1, long len1, mp_srcptr poly2, long len2, long n, nmod_t mod) + # Sets ``res`` to the first ``n`` coefficients of the + # product of ``poly1`` of length ``len1`` and ``poly2`` of + # length ``len2``. It is assumed that ``0 < n <= len1 + len2 - 1`` + # and that ``len1 >= len2 > 0``. No aliasing of inputs and output + # is permitted. + + void nmod_poly_mullow(nmod_poly_t res, const nmod_poly_t poly1, const nmod_poly_t poly2, long trunc) + # Sets ``res`` to the first ``trunc`` coefficients of the + # product of ``poly1`` and ``poly2``. + + void _nmod_poly_mulhigh(mp_ptr res, mp_srcptr poly1, long len1, mp_srcptr poly2, long len2, long n, nmod_t mod) + # Sets all but the low `n` coefficients of ``res`` to the + # corresponding coefficients of the product of ``poly1`` of length + # ``len1`` and ``poly2`` of length ``len2``, the other + # coefficients being arbitrary. It is assumed that + # ``len1 >= len2 > 0`` and that ``0 < n <= len1 + len2 - 1``. + # Aliasing of inputs and output is not permitted. + + void nmod_poly_mulhigh(nmod_poly_t res, const nmod_poly_t poly1, const nmod_poly_t poly2, long n) + # Sets all but the low `n` coefficients of ``res`` to the + # corresponding coefficients of the product of ``poly1`` and + # ``poly2``, the remaining coefficients being arbitrary. + + void _nmod_poly_mulmod(mp_ptr res, mp_srcptr poly1, long len1, mp_srcptr poly2, long len2, mp_srcptr f, long lenf, nmod_t mod) + # Sets ``res`` to the remainder of the product of ``poly1`` and + # ``poly2`` upon polynomial division by ``f``. + # It is required that ``len1 + len2 - lenf > 0``, which is equivalent + # to requiring that the result will actually be reduced. Otherwise, simply + # use ``_nmod_poly_mul`` instead. + # Aliasing of ``f`` and ``res`` is not permitted. + + void nmod_poly_mulmod(nmod_poly_t res, const nmod_poly_t poly1, const nmod_poly_t poly2, const nmod_poly_t f) + # Sets ``res`` to the remainder of the product of ``poly1`` and + # ``poly2`` upon polynomial division by ``f``. + + void _nmod_poly_mulmod_preinv(mp_ptr res, mp_srcptr poly1, long len1, mp_srcptr poly2, long len2, mp_srcptr f, long lenf, mp_srcptr finv, long lenfinv, nmod_t mod) + # Sets ``res`` to the remainder of the product of ``poly1`` and + # ``poly2`` upon polynomial division by ``f``. + # It is required that ``finv`` is the inverse of the reverse of ``f`` + # mod ``x^lenf``. It is required that ``len1 + len2 - lenf > 0``, + # which is equivalent to requiring that the result will actually be reduced. + # It is required that ``len1 < lenf`` and ``len2 < lenf``. + # Otherwise, simply use ``_nmod_poly_mul`` instead. + # Aliasing of ```res`` with any of the inputs is not permitted. + + void nmod_poly_mulmod_preinv(nmod_poly_t res, const nmod_poly_t poly1, const nmod_poly_t poly2, const nmod_poly_t f, const nmod_poly_t finv) + # Sets ``res`` to the remainder of the product of ``poly1`` and + # ``poly2`` upon polynomial division by ``f``. ``finv`` is the + # inverse of the reverse of ``f``. It is required that ``poly1`` and + # ``poly2`` are reduced modulo ``f``. + + void _nmod_poly_pow_binexp(mp_ptr res, mp_srcptr poly, long len, unsigned long e, nmod_t mod) + # Raises ``poly`` of length ``len`` to the power ``e`` and sets + # ``res`` to the result. We require that ``res`` has enough space + # for ``(len - 1)*e + 1`` coefficients. Assumes that ``len > 0``, + # ``e > 1``. Aliasing is not permitted. Uses the binary exponentiation + # method. + + void nmod_poly_pow_binexp(nmod_poly_t res, const nmod_poly_t poly, unsigned long e) + # Raises ``poly`` to the power ``e`` and sets ``res`` to the + # result. Uses the binary exponentiation method. + + void _nmod_poly_pow(mp_ptr res, mp_srcptr poly, long len, unsigned long e, nmod_t mod) + # Raises ``poly`` of length ``len`` to the power ``e`` and sets + # ``res`` to the result. We require that ``res`` has enough space + # for ``(len - 1)*e + 1`` coefficients. Assumes that ``len > 0``, + # ``e > 1``. Aliasing is not permitted. + + void nmod_poly_pow(nmod_poly_t res, const nmod_poly_t poly, unsigned long e) + # Raises ``poly`` to the power ``e`` and sets ``res`` to the + # result. + + void _nmod_poly_pow_trunc_binexp(mp_ptr res, mp_srcptr poly, unsigned long e, long trunc, nmod_t mod) + # Sets ``res`` to the low ``trunc`` coefficients of ``poly`` + # (assumed to be zero padded if necessary to length ``trunc``) to + # the power ``e``. This is equivalent to doing a powering followed + # by a truncation. We require that ``res`` has enough space for + # ``trunc`` coefficients, that ``trunc > 0`` and that + # ``e > 1``. Aliasing is not permitted. Uses the binary + # exponentiation method. + + void nmod_poly_pow_trunc_binexp(nmod_poly_t res, const nmod_poly_t poly, unsigned long e, long trunc) + # Sets ``res`` to the low ``trunc`` coefficients of ``poly`` + # to the power ``e``. This is equivalent to doing a powering + # followed by a truncation. Uses the binary exponentiation method. + + void _nmod_poly_pow_trunc(mp_ptr res, mp_srcptr poly, unsigned long e, long trunc, nmod_t mod) + # Sets ``res`` to the low ``trunc`` coefficients of ``poly`` + # (assumed to be zero padded if necessary to length ``trunc``) to + # the power ``e``. This is equivalent to doing a powering followed + # by a truncation. We require that ``res`` has enough space for + # ``trunc`` coefficients, that ``trunc > 0`` and that + # ``e > 1``. Aliasing is not permitted. + + void nmod_poly_pow_trunc(nmod_poly_t res, const nmod_poly_t poly, unsigned long e, long trunc) + # Sets ``res`` to the low ``trunc`` coefficients of ``poly`` + # to the power ``e``. This is equivalent to doing a powering + # followed by a truncation. + + void _nmod_poly_powmod_ui_binexp(mp_ptr res, mp_srcptr poly, unsigned long e, mp_srcptr f, long lenf, nmod_t mod) + # Sets ``res`` to ``poly`` raised to the power ``e`` + # modulo ``f``, using binary exponentiation. We require ``e > 0``. + # We require ``lenf > 1``. It is assumed that ``poly`` is already + # reduced modulo ``f`` and zero-padded as necessary to have length + # exactly ``lenf - 1``. The output ``res`` must have room for + # ``lenf - 1`` coefficients. + + void nmod_poly_powmod_ui_binexp(nmod_poly_t res, const nmod_poly_t poly, unsigned long e, const nmod_poly_t f) + # Sets ``res`` to ``poly`` raised to the power ``e`` + # modulo ``f``, using binary exponentiation. We require ``e >= 0``. + + void _nmod_poly_powmod_mpz_binexp(mp_ptr res, mp_srcptr poly, mpz_srcptr e, mp_srcptr f, long lenf, nmod_t mod) + # Sets ``res`` to ``poly`` raised to the power ``e`` + # modulo ``f``, using binary exponentiation. We require ``e > 0``. + # We require ``lenf > 1``. It is assumed that ``poly`` is already + # reduced modulo ``f`` and zero-padded as necessary to have length + # exactly ``lenf - 1``. The output ``res`` must have room for + # ``lenf - 1`` coefficients. + + void nmod_poly_powmod_mpz_binexp(nmod_poly_t res, const nmod_poly_t poly, mpz_srcptr e, const nmod_poly_t f) + # Sets ``res`` to ``poly`` raised to the power ``e`` + # modulo ``f``, using binary exponentiation. We require ``e >= 0``. + + void _nmod_poly_powmod_fmpz_binexp(mp_ptr res, mp_srcptr poly, fmpz_t e, mp_srcptr f, long lenf, nmod_t mod) + # Sets ``res`` to ``poly`` raised to the power ``e`` + # modulo ``f``, using binary exponentiation. We require ``e > 0``. + # We require ``lenf > 1``. It is assumed that ``poly`` is already + # reduced modulo ``f`` and zero-padded as necessary to have length + # exactly ``lenf - 1``. The output ``res`` must have room for ``lenf - 1`` coefficients. + + void nmod_poly_powmod_fmpz_binexp(nmod_poly_t res, const nmod_poly_t poly, fmpz_t e, const nmod_poly_t f) + # Sets ``res`` to ``poly`` raised to the power ``e`` + # modulo ``f``, using binary exponentiation. We require ``e >= 0``. + + void _nmod_poly_powmod_ui_binexp_preinv (mp_ptr res, mp_srcptr poly, unsigned long e, mp_srcptr f, long lenf, mp_srcptr finv, long lenfinv, nmod_t mod) + # Sets ``res`` to ``poly`` raised to the power ``e`` + # modulo ``f``, using binary exponentiation. We require ``e > 0``. + # We require ``finv`` to be the inverse of the reverse of ``f``. + # We require ``lenf > 1``. It is assumed that ``poly`` is already + # reduced modulo ``f`` and zero-padded as necessary to have length + # exactly ``lenf - 1``. The output ``res`` must have room for + # ``lenf - 1`` coefficients. + + void nmod_poly_powmod_ui_binexp_preinv(nmod_poly_t res, const nmod_poly_t poly, unsigned long e, const nmod_poly_t f, const nmod_poly_t finv) + # Sets ``res`` to ``poly`` raised to the power ``e`` + # modulo ``f``, using binary exponentiation. We require ``e >= 0``. + # We require ``finv`` to be the inverse of the reverse of ``f``. + + void _nmod_poly_powmod_mpz_binexp_preinv (mp_ptr res, mp_srcptr poly, mpz_srcptr e, mp_srcptr f, long lenf, mp_srcptr finv, long lenfinv, nmod_t mod) + # Sets ``res`` to ``poly`` raised to the power ``e`` + # modulo ``f``, using binary exponentiation. We require ``e > 0``. + # We require ``finv`` to be the inverse of the reverse of ``f``. + # We require ``lenf > 1``. It is assumed that ``poly`` is already + # reduced modulo ``f`` and zero-padded as necessary to have length + # exactly ``lenf - 1``. The output ``res`` must have room for + # ``lenf - 1`` coefficients. + + void nmod_poly_powmod_mpz_binexp_preinv(nmod_poly_t res, const nmod_poly_t poly, mpz_srcptr e, const nmod_poly_t f, const nmod_poly_t finv) + # Sets ``res`` to ``poly`` raised to the power ``e`` + # modulo ``f``, using binary exponentiation. We require ``e >= 0``. + # We require ``finv`` to be the inverse of the reverse of ``f``. + + void _nmod_poly_powmod_fmpz_binexp_preinv (mp_ptr res, mp_srcptr poly, fmpz_t e, mp_srcptr f, long lenf, mp_srcptr finv, long lenfinv, nmod_t mod) + # Sets ``res`` to ``poly`` raised to the power ``e`` + # modulo ``f``, using binary exponentiation. We require ``e > 0``. + # We require ``finv`` to be the inverse of the reverse of ``f``. + # We require ``lenf > 1``. It is assumed that ``poly`` is already + # reduced modulo ``f`` and zero-padded as necessary to have length + # exactly ``lenf - 1``. The output ``res`` must have room for + # ``lenf - 1`` coefficients. + + void nmod_poly_powmod_fmpz_binexp_preinv(nmod_poly_t res, const nmod_poly_t poly, fmpz_t e, const nmod_poly_t f, const nmod_poly_t finv) + # Sets ``res`` to ``poly`` raised to the power ``e`` + # modulo ``f``, using binary exponentiation. We require ``e >= 0``. + # We require ``finv`` to be the inverse of the reverse of ``f``. + + void _nmod_poly_powmod_x_ui_preinv (mp_ptr res, unsigned long e, mp_srcptr f, long lenf, mp_srcptr finv, long lenfinv, nmod_t mod) + # Sets ``res`` to ``x`` raised to the power ``e`` modulo ``f``, + # using sliding window exponentiation. We require ``e > 0``. + # We require ``finv`` to be the inverse of the reverse of ``f``. + # We require ``lenf > 2``. The output ``res`` must have room for + # ``lenf - 1`` coefficients. + + void nmod_poly_powmod_x_ui_preinv(nmod_poly_t res, unsigned long e, const nmod_poly_t f, const nmod_poly_t finv) + # Sets ``res`` to ``x`` raised to the power ``e`` + # modulo ``f``, using sliding window exponentiation. We require + # ``e >= 0``. We require ``finv`` to be the inverse of the reverse of + # ``f``. + + void _nmod_poly_powmod_x_fmpz_preinv (mp_ptr res, fmpz_t e, mp_srcptr f, long lenf, mp_srcptr finv, long lenfinv, nmod_t mod) + # Sets ``res`` to ``x`` raised to the power ``e`` modulo ``f``, + # using sliding window exponentiation. We require ``e > 0``. + # We require ``finv`` to be the inverse of the reverse of ``f``. + # We require ``lenf > 2``. The output ``res`` must have room for + # ``lenf - 1`` coefficients. + + void nmod_poly_powmod_x_fmpz_preinv(nmod_poly_t res, fmpz_t e, const nmod_poly_t f, const nmod_poly_t finv) + # Sets ``res`` to ``x`` raised to the power ``e`` + # modulo ``f``, using sliding window exponentiation. We require + # ``e >= 0``. We require ``finv`` to be the inverse of the reverse of + # ``f``. + + void _nmod_poly_powers_mod_preinv_naive(mp_ptr * res, mp_srcptr f, long flen, long n, mp_srcptr g, long glen, mp_srcptr ginv, long ginvlen, const nmod_t mod) + # Compute ``f^0, f^1, ..., f^(n-1) mod g``, where ``g`` has length ``glen`` + # and ``f`` is reduced mod ``g`` and has length ``flen`` (possibly zero + # spaced). Assumes ``res`` is an array of ``n`` arrays each with space for + # at least ``glen - 1`` coefficients and that ``flen > 0``. We require that + # ``ginv`` of length ``ginvlen`` is set to the power series inverse of the + # reverse of ``g``. + + void nmod_poly_powers_mod_naive(nmod_poly_struct * res, const nmod_poly_t f, long n, const nmod_poly_t g) + # Set the entries of the array ``res`` to ``f^0, f^1, ..., f^(n-1) mod g``. + # No aliasing is permitted between the entries of ``res`` and either of the + # inputs. + + void _nmod_poly_powers_mod_preinv_threaded_pool(mp_ptr * res, mp_srcptr f, long flen, long n, mp_srcptr g, long glen, mp_srcptr ginv, long ginvlen, const nmod_t mod, thread_pool_handle * threads, long num_threads) + # Compute ``f^0, f^1, ..., f^(n-1) mod g``, where ``g`` has length ``glen`` + # and ``f`` is reduced mod ``g`` and has length ``flen`` (possibly zero + # spaced). Assumes ``res`` is an array of ``n`` arrays each with space for + # at least ``glen - 1`` coefficients and that ``flen > 0``. We require that + # ``ginv`` of length ``ginvlen`` is set to the power series inverse of the + # reverse of ``g``. + + void _nmod_poly_powers_mod_preinv_threaded(mp_ptr * res, mp_srcptr f, long flen, long n, mp_srcptr g, long glen, mp_srcptr ginv, long ginvlen, const nmod_t mod) + # Compute ``f^0, f^1, ..., f^(n-1) mod g``, where ``g`` has length ``glen`` + # and ``f`` is reduced mod ``g`` and has length ``flen`` (possibly zero + # spaced). Assumes ``res`` is an array of ``n`` arrays each with space for + # at least ``glen - 1`` coefficients and that ``flen > 0``. We require that + # ``ginv`` of length ``ginvlen`` is set to the power series inverse of the + # reverse of ``g``. + + void nmod_poly_powers_mod_bsgs(nmod_poly_struct * res, const nmod_poly_t f, long n, const nmod_poly_t g) + # Set the entries of the array ``res`` to ``f^0, f^1, ..., f^(n-1) mod g``. + # No aliasing is permitted between the entries of ``res`` and either of the + # inputs. + + void _nmod_poly_divrem_basecase(mp_ptr Q, mp_ptr R, mp_srcptr A, long A_len, mp_srcptr B, long B_len, nmod_t mod) + # Finds `Q` and `R` such that `A = B Q + R` with `\operatorname{len}(R) < \operatorname{len}(B)`. + # If `\operatorname{len}(B) = 0` an exception is raised. We require that ``W`` + # is temporary space of ``NMOD_DIVREM_BC_ITCH(A_len, B_len, mod)`` + # coefficients. + + void nmod_poly_divrem_basecase(nmod_poly_t Q, nmod_poly_t R, const nmod_poly_t A, const nmod_poly_t B) + # Finds `Q` and `R` such that `A = B Q + R` with `\operatorname{len}(R) < \operatorname{len}(B)`. + # If `\operatorname{len}(B) = 0` an exception is raised. + + void _nmod_poly_divrem(mp_ptr Q, mp_ptr R, mp_srcptr A, long lenA, mp_srcptr B, long lenB, nmod_t mod) + # Computes `Q` and `R` such that `A = BQ + R` with `\operatorname{len}(R)` less than + # ``lenB``, where ``A`` is of length ``lenA`` and ``B`` is of + # length ``lenB``. We require that ``Q`` have space for + # ``lenA - lenB + 1`` coefficients. + + void nmod_poly_divrem(nmod_poly_t Q, nmod_poly_t R, const nmod_poly_t A, const nmod_poly_t B) + # Computes `Q` and `R` such that `A = BQ + R` with `\operatorname{len}(R) < \operatorname{len}(B)`. + + void _nmod_poly_div(mp_ptr Q, mp_srcptr A, long lenA, mp_srcptr B, long lenB, nmod_t mod) + # Notionally computes polynomials `Q` and `R` such that `A = BQ + R` with + # `\operatorname{len}(R)` less than ``lenB``, where ``A`` is of length ``lenA`` + # and ``B`` is of length ``lenB``, but returns only ``Q``. We + # require that ``Q`` have space for ``lenA - lenB + 1`` coefficients. + + void nmod_poly_div(nmod_poly_t Q, const nmod_poly_t A, const nmod_poly_t B) + # Computes the quotient `Q` on polynomial division of `A` and `B`. + + void _nmod_poly_rem_q1(mp_ptr R, mp_srcptr A, long lenA, mp_srcptr B, long lenB, nmod_t mod) + + void _nmod_poly_rem(mp_ptr R, mp_srcptr A, long lenA, mp_srcptr B, long lenB, nmod_t mod) + # Computes the remainder `R` on polynomial division of `A` by `B`. + + void nmod_poly_rem(nmod_poly_t R, const nmod_poly_t A, const nmod_poly_t B) + # Computes the remainder `R` on polynomial division of `A` by `B`. + + void _nmod_poly_inv_series_basecase(mp_ptr Qinv, mp_srcptr Q, long Qlen, long n, nmod_t mod) + # Given ``Q`` of length ``Qlen`` whose leading coefficient is invertible + # modulo the given modulus, finds a polynomial ``Qinv`` of length ``n`` + # such that the top ``n`` coefficients of the product ``Q * Qinv`` is + # `x^{n - 1}`. Requires that ``n > 0``. This function can be viewed as + # inverting a power series. + + void nmod_poly_inv_series_basecase(nmod_poly_t Qinv, const nmod_poly_t Q, long n) + # Given ``Q`` of length at least ``n`` find ``Qinv`` of length + # ``n`` such that the top ``n`` coefficients of the product + # ``Q * Qinv`` is `x^{n - 1}`. An exception is raised if ``n = 0`` + # or if the length of ``Q`` is less than ``n``. The leading + # coefficient of ``Q`` must be invertible modulo the modulus of + # ``Q``. This function can be viewed as inverting a power series. + + void _nmod_poly_inv_series_newton(mp_ptr Qinv, mp_srcptr Q, long Qlen, long n, nmod_t mod) + # Given ``Q`` of length ``Qlen`` whose constant coefficient is invertible + # modulo the given modulus, find a polynomial ``Qinv`` of length ``n`` + # such that ``Q * Qinv`` is ``1`` modulo `x^n`. Requires ``n > 0``. + # This function can be viewed as inverting a power series via Newton + # iteration. + + void nmod_poly_inv_series_newton(nmod_poly_t Qinv, const nmod_poly_t Q, long n) + # Given ``Q`` find ``Qinv`` such that ``Q * Qinv`` is ``1`` + # modulo `x^n`. The constant coefficient of ``Q`` must be invertible + # modulo the modulus of ``Q``. An exception is raised if this is not + # the case or if ``n = 0``. This function can be viewed as inverting + # a power series via Newton iteration. + + void _nmod_poly_inv_series(mp_ptr Qinv, mp_srcptr Q, long Qlen, long n, nmod_t mod) + # Given ``Q`` of length ``Qlenn`` whose constant coefficient is invertible + # modulo the given modulus, find a polynomial ``Qinv`` of length ``n`` + # such that ``Q * Qinv`` is ``1`` modulo `x^n`. Requires ``n > 0``. + # This function can be viewed as inverting a power series. + + void nmod_poly_inv_series(nmod_poly_t Qinv, const nmod_poly_t Q, long n) + # Given ``Q`` find ``Qinv`` such that ``Q * Qinv`` is ``1`` + # modulo `x^n`. The constant coefficient of ``Q`` must be invertible + # modulo the modulus of ``Q``. An exception is raised if this is not + # the case or if ``n = 0``. This function can be viewed as inverting + # a power series. + + void _nmod_poly_div_series_basecase(mp_ptr Q, mp_srcptr A, long Alen, mp_srcptr B, long Blen, long n, nmod_t mod) + # Given polynomials ``A`` and ``B`` of length ``Alen`` and + # ``Blen``, finds the + # polynomial ``Q`` of length ``n`` such that ``Q * B = A`` + # modulo `x^n`. We assume ``n > 0`` and that the constant coefficient + # of ``B`` is invertible modulo the given modulus. The polynomial + # ``Q`` must have space for ``n`` coefficients. + + void nmod_poly_div_series_basecase(nmod_poly_t Q, const nmod_poly_t A, const nmod_poly_t B, long n) + # Given polynomials ``A`` and ``B`` considered modulo ``n``, + # finds the polynomial ``Q`` of length at most ``n`` such that + # ``Q * B = A`` modulo `x^n`. We assume ``n > 0`` and that the + # constant coefficient of ``B`` is invertible modulo the modulus. + # An exception is raised if ``n == 0`` or the constant coefficient + # of ``B`` is zero. + + void _nmod_poly_div_series(mp_ptr Q, mp_srcptr A, long Alen, mp_srcptr B, long Blen, long n, nmod_t mod) + # Given polynomials ``A`` and ``B`` of length ``Alen`` and + # ``Blen``, finds the + # polynomial ``Q`` of length ``n`` such that ``Q * B = A`` + # modulo `x^n`. We assume ``n > 0`` and that the constant coefficient + # of ``B`` is invertible modulo the given modulus. The polynomial + # ``Q`` must have space for ``n`` coefficients. + + void nmod_poly_div_series(nmod_poly_t Q, const nmod_poly_t A, const nmod_poly_t B, long n) + # Given polynomials ``A`` and ``B`` considered modulo ``n``, + # finds the polynomial ``Q`` of length at most ``n`` such that + # ``Q * B = A`` modulo `x^n`. We assume ``n > 0`` and that the + # constant coefficient of ``B`` is invertible modulo the modulus. + # An exception is raised if ``n == 0`` or the constant coefficient + # of ``B`` is zero. + + void _nmod_poly_div_newton_n_preinv (mp_ptr Q, mp_srcptr A, long lenA, mp_srcptr B, long lenB, mp_srcptr Binv, long lenBinv, nmod_t mod) + # Notionally computes polynomials `Q` and `R` such that `A = BQ + R` with + # `\operatorname{len}(R)` less than ``lenB``, where ``A`` is of length ``lenA`` + # and ``B`` is of length ``lenB``, but return only `Q`. + # We require that `Q` have space for ``lenA - lenB + 1`` coefficients + # and assume that the leading coefficient of `B` is a unit. Furthermore, we + # assume that `Binv` is the inverse of the reverse of `B` mod `x^{\operatorname{len}(B)}`. + # The algorithm used is to reverse the polynomials and divide the + # resulting power series, then reverse the result. + + void nmod_poly_div_newton_n_preinv (nmod_poly_t Q, const nmod_poly_t A, const nmod_poly_t B, const nmod_poly_t Binv) + # Notionally computes `Q` and `R` such that `A = BQ + R` with + # `\operatorname{len}(R) < \operatorname{len}(B)`, but returns only `Q`. + # We assume that the leading coefficient of `B` is a unit and that `Binv` is + # the inverse of the reverse of `B` mod `x^{\operatorname{len}(B)}`. + # It is required that the length of `A` is less than or equal to + # 2*the length of `B` - 2. + # The algorithm used is to reverse the polynomials and divide the + # resulting power series, then reverse the result. + + void _nmod_poly_divrem_newton_n_preinv (mp_ptr Q, mp_ptr R, mp_srcptr A, long lenA, mp_srcptr B, long lenB, mp_srcptr Binv, long lenBinv, nmod_t mod) + # Computes `Q` and `R` such that `A = BQ + R` with `\operatorname{len}(R)` less than + # ``lenB``, where `A` is of length ``lenA`` and `B` is of length + # ``lenB``. We require that `Q` have space for ``lenA - lenB + 1`` + # coefficients. Furthermore, we assume that `Binv` is the inverse of the + # reverse of `B` mod `x^{\operatorname{len}(B)}`. The algorithm used is to call + # :func:`div_newton_n_preinv` and then multiply out and compute + # the remainder. + + void nmod_poly_divrem_newton_n_preinv(nmod_poly_t Q, nmod_poly_t R, const nmod_poly_t A, const nmod_poly_t B, const nmod_poly_t Binv) + # Computes `Q` and `R` such that `A = BQ + R` with `\operatorname{len}(R) < \operatorname{len}(B)`. + # We assume `Binv` is the inverse of the reverse of `B` mod `x^{\operatorname{len}(B)}`. + # It is required that the length of `A` is less than or equal to + # 2*the length of `B` - 2. + # The algorithm used is to call :func:`div_newton_n` and then multiply out + # and compute the remainder. + + mp_limb_t _nmod_poly_div_root(mp_ptr Q, mp_srcptr A, long len, mp_limb_t c, nmod_t mod) + # Sets ``(Q, len-1)`` to the quotient of ``(A, len)`` on division + # by `(x - c)`, and returns the remainder, equal to the value of `A` + # evaluated at `c`. `A` and `Q` are allowed to be the same, but may + # not overlap partially in any other way. + + mp_limb_t nmod_poly_div_root(nmod_poly_t Q, const nmod_poly_t A, mp_limb_t c) + # Sets `Q` to the quotient of `A` on division by `(x - c)`, and returns + # the remainder, equal to the value of `A` evaluated at `c`. + + int _nmod_poly_divides_classical(mp_ptr Q, mp_srcptr A, long lenA, mp_srcptr B, long lenB, nmod_t mod) + # Returns `1` if `(B, lenB)` divides `(A, lenA)` and sets + # `(Q, lenA - lenB + 1)` to the quotient. Otherwise, returns `0` and sets + # `(Q, lenA - lenB + 1)` to zero. We require that `lenA >= lenB > 0`. + + int nmod_poly_divides_classical(nmod_poly_t Q, const nmod_poly_t A, const nmod_poly_t B) + # Returns `1` if `B` divides `A` and sets `Q` to the quotient. Otherwise + # returns `0` and sets `Q` to zero. + + int _nmod_poly_divides(mp_ptr Q, mp_srcptr A, long lenA, mp_srcptr B, long lenB, nmod_t mod) + # Returns `1` if `(B, lenB)` divides `(A, lenA)` and sets + # `(Q, lenA - lenB + 1)` to the quotient. Otherwise, returns `0` and sets + # `(Q, lenA - lenB + 1)` to zero. We require that `lenA >= lenB > 0`. + + int nmod_poly_divides(nmod_poly_t Q, const nmod_poly_t A, const nmod_poly_t B) + # Returns `1` if `B` divides `A` and sets `Q` to the quotient. Otherwise + # returns `0` and sets `Q` to zero. + + void _nmod_poly_derivative(mp_ptr x_prime, mp_srcptr x, long len, nmod_t mod) + # Sets the first ``len - 1`` coefficients of ``x_prime`` to the + # derivative of ``x`` which is assumed to be of length ``len``. + # It is assumed that ``len > 0``. + + void nmod_poly_derivative(nmod_poly_t x_prime, const nmod_poly_t x) + # Sets ``x_prime`` to the derivative of ``x``. + + void _nmod_poly_integral(mp_ptr x_int, mp_srcptr x, long len, nmod_t mod) + # Set the first ``len`` coefficients of ``x_int`` to the + # integral of ``x`` which is assumed to be of length ``len - 1``. + # The constant term of ``x_int`` is set to zero. + # It is assumed that ``len > 0``. The result is only well-defined + # if the modulus is a prime number strictly larger than the degree of + # ``x``. Supports aliasing between the two polynomials. + + void nmod_poly_integral(nmod_poly_t x_int, const nmod_poly_t x) + # Set ``x_int`` to the indefinite integral of ``x`` with constant + # term zero. The result is only well-defined if the modulus + # is a prime number strictly larger than the degree of ``x``. + + mp_limb_t _nmod_poly_evaluate_nmod(mp_srcptr poly, long len, mp_limb_t c, nmod_t mod) + # Evaluates ``poly`` at the value~``c`` and reduces modulo the + # given modulus of ``poly``. The value~``c`` should be reduced + # modulo the modulus. The algorithm used is Horner's method. + + mp_limb_t nmod_poly_evaluate_nmod(const nmod_poly_t poly, mp_limb_t c) + # Evaluates ``poly`` at the value~``c`` and reduces modulo the + # modulus of ``poly``. The value~``c`` should be reduced modulo + # the modulus. The algorithm used is Horner's method. + + void nmod_poly_evaluate_mat_horner(nmod_mat_t dest, const nmod_poly_t poly, const nmod_mat_t c) + # Evaluates ``poly`` with matrix as an argument at the value ``c`` + # and stores the result in ``dest``. The dimension and modulus of + # ``dest`` is assumed to be same as that of ``c``. ``dest`` and + # ``c`` may be aliased. Horner's Method is used to compute the result. + + void nmod_poly_evaluate_mat_paterson_stockmeyer(nmod_mat_t dest, const nmod_poly_t poly, const nmod_mat_t c) + # Evaluates ``poly`` with matrix as an argument at the value ``c`` + # and stores the result in ``dest``. The dimension and modulus of + # ``dest`` is assumed to be same as that of ``c``. ``dest`` and + # ``c`` may be aliased. Paterson-Stockmeyer algorithm is used to compute + # the result. The algorithm is described in [Paterson1973]_. + + void nmod_poly_evaluate_mat(nmod_mat_t dest, const nmod_poly_t poly, const nmod_mat_t c) + # Evaluates ``poly`` with matrix as an argument at the value ``c`` + # and stores the result in ``dest``. The dimension and modulus of + # ``dest`` is assumed to be same as that of ``c``. ``dest`` and + # ``c`` may be aliased. This function automatically switches between + # Horner's method and the Paterson-Stockmeyer algorithm. + + void _nmod_poly_evaluate_nmod_vec_iter(mp_ptr ys, mp_srcptr poly, long len, mp_srcptr xs, long n, nmod_t mod) + # Evaluates (``coeffs``, ``len``) at the ``n`` values + # given in the vector ``xs``, writing the output values + # to ``ys``. The values in ``xs`` should be reduced + # modulo the modulus. + # Uses Horner's method iteratively. + + void nmod_poly_evaluate_nmod_vec_iter(mp_ptr ys, const nmod_poly_t poly, mp_srcptr xs, long n) + # Evaluates ``poly`` at the ``n`` values given in the vector + # ``xs``, writing the output values to ``ys``. The values in + # ``xs`` should be reduced modulo the modulus. + # Uses Horner's method iteratively. + + void _nmod_poly_evaluate_nmod_vec_fast_precomp(mp_ptr vs, mp_srcptr poly, long plen, const mp_ptr * tree, long len, nmod_t mod) + # Evaluates (``poly``, ``plen``) at the ``len`` values given + # by the precomputed subproduct tree ``tree``. + + void _nmod_poly_evaluate_nmod_vec_fast(mp_ptr ys, mp_srcptr poly, long len, mp_srcptr xs, long n, nmod_t mod) + # Evaluates (``coeffs``, ``len``) at the ``n`` values + # given in the vector ``xs``, writing the output values + # to ``ys``. The values in ``xs`` should be reduced + # modulo the modulus. + # Uses fast multipoint evaluation, building a temporary subproduct tree. + + void nmod_poly_evaluate_nmod_vec_fast(mp_ptr ys, const nmod_poly_t poly, mp_srcptr xs, long n) + # Evaluates ``poly`` at the ``n`` values given in the vector + # ``xs``, writing the output values to ``ys``. The values in + # ``xs`` should be reduced modulo the modulus. + # Uses fast multipoint evaluation, building a temporary subproduct tree. + + void _nmod_poly_evaluate_nmod_vec(mp_ptr ys, mp_srcptr poly, long len, mp_srcptr xs, long n, nmod_t mod) + # Evaluates (``poly``, ``len``) at the ``n`` values + # given in the vector ``xs``, writing the output values + # to ``ys``. The values in ``xs`` should be reduced + # modulo the modulus. + + void nmod_poly_evaluate_nmod_vec(mp_ptr ys, const nmod_poly_t poly, mp_srcptr xs, long n) + # Evaluates ``poly`` at the ``n`` values given in the vector + # ``xs``, writing the output values to ``ys``. The values in + # ``xs`` should be reduced modulo the modulus. + + void _nmod_poly_interpolate_nmod_vec(mp_ptr poly, mp_srcptr xs, mp_srcptr ys, long n, nmod_t mod) + # Sets ``poly`` to the unique polynomial of length at most ``n`` + # that interpolates the ``n`` given evaluation points ``xs`` and + # values ``ys``. If the interpolating polynomial is shorter than + # length ``n``, the leading coefficients are set to zero. + # The values in ``xs`` and ``ys`` should be reduced modulo the + # modulus, and all ``xs`` must be distinct. Aliasing between + # ``poly`` and ``xs`` or ``ys`` is not allowed. + + void nmod_poly_interpolate_nmod_vec(nmod_poly_t poly, mp_srcptr xs, mp_srcptr ys, long n) + # Sets ``poly`` to the unique polynomial of length ``n`` that + # interpolates the ``n`` given evaluation points ``xs`` and + # values ``ys``. The values in ``xs`` and ``ys`` should be + # reduced modulo the modulus, and all ``xs`` must be distinct. + + void _nmod_poly_interpolation_weights(mp_ptr w, const mp_ptr * tree, long len, nmod_t mod) + # Sets ``w`` to the barycentric interpolation weights for fast + # Lagrange interpolation with respect to a given subproduct tree. + + void _nmod_poly_interpolate_nmod_vec_fast_precomp(mp_ptr poly, mp_srcptr ys, const mp_ptr * tree, mp_srcptr weights, long len, nmod_t mod) + # Performs interpolation using the fast Lagrange interpolation + # algorithm, generating a temporary subproduct tree. + # The function values are given as ``ys``. The function takes + # a precomputed subproduct tree ``tree`` and barycentric + # interpolation weights ``weights`` corresponding to the + # roots. + + void _nmod_poly_interpolate_nmod_vec_fast(mp_ptr poly, mp_srcptr xs, mp_srcptr ys, long n, nmod_t mod) + # Performs interpolation using the fast Lagrange interpolation + # algorithm, generating a temporary subproduct tree. + + void nmod_poly_interpolate_nmod_vec_fast(nmod_poly_t poly, mp_srcptr xs, mp_srcptr ys, long n) + # Performs interpolation using the fast Lagrange interpolation algorithm, + # generating a temporary subproduct tree. + + void _nmod_poly_interpolate_nmod_vec_newton(mp_ptr poly, mp_srcptr xs, mp_srcptr ys, long n, nmod_t mod) + # Forms the interpolating polynomial in the Newton basis using + # the method of divided differences and then converts it to + # monomial form. + + void nmod_poly_interpolate_nmod_vec_newton(nmod_poly_t poly, mp_srcptr xs, mp_srcptr ys, long n) + # Forms the interpolating polynomial in the Newton basis using + # the method of divided differences and then converts it to + # monomial form. + + void _nmod_poly_interpolate_nmod_vec_barycentric(mp_ptr poly, mp_srcptr xs, mp_srcptr ys, long n, nmod_t mod) + # Forms the interpolating polynomial using a naive implementation + # of the barycentric form of Lagrange interpolation. + + void nmod_poly_interpolate_nmod_vec_barycentric(nmod_poly_t poly, mp_srcptr xs, mp_srcptr ys, long n) + # Forms the interpolating polynomial using a naive implementation + # of the barycentric form of Lagrange interpolation. + + void _nmod_poly_compose_horner(mp_ptr res, mp_srcptr poly1, long len1, mp_srcptr poly2, long len2, nmod_t mod) + # Composes ``poly1`` of length ``len1`` with ``poly2`` of length + # ``len2`` and sets ``res`` to the result, i.e.\ evaluates + # ``poly1`` at ``poly2``. The algorithm used is Horner's algorithm. + # We require that ``res`` have space for ``(len1 - 1)*(len2 - 1) + 1`` + # coefficients. It is assumed that ``len1 > 0`` and ``len2 > 0``. + + void nmod_poly_compose_horner(nmod_poly_t res, const nmod_poly_t poly1, const nmod_poly_t poly2) + # Composes ``poly1`` with ``poly2`` and sets ``res`` to the result, + # i.e.\ evaluates ``poly1`` at ``poly2``. The algorithm used is + # Horner's algorithm. + + void _nmod_poly_compose_divconquer(mp_ptr res, mp_srcptr poly1, long len1, mp_srcptr poly2, long len2, nmod_t mod) + # Composes ``poly1`` of length ``len1`` with ``poly2`` of length + # ``len2`` and sets ``res`` to the result, i.e.\ evaluates + # ``poly1`` at ``poly2``. The algorithm used is the divide and + # conquer algorithm. We require that ``res`` have space for + # ``(len1 - 1)*(len2 - 1) + 1`` coefficients. It is assumed that + # ``len1 > 0`` and ``len2 > 0``. + + void nmod_poly_compose_divconquer(nmod_poly_t res, const nmod_poly_t poly1, const nmod_poly_t poly2) + # Composes ``poly1`` with ``poly2`` and sets ``res`` to the result, + # i.e.\ evaluates ``poly1`` at ``poly2``. The algorithm used is + # the divide and conquer algorithm. + + void _nmod_poly_compose(mp_ptr res, mp_srcptr poly1, long len1, mp_srcptr poly2, long len2, nmod_t mod) + # Composes ``poly1`` of length ``len1`` with ``poly2`` of length + # ``len2`` and sets ``res`` to the result, i.e.\ evaluates ``poly1`` + # at ``poly2``. We require that ``res`` have space for + # ``(len1 - 1)*(len2 - 1) + 1`` coefficients. It is assumed that + # ``len1 > 0`` and ``len2 > 0``. + + void nmod_poly_compose(nmod_poly_t res, const nmod_poly_t poly1, const nmod_poly_t poly2) + # Composes ``poly1`` with ``poly2`` and sets ``res`` to the result, + # that is, evaluates ``poly1`` at ``poly2``. + + void _nmod_poly_taylor_shift_horner(mp_ptr poly, mp_limb_t c, long len, nmod_t mod) + # Performs the Taylor shift composing ``poly`` by `x+c` in-place. + # Uses an efficient version Horner's rule. + + void nmod_poly_taylor_shift_horner(nmod_poly_t g, const nmod_poly_t f, mp_limb_t c) + # Performs the Taylor shift composing ``f`` by `x+c`. + + void _nmod_poly_taylor_shift_convolution(mp_ptr poly, mp_limb_t c, long len, nmod_t mod) + # Performs the Taylor shift composing ``poly`` by `x+c` in-place. + # Writes the composition as a single convolution with cost `O(M(n))`. + # We require that the modulus is a prime at least as large as the length. + + void nmod_poly_taylor_shift_convolution(nmod_poly_t g, const nmod_poly_t f, mp_limb_t c) + # Performs the Taylor shift composing ``f`` by `x+c`. + # Writes the composition as a single convolution with cost `O(M(n))`. + # We require that the modulus is a prime at least as large as the length. + + void _nmod_poly_taylor_shift(mp_ptr poly, mp_limb_t c, long len, nmod_t mod) + # Performs the Taylor shift composing ``poly`` by `x+c` in-place. + # We require that the modulus is a prime. + + void nmod_poly_taylor_shift(nmod_poly_t g, const nmod_poly_t f, mp_limb_t c) + # Performs the Taylor shift composing ``f`` by `x+c`. + # We require that the modulus is a prime. + + void _nmod_poly_compose_mod_horner(mp_ptr res, mp_srcptr f, long lenf, mp_srcptr g, mp_srcptr h, long lenh, nmod_t mod) + # Sets ``res`` to the composition `f(g)` modulo `h`. We require that + # `h` is nonzero and that the length of `g` is one less than the + # length of `h` (possibly with zero padding). The output is not allowed + # to be aliased with any of the inputs. + # The algorithm used is Horner's rule. + + void nmod_poly_compose_mod_horner(nmod_poly_t res, const nmod_poly_t f, const nmod_poly_t g, const nmod_poly_t h) + # Sets ``res`` to the composition `f(g)` modulo `h`. We require that + # `h` is nonzero. The algorithm used is Horner's rule. + + void _nmod_poly_compose_mod_brent_kung(mp_ptr res, mp_srcptr f, long lenf, mp_srcptr g, mp_srcptr h, long lenh, nmod_t mod) + # Sets ``res`` to the composition `f(g)` modulo `h`. We require that + # `h` is nonzero and that the length of `g` is one less than the + # length of `h` (possibly with zero padding). We also require that + # the length of `f` is less than the length of `h`. The output is not allowed + # to be aliased with any of the inputs. + # The algorithm used is the Brent-Kung matrix algorithm. + + void nmod_poly_compose_mod_brent_kung(nmod_poly_t res, const nmod_poly_t f, const nmod_poly_t g, const nmod_poly_t h) + # Sets ``res`` to the composition `f(g)` modulo `h`. We require that + # `h` is nonzero and that `f` has smaller degree than `h`. + # The algorithm used is the Brent-Kung matrix algorithm. + + void _nmod_poly_compose_mod_brent_kung_preinv(mp_ptr res, mp_srcptr f, long lenf, mp_srcptr g, mp_srcptr h, long lenh, mp_srcptr hinv, long lenhinv, nmod_t mod) + # Sets ``res`` to the composition `f(g)` modulo `h`. We require that + # `h` is nonzero and that the length of `g` is one less than the + # length of `h` (possibly with zero padding). We also require that + # the length of `f` is less than the length of `h`. Furthermore, we require + # ``hinv`` to be the inverse of the reverse of ``h``. + # The output is not allowed to be aliased with any of the inputs. + # The algorithm used is the Brent-Kung matrix algorithm. + + void nmod_poly_compose_mod_brent_kung_preinv(nmod_poly_t res, const nmod_poly_t f, const nmod_poly_t g, const nmod_poly_t h, const nmod_poly_t hinv) + # Sets ``res`` to the composition `f(g)` modulo `h`. We require that + # `h` is nonzero and that `f` has smaller degree than `h`. Furthermore, + # we require ``hinv`` to be the inverse of the reverse of ``h``. + # The algorithm used is the Brent-Kung matrix algorithm. + + void _nmod_poly_reduce_matrix_mod_poly (nmod_mat_t A, const nmod_mat_t B, const nmod_poly_t f) + # Sets the ith row of ``A`` to the reduction of the ith row of `B` modulo + # `f` for `i=1,\ldots,\sqrt{\deg(f)}`. We require `B` to be at least + # a `\sqrt{\deg(f)}\times \deg(f)` matrix and `f` to be nonzero. + + void _nmod_poly_precompute_matrix_worker (void * arg_ptr) + # Worker function version of ``_nmod_poly_precompute_matrix``. + # Input/output is stored in ``nmod_poly_matrix_precompute_arg_t``. + + void _nmod_poly_precompute_matrix (nmod_mat_t A, mp_srcptr f, mp_srcptr g, long leng, mp_srcptr ginv, long lenginv, nmod_t mod) + # Sets the ith row of ``A`` to `f^i` modulo `g` for + # `i=1,\ldots,\sqrt{\deg(g)}`. We require `A` to be + # a `\sqrt{\deg(g)}\times \deg(g)` matrix. We require + # ``ginv`` to be the inverse of the reverse of ``g`` and `g` to be + # nonzero. ``f`` has to be reduced modulo ``g`` and of length one less + # than ``leng`` (possibly with zero padding). + + void nmod_poly_precompute_matrix (nmod_mat_t A, const nmod_poly_t f, const nmod_poly_t g, const nmod_poly_t ginv) + # Sets the ith row of ``A`` to `f^i` modulo `g` for + # `i=1,\ldots,\sqrt{\deg(g)}`. We require `A` to be + # a `\sqrt{\deg(g)}\times \deg(g)` matrix. We require + # ``ginv`` to be the inverse of the reverse of ``g``. + + void _nmod_poly_compose_mod_brent_kung_precomp_preinv_worker(void * arg_ptr) + # Worker function version of + # ``_nmod_poly_compose_mod_brent_kung_precomp_preinv``. + # Input/output is stored in + # ``nmod_poly_compose_mod_precomp_preinv_arg_t``. + + void _nmod_poly_compose_mod_brent_kung_precomp_preinv(mp_ptr res, mp_srcptr f, long lenf, const nmod_mat_t A, mp_srcptr h, long lenh, mp_srcptr hinv, long lenhinv, nmod_t mod) + # Sets ``res`` to the composition `f(g)` modulo `h`. We require that + # `h` is nonzero. We require that the ith row of `A` contains `g^i` for + # `i=1,\ldots,\sqrt{\deg(h)}`, i.e. `A` is a + # `\sqrt{\deg(h)}\times \deg(h)` matrix. We also require that + # the length of `f` is less than the length of `h`. Furthermore, we require + # ``hinv`` to be the inverse of the reverse of ``h``. + # The output is not allowed to be aliased with any of the inputs. + # The algorithm used is the Brent-Kung matrix algorithm. + + void nmod_poly_compose_mod_brent_kung_precomp_preinv(nmod_poly_t res, const nmod_poly_t f, const nmod_mat_t A, const nmod_poly_t h, const nmod_poly_t hinv) + # Sets ``res`` to the composition `f(g)` modulo `h`. We require that the + # ith row of `A` contains `g^i` for `i=1,\ldots,\sqrt{\deg(h)}`, i.e. `A` is a + # `\sqrt{\deg(h)}\times \deg(h)` matrix. We require that `h` is nonzero and + # that `f` has smaller degree than `h`. Furthermore, we require ``hinv`` to + # be the inverse of the reverse of ``h``. This version of Brent-Kung + # modular composition is particularly useful if one has to perform several + # modular composition of the form `f(g)` modulo `h` for fixed `g` and `h`. + + void _nmod_poly_compose_mod_brent_kung_vec_preinv(nmod_poly_struct * res, const nmod_poly_struct * polys, long len1, long l, mp_srcptr g, long leng, mp_srcptr h, long lenh, mp_srcptr hinv, long lenhinv, nmod_t mod) + # Sets ``res`` to the composition `f_i(g)` modulo `h` for `1\leq i \leq l`, + # where `f_i` are the first ``l`` elements of ``polys``. We require that `h` + # is nonzero and that the length of `g` is less than the length of `h`. We + # also require that the length of `f_i` is less than the length of `h`. We + # require ``res`` to have enough memory allocated to hold ``l`` + # ``nmod_poly_struct``'s. The entries of ``res`` need to be initialised and + # ``l`` needs to be less than ``len1`` Furthermore, we require ``hinv`` to + # be the inverse of the reverse of ``h``. The output is not allowed to be + # aliased with any of the inputs. + # The algorithm used is the Brent-Kung matrix algorithm. + + void nmod_poly_compose_mod_brent_kung_vec_preinv(nmod_poly_struct * res, const nmod_poly_struct * polys, long len1, long n, const nmod_poly_t g, const nmod_poly_t h, const nmod_poly_t hinv) + # Sets ``res`` to the composition `f_i(g)` modulo `h` for `1\leq i \leq n` + # where `f_i` are the first ``n`` elements of ``polys``. We require ``res`` + # to have enough memory allocated to hold ``n`` ``nmod_poly_struct``. The + # entries of ``res`` need to be initialised and ``n`` needs to be less than + # ``len1``. We require that `h` is nonzero and that `f_i` and `g` have + # smaller degree than `h`. Furthermore, we require ``hinv`` to be the inverse + # of the reverse of ``h``. No aliasing of ``res`` and ``polys`` is allowed. + # The algorithm used is the Brent-Kung matrix algorithm. + + void _nmod_poly_compose_mod_brent_kung_vec_preinv_threaded_pool(nmod_poly_struct * res, const nmod_poly_struct * polys, long lenpolys, long l, mp_srcptr g, long glen, mp_srcptr poly, long len, mp_srcptr polyinv, long leninv, nmod_t mod, thread_pool_handle * threads, long num_threads) + # Multithreaded version of + # :func:`_nmod_poly_compose_mod_brent_kung_vec_preinv`. Distributing the + # Horner evaluations across :func:`flint_get_num_threads` threads. + + void nmod_poly_compose_mod_brent_kung_vec_preinv_threaded_pool(nmod_poly_struct * res, const nmod_poly_struct * polys, long len1, long n, const nmod_poly_t g, const nmod_poly_t poly, const nmod_poly_t polyinv, thread_pool_handle * threads, long num_threads) + # Multithreaded version of + # :func:`nmod_poly_compose_mod_brent_kung_vec_preinv`. Distributing the + # Horner evaluations across :func:`flint_get_num_threads` threads. + + void nmod_poly_compose_mod_brent_kung_vec_preinv_threaded(nmod_poly_struct * res, const nmod_poly_struct * polys, long len1, long n, const nmod_poly_t g, const nmod_poly_t poly, const nmod_poly_t polyinv) + # Multithreaded version of + # :func:`nmod_poly_compose_mod_brent_kung_vec_preinv`. Distributing the + # Horner evaluations across :func:`flint_get_num_threads` threads. + + void _nmod_poly_compose_mod(mp_ptr res, mp_srcptr f, long lenf, mp_srcptr g, mp_srcptr h, long lenh, nmod_t mod) + # Sets ``res`` to the composition `f(g)` modulo `h`. We require that + # `h` is nonzero and that the length of `g` is one less than the + # length of `h` (possibly with zero padding). The output is not allowed + # to be aliased with any of the inputs. + + void nmod_poly_compose_mod(nmod_poly_t res, const nmod_poly_t f, const nmod_poly_t g, const nmod_poly_t h) + # Sets ``res`` to the composition `f(g)` modulo `h`. We require that + # `h` is nonzero. + + long _nmod_poly_gcd_euclidean(mp_ptr G, mp_srcptr A, long lenA, mp_srcptr B, long lenB, nmod_t mod) + # Computes the GCD of `A` of length ``lenA`` and `B` of length + # ``lenB``, where ``lenA >= lenB > 0``. The length of the GCD `G` + # is returned by the function. No attempt is made to make the GCD monic. It + # is required that `G` have space for ``lenB`` coefficients. + + void nmod_poly_gcd_euclidean(nmod_poly_t G, const nmod_poly_t A, const nmod_poly_t B) + # Computes the GCD of `A` and `B`. The GCD of zero polynomials is + # defined to be zero, whereas the GCD of the zero polynomial and some other + # polynomial `P` is defined to be `P`. Except in the case where + # the GCD is zero, the GCD `G` is made monic. + + long _nmod_poly_hgcd(mp_ptr *M, long *lenM, mp_ptr A, long *lenA, mp_ptr B, long *lenB, mp_srcptr a, long lena, mp_srcptr b, long lenb, nmod_t mod) + # Computes the HGCD of `a` and `b`, that is, a matrix~`M`, a sign~`\sigma` + # and two polynomials `A` and `B` such that + # .. math :: + # (A,B)^t = M^{-1} (a,b)^t, \sigma = \det(M), + # and `A` and `B` are consecutive remainders in the Euclidean remainder + # sequence for the division of `a` by `b` satisfying \deg(A) \ge \frac{\deg(a)}{2} > \deg(B). + # Furthermore, `M` will be the product of ``[[q 1][1 0]]`` for the quotients ``q`` generated by such a remainder sequence. + # Assumes that `\operatorname{len}(a) > \operatorname{len}(b) > 0`, i.e. `\deg(a) > `deg(b) > 1`. + # Assumes that `A` and `B` have space of size at least `\operatorname{len}(a)` + # and `\operatorname{len}(b)`, respectively. On exit, ``*lenA`` and ``*lenB`` + # will contain the correct lengths of `A` and `B`. + # Assumes that ``M[0]``, ``M[1]``, ``M[2]``, and ``M[3]`` + # each point to a vector of size at least `\operatorname{len}(a)`. + + long _nmod_poly_gcd_hgcd(mp_ptr G, mp_srcptr A, long lenA, mp_srcptr B, long lenB, nmod_t mod) + # Computes the monic GCD of `A` and `B`, assuming that + # `\operatorname{len}(A) \geq \operatorname{len}(B) > 0`. + # Assumes that `G` has space for `\operatorname{len}(B)` coefficients and + # returns the length of `G` on output. + + void nmod_poly_gcd_hgcd(nmod_poly_t G, const nmod_poly_t A, const nmod_poly_t B) + # Computes the monic GCD of `A` and `B` using the HGCD algorithm. + # As a special case, the GCD of two zero polynomials is defined to be + # the zero polynomial. + # The time complexity of the algorithm is `\mathcal{O}(n \log^2 n)`. + # For further details, see~[ThullYap1990]_. + + long _nmod_poly_gcd(mp_ptr G, mp_srcptr A, long lenA, mp_srcptr B, long lenB, nmod_t mod) + # Computes the GCD of `A` of length ``lenA`` and `B` of length + # ``lenB``, where ``lenA >= lenB > 0``. The length of the GCD `G` + # is returned by the function. No attempt is made to make the GCD monic. It + # is required that `G` have space for ``lenB`` coefficients. + + void nmod_poly_gcd(nmod_poly_t G, const nmod_poly_t A, const nmod_poly_t B) + # Computes the GCD of `A` and `B`. The GCD of zero polynomials is + # defined to be zero, whereas the GCD of the zero polynomial and some other + # polynomial `P` is defined to be `P`. Except in the case where + # the GCD is zero, the GCD `G` is made monic. + + long _nmod_poly_xgcd_euclidean(mp_ptr G, mp_ptr S, mp_ptr T, mp_srcptr A, long A_len, mp_srcptr B, long B_len, nmod_t mod) + # Computes the GCD of `A` and `B` together with cofactors `S` and `T` + # such that `S A + T B = G`. Returns the length of `G`. + # Assumes that `\operatorname{len}(A) \geq \operatorname{len}(B) \geq 1` and + # `(\operatorname{len}(A),\operatorname{len}(B)) \neq (1,1)`. + # No attempt is made to make the GCD monic. + # Requires that `G` have space for `\operatorname{len}(B)` coefficients. Writes + # `\operatorname{len}(B)-1` and `\operatorname{len}(A)-1` coefficients to `S` and `T`, respectively. + # Note that, in fact, `\operatorname{len}(S) \leq \max(\operatorname{len}(B) - \operatorname{len}(G), 1)` and + # `\operatorname{len}(T) \leq \max(\operatorname{len}(A) - \operatorname{len}(G), 1)`. + # No aliasing of input and output operands is permitted. + + void nmod_poly_xgcd_euclidean(nmod_poly_t G, nmod_poly_t S, nmod_poly_t T, const nmod_poly_t A, const nmod_poly_t B) + # Computes the GCD of `A` and `B`. The GCD of zero polynomials is + # defined to be zero, whereas the GCD of the zero polynomial and some other + # polynomial `P` is defined to be `P`. Except in the case where + # the GCD is zero, the GCD `G` is made monic. + # Polynomials ``S`` and ``T`` are computed such that + # ``S*A + T*B = G``. The length of ``S`` will be at most + # ``lenB`` and the length of ``T`` will be at most ``lenA``. + + long _nmod_poly_xgcd_hgcd(mp_ptr G, mp_ptr S, mp_ptr T, mp_srcptr A, long A_len, mp_srcptr B, long B_len, nmod_t mod) + # Computes the GCD of `A` and `B`, where `\operatorname{len}(A) \geq \operatorname{len}(B) > 0`, + # together with cofactors `S` and `T` such that `S A + T B = G`. Returns + # the length of `G`. + # No attempt is made to make the GCD monic. + # Requires that `G` have space for `\operatorname{len}(B)` coefficients. Writes + # `\operatorname{len}(B) - 1` and `\operatorname{len}(A) - 1` coefficients to `S` and `T`, + # respectively. Note that, in fact, `\operatorname{len}(S) \leq \operatorname{len}(B) - \operatorname{len}(G)` + # and `\operatorname{len}(T) \leq \operatorname{len}(A) - \operatorname{len}(G)`. + # Both `S` and `T` must have space for at least `2` coefficients. + # No aliasing of input and output operands is permitted. + + void nmod_poly_xgcd_hgcd(nmod_poly_t G, nmod_poly_t S, nmod_poly_t T, const nmod_poly_t A, const nmod_poly_t B) + # Computes the GCD of `A` and `B`. The GCD of zero polynomials is + # defined to be zero, whereas the GCD of the zero polynomial and some other + # polynomial `P` is defined to be `P`. Except in the case where + # the GCD is zero, the GCD `G` is made monic. + # Polynomials ``S`` and ``T`` are computed such that + # ``S*A + T*B = G``. The length of ``S`` will be at most + # ``lenB`` and the length of ``T`` will be at most ``lenA``. + + long _nmod_poly_xgcd(mp_ptr G, mp_ptr S, mp_ptr T, mp_srcptr A, long lenA, mp_srcptr B, long lenB, nmod_t mod) + # Computes the GCD of `A` and `B`, where `\operatorname{len}(A) \geq \operatorname{len}(B) > 0`, + # together with cofactors `S` and `T` such that `S A + T B = G`. Returns + # the length of `G`. + # No attempt is made to make the GCD monic. + # Requires that `G` have space for `\operatorname{len}(B)` coefficients. Writes + # `\operatorname{len}(B) - 1` and `\operatorname{len}(A) - 1` coefficients to `S` and `T`, + # respectively. Note that, in fact, `\operatorname{len}(S) \leq \operatorname{len}(B) - \operatorname{len}(G)` + # and `\operatorname{len}(T) \leq \operatorname{len}(A) - \operatorname{len}(G)`. + # No aliasing of input and output operands is permitted. + + void nmod_poly_xgcd(nmod_poly_t G, nmod_poly_t S, nmod_poly_t T, const nmod_poly_t A, const nmod_poly_t B) + # Computes the GCD of `A` and `B`. The GCD of zero polynomials is + # defined to be zero, whereas the GCD of the zero polynomial and some other + # polynomial `P` is defined to be `P`. Except in the case where + # the GCD is zero, the GCD `G` is made monic. + # The polynomials ``S`` and ``T`` are set such that + # ``S*A + T*B = G``. The length of ``S`` will be at most + # ``lenB`` and the length of ``T`` will be at most ``lenA``. + + mp_limb_t _nmod_poly_resultant_euclidean(mp_srcptr poly1, long len1, mp_srcptr poly2, long len2, nmod_t mod) + # Returns the resultant of ``(poly1, len1)`` and + # ``(poly2, len2)`` using the Euclidean algorithm. + # Assumes that ``len1 >= len2 > 0``. + # Assumes that the modulus is prime. + + mp_limb_t nmod_poly_resultant_euclidean(const nmod_poly_t f, const nmod_poly_t g) + # Computes the resultant of `f` and `g` using the Euclidean algorithm. + # For two non-zero polynomials `f(x) = a_m x^m + \dotsb + a_0` and + # `g(x) = b_n x^n + \dotsb + b_0` of degrees `m` and `n`, the resultant + # is defined to be + # .. math :: + # a_m^n b_n^m \prod_{(x, y) : f(x) = g(y) = 0} (x - y). + # For convenience, we define the resultant to be equal to zero if either + # of the two polynomials is zero. + + mp_limb_t _nmod_poly_resultant_hgcd(mp_srcptr poly1, long len1, mp_srcptr poly2, long len2, nmod_t mod) + # Returns the resultant of ``(poly1, len1)`` and + # ``(poly2, len2)`` using the half-gcd algorithm. + # This algorithm computes the half-gcd as per :func:`_nmod_poly_gcd_hgcd` + # but additionally updates the resultant every time a division occurs. The + # half-gcd algorithm computes the GCD recursively. Given inputs `a` and `b` + # it lets ``m = len(a)/2`` and (recursively) performs all quotients in + # the Euclidean algorithm which do not require the low `m` coefficients of + # `a` and `b`. + # This performs quotients in exactly the same order as the ordinary + # Euclidean algorithm except that the low `m` coefficients of the polynomials + # in the remainder sequence are not computed. A correction step after hgcd + # has been called computes these low `m` coefficients (by matrix + # multiplication by a transformation matrix also computed by hgcd). + # This means that from the point of view of the resultant, all but the last + # quotient performed by a recursive call to hgcd is an ordinary quotient as + # per the usual Euclidean algorithm. However, the final quotient may give + # a remainder of less than `m + 1` coefficients, which won't be corrected + # until the hgcd correction step is performed afterwards. + # To compute the adjustments to the resultant coming from this corrected + # quotient, we save the relevant information in an :type:`nmod_poly_res_t` + # struct at the time the quotient is performed so that when the correction + # step is performed later, the adjustments to the resultant can be computed + # at that time also. + # The only time an adjustment to the resultant is not required after a + # call to hgcd is if hgcd does nothing (the remainder may already have had + # less than `m + 1` coefficients when hgcd was called). + # Assumes that ``len1 >= len2 > 0``. + # Assumes that the modulus is prime. + + mp_limb_t nmod_poly_resultant_hgcd(const nmod_poly_t f, const nmod_poly_t g) + # Computes the resultant of `f` and `g` using the half-gcd algorithm. + # For two non-zero polynomials `f(x) = a_m x^m + \dotsb + a_0` and + # `g(x) = b_n x^n + \dotsb + b_0` of degrees `m` and `n`, the resultant + # is defined to be + # .. math :: + # a_m^n b_n^m \prod_{(x, y) : f(x) = g(y) = 0} (x - y). + # For convenience, we define the resultant to be equal to zero if either + # of the two polynomials is zero. + + mp_limb_t _nmod_poly_resultant(mp_srcptr poly1, long len1, mp_srcptr poly2, long len2, nmod_t mod) + # Returns the resultant of ``(poly1, len1)`` and + # ``(poly2, len2)``. + # Assumes that ``len1 >= len2 > 0``. + # Assumes that the modulus is prime. + + mp_limb_t nmod_poly_resultant(const nmod_poly_t f, const nmod_poly_t g) + # Computes the resultant of `f` and `g`. + # For two non-zero polynomials `f(x) = a_m x^m + \dotsb + a_0` and + # `g(x) = b_n x^n + \dotsb + b_0` of degrees `m` and `n`, the resultant + # is defined to be + # .. math :: + # a_m^n b_n^m \prod_{(x, y) : f(x) = g(y) = 0} (x - y). + # For convenience, we define the resultant to be equal to zero if either + # of the two polynomials is zero. + + long _nmod_poly_gcdinv(mp_limb_t *G, mp_limb_t *S, const mp_limb_t *A, long lenA, const mp_limb_t *B, long lenB, const nmod_t mod) + # Computes ``(G, lenA)``, ``(S, lenB-1)`` such that + # `G \cong S A \pmod{B}`, returning the actual length of `G`. + # Assumes that `0 < \operatorname{len}(A) < \operatorname{len}(B)`. + + void nmod_poly_gcdinv(nmod_poly_t G, nmod_poly_t S, const nmod_poly_t A, const nmod_poly_t B) + # Computes polynomials `G` and `S`, both reduced modulo~`B`, + # such that `G \cong S A \pmod{B}`, where `B` is assumed to + # have `\operatorname{len}(B) \geq 2`. + # In the case that `A = 0 \pmod{B}`, returns `G = S = 0`. + + int _nmod_poly_invmod(mp_limb_t *A, const mp_limb_t *B, long lenB, const mp_limb_t *P, long lenP, const nmod_t mod) + # Attempts to set ``(A, lenP-1)`` to the inverse of ``(B, lenB)`` + # modulo the polynomial ``(P, lenP)``. Returns `1` if ``(B, lenB)`` + # is invertible and `0` otherwise. + # Assumes that `0 < \operatorname{len}(B) < \operatorname{len}(P)`, and hence also `\operatorname{len}(P) \geq 2`, + # but supports zero-padding in ``(B, lenB)``. + # Does not support aliasing. + # Assumes that `mod` is a prime number. + + int nmod_poly_invmod(nmod_poly_t A, const nmod_poly_t B, const nmod_poly_t P) + # Attempts to set `A` to the inverse of `B` modulo `P` in the polynomial + # ring `(\mathbf{Z}/p\mathbf{Z})[X]`, where we assume that `p` is a prime + # number. + # If `\operatorname{len}(P) < 2`, raises an exception. + # If the greatest common divisor of `B` and `P` is~`1`, returns~`1` and + # sets `A` to the inverse of `B`. Otherwise, returns~`0` and the value + # of `A` on exit is undefined. + + mp_limb_t _nmod_poly_discriminant(mp_srcptr poly, long len, nmod_t mod) + # Return the discriminant of ``(poly, len)``. Assumes ``len > 1``. + + mp_limb_t nmod_poly_discriminant(const nmod_poly_t f) + # Return the discriminant of `f`. + # We normalise the discriminant so that + # `\operatorname{disc}(f) = (-1)^(n(n-1)/2) \operatorname{res}(f, f') / + # \operatorname{lc}(f)^(n - m - 2)`, where ``n = len(f)`` and + # ``m = len(f')``. Thus `\operatorname{disc}(f) = + # \operatorname{lc}(f)^(2n - 2) \prod_{i < j} (r_i - r_j)^2`, where + # `\operatorname{lc}(f)` is the leading coefficient of `f` and `r_i` are the + # roots of `f`. + + void _nmod_poly_compose_series(mp_ptr res, mp_srcptr poly1, long len1, mp_srcptr poly2, long len2, long n, nmod_t mod) + # Sets ``res`` to the composition of ``poly1`` and ``poly2`` + # modulo `x^n`, where the constant term of ``poly2`` is required + # to be zero. + # Assumes that ``len1, len2, n > 0``, that ``len1, len2 <= n``, + # and that\\ ``(len1-1) * (len2-1) + 1 <= n``, and that ``res`` has + # space for ``n`` coefficients. Does not support aliasing between any + # of the inputs and the output. + # Wraps :func:`_gr_poly_compose_series` which chooses automatically + # between various algorithms. + + void nmod_poly_compose_series(nmod_poly_t res, const nmod_poly_t poly1, const nmod_poly_t poly2, long n) + # Sets ``res`` to the composition of ``poly1`` and ``poly2`` + # modulo `x^n`, where the constant term of ``poly2`` is required + # to be zero. + + void _nmod_poly_revert_series_lagrange(mp_ptr Qinv, mp_srcptr Q, long n, nmod_t mod) + # Sets ``Qinv`` to the compositional inverse or reversion of ``Q`` + # as a power series, i.e. computes `Q^{-1}` such that + # `Q(Q^{-1}(x)) = Q^{-1}(Q(x)) = x \bmod x^n`. The arguments must + # both have length ``n`` and may not be aliased. + # It is required that `Q_0 = 0` and that `Q_1` as well as the integers + # `1, 2, \ldots, n-1` are invertible modulo the modulus. + # This implementation uses the Lagrange inversion formula. + + void nmod_poly_revert_series_lagrange(nmod_poly_t Qinv, const nmod_poly_t Q, long n) + # Sets ``Qinv`` to the compositional inverse or reversion of ``Q`` + # as a power series, i.e. computes `Q^{-1}` such that + # `Q(Q^{-1}(x)) = Q^{-1}(Q(x)) = x \bmod x^n`. + # It is required that `Q_0 = 0` and that `Q_1` as well as the integers + # `1, 2, \ldots, n-1` are invertible modulo the modulus. + # This implementation uses the Lagrange inversion formula. + + void _nmod_poly_revert_series_lagrange_fast(mp_ptr Qinv, mp_srcptr Q, long n, nmod_t mod) + # Sets ``Qinv`` to the compositional inverse or reversion of ``Q`` + # as a power series, i.e. computes `Q^{-1}` such that + # `Q(Q^{-1}(x)) = Q^{-1}(Q(x)) = x \bmod x^n`. The arguments must + # both have length ``n`` and may not be aliased. + # It is required that `Q_0 = 0` and that `Q_1` as well as the integers + # `1, 2, \ldots, n-1` are invertible modulo the modulus. + # This implementation uses a reduced-complexity implementation + # of the Lagrange inversion formula. + + void nmod_poly_revert_series_lagrange_fast(nmod_poly_t Qinv, const nmod_poly_t Q, long n) + # Sets ``Qinv`` to the compositional inverse or reversion of ``Q`` + # as a power series, i.e. computes `Q^{-1}` such that + # `Q(Q^{-1}(x)) = Q^{-1}(Q(x)) = x \bmod x^n`. + # It is required that `Q_0 = 0` and that `Q_1` as well as the integers + # `1, 2, \ldots, n-1` are invertible modulo the modulus. + # This implementation uses a reduced-complexity implementation + # of the Lagrange inversion formula. + + void _nmod_poly_revert_series_newton(mp_ptr Qinv, mp_srcptr Q, long n, nmod_t mod) + # Sets ``Qinv`` to the compositional inverse or reversion of ``Q`` + # as a power series, i.e. computes `Q^{-1}` such that + # `Q(Q^{-1}(x)) = Q^{-1}(Q(x)) = x \bmod x^n`. The arguments must + # both have length ``n`` and may not be aliased. + # It is required that `Q_0 = 0` and that `Q_1` as well as the integers + # `1, 2, \ldots, n-1` are invertible modulo the modulus. + # This implementation uses Newton iteration [BrentKung1978]_. + + void nmod_poly_revert_series_newton(nmod_poly_t Qinv, const nmod_poly_t Q, long n) + # Sets ``Qinv`` to the compositional inverse or reversion of ``Q`` + # as a power series, i.e. computes `Q^{-1}` such that + # `Q(Q^{-1}(x)) = Q^{-1}(Q(x)) = x \bmod x^n`. + # It is required that `Q_0 = 0` and that `Q_1` as well as the integers + # `1, 2, \ldots, n-1` are invertible modulo the modulus. + # This implementation uses Newton iteration [BrentKung1978]_. + + void _nmod_poly_revert_series(mp_ptr Qinv, mp_srcptr Q, long n, nmod_t mod) + # Sets ``Qinv`` to the compositional inverse or reversion of ``Q`` + # as a power series, i.e. computes `Q^{-1}` such that + # `Q(Q^{-1}(x)) = Q^{-1}(Q(x)) = x \bmod x^n`. The arguments must + # both have length ``n`` and may not be aliased. + # It is required that `Q_0 = 0` and that `Q_1` as well as the integers + # `1, 2, \ldots, n-1` are invertible modulo the modulus. + # This implementation automatically chooses between the Lagrange + # inversion formula and Newton iteration based on the size of the + # input. + + void nmod_poly_revert_series(nmod_poly_t Qinv, const nmod_poly_t Q, long n) + # Sets ``Qinv`` to the compositional inverse or reversion of ``Q`` + # as a power series, i.e. computes `Q^{-1}` such that + # `Q(Q^{-1}(x)) = Q^{-1}(Q(x)) = x \bmod x^n`. + # It is required that `Q_0 = 0` and that `Q_1` as well as the integers + # `1, 2, \ldots, n-1` are invertible modulo the modulus. + # This implementation automatically chooses between the Lagrange + # inversion formula and Newton iteration based on the size of the + # input. + + void _nmod_poly_invsqrt_series(mp_ptr g, mp_srcptr h, long hlen, long n, nmod_t mod) + # Set the first `n` terms of `g` to the series expansion of `1/\sqrt{h}`. + # It is assumed that `n > 0`, that `h` has constant term 1. Aliasing is not permitted. + + void nmod_poly_invsqrt_series(nmod_poly_t g, const nmod_poly_t h, long n) + # Set `g` to the series expansion of `1/\sqrt{h}` to order `O(x^n)`. + # It is assumed that `h` has constant term 1. + + void _nmod_poly_sqrt_series(mp_ptr g, mp_srcptr h, long hlen, long n, nmod_t mod) + # Set the first `n` terms of `g` to the series expansion of `\sqrt{h}`. + # It is assumed that `n > 0`, that `h` has constant term 1. Aliasing is not permitted. + + void nmod_poly_sqrt_series(nmod_poly_t g, const nmod_poly_t h, long n) + # Set `g` to the series expansion of `\sqrt{h}` to order `O(x^n)`. + # It is assumed that `h` has constant term 1. + + int _nmod_poly_sqrt(mp_ptr s, mp_srcptr p, long n, nmod_t mod) + # If ``(p, n)`` is a perfect square, sets ``(s, n / 2 + 1)`` + # to a square root of `p` and returns 1. Otherwise returns 0. + + int nmod_poly_sqrt(nmod_poly_t s, const nmod_poly_t p) + # If `p` is a perfect square, sets `s` to a square root of `p` + # and returns 1. Otherwise returns 0. + + void _nmod_poly_power_sums_naive(mp_ptr res, mp_srcptr poly, long len, long n, nmod_t mod) + # Compute the (truncated) power sums series of the polynomial + # ``(poly,len)`` up to length `n` using Newton identities. + + void nmod_poly_power_sums_naive(nmod_poly_t res, const nmod_poly_t poly, long n) + # Compute the (truncated) power sum series of the polynomial + # ``poly`` up to length `n` using Newton identities. + + void _nmod_poly_power_sums_schoenhage(mp_ptr res, mp_srcptr poly, long len, long n, nmod_t mod) + # Compute the (truncated) power sums series of the polynomial + # ``(poly,len)`` up to length `n` using a series expansion + # (a formula due to Schoenhage). + + void nmod_poly_power_sums_schoenhage(nmod_poly_t res, const nmod_poly_t poly, long n) + # Compute the (truncated) power sums series of the polynomial + # ``poly`` up to length `n` using a series expansion + # (a formula due to Schoenhage). + + void _nmod_poly_power_sums(mp_ptr res, mp_srcptr poly, long len, long n, nmod_t mod) + # Compute the (truncated) power sums series of the polynomial + # ``(poly,len)`` up to length `n`. + + void nmod_poly_power_sums(nmod_poly_t res, const nmod_poly_t poly, long n) + # Compute the (truncated) power sums series of the polynomial + # ``poly`` up to length `n`. + + void _nmod_poly_power_sums_to_poly_naive(mp_ptr res, mp_srcptr poly, long len, nmod_t mod) + # Compute the (monic) polynomial given by its power sums series + # ``(poly,len)`` using Newton identities. + + void nmod_poly_power_sums_to_poly_naive(nmod_poly_t res, const nmod_poly_t Q) + # Compute the (monic) polynomial given by its power sums series + # ``Q`` using Newton identities. + + void _nmod_poly_power_sums_to_poly_schoenhage(mp_ptr res, mp_srcptr poly, long len, nmod_t mod) + # Compute the (monic) polynomial given by its power sums series + # ``(poly,len)`` using series expansion (a formula due to Schoenhage). + + void nmod_poly_power_sums_to_poly_schoenhage(nmod_poly_t res, const nmod_poly_t Q) + # Compute the (monic) polynomial given by its power sums series + # ``Q`` using series expansion (a formula due to Schoenhage). + + void _nmod_poly_power_sums_to_poly(mp_ptr res, mp_srcptr poly, long len, nmod_t mod) + # Compute the (monic) polynomial given by its power sums series + # ``(poly,len)``. + + void nmod_poly_power_sums_to_poly(nmod_poly_t res, const nmod_poly_t Q) + # Compute the (monic) polynomial given by its power sums series ``Q``. + + void _nmod_poly_log_series(mp_ptr g, mp_srcptr h, long hlen, long n, nmod_t mod) + # Set `g = \log(h) + O(x^n)`. Assumes `n > 0` and ``hlen > 0``. + # Aliasing of `g` and `h` is allowed. + + void nmod_poly_log_series(nmod_poly_t g, const nmod_poly_t h, long n) + # Set `g = \log(h) + O(x^n)`. The case `h = 1+cx^r` is automatically + # detected and handled efficiently. + + void _nmod_poly_exp_series(mp_ptr f, mp_srcptr h, long hlen, long n, nmod_t mod) + # Set `f = \exp(h) + O(x^n)` where ``h`` is a polynomial. Assume + # `n > 0`. Aliasing of `g` and `h` is not allowed. + # Uses Newton iteration (an improved version of the + # algorithm in [HanZim2004]_). + # For small `n`, falls back to the basecase algorithm. + + void _nmod_poly_exp_expinv_series(mp_ptr f, mp_ptr g, mp_srcptr h, long hlen, long n, nmod_t mod) + # Set `f = \exp(h) + O(x^n)` and `g = \exp(-h) + O(x^n)`, more efficiently + # for large `n` than performing a separate inversion to obtain `g`. + # Assumes `n > 0` and that `h` is zero-padded + # as necessary to length `n`. Aliasing is not allowed. + # Uses Newton iteration (the version given in [HanZim2004]_). + # For small `n`, falls back to the basecase algorithm. + + void nmod_poly_exp_series(nmod_poly_t g, const nmod_poly_t h, long n) + # Set `g = \exp(h) + O(x^n)`. The case `h = cx^r` is automatically + # detected and handled efficiently. Otherwise this function automatically + # uses the basecase algorithm for small `n` and Newton iteration otherwise. + + void _nmod_poly_atan_series(mp_ptr g, mp_srcptr h, long hlen, long n, nmod_t mod) + # Set `g = \operatorname{atan}(h) + O(x^n)`. Assumes `n > 0`. + # Aliasing of `g` and `h` is allowed. + + void nmod_poly_atan_series(nmod_poly_t g, const nmod_poly_t h, long n) + # Set `g = \operatorname{atan}(h) + O(x^n)`. + + void _nmod_poly_atanh_series(mp_ptr g, mp_srcptr h, long hlen, long n, nmod_t mod) + # Set `g = \operatorname{atanh}(h) + O(x^n)`. Assumes `n > 0`. + # Aliasing of `g` and `h` is allowed. + + void nmod_poly_atanh_series(nmod_poly_t g, const nmod_poly_t h, long n) + # Set `g = \operatorname{atanh}(h) + O(x^n)`. + + void _nmod_poly_asin_series(mp_ptr g, mp_srcptr h, long hlen, long n, nmod_t mod) + # Set `g = \operatorname{asin}(h) + O(x^n)`. Assumes `n > 0`. + # Aliasing of `g` and `h` is allowed. + + void nmod_poly_asin_series(nmod_poly_t g, const nmod_poly_t h, long n) + # Set `g = \operatorname{asin}(h) + O(x^n)`. + + void _nmod_poly_asinh_series(mp_ptr g, mp_srcptr h, long hlen, long n, nmod_t mod) + # Set `g = \operatorname{asinh}(h) + O(x^n)`. Assumes `n > 0`. + # Aliasing of `g` and `h` is allowed. + + void nmod_poly_asinh_series(nmod_poly_t g, const nmod_poly_t h, long n) + # Set `g = \operatorname{asinh}(h) + O(x^n)`. + + void _nmod_poly_sin_series(mp_ptr g, mp_srcptr h, long n, nmod_t mod) + # Set `g = \operatorname{sin}(h) + O(x^n)`. Assumes `n > 0` and that `h` + # is zero-padded as necessary to length `n`. Aliasing of `g` and `h` is + # allowed. The value is computed using the identity + # `\sin(x) = 2 \tan(x/2)) / (1 + \tan^2(x/2)).` + + void nmod_poly_sin_series(nmod_poly_t g, const nmod_poly_t h, long n) + # Set `g = \operatorname{sin}(h) + O(x^n)`. + + void _nmod_poly_cos_series(mp_ptr g, mp_srcptr h, long n, nmod_t mod) + # Set `g = \operatorname{cos}(h) + O(x^n)`. Assumes `n > 0` and that `h` + # is zero-padded as necessary to length `n`. Aliasing of `g` and `h` is + # allowed. The value is computed using the identity + # `\cos(x) = (1-\tan^2(x/2)) / (1 + \tan^2(x/2)).` + + void nmod_poly_cos_series(nmod_poly_t g, const nmod_poly_t h, long n) + # Set `g = \operatorname{cos}(h) + O(x^n)`. + + void _nmod_poly_tan_series(mp_ptr g, mp_srcptr h, long hlen, long n, nmod_t mod) + # Set `g = \operatorname{tan}(h) + O(x^n)`. Assumes `n > 0` and that `h` + # is zero-padded as necessary to length `n`. Aliasing of `g` and `h` is + # not allowed. Uses Newton iteration to invert the atan function. + + void nmod_poly_tan_series(nmod_poly_t g, const nmod_poly_t h, long n) + # Set `g = \operatorname{tan}(h) + O(x^n)`. + + void _nmod_poly_sinh_series(mp_ptr g, mp_srcptr h, long n, nmod_t mod) + # Set `g = \operatorname{sinh}(h) + O(x^n)`. Assumes `n > 0` and that `h` + # is zero-padded as necessary to length `n`. Aliasing of `g` and `h` is + # not allowed. Uses the identity `\sinh(x) = (e^x - e^{-x})/2`. + + void nmod_poly_sinh_series(nmod_poly_t g, const nmod_poly_t h, long n) + # Set `g = \operatorname{sinh}(h) + O(x^n)`. + + void _nmod_poly_cosh_series(mp_ptr g, mp_srcptr h, long n, nmod_t mod) + # Set `g = \operatorname{cos}(h) + O(x^n)`. Assumes `n > 0` and that `h` + # is zero-padded as necessary to length `n`. Aliasing of `g` and `h` is + # not allowed. + # Uses the identity `\cosh(x) = (e^x + e^{-x})/2`. + + void nmod_poly_cosh_series(nmod_poly_t g, const nmod_poly_t h, long n) + # Set `g = \operatorname{cosh}(h) + O(x^n)`. + + void _nmod_poly_tanh_series(mp_ptr g, mp_srcptr h, long n, nmod_t mod) + # Set `g = \operatorname{tanh}(h) + O(x^n)`. Assumes `n > 0` and that `h` + # is zero-padded as necessary to length `n`. Uses the identity + # `\tanh(x) = (e^{2x}-1)/(e^{2x}+1)`. + + void nmod_poly_tanh_series(nmod_poly_t g, const nmod_poly_t h, long n) + # Set `g = \operatorname{tanh}(h) + O(x^n)`. + + void _nmod_poly_product_roots_nmod_vec(mp_ptr poly, mp_srcptr xs, long n, nmod_t mod) + # Sets ``(poly, n + 1)`` to the monic polynomial which is the product + # of `(x - x_0)(x - x_1) \cdots (x - x_{n-1})`, the roots `x_i` being + # given by ``xs``. + # Aliasing of the input and output is not allowed. + + void nmod_poly_product_roots_nmod_vec(nmod_poly_t poly, mp_srcptr xs, long n) + # Sets ``poly`` to the monic polynomial which is the product + # of `(x - x_0)(x - x_1) \cdots (x - x_{n-1})`, the roots `x_i` being + # given by ``xs``. + + int nmod_poly_find_distinct_nonzero_roots(mp_limb_t * roots, const nmod_poly_t A) + # If ``A`` has `\deg(A)` distinct nonzero roots in `\mathbb{F}_p`, write these roots out to ``roots[0]`` to ``roots[deg(A) - 1]`` and return ``1``. + # Otherwise, return ``0``. It is assumed that ``A`` is nonzero and that the modulus of ``A`` is prime. + # This function uses Rabin's probabilistic method via gcd's with `(x + \delta)^{\frac{p-1}{2}} - 1`. + + mp_ptr * _nmod_poly_tree_alloc(long len) + # Allocates space for a subproduct tree of the given length, having + # linear factors at the lowest level. + # Entry `i` in the tree is a pointer to a single array of limbs, + # capable of storing `\lfloor n / 2^i \rfloor` subproducts of + # degree `2^i` adjacently, plus a trailing entry if `n / 2^i` is + # not an integer. + # For example, a tree of length 7 built from monic linear factors has + # the following structure, where spaces have been inserted + # for illustrative purposes:: + # X1 X1 X1 X1 X1 X1 X1 + # XX1 XX1 XX1 X1 + # XXXX1 XX1 X1 + # XXXXXXX1 + + void _nmod_poly_tree_free(mp_ptr * tree, long len) + # Free the allocated space for the subproduct. + + void _nmod_poly_tree_build(mp_ptr * tree, mp_srcptr roots, long len, nmod_t mod) + # Builds a subproduct tree in the preallocated space from + # the ``len`` monic linear factors `(x-r_i)`. The top level + # product is not computed. + + void nmod_poly_inflate(nmod_poly_t result, const nmod_poly_t input, unsigned long inflation) + # Sets ``result`` to the inflated polynomial `p(x^n)` where + # `p` is given by ``input`` and `n` is given by ``deflation``. + + void nmod_poly_deflate(nmod_poly_t result, const nmod_poly_t input, unsigned long deflation) + # Sets ``result`` to the deflated polynomial `p(x^{1/n})` where + # `p` is given by ``input`` and `n` is given by ``deflation``. + # Requires `n > 0`. + + unsigned long nmod_poly_deflation(const nmod_poly_t input) + # Returns the largest integer by which ``input`` can be deflated. + # As special cases, returns 0 if ``input`` is the zero polynomial + # and 1 of ``input`` is a constant polynomial. + + void nmod_poly_multi_crt_init(nmod_poly_multi_crt_t CRT) + # Initialize ``CRT`` for Chinese remaindering. + + int nmod_poly_multi_crt_precompute(nmod_poly_multi_crt_t CRT, const nmod_poly_struct * moduli, long len) + int nmod_poly_multi_crt_precompute_p(nmod_poly_multi_crt_t CRT, const nmod_poly_struct * const * moduli, long len) + # Configure ``CRT`` for repeated Chinese remaindering of ``moduli``. The number of moduli, ``len``, should be positive. + # A return of ``0`` indicates that the compilation failed and future calls to :func:`nmod_poly_multi_crt_precomp` will leave the output undefined. + # A return of ``1`` indicates that the compilation was successful, which occurs if and only if either (1) ``len == 1`` and ``modulus + 0`` is nonzero, or (2) all of the moduli have positive degree and are pairwise relatively prime. + + void nmod_poly_multi_crt_precomp(nmod_poly_t output, const nmod_poly_multi_crt_t CRT, const nmod_poly_struct * values) + void nmod_poly_multi_crt_precomp_p(nmod_poly_t output, const nmod_poly_multi_crt_t CRT, const nmod_poly_struct * const * values) + # Set ``output`` to the polynomial of lowest possible degree that is congruent to ``values + i`` modulo the ``moduli + i`` in :func:`nmod_poly_multi_crt_precompute`. + # The inputs ``values + 0, ..., values + len - 1`` where ``len`` was used in :func:`nmod_poly_multi_crt_precompute` are expected to be valid and have modulus matching the modulus of the moduli used in :func:`nmod_poly_multi_crt_precompute`. + + int nmod_poly_multi_crt(nmod_poly_t output, const nmod_poly_struct * moduli, const nmod_poly_struct * values, long len) + # Perform the same operation as :func:`nmod_poly_multi_crt_precomp` while internally constructing and destroying the precomputed data. + # All of the remarks in :func:`nmod_poly_multi_crt_precompute` apply. + + void nmod_poly_multi_crt_clear(nmod_poly_multi_crt_t CRT) + # Free all space used by ``CRT``. + + long _nmod_poly_multi_crt_local_size(const nmod_poly_multi_crt_t CRT) + # Return the required length of the output for :func:`_nmod_poly_multi_crt_run`. + + void _nmod_poly_multi_crt_run(nmod_poly_struct * outputs, const nmod_poly_multi_crt_t CRT, const nmod_poly_struct * inputs) + void _nmod_poly_multi_crt_run_p(nmod_poly_struct * outputs, const nmod_poly_multi_crt_t CRT, const nmod_poly_struct * const * inputs) + # Perform the same operation as :func:`nmod_poly_multi_crt_precomp` using supplied temporary space. + # The actual output is placed in ``outputs + 0``, and ``outputs`` should contain space for all temporaries and should be at least as long as ``_nmod_poly_multi_crt_local_size(CRT)``. + # Of course the moduli of these temporaries should match the modulus of the inputs. + + void nmod_berlekamp_massey_init(nmod_berlekamp_massey_t B, mp_limb_t p) + # Initialize ``B`` in characteristic ``p`` with an empty stream. + + void nmod_berlekamp_massey_clear(nmod_berlekamp_massey_t B) + # Free any space used by ``B``. + + void nmod_berlekamp_massey_start_over(nmod_berlekamp_massey_t B) + # Empty the stream of points in ``B``. + + void nmod_berlekamp_massey_set_prime(nmod_berlekamp_massey_t B, mp_limb_t p) + # Set the characteristic of the field and empty the stream of points in ``B``. + + void nmod_berlekamp_massey_add_points(nmod_berlekamp_massey_t B, const mp_limb_t * a, long count) + void nmod_berlekamp_massey_add_zeros(nmod_berlekamp_massey_t B, long count) + void nmod_berlekamp_massey_add_point(nmod_berlekamp_massey_t B, mp_limb_t a) + # Add point(s) to the stream processed by ``B``. The addition of any number of points will not update the `V` and `R` polynomial. + + int nmod_berlekamp_massey_reduce(nmod_berlekamp_massey_t B) + # Ensure that the polynomials `V` and `R` are up to date. The return value is ``1`` if this function changed `V` and ``0`` otherwise. + # For example, if this function is called twice in a row without adding any points in between, the return of the second call should be ``0``. + # As another example, suppose the object is emptied, the points `1, 1, 2, 3` are added, then reduce is called. This reduce should return ``1`` with `\deg(R) < \deg(V) = 2` because the Fibonacci sequence has been recognized. The further addition of the two points `5, 8` and a reduce will result in a return value of ``0``. + + long nmod_berlekamp_massey_point_count(const nmod_berlekamp_massey_t B) + # Return the number of points stored in ``B``. + + const mp_limb_t * nmod_berlekamp_massey_points(const nmod_berlekamp_massey_t B) + # Return a pointer to the array of points stored in ``B``. This may be ``NULL`` if :func:`nmod_berlekamp_massey_point_count` returns ``0``. + + const nmod_poly_struct * nmod_berlekamp_massey_V_poly(const nmod_berlekamp_massey_t B) + # Return the polynomial `V` in ``B``. + + const nmod_poly_struct * nmod_berlekamp_massey_R_poly(const nmod_berlekamp_massey_t B) + # Return the polynomial `R` in ``B``. diff --git a/src/sage/libs/flint/nmod_poly_factor.pxd b/src/sage/libs/flint/nmod_poly_factor.pxd new file mode 100644 index 00000000000..93442d54682 --- /dev/null +++ b/src/sage/libs/flint/nmod_poly_factor.pxd @@ -0,0 +1,162 @@ +# distutils: libraries = flint +# distutils: depends = flint/nmod_poly_factor.h + +################################################################################ +# This file is auto-generated. Do not modify by hand +################################################################################ + +from libc.stdio cimport FILE +from sage.libs.gmp.types cimport * +from sage.libs.mpfr.types cimport * +from sage.libs.flint.types cimport * + +cdef extern from "flint_wrap.h": + + void nmod_poly_factor_init(nmod_poly_factor_t fac) + # Initialises ``fac`` for use. An ``nmod_poly_factor_t`` + # represents a polynomial in factorised form as a product of + # polynomials with associated exponents. + + void nmod_poly_factor_clear(nmod_poly_factor_t fac) + # Frees all memory associated with ``fac``. + + void nmod_poly_factor_realloc(nmod_poly_factor_t fac, long alloc) + # Reallocates the factor structure to provide space for + # precisely ``alloc`` factors. + + void nmod_poly_factor_fit_length(nmod_poly_factor_t fac, long len) + # Ensures that the factor structure has space for at + # least ``len`` factors. This function takes care + # of the case of repeated calls by always at least + # doubling the number of factors the structure can hold. + + void nmod_poly_factor_set(nmod_poly_factor_t res, const nmod_poly_factor_t fac) + # Sets ``res`` to the same factorisation as ``fac``. + + void nmod_poly_factor_print(const nmod_poly_factor_t fac) + # Prints the entries of ``fac`` to standard output. + + void nmod_poly_factor_insert(nmod_poly_factor_t fac, const nmod_poly_t poly, long exp) + # Inserts the factor ``poly`` with multiplicity ``exp`` into + # the factorisation ``fac``. + # If ``fac`` already contains ``poly``, then ``exp`` simply + # gets added to the exponent of the existing entry. + + void nmod_poly_factor_concat(nmod_poly_factor_t res, const nmod_poly_factor_t fac) + # Concatenates two factorisations. + # This is equivalent to calling :func:`nmod_poly_factor_insert` + # repeatedly with the individual factors of ``fac``. + # Does not support aliasing between ``res`` and ``fac``. + + void nmod_poly_factor_pow(nmod_poly_factor_t fac, long exp) + # Raises ``fac`` to the power ``exp``. + + unsigned long nmod_poly_remove(nmod_poly_t f, const nmod_poly_t p) + # Removes the highest possible power of ``p`` from ``f`` and + # returns the exponent. + + int nmod_poly_is_irreducible(const nmod_poly_t f) + # Returns 1 if the polynomial ``f`` is irreducible, otherwise returns 0. + + int nmod_poly_is_irreducible_ddf(const nmod_poly_t f) + # Returns 1 if the polynomial ``f`` is irreducible, otherwise returns 0. + # Uses fast distinct-degree factorisation. + + int nmod_poly_is_irreducible_rabin(const nmod_poly_t f) + # Returns 1 if the polynomial ``f`` is irreducible, otherwise returns 0. + # Uses Rabin irreducibility test. + + int _nmod_poly_is_squarefree(mp_srcptr f, long len, nmod_t mod) + # Returns 1 if ``(f, len)`` is squarefree, and 0 otherwise. As a + # special case, the zero polynomial is not considered squarefree. + # There are no restrictions on the length. + + int nmod_poly_is_squarefree(const nmod_poly_t f) + # Returns 1 if ``f`` is squarefree, and 0 otherwise. As a special + # case, the zero polynomial is not considered squarefree. + + void nmod_poly_factor_squarefree(nmod_poly_factor_t res, const nmod_poly_t f) + # Sets ``res`` to a square-free factorization of ``f``. + + int nmod_poly_factor_equal_deg_prob(nmod_poly_t factor, flint_rand_t state, const nmod_poly_t pol, long d) + # Probabilistic equal degree factorisation of ``pol`` into + # irreducible factors of degree ``d``. If it passes, a factor is + # placed in factor and 1 is returned, otherwise 0 is returned and + # the value of factor is undetermined. + # Requires that ``pol`` be monic, non-constant and squarefree. + + void nmod_poly_factor_equal_deg(nmod_poly_factor_t factors, const nmod_poly_t pol, long d) + # Assuming ``pol`` is a product of irreducible factors all of + # degree ``d``, finds all those factors and places them in factors. + # Requires that ``pol`` be monic, non-constant and squarefree. + + void nmod_poly_factor_distinct_deg(nmod_poly_factor_t res, const nmod_poly_t poly, long * const *degs) + # Factorises a monic non-constant squarefree polynomial ``poly`` + # of degree n into factors `f[d]` such that for `1 \leq d \leq n` + # `f[d]` is the product of the monic irreducible factors of ``poly`` + # of degree `d`. Factors `f[d]` are stored in ``res``, and the degree `d` + # of the irreducible factors is stored in ``degs`` in the same order + # as the factors. + # Requires that ``degs`` has enough space for ``(n/2)+1 * sizeof(slong)``. + + void nmod_poly_factor_distinct_deg_threaded(nmod_poly_factor_t res, const nmod_poly_t poly, long * const *degs) + # Multithreaded version of :func:`nmod_poly_factor_distinct_deg`. + + void nmod_poly_factor_cantor_zassenhaus(nmod_poly_factor_t res, const nmod_poly_t f) + # Factorises a non-constant polynomial ``f`` into monic irreducible + # factors using the Cantor-Zassenhaus algorithm. + + void nmod_poly_factor_berlekamp(nmod_poly_factor_t res, const nmod_poly_t f) + # Factorises a non-constant, squarefree polynomial ``f`` into monic + # irreducible factors using the Berlekamp algorithm. + + void nmod_poly_factor_kaltofen_shoup(nmod_poly_factor_t res, const nmod_poly_t poly) + # Factorises a non-constant polynomial ``f`` into monic irreducible + # factors using the fast version of Cantor-Zassenhaus algorithm proposed by + # Kaltofen and Shoup (1998). More precisely this algorithm uses a + # “baby step/giant step” strategy for the distinct-degree factorization + # step. If :func:`flint_get_num_threads` is greater than one + # :func:`nmod_poly_factor_distinct_deg_threaded` is used. + + mp_limb_t nmod_poly_factor_with_berlekamp(nmod_poly_factor_t res, const nmod_poly_t f) + # Factorises a general polynomial ``f`` into monic irreducible factors + # and returns the leading coefficient of ``f``, or 0 if ``f`` + # is the zero polynomial. + # This function first checks for small special cases, deflates ``f`` + # if it is of the form `p(x^m)` for some `m > 1`, then performs a + # square-free factorisation, and finally runs Berlekamp on all the + # individual square-free factors. + + mp_limb_t nmod_poly_factor_with_cantor_zassenhaus(nmod_poly_factor_t res, const nmod_poly_t f) + # Factorises a general polynomial ``f`` into monic irreducible factors + # and returns the leading coefficient of ``f``, or 0 if ``f`` + # is the zero polynomial. + # This function first checks for small special cases, deflates ``f`` + # if it is of the form `p(x^m)` for some `m > 1`, then performs a + # square-free factorisation, and finally runs Cantor-Zassenhaus on all the + # individual square-free factors. + + mp_limb_t nmod_poly_factor_with_kaltofen_shoup(nmod_poly_factor_t res, const nmod_poly_t f) + # Factorises a general polynomial ``f`` into monic irreducible factors + # and returns the leading coefficient of ``f``, or 0 if ``f`` + # is the zero polynomial. + # This function first checks for small special cases, deflates ``f`` + # if it is of the form `p(x^m)` for some `m > 1`, then performs a + # square-free factorisation, and finally runs Kaltofen-Shoup on all the + # individual square-free factors. + + mp_limb_t nmod_poly_factor(nmod_poly_factor_t res, const nmod_poly_t f) + # Factorises a general polynomial ``f`` into monic irreducible factors + # and returns the leading coefficient of ``f``, or 0 if ``f`` + # is the zero polynomial. + # This function first checks for small special cases, deflates ``f`` + # if it is of the form `p(x^m)` for some `m > 1`, then performs a + # square-free factorisation, and finally runs either Cantor-Zassenhaus + # or Berlekamp on all the individual square-free factors. + # Currently Cantor-Zassenhaus is used by default unless the modulus is 2, in + # which case Berlekamp is used. + + void _nmod_poly_interval_poly_worker(void* arg_ptr) + # Worker function to compute interval polynomials in distinct degree + # factorisation. Input/output is stored in + # ``nmod_poly_interval_poly_arg_t``. diff --git a/src/sage/libs/flint/nmod_poly_linkage.pxi b/src/sage/libs/flint/nmod_poly_linkage.pxi index 32087acf9dc..303cb6472fe 100644 --- a/src/sage/libs/flint/nmod_poly_linkage.pxi +++ b/src/sage/libs/flint/nmod_poly_linkage.pxi @@ -20,7 +20,9 @@ AUTHOR: from cysignals.signals cimport sig_on, sig_off from cysignals.memory cimport sig_malloc, sig_free +from sage.libs.flint.types cimport * from sage.libs.flint.nmod_poly cimport * +from sage.libs.flint.nmod_poly_factor cimport * from sage.libs.flint.ulong_extras cimport * from sage.structure.factorization import Factorization diff --git a/src/sage/libs/flint/padic.pxd b/src/sage/libs/flint/padic.pxd index e155ddabfd8..a8cc1202a40 100644 --- a/src/sage/libs/flint/padic.pxd +++ b/src/sage/libs/flint/padic.pxd @@ -1,117 +1,395 @@ # distutils: libraries = flint -# distutils: depends = flint/qadic.h +# distutils: depends = flint/padic.h +################################################################################ +# This file is auto-generated. Do not modify by hand +################################################################################ + +from libc.stdio cimport FILE +from sage.libs.gmp.types cimport * +from sage.libs.mpfr.types cimport * from sage.libs.flint.types cimport * -# flint/qadic.h cdef extern from "flint_wrap.h": - # macros - long padic_val(padic_t x) - long padic_prec(padic_t x) - fmpz * padic_unit(const padic_t x) - slong padic_get_val(const padic_t x) - slong padic_get_prec(const padic_t x) + fmpz * padic_unit(const padic_t op) + # Returns the unit part of the `p`-adic number as a FLINT integer, which + # can be used as an operand for the ``fmpz`` functions. - #* Context *******************************************************************/ - void padic_ctx_init(padic_ctx_t ctx, const fmpz_t p, slong min, slong max, - padic_print_mode mode) - void padic_ctx_clear(padic_ctx_t ctx) + long padic_val(const padic_t op) + # Returns the valuation part of the `p`-adic number. + # Note that this function is implemented as a macro and that + # the expression ``padic_val(op)`` can be used as both an + # *lvalue* and an *rvalue*. + + long padic_get_val(const padic_t op) + # Returns the valuation part of the `p`-adic number. + + long padic_prec(const padic_t op) + # Returns the precision of the `p`-adic number. + # Note that this function is implemented as a macro and that + # the expression ``padic_prec(op)`` can be used as both an + # *lvalue* and an *rvalue*. - int _padic_ctx_pow_ui(fmpz_t rop, ulong e, const padic_ctx_t ctx) + long padic_get_prec(const padic_t op) + # Returns the precision of the `p`-adic number. - void padic_ctx_pow_ui(fmpz_t rop, ulong e, const padic_ctx_t ctx) + void padic_ctx_init(padic_ctx_t ctx, const fmpz_t p, long min, long max, padic_print_mode mode) + # Initialises the context ``ctx`` with the given data. + # Assumes that `p` is a prime. This is not verified but the subsequent + # behaviour is undefined if `p` is a composite number. + # Assumes that ``min`` and ``max`` are non-negative and that + # ``min`` is at most ``max``, raising an ``abort`` signal + # otherwise. + # Assumes that the printing mode is one of ``PADIC_TERSE``, + # ``PADIC_SERIES``, or ``PADIC_VAL_UNIT``. Using the example + # `x = 7^{-1} 12` in `\mathbf{Q}_7`, these behave as follows: + # In ``PADIC_TERSE`` mode, a `p`-adic number is printed + # in the same way as a rational number, e.g. ``12/7``. + # In ``PADIC_SERIES`` mode, a `p`-adic number is printed + # digit by digit, e.g. ``5*7^-1 + 1``. + # In ``PADIC_VAL_UNIT`` mode, a `p`-adic number is + # printed showing the valuation and unit parts separately, + # e.g. ``12*7^-1``. + + void padic_ctx_clear(padic_ctx_t ctx) + # Clears all memory that has been allocated as part of the context. + + int _padic_ctx_pow_ui(fmpz_t rop, unsigned long e, const padic_ctx_t ctx) + # Sets ``rop`` to `p^e` as efficiently as possible, where + # ``rop`` is expected to be an uninitialised ``fmpz_t``. + # If the return value is non-zero, it is the responsibility of + # the caller to clear the returned integer. - #* Memory management *********************************************************/ void padic_init(padic_t rop) - void padic_init2(padic_t rop, slong N) + # Initialises the `p`-adic number with the precision set to + # ``PADIC_DEFAULT_PREC``, which is defined as `20`. + + void padic_init2(padic_t rop, long N) + # Initialises the `p`-adic number ``rop`` with precision `N`. + void padic_clear(padic_t rop) + # Clears all memory used by the `p`-adic number ``rop``. + void _padic_canonicalise(padic_t rop, const padic_ctx_t ctx) + # Brings the `p`-adic number ``rop`` into canonical form. + # That is to say, ensures that either `u = v = 0` or + # `p \nmid u`. There is no reduction modulo a power + # of `p`. + void _padic_reduce(padic_t rop, const padic_ctx_t ctx) + # Given a `p`-adic number ``rop`` in canonical form, + # reduces it modulo `p^N`. + void padic_reduce(padic_t rop, const padic_ctx_t ctx) + # Ensures that the `p`-adic number ``rop`` is reduced. - #* Randomisation *************************************************************/ void padic_randtest(padic_t rop, flint_rand_t state, const padic_ctx_t ctx) - void padic_randtest_not_zero(padic_t rop, flint_rand_t state, - const padic_ctx_t ctx) - void padic_randtest_int(padic_t rop, flint_rand_t state, - const padic_ctx_t ctx) + # Sets ``rop`` to a random `p`-adic number modulo `p^N` with valuation + # in the range `[- \lceil N/10\rceil, N)`, `[N - \lceil -N/10\rceil, N)`, or `[-10, 0)` + # as `N` is positive, negative or zero, whenever ``rop`` is non-zero. + + void padic_randtest_not_zero(padic_t rop, flint_rand_t state, const padic_ctx_t ctx) + # Sets ``rop`` to a random non-zero `p`-adic number modulo `p^N`, + # where the range of the valuation is as for the function + # :func:`padic_randtest`. + + void padic_randtest_int(padic_t rop, flint_rand_t state, const padic_ctx_t ctx) + # Sets ``rop`` to a random `p`-adic integer modulo `p^N`. + # Note that whenever `N \leq 0`, ``rop`` is set to zero. - #* Assignments and conversions ***********************************************/ void padic_set(padic_t rop, const padic_t op, const padic_ctx_t ctx) - void padic_set_si(padic_t rop, slong op, const padic_ctx_t ctx) - void padic_set_ui(padic_t rop, ulong op, const padic_ctx_t ctx) + # Sets ``rop`` to the `p`-adic number ``op``. + + void padic_set_si(padic_t rop, long op, const padic_ctx_t ctx) + # Sets the `p`-adic number ``rop`` to the + # ``slong`` integer ``op``. + + void padic_set_ui(padic_t rop, unsigned long op, const padic_ctx_t ctx) + # Sets the `p`-adic number ``rop`` to the ``ulong`` + # integer ``op``. + void padic_set_fmpz(padic_t rop, const fmpz_t op, const padic_ctx_t ctx) + # Sets the `p`-adic number ``rop`` to the integer ``op``. + void padic_set_fmpq(padic_t rop, const fmpq_t op, const padic_ctx_t ctx) + # Sets ``rop`` to the rational ``op``. + void padic_set_mpz(padic_t rop, const mpz_t op, const padic_ctx_t ctx) + # Sets the `p`-adic number ``rop`` to the MPIR integer ``op``. + void padic_set_mpq(padic_t rop, const mpq_t op, const padic_ctx_t ctx) + # Sets ``rop`` to the MPIR rational ``op``. + void padic_get_fmpz(fmpz_t rop, const padic_t op, const padic_ctx_t ctx) + # Sets the integer ``rop`` to the exact `p`-adic integer ``op``. + # If ``op`` is not a `p`-adic integer, raises an ``abort`` signal. + void padic_get_fmpq(fmpq_t rop, const padic_t op, const padic_ctx_t ctx) + # Sets the rational ``rop`` to the `p`-adic number ``op``. + void padic_get_mpz(mpz_t rop, const padic_t op, const padic_ctx_t ctx) + # Sets the MPIR integer ``rop`` to the `p`-adic integer ``op``. + # If ``op`` is not a `p`-adic integer, raises an ``abort`` signal. + void padic_get_mpq(mpq_t rop, const padic_t op, const padic_ctx_t ctx) + # Sets the MPIR rational ``rop`` to the value of ``op``. + void padic_swap(padic_t op1, padic_t op2) + # Swaps the two `p`-adic numbers ``op1`` and ``op2``. + # Note that this includes swapping the precisions. In particular, this + # operation is not equivalent to swapping ``op1`` and ``op2`` + # using :func:`padic_set` and an auxiliary variable whenever the + # precisions of the two elements are different. + void padic_zero(padic_t rop) + # Sets the `p`-adic number ``rop`` to zero. + void padic_one(padic_t rop) + # Sets the `p`-adic number ``rop`` to one, reduced modulo the + # precision of ``rop``. - #* Comparison ****************************************************************/ int padic_is_zero(const padic_t op) + # Returns whether ``op`` is equal to zero. + int padic_is_one(const padic_t op) + # Returns whether ``op`` is equal to one, that is, whether + # `u = 1` and `v = 0`. + int padic_equal(const padic_t op1, const padic_t op2) + # Returns whether ``op1`` and ``op2`` are equal, that is, + # whether `u_1 = u_2` and `v_1 = v_2`. + + long * _padic_lifts_exps(long *n, long N) + # Given a positive integer `N` define the sequence + # `a_0 = N, a_1 = \lceil a_0/2\rceil, \dotsc, a_{n-1} = \lceil a_{n-2}/2\rceil = 1`. + # Then `n = \lceil\log_2 N\rceil + 1`. + # This function sets `n` and allocates and returns the array `a`. + + void _padic_lifts_pows(fmpz *pow, const long *a, long n, const fmpz_t p) + # Given an array `a` as computed above, this function + # computes the corresponding powers of `p`, that is, + # ``pow[i]`` is equal to `p^{a_i}`. + + void padic_add(padic_t rop, const padic_t op1, const padic_t op2, const padic_ctx_t ctx) + # Sets ``rop`` to the sum of ``op1`` and ``op2``. + + void padic_sub(padic_t rop, const padic_t op1, const padic_t op2, const padic_ctx_t ctx) + # Sets ``rop`` to the difference of ``op1`` and ``op2``. - #* Arithmetic operations *****************************************************/ - slong * _padic_lifts_exps(slong *n, slong N) - void _padic_lifts_pows(fmpz *pow, const slong *a, slong n, const fmpz_t p) - void padic_add(padic_t rop, const padic_t op1, const padic_t op2, - const padic_ctx_t ctx) - void padic_sub(padic_t rop, const padic_t op1, const padic_t op2, - const padic_ctx_t ctx) void padic_neg(padic_t rop, const padic_t op, const padic_ctx_t ctx) - void padic_mul(padic_t rop, const padic_t op1, const padic_t op2, - const padic_ctx_t ctx) - void padic_shift(padic_t rop, const padic_t op, slong v, const padic_ctx_t ctx) - void padic_div(padic_t rop, const padic_t op1, const padic_t op2, - const padic_ctx_t ctx) - void _padic_inv_precompute(padic_inv_t S, const fmpz_t p, slong N) + # Sets ``rop`` to the additive inverse of ``op``. + + void padic_mul(padic_t rop, const padic_t op1, const padic_t op2, const padic_ctx_t ctx) + # Sets ``rop`` to the product of ``op1`` and ``op2``. + + void padic_shift(padic_t rop, const padic_t op, long v, const padic_ctx_t ctx) + # Sets ``rop`` to the product of ``op`` and `p^v`. + + void padic_div(padic_t rop, const padic_t op1, const padic_t op2, const padic_ctx_t ctx) + # Sets ``rop`` to the quotient of ``op1`` and ``op2``. + + void _padic_inv_precompute(padic_inv_t S, const fmpz_t p, long N) + # Pre-computes some data and allocates temporary space for + # `p`-adic inversion using Hensel lifting. + void _padic_inv_clear(padic_inv_t S) + # Frees the memory used by `S`. + void _padic_inv_precomp(fmpz_t rop, const fmpz_t op, const padic_inv_t S) - void _padic_inv(fmpz_t rop, const fmpz_t op, const fmpz_t p, slong N) + # Sets ``rop`` to the inverse of ``op`` modulo `p^N`, + # assuming that ``op`` is a unit and `N \geq 1`. + # In the current implementation, allows aliasing, but this might + # change in future versions. + # Uses some data `S` precomputed by calling the function + # :func:`_padic_inv_precompute`. Note that this object + # is not declared ``const`` and in fact it carries a field + # providing temporary work space. This allows repeated calls of + # this function to avoid repeated memory allocations, as used + # e.g. by the function :func:`padic_log`. + + void _padic_inv(fmpz_t rop, const fmpz_t op, const fmpz_t p, long N) + # Sets ``rop`` to the inverse of ``op`` modulo `p^N`, + # assuming that ``op`` is a unit and `N \geq 1`. + # In the current implementation, allows aliasing, but this might + # change in future versions. + void padic_inv(padic_t rop, const padic_t op, const padic_ctx_t ctx) + # Computes the inverse of ``op`` modulo `p^N`. + # Suppose that ``op`` is given as `x = u p^v`. + # Raises an ``abort`` signal if `v < -N`. Otherwise, + # computes the inverse of `u` modulo `p^{N+v}`. + # This function employs Hensel lifting of an inverse modulo `p`. + int padic_sqrt(padic_t rop, const padic_t op, const padic_ctx_t ctx) - void padic_pow_si(padic_t rop, const padic_t op, slong e, - const padic_ctx_t ctx) - - #* Exponential ***************************************************************/ - slong _padic_exp_bound(slong v, slong N, const fmpz_t p) - void _padic_exp(fmpz_t rop, const fmpz_t u, slong v, const fmpz_t p, slong N) - void _padic_exp_rectangular(fmpz_t rop, const fmpz_t u, slong v, const fmpz_t p, slong N) - void _padic_exp_balanced(fmpz_t rop, const fmpz_t u, slong v, const fmpz_t p, slong N) - int padic_exp(padic_t rop, const padic_t op, const padic_ctx_t ctx) - int padic_exp_rectangular(padic_t rop, const padic_t op, const padic_ctx_t ctx) - int padic_exp_balanced(padic_t rop, const padic_t op, const padic_ctx_t ctx) - - #* Logarithm *****************************************************************/ - slong _padic_log_bound(slong v, slong N, const fmpz_t p) - void _padic_log(fmpz_t z, const fmpz_t y, slong v, const fmpz_t p, slong N) - void _padic_log_rectangular(fmpz_t z, const fmpz_t y, slong v, const fmpz_t p, slong N) - void _padic_log_satoh(fmpz_t z, const fmpz_t y, slong v, const fmpz_t p, slong N) - void _padic_log_balanced(fmpz_t z, const fmpz_t y, slong v, const fmpz_t p, slong N) + # Returns whether ``op`` is a `p`-adic square. If this is + # the case, sets ``rop`` to one of the square roots; otherwise, + # the value of ``rop`` is undefined. + # We have the following theorem: + # Let `u \in \mathbf{Z}^{\times}`. Then `u` is a + # square if and only if `u \bmod p` is a square in + # `\mathbf{Z} / p \mathbf{Z}`, for `p > 2`, or if + # `u \bmod 8` is a square in `\mathbf{Z} / 8 \mathbf{Z}`, + # for `p = 2`. + + void padic_pow_si(padic_t rop, const padic_t op, long e, const padic_ctx_t ctx) + # Sets ``rop`` to ``op`` raised to the power `e`, + # which is defined as one whenever `e = 0`. + # Assumes that some computations involving `e` and the + # valuation of ``op`` do not overflow in the ``slong`` + # range. + # Note that if the input `x = p^v u` is defined modulo `p^N` + # then `x^e = p^{ev} u^e` is defined modulo `p^{N + (e - 1) v}`, + # which is a precision loss in case `v < 0`. + + long _padic_exp_bound(long v, long N, const fmpz_t p) + # Returns an integer `i` such that for all `j \geq i` we have + # `\operatorname{ord}_p(x^j / j!) \geq N`, where `\operatorname{ord}_p(x) = v`. + # When `p` is a word-sized prime, + # returns `\left\lceil \frac{(p-1)N - 1}{(p-1)v - 1}\right\rceil`. + # Otherwise, returns `\lceil N/v\rceil`. + # Assumes that `v < N`. Moreover, `v` has to be at least `2` or `1`, + # depending on whether `p` is `2` or odd. + + void _padic_exp_rectangular(fmpz_t rop, const fmpz_t u, long v, const fmpz_t p, long N) + void _padic_exp_balanced(fmpz_t rop, const fmpz_t u, long v, const fmpz_t p, long N) + void _padic_exp(fmpz_t rop, const fmpz_t u, long v, const fmpz_t p, long N) + # Sets ``rop`` to the `p`-exponential function evaluated at + # `x = p^v u`, reduced modulo `p^N`. + # Assumes that `x \neq 0`, that `\operatorname{ord}_p(x) < N` and that + # `\exp(x)` converges, that is, that `\operatorname{ord}_p(x)` is at least + # `2` or `1` depending on whether the prime `p` is `2` or odd. + # Supports aliasing between ``rop`` and `u`. + + int padic_exp(padic_t y, const padic_t x, const padic_ctx_t ctx) + # Returns whether the `p`-adic exponential function converges at + # the `p`-adic number `x`, and if so sets `y` to its value. + # The `p`-adic exponential function is defined by the usual series + # .. math :: + # \exp_p(x) = \sum_{i = 0}^{\infty} \frac{x^i}{i!} + # but this only converges only when `\operatorname{ord}_p(x) > 1 / (p - 1)`. For + # elements `x \in \mathbf{Q}_p`, this means that `\operatorname{ord}_p(x) \geq 1` + # when `p \geq 3` and `\operatorname{ord}_2(x) \geq 2` when `p = 2`. + + int padic_exp_rectangular(padic_t y, const padic_t x, const padic_ctx_t ctx) + # Returns whether the `p`-adic exponential function converges at + # the `p`-adic number `x`, and if so sets `y` to its value. + # Uses a rectangular splitting algorithm to evaluate the series + # expression of `\exp(x) \bmod{p^N}`. + + int padic_exp_balanced(padic_t y, const padic_t x, const padic_ctx_t ctx) + # Returns whether the `p`-adic exponential function converges at + # the `p`-adic number `x`, and if so sets `y` to its value. + # Uses a balanced approach, balancing the size of chunks of `x` + # with the valuation and hence the rate of convergence, which + # results in a quasi-linear algorithm in `N`, for fixed `p`. + + long _padic_log_bound(long v, long N, const fmpz_t p) + # Returns `b` such that for all `i \geq b` we have + # .. math :: + # i v - \operatorname{ord}_p(i) \geq N + # where `v \geq 1`. + # Assumes that `1 \leq v < N` or `2 \leq v < N` when `p` is + # odd or `p = 2`, respectively, and also that `N < 2^{f-2}` + # where `f` is ``FLINT_BITS``. + + void _padic_log(fmpz_t z, const fmpz_t y, long v, const fmpz_t p, long N) + void _padic_log_rectangular(fmpz_t z, const fmpz_t y, long v, const fmpz_t p, long N) + void _padic_log_satoh(fmpz_t z, const fmpz_t y, long v, const fmpz_t p, long N) + void _padic_log_balanced(fmpz_t z, const fmpz_t y, long v, const fmpz_t p, long N) + # Computes + # .. math :: + # z = - \sum_{i = 1}^{\infty} \frac{y^i}{i} \pmod{p^N}, + # reduced modulo `p^N`. + # Note that this can be used to compute the `p`-adic logarithm + # via the equation + # .. math :: + # \log(x) & = \sum_{i=1}^{\infty} (-1)^{i-1} \frac{(x-1)^i}{i} \\ + # & = - \sum_{i=1}^{\infty} \frac{(1-x)^i}{i}. + # Assumes that `y = 1 - x` is non-zero and that `v = \operatorname{ord}_p(y)` + # is at least `1` when `p` is odd and at least `2` when `p = 2` + # so that the series converges. + # Assumes that `v < N`, and hence in particular `N \geq 2`. + # Does not support aliasing between `y` and `z`. + int padic_log(padic_t rop, const padic_t op, const padic_ctx_t ctx) + # Returns whether the `p`-adic logarithm function converges at + # the `p`-adic number ``op``, and if so sets ``rop`` to its + # value. + # The `p`-adic logarithm function is defined by the usual series + # .. math :: + # \log_p(x) = \sum_{i=1}^{\infty} (-1)^{i-1} \frac{(x-1)^i}{i} + # but this only converges when `\operatorname{ord}_p(x - 1)` is at least `2` + # or `1` when `p = 2` or `p > 2`, respectively. + int padic_log_rectangular(padic_t rop, const padic_t op, const padic_ctx_t ctx) + # Returns whether the `p`-adic logarithm function converges at + # the `p`-adic number ``op``, and if so sets ``rop`` to its + # value. + # Uses a rectangular splitting algorithm to evaluate the series + # expression of `\log(x) \bmod{p^N}`. + int padic_log_satoh(padic_t rop, const padic_t op, const padic_ctx_t ctx) + # Returns whether the `p`-adic logarithm function converges at + # the `p`-adic number ``op``, and if so sets ``rop`` to its + # value. + # Uses an algorithm based on a result of Satoh, Skjernaa and Taguchi + # that `\operatorname{ord}_p\bigl(a^{p^k} - 1\bigr) > k`, which implies that + # .. math :: + # \log(a) \equiv p^{-k} \Bigl( \log\bigl(a^{p^k}\bigr) \pmod{p^{N+k}} + # \Bigr) \pmod{p^N}. + int padic_log_balanced(padic_t rop, const padic_t op, const padic_ctx_t ctx) + # Returns whether the `p`-adic logarithm function converges at + # the `p`-adic number ``op``, and if so sets ``rop`` to its + # value. + + void _padic_teichmuller(fmpz_t rop, const fmpz_t op, const fmpz_t p, long N) + # Computes the Teichm\"uller lift of the `p`-adic unit ``op``, + # assuming that `N \geq 1`. + # Supports aliasing between ``rop`` and ``op``. - #* Special functions *********************************************************/ - void _padic_teichmuller(fmpz_t rop, const fmpz_t op, const fmpz_t p, slong N) void padic_teichmuller(padic_t rop, const padic_t op, const padic_ctx_t ctx) - ulong padic_val_fac_ui_2(ulong N) - ulong padic_val_fac_ui(ulong N, const fmpz_t p) + # Computes the Teichm\"uller lift of the `p`-adic unit ``op``. + # If ``op`` is a `p`-adic integer divisible by `p`, sets ``rop`` + # to zero, which satisfies `t^p - t = 0`, although it is clearly not + # a `(p-1)`-st root of unity. + # If ``op`` has negative valuation, raises an ``abort`` signal. + + unsigned long padic_val_fac_ui_2(unsigned long n) + # Computes the `2`-adic valuation of `n!`. + # Note that since `n` fits into an ``ulong``, so does + # `\operatorname{ord}_2(n!)` since `\operatorname{ord}_2(n!) \leq (n - 1) / (p - 1) = n - 1`. + + unsigned long padic_val_fac_ui(unsigned long n, const fmpz_t p) + # Computes the `p`-adic valuation of `n!`. + # Note that since `n` fits into an ``ulong``, so does + # `\operatorname{ord}_p(n!)` since `\operatorname{ord}_p(n!) \leq (n - 1) / (p - 1)`. + void padic_val_fac(fmpz_t rop, const fmpz_t op, const fmpz_t p) + # Sets ``rop`` to the `p`-adic valuation of the factorial + # of ``op``, assuming that ``op`` is non-negative. - #* Input and output **********************************************************/ char * padic_get_str(char * str, const padic_t op, const padic_ctx_t ctx) - int _padic_fprint(FILE * file, const fmpz_t u, slong v, const padic_ctx_t ctx) + # Returns the string representation of the `p`-adic number ``op`` + # according to the printing mode set in the context. + # If ``str`` is ``NULL`` then a new block of memory is allocated + # and a pointer to this is returned. Otherwise, it is assumed that + # the string ``str`` is large enough to hold the representation and + # it is also the return value. + + int _padic_fprint(FILE * file, const fmpz_t u, long v, const padic_ctx_t ctx) int padic_fprint(FILE * file, const padic_t op, const padic_ctx_t ctx) + # Prints the string representation of the `p`-adic number ``op`` + # to the stream ``file``. + # In the current implementation, always returns `1`. - int _padic_print(const fmpz_t u, slong v, const padic_ctx_t ctx) + int _padic_print(const fmpz_t u, long v, const padic_ctx_t ctx) int padic_print(const padic_t op, const padic_ctx_t ctx) + # Prints the string representation of the `p`-adic number ``op`` + # to the stream ``stdout``. + # In the current implementation, always returns `1`. + void padic_debug(const padic_t op) + # Prints debug information about ``op`` to the stream ``stdout``, + # in the format ``"(u v N)"``. diff --git a/src/sage/libs/flint/padic_poly.pxd b/src/sage/libs/flint/padic_poly.pxd index 6cd172fd14f..c9198d3caf4 100644 --- a/src/sage/libs/flint/padic_poly.pxd +++ b/src/sage/libs/flint/padic_poly.pxd @@ -1,182 +1,352 @@ # distutils: libraries = flint # distutils: depends = flint/padic_poly.h +################################################################################ +# This file is auto-generated. Do not modify by hand +################################################################################ + +from libc.stdio cimport FILE +from sage.libs.gmp.types cimport * +from sage.libs.mpfr.types cimport * from sage.libs.flint.types cimport * -# flint/padic_poly.h cdef extern from "flint_wrap.h": - #* Helper functions ********************************************************/ - long _fmpz_vec_ord_p(const fmpz *vec, long len, const fmpz_t p) - #* Memory management *******************************************************/ void padic_poly_init(padic_poly_t poly) + # Initialises ``poly`` for use, setting its length to zero. + # The precision of the polynomial is set to ``PADIC_DEFAULT_PREC``. + # A corresponding call to :func:`padic_poly_clear` must be made + # after finishing with the :type:`padic_poly_t` to free the memory + # used by the polynomial. + void padic_poly_init2(padic_poly_t poly, long alloc, long prec) - void padic_poly_clear(padic_poly_t poly) - void padic_poly_realloc(padic_poly_t f, long alloc, const fmpz_t p) - void padic_poly_fit_length(padic_poly_t f, long len) + # Initialises ``poly`` with space for at least ``alloc`` coefficients + # and sets the length to zero. The allocated coefficients are all set to + # zero. The precision is set to ``prec``. + + void padic_poly_realloc(padic_poly_t poly, long alloc, const fmpz_t p) + # Reallocates the given polynomial to have space for ``alloc`` + # coefficients. If ``alloc`` is zero the polynomial is cleared + # and then reinitialised. If the current length is greater than + # ``alloc`` the polynomial is first truncated to length ``alloc``. + + void padic_poly_fit_length(padic_poly_t poly, long len) + # If ``len`` is greater than the number of coefficients currently + # allocated, then the polynomial is reallocated to have space for at + # least ``len`` coefficients. No data is lost when calling this + # function. + # The function efficiently deals with the case where ``fit_length`` is + # called many times in small increments by at least doubling the number + # of allocated coefficients when length is larger than the number of + # coefficients currently allocated. + void _padic_poly_set_length(padic_poly_t poly, long len) - void _padic_poly_normalise(padic_poly_t f) + # Demotes the coefficients of ``poly`` beyond ``len`` and sets + # the length of ``poly`` to ``len``. + # Note that if the current length is greater than ``len`` the + # polynomial may no slonger be in canonical form. + + void padic_poly_clear(padic_poly_t poly) + # Clears the given polynomial, releasing any memory used. It must + # be reinitialised in order to be used again. + + void _padic_poly_normalise(padic_poly_t poly) + # Sets the length of ``poly`` so that the top coefficient is non-zero. + # If all coefficients are zero, the length is set to zero. This function + # is mainly used internally, as all functions guarantee normalisation. + void _padic_poly_canonicalise(fmpz *poly, long *v, long len, const fmpz_t p) void padic_poly_canonicalise(padic_poly_t poly, const fmpz_t p) - void padic_poly_reduce(padic_poly_t f, const padic_ctx_t ctx) + # Brings the polynomial ``poly`` into canonical form, + # assuming that it is normalised already. Does *not* + # carry out any reduction. + + void padic_poly_reduce(padic_poly_t poly, const padic_ctx_t ctx) + # Reduces the polynomial ``poly`` modulo `p^N`, assuming + # that it is in canonical form already. + void padic_poly_truncate(padic_poly_t poly, long n, const fmpz_t p) + # Truncates the polynomial to length at most~`n`. - #* Polynomial parameters ***************************************************/ long padic_poly_degree(const padic_poly_t poly) + # Returns the degree of the polynomial ``poly``. + long padic_poly_length(const padic_poly_t poly) + # Returns the length of the polynomial ``poly``. + long padic_poly_val(const padic_poly_t poly) - # macros - long padic_poly_val(padic_poly_t poly) + # Returns the valuation of the polynomial ``poly``, + # which is defined to be the minimum valuation of all + # its coefficients. + # The valuation of the zero polynomial is~`0`. + # Note that this is implemented as a macro and can be + # used as either a ``lvalue`` or a ``rvalue``. + long padic_poly_prec(padic_poly_t poly) + # Returns the precision of the polynomial ``poly``. + # Note that this is implemented as a macro and can be + # used as either a ``lvalue`` or a ``rvalue``. + # Note that increasing the precision might require + # a call to :func:`padic_poly_reduce`. + + void padic_poly_randtest(padic_poly_t f, flint_rand_t state, long len, const padic_ctx_t ctx) + # Sets `f` to a random polynomial of length at most ``len`` + # with entries reduced modulo `p^N`. + + void padic_poly_randtest_not_zero(padic_poly_t f, flint_rand_t state, long len, const padic_ctx_t ctx) + # Sets `f` to a non-zero random polynomial of length at most ``len`` + # with entries reduced modulo `p^N`. + + void padic_poly_randtest_val(padic_poly_t f, flint_rand_t state, long val, long len, const padic_ctx_t ctx) + # Sets `f` to a random polynomial of length at most ``len`` + # with at most the prescribed valuation ``val`` and entries + # reduced modulo `p^N`. + # Specifically, we aim to set the valuation to be exactly equal + # to ``val``, but do not check for additional cancellation + # when creating the coefficients. + + void padic_poly_set_padic(padic_poly_t poly, const padic_t x, const padic_ctx_t ctx) + # Sets the polynomial ``poly`` to the `p`-adic number `x`, + # reduced to the precision of the polynomial. + + void padic_poly_set(padic_poly_t poly1, const padic_poly_t poly2, const padic_ctx_t ctx) + # Sets the polynomial ``poly1`` to the polynomial ``poly2``, + # reduced to the precision of ``poly1``. - #* Randomisation ***********************************************************/ - void padic_poly_randtest(padic_poly_t f, flint_rand_t state, - long len, const padic_ctx_t ctx) - void padic_poly_randtest_not_zero(padic_poly_t f, flint_rand_t state, - long len, const padic_ctx_t ctx) - void padic_poly_randtest_val(padic_poly_t f, flint_rand_t state, - long val, long len, const padic_ctx_t ctx) - - #* Assignment and basic manipulation ***************************************/ - void padic_poly_set(padic_poly_t f, const padic_poly_t g, - const padic_ctx_t ctx) - void padic_poly_set_padic(padic_poly_t poly, const padic_t x, - const padic_ctx_t ctx) void padic_poly_set_si(padic_poly_t poly, long x, const padic_ctx_t ctx) + # Sets the polynomial ``poly`` to the ``signed slong`` + # integer `x` reduced to the precision of the polynomial. + void padic_poly_set_ui(padic_poly_t poly, unsigned long x, const padic_ctx_t ctx) - void padic_poly_set_fmpz(padic_poly_t poly, const fmpz_t x, - const padic_ctx_t ctx) - void padic_poly_set_fmpq(padic_poly_t poly, const fmpq_t x, - const padic_ctx_t ctx) - void padic_poly_set_fmpz_poly(padic_poly_t rop, const fmpz_poly_t op, - const padic_ctx_t ctx) - void padic_poly_set_fmpq_poly(padic_poly_t rop, - const fmpq_poly_t op, const padic_ctx_t ctx) - int padic_poly_get_fmpz_poly(fmpz_poly_t rop, const padic_poly_t op, - const padic_ctx_t ctx) - void padic_poly_get_fmpq_poly(fmpq_poly_t rop, - const padic_poly_t op, const padic_ctx_t ctx) + # Sets the polynomial ``poly`` to the ``unsigned slong`` + # integer `x` reduced to the precision of the polynomial. + + void padic_poly_set_fmpz(padic_poly_t poly, const fmpz_t x, const padic_ctx_t ctx) + # Sets the polynomial ``poly`` to the integer `x` + # reduced to the precision of the polynomial. + + void padic_poly_set_fmpq(padic_poly_t poly, const fmpq_t x, const padic_ctx_t ctx) + # Sets the polynomial ``poly`` to the value of the rational `x`, + # reduced to the precision of the polynomial. + + void padic_poly_set_fmpz_poly(padic_poly_t rop, const fmpz_poly_t op, const padic_ctx_t ctx) + # Sets the polynomial ``rop`` to the integer polynomial ``op`` + # reduced to the precision of the polynomial. + + void padic_poly_set_fmpq_poly(padic_poly_t rop, const fmpq_poly_t op, const padic_ctx_t ctx) + # Sets the polynomial ``rop`` to the value of the rational + # polynomial ``op``, reduced to the precision of the polynomial. + + int padic_poly_get_fmpz_poly(fmpz_poly_t rop, const padic_poly_t op, const padic_ctx_t ctx) + # Sets the integer polynomial ``rop`` to the value of the `p`-adic + # polynomial ``op`` and returns `1` if the polynomial is `p`-adically + # integral. Otherwise, returns `0`. + + void padic_poly_get_fmpq_poly(fmpq_poly_t rop, const padic_poly_t op, const padic_ctx_t ctx) + # Sets ``rop`` to the rational polynomial corresponding to + # the `p`-adic polynomial ``op``. + void padic_poly_zero(padic_poly_t poly) + # Sets ``poly`` to the zero polynomial. + void padic_poly_one(padic_poly_t poly) + # Sets ``poly`` to the constant polynomial `1`, + # reduced to the precision of the polynomial. + void padic_poly_swap(padic_poly_t poly1, padic_poly_t poly2) + # Swaps the two polynomials ``poly1`` and ``poly2``, + # including their precisions. + # This is done efficiently by swapping pointers. + + void padic_poly_get_coeff_padic(padic_t c, const padic_poly_t poly, long n, const padic_ctx_t ctx) + # Sets `c` to the coefficient of `x^n` in the polynomial, + # reduced modulo the precision of `c`. - #* Getting and setting coefficients ****************************************/ - void padic_poly_get_coeff_padic(padic_t c, const padic_poly_t poly, long n, - const padic_ctx_t ctx) - void padic_poly_set_coeff_padic(padic_poly_t f, long n, const padic_t c, - const padic_ctx_t ctx) + void padic_poly_set_coeff_padic(padic_poly_t f, long n, const padic_t c, const padic_ctx_t ctx) + # Sets the coefficient of `x^n` in the polynomial `f` to `c`, + # reduced to the precision of the polynomial `f`. + # Note that this operation can take linear time in the length + # of the polynomial. + + int padic_poly_equal(const padic_poly_t poly1, const padic_poly_t poly2) + # Returns whether the two polynomials ``poly1`` and ``poly2`` + # are equal. - #* Comparison **************************************************************/ - int padic_poly_equal(const padic_poly_t f, const padic_poly_t g) int padic_poly_is_zero(const padic_poly_t poly) + # Returns whether the polynomial ``poly`` is the zero polynomial. + int padic_poly_is_one(const padic_poly_t poly) + # Returns whether the polynomial ``poly`` is equal + # to the constant polynomial~`1`, taking the precision + # of the polynomial into account. + + void _padic_poly_add(fmpz *rop, long *rval, long N, const fmpz *op1, long val1, long len1, long N1, const fmpz *op2, long val2, long len2, long N2, const padic_ctx_t ctx) + # Sets ``(rop, *val, FLINT_MAX(len1, len2)`` to the sum of + # ``(op1, val1, len1)`` and ``(op2, val2, len2)``. + # Assumes that the input is reduced and guarantees that this is + # also the case for the output. + # Assumes that `\min\{v_1, v_2\} < N`. + # Supports aliasing between the output and input arguments. + + void padic_poly_add(padic_poly_t f, const padic_poly_t g, const padic_poly_t h, const padic_ctx_t ctx) + # Sets `f` to the sum `g + h`. + + void _padic_poly_sub(fmpz *rop, long *rval, long N, const fmpz *op1, long val1, long len1, long N1, const fmpz *op2, long val2, long len2, long N2, const padic_ctx_t ctx) + # Sets ``(rop, *val, FLINT_MAX(len1, len2)`` to the difference of + # ``(op1, val1, len1)`` and ``(op2, val2, len2)``. + # Assumes that the input is reduced and guarantees that this is + # also the case for the output. + # Assumes that `\min\{v_1, v_2\} < N`. + # Support aliasing between the output and input arguments. + + void padic_poly_sub(padic_poly_t f, const padic_poly_t g, const padic_poly_t h, const padic_ctx_t ctx) + # Sets `f` to the difference `g - h`. + + void padic_poly_neg(padic_poly_t f, const padic_poly_t g, const padic_ctx_t ctx) + # Sets `f` to `-g`. + + void _padic_poly_scalar_mul_padic(fmpz *rop, long *rval, long N, const fmpz *op, long val, long len, const padic_t c, const padic_ctx_t ctx) + # Sets ``(rop, *rval, len)`` to ``(op, val, len)`` multiplied + # by the scalar `c`. + # The result will only be correctly reduced if the polynomial + # is non-zero. Otherwise, the array ``(rop, len)`` will be + # set to zero but the valuation ``*rval`` might be wrong. + + void padic_poly_scalar_mul_padic(padic_poly_t rop, const padic_poly_t op, const padic_t c, const padic_ctx_t ctx) + # Sets the polynomial ``rop`` to the product of the + # polynomial ``op`` and the `p`-adic number `c`, + # reducing the result modulo `p^N`. + + void _padic_poly_mul(fmpz *rop, long *rval, long N, const fmpz *op1, long val1, long len1, const fmpz *op2, long val2, long len2, const padic_ctx_t ctx) + # Sets ``(rop, *rval, len1 + len2 - 1)`` to the product of + # ``(op1, val1, len1)`` and ``(op2, val2, len2)``. + # Assumes that the resulting valuation ``*rval``, which is + # the sum of the valuations ``val1`` and ``val2``, is less + # than the precision~`N` of the context. + # Assumes that ``len1 >= len2 > 0``. + + void padic_poly_mul(padic_poly_t res, const padic_poly_t poly1, const padic_poly_t poly2, const padic_ctx_t ctx) + # Sets the polynomial ``res`` to the product of the two polynomials + # ``poly1`` and ``poly2``, reduced modulo `p^N`. + + void _padic_poly_pow(fmpz *rop, long *rval, long N, const fmpz *op, long val, long len, unsigned long e, const padic_ctx_t ctx) + # Sets the polynomial ``(rop, *rval, e (len - 1) + 1)`` to the + # polynomial ``(op, val, len)`` raised to the power~`e`. + # Assumes that `e > 1` and ``len > 0``. + # Does not support aliasing between the input and output arguments. + + void padic_poly_pow(padic_poly_t rop, const padic_poly_t op, unsigned long e, const padic_ctx_t ctx) + # Sets the polynomial ``rop`` to the polynomial ``op`` raised + # to the power~`e`, reduced to the precision in ``rop``. + # In the special case `e = 0`, sets ``rop`` to the constant + # polynomial one reduced to the precision of ``rop``. + # Also note that when `e = 1`, this operation sets ``rop`` to + # ``op`` and then reduces ``rop``. + # When the valuation of the input polynomial is negative, + # this results in a loss of `p`-adic precision. Suppose + # that the input polynomial is given to precision~`N` and + # has valuation~`v < 0`. The result then has valuation + # `e v < 0` but is only correct to precision `N + (e - 1) v`. + + void padic_poly_inv_series(padic_poly_t g, const padic_poly_t f, long n, const padic_ctx_t ctx) + # Computes the power series inverse `g` of `f` modulo `X^n`, + # where `n \geq 1`. + # Given the polynomial `f \in \mathbf{Q}[X] \subset \mathbf{Q}_p[X]`, + # there exists a unique polynomial `f^{-1} \in \mathbf{Q}[X]` such that + # `f f^{-1} = 1` modulo `X^n`. This function sets `g` to `f^{-1}` + # reduced modulo `p^N`. + # Assumes that the constant coefficient of `f` is non-zero. + # Moreover, assumes that the valuation of the constant coefficient + # of `f` is minimal among the coefficients of `f`. + # Note that the result `g` is zero if and only if `- \operatorname{ord}_p(f) \geq N`. + + void _padic_poly_derivative(fmpz *rop, long *rval, long N, const fmpz *op, long val, long len, const padic_ctx_t ctx) + # Sets ``(rop, rval)`` to the derivative of ``(op, val)`` reduced + # modulo `p^N`. + # Supports aliasing of the input and the output parameters. + + void padic_poly_derivative(padic_poly_t rop, const padic_poly_t op, const padic_ctx_t ctx) + # Sets ``rop`` to the derivative of ``op``, reducing the + # result modulo the precision of ``rop``. + + void padic_poly_shift_left(padic_poly_t rop, const padic_poly_t op, long n, const padic_ctx_t ctx) + # Notationally, sets the polynomial ``rop`` to the polynomial ``op`` + # multiplied by `x^n`, where `n \geq 0`, and reduces the result. + + void padic_poly_shift_right(padic_poly_t rop, const padic_poly_t op, long n, const padic_ctx_t ctx) + # Notationally, sets the polynomial ``rop`` to the polynomial + # ``op`` after floor division by `x^n`, where `n \geq 0`, ensuring + # the result is reduced. + + void _padic_poly_evaluate_padic(fmpz_t u, long *v, long N, const fmpz *poly, long val, long len, const fmpz_t a, long b, const padic_ctx_t ctx) + void padic_poly_evaluate_padic(padic_t y, const padic_poly_t poly, const padic_t a, const padic_ctx_t ctx) + # Sets the `p`-adic number ``y`` to ``poly`` evaluated at `a`, + # reduced in the given context. + # Suppose that the polynomial can be written as `F(X) = p^w f(X)` + # with `\operatorname{ord}_p(f) = 1`, that `\operatorname{ord}_p(a) = b` and that both are + # defined to precision~`N`. Then `f` is defined to precision + # `N-w` and so `f(a)` is defined to precision `N-w` when `a` is + # integral and `N-w+(n-1)b` when `b < 0`, where `n = \deg(f)`. Thus, + # `y = F(a)` is defined to precision `N` when `a` is integral and + # `N+(n-1)b` when `b < 0`. + + void _padic_poly_compose(fmpz *rop, long *rval, long N, const fmpz *op1, long val1, long len1, const fmpz *op2, long val2, long len2, const padic_ctx_t ctx) + # Sets ``(rop, *rval, (len1-1)*(len2-1)+1)`` to the composition + # of the two input polynomials, reducing the result modulo `p^N`. + # Assumes that ``len1`` is non-zero. + # Does not support aliasing. + + void padic_poly_compose(padic_poly_t rop, const padic_poly_t op1, const padic_poly_t op2, const padic_ctx_t ctx) + # Sets ``rop`` to the composition of ``op1`` and ``op2``, + # reducing the result in the given context. + # To be clear about the order of composition, let `f(X)` and `g(X)` + # denote the polynomials ``op1`` and ``op2``, respectively. + # Then ``rop`` is set to `f(g(X))`. + + void _padic_poly_compose_pow(fmpz *rop, long *rval, long N, const fmpz *op, long val, long len, long k, const padic_ctx_t ctx) + # Sets ``(rop, *rval, (len - 1)*k + 1)`` to the composition of + # ``(op, val, len)`` and the monomial `x^k`, where `k \geq 1`. + # Assumes that ``len`` is positive. + # Supports aliasing between the input and output polynomials. + + void padic_poly_compose_pow(padic_poly_t rop, const padic_poly_t op, long k, const padic_ctx_t ctx) + # Sets ``rop`` to the composition of ``op`` and the monomial `x^k`, + # where `k \geq 1`. + # Note that no reduction takes place. - #* Addition and subtraction ************************************************/ - void _padic_poly_add(fmpz *rop, long *rval, long N, - const fmpz *op1, long val1, long len1, long N1, - const fmpz *op2, long val2, long len2, long N2, - const padic_ctx_t ctx) - void padic_poly_add(padic_poly_t f, - const padic_poly_t g, const padic_poly_t h, - const padic_ctx_t ctx) - void _padic_poly_sub(fmpz *rop, long *rval, long N, - const fmpz *op1, long val1, long len1, long N1, - const fmpz *op2, long val2, long len2, long N2, - const padic_ctx_t ctx) - void padic_poly_sub(padic_poly_t f, - const padic_poly_t g, const padic_poly_t h, - const padic_ctx_t ctx) - void padic_poly_neg(padic_poly_t f, const padic_poly_t g, - const padic_ctx_t ctx) - -#* Scalar multiplication and division **************************************/ - void _padic_poly_scalar_mul_padic(fmpz *rop, long *rval, long N, - const fmpz *op, long val, long len, - const padic_t c, const padic_ctx_t ctx) - void padic_poly_scalar_mul_padic(padic_poly_t rop, const padic_poly_t op, - const padic_t c, const padic_ctx_t ctx) - -#* Multiplication **********************************************************/ - void _padic_poly_mul(fmpz *rop, long *rval, long N, - const fmpz *op1, long val1, long len1, - const fmpz *op2, long val2, long len2, - const padic_ctx_t ctx) - void padic_poly_mul(padic_poly_t f, - const padic_poly_t g, const padic_poly_t h, - const padic_ctx_t ctx) - -#* Powering ****************************************************************/ - void _padic_poly_pow(fmpz *rop, long *rval, long N, - const fmpz *op, long val, long len, unsigned long e, - const padic_ctx_t ctx) - void padic_poly_pow(padic_poly_t rop, const padic_poly_t op, unsigned long e, - const padic_ctx_t ctx) - -#* Series inversion ********************************************************/ - void padic_poly_inv_series(padic_poly_t Qinv, const padic_poly_t Q, long n, - const padic_ctx_t ctx) - -#* Derivative **************************************************************/ - void _padic_poly_derivative(fmpz *rop, long *rval, long N, - const fmpz *op, long val, long len, - const padic_ctx_t ctx) - void padic_poly_derivative(padic_poly_t rop, - const padic_poly_t op, const padic_ctx_t ctx) - -#* Shifting ****************************************************************/ - void padic_poly_shift_left(padic_poly_t rop, const padic_poly_t op, long n, - const padic_ctx_t ctx) - void padic_poly_shift_right(padic_poly_t rop, const padic_poly_t op, long n, - const padic_ctx_t ctx) - -#* Evaluation **************************************************************/ - void _padic_poly_evaluate_padic(fmpz_t u, long *v, long N, - const fmpz *poly, long val, long len, - const fmpz_t a, long b, const padic_ctx_t ctx) - void padic_poly_evaluate_padic(padic_t y, const padic_poly_t poly, - const padic_t x, const padic_ctx_t ctx) - -#* Composition *************************************************************/ - void _padic_poly_compose(fmpz *rop, long *rval, long N, - const fmpz *op1, long val1, long len1, - const fmpz *op2, long val2, long len2, - const padic_ctx_t ctx) - void padic_poly_compose(padic_poly_t rop, - const padic_poly_t op1, const padic_poly_t op2, - const padic_ctx_t ctx) - void _padic_poly_compose_pow(fmpz *rop, long *rval, long N, - const fmpz *op, long val, long len, long k, - const padic_ctx_t ctx) - void padic_poly_compose_pow(padic_poly_t rop, const padic_poly_t op, long k, - const padic_ctx_t ctx) - - #* Input and output ********************************************************/ int padic_poly_debug(const padic_poly_t poly) - int _padic_poly_fprint(FILE *file, const fmpz *poly, long val, long len, - const padic_ctx_t ctx) - int padic_poly_fprint(FILE *file, const padic_poly_t poly, - const padic_ctx_t ctx) - int _padic_poly_print(const fmpz *poly, long val, long len, - const padic_ctx_t ctx) + # Prints the data defining the `p`-adic polynomial ``poly`` + # in a simple format useful for debugging purposes. + # In the current implementation, always returns `1`. + + int _padic_poly_fprint(FILE *file, const fmpz *poly, long val, long len, const padic_ctx_t ctx) + int padic_poly_fprint(FILE *file, const padic_poly_t poly, const padic_ctx_t ctx) + # Prints a simple representation of the polynomial ``poly`` + # to the stream ``file``. + # A non-zero polynomial is represented by the number of coefficients, + # two spaces, followed by a list of the coefficients, which are printed + # in a way depending on the print mode, + # In the ``PADIC_TERSE`` mode, the coefficients are printed as + # rational numbers. + # The ``PADIC_SERIES`` mode is currently not supported and will + # raise an abort signal. + # In the ``PADIC_VAL_UNIT`` mode, the coefficients are printed + # in the form `p^v u`. + # The zero polynomial is represented by ``"0"``. + # In the current implementation, always returns `1`. + + int _padic_poly_print(const fmpz *poly, long val, long len, const padic_ctx_t ctx) int padic_poly_print(const padic_poly_t poly, const padic_ctx_t ctx) - int _padic_poly_fprint_pretty(FILE *file, - const fmpz *poly, long val, long len, - const char *var, - const padic_ctx_t ctx) - int padic_poly_fprint_pretty(FILE *file, - const padic_poly_t poly, const char *var, - const padic_ctx_t ctx) - int _padic_poly_print_pretty(FILE *file, - const fmpz *poly, long val, long len, - const char *var, - const padic_ctx_t ctx) - int padic_poly_print_pretty(const padic_poly_t poly, const char *var, - const padic_ctx_t ctx) - - #* Testing *****************************************************************/ - int _padic_poly_is_canonical(const fmpz *op, long val, long len, - const padic_ctx_t ctx) + # Prints a simple representation of the polynomial ``poly`` + # to ``stdout``. + # In the current implementation, always returns `1`. + + int _padic_poly_fprint_pretty(FILE *file, const fmpz *poly, long val, long len, const char *var, const padic_ctx_t ctx) + int padic_poly_fprint_pretty(FILE *file, const padic_poly_t poly, const char *var, const padic_ctx_t ctx) + int _padic_poly_print_pretty(const fmpz *poly, long val, long len, const char *var, const padic_ctx_t ctx) + int padic_poly_print_pretty(const padic_poly_t poly, const char *var, const padic_ctx_t ctx) + + int _padic_poly_is_canonical(const fmpz *op, long val, long len, const padic_ctx_t ctx) int padic_poly_is_canonical(const padic_poly_t op, const padic_ctx_t ctx) - int _padic_poly_is_reduced(const fmpz *op, long val, long len, long N, - const padic_ctx_t ctx) + int _padic_poly_is_reduced(const fmpz *op, long val, long len, long N, const padic_ctx_t ctx) int padic_poly_is_reduced(const padic_poly_t op, const padic_ctx_t ctx) diff --git a/src/sage/libs/flint/qadic.pxd b/src/sage/libs/flint/qadic.pxd index ec64e9eef74..86fc1237bf7 100644 --- a/src/sage/libs/flint/qadic.pxd +++ b/src/sage/libs/flint/qadic.pxd @@ -1,119 +1,375 @@ # distutils: libraries = flint # distutils: depends = flint/qadic.h +################################################################################ +# This file is auto-generated. Do not modify by hand +################################################################################ + +from libc.stdio cimport FILE +from sage.libs.gmp.types cimport * +from sage.libs.mpfr.types cimport * from sage.libs.flint.types cimport * -# flint/qadic.h cdef extern from "flint_wrap.h": - long qadic_val(const qadic_t op) - long qadic_prec(const qadic_t op) - void qadic_ctx_init_conway(qadic_ctx_t ctx, - const fmpz_t p, long d, long min, long max, - const char *var, padic_print_mode mode) + void qadic_ctx_init(qadic_ctx_t ctx, const fmpz_t p, long d, long min, long max, const char *var, padic_print_mode mode) + # Initialises the context ``ctx`` with prime `p`, extension degree `d`, + # variable name ``var`` and printing mode ``mode``. The defining polynomial + # is chosen as a Conway polynomial if possible and otherwise as a random + # sparse polynomial. + # Stores powers of `p` with exponents between ``min`` (inclusive) and + # ``max`` exclusive. Assumes that ``min`` is at most ``max``. + # Assumes that `p` is a prime. + # Assumes that the string ``var`` is a null-terminated string + # of length at least one. + # Assumes that the printing mode is one of ``PADIC_TERSE``, + # ``PADIC_SERIES``, or ``PADIC_VAL_UNIT``. + # This function also carries out some relevant precomputation for + # arithmetic in `\mathbf{Q}_p / (p^N)` such as powers of `p` close + # to `p^N`. + + void qadic_ctx_init_conway(qadic_ctx_t ctx, const fmpz_t p, long d, long min, long max, const char *var, padic_print_mode mode) + # Initialises the context ``ctx`` with prime `p`, extension degree `d`, + # variable name ``var`` and printing mode ``mode``. The defining polynomial + # is chosen as a Conway polynomial, hence has restrictions on the + # prime and the degree. + # Stores powers of `p` with exponents between ``min`` (inclusive) and + # ``max`` exclusive. Assumes that ``min`` is at most ``max``. + # Assumes that `p` is a prime. + # Assumes that the string ``var`` is a null-terminated string + # of length at least one. + # Assumes that the printing mode is one of ``PADIC_TERSE``, + # ``PADIC_SERIES``, or ``PADIC_VAL_UNIT``. + # This function also carries out some relevant precomputation for + # arithmetic in `\mathbf{Q}_p / (p^N)` such as powers of `p` close + # to `p^N`. + void qadic_ctx_clear(qadic_ctx_t ctx) + # Clears all memory that has been allocated as part of the context. + long qadic_ctx_degree(const qadic_ctx_t ctx) + # Returns the extension degree. + void qadic_ctx_print(const qadic_ctx_t ctx) + # Prints the data from the given context. + + void qadic_init(qadic_t rop) + # Initialises the element ``rop``, setting its value to `0`. - #* Memory management *********************************************************/ - void qadic_init(qadic_t x) void qadic_init2(qadic_t rop, long prec) - void qadic_clear(qadic_t x) + # Initialises the element ``rop`` with the given output precision, + # setting the value to `0`. + + void qadic_clear(qadic_t rop) + # Clears the element ``rop``. + void _fmpz_poly_reduce(fmpz *R, long lenR, const fmpz *a, const long *j, long len) - void _fmpz_mod_poly_reduce(fmpz *R, long lenR, - const fmpz *a, const long *j, long len, const fmpz_t p) - void qadic_reduce(qadic_t x, const qadic_ctx_t ctx) - - #* Randomisation *************************************************************/ - void qadic_randtest(qadic_t x, flint_rand_t state, const qadic_ctx_t ctx) - void qadic_randtest_not_zero(qadic_t x, flint_rand_t state, const qadic_ctx_t ctx) - void qadic_randtest_val(qadic_t x, flint_rand_t state, long val, - const qadic_ctx_t ctx) - void qadic_randtest_int(qadic_t x, flint_rand_t state, const qadic_ctx_t ctx) - - #* Assignments and conversions ***********************************************/ - void qadic_zero(qadic_t op) - void qadic_one(qadic_t op) - void qadic_gen(qadic_t x, const qadic_ctx_t ctx) + # Reduces a polynomial ``(R, lenR)`` modulo a sparse monic + # polynomial `f(X) = \sum_{i} a_{i} X^{j_{i}}` of degree at + # least `2`. + # Assumes that the array `j` of positive length ``len`` is + # sorted in ascending order. + # Allows zero-padding in ``(R, lenR)``. + + void _fmpz_mod_poly_reduce(fmpz *R, long lenR, const fmpz *a, const long *j, long len, const fmpz_t p) + # Reduces a polynomial ``(R, lenR)`` modulo a sparse monic + # polynomial `f(X) = \sum_{i} a_{i} X^{j_{i}}` of degree at + # least `2` in `\mathbf{Z}/(p)`, where `p` is typically a prime + # power. + # Assumes that the array `j` of positive length ``len`` is + # sorted in ascending order. + # Allows zero-padding in ``(R, lenR)``. + + void qadic_reduce(qadic_t rop, const qadic_ctx_t ctx) + # Reduces ``rop`` modulo `f(X)` and `p^N`. + + long qadic_val(const qadic_t op) + # Returns the valuation of ``op``. + + long qadic_prec(const qadic_t op) + # Returns the precision of ``op``. + + void qadic_randtest(qadic_t rop, flint_rand_t state, const qadic_ctx_t ctx) + # Generates a random element of `\mathbf{Q}_q`. + + void qadic_randtest_not_zero(qadic_t rop, flint_rand_t state, const qadic_ctx_t ctx) + # Generates a random non-zero element of `\mathbf{Q}_q`. + + void qadic_randtest_val(qadic_t rop, flint_rand_t state, long v, const qadic_ctx_t ctx) + # Generates a random element of `\mathbf{Q}_q` with prescribed + # valuation ``val``. + # Note that if `v \geq N` then the element is necessarily zero. + + void qadic_randtest_int(qadic_t rop, flint_rand_t state, const qadic_ctx_t ctx) + # Generates a random element of `\mathbf{Q}_q` with non-negative valuation. + + void qadic_set(qadic_t rop, const qadic_t op, const qadic_ctx_t ctx) + # Sets ``rop`` to ``op``. + + void qadic_zero(qadic_t rop) + # Sets ``rop`` to zero. + + void qadic_one(qadic_t rop) + # Sets ``rop`` to one, reduced in the given context. + # Note that if the precision `N` is non-positive then ``rop`` + # is actually set to zero. + + void qadic_gen(qadic_t rop, const qadic_ctx_t ctx) + # Sets ``rop`` to the generator `X` for the extension + # when `N > 0`, and zero otherwise. If the extension degree + # is one, raises an abort signal. + void qadic_set_ui(qadic_t rop, unsigned long op, const qadic_ctx_t ctx) + # Sets ``rop`` to the integer ``op``, reduced in the + # context. + int qadic_get_padic(padic_t rop, const qadic_t op, const qadic_ctx_t ctx) - void qadic_set(qadic_t rop, const qadic_t op, const qadic_ctx_t ctx) - void qadic_set_fmpz_poly(qadic_t rop, const fmpz_poly_t op, - const qadic_ctx_t ctx) + # If the element ``op`` lies in `\mathbf{Q}_p`, sets ``rop`` + # to its value and returns `1`; otherwise, returns `0`. - #* Comparison ****************************************************************/ int qadic_is_zero(const qadic_t op) + # Returns whether ``op`` is equal to zero. + int qadic_is_one(const qadic_t op) + # Returns whether ``op`` is equal to one in the given + # context. + int qadic_equal(const qadic_t op1, const qadic_t op2) + # Returns whether ``op1`` and ``op2`` are equal. + + void qadic_add(qadic_t rop, const qadic_t op1, const qadic_t op2, const qadic_ctx_t ctx) + # Sets ``rop`` to the sum of ``op1`` and ``op2``. + # Assumes that both ``op1`` and ``op2`` are reduced in the + # given context and ensures that ``rop`` is, too. + + void qadic_sub(qadic_t rop, const qadic_t op1, const qadic_t op2, const qadic_ctx_t ctx) + # Sets ``rop`` to the difference of ``op1`` and ``op2``. + # Assumes that both ``op1`` and ``op2`` are reduced in the + # given context and ensures that ``rop`` is, too. + + void qadic_neg(qadic_t rop, const qadic_t op, const qadic_ctx_t ctx) + # Sets ``rop`` to the negative of ``op``. + # Assumes that ``op`` is reduced in the given context and + # ensures that ``rop`` is, too. + + void qadic_mul(qadic_t rop, const qadic_t op1, const qadic_t op2, const qadic_ctx_t ctx) + # Sets ``rop`` to the product of ``op1`` and ``op2``, + # reducing the output in the given context. + + void _qadic_inv(fmpz *rop, const fmpz *op, long len, const fmpz *a, const long *j, long lena, const fmpz_t p, long N) + # Sets ``(rop, d)`` to the inverse of ``(op, len)`` + # modulo `f(X)` given by ``(a,j,lena)`` and `p^N`. + # Assumes that ``(op,len)`` has valuation `0`, that is, + # that it represents a `p`-adic unit. + # Assumes that ``len`` is at most `d`. + # Does not support aliasing. + + void qadic_inv(qadic_t rop, const qadic_t op, const qadic_ctx_t ctx) + # Sets ``rop`` to the inverse of ``op``, reduced in the given context. + + void _qadic_pow(fmpz *rop, const fmpz *op, long len, const fmpz_t e, const fmpz *a, const long *j, long lena, const fmpz_t p) + # Sets ``(rop, 2*d-1)`` to ``(op,len)`` raised to the power `e`, + # reduced modulo `f(X)` given by ``(a, j, lena)`` and `p`, which + # is expected to be a prime power. + # Assumes that `e \geq 0` and that ``len`` is positive and at most `d`. + # Although we require that ``rop`` provides space for + # `2d - 1` coefficients, the output will be reduced modulo + # `f(X)`, which is a polynomial of degree `d`. + # Does not support aliasing. + + void qadic_pow(qadic_t rop, const qadic_t op, const fmpz_t e, const qadic_ctx_t ctx) + # Sets ``rop`` the ``op`` raised to the power `e`. + # Currently assumes that `e \geq 0`. + # Note that for any input ``op``, ``rop`` is set to one in the + # given context whenever `e = 0`. + + int qadic_sqrt(qadic_t rop, const qadic_t op, const qadic_ctx_t ctx) + # Return ``1`` if the input is a square (to input precision). If so, set + # ``rop`` to a square root (truncated to output precision). + + void _qadic_exp_rectangular(fmpz *rop, const fmpz *op, long v, long len, const fmpz *a, const long *j, long lena, const fmpz_t p, long N, const fmpz_t pN) + # Sets ``(rop, 2*d - 1)`` to the exponential of ``(op, v, len)`` + # reduced modulo `p^N`, assuming that the series converges. + # Assumes that ``(op, v, len)`` is non-zero. + # Does not support aliasing. + + int qadic_exp_rectangular(qadic_t rop, const qadic_t op, const qadic_ctx_t ctx) + # Returns whether the exponential series converges at ``op`` + # and sets ``rop`` to its value reduced modulo in the given + # context. + + void _qadic_exp_balanced(fmpz *rop, const fmpz *x, long v, long len, const fmpz *a, const long *j, long lena, const fmpz_t p, long N, const fmpz_t pN) + # Sets ``(rop, d)`` to the exponential of ``(op, v, len)`` + # reduced modulo `p^N`, assuming that the series converges. + # Assumes that ``len`` is in `[1,d)` but supports zero padding, + # including the special case when ``(op, len)`` is zero. + # Supports aliasing between ``rop`` and ``op``. + + int qadic_exp_balanced(qadic_t rop, const qadic_t op, const qadic_ctx_t ctx) + # Returns whether the exponential series converges at ``op`` + # and sets ``rop`` to its value reduced modulo in the given + # context. + + void _qadic_exp(fmpz *rop, const fmpz *op, long v, long len, const fmpz *a, const long *j, long lena, const fmpz_t p, long N, const fmpz_t pN) + # Sets ``(rop, 2*d - 1)`` to the exponential of ``(op, v, len)`` + # reduced modulo `p^N`, assuming that the series converges. + # Assumes that ``(op, v, len)`` is non-zero. + # Does not support aliasing. - #* Basic arithmetic **********************************************************/ - void qadic_add(qadic_t x, const qadic_t y, const qadic_t z, const qadic_ctx_t ctx) - void qadic_sub(qadic_t x, const qadic_t y, const qadic_t z, const qadic_ctx_t ctx) - void qadic_neg(qadic_t x, const qadic_t y, const qadic_ctx_t ctx) - void qadic_mul(qadic_t x, const qadic_t y, const qadic_t z, - const qadic_ctx_t ctx) - void _qadic_inv(fmpz *rop, const fmpz *op, long len, - const fmpz *a, const long *j, long lena, - const fmpz_t p, long N) - void qadic_inv(qadic_t x, const qadic_t y, const qadic_ctx_t ctx) - void _qadic_pow(fmpz *rop, const fmpz *op, long len, const fmpz_t e, - const fmpz *a, const long *j, long lena, - const fmpz_t p) - void qadic_pow(qadic_t x, const qadic_t y, const fmpz_t e, const qadic_ctx_t ctx) - - #* Special functions *********************************************************/ - void _qadic_exp_rectangular(fmpz *rop, const fmpz *op, long v, long len, - const fmpz *a, const long *j, long lena, - const fmpz_t p, long N, const fmpz_t pN) - int qadic_exp_rectangular(qadic_t rop, const qadic_t op, - const qadic_ctx_t ctx) - void _qadic_exp_balanced(fmpz *rop, const fmpz *op, long v, long len, - const fmpz *a, const long *j, long lena, - const fmpz_t p, long N, const fmpz_t pN) - int qadic_exp_balanced(qadic_t rop, const qadic_t op, - const qadic_ctx_t ctx) - void _qadic_exp(fmpz *rop, const fmpz *op, long v, long len, - const fmpz *a, const long *j, long lena, - const fmpz_t p, long N, const fmpz_t pN) int qadic_exp(qadic_t rop, const qadic_t op, const qadic_ctx_t ctx) - void _qadic_log_rectangular(fmpz *z, const fmpz *y, long v, long len, - const fmpz *a, const long *j, long lena, - const fmpz_t p, long N, const fmpz_t pN) + # Returns whether the exponential series converges at ``op`` + # and sets ``rop`` to its value reduced modulo in the given + # context. + # The exponential series converges if the valuation of ``op`` + # is at least `2` or `1` when `p` is even or odd, respectively. + + void _qadic_log_rectangular(fmpz *z, const fmpz *y, long v, long len, const fmpz *a, const long *j, long lena, const fmpz_t p, long N, const fmpz_t pN) + # Computes + # .. math :: + # z = - \sum_{i = 1}^{\infty} \frac{y^i}{i} \pmod{p^N}. + # Note that this can be used to compute the `p`-adic logarithm + # via the equation + # .. math :: + # \log(x) & = \sum_{i=1}^{\infty} (-1)^{i-1} \frac{(x-1)^i}{i} \\ + # & = - \sum_{i=1}^{\infty} \frac{(1-x)^i}{i}. + # Assumes that `y = 1 - x` is non-zero and that `v = \operatorname{ord}_p(y)` + # is at least `1` when `p` is odd and at least `2` when `p = 2` + # so that the series converges. + # Assumes that `y` is reduced modulo `p^N`. + # Assumes that `v < N`, and in particular `N \geq 2`. + # Supports aliasing between `y` and `z`. + int qadic_log_rectangular(qadic_t rop, const qadic_t op, const qadic_ctx_t ctx) - void _qadic_log_balanced(fmpz *z, const fmpz *y, long len, - const fmpz *a, const long *j, long lena, - const fmpz_t p, long N, const fmpz_t pN) + # Returns whether the `p`-adic logarithm function converges at + # ``op``, and if so sets ``rop`` to its value. + + void _qadic_log_balanced(fmpz *z, const fmpz *y, long len, const fmpz *a, const long *j, long lena, const fmpz_t p, long N, const fmpz_t pN) + # Computes `(z, d)` as + # .. math :: + # z = - \sum_{i = 1}^{\infty} \frac{y^i}{i} \pmod{p^N}. + # Assumes that `v = \operatorname{ord}_p(y)` is at least `1` when `p` is odd and + # at least `2` when `p = 2` so that the series converges. + # Supports aliasing between `z` and `y`. + int qadic_log_balanced(qadic_t rop, const qadic_t op, const qadic_ctx_t ctx) - void _qadic_log(fmpz *z, const fmpz *y, long v, long len, - const fmpz *a, const long *j, long lena, - const fmpz_t p, long N, const fmpz_t pN) + # Returns whether the `p`-adic logarithm function converges at + # ``op``, and if so sets ``rop`` to its value. + + void _qadic_log(fmpz *z, const fmpz *y, long v, long len, const fmpz *a, const long *j, long lena, const fmpz_t p, long N, const fmpz_t pN) + # Computes `(z, d)` as + # .. math :: + # z = - \sum_{i = 1}^{\infty} \frac{y^i}{i} \pmod{p^N}. + # Note that this can be used to compute the `p`-adic logarithm + # via the equation + # .. math :: + # \log(x) & = \sum_{i=1}^{\infty} (-1)^{i-1} \frac{(x-1)^i}{i} \\ + # & = - \sum_{i=1}^{\infty} \frac{(1-x)^i}{i}. + # Assumes that `y = 1 - x` is non-zero and that `v = \operatorname{ord}_p(y)` + # is at least `1` when `p` is odd and at least `2` when `p = 2` + # so that the series converges. + # Assumes that `(y, d)` is reduced modulo `p^N`. + # Assumes that `v < N`, and hence in particular `N \geq 2`. + # Supports aliasing between `z` and `y`. + int qadic_log(qadic_t rop, const qadic_t op, const qadic_ctx_t ctx) - void _qadic_frobenius(fmpz *rop, const fmpz *op, long len, long e, - const fmpz *a, const long *j, long lena, - const fmpz_t p, long N) + # Returns whether the `p`-adic logarithm function converges at + # ``op``, and if so sets ``rop`` to its value. + # The `p`-adic logarithm function is defined by the usual series + # .. math :: + # \log_p(x) = \sum_{i=1}^{\infty} (-1)^{i-1} \frac{(x-1)^i}{i} + # but this only converges when `\operatorname{ord}_p(x)` is at least `2` or `1` + # when `p = 2` or `p > 2`, respectively. + + void _qadic_frobenius_a(fmpz *rop, long e, const fmpz *a, const long *j, long lena, const fmpz_t p, long N) + # Computes `\sigma^e(X) \bmod{p^N}` where `X` is such that + # `\mathbf{Q}_q \cong \mathbf{Q}_p[X]/(f(X))`. + # Assumes that the precision `N` is at least `2` and that the + # extension is non-trivial, i.e. `d \geq 2`. + # Assumes that `0 < e < d`. + # Sets ``(rop, 2*d-1)``, although the actual length of the + # output will be at most `d`. + + void _qadic_frobenius(fmpz *rop, const fmpz *op, long len, long e, const fmpz *a, const long *j, long lena, const fmpz_t p, long N) + # Sets ``(rop, 2*d-1)`` to `\Sigma` evaluated at ``(op, len)``. + # Assumes that ``len`` is positive but at most `d`. + # Assumes that `0 < e < d`. + # Does not support aliasing. + void qadic_frobenius(qadic_t rop, const qadic_t op, long e, const qadic_ctx_t ctx) - void _qadic_teichmuller(fmpz *rop, const fmpz *op, long len, - const fmpz *a, const long *j, long lena, - const fmpz_t p, long N) + # Evaluates the homomorphism `\Sigma^e` at ``op``. + # Recall that `\mathbf{Q}_q / \mathbf{Q}_p` is Galois with Galois group + # `\langle \Sigma \rangle \cong \langle \sigma \rangle`, which is also + # isomorphic to `\mathbf{Z}/d\mathbf{Z}`, where + # `\sigma \in \operatorname{Gal}(\mathbf{F}_q/\mathbf{F}_p)` is the Frobenius element + # `\sigma \colon x \mapsto x^p` and `\Sigma` is its lift to + # `\operatorname{Gal}(\mathbf{Q}_q/\mathbf{Q}_p)`. + # This functionality is implemented as ``GaloisImage()`` in Magma. + + void _qadic_teichmuller(fmpz *rop, const fmpz *op, long len, const fmpz *a, const long *j, long lena, const fmpz_t p, long N) + # Sets ``(rop, d)`` to the Teichmüller lift of ``(op, len)`` + # modulo `p^N`. + # Does not support aliasing. + void qadic_teichmuller(qadic_t rop, const qadic_t op, const qadic_ctx_t ctx) - void _qadic_trace(fmpz_t rop, const fmpz *op, long len, - const fmpz *a, const long *j, long lena, const fmpz_t pN) + # Sets ``rop`` to the Teichmüller lift of ``op`` to the + # precision given in the context. + # For a unit ``op``, this is the unique `(q-1)`\th root of unity + # which is congruent to ``op`` modulo `p`. + # Sets ``rop`` to zero if ``op`` is zero in the given context. + # Raises an exception if the valuation of ``op`` is negative. + + void _qadic_trace(fmpz_t rop, const fmpz *op, long len, const fmpz *a, const long *j, long lena, const fmpz_t pN) void qadic_trace(padic_t rop, const qadic_t op, const qadic_ctx_t ctx) - void _qadic_norm_resultant(fmpz_t rop, const fmpz *op, long len, - const fmpz *a, const long *j, long lena, - const fmpz_t p, long N) - void _qadic_norm_analytic(fmpz_t rop, const fmpz *y, long v, long len, - const fmpz *a, const long *j, long lena, - const fmpz_t p, long N) - void _qadic_norm(fmpz_t rop, const fmpz *op, long len, - const fmpz *a, const long *j, long lena, - const fmpz_t p, long N) + # Sets ``rop`` to the trace of ``op``. + # For an element `a \in \mathbf{Q}_q`, multiplication by `a` defines + # a `\mathbf{Q}_p`-linear map on `\mathbf{Q}_q`. We define the trace + # of `a` as the trace of this map. Equivalently, if `\Sigma` generates + # `\operatorname{Gal}(\mathbf{Q}_q / \mathbf{Q}_p)` then the trace of `a` is equal to + # `\sum_{i=0}^{d-1} \Sigma^i (a)`. + + void _qadic_norm(fmpz_t rop, const fmpz *op, long len, const fmpz *a, const long *j, long lena, const fmpz_t p, long N) + # Sets ``rop`` to the norm of the element ``(op,len)`` + # in `\mathbf{Z}_q` to precision `N`, where ``len`` is at + # least one. + # The result will be reduced modulo `p^N`. + # Note that whenever ``(op,len)`` is a unit, so is its norm. + # Thus, the output ``rop`` of this function will typically + # not have to be canonicalised or reduced by the caller. + void qadic_norm(padic_t rop, const qadic_t op, const qadic_ctx_t ctx) + # Computes the norm of ``op`` to the given precision. + # Algorithm selection is automatic depending on the input. + void qadic_norm_analytic(padic_t rop, const qadic_t op, const qadic_ctx_t ctx) + # Whenever ``op`` has valuation greater than `(p-1)^{-1}`, this + # routine computes its norm ``rop`` via + # .. math :: + # \operatorname{Norm} (x) = \exp \Bigl( \bigl( \operatorname{Trace} \log (x) \bigr) \Bigr). + # In the special case that ``op`` lies in `\mathbf{Q}_p`, returns + # its norm as `\operatorname{Norm}(x) = x^d`, where `d` is the extension degree. + # Otherwise, raises an ``abort`` signal. + # The complexity of this implementation is quasi-linear in `d` and `N`, + # and polynomial in `\log p`. + void qadic_norm_resultant(padic_t rop, const qadic_t op, const qadic_ctx_t ctx) - int qadic_sqrt(qadic_t rop, const qadic_t op, const qadic_ctx_t ctx) + # Sets ``rop`` to the norm of ``op``, using the formula + # .. math :: + # \operatorname{Norm}(x) = \ell(f)^{-\deg(a)} \operatorname{Res}(f(X), a(X)), + # where `\mathbf{Q}_q \cong \mathbf{Q}_p[X] / (f(X))`, `\ell(f)` is the + # leading coefficient of `f(X)`, and `a(X) \in \mathbf{Q}_p[X]` denotes + # the same polynomial as `x`. + # The complexity of the current implementation is given by + # `\mathcal{O}(d^4 M(N \log p))`, where `M(n)` denotes the + # complexity of multiplying to `n`-bit integers. - #* Output ********************************************************************/ int qadic_fprint_pretty(FILE *file, const qadic_t op, const qadic_ctx_t ctx) + # Prints a pretty representation of ``op`` to ``file``. + # In the current implementation, always returns `1`. The return code is + # part of the function's signature to allow for a later implementation to + # return the number of characters printed or a non-positive error code. + int qadic_print_pretty(const qadic_t op, const qadic_ctx_t ctx) - int qadic_debug(const qadic_t op) + # Prints a pretty representation of ``op`` to ``stdout``. + # In the current implementation, always returns `1`. The return code is + # part of the function's signature to allow for a later implementation to + # return the number of characters printed or a non-positive error code. diff --git a/src/sage/libs/flint/qsieve.pyx b/src/sage/libs/flint/qsieve.pyx index 7d93d41f4cc..78c28198718 100644 --- a/src/sage/libs/flint/qsieve.pyx +++ b/src/sage/libs/flint/qsieve.pyx @@ -5,8 +5,10 @@ been absorbed into flint. """ from cysignals.signals cimport sig_on, sig_off -from sage.libs.flint.fmpz cimport fmpz_t, fmpz_init, fmpz_set_mpz -from sage.libs.flint.fmpz_factor cimport * +from .types cimport fmpz_t +from .fmpz cimport fmpz_init, fmpz_set_mpz +from .fmpz_factor cimport fmpz_factor_init, fmpz_factor_clear +from .fmpz_factor_extra cimport fmpz_factor_to_pairlist from sage.rings.integer cimport Integer diff --git a/src/sage/libs/flint/thread_pool.pxd b/src/sage/libs/flint/thread_pool.pxd index a2cd915de79..98a7f0149bb 100644 --- a/src/sage/libs/flint/thread_pool.pxd +++ b/src/sage/libs/flint/thread_pool.pxd @@ -11,22 +11,10 @@ # http://www.gnu.org/licenses/ #***************************************************************************** -from sage.libs.flint.types cimport slong +from .types cimport slong, thread_pool_entry_t, thread_pool_t # flint/thread_pool.h cdef extern from "flint/thread_pool.h": - ctypedef struct thread_pool_entry_struct: - pass - - ctypedef thread_pool_entry_struct thread_pool_entry_t[1] - - ctypedef struct thread_pool_struct: - pass - - ctypedef thread_pool_struct thread_pool_t[1] - ctypedef int thread_pool_handle - - extern thread_pool_t global_thread_pool extern int global_thread_pool_initialized diff --git a/src/sage/libs/flint/types.pxd b/src/sage/libs/flint/types.pxd index aee66dc9aa2..58d795c773c 100644 --- a/src/sage/libs/flint/types.pxd +++ b/src/sage/libs/flint/types.pxd @@ -1,4 +1,4 @@ -# distutils: depends = flint/flint.h flint/fmpz.h flint/fmpz_factor.h flint/fmpz_poly.h flint/fmpz_mat.h flint/fmpq.h flint/fmpq_poly.h flint/fmpq_mat.h flint/fmpz_mod_poly.h flint/nmod_poly.h flint/fq.h flint/fq_nmod.h flint/ulong_extras.h flint/padic.h flint/padic_poly.h flint/qadic.h flint/fmpz_poly_q.h +# distutils: depends = flint/fmpz_poly_mat.h flint/fmpq_mpoly.h flint/nmod_poly_mat.h flint/perm.h flint/nmod_vec.h flint/fmpzi.h flint/mpoly.h flint/mpfr_mat.h flint/gr_implementing.h flint/nmod_poly.h flint/long_extras.h flint/partitions.h flint/fq_nmod_poly_factor.h flint/mpf_mat.h flint/fmpz_poly_q.h flint/ca_vec.h flint/double_extras.h flint/fq_nmod_mpoly_factor.h flint/fmpz_mpoly.h flint/fmpq_vec.h flint/fq_poly.h flint/fq_nmod_mat.h flint/calcium.h flint/fft_small.h flint/fmpz_vec.h flint/fexpr_builtin.h flint/ca_poly.h flint/fq_embed.h flint/nmod_poly_factor.h flint/fmpz_extras.h flint/acb_mat.h flint/gr_generic.h flint/gr_poly.h flint/fq_zech_poly_factor.h flint/fmpz_mpoly_q.h flint/nmod.h flint/ca_mat.h flint/fq_zech_vec.h flint/gr_domains.h flint/arb.h flint/nf_elem.h flint/fmpz_poly.h flint/fq_nmod_embed.h flint/arb_poly.h flint/fmpq.h flint/fmpq_mpoly_factor.h flint/acb_calc.h flint/fq_vec.h flint/padic_mat.h flint/fmpz.h flint/fmpz_mat.h flint/fmpz_mod_mat.h flint/fq_zech.h flint/double_interval.h flint/fq_default_mat.h flint/fmpz_mod_mpoly.h flint/qsieve.h flint/qfb.h flint/thread_pool.h flint/fmpz_mod_mpoly_factor.h flint/acb_modular.h flint/fq_nmod_poly.h flint/profiler.h flint/acb_hypgeom.h flint/d_mat.h flint/fq_zech_poly.h flint/fmpz_mod.h flint/qqbar.h flint/hypgeom.h flint/acb_elliptic.h flint/acb_dft.h flint/d_vec.h flint/ulong_extras.h flint/dlog.h flint/bool_mat.h flint/fmpq_poly.h flint/fexpr.h flint/machine_vectors.h flint/mag.h flint/fmpz_mpoly_factor.h flint/mpfr_vec.h flint/ca_ext.h flint/gr.h flint/acb_poly.h flint/fft.h flint/padic.h flint/dirichlet.h flint/fmpz_mod_poly_factor.h flint/fq_default.h flint/fq.h flint/gr_vec.h flint/fq_nmod.h flint/fq_zech_embed.h flint/nmod_mpoly_factor.h flint/flint.h flint/fmpz_factor.h flint/qadic.h flint/nf.h flint/gr_mpoly.h flint/arb_fpwrap.h flint/fq_default_poly.h flint/aprcl.h flint/acf.h flint/gr_special.h flint/arf.h flint/threading.h flint/fq_zech_mat.h flint/gr_mat.h flint/arb_fmpz_poly.h flint/fq_nmod_vec.h flint/fmpz_mod_poly.h flint/bernoulli.h flint/fq_default_poly_factor.h flint/arb_mat.h flint/arb_hypgeom.h flint/fq_poly_factor.h flint/nmod_mpoly.h flint/acb.h flint/fmpz_lll.h flint/fmpz_poly_factor.h flint/ca_field.h flint/acb_dirichlet.h flint/arith.h flint/fmpz_mod_vec.h flint/fmpq_mat.h flint/fq_mat.h flint/mpn_extras.h flint/mpf_vec.h flint/ca.h flint/padic_poly.h flint/nmod_mat.h flint/fq_nmod_mpoly.h flint/arb_calc.h flint/nmod_types.h """ Declarations for FLINT types @@ -19,16 +19,27 @@ from sage.libs.gmp.types cimport * # Use these typedefs in lieu of flint's ulong and slong macros ctypedef mp_limb_t ulong ctypedef mp_limb_signed_t slong +ctypedef mp_limb_t flint_bitcnt_t -# flint/flint.h: cdef extern from "flint_wrap.h": + # flint/d_mat.h + ctypedef struct d_mat_struct: + double * entries + slong r + slong c + double ** rows + + ctypedef d_mat_struct d_mat_t[1] + + + # flint/flint.h ctypedef void* flint_rand_t cdef long FLINT_BITS cdef long FLINT_D_BITS -# flint/fmpz.h: -cdef extern from "flint_wrap.h": + + # flint/fmpz.h ctypedef slong fmpz ctypedef fmpz fmpz_t[1] @@ -42,19 +53,31 @@ cdef extern from "flint_wrap.h": ctypedef fmpz_preinvn_struct[1] fmpz_preinvn_t -# flint/fmpz_factor.h: -cdef extern from "flint_wrap.h": - ctypedef struct fmpz_factor_struct: - int sign - fmpz* p - ulong* exp - slong alloc - slong num + ctypedef struct fmpz_comb_struct: + pass - ctypedef fmpz_factor_struct fmpz_factor_t[1] + ctypedef fmpz_comb_struct fmpz_comb_t[1] -# flint/fmpz_mod.h: -cdef extern from "flint_wrap.h": + ctypedef struct fmpz_comb_temp_struct: + slong Alen, Tlen + fmpz * A, * T + + ctypedef fmpz_comb_temp_struct fmpz_comb_temp_t[1] + + ctypedef struct fmpz_multi_CRT_struct: + pass + + ctypedef fmpz_multi_CRT_struct fmpz_multi_CRT_t[1] + + + # flint/fmpz_factor.h + ctypedef struct ecm_s: + pass + + ctypedef ecm_s ecm_t[1] + + + # flint/fmpz_mod.h ctypedef struct fmpz_mod_ctx_struct: pass @@ -62,12 +85,23 @@ cdef extern from "flint_wrap.h": ctypedef struct fmpz_mod_discrete_log_pohlig_hellman_entry_struct: pass + ctypedef struct fmpz_mod_discrete_log_pohlig_hellman_struct: pass + ctypedef fmpz_mod_discrete_log_pohlig_hellman_struct fmpz_mod_discrete_log_pohlig_hellman_t[1] -# flint/fmpz_poly.h: -cdef extern from "flint_wrap.h": + + # flint/fmpz_types.h + ctypedef struct fmpz_factor_struct: + int sign + fmpz* p + ulong* exp + slong alloc + slong num + + ctypedef fmpz_factor_struct fmpz_factor_t[1] + ctypedef struct fmpz_poly_struct: fmpz* coeffs long alloc @@ -75,57 +109,136 @@ cdef extern from "flint_wrap.h": ctypedef fmpz_poly_struct fmpz_poly_t[1] -# flint/fmpz_mat.h: -cdef extern from "flint_wrap.h": + ctypedef struct fmpz_poly_factor_struct: + pass + + ctypedef fmpz_poly_factor_struct fmpz_poly_factor_t[1] + ctypedef struct fmpz_mat_struct: pass ctypedef fmpz_mat_struct fmpz_mat_t[1] -# flint/fmpq.h: -cdef extern from "flint_wrap.h": + ctypedef struct fmpz_poly_mat_struct: + pass + + ctypedef fmpz_poly_mat_struct fmpz_poly_mat_t[1] + + ctypedef struct fmpz_mpoly_struct: + pass + + ctypedef fmpz_mpoly_struct fmpz_mpoly_t[1] + + ctypedef struct fmpz_mpoly_factor_struct: + pass + + ctypedef fmpz_mpoly_factor_struct fmpz_mpoly_factor_t[1]; + + ctypedef struct fmpz_poly_q_struct: + fmpz_poly_struct *num + fmpz_poly_struct *den + + ctypedef fmpz_poly_q_struct fmpz_poly_q_t[1] + + ctypedef struct fmpz_mpoly_q_struct: + pass + + ctypedef fmpz_mpoly_q_struct fmpz_mpoly_q_t[1] + + ctypedef struct fmpzi_struct: + fmpz a + fmpz b + + ctypedef fmpzi_struct fmpzi_t[1] + + + # flint/fmpz_mod_types.h + ctypedef struct fmpz_mod_ctx_struct: + pass + + ctypedef fmpz_mod_ctx_struct fmpz_mod_ctx_t[1] + + ctypedef struct fmpz_mod_mat_struct: + fmpz_mat_t mat + fmpz_t mod + + ctypedef fmpz_mod_mat_struct fmpz_mod_mat_t[1] + + ctypedef struct fmpz_mod_poly_struct: + fmpz * coeffs + slong alloc + slong length + + ctypedef fmpz_mod_poly_struct fmpz_mod_poly_t[1] + + ctypedef struct fmpz_mod_poly_factor_struct: + fmpz_mod_poly_struct * poly + slong *exp + slong num + slong alloc + + ctypedef fmpz_mod_poly_factor_struct fmpz_mod_poly_factor_t[1] + + ctypedef struct fmpz_mod_mpoly_struct: + fmpz * coeffs + ulong * exps + slong length + flint_bitcnt_t bits + slong coeffs_alloc + slong exps_alloc + + ctypedef fmpz_mod_mpoly_struct fmpz_mod_mpoly_t[1] + + ctypedef struct fmpz_mod_mpoly_factor_struct: + fmpz_t constant + fmpz_mod_mpoly_struct * poly + fmpz * exp + slong num + slong alloc + + ctypedef fmpz_mod_mpoly_factor_struct fmpz_mod_mpoly_factor_t[1] + + + # flint/fmpq.h ctypedef struct fmpq: pass ctypedef fmpq fmpq_t[1] -# flint/fmpq_poly.h: -cdef extern from "flint_wrap.h": + + # flint/fmpq_poly.h ctypedef struct fmpq_poly_struct: pass ctypedef fmpq_poly_struct fmpq_poly_t[1] -# flint/fmpq_mat.h: -cdef extern from "flint_wrap.h": + + # flint/fmpq_mat.h ctypedef struct fmpq_mat_struct: pass ctypedef fmpq_mat_struct fmpq_mat_t[1] -# flint/fmpz_poly_mat.h: -cdef extern from "flint_wrap.h": - ctypedef struct fmpz_poly_mat_struct: - pass - - ctypedef fmpz_poly_mat_struct fmpz_poly_mat_t[1] -# flint/fmpz_mod_poly.h: -cdef extern from "flint_wrap.h": + # flint/fmpz_mod_poly.h: ctypedef struct fmpz_mod_poly_struct: pass + ctypedef fmpz_mod_poly_struct fmpz_mod_poly_t[1] ctypedef struct fmpz_mod_poly_res_struct: pass + ctypedef fmpz_mod_poly_res_struct fmpz_mod_poly_res_t[1] ctypedef struct fmpz_mod_poly_frobenius_powers_2exp_struct: pass + ctypedef fmpz_mod_poly_frobenius_powers_2exp_struct fmpz_mod_poly_frobenius_powers_2exp_t[1] ctypedef struct fmpz_mod_poly_frobenius_powers_struct: pass + ctypedef fmpz_mod_poly_frobenius_powers_struct fmpz_mod_poly_frobenius_powers_t[1] ctypedef struct fmpz_mod_poly_matrix_precompute_arg_t: @@ -136,14 +249,16 @@ cdef extern from "flint_wrap.h": ctypedef struct fmpz_mod_poly_radix_struct: pass + ctypedef fmpz_mod_poly_radix_struct fmpz_mod_poly_radix_t[1] ctypedef struct fmpz_mod_berlekamp_massey_struct: pass + ctypedef fmpz_mod_berlekamp_massey_struct fmpz_mod_berlekamp_massey_t[1] -# flint/nmod_poly.h: -cdef extern from "flint_wrap.h": + + # flint/nmod_poly.h ctypedef struct nmod_t: mp_limb_t n mp_limb_t ninv @@ -165,8 +280,73 @@ cdef extern from "flint_wrap.h": ctypedef nmod_poly_factor_struct nmod_poly_factor_t[1] -# flint/fq.h: -cdef extern from "flint_wrap.h": + ctypedef struct nmod_poly_multi_crt_struct: + pass + + ctypedef nmod_poly_multi_crt_struct nmod_poly_multi_crt_t[1] + + ctypedef struct nmod_berlekamp_massey_struct: + pass + + ctypedef nmod_berlekamp_massey_struct nmod_berlekamp_massey_t[1] + + + # flint/nmod_types.h + ctypedef struct nmod_mat_struct: + mp_limb_t * entries + slong r + slong c + mp_limb_t ** rows + nmod_t mod + + ctypedef nmod_mat_struct nmod_mat_t[1] + + ctypedef struct nmod_poly_struct: + mp_ptr coeffs + slong alloc + slong length + nmod_t mod + + ctypedef nmod_poly_struct nmod_poly_t[1] + + ctypedef struct nmod_poly_factor_struct: + nmod_poly_struct * p + slong *exp + slong num + slong alloc + + ctypedef nmod_poly_factor_struct nmod_poly_factor_t[1] + + ctypedef struct nmod_poly_mat_struct: + nmod_poly_struct * entries + slong r + slong c + nmod_poly_struct ** rows + mp_limb_t modulus + + ctypedef nmod_poly_mat_struct nmod_poly_mat_t[1] + + ctypedef struct nmod_mpoly_struct: + mp_limb_t * coeffs + ulong * exps + slong length + flint_bitcnt_t bits + slong coeffs_alloc + slong exps_alloc + + ctypedef nmod_mpoly_struct nmod_mpoly_t[1] + + ctypedef struct nmod_mpoly_factor_struct: + mp_limb_t constant + nmod_mpoly_struct * poly + fmpz * exp + slong num + slong alloc + + ctypedef nmod_mpoly_factor_struct nmod_mpoly_factor_t[1] + + + # flint/fq.h ctypedef struct fq_ctx_struct: fmpz_mod_poly_t modulus @@ -175,8 +355,8 @@ cdef extern from "flint_wrap.h": ctypedef fmpz_poly_struct fq_struct ctypedef fmpz_poly_t fq_t -# flint/fq_nmod.h: -cdef extern from "flint_wrap.h": + + # flint/fq_nmod.h ctypedef struct fq_nmod_ctx_struct: nmod_poly_t modulus @@ -185,15 +365,15 @@ cdef extern from "flint_wrap.h": ctypedef nmod_poly_struct fq_nmod_struct ctypedef nmod_poly_t fq_nmod_t -# flint/ulong_extras.h: -cdef extern from "flint_wrap.h": + + # flint/ulong_extras.h ctypedef struct n_factor_t: int num unsigned long exp[15] unsigned long p[15] -# flint/padic.h: -cdef extern from "flint_wrap.h": + + # flint/padic.h ctypedef struct padic_struct: fmpz u long v @@ -222,8 +402,8 @@ cdef extern from "flint_wrap.h": ctypedef padic_inv_struct padic_inv_t[1] -# flint/padic_poly.h: -cdef extern from "flint_wrap.h": + + # flint/padic_poly.h ctypedef struct padic_poly_struct: fmpz *coeffs long alloc @@ -233,8 +413,8 @@ cdef extern from "flint_wrap.h": ctypedef padic_poly_struct padic_poly_t[1] -# flint/qadic.h: -cdef extern from "flint_wrap.h": + + # flint/qadic.h ctypedef struct qadic_ctx_struct: padic_ctx_struct pctx fmpz *a @@ -247,10 +427,15 @@ cdef extern from "flint_wrap.h": ctypedef padic_poly_struct qadic_struct ctypedef padic_poly_t qadic_t -# flint/fmpz_poly_q.h: -cdef extern from "flint_wrap.h": - ctypedef struct fmpz_poly_q_struct: - fmpz_poly_struct *num - fmpz_poly_struct *den - ctypedef fmpz_poly_q_struct fmpz_poly_q_t[1] + # flint/thread_pool.h + ctypedef struct thread_pool_entry_struct: + pass + + ctypedef thread_pool_entry_struct thread_pool_entry_t[1] + + ctypedef struct thread_pool_struct: + pass + + ctypedef thread_pool_struct thread_pool_t[1] + ctypedef int thread_pool_handle diff --git a/src/sage/rings/factorint_flint.pyx b/src/sage/rings/factorint_flint.pyx index 7e08edafa97..e20ae4dd4a8 100644 --- a/src/sage/rings/factorint_flint.pyx +++ b/src/sage/rings/factorint_flint.pyx @@ -20,6 +20,7 @@ from cysignals.signals cimport sig_on, sig_off from sage.libs.flint.fmpz cimport fmpz_t, fmpz_init, fmpz_set_mpz from sage.libs.flint.fmpz_factor cimport * +from sage.libs.flint.fmpz_factor_extra cimport * from sage.rings.integer cimport Integer From e51132121f7535bc960394fdf4067f0c340ad976 Mon Sep 17 00:00:00 2001 From: Vincent Delecroix Date: Thu, 12 Oct 2023 11:41:44 +0200 Subject: [PATCH 02/41] two fixes --- src/sage/libs/flint/flint_wrap.h | 3 --- src/sage/libs/flint/types.pxd | 2 +- src/sage/schemes/elliptic_curves/descent_two_isogeny.pyx | 1 + 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/sage/libs/flint/flint_wrap.h b/src/sage/libs/flint/flint_wrap.h index d411bde44db..777394440b6 100644 --- a/src/sage/libs/flint/flint_wrap.h +++ b/src/sage/libs/flint/flint_wrap.h @@ -39,7 +39,6 @@ #include #include #include -#include #include #include #include @@ -69,7 +68,6 @@ #include #include #include -#include #include #include #include @@ -136,7 +134,6 @@ #include #include #include -#include #include #include #include diff --git a/src/sage/libs/flint/types.pxd b/src/sage/libs/flint/types.pxd index 58d795c773c..ea5ebd62f92 100644 --- a/src/sage/libs/flint/types.pxd +++ b/src/sage/libs/flint/types.pxd @@ -1,4 +1,4 @@ -# distutils: depends = flint/fmpz_poly_mat.h flint/fmpq_mpoly.h flint/nmod_poly_mat.h flint/perm.h flint/nmod_vec.h flint/fmpzi.h flint/mpoly.h flint/mpfr_mat.h flint/gr_implementing.h flint/nmod_poly.h flint/long_extras.h flint/partitions.h flint/fq_nmod_poly_factor.h flint/mpf_mat.h flint/fmpz_poly_q.h flint/ca_vec.h flint/double_extras.h flint/fq_nmod_mpoly_factor.h flint/fmpz_mpoly.h flint/fmpq_vec.h flint/fq_poly.h flint/fq_nmod_mat.h flint/calcium.h flint/fft_small.h flint/fmpz_vec.h flint/fexpr_builtin.h flint/ca_poly.h flint/fq_embed.h flint/nmod_poly_factor.h flint/fmpz_extras.h flint/acb_mat.h flint/gr_generic.h flint/gr_poly.h flint/fq_zech_poly_factor.h flint/fmpz_mpoly_q.h flint/nmod.h flint/ca_mat.h flint/fq_zech_vec.h flint/gr_domains.h flint/arb.h flint/nf_elem.h flint/fmpz_poly.h flint/fq_nmod_embed.h flint/arb_poly.h flint/fmpq.h flint/fmpq_mpoly_factor.h flint/acb_calc.h flint/fq_vec.h flint/padic_mat.h flint/fmpz.h flint/fmpz_mat.h flint/fmpz_mod_mat.h flint/fq_zech.h flint/double_interval.h flint/fq_default_mat.h flint/fmpz_mod_mpoly.h flint/qsieve.h flint/qfb.h flint/thread_pool.h flint/fmpz_mod_mpoly_factor.h flint/acb_modular.h flint/fq_nmod_poly.h flint/profiler.h flint/acb_hypgeom.h flint/d_mat.h flint/fq_zech_poly.h flint/fmpz_mod.h flint/qqbar.h flint/hypgeom.h flint/acb_elliptic.h flint/acb_dft.h flint/d_vec.h flint/ulong_extras.h flint/dlog.h flint/bool_mat.h flint/fmpq_poly.h flint/fexpr.h flint/machine_vectors.h flint/mag.h flint/fmpz_mpoly_factor.h flint/mpfr_vec.h flint/ca_ext.h flint/gr.h flint/acb_poly.h flint/fft.h flint/padic.h flint/dirichlet.h flint/fmpz_mod_poly_factor.h flint/fq_default.h flint/fq.h flint/gr_vec.h flint/fq_nmod.h flint/fq_zech_embed.h flint/nmod_mpoly_factor.h flint/flint.h flint/fmpz_factor.h flint/qadic.h flint/nf.h flint/gr_mpoly.h flint/arb_fpwrap.h flint/fq_default_poly.h flint/aprcl.h flint/acf.h flint/gr_special.h flint/arf.h flint/threading.h flint/fq_zech_mat.h flint/gr_mat.h flint/arb_fmpz_poly.h flint/fq_nmod_vec.h flint/fmpz_mod_poly.h flint/bernoulli.h flint/fq_default_poly_factor.h flint/arb_mat.h flint/arb_hypgeom.h flint/fq_poly_factor.h flint/nmod_mpoly.h flint/acb.h flint/fmpz_lll.h flint/fmpz_poly_factor.h flint/ca_field.h flint/acb_dirichlet.h flint/arith.h flint/fmpz_mod_vec.h flint/fmpq_mat.h flint/fq_mat.h flint/mpn_extras.h flint/mpf_vec.h flint/ca.h flint/padic_poly.h flint/nmod_mat.h flint/fq_nmod_mpoly.h flint/arb_calc.h flint/nmod_types.h +# distutils: depends = flint/fmpz_poly_mat.h flint/fmpq_mpoly.h flint/nmod_poly_mat.h flint/perm.h flint/nmod_vec.h flint/fmpzi.h flint/mpoly.h flint/mpfr_mat.h flint/nmod_poly.h flint/long_extras.h flint/partitions.h flint/fq_nmod_poly_factor.h flint/mpf_mat.h flint/fmpz_poly_q.h flint/ca_vec.h flint/double_extras.h flint/fq_nmod_mpoly_factor.h flint/fmpz_mpoly.h flint/fmpq_vec.h flint/fq_poly.h flint/fq_nmod_mat.h flint/calcium.h flint/fft_small.h flint/fmpz_vec.h flint/fexpr_builtin.h flint/ca_poly.h flint/fq_embed.h flint/nmod_poly_factor.h flint/fmpz_extras.h flint/acb_mat.h flint/gr_generic.h flint/gr_poly.h flint/fq_zech_poly_factor.h flint/fmpz_mpoly_q.h flint/nmod.h flint/ca_mat.h flint/fq_zech_vec.h flint/arb.h flint/nf_elem.h flint/fmpz_poly.h flint/fq_nmod_embed.h flint/arb_poly.h flint/fmpq.h flint/fmpq_mpoly_factor.h flint/acb_calc.h flint/fq_vec.h flint/padic_mat.h flint/fmpz.h flint/fmpz_mat.h flint/fmpz_mod_mat.h flint/fq_zech.h flint/double_interval.h flint/fq_default_mat.h flint/fmpz_mod_mpoly.h flint/qsieve.h flint/qfb.h flint/thread_pool.h flint/fmpz_mod_mpoly_factor.h flint/acb_modular.h flint/fq_nmod_poly.h flint/profiler.h flint/acb_hypgeom.h flint/d_mat.h flint/fq_zech_poly.h flint/fmpz_mod.h flint/qqbar.h flint/hypgeom.h flint/acb_elliptic.h flint/acb_dft.h flint/d_vec.h flint/ulong_extras.h flint/dlog.h flint/bool_mat.h flint/fmpq_poly.h flint/fexpr.h flint/machine_vectors.h flint/mag.h flint/fmpz_mpoly_factor.h flint/mpfr_vec.h flint/ca_ext.h flint/gr.h flint/acb_poly.h flint/fft.h flint/padic.h flint/dirichlet.h flint/fmpz_mod_poly_factor.h flint/fq_default.h flint/fq.h flint/gr_vec.h flint/fq_nmod.h flint/fq_zech_embed.h flint/nmod_mpoly_factor.h flint/flint.h flint/fmpz_factor.h flint/qadic.h flint/nf.h flint/gr_mpoly.h flint/arb_fpwrap.h flint/fq_default_poly.h flint/aprcl.h flint/acf.h flint/gr_special.h flint/arf.h flint/fq_zech_mat.h flint/gr_mat.h flint/arb_fmpz_poly.h flint/fq_nmod_vec.h flint/fmpz_mod_poly.h flint/bernoulli.h flint/fq_default_poly_factor.h flint/arb_mat.h flint/arb_hypgeom.h flint/fq_poly_factor.h flint/nmod_mpoly.h flint/acb.h flint/fmpz_lll.h flint/fmpz_poly_factor.h flint/ca_field.h flint/acb_dirichlet.h flint/arith.h flint/fmpz_mod_vec.h flint/fmpq_mat.h flint/fq_mat.h flint/mpn_extras.h flint/mpf_vec.h flint/ca.h flint/padic_poly.h flint/nmod_mat.h flint/fq_nmod_mpoly.h flint/arb_calc.h flint/nmod_types.h """ Declarations for FLINT types diff --git a/src/sage/schemes/elliptic_curves/descent_two_isogeny.pyx b/src/sage/schemes/elliptic_curves/descent_two_isogeny.pyx index 66d679a1241..2f65456c2ad 100644 --- a/src/sage/schemes/elliptic_curves/descent_two_isogeny.pyx +++ b/src/sage/schemes/elliptic_curves/descent_two_isogeny.pyx @@ -26,6 +26,7 @@ from sage.rings.integer cimport Integer from sage.libs.gmp.mpz cimport * from sage.libs.flint.fmpz_poly cimport * from sage.libs.flint.nmod_poly cimport * +from sage.libs.flint.nmod_poly_factor cimport * from sage.libs.flint.ulong_extras cimport * from cypari2.paridecl cimport (GEN, cgetg, t_POL, set_gel, gel, stoi, lg, From a87083f5db5012ac967eb6b827eeb5ccd7cdb756 Mon Sep 17 00:00:00 2001 From: Vincent Delecroix Date: Thu, 12 Oct 2023 11:58:28 +0200 Subject: [PATCH 03/41] do not include fft_small.h --- src/sage/libs/flint/flint_wrap.h | 1 - src/sage/libs/flint/types.pxd | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/sage/libs/flint/flint_wrap.h b/src/sage/libs/flint/flint_wrap.h index 777394440b6..b308b9389e9 100644 --- a/src/sage/libs/flint/flint_wrap.h +++ b/src/sage/libs/flint/flint_wrap.h @@ -53,7 +53,6 @@ #include #include #include -#include #include #include #include diff --git a/src/sage/libs/flint/types.pxd b/src/sage/libs/flint/types.pxd index ea5ebd62f92..ffdb67cb69e 100644 --- a/src/sage/libs/flint/types.pxd +++ b/src/sage/libs/flint/types.pxd @@ -1,4 +1,4 @@ -# distutils: depends = flint/fmpz_poly_mat.h flint/fmpq_mpoly.h flint/nmod_poly_mat.h flint/perm.h flint/nmod_vec.h flint/fmpzi.h flint/mpoly.h flint/mpfr_mat.h flint/nmod_poly.h flint/long_extras.h flint/partitions.h flint/fq_nmod_poly_factor.h flint/mpf_mat.h flint/fmpz_poly_q.h flint/ca_vec.h flint/double_extras.h flint/fq_nmod_mpoly_factor.h flint/fmpz_mpoly.h flint/fmpq_vec.h flint/fq_poly.h flint/fq_nmod_mat.h flint/calcium.h flint/fft_small.h flint/fmpz_vec.h flint/fexpr_builtin.h flint/ca_poly.h flint/fq_embed.h flint/nmod_poly_factor.h flint/fmpz_extras.h flint/acb_mat.h flint/gr_generic.h flint/gr_poly.h flint/fq_zech_poly_factor.h flint/fmpz_mpoly_q.h flint/nmod.h flint/ca_mat.h flint/fq_zech_vec.h flint/arb.h flint/nf_elem.h flint/fmpz_poly.h flint/fq_nmod_embed.h flint/arb_poly.h flint/fmpq.h flint/fmpq_mpoly_factor.h flint/acb_calc.h flint/fq_vec.h flint/padic_mat.h flint/fmpz.h flint/fmpz_mat.h flint/fmpz_mod_mat.h flint/fq_zech.h flint/double_interval.h flint/fq_default_mat.h flint/fmpz_mod_mpoly.h flint/qsieve.h flint/qfb.h flint/thread_pool.h flint/fmpz_mod_mpoly_factor.h flint/acb_modular.h flint/fq_nmod_poly.h flint/profiler.h flint/acb_hypgeom.h flint/d_mat.h flint/fq_zech_poly.h flint/fmpz_mod.h flint/qqbar.h flint/hypgeom.h flint/acb_elliptic.h flint/acb_dft.h flint/d_vec.h flint/ulong_extras.h flint/dlog.h flint/bool_mat.h flint/fmpq_poly.h flint/fexpr.h flint/machine_vectors.h flint/mag.h flint/fmpz_mpoly_factor.h flint/mpfr_vec.h flint/ca_ext.h flint/gr.h flint/acb_poly.h flint/fft.h flint/padic.h flint/dirichlet.h flint/fmpz_mod_poly_factor.h flint/fq_default.h flint/fq.h flint/gr_vec.h flint/fq_nmod.h flint/fq_zech_embed.h flint/nmod_mpoly_factor.h flint/flint.h flint/fmpz_factor.h flint/qadic.h flint/nf.h flint/gr_mpoly.h flint/arb_fpwrap.h flint/fq_default_poly.h flint/aprcl.h flint/acf.h flint/gr_special.h flint/arf.h flint/fq_zech_mat.h flint/gr_mat.h flint/arb_fmpz_poly.h flint/fq_nmod_vec.h flint/fmpz_mod_poly.h flint/bernoulli.h flint/fq_default_poly_factor.h flint/arb_mat.h flint/arb_hypgeom.h flint/fq_poly_factor.h flint/nmod_mpoly.h flint/acb.h flint/fmpz_lll.h flint/fmpz_poly_factor.h flint/ca_field.h flint/acb_dirichlet.h flint/arith.h flint/fmpz_mod_vec.h flint/fmpq_mat.h flint/fq_mat.h flint/mpn_extras.h flint/mpf_vec.h flint/ca.h flint/padic_poly.h flint/nmod_mat.h flint/fq_nmod_mpoly.h flint/arb_calc.h flint/nmod_types.h +# distutils: depends = flint/fmpz_poly_mat.h flint/fmpq_mpoly.h flint/nmod_poly_mat.h flint/perm.h flint/nmod_vec.h flint/fmpzi.h flint/mpoly.h flint/mpfr_mat.h flint/nmod_poly.h flint/long_extras.h flint/partitions.h flint/fq_nmod_poly_factor.h flint/mpf_mat.h flint/fmpz_poly_q.h flint/ca_vec.h flint/double_extras.h flint/fq_nmod_mpoly_factor.h flint/fmpz_mpoly.h flint/fmpq_vec.h flint/fq_poly.h flint/fq_nmod_mat.h flint/calcium.h flint/fmpz_vec.h flint/fexpr_builtin.h flint/ca_poly.h flint/fq_embed.h flint/nmod_poly_factor.h flint/fmpz_extras.h flint/acb_mat.h flint/gr_generic.h flint/gr_poly.h flint/fq_zech_poly_factor.h flint/fmpz_mpoly_q.h flint/nmod.h flint/ca_mat.h flint/fq_zech_vec.h flint/arb.h flint/nf_elem.h flint/fmpz_poly.h flint/fq_nmod_embed.h flint/arb_poly.h flint/fmpq.h flint/fmpq_mpoly_factor.h flint/acb_calc.h flint/fq_vec.h flint/padic_mat.h flint/fmpz.h flint/fmpz_mat.h flint/fmpz_mod_mat.h flint/fq_zech.h flint/double_interval.h flint/fq_default_mat.h flint/fmpz_mod_mpoly.h flint/qsieve.h flint/qfb.h flint/thread_pool.h flint/fmpz_mod_mpoly_factor.h flint/acb_modular.h flint/fq_nmod_poly.h flint/profiler.h flint/acb_hypgeom.h flint/d_mat.h flint/fq_zech_poly.h flint/fmpz_mod.h flint/qqbar.h flint/hypgeom.h flint/acb_elliptic.h flint/acb_dft.h flint/d_vec.h flint/ulong_extras.h flint/dlog.h flint/bool_mat.h flint/fmpq_poly.h flint/fexpr.h flint/machine_vectors.h flint/mag.h flint/fmpz_mpoly_factor.h flint/mpfr_vec.h flint/ca_ext.h flint/gr.h flint/acb_poly.h flint/fft.h flint/padic.h flint/dirichlet.h flint/fmpz_mod_poly_factor.h flint/fq_default.h flint/fq.h flint/gr_vec.h flint/fq_nmod.h flint/fq_zech_embed.h flint/nmod_mpoly_factor.h flint/flint.h flint/fmpz_factor.h flint/qadic.h flint/nf.h flint/gr_mpoly.h flint/arb_fpwrap.h flint/fq_default_poly.h flint/aprcl.h flint/acf.h flint/gr_special.h flint/arf.h flint/fq_zech_mat.h flint/gr_mat.h flint/arb_fmpz_poly.h flint/fq_nmod_vec.h flint/fmpz_mod_poly.h flint/bernoulli.h flint/fq_default_poly_factor.h flint/arb_mat.h flint/arb_hypgeom.h flint/fq_poly_factor.h flint/nmod_mpoly.h flint/acb.h flint/fmpz_lll.h flint/fmpz_poly_factor.h flint/ca_field.h flint/acb_dirichlet.h flint/arith.h flint/fmpz_mod_vec.h flint/fmpq_mat.h flint/fq_mat.h flint/mpn_extras.h flint/mpf_vec.h flint/ca.h flint/padic_poly.h flint/nmod_mat.h flint/fq_nmod_mpoly.h flint/arb_calc.h flint/nmod_types.h """ Declarations for FLINT types From 47a8277a337e90d45cdbbf03ed06dd06a284cf2f Mon Sep 17 00:00:00 2001 From: Vincent Delecroix Date: Thu, 12 Oct 2023 12:12:01 +0200 Subject: [PATCH 04/41] do not include machine_vectors.h --- src/sage/libs/flint/flint_wrap.h | 1 - src/sage/libs/flint/types.pxd | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/sage/libs/flint/flint_wrap.h b/src/sage/libs/flint/flint_wrap.h index b308b9389e9..e28943f2d90 100644 --- a/src/sage/libs/flint/flint_wrap.h +++ b/src/sage/libs/flint/flint_wrap.h @@ -105,7 +105,6 @@ #include #include #include -#include #include #include #include diff --git a/src/sage/libs/flint/types.pxd b/src/sage/libs/flint/types.pxd index ffdb67cb69e..aa00e501604 100644 --- a/src/sage/libs/flint/types.pxd +++ b/src/sage/libs/flint/types.pxd @@ -1,4 +1,4 @@ -# distutils: depends = flint/fmpz_poly_mat.h flint/fmpq_mpoly.h flint/nmod_poly_mat.h flint/perm.h flint/nmod_vec.h flint/fmpzi.h flint/mpoly.h flint/mpfr_mat.h flint/nmod_poly.h flint/long_extras.h flint/partitions.h flint/fq_nmod_poly_factor.h flint/mpf_mat.h flint/fmpz_poly_q.h flint/ca_vec.h flint/double_extras.h flint/fq_nmod_mpoly_factor.h flint/fmpz_mpoly.h flint/fmpq_vec.h flint/fq_poly.h flint/fq_nmod_mat.h flint/calcium.h flint/fmpz_vec.h flint/fexpr_builtin.h flint/ca_poly.h flint/fq_embed.h flint/nmod_poly_factor.h flint/fmpz_extras.h flint/acb_mat.h flint/gr_generic.h flint/gr_poly.h flint/fq_zech_poly_factor.h flint/fmpz_mpoly_q.h flint/nmod.h flint/ca_mat.h flint/fq_zech_vec.h flint/arb.h flint/nf_elem.h flint/fmpz_poly.h flint/fq_nmod_embed.h flint/arb_poly.h flint/fmpq.h flint/fmpq_mpoly_factor.h flint/acb_calc.h flint/fq_vec.h flint/padic_mat.h flint/fmpz.h flint/fmpz_mat.h flint/fmpz_mod_mat.h flint/fq_zech.h flint/double_interval.h flint/fq_default_mat.h flint/fmpz_mod_mpoly.h flint/qsieve.h flint/qfb.h flint/thread_pool.h flint/fmpz_mod_mpoly_factor.h flint/acb_modular.h flint/fq_nmod_poly.h flint/profiler.h flint/acb_hypgeom.h flint/d_mat.h flint/fq_zech_poly.h flint/fmpz_mod.h flint/qqbar.h flint/hypgeom.h flint/acb_elliptic.h flint/acb_dft.h flint/d_vec.h flint/ulong_extras.h flint/dlog.h flint/bool_mat.h flint/fmpq_poly.h flint/fexpr.h flint/machine_vectors.h flint/mag.h flint/fmpz_mpoly_factor.h flint/mpfr_vec.h flint/ca_ext.h flint/gr.h flint/acb_poly.h flint/fft.h flint/padic.h flint/dirichlet.h flint/fmpz_mod_poly_factor.h flint/fq_default.h flint/fq.h flint/gr_vec.h flint/fq_nmod.h flint/fq_zech_embed.h flint/nmod_mpoly_factor.h flint/flint.h flint/fmpz_factor.h flint/qadic.h flint/nf.h flint/gr_mpoly.h flint/arb_fpwrap.h flint/fq_default_poly.h flint/aprcl.h flint/acf.h flint/gr_special.h flint/arf.h flint/fq_zech_mat.h flint/gr_mat.h flint/arb_fmpz_poly.h flint/fq_nmod_vec.h flint/fmpz_mod_poly.h flint/bernoulli.h flint/fq_default_poly_factor.h flint/arb_mat.h flint/arb_hypgeom.h flint/fq_poly_factor.h flint/nmod_mpoly.h flint/acb.h flint/fmpz_lll.h flint/fmpz_poly_factor.h flint/ca_field.h flint/acb_dirichlet.h flint/arith.h flint/fmpz_mod_vec.h flint/fmpq_mat.h flint/fq_mat.h flint/mpn_extras.h flint/mpf_vec.h flint/ca.h flint/padic_poly.h flint/nmod_mat.h flint/fq_nmod_mpoly.h flint/arb_calc.h flint/nmod_types.h +# distutils: depends = flint/fmpz_poly_mat.h flint/fmpq_mpoly.h flint/nmod_poly_mat.h flint/perm.h flint/nmod_vec.h flint/fmpzi.h flint/mpoly.h flint/mpfr_mat.h flint/nmod_poly.h flint/long_extras.h flint/partitions.h flint/fq_nmod_poly_factor.h flint/mpf_mat.h flint/fmpz_poly_q.h flint/ca_vec.h flint/double_extras.h flint/fq_nmod_mpoly_factor.h flint/fmpz_mpoly.h flint/fmpq_vec.h flint/fq_poly.h flint/fq_nmod_mat.h flint/calcium.h flint/fmpz_vec.h flint/fexpr_builtin.h flint/ca_poly.h flint/fq_embed.h flint/nmod_poly_factor.h flint/fmpz_extras.h flint/acb_mat.h flint/gr_generic.h flint/gr_poly.h flint/fq_zech_poly_factor.h flint/fmpz_mpoly_q.h flint/nmod.h flint/ca_mat.h flint/fq_zech_vec.h flint/arb.h flint/nf_elem.h flint/fmpz_poly.h flint/fq_nmod_embed.h flint/arb_poly.h flint/fmpq.h flint/fmpq_mpoly_factor.h flint/acb_calc.h flint/fq_vec.h flint/padic_mat.h flint/fmpz.h flint/fmpz_mat.h flint/fmpz_mod_mat.h flint/fq_zech.h flint/double_interval.h flint/fq_default_mat.h flint/fmpz_mod_mpoly.h flint/qsieve.h flint/qfb.h flint/thread_pool.h flint/fmpz_mod_mpoly_factor.h flint/acb_modular.h flint/fq_nmod_poly.h flint/profiler.h flint/acb_hypgeom.h flint/d_mat.h flint/fq_zech_poly.h flint/fmpz_mod.h flint/qqbar.h flint/hypgeom.h flint/acb_elliptic.h flint/acb_dft.h flint/d_vec.h flint/ulong_extras.h flint/dlog.h flint/bool_mat.h flint/fmpq_poly.h flint/fexpr.h flint/mag.h flint/fmpz_mpoly_factor.h flint/mpfr_vec.h flint/ca_ext.h flint/gr.h flint/acb_poly.h flint/fft.h flint/padic.h flint/dirichlet.h flint/fmpz_mod_poly_factor.h flint/fq_default.h flint/fq.h flint/gr_vec.h flint/fq_nmod.h flint/fq_zech_embed.h flint/nmod_mpoly_factor.h flint/flint.h flint/fmpz_factor.h flint/qadic.h flint/nf.h flint/gr_mpoly.h flint/arb_fpwrap.h flint/fq_default_poly.h flint/aprcl.h flint/acf.h flint/gr_special.h flint/arf.h flint/fq_zech_mat.h flint/gr_mat.h flint/arb_fmpz_poly.h flint/fq_nmod_vec.h flint/fmpz_mod_poly.h flint/bernoulli.h flint/fq_default_poly_factor.h flint/arb_mat.h flint/arb_hypgeom.h flint/fq_poly_factor.h flint/nmod_mpoly.h flint/acb.h flint/fmpz_lll.h flint/fmpz_poly_factor.h flint/ca_field.h flint/acb_dirichlet.h flint/arith.h flint/fmpz_mod_vec.h flint/fmpq_mat.h flint/fq_mat.h flint/mpn_extras.h flint/mpf_vec.h flint/ca.h flint/padic_poly.h flint/nmod_mat.h flint/fq_nmod_mpoly.h flint/arb_calc.h flint/nmod_types.h """ Declarations for FLINT types From 475f1b54b99da9259063bd9c7728294396d44d5e Mon Sep 17 00:00:00 2001 From: Vincent Delecroix Date: Thu, 12 Oct 2023 22:29:42 +0200 Subject: [PATCH 05/41] more autogenerated headers --- src/sage/libs/flint/acb.pxd | 919 ++++++++++++++ src/sage/libs/flint/acb_calc.pxd | 173 +++ src/sage/libs/flint/acb_dft.pxd | 81 ++ src/sage/libs/flint/acb_dirichlet.pxd | 521 ++++++++ src/sage/libs/flint/acb_elliptic.pxd | 244 ++++ src/sage/libs/flint/acb_hypgeom.pxd | 908 ++++++++++++++ src/sage/libs/flint/acb_mat.pxd | 570 +++++++++ src/sage/libs/flint/acb_modular.pxd | 379 ++++++ src/sage/libs/flint/acb_poly.pxd | 902 ++++++++++++++ src/sage/libs/flint/acf.pxd | 57 + src/sage/libs/flint/aprcl.pxd | 279 +++++ src/sage/libs/flint/arb.pxd | 1487 +++++++++++++++++++++++ src/sage/libs/flint/arb_calc.pxd | 133 ++ src/sage/libs/flint/arb_fmpz_poly.pxd | 103 ++ src/sage/libs/flint/arb_fpwrap.pxd | 348 ++++++ src/sage/libs/flint/arb_hypgeom.pxd | 521 ++++++++ src/sage/libs/flint/arb_mat.pxd | 547 +++++++++ src/sage/libs/flint/arb_poly.pxd | 874 +++++++++++++ src/sage/libs/flint/arf.pxd | 535 ++++++++ src/sage/libs/flint/bernoulli.pxd | 81 ++ src/sage/libs/flint/bool_mat.pxd | 162 +++ src/sage/libs/flint/ca.pxd | 812 +++++++++++++ src/sage/libs/flint/ca_ext.pxd | 80 ++ src/sage/libs/flint/ca_field.pxd | 88 ++ src/sage/libs/flint/ca_mat.pxd | 450 +++++++ src/sage/libs/flint/ca_poly.pxd | 274 +++++ src/sage/libs/flint/ca_vec.pxd | 113 ++ src/sage/libs/flint/calcium.pxd | 46 + src/sage/libs/flint/d_mat.pxd | 109 ++ src/sage/libs/flint/d_vec.pxd | 75 ++ src/sage/libs/flint/dirichlet.pxd | 147 +++ src/sage/libs/flint/dlog.pxd | 85 ++ src/sage/libs/flint/double_extras.pxd | 51 + src/sage/libs/flint/double_interval.pxd | 66 + src/sage/libs/flint/fft.pxd | 440 +++++++ 35 files changed, 12660 insertions(+) create mode 100644 src/sage/libs/flint/acb.pxd create mode 100644 src/sage/libs/flint/acb_calc.pxd create mode 100644 src/sage/libs/flint/acb_dft.pxd create mode 100644 src/sage/libs/flint/acb_dirichlet.pxd create mode 100644 src/sage/libs/flint/acb_elliptic.pxd create mode 100644 src/sage/libs/flint/acb_hypgeom.pxd create mode 100644 src/sage/libs/flint/acb_mat.pxd create mode 100644 src/sage/libs/flint/acb_modular.pxd create mode 100644 src/sage/libs/flint/acb_poly.pxd create mode 100644 src/sage/libs/flint/acf.pxd create mode 100644 src/sage/libs/flint/aprcl.pxd create mode 100644 src/sage/libs/flint/arb.pxd create mode 100644 src/sage/libs/flint/arb_calc.pxd create mode 100644 src/sage/libs/flint/arb_fmpz_poly.pxd create mode 100644 src/sage/libs/flint/arb_fpwrap.pxd create mode 100644 src/sage/libs/flint/arb_hypgeom.pxd create mode 100644 src/sage/libs/flint/arb_mat.pxd create mode 100644 src/sage/libs/flint/arb_poly.pxd create mode 100644 src/sage/libs/flint/arf.pxd create mode 100644 src/sage/libs/flint/bernoulli.pxd create mode 100644 src/sage/libs/flint/bool_mat.pxd create mode 100644 src/sage/libs/flint/ca.pxd create mode 100644 src/sage/libs/flint/ca_ext.pxd create mode 100644 src/sage/libs/flint/ca_field.pxd create mode 100644 src/sage/libs/flint/ca_mat.pxd create mode 100644 src/sage/libs/flint/ca_poly.pxd create mode 100644 src/sage/libs/flint/ca_vec.pxd create mode 100644 src/sage/libs/flint/calcium.pxd create mode 100644 src/sage/libs/flint/d_mat.pxd create mode 100644 src/sage/libs/flint/d_vec.pxd create mode 100644 src/sage/libs/flint/dirichlet.pxd create mode 100644 src/sage/libs/flint/dlog.pxd create mode 100644 src/sage/libs/flint/double_extras.pxd create mode 100644 src/sage/libs/flint/double_interval.pxd create mode 100644 src/sage/libs/flint/fft.pxd diff --git a/src/sage/libs/flint/acb.pxd b/src/sage/libs/flint/acb.pxd new file mode 100644 index 00000000000..9226bea8c25 --- /dev/null +++ b/src/sage/libs/flint/acb.pxd @@ -0,0 +1,919 @@ +# distutils: libraries = flint +# distutils: depends = flint/acb.h + +################################################################################ +# This file is auto-generated. Do not modify by hand +################################################################################ + +from libc.stdio cimport FILE +from sage.libs.gmp.types cimport * +from sage.libs.mpfr.types cimport * +from sage.libs.flint.types cimport * + +cdef extern from "flint_wrap.h": + + void acb_init(acb_t x) + # Initializes the variable *x* for use, and sets its value to zero. + + void acb_clear(acb_t x) + # Clears the variable *x*, freeing or recycling its allocated memory. + + acb_ptr _acb_vec_init(long n) + # Returns a pointer to an array of *n* initialized *acb_struct*:s. + + void _acb_vec_clear(acb_ptr v, long n) + # Clears an array of *n* initialized *acb_struct*:s. + + long acb_allocated_bytes(const acb_t x) + # Returns the total number of bytes heap-allocated internally by this object. + # The count excludes the size of the structure itself. Add + # ``sizeof(acb_struct)`` to get the size of the object as a whole. + + long _acb_vec_allocated_bytes(acb_srcptr vec, long len) + # Returns the total number of bytes allocated for this vector, i.e. the + # space taken up by the vector itself plus the sum of the internal heap + # allocation sizes for all its member elements. + + double _acb_vec_estimate_allocated_bytes(long len, long prec) + # Estimates the number of bytes that need to be allocated for a vector of + # *len* elements with *prec* bits of precision, including the space for + # internal limb data. + # See comments for :func:`_arb_vec_estimate_allocated_bytes`. + + void acb_zero(acb_t z) + + void acb_one(acb_t z) + + void acb_onei(acb_t z) + # Sets *z* respectively to 0, 1, `i = \sqrt{-1}`. + + void acb_set(acb_t z, const acb_t x) + + void acb_set_ui(acb_t z, unsigned long x) + + void acb_set_si(acb_t z, long x) + + void acb_set_d(acb_t z, double x) + + void acb_set_fmpz(acb_t z, const fmpz_t x) + + void acb_set_arb(acb_t z, const arb_t c) + # Sets *z* to the value of *x*. + + void acb_set_si_si(acb_t z, long x, long y) + + void acb_set_d_d(acb_t z, double x, double y) + + void acb_set_fmpz_fmpz(acb_t z, const fmpz_t x, const fmpz_t y) + + void acb_set_arb_arb(acb_t z, const arb_t x, const arb_t y) + # Sets the real and imaginary part of *z* to the values *x* and *y* respectively + + void acb_set_fmpq(acb_t z, const fmpq_t x, long prec) + + void acb_set_round(acb_t z, const acb_t x, long prec) + + void acb_set_round_fmpz(acb_t z, const fmpz_t x, long prec) + + void acb_set_round_arb(acb_t z, const arb_t x, long prec) + # Sets *z* to *x*, rounded to *prec* bits. + + void acb_swap(acb_t z, acb_t x) + # Swaps *z* and *x* efficiently. + + void acb_add_error_arf(acb_t x, const arf_t err) + + void acb_add_error_mag(acb_t x, const mag_t err) + + void acb_add_error_arb(acb_t x, const arb_t err) + # Adds *err* to the error bounds of both the real and imaginary + # parts of *x*, modifying *x* in-place. + + void acb_get_mid(acb_t m, const acb_t x) + # Sets *m* to the midpoint of *x*. + + void acb_print(const acb_t x) + + void acb_fprint(FILE * file, const acb_t x) + # Prints the internal representation of *x*. + + void acb_printd(const acb_t x, long digits) + + void acb_fprintd(FILE * file, const acb_t x, long digits) + # Prints *x* in decimal. The printed value of the radius is not adjusted + # to compensate for the fact that the binary-to-decimal conversion + # of both the midpoint and the radius introduces additional error. + + void acb_printn(const acb_t x, long digits, unsigned long flags) + + void acb_fprintn(FILE * file, const acb_t x, long digits, unsigned long flags) + # Prints a nice decimal representation of *x*, using the format of + # :func:`arb_get_str` (or the corresponding :func:`arb_printn`) for the + # real and imaginary parts. + # By default, the output shows the midpoint of both the real and imaginary + # parts with a guaranteed error of at most one unit in the last decimal + # place. In addition, explicit error bounds are printed so that the displayed + # decimal interval is guaranteed to enclose *x*. + # Any flags understood by :func:`arb_get_str` can be passed via *flags* + # to control the format of the real and imaginary parts. + + void acb_randtest(acb_t z, flint_rand_t state, long prec, long mag_bits) + # Generates a random complex number by generating separate random + # real and imaginary parts. + + void acb_randtest_special(acb_t z, flint_rand_t state, long prec, long mag_bits) + # Generates a random complex number by generating separate random + # real and imaginary parts. Also generates NaNs and infinities. + + void acb_randtest_precise(acb_t z, flint_rand_t state, long prec, long mag_bits) + # Generates a random complex number with precise real and imaginary parts. + + void acb_randtest_param(acb_t z, flint_rand_t state, long prec, long mag_bits) + # Generates a random complex number, with very high probability of + # generating integers and half-integers. + + int acb_is_zero(const acb_t z) + # Returns nonzero iff *z* is zero. + + int acb_is_one(const acb_t z) + # Returns nonzero iff *z* is exactly 1. + + int acb_is_finite(const acb_t z) + # Returns nonzero iff *z* certainly is finite. + + int acb_is_exact(const acb_t z) + # Returns nonzero iff *z* is exact. + + int acb_is_int(const acb_t z) + # Returns nonzero iff *z* is an exact integer. + + int acb_is_int_2exp_si(const acb_t x, long e) + # Returns nonzero iff *z* exactly equals `n 2^e` for some integer *n*. + + int acb_equal(const acb_t x, const acb_t y) + # Returns nonzero iff *x* and *y* are identical as sets, i.e. + # if the real and imaginary parts are equal as balls. + # Note that this is not the same thing as testing whether both + # *x* and *y* certainly represent the same complex number, unless + # either *x* or *y* is exact (and neither contains NaN). + # To test whether both operands *might* represent the same mathematical + # quantity, use :func:`acb_overlaps` or :func:`acb_contains`, + # depending on the circumstance. + + int acb_equal_si(const acb_t x, long y) + # Returns nonzero iff *x* is equal to the integer *y*. + + int acb_eq(const acb_t x, const acb_t y) + # Returns nonzero iff *x* and *y* are certainly equal, as determined + # by testing that :func:`arb_eq` holds for both the real and imaginary + # parts. + + int acb_ne(const acb_t x, const acb_t y) + # Returns nonzero iff *x* and *y* are certainly not equal, as determined + # by testing that :func:`arb_ne` holds for either the real or imaginary parts. + + int acb_overlaps(const acb_t x, const acb_t y) + # Returns nonzero iff *x* and *y* have some point in common. + + void acb_union(acb_t z, const acb_t x, const acb_t y, long prec) + # Sets *z* to a complex interval containing both *x* and *y*. + + void acb_get_abs_ubound_arf(arf_t u, const acb_t z, long prec) + # Sets *u* to an upper bound for the absolute value of *z*, computed + # using a working precision of *prec* bits. + + void acb_get_abs_lbound_arf(arf_t u, const acb_t z, long prec) + # Sets *u* to a lower bound for the absolute value of *z*, computed + # using a working precision of *prec* bits. + + void acb_get_rad_ubound_arf(arf_t u, const acb_t z, long prec) + # Sets *u* to an upper bound for the error radius of *z* (the value + # is currently not computed tightly). + + void acb_get_mag(mag_t u, const acb_t x) + # Sets *u* to an upper bound for the absolute value of *x*. + + void acb_get_mag_lower(mag_t u, const acb_t x) + # Sets *u* to a lower bound for the absolute value of *x*. + + int acb_contains_fmpq(const acb_t x, const fmpq_t y) + + int acb_contains_fmpz(const acb_t x, const fmpz_t y) + + int acb_contains(const acb_t x, const acb_t y) + # Returns nonzero iff *y* is contained in *x*. + + int acb_contains_zero(const acb_t x) + # Returns nonzero iff zero is contained in *x*. + + int acb_contains_int(const acb_t x) + # Returns nonzero iff the complex interval represented by *x* contains + # an integer. + + int acb_contains_interior(const acb_t x, const acb_t y) + # Tests if *y* is contained in the interior of *x*. + # This predicate always evaluates to false if *x* and *y* are both + # real-valued, since an imaginary part of 0 is not considered contained in + # the interior of the point interval 0. More generally, the same + # problem occurs for intervals with an exact real or imaginary part. + # Such intervals must be handled specially by the user where a different + # interpretation is intended. + + long acb_rel_error_bits(const acb_t x) + # Returns the effective relative error of *x* measured in bits. + # This is computed as if calling :func:`arb_rel_error_bits` on the + # real ball whose midpoint is the larger out of the real and imaginary + # midpoints of *x*, and whose radius is the larger out of the real + # and imaginary radiuses of *x*. + + long acb_rel_accuracy_bits(const acb_t x) + # Returns the effective relative accuracy of *x* measured in bits, + # equal to the negative of the return value from :func:`acb_rel_error_bits`. + + long acb_rel_one_accuracy_bits(const acb_t x) + # Given a ball with midpoint *m* and radius *r*, returns an approximation of + # the relative accuracy of `[\max(1,|m|) \pm r]` measured in bits. + + long acb_bits(const acb_t x) + # Returns the maximum of *arb_bits* applied to the real + # and imaginary parts of *x*, i.e. the minimum precision sufficient + # to represent *x* exactly. + + void acb_indeterminate(acb_t x) + # Sets *x* to + # `[\operatorname{NaN} \pm \infty] + [\operatorname{NaN} \pm \infty]i`, + # representing an indeterminate result. + + void acb_trim(acb_t y, const acb_t x) + # Sets *y* to a a copy of *x* with both the real and imaginary + # parts trimmed (see :func:`arb_trim`). + + int acb_is_real(const acb_t x) + # Returns nonzero iff the imaginary part of *x* is zero. + # It does not test whether the real part of *x* also is finite. + + int acb_get_unique_fmpz(fmpz_t z, const acb_t x) + # If *x* contains a unique integer, sets *z* to that value and returns + # nonzero. Otherwise (if *x* represents no integers or more than one integer), + # returns zero. + + void acb_get_real(arb_t re, const acb_t z) + # Sets *re* to the real part of *z*. + + void acb_get_imag(arb_t im, const acb_t z) + # Sets *im* to the imaginary part of *z*. + + void acb_arg(arb_t r, const acb_t z, long prec) + # Sets *r* to a real interval containing the complex argument (phase) of *z*. + # We define the complex argument have a discontinuity on `(-\infty,0]`, with + # the special value `\operatorname{arg}(0) = 0`, and + # `\operatorname{arg}(a+0i) = \pi` for `a < 0`. Equivalently, if + # `z = a+bi`, the argument is given by `\operatorname{atan2}(b,a)` + # (see :func:`arb_atan2`). + + void acb_abs(arb_t r, const acb_t z, long prec) + # Sets *r* to the absolute value of *z*. + + void acb_sgn(acb_t r, const acb_t z, long prec) + # Sets *r* to the complex sign of *z*, defined as 0 if *z* is exactly zero + # and the projection onto the unit circle `z / |z| = \exp(i \arg(z))` otherwise. + + void acb_csgn(arb_t r, const acb_t z) + # Sets *r* to the extension of the real sign function taking the + # value 1 for *z* strictly in the right half plane, -1 for *z* strictly + # in the left half plane, and the sign of the imaginary part when *z* is on + # the imaginary axis. Equivalently, `\operatorname{csgn}(z) = z / \sqrt{z^2}` + # except that the value is 0 when *z* is exactly zero. + + void acb_neg(acb_t z, const acb_t x) + + void acb_neg_round(acb_t z, const acb_t x, long prec) + # Sets *z* to the negation of *x*. + + void acb_conj(acb_t z, const acb_t x) + # Sets *z* to the complex conjugate of *x*. + + void acb_add_ui(acb_t z, const acb_t x, unsigned long y, long prec) + + void acb_add_si(acb_t z, const acb_t x, long y, long prec) + + void acb_add_fmpz(acb_t z, const acb_t x, const fmpz_t y, long prec) + + void acb_add_arb(acb_t z, const acb_t x, const arb_t y, long prec) + + void acb_add(acb_t z, const acb_t x, const acb_t y, long prec) + # Sets *z* to the sum of *x* and *y*. + + void acb_sub_ui(acb_t z, const acb_t x, unsigned long y, long prec) + + void acb_sub_si(acb_t z, const acb_t x, long y, long prec) + + void acb_sub_fmpz(acb_t z, const acb_t x, const fmpz_t y, long prec) + + void acb_sub_arb(acb_t z, const acb_t x, const arb_t y, long prec) + + void acb_sub(acb_t z, const acb_t x, const acb_t y, long prec) + # Sets *z* to the difference of *x* and *y*. + + void acb_mul_onei(acb_t z, const acb_t x) + # Sets *z* to *x* multiplied by the imaginary unit. + + void acb_div_onei(acb_t z, const acb_t x) + # Sets *z* to *x* divided by the imaginary unit. + + void acb_mul_ui(acb_t z, const acb_t x, unsigned long y, long prec) + + void acb_mul_si(acb_t z, const acb_t x, long y, long prec) + + void acb_mul_fmpz(acb_t z, const acb_t x, const fmpz_t y, long prec) + + void acb_mul_arb(acb_t z, const acb_t x, const arb_t y, long prec) + # Sets *z* to the product of *x* and *y*. + + void acb_mul(acb_t z, const acb_t x, const acb_t y, long prec) + # Sets *z* to the product of *x* and *y*. If at least one part of + # *x* or *y* is zero, the operations is reduced to two real multiplications. + # If *x* and *y* are the same pointers, they are assumed to represent + # the same mathematical quantity and the squaring formula is used. + + void acb_mul_2exp_si(acb_t z, const acb_t x, long e) + + void acb_mul_2exp_fmpz(acb_t z, const acb_t x, const fmpz_t e) + # Sets *z* to *x* multiplied by `2^e`, without rounding. + + void acb_sqr(acb_t z, const acb_t x, long prec) + # Sets *z* to *x* squared. + + void acb_cube(acb_t z, const acb_t x, long prec) + # Sets *z* to *x* cubed, computed efficiently using two real squarings, + # two real multiplications, and scalar operations. + + void acb_addmul(acb_t z, const acb_t x, const acb_t y, long prec) + + void acb_addmul_ui(acb_t z, const acb_t x, unsigned long y, long prec) + + void acb_addmul_si(acb_t z, const acb_t x, long y, long prec) + + void acb_addmul_fmpz(acb_t z, const acb_t x, const fmpz_t y, long prec) + + void acb_addmul_arb(acb_t z, const acb_t x, const arb_t y, long prec) + # Sets *z* to *z* plus the product of *x* and *y*. + + void acb_submul(acb_t z, const acb_t x, const acb_t y, long prec) + + void acb_submul_ui(acb_t z, const acb_t x, unsigned long y, long prec) + + void acb_submul_si(acb_t z, const acb_t x, long y, long prec) + + void acb_submul_fmpz(acb_t z, const acb_t x, const fmpz_t y, long prec) + + void acb_submul_arb(acb_t z, const acb_t x, const arb_t y, long prec) + # Sets *z* to *z* minus the product of *x* and *y*. + + void acb_inv(acb_t z, const acb_t x, long prec) + # Sets *z* to the multiplicative inverse of *x*. + + void acb_div_ui(acb_t z, const acb_t x, unsigned long y, long prec) + + void acb_div_si(acb_t z, const acb_t x, long y, long prec) + + void acb_div_fmpz(acb_t z, const acb_t x, const fmpz_t y, long prec) + + void acb_div_arb(acb_t z, const acb_t x, const arb_t y, long prec) + + void acb_div(acb_t z, const acb_t x, const acb_t y, long prec) + # Sets *z* to the quotient of *x* and *y*. + + void acb_dot_precise(acb_t res, const acb_t s, int subtract, acb_srcptr x, long xstep, acb_srcptr y, long ystep, long len, long prec) + void acb_dot_simple(acb_t res, const acb_t s, int subtract, acb_srcptr x, long xstep, acb_srcptr y, long ystep, long len, long prec) + void acb_dot(acb_t res, const acb_t s, int subtract, acb_srcptr x, long xstep, acb_srcptr y, long ystep, long len, long prec) + # Computes the dot product of the vectors *x* and *y*, setting + # *res* to `s + (-1)^{subtract} \sum_{i=0}^{len-1} x_i y_i`. + # The initial term *s* is optional and can be + # omitted by passing *NULL* (equivalently, `s = 0`). + # The parameter *subtract* must be 0 or 1. + # The length *len* is allowed to be negative, which is equivalent + # to a length of zero. + # The parameters *xstep* or *ystep* specify a step length for + # traversing subsequences of the vectors *x* and *y*; either can be + # negative to step in the reverse direction starting from + # the initial pointer. + # Aliasing is allowed between *res* and *s* but not between + # *res* and the entries of *x* and *y*. + # The default version determines the optimal precision for each term + # and performs all internal calculations using mpn arithmetic + # with minimal overhead. This is the preferred way to compute a + # dot product; it is generally much faster and more precise + # than a simple loop. + # The *simple* version performs fused multiply-add operations in + # a simple loop. This can be used for + # testing purposes and is also used as a fallback by the + # default version when the exponents are out of range + # for the optimized code. + # The *precise* version computes the dot product exactly up to the + # final rounding. This can be extremely slow and is only intended + # for testing. + + void acb_approx_dot(acb_t res, const acb_t s, int subtract, acb_srcptr x, long xstep, acb_srcptr y, long ystep, long len, long prec) + # Computes an approximate dot product *without error bounds*. + # The radii of the inputs are ignored (only the midpoints are read) + # and only the midpoint of the output is written. + + void acb_dot_ui(acb_t res, const acb_t initial, int subtract, acb_srcptr x, long xstep, const unsigned long * y, long ystep, long len, long prec) + void acb_dot_si(acb_t res, const acb_t initial, int subtract, acb_srcptr x, long xstep, const long * y, long ystep, long len, long prec) + void acb_dot_uiui(acb_t res, const acb_t initial, int subtract, acb_srcptr x, long xstep, const unsigned long * y, long ystep, long len, long prec) + void acb_dot_siui(acb_t res, const acb_t initial, int subtract, acb_srcptr x, long xstep, const unsigned long * y, long ystep, long len, long prec) + void acb_dot_fmpz(acb_t res, const acb_t initial, int subtract, acb_srcptr x, long xstep, const fmpz * y, long ystep, long len, long prec) + # Equivalent to :func:`acb_dot`, but with integers in the array *y*. + # The *uiui* and *siui* versions take an array of double-limb integers + # as input; the *siui* version assumes that these represent signed + # integers in two's complement form. + + void acb_const_pi(acb_t y, long prec) + # Sets *y* to the constant `\pi`. + + void acb_sqrt(acb_t r, const acb_t z, long prec) + # Sets *r* to the square root of *z*. + # If either the real or imaginary part is exactly zero, only + # a single real square root is needed. Generally, we use the formula + # `\sqrt{a+bi} = u/2 + ib/u, u = \sqrt{2(|a+bi|+a)}`, + # requiring two real square root extractions. + + void acb_sqrt_analytic(acb_t r, const acb_t z, int analytic, long prec) + # Computes the square root. If *analytic* is set, gives a NaN-containing + # result if *z* touches the branch cut. + + void acb_rsqrt(acb_t r, const acb_t z, long prec) + # Sets *r* to the reciprocal square root of *z*. + # If either the real or imaginary part is exactly zero, only + # a single real reciprocal square root is needed. Generally, we use the + # formula `1/\sqrt{a+bi} = ((a+r) - bi)/v, r = |a+bi|, v = \sqrt{r |a+bi+r|^2}`, + # requiring one real square root and one real reciprocal square root. + + void acb_rsqrt_analytic(acb_t r, const acb_t z, int analytic, long prec) + # Computes the reciprocal square root. If *analytic* is set, gives a + # NaN-containing result if *z* touches the branch cut. + + void acb_quadratic_roots_fmpz(acb_t r1, acb_t r2, const fmpz_t a, const fmpz_t b, const fmpz_t c, long prec) + # Sets *r1* and *r2* to the roots of the quadratic polynomial + # `ax^2 + bx + c`. Requires that *a* is nonzero. + # This function is implemented so that both roots are computed accurately + # even when direct use of the quadratic formula would lose accuracy. + + void acb_root_ui(acb_t r, const acb_t z, unsigned long k, long prec) + # Sets *r* to the principal *k*-th root of *z*. + + void acb_pow_fmpz(acb_t y, const acb_t b, const fmpz_t e, long prec) + + void acb_pow_ui(acb_t y, const acb_t b, unsigned long e, long prec) + + void acb_pow_si(acb_t y, const acb_t b, long e, long prec) + # Sets `y = b^e` using binary exponentiation (with an initial division + # if `e < 0`). Note that these functions can get slow if the exponent is + # extremely large (in such cases :func:`acb_pow` may be superior). + + void acb_pow_arb(acb_t z, const acb_t x, const arb_t y, long prec) + + void acb_pow(acb_t z, const acb_t x, const acb_t y, long prec) + # Sets `z = x^y`, computed using binary exponentiation if `y` if + # a small exact integer, as `z = (x^{1/2})^{2y}` if `y` is a small exact + # half-integer, and generally as `z = \exp(y \log x)`. + + void acb_pow_analytic(acb_t r, const acb_t x, const acb_t y, int analytic, long prec) + # Computes the power `x^y`. If *analytic* is set, gives a + # NaN-containing result if *x* touches the branch cut (unless *y* is + # an integer). + + void acb_unit_root(acb_t res, unsigned long order, long prec) + # Sets *res* to `\exp(\frac{2i\pi}{\mathrm{order}})` to precision *prec*. + + void acb_exp(acb_t y, const acb_t z, long prec) + # Sets *y* to the exponential function of *z*, computed as + # `\exp(a+bi) = \exp(a) \left( \cos(b) + \sin(b) i \right)`. + + void acb_exp_pi_i(acb_t y, const acb_t z, long prec) + # Sets *y* to `\exp(\pi i z)`. + + void acb_exp_invexp(acb_t s, acb_t t, const acb_t z, long prec) + # Sets `s = \exp(z)` and `t = \exp(-z)`. + + void acb_expm1(acb_t res, const acb_t z, long prec) + # Sets *res* to `\exp(z)-1`, using a more accurate method when `z \approx 0`. + + void acb_log(acb_t y, const acb_t z, long prec) + # Sets *y* to the principal branch of the natural logarithm of *z*, + # computed as + # `\log(a+bi) = \frac{1}{2} \log(a^2 + b^2) + i \operatorname{arg}(a+bi)`. + + void acb_log_analytic(acb_t r, const acb_t z, int analytic, long prec) + # Computes the natural logarithm. If *analytic* is set, gives a + # NaN-containing result if *z* touches the branch cut. + + void acb_log1p(acb_t z, const acb_t x, long prec) + # Sets `z = \log(1+x)`, computed accurately when `x \approx 0`. + + void acb_sin(acb_t s, const acb_t z, long prec) + + void acb_cos(acb_t c, const acb_t z, long prec) + + void acb_sin_cos(acb_t s, acb_t c, const acb_t z, long prec) + # Sets `s = \sin(z)`, `c = \cos(z)`, evaluated as + # `\sin(a+bi) = \sin(a)\cosh(b) + i \cos(a)\sinh(b)`, + # `\cos(a+bi) = \cos(a)\cosh(b) - i \sin(a)\sinh(b)`. + + void acb_tan(acb_t s, const acb_t z, long prec) + # Sets `s = \tan(z) = \sin(z) / \cos(z)`. For large imaginary parts, + # the function is evaluated in a numerically stable way as `\pm i` + # plus a decreasing exponential factor. + + void acb_cot(acb_t s, const acb_t z, long prec) + # Sets `s = \cot(z) = \cos(z) / \sin(z)`. For large imaginary parts, + # the function is evaluated in a numerically stable way as `\pm i` + # plus a decreasing exponential factor. + + void acb_sin_pi(acb_t s, const acb_t z, long prec) + + void acb_cos_pi(acb_t s, const acb_t z, long prec) + + void acb_sin_cos_pi(acb_t s, acb_t c, const acb_t z, long prec) + # Sets `s = \sin(\pi z)`, `c = \cos(\pi z)`, evaluating the trigonometric + # factors of the real and imaginary part accurately via :func:`arb_sin_cos_pi`. + + void acb_tan_pi(acb_t s, const acb_t z, long prec) + # Sets `s = \tan(\pi z)`. Uses the same algorithm as :func:`acb_tan`, + # but evaluates the sine and cosine accurately via :func:`arb_sin_cos_pi`. + + void acb_cot_pi(acb_t s, const acb_t z, long prec) + # Sets `s = \cot(\pi z)`. Uses the same algorithm as :func:`acb_cot`, + # but evaluates the sine and cosine accurately via :func:`arb_sin_cos_pi`. + + void acb_sec(acb_t res, const acb_t z, long prec) + # Computes `\sec(z) = 1 / \cos(z)`. + + void acb_csc(acb_t res, const acb_t z, long prec) + # Computes `\csc(x) = 1 / \sin(z)`. + + void acb_csc_pi(acb_t res, const acb_t z, long prec) + # Computes `\csc(\pi x) = 1 / \sin(\pi z)`. Evaluates the sine accurately + # via :func:`acb_sin_pi`. + + void acb_sinc(acb_t s, const acb_t z, long prec) + # Sets `s = \operatorname{sinc}(x) = \sin(z) / z`. + + void acb_sinc_pi(acb_t s, const acb_t z, long prec) + # Sets `s = \operatorname{sinc}(\pi x) = \sin(\pi z) / (\pi z)`. + + void acb_asin(acb_t res, const acb_t z, long prec) + # Sets *res* to `\operatorname{asin}(z) = -i \log(iz + \sqrt{1-z^2})`. + + void acb_acos(acb_t res, const acb_t z, long prec) + # Sets *res* to `\operatorname{acos}(z) = \tfrac{1}{2} \pi - \operatorname{asin}(z)`. + + void acb_atan(acb_t res, const acb_t z, long prec) + # Sets *res* to `\operatorname{atan}(z) = \tfrac{1}{2} i (\log(1-iz)-\log(1+iz))`. + + void acb_sinh(acb_t s, const acb_t z, long prec) + + void acb_cosh(acb_t c, const acb_t z, long prec) + + void acb_sinh_cosh(acb_t s, acb_t c, const acb_t z, long prec) + + void acb_tanh(acb_t s, const acb_t z, long prec) + + void acb_coth(acb_t s, const acb_t z, long prec) + # Respectively computes `\sinh(z) = -i\sin(iz)`, `\cosh(z) = \cos(iz)`, + # `\tanh(z) = -i\tan(iz)`, `\coth(z) = i\cot(iz)`. + + void acb_sech(acb_t res, const acb_t z, long prec) + # Computes `\operatorname{sech}(z) = 1 / \cosh(z)`. + + void acb_csch(acb_t res, const acb_t z, long prec) + # Computes `\operatorname{csch}(z) = 1 / \sinh(z)`. + + void acb_asinh(acb_t res, const acb_t z, long prec) + # Sets *res* to `\operatorname{asinh}(z) = -i \operatorname{asin}(iz)`. + + void acb_acosh(acb_t res, const acb_t z, long prec) + # Sets *res* to `\operatorname{acosh}(z) = \log(z + \sqrt{z+1} \sqrt{z-1})`. + + void acb_atanh(acb_t res, const acb_t z, long prec) + # Sets *res* to `\operatorname{atanh}(z) = -i \operatorname{atan}(iz)`. + + void acb_lambertw_asymp(acb_t res, const acb_t z, const fmpz_t k, long L, long M, long prec) + # Sets *res* to the Lambert W function `W_k(z)` computed using *L* and *M* + # terms in the bivariate series giving the asymptotic expansion at + # zero or infinity. This algorithm is valid + # everywhere, but the error bound is only finite when `|\log(z)|` is + # sufficiently large. + + int acb_lambertw_check_branch(const acb_t w, const fmpz_t k, long prec) + # Tests if *w* definitely lies in the image of the branch `W_k(z)`. + # This function is used internally to verify that a computed approximation + # of the Lambert W function lies on the intended branch. Note that this will + # necessarily evaluate to false for points exactly on (or overlapping) the + # branch cuts, where a different algorithm has to be used. + + void acb_lambertw_bound_deriv(mag_t res, const acb_t z, const acb_t ez1, const fmpz_t k) + # Sets *res* to an upper bound for `|W_k'(z)|`. The input *ez1* should + # contain the precomputed value of `ez+1`. + # Along the real line, the directional derivative of `W_k(z)` is understood + # to be taken. As a result, the user must handle the branch cut + # discontinuity separately when using this function to bound perturbations + # in the value of `W_k(z)`. + + void acb_lambertw(acb_t res, const acb_t z, const fmpz_t k, int flags, long prec) + # Sets *res* to the Lambert W function `W_k(z)` where the index *k* selects + # the branch (with `k = 0` giving the principal branch). + # The placement of branch cuts follows [CGHJK1996]_. + # If *flags* is nonzero, nonstandard branch cuts are used. + # If *flags* is set to *ACB_LAMBERTW_LEFT*, computes `W_{\mathrm{left}|k}(z)` + # which corresponds to `W_k(z)` in the upper + # half plane and `W_{k+1}(z)` in the lower half plane, connected continuously + # to the left of the branch points. + # In other words, the branch cut on `(-\infty,0)` is rotated counterclockwise + # to `(0,+\infty)`. + # (For `k = -1` and `k = 0`, there is also a branch cut on `(-1/e,0)`, + # continuous from below instead of from above to maintain counterclockwise + # continuity.) + # If *flags* is set to *ACB_LAMBERTW_MIDDLE*, computes + # `W_{\mathrm{middle}}(z)` which corresponds to + # `W_{-1}(z)` in the upper half plane and `W_{1}(z)` in the lower half + # plane, connected continuously through `(-1/e,0)` with branch cuts + # on `(-\infty,-1/e)` and `(0,+\infty)`. `W_{\mathrm{middle}}(z)` extends the + # real analytic function `W_{-1}(x)` defined on `(-1/e,0)` to a complex + # analytic function, whereas the standard branch `W_{-1}(z)` has a branch + # cut along the real segment. + # The algorithm used to compute the Lambert W function is described + # in [Joh2017b]_. + + void acb_rising_ui(acb_t z, const acb_t x, unsigned long n, long prec) + void acb_rising(acb_t z, const acb_t x, const acb_t n, long prec) + # Computes the rising factorial `z = x (x+1) (x+2) \cdots (x+n-1)`. + # These functions are aliases for :func:`acb_hypgeom_rising_ui` + # and :func:`acb_hypgeom_rising`. + + void acb_gamma(acb_t y, const acb_t x, long prec) + # Computes the gamma function `y = \Gamma(x)`. + # This is an alias for :func:`acb_hypgeom_gamma`. + + void acb_rgamma(acb_t y, const acb_t x, long prec) + # Computes the reciprocal gamma function `y = 1/\Gamma(x)`, + # avoiding division by zero at the poles of the gamma function. + # This is an alias for :func:`acb_hypgeom_rgamma`. + + void acb_lgamma(acb_t y, const acb_t x, long prec) + # Computes the logarithmic gamma function `y = \log \Gamma(x)`. + # This is an alias for :func:`acb_hypgeom_lgamma`. + # The branch cut of the logarithmic gamma function is placed on the + # negative half-axis, which means that + # `\log \Gamma(z) + \log z = \log \Gamma(z+1)` holds for all `z`, + # whereas `\log \Gamma(z) \ne \log(\Gamma(z))` in general. + # In the left half plane, the reflection formula with correct + # branch structure is evaluated via :func:`acb_log_sin_pi`. + + void acb_digamma(acb_t y, const acb_t x, long prec) + # Computes the digamma function `y = \psi(x) = (\log \Gamma(x))' = \Gamma'(x) / \Gamma(x)`. + + void acb_log_sin_pi(acb_t res, const acb_t z, long prec) + # Computes the logarithmic sine function defined by + # .. math :: + # S(z) = \log(\pi) - \log \Gamma(z) + \log \Gamma(1-z) + # which is equal to + # .. math :: + # S(z) = \int_{1/2}^z \pi \cot(\pi t) dt + # where the path of integration goes through the upper half plane + # if `0 < \arg(z) \le \pi` and through the lower half plane + # if `-\pi < \arg(z) \le 0`. Equivalently, + # .. math :: + # S(z) = \log(\sin(\pi(z-n))) \mp n \pi i, \quad n = \lfloor \operatorname{re}(z) \rfloor + # where the negative sign is taken if `0 < \arg(z) \le \pi` + # and the positive sign is taken otherwise (if the interval `\arg(z)` + # does not certainly satisfy either condition, the union of + # both cases is computed). + # After subtracting *n*, we have `0 \le \operatorname{re}(z) < 1`. In + # this strip, we use + # use `S(z) = \log(\sin(\pi(z)))` if the imaginary part of *z* is small. + # Otherwise, we use `S(z) = i \pi (z-1/2) + \log((1+e^{-2i\pi z})/2)` + # in the lower half-plane and the conjugated expression in the upper + # half-plane to avoid exponent overflow. + # The function is evaluated at the midpoint and the propagated error + # is computed from `S'(z)` to get a continuous change + # when `z` is non-real and `n` spans more than one possible integer value. + + void acb_polygamma(acb_t res, const acb_t s, const acb_t z, long prec) + # Sets *res* to the value of the generalized polygamma function `\psi(s,z)`. + # If *s* is a nonnegative order, this is simply the *s*-order derivative + # of the digamma function. If `s = 0`, this function simply + # calls the digamma function internally. For integers `s \ge 1`, + # it calls the Hurwitz zeta function. Note that for small integers + # `s \ge 1`, it can be faster to use + # :func:`acb_poly_digamma_series` and read off the coefficients. + # The generalization to other values of *s* is due to + # Espinosa and Moll [EM2004]_: + # .. math :: + # \psi(s,z) = \frac{\zeta'(s+1,z) + (\gamma + \psi(-s)) \zeta(s+1,z)}{\Gamma(-s)} + + void acb_barnes_g(acb_t res, const acb_t z, long prec) + + void acb_log_barnes_g(acb_t res, const acb_t z, long prec) + # Computes Barnes *G*-function or the logarithmic Barnes *G*-function, + # respectively. The logarithmic version has branch cuts on the negative + # real axis and is continuous elsewhere in the complex plane, + # in analogy with the logarithmic gamma function. The functional + # equation + # .. math :: + # \log G(z+1) = \log \Gamma(z) + \log G(z). + # holds for all *z*. + # For small integers, we directly use the recurrence + # relation `G(z+1) = \Gamma(z) G(z)` together with the initial value + # `G(1) = 1`. For general *z*, we use the formula + # .. math :: + # \log G(z) = (z-1) \log \Gamma(z) - \zeta'(-1,z) + \zeta'(-1). + + void acb_zeta(acb_t z, const acb_t s, long prec) + # Sets *z* to the value of the Riemann zeta function `\zeta(s)`. + # Note: for computing derivatives with respect to `s`, + # use :func:`acb_poly_zeta_series` or related methods. + # This is a wrapper of :func:`acb_dirichlet_zeta`. + + void acb_hurwitz_zeta(acb_t z, const acb_t s, const acb_t a, long prec) + # Sets *z* to the value of the Hurwitz zeta function `\zeta(s, a)`. + # Note: for computing derivatives with respect to `s`, + # use :func:`acb_poly_zeta_series` or related methods. + # This is a wrapper of :func:`acb_dirichlet_hurwitz`. + + void acb_bernoulli_poly_ui(acb_t res, unsigned long n, const acb_t x, long prec) + # Sets *res* to the value of the Bernoulli polynomial `B_n(x)`. + # Warning: this function is only fast if either *n* or *x* is a small integer. + # This function reads Bernoulli numbers from the global cache if they + # are already cached, but does not automatically extend the cache by itself. + + void acb_polylog(acb_t w, const acb_t s, const acb_t z, long prec) + + void acb_polylog_si(acb_t w, long s, const acb_t z, long prec) + # Sets *w* to the polylogarithm `\operatorname{Li}_s(z)`. + + void acb_agm1(acb_t m, const acb_t z, long prec) + # Sets *m* to the arithmetic-geometric mean `M(z) = \operatorname{agm}(1,z)`, + # defined such that the function is continuous in the complex plane except for + # a branch cut along the negative half axis (where it is continuous + # from above). This corresponds to always choosing an "optimal" branch for + # the square root in the arithmetic-geometric mean iteration. + + void acb_agm1_cpx(acb_ptr m, const acb_t z, long len, long prec) + # Sets the coefficients in the array *m* to the power series expansion of the + # arithmetic-geometric mean at the point *z* truncated to length *len*, i.e. + # `M(z+x) \in \mathbb{C}[[x]]`. + + void acb_agm(acb_t m, const acb_t x, const acb_t y, long prec) + # Sets *m* to the arithmetic-geometric mean of *x* and *y*. The square + # roots in the AGM iteration are chosen so as to form the "optimal" + # AGM sequence. This gives a well-defined function of *x* and *y* except + # when `x / y` is a negative real number, in which case there are two + # optimal AGM sequences. In that case, an arbitrary but consistent + # choice is made (if a decision cannot be made due to inexact arithmetic, + # the union of both choices is returned). + + void acb_chebyshev_t_ui(acb_t a, unsigned long n, const acb_t x, long prec) + + void acb_chebyshev_u_ui(acb_t a, unsigned long n, const acb_t x, long prec) + # Evaluates the Chebyshev polynomial of the first kind `a = T_n(x)` + # or the Chebyshev polynomial of the second kind `a = U_n(x)`. + + void acb_chebyshev_t2_ui(acb_t a, acb_t b, unsigned long n, const acb_t x, long prec) + + void acb_chebyshev_u2_ui(acb_t a, acb_t b, unsigned long n, const acb_t x, long prec) + # Simultaneously evaluates `a = T_n(x), b = T_{n-1}(x)` or + # `a = U_n(x), b = U_{n-1}(x)`. + # Aliasing between *a*, *b* and *x* is not permitted. + + void acb_real_abs(acb_t res, const acb_t z, int analytic, long prec) + # The absolute value is extended to `+z` in the right half plane and + # `-z` in the left half plane, with a discontinuity on the vertical line + # `\operatorname{Re}(z) = 0`. + + void acb_real_sgn(acb_t res, const acb_t z, int analytic, long prec) + # The sign function is extended to `+1` in the right half plane and + # `-1` in the left half plane, with a discontinuity on the vertical line + # `\operatorname{Re}(z) = 0`. + # If *analytic* is not set, this is effectively the same function as + # :func:`acb_csgn`. + + void acb_real_heaviside(acb_t res, const acb_t z, int analytic, long prec) + # The Heaviside step function (or unit step function) is extended to `+1` in + # the right half plane and `0` in the left half plane, with a discontinuity on + # the vertical line `\operatorname{Re}(z) = 0`. + + void acb_real_floor(acb_t res, const acb_t z, int analytic, long prec) + # The floor function is extended to a piecewise constant function + # equal to `n` in the strips with real part `(n,n+1)`, with discontinuities + # on the vertical lines `\operatorname{Re}(z) = n`. + + void acb_real_ceil(acb_t res, const acb_t z, int analytic, long prec) + # The ceiling function is extended to a piecewise constant function + # equal to `n+1` in the strips with real part `(n,n+1)`, with discontinuities + # on the vertical lines `\operatorname{Re}(z) = n`. + + void acb_real_max(acb_t res, const acb_t x, const acb_t y, int analytic, long prec) + # The real function `\max(x,y)` is extended to a piecewise analytic function + # of two variables by returning `x` when + # `\operatorname{Re}(x) \ge \operatorname{Re}(y)` + # and returning `y` when `\operatorname{Re}(x) < \operatorname{Re}(y)`, + # with discontinuities where `\operatorname{Re}(x) = \operatorname{Re}(y)`. + + void acb_real_min(acb_t res, const acb_t x, const acb_t y, int analytic, long prec) + # The real function `\min(x,y)` is extended to a piecewise analytic function + # of two variables by returning `x` when + # `\operatorname{Re}(x) \le \operatorname{Re}(y)` + # and returning `y` when `\operatorname{Re}(x) > \operatorname{Re}(y)`, + # with discontinuities where `\operatorname{Re}(x) = \operatorname{Re}(y)`. + + void acb_real_sqrtpos(acb_t res, const acb_t z, int analytic, long prec) + # Extends the real square root function on `[0,+\infty)` to the usual + # complex square root on the cut plane. Like :func:`arb_sqrtpos`, only + # the nonnegative part of *z* is considered if *z* is purely real + # and *analytic* is not set. This is useful for integrating `\sqrt{f(x)}` + # where it is known that `f(x) \ge 0`: unlike :func:`acb_sqrt_analytic`, + # no spurious imaginary terms `[\pm \varepsilon] i` are created when the + # balls computed for `f(x)` straddle zero. + + void _acb_vec_zero(acb_ptr A, long n) + # Sets all entries in *vec* to zero. + + int _acb_vec_is_zero(acb_srcptr vec, long len) + # Returns nonzero iff all entries in *x* are zero. + + int _acb_vec_is_real(acb_srcptr v, long len) + # Returns nonzero iff all entries in *x* have zero imaginary part. + + void _acb_vec_set(acb_ptr res, acb_srcptr vec, long len) + # Sets *res* to a copy of *vec*. + + void _acb_vec_set_round(acb_ptr res, acb_srcptr vec, long len, long prec) + # Sets *res* to a copy of *vec*, rounding each entry to *prec* bits. + + void _acb_vec_swap(acb_ptr vec1, acb_ptr vec2, long len) + # Swaps the entries of *vec1* and *vec2*. + + void _acb_vec_neg(acb_ptr res, acb_srcptr vec, long len) + + void _acb_vec_add(acb_ptr res, acb_srcptr vec1, acb_srcptr vec2, long len, long prec) + + void _acb_vec_sub(acb_ptr res, acb_srcptr vec1, acb_srcptr vec2, long len, long prec) + + void _acb_vec_scalar_submul(acb_ptr res, acb_srcptr vec, long len, const acb_t c, long prec) + + void _acb_vec_scalar_addmul(acb_ptr res, acb_srcptr vec, long len, const acb_t c, long prec) + + void _acb_vec_scalar_mul(acb_ptr res, acb_srcptr vec, long len, const acb_t c, long prec) + + void _acb_vec_scalar_mul_ui(acb_ptr res, acb_srcptr vec, long len, unsigned long c, long prec) + + void _acb_vec_scalar_mul_2exp_si(acb_ptr res, acb_srcptr vec, long len, long c) + + void _acb_vec_scalar_mul_onei(acb_ptr res, acb_srcptr vec, long len) + + void _acb_vec_scalar_div_ui(acb_ptr res, acb_srcptr vec, long len, unsigned long c, long prec) + + void _acb_vec_scalar_div(acb_ptr res, acb_srcptr vec, long len, const acb_t c, long prec) + + void _acb_vec_scalar_mul_arb(acb_ptr res, acb_srcptr vec, long len, const arb_t c, long prec) + + void _acb_vec_scalar_div_arb(acb_ptr res, acb_srcptr vec, long len, const arb_t c, long prec) + + void _acb_vec_scalar_mul_fmpz(acb_ptr res, acb_srcptr vec, long len, const fmpz_t c, long prec) + + void _acb_vec_scalar_div_fmpz(acb_ptr res, acb_srcptr vec, long len, const fmpz_t c, long prec) + + long _acb_vec_bits(acb_srcptr vec, long len) + # Returns the maximum of :func:`arb_bits` for all entries in *vec*. + + void _acb_vec_set_powers(acb_ptr xs, const acb_t x, long len, long prec) + # Sets *xs* to the powers `1, x, x^2, \ldots, x^{len-1}`. + + void _acb_vec_unit_roots(acb_ptr z, long order, long len, long prec) + # Sets *z* to the powers `1,z,z^2,\dots z^{\mathrm{len}-1}` where `z=\exp(\frac{2i\pi}{\mathrm{order}})` to precision *prec*. + # *order* can be taken negative. + # In order to avoid precision loss, this function does not simply compute powers of a primitive root. + + void _acb_vec_add_error_arf_vec(acb_ptr res, arf_srcptr err, long len) + + void _acb_vec_add_error_mag_vec(acb_ptr res, mag_srcptr err, long len) + # Adds the magnitude of each entry in *err* to the radius of the + # corresponding entry in *res*. + + void _acb_vec_indeterminate(acb_ptr vec, long len) + # Applies :func:`acb_indeterminate` elementwise. + + void _acb_vec_trim(acb_ptr res, acb_srcptr vec, long len) + # Applies :func:`acb_trim` elementwise. + + int _acb_vec_get_unique_fmpz_vec(fmpz * res, acb_srcptr vec, long len) + # Calls :func:`acb_get_unique_fmpz` elementwise and returns nonzero if + # all entries can be rounded uniquely to integers. If any entry in *vec* + # cannot be rounded uniquely to an integer, returns zero. + + void _acb_vec_sort_pretty(acb_ptr vec, long len) + # Sorts the vector of complex numbers based on the real and imaginary parts. + # This is intended to reveal structure when printing a set of complex numbers, + # not to apply an order relation in a rigorous way. diff --git a/src/sage/libs/flint/acb_calc.pxd b/src/sage/libs/flint/acb_calc.pxd new file mode 100644 index 00000000000..cf78e824782 --- /dev/null +++ b/src/sage/libs/flint/acb_calc.pxd @@ -0,0 +1,173 @@ +# distutils: libraries = flint +# distutils: depends = flint/acb_calc.h + +################################################################################ +# This file is auto-generated. Do not modify by hand +################################################################################ + +from libc.stdio cimport FILE +from sage.libs.gmp.types cimport * +from sage.libs.mpfr.types cimport * +from sage.libs.flint.types cimport * + +cdef extern from "flint_wrap.h": + + int acb_calc_integrate(acb_t res, acb_calc_func_t func, void * param, const acb_t a, const acb_t b, long rel_goal, const mag_t abs_tol, const acb_calc_integrate_opt_t options, long prec) + # Computes a rigorous enclosure of the integral + # .. math :: + # I = \int_a^b f(t) dt + # where *f* is specified by (*func*, *param*), following a straight-line + # path between the complex numbers *a* and *b*. + # For finite results, *a*, *b* must be finite and *f* must be bounded + # on the path of integration. + # To compute improper integrals, the user should therefore truncate the path + # of integration manually (or make a regularizing change of variables, + # if possible). + # Returns *ARB_CALC_SUCCESS* if the integration converged to the + # target accuracy on all subintervals, and returns + # *ARB_CALC_NO_CONVERGENCE* otherwise. + # By default, the integrand *func* will only be called with *order* = 0 + # or *order* = 1; that is, derivatives are not required. + # - The integrand will be called with *order* = 0 to evaluate *f* + # normally on the integration path (either at a single point + # or on a subinterval). In this case, *f* is treated as a pointwise defined + # function and can have arbitrary discontinuities. + # - The integrand will be called with *order* = 1 to evaluate *f* + # on a domain surrounding a segment of the integration path for the purpose + # of bounding the error of a quadrature formula. In this case, *func* must + # verify that *f* is holomorphic on this domain (and output a non-finite + # value if it is not). + # The integration algorithm combines direct interval enclosures, + # Gauss-Legendre quadrature where *f* is holomorphic, + # and adaptive subdivision. This strategy supports integrands with + # discontinuities while providing exponential convergence for typical + # piecewise holomorphic integrands. + # The following parameters control accuracy: + # - *rel_goal* - relative accuracy goal as a number of bits, i.e. + # target a relative error less than `\varepsilon_{rel} = 2^{-r}` + # where *r* = *rel_goal* + # (note the sign: *rel_goal* should be nonnegative). + # - *abs_tol* - absolute accuracy goal as a :type:`mag_t` describing + # the error tolerance, i.e. + # target an absolute error less than `\varepsilon_{abs}` = *abs_tol*. + # - *prec* - working precision. This is the working precision used to + # evaluate the integrand and manipulate interval endpoints. + # As currently implemented, the algorithm does not attempt to adjust the + # working precision by itself, and adaptive + # control of the working precision must be handled by the user. + # For typical usage, set *rel_goal* = *prec* and *abs_tol* = `2^{-prec}`. + # It usually only makes sense to have *rel_goal* between 0 and *prec*. + # The algorithm attempts to achieve an error of + # `\max(\varepsilon_{abs}, M \varepsilon_{rel})` on each subinterval, + # where *M* is the magnitude of the integral. + # These parameters are only guidelines; the cumulative error may be larger + # than both the prescribed + # absolute and relative error goals, depending on the number of + # subdivisions, cancellation between segments of the integral, and numerical + # errors in the evaluation of the integrand. + # To compute tiny integrals with high relative accuracy, one should set + # `\varepsilon_{abs} \approx M \varepsilon_{rel}` where *M* is a known + # estimate of the magnitude. Setting `\varepsilon_{abs}` to 0 is also + # allowed, forcing use of a relative instead of an absolute tolerance goal. + # This can be handy for exponentially small or + # large functions of unknown magnitude. It is recommended to avoid + # setting `\varepsilon_{abs}` very small + # if possible since the algorithm might need many extra + # subdivisions to estimate *M* automatically; if the approximate + # magnitude can be estimated by some external means (for example if + # a midpoint-width or endpoint-width estimate is known to be accurate), + # providing an appropriate `\varepsilon_{abs} \approx M \varepsilon_{rel}` + # will be more efficient. + # If the integral has very large magnitude, setting the absolute + # tolerance to a corresponding large value is recommended for best + # performance, but it is not necessary for convergence since the absolute + # tolerance is increased automatically during the execution of the + # algorithm if the partial integrals are found to have larger error. + # Additional options for the integration can be provided via the *options* + # parameter (documented below). To use all defaults, *NULL* can be passed + # for *options*. + + void acb_calc_integrate_opt_init(acb_calc_integrate_opt_t options) + # Initializes *options* for use, setting all fields to 0 indicating + # default values. + + int acb_calc_integrate_gl_auto_deg(acb_t res, long * num_eval, acb_calc_func_t func, void * param, const acb_t a, const acb_t b, const mag_t tol, long deg_limit, int flags, long prec) + # Attempts to compute `I = \int_a^b f(t) dt` using a single application + # of Gauss-Legendre quadrature with automatic determination of the + # quadrature degree so that the error is smaller than *tol*. + # Returns *ARB_CALC_SUCCESS* if the integral has been evaluated successfully + # or *ARB_CALC_NO_CONVERGENCE* if the tolerance could not be met. + # The total number of function evaluations is written to *num_eval*. + # For the interval `[-1,1]`, the error of the *n*-point Gauss-Legendre + # rule is bounded by + # .. math :: + # \left| I - \sum_{k=0}^{n-1} w_k f(x_k) \right| \le \frac{64 M}{15 (\rho-1) \rho^{2n-1}} + # if `f` is holomorphic with `|f(z)| \le M` inside the ellipse *E* + # with foci `\pm 1` and semiaxes + # `X` and `Y = \sqrt{X^2 - 1}` such that `\rho = X + Y` + # with `\rho > 1` [Tre2008]_. + # For an arbitrary interval, we use `\int_a^b f(t) dt = \int_{-1}^1 g(t) dt` + # where `g(t) = \Delta f(\Delta t + m)`, + # `\Delta = \tfrac{1}{2}(b-a)`, `m = \tfrac{1}{2}(a+b)`. + # With `I = [\pm X] + [\pm Y]i`, this means that we evaluate + # `\Delta f(\Delta I + m)` to get the bound `M`. + # (An improvement would be to reduce the wrapping effect of rotating the + # ellipse when the path is not rectilinear). + # We search for an `X` that makes the error small by trying steps `2^{2^k}`. + # Larger `X` will give smaller `1 / \rho^{2n-1}` but larger `M`. If we try + # successive larger values of `k`, we can abort when `M = \infty` + # since this either means that we have hit a singularity or a branch cut or + # that overestimation in the evaluation of `f` is becoming too severe. + + void acb_calc_cauchy_bound(arb_t bound, acb_calc_func_t func, void * param, const acb_t x, const arb_t radius, long maxdepth, long prec) + # Sets *bound* to a ball containing the value of the integral + # .. math :: + # C(x,r) = \frac{1}{2 \pi r} \oint_{|z-x| = r} |f(z)| dz + # = \int_0^1 |f(x+re^{2\pi i t})| dt + # where *f* is specified by (*func*, *param*) and *r* is given by *radius*. + # The integral is computed using a simple step sum. + # The integration range is subdivided until the order of magnitude of *b* + # can be determined (i.e. its error bound is smaller than its midpoint), + # or until the step length has been cut in half *maxdepth* times. + # This function is currently implemented completely naively, and + # repeatedly subdivides the whole integration range instead of + # performing adaptive subdivisions. + + int acb_calc_integrate_taylor(acb_t res, acb_calc_func_t func, void * param, const acb_t a, const acb_t b, const arf_t inner_radius, const arf_t outer_radius, long accuracy_goal, long prec) + # Computes the integral + # .. math :: + # I = \int_a^b f(t) dt + # where *f* is specified by (*func*, *param*), following a straight-line + # path between the complex numbers *a* and *b* which both must be finite. + # The integral is approximated by piecewise centered Taylor polynomials. + # Rigorous truncation error bounds are calculated using the Cauchy integral + # formula. More precisely, if the Taylor series of *f* centered at the point + # *m* is `f(m+x) = \sum_{n=0}^{\infty} a_n x^n`, then + # .. math :: + # \int f(m+x) = \left( \sum_{n=0}^{N-1} a_n \frac{x^{n+1}}{n+1} \right) + # + \left( \sum_{n=N}^{\infty} a_n \frac{x^{n+1}}{n+1} \right). + # For sufficiently small *x*, the second series converges and its + # absolute value is bounded by + # .. math :: + # \sum_{n=N}^{\infty} \frac{C(m,R)}{R^n} \frac{|x|^{n+1}}{N+1} + # = \frac{C(m,R) R x}{(R-x)(N+1)} \left( \frac{x}{R} \right)^N. + # It is required that any singularities of *f* are + # isolated from the path of integration by a distance strictly + # greater than the positive value *outer_radius* (which is the integration + # radius used for the Cauchy bound). Taylor series step lengths are + # chosen so as not to + # exceed *inner_radius*, which must be strictly smaller than *outer_radius* + # for convergence. A smaller *inner_radius* gives more rapid convergence + # of each Taylor series but means that more series might have to be used. + # A reasonable choice might be to set *inner_radius* to half the value of + # *outer_radius*, giving roughly one accurate bit per term. + # The truncation point of each Taylor series is chosen so that the absolute + # truncation error is roughly `2^{-p}` where *p* is given by *accuracy_goal* + # (in the future, this might change to a relative accuracy). + # Arithmetic operations and function + # evaluations are performed at a precision of *prec* bits. Note that due + # to accumulation of numerical errors, both values may have to be set + # higher (and the endpoints may have to be computed more accurately) + # to achieve a desired accuracy. + # This function chooses the evaluation points uniformly rather + # than implementing adaptive subdivision. diff --git a/src/sage/libs/flint/acb_dft.pxd b/src/sage/libs/flint/acb_dft.pxd new file mode 100644 index 00000000000..13d8e8280bf --- /dev/null +++ b/src/sage/libs/flint/acb_dft.pxd @@ -0,0 +1,81 @@ +# distutils: libraries = flint +# distutils: depends = flint/acb_dft.h + +################################################################################ +# This file is auto-generated. Do not modify by hand +################################################################################ + +from libc.stdio cimport FILE +from sage.libs.gmp.types cimport * +from sage.libs.mpfr.types cimport * +from sage.libs.flint.types cimport * + +cdef extern from "flint_wrap.h": + + void acb_dft(acb_ptr w, acb_srcptr v, long n, long prec) + + void acb_dft_inverse(acb_ptr w, acb_srcptr v, long n, long prec) + + void acb_dft_precomp_init(acb_dft_pre_t pre, long len, long prec) + + void acb_dft_precomp_clear(acb_dft_pre_t pre) + + void acb_dft_precomp(acb_ptr w, acb_srcptr v, const acb_dft_pre_t pre, long prec) + + void acb_dft_inverse_precomp(acb_ptr w, acb_srcptr v, const acb_dft_pre_t pre, long prec) + + void acb_dirichlet_dft_prod(acb_ptr w, acb_srcptr v, long * cyc, long num, long prec) + + void acb_dft_prod_init(acb_dft_prod_t t, long * cyc, long num, long prec) + + void acb_dft_prod_clear(acb_dft_prod_t t) + + void acb_dirichlet_dft_prod_precomp(acb_ptr w, acb_srcptr v, const acb_dft_prod_t prod, long prec) + + void acb_dft_convol_naive(acb_ptr w, acb_srcptr f, acb_srcptr g, long len, long prec) + + void acb_dft_convol_rad2(acb_ptr w, acb_srcptr f, acb_srcptr g, long len, long prec) + + void acb_dft_convol(acb_ptr w, acb_srcptr f, acb_srcptr g, long len, long prec) + + void acb_dft_naive(acb_ptr w, acb_srcptr v, long n, long prec) + + void acb_dft_naive_init(acb_dft_naive_t t, long len, long prec) + + void acb_dft_naive_clear(acb_dft_naive_t t) + + void acb_dft_naive_precomp(acb_ptr w, acb_srcptr v, const acb_dft_naive_t t, long prec) + + void acb_dft_crt(acb_ptr w, acb_srcptr v, long n, long prec) + + void acb_dft_crt_init(acb_dft_crt_t t, long len, long prec) + + void acb_dft_crt_clear(acb_dft_crt_t t) + + void acb_dft_crt_precomp(acb_ptr w, acb_srcptr v, const acb_dft_crt_t t, long prec) + + void acb_dft_cyc(acb_ptr w, acb_srcptr v, long n, long prec) + + void acb_dft_cyc_init(acb_dft_cyc_t t, long len, long prec) + + void acb_dft_cyc_clear(acb_dft_cyc_t t) + + void acb_dft_cyc_precomp(acb_ptr w, acb_srcptr v, const acb_dft_cyc_t t, long prec) + + void acb_dft_rad2(acb_ptr w, acb_srcptr v, int e, long prec) + + void acb_dft_inverse_rad2(acb_ptr w, acb_srcptr v, int e, long prec) + + void acb_dft_rad2_init(acb_dft_rad2_t t, int e, long prec) + + void acb_dft_rad2_clear(acb_dft_rad2_t t) + + void acb_dft_rad2_precomp(acb_ptr w, acb_srcptr v, const acb_dft_rad2_t t, long prec) + + void acb_dft_bluestein(acb_ptr w, acb_srcptr v, long n, long prec) + + void acb_dft_bluestein_init(acb_dft_bluestein_t t, long len, long prec) + + void acb_dft_bluestein_clear(acb_dft_bluestein_t t) + + void acb_dft_bluestein_precomp(acb_ptr w, acb_srcptr v, const acb_dft_bluestein_t t, long prec) diff --git a/src/sage/libs/flint/acb_dirichlet.pxd b/src/sage/libs/flint/acb_dirichlet.pxd new file mode 100644 index 00000000000..e70e6c189aa --- /dev/null +++ b/src/sage/libs/flint/acb_dirichlet.pxd @@ -0,0 +1,521 @@ +# distutils: libraries = flint +# distutils: depends = flint/acb_dirichlet.h + +################################################################################ +# This file is auto-generated. Do not modify by hand +################################################################################ + +from libc.stdio cimport FILE +from sage.libs.gmp.types cimport * +from sage.libs.mpfr.types cimport * +from sage.libs.flint.types cimport * + +cdef extern from "flint_wrap.h": + + void acb_dirichlet_roots_init(acb_dirichlet_roots_t roots, unsigned long n, long num, long prec) + # Initializes *roots* with precomputed data for fast evaluation of roots of + # unity `e^{2\pi i k/n}` of a fixed order *n*. The precomputation is + # optimized for *num* evaluations. + # For very small *num*, only the single root `e^{2\pi i/n}` will be + # precomputed, which can then be raised to a power. For small *prec* + # and large *n*, this method might even skip precomputing this single root + # if it estimates that evaluating roots of unity from scratch will be faster + # than powering. + # If *num* is large enough, the whole set of roots in the first quadrant + # will be precomputed at once. However, this is automatically avoided for + # large *n* if too much memory would be used. For intermediate *num*, + # baby-step giant-step tables are computed. + + void acb_dirichlet_roots_clear(acb_dirichlet_roots_t roots) + # Clears the structure. + + void acb_dirichlet_root(acb_t res, const acb_dirichlet_roots_t roots, unsigned long k, long prec) + # Computes `e^{2\pi i k/n}`. + + void acb_dirichlet_powsum_term(acb_ptr res, arb_t log_prev, unsigned long * prev, const acb_t s, unsigned long k, int integer, int critical_line, long len, long prec) + # Sets *res* to `k^{-(s+x)}` as a power series in *x* truncated to length *len*. + # The flags *integer* and *critical_line* respectively specify optimizing + # for *s* being an integer or having real part 1/2. + # On input *log_prev* should contain the natural logarithm of the integer + # at *prev*. If *prev* is close to *k*, this can be used to speed up + # computations. If `\log(k)` is computed internally by this function, then + # *log_prev* is overwritten by this value, and the integer at *prev* is + # overwritten by *k*, allowing *log_prev* to be recycled for the next + # term when evaluating a power sum. + + void acb_dirichlet_powsum_sieved(acb_ptr res, const acb_t s, unsigned long n, long len, long prec) + # Sets *res* to `\sum_{k=1}^n k^{-(s+x)}` + # as a power series in *x* truncated to length *len*. + # This function stores a table of powers that have already been calculated, + # computing `(ij)^r` as `i^r j^r` whenever `k = ij` is + # composite. As a further optimization, it groups all even `k` and + # evaluates the sum as a polynomial in `2^{-(s+x)}`. + # This scheme requires about `n / \log n` powers, `n / 2` multiplications, + # and temporary storage of `n / 6` power series. Due to the extra + # power series multiplications, it is only faster than the naive + # algorithm when *len* is small. + + void acb_dirichlet_powsum_smooth(acb_ptr res, const acb_t s, unsigned long n, long len, long prec) + # Sets *res* to `\sum_{k=1}^n k^{-(s+x)}` + # as a power series in *x* truncated to length *len*. + # This function performs partial sieving by adding multiples of 5-smooth *k* + # into separate buckets. Asymptotically, this requires computing 4/15 + # of the powers, which is slower than *sieved*, but only requires + # logarithmic extra space. It is also faster for large *len*, since most + # power series multiplications are traded for additions. + # A slightly bigger gain for larger *n* could be achieved by using more + # small prime factors, at the expense of space. + + void acb_dirichlet_zeta(acb_t res, const acb_t s, long prec) + # Computes `\zeta(s)` using an automatic choice of algorithm. + + void acb_dirichlet_zeta_jet(acb_t res, const acb_t s, int deflate, long len, long prec) + # Computes the first *len* terms of the Taylor series of the Riemann zeta + # function at *s*. If *deflate* is nonzero, computes the deflated + # function `\zeta(s) - 1/(s-1)` instead. + + void acb_dirichlet_zeta_bound(mag_t res, const acb_t s) + # Computes an upper bound for `|\zeta(s)|` quickly. On the critical strip (and + # slightly outside of it), formula (43.3) in [Rad1973]_ is used. + # To the right, evaluating at the real part of *s* gives a trivial bound. + # To the left, the functional equation is used. + + void acb_dirichlet_zeta_deriv_bound(mag_t der1, mag_t der2, const acb_t s) + # Sets *der1* to a bound for `|\zeta'(s)|` and *der2* to a bound for + # `|\zeta''(s)|`. These bounds are mainly intended for use in the critical + # strip and will not be tight. + + void acb_dirichlet_eta(acb_t res, const acb_t s, long prec) + # Sets *res* to the Dirichlet eta function + # `\eta(s) = \sum_{k=1}^{\infty} (-1)^{k+1} / k^s = (1-2^{1-s}) \zeta(s)`, + # also known as the alternating zeta function. + # Note that the alternating character `\{1,-1\}` is not itself + # a Dirichlet character. + + void acb_dirichlet_xi(acb_t res, const acb_t s, long prec) + # Sets *res* to the Riemann xi function + # `\xi(s) = \frac{1}{2} s (s-1) \pi^{-s/2} \Gamma(\frac{1}{2} s) \zeta(s)`. + # The functional equation for xi is `\xi(1-s) = \xi(s)`. + + void acb_dirichlet_zeta_rs_f_coeffs(acb_ptr f, const arb_t p, long n, long prec) + # Computes the coefficients `F^{(j)}(p)` for `0 \le j < n`. + # Uses power series division. This method breaks down when `p = \pm 1/2` + # (which is not problem if *s* is an exact floating-point number). + + void acb_dirichlet_zeta_rs_d_coeffs(arb_ptr d, const arb_t sigma, long k, long prec) + # Computes the coefficients `d_j^{(k)}` for `0 \le j \le \lfloor 3k/2 \rfloor + 1`. + # On input, the array *d* must contain the coefficients for `d_j^{(k-1)}` + # unless `k = 0`, and these coefficients will be updated in-place. + + void acb_dirichlet_zeta_rs_bound(mag_t err, const acb_t s, long K) + # Bounds the error term `RS_K` following Theorem 4.2 in Arias de Reyna. + + void acb_dirichlet_zeta_rs_r(acb_t res, const acb_t s, long K, long prec) + # Computes `\mathcal{R}(s)` in the upper half plane. Uses precisely *K* + # asymptotic terms in the RS formula if this input parameter is positive; + # otherwise chooses the number of terms automatically based on *s* and the + # precision. + + void acb_dirichlet_zeta_rs(acb_t res, const acb_t s, long K, long prec) + # Computes `\zeta(s)` using the Riemann-Siegel formula. Uses precisely + # *K* asymptotic terms in the RS formula if this input parameter is positive; + # otherwise chooses the number of terms automatically based on *s* and the + # precision. + + void acb_dirichlet_zeta_jet_rs(acb_ptr res, const acb_t s, long len, long prec) + # Computes the first *len* terms of the Taylor series of the Riemann zeta + # function at *s* using the Riemann Siegel formula. This function currently + # only supports *len* = 1 or *len* = 2. A finite difference is used + # to compute the first derivative. + + void acb_dirichlet_hurwitz(acb_t res, const acb_t s, const acb_t a, long prec) + # Computes the Hurwitz zeta function `\zeta(s, a)`. + # This function automatically delegates to the code for the Riemann zeta function + # when `a = 1`. Some other special cases may also be handled by direct + # formulas. In general, Euler-Maclaurin summation is used. + + void acb_dirichlet_hurwitz_precomp_init(acb_dirichlet_hurwitz_precomp_t pre, const acb_t s, int deflate, long A, long K, long N, long prec) + # Precomputes a grid of Taylor polynomials for fast evaluation of + # `\zeta(s,a)` on `a \in (0,1]` with fixed *s*. + # *A* is the initial shift to apply to *a*, *K* is the number of Taylor terms, + # *N* is the number of grid points. The precomputation requires *NK* + # evaluations of the Hurwitz zeta function, and each subsequent evaluation + # requires *2K* simple arithmetic operations (polynomial evaluation) plus + # *A* powers. As *K* grows, the error is at most `O(1/(2AN)^K)`. + # This function can be called with *A* set to zero, in which case + # no Taylor series precomputation is performed. This means that evaluation + # will be identical to calling :func:`acb_dirichlet_hurwitz` directly. + # Otherwise, we require that *A*, *K* and *N* are all positive. For a finite + # error bound, we require `K+\operatorname{re}(s) > 1`. + # To avoid an initial "bump" that steals precision + # and slows convergence, *AN* should be at least roughly as large as `|s|`, + # e.g. it is a good idea to have at least `AN > 0.5 |s|`. + # If *deflate* is set, the deflated Hurwitz zeta function is used, + # removing the pole at `s = 1`. + + void acb_dirichlet_hurwitz_precomp_init_num(acb_dirichlet_hurwitz_precomp_t pre, const acb_t s, int deflate, double num_eval, long prec) + # Initializes *pre*, choosing the parameters *A*, *K*, and *N* + # automatically to minimize the cost of *num_eval* evaluations of the + # Hurwitz zeta function at argument *s* to precision *prec*. + + void acb_dirichlet_hurwitz_precomp_clear(acb_dirichlet_hurwitz_precomp_t pre) + # Clears the precomputed data. + + void acb_dirichlet_hurwitz_precomp_choose_param(unsigned long * A, unsigned long * K, unsigned long * N, const acb_t s, double num_eval, long prec) + # Chooses precomputation parameters *A*, *K* and *N* to minimize + # the cost of *num_eval* evaluations of the Hurwitz zeta function + # at argument *s* to precision *prec*. + # If it is estimated that evaluating each Hurwitz zeta function from + # scratch would be better than performing a precomputation, *A*, *K* and *N* + # are all set to 0. + + void acb_dirichlet_hurwitz_precomp_bound(mag_t res, const acb_t s, long A, long K, long N) + # Computes an upper bound for the truncation error (not accounting for + # roundoff error) when evaluating `\zeta(s,a)` with precomputation parameters + # *A*, *K*, *N*, assuming that `0 < a \le 1`. + # For details, see :ref:`algorithms_hurwitz`. + + void acb_dirichlet_hurwitz_precomp_eval(acb_t res, const acb_dirichlet_hurwitz_precomp_t pre, unsigned long p, unsigned long q, long prec) + # Evaluates `\zeta(s,p/q)` using precomputed data, assuming that `0 < p/q \le 1`. + + void acb_dirichlet_lerch_phi_integral(acb_t res, const acb_t z, const acb_t s, const acb_t a, long prec) + void acb_dirichlet_lerch_phi_direct(acb_t res, const acb_t z, const acb_t s, const acb_t a, long prec) + void acb_dirichlet_lerch_phi(acb_t res, const acb_t z, const acb_t s, const acb_t a, long prec) + # Computes the Lerch transcendent + # .. math :: + # \Phi(z,s,a) = \sum_{k=0}^{\infty} \frac{z^k}{(k+a)^s} + # which is analytically continued for `|z| \ge 1`. + # The *direct* version evaluates a truncation of the defining series. + # The *integral* version uses the Hankel contour integral + # .. math :: + # \Phi(z,s,a) = -\frac{\Gamma(1-s)}{2 \pi i} \int_C \frac{(-t)^{s-1} e^{-a t}}{1 - z e^{-t}} dt + # where the path is deformed as needed to avoid poles and branch + # cuts of the integrand. + # The default method chooses an algorithm automatically and also + # checks for some special cases where the function can be expressed + # in terms of simpler functions (Hurwitz zeta, polylogarithms). + + void acb_dirichlet_stieltjes(acb_t res, const fmpz_t n, const acb_t a, long prec) + # Given a nonnegative integer *n*, sets *res* to the generalized Stieltjes constant + # `\gamma_n(a)` which is the coefficient in the Laurent series of the + # Hurwitz zeta function at the pole + # .. math :: + # \zeta(s,a) = \frac{1}{s-1} + \sum_{n=0}^\infty \frac{(-1)^n}{n!} \gamma_n(a) (s-1)^n. + # With `a = 1`, this gives the ordinary Stieltjes constants for the + # Riemann zeta function. + # This function uses an integral representation to permit fast computation + # for extremely large *n* [JB2018]_. If *n* is moderate and the precision + # is high enough, it falls back to evaluating the Hurwitz zeta function + # of a power series and reading off the last coefficient. + # Note that for computing a range of values + # `\gamma_0(a), \ldots, \gamma_n(a)`, it is + # generally more efficient to evaluate the Hurwitz zeta function series + # expansion once at `s = 1` than to call this function repeatedly, + # unless *n* is extremely large (at least several hundred). + + void acb_dirichlet_chi(acb_t res, const dirichlet_group_t G, const dirichlet_char_t chi, unsigned long n, long prec) + # Sets *res* to `\chi(n)`, the value of the Dirichlet character *chi* + # at the integer *n*. + + void acb_dirichlet_chi_vec(acb_ptr v, const dirichlet_group_t G, const dirichlet_char_t chi, long nv, long prec) + # Compute the *nv* first Dirichlet values. + + void acb_dirichlet_pairing(acb_t res, const dirichlet_group_t G, unsigned long m, unsigned long n, long prec) + + void acb_dirichlet_pairing_char(acb_t res, const dirichlet_group_t G, const dirichlet_char_t a, const dirichlet_char_t b, long prec) + # Sets *res* to the value of the Dirichlet pairing `\chi(m,n)` at numbers `m` and `n`. + # The second form takes two characters as input. + + void acb_dirichlet_gauss_sum_naive(acb_t res, const dirichlet_group_t G, const dirichlet_char_t chi, long prec) + + void acb_dirichlet_gauss_sum_factor(acb_t res, const dirichlet_group_t G, const dirichlet_char_t chi, long prec) + + void acb_dirichlet_gauss_sum_order2(acb_t res, const dirichlet_group_t G, const dirichlet_char_t chi, long prec) + + void acb_dirichlet_gauss_sum_theta(acb_t res, const dirichlet_group_t G, const dirichlet_char_t chi, long prec) + + void acb_dirichlet_gauss_sum(acb_t res, const dirichlet_group_t G, const dirichlet_char_t chi, long prec) + + void acb_dirichlet_jacobi_sum_naive(acb_t res, const dirichlet_group_t G, const dirichlet_char_t chi1, const dirichlet_char_t chi2, long prec) + + void acb_dirichlet_jacobi_sum_factor(acb_t res, const dirichlet_group_t G, const dirichlet_char_t chi1, const dirichlet_char_t chi2, long prec) + + void acb_dirichlet_jacobi_sum_gauss(acb_t res, const dirichlet_group_t G, const dirichlet_char_t chi1, const dirichlet_char_t chi2, long prec) + + void acb_dirichlet_jacobi_sum(acb_t res, const dirichlet_group_t G, const dirichlet_char_t chi1, const dirichlet_char_t chi2, long prec) + + void acb_dirichlet_jacobi_sum_ui(acb_t res, const dirichlet_group_t G, unsigned long a, unsigned long b, long prec) + + void acb_dirichlet_chi_theta_arb(acb_t res, const dirichlet_group_t G, const dirichlet_char_t chi, const arb_t t, long prec) + + void acb_dirichlet_ui_theta_arb(acb_t res, const dirichlet_group_t G, unsigned long a, const arb_t t, long prec) + # Compute the theta series `\Theta_q(a,t)` for real argument `t>0`. + # Beware that if `t<1` the functional equation + # .. math:: + # t \theta(a,t) = \epsilon(\chi) \theta\left(\frac1a, \frac1t\right) + # should be used, which is not done automatically (to avoid recomputing the + # Gauss sum). + # We call *theta series* of a Dirichlet character the quadratic series + # .. math:: + # \Theta_q(a) = \sum_{n\geq 0} \chi_q(a, n) n^p x^{n^2} + # where `p` is the parity of the character `\chi_q(a,\cdot)`. + # For `\Re(t)>0` we write `x(t)=\exp(-\frac{\pi}{N}t^2)` and define + # .. math:: + # \Theta_q(a,t) = \sum_{n\geq 0} \chi_q(a, n) x(t)^{n^2}. + + unsigned long acb_dirichlet_theta_length(unsigned long q, const arb_t t, long prec) + + void acb_dirichlet_qseries_arb_powers_naive(acb_t res, const arb_t x, int p, const unsigned long * a, const acb_dirichlet_roots_t z, long len, long prec) + + void acb_dirichlet_qseries_arb_powers_smallorder(acb_t res, const arb_t x, int p, const unsigned long * a, const acb_dirichlet_roots_t z, long len, long prec) + + void acb_dirichlet_dft_conrey(acb_ptr w, acb_srcptr v, const dirichlet_group_t G, long prec) + + void acb_dirichlet_dft(acb_ptr w, acb_srcptr v, const dirichlet_group_t G, long prec) + + void acb_dirichlet_root_number_theta(acb_t res, const dirichlet_group_t G, const dirichlet_char_t chi, long prec) + + void acb_dirichlet_root_number(acb_t res, const dirichlet_group_t G, const dirichlet_char_t chi, long prec) + + void acb_dirichlet_l_hurwitz(acb_t res, const acb_t s, const acb_dirichlet_hurwitz_precomp_t precomp, const dirichlet_group_t G, const dirichlet_char_t chi, long prec) + # Computes `L(s,\chi)` using decomposition in terms of the Hurwitz zeta function + # .. math:: + # L(s,\chi) = q^{-s}\sum_{k=1}^q \chi(k) \,\zeta\!\left(s,\frac kq\right). + # If `s = 1` and `\chi` is non-principal, the deflated Hurwitz zeta function + # is used to avoid poles. + # If *precomp* is *NULL*, each Hurwitz zeta function value is computed + # directly. If a pre-initialized *precomp* object is provided, this will be + # used instead to evaluate the Hurwitz zeta function. + + void acb_dirichlet_l_euler_product(acb_t res, const acb_t s, const dirichlet_group_t G, const dirichlet_char_t chi, long prec) + + void _acb_dirichlet_euler_product_real_ui(arb_t res, unsigned long s, const signed char * chi, int mod, int reciprocal, long prec) + # Computes `L(s,\chi)` directly using the Euler product. This is + # efficient if *s* has large positive real part. As implemented, this + # function only gives a finite result if `\operatorname{re}(s) \ge 2`. + # An error bound is computed via :func:`mag_hurwitz_zeta_uiui`. + # If *s* is complex, replace it with its real part. Since + # .. math :: + # \frac{1}{L(s,\chi)} = \prod_{p} \left(1 - \frac{\chi(p)}{p^s}\right) + # = \sum_{k=1}^{\infty} \frac{\mu(k)\chi(k)}{k^s} + # and the truncated product gives all smooth-index terms in the series, we have + # .. math :: + # \left|\prod_{p < N} \left(1 - \frac{\chi(p)}{p^s}\right) - \frac{1}{L(s,\chi)}\right| + # \le \sum_{k=N}^{\infty} \frac{1}{k^s} = \zeta(s,N). + # The underscore version specialized for integer *s* assumes that `\chi` is + # a real Dirichlet character given by the explicit list *chi* of character + # values at 0, 1, ..., *mod* - 1. If *reciprocal* is set, it computes + # `1 / L(s,\chi)` (this is faster if the reciprocal can be used directly). + + void acb_dirichlet_l(acb_t res, const acb_t s, const dirichlet_group_t G, const dirichlet_char_t chi, long prec) + # Computes `L(s,\chi)` using a default choice of algorithm. + + void acb_dirichlet_l_fmpq(acb_t res, const fmpq_t s, const dirichlet_group_t G, const dirichlet_char_t chi, long prec) + void acb_dirichlet_l_fmpq_afe(acb_t res, const fmpq_t s, const dirichlet_group_t G, const dirichlet_char_t chi, long prec) + # Computes `L(s,\chi)` where *s* is a rational number. + # The *afe* version uses the approximate functional equation; + # the default version chooses an algorithm automatically. + + void acb_dirichlet_l_vec_hurwitz(acb_ptr res, const acb_t s, const acb_dirichlet_hurwitz_precomp_t precomp, const dirichlet_group_t G, long prec) + # Compute all values `L(s,\chi)` for `\chi` mod `q`, using the + # Hurwitz zeta function and a discrete Fourier transform. + # The output *res* is assumed to have length *G->phi_q* and values + # are stored by lexicographically ordered + # Conrey logs. See :func:`acb_dirichlet_dft_conrey`. + # If *precomp* is *NULL*, each Hurwitz zeta function value is computed + # directly. If a pre-initialized *precomp* object is provided, this will be + # used instead to evaluate the Hurwitz zeta function. + + void acb_dirichlet_l_jet(acb_ptr res, const acb_t s, const dirichlet_group_t G, const dirichlet_char_t chi, int deflate, long len, long prec) + # Computes the Taylor expansion of `L(s,\chi)` to length *len*, + # i.e. `L(s), L'(s), \ldots, L^{(len-1)}(s) / (len-1)!`. + # If *deflate* is set, computes the expansion of + # .. math :: + # L(s,\chi) - \frac{\sum_{k=1}^q \chi(k)}{(s-1)q} + # instead. If *chi* is a principal character, then this has the effect of + # subtracting the pole with residue `\sum_{k=1}^q \chi(k) = \phi(q) / q` + # that is located at `s = 1`. In particular, when evaluated at `s = 1`, this + # gives the regular part of the Laurent expansion. + # When *chi* is non-principal, *deflate* has no effect. + + void _acb_dirichlet_l_series(acb_ptr res, acb_srcptr s, long slen, const dirichlet_group_t G, const dirichlet_char_t chi, int deflate, long len, long prec) + + void acb_dirichlet_l_series(acb_poly_t res, const acb_poly_t s, const dirichlet_group_t G, const dirichlet_char_t chi, int deflate, long len, long prec) + # Sets *res* to the power series `L(s,\chi)` where *s* is a given power series, truncating the result to length *len*. + # See :func:`acb_dirichlet_l_jet` for the meaning of the *deflate* flag. + + void acb_dirichlet_hardy_theta(acb_ptr res, const acb_t t, const dirichlet_group_t G, const dirichlet_char_t chi, long len, long prec) + # Computes the phase function used to construct the Z-function. + # We have + # .. math :: + # \theta(t) = -\frac{t}{2} \log(\pi/q) - \frac{i \log(\epsilon)}{2} + # + \frac{\log \Gamma((s+\delta)/2) - \log \Gamma((1-s+\delta)/2)}{2i} + # where `s = 1/2+it`, `\delta` is the parity of *chi*, and `\epsilon` + # is the root number as computed by :func:`acb_dirichlet_root_number`. + # The first *len* terms in the Taylor expansion are written to the output. + + void acb_dirichlet_hardy_z(acb_ptr res, const acb_t t, const dirichlet_group_t G, const dirichlet_char_t chi, long len, long prec) + # Computes the Hardy Z-function, also known as the Riemann-Siegel Z-function + # `Z(t) = e^{i \theta(t)} L(1/2+it)`, which is real-valued for real *t*. + # The first *len* terms in the Taylor expansion are written to the output. + + void _acb_dirichlet_hardy_theta_series(acb_ptr res, acb_srcptr t, long tlen, const dirichlet_group_t G, const dirichlet_char_t chi, long len, long prec) + + void acb_dirichlet_hardy_theta_series(acb_poly_t res, const acb_poly_t t, const dirichlet_group_t G, const dirichlet_char_t chi, long len, long prec) + # Sets *res* to the power series `\theta(t)` where *t* is a given power series, truncating the result to length *len*. + + void _acb_dirichlet_hardy_z_series(acb_ptr res, acb_srcptr t, long tlen, const dirichlet_group_t G, const dirichlet_char_t chi, long len, long prec) + + void acb_dirichlet_hardy_z_series(acb_poly_t res, const acb_poly_t t, const dirichlet_group_t G, const dirichlet_char_t chi, long len, long prec) + # Sets *res* to the power series `Z(t)` where *t* is a given power series, truncating the result to length *len*. + + void acb_dirichlet_gram_point(arb_t res, const fmpz_t n, const dirichlet_group_t G, const dirichlet_char_t chi, long prec) + # Sets *res* to the *n*-th Gram point `g_n`, defined as the unique solution + # in `[7, \infty)` of `\theta(g_n) = \pi n`. Currently only the Gram points + # corresponding to the Riemann zeta function are supported and *G* and *chi* + # must both be set to *NULL*. Requires `n \ge -1`. + + unsigned long acb_dirichlet_turing_method_bound(const fmpz_t p) + # Computes an upper bound *B* for the minimum number of consecutive good + # Gram blocks sufficient to count nontrivial zeros of the Riemann zeta + # function using Turing's method [Tur1953]_ as updated by [Leh1970]_, + # [Bre1979]_, and [Tru2011]_. + # Let `N(T)` denote the number of zeros (counted according to their + # multiplicities) of `\zeta(s)` in the region `0 < \operatorname{Im}(s) \le T`. + # If at least *B* consecutive Gram blocks with union `[g_n, g_p)` + # satisfy Rosser's rule, then `N(g_n) \le n + 1` and `N(g_p) \ge p + 1`. + + int _acb_dirichlet_definite_hardy_z(arb_t res, const arf_t t, long * pprec) + # Sets *res* to the Hardy Z-function `Z(t)`. + # The initial precision (* *pprec*) is increased as necessary + # to determine the sign of `Z(t)`. The sign is returned. + + void _acb_dirichlet_isolate_gram_hardy_z_zero(arf_t a, arf_t b, const fmpz_t n) + # Uses Gram's law to compute an interval `(a, b)` that + # contains the *n*-th zero of the Hardy Z-function and no other zero. + # Requires `1 \le n \le 126`. + + void _acb_dirichlet_isolate_rosser_hardy_z_zero(arf_t a, arf_t b, const fmpz_t n) + # Uses Rosser's rule to compute an interval `(a, b)` that + # contains the *n*-th zero of the Hardy Z-function and no other zero. + # Requires `1 \le n \le 13999526`. + + void _acb_dirichlet_isolate_turing_hardy_z_zero(arf_t a, arf_t b, const fmpz_t n) + # Computes an interval `(a, b)` that contains the *n*-th zero of the + # Hardy Z-function and no other zero, following Turing's method. + # Requires `n \ge 2`. + + void acb_dirichlet_isolate_hardy_z_zero(arf_t a, arf_t b, const fmpz_t n) + # Computes an interval `(a, b)` that contains the *n*-th zero of the + # Hardy Z-function and contains no other zero, using the most appropriate + # underscore version of this function. Requires `n \ge 1`. + + void _acb_dirichlet_refine_hardy_z_zero(arb_t res, const arf_t a, const arf_t b, long prec) + # Sets *res* to the unique zero of the Hardy Z-function in the + # interval `(a, b)`. + + void acb_dirichlet_hardy_z_zero(arb_t res, const fmpz_t n, long prec) + # Sets *res* to the *n*-th zero of the Hardy Z-function, requiring `n \ge 1`. + + void acb_dirichlet_hardy_z_zeros(arb_ptr res, const fmpz_t n, long len, long prec) + # Sets the entries of *res* to *len* consecutive zeros of the + # Hardy Z-function, beginning with the *n*-th zero. Requires positive *n*. + + void acb_dirichlet_zeta_zero(acb_t res, const fmpz_t n, long prec) + # Sets *res* to the *n*-th nontrivial zero of `\zeta(s)`, requiring `n \ge 1`. + + void acb_dirichlet_zeta_zeros(acb_ptr res, const fmpz_t n, long len, long prec) + # Sets the entries of *res* to *len* consecutive nontrivial zeros of `\zeta(s)` + # beginning with the *n*-th zero. Requires positive *n*. + + void _acb_dirichlet_exact_zeta_nzeros(fmpz_t res, const arf_t t) + + void acb_dirichlet_zeta_nzeros(arb_t res, const arb_t t, long prec) + # Compute the number of zeros (counted according to their multiplicities) + # of `\zeta(s)` in the region `0 < \operatorname{Im}(s) \le t`. + + void acb_dirichlet_backlund_s(arb_t res, const arb_t t, long prec) + # Compute `S(t) = \frac{1}{\pi}\operatorname{arg}\zeta(\frac{1}{2} + it)` + # where the argument is defined by continuous variation of `s` in `\zeta(s)` + # starting at `s = 2`, then vertically to `s = 2 + it`, then horizontally + # to `s = \frac{1}{2} + it`. In particular `\operatorname{arg}` in this + # context is not the principal value of the argument, and it cannot be + # computed directly by :func:`acb_arg`. In practice `S(t)` is computed as + # `S(t) = N(t) - \frac{1}{\pi}\theta(t) - 1` where `N(t)` is + # :func:`acb_dirichlet_zeta_nzeros` and `\theta(t)` is + # :func:`acb_dirichlet_hardy_theta`. + + void acb_dirichlet_backlund_s_bound(mag_t res, const arb_t t) + # Compute an upper bound for `|S(t)|` quickly. Theorem 1 + # and the bounds in (1.2) in [Tru2014]_ are used. + + void acb_dirichlet_zeta_nzeros_gram(fmpz_t res, const fmpz_t n) + # Compute `N(g_n)`. That is, compute the number of zeros (counted according + # to their multiplicities) of `\zeta(s)` in the region + # `0 < \operatorname{Im}(s) \le g_n` where `g_n` is the *n*-th Gram point. + # Requires `n \ge -1`. + + long acb_dirichlet_backlund_s_gram(const fmpz_t n) + # Compute `S(g_n)` where `g_n` is the *n*-th Gram point. Requires `n \ge -1`. + + void acb_dirichlet_platt_scaled_lambda(arb_t res, const arb_t t, long prec) + # Compute `\Lambda(t) e^{\pi t/4}` where + # .. math :: + # \Lambda(t) = \pi^{-\frac{it}{2}} + # \Gamma\left(\frac{\frac{1}{2}+it}{2}\right) + # \zeta\left(\frac{1}{2} + it\right) + # is defined in the beginning of section 3 of [Pla2017]_. As explained in + # [Pla2011]_ this function has the same zeros as `\zeta(1/2 + it)` and is + # real-valued by the functional equation, and the exponential factor is + # designed to counteract the decay of the gamma factor as `t` increases. + + void acb_dirichlet_platt_scaled_lambda_vec(arb_ptr res, const fmpz_t T, long A, long B, long prec) + + void acb_dirichlet_platt_multieval(arb_ptr res, const fmpz_t T, long A, long B, const arb_t h, const fmpz_t J, long K, long sigma, long prec) + + void acb_dirichlet_platt_multieval_threaded(arb_ptr res, const fmpz_t T, long A, long B, const arb_t h, const fmpz_t J, long K, long sigma, long prec) + # Compute :func:`acb_dirichlet_platt_scaled_lambda` at `N=AB` points on a + # grid, following the notation of [Pla2017]_. The first point on the grid + # is `T - B/2` and the distance between grid points is `1/A`. The product + # `N=AB` must be an even integer. The multieval versions evaluate the + # function at all points on the grid simultaneously using discrete Fourier + # transforms, and they require the four additional tuning parameters + # *h*, *J*, *K*, and *sigma*. The *threaded* multieval version splits the + # computation over the number of threads returned by + # *flint_get_num_threads()*, while the default multieval version chooses + # whether to use multithreading automatically. + + void acb_dirichlet_platt_ws_interpolation(arb_t res, arf_t deriv, const arb_t t0, arb_srcptr p, const fmpz_t T, long A, long B, long Ns_max, const arb_t H, long sigma, long prec) + # Compute :func:`acb_dirichlet_platt_scaled_lambda` at *t0* by + # Gaussian-windowed Whittaker-Shannon interpolation of points evaluated by + # :func:`acb_dirichlet_platt_scaled_lambda_vec`. The derivative is + # also approximated if the output parameter *deriv* is not *NULL*. + # *Ns_max* defines the maximum number of supporting points to be used in + # the interpolation on either side of *t0*. *H* is the standard deviation + # of the Gaussian window centered on *t0* to be applied before the + # interpolation. *sigma* is an odd positive integer tuning parameter + # `\sigma \in 2\mathbb{Z}_{>0}+1` used in computing error bounds. + + long _acb_dirichlet_platt_local_hardy_z_zeros(arb_ptr res, const fmpz_t n, long len, const fmpz_t T, long A, long B, const arb_t h, const fmpz_t J, long K, long sigma_grid, long Ns_max, const arb_t H, long sigma_interp, long prec) + + long acb_dirichlet_platt_local_hardy_z_zeros(arb_ptr res, const fmpz_t n, long len, long prec) + + long acb_dirichlet_platt_hardy_z_zeros(arb_ptr res, const fmpz_t n, long len, long prec) + # Sets at most the first *len* entries of *res* to consecutive + # zeros of the Hardy Z-function starting with the *n*-th zero. + # The number of obtained consecutive zeros is returned. The first two + # function variants each make a single call to Platt's grid evaluation + # of the scaled Lambda function, whereas the third variant performs as many + # evaluations as necessary to obtain *len* consecutive zeros. + # The final several parameters of the underscored local variant have the same + # meanings as in the functions :func:`acb_dirichlet_platt_multieval` + # and :func:`acb_dirichlet_platt_ws_interpolation`. The non-underscored + # variants currently expect `10^4 \leq n \leq 10^{23}`. The user has the + # option of multi-threading through *flint_set_num_threads(numthreads)*. + + long acb_dirichlet_platt_zeta_zeros(acb_ptr res, const fmpz_t n, long len, long prec) + # Sets at most the first *len* entries of *res* to consecutive + # zeros of the Riemann zeta function starting with the *n*-th zero. + # The number of obtained consecutive zeros is returned. It currently + # expects `10^4 \leq n \leq 10^{23}`. The user has the option of + # multi-threading through *flint_set_num_threads(numthreads)*. diff --git a/src/sage/libs/flint/acb_elliptic.pxd b/src/sage/libs/flint/acb_elliptic.pxd new file mode 100644 index 00000000000..b6b9de27d3a --- /dev/null +++ b/src/sage/libs/flint/acb_elliptic.pxd @@ -0,0 +1,244 @@ +# distutils: libraries = flint +# distutils: depends = flint/acb_elliptic.h + +################################################################################ +# This file is auto-generated. Do not modify by hand +################################################################################ + +from libc.stdio cimport FILE +from sage.libs.gmp.types cimport * +from sage.libs.mpfr.types cimport * +from sage.libs.flint.types cimport * + +cdef extern from "flint_wrap.h": + + void acb_elliptic_k(acb_t res, const acb_t m, long prec) + # Computes the complete elliptic integral of the first kind + # .. math :: + # K(m) = \int_0^{\pi/2} \frac{dt}{\sqrt{1-m \sin^2 t}} + # = \int_0^1 + # \frac{dt}{\left(\sqrt{1-t^2}\right)\left(\sqrt{1-mt^2}\right)} + # using the arithmetic-geometric mean: `K(m) = \pi / (2 M(\sqrt{1-m}))`. + + void acb_elliptic_k_jet(acb_ptr res, const acb_t m, long len, long prec) + # Sets the coefficients in the array *res* to the power series expansion of the + # complete elliptic integral of the first kind at the point *m* truncated to + # length *len*, i.e. `K(m+x) \in \mathbb{C}[[x]]`. + + void _acb_elliptic_k_series(acb_ptr res, acb_srcptr m, long mlen, long len, long prec) + + void acb_elliptic_k_series(acb_poly_t res, const acb_poly_t m, long len, long prec) + # Sets *res* to the complete elliptic integral of the first kind of the + # power series *m*, truncated to length *len*. + + void acb_elliptic_e(acb_t res, const acb_t m, long prec) + # Computes the complete elliptic integral of the second kind + # .. math :: + # E(m) = \int_0^{\pi/2} \sqrt{1-m \sin^2 t} \, dt = + # \int_0^1 + # \frac{\sqrt{1-mt^2}}{\sqrt{1-t^2}} \, dt + # using `E(m) = (1-m)(2m K'(m) + K(m))` (where the prime + # denotes a derivative, not a complementary integral). + + void acb_elliptic_pi(acb_t res, const acb_t n, const acb_t m, long prec) + # Evaluates the complete elliptic integral of the third kind + # .. math :: + # \Pi(n, m) = \int_0^{\pi/2} + # \frac{dt}{(1-n \sin^2 t) \sqrt{1-m \sin^2 t}} = + # \int_0^1 + # \frac{dt}{(1-nt^2) \sqrt{1-t^2} \sqrt{1-mt^2}}. + # This implementation currently uses the same algorithm as the corresponding + # incomplete integral. It is therefore less efficient than the implementations + # of the first two complete elliptic integrals which use the AGM. + + void acb_elliptic_f(acb_t res, const acb_t phi, const acb_t m, int pi, long prec) + # Evaluates the Legendre incomplete elliptic integral of the first kind, + # given by + # .. math :: + # F(\phi,m) = \int_0^{\phi} \frac{dt}{\sqrt{1-m \sin^2 t}} + # = \int_0^{\sin \phi} + # \frac{dt}{\left(\sqrt{1-t^2}\right)\left(\sqrt{1-mt^2}\right)} + # on the standard strip `-\pi/2 \le \operatorname{Re}(\phi) \le \pi/2`. + # Outside this strip, the function extends quasiperiodically as + # .. math :: + # F(\phi + n \pi, m) = 2 n K(m) + F(\phi,m), n \in \mathbb{Z}. + # Inside the standard strip, the function is computed via + # the symmetric integral `R_F`. + # If the flag *pi* is set to 1, the variable `\phi` is replaced by + # `\pi \phi`, changing the quasiperiod to 1. + # The function reduces to a complete elliptic integral of the first kind + # when `\phi = \frac{\pi}{2}`; that is, + # `F\left(\frac{\pi}{2}, m\right) = K(m)`. + + void acb_elliptic_e_inc(acb_t res, const acb_t phi, const acb_t m, int pi, long prec) + # Evaluates the Legendre incomplete elliptic integral of the second kind, + # given by + # .. math :: + # E(\phi,m) = \int_0^{\phi} \sqrt{1-m \sin^2 t} \, dt = + # \int_0^{\sin \phi} + # \frac{\sqrt{1-mt^2}}{\sqrt{1-t^2}} \, dt + # on the standard strip `-\pi/2 \le \operatorname{Re}(\phi) \le \pi/2`. + # Outside this strip, the function extends quasiperiodically as + # .. math :: + # E(\phi + n \pi, m) = 2 n E(m) + E(\phi,m), n \in \mathbb{Z}. + # Inside the standard strip, the function is computed via + # the symmetric integrals `R_F` and `R_D`. + # If the flag *pi* is set to 1, the variable `\phi` is replaced by + # `\pi \phi`, changing the quasiperiod to 1. + # The function reduces to a complete elliptic integral of the second kind + # when `\phi = \frac{\pi}{2}`; that is, + # `E\left(\frac{\pi}{2}, m\right) = E(m)`. + + void acb_elliptic_pi_inc(acb_t res, const acb_t n, const acb_t phi, const acb_t m, int pi, long prec) + # Evaluates the Legendre incomplete elliptic integral of the third kind, + # given by + # .. math :: + # \Pi(n, \phi, m) = \int_0^{\phi} + # \frac{dt}{(1-n \sin^2 t) \sqrt{1-m \sin^2 t}} = + # \int_0^{\sin \phi} + # \frac{dt}{(1-nt^2) \sqrt{1-t^2} \sqrt{1-mt^2}} + # on the standard strip `-\pi/2 \le \operatorname{Re}(\phi) \le \pi/2`. + # Outside this strip, the function extends quasiperiodically as + # .. math :: + # \Pi(n, \phi + k \pi, m) = 2 k \Pi(n,m) + \Pi(n,\phi,m), k \in \mathbb{Z}. + # Inside the standard strip, the function is computed via + # the symmetric integrals `R_F` and `R_J`. + # If the flag *pi* is set to 1, the variable `\phi` is replaced by + # `\pi \phi`, changing the quasiperiod to 1. + # The function reduces to a complete elliptic integral of the third kind + # when `\phi = \frac{\pi}{2}`; that is, + # `\Pi\left(n, \frac{\pi}{2}, m\right) = \Pi(n, m)`. + + void acb_elliptic_rf(acb_t res, const acb_t x, const acb_t y, const acb_t z, int flags, long prec) + # Evaluates the Carlson symmetric elliptic integral of the first kind + # .. math :: + # R_F(x,y,z) = \frac{1}{2} + # \int_0^{\infty} \frac{dt}{\sqrt{(t+x)(t+y)(t+z)}} + # where the square root extends continuously from positive infinity. + # The integral is well-defined for `x,y,z \notin (-\infty,0)`, and with + # at most one of `x,y,z` being zero. + # When some parameters are negative real numbers, the function is + # still defined by analytic continuation. + # In general, one or more duplication steps are applied until + # `x,y,z` are close enough to use a multivariate Taylor series. + # The special case `R_C(x, y) = R_F(x, y, y) = \frac{1}{2} \int_0^{\infty} (t+x)^{-1/2} (t+y)^{-1} dt` + # may be computed by + # setting *y* and *z* to the same variable. + # (This case is not yet handled specially, but might be optimized in + # the future.) + # The *flags* parameter is reserved for future use and currently + # does nothing. Passing 0 results in default behavior. + + void acb_elliptic_rg(acb_t res, const acb_t x, const acb_t y, const acb_t z, int flags, long prec) + # Evaluates the Carlson symmetric elliptic integral of the second kind + # .. math :: + # R_G(x,y,z) = \frac{1}{4} \int_0^{\infty} + # \frac{t}{\sqrt{(t+x)(t+y)(t+z)}} + # \left( \frac{x}{t+x} + \frac{y}{t+y} + \frac{z}{t+z}\right) dt + # where the square root is taken continuously as in `R_F`. + # The evaluation is done by expressing `R_G` in terms of `R_F` and `R_D`. + # There are no restrictions on the variables. + + void acb_elliptic_rj(acb_t res, const acb_t x, const acb_t y, const acb_t z, const acb_t p, int flags, long prec) + + void acb_elliptic_rj_carlson(acb_t res, const acb_t x, const acb_t y, const acb_t z, const acb_t p, int flags, long prec) + + void acb_elliptic_rj_integration(acb_t res, const acb_t x, const acb_t y, const acb_t z, const acb_t p, int flags, long prec) + # Evaluates the Carlson symmetric elliptic integral of the third kind + # .. math :: + # R_J(x,y,z,p) = \frac{3}{2} + # \int_0^{\infty} \frac{dt}{(t+p)\sqrt{(t+x)(t+y)(t+z)}} + # where the square root is taken continuously as in `R_F`. + # Three versions of this function are available: the *carlson* version + # applies one or more duplication steps until `x,y,z,p` are close enough + # to use a multivariate Taylor series. + # The duplication algorithm is not correct for all possible + # combinations of complex variables, since the square roots taken + # during the computation can introduce spurious branch cuts. + # According to [Car1995]_, a sufficient (but not necessary) condition + # for correctness is that *x*, *y*, *z* have nonnegative + # real part and that *p* has positive real part. + # In other cases, the algorithm *might* still be correct, but no attempt + # is made to check this; it is up to the user to verify that + # the duplication algorithm is appropriate for the given parameters + # before calling this function. + # The *integration* algorithm uses explicit numerical integration to + # translate the parameters to the right half-plane. This is reliable + # but can be slow. + # The default method uses the *carlson* algorithm when it is certain + # to be correct, and otherwise falls back to the slow *integration* + # algorithm. + # The special case `R_D(x, y, z) = R_J(x, y, z, z)` + # may be computed by setting *z* and *p* to the same variable. + # This case is handled specially to avoid redundant arithmetic operations. + # In this case, the *carlson* algorithm is correct for all *x*, *y* and *z*. + # The *flags* parameter is reserved for future use and currently + # does nothing. Passing 0 results in default behavior. + + void acb_elliptic_rc1(acb_t res, const acb_t x, long prec) + # This helper function computes the special case + # `R_C(1, 1+x) = \operatorname{atan}(\sqrt{x})/\sqrt{x} = {}_2F_1(1,1/2,3/2,-x)`, + # which is needed in the evaluation of `R_J`. + + void acb_elliptic_p(acb_t res, const acb_t z, const acb_t tau, long prec) + # Computes Weierstrass's elliptic function + # .. math :: + # \wp(z, \tau) = \frac{1}{z^2} + \sum_{n^2+m^2 \ne 0} + # \left[ \frac{1}{(z+m+n\tau)^2} - \frac{1}{(m+n\tau)^2} \right] + # which satisfies `\wp(z, \tau) = \wp(z + 1, \tau) = \wp(z + \tau, \tau)`. + # To evaluate the function efficiently, we use the formula + # .. math :: + # \wp(z, \tau) = \pi^2 \theta_2^2(0,\tau) \theta_3^2(0,\tau) + # \frac{\theta_4^2(z,\tau)}{\theta_1^2(z,\tau)} - + # \frac{\pi^2}{3} \left[ \theta_2^4(0,\tau) + \theta_3^4(0,\tau)\right]. + + void acb_elliptic_p_prime(acb_t res, const acb_t z, const acb_t tau, long prec) + # Computes the derivative `\wp'(z, \tau)` of Weierstrass's elliptic function `\wp(z, \tau)`. + + void acb_elliptic_p_jet(acb_ptr res, const acb_t z, const acb_t tau, long len, long prec) + # Computes the formal power series `\wp(z + x, \tau) \in \mathbb{C}[[x]]`, + # truncated to length *len*. In particular, with *len* = 2, simultaneously + # computes `\wp(z, \tau), \wp'(z, \tau)` which together generate + # the field of elliptic functions with periods 1 and `\tau`. + + void _acb_elliptic_p_series(acb_ptr res, acb_srcptr z, long zlen, const acb_t tau, long len, long prec) + + void acb_elliptic_p_series(acb_poly_t res, const acb_poly_t z, const acb_t tau, long len, long prec) + # Sets *res* to the Weierstrass elliptic function of the power series *z*, + # with periods 1 and *tau*, truncated to length *len*. + + void acb_elliptic_invariants(acb_t g2, acb_t g3, const acb_t tau, long prec) + # Computes the lattice invariants `g_2, g_3`. The Weierstrass elliptic + # function satisfies the differential equation + # `[\wp'(z, \tau)]^2 = 4 [\wp(z,\tau)]^3 - g_2 \wp(z,\tau) - g_3`. + # Up to constant factors, the lattice invariants are the first two + # Eisenstein series (see :func:`acb_modular_eisenstein`). + + void acb_elliptic_roots(acb_t e1, acb_t e2, acb_t e3, const acb_t tau, long prec) + # Computes the lattice roots `e_1, e_2, e_3`, which are the roots of + # the polynomial `4z^3 - g_2 z - g_3`. + + void acb_elliptic_inv_p(acb_t res, const acb_t z, const acb_t tau, long prec) + # Computes the inverse of the Weierstrass elliptic function, which + # satisfies `\wp(\wp^{-1}(z, \tau), \tau) = z`. This function is given + # by the elliptic integral + # .. math :: + # \wp^{-1}(z, \tau) = \frac{1}{2} \int_z^{\infty} \frac{dt}{\sqrt{(t-e_1)(t-e_2)(t-e_3)}} + # = R_F(z-e_1,z-e_2,z-e_3). + + void acb_elliptic_zeta(acb_t res, const acb_t z, const acb_t tau, long prec) + # Computes the Weierstrass zeta function + # .. math :: + # \zeta(z, \tau) = \frac{1}{z} + \sum_{n^2+m^2 \ne 0} + # \left[ \frac{1}{z-m-n\tau} + \frac{1}{m+n\tau} + \frac{z}{(m+n\tau)^2} \right] + # which is quasiperiodic with `\zeta(z + 1, \tau) = \zeta(z, \tau) + \zeta(1/2, \tau)` + # and `\zeta(z + \tau, \tau) = \zeta(z, \tau) + \zeta(\tau/2, \tau)`. + + void acb_elliptic_sigma(acb_t res, const acb_t z, const acb_t tau, long prec) + # Computes the Weierstrass sigma function + # .. math :: + # \sigma(z, \tau) = z \prod_{n^2+m^2 \ne 0} + # \left[ \left(1-\frac{z}{m+n\tau}\right) + # \exp\left(\frac{z}{m+n\tau} + \frac{z^2}{2(m+n\tau)^2} \right) \right] + # which is quasiperiodic with `\sigma(z + 1, \tau) = -e^{2 \zeta(1/2, \tau) (z+1/2)} \sigma(z, \tau)` + # and `\sigma(z + \tau, \tau) = -e^{2 \zeta(\tau/2, \tau) (z+\tau/2)} \sigma(z, \tau)`. diff --git a/src/sage/libs/flint/acb_hypgeom.pxd b/src/sage/libs/flint/acb_hypgeom.pxd new file mode 100644 index 00000000000..8f0ff458438 --- /dev/null +++ b/src/sage/libs/flint/acb_hypgeom.pxd @@ -0,0 +1,908 @@ +# distutils: libraries = flint +# distutils: depends = flint/acb_hypgeom.h + +################################################################################ +# This file is auto-generated. Do not modify by hand +################################################################################ + +from libc.stdio cimport FILE +from sage.libs.gmp.types cimport * +from sage.libs.mpfr.types cimport * +from sage.libs.flint.types cimport * + +cdef extern from "flint_wrap.h": + + void acb_hypgeom_rising_ui_forward(acb_t res, const acb_t x, unsigned long n, long prec) + void acb_hypgeom_rising_ui_bs(acb_t res, const acb_t x, unsigned long n, long prec) + void acb_hypgeom_rising_ui_rs(acb_t res, const acb_t x, unsigned long n, unsigned long m, long prec) + void acb_hypgeom_rising_ui_rec(acb_t res, const acb_t x, unsigned long n, long prec) + void acb_hypgeom_rising_ui(acb_t res, const acb_t x, unsigned long n, long prec) + void acb_hypgeom_rising(acb_t res, const acb_t x, const acb_t n, long prec) + # Computes the rising factorial `(x)_n`. + # The *forward* version uses the forward recurrence. + # The *bs* version uses binary splitting. + # The *rs* version uses rectangular splitting. It takes an extra tuning + # parameter *m* which can be set to zero to choose automatically. + # The *rec* version chooses an algorithm automatically, avoiding + # use of the gamma function (so that it can be used in the computation + # of the gamma function). + # The default versions (*rising_ui* and *rising_ui*) choose an algorithm + # automatically and may additionally fall back on the gamma function. + + void acb_hypgeom_rising_ui_jet_powsum(acb_ptr res, const acb_t x, unsigned long n, long len, long prec) + void acb_hypgeom_rising_ui_jet_bs(acb_ptr res, const acb_t x, unsigned long n, long len, long prec) + void acb_hypgeom_rising_ui_jet_rs(acb_ptr res, const acb_t x, unsigned long n, unsigned long m, long len, long prec) + void acb_hypgeom_rising_ui_jet(acb_ptr res, const acb_t x, unsigned long n, long len, long prec) + # Computes the jet of the rising factorial `(x)_n`, truncated to length *len*. + # In other words, constructs the polynomial `(X + x)_n \in \mathbb{R}[X]`, + # truncated if `\operatorname{len} < n + 1` (and zero-extended + # if `\operatorname{len} > n + 1`). + # The *powsum* version computes the sequence of powers of *x* and forms integral + # linear combinations of these. + # The *bs* version uses binary splitting. + # The *rs* version uses rectangular splitting. It takes an extra tuning + # parameter *m* which can be set to zero to choose automatically. + # The default version chooses an algorithm automatically. + + void acb_hypgeom_log_rising_ui(acb_ptr res, const acb_t x, unsigned long n, long prec) + # Computes the log-rising factorial `\log \, (x)_n = \sum_{k=0}^{n-1} \log(x+k)`. + # This first computes the ordinary rising factorial and then determines + # the branch correction `2 \pi i m` with respect to the principal + # logarithm. The correction is computed using Hare's algorithm in + # floating-point arithmetic if this is safe; otherwise, + # a direct computation of `\sum_{k=0}^{n-1} \arg(x+k)` is used as a fallback. + + void acb_hypgeom_log_rising_ui_jet(acb_ptr res, const acb_t x, unsigned long n, long len, long prec) + # Computes the jet of the log-rising factorial `\log \, (x)_n`, + # truncated to length *len*. + + void acb_hypgeom_gamma_stirling_sum_horner(acb_t s, const acb_t z, long N, long prec) + void acb_hypgeom_gamma_stirling_sum_improved(acb_t s, const acb_t z, long N, long K, long prec) + # Sets *res* to the final sum in the Stirling series for the gamma function + # truncated before the term with index *N*, i.e. computes + # `\sum_{n=1}^{N-1} B_{2n} / (2n(2n-1) z^{2n-1})`. + # The *horner* version uses Horner scheme with gradual precision adjustments. + # The *improved* version uses rectangular splitting for the low-index + # terms and reexpands the high-index terms as hypergeometric polynomials, + # using a splitting parameter *K* (which can be set to 0 to use a default + # value). + + void acb_hypgeom_gamma_stirling(acb_t res, const acb_t x, int reciprocal, long prec) + # Sets *res* to the gamma function of *x* computed using the Stirling + # series together with argument reduction. If *reciprocal* is set, + # the reciprocal gamma function is computed instead. + + int acb_hypgeom_gamma_taylor(acb_t res, const acb_t x, int reciprocal, long prec) + # Attempts to compute the gamma function of *x* using Taylor series + # together with argument reduction. This is only supported if *x* and *prec* + # are both small enough. If successful, returns 1; otherwise, does nothing + # and returns 0. If *reciprocal* is set, the reciprocal gamma function is + # computed instead. + + void acb_hypgeom_gamma(acb_t res, const acb_t x, long prec) + # Sets *res* to the gamma function of *x* computed using a default + # algorithm choice. + + void acb_hypgeom_rgamma(acb_t res, const acb_t x, long prec) + # Sets *res* to the reciprocal gamma function of *x* computed using a default + # algorithm choice. + + void acb_hypgeom_lgamma(acb_t res, const acb_t x, long prec) + # Sets *res* to the principal branch of the log-gamma function of *x* + # computed using a default algorithm choice. + + void acb_hypgeom_pfq_bound_factor(mag_t C, acb_srcptr a, long p, acb_srcptr b, long q, const acb_t z, unsigned long n) + # Computes a factor *C* such that + # `\left|\sum_{k=n}^{\infty} T(k)\right| \le C |T(n)|`. + # See :ref:`algorithms_hypergeometric_convergent`. + # As currently implemented, the bound becomes infinite when `n` is + # too small, even if the series converges. + + long acb_hypgeom_pfq_choose_n(acb_srcptr a, long p, acb_srcptr b, long q, const acb_t z, long prec) + # Heuristically attempts to choose a number of terms *n* to + # sum of a hypergeometric series at a working precision of *prec* bits. + # Uses double precision arithmetic internally. As currently implemented, + # it can fail to produce a good result if the parameters are extremely + # large or extremely close to nonpositive integers. + # Numerical cancellation is assumed to be significant, so truncation + # is done when the current term is *prec* bits + # smaller than the largest encountered term. + # This function will also attempt to pick a reasonable + # truncation point for divergent series. + + void acb_hypgeom_pfq_sum_forward(acb_t s, acb_t t, acb_srcptr a, long p, acb_srcptr b, long q, const acb_t z, long n, long prec) + + void acb_hypgeom_pfq_sum_rs(acb_t s, acb_t t, acb_srcptr a, long p, acb_srcptr b, long q, const acb_t z, long n, long prec) + + void acb_hypgeom_pfq_sum_bs(acb_t s, acb_t t, acb_srcptr a, long p, acb_srcptr b, long q, const acb_t z, long n, long prec) + + void acb_hypgeom_pfq_sum_fme(acb_t s, acb_t t, acb_srcptr a, long p, acb_srcptr b, long q, const acb_t z, long n, long prec) + + void acb_hypgeom_pfq_sum(acb_t s, acb_t t, acb_srcptr a, long p, acb_srcptr b, long q, const acb_t z, long n, long prec) + # Computes `s = \sum_{k=0}^{n-1} T(k)` and `t = T(n)`. + # Does not allow aliasing between input and output variables. + # We require `n \ge 0`. + # The *forward* version computes the sum using forward + # recurrence. + # The *bs* version computes the sum using binary splitting. + # The *rs* version computes the sum in reverse order + # using rectangular splitting. It only computes a + # magnitude bound for the value of *t*. + # The *fme* version uses fast multipoint evaluation. + # The default version automatically chooses an algorithm + # depending on the inputs. + + void acb_hypgeom_pfq_sum_bs_invz(acb_t s, acb_t t, acb_srcptr a, long p, acb_srcptr b, long q, const acb_t w, long n, long prec) + + void acb_hypgeom_pfq_sum_invz(acb_t s, acb_t t, acb_srcptr a, long p, acb_srcptr b, long q, const acb_t z, const acb_t w, long n, long prec) + # Like :func:`acb_hypgeom_pfq_sum`, but taking advantage of + # `w = 1/z` possibly having few bits. + + void acb_hypgeom_pfq_direct(acb_t res, acb_srcptr a, long p, acb_srcptr b, long q, const acb_t z, long n, long prec) + # Computes + # .. math :: + # {}_pf_{q}(z) + # = \sum_{k=0}^{\infty} T(k) + # = \sum_{k=0}^{n-1} T(k) + \varepsilon + # directly from the defining series, including a rigorous bound for + # the truncation error `\varepsilon` in the output. + # If `n < 0`, this function chooses a number of terms automatically + # using :func:`acb_hypgeom_pfq_choose_n`. + + void acb_hypgeom_pfq_series_sum_forward(acb_poly_t s, acb_poly_t t, const acb_poly_struct * a, long p, const acb_poly_struct * b, long q, const acb_poly_t z, int regularized, long n, long len, long prec) + + void acb_hypgeom_pfq_series_sum_bs(acb_poly_t s, acb_poly_t t, const acb_poly_struct * a, long p, const acb_poly_struct * b, long q, const acb_poly_t z, int regularized, long n, long len, long prec) + + void acb_hypgeom_pfq_series_sum_rs(acb_poly_t s, acb_poly_t t, const acb_poly_struct * a, long p, const acb_poly_struct * b, long q, const acb_poly_t z, int regularized, long n, long len, long prec) + + void acb_hypgeom_pfq_series_sum(acb_poly_t s, acb_poly_t t, const acb_poly_struct * a, long p, const acb_poly_struct * b, long q, const acb_poly_t z, int regularized, long n, long len, long prec) + # Computes `s = \sum_{k=0}^{n-1} T(k)` and `t = T(n)` given parameters + # and argument that are power series. + # Does not allow aliasing between input and output variables. + # We require `n \ge 0` and that *len* is positive. + # If *regularized* is set, the regularized sum is computed, avoiding + # division by zero at the poles of the gamma function. + # The *forward*, *bs*, *rs* and default versions use forward recurrence, + # binary splitting, rectangular splitting, and an automatic algorithm + # choice. + + void acb_hypgeom_pfq_series_direct(acb_poly_t res, const acb_poly_struct * a, long p, const acb_poly_struct * b, long q, const acb_poly_t z, int regularized, long n, long len, long prec) + # Computes `{}_pf_{q}(z)` directly using the defining series, given + # parameters and argument that are power series. + # The result is a power series of length *len*. + # We require that *len* is positive. + # An error bound is computed automatically as a function of the number + # of terms *n*. If `n < 0`, the number of terms is chosen + # automatically. + # If *regularized* is set, the regularized hypergeometric function + # is computed instead. + + void acb_hypgeom_u_asymp(acb_t res, const acb_t a, const acb_t b, const acb_t z, long n, long prec) + # Sets *res* to `U^{*}(a,b,z)` computed using *n* terms of the asymptotic series, + # with a rigorous bound for the error included in the output. + # We require `n \ge 0`. + + int acb_hypgeom_u_use_asymp(const acb_t z, long prec) + # Heuristically determines whether the asymptotic series can be used + # to evaluate `U(a,b,z)` to *prec* accurate bits (assuming that *a* and *b* + # are small). + + void acb_hypgeom_pfq(acb_t res, acb_srcptr a, long p, acb_srcptr b, long q, const acb_t z, int regularized, long prec) + # Computes the generalized hypergeometric function `{}_pF_{q}(z)`, + # or the regularized version if *regularized* is set. + # This function automatically delegates to a specialized implementation + # when the order (*p*, *q*) is one of (0,0), (1,0), (0,1), (1,1), (2,1). + # Otherwise, it falls back to direct summation. + # While this is a top-level function meant to take care of special cases + # automatically, it does not generally perform the optimization + # of deleting parameters that appear in both *a* and *b*. This can be + # done ahead of time by the user in applications where duplicate + # parameters are likely to occur. + + void acb_hypgeom_u_1f1_series(acb_poly_t res, const acb_poly_t a, const acb_poly_t b, const acb_poly_t z, long len, long prec) + # Computes `U(a,b,z)` as a power series truncated to length *len*, + # given `a, b, z \in \mathbb{C}[[x]]`. + # If `b[0] \in \mathbb{Z}`, it computes one extra derivative and removes + # the singularity (it is then assumed that `b[1] \ne 0`). + # As currently implemented, the output is indeterminate if `b` is nonexact + # and contains an integer. + + void acb_hypgeom_u_1f1(acb_t res, const acb_t a, const acb_t b, const acb_t z, long prec) + # Computes `U(a,b,z)` as a sum of two convergent hypergeometric series. + # If `b \in \mathbb{Z}`, it computes + # the limit value via :func:`acb_hypgeom_u_1f1_series`. + # As currently implemented, the output is indeterminate if `b` is nonexact + # and contains an integer. + + void acb_hypgeom_u(acb_t res, const acb_t a, const acb_t b, const acb_t z, long prec) + # Computes `U(a,b,z)` using an automatic algorithm choice. The + # function :func:`acb_hypgeom_u_asymp` is used + # if `a` or `a-b+1` is a nonpositive integer (in which + # case the asymptotic series terminates), or if *z* is sufficiently large. + # Otherwise :func:`acb_hypgeom_u_1f1` is used. + + void acb_hypgeom_m_asymp(acb_t res, const acb_t a, const acb_t b, const acb_t z, int regularized, long prec) + + void acb_hypgeom_m_1f1(acb_t res, const acb_t a, const acb_t b, const acb_t z, int regularized, long prec) + + void acb_hypgeom_m(acb_t res, const acb_t a, const acb_t b, const acb_t z, int regularized, long prec) + # Computes the confluent hypergeometric function + # `M(a,b,z) = {}_1F_1(a,b,z)`, or + # `\mathbf{M}(a,b,z) = \frac{1}{\Gamma(b)} {}_1F_1(a,b,z)` if *regularized* + # is set. + + void acb_hypgeom_1f1(acb_t res, const acb_t a, const acb_t b, const acb_t z, int regularized, long prec) + # Alias for :func:`acb_hypgeom_m`. + + void acb_hypgeom_0f1_asymp(acb_t res, const acb_t a, const acb_t z, int regularized, long prec) + + void acb_hypgeom_0f1_direct(acb_t res, const acb_t a, const acb_t z, int regularized, long prec) + + void acb_hypgeom_0f1(acb_t res, const acb_t a, const acb_t z, int regularized, long prec) + # Computes the confluent hypergeometric function + # `{}_0F_1(a,z)`, or `\frac{1}{\Gamma(a)} {}_0F_1(a,z)` if *regularized* + # is set, using asymptotic expansions, direct summation, + # or an automatic algorithm choice. + # The *asymp* version uses the asymptotic expansions of Bessel + # functions, together with the connection formulas + # .. math :: + # \frac{{}_0F_1(a,z)}{\Gamma(a)} = (-z)^{(1-a)/2} J_{a-1}(2 \sqrt{-z}) = + # z^{(1-a)/2} I_{a-1}(2 \sqrt{z}). + # The Bessel-*J* function is used in the left half-plane and the + # Bessel-*I* function is used in the right half-plane, to avoid loss + # of accuracy due to evaluating the square root on the branch cut. + + void acb_hypgeom_erf_propagated_error(mag_t re, mag_t im, const acb_t z) + # Sets *re* and *im* to upper bounds for the error in the real and imaginary + # part resulting from approximating the error function of *z* by + # the error function evaluated at the midpoint of *z*. Uses + # the first derivative. + + void acb_hypgeom_erf_1f1a(acb_t res, const acb_t z, long prec) + + void acb_hypgeom_erf_1f1b(acb_t res, const acb_t z, long prec) + + void acb_hypgeom_erf_asymp(acb_t res, const acb_t z, int complementary, long prec, long prec2) + # Computes the error function respectively using + # .. math :: + # \operatorname{erf}(z) &= \frac{2z}{\sqrt{\pi}} + # {}_1F_1(\tfrac{1}{2}, \tfrac{3}{2}, -z^2) + # \operatorname{erf}(z) &= \frac{2z e^{-z^2}}{\sqrt{\pi}} + # {}_1F_1(1, \tfrac{3}{2}, z^2) + # \operatorname{erf}(z) &= \frac{z}{\sqrt{z^2}} + # \left(1 - \frac{e^{-z^2}}{\sqrt{\pi}} + # U(\tfrac{1}{2}, \tfrac{1}{2}, z^2)\right) = + # \frac{z}{\sqrt{z^2}} - \frac{e^{-z^2}}{z \sqrt{\pi}} + # U^{*}(\tfrac{1}{2}, \tfrac{1}{2}, z^2). + # The *asymp* version takes a second precision to use for the *U* term. + # It also takes an extra flag *complementary*, computing the complementary + # error function if set. + + void acb_hypgeom_erf(acb_t res, const acb_t z, long prec) + # Computes the error function using an automatic algorithm choice. + # If *z* is too small to use the asymptotic expansion, a working precision + # sufficient to circumvent cancellation in the hypergeometric series is + # determined automatically, and a bound for the propagated error is + # computed with :func:`acb_hypgeom_erf_propagated_error`. + + void _acb_hypgeom_erf_series(acb_ptr res, acb_srcptr z, long zlen, long len, long prec) + + void acb_hypgeom_erf_series(acb_poly_t res, const acb_poly_t z, long len, long prec) + # Computes the error function of the power series *z*, + # truncated to length *len*. + + void acb_hypgeom_erfc(acb_t res, const acb_t z, long prec) + # Computes the complementary error function + # `\operatorname{erfc}(z) = 1 - \operatorname{erf}(z)`. + # This function avoids catastrophic cancellation for large positive *z*. + + void _acb_hypgeom_erfc_series(acb_ptr res, acb_srcptr z, long zlen, long len, long prec) + + void acb_hypgeom_erfc_series(acb_poly_t res, const acb_poly_t z, long len, long prec) + # Computes the complementary error function of the power series *z*, + # truncated to length *len*. + + void acb_hypgeom_erfi(acb_t res, const acb_t z, long prec) + # Computes the imaginary error function + # `\operatorname{erfi}(z) = -i\operatorname{erf}(iz)`. This is a trivial wrapper + # of :func:`acb_hypgeom_erf`. + + void _acb_hypgeom_erfi_series(acb_ptr res, acb_srcptr z, long zlen, long len, long prec) + + void acb_hypgeom_erfi_series(acb_poly_t res, const acb_poly_t z, long len, long prec) + # Computes the imaginary error function of the power series *z*, + # truncated to length *len*. + + void acb_hypgeom_fresnel(acb_t res1, acb_t res2, const acb_t z, int normalized, long prec) + # Sets *res1* to the Fresnel sine integral `S(z)` and *res2* to + # the Fresnel cosine integral `C(z)`. Optionally, just a single function + # can be computed by passing *NULL* as the other output variable. + # The definition `S(z) = \int_0^z \sin(t^2) dt` is used if *normalized* is 0, + # and `S(z) = \int_0^z \sin(\tfrac{1}{2} \pi t^2) dt` is used if + # *normalized* is 1 (the latter is the Abramowitz & Stegun convention). + # `C(z)` is defined analogously. + + void _acb_hypgeom_fresnel_series(acb_ptr res1, acb_ptr res2, acb_srcptr z, long zlen, int normalized, long len, long prec) + + void acb_hypgeom_fresnel_series(acb_poly_t res1, acb_poly_t res2, const acb_poly_t z, int normalized, long len, long prec) + # Sets *res1* to the Fresnel sine integral and *res2* to the Fresnel + # cosine integral of the power series *z*, truncated to length *len*. + # Optionally, just a single function can be computed by passing *NULL* + # as the other output variable. + + void acb_hypgeom_bessel_j_asymp(acb_t res, const acb_t nu, const acb_t z, long prec) + # Computes the Bessel function of the first kind + # via :func:`acb_hypgeom_u_asymp`. + # For all complex `\nu, z`, we have + # .. math :: + # J_{\nu}(z) = \frac{z^{\nu}}{2^{\nu} e^{iz} \Gamma(\nu+1)} + # {}_1F_1(\nu+\tfrac{1}{2}, 2\nu+1, 2iz) = A_{+} B_{+} + A_{-} B_{-} + # where + # .. math :: + # A_{\pm} = z^{\nu} (z^2)^{-\tfrac{1}{2}-\nu} (\mp i z)^{\tfrac{1}{2}+\nu} (2 \pi)^{-1/2} = (\pm iz)^{-1/2-\nu} z^{\nu} (2 \pi)^{-1/2} + # .. math :: + # B_{\pm} = e^{\pm i z} U^{*}(\nu+\tfrac{1}{2}, 2\nu+1, \mp 2iz). + # Nicer representations of the factors `A_{\pm}` can be given depending conditionally + # on the parameters. If `\nu + \tfrac{1}{2} = n \in \mathbb{Z}`, we have + # `A_{\pm} = (\pm i)^{n} (2 \pi z)^{-1/2}`. + # And if `\operatorname{Re}(z) > 0`, we have `A_{\pm} = \exp(\mp i [(2\nu+1)/4] \pi) (2 \pi z)^{-1/2}`. + + void acb_hypgeom_bessel_j_0f1(acb_t res, const acb_t nu, const acb_t z, long prec) + # Computes the Bessel function of the first kind from + # .. math :: + # J_{\nu}(z) = \frac{1}{\Gamma(\nu+1)} \left(\frac{z}{2}\right)^{\nu} + # {}_0F_1\left(\nu+1, -\frac{z^2}{4}\right). + + void acb_hypgeom_bessel_j(acb_t res, const acb_t nu, const acb_t z, long prec) + # Computes the Bessel function of the first kind `J_{\nu}(z)` using + # an automatic algorithm choice. + + void acb_hypgeom_bessel_y(acb_t res, const acb_t nu, const acb_t z, long prec) + # Computes the Bessel function of the second kind `Y_{\nu}(z)` from the + # formula + # .. math :: + # Y_{\nu}(z) = \frac{\cos(\nu \pi) J_{\nu}(z) - J_{-\nu}(z)}{\sin(\nu \pi)} + # unless `\nu = n` is an integer in which case the limit value + # .. math :: + # Y_n(z) = -\frac{2}{\pi} \left( i^n K_n(iz) + + # \left[\log(iz)-\log(z)\right] J_n(z) \right) + # is computed. + # As currently implemented, the output is indeterminate if `\nu` is nonexact + # and contains an integer. + + void acb_hypgeom_bessel_jy(acb_t res1, acb_t res2, const acb_t nu, const acb_t z, long prec) + # Sets *res1* to `J_{\nu}(z)` and *res2* to `Y_{\nu}(z)`, computed + # simultaneously. From these values, the user can easily + # construct the Bessel functions of the third kind (Hankel functions) + # `H_{\nu}^{(1)}(z), H_{\nu}^{(2)}(z) = J_{\nu}(z) \pm i Y_{\nu}(z)`. + + void acb_hypgeom_bessel_i_asymp(acb_t res, const acb_t nu, const acb_t z, int scaled, long prec) + + void acb_hypgeom_bessel_i_0f1(acb_t res, const acb_t nu, const acb_t z, int scaled, long prec) + + void acb_hypgeom_bessel_i(acb_t res, const acb_t nu, const acb_t z, long prec) + + void acb_hypgeom_bessel_i_scaled(acb_t res, const acb_t nu, const acb_t z, long prec) + # Computes the modified Bessel function of the first kind + # `I_{\nu}(z) = z^{\nu} (iz)^{-\nu} J_{\nu}(iz)` respectively using + # asymptotic series (see :func:`acb_hypgeom_bessel_j_asymp`), + # the convergent series + # .. math :: + # I_{\nu}(z) = \frac{1}{\Gamma(\nu+1)} \left(\frac{z}{2}\right)^{\nu} + # {}_0F_1\left(\nu+1, \frac{z^2}{4}\right), + # or an automatic algorithm choice. + # The *scaled* version computes the function `e^{-z} I_{\nu}(z)`. The *asymp* + # and *0f1* functions implement both variants and allow choosing with a flag. + + void acb_hypgeom_bessel_k_asymp(acb_t res, const acb_t nu, const acb_t z, int scaled, long prec) + # Computes the modified Bessel function of the second kind via + # via :func:`acb_hypgeom_u_asymp`. For all `\nu` and all `z \ne 0`, we have + # .. math :: + # K_{\nu}(z) = \left(\frac{2z}{\pi}\right)^{-1/2} e^{-z} + # U^{*}(\nu+\tfrac{1}{2}, 2\nu+1, 2z). + # If *scaled* is set, computes the function `e^{z} K_{\nu}(z)`. + + void acb_hypgeom_bessel_k_0f1_series(acb_poly_t res, const acb_poly_t nu, const acb_poly_t z, int scaled, long len, long prec) + # Computes the modified Bessel function of the second kind `K_{\nu}(z)` + # as a power series truncated to length *len*, + # given `\nu, z \in \mathbb{C}[[x]]`. Uses the formula + # .. math :: + # K_{\nu}(z) = \frac{1}{2} \frac{\pi}{\sin(\pi \nu)} \left[ + # \left(\frac{z}{2}\right)^{-\nu} + # {}_0{\widetilde F}_1\left(1-\nu, \frac{z^2}{4}\right) + # - + # \left(\frac{z}{2}\right)^{\nu} + # {}_0{\widetilde F}_1\left(1+\nu, \frac{z^2}{4}\right) + # \right]. + # If `\nu[0] \in \mathbb{Z}`, it computes one extra derivative and removes + # the singularity (it is then assumed that `\nu[1] \ne 0`). + # As currently implemented, the output is indeterminate if `\nu[0]` is nonexact + # and contains an integer. + # If *scaled* is set, computes the function `e^{z} K_{\nu}(z)`. + + void acb_hypgeom_bessel_k_0f1(acb_t res, const acb_t nu, const acb_t z, int scaled, long prec) + # Computes the modified Bessel function of the second kind from + # .. math :: + # K_{\nu}(z) = \frac{1}{2} \left[ + # \left(\frac{z}{2}\right)^{-\nu} + # \Gamma(\nu) + # {}_0F_1\left(1-\nu, \frac{z^2}{4}\right) + # - + # \left(\frac{z}{2}\right)^{\nu} + # \frac{\pi}{\nu \sin(\pi \nu) \Gamma(\nu)} + # {}_0F_1\left(\nu+1, \frac{z^2}{4}\right) + # \right] + # if `\nu \notin \mathbb{Z}`. If `\nu \in \mathbb{Z}`, it computes + # the limit value via :func:`acb_hypgeom_bessel_k_0f1_series`. + # As currently implemented, the output is indeterminate if `\nu` is nonexact + # and contains an integer. + # If *scaled* is set, computes the function `e^{z} K_{\nu}(z)`. + + void acb_hypgeom_bessel_k(acb_t res, const acb_t nu, const acb_t z, long prec) + # Computes the modified Bessel function of the second kind `K_{\nu}(z)` using + # an automatic algorithm choice. + + void acb_hypgeom_bessel_k_scaled(acb_t res, const acb_t nu, const acb_t z, long prec) + # Computes the function `e^{z} K_{\nu}(z)`. + + void acb_hypgeom_airy_direct(acb_t ai, acb_t ai_prime, acb_t bi, acb_t bi_prime, const acb_t z, long n, long prec) + # Computes the Airy functions using direct series expansions truncated at *n* terms. + # Error bounds are included in the output. + + void acb_hypgeom_airy_asymp(acb_t ai, acb_t ai_prime, acb_t bi, acb_t bi_prime, const acb_t z, long n, long prec) + # Computes the Airy functions using asymptotic expansions truncated at *n* terms. + # Error bounds are included in the output. + # For details about how the error bounds are computed, see + # :ref:`algorithms_hypergeometric_asymptotic_airy`. + + void acb_hypgeom_airy_bound(mag_t ai, mag_t ai_prime, mag_t bi, mag_t bi_prime, const acb_t z) + # Computes bounds for the Airy functions using first-order asymptotic + # expansions together with error bounds. This function uses some + # shortcuts to make it slightly faster than calling + # :func:`acb_hypgeom_airy_asymp` with `n = 1`. + + void acb_hypgeom_airy(acb_t ai, acb_t ai_prime, acb_t bi, acb_t bi_prime, const acb_t z, long prec) + # Computes Airy functions using an automatic algorithm choice. + # We use :func:`acb_hypgeom_airy_asymp` whenever this gives full accuracy + # and :func:`acb_hypgeom_airy_direct` otherwise. + # In the latter case, we first use hardware double precision arithmetic to + # determine an accurate estimate of the working precision needed + # to compute the Airy functions accurately for given *z*. This estimate is + # obtained by comparing the leading-order asymptotic estimate of the Airy + # functions with the magnitude of the largest term in the power series. + # The estimate is generic in the sense that it does not take into account + # vanishing near the roots of the functions. + # We subsequently evaluate the power series at the midpoint of *z* and + # bound the propagated error using derivatives. Derivatives are + # bounded using :func:`acb_hypgeom_airy_bound`. + + void acb_hypgeom_airy_jet(acb_ptr ai, acb_ptr bi, const acb_t z, long len, long prec) + # Writes to *ai* and *bi* the respective Taylor expansions of the Airy functions + # at the point *z*, truncated to length *len*. + # Either of the outputs can be *NULL* to avoid computing that function. + # The variable *z* is not allowed to be aliased with the outputs. + # To simplify the implementation, this method does not compute the + # series expansions of the primed versions directly; these are + # easily obtained by computing one extra coefficient and differentiating + # the output with :func:`_acb_poly_derivative`. + + void _acb_hypgeom_airy_series(acb_ptr ai, acb_ptr ai_prime, acb_ptr bi, acb_ptr bi_prime, acb_srcptr z, long zlen, long len, long prec) + + void acb_hypgeom_airy_series(acb_poly_t ai, acb_poly_t ai_prime, acb_poly_t bi, acb_poly_t bi_prime, const acb_poly_t z, long len, long prec) + # Computes the Airy functions evaluated at the power series *z*, + # truncated to length *len*. As with the other Airy methods, any of the + # outputs can be *NULL*. + + void acb_hypgeom_coulomb(acb_t F, acb_t G, acb_t Hpos, acb_t Hneg, const acb_t l, const acb_t eta, const acb_t z, long prec) + # Writes to *F*, *G*, *Hpos*, *Hneg* the values of the respective + # Coulomb wave functions. Any of the outputs can be *NULL*. + + void acb_hypgeom_coulomb_jet(acb_ptr F, acb_ptr G, acb_ptr Hpos, acb_ptr Hneg, const acb_t l, const acb_t eta, const acb_t z, long len, long prec) + # Writes to *F*, *G*, *Hpos*, *Hneg* the respective Taylor expansions of the + # Coulomb wave functions at the point *z*, truncated to length *len*. + # Any of the outputs can be *NULL*. + + void _acb_hypgeom_coulomb_series(acb_ptr F, acb_ptr G, acb_ptr Hpos, acb_ptr Hneg, const acb_t l, const acb_t eta, acb_srcptr z, long zlen, long len, long prec) + + void acb_hypgeom_coulomb_series(acb_poly_t F, acb_poly_t G, acb_poly_t Hpos, acb_poly_t Hneg, const acb_t l, const acb_t eta, const acb_poly_t z, long len, long prec) + # Computes the Coulomb wave functions evaluated at the power series *z*, + # truncated to length *len*. Any of the outputs can be *NULL*. + + void acb_hypgeom_gamma_upper_asymp(acb_t res, const acb_t s, const acb_t z, int regularized, long prec) + + void acb_hypgeom_gamma_upper_1f1a(acb_t res, const acb_t s, const acb_t z, int regularized, long prec) + + void acb_hypgeom_gamma_upper_1f1b(acb_t res, const acb_t s, const acb_t z, int regularized, long prec) + + void acb_hypgeom_gamma_upper_singular(acb_t res, long s, const acb_t z, int regularized, long prec) + + void acb_hypgeom_gamma_upper(acb_t res, const acb_t s, const acb_t z, int regularized, long prec) + # If *regularized* is 0, computes the upper incomplete gamma function + # `\Gamma(s,z)`. + # If *regularized* is 1, computes the regularized upper incomplete + # gamma function `Q(s,z) = \Gamma(s,z) / \Gamma(s)`. + # If *regularized* is 2, computes the generalized exponential integral + # `z^{-s} \Gamma(s,z) = E_{1-s}(z)` instead (this option is mainly + # intended for internal use; :func:`acb_hypgeom_expint` is the intended + # interface for computing the exponential integral). + # The different methods respectively implement the formulas + # .. math :: + # \Gamma(s,z) = e^{-z} U(1-s,1-s,z) + # .. math :: + # \Gamma(s,z) = \Gamma(s) - \frac{z^s}{s} {}_1F_1(s, s+1, -z) + # .. math :: + # \Gamma(s,z) = \Gamma(s) - \frac{z^s e^{-z}}{s} {}_1F_1(1, s+1, z) + # .. math :: + # \Gamma(s,z) = \frac{(-1)^n}{n!} (\psi(n+1) - \log(z)) + # + \frac{(-1)^n}{(n+1)!} z \, {}_2F_2(1,1,2,2+n,-z) + # - z^{-n} \sum_{k=0}^{n-1} \frac{(-z)^k}{(k-n) k!}, + # \quad n = -s \in \mathbb{Z}_{\ge 0} + # and an automatic algorithm choice. The automatic version also handles + # other special input such as `z = 0` and `s = 1, 2, 3`. + # The *singular* version evaluates the finite sum directly and therefore + # assumes that *s* is not too large. + + void _acb_hypgeom_gamma_upper_series(acb_ptr res, const acb_t s, acb_srcptr z, long zlen, int regularized, long n, long prec) + + void acb_hypgeom_gamma_upper_series(acb_poly_t res, const acb_t s, const acb_poly_t z, int regularized, long n, long prec) + # Sets *res* to an upper incomplete gamma function where *s* is + # a constant and *z* is a power series, truncated to length *n*. + # The *regularized* argument has the same interpretation as in + # :func:`acb_hypgeom_gamma_upper`. + + void acb_hypgeom_gamma_lower(acb_t res, const acb_t s, const acb_t z, int regularized, long prec) + # If *regularized* is 0, computes the lower incomplete gamma function + # `\gamma(s,z) = \frac{z^s}{s} {}_1F_1(s, s+1, -z)`. + # If *regularized* is 1, computes the regularized lower incomplete + # gamma function `P(s,z) = \gamma(s,z) / \Gamma(s)`. + # If *regularized* is 2, computes a further regularized lower incomplete + # gamma function `\gamma^{*}(s,z) = z^{-s} P(s,z)`. + + void _acb_hypgeom_gamma_lower_series(acb_ptr res, const acb_t s, acb_srcptr z, long zlen, int regularized, long n, long prec) + + void acb_hypgeom_gamma_lower_series(acb_poly_t res, const acb_t s, const acb_poly_t z, int regularized, long n, long prec) + # Sets *res* to an lower incomplete gamma function where *s* is + # a constant and *z* is a power series, truncated to length *n*. + # The *regularized* argument has the same interpretation as in + # :func:`acb_hypgeom_gamma_lower`. + + void acb_hypgeom_beta_lower(acb_t res, const acb_t a, const acb_t b, const acb_t z, int regularized, long prec) + # Computes the (lower) incomplete beta function, defined by + # `B(a,b;z) = \int_0^z t^{a-1} (1-t)^{b-1}`, + # optionally the regularized incomplete beta function + # `I(a,b;z) = B(a,b;z) / B(a,b;1)`. + # In general, the integral must be interpreted using analytic continuation. + # The precise definitions for all parameter values are + # .. math :: + # B(a,b;z) = \frac{z^a}{a} {}_2F_1(a, 1-b, a+1, z) + # .. math :: + # I(a,b;z) = \frac{\Gamma(a+b)}{\Gamma(b)} z^a {}_2{\widetilde F}_1(a, 1-b, a+1, z). + # Note that both functions with this definition are undefined + # for nonpositive integer *a*, and *I* is undefined for nonpositive integer + # `a + b`. + + void _acb_hypgeom_beta_lower_series(acb_ptr res, const acb_t a, const acb_t b, acb_srcptr z, long zlen, int regularized, long n, long prec) + + void acb_hypgeom_beta_lower_series(acb_poly_t res, const acb_t a, const acb_t b, const acb_poly_t z, int regularized, long n, long prec) + # Sets *res* to the lower incomplete beta function `B(a,b;z)` (optionally + # the regularized version `I(a,b;z)`) where *a* and *b* are constants + # and *z* is a power series, truncating the result to length *n*. + # The underscore method requires positive lengths and does not support + # aliasing. + + void acb_hypgeom_expint(acb_t res, const acb_t s, const acb_t z, long prec) + # Computes the generalized exponential integral `E_s(z)`. This is a + # trivial wrapper of :func:`acb_hypgeom_gamma_upper`. + + void acb_hypgeom_ei_asymp(acb_t res, const acb_t z, long prec) + + void acb_hypgeom_ei_2f2(acb_t res, const acb_t z, long prec) + + void acb_hypgeom_ei(acb_t res, const acb_t z, long prec) + # Computes the exponential integral `\operatorname{Ei}(z)`, respectively + # using + # .. math :: + # \operatorname{Ei}(z) = -e^z U(1,1,-z) - \log(-z) + # + \frac{1}{2} \left(\log(z) - \log\left(\frac{1}{z}\right) \right) + # .. math :: + # \operatorname{Ei}(z) = z {}_2F_2(1, 1; 2, 2; z) + \gamma + # + \frac{1}{2} \left(\log(z) - \log\left(\frac{1}{z}\right) \right) + # and an automatic algorithm choice. + + void _acb_hypgeom_ei_series(acb_ptr res, acb_srcptr z, long zlen, long len, long prec) + + void acb_hypgeom_ei_series(acb_poly_t res, const acb_poly_t z, long len, long prec) + # Computes the exponential integral of the power series *z*, + # truncated to length *len*. + + void acb_hypgeom_si_asymp(acb_t res, const acb_t z, long prec) + + void acb_hypgeom_si_1f2(acb_t res, const acb_t z, long prec) + + void acb_hypgeom_si(acb_t res, const acb_t z, long prec) + # Computes the sine integral `\operatorname{Si}(z)`, respectively + # using + # .. math :: + # \operatorname{Si}(z) = \frac{i}{2} \left[ + # e^{iz} U(1,1,-iz) - e^{-iz} U(1,1,iz) + + # \log(-iz) - \log(iz) \right] + # .. math :: + # \operatorname{Si}(z) = z {}_1F_2(\tfrac{1}{2}; \tfrac{3}{2}, \tfrac{3}{2}; -\tfrac{z^2}{4}) + # and an automatic algorithm choice. + + void _acb_hypgeom_si_series(acb_ptr res, acb_srcptr z, long zlen, long len, long prec) + + void acb_hypgeom_si_series(acb_poly_t res, const acb_poly_t z, long len, long prec) + # Computes the sine integral of the power series *z*, + # truncated to length *len*. + + void acb_hypgeom_ci_asymp(acb_t res, const acb_t z, long prec) + + void acb_hypgeom_ci_2f3(acb_t res, const acb_t z, long prec) + + void acb_hypgeom_ci(acb_t res, const acb_t z, long prec) + # Computes the cosine integral `\operatorname{Ci}(z)`, respectively + # using + # .. math :: + # \operatorname{Ci}(z) = \log(z) - \frac{1}{2} \left[ + # e^{iz} U(1,1,-iz) + e^{-iz} U(1,1,iz) + + # \log(-iz) + \log(iz) \right] + # .. math :: + # \operatorname{Ci}(z) = -\tfrac{z^2}{4} + # {}_2F_3(1, 1; 2, 2, \tfrac{3}{2}; -\tfrac{z^2}{4}) + # + \log(z) + \gamma + # and an automatic algorithm choice. + + void _acb_hypgeom_ci_series(acb_ptr res, acb_srcptr z, long zlen, long len, long prec) + + void acb_hypgeom_ci_series(acb_poly_t res, const acb_poly_t z, long len, long prec) + # Computes the cosine integral of the power series *z*, + # truncated to length *len*. + + void acb_hypgeom_shi(acb_t res, const acb_t z, long prec) + # Computes the hyperbolic sine integral + # `\operatorname{Shi}(z) = -i \operatorname{Si}(iz)`. + # This is a trivial wrapper of :func:`acb_hypgeom_si`. + + void _acb_hypgeom_shi_series(acb_ptr res, acb_srcptr z, long zlen, long len, long prec) + + void acb_hypgeom_shi_series(acb_poly_t res, const acb_poly_t z, long len, long prec) + # Computes the hyperbolic sine integral of the power series *z*, + # truncated to length *len*. + + void acb_hypgeom_chi_asymp(acb_t res, const acb_t z, long prec) + + void acb_hypgeom_chi_2f3(acb_t res, const acb_t z, long prec) + + void acb_hypgeom_chi(acb_t res, const acb_t z, long prec) + # Computes the hyperbolic cosine integral `\operatorname{Chi}(z)`, respectively + # using + # .. math :: + # \operatorname{Chi}(z) = -\frac{1}{2} \left[ + # e^{z} U(1,1,-z) + e^{-z} U(1,1,z) + + # \log(-z) - \log(z) \right] + # .. math :: + # \operatorname{Chi}(z) = \tfrac{z^2}{4} + # {}_2F_3(1, 1; 2, 2, \tfrac{3}{2}; \tfrac{z^2}{4}) + # + \log(z) + \gamma + # and an automatic algorithm choice. + + void _acb_hypgeom_chi_series(acb_ptr res, acb_srcptr z, long zlen, long len, long prec) + + void acb_hypgeom_chi_series(acb_poly_t res, const acb_poly_t z, long len, long prec) + # Computes the hyperbolic cosine integral of the power series *z*, + # truncated to length *len*. + + void acb_hypgeom_li(acb_t res, const acb_t z, int offset, long prec) + # If *offset* is zero, computes the logarithmic integral + # `\operatorname{li}(z) = \operatorname{Ei}(\log(z))`. + # If *offset* is nonzero, computes the offset logarithmic integral + # `\operatorname{Li}(z) = \operatorname{li}(z) - \operatorname{li}(2)`. + + void _acb_hypgeom_li_series(acb_ptr res, acb_srcptr z, long zlen, int offset, long len, long prec) + + void acb_hypgeom_li_series(acb_poly_t res, const acb_poly_t z, int offset, long len, long prec) + # Computes the logarithmic integral (optionally the offset version) + # of the power series *z*, truncated to length *len*. + + void acb_hypgeom_2f1_continuation(acb_t res0, acb_t res1, const acb_t a, const acb_t b, const acb_t c, const acb_t z0, const acb_t z1, const acb_t f0, const acb_t f1, long prec) + # Given `F(z_0), F'(z_0)` in *f0*, *f1*, sets *res0* and *res1* to `F(z_1), F'(z_1)` + # by integrating the hypergeometric differential equation along a straight-line path. + # The evaluation points should be well-isolated from the singular points 0 and 1. + + void acb_hypgeom_2f1_series_direct(acb_poly_t res, const acb_poly_t a, const acb_poly_t b, const acb_poly_t c, const acb_poly_t z, int regularized, long len, long prec) + # Computes `F(z)` of the given power series truncated to length *len*, using + # direct summation of the hypergeometric series. + + void acb_hypgeom_2f1_direct(acb_t res, const acb_t a, const acb_t b, const acb_t c, const acb_t z, int regularized, long prec) + # Computes `F(z)` using direct summation of the hypergeometric series. + + void acb_hypgeom_2f1_transform(acb_t res, const acb_t a, const acb_t b, const acb_t c, const acb_t z, int flags, int which, long prec) + + void acb_hypgeom_2f1_transform_limit(acb_t res, const acb_t a, const acb_t b, const acb_t c, const acb_t z, int regularized, int which, long prec) + # Computes `F(z)` using an argument transformation determined by the flag *which*. + # Legal values are 1 for `z/(z-1)`, + # 2 for `1/z`, 3 for `1/(1-z)`, 4 for `1-z`, and 5 for `1-1/z`. + # The *transform_limit* version assumes that *which* is not 1. + # If *which* is 2 or 3, it assumes that `b-a` represents an exact integer. + # If *which* is 4 or 5, it assumes that `c-a-b` represents an exact integer. + # In these cases, it computes the correct limit value. + # See :func:`acb_hypgeom_2f1` for the meaning of *flags*. + + void acb_hypgeom_2f1_corner(acb_t res, const acb_t a, const acb_t b, const acb_t c, const acb_t z, int regularized, long prec) + # Computes `F(z)` near the corner cases `\exp(\pm \pi i \sqrt{3})` + # by analytic continuation. + + int acb_hypgeom_2f1_choose(const acb_t z) + # Chooses a method to compute the function based on the location of *z* + # in the complex plane. If the return value is 0, direct summation should be used. + # If the return value is 1 to 5, the transformation with this index in + # :func:`acb_hypgeom_2f1_transform` should be used. + # If the return value is 6, the corner case algorithm should be used. + + void acb_hypgeom_2f1(acb_t res, const acb_t a, const acb_t b, const acb_t c, const acb_t z, int flags, long prec) + # Computes `F(z)` or `\operatorname{\mathbf{F}}(z)` + # using an automatic algorithm choice. + # The following bit fields can be set in *flags*: + # - *ACB_HYPGEOM_2F1_REGULARIZED* - computes the regularized + # hypergeometric function `\operatorname{\mathbf{F}}(z)`. + # Setting *flags* to 1 is the same as just toggling this option. + # - *ACB_HYPGEOM_2F1_AB* - `a-b` is an integer. + # - *ACB_HYPGEOM_2F1_ABC* - `a+b-c` is an integer. + # - *ACB_HYPGEOM_2F1_AC* - `a-c` is an integer. + # - *ACB_HYPGEOM_2F1_BC* - `b-c` is an integer. + # The last four flags can be set to indicate that the respective parameter + # differences are known to represent exact integers, even if the input intervals + # are inexact. This allows the correct limits to be evaluated when + # applying transformation formulas. For example, to evaluate + # `{}_2F_1(\sqrt{2}, 1/2, \sqrt{2}+3/2, 9/10)`, the *ABC* flag should be set. + # If not set, the result will be an indeterminate interval due to + # internally dividing by an interval containing zero. + # If the parameters are exact floating-point numbers (including exact + # integers or half-integers), then the limits are computed automatically, and + # setting these flags is unnecessary. + # Currently, only the *AB* and *ABC* flags are used this way; + # the *AC* and *BC* flags might be used in the future. + + void acb_hypgeom_chebyshev_t(acb_t res, const acb_t n, const acb_t z, long prec) + + void acb_hypgeom_chebyshev_u(acb_t res, const acb_t n, const acb_t z, long prec) + # Computes the Chebyshev polynomial (or Chebyshev function) of first or second kind + # .. math :: + # T_n(z) = {}_2F_1\left(-n,n,\frac{1}{2},\frac{1-z}{2}\right) + # .. math :: + # U_n(z) = (n+1) {}_2F_1\left(-n,n+2,\frac{3}{2},\frac{1-z}{2}\right). + # The hypergeometric series definitions are only used for computation + # near the point 1. In general, trigonometric representations are used. + # For word-size integer *n*, :func:`acb_chebyshev_t_ui` and + # :func:`acb_chebyshev_u_ui` are called. + + void acb_hypgeom_jacobi_p(acb_t res, const acb_t n, const acb_t a, const acb_t b, const acb_t z, long prec) + # Computes the Jacobi polynomial (or Jacobi function) + # .. math :: + # P_n^{(a,b)}(z)=\frac{(a+1)_n}{\Gamma(n+1)} {}_2F_1\left(-n,n+a+b+1,a+1,\frac{1-z}{2}\right). + # For nonnegative integer *n*, this is a polynomial in *a*, *b* and *z*, + # even when the parameters are such that the hypergeometric series + # is undefined. In such cases, the polynomial is evaluated using + # direct methods. + + void acb_hypgeom_gegenbauer_c(acb_t res, const acb_t n, const acb_t m, const acb_t z, long prec) + # Computes the Gegenbauer polynomial (or Gegenbauer function) + # .. math :: + # C_n^{m}(z)=\frac{(2m)_n}{\Gamma(n+1)} {}_2F_1\left(-n,2m+n,m+\frac{1}{2},\frac{1-z}{2}\right). + # For nonnegative integer *n*, this is a polynomial in *m* and *z*, + # even when the parameters are such that the hypergeometric series + # is undefined. In such cases, the polynomial is evaluated using + # direct methods. + + void acb_hypgeom_laguerre_l(acb_t res, const acb_t n, const acb_t m, const acb_t z, long prec) + # Computes the Laguerre polynomial (or Laguerre function) + # .. math :: + # L_n^{m}(z)=\frac{(m+1)_n}{\Gamma(n+1)} {}_1F_1\left(-n,m+1,z\right). + # For nonnegative integer *n*, this is a polynomial in *m* and *z*, + # even when the parameters are such that the hypergeometric series + # is undefined. In such cases, the polynomial is evaluated using + # direct methods. + # There are at least two incompatible ways to define the Laguerre function when + # *n* is a negative integer. One possibility when `m = 0` is to define + # `L_{-n}^0(z) = e^z L_{n-1}^0(-z)`. Another possibility is to cover this + # case with the recurrence relation `L_{n-1}^m(z) + L_n^{m-1}(z) = L_n^m(z)`. + # Currently, we leave this case undefined (returning indeterminate). + + void acb_hypgeom_hermite_h(acb_t res, const acb_t n, const acb_t z, long prec) + # Computes the Hermite polynomial (or Hermite function) + # .. math :: + # H_n(z) = 2^n \sqrt{\pi} \left( + # \frac{1}{\Gamma((1-n)/2)} {}_1F_1\left(-\frac{n}{2},\frac{1}{2},z^2\right) + # - + # \frac{2z}{\Gamma(-n/2)} {}_1F_1\left(\frac{1-n}{2},\frac{3}{2},z^2\right)\right). + + void acb_hypgeom_legendre_p(acb_t res, const acb_t n, const acb_t m, const acb_t z, int type, long prec) + # Sets *res* to the associated Legendre function of the first kind + # evaluated for degree *n*, order *m*, and argument *z*. + # When *m* is zero, this reduces to the Legendre polynomial `P_n(z)`. + # Many different branch cut conventions appear in the literature. + # If *type* is 0, the version + # .. math :: + # P_n^m(z) = \frac{(1+z)^{m/2}}{(1-z)^{m/2}} + # \mathbf{F}\left(-n, n+1, 1-m, \frac{1-z}{2}\right) + # is computed, and if *type* is 1, the alternative version + # .. math :: + # {\mathcal P}_n^m(z) = \frac{(z+1)^{m/2}}{(z-1)^{m/2}} + # \mathbf{F}\left(-n, n+1, 1-m, \frac{1-z}{2}\right). + # is computed. Type 0 and type 1 respectively correspond to + # type 2 and type 3 in *Mathematica* and *mpmath*. + + void acb_hypgeom_legendre_q(acb_t res, const acb_t n, const acb_t m, const acb_t z, int type, long prec) + # Sets *res* to the associated Legendre function of the second kind + # evaluated for degree *n*, order *m*, and argument *z*. + # When *m* is zero, this reduces to the Legendre function `Q_n(z)`. + # Many different branch cut conventions appear in the literature. + # If *type* is 0, the version + # .. math :: + # Q_n^m(z) = \frac{\pi}{2 \sin(\pi m)} + # \left( \cos(\pi m) P_n^m(z) - + # \frac{\Gamma(1+m+n)}{\Gamma(1-m+n)} P_n^{-m}(z)\right) + # is computed, and if *type* is 1, the alternative version + # .. math :: + # \mathcal{Q}_n^m(z) = \frac{\pi}{2 \sin(\pi m)} e^{\pi i m} + # \left( \mathcal{P}_n^m(z) - + # \frac{\Gamma(1+m+n)}{\Gamma(1-m+n)} \mathcal{P}_n^{-m}(z)\right) + # is computed. Type 0 and type 1 respectively correspond to + # type 2 and type 3 in *Mathematica* and *mpmath*. + # When *m* is an integer, either expression is interpreted as a limit. + # We make use of the connection formulas [WQ3a]_, [WQ3b]_ and [WQ3c]_ + # to allow computing the function even in the limiting case. + # (The formula [WQ3d]_ would be useful, but is incorrect in the lower + # half plane.) + # .. [WQ3a] http://functions.wolfram.com/07.11.26.0033.01 + # .. [WQ3b] http://functions.wolfram.com/07.12.27.0014.01 + # .. [WQ3c] http://functions.wolfram.com/07.12.26.0003.01 + # .. [WQ3d] http://functions.wolfram.com/07.12.26.0088.01 + + void acb_hypgeom_legendre_p_uiui_rec(acb_t res, unsigned long n, unsigned long m, const acb_t z, long prec) + # For nonnegative integer *n* and *m*, uses recurrence relations to evaluate + # `(1-z^2)^{-m/2} P_n^m(z)` which is a polynomial in *z*. + + void acb_hypgeom_spherical_y(acb_t res, long n, long m, const acb_t theta, const acb_t phi, long prec) + # Computes the spherical harmonic of degree *n*, order *m*, + # latitude angle *theta*, and longitude angle *phi*, normalized + # such that + # .. math :: + # Y_n^m(\theta, \phi) = \sqrt{\frac{2n+1}{4\pi} \frac{(n-m)!}{(n+m)!}} e^{im\phi} P_n^m(\cos(\theta)). + # The definition is extended to negative *m* and *n* by symmetry. + # This function is a polynomial in `\cos(\theta)` and `\sin(\theta)`. + # We evaluate it using :func:`acb_hypgeom_legendre_p_uiui_rec`. + + void acb_hypgeom_dilog_zero_taylor(acb_t res, const acb_t z, long prec) + # Computes the dilogarithm for *z* close to 0 using the hypergeometric series + # (effective only when `|z| \ll 1`). + + void acb_hypgeom_dilog_zero(acb_t res, const acb_t z, long prec) + # Computes the dilogarithm for *z* close to 0, using the bit-burst algorithm + # instead of the hypergeometric series directly at very high precision. + + void acb_hypgeom_dilog_transform(acb_t res, const acb_t z, int algorithm, long prec) + # Computes the dilogarithm by applying one of the transformations + # `1/z`, `1-z`, `z/(z-1)`, `1/(1-z)`, indexed by *algorithm* from 1 to 4, + # and calling :func:`acb_hypgeom_dilog_zero` with the reduced variable. + # Alternatively, for *algorithm* between 5 and 7, starts from the + # respective point `\pm i`, `(1\pm i)/2`, `(1\pm i)/2` (with the sign + # chosen according to the midpoint of *z*) + # and computes the dilogarithm by the bit-burst method. + + void acb_hypgeom_dilog_continuation(acb_t res, const acb_t a, const acb_t z, long prec) + # Computes `\operatorname{Li}_2(z) - \operatorname{Li}_2(a)` using + # Taylor expansion at *a*. Binary splitting is used. Both *a* and *z* + # should be well isolated from the points 0 and 1, except that *a* may + # be exactly 0. If the straight line path from *a* to *b* crosses the branch + # cut, this method provides continuous analytic continuation instead of + # computing the principal branch. + + void acb_hypgeom_dilog_bitburst(acb_t res, acb_t z0, const acb_t z, long prec) + # Sets *z0* to a point with short bit expansion close to *z* and sets + # *res* to `\operatorname{Li}_2(z) - \operatorname{Li}_2(z_0)`, computed + # using the bit-burst algorithm. + + void acb_hypgeom_dilog(acb_t res, const acb_t z, long prec) + # Computes the dilogarithm using a default algorithm choice. diff --git a/src/sage/libs/flint/acb_mat.pxd b/src/sage/libs/flint/acb_mat.pxd new file mode 100644 index 00000000000..a12ceeda761 --- /dev/null +++ b/src/sage/libs/flint/acb_mat.pxd @@ -0,0 +1,570 @@ +# distutils: libraries = flint +# distutils: depends = flint/acb_mat.h + +################################################################################ +# This file is auto-generated. Do not modify by hand +################################################################################ + +from libc.stdio cimport FILE +from sage.libs.gmp.types cimport * +from sage.libs.mpfr.types cimport * +from sage.libs.flint.types cimport * + +cdef extern from "flint_wrap.h": + + void acb_mat_init(acb_mat_t mat, long r, long c) + # Initializes the matrix, setting it to the zero matrix with *r* rows + # and *c* columns. + + void acb_mat_clear(acb_mat_t mat) + # Clears the matrix, deallocating all entries. + + long acb_mat_allocated_bytes(const acb_mat_t x) + # Returns the total number of bytes heap-allocated internally by this object. + # The count excludes the size of the structure itself. Add + # ``sizeof(acb_mat_struct)`` to get the size of the object as a whole. + + void acb_mat_window_init(acb_mat_t window, const acb_mat_t mat, long r1, long c1, long r2, long c2) + # Initializes *window* to a window matrix into the submatrix of *mat* + # starting at the corner at row *r1* and column *c1* (inclusive) and ending + # at row *r2* and column *c2* (exclusive). + + void acb_mat_window_clear(acb_mat_t window) + # Frees the window matrix. + + void acb_mat_set(acb_mat_t dest, const acb_mat_t src) + + void acb_mat_set_fmpz_mat(acb_mat_t dest, const fmpz_mat_t src) + + void acb_mat_set_round_fmpz_mat(acb_mat_t dest, const fmpz_mat_t src, long prec) + + void acb_mat_set_fmpq_mat(acb_mat_t dest, const fmpq_mat_t src, long prec) + + void acb_mat_set_arb_mat(acb_mat_t dest, const arb_mat_t src) + + void acb_mat_set_round_arb_mat(acb_mat_t dest, const arb_mat_t src, long prec) + # Sets *dest* to *src*. The operands must have identical dimensions. + + void acb_mat_randtest(acb_mat_t mat, flint_rand_t state, long prec, long mag_bits) + # Sets *mat* to a random matrix with up to *prec* bits of precision + # and with exponents of width up to *mag_bits*. + + void acb_mat_randtest_eig(acb_mat_t mat, flint_rand_t state, acb_srcptr E, long prec) + # Sets *mat* to a random matrix with the prescribed eigenvalues + # supplied as the vector *E*. The output matrix is required to be + # square. We generate a random unitary matrix via a matrix + # exponential, and then evaluate an inverse Schur decomposition. + + void acb_mat_printd(const acb_mat_t mat, long digits) + # Prints each entry in the matrix with the specified number of decimal digits. + + void acb_mat_fprintd(FILE * file, const acb_mat_t mat, long digits) + # Prints each entry in the matrix with the specified number of decimal + # digits to the stream *file*. + + int acb_mat_equal(const acb_mat_t mat1, const acb_mat_t mat2) + # Returns whether the matrices have the same dimensions and identical + # intervals as entries. + + int acb_mat_overlaps(const acb_mat_t mat1, const acb_mat_t mat2) + # Returns whether the matrices have the same dimensions + # and each entry in *mat1* overlaps with the corresponding entry in *mat2*. + + int acb_mat_contains(const acb_mat_t mat1, const acb_mat_t mat2) + + int acb_mat_contains_fmpz_mat(const acb_mat_t mat1, const fmpz_mat_t mat2) + + int acb_mat_contains_fmpq_mat(const acb_mat_t mat1, const fmpq_mat_t mat2) + # Returns whether the matrices have the same dimensions and each entry + # in *mat2* is contained in the corresponding entry in *mat1*. + + int acb_mat_eq(const acb_mat_t mat1, const acb_mat_t mat2) + # Returns whether *mat1* and *mat2* certainly represent the same matrix. + + int acb_mat_ne(const acb_mat_t mat1, const acb_mat_t mat2) + # Returns whether *mat1* and *mat2* certainly do not represent the same matrix. + + int acb_mat_is_real(const acb_mat_t mat) + # Returns whether all entries in *mat* have zero imaginary part. + + int acb_mat_is_empty(const acb_mat_t mat) + # Returns whether the number of rows or the number of columns in *mat* is zero. + + int acb_mat_is_square(const acb_mat_t mat) + # Returns whether the number of rows is equal to the number of columns in *mat*. + + int acb_mat_is_exact(const acb_mat_t mat) + # Returns whether all entries in *mat* have zero radius. + + int acb_mat_is_zero(const acb_mat_t mat) + # Returns whether all entries in *mat* are exactly zero. + + int acb_mat_is_finite(const acb_mat_t mat) + # Returns whether all entries in *mat* are finite. + + int acb_mat_is_triu(const acb_mat_t mat) + # Returns whether *mat* is upper triangular; that is, all entries + # below the main diagonal are exactly zero. + + int acb_mat_is_tril(const acb_mat_t mat) + # Returns whether *mat* is lower triangular; that is, all entries + # above the main diagonal are exactly zero. + + int acb_mat_is_diag(const acb_mat_t mat) + # Returns whether *mat* is a diagonal matrix; that is, all entries + # off the main diagonal are exactly zero. + + void acb_mat_zero(acb_mat_t mat) + # Sets all entries in mat to zero. + + void acb_mat_one(acb_mat_t mat) + # Sets the entries on the main diagonal to ones, + # and all other entries to zero. + + void acb_mat_ones(acb_mat_t mat) + # Sets all entries in the matrix to ones. + + void acb_mat_indeterminate(acb_mat_t mat) + # Sets all entries in the matrix to indeterminate (NaN). + + void acb_mat_dft(acb_mat_t mat, int type, long prec) + # Sets *mat* to the DFT (discrete Fourier transform) matrix of order *n* + # where *n* is the smallest dimension of *mat* (if *mat* is not square, + # the matrix is extended periodically along the larger dimension). + # Here, we use the normalized DFT matrix + # .. math :: + # A_{j,k} = \frac{\omega^{jk}}{\sqrt{n}}, \quad \omega = e^{-2\pi i/n}. + # The *type* parameter is currently ignored and should be set to 0. + # In the future, it might be used to select a different convention. + + void acb_mat_transpose(acb_mat_t dest, const acb_mat_t src) + # Sets *dest* to the exact transpose *src*. The operands must have + # compatible dimensions. Aliasing is allowed. + + void acb_mat_conjugate_transpose(acb_mat_t dest, const acb_mat_t src) + # Sets *dest* to the conjugate transpose of *src*. The operands must have + # compatible dimensions. Aliasing is allowed. + + void acb_mat_conjugate(acb_mat_t dest, const acb_mat_t src) + # Sets *dest* to the elementwise complex conjugate of *src*. + + void acb_mat_bound_inf_norm(mag_t b, const acb_mat_t A) + # Sets *b* to an upper bound for the infinity norm (i.e. the largest + # absolute value row sum) of *A*. + + void acb_mat_frobenius_norm(arb_t res, const acb_mat_t A, long prec) + # Sets *res* to the Frobenius norm (i.e. the square root of the sum + # of squares of entries) of *A*. + + void acb_mat_bound_frobenius_norm(mag_t res, const acb_mat_t A) + # Sets *res* to an upper bound for the Frobenius norm of *A*. + + void acb_mat_neg(acb_mat_t dest, const acb_mat_t src) + # Sets *dest* to the exact negation of *src*. The operands must have + # the same dimensions. + + void acb_mat_add(acb_mat_t res, const acb_mat_t mat1, const acb_mat_t mat2, long prec) + # Sets res to the sum of *mat1* and *mat2*. The operands must have the same dimensions. + + void acb_mat_sub(acb_mat_t res, const acb_mat_t mat1, const acb_mat_t mat2, long prec) + # Sets *res* to the difference of *mat1* and *mat2*. The operands must have + # the same dimensions. + + void acb_mat_mul_classical(acb_mat_t res, const acb_mat_t mat1, const acb_mat_t mat2, long prec) + + void acb_mat_mul_threaded(acb_mat_t res, const acb_mat_t mat1, const acb_mat_t mat2, long prec) + + void acb_mat_mul_reorder(acb_mat_t res, const acb_mat_t mat1, const acb_mat_t mat2, long prec) + + void acb_mat_mul(acb_mat_t res, const acb_mat_t mat1, const acb_mat_t mat2, long prec) + # Sets *res* to the matrix product of *mat1* and *mat2*. The operands must have + # compatible dimensions for matrix multiplication. + # The *classical* version performs matrix multiplication in the trivial way. + # The *threaded* version performs classical multiplication but splits the + # computation over the number of threads returned by *flint_get_num_threads()*. + # The *reorder* version reorders the data and performs one to four real + # matrix multiplications via :func:`arb_mat_mul`. + # The default version chooses an algorithm automatically. + + void acb_mat_mul_entrywise(acb_mat_t res, const acb_mat_t mat1, const acb_mat_t mat2, long prec) + # Sets *res* to the entrywise product of *mat1* and *mat2*. + # The operands must have the same dimensions. + + void acb_mat_sqr_classical(acb_mat_t res, const acb_mat_t mat, long prec) + + void acb_mat_sqr(acb_mat_t res, const acb_mat_t mat, long prec) + # Sets *res* to the matrix square of *mat*. The operands must both be square + # with the same dimensions. + + void acb_mat_pow_ui(acb_mat_t res, const acb_mat_t mat, unsigned long exp, long prec) + # Sets *res* to *mat* raised to the power *exp*. Requires that *mat* + # is a square matrix. + + void acb_mat_approx_mul(acb_mat_t res, const acb_mat_t mat1, const acb_mat_t mat2, long prec) + # Approximate matrix multiplication. The input radii are ignored and + # the output matrix is set to an approximate floating-point result. + # For performance reasons, the radii in the output matrix will *not* + # necessarily be written (zeroed), but will remain zero if they + # are already zeroed in *res* before calling this function. + + void acb_mat_scalar_mul_2exp_si(acb_mat_t B, const acb_mat_t A, long c) + # Sets *B* to *A* multiplied by `2^c`. + + void acb_mat_scalar_addmul_si(acb_mat_t B, const acb_mat_t A, long c, long prec) + + void acb_mat_scalar_addmul_fmpz(acb_mat_t B, const acb_mat_t A, const fmpz_t c, long prec) + + void acb_mat_scalar_addmul_arb(acb_mat_t B, const acb_mat_t A, const arb_t c, long prec) + + void acb_mat_scalar_addmul_acb(acb_mat_t B, const acb_mat_t A, const acb_t c, long prec) + # Sets *B* to `B + A \times c`. + + void acb_mat_scalar_mul_si(acb_mat_t B, const acb_mat_t A, long c, long prec) + + void acb_mat_scalar_mul_fmpz(acb_mat_t B, const acb_mat_t A, const fmpz_t c, long prec) + + void acb_mat_scalar_mul_arb(acb_mat_t B, const acb_mat_t A, const arb_t c, long prec) + + void acb_mat_scalar_mul_acb(acb_mat_t B, const acb_mat_t A, const acb_t c, long prec) + # Sets *B* to `A \times c`. + + void acb_mat_scalar_div_si(acb_mat_t B, const acb_mat_t A, long c, long prec) + + void acb_mat_scalar_div_fmpz(acb_mat_t B, const acb_mat_t A, const fmpz_t c, long prec) + + void acb_mat_scalar_div_arb(acb_mat_t B, const acb_mat_t A, const arb_t c, long prec) + + void acb_mat_scalar_div_acb(acb_mat_t B, const acb_mat_t A, const acb_t c, long prec) + # Sets *B* to `A / c`. + + int acb_mat_lu_classical(long * perm, acb_mat_t LU, const acb_mat_t A, long prec) + + int acb_mat_lu_recursive(long * perm, acb_mat_t LU, const acb_mat_t A, long prec) + + int acb_mat_lu(long * perm, acb_mat_t LU, const acb_mat_t A, long prec) + # Given an `n \times n` matrix `A`, computes an LU decomposition `PLU = A` + # using Gaussian elimination with partial pivoting. + # The input and output matrices can be the same, performing the + # decomposition in-place. + # Entry `i` in the permutation vector perm is set to the row index in + # the input matrix corresponding to row `i` in the output matrix. + # The algorithm succeeds and returns nonzero if it can find `n` invertible + # (i.e. not containing zero) pivot entries. This guarantees that the matrix + # is invertible. + # The algorithm fails and returns zero, leaving the entries in `P` and `LU` + # undefined, if it cannot find `n` invertible pivot elements. + # In this case, either the matrix is singular, the input matrix was + # computed to insufficient precision, or the LU decomposition was + # attempted at insufficient precision. + # The *classical* version uses Gaussian elimination directly while + # the *recursive* version performs the computation in a block recursive + # way to benefit from fast matrix multiplication. The default version + # chooses an algorithm automatically. + + void acb_mat_solve_tril_classical(acb_mat_t X, const acb_mat_t L, const acb_mat_t B, int unit, long prec) + + void acb_mat_solve_tril_recursive(acb_mat_t X, const acb_mat_t L, const acb_mat_t B, int unit, long prec) + + void acb_mat_solve_tril(acb_mat_t X, const acb_mat_t L, const acb_mat_t B, int unit, long prec) + + void acb_mat_solve_triu_classical(acb_mat_t X, const acb_mat_t U, const acb_mat_t B, int unit, long prec) + + void acb_mat_solve_triu_recursive(acb_mat_t X, const acb_mat_t U, const acb_mat_t B, int unit, long prec) + + void acb_mat_solve_triu(acb_mat_t X, const acb_mat_t U, const acb_mat_t B, int unit, long prec) + # Solves the lower triangular system `LX = B` or the upper triangular system + # `UX = B`, respectively. If *unit* is set, the main diagonal of *L* or *U* + # is taken to consist of all ones, and in that case the actual entries on + # the diagonal are not read at all and can contain other data. + # The *classical* versions perform the computations iteratively while the + # *recursive* versions perform the computations in a block recursive + # way to benefit from fast matrix multiplication. The default versions + # choose an algorithm automatically. + + void acb_mat_solve_lu_precomp(acb_mat_t X, const long * perm, const acb_mat_t LU, const acb_mat_t B, long prec) + # Solves `AX = B` given the precomputed nonsingular LU decomposition `A = PLU`. + # The matrices `X` and `B` are allowed to be aliased with each other, + # but `X` is not allowed to be aliased with `LU`. + + int acb_mat_solve(acb_mat_t X, const acb_mat_t A, const acb_mat_t B, long prec) + + int acb_mat_solve_lu(acb_mat_t X, const acb_mat_t A, const acb_mat_t B, long prec) + + int acb_mat_solve_precond(acb_mat_t X, const acb_mat_t A, const acb_mat_t B, long prec) + # Solves `AX = B` where `A` is a nonsingular `n \times n` matrix + # and `X` and `B` are `n \times m` matrices. + # If `m > 0` and `A` cannot be inverted numerically (indicating either that + # `A` is singular or that the precision is insufficient), the values in the + # output matrix are left undefined and zero is returned. A nonzero return + # value guarantees that `A` is invertible and that the exact solution + # matrix is contained in the output. + # Three algorithms are provided: + # * The *lu* version performs LU decomposition directly in ball arithmetic. + # This is fast, but the bounds typically blow up exponentially with *n*, + # even if the system is well-conditioned. This algorithm is usually + # the best choice at very high precision. + # * The *precond* version computes an approximate inverse to precondition + # the system. This is usually several times slower than direct LU + # decomposition, but the bounds do not blow up with *n* if the system is + # well-conditioned. This algorithm is usually + # the best choice for large systems at low to moderate precision. + # * The default version selects between *lu* and *precomp* automatically. + # The automatic choice should be reasonable most of the time, but users + # may benefit from trying either *lu* or *precond* in specific applications. + # For example, the *lu* solver often performs better for ill-conditioned + # systems where use of very high precision is unavoidable. + + int acb_mat_inv(acb_mat_t X, const acb_mat_t A, long prec) + # Sets `X = A^{-1}` where `A` is a square matrix, computed by solving + # the system `AX = I`. + # If `A` cannot be inverted numerically (indicating either that + # `A` is singular or that the precision is insufficient), the values in the + # output matrix are left undefined and zero is returned. + # A nonzero return value guarantees that the matrix is invertible + # and that the exact inverse is contained in the output. + + void acb_mat_det_lu(acb_t det, const acb_mat_t A, long prec) + + void acb_mat_det_precond(acb_t det, const acb_mat_t A, long prec) + + void acb_mat_det(acb_t det, const acb_mat_t A, long prec) + # Sets *det* to the determinant of the matrix *A*. + # The *lu* version uses Gaussian elimination with partial pivoting. If at + # some point an invertible pivot element cannot be found, the elimination is + # stopped and the magnitude of the determinant of the remaining submatrix + # is bounded using Hadamard's inequality. + # The *precond* version computes an approximate LU factorization of *A* + # and multiplies by the inverse *L* and *U* martices as preconditioners + # to obtain a matrix close to the identity matrix [Rum2010]_. An enclosure + # for this determinant is computed using Gershgorin circles. This is about + # four times slower than direct Gaussian elimination, but much more + # numerically stable. + # The default version automatically selects between the *lu* and *precond* + # versions and additionally handles small or triangular matrices + # by direct formulas. + + void acb_mat_approx_solve_triu(acb_mat_t X, const acb_mat_t U, const acb_mat_t B, int unit, long prec) + + void acb_mat_approx_solve_tril(acb_mat_t X, const acb_mat_t L, const acb_mat_t B, int unit, long prec) + + int acb_mat_approx_lu(long * P, acb_mat_t LU, const acb_mat_t A, long prec) + + void acb_mat_approx_solve_lu_precomp(acb_mat_t X, const long * perm, const acb_mat_t A, const acb_mat_t B, long prec) + + int acb_mat_approx_solve(acb_mat_t X, const acb_mat_t A, const acb_mat_t B, long prec) + + int acb_mat_approx_inv(acb_mat_t X, const acb_mat_t A, long prec) + # These methods perform approximate solving *without any error control*. + # The radii in the input matrices are ignored, the computations are done + # numerically with floating-point arithmetic (using ordinary + # Gaussian elimination and triangular solving, accelerated through + # the use of block recursive strategies for large matrices), and the + # output matrices are set to the approximate floating-point results with + # zeroed error bounds. + + void _acb_mat_charpoly(acb_ptr poly, const acb_mat_t mat, long prec) + + void acb_mat_charpoly(acb_poly_t poly, const acb_mat_t mat, long prec) + # Sets *poly* to the characteristic polynomial of *mat* which must be + # a square matrix. If the matrix has *n* rows, the underscore method + # requires space for `n + 1` output coefficients. + # Employs a division-free algorithm using `O(n^4)` operations. + + void _acb_mat_companion(acb_mat_t mat, acb_srcptr poly, long prec) + + void acb_mat_companion(acb_mat_t mat, const acb_poly_t poly, long prec) + # Sets the *n* by *n* matrix *mat* to the companion matrix of the polynomial + # *poly* which must have degree *n*. + # The underscore method reads `n + 1` input coefficients. + + void acb_mat_exp_taylor_sum(acb_mat_t S, const acb_mat_t A, long N, long prec) + # Sets *S* to the truncated exponential Taylor series `S = \sum_{k=0}^{N-1} A^k / k!`. + # See :func:`arb_mat_exp_taylor_sum` for implementation notes. + + void acb_mat_exp(acb_mat_t B, const acb_mat_t A, long prec) + # Sets *B* to the exponential of the matrix *A*, defined by the Taylor series + # .. math :: + # \exp(A) = \sum_{k=0}^{\infty} \frac{A^k}{k!}. + # The function is evaluated as `\exp(A/2^r)^{2^r}`, where `r` is chosen + # to give rapid convergence of the Taylor series. + # Error bounds are computed as for :func:`arb_mat_exp`. + + void acb_mat_trace(acb_t trace, const acb_mat_t mat, long prec) + # Sets *trace* to the trace of the matrix, i.e. the sum of entries on the + # main diagonal of *mat*. The matrix is required to be square. + + void _acb_mat_diag_prod(acb_t res, const acb_mat_t mat, long a, long b, long prec) + + void acb_mat_diag_prod(acb_t res, const acb_mat_t mat, long prec) + # Sets *res* to the product of the entries on the main diagonal of *mat*. + # The underscore method computes the product of the entries between + # index *a* inclusive and *b* exclusive (the indices must be in range). + + void acb_mat_get_mid(acb_mat_t B, const acb_mat_t A) + # Sets the entries of *B* to the exact midpoints of the entries of *A*. + + void acb_mat_add_error_mag(acb_mat_t mat, const mag_t err) + # Adds *err* in-place to the radii of the entries of *mat*. + + int acb_mat_approx_eig_qr(acb_ptr E, acb_mat_t L, acb_mat_t R, const acb_mat_t A, const mag_t tol, long maxiter, long prec) + # Computes floating-point approximations of all the *n* eigenvalues + # (and optionally eigenvectors) of the + # given *n* by *n* matrix *A*. The approximations of the + # eigenvalues are written to the vector *E*, in no particular order. + # If *L* is not *NULL*, approximations of the corresponding left + # eigenvectors are written to the rows of *L*. If *R* is not *NULL*, + # approximations of the corresponding + # right eigenvectors are written to the columns of *R*. + # The parameters *tol* and *maxiter* can be used to control the + # target numerical error and the maximum number of iterations + # allowed before giving up. Passing *NULL* and 0 respectively results + # in default values being used. + # Uses the implicitly shifted QR algorithm with reduction + # to Hessenberg form. + # No guarantees are made about the accuracy of the output. A nonzero + # return value indicates that the QR iteration converged numerically, + # but this is only a heuristic termination test and does not imply + # any statement whatsoever about error bounds. + # The output may also be accurate even if this function returns zero. + + void acb_mat_eig_global_enclosure(mag_t eps, const acb_mat_t A, acb_srcptr E, const acb_mat_t R, long prec) + # Given an *n* by *n* matrix *A*, a length-*n* vector *E* + # containing approximations of the eigenvalues of *A*, + # and an *n* by *n* matrix *R* containing approximations of + # the corresponding right eigenvectors, computes a rigorous bound + # `\varepsilon` such that every eigenvalue `\lambda` of *A* satisfies + # `|\lambda - \hat \lambda_k| \le \varepsilon` + # for some `\hat \lambda_k` in *E*. + # In other words, the union of the balls + # `B_k = \{z : |z - \hat \lambda_k| \le \varepsilon\}` is guaranteed to + # be an enclosure of all eigenvalues of *A*. + # Note that there is no guarantee that each ball `B_k` can be + # identified with a single eigenvalue: it is possible that some + # balls contain several eigenvalues while other balls contain + # no eigenvalues. In other words, this method is not powerful enough + # to compute isolating balls for the individual eigenvalues (or even + # for clusters of eigenvalues other than the whole spectrum). + # Nevertheless, in practice the balls `B_k` will represent + # eigenvalues one-to-one with high probability if the + # given approximations are good. + # The output can be used to certify + # that all eigenvalues of *A* lie in some region of the complex + # plane (such as a specific half-plane, strip, disk, or annulus) + # without the need to certify the individual eigenvalues. + # The output is easily converted into lower or upper bounds + # for the absolute values or real or imaginary parts + # of the spectrum, and with high probability these bounds will be tight. + # Using :func:`acb_add_error_mag` and :func:`acb_union`, the output + # can also be converted to a single :type:`acb_t` enclosing + # the whole spectrum of *A* in a rectangle, but note that to + # test whether a condition holds for all eigenvalues of *A*, it + # is typically better to iterate over the individual balls `B_k`. + # This function implements the fast algorithm in Theorem 1 in + # [Miy2010]_ which extends the Bauer-Fike theorem. Approximations + # *E* and *R* can, for instance, be computed using + # :func:`acb_mat_approx_eig_qr`. + # No assumptions are made about the structure of *A* or the + # quality of the given approximations. + + void acb_mat_eig_enclosure_rump(acb_t lambda, acb_mat_t J, acb_mat_t R, const acb_mat_t A, const acb_t lambda_approx, const acb_mat_t R_approx, long prec) + # Given an *n* by *n* matrix *A* and an approximate + # eigenvalue-eigenvector pair *lambda_approx* and *R_approx* (where + # *R_approx* is an *n* by 1 matrix), computes an enclosure + # *lambda* guaranteed to contain at least one of the eigenvalues of *A*, + # along with an enclosure *R* for a corresponding right eigenvector. + # More generally, this function can handle clustered (or repeated) + # eigenvalues. If *R_approx* is an *n* by *k* + # matrix containing approximate eigenvectors for a presumed cluster + # of *k* eigenvalues near *lambda_approx*, + # this function computes an enclosure *lambda* + # guaranteed to contain at + # least *k* eigenvalues of *A* along with a matrix *R* guaranteed to + # contain a basis for the *k*-dimensional invariant subspace + # associated with these eigenvalues. + # Note that for multiple eigenvalues, determining the individual eigenvectors is + # an ill-posed problem; describing an enclosure of the invariant subspace + # is the best we can hope for. + # For `k = 1`, it is guaranteed that `AR - R \lambda` contains + # the zero matrix. For `k > 2`, this cannot generally be guaranteed + # (in particular, *A* might not diagonalizable). + # In this case, we can still compute an approximately diagonal + # *k* by *k* interval matrix `J \approx \lambda I` such that `AR - RJ` + # is guaranteed to contain the zero matrix. + # This matrix has the property that the Jordan canonical form of + # (any exact matrix contained in) *A* has a *k* by *k* submatrix + # equal to the Jordan canonical form of + # (some exact matrix contained in) *J*. + # The output *J* is optional (the user can pass *NULL* to omit it). + # The algorithm follows section 13.4 in [Rum2010]_, corresponding + # to the ``verifyeig()`` routine in INTLAB. + # The initial approximations can, for instance, be computed using + # :func:`acb_mat_approx_eig_qr`. + # No assumptions are made about the structure of *A* or the + # quality of the given approximations. + + int acb_mat_eig_simple_rump(acb_ptr E, acb_mat_t L, acb_mat_t R, const acb_mat_t A, acb_srcptr E_approx, const acb_mat_t R_approx, long prec) + + int acb_mat_eig_simple_vdhoeven_mourrain(acb_ptr E, acb_mat_t L, acb_mat_t R, const acb_mat_t A, acb_srcptr E_approx, const acb_mat_t R_approx, long prec) + + int acb_mat_eig_simple(acb_ptr E, acb_mat_t L, acb_mat_t R, const acb_mat_t A, acb_srcptr E_approx, const acb_mat_t R_approx, long prec) + # Computes all the eigenvalues (and optionally corresponding + # eigenvectors) of the given *n* by *n* matrix *A*. + # Attempts to prove that *A* has *n* simple (isolated) + # eigenvalues, returning 1 if successful + # and 0 otherwise. On success, isolating complex intervals for the + # eigenvalues are written to the vector *E*, in no particular order. + # If *L* is not *NULL*, enclosures of the corresponding left + # eigenvectors are written to the rows of *L*. If *R* is not *NULL*, + # enclosures of the corresponding + # right eigenvectors are written to the columns of *R*. + # The left eigenvectors are normalized so that `L = R^{-1}`. + # This produces a diagonalization `LAR = D` where *D* is the + # diagonal matrix with the entries in *E* on the diagonal. + # The user supplies approximations *E_approx* and *R_approx* + # of the eigenvalues and the right eigenvectors. + # The initial approximations can, for instance, be computed using + # :func:`acb_mat_approx_eig_qr`. + # No assumptions are made about the structure of *A* or the + # quality of the given approximations. + # Two algorithms are implemented: + # * The *rump* version calls :func:`acb_mat_eig_enclosure_rump` repeatedly + # to certify eigenvalue-eigenvector pairs one by one. The iteration is + # stopped to return non-success if a new eigenvalue overlaps with + # previously computed one. Finally, *L* is computed by a matrix inversion. + # This has complexity `O(n^4)`. + # * The *vdhoeven_mourrain* version uses the algorithm in [HM2017]_ to + # certify all eigenvalues and eigenvectors in one step. This has + # complexity `O(n^3)`. + # The default version currently uses *vdhoeven_mourrain*. + # By design, these functions terminate instead of attempting to + # compute eigenvalue clusters if some eigenvalues cannot be isolated. + # To compute all eigenvalues of a matrix allowing for overlap, + # :func:`acb_mat_eig_multiple_rump` may be used as a fallback, + # or :func:`acb_mat_eig_multiple` may be used in the first place. + + int acb_mat_eig_multiple_rump(acb_ptr E, const acb_mat_t A, acb_srcptr E_approx, const acb_mat_t R_approx, long prec) + + int acb_mat_eig_multiple(acb_ptr E, const acb_mat_t A, acb_srcptr E_approx, const acb_mat_t R_approx, long prec) + # Computes all the eigenvalues of the given *n* by *n* matrix *A*. + # On success, the output vector *E* contains *n* complex intervals, + # each representing one eigenvalue of *A* with the correct + # multiplicities in case of overlap. + # The output intervals are either disjoint or identical, and + # identical intervals are guaranteed to be grouped consecutively. + # Each complete run of *k* identical intervals thus represents a cluster of + # exactly *k* eigenvalues which could not be separated from each + # other at the current precision, but which could be isolated + # from the other `n - k` eigenvalues of the matrix. + # The user supplies approximations *E_approx* and *R_approx* + # of the eigenvalues and the right eigenvectors. + # The initial approximations can, for instance, be computed using + # :func:`acb_mat_approx_eig_qr`. + # No assumptions are made about the structure of *A* or the + # quality of the given approximations. + # The *rump* algorithm groups approximate eigenvalues that are close + # and calls :func:`acb_mat_eig_enclosure_rump` repeatedly to validate + # each cluster. The complexity is `O(m n^3)` for *m* clusters. + # The default version, as currently implemented, first attempts to + # call :func:`acb_mat_eig_simple_vdhoeven_mourrain` hoping that the + # eigenvalues are actually simple. It then uses the *rump* algorithm as + # a fallback. diff --git a/src/sage/libs/flint/acb_modular.pxd b/src/sage/libs/flint/acb_modular.pxd new file mode 100644 index 00000000000..0164bb3df8d --- /dev/null +++ b/src/sage/libs/flint/acb_modular.pxd @@ -0,0 +1,379 @@ +# distutils: libraries = flint +# distutils: depends = flint/acb_modular.h + +################################################################################ +# This file is auto-generated. Do not modify by hand +################################################################################ + +from libc.stdio cimport FILE +from sage.libs.gmp.types cimport * +from sage.libs.mpfr.types cimport * +from sage.libs.flint.types cimport * + +cdef extern from "flint_wrap.h": + + void psl2z_init(psl2z_t g) + # Initializes *g* and set it to the identity element. + + void psl2z_clear(psl2z_t g) + # Clears *g*. + + void psl2z_swap(psl2z_t f, psl2z_t g) + # Swaps *f* and *g* efficiently. + + void psl2z_set(psl2z_t f, const psl2z_t g) + # Sets *f* to a copy of *g*. + + void psl2z_one(psl2z_t g) + # Sets *g* to the identity element. + + int psl2z_is_one(const psl2z_t g) + # Returns nonzero iff *g* is the identity element. + + void psl2z_print(const psl2z_t g) + # Prints *g* to standard output. + + void psl2z_fprint(FILE * file, const psl2z_t g) + # Prints *g* to the stream *file*. + + int psl2z_equal(const psl2z_t f, const psl2z_t g) + # Returns nonzero iff *f* and *g* are equal. + + void psl2z_mul(psl2z_t h, const psl2z_t f, const psl2z_t g) + # Sets *h* to the product of *f* and *g*, namely the matrix product + # with the signs canonicalized. + + void psl2z_inv(psl2z_t h, const psl2z_t g) + # Sets *h* to the inverse of *g*. + + int psl2z_is_correct(const psl2z_t g) + # Returns nonzero iff *g* contains correct data, i.e. + # satisfying `ad-bc = 1`, `c \ge 0`, and `d > 0` if `c = 0`. + + void psl2z_randtest(psl2z_t g, flint_rand_t state, long bits) + # Sets *g* to a random element of `\text{PSL}(2, \mathbb{Z})` + # with entries of bit length at most *bits* + # (or 1, if *bits* is not positive). We first generate *a* and *d*, compute + # their Bezout coefficients, divide by the GCD, and then correct the signs. + + void acb_modular_transform(acb_t w, const psl2z_t g, const acb_t z, long prec) + # Applies the modular transformation *g* to the complex number *z*, + # evaluating + # .. math :: + # w = g z = \frac{az+b}{cz+d}. + + void acb_modular_fundamental_domain_approx_d(psl2z_t g, double x, double y, double one_minus_eps) + + void acb_modular_fundamental_domain_approx_arf(psl2z_t g, const arf_t x, const arf_t y, const arf_t one_minus_eps, long prec) + # Attempts to determine a modular transformation *g* that maps the + # complex number `x+yi` to the fundamental domain or just + # slightly outside the fundamental domain, where the target tolerance + # (not a strict bound) is specified by *one_minus_eps*. + # The inputs are assumed to be finite numbers, with *y* positive. + # Uses floating-point iteration, repeatedly applying either + # the transformation `z \gets z + b` or `z \gets -1/z`. The iteration is + # terminated if `|x| \le 1/2` and `x^2 + y^2 \ge 1 - \varepsilon` where + # `1 - \varepsilon` is passed as *one_minus_eps*. It is also terminated + # if too many steps have been taken without convergence, or if the numbers + # end up too large or too small for the working precision. + # The algorithm can fail to produce a satisfactory transformation. + # The output *g* is always set to *some* correct modular transformation, + # but it is up to the user to verify a posteriori that *g* maps `x+yi` + # close enough to the fundamental domain. + + void acb_modular_fundamental_domain_approx(acb_t w, psl2z_t g, const acb_t z, const arf_t one_minus_eps, long prec) + # Attempts to determine a modular transformation *g* that maps the + # complex number `z` to the fundamental domain or just + # slightly outside the fundamental domain, where the target tolerance + # (not a strict bound) is specified by *one_minus_eps*. It also computes + # the transformed value `w = gz`. + # This function first tries to use + # :func:`acb_modular_fundamental_domain_approx_d` and checks if the + # result is acceptable. If this fails, it calls + # :func:`acb_modular_fundamental_domain_approx_arf` with higher precision. + # Finally, `w = gz` is evaluated by a single application of *g*. + # The algorithm can fail to produce a satisfactory transformation. + # The output *g* is always set to *some* correct modular transformation, + # but it is up to the user to verify a posteriori that `w` is close enough + # to the fundamental domain. + + int acb_modular_is_in_fundamental_domain(const acb_t z, const arf_t tol, long prec) + # Returns nonzero if it is certainly true that `|z| \ge 1 - \varepsilon` and + # `|\operatorname{Re}(z)| \le 1/2 + \varepsilon` where `\varepsilon` is + # specified by *tol*. Returns zero if this is false or cannot be determined. + + void acb_modular_fill_addseq(long * tab, long len) + # Builds a near-optimal addition sequence for a sequence of integers + # which is assumed to be reasonably dense. + # As input, the caller should set each entry in *tab* to `-1` if + # that index is to be part of the addition sequence, and to 0 otherwise. + # On output, entry *i* in *tab* will either be zero (if the number is + # not part of the sequence), or a value *j* such that both + # *j* and `i - j` are also marked. + # The first two entries in *tab* are ignored (the number 1 is always + # assumed to be part of the sequence). + + void acb_modular_theta_transform(int * R, int * S, int * C, const psl2z_t g) + # We wish to write a theta function with quasiperiod `\tau` in terms + # of a theta function with quasiperiod `\tau' = g \tau`, given + # some `g = (a, b; c, d) \in \text{PSL}(2, \mathbb{Z})`. + # For `i = 0, 1, 2, 3`, this function computes integers `R_i` and `S_i` + # (*R* and *S* should be arrays of length 4) + # and `C \in \{0, 1\}` such that + # .. math :: + # \theta_{1+i}(z,\tau) = \exp(\pi i R_i / 4) \cdot A \cdot B \cdot \theta_{1+S_i}(z',\tau') + # where `z' = z, A = B = 1` if `C = 0`, and + # .. math :: + # z' = \frac{-z}{c \tau + d}, \quad + # A = \sqrt{\frac{i}{c \tau + d}}, \quad + # B = \exp\left(-\pi i c \frac{z^2}{c \tau + d}\right) + # if `C = 1`. Note that `A` is well-defined with the principal branch + # of the square root since `A^2 = i/(c \tau + d)` lies in the right half-plane. + # Firstly, if `c = 0`, we have + # `\theta_i(z, \tau) = \exp(-\pi i b / 4) \theta_i(z, \tau+b)` + # for `i = 1, 2`, whereas + # `\theta_3` and `\theta_4` remain unchanged when `b` is even + # and swap places with each other when `b` is odd. + # In this case we set `C = 0`. + # For an arbitrary `g` with `c > 0`, we set `C = 1`. The general + # transformations are given by Rademacher [Rad1973]_. + # We need the function `\theta_{m,n}(z,\tau)` defined for `m, n \in \mathbb{Z}` by + # (beware of the typos in [Rad1973]_) + # .. math :: + # \theta_{0,0}(z,\tau) = \theta_3(z,\tau), \quad + # \theta_{0,1}(z,\tau) = \theta_4(z,\tau) + # .. math :: + # \theta_{1,0}(z,\tau) = \theta_2(z,\tau), \quad + # \theta_{1,1}(z,\tau) = i \theta_1(z,\tau) + # .. math :: + # \theta_{m+2,n}(z,\tau) = (-1)^n \theta_{m,n}(z,\tau) + # .. math :: + # \theta_{m,n+2}(z,\tau) = \theta_{m,n}(z,\tau). + # Then we may write + # .. math :: + # \theta_1(z,\tau) &= \varepsilon_1 A B \theta_1(z', \tau') + # \theta_2(z,\tau) &= \varepsilon_2 A B \theta_{1-c,1+a}(z', \tau') + # \theta_3(z,\tau) &= \varepsilon_3 A B \theta_{1+d-c,1-b+a}(z', \tau') + # \theta_4(z,\tau) &= \varepsilon_4 A B \theta_{1+d,1-b}(z', \tau') + # where `\varepsilon_i` is an 8th root of unity. + # Specifically, if we denote the 24th root of unity + # in the transformation formula of the Dedekind eta + # function by `\varepsilon(a,b,c,d) = \exp(\pi i R(a,b,c,d) / 12)` + # (see :func:`acb_modular_epsilon_arg`), then: + # .. math :: + # \varepsilon_1(a,b,c,d) &= \exp(\pi i [R(-d,b,c,-a) + 1] / 4) + # \varepsilon_2(a,b,c,d) &= \exp(\pi i [-R(a,b,c,d) + (5+(2-c)a)] / 4) + # \varepsilon_3(a,b,c,d) &= \exp(\pi i [-R(a,b,c,d) + (4+(c-d-2)(b-a))] / 4) + # \varepsilon_4(a,b,c,d) &= \exp(\pi i [-R(a,b,c,d) + (3-(2+d)b)] / 4) + # These formulas are easily derived from the formulas in [Rad1973]_ + # (Rademacher has the transformed/untransformed variables exchanged, + # and his "`\varepsilon`" differs from ours by a constant + # offset in the phase). + + void acb_modular_addseq_theta(long * exponents, long * aindex, long * bindex, long num) + # Constructs an addition sequence for the first *num* squares and triangular + # numbers interleaved (excluding zero), i.e. 1, 2, 4, 6, 9, 12, 16, 20, 25, 30 etc. + + void acb_modular_theta_sum(acb_ptr theta1, acb_ptr theta2, acb_ptr theta3, acb_ptr theta4, const acb_t w, int w_is_unit, const acb_t q, long len, long prec) + # Simultaneously computes the first *len* coefficients of each of the + # formal power series + # .. math :: + # \theta_1(z+x,\tau) / q_{1/4} \in \mathbb{C}[[x]] + # \theta_2(z+x,\tau) / q_{1/4} \in \mathbb{C}[[x]] + # \theta_3(z+x,\tau) \in \mathbb{C}[[x]] + # \theta_4(z+x,\tau) \in \mathbb{C}[[x]] + # given `w = \exp(\pi i z)` and `q = \exp(\pi i \tau)`, by summing + # a finite truncation of the respective theta function series. + # In particular, with *len* equal to 1, computes the respective + # value of the theta function at the point *z*. + # We require *len* to be positive. + # If *w_is_unit* is nonzero, *w* is assumed to lie on the unit circle, + # i.e. *z* is assumed to be real. + # Note that the factor `q_{1/4}` is removed from `\theta_1` and `\theta_2`. + # To get the true theta function values, the user has to multiply + # this factor back. This convention avoids unnecessary computations, + # since the user can compute `q_{1/4} = \exp(\pi i \tau / 4)` followed by + # `q = (q_{1/4})^4`, and in many cases when computing products or quotients + # of theta functions, the factor `q_{1/4}` can be eliminated entirely. + # This function is intended for `|q| \ll 1`. It can be called with any + # `q`, but will return useless intervals if convergence is not rapid. + # For general evaluation of theta functions, the user should only call + # this function after applying a suitable modular transformation. + # We consider the sums together, alternatingly updating `(\theta_1, \theta_2)` + # or `(\theta_3, \theta_4)`. For `k = 0, 1, 2, \ldots`, the powers of `q` + # are `\lfloor (k+2)^2 / 4 \rfloor = 1, 2, 4, 6, 9` etc. and the powers of `w` are + # `\pm (k+2) = \pm 2, \pm 3, \pm 4, \ldots` etc. The scheme + # is illustrated by the following table: + # .. math :: + # \begin{array}{llll} + # & \theta_1, \theta_2 & q^0 & (w^1 \pm w^{-1}) \\ + # k = 0 & \theta_3, \theta_4 & q^1 & (w^2 \pm w^{-2}) \\ + # k = 1 & \theta_1, \theta_2 & q^2 & (w^3 \pm w^{-3}) \\ + # k = 2 & \theta_3, \theta_4 & q^4 & (w^4 \pm w^{-4}) \\ + # k = 3 & \theta_1, \theta_2 & q^6 & (w^5 \pm w^{-5}) \\ + # k = 4 & \theta_3, \theta_4 & q^9 & (w^6 \pm w^{-6}) \\ + # k = 5 & \theta_1, \theta_2 & q^{12} & (w^7 \pm w^{-7}) \\ + # \end{array} + # For some integer `N \ge 1`, the summation is stopped just before term + # `k = N`. Let `Q = |q|`, `W = \max(|w|,|w^{-1}|)`, + # `E = \lfloor (N+2)^2 / 4 \rfloor` and + # `F = \lfloor (N+1)/2 \rfloor + 1`. The error of the + # zeroth derivative can be bounded as + # .. math :: + # 2 Q^E W^{N+2} \left[ 1 + Q^F W + Q^{2F} W^2 + \ldots \right] + # = \frac{2 Q^E W^{N+2}}{1 - Q^F W} + # provided that the denominator is positive (otherwise we set + # the error bound to infinity). + # When *len* is greater than 1, consider the derivative of order *r*. + # The term of index *k* and order *r* picks up a factor of magnitude + # `(k+2)^r` from differentiation of `w^{k+2}` (it also picks up a factor + # `\pi^r`, but we omit this until we rescale the coefficients + # at the end of the computation). Thus we have the error bound + # .. math :: + # 2 Q^E W^{N+2} (N+2)^r \left[ 1 + Q^F W \frac{(N+3)^r}{(N+2)^r} + Q^{2F} W^2 \frac{(N+4)^r}{(N+2)^r} + \ldots \right] + # which by the inequality `(1 + m/(N+2))^r \le \exp(mr/(N+2))` + # can be bounded as + # .. math :: + # \frac{2 Q^E W^{N+2} (N+2)^r}{1 - Q^F W \exp(r/(N+2))}, + # again valid when the denominator is positive. + # To actually evaluate the series, we write the even + # cosine terms as `w^{2n} + w^{-2n}`, the odd cosine terms as + # `w (w^{2n} + w^{-2n-2})`, and the sine terms as `w (w^{2n} - w^{-2n-2})`. + # This way we only need even powers of `w` and `w^{-1}`. + # The implementation is not yet optimized for real `z`, in which case + # further work can be saved. + # This function does not permit aliasing between input and output + # arguments. + + void acb_modular_theta_const_sum_basecase(acb_t theta2, acb_t theta3, acb_t theta4, const acb_t q, long N, long prec) + + void acb_modular_theta_const_sum_rs(acb_t theta2, acb_t theta3, acb_t theta4, const acb_t q, long N, long prec) + # Computes the truncated theta constant sums + # `\theta_2 = \sum_{k(k+1) < N} q^{k(k+1)}`, + # `\theta_3 = \sum_{k^2 < N} q^{k^2}`, + # `\theta_4 = \sum_{k^2 < N} (-1)^k q^{k^2}`. + # The *basecase* version uses a short addition sequence. + # The *rs* version uses rectangular splitting. + # The algorithms are described in [EHJ2016]_. + + void acb_modular_theta_const_sum(acb_t theta2, acb_t theta3, acb_t theta4, const acb_t q, long prec) + # Computes the respective theta constants by direct summation + # (without applying modular transformations). This function + # selects an appropriate *N*, calls either + # :func:`acb_modular_theta_const_sum_basecase` or + # :func:`acb_modular_theta_const_sum_rs` or depending on *N*, + # and adds a bound for the truncation error. + + void acb_modular_theta_notransform(acb_t theta1, acb_t theta2, acb_t theta3, acb_t theta4, const acb_t z, const acb_t tau, long prec) + # Evaluates the Jacobi theta functions `\theta_i(z,\tau)`, `i = 1, 2, 3, 4` + # simultaneously. This function does not move `\tau` to the fundamental domain. + # This is generally worse than :func:`acb_modular_theta`, but can + # be slightly better for moderate input. + + void acb_modular_theta(acb_t theta1, acb_t theta2, acb_t theta3, acb_t theta4, const acb_t z, const acb_t tau, long prec) + # Evaluates the Jacobi theta functions `\theta_i(z,\tau)`, `i = 1, 2, 3, 4` + # simultaneously. This function moves `\tau` to the fundamental domain + # and then also reduces `z` modulo `\tau` + # before calling :func:`acb_modular_theta_sum`. + + void acb_modular_theta_jet_notransform(acb_ptr theta1, acb_ptr theta2, acb_ptr theta3, acb_ptr theta4, const acb_t z, const acb_t tau, long len, long prec) + + void acb_modular_theta_jet(acb_ptr theta1, acb_ptr theta2, acb_ptr theta3, acb_ptr theta4, const acb_t z, const acb_t tau, long len, long prec) + # Evaluates the Jacobi theta functions along with their derivatives + # with respect to *z*, writing the first *len* coefficients in the power + # series `\theta_i(z+x,\tau) \in \mathbb{C}[[x]]` to + # each respective output variable. The *notransform* version does not + # move `\tau` to the fundamental domain or reduce `z` during the computation. + + void _acb_modular_theta_series(acb_ptr theta1, acb_ptr theta2, acb_ptr theta3, acb_ptr theta4, acb_srcptr z, long zlen, const acb_t tau, long len, long prec) + + void acb_modular_theta_series(acb_poly_t theta1, acb_poly_t theta2, acb_poly_t theta3, acb_poly_t theta4, const acb_poly_t z, const acb_t tau, long len, long prec) + # Evaluates the respective Jacobi theta functions of the power series *z*, + # truncated to length *len*. Either of the output variables can be *NULL*. + + void acb_modular_addseq_eta(long * exponents, long * aindex, long * bindex, long num) + # Constructs an addition sequence for the first *num* generalized pentagonal + # numbers (excluding zero), i.e. 1, 2, 5, 7, 12, 15, 22, 26, 35, 40 etc. + + void acb_modular_eta_sum(acb_t eta, const acb_t q, long prec) + # Evaluates the Dedekind eta function + # without the leading 24th root, i.e. + # .. math :: \exp(-\pi i \tau/12) \eta(\tau) = \sum_{n=-\infty}^{\infty} (-1)^n q^{(3n^2-n)/2} + # given `q = \exp(2 \pi i \tau)`, by summing the defining series. + # This function is intended for `|q| \ll 1`. It can be called with any + # `q`, but will return useless intervals if convergence is not rapid. + # For general evaluation of the eta function, the user should only call + # this function after applying a suitable modular transformation. + # The series is evaluated using either a short addition sequence or + # rectangular splitting, depending on the number of terms. + # The algorithms are described in [EHJ2016]_. + + int acb_modular_epsilon_arg(const psl2z_t g) + # Given `g = (a, b; c, d)`, computes an integer `R` such that + # `\varepsilon(a,b,c,d) = \exp(\pi i R / 12)` is the 24th root of unity in + # the transformation formula for the Dedekind eta function, + # .. math :: + # \eta\left(\frac{a\tau+b}{c\tau+d}\right) = \varepsilon (a,b,c,d) + # \sqrt{c\tau+d} \eta(\tau). + + void acb_modular_eta(acb_t r, const acb_t tau, long prec) + # Computes the Dedekind eta function `\eta(\tau)` given `\tau` in the upper + # half-plane. This function applies the functional equation to move + # `\tau` to the fundamental domain before calling + # :func:`acb_modular_eta_sum`. + + void acb_modular_j(acb_t r, const acb_t tau, long prec) + # Computes Klein's j-invariant `j(\tau)` given `\tau` in the upper + # half-plane. The function is normalized so that `j(i) = 1728`. + # We first move `\tau` to the fundamental domain, which does not change + # the value of the function. Then we use the formula + # `j(\tau) = 32 (\theta_2^8+\theta_3^8+\theta_4^8)^3 / (\theta_2 \theta_3 \theta_4)^8` where + # `\theta_i = \theta_i(0,\tau)`. + + void acb_modular_lambda(acb_t r, const acb_t tau, long prec) + # Computes the lambda function + # `\lambda(\tau) = \theta_2^4(0,\tau) / \theta_3^4(0,\tau)`, which + # is invariant under modular transformations `(a, b; c, d)` + # where `a, d` are odd and `b, c` are even. + + void acb_modular_delta(acb_t r, const acb_t tau, long prec) + # Computes the modular discriminant `\Delta(\tau) = \eta(\tau)^{24}`, + # which transforms as + # .. math :: + # \Delta\left(\frac{a\tau+b}{c\tau+d}\right) = (c\tau+d)^{12} \Delta(\tau). + # The modular discriminant is sometimes defined with an extra factor + # `(2\pi)^{12}`, which we omit in this implementation. + + void acb_modular_eisenstein(acb_ptr r, const acb_t tau, long len, long prec) + # Computes simultaneously the first *len* entries in the sequence + # of Eisenstein series `G_4(\tau), G_6(\tau), G_8(\tau), \ldots`, + # defined by + # .. math :: + # G_{2k}(\tau) = \sum_{m^2 + n^2 \ne 0} \frac{1}{(m+n\tau )^{2k}} + # and satisfying + # .. math :: + # G_{2k} \left(\frac{a\tau+b}{c\tau+d}\right) = (c\tau+d)^{2k} G_{2k}(\tau). + # We first evaluate `G_4(\tau)` and `G_6(\tau)` on the fundamental + # domain using theta functions, and then compute the Eisenstein series + # of higher index using a recurrence relation. + + void acb_modular_elliptic_k(acb_t w, const acb_t m, long prec) + + void acb_modular_elliptic_k_cpx(acb_ptr w, const acb_t m, long len, long prec) + + void acb_modular_elliptic_e(acb_t w, const acb_t m, long prec) + + void acb_modular_elliptic_p(acb_t wp, const acb_t z, const acb_t tau, long prec) + + void acb_modular_elliptic_p_zpx(acb_ptr wp, const acb_t z, const acb_t tau, long len, long prec) + + void acb_modular_hilbert_class_poly(fmpz_poly_t res, long D) + # Sets *res* to the Hilbert class polynomial of discriminant *D*, + # defined as + # .. math :: + # H_D(x) = \prod_{(a,b,c)} \left(x - j\left(\frac{-b+\sqrt{D}}{2a}\right)\right) + # where `(a,b,c)` ranges over the primitive reduced positive + # definite binary quadratic forms of discriminant `b^2 - 4ac = D`. + # The Hilbert class polynomial is only defined if `D < 0` and *D* + # is congruent to 0 or 1 mod 4. If some other value of *D* is passed as + # input, *res* is set to the zero polynomial. diff --git a/src/sage/libs/flint/acb_poly.pxd b/src/sage/libs/flint/acb_poly.pxd new file mode 100644 index 00000000000..f097b6df820 --- /dev/null +++ b/src/sage/libs/flint/acb_poly.pxd @@ -0,0 +1,902 @@ +# distutils: libraries = flint +# distutils: depends = flint/acb_poly.h + +################################################################################ +# This file is auto-generated. Do not modify by hand +################################################################################ + +from libc.stdio cimport FILE +from sage.libs.gmp.types cimport * +from sage.libs.mpfr.types cimport * +from sage.libs.flint.types cimport * + +cdef extern from "flint_wrap.h": + + void acb_poly_init(acb_poly_t poly) + # Initializes the polynomial for use, setting it to the zero polynomial. + + void acb_poly_clear(acb_poly_t poly) + # Clears the polynomial, deallocating all coefficients and the + # coefficient array. + + void acb_poly_fit_length(acb_poly_t poly, long len) + # Makes sure that the coefficient array of the polynomial contains at + # least *len* initialized coefficients. + + void _acb_poly_set_length(acb_poly_t poly, long len) + # Directly changes the length of the polynomial, without allocating or + # deallocating coefficients. The value should not exceed the allocation length. + + void _acb_poly_normalise(acb_poly_t poly) + # Strips any trailing coefficients which are identical to zero. + + void acb_poly_swap(acb_poly_t poly1, acb_poly_t poly2) + # Swaps *poly1* and *poly2* efficiently. + + long acb_poly_allocated_bytes(const acb_poly_t x) + # Returns the total number of bytes heap-allocated internally by this object. + # The count excludes the size of the structure itself. Add + # ``sizeof(acb_poly_struct)`` to get the size of the object as a whole. + + long acb_poly_length(const acb_poly_t poly) + # Returns the length of *poly*, i.e. zero if *poly* is + # identically zero, and otherwise one more than the index + # of the highest term that is not identically zero. + + long acb_poly_degree(const acb_poly_t poly) + # Returns the degree of *poly*, defined as one less than its length. + # Note that if one or several leading coefficients are balls + # containing zero, this value can be larger than the true + # degree of the exact polynomial represented by *poly*, + # so the return value of this function is effectively + # an upper bound. + + int acb_poly_is_zero(const acb_poly_t poly) + + int acb_poly_is_one(const acb_poly_t poly) + + int acb_poly_is_x(const acb_poly_t poly) + # Returns 1 if *poly* is exactly the polynomial 0, 1 or *x* + # respectively. Returns 0 otherwise. + + void acb_poly_zero(acb_poly_t poly) + # Sets *poly* to the zero polynomial. + + void acb_poly_one(acb_poly_t poly) + # Sets *poly* to the constant polynomial 1. + + void acb_poly_set(acb_poly_t dest, const acb_poly_t src) + # Sets *dest* to a copy of *src*. + + void acb_poly_set_round(acb_poly_t dest, const acb_poly_t src, long prec) + # Sets *dest* to a copy of *src*, rounded to *prec* bits. + + void acb_poly_set_trunc(acb_poly_t dest, const acb_poly_t src, long n) + + void acb_poly_set_trunc_round(acb_poly_t dest, const acb_poly_t src, long n, long prec) + # Sets *dest* to a copy of *src*, truncated to length *n* and rounded to *prec* bits. + + void acb_poly_set_coeff_si(acb_poly_t poly, long n, long c) + + void acb_poly_set_coeff_acb(acb_poly_t poly, long n, const acb_t c) + # Sets the coefficient with index *n* in *poly* to the value *c*. + # We require that *n* is nonnegative. + + void acb_poly_get_coeff_acb(acb_t v, const acb_poly_t poly, long n) + # Sets *v* to the value of the coefficient with index *n* in *poly*. + # We require that *n* is nonnegative. + + void _acb_poly_shift_right(acb_ptr res, acb_srcptr poly, long len, long n) + + void acb_poly_shift_right(acb_poly_t res, const acb_poly_t poly, long n) + # Sets *res* to *poly* divided by `x^n`, throwing away the lower coefficients. + # We require that *n* is nonnegative. + + void _acb_poly_shift_left(acb_ptr res, acb_srcptr poly, long len, long n) + + void acb_poly_shift_left(acb_poly_t res, const acb_poly_t poly, long n) + # Sets *res* to *poly* multiplied by `x^n`. + # We require that *n* is nonnegative. + + void acb_poly_truncate(acb_poly_t poly, long n) + # Truncates *poly* to have length at most *n*, i.e. degree + # strictly smaller than *n*. We require that *n* is nonnegative. + + long acb_poly_valuation(const acb_poly_t poly) + # Returns the degree of the lowest term that is not exactly zero in *poly*. + # Returns -1 if *poly* is the zero polynomial. + + void acb_poly_printd(const acb_poly_t poly, long digits) + # Prints the polynomial as an array of coefficients, printing each + # coefficient using *acb_printd*. + + void acb_poly_fprintd(FILE * file, const acb_poly_t poly, long digits) + # Prints the polynomial as an array of coefficients to the stream *file*, + # printing each coefficient using *acb_fprintd*. + + void acb_poly_randtest(acb_poly_t poly, flint_rand_t state, long len, long prec, long mag_bits) + # Creates a random polynomial with length at most *len*. + + int acb_poly_equal(const acb_poly_t A, const acb_poly_t B) + # Returns nonzero iff *A* and *B* are identical as interval polynomials. + + int acb_poly_contains(const acb_poly_t poly1, const acb_poly_t poly2) + + int acb_poly_contains_fmpz_poly(const acb_poly_t poly1, const fmpz_poly_t poly2) + + int acb_poly_contains_fmpq_poly(const acb_poly_t poly1, const fmpq_poly_t poly2) + # Returns nonzero iff *poly2* is contained in *poly1*. + + int _acb_poly_overlaps(acb_srcptr poly1, long len1, acb_srcptr poly2, long len2) + + int acb_poly_overlaps(const acb_poly_t poly1, const acb_poly_t poly2) + # Returns nonzero iff *poly1* overlaps with *poly2*. The underscore + # function requires that *len1* ist at least as large as *len2*. + + int acb_poly_get_unique_fmpz_poly(fmpz_poly_t z, const acb_poly_t x) + # If *x* contains a unique integer polynomial, sets *z* to that value and returns + # nonzero. Otherwise (if *x* represents no integers or more than one integer), + # returns zero, possibly partially modifying *z*. + + int acb_poly_is_real(const acb_poly_t poly) + # Returns nonzero iff all coefficients in *poly* have zero imaginary part. + + void acb_poly_set_fmpz_poly(acb_poly_t poly, const fmpz_poly_t re, long prec) + + void acb_poly_set2_fmpz_poly(acb_poly_t poly, const fmpz_poly_t re, const fmpz_poly_t im, long prec) + + void acb_poly_set_arb_poly(acb_poly_t poly, const arb_poly_t re) + + void acb_poly_set2_arb_poly(acb_poly_t poly, const arb_poly_t re, const arb_poly_t im) + + void acb_poly_set_fmpq_poly(acb_poly_t poly, const fmpq_poly_t re, long prec) + + void acb_poly_set2_fmpq_poly(acb_poly_t poly, const fmpq_poly_t re, const fmpq_poly_t im, long prec) + # Sets *poly* to the given real part *re* plus the imaginary part *im*, + # both rounded to *prec* bits. + + void acb_poly_set_acb(acb_poly_t poly, const acb_t src) + + void acb_poly_set_si(acb_poly_t poly, long src) + # Sets *poly* to *src*. + + void _acb_poly_majorant(arb_ptr res, acb_srcptr poly, long len, long prec) + + void acb_poly_majorant(arb_poly_t res, const acb_poly_t poly, long prec) + # Sets *res* to an exact real polynomial whose coefficients are + # upper bounds for the absolute values of the coefficients in *poly*, + # rounded to *prec* bits. + + void _acb_poly_add(acb_ptr C, acb_srcptr A, long lenA, acb_srcptr B, long lenB, long prec) + # Sets *{C, max(lenA, lenB)}* to the sum of *{A, lenA}* and *{B, lenB}*. + # Allows aliasing of the input and output operands. + + void acb_poly_add(acb_poly_t C, const acb_poly_t A, const acb_poly_t B, long prec) + + void acb_poly_add_si(acb_poly_t C, const acb_poly_t A, long B, long prec) + # Sets *C* to the sum of *A* and *B*. + + void _acb_poly_sub(acb_ptr C, acb_srcptr A, long lenA, acb_srcptr B, long lenB, long prec) + # Sets *{C, max(lenA, lenB)}* to the difference of *{A, lenA}* and *{B, lenB}*. + # Allows aliasing of the input and output operands. + + void acb_poly_sub(acb_poly_t C, const acb_poly_t A, const acb_poly_t B, long prec) + # Sets *C* to the difference of *A* and *B*. + + void acb_poly_add_series(acb_poly_t C, const acb_poly_t A, const acb_poly_t B, long len, long prec) + # Sets *C* to the sum of *A* and *B*, truncated to length *len*. + + void acb_poly_sub_series(acb_poly_t C, const acb_poly_t A, const acb_poly_t B, long len, long prec) + # Sets *C* to the difference of *A* and *B*, truncated to length *len*. + + void acb_poly_neg(acb_poly_t C, const acb_poly_t A) + # Sets *C* to the negation of *A*. + + void acb_poly_scalar_mul_2exp_si(acb_poly_t C, const acb_poly_t A, long c) + # Sets *C* to *A* multiplied by `2^c`. + + void acb_poly_scalar_mul(acb_poly_t C, const acb_poly_t A, const acb_t c, long prec) + # Sets *C* to *A* multiplied by *c*. + + void acb_poly_scalar_div(acb_poly_t C, const acb_poly_t A, const acb_t c, long prec) + # Sets *C* to *A* divided by *c*. + + void _acb_poly_mullow_classical(acb_ptr C, acb_srcptr A, long lenA, acb_srcptr B, long lenB, long n, long prec) + + void _acb_poly_mullow_transpose(acb_ptr C, acb_srcptr A, long lenA, acb_srcptr B, long lenB, long n, long prec) + + void _acb_poly_mullow_transpose_gauss(acb_ptr C, acb_srcptr A, long lenA, acb_srcptr B, long lenB, long n, long prec) + + void _acb_poly_mullow(acb_ptr C, acb_srcptr A, long lenA, acb_srcptr B, long lenB, long n, long prec) + # Sets *{C, n}* to the product of *{A, lenA}* and *{B, lenB}*, truncated to + # length *n*. The output is not allowed to be aliased with either of the + # inputs. We require `\mathrm{lenA} \ge \mathrm{lenB} > 0`, + # `n > 0`, `\mathrm{lenA} + \mathrm{lenB} - 1 \ge n`. + # The *classical* version uses a plain loop. + # The *transpose* version evaluates the product using four real polynomial + # multiplications (via :func:`_arb_poly_mullow`). + # The *transpose_gauss* version evaluates the product using three real + # polynomial multiplications. This is almost always faster than *transpose*, + # but has worse numerical stability when the coefficients vary + # in magnitude. + # The default function :func:`_acb_poly_mullow` automatically switches + # been *classical* and *transpose* multiplication. + # If the input pointers are identical (and the lengths are the same), + # they are assumed to represent the same polynomial, and its + # square is computed. + + void acb_poly_mullow_classical(acb_poly_t C, const acb_poly_t A, const acb_poly_t B, long n, long prec) + + void acb_poly_mullow_transpose(acb_poly_t C, const acb_poly_t A, const acb_poly_t B, long n, long prec) + + void acb_poly_mullow_transpose_gauss(acb_poly_t C, const acb_poly_t A, const acb_poly_t B, long n, long prec) + + void acb_poly_mullow(acb_poly_t C, const acb_poly_t A, const acb_poly_t B, long n, long prec) + # Sets *C* to the product of *A* and *B*, truncated to length *n*. + # If the same variable is passed for *A* and *B*, sets *C* to the + # square of *A* truncated to length *n*. + + void _acb_poly_mul(acb_ptr C, acb_srcptr A, long lenA, acb_srcptr B, long lenB, long prec) + # Sets *{C, lenA + lenB - 1}* to the product of *{A, lenA}* and *{B, lenB}*. + # The output is not allowed to be aliased with either of the + # inputs. We require `\mathrm{lenA} \ge \mathrm{lenB} > 0`. + # This function is implemented as a simple wrapper for :func:`_acb_poly_mullow`. + # If the input pointers are identical (and the lengths are the same), + # they are assumed to represent the same polynomial, and its + # square is computed. + + void acb_poly_mul(acb_poly_t C, const acb_poly_t A1, const acb_poly_t B2, long prec) + # Sets *C* to the product of *A* and *B*. + # If the same variable is passed for *A* and *B*, sets *C* to + # the square of *A*. + + void _acb_poly_inv_series(acb_ptr Qinv, acb_srcptr Q, long Qlen, long len, long prec) + # Sets *{Qinv, len}* to the power series inverse of *{Q, Qlen}*. Uses Newton iteration. + + void acb_poly_inv_series(acb_poly_t Qinv, const acb_poly_t Q, long n, long prec) + # Sets *Qinv* to the power series inverse of *Q*. + + void _acb_poly_div_series(acb_ptr Q, acb_srcptr A, long Alen, acb_srcptr B, long Blen, long n, long prec) + # Sets *{Q, n}* to the power series quotient of *{A, Alen}* by *{B, Blen}*. + # Uses Newton iteration followed by multiplication. + + void acb_poly_div_series(acb_poly_t Q, const acb_poly_t A, const acb_poly_t B, long n, long prec) + # Sets *Q* to the power series quotient *A* divided by *B*, truncated to length *n*. + + void _acb_poly_div(acb_ptr Q, acb_srcptr A, long lenA, acb_srcptr B, long lenB, long prec) + + void _acb_poly_rem(acb_ptr R, acb_srcptr A, long lenA, acb_srcptr B, long lenB, long prec) + + void _acb_poly_divrem(acb_ptr Q, acb_ptr R, acb_srcptr A, long lenA, acb_srcptr B, long lenB, long prec) + + int acb_poly_divrem(acb_poly_t Q, acb_poly_t R, const acb_poly_t A, const acb_poly_t B, long prec) + # Performs polynomial division with remainder, computing a quotient `Q` and + # a remainder `R` such that `A = BQ + R`. The implementation reverses the + # inputs and performs power series division. + # If the leading coefficient of `B` contains zero (or if `B` is identically + # zero), returns 0 indicating failure without modifying the outputs. + # Otherwise returns nonzero. + + void _acb_poly_div_root(acb_ptr Q, acb_t R, acb_srcptr A, long len, const acb_t c, long prec) + # Divides `A` by the polynomial `x - c`, computing the quotient `Q` as well + # as the remainder `R = f(c)`. + + void _acb_poly_taylor_shift(acb_ptr g, const acb_t c, long n, long prec) + void acb_poly_taylor_shift(acb_poly_t g, const acb_poly_t f, const acb_t c, long prec) + # Sets *g* to the Taylor shift `f(x+c)`. + # The underscore methods act in-place on *g* = *f* which has length *n*. + + void _acb_poly_compose(acb_ptr res, acb_srcptr poly1, long len1, acb_srcptr poly2, long len2, long prec) + void acb_poly_compose(acb_poly_t res, const acb_poly_t poly1, const acb_poly_t poly2, long prec) + # Sets *res* to the composition `h(x) = f(g(x))` where `f` is given by + # *poly1* and `g` is given by *poly2*. + # The underscore method does not support aliasing of the output + # with either input polynomial. + + void _acb_poly_compose_series(acb_ptr res, acb_srcptr poly1, long len1, acb_srcptr poly2, long len2, long n, long prec) + void acb_poly_compose_series(acb_poly_t res, const acb_poly_t poly1, const acb_poly_t poly2, long n, long prec) + # Sets *res* to the power series composition `h(x) = f(g(x))` truncated + # to order `O(x^n)` where `f` is given by *poly1* and `g` is given by *poly2*. + # Wraps :func:`_gr_poly_compose_series` which chooses automatically + # between various algorithms. + # We require that the constant term in `g(x)` is exactly zero. + # The underscore method does not support aliasing of the output + # with either input polynomial. + + void _acb_poly_revert_series_lagrange(acb_ptr h, acb_srcptr f, long flen, long n, long prec) + + void acb_poly_revert_series_lagrange(acb_poly_t h, const acb_poly_t f, long n, long prec) + + void _acb_poly_revert_series_newton(acb_ptr h, acb_srcptr f, long flen, long n, long prec) + + void acb_poly_revert_series_newton(acb_poly_t h, const acb_poly_t f, long n, long prec) + + void _acb_poly_revert_series_lagrange_fast(acb_ptr h, acb_srcptr f, long flen, long n, long prec) + + void acb_poly_revert_series_lagrange_fast(acb_poly_t h, const acb_poly_t f, long n, long prec) + + void _acb_poly_revert_series(acb_ptr h, acb_srcptr f, long flen, long n, long prec) + + void acb_poly_revert_series(acb_poly_t h, const acb_poly_t f, long n, long prec) + # Sets `h` to the power series reversion of `f`, i.e. the expansion + # of the compositional inverse function `f^{-1}(x)`, + # truncated to order `O(x^n)`, using respectively + # Lagrange inversion, Newton iteration, fast Lagrange inversion, + # and a default algorithm choice. + # We require that the constant term in `f` is exactly zero and that the + # linear term is nonzero. The underscore methods assume that *flen* + # is at least 2, and do not support aliasing. + + void _acb_poly_evaluate_horner(acb_t y, acb_srcptr f, long len, const acb_t x, long prec) + + void acb_poly_evaluate_horner(acb_t y, const acb_poly_t f, const acb_t x, long prec) + + void _acb_poly_evaluate_rectangular(acb_t y, acb_srcptr f, long len, const acb_t x, long prec) + + void acb_poly_evaluate_rectangular(acb_t y, const acb_poly_t f, const acb_t x, long prec) + + void _acb_poly_evaluate(acb_t y, acb_srcptr f, long len, const acb_t x, long prec) + + void acb_poly_evaluate(acb_t y, const acb_poly_t f, const acb_t x, long prec) + # Sets `y = f(x)`, evaluated respectively using Horner's rule, + # rectangular splitting, and an automatic algorithm choice. + + void _acb_poly_evaluate2_horner(acb_t y, acb_t z, acb_srcptr f, long len, const acb_t x, long prec) + + void acb_poly_evaluate2_horner(acb_t y, acb_t z, const acb_poly_t f, const acb_t x, long prec) + + void _acb_poly_evaluate2_rectangular(acb_t y, acb_t z, acb_srcptr f, long len, const acb_t x, long prec) + + void acb_poly_evaluate2_rectangular(acb_t y, acb_t z, const acb_poly_t f, const acb_t x, long prec) + + void _acb_poly_evaluate2(acb_t y, acb_t z, acb_srcptr f, long len, const acb_t x, long prec) + + void acb_poly_evaluate2(acb_t y, acb_t z, const acb_poly_t f, const acb_t x, long prec) + # Sets `y = f(x), z = f'(x)`, evaluated respectively using Horner's rule, + # rectangular splitting, and an automatic algorithm choice. + # When Horner's rule is used, the only advantage of evaluating the + # function and its derivative simultaneously is that one does not have + # to generate the derivative polynomial explicitly. + # With the rectangular splitting algorithm, the powers can be reused, + # making simultaneous evaluation slightly faster. + + void _acb_poly_product_roots(acb_ptr poly, acb_srcptr xs, long n, long prec) + + void acb_poly_product_roots(acb_poly_t poly, acb_srcptr xs, long n, long prec) + # Generates the polynomial `(x-x_0)(x-x_1)\cdots(x-x_{n-1})`. + + acb_ptr * _acb_poly_tree_alloc(long len) + # Returns an initialized data structured capable of representing a + # remainder tree (product tree) of *len* roots. + + void _acb_poly_tree_free(acb_ptr * tree, long len) + # Deallocates a tree structure as allocated using *_acb_poly_tree_alloc*. + + void _acb_poly_tree_build(acb_ptr * tree, acb_srcptr roots, long len, long prec) + # Constructs a product tree from a given array of *len* roots. The tree + # structure must be pre-allocated to the specified length using + # :func:`_acb_poly_tree_alloc`. + + void _acb_poly_evaluate_vec_iter(acb_ptr ys, acb_srcptr poly, long plen, acb_srcptr xs, long n, long prec) + + void acb_poly_evaluate_vec_iter(acb_ptr ys, const acb_poly_t poly, acb_srcptr xs, long n, long prec) + # Evaluates the polynomial simultaneously at *n* given points, calling + # :func:`_acb_poly_evaluate` repeatedly. + + void _acb_poly_evaluate_vec_fast_precomp(acb_ptr vs, acb_srcptr poly, long plen, acb_ptr * tree, long len, long prec) + + void _acb_poly_evaluate_vec_fast(acb_ptr ys, acb_srcptr poly, long plen, acb_srcptr xs, long n, long prec) + + void acb_poly_evaluate_vec_fast(acb_ptr ys, const acb_poly_t poly, acb_srcptr xs, long n, long prec) + # Evaluates the polynomial simultaneously at *n* given points, using + # fast multipoint evaluation. + + void _acb_poly_interpolate_newton(acb_ptr poly, acb_srcptr xs, acb_srcptr ys, long n, long prec) + + void acb_poly_interpolate_newton(acb_poly_t poly, acb_srcptr xs, acb_srcptr ys, long n, long prec) + # Recovers the unique polynomial of length at most *n* that interpolates + # the given *x* and *y* values. This implementation first interpolates in the + # Newton basis and then converts back to the monomial basis. + + void _acb_poly_interpolate_barycentric(acb_ptr poly, acb_srcptr xs, acb_srcptr ys, long n, long prec) + + void acb_poly_interpolate_barycentric(acb_poly_t poly, acb_srcptr xs, acb_srcptr ys, long n, long prec) + # Recovers the unique polynomial of length at most *n* that interpolates + # the given *x* and *y* values. This implementation uses the barycentric + # form of Lagrange interpolation. + + void _acb_poly_interpolation_weights(acb_ptr w, acb_ptr * tree, long len, long prec) + + void _acb_poly_interpolate_fast_precomp(acb_ptr poly, acb_srcptr ys, acb_ptr * tree, acb_srcptr weights, long len, long prec) + + void _acb_poly_interpolate_fast(acb_ptr poly, acb_srcptr xs, acb_srcptr ys, long len, long prec) + + void acb_poly_interpolate_fast(acb_poly_t poly, acb_srcptr xs, acb_srcptr ys, long n, long prec) + # Recovers the unique polynomial of length at most *n* that interpolates + # the given *x* and *y* values, using fast Lagrange interpolation. + # The precomp function takes a precomputed product tree over the + # *x* values and a vector of interpolation weights as additional inputs. + + void _acb_poly_derivative(acb_ptr res, acb_srcptr poly, long len, long prec) + # Sets *{res, len - 1}* to the derivative of *{poly, len}*. + # Allows aliasing of the input and output. + + void acb_poly_derivative(acb_poly_t res, const acb_poly_t poly, long prec) + # Sets *res* to the derivative of *poly*. + + void _acb_poly_nth_derivative(acb_ptr res, acb_srcptr poly, unsigned long n, long len, long prec) + # Sets *{res, len - n}* to the nth derivative of *{poly, len}*. Does + # nothing if *len <= n*. Allows aliasing of the input and output. + + void acb_poly_nth_derivative(acb_poly_t res, const acb_poly_t poly, unsigned long n, long prec) + # Sets *res* to the nth derivative of *poly*. + + void _acb_poly_integral(acb_ptr res, acb_srcptr poly, long len, long prec) + # Sets *{res, len}* to the integral of *{poly, len - 1}*. + # Allows aliasing of the input and output. + + void acb_poly_integral(acb_poly_t res, const acb_poly_t poly, long prec) + # Sets *res* to the integral of *poly*. + + void _acb_poly_borel_transform(acb_ptr res, acb_srcptr poly, long len, long prec) + + void acb_poly_borel_transform(acb_poly_t res, const acb_poly_t poly, long prec) + # Computes the Borel transform of the input polynomial, mapping `\sum_k a_k x^k` + # to `\sum_k (a_k / k!) x^k`. The underscore method allows aliasing. + + void _acb_poly_inv_borel_transform(acb_ptr res, acb_srcptr poly, long len, long prec) + + void acb_poly_inv_borel_transform(acb_poly_t res, const acb_poly_t poly, long prec) + # Computes the inverse Borel transform of the input polynomial, mapping `\sum_k a_k x^k` + # to `\sum_k a_k k! x^k`. The underscore method allows aliasing. + + void _acb_poly_binomial_transform_basecase(acb_ptr b, acb_srcptr a, long alen, long len, long prec) + + void acb_poly_binomial_transform_basecase(acb_poly_t b, const acb_poly_t a, long len, long prec) + + void _acb_poly_binomial_transform_convolution(acb_ptr b, acb_srcptr a, long alen, long len, long prec) + + void acb_poly_binomial_transform_convolution(acb_poly_t b, const acb_poly_t a, long len, long prec) + + void _acb_poly_binomial_transform(acb_ptr b, acb_srcptr a, long alen, long len, long prec) + + void acb_poly_binomial_transform(acb_poly_t b, const acb_poly_t a, long len, long prec) + # Computes the binomial transform of the input polynomial, truncating + # the output to length *len*. See :func:`arb_poly_binomial_transform` for + # details. + # The underscore methods do not support aliasing, and assume that + # the lengths are nonzero. + + void _acb_poly_graeffe_transform(acb_ptr b, acb_srcptr a, long len, long prec) + + void acb_poly_graeffe_transform(acb_poly_t b, const acb_poly_t a, long prec) + # Computes the Graeffe transform of input polynomial, which is of length *len*. + # See :func:`arb_poly_graeffe_transform` for details. + # The underscore method assumes that *a* and *b* are initialized, + # *a* is of length *len*, and *b* is of length at least *len*. + # Both methods allow aliasing. + + void _acb_poly_pow_ui_trunc_binexp(acb_ptr res, acb_srcptr f, long flen, unsigned long exp, long len, long prec) + # Sets *{res, len}* to *{f, flen}* raised to the power *exp*, truncated + # to length *len*. Requires that *len* is no longer than the length + # of the power as computed without truncation (i.e. no zero-padding is performed). + # Does not support aliasing of the input and output, and requires + # that *flen* and *len* are positive. + # Uses binary exponentiation. + + void acb_poly_pow_ui_trunc_binexp(acb_poly_t res, const acb_poly_t poly, unsigned long exp, long len, long prec) + # Sets *res* to *poly* raised to the power *exp*, truncated to length *len*. + # Uses binary exponentiation. + + void _acb_poly_pow_ui(acb_ptr res, acb_srcptr f, long flen, unsigned long exp, long prec) + # Sets *res* to *{f, flen}* raised to the power *exp*. Does not + # support aliasing of the input and output, and requires that + # *flen* is positive. + + void acb_poly_pow_ui(acb_poly_t res, const acb_poly_t poly, unsigned long exp, long prec) + # Sets *res* to *poly* raised to the power *exp*. + + void _acb_poly_pow_series(acb_ptr h, acb_srcptr f, long flen, acb_srcptr g, long glen, long len, long prec) + # Sets *{h, len}* to the power series `f(x)^{g(x)} = \exp(g(x) \log f(x))` truncated + # to length *len*. This function detects special cases such as *g* being an + # exact small integer or `\pm 1/2`, and computes such powers more + # efficiently. This function does not support aliasing of the output + # with either of the input operands. It requires that all lengths + # are positive, and assumes that *flen* and *glen* do not exceed *len*. + + void acb_poly_pow_series(acb_poly_t h, const acb_poly_t f, const acb_poly_t g, long len, long prec) + # Sets *h* to the power series `f(x)^{g(x)} = \exp(g(x) \log f(x))` truncated + # to length *len*. This function detects special cases such as *g* being an + # exact small integer or `\pm 1/2`, and computes such powers more + # efficiently. + + void _acb_poly_pow_acb_series(acb_ptr h, acb_srcptr f, long flen, const acb_t g, long len, long prec) + # Sets *{h, len}* to the power series `f(x)^g = \exp(g \log f(x))` truncated + # to length *len*. This function detects special cases such as *g* being an + # exact small integer or `\pm 1/2`, and computes such powers more + # efficiently. This function does not support aliasing of the output + # with either of the input operands. It requires that all lengths + # are positive, and assumes that *flen* does not exceed *len*. + + void acb_poly_pow_acb_series(acb_poly_t h, const acb_poly_t f, const acb_t g, long len, long prec) + # Sets *h* to the power series `f(x)^g = \exp(g \log f(x))` truncated + # to length *len*. + + void _acb_poly_sqrt_series(acb_ptr g, acb_srcptr h, long hlen, long n, long prec) + + void acb_poly_sqrt_series(acb_poly_t g, const acb_poly_t h, long n, long prec) + # Sets *g* to the power series square root of *h*, truncated to length *n*. + # Uses division-free Newton iteration for the reciprocal square root, + # followed by a multiplication. + # The underscore method does not support aliasing of the input and output + # arrays. It requires that *hlen* and *n* are greater than zero. + + void _acb_poly_rsqrt_series(acb_ptr g, acb_srcptr h, long hlen, long n, long prec) + + void acb_poly_rsqrt_series(acb_poly_t g, const acb_poly_t h, long n, long prec) + # Sets *g* to the reciprocal power series square root of *h*, truncated to length *n*. + # Uses division-free Newton iteration. + # The underscore method does not support aliasing of the input and output + # arrays. It requires that *hlen* and *n* are greater than zero. + + void _acb_poly_log_series(acb_ptr res, acb_srcptr f, long flen, long n, long prec) + + void acb_poly_log_series(acb_poly_t res, const acb_poly_t f, long n, long prec) + # Sets *res* to the power series logarithm of *f*, truncated to length *n*. + # Uses the formula `\log(f(x)) = \int f'(x) / f(x) dx`, adding the logarithm of the + # constant term in *f* as the constant of integration. + # The underscore method supports aliasing of the input and output + # arrays. It requires that *flen* and *n* are greater than zero. + + void _acb_poly_log1p_series(acb_ptr res, acb_srcptr f, long flen, long n, long prec) + + void acb_poly_log1p_series(acb_poly_t res, const acb_poly_t f, long n, long prec) + # Computes the power series `\log(1+f)`, with better accuracy when the constant term of *f* is small. + + void _acb_poly_atan_series(acb_ptr res, acb_srcptr f, long flen, long n, long prec) + + void acb_poly_atan_series(acb_poly_t res, const acb_poly_t f, long n, long prec) + # Sets *res* the power series inverse tangent of *f*, truncated to length *n*. + # Uses the formula + # .. math :: + # \tan^{-1}(f(x)) = \int f'(x) / (1+f(x)^2) dx, + # adding the function of the constant term in *f* as the constant of integration. + # The underscore method supports aliasing of the input and output + # arrays. It requires that *flen* and *n* are greater than zero. + + void _acb_poly_exp_series_basecase(acb_ptr f, acb_srcptr h, long hlen, long n, long prec) + + void acb_poly_exp_series_basecase(acb_poly_t f, const acb_poly_t h, long n, long prec) + + void _acb_poly_exp_series(acb_ptr f, acb_srcptr h, long hlen, long n, long prec) + + void acb_poly_exp_series(acb_poly_t f, const acb_poly_t h, long n, long prec) + # Sets `f` to the power series exponential of `h`, truncated to length `n`. + # The basecase version uses a simple recurrence for the coefficients, + # requiring `O(nm)` operations where `m` is the length of `h`. + # The main implementation uses Newton iteration, starting from a small + # number of terms given by the basecase algorithm. The complexity + # is `O(M(n))`. Redundant operations in the Newton iteration are + # avoided by using the scheme described in [HZ2004]_. + # The underscore methods support aliasing and allow the input to be + # shorter than the output, but require the lengths to be nonzero. + + void _acb_poly_exp_pi_i_series(acb_ptr f, acb_srcptr h, long hlen, long n, long prec) + + void acb_poly_exp_pi_i_series(acb_poly_t f, const acb_poly_t h, long n, long prec) + # Sets *f* to the power series `\exp(\pi i h)` truncated to length *n*. + # The underscore method supports aliasing and allows the input to be + # shorter than the output, but requires the lengths to be nonzero. + + void _acb_poly_sin_cos_series(acb_ptr s, acb_ptr c, const acb_srcptr h, long hlen, long n, long prec) + void acb_poly_sin_cos_series(acb_poly_t s, acb_poly_t c, const acb_poly_t h, long n, long prec) + # Sets *s* and *c* to the power series sine and cosine of *h*, computed + # simultaneously. + # The underscore method supports aliasing and requires the lengths to be nonzero. + + void _acb_poly_sin_series(acb_ptr s, acb_srcptr h, long hlen, long n, long prec) + + void acb_poly_sin_series(acb_poly_t s, const acb_poly_t h, long n, long prec) + + void _acb_poly_cos_series(acb_ptr c, acb_srcptr h, long hlen, long n, long prec) + + void acb_poly_cos_series(acb_poly_t c, const acb_poly_t h, long n, long prec) + # Respectively evaluates the power series sine or cosine. These functions + # simply wrap :func:`_acb_poly_sin_cos_series`. The underscore methods + # support aliasing and require the lengths to be nonzero. + + void _acb_poly_tan_series(acb_ptr g, acb_srcptr h, long hlen, long len, long prec) + + void acb_poly_tan_series(acb_poly_t g, const acb_poly_t h, long n, long prec) + # Sets *g* to the power series tangent of *h*. + # For small *n* takes the quotient of the sine and cosine as computed + # using the basecase algorithm. For large *n*, uses Newton iteration + # to invert the inverse tangent series. The complexity is `O(M(n))`. + # The underscore version does not support aliasing, and requires + # the lengths to be nonzero. + + void _acb_poly_sin_cos_pi_series(acb_ptr s, acb_ptr c, const acb_srcptr h, long hlen, long n, long prec) + + void acb_poly_sin_cos_pi_series(acb_poly_t s, acb_poly_t c, const acb_poly_t h, long n, long prec) + + void _acb_poly_sin_pi_series(acb_ptr s, acb_srcptr h, long hlen, long n, long prec) + + void acb_poly_sin_pi_series(acb_poly_t s, const acb_poly_t h, long n, long prec) + + void _acb_poly_cos_pi_series(acb_ptr c, acb_srcptr h, long hlen, long n, long prec) + + void acb_poly_cos_pi_series(acb_poly_t c, const acb_poly_t h, long n, long prec) + + void _acb_poly_cot_pi_series(acb_ptr c, acb_srcptr h, long hlen, long n, long prec) + + void acb_poly_cot_pi_series(acb_poly_t c, const acb_poly_t h, long n, long prec) + # Compute the respective trigonometric functions of the input + # multiplied by `\pi`. + + void _acb_poly_sinh_cosh_series_basecase(acb_ptr s, acb_ptr c, const acb_srcptr h, long hlen, long n, long prec) + + void acb_poly_sinh_cosh_series_basecase(acb_poly_t s, acb_poly_t c, const acb_poly_t h, long n, long prec) + + void _acb_poly_sinh_cosh_series_exponential(acb_ptr s, acb_ptr c, const acb_srcptr h, long hlen, long n, long prec) + + void acb_poly_sinh_cosh_series_exponential(acb_poly_t s, acb_poly_t c, const acb_poly_t h, long n, long prec) + + void _acb_poly_sinh_cosh_series(acb_ptr s, acb_ptr c, const acb_srcptr h, long hlen, long n, long prec) + + void acb_poly_sinh_cosh_series(acb_poly_t s, acb_poly_t c, const acb_poly_t h, long n, long prec) + + void _acb_poly_sinh_series(acb_ptr s, acb_srcptr h, long hlen, long n, long prec) + + void acb_poly_sinh_series(acb_poly_t s, const acb_poly_t h, long n, long prec) + + void _acb_poly_cosh_series(acb_ptr c, acb_srcptr h, long hlen, long n, long prec) + + void acb_poly_cosh_series(acb_poly_t c, const acb_poly_t h, long n, long prec) + # Sets *s* and *c* respectively to the hyperbolic sine and cosine of the + # power series *h*, truncated to length *n*. + # The implementations mirror those for sine and cosine, except that + # the *exponential* version computes both functions using the exponential + # function instead of the hyperbolic tangent. + + void _acb_poly_sinc_series(acb_ptr s, acb_srcptr h, long hlen, long n, long prec) + + void acb_poly_sinc_series(acb_poly_t s, const acb_poly_t h, long n, long prec) + # Sets *s* to the sinc function of the power series *h*, truncated + # to length *n*. + + void _acb_poly_lambertw_series(acb_ptr res, acb_srcptr z, long zlen, const fmpz_t k, int flags, long len, long prec) + + void acb_poly_lambertw_series(acb_poly_t res, const acb_poly_t z, const fmpz_t k, int flags, long len, long prec) + # Sets *res* to branch *k* of the Lambert W function of the power series *z*. + # The argument *flags* is reserved for future use. + # The underscore method allows aliasing, but assumes that the lengths are nonzero. + + void _acb_poly_gamma_series(acb_ptr res, acb_srcptr h, long hlen, long n, long prec) + + void acb_poly_gamma_series(acb_poly_t res, const acb_poly_t h, long n, long prec) + + void _acb_poly_rgamma_series(acb_ptr res, acb_srcptr h, long hlen, long n, long prec) + + void acb_poly_rgamma_series(acb_poly_t res, const acb_poly_t h, long n, long prec) + + void _acb_poly_lgamma_series(acb_ptr res, acb_srcptr h, long hlen, long n, long prec) + + void acb_poly_lgamma_series(acb_poly_t res, const acb_poly_t h, long n, long prec) + + void _acb_poly_digamma_series(acb_ptr res, acb_srcptr h, long hlen, long n, long prec) + + void acb_poly_digamma_series(acb_poly_t res, const acb_poly_t h, long n, long prec) + # Sets *res* to the series expansion of `\Gamma(h(x))`, `1/\Gamma(h(x))`, + # or `\log \Gamma(h(x))`, `\psi(h(x))`, truncated to length *n*. + # These functions first generate the Taylor series at the constant + # term of *h*, and then call :func:`_acb_poly_compose_series`. + # The Taylor coefficients are generated using Stirling's series. + # The underscore methods support aliasing of the input and output + # arrays, and require that *hlen* and *n* are greater than zero. + + void _acb_poly_rising_ui_series(acb_ptr res, acb_srcptr f, long flen, unsigned long r, long trunc, long prec) + + void acb_poly_rising_ui_series(acb_poly_t res, const acb_poly_t f, unsigned long r, long trunc, long prec) + # Sets *res* to the rising factorial `(f) (f+1) (f+2) \cdots (f+r-1)`, truncated + # to length *trunc*. The underscore method assumes that *flen*, *r* and *trunc* + # are at least 1, and does not support aliasing. Uses binary splitting. + + void _acb_poly_powsum_series_naive(acb_ptr z, const acb_t s, const acb_t a, const acb_t q, long n, long len, long prec) + + void _acb_poly_powsum_series_naive_threaded(acb_ptr z, const acb_t s, const acb_t a, const acb_t q, long n, long len, long prec) + # Computes + # .. math :: + # z = S(s,a,n) = \sum_{k=0}^{n-1} \frac{q^k}{(k+a)^{s+t}} + # as a power series in `t` truncated to length *len*. This function + # evaluates the sum naively term by term. + # The *threaded* version splits the computation + # over the number of threads returned by *flint_get_num_threads()*. + + void _acb_poly_powsum_one_series_sieved(acb_ptr z, const acb_t s, long n, long len, long prec) + # Computes + # .. math :: + # z = S(s,1,n) \sum_{k=1}^n \frac{1}{k^{s+t}} + # as a power series in `t` truncated to length *len*. + # This function stores a table of powers that have already been calculated, + # computing `(ij)^r` as `i^r j^r` whenever `k = ij` is + # composite. As a further optimization, it groups all even `k` and + # evaluates the sum as a polynomial in `2^{-(s+t)}`. + # This scheme requires about `n / \log n` powers, `n / 2` multiplications, + # and temporary storage of `n / 6` power series. Due to the extra + # power series multiplications, it is only faster than the naive + # algorithm when *len* is small. + + void _acb_poly_zeta_em_choose_param(mag_t bound, unsigned long * N, unsigned long * M, const acb_t s, const acb_t a, long d, long target, long prec) + # Chooses *N* and *M* for Euler-Maclaurin summation of the + # Hurwitz zeta function, using a default algorithm. + + void _acb_poly_zeta_em_bound1(mag_t bound, const acb_t s, const acb_t a, long N, long M, long d, long wp) + + void _acb_poly_zeta_em_bound(arb_ptr vec, const acb_t s, const acb_t a, unsigned long N, unsigned long M, long d, long wp) + # Compute bounds for Euler-Maclaurin evaluation of the Hurwitz zeta function + # or its power series, using the formulas in [Joh2013]_. + + void _acb_poly_zeta_em_tail_naive(acb_ptr z, const acb_t s, const acb_t Na, acb_srcptr Nasx, long M, long len, long prec) + + void _acb_poly_zeta_em_tail_bsplit(acb_ptr z, const acb_t s, const acb_t Na, acb_srcptr Nasx, long M, long len, long prec) + # Evaluates the tail in the Euler-Maclaurin sum for the Hurwitz zeta + # function, respectively using the naive recurrence and binary splitting. + + void _acb_poly_zeta_em_sum(acb_ptr z, const acb_t s, const acb_t a, int deflate, unsigned long N, unsigned long M, long d, long prec) + # Evaluates the truncated Euler-Maclaurin sum of order `N, M` for the + # length-*d* truncated Taylor series of the Hurwitz zeta function + # `\zeta(s,a)` at `s`, using a working precision of *prec* bits. + # With `a = 1`, this gives the usual Riemann zeta function. + # If *deflate* is nonzero, `\zeta(s,a) - 1/(s-1)` is evaluated + # (which permits series expansion at `s = 1`). + + void _acb_poly_zeta_cpx_series(acb_ptr z, const acb_t s, const acb_t a, int deflate, long d, long prec) + # Computes the series expansion of `\zeta(s+x,a)` (or + # `\zeta(s+x,a) - 1/(s+x-1)` if *deflate* is nonzero) to order *d*. + # This function wraps :func:`_acb_poly_zeta_em_sum`, automatically choosing + # default values for `N, M` using :func:`_acb_poly_zeta_em_choose_param` to + # target an absolute truncation error of `2^{-\operatorname{prec}}`. + + void _acb_poly_zeta_series(acb_ptr res, acb_srcptr h, long hlen, const acb_t a, int deflate, long len, long prec) + + void acb_poly_zeta_series(acb_poly_t res, const acb_poly_t f, const acb_t a, int deflate, long n, long prec) + # Sets *res* to the Hurwitz zeta function `\zeta(s,a)` where `s` a power + # series and `a` is a constant, truncated to length *n*. + # To evaluate the usual Riemann zeta function, set `a = 1`. + # If *deflate* is nonzero, evaluates `\zeta(s,a) + 1/(1-s)`, which + # is well-defined as a limit when the constant term of `s` is 1. + # In particular, expanding `\zeta(s,a) + 1/(1-s)` with `s = 1+x` + # gives the Stieltjes constants + # .. math :: + # \sum_{k=0}^{n-1} \frac{(-1)^k}{k!} \gamma_k(a) x^k`. + # If `a = 1`, this implementation uses the reflection formula if the midpoint + # of the constant term of `s` is negative. + + void _acb_poly_polylog_cpx_small(acb_ptr w, const acb_t s, const acb_t z, long len, long prec) + + void _acb_poly_polylog_cpx_zeta(acb_ptr w, const acb_t s, const acb_t z, long len, long prec) + + void _acb_poly_polylog_cpx(acb_ptr w, const acb_t s, const acb_t z, long len, long prec) + # Sets *w* to the Taylor series with respect to *x* of the polylogarithm + # `\operatorname{Li}_{s+x}(z)`, where *s* and *z* are given complex + # constants. The output is computed to length *len* which must be positive. + # Aliasing between *w* and *s* or *z* is not permitted. + # The *small* version uses the standard power series expansion with respect + # to *z*, convergent when `|z| < 1`. The *zeta* version evaluates + # the polylogarithm as a sum of two Hurwitz zeta functions. + # The default version automatically delegates to the *small* version + # when *z* is close to zero, and the *zeta* version otherwise. + # For further details, see :ref:`algorithms_polylogarithms`. + + void _acb_poly_polylog_series(acb_ptr w, acb_srcptr s, long slen, const acb_t z, long len, long prec) + + void acb_poly_polylog_series(acb_poly_t w, const acb_poly_t s, const acb_t z, long len, long prec) + # Sets *w* to the polylogarithm `\operatorname{Li}_{s}(z)` where *s* is a given + # power series, truncating the output to length *len*. The underscore method + # requires all lengths to be positive and supports aliasing between + # all inputs and outputs. + + void _acb_poly_erf_series(acb_ptr res, acb_srcptr z, long zlen, long n, long prec) + + void acb_poly_erf_series(acb_poly_t res, const acb_poly_t z, long n, long prec) + # Sets *res* to the error function of the power series *z*, truncated to length *n*. + # These methods are provided for backwards compatibility. + # See :func:`acb_hypgeom_erf_series`, :func:`acb_hypgeom_erfc_series`, + # :func:`acb_hypgeom_erfi_series`. + + void _acb_poly_agm1_series(acb_ptr res, acb_srcptr z, long zlen, long len, long prec) + + void acb_poly_agm1_series(acb_poly_t res, const acb_poly_t z, long n, long prec) + # Sets *res* to the arithmetic-geometric mean of 1 and the power series *z*, + # truncated to length *n*. + + void _acb_poly_elliptic_k_series(acb_ptr res, acb_srcptr z, long zlen, long len, long prec) + + void acb_poly_elliptic_k_series(acb_poly_t res, const acb_poly_t z, long n, long prec) + + void _acb_poly_elliptic_p_series(acb_ptr res, acb_srcptr z, long zlen, const acb_t tau, long len, long prec) + + void acb_poly_elliptic_p_series(acb_poly_t res, const acb_poly_t z, const acb_t tau, long n, long prec) + + void _acb_poly_root_bound_fujiwara(mag_t bound, acb_srcptr poly, long len) + + void acb_poly_root_bound_fujiwara(mag_t bound, acb_poly_t poly) + # Sets *bound* to an upper bound for the magnitude of all the complex + # roots of *poly*. Uses Fujiwara's bound + # .. math :: + # 2 \max \left\{\left|\frac{a_{n-1}}{a_n}\right|, + # \left|\frac{a_{n-2}}{a_n}\right|^{1/2}, + # \cdots, + # \left|\frac{a_1}{a_n}\right|^{1/(n-1)}, + # \left|\frac{a_0}{2a_n}\right|^{1/n} + # \right\} + # where `a_0, \ldots, a_n` are the coefficients of *poly*. + + void _acb_poly_root_inclusion(acb_t r, const acb_t m, acb_srcptr poly, acb_srcptr polyder, long len, long prec) + # Given any complex number `m`, and a nonconstant polynomial `f` and its + # derivative `f'`, sets *r* to a complex interval centered on `m` that is + # guaranteed to contain at least one root of `f`. + # Such an interval is obtained by taking a ball of radius `|f(m)/f'(m)| n` + # where `n` is the degree of `f`. Proof: assume that the distance + # to the nearest root exceeds `r = |f(m)/f'(m)| n`. Then + # .. math :: + # \left|\frac{f'(m)}{f(m)}\right| = + # \left|\sum_i \frac{1}{m-\zeta_i}\right| + # \le \sum_i \frac{1}{|m-\zeta_i|} + # < \frac{n}{r} = \left|\frac{f'(m)}{f(m)}\right| + # which is a contradiction (see [Kob2010]_). + + long _acb_poly_validate_roots(acb_ptr roots, acb_srcptr poly, long len, long prec) + # Given a list of approximate roots of the input polynomial, this + # function sets a rigorous bounding interval for each root, and determines + # which roots are isolated from all the other roots. + # It then rearranges the list of roots so that the isolated roots + # are at the front of the list, and returns the count of isolated roots. + # If the return value equals the degree of the polynomial, then all + # roots have been found. If the return value is smaller, all the + # remaining output intervals are guaranteed to contain roots, but + # it is possible that not all of the polynomial's roots are contained + # among them. + + void _acb_poly_refine_roots_durand_kerner(acb_ptr roots, acb_srcptr poly, long len, long prec) + # Refines the given roots simultaneously using a single iteration + # of the Durand-Kerner method. The radius of each root is set to an + # approximation of the correction, giving a rough estimate of its error (not + # a rigorous bound). + + long _acb_poly_find_roots(acb_ptr roots, acb_srcptr poly, acb_srcptr initial, long len, long maxiter, long prec) + + long acb_poly_find_roots(acb_ptr roots, const acb_poly_t poly, acb_srcptr initial, long maxiter, long prec) + # Attempts to compute all the roots of the given nonzero polynomial *poly* + # using a working precision of *prec* bits. If *n* denotes the degree of *poly*, + # the function writes *n* approximate roots with rigorous error bounds to + # the preallocated array *roots*, and returns the number of + # roots that are isolated. + # If the return value equals the degree of the polynomial, then all + # roots have been found. If the return value is smaller, all the output + # intervals are guaranteed to contain roots, but it is possible that + # not all of the polynomial's roots are contained among them. + # The roots are computed numerically by performing several steps with + # the Durand-Kerner method and terminating if the estimated accuracy of + # the roots approaches the working precision or if the number + # of steps exceeds *maxiter*, which can be set to zero in order to use + # a default value. Finally, the approximate roots are validated rigorously. + # Initial values for the iteration can be provided as the array *initial*. + # If *initial* is set to *NULL*, default values `(0.4+0.9i)^k` are used. + # The polynomial is assumed to be squarefree. If there are repeated + # roots, the iteration is likely to find them (with low numerical accuracy), + # but the error bounds will not converge as the precision increases. + + int _acb_poly_validate_real_roots(acb_srcptr roots, acb_srcptr poly, long len, long prec) + + int acb_poly_validate_real_roots(acb_srcptr roots, const acb_poly_t poly, long prec) + # Given a strictly real polynomial *poly* (of length *len*) and isolating + # intervals for all its complex roots, determines if all the real roots + # are separated from the non-real roots. If this function returns nonzero, + # every root enclosure that touches the real axis (as tested by applying + # :func:`arb_contains_zero` to the imaginary part) corresponds to a real root + # (its imaginary part can be set to zero), and every other root enclosure + # corresponds to a non-real root (with known sign for the imaginary part). + # If this function returns zero, then the signs of the imaginary parts + # are not known for certain, based on the accuracy of the inputs + # and the working precision *prec*. diff --git a/src/sage/libs/flint/acf.pxd b/src/sage/libs/flint/acf.pxd new file mode 100644 index 00000000000..6cd562700e3 --- /dev/null +++ b/src/sage/libs/flint/acf.pxd @@ -0,0 +1,57 @@ +# distutils: libraries = flint +# distutils: depends = flint/acf.h + +################################################################################ +# This file is auto-generated. Do not modify by hand +################################################################################ + +from libc.stdio cimport FILE +from sage.libs.gmp.types cimport * +from sage.libs.mpfr.types cimport * +from sage.libs.flint.types cimport * + +cdef extern from "flint_wrap.h": + + void acf_init(acf_t x) + # Initializes the variable *x* for use, and sets its value to zero. + + void acf_clear(acf_t x) + # Clears the variable *x*, freeing or recycling its allocated memory. + + void acf_swap(acf_t z, acf_t x) + # Swaps *z* and *x* efficiently. + + long acf_allocated_bytes(const acf_t x) + # Returns the total number of bytes heap-allocated internally by this object. + # The count excludes the size of the structure itself. Add + # ``sizeof(acf_struct)`` to get the size of the object as a whole. + + arf_ptr acf_real_ptr(acf_t z) + arf_ptr acf_imag_ptr(acf_t z) + # Returns a pointer to the real or imaginary part of *z*. + + void acf_set(acf_t z, const acf_t x) + # Sets *z* to the value *x*. + + int acf_equal(const acf_t x, const acf_t y) + # Returns whether *x* and *y* are equal. + + int acf_add(acf_t res, const acf_t x, const acf_t y, long prec, arf_rnd_t rnd) + + int acf_sub(acf_t res, const acf_t x, const acf_t y, long prec, arf_rnd_t rnd) + + int acf_mul(acf_t res, const acf_t x, const acf_t y, long prec, arf_rnd_t rnd) + # Sets *res* to the sum, difference or product of *x* or *y*, correctly + # rounding the real and imaginary parts in direction *rnd*. + # The return flag has the least significant bit set if the real + # part is inexact, and the second least significant bit set if + # the imaginary part is inexact. + + void acf_approx_inv(acf_t res, const acf_t x, long prec, arf_rnd_t rnd) + void acf_approx_div(acf_t res, const acf_t x, const acf_t y, long prec, arf_rnd_t rnd) + void acf_approx_sqrt(acf_t res, const acf_t x, long prec, arf_rnd_t rnd) + # Computes an approximate inverse, quotient or square root. + + void acf_approx_dot(acf_t res, const acf_t initial, int subtract, acf_srcptr x, long xstep, acf_srcptr y, long ystep, long len, long prec, arf_rnd_t rnd) + # Computes an approximate dot product, with the same meaning of + # the parameters as :func:`arb_dot`. diff --git a/src/sage/libs/flint/aprcl.pxd b/src/sage/libs/flint/aprcl.pxd new file mode 100644 index 00000000000..0a480651aa5 --- /dev/null +++ b/src/sage/libs/flint/aprcl.pxd @@ -0,0 +1,279 @@ +# distutils: libraries = flint +# distutils: depends = flint/aprcl.h + +################################################################################ +# This file is auto-generated. Do not modify by hand +################################################################################ + +from libc.stdio cimport FILE +from sage.libs.gmp.types cimport * +from sage.libs.mpfr.types cimport * +from sage.libs.flint.types cimport * + +cdef extern from "flint_wrap.h": + + int aprcl_is_prime(const fmpz_t n) + # Tests `n` for primality using the APRCL test. + # This is the same as :func:`aprcl_is_prime_jacobi`. + + int aprcl_is_prime_jacobi(const fmpz_t n) + # If `n` is prime returns 1; otherwise returns 0. The algorithm is well described + # in "Implementation of a New Primality Test" by H. Cohen and A.K. Lenstra and + # "A Course in Computational Algebraic Number Theory" by H. Cohen. + # It is theoretically possible that this function fails to prove that + # `n` is prime. In this event, :func:`flint_abort` is called. + # To handle this condition, the :func:`_aprcl_is_prime_jacobi` function + # can be used. + + int aprcl_is_prime_gauss(const fmpz_t n) + # If `n` is prime returns 1; otherwise returns 0. + # Uses the cyclotomic primality testing algorithm described in + # "Four primality testing algorithms" by Rene Schoof. + # The minimum required numbers `s` and `R` are computed automatically. + # By default `R \ge 180`. In some cases this function fails to prove + # that `n` is prime. This means that we select a too small `R` value. + # In this event, :func:`flint_abort` is called. + # To handle this condition, the :func:`_aprcl_is_prime_jacobi` function + # can be used. + + primality_test_status _aprcl_is_prime_jacobi(const fmpz_t n, const aprcl_config config) + # Jacobi sum test for `n`. Possible return values: + # ``PRIME``, ``COMPOSITE`` and ``UNKNOWN`` (if we cannot + # prove primality). + + primality_test_status _aprcl_is_prime_gauss(const fmpz_t n, const aprcl_config config) + # Tests `n` for primality with fixed ``config``. Possible return values: + # ``PRIME``, ``COMPOSITE`` and ``PROBABPRIME`` + # (if we cannot prove primality). + + int aprcl_is_prime_gauss_min_R(const fmpz_t n, unsigned long R) + # Same as :func:`aprcl_is_prime_gauss` with fixed minimum value of `R`. + + int aprcl_is_prime_final_division(const fmpz_t n, const fmpz_t s, unsigned long r) + # Returns 0 if for some `a = n^k \bmod s`, where `k \in [1, r - 1]`, + # we have that `a \mid n`; otherwise returns 1. + + void aprcl_config_gauss_init(aprcl_config conf, const fmpz_t n) + # Computes the `s` and `R` values used in the cyclotomic primality test, + # `s^2 > n` and `s=\prod\limits_{\substack{q-1\mid R \\ q \text{ prime}}}q`. + # Also stores factors of `R` and `s`. + + void aprcl_config_gauss_init_min_R(aprcl_config conf, const fmpz_t n, unsigned long R) + # Computes the `s` with fixed minimum `R` such that `a^R \equiv 1 \mod{s}` + # for all integers `a` coprime to `s`. + + void aprcl_config_gauss_clear(aprcl_config conf) + # Clears the given ``aprcl_config`` element. It must be reinitialised in + # order to be used again. + + unsigned long aprcl_R_value(const fmpz_t n) + # Returns a precomputed `R` value for APRCL, such that the + # corresponding `s` value is greater than `\sqrt{n}`. The maximum + # stored value `6983776800` allows to test numbers up to `6000` digits. + + void aprcl_config_jacobi_init(aprcl_config conf, const fmpz_t n) + # Computes the `s` and `R` values used in the cyclotomic primality test, + # `s^2 > n` and `a^R \equiv 1 \mod{s}` for all `a` coprime to `s`. + # Also stores factors of `R` and `s`. + + void aprcl_config_jacobi_clear(aprcl_config conf) + # Clears the given ``aprcl_config`` element. It must be reinitialised in + # order to be used again. + + void unity_zp_init(unity_zp f, unsigned long p, unsigned long exp, const fmpz_t n) + # Initializes `f` as an element of `\mathbb{Z}[\zeta_{p^{exp}}]/(n)`. + + void unity_zp_clear(unity_zp f) + # Clears the given element. It must be reinitialised in + # order to be used again. + + void unity_zp_copy(unity_zp f, const unity_zp g) + # Sets `f` to `g`. `f` and `g` must be initialized with same `p` and `n`. + + void unity_zp_swap(unity_zp f, unity_zp q) + # Swaps `f` and `g`. `f` and `g` must be initialized with same `p` and `n`. + + void unity_zp_set_zero(unity_zp f) + # Sets `f` to zero. + + long unity_zp_is_unity(unity_zp f) + # If `f = \zeta^h` returns h; otherwise returns -1. + + int unity_zp_equal(unity_zp f, unity_zp g) + # Returns nonzero if `f = g` reduced by the `p^{exp}`-th cyclotomic + # polynomial. + + void unity_zp_print(const unity_zp f) + # Prints the contents of the `f`. + + void unity_zp_coeff_set_fmpz(unity_zp f, unsigned long ind, const fmpz_t x) + void unity_zp_coeff_set_ui(unity_zp f, unsigned long ind, unsigned long x) + # Sets the coefficient of `\zeta^{ind}` to `x`. + # `ind` must be less than `p^{exp}`. + + void unity_zp_coeff_add_fmpz(unity_zp f, unsigned long ind, const fmpz_t x) + void unity_zp_coeff_add_ui(unity_zp f, unsigned long ind, unsigned long x) + # Adds `x` to the coefficient of `\zeta^{ind}`. + # `x` must be less than `n`. + # `ind` must be less than `p^{exp}`. + + void unity_zp_coeff_inc(unity_zp f, unsigned long ind) + # Increments the coefficient of `\zeta^{ind}`. + # `ind` must be less than `p^{exp}`. + + void unity_zp_coeff_dec(unity_zp f, unsigned long ind) + # Decrements the coefficient of `\zeta^{ind}`. + # `ind` must be less than `p^{exp}`. + + void unity_zp_mul_scalar_fmpz(unity_zp f, const unity_zp g, const fmpz_t s) + # Sets `f` to `s \cdot g`. `f` and `g` must be initialized with + # same `p`, `exp` and `n`. + + void unity_zp_mul_scalar_ui(unity_zp f, const unity_zp g, unsigned long s) + # Sets `f` to `s \cdot g`. `f` and `g` must be initialized with + # same `p`, `exp` and `n`. + + void unity_zp_add(unity_zp f, const unity_zp g, const unity_zp h) + # Sets `f` to `g + h`. + # `f`, `g` and `h` must be initialized with same `p`, `exp` and `n`. + + void unity_zp_mul(unity_zp f, const unity_zp g, const unity_zp h) + # Sets `f` to `g \cdot h`. + # `f`, `g` and `h` must be initialized with same `p`, `exp` and `n`. + + void unity_zp_sqr(unity_zp f, const unity_zp g) + # Sets `f` to `g \cdot g`. + # `f`, `g` and `h` must be initialized with same `p`, `exp` and `n`. + + void unity_zp_mul_inplace(unity_zp f, const unity_zp g, const unity_zp h, fmpz_t * t) + # Sets `f` to `g \cdot h`. If `p^{exp} = 3, 4, 5, 7, 8, 9, 11, 16` special + # multiplication functions are used. The preallocated array `t` of ``fmpz_t`` is + # used for all computations in this case. + # `f`, `g` and `h` must be initialized with same `p`, `exp` and `n`. + + void unity_zp_sqr_inplace(unity_zp f, const unity_zp g, fmpz_t * t) + # Sets `f` to `g \cdot g`. If `p^{exp} = 3, 4, 5, 7, 8, 9, 11, 16` special + # multiplication functions are used. The preallocated array `t` of ``fmpz_t`` is + # used for all computations in this case. + # `f` and `g` must be initialized with same `p`, `exp` and `n`. + + void unity_zp_pow_fmpz(unity_zp f, const unity_zp g, const fmpz_t pow) + # Sets `f` to `g^{pow}`. `f` and `g` must be initialized with + # same `p`, `exp` and `n`. + + void unity_zp_pow_ui(unity_zp f, const unity_zp g, unsigned long pow) + # Sets `f` to `g^{pow}`. `f` and `g` must be initialized with + # same `p`, `exp` and `n`. + + unsigned long _unity_zp_pow_select_k(const fmpz_t n) + # Returns the smallest integer `k` satisfying + # `\log (n) < (k(k + 1)2^{2k}) / (2^{k + 1} - k - 2) + 1` + + void unity_zp_pow_2k_fmpz(unity_zp f, const unity_zp g, const fmpz_t pow) + # Sets `f` to `g^{pow}` using the `2^k`-ary exponentiation method. + # `f` and `g` must be initialized with same `p`, `exp` and `n`. + + void unity_zp_pow_2k_ui(unity_zp f, const unity_zp g, unsigned long pow) + # Sets `f` to `g^{pow}` using the `2^k`-ary exponentiation method. + # `f` and `g` must be initialized with same `p`, `exp` and `n`. + + void unity_zp_pow_sliding_fmpz(unity_zp f, unity_zp g, const fmpz_t pow) + # Sets `f` to `g^{pow}` using the sliding window exponentiation method. + # `f` and `g` must be initialized with same `p`, `exp` and `n`. + + void _unity_zp_reduce_cyclotomic_divmod(unity_zp f) + void _unity_zp_reduce_cyclotomic(unity_zp f) + # Sets `f = f \bmod \Phi_{p^{exp}}`. `\Phi_{p^{exp}}` is the `p^{exp}`-th + # cyclotomic polynomial. `g` must be reduced by `x^{p^{exp}}-1` poly. + # `f` and `g` must be initialized with same `p`, `exp` and `n`. + + void unity_zp_reduce_cyclotomic(unity_zp f, const unity_zp g) + # Sets `f = g \bmod \Phi_{p^{exp}}`. `\Phi_{p^{exp}}` is the `p^{exp}`-th + # cyclotomic polynomial. + + void unity_zp_aut(unity_zp f, const unity_zp g, unsigned long x) + # Sets `f = \sigma_x(g)`, the automorphism `\sigma_x(\zeta)=\zeta^x`. + # `f` and `g` must be initialized with the same `p`, `exp` and `n`. + + void unity_zp_aut_inv(unity_zp f, const unity_zp g, unsigned long x) + # Sets `f = \sigma_x^{-1}(g)`, so `\sigma_x(f) = g`. + # `g` must be reduced by `\Phi_{p^{exp}}`. + # `f` and `g` must be initialized with the same `p`, `exp` and `n`. + + void unity_zp_jacobi_sum_pq(unity_zp f, unsigned long q, unsigned long p) + # Sets `f` to the Jacobi sum `J(p, q) = j(\chi_{p, q}, \chi_{p, q})`. + + void unity_zp_jacobi_sum_2q_one(unity_zp f, unsigned long q) + # Sets `f` to the Jacobi sum + # `J_2(q) = j(\chi_{2, q}^{2^{k - 3}}, \chi_{2, q}^{3 \cdot 2^{k - 3}}))^2`. + + void unity_zp_jacobi_sum_2q_two(unity_zp f, unsigned long q) + # Sets `f` to the Jacobi sum + # `J_3(1) = j(\chi_{2, q}, \chi_{2, q}, \chi_{2, q}) = + # J(2, q) \cdot j(\chi_{2, q}^2, \chi_{2, q})`. + + void unity_zpq_init(unity_zpq f, unsigned long q, unsigned long p, const fmpz_t n) + # Initializes `f` as an element of `\mathbb{Z}[\zeta_q, \zeta_p]/(n)`. + + void unity_zpq_clear(unity_zpq f) + # Clears the given element. It must be reinitialized in + # order to be used again. + + void unity_zpq_copy(unity_zpq f, const unity_zpq g) + # Sets `f` to `g`. `f` and `g` must be initialized with + # same `p`, `q` and `n`. + + void unity_zpq_swap(unity_zpq f, unity_zpq q) + # Swaps `f` and `g`. `f` and `g` must be initialized with + # same `p`, `q` and `n`. + + int unity_zpq_equal(const unity_zpq f, const unity_zpq g) + # Returns nonzero if `f = g`. + + long unity_zpq_p_unity(const unity_zpq f) + # If `f = \zeta_p^x` returns `x \in [0, p - 1]`; otherwise returns `p`. + + int unity_zpq_is_p_unity(const unity_zpq f) + # Returns nonzero if `f = \zeta_p^x`. + + int unity_zpq_is_p_unity_generator(const unity_zpq f) + # Returns nonzero if `f` is a generator of the cyclic group `\langle\zeta_p\rangle`. + + void unity_zpq_coeff_set_fmpz(unity_zpq f, long i, long j, const fmpz_t x) + # Sets the coefficient of `\zeta_q^i \zeta_p^j` to `x`. + # `i` must be less than `q` and `j` must be less than `p`. + + void unity_zpq_coeff_set_ui(unity_zpq f, long i, long j, unsigned long x) + # Sets the coefficient of `\zeta_q^i \zeta_p^j` to `x`. + # `i` must be less than `q` and `j` must be less then `p`. + + void unity_zpq_coeff_add(unity_zpq f, long i, long j, const fmpz_t x) + # Adds `x` to the coefficient of `\zeta_p^i \zeta_q^j`. `x` must be less than `n`. + + void unity_zpq_add(unity_zpq f, const unity_zpq g, const unity_zpq h) + # Sets `f` to `g + h`. + # `f`, `g` and `h` must be initialized with same + # `q`, `p` and `n`. + + void unity_zpq_mul(unity_zpq f, const unity_zpq g, const unity_zpq h) + # Sets the `f` to `g \cdot h`. + # `f`, `g` and `h` must be initialized with same + # `q`, `p` and `n`. + + void _unity_zpq_mul_unity_p(unity_zpq f) + # Sets `f = f \cdot \zeta_p`. + + void unity_zpq_mul_unity_p_pow(unity_zpq f, const unity_zpq g, long k) + # Sets `f` to `g \cdot \zeta_p^k`. + + void unity_zpq_pow(unity_zpq f, const unity_zpq g, const fmpz_t p) + # Sets `f` to `g^p`. `f` and `g` must be initialized with same `p`, `q` and `n`. + + void unity_zpq_pow_ui(unity_zpq f, const unity_zpq g, unsigned long p) + # Sets `f` to `g^p`. `f` and `g` must be initialized with same `p`, `q` and `n`. + + void unity_zpq_gauss_sum(unity_zpq f, unsigned long q, unsigned long p) + # Sets `f = \tau(\chi_{p, q})`. + + void unity_zpq_gauss_sum_sigma_pow(unity_zpq f, unsigned long q, unsigned long p) + # Sets `f = \tau^{\sigma_n}(\chi_{p, q})`. diff --git a/src/sage/libs/flint/arb.pxd b/src/sage/libs/flint/arb.pxd new file mode 100644 index 00000000000..2563924df26 --- /dev/null +++ b/src/sage/libs/flint/arb.pxd @@ -0,0 +1,1487 @@ +# distutils: libraries = flint +# distutils: depends = flint/arb.h + +################################################################################ +# This file is auto-generated. Do not modify by hand +################################################################################ + +from libc.stdio cimport FILE +from sage.libs.gmp.types cimport * +from sage.libs.mpfr.types cimport * +from sage.libs.flint.types cimport * + +cdef extern from "flint_wrap.h": + + void arb_init(arb_t x) + # Initializes the variable *x* for use. Its midpoint and radius are both + # set to zero. + + void arb_clear(arb_t x) + # Clears the variable *x*, freeing or recycling its allocated memory. + + arb_ptr _arb_vec_init(long n) + # Returns a pointer to an array of *n* initialized :type:`arb_struct` + # entries. + + void _arb_vec_clear(arb_ptr v, long n) + # Clears an array of *n* initialized :type:`arb_struct` entries. + + void arb_swap(arb_t x, arb_t y) + # Swaps *x* and *y* efficiently. + + long arb_allocated_bytes(const arb_t x) + # Returns the total number of bytes heap-allocated internally by this object. + # The count excludes the size of the structure itself. Add + # ``sizeof(arb_struct)`` to get the size of the object as a whole. + + long _arb_vec_allocated_bytes(arb_srcptr vec, long len) + # Returns the total number of bytes allocated for this vector, i.e. the + # space taken up by the vector itself plus the sum of the internal heap + # allocation sizes for all its member elements. + + double _arb_vec_estimate_allocated_bytes(long len, long prec) + # Estimates the number of bytes that need to be allocated for a vector of + # *len* elements with *prec* bits of precision, including the space for + # internal limb data. + # This function returns a *double* to avoid overflow issues when both + # *len* and *prec* are large. + # This is only an approximation of the physical memory that will be used + # by an actual vector. In practice, the space varies with the content + # of the numbers; for example, zeros and small integers require no + # internal heap allocation even if the precision is huge. + # The estimate assumes that exponents will not be bignums. + # The actual amount may also be higher or lower due to overhead in the + # memory allocator or overcommitment by the operating system. + + void arb_set(arb_t y, const arb_t x) + + void arb_set_arf(arb_t y, const arf_t x) + + void arb_set_si(arb_t y, long x) + + void arb_set_ui(arb_t y, unsigned long x) + + void arb_set_d(arb_t y, double x) + + void arb_set_fmpz(arb_t y, const fmpz_t x) + # Sets *y* to the value of *x* without rounding. + + void arb_set_fmpz_2exp(arb_t y, const fmpz_t x, const fmpz_t e) + # Sets *y* to `x \cdot 2^e`. + + void arb_set_round(arb_t y, const arb_t x, long prec) + + void arb_set_round_fmpz(arb_t y, const fmpz_t x, long prec) + # Sets *y* to the value of *x*, rounded to *prec* bits in the direction + # towards zero. + + void arb_set_round_fmpz_2exp(arb_t y, const fmpz_t x, const fmpz_t e, long prec) + # Sets *y* to `x \cdot 2^e`, rounded to *prec* bits in the direction + # towards zero. + + void arb_set_fmpq(arb_t y, const fmpq_t x, long prec) + # Sets *y* to the rational number *x*, rounded to *prec* bits in the direction + # towards zero. + + int arb_set_str(arb_t res, const char * inp, long prec) + # Sets *res* to the value specified by the human-readable string *inp*. + # The input may be a decimal floating-point literal, + # such as "25", "0.001", "7e+141" or "-31.4159e-1", and may also consist + # of two such literals separated by the symbol "+/-" and optionally + # enclosed in brackets, e.g. "[3.25 +/- 0.0001]", or simply + # "[+/- 10]" with an implicit zero midpoint. + # The output is rounded to *prec* bits, and if the binary-to-decimal + # conversion is inexact, the resulting error is added to the radius. + # The symbols "inf" and "nan" are recognized (a nan midpoint results in an + # indeterminate interval, with infinite radius). + # Returns 0 if successful and nonzero if unsuccessful. If unsuccessful, + # the result is set to an indeterminate interval. + + char * arb_get_str(const arb_t x, long n, unsigned long flags) + # Returns a nice human-readable representation of *x*, with at most *n* + # digits of the midpoint printed. + # With default flags, the output can be parsed back with :func:`arb_set_str`, + # and this is guaranteed to produce an interval containing the original + # interval *x*. + # By default, the output is rounded so that the value given for the + # midpoint is correct up to 1 ulp (unit in the last decimal place). + # If *ARB_STR_MORE* is added to *flags*, more (possibly incorrect) + # digits may be printed. + # If *ARB_STR_NO_RADIUS* is added to *flags*, the radius is not + # included in the output. Unless *ARB_STR_MORE* is set, the output is + # rounded so that the midpoint is correct to 1 ulp. As a special case, + # if there are no significant digits after rounding, the result will + # be shown as ``0e+n``, meaning that the result is between + # ``-1e+n`` and ``1e+n`` (following the contract that the output is + # correct to within one unit in the only shown digit). + # By adding a multiple *m* of *ARB_STR_CONDENSE* to *flags*, strings + # of more than three times *m* consecutive digits are condensed, only + # printing the leading and trailing *m* digits along with + # brackets indicating the number of digits omitted + # (useful when computing values to extremely high precision). + + void arb_zero(arb_t x) + # Sets *x* to zero. + + void arb_one(arb_t f) + # Sets *x* to the exact integer 1. + + void arb_pos_inf(arb_t x) + # Sets *x* to positive infinity, with a zero radius. + + void arb_neg_inf(arb_t x) + # Sets *x* to negative infinity, with a zero radius. + + void arb_zero_pm_inf(arb_t x) + # Sets *x* to `[0 \pm \infty]`, representing the whole extended real line. + + void arb_indeterminate(arb_t x) + # Sets *x* to `[\operatorname{NaN} \pm \infty]`, representing + # an indeterminate result. + + void arb_zero_pm_one(arb_t x) + # Sets *x* to the interval `[0 \pm 1]`. + + void arb_unit_interval(arb_t x) + # Sets *x* to the interval `[0, 1]`. + + void arb_print(const arb_t x) + + void arb_fprint(FILE * file, const arb_t x) + # Prints the internal representation of *x*. + + void arb_printd(const arb_t x, long digits) + + void arb_fprintd(FILE * file, const arb_t x, long digits) + # Prints *x* in decimal. The printed value of the radius is not adjusted + # to compensate for the fact that the binary-to-decimal conversion + # of both the midpoint and the radius introduces additional error. + + void arb_printn(const arb_t x, long digits, unsigned long flags) + + void arb_fprintn(FILE * file, const arb_t x, long digits, unsigned long flags) + # Prints a nice decimal representation of *x*. + # By default, the output shows the midpoint with a guaranteed error of at + # most one unit in the last decimal place. In addition, an explicit error + # bound is printed so that the displayed decimal interval is guaranteed to + # enclose *x*. + # See :func:`arb_get_str` for details. + + char * arb_dump_str(const arb_t x) + # Returns a serialized representation of *x* as a null-terminated + # ASCII string that can be read by :func:`arb_load_str`. The format consists + # of four hexadecimal integers representing the midpoint mantissa, + # midpoint exponent, radius mantissa and radius exponent (with special + # values to indicate zero, infinity and NaN values), + # separated by single spaces. The returned string needs to be deallocated + # with *flint_free*. + + int arb_load_str(arb_t x, const char * str) + # Sets *x* to the serialized representation given in *str*. Returns a + # nonzero value if *str* is not formatted correctly (see :func:`arb_dump_str`). + + int arb_dump_file(FILE * stream, const arb_t x) + # Writes a serialized ASCII representation of *x* to *stream* in a form that + # can be read by :func:`arb_load_file`. Returns a nonzero value if the data + # could not be written. + + int arb_load_file(arb_t x, FILE * stream) + # Reads *x* from a serialized ASCII representation in *stream*. Returns a + # nonzero value if the data is not + # formatted correctly or the read failed. Note that the data is assumed to be + # delimited by a whitespace or end-of-file, i.e., when writing multiple + # values with :func:`arb_dump_file` make sure to insert a whitespace to + # separate consecutive values. + # It is possible to serialize and deserialize a vector as follows + # (warning: without error handling): + # .. code-block:: c + # fp = fopen("data.txt", "w"); + # for (i = 0; i < n; i++) + # { + # arb_dump_file(fp, vec + i); + # fprintf(fp, "\n"); // or any whitespace character + # } + # fclose(fp); + # fp = fopen("data.txt", "r"); + # for (i = 0; i < n; i++) + # { + # arb_load_file(vec + i, fp); + # } + # fclose(fp); + + void arb_randtest(arb_t x, flint_rand_t state, long prec, long mag_bits) + # Generates a random ball. The midpoint and radius will both be finite. + + void arb_randtest_exact(arb_t x, flint_rand_t state, long prec, long mag_bits) + # Generates a random number with zero radius. + + void arb_randtest_precise(arb_t x, flint_rand_t state, long prec, long mag_bits) + # Generates a random number with radius around `2^{-\text{prec}}` + # the magnitude of the midpoint. + + void arb_randtest_wide(arb_t x, flint_rand_t state, long prec, long mag_bits) + # Generates a random number with midpoint and radius chosen independently, + # possibly giving a very large interval. + + void arb_randtest_special(arb_t x, flint_rand_t state, long prec, long mag_bits) + # Generates a random interval, possibly having NaN or an infinity + # as the midpoint and possibly having an infinite radius. + + void arb_get_rand_fmpq(fmpq_t q, flint_rand_t state, const arb_t x, long bits) + # Sets *q* to a random rational number from the interval represented by *x*. + # A denominator is chosen by multiplying the binary denominator of *x* + # by a random integer up to *bits* bits. + # The outcome is undefined if the midpoint or radius of *x* is non-finite, + # or if the exponent of the midpoint or radius is so large or small + # that representing the endpoints as exact rational numbers would + # cause overflows. + + void arb_urandom(arb_t x, flint_rand_t state, long prec) + # Sets *x* to a uniformly distributed random number in the interval + # `[0, 1]`. The method uses rounding from integers to floats, hence the + # radius might not be `0`. + + void arb_get_mid_arb(arb_t m, const arb_t x) + # Sets *m* to the midpoint of *x*. + + void arb_get_rad_arb(arb_t r, const arb_t x) + # Sets *r* to the radius of *x*. + + void arb_add_error_arf(arb_t x, const arf_t err) + + void arb_add_error_mag(arb_t x, const mag_t err) + + void arb_add_error(arb_t x, const arb_t err) + # Adds the absolute value of *err* to the radius of *x* (the operation + # is done in-place). + + void arb_add_error_2exp_si(arb_t x, long e) + + void arb_add_error_2exp_fmpz(arb_t x, const fmpz_t e) + # Adds `2^e` to the radius of *x*. + + void arb_union(arb_t z, const arb_t x, const arb_t y, long prec) + # Sets *z* to a ball containing both *x* and *y*. + + int arb_intersection(arb_t z, const arb_t x, const arb_t y, long prec) + # If *x* and *y* overlap according to :func:`arb_overlaps`, + # then *z* is set to a ball containing the intersection of *x* and *y* + # and a nonzero value is returned. + # Otherwise zero is returned and the value of *z* is undefined. + # If *x* or *y* contains NaN, the result is NaN. + + void arb_nonnegative_part(arb_t res, const arb_t x) + # Sets *res* to the intersection of *x* with `[0,\infty]`. If *x* is + # nonnegative, an exact copy is made. If *x* is finite and contains negative + # numbers, an interval of the form `[r/2 \pm r/2]` is produced, which + # certainly contains no negative points. + # In the special case when *x* is strictly negative, *res* is set to zero. + + void arb_get_abs_ubound_arf(arf_t u, const arb_t x, long prec) + # Sets *u* to the upper bound for the absolute value of *x*, + # rounded up to *prec* bits. If *x* contains NaN, the result is NaN. + + void arb_get_abs_lbound_arf(arf_t u, const arb_t x, long prec) + # Sets *u* to the lower bound for the absolute value of *x*, + # rounded down to *prec* bits. If *x* contains NaN, the result is NaN. + + void arb_get_ubound_arf(arf_t u, const arb_t x, long prec) + # Sets *u* to the upper bound for the value of *x*, + # rounded up to *prec* bits. If *x* contains NaN, the result is NaN. + + void arb_get_lbound_arf(arf_t u, const arb_t x, long prec) + # Sets *u* to the lower bound for the value of *x*, + # rounded down to *prec* bits. If *x* contains NaN, the result is NaN. + + void arb_get_mag(mag_t z, const arb_t x) + # Sets *z* to an upper bound for the absolute value of *x*. If *x* contains + # NaN, the result is positive infinity. + + void arb_get_mag_lower(mag_t z, const arb_t x) + # Sets *z* to a lower bound for the absolute value of *x*. If *x* contains + # NaN, the result is zero. + + void arb_get_mag_lower_nonnegative(mag_t z, const arb_t x) + # Sets *z* to a lower bound for the signed value of *x*, or zero + # if *x* overlaps with the negative half-axis. If *x* contains NaN, + # the result is zero. + + void arb_get_interval_fmpz_2exp(fmpz_t a, fmpz_t b, fmpz_t exp, const arb_t x) + # Computes the exact interval represented by *x*, in the form of an integer + # interval multiplied by a power of two, i.e. `x = [a, b] \times 2^{\text{exp}}`. + # The result is normalized by removing common trailing zeros + # from *a* and *b*. + # This method aborts if *x* is infinite or NaN, or if the difference between + # the exponents of the midpoint and the radius is so large that allocating + # memory for the result fails. + # Warning: this method will allocate a huge amount of memory to store + # the result if the exponent difference is huge. Memory allocation could + # succeed even if the required space is far larger than the physical + # memory available on the machine, resulting in swapping. It is recommended + # to check that the midpoint and radius of *x* both are within a + # reasonable range before calling this method. + + void arb_set_interval_mag(arb_t x, const mag_t a, const mag_t b, long prec) + + void arb_set_interval_arf(arb_t x, const arf_t a, const arf_t b, long prec) + + void arb_set_interval_mpfr(arb_t x, const mpfr_t a, const mpfr_t b, long prec) + # Sets *x* to a ball containing the interval `[a, b]`. We + # require that `a \le b`. + + void arb_set_interval_neg_pos_mag(arb_t x, const mag_t a, const mag_t b, long prec) + # Sets *x* to a ball containing the interval `[-a, b]`. + + void arb_get_interval_arf(arf_t a, arf_t b, const arb_t x, long prec) + + void arb_get_interval_mpfr(mpfr_t a, mpfr_t b, const arb_t x) + # Constructs an interval `[a, b]` containing the ball *x*. The MPFR version + # uses the precision of the output variables. + + long arb_rel_error_bits(const arb_t x) + # Returns the effective relative error of *x* measured in bits, defined as + # the difference between the position of the top bit in the radius + # and the top bit in the midpoint, plus one. + # The result is clamped between plus/minus *ARF_PREC_EXACT*. + + long arb_rel_accuracy_bits(const arb_t x) + # Returns the effective relative accuracy of *x* measured in bits, + # equal to the negative of the return value from :func:`arb_rel_error_bits`. + + long arb_rel_one_accuracy_bits(const arb_t x) + # Given a ball with midpoint *m* and radius *r*, returns an approximation of + # the relative accuracy of `[\max(1,|m|) \pm r]` measured in bits. + + long arb_bits(const arb_t x) + # Returns the number of bits needed to represent the absolute value + # of the mantissa of the midpoint of *x*, i.e. the minimum precision + # sufficient to represent *x* exactly. Returns 0 if the midpoint + # of *x* is a special value. + + void arb_trim(arb_t y, const arb_t x) + # Sets *y* to a trimmed copy of *x*: rounds *x* to a number of bits + # equal to the accuracy of *x* (as indicated by its radius), + # plus a few guard bits. The resulting ball is guaranteed to + # contain *x*, but is more economical if *x* has + # less than full accuracy. + + int arb_get_unique_fmpz(fmpz_t z, const arb_t x) + # If *x* contains a unique integer, sets *z* to that value and returns + # nonzero. Otherwise (if *x* represents no integers or more than one integer), + # returns zero. + # This method aborts if there is a unique integer but that integer + # is so large that allocating memory for the result fails. + # Warning: this method will allocate a huge amount of memory to store + # the result if there is a unique integer and that integer is huge. + # Memory allocation could succeed even if the required space is far + # larger than the physical memory available on the machine, resulting + # in swapping. It is recommended to check that the midpoint of *x* is + # within a reasonable range before calling this method. + + void arb_floor(arb_t y, const arb_t x, long prec) + void arb_ceil(arb_t y, const arb_t x, long prec) + void arb_trunc(arb_t y, const arb_t x, long prec) + void arb_nint(arb_t y, const arb_t x, long prec) + # Sets *y* to a ball containing respectively, `\lfloor x \rfloor` and + # `\lceil x \rceil`, `\operatorname{trunc}(x)`, `\operatorname{nint}(x)`, + # with the midpoint of *y* rounded to at most *prec* bits. + + void arb_get_fmpz_mid_rad_10exp(fmpz_t mid, fmpz_t rad, fmpz_t exp, const arb_t x, long n) + # Assuming that *x* is finite and not exactly zero, computes integers *mid*, + # *rad*, *exp* such that `x \in [m-r, m+r] \times 10^e` and such that the + # larger out of *mid* and *rad* has at least *n* digits plus a few guard + # digits. If *x* is infinite or exactly zero, the outputs are all set + # to zero. + + int arb_can_round_arf(const arb_t x, long prec, arf_rnd_t rnd) + + int arb_can_round_mpfr(const arb_t x, long prec, mpfr_rnd_t rnd) + # Returns nonzero if rounding the midpoint of *x* to *prec* bits in + # the direction *rnd* is guaranteed to give the unique correctly + # rounded floating-point approximation for the real number represented by *x*. + # In other words, if this function returns nonzero, applying + # :func:`arf_set_round`, or :func:`arf_get_mpfr`, or :func:`arf_get_d` + # to the midpoint of *x* is guaranteed to return a correctly rounded *arf_t*, + # *mpfr_t* (provided that *prec* is the precision of the output variable), + # or *double* (provided that *prec* is 53). + # Moreover, :func:`arf_get_mpfr` is guaranteed to return the correct ternary + # value according to MPFR semantics. + # Note that the *mpfr* version of this function takes an MPFR rounding mode + # symbol as input, while the *arf* version takes an *arf* rounding mode + # symbol. Otherwise, the functions are identical. + # This function may perform a fast, inexact test; that is, it may return + # zero in some cases even when correct rounding actually is possible. + # To be conservative, zero is returned when *x* is non-finite, even if it + # is an "exact" infinity. + + int arb_is_zero(const arb_t x) + # Returns nonzero iff the midpoint and radius of *x* are both zero. + + int arb_is_nonzero(const arb_t x) + # Returns nonzero iff zero is not contained in the interval represented + # by *x*. + + int arb_is_one(const arb_t f) + # Returns nonzero iff *x* is exactly 1. + + int arb_is_finite(const arb_t x) + # Returns nonzero iff the midpoint and radius of *x* are both finite + # floating-point numbers, i.e. not infinities or NaN. + + int arb_is_exact(const arb_t x) + # Returns nonzero iff the radius of *x* is zero. + + int arb_is_int(const arb_t x) + # Returns nonzero iff *x* is an exact integer. + + int arb_is_int_2exp_si(const arb_t x, long e) + # Returns nonzero iff *x* exactly equals `n 2^e` for some integer *n*. + + int arb_equal(const arb_t x, const arb_t y) + # Returns nonzero iff *x* and *y* are equal as balls, i.e. have both the + # same midpoint and radius. + # Note that this is not the same thing as testing whether both + # *x* and *y* certainly represent the same real number, unless + # either *x* or *y* is exact (and neither contains NaN). + # To test whether both operands *might* represent the same mathematical + # quantity, use :func:`arb_overlaps` or :func:`arb_contains`, + # depending on the circumstance. + + int arb_equal_si(const arb_t x, long y) + # Returns nonzero iff *x* is equal to the integer *y*. + + int arb_is_positive(const arb_t x) + + int arb_is_nonnegative(const arb_t x) + + int arb_is_negative(const arb_t x) + + int arb_is_nonpositive(const arb_t x) + # Returns nonzero iff all points *p* in the interval represented by *x* + # satisfy, respectively, `p > 0`, `p \ge 0`, `p < 0`, `p \le 0`. + # If *x* contains NaN, returns zero. + + int arb_overlaps(const arb_t x, const arb_t y) + # Returns nonzero iff *x* and *y* have some point in common. + # If either *x* or *y* contains NaN, this function always returns nonzero + # (as a NaN could be anything, it could in particular contain any + # number that is included in the other operand). + + int arb_contains_arf(const arb_t x, const arf_t y) + + int arb_contains_fmpq(const arb_t x, const fmpq_t y) + + int arb_contains_fmpz(const arb_t x, const fmpz_t y) + + int arb_contains_si(const arb_t x, long y) + + int arb_contains_mpfr(const arb_t x, const mpfr_t y) + + int arb_contains(const arb_t x, const arb_t y) + # Returns nonzero iff the given number (or ball) *y* is contained in + # the interval represented by *x*. + # If *x* contains NaN, this function always returns nonzero (as it + # could represent anything, and in particular could represent all + # the points included in *y*). + # If *y* contains NaN and *x* does not, it always returns zero. + + int arb_contains_int(const arb_t x) + # Returns nonzero iff the interval represented by *x* contains an integer. + + int arb_contains_zero(const arb_t x) + + int arb_contains_negative(const arb_t x) + + int arb_contains_nonpositive(const arb_t x) + + int arb_contains_positive(const arb_t x) + + int arb_contains_nonnegative(const arb_t x) + # Returns nonzero iff there is any point *p* in the interval represented + # by *x* satisfying, respectively, `p = 0`, `p < 0`, `p \le 0`, `p > 0`, `p \ge 0`. + # If *x* contains NaN, returns nonzero. + + int arb_contains_interior(const arb_t x, const arb_t y) + # Tests if *y* is contained in the interior of *x*; that is, contained + # in *x* and not touching either endpoint. + + int arb_eq(const arb_t x, const arb_t y) + + int arb_ne(const arb_t x, const arb_t y) + + int arb_lt(const arb_t x, const arb_t y) + + int arb_le(const arb_t x, const arb_t y) + + int arb_gt(const arb_t x, const arb_t y) + + int arb_ge(const arb_t x, const arb_t y) + # Respectively performs the comparison `x = y`, `x \ne y`, + # `x < y`, `x \le y`, `x > y`, `x \ge y` in a mathematically meaningful way. + # If the comparison `t \, (\operatorname{op}) \, u` holds for all + # `t \in x` and all `u \in y`, returns 1. + # Otherwise, returns 0. + # The balls *x* and *y* are viewed as subintervals of the extended real line. + # Note that balls that are formally different can compare as equal + # under this definition: for example, `[-\infty \pm 3] = [-\infty \pm 0]`. + # Also `[-\infty] \le [\infty \pm \infty]`. + # The output is always 0 if either input has NaN as midpoint. + + void arb_neg(arb_t y, const arb_t x) + + void arb_neg_round(arb_t y, const arb_t x, long prec) + # Sets *y* to the negation of *x*. + + void arb_abs(arb_t y, const arb_t x) + # Sets *y* to the absolute value of *x*. No attempt is made to improve the + # interval represented by *x* if it contains zero. + + void arb_nonnegative_abs(arb_t y, const arb_t x) + # Sets *y* to the absolute value of *x*. If *x* is finite and it contains + # zero, sets *y* to some interval `[r \pm r]` that contains the absolute + # value of *x*. + + void arb_sgn(arb_t y, const arb_t x) + # Sets *y* to the sign function of *x*. The result is `[0 \pm 1]` if + # *x* contains both zero and nonzero numbers. + + int arb_sgn_nonzero(const arb_t x) + # Returns 1 if *x* is strictly positive, -1 if *x* is strictly negative, + # and 0 if *x* is zero or a ball containing zero so that its sign + # is not determined. + + void arb_min(arb_t z, const arb_t x, const arb_t y, long prec) + + void arb_max(arb_t z, const arb_t x, const arb_t y, long prec) + # Sets *z* respectively to the minimum and the maximum of *x* and *y*. + + void arb_add(arb_t z, const arb_t x, const arb_t y, long prec) + + void arb_add_arf(arb_t z, const arb_t x, const arf_t y, long prec) + + void arb_add_ui(arb_t z, const arb_t x, unsigned long y, long prec) + + void arb_add_si(arb_t z, const arb_t x, long y, long prec) + + void arb_add_fmpz(arb_t z, const arb_t x, const fmpz_t y, long prec) + # Sets `z = x + y`, rounded to *prec* bits. The precision can be + # *ARF_PREC_EXACT* provided that the result fits in memory. + + void arb_add_fmpz_2exp(arb_t z, const arb_t x, const fmpz_t m, const fmpz_t e, long prec) + # Sets `z = x + m \cdot 2^e`, rounded to *prec* bits. The precision can be + # *ARF_PREC_EXACT* provided that the result fits in memory. + + void arb_sub(arb_t z, const arb_t x, const arb_t y, long prec) + + void arb_sub_arf(arb_t z, const arb_t x, const arf_t y, long prec) + + void arb_sub_ui(arb_t z, const arb_t x, unsigned long y, long prec) + + void arb_sub_si(arb_t z, const arb_t x, long y, long prec) + + void arb_sub_fmpz(arb_t z, const arb_t x, const fmpz_t y, long prec) + # Sets `z = x - y`, rounded to *prec* bits. The precision can be + # *ARF_PREC_EXACT* provided that the result fits in memory. + + void arb_mul(arb_t z, const arb_t x, const arb_t y, long prec) + + void arb_mul_arf(arb_t z, const arb_t x, const arf_t y, long prec) + + void arb_mul_si(arb_t z, const arb_t x, long y, long prec) + + void arb_mul_ui(arb_t z, const arb_t x, unsigned long y, long prec) + + void arb_mul_fmpz(arb_t z, const arb_t x, const fmpz_t y, long prec) + # Sets `z = x \cdot y`, rounded to *prec* bits. The precision can be + # *ARF_PREC_EXACT* provided that the result fits in memory. + + void arb_mul_2exp_si(arb_t y, const arb_t x, long e) + + void arb_mul_2exp_fmpz(arb_t y, const arb_t x, const fmpz_t e) + # Sets *y* to *x* multiplied by `2^e`. + + void arb_addmul(arb_t z, const arb_t x, const arb_t y, long prec) + + void arb_addmul_arf(arb_t z, const arb_t x, const arf_t y, long prec) + + void arb_addmul_si(arb_t z, const arb_t x, long y, long prec) + + void arb_addmul_ui(arb_t z, const arb_t x, unsigned long y, long prec) + + void arb_addmul_fmpz(arb_t z, const arb_t x, const fmpz_t y, long prec) + # Sets `z = z + x \cdot y`, rounded to prec bits. The precision can be + # *ARF_PREC_EXACT* provided that the result fits in memory. + + void arb_submul(arb_t z, const arb_t x, const arb_t y, long prec) + + void arb_submul_arf(arb_t z, const arb_t x, const arf_t y, long prec) + + void arb_submul_si(arb_t z, const arb_t x, long y, long prec) + + void arb_submul_ui(arb_t z, const arb_t x, unsigned long y, long prec) + + void arb_submul_fmpz(arb_t z, const arb_t x, const fmpz_t y, long prec) + # Sets `z = z - x \cdot y`, rounded to prec bits. The precision can be + # *ARF_PREC_EXACT* provided that the result fits in memory. + + void arb_fma(arb_t res, const arb_t x, const arb_t y, const arb_t z, long prec) + void arb_fma_arf(arb_t res, const arb_t x, const arf_t y, const arb_t z, long prec) + void arb_fma_si(arb_t res, const arb_t x, long y, const arb_t z, long prec) + void arb_fma_ui(arb_t res, const arb_t x, unsigned long y, const arb_t z, long prec) + void arb_fma_fmpz(arb_t res, const arb_t x, const fmpz_t y, const arb_t z, long prec) + # Sets *res* to `x \cdot y + z`. This is equivalent to an *addmul* except + # that *res* and *z* can be separate variables. + + void arb_inv(arb_t z, const arb_t x, long prec) + # Sets *z* to `1 / x`. + + void arb_div(arb_t z, const arb_t x, const arb_t y, long prec) + + void arb_div_arf(arb_t z, const arb_t x, const arf_t y, long prec) + + void arb_div_si(arb_t z, const arb_t x, long y, long prec) + + void arb_div_ui(arb_t z, const arb_t x, unsigned long y, long prec) + + void arb_div_fmpz(arb_t z, const arb_t x, const fmpz_t y, long prec) + + void arb_fmpz_div_fmpz(arb_t z, const fmpz_t x, const fmpz_t y, long prec) + + void arb_ui_div(arb_t z, unsigned long x, const arb_t y, long prec) + # Sets `z = x / y`, rounded to *prec* bits. If *y* contains zero, *z* is + # set to `0 \pm \infty`. Otherwise, error propagation uses the rule + # .. math :: + # \left| \frac{x}{y} - \frac{x+\xi_1 a}{y+\xi_2 b} \right| = + # \left|\frac{x \xi_2 b - y \xi_1 a}{y (y+\xi_2 b)}\right| \le + # \frac{|xb|+|ya|}{|y| (|y|-b)} + # where `-1 \le \xi_1, \xi_2 \le 1`, and + # where the triangle inequality has been applied to the numerator and + # the reverse triangle inequality has been applied to the denominator. + + void arb_div_2expm1_ui(arb_t z, const arb_t x, unsigned long n, long prec) + # Sets `z = x / (2^n - 1)`, rounded to *prec* bits. + + void arb_dot_precise(arb_t res, const arb_t s, int subtract, arb_srcptr x, long xstep, arb_srcptr y, long ystep, long len, long prec) + void arb_dot_simple(arb_t res, const arb_t s, int subtract, arb_srcptr x, long xstep, arb_srcptr y, long ystep, long len, long prec) + void arb_dot(arb_t res, const arb_t s, int subtract, arb_srcptr x, long xstep, arb_srcptr y, long ystep, long len, long prec) + # Computes the dot product of the vectors *x* and *y*, setting + # *res* to `s + (-1)^{subtract} \sum_{i=0}^{len-1} x_i y_i`. + # The initial term *s* is optional and can be + # omitted by passing *NULL* (equivalently, `s = 0`). + # The parameter *subtract* must be 0 or 1. + # The length *len* is allowed to be negative, which is equivalent + # to a length of zero. + # The parameters *xstep* or *ystep* specify a step length for + # traversing subsequences of the vectors *x* and *y*; either can be + # negative to step in the reverse direction starting from + # the initial pointer. + # Aliasing is allowed between *res* and *s* but not between + # *res* and the entries of *x* and *y*. + # The default version determines the optimal precision for each term + # and performs all internal calculations using mpn arithmetic + # with minimal overhead. This is the preferred way to compute a + # dot product; it is generally much faster and more precise + # than a simple loop. + # The *simple* version performs fused multiply-add operations in + # a simple loop. This can be used for + # testing purposes and is also used as a fallback by the + # default version when the exponents are out of range + # for the optimized code. + # The *precise* version computes the dot product exactly up to the + # final rounding. This can be extremely slow and is only intended + # for testing. + + void arb_approx_dot(arb_t res, const arb_t s, int subtract, arb_srcptr x, long xstep, arb_srcptr y, long ystep, long len, long prec) + # Computes an approximate dot product *without error bounds*. + # The radii of the inputs are ignored (only the midpoints are read) + # and only the midpoint of the output is written. + + void arb_dot_ui(arb_t res, const arb_t initial, int subtract, arb_srcptr x, long xstep, const unsigned long * y, long ystep, long len, long prec) + void arb_dot_si(arb_t res, const arb_t initial, int subtract, arb_srcptr x, long xstep, const long * y, long ystep, long len, long prec) + void arb_dot_uiui(arb_t res, const arb_t initial, int subtract, arb_srcptr x, long xstep, const unsigned long * y, long ystep, long len, long prec) + void arb_dot_siui(arb_t res, const arb_t initial, int subtract, arb_srcptr x, long xstep, const unsigned long * y, long ystep, long len, long prec) + void arb_dot_fmpz(arb_t res, const arb_t initial, int subtract, arb_srcptr x, long xstep, const fmpz * y, long ystep, long len, long prec) + # Equivalent to :func:`arb_dot`, but with integers in the array *y*. + # The *uiui* and *siui* versions take an array of double-limb integers + # as input; the *siui* version assumes that these represent signed + # integers in two's complement form. + + void arb_sqrt(arb_t z, const arb_t x, long prec) + + void arb_sqrt_arf(arb_t z, const arf_t x, long prec) + + void arb_sqrt_fmpz(arb_t z, const fmpz_t x, long prec) + + void arb_sqrt_ui(arb_t z, unsigned long x, long prec) + # Sets *z* to the square root of *x*, rounded to *prec* bits. + # If `x = m \pm x` where `m \ge r \ge 0`, the propagated error is bounded by + # `\sqrt{m} - \sqrt{m-r} = \sqrt{m} (1 - \sqrt{1 - r/m}) \le \sqrt{m} (r/m + (r/m)^2)/2`. + + void arb_sqrtpos(arb_t z, const arb_t x, long prec) + # Sets *z* to the square root of *x*, assuming that *x* represents a + # nonnegative number (i.e. discarding any negative numbers in the input + # interval). + + void arb_hypot(arb_t z, const arb_t x, const arb_t y, long prec) + # Sets *z* to `\sqrt{x^2 + y^2}`. + + void arb_rsqrt(arb_t z, const arb_t x, long prec) + + void arb_rsqrt_ui(arb_t z, unsigned long x, long prec) + # Sets *z* to the reciprocal square root of *x*, rounded to *prec* bits. + # At high precision, this is faster than computing a square root. + + void arb_sqrt1pm1(arb_t z, const arb_t x, long prec) + # Sets `z = \sqrt{1+x}-1`, computed accurately when `x \approx 0`. + + void arb_root_ui(arb_t z, const arb_t x, unsigned long k, long prec) + # Sets *z* to the *k*-th root of *x*, rounded to *prec* bits. + # This function selects between different algorithms. For large *k*, + # it evaluates `\exp(\log(x)/k)`. For small *k*, it uses :func:`arf_root` + # at the midpoint and computes a propagated error bound as follows: + # if input interval is `[m-r, m+r]` with `r \le m`, the error is largest at + # `m-r` where it satisfies + # .. math :: + # m^{1/k} - (m-r)^{1/k} = m^{1/k} [1 - (1-r/m)^{1/k}] + # = m^{1/k} [1 - \exp(\log(1-r/m)/k)] + # \le m^{1/k} \min(1, -\log(1-r/m)/k) + # = m^{1/k} \min(1, \log(1+r/(m-r))/k). + # This is evaluated using :func:`mag_log1p`. + + void arb_root(arb_t z, const arb_t x, unsigned long k, long prec) + # Alias for :func:`arb_root_ui`, provided for backwards compatibility. + + void arb_sqr(arb_t y, const arb_t x, long prec) + # Sets *y* to be the square of *x*. + + void arb_pow_fmpz_binexp(arb_t y, const arb_t b, const fmpz_t e, long prec) + + void arb_pow_fmpz(arb_t y, const arb_t b, const fmpz_t e, long prec) + + void arb_pow_ui(arb_t y, const arb_t b, unsigned long e, long prec) + + void arb_ui_pow_ui(arb_t y, unsigned long b, unsigned long e, long prec) + + void arb_si_pow_ui(arb_t y, long b, unsigned long e, long prec) + # Sets `y = b^e` using binary exponentiation (with an initial division + # if `e < 0`). Provided that *b* and *e* + # are small enough and the exponent is positive, the exact power can be + # computed by setting the precision to *ARF_PREC_EXACT*. + # Note that these functions can get slow if the exponent is + # extremely large (in such cases :func:`arb_pow` may be superior). + + void arb_pow_fmpq(arb_t y, const arb_t x, const fmpq_t a, long prec) + # Sets `y = b^e`, computed as `y = (b^{1/q})^p` if the denominator of + # `e = p/q` is small, and generally as `y = \exp(e \log b)`. + # Note that this function can get slow if the exponent is + # extremely large (in such cases :func:`arb_pow` may be superior). + + void arb_pow(arb_t z, const arb_t x, const arb_t y, long prec) + # Sets `z = x^y`, computed using binary exponentiation if `y` is + # a small exact integer, as `z = (x^{1/2})^{2y}` if `y` is a small exact + # half-integer, and generally as `z = \exp(y \log x)`, except giving the + # obvious finite result if `x` is `a \pm a` and `y` is positive. + + void arb_log_ui(arb_t z, unsigned long x, long prec) + + void arb_log_fmpz(arb_t z, const fmpz_t x, long prec) + + void arb_log_arf(arb_t z, const arf_t x, long prec) + + void arb_log(arb_t z, const arb_t x, long prec) + # Sets `z = \log(x)`. + # At low to medium precision (up to about 4096 bits), :func:`arb_log_arf` + # uses table-based argument reduction and fast Taylor series evaluation + # via :func:`_arb_atan_taylor_rs`. At high precision, it falls back to MPFR. + # The function :func:`arb_log` simply calls :func:`arb_log_arf` with + # the midpoint as input, and separately adds the propagated error. + + void arb_log_ui_from_prev(arb_t log_k1, unsigned long k1, arb_t log_k0, unsigned long k0, long prec) + # Computes `\log(k_1)`, given `\log(k_0)` where `k_0 < k_1`. + # At high precision, this function uses the formula + # `\log(k_1) = \log(k_0) + 2 \operatorname{atanh}((k_1-k_0)/(k_1+k_0))`, + # evaluating the inverse hyperbolic tangent using binary splitting + # (for best efficiency, `k_0` should be large and `k_1 - k_0` should + # be small). Otherwise, it ignores `\log(k_0)` and evaluates the logarithm + # the usual way. + + void arb_log1p(arb_t z, const arb_t x, long prec) + # Sets `z = \log(1+x)`, computed accurately when `x \approx 0`. + + void arb_log_base_ui(arb_t res, const arb_t x, unsigned long b, long prec) + # Sets *res* to `\log_b(x)`. The result is computed exactly when possible. + + void arb_log_hypot(arb_t res, const arb_t x, const arb_t y, long prec) + # Sets *res* to `\log(\sqrt{x^2+y^2})`. + + void arb_exp(arb_t z, const arb_t x, long prec) + # Sets `z = \exp(x)`. Error propagation is done using the following rule: + # assuming `x = m \pm r`, the error is largest at `m + r`, and we have + # `\exp(m+r) - \exp(m) = \exp(m) (\exp(r)-1) \le r \exp(m+r)`. + + void arb_expm1(arb_t z, const arb_t x, long prec) + # Sets `z = \exp(x)-1`, using a more accurate method when `x \approx 0`. + + void arb_exp_invexp(arb_t z, arb_t w, const arb_t x, long prec) + # Sets `z = \exp(x)` and `w = \exp(-x)`. The second exponential is computed + # from the first using a division, but propagated error bounds are + # computed separately. + + void arb_sin(arb_t s, const arb_t x, long prec) + + void arb_cos(arb_t c, const arb_t x, long prec) + + void arb_sin_cos(arb_t s, arb_t c, const arb_t x, long prec) + # Sets `s = \sin(x)`, `c = \cos(x)`. + + void arb_sin_pi(arb_t s, const arb_t x, long prec) + + void arb_cos_pi(arb_t c, const arb_t x, long prec) + + void arb_sin_cos_pi(arb_t s, arb_t c, const arb_t x, long prec) + # Sets `s = \sin(\pi x)`, `c = \cos(\pi x)`. + + void arb_tan(arb_t y, const arb_t x, long prec) + # Sets `y = \tan(x) = \sin(x) / \cos(y)`. + + void arb_cot(arb_t y, const arb_t x, long prec) + # Sets `y = \cot(x) = \cos(x) / \sin(y)`. + + void arb_sin_cos_pi_fmpq(arb_t s, arb_t c, const fmpq_t x, long prec) + + void arb_sin_pi_fmpq(arb_t s, const fmpq_t x, long prec) + + void arb_cos_pi_fmpq(arb_t c, const fmpq_t x, long prec) + # Sets `s = \sin(\pi x)`, `c = \cos(\pi x)` where `x` is a rational + # number (whose numerator and denominator are assumed to be reduced). + # We first use trigonometric symmetries to reduce the argument to the + # octant `[0, 1/4]`. Then we either multiply by a numerical approximation + # of `\pi` and evaluate the trigonometric function the usual way, + # or we use algebraic methods, depending on which is estimated to be faster. + # Since the argument has been reduced to the first octant, the + # first of these two methods gives full accuracy even if the original + # argument is close to some root other the origin. + + void arb_tan_pi(arb_t y, const arb_t x, long prec) + # Sets `y = \tan(\pi x)`. + + void arb_cot_pi(arb_t y, const arb_t x, long prec) + # Sets `y = \cot(\pi x)`. + + void arb_sec(arb_t res, const arb_t x, long prec) + # Computes `\sec(x) = 1 / \cos(x)`. + + void arb_csc(arb_t res, const arb_t x, long prec) + # Computes `\csc(x) = 1 / \sin(x)`. + + void arb_csc_pi(arb_t res, const arb_t x, long prec) + # Computes `\csc(\pi x) = 1 / \sin(\pi x)`. + + void arb_sinc(arb_t z, const arb_t x, long prec) + # Sets `z = \operatorname{sinc}(x) = \sin(x) / x`. + + void arb_sinc_pi(arb_t z, const arb_t x, long prec) + # Sets `z = \operatorname{sinc}(\pi x) = \sin(\pi x) / (\pi x)`. + + void arb_atan_arf(arb_t z, const arf_t x, long prec) + + void arb_atan(arb_t z, const arb_t x, long prec) + # Sets `z = \operatorname{atan}(x)`. + # At low to medium precision (up to about 4096 bits), :func:`arb_atan_arf` + # uses table-based argument reduction and fast Taylor series evaluation + # via :func:`_arb_atan_taylor_rs`. At high precision, it falls back to MPFR. + # The function :func:`arb_atan` simply calls :func:`arb_atan_arf` with + # the midpoint as input, and separately adds the propagated error. + # The function :func:`arb_atan_arf` uses lookup tables if + # possible, and otherwise falls back to :func:`arb_atan_arf_bb`. + + void arb_atan2(arb_t z, const arb_t b, const arb_t a, long prec) + # Sets *r* to an the argument (phase) of the complex number + # `a + bi`, with the branch cut discontinuity on `(-\infty,0]`. + # We define `\operatorname{atan2}(0,0) = 0`, and for `a < 0`, + # `\operatorname{atan2}(0,a) = \pi`. + + void arb_asin(arb_t z, const arb_t x, long prec) + # Sets `z = \operatorname{asin}(x) = \operatorname{atan}(x / \sqrt{1-x^2})`. + # If `x` is not contained in the domain `[-1,1]`, the result is an + # indeterminate interval. + + void arb_acos(arb_t z, const arb_t x, long prec) + # Sets `z = \operatorname{acos}(x) = \pi/2 - \operatorname{asin}(x)`. + # If `x` is not contained in the domain `[-1,1]`, the result is an + # indeterminate interval. + + void arb_sinh(arb_t s, const arb_t x, long prec) + + void arb_cosh(arb_t c, const arb_t x, long prec) + + void arb_sinh_cosh(arb_t s, arb_t c, const arb_t x, long prec) + # Sets `s = \sinh(x)`, `c = \cosh(x)`. If the midpoint of `x` is close + # to zero and the hyperbolic sine is to be computed, + # evaluates `(e^{2x}\pm1) / (2e^x)` via :func:`arb_expm1` + # to avoid loss of accuracy. Otherwise evaluates `(e^x \pm e^{-x}) / 2`. + + void arb_tanh(arb_t y, const arb_t x, long prec) + # Sets `y = \tanh(x) = \sinh(x) / \cosh(x)`, evaluated + # via :func:`arb_expm1` as `\tanh(x) = (e^{2x} - 1) / (e^{2x} + 1)` + # if `|x|` is small, and as + # `\tanh(\pm x) = 1 - 2 e^{\mp 2x} / (1 + e^{\mp 2x})` + # if `|x|` is large. + + void arb_coth(arb_t y, const arb_t x, long prec) + # Sets `y = \coth(x) = \cosh(x) / \sinh(x)`, evaluated using + # the same strategy as :func:`arb_tanh`. + + void arb_sech(arb_t res, const arb_t x, long prec) + # Computes `\operatorname{sech}(x) = 1 / \cosh(x)`. + + void arb_csch(arb_t res, const arb_t x, long prec) + # Computes `\operatorname{csch}(x) = 1 / \sinh(x)`. + + void arb_atanh(arb_t z, const arb_t x, long prec) + # Sets `z = \operatorname{atanh}(x)`. + + void arb_asinh(arb_t z, const arb_t x, long prec) + # Sets `z = \operatorname{asinh}(x)`. + + void arb_acosh(arb_t z, const arb_t x, long prec) + # Sets `z = \operatorname{acosh}(x)`. + # If `x < 1`, the result is an indeterminate interval. + + void arb_const_pi(arb_t z, long prec) + # Computes `\pi`. + + void arb_const_sqrt_pi(arb_t z, long prec) + # Computes `\sqrt{\pi}`. + + void arb_const_log_sqrt2pi(arb_t z, long prec) + # Computes `\log \sqrt{2 \pi}`. + + void arb_const_log2(arb_t z, long prec) + # Computes `\log(2)`. + + void arb_const_log10(arb_t z, long prec) + # Computes `\log(10)`. + + void arb_const_euler(arb_t z, long prec) + # Computes Euler's constant `\gamma = \lim_{k \rightarrow \infty} (H_k - \log k)` + # where `H_k = 1 + 1/2 + \ldots + 1/k`. + + void arb_const_catalan(arb_t z, long prec) + # Computes Catalan's constant `C = \sum_{n=0}^{\infty} (-1)^n / (2n+1)^2`. + + void arb_const_e(arb_t z, long prec) + # Computes `e = \exp(1)`. + + void arb_const_khinchin(arb_t z, long prec) + # Computes Khinchin's constant `K_0`. + + void arb_const_glaisher(arb_t z, long prec) + # Computes the Glaisher-Kinkelin constant `A = \exp(1/12 - \zeta'(-1))`. + + void arb_const_apery(arb_t z, long prec) + # Computes Apery's constant `\zeta(3)`. + + void arb_lambertw(arb_t res, const arb_t x, int flags, long prec) + # Computes the Lambert W function, which solves the equation `w e^w = x`. + # The Lambert W function has infinitely many complex branches `W_k(x)`, + # two of which are real on a part of the real line. + # The principal branch `W_0(x)` is selected by setting *flags* to 0, and the + # `W_{-1}` branch is selected by setting *flags* to 1. + # The principal branch is real-valued for `x \ge -1/e` + # (taking values in `[-1,+\infty)`) and the `W_{-1}` branch is real-valued + # for `-1/e \le x < 0` and takes values in `(-\infty,-1]`. + # Elsewhere, the Lambert W function is complex and :func:`acb_lambertw` + # should be used. + # The implementation first computes a floating-point approximation + # heuristically and then computes a rigorously certified enclosure around + # this approximation. Some asymptotic cases are handled specially. + # The algorithm used to compute the Lambert W function is described + # in [Joh2017b]_, which follows the main ideas in [CGHJK1996]_. + + void arb_rising_ui(arb_t z, const arb_t x, unsigned long n, long prec) + void arb_rising(arb_t z, const arb_t x, const arb_t n, long prec) + # Computes the rising factorial `z = x (x+1) (x+2) \cdots (x+n-1)`. + # These functions are aliases for :func:`arb_hypgeom_rising_ui` + # and :func:`arb_hypgeom_rising`. + + void arb_rising_fmpq_ui(arb_t z, const fmpq_t x, unsigned long n, long prec) + # Computes the rising factorial `z = x (x+1) (x+2) \cdots (x+n-1)` using + # binary splitting. If the denominator or numerator of *x* is large + # compared to *prec*, it is more efficient to convert *x* to an approximation + # and use :func:`arb_rising_ui`. + + void arb_fac_ui(arb_t z, unsigned long n, long prec) + # Computes the factorial `z = n!` via the gamma function. + + void arb_doublefac_ui(arb_t z, unsigned long n, long prec) + # Computes the double factorial `z = n!!` via the gamma function. + + void arb_bin_ui(arb_t z, const arb_t n, unsigned long k, long prec) + + void arb_bin_uiui(arb_t z, unsigned long n, unsigned long k, long prec) + # Computes the binomial coefficient `z = {n \choose k}`, via the + # rising factorial as `{n \choose k} = (n-k+1)_k / k!`. + + void arb_gamma(arb_t z, const arb_t x, long prec) + void arb_gamma_fmpq(arb_t z, const fmpq_t x, long prec) + void arb_gamma_fmpz(arb_t z, const fmpz_t x, long prec) + # Computes the gamma function `z = \Gamma(x)`. + # These functions are aliases for :func:`arb_hypgeom_gamma`, + # :func:`arb_hypgeom_gamma_fmpq`, :func:`arb_hypgeom_gamma_fmpz`. + + void arb_lgamma(arb_t z, const arb_t x, long prec) + # Computes the logarithmic gamma function `z = \log \Gamma(x)`. + # The complex branch structure is assumed, so if `x \le 0`, the + # result is an indeterminate interval. + # This function is an alias for :func:`arb_hypgeom_lgamma`. + + void arb_rgamma(arb_t z, const arb_t x, long prec) + # Computes the reciprocal gamma function `z = 1/\Gamma(x)`, + # avoiding division by zero at the poles of the gamma function. + # This function is an alias for :func:`arb_hypgeom_rgamma`. + + void arb_digamma(arb_t y, const arb_t x, long prec) + # Computes the digamma function `z = \psi(x) = (\log \Gamma(x))' = \Gamma'(x) / \Gamma(x)`. + + void arb_zeta_ui_vec_borwein(arb_ptr z, unsigned long start, long num, unsigned long step, long prec) + # Evaluates `\zeta(s)` at `\mathrm{num}` consecutive integers *s* beginning + # with *start* and proceeding in increments of *step*. + # Uses Borwein's formula ([Bor2000]_, [GS2003]_), + # implemented to support fast multi-evaluation + # (but also works well for a single *s*). + # Requires `\mathrm{start} \ge 2`. For efficiency, the largest *s* + # should be at most about as + # large as *prec*. Arguments approaching *LONG_MAX* will cause + # overflows. + # One should therefore only use this function for *s* up to about *prec*, and + # then switch to the Euler product. + # The algorithm for single *s* is basically identical to the one used in MPFR + # (see [MPFR2012]_ for a detailed description). + # In particular, we evaluate the sum backwards to avoid storing more than one + # `d_k` coefficient, and use integer arithmetic throughout since it + # is convenient and the terms turn out to be slightly larger than + # `2^\mathrm{prec}`. + # The only numerical error in the main loop comes from the division by `k^s`, + # which adds less than 1 unit of error per term. + # For fast multi-evaluation, we repeatedly divide by `k^{\mathrm{step}}`. + # Each division reduces the input error and adds at most 1 unit of + # additional rounding error, so by induction, the error per term + # is always smaller than 2 units. + + void arb_zeta_ui_asymp(arb_t x, unsigned long s, long prec) + + void arb_zeta_ui_euler_product(arb_t z, unsigned long s, long prec) + # Computes `\zeta(s)` using the Euler product. This is fast only if *s* + # is large compared to the precision. Both methods are trivial wrappers + # for :func:`_acb_dirichlet_euler_product_real_ui`. + + void arb_zeta_ui_bernoulli(arb_t x, unsigned long s, long prec) + # Computes `\zeta(s)` for even *s* via the corresponding Bernoulli number. + + void arb_zeta_ui_borwein_bsplit(arb_t x, unsigned long s, long prec) + # Computes `\zeta(s)` for arbitrary `s \ge 2` using a binary splitting + # implementation of Borwein's algorithm. This has quasilinear complexity + # with respect to the precision (assuming that `s` is fixed). + + void arb_zeta_ui_vec(arb_ptr x, unsigned long start, long num, long prec) + + void arb_zeta_ui_vec_even(arb_ptr x, unsigned long start, long num, long prec) + + void arb_zeta_ui_vec_odd(arb_ptr x, unsigned long start, long num, long prec) + # Computes `\zeta(s)` at *num* consecutive integers (respectively *num* + # even or *num* odd integers) beginning with `s = \mathrm{start} \ge 2`, + # automatically choosing an appropriate algorithm. + + void arb_zeta_ui(arb_t x, unsigned long s, long prec) + # Computes `\zeta(s)` for nonnegative integer `s \ne 1`, automatically + # choosing an appropriate algorithm. This function is + # intended for numerical evaluation of isolated zeta values; for + # multi-evaluation, the vector versions are more efficient. + + void arb_zeta(arb_t z, const arb_t s, long prec) + # Sets *z* to the value of the Riemann zeta function `\zeta(s)`. + # For computing derivatives with respect to `s`, + # use :func:`arb_poly_zeta_series`. + + void arb_hurwitz_zeta(arb_t z, const arb_t s, const arb_t a, long prec) + # Sets *z* to the value of the Hurwitz zeta function `\zeta(s,a)`. + # For computing derivatives with respect to `s`, + # use :func:`arb_poly_zeta_series`. + + void arb_bernoulli_ui(arb_t b, unsigned long n, long prec) + + void arb_bernoulli_fmpz(arb_t b, const fmpz_t n, long prec) + # Sets `b` to the numerical value of the Bernoulli number `B_n` + # approximated to *prec* bits. + # The internal precision is increased automatically to give an accurate + # result. Note that, with huge *fmpz* input, the output will have a huge + # exponent and evaluation will accordingly be slower. + # A single division from the exact fraction of `B_n` is used if this value + # is in the global cache or the exact numerator roughly is larger than + # *prec* bits. Otherwise, the Riemann zeta function is used + # (see :func:`arb_bernoulli_ui_zeta`). + # This function reads `B_n` from the global cache + # if the number is already cached, but does not automatically extend + # the cache by itself. + + void arb_bernoulli_ui_zeta(arb_t b, unsigned long n, long prec) + # Sets `b` to the numerical value of `B_n` accurate to *prec* bits, + # computed using the formula `B_{2n} = (-1)^{n+1} 2 (2n)! \zeta(2n) / (2 \pi)^n`. + # To avoid potential infinite recursion, we explicitly call the + # Euler product implementation of the zeta function. + # This method will only give high accuracy if the precision is small + # enough compared to `n` for the Euler product to converge rapidly. + + void arb_bernoulli_poly_ui(arb_t res, unsigned long n, const arb_t x, long prec) + # Sets *res* to the value of the Bernoulli polynomial `B_n(x)`. + # Warning: this function is only fast if either *n* or *x* is a small integer. + # This function reads Bernoulli numbers from the global cache if they + # are already cached, but does not automatically extend the cache by itself. + + void arb_power_sum_vec(arb_ptr res, const arb_t a, const arb_t b, long len, long prec) + # For *n* from 0 to *len* - 1, sets entry *n* in the output vector *res* to + # .. math :: + # S_n(a,b) = \frac{1}{n+1}\left(B_{n+1}(b) - B_{n+1}(a)\right) + # where `B_n(x)` is a Bernoulli polynomial. If *a* and *b* are integers + # and `b \ge a`, this is equivalent to + # .. math :: + # S_n(a,b) = \sum_{k=a}^{b-1} k^n. + # The computation uses the generating function for Bernoulli polynomials. + + void arb_polylog(arb_t w, const arb_t s, const arb_t z, long prec) + + void arb_polylog_si(arb_t w, long s, const arb_t z, long prec) + # Sets *w* to the polylogarithm `\operatorname{Li}_s(z)`. + + void arb_fib_fmpz(arb_t z, const fmpz_t n, long prec) + void arb_fib_ui(arb_t z, unsigned long n, long prec) + # Computes the Fibonacci number `F_n` using binary squaring. + + void arb_agm(arb_t z, const arb_t x, const arb_t y, long prec) + # Sets *z* to the arithmetic-geometric mean of *x* and *y*. + + void arb_chebyshev_t_ui(arb_t a, unsigned long n, const arb_t x, long prec) + + void arb_chebyshev_u_ui(arb_t a, unsigned long n, const arb_t x, long prec) + # Evaluates the Chebyshev polynomial of the first kind `a = T_n(x)` + # or the Chebyshev polynomial of the second kind `a = U_n(x)`. + + void arb_chebyshev_t2_ui(arb_t a, arb_t b, unsigned long n, const arb_t x, long prec) + + void arb_chebyshev_u2_ui(arb_t a, arb_t b, unsigned long n, const arb_t x, long prec) + # Simultaneously evaluates `a = T_n(x), b = T_{n-1}(x)` or + # `a = U_n(x), b = U_{n-1}(x)`. + # Aliasing between *a*, *b* and *x* is not permitted. + + void arb_bell_sum_bsplit(arb_t res, const fmpz_t n, const fmpz_t a, const fmpz_t b, const fmpz_t mmag, long prec) + + void arb_bell_sum_taylor(arb_t res, const fmpz_t n, const fmpz_t a, const fmpz_t b, const fmpz_t mmag, long prec) + # Helper functions for Bell numbers, evaluating the sum + # `\sum_{k=a}^{b-1} k^n / k!`. If *mmag* is non-NULL, it may be used + # to indicate that the target error tolerance should be + # `2^{mmag - prec}`. + + void arb_bell_fmpz(arb_t res, const fmpz_t n, long prec) + + void arb_bell_ui(arb_t res, unsigned long n, long prec) + # Sets *res* to the Bell number `B_n`. If the number is too large to + # fit exactly in *prec* bits, a numerical approximation is computed + # efficiently. + # The algorithm to compute Bell numbers, including error analysis, + # is described in detail in [Joh2015]_. + + void arb_euler_number_fmpz(arb_t res, const fmpz_t n, long prec) + void arb_euler_number_ui(arb_t res, unsigned long n, long prec) + # Sets *res* to the Euler number `E_n`, which is defined by + # the exponential generating function `1 / \cosh(x)`. + # The result will be exact if `E_n` is exactly representable + # at the requested precision. + + void arb_fmpz_euler_number_ui_multi_mod(fmpz_t res, unsigned long n, double alpha) + void arb_fmpz_euler_number_ui(fmpz_t res, unsigned long n) + # Computes the Euler number `E_n` as an exact integer. The default + # algorithm uses a table lookup, the Dirichlet beta function or a + # hybrid modular algorithm depending on the size of *n*. + # The *multi_mod* algorithm accepts a tuning parameter *alpha* which + # can be set to a negative value to use defaults. + + void arb_partitions_fmpz(arb_t res, const fmpz_t n, long prec) + + void arb_partitions_ui(arb_t res, unsigned long n, long prec) + # Sets *res* to the partition function `p(n)`. + # When *n* is large and `\log_2 p(n)` is more than twice *prec*, + # the leading term in the Hardy-Ramanujan asymptotic series is used + # together with an error bound. Otherwise, the exact value is computed + # and rounded. + + void arb_primorial_nth_ui(arb_t res, unsigned long n, long prec) + # Sets *res* to the *nth* primorial, defined as the product of the + # first *n* prime numbers. The running time is quasilinear in *n*. + + void arb_primorial_ui(arb_t res, unsigned long n, long prec) + # Sets *res* to the primorial defined as the product of the positive + # integers up to and including *n*. The running time is quasilinear in *n*. + + void _arb_atan_taylor_naive(mp_ptr y, mp_limb_t * error, mp_srcptr x, mp_size_t xn, unsigned long N, int alternating) + + void _arb_atan_taylor_rs(mp_ptr y, mp_limb_t * error, mp_srcptr x, mp_size_t xn, unsigned long N, int alternating) + # Computes an approximation of `y = \sum_{k=0}^{N-1} x^{2k+1} / (2k+1)` + # (if *alternating* is 0) or `y = \sum_{k=0}^{N-1} (-1)^k x^{2k+1} / (2k+1)` + # (if *alternating* is 1). Used internally for computing arctangents + # and logarithms. The *naive* version uses the forward recurrence, and the + # *rs* version uses a division-avoiding rectangular splitting scheme. + # Requires `N \le 255`, `0 \le x \le 1/16`, and *xn* positive. + # The input *x* and output *y* are fixed-point numbers with *xn* fractional + # limbs. A bound for the ulp error is written to *error*. + + void _arb_exp_taylor_naive(mp_ptr y, mp_limb_t * error, mp_srcptr x, mp_size_t xn, unsigned long N) + + void _arb_exp_taylor_rs(mp_ptr y, mp_limb_t * error, mp_srcptr x, mp_size_t xn, unsigned long N) + # Computes an approximation of `y = \sum_{k=0}^{N-1} x^k / k!`. Used internally + # for computing exponentials. The *naive* version uses the forward recurrence, + # and the *rs* version uses a division-avoiding rectangular splitting scheme. + # Requires `N \le 287`, `0 \le x \le 1/16`, and *xn* positive. + # The input *x* is a fixed-point number with *xn* fractional + # limbs, and the output *y* is a fixed-point number with *xn* fractional + # limbs plus one extra limb for the integer part of the result. + # A bound for the ulp error is written to *error*. + + void _arb_sin_cos_taylor_naive(mp_ptr ysin, mp_ptr ycos, mp_limb_t * error, mp_srcptr x, mp_size_t xn, unsigned long N) + + void _arb_sin_cos_taylor_rs(mp_ptr ysin, mp_ptr ycos, mp_limb_t * error, mp_srcptr x, mp_size_t xn, unsigned long N, int sinonly, int alternating) + # Computes approximations of `y_s = \sum_{k=0}^{N-1} (-1)^k x^{2k+1} / (2k+1)!` + # and `y_c = \sum_{k=0}^{N-1} (-1)^k x^{2k} / (2k)!`. + # Used internally for computing sines and cosines. The *naive* version uses + # the forward recurrence, and the *rs* version uses a division-avoiding + # rectangular splitting scheme. + # Requires `N \le 143`, `0 \le x \le 1/16`, and *xn* positive. + # The input *x* and outputs *ysin*, *ycos* are fixed-point numbers with + # *xn* fractional limbs. A bound for the ulp error is written to *error*. + # If *sinonly* is 1, only the sine is computed; if *sinonly* is 0 + # both the sine and cosine are computed. + # To compute sin and cos, *alternating* should be 1. If *alternating* is 0, + # the hyperbolic sine is computed (this is currently only intended to + # be used together with *sinonly*). + + 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) + # Attempts to write `w = x - q \log(2)` with `0 \le w < \log(2)`, where *w* + # is a fixed-point number with *wn* limbs and ulp error *error*. + # Returns success. + + 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) + # Attempts to write `w = |x| - q \pi/4` with `0 \le w < \pi/4`, where *w* + # is a fixed-point number with *wn* limbs and ulp error *error*. + # Returns success. + # The value of *q* mod 8 is written to *octant*. The output variable *q* + # can be NULL, in which case the full value of *q* is not stored. + + long _arb_exp_taylor_bound(long mag, long prec) + # Returns *n* such that + # `\left|\sum_{k=n}^{\infty} x^k / k!\right| \le 2^{-\mathrm{prec}}`, + # assuming `|x| \le 2^{\mathrm{mag}} \le 1/4`. + + void arb_exp_arf_bb(arb_t z, const arf_t x, long prec, int m1) + # Computes the exponential function using the bit-burst algorithm. + # If *m1* is nonzero, the exponential function minus one is computed + # accurately. + # Aborts if *x* is extremely small or large (where another algorithm + # should be used). + # For large *x*, repeated halving is used. In fact, we always + # do argument reduction until `|x|` is smaller than about `2^{-d}` + # where `d \approx 16` to speed up convergence. If `|x| \approx 2^m`, + # we thus need about `m+d` squarings. + # Computing `\log(2)` costs roughly 100-200 multiplications, so is not + # usually worth the effort at very high precision. However, this function + # could be improved by using `\log(2)` based reduction at precision low + # enough that the value can be assumed to be cached. + + void _arb_exp_sum_bs_simple(fmpz_t T, fmpz_t Q, flint_bitcnt_t * Qexp, const fmpz_t x, flint_bitcnt_t r, long N) + + void _arb_exp_sum_bs_powtab(fmpz_t T, fmpz_t Q, flint_bitcnt_t * Qexp, const fmpz_t x, flint_bitcnt_t r, long N) + # Computes *T*, *Q* and *Qexp* such that + # `T / (Q 2^{\text{Qexp}}) = \sum_{k=1}^N (x/2^r)^k/k!` using binary splitting. + # Note that the sum is taken to *N* inclusive and omits the constant term. + # The *powtab* version precomputes a table of powers of *x*, + # resulting in slightly higher memory usage but better speed. For best + # efficiency, *N* should have many trailing zero bits. + + void arb_exp_arf_rs_generic(arb_t res, const arf_t x, long prec, int minus_one) + # Computes the exponential function using a generic version of the rectangular + # splitting strategy, intended for intermediate precision. + + void _arb_atan_sum_bs_simple(fmpz_t T, fmpz_t Q, flint_bitcnt_t * Qexp, const fmpz_t x, flint_bitcnt_t r, long N) + + void _arb_atan_sum_bs_powtab(fmpz_t T, fmpz_t Q, flint_bitcnt_t * Qexp, const fmpz_t x, flint_bitcnt_t r, long N) + # Computes *T*, *Q* and *Qexp* such that + # `T / (Q 2^{\text{Qexp}}) = \sum_{k=1}^N (-1)^k (x/2^r)^{2k} / (2k+1)` + # using binary splitting. + # Note that the sum is taken to *N* inclusive, omits the linear term, + # and requires a final multiplication by `(x/2^r)` to give the + # true series for atan. + # The *powtab* version precomputes a table of powers of *x*, + # resulting in slightly higher memory usage but better speed. For best + # efficiency, *N* should have many trailing zero bits. + + void arb_atan_arf_bb(arb_t z, const arf_t x, long prec) + # Computes the arctangent of *x*. + # Initially, the argument-halving formula + # .. math :: + # \operatorname{atan}(x) = 2 \operatorname{atan}\left(\frac{x}{1+\sqrt{1+x^2}}\right) + # is applied up to 8 times to get a small argument. + # Then a version of the bit-burst algorithm is used. + # The functional equation + # .. math :: + # \operatorname{atan}(x) = \operatorname{atan}(p/q) + + # \operatorname{atan}(w), + # \quad w = \frac{qx-p}{px+q}, + # \quad p = \lfloor qx \rfloor + # is applied repeatedly instead of integrating a differential + # equation for the arctangent, as this appears to be more efficient. + + void arb_atan_frac_bsplit(arb_t s, const fmpz_t p, const fmpz_t q, int hyperbolic, long prec) + # Computes the arctangent of `p/q`, optionally the hyperbolic + # arctangent, using direct series summation with binary splitting. + + void arb_sin_cos_arf_generic(arb_t s, arb_t c, const arf_t x, long prec) + # Computes the sine and cosine of *x* using a generic strategy. + # This function gets called internally by the main sin and cos functions + # when the precision for argument reduction or series evaluation + # based on lookup tables is exhausted. + # This function first performs a cheap test to see if + # `|x| < \pi / 2 - \varepsilon`. If the test fails, it uses + # `\pi` to reduce the argument to the first octant, + # and then evaluates the sin and cos functions recursively (this call cannot + # result in infinite recursion). + # If no argument reduction is needed, this function uses a generic version + # of the rectangular splitting algorithm if the precision is not too high, + # and otherwise invokes the asymptotically fast bit-burst algorithm. + + void arb_sin_cos_arf_bb(arb_t s, arb_t c, const arf_t x, long prec) + # Computes the sine and cosine of *x* using the bit-burst algorithm. + # It is required that `|x| < \pi / 2` (this is not checked). + + void arb_sin_cos_wide(arb_t s, arb_t c, const arb_t x, long prec) + # Computes an accurate enclosure (with both endpoints optimal to within + # about `2^{-30}` as afforded by the radius format) of the range of + # sine and cosine on a given wide interval. The computation is done + # by evaluating the sine and cosine at the interval endpoints and + # determining whether peaks of -1 or 1 occur between the endpoints. + # The interval is then converted back to a ball. + # The internal computations are done with doubles, using a simple + # floating-point algorithm to approximate the sine and cosine. It is + # easy to see that the cumulative errors in this algorithm add up to + # less than `2^{-30}`, with the dominant source of error being a single + # approximate reduction by `\pi/2`. This reduction is done safely using + # doubles up to a magnitude of about `2^{20}`. For larger arguments, a + # slower reduction using :type:`arb_t` arithmetic is done as a + # preprocessing step. + + void arb_sin_cos_generic(arb_t s, arb_t c, const arb_t x, long prec) + # Computes the sine and cosine of *x* by taking care of various special + # cases and computing the propagated error before calling + # :func:`arb_sin_cos_arf_generic`. This is used as a fallback inside + # :func:`arb_sin_cos` to take care of all cases without a fast + # path in that function. + + void arb_log_primes_vec_bsplit(arb_ptr res, long n, long prec) + # Sets *res* to a vector containing the natural logarithms of + # the first *n* prime numbers, computed using binary splitting + # applied to simultaneous Machine-type formulas. This function is not + # optimized for large *n* or small *prec*. + + void _arb_log_p_ensure_cached(long prec) + # Ensure that the internal cache of logarithms of small prime + # numbers has entries to at least *prec* bits. + + void arb_exp_arf_log_reduction(arb_t res, const arf_t x, long prec, int minus_one) + # Computes the exponential function using log reduction. + + void arb_exp_arf_generic(arb_t z, const arf_t x, long prec, int minus_one) + # Computes the exponential function using an automatic choice + # between rectangular splitting and the bit-burst algorithm, + # without precomputation. + + void arb_exp_arf(arb_t z, const arf_t x, long prec, int minus_one, long maglim) + # Computes the exponential function using an automatic choice + # between all implemented algorithms. + + void arb_log_newton(arb_t res, const arb_t x, long prec) + void arb_log_arf_newton(arb_t res, const arf_t x, long prec) + # Computes the logarithm using Newton iteration. + + void arb_atan_gauss_primes_vec_bsplit(arb_ptr res, long n, long prec) + # Sets *res* to the primitive angles corresponding to the + # first *n* nonreal Gaussian primes (ignoring symmetries), + # computed using binary splitting + # applied to simultaneous Machine-type formulas. This function is not + # optimized for large *n* or small *prec*. + + void _arb_atan_gauss_p_ensure_cached(long prec) + + void arb_sin_cos_arf_atan_reduction(arb_t res1, arb_t res2, const arf_t x, long prec) + # Computes sin and/or cos using reduction by primitive angles. + + void arb_atan_newton(arb_t res, const arb_t x, long prec) + void arb_atan_arf_newton(arb_t res, const arf_t x, long prec) + # Computes the arctangent using Newton iteration. + + void _arb_vec_zero(arb_ptr vec, long n) + # Sets all entries in *vec* to zero. + + int _arb_vec_is_zero(arb_srcptr vec, long len) + # Returns nonzero iff all entries in *x* are zero. + + int _arb_vec_is_finite(arb_srcptr x, long len) + # Returns nonzero iff all entries in *x* certainly are finite. + + void _arb_vec_set(arb_ptr res, arb_srcptr vec, long len) + # Sets *res* to a copy of *vec*. + + void _arb_vec_set_round(arb_ptr res, arb_srcptr vec, long len, long prec) + # Sets *res* to a copy of *vec*, rounding each entry to *prec* bits. + + void _arb_vec_swap(arb_ptr vec1, arb_ptr vec2, long len) + # Swaps the entries of *vec1* and *vec2*. + + void _arb_vec_neg(arb_ptr B, arb_srcptr A, long n) + + void _arb_vec_sub(arb_ptr C, arb_srcptr A, arb_srcptr B, long n, long prec) + + void _arb_vec_add(arb_ptr C, arb_srcptr A, arb_srcptr B, long n, long prec) + + void _arb_vec_scalar_mul(arb_ptr res, arb_srcptr vec, long len, const arb_t c, long prec) + + void _arb_vec_scalar_div(arb_ptr res, arb_srcptr vec, long len, const arb_t c, long prec) + + void _arb_vec_scalar_mul_fmpz(arb_ptr res, arb_srcptr vec, long len, const fmpz_t c, long prec) + + void _arb_vec_scalar_mul_2exp_si(arb_ptr res, arb_srcptr src, long len, long c) + + void _arb_vec_scalar_addmul(arb_ptr res, arb_srcptr vec, long len, const arb_t c, long prec) + + void _arb_vec_get_mag(mag_t bound, arb_srcptr vec, long len) + # Sets *bound* to an upper bound for the entries in *vec*. + + long _arb_vec_bits(arb_srcptr x, long len) + # Returns the maximum of :func:`arb_bits` for all entries in *vec*. + + void _arb_vec_set_powers(arb_ptr xs, const arb_t x, long len, long prec) + # Sets *xs* to the powers `1, x, x^2, \ldots, x^{len-1}`. + + void _arb_vec_add_error_arf_vec(arb_ptr res, arf_srcptr err, long len) + + void _arb_vec_add_error_mag_vec(arb_ptr res, mag_srcptr err, long len) + # Adds the magnitude of each entry in *err* to the radius of the + # corresponding entry in *res*. + + void _arb_vec_indeterminate(arb_ptr vec, long len) + # Applies :func:`arb_indeterminate` elementwise. + + void _arb_vec_trim(arb_ptr res, arb_srcptr vec, long len) + # Applies :func:`arb_trim` elementwise. + + int _arb_vec_get_unique_fmpz_vec(fmpz * res, arb_srcptr vec, long len) + # Calls :func:`arb_get_unique_fmpz` elementwise and returns nonzero if + # all entries can be rounded uniquely to integers. If any entry in *vec* + # cannot be rounded uniquely to an integer, returns zero. diff --git a/src/sage/libs/flint/arb_calc.pxd b/src/sage/libs/flint/arb_calc.pxd new file mode 100644 index 00000000000..ee897b125d0 --- /dev/null +++ b/src/sage/libs/flint/arb_calc.pxd @@ -0,0 +1,133 @@ +# distutils: libraries = flint +# distutils: depends = flint/arb_calc.h + +################################################################################ +# This file is auto-generated. Do not modify by hand +################################################################################ + +from libc.stdio cimport FILE +from sage.libs.gmp.types cimport * +from sage.libs.mpfr.types cimport * +from sage.libs.flint.types cimport * + +cdef extern from "flint_wrap.h": + + void arf_interval_init(arf_interval_t v) + + void arf_interval_clear(arf_interval_t v) + + arf_interval_ptr _arf_interval_vec_init(long n) + + void _arf_interval_vec_clear(arf_interval_ptr v, long n) + + void arf_interval_set(arf_interval_t v, const arf_interval_t u) + + void arf_interval_swap(arf_interval_t v, arf_interval_t u) + + void arf_interval_get_arb(arb_t x, const arf_interval_t v, long prec) + + void arf_interval_printd(const arf_interval_t v, long n) + # Helper functions for endpoint-based intervals. + + void arf_interval_fprintd(FILE * file, const arf_interval_t v, long n) + # Helper functions for endpoint-based intervals. + + long arb_calc_isolate_roots(arf_interval_ptr * found, int ** flags, arb_calc_func_t func, void * param, const arf_interval_t interval, long maxdepth, long maxeval, long maxfound, long prec) + # Rigorously isolates single roots of a real analytic function + # on the interior of an interval. + # This routine writes an array of *n* interesting subintervals of + # *interval* to *found* and corresponding flags to *flags*, returning the integer *n*. + # The output has the following properties: + # * The function has no roots on *interval* outside of the output + # subintervals. + # * Subintervals are sorted in increasing order (with no overlap except + # possibly starting and ending with the same point). + # * Subintervals with a flag of 1 contain exactly one (single) root. + # * Subintervals with any other flag may or may not contain roots. + # If no flags other than 1 occur, all roots of the function on *interval* + # have been isolated. If there are output subintervals on which the + # existence or nonexistence of roots could not be determined, + # the user may attempt further searches on those subintervals + # (possibly with increased precision and/or increased + # bounds for the breaking criteria). Note that roots of multiplicity + # higher than one and roots located exactly at endpoints cannot be isolated + # by the algorithm. + # The following breaking criteria are implemented: + # * At most *maxdepth* recursive subdivisions are attempted. The smallest + # details that can be distinguished are therefore about + # `2^{-\text{maxdepth}}` times the width of *interval*. + # A typical, reasonable value might be between 20 and 50. + # * If the total number of tested subintervals exceeds *maxeval*, the + # algorithm is terminated and any untested subintervals are added + # to the output. The total number of calls to *func* is thereby restricted + # to a small multiple of *maxeval* (the actual count can be slightly + # higher depending on implementation details). + # A typical, reasonable value might be between 100 and 100000. + # * The algorithm terminates if *maxfound* roots have been isolated. + # In particular, setting *maxfound* to 1 can be used to locate + # just one root of the function even if there are numerous roots. + # To try to find all roots, *LONG_MAX* may be passed. + # The argument *prec* denotes the precision used to evaluate the + # function. It is possibly also used for some other arithmetic operations + # performed internally by the algorithm. Note that it probably does not + # make sense for *maxdepth* to exceed *prec*. + # Warning: it is assumed that subdivision points of *interval* can be + # represented exactly as floating-point numbers in memory. + # Do not pass `1 \pm 2^{-10^{100}}` as input. + + int arb_calc_refine_root_bisect(arf_interval_t r, arb_calc_func_t func, void * param, const arf_interval_t start, long iter, long prec) + # Given an interval *start* known to contain a single root of *func*, + # refines it using *iter* bisection steps. The algorithm can + # return a failure code if the sign of the function at an evaluation + # point is ambiguous. The output *r* is set to a valid isolating interval + # (possibly just *start*) even if the algorithm fails. + + void arb_calc_newton_conv_factor(arf_t conv_factor, arb_calc_func_t func, void * param, const arb_t conv_region, long prec) + # Given an interval `I` specified by *conv_region*, evaluates a bound + # for `C = \sup_{t,u \in I} \frac{1}{2} |f''(t)| / |f'(u)|`, + # where `f` is the function specified by *func* and *param*. + # The bound is obtained by evaluating `f'(I)` and `f''(I)` directly. + # If `f` is ill-conditioned, `I` may need to be extremely precise in + # order to get an effective, finite bound for *C*. + + int arb_calc_newton_step(arb_t xnew, arb_calc_func_t func, void * param, const arb_t x, const arb_t conv_region, const arf_t conv_factor, long prec) + # Performs a single step with an interval version of Newton's method. + # The input consists of the function `f` specified + # by *func* and *param*, a ball `x = [m-r, m+r]` known + # to contain a single root of `f`, a ball `I` (*conv_region*) + # containing `x` with an associated bound (*conv_factor*) for + # `C = \sup_{t,u \in I} \frac{1}{2} |f''(t)| / |f'(u)|`, + # and a working precision *prec*. + # The Newton update consists of setting + # `x' = [m'-r', m'+r']` where `m' = m - f(m) / f'(m)` + # and `r' = C r^2`. The expression `m - f(m) / f'(m)` is evaluated + # using ball arithmetic at a working precision of *prec* bits, and the + # rounding error during this evaluation is accounted for in the output. + # We now check that `x' \in I` and `r' < r`. If both conditions are + # satisfied, we set *xnew* to `x'` and return *ARB_CALC_SUCCESS*. + # If either condition fails, we set *xnew* to `x` and return + # *ARB_CALC_NO_CONVERGENCE*, indicating that no progress + # is made. + + int arb_calc_refine_root_newton(arb_t r, arb_calc_func_t func, void * param, const arb_t start, const arb_t conv_region, const arf_t conv_factor, long eval_extra_prec, long prec) + # Refines a precise estimate of a single root of a function + # to high precision by performing several Newton steps, using + # nearly optimally chosen doubling precision steps. + # The inputs are defined as for *arb_calc_newton_step*, except for + # the precision parameters: *prec* is the target accuracy and + # *eval_extra_prec* is the estimated number of guard bits that need + # to be added to evaluate the function accurately close to the root + # (for example, if the function is a polynomial with large coefficients + # of alternating signs and Horner's rule is used to evaluate it, + # the extra precision should typically be approximately + # the bit size of the coefficients). + # This function returns *ARB_CALC_SUCCESS* if all attempted + # Newton steps are successful (note that this does not guarantee + # that the computed root is accurate to *prec* bits, which has + # to be verified by the user), only that it is more accurate + # than the starting ball. + # On failure, *ARB_CALC_IMPRECISE_INPUT* + # or *ARB_CALC_NO_CONVERGENCE* may be returned. In this case, *r* + # is set to a ball for the root which is valid but likely + # does have full accuracy (it can possibly just be equal + # to the starting ball). diff --git a/src/sage/libs/flint/arb_fmpz_poly.pxd b/src/sage/libs/flint/arb_fmpz_poly.pxd new file mode 100644 index 00000000000..4d439287ef0 --- /dev/null +++ b/src/sage/libs/flint/arb_fmpz_poly.pxd @@ -0,0 +1,103 @@ +# distutils: libraries = flint +# distutils: depends = flint/arb_fmpz_poly.h + +################################################################################ +# This file is auto-generated. Do not modify by hand +################################################################################ + +from libc.stdio cimport FILE +from sage.libs.gmp.types cimport * +from sage.libs.mpfr.types cimport * +from sage.libs.flint.types cimport * + +cdef extern from "flint_wrap.h": + + void _arb_fmpz_poly_evaluate_arb_horner(arb_t res, const fmpz * poly, long len, const arb_t x, long prec) + + void arb_fmpz_poly_evaluate_arb_horner(arb_t res, const fmpz_poly_t poly, const arb_t x, long prec) + + void _arb_fmpz_poly_evaluate_arb_rectangular(arb_t res, const fmpz * poly, long len, const arb_t x, long prec) + + void arb_fmpz_poly_evaluate_arb_rectangular(arb_t res, const fmpz_poly_t poly, const arb_t x, long prec) + + void _arb_fmpz_poly_evaluate_arb(arb_t res, const fmpz * poly, long len, const arb_t x, long prec) + + void arb_fmpz_poly_evaluate_arb(arb_t res, const fmpz_poly_t poly, const arb_t x, long prec) + + void _arb_fmpz_poly_evaluate_acb_horner(acb_t res, const fmpz * poly, long len, const acb_t x, long prec) + + void arb_fmpz_poly_evaluate_acb_horner(acb_t res, const fmpz_poly_t poly, const acb_t x, long prec) + + void _arb_fmpz_poly_evaluate_acb_rectangular(acb_t res, const fmpz * poly, long len, const acb_t x, long prec) + + void arb_fmpz_poly_evaluate_acb_rectangular(acb_t res, const fmpz_poly_t poly, const acb_t x, long prec) + + void _arb_fmpz_poly_evaluate_acb(acb_t res, const fmpz * poly, long len, const acb_t x, long prec) + + void arb_fmpz_poly_evaluate_acb(acb_t res, const fmpz_poly_t poly, const acb_t x, long prec) + # Evaluates *poly* (given by a polynomial object or an array with *len* coefficients) + # at the given real or complex number, respectively using Horner's rule, rectangular + # splitting, or a default algorithm choice. + + unsigned long arb_fmpz_poly_deflation(const fmpz_poly_t poly) + # Finds the maximal exponent by which *poly* can be deflated. + + void arb_fmpz_poly_deflate(fmpz_poly_t res, const fmpz_poly_t poly, unsigned long deflation) + # Sets *res* to a copy of *poly* deflated by the exponent *deflation*. + + void arb_fmpz_poly_complex_roots(acb_ptr roots, const fmpz_poly_t poly, int flags, long prec) + # Writes to *roots* all the real and complex roots of the polynomial *poly*, + # computed to at least *prec* accurate bits. + # The root enclosures are guaranteed to be disjoint, so that + # all roots are isolated. + # The real roots are written first in ascending order (with + # the imaginary parts set exactly to zero). The following + # nonreal roots are written in arbitrary order, but with conjugate pairs + # grouped together (the root in the upper plane leading + # the root in the lower plane). + # The input polynomial *must* be squarefree. For a general polynomial, + # compute the squarefree part `f / \gcd(f,f')` or do a full squarefree + # factorization to obtain the multiplicities of the roots:: + # fmpz_poly_factor_t fac; + # fmpz_poly_factor_init(fac); + # fmpz_poly_factor_squarefree(fac, poly); + # for (i = 0; i < fac->num; i++) + # { + # deg = fmpz_poly_degree(fac->p + i); + # flint_printf("%wd roots of multiplicity %wd\n", deg, fac->exp[i]); + # roots = _acb_vec_init(deg); + # arb_fmpz_poly_complex_roots(roots, fac->p + i, 0, prec); + # _acb_vec_clear(roots, deg); + # } + # fmpz_poly_factor_clear(fac); + # All roots are refined to a relative accuracy of at least *prec* bits. + # The output values will generally have higher actual precision, + # depending on the precision needed for isolation and the + # precision used internally by the algorithm. + # This implementation should be adequate for general use, but it is not + # currently competitive with state-of-the-art isolation + # methods for finding real roots alone. + # The following *flags* are supported: + # * *ARB_FMPZ_POLY_ROOTS_VERBOSE* + + void arb_fmpz_poly_cos_minpoly(fmpz_poly_t res, unsigned long n) + # Sets *res* to the monic minimal polynomial of `2 \cos(2 \pi / n)`. + # This is a wrapper of FLINT's *fmpz_poly_cos_minpoly*, provided here + # for backward compatibility. + + void arb_fmpz_poly_gauss_period_minpoly(fmpz_poly_t res, unsigned long q, unsigned long n) + # Sets *res* to the minimal polynomial of the Gaussian periods + # `\sum_{a \in H} \zeta^a` where `\zeta = \exp(2 \pi i / q)` + # and *H* are the cosets of the subgroups of order `d = (q - 1) / n` of + # `(\mathbb{Z}/q\mathbb{Z})^{\times}`. + # The resulting polynomial has degree *n*. + # When `d = 1`, the result is the cyclotomic polynomial `\Phi_q`. + # The implementation assumes that *q* is prime, and that *n* is a divisor of + # `q - 1` such that *n* is coprime with *d*. If any condition is not met, + # *res* is set to the zero polynomial. + # This method provides a fast (in practice) way to + # construct finite field extensions of prescribed degree. + # If *q* satisfies the conditions stated above and `(q-1)/f` additionally + # is coprime with *n*, where *f* is the multiplicative order of *p* mod *q*, then + # the Gaussian period minimal polynomial is irreducible over + # `\operatorname{GF}(p)` [CP2005]_. diff --git a/src/sage/libs/flint/arb_fpwrap.pxd b/src/sage/libs/flint/arb_fpwrap.pxd new file mode 100644 index 00000000000..c44fc48c920 --- /dev/null +++ b/src/sage/libs/flint/arb_fpwrap.pxd @@ -0,0 +1,348 @@ +# distutils: libraries = flint +# distutils: depends = flint/arb_fpwrap.h + +################################################################################ +# This file is auto-generated. Do not modify by hand +################################################################################ + +from libc.stdio cimport FILE +from sage.libs.gmp.types cimport * +from sage.libs.mpfr.types cimport * +from sage.libs.flint.types cimport * + +cdef extern from "flint_wrap.h": + + int arb_fpwrap_double_exp(double * res, double x, int flags) + int arb_fpwrap_cdouble_exp(complex_double * res, complex_double x, int flags) + + int arb_fpwrap_double_expm1(double * res, double x, int flags) + int arb_fpwrap_cdouble_expm1(complex_double * res, complex_double x, int flags) + + int arb_fpwrap_double_log(double * res, double x, int flags) + int arb_fpwrap_cdouble_log(complex_double * res, complex_double x, int flags) + + int arb_fpwrap_double_log1p(double * res, double x, int flags) + int arb_fpwrap_cdouble_log1p(complex_double * res, complex_double x, int flags) + + int arb_fpwrap_double_pow(double * res, double x, double y, int flags) + int arb_fpwrap_cdouble_pow(complex_double * res, complex_double x, complex_double y, int flags) + + int arb_fpwrap_double_sqrt(double * res, double x, int flags) + int arb_fpwrap_cdouble_sqrt(complex_double * res, complex_double x, int flags) + + int arb_fpwrap_double_rsqrt(double * res, double x, int flags) + int arb_fpwrap_cdouble_rsqrt(complex_double * res, complex_double x, int flags) + + int arb_fpwrap_double_cbrt(double * res, double x, int flags) + int arb_fpwrap_cdouble_cbrt(complex_double * res, complex_double x, int flags) + + int arb_fpwrap_double_sin(double * res, double x, int flags) + int arb_fpwrap_cdouble_sin(complex_double * res, complex_double x, int flags) + + int arb_fpwrap_double_cos(double * res, double x, int flags) + int arb_fpwrap_cdouble_cos(complex_double * res, complex_double x, int flags) + + int arb_fpwrap_double_tan(double * res, double x, int flags) + int arb_fpwrap_cdouble_tan(complex_double * res, complex_double x, int flags) + + int arb_fpwrap_double_cot(double * res, double x, int flags) + int arb_fpwrap_cdouble_cot(complex_double * res, complex_double x, int flags) + + int arb_fpwrap_double_sec(double * res, double x, int flags) + int arb_fpwrap_cdouble_sec(complex_double * res, complex_double x, int flags) + + int arb_fpwrap_double_csc(double * res, double x, int flags) + int arb_fpwrap_cdouble_csc(complex_double * res, complex_double x, int flags) + + int arb_fpwrap_double_sinc(double * res, double x, int flags) + int arb_fpwrap_cdouble_sinc(complex_double * res, complex_double x, int flags) + + int arb_fpwrap_double_sin_pi(double * res, double x, int flags) + int arb_fpwrap_cdouble_sin_pi(complex_double * res, complex_double x, int flags) + + int arb_fpwrap_double_cos_pi(double * res, double x, int flags) + int arb_fpwrap_cdouble_cos_pi(complex_double * res, complex_double x, int flags) + + int arb_fpwrap_double_tan_pi(double * res, double x, int flags) + int arb_fpwrap_cdouble_tan_pi(complex_double * res, complex_double x, int flags) + + int arb_fpwrap_double_cot_pi(double * res, double x, int flags) + int arb_fpwrap_cdouble_cot_pi(complex_double * res, complex_double x, int flags) + + int arb_fpwrap_double_sinc_pi(double * res, double x, int flags) + int arb_fpwrap_cdouble_sinc_pi(complex_double * res, complex_double x, int flags) + + int arb_fpwrap_double_asin(double * res, double x, int flags) + int arb_fpwrap_cdouble_asin(complex_double * res, complex_double x, int flags) + + int arb_fpwrap_double_acos(double * res, double x, int flags) + int arb_fpwrap_cdouble_acos(complex_double * res, complex_double x, int flags) + + int arb_fpwrap_double_atan(double * res, double x, int flags) + int arb_fpwrap_cdouble_atan(complex_double * res, complex_double x, int flags) + + int arb_fpwrap_double_atan2(double * res, double x1, double x2, int flags) + + int arb_fpwrap_double_asinh(double * res, double x, int flags) + int arb_fpwrap_cdouble_asinh(complex_double * res, complex_double x, int flags) + + int arb_fpwrap_double_acosh(double * res, double x, int flags) + int arb_fpwrap_cdouble_acosh(complex_double * res, complex_double x, int flags) + + int arb_fpwrap_double_atanh(double * res, double x, int flags) + int arb_fpwrap_cdouble_atanh(complex_double * res, complex_double x, int flags) + + int arb_fpwrap_double_lambertw(double * res, double x, long branch, int flags) + int arb_fpwrap_cdouble_lambertw(complex_double * res, complex_double x, long branch, int flags) + + int arb_fpwrap_double_rising(double * res, double x, double n, int flags) + int arb_fpwrap_cdouble_rising(complex_double * res, complex_double x, complex_double n, int flags) + # Rising factorial. + + int arb_fpwrap_double_gamma(double * res, double x, int flags) + int arb_fpwrap_cdouble_gamma(complex_double * res, complex_double x, int flags) + # Gamma function. + + int arb_fpwrap_double_rgamma(double * res, double x, int flags) + int arb_fpwrap_cdouble_rgamma(complex_double * res, complex_double x, int flags) + # Reciprocal gamma function. + + int arb_fpwrap_double_lgamma(double * res, double x, int flags) + int arb_fpwrap_cdouble_lgamma(complex_double * res, complex_double x, int flags) + # Log-gamma function. + + int arb_fpwrap_double_digamma(double * res, double x, int flags) + int arb_fpwrap_cdouble_digamma(complex_double * res, complex_double x, int flags) + # Digamma function. + + int arb_fpwrap_double_zeta(double * res, double x, int flags) + int arb_fpwrap_cdouble_zeta(complex_double * res, complex_double x, int flags) + # Riemann zeta function. + + int arb_fpwrap_double_hurwitz_zeta(double * res, double s, double z, int flags) + int arb_fpwrap_cdouble_hurwitz_zeta(complex_double * res, complex_double s, complex_double z, int flags) + # Hurwitz zeta function. + + int arb_fpwrap_double_lerch_phi(double * res, double z, double s, double a, int flags) + int arb_fpwrap_cdouble_lerch_phi(complex_double * res, complex_double z, complex_double s, complex_double a, int flags) + # Lerch transcendent. + + int arb_fpwrap_double_barnes_g(double * res, double x, int flags) + int arb_fpwrap_cdouble_barnes_g(complex_double * res, complex_double x, int flags) + # Barnes G-function. + + int arb_fpwrap_double_log_barnes_g(double * res, double x, int flags) + int arb_fpwrap_cdouble_log_barnes_g(complex_double * res, complex_double x, int flags) + # Logarithmic Barnes G-function. + + int arb_fpwrap_double_polygamma(double * res, double s, double z, int flags) + int arb_fpwrap_cdouble_polygamma(complex_double * res, complex_double s, complex_double z, int flags) + # Polygamma function. + + int arb_fpwrap_double_polylog(double * res, double s, double z, int flags) + int arb_fpwrap_cdouble_polylog(complex_double * res, complex_double s, complex_double z, int flags) + # Polylogarithm. + + int arb_fpwrap_cdouble_dirichlet_eta(complex_double * res, complex_double s, int flags) + + int arb_fpwrap_cdouble_riemann_xi(complex_double * res, complex_double s, int flags) + + int arb_fpwrap_cdouble_hardy_theta(complex_double * res, complex_double z, int flags) + + int arb_fpwrap_cdouble_hardy_z(complex_double * res, complex_double z, int flags) + + int arb_fpwrap_cdouble_zeta_zero(complex_double * res, unsigned long n, int flags) + + int arb_fpwrap_double_erf(double * res, double x, int flags) + int arb_fpwrap_cdouble_erf(complex_double * res, complex_double x, int flags) + + int arb_fpwrap_double_erfc(double * res, double x, int flags) + int arb_fpwrap_cdouble_erfc(complex_double * res, complex_double x, int flags) + + int arb_fpwrap_double_erfi(double * res, double x, int flags) + int arb_fpwrap_cdouble_erfi(complex_double * res, complex_double x, int flags) + + int arb_fpwrap_double_erfinv(double * res, double x, int flags) + + int arb_fpwrap_double_erfcinv(double * res, double x, int flags) + + int arb_fpwrap_double_fresnel_s(double * res, double x, int normalized, int flags) + int arb_fpwrap_cdouble_fresnel_s(complex_double * res, complex_double x, int normalized, int flags) + + int arb_fpwrap_double_fresnel_c(double * res, double x, int normalized, int flags) + int arb_fpwrap_cdouble_fresnel_c(complex_double * res, complex_double x, int normalized, int flags) + + int arb_fpwrap_double_gamma_upper(double * res, double s, double z, int regularized, int flags) + int arb_fpwrap_cdouble_gamma_upper(complex_double * res, complex_double s, complex_double z, int regularized, int flags) + + int arb_fpwrap_double_gamma_lower(double * res, double s, double z, int regularized, int flags) + int arb_fpwrap_cdouble_gamma_lower(complex_double * res, complex_double s, complex_double z, int regularized, int flags) + + int arb_fpwrap_double_beta_lower(double * res, double a, double b, double z, int regularized, int flags) + int arb_fpwrap_cdouble_beta_lower(complex_double * res, complex_double a, complex_double b, complex_double z, int regularized, int flags) + + int arb_fpwrap_double_exp_integral_e(double * res, double s, double z, int flags) + int arb_fpwrap_cdouble_exp_integral_e(complex_double * res, complex_double s, complex_double z, int flags) + + int arb_fpwrap_double_exp_integral_ei(double * res, double x, int flags) + int arb_fpwrap_cdouble_exp_integral_ei(complex_double * res, complex_double x, int flags) + + int arb_fpwrap_double_sin_integral(double * res, double x, int flags) + int arb_fpwrap_cdouble_sin_integral(complex_double * res, complex_double x, int flags) + + int arb_fpwrap_double_cos_integral(double * res, double x, int flags) + int arb_fpwrap_cdouble_cos_integral(complex_double * res, complex_double x, int flags) + + int arb_fpwrap_double_sinh_integral(double * res, double x, int flags) + int arb_fpwrap_cdouble_sinh_integral(complex_double * res, complex_double x, int flags) + + int arb_fpwrap_double_cosh_integral(double * res, double x, int flags) + int arb_fpwrap_cdouble_cosh_integral(complex_double * res, complex_double x, int flags) + + int arb_fpwrap_double_log_integral(double * res, double x, int offset, int flags) + int arb_fpwrap_cdouble_log_integral(complex_double * res, complex_double x, int offset, int flags) + + int arb_fpwrap_double_dilog(double * res, double x, int flags) + int arb_fpwrap_cdouble_dilog(complex_double * res, complex_double x, int flags) + + int arb_fpwrap_double_bessel_j(double * res, double nu, double x, int flags) + int arb_fpwrap_cdouble_bessel_j(complex_double * res, complex_double nu, complex_double x, int flags) + + int arb_fpwrap_double_bessel_y(double * res, double nu, double x, int flags) + int arb_fpwrap_cdouble_bessel_y(complex_double * res, complex_double nu, complex_double x, int flags) + + int arb_fpwrap_double_bessel_i(double * res, double nu, double x, int flags) + int arb_fpwrap_cdouble_bessel_i(complex_double * res, complex_double nu, complex_double x, int flags) + + int arb_fpwrap_double_bessel_k(double * res, double nu, double x, int flags) + int arb_fpwrap_cdouble_bessel_k(complex_double * res, complex_double nu, complex_double x, int flags) + + int arb_fpwrap_double_bessel_k_scaled(double * res, double nu, double x, int flags) + int arb_fpwrap_cdouble_bessel_k_scaled(complex_double * res, complex_double nu, complex_double x, int flags) + + int arb_fpwrap_double_airy_ai(double * res, double x, int flags) + int arb_fpwrap_cdouble_airy_ai(complex_double * res, complex_double x, int flags) + + int arb_fpwrap_double_airy_ai_prime(double * res, double x, int flags) + int arb_fpwrap_cdouble_airy_ai_prime(complex_double * res, complex_double x, int flags) + + int arb_fpwrap_double_airy_bi(double * res, double x, int flags) + int arb_fpwrap_cdouble_airy_bi(complex_double * res, complex_double x, int flags) + + int arb_fpwrap_double_airy_bi_prime(double * res, double x, int flags) + int arb_fpwrap_cdouble_airy_bi_prime(complex_double * res, complex_double x, int flags) + + int arb_fpwrap_double_airy_ai_zero(double * res, unsigned long n, int flags) + + int arb_fpwrap_double_airy_ai_prime_zero(double * res, unsigned long n, int flags) + + int arb_fpwrap_double_airy_bi_zero(double * res, unsigned long n, int flags) + + int arb_fpwrap_double_airy_bi_prime_zero(double * res, unsigned long n, int flags) + + int arb_fpwrap_double_coulomb_f(double * res, double l, double eta, double x, int flags) + int arb_fpwrap_cdouble_coulomb_f(complex_double * res, complex_double l, complex_double eta, complex_double x, int flags) + + int arb_fpwrap_double_coulomb_g(double * res, double l, double eta, double x, int flags) + int arb_fpwrap_cdouble_coulomb_g(complex_double * res, complex_double l, complex_double eta, complex_double x, int flags) + + int arb_fpwrap_cdouble_coulomb_hpos(complex_double * res, complex_double l, complex_double eta, complex_double x, int flags) + int arb_fpwrap_cdouble_coulomb_hneg(complex_double * res, complex_double l, complex_double eta, complex_double x, int flags) + + int arb_fpwrap_double_chebyshev_t(double * res, double n, double x, int flags) + int arb_fpwrap_cdouble_chebyshev_t(complex_double * res, complex_double n, complex_double x, int flags) + + int arb_fpwrap_double_chebyshev_u(double * res, double n, double x, int flags) + int arb_fpwrap_cdouble_chebyshev_u(complex_double * res, complex_double n, complex_double x, int flags) + + int arb_fpwrap_double_jacobi_p(double * res, double n, double a, double b, double x, int flags) + int arb_fpwrap_cdouble_jacobi_p(complex_double * res, complex_double n, complex_double a, complex_double b, complex_double x, int flags) + + int arb_fpwrap_double_gegenbauer_c(double * res, double n, double m, double x, int flags) + int arb_fpwrap_cdouble_gegenbauer_c(complex_double * res, complex_double n, complex_double m, complex_double x, int flags) + + int arb_fpwrap_double_laguerre_l(double * res, double n, double m, double x, int flags) + int arb_fpwrap_cdouble_laguerre_l(complex_double * res, complex_double n, complex_double m, complex_double x, int flags) + + int arb_fpwrap_double_hermite_h(double * res, double n, double x, int flags) + int arb_fpwrap_cdouble_hermite_h(complex_double * res, complex_double n, complex_double x, int flags) + + int arb_fpwrap_double_legendre_p(double * res, double n, double m, double x, int type, int flags) + int arb_fpwrap_cdouble_legendre_p(complex_double * res, complex_double n, complex_double m, complex_double x, int type, int flags) + + int arb_fpwrap_double_legendre_q(double * res, double n, double m, double x, int type, int flags) + int arb_fpwrap_cdouble_legendre_q(complex_double * res, complex_double n, complex_double m, complex_double x, int type, int flags) + + int arb_fpwrap_double_legendre_root(double * res1, double * res2, unsigned long n, unsigned long k, int flags) + # Sets *res1* to the index *k* root of the Legendre polynomial `P_n(x)`, + # and simultaneously sets *res2* to the corresponding weight for + # Gauss-Legendre quadrature. + + int arb_fpwrap_cdouble_spherical_y(complex_double * res, long n, long m, complex_double x1, complex_double x2, int flags) + + int arb_fpwrap_double_hypgeom_0f1(double * res, double a, double x, int regularized, int flags) + int arb_fpwrap_cdouble_hypgeom_0f1(complex_double * res, complex_double a, complex_double x, int regularized, int flags) + + int arb_fpwrap_double_hypgeom_1f1(double * res, double a, double b, double x, int regularized, int flags) + int arb_fpwrap_cdouble_hypgeom_1f1(complex_double * res, complex_double a, complex_double b, complex_double x, int regularized, int flags) + + int arb_fpwrap_double_hypgeom_u(double * res, double a, double b, double x, int flags) + int arb_fpwrap_cdouble_hypgeom_u(complex_double * res, complex_double a, complex_double b, complex_double x, int flags) + + int arb_fpwrap_double_hypgeom_2f1(double * res, double a, double b, double c, double x, int regularized, int flags) + int arb_fpwrap_cdouble_hypgeom_2f1(complex_double * res, complex_double a, complex_double b, complex_double c, complex_double x, int regularized, int flags) + + int arb_fpwrap_double_hypgeom_pfq(double * res, const double * a, long p, const double * b, long q, double z, int regularized, int flags) + int arb_fpwrap_cdouble_hypgeom_pfq(complex_double * res, const complex_double * a, long p, const complex_double * b, long q, complex_double z, int regularized, int flags) + + int arb_fpwrap_double_agm(double * res, double x, double y, int flags) + int arb_fpwrap_cdouble_agm(complex_double * res, complex_double x, complex_double y, int flags) + # Arithmetic-geometric mean. + + int arb_fpwrap_cdouble_elliptic_k(complex_double * res, complex_double m, int flags) + + int arb_fpwrap_cdouble_elliptic_e(complex_double * res, complex_double m, int flags) + + int arb_fpwrap_cdouble_elliptic_pi(complex_double * res, complex_double n, complex_double m, int flags) + + int arb_fpwrap_cdouble_elliptic_f(complex_double * res, complex_double phi, complex_double m, int pi, int flags) + + int arb_fpwrap_cdouble_elliptic_e_inc(complex_double * res, complex_double phi, complex_double m, int pi, int flags) + + int arb_fpwrap_cdouble_elliptic_pi_inc(complex_double * res, complex_double n, complex_double phi, complex_double m, int pi, int flags) + # Complete and incomplete elliptic integrals. + + int arb_fpwrap_cdouble_elliptic_rf(complex_double * res, complex_double x, complex_double y, complex_double z, int option, int flags) + + int arb_fpwrap_cdouble_elliptic_rg(complex_double * res, complex_double x, complex_double y, complex_double z, int option, int flags) + + int arb_fpwrap_cdouble_elliptic_rj(complex_double * res, complex_double x, complex_double y, complex_double z, complex_double w, int option, int flags) + # Carlson symmetric elliptic integrals. + + int arb_fpwrap_cdouble_elliptic_p(complex_double * res, complex_double z, complex_double tau, int flags) + + int arb_fpwrap_cdouble_elliptic_p_prime(complex_double * res, complex_double z, complex_double tau, int flags) + + int arb_fpwrap_cdouble_elliptic_inv_p(complex_double * res, complex_double z, complex_double tau, int flags) + + int arb_fpwrap_cdouble_elliptic_zeta(complex_double * res, complex_double z, complex_double tau, int flags) + + int arb_fpwrap_cdouble_elliptic_sigma(complex_double * res, complex_double z, complex_double tau, int flags) + # Weierstrass elliptic functions. + + int arb_fpwrap_cdouble_jacobi_theta_1(complex_double * res, complex_double z, complex_double tau, int flags) + + int arb_fpwrap_cdouble_jacobi_theta_2(complex_double * res, complex_double z, complex_double tau, int flags) + + int arb_fpwrap_cdouble_jacobi_theta_3(complex_double * res, complex_double z, complex_double tau, int flags) + + int arb_fpwrap_cdouble_jacobi_theta_4(complex_double * res, complex_double z, complex_double tau, int flags) + # Jacobi theta functions. + + int arb_fpwrap_cdouble_dedekind_eta(complex_double * res, complex_double tau, int flags) + + int arb_fpwrap_cdouble_modular_j(complex_double * res, complex_double tau, int flags) + + int arb_fpwrap_cdouble_modular_lambda(complex_double * res, complex_double tau, int flags) + + int arb_fpwrap_cdouble_modular_delta(complex_double * res, complex_double tau, int flags) diff --git a/src/sage/libs/flint/arb_hypgeom.pxd b/src/sage/libs/flint/arb_hypgeom.pxd new file mode 100644 index 00000000000..63ae194e20a --- /dev/null +++ b/src/sage/libs/flint/arb_hypgeom.pxd @@ -0,0 +1,521 @@ +# distutils: libraries = flint +# distutils: depends = flint/arb_hypgeom.h + +################################################################################ +# This file is auto-generated. Do not modify by hand +################################################################################ + +from libc.stdio cimport FILE +from sage.libs.gmp.types cimport * +from sage.libs.mpfr.types cimport * +from sage.libs.flint.types cimport * + +cdef extern from "flint_wrap.h": + + void _arb_hypgeom_rising_coeffs_1(unsigned long * c, unsigned long k, long n) + void _arb_hypgeom_rising_coeffs_2(unsigned long * c, unsigned long k, long n) + void _arb_hypgeom_rising_coeffs_fmpz(fmpz * c, unsigned long k, long n) + # Sets *c* to the coefficients of the rising factorial polynomial + # `(X+k)_n`. The *1* and *2* versions respectively + # compute single-word and double-word coefficients, without checking for + # overflow, while the *fmpz* version allows arbitrarily large coefficients. + # These functions are mostly intended for internal use; the *fmpz* version + # does not use an asymptotically fast algorithm. + # The degree *n* must be at least 2. + + void arb_hypgeom_rising_ui_forward(arb_t res, const arb_t x, unsigned long n, long prec) + void arb_hypgeom_rising_ui_bs(arb_t res, const arb_t x, unsigned long n, long prec) + void arb_hypgeom_rising_ui_rs(arb_t res, const arb_t x, unsigned long n, unsigned long m, long prec) + void arb_hypgeom_rising_ui_rec(arb_t res, const arb_t x, unsigned long n, long prec) + void arb_hypgeom_rising_ui(arb_t res, const arb_t x, unsigned long n, long prec) + void arb_hypgeom_rising(arb_t res, const arb_t x, const arb_t n, long prec) + # Computes the rising factorial `(x)_n`. + # The *forward* version uses the forward recurrence. + # The *bs* version uses binary splitting. + # The *rs* version uses rectangular splitting. It takes an extra tuning + # parameter *m* which can be set to zero to choose automatically. + # The *rec* version chooses an algorithm automatically, avoiding + # use of the gamma function (so that it can be used in the computation + # of the gamma function). + # The default versions (*rising_ui* and *rising_ui*) choose an algorithm + # automatically and may additionally fall back on the gamma function. + + void arb_hypgeom_rising_ui_jet_powsum(arb_ptr res, const arb_t x, unsigned long n, long len, long prec) + void arb_hypgeom_rising_ui_jet_bs(arb_ptr res, const arb_t x, unsigned long n, long len, long prec) + void arb_hypgeom_rising_ui_jet_rs(arb_ptr res, const arb_t x, unsigned long n, unsigned long m, long len, long prec) + void arb_hypgeom_rising_ui_jet(arb_ptr res, const arb_t x, unsigned long n, long len, long prec) + # Computes the jet of the rising factorial `(x)_n`, truncated to length *len*. + # In other words, constructs the polynomial `(X + x)_n \in \mathbb{R}[X]`, + # truncated if `\operatorname{len} < n + 1` (and zero-extended + # if `\operatorname{len} > n + 1`). + # The *powsum* version computes the sequence of powers of *x* and forms integral + # linear combinations of these. + # The *bs* version uses binary splitting. + # The *rs* version uses rectangular splitting. It takes an extra tuning + # parameter *m* which can be set to zero to choose automatically. + # The default version chooses an algorithm automatically. + + void _arb_hypgeom_gamma_stirling_term_bounds(long * bound, const mag_t zinv, long N) + # For `1 \le n < N`, sets *bound* to an exponent bounding the *n*-th term + # in the Stirling series for the gamma function, given a precomputed upper + # bound for `|z|^{-1}`. This function is intended for internal use and + # does not check for underflow or underflow in the exponents. + + void arb_hypgeom_gamma_stirling_sum_horner(arb_t res, const arb_t z, long N, long prec) + void arb_hypgeom_gamma_stirling_sum_improved(arb_t res, const arb_t z, long N, long K, long prec) + # Sets *res* to the final sum in the Stirling series for the gamma function + # truncated before the term with index *N*, i.e. computes + # `\sum_{n=1}^{N-1} B_{2n} / (2n(2n-1) z^{2n-1})`. + # The *horner* version uses Horner scheme with gradual precision adjustments. + # The *improved* version uses rectangular splitting for the low-index + # terms and reexpands the high-index terms as hypergeometric polynomials, + # using a splitting parameter *K* (which can be set to 0 to use a default + # value). + + void arb_hypgeom_gamma_stirling(arb_t res, const arb_t x, int reciprocal, long prec) + # Sets *res* to the gamma function of *x* computed using the Stirling + # series together with argument reduction. If *reciprocal* is set, + # the reciprocal gamma function is computed instead. + + int arb_hypgeom_gamma_taylor(arb_t res, const arb_t x, int reciprocal, long prec) + # Attempts to compute the gamma function of *x* using Taylor series + # together with argument reduction. This is only supported if *x* and *prec* + # are both small enough. If successful, returns 1; otherwise, does nothing + # and returns 0. If *reciprocal* is set, the reciprocal gamma function is + # computed instead. + + void arb_hypgeom_gamma(arb_t res, const arb_t x, long prec) + void arb_hypgeom_gamma_fmpq(arb_t res, const fmpq_t x, long prec) + void arb_hypgeom_gamma_fmpz(arb_t res, const fmpz_t x, long prec) + # Sets *res* to the gamma function of *x* computed using a default + # algorithm choice. + + void arb_hypgeom_rgamma(arb_t res, const arb_t x, long prec) + # Sets *res* to the reciprocal gamma function of *x* computed using a default + # algorithm choice. + + void arb_hypgeom_lgamma(arb_t res, const arb_t x, long prec) + # Sets *res* to the log-gamma function of *x* computed using a default + # algorithm choice. + + void arb_hypgeom_central_bin_ui(arb_t res, unsigned long n, long prec) + # Computes the central binomial coefficient `{2n \choose n}`. + + void arb_hypgeom_pfq(arb_t res, arb_srcptr a, long p, arb_srcptr b, long q, const arb_t z, int regularized, long prec) + # Computes the generalized hypergeometric function `{}_pF_{q}(z)`, + # or the regularized version if *regularized* is set. + + void arb_hypgeom_0f1(arb_t res, const arb_t a, const arb_t z, int regularized, long prec) + # Computes the confluent hypergeometric limit function + # `{}_0F_1(a,z)`, or `\frac{1}{\Gamma(a)} {}_0F_1(a,z)` if *regularized* + # is set. + + void arb_hypgeom_m(arb_t res, const arb_t a, const arb_t b, const arb_t z, int regularized, long prec) + # Computes the confluent hypergeometric function + # `M(a,b,z) = {}_1F_1(a,b,z)`, or + # `\mathbf{M}(a,b,z) = \frac{1}{\Gamma(b)} {}_1F_1(a,b,z)` if *regularized* is set. + + void arb_hypgeom_1f1(arb_t res, const arb_t a, const arb_t b, const arb_t z, int regularized, long prec) + # Alias for :func:`arb_hypgeom_m`. + + void arb_hypgeom_1f1_integration(arb_t res, const arb_t a, const arb_t b, const arb_t z, int regularized, long prec) + # Computes the confluent hypergeometric function using numerical integration + # of the representation + # .. math :: + # {}_1F_1(a,b,z) = \frac{\Gamma(b)}{\Gamma(a) \Gamma(b-a)} \int_0^1 e^{zt} t^{a-1} (1-t)^{b-a-1} dt. + # This algorithm can be useful if the parameters are large. This will currently + # only return a finite enclosure if `a \ge 1` and `b - a \ge 1`. + + void arb_hypgeom_u(arb_t res, const arb_t a, const arb_t b, const arb_t z, long prec) + # Computes the confluent hypergeometric function `U(a,b,z)`. + + void arb_hypgeom_u_integration(arb_t res, const arb_t a, const arb_t b, const arb_t z, long prec) + # Computes the confluent hypergeometric function `U(a,b,z)` using numerical integration + # of the representation + # .. math :: + # U(a,b,z) = \frac{1}{\Gamma(a)} \int_0^{\infty} e^{-zt} t^{a-1} (1+t)^{b-a-1} dt. + # This algorithm can be useful if the parameters are large. This will currently + # only return a finite enclosure if `a \ge 1` and `z > 0`. + + void arb_hypgeom_2f1(arb_t res, const arb_t a, const arb_t b, const arb_t c, const arb_t z, int regularized, long prec) + # Computes the Gauss hypergeometric function + # `{}_2F_1(a,b,c,z)`, or + # `\mathbf{F}(a,b,c,z) = \frac{1}{\Gamma(c)} {}_2F_1(a,b,c,z)` + # if *regularized* is set. + # Additional evaluation flags can be passed via the *regularized* + # argument; see :func:`acb_hypgeom_2f1` for documentation. + + void arb_hypgeom_2f1_integration(arb_t res, const arb_t a, const arb_t b, const arb_t c, const arb_t z, int regularized, long prec) + # Computes the Gauss hypergeometric function using numerical integration + # of the representation + # .. math :: + # {}_2F_1(a,b,c,z) = \frac{\Gamma(a)}{\Gamma(b) \Gamma(c-b)} \int_0^1 t^{b-1} (1-t)^{c-b-1} (1-zt)^{-a} dt. + # This algorithm can be useful if the parameters are large. This will currently + # only return a finite enclosure if `b \ge 1` and `c - b \ge 1` and + # `z < 1`, possibly with *a* and *b* exchanged. + + void arb_hypgeom_erf(arb_t res, const arb_t z, long prec) + # Computes the error function `\operatorname{erf}(z)`. + + void _arb_hypgeom_erf_series(arb_ptr res, arb_srcptr z, long zlen, long len, long prec) + void arb_hypgeom_erf_series(arb_poly_t res, const arb_poly_t z, long len, long prec) + # Computes the error function of the power series *z*, + # truncated to length *len*. + + void arb_hypgeom_erfc(arb_t res, const arb_t z, long prec) + # Computes the complementary error function + # `\operatorname{erfc}(z) = 1 - \operatorname{erf}(z)`. + # This function avoids catastrophic cancellation for large positive *z*. + + void _arb_hypgeom_erfc_series(arb_ptr res, arb_srcptr z, long zlen, long len, long prec) + void arb_hypgeom_erfc_series(arb_poly_t res, const arb_poly_t z, long len, long prec) + # Computes the complementary error function of the power series *z*, + # truncated to length *len*. + + void arb_hypgeom_erfi(arb_t res, const arb_t z, long prec) + # Computes the imaginary error function + # `\operatorname{erfi}(z) = -i\operatorname{erf}(iz)`. + + void _arb_hypgeom_erfi_series(arb_ptr res, arb_srcptr z, long zlen, long len, long prec) + void arb_hypgeom_erfi_series(arb_poly_t res, const arb_poly_t z, long len, long prec) + # Computes the imaginary error function of the power series *z*, + # truncated to length *len*. + + void arb_hypgeom_erfinv(arb_t res, const arb_t z, long prec) + void arb_hypgeom_erfcinv(arb_t res, const arb_t z, long prec) + # Computes the inverse error function `\operatorname{erf}^{-1}(z)` + # or inverse complementary error function `\operatorname{erfc}^{-1}(z)`. + + void arb_hypgeom_fresnel(arb_t res1, arb_t res2, const arb_t z, int normalized, long prec) + # Sets *res1* to the Fresnel sine integral `S(z)` and *res2* to + # the Fresnel cosine integral `C(z)`. Optionally, just a single function + # can be computed by passing *NULL* as the other output variable. + # The definition `S(z) = \int_0^z \sin(t^2) dt` is used if *normalized* is 0, + # and `S(z) = \int_0^z \sin(\tfrac{1}{2} \pi t^2) dt` is used if + # *normalized* is 1 (the latter is the Abramowitz & Stegun convention). + # `C(z)` is defined analogously. + + void _arb_hypgeom_fresnel_series(arb_ptr res1, arb_ptr res2, arb_srcptr z, long zlen, int normalized, long len, long prec) + void arb_hypgeom_fresnel_series(arb_poly_t res1, arb_poly_t res2, const arb_poly_t z, int normalized, long len, long prec) + # Sets *res1* to the Fresnel sine integral and *res2* to the Fresnel + # cosine integral of the power series *z*, truncated to length *len*. + # Optionally, just a single function can be computed by passing *NULL* + # as the other output variable. + + void arb_hypgeom_gamma_upper(arb_t res, const arb_t s, const arb_t z, int regularized, long prec) + # If *regularized* is 0, computes the upper incomplete gamma function + # `\Gamma(s,z)`. + # If *regularized* is 1, computes the regularized upper incomplete + # gamma function `Q(s,z) = \Gamma(s,z) / \Gamma(s)`. + # If *regularized* is 2, computes the generalized exponential integral + # `z^{-s} \Gamma(s,z) = E_{1-s}(z)` instead (this option is mainly + # intended for internal use; :func:`arb_hypgeom_expint` is the intended + # interface for computing the exponential integral). + + void arb_hypgeom_gamma_upper_integration(arb_t res, const arb_t s, const arb_t z, int regularized, long prec) + # Computes the upper incomplete gamma function using numerical + # integration. + + void _arb_hypgeom_gamma_upper_series(arb_ptr res, const arb_t s, arb_srcptr z, long zlen, int regularized, long n, long prec) + void arb_hypgeom_gamma_upper_series(arb_poly_t res, const arb_t s, const arb_poly_t z, int regularized, long n, long prec) + # Sets *res* to an upper incomplete gamma function where *s* is + # a constant and *z* is a power series, truncated to length *n*. + # The *regularized* argument has the same interpretation as in + # :func:`arb_hypgeom_gamma_upper`. + + void arb_hypgeom_gamma_lower(arb_t res, const arb_t s, const arb_t z, int regularized, long prec) + # If *regularized* is 0, computes the lower incomplete gamma function + # `\gamma(s,z) = \frac{z^s}{s} {}_1F_1(s, s+1, -z)`. + # If *regularized* is 1, computes the regularized lower incomplete + # gamma function `P(s,z) = \gamma(s,z) / \Gamma(s)`. + # If *regularized* is 2, computes a further regularized lower incomplete + # gamma function `\gamma^{*}(s,z) = z^{-s} P(s,z)`. + + void _arb_hypgeom_gamma_lower_series(arb_ptr res, const arb_t s, arb_srcptr z, long zlen, int regularized, long n, long prec) + void arb_hypgeom_gamma_lower_series(arb_poly_t res, const arb_t s, const arb_poly_t z, int regularized, long n, long prec) + # Sets *res* to an lower incomplete gamma function where *s* is + # a constant and *z* is a power series, truncated to length *n*. + # The *regularized* argument has the same interpretation as in + # :func:`arb_hypgeom_gamma_lower`. + + void arb_hypgeom_beta_lower(arb_t res, const arb_t a, const arb_t b, const arb_t z, int regularized, long prec) + # Computes the (lower) incomplete beta function, defined by + # `B(a,b;z) = \int_0^z t^{a-1} (1-t)^{b-1}`, + # optionally the regularized incomplete beta function + # `I(a,b;z) = B(a,b;z) / B(a,b;1)`. + + void _arb_hypgeom_beta_lower_series(arb_ptr res, const arb_t a, const arb_t b, arb_srcptr z, long zlen, int regularized, long n, long prec) + void arb_hypgeom_beta_lower_series(arb_poly_t res, const arb_t a, const arb_t b, const arb_poly_t z, int regularized, long n, long prec) + # Sets *res* to the lower incomplete beta function `B(a,b;z)` (optionally + # the regularized version `I(a,b;z)`) where *a* and *b* are constants + # and *z* is a power series, truncating the result to length *n*. + # The underscore method requires positive lengths and does not support + # aliasing. + + void _arb_hypgeom_gamma_lower_sum_rs_1(arb_t res, unsigned long p, unsigned long q, const arb_t z, long N, long prec) + # Computes `\sum_{k=0}^{N-1} z^k / (a)_k` where `a = p/q` using + # rectangular splitting. It is assumed that `p + qN` fits in a limb. + + void _arb_hypgeom_gamma_upper_sum_rs_1(arb_t res, unsigned long p, unsigned long q, const arb_t z, long N, long prec) + # Computes `\sum_{k=0}^{N-1} (a)_k / z^k` where `a = p/q` using + # rectangular splitting. It is assumed that `p + qN` fits in a limb. + + long _arb_hypgeom_gamma_upper_fmpq_inf_choose_N(mag_t err, const fmpq_t a, const arb_t z, const mag_t abs_tol) + # Returns number of terms *N* and sets *err* to the truncation error for evaluating + # `\Gamma(a,z)` using the asymptotic series at infinity, targeting an absolute + # tolerance of *abs_tol*. The error may be set to *err* if the tolerance + # cannot be achieved. Assumes that *z* is positive. + + void _arb_hypgeom_gamma_upper_fmpq_inf_bsplit(arb_t res, const fmpq_t a, const arb_t z, long N, long prec) + # Sets *res* to the approximation of `\Gamma(a,z)` obtained by truncating + # the asymptotic series at infinity before term *N*. + # The truncation error bound has to be added separately. + + long _arb_hypgeom_gamma_lower_fmpq_0_choose_N(mag_t err, const fmpq_t a, const arb_t z, const mag_t abs_tol) + # Returns number of terms *N* and sets *err* to the truncation error for evaluating + # `\gamma(a,z)` using the Taylor series at zero, targeting an absolute + # tolerance of *abs_tol*. Assumes that *z* is positive. + + void _arb_hypgeom_gamma_lower_fmpq_0_bsplit(arb_t res, const fmpq_t a, const arb_t z, long N, long prec) + # Sets *res* to the approximation of `\gamma(a,z)` obtained by truncating + # the Taylor series at zero before term *N*. + # The truncation error bound has to be added separately. + + long _arb_hypgeom_gamma_upper_singular_si_choose_N(mag_t err, long n, const arb_t z, const mag_t abs_tol) + # Returns number of terms *N* and sets *err* to the truncation error for evaluating + # `\Gamma(-n,z)` using the Taylor series at zero, targeting an absolute + # tolerance of *abs_tol*. + + void _arb_hypgeom_gamma_upper_singular_si_bsplit(arb_t res, long n, const arb_t z, long N, long prec) + # Sets *res* to the approximation of `\Gamma(-n,z)` obtained by truncating + # the Taylor series at zero before term *N*. + # The truncation error bound has to be added separately. + + void _arb_gamma_upper_fmpq_step_bsplit(arb_t Gz1, const fmpq_t a, const arb_t z0, const arb_t z1, const arb_t Gz0, const arb_t expmz0, const mag_t abs_tol, long prec) + # Given *Gz0* and *expmz0* representing the values `\Gamma(a,z_0)` and `\exp(-z_0)`, + # computes `\Gamma(a,z_1)` using the Taylor series at `z_0` evaluated + # using binary splitting, + # targeting an absolute error of *abs_tol*. + # Assumes that `z_0` and `z_1` are positive. + + void arb_hypgeom_expint(arb_t res, const arb_t s, const arb_t z, long prec) + # Computes the generalized exponential integral `E_s(z)`. + + void arb_hypgeom_ei(arb_t res, const arb_t z, long prec) + # Computes the exponential integral `\operatorname{Ei}(z)`. + + void _arb_hypgeom_ei_series(arb_ptr res, arb_srcptr z, long zlen, long len, long prec) + void arb_hypgeom_ei_series(arb_poly_t res, const arb_poly_t z, long len, long prec) + # Computes the exponential integral of the power series *z*, + # truncated to length *len*. + + void _arb_hypgeom_si_asymp(arb_t res, const arb_t z, long N, long prec) + void _arb_hypgeom_si_1f2(arb_t res, const arb_t z, long N, long wp, long prec) + void arb_hypgeom_si(arb_t res, const arb_t z, long prec) + # Computes the sine integral `\operatorname{Si}(z)`. + + void _arb_hypgeom_si_series(arb_ptr res, arb_srcptr z, long zlen, long len, long prec) + void arb_hypgeom_si_series(arb_poly_t res, const arb_poly_t z, long len, long prec) + # Computes the sine integral of the power series *z*, + # truncated to length *len*. + + void _arb_hypgeom_ci_asymp(arb_t res, const arb_t z, long N, long prec) + void _arb_hypgeom_ci_2f3(arb_t res, const arb_t z, long N, long wp, long prec) + void arb_hypgeom_ci(arb_t res, const arb_t z, long prec) + # Computes the cosine integral `\operatorname{Ci}(z)`. + # The result is indeterminate if `z < 0` since the value of the function would be complex. + + void _arb_hypgeom_ci_series(arb_ptr res, arb_srcptr z, long zlen, long len, long prec) + void arb_hypgeom_ci_series(arb_poly_t res, const arb_poly_t z, long len, long prec) + # Computes the cosine integral of the power series *z*, + # truncated to length *len*. + + void arb_hypgeom_shi(arb_t res, const arb_t z, long prec) + # Computes the hyperbolic sine integral `\operatorname{Shi}(z) = -i \operatorname{Si}(iz)`. + + void _arb_hypgeom_shi_series(arb_ptr res, arb_srcptr z, long zlen, long len, long prec) + void arb_hypgeom_shi_series(arb_poly_t res, const arb_poly_t z, long len, long prec) + # Computes the hyperbolic sine integral of the power series *z*, + # truncated to length *len*. + + void arb_hypgeom_chi(arb_t res, const arb_t z, long prec) + # Computes the hyperbolic cosine integral `\operatorname{Chi}(z)`. + # The result is indeterminate if `z < 0` since the value of the function would be complex. + + void _arb_hypgeom_chi_series(arb_ptr res, arb_srcptr z, long zlen, long len, long prec) + void arb_hypgeom_chi_series(arb_poly_t res, const arb_poly_t z, long len, long prec) + # Computes the hyperbolic cosine integral of the power series *z*, + # truncated to length *len*. + + void arb_hypgeom_li(arb_t res, const arb_t z, int offset, long prec) + # If *offset* is zero, computes the logarithmic integral + # `\operatorname{li}(z) = \operatorname{Ei}(\log(z))`. + # If *offset* is nonzero, computes the offset logarithmic integral + # `\operatorname{Li}(z) = \operatorname{li}(z) - \operatorname{li}(2)`. + # The result is indeterminate if `z < 0` since the value of the function would be complex. + + void _arb_hypgeom_li_series(arb_ptr res, arb_srcptr z, long zlen, int offset, long len, long prec) + void arb_hypgeom_li_series(arb_poly_t res, const arb_poly_t z, int offset, long len, long prec) + # Computes the logarithmic integral (optionally the offset version) + # of the power series *z*, truncated to length *len*. + + void arb_hypgeom_bessel_j(arb_t res, const arb_t nu, const arb_t z, long prec) + # Computes the Bessel function of the first kind `J_{\nu}(z)`. + + void arb_hypgeom_bessel_y(arb_t res, const arb_t nu, const arb_t z, long prec) + # Computes the Bessel function of the second kind `Y_{\nu}(z)`. + + void arb_hypgeom_bessel_jy(arb_t res1, arb_t res2, const arb_t nu, const arb_t z, long prec) + # Sets *res1* to `J_{\nu}(z)` and *res2* to `Y_{\nu}(z)`, computed + # simultaneously. + + void arb_hypgeom_bessel_i(arb_t res, const arb_t nu, const arb_t z, long prec) + # Computes the modified Bessel function of the first kind + # `I_{\nu}(z) = z^{\nu} (iz)^{-\nu} J_{\nu}(iz)`. + + void arb_hypgeom_bessel_i_scaled(arb_t res, const arb_t nu, const arb_t z, long prec) + # Computes the function `e^{-z} I_{\nu}(z)`. + + void arb_hypgeom_bessel_k(arb_t res, const arb_t nu, const arb_t z, long prec) + # Computes the modified Bessel function of the second kind `K_{\nu}(z)`. + + void arb_hypgeom_bessel_k_scaled(arb_t res, const arb_t nu, const arb_t z, long prec) + # Computes the function `e^{z} K_{\nu}(z)`. + + void arb_hypgeom_bessel_i_integration(arb_t res, const arb_t nu, const arb_t z, int scaled, long prec) + void arb_hypgeom_bessel_k_integration(arb_t res, const arb_t nu, const arb_t z, int scaled, long prec) + # Computes the modified Bessel functions using numerical integration. + + void arb_hypgeom_airy(arb_t ai, arb_t ai_prime, arb_t bi, arb_t bi_prime, const arb_t z, long prec) + # Computes the Airy functions `(\operatorname{Ai}(z), \operatorname{Ai}'(z), \operatorname{Bi}(z), \operatorname{Bi}'(z))` + # simultaneously. Any of the four function values can be omitted by passing + # *NULL* for the unwanted output variables, speeding up the evaluation. + + void arb_hypgeom_airy_jet(arb_ptr ai, arb_ptr bi, const arb_t z, long len, long prec) + # Writes to *ai* and *bi* the respective Taylor expansions of the Airy functions + # at the point *z*, truncated to length *len*. + # Either of the outputs can be *NULL* to avoid computing that function. + # The variable *z* is not allowed to be aliased with the outputs. + # To simplify the implementation, this method does not compute the + # series expansions of the primed versions directly; these are + # easily obtained by computing one extra coefficient and differentiating + # the output with :func:`_arb_poly_derivative`. + + void _arb_hypgeom_airy_series(arb_ptr ai, arb_ptr ai_prime, arb_ptr bi, arb_ptr bi_prime, arb_srcptr z, long zlen, long len, long prec) + void arb_hypgeom_airy_series(arb_poly_t ai, arb_poly_t ai_prime, arb_poly_t bi, arb_poly_t bi_prime, const arb_poly_t z, long len, long prec) + # Computes the Airy functions evaluated at the power series *z*, + # truncated to length *len*. As with the other Airy methods, any of the + # outputs can be *NULL*. + + void arb_hypgeom_airy_zero(arb_t a, arb_t a_prime, arb_t b, arb_t b_prime, const fmpz_t n, long prec) + # Computes the *n*-th real zero `a_n`, `a'_n`, `b_n`, or `b'_n` + # for the respective Airy function or Airy function derivative. + # Any combination of the four output variables can be *NULL*. + # The zeros are indexed by increasing magnitude, starting with + # `n = 1` to follow the convention in the literature. + # An index *n* that is not positive is invalid input. + # The implementation uses asymptotic expansions for the zeros + # [PS1991]_ together with the interval Newton method for refinement. + + void arb_hypgeom_coulomb(arb_t F, arb_t G, const arb_t l, const arb_t eta, const arb_t z, long prec) + # Writes to *F*, *G* the values of the respective + # Coulomb wave functions `F_{\ell}(\eta,z)` and `G_{\ell}(\eta,z)`. + # Either of the outputs can be *NULL*. + + void arb_hypgeom_coulomb_jet(arb_ptr F, arb_ptr G, const arb_t l, const arb_t eta, const arb_t z, long len, long prec) + # Writes to *F*, *G* the respective Taylor expansions of the + # Coulomb wave functions at the point *z*, truncated to length *len*. + # Either of the outputs can be *NULL*. + + void _arb_hypgeom_coulomb_series(arb_ptr F, arb_ptr G, const arb_t l, const arb_t eta, arb_srcptr z, long zlen, long len, long prec) + void arb_hypgeom_coulomb_series(arb_poly_t F, arb_poly_t G, const arb_t l, const arb_t eta, const arb_poly_t z, long len, long prec) + # Computes the Coulomb wave functions evaluated at the power series *z*, + # truncated to length *len*. Either of the outputs can be *NULL*. + + void arb_hypgeom_chebyshev_t(arb_t res, const arb_t nu, const arb_t z, long prec) + void arb_hypgeom_chebyshev_u(arb_t res, const arb_t nu, const arb_t z, long prec) + void arb_hypgeom_jacobi_p(arb_t res, const arb_t n, const arb_t a, const arb_t b, const arb_t z, long prec) + void arb_hypgeom_gegenbauer_c(arb_t res, const arb_t n, const arb_t m, const arb_t z, long prec) + void arb_hypgeom_laguerre_l(arb_t res, const arb_t n, const arb_t m, const arb_t z, long prec) + void arb_hypgeom_hermite_h(arb_t res, const arb_t nu, const arb_t z, long prec) + # Computes Chebyshev, Jacobi, Gegenbauer, Laguerre or Hermite polynomials, + # or their extensions to non-integer orders. + + void arb_hypgeom_legendre_p(arb_t res, const arb_t n, const arb_t m, const arb_t z, int type, long prec) + void arb_hypgeom_legendre_q(arb_t res, const arb_t n, const arb_t m, const arb_t z, int type, long prec) + # Computes Legendre functions of the first and second kind. + # See :func:`acb_hypgeom_legendre_p` and :func:`acb_hypgeom_legendre_q` + # for definitions. + + void arb_hypgeom_legendre_p_ui_deriv_bound(mag_t dp, mag_t dp2, unsigned long n, const arb_t x, const arb_t x2sub1) + # Sets *dp* to an upper bound for `P'_n(x)` and *dp2* to an upper + # bound for `P''_n(x)` given *x* assumed to represent a real + # number with `|x| \le 1`. The variable *x2sub1* must contain + # the precomputed value `1-x^2` (or `x^2-1`). This method is used + # internally to bound the propagated error for Legendre polynomials. + + void arb_hypgeom_legendre_p_ui_zero(arb_t res, arb_t res_prime, unsigned long n, const arb_t x, long K, long prec) + void arb_hypgeom_legendre_p_ui_one(arb_t res, arb_t res_prime, unsigned long n, const arb_t x, long K, long prec) + void arb_hypgeom_legendre_p_ui_asymp(arb_t res, arb_t res_prime, unsigned long n, const arb_t x, long K, long prec) + void arb_hypgeom_legendre_p_ui_rec(arb_t res, arb_t res_prime, unsigned long n, const arb_t x, long prec) + void arb_hypgeom_legendre_p_ui(arb_t res, arb_t res_prime, unsigned long n, const arb_t x, long prec) + # Evaluates the ordinary Legendre polynomial `P_n(x)`. If *res_prime* is + # non-NULL, simultaneously evaluates the derivative `P'_n(x)`. + # The overall algorithm is described in [JM2018]_. + # The versions *zero*, *one* respectively use the hypergeometric series + # expansions at `x = 0` and `x = 1` while the *asymp* version uses an + # asymptotic series on `(-1,1)` intended for large *n*. The parameter *K* + # specifies the exact number of expansion terms to use (if the series + # expansion truncated at this point does not give the exact polynomial, + # an error bound is computed automatically). + # The asymptotic expansion with error bounds is given in [Bog2012]_. + # The *rec* version uses the forward recurrence implemented using + # fixed-point arithmetic; it is only intended for the interval `(-1,1)`, + # moderate *n* and modest precision. + # The default version attempts to choose the best algorithm automatically. + # It also estimates the amount of cancellation in the hypergeometric series + # and increases the working precision to compensate, bounding the + # propagated error using derivative bounds. + + void arb_hypgeom_legendre_p_ui_root(arb_t res, arb_t weight, unsigned long n, unsigned long k, long prec) + # Sets *res* to the *k*-th root of the Legendre polynomial `P_n(x)`. + # We index the roots in decreasing order + # .. math :: + # 1 > x_0 > x_1 > \ldots > x_{n-1} > -1 + # (which corresponds to ordering the roots of `P_n(\cos(\theta))` + # in order of increasing `\theta`). + # If *weight* is non-NULL, it is set to the weight corresponding + # to the node `x_k` for Gaussian quadrature on `[-1,1]`. + # Note that only `\lceil n / 2 \rceil` roots need to be computed, + # since the remaining roots are given by `x_k = -x_{n-1-k}`. + # We compute an enclosing interval using an asymptotic approximation followed + # by some number of Newton iterations, using the error bounds given + # in [Pet1999]_. If very high precision is requested, the root is + # subsequently refined using interval Newton steps with doubling working + # precision. + + void arb_hypgeom_dilog(arb_t res, const arb_t z, long prec) + # Computes the dilogarithm `\operatorname{Li}_2(z)`. + + void arb_hypgeom_sum_fmpq_arb_forward(arb_t res, const fmpq * a, long alen, const fmpq * b, long blen, const arb_t z, int reciprocal, long N, long prec) + void arb_hypgeom_sum_fmpq_arb_rs(arb_t res, const fmpq * a, long alen, const fmpq * b, long blen, const arb_t z, int reciprocal, long N, long prec) + void arb_hypgeom_sum_fmpq_arb(arb_t res, const fmpq * a, long alen, const fmpq * b, long blen, const arb_t z, int reciprocal, long N, long prec) + # Sets *res* to the finite hypergeometric sum + # `\sum_{n=0}^{N-1} (\textbf{a})_n z^n / (\textbf{b})_n` + # where `\textbf{x}_n = (x_1)_n (x_2)_n \cdots`, + # given vectors of rational parameters *a* (of length *alen*) + # and *b* (of length *blen*). + # If *reciprocal* is set, replace `z` by `1 / z`. + # The *forward* version uses the forward recurrence, optimized by + # delaying divisions, the *rs* version + # uses rectangular splitting, and the default version uses + # an automatic algorithm choice. + + void arb_hypgeom_sum_fmpq_imag_arb_forward(arb_t res1, arb_t res2, const fmpq * a, long alen, const fmpq * b, long blen, const arb_t z, int reciprocal, long N, long prec) + void arb_hypgeom_sum_fmpq_imag_arb_rs(arb_t res1, arb_t res2, const fmpq * a, long alen, const fmpq * b, long blen, const arb_t z, int reciprocal, long N, long prec) + void arb_hypgeom_sum_fmpq_imag_arb_bs(arb_t res1, arb_t res2, const fmpq * a, long alen, const fmpq * b, long blen, const arb_t z, int reciprocal, long N, long prec) + void arb_hypgeom_sum_fmpq_imag_arb(arb_t res1, arb_t res2, const fmpq * a, long alen, const fmpq * b, long blen, const arb_t z, int reciprocal, long N, long prec) + # Sets *res1* and *res2* to the real and imaginary part of the + # finite hypergeometric sum + # `\sum_{n=0}^{N-1} (\textbf{a})_n (i z)^n / (\textbf{b})_n`. + # If *reciprocal* is set, replace `z` by `1 / z`. diff --git a/src/sage/libs/flint/arb_mat.pxd b/src/sage/libs/flint/arb_mat.pxd new file mode 100644 index 00000000000..2bfe405fa14 --- /dev/null +++ b/src/sage/libs/flint/arb_mat.pxd @@ -0,0 +1,547 @@ +# distutils: libraries = flint +# distutils: depends = flint/arb_mat.h + +################################################################################ +# This file is auto-generated. Do not modify by hand +################################################################################ + +from libc.stdio cimport FILE +from sage.libs.gmp.types cimport * +from sage.libs.mpfr.types cimport * +from sage.libs.flint.types cimport * + +cdef extern from "flint_wrap.h": + + void arb_mat_init(arb_mat_t mat, long r, long c) + # Initializes the matrix, setting it to the zero matrix with *r* rows + # and *c* columns. + + void arb_mat_clear(arb_mat_t mat) + # Clears the matrix, deallocating all entries. + + long arb_mat_allocated_bytes(const arb_mat_t x) + # Returns the total number of bytes heap-allocated internally by this object. + # The count excludes the size of the structure itself. Add + # ``sizeof(arb_mat_struct)`` to get the size of the object as a whole. + + void arb_mat_window_init(arb_mat_t window, const arb_mat_t mat, long r1, long c1, long r2, long c2) + # Initializes *window* to a window matrix into the submatrix of *mat* + # starting at the corner at row *r1* and column *c1* (inclusive) and ending + # at row *r2* and column *c2* (exclusive). + + void arb_mat_window_clear(arb_mat_t window) + # Frees the window matrix. + + void arb_mat_set(arb_mat_t dest, const arb_mat_t src) + + void arb_mat_set_fmpz_mat(arb_mat_t dest, const fmpz_mat_t src) + + void arb_mat_set_round_fmpz_mat(arb_mat_t dest, const fmpz_mat_t src, long prec) + + void arb_mat_set_fmpq_mat(arb_mat_t dest, const fmpq_mat_t src, long prec) + # Sets *dest* to *src*. The operands must have identical dimensions. + + void arb_mat_randtest(arb_mat_t mat, flint_rand_t state, long prec, long mag_bits) + # Sets *mat* to a random matrix with up to *prec* bits of precision + # and with exponents of width up to *mag_bits*. + + void arb_mat_printd(const arb_mat_t mat, long digits) + # Prints each entry in the matrix with the specified number of decimal digits. + + void arb_mat_fprintd(FILE * file, const arb_mat_t mat, long digits) + # Prints each entry in the matrix with the specified number of decimal + # digits to the stream *file*. + + int arb_mat_equal(const arb_mat_t mat1, const arb_mat_t mat2) + # Returns whether the matrices have the same dimensions + # and identical intervals as entries. + + int arb_mat_overlaps(const arb_mat_t mat1, const arb_mat_t mat2) + # Returns whether the matrices have the same dimensions + # and each entry in *mat1* overlaps with the corresponding entry in *mat2*. + + int arb_mat_contains(const arb_mat_t mat1, const arb_mat_t mat2) + + int arb_mat_contains_fmpz_mat(const arb_mat_t mat1, const fmpz_mat_t mat2) + + int arb_mat_contains_fmpq_mat(const arb_mat_t mat1, const fmpq_mat_t mat2) + # Returns whether the matrices have the same dimensions and each entry + # in *mat2* is contained in the corresponding entry in *mat1*. + + int arb_mat_eq(const arb_mat_t mat1, const arb_mat_t mat2) + # Returns whether *mat1* and *mat2* certainly represent the same matrix. + + int arb_mat_ne(const arb_mat_t mat1, const arb_mat_t mat2) + # Returns whether *mat1* and *mat2* certainly do not represent the same matrix. + + int arb_mat_is_empty(const arb_mat_t mat) + # Returns whether the number of rows or the number of columns in *mat* is zero. + + int arb_mat_is_square(const arb_mat_t mat) + # Returns whether the number of rows is equal to the number of columns in *mat*. + + int arb_mat_is_exact(const arb_mat_t mat) + # Returns whether all entries in *mat* have zero radius. + + int arb_mat_is_zero(const arb_mat_t mat) + # Returns whether all entries in *mat* are exactly zero. + + int arb_mat_is_finite(const arb_mat_t mat) + # Returns whether all entries in *mat* are finite. + + int arb_mat_is_triu(const arb_mat_t mat) + # Returns whether *mat* is upper triangular; that is, all entries + # below the main diagonal are exactly zero. + + int arb_mat_is_tril(const arb_mat_t mat) + # Returns whether *mat* is lower triangular; that is, all entries + # above the main diagonal are exactly zero. + + int arb_mat_is_diag(const arb_mat_t mat) + # Returns whether *mat* is a diagonal matrix; that is, all entries + # off the main diagonal are exactly zero. + + void arb_mat_zero(arb_mat_t mat) + # Sets all entries in mat to zero. + + void arb_mat_one(arb_mat_t mat) + # Sets the entries on the main diagonal to ones, + # and all other entries to zero. + + void arb_mat_ones(arb_mat_t mat) + # Sets all entries in the matrix to ones. + + void arb_mat_indeterminate(arb_mat_t mat) + # Sets all entries in the matrix to indeterminate (NaN). + + void arb_mat_hilbert(arb_mat_t mat, long prec) + # Sets *mat* to the Hilbert matrix, which has entries `A_{j,k} = 1/(j+k+1)`. + + void arb_mat_pascal(arb_mat_t mat, int triangular, long prec) + # Sets *mat* to a Pascal matrix, whose entries are binomial coefficients. + # If *triangular* is 0, constructs a full symmetric matrix + # with the rows of Pascal's triangle as successive antidiagonals. + # If *triangular* is 1, constructs the upper triangular matrix with + # the rows of Pascal's triangle as columns, and if *triangular* is -1, + # constructs the lower triangular matrix with the rows of Pascal's + # triangle as rows. + # The entries are computed using recurrence relations. + # When the dimensions get large, some precision loss is possible; in that + # case, the user may wish to create the matrix at slightly higher precision + # and then round it to the final precision. + + void arb_mat_stirling(arb_mat_t mat, int kind, long prec) + # Sets *mat* to a Stirling matrix, whose entries are Stirling numbers. + # If *kind* is 0, the entries are set to the unsigned Stirling numbers + # of the first kind. If *kind* is 1, the entries are set to the signed + # Stirling numbers of the first kind. If *kind* is 2, the entries are + # set to the Stirling numbers of the second kind. + # The entries are computed using recurrence relations. + # When the dimensions get large, some precision loss is possible; in that + # case, the user may wish to create the matrix at slightly higher precision + # and then round it to the final precision. + + void arb_mat_dct(arb_mat_t mat, int type, long prec) + # Sets *mat* to the DCT (discrete cosine transform) matrix of order *n* + # where *n* is the smallest dimension of *mat* (if *mat* is not square, + # the matrix is extended periodically along the larger dimension). + # There are many different conventions for defining DCT matrices; here, + # we use the normalized "DCT-II" transform matrix + # .. math :: + # A_{j,k} = \sqrt{\frac{2}{n}} \cos\left(\frac{\pi j}{n} \left(k+\frac{1}{2}\right)\right) + # which satisfies `A^{-1} = A^T`. + # The *type* parameter is currently ignored and should be set to 0. + # In the future, it might be used to select a different convention. + + void arb_mat_transpose(arb_mat_t dest, const arb_mat_t src) + # Sets *dest* to the exact transpose *src*. The operands must have + # compatible dimensions. Aliasing is allowed. + + void arb_mat_bound_inf_norm(mag_t b, const arb_mat_t A) + # Sets *b* to an upper bound for the infinity norm (i.e. the largest + # absolute value row sum) of *A*. + + void arb_mat_frobenius_norm(arb_t res, const arb_mat_t A, long prec) + # Sets *res* to the Frobenius norm (i.e. the square root of the sum + # of squares of entries) of *A*. + + void arb_mat_bound_frobenius_norm(mag_t res, const arb_mat_t A) + # Sets *res* to an upper bound for the Frobenius norm of *A*. + + void arb_mat_neg(arb_mat_t dest, const arb_mat_t src) + # Sets *dest* to the exact negation of *src*. The operands must have + # the same dimensions. + + void arb_mat_add(arb_mat_t res, const arb_mat_t mat1, const arb_mat_t mat2, long prec) + # Sets res to the sum of *mat1* and *mat2*. The operands must have the same dimensions. + + void arb_mat_sub(arb_mat_t res, const arb_mat_t mat1, const arb_mat_t mat2, long prec) + # Sets *res* to the difference of *mat1* and *mat2*. The operands must have + # the same dimensions. + + void arb_mat_mul_classical(arb_mat_t C, const arb_mat_t A, const arb_mat_t B, long prec) + + void arb_mat_mul_threaded(arb_mat_t C, const arb_mat_t A, const arb_mat_t B, long prec) + + void arb_mat_mul_block(arb_mat_t C, const arb_mat_t A, const arb_mat_t B, long prec) + + void arb_mat_mul(arb_mat_t res, const arb_mat_t mat1, const arb_mat_t mat2, long prec) + # Sets *res* to the matrix product of *mat1* and *mat2*. The operands must have + # compatible dimensions for matrix multiplication. + # The *classical* version performs matrix multiplication in the trivial way. + # The *block* version decomposes the input matrices into one or several + # blocks of uniformly scaled matrices and multiplies + # large blocks via *fmpz_mat_mul*. It also invokes + # :func:`_arb_mat_addmul_rad_mag_fast` for the radius matrix multiplications. + # The *threaded* version performs classical multiplication but splits the + # computation over the number of threads returned by *flint_get_num_threads()*. + # The default version chooses an algorithm automatically. + + void arb_mat_mul_entrywise(arb_mat_t C, const arb_mat_t A, const arb_mat_t B, long prec) + # Sets *C* to the entrywise product of *A* and *B*. + # The operands must have the same dimensions. + + void arb_mat_sqr_classical(arb_mat_t B, const arb_mat_t A, long prec) + + void arb_mat_sqr(arb_mat_t res, const arb_mat_t mat, long prec) + + void arb_mat_pow_ui(arb_mat_t res, const arb_mat_t mat, unsigned long exp, long prec) + # Sets *res* to *mat* raised to the power *exp*. Requires that *mat* + # is a square matrix. + + void _arb_mat_addmul_rad_mag_fast(arb_mat_t C, mag_srcptr A, mag_srcptr B, long ar, long ac, long bc) + # Helper function for matrix multiplication. + # Adds to the radii of *C* the matrix product of the matrices represented + # by *A* and *B*, where *A* is a linear array of coefficients in row-major + # order and *B* is a linear array of coefficients in column-major order. + # This function assumes that all exponents are small and is unsafe + # for general use. + + void arb_mat_approx_mul(arb_mat_t res, const arb_mat_t mat1, const arb_mat_t mat2, long prec) + # Approximate matrix multiplication. The input radii are ignored and + # the output matrix is set to an approximate floating-point result. + # The radii in the output matrix will *not* necessarily be zeroed. + + void arb_mat_scalar_mul_2exp_si(arb_mat_t B, const arb_mat_t A, long c) + # Sets *B* to *A* multiplied by `2^c`. + + void arb_mat_scalar_addmul_si(arb_mat_t B, const arb_mat_t A, long c, long prec) + + void arb_mat_scalar_addmul_fmpz(arb_mat_t B, const arb_mat_t A, const fmpz_t c, long prec) + + void arb_mat_scalar_addmul_arb(arb_mat_t B, const arb_mat_t A, const arb_t c, long prec) + # Sets *B* to `B + A \times c`. + + void arb_mat_scalar_mul_si(arb_mat_t B, const arb_mat_t A, long c, long prec) + + void arb_mat_scalar_mul_fmpz(arb_mat_t B, const arb_mat_t A, const fmpz_t c, long prec) + + void arb_mat_scalar_mul_arb(arb_mat_t B, const arb_mat_t A, const arb_t c, long prec) + # Sets *B* to `A \times c`. + + void arb_mat_scalar_div_si(arb_mat_t B, const arb_mat_t A, long c, long prec) + + void arb_mat_scalar_div_fmpz(arb_mat_t B, const arb_mat_t A, const fmpz_t c, long prec) + + void arb_mat_scalar_div_arb(arb_mat_t B, const arb_mat_t A, const arb_t c, long prec) + # Sets *B* to `A / c`. + + int arb_mat_lu_classical(long * perm, arb_mat_t LU, const arb_mat_t A, long prec) + + int arb_mat_lu_recursive(long * perm, arb_mat_t LU, const arb_mat_t A, long prec) + + int arb_mat_lu(long * perm, arb_mat_t LU, const arb_mat_t A, long prec) + # Given an `n \times n` matrix `A`, computes an LU decomposition `PLU = A` + # using Gaussian elimination with partial pivoting. + # The input and output matrices can be the same, performing the + # decomposition in-place. + # Entry `i` in the permutation vector perm is set to the row index in + # the input matrix corresponding to row `i` in the output matrix. + # The algorithm succeeds and returns nonzero if it can find `n` invertible + # (i.e. not containing zero) pivot entries. This guarantees that the matrix + # is invertible. + # The algorithm fails and returns zero, leaving the entries in `P` and `LU` + # undefined, if it cannot find `n` invertible pivot elements. + # In this case, either the matrix is singular, the input matrix was + # computed to insufficient precision, or the LU decomposition was + # attempted at insufficient precision. + # The *classical* version uses Gaussian elimination directly while + # the *recursive* version performs the computation in a block recursive + # way to benefit from fast matrix multiplication. The default version + # chooses an algorithm automatically. + + void arb_mat_solve_tril_classical(arb_mat_t X, const arb_mat_t L, const arb_mat_t B, int unit, long prec) + + void arb_mat_solve_tril_recursive(arb_mat_t X, const arb_mat_t L, const arb_mat_t B, int unit, long prec) + + void arb_mat_solve_tril(arb_mat_t X, const arb_mat_t L, const arb_mat_t B, int unit, long prec) + + void arb_mat_solve_triu_classical(arb_mat_t X, const arb_mat_t U, const arb_mat_t B, int unit, long prec) + + void arb_mat_solve_triu_recursive(arb_mat_t X, const arb_mat_t U, const arb_mat_t B, int unit, long prec) + + void arb_mat_solve_triu(arb_mat_t X, const arb_mat_t U, const arb_mat_t B, int unit, long prec) + # Solves the lower triangular system `LX = B` or the upper triangular system + # `UX = B`, respectively. If *unit* is set, the main diagonal of *L* or *U* + # is taken to consist of all ones, and in that case the actual entries on + # the diagonal are not read at all and can contain other data. + # The *classical* versions perform the computations iteratively while the + # *recursive* versions perform the computations in a block recursive + # way to benefit from fast matrix multiplication. The default versions + # choose an algorithm automatically. + + void arb_mat_solve_lu_precomp(arb_mat_t X, const long * perm, const arb_mat_t LU, const arb_mat_t B, long prec) + # Solves `AX = B` given the precomputed nonsingular LU decomposition `A = PLU`. + # The matrices `X` and `B` are allowed to be aliased with each other, + # but `X` is not allowed to be aliased with `LU`. + + int arb_mat_solve(arb_mat_t X, const arb_mat_t A, const arb_mat_t B, long prec) + + int arb_mat_solve_lu(arb_mat_t X, const arb_mat_t A, const arb_mat_t B, long prec) + + int arb_mat_solve_precond(arb_mat_t X, const arb_mat_t A, const arb_mat_t B, long prec) + # Solves `AX = B` where `A` is a nonsingular `n \times n` matrix + # and `X` and `B` are `n \times m` matrices. + # If `m > 0` and `A` cannot be inverted numerically (indicating either that + # `A` is singular or that the precision is insufficient), the values in the + # output matrix are left undefined and zero is returned. A nonzero return + # value guarantees that `A` is invertible and that the exact solution + # matrix is contained in the output. + # Three algorithms are provided: + # * The *lu* version performs LU decomposition directly in ball arithmetic. + # This is fast, but the bounds typically blow up exponentially with *n*, + # even if the system is well-conditioned. This algorithm is usually + # the best choice at very high precision. + # * The *precond* version computes an approximate inverse to precondition + # the system [HS1967]_. This is usually several times slower than direct LU + # decomposition, but the bounds do not blow up with *n* if the system is + # well-conditioned. This algorithm is usually + # the best choice for large systems at low to moderate precision. + # * The default version selects between *lu* and *precomp* automatically. + # The automatic choice should be reasonable most of the time, but users + # may benefit from trying either *lu* or *precond* in specific applications. + # For example, the *lu* solver often performs better for ill-conditioned + # systems where use of very high precision is unavoidable. + + int arb_mat_solve_preapprox(arb_mat_t X, const arb_mat_t A, const arb_mat_t B, const arb_mat_t R, const arb_mat_t T, long prec) + # Solves `AX = B` where `A` is a nonsingular `n \times n` matrix + # and `X` and `B` are `n \times m` matrices, given an approximation + # `R` of the matrix inverse of `A`, and given the approximation `T` + # of the solution `X`. + # If `m > 0` and `A` cannot be inverted numerically (indicating either that + # `A` is singular or that the precision is insufficient, or that `R` is + # not a close enough approximation of the inverse of `A`), the values in the + # output matrix are left undefined and zero is returned. A nonzero return + # value guarantees that `A` is invertible and that the exact solution + # matrix is contained in the output. + + int arb_mat_inv(arb_mat_t X, const arb_mat_t A, long prec) + # Sets `X = A^{-1}` where `A` is a square matrix, computed by solving + # the system `AX = I`. + # If `A` cannot be inverted numerically (indicating either that + # `A` is singular or that the precision is insufficient), the values in the + # output matrix are left undefined and zero is returned. + # A nonzero return value guarantees that the matrix is invertible + # and that the exact inverse is contained in the output. + + void arb_mat_det_lu(arb_t det, const arb_mat_t A, long prec) + + void arb_mat_det_precond(arb_t det, const arb_mat_t A, long prec) + + void arb_mat_det(arb_t det, const arb_mat_t A, long prec) + # Sets *det* to the determinant of the matrix *A*. + # The *lu* version uses Gaussian elimination with partial pivoting. If at + # some point an invertible pivot element cannot be found, the elimination is + # stopped and the magnitude of the determinant of the remaining submatrix + # is bounded using Hadamard's inequality. + # The *precond* version computes an approximate LU factorization of *A* + # and multiplies by the inverse *L* and *U* martices as preconditioners + # to obtain a matrix close to the identity matrix [Rum2010]_. An enclosure + # for this determinant is computed using Gershgorin circles. This is about + # four times slower than direct Gaussian elimination, but much more + # numerically stable. + # The default version automatically selects between the *lu* and *precond* + # versions and additionally handles small or triangular matrices + # by direct formulas. + + void arb_mat_approx_solve_triu(arb_mat_t X, const arb_mat_t U, const arb_mat_t B, int unit, long prec) + + void arb_mat_approx_solve_tril(arb_mat_t X, const arb_mat_t L, const arb_mat_t B, int unit, long prec) + + int arb_mat_approx_lu(long * P, arb_mat_t LU, const arb_mat_t A, long prec) + + void arb_mat_approx_solve_lu_precomp(arb_mat_t X, const long * perm, const arb_mat_t A, const arb_mat_t B, long prec) + + int arb_mat_approx_solve(arb_mat_t X, const arb_mat_t A, const arb_mat_t B, long prec) + + int arb_mat_approx_inv(arb_mat_t X, const arb_mat_t A, long prec) + # These methods perform approximate solving *without any error control*. + # The radii in the input matrices are ignored, the computations are done + # numerically with floating-point arithmetic (using ordinary + # Gaussian elimination and triangular solving, accelerated through + # the use of block recursive strategies for large matrices), and the + # output matrices are set to the approximate floating-point results with + # zeroed error bounds. + # Approximate solutions are useful for computing preconditioning matrices + # for certified solutions. Some users may also find these methods useful + # for doing ordinary numerical linear algebra in applications where + # error bounds are not needed. + + int _arb_mat_cholesky_banachiewicz(arb_mat_t A, long prec) + + int arb_mat_cho(arb_mat_t L, const arb_mat_t A, long prec) + # Computes the Cholesky decomposition of *A*, returning nonzero iff + # the symmetric matrix defined by the lower triangular part of *A* + # is certainly positive definite. + # If a nonzero value is returned, then *L* is set to the lower triangular + # matrix such that `A = L * L^T`. + # If zero is returned, then either the matrix is not symmetric positive + # definite, the input matrix was computed to insufficient precision, + # or the decomposition was attempted at insufficient precision. + # The underscore method computes *L* from *A* in-place, leaving the + # strict upper triangular region undefined. + + void arb_mat_solve_cho_precomp(arb_mat_t X, const arb_mat_t L, const arb_mat_t B, long prec) + # Solves `AX = B` given the precomputed Cholesky decomposition `A = L L^T`. + # The matrices *X* and *B* are allowed to be aliased with each other, + # but *X* is not allowed to be aliased with *L*. + + int arb_mat_spd_solve(arb_mat_t X, const arb_mat_t A, const arb_mat_t B, long prec) + # Solves `AX = B` where *A* is a symmetric positive definite matrix + # and *X* and *B* are `n \times m` matrices, using Cholesky decomposition. + # If `m > 0` and *A* cannot be factored using Cholesky decomposition + # (indicating either that *A* is not symmetric positive definite or that + # the precision is insufficient), the values in the + # output matrix are left undefined and zero is returned. A nonzero return + # value guarantees that the symmetric matrix defined through the lower + # triangular part of *A* is invertible and that the exact solution matrix + # is contained in the output. + + void arb_mat_inv_cho_precomp(arb_mat_t X, const arb_mat_t L, long prec) + # Sets `X = A^{-1}` where `A` is a symmetric positive definite matrix + # whose Cholesky decomposition *L* has been computed with + # :func:`arb_mat_cho`. + # The inverse is calculated using the method of [Kri2013]_ which is more + # efficient than solving `AX = I` with :func:`arb_mat_solve_cho_precomp`. + + int arb_mat_spd_inv(arb_mat_t X, const arb_mat_t A, long prec) + # Sets `X = A^{-1}` where *A* is a symmetric positive definite matrix. + # It is calculated using the method of [Kri2013]_ which computes fewer + # intermediate results than solving `AX = I` with :func:`arb_mat_spd_solve`. + # If *A* cannot be factored using Cholesky decomposition + # (indicating either that *A* is not symmetric positive definite or that + # the precision is insufficient), the values in the + # output matrix are left undefined and zero is returned. A nonzero return + # value guarantees that the symmetric matrix defined through the lower + # triangular part of *A* is invertible and that the exact inverse + # is contained in the output. + + int _arb_mat_ldl_inplace(arb_mat_t A, long prec) + + int _arb_mat_ldl_golub_and_van_loan(arb_mat_t A, long prec) + + int arb_mat_ldl(arb_mat_t res, const arb_mat_t A, long prec) + # Computes the `LDL^T` decomposition of *A*, returning nonzero iff + # the symmetric matrix defined by the lower triangular part of *A* + # is certainly positive definite. + # If a nonzero value is returned, then *res* is set to a lower triangular + # matrix that encodes the `L * D * L^T` decomposition of *A*. + # In particular, `L` is a lower triangular matrix with ones on its diagonal + # and whose strictly lower triangular region is the same as that of *res*. + # `D` is a diagonal matrix with the same diagonal as that of *res*. + # If zero is returned, then either the matrix is not symmetric positive + # definite, the input matrix was computed to insufficient precision, + # or the decomposition was attempted at insufficient precision. + # The underscore methods compute *res* from *A* in-place, leaving the + # strict upper triangular region undefined. + # The default method uses algorithm 4.1.2 from [GVL1996]_. + + void arb_mat_solve_ldl_precomp(arb_mat_t X, const arb_mat_t L, const arb_mat_t B, long prec) + # Solves `AX = B` given the precomputed `A = LDL^T` decomposition + # encoded by *L*. The matrices *X* and *B* are allowed to be aliased + # with each other, but *X* is not allowed to be aliased with *L*. + + void arb_mat_inv_ldl_precomp(arb_mat_t X, const arb_mat_t L, long prec) + # Sets `X = A^{-1}` where `A` is a symmetric positive definite matrix + # whose `LDL^T` decomposition encoded by *L* has been computed with + # :func:`arb_mat_ldl`. + # The inverse is calculated using the method of [Kri2013]_ which is more + # efficient than solving `AX = I` with :func:`arb_mat_solve_ldl_precomp`. + + void _arb_mat_charpoly(arb_ptr poly, const arb_mat_t mat, long prec) + + void arb_mat_charpoly(arb_poly_t poly, const arb_mat_t mat, long prec) + # Sets *poly* to the characteristic polynomial of *mat* which must be + # a square matrix. If the matrix has *n* rows, the underscore method + # requires space for `n + 1` output coefficients. + # Employs a division-free algorithm using `O(n^4)` operations. + + void _arb_mat_companion(arb_mat_t mat, arb_srcptr poly, long prec) + + void arb_mat_companion(arb_mat_t mat, const arb_poly_t poly, long prec) + # Sets the *n* by *n* matrix *mat* to the companion matrix of the polynomial + # *poly* which must have degree *n*. + # The underscore method reads `n + 1` input coefficients. + + void arb_mat_exp_taylor_sum(arb_mat_t S, const arb_mat_t A, long N, long prec) + # Sets *S* to the truncated exponential Taylor series `S = \sum_{k=0}^{N-1} A^k / k!`. + # Uses rectangular splitting to compute the sum using `O(\sqrt{N})` + # matrix multiplications. The recurrence relation for factorials + # is used to get scalars that are small integers instead of full + # factorials. As in [Joh2014b]_, all divisions are postponed to + # the end by computing partial factorials of length `O(\sqrt{N})`. + # The scalars could be reduced by doing more divisions, but this + # appears to be slower in most cases. + + void arb_mat_exp(arb_mat_t B, const arb_mat_t A, long prec) + # Sets *B* to the exponential of the matrix *A*, defined by the Taylor series + # .. math :: + # \exp(A) = \sum_{k=0}^{\infty} \frac{A^k}{k!}. + # The function is evaluated as `\exp(A/2^r)^{2^r}`, where `r` is chosen + # to give rapid convergence. + # The elementwise error when truncating the Taylor series after *N* + # terms is bounded by the error in the infinity norm, for which we have + # .. math :: + # \left\|\exp(2^{-r}A) - \sum_{k=0}^{N-1} + # \frac{\left(2^{-r} A\right)^k}{k!} \right\|_{\infty} = + # \left\|\sum_{k=N}^{\infty} \frac{\left(2^{-r} A\right)^k}{k!}\right\|_{\infty} \le + # \sum_{k=N}^{\infty} \frac{(2^{-r} \|A\|_{\infty})^k}{k!}. + # We bound the sum on the right using :func:`mag_exp_tail`. + # Truncation error is not added to entries whose values are determined + # by the sparsity structure of `A`. + + void arb_mat_trace(arb_t trace, const arb_mat_t mat, long prec) + # Sets *trace* to the trace of the matrix, i.e. the sum of entries on the + # main diagonal of *mat*. The matrix is required to be square. + + void _arb_mat_diag_prod(arb_t res, const arb_mat_t mat, long a, long b, long prec) + + void arb_mat_diag_prod(arb_t res, const arb_mat_t mat, long prec) + # Sets *res* to the product of the entries on the main diagonal of *mat*. + # The underscore method computes the product of the entries between + # index *a* inclusive and *b* exclusive (the indices must be in range). + + void arb_mat_entrywise_is_zero(fmpz_mat_t dest, const arb_mat_t src) + # Sets each entry of *dest* to indicate whether the corresponding + # entry of *src* is certainly zero. + # If the entry of *src* at row `i` and column `j` is zero according to + # :func:`arb_is_zero` then the entry of *dest* at that row and column + # is set to one, otherwise that entry of *dest* is set to zero. + + void arb_mat_entrywise_not_is_zero(fmpz_mat_t dest, const arb_mat_t src) + # Sets each entry of *dest* to indicate whether the corresponding + # entry of *src* is not certainly zero. + # This the complement of :func:`arb_mat_entrywise_is_zero`. + + long arb_mat_count_is_zero(const arb_mat_t mat) + # Returns the number of entries of *mat* that are certainly zero + # according to :func:`arb_is_zero`. + + long arb_mat_count_not_is_zero(const arb_mat_t mat) + # Returns the number of entries of *mat* that are not certainly zero. + + void arb_mat_get_mid(arb_mat_t B, const arb_mat_t A) + # Sets the entries of *B* to the exact midpoints of the entries of *A*. + + void arb_mat_add_error_mag(arb_mat_t mat, const mag_t err) + # Adds *err* in-place to the radii of the entries of *mat*. diff --git a/src/sage/libs/flint/arb_poly.pxd b/src/sage/libs/flint/arb_poly.pxd new file mode 100644 index 00000000000..e71fa90ec2a --- /dev/null +++ b/src/sage/libs/flint/arb_poly.pxd @@ -0,0 +1,874 @@ +# distutils: libraries = flint +# distutils: depends = flint/arb_poly.h + +################################################################################ +# This file is auto-generated. Do not modify by hand +################################################################################ + +from libc.stdio cimport FILE +from sage.libs.gmp.types cimport * +from sage.libs.mpfr.types cimport * +from sage.libs.flint.types cimport * + +cdef extern from "flint_wrap.h": + + void arb_poly_init(arb_poly_t poly) + # Initializes the polynomial for use, setting it to the zero polynomial. + + void arb_poly_clear(arb_poly_t poly) + # Clears the polynomial, deallocating all coefficients and the + # coefficient array. + + void arb_poly_fit_length(arb_poly_t poly, long len) + # Makes sure that the coefficient array of the polynomial contains at + # least *len* initialized coefficients. + + void _arb_poly_set_length(arb_poly_t poly, long len) + # Directly changes the length of the polynomial, without allocating or + # deallocating coefficients. The value should not exceed the allocation length. + + void _arb_poly_normalise(arb_poly_t poly) + # Strips any trailing coefficients which are identical to zero. + + long arb_poly_allocated_bytes(const arb_poly_t x) + # Returns the total number of bytes heap-allocated internally by this object. + # The count excludes the size of the structure itself. Add + # ``sizeof(arb_poly_struct)`` to get the size of the object as a whole. + + long arb_poly_length(const arb_poly_t poly) + # Returns the length of *poly*, i.e. zero if *poly* is + # identically zero, and otherwise one more than the index + # of the highest term that is not identically zero. + + long arb_poly_degree(const arb_poly_t poly) + # Returns the degree of *poly*, defined as one less than its length. + # Note that if one or several leading coefficients are balls + # containing zero, this value can be larger than the true + # degree of the exact polynomial represented by *poly*, + # so the return value of this function is effectively + # an upper bound. + + int arb_poly_is_zero(const arb_poly_t poly) + + int arb_poly_is_one(const arb_poly_t poly) + + int arb_poly_is_x(const arb_poly_t poly) + # Returns 1 if *poly* is exactly the polynomial 0, 1 or *x* + # respectively. Returns 0 otherwise. + + void arb_poly_zero(arb_poly_t poly) + + void arb_poly_one(arb_poly_t poly) + # Sets *poly* to the constant 0 respectively 1. + + void arb_poly_set(arb_poly_t dest, const arb_poly_t src) + # Sets *dest* to a copy of *src*. + + void arb_poly_set_round(arb_poly_t dest, const arb_poly_t src, long prec) + # Sets *dest* to a copy of *src*, rounded to *prec* bits. + + void arb_poly_set_trunc(arb_poly_t dest, const arb_poly_t src, long n) + + void arb_poly_set_trunc_round(arb_poly_t dest, const arb_poly_t src, long n, long prec) + # Sets *dest* to a copy of *src*, truncated to length *n* and rounded to *prec* bits. + + void arb_poly_set_coeff_si(arb_poly_t poly, long n, long c) + + void arb_poly_set_coeff_arb(arb_poly_t poly, long n, const arb_t c) + # Sets the coefficient with index *n* in *poly* to the value *c*. + # We require that *n* is nonnegative. + + void arb_poly_get_coeff_arb(arb_t v, const arb_poly_t poly, long n) + # Sets *v* to the value of the coefficient with index *n* in *poly*. + # We require that *n* is nonnegative. + + void _arb_poly_shift_right(arb_ptr res, arb_srcptr poly, long len, long n) + + void arb_poly_shift_right(arb_poly_t res, const arb_poly_t poly, long n) + # Sets *res* to *poly* divided by `x^n`, throwing away the lower coefficients. + # We require that *n* is nonnegative. + + void _arb_poly_shift_left(arb_ptr res, arb_srcptr poly, long len, long n) + + void arb_poly_shift_left(arb_poly_t res, const arb_poly_t poly, long n) + # Sets *res* to *poly* multiplied by `x^n`. + # We require that *n* is nonnegative. + + void arb_poly_truncate(arb_poly_t poly, long n) + # Truncates *poly* to have length at most *n*, i.e. degree + # strictly smaller than *n*. We require that *n* is nonnegative. + + long arb_poly_valuation(const arb_poly_t poly) + # Returns the degree of the lowest term that is not exactly zero in *poly*. + # Returns -1 if *poly* is the zero polynomial. + + void arb_poly_set_fmpz_poly(arb_poly_t poly, const fmpz_poly_t src, long prec) + + void arb_poly_set_fmpq_poly(arb_poly_t poly, const fmpq_poly_t src, long prec) + + void arb_poly_set_si(arb_poly_t poly, long src) + # Sets *poly* to *src*, rounding the coefficients to *prec* bits. + + void arb_poly_printd(const arb_poly_t poly, long digits) + # Prints the polynomial as an array of coefficients, printing each + # coefficient using *arb_printd*. + + void arb_poly_fprintd(FILE * file, const arb_poly_t poly, long digits) + # Prints the polynomial as an array of coefficients to the stream *file*, + # printing each coefficient using *arb_fprintd*. + + void arb_poly_randtest(arb_poly_t poly, flint_rand_t state, long len, long prec, long mag_bits) + # Creates a random polynomial with length at most *len*. + + int arb_poly_contains(const arb_poly_t poly1, const arb_poly_t poly2) + + int arb_poly_contains_fmpz_poly(const arb_poly_t poly1, const fmpz_poly_t poly2) + + int arb_poly_contains_fmpq_poly(const arb_poly_t poly1, const fmpq_poly_t poly2) + # Returns nonzero iff *poly1* contains *poly2*. + + int arb_poly_equal(const arb_poly_t A, const arb_poly_t B) + # Returns nonzero iff *A* and *B* are equal as polynomial balls, i.e. all + # coefficients have equal midpoint and radius. + + int _arb_poly_overlaps(arb_srcptr poly1, long len1, arb_srcptr poly2, long len2) + + int arb_poly_overlaps(const arb_poly_t poly1, const arb_poly_t poly2) + # Returns nonzero iff *poly1* overlaps with *poly2*. The underscore + # function requires that *len1* ist at least as large as *len2*. + + int arb_poly_get_unique_fmpz_poly(fmpz_poly_t z, const arb_poly_t x) + # If *x* contains a unique integer polynomial, sets *z* to that value and returns + # nonzero. Otherwise (if *x* represents no integers or more than one integer), + # returns zero, possibly partially modifying *z*. + + void _arb_poly_majorant(arb_ptr res, arb_srcptr poly, long len, long prec) + + void arb_poly_majorant(arb_poly_t res, const arb_poly_t poly, long prec) + # Sets *res* to an exact real polynomial whose coefficients are + # upper bounds for the absolute values of the coefficients in *poly*, + # rounded to *prec* bits. + + void _arb_poly_add(arb_ptr C, arb_srcptr A, long lenA, arb_srcptr B, long lenB, long prec) + # Sets *{C, max(lenA, lenB)}* to the sum of *{A, lenA}* and *{B, lenB}*. + # Allows aliasing of the input and output operands. + + void arb_poly_add(arb_poly_t C, const arb_poly_t A, const arb_poly_t B, long prec) + + void arb_poly_add_si(arb_poly_t C, const arb_poly_t A, long B, long prec) + # Sets *C* to the sum of *A* and *B*. + + void _arb_poly_sub(arb_ptr C, arb_srcptr A, long lenA, arb_srcptr B, long lenB, long prec) + # Sets *{C, max(lenA, lenB)}* to the difference of *{A, lenA}* and *{B, lenB}*. + # Allows aliasing of the input and output operands. + + void arb_poly_sub(arb_poly_t C, const arb_poly_t A, const arb_poly_t B, long prec) + # Sets *C* to the difference of *A* and *B*. + + void arb_poly_add_series(arb_poly_t C, const arb_poly_t A, const arb_poly_t B, long len, long prec) + # Sets *C* to the sum of *A* and *B*, truncated to length *len*. + + void arb_poly_sub_series(arb_poly_t C, const arb_poly_t A, const arb_poly_t B, long len, long prec) + # Sets *C* to the difference of *A* and *B*, truncated to length *len*. + + void arb_poly_neg(arb_poly_t C, const arb_poly_t A) + # Sets *C* to the negation of *A*. + + void arb_poly_scalar_mul_2exp_si(arb_poly_t C, const arb_poly_t A, long c) + # Sets *C* to *A* multiplied by `2^c`. + + void arb_poly_scalar_mul(arb_poly_t C, const arb_poly_t A, const arb_t c, long prec) + # Sets *C* to *A* multiplied by *c*. + + void arb_poly_scalar_div(arb_poly_t C, const arb_poly_t A, const arb_t c, long prec) + # Sets *C* to *A* divided by *c*. + + void _arb_poly_mullow_classical(arb_ptr C, arb_srcptr A, long lenA, arb_srcptr B, long lenB, long n, long prec) + + void _arb_poly_mullow_block(arb_ptr C, arb_srcptr A, long lenA, arb_srcptr B, long lenB, long n, long prec) + + void _arb_poly_mullow(arb_ptr C, arb_srcptr A, long lenA, arb_srcptr B, long lenB, long n, long prec) + # Sets *{C, n}* to the product of *{A, lenA}* and *{B, lenB}*, truncated to + # length *n*. The output is not allowed to be aliased with either of the + # inputs. We require `\mathrm{lenA} \ge \mathrm{lenB} > 0`, + # `n > 0`, `\mathrm{lenA} + \mathrm{lenB} - 1 \ge n`. + # The *classical* version uses a plain loop. This has good numerical + # stability but gets slow for large *n*. + # The *block* version decomposes the product into several + # subproducts which are computed exactly over the integers. + # It first attempts to find an integer `c` + # such that `A(2^c x)` and `B(2^c x)` have slowly varying + # coefficients, to reduce the number of blocks. + # The scaling factor `c` is chosen in a quick, heuristic way + # by picking the first and last nonzero terms in each polynomial. + # If the indices in `A` are `a_2, a_1` and the log-2 magnitudes + # are `e_2, e_1`, and the indices in `B` are `b_2, b_1` + # with corresponding magnitudes `f_2, f_1`, then we compute + # `c` as the weighted arithmetic mean of the slopes, + # rounded to the nearest integer: + # .. math :: + # c = \left\lfloor + # \frac{(e_2 - e_1) + (f_2 + f_1)}{(a_2 - a_1) + (b_2 - b_1)} + # + \frac{1}{2} + # \right \rfloor. + # This strategy is used because it is simple. It is not optimal + # in all cases, but will typically give good performance when + # multiplying two power series with a similar decay rate. + # The default algorithm chooses the *classical* algorithm for + # short polynomials and the *block* algorithm for long polynomials. + # If the input pointers are identical (and the lengths are the same), + # they are assumed to represent the same polynomial, and its + # square is computed. + + void arb_poly_mullow_classical(arb_poly_t C, const arb_poly_t A, const arb_poly_t B, long n, long prec) + + void arb_poly_mullow_ztrunc(arb_poly_t C, const arb_poly_t A, const arb_poly_t B, long n, long prec) + + void arb_poly_mullow_block(arb_poly_t C, const arb_poly_t A, const arb_poly_t B, long n, long prec) + + void arb_poly_mullow(arb_poly_t C, const arb_poly_t A, const arb_poly_t B, long n, long prec) + # Sets *C* to the product of *A* and *B*, truncated to length *n*. + # If the same variable is passed for *A* and *B*, sets *C* to the square + # of *A* truncated to length *n*. + + void _arb_poly_mul(arb_ptr C, arb_srcptr A, long lenA, arb_srcptr B, long lenB, long prec) + # Sets *{C, lenA + lenB - 1}* to the product of *{A, lenA}* and *{B, lenB}*. + # The output is not allowed to be aliased with either of the + # inputs. We require `\mathrm{lenA} \ge \mathrm{lenB} > 0`. + # This function is implemented as a simple wrapper for :func:`_arb_poly_mullow`. + # If the input pointers are identical (and the lengths are the same), + # they are assumed to represent the same polynomial, and its + # square is computed. + + void arb_poly_mul(arb_poly_t C, const arb_poly_t A, const arb_poly_t B, long prec) + # Sets *C* to the product of *A* and *B*. + # If the same variable is passed for *A* and *B*, sets *C* to the + # square of *A*. + + void _arb_poly_inv_series(arb_ptr Q, arb_srcptr A, long Alen, long len, long prec) + # Sets *{Q, len}* to the power series inverse of *{A, Alen}*. Uses Newton iteration. + + void arb_poly_inv_series(arb_poly_t Q, const arb_poly_t A, long n, long prec) + # Sets *Q* to the power series inverse of *A*, truncated to length *n*. + + void _arb_poly_div_series(arb_ptr Q, arb_srcptr A, long Alen, arb_srcptr B, long Blen, long n, long prec) + # Sets *{Q, n}* to the power series quotient of *{A, Alen}* by *{B, Blen}*. + # Uses Newton iteration followed by multiplication. + + void arb_poly_div_series(arb_poly_t Q, const arb_poly_t A, const arb_poly_t B, long n, long prec) + # Sets *Q* to the power series quotient *A* divided by *B*, truncated to length *n*. + + void _arb_poly_div(arb_ptr Q, arb_srcptr A, long lenA, arb_srcptr B, long lenB, long prec) + + void _arb_poly_rem(arb_ptr R, arb_srcptr A, long lenA, arb_srcptr B, long lenB, long prec) + + void _arb_poly_divrem(arb_ptr Q, arb_ptr R, arb_srcptr A, long lenA, arb_srcptr B, long lenB, long prec) + + int arb_poly_divrem(arb_poly_t Q, arb_poly_t R, const arb_poly_t A, const arb_poly_t B, long prec) + # Performs polynomial division with remainder, computing a quotient `Q` and + # a remainder `R` such that `A = BQ + R`. The implementation reverses the + # inputs and performs power series division. + # If the leading coefficient of `B` contains zero (or if `B` is identically + # zero), returns 0 indicating failure without modifying the outputs. + # Otherwise returns nonzero. + + void _arb_poly_div_root(arb_ptr Q, arb_t R, arb_srcptr A, long len, const arb_t c, long prec) + # Divides `A` by the polynomial `x - c`, computing the quotient `Q` as well + # as the remainder `R = f(c)`. + + void _arb_poly_taylor_shift(arb_ptr g, const arb_t c, long n, long prec) + void arb_poly_taylor_shift(arb_poly_t g, const arb_poly_t f, const arb_t c, long prec) + # Sets *g* to the Taylor shift `f(x+c)`. + # The underscore methods act in-place on *g* = *f* which has length *n*. + + void _arb_poly_compose(arb_ptr res, arb_srcptr poly1, long len1, arb_srcptr poly2, long len2, long prec) + void arb_poly_compose(arb_poly_t res, const arb_poly_t poly1, const arb_poly_t poly2, long prec) + # Sets *res* to the composition `h(x) = f(g(x))` where `f` is given by + # *poly1* and `g` is given by *poly2*. + # The underscore method does not support aliasing of the output + # with either input polynomial. + + void _arb_poly_compose_series(arb_ptr res, arb_srcptr poly1, long len1, arb_srcptr poly2, long len2, long n, long prec) + void arb_poly_compose_series(arb_poly_t res, const arb_poly_t poly1, const arb_poly_t poly2, long n, long prec) + # Sets *res* to the power series composition `h(x) = f(g(x))` truncated + # to order `O(x^n)` where `f` is given by *poly1* and `g` is given by *poly2*. + # Wraps :func:`_gr_poly_compose_series` which chooses automatically + # between various algorithms. + # We require that the constant term in `g(x)` is exactly zero. + # The underscore method does not support aliasing of the output + # with either input polynomial. + + void _arb_poly_revert_series_lagrange(arb_ptr h, arb_srcptr f, long flen, long n, long prec) + + void arb_poly_revert_series_lagrange(arb_poly_t h, const arb_poly_t f, long n, long prec) + + void _arb_poly_revert_series_newton(arb_ptr h, arb_srcptr f, long flen, long n, long prec) + + void arb_poly_revert_series_newton(arb_poly_t h, const arb_poly_t f, long n, long prec) + + void _arb_poly_revert_series_lagrange_fast(arb_ptr h, arb_srcptr f, long flen, long n, long prec) + + void arb_poly_revert_series_lagrange_fast(arb_poly_t h, const arb_poly_t f, long n, long prec) + + void _arb_poly_revert_series(arb_ptr h, arb_srcptr f, long flen, long n, long prec) + + void arb_poly_revert_series(arb_poly_t h, const arb_poly_t f, long n, long prec) + # Sets `h` to the power series reversion of `f`, i.e. the expansion + # of the compositional inverse function `f^{-1}(x)`, + # truncated to order `O(x^n)`, using respectively + # Lagrange inversion, Newton iteration, fast Lagrange inversion, + # and a default algorithm choice. + # We require that the constant term in `f` is exactly zero and that the + # linear term is nonzero. The underscore methods assume that *flen* + # is at least 2, and do not support aliasing. + + void _arb_poly_evaluate_horner(arb_t y, arb_srcptr f, long len, const arb_t x, long prec) + + void arb_poly_evaluate_horner(arb_t y, const arb_poly_t f, const arb_t x, long prec) + + void _arb_poly_evaluate_rectangular(arb_t y, arb_srcptr f, long len, const arb_t x, long prec) + + void arb_poly_evaluate_rectangular(arb_t y, const arb_poly_t f, const arb_t x, long prec) + + void _arb_poly_evaluate(arb_t y, arb_srcptr f, long len, const arb_t x, long prec) + + void arb_poly_evaluate(arb_t y, const arb_poly_t f, const arb_t x, long prec) + # Sets `y = f(x)`, evaluated respectively using Horner's rule, + # rectangular splitting, and an automatic algorithm choice. + + void _arb_poly_evaluate_acb_horner(acb_t y, arb_srcptr f, long len, const acb_t x, long prec) + + void arb_poly_evaluate_acb_horner(acb_t y, const arb_poly_t f, const acb_t x, long prec) + + void _arb_poly_evaluate_acb_rectangular(acb_t y, arb_srcptr f, long len, const acb_t x, long prec) + + void arb_poly_evaluate_acb_rectangular(acb_t y, const arb_poly_t f, const acb_t x, long prec) + + void _arb_poly_evaluate_acb(acb_t y, arb_srcptr f, long len, const acb_t x, long prec) + + void arb_poly_evaluate_acb(acb_t y, const arb_poly_t f, const acb_t x, long prec) + # Sets `y = f(x)` where `x` is a complex number, evaluating the + # polynomial respectively using Horner's rule, + # rectangular splitting, and an automatic algorithm choice. + + void _arb_poly_evaluate2_horner(arb_t y, arb_t z, arb_srcptr f, long len, const arb_t x, long prec) + + void arb_poly_evaluate2_horner(arb_t y, arb_t z, const arb_poly_t f, const arb_t x, long prec) + + void _arb_poly_evaluate2_rectangular(arb_t y, arb_t z, arb_srcptr f, long len, const arb_t x, long prec) + + void arb_poly_evaluate2_rectangular(arb_t y, arb_t z, const arb_poly_t f, const arb_t x, long prec) + + void _arb_poly_evaluate2(arb_t y, arb_t z, arb_srcptr f, long len, const arb_t x, long prec) + + void arb_poly_evaluate2(arb_t y, arb_t z, const arb_poly_t f, const arb_t x, long prec) + # Sets `y = f(x), z = f'(x)`, evaluated respectively using Horner's rule, + # rectangular splitting, and an automatic algorithm choice. + # When Horner's rule is used, the only advantage of evaluating the + # function and its derivative simultaneously is that one does not have + # to generate the derivative polynomial explicitly. + # With the rectangular splitting algorithm, the powers can be reused, + # making simultaneous evaluation slightly faster. + + void _arb_poly_evaluate2_acb_horner(acb_t y, acb_t z, arb_srcptr f, long len, const acb_t x, long prec) + + void arb_poly_evaluate2_acb_horner(acb_t y, acb_t z, const arb_poly_t f, const acb_t x, long prec) + + void _arb_poly_evaluate2_acb_rectangular(acb_t y, acb_t z, arb_srcptr f, long len, const acb_t x, long prec) + + void arb_poly_evaluate2_acb_rectangular(acb_t y, acb_t z, const arb_poly_t f, const acb_t x, long prec) + + void _arb_poly_evaluate2_acb(acb_t y, acb_t z, arb_srcptr f, long len, const acb_t x, long prec) + + void arb_poly_evaluate2_acb(acb_t y, acb_t z, const arb_poly_t f, const acb_t x, long prec) + # Sets `y = f(x), z = f'(x)`, evaluated respectively using Horner's rule, + # rectangular splitting, and an automatic algorithm choice. + + void _arb_poly_product_roots(arb_ptr poly, arb_srcptr xs, long n, long prec) + + void arb_poly_product_roots(arb_poly_t poly, arb_srcptr xs, long n, long prec) + # Generates the polynomial `(x-x_0)(x-x_1)\cdots(x-x_{n-1})`. + + void _arb_poly_product_roots_complex(arb_ptr poly, arb_srcptr r, long rn, acb_srcptr c, long cn, long prec) + + void arb_poly_product_roots_complex(arb_poly_t poly, arb_srcptr r, long rn, acb_srcptr c, long cn, long prec) + # Generates the polynomial + # .. math :: + # \left(\prod_{i=0}^{rn-1} (x-r_i)\right) \left(\prod_{i=0}^{cn-1} (x-c_i)(x-\bar{c_i})\right) + # having *rn* real roots given by the array *r* and having `2cn` complex roots + # in conjugate pairs given by the length-*cn* array *c*. + # Either *rn* or *cn* or both may be zero. + # Note that only one representative from each complex conjugate pair + # is supplied (unless a pair is supposed to + # be repeated with higher multiplicity). + # To construct a polynomial from complex roots where the conjugate pairs + # have not been distinguished, use :func:`acb_poly_product_roots` instead. + + arb_ptr * _arb_poly_tree_alloc(long len) + # Returns an initialized data structured capable of representing a + # remainder tree (product tree) of *len* roots. + + void _arb_poly_tree_free(arb_ptr * tree, long len) + # Deallocates a tree structure as allocated using *_arb_poly_tree_alloc*. + + void _arb_poly_tree_build(arb_ptr * tree, arb_srcptr roots, long len, long prec) + # Constructs a product tree from a given array of *len* roots. The tree + # structure must be pre-allocated to the specified length using + # :func:`_arb_poly_tree_alloc`. + + void _arb_poly_evaluate_vec_iter(arb_ptr ys, arb_srcptr poly, long plen, arb_srcptr xs, long n, long prec) + + void arb_poly_evaluate_vec_iter(arb_ptr ys, const arb_poly_t poly, arb_srcptr xs, long n, long prec) + # Evaluates the polynomial simultaneously at *n* given points, calling + # :func:`_arb_poly_evaluate` repeatedly. + + void _arb_poly_evaluate_vec_fast_precomp(arb_ptr vs, arb_srcptr poly, long plen, arb_ptr * tree, long len, long prec) + + void _arb_poly_evaluate_vec_fast(arb_ptr ys, arb_srcptr poly, long plen, arb_srcptr xs, long n, long prec) + + void arb_poly_evaluate_vec_fast(arb_ptr ys, const arb_poly_t poly, arb_srcptr xs, long n, long prec) + # Evaluates the polynomial simultaneously at *n* given points, using + # fast multipoint evaluation. + + void _arb_poly_interpolate_newton(arb_ptr poly, arb_srcptr xs, arb_srcptr ys, long n, long prec) + + void arb_poly_interpolate_newton(arb_poly_t poly, arb_srcptr xs, arb_srcptr ys, long n, long prec) + # Recovers the unique polynomial of length at most *n* that interpolates + # the given *x* and *y* values. This implementation first interpolates in the + # Newton basis and then converts back to the monomial basis. + + void _arb_poly_interpolate_barycentric(arb_ptr poly, arb_srcptr xs, arb_srcptr ys, long n, long prec) + + void arb_poly_interpolate_barycentric(arb_poly_t poly, arb_srcptr xs, arb_srcptr ys, long n, long prec) + # Recovers the unique polynomial of length at most *n* that interpolates + # the given *x* and *y* values. This implementation uses the barycentric + # form of Lagrange interpolation. + + void _arb_poly_interpolation_weights(arb_ptr w, arb_ptr * tree, long len, long prec) + + void _arb_poly_interpolate_fast_precomp(arb_ptr poly, arb_srcptr ys, arb_ptr * tree, arb_srcptr weights, long len, long prec) + + void _arb_poly_interpolate_fast(arb_ptr poly, arb_srcptr xs, arb_srcptr ys, long len, long prec) + + void arb_poly_interpolate_fast(arb_poly_t poly, arb_srcptr xs, arb_srcptr ys, long n, long prec) + # Recovers the unique polynomial of length at most *n* that interpolates + # the given *x* and *y* values, using fast Lagrange interpolation. + # The precomp function takes a precomputed product tree over the + # *x* values and a vector of interpolation weights as additional inputs. + + void _arb_poly_derivative(arb_ptr res, arb_srcptr poly, long len, long prec) + # Sets *{res, len - 1}* to the derivative of *{poly, len}*. + # Allows aliasing of the input and output. + + void arb_poly_derivative(arb_poly_t res, const arb_poly_t poly, long prec) + # Sets *res* to the derivative of *poly*. + + void _arb_poly_nth_derivative(arb_ptr res, arb_srcptr poly, unsigned long n, long len, long prec) + # Sets *{res, len - n}* to the nth derivative of *{poly, len}*. Does + # nothing if *len <= n*. Allows aliasing of the input and output. + + void arb_poly_nth_derivative(arb_poly_t res, const arb_poly_t poly, unsigned long n, long prec) + # Sets *res* to the nth derivative of *poly*. + + void _arb_poly_integral(arb_ptr res, arb_srcptr poly, long len, long prec) + # Sets *{res, len}* to the integral of *{poly, len - 1}*. + # Allows aliasing of the input and output. + + void arb_poly_integral(arb_poly_t res, const arb_poly_t poly, long prec) + # Sets *res* to the integral of *poly*. + + void _arb_poly_borel_transform(arb_ptr res, arb_srcptr poly, long len, long prec) + + void arb_poly_borel_transform(arb_poly_t res, const arb_poly_t poly, long prec) + # Computes the Borel transform of the input polynomial, mapping `\sum_k a_k x^k` + # to `\sum_k (a_k / k!) x^k`. The underscore method allows aliasing. + + void _arb_poly_inv_borel_transform(arb_ptr res, arb_srcptr poly, long len, long prec) + + void arb_poly_inv_borel_transform(arb_poly_t res, const arb_poly_t poly, long prec) + # Computes the inverse Borel transform of the input polynomial, mapping `\sum_k a_k x^k` + # to `\sum_k a_k k! x^k`. The underscore method allows aliasing. + + void _arb_poly_binomial_transform_basecase(arb_ptr b, arb_srcptr a, long alen, long len, long prec) + + void arb_poly_binomial_transform_basecase(arb_poly_t b, const arb_poly_t a, long len, long prec) + + void _arb_poly_binomial_transform_convolution(arb_ptr b, arb_srcptr a, long alen, long len, long prec) + + void arb_poly_binomial_transform_convolution(arb_poly_t b, const arb_poly_t a, long len, long prec) + + void _arb_poly_binomial_transform(arb_ptr b, arb_srcptr a, long alen, long len, long prec) + + void arb_poly_binomial_transform(arb_poly_t b, const arb_poly_t a, long len, long prec) + # Computes the binomial transform of the input polynomial, truncating + # the output to length *len*. + # The binomial transform maps the coefficients `a_k` in the input polynomial + # to the coefficients `b_k` in the output polynomial via + # `b_n = \sum_{k=0}^n (-1)^k {n \choose k} a_k`. + # The binomial transform is equivalent to the power series composition + # `f(x) \to (1-x)^{-1} f(x/(x-1))`, and is its own inverse. + # The *basecase* version evaluates coefficients one by one from the + # definition, generating the binomial coefficients by a recurrence + # relation. + # The *convolution* version uses the identity + # `T(f(x)) = B^{-1}(e^x B(f(-x)))` where `T` denotes the binomial + # transform operator and `B` denotes the Borel transform operator. + # This only costs a single polynomial multiplication, plus some + # scalar operations. + # The default version automatically chooses an algorithm. + # The underscore methods do not support aliasing, and assume that + # the lengths are nonzero. + + void _arb_poly_graeffe_transform(arb_ptr b, arb_srcptr a, long len, long prec) + + void arb_poly_graeffe_transform(arb_poly_t b, const arb_poly_t a, long prec) + # Computes the Graeffe transform of input polynomial. + # The Graeffe transform `G` of a polynomial `P` is defined through the + # equation `G(x^2) = \pm P(x)P(-x)`. + # The sign is given by `(-1)^d`, where `d = deg(P)`. + # The Graeffe transform has the property that its roots are exactly the + # squares of the roots of P. + # The underscore method assumes that *a* and *b* are initialized, + # *a* is of length *len*, and *b* is of length at least *len*. + # Both methods allow aliasing. + + void _arb_poly_pow_ui_trunc_binexp(arb_ptr res, arb_srcptr f, long flen, unsigned long exp, long len, long prec) + # Sets *{res, len}* to *{f, flen}* raised to the power *exp*, truncated + # to length *len*. Requires that *len* is no longer than the length + # of the power as computed without truncation (i.e. no zero-padding is performed). + # Does not support aliasing of the input and output, and requires + # that *flen* and *len* are positive. + # Uses binary exponentiation. + + void arb_poly_pow_ui_trunc_binexp(arb_poly_t res, const arb_poly_t poly, unsigned long exp, long len, long prec) + # Sets *res* to *poly* raised to the power *exp*, truncated to length *len*. + # Uses binary exponentiation. + + void _arb_poly_pow_ui(arb_ptr res, arb_srcptr f, long flen, unsigned long exp, long prec) + # Sets *res* to *{f, flen}* raised to the power *exp*. Does not + # support aliasing of the input and output, and requires that + # *flen* is positive. + + void arb_poly_pow_ui(arb_poly_t res, const arb_poly_t poly, unsigned long exp, long prec) + # Sets *res* to *poly* raised to the power *exp*. + + void _arb_poly_pow_series(arb_ptr h, arb_srcptr f, long flen, arb_srcptr g, long glen, long len, long prec) + # Sets *{h, len}* to the power series `f(x)^{g(x)} = \exp(g(x) \log f(x))` truncated + # to length *len*. This function detects special cases such as *g* being an + # exact small integer or `\pm 1/2`, and computes such powers more + # efficiently. This function does not support aliasing of the output + # with either of the input operands. It requires that all lengths + # are positive, and assumes that *flen* and *glen* do not exceed *len*. + + void arb_poly_pow_series(arb_poly_t h, const arb_poly_t f, const arb_poly_t g, long len, long prec) + # Sets *h* to the power series `f(x)^{g(x)} = \exp(g(x) \log f(x))` truncated + # to length *len*. This function detects special cases such as *g* being an + # exact small integer or `\pm 1/2`, and computes such powers more + # efficiently. + + void _arb_poly_pow_arb_series(arb_ptr h, arb_srcptr f, long flen, const arb_t g, long len, long prec) + # Sets *{h, len}* to the power series `f(x)^g = \exp(g \log f(x))` truncated + # to length *len*. This function detects special cases such as *g* being an + # exact small integer or `\pm 1/2`, and computes such powers more + # efficiently. This function does not support aliasing of the output + # with either of the input operands. It requires that all lengths + # are positive, and assumes that *flen* does not exceed *len*. + + void arb_poly_pow_arb_series(arb_poly_t h, const arb_poly_t f, const arb_t g, long len, long prec) + # Sets *h* to the power series `f(x)^g = \exp(g \log f(x))` truncated + # to length *len*. + + void _arb_poly_sqrt_series(arb_ptr g, arb_srcptr h, long hlen, long n, long prec) + + void arb_poly_sqrt_series(arb_poly_t g, const arb_poly_t h, long n, long prec) + # Sets *g* to the power series square root of *h*, truncated to length *n*. + # Uses division-free Newton iteration for the reciprocal square root, + # followed by a multiplication. + # The underscore method does not support aliasing of the input and output + # arrays. It requires that *hlen* and *n* are greater than zero. + + void _arb_poly_rsqrt_series(arb_ptr g, arb_srcptr h, long hlen, long n, long prec) + + void arb_poly_rsqrt_series(arb_poly_t g, const arb_poly_t h, long n, long prec) + # Sets *g* to the reciprocal power series square root of *h*, truncated to length *n*. + # Uses division-free Newton iteration. + # The underscore method does not support aliasing of the input and output + # arrays. It requires that *hlen* and *n* are greater than zero. + + void _arb_poly_log_series(arb_ptr res, arb_srcptr f, long flen, long n, long prec) + + void arb_poly_log_series(arb_poly_t res, const arb_poly_t f, long n, long prec) + # Sets *res* to the power series logarithm of *f*, truncated to length *n*. + # Uses the formula `\log(f(x)) = \int f'(x) / f(x) dx`, adding the logarithm of the + # constant term in *f* as the constant of integration. + # The underscore method supports aliasing of the input and output + # arrays. It requires that *flen* and *n* are greater than zero. + + void _arb_poly_log1p_series(arb_ptr res, arb_srcptr f, long flen, long n, long prec) + + void arb_poly_log1p_series(arb_poly_t res, const arb_poly_t f, long n, long prec) + # Computes the power series `\log(1+f)`, with better accuracy when the constant term of *f* is small. + + void _arb_poly_atan_series(arb_ptr res, arb_srcptr f, long flen, long n, long prec) + + void arb_poly_atan_series(arb_poly_t res, const arb_poly_t f, long n, long prec) + + void _arb_poly_asin_series(arb_ptr res, arb_srcptr f, long flen, long n, long prec) + + void arb_poly_asin_series(arb_poly_t res, const arb_poly_t f, long n, long prec) + + void _arb_poly_acos_series(arb_ptr res, arb_srcptr f, long flen, long n, long prec) + + void arb_poly_acos_series(arb_poly_t res, const arb_poly_t f, long n, long prec) + # Sets *res* respectively to the power series inverse tangent, + # inverse sine and inverse cosine of *f*, truncated to length *n*. + # Uses the formulas + # .. math :: + # \tan^{-1}(f(x)) = \int f'(x) / (1+f(x)^2) dx, + # \sin^{-1}(f(x)) = \int f'(x) / (1-f(x)^2)^{1/2} dx, + # \cos^{-1}(f(x)) = -\int f'(x) / (1-f(x)^2)^{1/2} dx, + # adding the inverse + # function of the constant term in *f* as the constant of integration. + # The underscore methods supports aliasing of the input and output + # arrays. They require that *flen* and *n* are greater than zero. + + void _arb_poly_exp_series_basecase(arb_ptr f, arb_srcptr h, long hlen, long n, long prec) + + void arb_poly_exp_series_basecase(arb_poly_t f, const arb_poly_t h, long n, long prec) + + void _arb_poly_exp_series(arb_ptr f, arb_srcptr h, long hlen, long n, long prec) + + void arb_poly_exp_series(arb_poly_t f, const arb_poly_t h, long n, long prec) + # Sets `f` to the power series exponential of `h`, truncated to length `n`. + # The basecase version uses a simple recurrence for the coefficients, + # requiring `O(nm)` operations where `m` is the length of `h`. + # The main implementation uses Newton iteration, starting from a small + # number of terms given by the basecase algorithm. The complexity + # is `O(M(n))`. Redundant operations in the Newton iteration are + # avoided by using the scheme described in [HZ2004]_. + # The underscore methods support aliasing and allow the input to be + # shorter than the output, but require the lengths to be nonzero. + + void _arb_poly_sin_cos_series(arb_ptr s, arb_ptr c, arb_srcptr h, long hlen, long n, long prec) + void arb_poly_sin_cos_series(arb_poly_t s, arb_poly_t c, const arb_poly_t h, long n, long prec) + # Sets *s* and *c* to the power series sine and cosine of *h*, computed + # simultaneously. + # The underscore method supports aliasing and requires the lengths to be nonzero. + + void _arb_poly_sin_series(arb_ptr s, arb_srcptr h, long hlen, long n, long prec) + + void arb_poly_sin_series(arb_poly_t s, const arb_poly_t h, long n, long prec) + + void _arb_poly_cos_series(arb_ptr c, arb_srcptr h, long hlen, long n, long prec) + + void arb_poly_cos_series(arb_poly_t c, const arb_poly_t h, long n, long prec) + # Respectively evaluates the power series sine or cosine. These functions + # simply wrap :func:`_arb_poly_sin_cos_series`. The underscore methods + # support aliasing and require the lengths to be nonzero. + + void _arb_poly_tan_series(arb_ptr g, arb_srcptr h, long hlen, long len, long prec) + + void arb_poly_tan_series(arb_poly_t g, const arb_poly_t h, long n, long prec) + # Sets *g* to the power series tangent of *h*. + # For small *n* takes the quotient of the sine and cosine as computed + # using the basecase algorithm. For large *n*, uses Newton iteration + # to invert the inverse tangent series. The complexity is `O(M(n))`. + # The underscore version does not support aliasing, and requires + # the lengths to be nonzero. + + void _arb_poly_sin_cos_pi_series(arb_ptr s, arb_ptr c, arb_srcptr h, long hlen, long n, long prec) + + void arb_poly_sin_cos_pi_series(arb_poly_t s, arb_poly_t c, const arb_poly_t h, long n, long prec) + + void _arb_poly_sin_pi_series(arb_ptr s, arb_srcptr h, long hlen, long n, long prec) + + void arb_poly_sin_pi_series(arb_poly_t s, const arb_poly_t h, long n, long prec) + + void _arb_poly_cos_pi_series(arb_ptr c, arb_srcptr h, long hlen, long n, long prec) + + void arb_poly_cos_pi_series(arb_poly_t c, const arb_poly_t h, long n, long prec) + + void _arb_poly_cot_pi_series(arb_ptr c, arb_srcptr h, long hlen, long n, long prec) + + void arb_poly_cot_pi_series(arb_poly_t c, const arb_poly_t h, long n, long prec) + # Compute the respective trigonometric functions of the input + # multiplied by `\pi`. + + void _arb_poly_sinh_cosh_series_basecase(arb_ptr s, arb_ptr c, arb_srcptr h, long hlen, long n, long prec) + + void arb_poly_sinh_cosh_series_basecase(arb_poly_t s, arb_poly_t c, const arb_poly_t h, long n, long prec) + + void _arb_poly_sinh_cosh_series_exponential(arb_ptr s, arb_ptr c, arb_srcptr h, long hlen, long n, long prec) + + void arb_poly_sinh_cosh_series_exponential(arb_poly_t s, arb_poly_t c, const arb_poly_t h, long n, long prec) + + void _arb_poly_sinh_cosh_series(arb_ptr s, arb_ptr c, arb_srcptr h, long hlen, long n, long prec) + + void arb_poly_sinh_cosh_series(arb_poly_t s, arb_poly_t c, const arb_poly_t h, long n, long prec) + + void _arb_poly_sinh_series(arb_ptr s, arb_srcptr h, long hlen, long n, long prec) + + void arb_poly_sinh_series(arb_poly_t s, const arb_poly_t h, long n, long prec) + + void _arb_poly_cosh_series(arb_ptr c, arb_srcptr h, long hlen, long n, long prec) + + void arb_poly_cosh_series(arb_poly_t c, const arb_poly_t h, long n, long prec) + # Sets *s* and *c* respectively to the hyperbolic sine and cosine of the + # power series *h*, truncated to length *n*. + # The implementations mirror those for sine and cosine, except that + # the *exponential* version computes both functions using the exponential + # function instead of the hyperbolic tangent. + + void _arb_poly_sinc_series(arb_ptr s, arb_srcptr h, long hlen, long n, long prec) + + void arb_poly_sinc_series(arb_poly_t s, const arb_poly_t h, long n, long prec) + # Sets *c* to the sinc function of the power series *h*, truncated + # to length *n*. + + void _arb_poly_sinc_pi_series(arb_ptr s, arb_srcptr h, long hlen, long n, long prec) + + void arb_poly_sinc_pi_series(arb_poly_t s, const arb_poly_t h, long n, long prec) + # Compute the sinc function of the input multiplied by `\pi`. + + void _arb_poly_lambertw_series(arb_ptr res, arb_srcptr z, long zlen, int flags, long len, long prec) + + void arb_poly_lambertw_series(arb_poly_t res, const arb_poly_t z, int flags, long len, long prec) + # Sets *res* to the Lambert W function of the power series *z*. + # If *flags* is 0, the principal branch is computed; if *flags* is 1, + # the second real branch `W_{-1}(z)` is computed. + # The underscore method allows aliasing, but assumes that the lengths are nonzero. + + void _arb_poly_gamma_series(arb_ptr res, arb_srcptr h, long hlen, long n, long prec) + + void arb_poly_gamma_series(arb_poly_t res, const arb_poly_t h, long n, long prec) + + void _arb_poly_rgamma_series(arb_ptr res, arb_srcptr h, long hlen, long n, long prec) + + void arb_poly_rgamma_series(arb_poly_t res, const arb_poly_t h, long n, long prec) + + void _arb_poly_lgamma_series(arb_ptr res, arb_srcptr h, long hlen, long n, long prec) + + void arb_poly_lgamma_series(arb_poly_t res, const arb_poly_t h, long n, long prec) + + void _arb_poly_digamma_series(arb_ptr res, arb_srcptr h, long hlen, long n, long prec) + + void arb_poly_digamma_series(arb_poly_t res, const arb_poly_t h, long n, long prec) + # Sets *res* to the series expansion of `\Gamma(h(x))`, `1/\Gamma(h(x))`, + # or `\log \Gamma(h(x))`, `\psi(h(x))`, truncated to length *n*. + # These functions first generate the Taylor series at the constant + # term of *h*, and then call :func:`_arb_poly_compose_series`. + # The Taylor coefficients are generated using the Riemann zeta function + # if the constant term of *h* is a small integer, + # and with Stirling's series otherwise. + # The underscore methods support aliasing of the input and output + # arrays, and require that *hlen* and *n* are greater than zero. + + void _arb_poly_rising_ui_series(arb_ptr res, arb_srcptr f, long flen, unsigned long r, long trunc, long prec) + + void arb_poly_rising_ui_series(arb_poly_t res, const arb_poly_t f, unsigned long r, long trunc, long prec) + # Sets *res* to the rising factorial `(f) (f+1) (f+2) \cdots (f+r-1)`, truncated + # to length *trunc*. The underscore method assumes that *flen*, *r* and *trunc* + # are at least 1, and does not support aliasing. Uses binary splitting. + + void arb_poly_zeta_series(arb_poly_t res, const arb_poly_t s, const arb_t a, int deflate, long n, long prec) + # Sets *res* to the Hurwitz zeta function `\zeta(s,a)` where `s` a power + # series and `a` is a constant, truncated to length *n*. + # To evaluate the usual Riemann zeta function, set `a = 1`. + # If *deflate* is nonzero, evaluates `\zeta(s,a) + 1/(1-s)`, which + # is well-defined as a limit when the constant term of `s` is 1. + # In particular, expanding `\zeta(s,a) + 1/(1-s)` with `s = 1+x` + # gives the Stieltjes constants + # .. math :: + # \sum_{k=0}^{n-1} \frac{(-1)^k}{k!} \gamma_k(a) x^k. + # If `a = 1`, this implementation uses the reflection formula if the midpoint + # of the constant term of `s` is negative. + + void _arb_poly_riemann_siegel_theta_series(arb_ptr res, arb_srcptr h, long hlen, long n, long prec) + + void arb_poly_riemann_siegel_theta_series(arb_poly_t res, const arb_poly_t h, long n, long prec) + # Sets *res* to the series expansion of the Riemann-Siegel theta + # function + # .. math :: + # \theta(h) = \arg \left(\Gamma\left(\frac{2ih+1}{4}\right)\right) - \frac{\log \pi}{2} h + # where the argument of the gamma function is chosen continuously + # as the imaginary part of the log gamma function. + # The underscore method does not support aliasing of the input + # and output arrays, and requires that the lengths are greater + # than zero. + + void _arb_poly_riemann_siegel_z_series(arb_ptr res, arb_srcptr h, long hlen, long n, long prec) + + void arb_poly_riemann_siegel_z_series(arb_poly_t res, const arb_poly_t h, long n, long prec) + # Sets *res* to the series expansion of the Riemann-Siegel Z-function + # .. math :: + # Z(h) = e^{i\theta(h)} \zeta(1/2+ih). + # The zeros of the Z-function on the real line precisely + # correspond to the imaginary parts of the zeros of + # the Riemann zeta function on the critical line. + # The underscore method supports aliasing of the input + # and output arrays, and requires that the lengths are greater + # than zero. + + void _arb_poly_root_bound_fujiwara(mag_t bound, arb_srcptr poly, long len) + + void arb_poly_root_bound_fujiwara(mag_t bound, arb_poly_t poly) + # Sets *bound* to an upper bound for the magnitude of all the complex + # roots of *poly*. Uses Fujiwara's bound + # .. math :: + # 2 \max \left\{\left|\frac{a_{n-1}}{a_n}\right|, + # \left|\frac{a_{n-2}}{a_n}\right|^{1/2}, + # \cdots, + # \left|\frac{a_1}{a_n}\right|^{1/(n-1)}, + # \left|\frac{a_0}{2a_n}\right|^{1/n} + # \right\} + # where `a_0, \ldots, a_n` are the coefficients of *poly*. + + void _arb_poly_newton_convergence_factor(arf_t convergence_factor, arb_srcptr poly, long len, const arb_t convergence_interval, long prec) + # Given an interval `I` specified by *convergence_interval*, evaluates a bound + # for `C = \sup_{t,u \in I} \frac{1}{2} |f''(t)| / |f'(u)|`, + # where `f` is the polynomial defined by the coefficients *{poly, len}*. + # The bound is obtained by evaluating `f'(I)` and `f''(I)` directly. + # If `f` has large coefficients, `I` must be extremely precise in order to + # get a finite factor. + + int _arb_poly_newton_step(arb_t xnew, arb_srcptr poly, long len, const arb_t x, const arb_t convergence_interval, const arf_t convergence_factor, long prec) + # Performs a single step with Newton's method. + # The input consists of the polynomial `f` specified by the coefficients + # *{poly, len}*, an interval `x = [m-r, m+r]` known to contain a single root of `f`, + # an interval `I` (*convergence_interval*) containing `x` with an + # associated bound (*convergence_factor*) for + # `C = \sup_{t,u \in I} \frac{1}{2} |f''(t)| / |f'(u)|`, + # and a working precision *prec*. + # The Newton update consists of setting + # `x' = [m'-r', m'+r']` where `m' = m - f(m) / f'(m)` + # and `r' = C r^2`. The expression `m - f(m) / f'(m)` is evaluated + # using ball arithmetic at a working precision of *prec* bits, and the + # rounding error during this evaluation is accounted for in the output. + # We now check that `x' \in I` and `m' < m`. If both conditions are + # satisfied, we set *xnew* to `x'` and return nonzero. + # If either condition fails, we set *xnew* to `x` and return zero, + # indicating that no progress was made. + + void _arb_poly_newton_refine_root(arb_t r, arb_srcptr poly, long len, const arb_t start, const arb_t convergence_interval, const arf_t convergence_factor, long eval_extra_prec, long prec) + # Refines a precise estimate of a polynomial root to high precision + # by performing several Newton steps, using nearly optimally + # chosen doubling precision steps. + # The inputs are defined as for *_arb_poly_newton_step*, except for + # the precision parameters: *prec* is the target accuracy and + # *eval_extra_prec* is the estimated number of guard bits that need + # to be added to evaluate the polynomial accurately close to the root + # (typically, if the polynomial has large coefficients of alternating + # signs, this needs to be approximately the bit size of the coefficients). + + void _arb_poly_swinnerton_dyer_ui(arb_ptr poly, unsigned long n, long trunc, long prec) + + void arb_poly_swinnerton_dyer_ui(arb_poly_t poly, unsigned long n, long prec) + # Computes the Swinnerton-Dyer polynomial `S_n`, which has degree `2^n` + # and is the rational minimal polynomial of the sum + # of the square roots of the first *n* prime numbers. + # If *prec* is set to zero, a precision is chosen automatically such + # that :func:`arb_poly_get_unique_fmpz_poly` should be successful. + # Otherwise a working precision of *prec* bits is used. + # The underscore version accepts an additional *trunc* parameter. Even + # when computing a truncated polynomial, the array *poly* must have room for + # `2^n + 1` coefficients, used as temporary space. diff --git a/src/sage/libs/flint/arf.pxd b/src/sage/libs/flint/arf.pxd new file mode 100644 index 00000000000..738039a94ef --- /dev/null +++ b/src/sage/libs/flint/arf.pxd @@ -0,0 +1,535 @@ +# distutils: libraries = flint +# distutils: depends = flint/arf.h + +################################################################################ +# This file is auto-generated. Do not modify by hand +################################################################################ + +from libc.stdio cimport FILE +from sage.libs.gmp.types cimport * +from sage.libs.mpfr.types cimport * +from sage.libs.flint.types cimport * + +cdef extern from "flint_wrap.h": + + void arf_init(arf_t x) + # Initializes the variable *x* for use. Its value is set to zero. + + void arf_clear(arf_t x) + # Clears the variable *x*, freeing or recycling its allocated memory. + + long arf_allocated_bytes(const arf_t x) + # Returns the total number of bytes heap-allocated internally by this object. + # The count excludes the size of the structure itself. Add + # ``sizeof(arf_struct)`` to get the size of the object as a whole. + + void arf_zero(arf_t res) + + void arf_one(arf_t res) + + void arf_pos_inf(arf_t res) + + void arf_neg_inf(arf_t res) + + void arf_nan(arf_t res) + # Sets *res* respectively to 0, 1, `+\infty`, `-\infty`, NaN. + + int arf_is_zero(const arf_t x) + + int arf_is_one(const arf_t x) + + int arf_is_pos_inf(const arf_t x) + + int arf_is_neg_inf(const arf_t x) + + int arf_is_nan(const arf_t x) + # Returns nonzero iff *x* respectively equals 0, 1, `+\infty`, `-\infty`, NaN. + + int arf_is_inf(const arf_t x) + # Returns nonzero iff *x* equals either `+\infty` or `-\infty`. + + int arf_is_normal(const arf_t x) + # Returns nonzero iff *x* is a finite, nonzero floating-point value, i.e. + # not one of the special values 0, `+\infty`, `-\infty`, NaN. + + int arf_is_special(const arf_t x) + # Returns nonzero iff *x* is one of the special values + # 0, `+\infty`, `-\infty`, NaN, i.e. not a finite, nonzero + # floating-point value. + + int arf_is_finite(const arf_t x) + # Returns nonzero iff *x* is a finite floating-point value, + # i.e. not one of the values `+\infty`, `-\infty`, NaN. + # (Note that this is not equivalent to the negation of + # :func:`arf_is_inf`.) + + void arf_set(arf_t res, const arf_t x) + + void arf_set_mpz(arf_t res, const mpz_t x) + + void arf_set_fmpz(arf_t res, const fmpz_t x) + + void arf_set_ui(arf_t res, unsigned long x) + + void arf_set_si(arf_t res, long x) + + void arf_set_mpfr(arf_t res, const mpfr_t x) + + void arf_set_d(arf_t res, double x) + # Sets *res* to the exact value of *x*. + + void arf_swap(arf_t x, arf_t y) + # Swaps *x* and *y* efficiently. + + void arf_init_set_ui(arf_t res, unsigned long x) + + void arf_init_set_si(arf_t res, long x) + # Initializes *res* and sets it to *x* in a single operation. + + int arf_set_round(arf_t res, const arf_t x, long prec, arf_rnd_t rnd) + + int arf_set_round_si(arf_t res, long x, long prec, arf_rnd_t rnd) + + int arf_set_round_ui(arf_t res, unsigned long x, long prec, arf_rnd_t rnd) + + int arf_set_round_mpz(arf_t res, const mpz_t x, long prec, arf_rnd_t rnd) + + int arf_set_round_fmpz(arf_t res, const fmpz_t x, long prec, arf_rnd_t rnd) + # Sets *res* to *x*, rounded to *prec* bits in the direction + # specified by *rnd*. + + void arf_set_si_2exp_si(arf_t res, long m, long e) + + void arf_set_ui_2exp_si(arf_t res, unsigned long m, long e) + + void arf_set_fmpz_2exp(arf_t res, const fmpz_t m, const fmpz_t e) + # Sets *res* to `m \cdot 2^e`. + + int arf_set_round_fmpz_2exp(arf_t res, const fmpz_t x, const fmpz_t e, long prec, arf_rnd_t rnd) + # Sets *res* to `x \cdot 2^e`, rounded to *prec* bits in the direction + # specified by *rnd*. + + void arf_get_fmpz_2exp(fmpz_t m, fmpz_t e, const arf_t x) + # Sets *m* and *e* to the unique integers such that + # `x = m \cdot 2^e` and *m* is odd, + # provided that *x* is a nonzero finite fraction. + # If *x* is zero, both *m* and *e* are set to zero. If *x* is + # infinite or NaN, the result is undefined. + + void arf_frexp(arf_t m, fmpz_t e, const arf_t x) + # Writes *x* as `m \cdot 2^e`, where `0.5 \le |m| < 1` if *x* is a normal + # value. If *x* is a special value, copies this to *m* and sets *e* to zero. + # Note: for the inverse operation (*ldexp*), use :func:`arf_mul_2exp_fmpz`. + + double arf_get_d(const arf_t x, arf_rnd_t rnd) + # Returns *x* rounded to a double in the direction specified by *rnd*. + # This method rounds correctly when overflowing or underflowing + # the double exponent range (this was not the case in an earlier version). + + int arf_get_mpfr(mpfr_t res, const arf_t x, mpfr_rnd_t rnd) + # Sets the MPFR variable *res* to the value of *x*. If the precision of *x* + # is too small to allow *res* to be represented exactly, it is rounded in + # the specified MPFR rounding mode. The return value (-1, 0 or 1) + # indicates the direction of rounding, following the convention + # of the MPFR library. + # If *x* has an exponent too large or small to fit in the MPFR type, the + # result overflows to an infinity or underflows to a (signed) zero, + # and the corresponding MPFR exception flags are set. + + int arf_get_fmpz(fmpz_t res, const arf_t x, arf_rnd_t rnd) + # Sets *res* to *x* rounded to the nearest integer in the direction + # specified by *rnd*. If rnd is *ARF_RND_NEAR*, rounds to the nearest + # even integer in case of a tie. Returns inexact (beware: accordingly + # returns whether *x* is *not* an integer). + # This method aborts if *x* is infinite or NaN, or if the exponent of *x* + # is so large that allocating memory for the result fails. + # Warning: this method will allocate a huge amount of memory to store + # the result if the exponent of *x* is huge. Memory allocation could + # succeed even if the required space is far larger than the physical + # memory available on the machine, resulting in swapping. It is recommended + # to check that *x* is within a reasonable range before calling this method. + + long arf_get_si(const arf_t x, arf_rnd_t rnd) + # Returns *x* rounded to the nearest integer in the direction specified by + # *rnd*. If *rnd* is *ARF_RND_NEAR*, rounds to the nearest even integer + # in case of a tie. Aborts if *x* is infinite, NaN, or the value is + # too large to fit in a slong. + + int arf_get_fmpz_fixed_fmpz(fmpz_t res, const arf_t x, const fmpz_t e) + + int arf_get_fmpz_fixed_si(fmpz_t res, const arf_t x, long e) + # Converts *x* to a mantissa with predetermined exponent, i.e. sets *res* to + # an integer *y* such that `y \times 2^e \approx x`, truncating if necessary. + # Returns 0 if exact and 1 if truncation occurred. + # The warnings for :func:`arf_get_fmpz` apply. + + void arf_floor(arf_t res, const arf_t x) + + void arf_ceil(arf_t res, const arf_t x) + # Sets *res* to `\lfloor x \rfloor` and `\lceil x \rceil` respectively. + # The result is always represented exactly, requiring no more bits to + # store than the input. To round the result to a floating-point number + # with a lower precision, call :func:`arf_set_round` afterwards. + + void arf_get_fmpq(fmpq_t res, const arf_t x) + # Set *res* to the exact rational value of *x*. + # This method aborts if *x* is infinite or NaN, or if the exponent of *x* + # is so large that allocating memory for the result fails. + + int arf_equal(const arf_t x, const arf_t y) + int arf_equal_si(const arf_t x, long y) + int arf_equal_ui(const arf_t x, unsigned long y) + int arf_equal_d(const arf_t x, double y) + # Returns nonzero iff *x* and *y* are exactly equal. NaN is not + # treated specially, i.e. NaN compares as equal to itself. + # For comparison with a *double*, the values -0 and +0 are + # both treated as zero, and all NaN values are treated as identical. + + int arf_cmp(const arf_t x, const arf_t y) + + int arf_cmp_si(const arf_t x, long y) + + int arf_cmp_ui(const arf_t x, unsigned long y) + + int arf_cmp_d(const arf_t x, double y) + # Returns negative, zero, or positive, depending on whether *x* is + # respectively smaller, equal, or greater compared to *y*. + # Comparison with NaN is undefined. + + int arf_cmpabs(const arf_t x, const arf_t y) + + int arf_cmpabs_ui(const arf_t x, unsigned long y) + + int arf_cmpabs_d(const arf_t x, double y) + + int arf_cmpabs_mag(const arf_t x, const mag_t y) + # Compares the absolute values of *x* and *y*. + + int arf_cmp_2exp_si(const arf_t x, long e) + + int arf_cmpabs_2exp_si(const arf_t x, long e) + # Compares *x* (respectively its absolute value) with `2^e`. + + int arf_sgn(const arf_t x) + # Returns `-1`, `0` or `+1` according to the sign of *x*. The sign + # of NaN is undefined. + + void arf_min(arf_t res, const arf_t a, const arf_t b) + + void arf_max(arf_t res, const arf_t a, const arf_t b) + # Sets *res* respectively to the minimum and the maximum of *a* and *b*. + + long arf_bits(const arf_t x) + # Returns the number of bits needed to represent the absolute value + # of the mantissa of *x*, i.e. the minimum precision sufficient to represent + # *x* exactly. Returns 0 if *x* is a special value. + + int arf_is_int(const arf_t x) + # Returns nonzero iff *x* is integer-valued. + + int arf_is_int_2exp_si(const arf_t x, long e) + # Returns nonzero iff *x* equals `n 2^e` for some integer *n*. + + void arf_abs_bound_lt_2exp_fmpz(fmpz_t res, const arf_t x) + # Sets *res* to the smallest integer *b* such that `|x| < 2^b`. + # If *x* is zero, infinity or NaN, the result is undefined. + + void arf_abs_bound_le_2exp_fmpz(fmpz_t res, const arf_t x) + # Sets *res* to the smallest integer *b* such that `|x| \le 2^b`. + # If *x* is zero, infinity or NaN, the result is undefined. + + long arf_abs_bound_lt_2exp_si(const arf_t x) + # Returns the smallest integer *b* such that `|x| < 2^b`, clamping + # the result to lie between -*ARF_PREC_EXACT* and *ARF_PREC_EXACT* + # inclusive. If *x* is zero, -*ARF_PREC_EXACT* is returned, + # and if *x* is infinity or NaN, *ARF_PREC_EXACT* is returned. + + void arf_get_mag(mag_t res, const arf_t x) + # Sets *res* to an upper bound for the absolute value of *x*. + + void arf_get_mag_lower(mag_t res, const arf_t x) + # Sets *res* to a lower bound for the absolute value of *x*. + + void arf_set_mag(arf_t res, const mag_t x) + # Sets *res* to *x*. This operation is exact. + + void mag_init_set_arf(mag_t res, const arf_t x) + # Initializes *res* and sets it to an upper bound for *x*. + + void mag_fast_init_set_arf(mag_t res, const arf_t x) + # Initializes *res* and sets it to an upper bound for *x*. + # Assumes that the exponent of *res* is small (this function is unsafe). + + void arf_mag_set_ulp(mag_t res, const arf_t x, long prec) + # Sets *res* to the magnitude of the unit in the last place (ulp) of *x* + # at precision *prec*. + + void arf_mag_add_ulp(mag_t res, const mag_t x, const arf_t y, long prec) + # Sets *res* to an upper bound for the sum of *x* and the + # magnitude of the unit in the last place (ulp) of *y* + # at precision *prec*. + + void arf_mag_fast_add_ulp(mag_t res, const mag_t x, const arf_t y, long prec) + # Sets *res* to an upper bound for the sum of *x* and the + # magnitude of the unit in the last place (ulp) of *y* + # at precision *prec*. Assumes that all exponents are small. + + void arf_init_set_shallow(arf_t z, const arf_t x) + + void arf_init_set_mag_shallow(arf_t z, const mag_t x) + # Initializes *z* to a shallow copy of *x*. A shallow copy just involves + # copying struct data (no heap allocation is performed). + # The target variable *z* may not be cleared or modified in any way (it can + # only be used as constant input to functions), and may not be used after + # *x* has been cleared. Moreover, after *x* has been assigned shallowly + # to *z*, no modification of *x* is permitted as slong as *z* is in use. + + void arf_init_neg_shallow(arf_t z, const arf_t x) + + void arf_init_neg_mag_shallow(arf_t z, const mag_t x) + # Initializes *z* shallowly to the negation of *x*. + + void arf_randtest(arf_t res, flint_rand_t state, long bits, long mag_bits) + # Generates a finite random number whose mantissa has precision at most + # *bits* and whose exponent has at most *mag_bits* bits. The + # values are distributed non-uniformly: special bit patterns are generated + # with high probability in order to allow the test code to exercise corner + # cases. + + void arf_randtest_not_zero(arf_t res, flint_rand_t state, long bits, long mag_bits) + # Identical to :func:`arf_randtest`, except that zero is never produced + # as an output. + + void arf_randtest_special(arf_t res, flint_rand_t state, long bits, long mag_bits) + # Identical to :func:`arf_randtest`, except that the output occasionally + # is set to an infinity or NaN. + + void arf_urandom(arf_t res, flint_rand_t state, long bits, arf_rnd_t rnd) + # Sets *res* to a uniformly distributed random number in the interval + # `[0, 1]`. The method uses rounding from integers to floats based on the + # rounding mode *rnd*. + + void arf_debug(const arf_t x) + # Prints information about the internal representation of *x*. + + void arf_print(const arf_t x) + # Prints *x* as an integer mantissa and exponent. + + void arf_printd(const arf_t x, long d) + # Prints *x* as a decimal floating-point number, rounding to *d* digits. + # Rounding is faithful (at most 1 ulp error). + + char * arf_get_str(const arf_t x, long d) + # Returns *x* as a decimal floating-point number, rounding to *d* digits. + # Rounding is faithful (at most 1 ulp error). + + void arf_fprint(FILE * file, const arf_t x) + # Prints *x* as an integer mantissa and exponent to the stream *file*. + + void arf_fprintd(FILE * file, const arf_t y, long d) + # Prints *x* as a decimal floating-point number to the stream *file*, + # rounding to *d* digits. + # Rounding is faithful (at most 1 ulp error). + + char * arf_dump_str(const arf_t x) + # Allocates a string and writes a binary representation of *x* to it that can + # be read by :func:`arf_load_str`. The returned string needs to be + # deallocated with *flint_free*. + + int arf_load_str(arf_t x, const char * str) + # Parses *str* into *x*. Returns a nonzero value if *str* is not formatted + # correctly. + + int arf_dump_file(FILE * stream, const arf_t x) + # Writes a binary representation of *x* to *stream* that can be read by + # :func:`arf_load_file`. Returns a nonzero value if the data could not be + # written. + + int arf_load_file(arf_t x, FILE * stream) + # Reads *x* from *stream*. Returns a nonzero value if the data is not + # formatted correctly or the read failed. Note that the data is assumed to be + # delimited by a whitespace or end-of-file, i.e., when writing multiple + # values with :func:`arf_dump_file` make sure to insert a whitespace to + # separate consecutive values. + + void arf_abs(arf_t res, const arf_t x) + # Sets *res* to the absolute value of *x* exactly. + + void arf_neg(arf_t res, const arf_t x) + # Sets *res* to `-x` exactly. + + int arf_neg_round(arf_t res, const arf_t x, long prec, arf_rnd_t rnd) + # Sets *res* to `-x`. + + int arf_add(arf_t res, const arf_t x, const arf_t y, long prec, arf_rnd_t rnd) + + int arf_add_si(arf_t res, const arf_t x, long y, long prec, arf_rnd_t rnd) + + int arf_add_ui(arf_t res, const arf_t x, unsigned long y, long prec, arf_rnd_t rnd) + + int arf_add_fmpz(arf_t res, const arf_t x, const fmpz_t y, long prec, arf_rnd_t rnd) + # Sets *res* to `x + y`. + + int arf_add_fmpz_2exp(arf_t res, const arf_t x, const fmpz_t y, const fmpz_t e, long prec, arf_rnd_t rnd) + # Sets *res* to `x + y 2^e`. + + int arf_sub(arf_t res, const arf_t x, const arf_t y, long prec, arf_rnd_t rnd) + + int arf_sub_si(arf_t res, const arf_t x, long y, long prec, arf_rnd_t rnd) + + int arf_sub_ui(arf_t res, const arf_t x, unsigned long y, long prec, arf_rnd_t rnd) + + int arf_sub_fmpz(arf_t res, const arf_t x, const fmpz_t y, long prec, arf_rnd_t rnd) + # Sets *res* to `x - y`. + + void arf_mul_2exp_si(arf_t res, const arf_t x, long e) + + void arf_mul_2exp_fmpz(arf_t res, const arf_t x, const fmpz_t e) + # Sets *res* to `x 2^e` exactly. + + int arf_mul(arf_t res, const arf_t x, const arf_t y, long prec, arf_rnd_t rnd) + + int arf_mul_ui(arf_t res, const arf_t x, unsigned long y, long prec, arf_rnd_t rnd) + + int arf_mul_si(arf_t res, const arf_t x, long y, long prec, arf_rnd_t rnd) + + int arf_mul_mpz(arf_t res, const arf_t x, const mpz_t y, long prec, arf_rnd_t rnd) + + int arf_mul_fmpz(arf_t res, const arf_t x, const fmpz_t y, long prec, arf_rnd_t rnd) + # Sets *res* to `x \cdot y`. + + int arf_addmul(arf_t z, const arf_t x, const arf_t y, long prec, arf_rnd_t rnd) + + int arf_addmul_ui(arf_t z, const arf_t x, unsigned long y, long prec, arf_rnd_t rnd) + + int arf_addmul_si(arf_t z, const arf_t x, long y, long prec, arf_rnd_t rnd) + + int arf_addmul_mpz(arf_t z, const arf_t x, const mpz_t y, long prec, arf_rnd_t rnd) + + int arf_addmul_fmpz(arf_t z, const arf_t x, const fmpz_t y, long prec, arf_rnd_t rnd) + # Performs a fused multiply-add `z = z + x \cdot y`, updating *z* in-place. + + int arf_submul(arf_t z, const arf_t x, const arf_t y, long prec, arf_rnd_t rnd) + + int arf_submul_ui(arf_t z, const arf_t x, unsigned long y, long prec, arf_rnd_t rnd) + + int arf_submul_si(arf_t z, const arf_t x, long y, long prec, arf_rnd_t rnd) + + int arf_submul_mpz(arf_t z, const arf_t x, const mpz_t y, long prec, arf_rnd_t rnd) + + int arf_submul_fmpz(arf_t z, const arf_t x, const fmpz_t y, long prec, arf_rnd_t rnd) + # Performs a fused multiply-subtract `z = z - x \cdot y`, updating *z* in-place. + + int arf_fma(arf_t res, const arf_t x, const arf_t y, const arf_t z, long prec, arf_rnd_t rnd) + # Sets *res* to `x \cdot y + z`. This is equivalent to an *addmul* except + # that *res* and *z* can be separate variables. + + int arf_sosq(arf_t res, const arf_t x, const arf_t y, long prec, arf_rnd_t rnd) + # Sets *res* to `x^2 + y^2`, rounded to *prec* bits in the direction specified by *rnd*. + + int arf_sum(arf_t res, arf_srcptr terms, long len, long prec, arf_rnd_t rnd) + # Sets *res* to the sum of the array *terms* of length *len*, rounded to + # *prec* bits in the direction specified by *rnd*. The sum is computed as if + # done without any intermediate rounding error, with only a single rounding + # applied to the final result. Unlike repeated calls to :func:`arf_add` with + # infinite precision, this function does not overflow if the magnitudes of + # the terms are far apart. Warning: this function is implemented naively, + # and the running time is quadratic with respect to *len* in the worst case. + + void arf_approx_dot(arf_t res, const arf_t initial, int subtract, arf_srcptr x, long xstep, arf_srcptr y, long ystep, long len, long prec, arf_rnd_t rnd) + # Computes an approximate dot product, with the same meaning of + # the parameters as :func:`arb_dot`. + # This operation is not correctly rounded: the final rounding is done + # in the direction ``rnd`` but intermediate roundings are + # implementation-defined. + + int arf_div(arf_t res, const arf_t x, const arf_t y, long prec, arf_rnd_t rnd) + + int arf_div_ui(arf_t res, const arf_t x, unsigned long y, long prec, arf_rnd_t rnd) + + int arf_ui_div(arf_t res, unsigned long x, const arf_t y, long prec, arf_rnd_t rnd) + + int arf_div_si(arf_t res, const arf_t x, long y, long prec, arf_rnd_t rnd) + + int arf_si_div(arf_t res, long x, const arf_t y, long prec, arf_rnd_t rnd) + + int arf_div_fmpz(arf_t res, const arf_t x, const fmpz_t y, long prec, arf_rnd_t rnd) + + int arf_fmpz_div(arf_t res, const fmpz_t x, const arf_t y, long prec, arf_rnd_t rnd) + + int arf_fmpz_div_fmpz(arf_t res, const fmpz_t x, const fmpz_t y, long prec, arf_rnd_t rnd) + # Sets *res* to `x / y`, rounded to *prec* bits in the direction specified by *rnd*, + # returning nonzero iff the operation is inexact. The result is NaN if *y* is zero. + + int arf_sqrt(arf_t res, const arf_t x, long prec, arf_rnd_t rnd) + + int arf_sqrt_ui(arf_t res, unsigned long x, long prec, arf_rnd_t rnd) + + int arf_sqrt_fmpz(arf_t res, const fmpz_t x, long prec, arf_rnd_t rnd) + # Sets *res* to `\sqrt{x}`. The result is NaN if *x* is negative. + + int arf_rsqrt(arf_t res, const arf_t x, long prec, arf_rnd_t rnd) + # Sets *res* to `1/\sqrt{x}`. The result is NaN if *x* is + # negative, and `+\infty` if *x* is zero. + + int arf_root(arf_t res, const arf_t x, unsigned long k, long prec, arf_rnd_t rnd) + # Sets *res* to `x^{1/k}`. The result is NaN if *x* is negative. + # Warning: this function is a wrapper around the MPFR root function. + # It gets slow and uses much memory for large *k*. + # Consider working with :func:`arb_root_ui` for large *k* instead of using this + # function directly. + + 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, long 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, long prec, arf_rnd_t rnd) + # Computes the complex product `e + fi = (a + bi)(c + di)`, rounding both + # `e` and `f` correctly to *prec* bits in the direction specified by *rnd*. + # The first bit in the return code indicates inexactness of `e`, and the + # second bit indicates inexactness of `f`. + # If any of the components *a*, *b*, *c*, *d* is zero, two real + # multiplications and no additions are done. This convention is used even + # if any other part contains an infinity or NaN, and the behavior + # with infinite/NaN input is defined accordingly. + # The *fallback* version is implemented naively, for testing purposes. + # No squaring optimization is implemented. + + int arf_complex_sqr(arf_t e, arf_t f, const arf_t a, const arf_t b, long prec, arf_rnd_t rnd) + # Computes the complex square `e + fi = (a + bi)^2`. This function has + # identical semantics to :func:`arf_complex_mul` (with `c = a, b = d`), + # but is faster. + + int _arf_get_integer_mpn(mp_ptr y, mp_srcptr xp, mp_size_t xn, long exp) + # Given a floating-point number *x* represented by *xn* limbs at *xp* + # and an exponent *exp*, writes the integer part of *x* to + # *y*, returning whether the result is inexact. + # The correct number of limbs is written (no limbs are written + # if the integer part of *x* is zero). + # Assumes that ``xp[0]`` is nonzero and that the + # top bit of ``xp[xn-1]`` is set. + + int _arf_set_mpn_fixed(arf_t z, mp_srcptr xp, mp_size_t xn, mp_size_t fixn, int negative, long prec, arf_rnd_t rnd) + # Sets *z* to the fixed-point number having *xn* total limbs and *fixn* + # fractional limbs, negated if *negative* is set, rounding *z* to *prec* + # bits in the direction *rnd* and returning whether the result is inexact. + # Both *xn* and *fixn* must be nonnegative and not so large + # that the bit shift would overflow an *slong*, but otherwise no + # assumptions are made about the input. + + int _arf_set_round_ui(arf_t z, unsigned long x, int sgnbit, long prec, arf_rnd_t rnd) + # Sets *z* to the integer *x*, negated if *sgnbit* is 1, rounded to *prec* + # bits in the direction specified by *rnd*. There are no assumptions on *x*. + + int _arf_set_round_uiui(arf_t z, long * fix, mp_limb_t hi, mp_limb_t lo, int sgnbit, long prec, arf_rnd_t rnd) + # Sets the mantissa of *z* to the two-limb mantissa given by *hi* and *lo*, + # negated if *sgnbit* is 1, rounded to *prec* bits in the direction specified + # by *rnd*. Requires that not both *hi* and *lo* are zero. + # Writes the exponent shift to *fix* without writing the exponent of *z* + # directly. + + int _arf_set_round_mpn(arf_t z, long * exp_shift, mp_srcptr x, mp_size_t xn, int sgnbit, long prec, arf_rnd_t rnd) + # Sets the mantissa of *z* to the mantissa given by the *xn* limbs in *x*, + # negated if *sgnbit* is 1, rounded to *prec* bits in the direction + # specified by *rnd*. Returns the inexact flag. Requires that *xn* is positive + # and that the top limb of *x* is nonzero. If *x* has leading zero bits, + # writes the shift to *exp_shift*. This method does not write the exponent of + # *z* directly. Requires that *x* does not point to the limbs of *z*. diff --git a/src/sage/libs/flint/bernoulli.pxd b/src/sage/libs/flint/bernoulli.pxd new file mode 100644 index 00000000000..922fe433d26 --- /dev/null +++ b/src/sage/libs/flint/bernoulli.pxd @@ -0,0 +1,81 @@ +# distutils: libraries = flint +# distutils: depends = flint/bernoulli.h + +################################################################################ +# This file is auto-generated. Do not modify by hand +################################################################################ + +from libc.stdio cimport FILE +from sage.libs.gmp.types cimport * +from sage.libs.mpfr.types cimport * +from sage.libs.flint.types cimport * + +cdef extern from "flint_wrap.h": + + void bernoulli_rev_init(bernoulli_rev_t iter, unsigned long n) + # Initializes the iterator *iter*. The first Bernoulli number to + # be generated by calling :func:`bernoulli_rev_next` is `B_n`. + # It is assumed that `n` is even. + + void bernoulli_rev_next(fmpz_t numer, fmpz_t denom, bernoulli_rev_t iter) + # Sets *numer* and *denom* to the exact, reduced numerator and denominator + # of the Bernoulli number `B_k` and advances the state of *iter* + # so that the next invocation generates `B_{k-2}`. + + void bernoulli_rev_clear(bernoulli_rev_t iter) + # Frees all memory allocated internally by *iter*. + + void bernoulli_fmpq_vec_no_cache(fmpq * res, unsigned long a, long num) + # Writes *num* consecutive Bernoulli numbers to *res* starting + # with `B_a`. This function is not currently optimized for a small + # count *num*. The entries are not read from or written + # to the Bernoulli number cache; if retrieving a vector of + # Bernoulli numbers is needed more than once, + # use :func:`bernoulli_cache_compute` + # followed by :func:`bernoulli_fmpq_ui` instead. + # This function is a wrapper for the *rev* iterators. It can use + # multiple threads internally. + + void bernoulli_cache_compute(long n) + # Makes sure that the Bernoulli numbers up to at least `B_{n-1}` are cached. + # Calling :func:`flint_cleanup()` frees the cache. + # The cache is extended by calling :func:`bernoulli_fmpq_vec_no_cache` + # internally. + + long bernoulli_bound_2exp_si(unsigned long n) + # Returns an integer `b` such that `|B_n| \le 2^b`. Uses a lookup table + # for small `n`, and for larger `n` uses the inequality + # `|B_n| < 4 n! / (2 \pi)^n < 4 (n+1)^{n+1} e^{-n} / (2 \pi)^n`. + # Uses integer arithmetic throughout, with the bound for the logarithm + # being looked up from a table. If `|B_n| = 0`, returns *LONG_MIN*. + # Otherwise, the returned exponent `b` is never more than one percent + # larger than the true magnitude. + # This function is intended for use when `n` small enough that one might + # comfortably compute `B_n` exactly. It aborts if `n` is so large that + # internal overflow occurs. + + unsigned long bernoulli_mod_p_harvey(unsigned long n, unsigned long p) + # Returns the `B_n` modulo the prime number *p*, computed using + # Harvey's algorithm [Har2010]_. The running time is linear in *p*. + # If *p* divides the numerator of `B_n`, *UWORD_MAX* is returned + # as an error code. + + void _bernoulli_fmpq_ui_zeta(fmpz_t num, fmpz_t den, unsigned long n) + void _bernoulli_fmpq_ui_multi_mod(fmpz_t num, fmpz_t den, unsigned long n, double alpha) + # Sets *num* and *den* to the reduced numerator and denominator + # of the Bernoulli number `B_n`. + # The *zeta* version computes the denominator `d` using the von Staudt-Clausen + # theorem, numerically approximates `B_n` using :func:`arb_bernoulli_ui_zeta`, + # and then rounds `d B_n` to the correct numerator. + # The *multi_mod* version reconstructs `B_n` by computing the high bits + # via the Riemann zeta function and the low bits via Harvey's multimodular + # algorithm. The tuning parameter *alpha* should be a fraction between + # 0 and 1 controlling the number of bits to compute by the multimodular + # algorithm. If set to a negative number, a default value will be used. + + void _bernoulli_fmpq_ui(fmpz_t num, fmpz_t den, unsigned long n) + void bernoulli_fmpq_ui(fmpq_t b, unsigned long n) + # Computes the Bernoulli number `B_n` as an exact fraction, for an + # isolated integer `n`. This function reads `B_n` from the global cache + # if the number is already cached, but does not automatically extend + # the cache by itself. diff --git a/src/sage/libs/flint/bool_mat.pxd b/src/sage/libs/flint/bool_mat.pxd new file mode 100644 index 00000000000..e92d2b1fe3a --- /dev/null +++ b/src/sage/libs/flint/bool_mat.pxd @@ -0,0 +1,162 @@ +# distutils: libraries = flint +# distutils: depends = flint/bool_mat.h + +################################################################################ +# This file is auto-generated. Do not modify by hand +################################################################################ + +from libc.stdio cimport FILE +from sage.libs.gmp.types cimport * +from sage.libs.mpfr.types cimport * +from sage.libs.flint.types cimport * + +cdef extern from "flint_wrap.h": + + int bool_mat_get_entry(const bool_mat_t mat, long i, long j) + # Returns the entry of matrix *mat* at row *i* and column *j*. + + void bool_mat_set_entry(bool_mat_t mat, long i, long j, int x) + # Sets the entry of matrix *mat* at row *i* and column *j* to *x*. + + void bool_mat_init(bool_mat_t mat, long r, long c) + # Initializes the matrix, setting it to the zero matrix with *r* rows + # and *c* columns. + + void bool_mat_clear(bool_mat_t mat) + # Clears the matrix, deallocating all entries. + + int bool_mat_is_empty(const bool_mat_t mat) + # Returns nonzero iff the number of rows or the number of columns in *mat* + # is zero. Note that this does not depend on the entry values of *mat*. + + int bool_mat_is_square(const bool_mat_t mat) + # Returns nonzero iff the number of rows is equal to the number of columns in *mat*. + + void bool_mat_set(bool_mat_t dest, const bool_mat_t src) + # Sets *dest* to *src*. The operands must have identical dimensions. + + void bool_mat_print(const bool_mat_t mat) + # Prints each entry in the matrix. + + void bool_mat_fprint(FILE * file, const bool_mat_t mat) + # Prints each entry in the matrix to the stream *file*. + + int bool_mat_equal(const bool_mat_t mat1, const bool_mat_t mat2) + # Returns nonzero iff the matrices have the same dimensions + # and identical entries. + + int bool_mat_any(const bool_mat_t mat) + # Returns nonzero iff *mat* has a nonzero entry. + + int bool_mat_all(const bool_mat_t mat) + # Returns nonzero iff all entries of *mat* are nonzero. + + int bool_mat_is_diagonal(const bool_mat_t A) + # Returns nonzero iff `i \ne j \implies \bar{A_{ij}}`. + + int bool_mat_is_lower_triangular(const bool_mat_t A) + # Returns nonzero iff `i < j \implies \bar{A_{ij}}`. + + int bool_mat_is_transitive(const bool_mat_t mat) + # Returns nonzero iff `A_{ij} \wedge A_{jk} \implies A_{ik}`. + + int bool_mat_is_nilpotent(const bool_mat_t A) + # Returns nonzero iff some positive matrix power of `A` is zero. + + void bool_mat_randtest(bool_mat_t mat, flint_rand_t state) + # Sets *mat* to a random matrix. + + void bool_mat_randtest_diagonal(bool_mat_t mat, flint_rand_t state) + # Sets *mat* to a random diagonal matrix. + + void bool_mat_randtest_nilpotent(bool_mat_t mat, flint_rand_t state) + # Sets *mat* to a random nilpotent matrix. + + void bool_mat_zero(bool_mat_t mat) + # Sets all entries in mat to zero. + + void bool_mat_one(bool_mat_t mat) + # Sets the entries on the main diagonal to ones, + # and all other entries to zero. + + void bool_mat_directed_path(bool_mat_t A) + # Sets `A_{ij}` to `j = i + 1`. + # Requires that `A` is a square matrix. + + void bool_mat_directed_cycle(bool_mat_t A) + # Sets `A_{ij}` to `j = (i + 1) \mod n` + # where `n` is the order of the square matrix `A`. + + void bool_mat_transpose(bool_mat_t dest, const bool_mat_t src) + # Sets *dest* to the transpose of *src*. The operands must have + # compatible dimensions. Aliasing is allowed. + + void bool_mat_complement(bool_mat_t B, const bool_mat_t A) + # Sets *B* to the logical complement of *A*. + # That is `B_{ij}` is set to `\bar{A_{ij}}`. + # The operands must have the same dimensions. + + void bool_mat_add(bool_mat_t res, const bool_mat_t mat1, const bool_mat_t mat2) + # Sets *res* to the sum of *mat1* and *mat2*. + # The operands must have the same dimensions. + + void bool_mat_mul(bool_mat_t res, const bool_mat_t mat1, const bool_mat_t mat2) + # Sets *res* to the matrix product of *mat1* and *mat2*. + # The operands must have compatible dimensions for matrix multiplication. + + void bool_mat_mul_entrywise(bool_mat_t res, const bool_mat_t mat1, const bool_mat_t mat2) + # Sets *res* to the entrywise product of *mat1* and *mat2*. + # The operands must have the same dimensions. + + void bool_mat_sqr(bool_mat_t B, const bool_mat_t A) + + void bool_mat_pow_ui(bool_mat_t B, const bool_mat_t A, unsigned long exp) + # Sets *B* to *A* raised to the power *exp*. + # Requires that *A* is a square matrix. + + int bool_mat_trace(const bool_mat_t mat) + # Returns the trace of the matrix, i.e. the sum of entries on the + # main diagonal of *mat*. The matrix is required to be square. + # The sum is in the boolean semiring, so this function returns nonzero iff + # any entry on the diagonal of *mat* is nonzero. + + long bool_mat_nilpotency_degree(const bool_mat_t A) + # Returns the nilpotency degree of the `n \times n` matrix *A*. + # It returns the smallest positive `k` such that `A^k = 0`. + # If no such `k` exists then the function returns `-1` if `n` is positive, + # and otherwise it returns `0`. + + void bool_mat_transitive_closure(bool_mat_t B, const bool_mat_t A) + # Sets *B* to the transitive closure `\sum_{k=1}^\infty A^k`. + # The matrix *A* is required to be square. + + long bool_mat_get_strongly_connected_components(long * p, const bool_mat_t A) + # Partitions the `n` row and column indices of the `n \times n` matrix *A* + # according to the strongly connected components (SCC) of the graph + # for which *A* is the adjacency matrix. + # If the graph has `k` SCCs then the function returns `k`, + # and for each vertex `i \in [0, n-1]`, + # `p_i` is set to the index of the SCC to which the vertex belongs. + # The SCCs themselves can be considered as nodes in a directed acyclic + # graph (DAG), and the SCCs are indexed in postorder with respect to that DAG. + + long bool_mat_all_pairs_longest_walk(fmpz_mat_t B, const bool_mat_t A) + # Sets `B_{ij}` to the length of the longest walk with endpoint vertices + # `i` and `j` in the graph whose adjacency matrix is *A*. + # The matrix *A* must be square. Empty walks with zero length + # which begin and end at the same vertex are allowed. If `j` is not + # reachable from `i` then no walk from `i` to `j` exists and `B_{ij}` + # is set to the special value `-1`. + # If arbitrarily long walks from `i` to `j` exist then `B_{ij}` + # is set to the special value `-2`. + # The function returns `-2` if any entry of `B_{ij}` is `-2`, + # and otherwise it returns the maximum entry in `B`, except if `A` is empty + # in which case `-1` is returned. + # Note that the returned value is one less than + # that of :func:`nilpotency_degree`. + # This function can help quantify entrywise errors in a truncated evaluation + # of a matrix power series. If *A* is an indicator matrix with the same + # sparsity pattern as a matrix `M` over the real or complex numbers, + # and if `B_{ij}` does not take the special value `-2`, then the tail + # `\left[ \sum_{k=N}^\infty a_k M^k \right]_{ij}` + # vanishes when `N > B_{ij}`. diff --git a/src/sage/libs/flint/ca.pxd b/src/sage/libs/flint/ca.pxd new file mode 100644 index 00000000000..b01ad1a85c3 --- /dev/null +++ b/src/sage/libs/flint/ca.pxd @@ -0,0 +1,812 @@ +# distutils: libraries = flint +# distutils: depends = flint/ca.h + +################################################################################ +# This file is auto-generated. Do not modify by hand +################################################################################ + +from libc.stdio cimport FILE +from sage.libs.gmp.types cimport * +from sage.libs.mpfr.types cimport * +from sage.libs.flint.types cimport * + +cdef extern from "flint_wrap.h": + + void ca_ctx_init(ca_ctx_t ctx) + # Initializes the context object *ctx* for use. + # Any evaluation options stored in the context object + # are set to default values. + + void ca_ctx_clear(ca_ctx_t ctx) + # Clears the context object *ctx*, freeing any memory allocated internally. + # This function should only be called after all :type:`ca_t` instances + # referring to this context have been cleared. + + void ca_ctx_print(ca_ctx_t ctx) + # Prints a description of the context *ctx* to standard output. + # This will give a complete listing of the cached fields in *ctx*. + + void ca_init(ca_t x, ca_ctx_t ctx) + # Initializes the variable *x* for use, associating it with the + # context object *ctx*. The value of *x* is set to the rational number 0. + + void ca_clear(ca_t x, ca_ctx_t ctx) + # Clears the variable *x*. + + void ca_swap(ca_t x, ca_t y, ca_ctx_t ctx) + # Efficiently swaps the variables *x* and *y*. + + void ca_get_fexpr(fexpr_t res, const ca_t x, unsigned long flags, ca_ctx_t ctx) + # Sets *res* to a symbolic expression representing *x*. + + int ca_set_fexpr(ca_t res, const fexpr_t expr, ca_ctx_t ctx) + # Sets *res* to the value represented by the symbolic expression *expr*. + # Returns 1 on success and 0 on failure. + # This function essentially just traverses the expression tree using + # ``ca`` arithmetic; it does not provide advanced symbolic evaluation. + # It is guaranteed to at least be able to parse the output of + # :func:`ca_get_fexpr`. + + void ca_print(const ca_t x, ca_ctx_t ctx) + # Prints *x* to standard output. + + void ca_fprint(FILE * fp, const ca_t x, ca_ctx_t ctx) + # Prints *x* to the file *fp*. + + char * ca_get_str(const ca_t x, ca_ctx_t ctx) + # Prints *x* to a string which is returned. + # The user should free this string by calling ``flint_free``. + + void ca_printn(const ca_t x, long n, ca_ctx_t ctx) + # Prints an *n*-digit numerical representation of *x* to standard output. + + void ca_zero(ca_t res, ca_ctx_t ctx) + void ca_one(ca_t res, ca_ctx_t ctx) + void ca_neg_one(ca_t res, ca_ctx_t ctx) + # Sets *res* to the integer 0, 1 or -1. This creates a canonical representation + # of this number as an element of the trivial field `\mathbb{Q}`. + + void ca_i(ca_t res, ca_ctx_t ctx) + void ca_neg_i(ca_t res, ca_ctx_t ctx) + # Sets *res* to the imaginary unit `i = \sqrt{-1}`, or its negation `-i`. + # This creates a canonical representation of `i` as the generator of the + # algebraic number field `\mathbb{Q}(i)`. + + void ca_pi(ca_t res, ca_ctx_t ctx) + # Sets *res* to the constant `\pi`. This creates an element + # of the transcendental number field `\mathbb{Q}(\pi)`. + + void ca_pi_i(ca_t res, ca_ctx_t ctx) + # Sets *res* to the constant `\pi i`. This creates an element of the + # composite field `\mathbb{Q}(i,\pi)` rather than representing `\pi i` + # (or even `2 \pi i`, which for some purposes would be more elegant) + # as an atomic quantity. + + void ca_euler(ca_t res, ca_ctx_t ctx) + # Sets *res* to Euler's constant `\gamma`. This creates an element + # of the (transcendental?) number field `\mathbb{Q}(\gamma)`. + + void ca_unknown(ca_t res, ca_ctx_t ctx) + # Sets *res* to the meta-value *Unknown*. + + void ca_undefined(ca_t res, ca_ctx_t ctx) + # Sets *res* to *Undefined*. + + void ca_uinf(ca_t res, ca_ctx_t ctx) + # Sets *res* to unsigned infinity `{\tilde \infty}`. + + void ca_pos_inf(ca_t res, ca_ctx_t ctx) + void ca_neg_inf(ca_t res, ca_ctx_t ctx) + void ca_pos_i_inf(ca_t res, ca_ctx_t ctx) + void ca_neg_i_inf(ca_t res, ca_ctx_t ctx) + # Sets *res* to the signed infinity `+\infty`, `-\infty`, `+i \infty` or `-i \infty`. + + void ca_set(ca_t res, const ca_t x, ca_ctx_t ctx) + # Sets *res* to a copy of *x*. + + void ca_set_si(ca_t res, long v, ca_ctx_t ctx) + void ca_set_ui(ca_t res, unsigned long v, ca_ctx_t ctx) + void ca_set_fmpz(ca_t res, const fmpz_t v, ca_ctx_t ctx) + void ca_set_fmpq(ca_t res, const fmpq_t v, ca_ctx_t ctx) + # Sets *res* to the integer or rational number *v*. This creates a canonical + # representation of this number as an element of the trivial field + # `\mathbb{Q}`. + + void ca_set_d(ca_t res, double x, ca_ctx_t ctx) + void ca_set_d_d(ca_t res, double x, double y, ca_ctx_t ctx) + # Sets *res* to the value of *x*, or the complex value `x + yi`. + # NaN is interpreted as *Unknown* (not *Undefined*). + + void ca_transfer(ca_t res, ca_ctx_t res_ctx, const ca_t src, ca_ctx_t src_ctx) + # Sets *res* to *src* where the corresponding context objects *res_ctx* and + # *src_ctx* may be different. + # This operation preserves the mathematical value represented by *src*, + # but may result in a different internal representation depending on the + # settings of the context objects. + + void ca_set_qqbar(ca_t res, const qqbar_t x, ca_ctx_t ctx) + # Sets *res* to the algebraic number *x*. + # If *x* is rational, *res* is set to the canonical representation as + # an element in the trivial field `\mathbb{Q}`. + # If *x* is irrational, this function always sets *res* to an element of + # a univariate number field `\mathbb{Q}(a)`. It will not, for example, + # identify `\sqrt{2} + \sqrt{3}` + # as an element of `\mathbb{Q}(\sqrt{2}, \sqrt{3})`. However, it may + # attempt to find a simpler number field than that generated by *x* + # itself. For example: + # * If *x* is quadratic, it will be expressed as an element of + # `\mathbb{Q}(\sqrt{N})` where *N* has no small repeated factors + # (obtained by performing a smooth factorization of the discriminant). + # * TODO: if possible, coerce *x* to a low-degree cyclotomic field. + + int ca_get_fmpz(fmpz_t res, const ca_t x, ca_ctx_t ctx) + int ca_get_fmpq(fmpq_t res, const ca_t x, ca_ctx_t ctx) + int ca_get_qqbar(qqbar_t res, const ca_t x, ca_ctx_t ctx) + # Attempts to evaluate *x* to an explicit integer, rational or + # algebraic number. If successful, sets *res* to this number and + # returns 1. If unsuccessful, returns 0. + # The conversion certainly fails if *x* does not represent an integer, + # rational or algebraic number (respectively), but can also fail if *x* + # is too expensive to compute under + # the current evaluation limits. + # In particular, the evaluation will be aborted if an intermediate + # algebraic number (or more precisely, the resultant polynomial prior + # to factorization) exceeds ``CA_OPT_QQBAR_DEG_LIMIT`` + # or the coefficients exceed some multiple of ``CA_OPT_PREC_LIMIT``. + # Note that evaluation may hit those limits even if the minimal polynomial + # for *x* itself is small. The conversion can also fail if no algorithm + # has been implemented for the functions appearing in the construction + # of *x*. + + int ca_can_evaluate_qqbar(const ca_t x, ca_ctx_t ctx) + # Checks if :func:`ca_get_qqbar` has a chance to succeed. In effect, + # this checks if all extension numbers are manifestly algebraic + # numbers (without doing any evaluation). + + void ca_randtest_rational(ca_t res, flint_rand_t state, long bits, ca_ctx_t ctx) + # Sets *res* to a random rational number with numerator and denominator + # up to *bits* bits in size. + + void ca_randtest(ca_t res, flint_rand_t state, long depth, long bits, ca_ctx_t ctx) + # Sets *res* to a random number generated by evaluating a random expression. + # The algorithm randomly selects between generating a "simple" number + # (a random rational number or quadratic field element with coefficients + # up to *bits* in size, or a random builtin constant), + # or if *depth* is nonzero, applying a random arithmetic operation or + # function to operands produced through recursive calls with + # *depth* - 1. The output is guaranteed to be a number, not a special value. + + void ca_randtest_special(ca_t res, flint_rand_t state, long depth, long bits, ca_ctx_t ctx) + # Randomly generates either a special value or a number. + + void ca_randtest_same_nf(ca_t res, flint_rand_t state, const ca_t x, long bits, long den_bits, ca_ctx_t ctx) + # Sets *res* to a random element in the same number field as *x*, + # with numerator coefficients up to *bits* in size and denominator + # up to *den_bits* in size. This function requires that *x* is an + # element of an absolute number field. + + int ca_equal_repr(const ca_t x, const ca_t y, ca_ctx_t ctx) + # Returns whether *x* and *y* have identical representation. For field + # elements, this checks if *x* and *y* belong to the same formal field + # (with generators having identical representation) and are represented by + # the same rational function within that field. + # For special values, this tests + # equality of the special values, with *Unknown* handled as if it were + # a value rather than a meta-value: that is, *Unknown* = *Unknown* gives 1, + # and *Unknown* = *y* gives 0 for any other kind of value *y*. + # If neither *x* nor *y* is *Unknown*, then representation equality + # implies that *x* and *y* describe to the same mathematical value, but if + # either operand is *Unknown*, the result is meaningless for + # mathematical comparison. + + int ca_cmp_repr(const ca_t x, const ca_t y, ca_ctx_t ctx) + # Compares the representations of *x* and *y* in a canonical sort order, + # returning -1, 0 or 1. This only performs a lexicographic comparison + # of the representations of *x* and *y*; the return value does not say + # anything meaningful about the numbers represented by *x* and *y*. + + unsigned long ca_hash_repr(const ca_t x, ca_ctx_t ctx) + # Hashes the representation of *x*. + + int ca_is_unknown(const ca_t x, ca_ctx_t ctx) + # Returns whether *x* is Unknown. + + int ca_is_special(const ca_t x, ca_ctx_t ctx) + # Returns whether *x* is a special value or metavalue + # (not a field element). + + int ca_is_qq_elem(const ca_t x, ca_ctx_t ctx) + # Returns whether *x* is represented as an element of the + # rational field `\mathbb{Q}`. + + int ca_is_qq_elem_zero(const ca_t x, ca_ctx_t ctx) + int ca_is_qq_elem_one(const ca_t x, ca_ctx_t ctx) + int ca_is_qq_elem_integer(const ca_t x, ca_ctx_t ctx) + # Returns whether *x* is represented as the element 0, 1 or + # any integer in the rational field `\mathbb{Q}`. + + int ca_is_nf_elem(const ca_t x, ca_ctx_t ctx) + # Returns whether *x* is represented as an element of a univariate + # algebraic number field `\mathbb{Q}(a)`. + + int ca_is_cyclotomic_nf_elem(long * p, unsigned long * q, const ca_t x, ca_ctx_t ctx) + # Returns whether *x* is represented as an element of a univariate + # cyclotomic field, i.e. `\mathbb{Q}(a)` where *a* is a root of unity. + # If *p* and *q* are not *NULL* and *x* is represented as an + # element of a cyclotomic field, this also sets *p* and *q* to the + # minimal integers with `0 \le p < q` such that the generating + # root of unity is `a = e^{2 \pi i p / q}`. + # Note that the answer 0 does not prove that *x* is not + # a cyclotomic number, + # and the order *q* is also not necessarily the generator of the + # *smallest* cyclotomic field containing *x*. + # For the purposes of this function, only nontrivial + # cyclotomic fields count; the return value is 0 if *x* + # is represented as a rational number. + + int ca_is_generic_elem(const ca_t x, ca_ctx_t ctx) + # Returns whether *x* is represented as a generic field element; + # i.e. it is not a special value, not represented as + # an element of the rational field, and not represented as + # an element of a univariate algebraic number field. + + truth_t ca_check_is_number(const ca_t x, ca_ctx_t ctx) + # Tests if *x* is a number. The result is ``T_TRUE`` is *x* is + # a field element (and hence a complex number), ``T_FALSE`` if *x* is + # an infinity or *Undefined*, and ``T_UNKNOWN`` if *x* is *Unknown*. + + truth_t ca_check_is_zero(const ca_t x, ca_ctx_t ctx) + truth_t ca_check_is_one(const ca_t x, ca_ctx_t ctx) + truth_t ca_check_is_neg_one(const ca_t x, ca_ctx_t ctx) + truth_t ca_check_is_i(const ca_t x, ca_ctx_t ctx) + truth_t ca_check_is_neg_i(const ca_t x, ca_ctx_t ctx) + # Tests if *x* is equal to the number `0`, `1`, `-1`, `i`, or `-i`. + + truth_t ca_check_is_algebraic(const ca_t x, ca_ctx_t ctx) + truth_t ca_check_is_rational(const ca_t x, ca_ctx_t ctx) + truth_t ca_check_is_integer(const ca_t x, ca_ctx_t ctx) + # Tests if *x* is respectively an algebraic number, a rational number, + # or an integer. + + truth_t ca_check_is_real(const ca_t x, ca_ctx_t ctx) + # Tests if *x* is a real number. Warning: this returns ``T_FALSE`` if *x* is an + # infinity with real sign. + + truth_t ca_check_is_negative_real(const ca_t x, ca_ctx_t ctx) + # Tests if *x* is a negative real number. Warning: this returns ``T_FALSE`` + # if *x* is negative infinity. + + truth_t ca_check_is_imaginary(const ca_t x, ca_ctx_t ctx) + # Tests if *x* is an imaginary number. Warning: this returns ``T_FALSE`` if + # *x* is an infinity with imaginary sign. + + truth_t ca_check_is_undefined(const ca_t x, ca_ctx_t ctx) + # Tests if *x* is the special value *Undefined*. + + truth_t ca_check_is_infinity(const ca_t x, ca_ctx_t ctx) + # Tests if *x* is any infinity (unsigned or signed). + + truth_t ca_check_is_uinf(const ca_t x, ca_ctx_t ctx) + # Tests if *x* is unsigned infinity `{\tilde \infty}`. + + truth_t ca_check_is_signed_inf(const ca_t x, ca_ctx_t ctx) + # Tests if *x* is any signed infinity. + + truth_t ca_check_is_pos_inf(const ca_t x, ca_ctx_t ctx) + truth_t ca_check_is_neg_inf(const ca_t x, ca_ctx_t ctx) + truth_t ca_check_is_pos_i_inf(const ca_t x, ca_ctx_t ctx) + truth_t ca_check_is_neg_i_inf(const ca_t x, ca_ctx_t ctx) + # Tests if *x* is equal to the signed infinity `+\infty`, `-\infty`, + # `+i \infty`, `-i \infty`, respectively. + + truth_t ca_check_equal(const ca_t x, const ca_t y, ca_ctx_t ctx) + # Tests `x = y` as a mathematical equality. + # The result is ``T_UNKNOWN`` if either operand is *Unknown*. + # The result may also be ``T_UNKNOWN`` if *x* and *y* are numerically + # indistinguishable and cannot be proved equal or unequal by + # an exact computation. + + truth_t ca_check_lt(const ca_t x, const ca_t y, ca_ctx_t ctx) + truth_t ca_check_le(const ca_t x, const ca_t y, ca_ctx_t ctx) + truth_t ca_check_gt(const ca_t x, const ca_t y, ca_ctx_t ctx) + truth_t ca_check_ge(const ca_t x, const ca_t y, ca_ctx_t ctx) + # Compares *x* and *y*, implementing the respective operations + # `x < y`, `x \le y`, `x > y`, `x \ge y`. + # Only real numbers and `-\infty` and `+\infty` are considered comparable. + # The result is ``T_FALSE`` (not ``T_UNKNOWN``) if either operand is not + # comparable (being a nonreal complex number, unsigned infinity, or + # undefined). + + void ca_merge_fields(ca_t resx, ca_t resy, const ca_t x, const ca_t y, ca_ctx_t ctx) + # Sets *resx* and *resy* to copies of *x* and *y* coerced to a common field. + # Both *x* and *y* must be field elements (not special values). + # In the present implementation, this simply merges the lists of generators, + # avoiding duplication. In the future, it will be able to eliminate + # generators satisfying algebraic relations. + + void ca_condense_field(ca_t res, ca_ctx_t ctx) + # Attempts to demote the value of *res* to a trivial subfield of its + # current field by removing unused generators. In particular, this demotes + # any obviously rational value to the trivial field `\mathbb{Q}`. + # This function is applied automatically in most operations + # (arithmetic operations, etc.). + + ca_ext_ptr ca_is_gen_as_ext(const ca_t x, ca_ctx_t ctx) + # If *x* is a generator of its formal field, `x = a_k \in \mathbb{Q}(a_1,\ldots,a_n)`, + # returns a pointer to the extension number defining `a_k`. If *x* is + # not a generator, returns *NULL*. + + void ca_neg(ca_t res, const ca_t x, ca_ctx_t ctx) + # Sets *res* to the negation of *x*. + # For numbers, this operation amounts to a direct negation within the + # formal field. + # For a signed infinity `c \infty`, negation gives `(-c) \infty`; all other + # special values are unchanged. + + void ca_add_fmpq(ca_t res, const ca_t x, const fmpq_t y, ca_ctx_t ctx) + void ca_add_fmpz(ca_t res, const ca_t x, const fmpz_t y, ca_ctx_t ctx) + void ca_add_ui(ca_t res, const ca_t x, unsigned long y, ca_ctx_t ctx) + void ca_add_si(ca_t res, const ca_t x, long y, ca_ctx_t ctx) + void ca_add(ca_t res, const ca_t x, const ca_t y, ca_ctx_t ctx) + # Sets *res* to the sum of *x* and *y*. For special values, the following + # rules apply (`c \infty` denotes a signed infinity, `|c| = 1`): + # * `c \infty + d \infty = c \infty` if `c = d` + # * `c \infty + d \infty = \text{Undefined}` if `c \ne d` + # * `\tilde \infty + c \infty = \tilde \infty + \tilde \infty = \text{Undefined}` + # * `c \infty + z = c \infty` if `z \in \mathbb{C}` + # * `\tilde \infty + z = \tilde \infty` if `z \in \mathbb{C}` + # * `z + \text{Undefined} = \text{Undefined}` for any value *z* (including *Unknown*) + # In any other case involving special values, or if the specific case cannot + # be distinguished, the result is *Unknown*. + + void ca_sub_fmpq(ca_t res, const ca_t x, const fmpq_t y, ca_ctx_t ctx) + void ca_sub_fmpz(ca_t res, const ca_t x, const fmpz_t y, ca_ctx_t ctx) + void ca_sub_ui(ca_t res, const ca_t x, unsigned long y, ca_ctx_t ctx) + void ca_sub_si(ca_t res, const ca_t x, long y, ca_ctx_t ctx) + void ca_fmpq_sub(ca_t res, const fmpq_t x, const ca_t y, ca_ctx_t ctx) + void ca_fmpz_sub(ca_t res, const fmpz_t x, const ca_t y, ca_ctx_t ctx) + void ca_ui_sub(ca_t res, unsigned long x, const ca_t y, ca_ctx_t ctx) + void ca_si_sub(ca_t res, long x, const ca_t y, ca_ctx_t ctx) + void ca_sub(ca_t res, const ca_t x, const ca_t y, ca_ctx_t ctx) + # Sets *res* to the difference of *x* and *y*. + # This is equivalent to computing `x + (-y)`. + + void ca_mul_fmpq(ca_t res, const ca_t x, const fmpq_t y, ca_ctx_t ctx) + void ca_mul_fmpz(ca_t res, const ca_t x, const fmpz_t y, ca_ctx_t ctx) + void ca_mul_ui(ca_t res, const ca_t x, unsigned long y, ca_ctx_t ctx) + void ca_mul_si(ca_t res, const ca_t x, long y, ca_ctx_t ctx) + void ca_mul(ca_t res, const ca_t x, const ca_t y, ca_ctx_t ctx) + # Sets *res* to the product of *x* and *y*. For special values, the following + # rules apply (`c \infty` denotes a signed infinity, `|c| = 1`): + # * `c \infty \cdot d \infty = c d \infty` + # * `c \infty \cdot \tilde \infty = \tilde \infty` + # * `\tilde \infty \cdot \tilde \infty = \tilde \infty` + # * `c \infty \cdot z = \operatorname{sgn}(z) c \infty` if `z \in \mathbb{C} \setminus \{0\}` + # * `c \infty \cdot 0 = \text{Undefined}` + # * `\tilde \infty \cdot 0 = \text{Undefined}` + # * `z \cdot \text{Undefined} = \text{Undefined}` for any value *z* (including *Unknown*) + # In any other case involving special values, or if the specific case cannot + # be distinguished, the result is *Unknown*. + + void ca_inv(ca_t res, const ca_t x, ca_ctx_t ctx) + # Sets *res* to the multiplicative inverse of *x*. In a univariate algebraic + # number field, this always produces a rational denominator, but the + # denominator might not be rationalized in a multivariate + # field. + # For special values + # and zero, the following rules apply: + # * `1 / (c \infty) = 1 / \tilde \infty = 0` + # * `1 / 0 = \tilde \infty` + # * `1 / \text{Undefined} = \text{Undefined}` + # * `1 / \text{Unknown} = \text{Unknown}` + # If it cannot be determined whether *x* is zero or nonzero, + # the result is *Unknown*. + + void ca_fmpq_div(ca_t res, const fmpq_t x, const ca_t y, ca_ctx_t ctx) + void ca_fmpz_div(ca_t res, const fmpz_t x, const ca_t y, ca_ctx_t ctx) + void ca_ui_div(ca_t res, unsigned long x, const ca_t y, ca_ctx_t ctx) + void ca_si_div(ca_t res, long x, const ca_t y, ca_ctx_t ctx) + void ca_div_fmpq(ca_t res, const ca_t x, const fmpq_t y, ca_ctx_t ctx) + void ca_div_fmpz(ca_t res, const ca_t x, const fmpz_t y, ca_ctx_t ctx) + void ca_div_ui(ca_t res, const ca_t x, unsigned long y, ca_ctx_t ctx) + void ca_div_si(ca_t res, const ca_t x, long y, ca_ctx_t ctx) + void ca_div(ca_t res, const ca_t x, const ca_t y, ca_ctx_t ctx) + # Sets *res* to the quotient of *x* and *y*. This is equivalent + # to computing `x \cdot (1 / y)`. For special values and division + # by zero, this implies the following rules + # (`c \infty` denotes a signed infinity, `|c| = 1`): + # * `(c \infty) / (d \infty) = (c \infty) / \tilde \infty = \tilde \infty / (c \infty) = \tilde \infty / \tilde \infty = \text{Undefined}` + # * `c \infty / z = (c / \operatorname{sgn}(z)) \infty` if `z \in \mathbb{C} \setminus \{0\}` + # * `c \infty / 0 = \tilde \infty / 0 = \tilde \infty` + # * `z / (c \infty) = z / \tilde \infty = 0` if `z \in \mathbb{C}` + # * `z / 0 = \tilde \infty` if `z \in \mathbb{C} \setminus \{0\}` + # * `0 / 0 = \text{Undefined}` + # * `z / \text{Undefined} = \text{Undefined}` for any value *z* (including *Unknown*) + # * `\text{Undefined} / z = \text{Undefined}` for any value *z* (including *Unknown*) + # In any other case involving special values, or if the specific case cannot + # be distinguished, the result is *Unknown*. + + void ca_dot(ca_t res, const ca_t initial, int subtract, ca_srcptr x, long xstep, ca_srcptr y, long ystep, long len, ca_ctx_t ctx) + # Computes the dot product of the vectors *x* and *y*, setting + # *res* to `s + (-1)^{subtract} \sum_{i=0}^{len-1} x_i y_i`. + # The initial term *s* is optional and can be + # omitted by passing *NULL* (equivalently, `s = 0`). + # The parameter *subtract* must be 0 or 1. + # The length *len* is allowed to be negative, which is equivalent + # to a length of zero. + # The parameters *xstep* or *ystep* specify a step length for + # traversing subsequences of the vectors *x* and *y*; either can be + # negative to step in the reverse direction starting from + # the initial pointer. + # Aliasing is allowed between *res* and *s* but not between + # *res* and the entries of *x* and *y*. + + void ca_fmpz_poly_evaluate(ca_t res, const fmpz_poly_t poly, const ca_t x, ca_ctx_t ctx) + void ca_fmpq_poly_evaluate(ca_t res, const fmpq_poly_t poly, const ca_t x, ca_ctx_t ctx) + # Sets *res* to the polynomial *poly* evaluated at *x*. + + void ca_fmpz_mpoly_evaluate_horner(ca_t res, const fmpz_mpoly_t f, ca_srcptr x, const fmpz_mpoly_ctx_t mctx, ca_ctx_t ctx) + void ca_fmpz_mpoly_evaluate_iter(ca_t res, const fmpz_mpoly_t f, ca_srcptr x, const fmpz_mpoly_ctx_t mctx, ca_ctx_t ctx) + void ca_fmpz_mpoly_evaluate(ca_t res, const fmpz_mpoly_t f, ca_srcptr x, const fmpz_mpoly_ctx_t mctx, ca_ctx_t ctx) + # Sets *res* to the multivariate polynomial *f* evaluated at the vector of arguments *x*. + + void ca_fmpz_mpoly_q_evaluate(ca_t res, const fmpz_mpoly_q_t f, ca_srcptr x, const fmpz_mpoly_ctx_t mctx, ca_ctx_t ctx) + # Sets *res* to the multivariate rational function *f* evaluated at the vector of arguments *x*. + + void ca_fmpz_mpoly_q_evaluate_no_division_by_zero(ca_t res, const fmpz_mpoly_q_t f, ca_srcptr x, const fmpz_mpoly_ctx_t mctx, ca_ctx_t ctx) + void ca_inv_no_division_by_zero(ca_t res, const ca_t x, ca_ctx_t ctx) + # These functions behave like the normal arithmetic functions, + # but assume (and do not check) that division by zero cannot occur. + # Division by zero will result in undefined behavior. + + void ca_sqr(ca_t res, const ca_t x, ca_ctx_t ctx) + # Sets *res* to the square of *x*. + + void ca_pow_fmpq(ca_t res, const ca_t x, const fmpq_t y, ca_ctx_t ctx) + void ca_pow_fmpz(ca_t res, const ca_t x, const fmpz_t y, ca_ctx_t ctx) + void ca_pow_ui(ca_t res, const ca_t x, unsigned long y, ca_ctx_t ctx) + void ca_pow_si(ca_t res, const ca_t x, long y, ca_ctx_t ctx) + void ca_pow(ca_t res, const ca_t x, const ca_t y, ca_ctx_t ctx) + # Sets *res* to *x* raised to the power *y*. + # Handling of special values is not yet implemented. + + void ca_pow_si_arithmetic(ca_t res, const ca_t x, long n, ca_ctx_t ctx) + # Sets *res* to *x* raised to the power *n*. Whereas :func:`ca_pow`, + # :func:`ca_pow_si` etc. may create `x^n` as an extension number + # if *n* is large, this function always perform the exponentiation + # using field arithmetic. + + void ca_sqrt_inert(ca_t res, const ca_t x, ca_ctx_t ctx) + void ca_sqrt_nofactor(ca_t res, const ca_t x, ca_ctx_t ctx) + void ca_sqrt_factor(ca_t res, const ca_t x, unsigned long flags, ca_ctx_t ctx) + void ca_sqrt(ca_t res, const ca_t x, ca_ctx_t ctx) + # Sets *res* to the principal square root of *x*. + # For special values, the following definitions apply: + # * `\sqrt{c \infty} = \sqrt{c} \infty` + # * `\sqrt{\tilde \infty} = \tilde \infty`. + # * Both *Undefined* and *Unknown* map to themselves. + # The *inert* version outputs the generator in the formal field + # `\mathbb{Q}(\sqrt{x})` without simplifying. + # The *factor* version writes `x = A^2 B` in `K` where `K` is + # the field of *x*, and outputs `A \sqrt{B}` or + # `-A \sqrt{B}` (whichever gives the correct sign) as an element of + # `K(\sqrt{B})` or some subfield thereof. + # This factorization is only a heuristic and is not guaranteed + # to make `B` minimal. + # Factorization options can be passed through to *flags*: see + # :func:`ca_factor` for details. + # The *nofactor* version will not perform a general factorization, but + # may still perform other simplifications. It may in particular attempt to + # simplify `\sqrt{x}` to a single element in `\overline{\mathbb{Q}}`. + + void ca_sqrt_ui(ca_t res, unsigned long n, ca_ctx_t ctx) + # Sets *res* to the principal square root of *n*. + + void ca_abs(ca_t res, const ca_t x, ca_ctx_t ctx) + # Sets *res* to the absolute value of *x*. + # For special values, the following definitions apply: + # * `|c \infty| = |\tilde \infty| = +\infty`. + # * Both *Undefined* and *Unknown* map to themselves. + # This function will attempt to simplify its argument through an exact + # computation. It may in particular attempt to simplify `|x|` to + # a single element in `\overline{\mathbb{Q}}`. + # In the generic case, this function outputs an element of the formal + # field `\mathbb{Q}(|x|)`. + + void ca_sgn(ca_t res, const ca_t x, ca_ctx_t ctx) + # Sets *res* to the sign of *x*, defined by + # .. math :: + # \operatorname{sgn}(x) = \begin{cases} 0 & x = 0 \\ \frac{x}{|x|} & x \ne 0 \end{cases} + # for numbers. For special values, the following definitions apply: + # * `\operatorname{sgn}(c \infty) = c`. + # * `\operatorname{sgn}(\tilde \infty) = \operatorname{Undefined}`. + # * Both *Undefined* and *Unknown* map to themselves. + # This function will attempt to simplify its argument through an exact + # computation. It may in particular attempt to simplify `\operatorname{sgn}(x)` to + # a single element in `\overline{\mathbb{Q}}`. + # In the generic case, this function outputs an element of the formal + # field `\mathbb{Q}(\operatorname{sgn}(x))`. + + void ca_csgn(ca_t res, const ca_t x, ca_ctx_t ctx) + # Sets *res* to the extension of the real sign function taking the + # value 1 for *z* strictly in the right half plane, -1 for *z* strictly + # in the left half plane, and the sign of the imaginary part when *z* is on + # the imaginary axis. Equivalently, `\operatorname{csgn}(z) = z / \sqrt{z^2}` + # except that the value is 0 when *z* is exactly zero. + # This function gives *Undefined* for unsigned infinity + # and `\operatorname{csgn}(\operatorname{sgn}(c \infty)) = \operatorname{csgn}(c)` for + # signed infinities. + + void ca_arg(ca_t res, const ca_t x, ca_ctx_t ctx) + # Sets *res* to the complex argument (phase) of *x*, normalized + # to the range `(-\pi, +\pi]`. The argument of 0 is defined as 0. + # For special values, the following definitions apply: + # * `\operatorname{arg}(c \infty) = \operatorname{arg}(c)`. + # * `\operatorname{arg}(\tilde \infty) = \operatorname{Undefined}`. + # * Both *Undefined* and *Unknown* map to themselves. + + void ca_re(ca_t res, const ca_t x, ca_ctx_t ctx) + # Sets *res* to the real part of *x*. The result is *Undefined* if *x* + # is any infinity (including a real infinity). + + void ca_im(ca_t res, const ca_t x, ca_ctx_t ctx) + # Sets *res* to the imaginary part of *x*. The result is *Undefined* if *x* + # is any infinity (including an imaginary infinity). + + void ca_conj_deep(ca_t res, const ca_t x, ca_ctx_t ctx) + void ca_conj_shallow(ca_t res, const ca_t x, ca_ctx_t ctx) + void ca_conj(ca_t res, const ca_t x, ca_ctx_t ctx) + # Sets *res* to the complex conjugate of *x*. + # The *shallow* version creates a new extension element + # `\overline{x}` unless *x* can be trivially conjugated in-place + # in the existing field. + # The *deep* version recursively conjugates the extension numbers + # in the field of *x*. + + void ca_floor(ca_t res, const ca_t x, ca_ctx_t ctx) + # Sets *res* to the floor function of *x*. The result is *Undefined* if *x* + # is any infinity (including a real infinity). + # For complex numbers, this is presently defined to take the floor of the + # real part. + + void ca_ceil(ca_t res, const ca_t x, ca_ctx_t ctx) + # Sets *res* to the ceiling function of *x*. The result is *Undefined* if *x* + # is any infinity (including a real infinity). + # For complex numbers, this is presently defined to take the ceiling of the + # real part. + + void ca_exp(ca_t res, const ca_t x, ca_ctx_t ctx) + # Sets *res* to the exponential function of *x*. + # For special values, the following definitions apply: + # * `e^{+\infty} = +\infty` + # * `e^{c \infty} = \tilde \infty` if `0 < \operatorname{Re}(c) < 1`. + # * `e^{c \infty} = 0` if `\operatorname{Re}(c) < 0`. + # * `e^{c \infty} = \text{Undefined}` if `\operatorname{Re}(c) = 0`. + # * `e^{\tilde \infty} = \text{Undefined}`. + # * Both *Undefined* and *Unknown* map to themselves. + # The following symbolic simplifications are performed automatically: + # * `e^0 = 1` + # * `e^{\log(z)} = z` + # * `e^{(p/q) \log(z)} = z^{p/q}` (for rational `p/q`) + # * `e^{(p/q) \pi i}` = algebraic root of unity (for small rational `p/q`) + # In the generic case, this function outputs an element of the formal + # field `\mathbb{Q}(e^x)`. + + void ca_log(ca_t res, const ca_t x, ca_ctx_t ctx) + # Sets *res* to the natural logarithm of *x*. + # For special values and at the origin, the following definitions apply: + # * For any infinity, `\log(c\infty) = \log(\tilde \infty) = +\infty`. + # * `\log(0) = -\infty`. The result is *Unknown* if deciding `x = 0` fails. + # * Both *Undefined* and *Unknown* map to themselves. + # The following symbolic simplifications are performed automatically: + # * `\log(1) = 0` + # * `\log\left(e^z\right) = z + 2 \pi i k` + # * `\log\left(\sqrt{z}\right) = \tfrac{1}{2} \log(z) + 2 \pi i k` + # * `\log\left(z^a\right) = a \log(z) + 2 \pi i k` + # * `\log(x) = \log(-x) + \pi i` for negative real *x* + # In the generic case, this function outputs an element of the formal + # field `\mathbb{Q}(\log(x))`. + + void ca_sin_cos_exponential(ca_t res1, ca_t res2, const ca_t x, ca_ctx_t ctx) + void ca_sin_cos_direct(ca_t res1, ca_t res2, const ca_t x, ca_ctx_t ctx) + void ca_sin_cos_tangent(ca_t res1, ca_t res2, const ca_t x, ca_ctx_t ctx) + void ca_sin_cos(ca_t res1, ca_t res2, const ca_t x, ca_ctx_t ctx) + # Sets *res1* to the sine of *x* and *res2* to the cosine of *x*. + # Either *res1* or *res2* can be *NULL* to compute only the other function. + # Various representations are implemented: + # * The *exponential* version expresses the sine and cosine in terms + # of complex exponentials. Simple algebraic values will simplify to + # rational numbers or elements of cyclotomic fields. + # * The *direct* method expresses the sine and cosine in terms of + # the original functions (perhaps after applying some symmetry + # transformations, which may interchange sin and cos). Extremely + # simple algebraic values will automatically simplify to elements + # of real algebraic number fields. + # * The *tangent* version expresses the sine and cosine in terms + # of `\tan(x/2)`, perhaps after applying some symmetry + # transformations. Extremely simple algebraic values will + # automatically simplify to elements of real algebraic number + # fields. + # By default, the standard function uses the *exponential* + # representation as this typically works best for field arithmetic + # and simplifications, although it has the disadvantage of + # introducing complex numbers where real numbers would be sufficient. + # The behavior of the standard function can be changed using the + # :macro:`CA_OPT_TRIG_FORM` context setting. + # For special values, the following definitions apply: + # * `\sin(\pm i \infty) = \pm i \infty` + # * `\cos(\pm i \infty) = +\infty` + # * All other infinities give `\operatorname{Undefined}` + + void ca_sin(ca_t res, const ca_t x, ca_ctx_t ctx) + void ca_cos(ca_t res, const ca_t x, ca_ctx_t ctx) + # Sets *res* to the sine or cosine of *x*. + # These functions are shortcuts for :func:`ca_sin_cos`. + + void ca_tan_sine_cosine(ca_t res, const ca_t x, ca_ctx_t ctx) + void ca_tan_exponential(ca_t res, const ca_t x, ca_ctx_t ctx) + void ca_tan_direct(ca_t res, const ca_t x, ca_ctx_t ctx) + void ca_tan(ca_t res, const ca_t x, ca_ctx_t ctx) + # Sets *res* to the tangent of *x*. + # The *sine_cosine* version evaluates the tangent as a quotient of + # a sine and cosine, the *direct* version evaluates it directly + # as a tangent (possibly after transforming the variable), + # and the *exponential* version evaluates it in terms of complex + # exponentials. + # Simple algebraic values will automatically simplify to elements + # of trigonometric or cyclotomic number fields. + # By default, the standard function uses the *exponential* + # representation as this typically works best for field arithmetic + # and simplifications, although it has the disadvantage of + # introducing complex numbers where real numbers would be sufficient. + # The behavior of the standard function can be changed using the + # :macro:`CA_OPT_TRIG_FORM` context setting. + # For special values, the following definitions apply: + # * At poles, `\tan((n+\tfrac{1}{2}) \pi) = \tilde \infty` + # * `\tan(e^{i \theta} \infty) = +i, \quad 0 < \theta < \pi` + # * `\tan(e^{i \theta} \infty) = -i, \quad -\pi < \theta < 0` + # * `\tan(\pm \infty) = \tan(\tilde \infty) = \operatorname{Undefined}` + + void ca_cot(ca_t res, const ca_t x, ca_ctx_t ctx) + # Sets *res* to the cotangent *x*. This is equivalent to + # computing the reciprocal of the tangent. + + void ca_atan_logarithm(ca_t res, const ca_t x, ca_ctx_t ctx) + void ca_atan_direct(ca_t res, const ca_t x, ca_ctx_t ctx) + void ca_atan(ca_t res, const ca_t x, ca_ctx_t ctx) + # Sets *res* to the inverse tangent of *x*. + # The *direct* version expresses the result as an inverse tangent + # (possibly after transforming the variable). The *logarithm* + # version expresses it in terms of complex logarithms. + # Simple algebraic inputs will automatically simplify to + # rational multiples of `\pi`. + # By default, the standard function uses the *logarithm* + # representation as this typically works best for field arithmetic + # and simplifications, although it has the disadvantage of + # introducing complex numbers where real numbers would be sufficient. + # The behavior of the standard function can be changed using the + # :macro:`CA_OPT_TRIG_FORM` context setting (exponential mode + # results in logarithmic forms). + # For special values, the following definitions apply: + # * `\operatorname{atan}(\pm i) = \pm i \infty` + # * `\operatorname{atan}(c \infty) = \operatorname{csgn}(c) \pi / 2` + # * `\operatorname{atan}(\tilde \infty) = \operatorname{Undefined}` + + void ca_asin_logarithm(ca_t res, const ca_t x, ca_ctx_t ctx) + void ca_acos_logarithm(ca_t res, const ca_t x, ca_ctx_t ctx) + void ca_asin_direct(ca_t res, const ca_t x, ca_ctx_t ctx) + void ca_acos_direct(ca_t res, const ca_t x, ca_ctx_t ctx) + void ca_asin(ca_t res, const ca_t x, ca_ctx_t ctx) + void ca_acos(ca_t res, const ca_t x, ca_ctx_t ctx) + # Sets *res* to the inverse sine (respectively, cosine) of *x*. + # The *direct* version expresses the result as an inverse sine or + # cosine (possibly after transforming the variable). The *logarithm* + # version expresses it in terms of complex logarithms. + # Simple algebraic inputs will automatically simplify to + # rational multiples of `\pi`. + # By default, the standard function uses the *logarithm* + # representation as this typically works best for field arithmetic + # and simplifications, although it has the disadvantage of + # introducing complex numbers where real numbers would be sufficient. + # The behavior of the standard function can be changed using the + # :macro:`CA_OPT_TRIG_FORM` context setting (exponential mode + # results in logarithmic forms). + # The inverse cosine is presently implemented as + # `\operatorname{acos}(x) = \pi/2 - \operatorname{asin}(x)`. + + void ca_gamma(ca_t res, const ca_t x, ca_ctx_t ctx) + # Sets *res* to the gamma function of *x*. + + void ca_erf(ca_t res, const ca_t x, ca_ctx_t ctx) + # Sets *res* to the error function of *x*. + + void ca_erfc(ca_t res, const ca_t x, ca_ctx_t ctx) + # Sets *res* to the complementary error function of *x*. + + void ca_erfi(ca_t res, const ca_t x, ca_ctx_t ctx) + # Sets *res* to the imaginary error function of *x*. + + void ca_get_acb_raw(acb_t res, const ca_t x, long prec, ca_ctx_t ctx) + # Sets *res* to an enclosure of the numerical value of *x*. + # A working precision of *prec* bits is used internally for the evaluation, + # without adaptive refinement. + # If *x* is any special value, *res* is set to *acb_indeterminate*. + + void ca_get_acb(acb_t res, const ca_t x, long prec, ca_ctx_t ctx) + void ca_get_acb_accurate_parts(acb_t res, const ca_t x, long prec, ca_ctx_t ctx) + # Sets *res* to an enclosure of the numerical value of *x*. + # The working precision is increased adaptively to try to ensure *prec* + # accurate bits in the output. The *accurate_parts* version tries to ensure + # *prec* accurate bits for both the real and imaginary part separately. + # The refinement is stopped if the working precision exceeds + # ``CA_OPT_PREC_LIMIT`` (or twice the initial precision, if this is larger). + # The user may call *acb_rel_accuracy_bits* to check is the calculation + # was successful. + # The output is not rounded down to *prec* bits (to avoid unnecessary + # double rounding); the user may call *acb_set_round* when rounding + # is desired. + + char * ca_get_decimal_str(const ca_t x, long digits, unsigned long flags, ca_ctx_t ctx) + # Returns a decimal approximation of *x* with precision up to + # *digits*. The output is guaranteed to be correct within 1 ulp + # in the returned digits, but the number of returned digits may + # be smaller than *digits* if the numerical evaluation does + # not succeed. + # If *flags* is set to 1, attempts to achieve full accuracy for + # both the real and imaginary parts separately. + # If *x* is not finite or a finite enclosure cannot be produced, + # returns the string "?". + # The user should free the returned string with ``flint_free``. + + void ca_rewrite_complex_normal_form(ca_t res, const ca_t x, int deep, ca_ctx_t ctx) + # Sets *res* to *x* rewritten using standardizing transformations + # over the complex numbers: + # * Elementary functions are rewritten in terms of (complex) exponentials, roots and logarithms + # * Complex parts are rewritten using logarithms, square roots, and (deep) complex conjugates + # * Algebraic numbers are rewritten in terms of cyclotomic fields where applicable + # If *deep* is set, the rewriting is applied recursively to the tower + # of extension numbers; otherwise, the rewriting is only applied + # to the top-level extension numbers. + # The result is not a normal form in the strong sense (the same + # number can have many possible representations even after applying + # this transformation), but in practice this is a powerful heuristic + # for simplification. + + void ca_factor_init(ca_factor_t fac, ca_ctx_t ctx) + # Initializes *fac* and sets it to the empty factorization + # (equivalent to the number 1). + + void ca_factor_clear(ca_factor_t fac, ca_ctx_t ctx) + # Clears the factorization structure *fac*. + + void ca_factor_one(ca_factor_t fac, ca_ctx_t ctx) + # Sets *fac* to the empty factorization (equivalent to the number 1). + + void ca_factor_print(const ca_factor_t fac, ca_ctx_t ctx) + # Prints a description of *fac* to standard output. + + void ca_factor_insert(ca_factor_t fac, const ca_t base, const ca_t exp, ca_ctx_t ctx) + # Inserts `b^e` into *fac* where *b* is given by *base* and *e* + # is given by *exp*. If a base element structurally identical to *base* + # already exists in *fac*, the corresponding exponent is incremented by *exp*; + # otherwise, this factor is appended. + + void ca_factor_get_ca(ca_t res, const ca_factor_t fac, ca_ctx_t ctx) + # Expands *fac* back to a single :type:`ca_t` by evaluating the powers + # and multiplying out the result. + + void ca_factor(ca_factor_t res, const ca_t x, unsigned long flags, ca_ctx_t ctx) + # Sets *res* to a factorization of *x* + # of the form `x = b_1^{e_1} b_2^{e_2} \cdots b_n^{e_n}`. + # Requires that *x* is not a special value. + # The type of factorization is controlled by *flags*, which can be set + # to a combination of constants in the following section. + + void _ca_make_field_element(ca_t x, ca_field_srcptr new_index, ca_ctx_t ctx) + # Changes the internal representation of *x* to that of an element + # of the field with index *new_index* in the context object *ctx*. + # This may destroy the value of *x*. + + void _ca_make_fmpq(ca_t x, ca_ctx_t ctx) + # Changes the internal representation of *x* to that of an element of + # the trivial field `\mathbb{Q}`. This may destroy the value of *x*. diff --git a/src/sage/libs/flint/ca_ext.pxd b/src/sage/libs/flint/ca_ext.pxd new file mode 100644 index 00000000000..7deb4e37de1 --- /dev/null +++ b/src/sage/libs/flint/ca_ext.pxd @@ -0,0 +1,80 @@ +# distutils: libraries = flint +# distutils: depends = flint/ca_ext.h + +################################################################################ +# This file is auto-generated. Do not modify by hand +################################################################################ + +from libc.stdio cimport FILE +from sage.libs.gmp.types cimport * +from sage.libs.mpfr.types cimport * +from sage.libs.flint.types cimport * + +cdef extern from "flint_wrap.h": + + void ca_ext_init_qqbar(ca_ext_t res, const qqbar_t x, ca_ctx_t ctx) + # Initializes *res* and sets it to the algebraic constant *x*. + + void ca_ext_init_const(ca_ext_t res, calcium_func_code func, ca_ctx_t ctx) + # Initializes *res* and sets it to the constant defined by *func* + # (example: *func* = *CA_Pi* for `x = \pi`). + + void ca_ext_init_fx(ca_ext_t res, calcium_func_code func, const ca_t x, ca_ctx_t ctx) + # Initializes *res* and sets it to the univariate function value `f(x)` + # where *f* is defined by *func* (example: *func* = *CA_Exp* for `e^x`). + + void ca_ext_init_fxy(ca_ext_t res, calcium_func_code func, const ca_t x, const ca_t y, ca_ctx_t ctx) + # Initializes *res* and sets it to the bivariate function value `f(x, y)` + # where *f* is defined by *func* (example: *func* = *CA_Pow* for `x^y`). + + void ca_ext_init_fxn(ca_ext_t res, calcium_func_code func, ca_srcptr x, long nargs, ca_ctx_t ctx) + # Initializes *res* and sets it to the multivariate function value + # `f(x_1, \ldots, x_n)` where *f* is defined by *func* and *n* is + # given by *nargs*. + + void ca_ext_init_set(ca_ext_t res, const ca_ext_t x, ca_ctx_t ctx) + # Initializes *res* and sets it to a copy of *x*. + + void ca_ext_clear(ca_ext_t res, ca_ctx_t ctx) + # Clears *res*. + + long ca_ext_nargs(const ca_ext_t x, ca_ctx_t ctx) + # Returns the number of function arguments of *x*. + # The return value is 0 for any algebraic constant and for any built-in + # symbolic constant such as `\pi`. + + void ca_ext_get_arg(ca_t res, const ca_ext_t x, long i, ca_ctx_t ctx) + # Sets *res* to argument *i* (indexed from zero) of *x*. + # This calls *flint_abort* if *i* is out of range. + + unsigned long ca_ext_hash(const ca_ext_t x, ca_ctx_t ctx) + # Returns a hash of the structural representation of *x*. + + int ca_ext_equal_repr(const ca_ext_t x, const ca_ext_t y, ca_ctx_t ctx) + # Tests *x* and *y* for structural equality, returning 0 (false) or 1 (true). + + int ca_ext_cmp_repr(const ca_ext_t x, const ca_ext_t y, ca_ctx_t ctx) + # Compares the representations of *x* and *y* in a canonical sort order, + # returning -1, 0 or 1. This only performs a structural comparison + # of the symbolic representations; the return value does not say + # anything meaningful about the numbers represented by *x* and *y*. + + void ca_ext_print(const ca_ext_t x, ca_ctx_t ctx) + # Prints a description of *x* to standard output. + + void ca_ext_get_acb_raw(acb_t res, ca_ext_t x, long prec, ca_ctx_t ctx) + # Sets *res* to an enclosure of the numerical value of *x*. + # A working precision of *prec* bits is used for the evaluation, + # without adaptive refinement. + + void ca_ext_cache_init(ca_ext_cache_t cache, ca_ctx_t ctx) + # Initializes *cache* for use. + + void ca_ext_cache_clear(ca_ext_cache_t cache, ca_ctx_t ctx) + # Clears *cache*, freeing the memory allocated internally. + + ca_ext_ptr ca_ext_cache_insert(ca_ext_cache_t cache, const ca_ext_t x, ca_ctx_t ctx) + # Adds *x* to *cache* without duplication. If a structurally identical + # instance already exists in *cache*, a pointer to that instance is returned. + # Otherwise, a copy of *x* is inserted into *cache* and a pointer to that new + # instance is returned. diff --git a/src/sage/libs/flint/ca_field.pxd b/src/sage/libs/flint/ca_field.pxd new file mode 100644 index 00000000000..3ee7134d48c --- /dev/null +++ b/src/sage/libs/flint/ca_field.pxd @@ -0,0 +1,88 @@ +# distutils: libraries = flint +# distutils: depends = flint/ca_field.h + +################################################################################ +# This file is auto-generated. Do not modify by hand +################################################################################ + +from libc.stdio cimport FILE +from sage.libs.gmp.types cimport * +from sage.libs.mpfr.types cimport * +from sage.libs.flint.types cimport * + +cdef extern from "flint_wrap.h": + + void ca_field_init_qq(ca_field_t K, ca_ctx_t ctx) + # Initializes *K* to represent the trivial field `\mathbb{Q}`. + + void ca_field_init_nf(ca_field_t K, const qqbar_t x, ca_ctx_t ctx) + # Initializes *K* to represent the algebraic number field `\mathbb{Q}(x)`. + + void ca_field_init_const(ca_field_t K, calcium_func_code func, ca_ctx_t ctx) + # Initializes *K* to represent the field + # `\mathbb{Q}(x)` where *x* is a builtin constant defined by + # *func* (example: *func* = *CA_Pi* for `x = \pi`). + + void ca_field_init_fx(ca_field_t K, calcium_func_code func, const ca_t x, ca_ctx_t ctx) + # Initializes *K* to represent the field + # `\mathbb{Q}(a)` where `a = f(x)`, given a number *x* and a builtin + # univariate function *func* (example: *func* = *CA_Exp* for `e^x`). + + void ca_field_init_fxy(ca_field_t K, calcium_func_code func, const ca_t x, const ca_t y, ca_ctx_t ctx) + # Initializes *K* to represent the field + # `\mathbb{Q}(a,b)` where `a = f(x, y)`. + + void ca_field_init_multi(ca_field_t K, long len, ca_ctx_t ctx) + # Initializes *K* to represent a multivariate field + # `\mathbb{Q}(a_1, \ldots, a_n)` in *n* + # extension numbers. The extension numbers must subsequently be + # assigned one by one using :func:`ca_field_set_ext`. + + void ca_field_set_ext(ca_field_t K, long i, ca_ext_srcptr x_index, ca_ctx_t ctx) + # Sets the extension number at position *i* (here indexed from 0) of *K* + # to the generator of the field with index *x_index* in *ctx*. + # (It is assumed that the generating field is a univariate field.) + # This only inserts a shallow reference: the field at index *x_index* must + # be kept alive until *K* has been cleared. + + void ca_field_clear(ca_field_t K, ca_ctx_t ctx) + # Clears the field *K*. This does not clear the individual extension + # numbers, which are only held as references. + + void ca_field_print(const ca_field_t K, ca_ctx_t ctx) + # Prints a description of the field *K* to standard output. + + void ca_field_build_ideal(ca_field_t K, ca_ctx_t ctx) + # Given *K* with assigned extension numbers, + # builds the reduction ideal in-place. + + void ca_field_build_ideal_erf(ca_field_t K, ca_ctx_t ctx) + # Builds relations for error functions present among the extension + # numbers in *K*. This heuristic adds relations that are consequences + # of the functional equations + # `\operatorname{erf}(x) = -\operatorname{erf}(-x)`, + # `\operatorname{erfc}(x) = 1-\operatorname{erf}(x)`, + # `\operatorname{erfi}(x) = -i\operatorname{erf}(ix)`. + + int ca_field_cmp(const ca_field_t K1, const ca_field_t K2, ca_ctx_t ctx) + # Compares the field objects *K1* and *K2* in a canonical sort order, + # returning -1, 0 or 1. This only performs a lexicographic comparison + # of the representations of *K1* and *K2*; the return value does not say + # anything meaningful about the relative structures of *K1* and *K2* + # as mathematical fields. + + void ca_field_cache_init(ca_field_cache_t cache, ca_ctx_t ctx) + # Initializes *cache* for use. + + void ca_field_cache_clear(ca_field_cache_t cache, ca_ctx_t ctx) + # Clears *cache*, freeing the memory allocated internally. + # This does not clear the individual extension + # numbers, which are only held as references. + + ca_field_ptr ca_field_cache_insert_ext(ca_field_cache_t cache, ca_ext_struct ** x, long len, ca_ctx_t ctx) + # Adds the field defined by the length-*len* list of extension numbers *x* + # to *cache* without duplication. If such a field already exists in *cache*, + # a pointer to that instance is returned. Otherwise, a field with + # extension numbers *x* is inserted into *cache* and a pointer to that + # new instance is returned. Upon insertion of a new field, the + # reduction ideal is constructed via :func:`ca_field_build_ideal`. diff --git a/src/sage/libs/flint/ca_mat.pxd b/src/sage/libs/flint/ca_mat.pxd new file mode 100644 index 00000000000..e29429db86e --- /dev/null +++ b/src/sage/libs/flint/ca_mat.pxd @@ -0,0 +1,450 @@ +# distutils: libraries = flint +# distutils: depends = flint/ca_mat.h + +################################################################################ +# This file is auto-generated. Do not modify by hand +################################################################################ + +from libc.stdio cimport FILE +from sage.libs.gmp.types cimport * +from sage.libs.mpfr.types cimport * +from sage.libs.flint.types cimport * + +cdef extern from "flint_wrap.h": + + ca_ptr ca_mat_entry_ptr(ca_mat_t mat, long i, long j) + # Returns a pointer to the entry at row *i* and column *j*. + # Equivalent to :macro:`ca_mat_entry` but implemented as a function. + + void ca_mat_init(ca_mat_t mat, long r, long c, ca_ctx_t ctx) + # Initializes the matrix, setting it to the zero matrix with *r* rows + # and *c* columns. + + void ca_mat_clear(ca_mat_t mat, ca_ctx_t ctx) + # Clears the matrix, deallocating all entries. + + void ca_mat_swap(ca_mat_t mat1, ca_mat_t mat2, ca_ctx_t ctx) + # Efficiently swaps *mat1* and *mat2*. + + void ca_mat_window_init(ca_mat_t window, const ca_mat_t mat, long r1, long c1, long r2, long c2, ca_ctx_t ctx) + # Initializes *window* to a window matrix into the submatrix of *mat* + # starting at the corner at row *r1* and column *c1* (inclusive) and ending + # at row *r2* and column *c2* (exclusive). + + void ca_mat_window_clear(ca_mat_t window, ca_ctx_t ctx) + # Frees the window matrix. + + void ca_mat_set(ca_mat_t dest, const ca_mat_t src, ca_ctx_t ctx) + void ca_mat_set_fmpz_mat(ca_mat_t dest, const fmpz_mat_t src, ca_ctx_t ctx) + void ca_mat_set_fmpq_mat(ca_mat_t dest, const fmpq_mat_t src, ca_ctx_t ctx) + # Sets *dest* to *src*. The operands must have identical dimensions. + + void ca_mat_set_ca(ca_mat_t mat, const ca_t c, ca_ctx_t ctx) + # Sets *mat* to the matrix with the scalar *c* on the main diagonal + # and zeros elsewhere. + + void ca_mat_transfer(ca_mat_t res, ca_ctx_t res_ctx, const ca_mat_t src, ca_ctx_t src_ctx) + # Sets *res* to *src* where the corresponding context objects *res_ctx* and + # *src_ctx* may be different. + # This operation preserves the mathematical value represented by *src*, + # but may result in a different internal representation depending on the + # settings of the context objects. + + void ca_mat_randtest(ca_mat_t mat, flint_rand_t state, long depth, long bits, ca_ctx_t ctx) + # Sets *mat* to a random matrix with entries having complexity up to + # *depth* and *bits* (see :func:`ca_randtest`). + + void ca_mat_randtest_rational(ca_mat_t mat, flint_rand_t state, long bits, ca_ctx_t ctx) + # Sets *mat* to a random rational matrix with entries up to *bits* bits in size. + + void ca_mat_randops(ca_mat_t mat, flint_rand_t state, long count, ca_ctx_t ctx) + # Randomizes *mat* in-place by performing elementary row or column operations. + # More precisely, at most count random additions or subtractions of distinct + # rows and columns will be performed. This leaves the rank (and for square matrices, + # the determinant) unchanged. + + void ca_mat_print(const ca_mat_t mat, ca_ctx_t ctx) + # Prints *mat* to standard output. The entries are printed on separate lines. + + void ca_mat_printn(const ca_mat_t mat, long digits, ca_ctx_t ctx) + # Prints a decimal representation of *mat* with precision specified by *digits*. + # The entries are comma-separated with square brackets and comma separation + # for the rows. + + void ca_mat_zero(ca_mat_t mat, ca_ctx_t ctx) + # Sets all entries in *mat* to zero. + + void ca_mat_one(ca_mat_t mat, ca_ctx_t ctx) + # Sets the entries on the main diagonal of *mat* to one, and + # all other entries to zero. + + void ca_mat_ones(ca_mat_t mat, ca_ctx_t ctx) + # Sets all entries in *mat* to one. + + void ca_mat_pascal(ca_mat_t mat, int triangular, ca_ctx_t ctx) + # Sets *mat* to a Pascal matrix, whose entries are binomial coefficients. + # If *triangular* is 0, constructs a full symmetric matrix + # with the rows of Pascal's triangle as successive antidiagonals. + # If *triangular* is 1, constructs the upper triangular matrix with + # the rows of Pascal's triangle as columns, and if *triangular* is -1, + # constructs the lower triangular matrix with the rows of Pascal's + # triangle as rows. + + void ca_mat_stirling(ca_mat_t mat, int kind, ca_ctx_t ctx) + # Sets *mat* to a Stirling matrix, whose entries are Stirling numbers. + # If *kind* is 0, the entries are set to the unsigned Stirling numbers + # of the first kind. If *kind* is 1, the entries are set to the signed + # Stirling numbers of the first kind. If *kind* is 2, the entries are + # set to the Stirling numbers of the second kind. + + void ca_mat_hilbert(ca_mat_t mat, ca_ctx_t ctx) + # Sets *mat* to the Hilbert matrix, which has entries `A_{i,j} = 1/(i+j+1)`. + + void ca_mat_dft(ca_mat_t mat, int type, ca_ctx_t ctx) + # Sets *mat* to the DFT (discrete Fourier transform) matrix of order *n* + # where *n* is the smallest dimension of *mat* (if *mat* is not square, + # the matrix is extended periodically along the larger dimension). + # The *type* parameter selects between four different versions + # of the DFT matrix (in which `\omega = e^{2\pi i/n}`): + # * Type 0 -- entries `A_{j,k} = \omega^{-jk}` + # * Type 1 -- entries `A_{j,k} = \omega^{jk} / n` + # * Type 2 -- entries `A_{j,k} = \omega^{-jk} / \sqrt{n}` + # * Type 3 -- entries `A_{j,k} = \omega^{jk} / \sqrt{n}` + # The type 0 and 1 matrices are inverse pairs, and similarly for the + # type 2 and 3 matrices. + + truth_t ca_mat_check_equal(const ca_mat_t A, const ca_mat_t B, ca_ctx_t ctx) + # Compares *A* and *B* for equality. + + truth_t ca_mat_check_is_zero(const ca_mat_t A, ca_ctx_t ctx) + # Tests if *A* is the zero matrix. + + truth_t ca_mat_check_is_one(const ca_mat_t A, ca_ctx_t ctx) + # Tests if *A* has ones on the main diagonal and zeros elsewhere. + + void ca_mat_transpose(ca_mat_t res, const ca_mat_t A, ca_ctx_t ctx) + # Sets *res* to the transpose of *A*. + + void ca_mat_conj(ca_mat_t res, const ca_mat_t A, ca_ctx_t ctx) + # Sets *res* to the entrywise complex conjugate of *A*. + + void ca_mat_conj_transpose(ca_mat_t res, const ca_mat_t A, ca_ctx_t ctx) + # Sets *res* to the conjugate transpose (Hermitian transpose) of *A*. + + void ca_mat_neg(ca_mat_t res, const ca_mat_t A, ca_ctx_t ctx) + # Sets *res* to the negation of *A*. + + void ca_mat_add(ca_mat_t res, const ca_mat_t A, const ca_mat_t B, ca_ctx_t ctx) + # Sets *res* to the sum of *A* and *B*. + + void ca_mat_sub(ca_mat_t res, const ca_mat_t A, const ca_mat_t B, ca_ctx_t ctx) + # Sets *res* to the difference of *A* and *B*. + + void ca_mat_mul_classical(ca_mat_t res, const ca_mat_t A, const ca_mat_t B, ca_ctx_t ctx) + void ca_mat_mul_same_nf(ca_mat_t res, const ca_mat_t A, const ca_mat_t B, ca_field_t K, ca_ctx_t ctx) + void ca_mat_mul(ca_mat_t res, const ca_mat_t A, const ca_mat_t B, ca_ctx_t ctx) + # Sets *res* to the matrix product of *A* and *B*. + # The *classical* version uses classical multiplication. + # The *same_nf* version assumes (not checked) that both *A* and *B* + # have coefficients in the same simple algebraic number field *K* + # or in `\mathbb{Q}`. + # The default version chooses an algorithm automatically. + + void ca_mat_mul_si(ca_mat_t B, const ca_mat_t A, long c, ca_ctx_t ctx) + void ca_mat_mul_fmpz(ca_mat_t B, const ca_mat_t A, const fmpz_t c, ca_ctx_t ctx) + void ca_mat_mul_fmpq(ca_mat_t B, const ca_mat_t A, const fmpq_t c, ca_ctx_t ctx) + void ca_mat_mul_ca(ca_mat_t B, const ca_mat_t A, const ca_t c, ca_ctx_t ctx) + # Sets *B* to *A* multiplied by the scalar *c*. + + void ca_mat_div_si(ca_mat_t B, const ca_mat_t A, long c, ca_ctx_t ctx) + void ca_mat_div_fmpz(ca_mat_t B, const ca_mat_t A, const fmpz_t c, ca_ctx_t ctx) + void ca_mat_div_fmpq(ca_mat_t B, const ca_mat_t A, const fmpq_t c, ca_ctx_t ctx) + void ca_mat_div_ca(ca_mat_t B, const ca_mat_t A, const ca_t c, ca_ctx_t ctx) + # Sets *B* to *A* divided by the scalar *c*. + + void ca_mat_add_ca(ca_mat_t B, const ca_mat_t A, const ca_t c, ca_ctx_t ctx) + void ca_mat_sub_ca(ca_mat_t B, const ca_mat_t A, const ca_t c, ca_ctx_t ctx) + # Sets *B* to *A* plus or minus the scalar *c* (interpreted as a diagonal matrix). + + void ca_mat_addmul_ca(ca_mat_t B, const ca_mat_t A, const ca_t c, ca_ctx_t ctx) + void ca_mat_submul_ca(ca_mat_t B, const ca_mat_t A, const ca_t c, ca_ctx_t ctx) + # Sets the matrix *B* to *B* plus (or minus) the matrix *A* multiplied by the scalar *c*. + + void ca_mat_sqr(ca_mat_t B, const ca_mat_t A, ca_ctx_t ctx) + # Sets *B* to the square of *A*. + + void ca_mat_pow_ui_binexp(ca_mat_t B, const ca_mat_t A, unsigned long exp, ca_ctx_t ctx) + # Sets *B* to *A* raised to the power *exp*, evaluated using + # binary exponentiation. + + void _ca_mat_ca_poly_evaluate(ca_mat_t res, ca_srcptr poly, long len, const ca_mat_t A, ca_ctx_t ctx) + void ca_mat_ca_poly_evaluate(ca_mat_t res, const ca_poly_t poly, const ca_mat_t A, ca_ctx_t ctx) + # Sets *res* to `f(A)` where *f* is the polynomial given by *poly* + # and *A* is a square matrix. Uses the Paterson-Stockmeyer algorithm. + + truth_t ca_mat_find_pivot(long * pivot_row, ca_mat_t mat, long start_row, long end_row, long column, ca_ctx_t ctx) + # Attempts to find a nonzero entry in *mat* with column index *column* + # and row index between *start_row* (inclusive) and *end_row* (exclusive). + # If the return value is ``T_TRUE``, such an element exists, + # and *pivot_row* is set to the row index. + # If the return value is ``T_FALSE``, no such element exists + # (all entries in this part of the column are zero). + # If the return value is ``T_UNKNOWN``, it is unknown whether such + # an element exists (zero certification failed). + # This function is destructive: any elements that are nontrivially + # zero but can be certified zero will be overwritten by exact zeros. + + int ca_mat_lu_classical(long * rank, long * P, ca_mat_t LU, const ca_mat_t A, int rank_check, ca_ctx_t ctx) + int ca_mat_lu_recursive(long * rank, long * P, ca_mat_t LU, const ca_mat_t A, int rank_check, ca_ctx_t ctx) + int ca_mat_lu(long * rank, long * P, ca_mat_t LU, const ca_mat_t A, int rank_check, ca_ctx_t ctx) + # Computes a generalized LU decomposition `A = PLU` of a given + # matrix *A*, writing the rank of *A* to *rank*. + # If *A* is a nonsingular square matrix, *LU* will be set to + # a unit diagonal lower triangular matrix *L* and an upper + # triangular matrix *U* (the diagonal of *L* will not be stored + # explicitly). + # If *A* is an arbitrary matrix of rank *r*, *U* will be in row + # echelon form having *r* nonzero rows, and *L* will be lower + # triangular but truncated to *r* columns, having implicit ones on + # the *r* first entries of the main diagonal. All other entries will + # be zero. + # If a nonzero value for ``rank_check`` is passed, the function + # will abandon the output matrix in an undefined state and set + # the rank to 0 if *A* is detected to be rank-deficient. + # The algorithm can fail if it fails to certify that a pivot + # element is zero or nonzero, in which case the correct rank + # cannot be determined. + # The return value is 1 on success and 0 on failure. On failure, + # the data in the output variables + # ``rank``, ``P`` and ``LU`` will be meaningless. + # The *classical* version uses iterative Gaussian elimination. + # The *recursive* version uses a block recursive algorithm + # to take advantage of fast matrix multiplication. + + int ca_mat_fflu(long * rank, long * P, ca_mat_t LU, ca_t den, const ca_mat_t A, int rank_check, ca_ctx_t ctx) + # Similar to :func:`ca_mat_lu`, but computes a fraction-free + # LU decomposition using the Bareiss algorithm. + # The denominator is written to *den*. + # Note that despite being "fraction-free", this algorithm may + # introduce fractions due to incomplete symbolic simplifications. + + truth_t ca_mat_nonsingular_lu(long * P, ca_mat_t LU, const ca_mat_t A, ca_ctx_t ctx) + # Wrapper for :func:`ca_mat_lu`. + # If *A* can be proved to be invertible/nonsingular, returns ``T_TRUE`` and sets *P* and *LU* to a LU decomposition `A = PLU`. + # If *A* can be proved to be singular, returns ``T_FALSE``. + # If *A* cannot be proved to be either singular or nonsingular, returns ``T_UNKNOWN``. + # When the return value is ``T_FALSE`` or ``T_UNKNOWN``, the + # LU factorization is not completed and the values of + # *P* and *LU* are arbitrary. + + truth_t ca_mat_nonsingular_fflu(long * P, ca_mat_t LU, ca_t den, const ca_mat_t A, ca_ctx_t ctx) + # Wrapper for :func:`ca_mat_fflu`. + # Similar to :func:`ca_mat_nonsingular_lu`, but computes a fraction-free + # LU decomposition using the Bareiss algorithm. + # The denominator is written to *den*. + # Note that despite being "fraction-free", this algorithm may + # introduce fractions due to incomplete symbolic simplifications. + + truth_t ca_mat_inv(ca_mat_t X, const ca_mat_t A, ca_ctx_t ctx) + # Determines if the square matrix *A* is nonsingular, and if successful, + # sets `X = A^{-1}` and returns ``T_TRUE``. + # Returns ``T_FALSE`` if *A* is singular, and ``T_UNKNOWN`` if the + # rank of *A* cannot be determined. + + truth_t ca_mat_nonsingular_solve_adjugate(ca_mat_t X, const ca_mat_t A, const ca_mat_t B, ca_ctx_t ctx) + truth_t ca_mat_nonsingular_solve_fflu(ca_mat_t X, const ca_mat_t A, const ca_mat_t B, ca_ctx_t ctx) + truth_t ca_mat_nonsingular_solve_lu(ca_mat_t X, const ca_mat_t A, const ca_mat_t B, ca_ctx_t ctx) + truth_t ca_mat_nonsingular_solve(ca_mat_t X, const ca_mat_t A, const ca_mat_t B, ca_ctx_t ctx) + # Determines if the square matrix *A* is nonsingular, and if successful, + # solves `AX = B` and returns ``T_TRUE``. + # Returns ``T_FALSE`` if *A* is singular, and ``T_UNKNOWN`` if the + # rank of *A* cannot be determined. + + void ca_mat_solve_tril_classical(ca_mat_t X, const ca_mat_t L, const ca_mat_t B, int unit, ca_ctx_t ctx) + void ca_mat_solve_tril_recursive(ca_mat_t X, const ca_mat_t L, const ca_mat_t B, int unit, ca_ctx_t ctx) + void ca_mat_solve_tril(ca_mat_t X, const ca_mat_t L, const ca_mat_t B, int unit, ca_ctx_t ctx) + void ca_mat_solve_triu_classical(ca_mat_t X, const ca_mat_t U, const ca_mat_t B, int unit, ca_ctx_t ctx) + void ca_mat_solve_triu_recursive(ca_mat_t X, const ca_mat_t U, const ca_mat_t B, int unit, ca_ctx_t ctx) + void ca_mat_solve_triu(ca_mat_t X, const ca_mat_t U, const ca_mat_t B, int unit, ca_ctx_t ctx) + # Solves the lower triangular system `LX = B` or the upper triangular system + # `UX = B`, respectively. It is assumed (not checked) that the diagonal + # entries are nonzero. If *unit* is set, the main diagonal of *L* or *U* + # is taken to consist of all ones, and in that case the actual entries on + # the diagonal are not read at all and can contain other data. + # The *classical* versions perform the computations iteratively while the + # *recursive* versions perform the computations in a block recursive + # way to benefit from fast matrix multiplication. The default versions + # choose an algorithm automatically. + + void ca_mat_solve_fflu_precomp(ca_mat_t X, const long * perm, const ca_mat_t A, const ca_t den, const ca_mat_t B, ca_ctx_t ctx) + void ca_mat_solve_lu_precomp(ca_mat_t X, const long * P, const ca_mat_t LU, const ca_mat_t B, ca_ctx_t ctx) + # Solves `AX = B` given the precomputed nonsingular LU decomposition `A = PLU` + # or fraction-free LU decomposition with denominator *den*. + # The matrices `X` and `B` are allowed to be aliased with each other, + # but `X` is not allowed to be aliased with `LU`. + + int ca_mat_rank(long * rank, const ca_mat_t A, ca_ctx_t ctx) + # Computes the rank of the matrix *A*. If successful, returns 1 and + # writes the rank to ``rank``. If unsuccessful, returns 0. + + int ca_mat_rref_fflu(long * rank, ca_mat_t R, const ca_mat_t A, ca_ctx_t ctx) + int ca_mat_rref_lu(long * rank, ca_mat_t R, const ca_mat_t A, ca_ctx_t ctx) + int ca_mat_rref(long * rank, ca_mat_t R, const ca_mat_t A, ca_ctx_t ctx) + # Computes the reduced row echelon form (rref) of a given matrix. + # On success, sets *R* to the rref of *A*, writes the rank to + # *rank*, and returns 1. On failure to certify the correct rank, + # returns 0, leaving the data in *rank* and *R* meaningless. + # The *fflu* version computes a fraction-free LU decomposition and + # then converts the output ro rref form. The *lu* version computes a + # regular LU decomposition and then converts the output to rref form. + # The default version uses an automatic algorithm choice and may + # implement additional methods for special cases. + + int ca_mat_right_kernel(ca_mat_t X, const ca_mat_t A, ca_ctx_t ctx) + # Sets *X* to a basis of the right kernel (nullspace) of *A*. + # The output matrix *X* will be resized in-place to have a number + # of columns equal to the nullity of *A*. + # Returns 1 on success. On failure, returns 0 and leaves the data + # in *X* meaningless. + + void ca_mat_trace(ca_t trace, const ca_mat_t mat, ca_ctx_t ctx) + # Sets *trace* to the sum of the entries on the main diagonal of *mat*. + + void ca_mat_det_berkowitz(ca_t det, const ca_mat_t A, ca_ctx_t ctx) + int ca_mat_det_lu(ca_t det, const ca_mat_t A, ca_ctx_t ctx) + int ca_mat_det_bareiss(ca_t det, const ca_mat_t A, ca_ctx_t ctx) + void ca_mat_det_cofactor(ca_t det, const ca_mat_t A, ca_ctx_t ctx) + void ca_mat_det(ca_t det, const ca_mat_t A, ca_ctx_t ctx) + # Sets *det* to the determinant of the square matrix *A*. + # Various algorithms are available: + # * The *berkowitz* version uses the division-free Berkowitz algorithm + # performing `O(n^4)` operations. Since no zero tests are required, it + # is guaranteed to succeed. + # * The *cofactor* version performs cofactor expansion. This is currently + # only supported for matrices up to size 4. + # * The *lu* and *bareiss* versions use rational LU decomposition + # and fraction-free LU decomposition (Bareiss algorithm) respectively, + # requiring `O(n^3)` operations. These algorithms can fail if zero + # certification fails (see :func:`ca_mat_nonsingular_lu`); they + # return 1 for success and 0 for failure. + # Note that the Bareiss algorithm, despite being "fraction-free", + # may introduce fractions due to incomplete symbolic simplifications. + # The default function chooses an algorithm automatically. + # It will, in addition, recognize trivially rational and integer + # matrices and evaluate those determinants using + # :type:`fmpq_mat_t` or :type:`fmpz_mat_t`. + # The various algorithms can produce different symbolic + # forms of the same determinant. Which algorithm performs better + # depends strongly and sometimes + # unpredictably on the structure of the matrix. + + void ca_mat_adjugate_cofactor(ca_mat_t adj, ca_t det, const ca_mat_t A, ca_ctx_t ctx) + void ca_mat_adjugate_charpoly(ca_mat_t adj, ca_t det, const ca_mat_t A, ca_ctx_t ctx) + void ca_mat_adjugate(ca_mat_t adj, ca_t det, const ca_mat_t A, ca_ctx_t ctx) + # Sets *adj* to the adjuate matrix of *A* and *det* to the determinant + # of *A*, both computed simultaneously. + # The *cofactor* version uses cofactor expansion. + # The *charpoly* version computes and + # evaluates the characteristic polynomial. + # The default version uses an automatic algorithm choice. + + void _ca_mat_charpoly_berkowitz(ca_ptr cp, const ca_mat_t mat, ca_ctx_t ctx) + void ca_mat_charpoly_berkowitz(ca_poly_t cp, const ca_mat_t mat, ca_ctx_t ctx) + int _ca_mat_charpoly_danilevsky(ca_ptr cp, const ca_mat_t mat, ca_ctx_t ctx) + int ca_mat_charpoly_danilevsky(ca_poly_t cp, const ca_mat_t mat, ca_ctx_t ctx) + void _ca_mat_charpoly(ca_ptr cp, const ca_mat_t mat, ca_ctx_t ctx) + void ca_mat_charpoly(ca_poly_t cp, const ca_mat_t mat, ca_ctx_t ctx) + # Sets *poly* to the characteristic polynomial of *mat* which must be + # a square matrix. If the matrix has *n* rows, the underscore method + # requires space for `n + 1` output coefficients. + # The *berkowitz* version uses a division-free algorithm + # requiring `O(n^4)` operations. + # The *danilevsky* version only performs `O(n^3)` operations, but + # performs divisions and needs to check for zero which can fail. + # This version returns 1 on success and 0 on failure. + # The default version chooses an algorithm automatically. + + int ca_mat_companion(ca_mat_t mat, const ca_poly_t poly, ca_ctx_t ctx) + # Sets *mat* to the companion matrix of *poly*. + # This function verifies that the leading coefficient of *poly* + # is provably nonzero and that the output matrix has the right size, + # returning 1 on success. + # It returns 0 if the leading coefficient of *poly* cannot be + # proved nonzero or if the size of the output matrix does not match. + + int ca_mat_eigenvalues(ca_vec_t lambda, unsigned long * exp, const ca_mat_t mat, ca_ctx_t ctx) + # Attempts to compute all complex eigenvalues of the given matrix *mat*. + # On success, returns 1 and sets *lambda* to the distinct eigenvalues + # with corresponding multiplicities in *exp*. + # The eigenvalues are returned in arbitrary order. + # On failure, returns 0 and leaves the values in *lambda* and *exp* + # arbitrary. + # This function effectively computes the characteristic polynomial + # and then calls :type:`ca_poly_roots`. + + truth_t ca_mat_diagonalization(ca_mat_t D, ca_mat_t P, const ca_mat_t A, ca_ctx_t ctx) + # Matrix diagonalization: attempts to compute a diagonal matrix *D* + # and an invertible matrix *P* such that `A = PDP^{-1}`. + # Returns ``T_TRUE`` if *A* is diagonalizable and the computation + # succeeds, ``T_FALSE`` if *A* is provably not diagonalizable, + # and ``T_UNKNOWN`` if it is unknown whether *A* is diagonalizable. + # If the return value is not ``T_TRUE``, the values in *D* and *P* + # are arbitrary. + + int ca_mat_jordan_blocks(ca_vec_t lambda, long * num_blocks, long * block_lambda, long * block_size, const ca_mat_t A, ca_ctx_t ctx) + # Computes the blocks of the Jordan canonical form of *A*. + # On success, returns 1 and sets *lambda* to the unique eigenvalues + # of *A*, sets *num_blocks* to the number of Jordan blocks, + # entry *i* of *block_lambda* to the index of the eigenvalue + # in Jordan block *i*, and entry *i* of *block_size* to the size + # of Jordan block *i*. On failure, returns 0, leaving arbitrary + # values in the output variables. + # The user should allocate space in *block_lambda* and *block_size* + # for up to *n* entries where *n* is the size of the matrix. + # The Jordan form is unique up to the ordering of blocks, which + # is arbitrary. + + void ca_mat_set_jordan_blocks(ca_mat_t mat, const ca_vec_t lambda, long num_blocks, long * block_lambda, long * block_size, ca_ctx_t ctx) + # Sets *mat* to the concatenation of the Jordan blocks + # given in *lambda*, *num_blocks*, *block_lambda* and *block_size*. + # See :func:`ca_mat_jordan_blocks` for an explanation of these + # variables. + + int ca_mat_jordan_transformation(ca_mat_t mat, const ca_vec_t lambda, long num_blocks, long * block_lambda, long * block_size, const ca_mat_t A, ca_ctx_t ctx) + # Given the precomputed Jordan block decomposition + # (*lambda*, *num_blocks*, *block_lambda*, *block_size*) of the + # square matrix *A*, computes the corresponding transformation + # matrix *P* such that `A = P J P^{-1}`. + # On success, writes *P* to *mat* and returns 1. On failure, + # returns 0, leaving the value of *mat* arbitrary. + + int ca_mat_jordan_form(ca_mat_t J, ca_mat_t P, const ca_mat_t A, ca_ctx_t ctx) + # Computes the Jordan decomposition `A = P J P^{-1}` of the given + # square matrix *A*. The user can pass *NULL* for the output + # variable *P*, in which case only *J* is computed. + # On success, returns 1. On failure, returns 0, leaving the values + # of *J* and *P* arbitrary. + # This function is a convenience wrapper around + # :func:`ca_mat_jordan_blocks`, :func:`ca_mat_set_jordan_blocks` and + # :func:`ca_mat_jordan_transformation`. For computations with + # the Jordan decomposition, it is often better to use those + # methods directly since they give direct access to the + # spectrum and block structure. + + int ca_mat_exp(ca_mat_t res, const ca_mat_t A, ca_ctx_t ctx) + # Matrix exponential: given a square matrix *A*, sets *res* to + # `e^A` and returns 1 on success. If unsuccessful, returns 0, + # leaving the values in *res* arbitrary. + # This function uses Jordan decomposition. The matrix exponential + # always exists, but computation can fail if computing the Jordan + # decomposition fails. + + truth_t ca_mat_log(ca_mat_t res, const ca_mat_t A, ca_ctx_t ctx) + # Matrix logarithm: given a square matrix *A*, sets *res* to a + # logarithm `\log(A)` and returns ``T_TRUE`` on success. + # If *A* can be proved to have no logarithm, returns ``T_FALSE``. + # If the existence of a logarithm cannot be proved, returns + # ``T_UNKNOWN``. + # This function uses the Jordan decomposition, and the branch of + # the matrix logarithm is defined by taking the principal values + # of the logarithms of all eigenvalues. diff --git a/src/sage/libs/flint/ca_poly.pxd b/src/sage/libs/flint/ca_poly.pxd new file mode 100644 index 00000000000..1a0846bdea6 --- /dev/null +++ b/src/sage/libs/flint/ca_poly.pxd @@ -0,0 +1,274 @@ +# distutils: libraries = flint +# distutils: depends = flint/ca_poly.h + +################################################################################ +# This file is auto-generated. Do not modify by hand +################################################################################ + +from libc.stdio cimport FILE +from sage.libs.gmp.types cimport * +from sage.libs.mpfr.types cimport * +from sage.libs.flint.types cimport * + +cdef extern from "flint_wrap.h": + + void ca_poly_init(ca_poly_t poly, ca_ctx_t ctx) + # Initializes the polynomial for use, setting it to the zero polynomial. + + void ca_poly_clear(ca_poly_t poly, ca_ctx_t ctx) + # Clears the polynomial, deallocating all coefficients and the + # coefficient array. + + void ca_poly_fit_length(ca_poly_t poly, long len, ca_ctx_t ctx) + # Makes sure that the coefficient array of the polynomial contains at + # least *len* initialized coefficients. + + void _ca_poly_set_length(ca_poly_t poly, long len, ca_ctx_t ctx) + # Directly changes the length of the polynomial, without allocating or + # deallocating coefficients. The value should not exceed the allocation length. + + void _ca_poly_normalise(ca_poly_t poly, ca_ctx_t ctx) + # Strips any top coefficients which can be proved identical to zero. + + void ca_poly_zero(ca_poly_t poly, ca_ctx_t ctx) + # Sets *poly* to the zero polynomial. + + void ca_poly_one(ca_poly_t poly, ca_ctx_t ctx) + # Sets *poly* to the constant polynomial 1. + + void ca_poly_x(ca_poly_t poly, ca_ctx_t ctx) + # Sets *poly* to the monomial *x*. + + void ca_poly_set_ca(ca_poly_t poly, const ca_t c, ca_ctx_t ctx) + void ca_poly_set_si(ca_poly_t poly, long c, ca_ctx_t ctx) + # Sets *poly* to the constant polynomial *c*. + + void ca_poly_set(ca_poly_t res, const ca_poly_t src, ca_ctx_t ctx) + void ca_poly_set_fmpz_poly(ca_poly_t res, const fmpz_poly_t src, ca_ctx_t ctx) + void ca_poly_set_fmpq_poly(ca_poly_t res, const fmpq_poly_t src, ca_ctx_t ctx) + # Sets *poly* the polynomial *src*. + + void ca_poly_set_coeff_ca(ca_poly_t poly, long n, const ca_t x, ca_ctx_t ctx) + # Sets the coefficient at position *n* in *poly* to *x*. + + void ca_poly_transfer(ca_poly_t res, ca_ctx_t res_ctx, const ca_poly_t src, ca_ctx_t src_ctx) + # Sets *res* to *src* where the corresponding context objects *res_ctx* and + # *src_ctx* may be different. + # This operation preserves the mathematical value represented by *src*, + # but may result in a different internal representation depending on the + # settings of the context objects. + + void ca_poly_randtest(ca_poly_t poly, flint_rand_t state, long len, long depth, long bits, ca_ctx_t ctx) + # Sets *poly* to a random polynomial of length up to *len* and with entries having complexity up to + # *depth* and *bits* (see :func:`ca_randtest`). + + void ca_poly_randtest_rational(ca_poly_t poly, flint_rand_t state, long len, long bits, ca_ctx_t ctx) + # Sets *poly* to a random rational polynomial of length up to *len* and with entries up to *bits* bits in size. + + void ca_poly_print(const ca_poly_t poly, ca_ctx_t ctx) + # Prints *poly* to standard output. The coefficients are printed on separate lines. + + void ca_poly_printn(const ca_poly_t poly, long digits, ca_ctx_t ctx) + # Prints a decimal representation of *poly* with precision specified by *digits*. + # The coefficients are comma-separated and the whole list is enclosed in square brackets. + + int ca_poly_is_proper(const ca_poly_t poly, ca_ctx_t ctx) + # Checks that *poly* represents an element of `\mathbb{C}[X]` with + # well-defined degree. This returns 1 if the leading coefficient + # of *poly* is nonzero and all coefficients of *poly* are + # numbers (not special values). It returns 0 otherwise. + # It returns 1 when *poly* is precisely the zero polynomial (which + # does not have a leading coefficient). + + int ca_poly_make_monic(ca_poly_t res, const ca_poly_t poly, ca_ctx_t ctx) + # Makes *poly* monic by dividing by the leading coefficient if possible + # and returns 1. Returns 0 if the leading coefficient cannot be + # certified to be nonzero, or if *poly* is the zero polynomial. + + void _ca_poly_reverse(ca_ptr res, ca_srcptr poly, long len, long n, ca_ctx_t ctx) + + void ca_poly_reverse(ca_poly_t res, const ca_poly_t poly, long n, ca_ctx_t ctx) + # Sets *res* to the reversal of *poly* considered as a polynomial + # of length *n*, zero-padding if needed. The underscore method + # assumes that *len* is positive and less than or equal to *n*. + + truth_t _ca_poly_check_equal(ca_srcptr poly1, long len1, ca_srcptr poly2, long len2, ca_ctx_t ctx) + truth_t ca_poly_check_equal(const ca_poly_t poly1, const ca_poly_t poly2, ca_ctx_t ctx) + # Checks if *poly1* and *poly2* represent the same polynomial. + # The underscore method assumes that *len1* is at least as + # large as *len2*. + + truth_t ca_poly_check_is_zero(const ca_poly_t poly, ca_ctx_t ctx) + # Checks if *poly* is the zero polynomial. + + truth_t ca_poly_check_is_one(const ca_poly_t poly, ca_ctx_t ctx) + # Checks if *poly* is the constant polynomial 1. + + void _ca_poly_shift_left(ca_ptr res, ca_srcptr poly, long len, long n, ca_ctx_t ctx) + void ca_poly_shift_left(ca_poly_t res, const ca_poly_t poly, long n, ca_ctx_t ctx) + # Sets *res* to *poly* shifted *n* coefficients to the left; that is, + # multiplied by `x^n`. + + void _ca_poly_shift_right(ca_ptr res, ca_srcptr poly, long len, long n, ca_ctx_t ctx) + void ca_poly_shift_right(ca_poly_t res, const ca_poly_t poly, long n, ca_ctx_t ctx) + # Sets *res* to *poly* shifted *n* coefficients to the right; that is, + # divided by `x^n`. + + void ca_poly_neg(ca_poly_t res, const ca_poly_t src, ca_ctx_t ctx) + # Sets *res* to the negation of *src*. + + void _ca_poly_add(ca_ptr res, ca_srcptr poly1, long len1, ca_srcptr poly2, long len2, ca_ctx_t ctx) + void ca_poly_add(ca_poly_t res, const ca_poly_t poly1, const ca_poly_t poly2, ca_ctx_t ctx) + # Sets *res* to the sum of *poly1* and *poly2*. + + void _ca_poly_sub(ca_ptr res, ca_srcptr poly1, long len1, ca_srcptr poly2, long len2, ca_ctx_t ctx) + void ca_poly_sub(ca_poly_t res, const ca_poly_t poly1, const ca_poly_t poly2, ca_ctx_t ctx) + # Sets *res* to the difference of *poly1* and *poly2*. + + void _ca_poly_mul(ca_ptr res, ca_srcptr poly1, long len1, ca_srcptr poly2, long len2, ca_ctx_t ctx) + void ca_poly_mul(ca_poly_t res, const ca_poly_t poly1, const ca_poly_t poly2, ca_ctx_t ctx) + # Sets *res* to the product of *poly1* and *poly2*. + + void _ca_poly_mullow(ca_ptr C, ca_srcptr poly1, long len1, ca_srcptr poly2, long len2, long n, ca_ctx_t ctx) + void ca_poly_mullow(ca_poly_t res, const ca_poly_t poly1, const ca_poly_t poly2, long n, ca_ctx_t ctx) + # Sets *res* to the product of *poly1* and *poly2* truncated to length *n*. + + void ca_poly_mul_ca(ca_poly_t res, const ca_poly_t poly, const ca_t c, ca_ctx_t ctx) + # Sets *res* to *poly* multiplied by the scalar *c*. + + void ca_poly_div_ca(ca_poly_t res, const ca_poly_t poly, const ca_t c, ca_ctx_t ctx) + # Sets *res* to *poly* divided by the scalar *c*. + + void _ca_poly_divrem_basecase(ca_ptr Q, ca_ptr R, ca_srcptr A, long lenA, ca_srcptr B, long lenB, const ca_t invB, ca_ctx_t ctx) + int ca_poly_divrem_basecase(ca_poly_t Q, ca_poly_t R, const ca_poly_t A, const ca_poly_t B, ca_ctx_t ctx) + void _ca_poly_divrem(ca_ptr Q, ca_ptr R, ca_srcptr A, long lenA, ca_srcptr B, long lenB, const ca_t invB, ca_ctx_t ctx) + int ca_poly_divrem(ca_poly_t Q, ca_poly_t R, const ca_poly_t A, const ca_poly_t B, ca_ctx_t ctx) + int ca_poly_div(ca_poly_t Q, const ca_poly_t A, const ca_poly_t B, ca_ctx_t ctx) + int ca_poly_rem(ca_poly_t R, const ca_poly_t A, const ca_poly_t B, ca_ctx_t ctx) + # If the leading coefficient of *B* can be proved invertible, sets *Q* and *R* + # to the quotient and remainder of polynomial division of *A* by *B* + # and returns 1. If the leading coefficient cannot be proved + # invertible, returns 0. + # The underscore method takes a precomputed inverse of the leading coefficient of *B*. + + void _ca_poly_pow_ui_trunc(ca_ptr res, ca_srcptr f, long flen, unsigned long exp, long len, ca_ctx_t ctx) + void ca_poly_pow_ui_trunc(ca_poly_t res, const ca_poly_t poly, unsigned long exp, long len, ca_ctx_t ctx) + # Sets *res* to *poly* raised to the power *exp*, truncated to length *len*. + + void _ca_poly_pow_ui(ca_ptr res, ca_srcptr f, long flen, unsigned long exp, ca_ctx_t ctx) + void ca_poly_pow_ui(ca_poly_t res, const ca_poly_t poly, unsigned long exp, ca_ctx_t ctx) + # Sets *res* to *poly* raised to the power *exp*. + + void _ca_poly_evaluate_horner(ca_t res, ca_srcptr f, long len, const ca_t x, ca_ctx_t ctx) + void ca_poly_evaluate_horner(ca_t res, const ca_poly_t f, const ca_t a, ca_ctx_t ctx) + void _ca_poly_evaluate(ca_t res, ca_srcptr f, long len, const ca_t x, ca_ctx_t ctx) + void ca_poly_evaluate(ca_t res, const ca_poly_t f, const ca_t a, ca_ctx_t ctx) + # Sets *res* to *f* evaluated at the point *a*. + + void _ca_poly_compose(ca_ptr res, ca_srcptr poly1, long len1, ca_srcptr poly2, long len2, ca_ctx_t ctx) + void ca_poly_compose(ca_poly_t res, const ca_poly_t poly1, const ca_poly_t poly2, ca_ctx_t ctx) + # Sets *res* to the composition of *poly1* with *poly2*. + + void _ca_poly_derivative(ca_ptr res, ca_srcptr poly, long len, ca_ctx_t ctx) + void ca_poly_derivative(ca_poly_t res, const ca_poly_t poly, ca_ctx_t ctx) + # Sets *res* to the derivative of *poly*. The underscore method needs one less + # coefficient than *len* for the output array. + + void _ca_poly_integral(ca_ptr res, ca_srcptr poly, long len, ca_ctx_t ctx) + void ca_poly_integral(ca_poly_t res, const ca_poly_t poly, ca_ctx_t ctx) + # Sets *res* to the integral of *poly*. The underscore method needs one more + # coefficient than *len* for the output array. + + void _ca_poly_inv_series(ca_ptr res, ca_srcptr f, long flen, long len, ca_ctx_t ctx) + void ca_poly_inv_series(ca_poly_t res, const ca_poly_t f, long len, ca_ctx_t ctx) + # Sets *res* to the power series inverse of *f* truncated + # to length *len*. + + void _ca_poly_div_series(ca_ptr res, ca_srcptr f, long flen, ca_srcptr g, long glen, long len, ca_ctx_t ctx) + void ca_poly_div_series(ca_poly_t res, const ca_poly_t f, const ca_poly_t g, long len, ca_ctx_t ctx) + # Sets *res* to the power series quotient of *f* and *g* truncated + # to length *len*. + # This function divides by zero if *g* has constant term zero; + # the user should manually remove initial zeros when an + # exact cancellation is required. + + void _ca_poly_exp_series(ca_ptr res, ca_srcptr f, long flen, long len, ca_ctx_t ctx) + void ca_poly_exp_series(ca_poly_t res, const ca_poly_t f, long len, ca_ctx_t ctx) + # Sets *res* to the power series exponential of *f* truncated + # to length *len*. + + void _ca_poly_log_series(ca_ptr res, ca_srcptr f, long flen, long len, ca_ctx_t ctx) + void ca_poly_log_series(ca_poly_t res, const ca_poly_t f, long len, ca_ctx_t ctx) + # Sets *res* to the power series logarithm of *f* truncated + # to length *len*. + + long _ca_poly_gcd_euclidean(ca_ptr res, ca_srcptr A, long lenA, ca_srcptr B, long lenB, ca_ctx_t ctx) + int ca_poly_gcd_euclidean(ca_poly_t res, const ca_poly_t A, const ca_poly_t B, ca_ctx_t ctx) + long _ca_poly_gcd(ca_ptr res, ca_srcptr A, long lenA, ca_srcptr B, long lenB, ca_ctx_t ctx) + int ca_poly_gcd(ca_poly_t res, const ca_poly_t A, const ca_poly_t g, ca_ctx_t ctx) + # Sets *res* to the GCD of *A* and *B* and returns 1 on success. + # On failure, returns 0 leaving the value of *res* arbitrary. + # The computation can fail if testing a leading coefficient + # for zero fails in the execution of the GCD algorithm. + # The output is normalized to be monic if it is not the zero polynomial. + # The underscore methods assume `\text{lenA} \ge \text{lenB} \ge 1`, and that + # both *A* and *B* have nonzero leading coefficient. + # They return the length of the GCD, or 0 if the computation fails. + # The *euclidean* version implements the standard Euclidean algorithm. + # The default version first checks for rational polynomials or + # attempts to certify numerically that the polynomials are coprime + # and otherwise falls back to an automatic choice + # of algorithm (currently only the Euclidean algorithm). + + int ca_poly_factor_squarefree(ca_t c, ca_poly_vec_t fac, unsigned long * exp, const ca_poly_t F, ca_ctx_t ctx) + # Computes the squarefree factorization of *F*, giving a product + # `F = c f_1 f_2^2 \ldots f_n^n` where all `f_i` with `f_i \ne 1` + # are squarefree and pairwise coprime. The nontrivial factors + # `f_i` are written to *fac* and the corresponding exponents + # are written to *exp*. This algorithm can fail if GCD computation + # fails internally. Returns 1 on success and 0 on failure. + + int ca_poly_squarefree_part(ca_poly_t res, const ca_poly_t poly, ca_ctx_t ctx) + # Sets *res* to the squarefree part of *poly*, normalized to be monic. + # This algorithm can fail if GCD computation fails internally. + # Returns 1 on success and 0 on failure. + + void _ca_poly_set_roots(ca_ptr poly, ca_srcptr roots, const unsigned long * exp, long n, ca_ctx_t ctx) + void ca_poly_set_roots(ca_poly_t poly, ca_vec_t roots, const unsigned long * exp, ca_ctx_t ctx) + # Sets *poly* to the monic polynomial with the *n* roots + # given in the vector *roots*, with multiplicities given + # in the vector *exp*. In other words, this constructs + # the polynomial + # `(x-r_0)^{e_0} (x-r_1)^{e_1} \cdots (x-r_{n-1})^{e_{n-1}}`. + # Uses binary splitting. + + int _ca_poly_roots(ca_ptr roots, ca_srcptr poly, long len, ca_ctx_t ctx) + int ca_poly_roots(ca_vec_t roots, unsigned long * exp, const ca_poly_t poly, ca_ctx_t ctx) + # Attempts to compute all complex roots of the given polynomial *poly*. + # On success, returns 1 and sets *roots* to a vector containing all + # the distinct roots with corresponding multiplicities in *exp*. + # On failure, returns 0 and leaves the values in *roots* arbitrary. + # The roots are returned in arbitrary order. + # Failure will occur if the leading coefficient of *poly* cannot + # be proved to be nonzero, if determining the correct multiplicities + # fails, or if the builtin algorithms do not have a means to + # represent the roots symbolically. + # The underscore method assumes that the polynomial is squarefree. + # The non-underscore method performs a squarefree factorization. + + ca_poly_struct * _ca_poly_vec_init(long len, ca_ctx_t ctx) + void ca_poly_vec_init(ca_poly_vec_t res, long len, ca_ctx_t ctx) + # Initializes a vector with *len* polynomials. + + void _ca_poly_vec_fit_length(ca_poly_vec_t vec, long len, ca_ctx_t ctx) + # Allocates space for *len* polynomials in *vec*. + + void ca_poly_vec_set_length(ca_poly_vec_t vec, long len, ca_ctx_t ctx) + # Resizes *vec* to length *len*, zero-extending if needed. + + void _ca_poly_vec_clear(ca_poly_struct * vec, long len, ca_ctx_t ctx) + void ca_poly_vec_clear(ca_poly_vec_t vec, ca_ctx_t ctx) + # Clears the vector *vec*. + + void ca_poly_vec_append(ca_poly_vec_t vec, const ca_poly_t poly, ca_ctx_t ctx) + # Appends *poly* to the end of the vector *vec*. diff --git a/src/sage/libs/flint/ca_vec.pxd b/src/sage/libs/flint/ca_vec.pxd new file mode 100644 index 00000000000..6f756b25f70 --- /dev/null +++ b/src/sage/libs/flint/ca_vec.pxd @@ -0,0 +1,113 @@ +# distutils: libraries = flint +# distutils: depends = flint/ca_vec.h + +################################################################################ +# This file is auto-generated. Do not modify by hand +################################################################################ + +from libc.stdio cimport FILE +from sage.libs.gmp.types cimport * +from sage.libs.mpfr.types cimport * +from sage.libs.flint.types cimport * + +cdef extern from "flint_wrap.h": + + ca_ptr _ca_vec_init(long len, ca_ctx_t ctx) + # Returns a pointer to an array of *len* coefficients + # initialized to zero. + + void ca_vec_init(ca_vec_t vec, long len, ca_ctx_t ctx) + # Initializes *vec* to a length *len* vector. All entries + # are set to zero. + + void _ca_vec_clear(ca_ptr vec, long len, ca_ctx_t ctx) + # Clears all *len* entries in *vec* and frees the pointer + # *vec* itself. + + void ca_vec_clear(ca_vec_t vec, ca_ctx_t ctx) + # Clears the vector *vec*. + + void _ca_vec_swap(ca_ptr vec1, ca_ptr vec2, long len, ca_ctx_t ctx) + # Swaps the entries in *vec1* and *vec2* efficiently. + + void ca_vec_swap(ca_vec_t vec1, ca_vec_t vec2, ca_ctx_t ctx) + # Swaps the vectors *vec1* and *vec2* efficiently. + + long ca_vec_length(const ca_vec_t vec, ca_ctx_t ctx) + # Returns the length of *vec*. + + void _ca_vec_fit_length(ca_vec_t vec, long len, ca_ctx_t ctx) + # Allocates space in *vec* for *len* elements. + + void ca_vec_set_length(ca_vec_t vec, long len, ca_ctx_t ctx) + # Sets the length of *vec* to *len*. + # If *vec* is shorter on input, it will be zero-extended. + # If *vec* is longer on input, it will be truncated. + + void _ca_vec_set(ca_ptr res, ca_srcptr src, long len, ca_ctx_t ctx) + # Sets *res* to a copy of *src* of length *len*. + + void ca_vec_set(ca_vec_t res, const ca_vec_t src, ca_ctx_t ctx) + # Sets *res* to a copy of *src*. + + void _ca_vec_zero(ca_ptr res, long len, ca_ctx_t ctx) + # Sets the *len* entries in *res* to zeros. + + void ca_vec_zero(ca_vec_t res, long len, ca_ctx_t ctx) + # Sets *res* to the length *len* zero vector. + + void ca_vec_print(const ca_vec_t vec, ca_ctx_t ctx) + # Prints *vec* to standard output. The coefficients are printed on separate lines. + + void ca_vec_printn(const ca_vec_t poly, long digits, ca_ctx_t ctx) + # Prints a decimal representation of *vec* with precision specified by *digits*. + # The coefficients are comma-separated and the whole list is enclosed in square brackets. + + void ca_vec_append(ca_vec_t vec, const ca_t f, ca_ctx_t ctx) + # Appends *f* to the end of *vec*. + + void _ca_vec_neg(ca_ptr res, ca_srcptr src, long len, ca_ctx_t ctx) + + void ca_vec_neg(ca_vec_t res, const ca_vec_t src, ca_ctx_t ctx) + # Sets *res* to the negation of *src*. + + void _ca_vec_add(ca_ptr res, ca_srcptr vec1, ca_srcptr vec2, long len, ca_ctx_t ctx) + + void _ca_vec_sub(ca_ptr res, ca_srcptr vec1, ca_srcptr vec2, long len, ca_ctx_t ctx) + # Sets *res* to the sum or difference of *vec1* and *vec2*, + # all vectors having length *len*. + + void _ca_vec_scalar_mul_ca(ca_ptr res, ca_srcptr src, long len, const ca_t c, ca_ctx_t ctx) + # Sets *res* to *src* multiplied by *c*, all vectors having + # length *len*. + + void _ca_vec_scalar_div_ca(ca_ptr res, ca_srcptr src, long len, const ca_t c, ca_ctx_t ctx) + # Sets *res* to *src* divided by *c*, all vectors having + # length *len*. + + void _ca_vec_scalar_addmul_ca(ca_ptr res, ca_srcptr src, long len, const ca_t c, ca_ctx_t ctx) + # Adds *src* multiplied by *c* to the vector *res*, all vectors having + # length *len*. + + void _ca_vec_scalar_submul_ca(ca_ptr res, ca_srcptr src, long len, const ca_t c, ca_ctx_t ctx) + # Subtracts *src* multiplied by *c* from the vector *res*, all vectors having + # length *len*. + + truth_t _ca_vec_check_is_zero(ca_srcptr vec, long len, ca_ctx_t ctx) + # Returns whether *vec* is the zero vector. + + int _ca_vec_is_fmpq_vec(ca_srcptr vec, long len, ca_ctx_t ctx) + # Checks if all elements of *vec* are structurally rational numbers. + + int _ca_vec_fmpq_vec_is_fmpz_vec(ca_srcptr vec, long len, ca_ctx_t ctx) + # Assuming that all elements of *vec* are structurally rational numbers, + # checks if all elements are integers. + + void _ca_vec_fmpq_vec_get_fmpz_vec_den(fmpz * c, fmpz_t den, ca_srcptr vec, long len, ca_ctx_t ctx) + # Assuming that all elements of *vec* are structurally rational numbers, + # converts them to a vector of integers *c* on a common denominator + # *den*. + + void _ca_vec_set_fmpz_vec_div_fmpz(ca_ptr res, const fmpz * v, const fmpz_t den, long len, ca_ctx_t ctx) + # Sets *res* to the rational vector given by numerators *v* + # and the common denominator *den*. diff --git a/src/sage/libs/flint/calcium.pxd b/src/sage/libs/flint/calcium.pxd new file mode 100644 index 00000000000..8a0f33a978a --- /dev/null +++ b/src/sage/libs/flint/calcium.pxd @@ -0,0 +1,46 @@ +# distutils: libraries = flint +# distutils: depends = flint/calcium.h + +################################################################################ +# This file is auto-generated. Do not modify by hand +################################################################################ + +from libc.stdio cimport FILE +from sage.libs.gmp.types cimport * +from sage.libs.mpfr.types cimport * +from sage.libs.flint.types cimport * + +cdef extern from "flint_wrap.h": + + const char * calcium_version() + # Returns a pointer to the version of the library as a string ``X.Y.Z``. + + unsigned long calcium_fmpz_hash(const fmpz_t x) + # Hash function for integers. The algorithm may change; + # presently, this simply extracts the low word (with sign). + + void calcium_stream_init_file(calcium_stream_t out, FILE * fp) + # Initializes the stream *out* for writing to the file *fp*. + # The file can be *stdout*, *stderr*, or any file opened for writing + # by the user. + + void calcium_stream_init_str(calcium_stream_t out) + # Initializes the stream *out* for writing to a string in memory. + # When finished, the user should free the string (the *s* member + # of *out* with ``flint_free()``). + + void calcium_write(calcium_stream_t out, const char * s) + # Writes the string *s* to *out*. + + void calcium_write_free(calcium_stream_t out, char * s) + # Writes *s* to *out* and then frees *s* by calling ``flint_free()``. + + void calcium_write_si(calcium_stream_t out, long x) + void calcium_write_fmpz(calcium_stream_t out, const fmpz_t x) + # Writes the integer *x* to *out*. + + void calcium_write_arb(calcium_stream_t out, const arb_t z, long digits, unsigned long flags) + void calcium_write_acb(calcium_stream_t out, const acb_t z, long digits, unsigned long flags) + # Writes the Arb number *z* to *out*, showing *digits* + # digits and with the display style specified by *flags* + # (``ARB_STR_NO_RADIUS``, etc.). diff --git a/src/sage/libs/flint/d_mat.pxd b/src/sage/libs/flint/d_mat.pxd new file mode 100644 index 00000000000..5cbabced9c2 --- /dev/null +++ b/src/sage/libs/flint/d_mat.pxd @@ -0,0 +1,109 @@ +# distutils: libraries = flint +# distutils: depends = flint/d_mat.h + +################################################################################ +# This file is auto-generated. Do not modify by hand +################################################################################ + +from libc.stdio cimport FILE +from sage.libs.gmp.types cimport * +from sage.libs.mpfr.types cimport * +from sage.libs.flint.types cimport * + +cdef extern from "flint_wrap.h": + + void d_mat_init(d_mat_t mat, long rows, long cols) + # Initialises a matrix with the given number of rows and columns for use. + + void d_mat_clear(d_mat_t mat) + # Clears the given matrix. + + void d_mat_set(d_mat_t mat1, const d_mat_t mat2) + # Sets ``mat1`` to a copy of ``mat2``. The dimensions of + # ``mat1`` and ``mat2`` must be the same. + + void d_mat_swap(d_mat_t mat1, d_mat_t mat2) + # Swaps two matrices. The dimensions of ``mat1`` and ``mat2`` + # are allowed to be different. + + void d_mat_swap_entrywise(d_mat_t mat1, d_mat_t mat2) + # Swaps two matrices by swapping the individual entries rather than swapping + # the contents of the structs. + + double d_mat_entry(d_mat_t mat, long i, long j) + # Returns the entry of ``mat`` at row `i` and column `j`. + # Both `i` and `j` must not exceed the dimensions of the matrix. + # This function is implemented as a macro. + + double d_mat_get_entry(const d_mat_t mat, long i, long j) + # Returns the entry of ``mat`` at row `i` and column `j`. + # Both `i` and `j` must not exceed the dimensions of the matrix. + + double * d_mat_entry_ptr(const d_mat_t mat, long i, long j) + # Returns a pointer to the entry of ``mat`` at row `i` and column + # `j`. Both `i` and `j` must not exceed the dimensions of the matrix. + + void d_mat_zero(d_mat_t mat) + # Sets all entries of ``mat`` to 0. + + void d_mat_one(d_mat_t mat) + # Sets ``mat`` to the unit matrix, having ones on the main diagonal + # and zeroes elsewhere. If ``mat`` is nonsquare, it is set to the + # truncation of a unit matrix. + + void d_mat_randtest(d_mat_t mat, flint_rand_t state, long minexp, long maxexp) + # Sets the entries of ``mat`` to random signed numbers with exponents + # between ``minexp`` and ``maxexp`` or zero. + + void d_mat_print(const d_mat_t mat) + # Prints the given matrix to the stream ``stdout``. + + int d_mat_equal(const d_mat_t mat1, const d_mat_t mat2) + # Returns a non-zero value if ``mat1`` and ``mat2`` have + # the same dimensions and entries, and zero otherwise. + + int d_mat_approx_equal(const d_mat_t mat1, const d_mat_t mat2, double eps) + # Returns a non-zero value if ``mat1`` and ``mat2`` have + # the same dimensions and entries within ``eps`` of each other, + # and zero otherwise. + + int d_mat_is_zero(const d_mat_t mat) + # Returns a non-zero value if all entries ``mat`` are zero, and + # otherwise returns zero. + + int d_mat_is_approx_zero(const d_mat_t mat, double eps) + # Returns a non-zero value if all entries ``mat`` are zero to within + # ``eps`` and otherwise returns zero. + + int d_mat_is_empty(const d_mat_t mat) + # Returns a non-zero value if the number of rows or the number of + # columns in ``mat`` is zero, and otherwise returns + # zero. + + int d_mat_is_square(const d_mat_t mat) + # Returns a non-zero value if the number of rows is equal to the + # number of columns in ``mat``, and otherwise returns zero. + + void d_mat_transpose(d_mat_t B, const d_mat_t A) + # Sets `B` to `A^T`, the transpose of `A`. Dimensions must be compatible. + # `A` and `B` are allowed to be the same object if `A` is a square matrix. + + void d_mat_mul_classical(d_mat_t C, const d_mat_t A, const d_mat_t B) + # Sets ``C`` to the matrix product `C = A B`. The matrices must have + # compatible dimensions for matrix multiplication (an exception is raised + # otherwise). Aliasing is allowed. + + void d_mat_gso(d_mat_t B, const d_mat_t A) + # Takes a subset of `R^m` `S = {a_1, a_2, \ldots, a_n}` (as the columns of + # a `m \times n` matrix ``A``) and generates an orthonormal set + # `S' = {b_1, b_2, \ldots, b_n}` (as the columns of the `m \times n` matrix + # ``B``) that spans the same subspace of `R^m` as `S`. + # This uses an algorithm of Schwarz-Rutishauser. See pp. 9 of + # https://people.inf.ethz.ch/gander/papers/qrneu.pdf + + void d_mat_qr(d_mat_t Q, d_mat_t R, const d_mat_t A) + # Computes the `QR` decomposition of a matrix ``A`` using the Gram-Schmidt + # process. (Sets ``Q`` and ``R`` such that `A = QR` where ``R`` is + # an upper triangular matrix and ``Q`` is an orthogonal matrix.) + # This uses an algorithm of Schwarz-Rutishauser. See pp. 9 of + # https://people.inf.ethz.ch/gander/papers/qrneu.pdf diff --git a/src/sage/libs/flint/d_vec.pxd b/src/sage/libs/flint/d_vec.pxd new file mode 100644 index 00000000000..c567d3d7907 --- /dev/null +++ b/src/sage/libs/flint/d_vec.pxd @@ -0,0 +1,75 @@ +# distutils: libraries = flint +# distutils: depends = flint/d_vec.h + +################################################################################ +# This file is auto-generated. Do not modify by hand +################################################################################ + +from libc.stdio cimport FILE +from sage.libs.gmp.types cimport * +from sage.libs.mpfr.types cimport * +from sage.libs.flint.types cimport * + +cdef extern from "flint_wrap.h": + + double * _d_vec_init(long len) + # Returns an initialised vector of ``double``\s of given length. The + # entries are not zeroed. + + void _d_vec_clear(double * vec) + # Frees the space allocated for ``vec``. + + void _d_vec_randtest(double * f, flint_rand_t state, long len, long minexp, long maxexp) + # Sets the entries of a vector of the given length to random signed numbers + # with exponents between ``minexp`` and ``maxexp`` or zero. + + void _d_vec_set(double * vec1, const double * vec2, long len2) + # Makes a copy of ``(vec2, len2)`` into ``vec1``. + + void _d_vec_zero(double * vec, long len) + # Zeros the entries of ``(vec, len)``. + + int _d_vec_equal(const double * vec1, const double * vec2, long len) + # Compares two vectors of the given length and returns `1` if they are + # equal, otherwise returns `0`. + + int _d_vec_is_zero(const double * vec, long len) + # Returns `1` if ``(vec, len)`` is zero, and `0` otherwise. + + int _d_vec_is_approx_zero(const double * vec, long len, double eps) + # Returns `1` if the entries of ``(vec, len)`` are zero to within + # ``eps``, and `0` otherwise. + + int _d_vec_approx_equal(const double * vec1, const double * vec2, long len, double eps) + # Compares two vectors of the given length and returns `1` if their entries + # are within ``eps`` of each other, otherwise returns `0`. + + void _d_vec_add(double * res, const double * vec1, const double * vec2, long len2) + # Sets ``(res, len2)`` to the sum of ``(vec1, len2)`` + # and ``(vec2, len2)``. + + void _d_vec_sub(double * res, const double * vec1, const double * vec2, long len2) + # Sets ``(res, len2)`` to ``(vec1, len2)`` minus ``(vec2, len2)``. + + double _d_vec_dot(const double * vec1, const double * vec2, long len2) + # Returns the dot product of ``(vec1, len2)`` + # and ``(vec2, len2)``. + + double _d_vec_norm(const double * vec, long len) + # Returns the square of the Euclidean norm of ``(vec, len)``. + + double _d_vec_dot_heuristic(const double * vec1, const double * vec2, long len2, double * err) + # Returns the dot product of ``(vec1, len2)`` + # and ``(vec2, len2)`` by adding up the positive and negative products, + # and doing a single subtraction of the two sums at the end. ``err`` is a + # pointer to a double in which an error bound for the operation will be + # stored. + + double _d_vec_dot_thrice(const double * vec1, const double * vec2, long len2, double * err) + # Returns the dot product of ``(vec1, len2)`` + # and ``(vec2, len2)`` using error-free floating point sums and products + # to compute the dot product with three times (thrice) the working precision. + # ``err`` is a pointer to a double in which an error bound for the + # operation will be stored. + # This implements the algorithm of Ogita-Rump-Oishi. See + # http://www.ti3.tuhh.de/paper/rump/OgRuOi05.pdf. diff --git a/src/sage/libs/flint/dirichlet.pxd b/src/sage/libs/flint/dirichlet.pxd new file mode 100644 index 00000000000..2850884e733 --- /dev/null +++ b/src/sage/libs/flint/dirichlet.pxd @@ -0,0 +1,147 @@ +# distutils: libraries = flint +# distutils: depends = flint/dirichlet.h + +################################################################################ +# This file is auto-generated. Do not modify by hand +################################################################################ + +from libc.stdio cimport FILE +from sage.libs.gmp.types cimport * +from sage.libs.mpfr.types cimport * +from sage.libs.flint.types cimport * + +cdef extern from "flint_wrap.h": + + int dirichlet_group_init(dirichlet_group_t G, unsigned long q) + # Initializes *G* to the group of Dirichlet characters mod *q*. + # This method computes a canonical decomposition of *G* in terms of cyclic + # groups, which are the mod `p^e` subgroups for `p^e\|q`, plus + # the specific generator described by Conrey for each subgroup. + # In particular *G* contains: + # - the number *num* of components + # - the generators + # - the exponent *expo* of the group + # It does *not* automatically precompute lookup tables + # of discrete logarithms or numerical roots of unity, and can therefore + # safely be called even with large *q*. + # For implementation reasons, the largest prime factor of *q* must not + # exceed `10^{16}`. This restriction could + # be removed in the future. The function returns 1 on success and 0 + # if a factor is too large. + + void dirichlet_subgroup_init(dirichlet_group_t H, const dirichlet_group_t G, unsigned long h) + + void dirichlet_group_clear(dirichlet_group_t G) + # Clears *G*. Remark this function does *not* clear the discrete logarithm + # tables stored in *G* (which may be shared with another group). + + unsigned long dirichlet_group_size(const dirichlet_group_t G) + + unsigned long dirichlet_group_num_primitive(const dirichlet_group_t G) + + void dirichlet_group_dlog_precompute(dirichlet_group_t G, unsigned long num) + # Precompute decomposition and tables for discrete log computations in *G*, + # so as to minimize the complexity of *num* calls to discrete logarithms. + # If *num* gets very large, the entire group may be indexed. + + void dirichlet_group_dlog_clear(dirichlet_group_t G) + + void dirichlet_char_init(dirichlet_char_t chi, const dirichlet_group_t G) + # Initializes *chi* to an element of the group *G* and sets its value + # to the principal character. + + void dirichlet_char_clear(dirichlet_char_t chi) + # Clears *chi*. + + void dirichlet_char_print(const dirichlet_group_t G, const dirichlet_char_t chi) + # Prints the array of exponents representing this character. + + void dirichlet_char_log(dirichlet_char_t x, const dirichlet_group_t G, unsigned long m) + # Sets *x* to the character of number *m*, computing its log using discrete + # logarithm in *G*. + + unsigned long dirichlet_char_exp(const dirichlet_group_t G, const dirichlet_char_t x) + # Returns the number *m* corresponding to exponents in *x*. + + unsigned long _dirichlet_char_exp(dirichlet_char_t x, const dirichlet_group_t G) + # Computes and returns the number *m* corresponding to exponents in *x*. + # This function is for internal use. + + void dirichlet_char_one(dirichlet_char_t x, const dirichlet_group_t G) + # Sets *x* to the principal character in *G*, having *log* `[0,\dots 0]`. + + void dirichlet_char_first_primitive(dirichlet_char_t x, const dirichlet_group_t G) + # Sets *x* to the first primitive character of *G*, having *log* `[1,\dots 1]`, + # or `[0, 1, \dots 1]` if `8\mid q`. + + void dirichlet_char_set(dirichlet_char_t x, const dirichlet_group_t G, const dirichlet_char_t y) + # Sets *x* to the element *y*. + + int dirichlet_char_next(dirichlet_char_t x, const dirichlet_group_t G) + # Sets *x* to the next character in *G* according to lexicographic ordering + # of *log*. + # The return value + # is the index of the last updated exponent of *x*, or *-1* if the last + # element has been reached. + # This function allows to iterate on all elements of *G* looping on their *log*. + # Note that it produces elements in seemingly random *number* order. + # The following template can be used for such a loop:: + # dirichlet_char_one(chi, G); + # do { + # /* use character chi */ + # } while (dirichlet_char_next(chi, G) >= 0); + + int dirichlet_char_next_primitive(dirichlet_char_t x, const dirichlet_group_t G) + # Same as :func:`dirichlet_char_next`, but jumps to the next primitive character of *G*. + + unsigned long dirichlet_index_char(const dirichlet_group_t G, const dirichlet_char_t x) + # Returns the lexicographic index of the *log* of *x* as an integer in `0\dots \varphi(q)`. + + void dirichlet_char_index(dirichlet_char_t x, const dirichlet_group_t G, unsigned long j) + # Sets *x* to the character whose *log* has lexicographic index *j*. + + int dirichlet_char_eq(const dirichlet_char_t x, const dirichlet_char_t y) + + int dirichlet_char_eq_deep(const dirichlet_group_t G, const dirichlet_char_t x, const dirichlet_char_t y) + + int dirichlet_char_is_principal(const dirichlet_group_t G, const dirichlet_char_t chi) + + unsigned long dirichlet_conductor_ui(const dirichlet_group_t G, unsigned long a) + + unsigned long dirichlet_conductor_char(const dirichlet_group_t G, const dirichlet_char_t x) + + int dirichlet_parity_ui(const dirichlet_group_t G, unsigned long a) + + int dirichlet_parity_char(const dirichlet_group_t G, const dirichlet_char_t x) + + unsigned long dirichlet_order_ui(const dirichlet_group_t G, unsigned long a) + + unsigned long dirichlet_order_char(const dirichlet_group_t G, const dirichlet_char_t x) + + int dirichlet_char_is_real(const dirichlet_group_t G, const dirichlet_char_t chi) + + int dirichlet_char_is_primitive(const dirichlet_group_t G, const dirichlet_char_t chi) + + unsigned long dirichlet_pairing(const dirichlet_group_t G, unsigned long m, unsigned long n) + + unsigned long dirichlet_pairing_char(const dirichlet_group_t G, const dirichlet_char_t chi, const dirichlet_char_t psi) + + unsigned long dirichlet_chi(const dirichlet_group_t G, const dirichlet_char_t chi, unsigned long n) + + void dirichlet_chi_vec(unsigned long * v, const dirichlet_group_t G, const dirichlet_char_t chi, long nv) + + void dirichlet_chi_vec_order(unsigned long * v, const dirichlet_group_t G, const dirichlet_char_t chi, unsigned long order, long nv) + + void dirichlet_char_mul(dirichlet_char_t chi12, const dirichlet_group_t G, const dirichlet_char_t chi1, const dirichlet_char_t chi2) + + void dirichlet_char_pow(dirichlet_char_t c, const dirichlet_group_t G, const dirichlet_char_t a, unsigned long n) + + void dirichlet_char_lift(dirichlet_char_t chi_G, const dirichlet_group_t G, const dirichlet_char_t chi_H, const dirichlet_group_t H) + # If *H* is a subgroup of *G*, computes the character in *G* corresponding to + # *chi_H* in *H*. + + void dirichlet_char_lower(dirichlet_char_t chi_H, const dirichlet_group_t H, const dirichlet_char_t chi_G, const dirichlet_group_t G) + # If *chi_G* is a character of *G* which factors through *H*, sets *chi_H* to + # the corresponding restriction in *H*. + # This requires `c(\chi_G)\mid q_H\mid q_G`, where `c(\chi_G)` is the + # conductor of `\chi_G` and `q_G, q_H` are the moduli of G and H. diff --git a/src/sage/libs/flint/dlog.pxd b/src/sage/libs/flint/dlog.pxd new file mode 100644 index 00000000000..3d41a69958c --- /dev/null +++ b/src/sage/libs/flint/dlog.pxd @@ -0,0 +1,85 @@ +# distutils: libraries = flint +# distutils: depends = flint/dlog.h + +################################################################################ +# This file is auto-generated. Do not modify by hand +################################################################################ + +from libc.stdio cimport FILE +from sage.libs.gmp.types cimport * +from sage.libs.mpfr.types cimport * +from sage.libs.flint.types cimport * + +cdef extern from "flint_wrap.h": + + unsigned long dlog_once(unsigned long b, unsigned long a, const nmod_t mod, unsigned long n) + + void dlog_precomp_n_init(dlog_precomp_t pre, unsigned long a, unsigned long mod, unsigned long n, unsigned long num) + + unsigned long dlog_precomp(const dlog_precomp_t pre, unsigned long b) + + void dlog_precomp_clear(dlog_precomp_t pre) + + void dlog_precomp_modpe_init(dlog_precomp_t pre, unsigned long a, unsigned long p, unsigned long e, unsigned long pe, unsigned long num) + + void dlog_precomp_p_init(dlog_precomp_t pre, unsigned long a, unsigned long mod, unsigned long p, unsigned long num) + + void dlog_precomp_pe_init(dlog_precomp_t pre, unsigned long a, unsigned long mod, unsigned long p, unsigned long e, unsigned long pe, unsigned long num) + + void dlog_precomp_small_init(dlog_precomp_t pre, unsigned long a, unsigned long mod, unsigned long n, unsigned long num) + + void dlog_vec_fill(unsigned long * v, unsigned long nv, unsigned long x) + + void dlog_vec_set_not_found(unsigned long * v, unsigned long nv, nmod_t mod) + + void dlog_vec(unsigned long * v, unsigned long nv, unsigned long a, unsigned long va, nmod_t mod, unsigned long na, nmod_t order) + + void dlog_vec_add(unsigned long * v, unsigned long nv, unsigned long a, unsigned long va, nmod_t mod, unsigned long na, nmod_t order) + + void dlog_vec_loop(unsigned long * v, unsigned long nv, unsigned long a, unsigned long va, nmod_t mod, unsigned long na, nmod_t order) + + void dlog_vec_loop_add(unsigned long * v, unsigned long nv, unsigned long a, unsigned long va, nmod_t mod, unsigned long na, nmod_t order) + + void dlog_vec_eratos(unsigned long * v, unsigned long nv, unsigned long a, unsigned long va, nmod_t mod, unsigned long na, nmod_t order) + + void dlog_vec_eratos_add(unsigned long * v, unsigned long nv, unsigned long a, unsigned long va, nmod_t mod, unsigned long na, nmod_t order) + + void dlog_vec_sieve_add(unsigned long * v, unsigned long nv, unsigned long a, unsigned long va, nmod_t mod, unsigned long na, nmod_t order) + + void dlog_vec_sieve(unsigned long * v, unsigned long nv, unsigned long a, unsigned long va, nmod_t mod, unsigned long na, nmod_t order) + + unsigned long dlog_table_init(dlog_table_t t, unsigned long a, unsigned long mod) + + void dlog_table_clear(dlog_table_t t) + + unsigned long dlog_table(const dlog_table_t t, unsigned long b) + + unsigned long dlog_bsgs_init(dlog_bsgs_t t, unsigned long a, unsigned long mod, unsigned long n, unsigned long m) + + void dlog_bsgs_clear(dlog_bsgs_t t) + + unsigned long dlog_bsgs(const dlog_bsgs_t t, unsigned long b) + + unsigned long dlog_modpe_init(dlog_modpe_t t, unsigned long a, unsigned long p, unsigned long e, unsigned long pe, unsigned long num) + + void dlog_modpe_clear(dlog_modpe_t t) + + unsigned long dlog_modpe(const dlog_modpe_t t, unsigned long b) + + unsigned long dlog_crt_init(dlog_crt_t t, unsigned long a, unsigned long mod, unsigned long n, unsigned long num) + + void dlog_crt_clear(dlog_crt_t t) + + unsigned long dlog_crt(const dlog_crt_t t, unsigned long b) + + unsigned long dlog_power_init(dlog_power_t t, unsigned long a, unsigned long mod, unsigned long p, unsigned long e, unsigned long num) + + void dlog_power_clear(dlog_power_t t) + + unsigned long dlog_power(const dlog_power_t t, unsigned long b) + + void dlog_rho_init(dlog_rho_t t, unsigned long a, unsigned long mod, unsigned long n) + + void dlog_rho_clear(dlog_rho_t t) + + unsigned long dlog_rho(const dlog_rho_t t, unsigned long b) diff --git a/src/sage/libs/flint/double_extras.pxd b/src/sage/libs/flint/double_extras.pxd new file mode 100644 index 00000000000..73c9f88d781 --- /dev/null +++ b/src/sage/libs/flint/double_extras.pxd @@ -0,0 +1,51 @@ +# distutils: libraries = flint +# distutils: depends = flint/double_extras.h + +################################################################################ +# This file is auto-generated. Do not modify by hand +################################################################################ + +from libc.stdio cimport FILE +from sage.libs.gmp.types cimport * +from sage.libs.mpfr.types cimport * +from sage.libs.flint.types cimport * + +cdef extern from "flint_wrap.h": + + double d_randtest(flint_rand_t state) + # Returns a random number in the interval `[0.5, 1)`. + + double d_randtest_signed(flint_rand_t state, long minexp, long maxexp) + # Returns a random signed number with exponent between ``minexp`` and + # ``maxexp`` or zero. + + double d_randtest_special(flint_rand_t state, long minexp, long maxexp) + # Returns a random signed number with exponent between ``minexp`` and + # ``maxexp``, zero, ``D_NAN`` or `\pm`\ ``D_INF``. + + double d_polyval(const double * poly, int len, double x) + # Uses Horner's rule to evaluate the polynomial defined by the given + # ``len`` coefficients. Requires that ``len`` is nonzero. + + double d_lambertw(double x) + # Computes the principal branch of the Lambert W function, solving + # the equation `x = W(x) \exp(W(x))`. If `x < -1/e`, the solution is + # complex, and NaN is returned. + # Depending on the magnitude of `x`, we start from a piecewise rational + # approximation or a zeroth-order truncation of the asymptotic expansion + # at infinity, and perform 0, 1 or 2 iterations with Halley's + # method to obtain full accuracy. + # A test of `10^7` random inputs showed a maximum relative error smaller + # than 0.95 times ``DBL_EPSILON`` (`2^{-52}`) for positive `x`. + # Accuracy for negative `x` is slightly worse, and can grow to + # about 10 times ``DBL_EPSILON`` close to `-1/e`. + # However, accuracy may be worse depending on compiler flags and + # the accuracy of the system libm functions. + + int d_is_nan(double x) + # Returns a nonzero integral value if ``x`` is ``D_NAN``, and otherwise + # returns 0. + + double d_log2(double x) + # Returns the base 2 logarithm of ``x`` provided ``x`` is positive. If + # a domain or pole error occurs, the appropriate error value is returned. diff --git a/src/sage/libs/flint/double_interval.pxd b/src/sage/libs/flint/double_interval.pxd new file mode 100644 index 00000000000..8abc10b775d --- /dev/null +++ b/src/sage/libs/flint/double_interval.pxd @@ -0,0 +1,66 @@ +# distutils: libraries = flint +# distutils: depends = flint/double_interval.h + +################################################################################ +# This file is auto-generated. Do not modify by hand +################################################################################ + +from libc.stdio cimport FILE +from sage.libs.gmp.types cimport * +from sage.libs.mpfr.types cimport * +from sage.libs.flint.types cimport * + +cdef extern from "flint_wrap.h": + + di_t di_interval(double a, double b) + # Returns the interval `[a, b]`. We require that the endpoints + # are ordered and not NaN. + + di_t arb_get_di(const arb_t x) + # Returns the ball *x* converted to a double-precision interval. + + void arb_set_di(arb_t res, di_t x, long prec) + # Sets the ball *res* to the double-precision interval *x*, + # rounded to *prec* bits. + + void di_print(di_t x) + # Prints *x* to standard output. This simply prints decimal + # representations of the floating-point endpoints; the + # decimals are not guaranteed to be rounded outward. + + double d_randtest2(flint_rand_t state) + # Returns a random non-NaN ``double`` with any exponent. + # The value can be infinite or subnormal. + + di_t di_randtest(flint_rand_t state) + # Returns an interval with random endpoints. + + di_t di_neg(di_t x) + # Returns the exact negation of *x*. + + di_t di_fast_add(di_t x, di_t y) + di_t di_fast_sub(di_t x, di_t y) + di_t di_fast_mul(di_t x, di_t y) + di_t di_fast_div(di_t x, di_t y) + # Returns the sum, difference, product or quotient of *x* and *y*. + # Division by zero is currently defined to return `[-\infty, +\infty]`. + + di_t di_fast_sqr(di_t x) + # Returns the square of *x*. The output is clamped to + # be nonnegative. + + di_t di_fast_add_d(di_t x, double y) + di_t di_fast_sub_d(di_t x, double y) + di_t di_fast_mul_d(di_t x, double y) + di_t di_fast_div_d(di_t x, double y) + # Arithmetic with an exact ``double`` operand. + + di_t di_fast_log_nonnegative(di_t x) + # Returns an enclosure of `\log(x)`. The lower endpoint of *x* + # is rounded up to 0 if it is negative. + + di_t di_fast_mid(di_t x) + # Returns an enclosure of the midpoint of *x*. + + double di_fast_ubound_radius(di_t x) + # Returns an upper bound for the radius of *x*. diff --git a/src/sage/libs/flint/fft.pxd b/src/sage/libs/flint/fft.pxd new file mode 100644 index 00000000000..b00a80556cd --- /dev/null +++ b/src/sage/libs/flint/fft.pxd @@ -0,0 +1,440 @@ +# distutils: libraries = flint +# distutils: depends = flint/fft.h + +################################################################################ +# This file is auto-generated. Do not modify by hand +################################################################################ + +from libc.stdio cimport FILE +from sage.libs.gmp.types cimport * +from sage.libs.mpfr.types cimport * +from sage.libs.flint.types cimport * + +cdef extern from "flint_wrap.h": + + mp_size_t fft_split_limbs(mp_limb_t ** poly, mp_srcptr limbs, mp_size_t total_limbs, mp_size_t coeff_limbs, mp_size_t output_limbs) + # Split an integer ``(limbs, total_limbs)`` into coefficients of length + # ``coeff_limbs`` limbs and store as the coefficients of ``poly`` + # which are assumed to have space for ``output_limbs + 1`` limbs per + # coefficient. The coefficients of the polynomial do not need to be zeroed + # before calling this function, however the number of coefficients written + # is returned by the function and any coefficients beyond this point are + # not touched. + + mp_size_t fft_split_bits(mp_limb_t ** poly, mp_srcptr limbs, mp_size_t total_limbs, flint_bitcnt_t bits, mp_size_t output_limbs) + # Split an integer ``(limbs, total_limbs)`` into coefficients of the + # given number of ``bits`` and store as the coefficients of ``poly`` + # which are assumed to have space for ``output_limbs + 1`` limbs per + # coefficient. The coefficients of the polynomial do not need to be zeroed + # before calling this function, however the number of coefficients written + # is returned by the function and any coefficients beyond this point are + # not touched. + + void fft_combine_limbs(mp_limb_t * res, mp_limb_t ** poly, long length, mp_size_t coeff_limbs, mp_size_t output_limbs, mp_size_t total_limbs) + # Evaluate the polynomial ``poly`` of the given ``length`` at + # ``B^coeff_limbs``, where ``B = 2^FLINT_BITS``, and add the + # result to the integer ``(res, total_limbs)`` throwing away any bits + # that exceed the given number of limbs. The polynomial coefficients are + # assumed to have at least ``output_limbs`` limbs each, however any + # additional limbs are ignored. + # If the integer is initially zero the result will just be the evaluation + # of the polynomial. + + void fft_combine_bits(mp_limb_t * res, mp_limb_t ** poly, long length, flint_bitcnt_t bits, mp_size_t output_limbs, mp_size_t total_limbs) + # Evaluate the polynomial ``poly`` of the given ``length`` at + # ``2^bits`` and add the result to the integer + # ``(res, total_limbs)`` throwing away any bits that exceed the given + # number of limbs. The polynomial coefficients are assumed to have at least + # ``output_limbs`` limbs each, however any additional limbs are ignored. + # If the integer is initially zero the result will just be the evaluation + # of the polynomial. + + void fermat_to_mpz(mpz_t m, mp_limb_t * i, mp_size_t limbs) + # Convert the Fermat number ``(i, limbs)`` modulo ``B^limbs + 1`` to + # an ``mpz_t m``. Assumes ``m`` has been initialised. This function + # is used only in test code. + + void mpn_negmod_2expp1(mp_limb_t* z, const mp_limb_t* a, mp_size_t limbs) + # Set ``z`` to the negation of the Fermat number `a` modulo ``B^limbs + 1``. + # The input ``a`` is expected to be fully reduced, and the output is fully reduced. + # Aliasing is permitted. + + void mpn_addmod_2expp1_1(mp_limb_t * r, mp_size_t limbs, mp_limb_signed_t c) + # Adds the signed limb ``c`` to the generalised Fermat number ``r`` + # modulo ``B^limbs + 1``. The compiler should be able to inline + # this for the case that there is no overflow from the first limb. + + void mpn_normmod_2expp1(mp_limb_t * t, mp_size_t limbs) + # Given ``t`` a signed integer of ``limbs + 1`` limbs in two's + # complement format, reduce ``t`` to the corresponding value modulo the + # generalised Fermat number ``B^limbs + 1``, where + # ``B = 2^FLINT_BITS``. + + void mpn_mul_2expmod_2expp1(mp_limb_t * t, mp_limb_t * i1, mp_size_t limbs, flint_bitcnt_t d) + # Given ``i1`` a signed integer of ``limbs + 1`` limbs in two's + # complement format reduced modulo ``B^limbs + 1`` up to some + # overflow, compute ``t = i1*2^d`` modulo `p`. The result will not + # necessarily be fully reduced. The number of bits ``d`` must be + # nonnegative and less than ``FLINT_BITS``. Aliasing is permitted. + + void mpn_div_2expmod_2expp1(mp_limb_t * t, mp_limb_t * i1, mp_size_t limbs, flint_bitcnt_t d) + # Given ``i1`` a signed integer of ``limbs + 1`` limbs in two's + # complement format reduced modulo ``B^limbs + 1`` up to some + # overflow, compute ``t = i1/2^d`` modulo `p`. The result will not + # necessarily be fully reduced. The number of bits ``d`` must be + # nonnegative and less than ``FLINT_BITS``. Aliasing is permitted. + + void fft_adjust(mp_limb_t * r, mp_limb_t * i1, mp_size_t i, mp_size_t limbs, flint_bitcnt_t w) + # Set ``r`` to ``i1`` times `z^i` modulo ``B^limbs + 1`` where + # `z` corresponds to multiplication by `2^w`. This can be thought of as part + # of a butterfly operation. We require `0 \leq i < n` where `nw =` + # ``limbs*FLINT_BITS``. Aliasing is not supported. + + void fft_adjust_sqrt2(mp_limb_t * r, mp_limb_t * i1, mp_size_t i, mp_size_t limbs, flint_bitcnt_t w, mp_limb_t * temp) + # Set ``r`` to ``i1`` times `z^i` modulo ``B^limbs + 1`` where + # `z` corresponds to multiplication by `\sqrt{2}^w`. This can be thought of + # as part of a butterfly operation. We require `0 \leq i < 2\cdot n` and odd + # where `nw =` ``limbs*FLINT_BITS``. + + void butterfly_lshB(mp_limb_t * t, mp_limb_t * u, mp_limb_t * i1, mp_limb_t * i2, mp_size_t limbs, mp_size_t x, mp_size_t y) + # We are given two integers ``i1`` and ``i2`` modulo + # ``B^limbs + 1`` which are not necessarily normalised. We compute + # ``t = (i1 + i2)*B^x`` and ``u = (i1 - i2)*B^y`` modulo `p`. Aliasing + # between inputs and outputs is not permitted. We require ``x`` and + # ``y`` to be less than ``limbs`` and nonnegative. + + void butterfly_rshB(mp_limb_t * t, mp_limb_t * u, mp_limb_t * i1, mp_limb_t * i2, mp_size_t limbs, mp_size_t x, mp_size_t y) + # We are given two integers ``i1`` and ``i2`` modulo + # ``B^limbs + 1`` which are not necessarily normalised. We compute + # ``t = (i1 + i2)/B^x`` and ``u = (i1 - i2)/B^y`` modulo `p`. Aliasing + # between inputs and outputs is not permitted. We require ``x`` and + # ``y`` to be less than ``limbs`` and nonnegative. + + void fft_butterfly(mp_limb_t * s, mp_limb_t * t, mp_limb_t * i1, mp_limb_t * i2, mp_size_t i, mp_size_t limbs, flint_bitcnt_t w) + # Set ``s = i1 + i2``, ``t = z1^i*(i1 - i2)`` modulo + # ``B^limbs + 1`` where ``z1 = exp(Pi*I/n)`` corresponds to + # multiplication by `2^w`. Requires `0 \leq i < n` where `nw =` + # ``limbs*FLINT_BITS``. + + void ifft_butterfly(mp_limb_t * s, mp_limb_t * t, mp_limb_t * i1, mp_limb_t * i2, mp_size_t i, mp_size_t limbs, flint_bitcnt_t w) + # Set ``s = i1 + z1^i*i2``, ``t = i1 - z1^i*i2`` modulo + # ``B^limbs + 1`` where ``z1 = exp(-Pi*I/n)`` corresponds to + # division by `2^w`. Requires `0 \leq i < 2n` where `nw =` + # ``limbs*FLINT_BITS``. + + void fft_radix2(mp_limb_t ** ii, mp_size_t n, flint_bitcnt_t w, mp_limb_t ** t1, mp_limb_t ** t2) + # The radix 2 DIF FFT works as follows: + # Input: ``[i0, i1, ..., i(m-1)]``, for `m = 2n` a power of `2`. + # Output: ``[r0, r1, ..., r(m-1)]`` ``= FFT[i0, i1, ..., i(m-1)]``. + # Algorithm: + # | `\bullet` Recursively compute ``[r0, r2, r4, ...., r(m-2)]`` + # | ``= FFT[i0+i(m/2), i1+i(m/2+1), ..., i(m/2-1)+i(m-1)]`` + # | + # | `\bullet` Let ``[t0, t1, ..., t(m/2-1)]`` + # | ``= [i0-i(m/2), i1-i(m/2+1), ..., i(m/2-1)-i(m-1)]`` + # | + # | `\bullet` Let ``[u0, u1, ..., u(m/2-1)]`` + # | ``= [z1^0*t0, z1^1*t1, ..., z1^(m/2-1)*t(m/2-1)]`` + # | where ``z1 = exp(2*Pi*I/m)`` corresponds to multiplication by `2^w`. + # | + # | `\bullet` Recursively compute ``[r1, r3, ..., r(m-1)]`` + # | ``= FFT[u0, u1, ..., u(m/2-1)]`` + # The parameters are as follows: + # `\bullet` ``2*n`` is the length of the input and output arrays + # `\bullet` `w` is such that `2^w` is an `2n`-th root of unity in the ring `\mathbf{Z}/p\mathbf{Z}` that we are working in, i.e. `p = 2^{wn} + 1` (here `n` is divisible by + # ``GMP_LIMB_BITS``) + # `\bullet` ``ii`` is the array of inputs (each input is an + # array of limbs of length ``wn/GMP_LIMB_BITS + 1`` (the + # extra limbs being a "carry limb"). Outputs are written + # in-place. + # We require `nw` to be at least 64 and the two temporary space pointers to + # point to blocks of size ``n*w + FLINT_BITS`` bits. + + void fft_truncate(mp_limb_t ** ii, mp_size_t n, flint_bitcnt_t w, mp_limb_t ** t1, mp_limb_t ** t2, mp_size_t trunc) + # As for ``fft_radix2`` except that only the first ``trunc`` + # coefficients of the output are computed and the input is regarded as + # having (implied) zero coefficients from coefficient ``trunc`` onwards. + # The coefficients must exist as the algorithm needs to use this extra + # space, but their value is irrelevant. The value of ``trunc`` must be + # divisible by 2. + + void fft_truncate1(mp_limb_t ** ii, mp_size_t n, flint_bitcnt_t w, mp_limb_t ** t1, mp_limb_t ** t2, mp_size_t trunc) + # As for ``fft_radix2`` except that only the first ``trunc`` + # coefficients of the output are computed. The transform still needs all + # `2n` input coefficients to be specified. + + void ifft_radix2(mp_limb_t ** ii, mp_size_t n, flint_bitcnt_t w, mp_limb_t ** t1, mp_limb_t ** t2) + # The radix 2 DIF IFFT works as follows: + # Input: ``[i0, i1, ..., i(m-1)]``, for `m = 2n` a power of `2`. + # Output: ``[r0, r1, ..., r(m-1)]`` + # ``= IFFT[i0, i1, ..., i(m-1)]``. + # Algorithm: + # `\bullet` Recursively compute ``[s0, s1, ...., s(m/2-1)]`` + # ``= IFFT[i0, i2, ..., i(m-2)]`` + # `\bullet` Recursively compute ``[t(m/2), t(m/2+1), ..., t(m-1)]`` + # ``= IFFT[i1, i3, ..., i(m-1)]`` + # `\bullet` Let ``[r0, r1, ..., r(m/2-1)]`` + # ``= [s0+z1^0*t0, s1+z1^1*t1, ..., s(m/2-1)+z1^(m/2-1)*t(m/2-1)]`` where ``z1 = exp(-2*Pi*I/m)`` corresponds to division by `2^w`. + # `\bullet` Let ``[r(m/2), r(m/2+1), ..., r(m-1)]`` + # ``= [s0-z1^0*t0, s1-z1^1*t1, ..., s(m/2-1)-z1^(m/2-1)*t(m/2-1)]`` + # The parameters are as follows: + # `\bullet` ``2*n`` is the length of the input and output + # arrays + # `\bullet` `w` is such that `2^w` is an `2n`-th root of unity in the ring `\mathbf{Z}/p\mathbf{Z}` that we are working in, i.e. `p = 2^{wn} + 1` (here `n` is divisible by + # ``GMP_LIMB_BITS``) + # `\bullet` ``ii`` is the array of inputs (each input is an array of limbs of length ``wn/GMP_LIMB_BITS + 1`` (the extra limbs being a "carry limb"). Outputs are written in-place. + # We require `nw` to be at least 64 and the two temporary space pointers + # to point to blocks of size ``n*w + FLINT_BITS`` bits. + + void ifft_truncate(mp_limb_t ** ii, mp_size_t n, flint_bitcnt_t w, mp_limb_t ** t1, mp_limb_t ** t2, mp_size_t trunc) + # As for ``ifft_radix2`` except that the output is assumed to have + # zeros from coefficient trunc onwards and only the first trunc + # coefficients of the input are specified. The remaining coefficients need + # to exist as the extra space is needed, but their value is irrelevant. + # The value of ``trunc`` must be divisible by 2. + # Although the implementation does not require it, we assume for simplicity + # that ``trunc`` is greater than `n`. The algorithm begins by computing + # the inverse transform of the first `n` coefficients of the input array. + # The unspecified coefficients of the second half of the array are then + # written: coefficient ``trunc + i`` is computed as a twist of + # coefficient ``i`` by a root of unity. The values of these coefficients + # are then equal to what they would have been if the inverse transform of + # the right hand side of the input array had been computed with full data + # from the start. The function ``ifft_truncate1`` is then called on the + # entire right half of the input array with this auxiliary data filled in. + # Finally a single layer of the IFFT is completed on all the coefficients + # up to ``trunc`` being careful to note that this involves doubling the + # coefficients from ``trunc - n`` up to ``n``. + + void ifft_truncate1(mp_limb_t ** ii, mp_size_t n, flint_bitcnt_t w, mp_limb_t ** t1, mp_limb_t ** t2, mp_size_t trunc) + # Computes the first ``trunc`` coefficients of the radix 2 inverse + # transform assuming the first ``trunc`` coefficients are given and that + # the remaining coefficients have been set to the value they would have if + # an inverse transform had already been applied with full data. + # The algorithm is the same as for ``ifft_truncate`` except that the + # coefficients from ``trunc`` onwards after the inverse transform are + # not inferred to be zero but the supplied values. + + void fft_butterfly_sqrt2(mp_limb_t * s, mp_limb_t * t, mp_limb_t * i1, mp_limb_t * i2, mp_size_t i, mp_size_t limbs, flint_bitcnt_t w, mp_limb_t * temp) + # Let `w = 2k + 1`, `i = 2j + 1`. Set ``s = i1 + i2``, + # ``t = z1^i*(i1 - i2)`` modulo ``B^limbs + 1`` where + # ``z1^2 = exp(Pi*I/n)`` corresponds to multiplication by `2^w`. Requires + # `0 \leq i < 2n` where `nw =` ``limbs*FLINT_BITS``. + # Here ``z1`` corresponds to multiplication by `2^k` then multiplication + # by ``(2^(3nw/4) - 2^(nw/4))``. We see ``z1^i`` corresponds to + # multiplication by ``(2^(3nw/4) - 2^(nw/4))*2^(j+ik)``. + # We first multiply by ``2^(j + ik + wn/4)`` then multiply by an + # additional ``2^(nw/2)`` and subtract. + + void ifft_butterfly_sqrt2(mp_limb_t * s, mp_limb_t * t, mp_limb_t * i1, mp_limb_t * i2, mp_size_t i, mp_size_t limbs, flint_bitcnt_t w, mp_limb_t * temp) + # Let `w = 2k + 1`, `i = 2j + 1`. Set ``s = i1 + z1^i*i2``, + # ``t = i1 - z1^i*i2`` modulo ``B^limbs + 1`` where + # ``z1^2 = exp(-Pi*I/n)`` corresponds to division by `2^w`. Requires + # `0 \leq i < 2n` where `nw =` ``limbs*FLINT_BITS``. + # Here ``z1`` corresponds to division by `2^k` then division by + # ``(2^(3nw/4) - 2^(nw/4))``. We see ``z1^i`` corresponds to division + # by ``(2^(3nw/4) - 2^(nw/4))*2^(j+ik)`` which is the same as division + # by ``2^(j+ik + 1)`` then multiplication by + # ``(2^(3nw/4) - 2^(nw/4))``. + # Of course, division by ``2^(j+ik + 1)`` is the same as multiplication + # by ``2^(2*wn - j - ik - 1)``. The exponent is positive as + # `i \leq 2\cdot n`, `j < n`, `k < w/2`. + # We first multiply by ``2^(2*wn - j - ik - 1 + wn/4)`` then multiply by + # an additional ``2^(nw/2)`` and subtract. + + void fft_truncate_sqrt2(mp_limb_t ** ii, mp_size_t n, flint_bitcnt_t w, mp_limb_t ** t1, mp_limb_t ** t2, mp_limb_t ** temp, mp_size_t trunc) + # As per ``fft_truncate`` except that the transform is twice the usual + # length, i.e. length `4n` rather than `2n`. This is achieved by making use + # of twiddles by powers of a square root of 2, not powers of 2 in the first + # layer of the transform. + # We require `nw` to be at least 64 and the three temporary space pointers + # to point to blocks of size ``n*w + FLINT_BITS`` bits. + + void ifft_truncate_sqrt2(mp_limb_t ** ii, mp_size_t n, flint_bitcnt_t w, mp_limb_t ** t1, mp_limb_t ** t2, mp_limb_t ** temp, mp_size_t trunc) + # As per ``ifft_truncate`` except that the transform is twice the usual + # length, i.e. length `4n` instead of `2n`. This is achieved by making use + # of twiddles by powers of a square root of 2, not powers of 2 in the final + # layer of the transform. + # We require `nw` to be at least 64 and the three temporary space pointers + # to point to blocks of size ``n*w + FLINT_BITS`` bits. + + void fft_butterfly_twiddle(mp_limb_t * u, mp_limb_t * v, mp_limb_t * s, mp_limb_t * t, mp_size_t limbs, flint_bitcnt_t b1, flint_bitcnt_t b2) + # Set ``u = 2^b1*(s + t)``, ``v = 2^b2*(s - t)`` modulo + # ``B^limbs + 1``. This is used to compute + # ``u = 2^(ws*tw1)*(s + t)``, ``v = 2^(w+ws*tw2)*(s - t)`` in the + # matrix Fourier algorithm, i.e. effectively computing an ordinary butterfly + # with additional twiddles by ``z1^rc`` for row `r` and column `c` of the + # matrix of coefficients. Aliasing is not allowed. + + void ifft_butterfly_twiddle(mp_limb_t * u, mp_limb_t * v, mp_limb_t * s, mp_limb_t * t, mp_size_t limbs, flint_bitcnt_t b1, flint_bitcnt_t b2) + # Set ``u = s/2^b1 + t/2^b1)``, ``v = s/2^b1 - t/2^b1`` modulo + # ``B^limbs + 1``. This is used to compute + # ``u = 2^(-ws*tw1)*s + 2^(-ws*tw2)*t)``, + # ``v = 2^(-ws*tw1)*s + 2^(-ws*tw2)*t)`` in the matrix Fourier algorithm, + # i.e. effectively computing an ordinary butterfly with additional twiddles + # by ``z1^(-rc)`` for row `r` and column `c` of the matrix of + # coefficients. Aliasing is not allowed. + + void fft_radix2_twiddle(mp_limb_t ** ii, mp_size_t is, mp_size_t n, flint_bitcnt_t w, mp_limb_t ** t1, mp_limb_t ** t2, mp_size_t ws, mp_size_t r, mp_size_t c, mp_size_t rs) + # As for ``fft_radix2`` except that the coefficients are spaced by + # ``is`` in the array ``ii`` and an additional twist by ``z^c*i`` + # is applied to each coefficient where `i` starts at `r` and increases by + # ``rs`` as one moves from one coefficient to the next. Here ``z`` + # corresponds to multiplication by ``2^ws``. + + void ifft_radix2_twiddle(mp_limb_t ** ii, mp_size_t is, mp_size_t n, flint_bitcnt_t w, mp_limb_t ** t1, mp_limb_t ** t2, mp_size_t ws, mp_size_t r, mp_size_t c, mp_size_t rs) + # As for ``ifft_radix2`` except that the coefficients are spaced by + # ``is`` in the array ``ii`` and an additional twist by + # ``z^(-c*i)`` is applied to each coefficient where `i` starts at `r` + # and increases by ``rs`` as one moves from one coefficient to the next. + # Here ``z`` corresponds to multiplication by ``2^ws``. + + void fft_truncate1_twiddle(mp_limb_t ** ii, mp_size_t is, mp_size_t n, flint_bitcnt_t w, mp_limb_t ** t1, mp_limb_t ** t2, mp_size_t ws, mp_size_t r, mp_size_t c, mp_size_t rs, mp_size_t trunc) + # As per ``fft_radix2_twiddle`` except that the transform is truncated + # as per ``fft_truncate1``. + + void ifft_truncate1_twiddle(mp_limb_t ** ii, mp_size_t is, mp_size_t n, flint_bitcnt_t w, mp_limb_t ** t1, mp_limb_t ** t2, mp_size_t ws, mp_size_t r, mp_size_t c, mp_size_t rs, mp_size_t trunc) + # As per ``ifft_radix2_twiddle`` except that the transform is truncated + # as per ``ifft_truncate1``. + + void fft_mfa_truncate_sqrt2(mp_limb_t ** ii, mp_size_t n, flint_bitcnt_t w, mp_limb_t ** t1, mp_limb_t ** t2, mp_limb_t ** temp, mp_size_t n1, mp_size_t trunc) + # This is as per the ``fft_truncate_sqrt2`` function except that the + # matrix Fourier algorithm is used for the left and right FFTs. The total + # transform length is `4n` where ``n = 2^depth`` so that the left and + # right transforms are both length `2n`. We require ``trunc > 2*n`` and + # that ``trunc`` is divisible by ``2*n1`` (explained below). The coefficients + # are produced in an order different from ``fft_truncate_sqrt2``. + # The matrix Fourier algorithm, which is applied to each transform of length + # `2n`, works as follows. We set ``n1`` to a power of 2 about the square + # root of `n`. The data is then thought of as a set of ``n2`` rows each + # with ``n1`` columns (so that ``n1*n2 = 2n``). + # The length `2n` transform is then computed using a whole pile of short + # transforms. These comprise ``n1`` column transforms of length ``n2`` + # followed by some twiddles by roots of unity (namely ``z^rc`` where `r` + # is the row and `c` the column within the data) followed by ``n2`` + # row transforms of length ``n1``. Along the way the data needs to be + # rearranged due to the fact that the short transforms output the data in + # binary reversed order compared with what is needed. + # The matrix Fourier algorithm provides better cache locality by decomposing + # the long length `2n` transforms into many transforms of about the square + # root of the original length. + # For better cache locality the sqrt2 layer of the full length `4n` + # transform is folded in with the column FFTs performed as part of the first + # matrix Fourier algorithm on the left half of the data. + # The second half of the data requires a truncated version of the matrix + # Fourier algorithm. This is achieved by truncating to an exact multiple of + # the row length so that the row transforms are full length. Moreover, the + # column transforms will then be truncated transforms and their truncated + # length needs to be a multiple of 2. This explains the condition on + # ``trunc`` given above. + # To improve performance, the extra twiddles by roots of unity are combined + # with the butterflies performed at the last layer of the column transforms. + # We require `nw` to be at least 64 and the three temporary space pointers + # to point to blocks of size ``n*w + FLINT_BITS`` bits. + + void ifft_mfa_truncate_sqrt2(mp_limb_t ** ii, mp_size_t n, flint_bitcnt_t w, mp_limb_t ** t1, mp_limb_t ** t2, mp_limb_t ** temp, mp_size_t n1, mp_size_t trunc) + # This is as per the ``ifft_truncate_sqrt2`` function except that the + # matrix Fourier algorithm is used for the left and right IFFTs. The total + # transform length is `4n` where ``n = 2^depth`` so that the left and + # right transforms are both length `2n`. We require ``trunc > 2*n`` and + # that ``trunc`` is divisible by ``2*n1``. + # We set ``n1`` to a power of 2 about the square root of `n`. + # As per the matrix fourier FFT the sqrt2 layer is folded into the + # final column IFFTs for better cache locality and the extra twiddles that + # occur in the matrix Fourier algorithm are combined with the butterflied + # performed at the first layer of the final column transforms. + # We require `nw` to be at least 64 and the three temporary space pointers + # to point to blocks of size ``n*w + FLINT_BITS`` bits. + + void fft_mfa_truncate_sqrt2_outer(mp_limb_t ** ii, mp_size_t n, flint_bitcnt_t w, mp_limb_t ** t1, mp_limb_t ** t2, mp_limb_t ** temp, mp_size_t n1, mp_size_t trunc) + # Just the outer layers of ``fft_mfa_truncate_sqrt2``. + + void fft_mfa_truncate_sqrt2_inner(mp_limb_t ** ii, mp_limb_t ** jj, mp_size_t n, flint_bitcnt_t w, mp_limb_t ** t1, mp_limb_t ** t2, mp_limb_t ** temp, mp_size_t n1, mp_size_t trunc, mp_limb_t ** tt) + # The inner layers of ``fft_mfa_truncate_sqrt2`` and + # ``ifft_mfa_truncate_sqrt2`` combined with pointwise mults. + + void ifft_mfa_truncate_sqrt2_outer(mp_limb_t ** ii, mp_size_t n, flint_bitcnt_t w, mp_limb_t ** t1, mp_limb_t ** t2, mp_limb_t ** temp, mp_size_t n1, mp_size_t trunc) + # The outer layers of ``ifft_mfa_truncate_sqrt2`` combined with + # normalisation. + + void fft_negacyclic(mp_limb_t ** ii, mp_size_t n, flint_bitcnt_t w, mp_limb_t ** t1, mp_limb_t ** t2, mp_limb_t ** temp) + # As per ``fft_radix2`` except that it performs a sqrt2 negacyclic + # transform of length `2n`. This is the same as the radix 2 transform + # except that the `i`-th coefficient of the input is first multiplied by + # `\sqrt{2}^{iw}`. + # We require `nw` to be at least 64 and the two temporary space pointers to + # point to blocks of size ``n*w + FLINT_BITS`` bits. + + void ifft_negacyclic(mp_limb_t ** ii, mp_size_t n, flint_bitcnt_t w, mp_limb_t ** t1, mp_limb_t ** t2, mp_limb_t ** temp) + # As per ``ifft_radix2`` except that it performs a sqrt2 negacyclic + # inverse transform of length `2n`. This is the same as the radix 2 inverse + # transform except that the `i`-th coefficient of the output is finally + # divided by `\sqrt{2}^{iw}`. + # We require `nw` to be at least 64 and the two temporary space pointers to + # point to blocks of size ``n*w + FLINT_BITS`` bits. + + void fft_naive_convolution_1(mp_limb_t * r, mp_limb_t * ii, mp_limb_t * jj, mp_size_t m) + # Performs a naive negacyclic convolution of ``ii`` with ``jj``, + # both of length `m`, and sets `r` to the result. This is essentially + # multiplication of polynomials modulo `x^m + 1`. + + void _fft_mulmod_2expp1(mp_limb_t * r1, mp_limb_t * i1, mp_limb_t * i2, mp_size_t r_limbs, flint_bitcnt_t depth, flint_bitcnt_t w) + # Multiply ``i1`` by ``i2`` modulo ``B^r_limbs + 1`` where + # ``r_limbs = nw/FLINT_BITS`` with ``n = 2^depth``. Uses the + # negacyclic FFT convolution CRT'd with a 1 limb naive convolution. We + # require that ``depth`` and ``w`` have been selected as per the + # wrapper ``fft_mulmod_2expp1`` below. + + long fft_adjust_limbs(mp_size_t limbs) + # Given a number of limbs, returns a new number of limbs (no more than + # the next power of 2) which will work with the Nussbaumer code. It is only + # necessary to make this adjustment if + # ``limbs > FFT_MULMOD_2EXPP1_CUTOFF``. + + void fft_mulmod_2expp1(mp_limb_t * r, mp_limb_t * i1, mp_limb_t * i2, mp_size_t n, mp_size_t w, mp_limb_t * tt) + # As per ``_fft_mulmod_2expp1`` but with a tuned cutoff below which more + # classical methods are used for the convolution. The temporary space is + # required to fit ``n*w + FLINT_BITS`` bits. There are no restrictions + # on `n`, but if ``limbs = n*w/FLINT_BITS`` then if ``limbs`` exceeds + # ``FFT_MULMOD_2EXPP1_CUTOFF`` the function ``fft_adjust_limbs`` must + # be called to increase the number of limbs to an appropriate value. + + void mul_truncate_sqrt2(mp_ptr r1, mp_srcptr i1, mp_size_t n1, mp_srcptr i2, mp_size_t n2, flint_bitcnt_t depth, flint_bitcnt_t w) + # Integer multiplication using the radix 2 truncated sqrt2 transforms. + # Set ``(r1, n1 + n2)`` to the product of ``(i1, n1)`` by + # ``(i2, n2)``. This is achieved through an FFT convolution of length at + # most ``2^(depth + 2)`` with coefficients of size `nw` bits where + # ``n = 2^depth``. We require ``depth >= 6``. The input data is + # broken into chunks of data not exceeding ``(nw - (depth + 1))/2`` + # bits. If breaking the first integer into chunks of this size results in + # ``j1`` coefficients and breaking the second integer results in + # ``j2`` chunks then ``j1 + j2 - 1 <= 2^(depth + 2)``. + # If ``n = 2^depth`` then we require `nw` to be at least 64. + + void mul_mfa_truncate_sqrt2(mp_ptr r1, mp_srcptr i1, mp_size_t n1, mp_srcptr i2, mp_size_t n2, flint_bitcnt_t depth, flint_bitcnt_t w) + # As for ``mul_truncate_sqrt2`` except that the cache friendly matrix + # Fourier algorithm is used. + # If ``n = 2^depth`` then we require `nw` to be at least 64. Here we + # also require `w` to be `2^i` for some `i \geq 0`. + + void flint_mpn_mul_fft_main(mp_ptr r1, mp_srcptr i1, mp_size_t n1, mp_srcptr i2, mp_size_t n2) + # The main integer multiplication routine. Sets ``(r1, n1 + n2)`` to + # ``(i1, n1)`` times ``(i2, n2)``. We require ``n1 >= n2 > 0``. + + void fft_convolution(mp_limb_t ** ii, mp_limb_t ** jj, long depth, long limbs, long trunc, mp_limb_t ** t1, mp_limb_t ** t2, mp_limb_t ** s1, mp_limb_t ** tt) + # Perform an FFT convolution of ``ii`` with ``jj``, both of length + # ``4*n`` where ``n = 2^depth``. Assume that all but the first + # ``trunc`` coefficients of the output (placed in ``ii``) are zero. + # Each coefficient is taken modulo ``B^limbs + 1``. The temporary + # spaces ``t1``, ``t2`` and ``s1`` must have ``limbs + 1`` + # limbs of space and ``tt`` must have ``2*(limbs + 1)`` of free + # space. + + void fft_precache(mp_limb_t ** jj, long depth, long limbs, long trunc, mp_limb_t ** t1, mp_limb_t ** t2, mp_limb_t ** s1) + # Precompute the FFT of ``jj`` for use with precache functions. The + # parameters are as for ``fft_convolution``. + + void fft_convolution_precache(mp_limb_t ** ii, mp_limb_t ** jj, long depth, long limbs, long trunc, mp_limb_t ** t1, mp_limb_t ** t2, mp_limb_t ** s1, mp_limb_t ** tt) + # As per ``fft_convolution`` except that it is assumed ``fft_precache`` has + # been called on ``jj`` with the same parameters. This will then run faster + # than if ``fft_convolution`` had been run with the original ``jj``. From a3e313e875c09ad60b29960dddeae996341a579c Mon Sep 17 00:00:00 2001 From: Vincent Delecroix Date: Fri, 13 Oct 2023 09:39:33 +0200 Subject: [PATCH 06/41] modify arb headers --- src/sage/libs/arb/acb.pxd | 328 +++++++++--------- src/sage/libs/arb/acb_calc.pxd | 25 +- src/sage/libs/arb/acb_elliptic.pxd | 51 ++- src/sage/libs/arb/acb_hypgeom.pxd | 148 ++++---- src/sage/libs/arb/acb_mat.pxd | 118 ++++--- src/sage/libs/arb/acb_modular.pxd | 35 +- src/sage/libs/arb/acb_poly.pxd | 440 ++++++++++++------------ src/sage/libs/arb/arb.pxd | 503 +++++++++++++--------------- src/sage/libs/arb/arb_fmpz_poly.pxd | 43 ++- src/sage/libs/arb/arb_hypgeom.pxd | 167 +++++---- src/sage/libs/arb/arf.pxd | 260 +++++++------- src/sage/libs/arb/bernoulli.pxd | 11 +- src/sage/libs/arb/mag.pxd | 148 ++++---- src/sage/libs/arb/types.pxd | 116 +++---- 14 files changed, 1122 insertions(+), 1271 deletions(-) diff --git a/src/sage/libs/arb/acb.pxd b/src/sage/libs/arb/acb.pxd index 851488d803a..b723af56aea 100644 --- a/src/sage/libs/arb/acb.pxd +++ b/src/sage/libs/arb/acb.pxd @@ -1,177 +1,151 @@ -# distutils: libraries = gmp flint -# distutils: depends = acb.h - -from sage.libs.arb.types cimport * -from sage.libs.flint.types cimport fmpz_t, fmpq_t - -# acb.h -cdef extern from "arb_wrap.h": - - arb_t acb_realref(acb_t x) - arb_t acb_imagref(acb_t x) - - void acb_init(acb_t x) - void acb_clear(acb_t x) - acb_ptr _acb_vec_init(long n) - void _acb_vec_clear(acb_ptr v, long n) - - bint acb_is_zero(const acb_t z) - bint acb_is_one(const acb_t z) - bint acb_is_finite(const acb_t z) - bint acb_is_exact(const acb_t z) - bint acb_is_int(const acb_t z) - - void acb_zero(acb_t z) - void acb_one(acb_t z) - void acb_onei(acb_t z) - void acb_set(acb_t z, const acb_t x) - void acb_set_ui(acb_t z, long x) - void acb_set_si(acb_t z, long x) - void acb_set_fmpz(acb_t z, const fmpz_t x) - void acb_set_arb(acb_t z, const arb_t c) - void acb_set_fmpq(acb_t z, const fmpq_t x, long prec) - void acb_set_round(acb_t z, const acb_t x, long prec) - void acb_set_round_fmpz(acb_t z, const fmpz_t x, long prec) - void acb_set_round_arb(acb_t z, const arb_t x, long prec) - void acb_swap(acb_t z, acb_t x) - - void acb_print(const acb_t x) - void acb_printd(const acb_t z, long digits) - - # void acb_randtest(acb_t z, flint_rand_t state, long prec, long mag_bits) - # void acb_randtest_special(acb_t z, flint_rand_t state, long prec, long mag_bits) - # void acb_randtest_precise(acb_t z, flint_rand_t state, long prec, long mag_bits) - # void acb_randtest_param(acb_t z, flint_rand_t state, long prec, long mag_bits) - - bint acb_equal(const acb_t x, const acb_t y) - bint acb_eq(const acb_t x, const acb_t y) - bint acb_ne(const acb_t x, const acb_t y) - bint acb_overlaps(const acb_t x, const acb_t y) - void acb_union(acb_t z, const acb_t x, const acb_t y, long prec) - void acb_get_abs_ubound_arf(arf_t u, const acb_t z, long prec) - void acb_get_abs_lbound_arf(arf_t u, const acb_t z, long prec) - void acb_get_rad_ubound_arf(arf_t u, const acb_t z, long prec) - void acb_get_mag(mag_t u, const acb_t x) - void acb_get_mag_lower(mag_t u, const acb_t x) - bint acb_contains_fmpq(const acb_t x, const fmpq_t y) - bint acb_contains_fmpz(const acb_t x, const fmpz_t y) - bint acb_contains(const acb_t x, const acb_t y) - bint acb_contains_zero(const acb_t x) - bint acb_contains_int(const acb_t x) - - long acb_rel_error_bits(const acb_t x) - long acb_rel_accuracy_bits(const acb_t x) - long acb_bits(const acb_t x) - void acb_indeterminate(acb_t x) - void acb_trim(acb_t y, const acb_t x) - bint acb_is_real(const acb_t x) - bint acb_get_unique_fmpz(fmpz_t z, const acb_t x) - - void acb_arg(arb_t r, const acb_t z, long prec) - void acb_abs(arb_t r, const acb_t z, long prec) - - void acb_neg(acb_t z, const acb_t x) - void acb_conj(acb_t z, const acb_t x) - void acb_add_ui(acb_t z, const acb_t x, unsigned long y, long prec) - void acb_add_fmpz(acb_t z, const acb_t x, const fmpz_t y, long prec) - void acb_add_arb(acb_t z, const acb_t x, const arb_t y, long prec) - void acb_add(acb_t z, const acb_t x, const acb_t y, long prec) - void acb_sub_ui(acb_t z, const acb_t x, unsigned long y, long prec) - void acb_sub_fmpz(acb_t z, const acb_t x, const fmpz_t y, long prec) - void acb_sub_arb(acb_t z, const acb_t x, const arb_t y, long prec) - void acb_sub(acb_t z, const acb_t x, const acb_t y, long prec) - void acb_mul_onei(acb_t z, const acb_t x) - void acb_div_onei(acb_t z, const acb_t x) - void acb_mul_ui(acb_t z, const acb_t x, unsigned long y, long prec) - void acb_mul_si(acb_t z, const acb_t x, long y, long prec) - void acb_mul_fmpz(acb_t z, const acb_t x, const fmpz_t y, long prec) - void acb_mul_arb(acb_t z, const acb_t x, const arb_t y, long prec) - void acb_mul(acb_t z, const acb_t x, const acb_t y, long prec) - void acb_mul_2exp_si(acb_t z, const acb_t x, long e) - void acb_mul_2exp_fmpz(acb_t z, const acb_t x, const fmpz_t e) - void acb_cube(acb_t z, const acb_t x, long prec) - void acb_addmul(acb_t z, const acb_t x, const acb_t y, long prec) - void acb_addmul_ui(acb_t z, const acb_t x, unsigned long y, long prec) - void acb_addmul_si(acb_t z, const acb_t x, long y, long prec) - void acb_addmul_fmpz(acb_t z, const acb_t x, const fmpz_t y, long prec) - void acb_addmul_arb(acb_t z, const acb_t x, const arb_t y, long prec) - void acb_submul(acb_t z, const acb_t x, const acb_t y, long prec) - void acb_submul_ui(acb_t z, const acb_t x, unsigned long y, long prec) - void acb_submul_si(acb_t z, const acb_t x, long y, long prec) - void acb_submul_fmpz(acb_t z, const acb_t x, const fmpz_t y, long prec) - void acb_submul_arb(acb_t z, const acb_t x, const arb_t y, long prec) - void acb_inv(acb_t z, const acb_t x, long prec) - void acb_div_ui(acb_t z, const acb_t x, unsigned long y, long prec) - void acb_div_si(acb_t z, const acb_t x, long y, long prec) - void acb_div_fmpz(acb_t z, const acb_t x, const fmpz_t y, long prec) - void acb_div(acb_t z, const acb_t x, const acb_t y, long prec) - - void acb_const_pi(acb_t y, long prec) - - void acb_sqrt(acb_t r, const acb_t z, long prec) - void acb_rsqrt(acb_t r, const acb_t z, long prec) - void acb_pow_fmpz(acb_t y, const acb_t b, const fmpz_t e, long prec) - void acb_pow_ui(acb_t y, const acb_t b, unsigned long e, long prec) - void acb_pow_si(acb_t y, const acb_t b, long e, long prec) - void acb_pow_arb(acb_t z, const acb_t x, const arb_t y, long prec) - void acb_pow(acb_t z, const acb_t x, const acb_t y, long prec) - - void acb_exp(acb_t y, const acb_t z, long prec) - void acb_exp_pi_i(acb_t y, const acb_t z, long prec) - void acb_exp_invexp(acb_t s, acb_t t, const acb_t z, long prec) - void acb_log(acb_t y, const acb_t z, long prec) - void acb_log1p(acb_t z, const acb_t x, long prec) - - void acb_sin(acb_t s, const acb_t z, long prec) - void acb_cos(acb_t c, const acb_t z, long prec) - void acb_sin_cos(arb_t s, arb_t c, const acb_t z, long prec) - void acb_tan(acb_t s, const acb_t z, long prec) - void acb_cot(acb_t s, const acb_t z, long prec) - void acb_sec(acb_t s, const acb_t z, long prec) - void acb_csc(acb_t c, const acb_t z, long prec) - void acb_sin_pi(acb_t s, const acb_t z, long prec) - void acb_cos_pi(acb_t s, const acb_t z, long prec) - void acb_sin_cos_pi(acb_t s, acb_t c, const acb_t z, long prec) - void acb_tan_pi(acb_t s, const acb_t z, long prec) - void acb_cot_pi(acb_t s, const acb_t z, long prec) - - void acb_asin(acb_t s, const acb_t z, long prec) - void acb_acos(acb_t s, const acb_t z, long prec) - void acb_atan(acb_t s, const acb_t z, long prec) - void acb_asinh(acb_t s, const acb_t z, long prec) - void acb_acosh(acb_t s, const acb_t z, long prec) - void acb_atanh(acb_t s, const acb_t z, long prec) - - void acb_lambertw(acb_t res, const acb_t z, const fmpz_t k, int flags, long prec) - - void acb_sinh(acb_t s, const acb_t z, long prec) - void acb_cosh(acb_t c, const acb_t z, long prec) - void acb_sinh_cosh(acb_t s, acb_t c, const acb_t z, long prec) - void acb_tanh(acb_t s, const acb_t z, long prec) - void acb_coth(acb_t s, const acb_t z, long prec) - void acb_sech(acb_t s, const acb_t z, long prec) - void acb_csch(acb_t c, const acb_t z, long prec) - - void acb_rising(acb_t z, const acb_t x, const acb_t n, long prec) - - void acb_gamma(acb_t y, const acb_t x, long prec) - void acb_rgamma(acb_t y, const acb_t x, long prec) - void acb_lgamma(acb_t y, const acb_t x, long prec) - void acb_digamma(acb_t y, const acb_t x, long prec) - void acb_log_sin_pi(acb_t res, const acb_t z, long prec) - void acb_polygamma(acb_t z, const acb_t s, const acb_t z, long prec) - void acb_barnes_g(acb_t res, const acb_t z, long prec) - void acb_log_barnes_g(acb_t res, const acb_t z, long prec) - - void acb_zeta(acb_t z, const acb_t s, long prec) - void acb_hurwitz_zeta(acb_t z, const acb_t s, const acb_t a, long prec) - - void acb_polylog(acb_t w, const acb_t s, const acb_t z, long prec) - void acb_polylog_si(acb_t w, long s, const acb_t z, long prec) - - void acb_agm1(acb_t m, const acb_t z, long prec) - void acb_agm1_cpx(acb_ptr m, const acb_t z, long len, long prec) - - acb_ptr _acb_vec_init(long n) - void _acb_vec_sort_pretty(acb_ptr vec, long len) - void _acb_vec_clear(acb_ptr v, long n) +# Deprecated header file; use sage/libs/flint/acb.pxd instead +# See https://github.com/sagemath/sage/pull/36449 + +from sage.libs.flint.acb cimport ( + acb_realref, + acb_imagref, + acb_init, + acb_clear, + _acb_vec_init, + _acb_vec_clear, + acb_is_zero, + acb_is_one, + acb_is_finite, + acb_is_exact, + acb_is_int, + acb_zero, + acb_one, + acb_onei, + acb_set, + acb_set_ui, + acb_set_si, + acb_set_fmpz, + acb_set_arb, + acb_set_fmpq, + acb_set_round, + acb_set_round_fmpz, + acb_set_round_arb, + acb_swap, + acb_print, + acb_printd, + acb_randtest, + acb_randtest_special, + acb_randtest_precise, + acb_randtest_param, + acb_equal, + acb_eq, + acb_ne, + acb_overlaps, + acb_union, + acb_get_abs_ubound_arf, + acb_get_abs_lbound_arf, + acb_get_rad_ubound_arf, + acb_get_mag, + acb_get_mag_lower, + acb_contains_fmpq, + acb_contains_fmpz, + acb_contains, + acb_contains_zero, + acb_contains_int, + acb_rel_error_bits, + acb_rel_accuracy_bits, + acb_bits, + acb_indeterminate, + acb_trim, + acb_is_real, + acb_get_unique_fmpz, + acb_arg, + acb_abs, + acb_neg, + acb_conj, + acb_add_ui, + acb_add_fmpz, + acb_add_arb, + acb_add, + acb_sub_ui, + acb_sub_fmpz, + acb_sub_arb, + acb_sub, + acb_mul_onei, + acb_div_onei, + acb_mul_ui, + acb_mul_si, + acb_mul_fmpz, + acb_mul_arb, + acb_mul, + acb_mul_2exp_si, + acb_mul_2exp_fmpz, + acb_cube, + acb_addmul, + acb_addmul_ui, + acb_addmul_si, + acb_addmul_fmpz, + acb_addmul_arb, + acb_submul, + acb_submul_ui, + acb_submul_si, + acb_submul_fmpz, + acb_submul_arb, + acb_inv, + acb_div_ui, + acb_div_si, + acb_div_fmpz, + acb_div, + acb_const_pi, + acb_sqrt, + acb_rsqrt, + acb_pow_fmpz, + acb_pow_ui, + acb_pow_si, + acb_pow_arb, + acb_pow, + acb_exp, + acb_exp_pi_i, + acb_exp_invexp, + acb_log, + acb_log1p, + acb_sin, + acb_cos, + acb_sin_cos, + acb_tan, + acb_cot, + acb_sec, + acb_csc, + acb_sin_pi, + acb_cos_pi, + acb_sin_cos_pi, + acb_tan_pi, + acb_cot_pi, + acb_asin, + acb_acos, + acb_atan, + acb_asinh, + acb_acosh, + acb_atanh, + acb_lambertw, + acb_sinh, + acb_cosh, + acb_sinh_cosh, + acb_tanh, + acb_coth, + acb_sech, + acb_csch, + acb_rising_ui, + acb_rising, + acb_gamma, + acb_rgamma, + acb_lgamma, + acb_digamma, + acb_log_sin_pi, + acb_polygamma, + acb_barnes_g, + acb_log_barnes_g, + acb_zeta, + acb_hurwitz_zeta, + acb_polylog, + acb_polylog_si, + acb_agm1, + acb_agm1_cpx, + _acb_vec_init, + _acb_vec_sort_pretty, + _acb_vec_clear) diff --git a/src/sage/libs/arb/acb_calc.pxd b/src/sage/libs/arb/acb_calc.pxd index 67bd2ed57dc..4e01ac77cc4 100644 --- a/src/sage/libs/arb/acb_calc.pxd +++ b/src/sage/libs/arb/acb_calc.pxd @@ -1,21 +1,6 @@ -# distutils: libraries = gmp flint -# distutils: depends = acb_calc.h +# Deprecated header file; use sage/libs/flint/acb_calc.pxd instead +# See https://github.com/sagemath/sage/pull/36449 -from sage.libs.arb.types cimport * -from sage.libs.flint.types cimport fmpz_t, fmpq_t - -# acb_calc.h -cdef extern from "arb_wrap.h": - - void acb_calc_integrate_opt_init(acb_calc_integrate_opt_t options) - - int acb_calc_integrate( - acb_t res, - acb_calc_func_t func, - void * param, - const acb_t a, - const acb_t b, - long rel_goal, - const mag_t abs_tol, - const acb_calc_integrate_opt_t options, - long prec) +from sage.libs.flint.acb_calc cimport ( + acb_calc_integrate, + acb_calc_integrate_opt_init) diff --git a/src/sage/libs/arb/acb_elliptic.pxd b/src/sage/libs/arb/acb_elliptic.pxd index e3480e9f73b..d1899d64b94 100644 --- a/src/sage/libs/arb/acb_elliptic.pxd +++ b/src/sage/libs/arb/acb_elliptic.pxd @@ -1,29 +1,24 @@ -# distutils: libraries = gmp flint -# distutils: depends = acb_elliptic.h - -from sage.libs.arb.types cimport * - -# acb_elliptic.h -cdef extern from "arb_wrap.h": - void acb_elliptic_k(acb_t k, const acb_t m, long prec) - void acb_elliptic_k_jet(acb_ptr w, const acb_t m, long len, long prec) - void acb_elliptic_k_series(acb_poly_t res, const acb_poly_t m, long len, long prec) - void acb_elliptic_e(acb_t res, const acb_t m, long prec) - void acb_elliptic_rf(acb_t res, const acb_t x, const acb_t y, const acb_t z, int flags, long prec) - void acb_elliptic_rj(acb_t res, const acb_t x, const acb_t y, const acb_t z, const acb_t p, int flags, long prec) - void acb_elliptic_rg(acb_t res, const acb_t x, const acb_t y, const acb_t z, int flags, long prec) - void acb_elliptic_rc1(acb_t res, const acb_t x, long prec) - void acb_elliptic_f(acb_t res, const acb_t phi, const acb_t m, int times_pi, long prec) - void acb_elliptic_e_inc(acb_t res, const acb_t phi, const acb_t m, int times_pi, long prec) - void acb_elliptic_pi(acb_t r, const acb_t n, const acb_t m, long prec) - void acb_elliptic_pi_inc(acb_t res, const acb_t n, const acb_t phi, const acb_t m, int times_pi, long prec) - void acb_elliptic_p(acb_t r, const acb_t z, const acb_t tau, long prec) - void acb_elliptic_p_jet(acb_ptr r, const acb_t z, const acb_t tau, long len, long prec) - void acb_elliptic_p_series(acb_poly_t res, const acb_poly_t z, const acb_t tau, long len, long prec) - void acb_elliptic_zeta(acb_t res, const acb_t z, const acb_t tau, long prec) - void acb_elliptic_sigma(acb_t res, const acb_t z, const acb_t tau, long prec) - void acb_elliptic_roots(acb_t e1, acb_t e2, acb_t e3, const acb_t tau, long prec) - void acb_elliptic_invariants(acb_t g2, acb_t g3, const acb_t tau, long prec) - void acb_elliptic_inv_p(acb_t res, const acb_t z, const acb_t tau, long prec) - +# Deprecated header file; use sage/libs/flint/acb_elliptic.pxd instead +# See https://github.com/sagemath/sage/pull/36449 +from sage.libs.flint.acb_elliptic cimport ( + acb_elliptic_k, + acb_elliptic_k_jet, + acb_elliptic_k_series, + acb_elliptic_e, + acb_elliptic_rf, + acb_elliptic_rj, + acb_elliptic_rg, + acb_elliptic_rc1, + acb_elliptic_f, + acb_elliptic_e_inc, + acb_elliptic_pi, + acb_elliptic_pi_inc, + acb_elliptic_p, + acb_elliptic_p_jet, + acb_elliptic_p_series, + acb_elliptic_zeta, + acb_elliptic_sigma, + acb_elliptic_roots, + acb_elliptic_invariants, + acb_elliptic_inv_p) diff --git a/src/sage/libs/arb/acb_hypgeom.pxd b/src/sage/libs/arb/acb_hypgeom.pxd index c43e5c0623b..641dd595004 100644 --- a/src/sage/libs/arb/acb_hypgeom.pxd +++ b/src/sage/libs/arb/acb_hypgeom.pxd @@ -1,77 +1,73 @@ -# distutils: libraries = gmp flint -# distutils: depends = acb_hypgeom.h - -from sage.libs.arb.types cimport * - -# acb_hypgeom.h -cdef extern from "arb_wrap.h": - void acb_hypgeom_pfq_bound_factor(mag_t C, acb_srcptr a, long p, acb_srcptr b, long q, const acb_t z, unsigned long n) - long acb_hypgeom_pfq_choose_n(acb_srcptr a, long p, acb_srcptr b, long q, const acb_t z, long prec) - void acb_hypgeom_pfq_sum_forward(acb_t s, acb_t t, acb_srcptr a, long p, acb_srcptr b, long q, const acb_t z, long n, long prec) - void acb_hypgeom_pfq_sum_rs(acb_t s, acb_t t, acb_srcptr a, long p, acb_srcptr b, long q, const acb_t z, long n, long prec) - void acb_hypgeom_pfq_sum_bs(acb_t s, acb_t t, acb_srcptr a, long p, acb_srcptr b, long q, const acb_t z, long n, long prec) - void acb_hypgeom_pfq_sum_fme(acb_t s, acb_t t, acb_srcptr a, long p, acb_srcptr b, long q, const acb_t z, long n, long prec) - void acb_hypgeom_pfq_sum(acb_t s, acb_t t, acb_srcptr a, long p, acb_srcptr b, long q, const acb_t z, long n, long prec) - void acb_hypgeom_pfq_sum_bs_invz(acb_t s, acb_t t, acb_srcptr a, long p, acb_srcptr b, long q, const acb_t w, long n, long prec) - void acb_hypgeom_pfq_sum_invz(acb_t s, acb_t t, acb_srcptr a, long p, acb_srcptr b, long q, const acb_t z, const acb_t w, long n, long prec) - void acb_hypgeom_pfq_direct(acb_t res, acb_srcptr a, long p, acb_srcptr b, long q, const acb_t z, long n, long prec) - # void acb_hypgeom_pfq_series_direct(acb_poly_t res, const acb_poly_struct * a, long p, const acb_poly_struct * b, long q, const acb_poly_t z, int regularized, long n, long len, long prec) - void acb_hypgeom_u_asymp(acb_t res, const acb_t a, const acb_t b, const acb_t z, long n, long prec) - bint acb_hypgeom_u_use_asymp(const acb_t z, long prec) - # void acb_hypgeom_u_1f1_series(acb_poly_t res, const acb_poly_t a, const acb_poly_t b, const acb_poly_t z, long len, long prec) - void acb_hypgeom_u_1f1(acb_t res, const acb_t a, const acb_t b, const acb_t z, long prec) - void acb_hypgeom_u(acb_t res, const acb_t a, const acb_t b, const acb_t z, long prec) - void acb_hypgeom_m_asymp(acb_t res, const acb_t a, const acb_t b, const acb_t z, bint regularized, long prec) - void acb_hypgeom_m_1f1(acb_t res, const acb_t a, const acb_t b, const acb_t z, bint regularized, long prec) - void acb_hypgeom_m(acb_t res, const acb_t a, const acb_t b, const acb_t z, bint regularized, long prec) - void acb_hypgeom_erf_1f1a(acb_t res, const acb_t z, long prec) - void acb_hypgeom_erf_1f1b(acb_t res, const acb_t z, long prec) - void acb_hypgeom_erf_asymp(acb_t res, const acb_t z, long prec, long prec2) - void acb_hypgeom_erf(acb_t res, const acb_t z, long prec) - void acb_hypgeom_erfc(acb_t res, const acb_t z, long prec) - void acb_hypgeom_erfi(acb_t res, const acb_t z, long prec) - void acb_hypgeom_bessel_j_asymp(acb_t res, const acb_t nu, const acb_t z, long prec) - void acb_hypgeom_bessel_j_0f1(acb_t res, const acb_t nu, const acb_t z, long prec) - void acb_hypgeom_bessel_j(acb_t res, const acb_t nu, const acb_t z, long prec) - void acb_hypgeom_bessel_jy(acb_t res1, acb_t res2, const acb_t nu, const acb_t z, long prec) - void acb_hypgeom_bessel_y(acb_t res, const acb_t nu, const acb_t z, long prec) - void acb_hypgeom_bessel_i_asymp(acb_t res, const acb_t nu, const acb_t z, long prec) - void acb_hypgeom_bessel_i_0f1(acb_t res, const acb_t nu, const acb_t z, long prec) - void acb_hypgeom_bessel_i(acb_t res, const acb_t nu, const acb_t z, long prec) - void acb_hypgeom_bessel_k_asymp(acb_t res, const acb_t nu, const acb_t z, long prec) - # void acb_hypgeom_bessel_k_0f1_series(acb_poly_t res, const acb_poly_t nu, const acb_poly_t z, long len, long prec) - void acb_hypgeom_bessel_k_0f1(acb_t res, const acb_t nu, const acb_t z, long prec) - void acb_hypgeom_bessel_k(acb_t res, const acb_t nu, const acb_t z, long prec) - void acb_hypgeom_gamma_upper_asymp(acb_t res, const acb_t s, const acb_t z, bint modified, long prec) - void acb_hypgeom_gamma_upper_1f1a(acb_t res, const acb_t s, const acb_t z, bint modified, long prec) - void acb_hypgeom_gamma_upper_1f1b(acb_t res, const acb_t s, const acb_t z, bint modified, long prec) - void acb_hypgeom_gamma_upper_singular(acb_t res, long s, const acb_t z, bint modified, long prec) - void acb_hypgeom_gamma_upper(acb_t res, const acb_t s, const acb_t z, bint modified, long prec) - void acb_hypgeom_expint(acb_t res, const acb_t s, const acb_t z, long prec) - void acb_hypgeom_ei_asymp(acb_t res, const acb_t z, long prec) - void acb_hypgeom_ei_2f2(acb_t res, const acb_t z, long prec) - void acb_hypgeom_ei(acb_t res, const acb_t z, long prec) - void acb_hypgeom_si_asymp(acb_t res, const acb_t z, long prec) - void acb_hypgeom_si_1f2(acb_t res, const acb_t z, long prec) - void acb_hypgeom_si(acb_t res, const acb_t z, long prec) - void acb_hypgeom_ci_asymp(acb_t res, const acb_t z, long prec) - void acb_hypgeom_ci_2f3(acb_t res, const acb_t z, long prec) - void acb_hypgeom_ci(acb_t res, const acb_t z, long prec) - void acb_hypgeom_shi(acb_t res, const acb_t z, long prec) - void acb_hypgeom_chi_asymp(acb_t res, const acb_t z, long prec) - void acb_hypgeom_chi_2f3(acb_t res, const acb_t z, long prec) - void acb_hypgeom_chi(acb_t res, const acb_t z, long prec) - void acb_hypgeom_li(acb_t res, const acb_t z, int offset, long prec) - void acb_hypgeom_0f1(acb_t res, const acb_t b, const acb_t z, bint regularized, long prec) - void acb_hypgeom_2f1(acb_t res, const acb_t a, const acb_t b, const acb_t z, const acb_t z, bint regularized, long prec) - void acb_hypgeom_legendre_p(acb_t res, const acb_t n, const acb_t m, const acb_t z, int type, long prec) - void acb_hypgeom_legendre_q(acb_t res, const acb_t n, const acb_t m, const acb_t z, int type, long prec) - void acb_hypgeom_jacobi_p(acb_t res, const acb_t n, const acb_t a, const acb_t b, const acb_t z, long prec) - void acb_hypgeom_gegenbauer_c(acb_t res, const acb_t n, const acb_t m, const acb_t z, long prec) - void acb_hypgeom_laguerre_l(acb_t res, const acb_t n, const acb_t m, const acb_t z, long prec) - void acb_hypgeom_hermite_h(acb_t res, const acb_t n, const acb_t z, long prec) - void acb_hypgeom_chebyshev_t(acb_t res, const acb_t n, const acb_t z, long prec) - void acb_hypgeom_chebyshev_u(acb_t res, const acb_t n, const acb_t z, long prec) - void acb_hypgeom_spherical_y(acb_t res, long n, long m, const acb_t theta, const acb_t phi, long prec) - void acb_hypgeom_airy(acb_t ai, acb_t aip, acb_t bi, acb_t bip, const acb_t z, long prec) +# Deprecated header file; use sage/libs/flint/acb_hypgeom.pxd instead +# See https://github.com/sagemath/sage/pull/36449 +from sage.libs.flint.acb_hypgeom cimport ( + acb_hypgeom_pfq_bound_factor, + acb_hypgeom_pfq_choose_n, + acb_hypgeom_pfq_sum_forward, + acb_hypgeom_pfq_sum_rs, + acb_hypgeom_pfq_sum_bs, + acb_hypgeom_pfq_sum_fme, + acb_hypgeom_pfq_sum, + acb_hypgeom_pfq_sum_bs_invz, + acb_hypgeom_pfq_sum_invz, + acb_hypgeom_pfq_direct, + acb_hypgeom_pfq_series_direct, + acb_hypgeom_u_asymp, + acb_hypgeom_u_use_asymp, + acb_hypgeom_u_1f1_series, + acb_hypgeom_u_1f1, + acb_hypgeom_u, + acb_hypgeom_m_asymp, + acb_hypgeom_m_1f1, + acb_hypgeom_m, + acb_hypgeom_erf_1f1a, + acb_hypgeom_erf_1f1b, + acb_hypgeom_erf_asymp, + acb_hypgeom_erf, + acb_hypgeom_erfc, + acb_hypgeom_erfi, + acb_hypgeom_bessel_j_asymp, + acb_hypgeom_bessel_j_0f1, + acb_hypgeom_bessel_j, + acb_hypgeom_bessel_jy, + acb_hypgeom_bessel_y, + acb_hypgeom_bessel_i_asymp, + acb_hypgeom_bessel_i_0f1, + acb_hypgeom_bessel_i, + acb_hypgeom_bessel_k_asymp, + acb_hypgeom_bessel_k_0f1_series, + acb_hypgeom_bessel_k_0f1, + acb_hypgeom_bessel_k, + acb_hypgeom_gamma_upper_asymp, + acb_hypgeom_gamma_upper_1f1a, + acb_hypgeom_gamma_upper_1f1b, + acb_hypgeom_gamma_upper_singular, + acb_hypgeom_gamma_upper, + acb_hypgeom_expint, + acb_hypgeom_ei_asymp, + acb_hypgeom_ei_2f2, + acb_hypgeom_ei, + acb_hypgeom_si_asymp, + acb_hypgeom_si_1f2, + acb_hypgeom_si, + acb_hypgeom_ci_asymp, + acb_hypgeom_ci_2f3, + acb_hypgeom_ci, + acb_hypgeom_shi, + acb_hypgeom_chi_asymp, + acb_hypgeom_chi_2f3, + acb_hypgeom_chi, + acb_hypgeom_li, + acb_hypgeom_0f1, + acb_hypgeom_2f1, + acb_hypgeom_legendre_p, + acb_hypgeom_legendre_q, + acb_hypgeom_jacobi_p, + acb_hypgeom_gegenbauer_c, + acb_hypgeom_laguerre_l, + acb_hypgeom_hermite_h, + acb_hypgeom_chebyshev_t, + acb_hypgeom_chebyshev_u, + acb_hypgeom_spherical_y, + acb_hypgeom_airy) diff --git a/src/sage/libs/arb/acb_mat.pxd b/src/sage/libs/arb/acb_mat.pxd index aff7fa7d7b2..40c9308f539 100644 --- a/src/sage/libs/arb/acb_mat.pxd +++ b/src/sage/libs/arb/acb_mat.pxd @@ -1,61 +1,59 @@ -# distutils: depends = acb_mat.h +# Deprecated header file; use sage/libs/flint/acb_mat.pxd instead +# See https://github.com/sagemath/sage/pull/36449 -from sage.libs.arb.types cimport acb_t, acb_ptr, acb_srcptr, acb_mat_t, acb_poly_t, mag_t - -# acb_mat.h -cdef extern from "arb_wrap.h": - unsigned int acb_mat_nrows(acb_mat_t mat) - unsigned int acb_mat_ncols(acb_mat_t mat) - acb_t acb_mat_entry(acb_mat_t mat, unsigned long i, unsigned long j) - void acb_mat_init(acb_mat_t mat, long r, long c) - void acb_mat_clear(acb_mat_t mat) - long acb_mat_allocated_bytes(const acb_mat_t x) - void acb_mat_set(acb_mat_t dest, const acb_mat_t src) - void acb_mat_printd(const acb_mat_t mat, long digits) - bint acb_mat_equal(const acb_mat_t mat1, const acb_mat_t mat2) - bint acb_mat_overlaps(const acb_mat_t mat1, const acb_mat_t mat2) - bint acb_mat_contains(const acb_mat_t mat1, const acb_mat_t mat2) - bint acb_mat_eq(const acb_mat_t mat1, const acb_mat_t mat2) - bint acb_mat_ne(const acb_mat_t mat1, const acb_mat_t mat2) - bint acb_mat_is_real(const acb_mat_t mat) - bint acb_mat_is_empty(const acb_mat_t mat) - bint acb_mat_is_square(const acb_mat_t mat) - void acb_mat_zero(acb_mat_t mat) - void acb_mat_one(acb_mat_t mat) - void acb_mat_transpose(acb_mat_t dest, const acb_mat_t src) - void acb_mat_frobenius_norm(acb_t res, const acb_mat_t A, long prec) - void acb_mat_neg(acb_mat_t dest, const acb_mat_t src) - void acb_mat_add(acb_mat_t res, const acb_mat_t mat1, const acb_mat_t mat2, long prec) - void acb_mat_sub(acb_mat_t res, const acb_mat_t mat1, const acb_mat_t mat2, long prec) - void acb_mat_mul(acb_mat_t res, const acb_mat_t mat1, const acb_mat_t mat2, long prec) - void acb_mat_mul_classical(acb_mat_t res, const acb_mat_t mat1, const acb_mat_t mat2, long prec) - void acb_mat_mul_threaded(acb_mat_t res, const acb_mat_t mat1, const acb_mat_t mat2, long prec) - void acb_mat_mul_entrywise(acb_mat_t res, const acb_mat_t mat1, const acb_mat_t mat2, long prec) - void acb_mat_sqr(acb_mat_t res, const acb_mat_t mat, long prec) - void acb_mat_pow_ui(acb_mat_t res, const acb_mat_t mat, unsigned long exp, long prec) - void acb_mat_scalar_mul_2exp_si(acb_mat_t B, const acb_mat_t A, long c) - void acb_mat_scalar_addmul_si(acb_mat_t B, const acb_mat_t A, long c, long prec) - void acb_mat_scalar_addmul_acb(acb_mat_t B, const acb_mat_t A, const acb_t c, long prec) - void acb_mat_scalar_mul_si(acb_mat_t B, const acb_mat_t A, long c, long prec) - void acb_mat_scalar_mul_acb(acb_mat_t B, const acb_mat_t A, const acb_t c, long prec) - void acb_mat_scalar_div_si(acb_mat_t B, const acb_mat_t A, long c, long prec) - void acb_mat_scalar_div_acb(acb_mat_t B, const acb_mat_t A, const acb_t c, long prec) - bint acb_mat_lu(long * perm, acb_mat_t LU, const acb_mat_t A, long prec) - void acb_mat_solve_lu_precomp(acb_mat_t X, const long * perm, const acb_mat_t LU, const acb_mat_t B, long prec) - bint acb_mat_solve(acb_mat_t X, const acb_mat_t A, const acb_mat_t B, long prec) - bint acb_mat_inv(acb_mat_t X, const acb_mat_t A, long prec) - void acb_mat_det(acb_t det, const acb_mat_t A, long prec) - void acb_mat_charpoly(acb_poly_t cp, const acb_mat_t mat, long prec) - void acb_mat_exp_taylor_sum(acb_mat_t S, const acb_mat_t A, long N, long prec) - void acb_mat_exp(acb_mat_t B, const acb_mat_t A, long prec) - void acb_mat_trace(acb_t trace, const acb_mat_t mat, long prec) - void acb_mat_get_mid(acb_mat_t B, const acb_mat_t A) - void acb_mat_add_error_mag(acb_mat_t mat, const mag_t err) - int acb_mat_approx_eig_qr(acb_ptr E, acb_mat_t L, acb_mat_t R, const acb_mat_t A, const mag_t tol, long maxiter, long prec) - void acb_mat_eig_global_enclosure(mag_t eps, const acb_mat_t A, acb_srcptr E, const acb_mat_t R, long prec) - void acb_mat_eig_enclosure_rump(acb_t lam, acb_mat_t J, acb_mat_t R, const acb_mat_t A, const acb_t lambda_approx, const acb_mat_t R_approx, long prec) - int acb_mat_eig_simple_rump(acb_ptr E, acb_mat_t L, acb_mat_t R, const acb_mat_t A, acb_srcptr E_approx, const acb_mat_t R_approx, long prec) - int acb_mat_eig_simple_vdhoeven_mourrain(acb_ptr E, acb_mat_t L, acb_mat_t R, const acb_mat_t A, acb_srcptr E_approx, const acb_mat_t R_approx, long prec) - int acb_mat_eig_simple(acb_ptr E, acb_mat_t L, acb_mat_t R, const acb_mat_t A, acb_srcptr E_approx, const acb_mat_t R_approx, long prec) - int acb_mat_eig_multiple_rump(acb_ptr E, const acb_mat_t A, acb_srcptr E_approx, const acb_mat_t R_approx, long prec) - int acb_mat_eig_multiple(acb_ptr E, const acb_mat_t A, acb_srcptr E_approx, const acb_mat_t R_approx, long prec) +from sage.libs.flint.acb_mat cimport ( + acb_mat_nrows, + acb_mat_ncols, + acb_mat_entry, + acb_mat_init, + acb_mat_clear, + acb_mat_allocated_bytes, + acb_mat_set, + acb_mat_printd, + acb_mat_equal, + acb_mat_overlaps, + acb_mat_contains, + acb_mat_eq, + acb_mat_ne, + acb_mat_is_real, + acb_mat_is_empty, + acb_mat_is_square, + acb_mat_zero, + acb_mat_one, + acb_mat_transpose, + acb_mat_frobenius_norm, + acb_mat_neg, + acb_mat_add, + acb_mat_sub, + acb_mat_mul, + acb_mat_mul_classical, + acb_mat_mul_threaded, + acb_mat_mul_entrywise, + acb_mat_sqr, + acb_mat_pow_ui, + acb_mat_scalar_mul_2exp_si, + acb_mat_scalar_addmul_si, + acb_mat_scalar_addmul_acb, + acb_mat_scalar_mul_si, + acb_mat_scalar_mul_acb, + acb_mat_scalar_div_si, + acb_mat_scalar_div_acb, + acb_mat_lu, + acb_mat_solve_lu_precomp, + acb_mat_solve, + acb_mat_inv, + acb_mat_det, + acb_mat_charpoly, + acb_mat_exp_taylor_sum, + acb_mat_exp, + acb_mat_trace, + acb_mat_get_mid, + acb_mat_add_error_mag, + acb_mat_approx_eig_qr, + acb_mat_eig_global_enclosure, + acb_mat_eig_enclosure_rump, + acb_mat_eig_simple_rump, + acb_mat_eig_simple_vdhoeven_mourrain, + acb_mat_eig_simple, + acb_mat_eig_multiple_rump, + acb_mat_eig_multiple) diff --git a/src/sage/libs/arb/acb_modular.pxd b/src/sage/libs/arb/acb_modular.pxd index cdc413c92da..46ef451ddd4 100644 --- a/src/sage/libs/arb/acb_modular.pxd +++ b/src/sage/libs/arb/acb_modular.pxd @@ -1,21 +1,16 @@ -# distutils: libraries = gmp flint -# distutils: depends = acb_modular.h - -from sage.libs.arb.types cimport * -from sage.libs.flint.types cimport fmpz_poly_t - -# acb_modular.h -cdef extern from "arb_wrap.h": - void acb_modular_theta(acb_t theta1, acb_t theta2, acb_t theta3, acb_t theta4, const acb_t z, const acb_t tau, long prec) - void acb_modular_j(acb_t z, const acb_t tau, long prec) - void acb_modular_eta(acb_t z, const acb_t tau, long prec) - void acb_modular_lambda(acb_t r, const acb_t tau, long prec) - void acb_modular_delta(acb_t r, const acb_t tau, long prec) - void acb_modular_eisenstein(acb_ptr r, const acb_t tau, long len, long prec) - void acb_modular_elliptic_p(acb_t r, const acb_t z, const acb_t tau, long prec) - void acb_modular_elliptic_p_zpx(acb_ptr r, const acb_t z, const acb_t tau, long len, long prec) - void acb_modular_elliptic_k(acb_t k, const acb_t m, long prec) - void acb_modular_elliptic_k_cpx(acb_ptr w, const acb_t m, long len, long prec) - void acb_modular_elliptic_e(acb_t res, const acb_t m, long prec) - void acb_modular_hilbert_class_poly(fmpz_poly_t res, long D) +# Deprecated header file; use sage/libs/flint/acb_modular.pxd instead +# See https://github.com/sagemath/sage/pull/36449 +from sage.libs.flint.acb_modular cimport ( + acb_modular_theta, + acb_modular_j, + acb_modular_eta, + acb_modular_lambda, + acb_modular_delta, + acb_modular_eisenstein, + acb_modular_elliptic_p, + acb_modular_elliptic_p_zpx, + acb_modular_elliptic_k, + acb_modular_elliptic_k_cpx, + acb_modular_elliptic_e, + acb_modular_hilbert_class_poly) diff --git a/src/sage/libs/arb/acb_poly.pxd b/src/sage/libs/arb/acb_poly.pxd index ae02757ffd9..00e430cc50a 100644 --- a/src/sage/libs/arb/acb_poly.pxd +++ b/src/sage/libs/arb/acb_poly.pxd @@ -1,223 +1,219 @@ -# distutils: libraries = gmp flint -# distutils: depends = acb_poly.h +# Deprecated header file; use sage/libs/flint/acb_poly.pxd instead +# See https://github.com/sagemath/sage/pull/36449 -from sage.libs.arb.types cimport * -from sage.libs.flint.types cimport fmpz_t, fmpz_poly_t, fmpq_poly_t - -# acb_poly.h -cdef extern from "arb_wrap.h": - void acb_poly_init(acb_poly_t poly) - void acb_poly_clear(acb_poly_t poly) - void acb_poly_fit_length(acb_poly_t poly, long len) - void _acb_poly_set_length(acb_poly_t poly, long len) - void _acb_poly_normalise(acb_poly_t poly) - void acb_poly_swap(acb_poly_t poly1, acb_poly_t poly2) - long acb_poly_length(const acb_poly_t poly) - long acb_poly_degree(const acb_poly_t poly) - bint acb_poly_is_zero(const acb_poly_t poly) - bint acb_poly_is_one(const acb_poly_t poly) - bint acb_poly_is_x(const acb_poly_t poly) - void acb_poly_zero(acb_poly_t poly) - void acb_poly_one(acb_poly_t poly) - void acb_poly_set(acb_poly_t dest, const acb_poly_t src) - void acb_poly_set_round(acb_poly_t dest, const acb_poly_t src, long prec) - void acb_poly_set_coeff_si(acb_poly_t poly, long n, long c) - void acb_poly_set_coeff_acb(acb_poly_t poly, long n, const acb_t c) - void acb_poly_get_coeff_acb(acb_t v, const acb_poly_t poly, long n) - acb_ptr acb_poly_get_coeff_ptr(acb_poly_t, long) - void _acb_poly_shift_right(acb_ptr res, acb_srcptr poly, long len, long n) - void acb_poly_shift_right(acb_poly_t res, const acb_poly_t poly, long n) - void _acb_poly_shift_left(acb_ptr res, acb_srcptr poly, long len, long n) - void acb_poly_shift_left(acb_poly_t res, const acb_poly_t poly, long n) - void acb_poly_truncate(acb_poly_t poly, long n) - void acb_poly_printd(const acb_poly_t poly, long digits) - # void acb_poly_fprintd(FILE * file, const acb_poly_t poly, long digits) - # void acb_poly_randtest(acb_poly_t poly, flint_rand_t state, long len, long prec, long mag_bits) - bint acb_poly_equal(const acb_poly_t A, const acb_poly_t B) - bint acb_poly_contains(const acb_poly_t poly1, const acb_poly_t poly2) - bint acb_poly_contains_fmpz_poly(const acb_poly_t poly1, const fmpz_poly_t poly2) - bint acb_poly_contains_fmpq_poly(const acb_poly_t poly1, const fmpq_poly_t poly2) - bint _acb_poly_overlaps(acb_srcptr poly1, long len1, acb_srcptr poly2, long len2) - bint acb_poly_overlaps(const acb_poly_t poly1, const acb_poly_t poly2) - bint acb_poly_get_unique_fmpz_poly(fmpz_poly_t z, const acb_poly_t x) - bint acb_poly_is_real(const acb_poly_t poly) - void acb_poly_set_fmpz_poly(acb_poly_t poly, const fmpz_poly_t re, long prec) - void acb_poly_set2_fmpz_poly(acb_poly_t poly, const fmpz_poly_t re, const fmpz_poly_t im, long prec) - # void acb_poly_set_arb_poly(acb_poly_t poly, const arb_poly_t re) - # void acb_poly_set2_arb_poly(acb_poly_t poly, const arb_poly_t re, const arb_poly_t im) - void acb_poly_set_fmpq_poly(acb_poly_t poly, const fmpq_poly_t re, long prec) - void acb_poly_set2_fmpq_poly(acb_poly_t poly, const fmpq_poly_t re, const fmpq_poly_t im, long prec) - void acb_poly_set_acb(acb_poly_t poly, long src) - void acb_poly_set_si(acb_poly_t poly, long src) - # void _acb_poly_majorant(arb_ptr res, acb_srcptr poly, long len, long prec) - # void acb_poly_majorant(arb_poly_t res, const acb_poly_t poly, long prec) - void _acb_poly_add(acb_ptr C, acb_srcptr A, long lenA, acb_srcptr B, long lenB, long prec) - void acb_poly_add(acb_poly_t C, const acb_poly_t A, const acb_poly_t B, long prec) - void acb_poly_add_si(acb_poly_t C, const acb_poly_t A, long B, long prec) - void _acb_poly_sub(acb_ptr C, acb_srcptr A, long lenA, acb_srcptr B, long lenB, long prec) - void acb_poly_sub(acb_poly_t C, const acb_poly_t A, const acb_poly_t B, long prec) - void acb_poly_neg(acb_poly_t C, const acb_poly_t A) - void acb_poly_scalar_mul_2exp_si(acb_poly_t C, const acb_poly_t A, long c) - void acb_poly_scalar_mul(acb_poly_t C, const acb_poly_t A, const acb_t c, long prec) - void acb_poly_scalar_div(acb_poly_t C, const acb_poly_t A, const acb_t c, long prec) - void _acb_poly_mullow_classical(acb_ptr C, acb_srcptr A, long lenA, acb_srcptr B, long lenB, long n, long prec) - void _acb_poly_mullow_transpose(acb_ptr C, acb_srcptr A, long lenA, acb_srcptr B, long lenB, long n, long prec) - void _acb_poly_mullow_transpose_gauss(acb_ptr C, acb_srcptr A, long lenA, acb_srcptr B, long lenB, long n, long prec) - void _acb_poly_mullow(acb_ptr C, acb_srcptr A, long lenA, acb_srcptr B, long lenB, long n, long prec) - void acb_poly_mullow_classical(acb_poly_t C, const acb_poly_t A, const acb_poly_t B, long n, long prec) - void acb_poly_mullow_transpose(acb_poly_t C, const acb_poly_t A, const acb_poly_t B, long n, long prec) - void acb_poly_mullow_transpose_gauss(acb_poly_t C, const acb_poly_t A, const acb_poly_t B, long n, long prec) - void acb_poly_mullow(acb_poly_t C, const acb_poly_t A, const acb_poly_t B, long n, long prec) - void _acb_poly_mul(acb_ptr C, acb_srcptr A, long lenA, acb_srcptr B, long lenB, long prec) - void acb_poly_mul(acb_poly_t C, const acb_poly_t A1, const acb_poly_t B2, long prec) - void _acb_poly_inv_series(acb_ptr Qinv, acb_srcptr Q, long Qlen, long len, long prec) - void acb_poly_inv_series(acb_poly_t Qinv, const acb_poly_t Q, long n, long prec) - void _acb_poly_div_series(acb_ptr Q, acb_srcptr A, long Alen, acb_srcptr B, long Blen, long n, long prec) - void acb_poly_div_series(acb_poly_t Q, const acb_poly_t A, const acb_poly_t B, long n, long prec) - void _acb_poly_div(acb_ptr Q, acb_srcptr A, long lenA, acb_srcptr B, long lenB, long prec) - void _acb_poly_rem(acb_ptr R, acb_srcptr A, long lenA, acb_srcptr B, long lenB, long prec) - void _acb_poly_divrem(acb_ptr Q, acb_ptr R, acb_srcptr A, long lenA, acb_srcptr B, long lenB, long prec) - bint acb_poly_divrem(acb_poly_t Q, acb_poly_t R, const acb_poly_t A, const acb_poly_t B, long prec) - void _acb_poly_div_root(acb_ptr Q, acb_t R, acb_srcptr A, long len, const acb_t c, long prec) - void _acb_poly_taylor_shift(acb_ptr g, const acb_t c, long n, long prec) - void acb_poly_taylor_shift(acb_poly_t g, const acb_poly_t f, const acb_t c, long prec) - void _acb_poly_compose(acb_ptr res, acb_srcptr poly1, long len1, acb_srcptr poly2, long len2, long prec) - void acb_poly_compose(acb_poly_t res, const acb_poly_t poly1, const acb_poly_t poly2, long prec) - void _acb_poly_compose_series(acb_ptr res, acb_srcptr poly1, long len1, acb_srcptr poly2, long len2, long n, long prec) - void acb_poly_compose_series(acb_poly_t res, const acb_poly_t poly1, const acb_poly_t poly2, long n, long prec) - void _acb_poly_revert_series_lagrange(acb_ptr h, acb_srcptr f, long flen, long n, long prec) - void acb_poly_revert_series_lagrange(acb_poly_t h, const acb_poly_t f, long n, long prec) - void _acb_poly_revert_series_newton(acb_ptr h, acb_srcptr f, long flen, long n, long prec) - void acb_poly_revert_series_newton(acb_poly_t h, const acb_poly_t f, long n, long prec) - void _acb_poly_revert_series_lagrange_fast(acb_ptr h, acb_srcptr f, long flen, long n, long prec) - void acb_poly_revert_series_lagrange_fast(acb_poly_t h, const acb_poly_t f, long n, long prec) - void _acb_poly_revert_series(acb_ptr h, acb_srcptr f, long flen, long n, long prec) - void acb_poly_revert_series(acb_poly_t h, const acb_poly_t f, long n, long prec) - void _acb_poly_evaluate_horner(acb_t y, acb_srcptr f, long len, const acb_t x, long prec) - void acb_poly_evaluate_horner(acb_t y, const acb_poly_t f, const acb_t x, long prec) - void _acb_poly_evaluate_rectangular(acb_t y, acb_srcptr f, long len, const acb_t x, long prec) - void acb_poly_evaluate_rectangular(acb_t y, const acb_poly_t f, const acb_t x, long prec) - void _acb_poly_evaluate(acb_t y, acb_srcptr f, long len, const acb_t x, long prec) - void acb_poly_evaluate(acb_t y, const acb_poly_t f, const acb_t x, long prec) - void _acb_poly_evaluate2_horner(acb_t y, acb_t z, acb_srcptr f, long len, const acb_t x, long prec) - void acb_poly_evaluate2_horner(acb_t y, acb_t z, const acb_poly_t f, const acb_t x, long prec) - void _acb_poly_evaluate2_rectangular(acb_t y, acb_t z, acb_srcptr f, long len, const acb_t x, long prec) - void acb_poly_evaluate2_rectangular(acb_t y, acb_t z, const acb_poly_t f, const acb_t x, long prec) - void _acb_poly_evaluate2(acb_t y, acb_t z, acb_srcptr f, long len, const acb_t x, long prec) - void acb_poly_evaluate2(acb_t y, acb_t z, const acb_poly_t f, const acb_t x, long prec) - void _acb_poly_product_roots(acb_ptr poly, acb_srcptr xs, long n, long prec) - void acb_poly_product_roots(acb_poly_t poly, acb_srcptr xs, long n, long prec) - acb_ptr * _acb_poly_tree_alloc(long len) - void _acb_poly_tree_free(acb_ptr * tree, long len) - void _acb_poly_tree_build(acb_ptr * tree, acb_srcptr roots, long len, long prec) - void _acb_poly_evaluate_vec_iter(acb_ptr ys, acb_srcptr poly, long plen, acb_srcptr xs, long n, long prec) - void acb_poly_evaluate_vec_iter(acb_ptr ys, const acb_poly_t poly, acb_srcptr xs, long n, long prec) - void _acb_poly_evaluate_vec_fast_precomp(acb_ptr vs, acb_srcptr poly, long plen, acb_ptr * tree, long len, long prec) - void _acb_poly_evaluate_vec_fast(acb_ptr ys, acb_srcptr poly, long plen, acb_srcptr xs, long n, long prec) - void acb_poly_evaluate_vec_fast(acb_ptr ys, const acb_poly_t poly, acb_srcptr xs, long n, long prec) - void _acb_poly_interpolate_newton(acb_ptr poly, acb_srcptr xs, acb_srcptr ys, long n, long prec) - void acb_poly_interpolate_newton(acb_poly_t poly, acb_srcptr xs, acb_srcptr ys, long n, long prec) - void _acb_poly_interpolate_barycentric(acb_ptr poly, acb_srcptr xs, acb_srcptr ys, long n, long prec) - void acb_poly_interpolate_barycentric(acb_poly_t poly, acb_srcptr xs, acb_srcptr ys, long n, long prec) - void _acb_poly_interpolation_weights(acb_ptr w, acb_ptr * tree, long len, long prec) - void _acb_poly_interpolate_fast_precomp(acb_ptr poly, acb_srcptr ys, acb_ptr * tree, acb_srcptr weights, long len, long prec) - void _acb_poly_interpolate_fast(acb_ptr poly, acb_srcptr xs, acb_srcptr ys, long len, long prec) - void acb_poly_interpolate_fast(acb_poly_t poly, acb_srcptr xs, acb_srcptr ys, long n, long prec) - void _acb_poly_derivative(acb_ptr res, acb_srcptr poly, long len, long prec) - void acb_poly_derivative(acb_poly_t res, const acb_poly_t poly, long prec) - void _acb_poly_integral(acb_ptr res, acb_srcptr poly, long len, long prec) - void acb_poly_integral(acb_poly_t res, const acb_poly_t poly, long prec) - void _acb_poly_pow_ui_trunc_binexp(acb_ptr res, acb_srcptr f, long flen, unsigned long exp, long len, long prec) - void acb_poly_pow_ui_trunc_binexp(acb_poly_t res, const acb_poly_t poly, unsigned long exp, long len, long prec) - void _acb_poly_pow_ui(acb_ptr res, acb_srcptr f, long flen, unsigned long exp, long prec) - void acb_poly_pow_ui(acb_poly_t res, const acb_poly_t poly, unsigned long exp, long prec) - void _acb_poly_pow_series(acb_ptr h, acb_srcptr f, long flen, acb_srcptr g, long glen, long len, long prec) - void acb_poly_pow_series(acb_poly_t h, const acb_poly_t f, const acb_poly_t g, long len, long prec) - void _acb_poly_pow_acb_series(acb_ptr h, acb_srcptr f, long flen, const acb_t g, long len, long prec) - void acb_poly_pow_acb_series(acb_poly_t h, const acb_poly_t f, const acb_t g, long len, long prec) - void _acb_poly_sqrt_series(acb_ptr g, acb_srcptr h, long hlen, long n, long prec) - void acb_poly_sqrt_series(acb_poly_t g, const acb_poly_t h, long n, long prec) - void _acb_poly_rsqrt_series(acb_ptr g, acb_srcptr h, long hlen, long n, long prec) - void acb_poly_rsqrt_series(acb_poly_t g, const acb_poly_t h, long n, long prec) - void _acb_poly_log_series(acb_ptr res, acb_srcptr f, long flen, long n, long prec) - void acb_poly_log_series(acb_poly_t res, const acb_poly_t f, long n, long prec) - void _acb_poly_atan_series(acb_ptr res, acb_srcptr f, long flen, long n, long prec) - void acb_poly_atan_series(acb_poly_t res, const acb_poly_t f, long n, long prec) - void _acb_poly_exp_series_basecase(acb_ptr f, acb_srcptr h, long hlen, long n, long prec) - void acb_poly_exp_series_basecase(acb_poly_t f, const acb_poly_t h, long n, long prec) - void _acb_poly_exp_series(acb_ptr f, acb_srcptr h, long hlen, long n, long prec) - void acb_poly_exp_series(acb_poly_t f, const acb_poly_t h, long n, long prec) - void _acb_poly_sin_cos_series(acb_ptr s, acb_ptr c, acb_srcptr h, long hlen, long n, long prec) - void acb_poly_sin_cos_series(acb_poly_t s, acb_poly_t c, const acb_poly_t h, long n, long prec) - void _acb_poly_sin_series(acb_ptr s, acb_srcptr h, long hlen, long n, long prec) - void acb_poly_sin_series(acb_poly_t s, const acb_poly_t h, long n, long prec) - void _acb_poly_cos_series(acb_ptr c, acb_srcptr h, long hlen, long n, long prec) - void acb_poly_cos_series(acb_poly_t c, const acb_poly_t h, long n, long prec) - void _acb_poly_tan_series(acb_ptr g, acb_srcptr h, long hlen, long len, long prec) - void acb_poly_tan_series(acb_poly_t g, const acb_poly_t h, long n, long prec) - void _acb_poly_sin_cos_pi_series(acb_ptr s, acb_ptr c, acb_srcptr h, long hlen, long n, long prec) - void acb_poly_sin_cos_pi_series(acb_poly_t s, acb_poly_t c, const acb_poly_t h, long n, long prec) - void _acb_poly_sin_pi_series(acb_ptr s, acb_srcptr h, long hlen, long n, long prec) - void acb_poly_sin_pi_series(acb_poly_t s, const acb_poly_t h, long n, long prec) - void _acb_poly_cos_pi_series(acb_ptr c, acb_srcptr h, long hlen, long n, long prec) - void acb_poly_cos_pi_series(acb_poly_t c, const acb_poly_t h, long n, long prec) - void _acb_poly_cot_pi_series(acb_ptr c, acb_srcptr h, long hlen, long n, long prec) - void acb_poly_cot_pi_series(acb_poly_t c, const acb_poly_t h, long n, long prec) - void _acb_poly_sinh_cosh_series_basecase(acb_ptr s, acb_ptr c, acb_srcptr h, long hlen, long n, long prec) - void acb_poly_sinh_cosh_series_basecase(acb_poly_t s, acb_poly_t c, const acb_poly_t h, long n, long prec) - void _acb_poly_sinh_cosh_series_exponential(acb_ptr s, acb_ptr c, acb_srcptr h, long hlen, long n, long prec) - void acb_poly_sinh_cosh_series_exponential(acb_poly_t s, acb_poly_t c, const acb_poly_t h, long n, long prec) - void _acb_poly_sinh_cosh_series(acb_ptr s, acb_ptr c, acb_srcptr h, long hlen, long n, long prec) - void acb_poly_sinh_cosh_series(acb_poly_t s, acb_poly_t c, const acb_poly_t h, long n, long prec) - void _acb_poly_sinh_series(acb_ptr s, acb_srcptr h, long hlen, long n, long prec) - void acb_poly_sinh_series(acb_poly_t s, const acb_poly_t h, long n, long prec) - void _acb_poly_cosh_series(acb_ptr c, acb_srcptr h, long hlen, long n, long prec) - void acb_poly_cosh_series(acb_poly_t c, const acb_poly_t h, long n, long prec) - void _acb_poly_sinc_series(acb_ptr s, acb_srcptr h, long hlen, long n, long prec) - void acb_poly_sinc_series(acb_poly_t s, const acb_poly_t h, long n, long prec) - void _acb_poly_lambertw_series(acb_ptr res, acb_srcptr z, long zlen, const fmpz_t k, int flags, long len, long prec) - void acb_poly_lambertw_series(acb_poly_t res, const acb_poly_t z, const fmpz_t k, int flags, long len, long prec) - void _acb_poly_gamma_series(acb_ptr res, acb_srcptr h, long hlen, long n, long prec) - void acb_poly_gamma_series(acb_poly_t res, const acb_poly_t h, long n, long prec) - void _acb_poly_rgamma_series(acb_ptr res, acb_srcptr h, long hlen, long n, long prec) - void acb_poly_rgamma_series(acb_poly_t res, const acb_poly_t h, long n, long prec) - void _acb_poly_lgamma_series(acb_ptr res, acb_srcptr h, long hlen, long n, long prec) - void acb_poly_lgamma_series(acb_poly_t res, const acb_poly_t h, long n, long prec) - void _acb_poly_digamma_series(acb_ptr res, acb_srcptr h, long hlen, long n, long prec) - void acb_poly_digamma_series(acb_poly_t res, const acb_poly_t h, long n, long prec) - void _acb_poly_rising_ui_series(acb_ptr res, acb_srcptr f, long flen, unsigned long r, long trunc, long prec) - void acb_poly_rising_ui_series(acb_poly_t res, const acb_poly_t f, unsigned long r, long trunc, long prec) - void _acb_poly_powsum_series_naive(acb_ptr z, const acb_t s, const acb_t a, const acb_t q, long n, long len, long prec) - void _acb_poly_powsum_series_naive_threaded(acb_ptr z, const acb_t s, const acb_t a, const acb_t q, long n, long len, long prec) - void _acb_poly_powsum_one_series_sieved(acb_ptr z, const acb_t s, long n, long len, long prec) - void _acb_poly_zeta_em_choose_param(mag_t bound, unsigned long * N, unsigned long * M, const acb_t s, const acb_t a, long d, long target, long prec) - void _acb_poly_zeta_em_bound1(mag_t bound, const acb_t s, const acb_t a, long N, long M, long d, long wp) - # void _acb_poly_zeta_em_bound(arb_ptr vec, const acb_t s, const acb_t a, unsigned long N, unsigned long M, long d, long wp) - void _acb_poly_zeta_em_tail_naive(acb_ptr z, const acb_t s, const acb_t Na, acb_srcptr Nasx, long M, long len, long prec) - void _acb_poly_zeta_em_tail_bsplit(acb_ptr z, const acb_t s, const acb_t Na, acb_srcptr Nasx, long M, long len, long prec) - void _acb_poly_zeta_em_sum(acb_ptr z, const acb_t s, const acb_t a, bint deflate, unsigned long N, unsigned long M, long d, long prec) - void _acb_poly_zeta_cpx_series(acb_ptr z, const acb_t s, const acb_t a, bint deflate, long d, long prec) - void _acb_poly_zeta_series(acb_ptr res, acb_srcptr h, long hlen, const acb_t a, bint deflate, long len, long prec) - void acb_poly_zeta_series(acb_poly_t res, const acb_poly_t f, const acb_t a, bint deflate, long n, long prec) - void _acb_poly_polylog_cpx_small(acb_ptr w, const acb_t s, const acb_t z, long len, long prec) - void _acb_poly_polylog_cpx_zeta(acb_ptr w, const acb_t s, const acb_t z, long len, long prec) - void _acb_poly_polylog_cpx(acb_ptr w, const acb_t s, const acb_t z, long len, long prec) - void _acb_poly_polylog_series(acb_ptr w, acb_srcptr s, long slen, const acb_t z, long len, long prec) - void acb_poly_polylog_series(acb_poly_t w, const acb_poly_t s, const acb_t z, long len, long prec) - void _acb_poly_erf_series(acb_ptr res, acb_srcptr z, long zlen, long n, long prec) - void acb_poly_erf_series(acb_poly_t res, const acb_poly_t z, long n, long prec) - void _acb_poly_agm1_series(acb_ptr res, acb_srcptr z, long zlen, long len, long prec) - void acb_poly_agm1_series(acb_poly_t res, const acb_poly_t z, long n, long prec) - void _acb_poly_elliptic_k_series(acb_ptr res, acb_srcptr z, long zlen, long len, long prec) - void acb_poly_elliptic_k_series(acb_poly_t res, const acb_poly_t z, long n, long prec) - void _acb_poly_elliptic_p_series(acb_ptr res, acb_srcptr z, long zlen, const acb_t tau, long len, long prec) - void acb_poly_elliptic_p_series(acb_poly_t res, const acb_poly_t z, const acb_t tau, long n, long prec) - void _acb_poly_root_bound_fujiwara(mag_t bound, acb_srcptr poly, long len) - 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, long len, long prec) - long _acb_poly_validate_roots(acb_ptr roots, acb_srcptr poly, long len, long prec) - void _acb_poly_refine_roots_durand_kerner(acb_ptr roots, acb_srcptr poly, long len, long prec) - long _acb_poly_find_roots(acb_ptr roots, acb_srcptr poly, acb_srcptr initial, long len, long maxiter, long prec) - long acb_poly_find_roots(acb_ptr roots, const acb_poly_t poly, acb_srcptr initial, long maxiter, long prec) - bint _acb_poly_validate_real_roots(acb_srcptr roots, acb_srcptr poly, long len, long prec) - bint acb_poly_validate_real_roots(acb_srcptr roots, const acb_poly_t poly, long prec) +from sage.libs.flint.acb_poly cimport ( + acb_poly_init, + acb_poly_clear, + acb_poly_fit_length, + _acb_poly_set_length, + _acb_poly_normalise, + acb_poly_swap, + acb_poly_length, + acb_poly_degree, + acb_poly_is_zero, + acb_poly_is_one, + acb_poly_is_x, + acb_poly_zero, + acb_poly_one, + acb_poly_set, + acb_poly_set_round, + acb_poly_set_coeff_si, + acb_poly_set_coeff_acb, + acb_poly_get_coeff_acb, + acb_poly_get_coeff_ptr, + _acb_poly_shift_right, + acb_poly_shift_right, + _acb_poly_shift_left, + acb_poly_shift_left, + acb_poly_truncate, + acb_poly_printd, + acb_poly_fprintd, + acb_poly_randtest, + acb_poly_equal, + acb_poly_contains, + acb_poly_contains_fmpz_poly, + acb_poly_contains_fmpq_poly, + _acb_poly_overlaps, + acb_poly_overlaps, + acb_poly_get_unique_fmpz_poly, + acb_poly_is_real, + acb_poly_set_fmpz_poly, + acb_poly_set2_fmpz_poly, + acb_poly_set_arb_poly, + acb_poly_set2_arb_poly, + acb_poly_set_fmpq_poly, + acb_poly_set2_fmpq_poly, + acb_poly_set_acb, + acb_poly_set_si, + _acb_poly_majorant, + acb_poly_majorant, + _acb_poly_add, + acb_poly_add, + acb_poly_add_si, + _acb_poly_sub, + acb_poly_sub, + acb_poly_neg, + acb_poly_scalar_mul_2exp_si, + acb_poly_scalar_mul, + acb_poly_scalar_div, + _acb_poly_mullow_classical, + _acb_poly_mullow_transpose, + _acb_poly_mullow_transpose_gauss, + _acb_poly_mullow, + acb_poly_mullow_classical, + acb_poly_mullow_transpose, + acb_poly_mullow_transpose_gauss, + acb_poly_mullow, + _acb_poly_mul, + acb_poly_mul, + _acb_poly_inv_series, + acb_poly_inv_series, + _acb_poly_div_series, + acb_poly_div_series, + _acb_poly_div, + _acb_poly_rem, + _acb_poly_divrem, + acb_poly_divrem, + _acb_poly_div_root, + _acb_poly_taylor_shift, + acb_poly_taylor_shift, + _acb_poly_compose, + acb_poly_compose, + _acb_poly_compose_series, + acb_poly_compose_series, + _acb_poly_revert_series_lagrange, + acb_poly_revert_series_lagrange, + _acb_poly_revert_series_newton, + acb_poly_revert_series_newton, + _acb_poly_revert_series_lagrange_fast, + acb_poly_revert_series_lagrange_fast, + _acb_poly_revert_series, + acb_poly_revert_series, + _acb_poly_evaluate_horner, + acb_poly_evaluate_horner, + _acb_poly_evaluate_rectangular, + acb_poly_evaluate_rectangular, + _acb_poly_evaluate, + acb_poly_evaluate, + _acb_poly_evaluate2_horner, + acb_poly_evaluate2_horner, + _acb_poly_evaluate2_rectangular, + acb_poly_evaluate2_rectangular, + _acb_poly_evaluate2, + acb_poly_evaluate2, + _acb_poly_product_roots, + acb_poly_product_roots, + _acb_poly_tree_alloc, + _acb_poly_tree_free, + _acb_poly_tree_build, + _acb_poly_evaluate_vec_iter, + acb_poly_evaluate_vec_iter, + _acb_poly_evaluate_vec_fast_precomp, + _acb_poly_evaluate_vec_fast, + acb_poly_evaluate_vec_fast, + _acb_poly_interpolate_newton, + acb_poly_interpolate_newton, + _acb_poly_interpolate_barycentric, + acb_poly_interpolate_barycentric, + _acb_poly_interpolation_weights, + _acb_poly_interpolate_fast_precomp, + _acb_poly_interpolate_fast, + acb_poly_interpolate_fast, + _acb_poly_derivative, + acb_poly_derivative, + _acb_poly_integral, + acb_poly_integral, + _acb_poly_pow_ui_trunc_binexp, + acb_poly_pow_ui_trunc_binexp, + _acb_poly_pow_ui, + acb_poly_pow_ui, + _acb_poly_pow_series, + acb_poly_pow_series, + _acb_poly_pow_acb_series, + acb_poly_pow_acb_series, + _acb_poly_sqrt_series, + acb_poly_sqrt_series, + _acb_poly_rsqrt_series, + acb_poly_rsqrt_series, + _acb_poly_log_series, + acb_poly_log_series, + _acb_poly_atan_series, + acb_poly_atan_series, + _acb_poly_exp_series_basecase, + acb_poly_exp_series_basecase, + _acb_poly_exp_series, + acb_poly_exp_series, + _acb_poly_sin_cos_series, + acb_poly_sin_cos_series, + _acb_poly_sin_series, + acb_poly_sin_series, + _acb_poly_cos_series, + acb_poly_cos_series, + _acb_poly_tan_series, + acb_poly_tan_series, + _acb_poly_sin_cos_pi_series, + acb_poly_sin_cos_pi_series, + _acb_poly_sin_pi_series, + acb_poly_sin_pi_series, + _acb_poly_cos_pi_series, + acb_poly_cos_pi_series, + _acb_poly_cot_pi_series, + acb_poly_cot_pi_series, + _acb_poly_sinh_cosh_series_basecase, + acb_poly_sinh_cosh_series_basecase, + _acb_poly_sinh_cosh_series_exponential, + acb_poly_sinh_cosh_series_exponential, + _acb_poly_sinh_cosh_series, + acb_poly_sinh_cosh_series, + _acb_poly_sinh_series, + acb_poly_sinh_series, + _acb_poly_cosh_series, + acb_poly_cosh_series, + _acb_poly_sinc_series, + acb_poly_sinc_series, + _acb_poly_lambertw_series, + acb_poly_lambertw_series, + _acb_poly_gamma_series, + acb_poly_gamma_series, + _acb_poly_rgamma_series, + acb_poly_rgamma_series, + _acb_poly_lgamma_series, + acb_poly_lgamma_series, + _acb_poly_digamma_series, + acb_poly_digamma_series, + _acb_poly_rising_ui_series, + acb_poly_rising_ui_series, + _acb_poly_powsum_series_naive, + _acb_poly_powsum_series_naive_threaded, + _acb_poly_powsum_one_series_sieved, + _acb_poly_zeta_em_choose_param, + _acb_poly_zeta_em_bound1, + _acb_poly_zeta_em_bound, + _acb_poly_zeta_em_tail_naive, + _acb_poly_zeta_em_tail_bsplit, + _acb_poly_zeta_em_sum, + _acb_poly_zeta_cpx_series, + _acb_poly_zeta_series, + acb_poly_zeta_series, + _acb_poly_polylog_cpx_small, + _acb_poly_polylog_cpx_zeta, + _acb_poly_polylog_cpx, + _acb_poly_polylog_series, + acb_poly_polylog_series, + _acb_poly_erf_series, + acb_poly_erf_series, + _acb_poly_agm1_series, + acb_poly_agm1_series, + _acb_poly_elliptic_k_series, + acb_poly_elliptic_k_series, + _acb_poly_elliptic_p_series, + acb_poly_elliptic_p_series, + _acb_poly_root_bound_fujiwara, + acb_poly_root_bound_fujiwara, + _acb_poly_root_inclusion, + _acb_poly_validate_roots, + _acb_poly_refine_roots_durand_kerner, + _acb_poly_find_roots, + acb_poly_find_roots, + _acb_poly_validate_real_roots, + acb_poly_validate_real_roots) diff --git a/src/sage/libs/arb/arb.pxd b/src/sage/libs/arb/arb.pxd index acd232ab816..ca3a6ca34e7 100644 --- a/src/sage/libs/arb/arb.pxd +++ b/src/sage/libs/arb/arb.pxd @@ -1,267 +1,236 @@ -# distutils: libraries = gmp flint -# distutils: depends = arb.h - -from sage.libs.arb.types cimport * -from sage.libs.flint.types cimport fmpz_t, fmpq_t -from sage.libs.mpfr.types cimport mpfr_t - -# arb.h -cdef extern from "arb_wrap.h": - - arf_t arb_midref(arb_t x) - mag_t arb_radref(arb_t x) - - void arb_init(arb_t x) - void arb_clear(arb_t x) - void arb_swap(arb_t x, arb_t y) - - # void arb_set_fmprb(arb_t y, const fmprb_t x) - # void arb_get_fmprb(fmprb_t y, const arb_t x) - void arb_set(arb_t y, const arb_t x) - void arb_set_arf(arb_t y, const arf_t x) - void arb_set_si(arb_t y, long x) - void arb_set_ui(arb_t y, unsigned long x) - void arb_set_fmpz(arb_t y, const fmpz_t x) - void arb_set_fmpz_2exp(arb_t y, const fmpz_t x, const fmpz_t e) - void arb_set_round(arb_t y, const arb_t x, long prec) - void arb_set_round_fmpz(arb_t y, const fmpz_t x, long prec) - void arb_set_round_fmpz_2exp(arb_t y, const fmpz_t x, const fmpz_t e, long prec) - void arb_set_fmpq(arb_t y, const fmpq_t x, long prec) - int arb_set_str(arb_t res, const char * inp, long prec) - char * arb_get_str(const arb_t x, long n, unsigned long flags) - char * arb_version - - void arb_zero(arb_t x) - void arb_one(arb_t f) - void arb_pos_inf(arb_t x) - void arb_neg_inf(arb_t x) - void arb_zero_pm_inf(arb_t x) - void arb_indeterminate(arb_t x) - - void arb_print(const arb_t x) - void arb_printd(const arb_t x, long digits) - void arb_printn(const arb_t x, long digits, unsigned long flags) - - char *arb_dump_str(const arb_t x) - bint arb_load_str(arb_t x, const char *str) - - # void arb_randtest(arb_t x, flint_rand_t state, long prec, long mag_bits) - # void arb_randtest_exact(arb_t x, flint_rand_t state, long prec, long mag_bits) - # void arb_randtest_precise(arb_t x, flint_rand_t state, long prec, long mag_bits) - # void arb_randtest_wide(arb_t x, flint_rand_t state, long prec, long mag_bits) - # void arb_randtest_special(arb_t x, flint_rand_t state, long prec, long mag_bits) - # void arb_get_rand_fmpq(fmpq_t q, flint_rand_t state, const arb_t x, long bits) - - void arb_add_error_arf(arb_t x, const arf_t err) - void arb_add_error_2exp_si(arb_t x, long e) - void arb_add_error_2exp_fmpz(arb_t x, const fmpz_t e) - void arb_add_error(arb_t x, const arb_t error) - void arb_union(arb_t z, const arb_t x, const arb_t y, long prec) - void arb_get_abs_ubound_arf(arf_t u, const arb_t x, long prec) - void arb_get_abs_lbound_arf(arf_t u, const arb_t x, long prec) - void arb_get_mag(mag_t z, const arb_t x) - void arb_get_mag_lower(mag_t z, const arb_t x) - arb_get_mag_lower_nonnegative(mag_t z, const arb_t x) - void arb_get_interval_fmpz_2exp(fmpz_t a, fmpz_t b, fmpz_t exp, const arb_t x) - void arb_set_interval_arf(arb_t x, const arf_t a, const arf_t b, long prec) - void arb_set_interval_mpfr(arb_t x, const mpfr_t a, const mpfr_t b, long prec) - void arb_get_interval_arf(arf_t a, arf_t b, const arb_t x, long prec) - void arb_get_interval_mpfr(mpfr_t a, mpfr_t b, const arb_t x) - long arb_rel_error_bits(const arb_t x) - long arb_rel_accuracy_bits(const arb_t x) - long arb_bits(const arb_t x) - void arb_trim(arb_t y, const arb_t x) - int arb_get_unique_fmpz(fmpz_t z, const arb_t x) - void arb_floor(arb_t y, const arb_t x, long prec) - void arb_ceil(arb_t y, const arb_t x, long prec) - void arb_get_fmpz_mid_rad_10exp(fmpz_t mid, fmpz_t rad, fmpz_t exp, const arb_t x, long n) - - bint arb_is_zero(const arb_t x) - bint arb_is_nonzero(const arb_t x) - bint arb_is_one(const arb_t f) - bint arb_is_finite(const arb_t x) - bint arb_is_exact(const arb_t x) - bint arb_is_int(const arb_t x) - bint arb_equal(const arb_t x, const arb_t y) - bint arb_is_positive(const arb_t x) - bint arb_is_nonnegative(const arb_t x) - bint arb_is_negative(const arb_t x) - bint arb_is_nonpositive(const arb_t x) - bint arb_overlaps(const arb_t x, const arb_t y) - bint arb_contains_arf(const arb_t x, const arf_t y) - bint arb_contains_fmpq(const arb_t x, const fmpq_t y) - bint arb_contains_fmpz(const arb_t x, const fmpz_t y) - bint arb_contains_si(const arb_t x, long y) - bint arb_contains_mpfr(const arb_t x, const mpfr_t y) - bint arb_contains(const arb_t x, const arb_t y) - bint arb_contains_zero(const arb_t x) - bint arb_contains_negative(const arb_t x) - bint arb_contains_nonpositive(const arb_t x) - bint arb_contains_positive(const arb_t x) - bint arb_contains_nonnegative(const arb_t x) - bint arb_contains_int(const arb_t x) - bint arb_eq(const arb_t x, const arb_t y) - bint arb_ne(const arb_t x, const arb_t y) - bint arb_le(const arb_t x, const arb_t y) - bint arb_ge(const arb_t x, const arb_t y) - bint arb_lt(const arb_t x, const arb_t y) - bint arb_gt(const arb_t x, const arb_t y) - - void arb_neg(arb_t y, const arb_t x) - void arb_neg_round(arb_t y, const arb_t x, long prec) - void arb_abs(arb_t x, const arb_t y) - void arb_min(arb_t z, const arb_t x, const arb_t y, long prec) - void arb_max(arb_t z, const arb_t x, const arb_t y, long prec) - void arb_add(arb_t z, const arb_t x, const arb_t y, long prec) - void arb_add_arf(arb_t z, const arb_t x, const arf_t y, long prec) - void arb_add_ui(arb_t z, const arb_t x, unsigned long y, long prec) - void arb_add_si(arb_t z, const arb_t x, long y, long prec) - void arb_add_fmpz(arb_t z, const arb_t x, const fmpz_t y, long prec) - void arb_add_fmpz_2exp(arb_t z, const arb_t x, const fmpz_t m, const fmpz_t e, long prec) - void arb_sub(arb_t z, const arb_t x, const arb_t y, long prec) - void arb_sub_arf(arb_t z, const arb_t x, const arf_t y, long prec) - void arb_sub_ui(arb_t z, const arb_t x, unsigned long y, long prec) - void arb_sub_si(arb_t z, const arb_t x, long y, long prec) - void arb_sub_fmpz(arb_t z, const arb_t x, const fmpz_t y, long prec) - void arb_mul(arb_t z, const arb_t x, const arb_t y, long prec) - void arb_mul_arf(arb_t z, const arb_t x, const arf_t y, long prec) - void arb_mul_si(arb_t z, const arb_t x, long y, long prec) - void arb_mul_ui(arb_t z, const arb_t x, unsigned long y, long prec) - void arb_mul_fmpz(arb_t z, const arb_t x, const fmpz_t y, long prec) - void arb_mul_2exp_si(arb_t y, const arb_t x, long e) - void arb_mul_2exp_fmpz(arb_t y, const arb_t x, const fmpz_t e) - void arb_addmul(arb_t z, const arb_t x, const arb_t y, long prec) - void arb_addmul_arf(arb_t z, const arb_t x, const arf_t y, long prec) - void arb_addmul_si(arb_t z, const arb_t x, long y, long prec) - void arb_addmul_ui(arb_t z, const arb_t x, unsigned long y, long prec) - void arb_addmul_fmpz(arb_t z, const arb_t x, const fmpz_t y, long prec) - void arb_submul(arb_t z, const arb_t x, const arb_t y, long prec) - void arb_submul_arf(arb_t z, const arb_t x, const arf_t y, long prec) - void arb_submul_si(arb_t z, const arb_t x, long y, long prec) - void arb_submul_ui(arb_t z, const arb_t x, unsigned long y, long prec) - void arb_submul_fmpz(arb_t z, const arb_t x, const fmpz_t y, long prec) - void arb_inv(arb_t y, const arb_t x, long prec) - void arb_div(arb_t z, const arb_t x, const arb_t y, long prec) - void arb_div_arf(arb_t z, const arb_t x, const arf_t y, long prec) - void arb_div_si(arb_t z, const arb_t x, long y, long prec) - void arb_div_ui(arb_t z, const arb_t x, unsigned long y, long prec) - void arb_div_fmpz(arb_t z, const arb_t x, const fmpz_t y, long prec) - void arb_fmpz_div_fmpz(arb_t z, const fmpz_t x, const fmpz_t y, long prec) - void arb_ui_div(arb_t z, unsigned long x, const arb_t y, long prec) - void arb_div_2expm1_ui(arb_t z, const arb_t x, unsigned long n, long prec) - - void arb_sqrt(arb_t z, const arb_t x, long prec) - void arb_sqrt_arf(arb_t z, const arf_t x, long prec) - void arb_sqrt_fmpz(arb_t z, const fmpz_t x, long prec) - void arb_sqrt_ui(arb_t z, unsigned long x, long prec) - void arb_sqrtpos(arb_t z, const arb_t x, long prec) - void arb_hypot(arb_t z, const arb_t x, const arb_t y, long prec) - void arb_rsqrt(arb_t z, const arb_t x, long prec) - void arb_rsqrt_ui(arb_t z, unsigned long x, long prec) - void arb_sqrt1pm1(arb_t z, const arb_t x, long prec) - void arb_root(arb_t z, const arb_t x, unsigned long k, long prec) - void arb_pow_fmpz_binexp(arb_t y, const arb_t b, const fmpz_t e, long prec) - void arb_pow_fmpz(arb_t y, const arb_t b, const fmpz_t e, long prec) - void arb_pow_ui(arb_t y, const arb_t b, unsigned long e, long prec) - void arb_ui_pow_ui(arb_t y, unsigned long b, unsigned long e, long prec) - void arb_si_pow_ui(arb_t y, long b, unsigned long e, long prec) - void arb_pow_fmpq(arb_t y, const arb_t x, const fmpq_t a, long prec) - void arb_pow(arb_t z, const arb_t x, const arb_t y, long prec) - - void arb_log_ui(arb_t z, unsigned long x, long prec) - void arb_log_fmpz(arb_t z, const fmpz_t x, long prec) - void arb_log_arf(arb_t z, const arf_t x, long prec) - void arb_log(arb_t z, const arb_t x, long prec) - void arb_log_ui_from_prev(arb_t log_k1, unsigned long k1, arb_t log_k0, unsigned long k0, long prec) - void arb_log1p(arb_t z, const arb_t x, long prec) - void arb_exp(arb_t z, const arb_t x, long prec) - void arb_expm1(arb_t z, const arb_t x, long prec) - - void arb_sin(arb_t s, const arb_t x, long prec) - void arb_cos(arb_t c, const arb_t x, long prec) - void arb_sin_cos(arb_t s, arb_t c, const arb_t x, long prec) - void arb_sin_pi(arb_t s, const arb_t x, long prec) - void arb_cos_pi(arb_t c, const arb_t x, long prec) - void arb_sin_cos_pi(arb_t s, arb_t c, const arb_t x, long prec) - void arb_tan(arb_t y, const arb_t x, long prec) - void arb_cot(arb_t y, const arb_t x, long prec) - void arb_sin_cos_pi_fmpq(arb_t s, arb_t c, const fmpq_t x, long prec) - void arb_sin_pi_fmpq(arb_t s, const fmpq_t x, long prec) - void arb_cos_pi_fmpq(arb_t c, const fmpq_t x, long prec) - void arb_tan_pi(arb_t y, const arb_t x, long prec) - void arb_cot_pi(arb_t y, const arb_t x, long prec) - void arb_sec(arb_t s, const arb_t x, long prec) - void arb_csc(arb_t c, const arb_t x, long prec) - - void arb_atan_arf(arb_t z, const arf_t x, long prec) - void arb_atan(arb_t z, const arb_t x, long prec) - void arb_atan2(arb_t z, const arb_t b, const arb_t a, long prec) - void arb_asin(arb_t z, const arb_t x, long prec) - void arb_acos(arb_t z, const arb_t x, long prec) - - void arb_sinh(arb_t s, const arb_t x, long prec) - void arb_cosh(arb_t c, const arb_t x, long prec) - void arb_sinh_cosh(arb_t s, arb_t c, const arb_t x, long prec) - void arb_tanh(arb_t y, const arb_t x, long prec) - void arb_coth(arb_t y, const arb_t x, long prec) - void arb_sech(arb_t s, const arb_t x, long prec) - void arb_csch(arb_t c, const arb_t x, long prec) - - void arb_asinh(arb_t z, const arb_t x, long prec) - void arb_acosh(arb_t z, const arb_t x, long prec) - void arb_atanh(arb_t z, const arb_t x, long prec) - void arb_const_pi(arb_t z, long prec) - void arb_const_sqrt_pi(arb_t z, long prec) - void arb_const_log_sqrt2pi(arb_t z, long prec) - void arb_const_log2(arb_t z, long prec) - void arb_const_log10(arb_t z, long prec) - void arb_const_euler(arb_t z, long prec) - void arb_const_catalan(arb_t z, long prec) - void arb_const_e(arb_t z, long prec) - void arb_const_khinchin(arb_t z, long prec) - void arb_const_glaisher(arb_t z, long prec) - void arb_const_apery(arb_t z, long prec) - - void arb_lambertw(arb_t res, const arb_t x, int flags, long prec) - - void arb_rising(arb_t z, const arb_t x, const arb_t n, long prec) - void arb_rising_fmpq_ui(arb_t z, const fmpq_t x, unsigned long n, long prec) - void arb_fac_ui(arb_t z, unsigned long n, long prec) - void arb_bin_ui(arb_t z, const arb_t n, unsigned long k, long prec) - void arb_bin_uiui(arb_t z, unsigned long n, unsigned long k, long prec) - void arb_gamma(arb_t z, const arb_t x, long prec) - void arb_gamma_fmpq(arb_t z, const fmpq_t x, long prec) - void arb_gamma_fmpz(arb_t z, const fmpz_t x, long prec) - void arb_lgamma(arb_t z, const arb_t x, long prec) - void arb_rgamma(arb_t z, const arb_t x, long prec) - void arb_digamma(arb_t y, const arb_t x, long prec) - - void arb_zeta_ui_vec_borwein(arb_ptr z, unsigned long start, long num, unsigned long step, long prec) - void arb_zeta_ui_asymp(arb_t x, unsigned long s, long prec) - void arb_zeta_ui_euler_product(arb_t z, unsigned long s, long prec) - void arb_zeta_ui_bernoulli(arb_t x, unsigned long s, long prec) - void arb_zeta_ui_borwein_bsplit(arb_t x, unsigned long s, long prec) - void arb_zeta_ui_vec(arb_ptr x, unsigned long start, long num, long prec) - void arb_zeta_ui_vec_even(arb_ptr x, unsigned long start, long num, long prec) - void arb_zeta_ui_vec_odd(arb_ptr x, unsigned long start, long num, long prec) - void arb_zeta_ui(arb_t x, unsigned long s, long prec) - void arb_zeta(arb_t z, const arb_t s, long prec) - void arb_hurwitz_zeta(arb_t z, const arb_t s, const arb_t a, long prec) - - void arb_bernoulli_ui(arb_t b, unsigned long n, long prec) - void arb_bernoulli_ui_zeta(arb_t b, unsigned long n, long prec) - - void arb_polylog(arb_t w, const arb_t s, const arb_t z, long prec) - void arb_polylog_si(arb_t w, long s, const arb_t z, long prec) - - void arb_fib_fmpz(arb_t z, const fmpz_t n, long prec) - void arb_fib_ui(arb_t z, unsigned long n, long prec) - void arb_agm(arb_t z, const arb_t x, const arb_t y, long prec) - void arb_chebyshev_t_ui(arb_t a, unsigned long n, const arb_t x, long prec) - void arb_chebyshev_u_ui(arb_t a, unsigned long n, const arb_t x, long prec) - void arb_chebyshev_t2_ui(arb_t a, arb_t b, unsigned long n, const arb_t x, long prec) - void arb_chebyshev_u2_ui(arb_t a, arb_t b, unsigned long n, const arb_t x, long prec) - void arb_bell_fmpz(arb_t z, const fmpz_t n, long prec) - void arb_bell_ui(arb_t z, unsigned long n, long prec) - void arb_doublefac_ui(arb_t z, unsigned long n, long prec) - +# Deprecated header file; use sage/libs/flint/arb.pxd instead +# See https://github.com/sagemath/sage/pull/36449 + +from sage.libs.flint.arb cimport ( + arb_midref, + arb_radref, + arb_init, + arb_clear, + arb_swap, + arb_set, + arb_set_arf, + arb_set_si, + arb_set_ui, + arb_set_fmpz, + arb_set_fmpz_2exp, + arb_set_round, + arb_set_round_fmpz, + arb_set_round_fmpz_2exp, + arb_set_fmpq, + arb_set_str, + arb_get_str, + arb_zero, + arb_one, + arb_pos_inf, + arb_neg_inf, + arb_zero_pm_inf, + arb_indeterminate, + arb_print, + arb_printd, + arb_printn, + arb_load_str, + arb_randtest, + arb_randtest_exact, + arb_randtest_precise, + arb_randtest_wide, + arb_randtest_special, + arb_get_rand_fmpq, + arb_add_error_arf, + arb_add_error_2exp_si, + arb_add_error_2exp_fmpz, + arb_add_error, + arb_union, + arb_get_abs_ubound_arf, + arb_get_abs_lbound_arf, + arb_get_mag, + arb_get_mag_lower, + arb_get_mag_lower_nonnegative, + arb_get_interval_fmpz_2exp, + arb_set_interval_arf, + arb_set_interval_mpfr, + arb_get_interval_arf, + arb_get_interval_mpfr, + arb_rel_error_bits, + arb_rel_accuracy_bits, + arb_bits, + arb_trim, + arb_get_unique_fmpz, + arb_floor, + arb_ceil, + arb_get_fmpz_mid_rad_10exp, + arb_is_zero, + arb_is_nonzero, + arb_is_one, + arb_is_finite, + arb_is_exact, + arb_is_int, + arb_equal, + arb_is_positive, + arb_is_nonnegative, + arb_is_negative, + arb_is_nonpositive, + arb_overlaps, + arb_contains_arf, + arb_contains_fmpq, + arb_contains_fmpz, + arb_contains_si, + arb_contains_mpfr, + arb_contains, + arb_contains_zero, + arb_contains_negative, + arb_contains_nonpositive, + arb_contains_positive, + arb_contains_nonnegative, + arb_contains_int, + arb_eq, + arb_ne, + arb_le, + arb_ge, + arb_lt, + arb_gt, + arb_neg, + arb_neg_round, + arb_abs, + arb_min, + arb_max, + arb_add, + arb_add_arf, + arb_add_ui, + arb_add_si, + arb_add_fmpz, + arb_add_fmpz_2exp, + arb_sub, + arb_sub_arf, + arb_sub_ui, + arb_sub_si, + arb_sub_fmpz, + arb_mul, + arb_mul_arf, + arb_mul_si, + arb_mul_ui, + arb_mul_fmpz, + arb_mul_2exp_si, + arb_mul_2exp_fmpz, + arb_addmul, + arb_addmul_arf, + arb_addmul_si, + arb_addmul_ui, + arb_addmul_fmpz, + arb_submul, + arb_submul_arf, + arb_submul_si, + arb_submul_ui, + arb_submul_fmpz, + arb_inv, + arb_div, + arb_div_arf, + arb_div_si, + arb_div_ui, + arb_div_fmpz, + arb_fmpz_div_fmpz, + arb_ui_div, + arb_div_2expm1_ui, + arb_sqrt, + arb_sqrt_arf, + arb_sqrt_fmpz, + arb_sqrt_ui, + arb_sqrtpos, + arb_hypot, + arb_rsqrt, + arb_rsqrt_ui, + arb_sqrt1pm1, + arb_root, + arb_pow_fmpz_binexp, + arb_pow_fmpz, + arb_pow_ui, + arb_ui_pow_ui, + arb_si_pow_ui, + arb_pow_fmpq, + arb_pow, + arb_log_ui, + arb_log_fmpz, + arb_log_arf, + arb_log, + arb_log_ui_from_prev, + arb_log1p, + arb_exp, + arb_expm1, + arb_sin, + arb_cos, + arb_sin_cos, + arb_sin_pi, + arb_cos_pi, + arb_sin_cos_pi, + arb_tan, + arb_cot, + arb_sin_cos_pi_fmpq, + arb_sin_pi_fmpq, + arb_cos_pi_fmpq, + arb_tan_pi, + arb_cot_pi, + arb_sec, + arb_csc, + arb_atan_arf, + arb_atan, + arb_atan2, + arb_asin, + arb_acos, + arb_sinh, + arb_cosh, + arb_sinh_cosh, + arb_tanh, + arb_coth, + arb_sech, + arb_csch, + arb_asinh, + arb_acosh, + arb_atanh, + arb_const_pi, + arb_const_sqrt_pi, + arb_const_log_sqrt2pi, + arb_const_log2, + arb_const_log10, + arb_const_euler, + arb_const_catalan, + arb_const_e, + arb_const_khinchin, + arb_const_glaisher, + arb_const_apery, + arb_lambertw, + arb_rising_ui, + arb_rising, + arb_rising_fmpq_ui, + arb_fac_ui, + arb_bin_ui, + arb_bin_uiui, + arb_gamma, + arb_gamma_fmpq, + arb_gamma_fmpz, + arb_lgamma, + arb_rgamma, + arb_digamma, + arb_zeta_ui_vec_borwein, + arb_zeta_ui_asymp, + arb_zeta_ui_euler_product, + arb_zeta_ui_bernoulli, + arb_zeta_ui_borwein_bsplit, + arb_zeta_ui_vec, + arb_zeta_ui_vec_even, + arb_zeta_ui_vec_odd, + arb_zeta_ui, + arb_zeta, + arb_hurwitz_zeta, + arb_bernoulli_ui, + arb_bernoulli_ui_zeta, + arb_polylog, + arb_polylog_si, + arb_fib_fmpz, + arb_fib_ui, + arb_agm, + arb_chebyshev_t_ui, + arb_chebyshev_u_ui, + arb_chebyshev_t2_ui, + arb_chebyshev_u2_ui, + arb_bell_fmpz, + arb_bell_ui, + arb_doublefac_ui) diff --git a/src/sage/libs/arb/arb_fmpz_poly.pxd b/src/sage/libs/arb/arb_fmpz_poly.pxd index 55daa705238..a1de902aeb4 100644 --- a/src/sage/libs/arb/arb_fmpz_poly.pxd +++ b/src/sage/libs/arb/arb_fmpz_poly.pxd @@ -1,25 +1,20 @@ -# distutils: libraries = gmp flint -# distutils: depends = arb_fmpz_poly.h +# Deprecated header file; use sage/libs/flint/arb_fmpz_poly.pxd instead +# See https://github.com/sagemath/sage/pull/36449 -from sage.libs.arb.types cimport * -from sage.libs.flint.types cimport fmpz, fmpz_poly_t - -# acb.h -cdef extern from "arb_wrap.h": - - void _arb_fmpz_poly_evaluate_arb_horner(arb_t res, const fmpz * poly, long len, const arb_t x, long prec) - void arb_fmpz_poly_evaluate_arb_horner(arb_t res, const fmpz_poly_t poly, const arb_t x, long prec) - void _arb_fmpz_poly_evaluate_arb_rectangular(arb_t res, const fmpz * poly, long len, const arb_t x, long prec) - void arb_fmpz_poly_evaluate_arb_rectangular(arb_t res, const fmpz_poly_t poly, const arb_t x, long prec) - void _arb_fmpz_poly_evaluate_arb(arb_t res, const fmpz * poly, long len, const arb_t x, long prec) - void arb_fmpz_poly_evaluate_arb(arb_t res, const fmpz_poly_t poly, const arb_t x, long prec) - void _arb_fmpz_poly_evaluate_acb_horner(acb_t res, const fmpz * poly, long len, const acb_t x, long prec) - void arb_fmpz_poly_evaluate_acb_horner(acb_t res, const fmpz_poly_t poly, const acb_t x, long prec) - void _arb_fmpz_poly_evaluate_acb_rectangular(acb_t res, const fmpz * poly, long len, const acb_t x, long prec) - void arb_fmpz_poly_evaluate_acb_rectangular(acb_t res, const fmpz_poly_t poly, const acb_t x, long prec) - void _arb_fmpz_poly_evaluate_acb(acb_t res, const fmpz * poly, long len, const acb_t x, long prec) - void arb_fmpz_poly_evaluate_acb(acb_t res, const fmpz_poly_t poly, const acb_t x, long prec) - unsigned long arb_fmpz_poly_deflation(const fmpz_poly_t poly) - void arb_fmpz_poly_deflate(fmpz_poly_t res, const fmpz_poly_t poly, unsigned long deflation) - void arb_fmpz_poly_complex_roots(acb_ptr roots, const fmpz_poly_t poly, int flags, long prec) - void arb_fmpz_poly_gauss_period_minpoly(fmpz_poly_t res, unsigned long q, unsigned long n) +from sage.libs.flint.arb_fmpz_poly cimport ( + _arb_fmpz_poly_evaluate_arb_horner, + arb_fmpz_poly_evaluate_arb_horner, + _arb_fmpz_poly_evaluate_arb_rectangular, + arb_fmpz_poly_evaluate_arb_rectangular, + _arb_fmpz_poly_evaluate_arb, + arb_fmpz_poly_evaluate_arb, + _arb_fmpz_poly_evaluate_acb_horner, + arb_fmpz_poly_evaluate_acb_horner, + _arb_fmpz_poly_evaluate_acb_rectangular, + arb_fmpz_poly_evaluate_acb_rectangular, + _arb_fmpz_poly_evaluate_acb, + arb_fmpz_poly_evaluate_acb, + arb_fmpz_poly_deflation, + arb_fmpz_poly_deflate, + arb_fmpz_poly_complex_roots, + arb_fmpz_poly_gauss_period_minpoly) diff --git a/src/sage/libs/arb/arb_hypgeom.pxd b/src/sage/libs/arb/arb_hypgeom.pxd index 139b987d669..09ef72742a1 100644 --- a/src/sage/libs/arb/arb_hypgeom.pxd +++ b/src/sage/libs/arb/arb_hypgeom.pxd @@ -1,87 +1,82 @@ -# distutils: libraries = gmp flint -# distutils: depends = arb_hypgeom.h +# Deprecated header file; use sage/libs/flint/arb_hypgeom.pxd instead +# See https://github.com/sagemath/sage/pull/36449 -from sage.libs.flint.types cimport fmpz_t -from sage.libs.arb.types cimport * - -# arb_hypgeom.h -cdef extern from "arb_wrap.h": - void arb_hypgeom_pfq(arb_t res, arb_srcptr a, long p, arb_srcptr b, long q, const arb_t z, int regularized, long prec) - void arb_hypgeom_0f1(arb_t res, const arb_t a, const arb_t z, int regularized, long prec) - void arb_hypgeom_m(arb_t res, const arb_t a, const arb_t b, const arb_t z, int regularized, long prec) - void arb_hypgeom_1f1(arb_t res, const arb_t a, const arb_t b, const arb_t z, int regularized, long prec) - void arb_hypgeom_u(arb_t res, const arb_t a, const arb_t b, const arb_t z, long prec) - void arb_hypgeom_2f1(arb_t res, const arb_t a, const arb_t b, const arb_t c, const arb_t z, int regularized, long prec) - void arb_hypgeom_erf(arb_t res, const arb_t z, long prec) - void _arb_hypgeom_erf_series(arb_ptr res, arb_srcptr z, long zlen, long len, long prec) - void arb_hypgeom_erf_series(arb_poly_t res, const arb_poly_t z, long len, long prec) - void arb_hypgeom_erfc(arb_t res, const arb_t z, long prec) - void _arb_hypgeom_erfc_series(arb_ptr res, arb_srcptr z, long zlen, long len, long prec) - void arb_hypgeom_erfc_series(arb_poly_t res, const arb_poly_t z, long len, long prec) - void arb_hypgeom_erfi(arb_t res, const arb_t z, long prec) - void _arb_hypgeom_erfi_series(arb_ptr res, arb_srcptr z, long zlen, long len, long prec) - void arb_hypgeom_erfi_series(arb_poly_t res, const arb_poly_t z, long len, long prec) - void arb_hypgeom_fresnel(arb_t res1, arb_t res2, const arb_t z, int normalized, long prec) - void _arb_hypgeom_fresnel_series(arb_ptr res1, arb_ptr res2, arb_srcptr z, long zlen, int normalized, long len, long prec) - void arb_hypgeom_fresnel_series(arb_poly_t res1, arb_poly_t res2, const arb_poly_t z, int normalized, long len, long prec) - void arb_hypgeom_gamma_upper(arb_t res, const arb_t s, const arb_t z, int regularized, long prec) - void _arb_hypgeom_gamma_upper_series(arb_ptr res, const arb_t s, arb_srcptr z, long zlen, int regularized, long n, long prec) - void arb_hypgeom_gamma_upper_series(arb_poly_t res, const arb_t s, const arb_poly_t z, int regularized, long n, long prec) - void arb_hypgeom_gamma_lower(arb_t res, const arb_t s, const arb_t z, int regularized, long prec) - void _arb_hypgeom_gamma_lower_series(arb_ptr res, const arb_t s, arb_srcptr z, long zlen, int regularized, long n, long prec) - void arb_hypgeom_gamma_lower_series(arb_poly_t res, const arb_t s, const arb_poly_t z, int regularized, long n, long prec) - void arb_hypgeom_beta_lower(arb_t res, const arb_t a, const arb_t b, const arb_t z, bint regularized, long prec) - void _arb_hypgeom_beta_lower_series(arb_ptr res, const arb_t a, const arb_t b, arb_srcptr z, long zlen, bint regularized, long n, long prec) - void arb_hypgeom_beta_lower_series(arb_poly_t res, const arb_t a, const arb_t b, const arb_poly_t z, bint regularized, long n, long prec) - void arb_hypgeom_expint(arb_t res, const arb_t s, const arb_t z, long prec) - void arb_hypgeom_ei(arb_t res, const arb_t z, long prec) - void _arb_hypgeom_ei_series(arb_ptr res, arb_srcptr z, long zlen, long len, long prec) - void arb_hypgeom_ei_series(arb_poly_t res, const arb_poly_t z, long len, long prec) - void arb_hypgeom_si(arb_t res, const arb_t z, long prec) - void _arb_hypgeom_si_series(arb_ptr res, arb_srcptr z, long zlen, long len, long prec) - void arb_hypgeom_si_series(arb_poly_t res, const arb_poly_t z, long len, long prec) - void arb_hypgeom_ci(arb_t res, const arb_t z, long prec) - void _arb_hypgeom_ci_series(arb_ptr res, arb_srcptr z, long zlen, long len, long prec) - void arb_hypgeom_ci_series(arb_poly_t res, const arb_poly_t z, long len, long prec) - void arb_hypgeom_shi(arb_t res, const arb_t z, long prec) - void _arb_hypgeom_shi_series(arb_ptr res, arb_srcptr z, long zlen, long len, long prec) - void arb_hypgeom_shi_series(arb_poly_t res, const arb_poly_t z, long len, long prec) - void arb_hypgeom_chi(arb_t res, const arb_t z, long prec) - void _arb_hypgeom_chi_series(arb_ptr res, arb_srcptr z, long zlen, long len, long prec) - void arb_hypgeom_chi_series(arb_poly_t res, const arb_poly_t z, long len, long prec) - void arb_hypgeom_li(arb_t res, const arb_t z, bint offset, long prec) - void _arb_hypgeom_li_series(arb_ptr res, arb_srcptr z, long zlen, bint offset, long len, long prec) - void arb_hypgeom_li_series(arb_poly_t res, const arb_poly_t z, bint offset, long len, long prec) - void arb_hypgeom_bessel_j(arb_t res, const arb_t nu, const arb_t z, long prec) - void arb_hypgeom_bessel_y(arb_t res, const arb_t nu, const arb_t z, long prec) - void arb_hypgeom_bessel_jy(arb_t res1, arb_t res2, const arb_t nu, const arb_t z, long prec) - void arb_hypgeom_bessel_i(arb_t res, const arb_t nu, const arb_t z, long prec) - void arb_hypgeom_bessel_i_scaled(arb_t res, const arb_t nu, const arb_t z, long prec) - void arb_hypgeom_bessel_k(arb_t res, const arb_t nu, const arb_t z, long prec) - void arb_hypgeom_bessel_k_scaled(arb_t res, const arb_t nu, const arb_t z, long prec) - void arb_hypgeom_airy(arb_t ai, arb_t ai_prime, arb_t bi, arb_t bi_prime, const arb_t z, long prec) - void arb_hypgeom_airy_jet(arb_ptr ai, arb_ptr bi, const arb_t z, long len, long prec) - void _arb_hypgeom_airy_series(arb_ptr ai, arb_ptr ai_prime, arb_ptr bi, arb_ptr bi_prime, arb_srcptr z, long zlen, long len, long prec) - void arb_hypgeom_airy_series(arb_poly_t ai, arb_poly_t ai_prime, arb_poly_t bi, arb_poly_t bi_prime, const arb_poly_t z, long len, long prec) - void arb_hypgeom_airy_zero(arb_t a, arb_t a_prime, arb_t b, arb_t b_prime, const fmpz_t n, long prec) - void arb_hypgeom_coulomb(arb_t F, arb_t G, const arb_t l, const arb_t eta, const arb_t z, long prec) - void arb_hypgeom_coulomb_jet(arb_ptr F, arb_ptr G, const arb_t l, const arb_t eta, const arb_t z, long len, long prec) - void _arb_hypgeom_coulomb_series(arb_ptr F, arb_ptr G, const arb_t l, const arb_t eta, arb_srcptr z, long zlen, long len, long prec) - void arb_hypgeom_coulomb_series(arb_poly_t F, arb_poly_t G, const arb_t l, const arb_t eta, const arb_poly_t z, long len, long prec) - void arb_hypgeom_chebyshev_t(arb_t res, const arb_t nu, const arb_t z, long prec) - void arb_hypgeom_chebyshev_u(arb_t res, const arb_t nu, const arb_t z, long prec) - void arb_hypgeom_jacobi_p(arb_t res, const arb_t n, const arb_t a, const arb_t b, const arb_t z, long prec) - void arb_hypgeom_gegenbauer_c(arb_t res, const arb_t n, const arb_t m, const arb_t z, long prec) - void arb_hypgeom_laguerre_l(arb_t res, const arb_t n, const arb_t m, const arb_t z, long prec) - void arb_hypgeom_hermite_h(arb_t res, const arb_t nu, const arb_t z, long prec) - void arb_hypgeom_legendre_p(arb_t res, const arb_t n, const arb_t m, const arb_t z, int type, long prec) - void arb_hypgeom_legendre_q(arb_t res, const arb_t n, const arb_t m, const arb_t z, int type, long prec) - void arb_hypgeom_legendre_p_ui_deriv_bound(mag_t dp, mag_t dp2, unsigned long n, const arb_t x, const arb_t x2sub1) - void arb_hypgeom_legendre_p_ui_zero(arb_t res, arb_t res_prime, unsigned long n, const arb_t x, long K, long prec) - void arb_hypgeom_legendre_p_ui_one(arb_t res, arb_t res_prime, unsigned long n, const arb_t x, long K, long prec) - void arb_hypgeom_legendre_p_ui_asymp(arb_t res, arb_t res_prime, unsigned long n, const arb_t x, long K, long prec) - void arb_hypgeom_legendre_p_rec(arb_t res, arb_t res_prime, unsigned long n, const arb_t x, long prec) - void arb_hypgeom_legendre_p_ui(arb_t res, arb_t res_prime, unsigned long n, const arb_t x, long prec) - void arb_hypgeom_legendre_p_ui_root(arb_t res, arb_t weight, unsigned long n, unsigned long k, long prec) - void arb_hypgeom_dilog(arb_t res, const arb_t z, long prec) - void arb_hypgeom_central_bin_ui(arb_t res, unsigned long n, long prec) +from sage.libs.flint.arb_hypgeom cimport ( + arb_hypgeom_pfq, + arb_hypgeom_0f1, + arb_hypgeom_m, + arb_hypgeom_1f1, + arb_hypgeom_u, + arb_hypgeom_2f1, + arb_hypgeom_erf, + _arb_hypgeom_erf_series, + arb_hypgeom_erf_series, + arb_hypgeom_erfc, + _arb_hypgeom_erfc_series, + arb_hypgeom_erfc_series, + arb_hypgeom_erfi, + _arb_hypgeom_erfi_series, + arb_hypgeom_erfi_series, + arb_hypgeom_fresnel, + _arb_hypgeom_fresnel_series, + arb_hypgeom_fresnel_series, + arb_hypgeom_gamma_upper, + _arb_hypgeom_gamma_upper_series, + arb_hypgeom_gamma_upper_series, + arb_hypgeom_gamma_lower, + _arb_hypgeom_gamma_lower_series, + arb_hypgeom_gamma_lower_series, + arb_hypgeom_beta_lower, + _arb_hypgeom_beta_lower_series, + arb_hypgeom_beta_lower_series, + arb_hypgeom_expint, + arb_hypgeom_ei, + _arb_hypgeom_ei_series, + arb_hypgeom_ei_series, + arb_hypgeom_si, + _arb_hypgeom_si_series, + arb_hypgeom_si_series, + arb_hypgeom_ci, + _arb_hypgeom_ci_series, + arb_hypgeom_ci_series, + arb_hypgeom_shi, + _arb_hypgeom_shi_series, + arb_hypgeom_shi_series, + arb_hypgeom_chi, + _arb_hypgeom_chi_series, + arb_hypgeom_chi_series, + arb_hypgeom_li, + _arb_hypgeom_li_series, + arb_hypgeom_li_series, + arb_hypgeom_bessel_j, + arb_hypgeom_bessel_y, + arb_hypgeom_bessel_jy, + arb_hypgeom_bessel_i, + arb_hypgeom_bessel_i_scaled, + arb_hypgeom_bessel_k, + arb_hypgeom_bessel_k_scaled, + arb_hypgeom_airy, + arb_hypgeom_airy_jet, + _arb_hypgeom_airy_series, + arb_hypgeom_airy_series, + arb_hypgeom_airy_zero, + arb_hypgeom_coulomb, + arb_hypgeom_coulomb_jet, + _arb_hypgeom_coulomb_series, + arb_hypgeom_coulomb_series, + arb_hypgeom_chebyshev_t, + arb_hypgeom_chebyshev_u, + arb_hypgeom_jacobi_p, + arb_hypgeom_gegenbauer_c, + arb_hypgeom_laguerre_l, + arb_hypgeom_hermite_h, + arb_hypgeom_legendre_p, + arb_hypgeom_legendre_q, + arb_hypgeom_legendre_p_ui_deriv_bound, + arb_hypgeom_legendre_p_ui_zero, + arb_hypgeom_legendre_p_ui_one, + arb_hypgeom_legendre_p_ui_asymp, + arb_hypgeom_legendre_p_ui, + arb_hypgeom_legendre_p_ui_root, + arb_hypgeom_dilog, + arb_hypgeom_central_bin_ui) diff --git a/src/sage/libs/arb/arf.pxd b/src/sage/libs/arb/arf.pxd index 84778fe9f09..af211c27e03 100644 --- a/src/sage/libs/arb/arf.pxd +++ b/src/sage/libs/arb/arf.pxd @@ -1,134 +1,128 @@ -# distutils: libraries = gmp flint -# distutils: depends = arf.h +# Deprecated header file; use sage/libs/flint/arf.pxd instead +# See https://github.com/sagemath/sage/pull/36449 -from sage.libs.arb.types cimport * -from sage.libs.gmp.types cimport mpz_t -from sage.libs.flint.types cimport fmpz_t -from sage.libs.mpfr.types cimport mpfr_t, mpfr_rnd_t - -# arf.h -cdef extern from "arb_wrap.h": - void arf_init(arf_t x) - void arf_clear(arf_t x) - void arf_zero(arf_t x) - void arf_one(arf_t x) - void arf_pos_inf(arf_t x) - void arf_neg_inf(arf_t x) - void arf_nan(arf_t x) - bint arf_is_zero(const arf_t x) - bint arf_is_one(const arf_t x) - bint arf_is_pos_inf(const arf_t x) - bint arf_is_neg_inf(const arf_t x) - bint arf_is_nan(const arf_t x) - bint arf_is_inf(const arf_t x) - bint arf_is_normal(const arf_t x) - bint arf_is_special(const arf_t x) - bint arf_is_finite(arf_t x) - void arf_set(arf_t y, const arf_t x) - void arf_set_mpz(arf_t y, const mpz_t x) - void arf_set_fmpz(arf_t y, const fmpz_t x) - void arf_set_ui(arf_t y, unsigned long x) - void arf_set_si(arf_t y, long x) - void arf_set_mpfr(arf_t y, const mpfr_t x) - void arf_set_d(arf_t y, double x) - void arf_swap(arf_t y, arf_t x) - void arf_init_set_ui(arf_t y, unsigned long x) - void arf_init_set_si(arf_t y, long x) - int arf_set_round(arf_t y, const arf_t x, long prec, arf_rnd_t rnd) - int arf_set_round_si(arf_t x, long v, long prec, arf_rnd_t rnd) - int arf_set_round_ui(arf_t x, unsigned long v, long prec, arf_rnd_t rnd) - int arf_set_round_mpz(arf_t y, const mpz_t x, long prec, arf_rnd_t rnd) - int arf_set_round_fmpz(arf_t y, const fmpz_t x, long prec, arf_rnd_t rnd) - void arf_set_si_2exp_si(arf_t y, long m, long e) - void arf_set_ui_2exp_si(arf_t y, unsigned long m, long e) - void arf_set_fmpz_2exp(arf_t y, const fmpz_t m, const fmpz_t e) - int arf_set_round_fmpz_2exp(arf_t y, const fmpz_t x, const fmpz_t e, long prec, arf_rnd_t rnd) - void arf_get_fmpz_2exp(fmpz_t m, fmpz_t e, const arf_t x) - double arf_get_d(const arf_t x, arf_rnd_t rnd) - int arf_get_mpfr(mpfr_t y, const arf_t x, mpfr_rnd_t rnd) - void arf_get_fmpz(fmpz_t z, const arf_t x, arf_rnd_t rnd) - long arf_get_si(const arf_t x, arf_rnd_t rnd) - int arf_get_fmpz_fixed_fmpz(fmpz_t y, const arf_t x, const fmpz_t e) - int arf_get_fmpz_fixed_si(fmpz_t y, const arf_t x, long e) - void arf_floor(arf_t y, const arf_t x) - void arf_ceil(arf_t y, const arf_t x) - bint arf_equal(const arf_t x, const arf_t y) - bint arf_equal_si(const arf_t x, long y) - int arf_cmp(const arf_t x, const arf_t y) - int arf_cmpabs(const arf_t x, const arf_t y) - int arf_cmpabs_ui(const arf_t x, unsigned long y) - int arf_cmpabs_mag(const arf_t x, const mag_t y) - int arf_cmp_2exp_si(const arf_t x, long e) - int arf_cmpabs_2exp_si(const arf_t x, long e) - int arf_sgn(const arf_t x) - void arf_min(arf_t z, const arf_t a, const arf_t b) - void arf_max(arf_t z, const arf_t a, const arf_t b) - long arf_bits(const arf_t x) - bint arf_is_int(const arf_t x) - bint arf_is_int_2exp_si(const arf_t x, long e) - void arf_abs_bound_lt_2exp_fmpz(fmpz_t b, const arf_t x) - void arf_abs_bound_le_2exp_fmpz(fmpz_t b, const arf_t x) - long arf_abs_bound_lt_2exp_si(const arf_t x) - void arf_get_mag(mag_t y, const arf_t x) - void arf_get_mag_lower(mag_t y, const arf_t x) - void arf_set_mag(arf_t y, const mag_t x) - void mag_init_set_arf(mag_t y, const arf_t x) - void mag_fast_init_set_arf(mag_t y, const arf_t x) - void arf_mag_set_ulp(mag_t z, const arf_t y, long prec) - void arf_mag_add_ulp(mag_t z, const mag_t x, const arf_t y, long prec) - void arf_mag_fast_add_ulp(mag_t z, const mag_t x, const arf_t y, long prec) - void arf_init_set_shallow(arf_t z, const arf_t x) - void arf_init_set_mag_shallow(arf_t z, const mag_t x) - void arf_init_neg_shallow(arf_t z, const arf_t x) - void arf_init_neg_mag_shallow(arf_t z, const mag_t x) - # void arf_randtest(arf_t x, flint_rand_t state, long bits, long mag_bits) - # void arf_randtest_not_zero(arf_t x, flint_rand_t state, long bits, long mag_bits) - # void arf_randtest_special(arf_t x, flint_rand_t state, long bits, long mag_bits) - void arf_debug(const arf_t x) - void arf_print(const arf_t x) - void arf_printd(const arf_t y, long d) - void arf_abs(arf_t y, const arf_t x) - void arf_neg(arf_t y, const arf_t x) - int arf_neg_round(arf_t y, const arf_t x, long prec, arf_rnd_t rnd) - void arf_mul_2exp_si(arf_t y, const arf_t x, long e) - void arf_mul_2exp_fmpz(arf_t y, const arf_t x, const fmpz_t e) - int arf_mul(arf_t z, const arf_t x, const arf_t y, long prec, arf_rnd_t rnd) - int arf_mul_ui(arf_t z, const arf_t x, unsigned long y, long prec, arf_rnd_t rnd) - int arf_mul_si(arf_t z, const arf_t x, long y, long prec, arf_rnd_t rnd) - int arf_mul_mpz(arf_t z, const arf_t x, const mpz_t y, long prec, arf_rnd_t rnd) - int arf_mul_fmpz(arf_t z, const arf_t x, const fmpz_t y, long prec, arf_rnd_t rnd) - int arf_add(arf_t z, const arf_t x, const arf_t y, long prec, arf_rnd_t rnd) - int arf_add_si(arf_t z, const arf_t x, long y, long prec, arf_rnd_t rnd) - int arf_add_ui(arf_t z, const arf_t x, unsigned long y, long prec, arf_rnd_t rnd) - int arf_add_fmpz(arf_t z, const arf_t x, const fmpz_t y, long prec, arf_rnd_t rnd) - int arf_add_fmpz_2exp(arf_t z, const arf_t x, const fmpz_t y, const fmpz_t e, long prec, arf_rnd_t rnd) - int arf_sub(arf_t z, const arf_t x, const arf_t y, long prec, arf_rnd_t rnd) - int arf_sub_si(arf_t z, const arf_t x, long y, long prec, arf_rnd_t rnd) - int arf_sub_ui(arf_t z, const arf_t x, unsigned long y, long prec, arf_rnd_t rnd) - int arf_sub_fmpz(arf_t z, const arf_t x, const fmpz_t y, long prec, arf_rnd_t rnd) - int arf_addmul(arf_t z, const arf_t x, const arf_t y, long prec, arf_rnd_t rnd) - int arf_addmul_ui(arf_t z, const arf_t x, unsigned long y, long prec, arf_rnd_t rnd) - int arf_addmul_si(arf_t z, const arf_t x, long y, long prec, arf_rnd_t rnd) - int arf_addmul_mpz(arf_t z, const arf_t x, const mpz_t y, long prec, arf_rnd_t rnd) - int arf_addmul_fmpz(arf_t z, const arf_t x, const fmpz_t y, long prec, arf_rnd_t rnd) - int arf_submul(arf_t z, const arf_t x, const arf_t y, long prec, arf_rnd_t rnd) - int arf_submul_ui(arf_t z, const arf_t x, unsigned long y, long prec, arf_rnd_t rnd) - int arf_submul_si(arf_t z, const arf_t x, long y, long prec, arf_rnd_t rnd) - int arf_submul_mpz(arf_t z, const arf_t x, const mpz_t y, long prec, arf_rnd_t rnd) - int arf_submul_fmpz(arf_t z, const arf_t x, const fmpz_t y, long prec, arf_rnd_t rnd) - int arf_sum(arf_t s, arf_srcptr terms, long len, long prec, arf_rnd_t rnd) - int arf_div(arf_t z, const arf_t x, const arf_t y, long prec, arf_rnd_t rnd) - int arf_div_ui(arf_t z, const arf_t x, unsigned long y, long prec, arf_rnd_t rnd) - int arf_ui_div(arf_t z, unsigned long x, const arf_t y, long prec, arf_rnd_t rnd) - int arf_div_si(arf_t z, const arf_t x, long y, long prec, arf_rnd_t rnd) - int arf_si_div(arf_t z, long x, const arf_t y, long prec, arf_rnd_t rnd) - int arf_div_fmpz(arf_t z, const arf_t x, const fmpz_t y, long prec, arf_rnd_t rnd) - int arf_fmpz_div(arf_t z, const fmpz_t x, const arf_t y, long prec, arf_rnd_t rnd) - int arf_fmpz_div_fmpz(arf_t z, const fmpz_t x, const fmpz_t y, long prec, arf_rnd_t rnd) - int arf_sqrt(arf_t z, const arf_t x, long prec, arf_rnd_t rnd) - int arf_sqrt_ui(arf_t z, unsigned long x, long prec, arf_rnd_t rnd) - int arf_sqrt_fmpz(arf_t z, const fmpz_t x, long prec, arf_rnd_t rnd) - int arf_rsqrt(arf_t z, const arf_t x, long prec, arf_rnd_t rnd) - 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, long 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, long prec, arf_rnd_t rnd) - int arf_complex_sqr(arf_t e, arf_t f, const arf_t a, const arf_t b, long prec, arf_rnd_t rnd) +from sage.libs.flint.arf cimport ( + arf_init, + arf_clear, + arf_zero, + arf_one, + arf_pos_inf, + arf_neg_inf, + arf_nan, + arf_is_zero, + arf_is_one, + arf_is_pos_inf, + arf_is_neg_inf, + arf_is_nan, + arf_is_inf, + arf_is_normal, + arf_is_special, + arf_is_finite, + arf_set, + arf_set_mpz, + arf_set_fmpz, + arf_set_ui, + arf_set_si, + arf_set_mpfr, + arf_set_d, + arf_swap, + arf_init_set_ui, + arf_init_set_si, + arf_set_round, + arf_set_round_si, + arf_set_round_ui, + arf_set_round_mpz, + arf_set_round_fmpz, + arf_set_si_2exp_si, + arf_set_ui_2exp_si, + arf_set_fmpz_2exp, + arf_set_round_fmpz_2exp, + arf_get_fmpz_2exp, + arf_get_d, + arf_get_mpfr, + arf_get_fmpz, + arf_get_si, + arf_get_fmpz_fixed_fmpz, + arf_get_fmpz_fixed_si, + arf_floor, + arf_ceil, + arf_equal, + arf_equal_si, + arf_cmp, + arf_cmpabs, + arf_cmpabs_ui, + arf_cmpabs_mag, + arf_cmp_2exp_si, + arf_cmpabs_2exp_si, + arf_sgn, + arf_min, + arf_max, + arf_bits, + arf_is_int, + arf_is_int_2exp_si, + arf_abs_bound_lt_2exp_fmpz, + arf_abs_bound_le_2exp_fmpz, + arf_abs_bound_lt_2exp_si, + arf_get_mag, + arf_get_mag_lower, + arf_set_mag, + mag_init_set_arf, + mag_fast_init_set_arf, + arf_mag_set_ulp, + arf_mag_add_ulp, + arf_mag_fast_add_ulp, + arf_init_set_shallow, + arf_init_set_mag_shallow, + arf_init_neg_shallow, + arf_init_neg_mag_shallow, + arf_randtest, + arf_randtest_not_zero, + arf_randtest_special, + arf_debug, + arf_print, + arf_printd, + arf_abs, + arf_neg, + arf_neg_round, + arf_mul_2exp_si, + arf_mul_2exp_fmpz, + arf_mul, + arf_mul_ui, + arf_mul_si, + arf_mul_mpz, + arf_mul_fmpz, + arf_add, + arf_add_si, + arf_add_ui, + arf_add_fmpz, + arf_add_fmpz_2exp, + arf_sub, + arf_sub_si, + arf_sub_ui, + arf_sub_fmpz, + arf_addmul, + arf_addmul_ui, + arf_addmul_si, + arf_addmul_mpz, + arf_addmul_fmpz, + arf_submul, + arf_submul_ui, + arf_submul_si, + arf_submul_mpz, + arf_submul_fmpz, + arf_sum, + arf_div, + arf_div_ui, + arf_ui_div, + arf_div_si, + arf_si_div, + arf_div_fmpz, + arf_fmpz_div, + arf_fmpz_div_fmpz, + arf_sqrt, + arf_sqrt_ui, + arf_sqrt_fmpz, + arf_rsqrt, + arf_complex_mul, + arf_complex_mul_fallback, + arf_complex_sqr) diff --git a/src/sage/libs/arb/bernoulli.pxd b/src/sage/libs/arb/bernoulli.pxd index 95a84dd5179..a347f8e8378 100644 --- a/src/sage/libs/arb/bernoulli.pxd +++ b/src/sage/libs/arb/bernoulli.pxd @@ -1,8 +1,5 @@ -# distutils: libraries = gmp flint -# distutils: depends = bernoulli.h +# Deprecated header file; use sage/libs/flint/bernoulli.pxd instead +# See https://github.com/sagemath/sage/pull/36449 -from sage.libs.flint.types cimport fmpq_t, ulong - -# bernoulli.h -cdef extern from "arb_wrap.h": - void bernoulli_fmpq_ui(fmpq_t b, ulong n) +from sage.libs.flint.bernoulli cimport ( + bernoulli_fmpq_ui) diff --git a/src/sage/libs/arb/mag.pxd b/src/sage/libs/arb/mag.pxd index 69dfb990ae0..dfba357f8d7 100644 --- a/src/sage/libs/arb/mag.pxd +++ b/src/sage/libs/arb/mag.pxd @@ -1,77 +1,73 @@ -# distutils: libraries = gmp flint -# distutils: depends = mag.h +# Deprecated header file; use sage/libs/flint/mag.pxd instead +# See https://github.com/sagemath/sage/pull/36449 -from sage.libs.arb.types cimport * -from sage.libs.flint.types cimport fmpz_t, fmpq_t - -# mag.h -cdef extern from "arb_wrap.h": - void mag_init(mag_t x) - void mag_clear(mag_t x) - void mag_init_set(mag_t x, const mag_t y) - void mag_swap(mag_t x, mag_t y) - void mag_set(mag_t x, const mag_t y) - void mag_zero(mag_t x) - void mag_one(mag_t x) - void mag_inf(mag_t x) - bint mag_is_special(const mag_t x) - bint mag_is_zero(const mag_t x) - bint mag_is_inf(const mag_t x) - bint mag_is_finite(const mag_t x) - bint mag_equal(const mag_t x, const mag_t y) - bint mag_cmp(const mag_t x, const mag_t y) - bint mag_cmp_2exp_si(const mag_t x, long y) - void mag_min(mag_t z, const mag_t x, const mag_t y) - void mag_max(mag_t z, const mag_t x, const mag_t y) - void mag_print(const mag_t x) - # void mag_randtest(mag_t x, flint_rand_t state, long expbits) - # void mag_randtest_special(mag_t x, flint_rand_t state, long expbits) - void mag_set_d(mag_t y, double x) - void mag_set_ui(mag_t y, unsigned long x) - void mag_set_fmpz(mag_t y, const fmpz_t x) - void mag_set_d_2exp_fmpz(mag_t z, double x, const fmpz_t y) - void mag_set_fmpz_2exp_fmpz(mag_t z, const fmpz_t x, const fmpz_t y) - void mag_set_ui_2exp_si(mag_t z, unsigned long x, long y) - void mag_get_fmpq(fmpq_t y, const mag_t x) - void mag_set_ui_lower(mag_t z, unsigned long x) - void mag_set_fmpz_lower(mag_t z, const fmpz_t x) - void mag_set_fmpz_2exp_fmpz_lower(mag_t z, const fmpz_t x, const fmpz_t y) - void mag_mul_2exp_si(mag_t z, const mag_t x, long y) - void mag_mul_2exp_fmpz(mag_t z, const mag_t x, const fmpz_t y) - void mag_mul(mag_t z, const mag_t x, const mag_t y) - void mag_mul_ui(mag_t z, const mag_t x, unsigned long y) - void mag_mul_fmpz(mag_t z, const mag_t x, const fmpz_t y) - void mag_add(mag_t z, const mag_t x, const mag_t y) - void mag_addmul(mag_t z, const mag_t x, const mag_t y) - void mag_add_2exp_fmpz(mag_t z, const mag_t x, const fmpz_t e) - void mag_div(mag_t z, const mag_t x, const mag_t y) - void mag_div_ui(mag_t z, const mag_t x, unsigned long y) - void mag_div_fmpz(mag_t z, const mag_t x, const fmpz_t y) - void mag_mul_lower(mag_t z, const mag_t x, const mag_t y) - void mag_mul_ui_lower(mag_t z, const mag_t x, unsigned long y) - void mag_mul_fmpz_lower(mag_t z, const mag_t x, const fmpz_t y) - void mag_add_lower(mag_t z, const mag_t x, const mag_t y) - void mag_sub_lower(mag_t z, const mag_t x, const mag_t y) - void mag_fast_init_set(mag_t x, const mag_t y) - void mag_fast_zero(mag_t x) - bint mag_fast_is_zero(const mag_t x) - void mag_fast_mul(mag_t z, const mag_t x, const mag_t y) - void mag_fast_addmul(mag_t z, const mag_t x, const mag_t y) - void mag_fast_add_2exp_si(mag_t z, const mag_t x, long e) - void mag_fast_mul_2exp_si(mag_t z, const mag_t x, long e) - void mag_pow_ui(mag_t z, const mag_t x, unsigned long e) - void mag_pow_fmpz(mag_t z, const mag_t x, const fmpz_t e) - void mag_pow_ui_lower(mag_t z, const mag_t x, unsigned long e) - void mag_sqrt(mag_t z, const mag_t x) - void mag_rsqrt(mag_t z, const mag_t x) - void mag_hypot(mag_t z, const mag_t x, const mag_t y) - void mag_log1p(mag_t z, const mag_t x) - void mag_log_ui(mag_t z, unsigned long n) - void mag_exp(mag_t z, const mag_t x) - void mag_expm1(mag_t z, const mag_t x) - void mag_exp_tail(mag_t z, const mag_t x, unsigned long N) - void mag_binpow_uiui(mag_t z, unsigned long m, unsigned long n) - void mag_fac_ui(mag_t z, unsigned long n) - void mag_rfac_ui(mag_t z, unsigned long n) - void mag_bernoulli_div_fac_ui(mag_t z, unsigned long n) - void mag_polylog_tail(mag_t u, const mag_t z, long s, unsigned long d, unsigned long N) +from sage.libs.flint.mag cimport ( + mag_init, + mag_clear, + mag_init_set, + mag_swap, + mag_set, + mag_zero, + mag_one, + mag_inf, + mag_is_special, + mag_is_zero, + mag_is_inf, + mag_is_finite, + mag_equal, + mag_cmp, + mag_cmp_2exp_si, + mag_min, + mag_max, + mag_print, + mag_randtest, + mag_randtest_special, + mag_set_d, + mag_set_ui, + mag_set_fmpz, + mag_set_d_2exp_fmpz, + mag_set_fmpz_2exp_fmpz, + mag_set_ui_2exp_si, + mag_get_fmpq, + mag_set_ui_lower, + mag_set_fmpz_lower, + mag_set_fmpz_2exp_fmpz_lower, + mag_mul_2exp_si, + mag_mul_2exp_fmpz, + mag_mul, + mag_mul_ui, + mag_mul_fmpz, + mag_add, + mag_addmul, + mag_add_2exp_fmpz, + mag_div, + mag_div_ui, + mag_div_fmpz, + mag_mul_lower, + mag_mul_ui_lower, + mag_mul_fmpz_lower, + mag_add_lower, + mag_sub_lower, + mag_fast_init_set, + mag_fast_zero, + mag_fast_is_zero, + mag_fast_mul, + mag_fast_addmul, + mag_fast_add_2exp_si, + mag_fast_mul_2exp_si, + mag_pow_ui, + mag_pow_fmpz, + mag_pow_ui_lower, + mag_sqrt, + mag_rsqrt, + mag_hypot, + mag_log1p, + mag_log_ui, + mag_exp, + mag_expm1, + mag_exp_tail, + mag_binpow_uiui, + mag_fac_ui, + mag_rfac_ui, + mag_bernoulli_div_fac_ui, + mag_polylog_tail) diff --git a/src/sage/libs/arb/types.pxd b/src/sage/libs/arb/types.pxd index 98ed96dfb7a..0e9306ecdc2 100644 --- a/src/sage/libs/arb/types.pxd +++ b/src/sage/libs/arb/types.pxd @@ -1,76 +1,42 @@ -# distutils: depends = mag.h arf.h arb.h acb.h acb_mat.h acb_poly.h acb_calc.h - -# mag.h -cdef extern from "arb_wrap.h": - ctypedef struct mag_struct: - pass - ctypedef mag_struct mag_t[1] - ctypedef mag_struct * mag_ptr - ctypedef const mag_struct * mag_srcptr - long MAG_BITS - -# arf.h -cdef extern from "arb_wrap.h": - ctypedef struct arf_struct: - pass - ctypedef arf_struct arf_t[1] - ctypedef arf_struct * arf_ptr - ctypedef const arf_struct * arf_srcptr - cdef enum arf_rnd_t: - ARF_RND_DOWN - ARF_RND_UP - ARF_RND_FLOOR - ARF_RND_CEIL - ARF_RND_NEAR - long ARF_PREC_EXACT - -# arb.h -cdef extern from "arb_wrap.h": - ctypedef struct arb_struct: - pass - ctypedef arb_struct arb_t[1] - ctypedef arb_struct * arb_ptr - ctypedef const arb_struct * arb_srcptr - -# acb.h -cdef extern from "arb_wrap.h": - ctypedef struct acb_struct: - pass - ctypedef acb_struct[1] acb_t - ctypedef acb_struct * acb_ptr - ctypedef const acb_struct * acb_srcptr - -# acb_mat.h -cdef extern from "arb_wrap.h": - ctypedef struct acb_mat_struct: - pass - ctypedef acb_mat_struct[1] acb_mat_t - -# acb_poly.h -cdef extern from "arb_wrap.h": - ctypedef struct acb_poly_struct: - pass - ctypedef acb_poly_struct[1] acb_poly_t - ctypedef acb_poly_struct * acb_poly_ptr - ctypedef const acb_poly_struct * acb_poly_srcptr - -# acb_calc.h -cdef extern from "arb_wrap.h": - ctypedef struct acb_calc_integrate_opt_struct: - long deg_limit - long eval_limit - long depth_limit - bint use_heap - int verbose - ctypedef acb_calc_integrate_opt_struct acb_calc_integrate_opt_t[1] - ctypedef int (*acb_calc_func_t)(acb_ptr out, - const acb_t inp, void * param, long order, long prec) - -# arb_poly.h -cdef extern from "arb_wrap.h": - ctypedef struct arb_poly_struct: - pass - ctypedef arb_poly_struct[1] arb_poly_t - ctypedef arb_poly_struct * arb_poly_ptr - ctypedef const arb_poly_struct * arb_poly_srcptr +# Deprecated header file; use sage/libs/flint/types.pxd instead +# See https://github.com/sagemath/sage/pull/36449 + +from sage.libs.flint.types cimport ( + mag_struct, + mag_struct mag_t, + mag_ptr, + mag_srcptr, + MAG_BITS, + arf_struct, + arf_t, + arf_ptr, + arf_srcptr, + arf_rnd_t, + ARF_RND_DOWN, + ARF_RND_UP, + ARF_RND_FLOOR, + ARF_RND_CEIL, + ARF_RND_NEAR, + ARF_PREC_EXACT, + arb_struct, + arb_t, + arb_ptr, + arb_srcptr, + acb_struct + acb_t, + acb_ptr, + acb_srcptr, + acb_mat_struct, + acb_mat_t, + acb_poly_struct, + acb_poly_t, + acb_poly_ptr, + acb_poly_srcptr, + acb_calc_integrate_opt_struct, + acb_calc_integrate_opt_t, + acb_calc_func_t, + arb_poly_struct, + arb_poly_t, + arb_poly_ptr, + arb_poly_srcptr) From ffe259374bdb93717c41d19c734a8152e6dc01c6 Mon Sep 17 00:00:00 2001 From: Vincent Delecroix Date: Sat, 14 Oct 2023 00:27:59 +0200 Subject: [PATCH 07/41] more flint declarations --- src/sage/libs/flint/acb.pxd | 2 + src/sage/libs/flint/acb_macros.pxd | 11 + src/sage/libs/flint/acb_mat.pxd | 4 +- src/sage/libs/flint/acb_mat_macros.pxd | 14 + src/sage/libs/flint/acb_poly.pxd | 14 +- src/sage/libs/flint/acb_poly_macros.pxd | 8 + src/sage/libs/flint/arb.pxd | 5 + src/sage/libs/flint/arb_calc.pxd | 2 +- src/sage/libs/flint/arb_macros.pxd | 11 + src/sage/libs/flint/arb_mat.pxd | 2 + src/sage/libs/flint/arb_mat_macros.pxd | 14 + src/sage/libs/flint/arb_poly.pxd | 2 +- src/sage/libs/flint/arith.pxd | 403 ++- .../libs/flint/{arith.pyx => arith_sage.pyx} | 2 + src/sage/libs/flint/bernoulli.pxd | 6 +- src/sage/libs/flint/ca_mat.pxd | 8 +- src/sage/libs/flint/fexpr.pxd | 356 +++ src/sage/libs/flint/fexpr_builtin.pxd | 25 + src/sage/libs/flint/fmpq_mat.pxd | 2 + src/sage/libs/flint/fmpq_mat_macros.pxd | 14 + src/sage/libs/flint/fmpq_mpoly.pxd | 422 +++ src/sage/libs/flint/fmpq_mpoly_factor.pxd | 52 + src/sage/libs/flint/fmpq_poly.pxd | 1422 +++++++-- src/sage/libs/flint/fmpq_poly_macros.pxd | 8 + src/sage/libs/flint/fmpq_poly_sage.pxd | 190 ++ .../{fmpq_poly.pyx => fmpq_poly_sage.pyx} | 0 src/sage/libs/flint/fmpz_lll.pxd | 246 ++ src/sage/libs/flint/fmpz_mat.pxd | 2 + src/sage/libs/flint/fmpz_mat_macros.pxd | 14 + src/sage/libs/flint/fmpz_mod_mat.pxd | 252 ++ src/sage/libs/flint/fmpz_mod_mpoly.pxd | 416 +++ src/sage/libs/flint/fmpz_mod_mpoly_factor.pxd | 47 + src/sage/libs/flint/fmpz_mod_poly_factor.pxd | 155 + src/sage/libs/flint/fmpz_mod_vec.pxd | 44 + src/sage/libs/flint/fmpz_mpoly.pxd | 715 +++++ src/sage/libs/flint/fmpz_mpoly_factor.pxd | 48 + src/sage/libs/flint/fmpz_mpoly_q.pxd | 112 + src/sage/libs/flint/fmpz_poly.pxd | 2802 +++++++++++++++-- src/sage/libs/flint/fmpz_poly_factor.pxd | 101 + src/sage/libs/flint/fmpz_poly_macros.pxd | 8 + src/sage/libs/flint/fmpz_poly_mat.pxd | 280 +- src/sage/libs/flint/fmpz_poly_sage.pxd | 19 + .../{fmpz_poly.pyx => fmpz_poly_sage.pyx} | 1 + src/sage/libs/flint/fq_default.pxd | 305 ++ src/sage/libs/flint/fq_default_mat.pxd | 275 ++ src/sage/libs/flint/fq_default_poly.pxd | 358 +++ .../libs/flint/fq_default_poly_factor.pxd | 110 + src/sage/libs/flint/fq_nmod_embed.pxd | 97 + src/sage/libs/flint/fq_nmod_mat.pxd | 366 +++ src/sage/libs/flint/fq_nmod_mpoly.pxd | 365 +++ src/sage/libs/flint/fq_nmod_mpoly_factor.pxd | 47 + src/sage/libs/flint/fq_nmod_poly.pxd | 1064 +++++++ src/sage/libs/flint/fq_nmod_poly_factor.pxd | 168 + src/sage/libs/flint/fq_nmod_vec.pxd | 73 + src/sage/libs/flint/fq_zech.pxd | 380 +++ src/sage/libs/flint/fq_zech_embed.pxd | 97 + src/sage/libs/flint/fq_zech_mat.pxd | 344 ++ src/sage/libs/flint/fq_zech_poly.pxd | 1036 ++++++ src/sage/libs/flint/fq_zech_poly_factor.pxd | 168 + src/sage/libs/flint/fq_zech_vec.pxd | 73 + src/sage/libs/flint/gr.pxd | 429 +++ src/sage/libs/flint/gr_generic.pxd | 271 ++ src/sage/libs/flint/gr_mat.pxd | 541 ++++ src/sage/libs/flint/gr_mpoly.pxd | 124 + src/sage/libs/flint/gr_poly.pxd | 472 +++ src/sage/libs/flint/gr_special.pxd | 318 ++ src/sage/libs/flint/gr_vec.pxd | 176 ++ src/sage/libs/flint/mag.pxd | 365 +++ src/sage/libs/flint/mag_macros.pxd | 8 + src/sage/libs/flint/mpoly.pxd | 281 ++ src/sage/libs/flint/nmod_mpoly.pxd | 424 +++ src/sage/libs/flint/nmod_mpoly_factor.pxd | 47 + src/sage/libs/flint/nmod_poly.pxd | 124 +- src/sage/libs/flint/padic_mat.pxd | 183 ++ src/sage/libs/flint/partitions.pxd | 62 + src/sage/libs/flint/perm.pxd | 48 + src/sage/libs/flint/qqbar.pxd | 704 +++++ src/sage/libs/flint/types.pxd | 225 +- src/sage/libs/flint/ulong_extras.pxd | 1106 ++++++- ...ulong_extras.pyx => ulong_extras_sage.pyx} | 4 + 80 files changed, 18835 insertions(+), 664 deletions(-) create mode 100644 src/sage/libs/flint/acb_macros.pxd create mode 100644 src/sage/libs/flint/acb_mat_macros.pxd create mode 100644 src/sage/libs/flint/acb_poly_macros.pxd create mode 100644 src/sage/libs/flint/arb_macros.pxd create mode 100644 src/sage/libs/flint/arb_mat_macros.pxd rename src/sage/libs/flint/{arith.pyx => arith_sage.pyx} (99%) create mode 100644 src/sage/libs/flint/fexpr.pxd create mode 100644 src/sage/libs/flint/fexpr_builtin.pxd create mode 100644 src/sage/libs/flint/fmpq_mat_macros.pxd create mode 100644 src/sage/libs/flint/fmpq_mpoly.pxd create mode 100644 src/sage/libs/flint/fmpq_mpoly_factor.pxd create mode 100644 src/sage/libs/flint/fmpq_poly_macros.pxd create mode 100644 src/sage/libs/flint/fmpq_poly_sage.pxd rename src/sage/libs/flint/{fmpq_poly.pyx => fmpq_poly_sage.pyx} (100%) create mode 100644 src/sage/libs/flint/fmpz_lll.pxd create mode 100644 src/sage/libs/flint/fmpz_mat_macros.pxd create mode 100644 src/sage/libs/flint/fmpz_mod_mat.pxd create mode 100644 src/sage/libs/flint/fmpz_mod_mpoly.pxd create mode 100644 src/sage/libs/flint/fmpz_mod_mpoly_factor.pxd create mode 100644 src/sage/libs/flint/fmpz_mod_poly_factor.pxd create mode 100644 src/sage/libs/flint/fmpz_mod_vec.pxd create mode 100644 src/sage/libs/flint/fmpz_mpoly.pxd create mode 100644 src/sage/libs/flint/fmpz_mpoly_factor.pxd create mode 100644 src/sage/libs/flint/fmpz_mpoly_q.pxd create mode 100644 src/sage/libs/flint/fmpz_poly_factor.pxd create mode 100644 src/sage/libs/flint/fmpz_poly_macros.pxd create mode 100644 src/sage/libs/flint/fmpz_poly_sage.pxd rename src/sage/libs/flint/{fmpz_poly.pyx => fmpz_poly_sage.pyx} (99%) create mode 100644 src/sage/libs/flint/fq_default.pxd create mode 100644 src/sage/libs/flint/fq_default_mat.pxd create mode 100644 src/sage/libs/flint/fq_default_poly.pxd create mode 100644 src/sage/libs/flint/fq_default_poly_factor.pxd create mode 100644 src/sage/libs/flint/fq_nmod_embed.pxd create mode 100644 src/sage/libs/flint/fq_nmod_mat.pxd create mode 100644 src/sage/libs/flint/fq_nmod_mpoly.pxd create mode 100644 src/sage/libs/flint/fq_nmod_mpoly_factor.pxd create mode 100644 src/sage/libs/flint/fq_nmod_poly.pxd create mode 100644 src/sage/libs/flint/fq_nmod_poly_factor.pxd create mode 100644 src/sage/libs/flint/fq_nmod_vec.pxd create mode 100644 src/sage/libs/flint/fq_zech.pxd create mode 100644 src/sage/libs/flint/fq_zech_embed.pxd create mode 100644 src/sage/libs/flint/fq_zech_mat.pxd create mode 100644 src/sage/libs/flint/fq_zech_poly.pxd create mode 100644 src/sage/libs/flint/fq_zech_poly_factor.pxd create mode 100644 src/sage/libs/flint/fq_zech_vec.pxd create mode 100644 src/sage/libs/flint/gr.pxd create mode 100644 src/sage/libs/flint/gr_generic.pxd create mode 100644 src/sage/libs/flint/gr_mat.pxd create mode 100644 src/sage/libs/flint/gr_mpoly.pxd create mode 100644 src/sage/libs/flint/gr_poly.pxd create mode 100644 src/sage/libs/flint/gr_special.pxd create mode 100644 src/sage/libs/flint/gr_vec.pxd create mode 100644 src/sage/libs/flint/mag.pxd create mode 100644 src/sage/libs/flint/mag_macros.pxd create mode 100644 src/sage/libs/flint/mpoly.pxd create mode 100644 src/sage/libs/flint/nmod_mpoly.pxd create mode 100644 src/sage/libs/flint/nmod_mpoly_factor.pxd create mode 100644 src/sage/libs/flint/padic_mat.pxd create mode 100644 src/sage/libs/flint/partitions.pxd create mode 100644 src/sage/libs/flint/perm.pxd create mode 100644 src/sage/libs/flint/qqbar.pxd rename src/sage/libs/flint/{ulong_extras.pyx => ulong_extras_sage.pyx} (85%) diff --git a/src/sage/libs/flint/acb.pxd b/src/sage/libs/flint/acb.pxd index 9226bea8c25..71ed7da78bd 100644 --- a/src/sage/libs/flint/acb.pxd +++ b/src/sage/libs/flint/acb.pxd @@ -917,3 +917,5 @@ cdef extern from "flint_wrap.h": # Sorts the vector of complex numbers based on the real and imaginary parts. # This is intended to reveal structure when printing a set of complex numbers, # not to apply an order relation in a rigorous way. + +from .acb_macros cimport * diff --git a/src/sage/libs/flint/acb_macros.pxd b/src/sage/libs/flint/acb_macros.pxd new file mode 100644 index 00000000000..ec352a9c264 --- /dev/null +++ b/src/sage/libs/flint/acb_macros.pxd @@ -0,0 +1,11 @@ +# Macros from acb.h +# See https://github.com/flintlib/flint/issues/152 + +from .types cimport * + +cdef extern from "flint_wrap.h": + arb_ptr acb_realref(acb_t x) + # Macro giving a pointer to the real part of x + + arb_ptr acb_imagref(acb_t x) + # Macro giving a pointer to the imaginary part of x diff --git a/src/sage/libs/flint/acb_mat.pxd b/src/sage/libs/flint/acb_mat.pxd index a12ceeda761..0cba753670e 100644 --- a/src/sage/libs/flint/acb_mat.pxd +++ b/src/sage/libs/flint/acb_mat.pxd @@ -466,7 +466,7 @@ cdef extern from "flint_wrap.h": # No assumptions are made about the structure of *A* or the # quality of the given approximations. - void acb_mat_eig_enclosure_rump(acb_t lambda, acb_mat_t J, acb_mat_t R, const acb_mat_t A, const acb_t lambda_approx, const acb_mat_t R_approx, long prec) + void acb_mat_eig_enclosure_rump(acb_t lmbda, acb_mat_t J, acb_mat_t R, const acb_mat_t A, const acb_t lambda_approx, const acb_mat_t R_approx, long prec) # Given an *n* by *n* matrix *A* and an approximate # eigenvalue-eigenvector pair *lambda_approx* and *R_approx* (where # *R_approx* is an *n* by 1 matrix), computes an enclosure @@ -568,3 +568,5 @@ cdef extern from "flint_wrap.h": # call :func:`acb_mat_eig_simple_vdhoeven_mourrain` hoping that the # eigenvalues are actually simple. It then uses the *rump* algorithm as # a fallback. + +from .acb_mat_macros cimport * diff --git a/src/sage/libs/flint/acb_mat_macros.pxd b/src/sage/libs/flint/acb_mat_macros.pxd new file mode 100644 index 00000000000..7803cc4a945 --- /dev/null +++ b/src/sage/libs/flint/acb_mat_macros.pxd @@ -0,0 +1,14 @@ +# Macros from acb_mat.h +# See https://github.com/flintlib/flint/issues/152 + +from .types cimport * + +cdef extern from "flint_wrap.h": + acb_ptr acb_mat_entry(acb_mat_t mat, slong i, slong j) + # Macro giving a pointer to the entry at row *i* and column *j*. + + slong acb_mat_nrows(acb_mat_t) + # Returns the number of rows of the matrix. + + slong acb_mat_ncols(acb_mat_t) + # Returns the number of columns of the matrix. diff --git a/src/sage/libs/flint/acb_poly.pxd b/src/sage/libs/flint/acb_poly.pxd index f097b6df820..8cd0dcda0df 100644 --- a/src/sage/libs/flint/acb_poly.pxd +++ b/src/sage/libs/flint/acb_poly.pxd @@ -131,7 +131,7 @@ cdef extern from "flint_wrap.h": int acb_poly_overlaps(const acb_poly_t poly1, const acb_poly_t poly2) # Returns nonzero iff *poly1* overlaps with *poly2*. The underscore - # function requires that *len1* ist at least as large as *len2*. + # function requires that *len1* is at least as large as *len2*. int acb_poly_get_unique_fmpz_poly(fmpz_poly_t z, const acb_poly_t x) # If *x* contains a unique integer polynomial, sets *z* to that value and returns @@ -588,7 +588,7 @@ cdef extern from "flint_wrap.h": # The underscore method supports aliasing and allows the input to be # shorter than the output, but requires the lengths to be nonzero. - void _acb_poly_sin_cos_series(acb_ptr s, acb_ptr c, const acb_srcptr h, long hlen, long n, long prec) + void _acb_poly_sin_cos_series(acb_ptr s, acb_ptr c, acb_srcptr h, long hlen, long n, long prec) void acb_poly_sin_cos_series(acb_poly_t s, acb_poly_t c, const acb_poly_t h, long n, long prec) # Sets *s* and *c* to the power series sine and cosine of *h*, computed # simultaneously. @@ -615,7 +615,7 @@ cdef extern from "flint_wrap.h": # The underscore version does not support aliasing, and requires # the lengths to be nonzero. - void _acb_poly_sin_cos_pi_series(acb_ptr s, acb_ptr c, const acb_srcptr h, long hlen, long n, long prec) + void _acb_poly_sin_cos_pi_series(acb_ptr s, acb_ptr c, acb_srcptr h, long hlen, long n, long prec) void acb_poly_sin_cos_pi_series(acb_poly_t s, acb_poly_t c, const acb_poly_t h, long n, long prec) @@ -633,15 +633,15 @@ cdef extern from "flint_wrap.h": # Compute the respective trigonometric functions of the input # multiplied by `\pi`. - void _acb_poly_sinh_cosh_series_basecase(acb_ptr s, acb_ptr c, const acb_srcptr h, long hlen, long n, long prec) + void _acb_poly_sinh_cosh_series_basecase(acb_ptr s, acb_ptr c, acb_srcptr h, long hlen, long n, long prec) void acb_poly_sinh_cosh_series_basecase(acb_poly_t s, acb_poly_t c, const acb_poly_t h, long n, long prec) - void _acb_poly_sinh_cosh_series_exponential(acb_ptr s, acb_ptr c, const acb_srcptr h, long hlen, long n, long prec) + void _acb_poly_sinh_cosh_series_exponential(acb_ptr s, acb_ptr c, acb_srcptr h, long hlen, long n, long prec) void acb_poly_sinh_cosh_series_exponential(acb_poly_t s, acb_poly_t c, const acb_poly_t h, long n, long prec) - void _acb_poly_sinh_cosh_series(acb_ptr s, acb_ptr c, const acb_srcptr h, long hlen, long n, long prec) + void _acb_poly_sinh_cosh_series(acb_ptr s, acb_ptr c, acb_srcptr h, long hlen, long n, long prec) void acb_poly_sinh_cosh_series(acb_poly_t s, acb_poly_t c, const acb_poly_t h, long n, long prec) @@ -900,3 +900,5 @@ cdef extern from "flint_wrap.h": # If this function returns zero, then the signs of the imaginary parts # are not known for certain, based on the accuracy of the inputs # and the working precision *prec*. + +from .acb_poly_macros cimport * diff --git a/src/sage/libs/flint/acb_poly_macros.pxd b/src/sage/libs/flint/acb_poly_macros.pxd new file mode 100644 index 00000000000..18a51a7e315 --- /dev/null +++ b/src/sage/libs/flint/acb_poly_macros.pxd @@ -0,0 +1,8 @@ +# Macros from acb_poly.h +# See https://github.com/flintlib/flint/issues/152 + +from .types cimport * + +cdef extern from "flint_wrap.h": + acb_ptr acb_poly_get_coeff_ptr(acb_poly_t p, ulong n) + # Macro giving a pointer to the n-th coefficient of p (or NULL) diff --git a/src/sage/libs/flint/arb.pxd b/src/sage/libs/flint/arb.pxd index 2563924df26..d9cf87bb01d 100644 --- a/src/sage/libs/flint/arb.pxd +++ b/src/sage/libs/flint/arb.pxd @@ -555,6 +555,9 @@ cdef extern from "flint_wrap.h": void arb_max(arb_t z, const arb_t x, const arb_t y, long prec) # Sets *z* respectively to the minimum and the maximum of *x* and *y*. + void arb_minmax(arb_t z1, arb_t z2, const arb_t x, const arb_t y, long prec) + # Sets *z1* and *z2* respectively to the minimum and the maximum of *x* and *y*. + void arb_add(arb_t z, const arb_t x, const arb_t y, long prec) void arb_add_arf(arb_t z, const arb_t x, const arf_t y, long prec) @@ -1485,3 +1488,5 @@ cdef extern from "flint_wrap.h": # Calls :func:`arb_get_unique_fmpz` elementwise and returns nonzero if # all entries can be rounded uniquely to integers. If any entry in *vec* # cannot be rounded uniquely to an integer, returns zero. + +from .arb_macros cimport * diff --git a/src/sage/libs/flint/arb_calc.pxd b/src/sage/libs/flint/arb_calc.pxd index ee897b125d0..c98a6ff5765 100644 --- a/src/sage/libs/flint/arb_calc.pxd +++ b/src/sage/libs/flint/arb_calc.pxd @@ -75,7 +75,7 @@ cdef extern from "flint_wrap.h": # represented exactly as floating-point numbers in memory. # Do not pass `1 \pm 2^{-10^{100}}` as input. - int arb_calc_refine_root_bisect(arf_interval_t r, arb_calc_func_t func, void * param, const arf_interval_t start, long iter, long prec) + int arb_calc_refine_root_bisect(arf_interval_t r, arb_calc_func_t func, void * param, const arf_interval_t start, long it, long prec) # Given an interval *start* known to contain a single root of *func*, # refines it using *iter* bisection steps. The algorithm can # return a failure code if the sign of the function at an evaluation diff --git a/src/sage/libs/flint/arb_macros.pxd b/src/sage/libs/flint/arb_macros.pxd new file mode 100644 index 00000000000..02495200356 --- /dev/null +++ b/src/sage/libs/flint/arb_macros.pxd @@ -0,0 +1,11 @@ +# Macros from arb.h +# See https://github.com/flintlib/flint/issues/152 + +from .types cimport * + +cdef extern from "flint_wrap.h": + arf_ptr arb_midref(arb_t x) + # Macro giving a pointer to the midpoint of x + + mag_ptr arb_radref(arb_t x) + # Macro giving a pointer to the radius of x diff --git a/src/sage/libs/flint/arb_mat.pxd b/src/sage/libs/flint/arb_mat.pxd index 2bfe405fa14..1394a44ab39 100644 --- a/src/sage/libs/flint/arb_mat.pxd +++ b/src/sage/libs/flint/arb_mat.pxd @@ -545,3 +545,5 @@ cdef extern from "flint_wrap.h": void arb_mat_add_error_mag(arb_mat_t mat, const mag_t err) # Adds *err* in-place to the radii of the entries of *mat*. + +from .arb_mat_macros cimport * diff --git a/src/sage/libs/flint/arb_mat_macros.pxd b/src/sage/libs/flint/arb_mat_macros.pxd new file mode 100644 index 00000000000..99ba7bca0e4 --- /dev/null +++ b/src/sage/libs/flint/arb_mat_macros.pxd @@ -0,0 +1,14 @@ +# Macros from arb_mat.h +# See https://github.com/flintlib/flint/issues/152 + +from .types cimport * + +cdef extern from "flint_wrap.h": + arb_ptr arb_mat_entry(arb_mat_t mat, slong i, slong j) + # Macro giving a pointer to the entry at row *i* and column *j*. + + slong arb_mat_nrows(arb_mat_t) + # Returns the number of rows of the matrix. + + slong arb_mat_ncols(arb_mat_t) + # Returns the number of columns of the matrix. diff --git a/src/sage/libs/flint/arb_poly.pxd b/src/sage/libs/flint/arb_poly.pxd index e71fa90ec2a..cefd8845a26 100644 --- a/src/sage/libs/flint/arb_poly.pxd +++ b/src/sage/libs/flint/arb_poly.pxd @@ -135,7 +135,7 @@ cdef extern from "flint_wrap.h": int arb_poly_overlaps(const arb_poly_t poly1, const arb_poly_t poly2) # Returns nonzero iff *poly1* overlaps with *poly2*. The underscore - # function requires that *len1* ist at least as large as *len2*. + # function requires that *len1* is at least as large as *len2*. int arb_poly_get_unique_fmpz_poly(fmpz_poly_t z, const arb_poly_t x) # If *x* contains a unique integer polynomial, sets *z* to that value and returns diff --git a/src/sage/libs/flint/arith.pxd b/src/sage/libs/flint/arith.pxd index c8e1fb35566..f784056e447 100644 --- a/src/sage/libs/flint/arith.pxd +++ b/src/sage/libs/flint/arith.pxd @@ -1,15 +1,398 @@ # distutils: libraries = flint # distutils: depends = flint/arith.h -from sage.libs.flint.types cimport fmpz_t, fmpq_t, ulong, slong +################################################################################ +# This file is auto-generated. Do not modify by hand +################################################################################ + +from libc.stdio cimport FILE +from sage.libs.gmp.types cimport * +from sage.libs.mpfr.types cimport * +from sage.libs.flint.types cimport * -# flint/arith.h cdef extern from "flint_wrap.h": - void arith_bell_number(fmpz_t b, ulong n) - void arith_bernoulli_number(fmpq_t x, ulong n) - void arith_euler_number(fmpz_t res, ulong n) - void arith_stirling_number_1u(fmpz_t res, slong n, slong k) - void arith_stirling_number_2(fmpz_t res, slong n, slong k) - void arith_number_of_partitions(fmpz_t x, ulong n) - void arith_dedekind_sum(fmpq_t, fmpz_t, fmpz_t) - void arith_harmonic_number(fmpq_t, unsigned long n) + + void arith_primorial(fmpz_t res, long n) + # Sets ``res`` to ``n`` primorial or `n \#`, the product of all prime + # numbers less than or equal to `n`. + + void _arith_harmonic_number(fmpz_t num, fmpz_t den, long n) + void arith_harmonic_number(fmpq_t x, long n) + # These are aliases for the functions in the fmpq module. + + void arith_stirling_number_1u(fmpz_t s, unsigned long n, unsigned long k) + + void arith_stirling_number_1(fmpz_t s, unsigned long n, unsigned long k) + + void arith_stirling_number_2(fmpz_t s, unsigned long n, unsigned long k) + # Sets `s` to `S(n,k)` where `S(n,k)` denotes an unsigned Stirling + # number of the first kind `|S_1(n, k)|`, a signed Stirling number + # of the first kind `S_1(n, k)`, or a Stirling number of the second + # kind `S_2(n, k)`. The Stirling numbers are defined using the + # generating functions + # .. math :: + # x_{(n)} = \sum_{k=0}^n S_1(n,k) x^k + # x^{(n)} = \sum_{k=0}^n |S_1(n,k)| x^k + # x^n = \sum_{k=0}^n S_2(n,k) x_{(k)} + # where `x_{(n)} = x(x-1)(x-2) \dotsm (x-n+1)` is a falling factorial + # and `x^{(n)} = x(x+1)(x+2) \dotsm (x+n-1)` is a rising factorial. + # `S(n,k)` is taken to be zero if `n < 0` or `k < 0`. + # These three functions are useful for computing isolated Stirling + # numbers efficiently. To compute a range of numbers, the vector or + # matrix versions should generally be used. + + void arith_stirling_number_1u_vec(fmpz * row, unsigned long n, long klen) + + void arith_stirling_number_1_vec(fmpz * row, unsigned long n, long klen) + + void arith_stirling_number_2_vec(fmpz * row, unsigned long n, long klen) + # Computes the row of Stirling numbers + # ``S(n,0), S(n,1), S(n,2), ..., S(n,klen-1)``. + # To compute a full row, this function can be called with + # ``klen = n+1``. It is assumed that ``klen`` is at most `n + 1`. + + void arith_stirling_number_1u_vec_next(fmpz * row, const fmpz * prev, long n, long klen) + + void arith_stirling_number_1_vec_next(fmpz * row, const fmpz * prev, long n, long klen) + + void arith_stirling_number_2_vec_next(fmpz * row, const fmpz * prev, long n, long klen) + # Given the vector ``prev`` containing a row of Stirling numbers + # ``S(n-1,0), S(n-1,1), S(n-1,2), ..., S(n-1,klen-1)``, computes + # and stores in the row argument + # ``S(n,0), S(n,1), S(n,2), ..., S(n,klen-1)``. + # If ``klen`` is greater than ``n``, the output ends with + # ``S(n,n) = 1`` followed by ``S(n,n+1) = S(n,n+2) = ... = 0``. + # In this case, the input only needs to have length ``n-1``; + # only the input entries up to ``S(n-1,n-2)`` are read. + # The ``row`` and ``prev`` arguments are permitted to be the + # same, meaning that the row will be updated in-place. + + void arith_stirling_matrix_1u(fmpz_mat_t mat) + + void arith_stirling_matrix_1(fmpz_mat_t mat) + + void arith_stirling_matrix_2(fmpz_mat_t mat) + # For an arbitrary `m`-by-`n` matrix, writes the truncation of the + # infinite Stirling number matrix:: + # row 0 : S(0,0) + # row 1 : S(1,0), S(1,1) + # row 2 : S(2,0), S(2,1), S(2,2) + # row 3 : S(3,0), S(3,1), S(3,2), S(3,3) + # up to row `m-1` and column `n-1` inclusive. The upper triangular + # part of the matrix is zeroed. + # For any `n`, the `S_1` and `S_2` matrices thus obtained are + # inverses of each other. + + void arith_bell_number(fmpz_t b, unsigned long n) + void arith_bell_number_dobinski(fmpz_t res, unsigned long n) + void arith_bell_number_multi_mod(fmpz_t res, unsigned long n) + # Sets `b` to the Bell number `B_n`, defined as the + # number of partitions of a set with `n` members. Equivalently, + # `B_n = \sum_{k=0}^n S_2(n,k)` where `S_2(n,k)` denotes a Stirling number + # of the second kind. + # The default version automatically selects between table lookup, + # Dobinski's formula, and the multimodular algorithm. + # The ``dobinski`` version evaluates a precise truncation of + # the series `B_n = e^{-1} \sum_{k=0}^{\infty} \frac{k^n}{k!}` + # (Dobinski's formula). In fact, we compute `P = N! \sum_{k=0}^N \frac{k^n}{k!}` + # and `Q = N! \sum_{k=0}^N \frac{1}{k!} \approx N! e` and + # evaluate `B_n = \lceil P / Q \rceil`, avoiding the use + # of floating-point arithmetic. + # The ``multi_mod`` version computes the result modulo several limb-size + # primes and reconstructs the integer value using the fast + # Chinese remainder algorithm. + # A bound for the number of needed primes is computed using + # ``arith_bell_number_size``. + + void arith_bell_number_vec(fmpz * b, long n) + void arith_bell_number_vec_recursive(fmpz * b, long n) + void arith_bell_number_vec_multi_mod(fmpz * b, long n) + # Sets `b` to the vector of Bell numbers `B_0, B_1, \ldots, B_{n-1}` + # inclusive. The ``recursive`` version uses the `O(n^3 \log n)` + # triangular recurrence, while the ``multi_mod`` version implements + # multimodular evaluation of the exponential generating function, + # running in time `O(n^2 \log^{O(1)} n)`. The default version + # chooses an algorithm automatically. + + mp_limb_t arith_bell_number_nmod(unsigned long n, nmod_t mod) + # Computes the Bell number `B_n` modulo an integer given by ``mod``. + # After handling special cases, we use the formula + # .. math :: + # B_n = \sum_{k=0}^n \frac{(n-k)^n}{(n-k)!} + # \sum_{j=0}^k \frac{(-1)^j}{j!}. + # We arrange the operations in such a way that we only have to + # multiply (and not divide) in the main loop. As a further optimisation, + # we use sieving to reduce the number of powers that need to be + # evaluated. This results in `O(n)` memory usage. + # If the divisions by factorials are impossible, we fall back to + # calling ``arith_bell_number_nmod_vec`` and reading the last + # coefficient. + + void arith_bell_number_nmod_vec(mp_ptr b, long n, nmod_t mod) + void arith_bell_number_nmod_vec_recursive(mp_ptr b, long n, nmod_t mod) + void arith_bell_number_nmod_vec_ogf(mp_ptr b, long n, nmod_t mod) + int arith_bell_number_nmod_vec_series(mp_ptr b, long n, nmod_t mod) + # Sets `b` to the vector of Bell numbers `B_0, B_1, \ldots, B_{n-1}` + # inclusive modulo an integer given by ``mod``. + # The *recursive* version uses the `O(n^2)` triangular recurrence. + # The *ogf* version expands the ordinary generating function + # using binary splitting, which is `O(n \log^2 n)`. + # The *series* version uses the exponential generating function + # `\sum_{k=0}^{\infty} \frac{B_n}{n!} x^n = \exp(e^x-1)`, + # running in `O(n \log n)`. + # This only works if division by `n!` is possible, and the function + # returns whether it is successful. All other versions + # support any modulus. + # The default version of this function selects an algorithm + # automatically. + + double arith_bell_number_size(unsigned long n) + # Returns `b` such that `B_n < 2^{\lfloor b \rfloor}`. A previous + # version of this function used the inequality + # `B_n < \left(\frac{0.792n}{\log(n+1)}\right)^n` which is given + # in [BerTas2010]_; we now use a slightly better bound + # based on an asymptotic expansion. + + void _arith_bernoulli_number(fmpz_t num, fmpz_t den, unsigned long n) + # Sets ``(num, den)`` to the reduced numerator and denominator + # of the `n`-th Bernoulli number. + + void arith_bernoulli_number(fmpq_t x, unsigned long n) + # Sets ``x`` to the `n`-th Bernoulli number. This function is + # equivalent to ``_arith_bernoulli_number`` apart from the output + # being a single ``fmpq_t`` variable. + + void _arith_bernoulli_number_vec(fmpz * num, fmpz * den, long n) + # Sets the elements of ``num`` and ``den`` to the reduced + # numerators and denominators of the Bernoulli numbers + # `B_0, B_1, B_2, \ldots, B_{n-1}` inclusive. This function automatically + # chooses between the ``recursive``, ``zeta`` and ``multi_mod`` + # algorithms according to the size of `n`. + + void arith_bernoulli_number_vec(fmpq * x, long n) + # Sets the ``x`` to the vector of Bernoulli numbers + # `B_0, B_1, B_2, \ldots, B_{n-1}` inclusive. This function is + # equivalent to ``_arith_bernoulli_number_vec`` apart + # from the output being a single ``fmpq`` vector. + + void arith_bernoulli_number_denom(fmpz_t den, unsigned long n) + # Sets ``den`` to the reduced denominator of the `n`-th + # Bernoulli number `B_n`. For even `n`, the denominator is computed + # as the product of all primes `p` for which `p - 1` divides `n`; + # this property is a consequence of the von Staudt-Clausen theorem. + # For odd `n`, the denominator is trivial (``den`` is set to 1 whenever + # `B_n = 0`). The initial sequence of values smaller than `2^{32}` are + # looked up directly from a table. + + double arith_bernoulli_number_size(unsigned long n) + # Returns `b` such that `|B_n| < 2^{\lfloor b \rfloor}`, using the inequality + # `|B_n| < \frac{4 n!}{(2\pi)^n}` and `n! \le (n+1)^{n+1} e^{-n}`. + # No special treatment is given to odd `n`. Accuracy is not guaranteed + # if `n > 10^{14}`. + + void arith_bernoulli_polynomial(fmpq_poly_t poly, unsigned long n) + # Sets ``poly`` to the Bernoulli polynomial of degree `n`, + # `B_n(x) = \sum_{k=0}^n \binom{n}{k} B_k x^{n-k}` where `B_k` + # is a Bernoulli number. This function basically calls + # ``arith_bernoulli_number_vec`` and then rescales the coefficients + # efficiently. + + void _arith_bernoulli_number_vec_recursive(fmpz * num, fmpz * den, long n) + # Sets the elements of ``num`` and ``den`` to the reduced + # numerators and denominators of `B_0, B_1, B_2, \ldots, B_{n-1}` + # inclusive. + # The first few entries are computed using ``arith_bernoulli_number``, + # and then Ramanujan's recursive formula expressing `B_m` as a sum over + # `B_k` for `k` congruent to `m` modulo 6 is applied repeatedly. + # To avoid costly GCDs, the numerators are transformed internally + # to a common denominator and all operations are performed using + # integer arithmetic. This makes the algorithm fast for small `n`, + # say `n < 1000`. The common denominator is calculated directly + # as the primorial of `n + 1`. + # %[1] https://en.wikipedia.org/w/index.php?title=Bernoulli_number&oldid=405938876 + + void _arith_bernoulli_number_vec_multi_mod(fmpz * num, fmpz * den, long n) + # Sets the elements of ``num`` and ``den`` to the reduced + # numerators and denominators of `B_0, B_1, B_2, \ldots, B_{n-1}` + # inclusive. Uses the generating function + # .. math :: + # \frac{x^2}{\cosh(x)-1} = \sum_{k=0}^{\infty} + # \frac{(2-4k) B_{2k}}{(2k)!} x^{2k} + # which is evaluated modulo several limb-size primes using ``nmod_poly`` + # arithmetic to yield the numerators of the Bernoulli numbers after + # multiplication by the denominators and CRT reconstruction. This formula, + # given (incorrectly) in [BuhlerCrandallSompolski1992]_, saves about + # half of the time compared to the usual generating function `x/(e^x-1)` + # since the odd terms vanish. + + void arith_euler_number(fmpz_t res, unsigned long n) + # Sets ``res`` to the Euler number `E_n`. + + void arith_euler_number_vec(fmpz * res, long n) + # Computes the Euler numbers `E_0, E_1, \dotsc, E_{n-1}` for `n \geq 0` + # and stores the result in ``res``, which must be an initialised + # ``fmpz`` vector of sufficient size. + # This function evaluates the even-index `E_k` modulo several limb-size + # primes using the generating function and ``nmod_poly`` arithmetic. + # A tight bound for the number of needed primes is computed using + # ``arith_euler_number_size``, and the final integer values are recovered + # using balanced CRT reconstruction. + + double arith_euler_number_size(unsigned long n) + # Returns `b` such that `|E_n| < 2^{\lfloor b \rfloor}`, using the inequality + # ``|E_n| < \frac{2^{n+2} n!}{\pi^{n+1}}`` and `n! \le (n+1)^{n+1} e^{-n}`. + # No special treatment is given to odd `n`. + # Accuracy is not guaranteed if `n > 10^{14}`. + + void arith_euler_polynomial(fmpq_poly_t poly, unsigned long n) + # Sets ``poly`` to the Euler polynomial `E_n(x)`. Uses the formula + # .. math :: + # E_n(x) = \frac{2}{n+1}\left(B_{n+1}(x) - + # 2^{n+1}B_{n+1}\left(\frac{x}{2}\right)\right), + # with the Bernoulli polynomial `B_{n+1}(x)` evaluated once + # using ``bernoulli_polynomial`` and then rescaled. + + 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, unsigned long k, const fmpz_t n) + # These are aliases for the functions in the fmpz module. + + void arith_divisors(fmpz_poly_t res, const fmpz_t n) + # Set the coefficients of the polynomial ``res`` to the divisors of `n`, + # including `1` and `n` itself, in ascending order. + + void arith_ramanujan_tau(fmpz_t res, const fmpz_t n) + # Sets ``res`` to the Ramanujan tau function `\tau(n)` which is the + # coefficient of `q^n` in the series expansion of + # `f(q) = q \prod_{k \geq 1} \bigl(1 - q^k\bigr)^{24}`. + # We factor `n` and use the identity `\tau(pq) = \tau(p) \tau(q)` + # along with the recursion + # `\tau(p^{r+1}) = \tau(p) \tau(p^r) - p^{11} \tau(p^{r-1})` + # for prime powers. + # The base values `\tau(p)` are obtained using the function + # ``arith_ramanujan_tau_series()``. Thus the speed of + # ``arith_ramanujan_tau()`` depends on the largest prime factor of `n`. + # Future improvement: optimise this function for small `n`, which + # could be accomplished using a lookup table or by calling + # ``arith_ramanujan_tau_series()`` directly. + + void arith_ramanujan_tau_series(fmpz_poly_t res, long n) + # Sets ``res`` to the polynomial with coefficients + # `\tau(0),\tau(1), \dotsc, \tau(n-1)`, giving the initial `n` terms + # in the series expansion of + # `f(q) = q \prod_{k \geq 1} \bigl(1-q^k\bigr)^{24}`. + # We use the theta function identity + # .. math :: + # f(q) = q \Biggl( \sum_{k \geq 0} (-1)^k (2k+1) q^{k(k+1)/2} \Biggr)^8 + # which is evaluated using three squarings. The first squaring is done + # directly since the polynomial is very sparse at this point. + + void arith_landau_function_vec(fmpz * res, long len) + # Computes the first ``len`` values of Landau's function `g(n)` + # starting with `g(0)`. Landau's function gives the largest order + # of an element of the symmetric group `S_n`. + # Implements the "basic algorithm" given in + # [DelegliseNicolasZimmermann2009]_. The running time is + # `O(n^{3/2} / \sqrt{\log n})`. + + 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) + # These are aliases for the functions in the fmpq module. + + void arith_number_of_partitions_vec(fmpz * res, long len) + # Computes first ``len`` values of the partition function `p(n)` + # starting with `p(0)`. Uses inversion of Euler's pentagonal series. + + void arith_number_of_partitions_nmod_vec(mp_ptr res, long len, nmod_t mod) + # Computes first ``len`` values of the partition function `p(n)` + # starting with `p(0)`, modulo the modulus defined by ``mod``. + # Uses inversion of Euler's pentagonal series. + + void arith_hrr_expsum_factored(trig_prod_t prod, mp_limb_t k, mp_limb_t n) + # Symbolically evaluates the exponential sum + # .. math :: + # A_k(n) = \sum_{h=0}^{k-1} + # \exp\left(\pi i \left[ s(h,k) - \frac{2hn}{k}\right]\right) + # appearing in the Hardy-Ramanujan-Rademacher formula, where `s(h,k)` is a + # Dedekind sum. + # Rather than evaluating the sum naively, we factor `A_k(n)` into a + # product of cosines based on the prime factorisation of `k`. This + # process is based on the identities given in [Whiteman1956]_. + # The special ``trig_prod_t`` structure ``prod`` represents a + # product of cosines of rational arguments, multiplied by an algebraic + # prefactor. It must be pre-initialised with ``trig_prod_init``. + # This function assumes that `24k` and `24n` do not overflow a single limb. + # If `n` is larger, it can be pre-reduced modulo `k`, since `A_k(n)` + # only depends on the value of `n \bmod k`. + + void arith_number_of_partitions_mpfr(mpfr_t x, unsigned long n) + # Sets the pre-initialised MPFR variable `x` to the exact value of `p(n)`. + # The value is computed using the Hardy-Ramanujan-Rademacher formula. + # The precision of `x` will be changed to allow `p(n)` to be represented + # exactly. The interface of this function may be updated in the future + # to allow computing an approximation of `p(n)` to smaller precision. + # The Hardy-Ramanujan-Rademacher formula is given with error bounds + # in [Rademacher1937]_. We evaluate it in the form + # .. math :: + # p(n) = \sum_{k=1}^N B_k(n) U(C/k) + R(n,N) + # where + # .. math :: + # U(x) = \cosh(x) + \frac{\sinh(x)}{x}, + # \quad C = \frac{\pi}{6} \sqrt{24n-1} + # B_k(n) = \sqrt{\frac{3}{k}} \frac{4}{24n-1} A_k(n) + # and where `A_k(n)` is a certain exponential sum. The remainder satisfies + # .. math :: + # |R(n,N)| < \frac{44 \pi^2}{225 \sqrt{3}} N^{-1/2} + + # \frac{\pi \sqrt{2}}{75} \left(\frac{N}{n-1}\right)^{1/2} + # \sinh\left(\pi \sqrt{\frac{2}{3}} \frac{\sqrt{n}}{N} \right). + # We choose `N` such that `|R(n,N)| < 0.25`, and a working precision + # at term `k` such that the absolute error of the term is expected to be + # less than `0.25 / N`. We also use a summation variable with increased + # precision, essentially making additions exact. Thus the sum of errors + # adds up to less than 0.5, giving the correct value of `p(n)` when + # rounding to the nearest integer. + # The remainder estimate at step `k` provides an upper bound for the size + # of the `k`-th term. We add `\log_2 N` bits to get low bits in the terms + # below `0.25 / N` in magnitude. + # Using ``arith_hrr_expsum_factored``, each `B_k(n)` evaluation + # is broken down to a product of cosines of exact rational multiples + # of `\pi`. We transform all angles to `(0, \pi/4)` for optimal accuracy. + # Since the evaluation of each term involves only `O(\log k)` multiplications + # and evaluations of trigonometric functions of small angles, the + # relative rounding error is at most a few bits. We therefore just add + # an additional `\log_2 (C/k)` bits for the `U(x)` when `x` is large. + # The cancellation of terms in `U(x)` is of no concern, since Rademacher's + # bound allows us to terminate before `x` becomes small. + # This analysis should be performed in more detail to give a rigorous + # error bound, but the precision currently implemented is almost + # certainly sufficient, not least considering that Rademacher's + # remainder bound significantly overshoots the actual values. + # To improve performance, we switch to doubles when the working precision + # becomes small enough. We also use a separate accumulator variable + # which gets added to the main sum periodically, in order to avoid + # costly updates of the full-precision result when `n` is large. + + void arith_number_of_partitions(fmpz_t x, unsigned long n) + # Sets `x` to `p(n)`, the number of ways that `n` can be written + # as a sum of positive integers without regard to order. + # This function uses a lookup table for `n < 128` (where `p(n) < 2^{32}`), + # and otherwise calls ``arith_number_of_partitions_mpfr``. + + void arith_sum_of_squares(fmpz_t r, unsigned long k, const fmpz_t n) + # Sets `r` to the number of ways `r_k(n)` in which `n` can be represented + # as a sum of `k` squares. + # If `k = 2` or `k = 4`, we write `r_k(n)` as a divisor sum. + # Otherwise, we either recurse on `k` or compute the theta function + # expansion up to `O(x^{n+1})` and read off the last coefficient. + # This is generally optimal. + + void arith_sum_of_squares_vec(fmpz * r, unsigned long k, long n) + # For `i = 0, 1, \ldots, n-1`, sets `r_i` to the number of + # representations of `i` a sum of `k` squares, `r_k(i)`. + # This effectively computes the `q`-expansion of `\vartheta_3(q)` + # raised to the `k`-th power, i.e. + # .. math :: + # \vartheta_3^k(q) = \left( \sum_{i=-\infty}^{\infty} q^{i^2} \right)^k. diff --git a/src/sage/libs/flint/arith.pyx b/src/sage/libs/flint/arith_sage.pyx similarity index 99% rename from src/sage/libs/flint/arith.pyx rename to src/sage/libs/flint/arith_sage.pyx index fefe5f07efd..842d9782869 100644 --- a/src/sage/libs/flint/arith.pyx +++ b/src/sage/libs/flint/arith_sage.pyx @@ -15,8 +15,10 @@ FLINT Arithmetic Functions from cysignals.signals cimport sig_on, sig_off +from sage.libs.flint.types cimport * from sage.libs.flint.fmpz cimport * from sage.libs.flint.fmpq cimport * +from sage.libs.flint.arith cimport * from sage.rings.integer cimport Integer diff --git a/src/sage/libs/flint/bernoulli.pxd b/src/sage/libs/flint/bernoulli.pxd index 922fe433d26..0e59332afcb 100644 --- a/src/sage/libs/flint/bernoulli.pxd +++ b/src/sage/libs/flint/bernoulli.pxd @@ -12,17 +12,17 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void bernoulli_rev_init(bernoulli_rev_t iter, unsigned long n) + void bernoulli_rev_init(bernoulli_rev_t it, unsigned long n) # Initializes the iterator *iter*. The first Bernoulli number to # be generated by calling :func:`bernoulli_rev_next` is `B_n`. # It is assumed that `n` is even. - void bernoulli_rev_next(fmpz_t numer, fmpz_t denom, bernoulli_rev_t iter) + void bernoulli_rev_next(fmpz_t numer, fmpz_t denom, bernoulli_rev_t it) # Sets *numer* and *denom* to the exact, reduced numerator and denominator # of the Bernoulli number `B_k` and advances the state of *iter* # so that the next invocation generates `B_{k-2}`. - void bernoulli_rev_clear(bernoulli_rev_t iter) + void bernoulli_rev_clear(bernoulli_rev_t it) # Frees all memory allocated internally by *iter*. void bernoulli_fmpq_vec_no_cache(fmpq * res, unsigned long a, long num) diff --git a/src/sage/libs/flint/ca_mat.pxd b/src/sage/libs/flint/ca_mat.pxd index e29429db86e..807e612f59d 100644 --- a/src/sage/libs/flint/ca_mat.pxd +++ b/src/sage/libs/flint/ca_mat.pxd @@ -372,7 +372,7 @@ cdef extern from "flint_wrap.h": # It returns 0 if the leading coefficient of *poly* cannot be # proved nonzero or if the size of the output matrix does not match. - int ca_mat_eigenvalues(ca_vec_t lambda, unsigned long * exp, const ca_mat_t mat, ca_ctx_t ctx) + int ca_mat_eigenvalues(ca_vec_t lmbda, unsigned long * exp, const ca_mat_t mat, ca_ctx_t ctx) # Attempts to compute all complex eigenvalues of the given matrix *mat*. # On success, returns 1 and sets *lambda* to the distinct eigenvalues # with corresponding multiplicities in *exp*. @@ -391,7 +391,7 @@ cdef extern from "flint_wrap.h": # If the return value is not ``T_TRUE``, the values in *D* and *P* # are arbitrary. - int ca_mat_jordan_blocks(ca_vec_t lambda, long * num_blocks, long * block_lambda, long * block_size, const ca_mat_t A, ca_ctx_t ctx) + int ca_mat_jordan_blocks(ca_vec_t lmbda, long * num_blocks, long * block_lambda, long * block_size, const ca_mat_t A, ca_ctx_t ctx) # Computes the blocks of the Jordan canonical form of *A*. # On success, returns 1 and sets *lambda* to the unique eigenvalues # of *A*, sets *num_blocks* to the number of Jordan blocks, @@ -404,13 +404,13 @@ cdef extern from "flint_wrap.h": # The Jordan form is unique up to the ordering of blocks, which # is arbitrary. - void ca_mat_set_jordan_blocks(ca_mat_t mat, const ca_vec_t lambda, long num_blocks, long * block_lambda, long * block_size, ca_ctx_t ctx) + void ca_mat_set_jordan_blocks(ca_mat_t mat, const ca_vec_t lmbda, long num_blocks, long * block_lambda, long * block_size, ca_ctx_t ctx) # Sets *mat* to the concatenation of the Jordan blocks # given in *lambda*, *num_blocks*, *block_lambda* and *block_size*. # See :func:`ca_mat_jordan_blocks` for an explanation of these # variables. - int ca_mat_jordan_transformation(ca_mat_t mat, const ca_vec_t lambda, long num_blocks, long * block_lambda, long * block_size, const ca_mat_t A, ca_ctx_t ctx) + int ca_mat_jordan_transformation(ca_mat_t mat, const ca_vec_t lmbda, long num_blocks, long * block_lambda, long * block_size, const ca_mat_t A, ca_ctx_t ctx) # Given the precomputed Jordan block decomposition # (*lambda*, *num_blocks*, *block_lambda*, *block_size*) of the # square matrix *A*, computes the corresponding transformation diff --git a/src/sage/libs/flint/fexpr.pxd b/src/sage/libs/flint/fexpr.pxd new file mode 100644 index 00000000000..83107681649 --- /dev/null +++ b/src/sage/libs/flint/fexpr.pxd @@ -0,0 +1,356 @@ +# distutils: libraries = flint +# distutils: depends = flint/fexpr.h + +################################################################################ +# This file is auto-generated. Do not modify by hand +################################################################################ + +from libc.stdio cimport FILE +from sage.libs.gmp.types cimport * +from sage.libs.mpfr.types cimport * +from sage.libs.flint.types cimport * + +cdef extern from "flint_wrap.h": + + void fexpr_init(fexpr_t expr) + # Initializes *expr* for use. Its value is set to the atomic + # integer 0. + + void fexpr_clear(fexpr_t expr) + # Clears *expr*, freeing its allocated memory. + + fexpr_ptr _fexpr_vec_init(long len) + # Returns a heap-allocated vector of *len* initialized expressions. + + void _fexpr_vec_clear(fexpr_ptr vec, long len) + # Clears the *len* expressions in *vec* and frees *vec* itself. + + void fexpr_fit_size(fexpr_t expr, long size) + # Ensures that *expr* has room for *size* words. + + void fexpr_set(fexpr_t res, const fexpr_t expr) + # Sets *res* to the a copy of *expr*. + + void fexpr_swap(fexpr_t a, fexpr_t b) + # Swaps *a* and *b* efficiently. + + long fexpr_depth(const fexpr_t expr) + # Returns the depth of *expr* as a symbolic expression tree. + + long fexpr_num_leaves(const fexpr_t expr) + # Returns the number of leaves (atoms, counted with repetition) + # in the expression *expr*. + + long fexpr_size(const fexpr_t expr) + # Returns the number of words in the internal representation + # of *expr*. + + long fexpr_size_bytes(const fexpr_t expr) + # Returns the number of bytes in the internal representation + # of *expr*. The count excludes the size of the structure itself. + # Add ``sizeof(fexpr_struct)`` to get the size of the object as a + # whole. + + long fexpr_allocated_bytes(const fexpr_t expr) + # Returns the number of allocated bytes in the internal + # representation of *expr*. The count excludes the size of the + # structure itself. Add ``sizeof(fexpr_struct)`` to get the size of + # the object as a whole. + + int fexpr_equal(const fexpr_t a, const fexpr_t b) + # Checks if *a* and *b* are exactly equal as expressions. + + int fexpr_equal_si(const fexpr_t expr, long c) + + int fexpr_equal_ui(const fexpr_t expr, unsigned long c) + # Checks if *expr* is an atomic integer exactly equal to *c*. + + unsigned long fexpr_hash(const fexpr_t expr) + # Returns a hash of the expression *expr*. + + int fexpr_cmp_fast(const fexpr_t a, const fexpr_t b) + # Compares *a* and *b* using an ordering based on the internal + # representation, returning -1, 0 or 1. This can be used, for + # instance, to maintain sorted arrays of expressions for binary + # search; the sort order has no mathematical significance. + + int fexpr_is_integer(const fexpr_t expr) + # Returns whether *expr* is an atomic integer + + int fexpr_is_symbol(const fexpr_t expr) + # Returns whether *expr* is an atomic symbol. + + int fexpr_is_string(const fexpr_t expr) + # Returns whether *expr* is an atomic string. + + int fexpr_is_atom(const fexpr_t expr) + # Returns whether *expr* is any atom. + + void fexpr_zero(fexpr_t res) + # Sets *res* to the atomic integer 0. + + int fexpr_is_zero(const fexpr_t expr) + # Returns whether *expr* is the atomic integer 0. + + int fexpr_is_neg_integer(const fexpr_t expr) + # Returns whether *expr* is any negative atomic integer. + + void fexpr_set_si(fexpr_t res, long c) + void fexpr_set_ui(fexpr_t res, unsigned long c) + void fexpr_set_fmpz(fexpr_t res, const fmpz_t c) + # Sets *res* to the atomic integer *c*. + + int fexpr_get_fmpz(fmpz_t res, const fexpr_t expr) + # Sets *res* to the atomic integer in *expr*. This aborts + # if *expr* is not an atomic integer. + + void fexpr_set_symbol_builtin(fexpr_t res, long id) + # Sets *res* to the builtin symbol with internal index *id* + # (see :ref:`fexpr-builtin`). + + int fexpr_is_builtin_symbol(const fexpr_t expr, long id) + # Returns whether *expr* is the builtin symbol with index *id* + # (see :ref:`fexpr-builtin`). + + int fexpr_is_any_builtin_symbol(const fexpr_t expr) + # Returns whether *expr* is any builtin symbol + # (see :ref:`fexpr-builtin`). + + void fexpr_set_symbol_str(fexpr_t res, const char * s) + # Sets *res* to the symbol given by *s*. + + char * fexpr_get_symbol_str(const fexpr_t expr) + # Returns the symbol in *expr* as a string. The string must + # be freed with :func:`flint_free`. + # This aborts if *expr* is not an atomic symbol. + + void fexpr_set_string(fexpr_t res, const char * s) + # Sets *res* to the atomic string *s*. + + char * fexpr_get_string(const fexpr_t expr) + # Assuming that *expr* is an atomic string, returns a copy of this + # string. The string must be freed with :func:`flint_free`. + + void fexpr_write(calcium_stream_t stream, const fexpr_t expr) + # Writes *expr* to *stream*. + + void fexpr_print(const fexpr_t expr) + # Prints *expr* to standard output. + + char * fexpr_get_str(const fexpr_t expr) + # Returns a string representation of *expr*. The string must + # be freed with :func:`flint_free`. + # Warning: string literals appearing in expressions + # are currently not escaped. + + void fexpr_write_latex(calcium_stream_t stream, const fexpr_t expr, unsigned long flags) + # Writes the LaTeX representation of *expr* to *stream*. + + void fexpr_print_latex(const fexpr_t expr, unsigned long flags) + # Prints the LaTeX representation of *expr* to standard output. + + char * fexpr_get_str_latex(const fexpr_t expr, unsigned long flags) + # Returns a string of the LaTeX representation of *expr*. The string + # must be freed with :func:`flint_free`. + # Warning: string literals appearing in expressions + # are currently not escaped. + + long fexpr_nargs(const fexpr_t expr) + # Returns the number of arguments *n* in the function call + # `f(e_1,\ldots,e_n)` represented + # by *expr*. If *expr* is an atom, returns -1. + + void fexpr_func(fexpr_t res, const fexpr_t expr) + # Assuming that *expr* represents a function call + # `f(e_1,\ldots,e_n)`, sets *res* to the function expression *f*. + + void fexpr_view_func(fexpr_t view, const fexpr_t expr) + # As :func:`fexpr_func`, but sets *view* to a shallow view + # instead of copying the expression. + # The variable *view* must not be initialized before use or + # cleared after use, and *expr* must not be modified or cleared + # as long as *view* is in use. + + void fexpr_arg(fexpr_t res, const fexpr_t expr, long i) + # Assuming that *expr* represents a function call + # `f(e_1,\ldots,e_n)`, sets *res* to the argument `e_{i+1}`. + # Note that indexing starts from 0. + # The index must be in bounds, with `0 \le i < n`. + + void fexpr_view_arg(fexpr_t view, const fexpr_t expr, long i) + # As :func:`fexpr_arg`, but sets *view* to a shallow view + # instead of copying the expression. + # The variable *view* must not be initialized before use or + # cleared after use, and *expr* must not be modified or cleared + # as long as *view* is in use. + + void fexpr_view_next(fexpr_t view) + # Assuming that *view* is a shallow view of a function argument `e_i` + # in a function call `f(e_1,\ldots,e_n)`, sets *view* to + # a view of the next argument `e_{i+1}`. + # This function can be called when *view* refers to the last argument + # `e_n`, provided that *view* is not used afterwards. + # This function can also be called when *view* refers to the function *f*, + # in which case it will make *view* point to `e_1`. + + int fexpr_is_builtin_call(const fexpr_t expr, long id) + # Returns whether *expr* has the form `f(\ldots)` where *f* is + # a builtin function defined by *id* (see :ref:`fexpr-builtin`). + + int fexpr_is_any_builtin_call(const fexpr_t expr) + # Returns whether *expr* has the form `f(\ldots)` where *f* is + # any builtin function (see :ref:`fexpr-builtin`). + + void fexpr_call0(fexpr_t res, const fexpr_t f) + void fexpr_call1(fexpr_t res, const fexpr_t f, const fexpr_t x1) + void fexpr_call2(fexpr_t res, const fexpr_t f, const fexpr_t x1, const fexpr_t x2) + void fexpr_call3(fexpr_t res, const fexpr_t f, const fexpr_t x1, const fexpr_t x2, const fexpr_t x3) + void fexpr_call4(fexpr_t res, const fexpr_t f, const fexpr_t x1, const fexpr_t x2, const fexpr_t x3, const fexpr_t x4) + void fexpr_call_vec(fexpr_t res, const fexpr_t f, fexpr_srcptr args, long len) + # Creates the function call `f(x_1,\ldots,x_n)`. + # The *vec* version takes the arguments as an array *args* + # and *n* is given by *len*. + # Warning: aliasing between inputs and outputs is not implemented. + + void fexpr_call_builtin1(fexpr_t res, long f, const fexpr_t x1) + void fexpr_call_builtin2(fexpr_t res, long f, const fexpr_t x1, const fexpr_t x2) + # Creates the function call `f(x_1,\ldots,x_n)`, where *f* defines + # a builtin symbol. + + int fexpr_contains(const fexpr_t expr, const fexpr_t x) + # Returns whether *expr* contains the expression *x* as a subexpression + # (this includes the case where *expr* and *x* are equal). + + int fexpr_replace(fexpr_t res, const fexpr_t expr, const fexpr_t x, const fexpr_t y) + # Sets *res* to the expression *expr* with all occurrences of the subexpression + # *x* replaced by the expression *y*. Returns a boolean value indicating whether + # any replacements have been performed. + # Aliasing is allowed between *res* and *expr* but not between *res* + # and *x* or *y*. + + int fexpr_replace2(fexpr_t res, const fexpr_t expr, const fexpr_t x1, const fexpr_t y1, const fexpr_t x2, const fexpr_t y2) + # Like :func:`fexpr_replace`, but simultaneously replaces *x1* by *y1* + # and *x2* by *y2*. + + int fexpr_replace_vec(fexpr_t res, const fexpr_t expr, const fexpr_vec_t xs, const fexpr_vec_t ys) + # Sets *res* to the expression *expr* with all occurrences of the + # subexpressions given by entries in *xs* replaced by the corresponding + # expressions in *ys*. It is required that *xs* and *ys* have the same length. + # Returns a boolean value indicating whether any replacements + # have been performed. + # Aliasing is allowed between *res* and *expr* but not between *res* + # and the entries of *xs* or *ys*. + + void fexpr_set_fmpq(fexpr_t res, const fmpq_t x) + # Sets *res* to the rational number *x*. This creates an atomic + # integer if the denominator of *x* is one, and otherwise creates a + # division expression. + + void fexpr_set_arf(fexpr_t res, const arf_t x) + void fexpr_set_d(fexpr_t res, double x) + # Sets *res* to an expression for the value of the + # floating-point number *x*. NaN is represented + # as ``Undefined``. For a regular value, this creates an atomic integer + # or a rational fraction if the exponent is small, and otherwise + # creates an expression of the form ``Mul(m, Pow(2, e))``. + + void fexpr_set_re_im_d(fexpr_t res, double x, double y) + # Sets *res* to an expression for the complex number with real part + # *x* and imaginary part *y*. + + void fexpr_neg(fexpr_t res, const fexpr_t a) + void fexpr_add(fexpr_t res, const fexpr_t a, const fexpr_t b) + void fexpr_sub(fexpr_t res, const fexpr_t a, const fexpr_t b) + void fexpr_mul(fexpr_t res, const fexpr_t a, const fexpr_t b) + void fexpr_div(fexpr_t res, const fexpr_t a, const fexpr_t b) + void fexpr_pow(fexpr_t res, const fexpr_t a, const fexpr_t b) + # Constructs an arithmetic expression with given arguments. + # No simplifications whatsoever are performed. + + int fexpr_is_arithmetic_operation(const fexpr_t expr) + # Returns whether *expr* is of the form `f(e_1,\ldots,e_n)` + # where *f* is one of the arithmetic operators ``Pos``, ``Neg``, + # ``Add``, ``Sub``, ``Mul``, ``Div``. + + void fexpr_arithmetic_nodes(fexpr_vec_t nodes, const fexpr_t expr) + # Sets *nodes* to a vector of subexpressions of *expr* such that *expr* + # is an arithmetic expression with *nodes* as leaves. + # More precisely, *expr* will be constructed out of nested application + # the arithmetic operators + # ``Pos``, ``Neg``, ``Add``, ``Sub``, ``Mul``, ``Div`` with + # integers and expressions in *nodes* as leaves. + # Powers ``Pow`` with an atomic integer exponent are also allowed. + # The nodes are output without repetition but are not automatically sorted in + # a canonical order. + + int fexpr_get_fmpz_mpoly_q(fmpz_mpoly_q_t res, const fexpr_t expr, const fexpr_vec_t vars, const fmpz_mpoly_ctx_t ctx) + # Sets *res* to the expression *expr* as a formal rational + # function of the subexpressions in *vars*. + # The vector *vars* must have the same length as the number of + # variables specified in *ctx*. + # To build *vars* automatically for a given expression, + # :func:`fexpr_arithmetic_nodes` may be used. + # Returns 1 on success and 0 on failure. Failure can occur for the + # following reasons: + # * A subexpression is encountered that cannot be interpreted + # as an arithmetic operation and does not appear (exactly) in *vars*. + # * Overflow (too many terms or too large exponent). + # * Division by zero (a zero denominator is encountered). + # It is important to note that this function views *expr* as + # a formal rational function with *vars* as formal indeterminates. + # It does thus not check for algebraic relations between *vars* + # and can implicitly divide by zero if *vars* are not algebraically + # independent. + + void fexpr_set_fmpz_mpoly(fexpr_t res, const fmpz_mpoly_t poly, const fexpr_vec_t vars, const fmpz_mpoly_ctx_t ctx) + void fexpr_set_fmpz_mpoly_q(fexpr_t res, const fmpz_mpoly_q_t frac, const fexpr_vec_t vars, const fmpz_mpoly_ctx_t ctx) + # Sets *res* to an expression for the multivariate polynomial *poly* + # (or rational function *frac*), + # using the expressions in *vars* as the variables. The length + # of *vars* must agree with the number of variables in *ctx*. + # If *NULL* is passed for *vars*, a default choice of symbols + # is used. + + int fexpr_expanded_normal_form(fexpr_t res, const fexpr_t expr, unsigned long flags) + # Sets *res* to *expr* converted to expanded normal form viewed + # as a formal rational function with its non-arithmetic subexpressions + # as terminal nodes. + # This function first computes nodes with :func:`fexpr_arithmetic_nodes`, + # sorts the nodes, evaluates to a rational function with + # :func:`fexpr_get_fmpz_mpoly_q`, and then converts back to an + # expression with :func:`fexpr_set_fmpz_mpoly_q`. + # Optional *flags* are reserved for future use. + + void fexpr_vec_init(fexpr_vec_t vec, long len) + # Initializes *vec* to a vector of length *len*. All entries + # are set to the atomic integer 0. + + void fexpr_vec_clear(fexpr_vec_t vec) + # Clears the vector *vec*. + + void fexpr_vec_print(const fexpr_vec_t vec) + # Prints *vec* to standard output. + + void fexpr_vec_swap(fexpr_vec_t x, fexpr_vec_t y) + # Swaps *x* and *y* efficiently. + + void fexpr_vec_fit_length(fexpr_vec_t vec, long len) + # Ensures that *vec* has space for *len* entries. + + void fexpr_vec_set(fexpr_vec_t dest, const fexpr_vec_t src) + # Sets *dest* to a copy of *src*. + + void fexpr_vec_append(fexpr_vec_t vec, const fexpr_t expr) + # Appends *expr* to the end of the vector *vec*. + + long fexpr_vec_insert_unique(fexpr_vec_t vec, const fexpr_t expr) + # Inserts *expr* without duplication into vec, returning its + # position. If this expression already exists, *vec* is unchanged. + # If this expression does not exist in *vec*, it is appended. + + void fexpr_vec_set_length(fexpr_vec_t vec, long len) + # Sets the length of *vec* to *len*, truncating or zero-extending as needed. + + void _fexpr_vec_sort_fast(fexpr_ptr vec, long len) + # Sorts the *len* entries in *vec* using + # the comparison function :func:`fexpr_cmp_fast`. diff --git a/src/sage/libs/flint/fexpr_builtin.pxd b/src/sage/libs/flint/fexpr_builtin.pxd new file mode 100644 index 00000000000..7e703720544 --- /dev/null +++ b/src/sage/libs/flint/fexpr_builtin.pxd @@ -0,0 +1,25 @@ +# distutils: libraries = flint +# distutils: depends = flint/fexpr_builtin.h + +################################################################################ +# This file is auto-generated. Do not modify by hand +################################################################################ + +from libc.stdio cimport FILE +from sage.libs.gmp.types cimport * +from sage.libs.mpfr.types cimport * +from sage.libs.flint.types cimport * + +cdef extern from "flint_wrap.h": + + long fexpr_builtin_lookup(const char * s) + # Returns the internal index used to encode the builtin symbol + # with name *s* in expressions. If *s* is not the name of a builtin + # symbol, returns -1. + + const char * fexpr_builtin_name(long n) + # Returns a read-only pointer for a string giving the name of the + # builtin symbol with index *n*. + + long fexpr_builtin_length() + # Returns the number of builtin symbols. diff --git a/src/sage/libs/flint/fmpq_mat.pxd b/src/sage/libs/flint/fmpq_mat.pxd index 56f96157199..ff46f4a31b9 100644 --- a/src/sage/libs/flint/fmpq_mat.pxd +++ b/src/sage/libs/flint/fmpq_mat.pxd @@ -384,3 +384,5 @@ cdef extern from "flint_wrap.h": void fmpq_mat_minpoly(fmpq_poly_t pol, const fmpq_mat_t mat) # Set ``pol`` to the minimal polynomial of the given `n\times n` # matrix. If ``mat`` is not square, an exception is raised. + +from .fmpq_mat_macros cimport * diff --git a/src/sage/libs/flint/fmpq_mat_macros.pxd b/src/sage/libs/flint/fmpq_mat_macros.pxd new file mode 100644 index 00000000000..823941dadf8 --- /dev/null +++ b/src/sage/libs/flint/fmpq_mat_macros.pxd @@ -0,0 +1,14 @@ +# Macros from fmpq_mat.h +# See https://github.com/flintlib/flint/issues/152 + +from .types cimport * + +cdef extern from "flint_wrap.h": + fmpq * fmpq_mat_entry(fmpq_mat_t mat, slong i, slong j) + # Macro giving a pointer to the entry at row *i* and column *j*. + + slong fmpq_mat_nrows(fmpq_mat_t) + # Returns the number of rows of the matrix. + + slong fmpq_mat_ncols(fmpq_mat_t) + # Returns the number of columns of the matrix. diff --git a/src/sage/libs/flint/fmpq_mpoly.pxd b/src/sage/libs/flint/fmpq_mpoly.pxd new file mode 100644 index 00000000000..9a8240d9b1b --- /dev/null +++ b/src/sage/libs/flint/fmpq_mpoly.pxd @@ -0,0 +1,422 @@ +# distutils: libraries = flint +# distutils: depends = flint/fmpq_mpoly.h + +################################################################################ +# This file is auto-generated. Do not modify by hand +################################################################################ + +from libc.stdio cimport FILE +from sage.libs.gmp.types cimport * +from sage.libs.mpfr.types cimport * +from sage.libs.flint.types cimport * + +cdef extern from "flint_wrap.h": + + void fmpq_mpoly_ctx_init(fmpq_mpoly_ctx_t ctx, long nvars, const ordering_t ord) + # Initialise a context object for a polynomial ring with the given number of variables and the given ordering. + # The possibilities for the ordering are ``ORD_LEX``, ``ORD_DEGLEX`` and ``ORD_DEGREVLEX``. + + long fmpq_mpoly_ctx_nvars(const fmpq_mpoly_ctx_t ctx) + # Return the number of variables used to initialize the context. + + ordering_t fmpq_mpoly_ctx_ord(const fmpq_mpoly_ctx_t ctx) + # Return the ordering used to initialize the context. + + void fmpq_mpoly_ctx_clear(fmpq_mpoly_ctx_t ctx) + # Release up any space allocated by *ctx*. + + void fmpq_mpoly_init(fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx) + # Initialise *A* for use with the given and initialised context object. Its value is set to zero. + + void fmpq_mpoly_init2(fmpq_mpoly_t A, long alloc, const fmpq_mpoly_ctx_t ctx) + # Initialise *A* for use with the given and initialised context object. Its value is set to zero. + # It is allocated with space for *alloc* terms and at least ``MPOLY_MIN_BITS`` bits for the exponents. + + void fmpq_mpoly_init3(fmpq_mpoly_t A, long alloc, flint_bitcnt_t bits, const fmpq_mpoly_ctx_t ctx) + # Initialise *A* for use with the given and initialised context object. Its value is set to zero. + # It is allocated with space for *alloc* terms and *bits* bits for the exponents. + + void fmpq_mpoly_fit_length(fmpq_mpoly_t A, long len, const fmpq_mpoly_ctx_t ctx) + # Ensure that *A* has space for at least *len* terms. + + void fmpq_mpoly_fit_bits(fmpq_mpoly_t A, flint_bitcnt_t bits, const fmpq_mpoly_ctx_t ctx) + # Ensure that the exponent fields of *A* have at least *bits* bits. + + void fmpq_mpoly_realloc(fmpq_mpoly_t A, long alloc, const fmpq_mpoly_ctx_t ctx) + # Reallocate *A* to have space for *alloc* terms. + # Assumes the current length of the polynomial is not greater than *alloc*. + + void fmpq_mpoly_clear(fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx) + # Release any space allocated for *A*. + + char * fmpq_mpoly_get_str_pretty(const fmpq_mpoly_t A, const char ** x, const fmpq_mpoly_ctx_t ctx) + # Return a string, which the user is responsible for cleaning up, representing *A*, given an array of variable strings ``x``. + + int fmpq_mpoly_fprint_pretty(FILE * file, const fmpq_mpoly_t A, const char ** x, const fmpq_mpoly_ctx_t ctx) + # Print a string representing *A* to *file*. + + int fmpq_mpoly_print_pretty(const fmpq_mpoly_t A, const char ** x, const fmpq_mpoly_ctx_t ctx) + # Print a string representing *A* to ``stdout``. + + int fmpq_mpoly_set_str_pretty(fmpq_mpoly_t A, const char * str, const char ** x, const fmpq_mpoly_ctx_t ctx) + # Set *A* to the polynomial in the null-terminates string ``str`` given an array ``x`` of variable strings. + # If parsing ``str`` fails, *A* is set to zero, and `-1` is returned. Otherwise, `0` is returned. + # The operations ``+``, ``-``, ``*``, and ``/`` are permitted along with integers and the variables in ``x``. The character ``^`` must be immediately followed by the (integer) exponent. + # If any division is not exact, parsing fails. + + void fmpq_mpoly_gen(fmpq_mpoly_t A, long var, const fmpq_mpoly_ctx_t ctx) + # Set *A* to the variable of index *var*, where ``var = 0`` corresponds to the variable with the most significance with respect to the ordering. + + int fmpq_mpoly_is_gen(const fmpq_mpoly_t A, long var, const fmpq_mpoly_ctx_t ctx) + # If `var \ge 0`, return `1` if *A* is equal to the `var`-th generator, otherwise return `0`. + # If `var < 0`, return `1` if the polynomial is equal to any generator, otherwise return `0`. + + void fmpq_mpoly_set(fmpq_mpoly_t A, const fmpq_mpoly_t B, const fmpq_mpoly_ctx_t ctx) + # Set *A* to *B*. + + int fmpq_mpoly_equal(const fmpq_mpoly_t A, const fmpq_mpoly_t B, const fmpq_mpoly_ctx_t ctx) + # Return `1` if *A* is equal to *B*, else return `0`. + + void fmpq_mpoly_swap(fmpq_mpoly_t A, fmpq_mpoly_t B, const fmpq_mpoly_ctx_t ctx) + # Efficiently swap *A* and *B*. + + int fmpq_mpoly_is_fmpq(const fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx) + # Return `1` if *A* is a constant, else return `0`. + + void fmpq_mpoly_get_fmpq(fmpq_t c, const fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx) + # Assuming that *A* is a constant, set *c* to this constant. + # This function throws if *A* is not a constant. + + void fmpq_mpoly_set_fmpq(fmpq_mpoly_t A, const fmpq_t c, const fmpq_mpoly_ctx_t ctx) + void fmpq_mpoly_set_fmpz(fmpq_mpoly_t A, const fmpz_t c, const fmpq_mpoly_ctx_t ctx) + void fmpq_mpoly_set_ui(fmpq_mpoly_t A, unsigned long c, const fmpq_mpoly_ctx_t ctx) + void fmpq_mpoly_set_si(fmpq_mpoly_t A, long c, const fmpq_mpoly_ctx_t ctx) + # Set *A* to the constant *c*. + + void fmpq_mpoly_zero(fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx) + # Set *A* to the constant `0`. + + void fmpq_mpoly_one(fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx) + # Set *A* to the constant `1`. + + int fmpq_mpoly_equal_fmpq(const fmpq_mpoly_t A, const fmpq_t c, const fmpq_mpoly_ctx_t ctx) + int fmpq_mpoly_equal_fmpz(const fmpq_mpoly_t A, const fmpz_t c, const fmpq_mpoly_ctx_t ctx) + int fmpq_mpoly_equal_ui(const fmpq_mpoly_t A, unsigned long c, const fmpq_mpoly_ctx_t ctx) + int fmpq_mpoly_equal_si(const fmpq_mpoly_t A, long c, const fmpq_mpoly_ctx_t ctx) + # Return `1` if *A* is equal to the constant *c*, else return `0`. + + int fmpq_mpoly_is_zero(const fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx) + # Return `1` if *A* is equal to the constant `0`, else return `0`. + + int fmpq_mpoly_is_one(const fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx) + # Return `1` if *A* is equal to the constant `1`, else return `0`. + + int fmpq_mpoly_degrees_fit_si(const fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx) + # Return `1` if the degrees of *A* with respect to each variable fit into an ``slong``, otherwise return `0`. + + void fmpq_mpoly_degrees_fmpz(fmpz ** degs, const fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx) + void fmpq_mpoly_degrees_si(long * degs, const fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx) + # Set *degs* to the degrees of *A* with respect to each variable. + # If *A* is zero, all degrees are set to `-1`. + + void fmpq_mpoly_degree_fmpz(fmpz_t deg, const fmpq_mpoly_t A, long var, const fmpq_mpoly_ctx_t ctx) + long fmpq_mpoly_degree_si(const fmpq_mpoly_t A, long var, const fmpq_mpoly_ctx_t ctx) + # Either return or set *deg* to the degree of *A* with respect to the variable of index *var*. + # If *A* is zero, the degree is defined to be `-1`. + + int fmpq_mpoly_total_degree_fits_si(const fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx) + # Return `1` if the total degree of *A* fits into an ``slong``, otherwise return `0`. + + void fmpq_mpoly_total_degree_fmpz(fmpz_t tdeg, const fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx) + long fmpq_mpoly_total_degree_si(const fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx) + # Either return or set *tdeg* to the total degree of *A*. + # If *A* is zero, the total degree is defined to be `-1`. + + void fmpq_mpoly_used_vars(int * used, const fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx) + # For each variable index *i*, set ``used[i]`` to nonzero if the variable of index *i* appears in *A* and to zero otherwise. + + void fmpq_mpoly_get_denominator(fmpz_t d, const fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx) + # Set *d* to the denominator of *A*, the smallest positive integer `d` such that `d \times A` has integer coefficients. + + void fmpq_mpoly_get_coeff_fmpq_monomial(fmpq_t c, const fmpq_mpoly_t A, const fmpq_mpoly_t M, const fmpq_mpoly_ctx_t ctx) + # Assuming that *M* is a monomial, set *c* to the coefficient of the corresponding monomial in *A*. + # This function throws if *M* is not a monomial. + + void fmpq_mpoly_set_coeff_fmpq_monomial(fmpq_mpoly_t A, const fmpq_t c, const fmpq_mpoly_t M, const fmpq_mpoly_ctx_t ctx) + # Assuming that *M* is a monomial, set the coefficient of the corresponding monomial in *A* to *c*. + # This function throws if *M* is not a monomial. + + void fmpq_mpoly_get_coeff_fmpq_fmpz(fmpq_t c, const fmpq_mpoly_t A, fmpz * const * exp, const fmpq_mpoly_ctx_t ctx) + void fmpq_mpoly_get_coeff_fmpq_ui(fmpq_t c, const fmpq_mpoly_t A, const unsigned long * exp, const fmpq_mpoly_ctx_t ctx) + # Set *c* to the coefficient of the monomial with exponent *exp*. + + void fmpq_mpoly_set_coeff_fmpq_fmpz(fmpq_mpoly_t A, const fmpq_t c, fmpz * const * exp, const fmpq_mpoly_ctx_t ctx) + void fmpq_mpoly_set_coeff_fmpq_ui(fmpq_mpoly_t A, const fmpq_t c, const unsigned long * exp, const fmpq_mpoly_ctx_t ctx) + # Set the coefficient of the monomial with exponent *exp* to *c*. + + void fmpq_mpoly_get_coeff_vars_ui(fmpq_mpoly_t C, const fmpq_mpoly_t A, const long * vars, const unsigned long * exps, long length, const fmpq_mpoly_ctx_t ctx) + # Set *C* to the coefficient of *A* with respect to the variables in *vars* with powers in the corresponding array *exps*. + # Both *vars* and *exps* point to array of length *length*. It is assumed that `0 < length \le nvars(A)` and that the variables in *vars* are distinct. + + int fmpq_mpoly_cmp(const fmpq_mpoly_t A, const fmpq_mpoly_t B, const fmpq_mpoly_ctx_t ctx) + # Return `1` (resp. `-1`, or `0`) if *A* is after (resp. before, same as) *B* in some arbitrary but fixed total ordering of the polynomials. + # This ordering agrees with the usual ordering of monomials when *A* and *B* are both monomials. + + fmpq * fmpq_mpoly_content_ref(fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx) + # Return a reference to the content of *A*. + + fmpz_mpoly_struct * fmpq_mpoly_zpoly_ref(fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx) + # Return a reference to the integer polynomial of *A*. + + fmpz * fmpq_mpoly_zpoly_term_coeff_ref(fmpq_mpoly_t A, long i, const fmpq_mpoly_ctx_t ctx) + # Return a reference to the coefficient of index *i* of the integer polynomial of *A*. + + int fmpq_mpoly_is_canonical(const fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx) + # Return `1` if *A* is in canonical form. Otherwise, return `0`. + # An ``fmpq_mpoly_t`` is represented as the product of an ``fmpq_t content`` and an ``fmpz_mpoly_t zpoly``. + # The representation is considered canonical when either + # (1) both ``content`` and ``zpoly`` are zero, or + # (2) both ``content`` and ``zpoly`` are nonzero and canonical and ``zpoly`` is reduced. + # A nonzero ``zpoly`` is considered reduced when the coefficients have GCD one and the leading coefficient is positive. + + long fmpq_mpoly_length(const fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx) + # Return the number of terms stored in *A*. + # If the polynomial is in canonical form, this will be the number of nonzero coefficients. + + void fmpq_mpoly_resize(fmpq_mpoly_t A, long new_length, const fmpq_mpoly_ctx_t ctx) + # Set the length of *A* to ``new_length``. + # Terms are either deleted from the end, or new zero terms are appended. + + void fmpq_mpoly_get_term_coeff_fmpq(fmpq_t c, const fmpq_mpoly_t A, long i, const fmpq_mpoly_ctx_t ctx) + # Set *c* to coefficient of index *i* + + void fmpq_mpoly_set_term_coeff_fmpq(fmpq_mpoly_t A, long i, const fmpq_t c, const fmpq_mpoly_ctx_t ctx) + # Set the coefficient of index *i* to *c*. + + int fmpq_mpoly_term_exp_fits_si(const fmpq_mpoly_t A, long i, const fmpq_mpoly_ctx_t ctx) + int fmpq_mpoly_term_exp_fits_ui(const fmpq_mpoly_t A, long i, const fmpq_mpoly_ctx_t ctx) + # Return `1` if all entries of the exponent vector of the term of index *i* fit into an ``slong`` (resp. a ``ulong``). Otherwise, return `0`. + + void fmpq_mpoly_get_term_exp_fmpz(fmpz ** exps, const fmpq_mpoly_t A, long i, const fmpq_mpoly_ctx_t ctx) + void fmpq_mpoly_get_term_exp_ui(unsigned long * exps, const fmpq_mpoly_t A, long i, const fmpq_mpoly_ctx_t ctx) + void fmpq_mpoly_get_term_exp_si(long * exps, const fmpq_mpoly_t A, long i, const fmpq_mpoly_ctx_t ctx) + # Set *exp* to the exponent vector of the term of index *i*. + # The ``_ui`` (resp. ``_si``) version throws if any entry does not fit into a ``ulong`` (resp. ``slong``). + + unsigned long fmpq_mpoly_get_term_var_exp_ui(const fmpq_mpoly_t A, long i, long var, const fmpq_mpoly_ctx_t ctx) + long fmpq_mpoly_get_term_var_exp_si(const fmpq_mpoly_t A, long i, long var, const fmpq_mpoly_ctx_t ctx) + # Return the exponent of the variable *var* of the term of index *i*. + # This function throws if the exponent does not fit into a ``ulong`` (resp. ``slong``). + + void fmpq_mpoly_set_term_exp_fmpz(fmpq_mpoly_t A, long i, fmpz * const * exps, const fmpq_mpoly_ctx_t ctx) + void fmpq_mpoly_set_term_exp_ui(fmpq_mpoly_t A, long i, const unsigned long * exps, const fmpq_mpoly_ctx_t ctx) + # Set the exponent vector of the term of index *i* to *exp*. + + void fmpq_mpoly_get_term(fmpq_mpoly_t M, const fmpq_mpoly_t A, long i, const fmpq_mpoly_ctx_t ctx) + # Set *M* to the term of index *i* in *A*. + + void fmpq_mpoly_get_term_monomial(fmpq_mpoly_t M, const fmpq_mpoly_t A, long i, const fmpq_mpoly_ctx_t ctx) + # Set *M* to the monomial of the term of index *i* in *A*. The coefficient of *M* will be one. + + void fmpq_mpoly_push_term_fmpq_fmpz(fmpq_mpoly_t A, const fmpq_t c, fmpz * const * exp, const fmpq_mpoly_ctx_t ctx) + void fmpq_mpoly_push_term_fmpq_ffmpz(fmpq_mpoly_t A, const fmpq_t c, const fmpz * exp, const fmpq_mpoly_ctx_t ctx) + void fmpq_mpoly_push_term_fmpz_fmpz(fmpq_mpoly_t A, const fmpz_t c, fmpz * const * exp, const fmpq_mpoly_ctx_t ctx) + void fmpq_mpoly_push_term_fmpz_ffmpz(fmpq_mpoly_t A, const fmpz_t c, const fmpz * exp, const fmpq_mpoly_ctx_t ctx) + void fmpq_mpoly_push_term_ui_fmpz(fmpq_mpoly_t A, unsigned long c, fmpz * const * exp, const fmpq_mpoly_ctx_t ctx) + void fmpq_mpoly_push_term_ui_ffmpz(fmpq_mpoly_t A, unsigned long c, const fmpz * exp, const fmpq_mpoly_ctx_t ctx) + void fmpq_mpoly_push_term_si_fmpz(fmpq_mpoly_t A, long c, fmpz * const * exp, const fmpq_mpoly_ctx_t ctx) + void fmpq_mpoly_push_term_si_ffmpz(fmpq_mpoly_t A, long c, const fmpz * exp, const fmpq_mpoly_ctx_t ctx) + void fmpq_mpoly_push_term_fmpq_ui(fmpq_mpoly_t A, const fmpq_t c, const unsigned long * exp, const fmpq_mpoly_ctx_t ctx) + void fmpq_mpoly_push_term_fmpz_ui(fmpq_mpoly_t A, const fmpz_t c, const unsigned long * exp, const fmpq_mpoly_ctx_t ctx) + void fmpq_mpoly_push_term_ui_ui(fmpq_mpoly_t A, unsigned long c, const unsigned long * exp, const fmpq_mpoly_ctx_t ctx) + void fmpq_mpoly_push_term_si_ui(fmpq_mpoly_t A, long c, const unsigned long * exp, const fmpq_mpoly_ctx_t ctx) + # Append a term to *A* with coefficient *c* and exponent vector *exp*. + # This function should run in constant average time if the terms pushed have bounded denominator. + + void fmpq_mpoly_reduce(fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx) + # Factor out necessary content from ``A->zpoly`` so that it is reduced. + # If the terms of *A* were nonzero and sorted with distinct exponents to begin with, the result will be in canonical form. + + void fmpq_mpoly_sort_terms(fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx) + # Sort the internal ``A->zpoly`` into the canonical ordering dictated by the ordering in *ctx*. + # This function does not combine like terms, nor does it delete terms with coefficient zero, nor does it reduce. + + void fmpq_mpoly_combine_like_terms(fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx) + # Combine adjacent like terms in the internal ``A->zpoly`` and then factor out content via a call to :func:`fmpq_mpoly_reduce`. + # If the terms of *A* were sorted to begin with, the result will be in canonical form. + + void fmpq_mpoly_reverse(fmpq_mpoly_t A, const fmpq_mpoly_t B, const fmpq_mpoly_ctx_t ctx) + # Set *A* to the reversal of *B*. + + void fmpq_mpoly_randtest_bound(fmpq_mpoly_t A, flint_rand_t state, long length, mp_limb_t coeff_bits, unsigned long exp_bound, const fmpq_mpoly_ctx_t ctx) + # Generate a random polynomial with length up to *length* and exponents in the range ``[0, exp_bound - 1]``. + # The exponents of each variable are generated by calls to ``n_randint(state, exp_bound)``. + + void fmpq_mpoly_randtest_bounds(fmpq_mpoly_t A, flint_rand_t state, long length, mp_limb_t coeff_bits, unsigned long * exp_bounds, const fmpq_mpoly_ctx_t ctx) + # Generate a random polynomial with length up to *length* and exponents in the range ``[0, exp_bounds[i] - 1]``. + # The exponents of the variable of index *i* are generated by calls to ``n_randint(state, exp_bounds[i])``. + + void fmpq_mpoly_randtest_bits(fmpq_mpoly_t A, flint_rand_t state, long length, mp_limb_t coeff_bits, mp_limb_t exp_bits, const fmpq_mpoly_ctx_t ctx) + # Generate a random polynomial with length up to *length* and exponents whose packed form does not exceed the given bit count. + # The parameter ``coeff_bits`` to the three functions ``fmpq_mpoly_randtest_{bound|bounds|bits}`` is merely a suggestion for the approximate bit count of the resulting coefficients. + + 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, unsigned long c, const fmpq_mpoly_ctx_t ctx) + void fmpq_mpoly_add_si(fmpq_mpoly_t A, const fmpq_mpoly_t B, long c, const fmpq_mpoly_ctx_t ctx) + # Set *A* to `B + c`. + + void fmpq_mpoly_sub_fmpq(fmpq_mpoly_t A, const fmpq_mpoly_t B, const fmpq_t c, const fmpq_mpoly_ctx_t ctx) + void fmpq_mpoly_sub_fmpz(fmpq_mpoly_t A, const fmpq_mpoly_t B, const fmpz_t c, const fmpq_mpoly_ctx_t ctx) + void fmpq_mpoly_sub_ui(fmpq_mpoly_t A, const fmpq_mpoly_t B, unsigned long c, const fmpq_mpoly_ctx_t ctx) + void fmpq_mpoly_sub_si(fmpq_mpoly_t A, const fmpq_mpoly_t B, long c, const fmpq_mpoly_ctx_t ctx) + # Set *A* to `B - c`. + + void fmpq_mpoly_add(fmpq_mpoly_t A, const fmpq_mpoly_t B, const fmpq_mpoly_t C, const fmpq_mpoly_ctx_t ctx) + # Set *A* to `B + C`. + + void fmpq_mpoly_sub(fmpq_mpoly_t A, const fmpq_mpoly_t B, const fmpq_mpoly_t C, const fmpq_mpoly_ctx_t ctx) + # Set *A* to `B - C`. + + void fmpq_mpoly_neg(fmpq_mpoly_t A, const fmpq_mpoly_t B, const fmpq_mpoly_ctx_t ctx) + # Set *A* to `-B`. + + void fmpq_mpoly_scalar_mul_fmpq(fmpq_mpoly_t A, const fmpq_mpoly_t B, const fmpq_t c, const fmpq_mpoly_ctx_t ctx) + void fmpq_mpoly_scalar_mul_fmpz(fmpq_mpoly_t A, const fmpq_mpoly_t B, const fmpz_t c, const fmpq_mpoly_ctx_t ctx) + void fmpq_mpoly_scalar_mul_ui(fmpq_mpoly_t A, const fmpq_mpoly_t B, unsigned long c, const fmpq_mpoly_ctx_t ctx) + void fmpq_mpoly_scalar_mul_si(fmpq_mpoly_t A, const fmpq_mpoly_t B, long c, const fmpq_mpoly_ctx_t ctx) + # Set *A* to `B \times c`. + + void fmpq_mpoly_scalar_div_fmpq(fmpq_mpoly_t A, const fmpq_mpoly_t B, const fmpq_t c, const fmpq_mpoly_ctx_t ctx) + void fmpq_mpoly_scalar_div_fmpz(fmpq_mpoly_t A, const fmpq_mpoly_t B, const fmpz_t c, const fmpq_mpoly_ctx_t ctx) + void fmpq_mpoly_scalar_div_ui(fmpq_mpoly_t A, const fmpq_mpoly_t B, unsigned long c, const fmpq_mpoly_ctx_t ctx) + void fmpq_mpoly_scalar_div_si(fmpq_mpoly_t A, const fmpq_mpoly_t B, long c, const fmpq_mpoly_ctx_t ctx) + # Set *A* to `B/c`. + + void fmpq_mpoly_make_monic(fmpq_mpoly_t A, const fmpq_mpoly_t B, const fmpq_mpoly_ctx_t ctx) + # Set *A* to *B* divided by the leading coefficient of *B*. + # This throws if *B* is zero. + # All of these functions run quickly if *A* and *B* are aliased. + + void fmpq_mpoly_derivative(fmpq_mpoly_t A, const fmpq_mpoly_t B, long var, const fmpq_mpoly_ctx_t ctx) + # Set *A* to the derivative of *B* with respect to the variable of index *var*. + + void fmpq_mpoly_integral(fmpq_mpoly_t A, const fmpq_mpoly_t B, long var, const fmpq_mpoly_ctx_t ctx) + # Set *A* to the integral with the fewest number of terms of *B* with respect to the variable of index *var*. + + int fmpq_mpoly_evaluate_all_fmpq(fmpq_t ev, const fmpq_mpoly_t A, fmpq * const * vals, const fmpq_mpoly_ctx_t ctx) + # Set ``ev`` to the evaluation of *A* where the variables are replaced by the corresponding elements of the array ``vals``. + # Return `1` for success and `0` for failure. + + int fmpq_mpoly_evaluate_one_fmpq(fmpq_mpoly_t A, const fmpq_mpoly_t B, long var, const fmpq_t val, const fmpq_mpoly_ctx_t ctx) + # Set *A* to the evaluation of *B* where the variable of index *var* is replaced by ``val``. + # Return `1` for success and `0` for failure. + + int fmpq_mpoly_compose_fmpq_poly(fmpq_poly_t A, const fmpq_mpoly_t B, fmpq_poly_struct * const * C, const fmpq_mpoly_ctx_t ctxB) + # Set *A* to the evaluation of *B* where the variables are replaced by the corresponding elements of the array *C*. + # The context object of *B* is *ctxB*. + # Return `1` for success and `0` for failure. + + int fmpq_mpoly_compose_fmpq_mpoly(fmpq_mpoly_t A, const fmpq_mpoly_t B, fmpq_mpoly_struct * const * C, const fmpq_mpoly_ctx_t ctxB, const fmpq_mpoly_ctx_t ctxAC) + # Set *A* to the evaluation of *B* where the variables are replaced by the corresponding elements of the array *C*. + # Both *A* and the elements of *C* have context object *ctxAC*, while *B* has context object *ctxB*. + # Neither *A* nor *B* is allowed to alias any other polynomial. + # Return `1` for success and `0` for failure. + + void fmpq_mpoly_compose_fmpq_mpoly_gen(fmpq_mpoly_t A, const fmpq_mpoly_t B, const long * c, const fmpq_mpoly_ctx_t ctxB, const fmpq_mpoly_ctx_t ctxAC) + # Set *A* to the evaluation of *B* where the variable of index *i* in *ctxB* is replaced by the variable of index ``c[i]`` in *ctxAC*. + # The length of the array *C* is the number of variables in *ctxB*. + # If any ``c[i]`` is negative, the corresponding variable of *B* is replaced by zero. Otherwise, it is expected that ``c[i]`` is less than the number of variables in *ctxAC*. + + void fmpq_mpoly_mul(fmpq_mpoly_t A, const fmpq_mpoly_t B, const fmpq_mpoly_t C, const fmpq_mpoly_ctx_t ctx) + # Set *A* to `B \times C`. + + int fmpq_mpoly_pow_fmpz(fmpq_mpoly_t A, const fmpq_mpoly_t B, const fmpz_t k, const fmpq_mpoly_ctx_t ctx) + # Set *A* to *B* raised to the *k*-th power. + # Return `1` for success and `0` for failure. + + int fmpq_mpoly_pow_ui(fmpq_mpoly_t A, const fmpq_mpoly_t B, unsigned long k, const fmpq_mpoly_ctx_t ctx) + # Set *A* to *B* raised to the *k*-th power. + # Return `1` for success and `0` for failure. + + int fmpq_mpoly_divides(fmpq_mpoly_t Q, const fmpq_mpoly_t A, const fmpq_mpoly_t B, const fmpq_mpoly_ctx_t ctx) + # If *A* is divisible by *B*, set *Q* to the exact quotient and return `1`. Otherwise, set *Q* to zero and return `0`. + # Note that the function :func:`fmpq_mpoly_div` may be faster if the quotient is known to be exact. + + void fmpq_mpoly_div(fmpq_mpoly_t Q, const fmpq_mpoly_t A, const fmpq_mpoly_t B, const fmpq_mpoly_ctx_t ctx) + # Set *Q* to the quotient of *A* by *B*, discarding the remainder. + + void fmpq_mpoly_divrem(fmpq_mpoly_t Q, fmpq_mpoly_t R, const fmpq_mpoly_t A, const fmpq_mpoly_t B, const fmpq_mpoly_ctx_t ctx) + # Set *Q* and *R* to the quotient and remainder of *A* divided by *B*. + + void fmpq_mpoly_divrem_ideal(fmpq_mpoly_struct ** Q, fmpq_mpoly_t R, const fmpq_mpoly_t A, fmpq_mpoly_struct * const * B, long len, const fmpq_mpoly_ctx_t ctx) + # This function is as per :func:`fmpq_mpoly_divrem` except that it takes an array of divisor polynomials *B* and it returns an array of quotient polynomials *Q*. + # The number of divisor (and hence quotient) polynomials is given by *len*. + + void fmpq_mpoly_content(fmpq_t g, const fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx) + # Set *g* to the (nonnegative) gcd of the coefficients of *A*. + + void fmpq_mpoly_term_content(fmpq_mpoly_t M, const fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx) + # Set *M* to the GCD of the terms of *A*. + # If *A* is zero, *M* will be zero. Otherwise, *M* will be a monomial with coefficient one. + + int fmpq_mpoly_content_vars(fmpq_mpoly_t g, const fmpq_mpoly_t A, long * vars, long vars_length, const fmpq_mpoly_ctx_t ctx) + # Set *g* to the GCD of the coefficients of *A* when viewed as a polynomial in the variables *vars*. + # Return `1` for success and `0` for failure. Upon success, *g* will be independent of the variables *vars*. + + int fmpq_mpoly_gcd(fmpq_mpoly_t G, const fmpq_mpoly_t A, const fmpq_mpoly_t B, const fmpq_mpoly_ctx_t ctx) + # Try to set *G* to the monic GCD of *A* and *B*. The GCD of zero and zero is defined to be zero. + # If the return is `1` the function was successful. Otherwise the return is `0` and *G* is left untouched. + + int fmpq_mpoly_gcd_cofactors(fmpq_mpoly_t G, fmpq_mpoly_t Abar, fmpq_mpoly_t Bbar, const fmpq_mpoly_t A, const fmpq_mpoly_t B, const fmpq_mpoly_ctx_t ctx) + # Do the operation of :func:`fmpq_mpoly_gcd` and also compute `Abar = A/G` and `Bbar = B/G` if successful. + + int fmpq_mpoly_gcd_brown(fmpq_mpoly_t G, const fmpq_mpoly_t A, const fmpq_mpoly_t B, const fmpq_mpoly_ctx_t ctx) + int fmpq_mpoly_gcd_hensel(fmpq_mpoly_t G, const fmpq_mpoly_t A, const fmpq_mpoly_t B, const fmpq_mpoly_ctx_t ctx) + int fmpq_mpoly_gcd_subresultant(fmpq_mpoly_t G, const fmpq_mpoly_t A, const fmpq_mpoly_t B, const fmpq_mpoly_ctx_t ctx) + int fmpq_mpoly_gcd_zippel(fmpq_mpoly_t G, const fmpq_mpoly_t A, const fmpq_mpoly_t B, const fmpq_mpoly_ctx_t ctx) + int fmpq_mpoly_gcd_zippel2(fmpq_mpoly_t G, const fmpq_mpoly_t A, const fmpq_mpoly_t B, const fmpq_mpoly_ctx_t ctx) + # Try to set *G* to the GCD of *A* and *B* using various algorithms. + + int fmpq_mpoly_resultant(fmpq_mpoly_t R, const fmpq_mpoly_t A, const fmpq_mpoly_t B, long var, const fmpq_mpoly_ctx_t ctx) + # Try to set *R* to the resultant of *A* and *B* with respect to the variable of index *var*. + + int fmpq_mpoly_discriminant(fmpq_mpoly_t D, const fmpq_mpoly_t A, long var, const fmpq_mpoly_ctx_t ctx) + # Try to set *D* to the discriminant of *A* with respect to the variable of index *var*. + + int fmpq_mpoly_sqrt(fmpq_mpoly_t Q, const fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx) + # If *A* is a perfect square return `1` and set *Q* to the square root + # with positive leading coefficient. Otherwise return `0` and set *Q* to zero. + + int fmpq_mpoly_is_square(const fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx) + # Return `1` if *A* is a perfect square, otherwise return `0`. + + void fmpq_mpoly_univar_init(fmpq_mpoly_univar_t A, const fmpq_mpoly_ctx_t ctx) + # Initialize *A*. + + void fmpq_mpoly_univar_clear(fmpq_mpoly_univar_t A, const fmpq_mpoly_ctx_t ctx) + # Clear *A*. + + void fmpq_mpoly_univar_swap(fmpq_mpoly_univar_t A, fmpq_mpoly_univar_t B, const fmpq_mpoly_ctx_t ctx) + # Swap *A* and *B*. + + void fmpq_mpoly_to_univar(fmpq_mpoly_univar_t A, const fmpq_mpoly_t B, long var, const fmpq_mpoly_ctx_t ctx) + # Set *A* to a univariate form of *B* by pulling out the variable of index *var*. + # The coefficients of *A* will still belong to the content *ctx* but will not depend on the variable of index *var*. + + void fmpq_mpoly_from_univar(fmpq_mpoly_t A, const fmpq_mpoly_univar_t B, long var, const fmpq_mpoly_ctx_t ctx) + # Set *A* to the normal form of *B* by putting in the variable of index *var*. + # This function is undefined if the coefficients of *B* depend on the variable of index *var*. + + int fmpq_mpoly_univar_degree_fits_si(const fmpq_mpoly_univar_t A, const fmpq_mpoly_ctx_t ctx) + # Return `1` if the degree of *A* with respect to the main variable fits an ``slong``. Otherwise, return `0`. + + long fmpq_mpoly_univar_length(const fmpq_mpoly_univar_t A, const fmpq_mpoly_ctx_t ctx) + # Return the number of terms in *A* with respect to the main variable. + + long fmpq_mpoly_univar_get_term_exp_si(fmpq_mpoly_univar_t A, long i, const fmpq_mpoly_ctx_t ctx) + # Return the exponent of the term of index *i* of *A*. + + void fmpq_mpoly_univar_get_term_coeff(fmpq_mpoly_t c, const fmpq_mpoly_univar_t A, long i, const fmpq_mpoly_ctx_t ctx) + void fmpq_mpoly_univar_swap_term_coeff(fmpq_mpoly_t c, fmpq_mpoly_univar_t A, long i, const fmpq_mpoly_ctx_t ctx) + # Set (resp. swap) *c* to (resp. with) the coefficient of the term of index *i* of *A*. diff --git a/src/sage/libs/flint/fmpq_mpoly_factor.pxd b/src/sage/libs/flint/fmpq_mpoly_factor.pxd new file mode 100644 index 00000000000..c64b39474e0 --- /dev/null +++ b/src/sage/libs/flint/fmpq_mpoly_factor.pxd @@ -0,0 +1,52 @@ +# distutils: libraries = flint +# distutils: depends = flint/fmpq_mpoly_factor.h + +################################################################################ +# This file is auto-generated. Do not modify by hand +################################################################################ + +from libc.stdio cimport FILE +from sage.libs.gmp.types cimport * +from sage.libs.mpfr.types cimport * +from sage.libs.flint.types cimport * + +cdef extern from "flint_wrap.h": + + void fmpq_mpoly_factor_init(fmpq_mpoly_factor_t f, const fmpq_mpoly_ctx_t ctx) + # Initialise *f*. + + void fmpq_mpoly_factor_clear(fmpq_mpoly_factor_t f, const fmpq_mpoly_ctx_t ctx) + # Clear *f*. + + void fmpq_mpoly_factor_swap(fmpq_mpoly_factor_t f, fmpq_mpoly_factor_t g, const fmpq_mpoly_ctx_t ctx) + # Efficiently swap *f* and *g*. + + long fmpq_mpoly_factor_length(const fmpq_mpoly_factor_t f, const fmpq_mpoly_ctx_t ctx) + # Return the length of the product in *f*. + + void fmpq_mpoly_factor_get_constant_fmpq(fmpq_t c, const fmpq_mpoly_factor_t f, const fmpq_mpoly_ctx_t ctx) + # Set *c* to the constant of *f*. + + void fmpq_mpoly_factor_get_base(fmpq_mpoly_t B, const fmpq_mpoly_factor_t f, long i, const fmpq_mpoly_ctx_t ctx) + void fmpq_mpoly_factor_swap_base(fmpq_mpoly_t B, fmpq_mpoly_factor_t f, long i, const fmpq_mpoly_ctx_t ctx) + # Set (resp. swap) *B* to (resp. with) the base of the term of index *i* in *A*. + + long fmpq_mpoly_factor_get_exp_si(fmpq_mpoly_factor_t f, long i, const fmpq_mpoly_ctx_t ctx) + # Return the exponent of the term of index *i* in *A*. It is assumed to fit an ``slong``. + + void fmpq_mpoly_factor_sort(fmpq_mpoly_factor_t f, const fmpq_mpoly_ctx_t ctx) + # Sort the product of *f* first by exponent and then by base. + + int fmpq_mpoly_factor_make_monic(fmpq_mpoly_factor_t f, const fmpq_mpoly_ctx_t ctx) + int fmpq_mpoly_factor_make_integral(fmpq_mpoly_factor_t f, const fmpq_mpoly_ctx_t ctx) + # Make the bases in *f* monic (resp. integral and primitive with positive leading coefficient). + # Return `1` for success, `0` for failure. + + int fmpq_mpoly_factor_squarefree(fmpq_mpoly_factor_t f, const fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx) + # Set *f* to a factorization of *A* where the bases are primitive and + # pairwise relatively prime. If the product of all irreducible factors with + # a given exponent is desired, it is recommended to call :func:`fmpq_mpoly_factor_sort` + # and then multiply the bases with the desired exponent. + + int fmpq_mpoly_factor(fmpq_mpoly_factor_t f, const fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx) + # Set *f* to a factorization of *A* where the bases are irreducible. diff --git a/src/sage/libs/flint/fmpq_poly.pxd b/src/sage/libs/flint/fmpq_poly.pxd index afa16e5bbdd..7c18ee2e230 100644 --- a/src/sage/libs/flint/fmpq_poly.pxd +++ b/src/sage/libs/flint/fmpq_poly.pxd @@ -1,190 +1,1246 @@ # distutils: libraries = flint # distutils: depends = flint/fmpq_poly.h -#***************************************************************************** -# Copyright (C) 2010 Sebastian Pancratz -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 2 of the License, or -# (at your option) any later version. -# http://www.gnu.org/licenses/ -#***************************************************************************** - -from sage.libs.gmp.types cimport mpz_t, mpq_t +################################################################################ +# This file is auto-generated. Do not modify by hand +################################################################################ + +from libc.stdio cimport FILE +from sage.libs.gmp.types cimport * +from sage.libs.mpfr.types cimport * from sage.libs.flint.types cimport * -from sage.libs.flint.fmpz_vec cimport _fmpz_vec_max_limbs -# flint/fmpq_poly.h cdef extern from "flint_wrap.h": - # Memory management - void fmpq_poly_init(fmpq_poly_t) - void fmpq_poly_init2(fmpq_poly_t, slong) - void fmpq_poly_realloc(fmpq_poly_t, slong) - - void fmpq_poly_fit_length(fmpq_poly_t, slong) - - void fmpq_poly_clear(fmpq_poly_t) - - void fmpq_poly_canonicalise(fmpq_poly_t) - int fmpq_poly_is_canonical(const fmpq_poly_t) - - void _fmpq_poly_set_length(fmpq_poly_t, slong) - void _fmpq_poly_normalise(fmpq_poly_t) - - # Polynomial parameters - slong fmpq_poly_degree(const fmpq_poly_t) - ulong fmpq_poly_length(const fmpq_poly_t) - - # Accessing the numerator and denominator - fmpz *fmpq_poly_numref(fmpq_poly_t) - fmpz *fmpq_poly_denref(fmpq_poly_t) - - void fmpq_poly_get_numerator(fmpz_poly_t, const fmpq_poly_t) - - # Assignment, swap, negation - void fmpq_poly_set(fmpq_poly_t, const fmpq_poly_t) - void fmpq_poly_set_si(fmpq_poly_t, slong) - void fmpq_poly_set_ui(fmpq_poly_t, ulong) - void fmpq_poly_set_fmpz(fmpq_poly_t, const fmpz_t) - void fmpq_poly_set_fmpq(fmpq_poly_t, const fmpq_t) - void fmpq_poly_set_fmpz_poly(fmpq_poly_t, const fmpz_poly_t) - - void fmpq_poly_set_str(fmpq_poly_t, const char *) - char *fmpq_poly_get_str(const fmpq_poly_t) - char *fmpq_poly_get_str_pretty(const fmpq_poly_t, const char *) - - void fmpq_poly_zero(fmpq_poly_t) - void fmpq_poly_one(fmpq_poly_t) - - void fmpq_poly_neg(fmpq_poly_t, const fmpq_poly_t) - void fmpq_poly_inv(fmpq_poly_t, const fmpq_poly_t) - - void fmpq_poly_swap(fmpq_poly_t, fmpq_poly_t) - void fmpq_poly_truncate(fmpq_poly_t, slong) - void fmpq_poly_get_slice(fmpq_poly_t, const fmpq_poly_t, slong, slong) - void fmpq_poly_reverse(fmpq_poly_t, const fmpq_poly_t, slong) - - void fmpq_poly_get_coeff_fmpq(fmpq_t, const fmpq_poly_t, slong) - void fmpq_poly_get_coeff_si(slong, const fmpq_poly_t, slong) - void fmpq_poly_get_coeff_ui(ulong, const fmpq_poly_t, slong) - - void fmpq_poly_set_coeff_si(fmpq_poly_t, slong, slong) - void fmpq_poly_set_coeff_ui(fmpq_poly_t, slong, ulong) - void fmpq_poly_set_coeff_fmpz(fmpq_poly_t, slong, const fmpz_t) - void fmpq_poly_set_coeff_fmpq(fmpq_poly_t, slong, const fmpq_t) - - # Comparison - int fmpq_poly_equal(const fmpq_poly_t, const fmpq_poly_t) - int fmpq_poly_cmp(const fmpq_poly_t, const fmpq_poly_t) - int fmpq_poly_is_one(const fmpq_poly_t) - int fmpq_poly_is_zero(const fmpq_poly_t) - - # Addition and subtraction - void fmpq_poly_add(fmpq_poly_t, const fmpq_poly_t, const fmpq_poly_t) - void fmpq_poly_sub(fmpq_poly_t, const fmpq_poly_t, const fmpq_poly_t) - - void fmpq_poly_add_can( - fmpq_poly_t, const fmpq_poly_t, const fmpq_poly_t, int) - void fmpq_poly_sub_can( - fmpq_poly_t, const fmpq_poly_t, const fmpq_poly_t, int) - - # Scalar multiplication and division - void fmpq_poly_scalar_mul_si(fmpq_poly_t, const fmpq_poly_t, slong) - void fmpq_poly_scalar_mul_ui(fmpq_poly_t, const fmpq_poly_t, ulong) - void fmpq_poly_scalar_mul_fmpz( - fmpq_poly_t, const fmpq_poly_t, const fmpz_t) - void fmpq_poly_scalar_mul_fmpq( - fmpq_poly_t, const fmpq_poly_t, const fmpq_t) - - void fmpq_poly_scalar_div_si(fmpq_poly_t, const fmpq_poly_t, slong) - void fmpq_poly_scalar_div_ui(fmpq_poly_t, const fmpq_poly_t, ulong) - void fmpq_poly_scalar_div_fmpz( - fmpq_poly_t, const fmpq_poly_t, const fmpz_t) - void fmpq_poly_scalar_div_fmpq( - fmpq_poly_t, const fmpq_poly_t, const fmpq_t) - - # Multiplication - void fmpq_poly_mul(fmpq_poly_t, const fmpq_poly_t, const fmpq_poly_t) - void fmpq_poly_mullow(fmpq_poly_t, const fmpq_poly_t, const fmpq_poly_t, slong) - - void fmpq_poly_addmul(fmpq_poly_t, const fmpq_poly_t, const fmpq_poly_t) - void fmpq_poly_submul(fmpq_poly_t, const fmpq_poly_t, const fmpq_poly_t) - - # Powering - void fmpq_poly_pow(fmpq_poly_t, const fmpq_poly_t, ulong) - - # Shifting - void fmpq_poly_shift_left(fmpq_poly_t, const fmpq_poly_t, slong) - void fmpq_poly_shift_right(fmpq_poly_t, const fmpq_poly_t, slong) - - # Euclidean division - void fmpq_poly_divrem( - fmpq_poly_t, fmpq_poly_t, const fmpq_poly_t, const fmpq_poly_t) - void fmpq_poly_div(fmpq_poly_t, const fmpq_poly_t, const fmpq_poly_t) - void fmpq_poly_rem(fmpq_poly_t, const fmpq_poly_t, const fmpq_poly_t) - - # Greatest common divisor - void fmpq_poly_gcd(fmpq_poly_t, const fmpq_poly_t, const fmpq_poly_t) - void fmpq_poly_xgcd( - fmpq_poly_t, fmpq_poly_t, fmpq_poly_t, - const fmpq_poly_t, const fmpq_poly_t) - - void fmpq_poly_lcm(fmpq_poly_t, const fmpq_poly_t, const fmpq_poly_t) - - void fmpq_poly_resultant(fmpq_t, const fmpq_poly_t, const fmpq_poly_t) - - # Power series division - void fmpq_poly_inv_series_newton(fmpq_poly_t, const fmpq_poly_t, slong) - void fmpq_poly_inv_series(fmpq_poly_t, const fmpq_poly_t, slong) - void fmpq_poly_div_series( - fmpq_poly_t, const fmpq_poly_t, const fmpq_poly_t, slong) - - # Derivative and integral - void fmpq_poly_derivative(fmpq_poly_t, const fmpq_poly_t) - void fmpq_poly_integral(fmpq_poly_t, const fmpq_poly_t) - - # Evaluation - void fmpq_poly_evaluate_fmpz(fmpq_t, const fmpq_poly_t, const fmpz_t) - void fmpq_poly_evaluate_fmpq(fmpq_t, const fmpq_poly_t, const fmpq_t) - - # Composition - void fmpq_poly_compose(fmpq_poly_t, const fmpq_poly_t, const fmpq_poly_t) - void fmpq_poly_rescale(fmpq_poly_t, const fmpq_poly_t, const fmpq_t) - - # Revert - void fmpq_poly_revert_series(fmpq_poly_t, fmpq_poly_t, unsigned long) - - # Gaussian content - void fmpq_poly_content(fmpq_t, const fmpq_poly_t) - void fmpq_poly_primitive_part(fmpq_poly_t, const fmpq_poly_t) - - int fmpq_poly_is_monic(const fmpq_poly_t) - void fmpq_poly_make_monic(fmpq_poly_t, const fmpq_poly_t) - - # Transcendental functions - void fmpq_poly_log_series(fmpq_poly_t, const fmpq_poly_t, slong) - void fmpq_poly_exp_series(fmpq_poly_t, const fmpq_poly_t, slong) - void fmpq_poly_atan_series(fmpq_poly_t, const fmpq_poly_t, slong) - void fmpq_poly_atanh_series(fmpq_poly_t, const fmpq_poly_t, slong) - void fmpq_poly_asin_series(fmpq_poly_t, const fmpq_poly_t, slong) - void fmpq_poly_asinh_series(fmpq_poly_t, const fmpq_poly_t, slong) - void fmpq_poly_tan_series(fmpq_poly_t, const fmpq_poly_t, slong) - void fmpq_poly_sin_series(fmpq_poly_t, const fmpq_poly_t, slong) - void fmpq_poly_cos_series(fmpq_poly_t, const fmpq_poly_t, slong) - void fmpq_poly_sinh_series(fmpq_poly_t, const fmpq_poly_t, slong) - void fmpq_poly_cosh_series(fmpq_poly_t, const fmpq_poly_t, slong) - void fmpq_poly_tanh_series(fmpq_poly_t, const fmpq_poly_t, slong) - -# since the fmpq_poly header seems to be lacking this inline function -cdef inline sage_fmpq_poly_max_limbs(const fmpq_poly_t poly) noexcept: - return _fmpz_vec_max_limbs(fmpq_poly_numref(poly), fmpq_poly_length(poly)) - -# functions removed from flint but still needed in sage -cdef void fmpq_poly_scalar_mul_mpz(fmpq_poly_t, const fmpq_poly_t, const mpz_t) -cdef void fmpq_poly_scalar_mul_mpq(fmpq_poly_t, const fmpq_poly_t, const mpq_t) -cdef void fmpq_poly_set_coeff_mpq(fmpq_poly_t, slong, const mpq_t) -cdef void fmpq_poly_get_coeff_mpq(mpq_t, const fmpq_poly_t, slong) -cdef void fmpq_poly_set_mpz(fmpq_poly_t, const mpz_t) -cdef void fmpq_poly_set_mpq(fmpq_poly_t, const mpq_t) + void fmpq_poly_init(fmpq_poly_t poly) + # Initialises the polynomial for use. The length is set to zero. + + void fmpq_poly_init2(fmpq_poly_t poly, long alloc) + # Initialises the polynomial with space for at least ``alloc`` + # coefficients and sets the length to zero. The ``alloc`` coefficients + # are all set to zero. + + void fmpq_poly_realloc(fmpq_poly_t poly, long alloc) + # Reallocates the given polynomial to have space for ``alloc`` + # coefficients. If ``alloc`` is zero then the polynomial is cleared + # and then reinitialised. If the current length is greater than + # ``alloc`` then ``poly`` is first truncated to length + # ``alloc``. Note that this might leave the rational polynomial in + # non-canonical form. + + void fmpq_poly_fit_length(fmpq_poly_t poly, long len) + # If ``len`` is greater than the number of coefficients currently + # allocated, then the polynomial is reallocated to have space for at + # least ``len`` coefficients. No data is lost when calling this + # function. The function efficiently deals with the case where + # :func:`fit_length` is called many times in small increments by at + # least doubling the number of allocated coefficients when ``len`` + # is larger than the number of coefficients currently allocated. + + void _fmpq_poly_set_length(fmpq_poly_t poly, long len) + # Sets the length of the numerator polynomial to ``len``, demoting + # coefficients beyond the new length. Note that this method does + # not guarantee that the rational polynomial is in canonical form. + + void fmpq_poly_clear(fmpq_poly_t poly) + # Clears the given polynomial, releasing any memory used. The polynomial + # must be reinitialised in order to be used again. + + void _fmpq_poly_normalise(fmpq_poly_t poly) + # Sets the length of ``poly`` so that the top coefficient is + # non-zero. If all coefficients are zero, the length is set to zero. + # Note that this function does not guarantee the coprimality of the + # numerator polynomial and the integer denominator. + + void _fmpq_poly_canonicalise(fmpz * poly, fmpz_t den, long len) + # Puts ``(poly, den)`` of length ``len`` into canonical form. + # It is assumed that the array ``poly`` contains a non-zero entry in + # position ``len - 1`` whenever ``len > 0``. Assumes that ``den`` + # is non-zero. + + void fmpq_poly_canonicalise(fmpq_poly_t poly) + # Puts the polynomial ``poly`` into canonical form. Firstly, the length + # is set to the actual length of the numerator polynomial. For non-zero + # polynomials, it is then ensured that the numerator and denominator are + # coprime and that the denominator is positive. The canonical form of the + # zero polynomial is a zero numerator polynomial and a one denominator. + + int _fmpq_poly_is_canonical(const fmpz * poly, const fmpz_t den, long len) + # Returns whether the polynomial is in canonical form. + + int fmpq_poly_is_canonical(const fmpq_poly_t poly) + # Returns whether the polynomial is in canonical form. + + long fmpq_poly_degree(const fmpq_poly_t poly) + # Returns the degree of ``poly``, which is one less than its length, as + # a ``slong``. + + long fmpq_poly_length(const fmpq_poly_t poly) + # Returns the length of ``poly``. + + fmpz * fmpq_poly_numref(fmpq_poly_t poly) + # Returns a reference to the numerator polynomial as an array. + # Note that, because of a delayed initialisation approach, this might + # be ``NULL`` for zero polynomials. This situation can be salvaged + # by calling either :func:`fmpq_poly_fit_length` or + # :func:`fmpq_poly_realloc`. + # This function is implemented as a macro returning ``(poly)->coeffs``. + + fmpz_t fmpq_poly_denref(fmpq_poly_t poly) + # Returns a reference to the denominator as a ``fmpz_t``. The integer + # is guaranteed to be properly initialised. + # This function is implemented as a macro returning ``(poly)->den``. + + void fmpq_poly_get_numerator(fmpz_poly_t res, const fmpq_poly_t poly) + # Sets ``res`` to the numerator of ``poly``, e.g. the primitive part + # as an ``fmpz_poly_t`` if it is in canonical form. + + void fmpq_poly_get_denominator(fmpz_t den, const fmpq_poly_t poly) + # Sets ``res`` to the denominator of ``poly``. + + void fmpq_poly_randtest(fmpq_poly_t f, flint_rand_t state, long len, flint_bitcnt_t bits) + # Sets `f` to a random polynomial with coefficients up to the given + # length and where each coefficient has up to the given number of bits. + # The coefficients are signed randomly. One must call + # :func:`flint_randinit` before calling this function. + + void fmpq_poly_randtest_unsigned(fmpq_poly_t f, flint_rand_t state, long len, flint_bitcnt_t bits) + # Sets `f` to a random polynomial with coefficients up to the given length + # and where each coefficient has up to the given number of bits. One must + # call :func:`flint_randinit` before calling this function. + + void fmpq_poly_randtest_not_zero(fmpq_poly_t f, flint_rand_t state, long len, flint_bitcnt_t bits) + # As for :func:`fmpq_poly_randtest` except that ``len`` and ``bits`` + # may not be zero and the polynomial generated is guaranteed not to be the + # zero polynomial. One must call :func:`flint_randinit` before calling + # this function. + + void fmpq_poly_set(fmpq_poly_t poly1, const fmpq_poly_t poly2) + # Sets ``poly1`` to equal ``poly2``. + + void fmpq_poly_set_si(fmpq_poly_t poly, long x) + # Sets ``poly`` to the integer `x`. + + void fmpq_poly_set_ui(fmpq_poly_t poly, unsigned long x) + # Sets ``poly`` to the integer `x`. + + void fmpq_poly_set_fmpz(fmpq_poly_t poly, const fmpz_t x) + # Sets ``poly`` to the integer `x`. + + void fmpq_poly_set_fmpq(fmpq_poly_t poly, const fmpq_t x) + # Sets ``poly`` to the rational `x`, which is assumed to be + # given in lowest terms. + + void fmpq_poly_set_fmpz_poly(fmpq_poly_t rop, const fmpz_poly_t op) + # Sets the rational polynomial ``rop`` to the same value + # as the integer polynomial ``op``. + + void fmpq_poly_set_nmod_poly(fmpq_poly_t rop, const nmod_poly_t op) + # Sets the coefficients of ``rop`` to the residues in ``op``, + # normalised to the interval `-m/2 \le r < m/2` where `m` is the modulus. + + void fmpq_poly_get_nmod_poly(nmod_poly_t rop, const fmpq_poly_t op) + # Sets the coefficients of ``rop`` to the coefficients in the denominator of ``op``, + # reduced by the modulus of ``rop``. The result is multiplied by the inverse of the + # denominator of ``op``. It is assumed that the reduction of the denominator of ``op`` + # is invertible. + + void fmpq_poly_get_nmod_poly_den(nmod_poly_t rop, const fmpq_poly_t op, int den) + # Sets the coefficients of ``rop`` to the coefficients in the denominator + # of ``op``, reduced by the modulus of ``rop``. If ``den == 1``, the result is + # multiplied by the inverse of the denominator of ``op``. In this case it is + # assumed that the reduction of the denominator of ``op`` is invertible. + + int _fmpq_poly_set_str(fmpz * poly, fmpz_t den, const char * str, long len) + # Sets ``(poly, den)`` to the polynomial specified by the + # null-terminated string ``str`` of ``len`` coefficients. The input + # format is a sequence of coefficients separated by one space. + # The result is only guaranteed to be in lowest terms if all + # coefficients in the input string are in lowest terms. + # Returns `0` if no error occurred. Otherwise, returns -1 + # in which case the resulting value of ``(poly, den)`` is undefined. + # If ``str`` is not null-terminated, calling this method might result + # in a segmentation fault. + + int fmpq_poly_set_str(fmpq_poly_t poly, const char * str) + # Sets ``poly`` to the polynomial specified by the null-terminated + # string ``str``. The input format is the same as the output format + # of ``fmpq_poly_get_str``: the length given as a decimal integer, + # then two spaces, then the list of coefficients separated by one space. + # The result is only guaranteed to be in canonical form if all + # coefficients in the input string are in lowest terms. + # Returns `0` if no error occurred. Otherwise, returns -1 in which case + # the resulting value of ``poly`` is set to zero. If ``str`` is not + # null-terminated, calling this method might result in a segmentation fault. + + char * fmpq_poly_get_str(const fmpq_poly_t poly) + # Returns the string representation of ``poly``. + + char * fmpq_poly_get_str_pretty(const fmpq_poly_t poly, const char * var) + # Returns the pretty representation of ``poly``, using the + # null-terminated string ``var`` not equal to ``"\0"`` as + # the variable name. + + void fmpq_poly_zero(fmpq_poly_t poly) + # Sets ``poly`` to zero. + + void fmpq_poly_one(fmpq_poly_t poly) + # Sets ``poly`` to the constant polynomial `1`. + + void fmpq_poly_neg(fmpq_poly_t poly1, const fmpq_poly_t poly2) + # Sets ``poly1`` to the additive inverse of ``poly2``. + + void fmpq_poly_inv(fmpq_poly_t poly1, const fmpq_poly_t poly2) + # Sets ``poly1`` to the multiplicative inverse of ``poly2`` + # if possible. Otherwise, if ``poly2`` is not a unit, leaves + # ``poly1`` unmodified and calls :func:`abort`. + + void fmpq_poly_swap(fmpq_poly_t poly1, fmpq_poly_t poly2) + # Efficiently swaps the polynomials ``poly1`` and ``poly2``. + + void fmpq_poly_truncate(fmpq_poly_t poly, long n) + # If the current length of ``poly`` is greater than `n`, it is + # truncated to the given length. Discarded coefficients are demoted, + # but they are not necessarily set to zero. + + void fmpq_poly_set_trunc(fmpq_poly_t res, const fmpq_poly_t poly, long n) + # Sets ``res`` to a copy of ``poly``, truncated to length ``n``. + + void fmpq_poly_get_slice(fmpq_poly_t rop, const fmpq_poly_t op, long i, long j) + # Returns the slice with coefficients from `x^i` (including) to + # `x^j` (excluding). + + void fmpq_poly_reverse(fmpq_poly_t res, const fmpq_poly_t poly, long n) + # This function considers the polynomial ``poly`` to be of length `n`, + # notionally truncating and zero padding if required, and reverses + # the result. Since the function normalises its result ``res`` may be + # of length less than `n`. + + void fmpq_poly_get_coeff_fmpz(fmpz_t x, const fmpq_poly_t poly, long n) + # Retrieves the `n`\th coefficient of the numerator of ``poly``. + + void fmpq_poly_get_coeff_fmpq(fmpq_t x, const fmpq_poly_t poly, long n) + # Retrieves the `n`\th coefficient of ``poly``, in lowest terms. + + void fmpq_poly_set_coeff_si(fmpq_poly_t poly, long n, long x) + # Sets the `n`\th coefficient in ``poly`` to the integer `x`. + + void fmpq_poly_set_coeff_ui(fmpq_poly_t poly, long n, unsigned long x) + # Sets the `n`\th coefficient in ``poly`` to the integer `x`. + + void fmpq_poly_set_coeff_fmpz(fmpq_poly_t poly, long n, const fmpz_t x) + # Sets the `n`\th coefficient in ``poly`` to the integer `x`. + + void fmpq_poly_set_coeff_fmpq(fmpq_poly_t poly, long n, const fmpq_t x) + # Sets the `n`\th coefficient in ``poly`` to the rational `x`. + + int fmpq_poly_equal(const fmpq_poly_t poly1, const fmpq_poly_t poly2) + # Returns `1` if ``poly1`` is equal to ``poly2``, + # otherwise returns `0`. + + int _fmpq_poly_equal_trunc(const fmpz * poly1, const fmpz_t den1, long len1, const fmpz * poly2, const fmpz_t den2, long len2, long n) + # Returns `1` if ``poly1`` and ``poly2`` notionally truncated to length + # `n` are equal, otherwise returns `0`. + + int fmpq_poly_equal_trunc(const fmpq_poly_t poly1, const fmpq_poly_t poly2, long n) + # Returns `1` if ``poly1`` and ``poly2`` notionally truncated to length + # `n` are equal, otherwise returns `0`. + + int _fmpq_poly_cmp(const fmpz * lpoly, const fmpz_t lden, const fmpz * rpoly, const fmpz_t rden, long len) + # Compares two non-zero polynomials, assuming they have the same length + # ``len > 0``. + # The polynomials are expected to be provided in canonical form. + + int fmpq_poly_cmp(const fmpq_poly_t left, const fmpq_poly_t right) + # Compares the two polynomials ``left`` and ``right``. + # Compares the two polynomials ``left`` and ``right``, returning + # `-1`, `0`, or `1` as ``left`` is less than, equal to, or greater + # than ``right``. The comparison is first done by the degree, and + # then, in case of a tie, by the individual coefficients from highest + # to lowest. + + int fmpq_poly_is_one(const fmpq_poly_t poly) + # Returns `1` if ``poly`` is the constant polynomial `1`, otherwise + # returns `0`. + + int fmpq_poly_is_zero(const fmpq_poly_t poly) + # Returns `1` if ``poly`` is the zero polynomial, otherwise returns `0`. + + int fmpq_poly_is_gen(const fmpq_poly_t poly) + # Returns `1` if ``poly`` is the degree `1` polynomial `x`, otherwise returns + # `0`. + + void _fmpq_poly_add(fmpz * rpoly, fmpz_t rden, const fmpz * poly1, const fmpz_t den1, long len1, const fmpz * poly2, const fmpz_t den2, long len2) + # Forms the sum ``(rpoly, rden)`` of ``(poly1, den1, len1)`` and + # ``(poly2, den2, len2)``, placing the result into canonical form. + # Assumes that ``rpoly`` is an array of length the maximum of + # ``len1`` and ``len2``. The input operands are assumed to + # be in canonical form and are also allowed to be of length `0`. + # ``(rpoly, rden)`` and ``(poly1, den1)`` may be aliased, + # but ``(rpoly, rden)`` and ``(poly2, den2)`` may *not* + # be aliased. + + void _fmpq_poly_add_can(fmpz * rpoly, fmpz_t rden, const fmpz * poly1, const fmpz_t den1, long len1, const fmpz * poly2, const fmpz_t den2, long len2, int can) + # As per ``_fmpq_poly_add`` except that one can specify whether to + # canonicalise the output or not. This function is intended to be used with + # weak canonicalisation to prevent explosion in memory usage. It exists for + # performance reasons. + + void fmpq_poly_add(fmpq_poly_t res, const fmpq_poly_t poly1, const fmpq_poly_t poly2) + # Sets ``res`` to the sum of ``poly1`` and ``poly2``, using + # Henrici's algorithm. + + void fmpq_poly_add_can(fmpq_poly_t res, const fmpq_poly_t poly1, const fmpq_poly_t poly2, int can) + # As per ``mpq_poly_add`` except that one can specify whether to + # canonicalise the output or not. This function is intended to be used with + # weak canonicalisation to prevent explosion in memory usage. It exists for + # performance reasons. + + void _fmpq_poly_add_series(fmpz * rpoly, fmpz_t rden, const fmpz * poly1, const fmpz_t den1, long len1, const fmpz * poly2, const fmpz_t den2, long len2, long n) + # As per ``_fmpq_poly_add`` but the inputs are first notionally truncated + # to length `n`. If `n` is less than ``len1`` or ``len2`` then the + # output only needs space for `n` coefficients. We require `n \geq 0`. + + void _fmpq_poly_add_series_can(fmpz * rpoly, fmpz_t rden, const fmpz * poly1, const fmpz_t den1, long len1, const fmpz * poly2, const fmpz_t den2, long len2, long n, int can) + # As per ``_fmpq_poly_add_can`` but the inputs are first notionally + # truncated to length `n`. If `n` is less than ``len1`` or ``len2`` + # then the output only needs space for `n` coefficients. We require + # `n \geq 0`. + + void fmpq_poly_add_series(fmpq_poly_t res, const fmpq_poly_t poly1, const fmpq_poly_t poly2, long n) + # As per ``fmpq_poly_add`` but the inputs are first notionally + # truncated to length `n`. + + void fmpq_poly_add_series_can(fmpq_poly_t res, const fmpq_poly_t poly1, const fmpq_poly_t poly2, long n, int can) + # As per ``fmpq_poly_add_can`` but the inputs are first notionally + # truncated to length `n`. + + void _fmpq_poly_sub(fmpz * rpoly, fmpz_t rden, const fmpz * poly1, const fmpz_t den1, long len1, const fmpz * poly2, const fmpz_t den2, long len2) + # Forms the difference ``(rpoly, rden)`` of ``(poly1, den1, len1)`` + # and ``(poly2, den2, len2)``, placing the result into canonical form. + # Assumes that ``rpoly`` is an array of length the maximum of + # ``len1`` and ``len2``. The input operands are assumed to be in + # canonical form and are also allowed to be of length `0`. + # ``(rpoly, rden)`` and ``(poly1, den1, len1)`` may be aliased, + # but ``(rpoly, rden)`` and ``(poly2, den2, len2)`` may *not* be + # aliased. + + void _fmpq_poly_sub_can(fmpz * rpoly, fmpz_t rden, const fmpz * poly1, const fmpz_t den1, long len1, const fmpz * poly2, const fmpz_t den2, long len2, int can) + # As per ``_fmpq_poly_sub`` except that one can specify whether to + # canonicalise the output or not. This function is intended to be used with + # weak canonicalisation to prevent explosion in memory usage. It exists for + # performance reasons. + + void fmpq_poly_sub(fmpq_poly_t res, const fmpq_poly_t poly1, const fmpq_poly_t poly2) + # Sets ``res`` to the difference of ``poly1`` and ``poly2``, + # using Henrici's algorithm. + + void fmpq_poly_sub_can(fmpq_poly_t res, const fmpq_poly_t poly1, const fmpq_poly_t poly2, int can) + # As per ``_fmpq_poly_sub`` except that one can specify whether to + # canonicalise the output or not. This function is intended to be used with + # weak canonicalisation to prevent explosion in memory usage. It exists for + # performance reasons. + + void _fmpq_poly_sub_series(fmpz * rpoly, fmpz_t rden, const fmpz * poly1, const fmpz_t den1, long len1, const fmpz * poly2, const fmpz_t den2, long len2, long n) + # As per ``_fmpq_poly_sub`` but the inputs are first notionally truncated + # to length `n`. If `n` is less than ``len1`` or ``len2`` then the + # output only needs space for `n` coefficients. We require `n \geq 0`. + + void _fmpq_poly_sub_series_can(fmpz * rpoly, fmpz_t rden, const fmpz * poly1, const fmpz_t den1, long len1, const fmpz * poly2, const fmpz_t den2, long len2, long n, int can) + # As per ``_fmpq_poly_sub_can`` but the inputs are first notionally + # truncated to length `n`. If `n` is less than ``len1`` or ``len2`` + # then the output only needs space for `n` coefficients. We require + # `n \geq 0`. + + void fmpq_poly_sub_series(fmpq_poly_t res, const fmpq_poly_t poly1, const fmpq_poly_t poly2, long n) + # As per ``fmpq_poly_sub`` but the inputs are first notionally + # truncated to length `n`. + + void fmpq_poly_sub_series_can(fmpq_poly_t res, const fmpq_poly_t poly1, const fmpq_poly_t poly2, long n, int can) + # As per ``fmpq_poly_sub_can`` but the inputs are first notionally + # truncated to length `n`. + + void _fmpq_poly_scalar_mul_si(fmpz * rpoly, fmpz_t rden, const fmpz * poly, const fmpz_t den, long len, long c) + # Sets ``(rpoly, rden, len)`` to the product of `c` of + # ``(poly, den, len)``. + # If the input is normalised, then so is the output, provided it is + # non-zero. If the input is in lowest terms, then so is the output. + # However, even if neither of these conditions are met, the result + # will be (mathematically) correct. + # Supports exact aliasing between ``(rpoly, den)`` + # and ``(poly, den)``. + + void _fmpq_poly_scalar_mul_ui(fmpz * rpoly, fmpz_t rden, const fmpz * poly, const fmpz_t den, long len, unsigned long c) + # Sets ``(rpoly, rden, len)`` to the product of `c` of + # ``(poly, den, len)``. + # If the input is normalised, then so is the output, provided it is + # non-zero. If the input is in lowest terms, then so is the output. + # However, even if neither of these conditions are met, the result + # will be (mathematically) correct. + # Supports exact aliasing between ``(rpoly, den)`` + # and ``(poly, den)``. + + void _fmpq_poly_scalar_mul_fmpz(fmpz * rpoly, fmpz_t rden, const fmpz * poly, const fmpz_t den, long len, const fmpz_t c) + # Sets ``(rpoly, rden, len)`` to the product of `c` of + # ``(poly, den, len)``. + # If the input is normalised, then so is the output, provided it is + # non-zero. If the input is in lowest terms, then so is the output. + # However, even if neither of these conditions are met, the result + # will be (mathematically) correct. + # Supports exact aliasing between ``(rpoly, den)`` + # and ``(poly, den)``. + + void _fmpq_poly_scalar_mul_fmpq(fmpz * rpoly, fmpz_t rden, const fmpz * poly, const fmpz_t den, long len, const fmpz_t r, const fmpz_t s) + # Sets ``(rpoly, rden)`` to the product of `r/s` and + # ``(poly, den, len)``, in lowest terms. + # Assumes that ``(poly, den, len)`` and `r/s` are provided in lowest + # terms. Assumes that ``rpoly`` is an array of length ``len``. + # Supports aliasing of ``(rpoly, den)`` and ``(poly, den)``. + # The ``fmpz_t``'s `r` and `s` may not be part of ``(rpoly, rden)``. + + void fmpq_poly_scalar_mul_si(fmpq_poly_t rop, const fmpq_poly_t op, long c) + # Sets ``rop`` to `c` times ``op``. + + void fmpq_poly_scalar_mul_ui(fmpq_poly_t rop, const fmpq_poly_t op, unsigned long c) + # Sets ``rop`` to `c` times ``op``. + + void fmpq_poly_scalar_mul_fmpz(fmpq_poly_t rop, const fmpq_poly_t op, const fmpz_t c) + # Sets ``rop`` to `c` times ``op``. Assumes that the ``fmpz_t c`` + # is not part of ``rop``. + + void fmpq_poly_scalar_mul_mpq(fmpq_poly_t rop, const fmpq_poly_t op, const fmpq_t c) + # Sets ``rop`` to `c` times ``op``. + + void _fmpq_poly_scalar_div_fmpz(fmpz * rpoly, fmpz_t rden, const fmpz * poly, const fmpz_t den, long len, const fmpz_t c) + # Sets ``(rpoly, rden, len)`` to ``(poly, den, len)`` divided by `c`, + # in lowest terms. + # Assumes that ``len`` is positive. Assumes that `c` is non-zero. + # Supports aliasing between ``(rpoly, rden)`` and ``(poly, den)``. + # Assumes that `c` is not part of ``(rpoly, rden)``. + + void _fmpq_poly_scalar_div_si(fmpz * rpoly, fmpz_t rden, const fmpz * poly, const fmpz_t den, long len, long c) + # Sets ``(rpoly, rden, len)`` to ``(poly, den, len)`` divided by `c`, + # in lowest terms. + # Assumes that ``len`` is positive. Assumes that `c` is non-zero. + # Supports aliasing between ``(rpoly, rden)`` and ``(poly, den)``. + + void _fmpq_poly_scalar_div_ui(fmpz * rpoly, fmpz_t rden, const fmpz * poly, const fmpz_t den, long len, unsigned long c) + # Sets ``(rpoly, rden, len)`` to ``(poly, den, len)`` divided by `c`, + # in lowest terms. + # Assumes that ``len`` is positive. Assumes that `c` is non-zero. + # Supports aliasing between ``(rpoly, rden)`` and ``(poly, den)``. + + void _fmpq_poly_scalar_div_fmpq(fmpz * rpoly, fmpz_t rden, const fmpz * poly, const fmpz_t den, long len, const fmpz_t r, const fmpz_t s) + # Sets ``(rpoly, rden, len)`` to ``(poly, den, len)`` divided by `r/s`, + # in lowest terms. + # Assumes that ``len`` is positive. Assumes that `r/s` is non-zero and + # in lowest terms. Supports aliasing between ``(rpoly, rden)`` and + # ``(poly, den)``. The ``fmpz_t``'s `r` and `s` may not be part of + # ``(rpoly, poly)``. + + void fmpq_poly_scalar_div_si(fmpq_poly_t rop, const fmpq_poly_t op, long c) + void fmpq_poly_scalar_div_ui(fmpq_poly_t rop, const fmpq_poly_t op, unsigned long c) + void fmpq_poly_scalar_div_fmpz(fmpq_poly_t rop, const fmpq_poly_t op, const fmpz_t c) + void fmpq_poly_scalar_div_fmpq(fmpq_poly_t rop, const fmpq_poly_t op, const fmpq_t c) + # Sets ``rop`` to ``op`` divided by the scalar ``c``. + + void _fmpq_poly_mul(fmpz * rpoly, fmpz_t rden, const fmpz * poly1, const fmpz_t den1, long len1, const fmpz * poly2, const fmpz_t den2, long len2) + # Sets ``(rpoly, rden, len1 + len2 - 1)`` to the product of + # ``(poly1, den1, len1)`` and ``(poly2, den2, len2)``. If the + # input is provided in canonical form, then so is the output. + # Assumes ``len1 >= len2 > 0``. Allows zero-padding in the input. + # Does not allow aliasing between the inputs and outputs. + + void fmpq_poly_mul(fmpq_poly_t res, const fmpq_poly_t poly1, const fmpq_poly_t poly2) + # Sets ``res`` to the product of ``poly1`` and ``poly2``. + + void _fmpq_poly_mullow(fmpz * rpoly, fmpz_t rden, const fmpz * poly1, const fmpz_t den1, long len1, const fmpz * poly2, const fmpz_t den2, long len2, long n) + # Sets ``(rpoly, rden, n)`` to the low `n` coefficients of + # ``(poly1, den1)`` and ``(poly2, den2)``. The output is + # not guaranteed to be in canonical form. + # Assumes ``len1 >= len2 > 0`` and ``0 < n <= len1 + len2 - 1``. + # Allows for zero-padding in the inputs. Does not allow aliasing between + # the inputs and outputs. + + void fmpq_poly_mullow(fmpq_poly_t res, const fmpq_poly_t poly1, const fmpq_poly_t poly2, long n) + # Sets ``res`` to the product of ``poly1`` and ``poly2``, + # truncated to length `n`. + + void fmpq_poly_addmul(fmpq_poly_t rop, const fmpq_poly_t op1, const fmpq_poly_t op2) + # Adds the product of ``op1`` and ``op2`` to ``rop``. + + void fmpq_poly_submul(fmpq_poly_t rop, const fmpq_poly_t op1, const fmpq_poly_t op2) + # Subtracts the product of ``op1`` and ``op2`` from ``rop``. + + void _fmpq_poly_pow(fmpz * rpoly, fmpz_t rden, const fmpz * poly, const fmpz_t den, long len, unsigned long e) + # Sets ``(rpoly, rden)`` to ``(poly, den)^e``, assuming + # ``e, len > 0``. Assumes that ``rpoly`` is an array of + # length at least ``e * (len - 1) + 1``. Supports aliasing + # of ``(rpoly, den)`` and ``(poly, den)``. + + void fmpq_poly_pow(fmpq_poly_t res, const fmpq_poly_t poly, unsigned long e) + # Sets ``res`` to ``poly^e``, where the only special case `0^0` is + # defined as `1`. + + void _fmpq_poly_pow_trunc(fmpz * res, fmpz_t rden, const fmpz * f, const fmpz_t fden, long flen, unsigned long exp, long len) + # Sets ``(rpoly, rden, len)`` to ``(poly, den)^e`` truncated to length ``len``, + # where ``len`` is at most ``e * (flen - 1) + 1``. + + void fmpq_poly_pow_trunc(fmpq_poly_t res, const fmpq_poly_t poly, unsigned long e, long n) + # Sets ``res`` to ``poly^e`` truncated to length ``n``. + + void fmpq_poly_shift_left(fmpq_poly_t res, const fmpq_poly_t poly, long n) + # Set ``res`` to ``poly`` shifted left by `n` coefficients. Zero + # coefficients are inserted. + + void fmpq_poly_shift_right(fmpq_poly_t res, const fmpq_poly_t poly, long n) + # Set ``res`` to ``poly`` shifted right by `n` coefficients. + # If `n` is equal to or greater than the current length of ``poly``, + # ``res`` is set to the zero polynomial. + + void _fmpq_poly_divrem(fmpz * Q, fmpz_t q, fmpz * R, fmpz_t r, const fmpz * A, const fmpz_t a, long lenA, const fmpz * B, const fmpz_t b, long lenB, const fmpz_preinvn_t inv) + # Finds the quotient ``(Q, q)`` and remainder ``(R, r)`` of the + # Euclidean division of ``(A, a)`` by ``(B, b)``. + # Assumes that ``lenA >= lenB > 0``. Assumes that `R` has space for + # ``lenA`` coefficients, although only the bottom ``lenB - 1`` will + # carry meaningful data on exit. Supports no aliasing between the two + # outputs, or between the inputs and the outputs. + # An optional precomputed inverse of the leading coefficient of `B` from + # ``fmpz_preinvn_init`` can be supplied. Otherwise ``inv`` should be + # ``NULL``. + # Note: ``fmpz.h`` has to be included before ``fmpq_poly.h`` in order for the + # latter to declare this function. + + void fmpq_poly_divrem(fmpq_poly_t Q, fmpq_poly_t R, const fmpq_poly_t poly1, const fmpq_poly_t poly2) + # Finds the quotient `Q` and remainder `R` of the Euclidean division of + # ``poly1`` by ``poly2``. + + void _fmpq_poly_div(fmpz * Q, fmpz_t q, const fmpz * A, const fmpz_t a, long lenA, const fmpz * B, const fmpz_t b, long lenB, const fmpz_preinvn_t inv) + # Finds the quotient ``(Q, q)`` of the Euclidean division + # of ``(A, a)`` by ``(B, b)``. + # Assumes that ``lenA >= lenB > 0``. Supports no aliasing + # between the inputs and the outputs. + # An optional precomputed inverse of the leading coefficient of `B` from + # ``fmpz_preinvn_init`` can be supplied. Otherwise ``inv`` should be + # ``NULL``. + # Note: ``fmpz.h`` has to be included before ``fmpq_poly.h`` in order for the + # latter to declare this function. + + void fmpq_poly_div(fmpq_poly_t Q, const fmpq_poly_t poly1, const fmpq_poly_t poly2) + # Finds the quotient `Q` and remainder `R` of the Euclidean division + # of ``poly1`` by ``poly2``. + + void _fmpq_poly_rem(fmpz * R, fmpz_t r, const fmpz * A, const fmpz_t a, long lenA, const fmpz * B, const fmpz_t b, long lenB, const fmpz_preinvn_t inv) + # Finds the remainder ``(R, r)`` of the Euclidean division + # of ``(A, a)`` by ``(B, b)``. + # Assumes that ``lenA >= lenB > 0``. Supports no aliasing between + # the inputs and the outputs. + # An optional precomputed inverse of the leading coefficient of `B` from + # ``fmpz_preinvn_init`` can be supplied. Otherwise ``inv`` should be + # ``NULL``. + # Note: ``fmpz.h`` has to be included before ``fmpq_poly.h`` in order for the + # latter to declare this function. + + void fmpq_poly_rem(fmpq_poly_t R, const fmpq_poly_t poly1, const fmpq_poly_t poly2) + # Finds the remainder `R` of the Euclidean division + # of ``poly1`` by ``poly2``. + + fmpq_poly_struct * _fmpq_poly_powers_precompute(const fmpz * B, const fmpz_t denB, long len) + # Computes ``2*len - 1`` powers of `x` modulo the polynomial `B` of + # the given length. This is used as a kind of precomputed inverse in + # the remainder routine below. + + void fmpq_poly_powers_precompute(fmpq_poly_powers_precomp_t pinv, fmpq_poly_t poly) + # Computes ``2*len - 1`` powers of `x` modulo the polynomial `B` of the given length. This is used as a kind of precomputed inverse in the remainder routine below. + + void _fmpq_poly_powers_clear(fmpq_poly_struct * powers, long len) + # Clean up resources used by precomputed powers which have been computed + # by ``_fmpq_poly_powers_precompute``. + + void fmpq_poly_powers_clear(fmpq_poly_powers_precomp_t pinv) + # Clean up resources used by precomputed powers which have been computed + # by ``fmpq_poly_powers_precompute``. + + void _fmpq_poly_rem_powers_precomp(fmpz * A, fmpz_t denA, long m, const fmpz * B, const fmpz_t denB, long n, fmpq_poly_struct * const powers) + # Set `A` to the remainder of `A` divide `B` given precomputed powers mod `B` + # provided by ``_fmpq_poly_powers_precompute``. No aliasing is allowed. + # This function is only faster if `m \leq 2\cdot n - 1`. + # The output of this function is *not* canonicalised. + + void fmpq_poly_rem_powers_precomp(fmpq_poly_t R, const fmpq_poly_t A, const fmpq_poly_t B, const fmpq_poly_powers_precomp_t B_inv) + # Set `R` to the remainder of `A` divide `B` given precomputed powers mod `B` + # provided by ``fmpq_poly_powers_precompute``. + # This function is only faster if ``A->length <= 2*B->length - 1``. + # The output of this function is *not* canonicalised. + + int _fmpq_poly_divides(fmpz * qpoly, fmpz_t qden, const fmpz * poly1, const fmpz_t den1, long len1, const fmpz * poly2, const fmpz_t den2, long len2) + # Return `1` if ``(poly2, den2, len2)`` divides ``(poly1, den1, len1)`` and + # set ``(qpoly, qden, len1 - len2 + 1)`` to the quotient. Otherwise return + # `0`. Requires that ``qpoly`` has space for ``len1 - len2 + 1`` + # coefficients and that ``len1 >= len2 > 0``. + + int fmpq_poly_divides(fmpq_poly_t q, const fmpq_poly_t poly1, const fmpq_poly_t poly2) + # Return `1` if ``poly2`` divides ``poly1`` and set ``q`` to the quotient. + # Otherwise return `0`. + + long fmpq_poly_remove(fmpq_poly_t q, const fmpq_poly_t poly1, const fmpq_poly_t poly2) + # Sets ``q`` to the quotient of ``poly1`` by the highest power of ``poly2`` + # which divides it, and returns the power. The divisor ``poly2`` must not be + # constant or an exception is raised. + + void _fmpq_poly_inv_series_newton(fmpz * rpoly, fmpz_t rden, const fmpz * poly, const fmpz_t den, long len, long n) + # Computes the first `n` terms of the inverse power series of + # ``(poly, den, len)`` using Newton iteration. + # The result is produced in canonical form. + # Assumes that `n \geq 1` and that ``poly`` has non-zero constant term. + # Does not support aliasing. + + void fmpq_poly_inv_series_newton(fmpq_poly_t res, const fmpq_poly_t poly, long n) + # Computes the first `n` terms of the inverse power series + # of ``poly`` using Newton iteration, assuming that ``poly`` + # has non-zero constant term and `n \geq 1`. + + void _fmpq_poly_inv_series(fmpz * rpoly, fmpz_t rden, const fmpz * poly, const fmpz_t den, long den_len, long n) + # Computes the first `n` terms of the inverse power series of + # ``(poly, den, len)``. + # The result is produced in canonical form. + # Assumes that `n \geq 1` and that ``poly`` has non-zero constant term. + # Does not support aliasing. + + void fmpq_poly_inv_series(fmpq_poly_t res, const fmpq_poly_t poly, long n) + # Computes the first `n` terms of the inverse power series of ``poly``, + # assuming that ``poly`` has non-zero constant term and `n \geq 1`. + + void _fmpq_poly_div_series(fmpz * Q, fmpz_t denQ, const fmpz * A, const fmpz_t denA, long lenA, const fmpz * B, const fmpz_t denB, long lenB, long n) + # Divides ``(A, denA, lenA)`` by ``(B, denB, lenB)`` as power series + # over `\mathbb{Q}`, assuming `B` has non-zero constant term and that + # all lengths are positive. + # Aliasing is not supported. + # This function ensures that the numerator and denominator + # are coprime on exit. + + void fmpq_poly_div_series(fmpq_poly_t Q, const fmpq_poly_t A, const fmpq_poly_t B, long n) + # Performs power series division in `\mathbb{Q}[[x]] / (x^n)`. The function + # considers the polynomials `A` and `B` as power series of length `n` + # starting with the constant terms. The function assumes that `B` has + # non-zero constant term and `n \geq 1`. + + void _fmpq_poly_gcd(fmpz *G, fmpz_t denG, const fmpz *A, long lenA, const fmpz *B, long lenB) + # Computes the monic greatest common divisor `G` of `A` and `B`. + # Assumes that `G` has space for `\operatorname{len}(B)` coefficients, + # where `\operatorname{len}(A) \geq \operatorname{len}(B) > 0`. + # Aliasing between the output and input arguments is not supported. + # Does not support zero-padding. + + void fmpq_poly_gcd(fmpq_poly_t G, const fmpq_poly_t A, const fmpq_poly_t B) + # Computes the monic greatest common divisor `G` of `A` and `B`. + # In the special case when `A = B = 0`, sets `G = 0`. + + void _fmpq_poly_xgcd(fmpz *G, fmpz_t denG, fmpz *S, fmpz_t denS, fmpz *T, fmpz_t denT, const fmpz *A, const fmpz_t denA, long lenA, const fmpz *B, const fmpz_t denB, long lenB) + # Computes polynomials `G`, `S`, and `T` such that + # `G = \gcd(A, B) = S A + T B`, where `G` is the monic + # greatest common divisor of `A` and `B`. + # Assumes that `G`, `S`, and `T` have space for `\operatorname{len}(B)`, + # `\operatorname{len}(B)`, and `\operatorname{len}(A)` coefficients, respectively, + # where it is also assumed that `\operatorname{len}(A) \geq \operatorname{len}(B) > 0`. + # Does not support zero padding of the input arguments. + + void fmpq_poly_xgcd(fmpq_poly_t G, fmpq_poly_t S, fmpq_poly_t T, const fmpq_poly_t A, const fmpq_poly_t B) + # Computes polynomials `G`, `S`, and `T` such that + # `G = \gcd(A, B) = S A + T B`, where `G` is the monic + # greatest common divisor of `A` and `B`. + # Corner cases are handled as follows. If `A = B = 0`, returns + # `G = S = T = 0`. If `A \neq 0`, `B = 0`, returns the suitable + # scalar multiple of `G = A`, `S = 1`, and `T = 0`. The case + # when `A = 0`, `B \neq 0` is handled similarly. + + void _fmpq_poly_lcm(fmpz *L, fmpz_t denL, const fmpz *A, long lenA, const fmpz *B, long lenB) + # Computes the monic least common multiple `L` of `A` and `B`. + # Assumes that `L` has space for `\operatorname{len}(A) + \operatorname{len}(B) - 1` coefficients, + # where `\operatorname{len}(A) \geq \operatorname{len}(B) > 0`. + # Aliasing between the output and input arguments is not supported. + # Does not support zero-padding. + + void fmpq_poly_lcm(fmpq_poly_t L, const fmpq_poly_t A, const fmpq_poly_t B) + # Computes the monic least common multiple `L` of `A` and `B`. + # In the special case when `A = B = 0`, sets `L = 0`. + + void _fmpq_poly_resultant(fmpz_t rnum, fmpz_t rden, const fmpz *poly1, const fmpz_t den1, long len1, const fmpz *poly2, const fmpz_t den2, long len2) + # Sets ``(rnum, rden)`` to the resultant of the two input + # polynomials. + # Assumes that ``len1 >= len2 > 0``. Does not support zero-padding + # of the input polynomials. Does not support aliasing of the input and + # output arguments. + + void fmpq_poly_resultant(fmpq_t r, const fmpq_poly_t f, const fmpq_poly_t g) + # Returns the resultant of `f` and `g`. + # Enumerating the roots of `f` and `g` over `\bar{\mathbf{Q}}` as + # `r_1, \dotsc, r_m` and `s_1, \dotsc, s_n`, respectively, and + # letting `x` and `y` denote the leading coefficients, the resultant + # is defined as + # .. math :: + # x^{\deg(f)} y^{\deg(g)} \prod_{1 \leq i, j \leq n} (r_i - s_j). + # We handle special cases as follows: if one of the polynomials is zero, + # the resultant is zero. Note that otherwise if one of the polynomials is + # constant, the last term in the above expression is the empty product. + + void fmpq_poly_resultant_div(fmpq_t r, const fmpq_poly_t f, const fmpq_poly_t g, const fmpz_t div, long nbits) + # Returns the resultant of `f` and `g` divided by ``div`` under the + # assumption that the result has at most ``nbits`` bits. The result must + # be an integer. + + void _fmpq_poly_derivative(fmpz * rpoly, fmpz_t rden, const fmpz * poly, const fmpz_t den, long len) + # Sets ``(rpoly, rden, len - 1)`` to the derivative of + # ``(poly, den, len)``. Does nothing if ``len <= 1``. + # Supports aliasing between the two polynomials. + + void fmpq_poly_derivative(fmpq_poly_t res, const fmpq_poly_t poly) + # Sets ``res`` to the derivative of ``poly``. + + void _fmpq_poly_nth_derivative(fmpz * rpoly, fmpz_t rden, const fmpz * poly, const fmpz_t den, unsigned long n, long len) + # Sets ``(rpoly, rden, len - n)`` to the nth derivative of + # ``(poly, den, len)``. Does nothing if ``len <= n``. + # Supports aliasing between the two polynomials. + + void fmpq_poly_nth_derivative(fmpq_poly_t res, const fmpq_poly_t poly, unsigned long n) + # Sets ``res`` to the nth derivative of ``poly``. + + void _fmpq_poly_integral(fmpz * rpoly, fmpz_t rden, const fmpz * poly, const fmpz_t den, long len) + # Sets ``(rpoly, rden, len)`` to the integral of + # ``(poly, den, len - 1)``. Assumes ``len >= 0``. + # Supports aliasing between the two polynomials. + # The output will be in canonical form if the input is + # in canonical form. + + void fmpq_poly_integral(fmpq_poly_t res, const fmpq_poly_t poly) + # Sets ``res`` to the integral of ``poly``. The constant + # term is set to zero. In particular, the integral of the zero + # polynomial is the zero polynomial. + + void _fmpq_poly_sqrt_series(fmpz * g, fmpz_t gden, const fmpz * f, const fmpz_t fden, long flen, long n) + # Sets ``(g, gden, n)`` to the series expansion of the + # square root of ``(f, fden, flen)``. Assumes ``n > 0`` and + # that ``(f, fden, flen)`` has constant term 1. + # Does not support aliasing between the input and output polynomials. + + void fmpq_poly_sqrt_series(fmpq_poly_t res, const fmpq_poly_t f, long n) + # Sets ``res`` to the series expansion of the square root of ``f`` + # to order ``n > 1``. Requires ``f`` to have constant term 1. + + void _fmpq_poly_invsqrt_series(fmpz * g, fmpz_t gden, const fmpz * f, const fmpz_t fden, long flen, long n) + # Sets ``(g, gden, n)`` to the series expansion of the inverse + # square root of ``(f, fden, flen)``. Assumes ``n > 0`` and + # that ``(f, fden, flen)`` has constant term 1. + # Does not support aliasing between the input and output polynomials. + + void fmpq_poly_invsqrt_series(fmpq_poly_t res, const fmpq_poly_t f, long n) + # Sets ``res`` to the series expansion of the inverse square root of + # ``f`` to order ``n > 0``. Requires ``f`` to have constant term 1. + + void _fmpq_poly_power_sums(fmpz * res, fmpz_t rden, const fmpz * poly, long len, long n) + # Compute the (truncated) power sums series of the polynomial + # ``(poly,len)`` up to length `n` using Newton identities. + + void fmpq_poly_power_sums(fmpq_poly_t res, const fmpq_poly_t poly, long n) + # Compute the (truncated) power sum series of the monic polynomial + # ``poly`` up to length `n` using Newton identities. That is the power + # series whose coefficient of degree `i` is the sum of the `i`-th power of + # all (complex) roots of the polynomial ``poly``. + + void _fmpq_poly_power_sums_to_poly(fmpz * res, const fmpz * poly, const fmpz_t den, long len) + # Compute an integer polynomial given by its power sums series ``(poly,den,len)``. + + void fmpq_poly_power_sums_to_fmpz_poly(fmpz_poly_t res, const fmpq_poly_t Q) + # Compute the integer polynomial with content one and positive leading + # coefficient given by its power sums series ``Q``. + + void fmpq_poly_power_sums_to_poly(fmpq_poly_t res, const fmpq_poly_t Q) + # Compute the monic polynomial from its power sums series ``Q``. + + void _fmpq_poly_log_series(fmpz * g, fmpz_t gden, const fmpz * f, const fmpz_t fden, long flen, long n) + # Sets ``(g, gden, n)`` to the series expansion of the + # logarithm of ``(f, fden, flen)``. Assumes ``n > 0`` and + # that ``(f, fden, flen)`` has constant term 1. + # Supports aliasing between the input and output polynomials. + + void fmpq_poly_log_series(fmpq_poly_t res, const fmpq_poly_t f, long n) + # Sets ``res`` to the series expansion of the logarithm of ``f`` + # to order ``n > 0``. Requires ``f`` to have constant term 1. + + void _fmpq_poly_exp_series(fmpz * g, fmpz_t gden, const fmpz * h, const fmpz_t hden, long hlen, long n) + # Sets ``(g, gden, n)`` to the series expansion of the + # exponential function of ``(h, hden, hlen)``. Assumes + # ``n > 0, hlen > 0`` and + # that ``(h, hden, hlen)`` has constant term 0. + # Supports aliasing between the input and output polynomials. + + void fmpq_poly_exp_series(fmpq_poly_t res, const fmpq_poly_t h, long n) + # Sets ``res`` to the series expansion of the exponential function + # of ``h`` to order ``n > 0``. Requires ``f`` to have + # constant term 0. + + void _fmpq_poly_exp_expinv_series(fmpz * res1, fmpz_t res1den, fmpz * res2, fmpz_t res2den, const fmpz * h, const fmpz_t hden, long hlen, long n) + # The same as ``fmpq_poly_exp_series``, but simultaneously computes + # the exponential (in ``res1``, ``res1den``) and its multiplicative inverse + # (in ``res2``, ``res2den``). + # Supports aliasing between the input and output polynomials. + + void fmpq_poly_exp_expinv_series(fmpq_poly_t res1, fmpq_poly_t res2, const fmpq_poly_t h, long n) + # The same as ``fmpq_poly_exp_series``, but simultaneously computes + # the exponential (in ``res1``) and its multiplicative inverse + # (in ``res2``). + + void _fmpq_poly_atan_series(fmpz * g, fmpz_t gden, const fmpz * f, const fmpz_t fden, long flen, long n) + # Sets ``(g, gden, n)`` to the series expansion of the + # inverse tangent of ``(f, fden, flen)``. Assumes ``n > 0`` and + # that ``(f, fden, flen)`` has constant term 0. + # Supports aliasing between the input and output polynomials. + + void fmpq_poly_atan_series(fmpq_poly_t res, const fmpq_poly_t f, long n) + # Sets ``res`` to the series expansion of the inverse tangent of ``f`` + # to order ``n > 0``. Requires ``f`` to have constant term 0. + + void _fmpq_poly_atanh_series(fmpz * g, fmpz_t gden, const fmpz * f, const fmpz_t fden, long flen, long n) + # Sets ``(g, gden, n)`` to the series expansion of the inverse + # hyperbolic tangent of ``(f, fden, flen)``. Assumes ``n > 0`` and + # that ``(f, fden, flen)`` has constant term 0. + # Supports aliasing between the input and output polynomials. + + void fmpq_poly_atanh_series(fmpq_poly_t res, const fmpq_poly_t f, long n) + # Sets ``res`` to the series expansion of the inverse hyperbolic + # tangent of ``f`` to order ``n > 0``. Requires ``f`` to have + # constant term 0. + + void _fmpq_poly_asin_series(fmpz * g, fmpz_t gden, const fmpz * f, const fmpz_t fden, long flen, long n) + # Sets ``(g, gden, n)`` to the series expansion of the + # inverse sine of ``(f, fden, flen)``. Assumes ``n > 0`` and + # that ``(f, fden, flen)`` has constant term 0. + # Supports aliasing between the input and output polynomials. + + void fmpq_poly_asin_series(fmpq_poly_t res, const fmpq_poly_t f, long n) + # Sets ``res`` to the series expansion of the inverse sine of ``f`` + # to order ``n > 0``. Requires ``f`` to have constant term 0. + + void _fmpq_poly_asinh_series(fmpz * g, fmpz_t gden, const fmpz * f, const fmpz_t fden, long flen, long n) + # Sets ``(g, gden, n)`` to the series expansion of the inverse + # hyperbolic sine of ``(f, fden, flen)``. Assumes ``n > 0`` and + # that ``(f, fden, flen)`` has constant term 0. + # Supports aliasing between the input and output polynomials. + + void fmpq_poly_asinh_series(fmpq_poly_t res, const fmpq_poly_t f, long n) + # Sets ``res`` to the series expansion of the inverse hyperbolic + # sine of ``f`` to order ``n > 0``. Requires ``f`` to have + # constant term 0. + + void _fmpq_poly_tan_series(fmpz * g, fmpz_t gden, const fmpz * f, const fmpz_t fden, long flen, long n) + # Sets ``(g, gden, n)`` to the series expansion of the + # tangent function of ``(f, fden, flen)``. Assumes ``n > 0`` and + # that ``(f, fden, flen)`` has constant term 0. + # Does not support aliasing between the input and output polynomials. + + void fmpq_poly_tan_series(fmpq_poly_t res, const fmpq_poly_t f, long n) + # Sets ``res`` to the series expansion of the tangent function + # of ``f`` to order ``n > 0``. Requires ``f`` to have + # constant term 0. + + void _fmpq_poly_sin_series(fmpz * g, fmpz_t gden, const fmpz * f, const fmpz_t fden, long flen, long n) + # Sets ``(g, gden, n)`` to the series expansion of the + # sine of ``(f, fden, flen)``. Assumes ``n > 0`` and + # that ``(f, fden, flen)`` has constant term 0. + # Supports aliasing between the input and output polynomials. + + void fmpq_poly_sin_series(fmpq_poly_t res, const fmpq_poly_t f, long n) + # Sets ``res`` to the series expansion of the sine of ``f`` + # to order ``n > 0``. Requires ``f`` to have constant term 0. + + void _fmpq_poly_cos_series(fmpz * g, fmpz_t gden, const fmpz * f, const fmpz_t fden, long flen, long n) + # Sets ``(g, gden, n)`` to the series expansion of the + # cosine of ``(f, fden, flen)``. Assumes ``n > 0`` and + # that ``(f, fden, flen)`` has constant term 0. + # Supports aliasing between the input and output polynomials. + + void fmpq_poly_cos_series(fmpq_poly_t res, const fmpq_poly_t f, long n) + # Sets ``res`` to the series expansion of the cosine of ``f`` + # to order ``n > 0``. Requires ``f`` to have constant term 0. + + void _fmpq_poly_sin_cos_series(fmpz * s, fmpz_t sden, fmpz * c, fmpz_t cden, const fmpz * f, const fmpz_t fden, long flen, long n) + # Sets ``(s, sden, n)`` to the series expansion of the + # sine of ``(f, fden, flen)``, and ``(c, cden, n)`` to the series + # expansion of the cosine. Assumes ``n > 0`` and + # that ``(f, fden, flen)`` has constant term 0. + # Supports aliasing between the input and output polynomials. + + void fmpq_poly_sin_cos_series(fmpq_poly_t res1, fmpq_poly_t res2, const fmpq_poly_t f, long n) + # Sets ``res1`` to the series expansion of the sine of ``f`` + # to order ``n > 0``, and ``res2`` to the series expansion + # of the cosine. Requires ``f`` to have constant term 0. + + void _fmpq_poly_sinh_series(fmpz * g, fmpz_t gden, const fmpz * f, const fmpz_t fden, long flen, long n) + # Sets ``(g, gden, n)`` to the series expansion of the + # hyperbolic sine of ``(f, fden, flen)``. Assumes ``n > 0`` and + # that ``(f, fden, flen)`` has constant term 0. + # Does not support aliasing between the input and output polynomials. + + void fmpq_poly_sinh_series(fmpq_poly_t res, const fmpq_poly_t f, long n) + # Sets ``res`` to the series expansion of the hyperbolic sine of ``f`` + # to order ``n > 0``. Requires ``f`` to have constant term 0. + + void _fmpq_poly_cosh_series(fmpz * g, fmpz_t gden, const fmpz * f, const fmpz_t fden, long flen, long n) + # Sets ``(g, gden, n)`` to the series expansion of the hyperbolic + # cosine of ``(f, fden, flen)``. Assumes ``n > 0`` and + # that ``(f, fden, flen)`` has constant term 0. + # Does not support aliasing between the input and output polynomials. + + void fmpq_poly_cosh_series(fmpq_poly_t res, const fmpq_poly_t f, long n) + # Sets ``res`` to the series expansion of the hyperbolic cosine of + # ``f`` to order ``n > 0``. Requires ``f`` to have constant term 0. + + void _fmpq_poly_sinh_cosh_series(fmpz * s, fmpz_t sden, fmpz * c, fmpz_t cden, const fmpz * f, const fmpz_t fden, long flen, long n) + # Sets ``(s, sden, n)`` to the series expansion of the hyperbolic + # sine of ``(f, fden, flen)``, and ``(c, cden, n)`` to the series + # expansion of the hyperbolic cosine. Assumes ``n > 0`` and + # that ``(f, fden, flen)`` has constant term 0. + # Supports aliasing between the input and output polynomials. + + void fmpq_poly_sinh_cosh_series(fmpq_poly_t res1, fmpq_poly_t res2, const fmpq_poly_t f, long n) + # Sets ``res1`` to the series expansion of the hyperbolic sine of ``f`` + # to order ``n > 0``, and ``res2`` to the series expansion + # of the hyperbolic cosine. Requires ``f`` to have constant term 0. + + void _fmpq_poly_tanh_series(fmpz * g, fmpz_t gden, const fmpz * f, const fmpz_t fden, long flen, long n) + # Sets ``(g, gden, n)`` to the series expansion of the + # hyperbolic tangent of ``(f, fden, flen)``. Assumes ``n > 0`` and + # that ``(f, fden, flen)`` has constant term 0. + # Does not support aliasing between the input and output polynomials. + + void fmpq_poly_tanh_series(fmpq_poly_t res, const fmpq_poly_t f, long n) + # Sets ``res`` to the series expansion of the hyperbolic tangent of + # ``f`` to order ``n > 0``. Requires ``f`` to have constant term 0. + + void _fmpq_poly_legendre_p(fmpz * coeffs, fmpz_t den, unsigned long n) + # Sets ``coeffs`` to the coefficient array of the Legendre polynomial + # `P_n(x)`, defined by `(n+1) P_{n+1}(x) = (2n+1) x P_n(x) - n P_{n-1}(x)`, + # for `n\ge0`. Sets ``den`` to the overall denominator. + # The coefficients are calculated using a hypergeometric recurrence. + # The length of the array will be ``n+1``. + # To improve performance, the common denominator is computed in one step + # and the coefficients are evaluated using integer arithmetic. The + # denominator is given by + # `\gcd(n!,2^n) = 2^{\lfloor n/2 \rfloor + \lfloor n/4 \rfloor + \ldots}.` + # See ``fmpz_poly`` for the shifted Legendre polynomials. + + void fmpq_poly_legendre_p(fmpq_poly_t poly, unsigned long n) + # Sets ``poly`` to the Legendre polynomial `P_n(x)`, defined + # by `(n+1) P_{n+1}(x) = (2n+1) x P_n(x) - n P_{n-1}(x)`, for `n\ge0`. + # The coefficients are calculated using a hypergeometric recurrence. + # To improve performance, the common denominator is computed in one step + # and the coefficients are evaluated using integer arithmetic. The + # denominator is given by + # `\gcd(n!,2^n) = 2^{\lfloor n/2 \rfloor + \lfloor n/4 \rfloor + \ldots}.` + # See ``fmpz_poly`` for the shifted Legendre polynomials. + + void _fmpq_poly_laguerre_l(fmpz * coeffs, fmpz_t den, unsigned long n) + # Sets ``coeffs`` to the coefficient array of the Laguerre polynomial + # `L_n(x)`, defined by `(n+1) L_{n+1}(x) = (2n+1-x) L_n(x) - n L_{n-1}(x)`, + # for `n\ge0`. Sets ``den`` to the overall denominator. + # The coefficients are calculated using a hypergeometric recurrence. + # The length of the array will be ``n+1``. + + void fmpq_poly_laguerre_l(fmpq_poly_t poly, unsigned long n) + # Sets ``poly`` to the Laguerre polynomial `L_n(x)`, defined by + # `(n+1) L_{n+1}(x) = (2n+1-x) L_n(x) - n L_{n-1}(x)`, for `n\ge0`. + # The coefficients are calculated using a hypergeometric recurrence. + + void _fmpq_poly_gegenbauer_c(fmpz * coeffs, fmpz_t den, unsigned long n, const fmpq_t a) + # Sets ``coeffs`` to the coefficient array of the Gegenbauer + # (ultraspherical) polynomial + # `C^{(\alpha)}_n(x) = \frac{(2\alpha)_n}{n!}{}_2F_1\left(-n,2\alpha+n; + # \alpha+\frac12;\frac{1-x}{2}\right)`, for integer `n\ge0` and rational + # `\alpha>0`. Sets ``den`` to the overall denominator. + # The coefficients are calculated using a hypergeometric recurrence. + + void fmpq_poly_gegenbauer_c(fmpq_poly_t poly, unsigned long n, const fmpq_t a) + # Sets ``poly`` to the Gegenbauer (ultraspherical) polynomial + # `C^{(\alpha)}_n(x) = \frac{(2\alpha)_n}{n!}{}_2F_1\left(-n,2\alpha+n; + # \alpha+\frac12;\frac{1-x}{2}\right)`, for integer `n\ge0` and rational + # `\alpha>0`. + # The coefficients are calculated using a hypergeometric recurrence. + + void _fmpq_poly_evaluate_fmpz(fmpz_t rnum, fmpz_t rden, const fmpz * poly, const fmpz_t den, long len, const fmpz_t a) + # Evaluates the polynomial ``(poly, den, len)`` at the integer `a` and + # sets ``(rnum, rden)`` to the result in lowest terms. + + void fmpq_poly_evaluate_fmpz(fmpq_t res, const fmpq_poly_t poly, const fmpz_t a) + # Evaluates the polynomial ``poly`` at the integer `a` and sets + # ``res`` to the result. + + void _fmpq_poly_evaluate_fmpq(fmpz_t rnum, fmpz_t rden, const fmpz * poly, const fmpz_t den, long len, const fmpz_t anum, const fmpz_t aden) + # Evaluates the polynomial ``(poly, den, len)`` at the rational + # ``(anum, aden)`` and sets ``(rnum, rden)`` to the result in + # lowest terms. Aliasing between ``(rnum, rden)`` and + # ``(anum, aden)`` is not supported. + + void fmpq_poly_evaluate_fmpq(fmpq_t res, const fmpq_poly_t poly, const fmpq_t a) + # Evaluates the polynomial ``poly`` at the rational `a` and + # sets ``res`` to the result. + + void _fmpq_poly_interpolate_fmpz_vec(fmpz * poly, fmpz_t den, const fmpz * xs, const fmpz * ys, long n) + # Sets ``poly`` / ``den`` to the unique interpolating polynomial of + # degree at most `n - 1` satisfying `f(x_i) = y_i` for every pair `x_i, y_i` + # in ``xs`` and ``ys``. + # The vector ``poly`` must have room for ``n+1`` coefficients, + # even if the interpolating polynomial is shorter. + # Aliasing of ``poly`` or ``den`` with any other argument is not + # allowed. + # It is assumed that the `x` values are distinct. + # This function uses a simple `O(n^2)` implementation of Lagrange + # interpolation, clearing denominators to avoid working with fractions. + # It is currently not designed to be efficient for large `n`. + + void fmpq_poly_interpolate_fmpz_vec(fmpq_poly_t poly, const fmpz * xs, const fmpz * ys, long n) + # Sets ``poly`` to the unique interpolating polynomial of degree + # at most `n - 1` satisfying `f(x_i) = y_i` for every pair `x_i, y_i` + # in ``xs`` and ``ys``. It is assumed that the `x` values are distinct. + + void _fmpq_poly_compose(fmpz * res, fmpz_t den, const fmpz * poly1, const fmpz_t den1, long len1, const fmpz * poly2, const fmpz_t den2, long len2) + # Sets ``(res, den)`` to the composition of ``(poly1, den1, len1)`` + # and ``(poly2, den2, len2)``, assuming ``len1, len2 > 0``. + # Assumes that ``res`` has space for ``(len1 - 1) * (len2 - 1) + 1`` + # coefficients. Does not support aliasing. + + void fmpq_poly_compose(fmpq_poly_t res, const fmpq_poly_t poly1, const fmpq_poly_t poly2) + # Sets ``res`` to the composition of ``poly1`` and ``poly2``. + + void _fmpq_poly_rescale(fmpz * res, fmpz_t denr, const fmpz * poly, const fmpz_t den, long len, const fmpz_t anum, const fmpz_t aden) + # Sets ``(res, denr, len)`` to ``(poly, den, len)`` with the + # indeterminate rescaled by ``(anum, aden)``. + # Assumes that ``len > 0`` and that ``(anum, aden)`` is non-zero and + # in lowest terms. Supports aliasing between ``(res, denr, len)`` and + # ``(poly, den, len)``. + + void fmpq_poly_rescale(fmpq_poly_t res, const fmpq_poly_t poly, const fmpq_t a) + # Sets ``res`` to ``poly`` with the indeterminate rescaled by `a`. + + void _fmpq_poly_compose_series_horner(fmpz * res, fmpz_t den, const fmpz * poly1, const fmpz_t den1, long len1, const fmpz * poly2, const fmpz_t den2, long len2, long n) + # Sets ``(res, den, n)`` to the composition of + # ``(poly1, den1, len1)`` and ``(poly2, den2, len2)`` modulo `x^n`, + # where the constant term of ``poly2`` is required to be zero. + # Assumes that ``len1, len2, n > 0``, that ``len1, len2 <= n``, + # that ``(len1-1) * (len2-1) + 1 <= n``, and that ``res`` has + # space for ``n`` coefficients. Does not support aliasing between any + # of the inputs and the output. + # This implementation uses the Horner scheme. + # The default ``fmpz_poly`` composition algorithm is automatically + # used when the composition can be performed over the integers. + + void fmpq_poly_compose_series_horner(fmpq_poly_t res, const fmpq_poly_t poly1, const fmpq_poly_t poly2, long n) + # Sets ``res`` to the composition of ``poly1`` and ``poly2`` + # modulo `x^n`, where the constant term of ``poly2`` is required + # to be zero. + # This implementation uses the Horner scheme. + # The default ``fmpz_poly`` composition algorithm is automatically + # used when the composition can be performed over the integers. + + void _fmpq_poly_compose_series_brent_kung(fmpz * res, fmpz_t den, const fmpz * poly1, const fmpz_t den1, long len1, const fmpz * poly2, const fmpz_t den2, long len2, long n) + # Sets ``(res, den, n)`` to the composition of + # ``(poly1, den1, len1)`` and ``(poly2, den2, len2)`` modulo `x^n`, + # where the constant term of ``poly2`` is required to be zero. + # Assumes that ``len1, len2, n > 0``, that ``len1, len2 <= n``, + # that ``(len1-1) * (len2-1) + 1 <= n``, and that ``res`` has + # space for ``n`` coefficients. Does not support aliasing between any + # of the inputs and the output. + # This implementation uses Brent-Kung algorithm 2.1 [BrentKung1978]_. + # The default ``fmpz_poly`` composition algorithm is automatically + # used when the composition can be performed over the integers. + + void fmpq_poly_compose_series_brent_kung(fmpq_poly_t res, const fmpq_poly_t poly1, const fmpq_poly_t poly2, long n) + # Sets ``res`` to the composition of ``poly1`` and ``poly2`` + # modulo `x^n`, where the constant term of ``poly2`` is required + # to be zero. + # This implementation uses Brent-Kung algorithm 2.1 [BrentKung1978]_. + # The default ``fmpz_poly`` composition algorithm is automatically + # used when the composition can be performed over the integers. + + void _fmpq_poly_compose_series(fmpz * res, fmpz_t den, const fmpz * poly1, const fmpz_t den1, long len1, const fmpz * poly2, const fmpz_t den2, long len2, long n) + # Sets ``(res, den, n)`` to the composition of + # ``(poly1, den1, len1)`` and ``(poly2, den2, len2)`` modulo `x^n`, + # where the constant term of ``poly2`` is required to be zero. + # Assumes that ``len1, len2, n > 0``, that ``len1, len2 <= n``, + # that ``(len1-1) * (len2-1) + 1 <= n``, and that ``res`` has + # space for ``n`` coefficients. Does not support aliasing between any + # of the inputs and the output. + # This implementation automatically switches between the Horner scheme + # and Brent-Kung algorithm 2.1 depending on the size of the inputs. + # The default ``fmpz_poly`` composition algorithm is automatically + # used when the composition can be performed over the integers. + + void fmpq_poly_compose_series(fmpq_poly_t res, const fmpq_poly_t poly1, const fmpq_poly_t poly2, long n) + # Sets ``res`` to the composition of ``poly1`` and ``poly2`` + # modulo `x^n`, where the constant term of ``poly2`` is required + # to be zero. + # This implementation automatically switches between the Horner scheme + # and Brent-Kung algorithm 2.1 depending on the size of the inputs. + # The default ``fmpz_poly`` composition algorithm is automatically + # used when the composition can be performed over the integers. + + void _fmpq_poly_revert_series_lagrange(fmpz * res, fmpz_t den, const fmpz * poly1, const fmpz_t den1, long len1, long n) + # Sets ``(res, den)`` to the power series reversion of + # ``(poly1, den1, len1)`` modulo `x^n`. + # The constant term of ``poly2`` is required to be zero and + # the linear term is required to be nonzero. Assumes that `n > 0`. + # Does not support aliasing between any of the inputs and the output. + # This implementation uses the Lagrange inversion formula. + # The default ``fmpz_poly`` reversion algorithm is automatically + # used when the reversion can be performed over the integers. + + void fmpq_poly_revert_series_lagrange(fmpq_poly_t res, const fmpq_poly_t poly, long n) + # Sets ``res`` to the power series reversion of ``poly1`` modulo `x^n`. + # The constant term of ``poly2`` is required to be zero and + # the linear term is required to be nonzero. + # This implementation uses the Lagrange inversion formula. + # The default ``fmpz_poly`` reversion algorithm is automatically + # used when the reversion can be performed over the integers. + + void _fmpq_poly_revert_series_lagrange_fast(fmpz * res, fmpz_t den, const fmpz * poly1, const fmpz_t den1, long len1, long n) + # Sets ``(res, den)`` to the power series reversion of + # ``(poly1, den1, len1)`` modulo `x^n`. + # The constant term of ``poly2`` is required to be zero and + # the linear term is required to be nonzero. Assumes that `n > 0`. + # Does not support aliasing between any of the inputs and the output. + # This implementation uses a reduced-complexity implementation + # of the Lagrange inversion formula. + # The default ``fmpz_poly`` reversion algorithm is automatically + # used when the reversion can be performed over the integers. + + void fmpq_poly_revert_series_lagrange_fast(fmpq_poly_t res, const fmpq_poly_t poly, long n) + # Sets ``res`` to the power series reversion of ``poly1`` modulo `x^n`. + # The constant term of ``poly2`` is required to be zero and + # the linear term is required to be nonzero. + # This implementation uses a reduced-complexity implementation + # of the Lagrange inversion formula. + # The default ``fmpz_poly`` reversion algorithm is automatically + # used when the reversion can be performed over the integers. + + void _fmpq_poly_revert_series_newton(fmpz * res, fmpz_t den, const fmpz * poly1, const fmpz_t den1, long len1, long n) + # Sets ``(res, den)`` to the power series reversion of + # ``(poly1, den1, len1)`` modulo `x^n`. + # The constant term of ``poly2`` is required to be zero and + # the linear term is required to be nonzero. Assumes that `n > 0`. + # Does not support aliasing between any of the inputs and the output. + # This implementation uses Newton iteration. + # The default ``fmpz_poly`` reversion algorithm is automatically + # used when the reversion can be performed over the integers. + + void fmpq_poly_revert_series_newton(fmpq_poly_t res, const fmpq_poly_t poly, long n) + # Sets ``res`` to the power series reversion of ``poly1`` modulo `x^n`. + # The constant term of ``poly2`` is required to be zero and + # the linear term is required to be nonzero. + # This implementation uses Newton iteration. + # The default ``fmpz_poly`` reversion algorithm is automatically + # used when the reversion can be performed over the integers. + + void _fmpq_poly_revert_series(fmpz * res, fmpz_t den, const fmpz * poly1, const fmpz_t den1, long len1, long n) + # Sets ``(res, den)`` to the power series reversion of + # ``(poly1, den1, len1)`` modulo `x^n`. + # The constant term of ``poly2`` is required to be zero and + # the linear term is required to be nonzero. Assumes that `n > 0`. + # Does not support aliasing between any of the inputs and the output. + # This implementation defaults to using Newton iteration. + # The default ``fmpz_poly`` reversion algorithm is automatically + # used when the reversion can be performed over the integers. + + void fmpq_poly_revert_series(fmpq_poly_t res, const fmpq_poly_t poly, long n) + # Sets ``res`` to the power series reversion of ``poly1`` modulo `x^n`. + # The constant term of ``poly2`` is required to be zero and + # the linear term is required to be nonzero. + # This implementation defaults to using Newton iteration. + # The default ``fmpz_poly`` reversion algorithm is automatically + # used when the reversion can be performed over the integers. + + void _fmpq_poly_content(fmpq_t res, const fmpz * poly, const fmpz_t den, long len) + # Sets ``res`` to the content of ``(poly, den, len)``. + # If ``len == 0``, sets ``res`` to zero. + + void fmpq_poly_content(fmpq_t res, const fmpq_poly_t poly) + # Sets ``res`` to the content of ``poly``. The content of the zero + # polynomial is defined to be zero. + + void _fmpq_poly_primitive_part(fmpz * rpoly, fmpz_t rden, const fmpz * poly, const fmpz_t den, long len) + # Sets ``(rpoly, rden, len)`` to the primitive part, with non-negative + # leading coefficient, of ``(poly, den, len)``. Assumes that + # ``len > 0``. Supports aliasing between the two polynomials. + + void fmpq_poly_primitive_part(fmpq_poly_t res, const fmpq_poly_t poly) + # Sets ``res`` to the primitive part, with non-negative leading + # coefficient, of ``poly``. + + int _fmpq_poly_is_monic(const fmpz * poly, const fmpz_t den, long len) + # Returns whether the polynomial ``(poly, den, len)`` is monic. + # The zero polynomial is not monic by definition. + + int fmpq_poly_is_monic(const fmpq_poly_t poly) + # Returns whether the polynomial ``poly`` is monic. The zero + # polynomial is not monic by definition. + + void _fmpq_poly_make_monic(fmpz * rpoly, fmpz_t rden, const fmpz * poly, const fmpz_t den, long len) + # Sets ``(rpoly, rden, len)`` to the monic scalar multiple of + # ``(poly, den, len)``. Assumes that ``len > 0``. Supports + # aliasing between the two polynomials. + + void fmpq_poly_make_monic(fmpq_poly_t res, const fmpq_poly_t poly) + # Sets ``res`` to the monic scalar multiple of ``poly`` whenever + # ``poly`` is non-zero. If ``poly`` is the zero polynomial, sets + # ``res`` to zero. + + int fmpq_poly_is_squarefree(const fmpq_poly_t poly) + # Returns whether the polynomial ``poly`` is square-free. A non-zero + # polynomial is defined to be square-free if it has no non-unit square + # factors. We also define the zero polynomial to be square-free. + + int _fmpq_poly_print(const fmpz * poly, const fmpz_t den, long len) + # Prints the polynomial ``(poly, den, len)`` to ``stdout``. + # In case of success, returns a positive value. In case of failure, + # returns a non-positive value. + + int fmpq_poly_print(const fmpq_poly_t poly) + # Prints the polynomial to ``stdout``. + # In case of success, returns a positive value. In case of failure, + # returns a non-positive value. + + int _fmpq_poly_print_pretty(const fmpz *poly, const fmpz_t den, long len, const char * x) + + int fmpq_poly_print_pretty(const fmpq_poly_t poly, const char * var) + # Prints the pretty representation of ``poly`` to ``stdout``, using + # the null-terminated string ``var`` not equal to ``"\0"`` as the + # variable name. + # In the current implementation always returns `1`. + + int _fmpq_poly_fprint(FILE * file, const fmpz * poly, const fmpz_t den, long len) + # Prints the polynomial ``(poly, den, len)`` to the stream ``file``. + # In case of success, returns a positive value. In case of failure, + # returns a non-positive value. + + int fmpq_poly_fprint(FILE * file, const fmpq_poly_t poly) + # Prints the polynomial to the stream ``file``. + # In case of success, returns a positive value. In case of failure, + # returns a non-positive value. + + int _fmpq_poly_fprint_pretty(FILE * file, const fmpz *poly, const fmpz_t den, long len, const char * x) + + int fmpq_poly_fprint_pretty(FILE * file, const fmpq_poly_t poly, const char * var) + # Prints the pretty representation of ``poly`` to ``stdout``, using + # the null-terminated string ``var`` not equal to ``"\0"`` as the + # variable name. + # In the current implementation, always returns `1`. + + int fmpq_poly_read(fmpq_poly_t poly) + # Reads a polynomial from ``stdin``, storing the result + # in ``poly``. + # In case of success, returns a positive number. In case of failure, + # returns a non-positive value. + + int fmpq_poly_fread(FILE * file, fmpq_poly_t poly) + # Reads a polynomial from the stream ``file``, storing the result + # in ``poly``. + # In case of success, returns a positive number. In case of failure, + # returns a non-positive value. diff --git a/src/sage/libs/flint/fmpq_poly_macros.pxd b/src/sage/libs/flint/fmpq_poly_macros.pxd new file mode 100644 index 00000000000..41e1a8a4df0 --- /dev/null +++ b/src/sage/libs/flint/fmpq_poly_macros.pxd @@ -0,0 +1,8 @@ +# Macros from fmpz_poly.h +# See https://github.com/flintlib/flint/issues/152 + +from .types cimport * + +cdef extern from "flint_wrap.h": + fmpq_ptr fmpq_poly_get_coeff_ptr(fmpq_poly_t p, ulong n) + # Macro giving a pointer to the n-th coefficient of p (or NULL) diff --git a/src/sage/libs/flint/fmpq_poly_sage.pxd b/src/sage/libs/flint/fmpq_poly_sage.pxd new file mode 100644 index 00000000000..afa16e5bbdd --- /dev/null +++ b/src/sage/libs/flint/fmpq_poly_sage.pxd @@ -0,0 +1,190 @@ +# distutils: libraries = flint +# distutils: depends = flint/fmpq_poly.h + +#***************************************************************************** +# Copyright (C) 2010 Sebastian Pancratz +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 2 of the License, or +# (at your option) any later version. +# http://www.gnu.org/licenses/ +#***************************************************************************** + +from sage.libs.gmp.types cimport mpz_t, mpq_t +from sage.libs.flint.types cimport * +from sage.libs.flint.fmpz_vec cimport _fmpz_vec_max_limbs + +# flint/fmpq_poly.h +cdef extern from "flint_wrap.h": + # Memory management + void fmpq_poly_init(fmpq_poly_t) + + void fmpq_poly_init2(fmpq_poly_t, slong) + void fmpq_poly_realloc(fmpq_poly_t, slong) + + void fmpq_poly_fit_length(fmpq_poly_t, slong) + + void fmpq_poly_clear(fmpq_poly_t) + + void fmpq_poly_canonicalise(fmpq_poly_t) + int fmpq_poly_is_canonical(const fmpq_poly_t) + + void _fmpq_poly_set_length(fmpq_poly_t, slong) + void _fmpq_poly_normalise(fmpq_poly_t) + + # Polynomial parameters + slong fmpq_poly_degree(const fmpq_poly_t) + ulong fmpq_poly_length(const fmpq_poly_t) + + # Accessing the numerator and denominator + fmpz *fmpq_poly_numref(fmpq_poly_t) + fmpz *fmpq_poly_denref(fmpq_poly_t) + + void fmpq_poly_get_numerator(fmpz_poly_t, const fmpq_poly_t) + + # Assignment, swap, negation + void fmpq_poly_set(fmpq_poly_t, const fmpq_poly_t) + void fmpq_poly_set_si(fmpq_poly_t, slong) + void fmpq_poly_set_ui(fmpq_poly_t, ulong) + void fmpq_poly_set_fmpz(fmpq_poly_t, const fmpz_t) + void fmpq_poly_set_fmpq(fmpq_poly_t, const fmpq_t) + void fmpq_poly_set_fmpz_poly(fmpq_poly_t, const fmpz_poly_t) + + void fmpq_poly_set_str(fmpq_poly_t, const char *) + char *fmpq_poly_get_str(const fmpq_poly_t) + char *fmpq_poly_get_str_pretty(const fmpq_poly_t, const char *) + + void fmpq_poly_zero(fmpq_poly_t) + void fmpq_poly_one(fmpq_poly_t) + + void fmpq_poly_neg(fmpq_poly_t, const fmpq_poly_t) + void fmpq_poly_inv(fmpq_poly_t, const fmpq_poly_t) + + void fmpq_poly_swap(fmpq_poly_t, fmpq_poly_t) + void fmpq_poly_truncate(fmpq_poly_t, slong) + void fmpq_poly_get_slice(fmpq_poly_t, const fmpq_poly_t, slong, slong) + void fmpq_poly_reverse(fmpq_poly_t, const fmpq_poly_t, slong) + + void fmpq_poly_get_coeff_fmpq(fmpq_t, const fmpq_poly_t, slong) + void fmpq_poly_get_coeff_si(slong, const fmpq_poly_t, slong) + void fmpq_poly_get_coeff_ui(ulong, const fmpq_poly_t, slong) + + void fmpq_poly_set_coeff_si(fmpq_poly_t, slong, slong) + void fmpq_poly_set_coeff_ui(fmpq_poly_t, slong, ulong) + void fmpq_poly_set_coeff_fmpz(fmpq_poly_t, slong, const fmpz_t) + void fmpq_poly_set_coeff_fmpq(fmpq_poly_t, slong, const fmpq_t) + + # Comparison + int fmpq_poly_equal(const fmpq_poly_t, const fmpq_poly_t) + int fmpq_poly_cmp(const fmpq_poly_t, const fmpq_poly_t) + int fmpq_poly_is_one(const fmpq_poly_t) + int fmpq_poly_is_zero(const fmpq_poly_t) + + # Addition and subtraction + void fmpq_poly_add(fmpq_poly_t, const fmpq_poly_t, const fmpq_poly_t) + void fmpq_poly_sub(fmpq_poly_t, const fmpq_poly_t, const fmpq_poly_t) + + void fmpq_poly_add_can( + fmpq_poly_t, const fmpq_poly_t, const fmpq_poly_t, int) + void fmpq_poly_sub_can( + fmpq_poly_t, const fmpq_poly_t, const fmpq_poly_t, int) + + # Scalar multiplication and division + void fmpq_poly_scalar_mul_si(fmpq_poly_t, const fmpq_poly_t, slong) + void fmpq_poly_scalar_mul_ui(fmpq_poly_t, const fmpq_poly_t, ulong) + void fmpq_poly_scalar_mul_fmpz( + fmpq_poly_t, const fmpq_poly_t, const fmpz_t) + void fmpq_poly_scalar_mul_fmpq( + fmpq_poly_t, const fmpq_poly_t, const fmpq_t) + + void fmpq_poly_scalar_div_si(fmpq_poly_t, const fmpq_poly_t, slong) + void fmpq_poly_scalar_div_ui(fmpq_poly_t, const fmpq_poly_t, ulong) + void fmpq_poly_scalar_div_fmpz( + fmpq_poly_t, const fmpq_poly_t, const fmpz_t) + void fmpq_poly_scalar_div_fmpq( + fmpq_poly_t, const fmpq_poly_t, const fmpq_t) + + # Multiplication + void fmpq_poly_mul(fmpq_poly_t, const fmpq_poly_t, const fmpq_poly_t) + void fmpq_poly_mullow(fmpq_poly_t, const fmpq_poly_t, const fmpq_poly_t, slong) + + void fmpq_poly_addmul(fmpq_poly_t, const fmpq_poly_t, const fmpq_poly_t) + void fmpq_poly_submul(fmpq_poly_t, const fmpq_poly_t, const fmpq_poly_t) + + # Powering + void fmpq_poly_pow(fmpq_poly_t, const fmpq_poly_t, ulong) + + # Shifting + void fmpq_poly_shift_left(fmpq_poly_t, const fmpq_poly_t, slong) + void fmpq_poly_shift_right(fmpq_poly_t, const fmpq_poly_t, slong) + + # Euclidean division + void fmpq_poly_divrem( + fmpq_poly_t, fmpq_poly_t, const fmpq_poly_t, const fmpq_poly_t) + void fmpq_poly_div(fmpq_poly_t, const fmpq_poly_t, const fmpq_poly_t) + void fmpq_poly_rem(fmpq_poly_t, const fmpq_poly_t, const fmpq_poly_t) + + # Greatest common divisor + void fmpq_poly_gcd(fmpq_poly_t, const fmpq_poly_t, const fmpq_poly_t) + void fmpq_poly_xgcd( + fmpq_poly_t, fmpq_poly_t, fmpq_poly_t, + const fmpq_poly_t, const fmpq_poly_t) + + void fmpq_poly_lcm(fmpq_poly_t, const fmpq_poly_t, const fmpq_poly_t) + + void fmpq_poly_resultant(fmpq_t, const fmpq_poly_t, const fmpq_poly_t) + + # Power series division + void fmpq_poly_inv_series_newton(fmpq_poly_t, const fmpq_poly_t, slong) + void fmpq_poly_inv_series(fmpq_poly_t, const fmpq_poly_t, slong) + void fmpq_poly_div_series( + fmpq_poly_t, const fmpq_poly_t, const fmpq_poly_t, slong) + + # Derivative and integral + void fmpq_poly_derivative(fmpq_poly_t, const fmpq_poly_t) + void fmpq_poly_integral(fmpq_poly_t, const fmpq_poly_t) + + # Evaluation + void fmpq_poly_evaluate_fmpz(fmpq_t, const fmpq_poly_t, const fmpz_t) + void fmpq_poly_evaluate_fmpq(fmpq_t, const fmpq_poly_t, const fmpq_t) + + # Composition + void fmpq_poly_compose(fmpq_poly_t, const fmpq_poly_t, const fmpq_poly_t) + void fmpq_poly_rescale(fmpq_poly_t, const fmpq_poly_t, const fmpq_t) + + # Revert + void fmpq_poly_revert_series(fmpq_poly_t, fmpq_poly_t, unsigned long) + + # Gaussian content + void fmpq_poly_content(fmpq_t, const fmpq_poly_t) + void fmpq_poly_primitive_part(fmpq_poly_t, const fmpq_poly_t) + + int fmpq_poly_is_monic(const fmpq_poly_t) + void fmpq_poly_make_monic(fmpq_poly_t, const fmpq_poly_t) + + # Transcendental functions + void fmpq_poly_log_series(fmpq_poly_t, const fmpq_poly_t, slong) + void fmpq_poly_exp_series(fmpq_poly_t, const fmpq_poly_t, slong) + void fmpq_poly_atan_series(fmpq_poly_t, const fmpq_poly_t, slong) + void fmpq_poly_atanh_series(fmpq_poly_t, const fmpq_poly_t, slong) + void fmpq_poly_asin_series(fmpq_poly_t, const fmpq_poly_t, slong) + void fmpq_poly_asinh_series(fmpq_poly_t, const fmpq_poly_t, slong) + void fmpq_poly_tan_series(fmpq_poly_t, const fmpq_poly_t, slong) + void fmpq_poly_sin_series(fmpq_poly_t, const fmpq_poly_t, slong) + void fmpq_poly_cos_series(fmpq_poly_t, const fmpq_poly_t, slong) + void fmpq_poly_sinh_series(fmpq_poly_t, const fmpq_poly_t, slong) + void fmpq_poly_cosh_series(fmpq_poly_t, const fmpq_poly_t, slong) + void fmpq_poly_tanh_series(fmpq_poly_t, const fmpq_poly_t, slong) + +# since the fmpq_poly header seems to be lacking this inline function +cdef inline sage_fmpq_poly_max_limbs(const fmpq_poly_t poly) noexcept: + return _fmpz_vec_max_limbs(fmpq_poly_numref(poly), fmpq_poly_length(poly)) + +# functions removed from flint but still needed in sage +cdef void fmpq_poly_scalar_mul_mpz(fmpq_poly_t, const fmpq_poly_t, const mpz_t) +cdef void fmpq_poly_scalar_mul_mpq(fmpq_poly_t, const fmpq_poly_t, const mpq_t) +cdef void fmpq_poly_set_coeff_mpq(fmpq_poly_t, slong, const mpq_t) +cdef void fmpq_poly_get_coeff_mpq(mpq_t, const fmpq_poly_t, slong) +cdef void fmpq_poly_set_mpz(fmpq_poly_t, const mpz_t) +cdef void fmpq_poly_set_mpq(fmpq_poly_t, const mpq_t) diff --git a/src/sage/libs/flint/fmpq_poly.pyx b/src/sage/libs/flint/fmpq_poly_sage.pyx similarity index 100% rename from src/sage/libs/flint/fmpq_poly.pyx rename to src/sage/libs/flint/fmpq_poly_sage.pyx diff --git a/src/sage/libs/flint/fmpz_lll.pxd b/src/sage/libs/flint/fmpz_lll.pxd new file mode 100644 index 00000000000..13d98e60c4e --- /dev/null +++ b/src/sage/libs/flint/fmpz_lll.pxd @@ -0,0 +1,246 @@ +# distutils: libraries = flint +# distutils: depends = flint/fmpz_lll.h + +################################################################################ +# This file is auto-generated. Do not modify by hand +################################################################################ + +from libc.stdio cimport FILE +from sage.libs.gmp.types cimport * +from sage.libs.mpfr.types cimport * +from sage.libs.flint.types cimport * + +cdef extern from "flint_wrap.h": + + void fmpz_lll_context_init_default(fmpz_lll_t fl) + # Sets ``fl->delta``, ``fl->eta``, ``fl->rt`` and ``fl->gt`` to + # their default values, 0.99, 0.51, `Z\_BASIS` and `APPROX` respectively. + + void fmpz_lll_context_init(fmpz_lll_t fl, double delta, double eta, rep_type rt, gram_type gt) + # Sets ``fl->delta``, ``fl->eta``, ``fl->rt`` and ``fl->gt`` to + # ``delta``, ``eta``, ``rt`` and ``gt`` (given as input) + # respectively. ``delta`` and ``eta`` are the L^2 parameters. + # ``delta`` and ``eta`` must lie in the intervals `(0.25, 1)` and + # `(0.5, \sqrt{\mathtt{delta}})` respectively. The representation type is input + # using ``rt`` and can have the values `Z\_BASIS` for a lattice basis and + # `GRAM` for a Gram matrix. The Gram type to be used during computation can + # be specified using ``gt`` which can assume the values `APPROX` and + # `EXACT`. Note that ``gt`` has meaning only when ``rt`` is `Z\_BASIS`. + + void fmpz_lll_randtest(fmpz_lll_t fl, flint_rand_t state) + # Sets ``fl->delta`` and ``fl->eta`` to random values in the interval + # `(0.25, 1)` and `(0.5, \sqrt{\mathtt{delta}})` respectively. ``fl->rt`` is + # set to `GRAM` or `Z\_BASIS` and ``fl->gt`` is set to `APPROX` or `EXACT` + # in a pseudo random way. + + double fmpz_lll_heuristic_dot(const double * vec1, const double * vec2, long len2, const fmpz_mat_t B, long k, long j, long exp_adj) + # Computes the dot product of two vectors of doubles ``vec1`` and + # ``vec2``, which are respectively ``double`` approximations (up to + # scaling by a power of 2) to rows ``k`` and ``j`` in the exact integer + # matrix ``B``. If massive cancellation is detected an exact computation + # is made. + # The exact computation is scaled by `2^{-\mathtt{exp_adj}}`, where + # ``exp_adj = r2 + r1`` where `r2` is the exponent for row ``j`` and + # `r1` is the exponent for row ``k`` (i.e. row ``j`` is notionally + # thought of as being multiplied by `2^{r2}`, etc.). + # The final dot product computed by this function is then notionally the + # return value times `2^{\mathtt{exp_adj}}`. + + int fmpz_lll_check_babai(int kappa, fmpz_mat_t B, fmpz_mat_t U, d_mat_t mu, d_mat_t r, double *s, d_mat_t appB, int *expo, fmpz_gram_t A, int a, int zeros, int kappamax, int n, const fmpz_lll_t fl) + # Performs floating point size reductions of the ``kappa``-th row of + # ``B`` by all of the previous rows, uses d_mats ``mu`` and ``r`` + # for storing the GSO data. ``U`` is used to capture the unimodular + # transformations if it is not `NULL`. The ``double`` array ``s`` will + # contain the size of the ``kappa``-th row if it were moved into position + # `i`. The d_mat ``appB`` is an approximation of ``B`` with each row + # receiving an exponent stored in ``expo`` which gets populated only when + # needed. The d_mat ``A->appSP`` is an approximation of the Gram matrix + # whose entries are scalar products of the rows of ``B`` and is used when + # ``fl->gt`` == `APPROX`. When ``fl->gt`` == `EXACT` the fmpz_mat + # ``A->exactSP`` (the exact Gram matrix) is used. The index ``a`` is + # the smallest row index which will be reduced from the ``kappa``-th row. + # Index ``zeros`` is the number of zero rows in the matrix. + # ``kappamax`` is the highest index which has been size-reduced so far, + # and ``n`` is the number of columns you want to consider. ``fl`` is an + # LLL (L^2) context object. The output is the value -1 if the process fails + # (usually due to insufficient precision) or 0 if everything was successful. + # These descriptions will be true for the future Babai procedures as well. + + int fmpz_lll_check_babai_heuristic_d(int kappa, fmpz_mat_t B, fmpz_mat_t U, d_mat_t mu, d_mat_t r, double *s, d_mat_t appB, int *expo, fmpz_gram_t A, int a, int zeros, int kappamax, int n, const fmpz_lll_t fl) + # Same as :func:`fmpz_lll_check_babai` but using the heuristic inner product + # rather than a purely floating point inner product. The heuristic will + # compute at full precision when there is cancellation. + + int fmpz_lll_check_babai_heuristic(int kappa, fmpz_mat_t B, fmpz_mat_t U, mpf_mat_t mu, mpf_mat_t r, mpf *s, mpf_mat_t appB, fmpz_gram_t A, int a, int zeros, int kappamax, int n, mpf_t tmp, mpf_t rtmp, flint_bitcnt_t prec, const fmpz_lll_t fl) + # This function is like the ``mpf`` version of + # :func:`fmpz_lll_check_babai_heuristic_d`. However, it also inherits some + # temporary ``mpf_t`` variables ``tmp`` and ``rtmp``. + + int fmpz_lll_advance_check_babai(int cur_kappa, int kappa, fmpz_mat_t B, fmpz_mat_t U, d_mat_t mu, d_mat_t r, double *s, d_mat_t appB, int *expo, fmpz_gram_t A, int a, int zeros, int kappamax, int n, const fmpz_lll_t fl) + # This is a Babai procedure which is used when size reducing a vector beyond + # an index which LLL has reached. ``cur_kappa`` is the index behind which + # we can assume ``B`` is LLL reduced, while ``kappa`` is the vector to + # be reduced. This procedure only size reduces the ``kappa``-th row by + # vectors up to ``cur_kappa``, **not** ``kappa - 1``. + + int fmpz_lll_advance_check_babai_heuristic_d(int cur_kappa, int kappa, fmpz_mat_t B, fmpz_mat_t U, d_mat_t mu, d_mat_t r, double *s, d_mat_t appB, int *expo, fmpz_gram_t A, int a, int zeros, int kappamax, int n, const fmpz_lll_t fl) + # Same as :func:`fmpz_lll_advance_check_babai` but using the heuristic inner + # product rather than a purely floating point inner product. The heuristic + # will compute at full precision when there is cancellation. + + int fmpz_lll_shift(const fmpz_mat_t B) + # Computes the largest number of non-zero entries after the diagonal in + # ``B``. + + int fmpz_lll_d(fmpz_mat_t B, fmpz_mat_t U, const fmpz_lll_t fl) + # This is a mildly greedy version of floating point LLL using doubles only. + # It tries the fast version of the Babai algorithm + # (:func:`fmpz_lll_check_babai`). If that fails, then it switches to the + # heuristic version (:func:`fmpz_lll_check_babai_heuristic_d`) for only one + # loop and switches right back to the fast version. It reduces ``B`` in + # place. ``U`` is the matrix used to capture the unimodular + # transformations if it is not `NULL`. An exception is raised if `U` != `NULL` + # and ``U->r`` != `d`, where `d` is the lattice dimension. ``fl`` is the + # context object containing information containing the LLL parameters \delta + # and \eta. The function can perform reduction on both the lattice basis as + # well as its Gram matrix. The type of lattice representation can be + # specified via the parameter ``fl->rt``. The type of Gram matrix to be + # used in computation (approximate or exact) can also be specified through + # the variable ``fl->gt`` (applies only if ``fl->rt`` == `Z\_BASIS`). + + int fmpz_lll_d_heuristic(fmpz_mat_t B, fmpz_mat_t U, const fmpz_lll_t fl) + # This LLL reduces ``B`` in place using doubles only. It is similar to + # :func:`fmpz_lll_d` but only uses the heuristic inner products which + # attempt to detect cancellations. + + int fmpz_lll_mpf2(fmpz_mat_t B, fmpz_mat_t U, flint_bitcnt_t prec, const fmpz_lll_t fl) + # This is LLL using ``mpf`` with the given precision, ``prec`` for the + # underlying GSO. It reduces ``B`` in place like the other LLL functions. + # The `mpf2` in the function name refers to the way the ``mpf_t``'s are + # initialised. + + int fmpz_lll_mpf(fmpz_mat_t B, fmpz_mat_t U, const fmpz_lll_t fl) + # A wrapper of :func:`fmpz_lll_mpf2`. This currently begins with + # `prec == D\_BITS`, then for the first 20 loops, increases the precision one + # limb at a time. After 20 loops, it doubles the precision each time. There + # is a proof that this will eventually work. The return value of this + # function is 0 if the LLL is successful or -1 if the precision maxes out + # before ``B`` is LLL-reduced. + + int fmpz_lll_wrapper(fmpz_mat_t B, fmpz_mat_t U, const fmpz_lll_t fl) + # A wrapper of the above procedures. It begins with the greediest version + # (:func:`fmpz_lll_d`), then adapts to the version using heuristic inner + # products only (:func:`fmpz_lll_d_heuristic`) if ``fl->rt`` == `Z\_BASIS` and + # ``fl->gt`` == `APPROX`, and finally to the mpf version (:func:`fmpz_lll_mpf`) + # if needed. + # ``U`` is the matrix used to capture the unimodular + # transformations if it is not `NULL`. An exception is raised if `U` != `NULL` + # and ``U->r`` != `d`, where `d` is the lattice dimension. ``fl`` is the + # context object containing information containing the LLL parameters \delta + # and \eta. The function can perform reduction on both the lattice basis as + # well as its Gram matrix. The type of lattice representation can be + # specified via the parameter ``fl->rt``. The type of Gram matrix to be + # used in computation (approximate or exact) can also be specified through + # the variable ``fl->gt`` (applies only if ``fl->rt`` == `Z\_BASIS`). + + int fmpz_lll_d_with_removal(fmpz_mat_t B, fmpz_mat_t U, const fmpz_t gs_B, const fmpz_lll_t fl) + # Same as :func:`fmpz_lll_d` but with a removal bound, ``gs_B``. The + # return value is the new dimension of ``B`` if removals are desired. + + int fmpz_lll_d_heuristic_with_removal(fmpz_mat_t B, fmpz_mat_t U, const fmpz_t gs_B, const fmpz_lll_t fl) + # Same as :func:`fmpz_lll_d_heuristic` but with a removal bound, + # ``gs_B``. The return value is the new dimension of ``B`` if removals + # are desired. + + int fmpz_lll_mpf2_with_removal(fmpz_mat_t B, fmpz_mat_t U, flint_bitcnt_t prec, const fmpz_t gs_B, const fmpz_lll_t fl) + # Same as :func:`fmpz_lll_mpf2` but with a removal bound, ``gs_B``. The + # return value is the new dimension of ``B`` if removals are desired. + + int fmpz_lll_mpf_with_removal(fmpz_mat_t B, fmpz_mat_t U, const fmpz_t gs_B, const fmpz_lll_t fl) + # A wrapper of :func:`fmpz_lll_mpf2_with_removal`. This currently begins + # with `prec == D\_BITS`, then for the first 20 loops, increases the precision + # one limb at a time. After 20 loops, it doubles the precision each time. + # There is a proof that this will eventually work. The return value of this + # function is the new dimension of ``B`` if removals are desired or -1 if + # the precision maxes out before ``B`` is LLL-reduced. + + int fmpz_lll_wrapper_with_removal(fmpz_mat_t B, fmpz_mat_t U, const fmpz_t gs_B, const fmpz_lll_t fl) + # A wrapper of the procedures implementing the base case LLL with the + # addition of the removal boundary. It begins with the greediest version + # (:func:`fmpz_lll_d_with_removal`), then adapts to the version using + # heuristic inner products only (:func:`fmpz_lll_d_heuristic_with_removal`) + # if ``fl->rt`` == `Z\_BASIS` and ``fl->gt`` == `APPROX`, and finally to the mpf + # version (:func:`fmpz_lll_mpf_with_removal`) if needed. + + int fmpz_lll_d_with_removal_knapsack(fmpz_mat_t B, fmpz_mat_t U, const fmpz_t gs_B, const fmpz_lll_t fl) + # This is floating point LLL specialized to knapsack-type lattices. It + # performs early size reductions occasionally which makes things faster in + # the knapsack case. Otherwise, it is similar to + # ``fmpz_lll_d_with_removal``. + + int fmpz_lll_wrapper_with_removal_knapsack(fmpz_mat_t B, fmpz_mat_t U, const fmpz_t gs_B, const fmpz_lll_t fl) + # A wrapper of the procedures implementing the LLL specialized to + # knapsack-type lattices. It begins with the greediest version and the engine + # of this version, (:func:`fmpz_lll_d_with_removal_knapsack`), then adapts + # to the version using heuristic inner products only + # (:func:`fmpz_lll_d_heuristic_with_removal`) if ``fl->rt`` == `Z\_BASIS` and + # ``fl->gt`` == `APPROX`, and finally to the mpf version + # (:func:`fmpz_lll_mpf_with_removal`) if needed. + + int fmpz_lll_with_removal_ulll(fmpz_mat_t FM, fmpz_mat_t UM, long new_size, const fmpz_t gs_B, const fmpz_lll_t fl) + # ULLL is a new style of LLL which adjoins an identity matrix to the + # input lattice ``FM``, then scales the lattice down to ``new_size`` + # bits and reduces this augmented lattice. This tends to be more stable + # numerically than traditional LLL which means higher dimensions can be + # attacked using doubles. In each iteration a new identity matrix is adjoined + # to the truncated lattice. ``UM`` is used to capture the unimodular + # transformations, while ``gs_B`` and ``fl`` have the same role as in + # the previous routines. The function is optimised for factoring polynomials. + + int fmpz_lll_is_reduced_d(const fmpz_mat_t B, const fmpz_lll_t fl) + int fmpz_lll_is_reduced_mpfr(const fmpz_mat_t B, const fmpz_lll_t fl, flint_bitcnt_t prec) + int fmpz_lll_is_reduced_d_with_removal(const fmpz_mat_t B, const fmpz_lll_t fl, const fmpz_t gs_B, int newd) + int fmpz_lll_is_reduced_mpfr_with_removal(const fmpz_mat_t B, const fmpz_lll_t fl, const fmpz_t gs_B, int newd, flint_bitcnt_t prec) + # A non-zero return indicates the matrix is definitely reduced, that is, that + # * :func:`fmpz_mat_is_reduced` or :func:`fmpz_mat_is_reduced_gram` (for the first two) + # * :func:`fmpz_mat_is_reduced_with_removal` or :func:`fmpz_mat_is_reduced_gram_with_removal` (for the last two) + # return non-zero. A zero return value is inconclusive. + # The `_d` variants are performed in machine precision, while the `_mpfr` uses a precision of `prec` bits. + + int fmpz_lll_is_reduced(const fmpz_mat_t B, const fmpz_lll_t fl, flint_bitcnt_t prec) + int fmpz_lll_is_reduced_with_removal(const fmpz_mat_t B, const fmpz_lll_t fl, const fmpz_t gs_B, int newd, flint_bitcnt_t prec) + # The return from these functions is always conclusive: the functions + # * :func:`fmpz_mat_is_reduced` or :func:`fmpz_mat_is_reduced_gram` + # * :func:`fmpz_mat_is_reduced_with_removal` or :func:`fmpz_mat_is_reduced_gram_with_removal` + # are optimzied by calling the above heuristics first and returning right away if they give a conclusive answer. + + void fmpz_lll_storjohann_ulll(fmpz_mat_t FM, long new_size, const fmpz_lll_t fl) + # Performs ULLL using :func:`fmpz_mat_lll_storjohann` as the LLL function. + + void fmpz_lll(fmpz_mat_t B, fmpz_mat_t U, const fmpz_lll_t fl) + # Reduces ``B`` in place according to the parameters specified by the + # LLL context object ``fl``. + # This is the main LLL function which should be called by the user. It + # currently calls the ULLL algorithm (without removals). The ULLL function + # in turn calls a LLL wrapper which tries to choose an optimal LLL algorithm, + # starting with a version using just doubles (ULLL tries to maximise usage + # of this), then a heuristic LLL followed by a full precision floating point + # LLL if required. + # ``U`` is the matrix used to capture the unimodular + # transformations if it is not `NULL`. An exception is raised if `U` != `NULL` + # and ``U->r`` != `d`, where `d` is the lattice dimension. ``fl`` is the + # context object containing information containing the LLL parameters \delta + # and \eta. The function can perform reduction on both the lattice basis as + # well as its Gram matrix. The type of lattice representation can be + # specified via the parameter ``fl->rt``. The type of Gram matrix to be + # used in computation (approximate or exact) can also be specified through + # the variable ``fl->gt`` (applies only if ``fl->rt`` == `Z\_BASIS`). + + int fmpz_lll_with_removal(fmpz_mat_t B, fmpz_mat_t U, const fmpz_t gs_B, const fmpz_lll_t fl) + # Reduces ``B`` in place according to the parameters specified by the + # LLL context object ``fl`` and removes vectors whose squared Gram-Schmidt + # length is greater than the bound ``gs_B``. The return value is the new + # dimension of ``B`` to be considered for further computation. + # This is the main LLL with removals function which should be called by + # the user. Like ``fmpz_lll`` it calls ULLL, but it also sets the + # Gram-Schmidt bound to that supplied and does removals. diff --git a/src/sage/libs/flint/fmpz_mat.pxd b/src/sage/libs/flint/fmpz_mat.pxd index 1aa6bac6b9d..f5ba596ac8f 100644 --- a/src/sage/libs/flint/fmpz_mat.pxd +++ b/src/sage/libs/flint/fmpz_mat.pxd @@ -985,3 +985,5 @@ cdef extern from "flint_wrap.h": # See "Faster Algorithms for Integer Lattice Basis Reduction." Technical # Report 249. Zurich, Switzerland: Department Informatik, ETH. July 30, # 1996. + +from .fmpz_mat_macros cimport * diff --git a/src/sage/libs/flint/fmpz_mat_macros.pxd b/src/sage/libs/flint/fmpz_mat_macros.pxd new file mode 100644 index 00000000000..316117c3b4c --- /dev/null +++ b/src/sage/libs/flint/fmpz_mat_macros.pxd @@ -0,0 +1,14 @@ +# Macros from fmpz_mat.h +# See https://github.com/flintlib/flint/issues/152 + +from .types cimport * + +cdef extern from "flint_wrap.h": + fmpz * fmpz_mat_entry(fmpz_mat_t mat, slong i, slong j) + # Macro giving a pointer to the entry at row *i* and column *j*. + + slong fmpz_mat_nrows(fmpz_mat_t) + # Returns the number of rows of the matrix. + + slong fmpz_mat_ncols(fmpz_mat_t) + # Returns the number of columns of the matrix. diff --git a/src/sage/libs/flint/fmpz_mod_mat.pxd b/src/sage/libs/flint/fmpz_mod_mat.pxd new file mode 100644 index 00000000000..5c2e009b5c0 --- /dev/null +++ b/src/sage/libs/flint/fmpz_mod_mat.pxd @@ -0,0 +1,252 @@ +# distutils: libraries = flint +# distutils: depends = flint/fmpz_mod_mat.h + +################################################################################ +# This file is auto-generated. Do not modify by hand +################################################################################ + +from libc.stdio cimport FILE +from sage.libs.gmp.types cimport * +from sage.libs.mpfr.types cimport * +from sage.libs.flint.types cimport * + +cdef extern from "flint_wrap.h": + + fmpz * fmpz_mod_mat_entry(const fmpz_mod_mat_t mat, long i, long j) + # Return a reference to the element at row ``i`` and column ``j`` of ``mat``. + + void fmpz_mod_mat_set_entry(fmpz_mod_mat_t mat, long i, long j, const fmpz_t val) + # Set the entry at row ``i`` and column ``j`` of ``mat`` to ``val``. + + void fmpz_mod_mat_init(fmpz_mod_mat_t mat, long rows, long cols, const fmpz_t n) + # Initialise ``mat`` as a matrix with the given number of ``rows`` and + # ``cols`` and modulus ``n``. + + void fmpz_mod_mat_init_set(fmpz_mod_mat_t mat, const fmpz_mod_mat_t src) + # Initialise ``mat`` and set it equal to the matrix ``src``, including the + # number of rows and columns and the modulus. + + void fmpz_mod_mat_clear(fmpz_mod_mat_t mat) + # Clear ``mat`` and release any memory it used. + + long fmpz_mod_mat_nrows(const fmpz_mod_mat_t mat) + + long fmpz_mod_mat_ncols(const fmpz_mod_mat_t mat) + # Return the number of columns of ``mat``. + + void _fmpz_mod_mat_set_mod(fmpz_mod_mat_t mat, const fmpz_t n) + # Set the modulus of the matrix ``mat`` to ``n``. + + void fmpz_mod_mat_one(fmpz_mod_mat_t mat) + # Set ``mat`` to the identity matrix (ones down the diagonal). + + void fmpz_mod_mat_zero(fmpz_mod_mat_t mat) + # Set ``mat`` to the zero matrix. + + void fmpz_mod_mat_swap(fmpz_mod_mat_t mat1, fmpz_mod_mat_t mat2) + # Efficiently swap the matrices ``mat1`` and ``mat2``. + + void fmpz_mod_mat_swap_entrywise(fmpz_mod_mat_t mat1, fmpz_mod_mat_t mat2) + # Swaps two matrices by swapping the individual entries rather than swapping + # the contents of the structs. + + int fmpz_mod_mat_is_empty(const fmpz_mod_mat_t mat) + # Return `1` if ``mat`` has either zero rows or columns. + + int fmpz_mod_mat_is_square(const fmpz_mod_mat_t mat) + # Return `1` if ``mat`` has the same number of rows and columns. + + void _fmpz_mod_mat_reduce(fmpz_mod_mat_t mat) + # Reduce all the entries of ``mat`` by the modulus ``n``. This function is + # only needed internally. + + void fmpz_mod_mat_randtest(fmpz_mod_mat_t mat, flint_rand_t state) + # Generate a random matrix with the existing dimensions and entries in + # `[0, n)` where ``n`` is the modulus. + + void fmpz_mod_mat_window_init(fmpz_mod_mat_t window, const fmpz_mod_mat_t mat, long r1, long c1, long r2, long c2) + # Initializes the matrix ``window`` to be an ``r2 - r1`` by + # ``c2 - c1`` submatrix of ``mat`` whose ``(0, 0)`` entry + # is the ``(r1, c1)`` entry of ``mat``. The memory for the + # elements of ``window`` is shared with ``mat``. + + void fmpz_mod_mat_window_clear(fmpz_mod_mat_t window) + # Clears the matrix ``window`` and releases any memory that it + # uses. Note that the memory to the underlying matrix that + # ``window`` points to is not freed. + + void fmpz_mod_mat_concat_horizontal(fmpz_mod_mat_t res, const fmpz_mod_mat_t mat1, const fmpz_mod_mat_t mat2) + # Sets ``res`` to vertical concatenation of (``mat1``, ``mat2``) in that order. Matrix dimensions : ``mat1`` : `m \times n`, ``mat2`` : `k \times n`, ``res`` : `(m + k) \times n`. + + void fmpz_mod_mat_concat_vertical(fmpz_mod_mat_t res, const fmpz_mod_mat_t mat1, const fmpz_mod_mat_t mat2) + # Sets ``res`` to horizontal concatenation of (``mat1``, ``mat2``) + # in that order. Matrix dimensions : ``mat1`` : `m \times n`, + # ``mat2`` : `m \times k`, ``res`` : `m \times (n + k)`. + + void fmpz_mod_mat_print_pretty(const fmpz_mod_mat_t mat) + # Prints the given matrix to ``stdout``. The format is an + # opening square bracket then on each line a row of the matrix, followed + # by a closing square bracket. Each row is written as an opening square + # bracket followed by a space separated list of coefficients followed + # by a closing square bracket. + + int fmpz_mod_mat_is_zero(const fmpz_mod_mat_t mat) + # Return `1` if ``mat`` is the zero matrix. + + void fmpz_mod_mat_set(fmpz_mod_mat_t B, const fmpz_mod_mat_t A) + # Set ``B`` to equal ``A``. + + void fmpz_mod_mat_transpose(fmpz_mod_mat_t B, const fmpz_mod_mat_t A) + # Set ``B`` to the transpose of ``A``. + + void fmpz_mod_mat_set_fmpz_mat(fmpz_mod_mat_t A, const fmpz_mat_t B) + # Set ``A`` to the matrix ``B`` reducing modulo the modulus of ``A``. + + void fmpz_mod_mat_get_fmpz_mat(fmpz_mat_t A, const fmpz_mod_mat_t B) + # Set ``A`` to a lift of ``B``. + + void fmpz_mod_mat_add(fmpz_mod_mat_t C, const fmpz_mod_mat_t A, const fmpz_mod_mat_t B) + # Set ``C`` to `A + B`. + + void fmpz_mod_mat_sub(fmpz_mod_mat_t C, const fmpz_mod_mat_t A, const fmpz_mod_mat_t B) + # Set ``C`` to `A - B`. + + void fmpz_mod_mat_neg(fmpz_mod_mat_t B, const fmpz_mod_mat_t A) + # Set ``B`` to `-A`. + + void fmpz_mod_mat_scalar_mul_si(fmpz_mod_mat_t B, const fmpz_mod_mat_t A, long c) + # Set ``B`` to `cA` where ``c`` is a constant. + + void fmpz_mod_mat_scalar_mul_ui(fmpz_mod_mat_t B, const fmpz_mod_mat_t A, unsigned long c) + # Set ``B`` to `cA` where ``c`` is a constant. + + void fmpz_mod_mat_scalar_mul_fmpz(fmpz_mod_mat_t B, const fmpz_mod_mat_t A, fmpz_t c) + # Set ``B`` to `cA` where ``c`` is a constant. + + void fmpz_mod_mat_mul(fmpz_mod_mat_t C, const fmpz_mod_mat_t A, const fmpz_mod_mat_t B) + # Set ``C`` to ``A\times B``. The number of rows of ``B`` must match the + # number of columns of ``A``. + + void _fmpz_mod_mat_mul_classical_threaded_pool_op(fmpz_mod_mat_t D, const fmpz_mod_mat_t C, const fmpz_mod_mat_t A, const fmpz_mod_mat_t B, int op, thread_pool_handle * threads, long num_threads) + # Set ``D`` to ``A\times B + op*C`` where ``op`` is ``+1``, ``-1`` or ``0``. + + void _fmpz_mod_mat_mul_classical_threaded_op(fmpz_mod_mat_t D, const fmpz_mod_mat_t C, const fmpz_mod_mat_t A, const fmpz_mod_mat_t B, int op) + # Set ``D`` to ``A\times B + op*C`` where ``op`` is ``+1``, ``-1`` or ``0``. + + void fmpz_mod_mat_mul_classical_threaded(fmpz_mod_mat_t C, const fmpz_mod_mat_t A, const fmpz_mod_mat_t B) + # Set ``C`` to ``A\times B``. The number of rows of ``B`` must match the + # number of columns of ``A``. + + void fmpz_mod_mat_sqr(fmpz_mod_mat_t B, const fmpz_mod_mat_t A) + # Set ``B`` to ``A^2``. The matrix ``A`` must be square. + + void fmpz_mod_mat_mul_fmpz_vec(fmpz * c, const fmpz_mod_mat_t A, const fmpz * b, long blen) + void fmpz_mod_mat_mul_fmpz_vec_ptr(fmpz * const * c, const fmpz_mod_mat_t A, const fmpz * const * b, long blen) + # Compute a matrix-vector product of ``A`` and ``(b, blen)`` and store the result in ``c``. + # The vector ``(b, blen)`` is either truncated or zero-extended to the number of columns of ``A``. + # The number entries written to ``c`` is always equal to the number of rows of ``A``. + + void fmpz_mod_mat_fmpz_vec_mul(fmpz * c, const fmpz * a, long alen, const fmpz_mod_mat_t B) + void fmpz_mod_mat_fmpz_vec_mul_ptr(fmpz * const * c, const fmpz * const * a, long alen, const fmpz_mod_mat_t B) + # Compute a vector-matrix product of ``(a, alen)`` and ``B`` and and store the result in ``c``. + # The vector ``(a, alen)`` is either truncated or zero-extended to the number of rows of ``B``. + # The number entries written to ``c`` is always equal to the number of columns of ``B``. + + void fmpz_mod_mat_trace(fmpz_t trace, const fmpz_mod_mat_t mat) + # Set ``trace`` to the trace of the matrix ``mat``. + + long fmpz_mod_mat_rref(long * perm, fmpz_mod_mat_t mat) + # Uses Gauss-Jordan elimination to set ``mat`` to its reduced row echelon + # form and returns the rank of ``mat``. + # If ``perm`` is non-``NULL``, the permutation of + # rows in the matrix will also be applied to ``perm``. + # The modulus is assumed to be prime. + + void fmpz_mod_mat_strong_echelon_form(fmpz_mod_mat_t mat) + # Transforms `mat` into the strong echelon form of `mat`. The Howell form and the + # strong echelon form are equal up to permutation of the rows, see + # [FieHof2014]_ for a definition of the strong echelon form and the + # algorithm used here. + # `mat` must have at least as many rows as columns. + + long fmpz_mod_mat_howell_form(fmpz_mod_mat_t mat) + # Transforms `mat` into the Howell form of `mat`. For a definition of the + # Howell form see [StoMul1998]_. The Howell form is computed by first + # putting `mat` into strong echelon form and then ordering the rows. + # `mat` must have at least as many rows as columns. + + int fmpz_mod_mat_inv(fmpz_mod_mat_t B, fmpz_mod_mat_t A) + # Sets `B = A^{-1}` and returns `1` if `A` is invertible. If `A` is singular, + # returns `0` and sets the elements of `B` to undefined values. + # `A` and `B` must be square matrices with the same dimensions. + # The modulus is assumed to be prime. + + long fmpz_mod_mat_lu(long * P, fmpz_mod_mat_t A, int rank_check) + # Computes a generalised LU decomposition `LU = PA` of a given + # matrix `A`, returning the rank of `A`. + # If `A` is a nonsingular square matrix, it will be overwritten with + # a unit diagonal lower triangular matrix `L` and an upper + # triangular matrix `U` (the diagonal of `L` will not be stored + # explicitly). + # If `A` is an arbitrary matrix of rank `r`, `U` will be in row + # echelon form having `r` nonzero rows, and `L` will be lower + # triangular but truncated to `r` columns, having implicit ones on + # the `r` first entries of the main diagonal. All other entries will + # be zero. + # If a nonzero value for ``rank_check`` is passed, the function + # will abandon the output matrix in an undefined state and return 0 + # if `A` is detected to be rank-deficient. + # The modulus is assumed to be prime. + + void fmpz_mod_mat_solve_tril(fmpz_mod_mat_t X, const fmpz_mod_mat_t L, const fmpz_mod_mat_t B, int unit) + # Sets `X = L^{-1} B` where `L` is a full rank lower triangular + # square matrix. If ``unit`` = 1, `L` is assumed to have ones on + # its main diagonal, and the main diagonal will not be read. `X` + # and `B` are allowed to be the same matrix, but no other aliasing + # is allowed. Automatically chooses between the classical and + # recursive algorithms. + # The modulus is assumed to be prime. + + void fmpz_mod_mat_solve_triu(fmpz_mod_mat_t X, const fmpz_mod_mat_t U, const fmpz_mod_mat_t B, int unit) + # Sets `X = U^{-1} B` where `U` is a full rank upper triangular + # square matrix. If ``unit`` = 1, `U` is assumed to have ones on + # its main diagonal, and the main diagonal will not be read. `X` + # and `B` are allowed to be the same matrix, but no other aliasing + # is allowed. Automatically chooses between the classical and + # recursive algorithms. + # The modulus is assumed to be prime. + + int fmpz_mod_mat_solve(fmpz_mod_mat_t X, const fmpz_mod_mat_t A, const fmpz_mod_mat_t B) + # Solves the matrix-matrix equation `AX = B`. + # Returns `1` if `A` has full rank; otherwise returns `0` and sets the + # elements of `X` to undefined values. + # The matrix `A` must be square. + # The modulus is assumed to be prime. + + int fmpz_mod_mat_can_solve(fmpz_mod_mat_t X, const fmpz_mod_mat_t A, const fmpz_mod_mat_t B) + # Solves the matrix-matrix equation `AX = B` over `Fp`. + # Returns `1` if a solution exists; otherwise returns `0` and sets the + # elements of `X` to zero. If more than one solution exists, one of the + # valid solutions is given. + # There are no restrictions on the shape of `A` and it may be singular. + # The modulus is assumed to be prime. + + void fmpz_mod_mat_similarity(fmpz_mod_mat_t M, long r, fmpz_t d) + # Applies a similarity transform to the `n\times n` matrix `M` in-place. + # If `P` is the `n\times n` identity matrix the zero entries of whose row + # `r` (`0`-indexed) have been replaced by `d`, this transform is equivalent + # to `M = P^{-1}MP`. + # Similarity transforms preserve the determinant, characteristic polynomial + # and minimal polynomial. + # The value `d` is required to be reduced modulo the modulus of the entries + # in the matrix. + # The modulus is assumed to be prime. + + void fmpz_mod_mat_charpoly(fmpz_mod_poly_t p, const fmpz_mod_mat_t M, const fmpz_mod_ctx_t ctx) + # Compute the characteristic polynomial `p` of the matrix `M`. The matrix + # is required to be square, otherwise an exception is raised. + + void fmpz_mod_mat_minpoly(fmpz_mod_poly_t p, const fmpz_mod_mat_t M, const fmpz_mod_ctx_t ctx) + # Compute the minimal polynomial `p` of the matrix `M`. The matrix + # is required to be square, otherwise an exception is raised. + # The modulus is assumed to be prime. diff --git a/src/sage/libs/flint/fmpz_mod_mpoly.pxd b/src/sage/libs/flint/fmpz_mod_mpoly.pxd new file mode 100644 index 00000000000..38a4f66f107 --- /dev/null +++ b/src/sage/libs/flint/fmpz_mod_mpoly.pxd @@ -0,0 +1,416 @@ +# distutils: libraries = flint +# distutils: depends = flint/fmpz_mod_mpoly.h + +################################################################################ +# This file is auto-generated. Do not modify by hand +################################################################################ + +from libc.stdio cimport FILE +from sage.libs.gmp.types cimport * +from sage.libs.mpfr.types cimport * +from sage.libs.flint.types cimport * + +cdef extern from "flint_wrap.h": + + void fmpz_mod_mpoly_ctx_init(fmpz_mod_mpoly_ctx_t ctx, long nvars, const ordering_t ord, const fmpz_t p) + # Initialise a context object for a polynomial ring modulo *n* with *nvars* variables and ordering *ord*. + # The possibilities for the ordering are ``ORD_LEX``, ``ORD_DEGLEX`` and ``ORD_DEGREVLEX``. + + long fmpz_mod_mpoly_ctx_nvars(const fmpz_mod_mpoly_ctx_t ctx) + # Return the number of variables used to initialize the context. + + ordering_t fmpz_mod_mpoly_ctx_ord(const fmpz_mod_mpoly_ctx_t ctx) + # Return the ordering used to initialize the context. + + void fmpz_mod_mpoly_ctx_get_modulus(fmpz_t n, const fmpz_mod_mpoly_ctx_t ctx) + # Set *n* to the modulus used to initialize the context. + + void fmpz_mod_mpoly_ctx_clear(fmpz_mod_mpoly_ctx_t ctx) + # Release up any space allocated by an *ctx*. + + void fmpz_mod_mpoly_init(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_ctx_t ctx) + # Initialise *A* for use with the given an initialised context object. Its value is set to zero. + + void fmpz_mod_mpoly_init2(fmpz_mod_mpoly_t A, long alloc, const fmpz_mod_mpoly_ctx_t ctx) + # Initialise *A* for use with the given an initialised context object. Its value is set to zero. + # It is allocated with space for *alloc* terms and at least ``MPOLY_MIN_BITS`` bits for the exponents. + + void fmpz_mod_mpoly_init3(fmpz_mod_mpoly_t A, long alloc, flint_bitcnt_t bits, const fmpz_mod_mpoly_ctx_t ctx) + # Initialise *A* for use with the given an initialised context object. Its value is set to zero. + # It is allocated with space for *alloc* terms and *bits* bits for the exponents. + + void fmpz_mod_mpoly_clear(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_ctx_t ctx) + # Release any space allocated for *A*. + + char * fmpz_mod_mpoly_get_str_pretty(const fmpz_mod_mpoly_t A, const char ** x, const fmpz_mod_mpoly_ctx_t ctx) + # Return a string, which the user is responsible for cleaning up, representing *A*, given an array of variable strings *x*. + + int fmpz_mod_mpoly_fprint_pretty(FILE * file, const fmpz_mod_mpoly_t A, const char ** x, const fmpz_mod_mpoly_ctx_t ctx) + # Print a string representing *A* to *file*. + + int fmpz_mod_mpoly_print_pretty(const fmpz_mod_mpoly_t A, const char ** x, const fmpz_mod_mpoly_ctx_t ctx) + # Print a string representing *A* to ``stdout``. + + int fmpz_mod_mpoly_set_str_pretty(fmpz_mod_mpoly_t A, const char * str, const char ** x, const fmpz_mod_mpoly_ctx_t ctx) + # Set *A* to the polynomial in the null-terminates string *str* given an array *x* of variable strings. + # If parsing *str* fails, *A* is set to zero, and `-1` is returned. Otherwise, `0` is returned. + # The operations ``+``, ``-``, ``*``, and ``/`` are permitted along with integers and the variables in *x*. The character ``^`` must be immediately followed by the (integer) exponent. + # If any division is not exact, parsing fails. + + void fmpz_mod_mpoly_gen(fmpz_mod_mpoly_t A, long var, const fmpz_mod_mpoly_ctx_t ctx) + # Set *A* to the variable of index *var*, where `var = 0` corresponds to the variable with the most significance with respect to the ordering. + + int fmpz_mod_mpoly_is_gen(const fmpz_mod_mpoly_t A, long var, const fmpz_mod_mpoly_ctx_t ctx) + # If `var \ge 0`, return `1` if *A* is equal to the `var`-th generator, otherwise return `0`. + # If `var < 0`, return `1` if the polynomial is equal to any generator, otherwise return `0`. + + void fmpz_mod_mpoly_set(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, const fmpz_mod_mpoly_ctx_t ctx) + # Set *A* to *B*. + + int fmpz_mod_mpoly_equal(const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, const fmpz_mod_mpoly_ctx_t ctx) + # Return `1` if *A* is equal to *B*, else return `0`. + + void fmpz_mod_mpoly_swap(fmpz_mod_mpoly_t poly1, fmpz_mod_mpoly_t poly2, const fmpz_mod_mpoly_ctx_t ctx) + # Efficiently swap *A* and *B*. + + int fmpz_mod_mpoly_is_fmpz(const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_ctx_t ctx) + # Return `1` if *A* is a constant, else return `0`. + + void fmpz_mod_mpoly_get_fmpz(fmpz_t c, const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_ctx_t ctx) + # Assuming that *A* is a constant, set *c* to this constant. + # This function throws if *A* is not a constant. + + void fmpz_mod_mpoly_set_fmpz(fmpz_mod_mpoly_t A, const fmpz_t c, const fmpz_mod_mpoly_ctx_t ctx) + void fmpz_mod_mpoly_set_ui(fmpz_mod_mpoly_t A, unsigned long c, const fmpz_mod_mpoly_ctx_t ctx) + void fmpz_mod_mpoly_set_si(fmpz_mod_mpoly_t A, long c, const fmpz_mod_mpoly_ctx_t ctx) + # Set *A* to the constant *c*. + + void fmpz_mod_mpoly_zero(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_ctx_t ctx) + # Set *A* to the constant `0`. + + void fmpz_mod_mpoly_one(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_ctx_t ctx) + # Set *A* to the constant `1`. + + int fmpz_mod_mpoly_equal_fmpz(const fmpz_mod_mpoly_t A, const fmpz_t c, const fmpz_mod_mpoly_ctx_t ctx) + int fmpz_mod_mpoly_equal_ui(const fmpz_mod_mpoly_t A, unsigned long c, const fmpz_mod_mpoly_ctx_t ctx) + int fmpz_mod_mpoly_equal_si(const fmpz_mod_mpoly_t A, long c, const fmpz_mod_mpoly_ctx_t ctx) + # Return `1` if *A* is equal to the constant *c*, else return `0`. + + int fmpz_mod_mpoly_is_zero(const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_ctx_t ctx) + # Return `1` if *A* is the constant `0`, else return `0`. + + int fmpz_mod_mpoly_is_one(const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_ctx_t ctx) + # Return `1` if *A* is the constant `1`, else return `0`. + + int fmpz_mod_mpoly_degrees_fit_si(const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_ctx_t ctx) + # Return `1` if the degrees of *A* with respect to each variable fit into an ``slong``, otherwise return `0`. + + void fmpz_mod_mpoly_degrees_fmpz(fmpz ** degs, const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_ctx_t ctx) + void fmpz_mod_mpoly_degrees_si(long * degs, const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_ctx_t ctx) + # Set *degs* to the degrees of *A* with respect to each variable. + # If *A* is zero, all degrees are set to `-1`. + + void fmpz_mod_mpoly_degree_fmpz(fmpz_t deg, const fmpz_mod_mpoly_t A, long var, const fmpz_mod_mpoly_ctx_t ctx) + long fmpz_mod_mpoly_degree_si(const fmpz_mod_mpoly_t A, long var, const fmpz_mod_mpoly_ctx_t ctx) + # Either return or set *deg* to the degree of *A* with respect to the variable of index *var*. + # If *A* is zero, the degree is defined to be `-1`. + + int fmpz_mod_mpoly_total_degree_fits_si(const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_ctx_t ctx) + # Return `1` if the total degree of *A* fits into an ``slong``, otherwise return `0`. + + void fmpz_mod_mpoly_total_degree_fmpz(fmpz_t tdeg, const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_ctx_t ctx) + long fmpz_mod_mpoly_total_degree_si(const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_ctx_t ctx) + # Either return or set *tdeg* to the total degree of *A*. + # If *A* is zero, the total degree is defined to be `-1`. + + void fmpz_mod_mpoly_used_vars(int * used, const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_ctx_t ctx) + # For each variable index *i*, set ``used[i]`` to nonzero if the variable of index *i* appears in *A* and to zero otherwise. + + void fmpz_mod_mpoly_get_coeff_fmpz_monomial(fmpz_t c, const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t M, const fmpz_mod_mpoly_ctx_t ctx) + # Assuming that *M* is a monomial, set *c* to the coefficient of the corresponding monomial in *A*. + # This function throws if *M* is not a monomial. + + void fmpz_mod_mpoly_set_coeff_fmpz_monomial(fmpz_mod_mpoly_t A, const fmpz_t c, const fmpz_mod_mpoly_t M, const fmpz_mod_mpoly_ctx_t ctx) + # Assuming that *M* is a monomial, set the coefficient of the corresponding monomial in *A* to *c*. + # This function throws if *M* is not a monomial. + + void fmpz_mod_mpoly_get_coeff_fmpz_fmpz(fmpz_t c, const fmpz_mod_mpoly_t A, fmpz * const * exp, const fmpz_mod_mpoly_ctx_t ctx) + void fmpz_mod_mpoly_get_coeff_fmpz_ui(fmpz_t c, const fmpz_mod_mpoly_t A, const unsigned long * exp, const fmpz_mod_mpoly_ctx_t ctx) + # Set *c* to the coefficient of the monomial with exponent vector *exp*. + + void fmpz_mod_mpoly_set_coeff_fmpz_fmpz(fmpz_mod_mpoly_t A, const fmpz_t c, fmpz * const * exp, const fmpz_mod_mpoly_ctx_t ctx) + void fmpz_mod_mpoly_set_coeff_ui_fmpz(fmpz_mod_mpoly_t A, unsigned long c, fmpz * const * exp, const fmpz_mod_mpoly_ctx_t ctx) + void fmpz_mod_mpoly_set_coeff_si_fmpz(fmpz_mod_mpoly_t A, long c, fmpz * const * exp, const fmpz_mod_mpoly_ctx_t ctx) + void fmpz_mod_mpoly_set_coeff_fmpz_ui(fmpz_mod_mpoly_t A, const fmpz_t c, const unsigned long * exp, const fmpz_mod_mpoly_ctx_t ctx) + void fmpz_mod_mpoly_set_coeff_ui_ui(fmpz_mod_mpoly_t A, unsigned long c, const unsigned long * exp, const fmpz_mod_mpoly_ctx_t ctx) + void fmpz_mod_mpoly_set_coeff_si_ui(fmpz_mod_mpoly_t A, long c, const unsigned long * exp, const fmpz_mod_mpoly_ctx_t ctx) + # Set the coefficient of the monomial with exponent vector *exp* to *c*. + + void fmpz_mod_mpoly_get_coeff_vars_ui(fmpz_mod_mpoly_t C, const fmpz_mod_mpoly_t A, const long * vars, const unsigned long * exps, long length, const fmpz_mod_mpoly_ctx_t ctx) + # Set *C* to the coefficient of *A* with respect to the variables in *vars* with powers in the corresponding array *exps*. + # Both *vars* and *exps* point to array of length *length*. It is assumed that `0 < length \le nvars(A)` and that the variables in *vars* are distinct. + + int fmpz_mod_mpoly_cmp(const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, const fmpz_mod_mpoly_ctx_t ctx) + # Return `1` (resp. `-1`, or `0`) if *A* is after (resp. before, same as) *B* in some arbitrary but fixed total ordering of the polynomials. + # This ordering agrees with the usual ordering of monomials when *A* and *B* are both monomials. + + int fmpz_mod_mpoly_is_canonical(const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_ctx_t ctx) + # Return `1` if *A* is in canonical form. Otherwise, return `0`. + # To be in canonical form, all of the terms must have nonzero coefficient, and the terms must be sorted from greatest to least. + + long fmpz_mod_mpoly_length(const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_ctx_t ctx) + # Return the number of terms in *A*. + # If the polynomial is in canonical form, this will be the number of nonzero coefficients. + + void fmpz_mod_mpoly_resize(fmpz_mod_mpoly_t A, long new_length, const fmpz_mod_mpoly_ctx_t ctx) + # Set the length of *A* to ``new_length``. + # Terms are either deleted from the end, or new zero terms are appended. + + void fmpz_mod_mpoly_get_term_coeff_fmpz(fmpz_t c, const fmpz_mod_mpoly_t A, long i, const fmpz_mod_mpoly_ctx_t ctx) + # Set *c* to the coefficient of the term of index *i*. + + void fmpz_mod_mpoly_set_term_coeff_fmpz(fmpz_mod_mpoly_t A, long i, const fmpz_t c, const fmpz_mod_mpoly_ctx_t ctx) + void fmpz_mod_mpoly_set_term_coeff_ui(fmpz_mod_mpoly_t A, long i, unsigned long c, const fmpz_mod_mpoly_ctx_t ctx) + void fmpz_mod_mpoly_set_term_coeff_si(fmpz_mod_mpoly_t A, long i, long c, const fmpz_mod_mpoly_ctx_t ctx) + # Set the coefficient of the term of index *i* to *c*. + + int fmpz_mod_mpoly_term_exp_fits_si(const fmpz_mod_mpoly_t poly, long i, const fmpz_mod_mpoly_ctx_t ctx) + int fmpz_mod_mpoly_term_exp_fits_ui(const fmpz_mod_mpoly_t poly, long i, const fmpz_mod_mpoly_ctx_t ctx) + # Return `1` if all entries of the exponent vector of the term of index *i* fit into an ``slong`` (resp. a ``ulong``). Otherwise, return `0`. + + void fmpz_mod_mpoly_get_term_exp_fmpz(fmpz ** exp, const fmpz_mod_mpoly_t A, long i, const fmpz_mod_mpoly_ctx_t ctx) + void fmpz_mod_mpoly_get_term_exp_ui(unsigned long * exp, const fmpz_mod_mpoly_t A, long i, const fmpz_mod_mpoly_ctx_t ctx) + void fmpz_mod_mpoly_get_term_exp_si(long * exp, const fmpz_mod_mpoly_t A, long i, const fmpz_mod_mpoly_ctx_t ctx) + # Set *exp* to the exponent vector of the term of index *i*. + # The ``_ui`` (resp. ``_si``) version throws if any entry does not fit into a ``ulong`` (resp. ``slong``). + + unsigned long fmpz_mod_mpoly_get_term_var_exp_ui(const fmpz_mod_mpoly_t A, long i, long var, const fmpz_mod_mpoly_ctx_t ctx) + long fmpz_mod_mpoly_get_term_var_exp_si(const fmpz_mod_mpoly_t A, long i, long var, const fmpz_mod_mpoly_ctx_t ctx) + # Return the exponent of the variable *var* of the term of index *i*. + # This function throws if the exponent does not fit into a ``ulong`` (resp. ``slong``). + + void fmpz_mod_mpoly_set_term_exp_fmpz(fmpz_mod_mpoly_t A, long i, fmpz * const * exp, const fmpz_mod_mpoly_ctx_t ctx) + void fmpz_mod_mpoly_set_term_exp_ui(fmpz_mod_mpoly_t A, long i, const unsigned long * exp, const fmpz_mod_mpoly_ctx_t ctx) + # Set the exponent vector of the term of index *i* to *exp*. + + void fmpz_mod_mpoly_get_term(fmpz_mod_mpoly_t M, const fmpz_mod_mpoly_t A, long i, const fmpz_mod_mpoly_ctx_t ctx) + # Set *M* to the term of index *i* in *A*. + + void fmpz_mod_mpoly_get_term_monomial(fmpz_mod_mpoly_t M, const fmpz_mod_mpoly_t A, long i, const fmpz_mod_mpoly_ctx_t ctx) + # Set *M* to the monomial of the term of index *i* in *A*. The coefficient of *M* will be one. + + void fmpz_mod_mpoly_push_term_fmpz_fmpz(fmpz_mod_mpoly_t A, const fmpz_t c, fmpz * const * exp, const fmpz_mod_mpoly_ctx_t ctx) + void fmpz_mod_mpoly_push_term_fmpz_ffmpz(fmpz_mod_mpoly_t A, const fmpz_t c, const fmpz * exp, const fmpz_mod_mpoly_ctx_t ctx) + void fmpz_mod_mpoly_push_term_ui_fmpz(fmpz_mod_mpoly_t A, unsigned long c, fmpz * const * exp, const fmpz_mod_mpoly_ctx_t ctx) + void fmpz_mod_mpoly_push_term_ui_ffmpz(fmpz_mod_mpoly_t A, unsigned long c, const fmpz * exp, const fmpz_mod_mpoly_ctx_t ctx) + void fmpz_mod_mpoly_push_term_si_fmpz(fmpz_mod_mpoly_t A, long c, fmpz * const * exp, const fmpz_mod_mpoly_ctx_t ctx) + void fmpz_mod_mpoly_push_term_si_ffmpz(fmpz_mod_mpoly_t A, long c, const fmpz * exp, const fmpz_mod_mpoly_ctx_t ctx) + void fmpz_mod_mpoly_push_term_fmpz_ui(fmpz_mod_mpoly_t A, const fmpz_t c, const unsigned long * exp, const fmpz_mod_mpoly_ctx_t ctx) + void fmpz_mod_mpoly_push_term_ui_ui(fmpz_mod_mpoly_t A, unsigned long c, const unsigned long * exp, const fmpz_mod_mpoly_ctx_t ctx) + void fmpz_mod_mpoly_push_term_si_ui(fmpz_mod_mpoly_t A, long c, const unsigned long * exp, const fmpz_mod_mpoly_ctx_t ctx) + # Append a term to *A* with coefficient *c* and exponent vector *exp*. + # This function runs in constant average time. + + void fmpz_mod_mpoly_sort_terms(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_ctx_t ctx) + # Sort the terms of *A* into the canonical ordering dictated by the ordering in *ctx*. + # This function simply reorders the terms: It does not combine like terms, nor does it delete terms with coefficient zero. + # This function runs in linear time in the size of *A*. + + void fmpz_mod_mpoly_combine_like_terms(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_ctx_t ctx) + # Combine adjacent like terms in *A* and delete terms with coefficient zero. + # If the terms of *A* were sorted to begin with, the result will be in canonical form. + # This function runs in linear time in the size of *A*. + + void fmpz_mod_mpoly_reverse(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, const fmpz_mod_mpoly_ctx_t ctx) + # Set *A* to the reversal of *B*. + + void fmpz_mod_mpoly_randtest_bound(fmpz_mod_mpoly_t A, flint_rand_t state, long length, unsigned long exp_bound, const fmpz_mod_mpoly_ctx_t ctx) + # Generate a random polynomial with length up to *length* and exponents in the range ``[0, exp_bound - 1]``. + # The exponents of each variable are generated by calls to ``n_randint(state, exp_bound)``. + + void fmpz_mod_mpoly_randtest_bounds(fmpz_mod_mpoly_t A, flint_rand_t state, long length, unsigned long * exp_bounds, const fmpz_mod_mpoly_ctx_t ctx) + # Generate a random polynomial with length up to *length* and exponents in the range ``[0, exp_bounds[i] - 1]``. + # The exponents of the variable of index *i* are generated by calls to ``n_randint(state, exp_bounds[i])``. + + void fmpz_mod_mpoly_randtest_bits(fmpz_mod_mpoly_t A, flint_rand_t state, long length, mp_limb_t exp_bits, const fmpz_mod_mpoly_ctx_t ctx) + # Generate a random polynomial with length up to *length* and exponents whose packed form does not exceed the given bit count. + + void fmpz_mod_mpoly_add_fmpz(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, const fmpz_t c, const fmpz_mod_mpoly_ctx_t ctx) + void fmpz_mod_mpoly_add_ui(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, unsigned long c, const fmpz_mod_mpoly_ctx_t ctx) + void fmpz_mod_mpoly_add_si(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, long c, const fmpz_mod_mpoly_ctx_t ctx) + # Set *A* to `B + c`. + + void fmpz_mod_mpoly_sub_fmpz(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, const fmpz_t c, const fmpz_mod_mpoly_ctx_t ctx) + void fmpz_mod_mpoly_sub_ui(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, unsigned long c, const fmpz_mod_mpoly_ctx_t ctx) + void fmpz_mod_mpoly_sub_si(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, long c, const fmpz_mod_mpoly_ctx_t ctx) + # Set *A* to `B - c`. + + void fmpz_mod_mpoly_add(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, const fmpz_mod_mpoly_t C, const fmpz_mod_mpoly_ctx_t ctx) + # Set *A* to `B + C`. + + void fmpz_mod_mpoly_sub(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, const fmpz_mod_mpoly_t C, const fmpz_mod_mpoly_ctx_t ctx) + # Set *A* to `B - C`. + + void fmpz_mod_mpoly_neg(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, const fmpz_mod_mpoly_ctx_t ctx) + # Set *A* to `-B`. + + void fmpz_mod_mpoly_scalar_mul_fmpz(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, const fmpz_t c, const fmpz_mod_mpoly_ctx_t ctx) + void fmpz_mod_mpoly_scalar_mul_ui(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, unsigned long c, const fmpz_mod_mpoly_ctx_t ctx) + void fmpz_mod_mpoly_scalar_mul_si(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, long c, const fmpz_mod_mpoly_ctx_t ctx) + # Set *A* to `B \times c`. + + void fmpz_mod_mpoly_scalar_addmul_fmpz(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, const fmpz_mod_mpoly_t C, const fmpz_t d, const fmpz_mod_mpoly_ctx_t ctx) + # Sets *A* to `B + C \times d`. + + void fmpz_mod_mpoly_make_monic(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, const fmpz_mod_mpoly_ctx_t ctx) + # Set *A* to *B* divided by the leading coefficient of *B*. This throws if *B* is zero or the leading coefficient is not invertible. + + void fmpz_mod_mpoly_derivative(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, long var, const fmpz_mod_mpoly_ctx_t ctx) + # Set *A* to the derivative of *B* with respect to the variable of index *var*. + + void fmpz_mod_mpoly_evaluate_all_fmpz(fmpz_t eval, const fmpz_mod_mpoly_t A, fmpz * const * vals, const fmpz_mod_mpoly_ctx_t ctx) + # Set *ev* to the evaluation of *A* where the variables are replaced by the corresponding elements of the array *vals*. + + void fmpz_mod_mpoly_evaluate_one_fmpz(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, long var, const fmpz_t val, const fmpz_mod_mpoly_ctx_t ctx) + # Set *A* to the evaluation of *B* where the variable of index *var* is replaced by *val*. + # Return `1` for success and `0` for failure. + + int fmpz_mod_mpoly_compose_fmpz_poly(fmpz_poly_t A, const fmpz_mod_mpoly_t B, fmpz_poly_struct * const * C, const fmpz_mod_mpoly_ctx_t ctxB) + # Set *A* to the evaluation of *B* where the variables are replaced by the corresponding elements of the array *C*. + # The context object of *B* is *ctxB*. + # Return `1` for success and `0` for failure. + + int fmpz_mod_mpoly_compose_fmpz_mod_mpoly_geobucket(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, fmpz_mod_mpoly_struct * const * C, const fmpz_mod_mpoly_ctx_t ctxB, const fmpz_mod_mpoly_ctx_t ctxAC) + int fmpz_mod_mpoly_compose_fmpz_mod_mpoly(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, fmpz_mod_mpoly_struct * const * C, const fmpz_mod_mpoly_ctx_t ctxB, const fmpz_mod_mpoly_ctx_t ctxAC) + # Set *A* to the evaluation of *B* where the variables are replaced by the corresponding elements of the array *C*. + # Both *A* and the elements of *C* have context object *ctxAC*, while *B* has context object *ctxB*. + # The length of the array *C* is the number of variables in *ctxB*. + # Neither *A* nor *B* is allowed to alias any other polynomial. + # Return `1` for success and `0` for failure. + # The main method attempts to perform the calculation using matrices and chooses heuristically between the ``geobucket`` and ``horner`` methods if needed. + + void fmpz_mod_mpoly_compose_fmpz_mod_mpoly_gen(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, const long * c, const fmpz_mod_mpoly_ctx_t ctxB, const fmpz_mod_mpoly_ctx_t ctxAC) + # Set *A* to the evaluation of *B* where the variable of index *i* in *ctxB* is replaced by the variable of index ``c[i]`` in *ctxAC*. + # The length of the array *C* is the number of variables in *ctxB*. + # If any ``c[i]`` is negative, the corresponding variable of *B* is replaced by zero. Otherwise, it is expected that ``c[i]`` is less than the number of variables in *ctxAC*. + + void fmpz_mod_mpoly_mul(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, const fmpz_mod_mpoly_t C, const fmpz_mod_mpoly_ctx_t ctx) + # Set *A* to `B \times C`. + + void fmpz_mod_mpoly_mul_johnson(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, const fmpz_mod_mpoly_t C, const fmpz_mod_mpoly_ctx_t ctx) + # Set *A* to `B \times C` using Johnson's heap-based method. + + int fmpz_mod_mpoly_mul_dense(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, const fmpz_mod_mpoly_t C, const fmpz_mod_mpoly_ctx_t ctx) + # Try to set *A* to `B \times C` using dense arithmetic. + # If the return is `0`, the operation was unsuccessful. Otherwise, it was successful and the return is `1`. + + int fmpz_mod_mpoly_pow_fmpz(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, const fmpz_t k, const fmpz_mod_mpoly_ctx_t ctx) + # Set *A* to *B* raised to the `k`-th power. + # Return `1` for success and `0` for failure. + + int fmpz_mod_mpoly_pow_ui(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, unsigned long k, const fmpz_mod_mpoly_ctx_t ctx) + # Set *A* to *B* raised to the `k`-th power. + # Return `1` for success and `0` for failure. + + int fmpz_mod_mpoly_divides(fmpz_mod_mpoly_t Q, const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, const fmpz_mod_mpoly_ctx_t ctx) + # If *A* is divisible by *B*, set *Q* to the exact quotient and return `1`. Otherwise, set *Q* to zero and return `0`. + + void fmpz_mod_mpoly_div(fmpz_mod_mpoly_t Q, const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, const fmpz_mod_mpoly_ctx_t ctx) + # Set *Q* to the quotient of *A* by *B*, discarding the remainder. + + void fmpz_mod_mpoly_divrem(fmpz_mod_mpoly_t Q, fmpz_mod_mpoly_t R, const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, const fmpz_mod_mpoly_ctx_t ctx) + # Set *Q* and *R* to the quotient and remainder of *A* divided by *B*. + + void fmpz_mod_mpoly_divrem_ideal(fmpz_mod_mpoly_struct ** Q, fmpz_mod_mpoly_t R, const fmpz_mod_mpoly_t A, fmpz_mod_mpoly_struct * const * B, long len, const fmpz_mod_mpoly_ctx_t ctx) + # This function is as per :func:`fmpz_mod_mpoly_divrem` except that it takes an array of divisor polynomials *B* and it returns an array of quotient polynomials *Q*. + # The number of divisor (and hence quotient) polynomials, is given by *len*. + + void fmpz_mod_mpoly_term_content(fmpz_mod_mpoly_t M, const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_ctx_t ctx) + # Set *M* to the GCD of the terms of *A*. + # If *A* is zero, *M* will be zero. Otherwise, *M* will be a monomial with coefficient one. + + int fmpz_mod_mpoly_content_vars(fmpz_mod_mpoly_t g, const fmpz_mod_mpoly_t A, long * vars, long vars_length, const fmpz_mod_mpoly_ctx_t ctx) + # Set *g* to the GCD of the coefficients of *A* when viewed as a polynomial in the variables *vars*. + # Return `1` for success and `0` for failure. Upon success, *g* will be independent of the variables *vars*. + + int fmpz_mod_mpoly_gcd(fmpz_mod_mpoly_t G, const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, const fmpz_mod_mpoly_ctx_t ctx) + # Try to set *G* to the monic GCD of *A* and *B*. The GCD of zero and zero is defined to be zero. + # If the return is `1` the function was successful. Otherwise the return is `0` and *G* is left untouched. + + int fmpz_mod_mpoly_gcd_cofactors(fmpz_mod_mpoly_t G, fmpz_mod_mpoly_t Abar, fmpz_mod_mpoly_t Bbar, const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, const fmpz_mod_mpoly_ctx_t ctx) + # Do the operation of :func:`fmpz_mod_mpoly_gcd` and also compute `Abar = A/G` and `Bbar = B/G` if successful. + + int fmpz_mod_mpoly_gcd_brown(fmpz_mod_mpoly_t G, const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, const fmpz_mod_mpoly_ctx_t ctx) + int fmpz_mod_mpoly_gcd_hensel(fmpz_mod_mpoly_t G, const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, const fmpz_mod_mpoly_ctx_t ctx) + int fmpz_mod_mpoly_gcd_subresultant(fmpz_mod_mpoly_t G, const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, const fmpz_mod_mpoly_ctx_t ctx) + int fmpz_mod_mpoly_gcd_zippel(fmpz_mod_mpoly_t G, const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, const fmpz_mod_mpoly_ctx_t ctx) + int fmpz_mod_mpoly_gcd_zippel2(fmpz_mod_mpoly_t G, const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, const fmpz_mod_mpoly_ctx_t ctx) + # Try to set *G* to the GCD of *A* and *B* using various algorithms. + + int fmpz_mod_mpoly_resultant(fmpz_mod_mpoly_t R, const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, long var, const fmpz_mod_mpoly_ctx_t ctx) + # Try to set *R* to the resultant of *A* and *B* with respect to the variable of index *var*. + + int fmpz_mod_mpoly_discriminant(fmpz_mod_mpoly_t D, const fmpz_mod_mpoly_t A, long var, const fmpz_mod_mpoly_ctx_t ctx) + # Try to set *D* to the discriminant of *A* with respect to the variable of index *var*. + + int fmpz_mod_mpoly_sqrt(fmpz_mod_mpoly_t Q, const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_ctx_t ctx) + # If `Q^2=A` has a solution, set *Q* to a solution and return `1`, otherwise return `0` and set *Q* to zero. + + int fmpz_mod_mpoly_is_square(const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_ctx_t ctx) + # Return `1` if *A* is a perfect square, otherwise return `0`. + + int fmpz_mod_mpoly_quadratic_root(fmpz_mod_mpoly_t Q, const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, const fmpz_mod_mpoly_ctx_t ctx) + # If `Q^2+AQ=B` has a solution, set *Q* to a solution and return `1`, otherwise return `0`. + + void fmpz_mod_mpoly_univar_init(fmpz_mod_mpoly_univar_t A, const fmpz_mod_mpoly_ctx_t ctx) + # Initialize *A*. + + void fmpz_mod_mpoly_univar_clear(fmpz_mod_mpoly_univar_t A, const fmpz_mod_mpoly_ctx_t ctx) + # Clear *A*. + + void fmpz_mod_mpoly_univar_swap(fmpz_mod_mpoly_univar_t A, fmpz_mod_mpoly_univar_t B, const fmpz_mod_mpoly_ctx_t ctx) + # Swap *A* and *B*. + + void fmpz_mod_mpoly_to_univar(fmpz_mod_mpoly_univar_t A, const fmpz_mod_mpoly_t B, long var, const fmpz_mod_mpoly_ctx_t ctx) + # Set *A* to a univariate form of *B* by pulling out the variable of index *var*. + # The coefficients of *A* will still belong to the content *ctx* but will not depend on the variable of index *var*. + + void fmpz_mod_mpoly_from_univar(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_univar_t B, long var, const fmpz_mod_mpoly_ctx_t ctx) + # Set *A* to the normal form of *B* by putting in the variable of index *var*. + # This function is undefined if the coefficients of *B* depend on the variable of index *var*. + + int fmpz_mod_mpoly_univar_degree_fits_si(const fmpz_mod_mpoly_univar_t A, const fmpz_mod_mpoly_ctx_t ctx) + # Return `1` if the degree of *A* with respect to the main variable fits an ``slong``. Otherwise, return `0`. + + long fmpz_mod_mpoly_univar_length(const fmpz_mod_mpoly_univar_t A, const fmpz_mod_mpoly_ctx_t ctx) + # Return the number of terms in *A* with respect to the main variable. + + long fmpz_mod_mpoly_univar_get_term_exp_si(fmpz_mod_mpoly_univar_t A, long i, const fmpz_mod_mpoly_ctx_t ctx) + # Return the exponent of the term of index *i* of *A*. + + void fmpz_mod_mpoly_univar_get_term_coeff(fmpz_mod_mpoly_t c, const fmpz_mod_mpoly_univar_t A, long i, const fmpz_mod_mpoly_ctx_t ctx) + void fmpz_mod_mpoly_univar_swap_term_coeff(fmpz_mod_mpoly_t c, fmpz_mod_mpoly_univar_t A, long i, const fmpz_mod_mpoly_ctx_t ctx) + # Set (resp. swap) *c* to (resp. with) the coefficient of the term of index *i* of *A*. + + void fmpz_mod_mpoly_univar_set_coeff_ui(fmpz_mod_mpoly_univar_t Ax, unsigned long e, const fmpz_mod_mpoly_t c, const fmpz_mod_mpoly_ctx_t ctx) + # Set the coefficient of `X^e` in *Ax* to *c*. + + int fmpz_mod_mpoly_univar_resultant(fmpz_mod_mpoly_t R, const fmpz_mod_mpoly_univar_t Ax, const fmpz_mod_mpoly_univar_t Bx, const fmpz_mod_mpoly_ctx_t ctx) + # Try to set *R* to the resultant of *Ax* and *Bx*. + + int fmpz_mod_mpoly_univar_discriminant(fmpz_mod_mpoly_t D, const fmpz_mod_mpoly_univar_t Ax, const fmpz_mod_mpoly_ctx_t ctx) + # Try to set *D* to the discriminant of *Ax*. + + void fmpz_mod_mpoly_inflate(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, const fmpz * shift, const fmpz * stride, const fmpz_mod_mpoly_ctx_t ctx) + # Apply the function ``e -> shift[v] + stride[v]*e`` to each exponent ``e`` corresponding to the variable ``v``. + # It is assumed that each shift and stride is not negative. + + void fmpz_mod_mpoly_deflate(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, const fmpz * shift, const fmpz * stride, const fmpz_mod_mpoly_ctx_t ctx) + # Apply the function ``e -> (e - shift[v])/stride[v]`` to each exponent ``e`` corresponding to the variable ``v``. + # If any ``stride[v]`` is zero, the corresponding numerator ``e - shift[v]`` is assumed to be zero, and the quotient is defined as zero. + # This allows the function to undo the operation performed by :func:`fmpz_mod_mpoly_inflate` when possible. + + void fmpz_mod_mpoly_deflation(fmpz * shift, fmpz * stride, const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_ctx_t ctx) + # For each variable `v` let `S_v` be the set of exponents appearing on `v`. + # Set ``shift[v]`` to `\operatorname{min}(S_v)` and set ``stride[v]`` to `\operatorname{gcd}(S-\operatorname{min}(S_v))`. + # If *A* is zero, all shifts and strides are set to zero. diff --git a/src/sage/libs/flint/fmpz_mod_mpoly_factor.pxd b/src/sage/libs/flint/fmpz_mod_mpoly_factor.pxd new file mode 100644 index 00000000000..252413b5da2 --- /dev/null +++ b/src/sage/libs/flint/fmpz_mod_mpoly_factor.pxd @@ -0,0 +1,47 @@ +# distutils: libraries = flint +# distutils: depends = flint/fmpz_mod_mpoly_factor.h + +################################################################################ +# This file is auto-generated. Do not modify by hand +################################################################################ + +from libc.stdio cimport FILE +from sage.libs.gmp.types cimport * +from sage.libs.mpfr.types cimport * +from sage.libs.flint.types cimport * + +cdef extern from "flint_wrap.h": + + void fmpz_mod_mpoly_factor_init(fmpz_mod_mpoly_factor_t f, const fmpz_mod_mpoly_ctx_t ctx) + # Initialise *f*. + + void fmpz_mod_mpoly_factor_clear(fmpz_mod_mpoly_factor_t f, const fmpz_mod_mpoly_ctx_t ctx) + # Clear *f*. + + void fmpz_mod_mpoly_factor_swap(fmpz_mod_mpoly_factor_t f, fmpz_mod_mpoly_factor_t g, const fmpz_mod_mpoly_ctx_t ctx) + # Efficiently swap *f* and *g*. + + long fmpz_mod_mpoly_factor_length(const fmpz_mod_mpoly_factor_t f, const fmpz_mod_mpoly_ctx_t ctx) + # Return the length of the product in *f*. + + void fmpz_mod_mpoly_factor_get_constant_fmpz(fmpz_t c, const fmpz_mod_mpoly_factor_t f, const fmpz_mod_mpoly_ctx_t ctx) + # Set *c* to the constant of *f*. + + void fmpz_mod_mpoly_factor_get_base(fmpz_mod_mpoly_t B, const fmpz_mod_mpoly_factor_t f, long i, const fmpz_mod_mpoly_ctx_t ctx) + void fmpz_mod_mpoly_factor_swap_base(fmpz_mod_mpoly_t B, fmpz_mod_mpoly_factor_t f, long i, const fmpz_mod_mpoly_ctx_t ctx) + # Set (resp. swap) *B* to (resp. with) the base of the term of index *i* in *f*. + + long fmpz_mod_mpoly_factor_get_exp_si(fmpz_mod_mpoly_factor_t f, long i, const fmpz_mod_mpoly_ctx_t ctx) + # Return the exponent of the term of index *i* in *f*. It is assumed to fit an ``slong``. + + void fmpz_mod_mpoly_factor_sort(fmpz_mod_mpoly_factor_t f, const fmpz_mod_mpoly_ctx_t ctx) + # Sort the product of *f* first by exponent and then by base. + + int fmpz_mod_mpoly_factor_squarefree(fmpz_mod_mpoly_factor_t f, const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_ctx_t ctx) + # Set *f* to a factorization of *A* where the bases are primitive and + # pairwise relatively prime. If the product of all irreducible factors with + # a given exponent is desired, it is recommended to call :func:`fmpz_mod_mpoly_factor_sort` + # and then multiply the bases with the desired exponent. + + int fmpz_mod_mpoly_factor(fmpz_mod_mpoly_factor_t f, const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_ctx_t ctx) + # Set *f* to a factorization of *A* where the bases are irreducible. diff --git a/src/sage/libs/flint/fmpz_mod_poly_factor.pxd b/src/sage/libs/flint/fmpz_mod_poly_factor.pxd new file mode 100644 index 00000000000..8101ad69ebc --- /dev/null +++ b/src/sage/libs/flint/fmpz_mod_poly_factor.pxd @@ -0,0 +1,155 @@ +# distutils: libraries = flint +# distutils: depends = flint/fmpz_mod_poly_factor.h + +################################################################################ +# This file is auto-generated. Do not modify by hand +################################################################################ + +from libc.stdio cimport FILE +from sage.libs.gmp.types cimport * +from sage.libs.mpfr.types cimport * +from sage.libs.flint.types cimport * + +cdef extern from "flint_wrap.h": + + void fmpz_mod_poly_factor_init(fmpz_mod_poly_factor_t fac, const fmpz_mod_ctx_t ctx) + # Initialises ``fac`` for use. + + void fmpz_mod_poly_factor_clear(fmpz_mod_poly_factor_t fac, const fmpz_mod_ctx_t ctx) + # Frees all memory associated with ``fac``. + + void fmpz_mod_poly_factor_realloc(fmpz_mod_poly_factor_t fac, long alloc, const fmpz_mod_ctx_t ctx) + # Reallocates the factor structure to provide space for + # precisely ``alloc`` factors. + + void fmpz_mod_poly_factor_fit_length(fmpz_mod_poly_factor_t fac, long len, const fmpz_mod_ctx_t ctx) + # Ensures that the factor structure has space for at + # least ``len`` factors. This function takes care + # of the case of repeated calls by always at least + # doubling the number of factors the structure can hold. + + void fmpz_mod_poly_factor_set(fmpz_mod_poly_factor_t res, const fmpz_mod_poly_factor_t fac, const fmpz_mod_ctx_t ctx) + # Sets ``res`` to the same factorisation as ``fac``. + + void fmpz_mod_poly_factor_print(const fmpz_mod_poly_factor_t fac, const fmpz_mod_ctx_t ctx) + # Prints the entries of ``fac`` to standard output. + + void fmpz_mod_poly_factor_insert(fmpz_mod_poly_factor_t fac, const fmpz_mod_poly_t poly, long exp, const fmpz_mod_ctx_t ctx) + # Inserts the factor ``poly`` with multiplicity ``exp`` into + # the factorisation ``fac``. + # If ``fac`` already contains ``poly``, then ``exp`` simply + # gets added to the exponent of the existing entry. + + void fmpz_mod_poly_factor_concat(fmpz_mod_poly_factor_t res, const fmpz_mod_poly_factor_t fac, const fmpz_mod_ctx_t ctx) + # Concatenates two factorisations. + # This is equivalent to calling :func:`fmpz_mod_poly_factor_insert` + # repeatedly with the individual factors of ``fac``. + # Does not support aliasing between ``res`` and ``fac``. + + void fmpz_mod_poly_factor_pow(fmpz_mod_poly_factor_t fac, long exp, const fmpz_mod_ctx_t ctx) + # Raises ``fac`` to the power ``exp``. + + int fmpz_mod_poly_is_irreducible(const fmpz_mod_poly_t f, const fmpz_mod_ctx_t ctx) + # Returns 1 if the polynomial ``f`` is irreducible, otherwise returns 0. + + int fmpz_mod_poly_is_irreducible_ddf(const fmpz_mod_poly_t f, const fmpz_mod_ctx_t ctx) + # Returns 1 if the polynomial ``f`` is irreducible, otherwise returns 0. + # Uses fast distinct-degree factorisation. + + int fmpz_mod_poly_is_irreducible_rabin(const fmpz_mod_poly_t f, const fmpz_mod_ctx_t ctx) + # Returns 1 if the polynomial ``f`` is irreducible, otherwise returns 0. + # Uses Rabin irreducibility test. + + int fmpz_mod_poly_is_irreducible_rabin_f(fmpz_t r, const fmpz_mod_poly_t f, const fmpz_mod_ctx_t ctx) + # Either sets `r` to `1` and returns 1 if the polynomial ``f`` is + # irreducible or `0` otherwise, or sets `r` to a nontrivial factor of + # `p`. + # This algorithm correctly determines whether `f` is irreducible over + # `\mathbb{Z}/p\mathbb{Z}`, even for composite `f`, or it finds a factor + # of `p`. + + int _fmpz_mod_poly_is_squarefree(const fmpz * f, long len, const fmpz_mod_ctx_t ctx) + # Returns 1 if ``(f, len)`` is squarefree, and 0 otherwise. As a + # special case, the zero polynomial is not considered squarefree. + # There are no restrictions on the length. + + int _fmpz_mod_poly_is_squarefree_f(fmpz_t fac, const fmpz * f, long len, const fmpz_mod_ctx_t ctx) + # If `fac` returns with the value `1` then the function operates as per + # :func:`_fmpz_mod_poly_is_squarefree`, otherwise `f` is set to a nontrivial + # factor of `p`. + + int fmpz_mod_poly_is_squarefree(const fmpz_mod_poly_t f, const fmpz_mod_ctx_t ctx) + # Returns 1 if ``f`` is squarefree, and 0 otherwise. As a special + # case, the zero polynomial is not considered squarefree. + + int fmpz_mod_poly_is_squarefree_f(fmpz_t fac, const fmpz_mod_poly_t f, const fmpz_mod_ctx_t ctx) + # If `fac` returns with the value `1` then the function operates as per + # :func:`fmpz_mod_poly_is_squarefree`, otherwise `f` is set to a nontrivial + # factor of `p`. + + int fmpz_mod_poly_factor_equal_deg_prob(fmpz_mod_poly_t factor, flint_rand_t state, const fmpz_mod_poly_t pol, long d, const fmpz_mod_ctx_t ctx) + # Probabilistic equal degree factorisation of ``pol`` into + # irreducible factors of degree ``d``. If it passes, a factor is + # placed in ``factor`` and 1 is returned, otherwise 0 is returned and + # the value of factor is undetermined. + # Requires that ``pol`` be monic, non-constant and squarefree. + + void fmpz_mod_poly_factor_equal_deg(fmpz_mod_poly_factor_t factors, const fmpz_mod_poly_t pol, long d, const fmpz_mod_ctx_t ctx) + # Assuming ``pol`` is a product of irreducible factors all of + # degree ``d``, finds all those factors and places them in factors. + # Requires that ``pol`` be monic, non-constant and squarefree. + + void fmpz_mod_poly_factor_distinct_deg(fmpz_mod_poly_factor_t res, const fmpz_mod_poly_t poly, long * const *degs, const fmpz_mod_ctx_t ctx) + # Factorises a monic non-constant squarefree polynomial ``poly`` + # of degree `n` into factors `f[d]` such that for `1 \leq d \leq n` + # `f[d]` is the product of the monic irreducible factors of ``poly`` + # of degree `d`. Factors `f[d]` are stored in ``res``, and the degree `d` + # of the irreducible factors is stored in ``degs`` in the same order + # as the factors. + # Requires that ``degs`` has enough space for `(n/2)+1 * sizeof(slong)`. + + void fmpz_mod_poly_factor_distinct_deg_threaded(fmpz_mod_poly_factor_t res, const fmpz_mod_poly_t poly, long * const *degs, const fmpz_mod_ctx_t ctx) + # Multithreaded version of :func:`fmpz_mod_poly_factor_distinct_deg`. + + void fmpz_mod_poly_factor_squarefree(fmpz_mod_poly_factor_t res, const fmpz_mod_poly_t f, const fmpz_mod_ctx_t ctx) + # Sets ``res`` to a squarefree factorization of ``f``. + + void fmpz_mod_poly_factor(fmpz_mod_poly_factor_t res, const fmpz_mod_poly_t f, const fmpz_mod_ctx_t ctx) + # Factorises a non-constant polynomial ``f`` into monic irreducible + # factors choosing the best algorithm for given modulo and degree. + # Choice is based on heuristic measurements. + + void fmpz_mod_poly_factor_cantor_zassenhaus(fmpz_mod_poly_factor_t res, const fmpz_mod_poly_t f, const fmpz_mod_ctx_t ctx) + # Factorises a non-constant polynomial ``f`` into monic irreducible + # factors using the Cantor-Zassenhaus algorithm. + + void fmpz_mod_poly_factor_kaltofen_shoup(fmpz_mod_poly_factor_t res, const fmpz_mod_poly_t poly, const fmpz_mod_ctx_t ctx) + # Factorises a non-constant polynomial ``poly`` into monic irreducible + # factors using the fast version of Cantor-Zassenhaus algorithm proposed by + # Kaltofen and Shoup (1998). More precisely this algorithm uses a + # baby step/giant step strategy for the distinct-degree factorization + # step. If :func:`flint_get_num_threads` is greater than one + # :func:`fmpz_mod_poly_factor_distinct_deg_threaded` is used. + + void fmpz_mod_poly_factor_berlekamp(fmpz_mod_poly_factor_t factors, const fmpz_mod_poly_t f, const fmpz_mod_ctx_t ctx) + # Factorises a non-constant polynomial ``f`` into monic irreducible + # factors using the Berlekamp algorithm. + + void _fmpz_mod_poly_interval_poly_worker(void* arg_ptr) + # Worker function to compute interval polynomials in distinct degree + # factorisation. Input/output is stored in + # :type:`fmpz_mod_poly_interval_poly_arg_t`. + + void fmpz_mod_poly_roots(fmpz_mod_poly_factor_t r, const fmpz_mod_poly_t f, int with_multiplicity, const fmpz_mod_ctx_t ctx) + # Fill `r` with factors of the form `x - r_i` where the `r_i` are the distinct roots of a nonzero `f` in `Z/pZ`. + # It is expected and not checked that the modulus of `ctx` is prime. + # If `with\_multiplicity` is zero, the exponent `e_i` of the factor `x - r_i` is `1`. Otherwise, it is the largest `e_i` such that `(x-r_i)^e_i` divides `f`. + # This function throws if `f` is zero, but is otherwise always successful. + + int fmpz_mod_poly_roots_factored(fmpz_mod_poly_factor_t r, const fmpz_mod_poly_t f, int with_multiplicity, const fmpz_factor_t n, const fmpz_mod_ctx_t ctx) + # Fill `r` with factors of the form `x - r_i` where the `r_i` are the distinct roots of a nonzero `f` in `Z/nZ`. + # It is expected and not checked that `n` is a prime factorization of the modulus of `ctx`. + # If `with\_multiplicity` is zero, the exponent `e_i` of the factor `x - r_i` is `1`. Otherwise, it is the largest `e_i` such that `(x-r_i)^e_i` divides `f`. + # The roots are first found modulo the primes in `n`, then lifted to the corresponding prime powers, then combined into roots of the original polynomial `f`. + # A return of `1` indicates the function was successful. A return of `0` indicates the function was not able to find the roots, possibly because there are too many of them. + # This function throws if `f` is zero. diff --git a/src/sage/libs/flint/fmpz_mod_vec.pxd b/src/sage/libs/flint/fmpz_mod_vec.pxd new file mode 100644 index 00000000000..990b9d60c90 --- /dev/null +++ b/src/sage/libs/flint/fmpz_mod_vec.pxd @@ -0,0 +1,44 @@ +# distutils: libraries = flint +# distutils: depends = flint/fmpz_mod_vec.h + +################################################################################ +# This file is auto-generated. Do not modify by hand +################################################################################ + +from libc.stdio cimport FILE +from sage.libs.gmp.types cimport * +from sage.libs.mpfr.types cimport * +from sage.libs.flint.types cimport * + +cdef extern from "flint_wrap.h": + + void _fmpz_mod_vec_set_fmpz_vec(fmpz * A, const fmpz * B, long len, const fmpz_mod_ctx_t ctx) + # Set the `fmpz_mod_vec` `(A, len)` to the `fmpz_vec` `(B, len)` after + # reduction of each entry modulo the modulus.. + + void _fmpz_mod_vec_neg(fmpz * A, const fmpz * B, long len, const fmpz_mod_ctx_t ctx) + # Set `(A, len)` to `-(B, len)`. + + void _fmpz_mod_vec_add(fmpz * a, const fmpz * b, const fmpz * c, long n, const fmpz_mod_ctx_t ctx) + # Set (A, len)` to `(B, len) + (C, len)`. + + void _fmpz_mod_vec_sub(fmpz * a, const fmpz * b, const fmpz * c, long n, const fmpz_mod_ctx_t ctx) + # Set (A, len)` to `(B, len) - (C, len)`. + + void _fmpz_mod_vec_scalar_mul_fmpz_mod(fmpz * A, const fmpz * B, long len, const fmpz_t c, const fmpz_mod_ctx_t ctx) + # Set `(A, len)` to `(B, len)*c`. + + void _fmpz_mod_vec_scalar_addmul_fmpz_mod(fmpz * A, const fmpz * B, long len, const fmpz_t c, const fmpz_mod_ctx_t ctx) + # Set `(A, len)` to `(A, len) + (B, len)*c`. + + void _fmpz_mod_vec_scalar_div_fmpz_mod(fmpz * A, const fmpz * B, long len, const fmpz_t c, const fmpz_mod_ctx_t ctx) + # Set `(A, len)` to `(B, len)/c` assuming `c` is nonzero. + + void _fmpz_mod_vec_dot(fmpz_t d, const fmpz * A, const fmpz * B, long len, const fmpz_mod_ctx_t ctx) + # Set `d` to the dot product of `(A, len)` with `(B, len)`. + + void _fmpz_mod_vec_dot_rev(fmpz_t d, const fmpz * A, const fmpz * B, long len, const fmpz_mod_ctx_t ctx) + # Set `d` to the dot product of `(A, len)` with the reverse of the vector `(B, len)`. + + void _fmpz_mod_vec_mul(fmpz * A, const fmpz * B, const fmpz * C, long len, const fmpz_mod_ctx_t ctx) + # Set `(A, len)` the pointwise multiplication of `(B, len)` and `(C, len)`. diff --git a/src/sage/libs/flint/fmpz_mpoly.pxd b/src/sage/libs/flint/fmpz_mpoly.pxd new file mode 100644 index 00000000000..2db76877bb5 --- /dev/null +++ b/src/sage/libs/flint/fmpz_mpoly.pxd @@ -0,0 +1,715 @@ +# distutils: libraries = flint +# distutils: depends = flint/fmpz_mpoly.h + +################################################################################ +# This file is auto-generated. Do not modify by hand +################################################################################ + +from libc.stdio cimport FILE +from sage.libs.gmp.types cimport * +from sage.libs.mpfr.types cimport * +from sage.libs.flint.types cimport * + +cdef extern from "flint_wrap.h": + + void fmpz_mpoly_ctx_init(fmpz_mpoly_ctx_t ctx, long nvars, const ordering_t ord) + # Initialise a context object for a polynomial ring with the given number of variables and the given ordering. + # The possibilities for the ordering are ``ORD_LEX``, ``ORD_DEGLEX`` and ``ORD_DEGREVLEX``. + + long fmpz_mpoly_ctx_nvars(const fmpz_mpoly_ctx_t ctx) + # Return the number of variables used to initialize the context. + + ordering_t fmpz_mpoly_ctx_ord(const fmpz_mpoly_ctx_t ctx) + # Return the ordering used to initialize the context. + + void fmpz_mpoly_ctx_clear(fmpz_mpoly_ctx_t ctx) + # Release up any space allocated by *ctx*. + + void fmpz_mpoly_init(fmpz_mpoly_t A, const fmpz_mpoly_ctx_t ctx) + # Initialise *A* for use with the given and initialised context object. Its value is set to zero. + + void fmpz_mpoly_init2(fmpz_mpoly_t A, long alloc, const fmpz_mpoly_ctx_t ctx) + # Initialise *A* for use with the given and initialised context object. Its value is set to zero. + # It is allocated with space for *alloc* terms and at least ``MPOLY_MIN_BITS`` bits for the exponents. + + void fmpz_mpoly_init3(fmpz_mpoly_t A, long alloc, flint_bitcnt_t bits, const fmpz_mpoly_ctx_t ctx) + # Initialise *A* for use with the given and initialised context object. Its value is set to zero. + # It is allocated with space for *alloc* terms and *bits* bits for the exponents. + + void fmpz_mpoly_fit_length(fmpz_mpoly_t A, long len, const fmpz_mpoly_ctx_t ctx) + # Ensure that *A* has space for at least *len* terms. + + void fmpz_mpoly_fit_bits(fmpz_mpoly_t A, flint_bitcnt_t bits, const fmpz_mpoly_ctx_t ctx) + # Ensure that the exponent fields of *A* have at least *bits* bits. + + void fmpz_mpoly_realloc(fmpz_mpoly_t A, long alloc, const fmpz_mpoly_ctx_t ctx) + # Reallocate *A* to have space for *alloc* terms. + # Assumes the current length of the polynomial is not greater than *alloc*. + + void fmpz_mpoly_clear(fmpz_mpoly_t A, const fmpz_mpoly_ctx_t ctx) + # Release any space allocated for *A*. + + char * fmpz_mpoly_get_str_pretty(const fmpz_mpoly_t A, const char ** x, const fmpz_mpoly_ctx_t ctx) + # Return a string, which the user is responsible for cleaning up, representing *A*, given an array of variable strings *x*. + + int fmpz_mpoly_fprint_pretty(FILE * file, const fmpz_mpoly_t A, const char ** x, const fmpz_mpoly_ctx_t ctx) + # Print a string representing *A* to *file*. + + int fmpz_mpoly_print_pretty(const fmpz_mpoly_t A, const char ** x, const fmpz_mpoly_ctx_t ctx) + # Print a string representing *A* to ``stdout``. + + int fmpz_mpoly_set_str_pretty(fmpz_mpoly_t A, const char * str, const char ** x, const fmpz_mpoly_ctx_t ctx) + # Set *A* to the polynomial in the null-terminates string *str* given an array *x* of variable strings. + # If parsing *str* fails, *A* is set to zero, and `-1` is returned. Otherwise, `0` is returned. + # The operations ``+``, ``-``, ``*``, and ``/`` are permitted along with integers and the variables in *x*. The character ``^`` must be immediately followed by the (integer) exponent. + # If any division is not exact, parsing fails. + + void fmpz_mpoly_gen(fmpz_mpoly_t A, long var, const fmpz_mpoly_ctx_t ctx) + # Set *A* to the variable of index *var*, where `var = 0` corresponds to the variable with the most significance with respect to the ordering. + + int fmpz_mpoly_is_gen(const fmpz_mpoly_t A, long var, const fmpz_mpoly_ctx_t ctx) + # If `var \ge 0`, return `1` if *A* is equal to the `var`-th generator, otherwise return `0`. + # If `var < 0`, return `1` if the polynomial is equal to any generator, otherwise return `0`. + + void fmpz_mpoly_set(fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_mpoly_ctx_t ctx) + # Set *A* to *B*. + + int fmpz_mpoly_equal(const fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_mpoly_ctx_t ctx) + # Return `1` if *A* is equal to *B*, else return `0`. + + void fmpz_mpoly_swap(fmpz_mpoly_t poly1, fmpz_mpoly_t poly2, const fmpz_mpoly_ctx_t ctx) + # Efficiently swap *A* and *B*. + + int _fmpz_mpoly_fits_small(const fmpz * poly, long len) + # Return 1 if the array of coefficients of length *len* consists + # entirely of values that are small ``fmpz`` values, i.e. of at most + # ``FLINT_BITS - 2`` bits plus a sign bit. + + long fmpz_mpoly_max_bits(const fmpz_mpoly_t A) + # Computes the maximum number of bits `b` required to represent the absolute + # values of the coefficients of *A*. If all of the coefficients are + # positive, `b` is returned, otherwise `-b` is returned. + + int fmpz_mpoly_is_fmpz(const fmpz_mpoly_t A, const fmpz_mpoly_ctx_t ctx) + # Return `1` if *A* is a constant, else return `0`. + + void fmpz_mpoly_get_fmpz(fmpz_t c, const fmpz_mpoly_t A, const fmpz_mpoly_ctx_t ctx) + # Assuming that *A* is a constant, set *c* to this constant. + # This function throws if *A* is not a constant. + + void fmpz_mpoly_set_fmpz(fmpz_mpoly_t A, const fmpz_t c, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_set_ui(fmpz_mpoly_t A, unsigned long c, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_set_si(fmpz_mpoly_t A, long c, const fmpz_mpoly_ctx_t ctx) + # Set *A* to the constant *c*. + + void fmpz_mpoly_zero(fmpz_mpoly_t A, const fmpz_mpoly_ctx_t ctx) + # Set *A* to the constant `0`. + + void fmpz_mpoly_one(fmpz_mpoly_t A, const fmpz_mpoly_ctx_t ctx) + # Set *A* to the constant `1`. + + int fmpz_mpoly_equal_fmpz(const fmpz_mpoly_t A, const fmpz_t c, const fmpz_mpoly_ctx_t ctx) + int fmpz_mpoly_equal_ui(const fmpz_mpoly_t A, unsigned long c, const fmpz_mpoly_ctx_t ctx) + int fmpz_mpoly_equal_si(const fmpz_mpoly_t A, long c, const fmpz_mpoly_ctx_t ctx) + # Return `1` if *A* is equal to the constant *c*, else return `0`. + + int fmpz_mpoly_is_zero(const fmpz_mpoly_t A, const fmpz_mpoly_ctx_t ctx) + # Return `1` if *A* is the constant `0`, else return `0`. + + int fmpz_mpoly_is_one(const fmpz_mpoly_t A, const fmpz_mpoly_ctx_t ctx) + # Return `1` if *A* is the constant `1`, else return `0`. + + int fmpz_mpoly_degrees_fit_si(const fmpz_mpoly_t A, const fmpz_mpoly_ctx_t ctx) + # Return `1` if the degrees of *A* with respect to each variable fit into an ``slong``, otherwise return `0`. + + void fmpz_mpoly_degrees_fmpz(fmpz ** degs, const fmpz_mpoly_t A, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_degrees_si(long * degs, const fmpz_mpoly_t A, const fmpz_mpoly_ctx_t ctx) + # Set *degs* to the degrees of *A* with respect to each variable. + # If *A* is zero, all degrees are set to `-1`. + + void fmpz_mpoly_degree_fmpz(fmpz_t deg, const fmpz_mpoly_t A, long var, const fmpz_mpoly_ctx_t ctx) + long fmpz_mpoly_degree_si(const fmpz_mpoly_t A, long var, const fmpz_mpoly_ctx_t ctx) + # Either return or set *deg* to the degree of *A* with respect to the variable of index *var*. + # If *A* is zero, the degree is defined to be `-1`. + + int fmpz_mpoly_total_degree_fits_si(const fmpz_mpoly_t A, const fmpz_mpoly_ctx_t ctx) + # Return `1` if the total degree of *A* fits into an ``slong``, otherwise return `0`. + + void fmpz_mpoly_total_degree_fmpz(fmpz_t tdeg, const fmpz_mpoly_t A, const fmpz_mpoly_ctx_t ctx) + long fmpz_mpoly_total_degree_si(const fmpz_mpoly_t A, const fmpz_mpoly_ctx_t ctx) + # Either return or set *tdeg* to the total degree of *A*. + # If *A* is zero, the total degree is defined to be `-1`. + + void fmpz_mpoly_used_vars(int * used, const fmpz_mpoly_t A, const fmpz_mpoly_ctx_t ctx) + # For each variable index *i*, set ``used[i]`` to nonzero if the variable of index *i* appears in *A* and to zero otherwise. + + void fmpz_mpoly_get_coeff_fmpz_monomial(fmpz_t c, const fmpz_mpoly_t A, const fmpz_mpoly_t M, const fmpz_mpoly_ctx_t ctx) + # Assuming that *M* is a monomial, set *c* to the coefficient of the corresponding monomial in *A*. + # This function throws if *M* is not a monomial. + + void fmpz_mpoly_set_coeff_fmpz_monomial(fmpz_mpoly_t poly, const fmpz_t c, const fmpz_mpoly_t poly2, const fmpz_mpoly_ctx_t ctx) + # Assuming that *M* is a monomial, set the coefficient of the corresponding monomial in *A* to *c*. + # This function throws if *M* is not a monomial. + + void fmpz_mpoly_get_coeff_fmpz_fmpz(fmpz_t c, const fmpz_mpoly_t A, fmpz * const * exp, const fmpz_mpoly_ctx_t ctx) + unsigned long fmpz_mpoly_get_coeff_ui_fmpz(const fmpz_mpoly_t A, fmpz * const * exp, const fmpz_mpoly_ctx_t ctx) + long fmpz_mpoly_get_coeff_si_fmpz(const fmpz_mpoly_t A, fmpz * const * exp, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_get_coeff_fmpz_ui(fmpz_t c, const fmpz_mpoly_t A, const unsigned long * exp, const fmpz_mpoly_ctx_t ctx) + unsigned long fmpz_mpoly_get_coeff_ui_ui(const fmpz_mpoly_t A, const unsigned long * exp, const fmpz_mpoly_ctx_t ctx) + long fmpz_mpoly_get_coeff_si_ui(const fmpz_mpoly_t A, const unsigned long * exp, const fmpz_mpoly_ctx_t ctx) + # Either return or set *c* to the coefficient of the monomial with exponent vector *exp*. + + void fmpz_mpoly_set_coeff_fmpz_fmpz(fmpz_mpoly_t A, const fmpz_t c, fmpz * const * exp, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_set_coeff_ui_fmpz(fmpz_mpoly_t A, unsigned long c, fmpz * const * exp, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_set_coeff_si_fmpz(fmpz_mpoly_t A, long c, fmpz * const * exp, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_set_coeff_fmpz_ui(fmpz_mpoly_t A, const fmpz_t c, const unsigned long * exp, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_set_coeff_ui_ui(fmpz_mpoly_t A, unsigned long c, const unsigned long * exp, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_set_coeff_si_ui(fmpz_mpoly_t A, long c, const unsigned long * exp, const fmpz_mpoly_ctx_t ctx) + # Set the coefficient of the monomial with exponent vector *exp* to *c*. + + void fmpz_mpoly_get_coeff_vars_ui(fmpz_mpoly_t C, const fmpz_mpoly_t A, const long * vars, const unsigned long * exps, long length, const fmpz_mpoly_ctx_t ctx) + # Set *C* to the coefficient of *A* with respect to the variables in *vars* with powers in the corresponding array *exps*. + # Both *vars* and *exps* point to array of length *length*. It is assumed that `0 < length \le nvars(A)` and that the variables in *vars* are distinct. + + int fmpz_mpoly_cmp(const fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_mpoly_ctx_t ctx) + # Return `1` (resp. `-1`, or `0`) if *A* is after (resp. before, same as) *B* in some arbitrary but fixed total ordering of the polynomials. + # This ordering agrees with the usual ordering of monomials when *A* and *B* are both monomials. + + int fmpz_mpoly_is_fmpz_poly(const fmpz_mpoly_t A, long var, const fmpz_mpoly_ctx_t ctx) + # Return whether *A* is a univariate polynomial in the variable with index *var*. + + int fmpz_mpoly_get_fmpz_poly(fmpz_poly_t A, const fmpz_mpoly_t B, long var, const fmpz_mpoly_ctx_t ctx) + # If *B* is a univariate polynomial in the variable with index *var*, + # set *A* to this polynomial and return 1; otherwise return 0. + + void fmpz_mpoly_set_fmpz_poly(fmpz_mpoly_t A, const fmpz_poly_t B, long var, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_set_gen_fmpz_poly(fmpz_mpoly_t A, long var, const fmpz_poly_t B, const fmpz_mpoly_ctx_t ctx) + # Set *A* to the univariate polynomial *B* in the variable with index *var*. + + fmpz * fmpz_mpoly_term_coeff_ref(fmpz_mpoly_t A, long i, const fmpz_mpoly_ctx_t ctx) + # Return a reference to the coefficient of index *i* of *A*. + + int fmpz_mpoly_is_canonical(const fmpz_mpoly_t A, const fmpz_mpoly_ctx_t ctx) + # Return `1` if *A* is in canonical form. Otherwise, return `0`. + # To be in canonical form, all of the terms must have nonzero coefficient, and the terms must be sorted from greatest to least. + + long fmpz_mpoly_length(const fmpz_mpoly_t A, const fmpz_mpoly_ctx_t ctx) + # Return the number of terms in *A*. + # If the polynomial is in canonical form, this will be the number of nonzero coefficients. + + void fmpz_mpoly_resize(fmpz_mpoly_t A, long new_length, const fmpz_mpoly_ctx_t ctx) + # Set the length of *A* to `new\_length`. + # Terms are either deleted from the end, or new zero terms are appended. + + void fmpz_mpoly_get_term_coeff_fmpz(fmpz_t c, const fmpz_mpoly_t A, long i, const fmpz_mpoly_ctx_t ctx) + unsigned long fmpz_mpoly_get_term_coeff_ui(const fmpz_mpoly_t A, long i, const fmpz_mpoly_ctx_t ctx) + long fmpz_mpoly_get_term_coeff_si(const fmpz_mpoly_t poly, long i, const fmpz_mpoly_ctx_t ctx) + # Either return or set *c* to the coefficient of the term of index *i*. + + void fmpz_mpoly_set_term_coeff_fmpz(fmpz_mpoly_t A, long i, const fmpz_t c, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_set_term_coeff_ui(fmpz_mpoly_t A, long i, unsigned long c, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_set_term_coeff_si(fmpz_mpoly_t A, long i, long c, const fmpz_mpoly_ctx_t ctx) + # Set the coefficient of the term of index *i* to *c*. + + int fmpz_mpoly_term_exp_fits_si(const fmpz_mpoly_t poly, long i, const fmpz_mpoly_ctx_t ctx) + int fmpz_mpoly_term_exp_fits_ui(const fmpz_mpoly_t poly, long i, const fmpz_mpoly_ctx_t ctx) + # Return `1` if all entries of the exponent vector of the term of index *i* fit into an ``slong`` (resp. a ``ulong``). Otherwise, return `0`. + + void fmpz_mpoly_get_term_exp_fmpz(fmpz ** exp, const fmpz_mpoly_t A, long i, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_get_term_exp_ui(unsigned long * exp, const fmpz_mpoly_t A, long i, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_get_term_exp_si(long * exp, const fmpz_mpoly_t A, long i, const fmpz_mpoly_ctx_t ctx) + # Set *exp* to the exponent vector of the term of index *i*. + # The ``_ui`` (resp. ``_si``) version throws if any entry does not fit into a ``ulong`` (resp. ``slong``). + + unsigned long fmpz_mpoly_get_term_var_exp_ui(const fmpz_mpoly_t A, long i, long var, const fmpz_mpoly_ctx_t ctx) + long fmpz_mpoly_get_term_var_exp_si(const fmpz_mpoly_t A, long i, long var, const fmpz_mpoly_ctx_t ctx) + # Return the exponent of the variable `var` of the term of index *i*. + # This function throws if the exponent does not fit into a ``ulong`` (resp. ``slong``). + + void fmpz_mpoly_set_term_exp_fmpz(fmpz_mpoly_t A, long i, fmpz * const * exp, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_set_term_exp_ui(fmpz_mpoly_t A, long i, const unsigned long * exp, const fmpz_mpoly_ctx_t ctx) + # Set the exponent vector of the term of index *i* to *exp*. + + void fmpz_mpoly_get_term(fmpz_mpoly_t M, const fmpz_mpoly_t A, long i, const fmpz_mpoly_ctx_t ctx) + # Set `M` to the term of index *i* in *A*. + + void fmpz_mpoly_get_term_monomial(fmpz_mpoly_t M, const fmpz_mpoly_t A, long i, const fmpz_mpoly_ctx_t ctx) + # Set `M` to the monomial of the term of index *i* in *A*. The coefficient of `M` will be one. + + void fmpz_mpoly_push_term_fmpz_fmpz(fmpz_mpoly_t A, const fmpz_t c, fmpz * const * exp, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_push_term_fmpz_ffmpz(fmpz_mpoly_t A, const fmpz_t c, const fmpz * exp, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_push_term_ui_fmpz(fmpz_mpoly_t A, unsigned long c, fmpz * const * exp, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_push_term_ui_ffmpz(fmpz_mpoly_t A, unsigned long c, const fmpz * exp, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_push_term_si_fmpz(fmpz_mpoly_t A, long c, fmpz * const * exp, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_push_term_si_ffmpz(fmpz_mpoly_t A, long c, const fmpz * exp, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_push_term_fmpz_ui(fmpz_mpoly_t A, const fmpz_t c, const unsigned long * exp, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_push_term_ui_ui(fmpz_mpoly_t A, unsigned long c, const unsigned long * exp, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_push_term_si_ui(fmpz_mpoly_t A, long c, const unsigned long * exp, const fmpz_mpoly_ctx_t ctx) + # Append a term to *A* with coefficient *c* and exponent vector *exp*. + # This function runs in constant average time. + + void fmpz_mpoly_sort_terms(fmpz_mpoly_t A, const fmpz_mpoly_ctx_t ctx) + # Sort the terms of *A* into the canonical ordering dictated by the ordering in *ctx*. + # This function simply reorders the terms: It does not combine like terms, nor does it delete terms with coefficient zero. + # This function runs in linear time in the size of *A*. + + void fmpz_mpoly_combine_like_terms(fmpz_mpoly_t A, const fmpz_mpoly_ctx_t ctx) + # Combine adjacent like terms in *A* and delete terms with coefficient zero. + # If the terms of *A* were sorted to begin with, the result will be in canonical form. + # This function runs in linear time in the size of *A*. + + void fmpz_mpoly_reverse(fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_mpoly_ctx_t ctx) + # Set *A* to the reversal of *B*. + + void fmpz_mpoly_randtest_bound(fmpz_mpoly_t A, flint_rand_t state, long length, mp_limb_t coeff_bits, unsigned long exp_bound, const fmpz_mpoly_ctx_t ctx) + # Generate a random polynomial with length up to *length* and exponents in the range ``[0, exp_bound - 1]``. + # The exponents of each variable are generated by calls to ``n_randint(state, exp_bound)``. + + void fmpz_mpoly_randtest_bounds(fmpz_mpoly_t A, flint_rand_t state, long length, mp_limb_t coeff_bits, unsigned long * exp_bounds, const fmpz_mpoly_ctx_t ctx) + # Generate a random polynomial with length up to *length* and exponents in the range ``[0, exp_bounds[i] - 1]``. + # The exponents of the variable of index *i* are generated by calls to ``n_randint(state, exp_bounds[i])``. + + void fmpz_mpoly_randtest_bits(fmpz_mpoly_t A, flint_rand_t state, long length, mp_limb_t coeff_bits, mp_limb_t exp_bits, const fmpz_mpoly_ctx_t ctx) + # Generate a random polynomial with length up to the given length and exponents whose packed form does not exceed the given bit count. + # The parameter ``coeff_bits`` to the three functions ``fmpz_mpoly_randtest_{bound|bounds|bits}`` is merely a suggestion for the approximate bit count of the resulting signed coefficients. + # The function :func:`fmpz_mpoly_max_bits` will give the exact bit count of the result. + + void fmpz_mpoly_add_fmpz(fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_t c, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_add_ui(fmpz_mpoly_t A, const fmpz_mpoly_t B, unsigned long c, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_add_si(fmpz_mpoly_t A, const fmpz_mpoly_t B, long c, const fmpz_mpoly_ctx_t ctx) + # Set *A* to `B + c`. + # If *A* and *B* are aliased, this function will probably run quickly. + + void fmpz_mpoly_sub_fmpz(fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_t c, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_sub_ui(fmpz_mpoly_t A, const fmpz_mpoly_t B, unsigned long c, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_sub_si(fmpz_mpoly_t A, const fmpz_mpoly_t B, long c, const fmpz_mpoly_ctx_t ctx) + # Set *A* to `B - c`. + # If *A* and *B* are aliased, this function will probably run quickly. + + void fmpz_mpoly_add(fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_mpoly_t C, const fmpz_mpoly_ctx_t ctx) + # Set *A* to `B + C`. + # If *A* and *B* are aliased, this function might run in time proportional to the size of `C`. + + void fmpz_mpoly_sub(fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_mpoly_t C, const fmpz_mpoly_ctx_t ctx) + # Set *A* to `B - C`. + # If *A* and *B* are aliased, this function might run in time proportional to the size of `C`. + + void fmpz_mpoly_neg(fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_mpoly_ctx_t ctx) + # Set *A* to `-B`. + + void fmpz_mpoly_scalar_mul_fmpz(fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_t c, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_scalar_mul_ui(fmpz_mpoly_t A, const fmpz_mpoly_t B, unsigned long c, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_scalar_mul_si(fmpz_mpoly_t A, const fmpz_mpoly_t B, long c, const fmpz_mpoly_ctx_t ctx) + # Set *A* to `B \times c`. + + void fmpz_mpoly_scalar_fmma(fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_t c, const fmpz_mpoly_t D, const fmpz_t e, const fmpz_mpoly_ctx_t ctx) + # Sets *A* to `B \times c + D \times e`. + + void fmpz_mpoly_scalar_divexact_fmpz(fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_t c, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_scalar_divexact_ui(fmpz_mpoly_t A, const fmpz_mpoly_t B, unsigned long c, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_scalar_divexact_si(fmpz_mpoly_t A, const fmpz_mpoly_t B, long c, const fmpz_mpoly_ctx_t ctx) + # Set *A* to *B* divided by *c*. The division is assumed to be exact. + + int fmpz_mpoly_scalar_divides_fmpz(fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_t c, const fmpz_mpoly_ctx_t ctx) + int fmpz_mpoly_scalar_divides_ui(fmpz_mpoly_t A, const fmpz_mpoly_t B, unsigned long c, const fmpz_mpoly_ctx_t ctx) + int fmpz_mpoly_scalar_divides_si(fmpz_mpoly_t A, const fmpz_mpoly_t B, long c, const fmpz_mpoly_ctx_t ctx) + # If *B* is divisible by *c*, set *A* to the exact quotient and return `1`, otherwise set *A* to zero and return `0`. + + void fmpz_mpoly_derivative(fmpz_mpoly_t A, const fmpz_mpoly_t B, long var, const fmpz_mpoly_ctx_t ctx) + # Set *A* to the derivative of *B* with respect to the variable of index `var`. + + void fmpz_mpoly_integral(fmpz_mpoly_t A, fmpz_t scale, const fmpz_mpoly_t B, long var, const fmpz_mpoly_ctx_t ctx) + # Set *A* and *scale* so that *A* is an integral of `scale \times B` with respect to the variable of index *var*, where *scale* is positive and as small as possible. + + int fmpz_mpoly_evaluate_all_fmpz(fmpz_t ev, const fmpz_mpoly_t A, fmpz * const * vals, const fmpz_mpoly_ctx_t ctx) + # Set *ev* to the evaluation of *A* where the variables are replaced by the corresponding elements of the array *vals*. + # Return `1` for success and `0` for failure. + + int fmpz_mpoly_evaluate_one_fmpz(fmpz_mpoly_t A, const fmpz_mpoly_t B, long var, const fmpz_t val, const fmpz_mpoly_ctx_t ctx) + # Set *A* to the evaluation of *B* where the variable of index *var* is replaced by ``val``. + # Return `1` for success and `0` for failure. + + int fmpz_mpoly_compose_fmpz_poly(fmpz_poly_t A, const fmpz_mpoly_t B, fmpz_poly_struct * const * C, const fmpz_mpoly_ctx_t ctxB) + # Set *A* to the evaluation of *B* where the variables are replaced by the corresponding elements of the array *C*. + # The context object of *B* is *ctxB*. + # Return `1` for success and `0` for failure. + + int fmpz_mpoly_compose_fmpz_mpoly_geobucket(fmpz_mpoly_t A, const fmpz_mpoly_t B, fmpz_mpoly_struct * const * C, const fmpz_mpoly_ctx_t ctxB, const fmpz_mpoly_ctx_t ctxAC) + int fmpz_mpoly_compose_fmpz_mpoly_horner(fmpz_mpoly_t A, const fmpz_mpoly_t B, fmpz_mpoly_struct * const * C, const fmpz_mpoly_ctx_t ctxB, const fmpz_mpoly_ctx_t ctxAC) + int fmpz_mpoly_compose_fmpz_mpoly(fmpz_mpoly_t A, const fmpz_mpoly_t B, fmpz_mpoly_struct * const * C, const fmpz_mpoly_ctx_t ctxB, const fmpz_mpoly_ctx_t ctxAC) + # Set *A* to the evaluation of *B* where the variables are replaced by the corresponding elements of the array *C*. + # Both *A* and the elements of *C* have context object *ctxAC*, while *B* has context object *ctxB*. + # The length of the array *C* is the number of variables in *ctxB*. + # Neither *A* nor *B* is allowed to alias any other polynomial. + # Return `1` for success and `0` for failure. + # The main method attempts to perform the calculation using matrices and chooses heuristically between the ``geobucket`` and ``horner`` methods if needed. + + void fmpz_mpoly_compose_fmpz_mpoly_gen(fmpz_mpoly_t A, const fmpz_mpoly_t B, const long * c, const fmpz_mpoly_ctx_t ctxB, const fmpz_mpoly_ctx_t ctxAC) + # Set *A* to the evaluation of *B* where the variable of index *i* in *ctxB* is replaced by the variable of index ``c[i]`` in *ctxAC*. + # The length of the array *C* is the number of variables in *ctxB*. + # If any ``c[i]`` is negative, the corresponding variable of *B* is replaced by zero. Otherwise, it is expected that ``c[i]`` is less than the number of variables in *ctxAC*. + + void fmpz_mpoly_mul(fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_mpoly_t C, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_mul_threaded(fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_mpoly_t C, const fmpz_mpoly_ctx_t ctx, long thread_limit) + # Set *A* to `B \times C`. + + void fmpz_mpoly_mul_johnson(fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_mpoly_t C, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_mul_heap_threaded(fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_mpoly_t C, const fmpz_mpoly_ctx_t ctx) + # Set *A* to `B \times C` using Johnson's heap-based method. + # The first version always uses one thread. + + int fmpz_mpoly_mul_array(fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_mpoly_t C, const fmpz_mpoly_ctx_t ctx) + int fmpz_mpoly_mul_array_threaded(fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_mpoly_t C, const fmpz_mpoly_ctx_t ctx) + # Try to set *A* to `B \times C` using arrays. + # If the return is `0`, the operation was unsuccessful. Otherwise, it was successful and the return is `1`. + # The first version always uses one thread. + + int fmpz_mpoly_mul_dense(fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_mpoly_t C, const fmpz_mpoly_ctx_t ctx) + # Try to set *A* to `B \times C` using dense arithmetic. + # If the return is `0`, the operation was unsuccessful. Otherwise, it was successful and the return is `1`. + + int fmpz_mpoly_pow_fmpz(fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_t k, const fmpz_mpoly_ctx_t ctx) + # Set *A* to *B* raised to the *k*-th power. + # Return `1` for success and `0` for failure. + + int fmpz_mpoly_pow_ui(fmpz_mpoly_t A, const fmpz_mpoly_t B, unsigned long k, const fmpz_mpoly_ctx_t ctx) + # Set *A* to *B* raised to the *k*-th power. + # Return `1` for success and `0` for failure. + + int fmpz_mpoly_divides(fmpz_mpoly_t Q, const fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_mpoly_ctx_t ctx) + # If *A* is divisible by *B*, set *Q* to the exact quotient and return `1`. Otherwise, set `Q` to zero and return `0`. + + void fmpz_mpoly_divrem(fmpz_mpoly_t Q, fmpz_mpoly_t R, const fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_mpoly_ctx_t ctx) + # Set `Q` and `R` to the quotient and remainder of *A* divided by *B*. The monomials in *R* divisible by the leading monomial of *B* will have coefficients reduced modulo the absolute value of the leading coefficient of *B*. + # Note that this function is not very useful if the leading coefficient *B* is not a unit. + + void fmpz_mpoly_quasidivrem(fmpz_t scale, fmpz_mpoly_t Q, fmpz_mpoly_t R, const fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_mpoly_ctx_t ctx) + # Set *scale*, *Q* and *R* so that *Q* and *R* are the quotient and remainder of `scale \times A` divided by *B*. No monomials in *R* will be divisible by the leading monomial of *B*. + + void fmpz_mpoly_div(fmpz_mpoly_t Q, const fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_mpoly_ctx_t ctx) + # Perform the operation of :func:`fmpz_mpoly_divrem` and discard *R*. + # Note that this function is not very useful if the division is not exact and the leading coefficient *B* is not a unit. + + void fmpz_mpoly_quasidiv(fmpz_t scale, fmpz_mpoly_t Q, const fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_mpoly_ctx_t ctx) + # Perform the operation of :func:`fmpz_mpoly_quasidivrem` and discard *R*. + + void fmpz_mpoly_divrem_ideal(fmpz_mpoly_struct ** Q, fmpz_mpoly_t R, const fmpz_mpoly_t A, fmpz_mpoly_struct * const * B, long len, const fmpz_mpoly_ctx_t ctx) + # This function is as per :func:`fmpz_mpoly_divrem` except that it takes an array of divisor polynomials *B* and it returns an array of quotient polynomials *Q*. + # The number of divisor (and hence quotient) polynomials is given by *len*. + # Note that this function is not very useful if there is no unit among the leading coefficients in the array *B*. + + void fmpz_mpoly_quasidivrem_ideal(fmpz_t scale, fmpz_mpoly_struct ** Q, fmpz_mpoly_t R, const fmpz_mpoly_t A, fmpz_mpoly_struct * const * B, long len, const fmpz_mpoly_ctx_t ctx) + # This function is as per :func:`fmpz_mpoly_quasidivrem` except that it takes an array of divisor polynomials *B* and it returns an array of quotient polynomials *Q*. + # The number of divisor (and hence quotient) polynomials is given by *len*. + + void fmpz_mpoly_term_content(fmpz_mpoly_t M, const fmpz_mpoly_t A, const fmpz_mpoly_ctx_t ctx) + # Set *M* to the GCD of the terms of *A*. + # If *A* is zero, *M* will be zero. Otherwise, *M* will be a monomial with positive coefficient. + + int fmpz_mpoly_content_vars(fmpz_mpoly_t g, const fmpz_mpoly_t A, long * vars, long vars_length, const fmpz_mpoly_ctx_t ctx) + # Set *g* to the GCD of the coefficients of *A* when viewed as a polynomial in the variables *vars*. + # Return `1` for success and `0` for failure. Upon success, *g* will be independent of the variables *vars*. + + int fmpz_mpoly_gcd(fmpz_mpoly_t G, const fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_mpoly_ctx_t ctx) + # Try to set *G* to the GCD of *A* and *B* with positive leading coefficient. The GCD of zero and zero is defined to be zero. + # If the return is `1` the function was successful. Otherwise the return is `0` and *G* is left untouched. + + int fmpz_mpoly_gcd_cofactors(fmpz_mpoly_t G, fmpz_mpoly_t Abar, fmpz_mpoly_t Bbar, const fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_mpoly_ctx_t ctx) + # Do the operation of :func:`fmpz_mpoly_gcd` and also compute `Abar = A/G` and `Bbar = B/G` if successful. + + int fmpz_mpoly_gcd_brown(fmpz_mpoly_t G, const fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_mpoly_ctx_t ctx) + int fmpz_mpoly_gcd_hensel(fmpz_mpoly_t G, const fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_mpoly_ctx_t ctx) + int fmpz_mpoly_gcd_subresultant(fmpz_mpoly_t G, const fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_mpoly_ctx_t ctx) + int fmpz_mpoly_gcd_zippel(fmpz_mpoly_t G, const fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_mpoly_ctx_t ctx) + int fmpz_mpoly_gcd_zippel2(fmpz_mpoly_t G, const fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_mpoly_ctx_t ctx) + # Try to set *G* to the GCD of *A* and *B* using various algorithms. + + int fmpz_mpoly_resultant(fmpz_mpoly_t R, const fmpz_mpoly_t A, const fmpz_mpoly_t B, long var, const fmpz_mpoly_ctx_t ctx) + # Try to set *R* to the resultant of *A* and *B* with respect to the variable of index *var*. + + int fmpz_mpoly_discriminant(fmpz_mpoly_t D, const fmpz_mpoly_t A, long var, const fmpz_mpoly_ctx_t ctx) + # Try to set *D* to the discriminant of *A* with respect to the variable of index *var*. + + void fmpz_mpoly_primitive_part(fmpz_mpoly_t res, const fmpz_mpoly_t f, const fmpz_mpoly_ctx_t ctx) + # Sets *res* to the primitive part of *f*, obtained by dividing + # out the content of all coefficients and normalizing the leading + # coefficient to be positive. The zero polynomial is unchanged. + + int fmpz_mpoly_sqrt_heap(fmpz_mpoly_t Q, const fmpz_mpoly_t A, const fmpz_mpoly_ctx_t ctx, int check) + # If *A* is a perfect square return `1` and set *Q* to the square root + # with positive leading coefficient. Otherwise return `0` and set *Q* to the + # zero polynomial. If `check = 0` the polynomial is assumed to be a perfect + # square. This can be significantly faster, but it will not detect + # non-squares with any reliability, and in the event of being passed a + # non-square the result is meaningless. + + int fmpz_mpoly_sqrt(fmpz_mpoly_t q, const fmpz_mpoly_t A, const fmpz_mpoly_ctx_t ctx) + # If *A* is a perfect square return `1` and set *Q* to the square root + # with positive leading coefficient. Otherwise return `0` and set *Q* to zero. + + int fmpz_mpoly_is_square(const fmpz_mpoly_t A, const fmpz_mpoly_ctx_t ctx) + # Return `1` if *A* is a perfect square, otherwise return `0`. + + void fmpz_mpoly_univar_init(fmpz_mpoly_univar_t A, const fmpz_mpoly_ctx_t ctx) + # Initialize *A*. + + void fmpz_mpoly_univar_clear(fmpz_mpoly_univar_t A, const fmpz_mpoly_ctx_t ctx) + # Clear *A*. + + void fmpz_mpoly_univar_swap(fmpz_mpoly_univar_t A, fmpz_mpoly_univar_t B, const fmpz_mpoly_ctx_t ctx) + # Swap *A* and *B*. + + void fmpz_mpoly_to_univar(fmpz_mpoly_univar_t A, const fmpz_mpoly_t B, long var, const fmpz_mpoly_ctx_t ctx) + # Set *A* to a univariate form of *B* by pulling out the variable of index *var*. + # The coefficients of *A* will still belong to the content *ctx* but will not depend on the variable of index *var*. + + void fmpz_mpoly_from_univar(fmpz_mpoly_t A, const fmpz_mpoly_univar_t B, long var, const fmpz_mpoly_ctx_t ctx) + # Set *A* to the normal form of *B* by putting in the variable of index *var*. + # This function is undefined if the coefficients of *B* depend on the variable of index *var*. + + int fmpz_mpoly_univar_degree_fits_si(const fmpz_mpoly_univar_t A, const fmpz_mpoly_ctx_t ctx) + # Return `1` if the degree of *A* with respect to the main variable fits an ``slong``. Otherwise, return `0`. + + long fmpz_mpoly_univar_length(const fmpz_mpoly_univar_t A, const fmpz_mpoly_ctx_t ctx) + # Return the number of terms in *A* with respect to the main variable. + + long fmpz_mpoly_univar_get_term_exp_si(fmpz_mpoly_univar_t A, long i, const fmpz_mpoly_ctx_t ctx) + # Return the exponent of the term of index *i* of *A*. + + void fmpz_mpoly_univar_get_term_coeff(fmpz_mpoly_t c, const fmpz_mpoly_univar_t A, long i, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_univar_swap_term_coeff(fmpz_mpoly_t c, fmpz_mpoly_univar_t A, long i, const fmpz_mpoly_ctx_t ctx) + # Set (resp. swap) *c* to (resp. with) the coefficient of the term of index *i* of *A*. + + void fmpz_mpoly_inflate(fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz * shift, const fmpz * stride, const fmpz_mpoly_ctx_t ctx) + # Apply the function ``e -> shift[v] + stride[v]*e`` to each exponent ``e`` corresponding to the variable ``v``. + # It is assumed that each shift and stride is not negative. + + void fmpz_mpoly_deflate(fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz * shift, const fmpz * stride, const fmpz_mpoly_ctx_t ctx) + # Apply the function ``e -> (e - shift[v])/stride[v]`` to each exponent ``e`` corresponding to the variable ``v``. + # If any ``stride[v]`` is zero, the corresponding numerator ``e - shift[v]`` is assumed to be zero, and the quotient is defined as zero. + # This allows the function to undo the operation performed by :func:`fmpz_mpoly_inflate` when possible. + + void fmpz_mpoly_deflation(fmpz * shift, fmpz * stride, const fmpz_mpoly_t A, const fmpz_mpoly_ctx_t ctx) + # For each variable `v` let `S_v` be the set of exponents appearing on `v`. + # Set ``shift[v]`` to `\operatorname{min}(S_v)` and set ``stride[v]`` to `\operatorname{gcd}(S-\operatorname{min}(S_v))`. + # If *A* is zero, all shifts and strides are set to zero. + + void fmpz_mpoly_pow_fps(fmpz_mpoly_t A, const fmpz_mpoly_t B, unsigned long k, const fmpz_mpoly_ctx_t ctx) + # Set *A* to *B* raised to the *k*-th power, using the Monagan and Pearce FPS algorithm. + # It is assumed that *B* is not zero and `k \geq 2`. + + long _fmpz_mpoly_divides_array(fmpz ** poly1, unsigned long ** exp1, long * alloc, const fmpz * poly2, const unsigned long * exp2, long len2, const fmpz * poly3, const unsigned long * exp3, long len3, long * mults, long num, long bits) + # Use dense array exact division to set ``(poly1, exp1, alloc)`` to + # ``(poly2, exp3, len2)`` divided by ``(poly3, exp3, len3)`` in + # ``num`` variables, given a list of multipliers to tightly pack exponents + # and a number of bits for the fields of the exponents of the result. The + # array "mults" is a list of bases to be used in encoding the array indices + # from the exponents. The function reallocates its output, hence the double + # indirection, and returns the length of its output if the quotient is exact, + # or zero if not. It is assumed that ``poly2`` is not zero. No aliasing is + # allowed. + + int fmpz_mpoly_divides_array(fmpz_mpoly_t poly1, const fmpz_mpoly_t poly2, const fmpz_mpoly_t poly3, const fmpz_mpoly_ctx_t ctx) + # Set ``poly1`` to ``poly2`` divided by ``poly3``, using a big dense + # array to accumulate coefficients, and return 1 if the quotient is exact. + # Otherwise, return 0 if the quotient is not exact. If the array will be + # larger than some internally set parameter, the function fails silently and + # returns `-1` so that some other method may be called. This function is most + # efficient on dense inputs. Note that the function + # ``fmpz_mpoly_div_monagan_pearce`` below may be much faster if the + # quotient is known to be exact. + + long _fmpz_mpoly_divides_monagan_pearce(fmpz ** poly1, unsigned long ** exp1, long * alloc, const fmpz * poly2, const unsigned long * exp2, long len2, const fmpz * poly3, const unsigned long * exp3, long len3, unsigned long bits, long N, const mp_limb_t *cmpmask) + # Set ``(poly1, exp1, alloc)`` to ``(poly2, exp3, len2)`` divided by + # ``(poly3, exp3, len3)`` and return 1 if the quotient is exact. Otherwise + # return 0. The function assumes exponent vectors that each fit in `N` words, + # and are packed into fields of the given number of bits. Assumes input polys + # are nonzero. Implements "Polynomial division using dynamic arrays, heaps + # and packed exponents" by Michael Monagan and Roman Pearce. No aliasing is + # allowed. + + int fmpz_mpoly_divides_monagan_pearce(fmpz_mpoly_t poly1, const fmpz_mpoly_t poly2, const fmpz_mpoly_t poly3, const fmpz_mpoly_ctx_t ctx) + + int fmpz_mpoly_divides_heap_threaded(fmpz_mpoly_t Q, const fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_mpoly_ctx_t ctx) + # Set ``poly1`` to ``poly2`` divided by ``poly3`` and return 1 if + # the quotient is exact. Otherwise return 0. The function uses the algorithm + # of Michael Monagan and Roman Pearce. Note that the function + # ``fmpz_mpoly_div_monagan_pearce`` below may be much faster if the + # quotient is known to be exact. + # The threaded version takes an upper limit on the number of threads to use, while the first version always uses one thread. + + long _fmpz_mpoly_div_monagan_pearce(fmpz ** polyq, unsigned long ** expq, long * allocq, const fmpz * poly2, const unsigned long * exp2, long len2, const fmpz * poly3, const unsigned long * exp3, long len3, long bits, long N, const mp_limb_t *cmpmask) + # Set ``(polyq, expq, allocq)`` to the quotient of + # ``(poly2, exp2, len2)`` by ``(poly3, exp3, len3)`` discarding + # remainder (with notional remainder coefficients reduced modulo the leading + # coefficient of ``(poly3, exp3, len3)``), and return the length of the + # quotient. The function reallocates its output, hence the double + # indirection. The function assumes the exponent vectors all fit in `N` + # words. The exponent vectors are assumed to have fields with the given + # number of bits. Assumes input polynomials are nonzero. Implements + # "Polynomial division using dynamic arrays, heaps and packed exponents" by + # Michael Monagan and Roman Pearce. No aliasing is allowed. + + void fmpz_mpoly_div_monagan_pearce(fmpz_mpoly_t polyq, const fmpz_mpoly_t poly2, const fmpz_mpoly_t poly3, const fmpz_mpoly_ctx_t ctx) + # Set ``polyq`` to the quotient of ``poly2`` by ``poly3``, + # discarding the remainder (with notional remainder coefficients reduced + # modulo the leading coefficient of ``poly3``). Implements "Polynomial + # division using dynamic arrays, heaps and packed exponents" by Michael + # Monagan and Roman Pearce. This function is exceptionally efficient if the + # division is known to be exact. + + long _fmpz_mpoly_divrem_monagan_pearce(long * lenr, fmpz ** polyq, unsigned long ** expq, long * allocq, fmpz ** polyr, unsigned long ** expr, long * allocr, const fmpz * poly2, const unsigned long * exp2, long len2, const fmpz * poly3, const unsigned long * exp3, long len3, long bits, long N, const mp_limb_t *cmpmask) + # Set ``(polyq, expq, allocq)`` and ``(polyr, expr, allocr)`` to the + # quotient and remainder of ``(poly2, exp2, len2)`` by + # ``(poly3, exp3, len3)`` (with remainder coefficients reduced modulo the + # leading coefficient of ``(poly3, exp3, len3)``), and return the length + # of the quotient. The function reallocates its outputs, hence the double + # indirection. The function assumes the exponent vectors all fit in `N` + # words. The exponent vectors are assumed to have fields with the given + # number of bits. Assumes input polynomials are nonzero. Implements + # "Polynomial division using dynamic arrays, heaps and packed exponents" by + # Michael Monagan and Roman Pearce. No aliasing is allowed. + + void fmpz_mpoly_divrem_monagan_pearce(fmpz_mpoly_t q, fmpz_mpoly_t r, const fmpz_mpoly_t poly2, const fmpz_mpoly_t poly3, const fmpz_mpoly_ctx_t ctx) + # Set ``polyq`` and ``polyr`` to the quotient and remainder of + # ``poly2`` divided by ``poly3`` (with remainder coefficients reduced + # modulo the leading coefficient of ``poly3``). Implements "Polynomial + # division using dynamic arrays, heaps and packed exponents" by Michael + # Monagan and Roman Pearce. + + long _fmpz_mpoly_divrem_array(long * lenr, fmpz ** polyq, unsigned long ** expq, long * allocq, fmpz ** polyr, unsigned long ** expr, long * allocr, const fmpz * poly2, const unsigned long * exp2, long len2, const fmpz * poly3, const unsigned long * exp3, long len3, long * mults, long num, long bits) + # Use dense array division to set ``(polyq, expq, allocq)`` and + # ``(polyr, expr, allocr)`` to the quotient and remainder of + # ``(poly2, exp2, len2)`` divided by ``(poly3, exp3, len3)`` in + # ``num`` variables, given a list of multipliers to tightly pack + # exponents and a number of bits for the fields of the exponents of the + # result. The function reallocates its outputs, hence the double indirection. + # The array ``mults`` is a list of bases to be used in encoding the array + # indices from the exponents. The function returns the length of the + # quotient. It is assumed that the input polynomials are not zero. No + # aliasing is allowed. + + int fmpz_mpoly_divrem_array(fmpz_mpoly_t q, fmpz_mpoly_t r, const fmpz_mpoly_t poly2, const fmpz_mpoly_t poly3, const fmpz_mpoly_ctx_t ctx) + # Set ``polyq`` and ``polyr`` to the quotient and remainder of + # ``poly2`` divided by ``poly3`` (with remainder coefficients reduced + # modulo the leading coefficient of ``poly3``). The function is + # implemented using dense arrays, and is efficient when the inputs are fairly + # dense. If the array will be larger than some internally set parameter, the + # function silently returns 0 so that another function can be called, + # otherwise it returns 1. + + void fmpz_mpoly_quasidivrem_heap(fmpz_t scale, fmpz_mpoly_t q, fmpz_mpoly_t r, const fmpz_mpoly_t poly2, const fmpz_mpoly_t poly3, const fmpz_mpoly_ctx_t ctx) + # Set ``scale``, ``q`` and ``r`` so that + # ``scale*poly2 = q*poly3 + r`` and no monomial in ``r`` is divisible + # by the leading monomial of ``poly3``, where ``scale`` is positive + # and as small as possible. This function throws an exception if + # ``poly3`` is zero or if an exponent overflow occurs. + + long _fmpz_mpoly_divrem_ideal_monagan_pearce(fmpz_mpoly_struct ** polyq, fmpz ** polyr, unsigned long ** expr, long * allocr, const fmpz * poly2, const unsigned long * exp2, long len2, fmpz_mpoly_struct * const * poly3, unsigned long * const * exp3, long len, long N, long bits, const fmpz_mpoly_ctx_t ctx, const mp_limb_t *cmpmask) + # This function is as per ``_fmpz_mpoly_divrem_monagan_pearce`` except + # that it takes an array of divisor polynomials ``poly3`` and an array of + # repacked exponent arrays ``exp3``, which may alias the exponent arrays + # of ``poly3``, and it returns an array of quotient polynomials + # ``polyq``. The number of divisor (and hence quotient) polynomials is + # given by ``len``. The function computes polynomials `q_i` such that + # `r = a - \sum_{i=0}^{\mbox{len - 1}} q_ib_i`, where the `q_i` are the + # quotient polynomials and the `b_i` are the divisor polynomials. + + void fmpz_mpoly_divrem_ideal_monagan_pearce(fmpz_mpoly_struct ** q, fmpz_mpoly_t r, const fmpz_mpoly_t poly2, fmpz_mpoly_struct * const * poly3, long len, const fmpz_mpoly_ctx_t ctx) + # This function is as per ``fmpz_mpoly_divrem_monagan_pearce`` except + # that it takes an array of divisor polynomials ``poly3``, and it returns + # an array of quotient polynomials ``q``. The number of divisor (and hence + # quotient) polynomials is given by ``len``. The function computes + # polynomials `q_i = q[i]` such that ``poly2`` is + # `r + \sum_{i=0}^{\mbox{len - 1}} q_ib_i`, where `b_i =` ``poly3[i]``. + + void fmpz_mpoly_vec_init(fmpz_mpoly_vec_t vec, long len, const fmpz_mpoly_ctx_t ctx) + # Initializes *vec* to a vector of length *len*, setting all entries to the zero polynomial. + + void fmpz_mpoly_vec_clear(fmpz_mpoly_vec_t vec, const fmpz_mpoly_ctx_t ctx) + # Clears *vec*, freeing its allocated memory. + + void fmpz_mpoly_vec_print(const fmpz_mpoly_vec_t vec, const fmpz_mpoly_ctx_t ctx) + # Prints *vec* to standard output. + + void fmpz_mpoly_vec_swap(fmpz_mpoly_vec_t x, fmpz_mpoly_vec_t y, const fmpz_mpoly_ctx_t ctx) + # Swaps *x* and *y* efficiently. + + void fmpz_mpoly_vec_fit_length(fmpz_mpoly_vec_t vec, long len, const fmpz_mpoly_ctx_t ctx) + # Allocates room for *len* entries in *vec*. + + void fmpz_mpoly_vec_set(fmpz_mpoly_vec_t dest, const fmpz_mpoly_vec_t src, const fmpz_mpoly_ctx_t ctx) + # Sets *dest* to a copy of *src*. + + void fmpz_mpoly_vec_append(fmpz_mpoly_vec_t vec, const fmpz_mpoly_t f, const fmpz_mpoly_ctx_t ctx) + # Appends *f* to the end of *vec*. + + long fmpz_mpoly_vec_insert_unique(fmpz_mpoly_vec_t vec, const fmpz_mpoly_t f, const fmpz_mpoly_ctx_t ctx) + # Inserts *f* without duplication into *vec* and returns its index. + # If this polynomial already exists, *vec* is unchanged. If this + # polynomial does not exist in *vec*, it is appended. + + void fmpz_mpoly_vec_set_length(fmpz_mpoly_vec_t vec, long len, const fmpz_mpoly_ctx_t ctx) + # Sets the length of *vec* to *len*, truncating or zero-extending + # as needed. + + void fmpz_mpoly_vec_randtest_not_zero(fmpz_mpoly_vec_t vec, flint_rand_t state, long len, long poly_len, long bits, unsigned long exp_bound, fmpz_mpoly_ctx_t ctx) + # Sets *vec* to a random vector with exactly *len* entries, all nonzero, + # with random parameters defined by *poly_len*, *bits* and *exp_bound*. + + void fmpz_mpoly_vec_set_primitive_unique(fmpz_mpoly_vec_t res, const fmpz_mpoly_vec_t src, const fmpz_mpoly_ctx_t ctx) + # Sets *res* to a vector containing all polynomials in *src* reduced + # to their primitive parts, without duplication. The zero polynomial + # is skipped if present. The output order is arbitrary. + + void fmpz_mpoly_spoly(fmpz_mpoly_t res, const fmpz_mpoly_t f, const fmpz_mpoly_t g, const fmpz_mpoly_ctx_t ctx) + # Sets *res* to the *S*-polynomial of *f* and *g*, scaled to + # an integer polynomial by computing the LCM of the leading coefficients. + + void fmpz_mpoly_reduction_primitive_part(fmpz_mpoly_t res, const fmpz_mpoly_t f, const fmpz_mpoly_vec_t vec, const fmpz_mpoly_ctx_t ctx) + # Sets *res* to the primitive part of the reduction (remainder of multivariate + # quasidivision with remainder) with respect to the polynomials *vec*. + + int fmpz_mpoly_vec_is_groebner(const fmpz_mpoly_vec_t G, const fmpz_mpoly_vec_t F, const fmpz_mpoly_ctx_t ctx) + # If *F* is *NULL*, checks if *G* is a Gröbner basis. If *F* is not *NULL*, + # checks if *G* is a Gröbner basis for *F*. + + int fmpz_mpoly_vec_is_autoreduced(const fmpz_mpoly_vec_t F, const fmpz_mpoly_ctx_t ctx) + # Checks whether the vector *F* is autoreduced (or inter-reduced). + + void fmpz_mpoly_vec_autoreduction(fmpz_mpoly_vec_t H, const fmpz_mpoly_vec_t F, const fmpz_mpoly_ctx_t ctx) + # Sets *H* to the autoreduction (inter-reduction) of *F*. + + void fmpz_mpoly_vec_autoreduction_groebner(fmpz_mpoly_vec_t H, const fmpz_mpoly_vec_t G, const fmpz_mpoly_ctx_t ctx) + # Sets *H* to the autoreduction (inter-reduction) of *G*. + # Assumes that *G* is a Gröbner basis. + # This produces a reduced Gröbner basis, which is unique + # (up to the sort order of the entries in the vector). + + pair_t fmpz_mpoly_select_pop_pair(pairs_t pairs, const fmpz_mpoly_vec_t G, const fmpz_mpoly_ctx_t ctx) + # Given a vector *pairs* of indices `(i, j)` into *G*, selects one pair + # for elimination in Buchberger's algorithm. The pair is removed + # from *pairs* and returned. + + void fmpz_mpoly_buchberger_naive(fmpz_mpoly_vec_t G, const fmpz_mpoly_vec_t F, const fmpz_mpoly_ctx_t ctx) + # Sets *G* to a Gröbner basis for *F*, computed using + # a naive implementation of Buchberger's algorithm. + + int fmpz_mpoly_buchberger_naive_with_limits(fmpz_mpoly_vec_t G, const fmpz_mpoly_vec_t F, long ideal_len_limit, long poly_len_limit, long poly_bits_limit, const fmpz_mpoly_ctx_t ctx) + # As :func:`fmpz_mpoly_buchberger_naive`, but halts if during the + # execution of Buchberger's algorithm the length of the + # ideal basis set exceeds *ideal_len_limit*, the length of any + # polynomial exceeds *poly_len_limit*, or the size of the + # coefficients of any polynomial exceeds *poly_bits_limit*. + # Returns 1 for success and 0 for failure. On failure, *G* is + # a valid basis for *F* but it might not be a Gröbner basis. + + void fmpz_mpoly_symmetric_gens(fmpz_mpoly_t res, unsigned long k, long * vars, long n, const fmpz_mpoly_ctx_t ctx) + + void fmpz_mpoly_symmetric(fmpz_mpoly_t res, unsigned long k, const fmpz_mpoly_ctx_t ctx) + # Sets *res* to the elementary symmetric polynomial + # `e_k(X_1,\ldots,X_n)`. + # The *gens* version takes `X_1,\ldots,X_n` to be the subset of + # generators given by *vars* and *n*. + # The indices in *vars* start from zero. + # Currently, the indices in *vars* must be distinct. diff --git a/src/sage/libs/flint/fmpz_mpoly_factor.pxd b/src/sage/libs/flint/fmpz_mpoly_factor.pxd new file mode 100644 index 00000000000..0903fc4ac6e --- /dev/null +++ b/src/sage/libs/flint/fmpz_mpoly_factor.pxd @@ -0,0 +1,48 @@ +# distutils: libraries = flint +# distutils: depends = flint/fmpz_mpoly_factor.h + +################################################################################ +# This file is auto-generated. Do not modify by hand +################################################################################ + +from libc.stdio cimport FILE +from sage.libs.gmp.types cimport * +from sage.libs.mpfr.types cimport * +from sage.libs.flint.types cimport * + +cdef extern from "flint_wrap.h": + + void fmpz_mpoly_factor_init(fmpz_mpoly_factor_t f, const fmpz_mpoly_ctx_t ctx) + # Initialise *f*. + + void fmpz_mpoly_factor_clear(fmpz_mpoly_factor_t f, const fmpz_mpoly_ctx_t ctx) + # Clear *f*. + + void fmpz_mpoly_factor_swap(fmpz_mpoly_factor_t f, fmpz_mpoly_factor_t g, const fmpz_mpoly_ctx_t ctx) + # Efficiently swap *f* and *g*. + + long fmpz_mpoly_factor_length(const fmpz_mpoly_factor_t f, const fmpz_mpoly_ctx_t ctx) + # Return the length of the product in *f*. + + void fmpz_mpoly_factor_get_constant_fmpz(fmpz_t c, const fmpz_mpoly_factor_t f, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_factor_get_constant_fmpq(fmpq_t c, const fmpz_mpoly_factor_t f, const fmpz_mpoly_ctx_t ctx) + # Set `c` to the constant of *f*. + + void fmpz_mpoly_factor_get_base(fmpz_mpoly_t B, const fmpz_mpoly_factor_t f, long i, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_factor_swap_base(fmpz_mpoly_t B, fmpz_mpoly_factor_t f, long i, const fmpz_mpoly_ctx_t ctx) + # Set (resp. swap) *B* to (resp. with) the base of the term of index `i` in *A*. + + long fmpz_mpoly_factor_get_exp_si(fmpz_mpoly_factor_t f, long i, const fmpz_mpoly_ctx_t ctx) + # Return the exponent of the term of index `i` in *A*. It is assumed to fit an ``slong``. + + void fmpz_mpoly_factor_sort(fmpz_mpoly_factor_t f, const fmpz_mpoly_ctx_t ctx) + # Sort the product of *f* first by exponent and then by base. + + int fmpz_mpoly_factor_squarefree(fmpz_mpoly_factor_t f, const fmpz_mpoly_t A, const fmpz_mpoly_ctx_t ctx) + # Set *f* to a factorization of *A* where the bases are primitive and + # pairwise relatively prime. If the product of all irreducible factors with + # a given exponent is desired, it is recommended to call :func:`fmpz_mpoly_factor_sort` + # and then multiply the bases with the desired exponent. + + int fmpz_mpoly_factor(fmpz_mpoly_factor_t f, const fmpz_mpoly_t A, const fmpz_mpoly_ctx_t ctx) + # Set *f* to a factorization of *A* where the bases are irreducible. diff --git a/src/sage/libs/flint/fmpz_mpoly_q.pxd b/src/sage/libs/flint/fmpz_mpoly_q.pxd new file mode 100644 index 00000000000..8259ea4d8c1 --- /dev/null +++ b/src/sage/libs/flint/fmpz_mpoly_q.pxd @@ -0,0 +1,112 @@ +# distutils: libraries = flint +# distutils: depends = flint/fmpz_mpoly_q.h + +################################################################################ +# This file is auto-generated. Do not modify by hand +################################################################################ + +from libc.stdio cimport FILE +from sage.libs.gmp.types cimport * +from sage.libs.mpfr.types cimport * +from sage.libs.flint.types cimport * + +cdef extern from "flint_wrap.h": + + void fmpz_mpoly_q_init(fmpz_mpoly_q_t res, const fmpz_mpoly_ctx_t ctx) + # Initializes *res* for use, and sets its value to zero. + + void fmpz_mpoly_q_clear(fmpz_mpoly_q_t res, const fmpz_mpoly_ctx_t ctx) + # Clears *res*, freeing or recycling its allocated memory. + + void fmpz_mpoly_q_swap(fmpz_mpoly_q_t x, fmpz_mpoly_q_t y, const fmpz_mpoly_ctx_t ctx) + # Swaps the values of *x* and *y* efficiently. + + void fmpz_mpoly_q_set(fmpz_mpoly_q_t res, const fmpz_mpoly_q_t x, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_q_set_fmpq(fmpz_mpoly_q_t res, const fmpq_t x, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_q_set_fmpz(fmpz_mpoly_q_t res, const fmpz_t x, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_q_set_si(fmpz_mpoly_q_t res, long x, const fmpz_mpoly_ctx_t ctx) + # Sets *res* to the value *x*. + + void fmpz_mpoly_q_canonicalise(fmpz_mpoly_q_t x, const fmpz_mpoly_ctx_t ctx) + # Puts the numerator and denominator of *x* in canonical form by removing + # common content and making the leading term of the denominator positive. + + int fmpz_mpoly_q_is_canonical(const fmpz_mpoly_q_t x, const fmpz_mpoly_ctx_t ctx) + # Returns whether *x* is in canonical form. + # In addition to verifying that the numerator and denominator + # have no common content and that the leading term of the denominator + # is positive, this function checks that the denominator is nonzero and that + # the numerator and denominator have correctly sorted terms + # (these properties should normally hold; verifying them + # provides an extra consistency check for test code). + + int fmpz_mpoly_q_is_zero(const fmpz_mpoly_q_t x, const fmpz_mpoly_ctx_t ctx) + # Returns whether *x* is the constant 0. + + int fmpz_mpoly_q_is_one(const fmpz_mpoly_q_t x, const fmpz_mpoly_ctx_t ctx) + # Returns whether *x* is the constant 1. + + void fmpz_mpoly_q_used_vars(int * used, const fmpz_mpoly_q_t f, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_q_used_vars_num(int * used, const fmpz_mpoly_q_t f, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_q_used_vars_den(int * used, const fmpz_mpoly_q_t f, const fmpz_mpoly_ctx_t ctx) + # For each variable, sets the corresponding entry in *used* to the + # boolean flag indicating whether that variable appears in the + # rational function (respectively its numerator or denominator). + + void fmpz_mpoly_q_zero(fmpz_mpoly_q_t res, const fmpz_mpoly_ctx_t ctx) + # Sets *res* to the constant 0. + + void fmpz_mpoly_q_one(fmpz_mpoly_q_t res, const fmpz_mpoly_ctx_t ctx) + # Sets *res* to the constant 1. + + void fmpz_mpoly_q_gen(fmpz_mpoly_q_t res, long i, const fmpz_mpoly_ctx_t ctx) + # Sets *res* to the generator `x_{i+1}`. + # Requires `0 \le i < n` where *n* is the number of variables of *ctx*. + + void fmpz_mpoly_q_print_pretty(const fmpz_mpoly_q_t f, const char ** x, const fmpz_mpoly_ctx_t ctx) + # Prints *res* to standard output. If *x* is not *NULL*, the strings in + # *x* are used as the symbols for the variables. + + void fmpz_mpoly_q_randtest(fmpz_mpoly_q_t res, flint_rand_t state, long length, mp_limb_t coeff_bits, long exp_bound, const fmpz_mpoly_ctx_t ctx) + # Sets *res* to a random rational function where both numerator and denominator + # have up to *length* terms, coefficients up to size *coeff_bits*, and + # exponents strictly smaller than *exp_bound*. + + int fmpz_mpoly_q_equal(const fmpz_mpoly_q_t x, const fmpz_mpoly_q_t y, const fmpz_mpoly_ctx_t ctx) + # Returns whether *x* and *y* are equal. + + void fmpz_mpoly_q_neg(fmpz_mpoly_q_t res, const fmpz_mpoly_q_t x, const fmpz_mpoly_ctx_t ctx) + # Sets *res* to the negation of *x*. + + void fmpz_mpoly_q_add(fmpz_mpoly_q_t res, const fmpz_mpoly_q_t x, const fmpz_mpoly_q_t y, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_q_add_fmpq(fmpz_mpoly_q_t res, const fmpz_mpoly_q_t x, const fmpq_t y, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_q_add_fmpz(fmpz_mpoly_q_t res, const fmpz_mpoly_q_t x, const fmpz_t y, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_q_add_si(fmpz_mpoly_q_t res, const fmpz_mpoly_q_t x, long y, const fmpz_mpoly_ctx_t ctx) + # Sets *res* to the sum of *x* and *y*. + + void fmpz_mpoly_q_sub(fmpz_mpoly_q_t res, const fmpz_mpoly_q_t x, const fmpz_mpoly_q_t y, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_q_sub_fmpq(fmpz_mpoly_q_t res, const fmpz_mpoly_q_t x, const fmpq_t y, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_q_sub_fmpz(fmpz_mpoly_q_t res, const fmpz_mpoly_q_t x, const fmpz_t y, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_q_sub_si(fmpz_mpoly_q_t res, const fmpz_mpoly_q_t x, long y, const fmpz_mpoly_ctx_t ctx) + # Sets *res* to the difference of *x* and *y*. + + void fmpz_mpoly_q_mul(fmpz_mpoly_q_t res, const fmpz_mpoly_q_t x, const fmpz_mpoly_q_t y, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_q_mul_fmpq(fmpz_mpoly_q_t res, const fmpz_mpoly_q_t x, const fmpq_t y, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_q_mul_fmpz(fmpz_mpoly_q_t res, const fmpz_mpoly_q_t x, const fmpz_t y, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_q_mul_si(fmpz_mpoly_q_t res, const fmpz_mpoly_q_t x, long y, const fmpz_mpoly_ctx_t ctx) + # Sets *res* to the product of *x* and *y*. + + void fmpz_mpoly_q_div(fmpz_mpoly_q_t res, const fmpz_mpoly_q_t x, const fmpz_mpoly_q_t y, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_q_div_fmpq(fmpz_mpoly_q_t res, const fmpz_mpoly_q_t x, const fmpq_t y, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_q_div_fmpz(fmpz_mpoly_q_t res, const fmpz_mpoly_q_t x, const fmpz_t y, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_q_div_si(fmpz_mpoly_q_t res, const fmpz_mpoly_q_t x, long y, const fmpz_mpoly_ctx_t ctx) + # Sets *res* to the quotient of *x* and *y*. + # Division by zero calls *flint_abort*. + + void fmpz_mpoly_q_inv(fmpz_mpoly_q_t res, const fmpz_mpoly_q_t x, const fmpz_mpoly_ctx_t ctx) + # Sets *res* to the inverse of *x*. Division by zero + # calls *flint_abort*. + + void _fmpz_mpoly_q_content(fmpz_t num, fmpz_t den, const fmpz_mpoly_t xnum, const fmpz_mpoly_t xden, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_q_content(fmpq_t res, const fmpz_mpoly_q_t x, const fmpz_mpoly_ctx_t ctx) + # Sets *res* to the content of the coefficients of *x*. diff --git a/src/sage/libs/flint/fmpz_poly.pxd b/src/sage/libs/flint/fmpz_poly.pxd index c8bc6d3ca0a..e87c1fe0fbc 100644 --- a/src/sage/libs/flint/fmpz_poly.pxd +++ b/src/sage/libs/flint/fmpz_poly.pxd @@ -1,324 +1,2492 @@ # distutils: libraries = flint # distutils: depends = flint/fmpz_poly.h +################################################################################ +# This file is auto-generated. Do not modify by hand +################################################################################ + from libc.stdio cimport FILE -from sage.libs.gmp.types cimport mpz_t +from sage.libs.gmp.types cimport * +from sage.libs.mpfr.types cimport * from sage.libs.flint.types cimport * -# flint/fmpz_poly.h cdef extern from "flint_wrap.h": - # Memory management - void fmpz_poly_init(fmpz_poly_t) - void fmpz_poly_init2(fmpz_poly_t, slong) - - void fmpz_poly_realloc(fmpz_poly_t, slong) - void _fmpz_poly_set_length(fmpz_poly_t, long) - - void fmpz_poly_fit_length(fmpz_poly_t, slong) - - void fmpz_poly_clear(fmpz_poly_t) - void _fmpz_poly_normalise(fmpz_poly_t) - - # Polynomial parameters - slong fmpz_poly_length(const fmpz_poly_t) - slong fmpz_poly_degree(const fmpz_poly_t) - - # Assignment and basic manipulation - void fmpz_poly_set(fmpz_poly_t, const fmpz_poly_t) - void fmpz_poly_set_ui(fmpz_poly_t, ulong) - void fmpz_poly_set_si(fmpz_poly_t, slong) - void fmpz_poly_set_fmpz(fmpz_poly_t, const fmpz_t) - int fmpz_poly_set_str(fmpz_poly_t, const char *) - - char *fmpz_poly_get_str(const fmpz_poly_t) - char *fmpz_poly_get_str_pretty(const fmpz_poly_t, const char *) - - void fmpz_poly_zero(fmpz_poly_t) - void fmpz_poly_one(fmpz_poly_t) - - void fmpz_poly_zero_coeffs(fmpz_poly_t, slong, slong) - - void fmpz_poly_reverse(fmpz_poly_t, const fmpz_poly_t, slong) - - void fmpz_poly_truncate(fmpz_poly_t, slong) - - # Getting and setting coefficients - void fmpz_poly_get_coeff_fmpz(fmpz_t, const fmpz_poly_t, slong) - slong fmpz_poly_get_coeff_si(const fmpz_poly_t, slong) - ulong fmpz_poly_get_coeff_ui(const fmpz_poly_t, slong) - - fmpz *fmpz_poly_get_coeff_ptr(const fmpz_poly_t, slong) - fmpz *fmpz_poly_lead(const fmpz_poly_t) - - void fmpz_poly_set_coeff_fmpz(fmpz_poly_t, slong, const fmpz_t) - void fmpz_poly_set_coeff_si(fmpz_poly_t, slong, slong) - void fmpz_poly_set_coeff_ui(fmpz_poly_t, slong, ulong) - - # Comparison - int fmpz_poly_equal(const fmpz_poly_t, const fmpz_poly_t) - int fmpz_poly_is_zero(const fmpz_poly_t) - int fmpz_poly_is_one(const fmpz_poly_t) - int fmpz_poly_is_unit(const fmpz_poly_t) - int fmpz_poly_equal_fmpz(const fmpz_poly_t, const fmpz_t) - - # Addition and subtraction - void fmpz_poly_add(fmpz_poly_t, const fmpz_poly_t, const fmpz_poly_t) - void fmpz_poly_sub(fmpz_poly_t, const fmpz_poly_t, const fmpz_poly_t) - void fmpz_poly_neg(fmpz_poly_t, const fmpz_poly_t) - - # Scalar multiplication and division - void fmpz_poly_scalar_mul_fmpz( - fmpz_poly_t, const fmpz_poly_t, const fmpz_t) - void fmpz_poly_scalar_mul_si(fmpz_poly_t, const fmpz_poly_t, slong) - void fmpz_poly_scalar_mul_ui(fmpz_poly_t, const fmpz_poly_t, ulong) - void fmpz_poly_scalar_mul_2exp(fmpz_poly_t, const fmpz_poly_t, ulong) - - void fmpz_poly_scalar_addmul_fmpz( - fmpz_poly_t, const fmpz_poly_t, const fmpz_t) - void fmpz_poly_scalar_submul_fmpz( - fmpz_poly_t, const fmpz_poly_t, const fmpz_t) - - void fmpz_poly_scalar_fdiv_fmpz( - fmpz_poly_t, const fmpz_poly_t, const fmpz_t) - void fmpz_poly_scalar_fdiv_si(fmpz_poly_t, const fmpz_poly_t, slong) - void fmpz_poly_scalar_fdiv_ui(fmpz_poly_t, const fmpz_poly_t, ulong) - void fmpz_poly_scalar_fdiv_2exp(fmpz_poly_t, const fmpz_poly_t, ulong) - - void fmpz_poly_scalar_tdiv_fmpz( - fmpz_poly_t, const fmpz_poly_t, const fmpz_t) - void fmpz_poly_scalar_tdiv_si(fmpz_poly_t, const fmpz_poly_t, slong) - void fmpz_poly_scalar_tdiv_ui(fmpz_poly_t, const fmpz_poly_t, ulong) - void fmpz_poly_scalar_tdiv_2exp(fmpz_poly_t, const fmpz_poly_t, ulong) - - void fmpz_poly_scalar_divexact_fmpz( - fmpz_poly_t, const fmpz_poly_t, const fmpz_t) - void fmpz_poly_scalar_divexact_si(fmpz_poly_t, const fmpz_poly_t, slong) - void fmpz_poly_scalar_divexact_ui(fmpz_poly_t, const fmpz_poly_t, ulong) - - void fmpz_poly_scalar_mod_fmpz( - fmpz_poly_t, const fmpz_poly_t, const fmpz_t) - void fmpz_poly_scalar_smod_fmpz( - fmpz_poly_t, const fmpz_poly_t, const fmpz_t) - - # Multiplication - void fmpz_poly_mul_classical( - fmpz_poly_t, const fmpz_poly_t, const fmpz_poly_t) - void fmpz_poly_mullow_classical( - fmpz_poly_t, const fmpz_poly_t, const fmpz_poly_t, slong) - void fmpz_poly_mulhigh_classical( - fmpz_poly_t, const fmpz_poly_t, const fmpz_poly_t, slong) - void fmpz_poly_mulmid_classical( - fmpz_poly_t, const fmpz_poly_t, const fmpz_poly_t) - - void fmpz_poly_mul_karatsuba( - fmpz_poly_t, const fmpz_poly_t, const fmpz_poly_t) - void fmpz_poly_mullow_karatsuba_n( - fmpz_poly_t, const fmpz_poly_t, const fmpz_poly_t, slong) - void fmpz_poly_mulhigh_karatsuba_n( - fmpz_poly_t, const fmpz_poly_t, const fmpz_poly_t, slong) - - void fmpz_poly_mul_KS(fmpz_poly_t, const fmpz_poly_t, const fmpz_poly_t) - void fmpz_poly_mullow_KS( - fmpz_poly_t, const fmpz_poly_t, const fmpz_poly_t, slong) - - void fmpz_poly_mul_SS(fmpz_poly_t, const fmpz_poly_t, const fmpz_poly_t) - void fmpz_poly_mullow_SS( - fmpz_poly_t, const fmpz_poly_t, const fmpz_poly_t, slong) - - void fmpz_poly_mul(fmpz_poly_t, const fmpz_poly_t, const fmpz_poly_t) - void fmpz_poly_mullow( - fmpz_poly_t, const fmpz_poly_t, const fmpz_poly_t, slong) - void fmpz_poly_mulhigh( - fmpz_poly_t, const fmpz_poly_t, const fmpz_poly_t, slong) - - # Squaring - void fmpz_poly_sqr(fmpz_poly_t, const fmpz_poly_t) - - void fmpz_poly_sqr_classical(fmpz_poly_t, const fmpz_poly_t) - void fmpz_poly_sqrlow_classical(fmpz_poly_t, const fmpz_poly_t, slong) - - void fmpz_poly_sqr_karatsuba(fmpz_poly_t, const fmpz_poly_t) - void fmpz_poly_sqrlow_karatsuba_n(fmpz_poly_t, const fmpz_poly_t, slong) - - void fmpz_poly_sqr_KS(fmpz_poly_t, const fmpz_poly_t) - void fmpz_poly_sqrlow_KS(fmpz_poly_t, const fmpz_poly_t, slong) - - # Powering - void fmpz_poly_pow_multinomial(fmpz_poly_t, const fmpz_poly_t, ulong) - void fmpz_poly_pow_binomial(fmpz_poly_t, const fmpz_poly_t, ulong) - void fmpz_poly_pow_addchains(fmpz_poly_t, const fmpz_poly_t, ulong) - void fmpz_poly_pow_binexp(fmpz_poly_t, const fmpz_poly_t, ulong) - void fmpz_poly_pow_small(fmpz_poly_t, const fmpz_poly_t, ulong) - void fmpz_poly_pow(fmpz_poly_t, const fmpz_poly_t, ulong) - void fmpz_poly_pow_trunc(fmpz_poly_t, const fmpz_poly_t, ulong, slong) - - # Shifting - void fmpz_poly_shift_left(fmpz_poly_t, const fmpz_poly_t, slong) - void fmpz_poly_shift_right(fmpz_poly_t, const fmpz_poly_t, slong) - - # Bit sizes and norms - ulong fmpz_poly_max_limbs(const fmpz_poly_t) - slong fmpz_poly_max_bits(const fmpz_poly_t) - void fmpz_poly_height(fmpz_t, const fmpz_poly_t) - void fmpz_poly_2norm(fmpz_t, const fmpz_poly_t) - - # Greatest common divisor - void fmpz_poly_gcd_subresultant( - fmpz_poly_t, const fmpz_poly_t, const fmpz_poly_t) - int fmpz_poly_gcd_heuristic( - fmpz_poly_t, const fmpz_poly_t, const fmpz_poly_t) - void fmpz_poly_gcd_modular( - fmpz_poly_t, const fmpz_poly_t, const fmpz_poly_t) - void fmpz_poly_gcd(fmpz_poly_t, const fmpz_poly_t, const fmpz_poly_t) - - void fmpz_poly_xgcd_modular( - fmpz_t, fmpz_poly_t, fmpz_poly_t, - const fmpz_poly_t, const fmpz_poly_t) - void fmpz_poly_xgcd( - fmpz_t, fmpz_poly_t, fmpz_poly_t, - const fmpz_poly_t, const fmpz_poly_t) - - void fmpz_poly_lcm(fmpz_poly_t, const fmpz_poly_t, const fmpz_poly_t) - void fmpz_poly_resultant(fmpz_t, const fmpz_poly_t, const fmpz_poly_t) - - # Gaussian content - void fmpz_poly_content(fmpz_t, const fmpz_poly_t) - void fmpz_poly_primitive_part(fmpz_poly_t, const fmpz_poly_t) - - # Square-free - int fmpz_poly_is_squarefree(const fmpz_poly_t) - - # Euclidean division - void fmpz_poly_divrem_basecase( - fmpz_poly_t, fmpz_poly_t, const fmpz_poly_t, const fmpz_poly_t) - void fmpz_poly_divrem_divconquer( - fmpz_poly_t, fmpz_poly_t, const fmpz_poly_t, const fmpz_poly_t) - void fmpz_poly_divrem( - fmpz_poly_t, fmpz_poly_t, const fmpz_poly_t, const fmpz_poly_t) - - void fmpz_poly_div_basecase( - fmpz_poly_t, const fmpz_poly_t, const fmpz_poly_t) - void fmpz_poly_div_divconquer( - fmpz_poly_t, const fmpz_poly_t, const fmpz_poly_t) - void fmpz_poly_div(fmpz_poly_t, const fmpz_poly_t, const fmpz_poly_t) - - void fmpz_poly_rem_basecase( - fmpz_poly_t, const fmpz_poly_t, const fmpz_poly_t) - void fmpz_poly_rem(fmpz_poly_t, const fmpz_poly_t, const fmpz_poly_t) - void fmpz_poly_div_root(fmpz_poly_t, const fmpz_poly_t, const fmpz_t) - - # Division with precomputed inverse - void fmpz_poly_preinvert(fmpz_poly_t, const fmpz_poly_t) - void fmpz_poly_div_preinv( - fmpz_poly_t, - const fmpz_poly_t, const fmpz_poly_t, const fmpz_poly_t) - void fmpz_poly_divrem_preinv( - fmpz_poly_t, fmpz_poly_t, - const fmpz_poly_t, const fmpz_poly_t, const fmpz_poly_t) - - # Power series division - void fmpz_poly_inv_series_newton(fmpz_poly_t, const fmpz_poly_t, slong) - void fmpz_poly_inv_series(fmpz_poly_t, const fmpz_poly_t, slong) - void fmpz_poly_div_series( - fmpz_poly_t, const fmpz_poly_t, const fmpz_poly_t, slong) - - # Pseudo division - void fmpz_poly_pseudo_divrem_basecase( - fmpz_poly_t, fmpz_poly_t, - ulong *, const fmpz_poly_t, const fmpz_poly_t) - void fmpz_poly_pseudo_divrem_divconquer( - fmpz_poly_t, fmpz_poly_t, - ulong *, const fmpz_poly_t, const fmpz_poly_t) - void fmpz_poly_pseudo_divrem( - fmpz_poly_t, fmpz_poly_t, - ulong *, const fmpz_poly_t, const fmpz_poly_t) - - void fmpz_poly_pseudo_div( - fmpz_poly_t, ulong *, const fmpz_poly_t, const fmpz_poly_t) - void fmpz_poly_pseudo_rem( - fmpz_poly_t, ulong *, const fmpz_poly_t, const fmpz_poly_t) - - void fmpz_poly_pseudo_divrem_cohen( - fmpz_poly_t, fmpz_poly_t, const fmpz_poly_t, const fmpz_poly_t) - void fmpz_poly_pseudo_rem_cohen( - fmpz_poly_t, const fmpz_poly_t, const fmpz_poly_t) - - # Derivative - void fmpz_poly_derivative(fmpz_poly_t, const fmpz_poly_t) - - # Evaluation - void fmpz_poly_evaluate_divconquer_fmpz( - fmpz_t, const fmpz_poly_t, const fmpz_t) - void fmpz_poly_evaluate_horner_fmpz( - fmpz_t, const fmpz_poly_t, const fmpz_t) - void fmpz_poly_evaluate_fmpz(fmpz_t, const fmpz_poly_t, const fmpz_t) - - void fmpz_poly_evaluate_horner_fmpq( - fmpq_t, const fmpz_poly_t, const fmpq_t) - void fmpz_poly_evaluate_fmpq(fmpq_t, const fmpz_poly_t, const fmpq_t) - - mp_limb_t fmpz_poly_evaluate_mod(fmpz_poly_t, mp_limb_t, mp_limb_t) - - # Composition - void fmpz_poly_compose_horner( - fmpz_poly_t, const fmpz_poly_t, const fmpz_poly_t) - void fmpz_poly_compose_divconquer( - fmpz_poly_t, const fmpz_poly_t, const fmpz_poly_t) - void fmpz_poly_compose(fmpz_poly_t, const fmpz_poly_t, const fmpz_poly_t) - - # Revert - void fmpz_poly_revert_series_lagrange(fmpz_poly_t Qinv, fmpz_poly_t Q, long n) - void fmpz_poly_revert_series_lagrange_fast(fmpz_poly_t Qinv, - fmpz_poly_t Q, long n) - void fmpz_poly_revert_series_newton(fmpz_poly_t Qinv, fmpz_poly_t Q, long n) - void fmpz_poly_revert_series(fmpz_poly_t Qinv, fmpz_poly_t Q, long n) - - # Square root - int fmpz_poly_sqrt_classical(fmpz_poly_t b, fmpz_poly_t a) - int fmpz_poly_sqrt(fmpz_poly_t b, fmpz_poly_t a) - - # Signature - void fmpz_poly_signature(long * r1, long * r2, fmpz_poly_t poly) - - # Taylor shift - void fmpz_poly_taylor_shift_horner( - fmpz_poly_t, const fmpz_poly_t, const fmpz_t) - void fmpz_poly_taylor_shift_divconquer( - fmpz_poly_t, const fmpz_poly_t, const fmpz_t) - void fmpz_poly_taylor_shift(fmpz_poly_t, const fmpz_poly_t, const fmpz_t) - - # Input and output - int fmpz_poly_fprint(FILE *, fmpz_poly_t) - int fmpz_poly_fprint_prett(FILE *, fmpz_poly_t, char *) - int fmpz_poly_print(const fmpz_poly_t) - int fmpz_poly_print_pretty(const fmpz_poly_t, const char *) - - int fmpz_poly_fread(FILE *, fmpz_poly_t) - int fmpz_poly_fread_pretty(FILE *, fmpz_poly_t, char **) - int fmpz_poly_read(fmpz_poly_t) - int fmpz_poly_read_pretty(fmpz_poly_t, char **) - - # CRT - void fmpz_poly_get_nmod_poly(nmod_poly_t, const fmpz_poly_t) - - void fmpz_poly_set_nmod_poly(fmpz_poly_t, const nmod_poly_t) - void fmpz_poly_set_nmod_poly_unsigned(fmpz_poly_t, const nmod_poly_t) - - void fmpz_poly_CRT_ui( - fmpz_poly_t, - const fmpz_poly_t, const fmpz_t, const nmod_poly_t, int) - - -# functions removed from flint but still needed in sage -cdef void fmpz_poly_scalar_mul_mpz(fmpz_poly_t, const fmpz_poly_t, const mpz_t) -cdef void fmpz_poly_scalar_divexact_mpz(fmpz_poly_t, const fmpz_poly_t, const mpz_t) -cdef void fmpz_poly_scalar_fdiv_mpz(fmpz_poly_t, const fmpz_poly_t, const mpz_t) -cdef void fmpz_poly_set_coeff_mpz(fmpz_poly_t, slong, const mpz_t) -cdef void fmpz_poly_get_coeff_mpz(mpz_t, const fmpz_poly_t, slong) -cdef void fmpz_poly_set_mpz(fmpz_poly_t, const mpz_t) - - -# Wrapper Cython class -from sage.structure.sage_object cimport SageObject -cdef class Fmpz_poly(SageObject): - cdef fmpz_poly_t poly + + void fmpz_poly_init(fmpz_poly_t poly) + # Initialises ``poly`` for use, setting its length to zero. + # A corresponding call to :func:`fmpz_poly_clear` must be made after + # finishing with the ``fmpz_poly_t`` to free the memory used by + # the polynomial. + + void fmpz_poly_init2(fmpz_poly_t poly, long alloc) + # Initialises ``poly`` with space for at least ``alloc`` coefficients + # and sets the length to zero. The allocated coefficients are all set to + # zero. + + void fmpz_poly_realloc(fmpz_poly_t poly, long alloc) + # Reallocates the given polynomial to have space for ``alloc`` + # coefficients. If ``alloc`` is zero the polynomial is cleared + # and then reinitialised. If the current length is greater than + # ``alloc`` the polynomial is first truncated to length ``alloc``. + + void fmpz_poly_fit_length(fmpz_poly_t poly, long len) + # If ``len`` is greater than the number of coefficients currently + # allocated, then the polynomial is reallocated to have space for at + # least ``len`` coefficients. No data is lost when calling this + # function. + # The function efficiently deals with the case where ``fit_length`` is + # called many times in small increments by at least doubling the number + # of allocated coefficients when length is larger than the number of + # coefficients currently allocated. + + void fmpz_poly_clear(fmpz_poly_t poly) + # Clears the given polynomial, releasing any memory used. It must + # be reinitialised in order to be used again. + + void _fmpz_poly_normalise(fmpz_poly_t poly) + # Sets the length of ``poly`` so that the top coefficient is non-zero. + # If all coefficients are zero, the length is set to zero. This function + # is mainly used internally, as all functions guarantee normalisation. + + void _fmpz_poly_set_length(fmpz_poly_t poly, long newlen) + # Demotes the coefficients of ``poly`` beyond ``newlen`` and sets + # the length of ``poly`` to ``newlen``. + + void fmpz_poly_attach_truncate(fmpz_poly_t trunc, const fmpz_poly_t poly, long n) + # This function sets the uninitialised polynomial ``trunc`` to the low + # `n` coefficients of ``poly``, or to ``poly`` if the latter doesn't + # have `n` coefficients. The polynomial ``trunc`` not be cleared or used + # as the output of any Flint functions. + + void fmpz_poly_attach_shift(fmpz_poly_t trunc, const fmpz_poly_t poly, long n) + # This function sets the uninitialised polynomial ``trunc`` to the + # high coefficients of ``poly``, i.e. the coefficients not among the low + # `n` coefficients of ``poly``. If the latter doesn't have `n` + # coefficients ``trunc`` is set to the zero polynomial. The polynomial + # ``trunc`` not be cleared or used as the output of any Flint functions. + + long fmpz_poly_length(const fmpz_poly_t poly) + # Returns the length of ``poly``. The zero polynomial has length zero. + + long fmpz_poly_degree(const fmpz_poly_t poly) + # Returns the degree of ``poly``, which is one less than its length. + + void fmpz_poly_set(fmpz_poly_t poly1, const fmpz_poly_t poly2) + # Sets ``poly1`` to equal ``poly2``. + + void fmpz_poly_set_si(fmpz_poly_t poly, long c) + # Sets ``poly`` to the signed integer ``c``. + + void fmpz_poly_set_ui(fmpz_poly_t poly, unsigned long c) + # Sets ``poly`` to the unsigned integer ``c``. + + void fmpz_poly_set_fmpz(fmpz_poly_t poly, const fmpz_t c) + # Sets ``poly`` to the integer ``c``. + + int _fmpz_poly_set_str(fmpz * poly, const char * str) + # Sets ``poly`` to the polynomial encoded in the null-terminated + # string ``str``. Assumes that ``poly`` is allocated as a + # sufficiently large array suitable for the number of coefficients + # present in ``str``. + # Returns `0` if no error occurred. Otherwise, returns a non-zero + # value, in which case the resulting value of ``poly`` is undefined. + # If ``str`` is not null-terminated, calling this method might result + # in a segmentation fault. + + int fmpz_poly_set_str(fmpz_poly_t poly, const char * str) + # Imports a polynomial from a null-terminated string. If the string + # ``str`` represents a valid polynomial returns `0`, otherwise + # returns `1`. + # Returns `0` if no error occurred. Otherwise, returns a non-zero value, + # in which case the resulting value of ``poly`` is undefined. If + # ``str`` is not null-terminated, calling this method might result in + # a segmentation fault. + + char * _fmpz_poly_get_str(const fmpz * poly, long len) + # Returns the plain FLINT string representation of the polynomial + # ``(poly, len)``. + + char * fmpz_poly_get_str(const fmpz_poly_t poly) + # Returns the plain FLINT string representation of the polynomial + # ``poly``. + + char * _fmpz_poly_get_str_pretty(const fmpz * poly, long len, const char * x) + # Returns a pretty representation of the polynomial + # ``(poly, len)`` using the null-terminated string ``x`` as the + # variable name. + + char * fmpz_poly_get_str_pretty(const fmpz_poly_t poly, const char * x) + # Returns a pretty representation of the polynomial ``poly`` using the + # null-terminated string ``x`` as the variable name. + + void fmpz_poly_zero(fmpz_poly_t poly) + # Sets ``poly`` to the zero polynomial. + + void fmpz_poly_one(fmpz_poly_t poly) + # Sets ``poly`` to the constant polynomial one. + + void fmpz_poly_zero_coeffs(fmpz_poly_t poly, long i, long j) + # Sets the coefficients of `x^i, \dotsc, x^{j-1}` to zero. + + void fmpz_poly_swap(fmpz_poly_t poly1, fmpz_poly_t poly2) + # Swaps ``poly1`` and ``poly2``. This is done efficiently without + # copying data by swapping pointers, etc. + + void _fmpz_poly_reverse(fmpz * res, const fmpz * poly, long len, long n) + # Sets ``(res, n)`` to the reverse of ``(poly, n)``, where + # ``poly`` is in fact an array of length ``len``. Assumes that + # ``0 < len <= n``. Supports aliasing of ``res`` and ``poly``, + # but the behaviour is undefined in case of partial overlap. + + void fmpz_poly_reverse(fmpz_poly_t res, const fmpz_poly_t poly, long n) + # This function considers the polynomial ``poly`` to be of length `n`, + # notionally truncating and zero padding if required, and reverses + # the result. Since the function normalises its result ``res`` may be + # of length less than `n`. + + void fmpz_poly_truncate(fmpz_poly_t poly, long newlen) + # If the current length of ``poly`` is greater than ``newlen``, it + # is truncated to have the given length. Discarded coefficients are not + # necessarily set to zero. + + void fmpz_poly_set_trunc(fmpz_poly_t res, const fmpz_poly_t poly, long n) + # Sets ``res`` to a copy of ``poly``, truncated to length ``n``. + + void fmpz_poly_randtest(fmpz_poly_t f, flint_rand_t state, long len, flint_bitcnt_t bits) + # Sets `f` to a random polynomial with up to the given length and where + # each coefficient has up to the given number of bits. The coefficients + # are signed randomly. + + void fmpz_poly_randtest_unsigned(fmpz_poly_t f, flint_rand_t state, long len, flint_bitcnt_t bits) + # Sets `f` to a random polynomial with up to the given length and where + # each coefficient has up to the given number of bits. + + void fmpz_poly_randtest_not_zero(fmpz_poly_t f, flint_rand_t state, long len, flint_bitcnt_t bits) + # As for :func:`fmpz_poly_randtest` except that ``len`` and bits may + # not be zero and the polynomial generated is guaranteed not to be the + # zero polynomial. + + void fmpz_poly_randtest_no_real_root(fmpz_poly_t p, flint_rand_t state, long len, flint_bitcnt_t bits) + # Sets ``p`` to a random polynomial without any real root, whose + # length is up to ``len`` and where each coefficient has up to the + # given number of bits. + + void fmpz_poly_randtest_irreducible1(fmpz_poly_t pol, flint_rand_t state, long len, mp_bitcnt_t bits) + void fmpz_poly_randtest_irreducible2(fmpz_poly_t pol, flint_rand_t state, long len, mp_bitcnt_t bits) + void fmpz_poly_randtest_irreducible(fmpz_poly_t pol, flint_rand_t state, long len, mp_bitcnt_t bits) + # Sets ``p`` to a random irreducible polynomial, whose + # length is up to ``len`` and where each coefficient has up to the + # given number of bits. There are two algorithms: *irreducible1* + # generates an irreducible polynomial modulo a random prime number + # and lifts it to the integers; *irreducible2* generates a random + # integer polynomial, factors it, and returns a random factor. + # The default function chooses randomly between these methods. + + void fmpz_poly_get_coeff_fmpz(fmpz_t x, const fmpz_poly_t poly, long n) + # Sets `x` to the `n`-th coefficient of ``poly``. Coefficient + # numbering is from zero and if `n` is set to a value beyond the end of + # the polynomial, zero is returned. + + long fmpz_poly_get_coeff_si(const fmpz_poly_t poly, long n) + # Returns coefficient `n` of ``poly`` as a ``slong``. The result is + # undefined if the value does not fit into a ``slong``. Coefficient + # numbering is from zero and if `n` is set to a value beyond the end of + # the polynomial, zero is returned. + + unsigned long fmpz_poly_get_coeff_ui(const fmpz_poly_t poly, long n) + # Returns coefficient `n` of ``poly`` as a ``ulong``. The result is + # undefined if the value does not fit into a ``ulong``. Coefficient + # numbering is from zero and if `n` is set to a value beyond the end of the + # polynomial, zero is returned. + + fmpz * fmpz_poly_get_coeff_ptr(const fmpz_poly_t poly, long n) + # Returns a reference to the coefficient of `x^n` in the polynomial, + # as an ``fmpz *``. This function is provided so that individual + # coefficients can be accessed and operated on by functions in the + # ``fmpz`` module. This function does not make a copy of the + # data, but returns a reference to the actual coefficient. + # Returns ``NULL`` when `n` exceeds the degree of the polynomial. + # This function is implemented as a macro. + + fmpz * fmpz_poly_lead(const fmpz_poly_t poly) + # Returns a reference to the leading coefficient of the polynomial, + # as an ``fmpz *``. This function is provided so that the leading + # coefficient can be easily accessed and operated on by functions in + # the ``fmpz`` module. This function does not make a copy of the + # data, but returns a reference to the actual coefficient. + # Returns ``NULL`` when the polynomial is zero. + # This function is implemented as a macro. + + void fmpz_poly_set_coeff_fmpz(fmpz_poly_t poly, long n, const fmpz_t x) + # Sets coefficient `n` of ``poly`` to the ``fmpz`` value ``x``. + # Coefficient numbering starts from zero and if `n` is beyond the current + # length of ``poly`` then the polynomial is extended and zero + # coefficients inserted if necessary. + + void fmpz_poly_set_coeff_si(fmpz_poly_t poly, long n, long x) + # Sets coefficient `n` of ``poly`` to the ``slong`` value ``x``. + # Coefficient numbering starts from zero and if `n` is beyond the current + # length of ``poly`` then the polynomial is extended and zero + # coefficients inserted if necessary. + + void fmpz_poly_set_coeff_ui(fmpz_poly_t poly, long n, unsigned long x) + # Sets coefficient `n` of ``poly`` to the ``ulong`` value + # ``x``. Coefficient numbering starts from zero and if `n` is beyond + # the current length of ``poly`` then the polynomial is extended and + # zero coefficients inserted if necessary. + + int fmpz_poly_equal(const fmpz_poly_t poly1, const fmpz_poly_t poly2) + # Returns `1` if ``poly1`` is equal to ``poly2``, otherwise + # returns `0`. The polynomials are assumed to be normalised. + + int fmpz_poly_equal_trunc(const fmpz_poly_t poly1, const fmpz_poly_t poly2, long n) + # Return `1` if ``poly1`` and ``poly2``, notionally truncated to + # length `n` are equal, otherwise return `0`. + + int fmpz_poly_is_zero(const fmpz_poly_t poly) + # Returns `1` if the polynomial is zero and `0` otherwise. + # This function is implemented as a macro. + + int fmpz_poly_is_one(const fmpz_poly_t poly) + # Returns `1` if the polynomial is one and `0` otherwise. + + int fmpz_poly_is_unit(const fmpz_poly_t poly) + # Returns `1` if the polynomial is the constant polynomial `\pm 1`, + # and `0` otherwise. + + int fmpz_poly_is_gen(const fmpz_poly_t poly) + # Returns `1` if the polynomial is the degree `1` polynomial `x`, and `0` + # otherwise. + + void _fmpz_poly_add(fmpz * res, const fmpz * poly1, long len1, const fmpz * poly2, long len2) + # Sets ``res`` to the sum of ``(poly1, len1)`` and + # ``(poly2, len2)``. It is assumed that ``res`` has + # sufficient space for the longer of the two polynomials. + + void fmpz_poly_add(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2) + # Sets ``res`` to the sum of ``poly1`` and ``poly2``. + + void fmpz_poly_add_series(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2, long n) + # Notionally truncate ``poly1`` and ``poly2`` to length `n` and then + # set ``res`` to the sum. + + void _fmpz_poly_sub(fmpz * res, const fmpz * poly1, long len1, const fmpz * poly2, long len2) + # Sets ``res`` to ``(poly1, len1)`` minus ``(poly2, len2)``. It + # is assumed that ``res`` has sufficient space for the longer of the + # two polynomials. + + void fmpz_poly_sub(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2) + # Sets ``res`` to ``poly1`` minus ``poly2``. + + void fmpz_poly_sub_series(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2, long n) + # Notionally truncate ``poly1`` and ``poly2`` to length `n` and then + # set ``res`` to the sum. + + void fmpz_poly_neg(fmpz_poly_t res, const fmpz_poly_t poly) + # Sets ``res`` to ``-poly``. + + void fmpz_poly_scalar_abs(fmpz_poly_t res, const fmpz_poly_t poly) + # Sets ``poly1`` to the polynomial whose coefficients are the absolute + # value of those of ``poly2``. + + void fmpz_poly_scalar_mul_fmpz(fmpz_poly_t poly1, const fmpz_poly_t poly2, const fmpz_t x) + # Sets ``poly1`` to ``poly2`` times `x`. + + void fmpz_poly_scalar_mul_si(fmpz_poly_t poly1, const fmpz_poly_t poly2, long x) + # Sets ``poly1`` to ``poly2`` times the signed ``slong x``. + + void fmpz_poly_scalar_mul_ui(fmpz_poly_t poly1, const fmpz_poly_t poly2, unsigned long x) + # Sets ``poly1`` to ``poly2`` times the ``ulong x``. + + void fmpz_poly_scalar_mul_2exp(fmpz_poly_t poly1, const fmpz_poly_t poly2, unsigned long exp) + # Sets ``poly1`` to ``poly2`` times ``2^exp``. + + void fmpz_poly_scalar_addmul_si(fmpz_poly_t poly1, const fmpz_poly_t poly2, long x) + + void fmpz_poly_scalar_addmul_ui(fmpz_poly_t poly1, const fmpz_poly_t poly2, unsigned long x) + + void fmpz_poly_scalar_addmul_fmpz(fmpz_poly_t poly1, const fmpz_poly_t poly2, const fmpz_t x) + # Sets ``poly1`` to ``poly1 + x * poly2``. + + void fmpz_poly_scalar_submul_fmpz(fmpz_poly_t poly1, const fmpz_poly_t poly2, const fmpz_t x) + # Sets ``poly1`` to ``poly1 - x * poly2``. + + void fmpz_poly_scalar_fdiv_fmpz(fmpz_poly_t poly1, const fmpz_poly_t poly2, const fmpz_t x) + # Sets ``poly1`` to ``poly2`` divided by the ``fmpz_t x``, + # rounding coefficients down toward `- \infty`. + + void fmpz_poly_scalar_fdiv_si(fmpz_poly_t poly1, const fmpz_poly_t poly2, long x) + # Sets ``poly1`` to ``poly2`` divided by the ``slong x``, + # rounding coefficients down toward `- \infty`. + + void fmpz_poly_scalar_fdiv_ui(fmpz_poly_t poly1, const fmpz_poly_t poly2, unsigned long x) + # Sets ``poly1`` to ``poly2`` divided by the ``ulong x``, + # rounding coefficients down toward `- \infty`. + + void fmpz_poly_scalar_fdiv_2exp(fmpz_poly_t poly1, const fmpz_poly_t poly2, unsigned long x) + # Sets ``poly1`` to ``poly2`` divided by ``2^x``, + # rounding coefficients down toward `- \infty`. + + void fmpz_poly_scalar_tdiv_fmpz(fmpz_poly_t poly1, const fmpz_poly_t poly2, const fmpz_t x) + # Sets ``poly1`` to ``poly2`` divided by the ``fmpz_t x``, + # rounding coefficients toward `0`. + + void fmpz_poly_scalar_tdiv_si(fmpz_poly_t poly1, const fmpz_poly_t poly2, long x) + # Sets ``poly1`` to ``poly2`` divided by the ``slong x``, + # rounding coefficients toward `0`. + + void fmpz_poly_scalar_tdiv_ui(fmpz_poly_t poly1, const fmpz_poly_t poly2, unsigned long x) + # Sets ``poly1`` to ``poly2`` divided by the ``ulong x``, + # rounding coefficients toward `0`. + + void fmpz_poly_scalar_tdiv_2exp(fmpz_poly_t poly1, const fmpz_poly_t poly2, unsigned long x) + # Sets ``poly1`` to ``poly2`` divided by ``2^x``, + # rounding coefficients toward `0`. + + void fmpz_poly_scalar_divexact_fmpz(fmpz_poly_t poly1, const fmpz_poly_t poly2, const fmpz_t x) + # Sets ``poly1`` to ``poly2`` divided by the ``fmpz_t x``, + # assuming the division is exact for every coefficient. + + void fmpz_poly_scalar_divexact_si(fmpz_poly_t poly1, const fmpz_poly_t poly2, long x) + # Sets ``poly1`` to ``poly2`` divided by the ``slong x``, + # assuming the coefficient is exact for every coefficient. + + void fmpz_poly_scalar_divexact_ui(fmpz_poly_t poly1, const fmpz_poly_t poly2, unsigned long x) + # Sets ``poly1`` to ``poly2`` divided by the ``ulong x``, + # assuming the coefficient is exact for every coefficient. + + void fmpz_poly_scalar_mod_fmpz(fmpz_poly_t poly1, const fmpz_poly_t poly2, const fmpz_t p) + # Sets ``poly1`` to ``poly2``, reducing each coefficient + # modulo `p > 0`. + + void fmpz_poly_scalar_smod_fmpz(fmpz_poly_t poly1, const fmpz_poly_t poly2, const fmpz_t p) + # Sets ``poly1`` to ``poly2``, symmetrically reducing + # each coefficient modulo `p > 0`, that is, choosing the unique + # representative in the interval `(-p/2, p/2]`. + + long _fmpz_poly_remove_content_2exp(fmpz * pol, long len) + # Remove the 2-content of ``pol`` and return the number `k` + # that is the maximal non-negative integer so that `2^k` divides + # all coefficients of the polynomial. For the zero polynomial, + # `0` is returned. + + void _fmpz_poly_scale_2exp(fmpz * pol, long len, long k) + # Scale ``(pol, len)`` to `p(2^k X)` in-place and divide by the + # 2-content (so that the gcd of coefficients is odd). If ``k`` + # is negative the polynomial is multiplied by `2^{kd}`. + + void _fmpz_poly_bit_pack(mp_ptr arr, const fmpz * poly, long len, flint_bitcnt_t bit_size, int negate) + # Packs the coefficients of ``poly`` into bitfields of the given + # ``bit_size``, negating the coefficients before packing + # if ``negate`` is set to `-1`. + + int _fmpz_poly_bit_unpack(fmpz * poly, long len, mp_srcptr arr, flint_bitcnt_t bit_size, int negate) + # Unpacks the polynomial of given length from the array as packed into + # fields of the given ``bit_size``, finally negating the coefficients + # if ``negate`` is set to `-1`. Returns borrow, which is nonzero if a + # leading term with coefficient `\pm1` should be added at + # position ``len`` of ``poly``. + + void _fmpz_poly_bit_unpack_unsigned(fmpz * poly, long len, mp_srcptr arr, flint_bitcnt_t bit_size) + # Unpacks the polynomial of given length from the array as packed into + # fields of the given ``bit_size``. The coefficients are assumed to + # be unsigned. + + void fmpz_poly_bit_pack(fmpz_t f, const fmpz_poly_t poly, flint_bitcnt_t bit_size) + # Packs ``poly`` into bitfields of size ``bit_size``, writing the + # result to ``f``. The sign of ``f`` will be the same as that of + # the leading coefficient of ``poly``. + + void fmpz_poly_bit_unpack(fmpz_poly_t poly, const fmpz_t f, flint_bitcnt_t bit_size) + # Unpacks the polynomial with signed coefficients packed into + # fields of size ``bit_size`` as represented by the integer ``f``. + + void fmpz_poly_bit_unpack_unsigned(fmpz_poly_t poly, const fmpz_t f, flint_bitcnt_t bit_size) + # Unpacks the polynomial with unsigned coefficients packed into + # fields of size ``bit_size`` as represented by the integer ``f``. + # It is required that ``f`` is nonnegative. + + void _fmpz_poly_mul_classical(fmpz * res, const fmpz * poly1, long len1, const fmpz * poly2, long len2) + # Sets ``(res, len1 + len2 - 1)`` to the product of ``(poly1, len1)`` + # and ``(poly2, len2)``. + # Assumes ``len1`` and ``len2`` are positive. Allows zero-padding + # of the two input polynomials. No aliasing of inputs with outputs is + # allowed. + + void fmpz_poly_mul_classical(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2) + # Sets ``res`` to the product of ``poly1`` and ``poly2``, computed + # using the classical or schoolbook method. + + void _fmpz_poly_mullow_classical(fmpz * res, const fmpz * poly1, long len1, const fmpz * poly2, long len2, long n) + # Sets ``(res, n)`` to the first `n` coefficients of ``(poly1, len1)`` + # multiplied by ``(poly2, len2)``. + # Assumes ``0 < n <= len1 + len2 - 1``. Assumes neither ``len1`` nor + # ``len2`` is zero. + + void fmpz_poly_mullow_classical(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2, long n) + # Sets ``res`` to the first `n` coefficients of ``poly1 * poly2``. + + void _fmpz_poly_mulhigh_classical(fmpz * res, const fmpz * poly1, long len1, const fmpz * poly2, long len2, long start) + # Sets the first ``start`` coefficients of ``res`` to zero and the + # remainder to the corresponding coefficients of + # ``(poly1, len1) * (poly2, len2)``. + # Assumes ``start <= len1 + len2 - 1``. Assumes neither ``len1`` nor + # ``len2`` is zero. + + void fmpz_poly_mulhigh_classical(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2, long start) + # Sets the first ``start`` coefficients of ``res`` to zero and the + # remainder to the corresponding coefficients of the product of ``poly1`` + # and ``poly2``. + + void _fmpz_poly_mulmid_classical(fmpz * res, const fmpz * poly1, long len1, const fmpz * poly2, long len2) + # Sets ``res`` to the middle ``len1 - len2 + 1`` coefficients of + # the product of ``(poly1, len1)`` and ``(poly2, len2)``, i.e. the + # coefficients from degree ``len2 - 1`` to ``len1 - 1`` inclusive. + # Assumes that ``len1 >= len2 > 0``. + + void fmpz_poly_mulmid_classical(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2) + # Sets ``res`` to the middle ``len(poly1) - len(poly2) + 1`` + # coefficients of ``poly1 * poly2``, i.e. the coefficient from degree + # ``len2 - 1`` to ``len1 - 1`` inclusive. Assumes that + # ``len1 >= len2``. + + void _fmpz_poly_mul_karatsuba(fmpz * res, const fmpz * poly1, long len1, const fmpz * poly2, long len2) + # Sets ``(res, len1 + len2 - 1)`` to the product of ``(poly1, len1)`` + # and ``(poly2, len2)``. Assumes ``len1 >= len2 > 0``. Allows + # zero-padding of the two input polynomials. No aliasing of inputs with + # outputs is allowed. + + void fmpz_poly_mul_karatsuba(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2) + # Sets ``res`` to the product of ``poly1`` and ``poly2``. + + void _fmpz_poly_mullow_karatsuba_n(fmpz * res, const fmpz * poly1, const fmpz * poly2, long n) + # Sets ``res`` to the product of ``poly1`` and ``poly2`` and + # truncates to the given length. It is assumed that ``poly1`` and + # ``poly2`` are precisely the given length, possibly zero padded. + # Assumes `n` is not zero. + + void fmpz_poly_mullow_karatsuba_n(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2, long n) + # Sets ``res`` to the product of ``poly1`` and ``poly2`` and + # truncates to the given length. + + void _fmpz_poly_mulhigh_karatsuba_n(fmpz * res, const fmpz * poly1, const fmpz * poly2, long len) + # Sets ``res`` to the product of ``poly1`` and ``poly2`` and + # truncates at the top to the given length. The first ``len - 1`` + # coefficients are set to zero. It is assumed that ``poly1`` and + # ``poly2`` are precisely the given length, possibly zero padded. + # Assumes ``len`` is not zero. + + void fmpz_poly_mulhigh_karatsuba_n(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2, long len) + # Sets the first ``len - 1`` coefficients of the result to zero and the + # remaining coefficients to the corresponding coefficients of the product of + # ``poly1`` and ``poly2``. Assumes ``poly1`` and ``poly2`` are + # at most of the given length. + + void _fmpz_poly_mul_KS(fmpz * res, const fmpz * poly1, long len1, const fmpz * poly2, long len2) + # Sets ``(res, len1 + len2 - 1)`` to the product of ``(poly1, len1)`` + # and ``(poly2, len2)``. + # Places no assumptions on ``len1`` and ``len2``. Allows zero-padding + # of the two input polynomials. Supports aliasing of inputs and outputs. + + void fmpz_poly_mul_KS(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2) + # Sets ``res`` to the product of ``poly1`` and ``poly2``. + + void _fmpz_poly_mullow_KS(fmpz * res, const fmpz * poly1, long len1, const fmpz * poly2, long len2, long n) + # Sets ``(res, n)`` to the lowest `n` coefficients of the product of + # ``(poly1, len1)`` and ``(poly2, len2)``. + # Assumes that ``len1`` and ``len2`` are positive, but does allow + # for the polynomials to be zero-padded. The polynomials may be zero, + # too. Assumes `n` is positive. Supports aliasing between ``res``, + # ``poly1`` and ``poly2``. + + void fmpz_poly_mullow_KS(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2, long n) + # Sets ``res`` to the lowest `n` coefficients of the product of + # ``poly1`` and ``poly2``. + + void _fmpz_poly_mul_SS(fmpz * output, const fmpz * input1, long length1, const fmpz * input2, long length2) + # Sets ``(output, length1 + length2 - 1)`` to the product of + # ``(input1, length1)`` and ``(input2, length2)``. + # We must have ``len1 > 1`` and ``len2 > 1``. Allows zero-padding + # of the two input polynomials. Supports aliasing of inputs and outputs. + + void fmpz_poly_mul_SS(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2) + # Sets ``res`` to the product of ``poly1`` and ``poly2``. Uses the + # Schönhage-Strassen algorithm. + + void _fmpz_poly_mullow_SS(fmpz * output, const fmpz * input1, long length1, const fmpz * input2, long length2, long n) + # Sets ``(res, n)`` to the lowest `n` coefficients of the product of + # ``(poly1, len1)`` and ``(poly2, len2)``. + # Assumes that ``len1`` and ``len2`` are positive, but does allow + # for the polynomials to be zero-padded. We must have ``len1 > 1`` + # and ``len2 > 1``. Assumes `n` is positive. Supports aliasing between + # ``res``, ``poly1`` and ``poly2``. + + void fmpz_poly_mullow_SS(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2, long n) + # Sets ``res`` to the lowest `n` coefficients of the product of + # ``poly1`` and ``poly2``. + + void _fmpz_poly_mul(fmpz * res, const fmpz * poly1, long len1, const fmpz * poly2, long len2) + # Sets ``(res, len1 + len2 - 1)`` to the product of ``(poly1, len1)`` + # and ``(poly2, len2)``. Assumes ``len1 >= len2 > 0``. Allows + # zero-padding of the two input polynomials. Does not support aliasing + # between the inputs and the output. + + void fmpz_poly_mul(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2) + # Sets ``res`` to the product of ``poly1`` and ``poly2``. Chooses + # an optimal algorithm from the choices above. + + void _fmpz_poly_mullow(fmpz * res, const fmpz * poly1, long len1, const fmpz * poly2, long len2, long n) + # Sets ``(res, n)`` to the lowest `n` coefficients of the product of + # ``(poly1, len1)`` and ``(poly2, len2)``. + # Assumes ``len1 >= len2 > 0`` and ``0 < n <= len1 + len2 - 1``. + # Allows for zero-padding in the inputs. Does not support aliasing between + # the inputs and the output. + + void fmpz_poly_mullow(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2, long n) + # Sets ``res`` to the lowest `n` coefficients of the product of + # ``poly1`` and ``poly2``. + + void fmpz_poly_mulhigh_n(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2, long n) + # Sets the high `n` coefficients of ``res`` to the high `n` coefficients + # of the product of ``poly1`` and ``poly2``, assuming the latter are + # precisely `n` coefficients in length, zero padded if necessary. The + # remaining `n - 1` coefficients may be arbitrary. + + void _fmpz_poly_mulhigh(fmpz * res, const fmpz * poly1, long len1, const fmpz * poly2, long len2, long start) + # Sets all but the low `n` coefficients of `res` to the corresponding + # coefficients of the product of `poly1` of length `len1` and `poly2` of + # length `len2`, the remaining coefficients being arbitrary. It is assumed + # that `len1 >= len2 > 0` and that `0 < n < len1 + len2 - 1`. Aliasing of + # inputs is not permitted. + + void fmpz_poly_mul_SS_precache_init(fmpz_poly_mul_precache_t pre, long len1, long bits1, const fmpz_poly_t poly2) + # Precompute the FFT of ``poly2`` to enable repeated multiplication of + # ``poly2`` by polynomials whose length does not exceed ``len1`` and + # whose number of bits per coefficient does not exceed ``bits1``. + # The value ``bits1`` may be negative, i.e. it may be the result of + # calling ``fmpz_poly_max_bits``. The function only considers the + # absolute value of ``bits1``. + # Suppose ``len2`` is the length of ``poly2`` and + # ``len = len1 + len2 - 1`` is the maximum output length of a polynomial + # multiplication using ``pre``. Then internally ``len`` is rounded up to + # a power of two, `2^n` say. The truncated FFT algorithm is used to smooth + # performance but note that it can only do this in the range + # `(2^{n-1}, 2^n]`. Therefore, it may be more efficient to recompute `pre` + # for cases where the output length will fall below `2^{n-1} + 1`. Otherwise + # the implementation will zero pad them up to that length. + # Note that the Schoenhage-Strassen algorithm is only efficient for + # polynomials with relatively large coefficients relative to the length of + # the polynomials. + # Also note that there are no restrictions on the polynomials. In particular + # the polynomial whose FFT is being precached does not have to be either + # longer or shorter than the polynomials it is to be multiplied by. + + void fmpz_poly_mul_precache_clear(fmpz_poly_mul_precache_t pre) + # Clear the space allocated by ``fmpz_poly_mul_SS_precache_init``. + + void _fmpz_poly_mullow_SS_precache(fmpz * output, const fmpz * input1, long len1, fmpz_poly_mul_precache_t pre, long trunc) + # Write into ``output`` the first ``trunc`` coefficients of + # the polynomial ``(input1, len1)`` by the polynomial whose FFT was precached + # by ``fmpz_poly_mul_SS_precache_init`` and stored in ``pre``. + # For performance reasons it is recommended that all polynomials be truncated + # to at most ``trunc`` coefficients if possible. + + void fmpz_poly_mullow_SS_precache(fmpz_poly_t res, const fmpz_poly_t poly1, fmpz_poly_mul_precache_t pre, long n) + # Set ``res`` to the product of ``poly1`` by the polynomial whose FFT was + # precached by ``fmpz_poly_mul_SS_precache_init`` (and stored in pre). The + # result is truncated to `n` coefficients (and normalised). + # There are no restrictions on the length of ``poly1`` other than those given + # in the call to ``fmpz_poly_mul_SS_precache_init``. + + void fmpz_poly_mul_SS_precache(fmpz_poly_t res, const fmpz_poly_t poly1, fmpz_poly_mul_precache_t pre) + # Set ``res`` to the product of ``poly1`` by the polynomial whose FFT was + # precached by ``fmpz_poly_mul_SS_precache_init`` (and stored in pre). + # There are no restrictions on the length of ``poly1`` other than those given + # in the call to ``fmpz_poly_mul_SS_precache_init``. + + void _fmpz_poly_sqr_KS(fmpz * rop, const fmpz * op, long len) + # Sets ``(rop, 2*len - 1)`` to the square of ``(op, len)``, + # assuming that ``len > 0``. + # Supports zero-padding in ``(op, len)``. Does not support aliasing. + + void fmpz_poly_sqr_KS(fmpz_poly_t rop, const fmpz_poly_t op) + # Sets ``rop`` to the square of the polynomial ``op`` using + # Kronecker segmentation. + + void _fmpz_poly_sqr_karatsuba(fmpz * rop, const fmpz * op, long len) + # Sets ``(rop, 2*len - 1)`` to the square of ``(op, len)``, + # assuming that ``len > 0``. + # Supports zero-padding in ``(op, len)``. Does not support aliasing. + + void fmpz_poly_sqr_karatsuba(fmpz_poly_t rop, const fmpz_poly_t op) + # Sets ``rop`` to the square of the polynomial ``op`` using + # the Karatsuba multiplication algorithm. + + void _fmpz_poly_sqr_classical(fmpz * rop, const fmpz * op, long len) + # Sets ``(rop, 2*len - 1)`` to the square of ``(op, len)``, + # assuming that ``len > 0``. + # Supports zero-padding in ``(op, len)``. Does not support aliasing. + + void fmpz_poly_sqr_classical(fmpz_poly_t rop, const fmpz_poly_t op) + # Sets ``rop`` to the square of the polynomial ``op`` using + # the classical or schoolbook method. + + void _fmpz_poly_sqr(fmpz * rop, const fmpz * op, long len) + # Sets ``(rop, 2*len - 1)`` to the square of ``(op, len)``, + # assuming that ``len > 0``. + # Supports zero-padding in ``(op, len)``. Does not support aliasing. + + void fmpz_poly_sqr(fmpz_poly_t rop, const fmpz_poly_t op) + # Sets ``rop`` to the square of the polynomial ``op``. + + void _fmpz_poly_sqrlow_KS(fmpz * res, const fmpz * poly, long len, long n) + # Sets ``(res, n)`` to the lowest `n` coefficients + # of the square of ``(poly, len)``. + # Assumes that ``len`` is positive, but does allow for the polynomial + # to be zero-padded. The polynomial may be zero, too. Assumes `n` is + # positive. Supports aliasing between ``res`` and ``poly``. + + void fmpz_poly_sqrlow_KS(fmpz_poly_t res, const fmpz_poly_t poly, long n) + # Sets ``res`` to the lowest `n` coefficients + # of the square of ``poly``. + + void _fmpz_poly_sqrlow_karatsuba_n(fmpz * res, const fmpz * poly, long n) + # Sets ``(res, n)`` to the square of ``(poly, n)`` truncated + # to length `n`, which is assumed to be positive. Allows for ``poly`` + # to be zero-padded. + + void fmpz_poly_sqrlow_karatsuba_n(fmpz_poly_t res, const fmpz_poly_t poly, long n) + # Sets ``res`` to the square of ``poly`` and + # truncates to the given length. + + void _fmpz_poly_sqrlow_classical(fmpz * res, const fmpz * poly, long len, long n) + # Sets ``(res, n)`` to the first `n` coefficients of the square + # of ``(poly, len)``. + # Assumes that ``0 < n <= 2 * len - 1``. + + void fmpz_poly_sqrlow_classical(fmpz_poly_t res, const fmpz_poly_t poly, long n) + # Sets ``res`` to the first `n` coefficients of + # the square of ``poly``. + + void _fmpz_poly_sqrlow(fmpz * res, const fmpz * poly, long len, long n) + # Sets ``(res, n)`` to the lowest `n` coefficients + # of the square of ``(poly, len)``. + # Assumes ``len1 >= len2 > 0`` and ``0 < n <= 2 * len - 1``. + # Allows for zero-padding in the input. Does not support aliasing + # between the input and the output. + + void fmpz_poly_sqrlow(fmpz_poly_t res, const fmpz_poly_t poly, long n) + # Sets ``res`` to the lowest `n` coefficients + # of the square of ``poly``. + + void _fmpz_poly_pow_multinomial(fmpz * res, const fmpz * poly, long len, unsigned long e) + # Computes ``res = poly^e``. This uses the J.C.P. Miller pure + # recurrence as follows: + # If `\ell` is the index of the lowest non-zero coefficient in ``poly``, + # as a first step this method zeros out the lowest `e \ell` coefficients of + # ``res``. The recurrence above is then used to compute the remaining + # coefficients. + # Assumes ``len > 0``, ``e > 0``. Does not support aliasing. + + void fmpz_poly_pow_multinomial(fmpz_poly_t res, const fmpz_poly_t poly, unsigned long e) + # Computes ``res = poly^e`` using a generalisation of binomial expansion + # called the J.C.P. Miller pure recurrence [1], [2]. + # If `e` is zero, returns one, so that in particular ``0^0 = 1``. + # The formal statement of the recurrence is as follows. Write the input + # polynomial as `P(x) = p_0 + p_1 x + \dotsb + p_m x^m` with `p_0 \neq 0` + # and let + # .. math :: + # P(x)^n = a(n, 0) + a(n, 1) x + \dotsb + a(n, mn) x^{mn}. + # Then `a(n, 0) = p_0^n` and, for all `1 \leq k \leq mn`, + # .. math :: + # a(n, k) = + # (k p_0)^{-1} \sum_{i = 1}^m p_i \bigl( (n + 1) i - k \bigr) a(n, k-i). + # [1] D. Knuth, The Art of Computer Programming Vol. 2, Seminumerical + # Algorithms, Third Edition (Reading, Massachusetts: Addison-Wesley, 1997) + # [2] D. Zeilberger, The J.C.P. Miller Recurrence for Exponentiating a + # Polynomial, and its q-Analog, Journal of Difference Equations and + # Applications, 1995, Vol. 1, pp. 57--60 + + void _fmpz_poly_pow_binomial(fmpz * res, const fmpz * poly, unsigned long e) + # Computes ``res = poly^e`` when poly is of length 2, using binomial + # expansion. + # Assumes `e > 0`. Does not support aliasing. + + void fmpz_poly_pow_binomial(fmpz_poly_t res, const fmpz_poly_t poly, unsigned long e) + # Computes ``res = poly^e`` when ``poly`` is of length `2`, using + # binomial expansion. + # If the length of ``poly`` is not `2`, raises an exception and aborts. + + void _fmpz_poly_pow_addchains(fmpz * res, const fmpz * poly, long len, const int * a, int n) + # Given a star chain `1 = a_0 < a_1 < \dotsb < a_n = e` computes + # ``res = poly^e``. + # A star chain is an addition chain `1 = a_0 < a_1 < \dotsb < a_n` such + # that, for all `i > 0`, `a_i = a_{i-1} + a_j` for some `j < i`. + # Assumes that `e > 2`, or equivalently `n > 1`, and ``len > 0``. Does + # not support aliasing. + + void fmpz_poly_pow_addchains(fmpz_poly_t res, const fmpz_poly_t poly, unsigned long e) + # Computes ``res = poly^e`` using addition chains whenever + # `0 \leq e \leq 148`. + # If `e > 148`, raises an exception and aborts. + + void _fmpz_poly_pow_binexp(fmpz * res, const fmpz * poly, long len, unsigned long e) + # Sets ``res = poly^e`` using left-to-right binary exponentiation as + # described on p. 461 of [Knu1997]_. + # Assumes that ``len > 0``, ``e > 1``. Assumes that ``res`` is + # an array of length at least ``e*(len - 1) + 1``. Does not support + # aliasing. + + void fmpz_poly_pow_binexp(fmpz_poly_t res, const fmpz_poly_t poly, unsigned long e) + # Computes ``res = poly^e`` using the binary exponentiation algorithm. + # If `e` is zero, returns one, so that in particular ``0^0 = 1``. + + void _fmpz_poly_pow_small(fmpz * res, const fmpz * poly, long len, unsigned long e) + # Sets ``res = poly^e`` whenever `0 \leq e \leq 4`. + # Assumes that ``len > 0`` and that ``res`` is an array of length + # at least ``e*(len - 1) + 1``. Does not support aliasing. + + void _fmpz_poly_pow(fmpz * res, const fmpz * poly, long len, unsigned long e) + # Sets ``res = poly^e``, assuming that ``e, len > 0`` and that + # ``res`` has space for ``e*(len - 1) + 1`` coefficients. Does + # not support aliasing. + + void fmpz_poly_pow(fmpz_poly_t res, const fmpz_poly_t poly, unsigned long e) + # Computes ``res = poly^e``. If `e` is zero, returns one, + # so that in particular ``0^0 = 1``. + + void _fmpz_poly_pow_trunc(fmpz * res, const fmpz * poly, unsigned long e, long n) + # Sets ``(res, n)`` to ``(poly, n)`` raised to the power `e` and + # truncated to length `n`. + # Assumes that `e, n > 0`. Allows zero-padding of ``(poly, n)``. + # Does not support aliasing of any inputs and outputs. + + void fmpz_poly_pow_trunc(fmpz_poly_t res, const fmpz_poly_t poly, unsigned long e, long n) + # Notationally raises ``poly`` to the power `e`, truncates the result + # to length `n` and writes the result in ``res``. This is computed + # much more efficiently than simply powering the polynomial and truncating. + # Thus, if `n = 0` the result is zero. Otherwise, whenever `e = 0` the + # result will be the constant polynomial equal to `1`. + # This function can be used to raise power series to a power in an + # efficient way. + + void _fmpz_poly_shift_left(fmpz * res, const fmpz * poly, long len, long n) + # Sets ``(res, len + n)`` to ``(poly, len)`` shifted left by + # `n` coefficients. + # Inserts zero coefficients at the lower end. Assumes that ``len`` + # and `n` are positive, and that ``res`` fits ``len + n`` elements. + # Supports aliasing between ``res`` and ``poly``. + + void fmpz_poly_shift_left(fmpz_poly_t res, const fmpz_poly_t poly, long n) + # Sets ``res`` to ``poly`` shifted left by `n` coeffs. Zero + # coefficients are inserted. + + void _fmpz_poly_shift_right(fmpz * res, const fmpz * poly, long len, long n) + # Sets ``(res, len - n)`` to ``(poly, len)`` shifted right by + # `n` coefficients. + # Assumes that ``len`` and `n` are positive, that ``len > n``, + # and that ``res`` fits ``len - n`` elements. Supports aliasing + # between ``res`` and ``poly``, although in this case the top + # coefficients of ``poly`` are not set to zero. + + void fmpz_poly_shift_right(fmpz_poly_t res, const fmpz_poly_t poly, long n) + # Sets ``res`` to ``poly`` shifted right by `n` coefficients. If `n` + # is equal to or greater than the current length of ``poly``, ``res`` + # is set to the zero polynomial. + + unsigned long fmpz_poly_max_limbs(const fmpz_poly_t poly) + # Returns the maximum number of limbs required to store the absolute value + # of coefficients of ``poly``. If ``poly`` is zero, returns `0`. + + long fmpz_poly_max_bits(const fmpz_poly_t poly) + # Computes the maximum number of bits `b` required to store the absolute + # value of coefficients of ``poly``. If all the coefficients of + # ``poly`` are non-negative, `b` is returned, otherwise `-b` is returned. + + void fmpz_poly_height(fmpz_t height, const fmpz_poly_t poly) + # Computes the height of ``poly``, defined as the largest of the + # absolute values of the coefficients of ``poly``. Equivalently, this + # gives the infinity norm of the coefficients. If ``poly`` is zero, + # the height is `0`. + + void _fmpz_poly_2norm(fmpz_t res, const fmpz * poly, long len) + # Sets ``res`` to the Euclidean norm of ``(poly, len)``, that is, + # the integer square root of the sum of the squares of the coefficients + # of ``poly``. + + void fmpz_poly_2norm(fmpz_t res, const fmpz_poly_t poly) + # Sets ``res`` to the Euclidean norm of ``poly``, that is, the + # integer square root of the sum of the squares of the coefficients of + # ``poly``. + + mp_limb_t _fmpz_poly_2norm_normalised_bits(const fmpz * poly, long len) + # Returns an upper bound on the number of bits of the normalised + # Euclidean norm of ``(poly, len)``, i.e. the number of bits of + # the Euclidean norm divided by the absolute value of the leading + # coefficient. The returned value will be no more than 1 bit too + # large. + # This is used in the computation of the Landau-Mignotte bound. + # It is assumed that ``len > 0``. The result only makes sense + # if the leading coefficient is nonzero. + + void _fmpz_poly_gcd_subresultant(fmpz * res, const fmpz * poly1, long len1, const fmpz * poly2, long len2) + # Computes the greatest common divisor ``(res, len2)`` of + # ``(poly1, len1)`` and ``(poly2, len2)``, assuming + # ``len1 >= len2 > 0``. The result is normalised to have + # positive leading coefficient. Aliasing between ``res``, + # ``poly1`` and ``poly2`` is supported. + + void fmpz_poly_gcd_subresultant(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2) + # Computes the greatest common divisor ``res`` of ``poly1`` and + # ``poly2``, normalised to have non-negative leading coefficient. + # This function uses the subresultant algorithm as described + # in Algorithm 3.3.1 of [Coh1996]_. + + int _fmpz_poly_gcd_heuristic(fmpz * res, const fmpz * poly1, long len1, const fmpz * poly2, long len2) + # Computes the greatest common divisor ``(res, len2)`` of + # ``(poly1, len1)`` and ``(poly2, len2)``, assuming + # ``len1 >= len2 > 0``. The result is normalised to have + # positive leading coefficient. Aliasing between ``res``, + # ``poly1`` and ``poly2`` is not supported. The function + # may not always succeed in finding the GCD. If it fails, the + # function returns 0, otherwise it returns 1. + + int fmpz_poly_gcd_heuristic(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2) + # Computes the greatest common divisor ``res`` of ``poly1`` and + # ``poly2``, normalised to have non-negative leading coefficient. + # The function may not always succeed in finding the GCD. If it fails, + # the function returns 0, otherwise it returns 1. + # This function uses the heuristic GCD algorithm (GCDHEU). The basic + # strategy is to remove the content of the polynomials, pack them + # using Kronecker segmentation (given a bound on the size of the + # coefficients of the GCD) and take the integer GCD. Unpack the + # result and test divisibility. + + void _fmpz_poly_gcd_modular(fmpz * res, const fmpz * poly1, long len1, const fmpz * poly2, long len2) + # Computes the greatest common divisor ``(res, len2)`` of + # ``(poly1, len1)`` and ``(poly2, len2)``, assuming + # ``len1 >= len2 > 0``. The result is normalised to have + # positive leading coefficient. Aliasing between ``res``, + # ``poly1`` and ``poly2`` is not supported. + + void fmpz_poly_gcd_modular(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2) + # Computes the greatest common divisor ``res`` of ``poly1`` and + # ``poly2``, normalised to have non-negative leading coefficient. + # This function uses the modular GCD algorithm. The basic + # strategy is to remove the content of the polynomials, reduce them + # modulo sufficiently many primes and do CRT reconstruction until + # some bound is reached (or we can prove with trial division that + # we have the GCD). + + void _fmpz_poly_gcd(fmpz * res, const fmpz * poly1, long len1, const fmpz * poly2, long len2) + # Computes the greatest common divisor ``res`` of ``(poly1, len1)`` + # and ``(poly2, len2)``, assuming ``len1 >= len2 > 0``. The result + # is normalised to have positive leading coefficient. + # Assumes that ``res`` has space for ``len2`` coefficients. + # Aliasing between ``res``, ``poly1`` and ``poly2`` is not + # supported. + + void fmpz_poly_gcd(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2) + # Computes the greatest common divisor ``res`` of ``poly1`` and + # ``poly2``, normalised to have non-negative leading coefficient. + + void _fmpz_poly_xgcd_modular(fmpz_t r, fmpz * s, fmpz * t, const fmpz * f, long len1, const fmpz * g, long len2) + # Set `r` to the resultant of ``(f, len1)`` and ``(g, len2)``. + # If the resultant is zero, the function returns immediately. Otherwise it + # finds polynomials `s` and `t` such that ``s*f + t*g = r``. The length + # of `s` will be no greater than ``len2`` and the length of `t` will be + # no greater than ``len1`` (both are zero padded if necessary). + # It is assumed that ``len1 >= len2 > 0``. No aliasing of inputs and + # outputs is permitted. + # The function assumes that `f` and `g` are primitive (have Gaussian content + # equal to 1). The result is undefined otherwise. + # Uses a multimodular algorithm. The resultant is first computed and + # extended GCDs modulo various primes `p` are computed and combined using + # CRT. When the CRT stabilises the resulting polynomials are simply reduced + # modulo further primes until a proven bound is reached. + + void fmpz_poly_xgcd_modular(fmpz_t r, fmpz_poly_t s, fmpz_poly_t t, const fmpz_poly_t f, const fmpz_poly_t g) + # Set `r` to the resultant of `f` and `g`. If the resultant is zero, the + # function then returns immediately, otherwise `s` and `t` are found such + # that ``s*f + t*g = r``. + # The function assumes that `f` and `g` are primitive (have Gaussian content + # equal to 1). The result is undefined otherwise. + # Uses the multimodular algorithm. + + void _fmpz_poly_xgcd(fmpz_t r, fmpz * s, fmpz * t, const fmpz * f, long len1, const fmpz * g, long len2) + # Set `r` to the resultant of ``(f, len1)`` and ``(g, len2)``. + # If the resultant is zero, the function returns immediately. Otherwise it + # finds polynomials `s` and `t` such that ``s*f + t*g = r``. The length + # of `s` will be no greater than ``len2`` and the length of `t` will be + # no greater than ``len1`` (both are zero padded if necessary). + # The function assumes that `f` and `g` are primitive (have Gaussian content + # equal to 1). The result is undefined otherwise. + # It is assumed that ``len1 >= len2 > 0``. No aliasing of inputs and + # outputs is permitted. + + void fmpz_poly_xgcd(fmpz_t r, fmpz_poly_t s, fmpz_poly_t t, const fmpz_poly_t f, const fmpz_poly_t g) + # Set `r` to the resultant of `f` and `g`. If the resultant is zero, the + # function then returns immediately, otherwise `s` and `t` are found such + # that ``s*f + t*g = r``. + # The function assumes that `f` and `g` are primitive (have Gaussian content + # equal to 1). The result is undefined otherwise. + + void _fmpz_poly_lcm(fmpz * res, const fmpz * poly1, long len1, const fmpz * poly2, long len2) + # Sets ``(res, len1 + len2 - 1)`` to the least common multiple + # of the two polynomials ``(poly1, len1)`` and ``(poly2, len2)``, + # normalised to have non-negative leading coefficient. + # Assumes that ``len1 >= len2 > 0``. + # Does not support aliasing. + + void fmpz_poly_lcm(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2) + # Sets ``res`` to the least common multiple of the two + # polynomials ``poly1`` and ``poly2``, normalised to + # have non-negative leading coefficient. + # If either of the two polynomials is zero, sets ``res`` + # to zero. + # This ensures that the equality + # .. math :: + # f g = \gcd(f, g) \operatorname{lcm}(f, g) + # holds up to sign. + + void _fmpz_poly_resultant_modular(fmpz_t res, const fmpz * poly1, long len1, const fmpz * poly2, long len2) + # Sets ``res`` to the resultant of ``(poly1, len1)`` and + # ``(poly2, len2)``, assuming that ``len1 >= len2 > 0``. + + void fmpz_poly_resultant_modular(fmpz_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2) + # Computes the resultant of ``poly1`` and ``poly2``. + # For two non-zero polynomials `f(x) = a_m x^m + \dotsb + a_0` and + # `g(x) = b_n x^n + \dotsb + b_0` of degrees `m` and `n`, the resultant + # is defined to be + # .. math :: + # a_m^n b_n^m \prod_{(x, y) : f(x) = g(y) = 0} (x - y). + # For convenience, we define the resultant to be equal to zero if either + # of the two polynomials is zero. + # This function uses the modular algorithm described + # in [Col1971]_. + + void fmpz_poly_resultant_modular_div(fmpz_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2, const fmpz_t div, long nbits) + # Computes the resultant of ``poly1`` and ``poly2`` divided by + # ``div`` using a slight modification of the above function. It is assumed that + # the resultant is exactly divisible by ``div`` and the result ``res`` + # has at most ``nbits`` bits. + # This bypasses the computation of general bounds. + + void _fmpz_poly_resultant_euclidean(fmpz_t res, const fmpz * poly1, long len1, const fmpz * poly2, long len2) + # Sets ``res`` to the resultant of ``(poly1, len1)`` and + # ``(poly2, len2)``, assuming that ``len1 >= len2 > 0``. + + void fmpz_poly_resultant_euclidean(fmpz_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2) + # Computes the resultant of ``poly1`` and ``poly2``. + # For two non-zero polynomials `f(x) = a_m x^m + \dotsb + a_0` and + # `g(x) = b_n x^n + \dotsb + b_0` of degrees `m` and `n`, the resultant + # is defined to be + # .. math :: + # a_m^n b_n^m \prod_{(x, y) : f(x) = g(y) = 0} (x - y). + # For convenience, we define the resultant to be equal to zero if either + # of the two polynomials is zero. + # This function uses the algorithm described + # in Algorithm 3.3.7 of [Coh1996]_. + + void _fmpz_poly_resultant(fmpz_t res, const fmpz * poly1, long len1, const fmpz * poly2, long len2) + # Sets ``res`` to the resultant of ``(poly1, len1)`` and + # ``(poly2, len2)``, assuming that ``len1 >= len2 > 0``. + + void fmpz_poly_resultant(fmpz_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2) + # Computes the resultant of ``poly1`` and ``poly2``. + # For two non-zero polynomials `f(x) = a_m x^m + \dotsb + a_0` and + # `g(x) = b_n x^n + \dotsb + b_0` of degrees `m` and `n`, the resultant + # is defined to be + # .. math :: + # a_m^n b_n^m \prod_{(x, y) : f(x) = g(y) = 0} (x - y). + # For convenience, we define the resultant to be equal to zero if either + # of the two polynomials is zero. + + void _fmpz_poly_discriminant(fmpz_t res, const fmpz * poly, long len) + # Set ``res`` to the discriminant of ``(poly, len)``. Assumes + # ``len > 1``. + + void fmpz_poly_discriminant(fmpz_t res, const fmpz_poly_t poly) + # Set ``res`` to the discriminant of ``poly``. We normalise the + # discriminant so that `\operatorname{disc}(f) = (-1)^{(n(n-1)/2)} + # \operatorname{res}(f, f')/\operatorname{lc}(f)`, thus + # `\operatorname{disc}(f) = \operatorname{lc}(f)^{(2n - 2)} \prod_{i < j} (r_i + # - r_j)^2`, where `\operatorname{lc}(f)` is the leading coefficient of `f`, + # `n` is the degree of `f` and `r_i` are the roots of `f`. + + void _fmpz_poly_content(fmpz_t res, const fmpz * poly, long len) + # Sets ``res`` to the non-negative content of ``(poly, len)``. + # Aliasing between ``res`` and the coefficients of ``poly`` is + # not supported. + + void fmpz_poly_content(fmpz_t res, const fmpz_poly_t poly) + # Sets ``res`` to the non-negative content of ``poly``. The content + # of the zero polynomial is defined to be zero. Supports aliasing, that is, + # ``res`` is allowed to be one of the coefficients of ``poly``. + + void _fmpz_poly_primitive_part(fmpz * res, const fmpz * poly, long len) + # Sets ``(res, len)`` to ``(poly, len)`` divided by the content + # of ``(poly, len)``, and normalises the result to have non-negative + # leading coefficient. + # Assumes that ``(poly, len)`` is non-zero. Supports aliasing of + # ``res`` and ``poly``. + + void fmpz_poly_primitive_part(fmpz_poly_t res, const fmpz_poly_t poly) + # Sets ``res`` to ``poly`` divided by the content of ``poly``, + # and normalises the result to have non-negative leading coefficient. + # If ``poly`` is zero, sets ``res`` to zero. + + int _fmpz_poly_is_squarefree(const fmpz * poly, long len) + # Returns whether the polynomial ``(poly, len)`` is square-free. + + int fmpz_poly_is_squarefree(const fmpz_poly_t poly) + # Returns whether the polynomial ``poly`` is square-free. A non-zero + # polynomial is defined to be square-free if it has no non-unit square + # factors. We also define the zero polynomial to be square-free. + # Returns `1` if the length of ``poly`` is at most `2`. Returns whether + # the discriminant is zero for quadratic polynomials. Otherwise, returns + # whether the greatest common divisor of ``poly`` and its derivative has + # length `1`. + + int _fmpz_poly_divrem_basecase(fmpz * Q, fmpz * R, const fmpz * A, long lenA, const fmpz * B, long lenB, int exact) + # Computes ``(Q, lenA - lenB + 1)``, ``(R, lenA)`` such that + # `A = B Q + R` and each coefficient of `R` beyond ``lenB`` is reduced + # modulo the leading coefficient of `B`. + # If the leading coefficient of `B` is `\pm 1` or the division is exact, + # this is the same thing as division over `\mathbb{Q}`. + # Assumes that `\operatorname{len}(A), \operatorname{len}(B) > 0`. Allows zero-padding in + # ``(A, lenA)``. `R` and `A` may be aliased, but apart from this no + # aliasing of input and output operands is allowed. + # If the flag ``exact`` is `1`, the function stops if an inexact division + # is encountered, upon which the function will return `0`. If no inexact + # division is encountered, the function returns `1`. Note that this does not + # guarantee the remainder of the polynomial division is zero, merely that + # its length is less than that of B. This feature is useful for series + # division and for divisibility testing (upon testing the remainder). + # For ordinary use set the flag ``exact`` to `0`. In this case, no checks + # or early aborts occur and the function always returns `1`. + + void fmpz_poly_divrem_basecase(fmpz_poly_t Q, fmpz_poly_t R, const fmpz_poly_t A, const fmpz_poly_t B) + # Computes `Q`, `R` such that `A = B Q + R` and each coefficient of `R` + # beyond `\operatorname{len}(B) - 1` is reduced modulo the leading coefficient of `B`. + # If the leading coefficient of `B` is `\pm 1` or the division is exact, + # this is the same thing as division over `\mathbb{Q}`. An exception is raised + # if `B` is zero. + + int _fmpz_poly_divrem_divconquer_recursive(fmpz * Q, fmpz * BQ, fmpz * W, const fmpz * A, const fmpz * B, long lenB, int exact) + # Computes ``(Q, lenB)``, ``(BQ, 2 lenB - 1)`` such that + # `BQ = B \times Q` and `A = B Q + R` where each coefficient of `R` beyond + # `\operatorname{len}(B) - 1` is reduced modulo the leading coefficient of `B`. We + # assume that `\operatorname{len}(A) = 2 \operatorname{len}(B) - 1`. If the leading coefficient + # of `B` is `\pm 1` or the division is exact, this is the same as division + # over `\mathbb{Q}`. + # Assumes `\operatorname{len}(B) > 0`. Allows zero-padding in ``(A, lenA)``. Requires + # a temporary array ``(W, 2 lenB - 1)``. No aliasing of input and output + # operands is allowed. + # This function does not read the bottom `\operatorname{len}(B) - 1` coefficients from + # `A`, which means that they might not even need to exist in allocated + # memory. + # If the flag ``exact`` is `1`, the function stops if an inexact division + # is encountered, upon which the function will return `0`. If no inexact + # division is encountered, the function returns `1`. Note that this does not + # guarantee the remainder of the polynomial division is zero, merely that + # its length is less than that of B. This feature is useful for series + # division and for divisibility testing (upon testing the remainder). + # For ordinary use set the flag ``exact`` to `0`. In this case, no checks + # or early aborts occur and the function always returns `1`. + + int _fmpz_poly_divrem_divconquer(fmpz * Q, fmpz * R, const fmpz * A, long lenA, const fmpz * B, long lenB, int exact) + # Computes ``(Q, lenA - lenB + 1)``, ``(R, lenA)`` such that + # `A = B Q + R` and each coefficient of `R` beyond `\operatorname{len}(B) - 1` is + # reduced modulo the leading coefficient of `B`. If the leading + # coefficient of `B` is `\pm 1` or the division is exact, this is + # the same as division over `\mathbb{Q}`. + # Assumes `\operatorname{len}(A) \geq \operatorname{len}(B) > 0`. Allows zero-padding in + # ``(A, lenA)``. No aliasing of input and output operands is + # allowed. + # If the flag ``exact`` is `1`, the function stops if an inexact division + # is encountered, upon which the function will return `0`. If no inexact + # division is encountered, the function returns `1`. Note that this does not + # guarantee the remainder of the polynomial division is zero, merely that + # its length is less than that of B. This feature is useful for series + # division and for divisibility testing (upon testing the remainder). + # For ordinary use set the flag ``exact`` to `0`. In this case, no checks + # or early aborts occur and the function always returns `1`. + + void fmpz_poly_divrem_divconquer(fmpz_poly_t Q, fmpz_poly_t R, const fmpz_poly_t A, const fmpz_poly_t B) + # Computes `Q`, `R` such that `A = B Q + R` and each coefficient of `R` + # beyond `\operatorname{len}(B) - 1` is reduced modulo the leading coefficient of `B`. + # If the leading coefficient of `B` is `\pm 1` or the division is exact, + # this is the same as division over `\mathbb{Q}`. An exception is raised if `B` + # is zero. + + int _fmpz_poly_divrem(fmpz * Q, fmpz * R, const fmpz * A, long lenA, const fmpz * B, long lenB, int exact) + # Computes ``(Q, lenA - lenB + 1)``, ``(R, lenA)`` such that + # `A = B Q + R` and each coefficient of `R` beyond `\operatorname{len}(B) - 1` is + # reduced modulo the leading coefficient of `B`. If the leading + # coefficient of `B` is `\pm 1` or the division is exact, this is + # the same thing as division over `\mathbb{Q}`. + # Assumes `\operatorname{len}(A) \geq \operatorname{len}(B) > 0`. Allows zero-padding in + # ``(A, lenA)``. No aliasing of input and output operands is + # allowed. + # If the flag ``exact`` is `1`, the function stops if an inexact division + # is encountered, upon which the function will return `0`. If no inexact + # division is encountered, the function returns `1`. Note that this does not + # guarantee the remainder of the polynomial division is zero, merely that + # its length is less than that of B. This feature is useful for series + # division and for divisibility testing (upon testing the remainder). + # For ordinary use set the flag ``exact`` to `0`. In this case, no checks + # or early aborts occur and the function always returns `1`. + + void fmpz_poly_divrem(fmpz_poly_t Q, fmpz_poly_t R, const fmpz_poly_t A, const fmpz_poly_t B) + # Computes `Q`, `R` such that `A = B Q + R` and each coefficient of `R` + # beyond `\operatorname{len}(B) - 1` is reduced modulo the leading coefficient of `B`. + # If the leading coefficient of `B` is `\pm 1` or the division is exact, + # this is the same as division over `\mathbb{Q}`. An exception is raised if `B` + # is zero. + + int _fmpz_poly_div_basecase(fmpz * Q, fmpz * R, const fmpz * A, long lenA, const fmpz * B, long lenB, int exact) + # Computes the quotient ``(Q, lenA - lenB + 1)`` of ``(A, lenA)`` + # divided by ``(B, lenB)``. + # Notationally, computes `Q`, `R` such that `A = B Q + R` and each + # coefficient of `R` beyond `\operatorname{len}(B) - 1` is reduced modulo the leading + # coefficient of `B`. + # If the leading coefficient of `B` is `\pm 1` or the division is exact, + # this is the same as division over `\mathbb{Q}`. + # Assumes `\operatorname{len}(A), \operatorname{len}(B) > 0`. Allows zero-padding in ``(A, lenA)``. + # Requires a temporary array `R` of size at least the (actual) length + # of `A`. For convenience, `R` may be ``NULL``. `R` and `A` may be + # aliased, but apart from this no aliasing of input and output operands + # is allowed. + # If the flag ``exact`` is `1`, the function stops if an inexact division + # is encountered, upon which the function will return `0`. If no inexact + # division is encountered, the function returns `1`. Note that this does not + # guarantee the remainder of the polynomial division is zero, merely that + # its length is less than that of B. This feature is useful for series + # division and for divisibility testing (upon testing the remainder). + # For ordinary use set the flag ``exact`` to `0`. In this case, no checks + # or early aborts occur and the function always returns `1`. + + void fmpz_poly_div_basecase(fmpz_poly_t Q, const fmpz_poly_t A, const fmpz_poly_t B) + # Computes the quotient `Q` of `A` divided by `Q`. + # Notationally, computes `Q`, `R` such that `A = B Q + R` and each + # coefficient of `R` beyond `\operatorname{len}(B) - 1` is reduced modulo the leading + # coefficient of `B`. + # If the leading coefficient of `B` is `\pm 1` or the division is exact, + # this is the same as division over `\mathbb{Q}`. An exception is raised if `B` + # is zero. + + int _fmpz_poly_divremlow_divconquer_recursive(fmpz * Q, fmpz * BQ, const fmpz * A, const fmpz * B, long lenB, int exact) + # Divide and conquer division of ``(A, 2 lenB - 1)`` by ``(B, lenB)``, + # computing only the bottom `\operatorname{len}(B) - 1` coefficients of `B Q`. + # Assumes `\operatorname{len}(B) > 0`. Requires `B Q` to have length at least + # `2 \operatorname{len}(B) - 1`, although only the bottom `\operatorname{len}(B) - 1` coefficients will + # carry meaningful output. Does not support any aliasing. Allows + # zero-padding in `A`, but not in `B`. + # If the flag ``exact`` is `1`, the function stops if an inexact division + # is encountered, upon which the function will return `0`. If no inexact + # division is encountered, the function returns `1`. Note that this does not + # guarantee the remainder of the polynomial division is zero, merely that + # its length is less than that of B. This feature is useful for series + # division and for divisibility testing (upon testing the remainder). + # For ordinary use set the flag ``exact`` to `0`. In this case, no checks + # or early aborts occur and the function always returns `1`. + + int _fmpz_poly_div_divconquer_recursive(fmpz * Q, fmpz * temp, const fmpz * A, const fmpz * B, long lenB, int exact) + # Recursive short division in the balanced case. + # Computes the quotient ``(Q, lenB)`` of ``(A, 2 lenB - 1)`` upon + # division by ``(B, lenB)``. Requires `\operatorname{len}(B) > 0`. Needs a + # temporary array ``temp`` of length `2 \operatorname{len}(B) - 1`. Does not support + # any aliasing. + # For further details, see [Mul2000]_. + # If the flag ``exact`` is `1`, the function stops if an inexact division + # is encountered, upon which the function will return `0`. If no inexact + # division is encountered, the function returns `1`. Note that this does not + # guarantee the remainder of the polynomial division is zero, merely that + # its length is less than that of B. This feature is useful for series + # division and for divisibility testing (upon testing the remainder). + # For ordinary use set the flag ``exact`` to `0`. In this case, no checks + # or early aborts occur and the function always returns `1`. + + int _fmpz_poly_div_divconquer(fmpz * Q, const fmpz * A, long lenA, const fmpz * B, long lenB, int exact) + # Computes the quotient ``(Q, lenA - lenB + 1)`` of ``(A, lenA)`` + # upon division by ``(B, lenB)``. Assumes that + # `\operatorname{len}(A) \geq \operatorname{len}(B) > 0`. Does not support aliasing. + # If the flag ``exact`` is `1`, the function stops if an inexact division + # is encountered, upon which the function will return `0`. If no inexact + # division is encountered, the function returns `1`. Note that this does not + # guarantee the remainder of the polynomial division is zero, merely that + # its length is less than that of B. This feature is useful for series + # division and for divisibility testing (upon testing the remainder). + # For ordinary use set the flag ``exact`` to `0`. In this case, no checks + # or early aborts occur and the function always returns `1`. + + void fmpz_poly_div_divconquer(fmpz_poly_t Q, const fmpz_poly_t A, const fmpz_poly_t B) + # Computes the quotient `Q` of `A` divided by `B`. + # Notationally, computes `Q`, `R` such that `A = B Q + R` and each + # coefficient of `R` beyond `\operatorname{len}(B) - 1` is reduced modulo the leading + # coefficient of `B`. + # If the leading coefficient of `B` is `\pm 1` or the division is exact, + # this is the same as division over `\mathbb{Q}`. An exception is raised if `B` + # is zero. + + int _fmpz_poly_div(fmpz * Q, const fmpz * A, long lenA, const fmpz * B, long lenB, int exact) + # Computes the quotient ``(Q, lenA - lenB + 1)`` of ``(A, lenA)`` + # divided by ``(B, lenB)``. + # Notationally, computes `Q`, `R` such that `A = B Q + R` and each + # coefficient of `R` beyond `\operatorname{len}(B) - 1` is reduced modulo the leading + # coefficient of `B`. If the leading coefficient of `B` is `\pm 1` or + # the division is exact, this is the same as division over `\mathbb{Q}`. + # Assumes `\operatorname{len}(A) \geq \operatorname{len}(B) > 0`. Allows zero-padding in + # ``(A, lenA)``. Aliasing of input and output operands is not + # allowed. + # If the flag ``exact`` is `1`, the function stops if an inexact division + # is encountered, upon which the function will return `0`. If no inexact + # division is encountered, the function returns `1`. Note that this does not + # guarantee the remainder of the polynomial division is zero, merely that + # its length is less than that of B. This feature is useful for series + # division and for divisibility testing (upon testing the remainder). + # For ordinary use set the flag ``exact`` to `0`. In this case, no checks + # or early aborts occur and the function always returns `1`. + + void fmpz_poly_div(fmpz_poly_t Q, const fmpz_poly_t A, const fmpz_poly_t B) + # Computes the quotient `Q` of `A` divided by `B`. + # Notationally, computes `Q`, `R` such that `A = B Q + R` and each + # coefficient of `R` beyond `\operatorname{len}(B) - 1` is reduced modulo the leading + # coefficient of `B`. If the leading coefficient of `B` is `\pm 1` or + # the division is exact, this is the same as division over `Q`. An + # exception is raised if `B` is zero. + + void _fmpz_poly_rem_basecase(fmpz * R, const fmpz * A, long lenA, const fmpz * B, long lenB) + # Computes the remainder ``(R, lenA)`` of ``(A, lenA)`` upon + # division by ``(B, lenB)``. + # Notationally, computes `Q`, `R` such that `A = B Q + R` and each + # coefficient of `R` beyond `\operatorname{len}(B) - 1` is reduced modulo the leading + # coefficient of `B`. If the leading coefficient of `B` is `\pm 1` or + # the division is exact, this is the same thing as division over `\mathbb{Q}`. + # Assumes that `\operatorname{len}(A), \operatorname{len}(B) > 0`. Allows zero-padding in + # ``(A, lenA)``. `R` and `A` may be aliased, but apart from this no + # aliasing of input and output operands is allowed. + + void fmpz_poly_rem_basecase(fmpz_poly_t R, const fmpz_poly_t A, const fmpz_poly_t B) + # Computes the remainder `R` of `A` upon division by `B`. + # Notationally, computes `Q`, `R` such that `A = B Q + R` and each + # coefficient of `R` beyond `\operatorname{len}(B) - 1` is reduced modulo the leading + # coefficient of `B`. If the leading coefficient of `B` is `\pm 1` or + # the division is exact, this is the same as division over `\mathbb{Q}`. An + # exception is raised if `B` is zero. + + void _fmpz_poly_rem(fmpz * R, const fmpz * A, long lenA, const fmpz * B, long lenB) + # Computes the remainder ``(R, lenA)`` of ``(A, lenA)`` upon division + # by ``(B, lenB)``. + # Notationally, computes `Q`, `R` such that `A = B Q + R` and each + # coefficient of `R` beyond `\operatorname{len}(B) - 1` is reduced modulo the leading + # coefficient of `B`. If the leading coefficient of `B` is `\pm 1` or + # the division is exact, this is the same thing as division over `\mathbb{Q}`. + # Assumes that `\operatorname{len}(A) \geq \operatorname{len}(B) > 0`. Allows zero-padding in + # ``(A, lenA)``. Aliasing of input and output operands is not allowed. + + void fmpz_poly_rem(fmpz_poly_t R, const fmpz_poly_t A, const fmpz_poly_t B) + # Computes the remainder `R` of `A` upon division by `B`. + # Notationally, computes `Q`, `R` such that `A = B Q + R` and each + # coefficient of `R` beyond `\operatorname{len}(B) - 1` is reduced modulo the leading + # coefficient of `B`. If the leading coefficient of `B` is `\pm 1` or + # the division is exact, this is the same as division over `\mathbb{Q}`. An + # exception is raised if `B` is zero. + + void _fmpz_poly_div_root(fmpz * Q, const fmpz * A, long len, const fmpz_t c) + # Computes the quotient ``(Q, len-1)`` of ``(A, len)`` upon + # division by `x - c`. + # Supports aliasing of ``Q`` and ``A``, but the result is + # undefined in case of partial overlap. + + void fmpz_poly_div_root(fmpz_poly_t Q, const fmpz_poly_t A, const fmpz_t c) + # Computes the quotient ``(Q, len-1)`` of ``(A, len)`` upon + # division by `x - c`. + + void _fmpz_poly_preinvert(fmpz * B_inv, const fmpz * B, long n) + # Given a monic polynomial ``B`` of length ``n``, compute a precomputed + # inverse ``B_inv`` of length ``n`` for use in the functions below. No + # aliasing of ``B`` and ``B_inv`` is permitted. We assume ``n`` is not zero. + + void fmpz_poly_preinvert(fmpz_poly_t B_inv, const fmpz_poly_t B) + # Given a monic polynomial ``B``, compute a precomputed inverse + # ``B_inv`` for use in the functions below. An exception is raised if + # ``B`` is zero. + + void _fmpz_poly_div_preinv(fmpz * Q, const fmpz * A, long len1, const fmpz * B, const fmpz * B_inv, long len2) + # Given a precomputed inverse ``B_inv`` of the polynomial ``B`` of + # length ``len2``, compute the quotient ``Q`` of ``A`` by ``B``. + # We assume the length ``len1`` of ``A`` is at least ``len2``. The + # polynomial ``Q`` must have space for ``len1 - len2 + 1`` + # coefficients. No aliasing of operands is permitted. + + void fmpz_poly_div_preinv(fmpz_poly_t Q, const fmpz_poly_t A, const fmpz_poly_t B, const fmpz_poly_t B_inv) + # Given a precomputed inverse ``B_inv`` of the polynomial ``B``, + # compute the quotient ``Q`` of ``A`` by ``B``. Aliasing of ``B`` + # and ``B_inv`` is not permitted. + + void _fmpz_poly_divrem_preinv(fmpz * Q, fmpz * A, long len1, const fmpz * B, const fmpz * B_inv, long len2) + # Given a precomputed inverse ``B_inv`` of the polynomial ``B`` of + # length ``len2``, compute the quotient ``Q`` of ``A`` by ``B``. + # The remainder is then placed in ``A``. We assume the length ``len1`` + # of ``A`` is at least ``len2``. The polynomial ``Q`` must have + # space for ``len1 - len2 + 1`` coefficients. No aliasing of operands is + # permitted. + + void fmpz_poly_divrem_preinv(fmpz_poly_t Q, fmpz_poly_t R, const fmpz_poly_t A, const fmpz_poly_t B, const fmpz_poly_t B_inv) + # Given a precomputed inverse ``B_inv`` of the polynomial ``B``, + # compute the quotient ``Q`` of ``A`` by ``B`` and the remainder + # ``R``. Aliasing of ``B`` and ``B_inv`` is not permitted. + + fmpz ** _fmpz_poly_powers_precompute(const fmpz * B, long len) + # Computes ``2*len - 1`` powers of `x` modulo the polynomial `B` of + # the given length. This is used as a kind of precomputed inverse in + # the remainder routine below. + + void fmpz_poly_powers_precompute(fmpz_poly_powers_precomp_t pinv, fmpz_poly_t poly) + # Computes ``2*len - 1`` powers of `x` modulo the polynomial `B` of + # the given length. This is used as a kind of precomputed inverse in + # the remainder routine below. + + void _fmpz_poly_powers_clear(fmpz ** powers, long len) + # Clean up resources used by precomputed powers which have been computed + # by ``_fmpz_poly_powers_precompute``. + + void fmpz_poly_powers_clear(fmpz_poly_powers_precomp_t pinv) + # Clean up resources used by precomputed powers which have been computed + # by ``fmpz_poly_powers_precompute``. + + void _fmpz_poly_rem_powers_precomp(fmpz * A, long m, const fmpz * B, long n, fmpz ** const powers) + # Set `A` to the remainder of `A` divide `B` given precomputed powers mod `B` + # provided by ``_fmpz_poly_powers_precompute``. No aliasing is allowed. + + void fmpz_poly_rem_powers_precomp(fmpz_poly_t R, const fmpz_poly_t A, const fmpz_poly_t B, const fmpz_poly_powers_precomp_t B_inv) + # Set `R` to the remainder of `A` divide `B` given precomputed powers mod `B` + # provided by ``fmpz_poly_powers_precompute``. + + int _fmpz_poly_divides(fmpz * Q, const fmpz * A, long lenA, const fmpz * B, long lenB) + # Returns 1 if ``(B, lenB)`` divides ``(A, lenA)`` exactly and + # sets `Q` to the quotient, otherwise returns 0. + # It is assumed that `\operatorname{len}(A) \geq \operatorname{len}(B) > 0` and that `Q` has space + # for `\operatorname{len}(A) - \operatorname{len}(B) + 1` coefficients. + # Aliasing of `Q` with either of the inputs is not permitted. + # This function is currently unoptimised and provided for convenience + # only. + + int fmpz_poly_divides(fmpz_poly_t Q, const fmpz_poly_t A, const fmpz_poly_t B) + # Returns 1 if `B` divides `A` exactly and sets `Q` to the quotient, + # otherwise returns 0. + # This function is currently unoptimised and provided for convenience + # only. + + long fmpz_poly_remove(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2) + # Set ``res`` to ``poly1`` divided by the highest power of ``poly2`` that + # divides it and return the power. The divisor ``poly2`` must not be zero or + # `\pm 1`, otherwise an exception is raised. + + void fmpz_poly_divlow_smodp(fmpz * res, const fmpz_poly_t f, const fmpz_poly_t g, const fmpz_t p, long n) + # Compute the `n` lowest coefficients of `f` divided by `g`, assuming the + # division is exact modulo `p`. The computed coefficients are reduced modulo + # `p` using the symmetric remainder system. We require `f` to be at least `n` + # in length. The function can handle trailing zeroes, but the low nonzero + # coefficient of `g` must be coprime to `p`. This is a bespoke function used + # by factoring. + + void fmpz_poly_divhigh_smodp(fmpz * res, const fmpz_poly_t f, const fmpz_poly_t g, const fmpz_t p, long n) + # Compute the `n` highest coefficients of `f` divided by `g`, assuming the + # division is exact modulo `p`. The computed coefficients are reduced modulo + # `p` using the symmetric remainder system. We require `f` to be as output + # by ``fmpz_poly_mulhigh_n`` given polynomials `g` and a polynomial of + # length `n` as inputs. The leading coefficient of `g` must be coprime to + # `p`. This is a bespoke function used by factoring. + + void _fmpz_poly_inv_series_basecase(fmpz * Qinv, const fmpz * Q, long Qlen, long n) + # Computes the first `n` terms of the inverse power series of + # ``(Q, lenQ)`` using a recurrence. + # Assumes that `n \geq 1` and that `Q` has constant term `\pm 1`. + # Does not support aliasing. + + void fmpz_poly_inv_series_basecase(fmpz_poly_t Qinv, const fmpz_poly_t Q, long n) + # Computes the first `n` terms of the inverse power series of `Q` + # using a recurrence, assuming that `Q` has constant term `\pm 1` + # and `n \geq 1`. + + void _fmpz_poly_inv_series_newton(fmpz * Qinv, const fmpz * Q, long Qlen, long n) + # Computes the first `n` terms of the inverse power series of + # ``(Q, lenQ)`` using Newton iteration. + # Assumes that `n \geq 1` and that `Q` has constant term `\pm 1`. + # Does not support aliasing. + + void fmpz_poly_inv_series_newton(fmpz_poly_t Qinv, const fmpz_poly_t Q, long n) + # Computes the first `n` terms of the inverse power series of `Q` using + # Newton iteration, assuming `Q` has constant term `\pm 1` and `n \geq 1`. + + void _fmpz_poly_inv_series(fmpz * Qinv, const fmpz * Q, long Qlen, long n) + # Computes the first `n` terms of the inverse power series of + # ``(Q, lenQ)``. + # Assumes that `n \geq 1` and that `Q` has constant term `\pm 1`. + # Does not support aliasing. + + void fmpz_poly_inv_series(fmpz_poly_t Qinv, const fmpz_poly_t Q, long n) + # Computes the first `n` terms of the inverse power series of `Q`, + # assuming `Q` has constant term `\pm 1` and `n \geq 1`. + + void _fmpz_poly_div_series_basecase(fmpz * Q, const fmpz * A, long Alen, const fmpz * B, long Blen, long n) + + void _fmpz_poly_div_series_divconquer(fmpz * Q, const fmpz * A, long Alen, const fmpz * B, long Blen, long n) + + void _fmpz_poly_div_series(fmpz * Q, const fmpz * A, long Alen, const fmpz * B, long Blen, long n) + # Divides ``(A, Alen)`` by ``(B, Blen)`` as power series over `\mathbb{Z}`, + # assuming `B` has constant term `\pm 1` and `n \geq 1`. + # Aliasing is not supported. + + void fmpz_poly_div_series_basecase(fmpz_poly_t Q, const fmpz_poly_t A, const fmpz_poly_t B, long n) + + void fmpz_poly_div_series_divconquer(fmpz_poly_t Q, const fmpz_poly_t A, const fmpz_poly_t B, long n) + + void fmpz_poly_div_series(fmpz_poly_t Q, const fmpz_poly_t A, const fmpz_poly_t B, long n) + # Performs power series division in `\mathbb{Z}[[x]] / (x^n)`. The function + # considers the polynomials `A` and `B` as power series of length `n` + # starting with the constant terms. The function assumes that `B` has + # constant term `\pm 1` and `n \geq 1`. + + void _fmpz_poly_pseudo_divrem_basecase(fmpz * Q, fmpz * R, unsigned long * d, const fmpz * A, long lenA, const fmpz * B, long lenB, const fmpz_preinvn_t inv) + # If `\ell` is the leading coefficient of `B`, then computes `Q`, `R` such + # that `\ell^d A = Q B + R`. This function is used for simulating division + # over `\mathbb{Q}`. + # Assumes that `\operatorname{len}(A) \geq \operatorname{len}(B) > 0`. Assumes that `Q` can fit + # `\operatorname{len}(A) - \operatorname{len}(B) + 1` coefficients, and that `R` can fit `\operatorname{len}(A)` + # coefficients. Supports aliasing of ``(R, lenA)`` and ``(A, lenA)``. + # But other than this, no aliasing of the inputs and outputs is supported. + # An optional precomputed inverse of the leading coefficient of `B` from + # ``fmpz_preinvn_init`` can be supplied. Otherwise ``inv`` should be + # ``NULL``. + # Note: ``fmpz.h`` has to be included before ``fmpz_poly.h`` in order for + # ``fmpz_poly.h`` to declare this function. + + void fmpz_poly_pseudo_divrem_basecase(fmpz_poly_t Q, fmpz_poly_t R, unsigned long * d, const fmpz_poly_t A, const fmpz_poly_t B) + # If `\ell` is the leading coefficient of `B`, then computes `Q`, `R` such + # that `\ell^d A = Q B + R`. This function is used for simulating division + # over `\mathbb{Q}`. + + void _fmpz_poly_pseudo_divrem_divconquer(fmpz * Q, fmpz * R, unsigned long * d, const fmpz * A, long lenA, const fmpz * B, long lenB, const fmpz_preinvn_t inv) + # Computes ``(Q, lenA - lenB + 1)``, ``(R, lenA)`` such that + # `\ell^d A = B Q + R`, only setting the bottom `\operatorname{len}(B) - 1` coefficients + # of `R` to their correct values. The remaining top coefficients of + # ``(R, lenA)`` may be arbitrary. + # Assumes `\operatorname{len}(A) \geq \operatorname{len}(B) > 0`. Allows zero-padding in + # ``(A, lenA)``. No aliasing of input and output operands is allowed. + # An optional precomputed inverse of the leading coefficient of `B` from + # ``fmpz_preinvn_init`` can be supplied. Otherwise ``inv`` should be + # ``NULL``. + # Note: ``fmpz.h`` has to be included before ``fmpz_poly.h`` in order for + # ``fmpz_poly.h`` to declare this function. + + void fmpz_poly_pseudo_divrem_divconquer(fmpz_poly_t Q, fmpz_poly_t R, unsigned long * d, const fmpz_poly_t A, const fmpz_poly_t B) + # Computes `Q`, `R`, and `d` such that `\ell^d A = B Q + R`, where `R` has + # length less than the length of `B` and `\ell` is the leading coefficient + # of `B`. An exception is raised if `B` is zero. + + void _fmpz_poly_pseudo_divrem_cohen(fmpz * Q, fmpz * R, const fmpz * A, long lenA, const fmpz * B, long lenB) + # Assumes that `\operatorname{len}(A) \geq \operatorname{len}(B) > 0`. Assumes that `Q` can fit + # `\operatorname{len}(A) - \operatorname{len}(B) + 1` coefficients, and that `R` can fit `\operatorname{len}(A)` + # coefficients. Supports aliasing of ``(R, lenA)`` and ``(A, lenA)``. + # But other than this, no aliasing of the inputs and outputs is supported. + + void fmpz_poly_pseudo_divrem_cohen(fmpz_poly_t Q, fmpz_poly_t R, const fmpz_poly_t A, const fmpz_poly_t B) + # This is a variant of ``fmpz_poly_pseudo_divrem`` which computes + # polynomials `Q` and `R` such that `\ell^d A = B Q + R`. However, the + # value of `d` is fixed at `\max{\{0, \operatorname{len}(A) - \operatorname{len}(B) + 1\}}`. + # This function is faster when the remainder is not well behaved, i.e. + # where it is not expected to be close to zero. Note that this function + # is not asymptotically fast. It is efficient only for short polynomials, + # e.g. when `\operatorname{len}(B) < 32`. + + void _fmpz_poly_pseudo_rem_cohen(fmpz * R, const fmpz * A, long lenA, const fmpz * B, long lenB) + # Assumes that `\operatorname{len}(A) \geq \operatorname{len}(B) > 0`. Assumes that `R` can fit + # `\operatorname{len}(A)` coefficients. Supports aliasing of ``(R, lenA)`` and + # ``(A, lenA)``. But other than this, no aliasing of the inputs and + # outputs is supported. + + void fmpz_poly_pseudo_rem_cohen(fmpz_poly_t R, const fmpz_poly_t A, const fmpz_poly_t B) + # This is a variant of :func:`fmpz_poly_pseudo_rem` which computes + # polynomials `Q` and `R` such that `\ell^d A = B Q + R`, but only + # returns `R`. However, the value of `d` is fixed at + # `\max{\{0, \operatorname{len}(A) - \operatorname{len}(B) + 1\}}`. + # This function is faster when the remainder is not well behaved, i.e. + # where it is not expected to be close to zero. Note that this function + # is not asymptotically fast. It is efficient only for short polynomials, + # e.g. when `\operatorname{len}(B) < 32`. + # This function uses the algorithm described + # in Algorithm 3.1.2 of [Coh1996]_. + + void _fmpz_poly_pseudo_divrem(fmpz * Q, fmpz * R, unsigned long * d, const fmpz * A, long lenA, const fmpz * B, long lenB, const fmpz_preinvn_t inv) + # If `\ell` is the leading coefficient of `B`, then computes + # ``(Q, lenA - lenB + 1)``, ``(R, lenB - 1)`` and `d` such that + # `\ell^d A = B Q + R`. This function is used for simulating division + # over `\mathbb{Q}`. + # Assumes that `\operatorname{len}(A) \geq \operatorname{len}(B) > 0`. Assumes that `Q` can fit + # `\operatorname{len}(A) - \operatorname{len}(B) + 1` coefficients, and that `R` can fit `\operatorname{len}(A)` + # coefficients, although on exit only the bottom `\operatorname{len}(B)` coefficients + # will carry meaningful data. + # Supports aliasing of ``(R, lenA)`` and ``(A, lenA)``. But other + # than this, no aliasing of the inputs and outputs is supported. + # An optional precomputed inverse of the leading coefficient of `B` from + # ``fmpz_preinvn_init`` can be supplied. Otherwise ``inv`` should be + # ``NULL``. + # Note: ``fmpz.h`` has to be included before ``fmpz_poly.h`` in order for + # ``fmpz_poly.h`` to declare this function. + + void fmpz_poly_pseudo_divrem(fmpz_poly_t Q, fmpz_poly_t R, unsigned long * d, const fmpz_poly_t A, const fmpz_poly_t B) + # Computes `Q`, `R`, and `d` such that `\ell^d A = B Q + R`. + + void _fmpz_poly_pseudo_div(fmpz * Q, unsigned long * d, const fmpz * A, long lenA, const fmpz * B, long lenB, const fmpz_preinvn_t inv) + # Pseudo-division, only returning the quotient. + # Note: ``fmpz.h`` has to be included before ``fmpz_poly.h`` in order for + # ``fmpz_poly.h`` to declare this function. + + void fmpz_poly_pseudo_div(fmpz_poly_t Q, unsigned long * d, const fmpz_poly_t A, const fmpz_poly_t B) + # Pseudo-division, only returning the quotient. + + void _fmpz_poly_pseudo_rem(fmpz * R, unsigned long * d, const fmpz * A, long lenA, const fmpz * B, long lenB, const fmpz_preinvn_t inv) + # Pseudo-division, only returning the remainder. + # Note: ``fmpz.h`` has to be included before ``fmpz_poly.h`` in order for + # ``fmpz_poly.h`` to declare this function. + + void fmpz_poly_pseudo_rem(fmpz_poly_t R, unsigned long * d, const fmpz_poly_t A, const fmpz_poly_t B) + # Pseudo-division, only returning the remainder. + + void _fmpz_poly_derivative(fmpz * rpoly, const fmpz * poly, long len) + # Sets ``(rpoly, len - 1)`` to the derivative of ``(poly, len)``. + # Also handles the cases where ``len`` is `0` or `1` correctly. + # Supports aliasing of ``rpoly`` and ``poly``. + + void fmpz_poly_derivative(fmpz_poly_t res, const fmpz_poly_t poly) + # Sets ``res`` to the derivative of ``poly``. + + void _fmpz_poly_nth_derivative(fmpz * rpoly, const fmpz * poly, unsigned long n, long len) + # Sets ``(rpoly, len - n)`` to the nth derivative of ``(poly, len)``. + # Also handles the cases where ``len <= n`` correctly. + # Supports aliasing of ``rpoly`` and ``poly``. + + void fmpz_poly_nth_derivative(fmpz_poly_t res, const fmpz_poly_t poly, unsigned long n) + # Sets ``res`` to the nth derivative of ``poly``. + + void _fmpz_poly_evaluate_divconquer_fmpz(fmpz_t res, const fmpz * poly, long len, const fmpz_t a) + # Evaluates the polynomial ``(poly, len)`` at the integer `a` using + # a divide and conquer approach. Assumes that the length of the polynomial + # is at least one. Allows zero padding. Does not allow aliasing between + # ``res`` and ``x``. + + void fmpz_poly_evaluate_divconquer_fmpz(fmpz_t res, const fmpz_poly_t poly, const fmpz_t a) + # Evaluates the polynomial ``poly`` at the integer `a` using a divide + # and conquer approach. + # Aliasing between ``res`` and ``a`` is supported, however, + # ``res`` may not be part of ``poly``. + + void _fmpz_poly_evaluate_horner_fmpz(fmpz_t res, const fmpz * f, long len, const fmpz_t a) + # Evaluates the polynomial ``(f, len)`` at the integer `a` using + # Horner's rule, and sets ``res`` to the result. Aliasing between + # ``res`` and `a` or any of the coefficients of `f` is not supported. + + void fmpz_poly_evaluate_horner_fmpz(fmpz_t res, const fmpz_poly_t f, const fmpz_t a) + # Evaluates the polynomial `f` at the integer `a` using Horner's rule, and + # sets ``res`` to the result. + # As expected, aliasing between ``res`` and ``a`` is supported. + # However, ``res`` may not be aliased with a coefficient of `f`. + + void _fmpz_poly_evaluate_fmpz(fmpz_t res, const fmpz * f, long len, const fmpz_t a) + # Evaluates the polynomial ``(f, len)`` at the integer `a` and sets + # ``res`` to the result. Aliasing between ``res`` and `a` or any + # of the coefficients of `f` is not supported. + + void fmpz_poly_evaluate_fmpz(fmpz_t res, const fmpz_poly_t f, const fmpz_t a) + # Evaluates the polynomial `f` at the integer `a` and sets ``res`` + # to the result. + # As expected, aliasing between ``res`` and `a` is supported. However, + # ``res`` may not be aliased with a coefficient of `f`. + + void _fmpz_poly_evaluate_divconquer_fmpq(fmpz_t rnum, fmpz_t rden, const fmpz * f, long len, const fmpz_t anum, const fmpz_t aden) + # Evaluates the polynomial ``(f, len)`` at the rational + # ``(anum, aden)`` using a divide and conquer approach, and sets + # ``(rnum, rden)`` to the result in lowest terms. Assumes that + # the length of the polynomial is at least one. + # Aliasing between ``(rnum, rden)`` and ``(anum, aden)`` or any of + # the coefficients of `f` is not supported. + + void fmpz_poly_evaluate_divconquer_fmpq(fmpq_t res, const fmpz_poly_t f, const fmpq_t a) + # Evaluates the polynomial `f` at the rational `a` using a divide + # and conquer approach, and sets ``res`` to the result. + + void _fmpz_poly_evaluate_horner_fmpq(fmpz_t rnum, fmpz_t rden, const fmpz * f, long len, const fmpz_t anum, const fmpz_t aden) + # Evaluates the polynomial ``(f, len)`` at the rational + # ``(anum, aden)`` using Horner's rule, and sets ``(rnum, rden)`` to + # the result in lowest terms. + # Aliasing between ``(rnum, rden)`` and ``(anum, aden)`` or any of + # the coefficients of `f` is not supported. + + void fmpz_poly_evaluate_horner_fmpq(fmpq_t res, const fmpz_poly_t f, const fmpq_t a) + # Evaluates the polynomial `f` at the rational `a` using Horner's rule, and + # sets ``res`` to the result. + + void _fmpz_poly_evaluate_fmpq(fmpz_t rnum, fmpz_t rden, const fmpz * f, long len, const fmpz_t anum, const fmpz_t aden) + # Evaluates the polynomial ``(f, len)`` at the rational + # ``(anum, aden)`` and sets ``(rnum, rden)`` to the result in lowest + # terms. + # Aliasing between ``(rnum, rden)`` and ``(anum, aden)`` or any of + # the coefficients of `f` is not supported. + + void fmpz_poly_evaluate_fmpq(fmpq_t res, const fmpz_poly_t f, const fmpq_t a) + # Evaluates the polynomial `f` at the rational `a`, and + # sets ``res`` to the result. + + mp_limb_t _fmpz_poly_evaluate_mod(const fmpz * poly, long len, mp_limb_t a, mp_limb_t n, mp_limb_t ninv) + # Evaluates ``(poly, len)`` at the value `a` modulo `n` and + # returns the result. The last argument ``ninv`` must be set + # to the precomputed inverse of `n`, which can be obtained using + # the function :func:`n_preinvert_limb`. + + mp_limb_t fmpz_poly_evaluate_mod(const fmpz_poly_t poly, mp_limb_t a, mp_limb_t n) + # Evaluates ``poly`` at the value `a` modulo `n` and returns the result. + + void fmpz_poly_evaluate_fmpz_vec(fmpz * res, const fmpz_poly_t f, const fmpz * a, long n) + # Evaluates ``f`` at the `n` values given in the vector ``f``, + # writing the results to ``res``. + + double _fmpz_poly_evaluate_horner_d(const fmpz * poly, long n, double d) + # Evaluate ``(poly, n)`` at the double `d`. No attempt is made to do this + # efficiently or in a numerically stable way. It is currently only used in + # Flint for quick and dirty evaluations of polynomials with all coefficients + # positive. + + double fmpz_poly_evaluate_horner_d(const fmpz_poly_t poly, double d) + # Evaluate ``poly`` at the double `d`. No attempt is made to do this + # efficiently or in a numerically stable way. It is currently only used in + # Flint for quick and dirty evaluations of polynomials with all coefficients + # positive. + + double _fmpz_poly_evaluate_horner_d_2exp(long * exp, const fmpz * poly, long n, double d) + # Evaluate ``(poly, n)`` at the double `d`. Return the result as a double + # and an exponent ``exp`` combination. No attempt is made to do this + # efficiently or in a numerically stable way. It is currently only used in + # Flint for quick and dirty evaluations of polynomials with all coefficients + # positive. + + double fmpz_poly_evaluate_horner_d_2exp(long * exp, const fmpz_poly_t poly, double d) + # Evaluate ``poly`` at the double `d`. Return the result as a double + # and an exponent ``exp`` combination. No attempt is made to do this + # efficiently or in a numerically stable way. It is currently only used in + # Flint for quick and dirty evaluations of polynomials with all coefficients + # positive. + + double _fmpz_poly_evaluate_horner_d_2exp2(long * exp, const fmpz * poly, long n, double d, long dexp) + # Evaluate ``poly`` at ``d*2^dexp``. Return the result as a double + # and an exponent ``exp`` combination. No attempt is made to do this + # efficiently or in a numerically stable way. It is currently only used in + # Flint for quick and dirty evaluations of polynomials with all coefficients + # positive. + + void _fmpz_poly_monomial_to_newton(fmpz * poly, const fmpz * roots, long n) + # Converts ``(poly, n)`` in-place from its coefficients given + # in the standard monomial basis to the Newton basis + # for the roots `r_0, r_1, \ldots, r_{n-2}`. + # In other words, this determines output coefficients `c_i` such that + # `c_0 + c_1(x-r_0) + c_2(x-r_0)(x-r_1) + \ldots + c_{n-1}(x-r_0)(x-r_1)\cdots(x-r_{n-2})` + # is equal to the input polynomial. + # Uses repeated polynomial division. + + void _fmpz_poly_newton_to_monomial(fmpz * poly, const fmpz * roots, long n) + # Converts ``(poly, n)`` in-place from its coefficients given + # in the Newton basis for the roots `r_0, r_1, \ldots, r_{n-2}` + # to the standard monomial basis. In other words, this evaluates + # `c_0 + c_1(x-r_0) + c_2(x-r_0)(x-r_1) + \ldots + c_{n-1}(x-r_0)(x-r_1)\cdots(x-r_{n-2})` + # where `c_i` are the input coefficients for ``poly``. + # Uses Horner's rule. + + void fmpz_poly_interpolate_fmpz_vec(fmpz_poly_t poly, const fmpz * xs, const fmpz * ys, long n) + # Sets ``poly`` to the unique interpolating polynomial of degree at + # most `n - 1` satisfying `f(x_i) = y_i` for every pair `x_i, y_u` in + # ``xs`` and ``ys``, assuming that this polynomial has integer + # coefficients. + # If an interpolating polynomial with integer coefficients does not + # exist, a ``FLINT_INEXACT`` exception is thrown. + # It is assumed that the `x` values are distinct. + + void _fmpz_poly_compose_horner(fmpz * res, const fmpz * poly1, long len1, const fmpz * poly2, long len2) + # Sets ``res`` to the composition of ``(poly1, len1)`` and + # ``(poly2, len2)``. + # Assumes that ``res`` has space for ``(len1-1)*(len2-1) + 1`` + # coefficients. Assumes that ``poly1`` and ``poly2`` are non-zero + # polynomials. Does not support aliasing between any of the inputs and + # the output. + + void fmpz_poly_compose_horner(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2) + # Sets ``res`` to the composition of ``poly1`` and ``poly2``. + # To be more precise, denoting ``res``, ``poly1``, and ``poly2`` + # by `f`, `g`, and `h`, sets `f(t) = g(h(t))`. + # This implementation uses Horner's method. + + void _fmpz_poly_compose_divconquer(fmpz * res, const fmpz * poly1, long len1, const fmpz * poly2, long len2) + # Computes the composition of ``(poly1, len1)`` and ``(poly2, len2)`` + # using a divide and conquer approach and places the result into ``res``, + # assuming ``res`` can hold the output of length + # ``(len1 - 1) * (len2 - 1) + 1``. + # Assumes ``len1, len2 > 0``. Does not support aliasing between + # ``res`` and any of ``(poly1, len1)`` and ``(poly2, len2)``. + + void fmpz_poly_compose_divconquer(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2) + # Sets ``res`` to the composition of ``poly1`` and ``poly2``. + # To be precise about the order of composition, denoting ``res``, + # ``poly1``, and ``poly2`` by `f`, `g`, and `h`, respectively, + # sets `f(t) = g(h(t))`. + + void _fmpz_poly_compose(fmpz * res, const fmpz * poly1, long len1, const fmpz * poly2, long len2) + # Sets ``res`` to the composition of ``(poly1, len1)`` and + # ``(poly2, len2)``. + # Assumes that ``res`` has space for ``(len1-1)*(len2-1) + 1`` + # coefficients. Assumes that ``poly1`` and ``poly2`` are non-zero + # polynomials. Does not support aliasing between any of the inputs and + # the output. + + void fmpz_poly_compose(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2) + # Sets ``res`` to the composition of ``poly1`` and ``poly2``. + # To be precise about the order of composition, denoting ``res``, + # ``poly1``, and ``poly2`` by `f`, `g`, and `h`, respectively, + # sets `f(t) = g(h(t))`. + + void fmpz_poly_inflate(fmpz_poly_t result, const fmpz_poly_t input, unsigned long inflation) + # Sets ``result`` to the inflated polynomial `p(x^n)` where + # `p` is given by ``input`` and `n` is given by ``inflation``. + + void fmpz_poly_deflate(fmpz_poly_t result, const fmpz_poly_t input, unsigned long deflation) + # Sets ``result`` to the deflated polynomial `p(x^{1/n})` where + # `p` is given by ``input`` and `n` is given by ``deflation``. + # Requires `n > 0`. + + unsigned long fmpz_poly_deflation(const fmpz_poly_t input) + # Returns the largest integer by which ``input`` can be deflated. + # As special cases, returns 0 if ``input`` is the zero polynomial + # and 1 if ``input`` is a constant polynomial. + + void _fmpz_poly_taylor_shift_horner(fmpz * poly, const fmpz_t c, long n) + # Performs the Taylor shift composing ``poly`` by `x+c` in-place. + # Uses an efficient version Horner's rule. + + void fmpz_poly_taylor_shift_horner(fmpz_poly_t g, const fmpz_poly_t f, const fmpz_t c) + # Performs the Taylor shift composing ``f`` by `x+c`. + + void _fmpz_poly_taylor_shift_divconquer(fmpz * poly, const fmpz_t c, long n) + # Performs the Taylor shift composing ``poly`` by `x+c` in-place. + # Uses the divide-and-conquer polynomial composition algorithm. + + void fmpz_poly_taylor_shift_divconquer(fmpz_poly_t g, const fmpz_poly_t f, const fmpz_t c) + # Performs the Taylor shift composing ``f`` by `x+c`. + # Uses the divide-and-conquer polynomial composition algorithm. + + void _fmpz_poly_taylor_shift_multi_mod(fmpz * poly, const fmpz_t c, long n) + # Performs the Taylor shift composing ``poly`` by `x+c` in-place. + # Uses a multimodular algorithm, distributing the computation + # across :func:`flint_get_num_threads` threads. + + void fmpz_poly_taylor_shift_multi_mod(fmpz_poly_t g, const fmpz_poly_t f, const fmpz_t c) + # Performs the Taylor shift composing ``f`` by `x+c`. + # Uses a multimodular algorithm, distributing the computation + # across :func:`flint_get_num_threads` threads. + + void _fmpz_poly_taylor_shift(fmpz * poly, const fmpz_t c, long n) + # Performs the Taylor shift composing ``poly`` by `x+c` in-place. + + void fmpz_poly_taylor_shift(fmpz_poly_t g, const fmpz_poly_t f, const fmpz_t c) + # Performs the Taylor shift composing ``f`` by `x+c`. + + void _fmpz_poly_compose_series_horner(fmpz * res, const fmpz * poly1, long len1, const fmpz * poly2, long len2, long n) + # Sets ``res`` to the composition of ``poly1`` and ``poly2`` + # modulo `x^n`, where the constant term of ``poly2`` is required + # to be zero. + # Assumes that ``len1, len2, n > 0``, that ``len1, len2 <= n``, + # and that ``(len1-1) * (len2-1) + 1 <= n``, and that ``res`` has + # space for ``n`` coefficients. Does not support aliasing between any + # of the inputs and the output. + # This implementation uses the Horner scheme. + + void fmpz_poly_compose_series_horner(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2, long n) + # Sets ``res`` to the composition of ``poly1`` and ``poly2`` + # modulo `x^n`, where the constant term of ``poly2`` is required + # to be zero. + # This implementation uses the Horner scheme. + + void _fmpz_poly_compose_series_brent_kung(fmpz * res, const fmpz * poly1, long len1, const fmpz * poly2, long len2, long n) + # Sets ``res`` to the composition of ``poly1`` and ``poly2`` + # modulo `x^n`, where the constant term of ``poly2`` is required + # to be zero. + # Assumes that ``len1, len2, n > 0``, that ``len1, len2 <= n``, + # and that ``(len1-1) * (len2-1) + 1 <= n``, and that ``res`` has + # space for ``n`` coefficients. Does not support aliasing between any + # of the inputs and the output. + # This implementation uses Brent-Kung algorithm 2.1 [BrentKung1978]_. + + void fmpz_poly_compose_series_brent_kung(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2, long n) + # Sets ``res`` to the composition of ``poly1`` and ``poly2`` + # modulo `x^n`, where the constant term of ``poly2`` is required + # to be zero. + # This implementation uses Brent-Kung algorithm 2.1 [BrentKung1978]_. + + void _fmpz_poly_compose_series(fmpz * res, const fmpz * poly1, long len1, const fmpz * poly2, long len2, long n) + # Sets ``res`` to the composition of ``poly1`` and ``poly2`` + # modulo `x^n`, where the constant term of ``poly2`` is required + # to be zero. + # Assumes that ``len1, len2, n > 0``, that ``len1, len2 <= n``, + # and that ``(len1-1) * (len2-1) + 1 <= n``, and that ``res`` has + # space for ``n`` coefficients. Does not support aliasing between any + # of the inputs and the output. + # This implementation automatically switches between the Horner scheme + # and Brent-Kung algorithm 2.1 depending on the size of the inputs. + + void fmpz_poly_compose_series(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2, long n) + # Sets ``res`` to the composition of ``poly1`` and ``poly2`` + # modulo `x^n`, where the constant term of ``poly2`` is required + # to be zero. + # This implementation automatically switches between the Horner scheme + # and Brent-Kung algorithm 2.1 depending on the size of the inputs. + + void _fmpz_poly_revert_series_lagrange(fmpz * Qinv, const fmpz * Q, long Qlen, long n) + # Sets ``Qinv`` to the compositional inverse or reversion of + # ``(Q, Qlen)`` as a power series, i.e. computes `Q^{-1}` such that + # `Q(Q^{-1}(x)) = Q^{-1}(Q(x)) = x \bmod x^n`. The arguments may not be + # aliased, and ``Qlen`` must be at least 2. + # It is required that `Q_0 = 0` and `Q_1 = \pm 1`. + # This implementation uses the Lagrange inversion formula. + + void fmpz_poly_revert_series_lagrange(fmpz_poly_t Qinv, const fmpz_poly_t Q, long n) + # Sets ``Qinv`` to the compositional inverse or reversion of ``Q`` + # as a power series, i.e. computes `Q^{-1}` such that + # `Q(Q^{-1}(x)) = Q^{-1}(Q(x)) = x \bmod x^n`. + # It is required that `Q_0 = 0` and `Q_1 = \pm 1`. + # This implementation uses the Lagrange inversion formula. + + void _fmpz_poly_revert_series_lagrange_fast(fmpz * Qinv, const fmpz * Q, long Qlen, long n) + # Sets ``Qinv`` to the compositional inverse or reversion of + # ``(Q, Qlen)`` + # as a power series, i.e. computes `Q^{-1}` such that + # `Q(Q^{-1}(x)) = Q^{-1}(Q(x)) = x \bmod x^n`. The arguments may not be + # aliased, and ``Qlen`` must be at least 2. + # It is required that `Q_0 = 0` and `Q_1 = \pm 1`. + # This implementation uses a reduced-complexity implementation + # of the Lagrange inversion formula. + + void fmpz_poly_revert_series_lagrange_fast(fmpz_poly_t Qinv, const fmpz_poly_t Q, long n) + # Sets ``Qinv`` to the compositional inverse or reversion of ``Q`` + # as a power series, i.e. computes `Q^{-1}` such that + # `Q(Q^{-1}(x)) = Q^{-1}(Q(x)) = x \bmod x^n`. + # It is required that `Q_0 = 0` and `Q_1 = \pm 1`. + # This implementation uses a reduced-complexity implementation + # of the Lagrange inversion formula. + + void _fmpz_poly_revert_series_newton(fmpz * Qinv, const fmpz * Q, long Qlen, long n) + # Sets ``Qinv`` to the compositional inverse or reversion of ``Q`` + # as a power series, i.e. computes `Q^{-1}` such that + # `Q(Q^{-1}(x)) = Q^{-1}(Q(x)) = x \bmod x^n`. The arguments may not be + # aliased, and ``Qlen`` must be at least 2. + # It is required that `Q_0 = 0` and `Q_1 = \pm 1`. + # This implementation uses Newton iteration [BrentKung1978]_. + + void fmpz_poly_revert_series_newton(fmpz_poly_t Qinv, const fmpz_poly_t Q, long n) + # Sets ``Qinv`` to the compositional inverse or reversion of ``Q`` + # as a power series, i.e. computes `Q^{-1}` such that + # `Q(Q^{-1}(x)) = Q^{-1}(Q(x)) = x \bmod x^n`. + # It is required that `Q_0 = 0` and `Q_1 = \pm 1`. + # This implementation uses Newton iteration [BrentKung1978]_. + + void _fmpz_poly_revert_series(fmpz * Qinv, const fmpz * Q, long Qlen, long n) + # Sets ``Qinv`` to the compositional inverse or reversion of ``Q`` + # as a power series, i.e. computes `Q^{-1}` such that + # `Q(Q^{-1}(x)) = Q^{-1}(Q(x)) = x \bmod x^n`. The arguments may not be + # aliased, and ``Qlen`` must be at least 2. + # It is required that `Q_0 = 0` and `Q_1 = \pm 1`. + # This implementation defaults to the fast version of + # Lagrange interpolation. + + void fmpz_poly_revert_series(fmpz_poly_t Qinv, const fmpz_poly_t Q, long n) + # Sets ``Qinv`` to the compositional inverse or reversion of ``Q`` + # as a power series, i.e. computes `Q^{-1}` such that + # `Q(Q^{-1}(x)) = Q^{-1}(Q(x)) = x \bmod x^n`. + # It is required that `Q_0 = 0` and `Q_1 = \pm 1`. + # This implementation defaults to the fast version of + # Lagrange interpolation. + + int _fmpz_poly_sqrtrem_classical(fmpz * res, fmpz * r, const fmpz * poly, long len) + # Returns 1 if ``(poly, len)`` can be written in the form `A^2 + R` where + # deg(`R`) < deg(``poly``), otherwise returns `0`. If it can be so + # written, ``(res, m - 1)`` is set to `A` and ``(res, m)`` is set to + # `R`, where `m = \deg(\mathtt{poly})/2 + 1`. + # For efficiency reasons, ``r`` must have room for ``len`` + # coefficients, and may alias ``poly``. + + int fmpz_poly_sqrtrem_classical(fmpz_poly_t b, fmpz_poly_t r, const fmpz_poly_t a) + # If `a` can be written as `b^2 + r` with `\deg(r) < \deg(a)/2`, return + # `1` and set `b` and `r` appropriately. Otherwise return `0`. + + int _fmpz_poly_sqrtrem_divconquer(fmpz * res, fmpz * r, const fmpz * poly, long len, fmpz * temp) + # Returns 1 if ``(poly, len)`` can be written in the form `A^2 + R` where + # deg(`R`) < deg(``poly``), otherwise returns `0`. If it can be so + # written, ``(res, m - 1)`` is set to `A` and ``(res, m)`` is set to + # `R`, where `m = \deg(\mathtt{poly})/2 + 1`. + # For efficiency reasons, ``r`` must have room for ``len`` + # coefficients, and may alias ``poly``. Temporary space of ``len`` + # coefficients is required. + + int fmpz_poly_sqrtrem_divconquer(fmpz_poly_t b, fmpz_poly_t r, const fmpz_poly_t a) + # If `a` can be written as `b^2 + r` with `\deg(r) < \deg(a)/2`, return + # `1` and set `b` and `r` appropriately. Otherwise return `0`. + + int _fmpz_poly_sqrt_classical(fmpz * res, const fmpz * poly, long len, int exact) + # If ``exact`` is `1` and ``(poly, len)`` is a perfect square, sets + # ``(res, len / 2 + 1)`` to the square root of ``poly`` with positive + # leading coefficient and returns 1. Otherwise returns 0. + # If ``exact`` is `0`, allows a remainder after the square root, which is + # not computed. + # This function first uses various tests to detect nonsquares quickly. + # Then, it computes the square root iteratively from top to bottom, + # requiring `O(n^2)` coefficient operations. + + int fmpz_poly_sqrt_classical(fmpz_poly_t b, const fmpz_poly_t a) + # If ``a`` is a perfect square, sets ``b`` to the square root of + # ``a`` with positive leading coefficient and returns 1. + # Otherwise returns 0. + + int _fmpz_poly_sqrt_KS(fmpz * res, const fmpz * poly, long len) + # Heuristic square root. If the return value is `-1`, the function failed, + # otherwise it succeeded and the following applies. + # If ``(poly, len)`` is a perfect square, sets + # ``(res, len / 2 + 1)`` to the square root of ``poly`` with positive + # leading coefficient and returns 1. Otherwise returns 0. + # This function first uses various tests to detect nonsquares quickly. + # Then, it computes the square root iteratively from top to bottom. + + int fmpz_poly_sqrt_KS(fmpz_poly_t b, const fmpz_poly_t a) + # Heuristic square root. If the return value is `-1`, the function failed, + # otherwise it succeeded and the following applies. + # If ``a`` is a perfect square, sets ``b`` to the square root of + # ``a`` with positive leading coefficient and returns 1. + # Otherwise returns 0. + + int _fmpz_poly_sqrt_divconquer(fmpz * res, const fmpz * poly, long len, int exact) + # If ``exact`` is `1` and ``(poly, len)`` is a perfect square, sets + # ``(res, len / 2 + 1)`` to the square root of ``poly`` with positive + # leading coefficient and returns 1. Otherwise returns 0. + # If ``exact`` is `0`, allows a remainder after the square root, which is + # not computed. + # This function first uses various tests to detect nonsquares quickly. + # Then, it computes the square root iteratively from top to bottom. + + int fmpz_poly_sqrt_divconquer(fmpz_poly_t b, const fmpz_poly_t a) + # If ``a`` is a perfect square, sets ``b`` to the square root of + # ``a`` with positive leading coefficient and returns 1. + # Otherwise returns 0. + + int _fmpz_poly_sqrt(fmpz * res, const fmpz * poly, long len) + # If ``(poly, len)`` is a perfect square, sets ``(res, len / 2 + 1)`` + # to the square root of ``poly`` with positive leading coefficient + # and returns 1. Otherwise returns 0. + + int fmpz_poly_sqrt(fmpz_poly_t b, const fmpz_poly_t a) + # If ``a`` is a perfect square, sets ``b`` to the square root of + # ``a`` with positive leading coefficient and returns 1. + # Otherwise returns 0. + + int _fmpz_poly_sqrt_series(fmpz * res, const fmpz * poly, long len, long n) + # Set ``(res, n)`` to the square root of the series ``(poly, n)``, if it + # exists, and return `1`, otherwise, return `0`. + # If the valuation of ``poly`` is not zero, ``res`` is zero padded + # to make up for the fact that the square root may not be known to precision + # `n`. + + int fmpz_poly_sqrt_series(fmpz_poly_t b, const fmpz_poly_t a, long n) + # Set ``b`` to the square root of the series ``a``, where the latter + # is taken to be a series of precision `n`. If such a square root exists, + # return `1`, otherwise, return `0`. + # Note that if the valuation of ``a`` is not zero, ``b`` will + # not have precision ``n``. It is given only to the precision to which + # the square root can be computed. + + void _fmpz_poly_power_sums_naive(fmpz * res, const fmpz * poly, long len, long n) + # Compute the (truncated) power sums series of the monic polynomial + # ``(poly,len)`` up to length `n` using Newton identities. + + void fmpz_poly_power_sums_naive(fmpz_poly_t res, const fmpz_poly_t poly, long n) + # Compute the (truncated) power sum series of the monic polynomial + # ``poly`` up to length `n` using Newton identities. + + void fmpz_poly_power_sums(fmpz_poly_t res, const fmpz_poly_t poly, long n) + # Compute the (truncated) power sums series of the monic polynomial ``poly`` + # up to length `n`. That is the power series whose coefficient of degree `i` is + # the sum of the `i`-th power of all (complex) roots of the polynomial + # ``poly``. + + void _fmpz_poly_power_sums_to_poly(fmpz * res, const fmpz * poly, long len) + # Compute the (monic) polynomial given by its power sums series ``(poly,len)``. + + void fmpz_poly_power_sums_to_poly(fmpz_poly_t res, const fmpz_poly_t Q) + # Compute the (monic) polynomial given its power sums series ``(Q)``. + + void _fmpz_poly_signature(long * r1, long * r2, const fmpz * poly, long len) + # Computes the signature `(r_1, r_2)` of the polynomial + # ``(poly, len)``. Assumes that the polynomial is squarefree over `\mathbb{Q}`. + + void fmpz_poly_signature(long * r1, long * r2, const fmpz_poly_t poly) + # Computes the signature `(r_1, r_2)` of the polynomial ``poly``, + # which is assumed to be square-free over `\mathbb{Q}`. The values of `r_1` and + # `2 r_2` are the number of real and complex roots of the polynomial, + # respectively. For convenience, the zero polynomial is allowed, in which + # case the output is `(0, 0)`. + # If the polynomial is not square-free, the behaviour is undefined and an + # exception may be raised. + # This function uses the algorithm described + # in Algorithm 4.1.11 of [Coh1996]_. + + void fmpz_poly_hensel_build_tree(long * link, fmpz_poly_t *v, fmpz_poly_t *w, const nmod_poly_factor_t fac) + # Initialises and builds a Hensel tree consisting of two arrays `v`, `w` + # of polynomials and an array of links, called ``link``. + # The caller supplies a set of `r` local factors (in the factor structure + # ``fac``) of some polynomial `F` over `\mathbf{Z}`. They also supply + # two arrays of initialised polynomials `v` and `w`, each of length + # `2r - 2` and an array ``link``, also of length `2r - 2`. + # We will have five arrays: a `v` of ``fmpz_poly_t``'s and a `V` of + # ``nmod_poly_t``'s and also a `w` and a `W` and ``link``. Here's + # the idea: we sort each leaf and node of a factor tree by degree, in + # fact choosing to multiply the two smallest factors, then the next two + # smallest (factors or products) etc. until a tree is made. The tree + # will be stored in the `v`'s. The first two elements of `v` will be the + # smallest modular factors, the last two elements of `v` will multiply to + # form `F` itself. Since `v` will be rearranging the original factors we + # will need to be able to recover the original order. For this we use the + # array ``link`` which has nonnegative even numbers and negative numbers. + # It is an array of ``slong``\s which aligns with `V` and `v` if + # ``link`` has a negative number in spot `j` that means `V_j` is an + # original modular factor which has been lifted, if ``link[j]`` is a + # nonnegative even number then `V_j` stores a product of the two entries + # at ``V[link[j]]`` and ``V[link[j]+1]``. + # `W` and `w` play the role of the extended GCD, at `V_0`, `V_2`, `V_4`, + # etc. we have a new product, `W_0`, `W_2`, `W_4`, etc. are the XGCD + # cofactors of the `V`'s. For example, + # `V_0 W_0 + V_1 W_1 \equiv 1 \pmod{p^{\ell}}` for some `\ell`. These + # will be lifted along with the entries in `V`. It is not enough to just + # lift each factor, we have to lift the entire tree and the tree of + # XGCD cofactors. + + void fmpz_poly_hensel_lift(fmpz_poly_t G, fmpz_poly_t H, fmpz_poly_t A, fmpz_poly_t B, const fmpz_poly_t f, const fmpz_poly_t g, const fmpz_poly_t h, const fmpz_poly_t a, const fmpz_poly_t b, const fmpz_t p, const fmpz_t p1) + # This is the main Hensel lifting routine, which performs a Hensel step + # from polynomials mod `p` to polynomials mod `P = p p_1`. One starts with + # polynomials `f`, `g`, `h` such that `f = gh \pmod p`. The polynomials + # `a`, `b` satisfy `ag + bh = 1 \pmod p`. + # The lifting formulae are + # .. math :: + # G = \biggl( \bigl( \frac{f-gh}{p} \bigr) b \bmod g \biggr) p + g + # H = \biggl( \bigl( \frac{f-gh}{p} \bigr) a \bmod h \biggr) p + h + # B = \biggl( \bigl( \frac{1-aG-bH}{p} \bigr) b \bmod g \biggr) p + b + # A = \biggl( \bigl( \frac{1-aG-bH}{p} \bigr) a \bmod h \biggr) p + a + # Upon return we have `A G + B H = 1 \pmod P` and `f = G H \pmod P`, + # where `G = g \pmod p` etc. + # We require that `1 < p_1 \leq p` and that the input polynomials `f, g, h` + # have degree at least `1` and that the input polynomials `a` and `b` are + # non-zero. + # The output arguments `G, H, A, B` may only be aliased with + # the input arguments `g, h, a, b`, respectively. + + void fmpz_poly_hensel_lift_without_inverse(fmpz_poly_t Gout, fmpz_poly_t Hout, const fmpz_poly_t f, const fmpz_poly_t g, const fmpz_poly_t h, const fmpz_poly_t a, const fmpz_poly_t b, const fmpz_t p, const fmpz_t p1) + # Given polynomials such that `f = gh \pmod p` and `ag + bh = 1 \pmod p`, + # lifts only the factors `g` and `h` modulo `P = p p_1`. + # See :func:`fmpz_poly_hensel_lift`. + + void fmpz_poly_hensel_lift_only_inverse(fmpz_poly_t Aout, fmpz_poly_t Bout, const fmpz_poly_t G, const fmpz_poly_t H, const fmpz_poly_t a, const fmpz_poly_t b, const fmpz_t p, const fmpz_t p1) + # Given polynomials such that `f = gh \pmod p` and `ag + bh = 1 \pmod p`, + # lifts only the cofactors `a` and `b` modulo `P = p p_1`. + # See :func:`fmpz_poly_hensel_lift`. + + void fmpz_poly_hensel_lift_tree_recursive(long *link, fmpz_poly_t *v, fmpz_poly_t *w, fmpz_poly_t f, long j, long inv, const fmpz_t p0, const fmpz_t p1) + # Takes a current Hensel tree ``(link, v, w)`` and a pair `(j,j+1)` + # of entries in the tree and lifts the tree from mod `p_0` to + # mod `P = p_0 p_1`, where `1 < p_1 \leq p_0`. + # Set ``inv`` to `-1` if restarting Hensel lifting, `0` if stopping + # and `1` otherwise. + # Here `f = g h` is the polynomial whose factors we are trying to lift. + # We will have that ``v[j]`` is the product of ``v[link[j]]`` and + # ``v[link[j] + 1]`` as described above. + # Does support aliasing of `f` with one of the polynomials in + # the lists `v` and `w`. But the polynomials in these two lists + # are not allowed to be aliases of each other. + + void fmpz_poly_hensel_lift_tree(long *link, fmpz_poly_t *v, fmpz_poly_t *w, fmpz_poly_t f, long r, const fmpz_t p, long e0, long e1, long inv) + # Computes `p_0 = p^{e_0}` and `p_1 = p^{e_1 - e_0}` for a small prime `p` + # and `P = p^{e_1}`. + # If we aim to lift to `p^b` then `f` is the polynomial whose factors we + # wish to lift, made monic mod `p^b`. As usual, ``(link, v, w)`` is an + # initialised tree. + # This starts the recursion on lifting the *product tree* for lifting + # from `p^{e_0}` to `p^{e_1}`. The value of ``inv`` corresponds to that + # given for the function :func:`fmpz_poly_hensel_lift_tree_recursive`. We + # set `r` to the number of local factors of `f`. + # In terms of the notation, above `P = p^{e_1}`, `p_0 = p^{e_0}` and + # `p_1 = p^{e_1-e_0}`. + # Assumes that `f` is monic. + # Assumes that `1 < p_1 \leq p_0`, that is, `0 < e_1 \leq e_0`. + + long _fmpz_poly_hensel_start_lift(fmpz_poly_factor_t lifted_fac, long *link, fmpz_poly_t *v, fmpz_poly_t *w, const fmpz_poly_t f, const nmod_poly_factor_t local_fac, long N) + # This function takes the local factors in ``local_fac`` + # and Hensel lifts them until they are known mod `p^N`, where + # `N \geq 1`. + # These lifted factors will be stored (in the same ordering) in + # ``lifted_fac``. It is assumed that ``link``, ``v``, and + # ``w`` are initialized arrays of ``fmpz_poly_t``'s with at least + # `2*r - 2` entries and that `r \geq 2`. This is done outside of + # this function so that you can keep them for restarting Hensel lifting + # later. The product of local factors must be squarefree. + # The return value is an exponent which must be passed to the function + # :func:`_fmpz_poly_hensel_continue_lift` as ``prev_exp`` if the + # Hensel lifting is to be resumed. + # Currently, supports the case when `N = 1` for convenience, + # although it is preferable in this case to simply iterate + # over the local factors and convert them to polynomials over + # `\mathbf{Z}`. + + long _fmpz_poly_hensel_continue_lift(fmpz_poly_factor_t lifted_fac, long *link, fmpz_poly_t *v, fmpz_poly_t *w, const fmpz_poly_t f, long prev, long curr, long N, const fmpz_t p) + # This function restarts a stopped Hensel lift. + # It lifts from ``curr`` to `N`. It also requires ``prev`` + # (to lift the cofactors) given as the return value of the function + # :func:`_fmpz_poly_hensel_start_lift` or the function + # :func:`_fmpz_poly_hensel_continue_lift`. The current lifted factors + # are supplied in ``lifted_fac`` and upon return are updated + # there. As usual ``link``, ``v``, and ``w`` describe the + # current Hensel tree, `r` is the number of local factors and `p` is + # the small prime modulo whose power we are lifting to. It is required + # that ``curr`` be at least `1` and that ``N > curr``. + # Currently, supports the case when ``prev`` and ``curr`` + # are equal. + + void fmpz_poly_hensel_lift_once(fmpz_poly_factor_t lifted_fac, const fmpz_poly_t f, const nmod_poly_factor_t local_fac, long N) + # This function does a Hensel lift. + # It lifts local factors stored in ``local_fac`` of `f` to `p^N`, + # where `N \geq 2`. The lifted factors will be stored in ``lifted_fac``. + # This lift cannot be restarted. This function is a convenience function + # intended for end users. The product of local factors must be squarefree. + + int _fmpz_poly_print(const fmpz * poly, long len) + # Prints the polynomial ``(poly, len)`` to ``stdout``. + # In case of success, returns a positive value. In case of failure, + # returns a non-positive value. + + int fmpz_poly_print(const fmpz_poly_t poly) + # Prints the polynomial to ``stdout``. + # In case of success, returns a positive value. In case of failure, + # returns a non-positive value. + + int _fmpz_poly_print_pretty(const fmpz * poly, long len, const char * x) + # Prints the pretty representation of ``(poly, len)`` to ``stdout``, + # using the string ``x`` to represent the indeterminate. + # In case of success, returns a positive value. In case of failure, + # returns a non-positive value. + + int fmpz_poly_print_pretty(const fmpz_poly_t poly, const char * x) + # Prints the pretty representation of ``poly`` to ``stdout``, + # using the string ``x`` to represent the indeterminate. + # In case of success, returns a positive value. In case of failure, + # returns a non-positive value. + + int _fmpz_poly_fprint(FILE * file, const fmpz * poly, long len) + # Prints the polynomial ``(poly, len)`` to the stream ``file``. + # In case of success, returns a positive value. In case of failure, + # returns a non-positive value. + + int fmpz_poly_fprint(FILE * file, const fmpz_poly_t poly) + # Prints the polynomial to the stream ``file``. + # In case of success, returns a positive value. In case of failure, + # returns a non-positive value. + + int _fmpz_poly_fprint_pretty(FILE * file, const fmpz * poly, long len, const char * x) + # Prints the pretty representation of ``(poly, len)`` to the stream + # ``file``, using the string ``x`` to represent the indeterminate. + # In case of success, returns a positive value. In case of failure, + # returns a non-positive value. + + int fmpz_poly_fprint_pretty(FILE * file, const fmpz_poly_t poly, const char * x) + # Prints the pretty representation of ``poly`` to the stream ``file``, + # using the string ``x`` to represent the indeterminate. + # In case of success, returns a positive value. In case of failure, + # returns a non-positive value. + + int fmpz_poly_read(fmpz_poly_t poly) + # Reads a polynomial from ``stdin``, storing the result in ``poly``. + # In case of success, returns a positive number. In case of failure, + # returns a non-positive value. + + int fmpz_poly_read_pretty(fmpz_poly_t poly, char **x) + # Reads a polynomial in pretty format from ``stdin``. + # For further details, see the documentation for the function + # :func:`fmpz_poly_fread_pretty`. + + int fmpz_poly_fread(FILE * file, fmpz_poly_t poly) + # Reads a polynomial from the stream ``file``, storing the result + # in ``poly``. + # In case of success, returns a positive number. In case of failure, + # returns a non-positive value. + + int fmpz_poly_fread_pretty(FILE *file, fmpz_poly_t poly, char **x) + # Reads a polynomial from the file ``file`` and sets ``poly`` + # to this polynomial. The string ``*x`` is set to the variable + # name that is used in the input. + # Returns a positive value, equal to the number of characters read from + # the file, in case of success. Returns a non-positive value in case of + # failure, which could either be a read error or the indicator of a + # malformed input. + + void fmpz_poly_get_nmod_poly(nmod_poly_t Amod, const fmpz_poly_t A) + # Sets the coefficients of ``Amod`` to the coefficients in ``A``, + # reduced by the modulus of ``Amod``. + + void fmpz_poly_set_nmod_poly(fmpz_poly_t A, const nmod_poly_t Amod) + # Sets the coefficients of ``A`` to the residues in ``Amod``, + # normalised to the interval `-m/2 \le r < m/2` where `m` is the modulus. + + void fmpz_poly_set_nmod_poly_unsigned(fmpz_poly_t A, const nmod_poly_t Amod) + # Sets the coefficients of ``A`` to the residues in ``Amod``, + # normalised to the interval `0 \le r < m` where `m` is the modulus. + + void _fmpz_poly_CRT_ui_precomp(fmpz * res, const fmpz * poly1, long len1, const fmpz_t m1, mp_srcptr poly2, long len2, mp_limb_t m2, mp_limb_t m2inv, fmpz_t m1m2, mp_limb_t c, int sign) + # Sets the coefficients in ``res`` to the CRT reconstruction modulo + # `m_1m_2` of the residues ``(poly1, len1)`` and ``(poly2, len2)`` + # which are images modulo `m_1` and `m_2` respectively. + # The caller must supply the precomputed product of the input moduli as + # `m_1m_2`, the inverse of `m_1` modulo `m_2` as `c`, and + # the precomputed inverse of `m_2` (in the form computed by + # ``n_preinvert_limb``) as ``m2inv``. + # If ``sign`` = 0, residues `0 \le r < m_1 m_2` are computed, while + # if ``sign`` = 1, residues `-m_1 m_2/2 \le r < m_1 m_2/2` are computed. + # Coefficients of ``res`` are written up to the maximum of + # ``len1`` and ``len2``. + + void _fmpz_poly_CRT_ui(fmpz * res, const fmpz * poly1, long len1, const fmpz_t m1, mp_srcptr poly2, long len2, mp_limb_t m2, mp_limb_t m2inv, int sign) + # This function is identical to ``_fmpz_poly_CRT_ui_precomp``, + # apart from automatically computing `m_1m_2` and `c`. It also + # aborts if `c` cannot be computed. + + void fmpz_poly_CRT_ui(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_t m, const nmod_poly_t poly2, int sign) + # Given ``poly1`` with coefficients modulo ``m`` and ``poly2`` + # with modulus `n`, sets ``res`` to the CRT reconstruction modulo `mn` + # with coefficients satisfying `-mn/2 \le c < mn/2` (if sign = 1) + # or `0 \le c < mn` (if sign = 0). + + void _fmpz_poly_product_roots_fmpz_vec(fmpz * poly, const fmpz * xs, long n) + # Sets ``(poly, n + 1)`` to the monic polynomial which is the product + # of `(x - x_0)(x - x_1) \cdots (x - x_{n-1})`, the roots `x_i` being + # given by ``xs``. + # Aliasing of the input and output is not allowed. + + void fmpz_poly_product_roots_fmpz_vec(fmpz_poly_t poly, const fmpz * xs, long n) + # Sets ``poly`` to the monic polynomial which is the product + # of `(x - x_0)(x - x_1) \cdots (x - x_{n-1})`, the roots `x_i` being + # given by ``xs``. + + void _fmpz_poly_product_roots_fmpq_vec(fmpz * poly, const fmpq * xs, long n) + # Sets ``(poly, n + 1)`` to the product of + # `(q_0 x - p_0)(q_1 x - p_1) \cdots (q_{n-1} x - p_{n-1})`, the roots + # `p_i/q_i` being given by ``xs``. + + void fmpz_poly_product_roots_fmpq_vec(fmpz_poly_t poly, const fmpq * xs, long n) + # Sets ``poly`` to the polynomial which is the product + # of `(q_0 x - p_0)(q_1 x - p_1) \cdots (q_{n-1} x - p_{n-1})`, the roots + # `p_i/q_i` being given by ``xs``. + + void _fmpz_poly_bound_roots(fmpz_t bound, const fmpz * poly, long len) + void fmpz_poly_bound_roots(fmpz_t bound, const fmpz_poly_t poly) + # Computes a nonnegative integer ``bound`` that bounds the absolute + # value of all complex roots of ``poly``. Uses Fujiwara's bound + # .. math :: + # 2 \max \left( + # \left|\frac{a_{n-1}}{a_n}\right|, + # \left|\frac{a_{n-2}}{a_n}\right|^{\frac{1}{2}}, \dotsc, + # \left|\frac{a_1}{a_n}\right|^{\frac{1}{n-1}}, + # \left|\frac{a_0}{2a_n}\right|^{\frac{1}{n}} + # \right) + # where the coefficients of the polynomial are `a_0, \ldots, a_n`. + + void _fmpz_poly_num_real_roots_sturm(long * n_neg, long * n_pos, const fmpz * pol, long len) + # Sets ``n_neg`` and ``n_pos`` to the number of negative and + # positive roots of the polynomial ``(pol, len)`` using Sturm + # sequence. The Sturm sequence is computed via subresultant + # remainders obtained by repeated call to the function + # ``_fmpz_poly_pseudo_rem_cohen``. + # The polynomial is assumed to be squarefree, of degree larger than 1 + # and with non-zero constant coefficient. + + long fmpz_poly_num_real_roots_sturm(const fmpz_poly_t pol) + # Returns the number of real roots of the squarefree polynomial ``pol`` + # using Sturm sequence. + # The polynomial is assumed to be squarefree. + + long _fmpz_poly_num_real_roots(const fmpz * pol, long len) + # Returns the number of real roots of the squarefree polynomial + # ``(pol, len)``. + # The polynomial is assumed to be squarefree. + + long fmpz_poly_num_real_roots(const fmpz_poly_t pol) + # Returns the number of real roots of the squarefree polynomial ``pol``. + # The polynomial is assumed to be squarefree. + + void _fmpz_poly_cyclotomic(fmpz * a, unsigned long n, mp_ptr factors, long num_factors, unsigned long phi) + # Sets ``a`` to the lower half of the cyclotomic polynomial `\Phi_n(x)`, + # given `n \ge 3` which must be squarefree. + # A precomputed array containing the prime factors of `n` must be provided, + # as well as the value of the Euler totient function `\phi(n)` as ``phi``. + # If `n` is even, 2 must be the first factor in the list. + # The degree of `\Phi_n(x)` is exactly `\phi(n)`. Only the low + # `(\phi(n) + 1) / 2` coefficients are written; the high coefficients + # can be obtained afterwards by copying the low coefficients + # in reverse order, since `\Phi_n(x)` is a palindrome for `n \ne 1`. + # We use the sparse power series algorithm described as Algorithm 4 + # [ArnoldMonagan2011]_. The algorithm is based on the identity + # .. math :: + # \Phi_n(x) = \prod_{d|n} (x^d - 1)^{\mu(n/d)}. + # Treating the polynomial as a power series, the multiplications and + # divisions can be done very cheaply using repeated additions and + # subtractions. The complexity is `O(2^k \phi(n))` where `k` is the + # number of prime factors in `n`. + # To improve efficiency for small `n`, we treat the ``fmpz`` + # coefficients as machine integers when there is no risk of overflow. + # The following bounds are given in Table 6 of [ArnoldMonagan2011]_: + # For `n < 10163195`, the largest coefficient in any `\Phi_n(x)` + # has 27 bits, so machine arithmetic is safe on 32 bits. + # For `n < 169828113`, the largest coefficient in any `\Phi_n(x)` + # has 60 bits, so machine arithmetic is safe on 64 bits. + # Further, the coefficients are always `\pm 1` or 0 if there are + # exactly two prime factors, so in this case machine arithmetic can be + # used as well. + # Finally, we handle two special cases: if there is exactly one prime + # factor `n = p`, then `\Phi_n(x) = 1 + x + x^2 + \ldots + x^{n-1}`, + # and if `n = 2m`, we use `\Phi_n(x) = \Phi_m(-x)` to fall back + # to the case when `n` is odd. + + void fmpz_poly_cyclotomic(fmpz_poly_t poly, unsigned long n) + # Sets ``poly`` to the `n`-th cyclotomic polynomial, defined as + # `\Phi_n(x) = \prod_{\omega} (x-\omega)` + # where `\omega` runs over all the `n`-th primitive roots of unity. + # We factor `n` into `n = qs` where `q` is squarefree, + # and compute `\Phi_q(x)`. Then `\Phi_n(x) = \Phi_q(x^s)`. + + unsigned long _fmpz_poly_is_cyclotomic(const fmpz * poly, long len) + unsigned long fmpz_poly_is_cyclotomic(const fmpz_poly_t poly) + # If ``poly`` is a cyclotomic polynomial, returns the index `n` of this + # cyclotomic polynomial. If ``poly`` is not a cyclotomic polynomial, + # returns 0. + + void _fmpz_poly_cos_minpoly(fmpz * coeffs, unsigned long n) + void fmpz_poly_cos_minpoly(fmpz_poly_t poly, unsigned long n) + # Sets ``poly`` to the minimal polynomial of `2 \cos(2 \pi / n)`. + # For suitable choice of `n`, this gives the minimal polynomial + # of `2 \cos(a \pi)` or `2 \sin(a \pi)` for any rational `a`. + # The cosine is multiplied by a factor two since this gives + # a monic polynomial with integer coefficients. One can obtain + # the minimal polynomial for `\cos(2 \pi / n)` by making + # the substitution `x \to x / 2`. + # For `n > 2`, the degree of the polynomial is `\varphi(n) / 2`. + # For `n = 1, 2`, the degree is 1. For `n = 0`, we define + # the output to be the constant polynomial 1. + # See [WaktinsZeitlin1993]_. + + void _fmpz_poly_swinnerton_dyer(fmpz * coeffs, unsigned long n) + void fmpz_poly_swinnerton_dyer(fmpz_poly_t poly, unsigned long n) + # Sets ``poly`` to the Swinnerton-Dyer polynomial `S_n`, defined as + # the integer polynomial + # `S_n = \prod (x \pm \sqrt{2} \pm \sqrt{3} \pm \sqrt{5} \pm \ldots \pm \sqrt{p_n})` + # where `p_n` denotes the `n`-th prime number and all combinations + # of signs are taken. This polynomial has degree `2^n` and is + # irreducible over the integers (it is the minimal polynomial + # of `\sqrt{2} + \ldots + \sqrt{p_n}`). + + void _fmpz_poly_chebyshev_t(fmpz * coeffs, unsigned long n) + void fmpz_poly_chebyshev_t(fmpz_poly_t poly, unsigned long n) + # Sets ``poly`` to the Chebyshev polynomial of the first kind `T_n(x)`, + # defined by `T_n(x) = \cos(n \cos^{-1}(x))`, for `n\ge0`. The coefficients are + # calculated using a hypergeometric recurrence. + + void _fmpz_poly_chebyshev_u(fmpz * coeffs, unsigned long n) + void fmpz_poly_chebyshev_u(fmpz_poly_t poly, unsigned long n) + # Sets ``poly`` to the Chebyshev polynomial of the first kind `U_n(x)`, + # defined by `(n+1) U_n(x) = T'_{n+1}(x)`, for `n\ge0`. + # The coefficients are calculated using a hypergeometric recurrence. + + void _fmpz_poly_legendre_pt(fmpz * coeffs, unsigned long n) + # Sets ``coeffs`` to the coefficient array of the shifted Legendre + # polynomial `\tilde{P_n}(x)`, defined by `\tilde{P_n}(x) = P_n(2x-1)`, for `n\ge0`. + # The coefficients are calculated using a hypergeometric recurrence. + # The length of the array will be ``n+1``. + # See ``fmpq_poly`` for the Legendre polynomials. + + void fmpz_poly_legendre_pt(fmpz_poly_t poly, unsigned long n) + # Sets ``poly`` to the shifted Legendre polynomial `\tilde{P_n}(x)`, + # defined by `\tilde{P_n}(x) = P_n(2x-1)`, for `n\ge0`. The coefficients are + # calculated using a hypergeometric recurrence. See ``fmpq_poly`` + # for the Legendre polynomials. + + void _fmpz_poly_hermite_h(fmpz * coeffs, unsigned long n) + # Sets ``coeffs`` to the coefficient array of the Hermite + # polynomial `H_n(x)`, defined by `H'_n(x) = 2nH_{n-1}(x)`, for `n\ge0`. + # The coefficients are calculated using a hypergeometric recurrence. + # The length of the array will be ``n+1``. + + void fmpz_poly_hermite_h(fmpz_poly_t poly, unsigned long n) + # Sets ``poly`` to the Hermite polynomial `H_n(x)`, + # defined by `H'_n(x) = 2nH_{n-1}(x)`, for `n\ge0`. The coefficients are + # calculated using a hypergeometric recurrence. + + void _fmpz_poly_hermite_he(fmpz * coeffs, unsigned long n) + # Sets ``coeffs`` to the coefficient array of the Hermite + # polynomial `He_n(x)`, defined by + # `He_n(x) = 2^{-\tfrac{n}{2}}H_n\left(\frac{x}{\sqrt2}\right)`, for `n\ge0`. + # The coefficients are calculated using a hypergeometric recurrence. + # The length of the array will be ``n+1``. + + void fmpz_poly_hermite_he(fmpz_poly_t poly, unsigned long n) + # Sets ``poly`` to the Hermite polynomial `He_n(x)`, + # defined by `He_n(x) = 2^{-\tfrac{n}{2}}H_n\left(\frac{x}{\sqrt2}\right)`, for `n\ge0`. + # The coefficients are calculated using a hypergeometric recurrence. + + void _fmpz_poly_fibonacci(fmpz * coeffs, unsigned long n) + # Sets ``coeffs`` to the coefficient array of the `n`-th Fibonacci polynomial. + # The coefficients are calculated using a hypergeometric recurrence. + + void fmpz_poly_fibonacci(fmpz_poly_t poly, unsigned long n) + # Sets ``poly`` to the `n`-th Fibonacci polynomial. + # The coefficients are calculated using a hypergeometric recurrence. + + void arith_eulerian_polynomial(fmpz_poly_t res, unsigned long n) + # Sets ``res`` to the Eulerian polynomial `A_n(x)`, where we define + # `A_0(x) = 1`. The polynomial is calculated via a recursive relation. + + void _fmpz_poly_eta_qexp(fmpz * f, long r, long len) + void fmpz_poly_eta_qexp(fmpz_poly_t f, long r, long n) + # Sets `f` to the `q`-expansion to length `n` of the + # Dedekind eta function (without the leading factor + # `q^{1/24}`) raised to the power `r`, i.e. + # `(q^{-1/24} \eta(q))^r = \prod_{k=1}^{\infty} (1 - q^k)^r`. + # In particular, `r = -1` gives the generating function + # of the partition function `p(k)`, and `r = 24` gives, + # after multiplication by `q`, + # the modular discriminant `\Delta(q)` which generates + # the Ramanujan tau function `\tau(k)`. + # This function uses sparse formulas for `r = 1, 2, 3, 4, 6` + # and otherwise reduces to one of those cases using power series arithmetic. + + void _fmpz_poly_theta_qexp(fmpz * f, long r, long len) + void fmpz_poly_theta_qexp(fmpz_poly_t f, long r, long n) + # Sets `f` to the `q`-expansion to length `n` of the + # Jacobi theta function raised to the power `r`, i.e. `\vartheta(q)^r` + # where `\vartheta(q) = 1 + 2 \sum_{k=1}^{\infty} q^{k^2}`. + # This function uses sparse formulas for `r = 1, 2` + # and otherwise reduces to those cases using power series arithmetic. + + void fmpz_poly_CLD_bound(fmpz_t res, const fmpz_poly_t f, long n) + # Compute a bound on the `n` coefficient of `fg'/g` where `g` is any + # factor of `f`. + +from .fmpz_poly_macros cimport * diff --git a/src/sage/libs/flint/fmpz_poly_factor.pxd b/src/sage/libs/flint/fmpz_poly_factor.pxd new file mode 100644 index 00000000000..5af3341e064 --- /dev/null +++ b/src/sage/libs/flint/fmpz_poly_factor.pxd @@ -0,0 +1,101 @@ +# distutils: libraries = flint +# distutils: depends = flint/fmpz_poly_factor.h + +################################################################################ +# This file is auto-generated. Do not modify by hand +################################################################################ + +from libc.stdio cimport FILE +from sage.libs.gmp.types cimport * +from sage.libs.mpfr.types cimport * +from sage.libs.flint.types cimport * + +cdef extern from "flint_wrap.h": + + void fmpz_poly_factor_init(fmpz_poly_factor_t fac) + # Initialises a new factor structure. + + void fmpz_poly_factor_init2(fmpz_poly_factor_t fac, long alloc) + # Initialises a new factor structure, providing space for + # at least ``alloc`` factors. + + void fmpz_poly_factor_realloc(fmpz_poly_factor_t fac, long alloc) + # Reallocates the factor structure to provide space for + # precisely ``alloc`` factors. + + void fmpz_poly_factor_fit_length(fmpz_poly_factor_t fac, long len) + # Ensures that the factor structure has space for at + # least ``len`` factors. This functions takes care + # of the case of repeated calls by always at least + # doubling the number of factors the structure can hold. + + void fmpz_poly_factor_clear(fmpz_poly_factor_t fac) + # Releases all memory occupied by the factor structure. + + void fmpz_poly_factor_set(fmpz_poly_factor_t res, const fmpz_poly_factor_t fac) + # Sets ``res`` to the same factorisation as ``fac``. + + void fmpz_poly_factor_insert(fmpz_poly_factor_t fac, const fmpz_poly_t p, long e) + # Adds the primitive polynomial `p^e` to the factorisation ``fac``. + # Assumes that `\deg(p) \geq 2` and `e \neq 0`. + + void fmpz_poly_factor_concat(fmpz_poly_factor_t res, const fmpz_poly_factor_t fac) + # Concatenates two factorisations. + # This is equivalent to calling :func:`fmpz_poly_factor_insert` + # repeatedly with the individual factors of ``fac``. + # Does not support aliasing between ``res`` and ``fac``. + + void fmpz_poly_factor_print(const fmpz_poly_factor_t fac) + # Prints the entries of ``fac`` to standard output. + + void fmpz_poly_factor_squarefree(fmpz_poly_factor_t fac, const fmpz_poly_t F) + # Takes as input a polynomial `F` and a freshly initialized factor + # structure ``fac``. Updates ``fac`` to contain a factorization + # of `F` into (not necessarily irreducible) factors that themselves + # have no repeated factors. None of the returned factors will have + # the same exponent. That is we return `g_i` and unique `e_i` such that + # .. math :: + # F = c \prod_{i} g_i^{e_i} + # where `c` is the signed content of `F` and `\gcd(g_i, g_i') = 1`. + + void fmpz_poly_factor_zassenhaus_recombination(fmpz_poly_factor_t final_fac, const fmpz_poly_factor_t lifted_fac, const fmpz_poly_t F, const fmpz_t P, long exp) + # Takes as input a factor structure ``lifted_fac`` containing a + # squarefree factorization of the polynomial `F \bmod p`. The algorithm + # does a brute force search for irreducible factors of `F` over the + # integers, and each factor is raised to the power ``exp``. + # The impact of the algorithm is to augment a factorization of + # ``F^exp`` to the factor structure ``final_fac``. + + void _fmpz_poly_factor_zassenhaus(fmpz_poly_factor_t final_fac, long exp, const fmpz_poly_t f, long cutoff, int use_van_hoeij) + # This is the internal wrapper of Zassenhaus. + # It will attempt to find a small prime such that `f` modulo `p` has + # a minimal number of factors. If it cannot find a prime giving less + # than ``cutoff`` factors it aborts. Then it decides a `p`-adic + # precision to lift the factors to, Hensel lifts, and finally calls + # Zassenhaus recombination. + # Assumes that `\operatorname{len}(f) \geq 2`. + # Assumes that `f` is primitive. + # Assumes that the constant coefficient of `f` is non-zero. Note that + # this can be easily achieved by taking out factors of the form `x^k` + # before calling this routine. + # If the final flag is set, the function will use the van Hoeij factorisation + # algorithm with gradual feeding and mod `2^k` data truncation to find + # factors when the number of local factors is large. + + void fmpz_poly_factor_zassenhaus(fmpz_poly_factor_t final_fac, const fmpz_poly_t F) + # A wrapper of the Zassenhaus factoring algorithm, which takes as input + # any polynomial `F`, and stores a factorization in ``final_fac``. + # The complexity will be exponential in the number of local factors + # we find for the components of a squarefree factorization of `F`. + + void _fmpz_poly_factor_quadratic(fmpz_poly_factor_t fac, const fmpz_poly_t f, long exp) + void _fmpz_poly_factor_cubic(fmpz_poly_factor_t fac, const fmpz_poly_t f, long exp) + # Inserts the factorisation of the quadratic (resp. cubic) polynomial *f* into *fac* with + # multiplicity *exp*. This function requires that the content of *f* has + # been removed, and does not update the content of *fac*. + # The factorization is calculated over `\mathbb{R}` or `\mathbb{Q}_2` and then tested over `\mathbb{Z}`. + + void fmpz_poly_factor(fmpz_poly_factor_t final_fac, const fmpz_poly_t F) + # A wrapper of the Zassenhaus and van Hoeij factoring algorithms, which takes + # as input any polynomial `F`, and stores a factorization in + # ``final_fac``. diff --git a/src/sage/libs/flint/fmpz_poly_macros.pxd b/src/sage/libs/flint/fmpz_poly_macros.pxd new file mode 100644 index 00000000000..dc744322da3 --- /dev/null +++ b/src/sage/libs/flint/fmpz_poly_macros.pxd @@ -0,0 +1,8 @@ +# Macros from fmpz_poly.h +# See https://github.com/flintlib/flint/issues/152 + +from .types cimport * + +cdef extern from "flint_wrap.h": + fmpz * fmpz_poly_get_coeff_ptr(fmpz_poly_t p, ulong n) + # Macro giving a pointer to the n-th coefficient of p (or NULL) diff --git a/src/sage/libs/flint/fmpz_poly_mat.pxd b/src/sage/libs/flint/fmpz_poly_mat.pxd index d045c745de3..50d814146d5 100644 --- a/src/sage/libs/flint/fmpz_poly_mat.pxd +++ b/src/sage/libs/flint/fmpz_poly_mat.pxd @@ -1,27 +1,291 @@ # distutils: libraries = flint # distutils: depends = flint/fmpz_poly_mat.h -from sage.libs.flint.types cimport fmpz_poly_mat_t, fmpz_poly_t, fmpz_t, slong, fmpz_mat_t +################################################################################ +# This file is auto-generated. Do not modify by hand +################################################################################ + +from libc.stdio cimport FILE +from sage.libs.gmp.types cimport * +from sage.libs.mpfr.types cimport * +from sage.libs.flint.types cimport * -# flint/fmpz_poly_mat.h cdef extern from "flint_wrap.h": - void fmpz_poly_mat_init(fmpz_poly_mat_t mat, slong rows, slong cols) + void fmpz_poly_mat_init(fmpz_poly_mat_t mat, long rows, long cols) + # Initialises a matrix with the given number of rows and columns for use. + void fmpz_poly_mat_init_set(fmpz_poly_mat_t mat, const fmpz_poly_mat_t src) + # Initialises a matrix ``mat`` of the same dimensions as ``src``, + # and sets it to a copy of ``src``. + void fmpz_poly_mat_clear(fmpz_poly_mat_t mat) - fmpz_poly_t fmpz_poly_mat_entry(fmpz_poly_mat_t mat, long i, long j) - slong fmpz_poly_mat_nrows(const fmpz_poly_mat_t mat) - slong fmpz_poly_mat_ncols(const fmpz_poly_mat_t mat) + # Frees all memory associated with the matrix. The matrix must be + # reinitialised if it is to be used again. + + long fmpz_poly_mat_nrows(const fmpz_poly_mat_t mat) + # Returns the number of rows in ``mat``. + + long fmpz_poly_mat_ncols(const fmpz_poly_mat_t mat) + # Returns the number of columns in ``mat``. + + fmpz_poly_struct * fmpz_poly_mat_entry(const fmpz_poly_mat_t mat, long i, long j) + # Gives a reference to the entry at row ``i`` and column ``j``. + # The reference can be passed as an input or output variable to any + # ``fmpz_poly`` function for direct manipulation of the matrix element. + # No bounds checking is performed. void fmpz_poly_mat_set(fmpz_poly_mat_t mat1, const fmpz_poly_mat_t mat2) + # Sets ``mat1`` to a copy of ``mat2``. void fmpz_poly_mat_swap(fmpz_poly_mat_t mat1, fmpz_poly_mat_t mat2) + # Swaps ``mat1`` and ``mat2`` efficiently. + + void fmpz_poly_mat_swap_entrywise(fmpz_poly_mat_t mat1, fmpz_poly_mat_t mat2) + # Swaps two matrices by swapping the individual entries rather than swapping + # the contents of the structs. + + void fmpz_poly_mat_print(const fmpz_poly_mat_t mat, const char * x) + # Prints the matrix ``mat`` to standard output, using the + # variable ``x``. + + void fmpz_poly_mat_randtest(fmpz_poly_mat_t mat, flint_rand_t state, long len, flint_bitcnt_t bits) + # This is equivalent to applying ``fmpz_poly_randtest`` to all entries + # in the matrix. + + void fmpz_poly_mat_randtest_unsigned(fmpz_poly_mat_t mat, flint_rand_t state, long len, flint_bitcnt_t bits) + # This is equivalent to applying ``fmpz_poly_randtest_unsigned`` to + # all entries in the matrix. + + void fmpz_poly_mat_randtest_sparse(fmpz_poly_mat_t A, flint_rand_t state, long len, flint_bitcnt_t bits, float density) + # Creates a random matrix with the amount of nonzero entries given + # approximately by the ``density`` variable, which should be a fraction + # between 0 (most sparse) and 1 (most dense). + # The nonzero entries will have random lengths between 1 and ``len``. + + void fmpz_poly_mat_zero(fmpz_poly_mat_t mat) + # Sets ``mat`` to the zero matrix. + + void fmpz_poly_mat_one(fmpz_poly_mat_t mat) + # Sets ``mat`` to the unit or identity matrix of given shape, + # having the element 1 on the main diagonal and zeros elsewhere. + # If ``mat`` is nonsquare, it is set to the truncation of a unit matrix. + + int fmpz_poly_mat_equal(const fmpz_poly_mat_t mat1, const fmpz_poly_mat_t mat2) + # Returns nonzero if ``mat1`` and ``mat2`` have the same shape and + # all their entries agree, and returns zero otherwise. + + int fmpz_poly_mat_is_zero(const fmpz_poly_mat_t mat) + # Returns nonzero if all entries in ``mat`` are zero, and returns + # zero otherwise. + + int fmpz_poly_mat_is_one(const fmpz_poly_mat_t mat) + # Returns nonzero if all entries of ``mat`` on the main diagonal + # are the constant polynomial 1 and all remaining entries are zero, + # and returns zero otherwise. The matrix need not be square. + + int fmpz_poly_mat_is_empty(const fmpz_poly_mat_t mat) + # Returns a non-zero value if the number of rows or the number of + # columns in ``mat`` is zero, and otherwise returns + # zero. + + int fmpz_poly_mat_is_square(const fmpz_poly_mat_t mat) + # Returns a non-zero value if the number of rows is equal to the + # number of columns in ``mat``, and otherwise returns zero. + + long fmpz_poly_mat_max_bits(const fmpz_poly_mat_t A) + # Returns the maximum number of bits among the coefficients of the + # entries in ``A``, or the negative of that value if any + # coefficient is negative. + + long fmpz_poly_mat_max_length(const fmpz_poly_mat_t A) + # Returns the maximum polynomial length among all the entries in ``A``. void fmpz_poly_mat_transpose(fmpz_poly_mat_t B, const fmpz_poly_mat_t A) + # Sets `B` to `A^t`. + + void fmpz_poly_mat_evaluate_fmpz(fmpz_mat_t B, const fmpz_poly_mat_t A, const fmpz_t x) + # Sets the ``fmpz_mat_t`` ``B`` to ``A`` evaluated entrywise + # at the point ``x``. + + void fmpz_poly_mat_scalar_mul_fmpz_poly(fmpz_poly_mat_t B, const fmpz_poly_mat_t A, const fmpz_poly_t c) + # Sets ``B`` to ``A`` multiplied entrywise by the polynomial ``c``. + + void fmpz_poly_mat_scalar_mul_fmpz(fmpz_poly_mat_t B, const fmpz_poly_mat_t A, const fmpz_t c) + # Sets ``B`` to ``A`` multiplied entrywise by the integer ``c``. + + void fmpz_poly_mat_add(fmpz_poly_mat_t C, const fmpz_poly_mat_t A, const fmpz_poly_mat_t B) + # Sets ``C`` to the sum of ``A`` and ``B``. + # All matrices must have the same shape. Aliasing is allowed. - void fmpz_poly_mat_evaluate_fmpz(fmpz_mat_t B, const fmpz_poly_mat_t A, - const fmpz_t x) + void fmpz_poly_mat_sub(fmpz_poly_mat_t C, const fmpz_poly_mat_t A, const fmpz_poly_mat_t B) + # Sets ``C`` to the sum of ``A`` and ``B``. + # All matrices must have the same shape. Aliasing is allowed. + + void fmpz_poly_mat_neg(fmpz_poly_mat_t B, const fmpz_poly_mat_t A) + # Sets ``B`` to the negation of ``A``. + # The matrices must have the same shape. Aliasing is allowed. + + void fmpz_poly_mat_mul(fmpz_poly_mat_t C, const fmpz_poly_mat_t A, const fmpz_poly_mat_t B) + # Sets ``C`` to the matrix product of ``A`` and ``B``. + # The matrices must have compatible dimensions for matrix multiplication. + # Aliasing is allowed. This function automatically chooses between + # classical and KS multiplication. + + void fmpz_poly_mat_mul_classical(fmpz_poly_mat_t C, const fmpz_poly_mat_t A, const fmpz_poly_mat_t B) + # Sets ``C`` to the matrix product of ``A`` and ``B``, + # computed using the classical algorithm. The matrices must have + # compatible dimensions for matrix multiplication. Aliasing is allowed. + + void fmpz_poly_mat_mul_KS(fmpz_poly_mat_t C, const fmpz_poly_mat_t A, const fmpz_poly_mat_t B) + # Sets ``C`` to the matrix product of ``A`` and ``B``, + # computed using Kronecker segmentation. The matrices must have + # compatible dimensions for matrix multiplication. Aliasing is allowed. + + void fmpz_poly_mat_mullow(fmpz_poly_mat_t C, const fmpz_poly_mat_t A, const fmpz_poly_mat_t B, long len) + # Sets ``C`` to the matrix product of ``A`` and ``B``, + # truncating each entry in the result to length ``len``. + # Uses classical matrix multiplication. The matrices must have + # compatible dimensions for matrix multiplication. Aliasing is allowed. + + void fmpz_poly_mat_sqr(fmpz_poly_mat_t B, const fmpz_poly_mat_t A) + # Sets ``B`` to the square of ``A``, which must be a square matrix. + # Aliasing is allowed. This function automatically chooses between + # classical and KS squaring. + + void fmpz_poly_mat_sqr_classical(fmpz_poly_mat_t B, const fmpz_poly_mat_t A) + # Sets ``B`` to the square of ``A``, which must be a square matrix. + # Aliasing is allowed. This function uses direct formulas for very small + # matrices, and otherwise classical matrix multiplication. + + void fmpz_poly_mat_sqr_KS(fmpz_poly_mat_t B, const fmpz_poly_mat_t A) + # Sets ``B`` to the square of ``A``, which must be a square matrix. + # Aliasing is allowed. This function uses Kronecker segmentation. + + void fmpz_poly_mat_sqrlow(fmpz_poly_mat_t B, const fmpz_poly_mat_t A, long len) + # Sets ``B`` to the square of ``A``, which must be a square matrix, + # truncating all entries to length ``len``. + # Aliasing is allowed. This function uses direct formulas for very small + # matrices, and otherwise classical matrix multiplication. + + void fmpz_poly_mat_pow(fmpz_poly_mat_t B, const fmpz_poly_mat_t A, unsigned long exp) + # Sets ``B`` to ``A`` raised to the power ``exp``, where ``A`` + # is a square matrix. Uses exponentiation by squaring. Aliasing is allowed. + + void fmpz_poly_mat_pow_trunc(fmpz_poly_mat_t B, const fmpz_poly_mat_t A, unsigned long exp, long len) + # Sets ``B`` to ``A`` raised to the power ``exp``, truncating + # all entries to length ``len``, where ``A`` is a square matrix. + # Uses exponentiation by squaring. Aliasing is allowed. + + void fmpz_poly_mat_prod(fmpz_poly_mat_t res, fmpz_poly_mat_t * const factors, long n) + # Sets ``res`` to the product of the ``n`` matrices given in + # the vector ``factors``, all of which must be square and of the + # same size. Uses binary splitting. + + long fmpz_poly_mat_find_pivot_any(const fmpz_poly_mat_t mat, long start_row, long end_row, long c) + # Attempts to find a pivot entry for row reduction. + # Returns a row index `r` between ``start_row`` (inclusive) and + # ``stop_row`` (exclusive) such that column `c` in ``mat`` has + # a nonzero entry on row `r`, or returns -1 if no such entry exists. + # This implementation simply chooses the first nonzero entry + # it encounters. This is likely to be a nearly optimal choice if all + # entries in the matrix have roughly the same size, but can lead to + # unnecessary coefficient growth if the entries vary in size. + + long fmpz_poly_mat_find_pivot_partial(const fmpz_poly_mat_t mat, long start_row, long end_row, long c) + # Attempts to find a pivot entry for row reduction. + # Returns a row index `r` between ``start_row`` (inclusive) and + # ``stop_row`` (exclusive) such that column `c` in ``mat`` has + # a nonzero entry on row `r`, or returns -1 if no such entry exists. + # This implementation searches all the rows in the column and + # chooses the nonzero entry of smallest degree. If there are several + # entries with the same minimal degree, it chooses the entry with + # the smallest coefficient bit bound. This heuristic typically reduces + # coefficient growth when the matrix entries vary in size. + + long fmpz_poly_mat_fflu(fmpz_poly_mat_t B, fmpz_poly_t den, long * perm, const fmpz_poly_mat_t A, int rank_check) + # Uses fraction-free Gaussian elimination to set (``B``, ``den``) to a + # fraction-free LU decomposition of ``A`` and returns the + # rank of ``A``. Aliasing of ``A`` and ``B`` is allowed. + # Pivot elements are chosen with ``fmpz_poly_mat_find_pivot_partial``. + # If ``perm`` is non-``NULL``, the permutation of + # rows in the matrix will also be applied to ``perm``. + # If ``rank_check`` is set, the function aborts and returns 0 if the + # matrix is detected not to have full rank without completing the + # elimination. + # The denominator ``den`` is set to `\pm \operatorname{det}(A)`, where + # the sign is decided by the parity of the permutation. Note that the + # determinant is not generally the minimal denominator. + + long fmpz_poly_mat_rref(fmpz_poly_mat_t B, fmpz_poly_t den, const fmpz_poly_mat_t A) + # Sets (``B``, ``den``) to the reduced row echelon form of + # ``A`` and returns the rank of ``A``. Aliasing of ``A`` and + # ``B`` is allowed. + # The denominator ``den`` is set to `\pm \operatorname{det}(A)`. + # Note that the determinant is not generally the minimal denominator. void fmpz_poly_mat_trace(fmpz_poly_t trace, const fmpz_poly_mat_t mat) + # Computes the trace of the matrix, i.e. the sum of the entries on + # the main diagonal. The matrix is required to be square. void fmpz_poly_mat_det(fmpz_poly_t det, const fmpz_poly_mat_t A) + # Sets ``det`` to the determinant of the square matrix ``A``. Uses + # a direct formula, fraction-free LU decomposition, or interpolation, + # depending on the size of the matrix. + + void fmpz_poly_mat_det_fflu(fmpz_poly_t det, const fmpz_poly_mat_t A) + # Sets ``det`` to the determinant of the square matrix ``A``. + # The determinant is computed by performing a fraction-free LU + # decomposition on a copy of ``A``. + + void fmpz_poly_mat_det_interpolate(fmpz_poly_t det, const fmpz_poly_mat_t A) + # Sets ``det`` to the determinant of the square matrix ``A``. + # The determinant is computed by determining a bound `n` for its length, + # evaluating the matrix at `n` distinct points, computing the determinant + # of each integer matrix, and forming the interpolating polynomial. + + long fmpz_poly_mat_rank(const fmpz_poly_mat_t A) + # Returns the rank of ``A``. Performs fraction-free LU decomposition + # on a copy of ``A``. + + int fmpz_poly_mat_inv(fmpz_poly_mat_t Ainv, fmpz_poly_t den, const fmpz_poly_mat_t A) + # Sets (``Ainv``, ``den``) to the inverse matrix of ``A``. + # Returns 1 if ``A`` is nonsingular and 0 if ``A`` is singular. + # Aliasing of ``Ainv`` and ``A`` is allowed. + # More precisely, ``det`` will be set to the determinant of ``A`` + # and ``Ainv`` will be set to the adjugate matrix of ``A``. + # Note that the determinant is not necessarily the minimal denominator. + # Uses fraction-free LU decomposition, followed by solving for + # the identity matrix. + + long fmpz_poly_mat_nullspace(fmpz_poly_mat_t res, const fmpz_poly_mat_t mat) + # Computes the right rational nullspace of the matrix ``mat`` and + # returns the nullity. + # More precisely, assume that ``mat`` has rank `r` and nullity `n`. + # Then this function sets the first `n` columns of ``res`` + # to linearly independent vectors spanning the nullspace of ``mat``. + # As a result, we always have rank(``res``) `= n`, and + # ``mat`` `\times` ``res`` is the zero matrix. + # The computed basis vectors will not generally be in a reduced form. + # In general, the polynomials in each column vector in the result + # will have a nontrivial common GCD. + + int fmpz_poly_mat_solve(fmpz_poly_mat_t X, fmpz_poly_t den, const fmpz_poly_mat_t A, const fmpz_poly_mat_t B) + # Solves the equation `AX = B` for nonsingular `A`. More precisely, computes + # (``X``, ``den``) such that `AX = B \times \operatorname{den}`. + # Returns 1 if `A` is nonsingular and 0 if `A` is singular. + # The computed denominator will not generally be minimal. + # Uses fraction-free LU decomposition followed by fraction-free + # forward and back substitution. + + int fmpz_poly_mat_solve_fflu(fmpz_poly_mat_t X, fmpz_poly_t den, const fmpz_poly_mat_t A, const fmpz_poly_mat_t B) + # Solves the equation `AX = B` for nonsingular `A`. More precisely, computes + # (``X``, ``den``) such that `AX = B \times \operatorname{den}`. + # Returns 1 if `A` is nonsingular and 0 if `A` is singular. + # The computed denominator will not generally be minimal. + # Uses fraction-free LU decomposition followed by fraction-free + # forward and back substitution. + + void fmpz_poly_mat_solve_fflu_precomp(fmpz_poly_mat_t X, const long * perm, const fmpz_poly_mat_t FFLU, const fmpz_poly_mat_t B) + # Performs fraction-free forward and back substitution given a precomputed + # fraction-free LU decomposition and corresponding permutation. diff --git a/src/sage/libs/flint/fmpz_poly_sage.pxd b/src/sage/libs/flint/fmpz_poly_sage.pxd new file mode 100644 index 00000000000..1d86947143a --- /dev/null +++ b/src/sage/libs/flint/fmpz_poly_sage.pxd @@ -0,0 +1,19 @@ +# distutils: libraries = flint +# distutils: depends = flint/fmpz_poly.h + +from sage.libs.gmp.types cimport mpz_t +from .types cimport * + +# functions removed from flint but still needed in sage +cdef void fmpz_poly_scalar_mul_mpz(fmpz_poly_t, const fmpz_poly_t, const mpz_t) +cdef void fmpz_poly_scalar_divexact_mpz(fmpz_poly_t, const fmpz_poly_t, const mpz_t) +cdef void fmpz_poly_scalar_fdiv_mpz(fmpz_poly_t, const fmpz_poly_t, const mpz_t) +cdef void fmpz_poly_set_coeff_mpz(fmpz_poly_t, slong, const mpz_t) +cdef void fmpz_poly_get_coeff_mpz(mpz_t, const fmpz_poly_t, slong) +cdef void fmpz_poly_set_mpz(fmpz_poly_t, const mpz_t) + + +# Wrapper Cython class +from sage.structure.sage_object cimport SageObject +cdef class Fmpz_poly(SageObject): + cdef fmpz_poly_t poly diff --git a/src/sage/libs/flint/fmpz_poly.pyx b/src/sage/libs/flint/fmpz_poly_sage.pyx similarity index 99% rename from src/sage/libs/flint/fmpz_poly.pyx rename to src/sage/libs/flint/fmpz_poly_sage.pyx index cfcbea9090c..c20db2eed7b 100644 --- a/src/sage/libs/flint/fmpz_poly.pyx +++ b/src/sage/libs/flint/fmpz_poly_sage.pyx @@ -26,6 +26,7 @@ from cysignals.memory cimport sig_free from sage.arith.long cimport pyobject_to_long from sage.cpython.string cimport char_to_str, str_to_bytes from sage.libs.flint.fmpz cimport * +from sage.libs.flint.fmpz_poly cimport * from sage.structure.sage_object cimport SageObject from sage.rings.integer cimport Integer diff --git a/src/sage/libs/flint/fq_default.pxd b/src/sage/libs/flint/fq_default.pxd new file mode 100644 index 00000000000..01e7c55b3ee --- /dev/null +++ b/src/sage/libs/flint/fq_default.pxd @@ -0,0 +1,305 @@ +# distutils: libraries = flint +# distutils: depends = flint/fq_default.h + +################################################################################ +# This file is auto-generated. Do not modify by hand +################################################################################ + +from libc.stdio cimport FILE +from sage.libs.gmp.types cimport * +from sage.libs.mpfr.types cimport * +from sage.libs.flint.types cimport * + +cdef extern from "flint_wrap.h": + + void fq_default_ctx_init(fq_default_ctx_t ctx, const fmpz_t p, long d, const char * var) + # Initialises the context for prime `p` and extension degree `d`, + # with name ``var`` for the generator. By default, it will try + # use a Conway polynomial; if one is not available, a random + # irreducible polynomial will be used. + # Assumes that `p` is a prime. + # Assumes that the string ``var`` is a null-terminated string + # of length at least one. + + void fq_default_ctx_init_type(fq_default_ctx_t ctx, const fmpz_t p, long d, const char * var, int type) + # As per the previous function except that if ``type == 1`` an ``fq_zech`` + # context is created, if ``type == 2`` an ``fq_nmod`` and if ``type == 3`` + # an ``fq``. If ``type == 0`` the functionality is as per the previous + # function. + + void fq_default_ctx_init_modulus(fq_default_ctx_t ctx, const fmpz_mod_poly_t modulus, fmpz_mod_ctx_t mod_ctx, const char * var) + # Initialises the context for the finite field defined by the given + # polynomial ``modulus``. The characteristic will be the modulus of + # the polynomial and the degree equal to its degree. + # Assumes that the characteristic is prime and the polynomial irreducible. + # Assumes that the string ``var`` is a null-terminated string + # of length at least one. + + void fq_default_ctx_init_modulus_type(fq_default_ctx_t ctx, const fmpz_mod_poly_t modulus, fmpz_mod_ctx_t mod_ctx, const char * var, int type) + # As per the previous function except that if ``type == 1`` an ``fq_zech`` + # context is created, if ``type == 2`` an ``fq_nmod`` and if ``type == 3`` + # an ``fq``. If ``type == 0`` the functionality is as per the previous + # function. + + void fq_default_ctx_init_modulus_nmod(fq_default_ctx_t ctx, const nmod_poly_t modulus, const char * var) + # Initialises the context for the finite field defined by the given + # polynomial ``modulus``. The characteristic will be the modulus of + # the polynomial and the degree equal to its degree. + # Assumes that the characteristic is prime and the polynomial irreducible. + # Assumes that the string ``var`` is a null-terminated string + # of length at least one. + + void fq_default_ctx_init_modulus_nmod_type(fq_default_ctx_t ctx, const nmod_poly_t modulus, const char * var, int type) + # As per the previous function except that if ``type == 1`` an ``fq_zech`` + # context is created, if ``type == 2`` an ``fq_nmod`` and if ``type == 3`` + # an ``fq``. If ``type == 0`` the functionality is as per the previous + # function. + + void fq_default_ctx_clear(fq_default_ctx_t ctx) + # Clears all memory that has been allocated as part of the context. + + int fq_default_ctx_type(const fq_default_ctx_t ctx) + # Returns `1` if the context contains an ``fq_zech`` context, `2` if it + # contains an ``fq_mod`` context and `3` if it contains an ``fq`` context. + + long fq_default_ctx_degree(const fq_default_ctx_t ctx) + # Returns the degree of the field extension + # `[\mathbf{F}_{q} : \mathbf{F}_{p}]`, which + # is equal to `\log_{p} q`. + + void fq_default_ctx_prime(fmpz_t prime, const fq_default_ctx_t ctx) + # Sets `prime` to the prime `p` in the context. + + void fq_default_ctx_order(fmpz_t f, const fq_default_ctx_t ctx) + # Sets `f` to be the size of the finite field. + + void fq_default_ctx_modulus(fmpz_mod_poly_t p, const fq_default_ctx_t ctx) + # Sets `p` to the defining polynomial of the finite field.. + + int fq_default_ctx_fprint(FILE * file, const fq_default_ctx_t ctx) + # Prints the context information to ``file``. Returns 1 for a + # success and a negative number for an error. + + void fq_default_ctx_print(const fq_default_ctx_t ctx) + # Prints the context information to ``stdout``. + + void fq_default_ctx_randtest(fq_default_ctx_t ctx) + # Initializes ``ctx`` to a random finite field. Assumes that + # ``fq_default_ctx_init`` has not been called on ``ctx`` already. + + void fq_default_get_coeff_fmpz(fmpz_t c, fq_default_t op, long n, const fq_default_ctx_t ctx) + # Set `c` to the degree `n` coefficient of the polynomial representation of + # the finite field element ``op``. + + void fq_default_init(fq_default_t rop, const fq_default_ctx_t ctx) + # Initialises the element ``rop``, setting its value to `0`. + + void fq_default_init2(fq_default_t rop, const fq_default_ctx_t ctx) + # Initialises ``poly`` with at least enough space for it to be an element + # of ``ctx`` and sets it to `0`. + + void fq_default_clear(fq_default_t rop, const fq_default_ctx_t ctx) + # Clears the element ``rop``. + + int fq_default_is_invertible(const fq_default_t op, const fq_default_ctx_t ctx) + # Return ``1`` if ``op`` is an invertible element. + + void fq_default_add(fq_default_t rop, const fq_default_t op1, const fq_default_t op2, const fq_default_ctx_t ctx) + # Sets ``rop`` to the sum of ``op1`` and ``op2``. + + void fq_default_sub(fq_default_t rop, const fq_default_t op1, const fq_default_t op2, const fq_default_ctx_t ctx) + # Sets ``rop`` to the difference of ``op1`` and ``op2``. + + void fq_default_sub_one(fq_default_t rop, const fq_default_t op1, const fq_default_ctx_t ctx) + # Sets ``rop`` to the difference of ``op1`` and `1`. + + void fq_default_neg(fq_default_t rop, const fq_default_t op, const fq_default_ctx_t ctx) + # Sets ``rop`` to the negative of ``op``. + + void fq_default_mul(fq_default_t rop, const fq_default_t op1, const fq_default_t op2, const fq_default_ctx_t ctx) + # Sets ``rop`` to the product of ``op1`` and ``op2``, + # reducing the output in the given context. + + void fq_default_mul_fmpz(fq_default_t rop, const fq_default_t op, const fmpz_t x, const fq_default_ctx_t ctx) + # Sets ``rop`` to the product of ``op`` and `x`, + # reducing the output in the given context. + + void fq_default_mul_si(fq_default_t rop, const fq_default_t op, long x, const fq_default_ctx_t ctx) + # Sets ``rop`` to the product of ``op`` and `x`, + # reducing the output in the given context. + + void fq_default_mul_ui(fq_default_t rop, const fq_default_t op, unsigned long x, const fq_default_ctx_t ctx) + # Sets ``rop`` to the product of ``op`` and `x`, + # reducing the output in the given context. + + void fq_default_sqr(fq_default_t rop, const fq_default_t op, const fq_default_ctx_t ctx) + # Sets ``rop`` to the square of ``op``, + # reducing the output in the given context. + + void fq_default_div(fq_default_t rop, fq_default_t op1, fq_default_t op2, const fq_default_ctx_t ctx) + # Sets ``rop`` to the quotient of ``op1`` and ``op2``, + # reducing the output in the given context. + + void fq_default_inv(fq_default_t rop, const fq_default_t op, const fq_default_ctx_t ctx) + # Sets ``rop`` to the inverse of the non-zero element ``op``. + + void fq_default_pow(fq_default_t rop, const fq_default_t op, const fmpz_t e, const fq_default_ctx_t ctx) + # Sets ``rop`` the ``op`` raised to the power `e`. + # Currently assumes that `e \geq 0`. + # Note that for any input ``op``, ``rop`` is set to `1` + # whenever `e = 0`. + + void fq_default_pow_ui(fq_default_t rop, const fq_default_t op, const unsigned long e, const fq_default_ctx_t ctx) + # Sets ``rop`` the ``op`` raised to the power `e`. + # Currently assumes that `e \geq 0`. + # Note that for any input ``op``, ``rop`` is set to `1` + # whenever `e = 0`. + + int fq_default_sqrt(fq_default_t rop, const fq_default_t op1, const fq_default_ctx_t ctx) + # Sets ``rop`` to the square root of ``op1`` if it is a square, and return + # `1`, otherwise return `0`. + + void fq_default_pth_root(fq_default_t rop, const fq_default_t op1, const fq_default_ctx_t ctx) + # Sets ``rop`` to a `p^{th}` root root of ``op1``. Currently, + # this computes the root by raising ``op1`` to `p^{d-1}` where + # `d` is the degree of the extension. + + int fq_default_is_square(const fq_default_t op, const fq_default_ctx_t ctx) + # Return ``1`` if ``op`` is a square. + + int fq_default_fprint_pretty(FILE *file, const fq_default_t op, const fq_default_ctx_t ctx) + # Prints a pretty representation of ``op`` to ``file``. + # In the current implementation, always returns `1`. The return code is + # part of the function's signature to allow for a later implementation to + # return the number of characters printed or a non-positive error code. + + void fq_default_print_pretty(const fq_default_t op, const fq_default_ctx_t ctx) + # Prints a pretty representation of ``op`` to ``stdout``. + # In the current implementation, always returns `1`. The return code is + # part of the function's signature to allow for a later implementation to + # return the number of characters printed or a non-positive error code. + + int fq_default_fprint(FILE * file, const fq_default_t op, const fq_default_ctx_t ctx) + # Prints a representation of ``op`` to ``file``. + + void fq_default_print(const fq_default_t op, const fq_default_ctx_t ctx) + # Prints a representation of ``op`` to ``stdout``. + + char * fq_default_get_str(const fq_default_t op, const fq_default_ctx_t ctx) + # Returns the plain FLINT string representation of the element + # ``op``. + + char * fq_default_get_str_pretty(const fq_default_t op, const fq_default_ctx_t ctx) + # Returns a pretty representation of the element ``op`` using the + # null-terminated string ``x`` as the variable name. + + void fq_default_randtest(fq_default_t rop, flint_rand_t state, const fq_default_ctx_t ctx) + # Generates a random element of `\mathbf{F}_q`. + + void fq_default_randtest_not_zero(fq_default_t rop, flint_rand_t state, const fq_default_ctx_t ctx) + # Generates a random non-zero element of `\mathbf{F}_q`. + + void fq_default_rand(fq_default_t rop, flint_rand_t state, const fq_default_ctx_t ctx) + # Generates a high quality random element of `\mathbf{F}_q`. + + void fq_default_rand_not_zero(fq_default_t rop, flint_rand_t state, const fq_default_ctx_t ctx) + # Generates a high quality non-zero random element of `\mathbf{F}_q`. + + void fq_default_set(fq_default_t rop, const fq_default_t op, const fq_default_ctx_t ctx) + # Sets ``rop`` to ``op``. + + void fq_default_set_si(fq_default_t rop, const long x, const fq_default_ctx_t ctx) + # Sets ``rop`` to ``x``, considered as an element of + # `\mathbf{F}_p`. + + void fq_default_set_ui(fq_default_t rop, const unsigned long x, const fq_default_ctx_t ctx) + # Sets ``rop`` to ``x``, considered as an element of + # `\mathbf{F}_p`. + + void fq_default_set_fmpz(fq_default_t rop, const fmpz_t x, const fq_default_ctx_t ctx) + # Sets ``rop`` to ``x``, considered as an element of + # `\mathbf{F}_p`. + + void fq_default_swap(fq_default_t op1, fq_default_t op2, const fq_default_ctx_t ctx) + # Swaps the two elements ``op1`` and ``op2``. + + void fq_default_zero(fq_default_t rop, const fq_default_ctx_t ctx) + # Sets ``rop`` to zero. + + void fq_default_one(fq_default_t rop, const fq_default_ctx_t ctx) + # Sets ``rop`` to one, reduced in the given context. + + void fq_default_gen(fq_default_t rop, const fq_default_ctx_t ctx) + # Sets ``rop`` to a generator for the finite field. + # There is no guarantee this is a multiplicative generator of + # the finite field. + + int fq_default_get_fmpz(fmpz_t rop, const fq_default_t op, const fq_default_ctx_t ctx) + # If ``op`` has a lift to the integers, return `1` and set ``rop`` to the lift in `[0,p)`. + # Otherwise, return `0` and leave `rop` undefined. + + void fq_default_get_nmod_poly(nmod_poly_t poly, const fq_default_t op, const fq_default_ctx_t ctx) + # Sets ``poly`` to the polynomial representation of ``op``. Assumes the + # characteristic of the field and the modulus of the polynomial are the same. + # No checking of this occurs. + + void fq_default_set_nmod_poly(fq_default_t op, const nmod_poly_t poly, const fq_default_ctx_t ctx) + # Sets ``op`` to the finite field element represented by the polynomial + # ``poly``. Assumes the characteristic of the field and the modulus of the + # polynomial are the same. No checking of this occurs. + + void fq_default_get_fmpz_mod_poly(fmpz_mod_poly_t poly, const fq_default_t op, const fq_default_ctx_t ctx) + # Sets ``poly`` to the polynomial representation of ``op``. Assumes the + # characteristic of the field and the modulus of the polynomial are the same. + # No checking of this occurs. + + void fq_default_set_fmpz_mod_poly(fq_default_t op, const fmpz_mod_poly_t poly, const fq_default_ctx_t ctx) + # Sets ``op`` to the finite field element represented by the polynomial + # ``poly``. Assumes the characteristic of the field and the modulus of the + # polynomial are the same. No checking of this occurs. + + void fq_default_get_fmpz_poly(fmpz_poly_t a, const fq_default_t b, const fq_default_ctx_t ctx) + # Set ``a`` to a representative of ``b`` in ``ctx``. + # The representatives are taken in `(\mathbb{Z}/p\mathbb{Z})[x]/h(x)` where + # `h(x)` is the defining polynomial in ``ctx``. + + void fq_default_set_fmpz_poly(fq_default_t a, const fmpz_poly_t b, const fq_default_ctx_t ctx) + # Set ``a`` to the element in ``ctx`` with representative ``b``. + # The representatives are taken in `(\mathbb{Z}/p\mathbb{Z})[x]/h(x)` where + # `h(x)` is the defining polynomial in ``ctx``. + + int fq_default_is_zero(const fq_default_t op, const fq_default_ctx_t ctx) + # Returns whether ``op`` is equal to zero. + + int fq_default_is_one(const fq_default_t op, const fq_default_ctx_t ctx) + # Returns whether ``op`` is equal to one. + + int fq_default_equal(const fq_default_t op1, const fq_default_t op2, const fq_default_ctx_t ctx) + # Returns whether ``op1`` and ``op2`` are equal. + + void fq_default_trace(fmpz_t rop, const fq_default_t op, const fq_default_ctx_t ctx) + # Sets ``rop`` to the trace of ``op``. + # For an element `a \in \mathbf{F}_q`, multiplication by `a` defines + # a `\mathbf{F}_p`-linear map on `\mathbf{F}_q`. We define the + # trace of `a` as the trace of this map. Equivalently, if `\Sigma` + # generates `\operatorname{Gal}(\mathbf{F}_q / \mathbf{F}_p)` then the trace of + # `a` is equal to `\sum_{i=0}^{d-1} \Sigma^i (a)`, where `d = + # \log_{p} q`. + + void fq_default_norm(fmpz_t rop, const fq_default_t op, const fq_default_ctx_t ctx) + # Computes the norm of ``op``. + # For an element `a \in \mathbf{F}_q`, multiplication by `a` defines + # a `\mathbf{F}_p`-linear map on `\mathbf{F}_q`. We define the norm + # of `a` as the determinant of this map. Equivalently, if `\Sigma` generates + # `\operatorname{Gal}(\mathbf{F}_q / \mathbf{F}_p)` then the trace of `a` is equal to + # `\prod_{i=0}^{d-1} \Sigma^i (a)`, where + # `d = \text{dim}_{\mathbf{F}_p}(\mathbf{F}_q)`. + # Algorithm selection is automatic depending on the input. + + void fq_default_frobenius(fq_default_t rop, const fq_default_t op, long e, const fq_default_ctx_t ctx) + # Evaluates the homomorphism `\Sigma^e` at ``op``. + # Recall that `\mathbf{F}_q / \mathbf{F}_p` is Galois with Galois group + # `\langle \sigma \rangle`, which is also isomorphic to + # `\mathbf{Z}/d\mathbf{Z}`, where + # `\sigma \in \operatorname{Gal}(\mathbf{F}_q/\mathbf{F}_p)` is the Frobenius element + # `\sigma \colon x \mapsto x^p`. diff --git a/src/sage/libs/flint/fq_default_mat.pxd b/src/sage/libs/flint/fq_default_mat.pxd new file mode 100644 index 00000000000..a525d5c22b9 --- /dev/null +++ b/src/sage/libs/flint/fq_default_mat.pxd @@ -0,0 +1,275 @@ +# distutils: libraries = flint +# distutils: depends = flint/fq_default_mat.h + +################################################################################ +# This file is auto-generated. Do not modify by hand +################################################################################ + +from libc.stdio cimport FILE +from sage.libs.gmp.types cimport * +from sage.libs.mpfr.types cimport * +from sage.libs.flint.types cimport * + +cdef extern from "flint_wrap.h": + + void fq_default_mat_init(fq_default_mat_t mat, long rows, long cols, const fq_default_ctx_t ctx) + # Initialises ``mat`` to a ``rows``-by-``cols`` matrix with + # coefficients in `\mathbf{F}_{q}` given by ``ctx``. All elements + # are set to zero. + + void fq_default_mat_init_set(fq_default_mat_t mat, const fq_default_mat_t src, const fq_default_ctx_t ctx) + # Initialises ``mat`` and sets its dimensions and elements to + # those of ``src``. + + void fq_default_mat_clear(fq_default_mat_t mat, const fq_default_ctx_t ctx) + # Clears the matrix and releases any memory it used. The matrix + # cannot be used again until it is initialised. This function must be + # called exactly once when finished using an ``fq_default_mat_t`` object. + + void fq_default_mat_set(fq_default_mat_t mat, const fq_default_mat_t src, const fq_default_ctx_t ctx) + # Sets ``mat`` to a copy of ``src``. It is assumed + # that ``mat`` and ``src`` have identical dimensions. + + void fq_default_mat_entry(fq_default_t val, const fq_default_mat_t mat, long i, long j, const fq_default_ctx_t ctx) + # Directly accesses the entry in ``mat`` in row `i` and column `j`, + # indexed from zero by setting ``val`` to the value of that entry. No bounds + # checking is performed. + + void fq_default_mat_entry_set(fq_default_mat_t mat, long i, long j, const fq_default_t x, const fq_default_ctx_t ctx) + # Sets the entry in ``mat`` in row `i` and column `j` to ``x``. + + void fq_default_mat_entry_set_fmpz(fq_default_mat_t mat, long i, long j, const fmpz_t x, const fq_default_ctx_t ctx) + # Sets the entry in ``mat`` in row `i` and column `j` to ``x``. + + long fq_default_mat_nrows(const fq_default_mat_t mat, const fq_default_ctx_t ctx) + # Returns the number of rows in ``mat``. + + long fq_default_mat_ncols(const fq_default_mat_t mat, const fq_default_ctx_t ctx) + # Returns the number of columns in ``mat``. + + void fq_default_mat_swap(fq_default_mat_t mat1, fq_default_mat_t mat2, const fq_default_ctx_t ctx) + # Swaps two matrices. The dimensions of ``mat1`` and ``mat2`` + # are allowed to be different. + + void fq_default_mat_zero(fq_default_mat_t mat, const fq_default_ctx_t ctx) + # Sets all entries of ``mat`` to 0. + + void fq_default_mat_one(fq_default_mat_t mat, const fq_default_ctx_t ctx) + # Sets the diagonal entries of ``mat`` to 1 and all other entries to 0. + + void fq_default_mat_swap_rows(fq_default_mat_t mat, long * perm, long r, long s, const fq_default_ctx_t ctx) + # Swaps rows ``r`` and ``s`` of ``mat``. If ``perm`` is non-``NULL``, the + # permutation of the rows will also be applied to ``perm``. + + void fq_default_mat_swap_cols(fq_default_mat_t mat, long * perm, long r, long s, const fq_default_ctx_t ctx) + # Swaps columns ``r`` and ``s`` of ``mat``. If ``perm`` is non-``NULL``, the + # permutation of the columns will also be applied to ``perm``. + + void fq_default_mat_invert_rows(fq_default_mat_t mat, long * perm, const fq_default_ctx_t ctx) + # Swaps rows ``i`` and ``r - i`` of ``mat`` for ``0 <= i < r/2``, where + # ``r`` is the number of rows of ``mat``. If ``perm`` is non-``NULL``, the + # permutation of the rows will also be applied to ``perm``. + + void fq_default_mat_invert_cols(fq_default_mat_t mat, long * perm, const fq_default_ctx_t ctx) + # Swaps columns ``i`` and ``c - i`` of ``mat`` for ``0 <= i < c/2``, where + # ``c`` is the number of columns of ``mat``. If ``perm`` is non-``NULL``, the + # permutation of the columns will also be applied to ``perm``. + + void fq_default_mat_set_nmod_mat(fq_default_mat_t mat1, const nmod_mat_t mat2, const fq_default_ctx_t ctx) + # Sets the matrix ``mat1`` to the matrix ``mat2``. + + void fq_default_mat_set_fmpz_mod_mat(fq_default_mat_t mat1, const fmpz_mod_mat_t mat2, const fq_default_ctx_t ctx) + # Sets the matrix ``mat1`` to the matrix ``mat2``. + + void fq_default_mat_set_fmpz_mat(fq_default_mat_t mat1, const fmpz_mat_t mat2, const fq_default_ctx_t ctx) + # Sets the matrix ``mat1`` to the matrix ``mat2``, reducing the entries + # modulo the characteristic of the finite field. + + void fq_default_mat_concat_vertical(fq_default_mat_t res, const fq_default_mat_t mat1, const fq_default_mat_t mat2, const fq_default_ctx_t ctx) + # Sets ``res`` to vertical concatenation of (``mat1``, ``mat2``) in that order. Matrix dimensions : ``mat1`` : `m \times n`, ``mat2`` : `k \times n`, ``res`` : `(m + k) \times n`. + + void fq_default_mat_concat_horizontal(fq_default_mat_t res, const fq_default_mat_t mat1, const fq_default_mat_t mat2, const fq_default_ctx_t ctx) + # Sets ``res`` to horizontal concatenation of (``mat1``, ``mat2``) in that order. Matrix dimensions : ``mat1`` : `m \times n`, ``mat2`` : `m \times k`, ``res`` : `m \times (n + k)`. + + int fq_default_mat_print_pretty(const fq_default_mat_t mat, const fq_default_ctx_t ctx) + # Pretty-prints ``mat`` to ``stdout``. A header is printed + # followed by the rows enclosed in brackets. + + int fq_default_mat_fprint_pretty(FILE * file, const fq_default_mat_t mat, const fq_default_ctx_t ctx) + # Pretty-prints ``mat`` to ``file``. A header is printed + # followed by the rows enclosed in brackets. + # In case of success, returns a positive value. In case of failure, + # returns a non-positive value. + + int fq_default_mat_print(const fq_default_mat_t mat, const fq_default_ctx_t ctx) + # Prints ``mat`` to ``stdout``. A header is printed followed + # by the rows enclosed in brackets. + + int fq_default_mat_fprint(FILE * file, const fq_default_mat_t mat, const fq_default_ctx_t ctx) + # Prints ``mat`` to ``file``. A header is printed followed by + # the rows enclosed in brackets. + # In case of success, returns a positive value. In case of failure, + # returns a non-positive value. + + void fq_default_mat_window_init(fq_default_mat_t window, const fq_default_mat_t mat, long r1, long c1, long r2, long c2, const fq_default_ctx_t ctx) + # Initializes the matrix ``window`` to be an ``r2 - r1`` by + # ``c2 - c1`` submatrix of ``mat`` whose ``(0,0)`` entry + # is the ``(r1, c1)`` entry of ``mat``. The memory for the + # elements of ``window`` is shared with ``mat``. + + void fq_default_mat_window_clear(fq_default_mat_t window, const fq_default_ctx_t ctx) + # Clears the matrix ``window`` and releases any memory that it + # uses. Note that the memory to the underlying matrix that + # ``window`` points to is not freed. + + void fq_default_mat_randtest(fq_default_mat_t mat, flint_rand_t state, const fq_default_ctx_t ctx) + # Sets the elements of ``mat`` to random elements of + # `\mathbf{F}_{q}`, given by ``ctx``. + + int fq_default_mat_randpermdiag(fq_mat_t mat, flint_rand_t state, fq_struct * diag, long n, const fq_ctx_t ctx) + # Sets ``mat`` to a random permutation of the diagonal matrix + # with `n` leading entries given by the vector ``diag``. It is + # assumed that the main diagonal of ``mat`` has room for at + # least `n` entries. + # Returns `0` or `1`, depending on whether the permutation is even + # or odd respectively. + + void fq_default_mat_randrank(fq_default_mat_t mat, flint_rand_t state, long rank, const fq_default_ctx_t ctx) + # Sets ``mat`` to a random sparse matrix with the given rank, + # having exactly as many non-zero elements as the rank, with the + # non-zero elements being uniformly random elements of + # `\mathbf{F}_{q}`. + # The matrix can be transformed into a dense matrix with unchanged + # rank by subsequently calling :func:`fq_default_mat_randops`. + + void fq_default_mat_randops(fq_default_mat_t mat, long count, flint_rand_t state, const fq_default_ctx_t ctx) + # Randomises ``mat`` by performing elementary row or column + # operations. More precisely, at most ``count`` random additions + # or subtractions of distinct rows and columns will be performed. + # This leaves the rank (and for square matrices, determinant) + # unchanged. + + void fq_default_mat_randtril(fq_default_mat_t mat, flint_rand_t state, int unit, const fq_default_ctx_t ctx) + # Sets ``mat`` to a random lower triangular matrix. If + # ``unit`` is 1, it will have ones on the main diagonal, + # otherwise it will have random nonzero entries on the main + # diagonal. + + void fq_default_mat_randtriu(fq_default_mat_t mat, flint_rand_t state, int unit, const fq_default_ctx_t ctx) + # Sets ``mat`` to a random upper triangular matrix. If + # ``unit`` is 1, it will have ones on the main diagonal, + # otherwise it will have random nonzero entries on the main + # diagonal. + + int fq_default_mat_equal(const fq_default_mat_t mat1, const fq_default_mat_t mat2, const fq_default_ctx_t ctx) + # Returns nonzero if mat1 and mat2 have the same dimensions and elements, + # and zero otherwise. + + int fq_default_mat_is_zero(const fq_default_mat_t mat, const fq_default_ctx_t ctx) + # Returns a non-zero value if all entries of ``mat`` are zero, and + # otherwise returns zero. + + int fq_default_mat_is_one(const fq_default_mat_t mat, const fq_default_ctx_t ctx) + # Returns a non-zero value if all diagonal entries of ``mat`` are one and + # all other entries are zero, and otherwise returns zero. + + int fq_default_mat_is_empty(const fq_default_mat_t mat, const fq_default_ctx_t ctx) + # Returns a non-zero value if the number of rows or the number of + # columns in ``mat`` is zero, and otherwise returns zero. + + int fq_default_mat_is_square(const fq_default_mat_t mat, const fq_default_ctx_t ctx) + # Returns a non-zero value if the number of rows is equal to the + # number of columns in ``mat``, and otherwise returns zero. + + void fq_default_mat_add(fq_default_mat_t C, const fq_default_mat_t A, const fq_default_mat_t B, const fq_default_ctx_t ctx) + # Computes `C = A + B`. Dimensions must be identical. + + void fq_default_mat_sub(fq_default_mat_t C, const fq_default_mat_t A, const fq_default_mat_t B, const fq_default_ctx_t ctx) + # Computes `C = A - B`. Dimensions must be identical. + + void fq_default_mat_neg(fq_default_mat_t A, const fq_default_mat_t B, const fq_default_ctx_t ctx) + # Sets `B = -A`. Dimensions must be identical. + + void fq_default_mat_mul(fq_default_mat_t C, const fq_default_mat_t A, const fq_default_mat_t B, const fq_default_ctx_t ctx) + # Sets `C = AB`. Dimensions must be compatible for matrix + # multiplication. Aliasing is allowed. This function automatically chooses + # between classical and KS multiplication. + + void fq_default_mat_submul(fq_default_mat_t D, const fq_default_mat_t C, const fq_default_mat_t A, const fq_default_mat_t B, const fq_default_ctx_t ctx) + # Sets `D = C + AB`. `C` and `D` may be aliased with each other but + # not with `A` or `B`. + + int fq_default_mat_inv(fq_default_mat_t B, fq_default_mat_t A, const fq_default_ctx_t ctx) + # Sets `B = A^{-1}` and returns `1` if `A` is invertible. If `A` is singular, + # returns `0` and sets the elements of `B` to undefined values. + # `A` and `B` must be square matrices with the same dimensions. + + long fq_default_mat_lu(long * P, fq_default_mat_t A, int rank_check, const fq_default_ctx_t ctx) + # Computes a generalised LU decomposition `LU = PA` of a given + # matrix `A`, returning the rank of `A`. + # If `A` is a nonsingular square matrix, it will be overwritten with + # a unit diagonal lower triangular matrix `L` and an upper + # triangular matrix `U` (the diagonal of `L` will not be stored + # explicitly). + # If `A` is an arbitrary matrix of rank `r`, `U` will be in row + # echelon form having `r` nonzero rows, and `L` will be lower + # triangular but truncated to `r` columns, having implicit ones on + # the `r` first entries of the main diagonal. All other entries will + # be zero. + # If a nonzero value for ``rank_check`` is passed, the function + # will abandon the output matrix in an undefined state and return 0 + # if `A` is detected to be rank-deficient. + # This function calls ``fq_default_mat_lu_recursive``. + + long fq_default_mat_rref(fq_default_mat_t A, const fq_default_ctx_t ctx) + # Puts `A` in reduced row echelon form and returns the rank of `A`. + # The rref is computed by first obtaining an unreduced row echelon + # form via LU decomposition and then solving an additional + # triangular system. + + void fq_default_mat_solve_tril(fq_default_mat_t X, const fq_default_mat_t L, const fq_default_mat_t B, int unit, const fq_default_ctx_t ctx) + # Sets `X = L^{-1} B` where `L` is a full rank lower triangular + # square matrix. If ``unit`` = 1, `L` is assumed to have ones on + # its main diagonal, and the main diagonal will not be read. `X` + # and `B` are allowed to be the same matrix, but no other aliasing + # is allowed. Automatically chooses between the classical and + # recursive algorithms. + + void fq_default_mat_solve_triu(fq_default_mat_t X, const fq_default_mat_t U, const fq_default_mat_t B, int unit, const fq_default_ctx_t ctx) + # Sets `X = U^{-1} B` where `U` is a full rank upper triangular + # square matrix. If ``unit`` = 1, `U` is assumed to have ones on + # its main diagonal, and the main diagonal will not be read. `X` + # and `B` are allowed to be the same matrix, but no other aliasing + # is allowed. Automatically chooses between the classical and + # recursive algorithms. + + int fq_default_mat_solve(fq_default_mat_t X, const fq_default_mat_t A, const fq_default_mat_t B, const fq_default_ctx_t ctx) + # Solves the matrix-matrix equation `AX = B`. + # Returns `1` if `A` has full rank; otherwise returns `0` and sets the + # elements of `X` to undefined values. + # The matrix `A` must be square. + + int fq_default_mat_can_solve(fq_default_mat_t X, const fq_default_mat_t A, const fq_default_mat_t B, const fq_default_ctx_t ctx) + # Solves the matrix-matrix equation `AX = B` over `Fq`. + # Returns `1` if a solution exists; otherwise returns `0` and sets the + # elements of `X` to zero. If more than one solution exists, one of the + # valid solutions is given. + # There are no restrictions on the shape of `A` and it may be singular. + + void fq_default_mat_similarity(fq_default_mat_t M, long r, fq_default_t d, const fq_default_ctx_t ctx) + # Applies a similarity transform to the `n\times n` matrix `M` in-place. + # If `P` is the `n\times n` identity matrix the zero entries of whose row + # `r` (`0`-indexed) have been replaced by `d`, this transform is equivalent + # to `M = P^{-1}MP`. + # Similarity transforms preserve the determinant, characteristic polynomial + # and minimal polynomial. + # The value `d` is required to be reduced modulo the modulus of the entries + # in the matrix. + + void fq_default_mat_charpoly(fq_default_poly_t p, const fq_default_mat_t M, const fq_default_ctx_t ctx) + # Compute the characteristic polynomial `p` of the matrix `M`. The matrix + # is required to be square, otherwise an exception is raised. + + void fq_default_mat_minpoly(fq_default_poly_t p, const fq_default_mat_t M, const fq_default_ctx_t ctx) + # Compute the minimal polynomial `p` of the matrix `M`. The matrix + # is required to be square, otherwise an exception is raised. diff --git a/src/sage/libs/flint/fq_default_poly.pxd b/src/sage/libs/flint/fq_default_poly.pxd new file mode 100644 index 00000000000..a5950a6df14 --- /dev/null +++ b/src/sage/libs/flint/fq_default_poly.pxd @@ -0,0 +1,358 @@ +# distutils: libraries = flint +# distutils: depends = flint/fq_default_poly.h + +################################################################################ +# This file is auto-generated. Do not modify by hand +################################################################################ + +from libc.stdio cimport FILE +from sage.libs.gmp.types cimport * +from sage.libs.mpfr.types cimport * +from sage.libs.flint.types cimport * + +cdef extern from "flint_wrap.h": + + void fq_default_poly_init(fq_default_poly_t poly, const fq_default_ctx_t ctx) + # Initialises ``poly`` for use, with context ctx, and setting its + # length to zero. A corresponding call to :func:`fq_default_poly_clear` + # must be made after finishing with the ``fq_default_poly_t`` to free the + # memory used by the polynomial. + + void fq_default_poly_init2(fq_default_poly_t poly, long alloc, const fq_default_ctx_t ctx) + # Initialises ``poly`` with space for at least ``alloc`` + # coefficients and sets the length to zero. The allocated + # coefficients are all set to zero. A corresponding call to + # :func:`fq_default_poly_clear` must be made after finishing with the + # ``fq_default_poly_t`` to free the memory used by the polynomial. + + void fq_default_poly_realloc(fq_default_poly_t poly, long alloc, const fq_default_ctx_t ctx) + # Reallocates the given polynomial to have space for ``alloc`` + # coefficients. If ``alloc`` is zero the polynomial is cleared + # and then reinitialised. If the current length is greater than + # ``alloc`` the polynomial is first truncated to length + # ``alloc``. + + void fq_default_poly_fit_length(fq_default_poly_t poly, long len, const fq_default_ctx_t ctx) + # If ``len`` is greater than the number of coefficients currently + # allocated, then the polynomial is reallocated to have space for at + # least ``len`` coefficients. No data is lost when calling this + # function. + # The function efficiently deals with the case where + # ``fit_length`` is called many times in small increments by at + # least doubling the number of allocated coefficients when length is + # larger than the number of coefficients currently allocated. + + void fq_default_poly_clear(fq_default_poly_t poly, const fq_default_ctx_t ctx) + # Clears the given polynomial, releasing any memory used. It must + # be reinitialised in order to be used again. + + void _fq_default_poly_set_length(fq_default_poly_t poly, long len, const fq_default_ctx_t ctx) + # Set the length of ``poly`` to ``len``. + + void fq_default_poly_truncate(fq_default_poly_t poly, long newlen, const fq_default_ctx_t ctx) + # Truncates the polynomial to length at most `n`. + + void fq_default_poly_set_trunc(fq_default_poly_t poly1, fq_default_poly_t poly2, long newlen, const fq_default_ctx_t ctx) + # Sets ``poly1`` to ``poly2`` truncated to length `n`. + + void fq_default_poly_reverse(fq_default_poly_t output, const fq_default_poly_t input, long m, const fq_default_ctx_t ctx) + # Sets ``output`` to the reverse of ``input``, thinking of it + # as a polynomial of length ``m``, notionally zero-padded if + # necessary). The length ``m`` must be non-negative, but there + # are no other restrictions. The output polynomial will be set to + # length ``m`` and then normalised. + + long fq_default_poly_degree(const fq_default_poly_t poly, const fq_default_ctx_t ctx) + # Returns the degree of the polynomial ``poly``. + + long fq_default_poly_length(const fq_default_poly_t poly, const fq_default_ctx_t ctx) + # Returns the length of the polynomial ``poly``. + + void fq_default_poly_randtest(fq_default_poly_t f, flint_rand_t state, long len, const fq_default_ctx_t ctx) + # Sets `f` to a random polynomial of length at most ``len`` + # with entries in the field described by ``ctx``. + + void fq_default_poly_randtest_not_zero(fq_default_poly_t f, flint_rand_t state, long len, const fq_default_ctx_t ctx) + # Same as ``fq_default_poly_randtest`` but guarantees that the polynomial + # is not zero. + + void fq_default_poly_randtest_monic(fq_default_poly_t f, flint_rand_t state, long len, const fq_default_ctx_t ctx) + # Sets `f` to a random monic polynomial of length ``len`` with + # entries in the field described by ``ctx``. + + void fq_default_poly_randtest_irreducible(fq_default_poly_t f, flint_rand_t state, long len, const fq_default_ctx_t ctx) + # Sets `f` to a random monic, irreducible polynomial of length + # ``len`` with entries in the field described by ``ctx``. + + void fq_default_poly_set(fq_default_poly_t poly1, const fq_default_poly_t poly2, const fq_default_ctx_t ctx) + # Sets the polynomial ``poly1`` to the polynomial ``poly2``. + + void fq_default_poly_set_fq_default(fq_default_poly_t poly, const fq_default_t c, const fq_default_ctx_t ctx) + # Sets the polynomial ``poly`` to ``c``. + + void fq_default_poly_swap(fq_default_poly_t op1, fq_default_poly_t op2, const fq_default_ctx_t ctx) + # Swaps the two polynomials ``op1`` and ``op2``. + + void fq_default_poly_zero(fq_default_poly_t poly, const fq_default_ctx_t ctx) + # Sets ``poly`` to the zero polynomial. + + void fq_default_poly_one(fq_default_poly_t poly, const fq_default_ctx_t ctx) + # Sets ``poly`` to the constant polynomial `1`. + + void fq_default_poly_gen(fq_default_poly_t poly, const fq_default_ctx_t ctx) + # Sets ``poly`` to the polynomial `x`. + + void fq_default_poly_make_monic(fq_default_poly_t rop, const fq_default_poly_t op, const fq_default_ctx_t ctx) + # Sets ``rop`` to ``op``, normed to have leading coefficient 1. + + void fq_default_poly_set_nmod_poly(fq_default_poly_t rop, const nmod_poly_t op, const fq_default_ctx_t ctx) + # Sets the polynomial ``rop`` to the polynomial ``op``. + + void fq_default_poly_set_fmpz_mod_poly(fq_default_poly_t rop, const fmpz_mod_poly_t op, const fq_default_ctx_t ctx) + # Sets the polynomial ``rop`` to the polynomial ``op``. + + void fq_default_poly_set_fmpz_poly(fq_default_poly_t rop, const fmpz_poly_t op, const fq_default_ctx_t ctx) + # Sets the polynomial ``rop`` to the polynomial ``op``. + + void fq_default_poly_get_coeff(fq_default_t x, const fq_default_poly_t poly, long n, const fq_default_ctx_t ctx) + # Sets `x` to the coefficient of `X^n` in ``poly``. + + void fq_default_poly_set_coeff(fq_default_poly_t poly, long n, const fq_default_t x, const fq_default_ctx_t ctx) + # Sets the coefficient of `X^n` in ``poly`` to `x`. + + void fq_default_poly_set_coeff_fmpz(fq_default_poly_t poly, long n, const fmpz_t x, const fq_default_ctx_t ctx) + # Sets the coefficient of `X^n` in the polynomial to `x`, + # assuming `n \geq 0`. + + int fq_default_poly_equal(const fq_default_poly_t poly1, const fq_default_poly_t poly2, const fq_default_ctx_t ctx) + # Returns nonzero if the two polynomials ``poly1`` and ``poly2`` + # are equal, otherwise returns zero. + + int fq_default_poly_equal_trunc(const fq_default_poly_t poly1, const fq_default_poly_t poly2, long n, const fq_default_ctx_t ctx) + # Notionally truncate ``poly1`` and ``poly2`` to length `n` and + # return nonzero if they are equal, otherwise return zero. + + int fq_default_poly_is_zero(const fq_default_poly_t poly, const fq_default_ctx_t ctx) + # Returns whether the polynomial ``poly`` is the zero polynomial. + + int fq_default_poly_is_one(const fq_default_poly_t op, const fq_default_ctx_t ctx) + # Returns whether the polynomial ``poly`` is equal + # to the constant polynomial `1`. + + int fq_default_poly_is_gen(const fq_default_poly_t op, const fq_default_ctx_t ctx) + # Returns whether the polynomial ``poly`` is equal + # to the polynomial `x`. + + int fq_default_poly_is_unit(const fq_default_poly_t op, const fq_default_ctx_t ctx) + # Returns whether the polynomial ``poly`` is a unit in the polynomial + # ring `\mathbf{F}_q[X]`, i.e. if it has degree `0` and is non-zero. + + int fq_default_poly_equal_fq_default(const fq_default_poly_t poly, const fq_default_t c, const fq_default_ctx_t ctx) + # Returns whether the polynomial ``poly`` is equal the (constant) + # `\mathbf{F}_q` element ``c`` + + void fq_default_poly_add(fq_default_poly_t res, const fq_default_poly_t poly1, const fq_default_poly_t poly2, const fq_default_ctx_t ctx) + # Sets ``res`` to the sum of ``poly1`` and ``poly2``. + + void fq_default_poly_add_si(fq_default_poly_t res, const fq_default_poly_t poly1, long c, const fq_default_ctx_t ctx) + # Sets ``res`` to the sum of ``poly1`` and ``c``. + + void fq_default_poly_add_series(fq_default_poly_t res, const fq_default_poly_t poly1, const fq_default_poly_t poly2, long n, const fq_default_ctx_t ctx) + # Notionally truncate ``poly1`` and ``poly2`` to length ``n`` and set + # ``res`` to the sum. + + void fq_default_poly_sub(fq_default_poly_t res, const fq_default_poly_t poly1, const fq_default_poly_t poly2, const fq_default_ctx_t ctx) + # Sets ``res`` to the difference of ``poly1`` and ``poly2``. + + void fq_default_poly_sub_series(fq_default_poly_t res, const fq_default_poly_t poly1, const fq_default_poly_t poly2, long n, const fq_default_ctx_t ctx) + # Notionally truncate ``poly1`` and ``poly2`` to length ``n`` and set + # ``res`` to the difference. + + void fq_default_poly_neg(fq_default_poly_t res, const fq_default_poly_t poly, const fq_default_ctx_t ctx) + # Sets ``res`` to the additive inverse of ``poly``. + + void fq_default_poly_scalar_mul_fq_default(fq_default_poly_t rop, const fq_default_poly_t op, const fq_default_t x, const fq_default_ctx_t ctx) + # Sets ``rop`` to the product of ``op`` by the scalar ``x``, in the context + # defined by ``ctx``. + + void fq_default_poly_scalar_addmul_fq_default(fq_default_poly_t rop, const fq_default_poly_t op, const fq_default_t x, const fq_default_ctx_t ctx) + # Adds to ``rop`` the product of ``op`` by the + # scalar ``x``, in the context defined by ``ctx``. + + void fq_default_poly_scalar_submul_fq_default(fq_default_poly_t rop, const fq_default_poly_t op, const fq_default_t x, const fq_default_ctx_t ctx) + # Subtracts from ``rop`` the product of ``op`` by the + # scalar ``x``, in the context defined by ``ctx``. + + void fq_default_poly_scalar_div_fq_default(fq_default_poly_t rop, const fq_default_poly_t op, const fq_default_t x, const fq_default_ctx_t ctx) + # Sets ``rop`` to the quotient of ``op`` by the scalar ``x``, in the context + # defined by ``ctx``. An exception is raised if ``x`` is zero. + + void fq_default_poly_mul(fq_default_poly_t rop, const fq_default_poly_t op1, const fq_default_poly_t op2, const fq_default_ctx_t ctx) + # Sets ``rop`` to the product of ``op1`` and ``op2``, + # choosing an appropriate algorithm. + + void fq_default_poly_mullow(fq_default_poly_t rop, const fq_default_poly_t op1, const fq_default_poly_t op2, long n, const fq_default_ctx_t ctx) + # Sets ``rop`` to the lowest `n` coefficients of the product of + # ``op1`` and ``op2``. + + void fq_default_poly_mulhigh(fq_default_poly_t res, const fq_default_poly_t poly1, const fq_default_poly_t poly2, long start, const fq_default_ctx_t ctx) + # Computes the product of ``poly1`` and ``poly2`` and writes the + # coefficients from ``start`` onwards into the high coefficients of + # ``res``, the remaining coefficients being arbitrary but reduced. + + void fq_default_poly_mulmod(fq_default_poly_t res, const fq_default_poly_t poly1, const fq_default_poly_t poly2, const fq_default_poly_t f, const fq_default_ctx_t ctx) + # Sets ``res`` to the remainder of the product of ``poly1`` + # and ``poly2`` upon polynomial division by ``f``. + + void fq_default_poly_sqr(fq_default_poly_t rop, const fq_default_poly_t op, const fq_default_ctx_t ctx) + # Sets ``rop`` to the square of ``op``, + # choosing an appropriate algorithm. + + void fq_default_poly_pow(fq_default_poly_t rop, const fq_default_poly_t op, unsigned long e, const fq_default_ctx_t ctx) + # Computes ``rop = op^e``. If `e` is zero, returns one, + # so that in particular ``0^0 = 1``. + + void fq_default_poly_powmod_ui_binexp(fq_default_poly_t res, const fq_default_poly_t poly, unsigned long e, const fq_default_poly_t f, const fq_default_ctx_t ctx) + # Sets ``res`` to ``poly`` raised to the power ``e`` modulo + # ``f``, using binary exponentiation. We require ``e >= 0``. + + void fq_default_poly_powmod_fmpz_binexp(fq_default_poly_t res, const fq_default_poly_t poly, const fmpz_t e, const fq_default_poly_t f, const fq_default_ctx_t ctx) + # Sets ``res`` to ``poly`` raised to the power ``e`` modulo + # ``f``, using binary exponentiation. We require ``e >= 0``. + + void fq_default_poly_pow_trunc(fq_default_poly_t res, const fq_default_poly_t poly, unsigned long e, long trunc, const fq_default_ctx_t ctx) + # Sets ``res`` to the low ``trunc`` coefficients of ``poly`` + # to the power ``e``. This is equivalent to doing a powering + # followed by a truncation. + + void fq_default_poly_shift_left(fq_default_poly_t rop, const fq_default_poly_t op, long n, const fq_default_ctx_t ctx) + # Sets ``rop`` to ``op`` shifted left by `n` coeffs. Zero + # coefficients are inserted. + + void fq_default_poly_shift_right(fq_default_poly_t rop, const fq_default_poly_t op, long n, const fq_default_ctx_t ctx) + # Sets ``rop`` to ``op`` shifted right by `n` coefficients. + # If `n` is equal to or greater than the current length of + # ``op``, ``rop`` is set to the zero polynomial. + + long fq_default_poly_hamming_weight(const fq_default_poly_t op, const fq_default_ctx_t ctx) + # Returns the number of non-zero entries in the polynomial ``op``. + + void fq_default_poly_divrem(fq_default_poly_t Q, fq_default_poly_t R, const fq_default_poly_t A, const fq_default_poly_t B, const fq_default_ctx_t ctx) + # Computes `Q`, `R` such that `A = B Q + R` with + # `0 \leq \operatorname{len}(R) < \operatorname{len}(B)`. + # Assumes that the leading coefficient of `B` is invertible. This can + # be taken for granted the context is for a finite field, that is, when + # `p` is prime and `f(X)` is irreducible. + + void fq_default_poly_rem(fq_default_poly_t R, const fq_default_poly_t A, const fq_default_poly_t B, const fq_default_ctx_t ctx) + # Sets ``R`` to the remainder of the division of ``A`` by + # ``B`` in the context described by ``ctx``. + + void fq_default_poly_inv_series(fq_default_poly_t Qinv, const fq_default_poly_t Q, long n, const fq_default_ctx_t ctx) + # Given ``Q`` find ``Qinv`` such that ``Q * Qinv`` is + # ``1`` modulo `x^n`. The constant coefficient of ``Q`` must + # be invertible modulo the modulus of ``Q``. An exception is + # raised if this is not the case or if ``n = 0``. + + void fq_default_poly_div_series(fq_default_poly_t Q, const fq_default_poly_t A, const fq_default_poly_t B, long n, const fq_default_ctx_t ctx) + # Set `Q` to the quotient of the series `A` by `B`, thinking of the series as + # though they were of length `n`. We assume that the bottom coefficient of + # `B` is invertible. + + void fq_default_poly_gcd(fq_default_poly_t rop, const fq_default_poly_t op1, const fq_default_poly_t op2, const fq_default_ctx_t ctx) + # Sets ``rop`` to the greatest common divisor of ``op1`` and + # ``op2``, using the either the Euclidean or HGCD algorithm. The + # GCD of zero polynomials is defined to be zero, whereas the GCD of + # the zero polynomial and some other polynomial `P` is defined to be + # `P`. Except in the case where the GCD is zero, the GCD `G` is made + # monic. + + void fq_default_poly_xgcd(fq_default_poly_t G, fq_default_poly_t S, fq_default_poly_t T, const fq_default_poly_t A, const fq_default_poly_t B, const fq_default_ctx_t ctx) + # Computes the GCD of `A` and `B`. The GCD of zero polynomials is + # defined to be zero, whereas the GCD of the zero polynomial and some other + # polynomial `P` is defined to be `P`. Except in the case where + # the GCD is zero, the GCD `G` is made monic. + # Polynomials ``S`` and ``T`` are computed such that + # ``S*A + T*B = G``. The length of ``S`` will be at most + # ``lenB`` and the length of ``T`` will be at most ``lenA``. + + int fq_default_poly_divides(fq_default_poly_t Q, const fq_default_poly_t A, const fq_default_poly_t B, const fq_default_ctx_t ctx) + # Returns `1` if `B` divides `A` exactly and sets `Q` to the quotient, + # otherwise returns `0`. + # This function is currently unoptimised and provided for convenience + # only. + + void fq_default_poly_derivative(fq_default_poly_t rop, const fq_default_poly_t op, const fq_default_ctx_t ctx) + # Sets ``rop`` to the derivative of ``op``. + + void fq_default_poly_invsqrt_series(fq_default_poly_t g, const fq_default_poly_t h, long n, fq_default_ctx_t ctx) + # Set `g` to the series expansion of `1/\sqrt{h}` to order `O(x^n)`. + # It is assumed that `h` has constant term 1. + + void fq_default_poly_sqrt_series(fq_default_poly_t g, const fq_default_poly_t h, long n, fq_default_ctx_t ctx) + # Set `g` to the series expansion of `\sqrt{h}` to order `O(x^n)`. + # It is assumed that `h` has constant term 1. + + int fq_default_poly_sqrt(fq_default_poly_t s, const fq_default_poly_t p, fq_default_ctx_t mod) + # If `p` is a perfect square, sets `s` to a square root of `p` + # and returns 1. Otherwise returns 0. + + void fq_default_poly_evaluate_fq_default(fq_default_t rop, const fq_default_poly_t f, const fq_default_t a, const fq_default_ctx_t ctx) + # Sets ``rop`` to the value of `f(a)`. + # As the coefficient ring `\mathbf{F}_q` is finite, Horner's method + # is sufficient. + + void fq_default_poly_compose(fq_default_poly_t rop, const fq_default_poly_t op1, const fq_default_poly_t op2, const fq_default_ctx_t ctx) + # Sets ``rop`` to the composition of ``op1`` and ``op2``. + # To be precise about the order of composition, denoting ``rop``, + # ``op1``, and ``op2`` by `f`, `g`, and `h`, respectively, + # sets `f(t) = g(h(t))`. + + void fq_default_poly_compose_mod(fq_default_poly_t res, const fq_default_poly_t f, const fq_default_poly_t g, const fq_default_poly_t h, const fq_default_ctx_t ctx) + # Sets ``res`` to the composition `f(g)` modulo `h`. We require + # that `h` is nonzero. + + int fq_default_poly_fprint_pretty(FILE * file, const fq_default_poly_t poly, const char *x, const fq_default_ctx_t ctx) + # Prints the pretty representation of ``poly`` to the stream + # ``file``, using the string ``x`` to represent the indeterminate. + # In case of success, returns a positive value. In case of failure, + # returns a non-positive value. + + int fq_default_poly_print_pretty(const fq_default_poly_t poly, const char *x, const fq_default_ctx_t ctx) + # Prints the pretty representation of ``poly`` to ``stdout``, + # using the string ``x`` to represent the indeterminate. + # In case of success, returns a positive value. In case of failure, + # returns a non-positive value. + + int fq_default_poly_fprint(FILE * file, const fq_default_poly_t poly, const fq_default_ctx_t ctx) + # Prints the pretty representation of ``poly`` to the stream + # ``file``. + # In case of success, returns a positive value. In case of failure, + # returns a non-positive value. + + int fq_default_poly_print(const fq_default_poly_t poly, const fq_default_ctx_t ctx) + # Prints the representation of ``poly`` to ``stdout``. + # In case of success, returns a positive value. In case of failure, + # returns a non-positive value. + + char * fq_default_poly_get_str(const fq_default_poly_t poly, const fq_default_ctx_t ctx) + # Returns the plain FLINT string representation of the polynomial + # ``poly``. + + char * fq_default_poly_get_str_pretty(const fq_default_poly_t poly, const char * x, const fq_default_ctx_t ctx) + # Returns a pretty representation of the polynomial ``poly`` using the + # null-terminated string ``x`` as the variable name + + void fq_default_poly_inflate(fq_default_poly_t result, const fq_default_poly_t input, unsigned long inflation, const fq_default_ctx_t ctx) + # Sets ``result`` to the inflated polynomial `p(x^n)` where + # `p` is given by ``input`` and `n` is given by ``inflation``. + + void fq_default_poly_deflate(fq_default_poly_t result, const fq_default_poly_t input, unsigned long deflation, const fq_default_ctx_t ctx) + # Sets ``result`` to the deflated polynomial `p(x^{1/n})` where + # `p` is given by ``input`` and `n` is given by ``deflation``. + # Requires `n > 0`. + + unsigned long fq_default_poly_deflation(const fq_default_poly_t input, const fq_default_ctx_t ctx) + # Returns the largest integer by which ``input`` can be deflated. + # As special cases, returns 0 if ``input`` is the zero polynomial + # and 1 of ``input`` is a constant polynomial. diff --git a/src/sage/libs/flint/fq_default_poly_factor.pxd b/src/sage/libs/flint/fq_default_poly_factor.pxd new file mode 100644 index 00000000000..1d9acc1c491 --- /dev/null +++ b/src/sage/libs/flint/fq_default_poly_factor.pxd @@ -0,0 +1,110 @@ +# distutils: libraries = flint +# distutils: depends = flint/fq_default_poly_factor.h + +################################################################################ +# This file is auto-generated. Do not modify by hand +################################################################################ + +from libc.stdio cimport FILE +from sage.libs.gmp.types cimport * +from sage.libs.mpfr.types cimport * +from sage.libs.flint.types cimport * + +cdef extern from "flint_wrap.h": + + void fq_default_poly_factor_init(fq_default_poly_factor_t fac, const fq_default_ctx_t ctx) + # Initialises ``fac`` for use. An :type:`fq_default_poly_factor_t` + # represents a polynomial in factorised form as a product of + # polynomials with associated exponents. + + void fq_default_poly_factor_clear(fq_default_poly_factor_t fac, const fq_default_ctx_t ctx) + # Frees all memory associated with ``fac``. + + void fq_default_poly_factor_realloc(fq_default_poly_factor_t fac, long alloc, const fq_default_ctx_t ctx) + # Reallocates the factor structure to provide space for + # precisely ``alloc`` factors. + + void fq_default_poly_factor_fit_length(fq_default_poly_factor_t fac, long len, const fq_default_ctx_t ctx) + # Ensures that the factor structure has space for at least + # ``len`` factors. This function takes care of the case of + # repeated calls by always at least doubling the number of factors + # the structure can hold. + + void fq_default_poly_factor_set(fq_default_poly_factor_t res, const fq_default_poly_factor_t fac, const fq_default_ctx_t ctx) + # Sets ``res`` to the same factorisation as ``fac``. + + void fq_default_poly_factor_print_pretty(const fq_default_poly_factor_t fac, const char * var, const fq_default_ctx_t ctx) + # Pretty-prints the entries of ``fac`` to standard output. + + void fq_default_poly_factor_print(const fq_default_poly_factor_t fac, const fq_default_ctx_t ctx) + # Prints the entries of ``fac`` to standard output. + + void fq_default_poly_factor_insert(fq_default_poly_factor_t fac, const fq_default_poly_t poly, long exp, const fq_default_ctx_t ctx) + # Inserts the factor ``poly`` with multiplicity ``exp`` into + # the factorisation ``fac``. + # If ``fac`` already contains ``poly``, then ``exp`` simply + # gets added to the exponent of the existing entry. + + void fq_default_poly_factor_concat(fq_default_poly_factor_t res, const fq_default_poly_factor_t fac, const fq_default_ctx_t ctx) + # Concatenates two factorisations. + # This is equivalent to calling :func:`fq_default_poly_factor_insert` + # repeatedly with the individual factors of ``fac``. + # Does not support aliasing between ``res`` and ``fac``. + + void fq_default_poly_factor_pow(fq_default_poly_factor_t fac, long exp, const fq_default_ctx_t ctx) + # Raises ``fac`` to the power ``exp``. + + unsigned long fq_default_poly_remove(fq_default_poly_t f, const fq_default_poly_t p, const fq_default_ctx_t ctx) + # Removes the highest possible power of ``p`` from ``f`` and + # returns the exponent. + + long fq_default_poly_factor_length(fq_default_poly_factor_t fac, const fq_default_ctx_t ctx) + # Return the number of factors, not including the unit. + + void fq_default_poly_factor_get_poly(fq_default_poly_t poly, const fq_default_poly_factor_t fac, long i, const fq_default_ctx_t ctx) + # Set ``poly`` to factor ``i`` of ``fac`` (numbering starts at zero). + + long fq_default_poly_factor_exp(fq_default_poly_factor_t fac, long i, const fq_default_ctx_t ctx) + # Return the exponent of factor ``i`` of ``fac``. + + int fq_default_poly_is_irreducible(const fq_default_poly_t f, const fq_default_ctx_t ctx) + # Returns 1 if the polynomial ``f`` is irreducible, otherwise returns 0. + + int fq_default_poly_is_squarefree(const fq_default_poly_t f, const fq_default_ctx_t ctx) + # Returns 1 if ``f`` is squarefree, and 0 otherwise. As a special + # case, the zero polynomial is not considered squarefree. + + void fq_default_poly_factor_equal_deg(fq_default_poly_factor_t factors, const fq_default_poly_t pol, long d, const fq_default_ctx_t ctx) + # Assuming ``pol`` is a product of irreducible factors all of + # degree ``d``, finds all those factors and places them in + # factors. Requires that ``pol`` be monic, non-constant and + # squarefree. + + void fq_default_poly_factor_split_single(fq_default_poly_t linfactor, const fq_default_poly_t input, const fq_default_ctx_t ctx) + # Assuming ``input`` is a product of factors all of degree 1, finds a single + # linear factor of ``input`` and places it in ``linfactor``. + # Requires that ``input`` be monic and non-constant. + + void fq_default_poly_factor_distinct_deg(fq_default_poly_factor_t res, const fq_default_poly_t poly, long * const * degs, const fq_default_ctx_t ctx) + # Factorises a monic non-constant squarefree polynomial ``poly`` + # of degree `n` into factors `f[d]` such that for `1 \leq d \leq n` + # `f[d]` is the product of the monic irreducible factors of + # ``poly`` of degree `d`. Factors are stored in ``res``, + # associated powers of irreducible polynomials are stored in + # ``degs`` in the same order as factors. + # Requires that ``degs`` have enough space for irreducible polynomials' + # powers (maximum space required is ``n * sizeof(slong)``). + + void fq_default_poly_factor_squarefree(fq_default_poly_factor_t res, const fq_default_poly_t f, const fq_default_ctx_t ctx) + # Sets ``res`` to a squarefree factorization of ``f``. + + void fq_default_poly_factor(fq_default_poly_factor_t res, fq_default_t lead, const fq_default_poly_t f, const fq_default_ctx_t ctx) + # Factorises a non-constant polynomial ``f`` into monic + # irreducible factors choosing the best algorithm for given modulo + # and degree. The output ``lead`` is set to the leading coefficient of `f` + # upon return. Choice of algorithm is based on heuristic measurements. + + void fq_default_poly_roots(fq_default_poly_factor_t r, const fq_default_poly_t f, int with_multiplicity, const fq_default_ctx_t ctx) + # Fill `r` with factors of the form `x - r_i` where the `r_i` are the distinct roots of a nonzero `f` in `F_q`. + # If `with\_multiplicity` is zero, the exponent `e_i` of the factor `x - r_i` is `1`. Otherwise, it is the largest `e_i` such that `(x-r_i)^e_i` divides `f`. + # This function throws if `f` is zero, but is otherwise always successful. diff --git a/src/sage/libs/flint/fq_nmod_embed.pxd b/src/sage/libs/flint/fq_nmod_embed.pxd new file mode 100644 index 00000000000..331b7a2e9a0 --- /dev/null +++ b/src/sage/libs/flint/fq_nmod_embed.pxd @@ -0,0 +1,97 @@ +# distutils: libraries = flint +# distutils: depends = flint/fq_nmod_embed.h + +################################################################################ +# This file is auto-generated. Do not modify by hand +################################################################################ + +from libc.stdio cimport FILE +from sage.libs.gmp.types cimport * +from sage.libs.mpfr.types cimport * +from sage.libs.flint.types cimport * + +cdef extern from "flint_wrap.h": + + void fq_nmod_embed_gens(fq_nmod_t gen_sub, fq_nmod_t gen_sup, nmod_poly_t minpoly, const fq_nmod_ctx_t sub_ctx, const fq_nmod_ctx_t sup_ctx) + # Given two contexts ``sub_ctx`` and ``sup_ctx``, such that + # ``degree(sub_ctx)`` divides ``degree(sup_ctx)``, compute: + # * an element ``gen_sub`` in ``sub_ctx`` such that + # ``gen_sub`` generates the finite field defined by + # ``sub_ctx``, + # * its minimal polynomial ``minpoly``, + # * a root ``gen_sup`` of ``minpoly`` inside the field + # defined by ``sup_ctx``. + # These data uniquely define an embedding of ``sub_ctx`` into + # ``sup_ctx``. + + void _fq_nmod_embed_gens_naive(fq_nmod_t gen_sub, fq_nmod_t gen_sup, nmod_poly_t minpoly, const fq_nmod_ctx_t sub_ctx, const fq_nmod_ctx_t sup_ctx) + # Given two contexts ``sub_ctx`` and ``sup_ctx``, such that + # ``degree(sub_ctx)`` divides ``degree(sup_ctx)``, compute an + # embedding of ``sub_ctx`` into ``sup_ctx`` defined as follows: + # * ``gen_sub`` is the canonical generator of ``sup_ctx`` + # (i.e., the class of `X`), + # * ``minpoly`` is the defining polynomial of ``sub_ctx``, + # * ``gen_sup`` is a root of ``minpoly`` inside the field + # defined by ``sup_ctx``. + + void fq_nmod_embed_matrices(nmod_mat_t embed, nmod_mat_t project, const fq_nmod_t gen_sub, const fq_nmod_ctx_t sub_ctx, const fq_nmod_t gen_sup, const fq_nmod_ctx_t sup_ctx, const nmod_poly_t gen_minpoly) + # Given: + # * two contexts ``sub_ctx`` and ``sup_ctx``, of + # respective degrees `m` and `n`, such that `m` divides `n`; + # * a generator ``gen_sub`` of ``sub_ctx``, its minimal + # polynomial ``gen_minpoly``, and a root ``gen_sup`` of + # ``gen_minpoly`` in ``sup_ctx``, as returned by + # ``fq_nmod_embed_gens``; + # Compute: + # * the `n\times m` matrix ``embed`` mapping ``gen_sub`` + # to ``gen_sup``, and all their powers accordingly; + # * an `m\times n` matrix ``project`` such that + # ``project`` `\times` ``embed`` is the `m\times m` identity + # matrix. + + void fq_nmod_embed_trace_matrix(nmod_mat_t res, const nmod_mat_t basis, const fq_nmod_ctx_t sub_ctx, const fq_nmod_ctx_t sup_ctx) + # Given: + # * two contexts ``sub_ctx`` and ``sup_ctx``, of degrees + # `m` and `n`, such that `m` divides `n`; + # * an `n\times m` matrix ``basis`` that maps ``sub_ctx`` + # to an isomorphic subfield in ``sup_ctx``; + # Compute the `m\times n` matrix of the trace from ``sup_ctx`` to + # ``sub_ctx``. + # This matrix is computed as + # ``embed_dual_to_mono_matrix(_, sub_ctx)`` + # `\times` ``basis``:sup:`t` `\times` + # ``embed_mono_to_dual_matrix(_, sup_ctx)}``. + # **Note:** if + # `m=n`, ``basis`` represents a Frobenius, and the result is its + # inverse matrix. + + void fq_nmod_embed_composition_matrix(nmod_mat_t matrix, const fq_nmod_t gen, const fq_nmod_ctx_t ctx) + # Compute the *composition matrix* of ``gen``. + # For an element `a\in\mathbf{F}_{p^n}`, its composition matrix is the + # matrix whose columns are `a^0, a^1, \ldots, a^{n-1}`. + + void fq_nmod_embed_composition_matrix_sub(nmod_mat_t matrix, const fq_nmod_t gen, const fq_nmod_ctx_t ctx, long trunc) + # Compute the *composition matrix* of ``gen``, truncated to + # ``trunc`` columns. + + void fq_nmod_embed_mul_matrix(nmod_mat_t matrix, const fq_nmod_t gen, const fq_nmod_ctx_t ctx) + # Compute the *multiplication matrix* of ``gen``. + # For an element `a` in `\mathbf{F}_{p^n}=\mathbf{F}_p[x]`, its + # multiplication matrix is the matrix whose columns are `a, ax, + # \dots, ax^{n-1}`. + + void fq_nmod_embed_mono_to_dual_matrix(nmod_mat_t res, const fq_nmod_ctx_t ctx) + # Compute the change of basis matrix from the monomial basis of + # ``ctx`` to its dual basis. + + void fq_nmod_embed_dual_to_mono_matrix(nmod_mat_t res, const fq_nmod_ctx_t ctx) + # Compute the change of basis matrix from the dual basis of + # ``ctx`` to its monomial basis. + + void fq_nmod_modulus_pow_series_inv(nmod_poly_t res, const fq_nmod_ctx_t ctx, long trunc) + # Compute the power series inverse of the reverse of the modulus of + # ``ctx`` up to `O(x^\texttt{trunc})`. + + void fq_nmod_modulus_derivative_inv(fq_nmod_t m_prime, fq_nmod_t m_prime_inv, const fq_nmod_ctx_t ctx) + # Compute the derivative ``m_prime`` of the modulus of ``ctx`` + # as an element of ``ctx``, and its inverse ``m_prime_inv``. diff --git a/src/sage/libs/flint/fq_nmod_mat.pxd b/src/sage/libs/flint/fq_nmod_mat.pxd new file mode 100644 index 00000000000..a127af92231 --- /dev/null +++ b/src/sage/libs/flint/fq_nmod_mat.pxd @@ -0,0 +1,366 @@ +# distutils: libraries = flint +# distutils: depends = flint/fq_nmod_mat.h + +################################################################################ +# This file is auto-generated. Do not modify by hand +################################################################################ + +from libc.stdio cimport FILE +from sage.libs.gmp.types cimport * +from sage.libs.mpfr.types cimport * +from sage.libs.flint.types cimport * + +cdef extern from "flint_wrap.h": + + void fq_nmod_mat_init(fq_nmod_mat_t mat, long rows, long cols, const fq_nmod_ctx_t ctx) + # Initialises ``mat`` to a ``rows``-by-``cols`` matrix with + # coefficients in `\mathbf{F}_{q}` given by ``ctx``. All elements + # are set to zero. + + void fq_nmod_mat_init_set(fq_nmod_mat_t mat, const fq_nmod_mat_t src, const fq_nmod_ctx_t ctx) + # Initialises ``mat`` and sets its dimensions and elements to + # those of ``src``. + + void fq_nmod_mat_clear(fq_nmod_mat_t mat, const fq_nmod_ctx_t ctx) + # Clears the matrix and releases any memory it used. The matrix + # cannot be used again until it is initialised. This function must be + # called exactly once when finished using an :type:`fq_nmod_mat_t` object. + + void fq_nmod_mat_set(fq_nmod_mat_t mat, const fq_nmod_mat_t src, const fq_nmod_ctx_t ctx) + # Sets ``mat`` to a copy of ``src``. It is assumed + # that ``mat`` and ``src`` have identical dimensions. + + fq_nmod_struct * fq_nmod_mat_entry(const fq_nmod_mat_t mat, long i, long j) + # Directly accesses the entry in ``mat`` in row `i` and column `j`, + # indexed from zero. No bounds checking is performed. + + void fq_nmod_mat_entry_set(fq_nmod_mat_t mat, long i, long j, const fq_nmod_t x, const fq_nmod_ctx_t ctx) + # Sets the entry in ``mat`` in row `i` and column `j` to ``x``. + + long fq_nmod_mat_nrows(const fq_nmod_mat_t mat, const fq_nmod_ctx_t ctx) + # Returns the number of rows in ``mat``. + + long fq_nmod_mat_ncols(const fq_nmod_mat_t mat, const fq_nmod_ctx_t ctx) + # Returns the number of columns in ``mat``. + + void fq_nmod_mat_swap(fq_nmod_mat_t mat1, fq_nmod_mat_t mat2, const fq_nmod_ctx_t ctx) + # Swaps two matrices. The dimensions of ``mat1`` and ``mat2`` + # are allowed to be different. + + void fq_nmod_mat_swap_entrywise(fq_nmod_mat_t mat1, fq_nmod_mat_t mat2, const fq_nmod_ctx_t ctx) + # Swaps two matrices by swapping the individual entries rather than swapping + # the contents of the structs. + + void fq_nmod_mat_zero(fq_nmod_mat_t mat, const fq_nmod_ctx_t ctx) + # Sets all entries of ``mat`` to 0. + + void fq_nmod_mat_one(fq_nmod_mat_t mat, const fq_nmod_ctx_t ctx) + # Sets all diagonal entries of ``mat`` to 1 and all other entries to 0. + + void fq_nmod_mat_swap_rows(fq_nmod_mat_t mat, long * perm, long r, long s, const fq_nmod_ctx_t ctx) + # Swaps rows ``r`` and ``s`` of ``mat``. If ``perm`` is non-``NULL``, the + # permutation of the rows will also be applied to ``perm``. + + void fq_nmod_mat_swap_cols(fq_nmod_mat_t mat, long * perm, long r, long s, const fq_nmod_ctx_t ctx) + # Swaps columns ``r`` and ``s`` of ``mat``. If ``perm`` is non-``NULL``, the + # permutation of the columns will also be applied to ``perm``. + + void fq_nmod_mat_invert_rows(fq_nmod_mat_t mat, long * perm, const fq_nmod_ctx_t ctx) + # Swaps rows ``i`` and ``r - i`` of ``mat`` for ``0 <= i < r/2``, where + # ``r`` is the number of rows of ``mat``. If ``perm`` is non-``NULL``, the + # permutation of the rows will also be applied to ``perm``. + + void fq_nmod_mat_invert_cols(fq_nmod_mat_t mat, long * perm, const fq_nmod_ctx_t ctx) + # Swaps columns ``i`` and ``c - i`` of ``mat`` for ``0 <= i < c/2``, where + # ``c`` is the number of columns of ``mat``. If ``perm`` is non-``NULL``, the + # permutation of the columns will also be applied to ``perm``. + + void fq_nmod_mat_set_nmod_mat(fq_nmod_mat_t mat1, const nmod_mat_t mat2, const fq_nmod_ctx_t ctx) + # Sets the matrix ``mat1`` to the matrix ``mat2``. + + void fq_nmod_mat_set_fmpz_mod_mat(fq_nmod_mat_t mat1, const fmpz_mod_mat_t mat2, const fq_nmod_ctx_t ctx) + # Sets the matrix ``mat1`` to the matrix ``mat2``. + + void fq_nmod_mat_concat_vertical(fq_nmod_mat_t res, const fq_nmod_mat_t mat1, const fq_nmod_mat_t mat2, const fq_nmod_ctx_t ctx) + # Sets ``res`` to vertical concatenation of (``mat1``, ``mat2``) in that order. Matrix dimensions : ``mat1`` : `m \times n`, ``mat2`` : `k \times n`, ``res`` : `(m + k) \times n`. + + void fq_nmod_mat_concat_horizontal(fq_nmod_mat_t res, const fq_nmod_mat_t mat1, const fq_nmod_mat_t mat2, const fq_nmod_ctx_t ctx) + # Sets ``res`` to horizontal concatenation of (``mat1``, ``mat2``) in that order. Matrix dimensions : ``mat1`` : `m \times n`, ``mat2`` : `m \times k`, ``res`` : `m \times (n + k)`. + + int fq_nmod_mat_print_pretty(const fq_nmod_mat_t mat, const fq_nmod_ctx_t ctx) + # Pretty-prints ``mat`` to ``stdout``. A header is printed + # followed by the rows enclosed in brackets. + + int fq_nmod_mat_fprint_pretty(FILE * file, const fq_nmod_mat_t mat, const fq_nmod_ctx_t ctx) + # Pretty-prints ``mat`` to ``file``. A header is printed + # followed by the rows enclosed in brackets. + # In case of success, returns a positive value. In case of failure, + # returns a non-positive value. + + int fq_nmod_mat_print(const fq_nmod_mat_t mat, const fq_nmod_ctx_t ctx) + # Prints ``mat`` to ``stdout``. A header is printed followed + # by the rows enclosed in brackets. + + int fq_nmod_mat_fprint(FILE * file, const fq_nmod_mat_t mat, const fq_nmod_ctx_t ctx) + # Prints ``mat`` to ``file``. A header is printed followed by + # the rows enclosed in brackets. + # In case of success, returns a positive value. In case of failure, + # returns a non-positive value. + + void fq_nmod_mat_window_init(fq_nmod_mat_t window, const fq_nmod_mat_t mat, long r1, long c1, long r2, long c2, const fq_nmod_ctx_t ctx) + # Initializes the matrix ``window`` to be an ``r2 - r1`` by + # ``c2 - c1`` submatrix of ``mat`` whose ``(0,0)`` entry + # is the ``(r1, c1)`` entry of ``mat``. The memory for the + # elements of ``window`` is shared with ``mat``. + + void fq_nmod_mat_window_clear(fq_nmod_mat_t window, const fq_nmod_ctx_t ctx) + # Clears the matrix ``window`` and releases any memory that it + # uses. Note that the memory to the underlying matrix that + # ``window`` points to is not freed. + + void fq_nmod_mat_randtest(fq_nmod_mat_t mat, flint_rand_t state, const fq_nmod_ctx_t ctx) + # Sets the elements of ``mat`` to random elements of + # `\mathbf{F}_{q}`, given by ``ctx``. + + int fq_nmod_mat_randpermdiag(fq_nmod_mat_t mat, flint_rand_t state, fq_nmod_struct * diag, long n, const fq_nmod_ctx_t ctx) + # Sets ``mat`` to a random permutation of the diagonal matrix + # with `n` leading entries given by the vector ``diag``. It is + # assumed that the main diagonal of ``mat`` has room for at + # least `n` entries. + # Returns `0` or `1`, depending on whether the permutation is even + # or odd respectively. + + void fq_nmod_mat_randrank(fq_nmod_mat_t mat, flint_rand_t state, long rank, const fq_nmod_ctx_t ctx) + # Sets ``mat`` to a random sparse matrix with the given rank, + # having exactly as many non-zero elements as the rank, with the + # non-zero elements being uniformly random elements of + # `\mathbf{F}_{q}`. + # The matrix can be transformed into a dense matrix with unchanged + # rank by subsequently calling :func:`fq_nmod_mat_randops`. + + void fq_nmod_mat_randops(fq_nmod_mat_t mat, long count, flint_rand_t state, const fq_nmod_ctx_t ctx) + # Randomises ``mat`` by performing elementary row or column + # operations. More precisely, at most ``count`` random additions + # or subtractions of distinct rows and columns will be performed. + # This leaves the rank (and for square matrices, determinant) + # unchanged. + + void fq_nmod_mat_randtril(fq_nmod_mat_t mat, flint_rand_t state, int unit, const fq_nmod_ctx_t ctx) + # Sets ``mat`` to a random lower triangular matrix. If + # ``unit`` is 1, it will have ones on the main diagonal, + # otherwise it will have random nonzero entries on the main + # diagonal. + + void fq_nmod_mat_randtriu(fq_nmod_mat_t mat, flint_rand_t state, int unit, const fq_nmod_ctx_t ctx) + # Sets ``mat`` to a random upper triangular matrix. If + # ``unit`` is 1, it will have ones on the main diagonal, + # otherwise it will have random nonzero entries on the main + # diagonal. + + int fq_nmod_mat_equal(const fq_nmod_mat_t mat1, const fq_nmod_mat_t mat2, const fq_nmod_ctx_t ctx) + # Returns nonzero if mat1 and mat2 have the same dimensions and elements, + # and zero otherwise. + + int fq_nmod_mat_is_zero(const fq_nmod_mat_t mat, const fq_nmod_ctx_t ctx) + # Returns a non-zero value if all entries ``mat`` are zero, and + # otherwise returns zero. + + int fq_nmod_mat_is_one(const fq_nmod_mat_t mat, const fq_nmod_ctx_t ctx) + # Returns a non-zero value if all entries ``mat`` are zero except the + # diagonal entries which must be one, otherwise returns zero. + + int fq_nmod_mat_is_empty(const fq_nmod_mat_t mat, const fq_nmod_ctx_t ctx) + # Returns a non-zero value if the number of rows or the number of + # columns in ``mat`` is zero, and otherwise returns zero. + + int fq_nmod_mat_is_square(const fq_nmod_mat_t mat, const fq_nmod_ctx_t ctx) + # Returns a non-zero value if the number of rows is equal to the + # number of columns in ``mat``, and otherwise returns zero. + + void fq_nmod_mat_add(fq_nmod_mat_t C, const fq_nmod_mat_t A, const fq_nmod_mat_t B, const fq_nmod_ctx_t ctx) + # Computes `C = A + B`. Dimensions must be identical. + + void fq_nmod_mat_sub(fq_nmod_mat_t C, const fq_nmod_mat_t A, const fq_nmod_mat_t B, const fq_nmod_ctx_t ctx) + # Computes `C = A - B`. Dimensions must be identical. + + void fq_nmod_mat_neg(fq_nmod_mat_t A, const fq_nmod_mat_t B, const fq_nmod_ctx_t ctx) + # Sets `B = -A`. Dimensions must be identical. + + void fq_nmod_mat_mul(fq_nmod_mat_t C, const fq_nmod_mat_t A, const fq_nmod_mat_t B, const fq_nmod_ctx_t ctx) + # Sets `C = AB`. Dimensions must be compatible for matrix + # multiplication. Aliasing is allowed. This function automatically chooses + # between classical and KS multiplication. + + void fq_nmod_mat_mul_classical(fq_nmod_mat_t C, const fq_nmod_mat_t A, const fq_nmod_mat_t B, const fq_nmod_ctx_t ctx) + # Sets `C = AB`. Dimensions must be compatible for matrix multiplication. + # `C` is not allowed to be aliased with `A` or `B`. Uses classical + # matrix multiplication. + + void fq_nmod_mat_mul_KS(fq_nmod_mat_t C, const fq_nmod_mat_t A, const fq_nmod_mat_t B, const fq_nmod_ctx_t ctx) + # Sets `C = AB`. Dimensions must be compatible for matrix + # multiplication. `C` is not allowed to be aliased with `A` or + # `B`. Uses Kronecker substitution to perform the multiplication + # over the integers. + + void fq_nmod_mat_submul(fq_nmod_mat_t D, const fq_nmod_mat_t C, const fq_nmod_mat_t A, const fq_nmod_mat_t B, const fq_nmod_ctx_t ctx) + # Sets `D = C + AB`. `C` and `D` may be aliased with each other but + # not with `A` or `B`. + + void fq_nmod_mat_mul_vec(fq_nmod_struct * c, const fq_nmod_mat_t A, const fq_nmod_struct * b, long blen, const fq_nmod_ctx_t ctx) + void fq_nmod_mat_mul_vec_ptr(fq_nmod_struct * const * c, const fq_nmod_mat_t A, const fq_nmod_struct * const * b, long blen, const fq_nmod_ctx_t ctx) + # Compute a matrix-vector product of ``A`` and ``(b, blen)`` and store the result in ``c``. + # The vector ``(b, blen)`` is either truncated or zero-extended to the number of columns of ``A``. + # The number entries written to ``c`` is always equal to the number of rows of ``A``. + + void fq_nmod_mat_vec_mul(fq_nmod_struct * c, const fq_nmod_struct * a, long alen, const fq_nmod_mat_t B, const fq_nmod_ctx_t ctx) + void fq_nmod_mat_vec_mul_ptr(fq_nmod_struct * const * c, const fq_nmod_struct * const * a, long alen, const fq_nmod_mat_t B, const fq_nmod_ctx_t ctx) + # Compute a vector-matrix product of ``(a, alen)`` and ``B`` and and store the result in ``c``. + # The vector ``(a, alen)`` is either truncated or zero-extended to the number of rows of ``B``. + # The number entries written to ``c`` is always equal to the number of columns of ``B``. + + int fq_nmod_mat_inv(fq_nmod_mat_t B, fq_nmod_mat_t A, const fq_nmod_ctx_t ctx) + # Sets `B = A^{-1}` and returns `1` if `A` is invertible. If `A` is singular, + # returns `0` and sets the elements of `B` to undefined values. + # `A` and `B` must be square matrices with the same dimensions. + + long fq_nmod_mat_lu(long * P, fq_nmod_mat_t A, int rank_check, const fq_nmod_ctx_t ctx) + # Computes a generalised LU decomposition `LU = PA` of a given + # matrix `A`, returning the rank of `A`. + # If `A` is a nonsingular square matrix, it will be overwritten with + # a unit diagonal lower triangular matrix `L` and an upper + # triangular matrix `U` (the diagonal of `L` will not be stored + # explicitly). + # If `A` is an arbitrary matrix of rank `r`, `U` will be in row + # echelon form having `r` nonzero rows, and `L` will be lower + # triangular but truncated to `r` columns, having implicit ones on + # the `r` first entries of the main diagonal. All other entries will + # be zero. + # If a nonzero value for ``rank_check`` is passed, the function + # will abandon the output matrix in an undefined state and return 0 + # if `A` is detected to be rank-deficient. + # This function calls ``fq_nmod_mat_lu_recursive``. + + long fq_nmod_mat_lu_classical(long * P, fq_nmod_mat_t A, int rank_check, const fq_nmod_ctx_t ctx) + # Computes a generalised LU decomposition `LU = PA` of a given + # matrix `A`, returning the rank of `A`. The behavior of this + # function is identical to that of ``fq_nmod_mat_lu``. Uses Gaussian + # elimination. + + long fq_nmod_mat_lu_recursive(long * P, fq_nmod_mat_t A, int rank_check, const fq_nmod_ctx_t ctx) + # Computes a generalised LU decomposition `LU = PA` of a given + # matrix `A`, returning the rank of `A`. The behavior of this + # function is identical to that of ``fq_nmod_mat_lu``. Uses recursive + # block decomposition, switching to classical Gaussian elimination + # for sufficiently small blocks. + + long fq_nmod_mat_rref(fq_nmod_mat_t A, const fq_nmod_ctx_t ctx) + # Puts `A` in reduced row echelon form and returns the rank of `A`. + # The rref is computed by first obtaining an unreduced row echelon + # form via LU decomposition and then solving an additional + # triangular system. + + long fq_nmod_mat_reduce_row(fq_nmod_mat_t A, long * P, long * L, long n, const fq_nmod_ctx_t ctx) + # Reduce row n of the matrix `A`, assuming the prior rows are in Gauss + # form. However those rows may not be in order. The entry `i` of the array + # `P` is the row of `A` which has a pivot in the `i`-th column. If no such + # row exists, the entry of `P` will be `-1`. The function returns the column + # in which the `n`-th row has a pivot after reduction. This will always be + # chosen to be the first available column for a pivot from the left. This + # information is also updated in `P`. Entry `i` of the array `L` contains the + # number of possibly nonzero columns of `A` row `i`. This speeds up reduction + # in the case that `A` is chambered on the right. Otherwise the entries of + # `L` can all be set to the number of columns of `A`. We require the entries + # of `L` to be monotonic increasing. + + void fq_nmod_mat_solve_tril(fq_nmod_mat_t X, const fq_nmod_mat_t L, const fq_nmod_mat_t B, int unit, const fq_nmod_ctx_t ctx) + # Sets `X = L^{-1} B` where `L` is a full rank lower triangular + # square matrix. If ``unit`` = 1, `L` is assumed to have ones on + # its main diagonal, and the main diagonal will not be read. `X` + # and `B` are allowed to be the same matrix, but no other aliasing + # is allowed. Automatically chooses between the classical and + # recursive algorithms. + + void fq_nmod_mat_solve_tril_classical(fq_nmod_mat_t X, const fq_nmod_mat_t L, const fq_nmod_mat_t B, int unit, const fq_nmod_ctx_t ctx) + # Sets `X = L^{-1} B` where `L` is a full rank lower triangular + # square matrix. If ``unit`` = 1, `L` is assumed to have ones on + # its main diagonal, and the main diagonal will not be read. `X` + # and `B` are allowed to be the same matrix, but no other aliasing + # is allowed. Uses forward substitution. + + void fq_nmod_mat_solve_tril_recursive(fq_nmod_mat_t X, const fq_nmod_mat_t L, const fq_nmod_mat_t B, int unit, const fq_nmod_ctx_t ctx) + # Sets `X = L^{-1} B` where `L` is a full rank lower triangular + # square matrix. If ``unit`` = 1, `L` is assumed to have ones on + # its main diagonal, and the main diagonal will not be read. `X` + # and `B` are allowed to be the same matrix, but no other aliasing + # is allowed. + # Uses the block inversion formula + # .. math :: + # \begin{pmatrix} A & 0 \\ C & D \end{pmatrix}^{-1} + # \begin{pmatrix} X \\ Y \end{pmatrix} = + # \begin{pmatrix} A^{-1} X \\ D^{-1} ( Y - C A^{-1} X ) \end{pmatrix} + # to reduce the problem to matrix multiplication and triangular + # solving of smaller systems. + + void fq_nmod_mat_solve_triu(fq_nmod_mat_t X, const fq_nmod_mat_t U, const fq_nmod_mat_t B, int unit, const fq_nmod_ctx_t ctx) + # Sets `X = U^{-1} B` where `U` is a full rank upper triangular + # square matrix. If ``unit`` = 1, `U` is assumed to have ones on + # its main diagonal, and the main diagonal will not be read. `X` + # and `B` are allowed to be the same matrix, but no other aliasing + # is allowed. Automatically chooses between the classical and + # recursive algorithms. + + void fq_nmod_mat_solve_triu_classical(fq_nmod_mat_t X, const fq_nmod_mat_t U, const fq_nmod_mat_t B, int unit, const fq_nmod_ctx_t ctx) + # Sets `X = U^{-1} B` where `U` is a full rank upper triangular + # square matrix. If ``unit`` = 1, `U` is assumed to have ones on + # its main diagonal, and the main diagonal will not be read. `X` + # and `B` are allowed to be the same matrix, but no other aliasing + # is allowed. Uses forward substitution. + + void fq_nmod_mat_solve_triu_recursive(fq_nmod_mat_t X, const fq_nmod_mat_t U, const fq_nmod_mat_t B, int unit, const fq_nmod_ctx_t ctx) + # Sets `X = U^{-1} B` where `U` is a full rank upper triangular + # square matrix. If ``unit`` = 1, `U` is assumed to have ones on + # its main diagonal, and the main diagonal will not be read. `X` + # and `B` are allowed to be the same matrix, but no other aliasing + # is allowed. + # Uses the block inversion formula + # .. math :: + # \begin{pmatrix} A & B \\ 0 & D \end{pmatrix}^{-1} + # \begin{pmatrix} X \\ Y \end{pmatrix} = + # \begin{pmatrix} A^{-1} (X - B D^{-1} Y) \\ D^{-1} Y \end{pmatrix} + # to reduce the problem to matrix multiplication and triangular + # solving of smaller systems. + + int fq_nmod_mat_solve(fq_nmod_mat_t X, const fq_nmod_mat_t A, const fq_nmod_mat_t B, const fq_nmod_ctx_t ctx) + # Solves the matrix-matrix equation `AX = B`. + # Returns `1` if `A` has full rank; otherwise returns `0` and sets the + # elements of `X` to undefined values. + # The matrix `A` must be square. + + int fq_nmod_mat_can_solve(fq_nmod_mat_t X, const fq_nmod_mat_t A, const fq_nmod_mat_t B, const fq_nmod_ctx_t ctx) + # Solves the matrix-matrix equation `AX = B` over `Fq`. + # Returns `1` if a solution exists; otherwise returns `0` and sets the + # elements of `X` to zero. If more than one solution exists, one of the + # valid solutions is given. + # There are no restrictions on the shape of `A` and it may be singular. + + void fq_nmod_mat_similarity(fq_nmod_mat_t M, long r, fq_nmod_t d, const fq_nmod_ctx_t ctx) + # Applies a similarity transform to the `n\times n` matrix `M` in-place. + # If `P` is the `n\times n` identity matrix the zero entries of whose row + # `r` (`0`-indexed) have been replaced by `d`, this transform is equivalent + # to `M = P^{-1}MP`. + # Similarity transforms preserve the determinant, characteristic polynomial + # and minimal polynomial. + # The value `d` is required to be reduced modulo the modulus of the entries + # in the matrix. + + void fq_nmod_mat_charpoly_danilevsky(fq_nmod_poly_t p, const fq_nmod_mat_t M, const fq_nmod_ctx_t ctx) + # Compute the characteristic polynomial `p` of the matrix `M`. The matrix + # is assumed to be square. + + void fq_nmod_mat_charpoly(fq_nmod_poly_t p, const fq_nmod_mat_t M, const fq_nmod_ctx_t ctx) + # Compute the characteristic polynomial `p` of the matrix `M`. The matrix + # is required to be square, otherwise an exception is raised. + + void fq_nmod_mat_minpoly(fq_nmod_poly_t p, const fq_nmod_mat_t M, const fq_nmod_ctx_t ctx) + # Compute the minimal polynomial `p` of the matrix `M`. The matrix + # is required to be square, otherwise an exception is raised. diff --git a/src/sage/libs/flint/fq_nmod_mpoly.pxd b/src/sage/libs/flint/fq_nmod_mpoly.pxd new file mode 100644 index 00000000000..a5ef24068e8 --- /dev/null +++ b/src/sage/libs/flint/fq_nmod_mpoly.pxd @@ -0,0 +1,365 @@ +# distutils: libraries = flint +# distutils: depends = flint/fq_nmod_mpoly.h + +################################################################################ +# This file is auto-generated. Do not modify by hand +################################################################################ + +from libc.stdio cimport FILE +from sage.libs.gmp.types cimport * +from sage.libs.mpfr.types cimport * +from sage.libs.flint.types cimport * + +cdef extern from "flint_wrap.h": + + void fq_nmod_mpoly_ctx_init(fq_nmod_mpoly_ctx_t ctx, long nvars, const ordering_t ord, const fq_nmod_ctx_t fqctx) + # Initialise a context object for a polynomial ring with the given number of variables and the given ordering. + # It will have coefficients in the finite field *fqctx*. + # The possibilities for the ordering are ``ORD_LEX``, ``ORD_DEGLEX`` and ``ORD_DEGREVLEX``. + + long fq_nmod_mpoly_ctx_nvars(const fq_nmod_mpoly_ctx_t ctx) + # Return the number of variables used to initialize the context. + + ordering_t fq_nmod_mpoly_ctx_ord(const fq_nmod_mpoly_ctx_t ctx) + # Return the ordering used to initialize the context. + + void fq_nmod_mpoly_ctx_clear(fq_nmod_mpoly_ctx_t ctx) + # Release any space allocated by an *ctx*. + + void fq_nmod_mpoly_init(fq_nmod_mpoly_t A, const fq_nmod_mpoly_ctx_t ctx) + # Initialise *A* for use with the given an initialised context object. Its value is set to zero. + + void fq_nmod_mpoly_init2(fq_nmod_mpoly_t A, long alloc, const fq_nmod_mpoly_ctx_t ctx) + # Initialise *A* for use with the given an initialised context object. Its value is set to zero. + # It is allocated with space for *alloc* terms and at least ``MPOLY_MIN_BITS`` bits for the exponents. + + void fq_nmod_mpoly_init3(fq_nmod_mpoly_t A, long alloc, flint_bitcnt_t bits, const fq_nmod_mpoly_ctx_t ctx) + # Initialise *A* for use with the given an initialised context object. Its value is set to zero. + # It is allocated with space for *alloc* terms and *bits* bits for the exponents. + + void fq_nmod_mpoly_fit_length(fq_nmod_mpoly_t A, long len, const fq_nmod_mpoly_ctx_t ctx) + # Ensure that *A* has space for at least *len* terms. + + void fq_nmod_mpoly_realloc(fq_nmod_mpoly_t A, long alloc, const fq_nmod_mpoly_ctx_t ctx) + # Reallocate *A* to have space for *alloc* terms. + # Assumes the current length of the polynomial is not greater than *alloc*. + + void fq_nmod_mpoly_clear(fq_nmod_mpoly_t A, const fq_nmod_mpoly_ctx_t ctx) + # Release any space allocated for *A*. + + char * fq_nmod_mpoly_get_str_pretty(const fq_nmod_mpoly_t A, const char ** x, const fq_nmod_mpoly_ctx_t ctx) + # Return a string, which the user is responsible for cleaning up, representing *A*, given an array of variable strings *x*. + + int fq_nmod_mpoly_fprint_pretty(FILE * file, const fq_nmod_mpoly_t A, const char ** x, const fq_nmod_mpoly_ctx_t ctx) + # Print a string representing *A* to *file*. + + int fq_nmod_mpoly_print_pretty(const fq_nmod_mpoly_t A, const char ** x, const fq_nmod_mpoly_ctx_t ctx) + # Print a string representing *A* to ``stdout``. + + int fq_nmod_mpoly_set_str_pretty(fq_nmod_mpoly_t A, const char * str, const char ** x, const fq_nmod_mpoly_ctx_t ctx) + # Set *A* to the polynomial in the null-terminates string *str* given an array *x* of variable strings. + # If parsing *str* fails, *A* is set to zero, and `-1` is returned. Otherwise, `0` is returned. + # The operations ``+``, ``-``, ``*``, and ``/`` are permitted along with integers and the variables in *x*. The character ``^`` must be immediately followed by the (integer) exponent. + # If any division is not exact, parsing fails. + + void fq_nmod_mpoly_gen(fq_nmod_mpoly_t A, long var, const fq_nmod_mpoly_ctx_t ctx) + # Set *A* to the variable of index *var*, where `var = 0` corresponds to the variable with the most significance with respect to the ordering. + + int fq_nmod_mpoly_is_gen(const fq_nmod_mpoly_t A, long var, const fq_nmod_mpoly_ctx_t ctx) + # If `var \ge 0`, return `1` if *A* is equal to the `var`-th generator, otherwise return `0`. + # If `var < 0`, return `1` if the polynomial is equal to any generator, otherwise return `0`. + + void fq_nmod_mpoly_set(fq_nmod_mpoly_t A, const fq_nmod_mpoly_t B, const fq_nmod_mpoly_ctx_t ctx) + # Set *A* to *B*. + + int fq_nmod_mpoly_equal(const fq_nmod_mpoly_t A, const fq_nmod_mpoly_t B, const fq_nmod_mpoly_ctx_t ctx) + # Return `1` if *A* is equal to *B*, else return `0`. + + void fq_nmod_mpoly_swap(fq_nmod_mpoly_t A, fq_nmod_mpoly_t B, const fq_nmod_mpoly_ctx_t ctx) + # Efficiently swap *A* and *B*. + + int fq_nmod_mpoly_is_fq_nmod(const fq_nmod_mpoly_t A, const fq_nmod_mpoly_ctx_t ctx) + # Return `1` if *A* is a constant, else return `0`. + + void fq_nmod_mpoly_get_fq_nmod(fq_nmod_t c, const fq_nmod_mpoly_t A, const fq_nmod_mpoly_ctx_t ctx) + # Assuming that *A* is a constant, set *c* to this constant. + # This function throws if *A* is not a constant. + + void fq_nmod_mpoly_set_fq_nmod(fq_nmod_mpoly_t A, const fq_nmod_t c, const fq_nmod_mpoly_ctx_t ctx) + void fq_nmod_mpoly_set_ui(fq_nmod_mpoly_t A, unsigned long c, const fq_nmod_mpoly_ctx_t ctx) + # Set *A* to the constant *c*. + + void fq_nmod_mpoly_set_fq_nmod_gen(fq_nmod_mpoly_t A, const fq_nmod_mpoly_ctx_t ctx) + # Set *A* to the constant given by :func:`fq_nmod_gen`. + + void fq_nmod_mpoly_zero(fq_nmod_mpoly_t A, const fq_nmod_mpoly_ctx_t ctx) + # Set *A* to the constant `0`. + + void fq_nmod_mpoly_one(fq_nmod_mpoly_t A, const fq_nmod_mpoly_ctx_t ctx) + # Set *A* to the constant `1`. + + int fq_nmod_mpoly_equal_fq_nmod(const fq_nmod_mpoly_t A, const fq_nmod_t c, const fq_nmod_mpoly_ctx_t ctx) + # Return `1` if *A* is equal to the constant *c*, else return `0`. + + int fq_nmod_mpoly_is_zero(const fq_nmod_mpoly_t A, const fq_nmod_mpoly_ctx_t ctx) + # Return `1` if *A* is the constant `0`, else return `0`. + + int fq_nmod_mpoly_is_one(const fq_nmod_mpoly_t A, const fq_nmod_mpoly_ctx_t ctx) + # Return `1` if *A* is the constant `1`, else return `0`. + + int fq_nmod_mpoly_degrees_fit_si(const fq_nmod_mpoly_t A, const fq_nmod_mpoly_ctx_t ctx) + # Return `1` if the degrees of *A* with respect to each variable fit into an ``slong``, otherwise return `0`. + + void fq_nmod_mpoly_degrees_fmpz(fmpz ** degs, const fq_nmod_mpoly_t A, const fq_nmod_mpoly_ctx_t ctx) + void fq_nmod_mpoly_degrees_si(long * degs, const fq_nmod_mpoly_t A, const fq_nmod_mpoly_ctx_t ctx) + # Set *degs* to the degrees of *A* with respect to each variable. + # If *A* is zero, all degrees are set to `-1`. + + void fq_nmod_mpoly_degree_fmpz(fmpz_t deg, const fq_nmod_mpoly_t A, long var, const fq_nmod_mpoly_ctx_t ctx) + long fq_nmod_mpoly_degree_si(const fq_nmod_mpoly_t A, long var, const fq_nmod_mpoly_ctx_t ctx) + # Either return or set *deg* to the degree of *A* with respect to the variable of index *var*. + # If *A* is zero, the degree is defined to be `-1`. + + int fq_nmod_mpoly_total_degree_fits_si(const fq_nmod_mpoly_t A, const fq_nmod_mpoly_ctx_t ctx) + # Return `1` if the total degree of *A* fits into an ``slong``, otherwise return `0`. + + void fq_nmod_mpoly_total_degree_fmpz(fmpz_t tdeg, const fq_nmod_mpoly_t A, const fq_nmod_mpoly_ctx_t ctx) + long fq_nmod_mpoly_total_degree_si(const fq_nmod_mpoly_t A, const fq_nmod_mpoly_ctx_t ctx) + # Either return or set *tdeg* to the total degree of *A*. + # If *A* is zero, the total degree is defined to be `-1`. + + void fq_nmod_mpoly_used_vars(int * used, const fq_nmod_mpoly_t A, const fq_nmod_mpoly_ctx_t ctx) + # For each variable index `i`, set ``used[i]`` to nonzero if the variable of index `i` appears in *A* and to zero otherwise. + + void fq_nmod_mpoly_get_coeff_fq_nmod_monomial(fq_nmod_t c, const fq_nmod_mpoly_t A, const fq_nmod_mpoly_t M, const fq_nmod_mpoly_ctx_t ctx) + # Assuming that *M* is a monomial, set *c* to the coefficient of the corresponding monomial in *A*. + # This function throws if *M* is not a monomial. + + void fq_nmod_mpoly_set_coeff_fq_nmod_monomial(fq_nmod_mpoly_t A, const fq_nmod_t c, const fq_nmod_mpoly_t M, const fq_nmod_mpoly_ctx_t ctx) + # Assuming that *M* is a monomial, set the coefficient of the corresponding monomial in *A* to *c*. + # This function throws if *M* is not a monomial. + + void fq_nmod_mpoly_get_coeff_fq_nmod_fmpz(fq_nmod_t c, const fq_nmod_mpoly_t A, fmpz * const * exp, const fq_nmod_mpoly_ctx_t ctx) + void fq_nmod_mpoly_get_coeff_fq_nmod_ui(fq_nmod_t c, const fq_nmod_mpoly_t A, const unsigned long * exp, const fq_nmod_mpoly_ctx_t ctx) + # Set *c* to the coefficient of the monomial with exponent vector *exp*. + + void fq_nmod_mpoly_set_coeff_fq_nmod_fmpz(fq_nmod_mpoly_t A, const fq_nmod_t c, fmpz * const * exp, const fq_nmod_mpoly_ctx_t ctx) + void fq_nmod_mpoly_set_coeff_fq_nmod_ui(fq_nmod_mpoly_t A, const fq_nmod_t c, const unsigned long * exp, const fq_nmod_mpoly_ctx_t ctx) + # Set the coefficient of the monomial with exponent *exp* to *c*. + + void fq_nmod_mpoly_get_coeff_vars_ui(fq_nmod_mpoly_t C, const fq_nmod_mpoly_t A, const long * vars, const unsigned long * exps, long length, const fq_nmod_mpoly_ctx_t ctx) + # Set *C* to the coefficient of *A* with respect to the variables in *vars* with powers in the corresponding array *exps*. + # Both *vars* and *exps* point to array of length *length*. It is assumed that `0 < length \le nvars(A)` and that the variables in *vars* are distinct. + + int fq_nmod_mpoly_cmp(const fq_nmod_mpoly_t A, const fq_nmod_mpoly_t B, const fq_nmod_mpoly_ctx_t ctx) + # Return `1` (resp. `-1`, or `0`) if *A* is after (resp. before, same as) *B* in some arbitrary but fixed total ordering of the polynomials. + # This ordering agrees with the usual ordering of monomials when *A* and *B* are both monomials. + + int fq_nmod_mpoly_is_canonical(const fq_nmod_mpoly_t A, const fq_nmod_mpoly_ctx_t ctx) + # Return `1` if *A* is in canonical form. Otherwise, return `0`. + # To be in canonical form, all of the terms must have nonzero coefficients, and the terms must be sorted from greatest to least. + + long fq_nmod_mpoly_length(const fq_nmod_mpoly_t A, const fq_nmod_mpoly_ctx_t ctx) + # Return the number of terms in *A*. + # If the polynomial is in canonical form, this will be the number of nonzero coefficients. + + void fq_nmod_mpoly_resize(fq_nmod_mpoly_t A, long new_length, const fq_nmod_mpoly_ctx_t ctx) + # Set the length of *A* to ``new_length``. + # Terms are either deleted from the end, or new zero terms are appended. + + void fq_nmod_mpoly_get_term_coeff_fq_nmod(fq_nmod_t c, const fq_nmod_mpoly_t A, long i, const fq_nmod_mpoly_ctx_t ctx) + # Set *c* to the coefficient of the term of index *i*. + + void fq_nmod_mpoly_set_term_coeff_ui(fq_nmod_mpoly_t A, long i, unsigned long c, const fq_nmod_mpoly_ctx_t ctx) + # Set the coefficient of the term of index *i* to *c*. + + int fq_nmod_mpoly_term_exp_fits_si(const fq_nmod_mpoly_t A, long i, const fq_nmod_mpoly_ctx_t ctx) + int fq_nmod_mpoly_term_exp_fits_ui(const fq_nmod_mpoly_t A, long i, const fq_nmod_mpoly_ctx_t ctx) + # Return `1` if all entries of the exponent vector of the term of index `i` fit into an ``slong`` (resp. a ``ulong``). Otherwise, return `0`. + + void fq_nmod_mpoly_get_term_exp_fmpz(fmpz ** exp, const fq_nmod_mpoly_t A, long i, const fq_nmod_mpoly_ctx_t ctx) + void fq_nmod_mpoly_get_term_exp_ui(unsigned long * exp, const fq_nmod_mpoly_t A, long i, const fq_nmod_mpoly_ctx_t ctx) + void fq_nmod_mpoly_get_term_exp_si(long * exp, const fq_nmod_mpoly_t A, long i, const fq_nmod_mpoly_ctx_t ctx) + # Set *exp* to the exponent vector of the term of index *i*. + # The ``_ui`` (resp. ``_si``) version throws if any entry does not fit into a ``ulong`` (resp. ``slong``). + + unsigned long fq_nmod_mpoly_get_term_var_exp_ui(const fq_nmod_mpoly_t A, long i, long var, const fq_nmod_mpoly_ctx_t ctx) + long fq_nmod_mpoly_get_term_var_exp_si(const fq_nmod_mpoly_t A, long i, long var, const fq_nmod_mpoly_ctx_t ctx) + # Return the exponent of the variable *var* of the term of index *i*. + # This function throws if the exponent does not fit into a ``ulong`` (resp. ``slong``). + + void fq_nmod_mpoly_set_term_exp_fmpz(fq_nmod_mpoly_t A, long i, fmpz * const * exp, const fq_nmod_mpoly_ctx_t ctx) + void fq_nmod_mpoly_set_term_exp_ui(fq_nmod_mpoly_t A, long i, const unsigned long * exp, const fq_nmod_mpoly_ctx_t ctx) + # Set the exponent of the term of index *i* to *exp*. + + void fq_nmod_mpoly_get_term(fq_nmod_mpoly_t M, const fq_nmod_mpoly_t A, long i, const fq_nmod_mpoly_ctx_t ctx) + # Set *M* to the term of index *i* in *A*. + + void fq_nmod_mpoly_get_term_monomial(fq_nmod_mpoly_t M, const fq_nmod_mpoly_t A, long i, const fq_nmod_mpoly_ctx_t ctx) + # Set *M* to the monomial of the term of index *i* in *A*. The coefficient of *M* will be one. + + void fq_nmod_mpoly_push_term_fq_nmod_fmpz(fq_nmod_mpoly_t A, const fq_nmod_t c, fmpz * const * exp, const fq_nmod_mpoly_ctx_t ctx) + void fq_nmod_mpoly_push_term_fq_nmod_ffmpz(fq_nmod_mpoly_t A, const fq_nmod_t c, const fmpz * exp, const fq_nmod_mpoly_ctx_t ctx) + void fq_nmod_mpoly_push_term_fq_nmod_ui(fq_nmod_mpoly_t A, const fq_nmod_t c, const unsigned long * exp, const fq_nmod_mpoly_ctx_t ctx) + # Append a term to *A* with coefficient *c* and exponent vector *exp*. + # This function runs in constant average time. + + void fq_nmod_mpoly_sort_terms(fq_nmod_mpoly_t A, const fq_nmod_mpoly_ctx_t ctx) + # Sort the terms of *A* into the canonical ordering dictated by the ordering in *ctx*. + # This function simply reorders the terms: It does not combine like terms, nor does it delete terms with coefficient zero. + # This function runs in linear time in the bit size of *A*. + + void fq_nmod_mpoly_combine_like_terms(fq_nmod_mpoly_t A, const fq_nmod_mpoly_ctx_t ctx) + # Combine adjacent like terms in *A* and delete terms with coefficient zero. + # If the terms of *A* were sorted to begin with, the result will be in canonical form. + # This function runs in linear time in the bit size of *A*. + + void fq_nmod_mpoly_reverse(fq_nmod_mpoly_t A, const fq_nmod_mpoly_t B, const fq_nmod_mpoly_ctx_t ctx) + # Set *A* to the reversal of *B*. + + void fq_nmod_mpoly_randtest_bound(fq_nmod_mpoly_t A, flint_rand_t state, long length, unsigned long exp_bound, const fq_nmod_mpoly_ctx_t ctx) + # Generate a random polynomial with length up to *length* and exponents in the range ``[0, exp_bound - 1]``. + # The exponents of each variable are generated by calls to ``n_randint(state, exp_bound)``. + + void fq_nmod_mpoly_randtest_bounds(fq_nmod_mpoly_t A, flint_rand_t state, long length, unsigned long *exp_bounds, const fq_nmod_mpoly_ctx_t ctx) + # Generate a random polynomial with length up to *length* and exponents in the range ``[0, exp_bounds[i] - 1]``. + # The exponents of the variable of index *i* are generated by calls to ``n_randint(state, exp_bounds[i])``. + + void fq_nmod_mpoly_randtest_bits(fq_nmod_mpoly_t A, flint_rand_t state, long length, mp_limb_t exp_bits, const fq_nmod_mpoly_ctx_t ctx) + # Generate a random polynomial with length up to *length* and exponents whose packed form does not exceed the given bit count. + + void fq_nmod_mpoly_add_fq_nmod(fq_nmod_mpoly_t A, const fq_nmod_mpoly_t B, const fq_nmod_t C, const fq_nmod_mpoly_ctx_t ctx) + # Set *A* to `B + c`. + + void fq_nmod_mpoly_sub_fq_nmod(fq_nmod_mpoly_t A, const fq_nmod_mpoly_t B, const fq_nmod_t C, const fq_nmod_mpoly_ctx_t ctx) + # Set *A* to `B - c`. + + void fq_nmod_mpoly_add(fq_nmod_mpoly_t A, const fq_nmod_mpoly_t B, const fq_nmod_mpoly_t C, const fq_nmod_mpoly_ctx_t ctx) + # Set *A* to `B + C`. + + void fq_nmod_mpoly_sub(fq_nmod_mpoly_t A, const fq_nmod_mpoly_t B, const fq_nmod_mpoly_t C, const fq_nmod_mpoly_ctx_t ctx) + # Set *A* to `B - C`. + + void fq_nmod_mpoly_neg(fq_nmod_mpoly_t A, const fq_nmod_mpoly_t B, const fq_nmod_mpoly_ctx_t ctx) + # Set *A* to `-B`. + + void fq_nmod_mpoly_scalar_mul_fq_nmod(fq_nmod_mpoly_t A, const fq_nmod_mpoly_t B, const fq_nmod_t c, const fq_nmod_mpoly_ctx_t ctx) + # Set *A* to `B \times c`. + + void fq_nmod_mpoly_make_monic(fq_nmod_mpoly_t A, const fq_nmod_mpoly_t B, const fq_nmod_mpoly_ctx_t ctx) + # Set *A* to *B* divided by the leading coefficient of *B*. + # This throws if *B* is zero. + + void fq_nmod_mpoly_derivative(fq_nmod_mpoly_t A, const fq_nmod_mpoly_t B, long var, const fq_nmod_mpoly_ctx_t ctx) + # Set *A* to the derivative of *B* with respect to the variable of index *var*. + + void fq_nmod_mpoly_evaluate_all_fq_nmod(fq_nmod_t ev, const fq_nmod_mpoly_t A, fq_nmod_struct * const * vals, const fq_nmod_mpoly_ctx_t ctx) + # Set *ev* the evaluation of *A* where the variables are replaced by the corresponding elements of the array *vals*. + + void fq_nmod_mpoly_evaluate_one_fq_nmod(fq_nmod_mpoly_t A, const fq_nmod_mpoly_t B, long var, const fq_nmod_t val, const fq_nmod_mpoly_ctx_t ctx) + # Set *A* to the evaluation of *B* where the variable of index *var* is replaced by *val*. + + int fq_nmod_mpoly_compose_fq_nmod_poly(fq_nmod_poly_t A, const fq_nmod_mpoly_t B, fq_nmod_poly_struct * const * C, const fq_nmod_mpoly_ctx_t ctx) + # Set *A* to the evaluation of *B* where the variables are replaced by the corresponding elements of the array *C*. + # The context object of *B* is *ctxB*. + # Return `1` for success and `0` for failure. + + int fq_nmod_mpoly_compose_fq_nmod_mpoly(fq_nmod_mpoly_t A, const fq_nmod_mpoly_t B, fq_nmod_mpoly_struct * const * C, const fq_nmod_mpoly_ctx_t ctxB, const fq_nmod_mpoly_ctx_t ctxAC) + # Set *A* to the evaluation of *B* where the variables are replaced by the corresponding elements of the array *C*. + # Both *A* and the elements of *C* have context object *ctxAC*, while *B* has context object *ctxB*. + # Neither *A* nor *B* is allowed to alias any other polynomial. + # Return `1` for success and `0` for failure. + + void fq_nmod_mpoly_compose_fq_nmod_mpoly_gen(fq_nmod_mpoly_t A, const fq_nmod_mpoly_t B, const long * c, const fq_nmod_mpoly_ctx_t ctxB, const fq_nmod_mpoly_ctx_t ctxAC) + # Set *A* to the evaluation of *B* where the variable of index *i* in *ctxB* is replaced by the variable of index ``c[i]`` in *ctxAC*. + # The length of the array *C* is the number of variables in *ctxB*. + # If any ``c[i]`` is negative, the corresponding variable of *B* is replaced by zero. Otherwise, it is expected that ``c[i]`` is less than the number of variables in *ctxAC*. + + void fq_nmod_mpoly_mul(fq_nmod_mpoly_t A, const fq_nmod_mpoly_t B, const fq_nmod_mpoly_t C, const fq_nmod_mpoly_ctx_t ctx) + # Set *A* to *B* times *C*. + + int fq_nmod_mpoly_pow_fmpz(fq_nmod_mpoly_t A, const fq_nmod_mpoly_t B, const fmpz_t k, const fq_nmod_mpoly_ctx_t ctx) + # Set *A* to `B` raised to the *k*-th power. + # Return `1` for success and `0` for failure. + + int fq_nmod_mpoly_pow_ui(fq_nmod_mpoly_t A, const fq_nmod_mpoly_t B, unsigned long k, const fq_nmod_mpoly_ctx_t ctx) + # Set *A* to `B` raised to the *k*-th power. + # Return `1` for success and `0` for failure. + + int fq_nmod_mpoly_divides(fq_nmod_mpoly_t Q, const fq_nmod_mpoly_t A, const fq_nmod_mpoly_t B, const fq_nmod_mpoly_ctx_t ctx) + # If *A* is divisible by *B*, set *Q* to the exact quotient and return `1`. Otherwise, set *Q* to zero and return `0`. + + void fq_nmod_mpoly_div(fq_nmod_mpoly_t Q, const fq_nmod_mpoly_t A, const fq_nmod_mpoly_t B, const fq_nmod_mpoly_ctx_t ctx) + # Set *Q* to the quotient of *A* by *B*, discarding the remainder. + + void fq_nmod_mpoly_divrem(fq_nmod_mpoly_t Q, fq_nmod_mpoly_t R, const fq_nmod_mpoly_t A, const fq_nmod_mpoly_t B, const fq_nmod_mpoly_ctx_t ctx) + # Set *Q* and *R* to the quotient and remainder of *A* divided by *B*. + + void fq_nmod_mpoly_divrem_ideal(fq_nmod_mpoly_struct ** Q, fq_nmod_mpoly_t R, const fq_nmod_mpoly_t A, fq_nmod_mpoly_struct * const * B, long len, const fq_nmod_mpoly_ctx_t ctx) + # This function is as per :func:`fq_nmod_mpoly_divrem` except that it takes an array of divisor polynomials *B* and it returns an array of quotient polynomials *Q*. + # The number of divisor (and hence quotient) polynomials, is given by *len*. + + void fq_nmod_mpoly_term_content(fq_nmod_mpoly_t M, const fq_nmod_mpoly_t A, const fq_nmod_mpoly_ctx_t ctx) + # Set *M* to the GCD of the terms of *A*. + # If *A* is zero, *M* will be zero. Otherwise, *M* will be a monomial with coefficient one. + + int fq_nmod_mpoly_content_vars(fq_nmod_mpoly_t g, const fq_nmod_mpoly_t A, long * vars, long vars_length, const fq_nmod_mpoly_ctx_t ctx) + # Set *g* to the GCD of the coefficients of *A* when viewed as a polynomial in the variables *vars*. + # Return `1` for success and `0` for failure. Upon success, *g* will be independent of the variables *vars*. + + int fq_nmod_mpoly_gcd(fq_nmod_mpoly_t G, const fq_nmod_mpoly_t A, const fq_nmod_mpoly_t B, const fq_nmod_mpoly_ctx_t ctx) + # Try to set *G* to the monic GCD of *A* and *B*. The GCD of zero and zero is defined to be zero. + # If the return is `1` the function was successful. Otherwise the return is `0` and *G* is left untouched. + + int fq_nmod_mpoly_gcd_cofactors(fq_nmod_mpoly_t G, fq_nmod_mpoly_t Abar, fq_nmod_mpoly_t Bbar, const fq_nmod_mpoly_t A, const fq_nmod_mpoly_t B, const fq_nmod_mpoly_ctx_t ctx) + # Do the operation of :func:`fq_nmod_mpoly_gcd` and also compute `Abar = A/G` and `Bbar = B/G` if successful. + + int fq_nmod_mpoly_gcd_brown(fq_nmod_mpoly_t G, const fq_nmod_mpoly_t A, const fq_nmod_mpoly_t B, const fq_nmod_mpoly_ctx_t ctx) + int fq_nmod_mpoly_gcd_hensel(fq_nmod_mpoly_t G, const fq_nmod_mpoly_t A, const fq_nmod_mpoly_t B, const fq_nmod_mpoly_ctx_t ctx) + int fq_nmod_mpoly_gcd_zippel(fq_nmod_mpoly_t G, const fq_nmod_mpoly_t A, const fq_nmod_mpoly_t B, const fq_nmod_mpoly_ctx_t ctx) + # Try to set *G* to the GCD of *A* and *B* using various algorithms. + + int fq_nmod_mpoly_resultant(fq_nmod_mpoly_t R, const fq_nmod_mpoly_t A, const fq_nmod_mpoly_t B, long var, const fq_nmod_mpoly_ctx_t ctx) + # Try to set *R* to the resultant of *A* and *B* with respect to the variable of index *var*. + + int fq_nmod_mpoly_discriminant(fq_nmod_mpoly_t D, const fq_nmod_mpoly_t A, long var, const fq_nmod_mpoly_ctx_t ctx) + # Try to set *D* to the discriminant of *A* with respect to the variable of index *var*. + + int fq_nmod_mpoly_sqrt(fq_nmod_mpoly_t Q, const fq_nmod_mpoly_t A, const fq_nmod_mpoly_ctx_t ctx) + # If `Q^2=A` has a solution, set `Q` to a solution and return `1`, otherwise return `0` and set `Q` to zero. + + int fq_nmod_mpoly_is_square(const fq_nmod_mpoly_t A, const fq_nmod_mpoly_ctx_t ctx) + # Return `1` if *A* is a perfect square, otherwise return `0`. + + int fq_nmod_mpoly_quadratic_root(fq_nmod_mpoly_t Q, const fq_nmod_mpoly_t A, const fq_nmod_mpoly_t B, const fq_nmod_mpoly_ctx_t ctx) + # If `Q^2+AQ=B` has a solution, set `Q` to a solution and return `1`, otherwise return `0`. + + void fq_nmod_mpoly_univar_init(fq_nmod_mpoly_univar_t A, const fq_nmod_mpoly_ctx_t ctx) + # Initialize *A*. + + void fq_nmod_mpoly_univar_clear(fq_nmod_mpoly_univar_t A, const fq_nmod_mpoly_ctx_t ctx) + # Clear *A*. + + void fq_nmod_mpoly_univar_swap(fq_nmod_mpoly_univar_t A, fq_nmod_mpoly_univar_t B, const fq_nmod_mpoly_ctx_t ctx) + # Swap *A* and `B`. + + void fq_nmod_mpoly_to_univar(fq_nmod_mpoly_univar_t A, const fq_nmod_mpoly_t B, long var, const fq_nmod_mpoly_ctx_t ctx) + # Set *A* to a univariate form of *B* by pulling out the variable of index *var*. + # The coefficients of *A* will still belong to the content *ctx* but will not depend on the variable of index *var*. + + void fq_nmod_mpoly_from_univar(fq_nmod_mpoly_t A, const fq_nmod_mpoly_univar_t B, long var, const fq_nmod_mpoly_ctx_t ctx) + # Set *A* to the normal form of *B* by putting in the variable of index *var*. + # This function is undefined if the coefficients of *B* depend on the variable of index *var*. + + int fq_nmod_mpoly_univar_degree_fits_si(const fq_nmod_mpoly_univar_t A, const fq_nmod_mpoly_ctx_t ctx) + # Return `1` if the degree of *A* with respect to the main variable fits an ``slong``. Otherwise, return `0`. + + long fq_nmod_mpoly_univar_length(const fq_nmod_mpoly_univar_t A, const fq_nmod_mpoly_ctx_t ctx) + # Return the number of terms in *A* with respect to the main variable. + + long fq_nmod_mpoly_univar_get_term_exp_si(fq_nmod_mpoly_univar_t A, long i, const fq_nmod_mpoly_ctx_t ctx) + # Return the exponent of the term of index *i* of *A*. + + void fq_nmod_mpoly_univar_get_term_coeff(fq_nmod_mpoly_t c, const fq_nmod_mpoly_univar_t A, long i, const fq_nmod_mpoly_ctx_t ctx) + void fq_nmod_mpoly_univar_swap_term_coeff(fq_nmod_mpoly_t c, fq_nmod_mpoly_univar_t A, long i, const fq_nmod_mpoly_ctx_t ctx) + # Set (resp. swap) *c* to (resp. with) the coefficient of the term of index *i* of *A*. diff --git a/src/sage/libs/flint/fq_nmod_mpoly_factor.pxd b/src/sage/libs/flint/fq_nmod_mpoly_factor.pxd new file mode 100644 index 00000000000..a1ad523dede --- /dev/null +++ b/src/sage/libs/flint/fq_nmod_mpoly_factor.pxd @@ -0,0 +1,47 @@ +# distutils: libraries = flint +# distutils: depends = flint/fq_nmod_mpoly_factor.h + +################################################################################ +# This file is auto-generated. Do not modify by hand +################################################################################ + +from libc.stdio cimport FILE +from sage.libs.gmp.types cimport * +from sage.libs.mpfr.types cimport * +from sage.libs.flint.types cimport * + +cdef extern from "flint_wrap.h": + + void fq_nmod_mpoly_factor_init(fq_nmod_mpoly_factor_t f, const fq_nmod_mpoly_ctx_t ctx) + # Initialise *f*. + + void fq_nmod_mpoly_factor_clear(fq_nmod_mpoly_factor_t f, const fq_nmod_mpoly_ctx_t ctx) + # Clear *f*. + + void fq_nmod_mpoly_factor_swap(fq_nmod_mpoly_factor_t f, fq_nmod_mpoly_factor_t g, const fq_nmod_mpoly_ctx_t ctx) + # Efficiently swap *f* and *g*. + + long fq_nmod_mpoly_factor_length(const fq_nmod_mpoly_factor_t f, const fq_nmod_mpoly_ctx_t ctx) + # Return the length of the product in *f*. + + void fq_nmod_mpoly_factor_get_constant_fq_nmod(fq_nmod_t c, const fq_nmod_mpoly_factor_t f, const fq_nmod_mpoly_ctx_t ctx) + # Set `c` to the constant of *f*. + + void fq_nmod_mpoly_factor_get_base(fq_nmod_mpoly_t p, const fq_nmod_mpoly_factor_t f, long i, const fq_nmod_mpoly_ctx_t ctx) + void fq_nmod_mpoly_factor_swap_base(fq_nmod_mpoly_t p, const fq_nmod_mpoly_factor_t f, long i, const fq_nmod_mpoly_ctx_t ctx) + # Set (resp. swap) *B* to (resp. with) the base of the term of index *i* in *A*. + + long fq_nmod_mpoly_factor_get_exp_si(fq_nmod_mpoly_factor_t f, long i, const fq_nmod_mpoly_ctx_t ctx) + # Return the exponent of the term of index *i* in *A*. It is assumed to fit an ``slong``. + + void fq_nmod_mpoly_factor_sort(fq_nmod_mpoly_factor_t f, const fq_nmod_mpoly_ctx_t ctx) + # Sort the product of *f* first by exponent and then by base. + + int fq_nmod_mpoly_factor_squarefree(fq_nmod_mpoly_factor_t f, const fq_nmod_mpoly_t A, const fq_nmod_mpoly_ctx_t ctx) + # Set *f* to a factorization of *A* where the bases are primitive and + # pairwise relatively prime. If the product of all irreducible factors with + # a given exponent is desired, it is recommended to call :func:`fq_nmod_mpoly_factor_sort` + # and then multiply the bases with the desired exponent. + + int fq_nmod_mpoly_factor(fq_nmod_mpoly_factor_t f, const fq_nmod_mpoly_t A, const fq_nmod_mpoly_ctx_t ctx) + # Set *f* to a factorization of *A* where the bases are irreducible. diff --git a/src/sage/libs/flint/fq_nmod_poly.pxd b/src/sage/libs/flint/fq_nmod_poly.pxd new file mode 100644 index 00000000000..b6ec5c6788f --- /dev/null +++ b/src/sage/libs/flint/fq_nmod_poly.pxd @@ -0,0 +1,1064 @@ +# distutils: libraries = flint +# distutils: depends = flint/fq_nmod_poly.h + +################################################################################ +# This file is auto-generated. Do not modify by hand +################################################################################ + +from libc.stdio cimport FILE +from sage.libs.gmp.types cimport * +from sage.libs.mpfr.types cimport * +from sage.libs.flint.types cimport * + +cdef extern from "flint_wrap.h": + + void fq_nmod_poly_init(fq_nmod_poly_t poly, const fq_nmod_ctx_t ctx) + # Initialises ``poly`` for use, with context ctx, and setting its + # length to zero. A corresponding call to :func:`fq_nmod_poly_clear` + # must be made after finishing with the ``fq_nmod_poly_t`` to free the + # memory used by the polynomial. + + void fq_nmod_poly_init2(fq_nmod_poly_t poly, long alloc, const fq_nmod_ctx_t ctx) + # Initialises ``poly`` with space for at least ``alloc`` + # coefficients and sets the length to zero. The allocated + # coefficients are all set to zero. A corresponding call to + # :func:`fq_nmod_poly_clear` must be made after finishing with the + # ``fq_nmod_poly_t`` to free the memory used by the polynomial. + + void fq_nmod_poly_realloc(fq_nmod_poly_t poly, long alloc, const fq_nmod_ctx_t ctx) + # Reallocates the given polynomial to have space for ``alloc`` + # coefficients. If ``alloc`` is zero the polynomial is cleared + # and then reinitialised. If the current length is greater than + # ``alloc`` the polynomial is first truncated to length + # ``alloc``. + + void fq_nmod_poly_fit_length(fq_nmod_poly_t poly, long len, const fq_nmod_ctx_t ctx) + # If ``len`` is greater than the number of coefficients currently + # allocated, then the polynomial is reallocated to have space for at + # least ``len`` coefficients. No data is lost when calling this + # function. + # The function efficiently deals with the case where + # ``fit_length`` is called many times in small increments by at + # least doubling the number of allocated coefficients when length is + # larger than the number of coefficients currently allocated. + + void _fq_nmod_poly_set_length(fq_nmod_poly_t poly, long newlen, const fq_nmod_ctx_t ctx) + # Sets the coefficients of ``poly`` beyond ``len`` to zero and + # sets the length of ``poly`` to ``len``. + + void fq_nmod_poly_clear(fq_nmod_poly_t poly, const fq_nmod_ctx_t ctx) + # Clears the given polynomial, releasing any memory used. It must + # be reinitialised in order to be used again. + + void _fq_nmod_poly_normalise(fq_nmod_poly_t poly, const fq_nmod_ctx_t ctx) + # Sets the length of ``poly`` so that the top coefficient is + # non-zero. If all coefficients are zero, the length is set to + # zero. This function is mainly used internally, as all functions + # guarantee normalisation. + + void _fq_nmod_poly_normalise2(const fq_nmod_struct *poly, long *length, const fq_nmod_ctx_t ctx) + # Sets the length ``length`` of ``(poly,length)`` so that the + # top coefficient is non-zero. If all coefficients are zero, the + # length is set to zero. This function is mainly used internally, as + # all functions guarantee normalisation. + + void fq_nmod_poly_truncate(fq_nmod_poly_t poly, long newlen, const fq_nmod_ctx_t ctx) + # Truncates the polynomial to length at most ``n``. + + void fq_nmod_poly_set_trunc(fq_nmod_poly_t poly1, fq_nmod_poly_t poly2, long newlen, const fq_nmod_ctx_t ctx) + # Sets ``poly1`` to ``poly2`` truncated to length `n`. + + void _fq_nmod_poly_reverse(fq_nmod_struct* output, const fq_nmod_struct* input, long len, long m, const fq_nmod_ctx_t ctx) + # Sets ``output`` to the reverse of ``input``, which is of + # length ``len``, but thinking of it as a polynomial of + # length ``m``, notionally zero-padded if necessary. The + # length ``m`` must be non-negative, but there are no other + # restrictions. The polynomial ``output`` must have space for + # ``m`` coefficients. + + void fq_nmod_poly_reverse(fq_nmod_poly_t output, const fq_nmod_poly_t input, long m, const fq_nmod_ctx_t ctx) + # Sets ``output`` to the reverse of ``input``, thinking of it + # as a polynomial of length ``m``, notionally zero-padded if + # necessary). The length ``m`` must be non-negative, but there + # are no other restrictions. The output polynomial will be set to + # length ``m`` and then normalised. + + long fq_nmod_poly_degree(const fq_nmod_poly_t poly, const fq_nmod_ctx_t ctx) + # Returns the degree of the polynomial ``poly``. + + long fq_nmod_poly_length(const fq_nmod_poly_t poly, const fq_nmod_ctx_t ctx) + # Returns the length of the polynomial ``poly``. + + fq_nmod_struct * fq_nmod_poly_lead(const fq_nmod_poly_t poly, const fq_nmod_ctx_t ctx) + # Returns a pointer to the leading coefficient of ``poly``, or + # ``NULL`` if ``poly`` is the zero polynomial. + + void fq_nmod_poly_randtest(fq_nmod_poly_t f, flint_rand_t state, long len, const fq_nmod_ctx_t ctx) + # Sets `f` to a random polynomial of length at most ``len`` + # with entries in the field described by ``ctx``. + + void fq_nmod_poly_randtest_not_zero(fq_nmod_poly_t f, flint_rand_t state, long len, const fq_nmod_ctx_t ctx) + # Same as ``fq_nmod_poly_randtest`` but guarantees that the polynomial + # is not zero. + + void fq_nmod_poly_randtest_monic(fq_nmod_poly_t f, flint_rand_t state, long len, const fq_nmod_ctx_t ctx) + # Sets `f` to a random monic polynomial of length ``len`` with + # entries in the field described by ``ctx``. + + void fq_nmod_poly_randtest_irreducible(fq_nmod_poly_t f, flint_rand_t state, long len, const fq_nmod_ctx_t ctx) + # Sets `f` to a random monic, irreducible polynomial of length + # ``len`` with entries in the field described by ``ctx``. + + void _fq_nmod_poly_set(fq_nmod_struct *rop, const fq_nmod_struct *op, long len, const fq_nmod_ctx_t ctx) + # Sets ``(rop, len``) to ``(op, len)``. + + void fq_nmod_poly_set(fq_nmod_poly_t poly1, const fq_nmod_poly_t poly2, const fq_nmod_ctx_t ctx) + # Sets the polynomial ``poly1`` to the polynomial ``poly2``. + + void fq_nmod_poly_set_fq_nmod(fq_nmod_poly_t poly, const fq_nmod_t c, const fq_nmod_ctx_t ctx) + # Sets the polynomial ``poly`` to ``c``. + + void fq_nmod_poly_set_fmpz_mod_poly(fq_nmod_poly_t rop, const fmpz_mod_poly_t op, const fq_nmod_ctx_t ctx) + # Sets the polynomial ``rop`` to the polynomial ``op`` + + void fq_nmod_poly_set_nmod_poly(fq_nmod_poly_t rop, const nmod_poly_t op, const fq_nmod_ctx_t ctx) + # Sets the polynomial ``rop`` to the polynomial ``op`` + + void fq_nmod_poly_swap(fq_nmod_poly_t op1, fq_nmod_poly_t op2, const fq_nmod_ctx_t ctx) + # Swaps the two polynomials ``op1`` and ``op2``. + + void _fq_nmod_poly_zero(fq_nmod_struct *rop, long len, const fq_nmod_ctx_t ctx) + # Sets ``(rop, len)`` to the zero polynomial. + + void fq_nmod_poly_zero(fq_nmod_poly_t poly, const fq_nmod_ctx_t ctx) + # Sets ``poly`` to the zero polynomial. + + void fq_nmod_poly_one(fq_nmod_poly_t poly, const fq_nmod_ctx_t ctx) + # Sets ``poly`` to the constant polynomial `1`. + + void fq_nmod_poly_gen(fq_nmod_poly_t poly, const fq_nmod_ctx_t ctx) + # Sets ``poly`` to the polynomial `x`. + + void fq_nmod_poly_make_monic(fq_nmod_poly_t rop, const fq_nmod_poly_t op, const fq_nmod_ctx_t ctx) + # Sets ``rop`` to ``op``, normed to have leading coefficient 1. + + void _fq_nmod_poly_make_monic(fq_nmod_struct *rop, const fq_nmod_struct *op, long length, const fq_nmod_ctx_t ctx) + # Sets ``rop`` to ``(op,length)``, normed to have leading coefficient 1. + # Assumes that ``rop`` has enough space for the polynomial, assumes that + # ``op`` is not zero (and thus has an invertible leading coefficient). + + void fq_nmod_poly_get_coeff(fq_nmod_t x, const fq_nmod_poly_t poly, long n, const fq_nmod_ctx_t ctx) + # Sets `x` to the coefficient of `X^n` in ``poly``. + + void fq_nmod_poly_set_coeff(fq_nmod_poly_t poly, long n, const fq_nmod_t x, const fq_nmod_ctx_t ctx) + # Sets the coefficient of `X^n` in ``poly`` to `x`. + + void fq_nmod_poly_set_coeff_fmpz(fq_nmod_poly_t poly, long n, const fmpz_t x, const fq_nmod_ctx_t ctx) + # Sets the coefficient of `X^n` in the polynomial to `x`, + # assuming `n \geq 0`. + + int fq_nmod_poly_equal(const fq_nmod_poly_t poly1, const fq_nmod_poly_t poly2, const fq_nmod_ctx_t ctx) + # Returns nonzero if the two polynomials ``poly1`` and ``poly2`` + # are equal, otherwise return zero. + + int fq_nmod_poly_equal_trunc(const fq_nmod_poly_t poly1, const fq_nmod_poly_t poly2, long n, const fq_nmod_ctx_t ctx) + # Notionally truncate ``poly1`` and ``poly2`` to length `n` and + # return nonzero if they are equal, otherwise return zero. + + int fq_nmod_poly_is_zero(const fq_nmod_poly_t poly, const fq_nmod_ctx_t ctx) + # Returns whether the polynomial ``poly`` is the zero polynomial. + + int fq_nmod_poly_is_one(const fq_nmod_poly_t op, const fq_nmod_ctx_t ctx) + # Returns whether the polynomial ``poly`` is equal + # to the constant polynomial `1`. + + int fq_nmod_poly_is_gen(const fq_nmod_poly_t op, const fq_nmod_ctx_t ctx) + # Returns whether the polynomial ``poly`` is equal + # to the polynomial `x`. + + int fq_nmod_poly_is_unit(const fq_nmod_poly_t op, const fq_nmod_ctx_t ctx) + # Returns whether the polynomial ``poly`` is a unit in the polynomial + # ring `\mathbf{F}_q[X]`, i.e. if it has degree `0` and is non-zero. + + int fq_nmod_poly_equal_fq_nmod(const fq_nmod_poly_t poly, const fq_nmod_t c, const fq_nmod_ctx_t ctx) + # Returns whether the polynomial ``poly`` is equal the (constant) + # `\mathbf{F}_q` element ``c`` + + void _fq_nmod_poly_add(fq_nmod_struct *res, const fq_nmod_struct *poly1, long len1, const fq_nmod_struct *poly2, long len2, const fq_nmod_ctx_t ctx) + # Sets ``res`` to the sum of ``(poly1,len1)`` and ``(poly2,len2)``. + + void fq_nmod_poly_add(fq_nmod_poly_t res, const fq_nmod_poly_t poly1, const fq_nmod_poly_t poly2, const fq_nmod_ctx_t ctx) + # Sets ``res`` to the sum of ``poly1`` and ``poly2``. + + void fq_nmod_poly_add_si(fq_nmod_poly_t res, const fq_nmod_poly_t poly1, long c, const fq_nmod_ctx_t ctx) + # Sets ``res`` to the sum of ``poly1`` and ``c``. + + void fq_nmod_poly_add_series(fq_nmod_poly_t res, const fq_nmod_poly_t poly1, const fq_nmod_poly_t poly2, long n, const fq_nmod_ctx_t ctx) + # Notionally truncate ``poly1`` and ``poly2`` to length ``n`` and set + # ``res`` to the sum. + + void _fq_nmod_poly_sub(fq_nmod_struct *res, const fq_nmod_struct *poly1, long len1, const fq_nmod_struct *poly2, long len2, const fq_nmod_ctx_t ctx) + # Sets ``res`` to the difference of ``(poly1,len1)`` and + # ``(poly2,len2)``. + + void fq_nmod_poly_sub(fq_nmod_poly_t res, const fq_nmod_poly_t poly1, const fq_nmod_poly_t poly2, const fq_nmod_ctx_t ctx) + # Sets ``res`` to the difference of ``poly1`` and ``poly2``. + + void fq_nmod_poly_sub_series(fq_nmod_poly_t res, const fq_nmod_poly_t poly1, const fq_nmod_poly_t poly2, long n, const fq_nmod_ctx_t ctx) + # Notionally truncate ``poly1`` and ``poly2`` to length ``n`` and set + # ``res`` to the difference. + + void _fq_nmod_poly_neg(fq_nmod_struct *rop, const fq_nmod_struct *op, long len, const fq_nmod_ctx_t ctx) + # Sets ``rop`` to the additive inverse of ``(poly,len)``. + + void fq_nmod_poly_neg(fq_nmod_poly_t res, const fq_nmod_poly_t poly, const fq_nmod_ctx_t ctx) + # Sets ``res`` to the additive inverse of ``poly``. + + void _fq_nmod_poly_scalar_mul_fq_nmod(fq_nmod_struct *rop, const fq_nmod_struct *op, long len, const fq_nmod_t x, const fq_nmod_ctx_t ctx) + # Sets ``(rop,len)`` to the product of ``(op,len)`` by the + # scalar ``x``, in the context defined by ``ctx``. + + void fq_nmod_poly_scalar_mul_fq_nmod(fq_nmod_poly_t rop, const fq_nmod_poly_t op, const fq_nmod_t x, const fq_nmod_ctx_t ctx) + # Sets ``rop`` to the product of ``op`` by the scalar ``x``, in the context + # defined by ``ctx``. + + void _fq_nmod_poly_scalar_addmul_fq_nmod(fq_nmod_struct *rop, const fq_nmod_struct *op, long len, const fq_nmod_t x, const fq_nmod_ctx_t ctx) + # Adds to ``(rop,len)`` the product of ``(op,len)`` by the + # scalar ``x``, in the context defined by ``ctx``. + # In particular, assumes the same length for ``op`` and + # ``rop``. + + void fq_nmod_poly_scalar_addmul_fq_nmod(fq_nmod_poly_t rop, const fq_nmod_poly_t op, const fq_nmod_t x, const fq_nmod_ctx_t ctx) + # Adds to ``rop`` the product of ``op`` by the + # scalar ``x``, in the context defined by ``ctx``. + + void _fq_nmod_poly_scalar_submul_fq_nmod(fq_nmod_struct *rop, const fq_nmod_struct *op, long len, const fq_nmod_t x, const fq_nmod_ctx_t ctx) + # Subtracts from ``(rop,len)`` the product of ``(op,len)`` by the + # scalar ``x``, in the context defined by ``ctx``. + # In particular, assumes the same length for ``op`` and + # ``rop``. + + void fq_nmod_poly_scalar_submul_fq_nmod(fq_nmod_poly_t rop, const fq_nmod_poly_t op, const fq_nmod_t x, const fq_nmod_ctx_t ctx) + # Subtracts from ``rop`` the product of ``op`` by the + # scalar ``x``, in the context defined by ``ctx``. + + void _fq_nmod_poly_scalar_div_fq(fq_nmod_struct *rop, const fq_nmod_struct *op, long len, const fq_nmod_t x, const fq_nmod_ctx_t ctx) + # Sets ``(rop,len)`` to the quotient of ``(op,len)`` by the + # scalar ``x``, in the context defined by ``ctx``. An exception is raised + # if ``x`` is zero. + + void fq_nmod_poly_scalar_div_fq(fq_nmod_poly_t rop, const fq_nmod_poly_t op, const fq_nmod_t x, const fq_nmod_ctx_t ctx) + # Sets ``rop`` to the quotient of ``op`` by the scalar ``x``, in the context + # defined by ``ctx``. An exception is raised if ``x`` is zero. + + void _fq_nmod_poly_mul_classical(fq_nmod_struct *rop, const fq_nmod_struct *op1, long len1, const fq_nmod_struct *op2, long len2, const fq_nmod_ctx_t ctx) + # Sets ``(rop, len1 + len2 - 1)`` to the product of ``(op1, len1)`` + # and ``(op2, len2)``, assuming that ``len1`` is at least ``len2`` + # and neither is zero. + # Permits zero padding. Does not support aliasing of ``rop`` + # with either ``op1`` or ``op2``. + + void fq_nmod_poly_mul_classical(fq_nmod_poly_t rop, const fq_nmod_poly_t op1, const fq_nmod_poly_t op2, const fq_nmod_ctx_t ctx) + # Sets ``rop`` to the product of ``op1`` and ``op2`` + # using classical polynomial multiplication. + + void _fq_nmod_poly_mul_reorder(fq_nmod_struct *rop, const fq_nmod_struct *op1, long len1, const fq_nmod_struct *op2, long len2, const fq_nmod_ctx_t ctx) + # Sets ``(rop, len1 + len2 - 1)`` to the product of ``(op1, len1)`` + # and ``(op2, len2)``, assuming that ``len1`` and ``len2`` are + # non-zero. + # Permits zero padding. Supports aliasing. + + void fq_nmod_poly_mul_reorder(fq_nmod_poly_t rop, const fq_nmod_poly_t op1, const fq_nmod_poly_t op2, const fq_nmod_ctx_t ctx) + # Sets ``rop`` to the product of ``op1`` and ``op2``, + # reordering the two indeterminates `X` and `Y` when viewing + # the polynomials as elements of `\mathbf{F}_p[X,Y]`. + # Suppose `\mathbf{F}_q = \mathbf{F}_p[X]/ (f(X))` and recall + # that elements of `\mathbf{F}_q` are internally represented + # by elements of type ``fmpz_poly``. For small degree extensions + # but polynomials in `\mathbf{F}_q[Y]` of large degree `n`, we + # change the representation to + # .. math :: + # \begin{split} + # g(Y) & = \sum_{i=0}^{n} a_i(X) Y^i \\ + # & = \sum_{j=0}^{d} \sum_{i=0}^{n} \text{Coeff}(a_i(X), j) Y^i. + # \end{split} + # This allows us to use a poor algorithm (such as classical multiplication) + # in the `X`-direction and leverage the existing fast integer + # multiplication routines in the `Y`-direction where the polynomial + # degree `n` is large. + + void _fq_nmod_poly_mul_univariate(fq_nmod_struct *rop, const fq_nmod_struct *op1, long len1, const fq_nmod_struct *op2, long len2, const fq_nmod_ctx_t ctx) + # Sets ``(rop, len1 + len2 - 1)`` to the product of ``(op1, len1)`` + # and ``(op2, len2)``. + # Permits zero padding and makes no assumptions on ``len1`` and ``len2``. + # Supports aliasing. + + void fq_nmod_poly_mul_univariate(fq_nmod_poly_t rop, const fq_nmod_poly_t op1, const fq_nmod_poly_t op2, const fq_nmod_ctx_t ctx) + # Sets ``rop`` to the product of ``op1`` and ``op2`` + # using a bivariate to univariate transformation and reducing + # this problem to multiplying two univariate polynomials. + + void _fq_nmod_poly_mul_KS(fq_nmod_struct *rop, const fq_nmod_struct *op1, long len1, const fq_nmod_struct *op2, long len2, const fq_nmod_ctx_t ctx) + # Sets ``(rop, len1 + len2 - 1)`` to the product of ``(op1, len1)`` + # and ``(op2, len2)``. + # Permits zero padding and places no assumptions on the + # lengths ``len1`` and ``len2``. Supports aliasing. + + void fq_nmod_poly_mul_KS(fq_nmod_poly_t rop, const fq_nmod_poly_t op1, const fq_nmod_poly_t op2, const fq_nmod_ctx_t ctx) + # Sets ``rop`` to the product of ``op1`` and ``op2`` + # using Kronecker substitution, that is, by encoding each + # coefficient in `\mathbf{F}_{q}` as an integer and reducing + # this problem to multiplying two polynomials over the integers. + + void _fq_nmod_poly_mul(fq_nmod_struct *rop, const fq_nmod_struct *op1, long len1, const fq_nmod_struct *op2, long len2, const fq_nmod_ctx_t ctx) + # Sets ``(rop, len1 + len2 - 1)`` to the product of ``(op1, len1)`` + # and ``(op2, len2)``, choosing an appropriate algorithm. + # Permits zero padding. Does not support aliasing. + + void fq_nmod_poly_mul(fq_nmod_poly_t rop, const fq_nmod_poly_t op1, const fq_nmod_poly_t op2, const fq_nmod_ctx_t ctx) + # Sets ``rop`` to the product of ``op1`` and ``op2``, + # choosing an appropriate algorithm. + + void _fq_nmod_poly_mullow_classical(fq_nmod_struct *rop, const fq_nmod_struct *op1, long len1, const fq_nmod_struct *op2, long len2, long n, const fq_nmod_ctx_t ctx) + # Sets ``(rop, n)`` to the first `n` coefficients of + # ``(op1, len1)`` multiplied by ``(op2, len2)``. + # Assumes ``0 < n <= len1 + len2 - 1``. Assumes neither + # ``len1`` nor ``len2`` is zero. + + void fq_nmod_poly_mullow_classical(fq_nmod_poly_t rop, const fq_nmod_poly_t op1, const fq_nmod_poly_t op2, long n, const fq_nmod_ctx_t ctx) + # Sets ``rop`` to the product of ``op1`` and ``op2``, + # computed using the classical or schoolbook method. + + void _fq_nmod_poly_mullow_univariate(fq_nmod_struct *rop, const fq_nmod_struct *op1, long len1, const fq_nmod_struct *op2, long len2, long n, const fq_nmod_ctx_t ctx) + # Sets ``(rop, n)`` to the lowest `n` coefficients of the product of + # ``(op1, len1)`` and ``(op2, len2)``, computed using a + # bivariate to univariate transformation. + # Assumes that ``len1`` and ``len2`` are positive, but does allow + # for the polynomials to be zero-padded. The polynomials may be zero, + # too. Assumes `n` is positive. Supports aliasing between ``rop``, + # ``op1`` and ``op2``. + + void fq_nmod_poly_mullow_univariate(fq_nmod_poly_t rop, const fq_nmod_poly_t op1, const fq_nmod_poly_t op2, long n, const fq_nmod_ctx_t ctx) + # Sets ``rop`` to the lowest `n` coefficients of the product of + # ``poly1`` and ``poly2``, computed using a bivariate to + # univariate transformation. + + void _fq_nmod_poly_mullow_KS(fq_nmod_struct *rop, const fq_nmod_struct *op1, long len1, const fq_nmod_struct *op2, long len2, long n, const fq_nmod_ctx_t ctx) + # Sets ``(rop, n)`` to the lowest `n` coefficients of the product of + # ``(op1, len1)`` and ``(op2, len2)``. + # Assumes that ``len1`` and ``len2`` are positive, but does allow + # for the polynomials to be zero-padded. The polynomials may be zero, + # too. Assumes `n` is positive. Supports aliasing between ``rop``, + # ``op1`` and ``op2``. + + void fq_nmod_poly_mullow_KS(fq_nmod_poly_t rop, const fq_nmod_poly_t op1, const fq_nmod_poly_t op2, long n, const fq_nmod_ctx_t ctx) + # Sets ``rop`` to the product of ``op1`` and ``op2``. + + void _fq_nmod_poly_mullow(fq_nmod_struct *rop, const fq_nmod_struct *op1, long len1, const fq_nmod_struct *op2, long len2, long n, const fq_nmod_ctx_t ctx) + # Sets ``(rop, n)`` to the lowest `n` coefficients of the product of + # ``(op1, len1)`` and ``(op2, len2)``. + # Assumes ``0 < n <= len1 + len2 - 1``. Allows for zero-padding in + # the inputs. Does not support aliasing between the inputs and the output. + + void fq_nmod_poly_mullow(fq_nmod_poly_t rop, const fq_nmod_poly_t op1, const fq_nmod_poly_t op2, long n, const fq_nmod_ctx_t ctx) + # Sets ``rop`` to the lowest `n` coefficients of the product of + # ``op1`` and ``op2``. + + void _fq_nmod_poly_mulhigh_classical(fq_nmod_struct *res, const fq_nmod_struct *poly1, long len1, const fq_nmod_struct *poly2, long len2, long start, const fq_nmod_ctx_t ctx) + # Computes the product of ``(poly1, len1)`` and ``(poly2, len2)`` + # and writes the coefficients from ``start`` onwards into the high + # coefficients of ``res``, the remaining coefficients being arbitrary + # but reduced. Assumes that ``len1 >= len2 > 0``. Aliasing of inputs + # and output is not permitted. Algorithm is classical multiplication. + + void fq_nmod_poly_mulhigh_classical(fq_nmod_poly_t res, const fq_nmod_poly_t poly1, const fq_nmod_poly_t poly2, long start, const fq_nmod_ctx_t ctx) + # Computes the product of ``poly1`` and ``poly2`` and writes the + # coefficients from ``start`` onwards into the high coefficients of + # ``res``, the remaining coefficients being arbitrary but reduced. + # Algorithm is classical multiplication. + + void _fq_nmod_poly_mulhigh(fq_nmod_struct *res, const fq_nmod_struct *poly1, long len1, const fq_nmod_struct *poly2, long len2, long start, fq_nmod_ctx_t ctx) + # Computes the product of ``(poly1, len1)`` and ``(poly2, len2)`` + # and writes the coefficients from ``start`` onwards into the high + # coefficients of ``res``, the remaining coefficients being arbitrary + # but reduced. Assumes that ``len1 >= len2 > 0``. Aliasing of inputs + # and output is not permitted. + + void fq_nmod_poly_mulhigh(fq_nmod_poly_t res, const fq_nmod_poly_t poly1, const fq_nmod_poly_t poly2, long start, const fq_nmod_ctx_t ctx) + # Computes the product of ``poly1`` and ``poly2`` and writes the + # coefficients from ``start`` onwards into the high coefficients of + # ``res``, the remaining coefficients being arbitrary but reduced. + + void _fq_nmod_poly_mulmod(fq_nmod_struct* res, const fq_nmod_struct* poly1, long len1, const fq_nmod_struct* poly2, long len2, const fq_nmod_struct* f, long lenf, const fq_nmod_ctx_t ctx) + # Sets ``res`` to the remainder of the product of ``poly1`` + # and ``poly2`` upon polynomial division by ``f``. + # It is required that ``len1 + len2 - lenf > 0``, which is + # equivalent to requiring that the result will actually be + # reduced. Otherwise, simply use ``_fq_nmod_poly_mul`` instead. + # Aliasing of ``f`` and ``res`` is not permitted. + + void fq_nmod_poly_mulmod(fq_nmod_poly_t res, const fq_nmod_poly_t poly1, const fq_nmod_poly_t poly2, const fq_nmod_poly_t f, const fq_nmod_ctx_t ctx) + # Sets ``res`` to the remainder of the product of ``poly1`` + # and ``poly2`` upon polynomial division by ``f``. + + void _fq_nmod_poly_mulmod_preinv(fq_nmod_struct* res, const fq_nmod_struct* poly1, long len1, const fq_nmod_struct* poly2, long len2, const fq_nmod_struct* f, long lenf, const fq_nmod_struct* finv, long lenfinv, const fq_nmod_ctx_t ctx) + # Sets ``res`` to the remainder of the product of ``poly1`` + # and ``poly2`` upon polynomial division by ``f``. + # It is required that ``finv`` is the inverse of the reverse of + # ``f`` mod ``x^lenf``. + # Aliasing of ``res`` with any of the inputs is not permitted. + + void fq_nmod_poly_mulmod_preinv(fq_nmod_poly_t res, const fq_nmod_poly_t poly1, const fq_nmod_poly_t poly2, const fq_nmod_poly_t f, const fq_nmod_poly_t finv, const fq_nmod_ctx_t ctx) + # Sets ``res`` to the remainder of the product of ``poly1`` + # and ``poly2`` upon polynomial division by ``f``. ``finv`` + # is the inverse of the reverse of ``f``. + + void _fq_nmod_poly_sqr_classical(fq_nmod_struct *rop, const fq_nmod_struct *op, long len, const fq_nmod_ctx_t ctx) + # Sets ``(rop, 2*len - 1)`` to the square of ``(op, len)``, + # assuming that ``(op,len)`` is not zero and using classical + # polynomial multiplication. + # Permits zero padding. Does not support aliasing of ``rop`` + # with either ``op1`` or ``op2``. + + void fq_nmod_poly_sqr_classical(fq_nmod_poly_t rop, const fq_nmod_poly_t op, const fq_nmod_ctx_t ctx) + # Sets ``rop`` to the square of ``op`` using classical + # polynomial multiplication. + + void _fq_nmod_poly_sqr_KS(fq_nmod_struct *rop, const fq_nmod_struct *op, long len, const fq_nmod_ctx_t ctx) + # Sets ``(rop, 2*len - 1)`` to the square of ``(op, len)``. + # Permits zero padding and places no assumptions on the + # lengths ``len1`` and ``len2``. Supports aliasing. + + void fq_nmod_poly_sqr_KS(fq_nmod_poly_t rop, const fq_nmod_poly_t op, const fq_nmod_ctx_t ctx) + # Sets ``rop`` to the square ``op`` using Kronecker substitution, + # that is, by encoding each coefficient in `\mathbf{F}_{q}` as an integer + # and reducing this problem to multiplying two polynomials over the integers. + + void _fq_nmod_poly_sqr(fq_nmod_struct *rop, const fq_nmod_struct *op, long len, const fq_nmod_ctx_t ctx) + # Sets ``(rop, 2* len - 1)`` to the square of ``(op, len)``, + # choosing an appropriate algorithm. + # Permits zero padding. Does not support aliasing. + + void fq_nmod_poly_sqr(fq_nmod_poly_t rop, const fq_nmod_poly_t op, const fq_nmod_ctx_t ctx) + # Sets ``rop`` to the square of ``op``, + # choosing an appropriate algorithm. + + void _fq_nmod_poly_pow(fq_nmod_struct *rop, const fq_nmod_struct *op, long len, unsigned long e, const fq_nmod_ctx_t ctx) + # Sets ``rop = op^e``, assuming that ``e, len > 0`` and that + # ``rop`` has space for ``e*(len - 1) + 1`` coefficients. Does + # not support aliasing. + + void fq_nmod_poly_pow(fq_nmod_poly_t rop, const fq_nmod_poly_t op, unsigned long e, const fq_nmod_ctx_t ctx) + # Computes ``rop = op^e``. If `e` is zero, returns one, + # so that in particular ``0^0 = 1``. + + void _fq_nmod_poly_powmod_ui_binexp(fq_nmod_struct* res, const fq_nmod_struct* poly, unsigned long e, const fq_nmod_struct* f, long lenf, const fq_nmod_ctx_t ctx) + # Sets ``res`` to ``poly`` raised to the power ``e`` modulo + # ``f``, using binary exponentiation. We require ``e > 0``. + # We require ``lenf > 1``. It is assumed that ``poly`` is + # already reduced modulo ``f`` and zero-padded as necessary to + # have length exactly ``lenf - 1``. The output ``res`` must + # have room for ``lenf - 1`` coefficients. + + void fq_nmod_poly_powmod_ui_binexp(fq_nmod_poly_t res, const fq_nmod_poly_t poly, unsigned long e, const fq_nmod_poly_t f, const fq_nmod_ctx_t ctx) + # Sets ``res`` to ``poly`` raised to the power ``e`` modulo + # ``f``, using binary exponentiation. We require ``e >= 0``. + + void _fq_nmod_poly_powmod_ui_binexp_preinv(fq_nmod_struct* res, const fq_nmod_struct* poly, unsigned long e, const fq_nmod_struct* f, long lenf, const fq_nmod_struct* finv, long lenfinv, const fq_nmod_ctx_t ctx) + # Sets ``res`` to ``poly`` raised to the power ``e`` modulo + # ``f``, using binary exponentiation. We require ``e > 0``. + # We require ``finv`` to be the inverse of the reverse of + # ``f``. + # We require ``lenf > 1``. It is assumed that ``poly`` is + # already reduced modulo ``f`` and zero-padded as necessary to + # have length exactly ``lenf - 1``. The output ``res`` must + # have room for ``lenf - 1`` coefficients. + + void fq_nmod_poly_powmod_ui_binexp_preinv(fq_nmod_poly_t res, const fq_nmod_poly_t poly, unsigned long e, const fq_nmod_poly_t f, const fq_nmod_poly_t finv, const fq_nmod_ctx_t ctx) + # Sets ``res`` to ``poly`` raised to the power ``e`` modulo + # ``f``, using binary exponentiation. We require ``e >= 0``. + # We require ``finv`` to be the inverse of the reverse of + # ``f``. + + void _fq_nmod_poly_powmod_fmpz_binexp(fq_nmod_struct* res, const fq_nmod_struct* poly, const fmpz_t e, const fq_nmod_struct* f, long lenf, const fq_nmod_ctx_t ctx) + # Sets ``res`` to ``poly`` raised to the power ``e`` modulo + # ``f``, using binary exponentiation. We require ``e > 0``. + # We require ``lenf > 1``. It is assumed that ``poly`` is + # already reduced modulo ``f`` and zero-padded as necessary to + # have length exactly ``lenf - 1``. The output ``res`` must + # have room for ``lenf - 1`` coefficients. + + void fq_nmod_poly_powmod_fmpz_binexp(fq_nmod_poly_t res, const fq_nmod_poly_t poly, const fmpz_t e, const fq_nmod_poly_t f, const fq_nmod_ctx_t ctx) + # Sets ``res`` to ``poly`` raised to the power ``e`` modulo + # ``f``, using binary exponentiation. We require ``e >= 0``. + + void _fq_nmod_poly_powmod_fmpz_binexp_preinv(fq_nmod_struct* res, const fq_nmod_struct* poly, const fmpz_t e, const fq_nmod_struct* f, long lenf, const fq_nmod_struct* finv, long lenfinv, const fq_nmod_ctx_t ctx) + # Sets ``res`` to ``poly`` raised to the power ``e`` modulo + # ``f``, using binary exponentiation. We require ``e > 0``. + # We require ``finv`` to be the inverse of the reverse of + # ``f``. + # We require ``lenf > 1``. It is assumed that ``poly`` is + # already reduced modulo ``f`` and zero-padded as necessary to + # have length exactly ``lenf - 1``. The output ``res`` must + # have room for ``lenf - 1`` coefficients. + + void fq_nmod_poly_powmod_fmpz_binexp_preinv(fq_nmod_poly_t res, const fq_nmod_poly_t poly, const fmpz_t e, const fq_nmod_poly_t f, const fq_nmod_poly_t finv, const fq_nmod_ctx_t ctx) + # Sets ``res`` to ``poly`` raised to the power ``e`` modulo + # ``f``, using binary exponentiation. We require ``e >= 0``. + # We require ``finv`` to be the inverse of the reverse of + # ``f``. + + void _fq_nmod_poly_powmod_fmpz_sliding_preinv(fq_nmod_struct* res, const fq_nmod_struct* poly, const fmpz_t e, unsigned long k, const fq_nmod_struct* f, long lenf, const fq_nmod_struct* finv, long lenfinv, const fq_nmod_ctx_t ctx) + # Sets ``res`` to ``poly`` raised to the power ``e`` modulo + # ``f``, using sliding-window exponentiation with window size + # ``k``. We require ``e > 0``. We require ``finv`` to be + # the inverse of the reverse of ``f``. If ``k`` is set to + # zero, then an "optimum" size will be selected automatically base + # on ``e``. + # We require ``lenf > 1``. It is assumed that ``poly`` is + # already reduced modulo ``f`` and zero-padded as necessary to + # have length exactly ``lenf - 1``. The output ``res`` must + # have room for ``lenf - 1`` coefficients. + + void fq_nmod_poly_powmod_fmpz_sliding_preinv(fq_nmod_poly_t res, const fq_nmod_poly_t poly, const fmpz_t e, unsigned long k, const fq_nmod_poly_t f, const fq_nmod_poly_t finv, const fq_nmod_ctx_t ctx) + # Sets ``res`` to ``poly`` raised to the power ``e`` modulo + # ``f``, using sliding-window exponentiation with window size + # ``k``. We require ``e >= 0``. We require ``finv`` to be + # the inverse of the reverse of ``f``. If ``k`` is set to + # zero, then an "optimum" size will be selected automatically base + # on ``e``. + + void _fq_nmod_poly_powmod_x_fmpz_preinv(fq_nmod_struct * res, const fmpz_t e, const fq_nmod_struct * f, long lenf, const fq_nmod_struct * finv, long lenfinv, const fq_nmod_ctx_t ctx) + # Sets ``res`` to ``x`` raised to the power ``e`` modulo ``f``, + # using sliding window exponentiation. We require ``e > 0``. + # We require ``finv`` to be the inverse of the reverse of ``f``. + # We require ``lenf > 2``. The output ``res`` must have room for + # ``lenf - 1`` coefficients. + + void fq_nmod_poly_powmod_x_fmpz_preinv(fq_nmod_poly_t res, const fmpz_t e, const fq_nmod_poly_t f, const fq_nmod_poly_t finv, const fq_nmod_ctx_t ctx) + # Sets ``res`` to ``x`` raised to the power ``e`` + # modulo ``f``, using sliding window exponentiation. We require + # ``e >= 0``. We require ``finv`` to be the inverse of the reverse of + # ``f``. + + void _fq_nmod_poly_pow_trunc_binexp(fq_nmod_struct * res, const fq_nmod_struct * poly, unsigned long e, long trunc, const fq_nmod_ctx_t ctx) + # Sets ``res`` to the low ``trunc`` coefficients of ``poly`` + # (assumed to be zero padded if necessary to length ``trunc``) to + # the power ``e``. This is equivalent to doing a powering followed + # by a truncation. We require that ``res`` has enough space for + # ``trunc`` coefficients, that ``trunc > 0`` and that + # ``e > 1``. Aliasing is not permitted. Uses the binary + # exponentiation method. + + void fq_nmod_poly_pow_trunc_binexp(fq_nmod_poly_t res, const fq_nmod_poly_t poly, unsigned long e, long trunc, const fq_nmod_ctx_t ctx) + # Sets ``res`` to the low ``trunc`` coefficients of ``poly`` + # to the power ``e``. This is equivalent to doing a powering + # followed by a truncation. Uses the binary exponentiation method. + + void _fq_nmod_poly_pow_trunc(fq_nmod_struct * res, const fq_nmod_struct * poly, unsigned long e, long trunc, const fq_nmod_ctx_t mod) + # Sets ``res`` to the low ``trunc`` coefficients of ``poly`` + # (assumed to be zero padded if necessary to length ``trunc``) to + # the power ``e``. This is equivalent to doing a powering followed + # by a truncation. We require that ``res`` has enough space for + # ``trunc`` coefficients, that ``trunc > 0`` and that + # ``e > 1``. Aliasing is not permitted. + + void fq_nmod_poly_pow_trunc(fq_nmod_poly_t res, const fq_nmod_poly_t poly, unsigned long e, long trunc, const fq_nmod_ctx_t ctx) + # Sets ``res`` to the low ``trunc`` coefficients of ``poly`` + # to the power ``e``. This is equivalent to doing a powering + # followed by a truncation. + + void _fq_nmod_poly_shift_left(fq_nmod_struct *rop, const fq_nmod_struct *op, long len, long n, const fq_nmod_ctx_t ctx) + # Sets ``(rop, len + n)`` to ``(op, len)`` shifted left by + # `n` coefficients. + # Inserts zero coefficients at the lower end. Assumes that + # ``len`` and `n` are positive, and that ``rop`` fits + # ``len + n`` elements. Supports aliasing between ``rop`` and + # ``op``. + + void fq_nmod_poly_shift_left(fq_nmod_poly_t rop, const fq_nmod_poly_t op, long n, const fq_nmod_ctx_t ctx) + # Sets ``rop`` to ``op`` shifted left by `n` coeffs. Zero + # coefficients are inserted. + + void _fq_nmod_poly_shift_right(fq_nmod_struct *rop, const fq_nmod_struct *op, long len, long n, const fq_nmod_ctx_t ctx) + # Sets ``(rop, len - n)`` to ``(op, len)`` shifted right by + # `n` coefficients. + # Assumes that ``len`` and `n` are positive, that ``len > n``, + # and that ``rop`` fits ``len - n`` elements. Supports + # aliasing between ``rop`` and ``op``, although in this case + # the top coefficients of ``op`` are not set to zero. + + void fq_nmod_poly_shift_right(fq_nmod_poly_t rop, const fq_nmod_poly_t op, long n, const fq_nmod_ctx_t ctx) + # Sets ``rop`` to ``op`` shifted right by `n` coefficients. + # If `n` is equal to or greater than the current length of + # ``op``, ``rop`` is set to the zero polynomial. + + long _fq_nmod_poly_hamming_weight(const fq_nmod_struct *op, long len, const fq_nmod_ctx_t ctx) + # Returns the number of non-zero entries in ``(op, len)``. + + long fq_nmod_poly_hamming_weight(const fq_nmod_poly_t op, const fq_nmod_ctx_t ctx) + # Returns the number of non-zero entries in the polynomial ``op``. + + void _fq_nmod_poly_divrem(fq_nmod_struct *Q, fq_nmod_struct *R, const fq_nmod_struct *A, long lenA, const fq_nmod_struct *B, long lenB, const fq_nmod_t invB, const fq_nmod_ctx_t ctx) + # Computes ``(Q, lenA - lenB + 1)``, ``(R, lenA)`` such that + # `A = B Q + R` with `0 \leq \operatorname{len}(R) < \operatorname{len}(B)`. + # Assumes that the leading coefficient of `B` is invertible + # and that ``invB`` is its inverse. + # Assumes that `\operatorname{len}(A), \operatorname{len}(B) > 0`. Allows zero-padding in + # ``(A, lenA)``. `R` and `A` may be aliased, but apart from + # this no aliasing of input and output operands is allowed. + + void fq_nmod_poly_divrem(fq_nmod_poly_t Q, fq_nmod_poly_t R, const fq_nmod_poly_t A, const fq_nmod_poly_t B, const fq_nmod_ctx_t ctx) + # Computes `Q`, `R` such that `A = B Q + R` with + # `0 \leq \operatorname{len}(R) < \operatorname{len}(B)`. + # Assumes that the leading coefficient of `B` is invertible. This can + # be taken for granted the context is for a finite field, that is, when + # `p` is prime and `f(X)` is irreducible. + + void fq_nmod_poly_divrem_f(fq_nmod_t f, fq_nmod_poly_t Q, fq_nmod_poly_t R, const fq_nmod_poly_t A, const fq_nmod_poly_t B, const fq_nmod_ctx_t ctx) + # Either finds a non-trivial factor `f` of the modulus of + # ``ctx``, or computes `Q`, `R` such that `A = B Q + R` and + # `0 \leq \operatorname{len}(R) < \operatorname{len}(B)`. + # If the leading coefficient of `B` is invertible, the division with + # remainder operation is carried out, `Q` and `R` are computed + # correctly, and `f` is set to `1`. Otherwise, `f` is set to a + # non-trivial factor of the modulus and `Q` and `R` are not touched. + # Assumes that `B` is non-zero. + + void _fq_nmod_poly_rem(fq_nmod_struct *R, const fq_nmod_struct *A, long lenA, const fq_nmod_struct *B, long lenB, const fq_nmod_t invB, const fq_nmod_ctx_t ctx) + # Sets ``R`` to the remainder of the division of ``(A,lenA)`` by + # ``(B,lenB)``. Assumes that the leading coefficient of ``(B,lenB)`` + # is invertible and that ``invB`` is its inverse. + + void fq_nmod_poly_rem(fq_nmod_poly_t R, const fq_nmod_poly_t A, const fq_nmod_poly_t B, const fq_nmod_ctx_t ctx) + # Sets ``R`` to the remainder of the division of ``A`` by + # ``B`` in the context described by ``ctx``. + + void _fq_nmod_poly_div(fq_nmod_struct *Q, const fq_nmod_struct *A, long lenA, const fq_nmod_struct *B, long lenB, const fq_nmod_t invB, const fq_nmod_ctx_t ctx) + # Notationally, computes `Q`, `R` such that `A = B Q + R` with `0 + # \leq \operatorname{len}(R) < \operatorname{len}(B)` but only sets ``(Q, lenA - lenB + 1)``. + # Allows zero-padding in `A` but not in `B`. Assumes that the leading coefficient of `B` is a + # unit. + + void fq_nmod_poly_div(fq_nmod_poly_t Q, const fq_nmod_poly_t A, const fq_nmod_poly_t B, const fq_nmod_ctx_t ctx) + # Notionally finds polynomials `Q` and `R` such that `A = B Q + R` with + # `\operatorname{len}(R) < \operatorname{len}(B)`, but returns only ``Q``. If `\operatorname{len}(B) = 0` an + # exception is raised. + + void _fq_nmod_poly_div_newton_n_preinv(fq_nmod_struct* Q, const fq_nmod_struct* A, long lenA, const fq_nmod_struct* B, long lenB, const fq_nmod_struct* Binv, long lenBinv, const fq_nmod_ctx_t ctx) + # Notionally computes polynomials `Q` and `R` such that `A = BQ + R` with + # `\operatorname{len}(R)` less than ``lenB``, where ``A`` is of length ``lenA`` + # and ``B`` is of length ``lenB``, but return only `Q`. + # We require that `Q` have space for ``lenA - lenB + 1`` coefficients + # and assume that the leading coefficient of `B` is a unit. Furthermore, we + # assume that `Binv` is the inverse of the reverse of `B` mod `x^{\operatorname{len}(B)}`. + # The algorithm used is to reverse the polynomials and divide the + # resulting power series, then reverse the result. + + void fq_nmod_poly_div_newton_n_preinv(fq_nmod_poly_t Q, const fq_nmod_poly_t A, const fq_nmod_poly_t B, const fq_nmod_poly_t Binv, const fq_nmod_ctx_t ctx) + # Notionally computes `Q` and `R` such that `A = BQ + R` with + # `\operatorname{len}(R) < \operatorname{len}(B)`, but returns only `Q`. + # We assume that the leading coefficient of `B` is a unit and that `Binv` is + # the inverse of the reverse of `B` mod `x^{\operatorname{len}(B)}`. + # It is required that the length of `A` is less than or equal to + # 2*the length of `B` - 2. + # The algorithm used is to reverse the polynomials and divide the + # resulting power series, then reverse the result. + + void _fq_nmod_poly_divrem_newton_n_preinv(fq_nmod_struct* Q, fq_nmod_struct* R, const fq_nmod_struct* A, long lenA, const fq_nmod_struct* B, long lenB, const fq_nmod_struct* Binv, long lenBinv, const fq_nmod_ctx_t ctx) + # Computes `Q` and `R` such that `A = BQ + R` with `\operatorname{len}(R)` less + # than ``lenB``, where `A` is of length ``lenA`` and `B` is of + # length ``lenB``. We require that `Q` have space for + # ``lenA - lenB + 1`` coefficients. Furthermore, we assume that `Binv` is + # the inverse of the reverse of `B` mod `x^{\operatorname{len}(B)}`. The algorithm + # used is to call :func:`div_newton_preinv` and then multiply out + # and compute the remainder. + + void fq_nmod_poly_divrem_newton_n_preinv(fq_nmod_poly_t Q, fq_nmod_poly_t R, const fq_nmod_poly_t A, const fq_nmod_poly_t B, const fq_nmod_poly_t Binv, const fq_nmod_ctx_t ctx) + # Computes `Q` and `R` such that `A = BQ + R` with `\operatorname{len}(R) < + # \operatorname{len}(B)`. We assume `Binv` is the inverse of the reverse of `B` + # mod `x^{\operatorname{len}(B)}`. + # It is required that the length of `A` is less than or equal to + # 2*the length of `B` - 2. + # The algorithm used is to call :func:`div_newton` and then + # multiply out and compute the remainder. + + void _fq_nmod_poly_inv_series_newton(fq_nmod_struct* Qinv, const fq_nmod_struct* Q, long n, const fq_nmod_t cinv, const fq_nmod_ctx_t ctx) + # Given ``Q`` of length ``n`` whose constant coefficient is + # invertible modulo the given modulus, find a polynomial ``Qinv`` + # of length ``n`` such that ``Q * Qinv`` is ``1`` modulo + # `x^n`. Requires ``n > 0``. This function can be viewed as + # inverting a power series via Newton iteration. + + void fq_nmod_poly_inv_series_newton(fq_nmod_poly_t Qinv, const fq_nmod_poly_t Q, long n, const fq_nmod_ctx_t ctx) + # Given ``Q`` find ``Qinv`` such that ``Q * Qinv`` is + # ``1`` modulo `x^n`. The constant coefficient of ``Q`` must + # be invertible modulo the modulus of ``Q``. An exception is + # raised if this is not the case or if ``n = 0``. This function + # can be viewed as inverting a power series via Newton iteration. + + void _fq_nmod_poly_inv_series(fq_nmod_struct* Qinv, const fq_nmod_struct* Q, long n, const fq_nmod_t cinv, const fq_nmod_ctx_t ctx) + # Given ``Q`` of length ``n`` whose constant coefficient is + # invertible modulo the given modulus, find a polynomial ``Qinv`` + # of length ``n`` such that ``Q * Qinv`` is ``1`` modulo + # `x^n`. Requires ``n > 0``. + + void fq_nmod_poly_inv_series(fq_nmod_poly_t Qinv, const fq_nmod_poly_t Q, long n, const fq_nmod_ctx_t ctx) + # Given ``Q`` find ``Qinv`` such that ``Q * Qinv`` is + # ``1`` modulo `x^n`. The constant coefficient of ``Q`` must + # be invertible modulo the modulus of ``Q``. An exception is + # raised if this is not the case or if ``n = 0``. + + void _fq_nmod_poly_div_series(fq_nmod_struct *Q, const fq_nmod_struct *A, mp_limb_signed_t Alen, const fq_nmod_struct *B, mp_limb_signed_t Blen, mp_limb_signed_t n, const fq_nmod_ctx_t ctx) + # Set ``(Q, n)`` to the quotient of the series ``(A, Alen``) and + # ``(B, Blen)`` assuming ``Alen, Blen <= n``. We assume the bottom + # coefficient of ``B`` is invertible. + + void fq_nmod_poly_div_series(fq_nmod_poly_t Q, const fq_nmod_poly_t A, const fq_nmod_poly_t B, long n, fq_nmod_ctx_t ctx) + # Set `Q` to the quotient of the series `A` by `B`, thinking of the series as + # though they were of length `n`. We assume that the bottom coefficient of + # `B` is invertible. + + void fq_nmod_poly_gcd(fq_nmod_poly_t rop, const fq_nmod_poly_t op1, const fq_nmod_poly_t op2, const fq_nmod_ctx_t ctx) + # Sets ``rop`` to the greatest common divisor of ``op1`` and + # ``op2``, using the either the Euclidean or HGCD algorithm. The + # GCD of zero polynomials is defined to be zero, whereas the GCD of + # the zero polynomial and some other polynomial `P` is defined to be + # `P`. Except in the case where the GCD is zero, the GCD `G` is made + # monic. + + long _fq_nmod_poly_gcd(fq_nmod_struct* G, const fq_nmod_struct* A, long lenA, const fq_nmod_struct* B, long lenB, const fq_nmod_ctx_t ctx) + # Computes the GCD of `A` of length ``lenA`` and `B` of length + # ``lenB``, where ``lenA >= lenB > 0`` and sets `G` to it. The + # length of the GCD `G` is returned by the function. No attempt is + # made to make the GCD monic. It is required that `G` have space for + # ``lenB`` coefficients. + + long _fq_nmod_poly_gcd_euclidean_f(fq_nmod_t f, fq_nmod_struct *G, const fq_nmod_struct *A, long lenA, const fq_nmod_struct *B, long lenB, const fq_nmod_ctx_t ctx) + # Either sets `f = 1` and `G` to the greatest common divisor of + # `(A,\operatorname{len}(A))` and `(B, \operatorname{len}(B))` and returns its length, or sets + # `f` to a non-trivial factor of the modulus of ``ctx`` and leaves + # the contents of the vector `(G, lenB)` undefined. + # Assumes that `\operatorname{len}(A) \geq \operatorname{len}(B) > 0` and that the vector `G` + # has space for sufficiently many coefficients. + + void fq_nmod_poly_gcd_euclidean_f(fq_nmod_t f, fq_nmod_poly_t G, const fq_nmod_poly_t A, const fq_nmod_poly_t B, const fq_nmod_ctx_t ctx) + # Either sets `f = 1` and `G` to the greatest common divisor of `A` + # and `B` or sets `f` to a factor of the modulus of ``ctx``. + + long _fq_nmod_poly_xgcd(fq_nmod_struct *G, fq_nmod_struct *S, fq_nmod_struct *T, const fq_nmod_struct *A, long lenA, const fq_nmod_struct *B, long lenB, const fq_nmod_ctx_t ctx) + # Computes the GCD of `A` and `B` together with cofactors `S` and `T` + # such that `S A + T B = G`. Returns the length of `G`. + # Assumes that `\operatorname{len}(A) \geq \operatorname{len}(B) \geq 1` and + # `(\operatorname{len}(A),\operatorname{len}(B)) \neq (1,1)`. + # No attempt is made to make the GCD monic. + # Requires that `G` have space for `\operatorname{len}(B)` coefficients. Writes + # `\operatorname{len}(B)-1` and `\operatorname{len}(A)-1` coefficients to `S` and `T`, respectively. + # Note that, in fact, `\operatorname{len}(S) \leq \max(\operatorname{len}(B) - \operatorname{len}(G), 1)` and + # `\operatorname{len}(T) \leq \max(\operatorname{len}(A) - \operatorname{len}(G), 1)`. + # No aliasing of input and output operands is permitted. + + void fq_nmod_poly_xgcd(fq_nmod_poly_t G, fq_nmod_poly_t S, fq_nmod_poly_t T, const fq_nmod_poly_t A, const fq_nmod_poly_t B, const fq_nmod_ctx_t ctx) + # Computes the GCD of `A` and `B`. The GCD of zero polynomials is + # defined to be zero, whereas the GCD of the zero polynomial and some other + # polynomial `P` is defined to be `P`. Except in the case where + # the GCD is zero, the GCD `G` is made monic. + # Polynomials ``S`` and ``T`` are computed such that + # ``S*A + T*B = G``. The length of ``S`` will be at most + # ``lenB`` and the length of ``T`` will be at most ``lenA``. + + long _fq_nmod_poly_xgcd_euclidean_f(fq_nmod_t f, fq_nmod_struct *G, fq_nmod_struct *S, fq_nmod_struct *T, const fq_nmod_struct *A, long lenA, const fq_nmod_struct *B, long lenB, const fq_nmod_ctx_t ctx) + # Either sets `f = 1` and computes the GCD of `A` and `B` together + # with cofactors `S` and `T` such that `S A + T B = G`; otherwise, + # sets `f` to a non-trivial factor of the modulus of ``ctx`` and + # leaves `G`, `S`, and `T` undefined. Returns the length of `G`. + # Assumes that `\operatorname{len}(A) \geq \operatorname{len}(B) \geq 1` and + # `(\operatorname{len}(A),\operatorname{len}(B)) \neq (1,1)`. + # No attempt is made to make the GCD monic. + # Requires that `G` have space for `\operatorname{len}(B)` coefficients. Writes + # `\operatorname{len}(B)-1` and `\operatorname{len}(A)-1` coefficients to `S` and `T`, respectively. + # Note that, in fact, `\operatorname{len}(S) \leq \max(\operatorname{len}(B) - \operatorname{len}(G), 1)` and + # `\operatorname{len}(T) \leq \max(\operatorname{len}(A) - \operatorname{len}(G), 1)`. + # No aliasing of input and output operands is permitted. + + void fq_nmod_poly_xgcd_euclidean_f(fq_nmod_t f, fq_nmod_poly_t G, fq_nmod_poly_t S, fq_nmod_poly_t T, const fq_nmod_poly_t A, const fq_nmod_poly_t B, const fq_nmod_ctx_t ctx) + # Either sets `f = 1` and computes the GCD of `A` and `B` or sets + # `f` to a non-trivial factor of the modulus of ``ctx``. + # If the GCD is computed, polynomials ``S`` and ``T`` are + # computed such that ``S*A + T*B = G``; otherwise, they are + # undefined. The length of ``S`` will be at most ``lenB`` and + # the length of ``T`` will be at most ``lenA``. + # The GCD of zero polynomials is defined to be zero, whereas the GCD + # of the zero polynomial and some other polynomial `P` is defined to + # be `P`. Except in the case where the GCD is zero, the GCD `G` is + # made monic. + + int _fq_nmod_poly_divides(fq_nmod_struct *Q, const fq_nmod_struct *A, long lenA, const fq_nmod_struct *B, long lenB, const fq_nmod_t invB, const fq_nmod_ctx_t ctx) + # Returns `1` if ``(B, lenB)`` divides ``(A, lenA)`` exactly and + # sets `Q` to the quotient, otherwise returns `0`. + # It is assumed that `\operatorname{len}(A) \geq \operatorname{len}(B) > 0` and that `Q` has space + # for `\operatorname{len}(A) - \operatorname{len}(B) + 1` coefficients. + # Aliasing of `Q` with either of the inputs is not permitted. + # This function is currently unoptimised and provided for convenience + # only. + + int fq_nmod_poly_divides(fq_nmod_poly_t Q, const fq_nmod_poly_t A, const fq_nmod_poly_t B, const fq_nmod_ctx_t ctx) + # Returns `1` if `B` divides `A` exactly and sets `Q` to the quotient, + # otherwise returns `0`. + # This function is currently unoptimised and provided for convenience + # only. + + void _fq_nmod_poly_derivative(fq_nmod_struct *rop, const fq_nmod_struct *op, long len, const fq_nmod_ctx_t ctx) + # Sets ``(rop, len - 1)`` to the derivative of ``(op, len)``. + # Also handles the cases where ``len`` is `0` or `1` correctly. + # Supports aliasing of ``rop`` and ``op``. + + void fq_nmod_poly_derivative(fq_nmod_poly_t rop, const fq_nmod_poly_t op, const fq_nmod_ctx_t ctx) + # Sets ``rop`` to the derivative of ``op``. + + void _fq_nmod_poly_invsqrt_series(fq_nmod_struct * g, const fq_nmod_struct * h, long n, fq_nmod_ctx_t mod) + # Set the first `n` terms of `g` to the series expansion of `1/\sqrt{h}`. + # It is assumed that `n > 0`, that `h` has constant term 1 and that `h` + # is zero-padded as necessary to length `n`. Aliasing is not permitted. + + void fq_nmod_poly_invsqrt_series(fq_nmod_poly_t g, const fq_nmod_poly_t h, long n, fq_nmod_ctx_t ctx) + # Set `g` to the series expansion of `1/\sqrt{h}` to order `O(x^n)`. + # It is assumed that `h` has constant term 1. + + void _fq_nmod_poly_sqrt_series(fq_nmod_struct * g, const fq_nmod_struct * h, long n, fq_nmod_ctx_t ctx) + # Set the first `n` terms of `g` to the series expansion of `\sqrt{h}`. + # It is assumed that `n > 0`, that `h` has constant term 1 and that `h` + # is zero-padded as necessary to length `n`. Aliasing is not permitted. + + void fq_nmod_poly_sqrt_series(fq_nmod_poly_t g, const fq_nmod_poly_t h, long n, fq_nmod_ctx_t ctx) + # Set `g` to the series expansion of `\sqrt{h}` to order `O(x^n)`. + # It is assumed that `h` has constant term 1. + + int _fq_nmod_poly_sqrt(fq_nmod_struct * s, const fq_nmod_struct * p, long n, fq_nmod_ctx_t mod) + # If ``(p, n)`` is a perfect square, sets ``(s, n / 2 + 1)`` + # to a square root of `p` and returns 1. Otherwise returns 0. + + int fq_nmod_poly_sqrt(fq_nmod_poly_t s, const fq_nmod_poly_t p, fq_nmod_ctx_t mod) + # If `p` is a perfect square, sets `s` to a square root of `p` + # and returns 1. Otherwise returns 0. + + void _fq_nmod_poly_evaluate_fq_nmod(fq_nmod_t rop, const fq_nmod_struct *op, long len, const fq_nmod_t a, const fq_nmod_ctx_t ctx) + # Sets ``rop`` to ``(op, len)`` evaluated at `a`. + # Supports zero padding. There are no restrictions on ``len``, that + # is, ``len`` is allowed to be zero, too. + + void fq_nmod_poly_evaluate_fq_nmod(fq_nmod_t rop, const fq_nmod_poly_t f, const fq_nmod_t a, const fq_nmod_ctx_t ctx) + # Sets ``rop`` to the value of `f(a)`. + # As the coefficient ring `\mathbf{F}_q` is finite, Horner's method + # is sufficient. + + void _fq_nmod_poly_compose(fq_nmod_struct *rop, const fq_nmod_struct *op1, long len1, const fq_nmod_struct *op2, long len2, const fq_nmod_ctx_t ctx) + # Sets ``rop`` to the composition of ``(op1, len1)`` and + # ``(op2, len2)``. + # Assumes that ``rop`` has space for ``(len1-1)*(len2-1) + 1`` + # coefficients. Assumes that ``op1`` and ``op2`` are non-zero + # polynomials. Does not support aliasing between any of the inputs and + # the output. + + void fq_nmod_poly_compose(fq_nmod_poly_t rop, const fq_nmod_poly_t op1, const fq_nmod_poly_t op2, const fq_nmod_ctx_t ctx) + # Sets ``rop`` to the composition of ``op1`` and ``op2``. + # To be precise about the order of composition, denoting ``rop``, + # ``op1``, and ``op2`` by `f`, `g`, and `h`, respectively, + # sets `f(t) = g(h(t))`. + + void _fq_nmod_poly_compose_mod_horner(fq_nmod_struct * res, const fq_nmod_struct * f, long lenf, const fq_nmod_struct * g, const fq_nmod_struct * h, long lenh, const fq_nmod_ctx_t ctx) + # Sets ``res`` to the composition `f(g)` modulo `h`. We require that + # `h` is nonzero and that the length of `g` is one less than the + # length of `h` (possibly with zero padding). The output is not allowed + # to be aliased with any of the inputs. + # The algorithm used is Horner's rule. + + void fq_nmod_poly_compose_mod_horner(fq_nmod_poly_t res, const fq_nmod_poly_t f, const fq_nmod_poly_t g, const fq_nmod_poly_t h, const fq_nmod_ctx_t ctx) + # Sets ``res`` to the composition `f(g)` modulo `h`. We require that + # `h` is nonzero. The algorithm used is Horner's rule. + + void _fq_nmod_poly_compose_mod_horner_preinv(fq_nmod_struct * res, const fq_nmod_struct * f, long lenf, const fq_nmod_struct * g, const fq_nmod_struct * h, long lenh, const fq_nmod_struct * hinv, long lenhiv, const fq_nmod_ctx_t ctx) + # Sets ``res`` to the composition `f(g)` modulo `h`. We require + # that `h` is nonzero and that the length of `g` is one less than + # the length of `h` (possibly with zero padding). We also require + # that the length of `f` is less than the length of + # `h`. Furthermore, we require ``hinv`` to be the inverse of the + # reverse of ``h``. The output is not allowed to be aliased with + # any of the inputs. + # The algorithm used is Horner's rule. + + void fq_nmod_poly_compose_mod_horner_preinv(fq_nmod_poly_t res, const fq_nmod_poly_t f, const fq_nmod_poly_t g, const fq_nmod_poly_t h, const fq_nmod_poly_t hinv, const fq_nmod_ctx_t ctx) + # Sets ``res`` to the composition `f(g)` modulo `h`. We require + # that `h` is nonzero and that `f` has smaller degree than + # `h`. Furthermore, we require ``hinv`` to be the inverse of the + # reverse of ``h``. The algorithm used is Horner's rule. + + void _fq_nmod_poly_compose_mod_brent_kung(fq_nmod_struct * res, const fq_nmod_struct * f, long lenf, const fq_nmod_struct * g, const fq_nmod_struct * h, long lenh, const fq_nmod_ctx_t ctx) + # Sets ``res`` to the composition `f(g)` modulo `h`. We require + # that `h` is nonzero and that the length of `g` is one less than + # the length of `h` (possibly with zero padding). We also require + # that the length of `f` is less than the length of `h`. The output + # is not allowed to be aliased with any of the inputs. + # The algorithm used is the Brent-Kung matrix algorithm. + + void fq_nmod_poly_compose_mod_brent_kung(fq_nmod_poly_t res, const fq_nmod_poly_t f, const fq_nmod_poly_t g, const fq_nmod_poly_t h, const fq_nmod_ctx_t ctx) + # Sets ``res`` to the composition `f(g)` modulo `h`. We require + # that `h` is nonzero and that `f` has smaller degree than `h`. The + # algorithm used is the Brent-Kung matrix algorithm. + + void _fq_nmod_poly_compose_mod_brent_kung_preinv(fq_nmod_struct * res, const fq_nmod_struct * f, long lenf, const fq_nmod_struct * g, const fq_nmod_struct * h, long lenh, const fq_nmod_struct * hinv, long lenhiv, const fq_nmod_ctx_t ctx) + # Sets ``res`` to the composition `f(g)` modulo `h`. We require + # that `h` is nonzero and that the length of `g` is one less than + # the length of `h` (possibly with zero padding). We also require + # that the length of `f` is less than the length of + # `h`. Furthermore, we require ``hinv`` to be the inverse of the + # reverse of ``h``. The output is not allowed to be aliased with + # any of the inputs. + # The algorithm used is the Brent-Kung matrix algorithm. + + void fq_nmod_poly_compose_mod_brent_kung_preinv(fq_nmod_poly_t res, const fq_nmod_poly_t f, const fq_nmod_poly_t g, const fq_nmod_poly_t h, const fq_nmod_poly_t hinv, const fq_nmod_ctx_t ctx) + # Sets ``res`` to the composition `f(g)` modulo `h`. We require + # that `h` is nonzero and that `f` has smaller degree than + # `h`. Furthermore, we require ``hinv`` to be the inverse of the + # reverse of ``h``. The algorithm used is the Brent-Kung matrix + # algorithm. + + void _fq_nmod_poly_compose_mod(fq_nmod_struct * res, const fq_nmod_struct * f, long lenf, const fq_nmod_struct * g, const fq_nmod_struct * h, long lenh, const fq_nmod_ctx_t ctx) + # Sets ``res`` to the composition `f(g)` modulo `h`. We require + # that `h` is nonzero and that the length of `g` is one less than + # the length of `h` (possibly with zero padding). The output is not + # allowed to be aliased with any of the inputs. + + void fq_nmod_poly_compose_mod(fq_nmod_poly_t res, const fq_nmod_poly_t f, const fq_nmod_poly_t g, const fq_nmod_poly_t h, const fq_nmod_ctx_t ctx) + # Sets ``res`` to the composition `f(g)` modulo `h`. We require + # that `h` is nonzero. + + void _fq_nmod_poly_compose_mod_preinv(fq_nmod_struct * res, const fq_nmod_struct * f, long lenf, const fq_nmod_struct * g, const fq_nmod_struct * h, long lenh, const fq_nmod_struct * hinv, long lenhiv, const fq_nmod_ctx_t ctx) + # Sets ``res`` to the composition `f(g)` modulo `h`. We require + # that `h` is nonzero and that the length of `g` is one less than + # the length of `h` (possibly with zero padding). We also require + # that the length of `f` is less than the length of + # `h`. Furthermore, we require ``hinv`` to be the inverse of the + # reverse of ``h``. The output is not allowed to be aliased with + # any of the inputs. + + void fq_nmod_poly_compose_mod_preinv(fq_nmod_poly_t res, const fq_nmod_poly_t f, const fq_nmod_poly_t g, const fq_nmod_poly_t h, const fq_nmod_poly_t hinv, const fq_nmod_ctx_t ctx) + # Sets ``res`` to the composition `f(g)` modulo `h`. We require + # that `h` is nonzero and that `f` has smaller degree than + # `h`. Furthermore, we require ``hinv`` to be the inverse of the + # reverse of ``h``. + + void _fq_nmod_poly_reduce_matrix_mod_poly (fq_nmod_mat_t A, const fq_nmod_mat_t B, const fq_nmod_poly_t f, const fq_nmod_ctx_t ctx) + # Sets the ith row of ``A`` to the reduction of the ith row of `B` modulo + # `f` for `i=1,\ldots,\sqrt{\deg(f)}`. We require `B` to be at least + # a `\sqrt{\deg(f)}\times \deg(f)` matrix and `f` to be nonzero. + + void _fq_nmod_poly_precompute_matrix (fq_nmod_mat_t A, const fq_nmod_struct* f, const fq_nmod_struct* g, long leng, const fq_nmod_struct* ginv, long lenginv, const fq_nmod_ctx_t ctx) + # Sets the ith row of ``A`` to `f^i` modulo `g` for + # `i=1,\ldots,\sqrt{\deg(g)}`. We require `A` to be a + # `\sqrt{\deg(g)}\times \deg(g)` matrix. We require ``ginv`` to + # be the inverse of the reverse of ``g`` and `g` to be nonzero. + + void fq_nmod_poly_precompute_matrix (fq_nmod_mat_t A, const fq_nmod_poly_t f, const fq_nmod_poly_t g, const fq_nmod_poly_t ginv, const fq_nmod_ctx_t ctx) + # Sets the ith row of ``A`` to `f^i` modulo `g` for + # `i=1,\ldots,\sqrt{\deg(g)}`. We require `A` to be a + # `\sqrt{\deg(g)}\times \deg(g)` matrix. We require ``ginv`` to + # be the inverse of the reverse of ``g``. + + void _fq_nmod_poly_compose_mod_brent_kung_precomp_preinv(fq_nmod_struct* res, const fq_nmod_struct* f, long lenf, const fq_nmod_mat_t A, const fq_nmod_struct* h, long lenh, const fq_nmod_struct* hinv, long lenhinv, const fq_nmod_ctx_t ctx) + # Sets ``res`` to the composition `f(g)` modulo `h`. We require + # that `h` is nonzero. We require that the ith row of `A` contains + # `g^i` for `i=1,\ldots,\sqrt{\deg(h)}`, i.e. `A` is a + # `\sqrt{\deg(h)}\times \deg(h)` matrix. We also require that the + # length of `f` is less than the length of `h`. Furthermore, we + # require ``hinv`` to be the inverse of the reverse of ``h``. + # The output is not allowed to be aliased with any of the inputs. + # The algorithm used is the Brent-Kung matrix algorithm. + + void fq_nmod_poly_compose_mod_brent_kung_precomp_preinv(fq_nmod_poly_t res, const fq_nmod_poly_t f, const fq_nmod_mat_t A, const fq_nmod_poly_t h, const fq_nmod_poly_t hinv, const fq_nmod_ctx_t ctx) + # Sets ``res`` to the composition `f(g)` modulo `h`. We require + # that the ith row of `A` contains `g^i` for + # `i=1,\ldots,\sqrt{\deg(h)}`, i.e. `A` is a `\sqrt{\deg(h)}\times + # \deg(h)` matrix. We require that `h` is nonzero and that `f` has + # smaller degree than `h`. Furthermore, we require ``hinv`` to be + # the inverse of the reverse of ``h``. This version of Brent-Kung + # modular composition is particularly useful if one has to perform + # several modular composition of the form `f(g)` modulo `h` for + # fixed `g` and `h`. + + int _fq_nmod_poly_fprint_pretty(FILE *file, const fq_nmod_struct *poly, long len, const char *x, const fq_nmod_ctx_t ctx) + # Prints the pretty representation of ``(poly, len)`` to the stream + # ``file``, using the string ``x`` to represent the indeterminate. + # In case of success, returns a positive value. In case of failure, + # returns a non-positive value. + + int fq_nmod_poly_fprint_pretty(FILE * file, const fq_nmod_poly_t poly, const char *x, const fq_nmod_ctx_t ctx) + # Prints the pretty representation of ``poly`` to the stream + # ``file``, using the string ``x`` to represent the indeterminate. + # In case of success, returns a positive value. In case of failure, + # returns a non-positive value. + + int _fq_nmod_poly_print_pretty(const fq_nmod_struct *poly, long len, const char *x, const fq_nmod_ctx_t ctx) + # Prints the pretty representation of ``(poly, len)`` to ``stdout``, + # using the string ``x`` to represent the indeterminate. + # In case of success, returns a positive value. In case of failure, + # returns a non-positive value. + + int fq_nmod_poly_print_pretty(const fq_nmod_poly_t poly, const char *x, const fq_nmod_ctx_t ctx) + # Prints the pretty representation of ``poly`` to ``stdout``, + # using the string ``x`` to represent the indeterminate. + # In case of success, returns a positive value. In case of failure, + # returns a non-positive value. + + int _fq_nmod_poly_fprint(FILE *file, const fq_nmod_struct *poly, long len, const fq_nmod_ctx_t ctx) + # Prints the pretty representation of ``(poly, len)`` to the stream + # ``file``. + # In case of success, returns a positive value. In case of failure, + # returns a non-positive value. + + int fq_nmod_poly_fprint(FILE * file, const fq_nmod_poly_t poly, const fq_nmod_ctx_t ctx) + # Prints the pretty representation of ``poly`` to the stream + # ``file``. + # In case of success, returns a positive value. In case of failure, + # returns a non-positive value. + + int _fq_nmod_poly_print(const fq_nmod_struct *poly, long len, const fq_nmod_ctx_t ctx) + # Prints the pretty representation of ``(poly, len)`` to ``stdout``. + # In case of success, returns a positive value. In case of failure, + # returns a non-positive value. + + int fq_nmod_poly_print(const fq_nmod_poly_t poly, const fq_nmod_ctx_t ctx) + # Prints the representation of ``poly`` to ``stdout``. + # In case of success, returns a positive value. In case of failure, + # returns a non-positive value. + + char * _fq_nmod_poly_get_str(const fq_nmod_struct * poly, long len, const fq_nmod_ctx_t ctx) + # Returns the plain FLINT string representation of the polynomial + # ``(poly, len)``. + + char * fq_nmod_poly_get_str(const fq_nmod_poly_t poly, const fq_nmod_ctx_t ctx) + # Returns the plain FLINT string representation of the polynomial + # ``poly``. + + char * _fq_nmod_poly_get_str_pretty(const fq_nmod_struct * poly, long len, const char * x, const fq_nmod_ctx_t ctx) + # Returns a pretty representation of the polynomial + # ``(poly, len)`` using the null-terminated string ``x`` as the + # variable name. + + char * fq_nmod_poly_get_str_pretty(const fq_nmod_poly_t poly, const char * x, const fq_nmod_ctx_t ctx) + # Returns a pretty representation of the polynomial ``poly`` using the + # null-terminated string ``x`` as the variable name + + void fq_nmod_poly_inflate(fq_nmod_poly_t result, const fq_nmod_poly_t input, unsigned long inflation, const fq_nmod_ctx_t ctx) + # Sets ``result`` to the inflated polynomial `p(x^n)` where + # `p` is given by ``input`` and `n` is given by ``inflation``. + + void fq_nmod_poly_deflate(fq_nmod_poly_t result, const fq_nmod_poly_t input, unsigned long deflation, const fq_nmod_ctx_t ctx) + # Sets ``result`` to the deflated polynomial `p(x^{1/n})` where + # `p` is given by ``input`` and `n` is given by ``deflation``. + # Requires `n > 0`. + + unsigned long fq_nmod_poly_deflation(const fq_nmod_poly_t input, const fq_nmod_ctx_t ctx) + # Returns the largest integer by which ``input`` can be deflated. + # As special cases, returns 0 if ``input`` is the zero polynomial + # and 1 of ``input`` is a constant polynomial. diff --git a/src/sage/libs/flint/fq_nmod_poly_factor.pxd b/src/sage/libs/flint/fq_nmod_poly_factor.pxd new file mode 100644 index 00000000000..aae2f5f4336 --- /dev/null +++ b/src/sage/libs/flint/fq_nmod_poly_factor.pxd @@ -0,0 +1,168 @@ +# distutils: libraries = flint +# distutils: depends = flint/fq_nmod_poly_factor.h + +################################################################################ +# This file is auto-generated. Do not modify by hand +################################################################################ + +from libc.stdio cimport FILE +from sage.libs.gmp.types cimport * +from sage.libs.mpfr.types cimport * +from sage.libs.flint.types cimport * + +cdef extern from "flint_wrap.h": + + void fq_nmod_poly_factor_init(fq_nmod_poly_factor_t fac, const fq_nmod_ctx_t ctx) + # Initialises ``fac`` for use. An :type:`fq_nmod_poly_factor_t` + # represents a polynomial in factorised form as a product of + # polynomials with associated exponents. + + void fq_nmod_poly_factor_clear(fq_nmod_poly_factor_t fac, const fq_nmod_ctx_t ctx) + # Frees all memory associated with ``fac``. + + void fq_nmod_poly_factor_realloc(fq_nmod_poly_factor_t fac, long alloc, const fq_nmod_ctx_t ctx) + # Reallocates the factor structure to provide space for + # precisely ``alloc`` factors. + + void fq_nmod_poly_factor_fit_length(fq_nmod_poly_factor_t fac, long len, const fq_nmod_ctx_t ctx) + # Ensures that the factor structure has space for at least + # ``len`` factors. This function takes care of the case of + # repeated calls by always at least doubling the number of factors + # the structure can hold. + + void fq_nmod_poly_factor_set(fq_nmod_poly_factor_t res, const fq_nmod_poly_factor_t fac, const fq_nmod_ctx_t ctx) + # Sets ``res`` to the same factorisation as ``fac``. + + void fq_nmod_poly_factor_print_pretty(const fq_nmod_poly_factor_t fac, const char * var, const fq_nmod_ctx_t ctx) + # Pretty-prints the entries of ``fac`` to standard output. + + void fq_nmod_poly_factor_print(const fq_nmod_poly_factor_t fac, const fq_nmod_ctx_t ctx) + # Prints the entries of ``fac`` to standard output. + + void fq_nmod_poly_factor_insert(fq_nmod_poly_factor_t fac, const fq_nmod_poly_t poly, long exp, const fq_nmod_ctx_t ctx) + # Inserts the factor ``poly`` with multiplicity ``exp`` into + # the factorisation ``fac``. + # If ``fac`` already contains ``poly``, then ``exp`` simply + # gets added to the exponent of the existing entry. + + void fq_nmod_poly_factor_concat(fq_nmod_poly_factor_t res, const fq_nmod_poly_factor_t fac, const fq_nmod_ctx_t ctx) + # Concatenates two factorisations. + # This is equivalent to calling :func:`fq_nmod_poly_factor_insert` + # repeatedly with the individual factors of ``fac``. + # Does not support aliasing between ``res`` and ``fac``. + + void fq_nmod_poly_factor_pow(fq_nmod_poly_factor_t fac, long exp, const fq_nmod_ctx_t ctx) + # Raises ``fac`` to the power ``exp``. + + unsigned long fq_nmod_poly_remove(fq_nmod_poly_t f, const fq_nmod_poly_t p, const fq_nmod_ctx_t ctx) + # Removes the highest possible power of ``p`` from ``f`` and + # returns the exponent. + + int fq_nmod_poly_is_irreducible(const fq_nmod_poly_t f, const fq_nmod_ctx_t ctx) + # Returns 1 if the polynomial ``f`` is irreducible, otherwise returns 0. + + int fq_nmod_poly_is_irreducible_ddf(const fq_nmod_poly_t f, const fq_nmod_ctx_t ctx) + # Returns 1 if the polynomial ``f`` is irreducible, otherwise returns 0. + # Uses fast distinct-degree factorisation. + + int fq_nmod_poly_is_irreducible_ben_or(const fq_nmod_poly_t f, const fq_nmod_ctx_t ctx) + # Returns 1 if the polynomial ``f`` is irreducible, otherwise returns 0. + # Uses Ben-Or's irreducibility test. + + int _fq_nmod_poly_is_squarefree(const fq_nmod_struct * f, long len, const fq_nmod_ctx_t ctx) + # Returns 1 if ``(f, len)`` is squarefree, and 0 otherwise. As a + # special case, the zero polynomial is not considered squarefree. + # There are no restrictions on the length. + + int fq_nmod_poly_is_squarefree(const fq_nmod_poly_t f, const fq_nmod_ctx_t ctx) + # Returns 1 if ``f`` is squarefree, and 0 otherwise. As a special + # case, the zero polynomial is not considered squarefree. + + int fq_nmod_poly_factor_equal_deg_prob(fq_nmod_poly_t factor, flint_rand_t state, const fq_nmod_poly_t pol, long d, const fq_nmod_ctx_t ctx) + # Probabilistic equal degree factorisation of ``pol`` into + # irreducible factors of degree ``d``. If it passes, a factor is + # placed in factor and 1 is returned, otherwise 0 is returned and + # the value of factor is undetermined. + # Requires that ``pol`` be monic, non-constant and squarefree. + + void fq_nmod_poly_factor_equal_deg(fq_nmod_poly_factor_t factors, const fq_nmod_poly_t pol, long d, const fq_nmod_ctx_t ctx) + # Assuming ``pol`` is a product of irreducible factors all of + # degree ``d``, finds all those factors and places them in + # factors. Requires that ``pol`` be monic, non-constant and + # squarefree. + + void fq_nmod_poly_factor_split_single(fq_nmod_poly_t linfactor, const fq_nmod_poly_t input, const fq_nmod_ctx_t ctx) + # Assuming ``input`` is a product of factors all of degree 1, finds a single + # linear factor of ``input`` and places it in ``linfactor``. + # Requires that ``input`` be monic and non-constant. + + void fq_nmod_poly_factor_distinct_deg(fq_nmod_poly_factor_t res, const fq_nmod_poly_t poly, long * const *degs, const fq_nmod_ctx_t ctx) + # Factorises a monic non-constant squarefree polynomial ``poly`` + # of degree `n` into factors `f[d]` such that for `1 \leq d \leq n` + # `f[d]` is the product of the monic irreducible factors of + # ``poly`` of degree `d`. Factors are stored in ``res``, + # associated powers of irreducible polynomials are stored in + # ``degs`` in the same order as factors. + # Requires that ``degs`` have enough space for irreducible polynomials' + # powers (maximum space required is `n * sizeof(slong)`). + + void fq_nmod_poly_factor_squarefree(fq_nmod_poly_factor_t res, const fq_nmod_poly_t f, const fq_nmod_ctx_t ctx) + # Sets ``res`` to a squarefree factorization of ``f``. + + void fq_nmod_poly_factor(fq_nmod_poly_factor_t res, fq_nmod_t lead, const fq_nmod_poly_t f, const fq_nmod_ctx_t ctx) + # Factorises a non-constant polynomial ``f`` into monic + # irreducible factors choosing the best algorithm for given modulo + # and degree. The output ``lead`` is set to the leading coefficient of `f` + # upon return. Choice of algorithm is based on heuristic measurements. + + void fq_nmod_poly_factor_cantor_zassenhaus(fq_nmod_poly_factor_t res, const fq_nmod_poly_t f, const fq_nmod_ctx_t ctx) + # Factorises a non-constant polynomial ``f`` into monic + # irreducible factors using the Cantor-Zassenhaus algorithm. + + void fq_nmod_poly_factor_kaltofen_shoup(fq_nmod_poly_factor_t res, const fq_nmod_poly_t poly, const fq_nmod_ctx_t ctx) + # Factorises a non-constant polynomial ``f`` into monic + # irreducible factors using the fast version of Cantor-Zassenhaus + # algorithm proposed by Kaltofen and Shoup (1998). More precisely + # this algorithm uses a “baby step/giant step” strategy for the + # distinct-degree factorization step. + + void fq_nmod_poly_factor_berlekamp(fq_nmod_poly_factor_t factors, const fq_nmod_poly_t f, const fq_nmod_ctx_t ctx) + # Factorises a non-constant polynomial ``f`` into monic + # irreducible factors using the Berlekamp algorithm. + + void fq_nmod_poly_factor_with_berlekamp(fq_nmod_poly_factor_t res, fq_nmod_t leading_coeff, const fq_nmod_poly_t f, const fq_nmod_ctx_t ctx) + # Factorises a general polynomial ``f`` into monic irreducible + # factors and sets ``leading_coeff`` to the leading coefficient + # of ``f``, or 0 if ``f`` is the zero polynomial. + # This function first checks for small special cases, deflates + # ``f`` if it is of the form `p(x^m)` for some `m > 1`, then + # performs a square-free factorisation, and finally runs Berlekamp + # on all the individual square-free factors. + + void fq_nmod_poly_factor_with_cantor_zassenhaus(fq_nmod_poly_factor_t res, fq_nmod_t leading_coeff, const fq_nmod_poly_t f, const fq_nmod_ctx_t ctx) + # Factorises a general polynomial ``f`` into monic irreducible + # factors and sets ``leading_coeff`` to the leading coefficient + # of ``f``, or 0 if ``f`` is the zero polynomial. + # This function first checks for small special cases, deflates + # ``f`` if it is of the form `p(x^m)` for some `m > 1`, then + # performs a square-free factorisation, and finally runs + # Cantor-Zassenhaus on all the individual square-free factors. + + void fq_nmod_poly_factor_with_kaltofen_shoup(fq_nmod_poly_factor_t res, fq_nmod_t leading_coeff, const fq_nmod_poly_t f, const fq_nmod_ctx_t ctx) + # Factorises a general polynomial ``f`` into monic irreducible + # factors and sets ``leading_coeff`` to the leading coefficient + # of ``f``, or 0 if ``f`` is the zero polynomial. + # This function first checks for small special cases, deflates + # ``f`` if it is of the form `p(x^m)` for some `m > 1`, then + # performs a square-free factorisation, and finally runs + # Kaltofen-Shoup on all the individual square-free factors. + + void fq_nmod_poly_iterated_frobenius_preinv(fq_nmod_poly_t *rop, long n, const fq_nmod_poly_t v, const fq_nmod_poly_t vinv, const fq_nmod_ctx_t ctx) + # Sets ``rop[i]`` to be `x^{q^i} \bmod v` for `0 \le i < n`. + # It is required that ``vinv`` is the inverse of the reverse of + # ``v`` mod ``x^lenv``. + + void fq_nmod_poly_roots(fq_nmod_poly_factor_t r, const fq_nmod_poly_t f, int with_multiplicity, const fq_nmod_ctx_t ctx) + # Fill `r` with factors of the form `x - r_i` where the `r_i` are the distinct roots of a nonzero `f` in `F_q`. + # If `with\_multiplicity` is zero, the exponent `e_i` of the factor `x - r_i` is `1`. Otherwise, it is the largest `e_i` such that `(x-r_i)^e_i` divides `f`. + # This function throws if `f` is zero, but is otherwise always successful. diff --git a/src/sage/libs/flint/fq_nmod_vec.pxd b/src/sage/libs/flint/fq_nmod_vec.pxd new file mode 100644 index 00000000000..a24182e9d04 --- /dev/null +++ b/src/sage/libs/flint/fq_nmod_vec.pxd @@ -0,0 +1,73 @@ +# distutils: libraries = flint +# distutils: depends = flint/fq_nmod_vec.h + +################################################################################ +# This file is auto-generated. Do not modify by hand +################################################################################ + +from libc.stdio cimport FILE +from sage.libs.gmp.types cimport * +from sage.libs.mpfr.types cimport * +from sage.libs.flint.types cimport * + +cdef extern from "flint_wrap.h": + + fq_nmod_struct * _fq_nmod_vec_init(long len, const fq_nmod_ctx_t ctx) + # Returns an initialised vector of ``fq_nmod``'s of given length. + + void _fq_nmod_vec_clear(fq_nmod_struct * vec, long len, const fq_nmod_ctx_t ctx) + # Clears the entries of ``(vec, len)`` and frees the space allocated + # for ``vec``. + + void _fq_nmod_vec_randtest(fq_nmod_struct * f, flint_rand_t state, long len, const fq_nmod_ctx_t ctx) + # Sets the entries of a vector of the given length to elements of + # the finite field. + + int _fq_nmod_vec_fprint(FILE * file, const fq_nmod_struct * vec, long len, const fq_nmod_ctx_t ctx) + # Prints the vector of given length to the stream ``file``. The + # format is the length followed by two spaces, then a space separated + # list of coefficients. If the length is zero, only `0` is printed. + # In case of success, returns a positive value. In case of failure, + # returns a non-positive value. + + int _fq_nmod_vec_print(const fq_nmod_struct * vec, long len, const fq_nmod_ctx_t ctx) + # Prints the vector of given length to ``stdout``. + # For further details, see ``_fq_nmod_vec_fprint()``. + + void _fq_nmod_vec_set(fq_nmod_struct * vec1, const fq_nmod_struct * vec2, long len2, const fq_nmod_ctx_t ctx) + # Makes a copy of ``(vec2, len2)`` into ``vec1``. + + void _fq_nmod_vec_swap(fq_nmod_struct * vec1, fq_nmod_struct * vec2, long len2, const fq_nmod_ctx_t ctx) + # Swaps the elements in ``(vec1, len2)`` and ``(vec2, len2)``. + + void _fq_nmod_vec_zero(fq_nmod_struct * vec, long len, const fq_nmod_ctx_t ctx) + # Zeros the entries of ``(vec, len)``. + + void _fq_nmod_vec_neg(fq_nmod_struct * vec1, const fq_nmod_struct * vec2, long len2, const fq_nmod_ctx_t ctx) + # Negates ``(vec2, len2)`` and places it into ``vec1``. + + int _fq_nmod_vec_equal(const fq_nmod_struct * vec1, const fq_nmod_struct * vec2, long len, const fq_nmod_ctx_t ctx) + # Compares two vectors of the given length and returns `1` if they are + # equal, otherwise returns `0`. + + int _fq_nmod_vec_is_zero(const fq_nmod_struct * vec, long len, const fq_nmod_ctx_t ctx) + # Returns `1` if ``(vec, len)`` is zero, and `0` otherwise. + + void _fq_nmod_vec_add(fq_nmod_struct * res, const fq_nmod_struct * vec1, const fq_nmod_struct * vec2, long len2, const fq_nmod_ctx_t ctx) + # Sets ``(res, len2)`` to the sum of ``(vec1, len2)`` + # and ``(vec2, len2)``. + + void _fq_nmod_vec_sub(fq_nmod_struct * res, const fq_nmod_struct * vec1, const fq_nmod_struct * vec2, long len2, const fq_nmod_ctx_t ctx) + # Sets ``(res, len2)`` to ``(vec1, len2)`` minus ``(vec2, len2)``. + + void _fq_nmod_vec_scalar_addmul_fq_nmod(fq_nmod_struct * vec1, const fq_nmod_struct * vec2, long len2, const fq_nmod_t c, const fq_nmod_ctx_t ctx) + # Adds ``(vec2, len2)`` times `c` to ``(vec1, len2)``, where + # `c` is a ``fq_nmod_t``. + + void _fq_nmod_vec_scalar_submul_fq_nmod(fq_nmod_struct * vec1, const fq_nmod_struct * vec2, long len2, const fq_nmod_t c, const fq_nmod_ctx_t ctx) + # Subtracts ``(vec2, len2)`` times `c` from ``(vec1, len2)``, + # where `c` is a ``fq_nmod_t``. + + void _fq_nmod_vec_dot(fq_nmod_t res, const fq_nmod_struct * vec1, const fq_nmod_struct * vec2, long len2, const fq_nmod_ctx_t ctx) + # Sets ``res`` to the dot product of (``vec1``, ``len``) + # and (``vec2``, ``len``). diff --git a/src/sage/libs/flint/fq_zech.pxd b/src/sage/libs/flint/fq_zech.pxd new file mode 100644 index 00000000000..1ba59753e97 --- /dev/null +++ b/src/sage/libs/flint/fq_zech.pxd @@ -0,0 +1,380 @@ +# distutils: libraries = flint +# distutils: depends = flint/fq_zech.h + +################################################################################ +# This file is auto-generated. Do not modify by hand +################################################################################ + +from libc.stdio cimport FILE +from sage.libs.gmp.types cimport * +from sage.libs.mpfr.types cimport * +from sage.libs.flint.types cimport * + +cdef extern from "flint_wrap.h": + + void fq_zech_ctx_init(fq_zech_ctx_t ctx, const fmpz_t p, long d, const char *var) + # Initialises the context for prime `p` and extension degree `d`, + # with name ``var`` for the generator. By default, it will try + # use a Conway polynomial; if one is not available, a random + # primitive polynomial will be used. + # Assumes that `p` is a prime and :math:`p^d < 2^{\mathtt{FLINT\_BITS}}`. + # Assumes that the string ``var`` is a null-terminated string + # of length at least one. + + int _fq_zech_ctx_init_conway(fq_zech_ctx_t ctx, const fmpz_t p, long d, const char *var) + # Attempts to initialise the context for prime `p` and extension + # degree `d`, with name ``var`` for the generator using a Conway + # polynomial for the modulus. + # Returns `1` if the Conway polynomial is in the database for the + # given size and the initialization is successful; otherwise, + # returns `0`. + # Assumes that `p` is a prime and `p^d < 2^\mathtt{FLINT\_BITS}`. + # Assumes that the string ``var`` is a null-terminated string + # of length at least one. + + void fq_zech_ctx_init_conway(fq_zech_ctx_t ctx, const fmpz_t p, long d, const char *var) + # Initialises the context for prime `p` and extension degree `d`, + # with name ``var`` for the generator using a Conway polynomial + # for the modulus. + # Assumes that `p` is a prime and `p^d < 2^\mathtt{FLINT\_BITS}`. + # Assumes that the string ``var`` is a null-terminated string + # of length at least one. + + void fq_zech_ctx_init_random(fq_zech_ctx_t ctx, const fmpz_t p, long d, const char *var) + # Initialises the context for prime `p` and extension degree `d`, + # with name ``var`` for the generator using a random primitive + # polynomial. + # Assumes that `p` is a prime and `p^d < 2^\mathtt{FLINT\_BITS}`. + # Assumes that the string ``var`` is a null-terminated string + # of length at least one. + + void fq_zech_ctx_init_modulus(fq_zech_ctx_t ctx, const nmod_poly_t modulus, const char *var) + # Initialises the context for given ``modulus`` with name + # ``var`` for the generator. + # Assumes that ``modulus`` is an primitive polynomial over + # `\mathbf{F}_{p}`. An exception is raised if a non-primitive modulus is + # detected. + # Assumes that the string ``var`` is a null-terminated string + # of length at least one. + + int fq_zech_ctx_init_modulus_check(fq_zech_ctx_t ctx, const nmod_poly_t modulus, const char *var) + # As per the previous function, but returns `0` if the modulus was not + # primitive and `1` if the context was successfully initialised with the + # given modulus. No exception is raised. + + void fq_zech_ctx_init_fq_nmod_ctx(fq_zech_ctx_t ctx, fq_nmod_ctx_t ctxn) + # Initializes the context ``ctx`` to be the Zech representation + # for the finite field given by ``ctxn``. + + int fq_zech_ctx_init_fq_nmod_ctx_check(fq_zech_ctx_t ctx, fq_nmod_ctx_t ctxn) + # As per the previous function but returns `0` if a non-primitive modulus is + # detected. Returns `0` if the Zech representation was successfully + # initialised. + + void fq_zech_ctx_clear(fq_zech_ctx_t ctx) + # Clears all memory that has been allocated as part of the context. + + const nmod_poly_struct* fq_zech_ctx_modulus(const fq_zech_ctx_t ctx) + # Returns a pointer to the modulus in the context. + + long fq_zech_ctx_degree(const fq_zech_ctx_t ctx) + # Returns the degree of the field extension + # `[\mathbf{F}_{q} : \mathbf{F}_{p}]`, which + # is equal to `\log_{p} q`. + + fmpz * fq_zech_ctx_prime(const fq_zech_ctx_t ctx) + # Returns a pointer to the prime `p` in the context. + + void fq_zech_ctx_order(fmpz_t f, const fq_zech_ctx_t ctx) + # Sets `f` to be the size of the finite field. + + mp_limb_t fq_zech_ctx_order_ui(const fq_zech_ctx_t ctx) + # Returns the size of the finite field. + + int fq_zech_ctx_fprint(FILE * file, const fq_zech_ctx_t ctx) + # Prints the context information to {\tt{file}}. Returns 1 for a + # success and a negative number for an error. + + void fq_zech_ctx_print(const fq_zech_ctx_t ctx) + # Prints the context information to {\tt{stdout}}. + + void fq_zech_ctx_randtest(fq_zech_ctx_t ctx, flint_rand_t state) + # Initializes ``ctx`` to a random finite field. Assumes that + # ``fq_zech_ctx_init`` has not been called on ``ctx`` already. + + void fq_zech_ctx_randtest_reducible(fq_zech_ctx_t ctx, flint_rand_t state) + # Since the Zech logarithm representation does not work with a + # non-irreducible modulus, does the same as + # ``fq_zech_ctx_randtest``. + + void fq_zech_init(fq_zech_t rop, const fq_zech_ctx_t ctx) + # Initialises the element ``rop``, setting its value to `0`. + + void fq_zech_init2(fq_zech_t rop, const fq_zech_ctx_t ctx) + # Initialises ``poly`` with at least enough space for it to be an element + # of ``ctx`` and sets it to `0`. + + void fq_zech_clear(fq_zech_t rop, const fq_zech_ctx_t ctx) + # Clears the element ``rop``. + + void _fq_zech_sparse_reduce(mp_ptr R, long lenR, const fq_zech_ctx_t ctx) + # Reduces ``(R, lenR)`` modulo the polynomial `f` given by the + # modulus of ``ctx``. + + void _fq_zech_dense_reduce(mp_ptr R, long lenR, const fq_zech_ctx_t ctx) + # Reduces ``(R, lenR)`` modulo the polynomial `f` given by the + # modulus of ``ctx`` using Newton division. + + void _fq_zech_reduce(mp_ptr r, long lenR, const fq_zech_ctx_t ctx) + # Reduces ``(R, lenR)`` modulo the polynomial `f` given by the + # modulus of ``ctx``. Does either sparse or dense reduction + # based on ``ctx->sparse_modulus``. + + void fq_zech_reduce(fq_zech_t rop, const fq_zech_ctx_t ctx) + # Reduces the polynomial ``rop`` as an element of + # `\mathbf{F}_p[X] / (f(X))`. + + void fq_zech_add(fq_zech_t rop, const fq_zech_t op1, const fq_zech_t op2, const fq_zech_ctx_t ctx) + # Sets ``rop`` to the sum of ``op1`` and ``op2``. + + void fq_zech_sub(fq_zech_t rop, const fq_zech_t op1, const fq_zech_t op2, const fq_zech_ctx_t ctx) + # Sets ``rop`` to the difference of ``op1`` and ``op2``. + + void fq_zech_sub_one(fq_zech_t rop, const fq_zech_t op1, const fq_zech_ctx_t ctx) + # Sets ``rop`` to the difference of ``op1`` and `1`. + + void fq_zech_neg(fq_zech_t rop, const fq_zech_t op, const fq_zech_ctx_t ctx) + # Sets ``rop`` to the negative of ``op``. + + void fq_zech_mul(fq_zech_t rop, const fq_zech_t op1, const fq_zech_t op2, const fq_zech_ctx_t ctx) + # Sets ``rop`` to the product of ``op1`` and ``op2``, + # reducing the output in the given context. + + void fq_zech_mul_fmpz(fq_zech_t rop, const fq_zech_t op, const fmpz_t x, const fq_zech_ctx_t ctx) + # Sets ``rop`` to the product of ``op`` and `x`, + # reducing the output in the given context. + + void fq_zech_mul_si(fq_zech_t rop, const fq_zech_t op, long x, const fq_zech_ctx_t ctx) + # Sets ``rop`` to the product of ``op`` and `x`, + # reducing the output in the given context. + + void fq_zech_mul_ui(fq_zech_t rop, const fq_zech_t op, unsigned long x, const fq_zech_ctx_t ctx) + # Sets ``rop`` to the product of ``op`` and `x`, + # reducing the output in the given context. + + void fq_zech_sqr(fq_zech_t rop, const fq_zech_t op, const fq_zech_ctx_t ctx) + # Sets ``rop`` to the square of ``op``, + # reducing the output in the given context. + + void fq_zech_div(fq_zech_t rop, const fq_zech_t op1, const fq_zech_t op2, const fq_zech_ctx_t ctx) + # Sets ``rop`` to the quotient of ``op1`` and ``op2``, + # reducing the output in the given context. + + void _fq_zech_inv(mp_ptr *rop, mp_srcptr *op, long len, const fq_zech_ctx_t ctx) + # Sets ``(rop, d)`` to the inverse of the non-zero element + # ``(op, len)``. + + void fq_zech_inv(fq_zech_t rop, const fq_zech_t op, const fq_zech_ctx_t ctx) + # Sets ``rop`` to the inverse of the non-zero element ``op``. + + void fq_zech_gcdinv(fq_zech_t f, fq_zech_t inv, const fq_zech_t op, const fq_zech_ctx_t ctx) + # Sets ``inv`` to be the inverse of ``op`` modulo the modulus + # of ``ctx`` and sets ``f`` to one. Since the modulus for + # ``ctx`` is always irreducible, ``op`` is always invertible. + + void _fq_zech_pow(fmpz *rop, const fmpz *op, long len, const fmpz_t e, const fmpz * a, const long *j, long lena, const fmpz_t p) + # Sets ``(rop, 2*d-1)`` to ``(op,len)`` raised to the power `e`, + # reduced modulo `f(X)`, the modulus of ``ctx``. + # Assumes that `e \geq 0` and that ``len`` is positive and at most `d`. + # Although we require that ``rop`` provides space for + # `2d - 1` coefficients, the output will be reduced modulo + # `f(X)`, which is a polynomial of degree `d`. + # Does not support aliasing. + + void fq_zech_pow(fq_zech_t rop, const fq_zech_t op, const fmpz_t e, const fq_zech_ctx_t ctx) + # Sets ``rop`` the ``op`` raised to the power `e`. + # Currently assumes that `e \geq 0`. + # Note that for any input ``op``, ``rop`` is set to `1` + # whenever `e = 0`. + + void fq_zech_pow_ui(fq_zech_t rop, const fq_zech_t op, const unsigned long e, const fq_zech_ctx_t ctx) + # Sets ``rop`` the ``op`` raised to the power `e`. + # Currently assumes that `e \geq 0`. + # Note that for any input ``op``, ``rop`` is set to `1` + # whenever `e = 0`. + + int fq_zech_sqrt(fq_zech_t rop, const fq_zech_t op1, const fq_zech_ctx_t ctx) + # Sets ``rop`` to the square root of ``op1`` if it is a square, and return + # `1`, otherwise return `0`. + + void fq_zech_pth_root(fq_zech_t rop, const fq_zech_t op1, const fq_zech_ctx_t ctx) + # Sets ``rop`` to a `p^{th}` root root of ``op1``. Currently, + # this computes the root by raising ``op1`` to `p^{d-1}` where + # `d` is the degree of the extension. + + int fq_zech_is_square(const fq_zech_t op, const fq_zech_ctx_t ctx) + # Return ``1`` if ``op`` is a square. + + int fq_zech_fprint_pretty(FILE *file, const fq_zech_t op, const fq_zech_ctx_t ctx) + # Prints a pretty representation of ``op`` to ``file``. + # In the current implementation, always returns `1`. The return code is + # part of the function's signature to allow for a later implementation to + # return the number of characters printed or a non-positive error code. + + void fq_zech_print_pretty(const fq_zech_t op, const fq_zech_ctx_t ctx) + # Prints a pretty representation of ``op`` to ``stdout``. + # In the current implementation, always returns `1`. The return code is + # part of the function's signature to allow for a later implementation to + # return the number of characters printed or a non-positive error code. + + int fq_zech_fprint(FILE * file, const fq_zech_t op, const fq_zech_ctx_t ctx) + # Prints a representation of ``op`` to ``file``. + + void fq_zech_print(const fq_zech_t op, const fq_zech_ctx_t ctx) + # Prints a representation of ``op`` to ``stdout``. + + char * fq_zech_get_str(const fq_zech_t op, const fq_zech_ctx_t ctx) + # Returns the plain FLINT string representation of the element + # ``op``. + + char * fq_zech_get_str_pretty(const fq_zech_t op, const fq_zech_ctx_t ctx) + # Returns a pretty representation of the element ``op`` using the + # null-terminated string ``x`` as the variable name. + + void fq_zech_randtest(fq_zech_t rop, flint_rand_t state, const fq_zech_ctx_t ctx) + # Generates a random element of `\mathbf{F}_q`. + + void fq_zech_randtest_not_zero(fq_zech_t rop, flint_rand_t state, const fq_zech_ctx_t ctx) + # Generates a random non-zero element of `\mathbf{F}_q`. + + void fq_zech_randtest_dense(fq_zech_t rop, flint_rand_t state, const fq_zech_ctx_t ctx) + # Generates a random element of `\mathbf{F}_q` which has an + # underlying polynomial with dense coefficients. + + void fq_zech_rand(fq_zech_t rop, flint_rand_t state, const fq_zech_ctx_t ctx) + # Generates a high quality random element of `\mathbf{F}_q`. + + void fq_zech_rand_not_zero(fq_zech_t rop, flint_rand_t state, const fq_zech_ctx_t ctx) + # Generates a high quality non-zero random element of `\mathbf{F}_q`. + + void fq_zech_set(fq_zech_t rop, const fq_zech_t op, const fq_zech_ctx_t ctx) + # Sets ``rop`` to ``op``. + + void fq_zech_set_si(fq_zech_t rop, const long x, const fq_zech_ctx_t ctx) + # Sets ``rop`` to ``x``, considered as an element of + # `\mathbf{F}_p`. + + void fq_zech_set_ui(fq_zech_t rop, const unsigned long x, const fq_zech_ctx_t ctx) + # Sets ``rop`` to ``x``, considered as an element of + # `\mathbf{F}_p`. + + void fq_zech_set_fmpz(fq_zech_t rop, const fmpz_t x, const fq_zech_ctx_t ctx) + # Sets ``rop`` to ``x``, considered as an element of + # `\mathbf{F}_p`. + + void fq_zech_swap(fq_zech_t op1, fq_zech_t op2, const fq_zech_ctx_t ctx) + # Swaps the two elements ``op1`` and ``op2``. + + void fq_zech_zero(fq_zech_t rop, const fq_zech_ctx_t ctx) + # Sets ``rop`` to zero. + + void fq_zech_one(fq_zech_t rop, const fq_zech_ctx_t ctx) + # Sets ``rop`` to one, reduced in the given context. + + void fq_zech_gen(fq_zech_t rop, const fq_zech_ctx_t ctx) + # Sets ``rop`` to a generator for the finite field. + # There is no guarantee this is a multiplicative generator of + # the finite field. + + int fq_zech_get_fmpz(fmpz_t rop, const fq_zech_t op, const fq_zech_ctx_t ctx) + # If ``op`` has a lift to the integers, return `1` and set ``rop`` to the lift in `[0,p)`. + # Otherwise, return `0` and leave `rop` undefined. + + void fq_zech_get_fq_nmod(fq_nmod_t rop, const fq_zech_t op, const fq_zech_ctx_t ctx) + # Sets ``rop`` to the ``fq_nmod_t`` element corresponding to ``op``. + + void fq_zech_set_fq_nmod(fq_zech_t rop, const fq_nmod_t op, const fq_zech_ctx_t ctx) + # Sets ``rop`` to the ``fq_zech_t`` element corresponding to ``op``. + + void fq_zech_get_nmod_poly(nmod_poly_t a, const fq_zech_t b, const fq_zech_ctx_t ctx) + # Set ``a`` to a representative of ``b`` in ``ctx``. + # The representatives are taken in `(\mathbb{Z}/p\mathbb{Z})[x]/h(x)` where `h(x)` is the defining polynomial in ``ctx``. + + void fq_zech_set_nmod_poly(fq_zech_t a, const nmod_poly_t b, const fq_zech_ctx_t ctx) + # Set ``a`` to the element in ``ctx`` with representative ``b``. + # The representatives are taken in `(\mathbb{Z}/p\mathbb{Z})[x]/h(x)` where `h(x)` is the defining polynomial in ``ctx``. + + void fq_zech_get_nmod_mat(nmod_mat_t col, const fq_zech_t a, const fq_zech_ctx_t ctx) + # Convert ``a`` to a column vector of length ``degree(ctx)``. + + void fq_zech_set_nmod_mat(fq_zech_t a, const nmod_mat_t col, const fq_zech_ctx_t ctx) + # Convert a column vector ``col`` of length ``degree(ctx)`` to + # an element of ``ctx``. + + int fq_zech_is_zero(const fq_zech_t op, const fq_zech_ctx_t ctx) + # Returns whether ``op`` is equal to zero. + + int fq_zech_is_one(const fq_zech_t op, const fq_zech_ctx_t ctx) + # Returns whether ``op`` is equal to one. + + int fq_zech_equal(const fq_zech_t op1, const fq_zech_t op2, const fq_zech_ctx_t ctx) + # Returns whether ``op1`` and ``op2`` are equal. + + int fq_zech_is_invertible(const fq_zech_t op, const fq_zech_ctx_t ctx) + # Returns whether ``op`` is an invertible element. + + int fq_zech_is_invertible_f(fq_zech_t f, const fq_zech_t op, const fq_zech_ctx_t ctx) + # Returns whether ``op`` is an invertible element. If it is not, + # then ``f`` is set of a factor of the modulus. Since the + # modulus for an ``fq_zech_ctx_t`` is always irreducible, then + # any non-zero ``op`` will be invertible. + + void fq_zech_trace(fmpz_t rop, const fq_zech_t op, const fq_zech_ctx_t ctx) + # Sets ``rop`` to the trace of ``op``. + # For an element `a \in \mathbf{F}_q`, multiplication by `a` defines + # a `\mathbf{F}_p`-linear map on `\mathbf{F}_q`. We define the + # trace of `a` as the trace of this map. Equivalently, if `\Sigma` + # generates `\operatorname{Gal}(\mathbf{F}_q / \mathbf{F}_p)` then the trace of + # `a` is equal to `\sum_{i=0}^{d-1} \Sigma^i (a)`, where `d = + # \log_{p} q`. + + void fq_zech_norm(fmpz_t rop, const fq_zech_t op, const fq_zech_ctx_t ctx) + # Computes the norm of ``op``. + # For an element `a \in \mathbf{F}_q`, multiplication by `a` defines + # a `\mathbf{F}_p`-linear map on `\mathbf{F}_q`. We define the norm + # of `a` as the determinant of this map. Equivalently, if `\Sigma` generates + # `\operatorname{Gal}(\mathbf{F}_q / \mathbf{F}_p)` then the trace of `a` is equal to + # `\prod_{i=0}^{d-1} \Sigma^i (a)`, where + # `d = \text{dim}_{\mathbf{F}_p}(\mathbf{F}_q)`. + # Algorithm selection is automatic depending on the input. + + void fq_zech_frobenius(fq_zech_t rop, const fq_zech_t op, long e, const fq_zech_ctx_t ctx) + # Evaluates the homomorphism `\Sigma^e` at ``op``. + # Recall that `\mathbf{F}_q / \mathbf{F}_p` is Galois with Galois group + # `\langle \sigma \rangle`, which is also isomorphic to + # `\mathbf{Z}/d\mathbf{Z}`, where + # `\sigma \in \operatorname{Gal}(\mathbf{F}_q/\mathbf{F}_p)` is the Frobenius element + # `\sigma \colon x \mapsto x^p`. + + int fq_zech_multiplicative_order(fmpz * ord, const fq_zech_t op, const fq_zech_ctx_t ctx) + # Computes the order of ``op`` as an element of the + # multiplicative group of ``ctx``. + # Returns 0 if ``op`` is 0, otherwise it returns 1 if ``op`` + # is a generator of the multiplicative group, and -1 if it is not. + # Note that ``ctx`` must already correspond to a finite field defined by + # a primitive polynomial and so this function cannot be used to check + # primitivity of the generator, but can be used to check that other elements + # are primitive. + + int fq_zech_is_primitive(const fq_zech_t op, const fq_zech_ctx_t ctx) + # Returns whether ``op`` is primitive, i.e., whether it is a + # generator of the multiplicative group of ``ctx``. + + void fq_zech_bit_pack(fmpz_t f, const fq_zech_t op, flint_bitcnt_t bit_size, const fq_zech_ctx_t ctx) + # Packs ``op`` into bitfields of size ``bit_size``, writing the + # result to ``f``. + + void fq_zech_bit_unpack(fq_zech_t rop, const fmpz_t f, flint_bitcnt_t bit_size, const fq_zech_ctx_t ctx) + # Unpacks into ``rop`` the element with coefficients packed into + # fields of size ``bit_size`` as represented by the integer + # ``f``. diff --git a/src/sage/libs/flint/fq_zech_embed.pxd b/src/sage/libs/flint/fq_zech_embed.pxd new file mode 100644 index 00000000000..bcb53c83ffb --- /dev/null +++ b/src/sage/libs/flint/fq_zech_embed.pxd @@ -0,0 +1,97 @@ +# distutils: libraries = flint +# distutils: depends = flint/fq_zech_embed.h + +################################################################################ +# This file is auto-generated. Do not modify by hand +################################################################################ + +from libc.stdio cimport FILE +from sage.libs.gmp.types cimport * +from sage.libs.mpfr.types cimport * +from sage.libs.flint.types cimport * + +cdef extern from "flint_wrap.h": + + void fq_zech_embed_gens(fq_zech_t gen_sub, fq_zech_t gen_sup, nmod_poly_t minpoly, const fq_zech_ctx_t sub_ctx, const fq_zech_ctx_t sup_ctx) + # Given two contexts ``sub_ctx`` and ``sup_ctx``, such that + # ``degree(sub_ctx)`` divides ``degree(sup_ctx)``, compute: + # * an element ``gen_sub`` in ``sub_ctx`` such that + # ``gen_sub`` generates the finite field defined by + # ``sub_ctx``, + # * its minimal polynomial ``minpoly``, + # * a root ``gen_sup`` of ``minpoly`` inside the field + # defined by ``sup_ctx``. + # These data uniquely define an embedding of ``sub_ctx`` into + # ``sup_ctx``. + + void _fq_zech_embed_gens_naive(fq_zech_t gen_sub, fq_zech_t gen_sup, nmod_poly_t minpoly, const fq_zech_ctx_t sub_ctx, const fq_zech_ctx_t sup_ctx) + # Given two contexts ``sub_ctx`` and ``sup_ctx``, such that + # ``degree(sub_ctx)`` divides ``degree(sup_ctx)``, compute an + # embedding of ``sub_ctx`` into ``sup_ctx`` defined as follows: + # * ``gen_sub`` is the canonical generator of ``sup_ctx`` + # (i.e., the class of `X`), + # * ``minpoly`` is the defining polynomial of ``sub_ctx``, + # * ``gen_sup`` is a root of ``minpoly`` inside the field + # defined by ``sup_ctx``. + + void fq_zech_embed_matrices(nmod_mat_t embed, nmod_mat_t project, const fq_zech_t gen_sub, const fq_zech_ctx_t sub_ctx, const fq_zech_t gen_sup, const fq_zech_ctx_t sup_ctx, const nmod_poly_t gen_minpoly) + # Given: + # * two contexts ``sub_ctx`` and ``sup_ctx``, of + # respective degrees `m` and `n`, such that `m` divides `n`; + # * a generator ``gen_sub`` of ``sub_ctx``, its minimal + # polynomial ``gen_minpoly``, and a root ``gen_sup`` of + # ``gen_minpoly`` in ``sup_ctx``, as returned by + # ``fq_zech_embed_gens``; + # Compute: + # * the `n\times m` matrix ``embed`` mapping ``gen_sub`` + # to ``gen_sup``, and all their powers accordingly; + # * an `m\times n` matrix ``project`` such that + # ``project`` `\times` ``embed`` is the `m\times m` identity + # matrix. + + void fq_zech_embed_trace_matrix(nmod_mat_t res, const nmod_mat_t basis, const fq_zech_ctx_t sub_ctx, const fq_zech_ctx_t sup_ctx) + # Given: + # * two contexts ``sub_ctx`` and ``sup_ctx``, of degrees + # `m` and `n`, such that `m` divides `n`; + # * an `n\times m` matrix ``basis`` that maps ``sub_ctx`` + # to an isomorphic subfield in ``sup_ctx``; + # Compute the `m\times n` matrix of the trace from ``sup_ctx`` to + # ``sub_ctx``. + # This matrix is computed as + # ``embed_dual_to_mono_matrix(_, sub_ctx)`` + # `\times` ``basis``:sup:`t` `\times` + # ``embed_mono_to_dual_matrix(_, sup_ctx)}``. + # **Note:** if + # `m=n`, ``basis`` represents a Frobenius, and the result is its + # inverse matrix. + + void fq_zech_embed_composition_matrix(nmod_mat_t matrix, const fq_zech_t gen, const fq_zech_ctx_t ctx) + # Compute the *composition matrix* of ``gen``. + # For an element `a\in\mathbf{F}_{p^n}`, its composition matrix is the + # matrix whose columns are `a^0, a^1, \ldots, a^{n-1}`. + + void fq_zech_embed_composition_matrix_sub(nmod_mat_t matrix, const fq_zech_t gen, const fq_zech_ctx_t ctx, long trunc) + # Compute the *composition matrix* of ``gen``, truncated to + # ``trunc`` columns. + + void fq_zech_embed_mul_matrix(nmod_mat_t matrix, const fq_zech_t gen, const fq_zech_ctx_t ctx) + # Compute the *multiplication matrix* of ``gen``. + # For an element `a` in `\mathbf{F}_{p^n}=\mathbf{F}_p[x]`, its + # multiplication matrix is the matrix whose columns are `a, ax, + # \dots, ax^{n-1}`. + + void fq_zech_embed_mono_to_dual_matrix(nmod_mat_t res, const fq_zech_ctx_t ctx) + # Compute the change of basis matrix from the monomial basis of + # ``ctx`` to its dual basis. + + void fq_zech_embed_dual_to_mono_matrix(nmod_mat_t res, const fq_zech_ctx_t ctx) + # Compute the change of basis matrix from the dual basis of + # ``ctx`` to its monomial basis. + + void fq_zech_modulus_pow_series_inv(nmod_poly_t res, const fq_zech_ctx_t ctx, long trunc) + # Compute the power series inverse of the reverse of the modulus of + # ``ctx`` up to `O(x^\texttt{trunc})`. + + void fq_zech_modulus_derivative_inv(fq_zech_t m_prime, fq_zech_t m_prime_inv, const fq_zech_ctx_t ctx) + # Compute the derivative ``m_prime`` of the modulus of ``ctx`` + # as an element of ``ctx``, and its inverse ``m_prime_inv``. diff --git a/src/sage/libs/flint/fq_zech_mat.pxd b/src/sage/libs/flint/fq_zech_mat.pxd new file mode 100644 index 00000000000..d057b0b90cb --- /dev/null +++ b/src/sage/libs/flint/fq_zech_mat.pxd @@ -0,0 +1,344 @@ +# distutils: libraries = flint +# distutils: depends = flint/fq_zech_mat.h + +################################################################################ +# This file is auto-generated. Do not modify by hand +################################################################################ + +from libc.stdio cimport FILE +from sage.libs.gmp.types cimport * +from sage.libs.mpfr.types cimport * +from sage.libs.flint.types cimport * + +cdef extern from "flint_wrap.h": + + void fq_zech_mat_init(fq_zech_mat_t mat, long rows, long cols, const fq_zech_ctx_t ctx) + # Initialises ``mat`` to a ``rows``-by-``cols`` matrix with + # coefficients in `\mathbf{F}_{q}` given by ``ctx``. All elements + # are set to zero. + + void fq_zech_mat_init_set(fq_zech_mat_t mat, const fq_zech_mat_t src, const fq_zech_ctx_t ctx) + # Initialises ``mat`` and sets its dimensions and elements to + # those of ``src``. + + void fq_zech_mat_clear(fq_zech_mat_t mat, const fq_zech_ctx_t ctx) + # Clears the matrix and releases any memory it used. The matrix + # cannot be used again until it is initialised. This function must be + # called exactly once when finished using an ``fq_zech_mat_t`` object. + + void fq_zech_mat_set(fq_zech_mat_t mat, const fq_zech_mat_t src, const fq_zech_ctx_t ctx) + # Sets ``mat`` to a copy of ``src``. It is assumed + # that ``mat`` and ``src`` have identical dimensions. + + fq_zech_struct * fq_zech_mat_entry(const fq_zech_mat_t mat, long i, long j) + # Directly accesses the entry in ``mat`` in row `i` and column `j`, + # indexed from zero. No bounds checking is performed. + + void fq_zech_mat_entry_set(fq_zech_mat_t mat, long i, long j, const fq_zech_t x, const fq_zech_ctx_t ctx) + # Sets the entry in ``mat`` in row `i` and column `j` to ``x``. + + long fq_zech_mat_nrows(const fq_zech_mat_t mat, const fq_zech_ctx_t ctx) + # Returns the number of rows in ``mat``. + + long fq_zech_mat_ncols(const fq_zech_mat_t mat, const fq_zech_ctx_t ctx) + # Returns the number of columns in ``mat``. + + void fq_zech_mat_swap(fq_zech_mat_t mat1, fq_zech_mat_t mat2, const fq_zech_ctx_t ctx) + # Swaps two matrices. The dimensions of ``mat1`` and ``mat2`` + # are allowed to be different. + + void fq_zech_mat_swap_entrywise(fq_zech_mat_t mat1, fq_zech_mat_t mat2, const fq_zech_ctx_t ctx) + # Swaps two matrices by swapping the individual entries rather than swapping + # the contents of the structs. + + void fq_zech_mat_zero(fq_zech_mat_t mat, const fq_zech_ctx_t ctx) + # Sets all entries of ``mat`` to 0. + + void fq_zech_mat_one(fq_zech_mat_t mat, const fq_zech_ctx_t ctx) + # Sets all diagonal entries of ``mat`` to 1 and all other entries to 0. + + void fq_zech_mat_set_nmod_mat(fq_zech_mat_t mat1, const nmod_mat_t mat2, const fq_zech_ctx_t ctx) + # Sets the matrix ``mat1`` to the matrix ``mat2``. + + void fq_zech_mat_set_fmpz_mod_mat(fq_zech_mat_t mat1, const fmpz_mod_mat_t mat2, const fq_zech_ctx_t ctx) + # Sets the matrix ``mat1`` to the matrix ``mat2``. + + void fq_zech_mat_concat_vertical(fq_zech_mat_t res, const fq_zech_mat_t mat1, const fq_zech_mat_t mat2, const fq_zech_ctx_t ctx) + # Sets ``res`` to vertical concatenation of (``mat1``, ``mat2``) in that order. Matrix dimensions : ``mat1`` : `m \times n`, ``mat2`` : `k \times n`, ``res`` : `(m + k) \times n`. + + void fq_zech_mat_concat_horizontal(fq_zech_mat_t res, const fq_zech_mat_t mat1, const fq_zech_mat_t mat2, const fq_zech_ctx_t ctx) + # Sets ``res`` to horizontal concatenation of (``mat1``, ``mat2``) in that order. Matrix dimensions : ``mat1`` : `m \times n`, ``mat2`` : `m \times k`, ``res`` : `m \times (n + k)`. + + int fq_zech_mat_print_pretty(const fq_zech_mat_t mat, const fq_zech_ctx_t ctx) + # Pretty-prints ``mat`` to ``stdout``. A header is printed + # followed by the rows enclosed in brackets. + + int fq_zech_mat_fprint_pretty(FILE * file, const fq_zech_mat_t mat, const fq_zech_ctx_t ctx) + # Pretty-prints ``mat`` to ``file``. A header is printed + # followed by the rows enclosed in brackets. + # In case of success, returns a positive value. In case of failure, + # returns a non-positive value. + + int fq_zech_mat_print(const fq_zech_mat_t mat, const fq_zech_ctx_t ctx) + # Prints ``mat`` to ``stdout``. A header is printed followed + # by the rows enclosed in brackets. + + int fq_zech_mat_fprint(FILE * file, const fq_zech_mat_t mat, const fq_zech_ctx_t ctx) + # Prints ``mat`` to ``file``. A header is printed followed by + # the rows enclosed in brackets. + # In case of success, returns a positive value. In case of failure, + # returns a non-positive value. + + void fq_zech_mat_window_init(fq_zech_mat_t window, const fq_zech_mat_t mat, long r1, long c1, long r2, long c2, const fq_zech_ctx_t ctx) + # Initializes the matrix ``window`` to be an ``r2 - r1`` by + # ``c2 - c1`` submatrix of ``mat`` whose ``(0,0)`` entry + # is the ``(r1, c1)`` entry of ``mat``. The memory for the + # elements of ``window`` is shared with ``mat``. + + void fq_zech_mat_window_clear(fq_zech_mat_t window, const fq_zech_ctx_t ctx) + # Clears the matrix ``window`` and releases any memory that it + # uses. Note that the memory to the underlying matrix that + # ``window`` points to is not freed. + + void fq_zech_mat_randtest(fq_zech_mat_t mat, flint_rand_t state, const fq_zech_ctx_t ctx) + # Sets the elements of ``mat`` to random elements of + # `\mathbf{F}_{q}`, given by ``ctx``. + + int fq_zech_mat_randpermdiag(fq_zech_mat_t mat, flint_rand_t state, fq_zech_struct * diag, long n, const fq_zech_ctx_t ctx) + # Sets ``mat`` to a random permutation of the diagonal matrix + # with `n` leading entries given by the vector ``diag``. It is + # assumed that the main diagonal of ``mat`` has room for at + # least `n` entries. + # Returns `0` or `1`, depending on whether the permutation is even + # or odd respectively. + + void fq_zech_mat_randrank(fq_zech_mat_t mat, flint_rand_t state, long rank, const fq_zech_ctx_t ctx) + # Sets ``mat`` to a random sparse matrix with the given rank, + # having exactly as many non-zero elements as the rank, with the + # non-zero elements being uniformly random elements of + # `\mathbf{F}_{q}`. + # The matrix can be transformed into a dense matrix with unchanged + # rank by subsequently calling :func:`fq_zech_mat_randops`. + + void fq_zech_mat_randops(fq_zech_mat_t mat, long count, flint_rand_t state, const fq_zech_ctx_t ctx) + # Randomises ``mat`` by performing elementary row or column + # operations. More precisely, at most ``count`` random additions + # or subtractions of distinct rows and columns will be performed. + # This leaves the rank (and for square matrices, determinant) + # unchanged. + + void fq_zech_mat_randtril(fq_zech_mat_t mat, flint_rand_t state, int unit, const fq_zech_ctx_t ctx) + # Sets ``mat`` to a random lower triangular matrix. If + # ``unit`` is 1, it will have ones on the main diagonal, + # otherwise it will have random nonzero entries on the main + # diagonal. + + void fq_zech_mat_randtriu(fq_zech_mat_t mat, flint_rand_t state, int unit, const fq_zech_ctx_t ctx) + # Sets ``mat`` to a random upper triangular matrix. If + # ``unit`` is 1, it will have ones on the main diagonal, + # otherwise it will have random nonzero entries on the main + # diagonal. + + int fq_zech_mat_equal(const fq_zech_mat_t mat1, const fq_zech_mat_t mat2, const fq_zech_ctx_t ctx) + # Returns nonzero if mat1 and mat2 have the same dimensions and elements, + # and zero otherwise. + + int fq_zech_mat_is_zero(const fq_zech_mat_t mat, const fq_zech_ctx_t ctx) + # Returns a non-zero value if all entries ``mat`` are zero, and + # otherwise returns zero. + + int fq_zech_mat_is_one(const fq_zech_mat_t mat, const fq_zech_ctx_t ctx) + # Returns a non-zero value if all entries ``mat`` are zero except the + # diagonal entries which must be one, otherwise returns zero. + + int fq_zech_mat_is_empty(const fq_zech_mat_t mat, const fq_zech_ctx_t ctx) + # Returns a non-zero value if the number of rows or the number of + # columns in ``mat`` is zero, and otherwise returns zero. + + int fq_zech_mat_is_square(const fq_zech_mat_t mat, const fq_zech_ctx_t ctx) + # Returns a non-zero value if the number of rows is equal to the + # number of columns in ``mat``, and otherwise returns zero. + + void fq_zech_mat_add(fq_zech_mat_t C, const fq_zech_mat_t A, const fq_zech_mat_t B, const fq_zech_ctx_t ctx) + # Computes `C = A + B`. Dimensions must be identical. + + void fq_zech_mat_sub(fq_zech_mat_t C, const fq_zech_mat_t A, const fq_zech_mat_t B, const fq_zech_ctx_t ctx) + # Computes `C = A - B`. Dimensions must be identical. + + void fq_zech_mat_neg(fq_zech_mat_t A, const fq_zech_mat_t B, const fq_zech_ctx_t ctx) + # Sets `B = -A`. Dimensions must be identical. + + void fq_zech_mat_mul(fq_zech_mat_t C, const fq_zech_mat_t A, const fq_zech_mat_t B, const fq_zech_ctx_t ctx) + # Sets `C = AB`. Dimensions must be compatible for matrix + # multiplication. `C` is not allowed to be aliased with `A` or + # `B`. This function automatically chooses between classical and + # KS multiplication. + + void fq_zech_mat_mul_classical(fq_zech_mat_t C, const fq_zech_mat_t A, const fq_zech_mat_t B, const fq_zech_ctx_t ctx) + # Sets `C = AB`. Dimensions must be compatible for matrix multiplication. + # `C` is not allowed to be aliased with `A` or `B`. Uses classical + # matrix multiplication. + + void fq_zech_mat_mul_KS(fq_zech_mat_t C, const fq_zech_mat_t A, const fq_zech_mat_t B, const fq_zech_ctx_t ctx) + # Sets `C = AB`. Dimensions must be compatible for matrix + # multiplication. `C` is not allowed to be aliased with `A` or + # `B`. Uses Kronecker substitution to perform the multiplication + # over the integers. + + void fq_zech_mat_submul(fq_zech_mat_t D, const fq_zech_mat_t C, const fq_zech_mat_t A, const fq_zech_mat_t B, const fq_zech_ctx_t ctx) + # Sets `D = C + AB`. `C` and `D` may be aliased with each other but + # not with `A` or `B`. + + void fq_zech_mat_mul_vec(fq_zech_struct * c, const fq_zech_mat_t A, const fq_zech_struct * b, long blen, const fq_zech_ctx_t ctx) + void fq_zech_mat_mul_vec_ptr(fq_zech_struct * const * c, const fq_zech_mat_t A, const fq_zech_struct * const * b, long blen, const fq_zech_ctx_t ctx) + # Compute a matrix-vector product of ``A`` and ``(b, blen)`` and store the result in ``c``. + # The vector ``(b, blen)`` is either truncated or zero-extended to the number of columns of ``A``. + # The number entries written to ``c`` is always equal to the number of rows of ``A``. + + void fq_zech_mat_vec_mul(fq_zech_struct * c, const fq_zech_struct * a, long alen, const fq_zech_mat_t B, const fq_zech_ctx_t ctx) + void fq_zech_mat_vec_mul_ptr(fq_zech_struct * const * c, const fq_zech_struct * const * a, long alen, const fq_zech_mat_t B, const fq_zech_ctx_t ctx) + # Compute a vector-matrix product of ``(a, alen)`` and ``B`` and and store the result in ``c``. + # The vector ``(a, alen)`` is either truncated or zero-extended to the number of rows of ``B``. + # The number entries written to ``c`` is always equal to the number of columns of ``B``. + + long fq_zech_mat_lu(long * P, fq_zech_mat_t A, int rank_check, const fq_zech_ctx_t ctx) + # Computes a generalised LU decomposition `LU = PA` of a given + # matrix `A`, returning the rank of `A`. + # If `A` is a nonsingular square matrix, it will be overwritten with + # a unit diagonal lower triangular matrix `L` and an upper + # triangular matrix `U` (the diagonal of `L` will not be stored + # explicitly). + # If `A` is an arbitrary matrix of rank `r`, `U` will be in row + # echelon form having `r` nonzero rows, and `L` will be lower + # triangular but truncated to `r` columns, having implicit ones on + # the `r` first entries of the main diagonal. All other entries will + # be zero. + # If a nonzero value for ``rank_check`` is passed, the function + # will abandon the output matrix in an undefined state and return 0 + # if `A` is detected to be rank-deficient. + # This function calls ``fq_zech_mat_lu_recursive``. + + long fq_zech_mat_lu_classical(long * P, fq_zech_mat_t A, int rank_check, const fq_zech_ctx_t ctx) + # Computes a generalised LU decomposition `LU = PA` of a given + # matrix `A`, returning the rank of `A`. The behavior of this + # function is identical to that of ``fq_zech_mat_lu``. Uses Gaussian + # elimination. + + long fq_zech_mat_lu_recursive(long * P, fq_zech_mat_t A, int rank_check, const fq_zech_ctx_t ctx) + # Computes a generalised LU decomposition `LU = PA` of a given + # matrix `A`, returning the rank of `A`. The behavior of this + # function is identical to that of ``fq_zech_mat_lu``. Uses recursive + # block decomposition, switching to classical Gaussian elimination + # for sufficiently small blocks. + + long fq_zech_mat_rref(fq_zech_mat_t A, const fq_zech_ctx_t ctx) + # Puts `A` in reduced row echelon form and returns the rank of `A`. + # The rref is computed by first obtaining an unreduced row echelon + # form via LU decomposition and then solving an additional + # triangular system. + + long fq_zech_mat_reduce_row(fq_zech_mat_t A, long * P, long * L, long n, const fq_zech_ctx_t ctx) + # Reduce row n of the matrix `A`, assuming the prior rows are in Gauss + # form. However those rows may not be in order. The entry `i` of the array + # `P` is the row of `A` which has a pivot in the `i`-th column. If no such + # row exists, the entry of `P` will be `-1`. The function returns the column + # in which the `n`-th row has a pivot after reduction. This will always be + # chosen to be the first available column for a pivot from the left. This + # information is also updated in `P`. Entry `i` of the array `L` contains the + # number of possibly nonzero columns of `A` row `i`. This speeds up reduction + # in the case that `A` is chambered on the right. Otherwise the entries of + # `L` can all be set to the number of columns of `A`. We require the entries + # of `L` to be monotonic increasing. + + void fq_zech_mat_solve_tril(fq_zech_mat_t X, const fq_zech_mat_t L, const fq_zech_mat_t B, int unit, const fq_zech_ctx_t ctx) + # Sets `X = L^{-1} B` where `L` is a full rank lower triangular + # square matrix. If ``unit`` = 1, `L` is assumed to have ones on + # its main diagonal, and the main diagonal will not be read. `X` + # and `B` are allowed to be the same matrix, but no other aliasing + # is allowed. Automatically chooses between the classical and + # recursive algorithms. + + void fq_zech_mat_solve_tril_classical(fq_zech_mat_t X, const fq_zech_mat_t L, const fq_zech_mat_t B, int unit, const fq_zech_ctx_t ctx) + # Sets `X = L^{-1} B` where `L` is a full rank lower triangular + # square matrix. If ``unit`` = 1, `L` is assumed to have ones on + # its main diagonal, and the main diagonal will not be read. `X` + # and `B` are allowed to be the same matrix, but no other aliasing + # is allowed. Uses forward substitution. + + void fq_zech_mat_solve_tril_recursive(fq_zech_mat_t X, const fq_zech_mat_t L, const fq_zech_mat_t B, int unit, const fq_zech_ctx_t ctx) + # Sets `X = L^{-1} B` where `L` is a full rank lower triangular + # square matrix. If ``unit`` = 1, `L` is assumed to have ones on + # its main diagonal, and the main diagonal will not be read. `X` + # and `B` are allowed to be the same matrix, but no other aliasing + # is allowed. + # Uses the block inversion formula + # .. math :: + # \begin{pmatrix} A & 0 \\ C & D \end{pmatrix}^{-1} + # \begin{pmatrix} X \\ Y \end{pmatrix} = + # \begin{pmatrix} A^{-1} X \\ D^{-1} ( Y - C A^{-1} X ) \end{pmatrix} + # to reduce the problem to matrix multiplication and triangular + # solving of smaller systems. + + void fq_zech_mat_solve_triu(fq_zech_mat_t X, const fq_zech_mat_t U, const fq_zech_mat_t B, int unit, const fq_zech_ctx_t ctx) + # Sets `X = U^{-1} B` where `U` is a full rank upper triangular + # square matrix. If ``unit`` = 1, `U` is assumed to have ones on + # its main diagonal, and the main diagonal will not be read. `X` + # and `B` are allowed to be the same matrix, but no other aliasing + # is allowed. Automatically chooses between the classical and + # recursive algorithms. + + void fq_zech_mat_solve_triu_classical(fq_zech_mat_t X, const fq_zech_mat_t U, const fq_zech_mat_t B, int unit, const fq_zech_ctx_t ctx) + # Sets `X = U^{-1} B` where `U` is a full rank upper triangular + # square matrix. If ``unit`` = 1, `U` is assumed to have ones on + # its main diagonal, and the main diagonal will not be read. `X` + # and `B` are allowed to be the same matrix, but no other aliasing + # is allowed. Uses forward substitution. + + void fq_zech_mat_solve_triu_recursive(fq_zech_mat_t X, const fq_zech_mat_t U, const fq_zech_mat_t B, int unit, const fq_zech_ctx_t ctx) + # Sets `X = U^{-1} B` where `U` is a full rank upper triangular + # square matrix. If ``unit`` = 1, `U` is assumed to have ones on + # its main diagonal, and the main diagonal will not be read. `X` + # and `B` are allowed to be the same matrix, but no other aliasing + # is allowed. + # Uses the block inversion formula + # .. math :: + # \begin{pmatrix} A & B \\ 0 & D \end{pmatrix}^{-1} + # \begin{pmatrix} X \\ Y \end{pmatrix} = + # \begin{pmatrix} A^{-1} (X - B D^{-1} Y) \\ D^{-1} Y \end{pmatrix} + # to reduce the problem to matrix multiplication and triangular + # solving of smaller systems. + + int fq_zech_mat_solve(fq_zech_mat_t X, const fq_zech_mat_t A, const fq_zech_mat_t B, const fq_zech_ctx_t ctx) + # Solves the matrix-matrix equation `AX = B`. + # Returns `1` if `A` has full rank; otherwise returns `0` and sets the + # elements of `X` to undefined values. + # The matrix `A` must be square. + + int fq_zech_mat_can_solve(fq_zech_mat_t X, const fq_zech_mat_t A, const fq_zech_mat_t B, const fq_zech_ctx_t ctx) + # Solves the matrix-matrix equation `AX = B` over `Fq`. + # Returns `1` if a solution exists; otherwise returns `0` and sets the + # elements of `X` to zero. If more than one solution exists, one of the + # valid solutions is given. + # There are no restrictions on the shape of `A` and it may be singular. + + void fq_zech_mat_similarity(fq_zech_mat_t M, long r, fq_zech_t d, const fq_zech_ctx_t ctx) + # Applies a similarity transform to the `n\times n` matrix `M` in-place. + # If `P` is the `n\times n` identity matrix the zero entries of whose row + # `r` (`0`-indexed) have been replaced by `d`, this transform is equivalent + # to `M = P^{-1}MP`. + # Similarity transforms preserve the determinant, characteristic polynomial + # and minimal polynomial. + # The value `d` is required to be reduced modulo the modulus of the entries + # in the matrix. + + void fq_zech_mat_charpoly_danilevsky(fq_zech_poly_t p, const fq_zech_mat_t M, const fq_zech_ctx_t ctx) + # Compute the characteristic polynomial `p` of the matrix `M`. The matrix + # is assumed to be square. + + void fq_zech_mat_charpoly(fq_zech_poly_t p, const fq_zech_mat_t M, const fq_zech_ctx_t ctx) + # Compute the characteristic polynomial `p` of the matrix `M`. The matrix + # is required to be square, otherwise an exception is raised. + + void fq_zech_mat_minpoly(fq_zech_poly_t p, const fq_zech_mat_t M, const fq_zech_ctx_t ctx) + # Compute the minimal polynomial `p` of the matrix `M`. The matrix + # is required to be square, otherwise an exception is raised. diff --git a/src/sage/libs/flint/fq_zech_poly.pxd b/src/sage/libs/flint/fq_zech_poly.pxd new file mode 100644 index 00000000000..31d19a35841 --- /dev/null +++ b/src/sage/libs/flint/fq_zech_poly.pxd @@ -0,0 +1,1036 @@ +# distutils: libraries = flint +# distutils: depends = flint/fq_zech_poly.h + +################################################################################ +# This file is auto-generated. Do not modify by hand +################################################################################ + +from libc.stdio cimport FILE +from sage.libs.gmp.types cimport * +from sage.libs.mpfr.types cimport * +from sage.libs.flint.types cimport * + +cdef extern from "flint_wrap.h": + + void fq_zech_poly_init(fq_zech_poly_t poly, const fq_zech_ctx_t ctx) + # Initialises ``poly`` for use, with context ctx, and setting its + # length to zero. A corresponding call to :func:`fq_zech_poly_clear` + # must be made after finishing with the ``fq_zech_poly_t`` to free the + # memory used by the polynomial. + + void fq_zech_poly_init2(fq_zech_poly_t poly, long alloc, const fq_zech_ctx_t ctx) + # Initialises ``poly`` with space for at least ``alloc`` + # coefficients and sets the length to zero. The allocated + # coefficients are all set to zero. A corresponding call to + # :func:`fq_zech_poly_clear` must be made after finishing with the + # ``fq_zech_poly_t`` to free the memory used by the polynomial. + + void fq_zech_poly_realloc(fq_zech_poly_t poly, long alloc, const fq_zech_ctx_t ctx) + # Reallocates the given polynomial to have space for ``alloc`` + # coefficients. If ``alloc`` is zero the polynomial is cleared + # and then reinitialised. If the current length is greater than + # ``alloc`` the polynomial is first truncated to length + # ``alloc``. + + void fq_zech_poly_fit_length(fq_zech_poly_t poly, long len, const fq_zech_ctx_t ctx) + # If ``len`` is greater than the number of coefficients currently + # allocated, then the polynomial is reallocated to have space for at + # least ``len`` coefficients. No data is lost when calling this + # function. + # The function efficiently deals with the case where + # ``fit_length`` is called many times in small increments by at + # least doubling the number of allocated coefficients when length is + # larger than the number of coefficients currently allocated. + + void _fq_zech_poly_set_length(fq_zech_poly_t poly, long newlen, const fq_zech_ctx_t ctx) + # Sets the coefficients of ``poly`` beyond ``len`` to zero and + # sets the length of ``poly`` to ``len``. + + void fq_zech_poly_clear(fq_zech_poly_t poly, const fq_zech_ctx_t ctx) + # Clears the given polynomial, releasing any memory used. It must + # be reinitialised in order to be used again. + + void _fq_zech_poly_normalise(fq_zech_poly_t poly, const fq_zech_ctx_t ctx) + # Sets the length of ``poly`` so that the top coefficient is + # non-zero. If all coefficients are zero, the length is set to + # zero. This function is mainly used internally, as all functions + # guarantee normalisation. + + void _fq_zech_poly_normalise2(const fq_zech_struct *poly, long *length, const fq_zech_ctx_t ctx) + # Sets the length ``length`` of ``(poly,length)`` so that the + # top coefficient is non-zero. If all coefficients are zero, the + # length is set to zero. This function is mainly used internally, as + # all functions guarantee normalisation. + + void fq_zech_poly_truncate(fq_zech_poly_t poly, long newlen, const fq_zech_ctx_t ctx) + # Truncates the polynomial to length at most `n`. + + void fq_zech_poly_set_trunc(fq_zech_poly_t poly1, fq_zech_poly_t poly2, long newlen, const fq_zech_ctx_t ctx) + # Sets ``poly1`` to ``poly2`` truncated to length `n`. + + void _fq_zech_poly_reverse(fq_zech_struct* output, const fq_zech_struct* input, long len, long m, const fq_zech_ctx_t ctx) + # Sets ``output`` to the reverse of ``input``, which is of + # length ``len``, but thinking of it as a polynomial of + # length ``m``, notionally zero-padded if necessary. The + # length ``m`` must be non-negative, but there are no other + # restrictions. The polynomial ``output`` must have space for + # ``m`` coefficients. + + void fq_zech_poly_reverse(fq_zech_poly_t output, const fq_zech_poly_t input, long m, const fq_zech_ctx_t ctx) + # Sets ``output`` to the reverse of ``input``, thinking of it + # as a polynomial of length ``m``, notionally zero-padded if + # necessary). The length ``m`` must be non-negative, but there + # are no other restrictions. The output polynomial will be set to + # length ``m`` and then normalised. + + long fq_zech_poly_degree(const fq_zech_poly_t poly, const fq_zech_ctx_t ctx) + # Returns the degree of the polynomial ``poly``. + + long fq_zech_poly_length(const fq_zech_poly_t poly, const fq_zech_ctx_t ctx) + # Returns the length of the polynomial ``poly``. + + fq_zech_struct * fq_zech_poly_lead(const fq_zech_poly_t poly, const fq_zech_ctx_t ctx) + # Returns a pointer to the leading coefficient of ``poly``, or + # ``NULL`` if ``poly`` is the zero polynomial. + + void fq_zech_poly_randtest(fq_zech_poly_t f, flint_rand_t state, long len, const fq_zech_ctx_t ctx) + # Sets `f` to a random polynomial of length at most ``len`` + # with entries in the field described by ``ctx``. + + void fq_zech_poly_randtest_not_zero(fq_zech_poly_t f, flint_rand_t state, long len, const fq_zech_ctx_t ctx) + # Same as ``fq_zech_poly_randtest`` but guarantees that the polynomial + # is not zero. + + void fq_zech_poly_randtest_monic(fq_zech_poly_t f, flint_rand_t state, long len, const fq_zech_ctx_t ctx) + # Sets `f` to a random monic polynomial of length ``len`` with + # entries in the field described by ``ctx``. + + void fq_zech_poly_randtest_irreducible(fq_zech_poly_t f, flint_rand_t state, long len, const fq_zech_ctx_t ctx) + # Sets `f` to a random monic, irreducible polynomial of length + # ``len`` with entries in the field described by ``ctx``. + + void _fq_zech_poly_set(fq_zech_struct *rop, const fq_zech_struct *op, long len, const fq_zech_ctx_t ctx) + # Sets ``(rop, len``) to ``(op, len)``. + + void fq_zech_poly_set(fq_zech_poly_t poly1, const fq_zech_poly_t poly2, const fq_zech_ctx_t ctx) + # Sets the polynomial ``poly1`` to the polynomial ``poly2``. + + void fq_zech_poly_set_fq_zech(fq_zech_poly_t poly, const fq_zech_t c, const fq_zech_ctx_t ctx) + # Sets the polynomial ``poly`` to ``c``. + + void fq_zech_poly_set_fmpz_mod_poly(fq_zech_poly_t rop, const fmpz_mod_poly_t op, const fq_zech_ctx_t ctx) + # Sets the polynomial ``rop`` to the polynomial ``op`` + + void fq_zech_poly_set_nmod_poly(fq_zech_poly_t rop, const nmod_poly_t op, const fq_zech_ctx_t ctx) + # Sets the polynomial ``rop`` to the polynomial ``op`` + + void fq_zech_poly_swap(fq_zech_poly_t op1, fq_zech_poly_t op2, const fq_zech_ctx_t ctx) + # Swaps the two polynomials ``op1`` and ``op2``. + + void _fq_zech_poly_zero(fq_zech_struct *rop, long len, const fq_zech_ctx_t ctx) + # Sets ``(rop, len)`` to the zero polynomial. + + void fq_zech_poly_zero(fq_zech_poly_t poly, const fq_zech_ctx_t ctx) + # Sets ``poly`` to the zero polynomial. + + void fq_zech_poly_one(fq_zech_poly_t poly, const fq_zech_ctx_t ctx) + # Sets ``poly`` to the constant polynomial `1`. + + void fq_zech_poly_gen(fq_zech_poly_t poly, const fq_zech_ctx_t ctx) + # Sets ``poly`` to the polynomial `x`. + + void fq_zech_poly_make_monic(fq_zech_poly_t rop, const fq_zech_poly_t op, const fq_zech_ctx_t ctx) + # Sets ``rop`` to ``op``, normed to have leading coefficient 1. + + void _fq_zech_poly_make_monic(fq_zech_struct *rop, const fq_zech_struct *op, long length, const fq_zech_ctx_t ctx) + # Sets ``rop`` to ``(op,length)``, normed to have leading coefficient 1. + # Assumes that ``rop`` has enough space for the polynomial, assumes that + # ``op`` is not zero (and thus has an invertible leading coefficient). + + void fq_zech_poly_get_coeff(fq_zech_t x, const fq_zech_poly_t poly, long n, const fq_zech_ctx_t ctx) + # Sets `x` to the coefficient of `X^n` in ``poly``. + + void fq_zech_poly_set_coeff(fq_zech_poly_t poly, long n, const fq_zech_t x, const fq_zech_ctx_t ctx) + # Sets the coefficient of `X^n` in ``poly`` to `x`. + + void fq_zech_poly_set_coeff_fmpz(fq_zech_poly_t poly, long n, const fmpz_t x, const fq_zech_ctx_t ctx) + # Sets the coefficient of `X^n` in the polynomial to `x`, + # assuming `n \geq 0`. + + int fq_zech_poly_equal(const fq_zech_poly_t poly1, const fq_zech_poly_t poly2, const fq_zech_ctx_t ctx) + # Returns nonzero if the two polynomials ``poly1`` and ``poly2`` + # are equal, otherwise return zero. + + int fq_zech_poly_equal_trunc(const fq_zech_poly_t poly1, const fq_zech_poly_t poly2, long n, const fq_zech_ctx_t ctx) + # Notionally truncate ``poly1`` and ``poly2`` to length `n` and + # return nonzero if they are equal, otherwise return zero. + + int fq_zech_poly_is_zero(const fq_zech_poly_t poly, const fq_zech_ctx_t ctx) + # Returns whether the polynomial ``poly`` is the zero polynomial. + + int fq_zech_poly_is_one(const fq_zech_poly_t op, const fq_zech_ctx_t ctx) + # Returns whether the polynomial ``poly`` is equal + # to the constant polynomial `1`. + + int fq_zech_poly_is_gen(const fq_zech_poly_t op, const fq_zech_ctx_t ctx) + # Returns whether the polynomial ``poly`` is equal + # to the polynomial `x`. + + int fq_zech_poly_is_unit(const fq_zech_poly_t op, const fq_zech_ctx_t ctx) + # Returns whether the polynomial ``poly`` is a unit in the polynomial + # ring `\mathbf{F}_q[X]`, i.e. if it has degree `0` and is non-zero. + + int fq_zech_poly_equal_fq_zech(const fq_zech_poly_t poly, const fq_zech_t c, const fq_zech_ctx_t ctx) + # Returns whether the polynomial ``poly`` is equal the (constant) + # `\mathbf{F}_q` element ``c`` + + void _fq_zech_poly_add(fq_zech_struct *res, const fq_zech_struct *poly1, long len1, const fq_zech_struct *poly2, long len2, const fq_zech_ctx_t ctx) + # Sets ``res`` to the sum of ``(poly1,len1)`` and ``(poly2,len2)``. + + void fq_zech_poly_add(fq_zech_poly_t res, const fq_zech_poly_t poly1, const fq_zech_poly_t poly2, const fq_zech_ctx_t ctx) + # Sets ``res`` to the sum of ``poly1`` and ``poly2``. + + void fq_zech_poly_add_si(fq_zech_poly_t res, const fq_zech_poly_t poly1, long c, const fq_zech_ctx_t ctx) + # Sets ``res`` to the sum of ``poly1`` and ``c``. + + void fq_zech_poly_add_series(fq_zech_poly_t res, const fq_zech_poly_t poly1, const fq_zech_poly_t poly2, long n, const fq_zech_ctx_t ctx) + # Notionally truncate ``poly1`` and ``poly2`` to length ``n`` and set + # ``res`` to the sum. + + void _fq_zech_poly_sub(fq_zech_struct *res, const fq_zech_struct *poly1, long len1, const fq_zech_struct *poly2, long len2, const fq_zech_ctx_t ctx) + # Sets ``res`` to the difference of ``(poly1,len1)`` and + # ``(poly2,len2)``. + + void fq_zech_poly_sub(fq_zech_poly_t res, const fq_zech_poly_t poly1, const fq_zech_poly_t poly2, const fq_zech_ctx_t ctx) + # Sets ``res`` to the difference of ``poly1`` and ``poly2``. + + void fq_zech_poly_sub_series(fq_zech_poly_t res, const fq_zech_poly_t poly1, const fq_zech_poly_t poly2, long n, const fq_zech_ctx_t ctx) + # Notionally truncate ``poly1`` and ``poly2`` to length ``n`` and set + # ``res`` to the difference. + + void _fq_zech_poly_neg(fq_zech_struct *rop, const fq_zech_struct *op, long len, const fq_zech_ctx_t ctx) + # Sets ``rop`` to the additive inverse of ``(op,len)``. + + void fq_zech_poly_neg(fq_zech_poly_t res, const fq_zech_poly_t poly, const fq_zech_ctx_t ctx) + # Sets ``res`` to the additive inverse of ``poly``. + + void _fq_zech_poly_scalar_mul_fq_zech(fq_zech_struct *rop, const fq_zech_struct *op, long len, const fq_zech_t x, const fq_zech_ctx_t ctx) + # Sets ``(rop,len)`` to the product of ``(op,len)`` by the + # scalar ``x``, in the context defined by ``ctx``. + + void fq_zech_poly_scalar_mul_fq_zech(fq_zech_poly_t rop, const fq_zech_poly_t op, const fq_zech_t x, const fq_zech_ctx_t ctx) + # Sets ``rop`` to the product of ``op`` by the scalar ``x``, in the context + # defined by ``ctx``. + + void _fq_zech_poly_scalar_addmul_fq_zech(fq_zech_struct *rop, const fq_zech_struct *op, long len, const fq_zech_t x, const fq_zech_ctx_t ctx) + # Adds to ``(rop,len)`` the product of ``(op,len)`` by the + # scalar ``x``, in the context defined by ``ctx``. + # In particular, assumes the same length for ``op`` and + # ``rop``. + + void fq_zech_poly_scalar_addmul_fq_zech(fq_zech_poly_t rop, const fq_zech_poly_t op, const fq_zech_t x, const fq_zech_ctx_t ctx) + # Adds to ``rop`` the product of ``op`` by the + # scalar ``x``, in the context defined by ``ctx``. + + void _fq_zech_poly_scalar_submul_fq_zech(fq_zech_struct *rop, const fq_zech_struct *op, long len, const fq_zech_t x, const fq_zech_ctx_t ctx) + # Subtracts from ``(rop,len)`` the product of ``(op,len)`` by the + # scalar ``x``, in the context defined by ``ctx``. + # In particular, assumes the same length for ``op`` and + # ``rop``. + + void fq_zech_poly_scalar_submul_fq_zech(fq_zech_poly_t rop, const fq_zech_poly_t op, const fq_zech_t x, const fq_zech_ctx_t ctx) + # Subtracts from ``rop`` the product of ``op`` by the + # scalar ``x``, in the context defined by ``ctx``. + + void _fq_zech_poly_scalar_div_fq_zech(fq_zech_struct *rop, const fq_zech_struct *op, long len, const fq_zech_t x, const fq_zech_ctx_t ctx) + # Sets ``(rop,len)`` to the quotient of ``(op,len)`` by the + # scalar ``x``, in the context defined by ``ctx``. An exception is raised + # if ``x`` is zero. + + void fq_zech_poly_scalar_div_fq_zech(fq_zech_poly_t rop, const fq_zech_poly_t op, const fq_zech_t x, const fq_zech_ctx_t ctx) + # Sets ``rop`` to the quotient of ``op`` by the scalar ``x``, in the context + # defined by ``ctx``. An exception is raised if ``x`` is zero. + + void _fq_zech_poly_mul_classical(fq_zech_struct *rop, const fq_zech_struct *op1, long len1, const fq_zech_struct *op2, long len2, const fq_zech_ctx_t ctx) + # Sets ``(rop, len1 + len2 - 1)`` to the product of ``(op1, len1)`` + # and ``(op2, len2)``, assuming that ``len1`` is at least ``len2`` + # and neither is zero. + # Permits zero padding. Does not support aliasing of ``rop`` + # with either ``op1`` or ``op2``. + + void fq_zech_poly_mul_classical(fq_zech_poly_t rop, const fq_zech_poly_t op1, const fq_zech_poly_t op2, const fq_zech_ctx_t ctx) + # Sets ``rop`` to the product of ``op1`` and ``op2`` + # using classical polynomial multiplication. + + void _fq_zech_poly_mul_reorder(fq_zech_struct *rop, const fq_zech_struct *op1, long len1, const fq_zech_struct *op2, long len2, const fq_zech_ctx_t ctx) + # Sets ``(rop, len1 + len2 - 1)`` to the product of ``(op1, len1)`` + # and ``(op2, len2)``, assuming that ``len1`` and ``len2`` are + # non-zero. + # Permits zero padding. Supports aliasing. + + void fq_zech_poly_mul_reorder(fq_zech_poly_t rop, const fq_zech_poly_t op1, const fq_zech_poly_t op2, const fq_zech_ctx_t ctx) + # Sets ``rop`` to the product of ``op1`` and ``op2``, + # reordering the two indeterminates `X` and `Y` when viewing + # the polynomials as elements of `\mathbf{F}_p[X,Y]`. + # Suppose `\mathbf{F}_q = \mathbf{F}_p[X]/ (f(X))` and recall + # that elements of `\mathbf{F}_q` are internally represented + # by elements of type ``fmpz_poly``. For small degree extensions + # but polynomials in `\mathbf{F}_q[Y]` of large degree `n`, we + # change the representation to + # .. math :: + # \begin{split} + # g(Y) & = \sum_{i=0}^{n} a_i(X) Y^i \\ + # & = \sum_{j=0}^{d} \sum_{i=0}^{n} \text{Coeff}(a_i(X), j) Y^i. + # \end{split} + # This allows us to use a poor algorithm (such as classical multiplication) + # in the `X`-direction and leverage the existing fast integer + # multiplication routines in the `Y`-direction where the polynomial + # degree `n` is large. + + void _fq_zech_poly_mul_KS(fq_zech_struct *rop, const fq_zech_struct *op1, long len1, const fq_zech_struct *op2, long len2, const fq_zech_ctx_t ctx) + # Sets ``(rop, len1 + len2 - 1)`` to the product of ``(op1, len1)`` + # and ``(op2, len2)``. + # Permits zero padding and places no assumptions on the + # lengths ``len1`` and ``len2``. Supports aliasing. + + void fq_zech_poly_mul_KS(fq_zech_poly_t rop, const fq_zech_poly_t op1, const fq_zech_poly_t op2, const fq_zech_ctx_t ctx) + # Sets ``rop`` to the product of ``op1`` and ``op2`` + # using Kronecker substitution, that is, by encoding each + # coefficient in `\mathbf{F}_{q}` as an integer and reducing + # this problem to multiplying two polynomials over the integers. + + void _fq_zech_poly_mul(fq_zech_struct *rop, const fq_zech_struct *op1, long len1, const fq_zech_struct *op2, long len2, const fq_zech_ctx_t ctx) + # Sets ``(rop, len1 + len2 - 1)`` to the product of ``(op1, len1)`` + # and ``(op2, len2)``, choosing an appropriate algorithm. + # Permits zero padding. Does not support aliasing. + + void fq_zech_poly_mul(fq_zech_poly_t rop, const fq_zech_poly_t op1, const fq_zech_poly_t op2, const fq_zech_ctx_t ctx) + # Sets ``rop`` to the product of ``op1`` and ``op2``, + # choosing an appropriate algorithm. + + void _fq_zech_poly_mullow_classical(fq_zech_struct *rop, const fq_zech_struct *op1, long len1, const fq_zech_struct *op2, long len2, long n, const fq_zech_ctx_t ctx) + # Sets ``(rop, n)`` to the first `n` coefficients of + # ``(op1, len1)`` multiplied by ``(op2, len2)``. + # Assumes ``0 < n <= len1 + len2 - 1``. Assumes neither + # ``len1`` nor ``len2`` is zero. + + void fq_zech_poly_mullow_classical(fq_zech_poly_t rop, const fq_zech_poly_t op1, const fq_zech_poly_t op2, long n, const fq_zech_ctx_t ctx) + # Sets ``rop`` to the product of ``op1`` and ``op2``, + # computed using the classical or schoolbook method. + + void _fq_zech_poly_mullow_KS(fq_zech_struct *rop, const fq_zech_struct *op1, long len1, const fq_zech_struct *op2, long len2, long n, const fq_zech_ctx_t ctx) + # Sets ``(rop, n)`` to the lowest `n` coefficients of the product of + # ``(op1, len1)`` and ``(op2, len2)``. + # Assumes that ``len1`` and ``len2`` are positive, but does allow + # for the polynomials to be zero-padded. The polynomials may be zero, + # too. Assumes `n` is positive. Supports aliasing between ``rop``, + # ``op1`` and ``op2``. + + void fq_zech_poly_mullow_KS(fq_zech_poly_t rop, const fq_zech_poly_t op1, const fq_zech_poly_t op2, long n, const fq_zech_ctx_t ctx) + # Sets ``rop`` to the product of ``op1`` and ``op2``. + + void _fq_zech_poly_mullow(fq_zech_struct *rop, const fq_zech_struct *op1, long len1, const fq_zech_struct *op2, long len2, long n, const fq_zech_ctx_t ctx) + # Sets ``(rop, n)`` to the lowest `n` coefficients of the product of + # ``(op1, len1)`` and ``(op2, len2)``. + # Assumes ``0 < n <= len1 + len2 - 1``. Allows for zero-padding in + # the inputs. Does not support aliasing between the inputs and the output. + + void fq_zech_poly_mullow(fq_zech_poly_t rop, const fq_zech_poly_t op1, const fq_zech_poly_t op2, long n, const fq_zech_ctx_t ctx) + # Sets ``rop`` to the lowest `n` coefficients of the product of + # ``op1`` and ``op2``. + + void _fq_zech_poly_mulhigh_classical(fq_zech_struct *res, const fq_zech_struct *poly1, long len1, const fq_zech_struct *poly2, long len2, long start, const fq_zech_ctx_t ctx) + # Computes the product of ``(poly1, len1)`` and ``(poly2, len2)`` + # and writes the coefficients from ``start`` onwards into the high + # coefficients of ``res``, the remaining coefficients being arbitrary + # but reduced. Assumes that ``len1 >= len2 > 0``. Aliasing of inputs + # and output is not permitted. Algorithm is classical multiplication. + + void fq_zech_poly_mulhigh_classical(fq_zech_poly_t res, const fq_zech_poly_t poly1, const fq_zech_poly_t poly2, long start, const fq_zech_ctx_t ctx) + # Computes the product of ``poly1`` and ``poly2`` and writes the + # coefficients from ``start`` onwards into the high coefficients of + # ``res``, the remaining coefficients being arbitrary but reduced. + # Algorithm is classical multiplication. + + void _fq_zech_poly_mulhigh(fq_zech_struct *res, const fq_zech_struct *poly1, long len1, const fq_zech_struct *poly2, long len2, long start, fq_zech_ctx_t ctx) + # Computes the product of ``(poly1, len1)`` and ``(poly2, len2)`` + # and writes the coefficients from ``start`` onwards into the high + # coefficients of ``res``, the remaining coefficients being arbitrary + # but reduced. Assumes that ``len1 >= len2 > 0``. Aliasing of inputs + # and output is not permitted. + + void fq_zech_poly_mulhigh(fq_zech_poly_t res, const fq_zech_poly_t poly1, const fq_zech_poly_t poly2, long start, const fq_zech_ctx_t ctx) + # Computes the product of ``poly1`` and ``poly2`` and writes the + # coefficients from ``start`` onwards into the high coefficients of + # ``res``, the remaining coefficients being arbitrary but reduced. + + void _fq_zech_poly_mulmod(fq_zech_struct* res, const fq_zech_struct* poly1, long len1, const fq_zech_struct* poly2, long len2, const fq_zech_struct* f, long lenf, const fq_zech_ctx_t ctx) + # Sets ``res`` to the remainder of the product of ``poly1`` + # and ``poly2`` upon polynomial division by ``f``. + # It is required that ``len1 + len2 - lenf > 0``, which is + # equivalent to requiring that the result will actually be + # reduced. Otherwise, simply use ``_fq_zech_poly_mul`` instead. + # Aliasing of ``f`` and ``res`` is not permitted. + + void fq_zech_poly_mulmod(fq_zech_poly_t res, const fq_zech_poly_t poly1, const fq_zech_poly_t poly2, const fq_zech_poly_t f, const fq_zech_ctx_t ctx) + # Sets ``res`` to the remainder of the product of ``poly1`` + # and ``poly2`` upon polynomial division by ``f``. + + void _fq_zech_poly_mulmod_preinv(fq_zech_struct* res, const fq_zech_struct* poly1, long len1, const fq_zech_struct* poly2, long len2, const fq_zech_struct* f, long lenf, const fq_zech_struct* finv, long lenfinv, const fq_zech_ctx_t ctx) + # Sets ``res`` to the remainder of the product of ``poly1`` + # and ``poly2`` upon polynomial division by ``f``. + # It is required that ``finv`` is the inverse of the reverse of + # ``f`` mod ``x^lenf``. + # Aliasing of ``res`` with any of the inputs is not permitted. + + void fq_zech_poly_mulmod_preinv(fq_zech_poly_t res, const fq_zech_poly_t poly1, const fq_zech_poly_t poly2, const fq_zech_poly_t f, const fq_zech_poly_t finv, const fq_zech_ctx_t ctx) + # Sets ``res`` to the remainder of the product of ``poly1`` + # and ``poly2`` upon polynomial division by ``f``. ``finv`` + # is the inverse of the reverse of ``f``. + + void _fq_zech_poly_sqr_classical(fq_zech_struct *rop, const fq_zech_struct *op, long len, const fq_zech_ctx_t ctx) + # Sets ``(rop, 2*len - 1)`` to the square of ``(op, len)``, + # assuming that ``(op,len)`` is not zero and using classical + # polynomial multiplication. + # Permits zero padding. Does not support aliasing of ``rop`` + # with either ``op1`` or ``op2``. + + void fq_zech_poly_sqr_classical(fq_zech_poly_t rop, const fq_zech_poly_t op, const fq_zech_ctx_t ctx) + # Sets ``rop`` to the square of ``op`` using classical + # polynomial multiplication. + + void _fq_zech_poly_sqr_KS(fq_zech_struct *rop, const fq_zech_struct *op, long len, const fq_zech_ctx_t ctx) + # Sets ``(rop, 2*len - 1)`` to the square of ``(op, len)``. + # Permits zero padding and places no assumptions on the + # lengths ``len1`` and ``len2``. Supports aliasing. + + void fq_zech_poly_sqr_KS(fq_zech_poly_t rop, const fq_zech_poly_t op, const fq_zech_ctx_t ctx) + # Sets ``rop`` to the square ``op`` using Kronecker substitution, + # that is, by encoding each coefficient in `\mathbf{F}_{q}` as an integer + # and reducing this problem to multiplying two polynomials over the integers. + + void _fq_zech_poly_sqr(fq_zech_struct *rop, const fq_zech_struct *op, long len, const fq_zech_ctx_t ctx) + # Sets ``(rop, 2* len - 1)`` to the square of ``(op, len)``, + # choosing an appropriate algorithm. + # Permits zero padding. Does not support aliasing. + + void fq_zech_poly_sqr(fq_zech_poly_t rop, const fq_zech_poly_t op, const fq_zech_ctx_t ctx) + # Sets ``rop`` to the square of ``op``, + # choosing an appropriate algorithm. + + void _fq_zech_poly_pow(fq_zech_struct *rop, const fq_zech_struct *op, long len, unsigned long e, const fq_zech_ctx_t ctx) + # Sets ``rop = op^e``, assuming that ``e, len > 0`` and that + # ``res`` has space for ``e*(len - 1) + 1`` coefficients. Does + # not support aliasing. + + void fq_zech_poly_pow(fq_zech_poly_t rop, const fq_zech_poly_t op, unsigned long e, const fq_zech_ctx_t ctx) + # Computes ``rop = op^e``. If `e` is zero, returns one, + # so that in particular ``0^0 = 1``. + + void _fq_zech_poly_powmod_ui_binexp(fq_zech_struct* res, const fq_zech_struct* poly, unsigned long e, const fq_zech_struct* f, long lenf, const fq_zech_ctx_t ctx) + # Sets ``res`` to ``poly`` raised to the power ``e`` modulo + # ``f``, using binary exponentiation. We require ``e > 0``. + # We require ``lenf > 1``. It is assumed that ``poly`` is + # already reduced modulo ``f`` and zero-padded as necessary to + # have length exactly ``lenf - 1``. The output ``res`` must + # have room for ``lenf - 1`` coefficients. + + void fq_zech_poly_powmod_ui_binexp(fq_zech_poly_t res, const fq_zech_poly_t poly, unsigned long e, const fq_zech_poly_t f, const fq_zech_ctx_t ctx) + # Sets ``res`` to ``poly`` raised to the power ``e`` modulo + # ``f``, using binary exponentiation. We require ``e >= 0``. + + void _fq_zech_poly_powmod_ui_binexp_preinv(fq_zech_struct* res, const fq_zech_struct* poly, unsigned long e, const fq_zech_struct* f, long lenf, const fq_zech_struct* finv, long lenfinv, const fq_zech_ctx_t ctx) + # Sets ``res`` to ``poly`` raised to the power ``e`` modulo + # ``f``, using binary exponentiation. We require ``e > 0``. + # We require ``finv`` to be the inverse of the reverse of + # ``f``. + # We require ``lenf > 1``. It is assumed that ``poly`` is + # already reduced modulo ``f`` and zero-padded as necessary to + # have length exactly ``lenf - 1``. The output ``res`` must + # have room for ``lenf - 1`` coefficients. + + void fq_zech_poly_powmod_ui_binexp_preinv(fq_zech_poly_t res, const fq_zech_poly_t poly, unsigned long e, const fq_zech_poly_t f, const fq_zech_poly_t finv, const fq_zech_ctx_t ctx) + # Sets ``res`` to ``poly`` raised to the power ``e`` modulo + # ``f``, using binary exponentiation. We require ``e >= 0``. + # We require ``finv`` to be the inverse of the reverse of + # ``f``. + + void _fq_zech_poly_powmod_fmpz_binexp(fq_zech_struct* res, const fq_zech_struct* poly, const fmpz_t e, const fq_zech_struct* f, long lenf, const fq_zech_ctx_t ctx) + # Sets ``res`` to ``poly`` raised to the power ``e`` modulo + # ``f``, using binary exponentiation. We require ``e > 0``. + # We require ``lenf > 1``. It is assumed that ``poly`` is + # already reduced modulo ``f`` and zero-padded as necessary to + # have length exactly ``lenf - 1``. The output ``res`` must + # have room for ``lenf - 1`` coefficients. + + void fq_zech_poly_powmod_fmpz_binexp(fq_zech_poly_t res, const fq_zech_poly_t poly, const fmpz_t e, const fq_zech_poly_t f, const fq_zech_ctx_t ctx) + # Sets ``res`` to ``poly`` raised to the power ``e`` modulo + # ``f``, using binary exponentiation. We require ``e >= 0``. + + void _fq_zech_poly_powmod_fmpz_binexp_preinv(fq_zech_struct* res, const fq_zech_struct* poly, const fmpz_t e, const fq_zech_struct* f, long lenf, const fq_zech_struct* finv, long lenfinv, const fq_zech_ctx_t ctx) + # Sets ``res`` to ``poly`` raised to the power ``e`` modulo + # ``f``, using binary exponentiation. We require ``e > 0``. + # We require ``finv`` to be the inverse of the reverse of + # ``f``. + # We require ``lenf > 1``. It is assumed that ``poly`` is + # already reduced modulo ``f`` and zero-padded as necessary to + # have length exactly ``lenf - 1``. The output ``res`` must + # have room for ``lenf - 1`` coefficients. + + void fq_zech_poly_powmod_fmpz_binexp_preinv(fq_zech_poly_t res, const fq_zech_poly_t poly, const fmpz_t e, const fq_zech_poly_t f, const fq_zech_poly_t finv, const fq_zech_ctx_t ctx) + # Sets ``res`` to ``poly`` raised to the power ``e`` modulo + # ``f``, using binary exponentiation. We require ``e >= 0``. + # We require ``finv`` to be the inverse of the reverse of + # ``f``. + + void _fq_zech_poly_powmod_fmpz_sliding_preinv(fq_zech_struct* res, const fq_zech_struct* poly, const fmpz_t e, unsigned long k, const fq_zech_struct* f, long lenf, const fq_zech_struct* finv, long lenfinv, const fq_zech_ctx_t ctx) + # Sets ``res`` to ``poly`` raised to the power ``e`` modulo + # ``f``, using sliding-window exponentiation with window size + # ``k``. We require ``e > 0``. We require ``finv`` to be + # the inverse of the reverse of ``f``. If ``k`` is set to + # zero, then an "optimum" size will be selected automatically base + # on ``e``. + # We require ``lenf > 1``. It is assumed that ``poly`` is + # already reduced modulo ``f`` and zero-padded as necessary to + # have length exactly ``lenf - 1``. The output ``res`` must + # have room for ``lenf - 1`` coefficients. + + void fq_zech_poly_powmod_fmpz_sliding_preinv(fq_zech_poly_t res, const fq_zech_poly_t poly, const fmpz_t e, unsigned long k, const fq_zech_poly_t f, const fq_zech_poly_t finv, const fq_zech_ctx_t ctx) + # Sets ``res`` to ``poly`` raised to the power ``e`` modulo + # ``f``, using sliding-window exponentiation with window size + # ``k``. We require ``e >= 0``. We require ``finv`` to be + # the inverse of the reverse of ``f``. If ``k`` is set to + # zero, then an "optimum" size will be selected automatically base + # on ``e``. + + void _fq_zech_poly_powmod_x_fmpz_preinv(fq_zech_struct * res, const fmpz_t e, const fq_zech_struct * f, long lenf, const fq_zech_struct * finv, long lenfinv, const fq_zech_ctx_t ctx) + # Sets ``res`` to ``x`` raised to the power ``e`` modulo ``f``, + # using sliding window exponentiation. We require ``e > 0``. + # We require ``finv`` to be the inverse of the reverse of ``f``. + # We require ``lenf > 2``. The output ``res`` must have room for + # ``lenf - 1`` coefficients. + + void fq_zech_poly_powmod_x_fmpz_preinv(fq_zech_poly_t res, const fmpz_t e, const fq_zech_poly_t f, const fq_zech_poly_t finv, const fq_zech_ctx_t ctx) + # Sets ``res`` to ``x`` raised to the power ``e`` + # modulo ``f``, using sliding window exponentiation. We require + # ``e >= 0``. We require ``finv`` to be the inverse of the reverse of + # ``f``. + + void _fq_zech_poly_pow_trunc_binexp(fq_zech_struct * res, const fq_zech_struct * poly, unsigned long e, long trunc, const fq_zech_ctx_t ctx) + # Sets ``res`` to the low ``trunc`` coefficients of ``poly`` + # (assumed to be zero padded if necessary to length ``trunc``) to the power ``e``. This is equivalent to doing a powering followed + # by a truncation. We require that ``res`` has enough space for + # ``trunc`` coefficients, that ``trunc > 0`` and that ``e > 1``. Aliasing is not permitted. Uses the binary exponentiation method. + + void fq_zech_poly_pow_trunc_binexp(fq_zech_poly_t res, const fq_zech_poly_t poly, unsigned long e, long trunc, const fq_zech_ctx_t ctx) + # Sets ``res`` to the low ``trunc`` coefficients of ``poly`` + # to the power ``e``. This is equivalent to doing a powering + # followed by a truncation. Uses the binary exponentiation method. + + void _fq_zech_poly_pow_trunc(fq_zech_struct * res, const fq_zech_struct * poly, unsigned long e, long trunc, const fq_zech_ctx_t mod) + # Sets ``res`` to the low ``trunc`` coefficients of ``poly`` + # (assumed to be zero padded if necessary to length ``trunc``) to + # the power ``e``. This is equivalent to doing a powering followed + # by a truncation. We require that ``res`` has enough space for + # ``trunc`` coefficients, that ``trunc > 0`` and that + # ``e > 1``. Aliasing is not permitted. + + void fq_zech_poly_pow_trunc(fq_zech_poly_t res, const fq_zech_poly_t poly, unsigned long e, long trunc, const fq_zech_ctx_t ctx) + # Sets ``res`` to the low ``trunc`` coefficients of ``poly`` + # to the power ``e``. This is equivalent to doing a powering + # followed by a truncation. + + void _fq_zech_poly_shift_left(fq_zech_struct *rop, const fq_zech_struct *op, long len, long n, const fq_zech_ctx_t ctx) + # Sets ``(rop, len + n)`` to ``(op, len)`` shifted left by + # `n` coefficients. + # Inserts zero coefficients at the lower end. Assumes that + # ``len`` and `n` are positive, and that ``rop`` fits + # ``len + n`` elements. Supports aliasing between ``rop`` and + # ``op``. + + void fq_zech_poly_shift_left(fq_zech_poly_t rop, const fq_zech_poly_t op, long n, const fq_zech_ctx_t ctx) + # Sets ``rop`` to ``op`` shifted left by `n` coeffs. Zero + # coefficients are inserted. + + void _fq_zech_poly_shift_right(fq_zech_struct *rop, const fq_zech_struct *op, long len, long n, const fq_zech_ctx_t ctx) + # Sets ``(rop, len - n)`` to ``(op, len)`` shifted right by + # `n` coefficients. + # Assumes that ``len`` and `n` are positive, that ``len > n``, + # and that ``rop`` fits ``len - n`` elements. Supports + # aliasing between ``rop`` and ``op``, although in this case + # the top coefficients of ``op`` are not set to zero. + + void fq_zech_poly_shift_right(fq_zech_poly_t rop, const fq_zech_poly_t op, long n, const fq_zech_ctx_t ctx) + # Sets ``rop`` to ``op`` shifted right by `n` coefficients. + # If `n` is equal to or greater than the current length of + # ``op``, ``rop`` is set to the zero polynomial. + + long _fq_zech_poly_hamming_weight(const fq_zech_struct *op, long len, const fq_zech_ctx_t ctx) + # Returns the number of non-zero entries in ``(op, len)``. + + long fq_zech_poly_hamming_weight(const fq_zech_poly_t op, const fq_zech_ctx_t ctx) + # Returns the number of non-zero entries in the polynomial ``op``. + + void _fq_zech_poly_divrem(fq_zech_struct *Q, fq_zech_struct *R, const fq_zech_struct *A, long lenA, const fq_zech_struct *B, long lenB, const fq_zech_t invB, const fq_zech_ctx_t ctx) + # Computes ``(Q, lenA - lenB + 1)``, ``(R, lenA)`` such that + # `A = B Q + R` with `0 \leq \operatorname{len}(R) < \operatorname{len}(B)`. + # Assumes that the leading coefficient of `B` is invertible + # and that ``invB`` is its inverse. + # Assumes that `\operatorname{len}(A), \operatorname{len}(B) > 0`. Allows zero-padding in + # ``(A, lenA)``. `R` and `A` may be aliased, but apart from + # this no aliasing of input and output operands is allowed. + + void fq_zech_poly_divrem(fq_zech_poly_t Q, fq_zech_poly_t R, const fq_zech_poly_t A, const fq_zech_poly_t B, const fq_zech_ctx_t ctx) + # Computes `Q`, `R` such that `A = B Q + R` with + # `0 \leq \operatorname{len}(R) < \operatorname{len}(B)`. + # Assumes that the leading coefficient of `B` is invertible. This can + # be taken for granted the context is for a finite field, that is, when + # `p` is prime and `f(X)` is irreducible. + + void fq_zech_poly_divrem_f(fq_zech_t f, fq_zech_poly_t Q, fq_zech_poly_t R, const fq_zech_poly_t A, const fq_zech_poly_t B, const fq_zech_ctx_t ctx) + # Either finds a non-trivial factor `f` of the modulus of + # ``ctx``, or computes `Q`, `R` such that `A = B Q + R` and + # `0 \leq \operatorname{len}(R) < \operatorname{len}(B)`. + # If the leading coefficient of `B` is invertible, the division with + # remainder operation is carried out, `Q` and `R` are computed + # correctly, and `f` is set to `1`. Otherwise, `f` is set to a + # non-trivial factor of the modulus and `Q` and `R` are not touched. + # Assumes that `B` is non-zero. + + void _fq_zech_poly_rem(fq_zech_struct *R, const fq_zech_struct *A, long lenA, const fq_zech_struct *B, long lenB, const fq_zech_t invB, const fq_zech_ctx_t ctx) + # Sets ``R`` to the remainder of the division of ``(A,lenA)`` by + # ``(B,lenB)``. Assumes that the leading coefficient of ``(B,lenB)`` + # is invertible and that ``invB`` is its inverse. + + void fq_zech_poly_rem(fq_zech_poly_t R, const fq_zech_poly_t A, const fq_zech_poly_t B, const fq_zech_ctx_t ctx) + # Sets ``R`` to the remainder of the division of ``A`` by + # ``B`` in the context described by ``ctx``. + + void _fq_zech_poly_div(fq_zech_struct *Q, const fq_zech_struct *A, long lenA, const fq_zech_struct *B, long lenB, const fq_zech_t invB, const fq_zech_ctx_t ctx) + # Notationally, computes `Q`, `R` such that `A = B Q + R` with `0 + # \leq \operatorname{len}(R) < \operatorname{len}(B)` but only sets ``(Q, lenA - lenB + 1)``. + # Allows zero-padding in `A` but not in `B`. Assumes that the leading coefficient of `B` is a + # unit. + + void fq_zech_poly_div(fq_zech_poly_t Q, const fq_zech_poly_t A, const fq_zech_poly_t B, const fq_zech_ctx_t ctx) + # Notionally finds polynomials `Q` and `R` such that `A = B Q + R` with + # `\operatorname{len}(R) < \operatorname{len}(B)`, but returns only ``Q``. If `\operatorname{len}(B) = 0` an + # exception is raised. + + void _fq_zech_poly_div_newton_n_preinv(fq_zech_struct* Q, const fq_zech_struct* A, long lenA, const fq_zech_struct* B, long lenB, const fq_zech_struct* Binv, long lenBinv, const fq_zech_ctx_t ctx) + # Notionally computes polynomials `Q` and `R` such that `A = BQ + R` with + # `\operatorname{len}(R)` less than ``lenB``, where ``A`` is of length ``lenA`` + # and ``B`` is of length ``lenB``, but return only `Q`. + # We require that `Q` have space for ``lenA - lenB + 1`` coefficients + # and assume that the leading coefficient of `B` is a unit. Furthermore, we + # assume that `Binv` is the inverse of the reverse of `B` mod `x^{\operatorname{len}(B)}`. + # The algorithm used is to reverse the polynomials and divide the + # resulting power series, then reverse the result. + + void fq_zech_poly_div_newton_n_preinv(fq_zech_poly_t Q, const fq_zech_poly_t A, const fq_zech_poly_t B, const fq_zech_poly_t Binv, const fq_zech_ctx_t ctx) + # Notionally computes `Q` and `R` such that `A = BQ + R` with + # `\operatorname{len}(R) < \operatorname{len}(B)`, but returns only `Q`. + # We assume that the leading coefficient of `B` is a unit and that `Binv` is + # the inverse of the reverse of `B` mod `x^{\operatorname{len}(B)}`. + # It is required that the length of `A` is less than or equal to + # 2*the length of `B` - 2. + # The algorithm used is to reverse the polynomials and divide the + # resulting power series, then reverse the result. + + void _fq_zech_poly_divrem_newton_n_preinv(fq_zech_struct* Q, fq_zech_struct* R, const fq_zech_struct* A, long lenA, const fq_zech_struct* B, long lenB, const fq_zech_struct* Binv, long lenBinv, const fq_zech_ctx_t ctx) + # Computes `Q` and `R` such that `A = BQ + R` with `\operatorname{len}(R)` less + # than ``lenB``, where `A` is of length ``lenA`` and `B` is of + # length ``lenB``. We require that `Q` have space for + # ``lenA - lenB + 1`` coefficients. Furthermore, we assume that `Binv` is + # the inverse of the reverse of `B` mod `x^{\operatorname{len}(B)}`. The algorithm + # used is to call :func:`div_newton_preinv` and then multiply out + # and compute the remainder. + + void fq_zech_poly_divrem_newton_n_preinv(fq_zech_poly_t Q, fq_zech_poly_t R, const fq_zech_poly_t A, const fq_zech_poly_t B, const fq_zech_poly_t Binv, const fq_zech_ctx_t ctx) + # Computes `Q` and `R` such that `A = BQ + R` with `\operatorname{len}(R) < + # \operatorname{len}(B)`. We assume `Binv` is the inverse of the reverse of `B` + # mod `x^{\operatorname{len}(B)}`. + # It is required that the length of `A` is less than or equal to + # 2*the length of `B` - 2. + # The algorithm used is to call :func:`div_newton` and then + # multiply out and compute the remainder. + + void _fq_zech_poly_inv_series_newton(fq_zech_struct* Qinv, const fq_zech_struct* Q, long n, const fq_zech_t cinv, const fq_zech_ctx_t ctx) + # Given ``Q`` of length ``n`` whose constant coefficient is + # invertible modulo the given modulus, find a polynomial ``Qinv`` + # of length ``n`` such that ``Q * Qinv`` is ``1`` modulo + # `x^n`. Requires ``n > 0``. This function can be viewed as + # inverting a power series via Newton iteration. + + void fq_zech_poly_inv_series_newton(fq_zech_poly_t Qinv, const fq_zech_poly_t Q, long n, const fq_zech_ctx_t ctx) + # Given ``Q`` find ``Qinv`` such that ``Q * Qinv`` is + # ``1`` modulo `x^n`. The constant coefficient of ``Q`` must + # be invertible modulo the modulus of ``Q``. An exception is + # raised if this is not the case or if ``n = 0``. This function + # can be viewed as inverting a power series via Newton iteration. + + void _fq_zech_poly_inv_series(fq_zech_struct* Qinv, const fq_zech_struct* Q, long n, const fq_zech_t cinv, const fq_zech_ctx_t ctx) + # Given ``Q`` of length ``n`` whose constant coefficient is + # invertible modulo the given modulus, find a polynomial ``Qinv`` + # of length ``n`` such that ``Q * Qinv`` is ``1`` modulo + # `x^n`. Requires ``n > 0``. + + void fq_zech_poly_inv_series(fq_zech_poly_t Qinv, const fq_zech_poly_t Q, long n, const fq_zech_ctx_t ctx) + # Given ``Q`` find ``Qinv`` such that ``Q * Qinv`` is + # ``1`` modulo `x^n`. The constant coefficient of ``Q`` must + # be invertible modulo the modulus of ``Q``. An exception is + # raised if this is not the case or if ``n = 0``. + + void _fq_zech_poly_div_series(fq_zech_struct * Q, const fq_zech_struct * A, long Alen, const fq_zech_struct * B, long Blen, long n, const fq_zech_ctx_t ctx) + # Set ``(Q, n)`` to the quotient of the series ``(A, Alen``) and + # ``(B, Blen)`` assuming ``Alen, Blen <= n``. We assume the bottom + # coefficient of ``B`` is invertible. + + void fq_zech_poly_div_series(fq_zech_poly_t Q, const fq_zech_poly_t A, const fq_zech_poly_t B, long n, const fq_zech_ctx_t ctx) + # Set `Q` to the quotient of the series `A` by `B`, thinking of the series as + # though they were of length `n`. We assume that the bottom coefficient of + # `B` is invertible. + + void fq_zech_poly_gcd(fq_zech_poly_t rop, const fq_zech_poly_t op1, const fq_zech_poly_t op2, const fq_zech_ctx_t ctx) + # Sets ``rop`` to the greatest common divisor of ``op1`` and + # ``op2``, using the either the Euclidean or HGCD algorithm. The + # GCD of zero polynomials is defined to be zero, whereas the GCD of + # the zero polynomial and some other polynomial `P` is defined to be + # `P`. Except in the case where the GCD is zero, the GCD `G` is made + # monic. + + long _fq_zech_poly_gcd(fq_zech_struct* G, const fq_zech_struct* A, long lenA, const fq_zech_struct* B, long lenB, const fq_zech_ctx_t ctx) + # Computes the GCD of `A` of length ``lenA`` and `B` of length + # ``lenB``, where ``lenA >= lenB > 0`` and sets `G` to it. The + # length of the GCD `G` is returned by the function. No attempt is + # made to make the GCD monic. It is required that `G` have space for + # ``lenB`` coefficients. + + long _fq_zech_poly_gcd_euclidean_f(fq_zech_t f, fq_zech_struct *G, const fq_zech_struct *A, long lenA, const fq_zech_struct *B, long lenB, const fq_zech_ctx_t ctx) + # Either sets `f = 1` and `G` to the greatest common divisor of + # `(A,\operatorname{len}(A))` and `(B, \operatorname{len}(B))` and returns its length, or sets + # `f` to a non-trivial factor of the modulus of ``ctx`` and leaves + # the contents of the vector `(G, lenB)` undefined. + # Assumes that `\operatorname{len}(A) \geq \operatorname{len}(B) > 0` and that the vector `G` + # has space for sufficiently many coefficients. + + void fq_zech_poly_gcd_euclidean_f(fq_zech_t f, fq_zech_poly_t G, const fq_zech_poly_t A, const fq_zech_poly_t B, const fq_zech_ctx_t ctx) + # Either sets `f = 1` and `G` to the greatest common divisor of `A` + # and `B` or sets `f` to a factor of the modulus of ``ctx``. + + long _fq_zech_poly_xgcd(fq_zech_struct *G, fq_zech_struct *S, fq_zech_struct *T, const fq_zech_struct *A, long lenA, const fq_zech_struct *B, long lenB, const fq_zech_ctx_t ctx) + # Computes the GCD of `A` and `B` together with cofactors `S` and `T` + # such that `S A + T B = G`. Returns the length of `G`. + # Assumes that `\operatorname{len}(A) \geq \operatorname{len}(B) \geq 1` and + # `(\operatorname{len}(A),\operatorname{len}(B)) \neq (1,1)`. + # No attempt is made to make the GCD monic. + # Requires that `G` have space for `\operatorname{len}(B)` coefficients. Writes + # `\operatorname{len}(B)-1` and `\operatorname{len}(A)-1` coefficients to `S` and `T`, respectively. + # Note that, in fact, `\operatorname{len}(S) \leq \max(\operatorname{len}(B) - \operatorname{len}(G), 1)` and + # `\operatorname{len}(T) \leq \max(\operatorname{len}(A) - \operatorname{len}(G), 1)`. + # No aliasing of input and output operands is permitted. + + void fq_zech_poly_xgcd(fq_zech_poly_t G, fq_zech_poly_t S, fq_zech_poly_t T, const fq_zech_poly_t A, const fq_zech_poly_t B, const fq_zech_ctx_t ctx) + # Computes the GCD of `A` and `B`. The GCD of zero polynomials is + # defined to be zero, whereas the GCD of the zero polynomial and some other + # polynomial `P` is defined to be `P`. Except in the case where + # the GCD is zero, the GCD `G` is made monic. + # Polynomials ``S`` and ``T`` are computed such that + # ``S*A + T*B = G``. The length of ``S`` will be at most + # ``lenB`` and the length of ``T`` will be at most ``lenA``. + + long _fq_zech_poly_xgcd_euclidean_f(fq_zech_t f, fq_zech_struct *G, fq_zech_struct *S, fq_zech_struct *T, const fq_zech_struct *A, long lenA, const fq_zech_struct *B, long lenB, const fq_zech_ctx_t ctx) + # Either sets `f = 1` and computes the GCD of `A` and `B` together + # with cofactors `S` and `T` such that `S A + T B = G`; otherwise, + # sets `f` to a non-trivial factor of the modulus of ``ctx`` and + # leaves `G`, `S`, and `T` undefined. Returns the length of `G`. + # Assumes that `\operatorname{len}(A) \geq \operatorname{len}(B) \geq 1` and + # `(\operatorname{len}(A),\operatorname{len}(B)) \neq (1,1)`. + # No attempt is made to make the GCD monic. + # Requires that `G` have space for `\operatorname{len}(B)` coefficients. Writes + # `\operatorname{len}(B)-1` and `\operatorname{len}(A)-1` coefficients to `S` and `T`, respectively. + # Note that, in fact, `\operatorname{len}(S) \leq \max(\operatorname{len}(B) - \operatorname{len}(G), 1)` and + # `\operatorname{len}(T) \leq \max(\operatorname{len}(A) - \operatorname{len}(G), 1)`. + # No aliasing of input and output operands is permitted. + + void fq_zech_poly_xgcd_euclidean_f(fq_zech_t f, fq_zech_poly_t G, fq_zech_poly_t S, fq_zech_poly_t T, const fq_zech_poly_t A, const fq_zech_poly_t B, const fq_zech_ctx_t ctx) + # Either sets `f = 1` and computes the GCD of `A` and `B` or sets + # `f` to a non-trivial factor of the modulus of ``ctx``. + # If the GCD is computed, polynomials ``S`` and ``T`` are + # computed such that ``S*A + T*B = G``; otherwise, they are + # undefined. The length of ``S`` will be at most ``lenB`` and + # the length of ``T`` will be at most ``lenA``. + # The GCD of zero polynomials is defined to be zero, whereas the GCD + # of the zero polynomial and some other polynomial `P` is defined to + # be `P`. Except in the case where the GCD is zero, the GCD `G` is + # made monic. + + int _fq_zech_poly_divides(fq_zech_struct *Q, const fq_zech_struct *A, long lenA, const fq_zech_struct *B, long lenB, const fq_zech_t invB, const fq_zech_ctx_t ctx) + # Returns `1` if ``(B, lenB)`` divides ``(A, lenA)`` exactly and + # sets `Q` to the quotient, otherwise returns `0`. + # It is assumed that `\operatorname{len}(A) \geq \operatorname{len}(B) > 0` and that `Q` has space + # for `\operatorname{len}(A) - \operatorname{len}(B) + 1` coefficients. + # Aliasing of `Q` with either of the inputs is not permitted. + # This function is currently unoptimised and provided for convenience + # only. + + int fq_zech_poly_divides(fq_zech_poly_t Q, const fq_zech_poly_t A, const fq_zech_poly_t B, const fq_zech_ctx_t ctx) + # Returns `1` if `B` divides `A` exactly and sets `Q` to the quotient, + # otherwise returns `0`. + # This function is currently unoptimised and provided for convenience + # only. + + void _fq_zech_poly_derivative(fq_zech_struct *rop, const fq_zech_struct *op, long len, const fq_zech_ctx_t ctx) + # Sets ``(rop, len - 1)`` to the derivative of ``(op, len)``. + # Also handles the cases where ``len`` is `0` or `1` correctly. + # Supports aliasing of ``rop`` and ``op``. + + void fq_zech_poly_derivative(fq_zech_poly_t rop, const fq_zech_poly_t op, const fq_zech_ctx_t ctx) + # Sets ``rop`` to the derivative of ``op``. + + void _fq_zech_poly_invsqrt_series(fq_zech_struct * g, const fq_zech_struct * h, long n, fq_zech_ctx_t mod) + # Set the first `n` terms of `g` to the series expansion of `1/\sqrt{h}`. + # It is assumed that `n > 0`, that `h` has constant term 1 and that `h` + # is zero-padded as necessary to length `n`. Aliasing is not permitted. + + void fq_zech_poly_invsqrt_series(fq_zech_poly_t g, const fq_zech_poly_t h, long n, fq_zech_ctx_t ctx) + # Set `g` to the series expansion of `1/\sqrt{h}` to order `O(x^n)`. + # It is assumed that `h` has constant term 1. + + void _fq_zech_poly_sqrt_series(fq_zech_struct * g, const fq_zech_struct * h, long n, fq_zech_ctx_t ctx) + # Set the first `n` terms of `g` to the series expansion of `\sqrt{h}`. + # It is assumed that `n > 0`, that `h` has constant term 1 and that `h` + # is zero-padded as necessary to length `n`. Aliasing is not permitted. + + void fq_zech_poly_sqrt_series(fq_zech_poly_t g, const fq_zech_poly_t h, long n, fq_zech_ctx_t ctx) + # Set `g` to the series expansion of `\sqrt{h}` to order `O(x^n)`. + # It is assumed that `h` has constant term 1. + + int _fq_zech_poly_sqrt(fq_zech_struct * s, const fq_zech_struct * p, long n, fq_zech_ctx_t mod) + # If ``(p, n)`` is a perfect square, sets ``(s, n / 2 + 1)`` + # to a square root of `p` and returns 1. Otherwise returns 0. + + int fq_zech_poly_sqrt(fq_zech_poly_t s, const fq_zech_poly_t p, fq_zech_ctx_t mod) + # If `p` is a perfect square, sets `s` to a square root of `p` + # and returns 1. Otherwise returns 0. + + void _fq_zech_poly_evaluate_fq_zech(fq_zech_t rop, const fq_zech_struct *op, long len, const fq_zech_t a, const fq_zech_ctx_t ctx) + # Sets ``rop`` to ``(op, len)`` evaluated at `a`. + # Supports zero padding. There are no restrictions on ``len``, that + # is, ``len`` is allowed to be zero, too. + + void fq_zech_poly_evaluate_fq_zech(fq_zech_t rop, const fq_zech_poly_t f, const fq_zech_t a, const fq_zech_ctx_t ctx) + # Sets ``rop`` to the value of `f(a)`. + # As the coefficient ring `\mathbf{F}_q` is finite, Horner's method + # is sufficient. + + void _fq_zech_poly_compose(fq_zech_struct *rop, const fq_zech_struct *op1, long len1, const fq_zech_struct *op2, long len2, const fq_zech_ctx_t ctx) + # Sets ``rop`` to the composition of ``(op1, len1)`` and + # ``(op2, len2)``. + # Assumes that ``rop`` has space for ``(len1-1)*(len2-1) + 1`` + # coefficients. Assumes that ``op1`` and ``op2`` are non-zero + # polynomials. Does not support aliasing between any of the inputs and + # the output. + + void fq_zech_poly_compose(fq_zech_poly_t rop, const fq_zech_poly_t op1, const fq_zech_poly_t op2, const fq_zech_ctx_t ctx) + # Sets ``rop`` to the composition of ``op1`` and ``op2``. + # To be precise about the order of composition, denoting ``rop``, + # ``op1``, and ``op2`` by `f`, `g`, and `h`, respectively, + # sets `f(t) = g(h(t))`. + + void _fq_zech_poly_compose_mod_horner(fq_zech_struct * res, const fq_zech_struct * f, long lenf, const fq_zech_struct * g, const fq_zech_struct * h, long lenh, const fq_zech_ctx_t ctx) + # Sets ``res`` to the composition `f(g)` modulo `h`. We require that + # `h` is nonzero and that the length of `g` is one less than the + # length of `h` (possibly with zero padding). The output is not allowed + # to be aliased with any of the inputs. + # The algorithm used is Horner's rule. + + void fq_zech_poly_compose_mod_horner(fq_zech_poly_t res, const fq_zech_poly_t f, const fq_zech_poly_t g, const fq_zech_poly_t h, const fq_zech_ctx_t ctx) + # Sets ``res`` to the composition `f(g)` modulo `h`. We require that + # `h` is nonzero. The algorithm used is Horner's rule. + + void _fq_zech_poly_compose_mod_horner_preinv(fq_zech_struct * res, const fq_zech_struct * f, long lenf, const fq_zech_struct * g, const fq_zech_struct * h, long lenh, const fq_zech_struct * hinv, long lenhiv, const fq_zech_ctx_t ctx) + # Sets ``res`` to the composition `f(g)` modulo `h`. We require + # that `h` is nonzero and that the length of `g` is one less than + # the length of `h` (possibly with zero padding). We also require + # that the length of `f` is less than the length of + # `h`. Furthermore, we require ``hinv`` to be the inverse of the + # reverse of ``h``. The output is not allowed to be aliased with + # any of the inputs. + # The algorithm used is Horner's rule. + + void fq_zech_poly_compose_mod_horner_preinv(fq_zech_poly_t res, const fq_zech_poly_t f, const fq_zech_poly_t g, const fq_zech_poly_t h, const fq_zech_poly_t hinv, const fq_zech_ctx_t ctx) + # Sets ``res`` to the composition `f(g)` modulo `h`. We require + # that `h` is nonzero and that `f` has smaller degree than + # `h`. Furthermore, we require ``hinv`` to be the inverse of the + # reverse of ``h``. The algorithm used is Horner's rule. + + void _fq_zech_poly_compose_mod_brent_kung(fq_zech_struct * res, const fq_zech_struct * f, long lenf, const fq_zech_struct * g, const fq_zech_struct * h, long lenh, const fq_zech_ctx_t ctx) + # Sets ``res`` to the composition `f(g)` modulo `h`. We require + # that `h` is nonzero and that the length of `g` is one less than + # the length of `h` (possibly with zero padding). We also require + # that the length of `f` is less than the length of `h`. The output + # is not allowed to be aliased with any of the inputs. + # The algorithm used is the Brent-Kung matrix algorithm. + + void fq_zech_poly_compose_mod_brent_kung(fq_zech_poly_t res, const fq_zech_poly_t f, const fq_zech_poly_t g, const fq_zech_poly_t h, const fq_zech_ctx_t ctx) + # Sets ``res`` to the composition `f(g)` modulo `h`. We require + # that `h` is nonzero and that `f` has smaller degree than `h`. The + # algorithm used is the Brent-Kung matrix algorithm. + + void _fq_zech_poly_compose_mod_brent_kung_preinv(fq_zech_struct * res, const fq_zech_struct * f, long lenf, const fq_zech_struct * g, const fq_zech_struct * h, long lenh, const fq_zech_struct * hinv, long lenhiv, const fq_zech_ctx_t ctx) + # Sets ``res`` to the composition `f(g)` modulo `h`. We require + # that `h` is nonzero and that the length of `g` is one less than + # the length of `h` (possibly with zero padding). We also require + # that the length of `f` is less than the length of + # `h`. Furthermore, we require ``hinv`` to be the inverse of the + # reverse of ``h``. The output is not allowed to be aliased with + # any of the inputs. + # The algorithm used is the Brent-Kung matrix algorithm. + + void fq_zech_poly_compose_mod_brent_kung_preinv(fq_zech_poly_t res, const fq_zech_poly_t f, const fq_zech_poly_t g, const fq_zech_poly_t h, const fq_zech_poly_t hinv, const fq_zech_ctx_t ctx) + # Sets ``res`` to the composition `f(g)` modulo `h`. We require + # that `h` is nonzero and that `f` has smaller degree than + # `h`. Furthermore, we require ``hinv`` to be the inverse of the + # reverse of ``h``. The algorithm used is the Brent-Kung matrix + # algorithm. + + void _fq_zech_poly_compose_mod(fq_zech_struct * res, const fq_zech_struct * f, long lenf, const fq_zech_struct * g, const fq_zech_struct * h, long lenh, const fq_zech_ctx_t ctx) + # Sets ``res`` to the composition `f(g)` modulo `h`. We require + # that `h` is nonzero and that the length of `g` is one less than + # the length of `h` (possibly with zero padding). The output is not + # allowed to be aliased with any of the inputs. + + void fq_zech_poly_compose_mod(fq_zech_poly_t res, const fq_zech_poly_t f, const fq_zech_poly_t g, const fq_zech_poly_t h, const fq_zech_ctx_t ctx) + # Sets ``res`` to the composition `f(g)` modulo `h`. We require + # that `h` is nonzero. + + void _fq_zech_poly_compose_mod_preinv(fq_zech_struct * res, const fq_zech_struct * f, long lenf, const fq_zech_struct * g, const fq_zech_struct * h, long lenh, const fq_zech_struct * hinv, long lenhiv, const fq_zech_ctx_t ctx) + # Sets ``res`` to the composition `f(g)` modulo `h`. We require + # that `h` is nonzero and that the length of `g` is one less than + # the length of `h` (possibly with zero padding). We also require + # that the length of `f` is less than the length of + # `h`. Furthermore, we require ``hinv`` to be the inverse of the + # reverse of ``h``. The output is not allowed to be aliased with + # any of the inputs. + + void fq_zech_poly_compose_mod_preinv(fq_zech_poly_t res, const fq_zech_poly_t f, const fq_zech_poly_t g, const fq_zech_poly_t h, const fq_zech_poly_t hinv, const fq_zech_ctx_t ctx) + # Sets ``res`` to the composition `f(g)` modulo `h`. We require + # that `h` is nonzero and that `f` has smaller degree than + # `h`. Furthermore, we require ``hinv`` to be the inverse of the + # reverse of ``h``. + + void _fq_zech_poly_reduce_matrix_mod_poly (fq_zech_mat_t A, const fq_zech_mat_t B, const fq_zech_poly_t f, const fq_zech_ctx_t ctx) + # Sets the ith row of ``A`` to the reduction of the ith row of `B` modulo + # `f` for `i=1,\ldots,\sqrt{\deg(f)}`. We require `B` to be at least + # a `\sqrt{\deg(f)}\times \deg(f)` matrix and `f` to be nonzero. + + void _fq_zech_poly_precompute_matrix (fq_zech_mat_t A, const fq_zech_struct* f, const fq_zech_struct* g, long leng, const fq_zech_struct* ginv, long lenginv, const fq_zech_ctx_t ctx) + # Sets the ith row of ``A`` to `f^i` modulo `g` for + # `i=1,\ldots,\sqrt{\deg(g)}`. We require `A` to be a + # `\sqrt{\deg(g)}\times \deg(g)` matrix. We require ``ginv`` to + # be the inverse of the reverse of ``g`` and `g` to be nonzero. + + void fq_zech_poly_precompute_matrix (fq_zech_mat_t A, const fq_zech_poly_t f, const fq_zech_poly_t g, const fq_zech_poly_t ginv, const fq_zech_ctx_t ctx) + # Sets the ith row of ``A`` to `f^i` modulo `g` for + # `i=1,\ldots,\sqrt{\deg(g)}`. We require `A` to be a + # `\sqrt{\deg(g)}\times \deg(g)` matrix. We require ``ginv`` to + # be the inverse of the reverse of ``g``. + + void _fq_zech_poly_compose_mod_brent_kung_precomp_preinv(fq_zech_struct* res, const fq_zech_struct* f, long lenf, const fq_zech_mat_t A, const fq_zech_struct* h, long lenh, const fq_zech_struct* hinv, long lenhinv, const fq_zech_ctx_t ctx) + # Sets ``res`` to the composition `f(g)` modulo `h`. We require + # that `h` is nonzero. We require that the ith row of `A` contains + # `g^i` for `i=1,\ldots,\sqrt{\deg(h)}`, i.e. `A` is a + # `\sqrt{\deg(h)}\times \deg(h)` matrix. We also require that the + # length of `f` is less than the length of `h`. Furthermore, we + # require ``hinv`` to be the inverse of the reverse of ``h``. + # The output is not allowed to be aliased with any of the inputs. + # The algorithm used is the Brent-Kung matrix algorithm. + + void fq_zech_poly_compose_mod_brent_kung_precomp_preinv(fq_zech_poly_t res, const fq_zech_poly_t f, const fq_zech_mat_t A, const fq_zech_poly_t h, const fq_zech_poly_t hinv, const fq_zech_ctx_t ctx) + # Sets ``res`` to the composition `f(g)` modulo `h`. We require + # that the ith row of `A` contains `g^i` for + # `i=1,\ldots,\sqrt{\deg(h)}`, i.e. `A` is a `\sqrt{\deg(h)}\times + # \deg(h)` matrix. We require that `h` is nonzero and that `f` has + # smaller degree than `h`. Furthermore, we require ``hinv`` to be + # the inverse of the reverse of ``h``. This version of Brent-Kung + # modular composition is particularly useful if one has to perform + # several modular composition of the form `f(g)` modulo `h` for + # fixed `g` and `h`. + + int _fq_zech_poly_fprint_pretty(FILE *file, const fq_zech_struct *poly, long len, const char *x, const fq_zech_ctx_t ctx) + # Prints the pretty representation of ``(poly, len)`` to the stream + # ``file``, using the string ``x`` to represent the indeterminate. + # In case of success, returns a positive value. In case of failure, + # returns a non-positive value. + + int fq_zech_poly_fprint_pretty(FILE * file, const fq_zech_poly_t poly, const char *x, const fq_zech_ctx_t ctx) + # Prints the pretty representation of ``poly`` to the stream + # ``file``, using the string ``x`` to represent the indeterminate. + # In case of success, returns a positive value. In case of failure, + # returns a non-positive value. + + int _fq_zech_poly_print_pretty(const fq_zech_struct *poly, long len, const char *x, const fq_zech_ctx_t ctx) + # Prints the pretty representation of ``(poly, len)`` to ``stdout``, + # using the string ``x`` to represent the indeterminate. + # In case of success, returns a positive value. In case of failure, + # returns a non-positive value. + + int fq_zech_poly_print_pretty(const fq_zech_poly_t poly, const char *x, const fq_zech_ctx_t ctx) + # Prints the pretty representation of ``poly`` to ``stdout``, + # using the string ``x`` to represent the indeterminate. + # In case of success, returns a positive value. In case of failure, + # returns a non-positive value. + + int _fq_zech_poly_fprint(FILE *file, const fq_zech_struct *poly, long len, const fq_zech_ctx_t ctx) + # Prints the pretty representation of ``(poly, len)`` to the stream + # ``file``. + # In case of success, returns a positive value. In case of failure, + # returns a non-positive value. + + int fq_zech_poly_fprint(FILE * file, const fq_zech_poly_t poly, const fq_zech_ctx_t ctx) + # Prints the pretty representation of ``poly`` to the stream + # ``file``. + # In case of success, returns a positive value. In case of failure, + # returns a non-positive value. + + int _fq_zech_poly_print(const fq_zech_struct *poly, long len, const fq_zech_ctx_t ctx) + # Prints the pretty representation of ``(poly, len)`` to ``stdout``. + # In case of success, returns a positive value. In case of failure, + # returns a non-positive value. + + int fq_zech_poly_print(const fq_zech_poly_t poly, const fq_zech_ctx_t ctx) + # Prints the representation of ``poly`` to ``stdout``. + # In case of success, returns a positive value. In case of failure, + # returns a non-positive value. + + char * _fq_zech_poly_get_str(const fq_zech_struct * poly, long len, const fq_zech_ctx_t ctx) + # Returns the plain FLINT string representation of the polynomial + # ``(poly, len)``. + + char * fq_zech_poly_get_str(const fq_zech_poly_t poly, const fq_zech_ctx_t ctx) + # Returns the plain FLINT string representation of the polynomial + # ``poly``. + + char * _fq_zech_poly_get_str_pretty(const fq_zech_struct * poly, long len, const char * x, const fq_zech_ctx_t ctx) + # Returns a pretty representation of the polynomial + # ``(poly, len)`` using the null-terminated string ``x`` as the + # variable name. + + char * fq_zech_poly_get_str_pretty(const fq_zech_poly_t poly, const char * x, const fq_zech_ctx_t ctx) + # Returns a pretty representation of the polynomial ``poly`` using the + # null-terminated string ``x`` as the variable name + + void fq_zech_poly_inflate(fq_zech_poly_t result, const fq_zech_poly_t input, unsigned long inflation, const fq_zech_ctx_t ctx) + # Sets ``result`` to the inflated polynomial `p(x^n)` where + # `p` is given by ``input`` and `n` is given by ``inflation``. + + void fq_zech_poly_deflate(fq_zech_poly_t result, const fq_zech_poly_t input, unsigned long deflation, const fq_zech_ctx_t ctx) + # Sets ``result`` to the deflated polynomial `p(x^{1/n})` where + # `p` is given by ``input`` and `n` is given by ``deflation``. + # Requires `n > 0`. + + unsigned long fq_zech_poly_deflation(const fq_zech_poly_t input, const fq_zech_ctx_t ctx) + # Returns the largest integer by which ``input`` can be deflated. + # As special cases, returns 0 if ``input`` is the zero polynomial + # and 1 of ``input`` is a constant polynomial. diff --git a/src/sage/libs/flint/fq_zech_poly_factor.pxd b/src/sage/libs/flint/fq_zech_poly_factor.pxd new file mode 100644 index 00000000000..f41d590ecf3 --- /dev/null +++ b/src/sage/libs/flint/fq_zech_poly_factor.pxd @@ -0,0 +1,168 @@ +# distutils: libraries = flint +# distutils: depends = flint/fq_zech_poly_factor.h + +################################################################################ +# This file is auto-generated. Do not modify by hand +################################################################################ + +from libc.stdio cimport FILE +from sage.libs.gmp.types cimport * +from sage.libs.mpfr.types cimport * +from sage.libs.flint.types cimport * + +cdef extern from "flint_wrap.h": + + void fq_zech_poly_factor_init(fq_zech_poly_factor_t fac, const fq_zech_ctx_t ctx) + # Initialises ``fac`` for use. An ``fq_zech_poly_factor_t`` + # represents a polynomial in factorised form as a product of + # polynomials with associated exponents. + + void fq_zech_poly_factor_clear(fq_zech_poly_factor_t fac, const fq_zech_ctx_t ctx) + # Frees all memory associated with ``fac``. + + void fq_zech_poly_factor_realloc(fq_zech_poly_factor_t fac, long alloc, const fq_zech_ctx_t ctx) + # Reallocates the factor structure to provide space for + # precisely ``alloc`` factors. + + void fq_zech_poly_factor_fit_length(fq_zech_poly_factor_t fac, long len, const fq_zech_ctx_t ctx) + # Ensures that the factor structure has space for at least + # ``len`` factors. This function takes care of the case of + # repeated calls by always at least doubling the number of factors + # the structure can hold. + + void fq_zech_poly_factor_set(fq_zech_poly_factor_t res, const fq_zech_poly_factor_t fac, const fq_zech_ctx_t ctx) + # Sets ``res`` to the same factorisation as ``fac``. + + void fq_zech_poly_factor_print_pretty(const fq_zech_poly_factor_t fac, const char *var, const fq_zech_ctx_t ctx) + # Pretty-prints the entries of ``fac`` to standard output. + + void fq_zech_poly_factor_print(const fq_zech_poly_factor_t fac, const fq_zech_ctx_t ctx) + # Prints the entries of ``fac`` to standard output. + + void fq_zech_poly_factor_insert(fq_zech_poly_factor_t fac, const fq_zech_poly_t poly, long exp, const fq_zech_ctx_t ctx) + # Inserts the factor ``poly`` with multiplicity ``exp`` into + # the factorisation ``fac``. + # If ``fac`` already contains ``poly``, then ``exp`` simply + # gets added to the exponent of the existing entry. + + void fq_zech_poly_factor_concat(fq_zech_poly_factor_t res, const fq_zech_poly_factor_t fac, const fq_zech_ctx_t ctx) + # Concatenates two factorisations. + # This is equivalent to calling ``fq_zech_poly_factor_insert()`` + # repeatedly with the individual factors of ``fac``. + # Does not support aliasing between ``res`` and ``fac``. + + void fq_zech_poly_factor_pow(fq_zech_poly_factor_t fac, long exp, const fq_zech_ctx_t ctx) + # Raises ``fac`` to the power ``exp``. + + unsigned long fq_zech_poly_remove(fq_zech_poly_t f, const fq_zech_poly_t p, const fq_zech_ctx_t ctx) + # Removes the highest possible power of ``p`` from ``f`` and + # returns the exponent. + + int fq_zech_poly_is_irreducible(const fq_zech_poly_t f, const fq_zech_ctx_t ctx) + # Returns 1 if the polynomial ``f`` is irreducible, otherwise returns 0. + + int fq_zech_poly_is_irreducible_ddf(const fq_zech_poly_t f, const fq_zech_ctx_t ctx) + # Returns 1 if the polynomial ``f`` is irreducible, otherwise returns 0. + # Uses fast distinct-degree factorisation. + + int fq_zech_poly_is_irreducible_ben_or(const fq_zech_poly_t f, const fq_zech_ctx_t ctx) + # Returns 1 if the polynomial ``f`` is irreducible, otherwise returns 0. + # Uses Ben-Or's irreducibility test. + + int _fq_zech_poly_is_squarefree(const fq_zech_struct * f, long len, const fq_zech_ctx_t ctx) + # Returns 1 if ``(f, len)`` is squarefree, and 0 otherwise. As a + # special case, the zero polynomial is not considered squarefree. + # There are no restrictions on the length. + + int fq_zech_poly_is_squarefree(const fq_zech_poly_t f, const fq_zech_ctx_t ctx) + # Returns 1 if ``f`` is squarefree, and 0 otherwise. As a special + # case, the zero polynomial is not considered squarefree. + + int fq_zech_poly_factor_equal_deg_prob(fq_zech_poly_t factor, flint_rand_t state, const fq_zech_poly_t pol, long d, const fq_zech_ctx_t ctx) + # Probabilistic equal degree factorisation of ``pol`` into + # irreducible factors of degree ``d``. If it passes, a factor is + # placed in factor and 1 is returned, otherwise 0 is returned and + # the value of factor is undetermined. + # Requires that ``pol`` be monic, non-constant and squarefree. + + void fq_zech_poly_factor_equal_deg(fq_zech_poly_factor_t factors, const fq_zech_poly_t pol, long d, const fq_zech_ctx_t ctx) + # Assuming ``pol`` is a product of irreducible factors all of + # degree ``d``, finds all those factors and places them in + # factors. Requires that ``pol`` be monic, non-constant and + # squarefree. + + void fq_zech_poly_factor_split_single(fq_zech_poly_t linfactor, const fq_zech_poly_t input, const fq_zech_ctx_t ctx) + # Assuming ``input`` is a product of factors all of degree 1, finds a single + # linear factor of ``input`` and places it in ``linfactor``. + # Requires that ``input`` be monic and non-constant. + + void fq_zech_poly_factor_distinct_deg(fq_zech_poly_factor_t res, const fq_zech_poly_t poly, long * const *degs, const fq_zech_ctx_t ctx) + # Factorises a monic non-constant squarefree polynomial ``poly`` + # of degree `n` into factors `f[d]` such that for `1 \leq d \leq n` + # `f[d]` is the product of the monic irreducible factors of + # ``poly`` of degree `d`. Factors are stored in ``res``, + # associated powers of irreducible polynomials are stored in + # ``degs`` in the same order as factors. + # Requires that ``degs`` have enough space for irreducible polynomials' + # powers (maximum space required is `n * sizeof(slong)`). + + void fq_zech_poly_factor_squarefree(fq_zech_poly_factor_t res, const fq_zech_poly_t f, const fq_zech_ctx_t ctx) + # Sets ``res`` to a squarefree factorization of ``f``. + + void fq_zech_poly_factor(fq_zech_poly_factor_t res, fq_zech_t lead, const fq_zech_poly_t f, const fq_zech_ctx_t ctx) + # Factorises a non-constant polynomial ``f`` into monic + # irreducible factors choosing the best algorithm for given modulo + # and degree. The output ``lead`` is set to the leading coefficient of `f` + # upon return. Choice of algorithm is based on heuristic measurements. + + void fq_zech_poly_factor_cantor_zassenhaus(fq_zech_poly_factor_t res, const fq_zech_poly_t f, const fq_zech_ctx_t ctx) + # Factorises a non-constant polynomial ``f`` into monic + # irreducible factors using the Cantor-Zassenhaus algorithm. + + void fq_zech_poly_factor_kaltofen_shoup(fq_zech_poly_factor_t res, const fq_zech_poly_t poly, const fq_zech_ctx_t ctx) + # Factorises a non-constant polynomial ``f`` into monic + # irreducible factors using the fast version of Cantor-Zassenhaus + # algorithm proposed by Kaltofen and Shoup (1998). More precisely + # this algorithm uses a “baby step/giant step” strategy for the + # distinct-degree factorization step. + + void fq_zech_poly_factor_berlekamp(fq_zech_poly_factor_t factors, const fq_zech_poly_t f, const fq_zech_ctx_t ctx) + # Factorises a non-constant polynomial ``f`` into monic + # irreducible factors using the Berlekamp algorithm. + + void fq_zech_poly_factor_with_berlekamp(fq_zech_poly_factor_t res, fq_zech_t leading_coeff, const fq_zech_poly_t f, const fq_zech_ctx_t ctx) + # Factorises a general polynomial ``f`` into monic irreducible + # factors and sets ``leading_coeff`` to the leading coefficient + # of ``f``, or 0 if ``f`` is the zero polynomial. + # This function first checks for small special cases, deflates + # ``f`` if it is of the form `p(x^m)` for some `m > 1`, then + # performs a square-free factorisation, and finally runs Berlekamp + # on all the individual square-free factors. + + void fq_zech_poly_factor_with_cantor_zassenhaus(fq_zech_poly_factor_t res, fq_zech_t leading_coeff, const fq_zech_poly_t f, const fq_zech_ctx_t ctx) + # Factorises a general polynomial ``f`` into monic irreducible + # factors and sets ``leading_coeff`` to the leading coefficient + # of ``f``, or 0 if ``f`` is the zero polynomial. + # This function first checks for small special cases, deflates + # ``f`` if it is of the form `p(x^m)` for some `m > 1`, then + # performs a square-free factorisation, and finally runs + # Cantor-Zassenhaus on all the individual square-free factors. + + void fq_zech_poly_factor_with_kaltofen_shoup(fq_zech_poly_factor_t res, fq_zech_t leading_coeff, const fq_zech_poly_t f, const fq_zech_ctx_t ctx) + # Factorises a general polynomial ``f`` into monic irreducible + # factors and sets ``leading_coeff`` to the leading coefficient + # of ``f``, or 0 if ``f`` is the zero polynomial. + # This function first checks for small special cases, deflates + # ``f`` if it is of the form `p(x^m)` for some `m > 1`, then + # performs a square-free factorisation, and finally runs + # Kaltofen-Shoup on all the individual square-free factors. + + void fq_zech_poly_iterated_frobenius_preinv(fq_zech_poly_t *rop, long n, const fq_zech_poly_t v, const fq_zech_poly_t vinv, const fq_zech_ctx_t ctx) + # Sets ``rop[i]`` to be `x^{q^i} \bmod v` for `0 \le i < n`. + # It is required that ``vinv`` is the inverse of the reverse of + # ``v`` mod ``x^lenv``. + + void fq_zech_poly_roots(fq_zech_poly_factor_t r, const fq_zech_poly_t f, int with_multiplicity, const fq_zech_ctx_t ctx) + # Fill `r` with factors of the form `x - r_i` where the `r_i` are the distinct roots of a nonzero `f` in `F_q`. + # If `with\_multiplicity` is zero, the exponent `e_i` of the factor `x - r_i` is `1`. Otherwise, it is the largest `e_i` such that `(x-r_i)^e_i` divides `f`. + # This function throws if `f` is zero, but is otherwise always successful. diff --git a/src/sage/libs/flint/fq_zech_vec.pxd b/src/sage/libs/flint/fq_zech_vec.pxd new file mode 100644 index 00000000000..9282f112d6d --- /dev/null +++ b/src/sage/libs/flint/fq_zech_vec.pxd @@ -0,0 +1,73 @@ +# distutils: libraries = flint +# distutils: depends = flint/fq_zech_vec.h + +################################################################################ +# This file is auto-generated. Do not modify by hand +################################################################################ + +from libc.stdio cimport FILE +from sage.libs.gmp.types cimport * +from sage.libs.mpfr.types cimport * +from sage.libs.flint.types cimport * + +cdef extern from "flint_wrap.h": + + fq_zech_struct * _fq_zech_vec_init(long len, const fq_zech_ctx_t ctx) + # Returns an initialised vector of ``fq_zech``'s of given length. + + void _fq_zech_vec_clear(fq_zech_struct * vec, long len, const fq_zech_ctx_t ctx) + # Clears the entries of ``(vec, len)`` and frees the space allocated + # for ``vec``. + + void _fq_zech_vec_randtest(fq_zech_struct * f, flint_rand_t state, long len, const fq_zech_ctx_t ctx) + # Sets the entries of a vector of the given length to elements of + # the finite field. + + int _fq_zech_vec_fprint(FILE * file, const fq_zech_struct * vec, long len, const fq_zech_ctx_t ctx) + # Prints the vector of given length to the stream ``file``. The + # format is the length followed by two spaces, then a space separated + # list of coefficients. If the length is zero, only `0` is printed. + # In case of success, returns a positive value. In case of failure, + # returns a non-positive value. + + int _fq_zech_vec_print(const fq_zech_struct * vec, long len, const fq_zech_ctx_t ctx) + # Prints the vector of given length to ``stdout``. + # For further details, see ``_fq_zech_vec_fprint()``. + + void _fq_zech_vec_set(fq_zech_struct * vec1, const fq_zech_struct * vec2, long len2, const fq_zech_ctx_t ctx) + # Makes a copy of ``(vec2, len2)`` into ``vec1``. + + void _fq_zech_vec_swap(fq_zech_struct * vec1, fq_zech_struct * vec2, long len2, const fq_zech_ctx_t ctx) + # Swaps the elements in ``(vec1, len2)`` and ``(vec2, len2)``. + + void _fq_zech_vec_zero(fq_zech_struct * vec, long len, const fq_zech_ctx_t ctx) + # Zeros the entries of ``(vec, len)``. + + void _fq_zech_vec_neg(fq_zech_struct * vec1, const fq_zech_struct * vec2, long len2, const fq_zech_ctx_t ctx) + # Negates ``(vec2, len2)`` and places it into ``vec1``. + + int _fq_zech_vec_equal(const fq_zech_struct * vec1, const fq_zech_struct * vec2, long len, const fq_zech_ctx_t ctx) + # Compares two vectors of the given length and returns `1` if they are + # equal, otherwise returns `0`. + + int _fq_zech_vec_is_zero(const fq_zech_struct * vec, long len, const fq_zech_ctx_t ctx) + # Returns `1` if ``(vec, len)`` is zero, and `0` otherwise. + + void _fq_zech_vec_add(fq_zech_struct * res, const fq_zech_struct * vec1, const fq_zech_struct * vec2, long len2, const fq_zech_ctx_t ctx) + # Sets ``(res, len2)`` to the sum of ``(vec1, len2)`` + # and ``(vec2, len2)``. + + void _fq_zech_vec_sub(fq_zech_struct * res, const fq_zech_struct * vec1, const fq_zech_struct * vec2, long len2, const fq_zech_ctx_t ctx) + # Sets ``(res, len2)`` to ``(vec1, len2)`` minus ``(vec2, len2)``. + + void _fq_zech_vec_scalar_addmul_fq_zech(fq_zech_struct * vec1, const fq_zech_struct * vec2, long len2, const fq_zech_t c, const fq_zech_ctx_t ctx) + # Adds ``(vec2, len2)`` times `c` to ``(vec1, len2)``, where + # `c` is a ``fq_zech_t``. + + void _fq_zech_vec_scalar_submul_fq_zech(fq_zech_struct * vec1, const fq_zech_struct * vec2, long len2, const fq_zech_t c, const fq_zech_ctx_t ctx) + # Subtracts ``(vec2, len2)`` times `c` from ``(vec1, len2)``, + # where `c` is a ``fq_zech_t``. + + void _fq_zech_vec_dot(fq_zech_t res, const fq_zech_struct * vec1, const fq_zech_struct * vec2, long len2, const fq_zech_ctx_t ctx) + # Sets ``res`` to the dot product of (``vec1``, ``len``) + # and (``vec2``, ``len``). diff --git a/src/sage/libs/flint/gr.pxd b/src/sage/libs/flint/gr.pxd new file mode 100644 index 00000000000..0e7be38c48f --- /dev/null +++ b/src/sage/libs/flint/gr.pxd @@ -0,0 +1,429 @@ +# distutils: libraries = flint +# distutils: depends = flint/gr.h + +################################################################################ +# This file is auto-generated. Do not modify by hand +################################################################################ + +from libc.stdio cimport FILE +from sage.libs.gmp.types cimport * +from sage.libs.mpfr.types cimport * +from sage.libs.flint.types cimport * + +cdef extern from "flint_wrap.h": + + long gr_ctx_sizeof_elem(gr_ctx_t ctx) + # Return ``sizeof(type)`` where ``type`` is the underlying C + # type for elements of *ctx*. + + int gr_ctx_clear(gr_ctx_t ctx) + # Clears the context object *ctx*, freeing any memory + # allocated by this object. + # Some context objects may require that no elements are cleared after calling + # this method, and may leak memory if not all elements have + # been cleared when calling this method. + # If *ctx* is derived from a base ring, the base ring context + # may also be required to stay alive until after this + # method is called. + + int gr_ctx_write(gr_stream_t out, gr_ctx_t ctx) + int gr_ctx_print(gr_ctx_t ctx) + int gr_ctx_println(gr_ctx_t ctx) + int gr_ctx_get_str(char ** s, gr_ctx_t ctx) + # Writes a description of the structure *ctx* to the stream *out*, + # prints it to *stdout*, or sets *s* to a pointer to + # a heap-allocated string of the description (the user must free + # the string with ``flint_free``). + # The *println* version prints a trailing newline. + + int gr_ctx_set_gen_name(gr_ctx_t ctx, const char * s) + int gr_ctx_set_gen_names(gr_ctx_t ctx, const char ** s) + # Set the name of the generator (univariate polynomial ring, + # finite field, etc.) or generators (multivariate). + # The name is used when printing and may be used to choose + # coercions. + + void gr_init(gr_ptr res, gr_ctx_t ctx) + # Initializes *res* to a valid variable and sets it to the + # zero element of the ring *ctx*. + + void gr_clear(gr_ptr res, gr_ctx_t ctx) + # Clears *res*, freeing any memory allocated by this object. + + void gr_swap(gr_ptr x, gr_ptr y, gr_ctx_t ctx) + # Swaps *x* and *y* efficiently. + + void gr_set_shallow(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) + # Sets *res* to a shallow copy of *x*, copying the struct data. + + gr_ptr gr_heap_init(gr_ctx_t ctx) + # Return a pointer to a single new heap-allocated element of *ctx* + # set to 0. + + void gr_heap_clear(gr_ptr x, gr_ctx_t ctx) + # Free the single heap-allocated element *x* of *ctx* which should + # have been created with :func:`gr_heap_init`. + + gr_ptr gr_heap_init_vec(long len, gr_ctx_t ctx) + # Return a pointer to a new heap-allocated vector of *len* + # initialized elements. + + void gr_heap_clear_vec(gr_ptr x, long len, gr_ctx_t ctx) + # Clear the *len* elements in the heap-allocated vector *len* and + # free the vector itself. + + int gr_randtest(gr_ptr res, flint_rand_t state, gr_ctx_t ctx) + # Sets *res* to a random element of the domain *ctx*. + # The distribution is determined by the implementation. + # Typically the distribution is non-uniform in order to + # find corner cases more easily in test code. + + int gr_randtest_not_zero(gr_ptr res, flint_rand_t state, gr_ctx_t ctx) + # Sets *res* to a random nonzero element of the domain *ctx*. + # This operation will fail and return ``GR_DOMAIN`` in the zero ring. + + int gr_randtest_small(gr_ptr res, flint_rand_t state, gr_ctx_t ctx) + # Sets *res* to a "small" element of the domain *ctx*. + # This is suitable for randomized testing where a "large" argument + # could result in excessive computation time. + + int gr_write(gr_stream_t out, gr_srcptr x, gr_ctx_t ctx) + int gr_print(gr_srcptr x, gr_ctx_t ctx) + int gr_println(gr_srcptr x, gr_ctx_t ctx) + int gr_get_str(char ** s, gr_srcptr x, gr_ctx_t ctx) + # Writes a description of the element *x* to the stream *out*, + # or prints it to *stdout*, or sets *s* to a pointer to + # a heap-allocated string of the description (the user must free + # the string with ``flint_free``). The *println* version prints a + # trailing newline. + + int gr_set_str(gr_ptr res, const char * x, gr_ctx_t ctx) + # Sets *res* to the string description in *x*. + + int gr_write_n(gr_stream_t out, gr_srcptr x, long n, gr_ctx_t ctx) + int gr_get_str_n(char ** s, gr_srcptr x, long n, gr_ctx_t ctx) + # String conversion where real and complex numbers may be rounded + # to *n* digits. + + int gr_set(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) + # Sets *res* to a copy of the element *x*. + + int gr_set_other(gr_ptr res, gr_srcptr x, gr_ctx_t x_ctx, gr_ctx_t ctx) + # Sets *res* to the element *x* of the structure *x_ctx* which + # may be different from *ctx*. This returns the ``GR_DOMAIN`` flag + # if *x* is not an element of *ctx* or cannot be converted + # unambiguously to *ctx*. The ``GR_UNABLE`` flag is returned + # if the conversion is not implemented. + + int gr_set_ui(gr_ptr res, unsigned long x, gr_ctx_t ctx) + int gr_set_si(gr_ptr res, long x, gr_ctx_t ctx) + int gr_set_fmpz(gr_ptr res, const fmpz_t x, gr_ctx_t ctx) + int gr_set_fmpq(gr_ptr res, const fmpq_t x, gr_ctx_t ctx) + int gr_set_d(gr_ptr res, double x, gr_ctx_t ctx) + # Sets *res* to the value *x*. If no reasonable conversion to the + # domain *ctx* is possible, returns ``GR_DOMAIN``. + + int gr_get_si(long * res, gr_srcptr x, gr_ctx_t ctx) + int gr_get_ui(unsigned long * res, gr_srcptr x, gr_ctx_t ctx) + int gr_get_fmpz(fmpz_t res, gr_srcptr x, gr_ctx_t ctx) + int gr_get_fmpq(fmpq_t res, gr_srcptr x, gr_ctx_t ctx) + int gr_get_d(double * res, gr_srcptr x, gr_ctx_t ctx) + # Sets *res* to the value *x*. This returns the ``GR_DOMAIN`` flag + # if *x* cannot be converted to the target type. + # For floating-point output types, the output may be rounded. + + int gr_set_fmpz_2exp_fmpz(gr_ptr res, const fmpz_t x, const fmpz_t y, gr_ctx_t ctx) + int gr_get_fmpz_2exp_fmpz(fmpz_t res1, fmpz_t res2, gr_srcptr x, gr_ctx_t ctx) + # Set or retrieve a dyadic number. + + int gr_get_fexpr(fexpr_t res, gr_srcptr x, gr_ctx_t ctx) + int gr_get_fexpr_serialize(fexpr_t res, gr_srcptr x, gr_ctx_t ctx) + # Sets *res* to a symbolic expression representing *x*. + # The *serialize* version may generate a representation of the + # internal representation which is not intended to be human-readable. + + int gr_set_fexpr(gr_ptr res, fexpr_vec_t inputs, gr_vec_t outputs, const fexpr_t x, gr_ctx_t ctx) + # Sets *res* to the evaluation of the expression *x* in the + # given ring or structure. + # The user must provide vectors *inputs* and *outputs* which + # may be empty initially and which may be used as scratch space + # during evaluation. Non-empty vectors may be given to map symbols + # to predefined values. + + int gr_zero(gr_ptr res, gr_ctx_t ctx) + int gr_one(gr_ptr res, gr_ctx_t ctx) + int gr_neg_one(gr_ptr res, gr_ctx_t ctx) + # Sets *res* to the ring element 0, 1 or -1. + + int gr_gen(gr_ptr res, gr_ctx_t ctx) + # Sets *res* to a generator of this domain. The meaning of + # "generator" depends on the domain. + + int gr_gens(gr_vec_t res, gr_ctx_t ctx) + # Sets *res* to a vector containing the generators of this domain + # where this makes sense, for example in a multivariate polynomial + # ring. + + truth_t gr_is_zero(gr_srcptr x, gr_ctx_t ctx) + truth_t gr_is_one(gr_srcptr x, gr_ctx_t ctx) + truth_t gr_is_neg_one(gr_srcptr x, gr_ctx_t ctx) + # Returns whether *x* is equal to the ring element 0, 1 or -1, + # respectively. + + truth_t gr_equal(gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) + # Returns whether the elements *x* and *y* are equal. + + truth_t gr_is_integer(gr_srcptr x, gr_ctx_t ctx) + # Returns whether *x* represents an integer. + + truth_t gr_is_rational(gr_srcptr x, gr_ctx_t ctx) + # Returns whether *x* represents a rational number. + + int gr_neg(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) + # Sets *res* to `-x`. + + int gr_add(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) + int gr_add_ui(gr_ptr res, gr_srcptr x, unsigned long y, gr_ctx_t ctx) + int gr_add_si(gr_ptr res, gr_srcptr x, long y, gr_ctx_t ctx) + int gr_add_fmpz(gr_ptr res, gr_srcptr x, const fmpz_t y, gr_ctx_t ctx) + int gr_add_fmpq(gr_ptr res, gr_srcptr x, const fmpq_t y, gr_ctx_t ctx) + int gr_add_other(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t y_ctx, gr_ctx_t ctx) + int gr_other_add(gr_ptr res, gr_srcptr x, gr_ctx_t x_ctx, gr_srcptr y, gr_ctx_t ctx) + # Sets *res* to `x + y`. + + int gr_sub(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) + int gr_sub_ui(gr_ptr res, gr_srcptr x, unsigned long y, gr_ctx_t ctx) + int gr_sub_si(gr_ptr res, gr_srcptr x, long y, gr_ctx_t ctx) + int gr_sub_fmpz(gr_ptr res, gr_srcptr x, const fmpz_t y, gr_ctx_t ctx) + int gr_sub_fmpq(gr_ptr res, gr_srcptr x, const fmpq_t y, gr_ctx_t ctx) + int gr_sub_other(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t y_ctx, gr_ctx_t ctx) + int gr_other_sub(gr_ptr res, gr_srcptr x, gr_ctx_t x_ctx, gr_srcptr y, gr_ctx_t ctx) + # Sets *res* to `x - y`. + + int gr_mul(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) + int gr_mul_ui(gr_ptr res, gr_srcptr x, unsigned long y, gr_ctx_t ctx) + int gr_mul_si(gr_ptr res, gr_srcptr x, long y, gr_ctx_t ctx) + int gr_mul_fmpz(gr_ptr res, gr_srcptr x, const fmpz_t y, gr_ctx_t ctx) + int gr_mul_fmpq(gr_ptr res, gr_srcptr x, const fmpq_t y, gr_ctx_t ctx) + int gr_mul_other(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t y_ctx, gr_ctx_t ctx) + int gr_other_mul(gr_ptr res, gr_srcptr x, gr_ctx_t x_ctx, gr_srcptr y, gr_ctx_t ctx) + # Sets *res* to `x \cdot y`. + + int gr_addmul(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) + int gr_addmul_ui(gr_ptr res, gr_srcptr x, unsigned long y, gr_ctx_t ctx) + int gr_addmul_si(gr_ptr res, gr_srcptr x, long y, gr_ctx_t ctx) + int gr_addmul_fmpz(gr_ptr res, gr_srcptr x, const fmpz_t y, gr_ctx_t ctx) + int gr_addmul_fmpq(gr_ptr res, gr_srcptr x, const fmpq_t y, gr_ctx_t ctx) + int gr_addmul_other(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t y_ctx, gr_ctx_t ctx) + # Sets *res* to `\mathrm{res } + x \cdot y`. + # Rings may override the default + # implementation to perform this operation in one step without + # allocating a temporary variable, without intermediate rounding, etc. + + int gr_submul(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) + int gr_submul_ui(gr_ptr res, gr_srcptr x, unsigned long y, gr_ctx_t ctx) + int gr_submul_si(gr_ptr res, gr_srcptr x, long y, gr_ctx_t ctx) + int gr_submul_fmpz(gr_ptr res, gr_srcptr x, const fmpz_t y, gr_ctx_t ctx) + int gr_submul_fmpq(gr_ptr res, gr_srcptr x, const fmpq_t y, gr_ctx_t ctx) + int gr_submul_other(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t y_ctx, gr_ctx_t ctx) + # Sets *res* to `\mathrm{res } - x \cdot y`. + # Rings may override the default + # implementation to perform this operation in one step without + # allocating a temporary variable, without intermediate rounding, etc. + + int gr_mul_two(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) + # Sets *res* to `2x`. The default implementation adds *x* + # to itself. + + int gr_sqr(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) + # Sets *res* to `x ^ 2`. The default implementation multiplies *x* + # with itself. + + int gr_mul_2exp_si(gr_ptr res, gr_srcptr x, long y, gr_ctx_t ctx) + int gr_mul_2exp_fmpz(gr_ptr res, gr_srcptr x, const fmpz_t y, gr_ctx_t ctx) + # Sets *res* to `x \cdot 2^y`. This may perform `x \cdot 2^{-y}` + # when *y* is negative, allowing exact division by powers of two + # even if `2^{y}` is not representable. + + int gr_div(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) + int gr_div_ui(gr_ptr res, gr_srcptr x, unsigned long y, gr_ctx_t ctx) + int gr_div_si(gr_ptr res, gr_srcptr x, long y, gr_ctx_t ctx) + int gr_div_fmpz(gr_ptr res, gr_srcptr x, const fmpz_t y, gr_ctx_t ctx) + int gr_div_fmpq(gr_ptr res, gr_srcptr x, const fmpq_t y, gr_ctx_t ctx) + int gr_div_other(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t y_ctx, gr_ctx_t ctx) + int gr_other_div(gr_ptr res, gr_srcptr x, gr_ctx_t x_ctx, gr_srcptr y, gr_ctx_t ctx) + # Sets *res* to the quotient `x / y` if such an element exists + # in the present ring. Returns the flag ``GR_DOMAIN`` if no such + # quotient exists. + # Returns the flag ``GR_UNABLE`` if the implementation is unable + # to perform the computation. + # When the ring is not a field, the definition of division may + # vary depending on the ring. A ring implementation may define + # `x / y = x y^{-1}` and return ``GR_DOMAIN`` when `y^{-1}` does not + # exist; alternatively, it may attempt to solve the equation + # `q y = x` (which, for example, gives the usual exact + # division in `\mathbb{Z}`). + + truth_t gr_is_invertible(gr_srcptr x, gr_ctx_t ctx) + # Returns whether *x* has a multiplicative inverse in the present ring, + # i.e. whether *x* is a unit. + + int gr_inv(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) + # Sets *res* to the multiplicative inverse of *x* in the present ring, + # if such an element exists. + # Returns the flag ``GR_DOMAIN`` if *x* is not invertible, or + # ``GR_UNABLE`` if the implementation is unable to perform + # the computation. + + truth_t gr_divides(gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) + # Returns whether *x* divides *y*. + + int gr_divexact(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) + int gr_divexact_ui(gr_ptr res, gr_srcptr x, unsigned long y, gr_ctx_t ctx) + int gr_divexact_si(gr_ptr res, gr_srcptr x, long y, gr_ctx_t ctx) + int gr_divexact_fmpz(gr_ptr res, gr_srcptr x, const fmpz_t y, gr_ctx_t ctx) + int gr_divexact_other(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t y_ctx, gr_ctx_t ctx) + int gr_other_divexact(gr_ptr res, gr_srcptr x, gr_ctx_t x_ctx, gr_srcptr y, gr_ctx_t ctx) + # Sets *res* to the quotient `x / y`, assuming that this quotient + # is exact in the present ring. + # Rings may optimize this operation by not verifying that the + # division is possible. If the division is not actually exact, the + # implementation may set *res* to a nonsense value and still + # return the ``GR_SUCCESS`` flag. + + int gr_euclidean_div(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) + int gr_euclidean_rem(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) + int gr_euclidean_divrem(gr_ptr res1, gr_ptr res2, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) + # In a Euclidean ring, these functions perform some version of Euclidean + # division with remainder, where the choice of quotient is + # implementation-defined. For example, it is standard to use + # the round-to-floor quotient in `\mathbb{Z}` and a round-to-nearest quotient in `\mathbb{Z}[i]`. + # In non-Euclidean rings, these functions may implement some generalization of + # Euclidean division with remainder. + + int gr_pow(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) + int gr_pow_ui(gr_ptr res, gr_srcptr x, unsigned long y, gr_ctx_t ctx) + int gr_pow_si(gr_ptr res, gr_srcptr x, long y, gr_ctx_t ctx) + int gr_pow_fmpz(gr_ptr res, gr_srcptr x, const fmpz_t y, gr_ctx_t ctx) + int gr_pow_fmpq(gr_ptr res, gr_srcptr x, const fmpq_t y, gr_ctx_t ctx) + int gr_pow_other(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t y_ctx, gr_ctx_t ctx) + int gr_other_pow(gr_ptr res, gr_srcptr x, gr_ctx_t x_ctx, gr_srcptr y, gr_ctx_t ctx) + # Sets *res* to the power `x ^ y`, the interpretation of which + # depends on the ring when `y \not \in \mathbb{Z}`. + # Returns the flag ``GR_DOMAIN`` if this power cannot be assigned + # a meaningful value in the present ring, or ``GR_UNABLE`` if + # the implementation is unable to perform the computation. + # For subrings of `\mathbb{C}`, it is implied that the principal + # power `x^y = \exp(y \log(x))` is computed for `x \ne 0`. + # Default implementations of the powering methods support raising + # elements to integer powers using a generic implementation of + # exponentiation by squaring. Particular rings + # should override these methods with faster versions or + # to support more general notions of exponentiation when possible. + + truth_t gr_is_square(gr_srcptr x, gr_ctx_t ctx) + # Returns whether *x* is a perfect square in the present ring. + + int gr_sqrt(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) + int gr_rsqrt(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) + # Sets *res* to a square root of *x* (respectively reciprocal + # square root) in the present ring, if such an element exists. + # Returns the flag ``GR_DOMAIN`` if *x* is not a perfect square + # (also for zero, when computing the reciprocal square root), or + # ``GR_UNABLE`` if the implementation is unable to perform + # the computation. + + int gr_gcd(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) + # Sets *res* to a greatest common divisor (GCD) of *x* and *y*. + # Since the GCD is unique only up to multiplication by a unit, + # an implementation-defined representative is chosen. + + int gr_lcm(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) + # Sets *res* to a least common multiple (LCM) of *x* and *y*. + # Since the LCM is unique only up to multiplication by a unit, + # an implementation-defined representative is chosen. + + int gr_factor(gr_ptr c, gr_vec_t factors, gr_vec_t exponents, gr_srcptr x, int flags, gr_ctx_t ctx) + # Given `x \in R`, computes a factorization + # `x = c {f_1}^{e_1} \ldots {f_n}^{e_n}` + # where `f_k` will be irreducible or prime (depending on `R`). + # The prefactor `c` stores a unit, sign, or coefficient, e.g.\ the + # sign `-1`, `0` or `+1` in `\mathbb{Z}`, or a sign multiplied + # by the coefficient content in `\mathbb{Z}[x]`. + # Note that this function outputs `c` as an element of the + # same ring as the input: for example, in `\mathbb{Z}[x]`, + # `c` will be a constant polynomial rather than an + # element of the coefficient ring. + # The exponents `e_k` are output as a vector of ``fmpz`` elements. + # The factors `f_k` are guaranteed to be distinct, + # but they are not guaranteed to be sorted in any particular + # order. + + int gr_numerator(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) + int gr_denominator(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) + # Return a numerator `p` and denominator `q` such that `x = p/q`. + # For typical fraction fields, the denominator will be minimal + # and canonical. + # However, some rings may return an arbitrary denominator as long + # as the numerator matches. + # The default implementations simply return `p = x` and `q = 1`. + + int gr_floor(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) + int gr_ceil(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) + int gr_trunc(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) + int gr_nint(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) + # In the real and complex numbers, sets *res* to the integer closest + # to *x*, respectively rounding towards minus infinity, plus infinity, + # zero, or the nearest integer (with tie-to-even). + + int gr_abs(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) + # Sets *res* to the absolute value of *x*, which maybe defined + # both in complex rings and in any ordered ring. + + int gr_i(gr_ptr res, gr_ctx_t ctx) + # Sets *res* to the imaginary unit. + + int gr_conj(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) + int gr_re(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) + int gr_im(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) + int gr_sgn(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) + int gr_csgn(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) + int gr_arg(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) + # These methods may return the flag ``GR_DOMAIN`` (or ``GR_UNABLE``) + # when the ring is not a subring of the real or complex numbers. + + int gr_pos_inf(gr_ptr res, gr_ctx_t ctx) + int gr_neg_inf(gr_ptr res, gr_ctx_t ctx) + int gr_uinf(gr_ptr res, gr_ctx_t ctx) + int gr_undefined(gr_ptr res, gr_ctx_t ctx) + int gr_unknown(gr_ptr res, gr_ctx_t ctx) + + int gr_cmp(int * res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) + int gr_cmp_other(int * res, gr_srcptr x, gr_srcptr y, gr_ctx_t y_ctx, gr_ctx_t ctx) + # Sets *res* to -1, 0 or 1 according to whether *x* is less than, + # equal or greater than the absolute value of *y*. + # This may return ``GR_DOMAIN`` if the ring is not an ordered ring. + + int gr_cmpabs(int * res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) + int gr_cmpabs_other(int * res, gr_srcptr x, gr_srcptr y, gr_ctx_t y_ctx, gr_ctx_t ctx) + # Sets *res* to -1, 0 or 1 according to whether the absolute value + # of *x* is less than, equal or greater than the absolute value of *y*. + # This may return ``GR_DOMAIN`` if the ring is not an ordered ring. + + int gr_ctx_fq_prime(fmpz_t p, gr_ctx_t ctx) + + int gr_ctx_fq_degree(long * deg, gr_ctx_t ctx) + + int gr_ctx_fq_order(fmpz_t q, gr_ctx_t ctx) + + int gr_fq_frobenius(gr_ptr res, gr_srcptr x, long e, gr_ctx_t ctx) + + int gr_fq_multiplicative_order(fmpz_t res, gr_srcptr x, gr_ctx_t ctx) + + int gr_fq_norm(fmpz_t res, gr_srcptr x, gr_ctx_t ctx) + + int gr_fq_trace(fmpz_t res, gr_srcptr x, gr_ctx_t ctx) + + truth_t gr_fq_is_primitive(gr_srcptr x, gr_ctx_t ctx) + + int gr_fq_pth_root(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) diff --git a/src/sage/libs/flint/gr_generic.pxd b/src/sage/libs/flint/gr_generic.pxd new file mode 100644 index 00000000000..5a6b9b357c2 --- /dev/null +++ b/src/sage/libs/flint/gr_generic.pxd @@ -0,0 +1,271 @@ +# distutils: libraries = flint +# distutils: depends = flint/gr_generic.h + +################################################################################ +# This file is auto-generated. Do not modify by hand +################################################################################ + +from libc.stdio cimport FILE +from sage.libs.gmp.types cimport * +from sage.libs.mpfr.types cimport * +from sage.libs.flint.types cimport * + +cdef extern from "flint_wrap.h": + + void gr_generic_init() + void gr_generic_clear() + void gr_generic_swap() + void gr_generic_randtest() + void gr_generic_write() + void gr_generic_zero() + void gr_generic_one() + void gr_generic_equal() + void gr_generic_set() + void gr_generic_set_si() + void gr_generic_set_ui() + void gr_generic_set_fmpz() + void gr_generic_neg() + void gr_generic_add() + void gr_generic_sub() + void gr_generic_mul() + + int gr_generic_ctx_clear(gr_ctx_t ctx) + + void gr_generic_set_shallow(gr_ptr res, gr_srcptr x, const gr_ctx_t ctx) + + int gr_generic_write_n(gr_stream_t out, gr_srcptr x, long n, gr_ctx_t ctx) + + int gr_generic_randtest_not_zero(gr_ptr x, flint_rand_t state, gr_ctx_t ctx) + + int gr_generic_randtest_small(gr_ptr x, flint_rand_t state, gr_ctx_t ctx) + + truth_t gr_generic_is_zero(gr_srcptr x, gr_ctx_t ctx) + truth_t gr_generic_is_one(gr_srcptr x, gr_ctx_t ctx) + truth_t gr_generic_is_neg_one(gr_srcptr x, gr_ctx_t ctx) + + int gr_generic_neg_one(gr_ptr res, gr_ctx_t ctx) + + int gr_generic_set_other(gr_ptr res, gr_srcptr x, gr_ctx_t xctx, gr_ctx_t ctx) + int gr_generic_set_fmpq(gr_ptr res, const fmpq_t y, gr_ctx_t ctx) + + int gr_generic_add_fmpz(gr_ptr res, gr_srcptr x, const fmpz_t y, gr_ctx_t ctx) + int gr_generic_add_ui(gr_ptr res, gr_srcptr x, unsigned long y, gr_ctx_t ctx) + int gr_generic_add_si(gr_ptr res, gr_srcptr x, long y, gr_ctx_t ctx) + int gr_generic_add_fmpq(gr_ptr res, gr_srcptr x, const fmpq_t y, gr_ctx_t ctx) + int gr_generic_add_other(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t y_ctx, gr_ctx_t ctx) + int gr_generic_other_add(gr_ptr res, gr_srcptr x, gr_ctx_t x_ctx, gr_srcptr y, gr_ctx_t ctx) + + int gr_generic_sub_ui(gr_ptr res, gr_srcptr x, unsigned long y, gr_ctx_t ctx) + int gr_generic_sub_si(gr_ptr res, gr_srcptr x, long y, gr_ctx_t ctx) + int gr_generic_sub_fmpz(gr_ptr res, gr_srcptr x, const fmpz_t y, gr_ctx_t ctx) + int gr_generic_sub_fmpq(gr_ptr res, gr_srcptr x, const fmpq_t y, gr_ctx_t ctx) + int gr_generic_sub_other(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t y_ctx, gr_ctx_t ctx) + int gr_generic_other_sub(gr_ptr res, gr_srcptr x, gr_ctx_t x_ctx, gr_srcptr y, gr_ctx_t ctx) + + int gr_generic_mul_fmpz(gr_ptr res, gr_srcptr x, const fmpz_t y, gr_ctx_t ctx) + int gr_generic_mul_ui(gr_ptr res, gr_srcptr x, unsigned long y, gr_ctx_t ctx) + int gr_generic_mul_si(gr_ptr res, gr_srcptr x, long y, gr_ctx_t ctx) + int gr_generic_mul_fmpq(gr_ptr res, gr_srcptr x, const fmpq_t y, gr_ctx_t ctx) + int gr_generic_mul_other(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t y_ctx, gr_ctx_t ctx) + int gr_generic_other_mul(gr_ptr res, gr_srcptr x, gr_ctx_t x_ctx, gr_srcptr y, gr_ctx_t ctx) + + int gr_generic_addmul(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) + int gr_generic_addmul_ui(gr_ptr res, gr_srcptr x, unsigned long y, gr_ctx_t ctx) + int gr_generic_addmul_si(gr_ptr res, gr_srcptr x, long y, gr_ctx_t ctx) + int gr_generic_addmul_fmpz(gr_ptr res, gr_srcptr x, const fmpz_t y, gr_ctx_t ctx) + int gr_generic_addmul_fmpq(gr_ptr res, gr_srcptr x, const fmpq_t y, gr_ctx_t ctx) + int gr_generic_addmul_other(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t y_ctx, gr_ctx_t ctx) + + int gr_generic_submul(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) + int gr_generic_submul_ui(gr_ptr res, gr_srcptr x, unsigned long y, gr_ctx_t ctx) + int gr_generic_submul_si(gr_ptr res, gr_srcptr x, long y, gr_ctx_t ctx) + int gr_generic_submul_fmpz(gr_ptr res, gr_srcptr x, const fmpz_t y, gr_ctx_t ctx) + int gr_generic_submul_fmpq(gr_ptr res, gr_srcptr x, const fmpq_t y, gr_ctx_t ctx) + int gr_generic_submul_other(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t y_ctx, gr_ctx_t ctx) + + int gr_generic_mul_two(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) + + int gr_generic_sqr(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) + + int gr_generic_mul_2exp_si(gr_ptr res, gr_srcptr x, long y, gr_ctx_t ctx) + int gr_generic_mul_2exp_fmpz(gr_ptr res, gr_srcptr x, const fmpz_t y, gr_ctx_t ctx) + + int gr_generic_set_fmpz_2exp_fmpz(gr_ptr res, const fmpz_t x, const fmpz_t y, gr_ctx_t ctx) + + int gr_generic_get_fmpz_2exp_fmpz(fmpz_t res1, fmpz_t res2, gr_ptr x, gr_ctx_t ctx) + + int gr_generic_inv(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) + + truth_t gr_generic_is_invertible(gr_srcptr x, gr_ctx_t ctx) + + int gr_generic_div_fmpz(gr_ptr res, gr_srcptr x, const fmpz_t y, gr_ctx_t ctx) + int gr_generic_div_ui(gr_ptr res, gr_srcptr x, unsigned long y, gr_ctx_t ctx) + int gr_generic_div_si(gr_ptr res, gr_srcptr x, long y, gr_ctx_t ctx) + int gr_generic_div_fmpq(gr_ptr res, gr_srcptr x, const fmpq_t y, gr_ctx_t ctx) + int gr_generic_div_other(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t y_ctx, gr_ctx_t ctx) + int gr_generic_other_div(gr_ptr res, gr_srcptr x, gr_ctx_t x_ctx, gr_srcptr y, gr_ctx_t ctx) + + int gr_generic_divexact(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) + + int gr_generic_pow_fmpz_sliding(gr_ptr f, gr_srcptr g, const fmpz_t pow, gr_ctx_t ctx) + int gr_generic_pow_ui_sliding(gr_ptr f, gr_srcptr g, unsigned long pow, gr_ctx_t ctx) + int gr_generic_pow_fmpz_binexp(gr_ptr res, gr_srcptr x, const fmpz_t exp, gr_ctx_t ctx) + int gr_generic_pow_ui_binexp(gr_ptr res, gr_srcptr x, unsigned long e, gr_ctx_t ctx) + + int gr_generic_pow_fmpz(gr_ptr res, gr_srcptr x, const fmpz_t e, gr_ctx_t ctx) + int gr_generic_pow_si(gr_ptr res, gr_srcptr x, long e, gr_ctx_t ctx) + int gr_generic_pow_ui(gr_ptr res, gr_srcptr x, unsigned long e, gr_ctx_t ctx) + int gr_generic_pow_fmpq(gr_ptr res, gr_srcptr x, const fmpq_t y, gr_ctx_t ctx) + int gr_generic_pow_other(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t y_ctx, gr_ctx_t ctx) + int gr_generic_other_pow(gr_ptr res, gr_srcptr x, gr_ctx_t x_ctx, gr_srcptr y, gr_ctx_t ctx) + + int _gr_fmpz_poly_evaluate_horner(gr_ptr res, const fmpz * f, long len, gr_srcptr x, gr_ctx_t ctx) + int gr_fmpz_poly_evaluate_horner(gr_ptr res, const fmpz_poly_t f, gr_srcptr x, gr_ctx_t ctx) + int _gr_fmpz_poly_evaluate_rectangular(gr_ptr res, const fmpz * f, long len, gr_srcptr x, gr_ctx_t ctx) + int gr_fmpz_poly_evaluate_rectangular(gr_ptr res, const fmpz_poly_t f, gr_srcptr x, gr_ctx_t ctx) + int _gr_fmpz_poly_evaluate(gr_ptr res, const fmpz * f, long len, gr_srcptr x, gr_ctx_t ctx) + int gr_fmpz_poly_evaluate(gr_ptr res, const fmpz_poly_t f, gr_srcptr x, gr_ctx_t ctx) + # Sets *res* to the value of the integer polynomial *f* evaluated + # at the argument *x*. + + int gr_fmpz_mpoly_evaluate(gr_ptr res, const fmpz_mpoly_t f, gr_srcptr x, const fmpz_mpoly_ctx_t mctx, gr_ctx_t ctx) + # Sets *res* to value of the multivariate polynomial *f* (with + # corresponding context object *mctx*) evaluated at the vector + # of arguments in *x*. + + truth_t gr_generic_is_square(gr_srcptr x, gr_ctx_t ctx) + int gr_generic_sqrt(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) + int gr_generic_rsqrt(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) + # Currently these methods check for the special values 0 and 1. + + int gr_generic_numerator(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) + int gr_generic_denominator(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) + + int gr_generic_cmp(int * res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) + int gr_generic_cmpabs(int * res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) + int gr_generic_cmp_other(int * res, gr_srcptr x, gr_srcptr y, gr_ctx_t y_ctx, gr_ctx_t ctx) + int gr_generic_cmpabs_other(int * res, gr_srcptr x, gr_srcptr y, gr_ctx_t y_ctx, gr_ctx_t ctx) + + int gr_generic_bernoulli_ui(gr_ptr res, unsigned long n, gr_ctx_t ctx) + int gr_generic_bernoulli_fmpz(gr_ptr res, const fmpz_t n, gr_ctx_t ctx) + int gr_generic_bernoulli_vec(gr_ptr res, long len, gr_ctx_t ctx) + int gr_generic_eulernum_ui(gr_ptr res, unsigned long n, gr_ctx_t ctx) + int gr_generic_eulernum_fmpz(gr_ptr res, const fmpz_t n, gr_ctx_t ctx) + int gr_generic_eulernum_vec(gr_ptr res, long len, gr_ctx_t ctx) + int gr_generic_stirling_s1u_uiui(gr_ptr res, unsigned long x, unsigned long y, gr_ctx_t ctx) + int gr_generic_stirling_s1_uiui(gr_ptr res, unsigned long x, unsigned long y, gr_ctx_t ctx) + int gr_generic_stirling_s2_uiui(gr_ptr res, unsigned long x, unsigned long y, gr_ctx_t ctx) + int gr_generic_stirling_s1u_ui_vec(gr_ptr res, unsigned long x, long len, gr_ctx_t ctx) + int gr_generic_stirling_s1_ui_vec(gr_ptr res, unsigned long x, long len, gr_ctx_t ctx) + int gr_generic_stirling_s2_ui_vec(gr_ptr res, unsigned long x, long len, gr_ctx_t ctx) + + void gr_generic_vec_init(gr_ptr vec, long len, gr_ctx_t ctx) + + void gr_generic_vec_clear(gr_ptr vec, long len, gr_ctx_t ctx) + + void gr_generic_vec_swap(gr_ptr vec1, gr_ptr vec2, long len, gr_ctx_t ctx) + + int gr_generic_vec_zero(gr_ptr vec, long len, gr_ctx_t ctx) + + int gr_generic_vec_set(gr_ptr res, gr_srcptr src, long len, gr_ctx_t ctx) + + int gr_generic_vec_neg(gr_ptr res, gr_srcptr src, long len, gr_ctx_t ctx) + + int gr_generic_vec_normalise(long * res, gr_srcptr vec, long len, gr_ctx_t ctx) + + long gr_generic_vec_normalise_weak(gr_srcptr vec, long len, gr_ctx_t ctx) + + int gr_generic_vec_mul_scalar_2exp_si(gr_ptr vec1, gr_srcptr vec2, long len, long c, gr_ctx_t ctx) + + int gr_generic_vec_scalar_addmul(gr_ptr vec1, gr_srcptr vec2, long len, gr_srcptr c, gr_ctx_t ctx) + + int gr_generic_vec_scalar_submul(gr_ptr vec1, gr_srcptr vec2, long len, gr_srcptr c, gr_ctx_t ctx) + + int gr_generic_vec_scalar_addmul_si(gr_ptr vec1, gr_srcptr vec2, long len, long c, gr_ctx_t ctx) + + int gr_generic_vec_scalar_submul_si(gr_ptr vec1, gr_srcptr vec2, long len, long c, gr_ctx_t ctx) + + truth_t gr_generic_vec_equal(gr_srcptr vec1, gr_srcptr vec2, long len, gr_ctx_t ctx) + + int gr_generic_vec_is_zero(gr_srcptr vec, long len, gr_ctx_t ctx) + + int gr_generic_vec_dot(gr_ptr res, gr_srcptr initial, int subtract, gr_srcptr vec1, gr_srcptr vec2, long len, gr_ctx_t ctx) + + int gr_generic_vec_dot_rev(gr_ptr res, gr_srcptr initial, int subtract, gr_srcptr vec1, gr_srcptr vec2, long len, gr_ctx_t ctx) + + int gr_generic_vec_dot_ui(gr_ptr res, gr_srcptr initial, int subtract, gr_srcptr vec1, const unsigned long * vec2, long len, gr_ctx_t ctx) + + int gr_generic_vec_dot_si(gr_ptr res, gr_srcptr initial, int subtract, gr_srcptr vec1, const long * vec2, long len, gr_ctx_t ctx) + + int gr_generic_vec_dot_fmpz(gr_ptr res, gr_srcptr initial, int subtract, gr_srcptr vec1, const fmpz * vec2, long len, gr_ctx_t ctx) + + int gr_generic_vec_set_powers(gr_ptr res, gr_srcptr x, long len, gr_ctx_t ctx) + + int gr_generic_vec_reciprocals(gr_ptr res, long len, gr_ctx_t ctx) + + int gr_generic_vec_add(gr_ptr res, gr_srcptr src1, gr_srcptr src2, long len, gr_ctx_t ctx) + int gr_generic_vec_sub(gr_ptr res, gr_srcptr src1, gr_srcptr src2, long len, gr_ctx_t ctx) + int gr_generic_vec_mul(gr_ptr res, gr_srcptr src1, gr_srcptr src2, long len, gr_ctx_t ctx) + int gr_generic_vec_div(gr_ptr res, gr_srcptr src1, gr_srcptr src2, long len, gr_ctx_t ctx) + int gr_generic_vec_divexact(gr_ptr res, gr_srcptr src1, gr_srcptr src2, long len, gr_ctx_t ctx) + int gr_generic_vec_pow(gr_ptr res, gr_srcptr src1, gr_srcptr src2, long len, gr_ctx_t ctx) + int gr_generic_vec_add_scalar(gr_ptr vec1, gr_srcptr vec2, long len, gr_srcptr c, gr_ctx_t ctx) + int gr_generic_vec_sub_scalar(gr_ptr vec1, gr_srcptr vec2, long len, gr_srcptr c, gr_ctx_t ctx) + int gr_generic_vec_mul_scalar(gr_ptr vec1, gr_srcptr vec2, long len, gr_srcptr c, gr_ctx_t ctx) + int gr_generic_vec_div_scalar(gr_ptr vec1, gr_srcptr vec2, long len, gr_srcptr c, gr_ctx_t ctx) + int gr_generic_vec_divexact_scalar(gr_ptr vec1, gr_srcptr vec2, long len, gr_srcptr c, gr_ctx_t ctx) + int gr_generic_vec_pow_scalar(gr_ptr vec1, gr_srcptr vec2, long len, gr_srcptr c, gr_ctx_t ctx) + int gr_generic_vec_add_scalar_si(gr_ptr vec1, gr_srcptr vec2, long len, long c, gr_ctx_t ctx) + int gr_generic_vec_sub_scalar_si(gr_ptr vec1, gr_srcptr vec2, long len, long c, gr_ctx_t ctx) + int gr_generic_vec_mul_scalar_si(gr_ptr vec1, gr_srcptr vec2, long len, long c, gr_ctx_t ctx) + int gr_generic_vec_div_scalar_si(gr_ptr vec1, gr_srcptr vec2, long len, long c, gr_ctx_t ctx) + int gr_generic_vec_divexact_scalar_si(gr_ptr vec1, gr_srcptr vec2, long len, long c, gr_ctx_t ctx) + int gr_generic_vec_pow_scalar_si(gr_ptr vec1, gr_srcptr vec2, long len, long c, gr_ctx_t ctx) + int gr_generic_vec_add_scalar_ui(gr_ptr vec1, gr_srcptr vec2, long len, unsigned long c, gr_ctx_t ctx) + int gr_generic_vec_sub_scalar_ui(gr_ptr vec1, gr_srcptr vec2, long len, unsigned long c, gr_ctx_t ctx) + int gr_generic_vec_mul_scalar_ui(gr_ptr vec1, gr_srcptr vec2, long len, unsigned long c, gr_ctx_t ctx) + int gr_generic_vec_div_scalar_ui(gr_ptr vec1, gr_srcptr vec2, long len, unsigned long c, gr_ctx_t ctx) + int gr_generic_vec_divexact_scalar_ui(gr_ptr vec1, gr_srcptr vec2, long len, unsigned long c, gr_ctx_t ctx) + int gr_generic_vec_pow_scalar_ui(gr_ptr vec1, gr_srcptr vec2, long len, unsigned long c, gr_ctx_t ctx) + int gr_generic_vec_add_scalar_fmpz(gr_ptr vec1, gr_srcptr vec2, long len, const fmpz_t c, gr_ctx_t ctx) + int gr_generic_vec_sub_scalar_fmpz(gr_ptr vec1, gr_srcptr vec2, long len, const fmpz_t c, gr_ctx_t ctx) + int gr_generic_vec_mul_scalar_fmpz(gr_ptr vec1, gr_srcptr vec2, long len, const fmpz_t c, gr_ctx_t ctx) + int gr_generic_vec_div_scalar_fmpz(gr_ptr vec1, gr_srcptr vec2, long len, const fmpz_t c, gr_ctx_t ctx) + int gr_generic_vec_divexact_scalar_fmpz(gr_ptr vec1, gr_srcptr vec2, long len, const fmpz_t c, gr_ctx_t ctx) + int gr_generic_vec_pow_scalar_fmpz(gr_ptr vec1, gr_srcptr vec2, long len, const fmpz_t c, gr_ctx_t ctx) + int gr_generic_vec_add_scalar_fmpq(gr_ptr vec1, gr_srcptr vec2, long len, const fmpq_t c, gr_ctx_t ctx) + int gr_generic_vec_sub_scalar_fmpq(gr_ptr vec1, gr_srcptr vec2, long len, const fmpq_t c, gr_ctx_t ctx) + int gr_generic_vec_mul_scalar_fmpq(gr_ptr vec1, gr_srcptr vec2, long len, const fmpq_t c, gr_ctx_t ctx) + int gr_generic_vec_div_scalar_fmpq(gr_ptr vec1, gr_srcptr vec2, long len, const fmpq_t c, gr_ctx_t ctx) + int gr_generic_vec_divexact_scalar_fmpq(gr_ptr vec1, gr_srcptr vec2, long len, const fmpq_t c, gr_ctx_t ctx) + int gr_generic_vec_pow_scalar_fmpq(gr_ptr vec1, gr_srcptr vec2, long len, const fmpq_t c, gr_ctx_t ctx) + int gr_generic_scalar_add_vec(gr_ptr vec1, gr_srcptr c, gr_srcptr vec2, long len, gr_ctx_t ctx) + int gr_generic_scalar_sub_vec(gr_ptr vec1, gr_srcptr c, gr_srcptr vec2, long len, gr_ctx_t ctx) + int gr_generic_scalar_mul_vec(gr_ptr vec1, gr_srcptr c, gr_srcptr vec2, long len, gr_ctx_t ctx) + int gr_generic_scalar_div_vec(gr_ptr vec1, gr_srcptr c, gr_srcptr vec2, long len, gr_ctx_t ctx) + int gr_generic_scalar_divexact_vec(gr_ptr vec1, gr_srcptr c, gr_srcptr vec2, long len, gr_ctx_t ctx) + int gr_generic_scalar_pow_vec(gr_ptr vec1, gr_srcptr c, gr_srcptr vec2, long len, gr_ctx_t ctx) + int gr_generic_vec_add_other(gr_ptr vec1, gr_srcptr vec2, gr_srcptr vec3, gr_ctx_t ctx3, long len, gr_ctx_t ctx) + int gr_generic_vec_sub_other(gr_ptr vec1, gr_srcptr vec2, gr_srcptr vec3, gr_ctx_t ctx3, long len, gr_ctx_t ctx) + int gr_generic_vec_mul_other(gr_ptr vec1, gr_srcptr vec2, gr_srcptr vec3, gr_ctx_t ctx3, long len, gr_ctx_t ctx) + int gr_generic_vec_div_other(gr_ptr vec1, gr_srcptr vec2, gr_srcptr vec3, gr_ctx_t ctx3, long len, gr_ctx_t ctx) + int gr_generic_vec_divexact_other(gr_ptr vec1, gr_srcptr vec2, gr_srcptr vec3, gr_ctx_t ctx3, long len, gr_ctx_t ctx) + int gr_generic_vec_pow_other(gr_ptr vec1, gr_srcptr vec2, gr_srcptr vec3, gr_ctx_t ctx3, long len, gr_ctx_t ctx) + int gr_generic_other_add_vec(gr_ptr vec1, gr_srcptr vec2, gr_ctx_t ctx2, gr_srcptr vec3, long len, gr_ctx_t ctx) + int gr_generic_other_sub_vec(gr_ptr vec1, gr_srcptr vec2, gr_ctx_t ctx2, gr_srcptr vec3, long len, gr_ctx_t ctx) + int gr_generic_other_mul_vec(gr_ptr vec1, gr_srcptr vec2, gr_ctx_t ctx2, gr_srcptr vec3, long len, gr_ctx_t ctx) + int gr_generic_other_div_vec(gr_ptr vec1, gr_srcptr vec2, gr_ctx_t ctx2, gr_srcptr vec3, long len, gr_ctx_t ctx) + int gr_generic_other_divexact_vec(gr_ptr vec1, gr_srcptr vec2, gr_ctx_t ctx2, gr_srcptr vec3, long len, gr_ctx_t ctx) + int gr_generic_other_pow_vec(gr_ptr vec1, gr_srcptr vec2, gr_ctx_t ctx2, gr_srcptr vec3, long len, gr_ctx_t ctx) + int gr_generic_vec_add_scalar_other(gr_ptr vec1, gr_srcptr vec2, long len, gr_srcptr c, gr_ctx_t cctx, gr_ctx_t ctx) + int gr_generic_vec_sub_scalar_other(gr_ptr vec1, gr_srcptr vec2, long len, gr_srcptr c, gr_ctx_t cctx, gr_ctx_t ctx) + int gr_generic_vec_mul_scalar_other(gr_ptr vec1, gr_srcptr vec2, long len, gr_srcptr c, gr_ctx_t cctx, gr_ctx_t ctx) + int gr_generic_vec_div_scalar_other(gr_ptr vec1, gr_srcptr vec2, long len, gr_srcptr c, gr_ctx_t cctx, gr_ctx_t ctx) + int gr_generic_vec_divexact_scalar_other(gr_ptr vec1, gr_srcptr vec2, long len, gr_srcptr c, gr_ctx_t cctx, gr_ctx_t ctx) + int gr_generic_vec_pow_scalar_other(gr_ptr vec1, gr_srcptr vec2, long len, gr_srcptr c, gr_ctx_t cctx, gr_ctx_t ctx) + int gr_generic_scalar_other_add_vec(gr_ptr vec1, gr_srcptr c, gr_ctx_t cctx, gr_srcptr vec2, long len, gr_ctx_t ctx) + int gr_generic_scalar_other_sub_vec(gr_ptr vec1, gr_srcptr c, gr_ctx_t cctx, gr_srcptr vec2, long len, gr_ctx_t ctx) + int gr_generic_scalar_other_mul_vec(gr_ptr vec1, gr_srcptr c, gr_ctx_t cctx, gr_srcptr vec2, long len, gr_ctx_t ctx) + int gr_generic_scalar_other_div_vec(gr_ptr vec1, gr_srcptr c, gr_ctx_t cctx, gr_srcptr vec2, long len, gr_ctx_t ctx) + int gr_generic_scalar_other_divexact_vec(gr_ptr vec1, gr_srcptr c, gr_ctx_t cctx, gr_srcptr vec2, long len, gr_ctx_t ctx) + int gr_generic_scalar_other_pow_vec(gr_ptr vec1, gr_srcptr c, gr_ctx_t cctx, gr_srcptr vec2, long len, gr_ctx_t ctx) diff --git a/src/sage/libs/flint/gr_mat.pxd b/src/sage/libs/flint/gr_mat.pxd new file mode 100644 index 00000000000..d75f4b7c7e5 --- /dev/null +++ b/src/sage/libs/flint/gr_mat.pxd @@ -0,0 +1,541 @@ +# distutils: libraries = flint +# distutils: depends = flint/gr_mat.h + +################################################################################ +# This file is auto-generated. Do not modify by hand +################################################################################ + +from libc.stdio cimport FILE +from sage.libs.gmp.types cimport * +from sage.libs.mpfr.types cimport * +from sage.libs.flint.types cimport * + +cdef extern from "flint_wrap.h": + + gr_ptr gr_mat_entry_ptr(gr_mat_t mat, long i, long j, gr_ctx_t ctx) + # Function returning a pointer to the entry at row *i* and column + # *j* of the matrix *mat*. The indices must be in bounds. + + void gr_mat_init(gr_mat_t mat, long rows, long cols, gr_ctx_t ctx) + # Initializes *mat* to a matrix with the given number of rows and + # columns. + + int gr_mat_init_set(gr_mat_t res, const gr_mat_t mat, gr_ctx_t ctx) + # Initializes *res* to a copy of the matrix *mat*. + + void gr_mat_clear(gr_mat_t mat, gr_ctx_t ctx) + # Clears the matrix. + + void gr_mat_swap(gr_mat_t mat1, gr_mat_t mat2, gr_ctx_t ctx) + # Swaps *mat1* and *mat12* efficiently. + + int gr_mat_swap_entrywise(gr_mat_t mat1, const gr_mat_t mat2, gr_ctx_t ctx) + # Performs a deep swap of *mat1* and *mat2*, swapping the individual + # entries rather than the top-level structures. + + void gr_mat_window_init(gr_mat_t window, const gr_mat_t mat, long r1, long c1, long r2, long c2, gr_ctx_t ctx) + # Initializes *window* to a window matrix into the submatrix of *mat* + # starting at the corner at row *r1* and column *c1* (inclusive) and ending + # at row *r2* and column *c2* (exclusive). + # The indices must be within bounds. + + void gr_mat_window_clear(gr_mat_t window, gr_ctx_t ctx) + # Frees the window matrix. + + int gr_mat_write(gr_stream_t out, const gr_mat_t mat, gr_ctx_t ctx) + # Write *mat* to the stream *out*. + + int gr_mat_print(const gr_mat_t mat, gr_ctx_t ctx) + # Prints *mat* to standard output. + + truth_t gr_mat_equal(const gr_mat_t mat1, const gr_mat_t mat2, gr_ctx_t ctx) + # Returns whether *mat1* and *mat2* are equal. + + truth_t gr_mat_is_zero(const gr_mat_t mat, gr_ctx_t ctx) + truth_t gr_mat_is_one(const gr_mat_t mat, gr_ctx_t ctx) + truth_t gr_mat_is_neg_one(const gr_mat_t mat, gr_ctx_t ctx) + # Returns whether *mat* respectively is the zero matrix or + # the scalar matrix with 1 or -1 on the main diagonal. + + truth_t gr_mat_is_scalar(const gr_mat_t mat, gr_ctx_t ctx) + # Returns whether *mat* is a scalar matrix, being a diagonal matrix + # with identical elements on the main diagonal. + + int gr_mat_zero(gr_mat_t res, gr_ctx_t ctx) + # Sets *res* to the zero matrix. + + int gr_mat_one(gr_mat_t res, gr_ctx_t ctx) + # Sets *res* to the scalar matrix with 1 on the main diagonal + # and zero elsewhere. + + int gr_mat_set(gr_mat_t res, const gr_mat_t mat, gr_ctx_t ctx) + int gr_mat_set_fmpz_mat(gr_mat_t res, const fmpz_mat_t mat, gr_ctx_t ctx) + int gr_mat_set_fmpq_mat(gr_mat_t res, const fmpq_mat_t mat, gr_ctx_t ctx) + # Sets *res* to the value of *mat*. + + int gr_mat_set_scalar(gr_mat_t res, gr_srcptr c, gr_ctx_t ctx) + int gr_mat_set_ui(gr_mat_t res, unsigned long c, gr_ctx_t ctx) + int gr_mat_set_si(gr_mat_t res, long c, gr_ctx_t ctx) + int gr_mat_set_fmpz(gr_mat_t res, const fmpz_t c, gr_ctx_t ctx) + int gr_mat_set_fmpq(gr_mat_t res, const fmpq_t c, gr_ctx_t ctx) + # Set *res* to the scalar matrix with *c* on the main diagonal + # and zero elsewhere. + + int gr_mat_concat_horizontal(gr_mat_t res, const gr_mat_t mat1, const gr_mat_t mat2, gr_ctx_t ctx) + + int gr_mat_concat_vertical(gr_mat_t res, const gr_mat_t mat1, const gr_mat_t mat2, gr_ctx_t ctx) + + int gr_mat_transpose(gr_mat_t B, const gr_mat_t A, gr_ctx_t ctx) + # Sets *B* to the transpose of *A*. + + int gr_mat_swap_rows(gr_mat_t mat, long * perm, long r, long s, gr_ctx_t ctx) + # Swaps rows ``r`` and ``s`` of ``mat``. If ``perm`` is non-``NULL``, the + # permutation of the rows will also be applied to ``perm``. + + int gr_mat_swap_cols(gr_mat_t mat, long * perm, long r, long s, gr_ctx_t ctx) + # Swaps columns ``r`` and ``s`` of ``mat``. If ``perm`` is non-``NULL``, the + # permutation of the columns will also be applied to ``perm``. + + int gr_mat_invert_rows(gr_mat_t mat, long * perm, gr_ctx_t ctx) + # Swaps rows ``i`` and ``r - i`` of ``mat`` for ``0 <= i < r/2``, where + # ``r`` is the number of rows of ``mat``. If ``perm`` is non-``NULL``, the + # permutation of the rows will also be applied to ``perm``. + + int gr_mat_invert_cols(gr_mat_t mat, long * perm, gr_ctx_t ctx) + # Swaps columns ``i`` and ``c - i`` of ``mat`` for ``0 <= i < c/2``, where + # ``c`` is the number of columns of ``mat``. If ``perm`` is non-``NULL``, the + # permutation of the columns will also be applied to ``perm``. + + truth_t gr_mat_is_empty(const gr_mat_t mat, gr_ctx_t ctx) + # Returns whether *mat* is an empty matrix, having either zero + # rows or zero column. This predicate is always decidable (even if + # the underlying ring is not computable), returning + # ``T_TRUE`` or ``T_FALSE``. + + truth_t gr_mat_is_square(const gr_mat_t mat, gr_ctx_t ctx) + # Returns whether *mat* is a square matrix, having the same number + # of rows as columns (not the same thing as being a perfect square!). + # This predicate is always decidable (even if the underlying ring + # is not computable), returning ``T_TRUE`` or ``T_FALSE``. + + int gr_mat_neg(gr_mat_t res, const gr_mat_t mat, gr_ctx_t ctx) + + int gr_mat_add(gr_mat_t res, const gr_mat_t mat1, const gr_mat_t mat2, gr_ctx_t ctx) + + int gr_mat_sub(gr_mat_t res, const gr_mat_t mat1, const gr_mat_t mat2, gr_ctx_t ctx) + + int gr_mat_mul_classical(gr_mat_t res, const gr_mat_t mat1, const gr_mat_t mat2, gr_ctx_t ctx) + int gr_mat_mul_strassen(gr_mat_t C, const gr_mat_t A, const gr_mat_t B, gr_ctx_t ctx); + int gr_mat_mul_generic(gr_mat_t C, const gr_mat_t A, const gr_mat_t B, gr_ctx_t ctx) + int gr_mat_mul(gr_mat_t res, const gr_mat_t mat1, const gr_mat_t mat2, gr_ctx_t ctx) + # Matrix multiplication. The default function can be overloaded by specific rings; + # otherwise, it falls back to :func:`gr_mat_mul_generic` which currently + # only performs classical multiplication. + + int gr_mat_sqr(gr_mat_t res, const gr_mat_t mat, gr_ctx_t ctx) + + int gr_mat_add_scalar(gr_mat_t res, const gr_mat_t mat, gr_srcptr c, gr_ctx_t ctx) + int gr_mat_sub_scalar(gr_mat_t res, const gr_mat_t mat, gr_srcptr c, gr_ctx_t ctx) + int gr_mat_mul_scalar(gr_mat_t res, const gr_mat_t mat, gr_srcptr c, gr_ctx_t ctx) + int gr_mat_addmul_scalar(gr_mat_t res, const gr_mat_t mat, gr_srcptr c, gr_ctx_t ctx) + int gr_mat_submul_scalar(gr_mat_t res, const gr_mat_t mat, gr_srcptr c, gr_ctx_t ctx) + int gr_mat_div_scalar(gr_mat_t res, const gr_mat_t mat, gr_srcptr c, gr_ctx_t ctx) + + int _gr_mat_gr_poly_evaluate(gr_mat_t res, gr_srcptr poly, long len, const gr_mat_t mat, gr_ctx_t ctx) + int gr_mat_gr_poly_evaluate(gr_mat_t res, const gr_poly_t poly, const gr_mat_t mat, gr_ctx_t ctx) + # Sets *res* to the matrix obtained by evaluating the + # scalar polynomial *poly* with matrix argument *mat*. + + truth_t gr_mat_is_upper_triangular(const gr_mat_t mat, gr_ctx_t ctx) + truth_t gr_mat_is_lower_triangular(const gr_mat_t mat, gr_ctx_t ctx) + # Returns whether *mat* is upper (respectively lower) triangular, having + # zeros everywhere below (respectively above) the main diagonal. + # The matrix need not be square. + + truth_t gr_mat_is_diagonal(const gr_mat_t mat, gr_ctx_t ctx) + # Returns whether *mat* is a diagonal matrix, having zeros everywhere + # except on the main diagonal. + # The matrix need not be square. + + int gr_mat_mul_diag(gr_mat_t res, const gr_mat_t A, const gr_vec_t D, gr_ctx_t ctx) + int gr_mat_diag_mul(gr_mat_t res, const gr_vec_t D, const gr_mat_t A, gr_ctx_t ctx) + # Set *res* to the product `AD` or `DA` respectively, where `D` is + # a diagonal matrix represented as a vector of entries. + + int gr_mat_find_nonzero_pivot_large_abs(long * pivot_row, gr_mat_t mat, long start_row, long end_row, long column, gr_ctx_t ctx) + int gr_mat_find_nonzero_pivot_generic(long * pivot_row, gr_mat_t mat, long start_row, long end_row, long column, gr_ctx_t ctx) + int gr_mat_find_nonzero_pivot(long * pivot_row, gr_mat_t mat, long start_row, long end_row, long column, gr_ctx_t ctx) + # Attempts to find a nonzero element in column number *column* + # of the matrix *mat* in a row between *start_row* (inclusive) + # and *end_row* (exclusive). + # On success, sets ``pivot_row`` to the row index and returns + # ``GR_SUCCESS``. If no nonzero pivot element exists, returns ``GR_DOMAIN``. + # If no nonzero pivot element exists and zero-testing fails for some + # element, returns the flag ``GR_UNABLE``. + # This function may be destructive: any elements that are nontrivially + # zero but can be certified zero may be overwritten by exact zeros. + + int gr_mat_lu_classical(long * rank, long * P, gr_mat_t LU, const gr_mat_t A, int rank_check, gr_ctx_t ctx) + int gr_mat_lu_recursive(long * rank, long * P, gr_mat_t LU, const gr_mat_t A, int rank_check, gr_ctx_t ctx) + int gr_mat_lu(long * rank, long * P, gr_mat_t LU, const gr_mat_t A, int rank_check, gr_ctx_t ctx) + # Computes a generalized LU decomposition `A = PLU` of a given + # matrix *A*, writing the rank of *A* to *rank*. + # If *A* is a nonsingular square matrix, *LU* will be set to + # a unit diagonal lower triangular matrix *L* and an upper + # triangular matrix *U* (the diagonal of *L* will not be stored + # explicitly). + # If *A* is an arbitrary matrix of rank *r*, *U* will be in row + # echelon form having *r* nonzero rows, and *L* will be lower + # triangular but truncated to *r* columns, having implicit ones on + # the *r* first entries of the main diagonal. All other entries will + # be zero. + # If a nonzero value for ``rank_check`` is passed, the function + # will abandon the output matrix in an undefined state and set + # the rank to 0 if *A* is detected to be rank-deficient. + # This currently only works as expected for square matrices. + # The algorithm can fail if it fails to certify that a pivot + # element is zero or nonzero, in which case the correct rank + # cannot be determined. It can also fail if a pivot element + # is not invertible. In these cases the ``GR_UNABLE`` and/or + # ``GR_DOMAIN`` flags will be returned. On failure, + # the data in the output variables + # ``rank``, ``P`` and ``LU`` will be meaningless. + # The *classical* version uses iterative Gaussian elimination. + # The *recursive* version uses a block recursive algorithm + # to take advantage of fast matrix multiplication. + + int gr_mat_fflu(long * rank, long * P, gr_mat_t LU, gr_ptr den, const gr_mat_t A, int rank_check, gr_ctx_t ctx) + # Similar to :func:`gr_mat_lu`, but computes a fraction-free + # LU decomposition using the Bareiss algorithm. + # The denominator is written to *den*. + + int gr_mat_nonsingular_solve_tril_classical(gr_mat_t X, const gr_mat_t L, const gr_mat_t B, int unit, gr_ctx_t ctx) + int gr_mat_nonsingular_solve_tril_recursive(gr_mat_t X, const gr_mat_t L, const gr_mat_t B, int unit, gr_ctx_t ctx) + int gr_mat_nonsingular_solve_tril(gr_mat_t X, const gr_mat_t L, const gr_mat_t B, int unit, gr_ctx_t ctx) + int gr_mat_nonsingular_solve_triu_classical(gr_mat_t X, const gr_mat_t U, const gr_mat_t B, int unit, gr_ctx_t ctx) + int gr_mat_nonsingular_solve_triu_recursive(gr_mat_t X, const gr_mat_t U, const gr_mat_t B, int unit, gr_ctx_t ctx) + int gr_mat_nonsingular_solve_triu(gr_mat_t X, const gr_mat_t U, const gr_mat_t B, int unit, gr_ctx_t ctx) + # Solves the lower triangular system `LX = B` or the upper triangular system + # `UX = B`, respectively. Division by the the diagonal entries must + # be possible; if not a division fails, ``GR_DOMAIN`` is returned + # even if the system is solvable. + # If *unit* is set, the main diagonal of *L* or *U* + # is taken to consist of all ones, and in that case the actual entries on + # the diagonal are not read at all and can contain other data. + # The *classical* versions perform the computations iteratively while the + # *recursive* versions perform the computations in a block recursive + # way to benefit from fast matrix multiplication. The default versions + # choose an algorithm automatically. + + int gr_mat_nonsingular_solve_fflu(gr_mat_t X, const gr_mat_t A, const gr_mat_t B, gr_ctx_t ctx) + int gr_mat_nonsingular_solve_lu(gr_mat_t X, const gr_mat_t A, const gr_mat_t B, gr_ctx_t ctx) + int gr_mat_nonsingular_solve(gr_mat_t X, const gr_mat_t A, const gr_mat_t B, gr_ctx_t ctx) + # Solves `AX = B`. If *A* is not invertible, + # returns ``GR_DOMAIN`` even if the system has a solution. + + int gr_mat_nonsingular_solve_fflu_precomp(gr_mat_t X, const long * perm, const gr_mat_t LU, const gr_mat_t B, gr_ctx_t ctx) + int gr_mat_nonsingular_solve_lu_precomp(gr_mat_t X, const long * perm, const gr_mat_t LU, const gr_mat_t B, gr_ctx_t ctx) + # Solves `AX = B` given a precomputed FFLU or LU factorization of *A*. + + int gr_mat_nonsingular_solve_den_fflu(gr_mat_t X, gr_ptr den, const gr_mat_t A, const gr_mat_t B, gr_ctx_t ctx) + int gr_mat_nonsingular_solve_den(gr_mat_t X, gr_ptr den, const gr_mat_t A, const gr_mat_t B, gr_ctx_t ctx) + # Solves `AX = B` over the fraction field of the present ring + # (assumed to be an integral domain), returning `X` with + # an implied denominator *den*. + # If *A* is not invertible over the fraction field, returns + # ``GR_DOMAIN`` even if the system has a solution. + + int gr_mat_solve_field(gr_mat_t X, const gr_mat_t A, const gr_mat_t B, gr_ctx_t ctx) + # Solves `AX = B` where *A* is not necessarily square and not necessarily + # invertible. Assuming that the ring is a field, a return value of + # ``GR_DOMAIN`` indicates that the system has no solution. + # If there are multiple solutions, an arbitrary solution is returned. + + int gr_mat_det_fflu(gr_ptr res, const gr_mat_t mat, gr_ctx_t ctx) + int gr_mat_det_berkowitz(gr_ptr res, const gr_mat_t mat, gr_ctx_t ctx) + int gr_mat_det_lu(gr_ptr res, const gr_mat_t mat, gr_ctx_t ctx) + int gr_mat_det_cofactor(gr_ptr res, const gr_mat_t mat, gr_ctx_t ctx) + int gr_mat_det_generic_field(gr_ptr res, const gr_mat_t A, gr_ctx_t ctx) + int gr_mat_det_generic_integral_domain(gr_ptr res, const gr_mat_t A, gr_ctx_t ctx) + int gr_mat_det_generic(gr_ptr res, const gr_mat_t A, gr_ctx_t ctx) + int gr_mat_det(gr_ptr res, const gr_mat_t mat, gr_ctx_t ctx) + # Sets *res* to the determinant of the square matrix *mat*. + # Various algorithms are available: + # * The *berkowitz* version uses the division-free Berkowitz algorithm + # performing `O(n^4)` operations. Since no zero tests are required, it + # is guaranteed to succeed if the ring arithmetic succeeds. + # * The *cofactor* version performs cofactor expansion. This is currently + # only supported for matrices up to size 4, and for larger + # matrices returns the ``GR_UNABLE`` flag. + # * The *lu* and *fflu* versions use rational LU decomposition + # and fraction-free LU decomposition (Bareiss algorithm) respectively, + # requiring `O(n^3)` operations. These algorithms can fail if zero + # certification or inversion fails, in which case the ``GR_UNABLE`` + # flag is returned. + # * The *generic*, *generic_field* and *generic_integral_domain* + # versions choose an appropriate algorithm for a generic ring + # depending on the availability of division. + # * The *default* method can be overloaded. + # If the matrix is not square, ``GR_DOMAIN`` is returned. + + int gr_mat_trace(gr_ptr res, const gr_mat_t mat, gr_ctx_t ctx) + # Sets *res* to the trace (sum of entries on the main diagonal) of + # the square matrix *mat*. + # If the matrix is not square, ``GR_DOMAIN`` is returned. + + int gr_mat_rank_fflu(long * rank, const gr_mat_t mat, gr_ctx_t ctx) + int gr_mat_rank_lu(long * rank, const gr_mat_t mat, gr_ctx_t ctx) + int gr_mat_rank(long * rank, const gr_mat_t mat, gr_ctx_t ctx) + # Sets *res* to the rank of *mat*. + # The default method returns ``GR_DOMAIN`` if the element ring + # is not an integral domain, in which case the usual rank is + # not well-defined. The *fflu* and *lu* variants currently do + # not check the element domain, and simply return this flag if they + # encounter an impossible inverse in the execution of the + # respective algorithms. + + int gr_mat_rref_lu(long * rank, gr_mat_t R, const gr_mat_t A, gr_ctx_t ctx) + int gr_mat_rref_fflu(long * rank, gr_mat_t R, const gr_mat_t A, gr_ctx_t ctx) + int gr_mat_rref(long * rank, gr_mat_t R, const gr_mat_t A, gr_ctx_t ctx) + # Sets *R* to the reduced row echelon form of *A*, also setting + # *rank* to its rank. + + int gr_mat_rref_den_fflu(long * rank, gr_mat_t R, gr_ptr den, const gr_mat_t A, gr_ctx_t ctx) + int gr_mat_rref_den(long * rank, gr_mat_t R, gr_ptr den, const gr_mat_t A, gr_ctx_t ctx) + # Like *rref*, but computes the reduced row echelon multiplied + # by a common (not necessarily minimal) denominator which is written + # to *den*. This can be used to compute the rref over an integral + # domain which is not a field. + + int gr_mat_nullspace(gr_mat_t X, const gr_mat_t A, gr_ctx_t ctx) + # Sets *X* to a basis for the (right) nullspace of *A*. + # On success, the output matrix will be resized to the correct + # number of columns. + # The basis is not guaranteed to be presented in a + # canonical or minimal form. + # If the ring is not a field, this is implied to compute a nullspace + # basis over the fraction field. The result may be meaningless + # if the ring is not an integral domain. + + int gr_mat_inv(gr_mat_t res, const gr_mat_t mat, gr_ctx_t ctx) + # Sets *res* to the inverse of *mat*, computed by solving + # `A A^{-1} = I`. + # Returns ``GR_DOMAIN`` if it can be determined that *mat* is not + # invertible over the present ring (warning: this may not work + # over non-integral domains). If invertibility cannot be proved, + # returns ``GR_UNABLE``. + # To compute the inverse over the fraction field, one may use + # :func:`gr_mat_nonsingular_solve_den` or :func:`gr_mat_adjugate`. + + int gr_mat_adjugate_charpoly(gr_mat_t adj, gr_ptr det, const gr_mat_t mat, gr_ctx_t ctx) + int gr_mat_adjugate_cofactor(gr_mat_t adj, gr_ptr det, const gr_mat_t mat, gr_ctx_t ctx) + int gr_mat_adjugate(gr_mat_t adj, gr_ptr det, const gr_mat_t mat, gr_ctx_t ctx) + # Sets *adj* to the adjugate matrix of *mat*, simultaneously + # setting *det* to the determinant of *mat*. We have + # `\operatorname{adj}(A) A = A \operatorname{adj}(A) = \det(A) I`, + # and `A^{-1} = \operatorname{adj}(A) / \det(A)` when *A* + # is invertible. + # The *cofactor* version uses cofactor expansion, requiring the + # evaluation of `n^2` determinants. + # The *charpoly* version computes and then evaluates the + # characteristic polynomial, requiring `O(n^{1/2})` + # matrix multiplications plus `O(n^3)` or `O(n^4)` operations + # for the characteristic polynomial itself depending on the + # algorithm used. + + int _gr_mat_charpoly(gr_ptr res, const gr_mat_t mat, gr_ctx_t ctx) + int gr_mat_charpoly(gr_poly_t res, const gr_mat_t mat, gr_ctx_t ctx) + # Computes the characteristic polynomial using a default + # algorithm choice. The + # underscore method assumes that *res* is a preallocated + # array of `n + 1` coefficients. + + int _gr_mat_charpoly_berkowitz(gr_ptr res, const gr_mat_t mat, gr_ctx_t ctx) + int gr_mat_charpoly_berkowitz(gr_poly_t res, const gr_mat_t mat, gr_ctx_t ctx) + # Sets *res* to the characteristic polynomial of the square matrix + # *mat*, computed using the division-free Berkowitz algorithm. + # The number of operations is `O(n^4)` where *n* is the + # size of the matrix. + + int _gr_mat_charpoly_danilevsky_inplace(gr_ptr res, gr_mat_t mat, gr_ctx_t ctx) + int _gr_mat_charpoly_danilevsky(gr_ptr res, const gr_mat_t mat, gr_ctx_t ctx) + int gr_mat_charpoly_danilevsky(gr_poly_t res, const gr_mat_t mat, gr_ctx_t ctx) + int _gr_mat_charpoly_gauss(gr_ptr res, const gr_mat_t mat, gr_ctx_t ctx) + int gr_mat_charpoly_gauss(gr_poly_t res, const gr_mat_t mat, gr_ctx_t ctx) + int _gr_mat_charpoly_householder(gr_ptr res, const gr_mat_t mat, gr_ctx_t ctx) + int gr_mat_charpoly_householder(gr_poly_t res, const gr_mat_t mat, gr_ctx_t ctx) + # Sets *res* to the characteristic polynomial of the square matrix + # *mat*, computed using the Danilevsky algorithm, + # Hessenberg reduction using Gaussian elimination, + # and Hessenberg reduction using Householder reflections. + # The number of operations of each method is `O(n^3)` where *n* is the + # size of the matrix. The *inplace* version overwrites the input matrix. + # These methods require divisions and can therefore fail when the + # ring is not a field. They also require zero tests. + # The *householder* version also requires square roots. + # The flags ``GR_UNABLE`` or ``GR_DOMAIN`` are returned when + # an impossible division or square root + # is encountered or when a comparison cannot be performed. + + int _gr_mat_charpoly_faddeev(gr_ptr res, gr_mat_t adj, const gr_mat_t mat, gr_ctx_t ctx) + int gr_mat_charpoly_faddeev(gr_poly_t res, gr_mat_t adj, const gr_mat_t mat, gr_ctx_t ctx) + int _gr_mat_charpoly_faddeev_bsgs(gr_ptr res, gr_mat_t adj, const gr_mat_t mat, gr_ctx_t ctx) + int gr_mat_charpoly_faddeev_bsgs(gr_poly_t res, gr_mat_t adj, const gr_mat_t mat, gr_ctx_t ctx) + # Sets *res* to the characteristic polynomial of the square matrix + # *mat*, computed using the Faddeev-LeVerrier algorithm. + # If the optional output argument *adj* is not *NULL*, it is + # set to the adjugate matrix, which is computed free of charge. + # The *bsgs* version uses a baby-step giant-step strategy, + # also known as the Preparata-Sarwate algorithm. + # This reduces the complexity from `O(n^4)` to `O(n^{3.5})` operations + # at the cost of requiring `n^{0.5}` temporary matrices to be + # stored. + # This method requires divisions by small integers and can + # therefore fail (returning the ``GR_UNABLE`` or ``GR_DOMAIN`` flags) + # in finite characteristic or when the underlying ring does + # not implement a division algorithm. + + int _gr_mat_charpoly_from_hessenberg(gr_ptr res, const gr_mat_t mat, gr_ctx_t ctx) + int gr_mat_charpoly_from_hessenberg(gr_poly_t res, const gr_mat_t mat, gr_ctx_t ctx) + # Sets *res* to the characteristic polynomial of the square matrix + # *mat*, which is assumed to be in Hessenberg form (this is + # currently not checked). + + int gr_mat_minpoly_field(gr_poly_t res, const gr_mat_t mat, gr_ctx_t ctx) + # Compute the minimal polynomial of the matrix *mat*. + # The algorithm assumes that the coefficient ring is a field. + + int gr_mat_apply_row_similarity(gr_mat_t M, long r, gr_ptr d, gr_ctx_t ctx) + # Applies an elementary similarity transform to the `n\times n` matrix `M` + # in-place. + # If `P` is the `n\times n` identity matrix the zero entries of whose row + # `r` (`0`-indexed) have been replaced by `d`, this transform is equivalent + # to `M = P^{-1}MP`. + # Similarity transforms preserve the determinant, characteristic polynomial + # and minimal polynomial. + + int gr_mat_eigenvalues(gr_vec_t lmbda, gr_vec_t mult, const gr_mat_t mat, int flags, gr_ctx_t ctx) + int gr_mat_eigenvalues_other(gr_vec_t lmbda, gr_vec_t mult, const gr_mat_t mat, gr_ctx_t mat_ctx, int flags, gr_ctx_t ctx) + # Finds all eigenvalues of the given matrix in the ring defined by *ctx*, + # storing the eigenvalues without duplication in *lambda* (a vector with + # elements of type ``ctx``) and the corresponding multiplicities in + # *mult* (a vector with elements of type ``fmpz``). + # The interface is essentially the same as that of + # :func:`gr_poly_roots`; see its documentation for details. + + int gr_mat_diagonalization_precomp(gr_vec_t D, gr_mat_t L, gr_mat_t R, const gr_mat_t A, const gr_vec_t eigenvalues, const gr_vec_t mult, gr_ctx_t ctx) + int gr_mat_diagonalization_generic(gr_vec_t D, gr_mat_t L, gr_mat_t R, const gr_mat_t A, int flags, gr_ctx_t ctx) + int gr_mat_diagonalization(gr_vec_t D, gr_mat_t L, gr_mat_t R, const gr_mat_t A, int flags, gr_ctx_t ctx) + # Computes a diagonalization `LAR = D` given a square matrix `A`, + # where `D` is a diagonal matrix (returned as a vector) of the eigenvalues + # repeated according to their multiplicities, + # `L` is a matrix of left eigenvectors, + # and `R` is a matrix of right eigenvectors, + # normalized such that `L = R^{-1}`. + # This implies that `A = RDL = RDR^{-1}`. + # Either `L` or `R` (or both) can be set to ``NULL`` to omit computing + # the respective matrix. + # If the matrix has entries in a field then a return flag + # of ``GR_DOMAIN`` indicates that the matrix is non-diagonalizable + # over this field. + # The *precomp* version requires as input a precomputed set of eigenvalues + # with corresponding multiplicities, which can be computed + # with :func:`gr_mat_eigenvalues`. + + int gr_mat_set_jordan_blocks(gr_mat_t mat, const gr_vec_t lmbda, long num_blocks, long * block_lambda, long * block_size, gr_ctx_t ctx) + int gr_mat_jordan_blocks(gr_vec_t lmbda, long * num_blocks, long * block_lambda, long * block_size, const gr_mat_t A, gr_ctx_t ctx) + int gr_mat_jordan_transformation(gr_mat_t mat, const gr_vec_t lmbda, long num_blocks, long * block_lambda, long * block_size, const gr_mat_t A, gr_ctx_t ctx) + int gr_mat_jordan_form(gr_mat_t J, gr_mat_t P, const gr_mat_t A, gr_ctx_t ctx) + + int gr_mat_exp_jordan(gr_mat_t res, const gr_mat_t A, gr_ctx_t ctx) + int gr_mat_exp(gr_mat_t res, const gr_mat_t A, gr_ctx_t ctx) + + int gr_mat_log_jordan(gr_mat_t res, const gr_mat_t A, gr_ctx_t ctx) + int gr_mat_log(gr_mat_t res, const gr_mat_t A, gr_ctx_t ctx) + + truth_t gr_mat_is_hessenberg(const gr_mat_t mat, gr_ctx_t ctx) + # Returns whether *mat* is in upper Hessenberg form. + + int gr_mat_hessenberg_gauss(gr_mat_t res, const gr_mat_t mat, gr_ctx_t ctx) + int gr_mat_hessenberg_householder(gr_mat_t res, const gr_mat_t mat, gr_ctx_t ctx) + int gr_mat_hessenberg(gr_mat_t res, const gr_mat_t mat, gr_ctx_t ctx) + # Sets *res* to an upper Hessenberg form of *mat*. + # The *gauss* version uses Gaussian elimination. + # The *householder* version uses Householder reflections. + # These methods require divisions and zero testing + # and can therefore fail (returning ``GR_UNABLE`` or ``GR_DOMAIN``) + # when the ring is not a field. + # The *householder* version additionally requires complex + # conjugation and the ability to compute square roots. + + int gr_mat_randtest(gr_mat_t res, flint_rand_t state, gr_ctx_t ctx) + # Sets *res* to a random matrix. The distribution is nonuniform. + + int gr_mat_randops(gr_mat_t mat, flint_rand_t state, long count, gr_ctx_t ctx) + # Randomises *mat* in-place by performing elementary row or column + # operations. More precisely, at most *count* random additions or + # subtractions of distinct rows and columns will be performed. + + int gr_mat_randpermdiag(int * parity, gr_mat_t mat, flint_rand_t state, gr_ptr diag, long n, gr_ctx_t ctx) + # Sets mat to a random permutation of the diagonal matrix with *n* leading entries given by + # the vector ``diag``. Returns ``GR_DOMAIN`` if the main diagonal of ``mat`` + # does not have room for at least *n* entries. + # The parity (0 or 1) of the permutation is written to ``parity``. + + int gr_mat_randrank(gr_mat_t mat, flint_rand_t state, long rank, gr_ctx_t ctx) + # Sets ``mat`` to a random sparse matrix with the given rank, having exactly as many + # non-zero elements as the rank. The matrix can be transformed into a dense matrix + # with unchanged rank by subsequently calling :func:`gr_mat_randops`. + # This operation only makes sense over integral domains (currently not checked). + + int gr_mat_ones(gr_mat_t res, gr_ctx_t ctx) + # Sets all entries in *res* to one. + + int gr_mat_pascal(gr_mat_t res, int triangular, gr_ctx_t ctx) + # Sets *res* to a Pascal matrix, whose entries are binomial coefficients. + # If *triangular* is 0, constructs a full symmetric matrix + # with the rows of Pascal's triangle as successive antidiagonals. + # If *triangular* is 1, constructs the upper triangular matrix with + # the rows of Pascal's triangle as columns, and if *triangular* is -1, + # constructs the lower triangular matrix with the rows of Pascal's + # triangle as rows. + + int gr_mat_stirling(gr_mat_t res, int kind, gr_ctx_t ctx) + # Sets *res* to a Stirling matrix, whose entries are Stirling numbers. + # If *kind* is 0, the entries are set to the unsigned Stirling numbers + # of the first kind. If *kind* is 1, the entries are set to the signed + # Stirling numbers of the first kind. If *kind* is 2, the entries are + # set to the Stirling numbers of the second kind. + + int gr_mat_hilbert(gr_mat_t res, gr_ctx_t ctx) + # Sets *res* to the Hilbert matrix, which has entries `1/(i+j+1)` + # for `i, j \ge 0`. + + int gr_mat_hadamard(gr_mat_t res, gr_ctx_t ctx) + # If possible, sets *res* to a Hadamard matrix of the provided size + # and returns ``GR_SUCCESS``. Returns ``GR_DOMAIN`` + # if no Hadamard matrix of the given size exists, + # and ``GR_UNABLE`` if the implementation does + # not know how to construct a Hadamard matrix of the given + # size. + # A Hadamard matrix of size *n* can only exist if *n* is 0, 1, 2, + # or a multiple of 4. It is not known whether a + # Hadamard matrix exists for every size that is a multiple of 4. + # This function uses the Paley construction, which + # succeeds for all *n* of the form `n = 2^e` or `n = 2^e (q + 1)` where + # *q* is an odd prime power. Orders *n* for which Hadamard matrices are + # known to exist but for which this construction fails are + # 92, 116, 156, ... (OEIS A046116). + + int gr_mat_reduce_row(long * column, gr_mat_t A, long * P, long * L, long m, gr_ctx_t ctx) + # Reduce row n of the matrix `A`, assuming the prior rows are in Gauss + # form. However those rows may not be in order. The entry `i` of the array + # `P` is the row of `A` which has a pivot in the `i`-th column. If no such + # row exists, the entry of `P` will be `-1`. The function sets *column* to the column + # in which the `n`-th row has a pivot after reduction. This will always be + # chosen to be the first available column for a pivot from the left. This + # information is also updated in `P`. Entry `i` of the array `L` contains the + # number of possibly nonzero columns of `A` row `i`. This speeds up reduction + # in the case that `A` is chambered on the right. Otherwise the entries of + # `L` can all be set to the number of columns of `A`. We require the entries + # of `L` to be monotonic increasing. diff --git a/src/sage/libs/flint/gr_mpoly.pxd b/src/sage/libs/flint/gr_mpoly.pxd new file mode 100644 index 00000000000..eb9741016b0 --- /dev/null +++ b/src/sage/libs/flint/gr_mpoly.pxd @@ -0,0 +1,124 @@ +# distutils: libraries = flint +# distutils: depends = flint/gr_mpoly.h + +################################################################################ +# This file is auto-generated. Do not modify by hand +################################################################################ + +from libc.stdio cimport FILE +from sage.libs.gmp.types cimport * +from sage.libs.mpfr.types cimport * +from sage.libs.flint.types cimport * + +cdef extern from "flint_wrap.h": + + void gr_mpoly_init(gr_mpoly_t A, const mpoly_ctx_t mctx, gr_ctx_t cctx) + # Initializes and sets *A* to the zero polynomial. + + void gr_mpoly_init3(gr_mpoly_t A, long alloc, flint_bitcnt_t bits, const mpoly_ctx_t mctx, gr_ctx_t cctx) + void gr_mpoly_init2(gr_mpoly_t A, long alloc, const mpoly_ctx_t mctx, gr_ctx_t cctx) + # Initializes *A* with space allocated for the given number + # of coefficients and exponents with the given number of bits. + + void gr_mpoly_clear(gr_mpoly_t A, const mpoly_ctx_t mctx, gr_ctx_t cctx) + # Clears *A*, freeing all allocated data. + + void gr_mpoly_swap(gr_mpoly_t A, gr_mpoly_t B, const mpoly_ctx_t mctx, gr_ctx_t cctx) + # Swaps *A* and *B* efficiently. + + int gr_mpoly_set(gr_mpoly_t A, const gr_mpoly_t B, const mpoly_ctx_t mctx, gr_ctx_t cctx) + # Sets *A* to *B*. + + int gr_mpoly_zero(gr_mpoly_t A, const mpoly_ctx_t mctx, gr_ctx_t cctx) + # Sets *A* to the zero polynomial. + + truth_t gr_mpoly_is_zero(const gr_mpoly_t A, const mpoly_ctx_t mctx, gr_ctx_t cctx) + # Returns whether *A* is the zero polynomial. + + int gr_mpoly_gen(gr_mpoly_t A, long var, const mpoly_ctx_t mctx, gr_ctx_t cctx) + # Sets *A* to the generator with index *var* (indexed from zero). + + truth_t gr_mpoly_is_gen(const gr_mpoly_t A, long var, const mpoly_ctx_t mctx, gr_ctx_t cctx) + # Returns whether *A* is the generator with index *var* (indexed from zero). + + truth_t gr_mpoly_equal(const gr_mpoly_t A, const gr_mpoly_t B, const mpoly_ctx_t mctx, gr_ctx_t cctx) + # Returns whether *A* and *B* are equal. + + int gr_mpoly_randtest_bits(gr_mpoly_t A, flint_rand_t state, long length, flint_bitcnt_t exp_bits, const mpoly_ctx_t mctx, gr_ctx_t cctx) + # Sets *A* to a random polynomial with up to *length* terms + # and up to *exp_bits* bits in the exponents. + + int gr_mpoly_write_pretty(gr_stream_t out, const gr_mpoly_t A, const char ** x, const mpoly_ctx_t mctx, gr_ctx_t cctx) + int gr_mpoly_print_pretty(const gr_mpoly_t A, const char ** x, const mpoly_ctx_t mctx, gr_ctx_t cctx) + # Prints *A* using the strings in *x* for the variables. + # If *x* is *NULL*, defaults are used. + + int gr_mpoly_get_coeff_scalar_fmpz(gr_ptr c, const gr_mpoly_t A, const fmpz * exp, const mpoly_ctx_t mctx, gr_ctx_t cctx) + int gr_mpoly_get_coeff_scalar_ui(gr_ptr c, const gr_mpoly_t A, const unsigned long * exp, const mpoly_ctx_t mctx, gr_ctx_t cctx) + # Sets *c* to the coefficient in *A* with exponents *exp*. + + int gr_mpoly_set_coeff_scalar_fmpz(gr_mpoly_t A, gr_srcptr c, const fmpz * exp, const mpoly_ctx_t mctx, gr_ctx_t cctx) + int gr_mpoly_set_coeff_ui_fmpz(gr_mpoly_t A, unsigned long c, const fmpz * exp, const mpoly_ctx_t mctx, gr_ctx_t cctx) + int gr_mpoly_set_coeff_si_fmpz(gr_mpoly_t A, long c, const fmpz * exp, const mpoly_ctx_t mctx, gr_ctx_t cctx) + int gr_mpoly_set_coeff_fmpz_fmpz(gr_mpoly_t A, const fmpz_t c, const fmpz * exp, const mpoly_ctx_t mctx, gr_ctx_t cctx) + int gr_mpoly_set_coeff_fmpq_fmpz(gr_mpoly_t A, const fmpq_t c, const fmpz * exp, const mpoly_ctx_t mctx, gr_ctx_t cctx) + + int gr_mpoly_set_coeff_scalar_ui(gr_mpoly_t poly, gr_srcptr c, const unsigned long * exp, const mpoly_ctx_t mctx, gr_ctx_t cctx) + int gr_mpoly_set_coeff_ui_ui(gr_mpoly_t A, unsigned long c, const unsigned long * exp, const mpoly_ctx_t mctx, gr_ctx_t cctx) + int gr_mpoly_set_coeff_si_ui(gr_mpoly_t A, long c, const unsigned long * exp, const mpoly_ctx_t mctx, gr_ctx_t cctx) + int gr_mpoly_set_coeff_fmpz_ui(gr_mpoly_t A, const fmpz_t c, const unsigned long * exp, const mpoly_ctx_t mctx, gr_ctx_t cctx) + int gr_mpoly_set_coeff_fmpq_ui(gr_mpoly_t A, const fmpq_t c, const unsigned long * exp, const mpoly_ctx_t mctx, gr_ctx_t cctx) + # Sets the coefficient with exponents *exp* in *A* to the scalar *c* + # which must be an element of or coercible to the coefficient ring. + + int gr_mpoly_neg(gr_mpoly_t A, const gr_mpoly_t B, const mpoly_ctx_t mctx, gr_ctx_t cctx) + # Sets *A* to the negation of *B*. + + int gr_mpoly_add(gr_mpoly_t A, const gr_mpoly_t B, const gr_mpoly_t C, const mpoly_ctx_t mctx, gr_ctx_t cctx) + # Sets *A* to the difference of *B* and *C*. + + int gr_mpoly_sub(gr_mpoly_t A, const gr_mpoly_t B, const gr_mpoly_t C, const mpoly_ctx_t mctx, gr_ctx_t cctx) + # Sets *A* to the difference of *B* and *C*. + + int gr_mpoly_mul(gr_mpoly_t A, const gr_mpoly_t B, const gr_mpoly_t C, const mpoly_ctx_t mctx, gr_ctx_t cctx) + int gr_mpoly_mul_johnson(gr_mpoly_t A, const gr_mpoly_t B, const gr_mpoly_t C, const mpoly_ctx_t mctx, gr_ctx_t cctx) + int gr_mpoly_mul_monomial(gr_mpoly_t A, const gr_mpoly_t B, const gr_mpoly_t C, const mpoly_ctx_t mctx, gr_ctx_t cctx) + # Sets *A* to the product of *B* and *C*. + # The *monomial* version assumes that *C* is a monomial. + + int gr_mpoly_mul_scalar(gr_mpoly_t A, const gr_mpoly_t B, gr_srcptr c, const mpoly_ctx_t mctx, gr_ctx_t cctx) + int gr_mpoly_mul_si(gr_mpoly_t A, const gr_mpoly_t B, long c, const mpoly_ctx_t mctx, gr_ctx_t cctx) + int gr_mpoly_mul_ui(gr_mpoly_t A, const gr_mpoly_t B, unsigned long c, const mpoly_ctx_t mctx, gr_ctx_t cctx) + int gr_mpoly_mul_fmpz(gr_mpoly_t A, const gr_mpoly_t B, const fmpz_t c, const mpoly_ctx_t mctx, gr_ctx_t cctx) + int gr_mpoly_mul_fmpq(gr_mpoly_t A, const gr_mpoly_t B, const fmpq_t c, const mpoly_ctx_t mctx, gr_ctx_t cctx) + # Sets *A* to *B* multiplied by the scalar *c* which must be + # an element of or coercible to the coefficient ring. + + void _gr_mpoly_fit_length(gr_ptr * coeffs, long * coeffs_alloc, unsigned long ** exps, long * exps_alloc, long N, long length, gr_ctx_t cctx) + + void gr_mpoly_fit_length(gr_mpoly_t A, long len, const mpoly_ctx_t mctx, gr_ctx_t cctx) + # Ensures that *A* has space for *len* coefficients and exponents. + + void gr_mpoly_fit_bits(gr_mpoly_t A, flint_bitcnt_t bits, const mpoly_ctx_t mctx, gr_ctx_t cctx) + + void gr_mpoly_fit_length_fit_bits(gr_mpoly_t A, long len, flint_bitcnt_t bits, const mpoly_ctx_t mctx, gr_ctx_t cctx) + + void gr_mpoly_fit_length_reset_bits(gr_mpoly_t A, long len, flint_bitcnt_t bits, const mpoly_ctx_t mctx, gr_ctx_t cctx) + + void _gr_mpoly_set_length(gr_mpoly_t A, long newlen, const mpoly_ctx_t mctx, gr_ctx_t cctx) + + void _gr_mpoly_push_exp_ui(gr_mpoly_t A, const unsigned long * exp, const mpoly_ctx_t mctx, gr_ctx_t cctx) + + int gr_mpoly_push_term_scalar_ui(gr_mpoly_t A, gr_srcptr c, const unsigned long * exp, const mpoly_ctx_t mctx, gr_ctx_t cctx) + + void _gr_mpoly_push_exp_fmpz(gr_mpoly_t A, const fmpz * exp, const mpoly_ctx_t mctx, gr_ctx_t cctx) + + int gr_mpoly_push_term_scalar_fmpz(gr_mpoly_t A, gr_srcptr c, const fmpz * exp, const mpoly_ctx_t mctx, gr_ctx_t cctx) + + void gr_mpoly_sort_terms(gr_mpoly_t A, const mpoly_ctx_t mctx, gr_ctx_t cctx) + + int gr_mpoly_combine_like_terms(gr_mpoly_t A, const mpoly_ctx_t mctx, gr_ctx_t cctx) + + truth_t gr_mpoly_is_canonical(const gr_mpoly_t A, const mpoly_ctx_t mctx, gr_ctx_t cctx) + + void gr_mpoly_assert_canonical(const gr_mpoly_t A, const mpoly_ctx_t mctx, gr_ctx_t cctx) diff --git a/src/sage/libs/flint/gr_poly.pxd b/src/sage/libs/flint/gr_poly.pxd new file mode 100644 index 00000000000..632363b7146 --- /dev/null +++ b/src/sage/libs/flint/gr_poly.pxd @@ -0,0 +1,472 @@ +# distutils: libraries = flint +# distutils: depends = flint/gr_poly.h + +################################################################################ +# This file is auto-generated. Do not modify by hand +################################################################################ + +from libc.stdio cimport FILE +from sage.libs.gmp.types cimport * +from sage.libs.mpfr.types cimport * +from sage.libs.flint.types cimport * + +cdef extern from "flint_wrap.h": + + void gr_poly_init(gr_poly_t poly, gr_ctx_t ctx) + + void gr_poly_init2(gr_poly_t poly, long len, gr_ctx_t ctx) + + void gr_poly_clear(gr_poly_t poly, gr_ctx_t ctx) + + gr_ptr gr_poly_entry_ptr(gr_poly_t poly, long i, gr_ctx_t ctx) + + long gr_poly_length(const gr_poly_t poly, gr_ctx_t ctx) + + void gr_poly_swap(gr_poly_t poly1, gr_poly_t poly2, gr_ctx_t ctx) + + void gr_poly_fit_length(gr_poly_t poly, long len, gr_ctx_t ctx) + + void _gr_poly_set_length(gr_poly_t poly, long len, gr_ctx_t ctx) + + void _gr_poly_normalise(gr_poly_t poly, gr_ctx_t ctx) + + int gr_poly_set(gr_poly_t res, const gr_poly_t src, gr_ctx_t ctx) + int gr_poly_get_fmpz_poly(gr_poly_t res, const fmpz_poly_t src, gr_ctx_t ctx) + int gr_poly_set_fmpq_poly(gr_poly_t res, const fmpq_poly_t src, gr_ctx_t ctx) + int gr_poly_set_gr_poly_other(gr_poly_t res, const gr_poly_t x, gr_ctx_t x_ctx, gr_ctx_t ctx) + + int _gr_poly_reverse(gr_ptr res, gr_srcptr poly, long len, long n, gr_ctx_t ctx) + int gr_poly_reverse(gr_poly_t res, const gr_poly_t poly, long n, gr_ctx_t ctx) + + int gr_poly_truncate(gr_poly_t res, const gr_poly_t poly, long newlen, gr_ctx_t ctx) + + int gr_poly_zero(gr_poly_t poly, gr_ctx_t ctx) + int gr_poly_one(gr_poly_t poly, gr_ctx_t ctx) + int gr_poly_neg_one(gr_poly_t poly, gr_ctx_t ctx) + int gr_poly_gen(gr_poly_t poly, gr_ctx_t ctx) + + int gr_poly_write(gr_stream_t out, const gr_poly_t poly, const char * x, gr_ctx_t ctx) + int gr_poly_print(const gr_poly_t poly, gr_ctx_t ctx) + + int gr_poly_randtest(gr_poly_t poly, flint_rand_t state, long len, gr_ctx_t ctx) + + truth_t _gr_poly_equal(gr_srcptr poly1, long len1, gr_srcptr poly2, long len2, gr_ctx_t ctx) + truth_t gr_poly_equal(const gr_poly_t poly1, const gr_poly_t poly2, gr_ctx_t ctx) + + truth_t gr_poly_is_zero(const gr_poly_t poly, gr_ctx_t ctx) + truth_t gr_poly_is_one(const gr_poly_t poly, gr_ctx_t ctx) + truth_t gr_poly_is_gen(const gr_poly_t poly, gr_ctx_t ctx) + truth_t gr_poly_is_scalar(const gr_poly_t poly, gr_ctx_t ctx) + + int gr_poly_set_scalar(gr_poly_t poly, gr_srcptr c, gr_ctx_t ctx) + int gr_poly_set_si(gr_poly_t poly, long c, gr_ctx_t ctx) + int gr_poly_set_ui(gr_poly_t poly, unsigned long c, gr_ctx_t ctx) + int gr_poly_set_fmpz(gr_poly_t poly, const fmpz_t c, gr_ctx_t ctx) + int gr_poly_set_fmpq(gr_poly_t poly, const fmpq_t c, gr_ctx_t ctx) + + int gr_poly_set_coeff_scalar(gr_poly_t poly, long n, gr_srcptr c, gr_ctx_t ctx) + int gr_poly_set_coeff_si(gr_poly_t poly, long n, long c, gr_ctx_t ctx) + int gr_poly_set_coeff_ui(gr_poly_t poly, long n, unsigned long c, gr_ctx_t ctx) + int gr_poly_set_coeff_fmpz(gr_poly_t poly, long n, const fmpz_t c, gr_ctx_t ctx) + int gr_poly_set_coeff_fmpq(gr_poly_t poly, long n, const fmpq_t c, gr_ctx_t ctx) + + int gr_poly_get_coeff_scalar(gr_ptr res, const gr_poly_t poly, long n, gr_ctx_t ctx) + + int gr_poly_neg(gr_poly_t res, const gr_poly_t src, gr_ctx_t ctx) + + int _gr_poly_add(gr_ptr res, gr_srcptr poly1, long len1, gr_srcptr poly2, long len2, gr_ctx_t ctx) + int gr_poly_add(gr_poly_t res, const gr_poly_t poly1, const gr_poly_t poly2, gr_ctx_t ctx) + + int _gr_poly_sub(gr_ptr res, gr_srcptr poly1, long len1, gr_srcptr poly2, long len2, gr_ctx_t ctx) + int gr_poly_sub(gr_poly_t res, const gr_poly_t poly1, const gr_poly_t poly2, gr_ctx_t ctx) + + int _gr_poly_mul(gr_ptr res, gr_srcptr poly1, long len1, gr_srcptr poly2, long len2, gr_ctx_t ctx) + int gr_poly_mul(gr_poly_t res, const gr_poly_t poly1, const gr_poly_t poly2, gr_ctx_t ctx) + + int _gr_poly_mullow_generic(gr_ptr res, gr_srcptr poly1, long len1, gr_srcptr poly2, long len2, long len, gr_ctx_t ctx) + int _gr_poly_mullow(gr_ptr res, gr_srcptr poly1, long len1, gr_srcptr poly2, long len2, long len, gr_ctx_t ctx) + int gr_poly_mullow(gr_poly_t res, const gr_poly_t poly1, const gr_poly_t poly2, long len, gr_ctx_t ctx) + + int gr_poly_mul_scalar(gr_poly_t res, const gr_poly_t poly, gr_srcptr c, gr_ctx_t ctx) + + int _gr_poly_pow_series_ui_binexp(gr_ptr res, gr_srcptr f, long flen, unsigned long exp, long len, gr_ctx_t ctx) + int gr_poly_pow_series_ui_binexp(gr_poly_t res, const gr_poly_t poly, unsigned long exp, long len, gr_ctx_t ctx) + + int _gr_poly_pow_series_ui(gr_ptr res, gr_srcptr f, long flen, unsigned long exp, long len, gr_ctx_t ctx) + int gr_poly_pow_series_ui(gr_poly_t res, const gr_poly_t poly, unsigned long exp, long len, gr_ctx_t ctx) + + int _gr_poly_pow_ui_binexp(gr_ptr res, gr_srcptr f, long flen, unsigned long exp, gr_ctx_t ctx) + int gr_poly_pow_ui_binexp(gr_poly_t res, const gr_poly_t poly, unsigned long exp, gr_ctx_t ctx) + + int _gr_poly_pow_ui(gr_ptr res, gr_srcptr f, long flen, unsigned long exp, gr_ctx_t ctx) + int gr_poly_pow_ui(gr_poly_t res, const gr_poly_t poly, unsigned long exp, gr_ctx_t ctx) + + int gr_poly_pow_fmpz(gr_poly_t res, const gr_poly_t poly, const fmpz_t exp, gr_ctx_t ctx) + + int _gr_poly_pow_series_fmpq_recurrence(gr_ptr h, gr_srcptr f, long flen, const fmpq_t exp, long len, int precomp, gr_ctx_t ctx) + int gr_poly_pow_series_fmpq_recurrence(gr_poly_t res, const gr_poly_t poly, const fmpq_t exp, long len, gr_ctx_t ctx) + + int _gr_poly_shift_left(gr_ptr res, gr_srcptr poly, long len, long n, gr_ctx_t ctx) + int gr_poly_shift_left(gr_poly_t res, const gr_poly_t poly, long n, gr_ctx_t ctx) + + int _gr_poly_shift_right(gr_ptr res, gr_srcptr poly, long len, long n, gr_ctx_t ctx) + int gr_poly_shift_right(gr_poly_t res, const gr_poly_t poly, long n, gr_ctx_t ctx) + + int _gr_poly_divrem_divconquer_preinv1(gr_ptr Q, gr_ptr R, gr_srcptr A, long lenA, gr_srcptr B, long lenB, gr_srcptr invB, long cutoff, gr_ctx_t ctx) + int _gr_poly_divrem_divconquer_noinv(gr_ptr Q, gr_ptr R, gr_srcptr A, long lenA, gr_srcptr B, long lenB, long cutoff, gr_ctx_t ctx) + int _gr_poly_divrem_divconquer(gr_ptr Q, gr_ptr R, gr_srcptr A, long lenA, gr_srcptr B, long lenB, long cutoff, gr_ctx_t ctx) + int gr_poly_divrem_divconquer(gr_poly_t Q, gr_poly_t R, const gr_poly_t A, const gr_poly_t B, long cutoff, gr_ctx_t ctx) + int _gr_poly_divrem_basecase_preinv1(gr_ptr Q, gr_ptr R, gr_srcptr A, long lenA, gr_srcptr B, long lenB, gr_srcptr invB, gr_ctx_t ctx) + int _gr_poly_divrem_basecase_noinv(gr_ptr Q, gr_ptr R, gr_srcptr A, long lenA, gr_srcptr B, long lenB, gr_ctx_t ctx) + int _gr_poly_divrem_basecase(gr_ptr Q, gr_ptr R, gr_srcptr A, long lenA, gr_srcptr B, long lenB, gr_ctx_t ctx) + int gr_poly_divrem_basecase(gr_poly_t Q, gr_poly_t R, const gr_poly_t A, const gr_poly_t B, gr_ctx_t ctx) + int _gr_poly_divrem_newton(gr_ptr Q, gr_ptr R, gr_srcptr A, long lenA, gr_srcptr B, long lenB, gr_ctx_t ctx) + int gr_poly_divrem_newton(gr_poly_t Q, gr_poly_t R, const gr_poly_t A, const gr_poly_t B, gr_ctx_t ctx) + int _gr_poly_divrem(gr_ptr Q, gr_ptr R, gr_srcptr A, long lenA, gr_srcptr B, long lenB, gr_ctx_t ctx) + int gr_poly_divrem(gr_poly_t Q, gr_poly_t R, const gr_poly_t A, const gr_poly_t B, gr_ctx_t ctx) + # These functions implement Euclidean division with remainder: + # given polynomials `A, B \in K[x]` where `K` is a field, with `B \ne 0`, + # there is a unique quotient `Q` and remainder `R` such that `A = BQ + R` + # and either `R = 0` or `\deg(R) < \deg(B)`. + # If *B* is provably zero, ``GR_DOMAIN`` is returned. + # When `K` is a commutative ring and `\operatorname{lc}(B)` is a unit in `K`, + # the situation is the same as over fields. In particular, Euclidean division + # with remainder always makes sense over commutative rings when `B` is monic. + # If `\operatorname{lc}(B)` is not a unit, the division still makes sense if + # the coefficient quotient `\operatorname{lc}(r)` / `\operatorname{lc}(B)` + # exists for each partial remainder `r`. Indeed, + # the *basecase* and *divconquer* algorithms return ``GR_DOMAIN`` precisely when + # encountering a leading quotient `\operatorname{lc}(r)` / `\operatorname{lc}(B) \not \in K`. + # However, the *newton* algorithm as currently implemented + # returns ``GR_DOMAIN`` when `\operatorname{lc}(B)^{-1} \not \in K`. + # The underscore methods make the following assumptions: + # * *Q* has room for ``lenA - lenB + 1`` coefficients. + # * *R* has room for ``lenB - 1`` coefficients. + # * ``lenA >= lenB >= 1``. + # * *Q* is not aliased with either *A* or *B*. + # * *R* is not aliased with *B*. + # * *R* may be aliased with *A*, in which case all ``lenA`` + # entries may be used as scratch space. Note that in this case, + # only the low ``lenB - 1`` coefficients of *R* actually represent + # valid coefficients on output: the higher scratch coefficients will not + # necessarily be zeroed. + # * The divisor *B* is normalized to have nonzero leading coefficient. + # (The non-underscore methods check for leading coefficients that + # are not provably nonzero and return ``GR_UNABLE``.) + # The *preinv1* functions take a precomputed inverse of the + # leading coefficient as input. + # The *noinv* versions perform repeated checked divisions + # by the leading coefficient. + + int _gr_poly_div_divconquer_preinv1(gr_ptr Q, gr_srcptr A, long lenA, gr_srcptr B, long lenB, gr_srcptr invB, long cutoff, gr_ctx_t ctx) + int _gr_poly_div_divconquer_noinv(gr_ptr Q, gr_srcptr A, long lenA, gr_srcptr B, long lenB, long cutoff, gr_ctx_t ctx) + int _gr_poly_div_divconquer(gr_ptr Q, gr_srcptr A, long lenA, gr_srcptr B, long lenB, long cutoff, gr_ctx_t ctx) + int gr_poly_div_divconquer(gr_poly_t Q, const gr_poly_t A, const gr_poly_t B, long cutoff, gr_ctx_t ctx) + int _gr_poly_div_basecase_preinv1(gr_ptr Q, gr_srcptr A, long lenA, gr_srcptr B, long lenB, gr_srcptr invB, gr_ctx_t ctx) + int _gr_poly_div_basecase_noinv(gr_ptr Q, gr_srcptr A, long lenA, gr_srcptr B, long lenB, gr_ctx_t ctx) + int _gr_poly_div_basecase(gr_ptr Q, gr_srcptr A, long lenA, gr_srcptr B, long lenB, gr_ctx_t ctx) + int gr_poly_div_basecase(gr_poly_t Q, const gr_poly_t A, const gr_poly_t B, gr_ctx_t ctx) + int _gr_poly_div_newton(gr_ptr Q, gr_srcptr A, long lenA, gr_srcptr B, long lenB, gr_ctx_t ctx) + int gr_poly_div_newton(gr_poly_t Q, const gr_poly_t A, const gr_poly_t B, gr_ctx_t ctx) + int _gr_poly_div(gr_ptr Q, gr_srcptr A, long lenA, gr_srcptr B, long lenB, gr_ctx_t ctx) + int gr_poly_div(gr_poly_t Q, const gr_poly_t A, const gr_poly_t B, gr_ctx_t ctx) + # Versions of the *divrem* functions which output only the quotient. + # These are generally faster. + + int _gr_poly_rem(gr_ptr R, gr_srcptr A, long lenA, gr_srcptr B, long lenB, gr_ctx_t ctx) + int gr_poly_rem(gr_poly_t R, const gr_poly_t A, const gr_poly_t B, gr_ctx_t ctx) + # Versions of the *divrem* functions which output only the remainder. + + int _gr_poly_inv_series_newton(gr_ptr res, gr_srcptr A, long Alen, long len, long cutoff, gr_ctx_t ctx) + int gr_poly_inv_series_newton(gr_poly_t res, const gr_poly_t A, long len, long cutoff, gr_ctx_t ctx) + int _gr_poly_inv_series_basecase_preinv1(gr_ptr res, gr_srcptr A, long Alen, gr_srcptr Ainv, long len, gr_ctx_t ctx) + int _gr_poly_inv_series_basecase(gr_ptr res, gr_srcptr A, long Alen, long len, gr_ctx_t ctx) + int gr_poly_inv_series_basecase(gr_poly_t res, const gr_poly_t A, long len, gr_ctx_t ctx) + int _gr_poly_inv_series(gr_ptr res, gr_srcptr A, long Alen, long len, gr_ctx_t ctx) + int gr_poly_inv_series(gr_poly_t res, const gr_poly_t A, long len, gr_ctx_t ctx) + + int _gr_poly_div_series_newton(gr_ptr res, gr_srcptr A, long Alen, gr_srcptr B, long Blen, long len, long cutoff, gr_ctx_t ctx) + int gr_poly_div_series_newton(gr_poly_t res, const gr_poly_t A, const gr_poly_t B, long len, long cutoff, gr_ctx_t ctx) + int _gr_poly_div_series_divconquer(gr_ptr res, gr_srcptr B, long Blen, gr_srcptr A, long Alen, long len, long cutoff, gr_ctx_t ctx) + int gr_poly_div_series_divconquer(gr_poly_t Q, const gr_poly_t A, const gr_poly_t B, long len, long cutoff, gr_ctx_t ctx) + int _gr_poly_div_series_invmul(gr_ptr res, gr_srcptr B, long Blen, gr_srcptr A, long Alen, long len, gr_ctx_t ctx) + int gr_poly_div_series_invmul(gr_poly_t res, const gr_poly_t A, const gr_poly_t B, long len, gr_ctx_t ctx) + int _gr_poly_div_series_basecase_preinv1(gr_ptr Q, gr_srcptr A, long Alen, gr_srcptr B, long Blen, gr_srcptr Binv, long len, gr_ctx_t ctx) + int _gr_poly_div_series_basecase_noinv(gr_ptr Q, gr_srcptr A, long Alen, gr_srcptr B, long Blen, long len, gr_ctx_t ctx) + int _gr_poly_div_series_basecase(gr_ptr res, gr_srcptr A, long Alen, gr_srcptr B, long Blen, long len, gr_ctx_t ctx) + int gr_poly_div_series_basecase(gr_poly_t res, const gr_poly_t A, const gr_poly_t B, long len, gr_ctx_t ctx) + int _gr_poly_div_series(gr_ptr res, gr_srcptr A, long Alen, gr_srcptr B, long Blen, long len, gr_ctx_t ctx) + int gr_poly_div_series(gr_poly_t res, const gr_poly_t A, const gr_poly_t B, long len, gr_ctx_t ctx) + + int _gr_poly_divexact_basecase_bidirectional(gr_ptr Q, gr_srcptr A, long Alen, gr_srcptr B, long Blen, gr_ctx_t ctx) + int gr_poly_divexact_basecase_bidirectional(gr_poly_t Q, const gr_poly_t A, const gr_poly_t B, gr_ctx_t ctx) + int _gr_poly_divexact_bidirectional(gr_ptr Q, gr_srcptr A, long Alen, gr_srcptr B, long Blen, gr_ctx_t ctx) + int gr_poly_divexact_bidirectional(gr_poly_t Q, const gr_poly_t A, const gr_poly_t B, gr_ctx_t ctx) + int _gr_poly_divexact_basecase_noinv(gr_ptr Q, gr_srcptr A, long Alen, gr_srcptr B, long Blen, gr_ctx_t ctx) + int _gr_poly_divexact_basecase(gr_ptr Q, gr_srcptr A, long Alen, gr_srcptr B, long Blen, gr_ctx_t ctx) + int gr_poly_divexact_basecase(gr_poly_t Q, const gr_poly_t A, const gr_poly_t B, gr_ctx_t ctx) + + int _gr_poly_divexact_series_basecase_noinv(gr_ptr Q, gr_srcptr A, long Alen, gr_srcptr B, long Blen, long len, gr_ctx_t ctx) + int _gr_poly_divexact_series_basecase(gr_ptr Q, gr_srcptr A, long Alen, gr_srcptr B, long Blen, long len, gr_ctx_t ctx) + int gr_poly_divexact_series_basecase(gr_poly_t Q, const gr_poly_t A, const gr_poly_t B, long len, gr_ctx_t ctx) + + int _gr_poly_sqrt_series_newton(gr_ptr res, gr_srcptr f, long flen, long len, long cutoff, gr_ctx_t ctx) + int gr_poly_sqrt_series_newton(gr_poly_t res, const gr_poly_t f, long len, long cutoff, gr_ctx_t ctx) + int _gr_poly_sqrt_series_basecase(gr_ptr res, gr_srcptr f, long flen, long len, gr_ctx_t ctx) + int gr_poly_sqrt_series_basecase(gr_poly_t res, const gr_poly_t f, long len, gr_ctx_t ctx) + int _gr_poly_sqrt_series_miller(gr_ptr res, gr_srcptr f, long flen, long len, gr_ctx_t ctx) + int gr_poly_sqrt_series_miller(gr_poly_t res, const gr_poly_t f, long len, gr_ctx_t ctx) + int _gr_poly_sqrt_series(gr_ptr res, gr_srcptr f, long flen, long len, gr_ctx_t ctx) + int gr_poly_sqrt_series(gr_poly_t res, const gr_poly_t f, long len, gr_ctx_t ctx) + + int _gr_poly_rsqrt_series_newton(gr_ptr res, gr_srcptr f, long flen, long len, long cutoff, gr_ctx_t ctx) + int gr_poly_rsqrt_series_newton(gr_poly_t res, const gr_poly_t f, long len, long cutoff, gr_ctx_t ctx) + int _gr_poly_rsqrt_series_basecase(gr_ptr res, gr_srcptr f, long flen, long len, gr_ctx_t ctx) + int gr_poly_rsqrt_series_basecase(gr_poly_t res, const gr_poly_t f, long len, gr_ctx_t ctx) + int _gr_poly_rsqrt_series_miller(gr_ptr res, gr_srcptr f, long flen, long len, gr_ctx_t ctx) + int gr_poly_rsqrt_series_miller(gr_poly_t res, const gr_poly_t f, long len, gr_ctx_t ctx) + int _gr_poly_rsqrt_series(gr_ptr res, gr_srcptr f, long flen, long len, gr_ctx_t ctx) + int gr_poly_rsqrt_series(gr_poly_t res, const gr_poly_t f, long len, gr_ctx_t ctx) + + int _gr_poly_evaluate_rectangular(gr_ptr res, gr_srcptr poly, long len, gr_srcptr x, gr_ctx_t ctx) + int gr_poly_evaluate_rectangular(gr_ptr res, const gr_poly_t poly, gr_srcptr x, gr_ctx_t ctx) + + int _gr_poly_evaluate_horner(gr_ptr res, gr_srcptr poly, long len, gr_srcptr x, gr_ctx_t ctx) + int gr_poly_evaluate_horner(gr_ptr res, const gr_poly_t poly, gr_srcptr x, gr_ctx_t ctx) + + int _gr_poly_evaluate(gr_ptr res, gr_srcptr poly, long len, gr_srcptr x, gr_ctx_t ctx) + int gr_poly_evaluate(gr_ptr res, const gr_poly_t poly, gr_srcptr x, gr_ctx_t ctx) + # Set *res* to *poly* evaluated at *x*. + + int _gr_poly_evaluate_other_horner(gr_ptr res, gr_srcptr f, long len, const gr_srcptr x, gr_ctx_t x_ctx, gr_ctx_t ctx) + int gr_poly_evaluate_other_horner(gr_ptr res, const gr_poly_t f, gr_srcptr x, gr_ctx_t x_ctx, gr_ctx_t ctx) + int _gr_poly_evaluate_other_rectangular(gr_ptr res, gr_srcptr f, long len, const gr_srcptr x, gr_ctx_t x_ctx, gr_ctx_t ctx) + int gr_poly_evaluate_other_rectangular(gr_ptr res, const gr_poly_t f, gr_srcptr x, gr_ctx_t x_ctx, gr_ctx_t ctx) + int _gr_poly_evaluate_other(gr_ptr res, gr_srcptr f, long len, const gr_srcptr x, gr_ctx_t x_ctx, gr_ctx_t ctx) + int gr_poly_evaluate_other(gr_ptr res, const gr_poly_t f, gr_srcptr x, gr_ctx_t x_ctx, gr_ctx_t ctx) + # Set *res* to *poly* evaluated at *x*, where the coefficients of *f* + # belong to *ctx* while both *x* and *res* belong to *x_ctx*. + + gr_ptr * _gr_poly_tree_alloc(long len, gr_ctx_t ctx) + + void _gr_poly_tree_free(gr_ptr * tree, long len, gr_ctx_t ctx) + + int _gr_poly_tree_build(gr_ptr * tree, gr_srcptr roots, long len, gr_ctx_t ctx) + + int _gr_poly_evaluate_vec_fast_precomp(gr_ptr vs, gr_srcptr poly, long plen, gr_ptr * tree, long len, gr_ctx_t ctx) + + int _gr_poly_evaluate_vec_fast(gr_ptr ys, gr_srcptr poly, long plen, gr_srcptr xs, long n, gr_ctx_t ctx) + + int gr_poly_evaluate_vec_fast(gr_vec_t ys, const gr_poly_t poly, const gr_vec_t xs, gr_ctx_t ctx) + + int _gr_poly_evaluate_vec_iter(gr_ptr ys, gr_srcptr poly, long plen, gr_srcptr xs, long n, gr_ctx_t ctx) + + int gr_poly_evaluate_vec_iter(gr_vec_t ys, const gr_poly_t poly, const gr_vec_t xs, gr_ctx_t ctx) + + int _gr_poly_taylor_shift_horner(gr_ptr res, gr_srcptr poly, long len, gr_srcptr c, gr_ctx_t ctx) + int gr_poly_taylor_shift_horner(gr_poly_t res, const gr_poly_t poly, gr_srcptr c, gr_ctx_t ctx) + int _gr_poly_taylor_shift_divconquer(gr_ptr res, gr_srcptr poly, long len, gr_srcptr c, gr_ctx_t ctx) + int gr_poly_taylor_shift_divconquer(gr_poly_t res, const gr_poly_t poly, gr_srcptr c, gr_ctx_t ctx) + int _gr_poly_taylor_shift_convolution(gr_ptr res, gr_srcptr poly, long len, gr_srcptr c, gr_ctx_t ctx) + int gr_poly_taylor_shift_convolution(gr_poly_t res, const gr_poly_t poly, gr_srcptr c, gr_ctx_t ctx) + int _gr_poly_taylor_shift(gr_ptr res, gr_srcptr poly, long len, gr_srcptr c, gr_ctx_t ctx) + int gr_poly_taylor_shift(gr_poly_t res, const gr_poly_t poly, gr_srcptr c, gr_ctx_t ctx) + # Sets *res* to the Taylor shift `f(x+c)`, where *f* is given by + # *poly*, computed respectively using + # an optimized form of Horner's rule, divide-and-conquer, a single + # convolution, and an automatic choice between the three algorithms. + # The underscore methods support aliasing. + + int _gr_poly_compose_horner(gr_ptr res, gr_srcptr poly1, long len1, gr_srcptr poly2, long len2, gr_ctx_t ctx) + int gr_poly_compose_horner(gr_poly_t res, const gr_poly_t poly1, const gr_poly_t poly2, gr_ctx_t ctx) + int _gr_poly_compose_divconquer(gr_ptr res, gr_srcptr poly1, long len1, gr_srcptr poly2, long len2, gr_ctx_t ctx) + int gr_poly_compose_divconquer(gr_poly_t res, const gr_poly_t poly1, const gr_poly_t poly2, gr_ctx_t ctx) + int _gr_poly_compose(gr_ptr res, gr_srcptr poly1, long len1, gr_srcptr poly2, long len2, gr_ctx_t ctx) + int gr_poly_compose(gr_poly_t res, const gr_poly_t poly1, const gr_poly_t poly2, gr_ctx_t ctx) + # Sets *res* to the composition `f(g(x))` where *f* is given by *poly1* + # and *g* is given by *poly2*, respectively using Horner's rule, + # divide-and-conquer, and an automatic choice between the two algorithms. + # The default algorithm also handles special-form input `g = ax^n + c` + # efficiently by performing a Taylor shift followed by a rescaling. + # The underscore methods do not support aliasing of the output + # with either input polynomial. + + int _gr_poly_compose_series_horner(gr_ptr res, gr_srcptr poly1, long len1, gr_srcptr poly2, long len2, long n, gr_ctx_t ctx) + int gr_poly_compose_series_horner(gr_poly_t res, const gr_poly_t poly1, const gr_poly_t poly2, long n, gr_ctx_t ctx) + int _gr_poly_compose_series_brent_kung(gr_ptr res, gr_srcptr poly1, long len1, gr_srcptr poly2, long len2, long n, gr_ctx_t ctx) + int gr_poly_compose_series_brent_kung(gr_poly_t res, const gr_poly_t poly1, const gr_poly_t poly2, long n, gr_ctx_t ctx) + int _gr_poly_compose_series_divconquer(gr_ptr res, gr_srcptr poly1, long len1, gr_srcptr poly2, long len2, long n, gr_ctx_t ctx) + int gr_poly_compose_series_divconquer(gr_poly_t res, const gr_poly_t poly1, const gr_poly_t poly2, long n, gr_ctx_t ctx) + int _gr_poly_compose_series(gr_ptr res, gr_srcptr poly1, long len1, gr_srcptr poly2, long len2, long n, gr_ctx_t ctx) + int gr_poly_compose_series(gr_poly_t res, const gr_poly_t poly1, const gr_poly_t poly2, long n, gr_ctx_t ctx) + # Sets *res* to the power series composition `h(x) = f(g(x))` truncated + # to order `O(x^n)` where `f` is given by *poly1* and `g` is given by *poly2*, + # respectively using Horner's rule, the Brent-Kung baby step-giant step + # algorithm [BrentKung1978]_, divide-and-conquer, and an automatic choice between the algorithms. + # The default algorithm also handles short input and + # special-form input `g = ax^n` efficiently. + # We require that the constant term in `g(x)` is exactly zero. + # The underscore methods do not support aliasing of the output + # with either input polynomial, and do not zero-pad the result. + + int _gr_poly_derivative(gr_ptr res, gr_srcptr poly, long len, gr_ctx_t ctx) + int gr_poly_derivative(gr_poly_t res, const gr_poly_t poly, gr_ctx_t ctx) + + int _gr_poly_nth_derivative(gr_ptr res, gr_srcptr poly, unsigned long n, long len, gr_ctx_t ctx) + int gr_poly_nth_derivative(gr_poly_t res, const gr_poly_t poly, unsigned long n, gr_ctx_t ctx) + + int _gr_poly_integral(gr_ptr res, gr_srcptr poly, long len, gr_ctx_t ctx) + int gr_poly_integral(gr_poly_t res, const gr_poly_t poly, gr_ctx_t ctx) + + int _gr_poly_make_monic(gr_ptr res, gr_srcptr poly, long len, gr_ctx_t ctx) + int gr_poly_make_monic(gr_poly_t res, const gr_poly_t src, gr_ctx_t ctx) + + truth_t _gr_poly_is_monic(gr_srcptr poly, long len, gr_ctx_t ctx) + truth_t gr_poly_is_monic(const gr_poly_t res, gr_ctx_t ctx) + + int _gr_poly_hgcd(gr_ptr r, long * sgn, gr_ptr * M, long * lenM, gr_ptr A, long * lenA, gr_ptr B, long * lenB, gr_srcptr a, long lena, gr_srcptr b, long lenb, long cutoff, gr_ctx_t ctx) + # Computes the HGCD of `a` and `b`, that is, a matrix `M`, a sign `\sigma` + # and two polynomials `A` and `B` such that + # .. math :: + # (A,B)^t = \sigma M^{-1} (a,b)^t. + # Assumes that `\operatorname{len}(a) > \operatorname{len}(b) > 0`. + # Assumes that `A` and `B` have space of size at least `\operatorname{len}(a)` + # and `\operatorname{len}(b)`, respectively. On exit, ``*lenA`` and ``*lenB`` + # will contain the correct lengths of `A` and `B`. + # Assumes that ``M[0]``, ``M[1]``, ``M[2]``, and ``M[3]`` + # each point to a vector of size at least `\operatorname{len}(a)`. + # If `r` is not ``NULL``, writes to that variable the corresponding value + # for computing resultants using the HGCD algorithm. + + int _gr_poly_gcd_hgcd(gr_ptr G, long * _lenG, gr_srcptr A, long lenA, gr_srcptr B, long lenB, long inner_cutoff, long cutoff, gr_ctx_t ctx) + int gr_poly_gcd_hgcd(gr_poly_t G, const gr_poly_t A, const gr_poly_t B, long inner_cutoff, long cutoff, gr_ctx_t ctx) + int _gr_poly_gcd_euclidean(gr_ptr G, long * lenG, gr_srcptr A, long lenA, gr_srcptr B, long lenB, gr_ctx_t ctx) + int gr_poly_gcd_euclidean(gr_poly_t G, const gr_poly_t A, const gr_poly_t B, gr_ctx_t ctx) + int _gr_poly_gcd(gr_ptr G, long * lenG, gr_srcptr A, long lenA, gr_srcptr B, long lenB, gr_ctx_t ctx) + int gr_poly_gcd(gr_poly_t G, const gr_poly_t A, const gr_poly_t B, gr_ctx_t ctx) + # Polynomial GCD. Currently only useful over fields. + # The underscore methods assume ``lenA >= lenB >= 1`` and that both + # *A* and *B* have nonzero leading coefficient. + # The underscore methods do not attempt to make the result monic. + # The time complexity of the half-GCD algorithm is `\mathcal{O}(n \log^2 n)` + # ring operations. For further details, see [ThullYap1990]_. + + int _gr_poly_xgcd_euclidean(long * lenG, gr_ptr G, gr_ptr S, gr_ptr T, gr_srcptr A, long lenA, gr_srcptr B, long lenB, gr_ctx_t ctx) + int gr_poly_xgcd_euclidean(gr_poly_t G, gr_poly_t S, gr_poly_t T, const gr_poly_t A, const gr_poly_t B, gr_ctx_t ctx) + + int _gr_poly_xgcd_hgcd(long * Glen, gr_ptr G, gr_ptr S, gr_ptr T, gr_srcptr A, long lenA, gr_srcptr B, long lenB, long hgcd_cutoff, long cutoff, gr_ctx_t ctx) + int gr_poly_xgcd_hgcd(gr_poly_t G, gr_poly_t S, gr_poly_t T, const gr_poly_t A, const gr_poly_t B, long hgcd_cutoff, long cutoff, gr_ctx_t ctx) + + int _gr_poly_resultant_euclidean(gr_ptr res, gr_srcptr poly1, long len1, gr_srcptr poly2, long len2, gr_ctx_t ctx) + int gr_poly_resultant_euclidean(gr_ptr res, const gr_poly_t f, const gr_poly_t g, gr_ctx_t ctx) + int _gr_poly_resultant_hgcd(gr_ptr res, gr_srcptr A, long lenA, gr_srcptr B, long lenB, long inner_cutoff, long cutoff, gr_ctx_t ctx) + int gr_poly_resultant_hgcd(gr_ptr res, const gr_poly_t f, const gr_poly_t g, long inner_cutoff, long cutoff, gr_ctx_t ctx) + int _gr_poly_resultant_sylvester(gr_ptr res, gr_srcptr poly1, long len1, gr_srcptr poly2, long len2, gr_ctx_t ctx) + int gr_poly_resultant_sylvester(gr_ptr res, const gr_poly_t f, const gr_poly_t g, gr_ctx_t ctx) + int _gr_poly_resultant_small(gr_ptr res, gr_srcptr poly1, long len1, gr_srcptr poly2, long len2, gr_ctx_t ctx) + int gr_poly_resultant_small(gr_ptr res, const gr_poly_t f, const gr_poly_t g, gr_ctx_t ctx) + int _gr_poly_resultant(gr_ptr res, gr_srcptr poly1, long len1, gr_srcptr poly2, long len2, gr_ctx_t ctx) + int gr_poly_resultant(gr_ptr res, const gr_poly_t f, const gr_poly_t g, gr_ctx_t ctx) + # Sets *res* to the resultant of *poly1* and *poly2*. + # The underscore methods assume that `len1 \ge len2 \ge 1` + # and that the leading coefficients are nonzero. + # The *euclidean* algorithm is the ordinary Euclidean algorithm. + # The *hgcd* version uses the quasilinear half-GCD algorithm. + # It requires two extra tuning parameters ``inner_cutoff`` + # (recursion threshold passed forward to the HGCD algorithm) + # and ``cutoff``. Both algorithms can fail when run over + # non-fields; they will return ``GR_DOMAIN`` + # when encountering an impossible inverse. + # The *small* version uses division-free straight-line programs + # optimized for short polynomials. + # It returns ``GR_UNABLE`` if the polynomials are too large. + # Currently this function handles the cases where `len1 \le 2` + # or `len2 \le 3`. + # The *sylvester* version constructs the Sylvester matrix + # and computes its determinant. This is useful over inexact rings + # and as a fallback for rings without division. + # The default version attempts to choose an appropriate + # algorithm automatically. + # Currently no algorithm has been implemented that is appropriate for + # integral domains. + + int gr_poly_factor_squarefree(gr_ptr c, gr_vec_t fac, gr_vec_t exp, const gr_poly_t poly, gr_ctx_t ctx) + # Computes a squarefree factorization of *poly*. + # The constant *c* is set to an element of the scalar ring. + # The factors in *fac* are set to polynomials; the user must thus + # initialize it to a vector of polynomials of the same type as + # *poly* (and *not* to the parent *ctx*). + # The exponent vector *exp* must be initialized to the *fmpz* type. + + int gr_poly_squarefree_part(gr_poly_t res, const gr_poly_t poly, gr_ctx_t ctx) + # Sets *res* to the squarefreepart of *poly*. + + int gr_poly_roots(gr_vec_t roots, gr_vec_t mult, const gr_poly_t poly, int flags, gr_ctx_t ctx) + int gr_poly_roots_other(gr_vec_t roots, gr_vec_t mult, const gr_poly_t poly, gr_ctx_t poly_ctx, int flags, gr_ctx_t ctx) + # Finds all roots of the given polynomial in the ring defined by *ctx*, + # storing the roots without duplication in *roots* (a vector with + # elements of type ``ctx``) and the corresponding multiplicities in + # *mult* (a vector with elements of type ``fmpz``). + # If the target ring is not an algebraically closed field, then + # the sum of multiplicities can be smaller than the degree of the + # polynomial. For example, with ``fmpz`` coefficients, we only + # find integer roots. + # The *other* version of this function takes as input a polynomial + # with entries in a different ring ``poly_ctx``. For example, + # we can compute ``qqbar`` or ``arb`` roots for a polynomial + # with ``fmpz`` coefficients. + # Whether the roots are sorted in any particular order is + # ring-dependent. + # We consider roots of the zero polynomial to be ill-defined and return + # ``GR_DOMAIN`` in that case. + + int _gr_poly_asin_series(gr_ptr res, gr_srcptr f, long flen, long len, gr_ctx_t ctx) + int gr_poly_asin_series(gr_poly_t res, const gr_poly_t f, long len, gr_ctx_t ctx) + int _gr_poly_asinh_series(gr_ptr res, gr_srcptr f, long flen, long len, gr_ctx_t ctx) + int gr_poly_asinh_series(gr_poly_t res, const gr_poly_t f, long len, gr_ctx_t ctx) + int _gr_poly_acos_series(gr_ptr res, gr_srcptr f, long flen, long len, gr_ctx_t ctx) + int gr_poly_acos_series(gr_poly_t res, const gr_poly_t f, long len, gr_ctx_t ctx) + int _gr_poly_acosh_series(gr_ptr res, gr_srcptr f, long flen, long len, gr_ctx_t ctx) + int gr_poly_acosh_series(gr_poly_t res, const gr_poly_t f, long len, gr_ctx_t ctx) + int _gr_poly_atan_series(gr_ptr res, gr_srcptr f, long flen, long len, gr_ctx_t ctx) + int gr_poly_atan_series(gr_poly_t res, const gr_poly_t f, long len, gr_ctx_t ctx) + int _gr_poly_atanh_series(gr_ptr res, gr_srcptr f, long flen, long len, gr_ctx_t ctx) + int gr_poly_atanh_series(gr_poly_t res, const gr_poly_t f, long len, gr_ctx_t ctx) + + int _gr_poly_log_series(gr_ptr res, gr_srcptr f, long flen, long len, gr_ctx_t ctx) + int gr_poly_log_series(gr_poly_t res, const gr_poly_t f, long len, gr_ctx_t ctx) + int _gr_poly_log1p_series(gr_ptr res, gr_srcptr f, long flen, long len, gr_ctx_t ctx) + int gr_poly_log1p_series(gr_poly_t res, const gr_poly_t f, long len, gr_ctx_t ctx) + + int _gr_poly_exp_series_basecase(gr_ptr f, gr_srcptr h, long hlen, long n, gr_ctx_t ctx) + int gr_poly_exp_series_basecase(gr_poly_t f, const gr_poly_t h, long n, gr_ctx_t ctx) + int _gr_poly_exp_series_basecase_mul(gr_ptr f, gr_srcptr h, long hlen, long n, gr_ctx_t ctx) + int gr_poly_exp_series_basecase_mul(gr_poly_t f, const gr_poly_t h, long n, gr_ctx_t ctx) + int _gr_poly_exp_series_newton(gr_ptr f, gr_ptr g, gr_srcptr h, long hlen, long n, long cutoff, gr_ctx_t ctx) + int gr_poly_exp_series_newton(gr_poly_t f, const gr_poly_t h, long n, long cutoff, gr_ctx_t ctx) + int _gr_poly_exp_series_generic(gr_ptr f, gr_srcptr h, long hlen, long n, gr_ctx_t ctx) + int _gr_poly_exp_series(gr_ptr res, gr_srcptr f, long flen, long len, gr_ctx_t ctx) + int gr_poly_exp_series(gr_poly_t f, const gr_poly_t h, long n, gr_ctx_t ctx) + + int _gr_poly_sin_cos_series_basecase(gr_ptr s, gr_ptr c, gr_srcptr h, long hlen, long n, int times_pi, gr_ctx_t ctx) + int gr_poly_sin_cos_series_basecase(gr_poly_t s, gr_poly_t c, const gr_poly_t h, long n, int times_pi, gr_ctx_t ctx) + int _gr_poly_sin_cos_series_tangent(gr_ptr s, gr_ptr c, gr_srcptr h, long hlen, long n, int times_pi, gr_ctx_t ctx) + int gr_poly_sin_cos_series_tangent(gr_poly_t s, gr_poly_t c, const gr_poly_t h, long n, int times_pi, gr_ctx_t ctx) + # The *basecase* version uses a simple recurrence for the coefficients, + # requiring `O(nm)` operations where `m` is the length of `h`. + # The *tangent* version uses the tangent half-angle formulas to compute + # the sine and cosine via :func:`_acb_poly_tan_series`. This + # requires `O(M(n))` operations. + # When `h = h_0 + h_1` where the constant term `h_0` is nonzero, + # the evaluation is done as + # `\sin(h_0 + h_1) = \cos(h_0) \sin(h_1) + \sin(h_0) \cos(h_1)`, + # `\cos(h_0 + h_1) = \cos(h_0) \cos(h_1) - \sin(h_0) \sin(h_1)`. + # The *basecase* and *tangent* versions take a flag *times_pi* + # specifying that the input is to be multiplied by `\pi`. + + int _gr_poly_tan_series_basecase(gr_ptr f, gr_srcptr h, long hlen, long n, gr_ctx_t ctx) + int gr_poly_tan_series_basecase(gr_poly_t f, const gr_poly_t h, long n, gr_ctx_t ctx) + int _gr_poly_tan_series_newton(gr_ptr f, gr_srcptr h, long hlen, long n, long cutoff, gr_ctx_t ctx) + int gr_poly_tan_series_newton(gr_poly_t f, const gr_poly_t h, long n, long cutoff, gr_ctx_t ctx) + int _gr_poly_tan_series(gr_ptr f, gr_srcptr h, long hlen, long n, gr_ctx_t ctx) + int gr_poly_tan_series(gr_poly_t f, const gr_poly_t h, long n, gr_ctx_t ctx) diff --git a/src/sage/libs/flint/gr_special.pxd b/src/sage/libs/flint/gr_special.pxd new file mode 100644 index 00000000000..5481319e131 --- /dev/null +++ b/src/sage/libs/flint/gr_special.pxd @@ -0,0 +1,318 @@ +# distutils: libraries = flint +# distutils: depends = flint/gr_special.h + +################################################################################ +# This file is auto-generated. Do not modify by hand +################################################################################ + +from libc.stdio cimport FILE +from sage.libs.gmp.types cimport * +from sage.libs.mpfr.types cimport * +from sage.libs.flint.types cimport * + +cdef extern from "flint_wrap.h": + + int gr_pi(gr_ptr res, gr_ctx_t ctx) + int gr_euler(gr_ptr res, gr_ctx_t ctx) + int gr_catalan(gr_ptr res, gr_ctx_t ctx) + int gr_khinchin(gr_ptr res, gr_ctx_t ctx) + int gr_glaisher(gr_ptr res, gr_ctx_t ctx) + # Standard real constants: `\pi`, Euler's constant `\gamma`, + # Catalan's constant, Khinchin's constant, Glaisher's constant. + + int gr_exp(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) + int gr_expm1(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) + int gr_exp2(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) + int gr_exp10(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) + int gr_exp_pi_i(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) + int gr_log(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) + int gr_log1p(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) + int gr_log2(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) + int gr_log10(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) + int gr_log_pi_i(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) + + int gr_sin(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) + int gr_cos(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) + int gr_sin_cos(gr_ptr res1, gr_ptr res2, gr_srcptr x, gr_ctx_t ctx) + int gr_tan(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) + int gr_cot(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) + int gr_sec(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) + int gr_csc(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) + + int gr_sin_pi(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) + int gr_cos_pi(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) + int gr_sin_cos_pi(gr_ptr res1, gr_ptr res2, gr_srcptr x, gr_ctx_t ctx) + int gr_tan_pi(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) + int gr_cot_pi(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) + int gr_sec_pi(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) + int gr_csc_pi(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) + + int gr_sinc(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) + int gr_sinc_pi(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) + + int gr_sinh(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) + int gr_cosh(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) + int gr_sinh_cosh(gr_ptr res1, gr_ptr res2, gr_srcptr x, gr_ctx_t ctx) + int gr_tanh(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) + int gr_coth(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) + int gr_sech(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) + int gr_csch(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) + + int gr_asin(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) + int gr_acos(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) + int gr_atan(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) + int gr_atan2(gr_ptr res, gr_srcptr y, gr_srcptr x, gr_ctx_t ctx) + int gr_acot(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) + int gr_asec(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) + int gr_acsc(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) + + int gr_asin_pi(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) + int gr_acos_pi(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) + int gr_atan_pi(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) + int gr_acot_pi(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) + int gr_asec_pi(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) + int gr_acsc_pi(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) + + int gr_asinh(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) + int gr_acosh(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) + int gr_atanh(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) + int gr_acoth(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) + int gr_asech(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) + int gr_acsch(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) + + int gr_lambertw(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) + int gr_lambertw_fmpz(gr_ptr res, gr_srcptr x, const fmpz_t k, gr_ctx_t ctx) + + int gr_fac(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) + int gr_fac_ui(gr_ptr res, unsigned long x, gr_ctx_t ctx) + int gr_fac_fmpz(gr_ptr res, const fmpz_t x, gr_ctx_t ctx) + int gr_fac_vec(gr_ptr res, long len, gr_ctx_t ctx) + # Factorial `x!`. The *vec* version writes the first *len* + # consecutive values `1, 1, 2, 6, \ldots, (len-1)!` + # to the preallocated vector *res*. + + int gr_rfac(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) + int gr_rfac_ui(gr_ptr res, unsigned long x, gr_ctx_t ctx) + int gr_rfac_fmpz(gr_ptr res, const fmpz_t x, gr_ctx_t ctx) + int gr_rfac_vec(gr_ptr res, long len, gr_ctx_t ctx) + # Reciprocal factorial. The *vec* version writes the first *len* + # consecutive values `1, 1, 1/2, 1/6, \ldots, 1/(len-1)!` + # to the preallocated vector *res*. + + int gr_bin(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) + int gr_bin_ui(gr_ptr res, gr_srcptr x, unsigned long y, gr_ctx_t ctx) + int gr_bin_uiui(gr_ptr res, unsigned long x, unsigned long y, gr_ctx_t ctx) + int gr_bin_vec(gr_ptr res, gr_srcptr x, long len, gr_ctx_t ctx) + int gr_bin_ui_vec(gr_ptr res, unsigned long x, long len, gr_ctx_t ctx) + # Binomial coefficient `{x \choose y}`. The *vec* versions write the + # first *len* consecutive values `{x \choose 0}, {x \choose 1}, \ldots, {x \choose len-1}` + # to the preallocated vector *res*. + # For constructing a two-dimensional array of binomial + # coefficients (Pascal's triangle), it is more efficient to + # call :func:`gr_mat_pascal` than to call these functions repeatedly. + + int gr_rising(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) + int gr_rising_ui(gr_ptr res, gr_srcptr x, unsigned long y, gr_ctx_t ctx) + int gr_falling(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) + int gr_falling_ui(gr_ptr res, gr_srcptr x, unsigned long y, gr_ctx_t ctx) + # Rising and falling factorials `x (x+1) \cdots (x+y-1)` + # and `x (x-1) \cdots (x-y+1)`, or their generalizations + # to non-integer `y` via the gamma function. + + int gr_gamma(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) + int gr_gamma_fmpz(gr_ptr res, const fmpz_t x, gr_ctx_t ctx) + int gr_gamma_fmpq(gr_ptr res, const fmpq_t x, gr_ctx_t ctx) + int gr_rgamma(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) + int gr_lgamma(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) + int gr_digamma(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) + # Gamma function `\Gamma(x)`, its reciprocal `1 / \Gamma(x)`, + # the log-gamma function `\log \Gamma(x)`, and the digamma function + # `\psi(x)`. + + int gr_barnes_g(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) + int gr_log_barnes_g(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) + # Barnes G-function. + + int gr_beta(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) + # Beta function `B(x,y)`. + + int gr_doublefac(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) + int gr_doublefac_ui(gr_ptr res, unsigned long x, gr_ctx_t ctx) + # Double factorial `x!!`. + + int gr_harmonic(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) + int gr_harmonic_ui(gr_ptr res, unsigned long x, gr_ctx_t ctx) + # Harmonic number `H_x`. + + int gr_bernoulli_ui(gr_ptr res, unsigned long n, gr_ctx_t ctx) + int gr_bernoulli_fmpz(gr_ptr res, const fmpz_t n, gr_ctx_t ctx) + int gr_bernoulli_vec(gr_ptr res, long len, gr_ctx_t ctx) + # Bernoulli numbers `B_n`. + + int gr_eulernum_ui(gr_ptr res, unsigned long x, gr_ctx_t ctx) + int gr_eulernum_fmpz(gr_ptr res, const fmpz_t x, gr_ctx_t ctx) + int gr_eulernum_vec(gr_ptr res, long len, gr_ctx_t ctx) + # Euler numbers `E_n`. + + int gr_fib_ui(gr_ptr res, unsigned long n, gr_ctx_t ctx) + int gr_fib_fmpz(gr_ptr res, const fmpz_t n, gr_ctx_t ctx) + int gr_fib_vec(gr_ptr res, long len, gr_ctx_t ctx) + # Fibonacci numbers `F_n`. + + int gr_stirling_s1u_uiui(gr_ptr res, unsigned long x, unsigned long y, gr_ctx_t ctx) + int gr_stirling_s1_uiui(gr_ptr res, unsigned long x, unsigned long y, gr_ctx_t ctx) + int gr_stirling_s2_uiui(gr_ptr res, unsigned long x, unsigned long y, gr_ctx_t ctx) + int gr_stirling_s1u_ui_vec(gr_ptr res, unsigned long x, long len, gr_ctx_t ctx) + int gr_stirling_s1_ui_vec(gr_ptr res, unsigned long x, long len, gr_ctx_t ctx) + int gr_stirling_s2_ui_vec(gr_ptr res, unsigned long x, long len, gr_ctx_t ctx) + # Stirling numbers `S(x,y)`: unsigned of the first kind, + # signed of the first kind, and second kind. The *vec* versions + # write the *len* consecutive values `S(x,0), S(x,1), \ldots, S(x, len-1)` + # to the preallocated vector *res*. + # For constructing a two-dimensional array of Stirling numbers, + # it is more efficient to + # call :func:`gr_mat_stirling` than to call these functions repeatedly. + + int gr_bellnum_ui(gr_ptr res, unsigned long x, gr_ctx_t ctx) + int gr_bellnum_fmpz(gr_ptr res, const fmpz_t x, gr_ctx_t ctx) + int gr_bellnum_vec(gr_ptr res, long len, gr_ctx_t ctx) + # Bell numbers `B_n`. + + int gr_partitions_ui(gr_ptr res, unsigned long x, gr_ctx_t ctx) + int gr_partitions_fmpz(gr_ptr res, const fmpz_t x, gr_ctx_t ctx) + int gr_partitions_vec(gr_ptr res, long len, gr_ctx_t ctx) + # Partition numbers `p(n)`. + + int gr_erf(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) + int gr_erfc(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) + int gr_erfcx(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) + int gr_erfi(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) + int gr_erfinv(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) + int gr_erfcinv(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) + + int gr_fresnel_s(gr_ptr res, gr_srcptr x, int normalized, gr_ctx_t ctx) + int gr_fresnel_c(gr_ptr res, gr_srcptr x, int normalized, gr_ctx_t ctx) + int gr_fresnel(gr_ptr res1, gr_ptr res2, gr_srcptr x, int normalized, gr_ctx_t ctx) + + int gr_gamma_upper(gr_ptr res, gr_srcptr x, gr_srcptr y, int regularized, gr_ctx_t ctx) + int gr_gamma_lower(gr_ptr res, gr_srcptr x, gr_srcptr y, int regularized, gr_ctx_t ctx) + int gr_beta_lower(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_srcptr z, int regularized, gr_ctx_t ctx) + + int gr_exp_integral(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) + int gr_exp_integral_ei(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) + int gr_sin_integral(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) + int gr_cos_integral(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) + int gr_sinh_integral(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) + int gr_cosh_integral(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) + int gr_log_integral(gr_ptr res, gr_srcptr x, int offset, gr_ctx_t ctx) + int gr_dilog(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) + + int gr_chebyshev_t_fmpz(gr_ptr res, const fmpz_t n, gr_srcptr x, gr_ctx_t ctx) + int gr_chebyshev_t(gr_ptr res, gr_srcptr n, gr_srcptr x, gr_ctx_t ctx) + int gr_chebyshev_u_fmpz(gr_ptr res, const fmpz_t n, gr_srcptr x, gr_ctx_t ctx) + int gr_chebyshev_u(gr_ptr res, gr_srcptr n, gr_srcptr x, gr_ctx_t ctx) + + int gr_jacobi_p(gr_ptr res, gr_srcptr n, gr_srcptr a, gr_srcptr b, gr_srcptr z, gr_ctx_t ctx) + int gr_gegenbauer_c(gr_ptr res, gr_srcptr n, gr_srcptr m, gr_srcptr z, gr_ctx_t ctx) + int gr_laguerre_l(gr_ptr res, gr_srcptr n, gr_srcptr m, gr_srcptr z, gr_ctx_t ctx) + int gr_hermite_h(gr_ptr res, gr_srcptr n, gr_srcptr z, gr_ctx_t ctx) + int gr_legendre_p(gr_ptr res, gr_srcptr n, gr_srcptr m, gr_srcptr z, int type, gr_ctx_t ctx) + int gr_legendre_q(gr_ptr res, gr_srcptr n, gr_srcptr m, gr_srcptr z, int type, gr_ctx_t ctx) + int gr_spherical_y_si(gr_ptr res, long n, long m, gr_srcptr theta, gr_srcptr phi, gr_ctx_t ctx) + int gr_legendre_p_root_ui(gr_ptr root, gr_ptr weight, unsigned long n, unsigned long k, gr_ctx_t ctx) + + int gr_bessel_j(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) + int gr_bessel_y(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) + int gr_bessel_i(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) + int gr_bessel_k(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) + int gr_bessel_j_y(gr_ptr res1, gr_ptr res2, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) + int gr_bessel_i_scaled(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) + int gr_bessel_k_scaled(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) + + int gr_airy(gr_ptr res1, gr_ptr res2, gr_ptr res3, gr_ptr res4, gr_srcptr x, gr_ctx_t ctx) + int gr_airy_ai(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) + int gr_airy_bi(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) + int gr_airy_ai_prime(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) + int gr_airy_bi_prime(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) + + int gr_airy_ai_zero(gr_ptr res, const fmpz_t n, gr_ctx_t ctx) + int gr_airy_bi_zero(gr_ptr res, const fmpz_t n, gr_ctx_t ctx) + int gr_airy_ai_prime_zero(gr_ptr res, const fmpz_t n, gr_ctx_t ctx) + int gr_airy_bi_prime_zero(gr_ptr res, const fmpz_t n, gr_ctx_t ctx) + + int gr_coulomb(gr_ptr res1, gr_ptr res2, gr_ptr res3, gr_ptr res4, gr_srcptr x, gr_srcptr y, gr_srcptr z, gr_ctx_t ctx) + int gr_coulomb_f(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_srcptr z, gr_ctx_t ctx) + int gr_coulomb_g(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_srcptr z, gr_ctx_t ctx) + int gr_coulomb_hpos(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_srcptr z, gr_ctx_t ctx) + int gr_coulomb_hneg(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_srcptr z, gr_ctx_t ctx) + + int gr_hypgeom_0f1(gr_ptr res, gr_srcptr a, gr_srcptr z, int flags, gr_ctx_t ctx) + int gr_hypgeom_1f1(gr_ptr res, gr_srcptr a, gr_srcptr b, gr_srcptr z, int flags, gr_ctx_t ctx) + int gr_hypgeom_u(gr_ptr res, gr_srcptr a, gr_srcptr b, gr_srcptr z, int flags, gr_ctx_t ctx) + int gr_hypgeom_2f1(gr_ptr res, gr_srcptr a, gr_srcptr b, gr_srcptr c, gr_srcptr z, int flags, gr_ctx_t ctx) + int gr_hypgeom_pfq(gr_ptr res, const gr_vec_t a, const gr_vec_t b, gr_srcptr z, int flags, gr_ctx_t ctx) + + int gr_zeta(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) + int gr_zeta_ui(gr_ptr res, unsigned long x, gr_ctx_t ctx) + int gr_hurwitz_zeta(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) + int gr_polygamma(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) + int gr_polylog(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) + int gr_lerch_phi(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_srcptr z, gr_ctx_t ctx) + int gr_stieltjes(gr_ptr res, const fmpz_t x, gr_srcptr y, gr_ctx_t ctx) + + int gr_dirichlet_eta(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) + int gr_riemann_xi(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) + int gr_zeta_zero(gr_ptr res, const fmpz_t n, gr_ctx_t ctx) + int gr_zeta_zero_vec(gr_ptr res, const fmpz_t n, long len, gr_ctx_t ctx) + int gr_zeta_nzeros(gr_ptr res, gr_srcptr t, gr_ctx_t ctx) + + int gr_dirichlet_chi_fmpz(gr_ptr res, const dirichlet_group_t G, const dirichlet_char_t chi, const fmpz_t n, gr_ctx_t ctx) + int gr_dirichlet_chi_vec(gr_ptr res, const dirichlet_group_t G, const dirichlet_char_t chi, long len, gr_ctx_t ctx) + int gr_dirichlet_l(gr_ptr res, const dirichlet_group_t G, const dirichlet_char_t chi, gr_srcptr s, gr_ctx_t ctx) + int gr_dirichlet_l_all(gr_vec_t res, const dirichlet_group_t G, gr_srcptr s, gr_ctx_t ctx) + int gr_dirichlet_hardy_theta(gr_ptr res, const dirichlet_group_t G, const dirichlet_char_t chi, gr_srcptr t, gr_ctx_t ctx) + int gr_dirichlet_hardy_z(gr_ptr res, const dirichlet_group_t G, const dirichlet_char_t chi, gr_srcptr t, gr_ctx_t ctx) + + int gr_agm1(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) + int gr_agm(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) + + int gr_elliptic_k(gr_ptr res, gr_srcptr m, gr_ctx_t ctx) + int gr_elliptic_e(gr_ptr res, gr_srcptr m, gr_ctx_t ctx) + int gr_elliptic_pi(gr_ptr res, gr_srcptr n, gr_srcptr m, gr_ctx_t ctx) + int gr_elliptic_f(gr_ptr res, gr_srcptr phi, gr_srcptr m, int pi, gr_ctx_t ctx) + int gr_elliptic_e_inc(gr_ptr res, gr_srcptr phi, gr_srcptr m, int pi, gr_ctx_t ctx) + int gr_elliptic_pi_inc(gr_ptr res, gr_srcptr n, gr_srcptr phi, gr_srcptr m, int pi, gr_ctx_t ctx) + + int gr_carlson_rc(gr_ptr res, gr_srcptr x, gr_srcptr y, int flags, gr_ctx_t ctx) + int gr_carlson_rf(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_srcptr z, int flags, gr_ctx_t ctx) + int gr_carlson_rd(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_srcptr z, int flags, gr_ctx_t ctx) + int gr_carlson_rg(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_srcptr z, int flags, gr_ctx_t ctx) + int gr_carlson_rj(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_srcptr z, gr_srcptr w, int flags, gr_ctx_t ctx) + + int gr_jacobi_theta(gr_ptr res1, gr_ptr res2, gr_ptr res3, gr_ptr res4, gr_srcptr z, gr_srcptr tau, gr_ctx_t ctx) + int gr_jacobi_theta_1(gr_ptr res, gr_srcptr z, gr_srcptr tau, gr_ctx_t ctx) + int gr_jacobi_theta_2(gr_ptr res, gr_srcptr z, gr_srcptr tau, gr_ctx_t ctx) + int gr_jacobi_theta_3(gr_ptr res, gr_srcptr z, gr_srcptr tau, gr_ctx_t ctx) + int gr_jacobi_theta_4(gr_ptr res, gr_srcptr z, gr_srcptr tau, gr_ctx_t ctx) + + int gr_dedekind_eta(gr_ptr res, gr_srcptr tau, gr_ctx_t ctx) + int gr_dedekind_eta_q(gr_ptr res, gr_srcptr tau, gr_ctx_t ctx) + + int gr_modular_j(gr_ptr res, gr_srcptr tau, gr_ctx_t ctx) + int gr_modular_lambda(gr_ptr res, gr_srcptr tau, gr_ctx_t ctx) + int gr_modular_delta(gr_ptr res, gr_srcptr tau, gr_ctx_t ctx) + + int gr_hilbert_class_poly(gr_ptr res, long D, gr_srcptr x, gr_ctx_t ctx) + + int gr_eisenstein_e(gr_ptr res, unsigned long n, gr_srcptr tau, gr_ctx_t ctx) + int gr_eisenstein_g(gr_ptr res, unsigned long n, gr_srcptr tau, gr_ctx_t ctx) + int gr_eisenstein_g_vec(gr_ptr res, gr_srcptr tau, long len, gr_ctx_t ctx) + + int gr_elliptic_invariants(gr_ptr res1, gr_ptr res2, gr_srcptr tau, gr_ctx_t ctx) + int gr_elliptic_roots(gr_ptr res1, gr_ptr res2, gr_ptr res3, gr_srcptr tau, gr_ctx_t ctx) + + int gr_weierstrass_p(gr_ptr res, gr_srcptr z, gr_srcptr tau, gr_ctx_t ctx) + int gr_weierstrass_p_prime(gr_ptr res, gr_srcptr z, gr_srcptr tau, gr_ctx_t ctx) + int gr_weierstrass_p_inv(gr_ptr res, gr_srcptr z, gr_srcptr tau, gr_ctx_t ctx) + int gr_weierstrass_zeta(gr_ptr res, gr_srcptr z, gr_srcptr tau, gr_ctx_t ctx) + int gr_weierstrass_sigma(gr_ptr res, gr_srcptr z, gr_srcptr tau, gr_ctx_t ctx) diff --git a/src/sage/libs/flint/gr_vec.pxd b/src/sage/libs/flint/gr_vec.pxd new file mode 100644 index 00000000000..e9ec82b6a2d --- /dev/null +++ b/src/sage/libs/flint/gr_vec.pxd @@ -0,0 +1,176 @@ +# distutils: libraries = flint +# distutils: depends = flint/gr_vec.h + +################################################################################ +# This file is auto-generated. Do not modify by hand +################################################################################ + +from libc.stdio cimport FILE +from sage.libs.gmp.types cimport * +from sage.libs.mpfr.types cimport * +from sage.libs.flint.types cimport * + +cdef extern from "flint_wrap.h": + + void gr_vec_init(gr_vec_t vec, long len, gr_ctx_t ctx) + # Initializes *vec* to a vector of length *len* with elements + # in the ring *ctx*. The length must be nonnegative. + # All entries are set to zero. + + void gr_vec_clear(gr_vec_t vec, gr_ctx_t ctx) + # Clears the vector *vec*. + + gr_ptr gr_vec_entry_ptr(gr_vec_t vec, long i, gr_ctx_t ctx) + # Returns a pointer to the *i*-th element in the vector *vec*, + # indexed from zero. The index must be in bounds. + + long gr_vec_length(const gr_vec_t vec, gr_ctx_t ctx) + # Returns the length of the vector *vec*. + + void gr_vec_fit_length(gr_vec_t vec, long len, gr_ctx_t ctx) + # Allocates space for at least *len* elements in the vector *vec*. + # This does not change the size of the vector. + + void gr_vec_set_length(gr_vec_t vec, long len, gr_ctx_t ctx) + # Resizes the vector to length *len*, which must be nonnegative. + # The vector will be extended with zeros. + + int gr_vec_set(gr_vec_t res, const gr_vec_t src, gr_ctx_t ctx) + # Sets *res* to a copy of the vector *src*. + + int gr_vec_append(gr_vec_t vec, gr_srcptr x, gr_ctx_t ctx) + # Appends the element *x* to the end of vector *vec*. + + int _gr_vec_write(gr_stream_t out, gr_srcptr vec, long len, gr_ctx_t ctx) + int gr_vec_write(gr_stream_t out, const gr_vec_t vec, gr_ctx_t ctx) + int gr_vec_print(const gr_vec_t vec, gr_ctx_t ctx) + + void _gr_vec_init(gr_ptr vec, long len, gr_ctx_t ctx) + # Initialize *len* elements of *vec* to the value 0. + # The pointer *vec* must already refer to allocated memory. + + void _gr_vec_clear(gr_ptr vec, long len, gr_ctx_t ctx) + # Clears *len* elements of *vec*. + # This frees memory allocated by individual elements, but + # does not free the memory allocated by *vec* itself. + + void _gr_vec_swap(gr_ptr vec1, gr_ptr vec2, long len, gr_ctx_t ctx) + # Swap the entries of *vec1* and *vec2*. + + int _gr_vec_randtest(gr_ptr res, flint_rand_t state, long len, gr_ctx_t ctx) + + int _gr_vec_set(gr_ptr res, gr_srcptr src, long len, gr_ctx_t ctx) + + truth_t _gr_vec_equal(gr_srcptr vec1, gr_srcptr vec2, long len, gr_ctx_t ctx) + + int _gr_vec_zero(gr_ptr vec, long len, gr_ctx_t ctx) + + truth_t _gr_vec_is_zero(gr_srcptr vec, long len, gr_ctx_t ctx) + + int _gr_vec_normalise(long * res, gr_srcptr vec, long len, gr_ctx_t ctx) + + long _gr_vec_normalise_weak(gr_srcptr vec, long len, gr_ctx_t ctx) + + int _gr_vec_neg(gr_ptr res, gr_srcptr src, long len, gr_ctx_t ctx) + + int _gr_vec_add(gr_ptr res, gr_srcptr src1, gr_srcptr src2, long len, gr_ctx_t ctx) + int _gr_vec_sub(gr_ptr res, gr_srcptr src1, gr_srcptr src2, long len, gr_ctx_t ctx) + int _gr_vec_mul(gr_ptr res, gr_srcptr src1, gr_srcptr src2, long len, gr_ctx_t ctx) + int _gr_vec_div(gr_ptr res, gr_srcptr src1, gr_srcptr src2, long len, gr_ctx_t ctx) + int _gr_vec_divexact(gr_ptr res, gr_srcptr src1, gr_srcptr src2, long len, gr_ctx_t ctx) + int _gr_vec_pow(gr_ptr res, gr_srcptr src1, gr_srcptr src2, long len, gr_ctx_t ctx) + # Binary operations applied elementwise. + + int _gr_vec_add_scalar(gr_ptr vec1, gr_srcptr vec2, long len, gr_srcptr c, gr_ctx_t ctx) + int _gr_vec_sub_scalar(gr_ptr vec1, gr_srcptr vec2, long len, gr_srcptr c, gr_ctx_t ctx) + int _gr_vec_mul_scalar(gr_ptr vec1, gr_srcptr vec2, long len, gr_srcptr c, gr_ctx_t ctx) + int _gr_vec_div_scalar(gr_ptr vec1, gr_srcptr vec2, long len, gr_srcptr c, gr_ctx_t ctx) + int _gr_vec_divexact_scalar(gr_ptr vec1, gr_srcptr vec2, long len, gr_srcptr c, gr_ctx_t ctx) + int _gr_vec_pow_scalar(gr_ptr vec1, gr_srcptr vec2, long len, gr_srcptr c, gr_ctx_t ctx) + int _gr_scalar_add_vec(gr_ptr vec1, gr_srcptr c, gr_srcptr vec2, long len, gr_ctx_t ctx) + int _gr_scalar_sub_vec(gr_ptr vec1, gr_srcptr c, gr_srcptr vec2, long len, gr_ctx_t ctx) + int _gr_scalar_mul_vec(gr_ptr vec1, gr_srcptr c, gr_srcptr vec2, long len, gr_ctx_t ctx) + int _gr_scalar_div_vec(gr_ptr vec1, gr_srcptr c, gr_srcptr vec2, long len, gr_ctx_t ctx) + int _gr_scalar_divexact_vec(gr_ptr vec1, gr_srcptr c, gr_srcptr vec2, long len, gr_ctx_t ctx) + int _gr_scalar_pow_vec(gr_ptr vec1, gr_srcptr c, gr_srcptr vec2, long len, gr_ctx_t ctx) + # Binary operations applied elementwise with a fixed scalar operand. + + int _gr_vec_add_other(gr_ptr vec1, gr_srcptr vec2, gr_srcptr vec3, gr_ctx_t ctx3, long len, gr_ctx_t ctx) + int _gr_vec_sub_other(gr_ptr vec1, gr_srcptr vec2, gr_srcptr vec3, gr_ctx_t ctx3, long len, gr_ctx_t ctx) + int _gr_vec_mul_other(gr_ptr vec1, gr_srcptr vec2, gr_srcptr vec3, gr_ctx_t ctx3, long len, gr_ctx_t ctx) + int _gr_vec_div_other(gr_ptr vec1, gr_srcptr vec2, gr_srcptr vec3, gr_ctx_t ctx3, long len, gr_ctx_t ctx) + int _gr_vec_divexact_other(gr_ptr vec1, gr_srcptr vec2, gr_srcptr vec3, gr_ctx_t ctx3, long len, gr_ctx_t ctx) + int _gr_vec_pow_other(gr_ptr vec1, gr_srcptr vec2, gr_srcptr vec3, gr_ctx_t ctx3, long len, gr_ctx_t ctx) + int _gr_other_add_vec(gr_ptr vec1, gr_srcptr vec2, gr_ctx_t ctx2, gr_srcptr vec3, long len, gr_ctx_t ctx) + int _gr_other_sub_vec(gr_ptr vec1, gr_srcptr vec2, gr_ctx_t ctx2, gr_srcptr vec3, long len, gr_ctx_t ctx) + int _gr_other_mul_vec(gr_ptr vec1, gr_srcptr vec2, gr_ctx_t ctx2, gr_srcptr vec3, long len, gr_ctx_t ctx) + int _gr_other_div_vec(gr_ptr vec1, gr_srcptr vec2, gr_ctx_t ctx2, gr_srcptr vec3, long len, gr_ctx_t ctx) + int _gr_other_divexact_vec(gr_ptr vec1, gr_srcptr vec2, gr_ctx_t ctx2, gr_srcptr vec3, long len, gr_ctx_t ctx) + int _gr_other_pow_vec(gr_ptr vec1, gr_srcptr vec2, gr_ctx_t ctx2, gr_srcptr vec3, long len, gr_ctx_t ctx) + # Binary operations applied elementwise, allowing a different type for one of the vectors. + + int _gr_vec_add_scalar_other(gr_ptr vec1, gr_srcptr vec2, long len, gr_srcptr c, gr_ctx_t cctx, gr_ctx_t ctx) + int _gr_vec_sub_scalar_other(gr_ptr vec1, gr_srcptr vec2, long len, gr_srcptr c, gr_ctx_t cctx, gr_ctx_t ctx) + int _gr_vec_mul_scalar_other(gr_ptr vec1, gr_srcptr vec2, long len, gr_srcptr c, gr_ctx_t cctx, gr_ctx_t ctx) + int _gr_vec_div_scalar_other(gr_ptr vec1, gr_srcptr vec2, long len, gr_srcptr c, gr_ctx_t cctx, gr_ctx_t ctx) + int _gr_vec_divexact_scalar_other(gr_ptr vec1, gr_srcptr vec2, long len, gr_srcptr c, gr_ctx_t cctx, gr_ctx_t ctx) + int _gr_vec_pow_scalar_other(gr_ptr vec1, gr_srcptr vec2, long len, gr_srcptr c, gr_ctx_t cctx, gr_ctx_t ctx) + int _gr_scalar_other_add_vec(gr_ptr vec1, gr_srcptr c, gr_ctx_t cctx, gr_srcptr vec2, long len, gr_ctx_t ctx) + int _gr_scalar_other_sub_vec(gr_ptr vec1, gr_srcptr c, gr_ctx_t cctx, gr_srcptr vec2, long len, gr_ctx_t ctx) + int _gr_scalar_other_mul_vec(gr_ptr vec1, gr_srcptr c, gr_ctx_t cctx, gr_srcptr vec2, long len, gr_ctx_t ctx) + int _gr_scalar_other_div_vec(gr_ptr vec1, gr_srcptr c, gr_ctx_t cctx, gr_srcptr vec2, long len, gr_ctx_t ctx) + int _gr_scalar_other_divexact_vec(gr_ptr vec1, gr_srcptr c, gr_ctx_t cctx, gr_srcptr vec2, long len, gr_ctx_t ctx) + int _gr_scalar_other_pow_vec(gr_ptr vec1, gr_srcptr c, gr_ctx_t cctx, gr_srcptr vec2, long len, gr_ctx_t ctx) + int _gr_vec_add_scalar_si(gr_ptr vec1, gr_srcptr vec2, long len, long c, gr_ctx_t ctx) + int _gr_vec_sub_scalar_si(gr_ptr vec1, gr_srcptr vec2, long len, long c, gr_ctx_t ctx) + int _gr_vec_mul_scalar_si(gr_ptr vec1, gr_srcptr vec2, long len, long c, gr_ctx_t ctx) + int _gr_vec_div_scalar_si(gr_ptr vec1, gr_srcptr vec2, long len, long c, gr_ctx_t ctx) + int _gr_vec_divexact_scalar_si(gr_ptr vec1, gr_srcptr vec2, long len, long c, gr_ctx_t ctx) + int _gr_vec_pow_scalar_si(gr_ptr vec1, gr_srcptr vec2, long len, long c, gr_ctx_t ctx) + int _gr_vec_add_scalar_ui(gr_ptr vec1, gr_srcptr vec2, long len, unsigned long c, gr_ctx_t ctx) + int _gr_vec_sub_scalar_ui(gr_ptr vec1, gr_srcptr vec2, long len, unsigned long c, gr_ctx_t ctx) + int _gr_vec_mul_scalar_ui(gr_ptr vec1, gr_srcptr vec2, long len, unsigned long c, gr_ctx_t ctx) + int _gr_vec_div_scalar_ui(gr_ptr vec1, gr_srcptr vec2, long len, unsigned long c, gr_ctx_t ctx) + int _gr_vec_divexact_scalar_ui(gr_ptr vec1, gr_srcptr vec2, long len, unsigned long c, gr_ctx_t ctx) + int _gr_vec_pow_scalar_ui(gr_ptr vec1, gr_srcptr vec2, long len, unsigned long c, gr_ctx_t ctx) + int _gr_vec_add_scalar_fmpz(gr_ptr vec1, gr_srcptr vec2, long len, const fmpz_t c, gr_ctx_t ctx) + int _gr_vec_sub_scalar_fmpz(gr_ptr vec1, gr_srcptr vec2, long len, const fmpz_t c, gr_ctx_t ctx) + int _gr_vec_mul_scalar_fmpz(gr_ptr vec1, gr_srcptr vec2, long len, const fmpz_t c, gr_ctx_t ctx) + int _gr_vec_div_scalar_fmpz(gr_ptr vec1, gr_srcptr vec2, long len, const fmpz_t c, gr_ctx_t ctx) + int _gr_vec_divexact_scalar_fmpz(gr_ptr vec1, gr_srcptr vec2, long len, const fmpz_t c, gr_ctx_t ctx) + int _gr_vec_pow_scalar_fmpz(gr_ptr vec1, gr_srcptr vec2, long len, const fmpz_t c, gr_ctx_t ctx) + int _gr_vec_add_scalar_fmpq(gr_ptr vec1, gr_srcptr vec2, long len, const fmpq_t c, gr_ctx_t ctx) + int _gr_vec_sub_scalar_fmpq(gr_ptr vec1, gr_srcptr vec2, long len, const fmpq_t c, gr_ctx_t ctx) + int _gr_vec_mul_scalar_fmpq(gr_ptr vec1, gr_srcptr vec2, long len, const fmpq_t c, gr_ctx_t ctx) + int _gr_vec_div_scalar_fmpq(gr_ptr vec1, gr_srcptr vec2, long len, const fmpq_t c, gr_ctx_t ctx) + int _gr_vec_divexact_scalar_fmpq(gr_ptr vec1, gr_srcptr vec2, long len, const fmpq_t c, gr_ctx_t ctx) + int _gr_vec_pow_scalar_fmpq(gr_ptr vec1, gr_srcptr vec2, long len, const fmpq_t c, gr_ctx_t ctx) + # Binary operations applied elementwise with a fixed scalar operand, allowing a different type + # for the scalar. + + int _gr_vec_addmul_scalar(gr_ptr vec1, gr_srcptr vec2, long len, gr_srcptr c, gr_ctx_t ctx) + int _gr_vec_submul_scalar(gr_ptr vec1, gr_srcptr vec2, long len, gr_srcptr c, gr_ctx_t ctx) + int _gr_vec_addmul_scalar_si(gr_ptr vec1, gr_srcptr vec2, long len, long c, gr_ctx_t ctx) + int _gr_vec_submul_scalar_si(gr_ptr vec1, gr_srcptr vec2, long len, long c, gr_ctx_t ctx) + + int _gr_vec_mul_scalar_2exp_si(gr_ptr res, gr_srcptr vec, long len, long c, gr_ctx_t ctx) + + int _gr_vec_sum(gr_ptr res, gr_srcptr vec, long len, gr_ctx_t ctx) + + int _gr_vec_product(gr_ptr res, gr_srcptr vec, long len, gr_ctx_t ctx) + + int _gr_vec_dot(gr_ptr res, gr_srcptr initial, int subtract, gr_srcptr vec1, gr_srcptr vec2, long len, gr_ctx_t ctx) + int _gr_vec_dot_si(gr_ptr res, gr_srcptr initial, int subtract, gr_srcptr vec1, const long * vec2, long len, gr_ctx_t ctx) + int _gr_vec_dot_ui(gr_ptr res, gr_srcptr initial, int subtract, gr_srcptr vec1, const unsigned long * vec2, long len, gr_ctx_t ctx) + int _gr_vec_dot_fmpz(gr_ptr res, gr_srcptr initial, int subtract, gr_srcptr vec1, const fmpz * vec2, long len, gr_ctx_t ctx) + # Sets *res* to `c \pm \sum_{i=0}^{n-1} a_i b_i`. + + int _gr_vec_dot_rev(gr_ptr res, gr_srcptr initial, int subtract, gr_srcptr vec1, gr_srcptr vec2, long len, gr_ctx_t ctx) + # Sets *res* to `c \pm \sum_{i=0}^{n-1} a_i b_{n-1-i}`. + + int _gr_vec_step(gr_ptr vec, gr_srcptr start, gr_srcptr step, long len, gr_ctx_t ctx) + + int _gr_vec_reciprocals(gr_ptr res, long len, gr_ctx_t ctx) + # Sets *res* to the vector of reciprocals of the positive integers 1, 2, ... up to *len* inclusive. + + int _gr_vec_set_powers(gr_ptr res, gr_srcptr x, long len, gr_ctx_t ctx) diff --git a/src/sage/libs/flint/mag.pxd b/src/sage/libs/flint/mag.pxd new file mode 100644 index 00000000000..e288fc1ad74 --- /dev/null +++ b/src/sage/libs/flint/mag.pxd @@ -0,0 +1,365 @@ +# distutils: libraries = flint +# distutils: depends = flint/mag.h + +################################################################################ +# This file is auto-generated. Do not modify by hand +################################################################################ + +from libc.stdio cimport FILE +from sage.libs.gmp.types cimport * +from sage.libs.mpfr.types cimport * +from sage.libs.flint.types cimport * + +cdef extern from "flint_wrap.h": + + void mag_init(mag_t x) + # Initializes the variable *x* for use. Its value is set to zero. + + void mag_clear(mag_t x) + # Clears the variable *x*, freeing or recycling its allocated memory. + + void mag_swap(mag_t x, mag_t y) + # Swaps *x* and *y* efficiently. + + mag_ptr _mag_vec_init(long n) + # Allocates a vector of length *n*. All entries are set to zero. + + void _mag_vec_clear(mag_ptr v, long n) + # Clears a vector of length *n*. + + long mag_allocated_bytes(const mag_t x) + # Returns the total number of bytes heap-allocated internally by this object. + # The count excludes the size of the structure itself. Add + # ``sizeof(mag_struct)`` to get the size of the object as a whole. + + void mag_zero(mag_t res) + # Sets *res* to zero. + + void mag_one(mag_t res) + # Sets *res* to one. + + void mag_inf(mag_t res) + # Sets *res* to positive infinity. + + int mag_is_special(const mag_t x) + # Returns nonzero iff *x* is zero or positive infinity. + + int mag_is_zero(const mag_t x) + # Returns nonzero iff *x* is zero. + + int mag_is_inf(const mag_t x) + # Returns nonzero iff *x* is positive infinity. + + int mag_is_finite(const mag_t x) + # Returns nonzero iff *x* is not positive infinity (since there is no + # NaN value, this function is exactly the logical negation of :func:`mag_is_inf`). + + void mag_init_set(mag_t res, const mag_t x) + # Initializes *res* and sets it to the value of *x*. This operation is always exact. + + void mag_set(mag_t res, const mag_t x) + # Sets *res* to the value of *x*. This operation is always exact. + + void mag_set_d(mag_t res, double x) + + void mag_set_ui(mag_t res, unsigned long x) + + void mag_set_fmpz(mag_t res, const fmpz_t x) + # Sets *res* to an upper bound for `|x|`. The operation may be inexact + # even if *x* is exactly representable. + + void mag_set_d_lower(mag_t res, double x) + + void mag_set_ui_lower(mag_t res, unsigned long x) + + void mag_set_fmpz_lower(mag_t res, const fmpz_t x) + # Sets *res* to a lower bound for `|x|`. + # The operation may be inexact even if *x* is exactly representable. + + void mag_set_d_2exp_fmpz(mag_t res, double x, const fmpz_t y) + + void mag_set_fmpz_2exp_fmpz(mag_t res, const fmpz_t x, const fmpz_t y) + + void mag_set_ui_2exp_si(mag_t res, unsigned long x, long y) + # Sets *res* to an upper bound for `|x| \cdot 2^y`. + + void mag_set_d_2exp_fmpz_lower(mag_t res, double x, const fmpz_t y) + + void mag_set_fmpz_2exp_fmpz_lower(mag_t res, const fmpz_t x, const fmpz_t y) + # Sets *res* to a lower bound for `|x| \cdot 2^y`. + + double mag_get_d(const mag_t x) + # Returns a *double* giving an upper bound for *x*. + + double mag_get_d_log2_approx(const mag_t x) + # Returns a *double* approximating `\log_2(x)`, suitable for estimating + # magnitudes (warning: not a rigorous bound). + # The value is clamped between *COEFF_MIN* and *COEFF_MAX*. + + void mag_get_fmpq(fmpq_t res, const mag_t x) + + void mag_get_fmpz(fmpz_t res, const mag_t x) + + void mag_get_fmpz_lower(fmpz_t res, const mag_t x) + # Sets *res*, respectively, to the exact rational number represented by *x*, + # the integer exactly representing the ceiling function of *x*, or the + # integer exactly representing the floor function of *x*. + # These functions are unsafe: the user must check in advance that *x* is of + # reasonable magnitude. If *x* is infinite or has a bignum exponent, an + # abort will be raised. If the exponent otherwise is too large or too small, + # the available memory could be exhausted resulting in undefined behavior. + + int mag_equal(const mag_t x, const mag_t y) + # Returns nonzero iff *x* and *y* have the same value. + + int mag_cmp(const mag_t x, const mag_t y) + # Returns negative, zero, or positive, depending on whether *x* + # is smaller, equal, or larger than *y*. + + int mag_cmp_2exp_si(const mag_t x, long y) + # Returns negative, zero, or positive, depending on whether *x* + # is smaller, equal, or larger than `2^y`. + + void mag_min(mag_t res, const mag_t x, const mag_t y) + + void mag_max(mag_t res, const mag_t x, const mag_t y) + # Sets *res* respectively to the smaller or the larger of *x* and *y*. + + void mag_print(const mag_t x) + # Prints *x* to standard output. + + void mag_fprint(FILE * file, const mag_t x) + # Prints *x* to the stream *file*. + + char * mag_dump_str(const mag_t x) + # Allocates a string and writes a binary representation of *x* to it that can + # be read by :func:`mag_load_str`. The returned string needs to be + # deallocated with *flint_free*. + + int mag_load_str(mag_t x, const char * str) + # Parses *str* into *x*. Returns a nonzero value if *str* is not formatted + # correctly. + + int mag_dump_file(FILE * stream, const mag_t x) + # Writes a binary representation of *x* to *stream* that can be read by + # :func:`mag_load_file`. Returns a nonzero value if the data could not be + # written. + + int mag_load_file(mag_t x, FILE * stream) + # Reads *x* from *stream*. Returns a nonzero value if the data is not + # formatted correctly or the read failed. Note that the data is assumed to be + # delimited by a whitespace or end-of-file, i.e., when writing multiple + # values with :func:`mag_dump_file` make sure to insert a whitespace to + # separate consecutive values. + + void mag_randtest(mag_t res, flint_rand_t state, long expbits) + # Sets *res* to a random finite value, with an exponent up to *expbits* bits large. + + void mag_randtest_special(mag_t res, flint_rand_t state, long expbits) + # Like :func:`mag_randtest`, but also sometimes sets *res* to infinity. + + void mag_add(mag_t res, const mag_t x, const mag_t y) + + void mag_add_ui(mag_t res, const mag_t x, unsigned long y) + # Sets *res* to an upper bound for `x + y`. + + void mag_add_lower(mag_t res, const mag_t x, const mag_t y) + + void mag_add_ui_lower(mag_t res, const mag_t x, unsigned long y) + # Sets *res* to a lower bound for `x + y`. + + void mag_add_2exp_fmpz(mag_t res, const mag_t x, const fmpz_t e) + # Sets *res* to an upper bound for `x + 2^e`. + + void mag_add_ui_2exp_si(mag_t res, const mag_t x, unsigned long y, long e) + # Sets *res* to an upper bound for `x + y 2^e`. + + void mag_sub(mag_t res, const mag_t x, const mag_t y) + # Sets *res* to an upper bound for `\max(x-y, 0)`. + + void mag_sub_lower(mag_t res, const mag_t x, const mag_t y) + # Sets *res* to a lower bound for `\max(x-y, 0)`. + + void mag_mul_2exp_si(mag_t res, const mag_t x, long y) + + void mag_mul_2exp_fmpz(mag_t res, const mag_t x, const fmpz_t y) + # Sets *res* to `x \cdot 2^y`. This operation is exact. + + void mag_mul(mag_t res, const mag_t x, const mag_t y) + + void mag_mul_ui(mag_t res, const mag_t x, unsigned long y) + + void mag_mul_fmpz(mag_t res, const mag_t x, const fmpz_t y) + # Sets *res* to an upper bound for `xy`. + + void mag_mul_lower(mag_t res, const mag_t x, const mag_t y) + + void mag_mul_ui_lower(mag_t res, const mag_t x, unsigned long y) + + void mag_mul_fmpz_lower(mag_t res, const mag_t x, const fmpz_t y) + # Sets *res* to a lower bound for `xy`. + + void mag_addmul(mag_t z, const mag_t x, const mag_t y) + # Sets *z* to an upper bound for `z + xy`. + + void mag_div(mag_t res, const mag_t x, const mag_t y) + + void mag_div_ui(mag_t res, const mag_t x, unsigned long y) + + void mag_div_fmpz(mag_t res, const mag_t x, const fmpz_t y) + # Sets *res* to an upper bound for `x / y`. + + void mag_div_lower(mag_t res, const mag_t x, const mag_t y) + # Sets *res* to a lower bound for `x / y`. + + void mag_inv(mag_t res, const mag_t x) + # Sets *res* to an upper bound for `1 / x`. + + void mag_inv_lower(mag_t res, const mag_t x) + # Sets *res* to a lower bound for `1 / x`. + + void mag_fast_init_set(mag_t x, const mag_t y) + # Initialises *x* and sets it to the value of *y*. + + void mag_fast_zero(mag_t res) + # Sets *res* to zero. + + int mag_fast_is_zero(const mag_t x) + # Returns nonzero iff *x* to zero. + + void mag_fast_mul(mag_t res, const mag_t x, const mag_t y) + # Sets *res* to an upper bound for `xy`. + + void mag_fast_addmul(mag_t z, const mag_t x, const mag_t y) + # Sets *z* to an upper bound for `z + xy`. + + void mag_fast_add_2exp_si(mag_t res, const mag_t x, long e) + # Sets *res* to an upper bound for `x + 2^e`. + + void mag_fast_mul_2exp_si(mag_t res, const mag_t x, long e) + # Sets *res* to an upper bound for `x 2^e`. + + void mag_pow_ui(mag_t res, const mag_t x, unsigned long e) + + void mag_pow_fmpz(mag_t res, const mag_t x, const fmpz_t e) + # Sets *res* to an upper bound for `x^e`. + + void mag_pow_ui_lower(mag_t res, const mag_t x, unsigned long e) + + void mag_pow_fmpz_lower(mag_t res, const mag_t x, const fmpz_t e) + # Sets *res* to a lower bound for `x^e`. + + void mag_sqrt(mag_t res, const mag_t x) + # Sets *res* to an upper bound for `\sqrt{x}`. + + void mag_sqrt_lower(mag_t res, const mag_t x) + # Sets *res* to a lower bound for `\sqrt{x}`. + + void mag_rsqrt(mag_t res, const mag_t x) + # Sets *res* to an upper bound for `1/\sqrt{x}`. + + void mag_rsqrt_lower(mag_t res, const mag_t x) + # Sets *res* to an lower bound for `1/\sqrt{x}`. + + void mag_hypot(mag_t res, const mag_t x, const mag_t y) + # Sets *res* to an upper bound for `\sqrt{x^2 + y^2}`. + + void mag_root(mag_t res, const mag_t x, unsigned long n) + # Sets *res* to an upper bound for `x^{1/n}`. + + void mag_log(mag_t res, const mag_t x) + # Sets *res* to an upper bound for `\log(\max(1,x))`. + + void mag_log_lower(mag_t res, const mag_t x) + # Sets *res* to a lower bound for `\log(\max(1,x))`. + + void mag_neg_log(mag_t res, const mag_t x) + # Sets *res* to an upper bound for `-\log(\min(1,x))`, i.e. an upper + # bound for `|\log(x)|` for `x \le 1`. + + void mag_neg_log_lower(mag_t res, const mag_t x) + # Sets *res* to a lower bound for `-\log(\min(1,x))`, i.e. a lower + # bound for `|\log(x)|` for `x \le 1`. + + void mag_log_ui(mag_t res, unsigned long n) + # Sets *res* to an upper bound for `\log(n)`. + + void mag_log1p(mag_t res, const mag_t x) + # Sets *res* to an upper bound for `\log(1+x)`. The bound is computed + # accurately for small *x*. + + void mag_exp(mag_t res, const mag_t x) + # Sets *res* to an upper bound for `\exp(x)`. + + void mag_exp_lower(mag_t res, const mag_t x) + # Sets *res* to a lower bound for `\exp(x)`. + + void mag_expinv(mag_t res, const mag_t x) + # Sets *res* to an upper bound for `\exp(-x)`. + + void mag_expinv_lower(mag_t res, const mag_t x) + # Sets *res* to a lower bound for `\exp(-x)`. + + void mag_expm1(mag_t res, const mag_t x) + # Sets *res* to an upper bound for `\exp(x) - 1`. The bound is computed + # accurately for small *x*. + + void mag_exp_tail(mag_t res, const mag_t x, unsigned long N) + # Sets *res* to an upper bound for `\sum_{k=N}^{\infty} x^k / k!`. + + void mag_binpow_uiui(mag_t res, unsigned long m, unsigned long n) + # Sets *res* to an upper bound for `(1 + 1/m)^n`. + + void mag_geom_series(mag_t res, const mag_t x, unsigned long N) + # Sets *res* to an upper bound for `\sum_{k=N}^{\infty} x^k`. + + void mag_const_pi(mag_t res) + + void mag_const_pi_lower(mag_t res) + # Sets *res* to an upper (respectively lower) bound for `\pi`. + + void mag_atan(mag_t res, const mag_t x) + + void mag_atan_lower(mag_t res, const mag_t x) + # Sets *res* to an upper (respectively lower) bound for `\operatorname{atan}(x)`. + + void mag_cosh(mag_t res, const mag_t x) + + void mag_cosh_lower(mag_t res, const mag_t x) + + void mag_sinh(mag_t res, const mag_t x) + + void mag_sinh_lower(mag_t res, const mag_t x) + # Sets *res* to an upper or lower bound for `\cosh(x)` or `\sinh(x)`. + + void mag_fac_ui(mag_t res, unsigned long n) + # Sets *res* to an upper bound for `n!`. + + void mag_rfac_ui(mag_t res, unsigned long n) + # Sets *res* to an upper bound for `1/n!`. + + void mag_bin_uiui(mag_t res, unsigned long n, unsigned long k) + # Sets *res* to an upper bound for the binomial coefficient `{n \choose k}`. + + void mag_bernoulli_div_fac_ui(mag_t res, unsigned long n) + # Sets *res* to an upper bound for `|B_n| / n!` where `B_n` denotes + # a Bernoulli number. + + void mag_polylog_tail(mag_t res, const mag_t z, long s, unsigned long d, unsigned long N) + # Sets *res* to an upper bound for + # .. math :: + # \sum_{k=N}^{\infty} \frac{z^k \log^d(k)}{k^s}. + # The bounding strategy is described in :ref:`algorithms_polylogarithms`. + # Note: in applications where `s` in this formula may be + # real or complex, the user can simply + # substitute any convenient integer `s'` such that `s' \le \operatorname{Re}(s)`. + + void mag_hurwitz_zeta_uiui(mag_t res, unsigned long s, unsigned long a) + # Sets *res* to an upper bound for `\zeta(s,a) = \sum_{k=0}^{\infty} (k+a)^{-s}`. + # We use the formula + # .. math :: + # \zeta(s,a) \le \frac{1}{a^s} + \frac{1}{(s-1) a^{s-1}} + # which is obtained by estimating the sum by an integral. + # If `s \le 1` or `a = 0`, the bound is infinite. + +from .mag_macros cimport * diff --git a/src/sage/libs/flint/mag_macros.pxd b/src/sage/libs/flint/mag_macros.pxd new file mode 100644 index 00000000000..52bd50a906a --- /dev/null +++ b/src/sage/libs/flint/mag_macros.pxd @@ -0,0 +1,8 @@ +# Macros from mag.h +# See https://github.com/flintlib/flint/issues/152 + +from .types cimport * + +cdef extern from "flint_wrap.h": + long MAG_BITS + diff --git a/src/sage/libs/flint/mpoly.pxd b/src/sage/libs/flint/mpoly.pxd new file mode 100644 index 00000000000..51c9a1ae939 --- /dev/null +++ b/src/sage/libs/flint/mpoly.pxd @@ -0,0 +1,281 @@ +# distutils: libraries = flint +# distutils: depends = flint/mpoly.h + +################################################################################ +# This file is auto-generated. Do not modify by hand +################################################################################ + +from libc.stdio cimport FILE +from sage.libs.gmp.types cimport * +from sage.libs.mpfr.types cimport * +from sage.libs.flint.types cimport * + +cdef extern from "flint_wrap.h": + + void mpoly_ctx_init(mpoly_ctx_t ctx, long nvars, const ordering_t ord) + # Initialize a context for specified number of variables and ordering. + + void mpoly_ctx_clear(mpoly_ctx_t mctx) + # Clean up any space used by a context object. + + ordering_t mpoly_ordering_randtest(flint_rand_t state) + # Return a random ordering. The possibilities are ``ORD_LEX``, + # ``ORD_DEGLEX`` and ``ORD_DEGREVLEX``. + + void mpoly_ctx_init_rand(mpoly_ctx_t mctx, flint_rand_t state, long max_nvars) + # Initialize a context with a random choice for the ordering. + + int mpoly_ordering_isdeg(const mpoly_ctx_t ctx) + # Return 1 if the ordering of the given context is a degree ordering (deglex or degrevlex). + + int mpoly_ordering_isrev(const mpoly_ctx_t cth) + # Return 1 if the ordering of the given context is a reverse ordering (currently only + # degrevlex). + + void mpoly_ordering_print(ordering_t ord) + # Print a string (either "lex", "deglex" or "degrevlex") to standard + # output, corresponding to the given ordering. + + void mpoly_monomial_add(unsigned long * exp_ptr, const unsigned long * exp2, const unsigned long * exp3, long N) + # Set ``(exp_ptr, N)`` to the sum of the monomials ``(exp2, N)`` and + # ``(exp3, N)``, assuming ``bits <= FLINT_BITS`` + + void mpoly_monomial_add_mp(unsigned long * exp_ptr, const unsigned long * exp2, const unsigned long * exp3, long N) + # Set ``(exp_ptr, N)`` to the sum of the monomials ``(exp2, N)`` and + # ``(exp3, N)``. + + void mpoly_monomial_sub(unsigned long * exp_ptr, const unsigned long * exp2, const unsigned long * exp3, long N) + # Set ``(exp_ptr, N)`` to the difference of the monomials ``(exp2, N)`` and ``(exp3, N)``, assuming ``bits <= FLINT_BITS`` + + void mpoly_monomial_sub_mp(unsigned long * exp_ptr, const unsigned long * exp2, const unsigned long * exp3, long N) + # Set ``(exp_ptr, N)`` to the difference of the monomials ``(exp2, N)`` and ``(exp3, N)``. + + int mpoly_monomial_overflows(unsigned long * exp2, long N, unsigned long mask) + # Return true if any of the fields of the given monomial ``(exp2, N)`` has + # overflowed (or is negative). The ``mask`` is a word with the high bit of + # each field set to 1. In other words, the function returns 1 if any word of + # ``exp2`` has any of the nonzero bits in ``mask`` set. Assumes that + # ``bits <= FLINT_BITS``. + + int mpoly_monomial_overflows_mp(unsigned long * exp_ptr, long N, flint_bitcnt_t bits) + # Return true if any of the fields of the given monomial ``(exp_ptr, N)`` + # has overflowed. Assumes that ``bits >= FLINT_BITS``. + + int mpoly_monomial_overflows1(unsigned long exp, unsigned long mask) + # As per ``mpoly_monomial_overflows`` with ``N = 1``. + + void mpoly_monomial_set(unsigned long * exp2, const unsigned long * exp3, long N) + # Set the monomial ``(exp2, N)`` to ``(exp3, N)``. + + void mpoly_monomial_swap(unsigned long * exp2, unsigned long * exp3, long N) + # Swap the words in ``(exp2, N)`` and ``(exp3, N)``. + + void mpoly_monomial_mul_ui(unsigned long * exp2, const unsigned long * exp3, long N, unsigned long c) + # Set the words of ``(exp2, N)`` to the words of ``(exp3, N)`` + # multiplied by ``c``. + + int mpoly_monomial_is_zero(const unsigned long * exp, long N) + # Return 1 if ``(exp, N)`` is zero. + + int mpoly_monomial_equal(const unsigned long * exp2, const unsigned long * exp3, long N) + # Return 1 if the monomials ``(exp2, N)`` and ``(exp3, N)`` are equal. + + void mpoly_get_cmpmask(unsigned long * cmpmask, long N, unsigned long bits, const mpoly_ctx_t mctx) + # Get the mask ``(cmpmask, N)`` for comparisons. + # ``bits`` should be set to the number of bits in the exponents + # to be compared. Any function that compares monomials should use this + # comparison mask. + + int mpoly_monomial_lt(const unsigned long * exp2, const unsigned long * exp3, long N, const unsigned long * cmpmask) + # Return 1 if ``(exp2, N)`` is less than ``(exp3, N)``. + + int mpoly_monomial_gt(const unsigned long * exp2, const unsigned long * exp3, long N, const unsigned long * cmpmask) + # Return 1 if ``(exp2, N)`` is greater than ``(exp3, N)``. + + int mpoly_monomial_cmp(const unsigned long * exp2, const unsigned long * exp3, long N, const unsigned long * cmpmask) + # Return `1` if ``(exp2, N)`` is greater than, `0` if it is equal to and + # `-1` if it is less than ``(exp3, N)``. + + int mpoly_monomial_divides(unsigned long * exp_ptr, const unsigned long * exp2, const unsigned long * exp3, long N, unsigned long mask) + # Return 1 if the monomial ``(exp3, N)`` divides ``(exp2, N)``. If so + # set ``(exp_ptr, N)`` to the quotient monomial. The ``mask`` is a word + # with the high bit of each bit field set to 1. Assumes that + # ``bits <= FLINT_BITS``. + + int mpoly_monomial_divides_mp(unsigned long * exp_ptr, const unsigned long * exp2, const unsigned long * exp3, long N, flint_bitcnt_t bits) + # Return 1 if the monomial ``(exp3, N)`` divides ``(exp2, N)``. If so + # set ``(exp_ptr, N)`` to the quotient monomial. Assumes that + # ``bits >= FLINT_BITS``. + + int mpoly_monomial_divides1(unsigned long * exp_ptr, const unsigned long exp2, const unsigned long exp3, unsigned long mask) + # As per ``mpoly_monomial_divides`` with ``N = 1``. + + int mpoly_monomial_divides_tight(long e1, long e2, long * prods, long num) + # Return 1 if the monomial ``e2`` divides the monomial ``e1``, where + # the monomials are stored using factorial representation. The array + # ``(prods, num)`` should consist of `1`, `b_1, b_1\times b_2, \ldots`, + # where the `b_i` are the bases of the factorial number representation. + + flint_bitcnt_t mpoly_exp_bits_required_ui(const unsigned long * user_exp, const mpoly_ctx_t mctx) + # Returns the number of bits required to store ``user_exp`` in packed + # format. The returned number of bits includes space for a zeroed signed bit. + + flint_bitcnt_t mpoly_exp_bits_required_ffmpz(const fmpz * user_exp, const mpoly_ctx_t mctx) + # Returns the number of bits required to store ``user_exp`` in packed + # format. The returned number of bits includes space for a zeroed signed bit. + + flint_bitcnt_t mpoly_exp_bits_required_pfmpz(fmpz * const * user_exp, const mpoly_ctx_t mctx) + # Returns the number of bits required to store ``user_exp`` in packed + # format. The returned number of bits includes space for a zeroed signed bit. + + void mpoly_max_fields_ui_sp(unsigned long * max_fields, const unsigned long * poly_exps, long len, unsigned long bits, const mpoly_ctx_t mctx) + # Compute the field-wise maximum of packed exponents from ``poly_exps`` + # of length ``len`` and unpack the result into ``max_fields``. + # The maximums are assumed to fit a ulong. + + void mpoly_max_fields_fmpz(fmpz * max_fields, const unsigned long * poly_exps, long len, unsigned long bits, const mpoly_ctx_t mctx) + # Compute the field-wise maximum of packed exponents from ``poly_exps`` + # of length ``len`` and unpack the result into ``max_fields``. + + void mpoly_max_degrees_tight(long * max_exp, unsigned long * exps, long len, long * prods, long num) + # Return an array of ``num`` integers corresponding to the maximum degrees + # of the exponents in the array of exponent vectors ``(exps, len)``, + # assuming that the exponent are packed in a factorial representation. The + # array ``(prods, num)`` should consist of `1`, `b_1`, + # `b_1\times b_2, \ldots`, where the `b_i` are the bases of the factorial + # number representation. The results are stored in the array ``max_exp``, + # with the entry corresponding to the most significant base of the factorial + # representation first in the array. + + int mpoly_monomial_exists(long * index, const unsigned long * poly_exps, const unsigned long * exp, long len, long N, const unsigned long * cmpmask) + # Returns true if the given exponent vector ``exp`` exists in the array of + # exponent vectors ``(poly_exps, len)``, otherwise, returns false. If the + # exponent vector is found, its index into the array of exponent vectors is + # returned. Otherwise, ``index`` is set to the index where this exponent + # could be inserted to preserve the ordering. The index can be in the range + # ``[0, len]``. + + void mpoly_search_monomials(long ** e_ind, unsigned long * e, long * e_score, long * t1, long * t2, long *t3, long lower, long upper, const unsigned long * a, long a_len, const unsigned long * b, long b_len, long N, const unsigned long * cmpmask) + # Given packed exponent vectors ``a`` and ``b``, compute a packed + # exponent ``e`` such that the number of monomials in the cross product + # ``a`` X ``b`` that are less than or equal to ``e`` is between + # ``lower`` and ``upper``. This number is stored in ``e_store``. If + # no such monomial exists, one is chosen so that the number of monomials is as + # close as possible. This function assumes that ``1`` is the smallest + # monomial and needs three arrays ``t1``, ``t2``, and ``t3`` of the + # size as ``a`` for workspace. The parameter ``e_ind`` is set to one + # of ``t1``, ``t2``, and ``t3`` and gives the locations of the + # monomials in ``a`` X ``b``. + + int mpoly_term_exp_fits_ui(unsigned long * exps, unsigned long bits, long n, const mpoly_ctx_t mctx) + # Return whether every entry of the exponent vector of index `n` in + # ``exps`` fits into a ``ulong``. + + int mpoly_term_exp_fits_si(unsigned long * exps, unsigned long bits, long n, const mpoly_ctx_t mctx) + # Return whether every entry of the exponent vector of index `n` in + # ``exps`` fits into a ``slong``. + + void mpoly_get_monomial_ui(unsigned long * exps, const unsigned long * poly_exps, unsigned long bits, const mpoly_ctx_t mctx) + # Convert the packed exponent ``poly_exps`` of bit count ``bits`` to a + # monomial from the user's perspective. The exponents are assumed to fit + # a ulong. + + void mpoly_get_monomial_ffmpz(fmpz * exps, const unsigned long * poly_exps, flint_bitcnt_t bits, const mpoly_ctx_t mctx) + # Convert the packed exponent ``poly_exps`` of bit count ``bits`` to a + # monomial from the user's perspective. + + void mpoly_get_monomial_pfmpz(fmpz ** exps, const unsigned long * poly_exps, flint_bitcnt_t bits, const mpoly_ctx_t mctx) + # Convert the packed exponent ``poly_exps`` of bit count ``bits`` to a + # monomial from the user's perspective. + + void mpoly_set_monomial_ui(unsigned long * exp1, const unsigned long * exp2, unsigned long bits, const mpoly_ctx_t mctx) + # Convert the user monomial ``exp2`` to packed format using ``bits``. + + void mpoly_set_monomial_ffmpz(unsigned long * exp1, const fmpz * exp2, flint_bitcnt_t bits, const mpoly_ctx_t mctx) + # Convert the user monomial ``exp2`` to packed format using ``bits``. + + void mpoly_set_monomial_pfmpz(unsigned long * exp1, fmpz * const * exp2, flint_bitcnt_t bits, const mpoly_ctx_t mctx) + # Convert the user monomial ``exp2`` to packed format using ``bits``. + + void mpoly_pack_vec_ui(unsigned long * exp1, const unsigned long * exp2, unsigned long bits, long nfields, long len) + # Packs a vector ``exp2`` into \{exp1} using a bit count of ``bits``. + # No checking is done to ensure that the vector actually fits + # into ``bits`` bits. The number of fields in each vector is + # ``nfields`` and the total number of vectors to unpack is ``len``. + + void mpoly_pack_vec_fmpz(unsigned long * exp1, const fmpz * exp2, flint_bitcnt_t bits, long nfields, long len) + # Packs a vector ``exp2`` into \{exp1} using a bit count of ``bits``. + # No checking is done to ensure that the vector actually fits + # into ``bits`` bits. The number of fields in each vector is + # ``nfields`` and the total number of vectors to unpack is ``len``. + + void mpoly_unpack_vec_ui(unsigned long * exp1, const unsigned long * exp2, unsigned long bits, long nfields, long len) + # Unpacks vector ``exp2`` of bit count ``bits`` into ``exp1``. + # The number of fields in each vector is + # ``nfields`` and the total number of vectors to unpack is ``len``. + + void mpoly_unpack_vec_fmpz(fmpz * exp1, const unsigned long * exp2, flint_bitcnt_t bits, long nfields, long len) + # Unpacks vector ``exp2`` of bit count ``bits`` into ``exp1``. + # The number of fields in each vector is + # ``nfields`` and the total number of vectors to unpack is ``len``. + + int mpoly_repack_monomials(unsigned long * exps1, unsigned long bits1, const unsigned long * exps2, unsigned long bits2, long len, const mpoly_ctx_t mctx) + # Convert an array of length ``len`` of exponents ``exps2`` packed + # using bits ``bits2`` into an array ``exps1`` using bits ``bits1``. + # No checking is done to ensure that the result fits into bits ``bits1``. + + void mpoly_pack_monomials_tight(unsigned long * exp1, const unsigned long * exp2, long len, const long * mults, long num, long bits) + # Given an array of possibly packed exponent vectors ``exp2`` of length + # ``len``, where each field of each exponent vector is packed into the + # given number of bits, return the corresponding array of monomial vectors + # packed using a factorial numbering scheme. The "bases" for the factorial + # numbering scheme are given as an array of integers ``mults``, the first + # entry of which corresponds to the field of least significance in each + # input exponent vector. Obviously the maximum exponent to be packed must be + # less than the corresponding base in ``mults``. + # The number of multipliers is given by ``num``. The code only considers + # least significant ``num`` fields of each exponent vectors and ignores + # the rest. The number of ignored fields should be passed in ``extras``. + + void mpoly_unpack_monomials_tight(unsigned long * e1, unsigned long * e2, long len, long * mults, long num, long bits) + # Given an array of exponent vectors ``e2`` of length ``len`` packed + # using a factorial numbering scheme, unpack the monomials into an array + # ``e1`` of exponent vectors in standard packed format, where each field + # has the given number of bits. The "bases" for the factorial + # numbering scheme are given as an array of integers ``mults``, the first + # entry of which corresponds to the field of least significance in each + # exponent vector. + + void mpoly_main_variable_terms1(long * i1, long * n1, const unsigned long * exp1, long l1, long len1, long k, long num, long bits) + # Given an array of exponent vectors ``(exp1, len1)``, each exponent + # vector taking one word of space, with each exponent being packed into the + # given number of bits, compute ``l1`` starting offsets ``i1`` and + # lengths ``n1`` (which may be zero) to break the exponents into chunks. + # Each chunk consists of exponents have the same degree in the main variable. + # The index of the main variable is given by `k`. The variables are indexed + # from the variable of least significance, starting from `0`. The value + # ``l1`` should be the degree in the main variable, plus one. + + int _mpoly_heap_insert(mpoly_heap_s * heap, unsigned long * exp, void * x, long * next_loc, long * heap_len, long N, const unsigned long * cmpmask) + # Given a heap, insert a new node `x` corresponding to the given exponent + # into the heap. Heap elements are ordered by the exponent ``(exp, N)``, + # with the largest element at the head of the heap. A pointer to the current + # heap length must be passed in via ``heap_len``. This will be updated by + # the function. Note that the index 0 position in the heap is not used, so + # the length is always one greater than the number of elements. + + void _mpoly_heap_insert1(mpoly_heap1_s * heap, unsigned long exp, void * x, long * next_loc, long * heap_len, unsigned long maskhi) + # As per ``_mpoly_heap_insert`` except that ``N = 1``, and + # ``maskhi = cmpmask[0]``. + + void * _mpoly_heap_pop(mpoly_heap_s * heap, long * heap_len, long N, const unsigned long * cmpmask) + # Pop the head of the heap. It is cast to a ``void *``. A pointer to the + # current heap length must be passed in via ``heap_len``. This will be + # updated by the function. Note that the index 0 position in the heap is not + # used, so the length is always one greater than the number of elements. The + # ``maskhi`` and ``masklo`` values are zero except for degrevlex + # ordering, where they are as per the monomial comparison operations above. + + void * _mpoly_heap_pop1(mpoly_heap1_s * heap, long * heap_len, unsigned long maskhi) + # As per ``_mpoly_heap_pop1`` except that ``N = 1``, and + # ``maskhi = cmpmask[0]``. diff --git a/src/sage/libs/flint/nmod_mpoly.pxd b/src/sage/libs/flint/nmod_mpoly.pxd new file mode 100644 index 00000000000..bd76005f0e1 --- /dev/null +++ b/src/sage/libs/flint/nmod_mpoly.pxd @@ -0,0 +1,424 @@ +# distutils: libraries = flint +# distutils: depends = flint/nmod_mpoly.h + +################################################################################ +# This file is auto-generated. Do not modify by hand +################################################################################ + +from libc.stdio cimport FILE +from sage.libs.gmp.types cimport * +from sage.libs.mpfr.types cimport * +from sage.libs.flint.types cimport * + +cdef extern from "flint_wrap.h": + + void nmod_mpoly_ctx_init(nmod_mpoly_ctx_t ctx, long nvars, const ordering_t ord, mp_limb_t n) + # Initialise a context object for a polynomial ring with the given number of variables and the given ordering. + # It will have coefficients modulo *n*. Setting `n = 0` will give undefined behavior. + # The possibilities for the ordering are ``ORD_LEX``, ``ORD_DEGLEX`` and ``ORD_DEGREVLEX``. + + long nmod_mpoly_ctx_nvars(const nmod_mpoly_ctx_t ctx) + # Return the number of variables used to initialize the context. + + ordering_t nmod_mpoly_ctx_ord(const nmod_mpoly_ctx_t ctx) + # Return the ordering used to initialize the context. + + mp_limb_t nmod_mpoly_ctx_modulus(const nmod_mpoly_ctx_t ctx) + # Return the modulus used to initialize the context. + + void nmod_mpoly_ctx_clear(nmod_mpoly_ctx_t ctx) + # Release any space allocated by *ctx*. + + void nmod_mpoly_init(nmod_mpoly_t A, const nmod_mpoly_ctx_t ctx) + # Initialise *A* for use with the given an initialised context object. Its value is set to zero. + + void nmod_mpoly_init2(nmod_mpoly_t A, long alloc, const nmod_mpoly_ctx_t ctx) + # Initialise *A* for use with the given an initialised context object. Its value is set to zero. + # It is allocated with space for *alloc* terms and at least ``MPOLY_MIN_BITS`` bits for the exponent widths. + + void nmod_mpoly_init3(nmod_mpoly_t A, long alloc, flint_bitcnt_t bits, const nmod_mpoly_ctx_t ctx) + # Initialise *A* for use with the given an initialised context object. Its value is set to zero. + # It is allocated with space for *alloc* terms and *bits* bits for the exponents. + + void nmod_mpoly_fit_length(nmod_mpoly_t A, long len, const nmod_mpoly_ctx_t ctx) + # Ensure that *A* has space for at least *len* terms. + + void nmod_mpoly_realloc(nmod_mpoly_t A, long alloc, const nmod_mpoly_ctx_t ctx) + # Reallocate *A* to have space for *alloc* terms. + # Assumes the current length of the polynomial is not greater than *alloc*. + + void nmod_mpoly_clear(nmod_mpoly_t A, const nmod_mpoly_ctx_t ctx) + # Release any space allocated for *A*. + + char * nmod_mpoly_get_str_pretty(const nmod_mpoly_t A, const char ** x, const nmod_mpoly_ctx_t ctx) + # Return a string, which the user is responsible for cleaning up, representing *A*, given an array of variable strings *x*. + + int nmod_mpoly_fprint_pretty(FILE * file, const nmod_mpoly_t A, const char ** x, const nmod_mpoly_ctx_t ctx) + # Print a string representing *A* to *file*. + + int nmod_mpoly_print_pretty(const nmod_mpoly_t A, const char ** x, const nmod_mpoly_ctx_t ctx) + # Print a string representing *A* to ``stdout``. + + int nmod_mpoly_set_str_pretty(nmod_mpoly_t A, const char * str, const char ** x, const nmod_mpoly_ctx_t ctx) + # Set *A* to the polynomial in the null-terminates string *str* given an array *x* of variable strings. + # If parsing *str* fails, *A* is set to zero, and `-1` is returned. Otherwise, `0` is returned. + # The operations ``+``, ``-``, ``*``, and ``/`` are permitted along with integers and the variables in *x*. The character ``^`` must be immediately followed by the (integer) exponent. + # If any division is not exact, parsing fails. + + void nmod_mpoly_gen(nmod_mpoly_t A, long var, const nmod_mpoly_ctx_t ctx) + # Set *A* to the variable of index *var*, where `var = 0` corresponds to the variable with the most significance with respect to the ordering. + + int nmod_mpoly_is_gen(const nmod_mpoly_t A, long var, const nmod_mpoly_ctx_t ctx) + # If `var \ge 0`, return `1` if *A* is equal to the `var`-th generator, otherwise return `0`. + # If `var < 0`, return `1` if the polynomial is equal to any generator, otherwise return `0`. + + void nmod_mpoly_set(nmod_mpoly_t A, const nmod_mpoly_t B, const nmod_mpoly_ctx_t ctx) + # Set *A* to *B*. + + int nmod_mpoly_equal(const nmod_mpoly_t A, const nmod_mpoly_t B, const nmod_mpoly_ctx_t ctx) + # Return `1` if *A* is equal to *B*, else return `0`. + + void nmod_mpoly_swap(nmod_mpoly_t A, nmod_mpoly_t B, const nmod_mpoly_ctx_t ctx) + # Efficiently swap *A* and *B*. + + int nmod_mpoly_is_ui(const nmod_mpoly_t A, const nmod_mpoly_ctx_t ctx) + # Return `1` if *A* is a constant, else return `0`. + + unsigned long nmod_mpoly_get_ui(const nmod_mpoly_t A, const nmod_mpoly_ctx_t ctx) + # Assuming that *A* is a constant, return this constant. + # This function throws if *A* is not a constant. + + void nmod_mpoly_set_ui(nmod_mpoly_t A, unsigned long c, const nmod_mpoly_ctx_t ctx) + # Set *A* to the constant *c*. + + void nmod_mpoly_zero(nmod_mpoly_t A, const nmod_mpoly_ctx_t ctx) + # Set *A* to the constant `0`. + + void nmod_mpoly_one(nmod_mpoly_t A, const nmod_mpoly_ctx_t ctx) + # Set *A* to the constant `1`. + + int nmod_mpoly_equal_ui(const nmod_mpoly_t A, unsigned long c, const nmod_mpoly_ctx_t ctx) + # Return `1` if *A* is equal to the constant *c*, else return `0`. + + int nmod_mpoly_is_zero(const nmod_mpoly_t A, const nmod_mpoly_ctx_t ctx) + # Return `1` if *A* is the constant `0`, else return `0`. + + int nmod_mpoly_is_one(const nmod_mpoly_t A, const nmod_mpoly_ctx_t ctx) + # Return `1` if *A* is the constant `1`, else return `0`. + + int nmod_mpoly_degrees_fit_si(const nmod_mpoly_t A, const nmod_mpoly_ctx_t ctx) + # Return `1` if the degrees of *A* with respect to each variable fit into an ``slong``, otherwise return `0`. + + void nmod_mpoly_degrees_fmpz(fmpz ** degs, const nmod_mpoly_t A, const nmod_mpoly_ctx_t ctx) + void nmod_mpoly_degrees_si(long * degs, const nmod_mpoly_t A, const nmod_mpoly_ctx_t ctx) + # Set *degs* to the degrees of *A* with respect to each variable. + # If *A* is zero, all degrees are set to `-1`. + + void nmod_mpoly_degree_fmpz(fmpz_t deg, const nmod_mpoly_t A, long var, const nmod_mpoly_ctx_t ctx) + long nmod_mpoly_degree_si(const nmod_mpoly_t A, long var, const nmod_mpoly_ctx_t ctx) + # Either return or set *deg* to the degree of *A* with respect to the variable of index *var*. + # If *A* is zero, the degree is defined to be `-1`. + + int nmod_mpoly_total_degree_fits_si(const nmod_mpoly_t A, const nmod_mpoly_ctx_t ctx) + # Return `1` if the total degree of *A* fits into an ``slong``, otherwise return `0`. + + void nmod_mpoly_total_degree_fmpz(fmpz_t tdeg, const nmod_mpoly_t A, const nmod_mpoly_ctx_t ctx) + long nmod_mpoly_total_degree_si(const nmod_mpoly_t A, const nmod_mpoly_ctx_t ctx) + # Either return or set *tdeg* to the total degree of *A*. + # If *A* is zero, the total degree is defined to be `-1`. + + void nmod_mpoly_used_vars(int * used, const nmod_mpoly_t A, const nmod_mpoly_ctx_t ctx) + # For each variable index *i*, set ``used[i]`` to nonzero if the variable of index *i* appears in *A* and to zero otherwise. + + unsigned long nmod_mpoly_get_coeff_ui_monomial(const nmod_mpoly_t A, const nmod_mpoly_t M, const nmod_mpoly_ctx_t ctx) + # Assuming that *M* is a monomial, return the coefficient of the corresponding monomial in *A*. + # This function throws if *M* is not a monomial. + + void nmod_mpoly_set_coeff_ui_monomial(nmod_mpoly_t A, unsigned long c, const nmod_mpoly_t M, const nmod_mpoly_ctx_t ctx) + # Assuming that *M* is a monomial, set the coefficient of the corresponding monomial in *A* to *c*. + # This function throws if *M* is not a monomial. + + unsigned long nmod_mpoly_get_coeff_ui_fmpz(const nmod_mpoly_t A, fmpz * const * exp, const nmod_mpoly_ctx_t ctx) + unsigned long nmod_mpoly_get_coeff_ui_ui(const nmod_mpoly_t A, const unsigned long * exp, const nmod_mpoly_ctx_t ctx) + # Return the coefficient of the monomial with exponent *exp*. + + void nmod_mpoly_set_coeff_ui_fmpz(nmod_mpoly_t A, unsigned long c, fmpz * const * exp, const nmod_mpoly_ctx_t ctx) + void nmod_mpoly_set_coeff_ui_ui(nmod_mpoly_t A, unsigned long c, const unsigned long * exp, const nmod_mpoly_ctx_t ctx) + # Set the coefficient of the monomial with exponent *exp* to `c`. + + void nmod_mpoly_get_coeff_vars_ui(nmod_mpoly_t C, const nmod_mpoly_t A, const long * vars, const unsigned long * exps, long length, const nmod_mpoly_ctx_t ctx) + # Set *C* to the coefficient of *A* with respect to the variables in *vars* with powers in the corresponding array *exps*. + # Both *vars* and *exps* point to array of length *length*. It is assumed that ``0 < length \le nvars(A)`` and that the variables in *vars* are distinct. + + int nmod_mpoly_cmp(const nmod_mpoly_t A, const nmod_mpoly_t B, const nmod_mpoly_ctx_t ctx) + # Return `1` (resp. `-1`, or `0`) if *A* is after (resp. before, same as) *B* in some arbitrary but fixed total ordering of the polynomials. + # This ordering agrees with the usual ordering of monomials when *A* and *B* are both monomials. + + mp_limb_t * nmod_mpoly_term_coeff_ref(nmod_mpoly_t A, long i, const nmod_mpoly_ctx_t ctx) + # Return a reference to the coefficient of index *i* of *A*. + + int nmod_mpoly_is_canonical(const nmod_mpoly_t A, const nmod_mpoly_ctx_t ctx) + # Return `1` if *A* is in canonical form. Otherwise, return `0`. + # To be in canonical form, all of the terms must have nonzero coefficients, and the terms must be sorted from greatest to least. + + long nmod_mpoly_length(const nmod_mpoly_t A, const nmod_mpoly_ctx_t ctx) + # Return the number of terms in *A*. + # If the polynomial is in canonical form, this will be the number of nonzero coefficients. + + void nmod_mpoly_resize(nmod_mpoly_t A, long new_length, const nmod_mpoly_ctx_t ctx) + # Set the length of *A* to ``new_length``. + # Terms are either deleted from the end, or new zero terms are appended. + + unsigned long nmod_mpoly_get_term_coeff_ui(const nmod_mpoly_t A, long i, const nmod_mpoly_ctx_t ctx) + # Return the coefficient of the term of index *i*. + + void nmod_mpoly_set_term_coeff_ui(nmod_mpoly_t A, long i, unsigned long c, const nmod_mpoly_ctx_t ctx) + # Set the coefficient of the term of index *i* to *c*. + + int nmod_mpoly_term_exp_fits_si(const nmod_mpoly_t A, long i, const nmod_mpoly_ctx_t ctx) + int nmod_mpoly_term_exp_fits_ui(const nmod_mpoly_t A, long i, const nmod_mpoly_ctx_t ctx) + # Return `1` if all entries of the exponent vector of the term of index *i* fit into an ``slong`` (resp. a ``ulong``). Otherwise, return `0`. + + void nmod_mpoly_get_term_exp_fmpz(fmpz ** exp, const nmod_mpoly_t A, long i, const nmod_mpoly_ctx_t ctx) + void nmod_mpoly_get_term_exp_ui(unsigned long * exp, const nmod_mpoly_t A, long i, const nmod_mpoly_ctx_t ctx) + + void nmod_mpoly_get_term_exp_si(long * exp, const nmod_mpoly_t A, long i, const nmod_mpoly_ctx_t ctx) + # Set *exp* to the exponent vector of the term of index *i*. + # The ``_ui`` (resp. ``_si``) version throws if any entry does not fit into a ``ulong`` (resp. ``slong``). + + unsigned long nmod_mpoly_get_term_var_exp_ui(const nmod_mpoly_t A, long i, long var, const nmod_mpoly_ctx_t ctx) + long nmod_mpoly_get_term_var_exp_si(const nmod_mpoly_t A, long i, long var, const nmod_mpoly_ctx_t ctx) + # Return the exponent of the variable *var* of the term of index *i*. + # This function throws if the exponent does not fit into a ``ulong`` (resp. ``slong``). + + void nmod_mpoly_set_term_exp_fmpz(nmod_mpoly_t A, long i, fmpz * const * exp, const nmod_mpoly_ctx_t ctx) + void nmod_mpoly_set_term_exp_ui(nmod_mpoly_t A, long i, const unsigned long * exp, const nmod_mpoly_ctx_t ctx) + # Set the exponent of the term of index *i* to *exp*. + + void nmod_mpoly_get_term(nmod_mpoly_t M, const nmod_mpoly_t A, long i, const nmod_mpoly_ctx_t ctx) + # Set *M* to the term of index *i* in *A*. + + void nmod_mpoly_get_term_monomial(nmod_mpoly_t M, const nmod_mpoly_t A, long i, const nmod_mpoly_ctx_t ctx) + # Set *M* to the monomial of the term of index *i* in *A*. The coefficient of *M* will be one. + + void nmod_mpoly_push_term_ui_fmpz(nmod_mpoly_t A, unsigned long c, fmpz * const * exp, const nmod_mpoly_ctx_t ctx) + void nmod_mpoly_push_term_ui_ffmpz(nmod_mpoly_t A, unsigned long c, const fmpz * exp, const nmod_mpoly_ctx_t ctx) + void nmod_mpoly_push_term_ui_ui(nmod_mpoly_t A, unsigned long c, const unsigned long * exp, const nmod_mpoly_ctx_t ctx) + # Append a term to *A* with coefficient *c* and exponent vector *exp*. + # This function runs in constant average time. + + void nmod_mpoly_sort_terms(nmod_mpoly_t A, const nmod_mpoly_ctx_t ctx) + # Sort the terms of *A* into the canonical ordering dictated by the ordering in *ctx*. + # This function simply reorders the terms: It does not combine like terms, nor does it delete terms with coefficient zero. + # This function runs in linear time in the bit size of *A*. + + void nmod_mpoly_combine_like_terms(nmod_mpoly_t A, const nmod_mpoly_ctx_t ctx) + # Combine adjacent like terms in *A* and delete terms with coefficient zero. + # If the terms of *A* were sorted to begin with, the result will be in canonical form. + # This function runs in linear time in the bit size of *A*. + + void nmod_mpoly_reverse(nmod_mpoly_t A, const nmod_mpoly_t B, const nmod_mpoly_ctx_t ctx) + # Set *A* to the reversal of *B*. + + void nmod_mpoly_randtest_bound(nmod_mpoly_t A, flint_rand_t state, long length, unsigned long exp_bound, const nmod_mpoly_ctx_t ctx) + # Generate a random polynomial with length up to *length* and exponents in the range ``[0, exp_bound - 1]``. + # The exponents of each variable are generated by calls to ``n_randint(state, exp_bound)``. + + void nmod_mpoly_randtest_bounds(nmod_mpoly_t A, flint_rand_t state, long length, unsigned long * exp_bounds, const nmod_mpoly_ctx_t ctx) + # Generate a random polynomial with length up to *length* and exponents in the range ``[0, exp_bounds[i] - 1]``. + # The exponents of the variable of index *i* are generated by calls to ``n_randint(state, exp_bounds[i])``. + + void nmod_mpoly_randtest_bits(nmod_mpoly_t A, flint_rand_t state, long length, mp_limb_t exp_bits, const nmod_mpoly_ctx_t ctx) + # Generate a random polynomial with length up to *length* and exponents whose packed form does not exceed the given bit count. + + void nmod_mpoly_add_ui(nmod_mpoly_t A, const nmod_mpoly_t B, unsigned long c, const nmod_mpoly_ctx_t ctx) + # Set *A* to `B + c`. + + void nmod_mpoly_sub_ui(nmod_mpoly_t A, const nmod_mpoly_t B, unsigned long c, const nmod_mpoly_ctx_t ctx) + # Set *A* to `B - c`. + + void nmod_mpoly_add(nmod_mpoly_t A, const nmod_mpoly_t B, const nmod_mpoly_t C, const nmod_mpoly_ctx_t ctx) + # Set *A* to `B + C`. + + void nmod_mpoly_sub(nmod_mpoly_t A, const nmod_mpoly_t B, const nmod_mpoly_t C, const nmod_mpoly_ctx_t ctx) + # Set *A* to `B - C`. + + void nmod_mpoly_neg(nmod_mpoly_t A, const nmod_mpoly_t B, const nmod_mpoly_ctx_t ctx) + # Set *A* to `-B`. + + void nmod_mpoly_scalar_mul_ui(nmod_mpoly_t A, const nmod_mpoly_t B, unsigned long c, const nmod_mpoly_ctx_t ctx) + # Set *A* to `B \times c`. + + void nmod_mpoly_make_monic(nmod_mpoly_t A, const nmod_mpoly_t B, const nmod_mpoly_ctx_t ctx) + # Set *A* to *B* divided by the leading coefficient of *B*. + # This throws if *B* is zero or the leading coefficient is not invertible. + + void nmod_mpoly_derivative(nmod_mpoly_t A, const nmod_mpoly_t B, long var, const nmod_mpoly_ctx_t ctx) + # Set *A* to the derivative of *B* with respect to the variable of index *var*. + + unsigned long nmod_mpoly_evaluate_all_ui(const nmod_mpoly_t A, const unsigned long * vals, const nmod_mpoly_ctx_t ctx) + # Return the evaluation of *A* where the variables are replaced by the corresponding elements of the array *vals*. + + void nmod_mpoly_evaluate_one_ui(nmod_mpoly_t A, const nmod_mpoly_t B, long var, unsigned long val, const nmod_mpoly_ctx_t ctx) + # Set *A* to the evaluation of *B* where the variable of index *var* is replaced by *val*. + + int nmod_mpoly_compose_nmod_poly(nmod_poly_t A, const nmod_mpoly_t B, nmod_poly_struct * const * C, const nmod_mpoly_ctx_t ctx) + # Set *A* to the evaluation of *B* where the variables are replaced by the corresponding elements of the array *C*. + # The context object of *B* is *ctxB*. + # Return `1` for success and `0` for failure. + + int nmod_mpoly_compose_nmod_mpoly_geobucket(nmod_mpoly_t A, const nmod_mpoly_t B, nmod_mpoly_struct * const * C, const nmod_mpoly_ctx_t ctxB, const nmod_mpoly_ctx_t ctxAC) + int nmod_mpoly_compose_nmod_mpoly_horner(nmod_mpoly_t A, const nmod_mpoly_t B, nmod_mpoly_struct * const * C, const nmod_mpoly_ctx_t ctxB, const nmod_mpoly_ctx_t ctxAC) + int nmod_mpoly_compose_nmod_mpoly(nmod_mpoly_t A, const nmod_mpoly_t B, nmod_mpoly_struct * const * C, const nmod_mpoly_ctx_t ctxB, const nmod_mpoly_ctx_t ctxAC) + # Set *A* to the evaluation of *B* where the variables are replaced by the corresponding elements of the array *C*. + # Both *A* and the elements of *C* have context object *ctxAC*, while *B* has context object *ctxB*. + # Neither of *A* and *B* is allowed to alias any other polynomial. + # Return `1` for success and `0` for failure. + # The main method attempts to perform the calculation using matrices and chooses heuristically between the ``geobucket`` and ``horner`` methods if needed. + + void nmod_mpoly_compose_nmod_mpoly_gen(nmod_mpoly_t A, const nmod_mpoly_t B, const long * c, const nmod_mpoly_ctx_t ctxB, const nmod_mpoly_ctx_t ctxAC) + # Set *A* to the evaluation of *B* where the variable of index *i* in *ctxB* is replaced by the variable of index ``c[i]`` in *ctxAC*. + # The length of the array *C* is the number of variables in *ctxB*. + # If any ``c[i]`` is negative, the corresponding variable of *B* is replaced by zero. Otherwise, it is expected that ``c[i]`` is less than the number of variables in *ctxAC*. + + void nmod_mpoly_mul(nmod_mpoly_t A, const nmod_mpoly_t B, const nmod_mpoly_t C, const nmod_mpoly_ctx_t ctx) + # Set *A* to `B \times C`. + + void nmod_mpoly_mul_johnson(nmod_mpoly_t A, const nmod_mpoly_t B, const nmod_mpoly_t C, const nmod_mpoly_ctx_t ctx) + void nmod_mpoly_mul_heap_threaded(nmod_mpoly_t A, const nmod_mpoly_t B, const nmod_mpoly_t C, const nmod_mpoly_ctx_t ctx) + # Set *A* to `B \times C` using Johnson's heap-based method. + # The first version always uses one thread. + + int nmod_mpoly_mul_array(nmod_mpoly_t A, const nmod_mpoly_t B, const nmod_mpoly_t C, const nmod_mpoly_ctx_t ctx) + int nmod_mpoly_mul_array_threaded(nmod_mpoly_t A, const nmod_mpoly_t B, const nmod_mpoly_t C, const nmod_mpoly_ctx_t ctx) + # Try to set *A* to `B \times C` using arrays. + # If the return is `0`, the operation was unsuccessful. Otherwise, it was successful, and the return is `1`. + # The first version always uses one thread. + + int nmod_mpoly_mul_dense(nmod_mpoly_t A, const nmod_mpoly_t B, const nmod_mpoly_t C, const nmod_mpoly_ctx_t ctx) + # Try to set *A* to `B \times C` using univariate arithmetic. + # If the return is `0`, the operation was unsuccessful. Otherwise, it was successful and the return is `1`. + + int nmod_mpoly_pow_fmpz(nmod_mpoly_t A, const nmod_mpoly_t B, const fmpz_t k, const nmod_mpoly_ctx_t ctx) + # Set *A* to *B* raised to the *k*-th power. + # Return `1` for success and `0` for failure. + + int nmod_mpoly_pow_ui(nmod_mpoly_t A, const nmod_mpoly_t B, unsigned long k, const nmod_mpoly_ctx_t ctx) + # Set *A* to *B* raised to the *k*-th power. + # Return `1` for success and `0` for failure. + + int nmod_mpoly_divides(nmod_mpoly_t Q, const nmod_mpoly_t A, const nmod_mpoly_t B, const nmod_mpoly_ctx_t ctx) + # If *A* is divisible by *B*, set *Q* to the exact quotient and return `1`. Otherwise, set *Q* to zero and return `0`. + # Note that the function ``nmod_mpoly_div`` below may be faster if the quotient is known to be exact. + + void nmod_mpoly_div(nmod_mpoly_t Q, const nmod_mpoly_t A, const nmod_mpoly_t B, const nmod_mpoly_ctx_t ctx) + # Set *Q* to the quotient of *A* by *B*, discarding the remainder. + + void nmod_mpoly_divrem(nmod_mpoly_t Q, nmod_mpoly_t R, const nmod_mpoly_t A, const nmod_mpoly_t B, const nmod_mpoly_ctx_t ctx) + # Set *Q* and *R* to the quotient and remainder of *A* divided by *B*. + + void nmod_mpoly_divrem_ideal(nmod_mpoly_struct ** Q, nmod_mpoly_t R, const nmod_mpoly_t A, nmod_mpoly_struct * const * B, long len, const nmod_mpoly_ctx_t ctx) + # This function is as per :func:`nmod_mpoly_divrem` except that it takes an array of divisor polynomials *B* and it returns an array of quotient polynomials *Q*. + # The number of divisor (and hence quotient) polynomials, is given by *len*. + + int nmod_mpoly_divides_dense(nmod_mpoly_t Q, const nmod_mpoly_t A, const nmod_mpoly_t B, const nmod_mpoly_ctx_t ctx) + # Try to do the operation of ``nmod_mpoly_divides`` using univariate arithmetic. + # If the return is `-1`, the operation was unsuccessful. Otherwise, it was successful and the return is `0` or `1`. + + int nmod_mpoly_divides_monagan_pearce(nmod_mpoly_t Q, const nmod_mpoly_t A, const nmod_mpoly_t B, const nmod_mpoly_ctx_t ctx) + # Do the operation of ``nmod_mpoly_divides`` using the algorithm of Michael Monagan and Roman Pearce. + + int nmod_mpoly_divides_heap_threaded(nmod_mpoly_t Q, const nmod_mpoly_t A, const nmod_mpoly_t B, const nmod_mpoly_ctx_t ctx) + # Do the operation of ``nmod_mpoly_divides`` using a heap and multiple threads. + # This function should only be called once ``global_thread_pool`` has been initialized. + + void nmod_mpoly_term_content(nmod_mpoly_t M, const nmod_mpoly_t A, const nmod_mpoly_ctx_t ctx) + # Set *M* to the GCD of the terms of *A*. + # If *A* is zero, *M* will be zero. Otherwise, *M* will be a monomial with coefficient one. + + int nmod_mpoly_content_vars(nmod_mpoly_t g, const nmod_mpoly_t A, long * vars, long vars_length, const nmod_mpoly_ctx_t ctx) + # Set *g* to the GCD of the coefficients of *A* when viewed as a polynomial in the variables *vars*. + # Return `1` for success and `0` for failure. Upon success, *g* will be independent of the variables *vars*. + + int nmod_mpoly_gcd(nmod_mpoly_t G, const nmod_mpoly_t A, const nmod_mpoly_t B, const nmod_mpoly_ctx_t ctx) + # Try to set *G* to the monic GCD of *A* and *B*. The GCD of zero and zero is defined to be zero. + # If the return is `1` the function was successful. Otherwise the return is `0` and *G* is left untouched. + + int nmod_mpoly_gcd_cofactors(nmod_mpoly_t G, nmod_mpoly_t Abar, nmod_mpoly_t Bbar, const nmod_mpoly_t A, const nmod_mpoly_t B, const nmod_mpoly_ctx_t ctx) + # Do the operation of :func:`nmod_mpoly_gcd` and also compute `Abar = A/G` and `Bbar = B/G` if successful. + + int nmod_mpoly_gcd_brown(nmod_mpoly_t G, const nmod_mpoly_t A, const nmod_mpoly_t B, const nmod_mpoly_ctx_t ctx) + int nmod_mpoly_gcd_hensel(nmod_mpoly_t G, const nmod_mpoly_t A, const nmod_mpoly_t B, const nmod_mpoly_ctx_t ctx) + int nmod_mpoly_gcd_zippel(nmod_mpoly_t G, const nmod_mpoly_t A, const nmod_mpoly_t B, const nmod_mpoly_ctx_t ctx) + # Try to set *G* to the GCD of *A* and *B* using various algorithms. + + int nmod_mpoly_resultant(nmod_mpoly_t R, const nmod_mpoly_t A, const nmod_mpoly_t B, long var, const nmod_mpoly_ctx_t ctx) + # Try to set *R* to the resultant of *A* and *B* with respect to the variable of index *var*. + + int nmod_mpoly_discriminant(nmod_mpoly_t D, const nmod_mpoly_t A, long var, const nmod_mpoly_ctx_t ctx) + # Try to set *D* to the discriminant of *A* with respect to the variable of index *var*. + + int nmod_mpoly_sqrt(nmod_mpoly_t Q, const nmod_mpoly_t A, const nmod_mpoly_ctx_t ctx) + # If `Q^2=A` has a solution, set *Q* to a solution and return `1`, otherwise return `0` and set *Q* to zero. + + int nmod_mpoly_is_square(const nmod_mpoly_t A, const nmod_mpoly_ctx_t ctx) + # Return `1` if *A* is a perfect square, otherwise return `0`. + + int nmod_mpoly_quadratic_root(nmod_mpoly_t Q, const nmod_mpoly_t A, const nmod_mpoly_t B, const nmod_mpoly_ctx_t ctx) + # If `Q^2+AQ=B` has a solution, set *Q* to a solution and return `1`, otherwise return `0`. + + void nmod_mpoly_univar_init(nmod_mpoly_univar_t A, const nmod_mpoly_ctx_t ctx) + # Initialize *A*. + + void nmod_mpoly_univar_clear(nmod_mpoly_univar_t A, const nmod_mpoly_ctx_t ctx) + # Clear *A*. + + void nmod_mpoly_univar_swap(nmod_mpoly_univar_t A, nmod_mpoly_univar_t B, const nmod_mpoly_ctx_t ctx) + # Swap *A* and *B*. + + void nmod_mpoly_to_univar(nmod_mpoly_univar_t A, const nmod_mpoly_t B, long var, const nmod_mpoly_ctx_t ctx) + # Set *A* to a univariate form of *B* by pulling out the variable of index *var*. + # The coefficients of *A* will still belong to the content *ctx* but will not depend on the variable of index *var*. + + void nmod_mpoly_from_univar(nmod_mpoly_t A, const nmod_mpoly_univar_t B, long var, const nmod_mpoly_ctx_t ctx) + # Set *A* to the normal form of *B* by putting in the variable of index *var*. + # This function is undefined if the coefficients of *B* depend on the variable of index *var*. + + int nmod_mpoly_univar_degree_fits_si(const nmod_mpoly_univar_t A, const nmod_mpoly_ctx_t ctx) + # Return `1` if the degree of *A* with respect to the main variable fits an ``slong``. Otherwise, return `0`. + + long nmod_mpoly_univar_length(const nmod_mpoly_univar_t A, const nmod_mpoly_ctx_t ctx) + # Return the number of terms in *A* with respect to the main variable. + + long nmod_mpoly_univar_get_term_exp_si(nmod_mpoly_univar_t A, long i, const nmod_mpoly_ctx_t ctx) + # Return the exponent of the term of index *i* of *A*. + + void nmod_mpoly_univar_get_term_coeff(nmod_mpoly_t c, const nmod_mpoly_univar_t A, long i, const nmod_mpoly_ctx_t ctx) + void nmod_mpoly_univar_swap_term_coeff(nmod_mpoly_t c, nmod_mpoly_univar_t A, long i, const nmod_mpoly_ctx_t ctx) + # Set (resp. swap) *c* to (resp. with) the coefficient of the term of index *i* of *A*. + + void nmod_mpoly_pow_rmul(nmod_mpoly_t A, const nmod_mpoly_t B, unsigned long k, const nmod_mpoly_ctx_t ctx) + # Set *A* to *B* raised to the *k*-th power using repeated multiplications. + + void nmod_mpoly_div_monagan_pearce(nmod_mpoly_t polyq, const nmod_mpoly_t poly2, const nmod_mpoly_t poly3, const nmod_mpoly_ctx_t ctx) + # Set ``polyq`` to the quotient of ``poly2`` by ``poly3``, + # discarding the remainder (with notional remainder coefficients reduced + # modulo the leading coefficient of ``poly3``). Implements "Polynomial + # division using dynamic arrays, heaps and packed exponents" by Michael + # Monagan and Roman Pearce. This function is exceptionally efficient if the + # division is known to be exact. + + void nmod_mpoly_divrem_monagan_pearce(nmod_mpoly_t q, nmod_mpoly_t r, const nmod_mpoly_t poly2, const nmod_mpoly_t poly3, const nmod_mpoly_ctx_t ctx) + # Set ``polyq`` and ``polyr`` to the quotient and remainder of + # ``poly2`` divided by ``poly3``, (with remainder coefficients reduced + # modulo the leading coefficient of ``poly3``). Implements "Polynomial + # division using dynamic arrays, heaps and packed exponents" by Michael + # Monagan and Roman Pearce. + + void nmod_mpoly_divrem_ideal_monagan_pearce(nmod_mpoly_struct ** q, nmod_mpoly_t r, const nmod_mpoly_t poly2, nmod_mpoly_struct * const * poly3, long len, const nmod_mpoly_ctx_t ctx) + # This function is as per ``nmod_mpoly_divrem_monagan_pearce`` except + # that it takes an array of divisor polynomials ``poly3``, and it returns + # an array of quotient polynomials ``q``. The number of divisor (and hence + # quotient) polynomials, is given by *len*. The function computes + # polynomials `q_i = q[i]` such that ``poly2`` is + # `r + \sum_{i=0}^{\mbox{len - 1}} q_ib_i`, where `b_i =` ``poly3[i]``. diff --git a/src/sage/libs/flint/nmod_mpoly_factor.pxd b/src/sage/libs/flint/nmod_mpoly_factor.pxd new file mode 100644 index 00000000000..b9fd8aa4937 --- /dev/null +++ b/src/sage/libs/flint/nmod_mpoly_factor.pxd @@ -0,0 +1,47 @@ +# distutils: libraries = flint +# distutils: depends = flint/nmod_mpoly_factor.h + +################################################################################ +# This file is auto-generated. Do not modify by hand +################################################################################ + +from libc.stdio cimport FILE +from sage.libs.gmp.types cimport * +from sage.libs.mpfr.types cimport * +from sage.libs.flint.types cimport * + +cdef extern from "flint_wrap.h": + + void nmod_mpoly_factor_init(nmod_mpoly_factor_t f, const nmod_mpoly_ctx_t ctx) + # Initialise *f*. + + void nmod_mpoly_factor_clear(nmod_mpoly_factor_t f, const nmod_mpoly_ctx_t ctx) + # Clear *f*. + + void nmod_mpoly_factor_swap(nmod_mpoly_factor_t f, nmod_mpoly_factor_t g, const nmod_mpoly_ctx_t ctx) + # Efficiently swap *f* and *g*. + + long nmod_mpoly_factor_length(const nmod_mpoly_factor_t f, const nmod_mpoly_ctx_t ctx) + # Return the length of the product in *f*. + + unsigned long nmod_mpoly_factor_get_constant_ui(const nmod_mpoly_factor_t f, const nmod_mpoly_ctx_t ctx) + # Return the constant of *f*. + + void nmod_mpoly_factor_get_base(nmod_mpoly_t p, const nmod_mpoly_factor_t f, long i, const nmod_mpoly_ctx_t ctx) + void nmod_mpoly_factor_swap_base(nmod_mpoly_t p, nmod_mpoly_factor_t f, long i, const nmod_mpoly_ctx_t ctx) + # Set (resp. swap) *B* to (resp. with) the base of the term of index `i` in *A*. + + long nmod_mpoly_factor_get_exp_si(nmod_mpoly_factor_t f, long i, const nmod_mpoly_ctx_t ctx) + # Return the exponent of the term of index `i` in *A*. It is assumed to fit an ``slong``. + + void nmod_mpoly_factor_sort(nmod_mpoly_factor_t f, const nmod_mpoly_ctx_t ctx) + # Sort the product of *f* first by exponent and then by base. + + int nmod_mpoly_factor_squarefree(nmod_mpoly_factor_t f, const nmod_mpoly_t A, const nmod_mpoly_ctx_t ctx) + # Set *f* to a factorization of *A* where the bases are primitive and + # pairwise relatively prime. If the product of all irreducible factors with + # a given exponent is desired, it is recommended to call :func:`nmod_mpoly_factor_sort` + # and then multiply the bases with the desired exponent. + + int nmod_mpoly_factor(nmod_mpoly_factor_t f, const nmod_mpoly_t A, const nmod_mpoly_ctx_t ctx) + # Set *f* to a factorization of *A* where the bases are irreducible. diff --git a/src/sage/libs/flint/nmod_poly.pxd b/src/sage/libs/flint/nmod_poly.pxd index 727982a80a7..fdf00910a16 100644 --- a/src/sage/libs/flint/nmod_poly.pxd +++ b/src/sage/libs/flint/nmod_poly.pxd @@ -17,10 +17,10 @@ cdef extern from "flint_wrap.h": # else return 1 and set ``res`` to ``op2 - op1``. void nmod_poly_init(nmod_poly_t poly, mp_limb_t n) - # Initialises ``poly``. It will have coefficients modulo~`n`. + # Initialises ``poly``. It will have coefficients modulo `n`. void nmod_poly_init_preinv(nmod_poly_t poly, mp_limb_t n, mp_limb_t ninv) - # Initialises ``poly``. It will have coefficients modulo~`n`. + # Initialises ``poly``. It will have coefficients modulo `n`. # The caller supplies a precomputed inverse limb generated by # :func:`n_preinvert_limb`. @@ -28,11 +28,11 @@ cdef extern from "flint_wrap.h": # Initialises ``poly`` using an already initialised modulus ``mod``. void nmod_poly_init2(nmod_poly_t poly, mp_limb_t n, long alloc) - # Initialises ``poly``. It will have coefficients modulo~`n`. + # Initialises ``poly``. It will have coefficients modulo `n`. # Up to ``alloc`` coefficients may be stored in ``poly``. void nmod_poly_init2_preinv(nmod_poly_t poly, mp_limb_t n, mp_limb_t ninv, long alloc) - # Initialises ``poly``. It will have coefficients modulo~`n`. + # Initialises ``poly``. It will have coefficients modulo `n`. # The caller supplies a precomputed inverse limb generated by # :func:`n_preinvert_limb`. Up to ``alloc`` coefficients may # be stored in ``poly``. @@ -62,7 +62,7 @@ cdef extern from "flint_wrap.h": long nmod_poly_degree(const nmod_poly_t poly) # Returns the degree of the polynomial ``poly``. The zero polynomial - # is deemed to have degree~`-1`. + # is deemed to have degree `-1`. mp_limb_t nmod_poly_modulus(const nmod_poly_t poly) # Returns the modulus of the polynomial ``poly``. This will be a @@ -71,6 +71,10 @@ cdef extern from "flint_wrap.h": flint_bitcnt_t nmod_poly_max_bits(const nmod_poly_t poly) # Returns the maximum number of bits of any coefficient of ``poly``. + int nmod_poly_is_unit(const nmod_poly_t poly) + + int nmod_poly_is_monic(const nmod_poly_t poly) + void nmod_poly_set(nmod_poly_t a, const nmod_poly_t b) # Sets ``a`` to a copy of ``b``. @@ -86,14 +90,14 @@ cdef extern from "flint_wrap.h": # If ``len`` is greater than the current length of ``poly``, # then nothing happens. - void nmod_poly_set_trunc(nmod_poly_t res, const nmod_poly_t poly, long n) - # Notionally truncate ``poly`` to length `n` and set ``res`` to the + void nmod_poly_set_trunc(nmod_poly_t res, const nmod_poly_t poly, long len) + # Notionally truncate ``poly`` to length ``len`` and set ``res`` to the # result. The result is normalised. void _nmod_poly_reverse(mp_ptr output, mp_srcptr input, long len, long m) # Sets ``output`` to the reverse of ``input``, which is of length - # ``len``, but thinking of it as a polynomial of length~``m``, - # notionally zero-padded if necessary. The length~``m`` must be + # ``len``, but thinking of it as a polynomial of length ``m``, + # notionally zero-padded if necessary. The length ``m`` must be # non-negative, but there are no other restrictions. The polynomial # ``output`` must have space for ``m`` coefficients. Supports # aliasing of ``output`` and ``input``, but the behaviour is @@ -101,9 +105,9 @@ cdef extern from "flint_wrap.h": void nmod_poly_reverse(nmod_poly_t output, const nmod_poly_t input, long m) # Sets ``output`` to the reverse of ``input``, thinking of it as - # a polynomial of length~``m``, notionally zero-padded if necessary). - # The length~``m`` must be non-negative, but there are no other - # restrictions. The output polynomial will be set to length~``m`` + # a polynomial of length ``m``, notionally zero-padded if necessary). + # The length ``m`` must be non-negative, but there are no other + # restrictions. The output polynomial will be set to length ``m`` # and then normalised. void nmod_poly_randtest(nmod_poly_t poly, flint_rand_t state, long len) @@ -152,7 +156,7 @@ cdef extern from "flint_wrap.h": # set to a random monic irreducible polynomial. unsigned long nmod_poly_get_coeff_ui(const nmod_poly_t poly, long j) - # Returns the coefficient of ``poly`` at index~``j``, where + # Returns the coefficient of ``poly`` at index ``j``, where # coefficients are numbered with zero being the constant coefficient, # and returns it as an ``ulong``. If ``j`` refers to a # coefficient beyond the end of ``poly``, zero is returned. @@ -231,19 +235,31 @@ cdef extern from "flint_wrap.h": # positive value is returned, otherwise a non-positive value is returned. int nmod_poly_equal(const nmod_poly_t a, const nmod_poly_t b) - # Returns~`1` if the polynomials are equal, otherwise~`0`. + # Returns `1` if the polynomials are equal, otherwise `0`. + + int nmod_poly_equal_nmod(const nmod_poly_t poly, unsigned long cst) + # Returns `1` if the polynomial ``poly`` is constant, equal to ``cst``, + # otherwise `0`. + # ``cst`` is assumed to be already reduced, i.e. less than the modulus of + # ``poly``. + + int nmod_poly_equal_ui(const nmod_poly_t poly, unsigned long cst) + # Returns `1` if the polynomial ``poly`` is constant and equal to ``cst`` up to + # reduction modulo the modulus of ``poly``, otherwise returns `0`. int nmod_poly_equal_trunc(const nmod_poly_t poly1, const nmod_poly_t poly2, long n) # Notionally truncate ``poly1`` and ``poly2`` to length `n` and return # `1` if the truncations are equal, otherwise return `0`. int nmod_poly_is_zero(const nmod_poly_t poly) - # Returns~`1` if the polynomial ``poly`` is the zero polynomial, - # otherwise returns~`0`. + # Returns `1` if the polynomial ``poly`` is the zero polynomial, + # otherwise returns `0`. int nmod_poly_is_one(const nmod_poly_t poly) - # Returns~`1` if the polynomial ``poly`` is the constant polynomial 1, - # otherwise returns~`0`. + # Returns `1` if the polynomial ``poly`` is the constant polynomial 1, + # otherwise returns `0`. + + int nmod_poly_is_gen(const nmod_poly_t poly) void _nmod_poly_shift_left(mp_ptr res, mp_srcptr poly, long len, long k) # Sets ``(res, len + k)`` to ``(poly, len)`` shifted left by @@ -252,7 +268,7 @@ cdef extern from "flint_wrap.h": void nmod_poly_shift_left(nmod_poly_t res, const nmod_poly_t poly, long k) # Sets ``res`` to ``poly`` shifted left by ``k`` coefficients, - # i.e.\ multiplied by `x^k`. + # i.e. multiplied by `x^k`. void _nmod_poly_shift_right(mp_ptr res, mp_srcptr poly, long len, long k) # Sets ``(res, len - k)`` to ``(poly, len)`` shifted left by @@ -261,7 +277,7 @@ cdef extern from "flint_wrap.h": void nmod_poly_shift_right(nmod_poly_t res, const nmod_poly_t poly, long k) # Sets ``res`` to ``poly`` shifted right by ``k`` coefficients, - # i.e.\ divide by `x^k` and throws away the remainder. If ``k`` is + # i.e. divide by `x^k` and throw away the remainder. If ``k`` is # greater than or equal to the length of ``poly``, the result is the # zero polynomial. @@ -291,8 +307,8 @@ cdef extern from "flint_wrap.h": # Sets ``res`` to the negation of ``poly``. void nmod_poly_scalar_mul_nmod(nmod_poly_t res, const nmod_poly_t poly, unsigned long c) - # Sets ``res`` to ``(poly, len)`` multiplied by~`c`, - # where~`c` is reduced modulo the modulus of ``poly``. + # Sets ``res`` to ``(poly, len)`` multiplied by `c`, + # where `c` is reduced modulo the modulus of ``poly``. void _nmod_poly_make_monic(mp_ptr output, mp_srcptr input, long len, nmod_t mod) # Sets ``output`` to be the scalar multiple of ``input`` of @@ -312,7 +328,7 @@ cdef extern from "flint_wrap.h": void _nmod_poly_bit_pack(mp_ptr res, mp_srcptr poly, long len, flint_bitcnt_t bits) # Packs ``len`` coefficients of ``poly`` into fields of the given - # number of bits in the large integer ``res``, i.e.\ evaluates + # number of bits in the large integer ``res``, i.e. evaluates # ``poly`` at ``2^bits`` and store the result in ``res``. # Assumes ``len > 0`` and ``bits > 0``. Also assumes that no # coefficient of ``poly`` is bigger than ``bits/2`` bits. We @@ -565,18 +581,6 @@ cdef extern from "flint_wrap.h": # Sets ``res`` to ``poly`` raised to the power ``e`` # modulo ``f``, using binary exponentiation. We require ``e >= 0``. - void _nmod_poly_powmod_mpz_binexp(mp_ptr res, mp_srcptr poly, mpz_srcptr e, mp_srcptr f, long lenf, nmod_t mod) - # Sets ``res`` to ``poly`` raised to the power ``e`` - # modulo ``f``, using binary exponentiation. We require ``e > 0``. - # We require ``lenf > 1``. It is assumed that ``poly`` is already - # reduced modulo ``f`` and zero-padded as necessary to have length - # exactly ``lenf - 1``. The output ``res`` must have room for - # ``lenf - 1`` coefficients. - - void nmod_poly_powmod_mpz_binexp(nmod_poly_t res, const nmod_poly_t poly, mpz_srcptr e, const nmod_poly_t f) - # Sets ``res`` to ``poly`` raised to the power ``e`` - # modulo ``f``, using binary exponentiation. We require ``e >= 0``. - void _nmod_poly_powmod_fmpz_binexp(mp_ptr res, mp_srcptr poly, fmpz_t e, mp_srcptr f, long lenf, nmod_t mod) # Sets ``res`` to ``poly`` raised to the power ``e`` # modulo ``f``, using binary exponentiation. We require ``e > 0``. @@ -602,20 +606,6 @@ cdef extern from "flint_wrap.h": # modulo ``f``, using binary exponentiation. We require ``e >= 0``. # We require ``finv`` to be the inverse of the reverse of ``f``. - void _nmod_poly_powmod_mpz_binexp_preinv (mp_ptr res, mp_srcptr poly, mpz_srcptr e, mp_srcptr f, long lenf, mp_srcptr finv, long lenfinv, nmod_t mod) - # Sets ``res`` to ``poly`` raised to the power ``e`` - # modulo ``f``, using binary exponentiation. We require ``e > 0``. - # We require ``finv`` to be the inverse of the reverse of ``f``. - # We require ``lenf > 1``. It is assumed that ``poly`` is already - # reduced modulo ``f`` and zero-padded as necessary to have length - # exactly ``lenf - 1``. The output ``res`` must have room for - # ``lenf - 1`` coefficients. - - void nmod_poly_powmod_mpz_binexp_preinv(nmod_poly_t res, const nmod_poly_t poly, mpz_srcptr e, const nmod_poly_t f, const nmod_poly_t finv) - # Sets ``res`` to ``poly`` raised to the power ``e`` - # modulo ``f``, using binary exponentiation. We require ``e >= 0``. - # We require ``finv`` to be the inverse of the reverse of ``f``. - void _nmod_poly_powmod_fmpz_binexp_preinv (mp_ptr res, mp_srcptr poly, fmpz_t e, mp_srcptr f, long lenf, mp_srcptr finv, long lenfinv, nmod_t mod) # Sets ``res`` to ``poly`` raised to the power ``e`` # modulo ``f``, using binary exponentiation. We require ``e > 0``. @@ -887,13 +877,13 @@ cdef extern from "flint_wrap.h": # is a prime number strictly larger than the degree of ``x``. mp_limb_t _nmod_poly_evaluate_nmod(mp_srcptr poly, long len, mp_limb_t c, nmod_t mod) - # Evaluates ``poly`` at the value~``c`` and reduces modulo the - # given modulus of ``poly``. The value~``c`` should be reduced + # Evaluates ``poly`` at the value ``c`` and reduces modulo the + # given modulus of ``poly``. The value ``c`` should be reduced # modulo the modulus. The algorithm used is Horner's method. mp_limb_t nmod_poly_evaluate_nmod(const nmod_poly_t poly, mp_limb_t c) - # Evaluates ``poly`` at the value~``c`` and reduces modulo the - # modulus of ``poly``. The value~``c`` should be reduced modulo + # Evaluates ``poly`` at the value ``c`` and reduces modulo the + # modulus of ``poly``. The value ``c`` should be reduced modulo # the modulus. The algorithm used is Horner's method. void nmod_poly_evaluate_mat_horner(nmod_mat_t dest, const nmod_poly_t poly, const nmod_mat_t c) @@ -1012,19 +1002,19 @@ cdef extern from "flint_wrap.h": void _nmod_poly_compose_horner(mp_ptr res, mp_srcptr poly1, long len1, mp_srcptr poly2, long len2, nmod_t mod) # Composes ``poly1`` of length ``len1`` with ``poly2`` of length - # ``len2`` and sets ``res`` to the result, i.e.\ evaluates + # ``len2`` and sets ``res`` to the result, i.e. evaluates # ``poly1`` at ``poly2``. The algorithm used is Horner's algorithm. # We require that ``res`` have space for ``(len1 - 1)*(len2 - 1) + 1`` # coefficients. It is assumed that ``len1 > 0`` and ``len2 > 0``. void nmod_poly_compose_horner(nmod_poly_t res, const nmod_poly_t poly1, const nmod_poly_t poly2) # Composes ``poly1`` with ``poly2`` and sets ``res`` to the result, - # i.e.\ evaluates ``poly1`` at ``poly2``. The algorithm used is + # i.e. evaluates ``poly1`` at ``poly2``. The algorithm used is # Horner's algorithm. void _nmod_poly_compose_divconquer(mp_ptr res, mp_srcptr poly1, long len1, mp_srcptr poly2, long len2, nmod_t mod) # Composes ``poly1`` of length ``len1`` with ``poly2`` of length - # ``len2`` and sets ``res`` to the result, i.e.\ evaluates + # ``len2`` and sets ``res`` to the result, i.e. evaluates # ``poly1`` at ``poly2``. The algorithm used is the divide and # conquer algorithm. We require that ``res`` have space for # ``(len1 - 1)*(len2 - 1) + 1`` coefficients. It is assumed that @@ -1032,12 +1022,12 @@ cdef extern from "flint_wrap.h": void nmod_poly_compose_divconquer(nmod_poly_t res, const nmod_poly_t poly1, const nmod_poly_t poly2) # Composes ``poly1`` with ``poly2`` and sets ``res`` to the result, - # i.e.\ evaluates ``poly1`` at ``poly2``. The algorithm used is + # i.e. evaluates ``poly1`` at ``poly2``. The algorithm used is # the divide and conquer algorithm. void _nmod_poly_compose(mp_ptr res, mp_srcptr poly1, long len1, mp_srcptr poly2, long len2, nmod_t mod) # Composes ``poly1`` of length ``len1`` with ``poly2`` of length - # ``len2`` and sets ``res`` to the result, i.e.\ evaluates ``poly1`` + # ``len2`` and sets ``res`` to the result, i.e. evaluates ``poly1`` # at ``poly2``. We require that ``res`` have space for # ``(len1 - 1)*(len2 - 1) + 1`` coefficients. It is assumed that # ``len1 > 0`` and ``len2 > 0``. @@ -1218,7 +1208,7 @@ cdef extern from "flint_wrap.h": # the GCD is zero, the GCD `G` is made monic. long _nmod_poly_hgcd(mp_ptr *M, long *lenM, mp_ptr A, long *lenA, mp_ptr B, long *lenB, mp_srcptr a, long lena, mp_srcptr b, long lenb, nmod_t mod) - # Computes the HGCD of `a` and `b`, that is, a matrix~`M`, a sign~`\sigma` + # Computes the HGCD of `a` and `b`, that is, a matrix `M`, a sign `\sigma` # and two polynomials `A` and `B` such that # .. math :: # (A,B)^t = M^{-1} (a,b)^t, \sigma = \det(M), @@ -1243,7 +1233,7 @@ cdef extern from "flint_wrap.h": # As a special case, the GCD of two zero polynomials is defined to be # the zero polynomial. # The time complexity of the algorithm is `\mathcal{O}(n \log^2 n)`. - # For further details, see~[ThullYap1990]_. + # For further details, see [ThullYap1990]_. long _nmod_poly_gcd(mp_ptr G, mp_srcptr A, long lenA, mp_srcptr B, long lenB, nmod_t mod) # Computes the GCD of `A` of length ``lenA`` and `B` of length @@ -1397,7 +1387,7 @@ cdef extern from "flint_wrap.h": # Assumes that `0 < \operatorname{len}(A) < \operatorname{len}(B)`. void nmod_poly_gcdinv(nmod_poly_t G, nmod_poly_t S, const nmod_poly_t A, const nmod_poly_t B) - # Computes polynomials `G` and `S`, both reduced modulo~`B`, + # Computes polynomials `G` and `S`, both reduced modulo `B`, # such that `G \cong S A \pmod{B}`, where `B` is assumed to # have `\operatorname{len}(B) \geq 2`. # In the case that `A = 0 \pmod{B}`, returns `G = S = 0`. @@ -1416,8 +1406,8 @@ cdef extern from "flint_wrap.h": # ring `(\mathbf{Z}/p\mathbf{Z})[X]`, where we assume that `p` is a prime # number. # If `\operatorname{len}(P) < 2`, raises an exception. - # If the greatest common divisor of `B` and `P` is~`1`, returns~`1` and - # sets `A` to the inverse of `B`. Otherwise, returns~`0` and the value + # If the greatest common divisor of `B` and `P` is `1`, returns `1` and + # sets `A` to the inverse of `B`. Otherwise, returns `0` and the value # of `A` on exit is undefined. mp_limb_t _nmod_poly_discriminant(mp_srcptr poly, long len, nmod_t mod) @@ -1426,10 +1416,10 @@ cdef extern from "flint_wrap.h": mp_limb_t nmod_poly_discriminant(const nmod_poly_t f) # Return the discriminant of `f`. # We normalise the discriminant so that - # `\operatorname{disc}(f) = (-1)^(n(n-1)/2) \operatorname{res}(f, f') / - # \operatorname{lc}(f)^(n - m - 2)`, where ``n = len(f)`` and + # `\operatorname{disc}(f) = (-1)^{n(n-1)/2} \operatorname{res}(f, f') / + # \operatorname{lc}(f)^{n - m - 2}`, where ``n = len(f)`` and # ``m = len(f')``. Thus `\operatorname{disc}(f) = - # \operatorname{lc}(f)^(2n - 2) \prod_{i < j} (r_i - r_j)^2`, where + # \operatorname{lc}(f)^{2n - 2} \prod_{i < j} (r_i - r_j)^2`, where # `\operatorname{lc}(f)` is the leading coefficient of `f` and `r_i` are the # roots of `f`. @@ -1438,7 +1428,7 @@ cdef extern from "flint_wrap.h": # modulo `x^n`, where the constant term of ``poly2`` is required # to be zero. # Assumes that ``len1, len2, n > 0``, that ``len1, len2 <= n``, - # and that\\ ``(len1-1) * (len2-1) + 1 <= n``, and that ``res`` has + # and that ``(len1-1) * (len2-1) + 1 <= n``, and that ``res`` has # space for ``n`` coefficients. Does not support aliasing between any # of the inputs and the output. # Wraps :func:`_gr_poly_compose_series` which chooses automatically diff --git a/src/sage/libs/flint/padic_mat.pxd b/src/sage/libs/flint/padic_mat.pxd new file mode 100644 index 00000000000..c4ad9dbf7ea --- /dev/null +++ b/src/sage/libs/flint/padic_mat.pxd @@ -0,0 +1,183 @@ +# distutils: libraries = flint +# distutils: depends = flint/padic_mat.h + +################################################################################ +# This file is auto-generated. Do not modify by hand +################################################################################ + +from libc.stdio cimport FILE +from sage.libs.gmp.types cimport * +from sage.libs.mpfr.types cimport * +from sage.libs.flint.types cimport * + +cdef extern from "flint_wrap.h": + + fmpz_mat_struct * padic_mat(const padic_mat_t A) + # Returns a pointer to the unit part of the matrix, which + # is a matrix over `\mathbf{Z}`. + # The return value can be used as an argument to + # the functions in the ``fmpz_mat`` module. + + fmpz * padic_mat_entry(const padic_mat_t A, long i, long j) + # Returns a pointer to unit part of the entry in position `(i, j)`. + # Note that this is not necessarily a unit. + # The return value can be used as an argument to + # the functions in the ``fmpz`` module. + + long padic_mat_val(const padic_mat_t A) + # Allow access (as L-value or R-value) to ``val`` field of `A`. + # This function is implemented as a macro. + + long padic_mat_prec(const padic_mat_t A) + # Allow access (as L-value or R-value) to ``prec`` field of `A`. + # This function is implemented as a macro. + + long padic_mat_get_val(const padic_mat_t A) + # Returns the valuation of the matrix. + + long padic_mat_get_prec(const padic_mat_t A) + # Returns the `p`-adic precision of the matrix. + + long padic_mat_nrows(const padic_mat_t A) + # Returns the number of rows of the matrix `A`. + + long padic_mat_ncols(const padic_mat_t A) + # Returns the number of columns of the matrix `A`. + + void padic_mat_init(padic_mat_t A, long r, long c) + # Initialises the matrix `A` as a zero matrix with the specified numbers + # of rows and columns and precision ``PADIC_DEFAULT_PREC``. + + void padic_mat_init2(padic_mat_t A, long r, long c, long prec) + # Initialises the matrix `A` as a zero matrix with the specified numbers + # of rows and columns and the given precision. + + void padic_mat_clear(padic_mat_t A) + # Clears the matrix `A`. + + void _padic_mat_canonicalise(padic_mat_t A, const padic_ctx_t ctx) + # Ensures that the matrix `A` is in canonical form. + + void _padic_mat_reduce(padic_mat_t A, const padic_ctx_t ctx) + # Ensures that the matrix `A` is reduced modulo `p^N`, + # assuming that it is in canonical form already. + + void padic_mat_reduce(padic_mat_t A, const padic_ctx_t ctx) + # Ensures that the matrix `A` is reduced modulo `p^N`, + # without assuming that it is necessarily in canonical form. + + int padic_mat_is_empty(const padic_mat_t A) + # Returns whether the matrix `A` is empty, that is, + # whether it has zero rows or zero columns. + + int padic_mat_is_square(const padic_mat_t A) + # Returns whether the matrix `A` is square. + + int padic_mat_is_canonical(const padic_mat_t A, const padic_ctx_t p) + # Returns whether the matrix `A` is in canonical form. + + void padic_mat_set(padic_mat_t B, const padic_mat_t A, const padic_ctx_t p) + # Sets `B` to a copy of `A`, respecting the precision of `B`. + + void padic_mat_swap(padic_mat_t A, padic_mat_t B) + # Swaps the two matrices `A` and `B`. This is done efficiently by + # swapping pointers. + + void padic_mat_swap_entrywise(padic_mat_t mat1, padic_mat_t mat2) + # Swaps two matrices by swapping the individual entries rather than swapping + # the contents of the structs. + + void padic_mat_zero(padic_mat_t A) + # Sets the matrix `A` to zero. + + void padic_mat_one(padic_mat_t A) + # Sets the matrix `A` to the identity matrix. If the precision + # is negative then the matrix will be the zero matrix. + + void padic_mat_set_fmpq_mat(padic_mat_t B, const fmpq_mat_t A, const padic_ctx_t ctx) + # Sets the `p`-adic matrix `B` to the rational matrix `A`, reduced + # according to the given context. + + void padic_mat_get_fmpq_mat(fmpq_mat_t B, const padic_mat_t A, const padic_ctx_t ctx) + # Sets the rational matrix `B` to the `p`-adic matrices `A`; + # no reduction takes place. + + void padic_mat_get_entry_padic(padic_t rop, const padic_mat_t op, long i, long j, const padic_ctx_t ctx) + # Sets ``rop`` to the entry in position `(i, j)` in the matrix ``op``. + + void padic_mat_set_entry_padic(padic_mat_t rop, long i, long j, const padic_t op, const padic_ctx_t ctx) + # Sets the entry in position `(i, j)` in the matrix to ``rop``. + + int padic_mat_equal(const padic_mat_t A, const padic_mat_t B) + # Returns whether the two matrices `A` and `B` are equal. + + int padic_mat_is_zero(const padic_mat_t A) + # Returns whether the matrix `A` is zero. + + int padic_mat_fprint(FILE * file, const padic_mat_t A, const padic_ctx_t ctx) + # Prints a simple representation of the matrix `A` to the + # output stream ``file``. The format is the number of rows, + # a space, the number of columns, two spaces, followed by a list + # of all the entries, one row after the other. + # In the current implementation, always returns `1`. + + int padic_mat_fprint_pretty(FILE * file, const padic_mat_t A, const padic_ctx_t ctx) + # Prints a *pretty* representation of the matrix `A` + # to the output stream ``file``. + # In the current implementation, always returns `1`. + + int padic_mat_print(const padic_mat_t A, const padic_ctx_t ctx) + int padic_mat_print_pretty(const padic_mat_t A, const padic_ctx_t ctx) + + void padic_mat_randtest(padic_mat_t A, flint_rand_t state, const padic_ctx_t ctx) + # Sets `A` to a random matrix. + # The valuation will be in the range `[- \lceil N/10\rceil, N)`, + # `[N - \lceil -N/10\rceil, N)`, or `[-10, 0)` as `N` is positive, + # negative or zero. + + void padic_mat_transpose(padic_mat_t B, const padic_mat_t A) + # Sets `B` to `A^t`. + + void _padic_mat_add(padic_mat_t C, const padic_mat_t A, const padic_mat_t B, const padic_ctx_t ctx) + # Sets `C` to the exact sum `A + B`, ensuring that the result is in + # canonical form. + + void padic_mat_add(padic_mat_t C, const padic_mat_t A, const padic_mat_t B, const padic_ctx_t ctx) + # Sets `C` to the sum `A + B` modulo `p^N`. + + void _padic_mat_sub(padic_mat_t C, const padic_mat_t A, const padic_mat_t B, const padic_ctx_t ctx) + # Sets `C` to the exact difference `A - B`, ensuring that the result is in + # canonical form. + + void padic_mat_sub(padic_mat_t C, const padic_mat_t A, const padic_mat_t B, const padic_ctx_t ctx) + # Sets `C` to `A - B`, ensuring that the result is reduced. + + void _padic_mat_neg(padic_mat_t B, const padic_mat_t A) + # Sets `B` to `-A` in canonical form. + + void padic_mat_neg(padic_mat_t B, const padic_mat_t A, const padic_ctx_t ctx) + # Sets `B` to `-A`, ensuring the result is reduced. + + void _padic_mat_scalar_mul_padic(padic_mat_t B, const padic_mat_t A, const padic_t c, const padic_ctx_t ctx) + # Sets `B` to `c A`, ensuring that the result is in canonical form. + + void padic_mat_scalar_mul_padic(padic_mat_t B, const padic_mat_t A, const padic_t c, const padic_ctx_t ctx) + # Sets `B` to `c A`, ensuring that the result is reduced. + + void _padic_mat_scalar_mul_fmpz(padic_mat_t B, const padic_mat_t A, const fmpz_t c, const padic_ctx_t ctx) + # Sets `B` to `c A`, ensuring that the result is in canonical form. + + void padic_mat_scalar_mul_fmpz(padic_mat_t B, const padic_mat_t A, const fmpz_t c, const padic_ctx_t ctx) + # Sets `B` to `c A`, ensuring that the result is reduced. + + void padic_mat_scalar_div_fmpz(padic_mat_t B, const padic_mat_t A, const fmpz_t c, const padic_ctx_t ctx) + # Sets `B` to `c^{-1} A`, assuming that `c \neq 0`. + # Ensures that the result `B` is reduced. + + void _padic_mat_mul(padic_mat_t C, const padic_mat_t A, const padic_mat_t B, const padic_ctx_t ctx) + # Sets `C` to the product `A B` of the two matrices `A` and `B`, + # ensuring that `C` is in canonical form. + + void padic_mat_mul(padic_mat_t C, const padic_mat_t A, const padic_mat_t B, const padic_ctx_t ctx) + # Sets `C` to the product `A B` of the two matrices `A` and `B`, + # ensuring that `C` is reduced. diff --git a/src/sage/libs/flint/partitions.pxd b/src/sage/libs/flint/partitions.pxd new file mode 100644 index 00000000000..99133e80fb4 --- /dev/null +++ b/src/sage/libs/flint/partitions.pxd @@ -0,0 +1,62 @@ +# distutils: libraries = flint +# distutils: depends = flint/partitions.h + +################################################################################ +# This file is auto-generated. Do not modify by hand +################################################################################ + +from libc.stdio cimport FILE +from sage.libs.gmp.types cimport * +from sage.libs.mpfr.types cimport * +from sage.libs.flint.types cimport * + +cdef extern from "flint_wrap.h": + + void partitions_rademacher_bound(arf_t b, const fmpz_t n, unsigned long N) + # Sets `b` to an upper bound for + # .. math :: + # M(n,N) = \frac{44 \pi^2}{225 \sqrt 3} N^{-1/2} + # + \frac{\pi \sqrt{2}}{75} \left( \frac{N}{n-1} \right)^{1/2} + # \sinh\left(\frac{\pi}{N} \sqrt{\frac{2n}{3}}\right). + # This formula gives an upper bound for the truncation error in the + # Hardy-Ramanujan-Rademacher formula when the series is taken up + # to the term `t(n,N)` inclusive. + + void partitions_hrr_sum_arb(arb_t x, const fmpz_t n, long N0, long N, int use_doubles) + # Evaluates the partial sum `\sum_{k=N_0}^N t(n,k)` of the + # Hardy-Ramanujan-Rademacher series. + # If *use_doubles* is nonzero, doubles and the system's standard library math + # functions are used to evaluate the smallest terms. This significantly + # speeds up evaluation for small `n` (e.g. `n < 10^6`), and gives a small speed + # improvement for larger `n`, but the result is not guaranteed to be correct. + # In practice, the error is estimated very conservatively, and unless + # the system's standard library is broken, use of doubles can be considered + # safe. Setting *use_doubles* to zero gives a fully guaranteed + # bound. + + void partitions_fmpz_fmpz(fmpz_t p, const fmpz_t n, int use_doubles) + # Computes the partition function `p(n)` using the Hardy-Ramanujan-Rademacher + # formula. This function computes a numerical ball containing `p(n)` + # and verifies that the ball contains a unique integer. + # If *n* is sufficiently large and a number of threads greater than 1 + # has been selected with :func:`flint_set_num_threads()`, the computation + # time will be reduced by using two threads. + # See :func:`partitions_hrr_sum_arb` for an explanation of the + # *use_doubles* option. + + void partitions_fmpz_ui(fmpz_t p, unsigned long n) + # Computes the partition function `p(n)` using the Hardy-Ramanujan-Rademacher + # formula. This function computes a numerical ball containing `p(n)` + # and verifies that the ball contains a unique integer. + + void partitions_fmpz_ui_using_doubles(fmpz_t p, unsigned long n) + # Computes the partition function `p(n)`, enabling the use of doubles + # internally. This significantly speeds up evaluation for small `n` + # (e.g. `n < 10^6`), but the error bounds are not certified + # (see remarks for :func:`partitions_hrr_sum_arb`). + + void partitions_leading_fmpz(arb_t res, const fmpz_t n, long prec) + # Sets *res* to the leading term in the Hardy-Ramanujan series + # for `p(n)` (without Rademacher's correction of this term, which is + # vanishingly small when `n` is large), that is, + # `\sqrt{12} (1-1/t) e^t / (24n-1)` where `t = \pi \sqrt{24n-1} / 6`. diff --git a/src/sage/libs/flint/perm.pxd b/src/sage/libs/flint/perm.pxd new file mode 100644 index 00000000000..c6c65b2a816 --- /dev/null +++ b/src/sage/libs/flint/perm.pxd @@ -0,0 +1,48 @@ +# distutils: libraries = flint +# distutils: depends = flint/perm.h + +################################################################################ +# This file is auto-generated. Do not modify by hand +################################################################################ + +from libc.stdio cimport FILE +from sage.libs.gmp.types cimport * +from sage.libs.mpfr.types cimport * +from sage.libs.flint.types cimport * + +cdef extern from "flint_wrap.h": + + long * _perm_init(long n) + # Initialises the permutation for use. + + void _perm_clear(long *vec) + # Clears the permutation. + + void _perm_set(long *res, const long *vec, long n) + # Sets the permutation ``res`` to the same as the permutation ``vec``. + + void _perm_set_one(long *vec, long n) + # Sets the permutation to the identity permutation. + + void _perm_inv(long *res, const long *vec, long n) + # Sets ``res`` to the inverse permutation of ``vec``. + # Allows aliasing of ``res`` and ``vec``. + + void _perm_compose(long *res, const long *vec1, const long *vec2, long n) + # Forms the composition `\pi_1 \circ \pi_2` of two permutations + # `\pi_1` and `\pi_2`. Here, `\pi_2` is applied first, that is, + # `(\pi_1 \circ \pi_2)(i) = \pi_1(\pi_2(i))`. + # Allows aliasing of ``res``, ``vec1`` and ``vec2``. + + int _perm_parity(const long *vec, long n) + # Returns the parity of ``vec``, 0 if the permutation is even and 1 if + # the permutation is odd. + + int _perm_randtest(long *vec, long n, flint_rand_t state) + # Generates a random permutation vector of length `n` and returns + # its parity, 0 or 1. + # This function uses the Knuth shuffle algorithm to generate a uniformly + # random permutation without retries. + + int _perm_print(const long * vec, long n) + # Prints the permutation vector of length `n` to ``stdout``. diff --git a/src/sage/libs/flint/qqbar.pxd b/src/sage/libs/flint/qqbar.pxd new file mode 100644 index 00000000000..0bdbad8db5e --- /dev/null +++ b/src/sage/libs/flint/qqbar.pxd @@ -0,0 +1,704 @@ +# distutils: libraries = flint +# distutils: depends = flint/qqbar.h + +################################################################################ +# This file is auto-generated. Do not modify by hand +################################################################################ + +from libc.stdio cimport FILE +from sage.libs.gmp.types cimport * +from sage.libs.mpfr.types cimport * +from sage.libs.flint.types cimport * + +cdef extern from "flint_wrap.h": + + void qqbar_init(qqbar_t res) + # Initializes the variable *res* for use, and sets its value to zero. + + void qqbar_clear(qqbar_t res) + # Clears the variable *res*, freeing or recycling its allocated memory. + + qqbar_ptr _qqbar_vec_init(long len) + # Returns a pointer to an array of *len* initialized *qqbar_struct*:s. + + void _qqbar_vec_clear(qqbar_ptr vec, long len) + # Clears all *len* entries in the vector *vec* and frees the + # vector itself. + + void qqbar_swap(qqbar_t x, qqbar_t y) + # Swaps the values of *x* and *y* efficiently. + + void qqbar_set(qqbar_t res, const qqbar_t x) + void qqbar_set_si(qqbar_t res, long x) + void qqbar_set_ui(qqbar_t res, unsigned long x) + void qqbar_set_fmpz(qqbar_t res, const fmpz_t x) + void qqbar_set_fmpq(qqbar_t res, const fmpq_t x) + # Sets *res* to the value *x*. + + void qqbar_set_re_im(qqbar_t res, const qqbar_t x, const qqbar_t y) + # Sets *res* to the value `x + yi`. + + int qqbar_set_d(qqbar_t res, double x) + int qqbar_set_re_im_d(qqbar_t res, double x, double y) + # Sets *res* to the value *x* or `x + yi` respectively. These functions + # performs error handling: if *x* and *y* are finite, the conversion succeeds + # and the return flag is 1. If *x* or *y* is non-finite (infinity or NaN), + # the conversion fails and the return flag is 0. + + long qqbar_degree(const qqbar_t x) + # Returns the degree of *x*, i.e. the degree of the minimal polynomial. + + int qqbar_is_rational(const qqbar_t x) + # Returns whether *x* is a rational number. + + int qqbar_is_integer(const qqbar_t x) + # Returns whether *x* is an integer (an element of `\mathbb{Z}`). + + int qqbar_is_algebraic_integer(const qqbar_t x) + # Returns whether *x* is an algebraic integer, i.e. whether its minimal + # polynomial has leading coefficient 1. + + int qqbar_is_zero(const qqbar_t x) + int qqbar_is_one(const qqbar_t x) + int qqbar_is_neg_one(const qqbar_t x) + # Returns whether *x* is the number `0`, `1`, `-1`. + + int qqbar_is_i(const qqbar_t x) + int qqbar_is_neg_i(const qqbar_t x) + # Returns whether *x* is the imaginary unit `i` (respectively `-i`). + + int qqbar_is_real(const qqbar_t x) + # Returns whether *x* is a real number. + + void qqbar_height(fmpz_t res, const qqbar_t x) + # Sets *res* to the height of *x* (the largest absolute value of the + # coefficients of the minimal polynomial of *x*). + + long qqbar_height_bits(const qqbar_t x) + # Returns the height of *x* (the largest absolute value of the + # coefficients of the minimal polynomial of *x*) measured in bits. + + int qqbar_within_limits(const qqbar_t x, long deg_limit, long bits_limit) + # Checks if *x* has degree bounded by *deg_limit* and height + # bounded by *bits_limit* bits, returning 0 (false) or 1 (true). + # If *deg_limit* is set to 0, the degree check is skipped, + # and similarly for *bits_limit*. + + int qqbar_binop_within_limits(const qqbar_t x, const qqbar_t y, long deg_limit, long bits_limit) + # Checks if `x + y`, `x - y`, `x \cdot y` and `x / y` certainly have + # degree bounded by *deg_limit* (by multiplying the degrees for *x* and *y* + # to obtain a trivial bound). For *bits_limits*, the sum of the bit heights + # of *x* and *y* is checked against the bound (this is only a heuristic). + # If *deg_limit* is set to 0, the degree check is skipped, + # and similarly for *bits_limit*. + + void _qqbar_get_fmpq(fmpz_t num, fmpz_t den, const qqbar_t x) + # Sets *num* and *den* to the numerator and denominator of *x*. + # Aborts if *x* is not a rational number. + + void qqbar_get_fmpq(fmpq_t res, const qqbar_t x) + # Sets *res* to *x*. Aborts if *x* is not a rational number. + + void qqbar_get_fmpz(fmpz_t res, const qqbar_t x) + # Sets *res* to *x*. Aborts if *x* is not an integer. + + void qqbar_zero(qqbar_t res) + # Sets *res* to the number 0. + + void qqbar_one(qqbar_t res) + # Sets *res* to the number 1. + + void qqbar_i(qqbar_t res) + # Sets *res* to the imaginary unit `i`. + + void qqbar_phi(qqbar_t res) + # Sets *res* to the golden ratio `\varphi = \tfrac{1}{2}(\sqrt{5} + 1)`. + + void qqbar_print(const qqbar_t x) + # Prints *res* to standard output. The output shows the degree + # and the list of coefficients + # of the minimal polynomial followed by a decimal representation of + # the enclosing interval. This function is mainly intended for debugging. + + void qqbar_printn(const qqbar_t x, long n) + # Prints *res* to standard output. The output shows a decimal + # approximation to *n* digits. + + void qqbar_printnd(const qqbar_t x, long n) + # Prints *res* to standard output. The output shows a decimal + # approximation to *n* digits, followed by the degree of the number. + + void qqbar_randtest(qqbar_t res, flint_rand_t state, long deg, long bits) + # Sets *res* to a random algebraic number with degree up to *deg* and + # with height (measured in bits) up to *bits*. + + void qqbar_randtest_real(qqbar_t res, flint_rand_t state, long deg, long bits) + # Sets *res* to a random real algebraic number with degree up to *deg* and + # with height (measured in bits) up to *bits*. + + void qqbar_randtest_nonreal(qqbar_t res, flint_rand_t state, long deg, long bits) + # Sets *res* to a random nonreal algebraic number with degree up to *deg* and + # with height (measured in bits) up to *bits*. Since all algebraic numbers + # of degree 1 are real, *deg* must be at least 2. + + int qqbar_equal(const qqbar_t x, const qqbar_t y) + # Returns whether *x* and *y* are equal. + + int qqbar_equal_fmpq_poly_val(const qqbar_t x, const fmpq_poly_t f, const qqbar_t y) + # Returns whether *x* is equal to `f(y)`. This function is more efficient + # than evaluating `f(y)` and comparing the results. + + int qqbar_cmp_re(const qqbar_t x, const qqbar_t y) + # Compares the real parts of *x* and *y*, returning -1, 0 or +1. + + int qqbar_cmp_im(const qqbar_t x, const qqbar_t y) + # Compares the imaginary parts of *x* and *y*, returning -1, 0 or +1. + + int qqbar_cmpabs_re(const qqbar_t x, const qqbar_t y) + # Compares the absolute values of the real parts of *x* and *y*, returning -1, 0 or +1. + + int qqbar_cmpabs_im(const qqbar_t x, const qqbar_t y) + # Compares the absolute values of the imaginary parts of *x* and *y*, returning -1, 0 or +1. + + int qqbar_cmpabs(const qqbar_t x, const qqbar_t y) + # Compares the absolute values of *x* and *y*, returning -1, 0 or +1. + + int qqbar_cmp_root_order(const qqbar_t x, const qqbar_t y) + # Compares *x* and *y* using an arbitrary but convenient ordering + # defined on the complex numbers. This is useful for sorting the + # roots of a polynomial in a canonical order. + # We define the root order as follows: real roots come first, in + # descending order. Nonreal roots are subsequently ordered first by + # real part in descending order, then in ascending order by the + # absolute value of the imaginary part, and then in descending + # order of the sign. This implies that complex conjugate roots + # are adjacent, with the root in the upper half plane first. + + unsigned long qqbar_hash(const qqbar_t x) + # Returns a hash of *x*. As currently implemented, this function + # only hashes the minimal polynomial of *x*. The user should + # mix in some bits based on the numerical value if it is critical + # to distinguish between conjugates of the same minimal polynomial. + # This function is also likely to produce serial runs of values for + # lexicographically close minimal polynomials. This is not + # necessarily a problem for use in hash tables, but if it is + # important that all bits in the output are random, + # the user should apply an integer hash function to the output. + + void qqbar_conj(qqbar_t res, const qqbar_t x) + # Sets *res* to the complex conjugate of *x*. + + void qqbar_re(qqbar_t res, const qqbar_t x) + # Sets *res* to the real part of *x*. + + void qqbar_im(qqbar_t res, const qqbar_t x) + # Sets *res* to the imaginary part of *x*. + + void qqbar_re_im(qqbar_t res1, qqbar_t res2, const qqbar_t x) + # Sets *res1* to the real part of *x* and *res2* to the imaginary part of *x*. + + void qqbar_abs(qqbar_t res, const qqbar_t x) + # Sets *res* to the absolute value of *x*: + + void qqbar_abs2(qqbar_t res, const qqbar_t x) + # Sets *res* to the square of the absolute value of *x*. + + void qqbar_sgn(qqbar_t res, const qqbar_t x) + # Sets *res* to the complex sign of *x*, defined as 0 if *x* is zero + # and as `x / |x|` otherwise. + + int qqbar_sgn_re(const qqbar_t x) + # Returns the sign of the real part of *x* (-1, 0 or +1). + + int qqbar_sgn_im(const qqbar_t x) + # Returns the sign of the imaginary part of *x* (-1, 0 or +1). + + int qqbar_csgn(const qqbar_t x) + # Returns the extension of the real sign function taking the + # value 1 for *x* strictly in the right half plane, -1 for *x* strictly + # in the left half plane, and the sign of the imaginary part when *x* is on + # the imaginary axis. Equivalently, `\operatorname{csgn}(x) = x / \sqrt{x^2}` + # except that the value is 0 when *x* is zero. + + void qqbar_floor(fmpz_t res, const qqbar_t x) + # Sets *res* to the floor function of *x*. If *x* is not real, the + # value is defined as the floor function of the real part of *x*. + + void qqbar_ceil(fmpz_t res, const qqbar_t x) + # Sets *res* to the ceiling function of *x*. If *x* is not real, the + # value is defined as the ceiling function of the real part of *x*. + + void qqbar_neg(qqbar_t res, const qqbar_t x) + # Sets *res* to the negation of *x*. + + void qqbar_add(qqbar_t res, const qqbar_t x, const qqbar_t y) + void qqbar_add_fmpq(qqbar_t res, const qqbar_t x, const fmpq_t y) + void qqbar_add_fmpz(qqbar_t res, const qqbar_t x, const fmpz_t y) + void qqbar_add_ui(qqbar_t res, const qqbar_t x, unsigned long y) + void qqbar_add_si(qqbar_t res, const qqbar_t x, long y) + # Sets *res* to the sum of *x* and *y*. + + void qqbar_sub(qqbar_t res, const qqbar_t x, const qqbar_t y) + void qqbar_sub_fmpq(qqbar_t res, const qqbar_t x, const fmpq_t y) + void qqbar_sub_fmpz(qqbar_t res, const qqbar_t x, const fmpz_t y) + void qqbar_sub_ui(qqbar_t res, const qqbar_t x, unsigned long y) + void qqbar_sub_si(qqbar_t res, const qqbar_t x, long y) + void qqbar_fmpq_sub(qqbar_t res, const fmpq_t x, const qqbar_t y) + void qqbar_fmpz_sub(qqbar_t res, const fmpz_t x, const qqbar_t y) + void qqbar_ui_sub(qqbar_t res, unsigned long x, const qqbar_t y) + void qqbar_si_sub(qqbar_t res, long x, const qqbar_t y) + # Sets *res* to the difference of *x* and *y*. + + void qqbar_mul(qqbar_t res, const qqbar_t x, const qqbar_t y) + void qqbar_mul_fmpq(qqbar_t res, const qqbar_t x, const fmpq_t y) + void qqbar_mul_fmpz(qqbar_t res, const qqbar_t x, const fmpz_t y) + void qqbar_mul_ui(qqbar_t res, const qqbar_t x, unsigned long y) + void qqbar_mul_si(qqbar_t res, const qqbar_t x, long y) + # Sets *res* to the product of *x* and *y*. + + void qqbar_mul_2exp_si(qqbar_t res, const qqbar_t x, long e) + # Sets *res* to *x* multiplied by `2^e`. + + void qqbar_sqr(qqbar_t res, const qqbar_t x) + # Sets *res* to the square of *x*. + + void qqbar_inv(qqbar_t res, const qqbar_t x) + # Sets *res* to the multiplicative inverse of *y*. + # Division by zero calls *flint_abort*. + + void qqbar_div(qqbar_t res, const qqbar_t x, const qqbar_t y) + void qqbar_div_fmpq(qqbar_t res, const qqbar_t x, const fmpq_t y) + void qqbar_div_fmpz(qqbar_t res, const qqbar_t x, const fmpz_t y) + void qqbar_div_ui(qqbar_t res, const qqbar_t x, unsigned long y) + void qqbar_div_si(qqbar_t res, const qqbar_t x, long y) + void qqbar_fmpq_div(qqbar_t res, const fmpq_t x, const qqbar_t y) + void qqbar_fmpz_div(qqbar_t res, const fmpz_t x, const qqbar_t y) + void qqbar_ui_div(qqbar_t res, unsigned long x, const qqbar_t y) + void qqbar_si_div(qqbar_t res, long x, const qqbar_t y) + # Sets *res* to the quotient of *x* and *y*. + # Division by zero calls *flint_abort*. + + void qqbar_scalar_op(qqbar_t res, const qqbar_t x, const fmpz_t a, const fmpz_t b, const fmpz_t c) + # Sets *res* to the rational affine transformation `(ax+b)/c`, performed as + # a single operation. There are no restrictions on *a*, *b* and *c* + # except that *c* must be nonzero. Division by zero calls *flint_abort*. + + void qqbar_sqrt(qqbar_t res, const qqbar_t x) + void qqbar_sqrt_ui(qqbar_t res, unsigned long x) + # Sets *res* to the principal square root of *x*. + + void qqbar_rsqrt(qqbar_t res, const qqbar_t x) + # Sets *res* to the reciprocal of the principal square root of *x*. + # Division by zero calls *flint_abort*. + + void qqbar_pow_ui(qqbar_t res, const qqbar_t x, unsigned long n) + void qqbar_pow_si(qqbar_t res, const qqbar_t x, long n) + void qqbar_pow_fmpz(qqbar_t res, const qqbar_t x, const fmpz_t n) + void qqbar_pow_fmpq(qqbar_t res, const qqbar_t x, const fmpq_t n) + # Sets *res* to *x* raised to the *n*-th power. + # Raising zero to a negative power aborts. + + void qqbar_root_ui(qqbar_t res, const qqbar_t x, unsigned long n) + void qqbar_fmpq_root_ui(qqbar_t res, const fmpq_t x, unsigned long n) + # Sets *res* to the principal *n*-th root of *x*. The order *n* + # must be positive. + + void qqbar_fmpq_pow_si_ui(qqbar_t res, const fmpq_t x, long m, unsigned long n) + # Sets *res* to the principal branch of `x^{m/n}`. The order *n* + # must be positive. Division by zero calls *flint_abort*. + + int qqbar_pow(qqbar_t res, const qqbar_t x, const qqbar_t y) + # General exponentiation: if `x^y` is an algebraic number, sets *res* + # to this value and returns 1. If `x^y` is transcendental or + # undefined, returns 0. Note that this function returns 0 instead of + # aborting on division zero. + + void qqbar_get_acb(acb_t res, const qqbar_t x, long prec) + # Sets *res* to an enclosure of *x* rounded to *prec* bits. + + void qqbar_get_arb(arb_t res, const qqbar_t x, long prec) + # Sets *res* to an enclosure of *x* rounded to *prec* bits, assuming that + # *x* is a real number. If *x* is not real, *res* is set to + # `[\operatorname{NaN} \pm \infty]`. + + void qqbar_get_arb_re(arb_t res, const qqbar_t x, long prec) + # Sets *res* to an enclosure of the real part of *x* rounded to *prec* bits. + + void qqbar_get_arb_im(arb_t res, const qqbar_t x, long prec) + # Sets *res* to an enclosure of the imaginary part of *x* rounded to *prec* bits. + + void qqbar_cache_enclosure(qqbar_t res, long prec) + # Polishes the internal enclosure of *res* to at least *prec* bits + # of precision in-place. Normally, *qqbar* operations that need + # high-precision enclosures compute them on the fly without caching the results; + # if *res* will be used as an invariant operand for many operations, + # calling this function as a precomputation step can improve performance. + + void qqbar_denominator(fmpz_t res, const qqbar_t y) + # Sets *res* to the denominator of *y*, i.e. the leading coefficient + # of the minimal polynomial of *y*. + + void qqbar_numerator(qqbar_t res, const qqbar_t y) + # Sets *res* to the numerator of *y*, i.e. *y* multiplied by + # its denominator. + + void qqbar_conjugates(qqbar_ptr res, const qqbar_t x) + # Sets the entries of the vector *res* to the *d* algebraic conjugates of + # *x*, including *x* itself, where *d* is the degree of *x*. The output + # is sorted in a canonical order (as defined by :func:`qqbar_cmp_root_order`). + + void _qqbar_evaluate_fmpq_poly(qqbar_t res, const fmpz * poly, const fmpz_t den, long len, const qqbar_t x) + void qqbar_evaluate_fmpq_poly(qqbar_t res, const fmpq_poly_t poly, const qqbar_t x) + void _qqbar_evaluate_fmpz_poly(qqbar_t res, const fmpz * poly, long len, const qqbar_t x) + void qqbar_evaluate_fmpz_poly(qqbar_t res, const fmpz_poly_t poly, const qqbar_t x) + # Sets *res* to the value of the given polynomial *poly* evaluated at + # the algebraic number *x*. These methods detect simple special cases and + # automatically reduce *poly* if its degree is greater or equal + # to that of the minimal polynomial of *x*. In the generic case, evaluation + # is done by computing minimal polynomials of representation matrices. + + int qqbar_evaluate_fmpz_mpoly_iter(qqbar_t res, const fmpz_mpoly_t poly, qqbar_srcptr x, long deg_limit, long bits_limit, const fmpz_mpoly_ctx_t ctx) + int qqbar_evaluate_fmpz_mpoly_horner(qqbar_t res, const fmpz_mpoly_t poly, qqbar_srcptr x, long deg_limit, long bits_limit, const fmpz_mpoly_ctx_t ctx) + int qqbar_evaluate_fmpz_mpoly(qqbar_t res, const fmpz_mpoly_t poly, qqbar_srcptr x, long deg_limit, long bits_limit, const fmpz_mpoly_ctx_t ctx) + # Sets *res* to the value of *poly* evaluated at the algebraic numbers + # given in the vector *x*. The number of variables is defined by + # the context object *ctx*. + # The parameters *deg_limit* and *bits_limit* + # define evaluation limits: if any temporary result exceeds these limits + # (not necessarily the final value, in case of cancellation), the + # evaluation is aborted and 0 (failure) is returned. If evaluation + # succeeds, 1 is returned. + # The *iter* version iterates over all terms in succession and computes + # the powers that appear. The *horner* version uses a multivariate + # implementation of the Horner scheme. The default algorithm currently + # uses the Horner scheme. + + void qqbar_roots_fmpz_poly(qqbar_ptr res, const fmpz_poly_t poly, int flags) + void qqbar_roots_fmpq_poly(qqbar_ptr res, const fmpq_poly_t poly, int flags) + # Sets the entries of the vector *res* to the *d* roots of the polynomial + # *poly*. Roots with multiplicity appear with repetition in the + # output array. By default, the roots will be sorted in a + # convenient canonical order (as defined by :func:`qqbar_cmp_root_order`). + # Instances of a repeated root always appear consecutively. + # The following *flags* are supported: + # - QQBAR_ROOTS_IRREDUCIBLE - if set, *poly* is assumed to be + # irreducible (it may still have constant content), and no polynomial + # factorization is performed internally. + # - QQBAR_ROOTS_UNSORTED - if set, the roots will not be guaranteed + # to be sorted (except for repeated roots being listed + # consecutively). + + void qqbar_eigenvalues_fmpz_mat(qqbar_ptr res, const fmpz_mat_t mat, int flags) + void qqbar_eigenvalues_fmpq_mat(qqbar_ptr res, const fmpq_mat_t mat, int flags) + # Sets the entries of the vector *res* to the eigenvalues of the + # square matrix *mat*. These functions compute the characteristic polynomial + # of *mat* and then call :func:`qqbar_roots_fmpz_poly` with the same + # flags. + + void qqbar_root_of_unity(qqbar_t res, long p, unsigned long q) + # Sets *res* to the root of unity `e^{2 \pi i p / q}`. + + int qqbar_is_root_of_unity(long * p, unsigned long * q, const qqbar_t x) + # If *x* is not a root of unity, returns 0. + # If *x* is a root of unity, returns 1. + # If *p* and *q* are not *NULL* and *x* is a root of unity, + # this also sets *p* and *q* to the minimal integers with `0 \le p < q` + # such that `x = e^{2 \pi i p / q}`. + + void qqbar_exp_pi_i(qqbar_t res, long p, unsigned long q) + # Sets *res* to the root of unity `e^{\pi i p / q}`. + + void qqbar_cos_pi(qqbar_t res, long p, unsigned long q) + void qqbar_sin_pi(qqbar_t res, long p, unsigned long q) + int qqbar_tan_pi(qqbar_t res, long p, unsigned long q) + int qqbar_cot_pi(qqbar_t res, long p, unsigned long q) + int qqbar_sec_pi(qqbar_t res, long p, unsigned long q) + int qqbar_csc_pi(qqbar_t res, long p, unsigned long q) + # Sets *res* to the trigonometric function `\cos(\pi x)`, + # `\sin(\pi x)`, etc., with `x = \tfrac{p}{q}`. + # The functions tan, cot, sec and csc return the flag 1 if the value exists, + # and return 0 if the evaluation point is a pole of the function. + + int qqbar_log_pi_i(long * p, unsigned long * q, const qqbar_t x) + # If `y = \operatorname{log}(x) / (\pi i)` is algebraic, and hence + # necessarily rational, sets `y = p / q` to the reduced such + # fraction with `-1 < y \le 1` and returns 1. + # If *y* is not algebraic, returns 0. + + int qqbar_atan_pi(long * p, unsigned long * q, const qqbar_t x) + # If `y = \operatorname{atan}(x) / \pi` is algebraic, and hence + # necessarily rational, sets `y = p / q` to the reduced such + # fraction with `|y| < \tfrac{1}{2}` and returns 1. + # If *y* is not algebraic, returns 0. + + int qqbar_asin_pi(long * p, unsigned long * q, const qqbar_t x) + # If `y = \operatorname{asin}(x) / \pi` is algebraic, and hence + # necessarily rational, sets `y = p / q` to the reduced such + # fraction with `|y| \le \tfrac{1}{2}` and returns 1. + # If *y* is not algebraic, returns 0. + + int qqbar_acos_pi(long * p, unsigned long * q, const qqbar_t x) + # If `y = \operatorname{acos}(x) / \pi` is algebraic, and hence + # necessarily rational, sets `y = p / q` to the reduced such + # fraction with `0 \le y \le 1` and returns 1. + # If *y* is not algebraic, returns 0. + + int qqbar_acot_pi(long * p, unsigned long * q, const qqbar_t x) + # If `y = \operatorname{acot}(x) / \pi` is algebraic, and hence + # necessarily rational, sets `y = p / q` to the reduced such + # fraction with `-\tfrac{1}{2} < y \le \tfrac{1}{2}` and returns 1. + # If *y* is not algebraic, returns 0. + + int qqbar_asec_pi(long * p, unsigned long * q, const qqbar_t x) + # If `y = \operatorname{asec}(x) / \pi` is algebraic, and hence + # necessarily rational, sets `y = p / q` to the reduced such + # fraction with `0 \le y \le 1` and returns 1. + # If *y* is not algebraic, returns 0. + + int qqbar_acsc_pi(long * p, unsigned long * q, const qqbar_t x) + # If `y = \operatorname{acsc}(x) / \pi` is algebraic, and hence + # necessarily rational, sets `y = p / q` to the reduced such + # fraction with `-\tfrac{1}{2} \le y \le \tfrac{1}{2}` and returns 1. + # If *y* is not algebraic, returns 0. + + int qqbar_guess(qqbar_t res, const acb_t z, long max_deg, long max_bits, int flags, long prec) + # Attempts to find an algebraic number *res* of degree at most *max_deg* and + # height at most *max_bits* bits matching the numerical enclosure *z*. + # The return flag indicates success. + # This is only a heuristic method, and the return flag neither implies a + # rigorous proof that *res* is the correct result, nor a rigorous proof + # that no suitable algebraic number with the given *max_deg* and *max_bits* + # exists. (Proof of nonexistence could in principle be computed, + # but this is not yet implemented.) + # The working precision *prec* should normally be the same as the precision + # used to compute *z*. It does not make much sense to run this algorithm + # with precision smaller than O(*max_deg* · *max_bits*). + # This function does a single iteration at the target *max_deg*, *max_bits*, + # and *prec*. For best performance, one should invoke this function + # repeatedly with successively larger parameters when the size of the + # intended solution is unknown or may be much smaller than a worst-case bound. + + int qqbar_express_in_field(fmpq_poly_t res, const qqbar_t alpha, const qqbar_t x, long max_bits, int flags, long prec) + # Attempts to express *x* in the number field generated by *alpha*, returning + # success (0 or 1). On success, *res* is set to a polynomial *f* of degree + # less than the degree of *alpha* and with height (counting both the numerator + # and the denominator, when the coefficients of *g* are + # put on a common denominator) bounded by *max_bits* bits, such that + # `f(\alpha) = x`. + # (Exception: the *max_bits* parameter is currently ignored if *x* is + # rational, in which case *res* is just set to the value of *x*.) + # This function looks for a linear relation heuristically using a working + # precision of *prec* bits. If *x* is expressible in terms of *alpha*, + # then this function is guaranteed to succeed when *prec* is taken + # large enough. The identity `f(\alpha) = x` is checked + # rigorously, i.e. a return value of 1 implies a proof of correctness. + # In principle, choosing a sufficiently large *prec* can be used to + # prove that *x* does not lie in the field generated by *alpha*, + # but the present implementation does not support doing so automatically. + # This function does a single iteration at the target *max_bits* and + # and *prec*. For best performance, one should invoke this function + # repeatedly with successively larger parameters when the size of the + # intended solution is unknown or may be much smaller than a worst-case bound. + + void qqbar_get_quadratic(fmpz_t a, fmpz_t b, fmpz_t c, fmpz_t q, const qqbar_t x, int factoring) + # Assuming that *x* has degree 1 or 2, computes integers *a*, *b*, *c* + # and *q* such that + # .. math :: + # x = \frac{a + b \sqrt{c}}{q} + # and such that *c* is not a perfect square, *q* is positive, and + # *q* has no content in common with both *a* and *b*. In other words, + # this determines a quadratic field `\mathbb{Q}(\sqrt{c})` containing + # *x*, and then finds the canonical reduced coefficients *a*, *b* and + # *q* expressing *x* in this field. + # For convenience, this function supports rational *x*, + # for which *b* and *c* will both be set to zero. + # The following remarks apply to irrationals. + # The radicand *c* will not be a perfect square, but will not + # automatically be squarefree since this would require factoring the + # discriminant. As a special case, *c* will be set to `-1` if *x* + # is a Gaussian rational number. Otherwise, behavior is controlled + # by the *factoring* parameter. + # * If *factoring* is 0, no factorization is performed apart from + # removing powers of two. + # * If *factoring* is 1, a complete factorization is performed (*c* + # will be minimal). This can be very expensive if the discriminant + # is large. + # * If *factoring* is 2, a smooth factorization is performed to remove + # small factors from *c*. This is a tradeoff that provides pretty + # output in most cases while avoiding extreme worst-case slowdown. + # The smooth factorization guarantees finding all small factors + # (up to some trial division limit determined internally by Flint), + # but large factors are only found heuristically. + + int qqbar_set_fexpr(qqbar_t res, const fexpr_t expr) + # Sets *res* to the algebraic number represented by the symbolic + # expression *expr*, returning 1 on success and 0 on failure. + # This function performs a "static" evaluation using *qqbar* arithmetic, + # supporting only closed-form expressions with explicitly algebraic + # subexpressions. It can be used to recover values generated by + # :func:`qqbar_get_expr_formula` and variants. + # For evaluating more complex expressions involving other + # types of values or requiring symbolic simplifications, + # the user should preprocess *expr* so that it is in a form + # which can be parsed by :func:`qqbar_set_fexpr`. + # The following expressions are supported: + # * Integer constants + # * Arithmetic operations with algebraic operands + # * Square roots of algebraic numbers + # * Powers with algebraic base and exponent an explicit rational number + # * NumberI, GoldenRatio, RootOfUnity + # * Floor, Ceil, Abs, Sign, Csgn, Conjugate, Re, Im, Max, Min + # * Trigonometric functions with argument an explicit rational number times Pi + # * Exponentials with argument an explicit rational number times Pi * NumberI + # * The Decimal() constructor + # * AlgebraicNumberSerialized() (assuming valid data, which is not checked) + # * PolynomialRootIndexed() + # * PolynomialRootNearest() + # Examples of formulas that are not supported, despite the value being + # an algebraic number: + # * ``Pi - Pi`` (general transcendental simplifications are not performed) + # * ``1 / Infinity`` (only numbers are handled) + # * ``Sum(n, For(n, 1, 10))`` (only static evaluation is performed) + + void qqbar_get_fexpr_repr(fexpr_t res, const qqbar_t x) + # Sets *res* to a symbolic expression reflecting the exact internal + # representation of *x*. The output will have the form + # ``AlgebraicNumberSerialized(List(coeffs), enclosure)``. + # The output can be converted back to a ``qqbar_t`` value using + # :func:`qqbar_set_fexpr`. This is the recommended format for + # serializing algebraic numbers as it requires minimal computation, + # but it has the disadvantage of not being human-readable. + + void qqbar_get_fexpr_root_nearest(fexpr_t res, const qqbar_t x) + # Sets *res* to a symbolic expression unambiguously describing *x* + # in the form ``PolynomialRootNearest(List(coeffs), point)`` + # where *point* is an approximation of *x* guaranteed to be closer + # to *x* than any conjugate root. + # The output can be converted back to a ``qqbar_t`` value using + # :func:`qqbar_set_fexpr`. This is a useful format for human-readable + # presentation, but serialization and deserialization can be expensive. + + void qqbar_get_fexpr_root_indexed(fexpr_t res, const qqbar_t x) + # Sets *res* to a symbolic expression unambiguously describing *x* + # in the form ``PolynomialRootIndexed(List(coeffs), index)`` + # where *index* is the index of *x* among its conjugate roots + # in the builtin root sort order. + # The output can be converted back to a ``qqbar_t`` value using + # :func:`qqbar_set_fexpr`. This is a useful format for human-readable + # presentation when the numerical value is important, but serialization + # and deserialization can be expensive. + + int qqbar_get_fexpr_formula(fexpr_t res, const qqbar_t x, unsigned long flags) + # Attempts to express the algebraic number *x* as a closed-form expression + # using arithmetic operations, radicals, and possibly exponentials + # or trigonometric functions, but without using ``PolynomialRootNearest`` + # or ``PolynomialRootIndexed``. + # Returns 0 on failure and 1 on success. + # The *flags* parameter toggles different methods for generating formulas. + # It can be set to any combination of the following. If *flags* is 0, + # only rational numbers will be handled. + # .. macro:: QQBAR_FORMULA_ALL + # Toggles all methods (potentially expensive). + # .. macro:: QQBAR_FORMULA_GAUSSIANS + # Detect Gaussian rational numbers `a + bi`. + # .. macro:: QQBAR_FORMULA_QUADRATICS + # Solve quadratics in the form `a + b \sqrt{d}`. + # .. macro:: QQBAR_FORMULA_CYCLOTOMICS + # Detect elements of cyclotomic fields. This works by trying plausible + # cyclotomic fields (based on the degree of the input), using LLL + # to find candidate number field elements, and certifying candidates + # through an exact computation. Detection is heuristic and + # is not guaranteed to find all cyclotomic numbers. + # .. macro:: QQBAR_FORMULA_CUBICS + # QQBAR_FORMULA_QUARTICS + # QQBAR_FORMULA_QUINTICS + # Solve polynomials of degree 3, 4 and (where applicable) 5 using + # cubic, quartic and quintic formulas (not yet implemented). + # .. macro:: QQBAR_FORMULA_DEPRESSION + # Use depression to try to generate simpler numbers. + # .. macro:: QQBAR_FORMULA_DEFLATION + # Use deflation to try to generate simpler numbers. + # This allows handling number of the form `a^{1/n}` where *a* can + # be represented in closed form. + # .. macro:: QQBAR_FORMULA_SEPARATION + # Try separating real and imaginary parts or sign and magnitude of + # complex numbers. This allows handling numbers of the form `a + bi` + # or `m \cdot s` (with `m > 0, |s| = 1`) where *a* and *b* or *m* and *s* can be + # represented in closed form. This is only attempted as a fallback after + # other methods fail: if an explicit Cartesian or magnitude-sign + # represented is desired, the user should manually separate the number + # into complex parts before calling :func:`qqbar_get_fexpr_formula`. + # .. macro:: QQBAR_FORMULA_EXP_FORM + # QQBAR_FORMULA_TRIG_FORM + # QQBAR_FORMULA_RADICAL_FORM + # QQBAR_FORMULA_AUTO_FORM + # Select output form for cyclotomic numbers. The *auto* form (equivalent + # to no flags being set) results in radicals for numbers of low degree, + # trigonometric functions for real numbers, and complex exponentials + # for nonreal numbers. The other flags (not fully implemented) can be + # used to force exponential form, trigonometric form, or radical form. + + void qqbar_fmpz_poly_composed_op(fmpz_poly_t res, const fmpz_poly_t A, const fmpz_poly_t B, int op) + # Given nonconstant polynomials *A* and *B*, sets *res* to a polynomial + # whose roots are `a+b`, `a-b`, `ab` or `a/b` for all roots *a* of *A* + # and all roots *b* of *B*. The parameter *op* selects the arithmetic + # operation: 0 for addition, 1 for subtraction, 2 for multiplication + # and 3 for division. If *op* is 3, *B* must not have zero as a root. + + void qqbar_binary_op(qqbar_t res, const qqbar_t x, const qqbar_t y, int op) + # Performs a binary operation using a generic algorithm. This does not + # check for special cases. + + int _qqbar_validate_uniqueness(acb_t res, const fmpz_poly_t poly, const acb_t z, long max_prec) + # Given *z* known to be an enclosure of at least one root of *poly*, + # certifies that the enclosure contains a unique root, and in that + # case sets *res* to a new (possibly improved) enclosure for the same + # root, returning 1. Returns 0 if uniqueness cannot be certified. + # The enclosure is validated by performing a single step with the + # interval Newton method. The working precision is determined from the + # accuracy of *z*, but limited by *max_prec* bits. + # This method slightly inflates the enclosure *z* to improve the chances + # that the interval Newton step will succeed. Uniqueness on this larger + # interval implies uniqueness of the original interval, but not + # existence; when existence has not been ensured a priori, + # :func:`_qqbar_validate_existence_uniqueness` should be used instead. + + int _qqbar_validate_existence_uniqueness(acb_t res, const fmpz_poly_t poly, const acb_t z, long max_prec) + # Given any complex interval *z*, certifies that the enclosure contains a + # unique root of *poly*, and in that case sets *res* to a new (possibly + # improved) enclosure for the same root, returning 1. Returns 0 if + # existence and uniqueness cannot be certified. + # The enclosure is validated by performing a single step with the + # interval Newton method. The working precision is determined from the + # accuracy of *z*, but limited by *max_prec* bits. + + void _qqbar_enclosure_raw(acb_t res, const fmpz_poly_t poly, const acb_t z, long prec) + void qqbar_enclosure_raw(acb_t res, const qqbar_t x, long prec) + # Sets *res* to an enclosure of *x* accurate to about *prec* bits + # (the actual accuracy can be slightly lower, or higher). + # This function uses repeated interval Newton steps to polish the initial + # enclosure *z*, doubling the working precision each time. If any step + # fails to improve the accuracy significantly, the root is recomputed + # from scratch to higher precision. + # If the initial enclosure is accurate enough, *res* is set to this value + # without rounding and without further computation. + + int _qqbar_acb_lindep(fmpz * rel, acb_srcptr vec, long len, int check, long prec) + # Attempts to find an integer vector *rel* giving a linear relation between + # the elements of the real or complex vector *vec*, using the LLL algorithm. + # The working precision is set to the minimum of *prec* and the relative + # accuracy of *vec* (that is, the difference between the largest magnitude + # and the largest error magnitude within *vec*). 95% of the bits within the + # working precision are used for the LLL matrix, and the remaining 5% bits + # are used to validate the linear relation by evaluating the linear + # combination and checking that the resulting interval contains zero. + # This validation does not prove the existence or nonexistence + # of a linear relation, but it provides a quick heuristic way to eliminate + # spurious relations. + # If *check* is set, the return value indicates whether the validation + # was successful; otherwise, the return value simply indicates whether + # the algorithm was executed normally (failure may occur, for example, + # if the input vector is non-finite). + # In principle, this method can be used to produce a proof that no linear + # relation exists with coefficients up to a specified bit size, but this has + # not yet been implemented. diff --git a/src/sage/libs/flint/types.pxd b/src/sage/libs/flint/types.pxd index aa00e501604..4b85230ce5b 100644 --- a/src/sage/libs/flint/types.pxd +++ b/src/sage/libs/flint/types.pxd @@ -23,22 +23,6 @@ ctypedef mp_limb_t flint_bitcnt_t cdef extern from "flint_wrap.h": - # flint/d_mat.h - ctypedef struct d_mat_struct: - double * entries - slong r - slong c - double ** rows - - ctypedef d_mat_struct d_mat_t[1] - - - # flint/flint.h - ctypedef void* flint_rand_t - cdef long FLINT_BITS - cdef long FLINT_D_BITS - - # flint/fmpz.h ctypedef slong fmpz ctypedef fmpz fmpz_t[1] @@ -70,6 +54,144 @@ cdef extern from "flint_wrap.h": ctypedef fmpz_multi_CRT_struct fmpz_multi_CRT_t[1] + # flint/fmpq.h + ctypedef struct fmpq: + pass + + ctypedef fmpq fmpq_t[1] + + + # flint/arith.h + ctypedef struct trig_prod_struct: + pass + ctypedef trig_prod_struct trig_prod_t[1] + + + # flint/ulong_extras.pxd + ctypedef struct n_ecm_s: + pass + ctypedef n_ecm_s n_ecm_t[1]; + + + # flint/arf.h + ctypedef struct arf_struct: + pass + ctypedef arf_struct arf_t[1] + ctypedef arf_struct * arf_ptr + ctypedef const arf_struct * arf_srcptr + cdef enum arf_rnd_t: + ARF_RND_DOWN + ARF_RND_UP + ARF_RND_FLOOR + ARF_RND_CEIL + ARF_RND_NEAR + long ARF_PREC_EXACT + + + # flint/arb_types.h + ctypedef struct mag_struct: + pass + ctypedef mag_struct mag_t[1] + ctypedef mag_struct * mag_ptr + ctypedef const mag_struct * mag_srcptr + + ctypedef struct arb_struct: + pass + ctypedef arb_struct arb_t[1] + ctypedef arb_struct * arb_ptr + ctypedef const arb_struct * arb_srcptr + + ctypedef struct arb_mat_struct: + arb_ptr entries + slong r + slong c + arb_ptr * rows + ctypedef arb_mat_struct arb_mat_t[1] + + ctypedef struct arb_poly_struct: + pass + ctypedef arb_poly_struct[1] arb_poly_t + ctypedef arb_poly_struct * arb_poly_ptr + ctypedef const arb_poly_struct * arb_poly_srcptr + + + # flint/arb_calc.h + ctypedef int (*arb_calc_func_t)(arb_ptr out, const arb_t inp, + void * param, slong order, slong prec) + + + # flint/acb.h + ctypedef struct acb_struct: + pass + ctypedef acb_struct[1] acb_t + ctypedef acb_struct * acb_ptr + ctypedef const acb_struct * acb_srcptr + + + + # flint/acb_mat.h + ctypedef struct acb_mat_struct: + pass + ctypedef acb_mat_struct[1] acb_mat_t + + + # flint/acb_modular.h + ctypedef struct psl2z_struct: + fmpz a + fmpz b + fmpz c + fmpz d + ctypedef psl2z_struct psl2z_t[1]; + + + # flint/acb_poly.h + ctypedef struct acb_poly_struct: + pass + ctypedef acb_poly_struct[1] acb_poly_t + ctypedef acb_poly_struct * acb_poly_ptr + ctypedef const acb_poly_struct * acb_poly_srcptr + + # flint/acb_calc.h + ctypedef struct acb_calc_integrate_opt_struct: + long deg_limit + long eval_limit + long depth_limit + bint use_heap + int verbose + ctypedef acb_calc_integrate_opt_struct acb_calc_integrate_opt_t[1] + ctypedef int (*acb_calc_func_t)(acb_ptr out, + const acb_t inp, void * param, long order, long prec) + + # flint/d_mat.h + ctypedef struct d_mat_struct: + double * entries + slong r + slong c + double ** rows + + ctypedef d_mat_struct d_mat_t[1] + + + # flint/flint.h + ctypedef void* flint_rand_t + cdef long FLINT_BITS + cdef long FLINT_D_BITS + + + # flint/limb_types.h + ctypedef struct n_factor_t: + int num + unsigned long exp[15] + unsigned long p[15] + + ctypedef struct n_primes_struct: + pass + + ctypedef n_primes_struct n_primes_t[1] + + long FLINT_MAX_FACTORS_IN_LIMB + + # flint/fmpz_factor.h ctypedef struct ecm_s: pass @@ -78,11 +200,6 @@ cdef extern from "flint_wrap.h": # flint/fmpz_mod.h - ctypedef struct fmpz_mod_ctx_struct: - pass - - ctypedef fmpz_mod_ctx_struct fmpz_mod_ctx_t[1] - ctypedef struct fmpz_mod_discrete_log_pohlig_hellman_entry_struct: pass @@ -152,6 +269,25 @@ cdef extern from "flint_wrap.h": ctypedef fmpzi_struct fmpzi_t[1] + # flint/fmpz_poly.h + ctypedef struct fmpz_poly_powers_precomp_struct: + fmpz ** powers + slong len + + ctypedef fmpz_poly_powers_precomp_struct fmpz_poly_powers_precomp_t[1] + + ctypedef struct fmpz_poly_mul_precache_struct: + mp_limb_t ** jj + slong n + slong len2 + slong loglen + slong bits2 + slong limbs + fmpz_poly_t poly2 + + ctypedef fmpz_poly_mul_precache_struct fmpz_poly_mul_precache_t[1] + + # flint/fmpz_mod_types.h ctypedef struct fmpz_mod_ctx_struct: pass @@ -199,19 +335,18 @@ cdef extern from "flint_wrap.h": ctypedef fmpz_mod_mpoly_factor_struct fmpz_mod_mpoly_factor_t[1] - # flint/fmpq.h - ctypedef struct fmpq: - pass - - ctypedef fmpq fmpq_t[1] - - # flint/fmpq_poly.h ctypedef struct fmpq_poly_struct: pass ctypedef fmpq_poly_struct fmpq_poly_t[1] + ctypedef struct fmpq_poly_powers_precomp_struct: + fmpq_poly_struct * powers + slong len + + ctypedef fmpq_poly_powers_precomp_struct fmpq_poly_powers_precomp_t[1] + # flint/fmpq_mat.h ctypedef struct fmpq_mat_struct: @@ -221,11 +356,6 @@ cdef extern from "flint_wrap.h": # flint/fmpz_mod_poly.h: - ctypedef struct fmpz_mod_poly_struct: - pass - - ctypedef fmpz_mod_poly_struct fmpz_mod_poly_t[1] - ctypedef struct fmpz_mod_poly_res_struct: pass @@ -264,22 +394,6 @@ cdef extern from "flint_wrap.h": mp_limb_t ninv mp_bitcnt_t norm - ctypedef struct nmod_poly_struct: - mp_limb_t *coeffs - long alloc - long length - nmod_t mod - - ctypedef nmod_poly_struct nmod_poly_t[1] - - ctypedef struct nmod_poly_factor_struct: - nmod_poly_t p - long *exp - long num - long alloc - - ctypedef nmod_poly_factor_struct nmod_poly_factor_t[1] - ctypedef struct nmod_poly_multi_crt_struct: pass @@ -366,13 +480,6 @@ cdef extern from "flint_wrap.h": ctypedef nmod_poly_t fq_nmod_t - # flint/ulong_extras.h - ctypedef struct n_factor_t: - int num - unsigned long exp[15] - unsigned long p[15] - - # flint/padic.h ctypedef struct padic_struct: fmpz u @@ -439,3 +546,9 @@ cdef extern from "flint_wrap.h": ctypedef thread_pool_struct thread_pool_t[1] ctypedef int thread_pool_handle + + + # flint/bernoulli.h + ctypedef struct bernoulli_rev_struct: + pass + ctypedef bernoulli_rev_struct bernoulli_rev_t[1] diff --git a/src/sage/libs/flint/ulong_extras.pxd b/src/sage/libs/flint/ulong_extras.pxd index b56f11d44db..e9a73640a98 100644 --- a/src/sage/libs/flint/ulong_extras.pxd +++ b/src/sage/libs/flint/ulong_extras.pxd @@ -1,15 +1,1107 @@ # distutils: libraries = flint # distutils: depends = flint/ulong_extras.h -from sage.libs.flint.types cimport n_factor_t +################################################################################ +# This file is auto-generated. Do not modify by hand +################################################################################ + +from libc.stdio cimport FILE +from sage.libs.gmp.types cimport * +from sage.libs.mpfr.types cimport * +from sage.libs.flint.types cimport * -# flint/ulong_extras.h cdef extern from "flint_wrap.h": - cdef int n_jacobi(long x, unsigned long y) - cdef int n_is_prime(unsigned long n) + unsigned long n_randlimb(flint_rand_t state) + # Returns a uniformly pseudo random limb. + # The algorithm generates two random half limbs `s_j`, `j = 0, 1`, + # by iterating respectively `v_{i+1} = (v_i a + b) \bmod{p_j}` for + # some initial seed `v_0`, randomly chosen values `a` and `b` and + # ``p_0 = 4294967311 = nextprime(2^32)`` on a 64-bit machine + # and ``p_0 = nextprime(2^16)`` on a 32-bit machine and + # ``p_1 = nextprime(p_0)``. + + unsigned long n_randbits(flint_rand_t state, unsigned int bits) + # Returns a uniformly pseudo random number with the given number of + # bits. The most significant bit is always set, unless zero is passed, + # in which case zero is returned. + + unsigned long n_randtest_bits(flint_rand_t state, int bits) + # Returns a uniformly pseudo random number with the given number of + # bits. The most significant bit is always set, unless zero is passed, + # in which case zero is returned. The probability of a value with a + # sparse binary representation being returned is increased. This + # function is intended for use in test code. + + unsigned long n_randint(flint_rand_t state, unsigned long limit) + # Returns a uniformly pseudo random number up to but not including + # the given limit. If zero is passed as a parameter, an entire random + # limb is returned. + + unsigned long n_urandint(flint_rand_t state, unsigned long limit) + # Returns a uniformly pseudo random number up to but not including + # the given limit. If zero is passed as a parameter, an entire + # random limb is returned. This function provides somewhat better + # randomness as compared to :func:`n_randint`, especially for larger + # values of limit. + + unsigned long n_randtest(flint_rand_t state) + # Returns a pseudo random number with a random number of bits, + # from `0` to ``FLINT_BITS``. The probability of the special + # values `0`, `1`, ``COEFF_MAX`` and ``WORD_MAX`` is increased + # as is the probability of a value with sparse binary representation. + # This random function is mainly used for testing purposes. + # This function is intended for use in test code. + + unsigned long n_randtest_not_zero(flint_rand_t state) + # As for :func:`n_randtest`, but does not return `0`. + # This function is intended for use in test code. + + unsigned long n_randprime(flint_rand_t state, unsigned long bits, int proved) + # Returns a random prime number ``(proved = 1)`` or probable prime + # ``(proved = 0)`` + # with ``bits`` bits, where ``bits`` must be at least 2 and + # at most ``FLINT_BITS``. + + unsigned long n_randtest_prime(flint_rand_t state, int proved) + # Returns a random prime number ``(proved = 1)`` or probable + # prime ``(proved = 0)`` + # with size randomly chosen between 2 and ``FLINT_BITS`` bits. + # This function is intended for use in test code. + + unsigned long n_pow(unsigned long n, unsigned long exp) + # Returns ``n^exp``. No checking is done for overflow. The exponent + # may be zero. We define `0^0 = 1`. + # The algorithm simply uses a for loop. Repeated squaring is + # unlikely to speed up this algorithm. + + unsigned long n_flog(unsigned long n, unsigned long b) + # Returns `\lfloor\log_b n\rfloor`. + # Assumes that `n \geq 1` and `b \geq 2`. + + unsigned long n_clog(unsigned long n, unsigned long b) + # Returns `\lceil\log_b n\rceil`. + # Assumes that `n \geq 1` and `b \geq 2`. + + unsigned long n_clog_2exp(unsigned long n, unsigned long b) + # Returns `\lceil\log_b 2^n\rceil`. + # Assumes that `b \geq 2`. + + unsigned long n_revbin(unsigned long n, unsigned long b) + # Returns the binary reverse of `n`, assuming it is `b` bits in length, + # e.g. ``n_revbin(10110, 6)`` will return ``110100``. + + int n_sizeinbase(unsigned long n, int base) + # Returns the exact number of digits needed to represent `n` as a + # string in base ``base`` assumed to be between 2 and 36. + # Returns 1 when `n = 0`. + + unsigned long n_preinvert_limb_prenorm(unsigned long n) + # Computes an approximate inverse ``invxl`` of the limb ``xl``, + # with an implicit leading~`1`. More formally it computes:: + # invxl = (B^2 - B*x - 1)/x = (B^2 - 1)/x - B + # Note that `x` must be normalised, i.e. with msb set. This inverse + # makes use of the following theorem of Torbjorn Granlund and Peter + # Montgomery~[Lemma~8.1][GraMon1994]_: + # Let `d` be normalised, `d < B`, i.e. it fits in a word, and suppose + # that `m d < B^2 \leq (m+1) d`. Let `0 \leq n \leq B d - 1`. Write + # `n = n_2 B + n_1 B/2 + n_0` with `n_1 = 0` or `1` and `n_0 < B/2`. + # Suppose `q_1 B + q_0 = n_2 B + (n_2 + n_1) (m - B) + n_1 (d-B/2) + n_0` + # and `0 \leq q_0 < B`. Then `0 \leq q_1 < B` and `0 \leq n - q_1 d < 2 d`. + # In the theorem, `m` is the inverse of `d`. If we let + # ``m = invxl + B`` and `d = x` we have `m d = B^2 - 1 < B^2` and + # `(m+1) x = B^2 + d - 1 \geq B^2`. + # The theorem is often applied as follows: note that `n_0` and `n_1 (d-B/2)` + # are both less than `B/2`. Also note that `n_1 (m-B) < B`. Thus the sum of + # all these terms contributes at most `1` to `q_1`. We are left with + # `n_2 B + n_2 (m-B)`. But note that `(m-B)` is precisely our precomputed + # inverse ``invxl``. If we write `q_1 B + q_0 = n_2 B + n_2 (m-B)`, + # then from the theorem, we have `0 \leq n - q_1 d < 3 d`, i.e. the + # quotient is out by at most `2` and is always either correct or too small. + + unsigned long n_preinvert_limb(unsigned long n) + # Returns a precomputed inverse of `n`, as defined in [GraMol2010]_. + # This precomputed inverse can be used with all of the functions that + # take a precomputed inverse whose names are suffixed by ``_preinv``. + # We require `n > 0`. + + double n_precompute_inverse(unsigned long n) + # Returns a precomputed inverse of `n` with double precision value `1/n`. + # This precomputed inverse can be used with all of the functions that + # take a precomputed inverse whose names are suffixed by ``_precomp``. + # We require `n > 0`. + + unsigned long n_mod_precomp(unsigned long a, unsigned long n, double ninv) + # Returns `a \bmod{n}` given a precomputed inverse of `n` computed + # by :func:`n_precompute_inverse`. We require ``n < 2^FLINT_D_BITS`` + # and ``a < 2^(FLINT_BITS-1)`` and `0 \leq a < n^2`. + # We assume the processor is in the standard round to nearest + # mode. Thus ``ninv`` is correct to `53` binary bits, the least + # significant bit of which we shall call a place, and can be at most + # half a place out. When `a` is multiplied by `ninv`, the binary + # representation of `a` is exact and the mantissa is less than `2`, thus we + # see that ``a * ninv`` can be at most one out in the mantissa. We now + # truncate ``a * ninv`` to the nearest integer, which is always a round + # down. Either we already have an integer, or we need to make a change down + # of at least `1` in the last place. In the latter case we either get + # precisely the exact quotient or below it as when we rounded the + # product to the nearest place we changed by at most half a place. + # In the case that truncating to an integer takes us below the + # exact quotient, we have rounded down by less than `1` plus half a + # place. But as the product is less than `n` and `n` is less than `2^{53}`, + # half a place is less than `1`, thus we are out by less than `2` from + # the exact quotient, i.e. the quotient we have computed is the + # quotient we are after or one too small. That leaves only the case + # where we had to round up to the nearest place which happened to + # be an integer, so that truncating to an integer didn't change + # anything. But this implies that the exact quotient `a/n` is less + # than `2^{-54}` from an integer. We deal with this rare case by + # subtracting 1 from the quotient. Then the quotient we have computed is + # either exactly what we are after, or one too small. + + unsigned long n_mod2_precomp(unsigned long a, unsigned long n, double ninv) + # Returns `a \bmod{n}` given a precomputed inverse of `n` computed by + # :func:`n_precompute_inverse`. There are no restrictions on `a` or + # on `n`. + # As for :func:`n_mod_precomp` for `n < 2^{53}` and `a < n^2` the + # computed quotient is either what we are after or one too large or small. + # We deal with these cases. Otherwise we can be sure that the + # top `52` bits of the quotient are computed correctly. We take + # the remainder and adjust the quotient by multiplying the + # remainder by ``ninv`` to compute another approximate quotient as + # per :func:`mod_precomp`. Now the remainder may be either + # negative or positive, so the quotient we compute may be one + # out in either direction. + + unsigned long n_divrem2_preinv(unsigned long * q, unsigned long a, unsigned long n, unsigned long ninv) + # Returns `a \bmod{n}` and sets `q` to the quotient of `a` by `n`, given a + # precomputed inverse of `n` computed by :func:`n_preinvert_limb()`. There are + # no restrictions on `a` and the only restriction on `n` is that it be + # nonzero. + # This uses the algorithm of Granlund and Möller [GraMol2010]_. First + # `n` is normalised and `a` is shifted into two limbs to compensate. Then + # their algorithm is applied verbatim and the remainder shifted back. + + unsigned long n_div2_preinv(unsigned long a, unsigned long n, unsigned long ninv) + # Returns the Euclidean quotient of `a` by `n` given a precomputed inverse of + # `n` computed by :func:`n_preinvert_limb`. There are no restrictions on `a` + # and the only restriction on `n` is that it be nonzero. + # This uses the algorithm of Granlund and Möller [GraMol2010]_. First + # `n` is normalised and `a` is shifted into two limbs to compensate. Then + # their algorithm is applied verbatim. + + unsigned long n_mod2_preinv(unsigned long a, unsigned long n, unsigned long ninv) + # Returns `a \bmod{n}` given a precomputed inverse of `n` computed by + # :func:`n_preinvert_limb()`. There are no restrictions on `a` and the only + # restriction on `n` is that it be nonzero. + # This uses the algorithm of Granlund and Möller [GraMol2010]_. First + # `n` is normalised and `a` is shifted into two limbs to compensate. Then + # their algorithm is applied verbatim and the result shifted back. + + unsigned long n_divrem2_precomp(unsigned long * q, unsigned long a, unsigned long n, double npre) + # Returns `a \bmod{n}` given a precomputed inverse of `n` computed by + # :func:`n_precompute_inverse` and sets `q` to the quotient. There + # are no restrictions on `a` or on `n`. + # This is as for :func:`n_mod2_precomp` with some additional care taken + # to retain the quotient information. There are also special + # cases to deal with the case where `a` is already reduced modulo + # `n` and where `n` is `64` bits and `a` is not reduced modulo `n`. + + unsigned long n_ll_mod_preinv(unsigned long a_hi, unsigned long a_lo, unsigned long n, unsigned long ninv) + # Returns `a \bmod{n}` given a precomputed inverse of `n` computed by + # :func:`n_preinvert_limb`. There are no restrictions on `a`, which + # will be two limbs ``(a_hi, a_lo)``, or on `n`. + # The old version of this function merely reduced the top limb + # ``a_hi`` modulo `n` so that :func:`udiv_qrnnd_preinv()` could + # be used. + # The new version reduces the top limb modulo `n` as per + # :func:`n_mod2_preinv` and then the algorithm of Granlund and + # Möller [GraMol2010]_ is used again to reduce modulo `n`. + + unsigned long n_lll_mod_preinv(unsigned long a_hi, unsigned long a_mi, unsigned long a_lo, unsigned long n, unsigned long ninv) + # Returns `a \bmod{n}`, where `a` has three limbs ``(a_hi, a_mi, a_lo)``, + # given a precomputed inverse of `n` computed by :func:`n_preinvert_limb`. + # It is assumed that ``a_hi`` is reduced modulo `n`. There are no + # restrictions on `n`. + # This function uses the algorithm of Granlund and + # Möller [GraMol2010]_ to first reduce the top two limbs + # modulo `n`, then does the same on the bottom two limbs. + + unsigned long n_mulmod_precomp(unsigned long a, unsigned long b, unsigned long n, double ninv) + # Returns `a b \bmod{n}` given a precomputed inverse of `n` + # computed by :func:`n_precompute_inverse`. We require + # ``n < 2^FLINT_D_BITS`` and `0 \leq a, b < n`. + # We assume the processor is in the standard round to nearest + # mode. Thus ``ninv`` is correct to `53` binary bits, the least + # significant bit of which we shall call a place, and can be at most half + # a place out. The product of `a` and `b` is computed with error at most + # half a place. When ``a * b`` is multiplied by `ninv` we find that the + # exact quotient and computed quotient differ by less than two places. As + # the quotient is less than `n` this means that the exact quotient is at + # most `1` away from the computed quotient. We truncate this quotient to + # an integer which reduces the value by less than `1`. We end up with a + # value which can be no more than two above the quotient we are after and + # no less than two below. However an argument similar to that for + # :func:`n_mod_precomp` shows that the truncated computed quotient cannot + # be two smaller than the truncated exact quotient. In other words the + # computed integer quotient is at most two above and one below the quotient + # we are after. + + unsigned long n_mulmod2_preinv(unsigned long a, unsigned long b, unsigned long n, unsigned long ninv) + # Returns `a b \bmod{n}` given a precomputed inverse of `n` computed by + # :func:`n_preinvert_limb`. There are no restrictions on `a`, `b` or + # on `n`. This is implemented by multiplying using :func:`umul_ppmm` and + # then reducing using :func:`n_ll_mod_preinv`. + + unsigned long n_mulmod2(unsigned long a, unsigned long b, unsigned long n) + # Returns `a b \bmod{n}`. There are no restrictions on `a`, `b` or + # on `n`. This is implemented by multiplying using :func:`umul_ppmm` and + # then reducing using :func:`n_ll_mod_preinv` after computing a precomputed + # inverse. + + unsigned long n_mulmod_preinv(unsigned long a, unsigned long b, unsigned long n, unsigned long ninv, unsigned long norm) + # Returns `a b \pmod{n}` given a precomputed inverse of `n` computed by + # :func:`n_preinvert_limb`, assuming `a` and `b` are reduced modulo `n` + # and `n` is normalised, i.e. with most significant bit set. There are + # no other restrictions on `a`, `b` or `n`. + # The value ``norm`` is provided for convenience. As `n` is required + # to be normalised, it may be that `a` and `b` have been shifted to the + # left by ``norm`` bits before calling the function. Their product + # then has an extra factor of `2^\text{norm}`. Specifying a nonzero + # ``norm`` will shift the product right by this many bits before + # reducing it. + # The algorithm used is that of Granlund and Möller [GraMol2010]_. + + unsigned long n_gcd(unsigned long x, unsigned long y) + # Returns the greatest common divisor `g` of `x` and `y`. No assumptions + # are made about the values `x` and `y`. + # This function wraps GMP's ``mpn_gcd_1``. + + unsigned long n_gcdinv(unsigned long * a, unsigned long x, unsigned long y) + # Returns the greatest common divisor `g` of `x` and `y` and computes + # `a` such that `0 \leq a < y` and `a x = \gcd(x, y) \bmod{y}`, when + # this is defined. We require `x < y`. + # When `y = 1` the greatest common divisor is set to `1` and `a` is + # set to `0`. + # This is merely an adaption of the extended Euclidean algorithm + # computing just one cofactor and reducing it modulo `y`. + + unsigned long n_xgcd(unsigned long * a, unsigned long * b, unsigned long x, unsigned long y) + # Returns the greatest common divisor `g` of `x` and `y` and unsigned + # values `a` and `b` such that `a x - b y = g`. We require `x \geq y`. + # We claim that computing the extended greatest common divisor via the + # Euclidean algorithm always results in cofactor `\lvert a \rvert < x/2`, + # `\lvert b\rvert < x/2`, with perhaps some small degenerate exceptions. + # We proceed by induction. + # Suppose we are at some step of the algorithm, with `x_n = q y_n + r` + # with `r \geq 1`, and suppose `1 = s y_n - t r` with + # `s < y_n / 2`, `t < y_n / 2` by hypothesis. + # Write `1 = s y_n - t (x_n - q y_n) = (s + t q) y_n - t x_n`. + # It suffices to show that `(s + t q) < x_n / 2` as `t < y_n / 2 < x_n / 2`, + # which will complete the induction step. + # But at the previous step in the backsubstitution we would have had + # `1 = s r - c d` with `s < r/2` and `c < r/2`. + # Then `s + t q < r/2 + y_n / 2 q = (r + q y_n)/2 = x_n / 2`. + # See the documentation of :func:`n_gcd` for a description of the + # branching in the algorithm, which is faster than using division. + + int n_jacobi(mp_limb_signed_t x, unsigned long y) + # Computes the Jacobi symbol `\left(\frac{x}{y}\right)` for any `x` and odd `y`. + + int n_jacobi_unsigned(unsigned long x, unsigned long y) + # Computes the Jacobi symbol, allowing `x` to go up to a full limb. + + unsigned long n_addmod(unsigned long a, unsigned long b, unsigned long n) + # Returns `(a + b) \bmod{n}`. + + unsigned long n_submod(unsigned long a, unsigned long b, unsigned long n) + # Returns `(a - b) \bmod{n}`. + + unsigned long n_invmod(unsigned long x, unsigned long y) + # Returns the inverse of `x` modulo `y`, if it exists. Otherwise an exception + # is thrown. + # This is merely an adaption of the extended Euclidean algorithm + # with appropriate normalisation. + + unsigned long n_powmod_precomp(unsigned long a, mp_limb_signed_t exp, unsigned long n, double npre) + # Returns ``a^exp`` modulo `n` given a precomputed inverse of `n` + # computed by :func:`n_precompute_inverse`. We require `n < 2^{53}` + # and `0 \leq a < n`. There are no restrictions on ``exp``, i.e. + # it can be negative. + # This is implemented as a standard binary powering algorithm using + # repeated squaring and reducing modulo `n` at each step. + + unsigned long n_powmod_ui_precomp(unsigned long a, unsigned long exp, unsigned long n, double npre) + # Returns ``a^exp`` modulo `n` given a precomputed inverse of `n` + # computed by :func:`n_precompute_inverse`. We require `n < 2^{53}` + # and `0 \leq a < n`. The exponent ``exp`` is unsigned and so + # can be larger than allowed by :func:`n_powmod_precomp`. + # This is implemented as a standard binary powering algorithm using + # repeated squaring and reducing modulo `n` at each step. + + unsigned long n_powmod(unsigned long a, mp_limb_signed_t exp, unsigned long n) + # Returns ``a^exp`` modulo `n`. We require ``n < 2^FLINT_D_BITS`` + # and `0 \leq a < n`. There are no restrictions on ``exp``, i.e. + # it can be negative. + # This is implemented by precomputing an inverse and calling the + # ``precomp`` version of this function. + + unsigned long n_powmod2_preinv(unsigned long a, mp_limb_signed_t exp, unsigned long n, unsigned long ninv) + # Returns ``(a^exp) % n`` given a precomputed inverse of `n` computed + # by :func:`n_preinvert_limb`. We require `0 \leq a < n`, but there are no + # restrictions on `n` or on ``exp``, i.e. it can be negative. + # This is implemented as a standard binary powering algorithm using + # repeated squaring and reducing modulo `n` at each step. + # If ``exp`` is negative but `a` is not invertible modulo `n`, an + # exception is raised. + + unsigned long n_powmod2(unsigned long a, mp_limb_signed_t exp, unsigned long n) + # Returns ``(a^exp) % n``. We require `0 \leq a < n`, but there are + # no restrictions on `n` or on ``exp``, i.e. it can be negative. + # This is implemented by precomputing an inverse limb and calling the + # ``preinv`` version of this function. + # If ``exp`` is negative but `a` is not invertible modulo `n`, an + # exception is raised. + + unsigned long n_powmod2_ui_preinv(unsigned long a, unsigned long exp, unsigned long n, unsigned long ninv) + # Returns ``(a^exp) % n`` given a precomputed inverse of `n` computed + # by :func:`n_preinvert_limb`. We require `0 \leq a < n`, but there are no + # restrictions on `n`. The exponent ``exp`` is unsigned and so can be + # larger than allowed by :func:`n_powmod2_preinv`. + # This is implemented as a standard binary powering algorithm using + # repeated squaring and reducing modulo `n` at each step. + + unsigned long n_powmod2_fmpz_preinv(unsigned long a, const fmpz_t exp, unsigned long n, unsigned long ninv) + # Returns ``(a^exp) % n`` given a precomputed inverse of `n` computed + # by :func:`n_preinvert_limb`. We require `0 \leq a < n`, but there are no + # restrictions on `n`. The exponent ``exp`` must not be negative. + # This is implemented as a standard binary powering algorithm using + # repeated squaring and reducing modulo `n` at each step. + + unsigned long n_sqrtmod(unsigned long a, unsigned long p) + # If `p` is prime, compute a square root of `a` modulo `p` if `a` is a + # quadratic residue modulo `p`, otherwise return `0`. + # If `p` is not prime the result is with high probability `0`, indicating + # that `p` is not prime, or `a` is not a square modulo `p`. Otherwise the + # result is meaningless. + # Assumes that `a` is reduced modulo `p`. + + long n_sqrtmod_2pow(unsigned long ** sqrt, unsigned long a, long exp) + # Computes all the square roots of ``a`` modulo ``2^exp``. The roots + # are stored in an array which is created and whose address is stored in + # the location pointed to by ``sqrt``. The array of roots is allocated + # by the function but must be cleaned up by the user by calling + # ``flint_free``. The number of roots is returned by the function. If + # ``a`` is not a quadratic residue modulo ``2^exp`` then 0 is + # returned by the function and the location ``sqrt`` points to is set to + # NULL. + + long n_sqrtmod_primepow(unsigned long ** sqrt, unsigned long a, unsigned long p, long exp) + # Computes all the square roots of ``a`` modulo ``p^exp``. The roots + # are stored in an array which is created and whose address is stored in + # the location pointed to by ``sqrt``. The array of roots is allocated + # by the function but must be cleaned up by the user by calling + # ``flint_free``. The number of roots is returned by the function. If + # ``a`` is not a quadratic residue modulo ``p^exp`` then 0 is + # returned by the function and the location ``sqrt`` points to is set to + # NULL. + + long n_sqrtmodn(unsigned long ** sqrt, unsigned long a, n_factor_t * fac) + # Computes all the square roots of ``a`` modulo ``m`` given the + # factorisation of ``m`` in ``fac``. The roots are stored in an array + # which is created and whose address is stored in the location pointed to by + # ``sqrt``. The array of roots is allocated by the function but must be + # cleaned up by the user by calling :func:`flint_free`. The number of roots + # is returned by the function. If ``a`` is not a quadratic residue modulo + # ``m`` then 0 is returned by the function and the location ``sqrt`` + # points to is set to NULL. + + mp_limb_t n_mulmod_shoup(mp_limb_t w, mp_limb_t t, mp_limb_t w_precomp, mp_limb_t p) + # Returns `w t \bmod{p}` given a precomputed scaled approximation of `w / p` + # computed by :func:`n_mulmod_precomp_shoup`. The value of `p` should be + # less than `2^{\mathtt{FLINT\_BITS} - 1}`. `w` and `t` should be less than `p`. + # Works faster than :func:`n_mulmod2_preinv` if `w` fixed and `t` from array + # (for example, scalar multiplication of vector). + + mp_limb_t n_mulmod_precomp_shoup(mp_limb_t w, mp_limb_t p) + # Returns `w'`, scaled approximation of `w / p`. `w'` is equal to the integer + # part of `w \cdot 2^{\mathtt{FLINT\_BITS}} / p`. + + int n_divides(mp_limb_t * q, mp_limb_t n, mp_limb_t p) + + void n_primes_init(n_primes_t it) + # Initialises the prime number iterator ``iter`` for use. + + void n_primes_clear(n_primes_t it) + # Clears memory allocated by the prime number iterator ``iter``. + + unsigned long n_primes_next(n_primes_t it) + # Returns the next prime number and advances the state of ``iter``. + # The first call returns 2. + # Small primes are looked up from ``flint_small_primes``. + # When this table is exhausted, primes are generated in blocks + # by calling :func:`n_primes_sieve_range`. + + void n_primes_jump_after(n_primes_t it, unsigned long n) + # Changes the state of ``iter`` to start generating primes + # after `n` (excluding `n` itself). + + void n_primes_extend_small(n_primes_t it, unsigned long bound) + # Extends the table of small primes in ``iter`` to contain + # at least two primes larger than or equal to ``bound``. + + void n_primes_sieve_range(n_primes_t it, unsigned long a, unsigned long b) + # Sets the block endpoints of ``iter`` to the smallest and + # largest odd numbers between `a` and `b` inclusive, and + # sieves to mark all odd primes in this range. + # The iterator state is changed to point to the first + # number in the sieved range. + + void n_compute_primes(unsigned long num_primes) + # Precomputes at least ``num_primes`` primes and their ``double`` + # precomputed inverses and stores them in an internal cache. + # Assuming that FLINT has been built with support for thread-local storage, + # each thread has its own cache. + + const unsigned long * n_primes_arr_readonly(unsigned long num_primes) + # Returns a pointer to a read-only array of the first ``num_primes`` + # prime numbers. The computed primes are cached for repeated calls. + # The pointer is valid until the user calls :func:`n_cleanup_primes` + # in the same thread. + + const double * n_prime_inverses_arr_readonly(unsigned long n) + # Returns a pointer to a read-only array of inverses of the first + # ``num_primes`` prime numbers. The computed primes are cached for + # repeated calls. The pointer is valid until the user calls + # :func:`n_cleanup_primes` in the same thread. + + void n_cleanup_primes() + # Frees the internal cache of prime numbers used by the current thread. + # This will invalidate any pointers returned by + # :func:`n_primes_arr_readonly` or :func:`n_prime_inverses_arr_readonly`. + + unsigned long n_nextprime(unsigned long n, int proved) + # Returns the next prime after `n`. Assumes the result will fit in an + # ``ulong``. If proved is `0`, i.e. false, the prime is not + # proven prime, otherwise it is. + + unsigned long n_prime_pi(unsigned long n) + # Returns the value of the prime counting function `\pi(n)`, i.e. the + # number of primes less than or equal to `n`. The invariant + # ``n_prime_pi(n_nth_prime(n)) == n``. + # Currently, this function simply extends the table of cached primes up to + # an upper limit and then performs a binary search. + + void n_prime_pi_bounds(unsigned long *lo, unsigned long *hi, unsigned long n) + # Calculates lower and upper bounds for the value of the prime counting + # function ``lo <= pi(n) <= hi``. If ``lo`` and ``hi`` point to + # the same location, the high value will be stored. + # This does a table lookup for small values, then switches over to some + # proven bounds. + # The upper approximation is `1.25506 n / \ln n`, and the + # lower is `n / \ln n`. These bounds are due to Rosser and + # Schoenfeld [RosSch1962]_ and valid for `n \geq 17`. + # We use the number of bits in `n` (or one less) to form an + # approximation to `\ln n`, taking care to use a value too + # small or too large to maintain the inequality. + + unsigned long n_nth_prime(unsigned long n) + # Returns the `n`\th prime number `p_n`, using the mathematical indexing + # convention `p_1 = 2, p_2 = 3, \dotsc`. + # This function simply ensures that the table of cached primes is large + # enough and then looks up the entry. + + void n_nth_prime_bounds(unsigned long *lo, unsigned long *hi, unsigned long n) + # Calculates lower and upper bounds for the `n`\th prime number `p_n` , + # ``lo <= p_n <= hi``. If ``lo`` and ``hi`` point to the same + # location, the high value will be stored. Note that this function will + # overflow for sufficiently large `n`. + # We use the following estimates, valid for `n > 5` : + # .. math :: + # p_n & > n (\ln n + \ln \ln n - 1) \\ + # p_n & < n (\ln n + \ln \ln n) \\ + # p_n & < n (\ln n + \ln \ln n - 0.9427) \quad (n \geq 15985) + # The first inequality was proved by Dusart [Dus1999]_, and the last + # is due to Massias and Robin [MasRob1996]_. For a further overview, + # see http://primes.utm.edu/howmany.shtml . + # We bound `\ln n` using the number of bits in `n` as in + # ``n_prime_pi_bounds()``, and estimate `\ln \ln n` to the nearest + # integer; this function is nearly constant. + + int n_is_oddprime_small(unsigned long n) + # Returns `1` if `n` is an odd prime smaller than + # ``FLINT_ODDPRIME_SMALL_CUTOFF``. Expects `n` + # to be odd and smaller than the cutoff. + # This function merely uses a lookup table with one bit allocated for each + # odd number up to the cutoff. + + int n_is_oddprime_binary(unsigned long n) + # This function performs a simple binary search through + # the table of cached primes for `n`. If it exists in the array it returns + # `1`, otherwise `0`. For the algorithm to operate correctly + # `n` should be odd and at least `17`. + # Lower and upper bounds are computed with :func:`n_prime_pi_bounds`. + # Once we have bounds on where to look in the table, we + # refine our search with a simple binary algorithm, taking + # the top or bottom of the current interval as necessary. + + int n_is_prime_pocklington(unsigned long n, unsigned long iterations) + # Tests if `n` is a prime using the Pocklington--Lehmer primality + # test. If `1` is returned `n` has been proved prime. If `0` is returned + # `n` is composite. However `-1` may be returned if nothing was proved + # either way due to the number of iterations being too small. + # The most time consuming part of the algorithm is factoring + # `n - 1`. For this reason :func:`n_factor_partial` is used, + # which uses a combination of trial factoring and Hart's one + # line factor algorithm [Har2012]_ to try to quickly factor `n - 1`. + # Additionally if the cofactor is less than the square root of + # `n - 1` the algorithm can still proceed. + # One can also specify a number of iterations if less time + # should be taken. Simply set this to ``WORD(0)`` if this is irrelevant. + # In most cases a greater number of iterations will not + # significantly affect timings as most of the time is spent + # factoring. + # See + # https://mathworld.wolfram.com/PocklingtonsTheorem.html + # for a description of the algorithm. + + int n_is_prime_pseudosquare(unsigned long n) + # Tests if `n` is a prime according to Theorem 2.7 [LukPatWil1996]_. + # We first factor `N` using trial division up to some limit `B`. + # In fact, the number of primes used in the trial factoring is at + # most ``FLINT_PSEUDOSQUARES_CUTOFF``. + # Next we compute `N/B` and find the next pseudosquare `L_p` above + # this value, using a static table as per + # https://oeis.org/A002189/b002189.txt . + # As noted in the text, if `p` is prime then Step 3 will pass. This + # test rejects many composites, and so by this time we suspect + # that `p` is prime. If `N` is `3` or `7` modulo `8`, we are done, + # and `N` is prime. + # We now run a probable prime test, for which no known + # counterexamples are known, to reject any composites. We then + # proceed to prove `N` prime by executing Step 4. In the case that + # `N` is `1` modulo `8`, if Step 4 fails, we extend the number of primes + # `p_i` at Step 3 and hope to find one which passes Step 4. We take + # the test one past the largest `p` for which we have pseudosquares + # `L_p` tabulated, as this already corresponds to the next `L_p` which + # is bigger than `2^{64}` and hence larger than any prime we might be + # testing. + # As explained in the text, Condition 4 cannot fail if `N` is prime. + # The possibility exists that the probable prime test declares a + # composite prime. However in that case an error is printed, as + # that would be of independent interest. + + int n_is_prime(unsigned long n) + # Tests if `n` is a prime. This first sieves for small prime factors, + # then simply calls :func:`n_is_probabprime`. This has been checked + # against the tables of Feitsma and Galway + # http://www.cecm.sfu.ca/Pseudoprimes/index-2-to-64.html and thus + # constitutes a check for primality (rather than just pseudoprimality) + # up to `2^{64}`. + # In future, this test may produce and check a certificate of + # primality. This is likely to be significantly slower for prime + # inputs. + + int n_is_strong_probabprime_precomp(unsigned long n, double npre, unsigned long a, unsigned long d) + # Tests if `n` is a strong probable prime to the base `a`. We + # require that `d` is set to the largest odd factor of `n - 1` and + # ``npre`` is a precomputed inverse of `n` computed with + # :func:`n_precompute_inverse`. We also require that `n < 2^{53}`, + # `a` to be reduced modulo `n` and not `0` and `n` to be odd. + # If we write `n - 1 = 2^s d` where `d` is odd then `n` is a strong + # probable prime to the base `a`, i.e. an `a`-SPRP, if either + # `a^d = 1 \pmod n` or `(a^d)^{2^r} = -1 \pmod n` for some `r` less + # than `s`. + # A description of strong probable primes is given here: + # https://mathworld.wolfram.com/StrongPseudoprime.html + + int n_is_strong_probabprime2_preinv(unsigned long n, unsigned long ninv, unsigned long a, unsigned long d) + # Tests if `n` is a strong probable prime to the base `a`. We require + # that `d` is set to the largest odd factor of `n - 1` and ``npre`` + # is a precomputed inverse of `n` computed with :func:`n_preinvert_limb`. + # We require a to be reduced modulo `n` and not `0` and `n` to be odd. + # If we write `n - 1 = 2^s d` where `d` is odd then `n` is a strong + # probable prime to the base `a` (an `a`-SPRP) if either `a^d = 1 \pmod n` + # or `(a^d)^{2^r} = -1 \pmod n` for some `r` less than `s`. + # A description of strong probable primes is given here: + # https://mathworld.wolfram.com/StrongPseudoprime.html + + int n_is_probabprime_fermat(unsigned long n, unsigned long i) + # Returns `1` if `n` is a base `i` Fermat probable prime. Requires + # `1 < i < n` and that `i` does not divide `n`. + # By Fermat's Little Theorem if `i^{n-1}` is not congruent to `1` + # then `n` is not prime. + + int n_is_probabprime_fibonacci(unsigned long n) + # Let `F_j` be the `j`\th element of the Fibonacci sequence + # `0, 1, 1, 2, 3, 5, \dotsc`, starting at `j = 0`. Then if `n` is prime + # we have `F_{n - (n/5)} = 0 \pmod n`, where `(n/5)` is the Jacobi + # symbol. + # For further details, see pp. 142 [CraPom2005]_. + # We require that `n` is not divisible by `2` or `5`. + + int n_is_probabprime_BPSW(unsigned long n) + # Implements a Baillie--Pomerance--Selfridge--Wagstaff probable primality + # test. This is a variant of the usual BPSW test (which only uses strong + # base-2 probable prime and Lucas-Selfridge tests, see Baillie and + # Wagstaff [BaiWag1980]_). + # This implementation makes use of a weakening of the usual Baillie-PSW + # test given in [Chen2003]_, namely replacing the Lucas test with a + # Fibonacci test when `n \equiv 2, 3 \pmod{5}` (see also the comment on + # page 143 of [CraPom2005]_), regarding Fibonacci pseudoprimes. + # There are no known counterexamples to this being a primality test. + # Up to `2^{64}` the test we use has been checked against tables of + # pseudoprimes. Thus it is a primality test up to this limit. + + int n_is_probabprime_lucas(unsigned long n) + # For details on Lucas pseudoprimes, see [pp. 143] [CraPom2005]_. + # We implement a variant of the Lucas pseudoprime test similar to that + # described by Baillie and Wagstaff [BaiWag1980]_. + + int n_is_probabprime(unsigned long n) + # Tests if `n` is a probable prime. Up to ``FLINT_ODDPRIME_SMALL_CUTOFF`` + # this algorithm uses :func:`n_is_oddprime_small` which uses a lookup table. + # Next it calls :func:`n_compute_primes` with the maximum table size and + # uses this table to perform a binary search for `n` up to the table limit. + # Then up to `1050535501` it uses a number of strong probable prime tests, + # :func:`n_is_strong_probabprime_preinv`, etc., for various bases. The + # output of the algorithm is guaranteed to be correct up to this bound due + # to exhaustive tables, described at + # http://uucode.com/obf/dalbec/alg.html . + # Beyond that point the BPSW probabilistic primality test is used, by + # calling the function :func:`n_is_probabprime_BPSW`. There are no known + # counterexamples, and it has been checked against the tables of Feitsma + # and Galway and up to the accuracy of those tables, this is an exhaustive + # check up to `2^{64}`, i.e. there are no counterexamples. + + unsigned long n_CRT(unsigned long r1, unsigned long m1, unsigned long r2, unsigned long m2) + # Use the Chinese Remainder Theorem to return the unique value + # `0 \le x < M` congruent to `r_1` modulo `m_1` and `r_2` modulo `m_2`, + # where `M = m_1 \times m_2` is assumed to fit a ulong. + # It is assumed that `m_1` and `m_2` are positive integers greater + # than `1` and coprime. It is assumed that `0 \le r_1 < m_1` and `0 \le r_2 < m_2`. + + unsigned long n_sqrt(unsigned long a) + # Computes the integer truncation of the square root of `a`. + # The implementation uses a call to the IEEE floating point sqrt function. + # The integer itself is represented by the nearest double and its square + # root is computed to the nearest place. If `a` is one below a square, the + # rounding may be up, whereas if it is one above a square, the rounding + # will be down. Thus the square root may be one too large in some + # instances which we then adjust by checking if we have the right value. + # We also have to be careful when the square of this too large + # value causes an overflow. The same assumptions hold for a single + # precision float provided the square root itself can be represented + # in a single float, i.e. for `a < 281474976710656 = 2^{46}`. + + unsigned long n_sqrtrem(unsigned long * r, unsigned long a) + # Computes the integer truncation of the square root of `a`. + # The integer itself is represented by the nearest double and its square + # root is computed to the nearest place. If `a` is one below a square, the + # rounding may be up, whereas if it is one above a square, the rounding + # will be down. Thus the square root may be one too large in some + # instances which we then adjust by checking if we have the right value. + # We also have to be careful when the square of this too + # large value causes an overflow. The same assumptions hold for a + # single precision float provided the square root itself can be + # represented in a single float, i.e. for \ + # `a < 281474976710656 = 2^{46}`. + # The remainder is computed by subtracting the square of the computed square + # root from `a`. + + int n_is_square(unsigned long x) + # Returns `1` if `x` is a square, otherwise `0`. + # This code first checks if `x` is a square modulo `64`, + # `63 = 3 \times 3 \times 7` and `65 = 5 \times 13`, using lookup tables, + # and if so it then takes a square root and checks that the square of this + # equals the original value. + + int n_is_perfect_power235(unsigned long n) + # Returns `1` if `n` is a perfect square, cube or fifth power. + # This function uses a series of modular tests to reject most + # non 235-powers. Each modular test returns a value from 0 to 7 + # whose bits respectively indicate whether the value is a square, + # cube or fifth power modulo the given modulus. When these are + # logically ``AND``-ed together, this gives a powerful test which will + # reject most non-235 powers. + # If a bit remains set indicating it may be a square, a standard + # square root test is performed. Similarly a cube root or fifth + # root can be taken, if indicated, to determine whether the power + # of that root is exactly equal to `n`. + + int n_is_perfect_power(unsigned long * root, unsigned long n) + # If `n = r^k`, return `k` and set ``root`` to `r`. Note that `0` and + # `1` are considered squares. No guarantees are made about `r` or `k` + # being the minimum possible value. + + unsigned long n_rootrem(unsigned long* remainder, unsigned long n, unsigned long root) + # This function uses the Newton iteration method to calculate the nth root of + # a number. + # First approximation is calculated by an algorithm mentioned in this + # article: https://en.wikipedia.org/wiki/Fast_inverse_square_root . + # Instead of the inverse square root, the nth root is calculated. + # Returns the integer part of ``n ^ 1/root``. Remainder is set as + # ``n - base^root``. In case `n < 1` or ``root < 1``, `0` is returned. + + unsigned long n_cbrt(unsigned long n) + # This function returns the integer truncation of the cube root of `n`. + # First approximation is calculated by an algorithm mentioned in this + # article: https://en.wikipedia.org/wiki/Fast_inverse_square_root . + # Instead of the inverse square root, the cube root is calculated. + # This functions uses different algorithms to calculate the cube root, + # depending upon the size of `n`. For numbers greater than `2^{46}`, it uses + # :func:`n_cbrt_chebyshev_approx`. Otherwise, it makes use of the iteration, + # `x \leftarrow x - (x\cdot x\cdot x - a)\cdot x/(2\cdot x\cdot x\cdot x + a)` for getting a good estimate, + # as mentioned in the paper by W. Kahan [Kahan1991]_ . + + unsigned long n_cbrt_newton_iteration(unsigned long n) + # This function returns the integer truncation of the cube root of `n`. + # Makes use of Newton iterations to get a close value, and then adjusts the + # estimate so as to get the correct value. + + unsigned long n_cbrt_binary_search(unsigned long n) + # This function returns the integer truncation of the cube root of `n`. + # Uses binary search to get the correct value. + + unsigned long n_cbrt_chebyshev_approx(unsigned long n) + # This function returns the integer truncation of the cube root of `n`. + # The number is first expressed in the form ``x * 2^exp``. This ensures + # `x` is in the range [0.5, 1]. Cube root of x is calculated using + # Chebyshev's approximation polynomial for the function `y = x^{1/3}`. The + # values of the coefficient are calculated from the Python module mpmath, + # https://mpmath.org, using the function chebyfit. x is multiplied + # by ``2^exp`` and the cube root of 1, 2 or 4 (according to ``exp%3``). + + unsigned long n_cbrtrem(unsigned long* remainder, unsigned long n) + # This function returns the integer truncation of the cube root of `n`. + # Remainder is set as `n` minus the cube of the value returned. + + void n_factor_init(n_factor_t * factors) + # Initializes factors. + + int n_remove(unsigned long * n, unsigned long p) + # Removes the highest possible power of `p` from `n`, replacing + # `n` with the quotient. The return value is the highest + # power of `p` that divided `n`. Assumes `n` is not `0`. + # For `p = 2` trailing zeroes are counted. For other primes + # `p` is repeatedly squared and stored in a table of powers + # with the current highest power of `p` removed at each step + # until no higher power can be removed. The algorithm then + # proceeds down the power tree again removing powers of `p` + # until none remain. + + int n_remove2_precomp(unsigned long * n, unsigned long p, double ppre) + # Removes the highest possible power of `p` from `n`, replacing + # `n` with the quotient. The return value is the highest + # power of `p` that divided `n`. Assumes `n` is not `0`. We require + # ``ppre`` to be set to a precomputed inverse of `p` computed + # with :func:`n_precompute_inverse`. + # For `p = 2` trailing zeroes are counted. For other primes + # `p` we make repeated use of :func:`n_divrem2_precomp` until division + # by `p` is no longer possible. + + void n_factor_insert(n_factor_t * factors, unsigned long p, unsigned long exp) + # Inserts the given prime power factor ``p^exp`` into + # the ``n_factor_t`` ``factors``. See the documentation for + # :func:`n_factor_trial` for a description of the ``n_factor_t`` type. + # The algorithm performs a simple search to see if `p` already + # exists as a prime factor in the structure. If so the exponent + # there is increased by the supplied exponent. Otherwise a new + # factor ``p^exp`` is added to the end of the structure. + # There is no test code for this function other than its use by + # the various factoring functions, which have test code. + + unsigned long n_factor_trial_range(n_factor_t * factors, unsigned long n, unsigned long start, unsigned long num_primes) + # Trial factor `n` with the first ``num_primes`` primes, but + # starting at the prime with index start (counting from zero). + # One requires an initialised ``n_factor_t`` structure, but factors + # will be added by default to an already used ``n_factor_t``. Use + # the function :func:`n_factor_init` defined in ``ulong_extras`` if + # initialisation has not already been completed on factors. + # Once completed, ``num`` will contain the number of distinct + # prime factors found. The field `p` is an array of ``ulong``\s + # containing the distinct prime factors, ``exp`` an array + # containing the corresponding exponents. + # The return value is the unfactored cofactor after trial + # factoring is done. + # The function calls :func:`n_compute_primes` automatically. See + # the documentation for that function regarding limits. + # The algorithm stops when the current prime has a square + # exceeding `n`, as no prime factor of `n` can exceed this + # unless `n` is prime. + # The precomputed inverses of all the primes computed by + # :func:`n_compute_primes` are utilised with the :func:`n_remove2_precomp` + # function. + + unsigned long n_factor_trial(n_factor_t * factors, unsigned long n, unsigned long num_primes) + # This function calls :func:`n_factor_trial_range`, with the value of + # `0` for ``start``. By default this adds factors to an already existing + # ``n_factor_t`` or to a newly initialised one. + + unsigned long n_factor_power235(unsigned long *exp, unsigned long n) + # Returns `0` if `n` is not a perfect square, cube or fifth power. + # Otherwise it returns the root and sets ``exp`` to either `2`, + # `3` or `5` appropriately. + # This function uses a series of modular tests to reject most + # non 235-powers. Each modular test returns a value from 0 to 7 + # whose bits respectively indicate whether the value is a square, + # cube or fifth power modulo the given modulus. When these are + # logically ``AND``-ed together, this gives a powerful test which will + # reject most non-235 powers. + # If a bit remains set indicating it may be a square, a standard + # square root test is performed. Similarly a cube root or fifth + # root can be taken, if indicated, to determine whether the power + # of that root is exactly equal to `n`. + + unsigned long n_factor_one_line(unsigned long n, unsigned long iters) + # This implements Bill Hart's one line factoring algorithm [Har2012]_. + # It is a variant of Fermat's algorithm which cycles through a large number + # of multipliers instead of incrementing the square root. It is faster than + # SQUFOF for `n` less than about `2^{40}`. + + unsigned long n_factor_lehman(unsigned long n) + # Lehman's factoring algorithm. Currently works up to `10^{16}`, but is + # not particularly efficient and so is not used in the general factor + # function. Always returns a factor of `n`. + + unsigned long n_factor_SQUFOF(unsigned long n, unsigned long iters) + # Attempts to split `n` using the given number of iterations + # of SQUFOF. Simply set ``iters`` to ``WORD(0)`` for maximum + # persistence. + # The version of SQUFOF implemented here is as described by Gower + # and Wagstaff [GowWag2008]_. + # We start by trying SQUFOF directly on `n`. If that fails we + # multiply it by each of the primes in ``flint_primes_small`` in + # turn. As this multiplication may result in a two limb value + # we allow this in our implementation of SQUFOF. As SQUFOF + # works with values about half the size of `n` it only needs + # single limb arithmetic internally. + # If SQUFOF fails to factor `n` we return `0`, however with + # ``iters`` large enough this should never happen. + + void n_factor(n_factor_t * factors, unsigned long n, int proved) + # Factors `n` with no restrictions on `n`. If the prime factors are + # required to be checked with a primality test, one may set + # ``proved`` to `1`, otherwise set it to `0`, and they will only be + # probable primes. NB: at the present there is no difference because + # the probable prime tests have been exhaustively tested up to `2^{64}`. + # However, in future, this flag may produce and separately check + # a primality certificate. This may be quite slow (and probably no + # less reliable in practice). + # For details on the ``n_factor_t`` structure, see + # :func:`n_factor_trial`. + # This function first tries trial factoring with a number of primes + # specified by the constant ``FLINT_FACTOR_TRIAL_PRIMES``. If the + # cofactor is `1` or prime the function returns with all the factors. + # Otherwise, the cofactor is placed in the array ``factor_arr``. Whilst + # there are factors remaining in there which have not been split, the + # algorithm continues. At each step each factor is first checked to + # determine if it is a perfect power. If so it is replaced by the power + # that has been found. Next if the factor is small enough and composite, + # in particular, less than ``FLINT_FACTOR_ONE_LINE_MAX`` then + # :func:`n_factor_one_line` is called with + # ``FLINT_FACTOR_ONE_LINE_ITERS`` to try and split the factor. If + # that fails or the factor is too large for :func:`n_factor_one_line` + # then :func:`n_factor_SQUFOF` is called, with + # ``FLINT_FACTOR_SQUFOF_ITERS``. If that fails an error results and + # the program aborts. However this should not happen in practice. + + unsigned long n_factor_trial_partial(n_factor_t * factors, unsigned long n, unsigned long * prod, unsigned long num_primes, unsigned long limit) + # Attempts trial factoring of `n` with the first ``num_primes primes``, + # but stops when the product of prime factors so far exceeds ``limit``. + # One requires an initialised ``n_factor_t`` structure, but factors + # will be added by default to an already used ``n_factor_t``. Use + # the function :func:`n_factor_init` defined in ``ulong_extras`` if + # initialisation has not already been completed on ``factors``. + # Once completed, ``num`` will contain the number of distinct + # prime factors found. The field `p` is an array of ``ulong``\s + # containing the distinct prime factors, ``exp`` an array + # containing the corresponding exponents. + # The return value is the unfactored cofactor after trial + # factoring is done. The value ``prod`` will be set to the product + # of the factors found. + # The function calls :func:`n_compute_primes` automatically. See + # the documentation for that function regarding limits. + # The algorithm stops when the current prime has a square + # exceeding `n`, as no prime factor of `n` can exceed this + # unless `n` is prime. + # The precomputed inverses of all the primes computed by + # :func:`n_compute_primes` are utilised with the :func:`n_remove2_precomp` + # function. + + unsigned long n_factor_partial(n_factor_t * factors, unsigned long n, unsigned long limit, int proved) + # Factors `n`, but stops when the product of prime factors so far + # exceeds ``limit``. + # One requires an initialised ``n_factor_t`` structure, but factors + # will be added by default to an already used ``n_factor_t``. Use + # the function ``n_factor_init()`` defined in ``ulong_extras`` if + # initialisation has not already been completed on ``factors``. + # On exit, ``num`` will contain the number of distinct prime factors + # found. The field `p` is an array of ``ulong``\s containing the + # distinct prime factors, ``exp`` an array containing the corresponding + # exponents. + # The return value is the unfactored cofactor after factoring is done. + # The factors are proved prime if ``proved`` is `1`, otherwise + # they are merely probably prime. + + unsigned long n_factor_pp1(unsigned long n, unsigned long B1, unsigned long c) + # Factors `n` using Williams' `p + 1` factoring algorithm, with prime + # limit set to `B1`. We require `c` to be set to a random value. Each + # trial of the algorithm with a different value of `c` gives another + # chance to factor `n`, with roughly exponentially decreasing chance + # of finding a missing factor. If `p + 1` (or `p - 1`) is not smooth + # for any factor `p` of `n`, the algorithm will never succeed. The + # value `c` should be less than `n` and greater than `2`. + # If the algorithm succeeds, it returns the factor, otherwise it + # returns `0` or `1` (the trivial factors modulo `n`). + + unsigned long n_factor_pp1_wrapper(unsigned long n) + # A simple wrapper around ``n_factor_pp1`` which works in the range + # `31`-`64` bits. Below this point, trial factoring will always succeed. + # This function mainly exists for ``n_factor`` and is tuned to minimise + # the time for ``n_factor`` on numbers that reach the ``n_factor_pp1`` + # stage, i.e. after trial factoring and one line factoring. + + int n_factor_pollard_brent_single(mp_limb_t *factor, mp_limb_t n, mp_limb_t ninv, mp_limb_t ai, mp_limb_t xi, mp_limb_t normbits, mp_limb_t max_iters) + # Pollard Rho algorithm (with Brent modification) for integer factorization. + # Assumes that the `n` is not prime. `factor` is set as the factor if found. + # It is not assured that the factor found will be prime. Does not compute the complete + # factorization, just one factor. Returns 1 if factorization is successful + # (non trivial factor is found), else returns 0. Assumes `n` is normalized + # (shifted by normbits bits), and takes as input a precomputed inverse of `n` as + # computed by :func:`n_preinvert_limb`. `ai` and `xi` should also be shifted + # left by `normbits`. + # `ai` is the constant of the polynomial used, `xi` is the initial value. + # `max\_iters` is the number of iterations tried in process of finding the + # cycle. + # The algorithm used is a modification of the original Pollard Rho algorithm, + # suggested by Richard Brent in the paper, available at + # https://maths-people.anu.edu.au/~brent/pd/rpb051i.pdf + + int n_factor_pollard_brent(mp_limb_t *factor, flint_rand_t state, mp_limb_t n_in, mp_limb_t max_tries, mp_limb_t max_iters) + # Pollard Rho algorithm, modified as suggested by Richard Brent. Makes a call to + # :func:`n_factor_pollard_brent_single`. The input parameters ai and xi for + # :func:`n_factor_pollard_brent_single` are selected at random. + # If the algorithm fails to find a non trivial factor in one call, it tries again + # (this time with a different set of random values). This process is repeated a + # maximum of `max\_tries` times. + # Assumes `n` is not prime. `factor` is set as the factor found, if factorization + # is successful. In such a case, 1 is returned. Otherwise, 0 is returned. Factor + # discovered is not necessarily prime. + + int n_moebius_mu(unsigned long n) + # Computes the Moebius function `\mu(n)`, which is defined as `\mu(n) = 0` + # if `n` has a prime factor of multiplicity greater than `1`, `\mu(n) = -1` + # if `n` has an odd number of distinct prime factors, and `\mu(n) = 1` if + # `n` has an even number of distinct prime factors. By convention, + # `\mu(0) = 0`. + # For even numbers, we use the identities `\mu(4n) = 0` and + # `\mu(2n) = - \mu(n)`. Odd numbers up to a cutoff are then looked up from + # a precomputed table storing `\mu(n) + 1` in groups of two bits. + # For larger `n`, we first check if `n` is divisible by a small odd square + # and otherwise call ``n_factor()`` and count the factors. + + void n_moebius_mu_vec(int * mu, unsigned long len) + # Computes `\mu(n)` for ``n = 0, 1, ..., len - 1``. This + # is done by sieving over each prime in the range, flipping the sign + # of `\mu(n)` for every multiple of a prime `p` and setting `\mu(n) = 0` + # for every multiple of `p^2`. + + int n_is_squarefree(unsigned long n) + # Returns `0` if `n` is divisible by some perfect square, and `1` otherwise. + # This simply amounts to testing whether `\mu(n) \neq 0`. As special + # cases, `1` is considered squarefree and `0` is not considered squarefree. + + unsigned long n_euler_phi(unsigned long n) + # Computes the Euler totient function `\phi(n)`, counting the number of + # positive integers less than or equal to `n` that are coprime to `n`. + + unsigned long n_factorial_fast_mod2_preinv(unsigned long n, unsigned long p, unsigned long pinv) + # Returns `n! \bmod p` given a precomputed inverse of `p` as computed + # by :func:`n_preinvert_limb`. `p` is not required to be a prime, but + # no special optimisations are made for composite `p`. + # Uses fast multipoint evaluation, running in about `O(n^{1/2})` time. + + unsigned long n_factorial_mod2_preinv(unsigned long n, unsigned long p, unsigned long pinv) + # Returns `n! \bmod p` given a precomputed inverse of `p` as computed + # by :func:`n_preinvert_limb`. `p` is not required to be a prime, but + # no special optimisations are made for composite `p`. + # Uses a lookup table for small `n`, otherwise computes the product + # if `n` is not too large, and calls the fast algorithm for extremely + # large `n`. + + unsigned long n_primitive_root_prime_prefactor(unsigned long p, n_factor_t * factors) + # Returns a primitive root for the multiplicative subgroup of `\mathbb{Z}/p\mathbb{Z}` + # where `p` is prime given the factorisation (``factors``) of `p - 1`. + + unsigned long n_primitive_root_prime(unsigned long p) + # Returns a primitive root for the multiplicative subgroup of `\mathbb{Z}/p\mathbb{Z}` + # where `p` is prime. + + unsigned long n_discrete_log_bsgs(unsigned long b, unsigned long a, unsigned long n) + # Returns the discrete logarithm of `b` with respect to `a` in the + # multiplicative subgroup of `\mathbb{Z}/n\mathbb{Z}` when `\mathbb{Z}/n\mathbb{Z}` + # is cyclic. That is, + # it returns a number `x` such that `a^x = b \bmod n`. The + # multiplicative subgroup is only cyclic when `n` is `2`, `4`, + # `p^k`, or `2p^k` where `p` is an odd prime and `k` is a positive + # integer. + + void n_factor_ecm_double(mp_limb_t *x, mp_limb_t *z, mp_limb_t x0, mp_limb_t z0, mp_limb_t n, n_ecm_t n_ecm_inf) + # Sets the point `(x : z)` to two times `(x_0 : z_0)` modulo `n` according + # to the formula + # `x = (x_0 + z_0)^2 \cdot (x_0 - z_0)^2 \mod n,` + # `z = 4 x_0 z_0 \left((x_0 - z_0)^2 + 4a_{24}x_0z_0\right) \mod n.` + # This group doubling is valid only for points expressed in + # Montgomery projective coordinates. + + void n_factor_ecm_add(mp_limb_t *x, mp_limb_t *z, mp_limb_t x1, mp_limb_t z1, mp_limb_t x2, mp_limb_t z2, mp_limb_t x0, mp_limb_t z0, mp_limb_t n, n_ecm_t n_ecm_inf) + # Sets the point `(x : z)` to the sum of `(x_1 : z_1)` and `(x_2 : z_2)` + # modulo `n`, given the difference `(x_0 : z_0)` according to the formula + # This group doubling is valid only for points expressed in + # Montgomery projective coordinates. + + void n_factor_ecm_mul_montgomery_ladder(mp_limb_t *x, mp_limb_t *z, mp_limb_t x0, mp_limb_t z0, mp_limb_t k, mp_limb_t n, n_ecm_t n_ecm_inf) + # Montgomery ladder algorithm for scalar multiplication of elliptic points. + # Sets the point `(x : z)` to `k(x_0 : z_0)` modulo `n`. + # Valid only for points expressed in Montgomery projective coordinates. + + int n_factor_ecm_select_curve(mp_limb_t *f, mp_limb_t sigma, mp_limb_t n, n_ecm_t n_ecm_inf) + # Selects a random elliptic curve given a random integer ``sigma``, + # according to Suyama's parameterization. If the factor is found while + # selecting the curve, `1` is returned. In case the curve found is not + # suitable, `0` is returned. + # Also selects the initial point `x_0`, and the value of `(a + 2)/4`, where `a` + # is a curve parameter. Sets `z_0` as `1` (shifted left by + # ``n_ecm_inf->normbits``). All these are stored in the + # ``n_ecm_t`` struct. + # The curve selected is of Montgomery form, the points selected satisfy the + # curve and are projective coordinates. + + int n_factor_ecm_stage_I(mp_limb_t *f, const mp_limb_t *prime_array, mp_limb_t num, mp_limb_t B1, mp_limb_t n, n_ecm_t n_ecm_inf) + # Stage I implementation of the ECM algorithm. + # ``f`` is set as the factor if found. ``num`` is number of prime numbers + # `<=` the bound ``B1``. ``prime_array`` is an array of first ``B1`` + # primes. `n` is the number being factored. + # If the factor is found, `1` is returned, otherwise `0`. - cdef unsigned long n_gcd(long x, long y) + int n_factor_ecm_stage_II(mp_limb_t *f, mp_limb_t B1, mp_limb_t B2, mp_limb_t P, mp_limb_t n, n_ecm_t n_ecm_inf) + # Stage II implementation of the ECM algorithm. + # ``f`` is set as the factor if found. ``B1``, ``B2`` are the two + # bounds. ``P`` is the primorial (approximately equal to `\sqrt{B2}`). + # `n` is the number being factored. + # If the factor is found, `1` is returned, otherwise `0`. - cdef void n_factor(n_factor_t * factors, unsigned long n, int proved) - cdef void n_factor_init(n_factor_t * factors) + int n_factor_ecm(mp_limb_t *f, mp_limb_t curves, mp_limb_t B1, mp_limb_t B2, flint_rand_t state, mp_limb_t n) + # Outer wrapper function for the ECM algorithm. It factors `n` which + # must fit into a ``mp_limb_t``. + # The function calls stage I and II, and + # the precomputations (builds ``prime_array`` for stage I, + # ``GCD_table`` and ``prime_table`` for stage II). + # ``f`` is set as the factor if found. ``curves`` is the number of + # random curves being tried. ``B1``, ``B2`` are the two bounds or + # stage I and stage II. `n` is the number being factored. + # If a factor is found in stage I, `1` is returned. + # If a factor is found in stage II, `2` is returned. + # If a factor is found while selecting the curve, `-1` is returned. + # Otherwise `0` is returned. diff --git a/src/sage/libs/flint/ulong_extras.pyx b/src/sage/libs/flint/ulong_extras_sage.pyx similarity index 85% rename from src/sage/libs/flint/ulong_extras.pyx rename to src/sage/libs/flint/ulong_extras_sage.pyx index 10255a96f1c..db634ba9dc9 100644 --- a/src/sage/libs/flint/ulong_extras.pyx +++ b/src/sage/libs/flint/ulong_extras_sage.pyx @@ -1,3 +1,7 @@ +from .types cimport n_factor_t +from .ulong_extras cimport n_factor_init, n_factor + + def n_factor_to_list(unsigned long n, int proved): """ A wrapper around ``n_factor``. From effa900211c0d15590ca6e2ddc698cc0c6e8b9b3 Mon Sep 17 00:00:00 2001 From: Vincent Delecroix Date: Sat, 14 Oct 2023 00:28:38 +0200 Subject: [PATCH 08/41] fix arb headers --- src/sage/libs/arb/acb.pxd | 2 ++ src/sage/libs/arb/acb_calc.pxd | 2 ++ src/sage/libs/arb/acb_mat.pxd | 2 ++ src/sage/libs/arb/acb_poly.pxd | 2 ++ src/sage/libs/arb/arb.pxd | 3 +++ src/sage/libs/arb/arb_version.pyx | 6 +++++- src/sage/libs/arb/arf.pxd | 2 ++ src/sage/libs/arb/mag.pxd | 3 +++ src/sage/libs/arb/types.pxd | 6 ++---- 9 files changed, 23 insertions(+), 5 deletions(-) diff --git a/src/sage/libs/arb/acb.pxd b/src/sage/libs/arb/acb.pxd index b723af56aea..9dac39b52a6 100644 --- a/src/sage/libs/arb/acb.pxd +++ b/src/sage/libs/arb/acb.pxd @@ -1,6 +1,8 @@ # Deprecated header file; use sage/libs/flint/acb.pxd instead # See https://github.com/sagemath/sage/pull/36449 +from sage.libs.flint.types cimport acb_struct, acb_t, acb_ptr, acb_srcptr + from sage.libs.flint.acb cimport ( acb_realref, acb_imagref, diff --git a/src/sage/libs/arb/acb_calc.pxd b/src/sage/libs/arb/acb_calc.pxd index 4e01ac77cc4..c06d7c5ad39 100644 --- a/src/sage/libs/arb/acb_calc.pxd +++ b/src/sage/libs/arb/acb_calc.pxd @@ -1,6 +1,8 @@ # Deprecated header file; use sage/libs/flint/acb_calc.pxd instead # See https://github.com/sagemath/sage/pull/36449 +from sage.libs.flint.types cimport acb_calc_integrate_opt_t, acb_calc_func_t + from sage.libs.flint.acb_calc cimport ( acb_calc_integrate, acb_calc_integrate_opt_init) diff --git a/src/sage/libs/arb/acb_mat.pxd b/src/sage/libs/arb/acb_mat.pxd index 40c9308f539..5c16b9481a4 100644 --- a/src/sage/libs/arb/acb_mat.pxd +++ b/src/sage/libs/arb/acb_mat.pxd @@ -1,6 +1,8 @@ # Deprecated header file; use sage/libs/flint/acb_mat.pxd instead # See https://github.com/sagemath/sage/pull/36449 +from sage.libs.flint.types cimport acb_mat_struct, acb_mat_t + from sage.libs.flint.acb_mat cimport ( acb_mat_nrows, acb_mat_ncols, diff --git a/src/sage/libs/arb/acb_poly.pxd b/src/sage/libs/arb/acb_poly.pxd index 00e430cc50a..50f20af0cf9 100644 --- a/src/sage/libs/arb/acb_poly.pxd +++ b/src/sage/libs/arb/acb_poly.pxd @@ -1,6 +1,8 @@ # Deprecated header file; use sage/libs/flint/acb_poly.pxd instead # See https://github.com/sagemath/sage/pull/36449 +from sage.libs.flint.types cimport acb_poly_struct, acb_poly_t + from sage.libs.flint.acb_poly cimport ( acb_poly_init, acb_poly_clear, diff --git a/src/sage/libs/arb/arb.pxd b/src/sage/libs/arb/arb.pxd index ca3a6ca34e7..704a5419c2f 100644 --- a/src/sage/libs/arb/arb.pxd +++ b/src/sage/libs/arb/arb.pxd @@ -1,6 +1,8 @@ # Deprecated header file; use sage/libs/flint/arb.pxd instead # See https://github.com/sagemath/sage/pull/36449 +from sage.libs.flint.types cimport arb_struct, arb_t, arb_ptr, arb_srcptr + from sage.libs.flint.arb cimport ( arb_midref, arb_radref, @@ -21,6 +23,7 @@ from sage.libs.flint.arb cimport ( arb_get_str, arb_zero, arb_one, + arb_dump_str, arb_pos_inf, arb_neg_inf, arb_zero_pm_inf, diff --git a/src/sage/libs/arb/arb_version.pyx b/src/sage/libs/arb/arb_version.pyx index 55736c392e9..b8ab4d725e5 100644 --- a/src/sage/libs/arb/arb_version.pyx +++ b/src/sage/libs/arb/arb_version.pyx @@ -1,7 +1,11 @@ # -*- coding: utf-8 -from sage.libs.arb.arb cimport arb_version from sage.cpython.string cimport char_to_str + +cdef extern from "arb_wrap.h": + char * arb_version + + def version(): """ Get arb version diff --git a/src/sage/libs/arb/arf.pxd b/src/sage/libs/arb/arf.pxd index af211c27e03..bfdca642bc9 100644 --- a/src/sage/libs/arb/arf.pxd +++ b/src/sage/libs/arb/arf.pxd @@ -1,6 +1,8 @@ # Deprecated header file; use sage/libs/flint/arf.pxd instead # See https://github.com/sagemath/sage/pull/36449 +from sage.libs.flint.types cimport arf_t + from sage.libs.flint.arf cimport ( arf_init, arf_clear, diff --git a/src/sage/libs/arb/mag.pxd b/src/sage/libs/arb/mag.pxd index dfba357f8d7..7c75a4343cc 100644 --- a/src/sage/libs/arb/mag.pxd +++ b/src/sage/libs/arb/mag.pxd @@ -1,7 +1,10 @@ # Deprecated header file; use sage/libs/flint/mag.pxd instead # See https://github.com/sagemath/sage/pull/36449 +from sage.libs.flint.types cimport mag_t + from sage.libs.flint.mag cimport ( + MAG_BITS, mag_init, mag_clear, mag_init_set, diff --git a/src/sage/libs/arb/types.pxd b/src/sage/libs/arb/types.pxd index 0e9306ecdc2..7a9a2fe1706 100644 --- a/src/sage/libs/arb/types.pxd +++ b/src/sage/libs/arb/types.pxd @@ -3,10 +3,9 @@ from sage.libs.flint.types cimport ( mag_struct, - mag_struct mag_t, + mag_t, mag_ptr, mag_srcptr, - MAG_BITS, arf_struct, arf_t, arf_ptr, @@ -22,7 +21,7 @@ from sage.libs.flint.types cimport ( arb_t, arb_ptr, arb_srcptr, - acb_struct + acb_struct, acb_t, acb_ptr, acb_srcptr, @@ -39,4 +38,3 @@ from sage.libs.flint.types cimport ( arb_poly_t, arb_poly_ptr, arb_poly_srcptr) - From 6a82645a23cc464e6b5c354f6e896f5dabb9ebe0 Mon Sep 17 00:00:00 2001 From: Vincent Delecroix Date: Sat, 14 Oct 2023 09:18:53 +0200 Subject: [PATCH 09/41] more autogenerated flint headers --- src/sage/libs/flint/acb.pxd | 378 +++--- src/sage/libs/flint/acb_calc.pxd | 8 +- src/sage/libs/flint/acb_dft.pxd | 54 +- src/sage/libs/flint/acb_dirichlet.pxd | 168 +-- src/sage/libs/flint/acb_elliptic.pxd | 50 +- src/sage/libs/flint/acb_hypgeom.pxd | 298 ++--- src/sage/libs/flint/acb_mat.pxd | 152 +-- src/sage/libs/flint/acb_modular.pxd | 60 +- src/sage/libs/flint/acb_poly.pxd | 432 +++---- src/sage/libs/flint/acf.pxd | 16 +- src/sage/libs/flint/aprcl.pxd | 60 +- src/sage/libs/flint/arb.pxd | 564 ++++----- src/sage/libs/flint/arb_calc.pxd | 20 +- src/sage/libs/flint/arb_fmpz_poly.pxd | 34 +- src/sage/libs/flint/arb_fpwrap.pxd | 22 +- src/sage/libs/flint/arb_hypgeom.pxd | 260 ++-- src/sage/libs/flint/arb_mat.pxd | 162 +-- src/sage/libs/flint/arb_poly.pxd | 418 +++---- src/sage/libs/flint/arf.pxd | 172 +-- src/sage/libs/flint/arith.pxd | 92 +- src/sage/libs/flint/bernoulli.pxd | 18 +- src/sage/libs/flint/bool_mat.pxd | 14 +- src/sage/libs/flint/ca.pxd | 66 +- src/sage/libs/flint/ca_ext.pxd | 10 +- src/sage/libs/flint/ca_field.pxd | 6 +- src/sage/libs/flint/ca_mat.pxd | 56 +- src/sage/libs/flint/ca_poly.pxd | 100 +- src/sage/libs/flint/ca_vec.pxd | 46 +- src/sage/libs/flint/calcium.pxd | 8 +- src/sage/libs/flint/d_mat.pxd | 10 +- src/sage/libs/flint/d_vec.pxd | 28 +- src/sage/libs/flint/dirichlet.pxd | 42 +- src/sage/libs/flint/dlog.pxd | 58 +- src/sage/libs/flint/double_extras.pxd | 4 +- src/sage/libs/flint/double_interval.pxd | 2 +- src/sage/libs/flint/fexpr.pxd | 62 +- src/sage/libs/flint/fexpr_builtin.pxd | 6 +- src/sage/libs/flint/fft.pxd | 12 +- src/sage/libs/flint/flint.pxd | 96 +- src/sage/libs/flint/flint.pyx | 45 - src/sage/libs/flint/fmpq.pxd | 60 +- src/sage/libs/flint/fmpq_mat.pxd | 50 +- src/sage/libs/flint/fmpq_mpoly.pxd | 138 +-- src/sage/libs/flint/fmpq_mpoly_factor.pxd | 8 +- src/sage/libs/flint/fmpq_poly.pxd | 308 ++--- src/sage/libs/flint/fmpq_vec.pxd | 55 + src/sage/libs/flint/fmpz.pxd | 182 +-- src/sage/libs/flint/fmpz_extras.pxd | 66 + src/sage/libs/flint/fmpz_factor.pxd | 14 +- src/sage/libs/flint/fmpz_factor.pyx | 1 - src/sage/libs/flint/fmpz_lll.pxd | 6 +- src/sage/libs/flint/fmpz_mat.pxd | 106 +- src/sage/libs/flint/fmpz_mod.pxd | 14 +- src/sage/libs/flint/fmpz_mod_mat.pxd | 34 +- src/sage/libs/flint/fmpz_mod_mpoly.pxd | 138 +-- src/sage/libs/flint/fmpz_mod_mpoly_factor.pxd | 8 +- src/sage/libs/flint/fmpz_mod_poly.pxd | 288 ++--- src/sage/libs/flint/fmpz_mod_poly_factor.pxd | 20 +- src/sage/libs/flint/fmpz_mod_vec.pxd | 20 +- src/sage/libs/flint/fmpz_mpoly.pxd | 212 ++-- src/sage/libs/flint/fmpz_mpoly_factor.pxd | 8 +- src/sage/libs/flint/fmpz_mpoly_q.pxd | 14 +- src/sage/libs/flint/fmpz_poly.pxd | 552 ++++----- src/sage/libs/flint/fmpz_poly_factor.pxd | 16 +- src/sage/libs/flint/fmpz_poly_mat.pxd | 42 +- src/sage/libs/flint/fmpz_poly_q.pxd | 12 +- src/sage/libs/flint/fmpz_vec.pxd | 294 ++++- src/sage/libs/flint/fmpzi.pxd | 94 ++ src/sage/libs/flint/fq.pxd | 36 +- src/sage/libs/flint/fq_default.pxd | 20 +- src/sage/libs/flint/fq_default_mat.pxd | 34 +- src/sage/libs/flint/fq_default_poly.pxd | 70 +- .../libs/flint/fq_default_poly_factor.pxd | 20 +- src/sage/libs/flint/fq_embed.pxd | 97 ++ src/sage/libs/flint/fq_mat.pxd | 366 ++++++ src/sage/libs/flint/fq_nmod.pxd | 36 +- src/sage/libs/flint/fq_nmod_embed.pxd | 4 +- src/sage/libs/flint/fq_nmod_mat.pxd | 46 +- src/sage/libs/flint/fq_nmod_mpoly.pxd | 98 +- src/sage/libs/flint/fq_nmod_mpoly_factor.pxd | 8 +- src/sage/libs/flint/fq_nmod_poly.pxd | 230 ++-- src/sage/libs/flint/fq_nmod_poly_factor.pxd | 20 +- src/sage/libs/flint/fq_nmod_vec.pxd | 32 +- src/sage/libs/flint/fq_poly.pxd | 1075 +++++++++++++++++ src/sage/libs/flint/fq_poly_factor.pxd | 168 +++ src/sage/libs/flint/fq_vec.pxd | 73 ++ src/sage/libs/flint/fq_zech.pxd | 32 +- src/sage/libs/flint/fq_zech_embed.pxd | 4 +- src/sage/libs/flint/fq_zech_mat.pxd | 38 +- src/sage/libs/flint/fq_zech_poly.pxd | 226 ++-- src/sage/libs/flint/fq_zech_poly_factor.pxd | 20 +- src/sage/libs/flint/fq_zech_vec.pxd | 32 +- src/sage/libs/flint/gr.pxd | 56 +- src/sage/libs/flint/gr_generic.pxd | 284 ++--- src/sage/libs/flint/gr_mat.pxd | 70 +- src/sage/libs/flint/gr_mpoly.pxd | 44 +- src/sage/libs/flint/gr_poly.pxd | 378 +++--- src/sage/libs/flint/gr_special.pxd | 74 +- src/sage/libs/flint/gr_vec.pxd | 196 +-- src/sage/libs/flint/hypgeom.pxd | 63 + src/sage/libs/flint/long_extras.pxd | 39 + src/sage/libs/flint/mag.pxd | 62 +- src/sage/libs/flint/mpf_mat.pxd | 100 ++ src/sage/libs/flint/mpf_vec.pxd | 80 ++ src/sage/libs/flint/mpfr_mat.pxd | 50 + src/sage/libs/flint/mpfr_vec.pxd | 40 + src/sage/libs/flint/mpn_extras.pxd | 182 +++ src/sage/libs/flint/mpoly.pxd | 96 +- src/sage/libs/flint/nf.pxd | 21 + src/sage/libs/flint/nf_elem.pxd | 274 +++++ src/sage/libs/flint/nmod.pxd | 86 ++ src/sage/libs/flint/nmod_mat.pxd | 456 +++++++ src/sage/libs/flint/nmod_mpoly.pxd | 128 +- src/sage/libs/flint/nmod_mpoly_factor.pxd | 10 +- src/sage/libs/flint/nmod_poly.pxd | 446 +++---- src/sage/libs/flint/nmod_poly_factor.pxd | 20 +- src/sage/libs/flint/nmod_poly_mat.pxd | 324 +++++ src/sage/libs/flint/nmod_vec.pxd | 137 ++- src/sage/libs/flint/padic.pxd | 58 +- src/sage/libs/flint/padic_mat.pxd | 22 +- src/sage/libs/flint/padic_poly.pxd | 74 +- src/sage/libs/flint/partitions.pxd | 10 +- src/sage/libs/flint/perm.pxd | 18 +- src/sage/libs/flint/profiler.pxd | 87 ++ src/sage/libs/flint/qadic.pxd | 48 +- src/sage/libs/flint/qfb.pxd | 158 +++ src/sage/libs/flint/qqbar.pxd | 134 +- src/sage/libs/flint/qsieve.pxd | 126 +- .../flint/{qsieve.pyx => qsieve_sage.pyx} | 3 +- src/sage/libs/flint/thread_pool.pxd | 58 +- src/sage/libs/flint/types.pxd | 119 ++ src/sage/libs/flint/ulong_extras.pxd | 216 ++-- 132 files changed, 9542 insertions(+), 4959 deletions(-) delete mode 100644 src/sage/libs/flint/flint.pyx create mode 100644 src/sage/libs/flint/fmpq_vec.pxd create mode 100644 src/sage/libs/flint/fmpz_extras.pxd delete mode 100644 src/sage/libs/flint/fmpz_factor.pyx create mode 100644 src/sage/libs/flint/fmpzi.pxd create mode 100644 src/sage/libs/flint/fq_embed.pxd create mode 100644 src/sage/libs/flint/fq_mat.pxd create mode 100644 src/sage/libs/flint/fq_poly.pxd create mode 100644 src/sage/libs/flint/fq_poly_factor.pxd create mode 100644 src/sage/libs/flint/fq_vec.pxd create mode 100644 src/sage/libs/flint/hypgeom.pxd create mode 100644 src/sage/libs/flint/long_extras.pxd create mode 100644 src/sage/libs/flint/mpf_mat.pxd create mode 100644 src/sage/libs/flint/mpf_vec.pxd create mode 100644 src/sage/libs/flint/mpfr_mat.pxd create mode 100644 src/sage/libs/flint/mpfr_vec.pxd create mode 100644 src/sage/libs/flint/mpn_extras.pxd create mode 100644 src/sage/libs/flint/nf.pxd create mode 100644 src/sage/libs/flint/nf_elem.pxd create mode 100644 src/sage/libs/flint/nmod.pxd create mode 100644 src/sage/libs/flint/nmod_mat.pxd create mode 100644 src/sage/libs/flint/nmod_poly_mat.pxd create mode 100644 src/sage/libs/flint/profiler.pxd create mode 100644 src/sage/libs/flint/qfb.pxd rename src/sage/libs/flint/{qsieve.pyx => qsieve_sage.pyx} (95%) diff --git a/src/sage/libs/flint/acb.pxd b/src/sage/libs/flint/acb.pxd index 71ed7da78bd..196d7588f08 100644 --- a/src/sage/libs/flint/acb.pxd +++ b/src/sage/libs/flint/acb.pxd @@ -18,23 +18,23 @@ cdef extern from "flint_wrap.h": void acb_clear(acb_t x) # Clears the variable *x*, freeing or recycling its allocated memory. - acb_ptr _acb_vec_init(long n) + acb_ptr _acb_vec_init(slong n) # Returns a pointer to an array of *n* initialized *acb_struct*:s. - void _acb_vec_clear(acb_ptr v, long n) + void _acb_vec_clear(acb_ptr v, slong n) # Clears an array of *n* initialized *acb_struct*:s. - long acb_allocated_bytes(const acb_t x) + slong acb_allocated_bytes(const acb_t x) # Returns the total number of bytes heap-allocated internally by this object. # The count excludes the size of the structure itself. Add # ``sizeof(acb_struct)`` to get the size of the object as a whole. - long _acb_vec_allocated_bytes(acb_srcptr vec, long len) + slong _acb_vec_allocated_bytes(acb_srcptr vec, slong len) # Returns the total number of bytes allocated for this vector, i.e. the # space taken up by the vector itself plus the sum of the internal heap # allocation sizes for all its member elements. - double _acb_vec_estimate_allocated_bytes(long len, long prec) + double _acb_vec_estimate_allocated_bytes(slong len, slong prec) # Estimates the number of bytes that need to be allocated for a vector of # *len* elements with *prec* bits of precision, including the space for # internal limb data. @@ -49,9 +49,9 @@ cdef extern from "flint_wrap.h": void acb_set(acb_t z, const acb_t x) - void acb_set_ui(acb_t z, unsigned long x) + void acb_set_ui(acb_t z, ulong x) - void acb_set_si(acb_t z, long x) + void acb_set_si(acb_t z, slong x) void acb_set_d(acb_t z, double x) @@ -60,7 +60,7 @@ cdef extern from "flint_wrap.h": void acb_set_arb(acb_t z, const arb_t c) # Sets *z* to the value of *x*. - void acb_set_si_si(acb_t z, long x, long y) + void acb_set_si_si(acb_t z, slong x, slong y) void acb_set_d_d(acb_t z, double x, double y) @@ -69,13 +69,13 @@ cdef extern from "flint_wrap.h": void acb_set_arb_arb(acb_t z, const arb_t x, const arb_t y) # Sets the real and imaginary part of *z* to the values *x* and *y* respectively - void acb_set_fmpq(acb_t z, const fmpq_t x, long prec) + void acb_set_fmpq(acb_t z, const fmpq_t x, slong prec) - void acb_set_round(acb_t z, const acb_t x, long prec) + void acb_set_round(acb_t z, const acb_t x, slong prec) - void acb_set_round_fmpz(acb_t z, const fmpz_t x, long prec) + void acb_set_round_fmpz(acb_t z, const fmpz_t x, slong prec) - void acb_set_round_arb(acb_t z, const arb_t x, long prec) + void acb_set_round_arb(acb_t z, const arb_t x, slong prec) # Sets *z* to *x*, rounded to *prec* bits. void acb_swap(acb_t z, acb_t x) @@ -97,16 +97,16 @@ cdef extern from "flint_wrap.h": void acb_fprint(FILE * file, const acb_t x) # Prints the internal representation of *x*. - void acb_printd(const acb_t x, long digits) + void acb_printd(const acb_t x, slong digits) - void acb_fprintd(FILE * file, const acb_t x, long digits) + void acb_fprintd(FILE * file, const acb_t x, slong digits) # Prints *x* in decimal. The printed value of the radius is not adjusted # to compensate for the fact that the binary-to-decimal conversion # of both the midpoint and the radius introduces additional error. - void acb_printn(const acb_t x, long digits, unsigned long flags) + void acb_printn(const acb_t x, slong digits, ulong flags) - void acb_fprintn(FILE * file, const acb_t x, long digits, unsigned long flags) + void acb_fprintn(FILE * file, const acb_t x, slong digits, ulong flags) # Prints a nice decimal representation of *x*, using the format of # :func:`arb_get_str` (or the corresponding :func:`arb_printn`) for the # real and imaginary parts. @@ -117,18 +117,18 @@ cdef extern from "flint_wrap.h": # Any flags understood by :func:`arb_get_str` can be passed via *flags* # to control the format of the real and imaginary parts. - void acb_randtest(acb_t z, flint_rand_t state, long prec, long mag_bits) + void acb_randtest(acb_t z, flint_rand_t state, slong prec, slong mag_bits) # Generates a random complex number by generating separate random # real and imaginary parts. - void acb_randtest_special(acb_t z, flint_rand_t state, long prec, long mag_bits) + void acb_randtest_special(acb_t z, flint_rand_t state, slong prec, slong mag_bits) # Generates a random complex number by generating separate random # real and imaginary parts. Also generates NaNs and infinities. - void acb_randtest_precise(acb_t z, flint_rand_t state, long prec, long mag_bits) + void acb_randtest_precise(acb_t z, flint_rand_t state, slong prec, slong mag_bits) # Generates a random complex number with precise real and imaginary parts. - void acb_randtest_param(acb_t z, flint_rand_t state, long prec, long mag_bits) + void acb_randtest_param(acb_t z, flint_rand_t state, slong prec, slong mag_bits) # Generates a random complex number, with very high probability of # generating integers and half-integers. @@ -147,7 +147,7 @@ cdef extern from "flint_wrap.h": int acb_is_int(const acb_t z) # Returns nonzero iff *z* is an exact integer. - int acb_is_int_2exp_si(const acb_t x, long e) + int acb_is_int_2exp_si(const acb_t x, slong e) # Returns nonzero iff *z* exactly equals `n 2^e` for some integer *n*. int acb_equal(const acb_t x, const acb_t y) @@ -160,7 +160,7 @@ cdef extern from "flint_wrap.h": # quantity, use :func:`acb_overlaps` or :func:`acb_contains`, # depending on the circumstance. - int acb_equal_si(const acb_t x, long y) + int acb_equal_si(const acb_t x, slong y) # Returns nonzero iff *x* is equal to the integer *y*. int acb_eq(const acb_t x, const acb_t y) @@ -175,18 +175,18 @@ cdef extern from "flint_wrap.h": int acb_overlaps(const acb_t x, const acb_t y) # Returns nonzero iff *x* and *y* have some point in common. - void acb_union(acb_t z, const acb_t x, const acb_t y, long prec) + void acb_union(acb_t z, const acb_t x, const acb_t y, slong prec) # Sets *z* to a complex interval containing both *x* and *y*. - void acb_get_abs_ubound_arf(arf_t u, const acb_t z, long prec) + void acb_get_abs_ubound_arf(arf_t u, const acb_t z, slong prec) # Sets *u* to an upper bound for the absolute value of *z*, computed # using a working precision of *prec* bits. - void acb_get_abs_lbound_arf(arf_t u, const acb_t z, long prec) + void acb_get_abs_lbound_arf(arf_t u, const acb_t z, slong prec) # Sets *u* to a lower bound for the absolute value of *z*, computed # using a working precision of *prec* bits. - void acb_get_rad_ubound_arf(arf_t u, const acb_t z, long prec) + void acb_get_rad_ubound_arf(arf_t u, const acb_t z, slong prec) # Sets *u* to an upper bound for the error radius of *z* (the value # is currently not computed tightly). @@ -219,22 +219,22 @@ cdef extern from "flint_wrap.h": # Such intervals must be handled specially by the user where a different # interpretation is intended. - long acb_rel_error_bits(const acb_t x) + slong acb_rel_error_bits(const acb_t x) # Returns the effective relative error of *x* measured in bits. # This is computed as if calling :func:`arb_rel_error_bits` on the # real ball whose midpoint is the larger out of the real and imaginary # midpoints of *x*, and whose radius is the larger out of the real # and imaginary radiuses of *x*. - long acb_rel_accuracy_bits(const acb_t x) + slong acb_rel_accuracy_bits(const acb_t x) # Returns the effective relative accuracy of *x* measured in bits, # equal to the negative of the return value from :func:`acb_rel_error_bits`. - long acb_rel_one_accuracy_bits(const acb_t x) + slong acb_rel_one_accuracy_bits(const acb_t x) # Given a ball with midpoint *m* and radius *r*, returns an approximation of # the relative accuracy of `[\max(1,|m|) \pm r]` measured in bits. - long acb_bits(const acb_t x) + slong acb_bits(const acb_t x) # Returns the maximum of *arb_bits* applied to the real # and imaginary parts of *x*, i.e. the minimum precision sufficient # to represent *x* exactly. @@ -263,7 +263,7 @@ cdef extern from "flint_wrap.h": void acb_get_imag(arb_t im, const acb_t z) # Sets *im* to the imaginary part of *z*. - void acb_arg(arb_t r, const acb_t z, long prec) + void acb_arg(arb_t r, const acb_t z, slong prec) # Sets *r* to a real interval containing the complex argument (phase) of *z*. # We define the complex argument have a discontinuity on `(-\infty,0]`, with # the special value `\operatorname{arg}(0) = 0`, and @@ -271,10 +271,10 @@ cdef extern from "flint_wrap.h": # `z = a+bi`, the argument is given by `\operatorname{atan2}(b,a)` # (see :func:`arb_atan2`). - void acb_abs(arb_t r, const acb_t z, long prec) + void acb_abs(arb_t r, const acb_t z, slong prec) # Sets *r* to the absolute value of *z*. - void acb_sgn(acb_t r, const acb_t z, long prec) + void acb_sgn(acb_t r, const acb_t z, slong prec) # Sets *r* to the complex sign of *z*, defined as 0 if *z* is exactly zero # and the projection onto the unit circle `z / |z| = \exp(i \arg(z))` otherwise. @@ -287,32 +287,32 @@ cdef extern from "flint_wrap.h": void acb_neg(acb_t z, const acb_t x) - void acb_neg_round(acb_t z, const acb_t x, long prec) + void acb_neg_round(acb_t z, const acb_t x, slong prec) # Sets *z* to the negation of *x*. void acb_conj(acb_t z, const acb_t x) # Sets *z* to the complex conjugate of *x*. - void acb_add_ui(acb_t z, const acb_t x, unsigned long y, long prec) + void acb_add_ui(acb_t z, const acb_t x, ulong y, slong prec) - void acb_add_si(acb_t z, const acb_t x, long y, long prec) + void acb_add_si(acb_t z, const acb_t x, slong y, slong prec) - void acb_add_fmpz(acb_t z, const acb_t x, const fmpz_t y, long prec) + void acb_add_fmpz(acb_t z, const acb_t x, const fmpz_t y, slong prec) - void acb_add_arb(acb_t z, const acb_t x, const arb_t y, long prec) + void acb_add_arb(acb_t z, const acb_t x, const arb_t y, slong prec) - void acb_add(acb_t z, const acb_t x, const acb_t y, long prec) + void acb_add(acb_t z, const acb_t x, const acb_t y, slong prec) # Sets *z* to the sum of *x* and *y*. - void acb_sub_ui(acb_t z, const acb_t x, unsigned long y, long prec) + void acb_sub_ui(acb_t z, const acb_t x, ulong y, slong prec) - void acb_sub_si(acb_t z, const acb_t x, long y, long prec) + void acb_sub_si(acb_t z, const acb_t x, slong y, slong prec) - void acb_sub_fmpz(acb_t z, const acb_t x, const fmpz_t y, long prec) + void acb_sub_fmpz(acb_t z, const acb_t x, const fmpz_t y, slong prec) - void acb_sub_arb(acb_t z, const acb_t x, const arb_t y, long prec) + void acb_sub_arb(acb_t z, const acb_t x, const arb_t y, slong prec) - void acb_sub(acb_t z, const acb_t x, const acb_t y, long prec) + void acb_sub(acb_t z, const acb_t x, const acb_t y, slong prec) # Sets *z* to the difference of *x* and *y*. void acb_mul_onei(acb_t z, const acb_t x) @@ -321,72 +321,72 @@ cdef extern from "flint_wrap.h": void acb_div_onei(acb_t z, const acb_t x) # Sets *z* to *x* divided by the imaginary unit. - void acb_mul_ui(acb_t z, const acb_t x, unsigned long y, long prec) + void acb_mul_ui(acb_t z, const acb_t x, ulong y, slong prec) - void acb_mul_si(acb_t z, const acb_t x, long y, long prec) + void acb_mul_si(acb_t z, const acb_t x, slong y, slong prec) - void acb_mul_fmpz(acb_t z, const acb_t x, const fmpz_t y, long prec) + void acb_mul_fmpz(acb_t z, const acb_t x, const fmpz_t y, slong prec) - void acb_mul_arb(acb_t z, const acb_t x, const arb_t y, long prec) + void acb_mul_arb(acb_t z, const acb_t x, const arb_t y, slong prec) # Sets *z* to the product of *x* and *y*. - void acb_mul(acb_t z, const acb_t x, const acb_t y, long prec) + void acb_mul(acb_t z, const acb_t x, const acb_t y, slong prec) # Sets *z* to the product of *x* and *y*. If at least one part of # *x* or *y* is zero, the operations is reduced to two real multiplications. # If *x* and *y* are the same pointers, they are assumed to represent # the same mathematical quantity and the squaring formula is used. - void acb_mul_2exp_si(acb_t z, const acb_t x, long e) + void acb_mul_2exp_si(acb_t z, const acb_t x, slong e) void acb_mul_2exp_fmpz(acb_t z, const acb_t x, const fmpz_t e) # Sets *z* to *x* multiplied by `2^e`, without rounding. - void acb_sqr(acb_t z, const acb_t x, long prec) + void acb_sqr(acb_t z, const acb_t x, slong prec) # Sets *z* to *x* squared. - void acb_cube(acb_t z, const acb_t x, long prec) + void acb_cube(acb_t z, const acb_t x, slong prec) # Sets *z* to *x* cubed, computed efficiently using two real squarings, # two real multiplications, and scalar operations. - void acb_addmul(acb_t z, const acb_t x, const acb_t y, long prec) + void acb_addmul(acb_t z, const acb_t x, const acb_t y, slong prec) - void acb_addmul_ui(acb_t z, const acb_t x, unsigned long y, long prec) + void acb_addmul_ui(acb_t z, const acb_t x, ulong y, slong prec) - void acb_addmul_si(acb_t z, const acb_t x, long y, long prec) + void acb_addmul_si(acb_t z, const acb_t x, slong y, slong prec) - void acb_addmul_fmpz(acb_t z, const acb_t x, const fmpz_t y, long prec) + void acb_addmul_fmpz(acb_t z, const acb_t x, const fmpz_t y, slong prec) - void acb_addmul_arb(acb_t z, const acb_t x, const arb_t y, long prec) + void acb_addmul_arb(acb_t z, const acb_t x, const arb_t y, slong prec) # Sets *z* to *z* plus the product of *x* and *y*. - void acb_submul(acb_t z, const acb_t x, const acb_t y, long prec) + void acb_submul(acb_t z, const acb_t x, const acb_t y, slong prec) - void acb_submul_ui(acb_t z, const acb_t x, unsigned long y, long prec) + void acb_submul_ui(acb_t z, const acb_t x, ulong y, slong prec) - void acb_submul_si(acb_t z, const acb_t x, long y, long prec) + void acb_submul_si(acb_t z, const acb_t x, slong y, slong prec) - void acb_submul_fmpz(acb_t z, const acb_t x, const fmpz_t y, long prec) + void acb_submul_fmpz(acb_t z, const acb_t x, const fmpz_t y, slong prec) - void acb_submul_arb(acb_t z, const acb_t x, const arb_t y, long prec) + void acb_submul_arb(acb_t z, const acb_t x, const arb_t y, slong prec) # Sets *z* to *z* minus the product of *x* and *y*. - void acb_inv(acb_t z, const acb_t x, long prec) + void acb_inv(acb_t z, const acb_t x, slong prec) # Sets *z* to the multiplicative inverse of *x*. - void acb_div_ui(acb_t z, const acb_t x, unsigned long y, long prec) + void acb_div_ui(acb_t z, const acb_t x, ulong y, slong prec) - void acb_div_si(acb_t z, const acb_t x, long y, long prec) + void acb_div_si(acb_t z, const acb_t x, slong y, slong prec) - void acb_div_fmpz(acb_t z, const acb_t x, const fmpz_t y, long prec) + void acb_div_fmpz(acb_t z, const acb_t x, const fmpz_t y, slong prec) - void acb_div_arb(acb_t z, const acb_t x, const arb_t y, long prec) + void acb_div_arb(acb_t z, const acb_t x, const arb_t y, slong prec) - void acb_div(acb_t z, const acb_t x, const acb_t y, long prec) + void acb_div(acb_t z, const acb_t x, const acb_t y, slong prec) # Sets *z* to the quotient of *x* and *y*. - void acb_dot_precise(acb_t res, const acb_t s, int subtract, acb_srcptr x, long xstep, acb_srcptr y, long ystep, long len, long prec) - void acb_dot_simple(acb_t res, const acb_t s, int subtract, acb_srcptr x, long xstep, acb_srcptr y, long ystep, long len, long prec) - void acb_dot(acb_t res, const acb_t s, int subtract, acb_srcptr x, long xstep, acb_srcptr y, long ystep, long len, long prec) + void acb_dot_precise(acb_t res, const acb_t s, int subtract, acb_srcptr x, slong xstep, acb_srcptr y, slong ystep, slong len, slong prec) + void acb_dot_simple(acb_t res, const acb_t s, int subtract, acb_srcptr x, slong xstep, acb_srcptr y, slong ystep, slong len, slong prec) + void acb_dot(acb_t res, const acb_t s, int subtract, acb_srcptr x, slong xstep, acb_srcptr y, slong ystep, slong len, slong prec) # Computes the dot product of the vectors *x* and *y*, setting # *res* to `s + (-1)^{subtract} \sum_{i=0}^{len-1} x_i y_i`. # The initial term *s* is optional and can be @@ -414,199 +414,199 @@ cdef extern from "flint_wrap.h": # final rounding. This can be extremely slow and is only intended # for testing. - void acb_approx_dot(acb_t res, const acb_t s, int subtract, acb_srcptr x, long xstep, acb_srcptr y, long ystep, long len, long prec) + void acb_approx_dot(acb_t res, const acb_t s, int subtract, acb_srcptr x, slong xstep, acb_srcptr y, slong ystep, slong len, slong prec) # Computes an approximate dot product *without error bounds*. # The radii of the inputs are ignored (only the midpoints are read) # and only the midpoint of the output is written. - void acb_dot_ui(acb_t res, const acb_t initial, int subtract, acb_srcptr x, long xstep, const unsigned long * y, long ystep, long len, long prec) - void acb_dot_si(acb_t res, const acb_t initial, int subtract, acb_srcptr x, long xstep, const long * y, long ystep, long len, long prec) - void acb_dot_uiui(acb_t res, const acb_t initial, int subtract, acb_srcptr x, long xstep, const unsigned long * y, long ystep, long len, long prec) - void acb_dot_siui(acb_t res, const acb_t initial, int subtract, acb_srcptr x, long xstep, const unsigned long * y, long ystep, long len, long prec) - void acb_dot_fmpz(acb_t res, const acb_t initial, int subtract, acb_srcptr x, long xstep, const fmpz * y, long ystep, long len, long prec) + void acb_dot_ui(acb_t res, const acb_t initial, int subtract, acb_srcptr x, slong xstep, const ulong * y, slong ystep, slong len, slong prec) + void acb_dot_si(acb_t res, const acb_t initial, int subtract, acb_srcptr x, slong xstep, const slong * y, slong ystep, slong len, slong prec) + void acb_dot_uiui(acb_t res, const acb_t initial, int subtract, acb_srcptr x, slong xstep, const ulong * y, slong ystep, slong len, slong prec) + void acb_dot_siui(acb_t res, const acb_t initial, int subtract, acb_srcptr x, slong xstep, const ulong * y, slong ystep, slong len, slong prec) + void acb_dot_fmpz(acb_t res, const acb_t initial, int subtract, acb_srcptr x, slong xstep, const fmpz * y, slong ystep, slong len, slong prec) # Equivalent to :func:`acb_dot`, but with integers in the array *y*. # The *uiui* and *siui* versions take an array of double-limb integers # as input; the *siui* version assumes that these represent signed # integers in two's complement form. - void acb_const_pi(acb_t y, long prec) + void acb_const_pi(acb_t y, slong prec) # Sets *y* to the constant `\pi`. - void acb_sqrt(acb_t r, const acb_t z, long prec) + void acb_sqrt(acb_t r, const acb_t z, slong prec) # Sets *r* to the square root of *z*. # If either the real or imaginary part is exactly zero, only # a single real square root is needed. Generally, we use the formula # `\sqrt{a+bi} = u/2 + ib/u, u = \sqrt{2(|a+bi|+a)}`, # requiring two real square root extractions. - void acb_sqrt_analytic(acb_t r, const acb_t z, int analytic, long prec) + void acb_sqrt_analytic(acb_t r, const acb_t z, int analytic, slong prec) # Computes the square root. If *analytic* is set, gives a NaN-containing # result if *z* touches the branch cut. - void acb_rsqrt(acb_t r, const acb_t z, long prec) + void acb_rsqrt(acb_t r, const acb_t z, slong prec) # Sets *r* to the reciprocal square root of *z*. # If either the real or imaginary part is exactly zero, only # a single real reciprocal square root is needed. Generally, we use the # formula `1/\sqrt{a+bi} = ((a+r) - bi)/v, r = |a+bi|, v = \sqrt{r |a+bi+r|^2}`, # requiring one real square root and one real reciprocal square root. - void acb_rsqrt_analytic(acb_t r, const acb_t z, int analytic, long prec) + void acb_rsqrt_analytic(acb_t r, const acb_t z, int analytic, slong prec) # Computes the reciprocal square root. If *analytic* is set, gives a # NaN-containing result if *z* touches the branch cut. - void acb_quadratic_roots_fmpz(acb_t r1, acb_t r2, const fmpz_t a, const fmpz_t b, const fmpz_t c, long prec) + void acb_quadratic_roots_fmpz(acb_t r1, acb_t r2, const fmpz_t a, const fmpz_t b, const fmpz_t c, slong prec) # Sets *r1* and *r2* to the roots of the quadratic polynomial # `ax^2 + bx + c`. Requires that *a* is nonzero. # This function is implemented so that both roots are computed accurately # even when direct use of the quadratic formula would lose accuracy. - void acb_root_ui(acb_t r, const acb_t z, unsigned long k, long prec) + void acb_root_ui(acb_t r, const acb_t z, ulong k, slong prec) # Sets *r* to the principal *k*-th root of *z*. - void acb_pow_fmpz(acb_t y, const acb_t b, const fmpz_t e, long prec) + void acb_pow_fmpz(acb_t y, const acb_t b, const fmpz_t e, slong prec) - void acb_pow_ui(acb_t y, const acb_t b, unsigned long e, long prec) + void acb_pow_ui(acb_t y, const acb_t b, ulong e, slong prec) - void acb_pow_si(acb_t y, const acb_t b, long e, long prec) + void acb_pow_si(acb_t y, const acb_t b, slong e, slong prec) # Sets `y = b^e` using binary exponentiation (with an initial division # if `e < 0`). Note that these functions can get slow if the exponent is # extremely large (in such cases :func:`acb_pow` may be superior). - void acb_pow_arb(acb_t z, const acb_t x, const arb_t y, long prec) + void acb_pow_arb(acb_t z, const acb_t x, const arb_t y, slong prec) - void acb_pow(acb_t z, const acb_t x, const acb_t y, long prec) + void acb_pow(acb_t z, const acb_t x, const acb_t y, slong prec) # Sets `z = x^y`, computed using binary exponentiation if `y` if # a small exact integer, as `z = (x^{1/2})^{2y}` if `y` is a small exact # half-integer, and generally as `z = \exp(y \log x)`. - void acb_pow_analytic(acb_t r, const acb_t x, const acb_t y, int analytic, long prec) + void acb_pow_analytic(acb_t r, const acb_t x, const acb_t y, int analytic, slong prec) # Computes the power `x^y`. If *analytic* is set, gives a # NaN-containing result if *x* touches the branch cut (unless *y* is # an integer). - void acb_unit_root(acb_t res, unsigned long order, long prec) + void acb_unit_root(acb_t res, ulong order, slong prec) # Sets *res* to `\exp(\frac{2i\pi}{\mathrm{order}})` to precision *prec*. - void acb_exp(acb_t y, const acb_t z, long prec) + void acb_exp(acb_t y, const acb_t z, slong prec) # Sets *y* to the exponential function of *z*, computed as # `\exp(a+bi) = \exp(a) \left( \cos(b) + \sin(b) i \right)`. - void acb_exp_pi_i(acb_t y, const acb_t z, long prec) + void acb_exp_pi_i(acb_t y, const acb_t z, slong prec) # Sets *y* to `\exp(\pi i z)`. - void acb_exp_invexp(acb_t s, acb_t t, const acb_t z, long prec) + void acb_exp_invexp(acb_t s, acb_t t, const acb_t z, slong prec) # Sets `s = \exp(z)` and `t = \exp(-z)`. - void acb_expm1(acb_t res, const acb_t z, long prec) + void acb_expm1(acb_t res, const acb_t z, slong prec) # Sets *res* to `\exp(z)-1`, using a more accurate method when `z \approx 0`. - void acb_log(acb_t y, const acb_t z, long prec) + void acb_log(acb_t y, const acb_t z, slong prec) # Sets *y* to the principal branch of the natural logarithm of *z*, # computed as # `\log(a+bi) = \frac{1}{2} \log(a^2 + b^2) + i \operatorname{arg}(a+bi)`. - void acb_log_analytic(acb_t r, const acb_t z, int analytic, long prec) + void acb_log_analytic(acb_t r, const acb_t z, int analytic, slong prec) # Computes the natural logarithm. If *analytic* is set, gives a # NaN-containing result if *z* touches the branch cut. - void acb_log1p(acb_t z, const acb_t x, long prec) + void acb_log1p(acb_t z, const acb_t x, slong prec) # Sets `z = \log(1+x)`, computed accurately when `x \approx 0`. - void acb_sin(acb_t s, const acb_t z, long prec) + void acb_sin(acb_t s, const acb_t z, slong prec) - void acb_cos(acb_t c, const acb_t z, long prec) + void acb_cos(acb_t c, const acb_t z, slong prec) - void acb_sin_cos(acb_t s, acb_t c, const acb_t z, long prec) + void acb_sin_cos(acb_t s, acb_t c, const acb_t z, slong prec) # Sets `s = \sin(z)`, `c = \cos(z)`, evaluated as # `\sin(a+bi) = \sin(a)\cosh(b) + i \cos(a)\sinh(b)`, # `\cos(a+bi) = \cos(a)\cosh(b) - i \sin(a)\sinh(b)`. - void acb_tan(acb_t s, const acb_t z, long prec) + void acb_tan(acb_t s, const acb_t z, slong prec) # Sets `s = \tan(z) = \sin(z) / \cos(z)`. For large imaginary parts, # the function is evaluated in a numerically stable way as `\pm i` # plus a decreasing exponential factor. - void acb_cot(acb_t s, const acb_t z, long prec) + void acb_cot(acb_t s, const acb_t z, slong prec) # Sets `s = \cot(z) = \cos(z) / \sin(z)`. For large imaginary parts, # the function is evaluated in a numerically stable way as `\pm i` # plus a decreasing exponential factor. - void acb_sin_pi(acb_t s, const acb_t z, long prec) + void acb_sin_pi(acb_t s, const acb_t z, slong prec) - void acb_cos_pi(acb_t s, const acb_t z, long prec) + void acb_cos_pi(acb_t s, const acb_t z, slong prec) - void acb_sin_cos_pi(acb_t s, acb_t c, const acb_t z, long prec) + void acb_sin_cos_pi(acb_t s, acb_t c, const acb_t z, slong prec) # Sets `s = \sin(\pi z)`, `c = \cos(\pi z)`, evaluating the trigonometric # factors of the real and imaginary part accurately via :func:`arb_sin_cos_pi`. - void acb_tan_pi(acb_t s, const acb_t z, long prec) + void acb_tan_pi(acb_t s, const acb_t z, slong prec) # Sets `s = \tan(\pi z)`. Uses the same algorithm as :func:`acb_tan`, # but evaluates the sine and cosine accurately via :func:`arb_sin_cos_pi`. - void acb_cot_pi(acb_t s, const acb_t z, long prec) + void acb_cot_pi(acb_t s, const acb_t z, slong prec) # Sets `s = \cot(\pi z)`. Uses the same algorithm as :func:`acb_cot`, # but evaluates the sine and cosine accurately via :func:`arb_sin_cos_pi`. - void acb_sec(acb_t res, const acb_t z, long prec) + void acb_sec(acb_t res, const acb_t z, slong prec) # Computes `\sec(z) = 1 / \cos(z)`. - void acb_csc(acb_t res, const acb_t z, long prec) + void acb_csc(acb_t res, const acb_t z, slong prec) # Computes `\csc(x) = 1 / \sin(z)`. - void acb_csc_pi(acb_t res, const acb_t z, long prec) + void acb_csc_pi(acb_t res, const acb_t z, slong prec) # Computes `\csc(\pi x) = 1 / \sin(\pi z)`. Evaluates the sine accurately # via :func:`acb_sin_pi`. - void acb_sinc(acb_t s, const acb_t z, long prec) + void acb_sinc(acb_t s, const acb_t z, slong prec) # Sets `s = \operatorname{sinc}(x) = \sin(z) / z`. - void acb_sinc_pi(acb_t s, const acb_t z, long prec) + void acb_sinc_pi(acb_t s, const acb_t z, slong prec) # Sets `s = \operatorname{sinc}(\pi x) = \sin(\pi z) / (\pi z)`. - void acb_asin(acb_t res, const acb_t z, long prec) + void acb_asin(acb_t res, const acb_t z, slong prec) # Sets *res* to `\operatorname{asin}(z) = -i \log(iz + \sqrt{1-z^2})`. - void acb_acos(acb_t res, const acb_t z, long prec) + void acb_acos(acb_t res, const acb_t z, slong prec) # Sets *res* to `\operatorname{acos}(z) = \tfrac{1}{2} \pi - \operatorname{asin}(z)`. - void acb_atan(acb_t res, const acb_t z, long prec) + void acb_atan(acb_t res, const acb_t z, slong prec) # Sets *res* to `\operatorname{atan}(z) = \tfrac{1}{2} i (\log(1-iz)-\log(1+iz))`. - void acb_sinh(acb_t s, const acb_t z, long prec) + void acb_sinh(acb_t s, const acb_t z, slong prec) - void acb_cosh(acb_t c, const acb_t z, long prec) + void acb_cosh(acb_t c, const acb_t z, slong prec) - void acb_sinh_cosh(acb_t s, acb_t c, const acb_t z, long prec) + void acb_sinh_cosh(acb_t s, acb_t c, const acb_t z, slong prec) - void acb_tanh(acb_t s, const acb_t z, long prec) + void acb_tanh(acb_t s, const acb_t z, slong prec) - void acb_coth(acb_t s, const acb_t z, long prec) + void acb_coth(acb_t s, const acb_t z, slong prec) # Respectively computes `\sinh(z) = -i\sin(iz)`, `\cosh(z) = \cos(iz)`, # `\tanh(z) = -i\tan(iz)`, `\coth(z) = i\cot(iz)`. - void acb_sech(acb_t res, const acb_t z, long prec) + void acb_sech(acb_t res, const acb_t z, slong prec) # Computes `\operatorname{sech}(z) = 1 / \cosh(z)`. - void acb_csch(acb_t res, const acb_t z, long prec) + void acb_csch(acb_t res, const acb_t z, slong prec) # Computes `\operatorname{csch}(z) = 1 / \sinh(z)`. - void acb_asinh(acb_t res, const acb_t z, long prec) + void acb_asinh(acb_t res, const acb_t z, slong prec) # Sets *res* to `\operatorname{asinh}(z) = -i \operatorname{asin}(iz)`. - void acb_acosh(acb_t res, const acb_t z, long prec) + void acb_acosh(acb_t res, const acb_t z, slong prec) # Sets *res* to `\operatorname{acosh}(z) = \log(z + \sqrt{z+1} \sqrt{z-1})`. - void acb_atanh(acb_t res, const acb_t z, long prec) + void acb_atanh(acb_t res, const acb_t z, slong prec) # Sets *res* to `\operatorname{atanh}(z) = -i \operatorname{atan}(iz)`. - void acb_lambertw_asymp(acb_t res, const acb_t z, const fmpz_t k, long L, long M, long prec) + void acb_lambertw_asymp(acb_t res, const acb_t z, const fmpz_t k, slong L, slong M, slong prec) # Sets *res* to the Lambert W function `W_k(z)` computed using *L* and *M* # terms in the bivariate series giving the asymptotic expansion at # zero or infinity. This algorithm is valid # everywhere, but the error bound is only finite when `|\log(z)|` is # sufficiently large. - int acb_lambertw_check_branch(const acb_t w, const fmpz_t k, long prec) + int acb_lambertw_check_branch(const acb_t w, const fmpz_t k, slong prec) # Tests if *w* definitely lies in the image of the branch `W_k(z)`. # This function is used internally to verify that a computed approximation # of the Lambert W function lies on the intended branch. Note that this will @@ -621,7 +621,7 @@ cdef extern from "flint_wrap.h": # discontinuity separately when using this function to bound perturbations # in the value of `W_k(z)`. - void acb_lambertw(acb_t res, const acb_t z, const fmpz_t k, int flags, long prec) + void acb_lambertw(acb_t res, const acb_t z, const fmpz_t k, int flags, slong prec) # Sets *res* to the Lambert W function `W_k(z)` where the index *k* selects # the branch (with `k = 0` giving the principal branch). # The placement of branch cuts follows [CGHJK1996]_. @@ -646,22 +646,22 @@ cdef extern from "flint_wrap.h": # The algorithm used to compute the Lambert W function is described # in [Joh2017b]_. - void acb_rising_ui(acb_t z, const acb_t x, unsigned long n, long prec) - void acb_rising(acb_t z, const acb_t x, const acb_t n, long prec) + void acb_rising_ui(acb_t z, const acb_t x, ulong n, slong prec) + void acb_rising(acb_t z, const acb_t x, const acb_t n, slong prec) # Computes the rising factorial `z = x (x+1) (x+2) \cdots (x+n-1)`. # These functions are aliases for :func:`acb_hypgeom_rising_ui` # and :func:`acb_hypgeom_rising`. - void acb_gamma(acb_t y, const acb_t x, long prec) + void acb_gamma(acb_t y, const acb_t x, slong prec) # Computes the gamma function `y = \Gamma(x)`. # This is an alias for :func:`acb_hypgeom_gamma`. - void acb_rgamma(acb_t y, const acb_t x, long prec) + void acb_rgamma(acb_t y, const acb_t x, slong prec) # Computes the reciprocal gamma function `y = 1/\Gamma(x)`, # avoiding division by zero at the poles of the gamma function. # This is an alias for :func:`acb_hypgeom_rgamma`. - void acb_lgamma(acb_t y, const acb_t x, long prec) + void acb_lgamma(acb_t y, const acb_t x, slong prec) # Computes the logarithmic gamma function `y = \log \Gamma(x)`. # This is an alias for :func:`acb_hypgeom_lgamma`. # The branch cut of the logarithmic gamma function is placed on the @@ -671,10 +671,10 @@ cdef extern from "flint_wrap.h": # In the left half plane, the reflection formula with correct # branch structure is evaluated via :func:`acb_log_sin_pi`. - void acb_digamma(acb_t y, const acb_t x, long prec) + void acb_digamma(acb_t y, const acb_t x, slong prec) # Computes the digamma function `y = \psi(x) = (\log \Gamma(x))' = \Gamma'(x) / \Gamma(x)`. - void acb_log_sin_pi(acb_t res, const acb_t z, long prec) + void acb_log_sin_pi(acb_t res, const acb_t z, slong prec) # Computes the logarithmic sine function defined by # .. math :: # S(z) = \log(\pi) - \log \Gamma(z) + \log \Gamma(1-z) @@ -700,7 +700,7 @@ cdef extern from "flint_wrap.h": # is computed from `S'(z)` to get a continuous change # when `z` is non-real and `n` spans more than one possible integer value. - void acb_polygamma(acb_t res, const acb_t s, const acb_t z, long prec) + void acb_polygamma(acb_t res, const acb_t s, const acb_t z, slong prec) # Sets *res* to the value of the generalized polygamma function `\psi(s,z)`. # If *s* is a nonnegative order, this is simply the *s*-order derivative # of the digamma function. If `s = 0`, this function simply @@ -713,9 +713,9 @@ cdef extern from "flint_wrap.h": # .. math :: # \psi(s,z) = \frac{\zeta'(s+1,z) + (\gamma + \psi(-s)) \zeta(s+1,z)}{\Gamma(-s)} - void acb_barnes_g(acb_t res, const acb_t z, long prec) + void acb_barnes_g(acb_t res, const acb_t z, slong prec) - void acb_log_barnes_g(acb_t res, const acb_t z, long prec) + void acb_log_barnes_g(acb_t res, const acb_t z, slong prec) # Computes Barnes *G*-function or the logarithmic Barnes *G*-function, # respectively. The logarithmic version has branch cuts on the negative # real axis and is continuous elsewhere in the complex plane, @@ -730,42 +730,42 @@ cdef extern from "flint_wrap.h": # .. math :: # \log G(z) = (z-1) \log \Gamma(z) - \zeta'(-1,z) + \zeta'(-1). - void acb_zeta(acb_t z, const acb_t s, long prec) + void acb_zeta(acb_t z, const acb_t s, slong prec) # Sets *z* to the value of the Riemann zeta function `\zeta(s)`. # Note: for computing derivatives with respect to `s`, # use :func:`acb_poly_zeta_series` or related methods. # This is a wrapper of :func:`acb_dirichlet_zeta`. - void acb_hurwitz_zeta(acb_t z, const acb_t s, const acb_t a, long prec) + void acb_hurwitz_zeta(acb_t z, const acb_t s, const acb_t a, slong prec) # Sets *z* to the value of the Hurwitz zeta function `\zeta(s, a)`. # Note: for computing derivatives with respect to `s`, # use :func:`acb_poly_zeta_series` or related methods. # This is a wrapper of :func:`acb_dirichlet_hurwitz`. - void acb_bernoulli_poly_ui(acb_t res, unsigned long n, const acb_t x, long prec) + void acb_bernoulli_poly_ui(acb_t res, ulong n, const acb_t x, slong prec) # Sets *res* to the value of the Bernoulli polynomial `B_n(x)`. # Warning: this function is only fast if either *n* or *x* is a small integer. # This function reads Bernoulli numbers from the global cache if they # are already cached, but does not automatically extend the cache by itself. - void acb_polylog(acb_t w, const acb_t s, const acb_t z, long prec) + void acb_polylog(acb_t w, const acb_t s, const acb_t z, slong prec) - void acb_polylog_si(acb_t w, long s, const acb_t z, long prec) + void acb_polylog_si(acb_t w, slong s, const acb_t z, slong prec) # Sets *w* to the polylogarithm `\operatorname{Li}_s(z)`. - void acb_agm1(acb_t m, const acb_t z, long prec) + void acb_agm1(acb_t m, const acb_t z, slong prec) # Sets *m* to the arithmetic-geometric mean `M(z) = \operatorname{agm}(1,z)`, # defined such that the function is continuous in the complex plane except for # a branch cut along the negative half axis (where it is continuous # from above). This corresponds to always choosing an "optimal" branch for # the square root in the arithmetic-geometric mean iteration. - void acb_agm1_cpx(acb_ptr m, const acb_t z, long len, long prec) + void acb_agm1_cpx(acb_ptr m, const acb_t z, slong len, slong prec) # Sets the coefficients in the array *m* to the power series expansion of the # arithmetic-geometric mean at the point *z* truncated to length *len*, i.e. # `M(z+x) \in \mathbb{C}[[x]]`. - void acb_agm(acb_t m, const acb_t x, const acb_t y, long prec) + void acb_agm(acb_t m, const acb_t x, const acb_t y, slong prec) # Sets *m* to the arithmetic-geometric mean of *x* and *y*. The square # roots in the AGM iteration are chosen so as to form the "optimal" # AGM sequence. This gives a well-defined function of *x* and *y* except @@ -774,61 +774,61 @@ cdef extern from "flint_wrap.h": # choice is made (if a decision cannot be made due to inexact arithmetic, # the union of both choices is returned). - void acb_chebyshev_t_ui(acb_t a, unsigned long n, const acb_t x, long prec) + void acb_chebyshev_t_ui(acb_t a, ulong n, const acb_t x, slong prec) - void acb_chebyshev_u_ui(acb_t a, unsigned long n, const acb_t x, long prec) + void acb_chebyshev_u_ui(acb_t a, ulong n, const acb_t x, slong prec) # Evaluates the Chebyshev polynomial of the first kind `a = T_n(x)` # or the Chebyshev polynomial of the second kind `a = U_n(x)`. - void acb_chebyshev_t2_ui(acb_t a, acb_t b, unsigned long n, const acb_t x, long prec) + void acb_chebyshev_t2_ui(acb_t a, acb_t b, ulong n, const acb_t x, slong prec) - void acb_chebyshev_u2_ui(acb_t a, acb_t b, unsigned long n, const acb_t x, long prec) + void acb_chebyshev_u2_ui(acb_t a, acb_t b, ulong n, const acb_t x, slong prec) # Simultaneously evaluates `a = T_n(x), b = T_{n-1}(x)` or # `a = U_n(x), b = U_{n-1}(x)`. # Aliasing between *a*, *b* and *x* is not permitted. - void acb_real_abs(acb_t res, const acb_t z, int analytic, long prec) + void acb_real_abs(acb_t res, const acb_t z, int analytic, slong prec) # The absolute value is extended to `+z` in the right half plane and # `-z` in the left half plane, with a discontinuity on the vertical line # `\operatorname{Re}(z) = 0`. - void acb_real_sgn(acb_t res, const acb_t z, int analytic, long prec) + void acb_real_sgn(acb_t res, const acb_t z, int analytic, slong prec) # The sign function is extended to `+1` in the right half plane and # `-1` in the left half plane, with a discontinuity on the vertical line # `\operatorname{Re}(z) = 0`. # If *analytic* is not set, this is effectively the same function as # :func:`acb_csgn`. - void acb_real_heaviside(acb_t res, const acb_t z, int analytic, long prec) + void acb_real_heaviside(acb_t res, const acb_t z, int analytic, slong prec) # The Heaviside step function (or unit step function) is extended to `+1` in # the right half plane and `0` in the left half plane, with a discontinuity on # the vertical line `\operatorname{Re}(z) = 0`. - void acb_real_floor(acb_t res, const acb_t z, int analytic, long prec) + void acb_real_floor(acb_t res, const acb_t z, int analytic, slong prec) # The floor function is extended to a piecewise constant function # equal to `n` in the strips with real part `(n,n+1)`, with discontinuities # on the vertical lines `\operatorname{Re}(z) = n`. - void acb_real_ceil(acb_t res, const acb_t z, int analytic, long prec) + void acb_real_ceil(acb_t res, const acb_t z, int analytic, slong prec) # The ceiling function is extended to a piecewise constant function # equal to `n+1` in the strips with real part `(n,n+1)`, with discontinuities # on the vertical lines `\operatorname{Re}(z) = n`. - void acb_real_max(acb_t res, const acb_t x, const acb_t y, int analytic, long prec) + void acb_real_max(acb_t res, const acb_t x, const acb_t y, int analytic, slong prec) # The real function `\max(x,y)` is extended to a piecewise analytic function # of two variables by returning `x` when # `\operatorname{Re}(x) \ge \operatorname{Re}(y)` # and returning `y` when `\operatorname{Re}(x) < \operatorname{Re}(y)`, # with discontinuities where `\operatorname{Re}(x) = \operatorname{Re}(y)`. - void acb_real_min(acb_t res, const acb_t x, const acb_t y, int analytic, long prec) + void acb_real_min(acb_t res, const acb_t x, const acb_t y, int analytic, slong prec) # The real function `\min(x,y)` is extended to a piecewise analytic function # of two variables by returning `x` when # `\operatorname{Re}(x) \le \operatorname{Re}(y)` # and returning `y` when `\operatorname{Re}(x) > \operatorname{Re}(y)`, # with discontinuities where `\operatorname{Re}(x) = \operatorname{Re}(y)`. - void acb_real_sqrtpos(acb_t res, const acb_t z, int analytic, long prec) + void acb_real_sqrtpos(acb_t res, const acb_t z, int analytic, slong prec) # Extends the real square root function on `[0,+\infty)` to the usual # complex square root on the cut plane. Like :func:`arb_sqrtpos`, only # the nonnegative part of *z* is considered if *z* is purely real @@ -837,83 +837,83 @@ cdef extern from "flint_wrap.h": # no spurious imaginary terms `[\pm \varepsilon] i` are created when the # balls computed for `f(x)` straddle zero. - void _acb_vec_zero(acb_ptr A, long n) + void _acb_vec_zero(acb_ptr A, slong n) # Sets all entries in *vec* to zero. - int _acb_vec_is_zero(acb_srcptr vec, long len) + int _acb_vec_is_zero(acb_srcptr vec, slong len) # Returns nonzero iff all entries in *x* are zero. - int _acb_vec_is_real(acb_srcptr v, long len) + int _acb_vec_is_real(acb_srcptr v, slong len) # Returns nonzero iff all entries in *x* have zero imaginary part. - void _acb_vec_set(acb_ptr res, acb_srcptr vec, long len) + void _acb_vec_set(acb_ptr res, acb_srcptr vec, slong len) # Sets *res* to a copy of *vec*. - void _acb_vec_set_round(acb_ptr res, acb_srcptr vec, long len, long prec) + void _acb_vec_set_round(acb_ptr res, acb_srcptr vec, slong len, slong prec) # Sets *res* to a copy of *vec*, rounding each entry to *prec* bits. - void _acb_vec_swap(acb_ptr vec1, acb_ptr vec2, long len) + void _acb_vec_swap(acb_ptr vec1, acb_ptr vec2, slong len) # Swaps the entries of *vec1* and *vec2*. - void _acb_vec_neg(acb_ptr res, acb_srcptr vec, long len) + void _acb_vec_neg(acb_ptr res, acb_srcptr vec, slong len) - void _acb_vec_add(acb_ptr res, acb_srcptr vec1, acb_srcptr vec2, long len, long prec) + void _acb_vec_add(acb_ptr res, acb_srcptr vec1, acb_srcptr vec2, slong len, slong prec) - void _acb_vec_sub(acb_ptr res, acb_srcptr vec1, acb_srcptr vec2, long len, long prec) + void _acb_vec_sub(acb_ptr res, acb_srcptr vec1, acb_srcptr vec2, slong len, slong prec) - void _acb_vec_scalar_submul(acb_ptr res, acb_srcptr vec, long len, const acb_t c, long prec) + void _acb_vec_scalar_submul(acb_ptr res, acb_srcptr vec, slong len, const acb_t c, slong prec) - void _acb_vec_scalar_addmul(acb_ptr res, acb_srcptr vec, long len, const acb_t c, long prec) + void _acb_vec_scalar_addmul(acb_ptr res, acb_srcptr vec, slong len, const acb_t c, slong prec) - void _acb_vec_scalar_mul(acb_ptr res, acb_srcptr vec, long len, const acb_t c, long prec) + void _acb_vec_scalar_mul(acb_ptr res, acb_srcptr vec, slong len, const acb_t c, slong prec) - void _acb_vec_scalar_mul_ui(acb_ptr res, acb_srcptr vec, long len, unsigned long c, long prec) + void _acb_vec_scalar_mul_ui(acb_ptr res, acb_srcptr vec, slong len, ulong c, slong prec) - void _acb_vec_scalar_mul_2exp_si(acb_ptr res, acb_srcptr vec, long len, long c) + void _acb_vec_scalar_mul_2exp_si(acb_ptr res, acb_srcptr vec, slong len, slong c) - void _acb_vec_scalar_mul_onei(acb_ptr res, acb_srcptr vec, long len) + void _acb_vec_scalar_mul_onei(acb_ptr res, acb_srcptr vec, slong len) - void _acb_vec_scalar_div_ui(acb_ptr res, acb_srcptr vec, long len, unsigned long c, long prec) + void _acb_vec_scalar_div_ui(acb_ptr res, acb_srcptr vec, slong len, ulong c, slong prec) - void _acb_vec_scalar_div(acb_ptr res, acb_srcptr vec, long len, const acb_t c, long prec) + void _acb_vec_scalar_div(acb_ptr res, acb_srcptr vec, slong len, const acb_t c, slong prec) - void _acb_vec_scalar_mul_arb(acb_ptr res, acb_srcptr vec, long len, const arb_t c, long prec) + void _acb_vec_scalar_mul_arb(acb_ptr res, acb_srcptr vec, slong len, const arb_t c, slong prec) - void _acb_vec_scalar_div_arb(acb_ptr res, acb_srcptr vec, long len, const arb_t c, long prec) + void _acb_vec_scalar_div_arb(acb_ptr res, acb_srcptr vec, slong len, const arb_t c, slong prec) - void _acb_vec_scalar_mul_fmpz(acb_ptr res, acb_srcptr vec, long len, const fmpz_t c, long prec) + void _acb_vec_scalar_mul_fmpz(acb_ptr res, acb_srcptr vec, slong len, const fmpz_t c, slong prec) - void _acb_vec_scalar_div_fmpz(acb_ptr res, acb_srcptr vec, long len, const fmpz_t c, long prec) + void _acb_vec_scalar_div_fmpz(acb_ptr res, acb_srcptr vec, slong len, const fmpz_t c, slong prec) - long _acb_vec_bits(acb_srcptr vec, long len) + slong _acb_vec_bits(acb_srcptr vec, slong len) # Returns the maximum of :func:`arb_bits` for all entries in *vec*. - void _acb_vec_set_powers(acb_ptr xs, const acb_t x, long len, long prec) + void _acb_vec_set_powers(acb_ptr xs, const acb_t x, slong len, slong prec) # Sets *xs* to the powers `1, x, x^2, \ldots, x^{len-1}`. - void _acb_vec_unit_roots(acb_ptr z, long order, long len, long prec) + void _acb_vec_unit_roots(acb_ptr z, slong order, slong len, slong prec) # Sets *z* to the powers `1,z,z^2,\dots z^{\mathrm{len}-1}` where `z=\exp(\frac{2i\pi}{\mathrm{order}})` to precision *prec*. # *order* can be taken negative. # In order to avoid precision loss, this function does not simply compute powers of a primitive root. - void _acb_vec_add_error_arf_vec(acb_ptr res, arf_srcptr err, long len) + void _acb_vec_add_error_arf_vec(acb_ptr res, arf_srcptr err, slong len) - void _acb_vec_add_error_mag_vec(acb_ptr res, mag_srcptr err, long len) + void _acb_vec_add_error_mag_vec(acb_ptr res, mag_srcptr err, slong len) # Adds the magnitude of each entry in *err* to the radius of the # corresponding entry in *res*. - void _acb_vec_indeterminate(acb_ptr vec, long len) + void _acb_vec_indeterminate(acb_ptr vec, slong len) # Applies :func:`acb_indeterminate` elementwise. - void _acb_vec_trim(acb_ptr res, acb_srcptr vec, long len) + void _acb_vec_trim(acb_ptr res, acb_srcptr vec, slong len) # Applies :func:`acb_trim` elementwise. - int _acb_vec_get_unique_fmpz_vec(fmpz * res, acb_srcptr vec, long len) + int _acb_vec_get_unique_fmpz_vec(fmpz * res, acb_srcptr vec, slong len) # Calls :func:`acb_get_unique_fmpz` elementwise and returns nonzero if # all entries can be rounded uniquely to integers. If any entry in *vec* # cannot be rounded uniquely to an integer, returns zero. - void _acb_vec_sort_pretty(acb_ptr vec, long len) + void _acb_vec_sort_pretty(acb_ptr vec, slong len) # Sorts the vector of complex numbers based on the real and imaginary parts. # This is intended to reveal structure when printing a set of complex numbers, # not to apply an order relation in a rigorous way. diff --git a/src/sage/libs/flint/acb_calc.pxd b/src/sage/libs/flint/acb_calc.pxd index cf78e824782..788857bddb5 100644 --- a/src/sage/libs/flint/acb_calc.pxd +++ b/src/sage/libs/flint/acb_calc.pxd @@ -12,7 +12,7 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - int acb_calc_integrate(acb_t res, acb_calc_func_t func, void * param, const acb_t a, const acb_t b, long rel_goal, const mag_t abs_tol, const acb_calc_integrate_opt_t options, long prec) + int acb_calc_integrate(acb_t res, acb_calc_func_t func, void * param, const acb_t a, const acb_t b, slong rel_goal, const mag_t abs_tol, const acb_calc_integrate_opt_t options, slong prec) # Computes a rigorous enclosure of the integral # .. math :: # I = \int_a^b f(t) dt @@ -91,7 +91,7 @@ cdef extern from "flint_wrap.h": # Initializes *options* for use, setting all fields to 0 indicating # default values. - int acb_calc_integrate_gl_auto_deg(acb_t res, long * num_eval, acb_calc_func_t func, void * param, const acb_t a, const acb_t b, const mag_t tol, long deg_limit, int flags, long prec) + int acb_calc_integrate_gl_auto_deg(acb_t res, slong * num_eval, acb_calc_func_t func, void * param, const acb_t a, const acb_t b, const mag_t tol, slong deg_limit, int flags, slong prec) # Attempts to compute `I = \int_a^b f(t) dt` using a single application # of Gauss-Legendre quadrature with automatic determination of the # quadrature degree so that the error is smaller than *tol*. @@ -119,7 +119,7 @@ cdef extern from "flint_wrap.h": # since this either means that we have hit a singularity or a branch cut or # that overestimation in the evaluation of `f` is becoming too severe. - void acb_calc_cauchy_bound(arb_t bound, acb_calc_func_t func, void * param, const acb_t x, const arb_t radius, long maxdepth, long prec) + void acb_calc_cauchy_bound(arb_t bound, acb_calc_func_t func, void * param, const acb_t x, const arb_t radius, slong maxdepth, slong prec) # Sets *bound* to a ball containing the value of the integral # .. math :: # C(x,r) = \frac{1}{2 \pi r} \oint_{|z-x| = r} |f(z)| dz @@ -133,7 +133,7 @@ cdef extern from "flint_wrap.h": # repeatedly subdivides the whole integration range instead of # performing adaptive subdivisions. - int acb_calc_integrate_taylor(acb_t res, acb_calc_func_t func, void * param, const acb_t a, const acb_t b, const arf_t inner_radius, const arf_t outer_radius, long accuracy_goal, long prec) + int acb_calc_integrate_taylor(acb_t res, acb_calc_func_t func, void * param, const acb_t a, const acb_t b, const arf_t inner_radius, const arf_t outer_radius, slong accuracy_goal, slong prec) # Computes the integral # .. math :: # I = \int_a^b f(t) dt diff --git a/src/sage/libs/flint/acb_dft.pxd b/src/sage/libs/flint/acb_dft.pxd index 13d8e8280bf..626cdf22c78 100644 --- a/src/sage/libs/flint/acb_dft.pxd +++ b/src/sage/libs/flint/acb_dft.pxd @@ -12,70 +12,70 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void acb_dft(acb_ptr w, acb_srcptr v, long n, long prec) + void acb_dft(acb_ptr w, acb_srcptr v, slong n, slong prec) - void acb_dft_inverse(acb_ptr w, acb_srcptr v, long n, long prec) + void acb_dft_inverse(acb_ptr w, acb_srcptr v, slong n, slong prec) - void acb_dft_precomp_init(acb_dft_pre_t pre, long len, long prec) + void acb_dft_precomp_init(acb_dft_pre_t pre, slong len, slong prec) void acb_dft_precomp_clear(acb_dft_pre_t pre) - void acb_dft_precomp(acb_ptr w, acb_srcptr v, const acb_dft_pre_t pre, long prec) + void acb_dft_precomp(acb_ptr w, acb_srcptr v, const acb_dft_pre_t pre, slong prec) - void acb_dft_inverse_precomp(acb_ptr w, acb_srcptr v, const acb_dft_pre_t pre, long prec) + void acb_dft_inverse_precomp(acb_ptr w, acb_srcptr v, const acb_dft_pre_t pre, slong prec) - void acb_dirichlet_dft_prod(acb_ptr w, acb_srcptr v, long * cyc, long num, long prec) + void acb_dirichlet_dft_prod(acb_ptr w, acb_srcptr v, slong * cyc, slong num, slong prec) - void acb_dft_prod_init(acb_dft_prod_t t, long * cyc, long num, long prec) + void acb_dft_prod_init(acb_dft_prod_t t, slong * cyc, slong num, slong prec) void acb_dft_prod_clear(acb_dft_prod_t t) - void acb_dirichlet_dft_prod_precomp(acb_ptr w, acb_srcptr v, const acb_dft_prod_t prod, long prec) + void acb_dirichlet_dft_prod_precomp(acb_ptr w, acb_srcptr v, const acb_dft_prod_t prod, slong prec) - void acb_dft_convol_naive(acb_ptr w, acb_srcptr f, acb_srcptr g, long len, long prec) + void acb_dft_convol_naive(acb_ptr w, acb_srcptr f, acb_srcptr g, slong len, slong prec) - void acb_dft_convol_rad2(acb_ptr w, acb_srcptr f, acb_srcptr g, long len, long prec) + void acb_dft_convol_rad2(acb_ptr w, acb_srcptr f, acb_srcptr g, slong len, slong prec) - void acb_dft_convol(acb_ptr w, acb_srcptr f, acb_srcptr g, long len, long prec) + void acb_dft_convol(acb_ptr w, acb_srcptr f, acb_srcptr g, slong len, slong prec) - void acb_dft_naive(acb_ptr w, acb_srcptr v, long n, long prec) + void acb_dft_naive(acb_ptr w, acb_srcptr v, slong n, slong prec) - void acb_dft_naive_init(acb_dft_naive_t t, long len, long prec) + void acb_dft_naive_init(acb_dft_naive_t t, slong len, slong prec) void acb_dft_naive_clear(acb_dft_naive_t t) - void acb_dft_naive_precomp(acb_ptr w, acb_srcptr v, const acb_dft_naive_t t, long prec) + void acb_dft_naive_precomp(acb_ptr w, acb_srcptr v, const acb_dft_naive_t t, slong prec) - void acb_dft_crt(acb_ptr w, acb_srcptr v, long n, long prec) + void acb_dft_crt(acb_ptr w, acb_srcptr v, slong n, slong prec) - void acb_dft_crt_init(acb_dft_crt_t t, long len, long prec) + void acb_dft_crt_init(acb_dft_crt_t t, slong len, slong prec) void acb_dft_crt_clear(acb_dft_crt_t t) - void acb_dft_crt_precomp(acb_ptr w, acb_srcptr v, const acb_dft_crt_t t, long prec) + void acb_dft_crt_precomp(acb_ptr w, acb_srcptr v, const acb_dft_crt_t t, slong prec) - void acb_dft_cyc(acb_ptr w, acb_srcptr v, long n, long prec) + void acb_dft_cyc(acb_ptr w, acb_srcptr v, slong n, slong prec) - void acb_dft_cyc_init(acb_dft_cyc_t t, long len, long prec) + void acb_dft_cyc_init(acb_dft_cyc_t t, slong len, slong prec) void acb_dft_cyc_clear(acb_dft_cyc_t t) - void acb_dft_cyc_precomp(acb_ptr w, acb_srcptr v, const acb_dft_cyc_t t, long prec) + void acb_dft_cyc_precomp(acb_ptr w, acb_srcptr v, const acb_dft_cyc_t t, slong prec) - void acb_dft_rad2(acb_ptr w, acb_srcptr v, int e, long prec) + void acb_dft_rad2(acb_ptr w, acb_srcptr v, int e, slong prec) - void acb_dft_inverse_rad2(acb_ptr w, acb_srcptr v, int e, long prec) + void acb_dft_inverse_rad2(acb_ptr w, acb_srcptr v, int e, slong prec) - void acb_dft_rad2_init(acb_dft_rad2_t t, int e, long prec) + void acb_dft_rad2_init(acb_dft_rad2_t t, int e, slong prec) void acb_dft_rad2_clear(acb_dft_rad2_t t) - void acb_dft_rad2_precomp(acb_ptr w, acb_srcptr v, const acb_dft_rad2_t t, long prec) + void acb_dft_rad2_precomp(acb_ptr w, acb_srcptr v, const acb_dft_rad2_t t, slong prec) - void acb_dft_bluestein(acb_ptr w, acb_srcptr v, long n, long prec) + void acb_dft_bluestein(acb_ptr w, acb_srcptr v, slong n, slong prec) - void acb_dft_bluestein_init(acb_dft_bluestein_t t, long len, long prec) + void acb_dft_bluestein_init(acb_dft_bluestein_t t, slong len, slong prec) void acb_dft_bluestein_clear(acb_dft_bluestein_t t) - void acb_dft_bluestein_precomp(acb_ptr w, acb_srcptr v, const acb_dft_bluestein_t t, long prec) + void acb_dft_bluestein_precomp(acb_ptr w, acb_srcptr v, const acb_dft_bluestein_t t, slong prec) diff --git a/src/sage/libs/flint/acb_dirichlet.pxd b/src/sage/libs/flint/acb_dirichlet.pxd index e70e6c189aa..7cbbc3426b1 100644 --- a/src/sage/libs/flint/acb_dirichlet.pxd +++ b/src/sage/libs/flint/acb_dirichlet.pxd @@ -12,7 +12,7 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void acb_dirichlet_roots_init(acb_dirichlet_roots_t roots, unsigned long n, long num, long prec) + void acb_dirichlet_roots_init(acb_dirichlet_roots_t roots, ulong n, slong num, slong prec) # Initializes *roots* with precomputed data for fast evaluation of roots of # unity `e^{2\pi i k/n}` of a fixed order *n*. The precomputation is # optimized for *num* evaluations. @@ -29,10 +29,10 @@ cdef extern from "flint_wrap.h": void acb_dirichlet_roots_clear(acb_dirichlet_roots_t roots) # Clears the structure. - void acb_dirichlet_root(acb_t res, const acb_dirichlet_roots_t roots, unsigned long k, long prec) + void acb_dirichlet_root(acb_t res, const acb_dirichlet_roots_t roots, ulong k, slong prec) # Computes `e^{2\pi i k/n}`. - void acb_dirichlet_powsum_term(acb_ptr res, arb_t log_prev, unsigned long * prev, const acb_t s, unsigned long k, int integer, int critical_line, long len, long prec) + void acb_dirichlet_powsum_term(acb_ptr res, arb_t log_prev, ulong * prev, const acb_t s, ulong k, int integer, int critical_line, slong len, slong prec) # Sets *res* to `k^{-(s+x)}` as a power series in *x* truncated to length *len*. # The flags *integer* and *critical_line* respectively specify optimizing # for *s* being an integer or having real part 1/2. @@ -43,7 +43,7 @@ cdef extern from "flint_wrap.h": # overwritten by *k*, allowing *log_prev* to be recycled for the next # term when evaluating a power sum. - void acb_dirichlet_powsum_sieved(acb_ptr res, const acb_t s, unsigned long n, long len, long prec) + void acb_dirichlet_powsum_sieved(acb_ptr res, const acb_t s, ulong n, slong len, slong prec) # Sets *res* to `\sum_{k=1}^n k^{-(s+x)}` # as a power series in *x* truncated to length *len*. # This function stores a table of powers that have already been calculated, @@ -55,7 +55,7 @@ cdef extern from "flint_wrap.h": # power series multiplications, it is only faster than the naive # algorithm when *len* is small. - void acb_dirichlet_powsum_smooth(acb_ptr res, const acb_t s, unsigned long n, long len, long prec) + void acb_dirichlet_powsum_smooth(acb_ptr res, const acb_t s, ulong n, slong len, slong prec) # Sets *res* to `\sum_{k=1}^n k^{-(s+x)}` # as a power series in *x* truncated to length *len*. # This function performs partial sieving by adding multiples of 5-smooth *k* @@ -66,10 +66,10 @@ cdef extern from "flint_wrap.h": # A slightly bigger gain for larger *n* could be achieved by using more # small prime factors, at the expense of space. - void acb_dirichlet_zeta(acb_t res, const acb_t s, long prec) + void acb_dirichlet_zeta(acb_t res, const acb_t s, slong prec) # Computes `\zeta(s)` using an automatic choice of algorithm. - void acb_dirichlet_zeta_jet(acb_t res, const acb_t s, int deflate, long len, long prec) + void acb_dirichlet_zeta_jet(acb_t res, const acb_t s, int deflate, slong len, slong prec) # Computes the first *len* terms of the Taylor series of the Riemann zeta # function at *s*. If *deflate* is nonzero, computes the deflated # function `\zeta(s) - 1/(s-1)` instead. @@ -85,56 +85,56 @@ cdef extern from "flint_wrap.h": # `|\zeta''(s)|`. These bounds are mainly intended for use in the critical # strip and will not be tight. - void acb_dirichlet_eta(acb_t res, const acb_t s, long prec) + void acb_dirichlet_eta(acb_t res, const acb_t s, slong prec) # Sets *res* to the Dirichlet eta function # `\eta(s) = \sum_{k=1}^{\infty} (-1)^{k+1} / k^s = (1-2^{1-s}) \zeta(s)`, # also known as the alternating zeta function. # Note that the alternating character `\{1,-1\}` is not itself # a Dirichlet character. - void acb_dirichlet_xi(acb_t res, const acb_t s, long prec) + void acb_dirichlet_xi(acb_t res, const acb_t s, slong prec) # Sets *res* to the Riemann xi function # `\xi(s) = \frac{1}{2} s (s-1) \pi^{-s/2} \Gamma(\frac{1}{2} s) \zeta(s)`. # The functional equation for xi is `\xi(1-s) = \xi(s)`. - void acb_dirichlet_zeta_rs_f_coeffs(acb_ptr f, const arb_t p, long n, long prec) + void acb_dirichlet_zeta_rs_f_coeffs(acb_ptr f, const arb_t p, slong n, slong prec) # Computes the coefficients `F^{(j)}(p)` for `0 \le j < n`. # Uses power series division. This method breaks down when `p = \pm 1/2` # (which is not problem if *s* is an exact floating-point number). - void acb_dirichlet_zeta_rs_d_coeffs(arb_ptr d, const arb_t sigma, long k, long prec) + void acb_dirichlet_zeta_rs_d_coeffs(arb_ptr d, const arb_t sigma, slong k, slong prec) # Computes the coefficients `d_j^{(k)}` for `0 \le j \le \lfloor 3k/2 \rfloor + 1`. # On input, the array *d* must contain the coefficients for `d_j^{(k-1)}` # unless `k = 0`, and these coefficients will be updated in-place. - void acb_dirichlet_zeta_rs_bound(mag_t err, const acb_t s, long K) + void acb_dirichlet_zeta_rs_bound(mag_t err, const acb_t s, slong K) # Bounds the error term `RS_K` following Theorem 4.2 in Arias de Reyna. - void acb_dirichlet_zeta_rs_r(acb_t res, const acb_t s, long K, long prec) + void acb_dirichlet_zeta_rs_r(acb_t res, const acb_t s, slong K, slong prec) # Computes `\mathcal{R}(s)` in the upper half plane. Uses precisely *K* # asymptotic terms in the RS formula if this input parameter is positive; # otherwise chooses the number of terms automatically based on *s* and the # precision. - void acb_dirichlet_zeta_rs(acb_t res, const acb_t s, long K, long prec) + void acb_dirichlet_zeta_rs(acb_t res, const acb_t s, slong K, slong prec) # Computes `\zeta(s)` using the Riemann-Siegel formula. Uses precisely # *K* asymptotic terms in the RS formula if this input parameter is positive; # otherwise chooses the number of terms automatically based on *s* and the # precision. - void acb_dirichlet_zeta_jet_rs(acb_ptr res, const acb_t s, long len, long prec) + void acb_dirichlet_zeta_jet_rs(acb_ptr res, const acb_t s, slong len, slong prec) # Computes the first *len* terms of the Taylor series of the Riemann zeta # function at *s* using the Riemann Siegel formula. This function currently # only supports *len* = 1 or *len* = 2. A finite difference is used # to compute the first derivative. - void acb_dirichlet_hurwitz(acb_t res, const acb_t s, const acb_t a, long prec) + void acb_dirichlet_hurwitz(acb_t res, const acb_t s, const acb_t a, slong prec) # Computes the Hurwitz zeta function `\zeta(s, a)`. # This function automatically delegates to the code for the Riemann zeta function # when `a = 1`. Some other special cases may also be handled by direct # formulas. In general, Euler-Maclaurin summation is used. - void acb_dirichlet_hurwitz_precomp_init(acb_dirichlet_hurwitz_precomp_t pre, const acb_t s, int deflate, long A, long K, long N, long prec) + void acb_dirichlet_hurwitz_precomp_init(acb_dirichlet_hurwitz_precomp_t pre, const acb_t s, int deflate, slong A, slong K, slong N, slong prec) # Precomputes a grid of Taylor polynomials for fast evaluation of # `\zeta(s,a)` on `a \in (0,1]` with fixed *s*. # *A* is the initial shift to apply to *a*, *K* is the number of Taylor terms, @@ -153,7 +153,7 @@ cdef extern from "flint_wrap.h": # If *deflate* is set, the deflated Hurwitz zeta function is used, # removing the pole at `s = 1`. - void acb_dirichlet_hurwitz_precomp_init_num(acb_dirichlet_hurwitz_precomp_t pre, const acb_t s, int deflate, double num_eval, long prec) + void acb_dirichlet_hurwitz_precomp_init_num(acb_dirichlet_hurwitz_precomp_t pre, const acb_t s, int deflate, double num_eval, slong prec) # Initializes *pre*, choosing the parameters *A*, *K*, and *N* # automatically to minimize the cost of *num_eval* evaluations of the # Hurwitz zeta function at argument *s* to precision *prec*. @@ -161,7 +161,7 @@ cdef extern from "flint_wrap.h": void acb_dirichlet_hurwitz_precomp_clear(acb_dirichlet_hurwitz_precomp_t pre) # Clears the precomputed data. - void acb_dirichlet_hurwitz_precomp_choose_param(unsigned long * A, unsigned long * K, unsigned long * N, const acb_t s, double num_eval, long prec) + void acb_dirichlet_hurwitz_precomp_choose_param(ulong * A, ulong * K, ulong * N, const acb_t s, double num_eval, slong prec) # Chooses precomputation parameters *A*, *K* and *N* to minimize # the cost of *num_eval* evaluations of the Hurwitz zeta function # at argument *s* to precision *prec*. @@ -169,18 +169,18 @@ cdef extern from "flint_wrap.h": # scratch would be better than performing a precomputation, *A*, *K* and *N* # are all set to 0. - void acb_dirichlet_hurwitz_precomp_bound(mag_t res, const acb_t s, long A, long K, long N) + void acb_dirichlet_hurwitz_precomp_bound(mag_t res, const acb_t s, slong A, slong K, slong N) # Computes an upper bound for the truncation error (not accounting for # roundoff error) when evaluating `\zeta(s,a)` with precomputation parameters # *A*, *K*, *N*, assuming that `0 < a \le 1`. # For details, see :ref:`algorithms_hurwitz`. - void acb_dirichlet_hurwitz_precomp_eval(acb_t res, const acb_dirichlet_hurwitz_precomp_t pre, unsigned long p, unsigned long q, long prec) + void acb_dirichlet_hurwitz_precomp_eval(acb_t res, const acb_dirichlet_hurwitz_precomp_t pre, ulong p, ulong q, slong prec) # Evaluates `\zeta(s,p/q)` using precomputed data, assuming that `0 < p/q \le 1`. - void acb_dirichlet_lerch_phi_integral(acb_t res, const acb_t z, const acb_t s, const acb_t a, long prec) - void acb_dirichlet_lerch_phi_direct(acb_t res, const acb_t z, const acb_t s, const acb_t a, long prec) - void acb_dirichlet_lerch_phi(acb_t res, const acb_t z, const acb_t s, const acb_t a, long prec) + void acb_dirichlet_lerch_phi_integral(acb_t res, const acb_t z, const acb_t s, const acb_t a, slong prec) + void acb_dirichlet_lerch_phi_direct(acb_t res, const acb_t z, const acb_t s, const acb_t a, slong prec) + void acb_dirichlet_lerch_phi(acb_t res, const acb_t z, const acb_t s, const acb_t a, slong prec) # Computes the Lerch transcendent # .. math :: # \Phi(z,s,a) = \sum_{k=0}^{\infty} \frac{z^k}{(k+a)^s} @@ -195,7 +195,7 @@ cdef extern from "flint_wrap.h": # checks for some special cases where the function can be expressed # in terms of simpler functions (Hurwitz zeta, polylogarithms). - void acb_dirichlet_stieltjes(acb_t res, const fmpz_t n, const acb_t a, long prec) + void acb_dirichlet_stieltjes(acb_t res, const fmpz_t n, const acb_t a, slong prec) # Given a nonnegative integer *n*, sets *res* to the generalized Stieltjes constant # `\gamma_n(a)` which is the coefficient in the Laurent series of the # Hurwitz zeta function at the pole @@ -213,42 +213,42 @@ cdef extern from "flint_wrap.h": # expansion once at `s = 1` than to call this function repeatedly, # unless *n* is extremely large (at least several hundred). - void acb_dirichlet_chi(acb_t res, const dirichlet_group_t G, const dirichlet_char_t chi, unsigned long n, long prec) + void acb_dirichlet_chi(acb_t res, const dirichlet_group_t G, const dirichlet_char_t chi, ulong n, slong prec) # Sets *res* to `\chi(n)`, the value of the Dirichlet character *chi* # at the integer *n*. - void acb_dirichlet_chi_vec(acb_ptr v, const dirichlet_group_t G, const dirichlet_char_t chi, long nv, long prec) + void acb_dirichlet_chi_vec(acb_ptr v, const dirichlet_group_t G, const dirichlet_char_t chi, slong nv, slong prec) # Compute the *nv* first Dirichlet values. - void acb_dirichlet_pairing(acb_t res, const dirichlet_group_t G, unsigned long m, unsigned long n, long prec) + void acb_dirichlet_pairing(acb_t res, const dirichlet_group_t G, ulong m, ulong n, slong prec) - void acb_dirichlet_pairing_char(acb_t res, const dirichlet_group_t G, const dirichlet_char_t a, const dirichlet_char_t b, long prec) + void acb_dirichlet_pairing_char(acb_t res, const dirichlet_group_t G, const dirichlet_char_t a, const dirichlet_char_t b, slong prec) # Sets *res* to the value of the Dirichlet pairing `\chi(m,n)` at numbers `m` and `n`. # The second form takes two characters as input. - void acb_dirichlet_gauss_sum_naive(acb_t res, const dirichlet_group_t G, const dirichlet_char_t chi, long prec) + void acb_dirichlet_gauss_sum_naive(acb_t res, const dirichlet_group_t G, const dirichlet_char_t chi, slong prec) - void acb_dirichlet_gauss_sum_factor(acb_t res, const dirichlet_group_t G, const dirichlet_char_t chi, long prec) + void acb_dirichlet_gauss_sum_factor(acb_t res, const dirichlet_group_t G, const dirichlet_char_t chi, slong prec) - void acb_dirichlet_gauss_sum_order2(acb_t res, const dirichlet_group_t G, const dirichlet_char_t chi, long prec) + void acb_dirichlet_gauss_sum_order2(acb_t res, const dirichlet_group_t G, const dirichlet_char_t chi, slong prec) - void acb_dirichlet_gauss_sum_theta(acb_t res, const dirichlet_group_t G, const dirichlet_char_t chi, long prec) + void acb_dirichlet_gauss_sum_theta(acb_t res, const dirichlet_group_t G, const dirichlet_char_t chi, slong prec) - void acb_dirichlet_gauss_sum(acb_t res, const dirichlet_group_t G, const dirichlet_char_t chi, long prec) + void acb_dirichlet_gauss_sum(acb_t res, const dirichlet_group_t G, const dirichlet_char_t chi, slong prec) - void acb_dirichlet_jacobi_sum_naive(acb_t res, const dirichlet_group_t G, const dirichlet_char_t chi1, const dirichlet_char_t chi2, long prec) + void acb_dirichlet_jacobi_sum_naive(acb_t res, const dirichlet_group_t G, const dirichlet_char_t chi1, const dirichlet_char_t chi2, slong prec) - void acb_dirichlet_jacobi_sum_factor(acb_t res, const dirichlet_group_t G, const dirichlet_char_t chi1, const dirichlet_char_t chi2, long prec) + void acb_dirichlet_jacobi_sum_factor(acb_t res, const dirichlet_group_t G, const dirichlet_char_t chi1, const dirichlet_char_t chi2, slong prec) - void acb_dirichlet_jacobi_sum_gauss(acb_t res, const dirichlet_group_t G, const dirichlet_char_t chi1, const dirichlet_char_t chi2, long prec) + void acb_dirichlet_jacobi_sum_gauss(acb_t res, const dirichlet_group_t G, const dirichlet_char_t chi1, const dirichlet_char_t chi2, slong prec) - void acb_dirichlet_jacobi_sum(acb_t res, const dirichlet_group_t G, const dirichlet_char_t chi1, const dirichlet_char_t chi2, long prec) + void acb_dirichlet_jacobi_sum(acb_t res, const dirichlet_group_t G, const dirichlet_char_t chi1, const dirichlet_char_t chi2, slong prec) - void acb_dirichlet_jacobi_sum_ui(acb_t res, const dirichlet_group_t G, unsigned long a, unsigned long b, long prec) + void acb_dirichlet_jacobi_sum_ui(acb_t res, const dirichlet_group_t G, ulong a, ulong b, slong prec) - void acb_dirichlet_chi_theta_arb(acb_t res, const dirichlet_group_t G, const dirichlet_char_t chi, const arb_t t, long prec) + void acb_dirichlet_chi_theta_arb(acb_t res, const dirichlet_group_t G, const dirichlet_char_t chi, const arb_t t, slong prec) - void acb_dirichlet_ui_theta_arb(acb_t res, const dirichlet_group_t G, unsigned long a, const arb_t t, long prec) + void acb_dirichlet_ui_theta_arb(acb_t res, const dirichlet_group_t G, ulong a, const arb_t t, slong prec) # Compute the theta series `\Theta_q(a,t)` for real argument `t>0`. # Beware that if `t<1` the functional equation # .. math:: @@ -263,21 +263,21 @@ cdef extern from "flint_wrap.h": # .. math:: # \Theta_q(a,t) = \sum_{n\geq 0} \chi_q(a, n) x(t)^{n^2}. - unsigned long acb_dirichlet_theta_length(unsigned long q, const arb_t t, long prec) + ulong acb_dirichlet_theta_length(ulong q, const arb_t t, slong prec) - void acb_dirichlet_qseries_arb_powers_naive(acb_t res, const arb_t x, int p, const unsigned long * a, const acb_dirichlet_roots_t z, long len, long prec) + void acb_dirichlet_qseries_arb_powers_naive(acb_t res, const arb_t x, int p, const ulong * a, const acb_dirichlet_roots_t z, slong len, slong prec) - void acb_dirichlet_qseries_arb_powers_smallorder(acb_t res, const arb_t x, int p, const unsigned long * a, const acb_dirichlet_roots_t z, long len, long prec) + void acb_dirichlet_qseries_arb_powers_smallorder(acb_t res, const arb_t x, int p, const ulong * a, const acb_dirichlet_roots_t z, slong len, slong prec) - void acb_dirichlet_dft_conrey(acb_ptr w, acb_srcptr v, const dirichlet_group_t G, long prec) + void acb_dirichlet_dft_conrey(acb_ptr w, acb_srcptr v, const dirichlet_group_t G, slong prec) - void acb_dirichlet_dft(acb_ptr w, acb_srcptr v, const dirichlet_group_t G, long prec) + void acb_dirichlet_dft(acb_ptr w, acb_srcptr v, const dirichlet_group_t G, slong prec) - void acb_dirichlet_root_number_theta(acb_t res, const dirichlet_group_t G, const dirichlet_char_t chi, long prec) + void acb_dirichlet_root_number_theta(acb_t res, const dirichlet_group_t G, const dirichlet_char_t chi, slong prec) - void acb_dirichlet_root_number(acb_t res, const dirichlet_group_t G, const dirichlet_char_t chi, long prec) + void acb_dirichlet_root_number(acb_t res, const dirichlet_group_t G, const dirichlet_char_t chi, slong prec) - void acb_dirichlet_l_hurwitz(acb_t res, const acb_t s, const acb_dirichlet_hurwitz_precomp_t precomp, const dirichlet_group_t G, const dirichlet_char_t chi, long prec) + void acb_dirichlet_l_hurwitz(acb_t res, const acb_t s, const acb_dirichlet_hurwitz_precomp_t precomp, const dirichlet_group_t G, const dirichlet_char_t chi, slong prec) # Computes `L(s,\chi)` using decomposition in terms of the Hurwitz zeta function # .. math:: # L(s,\chi) = q^{-s}\sum_{k=1}^q \chi(k) \,\zeta\!\left(s,\frac kq\right). @@ -287,9 +287,9 @@ cdef extern from "flint_wrap.h": # directly. If a pre-initialized *precomp* object is provided, this will be # used instead to evaluate the Hurwitz zeta function. - void acb_dirichlet_l_euler_product(acb_t res, const acb_t s, const dirichlet_group_t G, const dirichlet_char_t chi, long prec) + void acb_dirichlet_l_euler_product(acb_t res, const acb_t s, const dirichlet_group_t G, const dirichlet_char_t chi, slong prec) - void _acb_dirichlet_euler_product_real_ui(arb_t res, unsigned long s, const signed char * chi, int mod, int reciprocal, long prec) + void _acb_dirichlet_euler_product_real_ui(arb_t res, ulong s, const signed char * chi, int mod, int reciprocal, slong prec) # Computes `L(s,\chi)` directly using the Euler product. This is # efficient if *s* has large positive real part. As implemented, this # function only gives a finite result if `\operatorname{re}(s) \ge 2`. @@ -307,16 +307,16 @@ cdef extern from "flint_wrap.h": # values at 0, 1, ..., *mod* - 1. If *reciprocal* is set, it computes # `1 / L(s,\chi)` (this is faster if the reciprocal can be used directly). - void acb_dirichlet_l(acb_t res, const acb_t s, const dirichlet_group_t G, const dirichlet_char_t chi, long prec) + void acb_dirichlet_l(acb_t res, const acb_t s, const dirichlet_group_t G, const dirichlet_char_t chi, slong prec) # Computes `L(s,\chi)` using a default choice of algorithm. - void acb_dirichlet_l_fmpq(acb_t res, const fmpq_t s, const dirichlet_group_t G, const dirichlet_char_t chi, long prec) - void acb_dirichlet_l_fmpq_afe(acb_t res, const fmpq_t s, const dirichlet_group_t G, const dirichlet_char_t chi, long prec) + void acb_dirichlet_l_fmpq(acb_t res, const fmpq_t s, const dirichlet_group_t G, const dirichlet_char_t chi, slong prec) + void acb_dirichlet_l_fmpq_afe(acb_t res, const fmpq_t s, const dirichlet_group_t G, const dirichlet_char_t chi, slong prec) # Computes `L(s,\chi)` where *s* is a rational number. # The *afe* version uses the approximate functional equation; # the default version chooses an algorithm automatically. - void acb_dirichlet_l_vec_hurwitz(acb_ptr res, const acb_t s, const acb_dirichlet_hurwitz_precomp_t precomp, const dirichlet_group_t G, long prec) + void acb_dirichlet_l_vec_hurwitz(acb_ptr res, const acb_t s, const acb_dirichlet_hurwitz_precomp_t precomp, const dirichlet_group_t G, slong prec) # Compute all values `L(s,\chi)` for `\chi` mod `q`, using the # Hurwitz zeta function and a discrete Fourier transform. # The output *res* is assumed to have length *G->phi_q* and values @@ -326,7 +326,7 @@ cdef extern from "flint_wrap.h": # directly. If a pre-initialized *precomp* object is provided, this will be # used instead to evaluate the Hurwitz zeta function. - void acb_dirichlet_l_jet(acb_ptr res, const acb_t s, const dirichlet_group_t G, const dirichlet_char_t chi, int deflate, long len, long prec) + void acb_dirichlet_l_jet(acb_ptr res, const acb_t s, const dirichlet_group_t G, const dirichlet_char_t chi, int deflate, slong len, slong prec) # Computes the Taylor expansion of `L(s,\chi)` to length *len*, # i.e. `L(s), L'(s), \ldots, L^{(len-1)}(s) / (len-1)!`. # If *deflate* is set, computes the expansion of @@ -338,13 +338,13 @@ cdef extern from "flint_wrap.h": # gives the regular part of the Laurent expansion. # When *chi* is non-principal, *deflate* has no effect. - void _acb_dirichlet_l_series(acb_ptr res, acb_srcptr s, long slen, const dirichlet_group_t G, const dirichlet_char_t chi, int deflate, long len, long prec) + void _acb_dirichlet_l_series(acb_ptr res, acb_srcptr s, slong slen, const dirichlet_group_t G, const dirichlet_char_t chi, int deflate, slong len, slong prec) - void acb_dirichlet_l_series(acb_poly_t res, const acb_poly_t s, const dirichlet_group_t G, const dirichlet_char_t chi, int deflate, long len, long prec) + void acb_dirichlet_l_series(acb_poly_t res, const acb_poly_t s, const dirichlet_group_t G, const dirichlet_char_t chi, int deflate, slong len, slong prec) # Sets *res* to the power series `L(s,\chi)` where *s* is a given power series, truncating the result to length *len*. # See :func:`acb_dirichlet_l_jet` for the meaning of the *deflate* flag. - void acb_dirichlet_hardy_theta(acb_ptr res, const acb_t t, const dirichlet_group_t G, const dirichlet_char_t chi, long len, long prec) + void acb_dirichlet_hardy_theta(acb_ptr res, const acb_t t, const dirichlet_group_t G, const dirichlet_char_t chi, slong len, slong prec) # Computes the phase function used to construct the Z-function. # We have # .. math :: @@ -354,28 +354,28 @@ cdef extern from "flint_wrap.h": # is the root number as computed by :func:`acb_dirichlet_root_number`. # The first *len* terms in the Taylor expansion are written to the output. - void acb_dirichlet_hardy_z(acb_ptr res, const acb_t t, const dirichlet_group_t G, const dirichlet_char_t chi, long len, long prec) + void acb_dirichlet_hardy_z(acb_ptr res, const acb_t t, const dirichlet_group_t G, const dirichlet_char_t chi, slong len, slong prec) # Computes the Hardy Z-function, also known as the Riemann-Siegel Z-function # `Z(t) = e^{i \theta(t)} L(1/2+it)`, which is real-valued for real *t*. # The first *len* terms in the Taylor expansion are written to the output. - void _acb_dirichlet_hardy_theta_series(acb_ptr res, acb_srcptr t, long tlen, const dirichlet_group_t G, const dirichlet_char_t chi, long len, long prec) + void _acb_dirichlet_hardy_theta_series(acb_ptr res, acb_srcptr t, slong tlen, const dirichlet_group_t G, const dirichlet_char_t chi, slong len, slong prec) - void acb_dirichlet_hardy_theta_series(acb_poly_t res, const acb_poly_t t, const dirichlet_group_t G, const dirichlet_char_t chi, long len, long prec) + void acb_dirichlet_hardy_theta_series(acb_poly_t res, const acb_poly_t t, const dirichlet_group_t G, const dirichlet_char_t chi, slong len, slong prec) # Sets *res* to the power series `\theta(t)` where *t* is a given power series, truncating the result to length *len*. - void _acb_dirichlet_hardy_z_series(acb_ptr res, acb_srcptr t, long tlen, const dirichlet_group_t G, const dirichlet_char_t chi, long len, long prec) + void _acb_dirichlet_hardy_z_series(acb_ptr res, acb_srcptr t, slong tlen, const dirichlet_group_t G, const dirichlet_char_t chi, slong len, slong prec) - void acb_dirichlet_hardy_z_series(acb_poly_t res, const acb_poly_t t, const dirichlet_group_t G, const dirichlet_char_t chi, long len, long prec) + void acb_dirichlet_hardy_z_series(acb_poly_t res, const acb_poly_t t, const dirichlet_group_t G, const dirichlet_char_t chi, slong len, slong prec) # Sets *res* to the power series `Z(t)` where *t* is a given power series, truncating the result to length *len*. - void acb_dirichlet_gram_point(arb_t res, const fmpz_t n, const dirichlet_group_t G, const dirichlet_char_t chi, long prec) + void acb_dirichlet_gram_point(arb_t res, const fmpz_t n, const dirichlet_group_t G, const dirichlet_char_t chi, slong prec) # Sets *res* to the *n*-th Gram point `g_n`, defined as the unique solution # in `[7, \infty)` of `\theta(g_n) = \pi n`. Currently only the Gram points # corresponding to the Riemann zeta function are supported and *G* and *chi* # must both be set to *NULL*. Requires `n \ge -1`. - unsigned long acb_dirichlet_turing_method_bound(const fmpz_t p) + ulong acb_dirichlet_turing_method_bound(const fmpz_t p) # Computes an upper bound *B* for the minimum number of consecutive good # Gram blocks sufficient to count nontrivial zeros of the Riemann zeta # function using Turing's method [Tur1953]_ as updated by [Leh1970]_, @@ -385,7 +385,7 @@ cdef extern from "flint_wrap.h": # If at least *B* consecutive Gram blocks with union `[g_n, g_p)` # satisfy Rosser's rule, then `N(g_n) \le n + 1` and `N(g_p) \ge p + 1`. - int _acb_dirichlet_definite_hardy_z(arb_t res, const arf_t t, long * pprec) + int _acb_dirichlet_definite_hardy_z(arb_t res, const arf_t t, slong * pprec) # Sets *res* to the Hardy Z-function `Z(t)`. # The initial precision (* *pprec*) is increased as necessary # to determine the sign of `Z(t)`. The sign is returned. @@ -410,31 +410,31 @@ cdef extern from "flint_wrap.h": # Hardy Z-function and contains no other zero, using the most appropriate # underscore version of this function. Requires `n \ge 1`. - void _acb_dirichlet_refine_hardy_z_zero(arb_t res, const arf_t a, const arf_t b, long prec) + void _acb_dirichlet_refine_hardy_z_zero(arb_t res, const arf_t a, const arf_t b, slong prec) # Sets *res* to the unique zero of the Hardy Z-function in the # interval `(a, b)`. - void acb_dirichlet_hardy_z_zero(arb_t res, const fmpz_t n, long prec) + void acb_dirichlet_hardy_z_zero(arb_t res, const fmpz_t n, slong prec) # Sets *res* to the *n*-th zero of the Hardy Z-function, requiring `n \ge 1`. - void acb_dirichlet_hardy_z_zeros(arb_ptr res, const fmpz_t n, long len, long prec) + void acb_dirichlet_hardy_z_zeros(arb_ptr res, const fmpz_t n, slong len, slong prec) # Sets the entries of *res* to *len* consecutive zeros of the # Hardy Z-function, beginning with the *n*-th zero. Requires positive *n*. - void acb_dirichlet_zeta_zero(acb_t res, const fmpz_t n, long prec) + void acb_dirichlet_zeta_zero(acb_t res, const fmpz_t n, slong prec) # Sets *res* to the *n*-th nontrivial zero of `\zeta(s)`, requiring `n \ge 1`. - void acb_dirichlet_zeta_zeros(acb_ptr res, const fmpz_t n, long len, long prec) + void acb_dirichlet_zeta_zeros(acb_ptr res, const fmpz_t n, slong len, slong prec) # Sets the entries of *res* to *len* consecutive nontrivial zeros of `\zeta(s)` # beginning with the *n*-th zero. Requires positive *n*. void _acb_dirichlet_exact_zeta_nzeros(fmpz_t res, const arf_t t) - void acb_dirichlet_zeta_nzeros(arb_t res, const arb_t t, long prec) + void acb_dirichlet_zeta_nzeros(arb_t res, const arb_t t, slong prec) # Compute the number of zeros (counted according to their multiplicities) # of `\zeta(s)` in the region `0 < \operatorname{Im}(s) \le t`. - void acb_dirichlet_backlund_s(arb_t res, const arb_t t, long prec) + void acb_dirichlet_backlund_s(arb_t res, const arb_t t, slong prec) # Compute `S(t) = \frac{1}{\pi}\operatorname{arg}\zeta(\frac{1}{2} + it)` # where the argument is defined by continuous variation of `s` in `\zeta(s)` # starting at `s = 2`, then vertically to `s = 2 + it`, then horizontally @@ -455,10 +455,10 @@ cdef extern from "flint_wrap.h": # `0 < \operatorname{Im}(s) \le g_n` where `g_n` is the *n*-th Gram point. # Requires `n \ge -1`. - long acb_dirichlet_backlund_s_gram(const fmpz_t n) + slong acb_dirichlet_backlund_s_gram(const fmpz_t n) # Compute `S(g_n)` where `g_n` is the *n*-th Gram point. Requires `n \ge -1`. - void acb_dirichlet_platt_scaled_lambda(arb_t res, const arb_t t, long prec) + void acb_dirichlet_platt_scaled_lambda(arb_t res, const arb_t t, slong prec) # Compute `\Lambda(t) e^{\pi t/4}` where # .. math :: # \Lambda(t) = \pi^{-\frac{it}{2}} @@ -469,11 +469,11 @@ cdef extern from "flint_wrap.h": # real-valued by the functional equation, and the exponential factor is # designed to counteract the decay of the gamma factor as `t` increases. - void acb_dirichlet_platt_scaled_lambda_vec(arb_ptr res, const fmpz_t T, long A, long B, long prec) + void acb_dirichlet_platt_scaled_lambda_vec(arb_ptr res, const fmpz_t T, slong A, slong B, slong prec) - void acb_dirichlet_platt_multieval(arb_ptr res, const fmpz_t T, long A, long B, const arb_t h, const fmpz_t J, long K, long sigma, long prec) + void acb_dirichlet_platt_multieval(arb_ptr res, const fmpz_t T, slong A, slong B, const arb_t h, const fmpz_t J, slong K, slong sigma, slong prec) - void acb_dirichlet_platt_multieval_threaded(arb_ptr res, const fmpz_t T, long A, long B, const arb_t h, const fmpz_t J, long K, long sigma, long prec) + void acb_dirichlet_platt_multieval_threaded(arb_ptr res, const fmpz_t T, slong A, slong B, const arb_t h, const fmpz_t J, slong K, slong sigma, slong prec) # Compute :func:`acb_dirichlet_platt_scaled_lambda` at `N=AB` points on a # grid, following the notation of [Pla2017]_. The first point on the grid # is `T - B/2` and the distance between grid points is `1/A`. The product @@ -485,7 +485,7 @@ cdef extern from "flint_wrap.h": # *flint_get_num_threads()*, while the default multieval version chooses # whether to use multithreading automatically. - void acb_dirichlet_platt_ws_interpolation(arb_t res, arf_t deriv, const arb_t t0, arb_srcptr p, const fmpz_t T, long A, long B, long Ns_max, const arb_t H, long sigma, long prec) + void acb_dirichlet_platt_ws_interpolation(arb_t res, arf_t deriv, const arb_t t0, arb_srcptr p, const fmpz_t T, slong A, slong B, slong Ns_max, const arb_t H, slong sigma, slong prec) # Compute :func:`acb_dirichlet_platt_scaled_lambda` at *t0* by # Gaussian-windowed Whittaker-Shannon interpolation of points evaluated by # :func:`acb_dirichlet_platt_scaled_lambda_vec`. The derivative is @@ -496,11 +496,11 @@ cdef extern from "flint_wrap.h": # interpolation. *sigma* is an odd positive integer tuning parameter # `\sigma \in 2\mathbb{Z}_{>0}+1` used in computing error bounds. - long _acb_dirichlet_platt_local_hardy_z_zeros(arb_ptr res, const fmpz_t n, long len, const fmpz_t T, long A, long B, const arb_t h, const fmpz_t J, long K, long sigma_grid, long Ns_max, const arb_t H, long sigma_interp, long prec) + slong _acb_dirichlet_platt_local_hardy_z_zeros(arb_ptr res, const fmpz_t n, slong len, const fmpz_t T, slong A, slong B, const arb_t h, const fmpz_t J, slong K, slong sigma_grid, slong Ns_max, const arb_t H, slong sigma_interp, slong prec) - long acb_dirichlet_platt_local_hardy_z_zeros(arb_ptr res, const fmpz_t n, long len, long prec) + slong acb_dirichlet_platt_local_hardy_z_zeros(arb_ptr res, const fmpz_t n, slong len, slong prec) - long acb_dirichlet_platt_hardy_z_zeros(arb_ptr res, const fmpz_t n, long len, long prec) + slong acb_dirichlet_platt_hardy_z_zeros(arb_ptr res, const fmpz_t n, slong len, slong prec) # Sets at most the first *len* entries of *res* to consecutive # zeros of the Hardy Z-function starting with the *n*-th zero. # The number of obtained consecutive zeros is returned. The first two @@ -513,7 +513,7 @@ cdef extern from "flint_wrap.h": # variants currently expect `10^4 \leq n \leq 10^{23}`. The user has the # option of multi-threading through *flint_set_num_threads(numthreads)*. - long acb_dirichlet_platt_zeta_zeros(acb_ptr res, const fmpz_t n, long len, long prec) + slong acb_dirichlet_platt_zeta_zeros(acb_ptr res, const fmpz_t n, slong len, slong prec) # Sets at most the first *len* entries of *res* to consecutive # zeros of the Riemann zeta function starting with the *n*-th zero. # The number of obtained consecutive zeros is returned. It currently diff --git a/src/sage/libs/flint/acb_elliptic.pxd b/src/sage/libs/flint/acb_elliptic.pxd index b6b9de27d3a..6424ab675a5 100644 --- a/src/sage/libs/flint/acb_elliptic.pxd +++ b/src/sage/libs/flint/acb_elliptic.pxd @@ -12,7 +12,7 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void acb_elliptic_k(acb_t res, const acb_t m, long prec) + void acb_elliptic_k(acb_t res, const acb_t m, slong prec) # Computes the complete elliptic integral of the first kind # .. math :: # K(m) = \int_0^{\pi/2} \frac{dt}{\sqrt{1-m \sin^2 t}} @@ -20,18 +20,18 @@ cdef extern from "flint_wrap.h": # \frac{dt}{\left(\sqrt{1-t^2}\right)\left(\sqrt{1-mt^2}\right)} # using the arithmetic-geometric mean: `K(m) = \pi / (2 M(\sqrt{1-m}))`. - void acb_elliptic_k_jet(acb_ptr res, const acb_t m, long len, long prec) + void acb_elliptic_k_jet(acb_ptr res, const acb_t m, slong len, slong prec) # Sets the coefficients in the array *res* to the power series expansion of the # complete elliptic integral of the first kind at the point *m* truncated to # length *len*, i.e. `K(m+x) \in \mathbb{C}[[x]]`. - void _acb_elliptic_k_series(acb_ptr res, acb_srcptr m, long mlen, long len, long prec) + void _acb_elliptic_k_series(acb_ptr res, acb_srcptr m, slong mlen, slong len, slong prec) - void acb_elliptic_k_series(acb_poly_t res, const acb_poly_t m, long len, long prec) + void acb_elliptic_k_series(acb_poly_t res, const acb_poly_t m, slong len, slong prec) # Sets *res* to the complete elliptic integral of the first kind of the # power series *m*, truncated to length *len*. - void acb_elliptic_e(acb_t res, const acb_t m, long prec) + void acb_elliptic_e(acb_t res, const acb_t m, slong prec) # Computes the complete elliptic integral of the second kind # .. math :: # E(m) = \int_0^{\pi/2} \sqrt{1-m \sin^2 t} \, dt = @@ -40,7 +40,7 @@ cdef extern from "flint_wrap.h": # using `E(m) = (1-m)(2m K'(m) + K(m))` (where the prime # denotes a derivative, not a complementary integral). - void acb_elliptic_pi(acb_t res, const acb_t n, const acb_t m, long prec) + void acb_elliptic_pi(acb_t res, const acb_t n, const acb_t m, slong prec) # Evaluates the complete elliptic integral of the third kind # .. math :: # \Pi(n, m) = \int_0^{\pi/2} @@ -51,7 +51,7 @@ cdef extern from "flint_wrap.h": # incomplete integral. It is therefore less efficient than the implementations # of the first two complete elliptic integrals which use the AGM. - void acb_elliptic_f(acb_t res, const acb_t phi, const acb_t m, int pi, long prec) + void acb_elliptic_f(acb_t res, const acb_t phi, const acb_t m, int pi, slong prec) # Evaluates the Legendre incomplete elliptic integral of the first kind, # given by # .. math :: @@ -70,7 +70,7 @@ cdef extern from "flint_wrap.h": # when `\phi = \frac{\pi}{2}`; that is, # `F\left(\frac{\pi}{2}, m\right) = K(m)`. - void acb_elliptic_e_inc(acb_t res, const acb_t phi, const acb_t m, int pi, long prec) + void acb_elliptic_e_inc(acb_t res, const acb_t phi, const acb_t m, int pi, slong prec) # Evaluates the Legendre incomplete elliptic integral of the second kind, # given by # .. math :: @@ -89,7 +89,7 @@ cdef extern from "flint_wrap.h": # when `\phi = \frac{\pi}{2}`; that is, # `E\left(\frac{\pi}{2}, m\right) = E(m)`. - void acb_elliptic_pi_inc(acb_t res, const acb_t n, const acb_t phi, const acb_t m, int pi, long prec) + void acb_elliptic_pi_inc(acb_t res, const acb_t n, const acb_t phi, const acb_t m, int pi, slong prec) # Evaluates the Legendre incomplete elliptic integral of the third kind, # given by # .. math :: @@ -109,7 +109,7 @@ cdef extern from "flint_wrap.h": # when `\phi = \frac{\pi}{2}`; that is, # `\Pi\left(n, \frac{\pi}{2}, m\right) = \Pi(n, m)`. - void acb_elliptic_rf(acb_t res, const acb_t x, const acb_t y, const acb_t z, int flags, long prec) + void acb_elliptic_rf(acb_t res, const acb_t x, const acb_t y, const acb_t z, int flags, slong prec) # Evaluates the Carlson symmetric elliptic integral of the first kind # .. math :: # R_F(x,y,z) = \frac{1}{2} @@ -129,7 +129,7 @@ cdef extern from "flint_wrap.h": # The *flags* parameter is reserved for future use and currently # does nothing. Passing 0 results in default behavior. - void acb_elliptic_rg(acb_t res, const acb_t x, const acb_t y, const acb_t z, int flags, long prec) + void acb_elliptic_rg(acb_t res, const acb_t x, const acb_t y, const acb_t z, int flags, slong prec) # Evaluates the Carlson symmetric elliptic integral of the second kind # .. math :: # R_G(x,y,z) = \frac{1}{4} \int_0^{\infty} @@ -139,11 +139,11 @@ cdef extern from "flint_wrap.h": # The evaluation is done by expressing `R_G` in terms of `R_F` and `R_D`. # There are no restrictions on the variables. - void acb_elliptic_rj(acb_t res, const acb_t x, const acb_t y, const acb_t z, const acb_t p, int flags, long prec) + void acb_elliptic_rj(acb_t res, const acb_t x, const acb_t y, const acb_t z, const acb_t p, int flags, slong prec) - void acb_elliptic_rj_carlson(acb_t res, const acb_t x, const acb_t y, const acb_t z, const acb_t p, int flags, long prec) + void acb_elliptic_rj_carlson(acb_t res, const acb_t x, const acb_t y, const acb_t z, const acb_t p, int flags, slong prec) - void acb_elliptic_rj_integration(acb_t res, const acb_t x, const acb_t y, const acb_t z, const acb_t p, int flags, long prec) + void acb_elliptic_rj_integration(acb_t res, const acb_t x, const acb_t y, const acb_t z, const acb_t p, int flags, slong prec) # Evaluates the Carlson symmetric elliptic integral of the third kind # .. math :: # R_J(x,y,z,p) = \frac{3}{2} @@ -175,12 +175,12 @@ cdef extern from "flint_wrap.h": # The *flags* parameter is reserved for future use and currently # does nothing. Passing 0 results in default behavior. - void acb_elliptic_rc1(acb_t res, const acb_t x, long prec) + void acb_elliptic_rc1(acb_t res, const acb_t x, slong prec) # This helper function computes the special case # `R_C(1, 1+x) = \operatorname{atan}(\sqrt{x})/\sqrt{x} = {}_2F_1(1,1/2,3/2,-x)`, # which is needed in the evaluation of `R_J`. - void acb_elliptic_p(acb_t res, const acb_t z, const acb_t tau, long prec) + void acb_elliptic_p(acb_t res, const acb_t z, const acb_t tau, slong prec) # Computes Weierstrass's elliptic function # .. math :: # \wp(z, \tau) = \frac{1}{z^2} + \sum_{n^2+m^2 \ne 0} @@ -192,33 +192,33 @@ cdef extern from "flint_wrap.h": # \frac{\theta_4^2(z,\tau)}{\theta_1^2(z,\tau)} - # \frac{\pi^2}{3} \left[ \theta_2^4(0,\tau) + \theta_3^4(0,\tau)\right]. - void acb_elliptic_p_prime(acb_t res, const acb_t z, const acb_t tau, long prec) + void acb_elliptic_p_prime(acb_t res, const acb_t z, const acb_t tau, slong prec) # Computes the derivative `\wp'(z, \tau)` of Weierstrass's elliptic function `\wp(z, \tau)`. - void acb_elliptic_p_jet(acb_ptr res, const acb_t z, const acb_t tau, long len, long prec) + void acb_elliptic_p_jet(acb_ptr res, const acb_t z, const acb_t tau, slong len, slong prec) # Computes the formal power series `\wp(z + x, \tau) \in \mathbb{C}[[x]]`, # truncated to length *len*. In particular, with *len* = 2, simultaneously # computes `\wp(z, \tau), \wp'(z, \tau)` which together generate # the field of elliptic functions with periods 1 and `\tau`. - void _acb_elliptic_p_series(acb_ptr res, acb_srcptr z, long zlen, const acb_t tau, long len, long prec) + void _acb_elliptic_p_series(acb_ptr res, acb_srcptr z, slong zlen, const acb_t tau, slong len, slong prec) - void acb_elliptic_p_series(acb_poly_t res, const acb_poly_t z, const acb_t tau, long len, long prec) + void acb_elliptic_p_series(acb_poly_t res, const acb_poly_t z, const acb_t tau, slong len, slong prec) # Sets *res* to the Weierstrass elliptic function of the power series *z*, # with periods 1 and *tau*, truncated to length *len*. - void acb_elliptic_invariants(acb_t g2, acb_t g3, const acb_t tau, long prec) + void acb_elliptic_invariants(acb_t g2, acb_t g3, const acb_t tau, slong prec) # Computes the lattice invariants `g_2, g_3`. The Weierstrass elliptic # function satisfies the differential equation # `[\wp'(z, \tau)]^2 = 4 [\wp(z,\tau)]^3 - g_2 \wp(z,\tau) - g_3`. # Up to constant factors, the lattice invariants are the first two # Eisenstein series (see :func:`acb_modular_eisenstein`). - void acb_elliptic_roots(acb_t e1, acb_t e2, acb_t e3, const acb_t tau, long prec) + void acb_elliptic_roots(acb_t e1, acb_t e2, acb_t e3, const acb_t tau, slong prec) # Computes the lattice roots `e_1, e_2, e_3`, which are the roots of # the polynomial `4z^3 - g_2 z - g_3`. - void acb_elliptic_inv_p(acb_t res, const acb_t z, const acb_t tau, long prec) + void acb_elliptic_inv_p(acb_t res, const acb_t z, const acb_t tau, slong prec) # Computes the inverse of the Weierstrass elliptic function, which # satisfies `\wp(\wp^{-1}(z, \tau), \tau) = z`. This function is given # by the elliptic integral @@ -226,7 +226,7 @@ cdef extern from "flint_wrap.h": # \wp^{-1}(z, \tau) = \frac{1}{2} \int_z^{\infty} \frac{dt}{\sqrt{(t-e_1)(t-e_2)(t-e_3)}} # = R_F(z-e_1,z-e_2,z-e_3). - void acb_elliptic_zeta(acb_t res, const acb_t z, const acb_t tau, long prec) + void acb_elliptic_zeta(acb_t res, const acb_t z, const acb_t tau, slong prec) # Computes the Weierstrass zeta function # .. math :: # \zeta(z, \tau) = \frac{1}{z} + \sum_{n^2+m^2 \ne 0} @@ -234,7 +234,7 @@ cdef extern from "flint_wrap.h": # which is quasiperiodic with `\zeta(z + 1, \tau) = \zeta(z, \tau) + \zeta(1/2, \tau)` # and `\zeta(z + \tau, \tau) = \zeta(z, \tau) + \zeta(\tau/2, \tau)`. - void acb_elliptic_sigma(acb_t res, const acb_t z, const acb_t tau, long prec) + void acb_elliptic_sigma(acb_t res, const acb_t z, const acb_t tau, slong prec) # Computes the Weierstrass sigma function # .. math :: # \sigma(z, \tau) = z \prod_{n^2+m^2 \ne 0} diff --git a/src/sage/libs/flint/acb_hypgeom.pxd b/src/sage/libs/flint/acb_hypgeom.pxd index 8f0ff458438..23335f58407 100644 --- a/src/sage/libs/flint/acb_hypgeom.pxd +++ b/src/sage/libs/flint/acb_hypgeom.pxd @@ -12,12 +12,12 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void acb_hypgeom_rising_ui_forward(acb_t res, const acb_t x, unsigned long n, long prec) - void acb_hypgeom_rising_ui_bs(acb_t res, const acb_t x, unsigned long n, long prec) - void acb_hypgeom_rising_ui_rs(acb_t res, const acb_t x, unsigned long n, unsigned long m, long prec) - void acb_hypgeom_rising_ui_rec(acb_t res, const acb_t x, unsigned long n, long prec) - void acb_hypgeom_rising_ui(acb_t res, const acb_t x, unsigned long n, long prec) - void acb_hypgeom_rising(acb_t res, const acb_t x, const acb_t n, long prec) + void acb_hypgeom_rising_ui_forward(acb_t res, const acb_t x, ulong n, slong prec) + void acb_hypgeom_rising_ui_bs(acb_t res, const acb_t x, ulong n, slong prec) + void acb_hypgeom_rising_ui_rs(acb_t res, const acb_t x, ulong n, ulong m, slong prec) + void acb_hypgeom_rising_ui_rec(acb_t res, const acb_t x, ulong n, slong prec) + void acb_hypgeom_rising_ui(acb_t res, const acb_t x, ulong n, slong prec) + void acb_hypgeom_rising(acb_t res, const acb_t x, const acb_t n, slong prec) # Computes the rising factorial `(x)_n`. # The *forward* version uses the forward recurrence. # The *bs* version uses binary splitting. @@ -29,10 +29,10 @@ cdef extern from "flint_wrap.h": # The default versions (*rising_ui* and *rising_ui*) choose an algorithm # automatically and may additionally fall back on the gamma function. - void acb_hypgeom_rising_ui_jet_powsum(acb_ptr res, const acb_t x, unsigned long n, long len, long prec) - void acb_hypgeom_rising_ui_jet_bs(acb_ptr res, const acb_t x, unsigned long n, long len, long prec) - void acb_hypgeom_rising_ui_jet_rs(acb_ptr res, const acb_t x, unsigned long n, unsigned long m, long len, long prec) - void acb_hypgeom_rising_ui_jet(acb_ptr res, const acb_t x, unsigned long n, long len, long prec) + void acb_hypgeom_rising_ui_jet_powsum(acb_ptr res, const acb_t x, ulong n, slong len, slong prec) + void acb_hypgeom_rising_ui_jet_bs(acb_ptr res, const acb_t x, ulong n, slong len, slong prec) + void acb_hypgeom_rising_ui_jet_rs(acb_ptr res, const acb_t x, ulong n, ulong m, slong len, slong prec) + void acb_hypgeom_rising_ui_jet(acb_ptr res, const acb_t x, ulong n, slong len, slong prec) # Computes the jet of the rising factorial `(x)_n`, truncated to length *len*. # In other words, constructs the polynomial `(X + x)_n \in \mathbb{R}[X]`, # truncated if `\operatorname{len} < n + 1` (and zero-extended @@ -44,7 +44,7 @@ cdef extern from "flint_wrap.h": # parameter *m* which can be set to zero to choose automatically. # The default version chooses an algorithm automatically. - void acb_hypgeom_log_rising_ui(acb_ptr res, const acb_t x, unsigned long n, long prec) + void acb_hypgeom_log_rising_ui(acb_ptr res, const acb_t x, ulong n, slong prec) # Computes the log-rising factorial `\log \, (x)_n = \sum_{k=0}^{n-1} \log(x+k)`. # This first computes the ordinary rising factorial and then determines # the branch correction `2 \pi i m` with respect to the principal @@ -52,12 +52,12 @@ cdef extern from "flint_wrap.h": # floating-point arithmetic if this is safe; otherwise, # a direct computation of `\sum_{k=0}^{n-1} \arg(x+k)` is used as a fallback. - void acb_hypgeom_log_rising_ui_jet(acb_ptr res, const acb_t x, unsigned long n, long len, long prec) + void acb_hypgeom_log_rising_ui_jet(acb_ptr res, const acb_t x, ulong n, slong len, slong prec) # Computes the jet of the log-rising factorial `\log \, (x)_n`, # truncated to length *len*. - void acb_hypgeom_gamma_stirling_sum_horner(acb_t s, const acb_t z, long N, long prec) - void acb_hypgeom_gamma_stirling_sum_improved(acb_t s, const acb_t z, long N, long K, long prec) + void acb_hypgeom_gamma_stirling_sum_horner(acb_t s, const acb_t z, slong N, slong prec) + void acb_hypgeom_gamma_stirling_sum_improved(acb_t s, const acb_t z, slong N, slong K, slong prec) # Sets *res* to the final sum in the Stirling series for the gamma function # truncated before the term with index *N*, i.e. computes # `\sum_{n=1}^{N-1} B_{2n} / (2n(2n-1) z^{2n-1})`. @@ -67,38 +67,38 @@ cdef extern from "flint_wrap.h": # using a splitting parameter *K* (which can be set to 0 to use a default # value). - void acb_hypgeom_gamma_stirling(acb_t res, const acb_t x, int reciprocal, long prec) + void acb_hypgeom_gamma_stirling(acb_t res, const acb_t x, int reciprocal, slong prec) # Sets *res* to the gamma function of *x* computed using the Stirling # series together with argument reduction. If *reciprocal* is set, # the reciprocal gamma function is computed instead. - int acb_hypgeom_gamma_taylor(acb_t res, const acb_t x, int reciprocal, long prec) + int acb_hypgeom_gamma_taylor(acb_t res, const acb_t x, int reciprocal, slong prec) # Attempts to compute the gamma function of *x* using Taylor series # together with argument reduction. This is only supported if *x* and *prec* # are both small enough. If successful, returns 1; otherwise, does nothing # and returns 0. If *reciprocal* is set, the reciprocal gamma function is # computed instead. - void acb_hypgeom_gamma(acb_t res, const acb_t x, long prec) + void acb_hypgeom_gamma(acb_t res, const acb_t x, slong prec) # Sets *res* to the gamma function of *x* computed using a default # algorithm choice. - void acb_hypgeom_rgamma(acb_t res, const acb_t x, long prec) + void acb_hypgeom_rgamma(acb_t res, const acb_t x, slong prec) # Sets *res* to the reciprocal gamma function of *x* computed using a default # algorithm choice. - void acb_hypgeom_lgamma(acb_t res, const acb_t x, long prec) + void acb_hypgeom_lgamma(acb_t res, const acb_t x, slong prec) # Sets *res* to the principal branch of the log-gamma function of *x* # computed using a default algorithm choice. - void acb_hypgeom_pfq_bound_factor(mag_t C, acb_srcptr a, long p, acb_srcptr b, long q, const acb_t z, unsigned long n) + void acb_hypgeom_pfq_bound_factor(mag_t C, acb_srcptr a, slong p, acb_srcptr b, slong q, const acb_t z, ulong n) # Computes a factor *C* such that # `\left|\sum_{k=n}^{\infty} T(k)\right| \le C |T(n)|`. # See :ref:`algorithms_hypergeometric_convergent`. # As currently implemented, the bound becomes infinite when `n` is # too small, even if the series converges. - long acb_hypgeom_pfq_choose_n(acb_srcptr a, long p, acb_srcptr b, long q, const acb_t z, long prec) + slong acb_hypgeom_pfq_choose_n(acb_srcptr a, slong p, acb_srcptr b, slong q, const acb_t z, slong prec) # Heuristically attempts to choose a number of terms *n* to # sum of a hypergeometric series at a working precision of *prec* bits. # Uses double precision arithmetic internally. As currently implemented, @@ -110,15 +110,15 @@ cdef extern from "flint_wrap.h": # This function will also attempt to pick a reasonable # truncation point for divergent series. - void acb_hypgeom_pfq_sum_forward(acb_t s, acb_t t, acb_srcptr a, long p, acb_srcptr b, long q, const acb_t z, long n, long prec) + void acb_hypgeom_pfq_sum_forward(acb_t s, acb_t t, acb_srcptr a, slong p, acb_srcptr b, slong q, const acb_t z, slong n, slong prec) - void acb_hypgeom_pfq_sum_rs(acb_t s, acb_t t, acb_srcptr a, long p, acb_srcptr b, long q, const acb_t z, long n, long prec) + void acb_hypgeom_pfq_sum_rs(acb_t s, acb_t t, acb_srcptr a, slong p, acb_srcptr b, slong q, const acb_t z, slong n, slong prec) - void acb_hypgeom_pfq_sum_bs(acb_t s, acb_t t, acb_srcptr a, long p, acb_srcptr b, long q, const acb_t z, long n, long prec) + void acb_hypgeom_pfq_sum_bs(acb_t s, acb_t t, acb_srcptr a, slong p, acb_srcptr b, slong q, const acb_t z, slong n, slong prec) - void acb_hypgeom_pfq_sum_fme(acb_t s, acb_t t, acb_srcptr a, long p, acb_srcptr b, long q, const acb_t z, long n, long prec) + void acb_hypgeom_pfq_sum_fme(acb_t s, acb_t t, acb_srcptr a, slong p, acb_srcptr b, slong q, const acb_t z, slong n, slong prec) - void acb_hypgeom_pfq_sum(acb_t s, acb_t t, acb_srcptr a, long p, acb_srcptr b, long q, const acb_t z, long n, long prec) + void acb_hypgeom_pfq_sum(acb_t s, acb_t t, acb_srcptr a, slong p, acb_srcptr b, slong q, const acb_t z, slong n, slong prec) # Computes `s = \sum_{k=0}^{n-1} T(k)` and `t = T(n)`. # Does not allow aliasing between input and output variables. # We require `n \ge 0`. @@ -132,13 +132,13 @@ cdef extern from "flint_wrap.h": # The default version automatically chooses an algorithm # depending on the inputs. - void acb_hypgeom_pfq_sum_bs_invz(acb_t s, acb_t t, acb_srcptr a, long p, acb_srcptr b, long q, const acb_t w, long n, long prec) + void acb_hypgeom_pfq_sum_bs_invz(acb_t s, acb_t t, acb_srcptr a, slong p, acb_srcptr b, slong q, const acb_t w, slong n, slong prec) - void acb_hypgeom_pfq_sum_invz(acb_t s, acb_t t, acb_srcptr a, long p, acb_srcptr b, long q, const acb_t z, const acb_t w, long n, long prec) + void acb_hypgeom_pfq_sum_invz(acb_t s, acb_t t, acb_srcptr a, slong p, acb_srcptr b, slong q, const acb_t z, const acb_t w, slong n, slong prec) # Like :func:`acb_hypgeom_pfq_sum`, but taking advantage of # `w = 1/z` possibly having few bits. - void acb_hypgeom_pfq_direct(acb_t res, acb_srcptr a, long p, acb_srcptr b, long q, const acb_t z, long n, long prec) + void acb_hypgeom_pfq_direct(acb_t res, acb_srcptr a, slong p, acb_srcptr b, slong q, const acb_t z, slong n, slong prec) # Computes # .. math :: # {}_pf_{q}(z) @@ -149,13 +149,13 @@ cdef extern from "flint_wrap.h": # If `n < 0`, this function chooses a number of terms automatically # using :func:`acb_hypgeom_pfq_choose_n`. - void acb_hypgeom_pfq_series_sum_forward(acb_poly_t s, acb_poly_t t, const acb_poly_struct * a, long p, const acb_poly_struct * b, long q, const acb_poly_t z, int regularized, long n, long len, long prec) + void acb_hypgeom_pfq_series_sum_forward(acb_poly_t s, acb_poly_t t, const acb_poly_struct * a, slong p, const acb_poly_struct * b, slong q, const acb_poly_t z, int regularized, slong n, slong len, slong prec) - void acb_hypgeom_pfq_series_sum_bs(acb_poly_t s, acb_poly_t t, const acb_poly_struct * a, long p, const acb_poly_struct * b, long q, const acb_poly_t z, int regularized, long n, long len, long prec) + void acb_hypgeom_pfq_series_sum_bs(acb_poly_t s, acb_poly_t t, const acb_poly_struct * a, slong p, const acb_poly_struct * b, slong q, const acb_poly_t z, int regularized, slong n, slong len, slong prec) - void acb_hypgeom_pfq_series_sum_rs(acb_poly_t s, acb_poly_t t, const acb_poly_struct * a, long p, const acb_poly_struct * b, long q, const acb_poly_t z, int regularized, long n, long len, long prec) + void acb_hypgeom_pfq_series_sum_rs(acb_poly_t s, acb_poly_t t, const acb_poly_struct * a, slong p, const acb_poly_struct * b, slong q, const acb_poly_t z, int regularized, slong n, slong len, slong prec) - void acb_hypgeom_pfq_series_sum(acb_poly_t s, acb_poly_t t, const acb_poly_struct * a, long p, const acb_poly_struct * b, long q, const acb_poly_t z, int regularized, long n, long len, long prec) + void acb_hypgeom_pfq_series_sum(acb_poly_t s, acb_poly_t t, const acb_poly_struct * a, slong p, const acb_poly_struct * b, slong q, const acb_poly_t z, int regularized, slong n, slong len, slong prec) # Computes `s = \sum_{k=0}^{n-1} T(k)` and `t = T(n)` given parameters # and argument that are power series. # Does not allow aliasing between input and output variables. @@ -166,7 +166,7 @@ cdef extern from "flint_wrap.h": # binary splitting, rectangular splitting, and an automatic algorithm # choice. - void acb_hypgeom_pfq_series_direct(acb_poly_t res, const acb_poly_struct * a, long p, const acb_poly_struct * b, long q, const acb_poly_t z, int regularized, long n, long len, long prec) + void acb_hypgeom_pfq_series_direct(acb_poly_t res, const acb_poly_struct * a, slong p, const acb_poly_struct * b, slong q, const acb_poly_t z, int regularized, slong n, slong len, slong prec) # Computes `{}_pf_{q}(z)` directly using the defining series, given # parameters and argument that are power series. # The result is a power series of length *len*. @@ -177,17 +177,17 @@ cdef extern from "flint_wrap.h": # If *regularized* is set, the regularized hypergeometric function # is computed instead. - void acb_hypgeom_u_asymp(acb_t res, const acb_t a, const acb_t b, const acb_t z, long n, long prec) + void acb_hypgeom_u_asymp(acb_t res, const acb_t a, const acb_t b, const acb_t z, slong n, slong prec) # Sets *res* to `U^{*}(a,b,z)` computed using *n* terms of the asymptotic series, # with a rigorous bound for the error included in the output. # We require `n \ge 0`. - int acb_hypgeom_u_use_asymp(const acb_t z, long prec) + int acb_hypgeom_u_use_asymp(const acb_t z, slong prec) # Heuristically determines whether the asymptotic series can be used # to evaluate `U(a,b,z)` to *prec* accurate bits (assuming that *a* and *b* # are small). - void acb_hypgeom_pfq(acb_t res, acb_srcptr a, long p, acb_srcptr b, long q, const acb_t z, int regularized, long prec) + void acb_hypgeom_pfq(acb_t res, acb_srcptr a, slong p, acb_srcptr b, slong q, const acb_t z, int regularized, slong prec) # Computes the generalized hypergeometric function `{}_pF_{q}(z)`, # or the regularized version if *regularized* is set. # This function automatically delegates to a specialized implementation @@ -199,7 +199,7 @@ cdef extern from "flint_wrap.h": # done ahead of time by the user in applications where duplicate # parameters are likely to occur. - void acb_hypgeom_u_1f1_series(acb_poly_t res, const acb_poly_t a, const acb_poly_t b, const acb_poly_t z, long len, long prec) + void acb_hypgeom_u_1f1_series(acb_poly_t res, const acb_poly_t a, const acb_poly_t b, const acb_poly_t z, slong len, slong prec) # Computes `U(a,b,z)` as a power series truncated to length *len*, # given `a, b, z \in \mathbb{C}[[x]]`. # If `b[0] \in \mathbb{Z}`, it computes one extra derivative and removes @@ -207,38 +207,38 @@ cdef extern from "flint_wrap.h": # As currently implemented, the output is indeterminate if `b` is nonexact # and contains an integer. - void acb_hypgeom_u_1f1(acb_t res, const acb_t a, const acb_t b, const acb_t z, long prec) + void acb_hypgeom_u_1f1(acb_t res, const acb_t a, const acb_t b, const acb_t z, slong prec) # Computes `U(a,b,z)` as a sum of two convergent hypergeometric series. # If `b \in \mathbb{Z}`, it computes # the limit value via :func:`acb_hypgeom_u_1f1_series`. # As currently implemented, the output is indeterminate if `b` is nonexact # and contains an integer. - void acb_hypgeom_u(acb_t res, const acb_t a, const acb_t b, const acb_t z, long prec) + void acb_hypgeom_u(acb_t res, const acb_t a, const acb_t b, const acb_t z, slong prec) # Computes `U(a,b,z)` using an automatic algorithm choice. The # function :func:`acb_hypgeom_u_asymp` is used # if `a` or `a-b+1` is a nonpositive integer (in which # case the asymptotic series terminates), or if *z* is sufficiently large. # Otherwise :func:`acb_hypgeom_u_1f1` is used. - void acb_hypgeom_m_asymp(acb_t res, const acb_t a, const acb_t b, const acb_t z, int regularized, long prec) + void acb_hypgeom_m_asymp(acb_t res, const acb_t a, const acb_t b, const acb_t z, int regularized, slong prec) - void acb_hypgeom_m_1f1(acb_t res, const acb_t a, const acb_t b, const acb_t z, int regularized, long prec) + void acb_hypgeom_m_1f1(acb_t res, const acb_t a, const acb_t b, const acb_t z, int regularized, slong prec) - void acb_hypgeom_m(acb_t res, const acb_t a, const acb_t b, const acb_t z, int regularized, long prec) + void acb_hypgeom_m(acb_t res, const acb_t a, const acb_t b, const acb_t z, int regularized, slong prec) # Computes the confluent hypergeometric function # `M(a,b,z) = {}_1F_1(a,b,z)`, or # `\mathbf{M}(a,b,z) = \frac{1}{\Gamma(b)} {}_1F_1(a,b,z)` if *regularized* # is set. - void acb_hypgeom_1f1(acb_t res, const acb_t a, const acb_t b, const acb_t z, int regularized, long prec) + void acb_hypgeom_1f1(acb_t res, const acb_t a, const acb_t b, const acb_t z, int regularized, slong prec) # Alias for :func:`acb_hypgeom_m`. - void acb_hypgeom_0f1_asymp(acb_t res, const acb_t a, const acb_t z, int regularized, long prec) + void acb_hypgeom_0f1_asymp(acb_t res, const acb_t a, const acb_t z, int regularized, slong prec) - void acb_hypgeom_0f1_direct(acb_t res, const acb_t a, const acb_t z, int regularized, long prec) + void acb_hypgeom_0f1_direct(acb_t res, const acb_t a, const acb_t z, int regularized, slong prec) - void acb_hypgeom_0f1(acb_t res, const acb_t a, const acb_t z, int regularized, long prec) + void acb_hypgeom_0f1(acb_t res, const acb_t a, const acb_t z, int regularized, slong prec) # Computes the confluent hypergeometric function # `{}_0F_1(a,z)`, or `\frac{1}{\Gamma(a)} {}_0F_1(a,z)` if *regularized* # is set, using asymptotic expansions, direct summation, @@ -258,11 +258,11 @@ cdef extern from "flint_wrap.h": # the error function evaluated at the midpoint of *z*. Uses # the first derivative. - void acb_hypgeom_erf_1f1a(acb_t res, const acb_t z, long prec) + void acb_hypgeom_erf_1f1a(acb_t res, const acb_t z, slong prec) - void acb_hypgeom_erf_1f1b(acb_t res, const acb_t z, long prec) + void acb_hypgeom_erf_1f1b(acb_t res, const acb_t z, slong prec) - void acb_hypgeom_erf_asymp(acb_t res, const acb_t z, int complementary, long prec, long prec2) + void acb_hypgeom_erf_asymp(acb_t res, const acb_t z, int complementary, slong prec, slong prec2) # Computes the error function respectively using # .. math :: # \operatorname{erf}(z) &= \frac{2z}{\sqrt{\pi}} @@ -278,42 +278,42 @@ cdef extern from "flint_wrap.h": # It also takes an extra flag *complementary*, computing the complementary # error function if set. - void acb_hypgeom_erf(acb_t res, const acb_t z, long prec) + void acb_hypgeom_erf(acb_t res, const acb_t z, slong prec) # Computes the error function using an automatic algorithm choice. # If *z* is too small to use the asymptotic expansion, a working precision # sufficient to circumvent cancellation in the hypergeometric series is # determined automatically, and a bound for the propagated error is # computed with :func:`acb_hypgeom_erf_propagated_error`. - void _acb_hypgeom_erf_series(acb_ptr res, acb_srcptr z, long zlen, long len, long prec) + void _acb_hypgeom_erf_series(acb_ptr res, acb_srcptr z, slong zlen, slong len, slong prec) - void acb_hypgeom_erf_series(acb_poly_t res, const acb_poly_t z, long len, long prec) + void acb_hypgeom_erf_series(acb_poly_t res, const acb_poly_t z, slong len, slong prec) # Computes the error function of the power series *z*, # truncated to length *len*. - void acb_hypgeom_erfc(acb_t res, const acb_t z, long prec) + void acb_hypgeom_erfc(acb_t res, const acb_t z, slong prec) # Computes the complementary error function # `\operatorname{erfc}(z) = 1 - \operatorname{erf}(z)`. # This function avoids catastrophic cancellation for large positive *z*. - void _acb_hypgeom_erfc_series(acb_ptr res, acb_srcptr z, long zlen, long len, long prec) + void _acb_hypgeom_erfc_series(acb_ptr res, acb_srcptr z, slong zlen, slong len, slong prec) - void acb_hypgeom_erfc_series(acb_poly_t res, const acb_poly_t z, long len, long prec) + void acb_hypgeom_erfc_series(acb_poly_t res, const acb_poly_t z, slong len, slong prec) # Computes the complementary error function of the power series *z*, # truncated to length *len*. - void acb_hypgeom_erfi(acb_t res, const acb_t z, long prec) + void acb_hypgeom_erfi(acb_t res, const acb_t z, slong prec) # Computes the imaginary error function # `\operatorname{erfi}(z) = -i\operatorname{erf}(iz)`. This is a trivial wrapper # of :func:`acb_hypgeom_erf`. - void _acb_hypgeom_erfi_series(acb_ptr res, acb_srcptr z, long zlen, long len, long prec) + void _acb_hypgeom_erfi_series(acb_ptr res, acb_srcptr z, slong zlen, slong len, slong prec) - void acb_hypgeom_erfi_series(acb_poly_t res, const acb_poly_t z, long len, long prec) + void acb_hypgeom_erfi_series(acb_poly_t res, const acb_poly_t z, slong len, slong prec) # Computes the imaginary error function of the power series *z*, # truncated to length *len*. - void acb_hypgeom_fresnel(acb_t res1, acb_t res2, const acb_t z, int normalized, long prec) + void acb_hypgeom_fresnel(acb_t res1, acb_t res2, const acb_t z, int normalized, slong prec) # Sets *res1* to the Fresnel sine integral `S(z)` and *res2* to # the Fresnel cosine integral `C(z)`. Optionally, just a single function # can be computed by passing *NULL* as the other output variable. @@ -322,15 +322,15 @@ cdef extern from "flint_wrap.h": # *normalized* is 1 (the latter is the Abramowitz & Stegun convention). # `C(z)` is defined analogously. - void _acb_hypgeom_fresnel_series(acb_ptr res1, acb_ptr res2, acb_srcptr z, long zlen, int normalized, long len, long prec) + void _acb_hypgeom_fresnel_series(acb_ptr res1, acb_ptr res2, acb_srcptr z, slong zlen, int normalized, slong len, slong prec) - void acb_hypgeom_fresnel_series(acb_poly_t res1, acb_poly_t res2, const acb_poly_t z, int normalized, long len, long prec) + void acb_hypgeom_fresnel_series(acb_poly_t res1, acb_poly_t res2, const acb_poly_t z, int normalized, slong len, slong prec) # Sets *res1* to the Fresnel sine integral and *res2* to the Fresnel # cosine integral of the power series *z*, truncated to length *len*. # Optionally, just a single function can be computed by passing *NULL* # as the other output variable. - void acb_hypgeom_bessel_j_asymp(acb_t res, const acb_t nu, const acb_t z, long prec) + void acb_hypgeom_bessel_j_asymp(acb_t res, const acb_t nu, const acb_t z, slong prec) # Computes the Bessel function of the first kind # via :func:`acb_hypgeom_u_asymp`. # For all complex `\nu, z`, we have @@ -347,17 +347,17 @@ cdef extern from "flint_wrap.h": # `A_{\pm} = (\pm i)^{n} (2 \pi z)^{-1/2}`. # And if `\operatorname{Re}(z) > 0`, we have `A_{\pm} = \exp(\mp i [(2\nu+1)/4] \pi) (2 \pi z)^{-1/2}`. - void acb_hypgeom_bessel_j_0f1(acb_t res, const acb_t nu, const acb_t z, long prec) + void acb_hypgeom_bessel_j_0f1(acb_t res, const acb_t nu, const acb_t z, slong prec) # Computes the Bessel function of the first kind from # .. math :: # J_{\nu}(z) = \frac{1}{\Gamma(\nu+1)} \left(\frac{z}{2}\right)^{\nu} # {}_0F_1\left(\nu+1, -\frac{z^2}{4}\right). - void acb_hypgeom_bessel_j(acb_t res, const acb_t nu, const acb_t z, long prec) + void acb_hypgeom_bessel_j(acb_t res, const acb_t nu, const acb_t z, slong prec) # Computes the Bessel function of the first kind `J_{\nu}(z)` using # an automatic algorithm choice. - void acb_hypgeom_bessel_y(acb_t res, const acb_t nu, const acb_t z, long prec) + void acb_hypgeom_bessel_y(acb_t res, const acb_t nu, const acb_t z, slong prec) # Computes the Bessel function of the second kind `Y_{\nu}(z)` from the # formula # .. math :: @@ -370,19 +370,19 @@ cdef extern from "flint_wrap.h": # As currently implemented, the output is indeterminate if `\nu` is nonexact # and contains an integer. - void acb_hypgeom_bessel_jy(acb_t res1, acb_t res2, const acb_t nu, const acb_t z, long prec) + void acb_hypgeom_bessel_jy(acb_t res1, acb_t res2, const acb_t nu, const acb_t z, slong prec) # Sets *res1* to `J_{\nu}(z)` and *res2* to `Y_{\nu}(z)`, computed # simultaneously. From these values, the user can easily # construct the Bessel functions of the third kind (Hankel functions) # `H_{\nu}^{(1)}(z), H_{\nu}^{(2)}(z) = J_{\nu}(z) \pm i Y_{\nu}(z)`. - void acb_hypgeom_bessel_i_asymp(acb_t res, const acb_t nu, const acb_t z, int scaled, long prec) + void acb_hypgeom_bessel_i_asymp(acb_t res, const acb_t nu, const acb_t z, int scaled, slong prec) - void acb_hypgeom_bessel_i_0f1(acb_t res, const acb_t nu, const acb_t z, int scaled, long prec) + void acb_hypgeom_bessel_i_0f1(acb_t res, const acb_t nu, const acb_t z, int scaled, slong prec) - void acb_hypgeom_bessel_i(acb_t res, const acb_t nu, const acb_t z, long prec) + void acb_hypgeom_bessel_i(acb_t res, const acb_t nu, const acb_t z, slong prec) - void acb_hypgeom_bessel_i_scaled(acb_t res, const acb_t nu, const acb_t z, long prec) + void acb_hypgeom_bessel_i_scaled(acb_t res, const acb_t nu, const acb_t z, slong prec) # Computes the modified Bessel function of the first kind # `I_{\nu}(z) = z^{\nu} (iz)^{-\nu} J_{\nu}(iz)` respectively using # asymptotic series (see :func:`acb_hypgeom_bessel_j_asymp`), @@ -394,7 +394,7 @@ cdef extern from "flint_wrap.h": # The *scaled* version computes the function `e^{-z} I_{\nu}(z)`. The *asymp* # and *0f1* functions implement both variants and allow choosing with a flag. - void acb_hypgeom_bessel_k_asymp(acb_t res, const acb_t nu, const acb_t z, int scaled, long prec) + void acb_hypgeom_bessel_k_asymp(acb_t res, const acb_t nu, const acb_t z, int scaled, slong prec) # Computes the modified Bessel function of the second kind via # via :func:`acb_hypgeom_u_asymp`. For all `\nu` and all `z \ne 0`, we have # .. math :: @@ -402,7 +402,7 @@ cdef extern from "flint_wrap.h": # U^{*}(\nu+\tfrac{1}{2}, 2\nu+1, 2z). # If *scaled* is set, computes the function `e^{z} K_{\nu}(z)`. - void acb_hypgeom_bessel_k_0f1_series(acb_poly_t res, const acb_poly_t nu, const acb_poly_t z, int scaled, long len, long prec) + void acb_hypgeom_bessel_k_0f1_series(acb_poly_t res, const acb_poly_t nu, const acb_poly_t z, int scaled, slong len, slong prec) # Computes the modified Bessel function of the second kind `K_{\nu}(z)` # as a power series truncated to length *len*, # given `\nu, z \in \mathbb{C}[[x]]`. Uses the formula @@ -420,7 +420,7 @@ cdef extern from "flint_wrap.h": # and contains an integer. # If *scaled* is set, computes the function `e^{z} K_{\nu}(z)`. - void acb_hypgeom_bessel_k_0f1(acb_t res, const acb_t nu, const acb_t z, int scaled, long prec) + void acb_hypgeom_bessel_k_0f1(acb_t res, const acb_t nu, const acb_t z, int scaled, slong prec) # Computes the modified Bessel function of the second kind from # .. math :: # K_{\nu}(z) = \frac{1}{2} \left[ @@ -438,18 +438,18 @@ cdef extern from "flint_wrap.h": # and contains an integer. # If *scaled* is set, computes the function `e^{z} K_{\nu}(z)`. - void acb_hypgeom_bessel_k(acb_t res, const acb_t nu, const acb_t z, long prec) + void acb_hypgeom_bessel_k(acb_t res, const acb_t nu, const acb_t z, slong prec) # Computes the modified Bessel function of the second kind `K_{\nu}(z)` using # an automatic algorithm choice. - void acb_hypgeom_bessel_k_scaled(acb_t res, const acb_t nu, const acb_t z, long prec) + void acb_hypgeom_bessel_k_scaled(acb_t res, const acb_t nu, const acb_t z, slong prec) # Computes the function `e^{z} K_{\nu}(z)`. - void acb_hypgeom_airy_direct(acb_t ai, acb_t ai_prime, acb_t bi, acb_t bi_prime, const acb_t z, long n, long prec) + void acb_hypgeom_airy_direct(acb_t ai, acb_t ai_prime, acb_t bi, acb_t bi_prime, const acb_t z, slong n, slong prec) # Computes the Airy functions using direct series expansions truncated at *n* terms. # Error bounds are included in the output. - void acb_hypgeom_airy_asymp(acb_t ai, acb_t ai_prime, acb_t bi, acb_t bi_prime, const acb_t z, long n, long prec) + void acb_hypgeom_airy_asymp(acb_t ai, acb_t ai_prime, acb_t bi, acb_t bi_prime, const acb_t z, slong n, slong prec) # Computes the Airy functions using asymptotic expansions truncated at *n* terms. # Error bounds are included in the output. # For details about how the error bounds are computed, see @@ -461,7 +461,7 @@ cdef extern from "flint_wrap.h": # shortcuts to make it slightly faster than calling # :func:`acb_hypgeom_airy_asymp` with `n = 1`. - void acb_hypgeom_airy(acb_t ai, acb_t ai_prime, acb_t bi, acb_t bi_prime, const acb_t z, long prec) + void acb_hypgeom_airy(acb_t ai, acb_t ai_prime, acb_t bi, acb_t bi_prime, const acb_t z, slong prec) # Computes Airy functions using an automatic algorithm choice. # We use :func:`acb_hypgeom_airy_asymp` whenever this gives full accuracy # and :func:`acb_hypgeom_airy_direct` otherwise. @@ -476,7 +476,7 @@ cdef extern from "flint_wrap.h": # bound the propagated error using derivatives. Derivatives are # bounded using :func:`acb_hypgeom_airy_bound`. - void acb_hypgeom_airy_jet(acb_ptr ai, acb_ptr bi, const acb_t z, long len, long prec) + void acb_hypgeom_airy_jet(acb_ptr ai, acb_ptr bi, const acb_t z, slong len, slong prec) # Writes to *ai* and *bi* the respective Taylor expansions of the Airy functions # at the point *z*, truncated to length *len*. # Either of the outputs can be *NULL* to avoid computing that function. @@ -486,37 +486,37 @@ cdef extern from "flint_wrap.h": # easily obtained by computing one extra coefficient and differentiating # the output with :func:`_acb_poly_derivative`. - void _acb_hypgeom_airy_series(acb_ptr ai, acb_ptr ai_prime, acb_ptr bi, acb_ptr bi_prime, acb_srcptr z, long zlen, long len, long prec) + void _acb_hypgeom_airy_series(acb_ptr ai, acb_ptr ai_prime, acb_ptr bi, acb_ptr bi_prime, acb_srcptr z, slong zlen, slong len, slong prec) - void acb_hypgeom_airy_series(acb_poly_t ai, acb_poly_t ai_prime, acb_poly_t bi, acb_poly_t bi_prime, const acb_poly_t z, long len, long prec) + void acb_hypgeom_airy_series(acb_poly_t ai, acb_poly_t ai_prime, acb_poly_t bi, acb_poly_t bi_prime, const acb_poly_t z, slong len, slong prec) # Computes the Airy functions evaluated at the power series *z*, # truncated to length *len*. As with the other Airy methods, any of the # outputs can be *NULL*. - void acb_hypgeom_coulomb(acb_t F, acb_t G, acb_t Hpos, acb_t Hneg, const acb_t l, const acb_t eta, const acb_t z, long prec) + void acb_hypgeom_coulomb(acb_t F, acb_t G, acb_t Hpos, acb_t Hneg, const acb_t l, const acb_t eta, const acb_t z, slong prec) # Writes to *F*, *G*, *Hpos*, *Hneg* the values of the respective # Coulomb wave functions. Any of the outputs can be *NULL*. - void acb_hypgeom_coulomb_jet(acb_ptr F, acb_ptr G, acb_ptr Hpos, acb_ptr Hneg, const acb_t l, const acb_t eta, const acb_t z, long len, long prec) + void acb_hypgeom_coulomb_jet(acb_ptr F, acb_ptr G, acb_ptr Hpos, acb_ptr Hneg, const acb_t l, const acb_t eta, const acb_t z, slong len, slong prec) # Writes to *F*, *G*, *Hpos*, *Hneg* the respective Taylor expansions of the # Coulomb wave functions at the point *z*, truncated to length *len*. # Any of the outputs can be *NULL*. - void _acb_hypgeom_coulomb_series(acb_ptr F, acb_ptr G, acb_ptr Hpos, acb_ptr Hneg, const acb_t l, const acb_t eta, acb_srcptr z, long zlen, long len, long prec) + void _acb_hypgeom_coulomb_series(acb_ptr F, acb_ptr G, acb_ptr Hpos, acb_ptr Hneg, const acb_t l, const acb_t eta, acb_srcptr z, slong zlen, slong len, slong prec) - void acb_hypgeom_coulomb_series(acb_poly_t F, acb_poly_t G, acb_poly_t Hpos, acb_poly_t Hneg, const acb_t l, const acb_t eta, const acb_poly_t z, long len, long prec) + void acb_hypgeom_coulomb_series(acb_poly_t F, acb_poly_t G, acb_poly_t Hpos, acb_poly_t Hneg, const acb_t l, const acb_t eta, const acb_poly_t z, slong len, slong prec) # Computes the Coulomb wave functions evaluated at the power series *z*, # truncated to length *len*. Any of the outputs can be *NULL*. - void acb_hypgeom_gamma_upper_asymp(acb_t res, const acb_t s, const acb_t z, int regularized, long prec) + void acb_hypgeom_gamma_upper_asymp(acb_t res, const acb_t s, const acb_t z, int regularized, slong prec) - void acb_hypgeom_gamma_upper_1f1a(acb_t res, const acb_t s, const acb_t z, int regularized, long prec) + void acb_hypgeom_gamma_upper_1f1a(acb_t res, const acb_t s, const acb_t z, int regularized, slong prec) - void acb_hypgeom_gamma_upper_1f1b(acb_t res, const acb_t s, const acb_t z, int regularized, long prec) + void acb_hypgeom_gamma_upper_1f1b(acb_t res, const acb_t s, const acb_t z, int regularized, slong prec) - void acb_hypgeom_gamma_upper_singular(acb_t res, long s, const acb_t z, int regularized, long prec) + void acb_hypgeom_gamma_upper_singular(acb_t res, slong s, const acb_t z, int regularized, slong prec) - void acb_hypgeom_gamma_upper(acb_t res, const acb_t s, const acb_t z, int regularized, long prec) + void acb_hypgeom_gamma_upper(acb_t res, const acb_t s, const acb_t z, int regularized, slong prec) # If *regularized* is 0, computes the upper incomplete gamma function # `\Gamma(s,z)`. # If *regularized* is 1, computes the regularized upper incomplete @@ -542,15 +542,15 @@ cdef extern from "flint_wrap.h": # The *singular* version evaluates the finite sum directly and therefore # assumes that *s* is not too large. - void _acb_hypgeom_gamma_upper_series(acb_ptr res, const acb_t s, acb_srcptr z, long zlen, int regularized, long n, long prec) + void _acb_hypgeom_gamma_upper_series(acb_ptr res, const acb_t s, acb_srcptr z, slong zlen, int regularized, slong n, slong prec) - void acb_hypgeom_gamma_upper_series(acb_poly_t res, const acb_t s, const acb_poly_t z, int regularized, long n, long prec) + void acb_hypgeom_gamma_upper_series(acb_poly_t res, const acb_t s, const acb_poly_t z, int regularized, slong n, slong prec) # Sets *res* to an upper incomplete gamma function where *s* is # a constant and *z* is a power series, truncated to length *n*. # The *regularized* argument has the same interpretation as in # :func:`acb_hypgeom_gamma_upper`. - void acb_hypgeom_gamma_lower(acb_t res, const acb_t s, const acb_t z, int regularized, long prec) + void acb_hypgeom_gamma_lower(acb_t res, const acb_t s, const acb_t z, int regularized, slong prec) # If *regularized* is 0, computes the lower incomplete gamma function # `\gamma(s,z) = \frac{z^s}{s} {}_1F_1(s, s+1, -z)`. # If *regularized* is 1, computes the regularized lower incomplete @@ -558,15 +558,15 @@ cdef extern from "flint_wrap.h": # If *regularized* is 2, computes a further regularized lower incomplete # gamma function `\gamma^{*}(s,z) = z^{-s} P(s,z)`. - void _acb_hypgeom_gamma_lower_series(acb_ptr res, const acb_t s, acb_srcptr z, long zlen, int regularized, long n, long prec) + void _acb_hypgeom_gamma_lower_series(acb_ptr res, const acb_t s, acb_srcptr z, slong zlen, int regularized, slong n, slong prec) - void acb_hypgeom_gamma_lower_series(acb_poly_t res, const acb_t s, const acb_poly_t z, int regularized, long n, long prec) + void acb_hypgeom_gamma_lower_series(acb_poly_t res, const acb_t s, const acb_poly_t z, int regularized, slong n, slong prec) # Sets *res* to an lower incomplete gamma function where *s* is # a constant and *z* is a power series, truncated to length *n*. # The *regularized* argument has the same interpretation as in # :func:`acb_hypgeom_gamma_lower`. - void acb_hypgeom_beta_lower(acb_t res, const acb_t a, const acb_t b, const acb_t z, int regularized, long prec) + void acb_hypgeom_beta_lower(acb_t res, const acb_t a, const acb_t b, const acb_t z, int regularized, slong prec) # Computes the (lower) incomplete beta function, defined by # `B(a,b;z) = \int_0^z t^{a-1} (1-t)^{b-1}`, # optionally the regularized incomplete beta function @@ -581,24 +581,24 @@ cdef extern from "flint_wrap.h": # for nonpositive integer *a*, and *I* is undefined for nonpositive integer # `a + b`. - void _acb_hypgeom_beta_lower_series(acb_ptr res, const acb_t a, const acb_t b, acb_srcptr z, long zlen, int regularized, long n, long prec) + void _acb_hypgeom_beta_lower_series(acb_ptr res, const acb_t a, const acb_t b, acb_srcptr z, slong zlen, int regularized, slong n, slong prec) - void acb_hypgeom_beta_lower_series(acb_poly_t res, const acb_t a, const acb_t b, const acb_poly_t z, int regularized, long n, long prec) + void acb_hypgeom_beta_lower_series(acb_poly_t res, const acb_t a, const acb_t b, const acb_poly_t z, int regularized, slong n, slong prec) # Sets *res* to the lower incomplete beta function `B(a,b;z)` (optionally # the regularized version `I(a,b;z)`) where *a* and *b* are constants # and *z* is a power series, truncating the result to length *n*. # The underscore method requires positive lengths and does not support # aliasing. - void acb_hypgeom_expint(acb_t res, const acb_t s, const acb_t z, long prec) + void acb_hypgeom_expint(acb_t res, const acb_t s, const acb_t z, slong prec) # Computes the generalized exponential integral `E_s(z)`. This is a # trivial wrapper of :func:`acb_hypgeom_gamma_upper`. - void acb_hypgeom_ei_asymp(acb_t res, const acb_t z, long prec) + void acb_hypgeom_ei_asymp(acb_t res, const acb_t z, slong prec) - void acb_hypgeom_ei_2f2(acb_t res, const acb_t z, long prec) + void acb_hypgeom_ei_2f2(acb_t res, const acb_t z, slong prec) - void acb_hypgeom_ei(acb_t res, const acb_t z, long prec) + void acb_hypgeom_ei(acb_t res, const acb_t z, slong prec) # Computes the exponential integral `\operatorname{Ei}(z)`, respectively # using # .. math :: @@ -609,17 +609,17 @@ cdef extern from "flint_wrap.h": # + \frac{1}{2} \left(\log(z) - \log\left(\frac{1}{z}\right) \right) # and an automatic algorithm choice. - void _acb_hypgeom_ei_series(acb_ptr res, acb_srcptr z, long zlen, long len, long prec) + void _acb_hypgeom_ei_series(acb_ptr res, acb_srcptr z, slong zlen, slong len, slong prec) - void acb_hypgeom_ei_series(acb_poly_t res, const acb_poly_t z, long len, long prec) + void acb_hypgeom_ei_series(acb_poly_t res, const acb_poly_t z, slong len, slong prec) # Computes the exponential integral of the power series *z*, # truncated to length *len*. - void acb_hypgeom_si_asymp(acb_t res, const acb_t z, long prec) + void acb_hypgeom_si_asymp(acb_t res, const acb_t z, slong prec) - void acb_hypgeom_si_1f2(acb_t res, const acb_t z, long prec) + void acb_hypgeom_si_1f2(acb_t res, const acb_t z, slong prec) - void acb_hypgeom_si(acb_t res, const acb_t z, long prec) + void acb_hypgeom_si(acb_t res, const acb_t z, slong prec) # Computes the sine integral `\operatorname{Si}(z)`, respectively # using # .. math :: @@ -630,17 +630,17 @@ cdef extern from "flint_wrap.h": # \operatorname{Si}(z) = z {}_1F_2(\tfrac{1}{2}; \tfrac{3}{2}, \tfrac{3}{2}; -\tfrac{z^2}{4}) # and an automatic algorithm choice. - void _acb_hypgeom_si_series(acb_ptr res, acb_srcptr z, long zlen, long len, long prec) + void _acb_hypgeom_si_series(acb_ptr res, acb_srcptr z, slong zlen, slong len, slong prec) - void acb_hypgeom_si_series(acb_poly_t res, const acb_poly_t z, long len, long prec) + void acb_hypgeom_si_series(acb_poly_t res, const acb_poly_t z, slong len, slong prec) # Computes the sine integral of the power series *z*, # truncated to length *len*. - void acb_hypgeom_ci_asymp(acb_t res, const acb_t z, long prec) + void acb_hypgeom_ci_asymp(acb_t res, const acb_t z, slong prec) - void acb_hypgeom_ci_2f3(acb_t res, const acb_t z, long prec) + void acb_hypgeom_ci_2f3(acb_t res, const acb_t z, slong prec) - void acb_hypgeom_ci(acb_t res, const acb_t z, long prec) + void acb_hypgeom_ci(acb_t res, const acb_t z, slong prec) # Computes the cosine integral `\operatorname{Ci}(z)`, respectively # using # .. math :: @@ -653,28 +653,28 @@ cdef extern from "flint_wrap.h": # + \log(z) + \gamma # and an automatic algorithm choice. - void _acb_hypgeom_ci_series(acb_ptr res, acb_srcptr z, long zlen, long len, long prec) + void _acb_hypgeom_ci_series(acb_ptr res, acb_srcptr z, slong zlen, slong len, slong prec) - void acb_hypgeom_ci_series(acb_poly_t res, const acb_poly_t z, long len, long prec) + void acb_hypgeom_ci_series(acb_poly_t res, const acb_poly_t z, slong len, slong prec) # Computes the cosine integral of the power series *z*, # truncated to length *len*. - void acb_hypgeom_shi(acb_t res, const acb_t z, long prec) + void acb_hypgeom_shi(acb_t res, const acb_t z, slong prec) # Computes the hyperbolic sine integral # `\operatorname{Shi}(z) = -i \operatorname{Si}(iz)`. # This is a trivial wrapper of :func:`acb_hypgeom_si`. - void _acb_hypgeom_shi_series(acb_ptr res, acb_srcptr z, long zlen, long len, long prec) + void _acb_hypgeom_shi_series(acb_ptr res, acb_srcptr z, slong zlen, slong len, slong prec) - void acb_hypgeom_shi_series(acb_poly_t res, const acb_poly_t z, long len, long prec) + void acb_hypgeom_shi_series(acb_poly_t res, const acb_poly_t z, slong len, slong prec) # Computes the hyperbolic sine integral of the power series *z*, # truncated to length *len*. - void acb_hypgeom_chi_asymp(acb_t res, const acb_t z, long prec) + void acb_hypgeom_chi_asymp(acb_t res, const acb_t z, slong prec) - void acb_hypgeom_chi_2f3(acb_t res, const acb_t z, long prec) + void acb_hypgeom_chi_2f3(acb_t res, const acb_t z, slong prec) - void acb_hypgeom_chi(acb_t res, const acb_t z, long prec) + void acb_hypgeom_chi(acb_t res, const acb_t z, slong prec) # Computes the hyperbolic cosine integral `\operatorname{Chi}(z)`, respectively # using # .. math :: @@ -687,39 +687,39 @@ cdef extern from "flint_wrap.h": # + \log(z) + \gamma # and an automatic algorithm choice. - void _acb_hypgeom_chi_series(acb_ptr res, acb_srcptr z, long zlen, long len, long prec) + void _acb_hypgeom_chi_series(acb_ptr res, acb_srcptr z, slong zlen, slong len, slong prec) - void acb_hypgeom_chi_series(acb_poly_t res, const acb_poly_t z, long len, long prec) + void acb_hypgeom_chi_series(acb_poly_t res, const acb_poly_t z, slong len, slong prec) # Computes the hyperbolic cosine integral of the power series *z*, # truncated to length *len*. - void acb_hypgeom_li(acb_t res, const acb_t z, int offset, long prec) + void acb_hypgeom_li(acb_t res, const acb_t z, int offset, slong prec) # If *offset* is zero, computes the logarithmic integral # `\operatorname{li}(z) = \operatorname{Ei}(\log(z))`. # If *offset* is nonzero, computes the offset logarithmic integral # `\operatorname{Li}(z) = \operatorname{li}(z) - \operatorname{li}(2)`. - void _acb_hypgeom_li_series(acb_ptr res, acb_srcptr z, long zlen, int offset, long len, long prec) + void _acb_hypgeom_li_series(acb_ptr res, acb_srcptr z, slong zlen, int offset, slong len, slong prec) - void acb_hypgeom_li_series(acb_poly_t res, const acb_poly_t z, int offset, long len, long prec) + void acb_hypgeom_li_series(acb_poly_t res, const acb_poly_t z, int offset, slong len, slong prec) # Computes the logarithmic integral (optionally the offset version) # of the power series *z*, truncated to length *len*. - void acb_hypgeom_2f1_continuation(acb_t res0, acb_t res1, const acb_t a, const acb_t b, const acb_t c, const acb_t z0, const acb_t z1, const acb_t f0, const acb_t f1, long prec) + void acb_hypgeom_2f1_continuation(acb_t res0, acb_t res1, const acb_t a, const acb_t b, const acb_t c, const acb_t z0, const acb_t z1, const acb_t f0, const acb_t f1, slong prec) # Given `F(z_0), F'(z_0)` in *f0*, *f1*, sets *res0* and *res1* to `F(z_1), F'(z_1)` # by integrating the hypergeometric differential equation along a straight-line path. # The evaluation points should be well-isolated from the singular points 0 and 1. - void acb_hypgeom_2f1_series_direct(acb_poly_t res, const acb_poly_t a, const acb_poly_t b, const acb_poly_t c, const acb_poly_t z, int regularized, long len, long prec) + void acb_hypgeom_2f1_series_direct(acb_poly_t res, const acb_poly_t a, const acb_poly_t b, const acb_poly_t c, const acb_poly_t z, int regularized, slong len, slong prec) # Computes `F(z)` of the given power series truncated to length *len*, using # direct summation of the hypergeometric series. - void acb_hypgeom_2f1_direct(acb_t res, const acb_t a, const acb_t b, const acb_t c, const acb_t z, int regularized, long prec) + void acb_hypgeom_2f1_direct(acb_t res, const acb_t a, const acb_t b, const acb_t c, const acb_t z, int regularized, slong prec) # Computes `F(z)` using direct summation of the hypergeometric series. - void acb_hypgeom_2f1_transform(acb_t res, const acb_t a, const acb_t b, const acb_t c, const acb_t z, int flags, int which, long prec) + void acb_hypgeom_2f1_transform(acb_t res, const acb_t a, const acb_t b, const acb_t c, const acb_t z, int flags, int which, slong prec) - void acb_hypgeom_2f1_transform_limit(acb_t res, const acb_t a, const acb_t b, const acb_t c, const acb_t z, int regularized, int which, long prec) + void acb_hypgeom_2f1_transform_limit(acb_t res, const acb_t a, const acb_t b, const acb_t c, const acb_t z, int regularized, int which, slong prec) # Computes `F(z)` using an argument transformation determined by the flag *which*. # Legal values are 1 for `z/(z-1)`, # 2 for `1/z`, 3 for `1/(1-z)`, 4 for `1-z`, and 5 for `1-1/z`. @@ -729,7 +729,7 @@ cdef extern from "flint_wrap.h": # In these cases, it computes the correct limit value. # See :func:`acb_hypgeom_2f1` for the meaning of *flags*. - void acb_hypgeom_2f1_corner(acb_t res, const acb_t a, const acb_t b, const acb_t c, const acb_t z, int regularized, long prec) + void acb_hypgeom_2f1_corner(acb_t res, const acb_t a, const acb_t b, const acb_t c, const acb_t z, int regularized, slong prec) # Computes `F(z)` near the corner cases `\exp(\pm \pi i \sqrt{3})` # by analytic continuation. @@ -740,7 +740,7 @@ cdef extern from "flint_wrap.h": # :func:`acb_hypgeom_2f1_transform` should be used. # If the return value is 6, the corner case algorithm should be used. - void acb_hypgeom_2f1(acb_t res, const acb_t a, const acb_t b, const acb_t c, const acb_t z, int flags, long prec) + void acb_hypgeom_2f1(acb_t res, const acb_t a, const acb_t b, const acb_t c, const acb_t z, int flags, slong prec) # Computes `F(z)` or `\operatorname{\mathbf{F}}(z)` # using an automatic algorithm choice. # The following bit fields can be set in *flags*: @@ -764,9 +764,9 @@ cdef extern from "flint_wrap.h": # Currently, only the *AB* and *ABC* flags are used this way; # the *AC* and *BC* flags might be used in the future. - void acb_hypgeom_chebyshev_t(acb_t res, const acb_t n, const acb_t z, long prec) + void acb_hypgeom_chebyshev_t(acb_t res, const acb_t n, const acb_t z, slong prec) - void acb_hypgeom_chebyshev_u(acb_t res, const acb_t n, const acb_t z, long prec) + void acb_hypgeom_chebyshev_u(acb_t res, const acb_t n, const acb_t z, slong prec) # Computes the Chebyshev polynomial (or Chebyshev function) of first or second kind # .. math :: # T_n(z) = {}_2F_1\left(-n,n,\frac{1}{2},\frac{1-z}{2}\right) @@ -777,7 +777,7 @@ cdef extern from "flint_wrap.h": # For word-size integer *n*, :func:`acb_chebyshev_t_ui` and # :func:`acb_chebyshev_u_ui` are called. - void acb_hypgeom_jacobi_p(acb_t res, const acb_t n, const acb_t a, const acb_t b, const acb_t z, long prec) + void acb_hypgeom_jacobi_p(acb_t res, const acb_t n, const acb_t a, const acb_t b, const acb_t z, slong prec) # Computes the Jacobi polynomial (or Jacobi function) # .. math :: # P_n^{(a,b)}(z)=\frac{(a+1)_n}{\Gamma(n+1)} {}_2F_1\left(-n,n+a+b+1,a+1,\frac{1-z}{2}\right). @@ -786,7 +786,7 @@ cdef extern from "flint_wrap.h": # is undefined. In such cases, the polynomial is evaluated using # direct methods. - void acb_hypgeom_gegenbauer_c(acb_t res, const acb_t n, const acb_t m, const acb_t z, long prec) + void acb_hypgeom_gegenbauer_c(acb_t res, const acb_t n, const acb_t m, const acb_t z, slong prec) # Computes the Gegenbauer polynomial (or Gegenbauer function) # .. math :: # C_n^{m}(z)=\frac{(2m)_n}{\Gamma(n+1)} {}_2F_1\left(-n,2m+n,m+\frac{1}{2},\frac{1-z}{2}\right). @@ -795,7 +795,7 @@ cdef extern from "flint_wrap.h": # is undefined. In such cases, the polynomial is evaluated using # direct methods. - void acb_hypgeom_laguerre_l(acb_t res, const acb_t n, const acb_t m, const acb_t z, long prec) + void acb_hypgeom_laguerre_l(acb_t res, const acb_t n, const acb_t m, const acb_t z, slong prec) # Computes the Laguerre polynomial (or Laguerre function) # .. math :: # L_n^{m}(z)=\frac{(m+1)_n}{\Gamma(n+1)} {}_1F_1\left(-n,m+1,z\right). @@ -809,7 +809,7 @@ cdef extern from "flint_wrap.h": # case with the recurrence relation `L_{n-1}^m(z) + L_n^{m-1}(z) = L_n^m(z)`. # Currently, we leave this case undefined (returning indeterminate). - void acb_hypgeom_hermite_h(acb_t res, const acb_t n, const acb_t z, long prec) + void acb_hypgeom_hermite_h(acb_t res, const acb_t n, const acb_t z, slong prec) # Computes the Hermite polynomial (or Hermite function) # .. math :: # H_n(z) = 2^n \sqrt{\pi} \left( @@ -817,7 +817,7 @@ cdef extern from "flint_wrap.h": # - # \frac{2z}{\Gamma(-n/2)} {}_1F_1\left(\frac{1-n}{2},\frac{3}{2},z^2\right)\right). - void acb_hypgeom_legendre_p(acb_t res, const acb_t n, const acb_t m, const acb_t z, int type, long prec) + void acb_hypgeom_legendre_p(acb_t res, const acb_t n, const acb_t m, const acb_t z, int type, slong prec) # Sets *res* to the associated Legendre function of the first kind # evaluated for degree *n*, order *m*, and argument *z*. # When *m* is zero, this reduces to the Legendre polynomial `P_n(z)`. @@ -833,7 +833,7 @@ cdef extern from "flint_wrap.h": # is computed. Type 0 and type 1 respectively correspond to # type 2 and type 3 in *Mathematica* and *mpmath*. - void acb_hypgeom_legendre_q(acb_t res, const acb_t n, const acb_t m, const acb_t z, int type, long prec) + void acb_hypgeom_legendre_q(acb_t res, const acb_t n, const acb_t m, const acb_t z, int type, slong prec) # Sets *res* to the associated Legendre function of the second kind # evaluated for degree *n*, order *m*, and argument *z*. # When *m* is zero, this reduces to the Legendre function `Q_n(z)`. @@ -860,11 +860,11 @@ cdef extern from "flint_wrap.h": # .. [WQ3c] http://functions.wolfram.com/07.12.26.0003.01 # .. [WQ3d] http://functions.wolfram.com/07.12.26.0088.01 - void acb_hypgeom_legendre_p_uiui_rec(acb_t res, unsigned long n, unsigned long m, const acb_t z, long prec) + void acb_hypgeom_legendre_p_uiui_rec(acb_t res, ulong n, ulong m, const acb_t z, slong prec) # For nonnegative integer *n* and *m*, uses recurrence relations to evaluate # `(1-z^2)^{-m/2} P_n^m(z)` which is a polynomial in *z*. - void acb_hypgeom_spherical_y(acb_t res, long n, long m, const acb_t theta, const acb_t phi, long prec) + void acb_hypgeom_spherical_y(acb_t res, slong n, slong m, const acb_t theta, const acb_t phi, slong prec) # Computes the spherical harmonic of degree *n*, order *m*, # latitude angle *theta*, and longitude angle *phi*, normalized # such that @@ -874,15 +874,15 @@ cdef extern from "flint_wrap.h": # This function is a polynomial in `\cos(\theta)` and `\sin(\theta)`. # We evaluate it using :func:`acb_hypgeom_legendre_p_uiui_rec`. - void acb_hypgeom_dilog_zero_taylor(acb_t res, const acb_t z, long prec) + void acb_hypgeom_dilog_zero_taylor(acb_t res, const acb_t z, slong prec) # Computes the dilogarithm for *z* close to 0 using the hypergeometric series # (effective only when `|z| \ll 1`). - void acb_hypgeom_dilog_zero(acb_t res, const acb_t z, long prec) + void acb_hypgeom_dilog_zero(acb_t res, const acb_t z, slong prec) # Computes the dilogarithm for *z* close to 0, using the bit-burst algorithm # instead of the hypergeometric series directly at very high precision. - void acb_hypgeom_dilog_transform(acb_t res, const acb_t z, int algorithm, long prec) + void acb_hypgeom_dilog_transform(acb_t res, const acb_t z, int algorithm, slong prec) # Computes the dilogarithm by applying one of the transformations # `1/z`, `1-z`, `z/(z-1)`, `1/(1-z)`, indexed by *algorithm* from 1 to 4, # and calling :func:`acb_hypgeom_dilog_zero` with the reduced variable. @@ -891,7 +891,7 @@ cdef extern from "flint_wrap.h": # chosen according to the midpoint of *z*) # and computes the dilogarithm by the bit-burst method. - void acb_hypgeom_dilog_continuation(acb_t res, const acb_t a, const acb_t z, long prec) + void acb_hypgeom_dilog_continuation(acb_t res, const acb_t a, const acb_t z, slong prec) # Computes `\operatorname{Li}_2(z) - \operatorname{Li}_2(a)` using # Taylor expansion at *a*. Binary splitting is used. Both *a* and *z* # should be well isolated from the points 0 and 1, except that *a* may @@ -899,10 +899,10 @@ cdef extern from "flint_wrap.h": # cut, this method provides continuous analytic continuation instead of # computing the principal branch. - void acb_hypgeom_dilog_bitburst(acb_t res, acb_t z0, const acb_t z, long prec) + void acb_hypgeom_dilog_bitburst(acb_t res, acb_t z0, const acb_t z, slong prec) # Sets *z0* to a point with short bit expansion close to *z* and sets # *res* to `\operatorname{Li}_2(z) - \operatorname{Li}_2(z_0)`, computed # using the bit-burst algorithm. - void acb_hypgeom_dilog(acb_t res, const acb_t z, long prec) + void acb_hypgeom_dilog(acb_t res, const acb_t z, slong prec) # Computes the dilogarithm using a default algorithm choice. diff --git a/src/sage/libs/flint/acb_mat.pxd b/src/sage/libs/flint/acb_mat.pxd index 0cba753670e..d54cf768c1c 100644 --- a/src/sage/libs/flint/acb_mat.pxd +++ b/src/sage/libs/flint/acb_mat.pxd @@ -12,19 +12,19 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void acb_mat_init(acb_mat_t mat, long r, long c) + void acb_mat_init(acb_mat_t mat, slong r, slong c) # Initializes the matrix, setting it to the zero matrix with *r* rows # and *c* columns. void acb_mat_clear(acb_mat_t mat) # Clears the matrix, deallocating all entries. - long acb_mat_allocated_bytes(const acb_mat_t x) + slong acb_mat_allocated_bytes(const acb_mat_t x) # Returns the total number of bytes heap-allocated internally by this object. # The count excludes the size of the structure itself. Add # ``sizeof(acb_mat_struct)`` to get the size of the object as a whole. - void acb_mat_window_init(acb_mat_t window, const acb_mat_t mat, long r1, long c1, long r2, long c2) + void acb_mat_window_init(acb_mat_t window, const acb_mat_t mat, slong r1, slong c1, slong r2, slong c2) # Initializes *window* to a window matrix into the submatrix of *mat* # starting at the corner at row *r1* and column *c1* (inclusive) and ending # at row *r2* and column *c2* (exclusive). @@ -36,29 +36,29 @@ cdef extern from "flint_wrap.h": void acb_mat_set_fmpz_mat(acb_mat_t dest, const fmpz_mat_t src) - void acb_mat_set_round_fmpz_mat(acb_mat_t dest, const fmpz_mat_t src, long prec) + void acb_mat_set_round_fmpz_mat(acb_mat_t dest, const fmpz_mat_t src, slong prec) - void acb_mat_set_fmpq_mat(acb_mat_t dest, const fmpq_mat_t src, long prec) + void acb_mat_set_fmpq_mat(acb_mat_t dest, const fmpq_mat_t src, slong prec) void acb_mat_set_arb_mat(acb_mat_t dest, const arb_mat_t src) - void acb_mat_set_round_arb_mat(acb_mat_t dest, const arb_mat_t src, long prec) + void acb_mat_set_round_arb_mat(acb_mat_t dest, const arb_mat_t src, slong prec) # Sets *dest* to *src*. The operands must have identical dimensions. - void acb_mat_randtest(acb_mat_t mat, flint_rand_t state, long prec, long mag_bits) + void acb_mat_randtest(acb_mat_t mat, flint_rand_t state, slong prec, slong mag_bits) # Sets *mat* to a random matrix with up to *prec* bits of precision # and with exponents of width up to *mag_bits*. - void acb_mat_randtest_eig(acb_mat_t mat, flint_rand_t state, acb_srcptr E, long prec) + void acb_mat_randtest_eig(acb_mat_t mat, flint_rand_t state, acb_srcptr E, slong prec) # Sets *mat* to a random matrix with the prescribed eigenvalues # supplied as the vector *E*. The output matrix is required to be # square. We generate a random unitary matrix via a matrix # exponential, and then evaluate an inverse Schur decomposition. - void acb_mat_printd(const acb_mat_t mat, long digits) + void acb_mat_printd(const acb_mat_t mat, slong digits) # Prints each entry in the matrix with the specified number of decimal digits. - void acb_mat_fprintd(FILE * file, const acb_mat_t mat, long digits) + void acb_mat_fprintd(FILE * file, const acb_mat_t mat, slong digits) # Prints each entry in the matrix with the specified number of decimal # digits to the stream *file*. @@ -127,7 +127,7 @@ cdef extern from "flint_wrap.h": void acb_mat_indeterminate(acb_mat_t mat) # Sets all entries in the matrix to indeterminate (NaN). - void acb_mat_dft(acb_mat_t mat, int type, long prec) + void acb_mat_dft(acb_mat_t mat, int type, slong prec) # Sets *mat* to the DFT (discrete Fourier transform) matrix of order *n* # where *n* is the smallest dimension of *mat* (if *mat* is not square, # the matrix is extended periodically along the larger dimension). @@ -152,7 +152,7 @@ cdef extern from "flint_wrap.h": # Sets *b* to an upper bound for the infinity norm (i.e. the largest # absolute value row sum) of *A*. - void acb_mat_frobenius_norm(arb_t res, const acb_mat_t A, long prec) + void acb_mat_frobenius_norm(arb_t res, const acb_mat_t A, slong prec) # Sets *res* to the Frobenius norm (i.e. the square root of the sum # of squares of entries) of *A*. @@ -163,20 +163,20 @@ cdef extern from "flint_wrap.h": # Sets *dest* to the exact negation of *src*. The operands must have # the same dimensions. - void acb_mat_add(acb_mat_t res, const acb_mat_t mat1, const acb_mat_t mat2, long prec) + void acb_mat_add(acb_mat_t res, const acb_mat_t mat1, const acb_mat_t mat2, slong prec) # Sets res to the sum of *mat1* and *mat2*. The operands must have the same dimensions. - void acb_mat_sub(acb_mat_t res, const acb_mat_t mat1, const acb_mat_t mat2, long prec) + void acb_mat_sub(acb_mat_t res, const acb_mat_t mat1, const acb_mat_t mat2, slong prec) # Sets *res* to the difference of *mat1* and *mat2*. The operands must have # the same dimensions. - void acb_mat_mul_classical(acb_mat_t res, const acb_mat_t mat1, const acb_mat_t mat2, long prec) + void acb_mat_mul_classical(acb_mat_t res, const acb_mat_t mat1, const acb_mat_t mat2, slong prec) - void acb_mat_mul_threaded(acb_mat_t res, const acb_mat_t mat1, const acb_mat_t mat2, long prec) + void acb_mat_mul_threaded(acb_mat_t res, const acb_mat_t mat1, const acb_mat_t mat2, slong prec) - void acb_mat_mul_reorder(acb_mat_t res, const acb_mat_t mat1, const acb_mat_t mat2, long prec) + void acb_mat_mul_reorder(acb_mat_t res, const acb_mat_t mat1, const acb_mat_t mat2, slong prec) - void acb_mat_mul(acb_mat_t res, const acb_mat_t mat1, const acb_mat_t mat2, long prec) + void acb_mat_mul(acb_mat_t res, const acb_mat_t mat1, const acb_mat_t mat2, slong prec) # Sets *res* to the matrix product of *mat1* and *mat2*. The operands must have # compatible dimensions for matrix multiplication. # The *classical* version performs matrix multiplication in the trivial way. @@ -186,62 +186,62 @@ cdef extern from "flint_wrap.h": # matrix multiplications via :func:`arb_mat_mul`. # The default version chooses an algorithm automatically. - void acb_mat_mul_entrywise(acb_mat_t res, const acb_mat_t mat1, const acb_mat_t mat2, long prec) + void acb_mat_mul_entrywise(acb_mat_t res, const acb_mat_t mat1, const acb_mat_t mat2, slong prec) # Sets *res* to the entrywise product of *mat1* and *mat2*. # The operands must have the same dimensions. - void acb_mat_sqr_classical(acb_mat_t res, const acb_mat_t mat, long prec) + void acb_mat_sqr_classical(acb_mat_t res, const acb_mat_t mat, slong prec) - void acb_mat_sqr(acb_mat_t res, const acb_mat_t mat, long prec) + void acb_mat_sqr(acb_mat_t res, const acb_mat_t mat, slong prec) # Sets *res* to the matrix square of *mat*. The operands must both be square # with the same dimensions. - void acb_mat_pow_ui(acb_mat_t res, const acb_mat_t mat, unsigned long exp, long prec) + void acb_mat_pow_ui(acb_mat_t res, const acb_mat_t mat, ulong exp, slong prec) # Sets *res* to *mat* raised to the power *exp*. Requires that *mat* # is a square matrix. - void acb_mat_approx_mul(acb_mat_t res, const acb_mat_t mat1, const acb_mat_t mat2, long prec) + void acb_mat_approx_mul(acb_mat_t res, const acb_mat_t mat1, const acb_mat_t mat2, slong prec) # Approximate matrix multiplication. The input radii are ignored and # the output matrix is set to an approximate floating-point result. # For performance reasons, the radii in the output matrix will *not* # necessarily be written (zeroed), but will remain zero if they # are already zeroed in *res* before calling this function. - void acb_mat_scalar_mul_2exp_si(acb_mat_t B, const acb_mat_t A, long c) + void acb_mat_scalar_mul_2exp_si(acb_mat_t B, const acb_mat_t A, slong c) # Sets *B* to *A* multiplied by `2^c`. - void acb_mat_scalar_addmul_si(acb_mat_t B, const acb_mat_t A, long c, long prec) + void acb_mat_scalar_addmul_si(acb_mat_t B, const acb_mat_t A, slong c, slong prec) - void acb_mat_scalar_addmul_fmpz(acb_mat_t B, const acb_mat_t A, const fmpz_t c, long prec) + void acb_mat_scalar_addmul_fmpz(acb_mat_t B, const acb_mat_t A, const fmpz_t c, slong prec) - void acb_mat_scalar_addmul_arb(acb_mat_t B, const acb_mat_t A, const arb_t c, long prec) + void acb_mat_scalar_addmul_arb(acb_mat_t B, const acb_mat_t A, const arb_t c, slong prec) - void acb_mat_scalar_addmul_acb(acb_mat_t B, const acb_mat_t A, const acb_t c, long prec) + void acb_mat_scalar_addmul_acb(acb_mat_t B, const acb_mat_t A, const acb_t c, slong prec) # Sets *B* to `B + A \times c`. - void acb_mat_scalar_mul_si(acb_mat_t B, const acb_mat_t A, long c, long prec) + void acb_mat_scalar_mul_si(acb_mat_t B, const acb_mat_t A, slong c, slong prec) - void acb_mat_scalar_mul_fmpz(acb_mat_t B, const acb_mat_t A, const fmpz_t c, long prec) + void acb_mat_scalar_mul_fmpz(acb_mat_t B, const acb_mat_t A, const fmpz_t c, slong prec) - void acb_mat_scalar_mul_arb(acb_mat_t B, const acb_mat_t A, const arb_t c, long prec) + void acb_mat_scalar_mul_arb(acb_mat_t B, const acb_mat_t A, const arb_t c, slong prec) - void acb_mat_scalar_mul_acb(acb_mat_t B, const acb_mat_t A, const acb_t c, long prec) + void acb_mat_scalar_mul_acb(acb_mat_t B, const acb_mat_t A, const acb_t c, slong prec) # Sets *B* to `A \times c`. - void acb_mat_scalar_div_si(acb_mat_t B, const acb_mat_t A, long c, long prec) + void acb_mat_scalar_div_si(acb_mat_t B, const acb_mat_t A, slong c, slong prec) - void acb_mat_scalar_div_fmpz(acb_mat_t B, const acb_mat_t A, const fmpz_t c, long prec) + void acb_mat_scalar_div_fmpz(acb_mat_t B, const acb_mat_t A, const fmpz_t c, slong prec) - void acb_mat_scalar_div_arb(acb_mat_t B, const acb_mat_t A, const arb_t c, long prec) + void acb_mat_scalar_div_arb(acb_mat_t B, const acb_mat_t A, const arb_t c, slong prec) - void acb_mat_scalar_div_acb(acb_mat_t B, const acb_mat_t A, const acb_t c, long prec) + void acb_mat_scalar_div_acb(acb_mat_t B, const acb_mat_t A, const acb_t c, slong prec) # Sets *B* to `A / c`. - int acb_mat_lu_classical(long * perm, acb_mat_t LU, const acb_mat_t A, long prec) + int acb_mat_lu_classical(slong * perm, acb_mat_t LU, const acb_mat_t A, slong prec) - int acb_mat_lu_recursive(long * perm, acb_mat_t LU, const acb_mat_t A, long prec) + int acb_mat_lu_recursive(slong * perm, acb_mat_t LU, const acb_mat_t A, slong prec) - int acb_mat_lu(long * perm, acb_mat_t LU, const acb_mat_t A, long prec) + int acb_mat_lu(slong * perm, acb_mat_t LU, const acb_mat_t A, slong prec) # Given an `n \times n` matrix `A`, computes an LU decomposition `PLU = A` # using Gaussian elimination with partial pivoting. # The input and output matrices can be the same, performing the @@ -261,17 +261,17 @@ cdef extern from "flint_wrap.h": # way to benefit from fast matrix multiplication. The default version # chooses an algorithm automatically. - void acb_mat_solve_tril_classical(acb_mat_t X, const acb_mat_t L, const acb_mat_t B, int unit, long prec) + void acb_mat_solve_tril_classical(acb_mat_t X, const acb_mat_t L, const acb_mat_t B, int unit, slong prec) - void acb_mat_solve_tril_recursive(acb_mat_t X, const acb_mat_t L, const acb_mat_t B, int unit, long prec) + void acb_mat_solve_tril_recursive(acb_mat_t X, const acb_mat_t L, const acb_mat_t B, int unit, slong prec) - void acb_mat_solve_tril(acb_mat_t X, const acb_mat_t L, const acb_mat_t B, int unit, long prec) + void acb_mat_solve_tril(acb_mat_t X, const acb_mat_t L, const acb_mat_t B, int unit, slong prec) - void acb_mat_solve_triu_classical(acb_mat_t X, const acb_mat_t U, const acb_mat_t B, int unit, long prec) + void acb_mat_solve_triu_classical(acb_mat_t X, const acb_mat_t U, const acb_mat_t B, int unit, slong prec) - void acb_mat_solve_triu_recursive(acb_mat_t X, const acb_mat_t U, const acb_mat_t B, int unit, long prec) + void acb_mat_solve_triu_recursive(acb_mat_t X, const acb_mat_t U, const acb_mat_t B, int unit, slong prec) - void acb_mat_solve_triu(acb_mat_t X, const acb_mat_t U, const acb_mat_t B, int unit, long prec) + void acb_mat_solve_triu(acb_mat_t X, const acb_mat_t U, const acb_mat_t B, int unit, slong prec) # Solves the lower triangular system `LX = B` or the upper triangular system # `UX = B`, respectively. If *unit* is set, the main diagonal of *L* or *U* # is taken to consist of all ones, and in that case the actual entries on @@ -281,16 +281,16 @@ cdef extern from "flint_wrap.h": # way to benefit from fast matrix multiplication. The default versions # choose an algorithm automatically. - void acb_mat_solve_lu_precomp(acb_mat_t X, const long * perm, const acb_mat_t LU, const acb_mat_t B, long prec) + void acb_mat_solve_lu_precomp(acb_mat_t X, const slong * perm, const acb_mat_t LU, const acb_mat_t B, slong prec) # Solves `AX = B` given the precomputed nonsingular LU decomposition `A = PLU`. # The matrices `X` and `B` are allowed to be aliased with each other, # but `X` is not allowed to be aliased with `LU`. - int acb_mat_solve(acb_mat_t X, const acb_mat_t A, const acb_mat_t B, long prec) + int acb_mat_solve(acb_mat_t X, const acb_mat_t A, const acb_mat_t B, slong prec) - int acb_mat_solve_lu(acb_mat_t X, const acb_mat_t A, const acb_mat_t B, long prec) + int acb_mat_solve_lu(acb_mat_t X, const acb_mat_t A, const acb_mat_t B, slong prec) - int acb_mat_solve_precond(acb_mat_t X, const acb_mat_t A, const acb_mat_t B, long prec) + int acb_mat_solve_precond(acb_mat_t X, const acb_mat_t A, const acb_mat_t B, slong prec) # Solves `AX = B` where `A` is a nonsingular `n \times n` matrix # and `X` and `B` are `n \times m` matrices. # If `m > 0` and `A` cannot be inverted numerically (indicating either that @@ -314,7 +314,7 @@ cdef extern from "flint_wrap.h": # For example, the *lu* solver often performs better for ill-conditioned # systems where use of very high precision is unavoidable. - int acb_mat_inv(acb_mat_t X, const acb_mat_t A, long prec) + int acb_mat_inv(acb_mat_t X, const acb_mat_t A, slong prec) # Sets `X = A^{-1}` where `A` is a square matrix, computed by solving # the system `AX = I`. # If `A` cannot be inverted numerically (indicating either that @@ -323,11 +323,11 @@ cdef extern from "flint_wrap.h": # A nonzero return value guarantees that the matrix is invertible # and that the exact inverse is contained in the output. - void acb_mat_det_lu(acb_t det, const acb_mat_t A, long prec) + void acb_mat_det_lu(acb_t det, const acb_mat_t A, slong prec) - void acb_mat_det_precond(acb_t det, const acb_mat_t A, long prec) + void acb_mat_det_precond(acb_t det, const acb_mat_t A, slong prec) - void acb_mat_det(acb_t det, const acb_mat_t A, long prec) + void acb_mat_det(acb_t det, const acb_mat_t A, slong prec) # Sets *det* to the determinant of the matrix *A*. # The *lu* version uses Gaussian elimination with partial pivoting. If at # some point an invertible pivot element cannot be found, the elimination is @@ -343,17 +343,17 @@ cdef extern from "flint_wrap.h": # versions and additionally handles small or triangular matrices # by direct formulas. - void acb_mat_approx_solve_triu(acb_mat_t X, const acb_mat_t U, const acb_mat_t B, int unit, long prec) + void acb_mat_approx_solve_triu(acb_mat_t X, const acb_mat_t U, const acb_mat_t B, int unit, slong prec) - void acb_mat_approx_solve_tril(acb_mat_t X, const acb_mat_t L, const acb_mat_t B, int unit, long prec) + void acb_mat_approx_solve_tril(acb_mat_t X, const acb_mat_t L, const acb_mat_t B, int unit, slong prec) - int acb_mat_approx_lu(long * P, acb_mat_t LU, const acb_mat_t A, long prec) + int acb_mat_approx_lu(slong * P, acb_mat_t LU, const acb_mat_t A, slong prec) - void acb_mat_approx_solve_lu_precomp(acb_mat_t X, const long * perm, const acb_mat_t A, const acb_mat_t B, long prec) + void acb_mat_approx_solve_lu_precomp(acb_mat_t X, const slong * perm, const acb_mat_t A, const acb_mat_t B, slong prec) - int acb_mat_approx_solve(acb_mat_t X, const acb_mat_t A, const acb_mat_t B, long prec) + int acb_mat_approx_solve(acb_mat_t X, const acb_mat_t A, const acb_mat_t B, slong prec) - int acb_mat_approx_inv(acb_mat_t X, const acb_mat_t A, long prec) + int acb_mat_approx_inv(acb_mat_t X, const acb_mat_t A, slong prec) # These methods perform approximate solving *without any error control*. # The radii in the input matrices are ignored, the computations are done # numerically with floating-point arithmetic (using ordinary @@ -362,26 +362,26 @@ cdef extern from "flint_wrap.h": # output matrices are set to the approximate floating-point results with # zeroed error bounds. - void _acb_mat_charpoly(acb_ptr poly, const acb_mat_t mat, long prec) + void _acb_mat_charpoly(acb_ptr poly, const acb_mat_t mat, slong prec) - void acb_mat_charpoly(acb_poly_t poly, const acb_mat_t mat, long prec) + void acb_mat_charpoly(acb_poly_t poly, const acb_mat_t mat, slong prec) # Sets *poly* to the characteristic polynomial of *mat* which must be # a square matrix. If the matrix has *n* rows, the underscore method # requires space for `n + 1` output coefficients. # Employs a division-free algorithm using `O(n^4)` operations. - void _acb_mat_companion(acb_mat_t mat, acb_srcptr poly, long prec) + void _acb_mat_companion(acb_mat_t mat, acb_srcptr poly, slong prec) - void acb_mat_companion(acb_mat_t mat, const acb_poly_t poly, long prec) + void acb_mat_companion(acb_mat_t mat, const acb_poly_t poly, slong prec) # Sets the *n* by *n* matrix *mat* to the companion matrix of the polynomial # *poly* which must have degree *n*. # The underscore method reads `n + 1` input coefficients. - void acb_mat_exp_taylor_sum(acb_mat_t S, const acb_mat_t A, long N, long prec) + void acb_mat_exp_taylor_sum(acb_mat_t S, const acb_mat_t A, slong N, slong prec) # Sets *S* to the truncated exponential Taylor series `S = \sum_{k=0}^{N-1} A^k / k!`. # See :func:`arb_mat_exp_taylor_sum` for implementation notes. - void acb_mat_exp(acb_mat_t B, const acb_mat_t A, long prec) + void acb_mat_exp(acb_mat_t B, const acb_mat_t A, slong prec) # Sets *B* to the exponential of the matrix *A*, defined by the Taylor series # .. math :: # \exp(A) = \sum_{k=0}^{\infty} \frac{A^k}{k!}. @@ -389,13 +389,13 @@ cdef extern from "flint_wrap.h": # to give rapid convergence of the Taylor series. # Error bounds are computed as for :func:`arb_mat_exp`. - void acb_mat_trace(acb_t trace, const acb_mat_t mat, long prec) + void acb_mat_trace(acb_t trace, const acb_mat_t mat, slong prec) # Sets *trace* to the trace of the matrix, i.e. the sum of entries on the # main diagonal of *mat*. The matrix is required to be square. - void _acb_mat_diag_prod(acb_t res, const acb_mat_t mat, long a, long b, long prec) + void _acb_mat_diag_prod(acb_t res, const acb_mat_t mat, slong a, slong b, slong prec) - void acb_mat_diag_prod(acb_t res, const acb_mat_t mat, long prec) + void acb_mat_diag_prod(acb_t res, const acb_mat_t mat, slong prec) # Sets *res* to the product of the entries on the main diagonal of *mat*. # The underscore method computes the product of the entries between # index *a* inclusive and *b* exclusive (the indices must be in range). @@ -406,7 +406,7 @@ cdef extern from "flint_wrap.h": void acb_mat_add_error_mag(acb_mat_t mat, const mag_t err) # Adds *err* in-place to the radii of the entries of *mat*. - int acb_mat_approx_eig_qr(acb_ptr E, acb_mat_t L, acb_mat_t R, const acb_mat_t A, const mag_t tol, long maxiter, long prec) + int acb_mat_approx_eig_qr(acb_ptr E, acb_mat_t L, acb_mat_t R, const acb_mat_t A, const mag_t tol, slong maxiter, slong prec) # Computes floating-point approximations of all the *n* eigenvalues # (and optionally eigenvectors) of the # given *n* by *n* matrix *A*. The approximations of the @@ -427,7 +427,7 @@ cdef extern from "flint_wrap.h": # any statement whatsoever about error bounds. # The output may also be accurate even if this function returns zero. - void acb_mat_eig_global_enclosure(mag_t eps, const acb_mat_t A, acb_srcptr E, const acb_mat_t R, long prec) + void acb_mat_eig_global_enclosure(mag_t eps, const acb_mat_t A, acb_srcptr E, const acb_mat_t R, slong prec) # Given an *n* by *n* matrix *A*, a length-*n* vector *E* # containing approximations of the eigenvalues of *A*, # and an *n* by *n* matrix *R* containing approximations of @@ -466,7 +466,7 @@ cdef extern from "flint_wrap.h": # No assumptions are made about the structure of *A* or the # quality of the given approximations. - void acb_mat_eig_enclosure_rump(acb_t lmbda, acb_mat_t J, acb_mat_t R, const acb_mat_t A, const acb_t lambda_approx, const acb_mat_t R_approx, long prec) + void acb_mat_eig_enclosure_rump(acb_t lmbda, acb_mat_t J, acb_mat_t R, const acb_mat_t A, const acb_t lambda_approx, const acb_mat_t R_approx, slong prec) # Given an *n* by *n* matrix *A* and an approximate # eigenvalue-eigenvector pair *lambda_approx* and *R_approx* (where # *R_approx* is an *n* by 1 matrix), computes an enclosure @@ -502,11 +502,11 @@ cdef extern from "flint_wrap.h": # No assumptions are made about the structure of *A* or the # quality of the given approximations. - int acb_mat_eig_simple_rump(acb_ptr E, acb_mat_t L, acb_mat_t R, const acb_mat_t A, acb_srcptr E_approx, const acb_mat_t R_approx, long prec) + int acb_mat_eig_simple_rump(acb_ptr E, acb_mat_t L, acb_mat_t R, const acb_mat_t A, acb_srcptr E_approx, const acb_mat_t R_approx, slong prec) - int acb_mat_eig_simple_vdhoeven_mourrain(acb_ptr E, acb_mat_t L, acb_mat_t R, const acb_mat_t A, acb_srcptr E_approx, const acb_mat_t R_approx, long prec) + int acb_mat_eig_simple_vdhoeven_mourrain(acb_ptr E, acb_mat_t L, acb_mat_t R, const acb_mat_t A, acb_srcptr E_approx, const acb_mat_t R_approx, slong prec) - int acb_mat_eig_simple(acb_ptr E, acb_mat_t L, acb_mat_t R, const acb_mat_t A, acb_srcptr E_approx, const acb_mat_t R_approx, long prec) + int acb_mat_eig_simple(acb_ptr E, acb_mat_t L, acb_mat_t R, const acb_mat_t A, acb_srcptr E_approx, const acb_mat_t R_approx, slong prec) # Computes all the eigenvalues (and optionally corresponding # eigenvectors) of the given *n* by *n* matrix *A*. # Attempts to prove that *A* has *n* simple (isolated) @@ -542,9 +542,9 @@ cdef extern from "flint_wrap.h": # :func:`acb_mat_eig_multiple_rump` may be used as a fallback, # or :func:`acb_mat_eig_multiple` may be used in the first place. - int acb_mat_eig_multiple_rump(acb_ptr E, const acb_mat_t A, acb_srcptr E_approx, const acb_mat_t R_approx, long prec) + int acb_mat_eig_multiple_rump(acb_ptr E, const acb_mat_t A, acb_srcptr E_approx, const acb_mat_t R_approx, slong prec) - int acb_mat_eig_multiple(acb_ptr E, const acb_mat_t A, acb_srcptr E_approx, const acb_mat_t R_approx, long prec) + int acb_mat_eig_multiple(acb_ptr E, const acb_mat_t A, acb_srcptr E_approx, const acb_mat_t R_approx, slong prec) # Computes all the eigenvalues of the given *n* by *n* matrix *A*. # On success, the output vector *E* contains *n* complex intervals, # each representing one eigenvalue of *A* with the correct diff --git a/src/sage/libs/flint/acb_modular.pxd b/src/sage/libs/flint/acb_modular.pxd index 0164bb3df8d..382eb9afc05 100644 --- a/src/sage/libs/flint/acb_modular.pxd +++ b/src/sage/libs/flint/acb_modular.pxd @@ -50,13 +50,13 @@ cdef extern from "flint_wrap.h": # Returns nonzero iff *g* contains correct data, i.e. # satisfying `ad-bc = 1`, `c \ge 0`, and `d > 0` if `c = 0`. - void psl2z_randtest(psl2z_t g, flint_rand_t state, long bits) + void psl2z_randtest(psl2z_t g, flint_rand_t state, slong bits) # Sets *g* to a random element of `\text{PSL}(2, \mathbb{Z})` # with entries of bit length at most *bits* # (or 1, if *bits* is not positive). We first generate *a* and *d*, compute # their Bezout coefficients, divide by the GCD, and then correct the signs. - void acb_modular_transform(acb_t w, const psl2z_t g, const acb_t z, long prec) + void acb_modular_transform(acb_t w, const psl2z_t g, const acb_t z, slong prec) # Applies the modular transformation *g* to the complex number *z*, # evaluating # .. math :: @@ -64,7 +64,7 @@ cdef extern from "flint_wrap.h": void acb_modular_fundamental_domain_approx_d(psl2z_t g, double x, double y, double one_minus_eps) - void acb_modular_fundamental_domain_approx_arf(psl2z_t g, const arf_t x, const arf_t y, const arf_t one_minus_eps, long prec) + void acb_modular_fundamental_domain_approx_arf(psl2z_t g, const arf_t x, const arf_t y, const arf_t one_minus_eps, slong prec) # Attempts to determine a modular transformation *g* that maps the # complex number `x+yi` to the fundamental domain or just # slightly outside the fundamental domain, where the target tolerance @@ -81,7 +81,7 @@ cdef extern from "flint_wrap.h": # but it is up to the user to verify a posteriori that *g* maps `x+yi` # close enough to the fundamental domain. - void acb_modular_fundamental_domain_approx(acb_t w, psl2z_t g, const acb_t z, const arf_t one_minus_eps, long prec) + void acb_modular_fundamental_domain_approx(acb_t w, psl2z_t g, const acb_t z, const arf_t one_minus_eps, slong prec) # Attempts to determine a modular transformation *g* that maps the # complex number `z` to the fundamental domain or just # slightly outside the fundamental domain, where the target tolerance @@ -97,12 +97,12 @@ cdef extern from "flint_wrap.h": # but it is up to the user to verify a posteriori that `w` is close enough # to the fundamental domain. - int acb_modular_is_in_fundamental_domain(const acb_t z, const arf_t tol, long prec) + int acb_modular_is_in_fundamental_domain(const acb_t z, const arf_t tol, slong prec) # Returns nonzero if it is certainly true that `|z| \ge 1 - \varepsilon` and # `|\operatorname{Re}(z)| \le 1/2 + \varepsilon` where `\varepsilon` is # specified by *tol*. Returns zero if this is false or cannot be determined. - void acb_modular_fill_addseq(long * tab, long len) + void acb_modular_fill_addseq(slong * tab, slong len) # Builds a near-optimal addition sequence for a sequence of integers # which is assumed to be reasonably dense. # As input, the caller should set each entry in *tab* to `-1` if @@ -170,11 +170,11 @@ cdef extern from "flint_wrap.h": # and his "`\varepsilon`" differs from ours by a constant # offset in the phase). - void acb_modular_addseq_theta(long * exponents, long * aindex, long * bindex, long num) + void acb_modular_addseq_theta(slong * exponents, slong * aindex, slong * bindex, slong num) # Constructs an addition sequence for the first *num* squares and triangular # numbers interleaved (excluding zero), i.e. 1, 2, 4, 6, 9, 12, 16, 20, 25, 30 etc. - void acb_modular_theta_sum(acb_ptr theta1, acb_ptr theta2, acb_ptr theta3, acb_ptr theta4, const acb_t w, int w_is_unit, const acb_t q, long len, long prec) + void acb_modular_theta_sum(acb_ptr theta1, acb_ptr theta2, acb_ptr theta3, acb_ptr theta4, const acb_t w, int w_is_unit, const acb_t q, slong len, slong prec) # Simultaneously computes the first *len* coefficients of each of the # formal power series # .. math :: @@ -245,9 +245,9 @@ cdef extern from "flint_wrap.h": # This function does not permit aliasing between input and output # arguments. - void acb_modular_theta_const_sum_basecase(acb_t theta2, acb_t theta3, acb_t theta4, const acb_t q, long N, long prec) + void acb_modular_theta_const_sum_basecase(acb_t theta2, acb_t theta3, acb_t theta4, const acb_t q, slong N, slong prec) - void acb_modular_theta_const_sum_rs(acb_t theta2, acb_t theta3, acb_t theta4, const acb_t q, long N, long prec) + void acb_modular_theta_const_sum_rs(acb_t theta2, acb_t theta3, acb_t theta4, const acb_t q, slong N, slong prec) # Computes the truncated theta constant sums # `\theta_2 = \sum_{k(k+1) < N} q^{k(k+1)}`, # `\theta_3 = \sum_{k^2 < N} q^{k^2}`, @@ -256,7 +256,7 @@ cdef extern from "flint_wrap.h": # The *rs* version uses rectangular splitting. # The algorithms are described in [EHJ2016]_. - void acb_modular_theta_const_sum(acb_t theta2, acb_t theta3, acb_t theta4, const acb_t q, long prec) + void acb_modular_theta_const_sum(acb_t theta2, acb_t theta3, acb_t theta4, const acb_t q, slong prec) # Computes the respective theta constants by direct summation # (without applying modular transformations). This function # selects an appropriate *N*, calls either @@ -264,38 +264,38 @@ cdef extern from "flint_wrap.h": # :func:`acb_modular_theta_const_sum_rs` or depending on *N*, # and adds a bound for the truncation error. - void acb_modular_theta_notransform(acb_t theta1, acb_t theta2, acb_t theta3, acb_t theta4, const acb_t z, const acb_t tau, long prec) + void acb_modular_theta_notransform(acb_t theta1, acb_t theta2, acb_t theta3, acb_t theta4, const acb_t z, const acb_t tau, slong prec) # Evaluates the Jacobi theta functions `\theta_i(z,\tau)`, `i = 1, 2, 3, 4` # simultaneously. This function does not move `\tau` to the fundamental domain. # This is generally worse than :func:`acb_modular_theta`, but can # be slightly better for moderate input. - void acb_modular_theta(acb_t theta1, acb_t theta2, acb_t theta3, acb_t theta4, const acb_t z, const acb_t tau, long prec) + void acb_modular_theta(acb_t theta1, acb_t theta2, acb_t theta3, acb_t theta4, const acb_t z, const acb_t tau, slong prec) # Evaluates the Jacobi theta functions `\theta_i(z,\tau)`, `i = 1, 2, 3, 4` # simultaneously. This function moves `\tau` to the fundamental domain # and then also reduces `z` modulo `\tau` # before calling :func:`acb_modular_theta_sum`. - void acb_modular_theta_jet_notransform(acb_ptr theta1, acb_ptr theta2, acb_ptr theta3, acb_ptr theta4, const acb_t z, const acb_t tau, long len, long prec) + void acb_modular_theta_jet_notransform(acb_ptr theta1, acb_ptr theta2, acb_ptr theta3, acb_ptr theta4, const acb_t z, const acb_t tau, slong len, slong prec) - void acb_modular_theta_jet(acb_ptr theta1, acb_ptr theta2, acb_ptr theta3, acb_ptr theta4, const acb_t z, const acb_t tau, long len, long prec) + void acb_modular_theta_jet(acb_ptr theta1, acb_ptr theta2, acb_ptr theta3, acb_ptr theta4, const acb_t z, const acb_t tau, slong len, slong prec) # Evaluates the Jacobi theta functions along with their derivatives # with respect to *z*, writing the first *len* coefficients in the power # series `\theta_i(z+x,\tau) \in \mathbb{C}[[x]]` to # each respective output variable. The *notransform* version does not # move `\tau` to the fundamental domain or reduce `z` during the computation. - void _acb_modular_theta_series(acb_ptr theta1, acb_ptr theta2, acb_ptr theta3, acb_ptr theta4, acb_srcptr z, long zlen, const acb_t tau, long len, long prec) + void _acb_modular_theta_series(acb_ptr theta1, acb_ptr theta2, acb_ptr theta3, acb_ptr theta4, acb_srcptr z, slong zlen, const acb_t tau, slong len, slong prec) - void acb_modular_theta_series(acb_poly_t theta1, acb_poly_t theta2, acb_poly_t theta3, acb_poly_t theta4, const acb_poly_t z, const acb_t tau, long len, long prec) + void acb_modular_theta_series(acb_poly_t theta1, acb_poly_t theta2, acb_poly_t theta3, acb_poly_t theta4, const acb_poly_t z, const acb_t tau, slong len, slong prec) # Evaluates the respective Jacobi theta functions of the power series *z*, # truncated to length *len*. Either of the output variables can be *NULL*. - void acb_modular_addseq_eta(long * exponents, long * aindex, long * bindex, long num) + void acb_modular_addseq_eta(slong * exponents, slong * aindex, slong * bindex, slong num) # Constructs an addition sequence for the first *num* generalized pentagonal # numbers (excluding zero), i.e. 1, 2, 5, 7, 12, 15, 22, 26, 35, 40 etc. - void acb_modular_eta_sum(acb_t eta, const acb_t q, long prec) + void acb_modular_eta_sum(acb_t eta, const acb_t q, slong prec) # Evaluates the Dedekind eta function # without the leading 24th root, i.e. # .. math :: \exp(-\pi i \tau/12) \eta(\tau) = \sum_{n=-\infty}^{\infty} (-1)^n q^{(3n^2-n)/2} @@ -316,13 +316,13 @@ cdef extern from "flint_wrap.h": # \eta\left(\frac{a\tau+b}{c\tau+d}\right) = \varepsilon (a,b,c,d) # \sqrt{c\tau+d} \eta(\tau). - void acb_modular_eta(acb_t r, const acb_t tau, long prec) + void acb_modular_eta(acb_t r, const acb_t tau, slong prec) # Computes the Dedekind eta function `\eta(\tau)` given `\tau` in the upper # half-plane. This function applies the functional equation to move # `\tau` to the fundamental domain before calling # :func:`acb_modular_eta_sum`. - void acb_modular_j(acb_t r, const acb_t tau, long prec) + void acb_modular_j(acb_t r, const acb_t tau, slong prec) # Computes Klein's j-invariant `j(\tau)` given `\tau` in the upper # half-plane. The function is normalized so that `j(i) = 1728`. # We first move `\tau` to the fundamental domain, which does not change @@ -330,13 +330,13 @@ cdef extern from "flint_wrap.h": # `j(\tau) = 32 (\theta_2^8+\theta_3^8+\theta_4^8)^3 / (\theta_2 \theta_3 \theta_4)^8` where # `\theta_i = \theta_i(0,\tau)`. - void acb_modular_lambda(acb_t r, const acb_t tau, long prec) + void acb_modular_lambda(acb_t r, const acb_t tau, slong prec) # Computes the lambda function # `\lambda(\tau) = \theta_2^4(0,\tau) / \theta_3^4(0,\tau)`, which # is invariant under modular transformations `(a, b; c, d)` # where `a, d` are odd and `b, c` are even. - void acb_modular_delta(acb_t r, const acb_t tau, long prec) + void acb_modular_delta(acb_t r, const acb_t tau, slong prec) # Computes the modular discriminant `\Delta(\tau) = \eta(\tau)^{24}`, # which transforms as # .. math :: @@ -344,7 +344,7 @@ cdef extern from "flint_wrap.h": # The modular discriminant is sometimes defined with an extra factor # `(2\pi)^{12}`, which we omit in this implementation. - void acb_modular_eisenstein(acb_ptr r, const acb_t tau, long len, long prec) + void acb_modular_eisenstein(acb_ptr r, const acb_t tau, slong len, slong prec) # Computes simultaneously the first *len* entries in the sequence # of Eisenstein series `G_4(\tau), G_6(\tau), G_8(\tau), \ldots`, # defined by @@ -357,17 +357,17 @@ cdef extern from "flint_wrap.h": # domain using theta functions, and then compute the Eisenstein series # of higher index using a recurrence relation. - void acb_modular_elliptic_k(acb_t w, const acb_t m, long prec) + void acb_modular_elliptic_k(acb_t w, const acb_t m, slong prec) - void acb_modular_elliptic_k_cpx(acb_ptr w, const acb_t m, long len, long prec) + void acb_modular_elliptic_k_cpx(acb_ptr w, const acb_t m, slong len, slong prec) - void acb_modular_elliptic_e(acb_t w, const acb_t m, long prec) + void acb_modular_elliptic_e(acb_t w, const acb_t m, slong prec) - void acb_modular_elliptic_p(acb_t wp, const acb_t z, const acb_t tau, long prec) + void acb_modular_elliptic_p(acb_t wp, const acb_t z, const acb_t tau, slong prec) - void acb_modular_elliptic_p_zpx(acb_ptr wp, const acb_t z, const acb_t tau, long len, long prec) + void acb_modular_elliptic_p_zpx(acb_ptr wp, const acb_t z, const acb_t tau, slong len, slong prec) - void acb_modular_hilbert_class_poly(fmpz_poly_t res, long D) + void acb_modular_hilbert_class_poly(fmpz_poly_t res, slong D) # Sets *res* to the Hilbert class polynomial of discriminant *D*, # defined as # .. math :: diff --git a/src/sage/libs/flint/acb_poly.pxd b/src/sage/libs/flint/acb_poly.pxd index 8cd0dcda0df..aa6207b1373 100644 --- a/src/sage/libs/flint/acb_poly.pxd +++ b/src/sage/libs/flint/acb_poly.pxd @@ -19,11 +19,11 @@ cdef extern from "flint_wrap.h": # Clears the polynomial, deallocating all coefficients and the # coefficient array. - void acb_poly_fit_length(acb_poly_t poly, long len) + void acb_poly_fit_length(acb_poly_t poly, slong len) # Makes sure that the coefficient array of the polynomial contains at # least *len* initialized coefficients. - void _acb_poly_set_length(acb_poly_t poly, long len) + void _acb_poly_set_length(acb_poly_t poly, slong len) # Directly changes the length of the polynomial, without allocating or # deallocating coefficients. The value should not exceed the allocation length. @@ -33,17 +33,17 @@ cdef extern from "flint_wrap.h": void acb_poly_swap(acb_poly_t poly1, acb_poly_t poly2) # Swaps *poly1* and *poly2* efficiently. - long acb_poly_allocated_bytes(const acb_poly_t x) + slong acb_poly_allocated_bytes(const acb_poly_t x) # Returns the total number of bytes heap-allocated internally by this object. # The count excludes the size of the structure itself. Add # ``sizeof(acb_poly_struct)`` to get the size of the object as a whole. - long acb_poly_length(const acb_poly_t poly) + slong acb_poly_length(const acb_poly_t poly) # Returns the length of *poly*, i.e. zero if *poly* is # identically zero, and otherwise one more than the index # of the highest term that is not identically zero. - long acb_poly_degree(const acb_poly_t poly) + slong acb_poly_degree(const acb_poly_t poly) # Returns the degree of *poly*, defined as one less than its length. # Note that if one or several leading coefficients are balls # containing zero, this value can be larger than the true @@ -68,53 +68,53 @@ cdef extern from "flint_wrap.h": void acb_poly_set(acb_poly_t dest, const acb_poly_t src) # Sets *dest* to a copy of *src*. - void acb_poly_set_round(acb_poly_t dest, const acb_poly_t src, long prec) + void acb_poly_set_round(acb_poly_t dest, const acb_poly_t src, slong prec) # Sets *dest* to a copy of *src*, rounded to *prec* bits. - void acb_poly_set_trunc(acb_poly_t dest, const acb_poly_t src, long n) + void acb_poly_set_trunc(acb_poly_t dest, const acb_poly_t src, slong n) - void acb_poly_set_trunc_round(acb_poly_t dest, const acb_poly_t src, long n, long prec) + void acb_poly_set_trunc_round(acb_poly_t dest, const acb_poly_t src, slong n, slong prec) # Sets *dest* to a copy of *src*, truncated to length *n* and rounded to *prec* bits. - void acb_poly_set_coeff_si(acb_poly_t poly, long n, long c) + void acb_poly_set_coeff_si(acb_poly_t poly, slong n, slong c) - void acb_poly_set_coeff_acb(acb_poly_t poly, long n, const acb_t c) + void acb_poly_set_coeff_acb(acb_poly_t poly, slong n, const acb_t c) # Sets the coefficient with index *n* in *poly* to the value *c*. # We require that *n* is nonnegative. - void acb_poly_get_coeff_acb(acb_t v, const acb_poly_t poly, long n) + void acb_poly_get_coeff_acb(acb_t v, const acb_poly_t poly, slong n) # Sets *v* to the value of the coefficient with index *n* in *poly*. # We require that *n* is nonnegative. - void _acb_poly_shift_right(acb_ptr res, acb_srcptr poly, long len, long n) + void _acb_poly_shift_right(acb_ptr res, acb_srcptr poly, slong len, slong n) - void acb_poly_shift_right(acb_poly_t res, const acb_poly_t poly, long n) + void acb_poly_shift_right(acb_poly_t res, const acb_poly_t poly, slong n) # Sets *res* to *poly* divided by `x^n`, throwing away the lower coefficients. # We require that *n* is nonnegative. - void _acb_poly_shift_left(acb_ptr res, acb_srcptr poly, long len, long n) + void _acb_poly_shift_left(acb_ptr res, acb_srcptr poly, slong len, slong n) - void acb_poly_shift_left(acb_poly_t res, const acb_poly_t poly, long n) + void acb_poly_shift_left(acb_poly_t res, const acb_poly_t poly, slong n) # Sets *res* to *poly* multiplied by `x^n`. # We require that *n* is nonnegative. - void acb_poly_truncate(acb_poly_t poly, long n) + void acb_poly_truncate(acb_poly_t poly, slong n) # Truncates *poly* to have length at most *n*, i.e. degree # strictly smaller than *n*. We require that *n* is nonnegative. - long acb_poly_valuation(const acb_poly_t poly) + slong acb_poly_valuation(const acb_poly_t poly) # Returns the degree of the lowest term that is not exactly zero in *poly*. # Returns -1 if *poly* is the zero polynomial. - void acb_poly_printd(const acb_poly_t poly, long digits) + void acb_poly_printd(const acb_poly_t poly, slong digits) # Prints the polynomial as an array of coefficients, printing each # coefficient using *acb_printd*. - void acb_poly_fprintd(FILE * file, const acb_poly_t poly, long digits) + void acb_poly_fprintd(FILE * file, const acb_poly_t poly, slong digits) # Prints the polynomial as an array of coefficients to the stream *file*, # printing each coefficient using *acb_fprintd*. - void acb_poly_randtest(acb_poly_t poly, flint_rand_t state, long len, long prec, long mag_bits) + void acb_poly_randtest(acb_poly_t poly, flint_rand_t state, slong len, slong prec, slong mag_bits) # Creates a random polynomial with length at most *len*. int acb_poly_equal(const acb_poly_t A, const acb_poly_t B) @@ -127,7 +127,7 @@ cdef extern from "flint_wrap.h": int acb_poly_contains_fmpq_poly(const acb_poly_t poly1, const fmpq_poly_t poly2) # Returns nonzero iff *poly2* is contained in *poly1*. - int _acb_poly_overlaps(acb_srcptr poly1, long len1, acb_srcptr poly2, long len2) + int _acb_poly_overlaps(acb_srcptr poly1, slong len1, acb_srcptr poly2, slong len2) int acb_poly_overlaps(const acb_poly_t poly1, const acb_poly_t poly2) # Returns nonzero iff *poly1* overlaps with *poly2*. The underscore @@ -141,73 +141,73 @@ cdef extern from "flint_wrap.h": int acb_poly_is_real(const acb_poly_t poly) # Returns nonzero iff all coefficients in *poly* have zero imaginary part. - void acb_poly_set_fmpz_poly(acb_poly_t poly, const fmpz_poly_t re, long prec) + void acb_poly_set_fmpz_poly(acb_poly_t poly, const fmpz_poly_t re, slong prec) - void acb_poly_set2_fmpz_poly(acb_poly_t poly, const fmpz_poly_t re, const fmpz_poly_t im, long prec) + void acb_poly_set2_fmpz_poly(acb_poly_t poly, const fmpz_poly_t re, const fmpz_poly_t im, slong prec) void acb_poly_set_arb_poly(acb_poly_t poly, const arb_poly_t re) void acb_poly_set2_arb_poly(acb_poly_t poly, const arb_poly_t re, const arb_poly_t im) - void acb_poly_set_fmpq_poly(acb_poly_t poly, const fmpq_poly_t re, long prec) + void acb_poly_set_fmpq_poly(acb_poly_t poly, const fmpq_poly_t re, slong prec) - void acb_poly_set2_fmpq_poly(acb_poly_t poly, const fmpq_poly_t re, const fmpq_poly_t im, long prec) + void acb_poly_set2_fmpq_poly(acb_poly_t poly, const fmpq_poly_t re, const fmpq_poly_t im, slong prec) # Sets *poly* to the given real part *re* plus the imaginary part *im*, # both rounded to *prec* bits. void acb_poly_set_acb(acb_poly_t poly, const acb_t src) - void acb_poly_set_si(acb_poly_t poly, long src) + void acb_poly_set_si(acb_poly_t poly, slong src) # Sets *poly* to *src*. - void _acb_poly_majorant(arb_ptr res, acb_srcptr poly, long len, long prec) + void _acb_poly_majorant(arb_ptr res, acb_srcptr poly, slong len, slong prec) - void acb_poly_majorant(arb_poly_t res, const acb_poly_t poly, long prec) + void acb_poly_majorant(arb_poly_t res, const acb_poly_t poly, slong prec) # Sets *res* to an exact real polynomial whose coefficients are # upper bounds for the absolute values of the coefficients in *poly*, # rounded to *prec* bits. - void _acb_poly_add(acb_ptr C, acb_srcptr A, long lenA, acb_srcptr B, long lenB, long prec) + void _acb_poly_add(acb_ptr C, acb_srcptr A, slong lenA, acb_srcptr B, slong lenB, slong prec) # Sets *{C, max(lenA, lenB)}* to the sum of *{A, lenA}* and *{B, lenB}*. # Allows aliasing of the input and output operands. - void acb_poly_add(acb_poly_t C, const acb_poly_t A, const acb_poly_t B, long prec) + void acb_poly_add(acb_poly_t C, const acb_poly_t A, const acb_poly_t B, slong prec) - void acb_poly_add_si(acb_poly_t C, const acb_poly_t A, long B, long prec) + void acb_poly_add_si(acb_poly_t C, const acb_poly_t A, slong B, slong prec) # Sets *C* to the sum of *A* and *B*. - void _acb_poly_sub(acb_ptr C, acb_srcptr A, long lenA, acb_srcptr B, long lenB, long prec) + void _acb_poly_sub(acb_ptr C, acb_srcptr A, slong lenA, acb_srcptr B, slong lenB, slong prec) # Sets *{C, max(lenA, lenB)}* to the difference of *{A, lenA}* and *{B, lenB}*. # Allows aliasing of the input and output operands. - void acb_poly_sub(acb_poly_t C, const acb_poly_t A, const acb_poly_t B, long prec) + void acb_poly_sub(acb_poly_t C, const acb_poly_t A, const acb_poly_t B, slong prec) # Sets *C* to the difference of *A* and *B*. - void acb_poly_add_series(acb_poly_t C, const acb_poly_t A, const acb_poly_t B, long len, long prec) + void acb_poly_add_series(acb_poly_t C, const acb_poly_t A, const acb_poly_t B, slong len, slong prec) # Sets *C* to the sum of *A* and *B*, truncated to length *len*. - void acb_poly_sub_series(acb_poly_t C, const acb_poly_t A, const acb_poly_t B, long len, long prec) + void acb_poly_sub_series(acb_poly_t C, const acb_poly_t A, const acb_poly_t B, slong len, slong prec) # Sets *C* to the difference of *A* and *B*, truncated to length *len*. void acb_poly_neg(acb_poly_t C, const acb_poly_t A) # Sets *C* to the negation of *A*. - void acb_poly_scalar_mul_2exp_si(acb_poly_t C, const acb_poly_t A, long c) + void acb_poly_scalar_mul_2exp_si(acb_poly_t C, const acb_poly_t A, slong c) # Sets *C* to *A* multiplied by `2^c`. - void acb_poly_scalar_mul(acb_poly_t C, const acb_poly_t A, const acb_t c, long prec) + void acb_poly_scalar_mul(acb_poly_t C, const acb_poly_t A, const acb_t c, slong prec) # Sets *C* to *A* multiplied by *c*. - void acb_poly_scalar_div(acb_poly_t C, const acb_poly_t A, const acb_t c, long prec) + void acb_poly_scalar_div(acb_poly_t C, const acb_poly_t A, const acb_t c, slong prec) # Sets *C* to *A* divided by *c*. - void _acb_poly_mullow_classical(acb_ptr C, acb_srcptr A, long lenA, acb_srcptr B, long lenB, long n, long prec) + void _acb_poly_mullow_classical(acb_ptr C, acb_srcptr A, slong lenA, acb_srcptr B, slong lenB, slong n, slong prec) - void _acb_poly_mullow_transpose(acb_ptr C, acb_srcptr A, long lenA, acb_srcptr B, long lenB, long n, long prec) + void _acb_poly_mullow_transpose(acb_ptr C, acb_srcptr A, slong lenA, acb_srcptr B, slong lenB, slong n, slong prec) - void _acb_poly_mullow_transpose_gauss(acb_ptr C, acb_srcptr A, long lenA, acb_srcptr B, long lenB, long n, long prec) + void _acb_poly_mullow_transpose_gauss(acb_ptr C, acb_srcptr A, slong lenA, acb_srcptr B, slong lenB, slong n, slong prec) - void _acb_poly_mullow(acb_ptr C, acb_srcptr A, long lenA, acb_srcptr B, long lenB, long n, long prec) + void _acb_poly_mullow(acb_ptr C, acb_srcptr A, slong lenA, acb_srcptr B, slong lenB, slong n, slong prec) # Sets *{C, n}* to the product of *{A, lenA}* and *{B, lenB}*, truncated to # length *n*. The output is not allowed to be aliased with either of the # inputs. We require `\mathrm{lenA} \ge \mathrm{lenB} > 0`, @@ -225,18 +225,18 @@ cdef extern from "flint_wrap.h": # they are assumed to represent the same polynomial, and its # square is computed. - void acb_poly_mullow_classical(acb_poly_t C, const acb_poly_t A, const acb_poly_t B, long n, long prec) + void acb_poly_mullow_classical(acb_poly_t C, const acb_poly_t A, const acb_poly_t B, slong n, slong prec) - void acb_poly_mullow_transpose(acb_poly_t C, const acb_poly_t A, const acb_poly_t B, long n, long prec) + void acb_poly_mullow_transpose(acb_poly_t C, const acb_poly_t A, const acb_poly_t B, slong n, slong prec) - void acb_poly_mullow_transpose_gauss(acb_poly_t C, const acb_poly_t A, const acb_poly_t B, long n, long prec) + void acb_poly_mullow_transpose_gauss(acb_poly_t C, const acb_poly_t A, const acb_poly_t B, slong n, slong prec) - void acb_poly_mullow(acb_poly_t C, const acb_poly_t A, const acb_poly_t B, long n, long prec) + void acb_poly_mullow(acb_poly_t C, const acb_poly_t A, const acb_poly_t B, slong n, slong prec) # Sets *C* to the product of *A* and *B*, truncated to length *n*. # If the same variable is passed for *A* and *B*, sets *C* to the # square of *A* truncated to length *n*. - void _acb_poly_mul(acb_ptr C, acb_srcptr A, long lenA, acb_srcptr B, long lenB, long prec) + void _acb_poly_mul(acb_ptr C, acb_srcptr A, slong lenA, acb_srcptr B, slong lenB, slong prec) # Sets *{C, lenA + lenB - 1}* to the product of *{A, lenA}* and *{B, lenB}*. # The output is not allowed to be aliased with either of the # inputs. We require `\mathrm{lenA} \ge \mathrm{lenB} > 0`. @@ -245,31 +245,31 @@ cdef extern from "flint_wrap.h": # they are assumed to represent the same polynomial, and its # square is computed. - void acb_poly_mul(acb_poly_t C, const acb_poly_t A1, const acb_poly_t B2, long prec) + void acb_poly_mul(acb_poly_t C, const acb_poly_t A1, const acb_poly_t B2, slong prec) # Sets *C* to the product of *A* and *B*. # If the same variable is passed for *A* and *B*, sets *C* to # the square of *A*. - void _acb_poly_inv_series(acb_ptr Qinv, acb_srcptr Q, long Qlen, long len, long prec) + void _acb_poly_inv_series(acb_ptr Qinv, acb_srcptr Q, slong Qlen, slong len, slong prec) # Sets *{Qinv, len}* to the power series inverse of *{Q, Qlen}*. Uses Newton iteration. - void acb_poly_inv_series(acb_poly_t Qinv, const acb_poly_t Q, long n, long prec) + void acb_poly_inv_series(acb_poly_t Qinv, const acb_poly_t Q, slong n, slong prec) # Sets *Qinv* to the power series inverse of *Q*. - void _acb_poly_div_series(acb_ptr Q, acb_srcptr A, long Alen, acb_srcptr B, long Blen, long n, long prec) + void _acb_poly_div_series(acb_ptr Q, acb_srcptr A, slong Alen, acb_srcptr B, slong Blen, slong n, slong prec) # Sets *{Q, n}* to the power series quotient of *{A, Alen}* by *{B, Blen}*. # Uses Newton iteration followed by multiplication. - void acb_poly_div_series(acb_poly_t Q, const acb_poly_t A, const acb_poly_t B, long n, long prec) + void acb_poly_div_series(acb_poly_t Q, const acb_poly_t A, const acb_poly_t B, slong n, slong prec) # Sets *Q* to the power series quotient *A* divided by *B*, truncated to length *n*. - void _acb_poly_div(acb_ptr Q, acb_srcptr A, long lenA, acb_srcptr B, long lenB, long prec) + void _acb_poly_div(acb_ptr Q, acb_srcptr A, slong lenA, acb_srcptr B, slong lenB, slong prec) - void _acb_poly_rem(acb_ptr R, acb_srcptr A, long lenA, acb_srcptr B, long lenB, long prec) + void _acb_poly_rem(acb_ptr R, acb_srcptr A, slong lenA, acb_srcptr B, slong lenB, slong prec) - void _acb_poly_divrem(acb_ptr Q, acb_ptr R, acb_srcptr A, long lenA, acb_srcptr B, long lenB, long prec) + void _acb_poly_divrem(acb_ptr Q, acb_ptr R, acb_srcptr A, slong lenA, acb_srcptr B, slong lenB, slong prec) - int acb_poly_divrem(acb_poly_t Q, acb_poly_t R, const acb_poly_t A, const acb_poly_t B, long prec) + int acb_poly_divrem(acb_poly_t Q, acb_poly_t R, const acb_poly_t A, const acb_poly_t B, slong prec) # Performs polynomial division with remainder, computing a quotient `Q` and # a remainder `R` such that `A = BQ + R`. The implementation reverses the # inputs and performs power series division. @@ -277,24 +277,24 @@ cdef extern from "flint_wrap.h": # zero), returns 0 indicating failure without modifying the outputs. # Otherwise returns nonzero. - void _acb_poly_div_root(acb_ptr Q, acb_t R, acb_srcptr A, long len, const acb_t c, long prec) + void _acb_poly_div_root(acb_ptr Q, acb_t R, acb_srcptr A, slong len, const acb_t c, slong prec) # Divides `A` by the polynomial `x - c`, computing the quotient `Q` as well # as the remainder `R = f(c)`. - void _acb_poly_taylor_shift(acb_ptr g, const acb_t c, long n, long prec) - void acb_poly_taylor_shift(acb_poly_t g, const acb_poly_t f, const acb_t c, long prec) + void _acb_poly_taylor_shift(acb_ptr g, const acb_t c, slong n, slong prec) + void acb_poly_taylor_shift(acb_poly_t g, const acb_poly_t f, const acb_t c, slong prec) # Sets *g* to the Taylor shift `f(x+c)`. # The underscore methods act in-place on *g* = *f* which has length *n*. - void _acb_poly_compose(acb_ptr res, acb_srcptr poly1, long len1, acb_srcptr poly2, long len2, long prec) - void acb_poly_compose(acb_poly_t res, const acb_poly_t poly1, const acb_poly_t poly2, long prec) + void _acb_poly_compose(acb_ptr res, acb_srcptr poly1, slong len1, acb_srcptr poly2, slong len2, slong prec) + void acb_poly_compose(acb_poly_t res, const acb_poly_t poly1, const acb_poly_t poly2, slong prec) # Sets *res* to the composition `h(x) = f(g(x))` where `f` is given by # *poly1* and `g` is given by *poly2*. # The underscore method does not support aliasing of the output # with either input polynomial. - void _acb_poly_compose_series(acb_ptr res, acb_srcptr poly1, long len1, acb_srcptr poly2, long len2, long n, long prec) - void acb_poly_compose_series(acb_poly_t res, const acb_poly_t poly1, const acb_poly_t poly2, long n, long prec) + void _acb_poly_compose_series(acb_ptr res, acb_srcptr poly1, slong len1, acb_srcptr poly2, slong len2, slong n, slong prec) + void acb_poly_compose_series(acb_poly_t res, const acb_poly_t poly1, const acb_poly_t poly2, slong n, slong prec) # Sets *res* to the power series composition `h(x) = f(g(x))` truncated # to order `O(x^n)` where `f` is given by *poly1* and `g` is given by *poly2*. # Wraps :func:`_gr_poly_compose_series` which chooses automatically @@ -303,21 +303,21 @@ cdef extern from "flint_wrap.h": # The underscore method does not support aliasing of the output # with either input polynomial. - void _acb_poly_revert_series_lagrange(acb_ptr h, acb_srcptr f, long flen, long n, long prec) + void _acb_poly_revert_series_lagrange(acb_ptr h, acb_srcptr f, slong flen, slong n, slong prec) - void acb_poly_revert_series_lagrange(acb_poly_t h, const acb_poly_t f, long n, long prec) + void acb_poly_revert_series_lagrange(acb_poly_t h, const acb_poly_t f, slong n, slong prec) - void _acb_poly_revert_series_newton(acb_ptr h, acb_srcptr f, long flen, long n, long prec) + void _acb_poly_revert_series_newton(acb_ptr h, acb_srcptr f, slong flen, slong n, slong prec) - void acb_poly_revert_series_newton(acb_poly_t h, const acb_poly_t f, long n, long prec) + void acb_poly_revert_series_newton(acb_poly_t h, const acb_poly_t f, slong n, slong prec) - void _acb_poly_revert_series_lagrange_fast(acb_ptr h, acb_srcptr f, long flen, long n, long prec) + void _acb_poly_revert_series_lagrange_fast(acb_ptr h, acb_srcptr f, slong flen, slong n, slong prec) - void acb_poly_revert_series_lagrange_fast(acb_poly_t h, const acb_poly_t f, long n, long prec) + void acb_poly_revert_series_lagrange_fast(acb_poly_t h, const acb_poly_t f, slong n, slong prec) - void _acb_poly_revert_series(acb_ptr h, acb_srcptr f, long flen, long n, long prec) + void _acb_poly_revert_series(acb_ptr h, acb_srcptr f, slong flen, slong n, slong prec) - void acb_poly_revert_series(acb_poly_t h, const acb_poly_t f, long n, long prec) + void acb_poly_revert_series(acb_poly_t h, const acb_poly_t f, slong n, slong prec) # Sets `h` to the power series reversion of `f`, i.e. the expansion # of the compositional inverse function `f^{-1}(x)`, # truncated to order `O(x^n)`, using respectively @@ -327,31 +327,31 @@ cdef extern from "flint_wrap.h": # linear term is nonzero. The underscore methods assume that *flen* # is at least 2, and do not support aliasing. - void _acb_poly_evaluate_horner(acb_t y, acb_srcptr f, long len, const acb_t x, long prec) + void _acb_poly_evaluate_horner(acb_t y, acb_srcptr f, slong len, const acb_t x, slong prec) - void acb_poly_evaluate_horner(acb_t y, const acb_poly_t f, const acb_t x, long prec) + void acb_poly_evaluate_horner(acb_t y, const acb_poly_t f, const acb_t x, slong prec) - void _acb_poly_evaluate_rectangular(acb_t y, acb_srcptr f, long len, const acb_t x, long prec) + void _acb_poly_evaluate_rectangular(acb_t y, acb_srcptr f, slong len, const acb_t x, slong prec) - void acb_poly_evaluate_rectangular(acb_t y, const acb_poly_t f, const acb_t x, long prec) + void acb_poly_evaluate_rectangular(acb_t y, const acb_poly_t f, const acb_t x, slong prec) - void _acb_poly_evaluate(acb_t y, acb_srcptr f, long len, const acb_t x, long prec) + void _acb_poly_evaluate(acb_t y, acb_srcptr f, slong len, const acb_t x, slong prec) - void acb_poly_evaluate(acb_t y, const acb_poly_t f, const acb_t x, long prec) + void acb_poly_evaluate(acb_t y, const acb_poly_t f, const acb_t x, slong prec) # Sets `y = f(x)`, evaluated respectively using Horner's rule, # rectangular splitting, and an automatic algorithm choice. - void _acb_poly_evaluate2_horner(acb_t y, acb_t z, acb_srcptr f, long len, const acb_t x, long prec) + void _acb_poly_evaluate2_horner(acb_t y, acb_t z, acb_srcptr f, slong len, const acb_t x, slong prec) - void acb_poly_evaluate2_horner(acb_t y, acb_t z, const acb_poly_t f, const acb_t x, long prec) + void acb_poly_evaluate2_horner(acb_t y, acb_t z, const acb_poly_t f, const acb_t x, slong prec) - void _acb_poly_evaluate2_rectangular(acb_t y, acb_t z, acb_srcptr f, long len, const acb_t x, long prec) + void _acb_poly_evaluate2_rectangular(acb_t y, acb_t z, acb_srcptr f, slong len, const acb_t x, slong prec) - void acb_poly_evaluate2_rectangular(acb_t y, acb_t z, const acb_poly_t f, const acb_t x, long prec) + void acb_poly_evaluate2_rectangular(acb_t y, acb_t z, const acb_poly_t f, const acb_t x, slong prec) - void _acb_poly_evaluate2(acb_t y, acb_t z, acb_srcptr f, long len, const acb_t x, long prec) + void _acb_poly_evaluate2(acb_t y, acb_t z, acb_srcptr f, slong len, const acb_t x, slong prec) - void acb_poly_evaluate2(acb_t y, acb_t z, const acb_poly_t f, const acb_t x, long prec) + void acb_poly_evaluate2(acb_t y, acb_t z, const acb_poly_t f, const acb_t x, slong prec) # Sets `y = f(x), z = f'(x)`, evaluated respectively using Horner's rule, # rectangular splitting, and an automatic algorithm choice. # When Horner's rule is used, the only advantage of evaluating the @@ -360,123 +360,123 @@ cdef extern from "flint_wrap.h": # With the rectangular splitting algorithm, the powers can be reused, # making simultaneous evaluation slightly faster. - void _acb_poly_product_roots(acb_ptr poly, acb_srcptr xs, long n, long prec) + void _acb_poly_product_roots(acb_ptr poly, acb_srcptr xs, slong n, slong prec) - void acb_poly_product_roots(acb_poly_t poly, acb_srcptr xs, long n, long prec) + void acb_poly_product_roots(acb_poly_t poly, acb_srcptr xs, slong n, slong prec) # Generates the polynomial `(x-x_0)(x-x_1)\cdots(x-x_{n-1})`. - acb_ptr * _acb_poly_tree_alloc(long len) + acb_ptr * _acb_poly_tree_alloc(slong len) # Returns an initialized data structured capable of representing a # remainder tree (product tree) of *len* roots. - void _acb_poly_tree_free(acb_ptr * tree, long len) + void _acb_poly_tree_free(acb_ptr * tree, slong len) # Deallocates a tree structure as allocated using *_acb_poly_tree_alloc*. - void _acb_poly_tree_build(acb_ptr * tree, acb_srcptr roots, long len, long prec) + void _acb_poly_tree_build(acb_ptr * tree, acb_srcptr roots, slong len, slong prec) # Constructs a product tree from a given array of *len* roots. The tree # structure must be pre-allocated to the specified length using # :func:`_acb_poly_tree_alloc`. - void _acb_poly_evaluate_vec_iter(acb_ptr ys, acb_srcptr poly, long plen, acb_srcptr xs, long n, long prec) + void _acb_poly_evaluate_vec_iter(acb_ptr ys, acb_srcptr poly, slong plen, acb_srcptr xs, slong n, slong prec) - void acb_poly_evaluate_vec_iter(acb_ptr ys, const acb_poly_t poly, acb_srcptr xs, long n, long prec) + void acb_poly_evaluate_vec_iter(acb_ptr ys, const acb_poly_t poly, acb_srcptr xs, slong n, slong prec) # Evaluates the polynomial simultaneously at *n* given points, calling # :func:`_acb_poly_evaluate` repeatedly. - void _acb_poly_evaluate_vec_fast_precomp(acb_ptr vs, acb_srcptr poly, long plen, acb_ptr * tree, long len, long prec) + void _acb_poly_evaluate_vec_fast_precomp(acb_ptr vs, acb_srcptr poly, slong plen, acb_ptr * tree, slong len, slong prec) - void _acb_poly_evaluate_vec_fast(acb_ptr ys, acb_srcptr poly, long plen, acb_srcptr xs, long n, long prec) + void _acb_poly_evaluate_vec_fast(acb_ptr ys, acb_srcptr poly, slong plen, acb_srcptr xs, slong n, slong prec) - void acb_poly_evaluate_vec_fast(acb_ptr ys, const acb_poly_t poly, acb_srcptr xs, long n, long prec) + void acb_poly_evaluate_vec_fast(acb_ptr ys, const acb_poly_t poly, acb_srcptr xs, slong n, slong prec) # Evaluates the polynomial simultaneously at *n* given points, using # fast multipoint evaluation. - void _acb_poly_interpolate_newton(acb_ptr poly, acb_srcptr xs, acb_srcptr ys, long n, long prec) + void _acb_poly_interpolate_newton(acb_ptr poly, acb_srcptr xs, acb_srcptr ys, slong n, slong prec) - void acb_poly_interpolate_newton(acb_poly_t poly, acb_srcptr xs, acb_srcptr ys, long n, long prec) + void acb_poly_interpolate_newton(acb_poly_t poly, acb_srcptr xs, acb_srcptr ys, slong n, slong prec) # Recovers the unique polynomial of length at most *n* that interpolates # the given *x* and *y* values. This implementation first interpolates in the # Newton basis and then converts back to the monomial basis. - void _acb_poly_interpolate_barycentric(acb_ptr poly, acb_srcptr xs, acb_srcptr ys, long n, long prec) + void _acb_poly_interpolate_barycentric(acb_ptr poly, acb_srcptr xs, acb_srcptr ys, slong n, slong prec) - void acb_poly_interpolate_barycentric(acb_poly_t poly, acb_srcptr xs, acb_srcptr ys, long n, long prec) + void acb_poly_interpolate_barycentric(acb_poly_t poly, acb_srcptr xs, acb_srcptr ys, slong n, slong prec) # Recovers the unique polynomial of length at most *n* that interpolates # the given *x* and *y* values. This implementation uses the barycentric # form of Lagrange interpolation. - void _acb_poly_interpolation_weights(acb_ptr w, acb_ptr * tree, long len, long prec) + void _acb_poly_interpolation_weights(acb_ptr w, acb_ptr * tree, slong len, slong prec) - void _acb_poly_interpolate_fast_precomp(acb_ptr poly, acb_srcptr ys, acb_ptr * tree, acb_srcptr weights, long len, long prec) + void _acb_poly_interpolate_fast_precomp(acb_ptr poly, acb_srcptr ys, acb_ptr * tree, acb_srcptr weights, slong len, slong prec) - void _acb_poly_interpolate_fast(acb_ptr poly, acb_srcptr xs, acb_srcptr ys, long len, long prec) + void _acb_poly_interpolate_fast(acb_ptr poly, acb_srcptr xs, acb_srcptr ys, slong len, slong prec) - void acb_poly_interpolate_fast(acb_poly_t poly, acb_srcptr xs, acb_srcptr ys, long n, long prec) + void acb_poly_interpolate_fast(acb_poly_t poly, acb_srcptr xs, acb_srcptr ys, slong n, slong prec) # Recovers the unique polynomial of length at most *n* that interpolates # the given *x* and *y* values, using fast Lagrange interpolation. # The precomp function takes a precomputed product tree over the # *x* values and a vector of interpolation weights as additional inputs. - void _acb_poly_derivative(acb_ptr res, acb_srcptr poly, long len, long prec) + void _acb_poly_derivative(acb_ptr res, acb_srcptr poly, slong len, slong prec) # Sets *{res, len - 1}* to the derivative of *{poly, len}*. # Allows aliasing of the input and output. - void acb_poly_derivative(acb_poly_t res, const acb_poly_t poly, long prec) + void acb_poly_derivative(acb_poly_t res, const acb_poly_t poly, slong prec) # Sets *res* to the derivative of *poly*. - void _acb_poly_nth_derivative(acb_ptr res, acb_srcptr poly, unsigned long n, long len, long prec) + void _acb_poly_nth_derivative(acb_ptr res, acb_srcptr poly, ulong n, slong len, slong prec) # Sets *{res, len - n}* to the nth derivative of *{poly, len}*. Does # nothing if *len <= n*. Allows aliasing of the input and output. - void acb_poly_nth_derivative(acb_poly_t res, const acb_poly_t poly, unsigned long n, long prec) + void acb_poly_nth_derivative(acb_poly_t res, const acb_poly_t poly, ulong n, slong prec) # Sets *res* to the nth derivative of *poly*. - void _acb_poly_integral(acb_ptr res, acb_srcptr poly, long len, long prec) + void _acb_poly_integral(acb_ptr res, acb_srcptr poly, slong len, slong prec) # Sets *{res, len}* to the integral of *{poly, len - 1}*. # Allows aliasing of the input and output. - void acb_poly_integral(acb_poly_t res, const acb_poly_t poly, long prec) + void acb_poly_integral(acb_poly_t res, const acb_poly_t poly, slong prec) # Sets *res* to the integral of *poly*. - void _acb_poly_borel_transform(acb_ptr res, acb_srcptr poly, long len, long prec) + void _acb_poly_borel_transform(acb_ptr res, acb_srcptr poly, slong len, slong prec) - void acb_poly_borel_transform(acb_poly_t res, const acb_poly_t poly, long prec) + void acb_poly_borel_transform(acb_poly_t res, const acb_poly_t poly, slong prec) # Computes the Borel transform of the input polynomial, mapping `\sum_k a_k x^k` # to `\sum_k (a_k / k!) x^k`. The underscore method allows aliasing. - void _acb_poly_inv_borel_transform(acb_ptr res, acb_srcptr poly, long len, long prec) + void _acb_poly_inv_borel_transform(acb_ptr res, acb_srcptr poly, slong len, slong prec) - void acb_poly_inv_borel_transform(acb_poly_t res, const acb_poly_t poly, long prec) + void acb_poly_inv_borel_transform(acb_poly_t res, const acb_poly_t poly, slong prec) # Computes the inverse Borel transform of the input polynomial, mapping `\sum_k a_k x^k` # to `\sum_k a_k k! x^k`. The underscore method allows aliasing. - void _acb_poly_binomial_transform_basecase(acb_ptr b, acb_srcptr a, long alen, long len, long prec) + void _acb_poly_binomial_transform_basecase(acb_ptr b, acb_srcptr a, slong alen, slong len, slong prec) - void acb_poly_binomial_transform_basecase(acb_poly_t b, const acb_poly_t a, long len, long prec) + void acb_poly_binomial_transform_basecase(acb_poly_t b, const acb_poly_t a, slong len, slong prec) - void _acb_poly_binomial_transform_convolution(acb_ptr b, acb_srcptr a, long alen, long len, long prec) + void _acb_poly_binomial_transform_convolution(acb_ptr b, acb_srcptr a, slong alen, slong len, slong prec) - void acb_poly_binomial_transform_convolution(acb_poly_t b, const acb_poly_t a, long len, long prec) + void acb_poly_binomial_transform_convolution(acb_poly_t b, const acb_poly_t a, slong len, slong prec) - void _acb_poly_binomial_transform(acb_ptr b, acb_srcptr a, long alen, long len, long prec) + void _acb_poly_binomial_transform(acb_ptr b, acb_srcptr a, slong alen, slong len, slong prec) - void acb_poly_binomial_transform(acb_poly_t b, const acb_poly_t a, long len, long prec) + void acb_poly_binomial_transform(acb_poly_t b, const acb_poly_t a, slong len, slong prec) # Computes the binomial transform of the input polynomial, truncating # the output to length *len*. See :func:`arb_poly_binomial_transform` for # details. # The underscore methods do not support aliasing, and assume that # the lengths are nonzero. - void _acb_poly_graeffe_transform(acb_ptr b, acb_srcptr a, long len, long prec) + void _acb_poly_graeffe_transform(acb_ptr b, acb_srcptr a, slong len, slong prec) - void acb_poly_graeffe_transform(acb_poly_t b, const acb_poly_t a, long prec) + void acb_poly_graeffe_transform(acb_poly_t b, const acb_poly_t a, slong prec) # Computes the Graeffe transform of input polynomial, which is of length *len*. # See :func:`arb_poly_graeffe_transform` for details. # The underscore method assumes that *a* and *b* are initialized, # *a* is of length *len*, and *b* is of length at least *len*. # Both methods allow aliasing. - void _acb_poly_pow_ui_trunc_binexp(acb_ptr res, acb_srcptr f, long flen, unsigned long exp, long len, long prec) + void _acb_poly_pow_ui_trunc_binexp(acb_ptr res, acb_srcptr f, slong flen, ulong exp, slong len, slong prec) # Sets *{res, len}* to *{f, flen}* raised to the power *exp*, truncated # to length *len*. Requires that *len* is no longer than the length # of the power as computed without truncation (i.e. no zero-padding is performed). @@ -484,19 +484,19 @@ cdef extern from "flint_wrap.h": # that *flen* and *len* are positive. # Uses binary exponentiation. - void acb_poly_pow_ui_trunc_binexp(acb_poly_t res, const acb_poly_t poly, unsigned long exp, long len, long prec) + void acb_poly_pow_ui_trunc_binexp(acb_poly_t res, const acb_poly_t poly, ulong exp, slong len, slong prec) # Sets *res* to *poly* raised to the power *exp*, truncated to length *len*. # Uses binary exponentiation. - void _acb_poly_pow_ui(acb_ptr res, acb_srcptr f, long flen, unsigned long exp, long prec) + void _acb_poly_pow_ui(acb_ptr res, acb_srcptr f, slong flen, ulong exp, slong prec) # Sets *res* to *{f, flen}* raised to the power *exp*. Does not # support aliasing of the input and output, and requires that # *flen* is positive. - void acb_poly_pow_ui(acb_poly_t res, const acb_poly_t poly, unsigned long exp, long prec) + void acb_poly_pow_ui(acb_poly_t res, const acb_poly_t poly, ulong exp, slong prec) # Sets *res* to *poly* raised to the power *exp*. - void _acb_poly_pow_series(acb_ptr h, acb_srcptr f, long flen, acb_srcptr g, long glen, long len, long prec) + void _acb_poly_pow_series(acb_ptr h, acb_srcptr f, slong flen, acb_srcptr g, slong glen, slong len, slong prec) # Sets *{h, len}* to the power series `f(x)^{g(x)} = \exp(g(x) \log f(x))` truncated # to length *len*. This function detects special cases such as *g* being an # exact small integer or `\pm 1/2`, and computes such powers more @@ -504,13 +504,13 @@ cdef extern from "flint_wrap.h": # with either of the input operands. It requires that all lengths # are positive, and assumes that *flen* and *glen* do not exceed *len*. - void acb_poly_pow_series(acb_poly_t h, const acb_poly_t f, const acb_poly_t g, long len, long prec) + void acb_poly_pow_series(acb_poly_t h, const acb_poly_t f, const acb_poly_t g, slong len, slong prec) # Sets *h* to the power series `f(x)^{g(x)} = \exp(g(x) \log f(x))` truncated # to length *len*. This function detects special cases such as *g* being an # exact small integer or `\pm 1/2`, and computes such powers more # efficiently. - void _acb_poly_pow_acb_series(acb_ptr h, acb_srcptr f, long flen, const acb_t g, long len, long prec) + void _acb_poly_pow_acb_series(acb_ptr h, acb_srcptr f, slong flen, const acb_t g, slong len, slong prec) # Sets *{h, len}* to the power series `f(x)^g = \exp(g \log f(x))` truncated # to length *len*. This function detects special cases such as *g* being an # exact small integer or `\pm 1/2`, and computes such powers more @@ -518,44 +518,44 @@ cdef extern from "flint_wrap.h": # with either of the input operands. It requires that all lengths # are positive, and assumes that *flen* does not exceed *len*. - void acb_poly_pow_acb_series(acb_poly_t h, const acb_poly_t f, const acb_t g, long len, long prec) + void acb_poly_pow_acb_series(acb_poly_t h, const acb_poly_t f, const acb_t g, slong len, slong prec) # Sets *h* to the power series `f(x)^g = \exp(g \log f(x))` truncated # to length *len*. - void _acb_poly_sqrt_series(acb_ptr g, acb_srcptr h, long hlen, long n, long prec) + void _acb_poly_sqrt_series(acb_ptr g, acb_srcptr h, slong hlen, slong n, slong prec) - void acb_poly_sqrt_series(acb_poly_t g, const acb_poly_t h, long n, long prec) + void acb_poly_sqrt_series(acb_poly_t g, const acb_poly_t h, slong n, slong prec) # Sets *g* to the power series square root of *h*, truncated to length *n*. # Uses division-free Newton iteration for the reciprocal square root, # followed by a multiplication. # The underscore method does not support aliasing of the input and output # arrays. It requires that *hlen* and *n* are greater than zero. - void _acb_poly_rsqrt_series(acb_ptr g, acb_srcptr h, long hlen, long n, long prec) + void _acb_poly_rsqrt_series(acb_ptr g, acb_srcptr h, slong hlen, slong n, slong prec) - void acb_poly_rsqrt_series(acb_poly_t g, const acb_poly_t h, long n, long prec) + void acb_poly_rsqrt_series(acb_poly_t g, const acb_poly_t h, slong n, slong prec) # Sets *g* to the reciprocal power series square root of *h*, truncated to length *n*. # Uses division-free Newton iteration. # The underscore method does not support aliasing of the input and output # arrays. It requires that *hlen* and *n* are greater than zero. - void _acb_poly_log_series(acb_ptr res, acb_srcptr f, long flen, long n, long prec) + void _acb_poly_log_series(acb_ptr res, acb_srcptr f, slong flen, slong n, slong prec) - void acb_poly_log_series(acb_poly_t res, const acb_poly_t f, long n, long prec) + void acb_poly_log_series(acb_poly_t res, const acb_poly_t f, slong n, slong prec) # Sets *res* to the power series logarithm of *f*, truncated to length *n*. # Uses the formula `\log(f(x)) = \int f'(x) / f(x) dx`, adding the logarithm of the # constant term in *f* as the constant of integration. # The underscore method supports aliasing of the input and output # arrays. It requires that *flen* and *n* are greater than zero. - void _acb_poly_log1p_series(acb_ptr res, acb_srcptr f, long flen, long n, long prec) + void _acb_poly_log1p_series(acb_ptr res, acb_srcptr f, slong flen, slong n, slong prec) - void acb_poly_log1p_series(acb_poly_t res, const acb_poly_t f, long n, long prec) + void acb_poly_log1p_series(acb_poly_t res, const acb_poly_t f, slong n, slong prec) # Computes the power series `\log(1+f)`, with better accuracy when the constant term of *f* is small. - void _acb_poly_atan_series(acb_ptr res, acb_srcptr f, long flen, long n, long prec) + void _acb_poly_atan_series(acb_ptr res, acb_srcptr f, slong flen, slong n, slong prec) - void acb_poly_atan_series(acb_poly_t res, const acb_poly_t f, long n, long prec) + void acb_poly_atan_series(acb_poly_t res, const acb_poly_t f, slong n, slong prec) # Sets *res* the power series inverse tangent of *f*, truncated to length *n*. # Uses the formula # .. math :: @@ -564,13 +564,13 @@ cdef extern from "flint_wrap.h": # The underscore method supports aliasing of the input and output # arrays. It requires that *flen* and *n* are greater than zero. - void _acb_poly_exp_series_basecase(acb_ptr f, acb_srcptr h, long hlen, long n, long prec) + void _acb_poly_exp_series_basecase(acb_ptr f, acb_srcptr h, slong hlen, slong n, slong prec) - void acb_poly_exp_series_basecase(acb_poly_t f, const acb_poly_t h, long n, long prec) + void acb_poly_exp_series_basecase(acb_poly_t f, const acb_poly_t h, slong n, slong prec) - void _acb_poly_exp_series(acb_ptr f, acb_srcptr h, long hlen, long n, long prec) + void _acb_poly_exp_series(acb_ptr f, acb_srcptr h, slong hlen, slong n, slong prec) - void acb_poly_exp_series(acb_poly_t f, const acb_poly_t h, long n, long prec) + void acb_poly_exp_series(acb_poly_t f, const acb_poly_t h, slong n, slong prec) # Sets `f` to the power series exponential of `h`, truncated to length `n`. # The basecase version uses a simple recurrence for the coefficients, # requiring `O(nm)` operations where `m` is the length of `h`. @@ -581,33 +581,33 @@ cdef extern from "flint_wrap.h": # The underscore methods support aliasing and allow the input to be # shorter than the output, but require the lengths to be nonzero. - void _acb_poly_exp_pi_i_series(acb_ptr f, acb_srcptr h, long hlen, long n, long prec) + void _acb_poly_exp_pi_i_series(acb_ptr f, acb_srcptr h, slong hlen, slong n, slong prec) - void acb_poly_exp_pi_i_series(acb_poly_t f, const acb_poly_t h, long n, long prec) + void acb_poly_exp_pi_i_series(acb_poly_t f, const acb_poly_t h, slong n, slong prec) # Sets *f* to the power series `\exp(\pi i h)` truncated to length *n*. # The underscore method supports aliasing and allows the input to be # shorter than the output, but requires the lengths to be nonzero. - void _acb_poly_sin_cos_series(acb_ptr s, acb_ptr c, acb_srcptr h, long hlen, long n, long prec) - void acb_poly_sin_cos_series(acb_poly_t s, acb_poly_t c, const acb_poly_t h, long n, long prec) + void _acb_poly_sin_cos_series(acb_ptr s, acb_ptr c, acb_srcptr h, slong hlen, slong n, slong prec) + void acb_poly_sin_cos_series(acb_poly_t s, acb_poly_t c, const acb_poly_t h, slong n, slong prec) # Sets *s* and *c* to the power series sine and cosine of *h*, computed # simultaneously. # The underscore method supports aliasing and requires the lengths to be nonzero. - void _acb_poly_sin_series(acb_ptr s, acb_srcptr h, long hlen, long n, long prec) + void _acb_poly_sin_series(acb_ptr s, acb_srcptr h, slong hlen, slong n, slong prec) - void acb_poly_sin_series(acb_poly_t s, const acb_poly_t h, long n, long prec) + void acb_poly_sin_series(acb_poly_t s, const acb_poly_t h, slong n, slong prec) - void _acb_poly_cos_series(acb_ptr c, acb_srcptr h, long hlen, long n, long prec) + void _acb_poly_cos_series(acb_ptr c, acb_srcptr h, slong hlen, slong n, slong prec) - void acb_poly_cos_series(acb_poly_t c, const acb_poly_t h, long n, long prec) + void acb_poly_cos_series(acb_poly_t c, const acb_poly_t h, slong n, slong prec) # Respectively evaluates the power series sine or cosine. These functions # simply wrap :func:`_acb_poly_sin_cos_series`. The underscore methods # support aliasing and require the lengths to be nonzero. - void _acb_poly_tan_series(acb_ptr g, acb_srcptr h, long hlen, long len, long prec) + void _acb_poly_tan_series(acb_ptr g, acb_srcptr h, slong hlen, slong len, slong prec) - void acb_poly_tan_series(acb_poly_t g, const acb_poly_t h, long n, long prec) + void acb_poly_tan_series(acb_poly_t g, const acb_poly_t h, slong n, slong prec) # Sets *g* to the power series tangent of *h*. # For small *n* takes the quotient of the sine and cosine as computed # using the basecase algorithm. For large *n*, uses Newton iteration @@ -615,77 +615,77 @@ cdef extern from "flint_wrap.h": # The underscore version does not support aliasing, and requires # the lengths to be nonzero. - void _acb_poly_sin_cos_pi_series(acb_ptr s, acb_ptr c, acb_srcptr h, long hlen, long n, long prec) + void _acb_poly_sin_cos_pi_series(acb_ptr s, acb_ptr c, acb_srcptr h, slong hlen, slong n, slong prec) - void acb_poly_sin_cos_pi_series(acb_poly_t s, acb_poly_t c, const acb_poly_t h, long n, long prec) + void acb_poly_sin_cos_pi_series(acb_poly_t s, acb_poly_t c, const acb_poly_t h, slong n, slong prec) - void _acb_poly_sin_pi_series(acb_ptr s, acb_srcptr h, long hlen, long n, long prec) + void _acb_poly_sin_pi_series(acb_ptr s, acb_srcptr h, slong hlen, slong n, slong prec) - void acb_poly_sin_pi_series(acb_poly_t s, const acb_poly_t h, long n, long prec) + void acb_poly_sin_pi_series(acb_poly_t s, const acb_poly_t h, slong n, slong prec) - void _acb_poly_cos_pi_series(acb_ptr c, acb_srcptr h, long hlen, long n, long prec) + void _acb_poly_cos_pi_series(acb_ptr c, acb_srcptr h, slong hlen, slong n, slong prec) - void acb_poly_cos_pi_series(acb_poly_t c, const acb_poly_t h, long n, long prec) + void acb_poly_cos_pi_series(acb_poly_t c, const acb_poly_t h, slong n, slong prec) - void _acb_poly_cot_pi_series(acb_ptr c, acb_srcptr h, long hlen, long n, long prec) + void _acb_poly_cot_pi_series(acb_ptr c, acb_srcptr h, slong hlen, slong n, slong prec) - void acb_poly_cot_pi_series(acb_poly_t c, const acb_poly_t h, long n, long prec) + void acb_poly_cot_pi_series(acb_poly_t c, const acb_poly_t h, slong n, slong prec) # Compute the respective trigonometric functions of the input # multiplied by `\pi`. - void _acb_poly_sinh_cosh_series_basecase(acb_ptr s, acb_ptr c, acb_srcptr h, long hlen, long n, long prec) + void _acb_poly_sinh_cosh_series_basecase(acb_ptr s, acb_ptr c, acb_srcptr h, slong hlen, slong n, slong prec) - void acb_poly_sinh_cosh_series_basecase(acb_poly_t s, acb_poly_t c, const acb_poly_t h, long n, long prec) + void acb_poly_sinh_cosh_series_basecase(acb_poly_t s, acb_poly_t c, const acb_poly_t h, slong n, slong prec) - void _acb_poly_sinh_cosh_series_exponential(acb_ptr s, acb_ptr c, acb_srcptr h, long hlen, long n, long prec) + void _acb_poly_sinh_cosh_series_exponential(acb_ptr s, acb_ptr c, acb_srcptr h, slong hlen, slong n, slong prec) - void acb_poly_sinh_cosh_series_exponential(acb_poly_t s, acb_poly_t c, const acb_poly_t h, long n, long prec) + void acb_poly_sinh_cosh_series_exponential(acb_poly_t s, acb_poly_t c, const acb_poly_t h, slong n, slong prec) - void _acb_poly_sinh_cosh_series(acb_ptr s, acb_ptr c, acb_srcptr h, long hlen, long n, long prec) + void _acb_poly_sinh_cosh_series(acb_ptr s, acb_ptr c, acb_srcptr h, slong hlen, slong n, slong prec) - void acb_poly_sinh_cosh_series(acb_poly_t s, acb_poly_t c, const acb_poly_t h, long n, long prec) + void acb_poly_sinh_cosh_series(acb_poly_t s, acb_poly_t c, const acb_poly_t h, slong n, slong prec) - void _acb_poly_sinh_series(acb_ptr s, acb_srcptr h, long hlen, long n, long prec) + void _acb_poly_sinh_series(acb_ptr s, acb_srcptr h, slong hlen, slong n, slong prec) - void acb_poly_sinh_series(acb_poly_t s, const acb_poly_t h, long n, long prec) + void acb_poly_sinh_series(acb_poly_t s, const acb_poly_t h, slong n, slong prec) - void _acb_poly_cosh_series(acb_ptr c, acb_srcptr h, long hlen, long n, long prec) + void _acb_poly_cosh_series(acb_ptr c, acb_srcptr h, slong hlen, slong n, slong prec) - void acb_poly_cosh_series(acb_poly_t c, const acb_poly_t h, long n, long prec) + void acb_poly_cosh_series(acb_poly_t c, const acb_poly_t h, slong n, slong prec) # Sets *s* and *c* respectively to the hyperbolic sine and cosine of the # power series *h*, truncated to length *n*. # The implementations mirror those for sine and cosine, except that # the *exponential* version computes both functions using the exponential # function instead of the hyperbolic tangent. - void _acb_poly_sinc_series(acb_ptr s, acb_srcptr h, long hlen, long n, long prec) + void _acb_poly_sinc_series(acb_ptr s, acb_srcptr h, slong hlen, slong n, slong prec) - void acb_poly_sinc_series(acb_poly_t s, const acb_poly_t h, long n, long prec) + void acb_poly_sinc_series(acb_poly_t s, const acb_poly_t h, slong n, slong prec) # Sets *s* to the sinc function of the power series *h*, truncated # to length *n*. - void _acb_poly_lambertw_series(acb_ptr res, acb_srcptr z, long zlen, const fmpz_t k, int flags, long len, long prec) + void _acb_poly_lambertw_series(acb_ptr res, acb_srcptr z, slong zlen, const fmpz_t k, int flags, slong len, slong prec) - void acb_poly_lambertw_series(acb_poly_t res, const acb_poly_t z, const fmpz_t k, int flags, long len, long prec) + void acb_poly_lambertw_series(acb_poly_t res, const acb_poly_t z, const fmpz_t k, int flags, slong len, slong prec) # Sets *res* to branch *k* of the Lambert W function of the power series *z*. # The argument *flags* is reserved for future use. # The underscore method allows aliasing, but assumes that the lengths are nonzero. - void _acb_poly_gamma_series(acb_ptr res, acb_srcptr h, long hlen, long n, long prec) + void _acb_poly_gamma_series(acb_ptr res, acb_srcptr h, slong hlen, slong n, slong prec) - void acb_poly_gamma_series(acb_poly_t res, const acb_poly_t h, long n, long prec) + void acb_poly_gamma_series(acb_poly_t res, const acb_poly_t h, slong n, slong prec) - void _acb_poly_rgamma_series(acb_ptr res, acb_srcptr h, long hlen, long n, long prec) + void _acb_poly_rgamma_series(acb_ptr res, acb_srcptr h, slong hlen, slong n, slong prec) - void acb_poly_rgamma_series(acb_poly_t res, const acb_poly_t h, long n, long prec) + void acb_poly_rgamma_series(acb_poly_t res, const acb_poly_t h, slong n, slong prec) - void _acb_poly_lgamma_series(acb_ptr res, acb_srcptr h, long hlen, long n, long prec) + void _acb_poly_lgamma_series(acb_ptr res, acb_srcptr h, slong hlen, slong n, slong prec) - void acb_poly_lgamma_series(acb_poly_t res, const acb_poly_t h, long n, long prec) + void acb_poly_lgamma_series(acb_poly_t res, const acb_poly_t h, slong n, slong prec) - void _acb_poly_digamma_series(acb_ptr res, acb_srcptr h, long hlen, long n, long prec) + void _acb_poly_digamma_series(acb_ptr res, acb_srcptr h, slong hlen, slong n, slong prec) - void acb_poly_digamma_series(acb_poly_t res, const acb_poly_t h, long n, long prec) + void acb_poly_digamma_series(acb_poly_t res, const acb_poly_t h, slong n, slong prec) # Sets *res* to the series expansion of `\Gamma(h(x))`, `1/\Gamma(h(x))`, # or `\log \Gamma(h(x))`, `\psi(h(x))`, truncated to length *n*. # These functions first generate the Taylor series at the constant @@ -694,16 +694,16 @@ cdef extern from "flint_wrap.h": # The underscore methods support aliasing of the input and output # arrays, and require that *hlen* and *n* are greater than zero. - void _acb_poly_rising_ui_series(acb_ptr res, acb_srcptr f, long flen, unsigned long r, long trunc, long prec) + void _acb_poly_rising_ui_series(acb_ptr res, acb_srcptr f, slong flen, ulong r, slong trunc, slong prec) - void acb_poly_rising_ui_series(acb_poly_t res, const acb_poly_t f, unsigned long r, long trunc, long prec) + void acb_poly_rising_ui_series(acb_poly_t res, const acb_poly_t f, ulong r, slong trunc, slong prec) # Sets *res* to the rising factorial `(f) (f+1) (f+2) \cdots (f+r-1)`, truncated # to length *trunc*. The underscore method assumes that *flen*, *r* and *trunc* # are at least 1, and does not support aliasing. Uses binary splitting. - void _acb_poly_powsum_series_naive(acb_ptr z, const acb_t s, const acb_t a, const acb_t q, long n, long len, long prec) + void _acb_poly_powsum_series_naive(acb_ptr z, const acb_t s, const acb_t a, const acb_t q, slong n, slong len, slong prec) - void _acb_poly_powsum_series_naive_threaded(acb_ptr z, const acb_t s, const acb_t a, const acb_t q, long n, long len, long prec) + void _acb_poly_powsum_series_naive_threaded(acb_ptr z, const acb_t s, const acb_t a, const acb_t q, slong n, slong len, slong prec) # Computes # .. math :: # z = S(s,a,n) = \sum_{k=0}^{n-1} \frac{q^k}{(k+a)^{s+t}} @@ -712,7 +712,7 @@ cdef extern from "flint_wrap.h": # The *threaded* version splits the computation # over the number of threads returned by *flint_get_num_threads()*. - void _acb_poly_powsum_one_series_sieved(acb_ptr z, const acb_t s, long n, long len, long prec) + void _acb_poly_powsum_one_series_sieved(acb_ptr z, const acb_t s, slong n, slong len, slong prec) # Computes # .. math :: # z = S(s,1,n) \sum_{k=1}^n \frac{1}{k^{s+t}} @@ -726,23 +726,23 @@ cdef extern from "flint_wrap.h": # power series multiplications, it is only faster than the naive # algorithm when *len* is small. - void _acb_poly_zeta_em_choose_param(mag_t bound, unsigned long * N, unsigned long * M, const acb_t s, const acb_t a, long d, long target, long prec) + void _acb_poly_zeta_em_choose_param(mag_t bound, ulong * N, ulong * M, const acb_t s, const acb_t a, slong d, slong target, slong prec) # Chooses *N* and *M* for Euler-Maclaurin summation of the # Hurwitz zeta function, using a default algorithm. - void _acb_poly_zeta_em_bound1(mag_t bound, const acb_t s, const acb_t a, long N, long M, long d, long wp) + void _acb_poly_zeta_em_bound1(mag_t bound, const acb_t s, const acb_t a, slong N, slong M, slong d, slong wp) - void _acb_poly_zeta_em_bound(arb_ptr vec, const acb_t s, const acb_t a, unsigned long N, unsigned long M, long d, long wp) + void _acb_poly_zeta_em_bound(arb_ptr vec, const acb_t s, const acb_t a, ulong N, ulong M, slong d, slong wp) # Compute bounds for Euler-Maclaurin evaluation of the Hurwitz zeta function # or its power series, using the formulas in [Joh2013]_. - void _acb_poly_zeta_em_tail_naive(acb_ptr z, const acb_t s, const acb_t Na, acb_srcptr Nasx, long M, long len, long prec) + void _acb_poly_zeta_em_tail_naive(acb_ptr z, const acb_t s, const acb_t Na, acb_srcptr Nasx, slong M, slong len, slong prec) - void _acb_poly_zeta_em_tail_bsplit(acb_ptr z, const acb_t s, const acb_t Na, acb_srcptr Nasx, long M, long len, long prec) + void _acb_poly_zeta_em_tail_bsplit(acb_ptr z, const acb_t s, const acb_t Na, acb_srcptr Nasx, slong M, slong len, slong prec) # Evaluates the tail in the Euler-Maclaurin sum for the Hurwitz zeta # function, respectively using the naive recurrence and binary splitting. - void _acb_poly_zeta_em_sum(acb_ptr z, const acb_t s, const acb_t a, int deflate, unsigned long N, unsigned long M, long d, long prec) + void _acb_poly_zeta_em_sum(acb_ptr z, const acb_t s, const acb_t a, int deflate, ulong N, ulong M, slong d, slong prec) # Evaluates the truncated Euler-Maclaurin sum of order `N, M` for the # length-*d* truncated Taylor series of the Hurwitz zeta function # `\zeta(s,a)` at `s`, using a working precision of *prec* bits. @@ -750,16 +750,16 @@ cdef extern from "flint_wrap.h": # If *deflate* is nonzero, `\zeta(s,a) - 1/(s-1)` is evaluated # (which permits series expansion at `s = 1`). - void _acb_poly_zeta_cpx_series(acb_ptr z, const acb_t s, const acb_t a, int deflate, long d, long prec) + void _acb_poly_zeta_cpx_series(acb_ptr z, const acb_t s, const acb_t a, int deflate, slong d, slong prec) # Computes the series expansion of `\zeta(s+x,a)` (or # `\zeta(s+x,a) - 1/(s+x-1)` if *deflate* is nonzero) to order *d*. # This function wraps :func:`_acb_poly_zeta_em_sum`, automatically choosing # default values for `N, M` using :func:`_acb_poly_zeta_em_choose_param` to # target an absolute truncation error of `2^{-\operatorname{prec}}`. - void _acb_poly_zeta_series(acb_ptr res, acb_srcptr h, long hlen, const acb_t a, int deflate, long len, long prec) + void _acb_poly_zeta_series(acb_ptr res, acb_srcptr h, slong hlen, const acb_t a, int deflate, slong len, slong prec) - void acb_poly_zeta_series(acb_poly_t res, const acb_poly_t f, const acb_t a, int deflate, long n, long prec) + void acb_poly_zeta_series(acb_poly_t res, const acb_poly_t f, const acb_t a, int deflate, slong n, slong prec) # Sets *res* to the Hurwitz zeta function `\zeta(s,a)` where `s` a power # series and `a` is a constant, truncated to length *n*. # To evaluate the usual Riemann zeta function, set `a = 1`. @@ -772,11 +772,11 @@ cdef extern from "flint_wrap.h": # If `a = 1`, this implementation uses the reflection formula if the midpoint # of the constant term of `s` is negative. - void _acb_poly_polylog_cpx_small(acb_ptr w, const acb_t s, const acb_t z, long len, long prec) + void _acb_poly_polylog_cpx_small(acb_ptr w, const acb_t s, const acb_t z, slong len, slong prec) - void _acb_poly_polylog_cpx_zeta(acb_ptr w, const acb_t s, const acb_t z, long len, long prec) + void _acb_poly_polylog_cpx_zeta(acb_ptr w, const acb_t s, const acb_t z, slong len, slong prec) - void _acb_poly_polylog_cpx(acb_ptr w, const acb_t s, const acb_t z, long len, long prec) + void _acb_poly_polylog_cpx(acb_ptr w, const acb_t s, const acb_t z, slong len, slong prec) # Sets *w* to the Taylor series with respect to *x* of the polylogarithm # `\operatorname{Li}_{s+x}(z)`, where *s* and *z* are given complex # constants. The output is computed to length *len* which must be positive. @@ -788,37 +788,37 @@ cdef extern from "flint_wrap.h": # when *z* is close to zero, and the *zeta* version otherwise. # For further details, see :ref:`algorithms_polylogarithms`. - void _acb_poly_polylog_series(acb_ptr w, acb_srcptr s, long slen, const acb_t z, long len, long prec) + void _acb_poly_polylog_series(acb_ptr w, acb_srcptr s, slong slen, const acb_t z, slong len, slong prec) - void acb_poly_polylog_series(acb_poly_t w, const acb_poly_t s, const acb_t z, long len, long prec) + void acb_poly_polylog_series(acb_poly_t w, const acb_poly_t s, const acb_t z, slong len, slong prec) # Sets *w* to the polylogarithm `\operatorname{Li}_{s}(z)` where *s* is a given # power series, truncating the output to length *len*. The underscore method # requires all lengths to be positive and supports aliasing between # all inputs and outputs. - void _acb_poly_erf_series(acb_ptr res, acb_srcptr z, long zlen, long n, long prec) + void _acb_poly_erf_series(acb_ptr res, acb_srcptr z, slong zlen, slong n, slong prec) - void acb_poly_erf_series(acb_poly_t res, const acb_poly_t z, long n, long prec) + void acb_poly_erf_series(acb_poly_t res, const acb_poly_t z, slong n, slong prec) # Sets *res* to the error function of the power series *z*, truncated to length *n*. # These methods are provided for backwards compatibility. # See :func:`acb_hypgeom_erf_series`, :func:`acb_hypgeom_erfc_series`, # :func:`acb_hypgeom_erfi_series`. - void _acb_poly_agm1_series(acb_ptr res, acb_srcptr z, long zlen, long len, long prec) + void _acb_poly_agm1_series(acb_ptr res, acb_srcptr z, slong zlen, slong len, slong prec) - void acb_poly_agm1_series(acb_poly_t res, const acb_poly_t z, long n, long prec) + void acb_poly_agm1_series(acb_poly_t res, const acb_poly_t z, slong n, slong prec) # Sets *res* to the arithmetic-geometric mean of 1 and the power series *z*, # truncated to length *n*. - void _acb_poly_elliptic_k_series(acb_ptr res, acb_srcptr z, long zlen, long len, long prec) + void _acb_poly_elliptic_k_series(acb_ptr res, acb_srcptr z, slong zlen, slong len, slong prec) - void acb_poly_elliptic_k_series(acb_poly_t res, const acb_poly_t z, long n, long prec) + void acb_poly_elliptic_k_series(acb_poly_t res, const acb_poly_t z, slong n, slong prec) - void _acb_poly_elliptic_p_series(acb_ptr res, acb_srcptr z, long zlen, const acb_t tau, long len, long prec) + void _acb_poly_elliptic_p_series(acb_ptr res, acb_srcptr z, slong zlen, const acb_t tau, slong len, slong prec) - void acb_poly_elliptic_p_series(acb_poly_t res, const acb_poly_t z, const acb_t tau, long n, long prec) + void acb_poly_elliptic_p_series(acb_poly_t res, const acb_poly_t z, const acb_t tau, slong n, slong prec) - void _acb_poly_root_bound_fujiwara(mag_t bound, acb_srcptr poly, long len) + void _acb_poly_root_bound_fujiwara(mag_t bound, acb_srcptr poly, slong len) void acb_poly_root_bound_fujiwara(mag_t bound, acb_poly_t poly) # Sets *bound* to an upper bound for the magnitude of all the complex @@ -832,7 +832,7 @@ cdef extern from "flint_wrap.h": # \right\} # where `a_0, \ldots, a_n` are the coefficients of *poly*. - void _acb_poly_root_inclusion(acb_t r, const acb_t m, acb_srcptr poly, acb_srcptr polyder, long len, long prec) + void _acb_poly_root_inclusion(acb_t r, const acb_t m, acb_srcptr poly, acb_srcptr polyder, slong len, slong prec) # Given any complex number `m`, and a nonconstant polynomial `f` and its # derivative `f'`, sets *r* to a complex interval centered on `m` that is # guaranteed to contain at least one root of `f`. @@ -846,7 +846,7 @@ cdef extern from "flint_wrap.h": # < \frac{n}{r} = \left|\frac{f'(m)}{f(m)}\right| # which is a contradiction (see [Kob2010]_). - long _acb_poly_validate_roots(acb_ptr roots, acb_srcptr poly, long len, long prec) + slong _acb_poly_validate_roots(acb_ptr roots, acb_srcptr poly, slong len, slong prec) # Given a list of approximate roots of the input polynomial, this # function sets a rigorous bounding interval for each root, and determines # which roots are isolated from all the other roots. @@ -858,15 +858,15 @@ cdef extern from "flint_wrap.h": # it is possible that not all of the polynomial's roots are contained # among them. - void _acb_poly_refine_roots_durand_kerner(acb_ptr roots, acb_srcptr poly, long len, long prec) + void _acb_poly_refine_roots_durand_kerner(acb_ptr roots, acb_srcptr poly, slong len, slong prec) # Refines the given roots simultaneously using a single iteration # of the Durand-Kerner method. The radius of each root is set to an # approximation of the correction, giving a rough estimate of its error (not # a rigorous bound). - long _acb_poly_find_roots(acb_ptr roots, acb_srcptr poly, acb_srcptr initial, long len, long maxiter, long prec) + slong _acb_poly_find_roots(acb_ptr roots, acb_srcptr poly, acb_srcptr initial, slong len, slong maxiter, slong prec) - long acb_poly_find_roots(acb_ptr roots, const acb_poly_t poly, acb_srcptr initial, long maxiter, long prec) + slong acb_poly_find_roots(acb_ptr roots, const acb_poly_t poly, acb_srcptr initial, slong maxiter, slong prec) # Attempts to compute all the roots of the given nonzero polynomial *poly* # using a working precision of *prec* bits. If *n* denotes the degree of *poly*, # the function writes *n* approximate roots with rigorous error bounds to @@ -887,9 +887,9 @@ cdef extern from "flint_wrap.h": # roots, the iteration is likely to find them (with low numerical accuracy), # but the error bounds will not converge as the precision increases. - int _acb_poly_validate_real_roots(acb_srcptr roots, acb_srcptr poly, long len, long prec) + int _acb_poly_validate_real_roots(acb_srcptr roots, acb_srcptr poly, slong len, slong prec) - int acb_poly_validate_real_roots(acb_srcptr roots, const acb_poly_t poly, long prec) + int acb_poly_validate_real_roots(acb_srcptr roots, const acb_poly_t poly, slong prec) # Given a strictly real polynomial *poly* (of length *len*) and isolating # intervals for all its complex roots, determines if all the real roots # are separated from the non-real roots. If this function returns nonzero, diff --git a/src/sage/libs/flint/acf.pxd b/src/sage/libs/flint/acf.pxd index 6cd562700e3..8ada9eff7bd 100644 --- a/src/sage/libs/flint/acf.pxd +++ b/src/sage/libs/flint/acf.pxd @@ -21,7 +21,7 @@ cdef extern from "flint_wrap.h": void acf_swap(acf_t z, acf_t x) # Swaps *z* and *x* efficiently. - long acf_allocated_bytes(const acf_t x) + slong acf_allocated_bytes(const acf_t x) # Returns the total number of bytes heap-allocated internally by this object. # The count excludes the size of the structure itself. Add # ``sizeof(acf_struct)`` to get the size of the object as a whole. @@ -36,22 +36,22 @@ cdef extern from "flint_wrap.h": int acf_equal(const acf_t x, const acf_t y) # Returns whether *x* and *y* are equal. - int acf_add(acf_t res, const acf_t x, const acf_t y, long prec, arf_rnd_t rnd) + int acf_add(acf_t res, const acf_t x, const acf_t y, slong prec, arf_rnd_t rnd) - int acf_sub(acf_t res, const acf_t x, const acf_t y, long prec, arf_rnd_t rnd) + int acf_sub(acf_t res, const acf_t x, const acf_t y, slong prec, arf_rnd_t rnd) - int acf_mul(acf_t res, const acf_t x, const acf_t y, long prec, arf_rnd_t rnd) + int acf_mul(acf_t res, const acf_t x, const acf_t y, slong prec, arf_rnd_t rnd) # Sets *res* to the sum, difference or product of *x* or *y*, correctly # rounding the real and imaginary parts in direction *rnd*. # The return flag has the least significant bit set if the real # part is inexact, and the second least significant bit set if # the imaginary part is inexact. - void acf_approx_inv(acf_t res, const acf_t x, long prec, arf_rnd_t rnd) - void acf_approx_div(acf_t res, const acf_t x, const acf_t y, long prec, arf_rnd_t rnd) - void acf_approx_sqrt(acf_t res, const acf_t x, long prec, arf_rnd_t rnd) + void acf_approx_inv(acf_t res, const acf_t x, slong prec, arf_rnd_t rnd) + void acf_approx_div(acf_t res, const acf_t x, const acf_t y, slong prec, arf_rnd_t rnd) + void acf_approx_sqrt(acf_t res, const acf_t x, slong prec, arf_rnd_t rnd) # Computes an approximate inverse, quotient or square root. - void acf_approx_dot(acf_t res, const acf_t initial, int subtract, acf_srcptr x, long xstep, acf_srcptr y, long ystep, long len, long prec, arf_rnd_t rnd) + void acf_approx_dot(acf_t res, const acf_t initial, int subtract, acf_srcptr x, slong xstep, acf_srcptr y, slong ystep, slong len, slong prec, arf_rnd_t rnd) # Computes an approximate dot product, with the same meaning of # the parameters as :func:`arb_dot`. diff --git a/src/sage/libs/flint/aprcl.pxd b/src/sage/libs/flint/aprcl.pxd index 0a480651aa5..64e1d10ac10 100644 --- a/src/sage/libs/flint/aprcl.pxd +++ b/src/sage/libs/flint/aprcl.pxd @@ -46,10 +46,10 @@ cdef extern from "flint_wrap.h": # ``PRIME``, ``COMPOSITE`` and ``PROBABPRIME`` # (if we cannot prove primality). - int aprcl_is_prime_gauss_min_R(const fmpz_t n, unsigned long R) + int aprcl_is_prime_gauss_min_R(const fmpz_t n, ulong R) # Same as :func:`aprcl_is_prime_gauss` with fixed minimum value of `R`. - int aprcl_is_prime_final_division(const fmpz_t n, const fmpz_t s, unsigned long r) + int aprcl_is_prime_final_division(const fmpz_t n, const fmpz_t s, ulong r) # Returns 0 if for some `a = n^k \bmod s`, where `k \in [1, r - 1]`, # we have that `a \mid n`; otherwise returns 1. @@ -58,7 +58,7 @@ cdef extern from "flint_wrap.h": # `s^2 > n` and `s=\prod\limits_{\substack{q-1\mid R \\ q \text{ prime}}}q`. # Also stores factors of `R` and `s`. - void aprcl_config_gauss_init_min_R(aprcl_config conf, const fmpz_t n, unsigned long R) + void aprcl_config_gauss_init_min_R(aprcl_config conf, const fmpz_t n, ulong R) # Computes the `s` with fixed minimum `R` such that `a^R \equiv 1 \mod{s}` # for all integers `a` coprime to `s`. @@ -66,7 +66,7 @@ cdef extern from "flint_wrap.h": # Clears the given ``aprcl_config`` element. It must be reinitialised in # order to be used again. - unsigned long aprcl_R_value(const fmpz_t n) + ulong aprcl_R_value(const fmpz_t n) # Returns a precomputed `R` value for APRCL, such that the # corresponding `s` value is greater than `\sqrt{n}`. The maximum # stored value `6983776800` allows to test numbers up to `6000` digits. @@ -80,7 +80,7 @@ cdef extern from "flint_wrap.h": # Clears the given ``aprcl_config`` element. It must be reinitialised in # order to be used again. - void unity_zp_init(unity_zp f, unsigned long p, unsigned long exp, const fmpz_t n) + void unity_zp_init(unity_zp f, ulong p, ulong exp, const fmpz_t n) # Initializes `f` as an element of `\mathbb{Z}[\zeta_{p^{exp}}]/(n)`. void unity_zp_clear(unity_zp f) @@ -96,7 +96,7 @@ cdef extern from "flint_wrap.h": void unity_zp_set_zero(unity_zp f) # Sets `f` to zero. - long unity_zp_is_unity(unity_zp f) + slong unity_zp_is_unity(unity_zp f) # If `f = \zeta^h` returns h; otherwise returns -1. int unity_zp_equal(unity_zp f, unity_zp g) @@ -106,22 +106,22 @@ cdef extern from "flint_wrap.h": void unity_zp_print(const unity_zp f) # Prints the contents of the `f`. - void unity_zp_coeff_set_fmpz(unity_zp f, unsigned long ind, const fmpz_t x) - void unity_zp_coeff_set_ui(unity_zp f, unsigned long ind, unsigned long x) + void unity_zp_coeff_set_fmpz(unity_zp f, ulong ind, const fmpz_t x) + void unity_zp_coeff_set_ui(unity_zp f, ulong ind, ulong x) # Sets the coefficient of `\zeta^{ind}` to `x`. # `ind` must be less than `p^{exp}`. - void unity_zp_coeff_add_fmpz(unity_zp f, unsigned long ind, const fmpz_t x) - void unity_zp_coeff_add_ui(unity_zp f, unsigned long ind, unsigned long x) + void unity_zp_coeff_add_fmpz(unity_zp f, ulong ind, const fmpz_t x) + void unity_zp_coeff_add_ui(unity_zp f, ulong ind, ulong x) # Adds `x` to the coefficient of `\zeta^{ind}`. # `x` must be less than `n`. # `ind` must be less than `p^{exp}`. - void unity_zp_coeff_inc(unity_zp f, unsigned long ind) + void unity_zp_coeff_inc(unity_zp f, ulong ind) # Increments the coefficient of `\zeta^{ind}`. # `ind` must be less than `p^{exp}`. - void unity_zp_coeff_dec(unity_zp f, unsigned long ind) + void unity_zp_coeff_dec(unity_zp f, ulong ind) # Decrements the coefficient of `\zeta^{ind}`. # `ind` must be less than `p^{exp}`. @@ -129,7 +129,7 @@ cdef extern from "flint_wrap.h": # Sets `f` to `s \cdot g`. `f` and `g` must be initialized with # same `p`, `exp` and `n`. - void unity_zp_mul_scalar_ui(unity_zp f, const unity_zp g, unsigned long s) + void unity_zp_mul_scalar_ui(unity_zp f, const unity_zp g, ulong s) # Sets `f` to `s \cdot g`. `f` and `g` must be initialized with # same `p`, `exp` and `n`. @@ -161,11 +161,11 @@ cdef extern from "flint_wrap.h": # Sets `f` to `g^{pow}`. `f` and `g` must be initialized with # same `p`, `exp` and `n`. - void unity_zp_pow_ui(unity_zp f, const unity_zp g, unsigned long pow) + void unity_zp_pow_ui(unity_zp f, const unity_zp g, ulong pow) # Sets `f` to `g^{pow}`. `f` and `g` must be initialized with # same `p`, `exp` and `n`. - unsigned long _unity_zp_pow_select_k(const fmpz_t n) + ulong _unity_zp_pow_select_k(const fmpz_t n) # Returns the smallest integer `k` satisfying # `\log (n) < (k(k + 1)2^{2k}) / (2^{k + 1} - k - 2) + 1` @@ -173,7 +173,7 @@ cdef extern from "flint_wrap.h": # Sets `f` to `g^{pow}` using the `2^k`-ary exponentiation method. # `f` and `g` must be initialized with same `p`, `exp` and `n`. - void unity_zp_pow_2k_ui(unity_zp f, const unity_zp g, unsigned long pow) + void unity_zp_pow_2k_ui(unity_zp f, const unity_zp g, ulong pow) # Sets `f` to `g^{pow}` using the `2^k`-ary exponentiation method. # `f` and `g` must be initialized with same `p`, `exp` and `n`. @@ -191,28 +191,28 @@ cdef extern from "flint_wrap.h": # Sets `f = g \bmod \Phi_{p^{exp}}`. `\Phi_{p^{exp}}` is the `p^{exp}`-th # cyclotomic polynomial. - void unity_zp_aut(unity_zp f, const unity_zp g, unsigned long x) + void unity_zp_aut(unity_zp f, const unity_zp g, ulong x) # Sets `f = \sigma_x(g)`, the automorphism `\sigma_x(\zeta)=\zeta^x`. # `f` and `g` must be initialized with the same `p`, `exp` and `n`. - void unity_zp_aut_inv(unity_zp f, const unity_zp g, unsigned long x) + void unity_zp_aut_inv(unity_zp f, const unity_zp g, ulong x) # Sets `f = \sigma_x^{-1}(g)`, so `\sigma_x(f) = g`. # `g` must be reduced by `\Phi_{p^{exp}}`. # `f` and `g` must be initialized with the same `p`, `exp` and `n`. - void unity_zp_jacobi_sum_pq(unity_zp f, unsigned long q, unsigned long p) + void unity_zp_jacobi_sum_pq(unity_zp f, ulong q, ulong p) # Sets `f` to the Jacobi sum `J(p, q) = j(\chi_{p, q}, \chi_{p, q})`. - void unity_zp_jacobi_sum_2q_one(unity_zp f, unsigned long q) + void unity_zp_jacobi_sum_2q_one(unity_zp f, ulong q) # Sets `f` to the Jacobi sum # `J_2(q) = j(\chi_{2, q}^{2^{k - 3}}, \chi_{2, q}^{3 \cdot 2^{k - 3}}))^2`. - void unity_zp_jacobi_sum_2q_two(unity_zp f, unsigned long q) + void unity_zp_jacobi_sum_2q_two(unity_zp f, ulong q) # Sets `f` to the Jacobi sum # `J_3(1) = j(\chi_{2, q}, \chi_{2, q}, \chi_{2, q}) = # J(2, q) \cdot j(\chi_{2, q}^2, \chi_{2, q})`. - void unity_zpq_init(unity_zpq f, unsigned long q, unsigned long p, const fmpz_t n) + void unity_zpq_init(unity_zpq f, ulong q, ulong p, const fmpz_t n) # Initializes `f` as an element of `\mathbb{Z}[\zeta_q, \zeta_p]/(n)`. void unity_zpq_clear(unity_zpq f) @@ -230,7 +230,7 @@ cdef extern from "flint_wrap.h": int unity_zpq_equal(const unity_zpq f, const unity_zpq g) # Returns nonzero if `f = g`. - long unity_zpq_p_unity(const unity_zpq f) + slong unity_zpq_p_unity(const unity_zpq f) # If `f = \zeta_p^x` returns `x \in [0, p - 1]`; otherwise returns `p`. int unity_zpq_is_p_unity(const unity_zpq f) @@ -239,15 +239,15 @@ cdef extern from "flint_wrap.h": int unity_zpq_is_p_unity_generator(const unity_zpq f) # Returns nonzero if `f` is a generator of the cyclic group `\langle\zeta_p\rangle`. - void unity_zpq_coeff_set_fmpz(unity_zpq f, long i, long j, const fmpz_t x) + void unity_zpq_coeff_set_fmpz(unity_zpq f, slong i, slong j, const fmpz_t x) # Sets the coefficient of `\zeta_q^i \zeta_p^j` to `x`. # `i` must be less than `q` and `j` must be less than `p`. - void unity_zpq_coeff_set_ui(unity_zpq f, long i, long j, unsigned long x) + void unity_zpq_coeff_set_ui(unity_zpq f, slong i, slong j, ulong x) # Sets the coefficient of `\zeta_q^i \zeta_p^j` to `x`. # `i` must be less than `q` and `j` must be less then `p`. - void unity_zpq_coeff_add(unity_zpq f, long i, long j, const fmpz_t x) + void unity_zpq_coeff_add(unity_zpq f, slong i, slong j, const fmpz_t x) # Adds `x` to the coefficient of `\zeta_p^i \zeta_q^j`. `x` must be less than `n`. void unity_zpq_add(unity_zpq f, const unity_zpq g, const unity_zpq h) @@ -263,17 +263,17 @@ cdef extern from "flint_wrap.h": void _unity_zpq_mul_unity_p(unity_zpq f) # Sets `f = f \cdot \zeta_p`. - void unity_zpq_mul_unity_p_pow(unity_zpq f, const unity_zpq g, long k) + void unity_zpq_mul_unity_p_pow(unity_zpq f, const unity_zpq g, slong k) # Sets `f` to `g \cdot \zeta_p^k`. void unity_zpq_pow(unity_zpq f, const unity_zpq g, const fmpz_t p) # Sets `f` to `g^p`. `f` and `g` must be initialized with same `p`, `q` and `n`. - void unity_zpq_pow_ui(unity_zpq f, const unity_zpq g, unsigned long p) + void unity_zpq_pow_ui(unity_zpq f, const unity_zpq g, ulong p) # Sets `f` to `g^p`. `f` and `g` must be initialized with same `p`, `q` and `n`. - void unity_zpq_gauss_sum(unity_zpq f, unsigned long q, unsigned long p) + void unity_zpq_gauss_sum(unity_zpq f, ulong q, ulong p) # Sets `f = \tau(\chi_{p, q})`. - void unity_zpq_gauss_sum_sigma_pow(unity_zpq f, unsigned long q, unsigned long p) + void unity_zpq_gauss_sum_sigma_pow(unity_zpq f, ulong q, ulong p) # Sets `f = \tau^{\sigma_n}(\chi_{p, q})`. diff --git a/src/sage/libs/flint/arb.pxd b/src/sage/libs/flint/arb.pxd index d9cf87bb01d..a18e6fca1fb 100644 --- a/src/sage/libs/flint/arb.pxd +++ b/src/sage/libs/flint/arb.pxd @@ -19,27 +19,27 @@ cdef extern from "flint_wrap.h": void arb_clear(arb_t x) # Clears the variable *x*, freeing or recycling its allocated memory. - arb_ptr _arb_vec_init(long n) + arb_ptr _arb_vec_init(slong n) # Returns a pointer to an array of *n* initialized :type:`arb_struct` # entries. - void _arb_vec_clear(arb_ptr v, long n) + void _arb_vec_clear(arb_ptr v, slong n) # Clears an array of *n* initialized :type:`arb_struct` entries. void arb_swap(arb_t x, arb_t y) # Swaps *x* and *y* efficiently. - long arb_allocated_bytes(const arb_t x) + slong arb_allocated_bytes(const arb_t x) # Returns the total number of bytes heap-allocated internally by this object. # The count excludes the size of the structure itself. Add # ``sizeof(arb_struct)`` to get the size of the object as a whole. - long _arb_vec_allocated_bytes(arb_srcptr vec, long len) + slong _arb_vec_allocated_bytes(arb_srcptr vec, slong len) # Returns the total number of bytes allocated for this vector, i.e. the # space taken up by the vector itself plus the sum of the internal heap # allocation sizes for all its member elements. - double _arb_vec_estimate_allocated_bytes(long len, long prec) + double _arb_vec_estimate_allocated_bytes(slong len, slong prec) # Estimates the number of bytes that need to be allocated for a vector of # *len* elements with *prec* bits of precision, including the space for # internal limb data. @@ -57,9 +57,9 @@ cdef extern from "flint_wrap.h": void arb_set_arf(arb_t y, const arf_t x) - void arb_set_si(arb_t y, long x) + void arb_set_si(arb_t y, slong x) - void arb_set_ui(arb_t y, unsigned long x) + void arb_set_ui(arb_t y, ulong x) void arb_set_d(arb_t y, double x) @@ -69,21 +69,21 @@ cdef extern from "flint_wrap.h": void arb_set_fmpz_2exp(arb_t y, const fmpz_t x, const fmpz_t e) # Sets *y* to `x \cdot 2^e`. - void arb_set_round(arb_t y, const arb_t x, long prec) + void arb_set_round(arb_t y, const arb_t x, slong prec) - void arb_set_round_fmpz(arb_t y, const fmpz_t x, long prec) + void arb_set_round_fmpz(arb_t y, const fmpz_t x, slong prec) # Sets *y* to the value of *x*, rounded to *prec* bits in the direction # towards zero. - void arb_set_round_fmpz_2exp(arb_t y, const fmpz_t x, const fmpz_t e, long prec) + void arb_set_round_fmpz_2exp(arb_t y, const fmpz_t x, const fmpz_t e, slong prec) # Sets *y* to `x \cdot 2^e`, rounded to *prec* bits in the direction # towards zero. - void arb_set_fmpq(arb_t y, const fmpq_t x, long prec) + void arb_set_fmpq(arb_t y, const fmpq_t x, slong prec) # Sets *y* to the rational number *x*, rounded to *prec* bits in the direction # towards zero. - int arb_set_str(arb_t res, const char * inp, long prec) + int arb_set_str(arb_t res, const char * inp, slong prec) # Sets *res* to the value specified by the human-readable string *inp*. # The input may be a decimal floating-point literal, # such as "25", "0.001", "7e+141" or "-31.4159e-1", and may also consist @@ -97,7 +97,7 @@ cdef extern from "flint_wrap.h": # Returns 0 if successful and nonzero if unsuccessful. If unsuccessful, # the result is set to an indeterminate interval. - char * arb_get_str(const arb_t x, long n, unsigned long flags) + char * arb_get_str(const arb_t x, slong n, ulong flags) # Returns a nice human-readable representation of *x*, with at most *n* # digits of the midpoint printed. # With default flags, the output can be parsed back with :func:`arb_set_str`, @@ -150,16 +150,16 @@ cdef extern from "flint_wrap.h": void arb_fprint(FILE * file, const arb_t x) # Prints the internal representation of *x*. - void arb_printd(const arb_t x, long digits) + void arb_printd(const arb_t x, slong digits) - void arb_fprintd(FILE * file, const arb_t x, long digits) + void arb_fprintd(FILE * file, const arb_t x, slong digits) # Prints *x* in decimal. The printed value of the radius is not adjusted # to compensate for the fact that the binary-to-decimal conversion # of both the midpoint and the radius introduces additional error. - void arb_printn(const arb_t x, long digits, unsigned long flags) + void arb_printn(const arb_t x, slong digits, ulong flags) - void arb_fprintn(FILE * file, const arb_t x, long digits, unsigned long flags) + void arb_fprintn(FILE * file, const arb_t x, slong digits, ulong flags) # Prints a nice decimal representation of *x*. # By default, the output shows the midpoint with a guaranteed error of at # most one unit in the last decimal place. In addition, an explicit error @@ -209,25 +209,25 @@ cdef extern from "flint_wrap.h": # } # fclose(fp); - void arb_randtest(arb_t x, flint_rand_t state, long prec, long mag_bits) + void arb_randtest(arb_t x, flint_rand_t state, slong prec, slong mag_bits) # Generates a random ball. The midpoint and radius will both be finite. - void arb_randtest_exact(arb_t x, flint_rand_t state, long prec, long mag_bits) + void arb_randtest_exact(arb_t x, flint_rand_t state, slong prec, slong mag_bits) # Generates a random number with zero radius. - void arb_randtest_precise(arb_t x, flint_rand_t state, long prec, long mag_bits) + void arb_randtest_precise(arb_t x, flint_rand_t state, slong prec, slong mag_bits) # Generates a random number with radius around `2^{-\text{prec}}` # the magnitude of the midpoint. - void arb_randtest_wide(arb_t x, flint_rand_t state, long prec, long mag_bits) + void arb_randtest_wide(arb_t x, flint_rand_t state, slong prec, slong mag_bits) # Generates a random number with midpoint and radius chosen independently, # possibly giving a very large interval. - void arb_randtest_special(arb_t x, flint_rand_t state, long prec, long mag_bits) + void arb_randtest_special(arb_t x, flint_rand_t state, slong prec, slong mag_bits) # Generates a random interval, possibly having NaN or an infinity # as the midpoint and possibly having an infinite radius. - void arb_get_rand_fmpq(fmpq_t q, flint_rand_t state, const arb_t x, long bits) + void arb_get_rand_fmpq(fmpq_t q, flint_rand_t state, const arb_t x, slong bits) # Sets *q* to a random rational number from the interval represented by *x*. # A denominator is chosen by multiplying the binary denominator of *x* # by a random integer up to *bits* bits. @@ -236,7 +236,7 @@ cdef extern from "flint_wrap.h": # that representing the endpoints as exact rational numbers would # cause overflows. - void arb_urandom(arb_t x, flint_rand_t state, long prec) + void arb_urandom(arb_t x, flint_rand_t state, slong prec) # Sets *x* to a uniformly distributed random number in the interval # `[0, 1]`. The method uses rounding from integers to floats, hence the # radius might not be `0`. @@ -255,15 +255,15 @@ cdef extern from "flint_wrap.h": # Adds the absolute value of *err* to the radius of *x* (the operation # is done in-place). - void arb_add_error_2exp_si(arb_t x, long e) + void arb_add_error_2exp_si(arb_t x, slong e) void arb_add_error_2exp_fmpz(arb_t x, const fmpz_t e) # Adds `2^e` to the radius of *x*. - void arb_union(arb_t z, const arb_t x, const arb_t y, long prec) + void arb_union(arb_t z, const arb_t x, const arb_t y, slong prec) # Sets *z* to a ball containing both *x* and *y*. - int arb_intersection(arb_t z, const arb_t x, const arb_t y, long prec) + int arb_intersection(arb_t z, const arb_t x, const arb_t y, slong prec) # If *x* and *y* overlap according to :func:`arb_overlaps`, # then *z* is set to a ball containing the intersection of *x* and *y* # and a nonzero value is returned. @@ -277,19 +277,19 @@ cdef extern from "flint_wrap.h": # certainly contains no negative points. # In the special case when *x* is strictly negative, *res* is set to zero. - void arb_get_abs_ubound_arf(arf_t u, const arb_t x, long prec) + void arb_get_abs_ubound_arf(arf_t u, const arb_t x, slong prec) # Sets *u* to the upper bound for the absolute value of *x*, # rounded up to *prec* bits. If *x* contains NaN, the result is NaN. - void arb_get_abs_lbound_arf(arf_t u, const arb_t x, long prec) + void arb_get_abs_lbound_arf(arf_t u, const arb_t x, slong prec) # Sets *u* to the lower bound for the absolute value of *x*, # rounded down to *prec* bits. If *x* contains NaN, the result is NaN. - void arb_get_ubound_arf(arf_t u, const arb_t x, long prec) + void arb_get_ubound_arf(arf_t u, const arb_t x, slong prec) # Sets *u* to the upper bound for the value of *x*, # rounded up to *prec* bits. If *x* contains NaN, the result is NaN. - void arb_get_lbound_arf(arf_t u, const arb_t x, long prec) + void arb_get_lbound_arf(arf_t u, const arb_t x, slong prec) # Sets *u* to the lower bound for the value of *x*, # rounded down to *prec* bits. If *x* contains NaN, the result is NaN. @@ -321,38 +321,38 @@ cdef extern from "flint_wrap.h": # to check that the midpoint and radius of *x* both are within a # reasonable range before calling this method. - void arb_set_interval_mag(arb_t x, const mag_t a, const mag_t b, long prec) + void arb_set_interval_mag(arb_t x, const mag_t a, const mag_t b, slong prec) - void arb_set_interval_arf(arb_t x, const arf_t a, const arf_t b, long prec) + void arb_set_interval_arf(arb_t x, const arf_t a, const arf_t b, slong prec) - void arb_set_interval_mpfr(arb_t x, const mpfr_t a, const mpfr_t b, long prec) + void arb_set_interval_mpfr(arb_t x, const mpfr_t a, const mpfr_t b, slong prec) # Sets *x* to a ball containing the interval `[a, b]`. We # require that `a \le b`. - void arb_set_interval_neg_pos_mag(arb_t x, const mag_t a, const mag_t b, long prec) + void arb_set_interval_neg_pos_mag(arb_t x, const mag_t a, const mag_t b, slong prec) # Sets *x* to a ball containing the interval `[-a, b]`. - void arb_get_interval_arf(arf_t a, arf_t b, const arb_t x, long prec) + void arb_get_interval_arf(arf_t a, arf_t b, const arb_t x, slong prec) void arb_get_interval_mpfr(mpfr_t a, mpfr_t b, const arb_t x) # Constructs an interval `[a, b]` containing the ball *x*. The MPFR version # uses the precision of the output variables. - long arb_rel_error_bits(const arb_t x) + slong arb_rel_error_bits(const arb_t x) # Returns the effective relative error of *x* measured in bits, defined as # the difference between the position of the top bit in the radius # and the top bit in the midpoint, plus one. # The result is clamped between plus/minus *ARF_PREC_EXACT*. - long arb_rel_accuracy_bits(const arb_t x) + slong arb_rel_accuracy_bits(const arb_t x) # Returns the effective relative accuracy of *x* measured in bits, # equal to the negative of the return value from :func:`arb_rel_error_bits`. - long arb_rel_one_accuracy_bits(const arb_t x) + slong arb_rel_one_accuracy_bits(const arb_t x) # Given a ball with midpoint *m* and radius *r*, returns an approximation of # the relative accuracy of `[\max(1,|m|) \pm r]` measured in bits. - long arb_bits(const arb_t x) + slong arb_bits(const arb_t x) # Returns the number of bits needed to represent the absolute value # of the mantissa of the midpoint of *x*, i.e. the minimum precision # sufficient to represent *x* exactly. Returns 0 if the midpoint @@ -378,24 +378,24 @@ cdef extern from "flint_wrap.h": # in swapping. It is recommended to check that the midpoint of *x* is # within a reasonable range before calling this method. - void arb_floor(arb_t y, const arb_t x, long prec) - void arb_ceil(arb_t y, const arb_t x, long prec) - void arb_trunc(arb_t y, const arb_t x, long prec) - void arb_nint(arb_t y, const arb_t x, long prec) + void arb_floor(arb_t y, const arb_t x, slong prec) + void arb_ceil(arb_t y, const arb_t x, slong prec) + void arb_trunc(arb_t y, const arb_t x, slong prec) + void arb_nint(arb_t y, const arb_t x, slong prec) # Sets *y* to a ball containing respectively, `\lfloor x \rfloor` and # `\lceil x \rceil`, `\operatorname{trunc}(x)`, `\operatorname{nint}(x)`, # with the midpoint of *y* rounded to at most *prec* bits. - void arb_get_fmpz_mid_rad_10exp(fmpz_t mid, fmpz_t rad, fmpz_t exp, const arb_t x, long n) + void arb_get_fmpz_mid_rad_10exp(fmpz_t mid, fmpz_t rad, fmpz_t exp, const arb_t x, slong n) # Assuming that *x* is finite and not exactly zero, computes integers *mid*, # *rad*, *exp* such that `x \in [m-r, m+r] \times 10^e` and such that the # larger out of *mid* and *rad* has at least *n* digits plus a few guard # digits. If *x* is infinite or exactly zero, the outputs are all set # to zero. - int arb_can_round_arf(const arb_t x, long prec, arf_rnd_t rnd) + int arb_can_round_arf(const arb_t x, slong prec, arf_rnd_t rnd) - int arb_can_round_mpfr(const arb_t x, long prec, mpfr_rnd_t rnd) + int arb_can_round_mpfr(const arb_t x, slong prec, mpfr_rnd_t rnd) # Returns nonzero if rounding the midpoint of *x* to *prec* bits in # the direction *rnd* is guaranteed to give the unique correctly # rounded floating-point approximation for the real number represented by *x*. @@ -434,7 +434,7 @@ cdef extern from "flint_wrap.h": int arb_is_int(const arb_t x) # Returns nonzero iff *x* is an exact integer. - int arb_is_int_2exp_si(const arb_t x, long e) + int arb_is_int_2exp_si(const arb_t x, slong e) # Returns nonzero iff *x* exactly equals `n 2^e` for some integer *n*. int arb_equal(const arb_t x, const arb_t y) @@ -447,7 +447,7 @@ cdef extern from "flint_wrap.h": # quantity, use :func:`arb_overlaps` or :func:`arb_contains`, # depending on the circumstance. - int arb_equal_si(const arb_t x, long y) + int arb_equal_si(const arb_t x, slong y) # Returns nonzero iff *x* is equal to the integer *y*. int arb_is_positive(const arb_t x) @@ -473,7 +473,7 @@ cdef extern from "flint_wrap.h": int arb_contains_fmpz(const arb_t x, const fmpz_t y) - int arb_contains_si(const arb_t x, long y) + int arb_contains_si(const arb_t x, slong y) int arb_contains_mpfr(const arb_t x, const mpfr_t y) @@ -529,7 +529,7 @@ cdef extern from "flint_wrap.h": void arb_neg(arb_t y, const arb_t x) - void arb_neg_round(arb_t y, const arb_t x, long prec) + void arb_neg_round(arb_t y, const arb_t x, slong prec) # Sets *y* to the negation of *x*. void arb_abs(arb_t y, const arb_t x) @@ -550,107 +550,107 @@ cdef extern from "flint_wrap.h": # and 0 if *x* is zero or a ball containing zero so that its sign # is not determined. - void arb_min(arb_t z, const arb_t x, const arb_t y, long prec) + void arb_min(arb_t z, const arb_t x, const arb_t y, slong prec) - void arb_max(arb_t z, const arb_t x, const arb_t y, long prec) + void arb_max(arb_t z, const arb_t x, const arb_t y, slong prec) # Sets *z* respectively to the minimum and the maximum of *x* and *y*. - void arb_minmax(arb_t z1, arb_t z2, const arb_t x, const arb_t y, long prec) + void arb_minmax(arb_t z1, arb_t z2, const arb_t x, const arb_t y, slong prec) # Sets *z1* and *z2* respectively to the minimum and the maximum of *x* and *y*. - void arb_add(arb_t z, const arb_t x, const arb_t y, long prec) + void arb_add(arb_t z, const arb_t x, const arb_t y, slong prec) - void arb_add_arf(arb_t z, const arb_t x, const arf_t y, long prec) + void arb_add_arf(arb_t z, const arb_t x, const arf_t y, slong prec) - void arb_add_ui(arb_t z, const arb_t x, unsigned long y, long prec) + void arb_add_ui(arb_t z, const arb_t x, ulong y, slong prec) - void arb_add_si(arb_t z, const arb_t x, long y, long prec) + void arb_add_si(arb_t z, const arb_t x, slong y, slong prec) - void arb_add_fmpz(arb_t z, const arb_t x, const fmpz_t y, long prec) + void arb_add_fmpz(arb_t z, const arb_t x, const fmpz_t y, slong prec) # Sets `z = x + y`, rounded to *prec* bits. The precision can be # *ARF_PREC_EXACT* provided that the result fits in memory. - void arb_add_fmpz_2exp(arb_t z, const arb_t x, const fmpz_t m, const fmpz_t e, long prec) + void arb_add_fmpz_2exp(arb_t z, const arb_t x, const fmpz_t m, const fmpz_t e, slong prec) # Sets `z = x + m \cdot 2^e`, rounded to *prec* bits. The precision can be # *ARF_PREC_EXACT* provided that the result fits in memory. - void arb_sub(arb_t z, const arb_t x, const arb_t y, long prec) + void arb_sub(arb_t z, const arb_t x, const arb_t y, slong prec) - void arb_sub_arf(arb_t z, const arb_t x, const arf_t y, long prec) + void arb_sub_arf(arb_t z, const arb_t x, const arf_t y, slong prec) - void arb_sub_ui(arb_t z, const arb_t x, unsigned long y, long prec) + void arb_sub_ui(arb_t z, const arb_t x, ulong y, slong prec) - void arb_sub_si(arb_t z, const arb_t x, long y, long prec) + void arb_sub_si(arb_t z, const arb_t x, slong y, slong prec) - void arb_sub_fmpz(arb_t z, const arb_t x, const fmpz_t y, long prec) + void arb_sub_fmpz(arb_t z, const arb_t x, const fmpz_t y, slong prec) # Sets `z = x - y`, rounded to *prec* bits. The precision can be # *ARF_PREC_EXACT* provided that the result fits in memory. - void arb_mul(arb_t z, const arb_t x, const arb_t y, long prec) + void arb_mul(arb_t z, const arb_t x, const arb_t y, slong prec) - void arb_mul_arf(arb_t z, const arb_t x, const arf_t y, long prec) + void arb_mul_arf(arb_t z, const arb_t x, const arf_t y, slong prec) - void arb_mul_si(arb_t z, const arb_t x, long y, long prec) + void arb_mul_si(arb_t z, const arb_t x, slong y, slong prec) - void arb_mul_ui(arb_t z, const arb_t x, unsigned long y, long prec) + void arb_mul_ui(arb_t z, const arb_t x, ulong y, slong prec) - void arb_mul_fmpz(arb_t z, const arb_t x, const fmpz_t y, long prec) + void arb_mul_fmpz(arb_t z, const arb_t x, const fmpz_t y, slong prec) # Sets `z = x \cdot y`, rounded to *prec* bits. The precision can be # *ARF_PREC_EXACT* provided that the result fits in memory. - void arb_mul_2exp_si(arb_t y, const arb_t x, long e) + void arb_mul_2exp_si(arb_t y, const arb_t x, slong e) void arb_mul_2exp_fmpz(arb_t y, const arb_t x, const fmpz_t e) # Sets *y* to *x* multiplied by `2^e`. - void arb_addmul(arb_t z, const arb_t x, const arb_t y, long prec) + void arb_addmul(arb_t z, const arb_t x, const arb_t y, slong prec) - void arb_addmul_arf(arb_t z, const arb_t x, const arf_t y, long prec) + void arb_addmul_arf(arb_t z, const arb_t x, const arf_t y, slong prec) - void arb_addmul_si(arb_t z, const arb_t x, long y, long prec) + void arb_addmul_si(arb_t z, const arb_t x, slong y, slong prec) - void arb_addmul_ui(arb_t z, const arb_t x, unsigned long y, long prec) + void arb_addmul_ui(arb_t z, const arb_t x, ulong y, slong prec) - void arb_addmul_fmpz(arb_t z, const arb_t x, const fmpz_t y, long prec) + void arb_addmul_fmpz(arb_t z, const arb_t x, const fmpz_t y, slong prec) # Sets `z = z + x \cdot y`, rounded to prec bits. The precision can be # *ARF_PREC_EXACT* provided that the result fits in memory. - void arb_submul(arb_t z, const arb_t x, const arb_t y, long prec) + void arb_submul(arb_t z, const arb_t x, const arb_t y, slong prec) - void arb_submul_arf(arb_t z, const arb_t x, const arf_t y, long prec) + void arb_submul_arf(arb_t z, const arb_t x, const arf_t y, slong prec) - void arb_submul_si(arb_t z, const arb_t x, long y, long prec) + void arb_submul_si(arb_t z, const arb_t x, slong y, slong prec) - void arb_submul_ui(arb_t z, const arb_t x, unsigned long y, long prec) + void arb_submul_ui(arb_t z, const arb_t x, ulong y, slong prec) - void arb_submul_fmpz(arb_t z, const arb_t x, const fmpz_t y, long prec) + void arb_submul_fmpz(arb_t z, const arb_t x, const fmpz_t y, slong prec) # Sets `z = z - x \cdot y`, rounded to prec bits. The precision can be # *ARF_PREC_EXACT* provided that the result fits in memory. - void arb_fma(arb_t res, const arb_t x, const arb_t y, const arb_t z, long prec) - void arb_fma_arf(arb_t res, const arb_t x, const arf_t y, const arb_t z, long prec) - void arb_fma_si(arb_t res, const arb_t x, long y, const arb_t z, long prec) - void arb_fma_ui(arb_t res, const arb_t x, unsigned long y, const arb_t z, long prec) - void arb_fma_fmpz(arb_t res, const arb_t x, const fmpz_t y, const arb_t z, long prec) + void arb_fma(arb_t res, const arb_t x, const arb_t y, const arb_t z, slong prec) + void arb_fma_arf(arb_t res, const arb_t x, const arf_t y, const arb_t z, slong prec) + void arb_fma_si(arb_t res, const arb_t x, slong y, const arb_t z, slong prec) + void arb_fma_ui(arb_t res, const arb_t x, ulong y, const arb_t z, slong prec) + void arb_fma_fmpz(arb_t res, const arb_t x, const fmpz_t y, const arb_t z, slong prec) # Sets *res* to `x \cdot y + z`. This is equivalent to an *addmul* except # that *res* and *z* can be separate variables. - void arb_inv(arb_t z, const arb_t x, long prec) + void arb_inv(arb_t z, const arb_t x, slong prec) # Sets *z* to `1 / x`. - void arb_div(arb_t z, const arb_t x, const arb_t y, long prec) + void arb_div(arb_t z, const arb_t x, const arb_t y, slong prec) - void arb_div_arf(arb_t z, const arb_t x, const arf_t y, long prec) + void arb_div_arf(arb_t z, const arb_t x, const arf_t y, slong prec) - void arb_div_si(arb_t z, const arb_t x, long y, long prec) + void arb_div_si(arb_t z, const arb_t x, slong y, slong prec) - void arb_div_ui(arb_t z, const arb_t x, unsigned long y, long prec) + void arb_div_ui(arb_t z, const arb_t x, ulong y, slong prec) - void arb_div_fmpz(arb_t z, const arb_t x, const fmpz_t y, long prec) + void arb_div_fmpz(arb_t z, const arb_t x, const fmpz_t y, slong prec) - void arb_fmpz_div_fmpz(arb_t z, const fmpz_t x, const fmpz_t y, long prec) + void arb_fmpz_div_fmpz(arb_t z, const fmpz_t x, const fmpz_t y, slong prec) - void arb_ui_div(arb_t z, unsigned long x, const arb_t y, long prec) + void arb_ui_div(arb_t z, ulong x, const arb_t y, slong prec) # Sets `z = x / y`, rounded to *prec* bits. If *y* contains zero, *z* is # set to `0 \pm \infty`. Otherwise, error propagation uses the rule # .. math :: @@ -661,12 +661,12 @@ cdef extern from "flint_wrap.h": # where the triangle inequality has been applied to the numerator and # the reverse triangle inequality has been applied to the denominator. - void arb_div_2expm1_ui(arb_t z, const arb_t x, unsigned long n, long prec) + void arb_div_2expm1_ui(arb_t z, const arb_t x, ulong n, slong prec) # Sets `z = x / (2^n - 1)`, rounded to *prec* bits. - void arb_dot_precise(arb_t res, const arb_t s, int subtract, arb_srcptr x, long xstep, arb_srcptr y, long ystep, long len, long prec) - void arb_dot_simple(arb_t res, const arb_t s, int subtract, arb_srcptr x, long xstep, arb_srcptr y, long ystep, long len, long prec) - void arb_dot(arb_t res, const arb_t s, int subtract, arb_srcptr x, long xstep, arb_srcptr y, long ystep, long len, long prec) + void arb_dot_precise(arb_t res, const arb_t s, int subtract, arb_srcptr x, slong xstep, arb_srcptr y, slong ystep, slong len, slong prec) + void arb_dot_simple(arb_t res, const arb_t s, int subtract, arb_srcptr x, slong xstep, arb_srcptr y, slong ystep, slong len, slong prec) + void arb_dot(arb_t res, const arb_t s, int subtract, arb_srcptr x, slong xstep, arb_srcptr y, slong ystep, slong len, slong prec) # Computes the dot product of the vectors *x* and *y*, setting # *res* to `s + (-1)^{subtract} \sum_{i=0}^{len-1} x_i y_i`. # The initial term *s* is optional and can be @@ -694,50 +694,50 @@ cdef extern from "flint_wrap.h": # final rounding. This can be extremely slow and is only intended # for testing. - void arb_approx_dot(arb_t res, const arb_t s, int subtract, arb_srcptr x, long xstep, arb_srcptr y, long ystep, long len, long prec) + void arb_approx_dot(arb_t res, const arb_t s, int subtract, arb_srcptr x, slong xstep, arb_srcptr y, slong ystep, slong len, slong prec) # Computes an approximate dot product *without error bounds*. # The radii of the inputs are ignored (only the midpoints are read) # and only the midpoint of the output is written. - void arb_dot_ui(arb_t res, const arb_t initial, int subtract, arb_srcptr x, long xstep, const unsigned long * y, long ystep, long len, long prec) - void arb_dot_si(arb_t res, const arb_t initial, int subtract, arb_srcptr x, long xstep, const long * y, long ystep, long len, long prec) - void arb_dot_uiui(arb_t res, const arb_t initial, int subtract, arb_srcptr x, long xstep, const unsigned long * y, long ystep, long len, long prec) - void arb_dot_siui(arb_t res, const arb_t initial, int subtract, arb_srcptr x, long xstep, const unsigned long * y, long ystep, long len, long prec) - void arb_dot_fmpz(arb_t res, const arb_t initial, int subtract, arb_srcptr x, long xstep, const fmpz * y, long ystep, long len, long prec) + void arb_dot_ui(arb_t res, const arb_t initial, int subtract, arb_srcptr x, slong xstep, const ulong * y, slong ystep, slong len, slong prec) + void arb_dot_si(arb_t res, const arb_t initial, int subtract, arb_srcptr x, slong xstep, const slong * y, slong ystep, slong len, slong prec) + void arb_dot_uiui(arb_t res, const arb_t initial, int subtract, arb_srcptr x, slong xstep, const ulong * y, slong ystep, slong len, slong prec) + void arb_dot_siui(arb_t res, const arb_t initial, int subtract, arb_srcptr x, slong xstep, const ulong * y, slong ystep, slong len, slong prec) + void arb_dot_fmpz(arb_t res, const arb_t initial, int subtract, arb_srcptr x, slong xstep, const fmpz * y, slong ystep, slong len, slong prec) # Equivalent to :func:`arb_dot`, but with integers in the array *y*. # The *uiui* and *siui* versions take an array of double-limb integers # as input; the *siui* version assumes that these represent signed # integers in two's complement form. - void arb_sqrt(arb_t z, const arb_t x, long prec) + void arb_sqrt(arb_t z, const arb_t x, slong prec) - void arb_sqrt_arf(arb_t z, const arf_t x, long prec) + void arb_sqrt_arf(arb_t z, const arf_t x, slong prec) - void arb_sqrt_fmpz(arb_t z, const fmpz_t x, long prec) + void arb_sqrt_fmpz(arb_t z, const fmpz_t x, slong prec) - void arb_sqrt_ui(arb_t z, unsigned long x, long prec) + void arb_sqrt_ui(arb_t z, ulong x, slong prec) # Sets *z* to the square root of *x*, rounded to *prec* bits. # If `x = m \pm x` where `m \ge r \ge 0`, the propagated error is bounded by # `\sqrt{m} - \sqrt{m-r} = \sqrt{m} (1 - \sqrt{1 - r/m}) \le \sqrt{m} (r/m + (r/m)^2)/2`. - void arb_sqrtpos(arb_t z, const arb_t x, long prec) + void arb_sqrtpos(arb_t z, const arb_t x, slong prec) # Sets *z* to the square root of *x*, assuming that *x* represents a # nonnegative number (i.e. discarding any negative numbers in the input # interval). - void arb_hypot(arb_t z, const arb_t x, const arb_t y, long prec) + void arb_hypot(arb_t z, const arb_t x, const arb_t y, slong prec) # Sets *z* to `\sqrt{x^2 + y^2}`. - void arb_rsqrt(arb_t z, const arb_t x, long prec) + void arb_rsqrt(arb_t z, const arb_t x, slong prec) - void arb_rsqrt_ui(arb_t z, unsigned long x, long prec) + void arb_rsqrt_ui(arb_t z, ulong x, slong prec) # Sets *z* to the reciprocal square root of *x*, rounded to *prec* bits. # At high precision, this is faster than computing a square root. - void arb_sqrt1pm1(arb_t z, const arb_t x, long prec) + void arb_sqrt1pm1(arb_t z, const arb_t x, slong prec) # Sets `z = \sqrt{1+x}-1`, computed accurately when `x \approx 0`. - void arb_root_ui(arb_t z, const arb_t x, unsigned long k, long prec) + void arb_root_ui(arb_t z, const arb_t x, ulong k, slong prec) # Sets *z* to the *k*-th root of *x*, rounded to *prec* bits. # This function selects between different algorithms. For large *k*, # it evaluates `\exp(\log(x)/k)`. For small *k*, it uses :func:`arf_root` @@ -751,21 +751,21 @@ cdef extern from "flint_wrap.h": # = m^{1/k} \min(1, \log(1+r/(m-r))/k). # This is evaluated using :func:`mag_log1p`. - void arb_root(arb_t z, const arb_t x, unsigned long k, long prec) + void arb_root(arb_t z, const arb_t x, ulong k, slong prec) # Alias for :func:`arb_root_ui`, provided for backwards compatibility. - void arb_sqr(arb_t y, const arb_t x, long prec) + void arb_sqr(arb_t y, const arb_t x, slong prec) # Sets *y* to be the square of *x*. - void arb_pow_fmpz_binexp(arb_t y, const arb_t b, const fmpz_t e, long prec) + void arb_pow_fmpz_binexp(arb_t y, const arb_t b, const fmpz_t e, slong prec) - void arb_pow_fmpz(arb_t y, const arb_t b, const fmpz_t e, long prec) + void arb_pow_fmpz(arb_t y, const arb_t b, const fmpz_t e, slong prec) - void arb_pow_ui(arb_t y, const arb_t b, unsigned long e, long prec) + void arb_pow_ui(arb_t y, const arb_t b, ulong e, slong prec) - void arb_ui_pow_ui(arb_t y, unsigned long b, unsigned long e, long prec) + void arb_ui_pow_ui(arb_t y, ulong b, ulong e, slong prec) - void arb_si_pow_ui(arb_t y, long b, unsigned long e, long prec) + void arb_si_pow_ui(arb_t y, slong b, ulong e, slong prec) # Sets `y = b^e` using binary exponentiation (with an initial division # if `e < 0`). Provided that *b* and *e* # are small enough and the exponent is positive, the exact power can be @@ -773,25 +773,25 @@ cdef extern from "flint_wrap.h": # Note that these functions can get slow if the exponent is # extremely large (in such cases :func:`arb_pow` may be superior). - void arb_pow_fmpq(arb_t y, const arb_t x, const fmpq_t a, long prec) + void arb_pow_fmpq(arb_t y, const arb_t x, const fmpq_t a, slong prec) # Sets `y = b^e`, computed as `y = (b^{1/q})^p` if the denominator of # `e = p/q` is small, and generally as `y = \exp(e \log b)`. # Note that this function can get slow if the exponent is # extremely large (in such cases :func:`arb_pow` may be superior). - void arb_pow(arb_t z, const arb_t x, const arb_t y, long prec) + void arb_pow(arb_t z, const arb_t x, const arb_t y, slong prec) # Sets `z = x^y`, computed using binary exponentiation if `y` is # a small exact integer, as `z = (x^{1/2})^{2y}` if `y` is a small exact # half-integer, and generally as `z = \exp(y \log x)`, except giving the # obvious finite result if `x` is `a \pm a` and `y` is positive. - void arb_log_ui(arb_t z, unsigned long x, long prec) + void arb_log_ui(arb_t z, ulong x, slong prec) - void arb_log_fmpz(arb_t z, const fmpz_t x, long prec) + void arb_log_fmpz(arb_t z, const fmpz_t x, slong prec) - void arb_log_arf(arb_t z, const arf_t x, long prec) + void arb_log_arf(arb_t z, const arf_t x, slong prec) - void arb_log(arb_t z, const arb_t x, long prec) + void arb_log(arb_t z, const arb_t x, slong prec) # Sets `z = \log(x)`. # At low to medium precision (up to about 4096 bits), :func:`arb_log_arf` # uses table-based argument reduction and fast Taylor series evaluation @@ -799,7 +799,7 @@ cdef extern from "flint_wrap.h": # The function :func:`arb_log` simply calls :func:`arb_log_arf` with # the midpoint as input, and separately adds the propagated error. - void arb_log_ui_from_prev(arb_t log_k1, unsigned long k1, arb_t log_k0, unsigned long k0, long prec) + void arb_log_ui_from_prev(arb_t log_k1, ulong k1, arb_t log_k0, ulong k0, slong prec) # Computes `\log(k_1)`, given `\log(k_0)` where `k_0 < k_1`. # At high precision, this function uses the formula # `\log(k_1) = \log(k_0) + 2 \operatorname{atanh}((k_1-k_0)/(k_1+k_0))`, @@ -808,53 +808,53 @@ cdef extern from "flint_wrap.h": # be small). Otherwise, it ignores `\log(k_0)` and evaluates the logarithm # the usual way. - void arb_log1p(arb_t z, const arb_t x, long prec) + void arb_log1p(arb_t z, const arb_t x, slong prec) # Sets `z = \log(1+x)`, computed accurately when `x \approx 0`. - void arb_log_base_ui(arb_t res, const arb_t x, unsigned long b, long prec) + void arb_log_base_ui(arb_t res, const arb_t x, ulong b, slong prec) # Sets *res* to `\log_b(x)`. The result is computed exactly when possible. - void arb_log_hypot(arb_t res, const arb_t x, const arb_t y, long prec) + void arb_log_hypot(arb_t res, const arb_t x, const arb_t y, slong prec) # Sets *res* to `\log(\sqrt{x^2+y^2})`. - void arb_exp(arb_t z, const arb_t x, long prec) + void arb_exp(arb_t z, const arb_t x, slong prec) # Sets `z = \exp(x)`. Error propagation is done using the following rule: # assuming `x = m \pm r`, the error is largest at `m + r`, and we have # `\exp(m+r) - \exp(m) = \exp(m) (\exp(r)-1) \le r \exp(m+r)`. - void arb_expm1(arb_t z, const arb_t x, long prec) + void arb_expm1(arb_t z, const arb_t x, slong prec) # Sets `z = \exp(x)-1`, using a more accurate method when `x \approx 0`. - void arb_exp_invexp(arb_t z, arb_t w, const arb_t x, long prec) + void arb_exp_invexp(arb_t z, arb_t w, const arb_t x, slong prec) # Sets `z = \exp(x)` and `w = \exp(-x)`. The second exponential is computed # from the first using a division, but propagated error bounds are # computed separately. - void arb_sin(arb_t s, const arb_t x, long prec) + void arb_sin(arb_t s, const arb_t x, slong prec) - void arb_cos(arb_t c, const arb_t x, long prec) + void arb_cos(arb_t c, const arb_t x, slong prec) - void arb_sin_cos(arb_t s, arb_t c, const arb_t x, long prec) + void arb_sin_cos(arb_t s, arb_t c, const arb_t x, slong prec) # Sets `s = \sin(x)`, `c = \cos(x)`. - void arb_sin_pi(arb_t s, const arb_t x, long prec) + void arb_sin_pi(arb_t s, const arb_t x, slong prec) - void arb_cos_pi(arb_t c, const arb_t x, long prec) + void arb_cos_pi(arb_t c, const arb_t x, slong prec) - void arb_sin_cos_pi(arb_t s, arb_t c, const arb_t x, long prec) + void arb_sin_cos_pi(arb_t s, arb_t c, const arb_t x, slong prec) # Sets `s = \sin(\pi x)`, `c = \cos(\pi x)`. - void arb_tan(arb_t y, const arb_t x, long prec) + void arb_tan(arb_t y, const arb_t x, slong prec) # Sets `y = \tan(x) = \sin(x) / \cos(y)`. - void arb_cot(arb_t y, const arb_t x, long prec) + void arb_cot(arb_t y, const arb_t x, slong prec) # Sets `y = \cot(x) = \cos(x) / \sin(y)`. - void arb_sin_cos_pi_fmpq(arb_t s, arb_t c, const fmpq_t x, long prec) + void arb_sin_cos_pi_fmpq(arb_t s, arb_t c, const fmpq_t x, slong prec) - void arb_sin_pi_fmpq(arb_t s, const fmpq_t x, long prec) + void arb_sin_pi_fmpq(arb_t s, const fmpq_t x, slong prec) - void arb_cos_pi_fmpq(arb_t c, const fmpq_t x, long prec) + void arb_cos_pi_fmpq(arb_t c, const fmpq_t x, slong prec) # Sets `s = \sin(\pi x)`, `c = \cos(\pi x)` where `x` is a rational # number (whose numerator and denominator are assumed to be reduced). # We first use trigonometric symmetries to reduce the argument to the @@ -865,30 +865,30 @@ cdef extern from "flint_wrap.h": # first of these two methods gives full accuracy even if the original # argument is close to some root other the origin. - void arb_tan_pi(arb_t y, const arb_t x, long prec) + void arb_tan_pi(arb_t y, const arb_t x, slong prec) # Sets `y = \tan(\pi x)`. - void arb_cot_pi(arb_t y, const arb_t x, long prec) + void arb_cot_pi(arb_t y, const arb_t x, slong prec) # Sets `y = \cot(\pi x)`. - void arb_sec(arb_t res, const arb_t x, long prec) + void arb_sec(arb_t res, const arb_t x, slong prec) # Computes `\sec(x) = 1 / \cos(x)`. - void arb_csc(arb_t res, const arb_t x, long prec) + void arb_csc(arb_t res, const arb_t x, slong prec) # Computes `\csc(x) = 1 / \sin(x)`. - void arb_csc_pi(arb_t res, const arb_t x, long prec) + void arb_csc_pi(arb_t res, const arb_t x, slong prec) # Computes `\csc(\pi x) = 1 / \sin(\pi x)`. - void arb_sinc(arb_t z, const arb_t x, long prec) + void arb_sinc(arb_t z, const arb_t x, slong prec) # Sets `z = \operatorname{sinc}(x) = \sin(x) / x`. - void arb_sinc_pi(arb_t z, const arb_t x, long prec) + void arb_sinc_pi(arb_t z, const arb_t x, slong prec) # Sets `z = \operatorname{sinc}(\pi x) = \sin(\pi x) / (\pi x)`. - void arb_atan_arf(arb_t z, const arf_t x, long prec) + void arb_atan_arf(arb_t z, const arf_t x, slong prec) - void arb_atan(arb_t z, const arb_t x, long prec) + void arb_atan(arb_t z, const arb_t x, slong prec) # Sets `z = \operatorname{atan}(x)`. # At low to medium precision (up to about 4096 bits), :func:`arb_atan_arf` # uses table-based argument reduction and fast Taylor series evaluation @@ -898,94 +898,94 @@ cdef extern from "flint_wrap.h": # The function :func:`arb_atan_arf` uses lookup tables if # possible, and otherwise falls back to :func:`arb_atan_arf_bb`. - void arb_atan2(arb_t z, const arb_t b, const arb_t a, long prec) + void arb_atan2(arb_t z, const arb_t b, const arb_t a, slong prec) # Sets *r* to an the argument (phase) of the complex number # `a + bi`, with the branch cut discontinuity on `(-\infty,0]`. # We define `\operatorname{atan2}(0,0) = 0`, and for `a < 0`, # `\operatorname{atan2}(0,a) = \pi`. - void arb_asin(arb_t z, const arb_t x, long prec) + void arb_asin(arb_t z, const arb_t x, slong prec) # Sets `z = \operatorname{asin}(x) = \operatorname{atan}(x / \sqrt{1-x^2})`. # If `x` is not contained in the domain `[-1,1]`, the result is an # indeterminate interval. - void arb_acos(arb_t z, const arb_t x, long prec) + void arb_acos(arb_t z, const arb_t x, slong prec) # Sets `z = \operatorname{acos}(x) = \pi/2 - \operatorname{asin}(x)`. # If `x` is not contained in the domain `[-1,1]`, the result is an # indeterminate interval. - void arb_sinh(arb_t s, const arb_t x, long prec) + void arb_sinh(arb_t s, const arb_t x, slong prec) - void arb_cosh(arb_t c, const arb_t x, long prec) + void arb_cosh(arb_t c, const arb_t x, slong prec) - void arb_sinh_cosh(arb_t s, arb_t c, const arb_t x, long prec) + void arb_sinh_cosh(arb_t s, arb_t c, const arb_t x, slong prec) # Sets `s = \sinh(x)`, `c = \cosh(x)`. If the midpoint of `x` is close # to zero and the hyperbolic sine is to be computed, # evaluates `(e^{2x}\pm1) / (2e^x)` via :func:`arb_expm1` # to avoid loss of accuracy. Otherwise evaluates `(e^x \pm e^{-x}) / 2`. - void arb_tanh(arb_t y, const arb_t x, long prec) + void arb_tanh(arb_t y, const arb_t x, slong prec) # Sets `y = \tanh(x) = \sinh(x) / \cosh(x)`, evaluated # via :func:`arb_expm1` as `\tanh(x) = (e^{2x} - 1) / (e^{2x} + 1)` # if `|x|` is small, and as # `\tanh(\pm x) = 1 - 2 e^{\mp 2x} / (1 + e^{\mp 2x})` # if `|x|` is large. - void arb_coth(arb_t y, const arb_t x, long prec) + void arb_coth(arb_t y, const arb_t x, slong prec) # Sets `y = \coth(x) = \cosh(x) / \sinh(x)`, evaluated using # the same strategy as :func:`arb_tanh`. - void arb_sech(arb_t res, const arb_t x, long prec) + void arb_sech(arb_t res, const arb_t x, slong prec) # Computes `\operatorname{sech}(x) = 1 / \cosh(x)`. - void arb_csch(arb_t res, const arb_t x, long prec) + void arb_csch(arb_t res, const arb_t x, slong prec) # Computes `\operatorname{csch}(x) = 1 / \sinh(x)`. - void arb_atanh(arb_t z, const arb_t x, long prec) + void arb_atanh(arb_t z, const arb_t x, slong prec) # Sets `z = \operatorname{atanh}(x)`. - void arb_asinh(arb_t z, const arb_t x, long prec) + void arb_asinh(arb_t z, const arb_t x, slong prec) # Sets `z = \operatorname{asinh}(x)`. - void arb_acosh(arb_t z, const arb_t x, long prec) + void arb_acosh(arb_t z, const arb_t x, slong prec) # Sets `z = \operatorname{acosh}(x)`. # If `x < 1`, the result is an indeterminate interval. - void arb_const_pi(arb_t z, long prec) + void arb_const_pi(arb_t z, slong prec) # Computes `\pi`. - void arb_const_sqrt_pi(arb_t z, long prec) + void arb_const_sqrt_pi(arb_t z, slong prec) # Computes `\sqrt{\pi}`. - void arb_const_log_sqrt2pi(arb_t z, long prec) + void arb_const_log_sqrt2pi(arb_t z, slong prec) # Computes `\log \sqrt{2 \pi}`. - void arb_const_log2(arb_t z, long prec) + void arb_const_log2(arb_t z, slong prec) # Computes `\log(2)`. - void arb_const_log10(arb_t z, long prec) + void arb_const_log10(arb_t z, slong prec) # Computes `\log(10)`. - void arb_const_euler(arb_t z, long prec) + void arb_const_euler(arb_t z, slong prec) # Computes Euler's constant `\gamma = \lim_{k \rightarrow \infty} (H_k - \log k)` # where `H_k = 1 + 1/2 + \ldots + 1/k`. - void arb_const_catalan(arb_t z, long prec) + void arb_const_catalan(arb_t z, slong prec) # Computes Catalan's constant `C = \sum_{n=0}^{\infty} (-1)^n / (2n+1)^2`. - void arb_const_e(arb_t z, long prec) + void arb_const_e(arb_t z, slong prec) # Computes `e = \exp(1)`. - void arb_const_khinchin(arb_t z, long prec) + void arb_const_khinchin(arb_t z, slong prec) # Computes Khinchin's constant `K_0`. - void arb_const_glaisher(arb_t z, long prec) + void arb_const_glaisher(arb_t z, slong prec) # Computes the Glaisher-Kinkelin constant `A = \exp(1/12 - \zeta'(-1))`. - void arb_const_apery(arb_t z, long prec) + void arb_const_apery(arb_t z, slong prec) # Computes Apery's constant `\zeta(3)`. - void arb_lambertw(arb_t res, const arb_t x, int flags, long prec) + void arb_lambertw(arb_t res, const arb_t x, int flags, slong prec) # Computes the Lambert W function, which solves the equation `w e^w = x`. # The Lambert W function has infinitely many complex branches `W_k(x)`, # two of which are real on a part of the real line. @@ -1002,52 +1002,52 @@ cdef extern from "flint_wrap.h": # The algorithm used to compute the Lambert W function is described # in [Joh2017b]_, which follows the main ideas in [CGHJK1996]_. - void arb_rising_ui(arb_t z, const arb_t x, unsigned long n, long prec) - void arb_rising(arb_t z, const arb_t x, const arb_t n, long prec) + void arb_rising_ui(arb_t z, const arb_t x, ulong n, slong prec) + void arb_rising(arb_t z, const arb_t x, const arb_t n, slong prec) # Computes the rising factorial `z = x (x+1) (x+2) \cdots (x+n-1)`. # These functions are aliases for :func:`arb_hypgeom_rising_ui` # and :func:`arb_hypgeom_rising`. - void arb_rising_fmpq_ui(arb_t z, const fmpq_t x, unsigned long n, long prec) + void arb_rising_fmpq_ui(arb_t z, const fmpq_t x, ulong n, slong prec) # Computes the rising factorial `z = x (x+1) (x+2) \cdots (x+n-1)` using # binary splitting. If the denominator or numerator of *x* is large # compared to *prec*, it is more efficient to convert *x* to an approximation # and use :func:`arb_rising_ui`. - void arb_fac_ui(arb_t z, unsigned long n, long prec) + void arb_fac_ui(arb_t z, ulong n, slong prec) # Computes the factorial `z = n!` via the gamma function. - void arb_doublefac_ui(arb_t z, unsigned long n, long prec) + void arb_doublefac_ui(arb_t z, ulong n, slong prec) # Computes the double factorial `z = n!!` via the gamma function. - void arb_bin_ui(arb_t z, const arb_t n, unsigned long k, long prec) + void arb_bin_ui(arb_t z, const arb_t n, ulong k, slong prec) - void arb_bin_uiui(arb_t z, unsigned long n, unsigned long k, long prec) + void arb_bin_uiui(arb_t z, ulong n, ulong k, slong prec) # Computes the binomial coefficient `z = {n \choose k}`, via the # rising factorial as `{n \choose k} = (n-k+1)_k / k!`. - void arb_gamma(arb_t z, const arb_t x, long prec) - void arb_gamma_fmpq(arb_t z, const fmpq_t x, long prec) - void arb_gamma_fmpz(arb_t z, const fmpz_t x, long prec) + void arb_gamma(arb_t z, const arb_t x, slong prec) + void arb_gamma_fmpq(arb_t z, const fmpq_t x, slong prec) + void arb_gamma_fmpz(arb_t z, const fmpz_t x, slong prec) # Computes the gamma function `z = \Gamma(x)`. # These functions are aliases for :func:`arb_hypgeom_gamma`, # :func:`arb_hypgeom_gamma_fmpq`, :func:`arb_hypgeom_gamma_fmpz`. - void arb_lgamma(arb_t z, const arb_t x, long prec) + void arb_lgamma(arb_t z, const arb_t x, slong prec) # Computes the logarithmic gamma function `z = \log \Gamma(x)`. # The complex branch structure is assumed, so if `x \le 0`, the # result is an indeterminate interval. # This function is an alias for :func:`arb_hypgeom_lgamma`. - void arb_rgamma(arb_t z, const arb_t x, long prec) + void arb_rgamma(arb_t z, const arb_t x, slong prec) # Computes the reciprocal gamma function `z = 1/\Gamma(x)`, # avoiding division by zero at the poles of the gamma function. # This function is an alias for :func:`arb_hypgeom_rgamma`. - void arb_digamma(arb_t y, const arb_t x, long prec) + void arb_digamma(arb_t y, const arb_t x, slong prec) # Computes the digamma function `z = \psi(x) = (\log \Gamma(x))' = \Gamma'(x) / \Gamma(x)`. - void arb_zeta_ui_vec_borwein(arb_ptr z, unsigned long start, long num, unsigned long step, long prec) + void arb_zeta_ui_vec_borwein(arb_ptr z, ulong start, slong num, ulong step, slong prec) # Evaluates `\zeta(s)` at `\mathrm{num}` consecutive integers *s* beginning # with *start* and proceeding in increments of *step*. # Uses Borwein's formula ([Bor2000]_, [GS2003]_), @@ -1072,49 +1072,49 @@ cdef extern from "flint_wrap.h": # additional rounding error, so by induction, the error per term # is always smaller than 2 units. - void arb_zeta_ui_asymp(arb_t x, unsigned long s, long prec) + void arb_zeta_ui_asymp(arb_t x, ulong s, slong prec) - void arb_zeta_ui_euler_product(arb_t z, unsigned long s, long prec) + void arb_zeta_ui_euler_product(arb_t z, ulong s, slong prec) # Computes `\zeta(s)` using the Euler product. This is fast only if *s* # is large compared to the precision. Both methods are trivial wrappers # for :func:`_acb_dirichlet_euler_product_real_ui`. - void arb_zeta_ui_bernoulli(arb_t x, unsigned long s, long prec) + void arb_zeta_ui_bernoulli(arb_t x, ulong s, slong prec) # Computes `\zeta(s)` for even *s* via the corresponding Bernoulli number. - void arb_zeta_ui_borwein_bsplit(arb_t x, unsigned long s, long prec) + void arb_zeta_ui_borwein_bsplit(arb_t x, ulong s, slong prec) # Computes `\zeta(s)` for arbitrary `s \ge 2` using a binary splitting # implementation of Borwein's algorithm. This has quasilinear complexity # with respect to the precision (assuming that `s` is fixed). - void arb_zeta_ui_vec(arb_ptr x, unsigned long start, long num, long prec) + void arb_zeta_ui_vec(arb_ptr x, ulong start, slong num, slong prec) - void arb_zeta_ui_vec_even(arb_ptr x, unsigned long start, long num, long prec) + void arb_zeta_ui_vec_even(arb_ptr x, ulong start, slong num, slong prec) - void arb_zeta_ui_vec_odd(arb_ptr x, unsigned long start, long num, long prec) + void arb_zeta_ui_vec_odd(arb_ptr x, ulong start, slong num, slong prec) # Computes `\zeta(s)` at *num* consecutive integers (respectively *num* # even or *num* odd integers) beginning with `s = \mathrm{start} \ge 2`, # automatically choosing an appropriate algorithm. - void arb_zeta_ui(arb_t x, unsigned long s, long prec) + void arb_zeta_ui(arb_t x, ulong s, slong prec) # Computes `\zeta(s)` for nonnegative integer `s \ne 1`, automatically # choosing an appropriate algorithm. This function is # intended for numerical evaluation of isolated zeta values; for # multi-evaluation, the vector versions are more efficient. - void arb_zeta(arb_t z, const arb_t s, long prec) + void arb_zeta(arb_t z, const arb_t s, slong prec) # Sets *z* to the value of the Riemann zeta function `\zeta(s)`. # For computing derivatives with respect to `s`, # use :func:`arb_poly_zeta_series`. - void arb_hurwitz_zeta(arb_t z, const arb_t s, const arb_t a, long prec) + void arb_hurwitz_zeta(arb_t z, const arb_t s, const arb_t a, slong prec) # Sets *z* to the value of the Hurwitz zeta function `\zeta(s,a)`. # For computing derivatives with respect to `s`, # use :func:`arb_poly_zeta_series`. - void arb_bernoulli_ui(arb_t b, unsigned long n, long prec) + void arb_bernoulli_ui(arb_t b, ulong n, slong prec) - void arb_bernoulli_fmpz(arb_t b, const fmpz_t n, long prec) + void arb_bernoulli_fmpz(arb_t b, const fmpz_t n, slong prec) # Sets `b` to the numerical value of the Bernoulli number `B_n` # approximated to *prec* bits. # The internal precision is increased automatically to give an accurate @@ -1128,7 +1128,7 @@ cdef extern from "flint_wrap.h": # if the number is already cached, but does not automatically extend # the cache by itself. - void arb_bernoulli_ui_zeta(arb_t b, unsigned long n, long prec) + void arb_bernoulli_ui_zeta(arb_t b, ulong n, slong prec) # Sets `b` to the numerical value of `B_n` accurate to *prec* bits, # computed using the formula `B_{2n} = (-1)^{n+1} 2 (2n)! \zeta(2n) / (2 \pi)^n`. # To avoid potential infinite recursion, we explicitly call the @@ -1136,13 +1136,13 @@ cdef extern from "flint_wrap.h": # This method will only give high accuracy if the precision is small # enough compared to `n` for the Euler product to converge rapidly. - void arb_bernoulli_poly_ui(arb_t res, unsigned long n, const arb_t x, long prec) + void arb_bernoulli_poly_ui(arb_t res, ulong n, const arb_t x, slong prec) # Sets *res* to the value of the Bernoulli polynomial `B_n(x)`. # Warning: this function is only fast if either *n* or *x* is a small integer. # This function reads Bernoulli numbers from the global cache if they # are already cached, but does not automatically extend the cache by itself. - void arb_power_sum_vec(arb_ptr res, const arb_t a, const arb_t b, long len, long prec) + void arb_power_sum_vec(arb_ptr res, const arb_t a, const arb_t b, slong len, slong prec) # For *n* from 0 to *len* - 1, sets entry *n* in the output vector *res* to # .. math :: # S_n(a,b) = \frac{1}{n+1}\left(B_{n+1}(b) - B_{n+1}(a)\right) @@ -1152,83 +1152,83 @@ cdef extern from "flint_wrap.h": # S_n(a,b) = \sum_{k=a}^{b-1} k^n. # The computation uses the generating function for Bernoulli polynomials. - void arb_polylog(arb_t w, const arb_t s, const arb_t z, long prec) + void arb_polylog(arb_t w, const arb_t s, const arb_t z, slong prec) - void arb_polylog_si(arb_t w, long s, const arb_t z, long prec) + void arb_polylog_si(arb_t w, slong s, const arb_t z, slong prec) # Sets *w* to the polylogarithm `\operatorname{Li}_s(z)`. - void arb_fib_fmpz(arb_t z, const fmpz_t n, long prec) - void arb_fib_ui(arb_t z, unsigned long n, long prec) + void arb_fib_fmpz(arb_t z, const fmpz_t n, slong prec) + void arb_fib_ui(arb_t z, ulong n, slong prec) # Computes the Fibonacci number `F_n` using binary squaring. - void arb_agm(arb_t z, const arb_t x, const arb_t y, long prec) + void arb_agm(arb_t z, const arb_t x, const arb_t y, slong prec) # Sets *z* to the arithmetic-geometric mean of *x* and *y*. - void arb_chebyshev_t_ui(arb_t a, unsigned long n, const arb_t x, long prec) + void arb_chebyshev_t_ui(arb_t a, ulong n, const arb_t x, slong prec) - void arb_chebyshev_u_ui(arb_t a, unsigned long n, const arb_t x, long prec) + void arb_chebyshev_u_ui(arb_t a, ulong n, const arb_t x, slong prec) # Evaluates the Chebyshev polynomial of the first kind `a = T_n(x)` # or the Chebyshev polynomial of the second kind `a = U_n(x)`. - void arb_chebyshev_t2_ui(arb_t a, arb_t b, unsigned long n, const arb_t x, long prec) + void arb_chebyshev_t2_ui(arb_t a, arb_t b, ulong n, const arb_t x, slong prec) - void arb_chebyshev_u2_ui(arb_t a, arb_t b, unsigned long n, const arb_t x, long prec) + void arb_chebyshev_u2_ui(arb_t a, arb_t b, ulong n, const arb_t x, slong prec) # Simultaneously evaluates `a = T_n(x), b = T_{n-1}(x)` or # `a = U_n(x), b = U_{n-1}(x)`. # Aliasing between *a*, *b* and *x* is not permitted. - void arb_bell_sum_bsplit(arb_t res, const fmpz_t n, const fmpz_t a, const fmpz_t b, const fmpz_t mmag, long prec) + void arb_bell_sum_bsplit(arb_t res, const fmpz_t n, const fmpz_t a, const fmpz_t b, const fmpz_t mmag, slong prec) - void arb_bell_sum_taylor(arb_t res, const fmpz_t n, const fmpz_t a, const fmpz_t b, const fmpz_t mmag, long prec) + void arb_bell_sum_taylor(arb_t res, const fmpz_t n, const fmpz_t a, const fmpz_t b, const fmpz_t mmag, slong prec) # Helper functions for Bell numbers, evaluating the sum # `\sum_{k=a}^{b-1} k^n / k!`. If *mmag* is non-NULL, it may be used # to indicate that the target error tolerance should be # `2^{mmag - prec}`. - void arb_bell_fmpz(arb_t res, const fmpz_t n, long prec) + void arb_bell_fmpz(arb_t res, const fmpz_t n, slong prec) - void arb_bell_ui(arb_t res, unsigned long n, long prec) + void arb_bell_ui(arb_t res, ulong n, slong prec) # Sets *res* to the Bell number `B_n`. If the number is too large to # fit exactly in *prec* bits, a numerical approximation is computed # efficiently. # The algorithm to compute Bell numbers, including error analysis, # is described in detail in [Joh2015]_. - void arb_euler_number_fmpz(arb_t res, const fmpz_t n, long prec) - void arb_euler_number_ui(arb_t res, unsigned long n, long prec) + void arb_euler_number_fmpz(arb_t res, const fmpz_t n, slong prec) + void arb_euler_number_ui(arb_t res, ulong n, slong prec) # Sets *res* to the Euler number `E_n`, which is defined by # the exponential generating function `1 / \cosh(x)`. # The result will be exact if `E_n` is exactly representable # at the requested precision. - void arb_fmpz_euler_number_ui_multi_mod(fmpz_t res, unsigned long n, double alpha) - void arb_fmpz_euler_number_ui(fmpz_t res, unsigned long n) + void arb_fmpz_euler_number_ui_multi_mod(fmpz_t res, ulong n, double alpha) + void arb_fmpz_euler_number_ui(fmpz_t res, ulong n) # Computes the Euler number `E_n` as an exact integer. The default # algorithm uses a table lookup, the Dirichlet beta function or a # hybrid modular algorithm depending on the size of *n*. # The *multi_mod* algorithm accepts a tuning parameter *alpha* which # can be set to a negative value to use defaults. - void arb_partitions_fmpz(arb_t res, const fmpz_t n, long prec) + void arb_partitions_fmpz(arb_t res, const fmpz_t n, slong prec) - void arb_partitions_ui(arb_t res, unsigned long n, long prec) + void arb_partitions_ui(arb_t res, ulong n, slong prec) # Sets *res* to the partition function `p(n)`. # When *n* is large and `\log_2 p(n)` is more than twice *prec*, # the leading term in the Hardy-Ramanujan asymptotic series is used # together with an error bound. Otherwise, the exact value is computed # and rounded. - void arb_primorial_nth_ui(arb_t res, unsigned long n, long prec) + void arb_primorial_nth_ui(arb_t res, ulong n, slong prec) # Sets *res* to the *nth* primorial, defined as the product of the # first *n* prime numbers. The running time is quasilinear in *n*. - void arb_primorial_ui(arb_t res, unsigned long n, long prec) + void arb_primorial_ui(arb_t res, ulong n, slong prec) # Sets *res* to the primorial defined as the product of the positive # integers up to and including *n*. The running time is quasilinear in *n*. - void _arb_atan_taylor_naive(mp_ptr y, mp_limb_t * error, mp_srcptr x, mp_size_t xn, unsigned long N, int alternating) + 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, unsigned long 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) # Computes an approximation of `y = \sum_{k=0}^{N-1} x^{2k+1} / (2k+1)` # (if *alternating* is 0) or `y = \sum_{k=0}^{N-1} (-1)^k x^{2k+1} / (2k+1)` # (if *alternating* is 1). Used internally for computing arctangents @@ -1238,9 +1238,9 @@ cdef extern from "flint_wrap.h": # The input *x* and output *y* are fixed-point numbers with *xn* fractional # limbs. A bound for the ulp error is written to *error*. - void _arb_exp_taylor_naive(mp_ptr y, mp_limb_t * error, mp_srcptr x, mp_size_t xn, unsigned long N) + 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, unsigned long N) + void _arb_exp_taylor_rs(mp_ptr y, mp_limb_t * error, mp_srcptr x, mp_size_t xn, ulong N) # Computes an approximation of `y = \sum_{k=0}^{N-1} x^k / k!`. Used internally # for computing exponentials. The *naive* version uses the forward recurrence, # and the *rs* version uses a division-avoiding rectangular splitting scheme. @@ -1250,9 +1250,9 @@ cdef extern from "flint_wrap.h": # limbs plus one extra limb for the integer part of the result. # A bound for the ulp error is written to *error*. - void _arb_sin_cos_taylor_naive(mp_ptr ysin, mp_ptr ycos, mp_limb_t * error, mp_srcptr x, mp_size_t xn, unsigned long 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, unsigned long N, int sinonly, int alternating) + 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) # Computes approximations of `y_s = \sum_{k=0}^{N-1} (-1)^k x^{2k+1} / (2k+1)!` # and `y_c = \sum_{k=0}^{N-1} (-1)^k x^{2k} / (2k)!`. # Used internally for computing sines and cosines. The *naive* version uses @@ -1279,12 +1279,12 @@ cdef extern from "flint_wrap.h": # The value of *q* mod 8 is written to *octant*. The output variable *q* # can be NULL, in which case the full value of *q* is not stored. - long _arb_exp_taylor_bound(long mag, long prec) + slong _arb_exp_taylor_bound(slong mag, slong prec) # Returns *n* such that # `\left|\sum_{k=n}^{\infty} x^k / k!\right| \le 2^{-\mathrm{prec}}`, # assuming `|x| \le 2^{\mathrm{mag}} \le 1/4`. - void arb_exp_arf_bb(arb_t z, const arf_t x, long prec, int m1) + void arb_exp_arf_bb(arb_t z, const arf_t x, slong prec, int m1) # Computes the exponential function using the bit-burst algorithm. # If *m1* is nonzero, the exponential function minus one is computed # accurately. @@ -1299,9 +1299,9 @@ cdef extern from "flint_wrap.h": # could be improved by using `\log(2)` based reduction at precision low # enough that the value can be assumed to be cached. - void _arb_exp_sum_bs_simple(fmpz_t T, fmpz_t Q, flint_bitcnt_t * Qexp, const fmpz_t x, flint_bitcnt_t r, long N) + 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) - void _arb_exp_sum_bs_powtab(fmpz_t T, fmpz_t Q, flint_bitcnt_t * Qexp, const fmpz_t x, flint_bitcnt_t r, long N) + void _arb_exp_sum_bs_powtab(fmpz_t T, fmpz_t Q, flint_bitcnt_t * Qexp, const fmpz_t x, flint_bitcnt_t r, slong N) # Computes *T*, *Q* and *Qexp* such that # `T / (Q 2^{\text{Qexp}}) = \sum_{k=1}^N (x/2^r)^k/k!` using binary splitting. # Note that the sum is taken to *N* inclusive and omits the constant term. @@ -1309,13 +1309,13 @@ cdef extern from "flint_wrap.h": # resulting in slightly higher memory usage but better speed. For best # efficiency, *N* should have many trailing zero bits. - void arb_exp_arf_rs_generic(arb_t res, const arf_t x, long prec, int minus_one) + void arb_exp_arf_rs_generic(arb_t res, const arf_t x, slong prec, int minus_one) # Computes the exponential function using a generic version of the rectangular # splitting strategy, intended for intermediate precision. - void _arb_atan_sum_bs_simple(fmpz_t T, fmpz_t Q, flint_bitcnt_t * Qexp, const fmpz_t x, flint_bitcnt_t r, long N) + void _arb_atan_sum_bs_simple(fmpz_t T, fmpz_t Q, flint_bitcnt_t * Qexp, const fmpz_t x, flint_bitcnt_t r, slong N) - void _arb_atan_sum_bs_powtab(fmpz_t T, fmpz_t Q, flint_bitcnt_t * Qexp, const fmpz_t x, flint_bitcnt_t r, long N) + void _arb_atan_sum_bs_powtab(fmpz_t T, fmpz_t Q, flint_bitcnt_t * Qexp, const fmpz_t x, flint_bitcnt_t r, slong N) # Computes *T*, *Q* and *Qexp* such that # `T / (Q 2^{\text{Qexp}}) = \sum_{k=1}^N (-1)^k (x/2^r)^{2k} / (2k+1)` # using binary splitting. @@ -1326,7 +1326,7 @@ cdef extern from "flint_wrap.h": # resulting in slightly higher memory usage but better speed. For best # efficiency, *N* should have many trailing zero bits. - void arb_atan_arf_bb(arb_t z, const arf_t x, long prec) + void arb_atan_arf_bb(arb_t z, const arf_t x, slong prec) # Computes the arctangent of *x*. # Initially, the argument-halving formula # .. math :: @@ -1342,11 +1342,11 @@ cdef extern from "flint_wrap.h": # is applied repeatedly instead of integrating a differential # equation for the arctangent, as this appears to be more efficient. - void arb_atan_frac_bsplit(arb_t s, const fmpz_t p, const fmpz_t q, int hyperbolic, long prec) + void arb_atan_frac_bsplit(arb_t s, const fmpz_t p, const fmpz_t q, int hyperbolic, slong prec) # Computes the arctangent of `p/q`, optionally the hyperbolic # arctangent, using direct series summation with binary splitting. - void arb_sin_cos_arf_generic(arb_t s, arb_t c, const arf_t x, long prec) + void arb_sin_cos_arf_generic(arb_t s, arb_t c, const arf_t x, slong prec) # Computes the sine and cosine of *x* using a generic strategy. # This function gets called internally by the main sin and cos functions # when the precision for argument reduction or series evaluation @@ -1360,11 +1360,11 @@ cdef extern from "flint_wrap.h": # of the rectangular splitting algorithm if the precision is not too high, # and otherwise invokes the asymptotically fast bit-burst algorithm. - void arb_sin_cos_arf_bb(arb_t s, arb_t c, const arf_t x, long prec) + void arb_sin_cos_arf_bb(arb_t s, arb_t c, const arf_t x, slong prec) # Computes the sine and cosine of *x* using the bit-burst algorithm. # It is required that `|x| < \pi / 2` (this is not checked). - void arb_sin_cos_wide(arb_t s, arb_t c, const arb_t x, long prec) + void arb_sin_cos_wide(arb_t s, arb_t c, const arb_t x, slong prec) # Computes an accurate enclosure (with both endpoints optimal to within # about `2^{-30}` as afforded by the radius format) of the range of # sine and cosine on a given wide interval. The computation is done @@ -1380,111 +1380,111 @@ cdef extern from "flint_wrap.h": # slower reduction using :type:`arb_t` arithmetic is done as a # preprocessing step. - void arb_sin_cos_generic(arb_t s, arb_t c, const arb_t x, long prec) + void arb_sin_cos_generic(arb_t s, arb_t c, const arb_t x, slong prec) # Computes the sine and cosine of *x* by taking care of various special # cases and computing the propagated error before calling # :func:`arb_sin_cos_arf_generic`. This is used as a fallback inside # :func:`arb_sin_cos` to take care of all cases without a fast # path in that function. - void arb_log_primes_vec_bsplit(arb_ptr res, long n, long prec) + void arb_log_primes_vec_bsplit(arb_ptr res, slong n, slong prec) # Sets *res* to a vector containing the natural logarithms of # the first *n* prime numbers, computed using binary splitting # applied to simultaneous Machine-type formulas. This function is not # optimized for large *n* or small *prec*. - void _arb_log_p_ensure_cached(long prec) + void _arb_log_p_ensure_cached(slong prec) # Ensure that the internal cache of logarithms of small prime # numbers has entries to at least *prec* bits. - void arb_exp_arf_log_reduction(arb_t res, const arf_t x, long prec, int minus_one) + void arb_exp_arf_log_reduction(arb_t res, const arf_t x, slong prec, int minus_one) # Computes the exponential function using log reduction. - void arb_exp_arf_generic(arb_t z, const arf_t x, long prec, int minus_one) + void arb_exp_arf_generic(arb_t z, const arf_t x, slong prec, int minus_one) # Computes the exponential function using an automatic choice # between rectangular splitting and the bit-burst algorithm, # without precomputation. - void arb_exp_arf(arb_t z, const arf_t x, long prec, int minus_one, long maglim) + void arb_exp_arf(arb_t z, const arf_t x, slong prec, int minus_one, slong maglim) # Computes the exponential function using an automatic choice # between all implemented algorithms. - void arb_log_newton(arb_t res, const arb_t x, long prec) - void arb_log_arf_newton(arb_t res, const arf_t x, long prec) + void arb_log_newton(arb_t res, const arb_t x, slong prec) + void arb_log_arf_newton(arb_t res, const arf_t x, slong prec) # Computes the logarithm using Newton iteration. - void arb_atan_gauss_primes_vec_bsplit(arb_ptr res, long n, long prec) + void arb_atan_gauss_primes_vec_bsplit(arb_ptr res, slong n, slong prec) # Sets *res* to the primitive angles corresponding to the # first *n* nonreal Gaussian primes (ignoring symmetries), # computed using binary splitting # applied to simultaneous Machine-type formulas. This function is not # optimized for large *n* or small *prec*. - void _arb_atan_gauss_p_ensure_cached(long prec) + void _arb_atan_gauss_p_ensure_cached(slong prec) - void arb_sin_cos_arf_atan_reduction(arb_t res1, arb_t res2, const arf_t x, long prec) + void arb_sin_cos_arf_atan_reduction(arb_t res1, arb_t res2, const arf_t x, slong prec) # Computes sin and/or cos using reduction by primitive angles. - void arb_atan_newton(arb_t res, const arb_t x, long prec) - void arb_atan_arf_newton(arb_t res, const arf_t x, long prec) + void arb_atan_newton(arb_t res, const arb_t x, slong prec) + void arb_atan_arf_newton(arb_t res, const arf_t x, slong prec) # Computes the arctangent using Newton iteration. - void _arb_vec_zero(arb_ptr vec, long n) + void _arb_vec_zero(arb_ptr vec, slong n) # Sets all entries in *vec* to zero. - int _arb_vec_is_zero(arb_srcptr vec, long len) + int _arb_vec_is_zero(arb_srcptr vec, slong len) # Returns nonzero iff all entries in *x* are zero. - int _arb_vec_is_finite(arb_srcptr x, long len) + int _arb_vec_is_finite(arb_srcptr x, slong len) # Returns nonzero iff all entries in *x* certainly are finite. - void _arb_vec_set(arb_ptr res, arb_srcptr vec, long len) + void _arb_vec_set(arb_ptr res, arb_srcptr vec, slong len) # Sets *res* to a copy of *vec*. - void _arb_vec_set_round(arb_ptr res, arb_srcptr vec, long len, long prec) + void _arb_vec_set_round(arb_ptr res, arb_srcptr vec, slong len, slong prec) # Sets *res* to a copy of *vec*, rounding each entry to *prec* bits. - void _arb_vec_swap(arb_ptr vec1, arb_ptr vec2, long len) + void _arb_vec_swap(arb_ptr vec1, arb_ptr vec2, slong len) # Swaps the entries of *vec1* and *vec2*. - void _arb_vec_neg(arb_ptr B, arb_srcptr A, long n) + void _arb_vec_neg(arb_ptr B, arb_srcptr A, slong n) - void _arb_vec_sub(arb_ptr C, arb_srcptr A, arb_srcptr B, long n, long prec) + void _arb_vec_sub(arb_ptr C, arb_srcptr A, arb_srcptr B, slong n, slong prec) - void _arb_vec_add(arb_ptr C, arb_srcptr A, arb_srcptr B, long n, long prec) + void _arb_vec_add(arb_ptr C, arb_srcptr A, arb_srcptr B, slong n, slong prec) - void _arb_vec_scalar_mul(arb_ptr res, arb_srcptr vec, long len, const arb_t c, long prec) + void _arb_vec_scalar_mul(arb_ptr res, arb_srcptr vec, slong len, const arb_t c, slong prec) - void _arb_vec_scalar_div(arb_ptr res, arb_srcptr vec, long len, const arb_t c, long prec) + void _arb_vec_scalar_div(arb_ptr res, arb_srcptr vec, slong len, const arb_t c, slong prec) - void _arb_vec_scalar_mul_fmpz(arb_ptr res, arb_srcptr vec, long len, const fmpz_t c, long prec) + void _arb_vec_scalar_mul_fmpz(arb_ptr res, arb_srcptr vec, slong len, const fmpz_t c, slong prec) - void _arb_vec_scalar_mul_2exp_si(arb_ptr res, arb_srcptr src, long len, long c) + void _arb_vec_scalar_mul_2exp_si(arb_ptr res, arb_srcptr src, slong len, slong c) - void _arb_vec_scalar_addmul(arb_ptr res, arb_srcptr vec, long len, const arb_t c, long prec) + void _arb_vec_scalar_addmul(arb_ptr res, arb_srcptr vec, slong len, const arb_t c, slong prec) - void _arb_vec_get_mag(mag_t bound, arb_srcptr vec, long len) + void _arb_vec_get_mag(mag_t bound, arb_srcptr vec, slong len) # Sets *bound* to an upper bound for the entries in *vec*. - long _arb_vec_bits(arb_srcptr x, long len) + slong _arb_vec_bits(arb_srcptr x, slong len) # Returns the maximum of :func:`arb_bits` for all entries in *vec*. - void _arb_vec_set_powers(arb_ptr xs, const arb_t x, long len, long prec) + void _arb_vec_set_powers(arb_ptr xs, const arb_t x, slong len, slong prec) # Sets *xs* to the powers `1, x, x^2, \ldots, x^{len-1}`. - void _arb_vec_add_error_arf_vec(arb_ptr res, arf_srcptr err, long len) + void _arb_vec_add_error_arf_vec(arb_ptr res, arf_srcptr err, slong len) - void _arb_vec_add_error_mag_vec(arb_ptr res, mag_srcptr err, long len) + void _arb_vec_add_error_mag_vec(arb_ptr res, mag_srcptr err, slong len) # Adds the magnitude of each entry in *err* to the radius of the # corresponding entry in *res*. - void _arb_vec_indeterminate(arb_ptr vec, long len) + void _arb_vec_indeterminate(arb_ptr vec, slong len) # Applies :func:`arb_indeterminate` elementwise. - void _arb_vec_trim(arb_ptr res, arb_srcptr vec, long len) + void _arb_vec_trim(arb_ptr res, arb_srcptr vec, slong len) # Applies :func:`arb_trim` elementwise. - int _arb_vec_get_unique_fmpz_vec(fmpz * res, arb_srcptr vec, long len) + int _arb_vec_get_unique_fmpz_vec(fmpz * res, arb_srcptr vec, slong len) # Calls :func:`arb_get_unique_fmpz` elementwise and returns nonzero if # all entries can be rounded uniquely to integers. If any entry in *vec* # cannot be rounded uniquely to an integer, returns zero. diff --git a/src/sage/libs/flint/arb_calc.pxd b/src/sage/libs/flint/arb_calc.pxd index c98a6ff5765..27b6601ec59 100644 --- a/src/sage/libs/flint/arb_calc.pxd +++ b/src/sage/libs/flint/arb_calc.pxd @@ -16,23 +16,23 @@ cdef extern from "flint_wrap.h": void arf_interval_clear(arf_interval_t v) - arf_interval_ptr _arf_interval_vec_init(long n) + arf_interval_ptr _arf_interval_vec_init(slong n) - void _arf_interval_vec_clear(arf_interval_ptr v, long n) + void _arf_interval_vec_clear(arf_interval_ptr v, slong n) void arf_interval_set(arf_interval_t v, const arf_interval_t u) void arf_interval_swap(arf_interval_t v, arf_interval_t u) - void arf_interval_get_arb(arb_t x, const arf_interval_t v, long prec) + void arf_interval_get_arb(arb_t x, const arf_interval_t v, slong prec) - void arf_interval_printd(const arf_interval_t v, long n) + void arf_interval_printd(const arf_interval_t v, slong n) # Helper functions for endpoint-based intervals. - void arf_interval_fprintd(FILE * file, const arf_interval_t v, long n) + void arf_interval_fprintd(FILE * file, const arf_interval_t v, slong n) # Helper functions for endpoint-based intervals. - long arb_calc_isolate_roots(arf_interval_ptr * found, int ** flags, arb_calc_func_t func, void * param, const arf_interval_t interval, long maxdepth, long maxeval, long maxfound, long prec) + slong arb_calc_isolate_roots(arf_interval_ptr * found, int ** flags, arb_calc_func_t func, void * param, const arf_interval_t interval, slong maxdepth, slong maxeval, slong maxfound, slong prec) # Rigorously isolates single roots of a real analytic function # on the interior of an interval. # This routine writes an array of *n* interesting subintervals of @@ -75,14 +75,14 @@ cdef extern from "flint_wrap.h": # represented exactly as floating-point numbers in memory. # Do not pass `1 \pm 2^{-10^{100}}` as input. - int arb_calc_refine_root_bisect(arf_interval_t r, arb_calc_func_t func, void * param, const arf_interval_t start, long it, long prec) + int arb_calc_refine_root_bisect(arf_interval_t r, arb_calc_func_t func, void * param, const arf_interval_t start, slong it, slong prec) # Given an interval *start* known to contain a single root of *func*, # refines it using *iter* bisection steps. The algorithm can # return a failure code if the sign of the function at an evaluation # point is ambiguous. The output *r* is set to a valid isolating interval # (possibly just *start*) even if the algorithm fails. - void arb_calc_newton_conv_factor(arf_t conv_factor, arb_calc_func_t func, void * param, const arb_t conv_region, long prec) + void arb_calc_newton_conv_factor(arf_t conv_factor, arb_calc_func_t func, void * param, const arb_t conv_region, slong prec) # Given an interval `I` specified by *conv_region*, evaluates a bound # for `C = \sup_{t,u \in I} \frac{1}{2} |f''(t)| / |f'(u)|`, # where `f` is the function specified by *func* and *param*. @@ -90,7 +90,7 @@ cdef extern from "flint_wrap.h": # If `f` is ill-conditioned, `I` may need to be extremely precise in # order to get an effective, finite bound for *C*. - int arb_calc_newton_step(arb_t xnew, arb_calc_func_t func, void * param, const arb_t x, const arb_t conv_region, const arf_t conv_factor, long prec) + int arb_calc_newton_step(arb_t xnew, arb_calc_func_t func, void * param, const arb_t x, const arb_t conv_region, const arf_t conv_factor, slong prec) # Performs a single step with an interval version of Newton's method. # The input consists of the function `f` specified # by *func* and *param*, a ball `x = [m-r, m+r]` known @@ -109,7 +109,7 @@ cdef extern from "flint_wrap.h": # *ARB_CALC_NO_CONVERGENCE*, indicating that no progress # is made. - int arb_calc_refine_root_newton(arb_t r, arb_calc_func_t func, void * param, const arb_t start, const arb_t conv_region, const arf_t conv_factor, long eval_extra_prec, long prec) + int arb_calc_refine_root_newton(arb_t r, arb_calc_func_t func, void * param, const arb_t start, const arb_t conv_region, const arf_t conv_factor, slong eval_extra_prec, slong prec) # Refines a precise estimate of a single root of a function # to high precision by performing several Newton steps, using # nearly optimally chosen doubling precision steps. diff --git a/src/sage/libs/flint/arb_fmpz_poly.pxd b/src/sage/libs/flint/arb_fmpz_poly.pxd index 4d439287ef0..0ef6725ffaa 100644 --- a/src/sage/libs/flint/arb_fmpz_poly.pxd +++ b/src/sage/libs/flint/arb_fmpz_poly.pxd @@ -12,40 +12,40 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void _arb_fmpz_poly_evaluate_arb_horner(arb_t res, const fmpz * poly, long len, const arb_t x, long prec) + void _arb_fmpz_poly_evaluate_arb_horner(arb_t res, const fmpz * poly, slong len, const arb_t x, slong prec) - void arb_fmpz_poly_evaluate_arb_horner(arb_t res, const fmpz_poly_t poly, const arb_t x, long prec) + void arb_fmpz_poly_evaluate_arb_horner(arb_t res, const fmpz_poly_t poly, const arb_t x, slong prec) - void _arb_fmpz_poly_evaluate_arb_rectangular(arb_t res, const fmpz * poly, long len, const arb_t x, long prec) + void _arb_fmpz_poly_evaluate_arb_rectangular(arb_t res, const fmpz * poly, slong len, const arb_t x, slong prec) - void arb_fmpz_poly_evaluate_arb_rectangular(arb_t res, const fmpz_poly_t poly, const arb_t x, long prec) + void arb_fmpz_poly_evaluate_arb_rectangular(arb_t res, const fmpz_poly_t poly, const arb_t x, slong prec) - void _arb_fmpz_poly_evaluate_arb(arb_t res, const fmpz * poly, long len, const arb_t x, long prec) + void _arb_fmpz_poly_evaluate_arb(arb_t res, const fmpz * poly, slong len, const arb_t x, slong prec) - void arb_fmpz_poly_evaluate_arb(arb_t res, const fmpz_poly_t poly, const arb_t x, long prec) + void arb_fmpz_poly_evaluate_arb(arb_t res, const fmpz_poly_t poly, const arb_t x, slong prec) - void _arb_fmpz_poly_evaluate_acb_horner(acb_t res, const fmpz * poly, long len, const acb_t x, long prec) + void _arb_fmpz_poly_evaluate_acb_horner(acb_t res, const fmpz * poly, slong len, const acb_t x, slong prec) - void arb_fmpz_poly_evaluate_acb_horner(acb_t res, const fmpz_poly_t poly, const acb_t x, long prec) + void arb_fmpz_poly_evaluate_acb_horner(acb_t res, const fmpz_poly_t poly, const acb_t x, slong prec) - void _arb_fmpz_poly_evaluate_acb_rectangular(acb_t res, const fmpz * poly, long len, const acb_t x, long prec) + void _arb_fmpz_poly_evaluate_acb_rectangular(acb_t res, const fmpz * poly, slong len, const acb_t x, slong prec) - void arb_fmpz_poly_evaluate_acb_rectangular(acb_t res, const fmpz_poly_t poly, const acb_t x, long prec) + void arb_fmpz_poly_evaluate_acb_rectangular(acb_t res, const fmpz_poly_t poly, const acb_t x, slong prec) - void _arb_fmpz_poly_evaluate_acb(acb_t res, const fmpz * poly, long len, const acb_t x, long prec) + void _arb_fmpz_poly_evaluate_acb(acb_t res, const fmpz * poly, slong len, const acb_t x, slong prec) - void arb_fmpz_poly_evaluate_acb(acb_t res, const fmpz_poly_t poly, const acb_t x, long prec) + void arb_fmpz_poly_evaluate_acb(acb_t res, const fmpz_poly_t poly, const acb_t x, slong prec) # Evaluates *poly* (given by a polynomial object or an array with *len* coefficients) # at the given real or complex number, respectively using Horner's rule, rectangular # splitting, or a default algorithm choice. - unsigned long arb_fmpz_poly_deflation(const fmpz_poly_t poly) + ulong arb_fmpz_poly_deflation(const fmpz_poly_t poly) # Finds the maximal exponent by which *poly* can be deflated. - void arb_fmpz_poly_deflate(fmpz_poly_t res, const fmpz_poly_t poly, unsigned long deflation) + void arb_fmpz_poly_deflate(fmpz_poly_t res, const fmpz_poly_t poly, ulong deflation) # Sets *res* to a copy of *poly* deflated by the exponent *deflation*. - void arb_fmpz_poly_complex_roots(acb_ptr roots, const fmpz_poly_t poly, int flags, long prec) + void arb_fmpz_poly_complex_roots(acb_ptr roots, const fmpz_poly_t poly, int flags, slong prec) # Writes to *roots* all the real and complex roots of the polynomial *poly*, # computed to at least *prec* accurate bits. # The root enclosures are guaranteed to be disjoint, so that @@ -80,12 +80,12 @@ cdef extern from "flint_wrap.h": # The following *flags* are supported: # * *ARB_FMPZ_POLY_ROOTS_VERBOSE* - void arb_fmpz_poly_cos_minpoly(fmpz_poly_t res, unsigned long n) + void arb_fmpz_poly_cos_minpoly(fmpz_poly_t res, ulong n) # Sets *res* to the monic minimal polynomial of `2 \cos(2 \pi / n)`. # This is a wrapper of FLINT's *fmpz_poly_cos_minpoly*, provided here # for backward compatibility. - void arb_fmpz_poly_gauss_period_minpoly(fmpz_poly_t res, unsigned long q, unsigned long n) + void arb_fmpz_poly_gauss_period_minpoly(fmpz_poly_t res, ulong q, ulong n) # Sets *res* to the minimal polynomial of the Gaussian periods # `\sum_{a \in H} \zeta^a` where `\zeta = \exp(2 \pi i / q)` # and *H* are the cosets of the subgroups of order `d = (q - 1) / n` of diff --git a/src/sage/libs/flint/arb_fpwrap.pxd b/src/sage/libs/flint/arb_fpwrap.pxd index c44fc48c920..beb5e912a64 100644 --- a/src/sage/libs/flint/arb_fpwrap.pxd +++ b/src/sage/libs/flint/arb_fpwrap.pxd @@ -92,8 +92,8 @@ cdef extern from "flint_wrap.h": int arb_fpwrap_double_atanh(double * res, double x, int flags) int arb_fpwrap_cdouble_atanh(complex_double * res, complex_double x, int flags) - int arb_fpwrap_double_lambertw(double * res, double x, long branch, int flags) - int arb_fpwrap_cdouble_lambertw(complex_double * res, complex_double x, long branch, int flags) + int arb_fpwrap_double_lambertw(double * res, double x, slong branch, int flags) + int arb_fpwrap_cdouble_lambertw(complex_double * res, complex_double x, slong branch, int flags) int arb_fpwrap_double_rising(double * res, double x, double n, int flags) int arb_fpwrap_cdouble_rising(complex_double * res, complex_double x, complex_double n, int flags) @@ -151,7 +151,7 @@ cdef extern from "flint_wrap.h": int arb_fpwrap_cdouble_hardy_z(complex_double * res, complex_double z, int flags) - int arb_fpwrap_cdouble_zeta_zero(complex_double * res, unsigned long n, int flags) + int arb_fpwrap_cdouble_zeta_zero(complex_double * res, ulong n, int flags) int arb_fpwrap_double_erf(double * res, double x, int flags) int arb_fpwrap_cdouble_erf(complex_double * res, complex_double x, int flags) @@ -232,13 +232,13 @@ cdef extern from "flint_wrap.h": int arb_fpwrap_double_airy_bi_prime(double * res, double x, int flags) int arb_fpwrap_cdouble_airy_bi_prime(complex_double * res, complex_double x, int flags) - int arb_fpwrap_double_airy_ai_zero(double * res, unsigned long n, int flags) + int arb_fpwrap_double_airy_ai_zero(double * res, ulong n, int flags) - int arb_fpwrap_double_airy_ai_prime_zero(double * res, unsigned long n, int flags) + int arb_fpwrap_double_airy_ai_prime_zero(double * res, ulong n, int flags) - int arb_fpwrap_double_airy_bi_zero(double * res, unsigned long n, int flags) + int arb_fpwrap_double_airy_bi_zero(double * res, ulong n, int flags) - int arb_fpwrap_double_airy_bi_prime_zero(double * res, unsigned long n, int flags) + int arb_fpwrap_double_airy_bi_prime_zero(double * res, ulong n, int flags) int arb_fpwrap_double_coulomb_f(double * res, double l, double eta, double x, int flags) int arb_fpwrap_cdouble_coulomb_f(complex_double * res, complex_double l, complex_double eta, complex_double x, int flags) @@ -273,12 +273,12 @@ cdef extern from "flint_wrap.h": int arb_fpwrap_double_legendre_q(double * res, double n, double m, double x, int type, int flags) int arb_fpwrap_cdouble_legendre_q(complex_double * res, complex_double n, complex_double m, complex_double x, int type, int flags) - int arb_fpwrap_double_legendre_root(double * res1, double * res2, unsigned long n, unsigned long k, int flags) + int arb_fpwrap_double_legendre_root(double * res1, double * res2, ulong n, ulong k, int flags) # Sets *res1* to the index *k* root of the Legendre polynomial `P_n(x)`, # and simultaneously sets *res2* to the corresponding weight for # Gauss-Legendre quadrature. - int arb_fpwrap_cdouble_spherical_y(complex_double * res, long n, long m, complex_double x1, complex_double x2, int flags) + int arb_fpwrap_cdouble_spherical_y(complex_double * res, slong n, slong m, complex_double x1, complex_double x2, int flags) int arb_fpwrap_double_hypgeom_0f1(double * res, double a, double x, int regularized, int flags) int arb_fpwrap_cdouble_hypgeom_0f1(complex_double * res, complex_double a, complex_double x, int regularized, int flags) @@ -292,8 +292,8 @@ cdef extern from "flint_wrap.h": int arb_fpwrap_double_hypgeom_2f1(double * res, double a, double b, double c, double x, int regularized, int flags) int arb_fpwrap_cdouble_hypgeom_2f1(complex_double * res, complex_double a, complex_double b, complex_double c, complex_double x, int regularized, int flags) - int arb_fpwrap_double_hypgeom_pfq(double * res, const double * a, long p, const double * b, long q, double z, int regularized, int flags) - int arb_fpwrap_cdouble_hypgeom_pfq(complex_double * res, const complex_double * a, long p, const complex_double * b, long q, complex_double z, int regularized, int flags) + int arb_fpwrap_double_hypgeom_pfq(double * res, const double * a, slong p, const double * b, slong q, double z, int regularized, int flags) + int arb_fpwrap_cdouble_hypgeom_pfq(complex_double * res, const complex_double * a, slong p, const complex_double * b, slong q, complex_double z, int regularized, int flags) int arb_fpwrap_double_agm(double * res, double x, double y, int flags) int arb_fpwrap_cdouble_agm(complex_double * res, complex_double x, complex_double y, int flags) diff --git a/src/sage/libs/flint/arb_hypgeom.pxd b/src/sage/libs/flint/arb_hypgeom.pxd index 63ae194e20a..6bdbd4e5f9b 100644 --- a/src/sage/libs/flint/arb_hypgeom.pxd +++ b/src/sage/libs/flint/arb_hypgeom.pxd @@ -12,9 +12,9 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void _arb_hypgeom_rising_coeffs_1(unsigned long * c, unsigned long k, long n) - void _arb_hypgeom_rising_coeffs_2(unsigned long * c, unsigned long k, long n) - void _arb_hypgeom_rising_coeffs_fmpz(fmpz * c, unsigned long k, long n) + void _arb_hypgeom_rising_coeffs_1(ulong * c, ulong k, slong n) + void _arb_hypgeom_rising_coeffs_2(ulong * c, ulong k, slong n) + void _arb_hypgeom_rising_coeffs_fmpz(fmpz * c, ulong k, slong n) # Sets *c* to the coefficients of the rising factorial polynomial # `(X+k)_n`. The *1* and *2* versions respectively # compute single-word and double-word coefficients, without checking for @@ -23,12 +23,12 @@ cdef extern from "flint_wrap.h": # does not use an asymptotically fast algorithm. # The degree *n* must be at least 2. - void arb_hypgeom_rising_ui_forward(arb_t res, const arb_t x, unsigned long n, long prec) - void arb_hypgeom_rising_ui_bs(arb_t res, const arb_t x, unsigned long n, long prec) - void arb_hypgeom_rising_ui_rs(arb_t res, const arb_t x, unsigned long n, unsigned long m, long prec) - void arb_hypgeom_rising_ui_rec(arb_t res, const arb_t x, unsigned long n, long prec) - void arb_hypgeom_rising_ui(arb_t res, const arb_t x, unsigned long n, long prec) - void arb_hypgeom_rising(arb_t res, const arb_t x, const arb_t n, long prec) + void arb_hypgeom_rising_ui_forward(arb_t res, const arb_t x, ulong n, slong prec) + void arb_hypgeom_rising_ui_bs(arb_t res, const arb_t x, ulong n, slong prec) + void arb_hypgeom_rising_ui_rs(arb_t res, const arb_t x, ulong n, ulong m, slong prec) + void arb_hypgeom_rising_ui_rec(arb_t res, const arb_t x, ulong n, slong prec) + void arb_hypgeom_rising_ui(arb_t res, const arb_t x, ulong n, slong prec) + void arb_hypgeom_rising(arb_t res, const arb_t x, const arb_t n, slong prec) # Computes the rising factorial `(x)_n`. # The *forward* version uses the forward recurrence. # The *bs* version uses binary splitting. @@ -40,10 +40,10 @@ cdef extern from "flint_wrap.h": # The default versions (*rising_ui* and *rising_ui*) choose an algorithm # automatically and may additionally fall back on the gamma function. - void arb_hypgeom_rising_ui_jet_powsum(arb_ptr res, const arb_t x, unsigned long n, long len, long prec) - void arb_hypgeom_rising_ui_jet_bs(arb_ptr res, const arb_t x, unsigned long n, long len, long prec) - void arb_hypgeom_rising_ui_jet_rs(arb_ptr res, const arb_t x, unsigned long n, unsigned long m, long len, long prec) - void arb_hypgeom_rising_ui_jet(arb_ptr res, const arb_t x, unsigned long n, long len, long prec) + void arb_hypgeom_rising_ui_jet_powsum(arb_ptr res, const arb_t x, ulong n, slong len, slong prec) + void arb_hypgeom_rising_ui_jet_bs(arb_ptr res, const arb_t x, ulong n, slong len, slong prec) + void arb_hypgeom_rising_ui_jet_rs(arb_ptr res, const arb_t x, ulong n, ulong m, slong len, slong prec) + void arb_hypgeom_rising_ui_jet(arb_ptr res, const arb_t x, ulong n, slong len, slong prec) # Computes the jet of the rising factorial `(x)_n`, truncated to length *len*. # In other words, constructs the polynomial `(X + x)_n \in \mathbb{R}[X]`, # truncated if `\operatorname{len} < n + 1` (and zero-extended @@ -55,14 +55,14 @@ cdef extern from "flint_wrap.h": # parameter *m* which can be set to zero to choose automatically. # The default version chooses an algorithm automatically. - void _arb_hypgeom_gamma_stirling_term_bounds(long * bound, const mag_t zinv, long N) + void _arb_hypgeom_gamma_stirling_term_bounds(slong * bound, const mag_t zinv, slong N) # For `1 \le n < N`, sets *bound* to an exponent bounding the *n*-th term # in the Stirling series for the gamma function, given a precomputed upper # bound for `|z|^{-1}`. This function is intended for internal use and # does not check for underflow or underflow in the exponents. - void arb_hypgeom_gamma_stirling_sum_horner(arb_t res, const arb_t z, long N, long prec) - void arb_hypgeom_gamma_stirling_sum_improved(arb_t res, const arb_t z, long N, long K, long prec) + void arb_hypgeom_gamma_stirling_sum_horner(arb_t res, const arb_t z, slong N, slong prec) + void arb_hypgeom_gamma_stirling_sum_improved(arb_t res, const arb_t z, slong N, slong K, slong prec) # Sets *res* to the final sum in the Stirling series for the gamma function # truncated before the term with index *N*, i.e. computes # `\sum_{n=1}^{N-1} B_{2n} / (2n(2n-1) z^{2n-1})`. @@ -72,53 +72,53 @@ cdef extern from "flint_wrap.h": # using a splitting parameter *K* (which can be set to 0 to use a default # value). - void arb_hypgeom_gamma_stirling(arb_t res, const arb_t x, int reciprocal, long prec) + void arb_hypgeom_gamma_stirling(arb_t res, const arb_t x, int reciprocal, slong prec) # Sets *res* to the gamma function of *x* computed using the Stirling # series together with argument reduction. If *reciprocal* is set, # the reciprocal gamma function is computed instead. - int arb_hypgeom_gamma_taylor(arb_t res, const arb_t x, int reciprocal, long prec) + int arb_hypgeom_gamma_taylor(arb_t res, const arb_t x, int reciprocal, slong prec) # Attempts to compute the gamma function of *x* using Taylor series # together with argument reduction. This is only supported if *x* and *prec* # are both small enough. If successful, returns 1; otherwise, does nothing # and returns 0. If *reciprocal* is set, the reciprocal gamma function is # computed instead. - void arb_hypgeom_gamma(arb_t res, const arb_t x, long prec) - void arb_hypgeom_gamma_fmpq(arb_t res, const fmpq_t x, long prec) - void arb_hypgeom_gamma_fmpz(arb_t res, const fmpz_t x, long prec) + void arb_hypgeom_gamma(arb_t res, const arb_t x, slong prec) + void arb_hypgeom_gamma_fmpq(arb_t res, const fmpq_t x, slong prec) + void arb_hypgeom_gamma_fmpz(arb_t res, const fmpz_t x, slong prec) # Sets *res* to the gamma function of *x* computed using a default # algorithm choice. - void arb_hypgeom_rgamma(arb_t res, const arb_t x, long prec) + void arb_hypgeom_rgamma(arb_t res, const arb_t x, slong prec) # Sets *res* to the reciprocal gamma function of *x* computed using a default # algorithm choice. - void arb_hypgeom_lgamma(arb_t res, const arb_t x, long prec) + void arb_hypgeom_lgamma(arb_t res, const arb_t x, slong prec) # Sets *res* to the log-gamma function of *x* computed using a default # algorithm choice. - void arb_hypgeom_central_bin_ui(arb_t res, unsigned long n, long prec) + void arb_hypgeom_central_bin_ui(arb_t res, ulong n, slong prec) # Computes the central binomial coefficient `{2n \choose n}`. - void arb_hypgeom_pfq(arb_t res, arb_srcptr a, long p, arb_srcptr b, long q, const arb_t z, int regularized, long prec) + void arb_hypgeom_pfq(arb_t res, arb_srcptr a, slong p, arb_srcptr b, slong q, const arb_t z, int regularized, slong prec) # Computes the generalized hypergeometric function `{}_pF_{q}(z)`, # or the regularized version if *regularized* is set. - void arb_hypgeom_0f1(arb_t res, const arb_t a, const arb_t z, int regularized, long prec) + void arb_hypgeom_0f1(arb_t res, const arb_t a, const arb_t z, int regularized, slong prec) # Computes the confluent hypergeometric limit function # `{}_0F_1(a,z)`, or `\frac{1}{\Gamma(a)} {}_0F_1(a,z)` if *regularized* # is set. - void arb_hypgeom_m(arb_t res, const arb_t a, const arb_t b, const arb_t z, int regularized, long prec) + void arb_hypgeom_m(arb_t res, const arb_t a, const arb_t b, const arb_t z, int regularized, slong prec) # Computes the confluent hypergeometric function # `M(a,b,z) = {}_1F_1(a,b,z)`, or # `\mathbf{M}(a,b,z) = \frac{1}{\Gamma(b)} {}_1F_1(a,b,z)` if *regularized* is set. - void arb_hypgeom_1f1(arb_t res, const arb_t a, const arb_t b, const arb_t z, int regularized, long prec) + void arb_hypgeom_1f1(arb_t res, const arb_t a, const arb_t b, const arb_t z, int regularized, slong prec) # Alias for :func:`arb_hypgeom_m`. - void arb_hypgeom_1f1_integration(arb_t res, const arb_t a, const arb_t b, const arb_t z, int regularized, long prec) + void arb_hypgeom_1f1_integration(arb_t res, const arb_t a, const arb_t b, const arb_t z, int regularized, slong prec) # Computes the confluent hypergeometric function using numerical integration # of the representation # .. math :: @@ -126,10 +126,10 @@ cdef extern from "flint_wrap.h": # This algorithm can be useful if the parameters are large. This will currently # only return a finite enclosure if `a \ge 1` and `b - a \ge 1`. - void arb_hypgeom_u(arb_t res, const arb_t a, const arb_t b, const arb_t z, long prec) + void arb_hypgeom_u(arb_t res, const arb_t a, const arb_t b, const arb_t z, slong prec) # Computes the confluent hypergeometric function `U(a,b,z)`. - void arb_hypgeom_u_integration(arb_t res, const arb_t a, const arb_t b, const arb_t z, long prec) + void arb_hypgeom_u_integration(arb_t res, const arb_t a, const arb_t b, const arb_t z, slong prec) # Computes the confluent hypergeometric function `U(a,b,z)` using numerical integration # of the representation # .. math :: @@ -137,7 +137,7 @@ cdef extern from "flint_wrap.h": # This algorithm can be useful if the parameters are large. This will currently # only return a finite enclosure if `a \ge 1` and `z > 0`. - void arb_hypgeom_2f1(arb_t res, const arb_t a, const arb_t b, const arb_t c, const arb_t z, int regularized, long prec) + void arb_hypgeom_2f1(arb_t res, const arb_t a, const arb_t b, const arb_t c, const arb_t z, int regularized, slong prec) # Computes the Gauss hypergeometric function # `{}_2F_1(a,b,c,z)`, or # `\mathbf{F}(a,b,c,z) = \frac{1}{\Gamma(c)} {}_2F_1(a,b,c,z)` @@ -145,7 +145,7 @@ cdef extern from "flint_wrap.h": # Additional evaluation flags can be passed via the *regularized* # argument; see :func:`acb_hypgeom_2f1` for documentation. - void arb_hypgeom_2f1_integration(arb_t res, const arb_t a, const arb_t b, const arb_t c, const arb_t z, int regularized, long prec) + void arb_hypgeom_2f1_integration(arb_t res, const arb_t a, const arb_t b, const arb_t c, const arb_t z, int regularized, slong prec) # Computes the Gauss hypergeometric function using numerical integration # of the representation # .. math :: @@ -154,39 +154,39 @@ cdef extern from "flint_wrap.h": # only return a finite enclosure if `b \ge 1` and `c - b \ge 1` and # `z < 1`, possibly with *a* and *b* exchanged. - void arb_hypgeom_erf(arb_t res, const arb_t z, long prec) + void arb_hypgeom_erf(arb_t res, const arb_t z, slong prec) # Computes the error function `\operatorname{erf}(z)`. - void _arb_hypgeom_erf_series(arb_ptr res, arb_srcptr z, long zlen, long len, long prec) - void arb_hypgeom_erf_series(arb_poly_t res, const arb_poly_t z, long len, long prec) + void _arb_hypgeom_erf_series(arb_ptr res, arb_srcptr z, slong zlen, slong len, slong prec) + void arb_hypgeom_erf_series(arb_poly_t res, const arb_poly_t z, slong len, slong prec) # Computes the error function of the power series *z*, # truncated to length *len*. - void arb_hypgeom_erfc(arb_t res, const arb_t z, long prec) + void arb_hypgeom_erfc(arb_t res, const arb_t z, slong prec) # Computes the complementary error function # `\operatorname{erfc}(z) = 1 - \operatorname{erf}(z)`. # This function avoids catastrophic cancellation for large positive *z*. - void _arb_hypgeom_erfc_series(arb_ptr res, arb_srcptr z, long zlen, long len, long prec) - void arb_hypgeom_erfc_series(arb_poly_t res, const arb_poly_t z, long len, long prec) + void _arb_hypgeom_erfc_series(arb_ptr res, arb_srcptr z, slong zlen, slong len, slong prec) + void arb_hypgeom_erfc_series(arb_poly_t res, const arb_poly_t z, slong len, slong prec) # Computes the complementary error function of the power series *z*, # truncated to length *len*. - void arb_hypgeom_erfi(arb_t res, const arb_t z, long prec) + void arb_hypgeom_erfi(arb_t res, const arb_t z, slong prec) # Computes the imaginary error function # `\operatorname{erfi}(z) = -i\operatorname{erf}(iz)`. - void _arb_hypgeom_erfi_series(arb_ptr res, arb_srcptr z, long zlen, long len, long prec) - void arb_hypgeom_erfi_series(arb_poly_t res, const arb_poly_t z, long len, long prec) + void _arb_hypgeom_erfi_series(arb_ptr res, arb_srcptr z, slong zlen, slong len, slong prec) + void arb_hypgeom_erfi_series(arb_poly_t res, const arb_poly_t z, slong len, slong prec) # Computes the imaginary error function of the power series *z*, # truncated to length *len*. - void arb_hypgeom_erfinv(arb_t res, const arb_t z, long prec) - void arb_hypgeom_erfcinv(arb_t res, const arb_t z, long prec) + void arb_hypgeom_erfinv(arb_t res, const arb_t z, slong prec) + void arb_hypgeom_erfcinv(arb_t res, const arb_t z, slong prec) # Computes the inverse error function `\operatorname{erf}^{-1}(z)` # or inverse complementary error function `\operatorname{erfc}^{-1}(z)`. - void arb_hypgeom_fresnel(arb_t res1, arb_t res2, const arb_t z, int normalized, long prec) + void arb_hypgeom_fresnel(arb_t res1, arb_t res2, const arb_t z, int normalized, slong prec) # Sets *res1* to the Fresnel sine integral `S(z)` and *res2* to # the Fresnel cosine integral `C(z)`. Optionally, just a single function # can be computed by passing *NULL* as the other output variable. @@ -195,14 +195,14 @@ cdef extern from "flint_wrap.h": # *normalized* is 1 (the latter is the Abramowitz & Stegun convention). # `C(z)` is defined analogously. - void _arb_hypgeom_fresnel_series(arb_ptr res1, arb_ptr res2, arb_srcptr z, long zlen, int normalized, long len, long prec) - void arb_hypgeom_fresnel_series(arb_poly_t res1, arb_poly_t res2, const arb_poly_t z, int normalized, long len, long prec) + void _arb_hypgeom_fresnel_series(arb_ptr res1, arb_ptr res2, arb_srcptr z, slong zlen, int normalized, slong len, slong prec) + void arb_hypgeom_fresnel_series(arb_poly_t res1, arb_poly_t res2, const arb_poly_t z, int normalized, slong len, slong prec) # Sets *res1* to the Fresnel sine integral and *res2* to the Fresnel # cosine integral of the power series *z*, truncated to length *len*. # Optionally, just a single function can be computed by passing *NULL* # as the other output variable. - void arb_hypgeom_gamma_upper(arb_t res, const arb_t s, const arb_t z, int regularized, long prec) + void arb_hypgeom_gamma_upper(arb_t res, const arb_t s, const arb_t z, int regularized, slong prec) # If *regularized* is 0, computes the upper incomplete gamma function # `\Gamma(s,z)`. # If *regularized* is 1, computes the regularized upper incomplete @@ -212,18 +212,18 @@ cdef extern from "flint_wrap.h": # intended for internal use; :func:`arb_hypgeom_expint` is the intended # interface for computing the exponential integral). - void arb_hypgeom_gamma_upper_integration(arb_t res, const arb_t s, const arb_t z, int regularized, long prec) + void arb_hypgeom_gamma_upper_integration(arb_t res, const arb_t s, const arb_t z, int regularized, slong prec) # Computes the upper incomplete gamma function using numerical # integration. - void _arb_hypgeom_gamma_upper_series(arb_ptr res, const arb_t s, arb_srcptr z, long zlen, int regularized, long n, long prec) - void arb_hypgeom_gamma_upper_series(arb_poly_t res, const arb_t s, const arb_poly_t z, int regularized, long n, long prec) + void _arb_hypgeom_gamma_upper_series(arb_ptr res, const arb_t s, arb_srcptr z, slong zlen, int regularized, slong n, slong prec) + void arb_hypgeom_gamma_upper_series(arb_poly_t res, const arb_t s, const arb_poly_t z, int regularized, slong n, slong prec) # Sets *res* to an upper incomplete gamma function where *s* is # a constant and *z* is a power series, truncated to length *n*. # The *regularized* argument has the same interpretation as in # :func:`arb_hypgeom_gamma_upper`. - void arb_hypgeom_gamma_lower(arb_t res, const arb_t s, const arb_t z, int regularized, long prec) + void arb_hypgeom_gamma_lower(arb_t res, const arb_t s, const arb_t z, int regularized, slong prec) # If *regularized* is 0, computes the lower incomplete gamma function # `\gamma(s,z) = \frac{z^s}{s} {}_1F_1(s, s+1, -z)`. # If *regularized* is 1, computes the regularized lower incomplete @@ -231,167 +231,167 @@ cdef extern from "flint_wrap.h": # If *regularized* is 2, computes a further regularized lower incomplete # gamma function `\gamma^{*}(s,z) = z^{-s} P(s,z)`. - void _arb_hypgeom_gamma_lower_series(arb_ptr res, const arb_t s, arb_srcptr z, long zlen, int regularized, long n, long prec) - void arb_hypgeom_gamma_lower_series(arb_poly_t res, const arb_t s, const arb_poly_t z, int regularized, long n, long prec) + void _arb_hypgeom_gamma_lower_series(arb_ptr res, const arb_t s, arb_srcptr z, slong zlen, int regularized, slong n, slong prec) + void arb_hypgeom_gamma_lower_series(arb_poly_t res, const arb_t s, const arb_poly_t z, int regularized, slong n, slong prec) # Sets *res* to an lower incomplete gamma function where *s* is # a constant and *z* is a power series, truncated to length *n*. # The *regularized* argument has the same interpretation as in # :func:`arb_hypgeom_gamma_lower`. - void arb_hypgeom_beta_lower(arb_t res, const arb_t a, const arb_t b, const arb_t z, int regularized, long prec) + void arb_hypgeom_beta_lower(arb_t res, const arb_t a, const arb_t b, const arb_t z, int regularized, slong prec) # Computes the (lower) incomplete beta function, defined by # `B(a,b;z) = \int_0^z t^{a-1} (1-t)^{b-1}`, # optionally the regularized incomplete beta function # `I(a,b;z) = B(a,b;z) / B(a,b;1)`. - void _arb_hypgeom_beta_lower_series(arb_ptr res, const arb_t a, const arb_t b, arb_srcptr z, long zlen, int regularized, long n, long prec) - void arb_hypgeom_beta_lower_series(arb_poly_t res, const arb_t a, const arb_t b, const arb_poly_t z, int regularized, long n, long prec) + void _arb_hypgeom_beta_lower_series(arb_ptr res, const arb_t a, const arb_t b, arb_srcptr z, slong zlen, int regularized, slong n, slong prec) + void arb_hypgeom_beta_lower_series(arb_poly_t res, const arb_t a, const arb_t b, const arb_poly_t z, int regularized, slong n, slong prec) # Sets *res* to the lower incomplete beta function `B(a,b;z)` (optionally # the regularized version `I(a,b;z)`) where *a* and *b* are constants # and *z* is a power series, truncating the result to length *n*. # The underscore method requires positive lengths and does not support # aliasing. - void _arb_hypgeom_gamma_lower_sum_rs_1(arb_t res, unsigned long p, unsigned long q, const arb_t z, long N, long prec) + void _arb_hypgeom_gamma_lower_sum_rs_1(arb_t res, ulong p, ulong q, const arb_t z, slong N, slong prec) # Computes `\sum_{k=0}^{N-1} z^k / (a)_k` where `a = p/q` using # rectangular splitting. It is assumed that `p + qN` fits in a limb. - void _arb_hypgeom_gamma_upper_sum_rs_1(arb_t res, unsigned long p, unsigned long q, const arb_t z, long N, long prec) + void _arb_hypgeom_gamma_upper_sum_rs_1(arb_t res, ulong p, ulong q, const arb_t z, slong N, slong prec) # Computes `\sum_{k=0}^{N-1} (a)_k / z^k` where `a = p/q` using # rectangular splitting. It is assumed that `p + qN` fits in a limb. - long _arb_hypgeom_gamma_upper_fmpq_inf_choose_N(mag_t err, const fmpq_t a, const arb_t z, const mag_t abs_tol) + slong _arb_hypgeom_gamma_upper_fmpq_inf_choose_N(mag_t err, const fmpq_t a, const arb_t z, const mag_t abs_tol) # Returns number of terms *N* and sets *err* to the truncation error for evaluating # `\Gamma(a,z)` using the asymptotic series at infinity, targeting an absolute # tolerance of *abs_tol*. The error may be set to *err* if the tolerance # cannot be achieved. Assumes that *z* is positive. - void _arb_hypgeom_gamma_upper_fmpq_inf_bsplit(arb_t res, const fmpq_t a, const arb_t z, long N, long prec) + void _arb_hypgeom_gamma_upper_fmpq_inf_bsplit(arb_t res, const fmpq_t a, const arb_t z, slong N, slong prec) # Sets *res* to the approximation of `\Gamma(a,z)` obtained by truncating # the asymptotic series at infinity before term *N*. # The truncation error bound has to be added separately. - long _arb_hypgeom_gamma_lower_fmpq_0_choose_N(mag_t err, const fmpq_t a, const arb_t z, const mag_t abs_tol) + slong _arb_hypgeom_gamma_lower_fmpq_0_choose_N(mag_t err, const fmpq_t a, const arb_t z, const mag_t abs_tol) # Returns number of terms *N* and sets *err* to the truncation error for evaluating # `\gamma(a,z)` using the Taylor series at zero, targeting an absolute # tolerance of *abs_tol*. Assumes that *z* is positive. - void _arb_hypgeom_gamma_lower_fmpq_0_bsplit(arb_t res, const fmpq_t a, const arb_t z, long N, long prec) + void _arb_hypgeom_gamma_lower_fmpq_0_bsplit(arb_t res, const fmpq_t a, const arb_t z, slong N, slong prec) # Sets *res* to the approximation of `\gamma(a,z)` obtained by truncating # the Taylor series at zero before term *N*. # The truncation error bound has to be added separately. - long _arb_hypgeom_gamma_upper_singular_si_choose_N(mag_t err, long n, const arb_t z, const mag_t abs_tol) + slong _arb_hypgeom_gamma_upper_singular_si_choose_N(mag_t err, slong n, const arb_t z, const mag_t abs_tol) # Returns number of terms *N* and sets *err* to the truncation error for evaluating # `\Gamma(-n,z)` using the Taylor series at zero, targeting an absolute # tolerance of *abs_tol*. - void _arb_hypgeom_gamma_upper_singular_si_bsplit(arb_t res, long n, const arb_t z, long N, long prec) + void _arb_hypgeom_gamma_upper_singular_si_bsplit(arb_t res, slong n, const arb_t z, slong N, slong prec) # Sets *res* to the approximation of `\Gamma(-n,z)` obtained by truncating # the Taylor series at zero before term *N*. # The truncation error bound has to be added separately. - void _arb_gamma_upper_fmpq_step_bsplit(arb_t Gz1, const fmpq_t a, const arb_t z0, const arb_t z1, const arb_t Gz0, const arb_t expmz0, const mag_t abs_tol, long prec) + void _arb_gamma_upper_fmpq_step_bsplit(arb_t Gz1, const fmpq_t a, const arb_t z0, const arb_t z1, const arb_t Gz0, const arb_t expmz0, const mag_t abs_tol, slong prec) # Given *Gz0* and *expmz0* representing the values `\Gamma(a,z_0)` and `\exp(-z_0)`, # computes `\Gamma(a,z_1)` using the Taylor series at `z_0` evaluated # using binary splitting, # targeting an absolute error of *abs_tol*. # Assumes that `z_0` and `z_1` are positive. - void arb_hypgeom_expint(arb_t res, const arb_t s, const arb_t z, long prec) + void arb_hypgeom_expint(arb_t res, const arb_t s, const arb_t z, slong prec) # Computes the generalized exponential integral `E_s(z)`. - void arb_hypgeom_ei(arb_t res, const arb_t z, long prec) + void arb_hypgeom_ei(arb_t res, const arb_t z, slong prec) # Computes the exponential integral `\operatorname{Ei}(z)`. - void _arb_hypgeom_ei_series(arb_ptr res, arb_srcptr z, long zlen, long len, long prec) - void arb_hypgeom_ei_series(arb_poly_t res, const arb_poly_t z, long len, long prec) + void _arb_hypgeom_ei_series(arb_ptr res, arb_srcptr z, slong zlen, slong len, slong prec) + void arb_hypgeom_ei_series(arb_poly_t res, const arb_poly_t z, slong len, slong prec) # Computes the exponential integral of the power series *z*, # truncated to length *len*. - void _arb_hypgeom_si_asymp(arb_t res, const arb_t z, long N, long prec) - void _arb_hypgeom_si_1f2(arb_t res, const arb_t z, long N, long wp, long prec) - void arb_hypgeom_si(arb_t res, const arb_t z, long prec) + void _arb_hypgeom_si_asymp(arb_t res, const arb_t z, slong N, slong prec) + void _arb_hypgeom_si_1f2(arb_t res, const arb_t z, slong N, slong wp, slong prec) + void arb_hypgeom_si(arb_t res, const arb_t z, slong prec) # Computes the sine integral `\operatorname{Si}(z)`. - void _arb_hypgeom_si_series(arb_ptr res, arb_srcptr z, long zlen, long len, long prec) - void arb_hypgeom_si_series(arb_poly_t res, const arb_poly_t z, long len, long prec) + void _arb_hypgeom_si_series(arb_ptr res, arb_srcptr z, slong zlen, slong len, slong prec) + void arb_hypgeom_si_series(arb_poly_t res, const arb_poly_t z, slong len, slong prec) # Computes the sine integral of the power series *z*, # truncated to length *len*. - void _arb_hypgeom_ci_asymp(arb_t res, const arb_t z, long N, long prec) - void _arb_hypgeom_ci_2f3(arb_t res, const arb_t z, long N, long wp, long prec) - void arb_hypgeom_ci(arb_t res, const arb_t z, long prec) + void _arb_hypgeom_ci_asymp(arb_t res, const arb_t z, slong N, slong prec) + void _arb_hypgeom_ci_2f3(arb_t res, const arb_t z, slong N, slong wp, slong prec) + void arb_hypgeom_ci(arb_t res, const arb_t z, slong prec) # Computes the cosine integral `\operatorname{Ci}(z)`. # The result is indeterminate if `z < 0` since the value of the function would be complex. - void _arb_hypgeom_ci_series(arb_ptr res, arb_srcptr z, long zlen, long len, long prec) - void arb_hypgeom_ci_series(arb_poly_t res, const arb_poly_t z, long len, long prec) + void _arb_hypgeom_ci_series(arb_ptr res, arb_srcptr z, slong zlen, slong len, slong prec) + void arb_hypgeom_ci_series(arb_poly_t res, const arb_poly_t z, slong len, slong prec) # Computes the cosine integral of the power series *z*, # truncated to length *len*. - void arb_hypgeom_shi(arb_t res, const arb_t z, long prec) + void arb_hypgeom_shi(arb_t res, const arb_t z, slong prec) # Computes the hyperbolic sine integral `\operatorname{Shi}(z) = -i \operatorname{Si}(iz)`. - void _arb_hypgeom_shi_series(arb_ptr res, arb_srcptr z, long zlen, long len, long prec) - void arb_hypgeom_shi_series(arb_poly_t res, const arb_poly_t z, long len, long prec) + void _arb_hypgeom_shi_series(arb_ptr res, arb_srcptr z, slong zlen, slong len, slong prec) + void arb_hypgeom_shi_series(arb_poly_t res, const arb_poly_t z, slong len, slong prec) # Computes the hyperbolic sine integral of the power series *z*, # truncated to length *len*. - void arb_hypgeom_chi(arb_t res, const arb_t z, long prec) + void arb_hypgeom_chi(arb_t res, const arb_t z, slong prec) # Computes the hyperbolic cosine integral `\operatorname{Chi}(z)`. # The result is indeterminate if `z < 0` since the value of the function would be complex. - void _arb_hypgeom_chi_series(arb_ptr res, arb_srcptr z, long zlen, long len, long prec) - void arb_hypgeom_chi_series(arb_poly_t res, const arb_poly_t z, long len, long prec) + void _arb_hypgeom_chi_series(arb_ptr res, arb_srcptr z, slong zlen, slong len, slong prec) + void arb_hypgeom_chi_series(arb_poly_t res, const arb_poly_t z, slong len, slong prec) # Computes the hyperbolic cosine integral of the power series *z*, # truncated to length *len*. - void arb_hypgeom_li(arb_t res, const arb_t z, int offset, long prec) + void arb_hypgeom_li(arb_t res, const arb_t z, int offset, slong prec) # If *offset* is zero, computes the logarithmic integral # `\operatorname{li}(z) = \operatorname{Ei}(\log(z))`. # If *offset* is nonzero, computes the offset logarithmic integral # `\operatorname{Li}(z) = \operatorname{li}(z) - \operatorname{li}(2)`. # The result is indeterminate if `z < 0` since the value of the function would be complex. - void _arb_hypgeom_li_series(arb_ptr res, arb_srcptr z, long zlen, int offset, long len, long prec) - void arb_hypgeom_li_series(arb_poly_t res, const arb_poly_t z, int offset, long len, long prec) + void _arb_hypgeom_li_series(arb_ptr res, arb_srcptr z, slong zlen, int offset, slong len, slong prec) + void arb_hypgeom_li_series(arb_poly_t res, const arb_poly_t z, int offset, slong len, slong prec) # Computes the logarithmic integral (optionally the offset version) # of the power series *z*, truncated to length *len*. - void arb_hypgeom_bessel_j(arb_t res, const arb_t nu, const arb_t z, long prec) + void arb_hypgeom_bessel_j(arb_t res, const arb_t nu, const arb_t z, slong prec) # Computes the Bessel function of the first kind `J_{\nu}(z)`. - void arb_hypgeom_bessel_y(arb_t res, const arb_t nu, const arb_t z, long prec) + void arb_hypgeom_bessel_y(arb_t res, const arb_t nu, const arb_t z, slong prec) # Computes the Bessel function of the second kind `Y_{\nu}(z)`. - void arb_hypgeom_bessel_jy(arb_t res1, arb_t res2, const arb_t nu, const arb_t z, long prec) + void arb_hypgeom_bessel_jy(arb_t res1, arb_t res2, const arb_t nu, const arb_t z, slong prec) # Sets *res1* to `J_{\nu}(z)` and *res2* to `Y_{\nu}(z)`, computed # simultaneously. - void arb_hypgeom_bessel_i(arb_t res, const arb_t nu, const arb_t z, long prec) + void arb_hypgeom_bessel_i(arb_t res, const arb_t nu, const arb_t z, slong prec) # Computes the modified Bessel function of the first kind # `I_{\nu}(z) = z^{\nu} (iz)^{-\nu} J_{\nu}(iz)`. - void arb_hypgeom_bessel_i_scaled(arb_t res, const arb_t nu, const arb_t z, long prec) + void arb_hypgeom_bessel_i_scaled(arb_t res, const arb_t nu, const arb_t z, slong prec) # Computes the function `e^{-z} I_{\nu}(z)`. - void arb_hypgeom_bessel_k(arb_t res, const arb_t nu, const arb_t z, long prec) + void arb_hypgeom_bessel_k(arb_t res, const arb_t nu, const arb_t z, slong prec) # Computes the modified Bessel function of the second kind `K_{\nu}(z)`. - void arb_hypgeom_bessel_k_scaled(arb_t res, const arb_t nu, const arb_t z, long prec) + void arb_hypgeom_bessel_k_scaled(arb_t res, const arb_t nu, const arb_t z, slong prec) # Computes the function `e^{z} K_{\nu}(z)`. - void arb_hypgeom_bessel_i_integration(arb_t res, const arb_t nu, const arb_t z, int scaled, long prec) - void arb_hypgeom_bessel_k_integration(arb_t res, const arb_t nu, const arb_t z, int scaled, long prec) + void arb_hypgeom_bessel_i_integration(arb_t res, const arb_t nu, const arb_t z, int scaled, slong prec) + void arb_hypgeom_bessel_k_integration(arb_t res, const arb_t nu, const arb_t z, int scaled, slong prec) # Computes the modified Bessel functions using numerical integration. - void arb_hypgeom_airy(arb_t ai, arb_t ai_prime, arb_t bi, arb_t bi_prime, const arb_t z, long prec) + void arb_hypgeom_airy(arb_t ai, arb_t ai_prime, arb_t bi, arb_t bi_prime, const arb_t z, slong prec) # Computes the Airy functions `(\operatorname{Ai}(z), \operatorname{Ai}'(z), \operatorname{Bi}(z), \operatorname{Bi}'(z))` # simultaneously. Any of the four function values can be omitted by passing # *NULL* for the unwanted output variables, speeding up the evaluation. - void arb_hypgeom_airy_jet(arb_ptr ai, arb_ptr bi, const arb_t z, long len, long prec) + void arb_hypgeom_airy_jet(arb_ptr ai, arb_ptr bi, const arb_t z, slong len, slong prec) # Writes to *ai* and *bi* the respective Taylor expansions of the Airy functions # at the point *z*, truncated to length *len*. # Either of the outputs can be *NULL* to avoid computing that function. @@ -401,13 +401,13 @@ cdef extern from "flint_wrap.h": # easily obtained by computing one extra coefficient and differentiating # the output with :func:`_arb_poly_derivative`. - void _arb_hypgeom_airy_series(arb_ptr ai, arb_ptr ai_prime, arb_ptr bi, arb_ptr bi_prime, arb_srcptr z, long zlen, long len, long prec) - void arb_hypgeom_airy_series(arb_poly_t ai, arb_poly_t ai_prime, arb_poly_t bi, arb_poly_t bi_prime, const arb_poly_t z, long len, long prec) + void _arb_hypgeom_airy_series(arb_ptr ai, arb_ptr ai_prime, arb_ptr bi, arb_ptr bi_prime, arb_srcptr z, slong zlen, slong len, slong prec) + void arb_hypgeom_airy_series(arb_poly_t ai, arb_poly_t ai_prime, arb_poly_t bi, arb_poly_t bi_prime, const arb_poly_t z, slong len, slong prec) # Computes the Airy functions evaluated at the power series *z*, # truncated to length *len*. As with the other Airy methods, any of the # outputs can be *NULL*. - void arb_hypgeom_airy_zero(arb_t a, arb_t a_prime, arb_t b, arb_t b_prime, const fmpz_t n, long prec) + void arb_hypgeom_airy_zero(arb_t a, arb_t a_prime, arb_t b, arb_t b_prime, const fmpz_t n, slong prec) # Computes the *n*-th real zero `a_n`, `a'_n`, `b_n`, or `b'_n` # for the respective Airy function or Airy function derivative. # Any combination of the four output variables can be *NULL*. @@ -417,48 +417,48 @@ cdef extern from "flint_wrap.h": # The implementation uses asymptotic expansions for the zeros # [PS1991]_ together with the interval Newton method for refinement. - void arb_hypgeom_coulomb(arb_t F, arb_t G, const arb_t l, const arb_t eta, const arb_t z, long prec) + void arb_hypgeom_coulomb(arb_t F, arb_t G, const arb_t l, const arb_t eta, const arb_t z, slong prec) # Writes to *F*, *G* the values of the respective # Coulomb wave functions `F_{\ell}(\eta,z)` and `G_{\ell}(\eta,z)`. # Either of the outputs can be *NULL*. - void arb_hypgeom_coulomb_jet(arb_ptr F, arb_ptr G, const arb_t l, const arb_t eta, const arb_t z, long len, long prec) + void arb_hypgeom_coulomb_jet(arb_ptr F, arb_ptr G, const arb_t l, const arb_t eta, const arb_t z, slong len, slong prec) # Writes to *F*, *G* the respective Taylor expansions of the # Coulomb wave functions at the point *z*, truncated to length *len*. # Either of the outputs can be *NULL*. - void _arb_hypgeom_coulomb_series(arb_ptr F, arb_ptr G, const arb_t l, const arb_t eta, arb_srcptr z, long zlen, long len, long prec) - void arb_hypgeom_coulomb_series(arb_poly_t F, arb_poly_t G, const arb_t l, const arb_t eta, const arb_poly_t z, long len, long prec) + void _arb_hypgeom_coulomb_series(arb_ptr F, arb_ptr G, const arb_t l, const arb_t eta, arb_srcptr z, slong zlen, slong len, slong prec) + void arb_hypgeom_coulomb_series(arb_poly_t F, arb_poly_t G, const arb_t l, const arb_t eta, const arb_poly_t z, slong len, slong prec) # Computes the Coulomb wave functions evaluated at the power series *z*, # truncated to length *len*. Either of the outputs can be *NULL*. - void arb_hypgeom_chebyshev_t(arb_t res, const arb_t nu, const arb_t z, long prec) - void arb_hypgeom_chebyshev_u(arb_t res, const arb_t nu, const arb_t z, long prec) - void arb_hypgeom_jacobi_p(arb_t res, const arb_t n, const arb_t a, const arb_t b, const arb_t z, long prec) - void arb_hypgeom_gegenbauer_c(arb_t res, const arb_t n, const arb_t m, const arb_t z, long prec) - void arb_hypgeom_laguerre_l(arb_t res, const arb_t n, const arb_t m, const arb_t z, long prec) - void arb_hypgeom_hermite_h(arb_t res, const arb_t nu, const arb_t z, long prec) + void arb_hypgeom_chebyshev_t(arb_t res, const arb_t nu, const arb_t z, slong prec) + void arb_hypgeom_chebyshev_u(arb_t res, const arb_t nu, const arb_t z, slong prec) + void arb_hypgeom_jacobi_p(arb_t res, const arb_t n, const arb_t a, const arb_t b, const arb_t z, slong prec) + void arb_hypgeom_gegenbauer_c(arb_t res, const arb_t n, const arb_t m, const arb_t z, slong prec) + void arb_hypgeom_laguerre_l(arb_t res, const arb_t n, const arb_t m, const arb_t z, slong prec) + void arb_hypgeom_hermite_h(arb_t res, const arb_t nu, const arb_t z, slong prec) # Computes Chebyshev, Jacobi, Gegenbauer, Laguerre or Hermite polynomials, # or their extensions to non-integer orders. - void arb_hypgeom_legendre_p(arb_t res, const arb_t n, const arb_t m, const arb_t z, int type, long prec) - void arb_hypgeom_legendre_q(arb_t res, const arb_t n, const arb_t m, const arb_t z, int type, long prec) + void arb_hypgeom_legendre_p(arb_t res, const arb_t n, const arb_t m, const arb_t z, int type, slong prec) + void arb_hypgeom_legendre_q(arb_t res, const arb_t n, const arb_t m, const arb_t z, int type, slong prec) # Computes Legendre functions of the first and second kind. # See :func:`acb_hypgeom_legendre_p` and :func:`acb_hypgeom_legendre_q` # for definitions. - void arb_hypgeom_legendre_p_ui_deriv_bound(mag_t dp, mag_t dp2, unsigned long n, const arb_t x, const arb_t x2sub1) + void arb_hypgeom_legendre_p_ui_deriv_bound(mag_t dp, mag_t dp2, ulong n, const arb_t x, const arb_t x2sub1) # Sets *dp* to an upper bound for `P'_n(x)` and *dp2* to an upper # bound for `P''_n(x)` given *x* assumed to represent a real # number with `|x| \le 1`. The variable *x2sub1* must contain # the precomputed value `1-x^2` (or `x^2-1`). This method is used # internally to bound the propagated error for Legendre polynomials. - void arb_hypgeom_legendre_p_ui_zero(arb_t res, arb_t res_prime, unsigned long n, const arb_t x, long K, long prec) - void arb_hypgeom_legendre_p_ui_one(arb_t res, arb_t res_prime, unsigned long n, const arb_t x, long K, long prec) - void arb_hypgeom_legendre_p_ui_asymp(arb_t res, arb_t res_prime, unsigned long n, const arb_t x, long K, long prec) - void arb_hypgeom_legendre_p_ui_rec(arb_t res, arb_t res_prime, unsigned long n, const arb_t x, long prec) - void arb_hypgeom_legendre_p_ui(arb_t res, arb_t res_prime, unsigned long n, const arb_t x, long prec) + void arb_hypgeom_legendre_p_ui_zero(arb_t res, arb_t res_prime, ulong n, const arb_t x, slong K, slong prec) + void arb_hypgeom_legendre_p_ui_one(arb_t res, arb_t res_prime, ulong n, const arb_t x, slong K, slong prec) + void arb_hypgeom_legendre_p_ui_asymp(arb_t res, arb_t res_prime, ulong n, const arb_t x, slong K, slong prec) + void arb_hypgeom_legendre_p_ui_rec(arb_t res, arb_t res_prime, ulong n, const arb_t x, slong prec) + void arb_hypgeom_legendre_p_ui(arb_t res, arb_t res_prime, ulong n, const arb_t x, slong prec) # Evaluates the ordinary Legendre polynomial `P_n(x)`. If *res_prime* is # non-NULL, simultaneously evaluates the derivative `P'_n(x)`. # The overall algorithm is described in [JM2018]_. @@ -477,7 +477,7 @@ cdef extern from "flint_wrap.h": # and increases the working precision to compensate, bounding the # propagated error using derivative bounds. - void arb_hypgeom_legendre_p_ui_root(arb_t res, arb_t weight, unsigned long n, unsigned long k, long prec) + void arb_hypgeom_legendre_p_ui_root(arb_t res, arb_t weight, ulong n, ulong k, slong prec) # Sets *res* to the *k*-th root of the Legendre polynomial `P_n(x)`. # We index the roots in decreasing order # .. math :: @@ -494,12 +494,12 @@ cdef extern from "flint_wrap.h": # subsequently refined using interval Newton steps with doubling working # precision. - void arb_hypgeom_dilog(arb_t res, const arb_t z, long prec) + void arb_hypgeom_dilog(arb_t res, const arb_t z, slong prec) # Computes the dilogarithm `\operatorname{Li}_2(z)`. - void arb_hypgeom_sum_fmpq_arb_forward(arb_t res, const fmpq * a, long alen, const fmpq * b, long blen, const arb_t z, int reciprocal, long N, long prec) - void arb_hypgeom_sum_fmpq_arb_rs(arb_t res, const fmpq * a, long alen, const fmpq * b, long blen, const arb_t z, int reciprocal, long N, long prec) - void arb_hypgeom_sum_fmpq_arb(arb_t res, const fmpq * a, long alen, const fmpq * b, long blen, const arb_t z, int reciprocal, long N, long prec) + void arb_hypgeom_sum_fmpq_arb_forward(arb_t res, const fmpq * a, slong alen, const fmpq * b, slong blen, const arb_t z, int reciprocal, slong N, slong prec) + void arb_hypgeom_sum_fmpq_arb_rs(arb_t res, const fmpq * a, slong alen, const fmpq * b, slong blen, const arb_t z, int reciprocal, slong N, slong prec) + void arb_hypgeom_sum_fmpq_arb(arb_t res, const fmpq * a, slong alen, const fmpq * b, slong blen, const arb_t z, int reciprocal, slong N, slong prec) # Sets *res* to the finite hypergeometric sum # `\sum_{n=0}^{N-1} (\textbf{a})_n z^n / (\textbf{b})_n` # where `\textbf{x}_n = (x_1)_n (x_2)_n \cdots`, @@ -511,10 +511,10 @@ cdef extern from "flint_wrap.h": # uses rectangular splitting, and the default version uses # an automatic algorithm choice. - void arb_hypgeom_sum_fmpq_imag_arb_forward(arb_t res1, arb_t res2, const fmpq * a, long alen, const fmpq * b, long blen, const arb_t z, int reciprocal, long N, long prec) - void arb_hypgeom_sum_fmpq_imag_arb_rs(arb_t res1, arb_t res2, const fmpq * a, long alen, const fmpq * b, long blen, const arb_t z, int reciprocal, long N, long prec) - void arb_hypgeom_sum_fmpq_imag_arb_bs(arb_t res1, arb_t res2, const fmpq * a, long alen, const fmpq * b, long blen, const arb_t z, int reciprocal, long N, long prec) - void arb_hypgeom_sum_fmpq_imag_arb(arb_t res1, arb_t res2, const fmpq * a, long alen, const fmpq * b, long blen, const arb_t z, int reciprocal, long N, long prec) + void arb_hypgeom_sum_fmpq_imag_arb_forward(arb_t res1, arb_t res2, const fmpq * a, slong alen, const fmpq * b, slong blen, const arb_t z, int reciprocal, slong N, slong prec) + void arb_hypgeom_sum_fmpq_imag_arb_rs(arb_t res1, arb_t res2, const fmpq * a, slong alen, const fmpq * b, slong blen, const arb_t z, int reciprocal, slong N, slong prec) + void arb_hypgeom_sum_fmpq_imag_arb_bs(arb_t res1, arb_t res2, const fmpq * a, slong alen, const fmpq * b, slong blen, const arb_t z, int reciprocal, slong N, slong prec) + void arb_hypgeom_sum_fmpq_imag_arb(arb_t res1, arb_t res2, const fmpq * a, slong alen, const fmpq * b, slong blen, const arb_t z, int reciprocal, slong N, slong prec) # Sets *res1* and *res2* to the real and imaginary part of the # finite hypergeometric sum # `\sum_{n=0}^{N-1} (\textbf{a})_n (i z)^n / (\textbf{b})_n`. diff --git a/src/sage/libs/flint/arb_mat.pxd b/src/sage/libs/flint/arb_mat.pxd index 1394a44ab39..9d97362250a 100644 --- a/src/sage/libs/flint/arb_mat.pxd +++ b/src/sage/libs/flint/arb_mat.pxd @@ -12,19 +12,19 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void arb_mat_init(arb_mat_t mat, long r, long c) + void arb_mat_init(arb_mat_t mat, slong r, slong c) # Initializes the matrix, setting it to the zero matrix with *r* rows # and *c* columns. void arb_mat_clear(arb_mat_t mat) # Clears the matrix, deallocating all entries. - long arb_mat_allocated_bytes(const arb_mat_t x) + slong arb_mat_allocated_bytes(const arb_mat_t x) # Returns the total number of bytes heap-allocated internally by this object. # The count excludes the size of the structure itself. Add # ``sizeof(arb_mat_struct)`` to get the size of the object as a whole. - void arb_mat_window_init(arb_mat_t window, const arb_mat_t mat, long r1, long c1, long r2, long c2) + void arb_mat_window_init(arb_mat_t window, const arb_mat_t mat, slong r1, slong c1, slong r2, slong c2) # Initializes *window* to a window matrix into the submatrix of *mat* # starting at the corner at row *r1* and column *c1* (inclusive) and ending # at row *r2* and column *c2* (exclusive). @@ -36,19 +36,19 @@ cdef extern from "flint_wrap.h": void arb_mat_set_fmpz_mat(arb_mat_t dest, const fmpz_mat_t src) - void arb_mat_set_round_fmpz_mat(arb_mat_t dest, const fmpz_mat_t src, long prec) + void arb_mat_set_round_fmpz_mat(arb_mat_t dest, const fmpz_mat_t src, slong prec) - void arb_mat_set_fmpq_mat(arb_mat_t dest, const fmpq_mat_t src, long prec) + void arb_mat_set_fmpq_mat(arb_mat_t dest, const fmpq_mat_t src, slong prec) # Sets *dest* to *src*. The operands must have identical dimensions. - void arb_mat_randtest(arb_mat_t mat, flint_rand_t state, long prec, long mag_bits) + void arb_mat_randtest(arb_mat_t mat, flint_rand_t state, slong prec, slong mag_bits) # Sets *mat* to a random matrix with up to *prec* bits of precision # and with exponents of width up to *mag_bits*. - void arb_mat_printd(const arb_mat_t mat, long digits) + void arb_mat_printd(const arb_mat_t mat, slong digits) # Prints each entry in the matrix with the specified number of decimal digits. - void arb_mat_fprintd(FILE * file, const arb_mat_t mat, long digits) + void arb_mat_fprintd(FILE * file, const arb_mat_t mat, slong digits) # Prints each entry in the matrix with the specified number of decimal # digits to the stream *file*. @@ -114,10 +114,10 @@ cdef extern from "flint_wrap.h": void arb_mat_indeterminate(arb_mat_t mat) # Sets all entries in the matrix to indeterminate (NaN). - void arb_mat_hilbert(arb_mat_t mat, long prec) + void arb_mat_hilbert(arb_mat_t mat, slong prec) # Sets *mat* to the Hilbert matrix, which has entries `A_{j,k} = 1/(j+k+1)`. - void arb_mat_pascal(arb_mat_t mat, int triangular, long prec) + void arb_mat_pascal(arb_mat_t mat, int triangular, slong prec) # Sets *mat* to a Pascal matrix, whose entries are binomial coefficients. # If *triangular* is 0, constructs a full symmetric matrix # with the rows of Pascal's triangle as successive antidiagonals. @@ -130,7 +130,7 @@ cdef extern from "flint_wrap.h": # case, the user may wish to create the matrix at slightly higher precision # and then round it to the final precision. - void arb_mat_stirling(arb_mat_t mat, int kind, long prec) + void arb_mat_stirling(arb_mat_t mat, int kind, slong prec) # Sets *mat* to a Stirling matrix, whose entries are Stirling numbers. # If *kind* is 0, the entries are set to the unsigned Stirling numbers # of the first kind. If *kind* is 1, the entries are set to the signed @@ -141,7 +141,7 @@ cdef extern from "flint_wrap.h": # case, the user may wish to create the matrix at slightly higher precision # and then round it to the final precision. - void arb_mat_dct(arb_mat_t mat, int type, long prec) + void arb_mat_dct(arb_mat_t mat, int type, slong prec) # Sets *mat* to the DCT (discrete cosine transform) matrix of order *n* # where *n* is the smallest dimension of *mat* (if *mat* is not square, # the matrix is extended periodically along the larger dimension). @@ -161,7 +161,7 @@ cdef extern from "flint_wrap.h": # Sets *b* to an upper bound for the infinity norm (i.e. the largest # absolute value row sum) of *A*. - void arb_mat_frobenius_norm(arb_t res, const arb_mat_t A, long prec) + void arb_mat_frobenius_norm(arb_t res, const arb_mat_t A, slong prec) # Sets *res* to the Frobenius norm (i.e. the square root of the sum # of squares of entries) of *A*. @@ -172,20 +172,20 @@ cdef extern from "flint_wrap.h": # Sets *dest* to the exact negation of *src*. The operands must have # the same dimensions. - void arb_mat_add(arb_mat_t res, const arb_mat_t mat1, const arb_mat_t mat2, long prec) + void arb_mat_add(arb_mat_t res, const arb_mat_t mat1, const arb_mat_t mat2, slong prec) # Sets res to the sum of *mat1* and *mat2*. The operands must have the same dimensions. - void arb_mat_sub(arb_mat_t res, const arb_mat_t mat1, const arb_mat_t mat2, long prec) + void arb_mat_sub(arb_mat_t res, const arb_mat_t mat1, const arb_mat_t mat2, slong prec) # Sets *res* to the difference of *mat1* and *mat2*. The operands must have # the same dimensions. - void arb_mat_mul_classical(arb_mat_t C, const arb_mat_t A, const arb_mat_t B, long prec) + void arb_mat_mul_classical(arb_mat_t C, const arb_mat_t A, const arb_mat_t B, slong prec) - void arb_mat_mul_threaded(arb_mat_t C, const arb_mat_t A, const arb_mat_t B, long prec) + void arb_mat_mul_threaded(arb_mat_t C, const arb_mat_t A, const arb_mat_t B, slong prec) - void arb_mat_mul_block(arb_mat_t C, const arb_mat_t A, const arb_mat_t B, long prec) + void arb_mat_mul_block(arb_mat_t C, const arb_mat_t A, const arb_mat_t B, slong prec) - void arb_mat_mul(arb_mat_t res, const arb_mat_t mat1, const arb_mat_t mat2, long prec) + void arb_mat_mul(arb_mat_t res, const arb_mat_t mat1, const arb_mat_t mat2, slong prec) # Sets *res* to the matrix product of *mat1* and *mat2*. The operands must have # compatible dimensions for matrix multiplication. # The *classical* version performs matrix multiplication in the trivial way. @@ -197,19 +197,19 @@ cdef extern from "flint_wrap.h": # computation over the number of threads returned by *flint_get_num_threads()*. # The default version chooses an algorithm automatically. - void arb_mat_mul_entrywise(arb_mat_t C, const arb_mat_t A, const arb_mat_t B, long prec) + void arb_mat_mul_entrywise(arb_mat_t C, const arb_mat_t A, const arb_mat_t B, slong prec) # Sets *C* to the entrywise product of *A* and *B*. # The operands must have the same dimensions. - void arb_mat_sqr_classical(arb_mat_t B, const arb_mat_t A, long prec) + void arb_mat_sqr_classical(arb_mat_t B, const arb_mat_t A, slong prec) - void arb_mat_sqr(arb_mat_t res, const arb_mat_t mat, long prec) + void arb_mat_sqr(arb_mat_t res, const arb_mat_t mat, slong prec) - void arb_mat_pow_ui(arb_mat_t res, const arb_mat_t mat, unsigned long exp, long prec) + void arb_mat_pow_ui(arb_mat_t res, const arb_mat_t mat, ulong exp, slong prec) # Sets *res* to *mat* raised to the power *exp*. Requires that *mat* # is a square matrix. - void _arb_mat_addmul_rad_mag_fast(arb_mat_t C, mag_srcptr A, mag_srcptr B, long ar, long ac, long bc) + void _arb_mat_addmul_rad_mag_fast(arb_mat_t C, mag_srcptr A, mag_srcptr B, slong ar, slong ac, slong bc) # Helper function for matrix multiplication. # Adds to the radii of *C* the matrix product of the matrices represented # by *A* and *B*, where *A* is a linear array of coefficients in row-major @@ -217,40 +217,40 @@ cdef extern from "flint_wrap.h": # This function assumes that all exponents are small and is unsafe # for general use. - void arb_mat_approx_mul(arb_mat_t res, const arb_mat_t mat1, const arb_mat_t mat2, long prec) + void arb_mat_approx_mul(arb_mat_t res, const arb_mat_t mat1, const arb_mat_t mat2, slong prec) # Approximate matrix multiplication. The input radii are ignored and # the output matrix is set to an approximate floating-point result. # The radii in the output matrix will *not* necessarily be zeroed. - void arb_mat_scalar_mul_2exp_si(arb_mat_t B, const arb_mat_t A, long c) + void arb_mat_scalar_mul_2exp_si(arb_mat_t B, const arb_mat_t A, slong c) # Sets *B* to *A* multiplied by `2^c`. - void arb_mat_scalar_addmul_si(arb_mat_t B, const arb_mat_t A, long c, long prec) + void arb_mat_scalar_addmul_si(arb_mat_t B, const arb_mat_t A, slong c, slong prec) - void arb_mat_scalar_addmul_fmpz(arb_mat_t B, const arb_mat_t A, const fmpz_t c, long prec) + void arb_mat_scalar_addmul_fmpz(arb_mat_t B, const arb_mat_t A, const fmpz_t c, slong prec) - void arb_mat_scalar_addmul_arb(arb_mat_t B, const arb_mat_t A, const arb_t c, long prec) + void arb_mat_scalar_addmul_arb(arb_mat_t B, const arb_mat_t A, const arb_t c, slong prec) # Sets *B* to `B + A \times c`. - void arb_mat_scalar_mul_si(arb_mat_t B, const arb_mat_t A, long c, long prec) + void arb_mat_scalar_mul_si(arb_mat_t B, const arb_mat_t A, slong c, slong prec) - void arb_mat_scalar_mul_fmpz(arb_mat_t B, const arb_mat_t A, const fmpz_t c, long prec) + void arb_mat_scalar_mul_fmpz(arb_mat_t B, const arb_mat_t A, const fmpz_t c, slong prec) - void arb_mat_scalar_mul_arb(arb_mat_t B, const arb_mat_t A, const arb_t c, long prec) + void arb_mat_scalar_mul_arb(arb_mat_t B, const arb_mat_t A, const arb_t c, slong prec) # Sets *B* to `A \times c`. - void arb_mat_scalar_div_si(arb_mat_t B, const arb_mat_t A, long c, long prec) + void arb_mat_scalar_div_si(arb_mat_t B, const arb_mat_t A, slong c, slong prec) - void arb_mat_scalar_div_fmpz(arb_mat_t B, const arb_mat_t A, const fmpz_t c, long prec) + void arb_mat_scalar_div_fmpz(arb_mat_t B, const arb_mat_t A, const fmpz_t c, slong prec) - void arb_mat_scalar_div_arb(arb_mat_t B, const arb_mat_t A, const arb_t c, long prec) + void arb_mat_scalar_div_arb(arb_mat_t B, const arb_mat_t A, const arb_t c, slong prec) # Sets *B* to `A / c`. - int arb_mat_lu_classical(long * perm, arb_mat_t LU, const arb_mat_t A, long prec) + int arb_mat_lu_classical(slong * perm, arb_mat_t LU, const arb_mat_t A, slong prec) - int arb_mat_lu_recursive(long * perm, arb_mat_t LU, const arb_mat_t A, long prec) + int arb_mat_lu_recursive(slong * perm, arb_mat_t LU, const arb_mat_t A, slong prec) - int arb_mat_lu(long * perm, arb_mat_t LU, const arb_mat_t A, long prec) + int arb_mat_lu(slong * perm, arb_mat_t LU, const arb_mat_t A, slong prec) # Given an `n \times n` matrix `A`, computes an LU decomposition `PLU = A` # using Gaussian elimination with partial pivoting. # The input and output matrices can be the same, performing the @@ -270,17 +270,17 @@ cdef extern from "flint_wrap.h": # way to benefit from fast matrix multiplication. The default version # chooses an algorithm automatically. - void arb_mat_solve_tril_classical(arb_mat_t X, const arb_mat_t L, const arb_mat_t B, int unit, long prec) + void arb_mat_solve_tril_classical(arb_mat_t X, const arb_mat_t L, const arb_mat_t B, int unit, slong prec) - void arb_mat_solve_tril_recursive(arb_mat_t X, const arb_mat_t L, const arb_mat_t B, int unit, long prec) + void arb_mat_solve_tril_recursive(arb_mat_t X, const arb_mat_t L, const arb_mat_t B, int unit, slong prec) - void arb_mat_solve_tril(arb_mat_t X, const arb_mat_t L, const arb_mat_t B, int unit, long prec) + void arb_mat_solve_tril(arb_mat_t X, const arb_mat_t L, const arb_mat_t B, int unit, slong prec) - void arb_mat_solve_triu_classical(arb_mat_t X, const arb_mat_t U, const arb_mat_t B, int unit, long prec) + void arb_mat_solve_triu_classical(arb_mat_t X, const arb_mat_t U, const arb_mat_t B, int unit, slong prec) - void arb_mat_solve_triu_recursive(arb_mat_t X, const arb_mat_t U, const arb_mat_t B, int unit, long prec) + void arb_mat_solve_triu_recursive(arb_mat_t X, const arb_mat_t U, const arb_mat_t B, int unit, slong prec) - void arb_mat_solve_triu(arb_mat_t X, const arb_mat_t U, const arb_mat_t B, int unit, long prec) + void arb_mat_solve_triu(arb_mat_t X, const arb_mat_t U, const arb_mat_t B, int unit, slong prec) # Solves the lower triangular system `LX = B` or the upper triangular system # `UX = B`, respectively. If *unit* is set, the main diagonal of *L* or *U* # is taken to consist of all ones, and in that case the actual entries on @@ -290,16 +290,16 @@ cdef extern from "flint_wrap.h": # way to benefit from fast matrix multiplication. The default versions # choose an algorithm automatically. - void arb_mat_solve_lu_precomp(arb_mat_t X, const long * perm, const arb_mat_t LU, const arb_mat_t B, long prec) + void arb_mat_solve_lu_precomp(arb_mat_t X, const slong * perm, const arb_mat_t LU, const arb_mat_t B, slong prec) # Solves `AX = B` given the precomputed nonsingular LU decomposition `A = PLU`. # The matrices `X` and `B` are allowed to be aliased with each other, # but `X` is not allowed to be aliased with `LU`. - int arb_mat_solve(arb_mat_t X, const arb_mat_t A, const arb_mat_t B, long prec) + int arb_mat_solve(arb_mat_t X, const arb_mat_t A, const arb_mat_t B, slong prec) - int arb_mat_solve_lu(arb_mat_t X, const arb_mat_t A, const arb_mat_t B, long prec) + int arb_mat_solve_lu(arb_mat_t X, const arb_mat_t A, const arb_mat_t B, slong prec) - int arb_mat_solve_precond(arb_mat_t X, const arb_mat_t A, const arb_mat_t B, long prec) + int arb_mat_solve_precond(arb_mat_t X, const arb_mat_t A, const arb_mat_t B, slong prec) # Solves `AX = B` where `A` is a nonsingular `n \times n` matrix # and `X` and `B` are `n \times m` matrices. # If `m > 0` and `A` cannot be inverted numerically (indicating either that @@ -323,7 +323,7 @@ cdef extern from "flint_wrap.h": # For example, the *lu* solver often performs better for ill-conditioned # systems where use of very high precision is unavoidable. - int arb_mat_solve_preapprox(arb_mat_t X, const arb_mat_t A, const arb_mat_t B, const arb_mat_t R, const arb_mat_t T, long prec) + int arb_mat_solve_preapprox(arb_mat_t X, const arb_mat_t A, const arb_mat_t B, const arb_mat_t R, const arb_mat_t T, slong prec) # Solves `AX = B` where `A` is a nonsingular `n \times n` matrix # and `X` and `B` are `n \times m` matrices, given an approximation # `R` of the matrix inverse of `A`, and given the approximation `T` @@ -335,7 +335,7 @@ cdef extern from "flint_wrap.h": # value guarantees that `A` is invertible and that the exact solution # matrix is contained in the output. - int arb_mat_inv(arb_mat_t X, const arb_mat_t A, long prec) + int arb_mat_inv(arb_mat_t X, const arb_mat_t A, slong prec) # Sets `X = A^{-1}` where `A` is a square matrix, computed by solving # the system `AX = I`. # If `A` cannot be inverted numerically (indicating either that @@ -344,11 +344,11 @@ cdef extern from "flint_wrap.h": # A nonzero return value guarantees that the matrix is invertible # and that the exact inverse is contained in the output. - void arb_mat_det_lu(arb_t det, const arb_mat_t A, long prec) + void arb_mat_det_lu(arb_t det, const arb_mat_t A, slong prec) - void arb_mat_det_precond(arb_t det, const arb_mat_t A, long prec) + void arb_mat_det_precond(arb_t det, const arb_mat_t A, slong prec) - void arb_mat_det(arb_t det, const arb_mat_t A, long prec) + void arb_mat_det(arb_t det, const arb_mat_t A, slong prec) # Sets *det* to the determinant of the matrix *A*. # The *lu* version uses Gaussian elimination with partial pivoting. If at # some point an invertible pivot element cannot be found, the elimination is @@ -364,17 +364,17 @@ cdef extern from "flint_wrap.h": # versions and additionally handles small or triangular matrices # by direct formulas. - void arb_mat_approx_solve_triu(arb_mat_t X, const arb_mat_t U, const arb_mat_t B, int unit, long prec) + void arb_mat_approx_solve_triu(arb_mat_t X, const arb_mat_t U, const arb_mat_t B, int unit, slong prec) - void arb_mat_approx_solve_tril(arb_mat_t X, const arb_mat_t L, const arb_mat_t B, int unit, long prec) + void arb_mat_approx_solve_tril(arb_mat_t X, const arb_mat_t L, const arb_mat_t B, int unit, slong prec) - int arb_mat_approx_lu(long * P, arb_mat_t LU, const arb_mat_t A, long prec) + int arb_mat_approx_lu(slong * P, arb_mat_t LU, const arb_mat_t A, slong prec) - void arb_mat_approx_solve_lu_precomp(arb_mat_t X, const long * perm, const arb_mat_t A, const arb_mat_t B, long prec) + void arb_mat_approx_solve_lu_precomp(arb_mat_t X, const slong * perm, const arb_mat_t A, const arb_mat_t B, slong prec) - int arb_mat_approx_solve(arb_mat_t X, const arb_mat_t A, const arb_mat_t B, long prec) + int arb_mat_approx_solve(arb_mat_t X, const arb_mat_t A, const arb_mat_t B, slong prec) - int arb_mat_approx_inv(arb_mat_t X, const arb_mat_t A, long prec) + int arb_mat_approx_inv(arb_mat_t X, const arb_mat_t A, slong prec) # These methods perform approximate solving *without any error control*. # The radii in the input matrices are ignored, the computations are done # numerically with floating-point arithmetic (using ordinary @@ -387,9 +387,9 @@ cdef extern from "flint_wrap.h": # for doing ordinary numerical linear algebra in applications where # error bounds are not needed. - int _arb_mat_cholesky_banachiewicz(arb_mat_t A, long prec) + int _arb_mat_cholesky_banachiewicz(arb_mat_t A, slong prec) - int arb_mat_cho(arb_mat_t L, const arb_mat_t A, long prec) + int arb_mat_cho(arb_mat_t L, const arb_mat_t A, slong prec) # Computes the Cholesky decomposition of *A*, returning nonzero iff # the symmetric matrix defined by the lower triangular part of *A* # is certainly positive definite. @@ -401,12 +401,12 @@ cdef extern from "flint_wrap.h": # The underscore method computes *L* from *A* in-place, leaving the # strict upper triangular region undefined. - void arb_mat_solve_cho_precomp(arb_mat_t X, const arb_mat_t L, const arb_mat_t B, long prec) + void arb_mat_solve_cho_precomp(arb_mat_t X, const arb_mat_t L, const arb_mat_t B, slong prec) # Solves `AX = B` given the precomputed Cholesky decomposition `A = L L^T`. # The matrices *X* and *B* are allowed to be aliased with each other, # but *X* is not allowed to be aliased with *L*. - int arb_mat_spd_solve(arb_mat_t X, const arb_mat_t A, const arb_mat_t B, long prec) + int arb_mat_spd_solve(arb_mat_t X, const arb_mat_t A, const arb_mat_t B, slong prec) # Solves `AX = B` where *A* is a symmetric positive definite matrix # and *X* and *B* are `n \times m` matrices, using Cholesky decomposition. # If `m > 0` and *A* cannot be factored using Cholesky decomposition @@ -417,14 +417,14 @@ cdef extern from "flint_wrap.h": # triangular part of *A* is invertible and that the exact solution matrix # is contained in the output. - void arb_mat_inv_cho_precomp(arb_mat_t X, const arb_mat_t L, long prec) + void arb_mat_inv_cho_precomp(arb_mat_t X, const arb_mat_t L, slong prec) # Sets `X = A^{-1}` where `A` is a symmetric positive definite matrix # whose Cholesky decomposition *L* has been computed with # :func:`arb_mat_cho`. # The inverse is calculated using the method of [Kri2013]_ which is more # efficient than solving `AX = I` with :func:`arb_mat_solve_cho_precomp`. - int arb_mat_spd_inv(arb_mat_t X, const arb_mat_t A, long prec) + int arb_mat_spd_inv(arb_mat_t X, const arb_mat_t A, slong prec) # Sets `X = A^{-1}` where *A* is a symmetric positive definite matrix. # It is calculated using the method of [Kri2013]_ which computes fewer # intermediate results than solving `AX = I` with :func:`arb_mat_spd_solve`. @@ -436,11 +436,11 @@ cdef extern from "flint_wrap.h": # triangular part of *A* is invertible and that the exact inverse # is contained in the output. - int _arb_mat_ldl_inplace(arb_mat_t A, long prec) + int _arb_mat_ldl_inplace(arb_mat_t A, slong prec) - int _arb_mat_ldl_golub_and_van_loan(arb_mat_t A, long prec) + int _arb_mat_ldl_golub_and_van_loan(arb_mat_t A, slong prec) - int arb_mat_ldl(arb_mat_t res, const arb_mat_t A, long prec) + int arb_mat_ldl(arb_mat_t res, const arb_mat_t A, slong prec) # Computes the `LDL^T` decomposition of *A*, returning nonzero iff # the symmetric matrix defined by the lower triangular part of *A* # is certainly positive definite. @@ -456,34 +456,34 @@ cdef extern from "flint_wrap.h": # strict upper triangular region undefined. # The default method uses algorithm 4.1.2 from [GVL1996]_. - void arb_mat_solve_ldl_precomp(arb_mat_t X, const arb_mat_t L, const arb_mat_t B, long prec) + void arb_mat_solve_ldl_precomp(arb_mat_t X, const arb_mat_t L, const arb_mat_t B, slong prec) # Solves `AX = B` given the precomputed `A = LDL^T` decomposition # encoded by *L*. The matrices *X* and *B* are allowed to be aliased # with each other, but *X* is not allowed to be aliased with *L*. - void arb_mat_inv_ldl_precomp(arb_mat_t X, const arb_mat_t L, long prec) + void arb_mat_inv_ldl_precomp(arb_mat_t X, const arb_mat_t L, slong prec) # Sets `X = A^{-1}` where `A` is a symmetric positive definite matrix # whose `LDL^T` decomposition encoded by *L* has been computed with # :func:`arb_mat_ldl`. # The inverse is calculated using the method of [Kri2013]_ which is more # efficient than solving `AX = I` with :func:`arb_mat_solve_ldl_precomp`. - void _arb_mat_charpoly(arb_ptr poly, const arb_mat_t mat, long prec) + void _arb_mat_charpoly(arb_ptr poly, const arb_mat_t mat, slong prec) - void arb_mat_charpoly(arb_poly_t poly, const arb_mat_t mat, long prec) + void arb_mat_charpoly(arb_poly_t poly, const arb_mat_t mat, slong prec) # Sets *poly* to the characteristic polynomial of *mat* which must be # a square matrix. If the matrix has *n* rows, the underscore method # requires space for `n + 1` output coefficients. # Employs a division-free algorithm using `O(n^4)` operations. - void _arb_mat_companion(arb_mat_t mat, arb_srcptr poly, long prec) + void _arb_mat_companion(arb_mat_t mat, arb_srcptr poly, slong prec) - void arb_mat_companion(arb_mat_t mat, const arb_poly_t poly, long prec) + void arb_mat_companion(arb_mat_t mat, const arb_poly_t poly, slong prec) # Sets the *n* by *n* matrix *mat* to the companion matrix of the polynomial # *poly* which must have degree *n*. # The underscore method reads `n + 1` input coefficients. - void arb_mat_exp_taylor_sum(arb_mat_t S, const arb_mat_t A, long N, long prec) + void arb_mat_exp_taylor_sum(arb_mat_t S, const arb_mat_t A, slong N, slong prec) # Sets *S* to the truncated exponential Taylor series `S = \sum_{k=0}^{N-1} A^k / k!`. # Uses rectangular splitting to compute the sum using `O(\sqrt{N})` # matrix multiplications. The recurrence relation for factorials @@ -493,7 +493,7 @@ cdef extern from "flint_wrap.h": # The scalars could be reduced by doing more divisions, but this # appears to be slower in most cases. - void arb_mat_exp(arb_mat_t B, const arb_mat_t A, long prec) + void arb_mat_exp(arb_mat_t B, const arb_mat_t A, slong prec) # Sets *B* to the exponential of the matrix *A*, defined by the Taylor series # .. math :: # \exp(A) = \sum_{k=0}^{\infty} \frac{A^k}{k!}. @@ -510,13 +510,13 @@ cdef extern from "flint_wrap.h": # Truncation error is not added to entries whose values are determined # by the sparsity structure of `A`. - void arb_mat_trace(arb_t trace, const arb_mat_t mat, long prec) + void arb_mat_trace(arb_t trace, const arb_mat_t mat, slong prec) # Sets *trace* to the trace of the matrix, i.e. the sum of entries on the # main diagonal of *mat*. The matrix is required to be square. - void _arb_mat_diag_prod(arb_t res, const arb_mat_t mat, long a, long b, long prec) + void _arb_mat_diag_prod(arb_t res, const arb_mat_t mat, slong a, slong b, slong prec) - void arb_mat_diag_prod(arb_t res, const arb_mat_t mat, long prec) + void arb_mat_diag_prod(arb_t res, const arb_mat_t mat, slong prec) # Sets *res* to the product of the entries on the main diagonal of *mat*. # The underscore method computes the product of the entries between # index *a* inclusive and *b* exclusive (the indices must be in range). @@ -533,11 +533,11 @@ cdef extern from "flint_wrap.h": # entry of *src* is not certainly zero. # This the complement of :func:`arb_mat_entrywise_is_zero`. - long arb_mat_count_is_zero(const arb_mat_t mat) + slong arb_mat_count_is_zero(const arb_mat_t mat) # Returns the number of entries of *mat* that are certainly zero # according to :func:`arb_is_zero`. - long arb_mat_count_not_is_zero(const arb_mat_t mat) + slong arb_mat_count_not_is_zero(const arb_mat_t mat) # Returns the number of entries of *mat* that are not certainly zero. void arb_mat_get_mid(arb_mat_t B, const arb_mat_t A) diff --git a/src/sage/libs/flint/arb_poly.pxd b/src/sage/libs/flint/arb_poly.pxd index cefd8845a26..7ae13775803 100644 --- a/src/sage/libs/flint/arb_poly.pxd +++ b/src/sage/libs/flint/arb_poly.pxd @@ -19,28 +19,28 @@ cdef extern from "flint_wrap.h": # Clears the polynomial, deallocating all coefficients and the # coefficient array. - void arb_poly_fit_length(arb_poly_t poly, long len) + void arb_poly_fit_length(arb_poly_t poly, slong len) # Makes sure that the coefficient array of the polynomial contains at # least *len* initialized coefficients. - void _arb_poly_set_length(arb_poly_t poly, long len) + void _arb_poly_set_length(arb_poly_t poly, slong len) # Directly changes the length of the polynomial, without allocating or # deallocating coefficients. The value should not exceed the allocation length. void _arb_poly_normalise(arb_poly_t poly) # Strips any trailing coefficients which are identical to zero. - long arb_poly_allocated_bytes(const arb_poly_t x) + slong arb_poly_allocated_bytes(const arb_poly_t x) # Returns the total number of bytes heap-allocated internally by this object. # The count excludes the size of the structure itself. Add # ``sizeof(arb_poly_struct)`` to get the size of the object as a whole. - long arb_poly_length(const arb_poly_t poly) + slong arb_poly_length(const arb_poly_t poly) # Returns the length of *poly*, i.e. zero if *poly* is # identically zero, and otherwise one more than the index # of the highest term that is not identically zero. - long arb_poly_degree(const arb_poly_t poly) + slong arb_poly_degree(const arb_poly_t poly) # Returns the degree of *poly*, defined as one less than its length. # Note that if one or several leading coefficients are balls # containing zero, this value can be larger than the true @@ -64,60 +64,60 @@ cdef extern from "flint_wrap.h": void arb_poly_set(arb_poly_t dest, const arb_poly_t src) # Sets *dest* to a copy of *src*. - void arb_poly_set_round(arb_poly_t dest, const arb_poly_t src, long prec) + void arb_poly_set_round(arb_poly_t dest, const arb_poly_t src, slong prec) # Sets *dest* to a copy of *src*, rounded to *prec* bits. - void arb_poly_set_trunc(arb_poly_t dest, const arb_poly_t src, long n) + void arb_poly_set_trunc(arb_poly_t dest, const arb_poly_t src, slong n) - void arb_poly_set_trunc_round(arb_poly_t dest, const arb_poly_t src, long n, long prec) + void arb_poly_set_trunc_round(arb_poly_t dest, const arb_poly_t src, slong n, slong prec) # Sets *dest* to a copy of *src*, truncated to length *n* and rounded to *prec* bits. - void arb_poly_set_coeff_si(arb_poly_t poly, long n, long c) + void arb_poly_set_coeff_si(arb_poly_t poly, slong n, slong c) - void arb_poly_set_coeff_arb(arb_poly_t poly, long n, const arb_t c) + void arb_poly_set_coeff_arb(arb_poly_t poly, slong n, const arb_t c) # Sets the coefficient with index *n* in *poly* to the value *c*. # We require that *n* is nonnegative. - void arb_poly_get_coeff_arb(arb_t v, const arb_poly_t poly, long n) + void arb_poly_get_coeff_arb(arb_t v, const arb_poly_t poly, slong n) # Sets *v* to the value of the coefficient with index *n* in *poly*. # We require that *n* is nonnegative. - void _arb_poly_shift_right(arb_ptr res, arb_srcptr poly, long len, long n) + void _arb_poly_shift_right(arb_ptr res, arb_srcptr poly, slong len, slong n) - void arb_poly_shift_right(arb_poly_t res, const arb_poly_t poly, long n) + void arb_poly_shift_right(arb_poly_t res, const arb_poly_t poly, slong n) # Sets *res* to *poly* divided by `x^n`, throwing away the lower coefficients. # We require that *n* is nonnegative. - void _arb_poly_shift_left(arb_ptr res, arb_srcptr poly, long len, long n) + void _arb_poly_shift_left(arb_ptr res, arb_srcptr poly, slong len, slong n) - void arb_poly_shift_left(arb_poly_t res, const arb_poly_t poly, long n) + void arb_poly_shift_left(arb_poly_t res, const arb_poly_t poly, slong n) # Sets *res* to *poly* multiplied by `x^n`. # We require that *n* is nonnegative. - void arb_poly_truncate(arb_poly_t poly, long n) + void arb_poly_truncate(arb_poly_t poly, slong n) # Truncates *poly* to have length at most *n*, i.e. degree # strictly smaller than *n*. We require that *n* is nonnegative. - long arb_poly_valuation(const arb_poly_t poly) + slong arb_poly_valuation(const arb_poly_t poly) # Returns the degree of the lowest term that is not exactly zero in *poly*. # Returns -1 if *poly* is the zero polynomial. - void arb_poly_set_fmpz_poly(arb_poly_t poly, const fmpz_poly_t src, long prec) + void arb_poly_set_fmpz_poly(arb_poly_t poly, const fmpz_poly_t src, slong prec) - void arb_poly_set_fmpq_poly(arb_poly_t poly, const fmpq_poly_t src, long prec) + void arb_poly_set_fmpq_poly(arb_poly_t poly, const fmpq_poly_t src, slong prec) - void arb_poly_set_si(arb_poly_t poly, long src) + void arb_poly_set_si(arb_poly_t poly, slong src) # Sets *poly* to *src*, rounding the coefficients to *prec* bits. - void arb_poly_printd(const arb_poly_t poly, long digits) + void arb_poly_printd(const arb_poly_t poly, slong digits) # Prints the polynomial as an array of coefficients, printing each # coefficient using *arb_printd*. - void arb_poly_fprintd(FILE * file, const arb_poly_t poly, long digits) + void arb_poly_fprintd(FILE * file, const arb_poly_t poly, slong digits) # Prints the polynomial as an array of coefficients to the stream *file*, # printing each coefficient using *arb_fprintd*. - void arb_poly_randtest(arb_poly_t poly, flint_rand_t state, long len, long prec, long mag_bits) + void arb_poly_randtest(arb_poly_t poly, flint_rand_t state, slong len, slong prec, slong mag_bits) # Creates a random polynomial with length at most *len*. int arb_poly_contains(const arb_poly_t poly1, const arb_poly_t poly2) @@ -131,7 +131,7 @@ cdef extern from "flint_wrap.h": # Returns nonzero iff *A* and *B* are equal as polynomial balls, i.e. all # coefficients have equal midpoint and radius. - int _arb_poly_overlaps(arb_srcptr poly1, long len1, arb_srcptr poly2, long len2) + int _arb_poly_overlaps(arb_srcptr poly1, slong len1, arb_srcptr poly2, slong len2) int arb_poly_overlaps(const arb_poly_t poly1, const arb_poly_t poly2) # Returns nonzero iff *poly1* overlaps with *poly2*. The underscore @@ -142,52 +142,52 @@ cdef extern from "flint_wrap.h": # nonzero. Otherwise (if *x* represents no integers or more than one integer), # returns zero, possibly partially modifying *z*. - void _arb_poly_majorant(arb_ptr res, arb_srcptr poly, long len, long prec) + void _arb_poly_majorant(arb_ptr res, arb_srcptr poly, slong len, slong prec) - void arb_poly_majorant(arb_poly_t res, const arb_poly_t poly, long prec) + void arb_poly_majorant(arb_poly_t res, const arb_poly_t poly, slong prec) # Sets *res* to an exact real polynomial whose coefficients are # upper bounds for the absolute values of the coefficients in *poly*, # rounded to *prec* bits. - void _arb_poly_add(arb_ptr C, arb_srcptr A, long lenA, arb_srcptr B, long lenB, long prec) + void _arb_poly_add(arb_ptr C, arb_srcptr A, slong lenA, arb_srcptr B, slong lenB, slong prec) # Sets *{C, max(lenA, lenB)}* to the sum of *{A, lenA}* and *{B, lenB}*. # Allows aliasing of the input and output operands. - void arb_poly_add(arb_poly_t C, const arb_poly_t A, const arb_poly_t B, long prec) + void arb_poly_add(arb_poly_t C, const arb_poly_t A, const arb_poly_t B, slong prec) - void arb_poly_add_si(arb_poly_t C, const arb_poly_t A, long B, long prec) + void arb_poly_add_si(arb_poly_t C, const arb_poly_t A, slong B, slong prec) # Sets *C* to the sum of *A* and *B*. - void _arb_poly_sub(arb_ptr C, arb_srcptr A, long lenA, arb_srcptr B, long lenB, long prec) + void _arb_poly_sub(arb_ptr C, arb_srcptr A, slong lenA, arb_srcptr B, slong lenB, slong prec) # Sets *{C, max(lenA, lenB)}* to the difference of *{A, lenA}* and *{B, lenB}*. # Allows aliasing of the input and output operands. - void arb_poly_sub(arb_poly_t C, const arb_poly_t A, const arb_poly_t B, long prec) + void arb_poly_sub(arb_poly_t C, const arb_poly_t A, const arb_poly_t B, slong prec) # Sets *C* to the difference of *A* and *B*. - void arb_poly_add_series(arb_poly_t C, const arb_poly_t A, const arb_poly_t B, long len, long prec) + void arb_poly_add_series(arb_poly_t C, const arb_poly_t A, const arb_poly_t B, slong len, slong prec) # Sets *C* to the sum of *A* and *B*, truncated to length *len*. - void arb_poly_sub_series(arb_poly_t C, const arb_poly_t A, const arb_poly_t B, long len, long prec) + void arb_poly_sub_series(arb_poly_t C, const arb_poly_t A, const arb_poly_t B, slong len, slong prec) # Sets *C* to the difference of *A* and *B*, truncated to length *len*. void arb_poly_neg(arb_poly_t C, const arb_poly_t A) # Sets *C* to the negation of *A*. - void arb_poly_scalar_mul_2exp_si(arb_poly_t C, const arb_poly_t A, long c) + void arb_poly_scalar_mul_2exp_si(arb_poly_t C, const arb_poly_t A, slong c) # Sets *C* to *A* multiplied by `2^c`. - void arb_poly_scalar_mul(arb_poly_t C, const arb_poly_t A, const arb_t c, long prec) + void arb_poly_scalar_mul(arb_poly_t C, const arb_poly_t A, const arb_t c, slong prec) # Sets *C* to *A* multiplied by *c*. - void arb_poly_scalar_div(arb_poly_t C, const arb_poly_t A, const arb_t c, long prec) + void arb_poly_scalar_div(arb_poly_t C, const arb_poly_t A, const arb_t c, slong prec) # Sets *C* to *A* divided by *c*. - void _arb_poly_mullow_classical(arb_ptr C, arb_srcptr A, long lenA, arb_srcptr B, long lenB, long n, long prec) + void _arb_poly_mullow_classical(arb_ptr C, arb_srcptr A, slong lenA, arb_srcptr B, slong lenB, slong n, slong prec) - void _arb_poly_mullow_block(arb_ptr C, arb_srcptr A, long lenA, arb_srcptr B, long lenB, long n, long prec) + void _arb_poly_mullow_block(arb_ptr C, arb_srcptr A, slong lenA, arb_srcptr B, slong lenB, slong n, slong prec) - void _arb_poly_mullow(arb_ptr C, arb_srcptr A, long lenA, arb_srcptr B, long lenB, long n, long prec) + void _arb_poly_mullow(arb_ptr C, arb_srcptr A, slong lenA, arb_srcptr B, slong lenB, slong n, slong prec) # Sets *{C, n}* to the product of *{A, lenA}* and *{B, lenB}*, truncated to # length *n*. The output is not allowed to be aliased with either of the # inputs. We require `\mathrm{lenA} \ge \mathrm{lenB} > 0`, @@ -220,18 +220,18 @@ cdef extern from "flint_wrap.h": # they are assumed to represent the same polynomial, and its # square is computed. - void arb_poly_mullow_classical(arb_poly_t C, const arb_poly_t A, const arb_poly_t B, long n, long prec) + void arb_poly_mullow_classical(arb_poly_t C, const arb_poly_t A, const arb_poly_t B, slong n, slong prec) - void arb_poly_mullow_ztrunc(arb_poly_t C, const arb_poly_t A, const arb_poly_t B, long n, long prec) + void arb_poly_mullow_ztrunc(arb_poly_t C, const arb_poly_t A, const arb_poly_t B, slong n, slong prec) - void arb_poly_mullow_block(arb_poly_t C, const arb_poly_t A, const arb_poly_t B, long n, long prec) + void arb_poly_mullow_block(arb_poly_t C, const arb_poly_t A, const arb_poly_t B, slong n, slong prec) - void arb_poly_mullow(arb_poly_t C, const arb_poly_t A, const arb_poly_t B, long n, long prec) + void arb_poly_mullow(arb_poly_t C, const arb_poly_t A, const arb_poly_t B, slong n, slong prec) # Sets *C* to the product of *A* and *B*, truncated to length *n*. # If the same variable is passed for *A* and *B*, sets *C* to the square # of *A* truncated to length *n*. - void _arb_poly_mul(arb_ptr C, arb_srcptr A, long lenA, arb_srcptr B, long lenB, long prec) + void _arb_poly_mul(arb_ptr C, arb_srcptr A, slong lenA, arb_srcptr B, slong lenB, slong prec) # Sets *{C, lenA + lenB - 1}* to the product of *{A, lenA}* and *{B, lenB}*. # The output is not allowed to be aliased with either of the # inputs. We require `\mathrm{lenA} \ge \mathrm{lenB} > 0`. @@ -240,31 +240,31 @@ cdef extern from "flint_wrap.h": # they are assumed to represent the same polynomial, and its # square is computed. - void arb_poly_mul(arb_poly_t C, const arb_poly_t A, const arb_poly_t B, long prec) + void arb_poly_mul(arb_poly_t C, const arb_poly_t A, const arb_poly_t B, slong prec) # Sets *C* to the product of *A* and *B*. # If the same variable is passed for *A* and *B*, sets *C* to the # square of *A*. - void _arb_poly_inv_series(arb_ptr Q, arb_srcptr A, long Alen, long len, long prec) + void _arb_poly_inv_series(arb_ptr Q, arb_srcptr A, slong Alen, slong len, slong prec) # Sets *{Q, len}* to the power series inverse of *{A, Alen}*. Uses Newton iteration. - void arb_poly_inv_series(arb_poly_t Q, const arb_poly_t A, long n, long prec) + void arb_poly_inv_series(arb_poly_t Q, const arb_poly_t A, slong n, slong prec) # Sets *Q* to the power series inverse of *A*, truncated to length *n*. - void _arb_poly_div_series(arb_ptr Q, arb_srcptr A, long Alen, arb_srcptr B, long Blen, long n, long prec) + void _arb_poly_div_series(arb_ptr Q, arb_srcptr A, slong Alen, arb_srcptr B, slong Blen, slong n, slong prec) # Sets *{Q, n}* to the power series quotient of *{A, Alen}* by *{B, Blen}*. # Uses Newton iteration followed by multiplication. - void arb_poly_div_series(arb_poly_t Q, const arb_poly_t A, const arb_poly_t B, long n, long prec) + void arb_poly_div_series(arb_poly_t Q, const arb_poly_t A, const arb_poly_t B, slong n, slong prec) # Sets *Q* to the power series quotient *A* divided by *B*, truncated to length *n*. - void _arb_poly_div(arb_ptr Q, arb_srcptr A, long lenA, arb_srcptr B, long lenB, long prec) + void _arb_poly_div(arb_ptr Q, arb_srcptr A, slong lenA, arb_srcptr B, slong lenB, slong prec) - void _arb_poly_rem(arb_ptr R, arb_srcptr A, long lenA, arb_srcptr B, long lenB, long prec) + void _arb_poly_rem(arb_ptr R, arb_srcptr A, slong lenA, arb_srcptr B, slong lenB, slong prec) - void _arb_poly_divrem(arb_ptr Q, arb_ptr R, arb_srcptr A, long lenA, arb_srcptr B, long lenB, long prec) + void _arb_poly_divrem(arb_ptr Q, arb_ptr R, arb_srcptr A, slong lenA, arb_srcptr B, slong lenB, slong prec) - int arb_poly_divrem(arb_poly_t Q, arb_poly_t R, const arb_poly_t A, const arb_poly_t B, long prec) + int arb_poly_divrem(arb_poly_t Q, arb_poly_t R, const arb_poly_t A, const arb_poly_t B, slong prec) # Performs polynomial division with remainder, computing a quotient `Q` and # a remainder `R` such that `A = BQ + R`. The implementation reverses the # inputs and performs power series division. @@ -272,24 +272,24 @@ cdef extern from "flint_wrap.h": # zero), returns 0 indicating failure without modifying the outputs. # Otherwise returns nonzero. - void _arb_poly_div_root(arb_ptr Q, arb_t R, arb_srcptr A, long len, const arb_t c, long prec) + void _arb_poly_div_root(arb_ptr Q, arb_t R, arb_srcptr A, slong len, const arb_t c, slong prec) # Divides `A` by the polynomial `x - c`, computing the quotient `Q` as well # as the remainder `R = f(c)`. - void _arb_poly_taylor_shift(arb_ptr g, const arb_t c, long n, long prec) - void arb_poly_taylor_shift(arb_poly_t g, const arb_poly_t f, const arb_t c, long prec) + void _arb_poly_taylor_shift(arb_ptr g, const arb_t c, slong n, slong prec) + void arb_poly_taylor_shift(arb_poly_t g, const arb_poly_t f, const arb_t c, slong prec) # Sets *g* to the Taylor shift `f(x+c)`. # The underscore methods act in-place on *g* = *f* which has length *n*. - void _arb_poly_compose(arb_ptr res, arb_srcptr poly1, long len1, arb_srcptr poly2, long len2, long prec) - void arb_poly_compose(arb_poly_t res, const arb_poly_t poly1, const arb_poly_t poly2, long prec) + void _arb_poly_compose(arb_ptr res, arb_srcptr poly1, slong len1, arb_srcptr poly2, slong len2, slong prec) + void arb_poly_compose(arb_poly_t res, const arb_poly_t poly1, const arb_poly_t poly2, slong prec) # Sets *res* to the composition `h(x) = f(g(x))` where `f` is given by # *poly1* and `g` is given by *poly2*. # The underscore method does not support aliasing of the output # with either input polynomial. - void _arb_poly_compose_series(arb_ptr res, arb_srcptr poly1, long len1, arb_srcptr poly2, long len2, long n, long prec) - void arb_poly_compose_series(arb_poly_t res, const arb_poly_t poly1, const arb_poly_t poly2, long n, long prec) + void _arb_poly_compose_series(arb_ptr res, arb_srcptr poly1, slong len1, arb_srcptr poly2, slong len2, slong n, slong prec) + void arb_poly_compose_series(arb_poly_t res, const arb_poly_t poly1, const arb_poly_t poly2, slong n, slong prec) # Sets *res* to the power series composition `h(x) = f(g(x))` truncated # to order `O(x^n)` where `f` is given by *poly1* and `g` is given by *poly2*. # Wraps :func:`_gr_poly_compose_series` which chooses automatically @@ -298,21 +298,21 @@ cdef extern from "flint_wrap.h": # The underscore method does not support aliasing of the output # with either input polynomial. - void _arb_poly_revert_series_lagrange(arb_ptr h, arb_srcptr f, long flen, long n, long prec) + void _arb_poly_revert_series_lagrange(arb_ptr h, arb_srcptr f, slong flen, slong n, slong prec) - void arb_poly_revert_series_lagrange(arb_poly_t h, const arb_poly_t f, long n, long prec) + void arb_poly_revert_series_lagrange(arb_poly_t h, const arb_poly_t f, slong n, slong prec) - void _arb_poly_revert_series_newton(arb_ptr h, arb_srcptr f, long flen, long n, long prec) + void _arb_poly_revert_series_newton(arb_ptr h, arb_srcptr f, slong flen, slong n, slong prec) - void arb_poly_revert_series_newton(arb_poly_t h, const arb_poly_t f, long n, long prec) + void arb_poly_revert_series_newton(arb_poly_t h, const arb_poly_t f, slong n, slong prec) - void _arb_poly_revert_series_lagrange_fast(arb_ptr h, arb_srcptr f, long flen, long n, long prec) + void _arb_poly_revert_series_lagrange_fast(arb_ptr h, arb_srcptr f, slong flen, slong n, slong prec) - void arb_poly_revert_series_lagrange_fast(arb_poly_t h, const arb_poly_t f, long n, long prec) + void arb_poly_revert_series_lagrange_fast(arb_poly_t h, const arb_poly_t f, slong n, slong prec) - void _arb_poly_revert_series(arb_ptr h, arb_srcptr f, long flen, long n, long prec) + void _arb_poly_revert_series(arb_ptr h, arb_srcptr f, slong flen, slong n, slong prec) - void arb_poly_revert_series(arb_poly_t h, const arb_poly_t f, long n, long prec) + void arb_poly_revert_series(arb_poly_t h, const arb_poly_t f, slong n, slong prec) # Sets `h` to the power series reversion of `f`, i.e. the expansion # of the compositional inverse function `f^{-1}(x)`, # truncated to order `O(x^n)`, using respectively @@ -322,46 +322,46 @@ cdef extern from "flint_wrap.h": # linear term is nonzero. The underscore methods assume that *flen* # is at least 2, and do not support aliasing. - void _arb_poly_evaluate_horner(arb_t y, arb_srcptr f, long len, const arb_t x, long prec) + void _arb_poly_evaluate_horner(arb_t y, arb_srcptr f, slong len, const arb_t x, slong prec) - void arb_poly_evaluate_horner(arb_t y, const arb_poly_t f, const arb_t x, long prec) + void arb_poly_evaluate_horner(arb_t y, const arb_poly_t f, const arb_t x, slong prec) - void _arb_poly_evaluate_rectangular(arb_t y, arb_srcptr f, long len, const arb_t x, long prec) + void _arb_poly_evaluate_rectangular(arb_t y, arb_srcptr f, slong len, const arb_t x, slong prec) - void arb_poly_evaluate_rectangular(arb_t y, const arb_poly_t f, const arb_t x, long prec) + void arb_poly_evaluate_rectangular(arb_t y, const arb_poly_t f, const arb_t x, slong prec) - void _arb_poly_evaluate(arb_t y, arb_srcptr f, long len, const arb_t x, long prec) + void _arb_poly_evaluate(arb_t y, arb_srcptr f, slong len, const arb_t x, slong prec) - void arb_poly_evaluate(arb_t y, const arb_poly_t f, const arb_t x, long prec) + void arb_poly_evaluate(arb_t y, const arb_poly_t f, const arb_t x, slong prec) # Sets `y = f(x)`, evaluated respectively using Horner's rule, # rectangular splitting, and an automatic algorithm choice. - void _arb_poly_evaluate_acb_horner(acb_t y, arb_srcptr f, long len, const acb_t x, long prec) + void _arb_poly_evaluate_acb_horner(acb_t y, arb_srcptr f, slong len, const acb_t x, slong prec) - void arb_poly_evaluate_acb_horner(acb_t y, const arb_poly_t f, const acb_t x, long prec) + void arb_poly_evaluate_acb_horner(acb_t y, const arb_poly_t f, const acb_t x, slong prec) - void _arb_poly_evaluate_acb_rectangular(acb_t y, arb_srcptr f, long len, const acb_t x, long prec) + void _arb_poly_evaluate_acb_rectangular(acb_t y, arb_srcptr f, slong len, const acb_t x, slong prec) - void arb_poly_evaluate_acb_rectangular(acb_t y, const arb_poly_t f, const acb_t x, long prec) + void arb_poly_evaluate_acb_rectangular(acb_t y, const arb_poly_t f, const acb_t x, slong prec) - void _arb_poly_evaluate_acb(acb_t y, arb_srcptr f, long len, const acb_t x, long prec) + void _arb_poly_evaluate_acb(acb_t y, arb_srcptr f, slong len, const acb_t x, slong prec) - void arb_poly_evaluate_acb(acb_t y, const arb_poly_t f, const acb_t x, long prec) + void arb_poly_evaluate_acb(acb_t y, const arb_poly_t f, const acb_t x, slong prec) # Sets `y = f(x)` where `x` is a complex number, evaluating the # polynomial respectively using Horner's rule, # rectangular splitting, and an automatic algorithm choice. - void _arb_poly_evaluate2_horner(arb_t y, arb_t z, arb_srcptr f, long len, const arb_t x, long prec) + void _arb_poly_evaluate2_horner(arb_t y, arb_t z, arb_srcptr f, slong len, const arb_t x, slong prec) - void arb_poly_evaluate2_horner(arb_t y, arb_t z, const arb_poly_t f, const arb_t x, long prec) + void arb_poly_evaluate2_horner(arb_t y, arb_t z, const arb_poly_t f, const arb_t x, slong prec) - void _arb_poly_evaluate2_rectangular(arb_t y, arb_t z, arb_srcptr f, long len, const arb_t x, long prec) + void _arb_poly_evaluate2_rectangular(arb_t y, arb_t z, arb_srcptr f, slong len, const arb_t x, slong prec) - void arb_poly_evaluate2_rectangular(arb_t y, arb_t z, const arb_poly_t f, const arb_t x, long prec) + void arb_poly_evaluate2_rectangular(arb_t y, arb_t z, const arb_poly_t f, const arb_t x, slong prec) - void _arb_poly_evaluate2(arb_t y, arb_t z, arb_srcptr f, long len, const arb_t x, long prec) + void _arb_poly_evaluate2(arb_t y, arb_t z, arb_srcptr f, slong len, const arb_t x, slong prec) - void arb_poly_evaluate2(arb_t y, arb_t z, const arb_poly_t f, const arb_t x, long prec) + void arb_poly_evaluate2(arb_t y, arb_t z, const arb_poly_t f, const arb_t x, slong prec) # Sets `y = f(x), z = f'(x)`, evaluated respectively using Horner's rule, # rectangular splitting, and an automatic algorithm choice. # When Horner's rule is used, the only advantage of evaluating the @@ -370,28 +370,28 @@ cdef extern from "flint_wrap.h": # With the rectangular splitting algorithm, the powers can be reused, # making simultaneous evaluation slightly faster. - void _arb_poly_evaluate2_acb_horner(acb_t y, acb_t z, arb_srcptr f, long len, const acb_t x, long prec) + void _arb_poly_evaluate2_acb_horner(acb_t y, acb_t z, arb_srcptr f, slong len, const acb_t x, slong prec) - void arb_poly_evaluate2_acb_horner(acb_t y, acb_t z, const arb_poly_t f, const acb_t x, long prec) + void arb_poly_evaluate2_acb_horner(acb_t y, acb_t z, const arb_poly_t f, const acb_t x, slong prec) - void _arb_poly_evaluate2_acb_rectangular(acb_t y, acb_t z, arb_srcptr f, long len, const acb_t x, long prec) + void _arb_poly_evaluate2_acb_rectangular(acb_t y, acb_t z, arb_srcptr f, slong len, const acb_t x, slong prec) - void arb_poly_evaluate2_acb_rectangular(acb_t y, acb_t z, const arb_poly_t f, const acb_t x, long prec) + void arb_poly_evaluate2_acb_rectangular(acb_t y, acb_t z, const arb_poly_t f, const acb_t x, slong prec) - void _arb_poly_evaluate2_acb(acb_t y, acb_t z, arb_srcptr f, long len, const acb_t x, long prec) + void _arb_poly_evaluate2_acb(acb_t y, acb_t z, arb_srcptr f, slong len, const acb_t x, slong prec) - void arb_poly_evaluate2_acb(acb_t y, acb_t z, const arb_poly_t f, const acb_t x, long prec) + void arb_poly_evaluate2_acb(acb_t y, acb_t z, const arb_poly_t f, const acb_t x, slong prec) # Sets `y = f(x), z = f'(x)`, evaluated respectively using Horner's rule, # rectangular splitting, and an automatic algorithm choice. - void _arb_poly_product_roots(arb_ptr poly, arb_srcptr xs, long n, long prec) + void _arb_poly_product_roots(arb_ptr poly, arb_srcptr xs, slong n, slong prec) - void arb_poly_product_roots(arb_poly_t poly, arb_srcptr xs, long n, long prec) + void arb_poly_product_roots(arb_poly_t poly, arb_srcptr xs, slong n, slong prec) # Generates the polynomial `(x-x_0)(x-x_1)\cdots(x-x_{n-1})`. - void _arb_poly_product_roots_complex(arb_ptr poly, arb_srcptr r, long rn, acb_srcptr c, long cn, long prec) + void _arb_poly_product_roots_complex(arb_ptr poly, arb_srcptr r, slong rn, acb_srcptr c, slong cn, slong prec) - void arb_poly_product_roots_complex(arb_poly_t poly, arb_srcptr r, long rn, acb_srcptr c, long cn, long prec) + void arb_poly_product_roots_complex(arb_poly_t poly, arb_srcptr r, slong rn, acb_srcptr c, slong cn, slong prec) # Generates the polynomial # .. math :: # \left(\prod_{i=0}^{rn-1} (x-r_i)\right) \left(\prod_{i=0}^{cn-1} (x-c_i)(x-\bar{c_i})\right) @@ -404,102 +404,102 @@ cdef extern from "flint_wrap.h": # To construct a polynomial from complex roots where the conjugate pairs # have not been distinguished, use :func:`acb_poly_product_roots` instead. - arb_ptr * _arb_poly_tree_alloc(long len) + arb_ptr * _arb_poly_tree_alloc(slong len) # Returns an initialized data structured capable of representing a # remainder tree (product tree) of *len* roots. - void _arb_poly_tree_free(arb_ptr * tree, long len) + void _arb_poly_tree_free(arb_ptr * tree, slong len) # Deallocates a tree structure as allocated using *_arb_poly_tree_alloc*. - void _arb_poly_tree_build(arb_ptr * tree, arb_srcptr roots, long len, long prec) + void _arb_poly_tree_build(arb_ptr * tree, arb_srcptr roots, slong len, slong prec) # Constructs a product tree from a given array of *len* roots. The tree # structure must be pre-allocated to the specified length using # :func:`_arb_poly_tree_alloc`. - void _arb_poly_evaluate_vec_iter(arb_ptr ys, arb_srcptr poly, long plen, arb_srcptr xs, long n, long prec) + void _arb_poly_evaluate_vec_iter(arb_ptr ys, arb_srcptr poly, slong plen, arb_srcptr xs, slong n, slong prec) - void arb_poly_evaluate_vec_iter(arb_ptr ys, const arb_poly_t poly, arb_srcptr xs, long n, long prec) + void arb_poly_evaluate_vec_iter(arb_ptr ys, const arb_poly_t poly, arb_srcptr xs, slong n, slong prec) # Evaluates the polynomial simultaneously at *n* given points, calling # :func:`_arb_poly_evaluate` repeatedly. - void _arb_poly_evaluate_vec_fast_precomp(arb_ptr vs, arb_srcptr poly, long plen, arb_ptr * tree, long len, long prec) + void _arb_poly_evaluate_vec_fast_precomp(arb_ptr vs, arb_srcptr poly, slong plen, arb_ptr * tree, slong len, slong prec) - void _arb_poly_evaluate_vec_fast(arb_ptr ys, arb_srcptr poly, long plen, arb_srcptr xs, long n, long prec) + void _arb_poly_evaluate_vec_fast(arb_ptr ys, arb_srcptr poly, slong plen, arb_srcptr xs, slong n, slong prec) - void arb_poly_evaluate_vec_fast(arb_ptr ys, const arb_poly_t poly, arb_srcptr xs, long n, long prec) + void arb_poly_evaluate_vec_fast(arb_ptr ys, const arb_poly_t poly, arb_srcptr xs, slong n, slong prec) # Evaluates the polynomial simultaneously at *n* given points, using # fast multipoint evaluation. - void _arb_poly_interpolate_newton(arb_ptr poly, arb_srcptr xs, arb_srcptr ys, long n, long prec) + void _arb_poly_interpolate_newton(arb_ptr poly, arb_srcptr xs, arb_srcptr ys, slong n, slong prec) - void arb_poly_interpolate_newton(arb_poly_t poly, arb_srcptr xs, arb_srcptr ys, long n, long prec) + void arb_poly_interpolate_newton(arb_poly_t poly, arb_srcptr xs, arb_srcptr ys, slong n, slong prec) # Recovers the unique polynomial of length at most *n* that interpolates # the given *x* and *y* values. This implementation first interpolates in the # Newton basis and then converts back to the monomial basis. - void _arb_poly_interpolate_barycentric(arb_ptr poly, arb_srcptr xs, arb_srcptr ys, long n, long prec) + void _arb_poly_interpolate_barycentric(arb_ptr poly, arb_srcptr xs, arb_srcptr ys, slong n, slong prec) - void arb_poly_interpolate_barycentric(arb_poly_t poly, arb_srcptr xs, arb_srcptr ys, long n, long prec) + void arb_poly_interpolate_barycentric(arb_poly_t poly, arb_srcptr xs, arb_srcptr ys, slong n, slong prec) # Recovers the unique polynomial of length at most *n* that interpolates # the given *x* and *y* values. This implementation uses the barycentric # form of Lagrange interpolation. - void _arb_poly_interpolation_weights(arb_ptr w, arb_ptr * tree, long len, long prec) + void _arb_poly_interpolation_weights(arb_ptr w, arb_ptr * tree, slong len, slong prec) - void _arb_poly_interpolate_fast_precomp(arb_ptr poly, arb_srcptr ys, arb_ptr * tree, arb_srcptr weights, long len, long prec) + void _arb_poly_interpolate_fast_precomp(arb_ptr poly, arb_srcptr ys, arb_ptr * tree, arb_srcptr weights, slong len, slong prec) - void _arb_poly_interpolate_fast(arb_ptr poly, arb_srcptr xs, arb_srcptr ys, long len, long prec) + void _arb_poly_interpolate_fast(arb_ptr poly, arb_srcptr xs, arb_srcptr ys, slong len, slong prec) - void arb_poly_interpolate_fast(arb_poly_t poly, arb_srcptr xs, arb_srcptr ys, long n, long prec) + void arb_poly_interpolate_fast(arb_poly_t poly, arb_srcptr xs, arb_srcptr ys, slong n, slong prec) # Recovers the unique polynomial of length at most *n* that interpolates # the given *x* and *y* values, using fast Lagrange interpolation. # The precomp function takes a precomputed product tree over the # *x* values and a vector of interpolation weights as additional inputs. - void _arb_poly_derivative(arb_ptr res, arb_srcptr poly, long len, long prec) + void _arb_poly_derivative(arb_ptr res, arb_srcptr poly, slong len, slong prec) # Sets *{res, len - 1}* to the derivative of *{poly, len}*. # Allows aliasing of the input and output. - void arb_poly_derivative(arb_poly_t res, const arb_poly_t poly, long prec) + void arb_poly_derivative(arb_poly_t res, const arb_poly_t poly, slong prec) # Sets *res* to the derivative of *poly*. - void _arb_poly_nth_derivative(arb_ptr res, arb_srcptr poly, unsigned long n, long len, long prec) + void _arb_poly_nth_derivative(arb_ptr res, arb_srcptr poly, ulong n, slong len, slong prec) # Sets *{res, len - n}* to the nth derivative of *{poly, len}*. Does # nothing if *len <= n*. Allows aliasing of the input and output. - void arb_poly_nth_derivative(arb_poly_t res, const arb_poly_t poly, unsigned long n, long prec) + void arb_poly_nth_derivative(arb_poly_t res, const arb_poly_t poly, ulong n, slong prec) # Sets *res* to the nth derivative of *poly*. - void _arb_poly_integral(arb_ptr res, arb_srcptr poly, long len, long prec) + void _arb_poly_integral(arb_ptr res, arb_srcptr poly, slong len, slong prec) # Sets *{res, len}* to the integral of *{poly, len - 1}*. # Allows aliasing of the input and output. - void arb_poly_integral(arb_poly_t res, const arb_poly_t poly, long prec) + void arb_poly_integral(arb_poly_t res, const arb_poly_t poly, slong prec) # Sets *res* to the integral of *poly*. - void _arb_poly_borel_transform(arb_ptr res, arb_srcptr poly, long len, long prec) + void _arb_poly_borel_transform(arb_ptr res, arb_srcptr poly, slong len, slong prec) - void arb_poly_borel_transform(arb_poly_t res, const arb_poly_t poly, long prec) + void arb_poly_borel_transform(arb_poly_t res, const arb_poly_t poly, slong prec) # Computes the Borel transform of the input polynomial, mapping `\sum_k a_k x^k` # to `\sum_k (a_k / k!) x^k`. The underscore method allows aliasing. - void _arb_poly_inv_borel_transform(arb_ptr res, arb_srcptr poly, long len, long prec) + void _arb_poly_inv_borel_transform(arb_ptr res, arb_srcptr poly, slong len, slong prec) - void arb_poly_inv_borel_transform(arb_poly_t res, const arb_poly_t poly, long prec) + void arb_poly_inv_borel_transform(arb_poly_t res, const arb_poly_t poly, slong prec) # Computes the inverse Borel transform of the input polynomial, mapping `\sum_k a_k x^k` # to `\sum_k a_k k! x^k`. The underscore method allows aliasing. - void _arb_poly_binomial_transform_basecase(arb_ptr b, arb_srcptr a, long alen, long len, long prec) + void _arb_poly_binomial_transform_basecase(arb_ptr b, arb_srcptr a, slong alen, slong len, slong prec) - void arb_poly_binomial_transform_basecase(arb_poly_t b, const arb_poly_t a, long len, long prec) + void arb_poly_binomial_transform_basecase(arb_poly_t b, const arb_poly_t a, slong len, slong prec) - void _arb_poly_binomial_transform_convolution(arb_ptr b, arb_srcptr a, long alen, long len, long prec) + void _arb_poly_binomial_transform_convolution(arb_ptr b, arb_srcptr a, slong alen, slong len, slong prec) - void arb_poly_binomial_transform_convolution(arb_poly_t b, const arb_poly_t a, long len, long prec) + void arb_poly_binomial_transform_convolution(arb_poly_t b, const arb_poly_t a, slong len, slong prec) - void _arb_poly_binomial_transform(arb_ptr b, arb_srcptr a, long alen, long len, long prec) + void _arb_poly_binomial_transform(arb_ptr b, arb_srcptr a, slong alen, slong len, slong prec) - void arb_poly_binomial_transform(arb_poly_t b, const arb_poly_t a, long len, long prec) + void arb_poly_binomial_transform(arb_poly_t b, const arb_poly_t a, slong len, slong prec) # Computes the binomial transform of the input polynomial, truncating # the output to length *len*. # The binomial transform maps the coefficients `a_k` in the input polynomial @@ -519,9 +519,9 @@ cdef extern from "flint_wrap.h": # The underscore methods do not support aliasing, and assume that # the lengths are nonzero. - void _arb_poly_graeffe_transform(arb_ptr b, arb_srcptr a, long len, long prec) + void _arb_poly_graeffe_transform(arb_ptr b, arb_srcptr a, slong len, slong prec) - void arb_poly_graeffe_transform(arb_poly_t b, const arb_poly_t a, long prec) + void arb_poly_graeffe_transform(arb_poly_t b, const arb_poly_t a, slong prec) # Computes the Graeffe transform of input polynomial. # The Graeffe transform `G` of a polynomial `P` is defined through the # equation `G(x^2) = \pm P(x)P(-x)`. @@ -532,7 +532,7 @@ cdef extern from "flint_wrap.h": # *a* is of length *len*, and *b* is of length at least *len*. # Both methods allow aliasing. - void _arb_poly_pow_ui_trunc_binexp(arb_ptr res, arb_srcptr f, long flen, unsigned long exp, long len, long prec) + void _arb_poly_pow_ui_trunc_binexp(arb_ptr res, arb_srcptr f, slong flen, ulong exp, slong len, slong prec) # Sets *{res, len}* to *{f, flen}* raised to the power *exp*, truncated # to length *len*. Requires that *len* is no longer than the length # of the power as computed without truncation (i.e. no zero-padding is performed). @@ -540,19 +540,19 @@ cdef extern from "flint_wrap.h": # that *flen* and *len* are positive. # Uses binary exponentiation. - void arb_poly_pow_ui_trunc_binexp(arb_poly_t res, const arb_poly_t poly, unsigned long exp, long len, long prec) + void arb_poly_pow_ui_trunc_binexp(arb_poly_t res, const arb_poly_t poly, ulong exp, slong len, slong prec) # Sets *res* to *poly* raised to the power *exp*, truncated to length *len*. # Uses binary exponentiation. - void _arb_poly_pow_ui(arb_ptr res, arb_srcptr f, long flen, unsigned long exp, long prec) + void _arb_poly_pow_ui(arb_ptr res, arb_srcptr f, slong flen, ulong exp, slong prec) # Sets *res* to *{f, flen}* raised to the power *exp*. Does not # support aliasing of the input and output, and requires that # *flen* is positive. - void arb_poly_pow_ui(arb_poly_t res, const arb_poly_t poly, unsigned long exp, long prec) + void arb_poly_pow_ui(arb_poly_t res, const arb_poly_t poly, ulong exp, slong prec) # Sets *res* to *poly* raised to the power *exp*. - void _arb_poly_pow_series(arb_ptr h, arb_srcptr f, long flen, arb_srcptr g, long glen, long len, long prec) + void _arb_poly_pow_series(arb_ptr h, arb_srcptr f, slong flen, arb_srcptr g, slong glen, slong len, slong prec) # Sets *{h, len}* to the power series `f(x)^{g(x)} = \exp(g(x) \log f(x))` truncated # to length *len*. This function detects special cases such as *g* being an # exact small integer or `\pm 1/2`, and computes such powers more @@ -560,13 +560,13 @@ cdef extern from "flint_wrap.h": # with either of the input operands. It requires that all lengths # are positive, and assumes that *flen* and *glen* do not exceed *len*. - void arb_poly_pow_series(arb_poly_t h, const arb_poly_t f, const arb_poly_t g, long len, long prec) + void arb_poly_pow_series(arb_poly_t h, const arb_poly_t f, const arb_poly_t g, slong len, slong prec) # Sets *h* to the power series `f(x)^{g(x)} = \exp(g(x) \log f(x))` truncated # to length *len*. This function detects special cases such as *g* being an # exact small integer or `\pm 1/2`, and computes such powers more # efficiently. - void _arb_poly_pow_arb_series(arb_ptr h, arb_srcptr f, long flen, const arb_t g, long len, long prec) + void _arb_poly_pow_arb_series(arb_ptr h, arb_srcptr f, slong flen, const arb_t g, slong len, slong prec) # Sets *{h, len}* to the power series `f(x)^g = \exp(g \log f(x))` truncated # to length *len*. This function detects special cases such as *g* being an # exact small integer or `\pm 1/2`, and computes such powers more @@ -574,52 +574,52 @@ cdef extern from "flint_wrap.h": # with either of the input operands. It requires that all lengths # are positive, and assumes that *flen* does not exceed *len*. - void arb_poly_pow_arb_series(arb_poly_t h, const arb_poly_t f, const arb_t g, long len, long prec) + void arb_poly_pow_arb_series(arb_poly_t h, const arb_poly_t f, const arb_t g, slong len, slong prec) # Sets *h* to the power series `f(x)^g = \exp(g \log f(x))` truncated # to length *len*. - void _arb_poly_sqrt_series(arb_ptr g, arb_srcptr h, long hlen, long n, long prec) + void _arb_poly_sqrt_series(arb_ptr g, arb_srcptr h, slong hlen, slong n, slong prec) - void arb_poly_sqrt_series(arb_poly_t g, const arb_poly_t h, long n, long prec) + void arb_poly_sqrt_series(arb_poly_t g, const arb_poly_t h, slong n, slong prec) # Sets *g* to the power series square root of *h*, truncated to length *n*. # Uses division-free Newton iteration for the reciprocal square root, # followed by a multiplication. # The underscore method does not support aliasing of the input and output # arrays. It requires that *hlen* and *n* are greater than zero. - void _arb_poly_rsqrt_series(arb_ptr g, arb_srcptr h, long hlen, long n, long prec) + void _arb_poly_rsqrt_series(arb_ptr g, arb_srcptr h, slong hlen, slong n, slong prec) - void arb_poly_rsqrt_series(arb_poly_t g, const arb_poly_t h, long n, long prec) + void arb_poly_rsqrt_series(arb_poly_t g, const arb_poly_t h, slong n, slong prec) # Sets *g* to the reciprocal power series square root of *h*, truncated to length *n*. # Uses division-free Newton iteration. # The underscore method does not support aliasing of the input and output # arrays. It requires that *hlen* and *n* are greater than zero. - void _arb_poly_log_series(arb_ptr res, arb_srcptr f, long flen, long n, long prec) + void _arb_poly_log_series(arb_ptr res, arb_srcptr f, slong flen, slong n, slong prec) - void arb_poly_log_series(arb_poly_t res, const arb_poly_t f, long n, long prec) + void arb_poly_log_series(arb_poly_t res, const arb_poly_t f, slong n, slong prec) # Sets *res* to the power series logarithm of *f*, truncated to length *n*. # Uses the formula `\log(f(x)) = \int f'(x) / f(x) dx`, adding the logarithm of the # constant term in *f* as the constant of integration. # The underscore method supports aliasing of the input and output # arrays. It requires that *flen* and *n* are greater than zero. - void _arb_poly_log1p_series(arb_ptr res, arb_srcptr f, long flen, long n, long prec) + void _arb_poly_log1p_series(arb_ptr res, arb_srcptr f, slong flen, slong n, slong prec) - void arb_poly_log1p_series(arb_poly_t res, const arb_poly_t f, long n, long prec) + void arb_poly_log1p_series(arb_poly_t res, const arb_poly_t f, slong n, slong prec) # Computes the power series `\log(1+f)`, with better accuracy when the constant term of *f* is small. - void _arb_poly_atan_series(arb_ptr res, arb_srcptr f, long flen, long n, long prec) + void _arb_poly_atan_series(arb_ptr res, arb_srcptr f, slong flen, slong n, slong prec) - void arb_poly_atan_series(arb_poly_t res, const arb_poly_t f, long n, long prec) + void arb_poly_atan_series(arb_poly_t res, const arb_poly_t f, slong n, slong prec) - void _arb_poly_asin_series(arb_ptr res, arb_srcptr f, long flen, long n, long prec) + void _arb_poly_asin_series(arb_ptr res, arb_srcptr f, slong flen, slong n, slong prec) - void arb_poly_asin_series(arb_poly_t res, const arb_poly_t f, long n, long prec) + void arb_poly_asin_series(arb_poly_t res, const arb_poly_t f, slong n, slong prec) - void _arb_poly_acos_series(arb_ptr res, arb_srcptr f, long flen, long n, long prec) + void _arb_poly_acos_series(arb_ptr res, arb_srcptr f, slong flen, slong n, slong prec) - void arb_poly_acos_series(arb_poly_t res, const arb_poly_t f, long n, long prec) + void arb_poly_acos_series(arb_poly_t res, const arb_poly_t f, slong n, slong prec) # Sets *res* respectively to the power series inverse tangent, # inverse sine and inverse cosine of *f*, truncated to length *n*. # Uses the formulas @@ -632,13 +632,13 @@ cdef extern from "flint_wrap.h": # The underscore methods supports aliasing of the input and output # arrays. They require that *flen* and *n* are greater than zero. - void _arb_poly_exp_series_basecase(arb_ptr f, arb_srcptr h, long hlen, long n, long prec) + void _arb_poly_exp_series_basecase(arb_ptr f, arb_srcptr h, slong hlen, slong n, slong prec) - void arb_poly_exp_series_basecase(arb_poly_t f, const arb_poly_t h, long n, long prec) + void arb_poly_exp_series_basecase(arb_poly_t f, const arb_poly_t h, slong n, slong prec) - void _arb_poly_exp_series(arb_ptr f, arb_srcptr h, long hlen, long n, long prec) + void _arb_poly_exp_series(arb_ptr f, arb_srcptr h, slong hlen, slong n, slong prec) - void arb_poly_exp_series(arb_poly_t f, const arb_poly_t h, long n, long prec) + void arb_poly_exp_series(arb_poly_t f, const arb_poly_t h, slong n, slong prec) # Sets `f` to the power series exponential of `h`, truncated to length `n`. # The basecase version uses a simple recurrence for the coefficients, # requiring `O(nm)` operations where `m` is the length of `h`. @@ -649,26 +649,26 @@ cdef extern from "flint_wrap.h": # The underscore methods support aliasing and allow the input to be # shorter than the output, but require the lengths to be nonzero. - void _arb_poly_sin_cos_series(arb_ptr s, arb_ptr c, arb_srcptr h, long hlen, long n, long prec) - void arb_poly_sin_cos_series(arb_poly_t s, arb_poly_t c, const arb_poly_t h, long n, long prec) + void _arb_poly_sin_cos_series(arb_ptr s, arb_ptr c, arb_srcptr h, slong hlen, slong n, slong prec) + void arb_poly_sin_cos_series(arb_poly_t s, arb_poly_t c, const arb_poly_t h, slong n, slong prec) # Sets *s* and *c* to the power series sine and cosine of *h*, computed # simultaneously. # The underscore method supports aliasing and requires the lengths to be nonzero. - void _arb_poly_sin_series(arb_ptr s, arb_srcptr h, long hlen, long n, long prec) + void _arb_poly_sin_series(arb_ptr s, arb_srcptr h, slong hlen, slong n, slong prec) - void arb_poly_sin_series(arb_poly_t s, const arb_poly_t h, long n, long prec) + void arb_poly_sin_series(arb_poly_t s, const arb_poly_t h, slong n, slong prec) - void _arb_poly_cos_series(arb_ptr c, arb_srcptr h, long hlen, long n, long prec) + void _arb_poly_cos_series(arb_ptr c, arb_srcptr h, slong hlen, slong n, slong prec) - void arb_poly_cos_series(arb_poly_t c, const arb_poly_t h, long n, long prec) + void arb_poly_cos_series(arb_poly_t c, const arb_poly_t h, slong n, slong prec) # Respectively evaluates the power series sine or cosine. These functions # simply wrap :func:`_arb_poly_sin_cos_series`. The underscore methods # support aliasing and require the lengths to be nonzero. - void _arb_poly_tan_series(arb_ptr g, arb_srcptr h, long hlen, long len, long prec) + void _arb_poly_tan_series(arb_ptr g, arb_srcptr h, slong hlen, slong len, slong prec) - void arb_poly_tan_series(arb_poly_t g, const arb_poly_t h, long n, long prec) + void arb_poly_tan_series(arb_poly_t g, const arb_poly_t h, slong n, slong prec) # Sets *g* to the power series tangent of *h*. # For small *n* takes the quotient of the sine and cosine as computed # using the basecase algorithm. For large *n*, uses Newton iteration @@ -676,83 +676,83 @@ cdef extern from "flint_wrap.h": # The underscore version does not support aliasing, and requires # the lengths to be nonzero. - void _arb_poly_sin_cos_pi_series(arb_ptr s, arb_ptr c, arb_srcptr h, long hlen, long n, long prec) + void _arb_poly_sin_cos_pi_series(arb_ptr s, arb_ptr c, arb_srcptr h, slong hlen, slong n, slong prec) - void arb_poly_sin_cos_pi_series(arb_poly_t s, arb_poly_t c, const arb_poly_t h, long n, long prec) + void arb_poly_sin_cos_pi_series(arb_poly_t s, arb_poly_t c, const arb_poly_t h, slong n, slong prec) - void _arb_poly_sin_pi_series(arb_ptr s, arb_srcptr h, long hlen, long n, long prec) + void _arb_poly_sin_pi_series(arb_ptr s, arb_srcptr h, slong hlen, slong n, slong prec) - void arb_poly_sin_pi_series(arb_poly_t s, const arb_poly_t h, long n, long prec) + void arb_poly_sin_pi_series(arb_poly_t s, const arb_poly_t h, slong n, slong prec) - void _arb_poly_cos_pi_series(arb_ptr c, arb_srcptr h, long hlen, long n, long prec) + void _arb_poly_cos_pi_series(arb_ptr c, arb_srcptr h, slong hlen, slong n, slong prec) - void arb_poly_cos_pi_series(arb_poly_t c, const arb_poly_t h, long n, long prec) + void arb_poly_cos_pi_series(arb_poly_t c, const arb_poly_t h, slong n, slong prec) - void _arb_poly_cot_pi_series(arb_ptr c, arb_srcptr h, long hlen, long n, long prec) + void _arb_poly_cot_pi_series(arb_ptr c, arb_srcptr h, slong hlen, slong n, slong prec) - void arb_poly_cot_pi_series(arb_poly_t c, const arb_poly_t h, long n, long prec) + void arb_poly_cot_pi_series(arb_poly_t c, const arb_poly_t h, slong n, slong prec) # Compute the respective trigonometric functions of the input # multiplied by `\pi`. - void _arb_poly_sinh_cosh_series_basecase(arb_ptr s, arb_ptr c, arb_srcptr h, long hlen, long n, long prec) + void _arb_poly_sinh_cosh_series_basecase(arb_ptr s, arb_ptr c, arb_srcptr h, slong hlen, slong n, slong prec) - void arb_poly_sinh_cosh_series_basecase(arb_poly_t s, arb_poly_t c, const arb_poly_t h, long n, long prec) + void arb_poly_sinh_cosh_series_basecase(arb_poly_t s, arb_poly_t c, const arb_poly_t h, slong n, slong prec) - void _arb_poly_sinh_cosh_series_exponential(arb_ptr s, arb_ptr c, arb_srcptr h, long hlen, long n, long prec) + void _arb_poly_sinh_cosh_series_exponential(arb_ptr s, arb_ptr c, arb_srcptr h, slong hlen, slong n, slong prec) - void arb_poly_sinh_cosh_series_exponential(arb_poly_t s, arb_poly_t c, const arb_poly_t h, long n, long prec) + void arb_poly_sinh_cosh_series_exponential(arb_poly_t s, arb_poly_t c, const arb_poly_t h, slong n, slong prec) - void _arb_poly_sinh_cosh_series(arb_ptr s, arb_ptr c, arb_srcptr h, long hlen, long n, long prec) + void _arb_poly_sinh_cosh_series(arb_ptr s, arb_ptr c, arb_srcptr h, slong hlen, slong n, slong prec) - void arb_poly_sinh_cosh_series(arb_poly_t s, arb_poly_t c, const arb_poly_t h, long n, long prec) + void arb_poly_sinh_cosh_series(arb_poly_t s, arb_poly_t c, const arb_poly_t h, slong n, slong prec) - void _arb_poly_sinh_series(arb_ptr s, arb_srcptr h, long hlen, long n, long prec) + void _arb_poly_sinh_series(arb_ptr s, arb_srcptr h, slong hlen, slong n, slong prec) - void arb_poly_sinh_series(arb_poly_t s, const arb_poly_t h, long n, long prec) + void arb_poly_sinh_series(arb_poly_t s, const arb_poly_t h, slong n, slong prec) - void _arb_poly_cosh_series(arb_ptr c, arb_srcptr h, long hlen, long n, long prec) + void _arb_poly_cosh_series(arb_ptr c, arb_srcptr h, slong hlen, slong n, slong prec) - void arb_poly_cosh_series(arb_poly_t c, const arb_poly_t h, long n, long prec) + void arb_poly_cosh_series(arb_poly_t c, const arb_poly_t h, slong n, slong prec) # Sets *s* and *c* respectively to the hyperbolic sine and cosine of the # power series *h*, truncated to length *n*. # The implementations mirror those for sine and cosine, except that # the *exponential* version computes both functions using the exponential # function instead of the hyperbolic tangent. - void _arb_poly_sinc_series(arb_ptr s, arb_srcptr h, long hlen, long n, long prec) + void _arb_poly_sinc_series(arb_ptr s, arb_srcptr h, slong hlen, slong n, slong prec) - void arb_poly_sinc_series(arb_poly_t s, const arb_poly_t h, long n, long prec) + void arb_poly_sinc_series(arb_poly_t s, const arb_poly_t h, slong n, slong prec) # Sets *c* to the sinc function of the power series *h*, truncated # to length *n*. - void _arb_poly_sinc_pi_series(arb_ptr s, arb_srcptr h, long hlen, long n, long prec) + void _arb_poly_sinc_pi_series(arb_ptr s, arb_srcptr h, slong hlen, slong n, slong prec) - void arb_poly_sinc_pi_series(arb_poly_t s, const arb_poly_t h, long n, long prec) + void arb_poly_sinc_pi_series(arb_poly_t s, const arb_poly_t h, slong n, slong prec) # Compute the sinc function of the input multiplied by `\pi`. - void _arb_poly_lambertw_series(arb_ptr res, arb_srcptr z, long zlen, int flags, long len, long prec) + void _arb_poly_lambertw_series(arb_ptr res, arb_srcptr z, slong zlen, int flags, slong len, slong prec) - void arb_poly_lambertw_series(arb_poly_t res, const arb_poly_t z, int flags, long len, long prec) + void arb_poly_lambertw_series(arb_poly_t res, const arb_poly_t z, int flags, slong len, slong prec) # Sets *res* to the Lambert W function of the power series *z*. # If *flags* is 0, the principal branch is computed; if *flags* is 1, # the second real branch `W_{-1}(z)` is computed. # The underscore method allows aliasing, but assumes that the lengths are nonzero. - void _arb_poly_gamma_series(arb_ptr res, arb_srcptr h, long hlen, long n, long prec) + void _arb_poly_gamma_series(arb_ptr res, arb_srcptr h, slong hlen, slong n, slong prec) - void arb_poly_gamma_series(arb_poly_t res, const arb_poly_t h, long n, long prec) + void arb_poly_gamma_series(arb_poly_t res, const arb_poly_t h, slong n, slong prec) - void _arb_poly_rgamma_series(arb_ptr res, arb_srcptr h, long hlen, long n, long prec) + void _arb_poly_rgamma_series(arb_ptr res, arb_srcptr h, slong hlen, slong n, slong prec) - void arb_poly_rgamma_series(arb_poly_t res, const arb_poly_t h, long n, long prec) + void arb_poly_rgamma_series(arb_poly_t res, const arb_poly_t h, slong n, slong prec) - void _arb_poly_lgamma_series(arb_ptr res, arb_srcptr h, long hlen, long n, long prec) + void _arb_poly_lgamma_series(arb_ptr res, arb_srcptr h, slong hlen, slong n, slong prec) - void arb_poly_lgamma_series(arb_poly_t res, const arb_poly_t h, long n, long prec) + void arb_poly_lgamma_series(arb_poly_t res, const arb_poly_t h, slong n, slong prec) - void _arb_poly_digamma_series(arb_ptr res, arb_srcptr h, long hlen, long n, long prec) + void _arb_poly_digamma_series(arb_ptr res, arb_srcptr h, slong hlen, slong n, slong prec) - void arb_poly_digamma_series(arb_poly_t res, const arb_poly_t h, long n, long prec) + void arb_poly_digamma_series(arb_poly_t res, const arb_poly_t h, slong n, slong prec) # Sets *res* to the series expansion of `\Gamma(h(x))`, `1/\Gamma(h(x))`, # or `\log \Gamma(h(x))`, `\psi(h(x))`, truncated to length *n*. # These functions first generate the Taylor series at the constant @@ -763,14 +763,14 @@ cdef extern from "flint_wrap.h": # The underscore methods support aliasing of the input and output # arrays, and require that *hlen* and *n* are greater than zero. - void _arb_poly_rising_ui_series(arb_ptr res, arb_srcptr f, long flen, unsigned long r, long trunc, long prec) + void _arb_poly_rising_ui_series(arb_ptr res, arb_srcptr f, slong flen, ulong r, slong trunc, slong prec) - void arb_poly_rising_ui_series(arb_poly_t res, const arb_poly_t f, unsigned long r, long trunc, long prec) + void arb_poly_rising_ui_series(arb_poly_t res, const arb_poly_t f, ulong r, slong trunc, slong prec) # Sets *res* to the rising factorial `(f) (f+1) (f+2) \cdots (f+r-1)`, truncated # to length *trunc*. The underscore method assumes that *flen*, *r* and *trunc* # are at least 1, and does not support aliasing. Uses binary splitting. - void arb_poly_zeta_series(arb_poly_t res, const arb_poly_t s, const arb_t a, int deflate, long n, long prec) + void arb_poly_zeta_series(arb_poly_t res, const arb_poly_t s, const arb_t a, int deflate, slong n, slong prec) # Sets *res* to the Hurwitz zeta function `\zeta(s,a)` where `s` a power # series and `a` is a constant, truncated to length *n*. # To evaluate the usual Riemann zeta function, set `a = 1`. @@ -783,9 +783,9 @@ cdef extern from "flint_wrap.h": # If `a = 1`, this implementation uses the reflection formula if the midpoint # of the constant term of `s` is negative. - void _arb_poly_riemann_siegel_theta_series(arb_ptr res, arb_srcptr h, long hlen, long n, long prec) + void _arb_poly_riemann_siegel_theta_series(arb_ptr res, arb_srcptr h, slong hlen, slong n, slong prec) - void arb_poly_riemann_siegel_theta_series(arb_poly_t res, const arb_poly_t h, long n, long prec) + void arb_poly_riemann_siegel_theta_series(arb_poly_t res, const arb_poly_t h, slong n, slong prec) # Sets *res* to the series expansion of the Riemann-Siegel theta # function # .. math :: @@ -796,9 +796,9 @@ cdef extern from "flint_wrap.h": # and output arrays, and requires that the lengths are greater # than zero. - void _arb_poly_riemann_siegel_z_series(arb_ptr res, arb_srcptr h, long hlen, long n, long prec) + void _arb_poly_riemann_siegel_z_series(arb_ptr res, arb_srcptr h, slong hlen, slong n, slong prec) - void arb_poly_riemann_siegel_z_series(arb_poly_t res, const arb_poly_t h, long n, long prec) + void arb_poly_riemann_siegel_z_series(arb_poly_t res, const arb_poly_t h, slong n, slong prec) # Sets *res* to the series expansion of the Riemann-Siegel Z-function # .. math :: # Z(h) = e^{i\theta(h)} \zeta(1/2+ih). @@ -809,7 +809,7 @@ cdef extern from "flint_wrap.h": # and output arrays, and requires that the lengths are greater # than zero. - void _arb_poly_root_bound_fujiwara(mag_t bound, arb_srcptr poly, long len) + void _arb_poly_root_bound_fujiwara(mag_t bound, arb_srcptr poly, slong len) void arb_poly_root_bound_fujiwara(mag_t bound, arb_poly_t poly) # Sets *bound* to an upper bound for the magnitude of all the complex @@ -823,7 +823,7 @@ cdef extern from "flint_wrap.h": # \right\} # where `a_0, \ldots, a_n` are the coefficients of *poly*. - void _arb_poly_newton_convergence_factor(arf_t convergence_factor, arb_srcptr poly, long len, const arb_t convergence_interval, long prec) + void _arb_poly_newton_convergence_factor(arf_t convergence_factor, arb_srcptr poly, slong len, const arb_t convergence_interval, slong prec) # Given an interval `I` specified by *convergence_interval*, evaluates a bound # for `C = \sup_{t,u \in I} \frac{1}{2} |f''(t)| / |f'(u)|`, # where `f` is the polynomial defined by the coefficients *{poly, len}*. @@ -831,7 +831,7 @@ cdef extern from "flint_wrap.h": # If `f` has large coefficients, `I` must be extremely precise in order to # get a finite factor. - int _arb_poly_newton_step(arb_t xnew, arb_srcptr poly, long len, const arb_t x, const arb_t convergence_interval, const arf_t convergence_factor, long prec) + int _arb_poly_newton_step(arb_t xnew, arb_srcptr poly, slong len, const arb_t x, const arb_t convergence_interval, const arf_t convergence_factor, slong prec) # Performs a single step with Newton's method. # The input consists of the polynomial `f` specified by the coefficients # *{poly, len}*, an interval `x = [m-r, m+r]` known to contain a single root of `f`, @@ -849,7 +849,7 @@ cdef extern from "flint_wrap.h": # If either condition fails, we set *xnew* to `x` and return zero, # indicating that no progress was made. - void _arb_poly_newton_refine_root(arb_t r, arb_srcptr poly, long len, const arb_t start, const arb_t convergence_interval, const arf_t convergence_factor, long eval_extra_prec, long prec) + void _arb_poly_newton_refine_root(arb_t r, arb_srcptr poly, slong len, const arb_t start, const arb_t convergence_interval, const arf_t convergence_factor, slong eval_extra_prec, slong prec) # Refines a precise estimate of a polynomial root to high precision # by performing several Newton steps, using nearly optimally # chosen doubling precision steps. @@ -860,9 +860,9 @@ cdef extern from "flint_wrap.h": # (typically, if the polynomial has large coefficients of alternating # signs, this needs to be approximately the bit size of the coefficients). - void _arb_poly_swinnerton_dyer_ui(arb_ptr poly, unsigned long n, long trunc, long prec) + void _arb_poly_swinnerton_dyer_ui(arb_ptr poly, ulong n, slong trunc, slong prec) - void arb_poly_swinnerton_dyer_ui(arb_poly_t poly, unsigned long n, long prec) + void arb_poly_swinnerton_dyer_ui(arb_poly_t poly, ulong n, slong prec) # Computes the Swinnerton-Dyer polynomial `S_n`, which has degree `2^n` # and is the rational minimal polynomial of the sum # of the square roots of the first *n* prime numbers. diff --git a/src/sage/libs/flint/arf.pxd b/src/sage/libs/flint/arf.pxd index 738039a94ef..89d4556442e 100644 --- a/src/sage/libs/flint/arf.pxd +++ b/src/sage/libs/flint/arf.pxd @@ -18,7 +18,7 @@ cdef extern from "flint_wrap.h": void arf_clear(arf_t x) # Clears the variable *x*, freeing or recycling its allocated memory. - long arf_allocated_bytes(const arf_t x) + slong arf_allocated_bytes(const arf_t x) # Returns the total number of bytes heap-allocated internally by this object. # The count excludes the size of the structure itself. Add # ``sizeof(arf_struct)`` to get the size of the object as a whole. @@ -69,9 +69,9 @@ cdef extern from "flint_wrap.h": void arf_set_fmpz(arf_t res, const fmpz_t x) - void arf_set_ui(arf_t res, unsigned long x) + void arf_set_ui(arf_t res, ulong x) - void arf_set_si(arf_t res, long x) + void arf_set_si(arf_t res, slong x) void arf_set_mpfr(arf_t res, const mpfr_t x) @@ -81,31 +81,31 @@ cdef extern from "flint_wrap.h": void arf_swap(arf_t x, arf_t y) # Swaps *x* and *y* efficiently. - void arf_init_set_ui(arf_t res, unsigned long x) + void arf_init_set_ui(arf_t res, ulong x) - void arf_init_set_si(arf_t res, long x) + void arf_init_set_si(arf_t res, slong x) # Initializes *res* and sets it to *x* in a single operation. - int arf_set_round(arf_t res, const arf_t x, long prec, arf_rnd_t rnd) + int arf_set_round(arf_t res, const arf_t x, slong prec, arf_rnd_t rnd) - int arf_set_round_si(arf_t res, long x, long prec, arf_rnd_t rnd) + int arf_set_round_si(arf_t res, slong x, slong prec, arf_rnd_t rnd) - int arf_set_round_ui(arf_t res, unsigned long x, long prec, arf_rnd_t rnd) + int arf_set_round_ui(arf_t res, ulong x, slong prec, arf_rnd_t rnd) - int arf_set_round_mpz(arf_t res, const mpz_t x, long prec, arf_rnd_t rnd) + int arf_set_round_mpz(arf_t res, const mpz_t x, slong prec, arf_rnd_t rnd) - int arf_set_round_fmpz(arf_t res, const fmpz_t x, long prec, arf_rnd_t rnd) + int arf_set_round_fmpz(arf_t res, const fmpz_t x, slong prec, arf_rnd_t rnd) # Sets *res* to *x*, rounded to *prec* bits in the direction # specified by *rnd*. - void arf_set_si_2exp_si(arf_t res, long m, long e) + void arf_set_si_2exp_si(arf_t res, slong m, slong e) - void arf_set_ui_2exp_si(arf_t res, unsigned long m, long e) + void arf_set_ui_2exp_si(arf_t res, ulong m, slong e) void arf_set_fmpz_2exp(arf_t res, const fmpz_t m, const fmpz_t e) # Sets *res* to `m \cdot 2^e`. - int arf_set_round_fmpz_2exp(arf_t res, const fmpz_t x, const fmpz_t e, long prec, arf_rnd_t rnd) + int arf_set_round_fmpz_2exp(arf_t res, const fmpz_t x, const fmpz_t e, slong prec, arf_rnd_t rnd) # Sets *res* to `x \cdot 2^e`, rounded to *prec* bits in the direction # specified by *rnd*. @@ -149,7 +149,7 @@ cdef extern from "flint_wrap.h": # memory available on the machine, resulting in swapping. It is recommended # to check that *x* is within a reasonable range before calling this method. - long arf_get_si(const arf_t x, arf_rnd_t rnd) + slong arf_get_si(const arf_t x, arf_rnd_t rnd) # Returns *x* rounded to the nearest integer in the direction specified by # *rnd*. If *rnd* is *ARF_RND_NEAR*, rounds to the nearest even integer # in case of a tie. Aborts if *x* is infinite, NaN, or the value is @@ -157,7 +157,7 @@ cdef extern from "flint_wrap.h": int arf_get_fmpz_fixed_fmpz(fmpz_t res, const arf_t x, const fmpz_t e) - int arf_get_fmpz_fixed_si(fmpz_t res, const arf_t x, long e) + int arf_get_fmpz_fixed_si(fmpz_t res, const arf_t x, slong e) # Converts *x* to a mantissa with predetermined exponent, i.e. sets *res* to # an integer *y* such that `y \times 2^e \approx x`, truncating if necessary. # Returns 0 if exact and 1 if truncation occurred. @@ -177,8 +177,8 @@ cdef extern from "flint_wrap.h": # is so large that allocating memory for the result fails. int arf_equal(const arf_t x, const arf_t y) - int arf_equal_si(const arf_t x, long y) - int arf_equal_ui(const arf_t x, unsigned long y) + int arf_equal_si(const arf_t x, slong y) + int arf_equal_ui(const arf_t x, ulong y) int arf_equal_d(const arf_t x, double y) # Returns nonzero iff *x* and *y* are exactly equal. NaN is not # treated specially, i.e. NaN compares as equal to itself. @@ -187,9 +187,9 @@ cdef extern from "flint_wrap.h": int arf_cmp(const arf_t x, const arf_t y) - int arf_cmp_si(const arf_t x, long y) + int arf_cmp_si(const arf_t x, slong y) - int arf_cmp_ui(const arf_t x, unsigned long y) + int arf_cmp_ui(const arf_t x, ulong y) int arf_cmp_d(const arf_t x, double y) # Returns negative, zero, or positive, depending on whether *x* is @@ -198,16 +198,16 @@ cdef extern from "flint_wrap.h": int arf_cmpabs(const arf_t x, const arf_t y) - int arf_cmpabs_ui(const arf_t x, unsigned long y) + int arf_cmpabs_ui(const arf_t x, ulong y) int arf_cmpabs_d(const arf_t x, double y) int arf_cmpabs_mag(const arf_t x, const mag_t y) # Compares the absolute values of *x* and *y*. - int arf_cmp_2exp_si(const arf_t x, long e) + int arf_cmp_2exp_si(const arf_t x, slong e) - int arf_cmpabs_2exp_si(const arf_t x, long e) + int arf_cmpabs_2exp_si(const arf_t x, slong e) # Compares *x* (respectively its absolute value) with `2^e`. int arf_sgn(const arf_t x) @@ -219,7 +219,7 @@ cdef extern from "flint_wrap.h": void arf_max(arf_t res, const arf_t a, const arf_t b) # Sets *res* respectively to the minimum and the maximum of *a* and *b*. - long arf_bits(const arf_t x) + slong arf_bits(const arf_t x) # Returns the number of bits needed to represent the absolute value # of the mantissa of *x*, i.e. the minimum precision sufficient to represent # *x* exactly. Returns 0 if *x* is a special value. @@ -227,7 +227,7 @@ cdef extern from "flint_wrap.h": int arf_is_int(const arf_t x) # Returns nonzero iff *x* is integer-valued. - int arf_is_int_2exp_si(const arf_t x, long e) + int arf_is_int_2exp_si(const arf_t x, slong e) # Returns nonzero iff *x* equals `n 2^e` for some integer *n*. void arf_abs_bound_lt_2exp_fmpz(fmpz_t res, const arf_t x) @@ -238,7 +238,7 @@ cdef extern from "flint_wrap.h": # Sets *res* to the smallest integer *b* such that `|x| \le 2^b`. # If *x* is zero, infinity or NaN, the result is undefined. - long arf_abs_bound_lt_2exp_si(const arf_t x) + slong arf_abs_bound_lt_2exp_si(const arf_t x) # Returns the smallest integer *b* such that `|x| < 2^b`, clamping # the result to lie between -*ARF_PREC_EXACT* and *ARF_PREC_EXACT* # inclusive. If *x* is zero, -*ARF_PREC_EXACT* is returned, @@ -260,16 +260,16 @@ cdef extern from "flint_wrap.h": # Initializes *res* and sets it to an upper bound for *x*. # Assumes that the exponent of *res* is small (this function is unsafe). - void arf_mag_set_ulp(mag_t res, const arf_t x, long prec) + void arf_mag_set_ulp(mag_t res, const arf_t x, slong prec) # Sets *res* to the magnitude of the unit in the last place (ulp) of *x* # at precision *prec*. - void arf_mag_add_ulp(mag_t res, const mag_t x, const arf_t y, long prec) + void arf_mag_add_ulp(mag_t res, const mag_t x, const arf_t y, slong prec) # Sets *res* to an upper bound for the sum of *x* and the # magnitude of the unit in the last place (ulp) of *y* # at precision *prec*. - void arf_mag_fast_add_ulp(mag_t res, const mag_t x, const arf_t y, long prec) + void arf_mag_fast_add_ulp(mag_t res, const mag_t x, const arf_t y, slong prec) # Sets *res* to an upper bound for the sum of *x* and the # magnitude of the unit in the last place (ulp) of *y* # at precision *prec*. Assumes that all exponents are small. @@ -289,22 +289,22 @@ cdef extern from "flint_wrap.h": void arf_init_neg_mag_shallow(arf_t z, const mag_t x) # Initializes *z* shallowly to the negation of *x*. - void arf_randtest(arf_t res, flint_rand_t state, long bits, long mag_bits) + void arf_randtest(arf_t res, flint_rand_t state, slong bits, slong mag_bits) # Generates a finite random number whose mantissa has precision at most # *bits* and whose exponent has at most *mag_bits* bits. The # values are distributed non-uniformly: special bit patterns are generated # with high probability in order to allow the test code to exercise corner # cases. - void arf_randtest_not_zero(arf_t res, flint_rand_t state, long bits, long mag_bits) + void arf_randtest_not_zero(arf_t res, flint_rand_t state, slong bits, slong mag_bits) # Identical to :func:`arf_randtest`, except that zero is never produced # as an output. - void arf_randtest_special(arf_t res, flint_rand_t state, long bits, long mag_bits) + void arf_randtest_special(arf_t res, flint_rand_t state, slong bits, slong mag_bits) # Identical to :func:`arf_randtest`, except that the output occasionally # is set to an infinity or NaN. - void arf_urandom(arf_t res, flint_rand_t state, long bits, arf_rnd_t rnd) + void arf_urandom(arf_t res, flint_rand_t state, slong bits, arf_rnd_t rnd) # Sets *res* to a uniformly distributed random number in the interval # `[0, 1]`. The method uses rounding from integers to floats based on the # rounding mode *rnd*. @@ -315,18 +315,18 @@ cdef extern from "flint_wrap.h": void arf_print(const arf_t x) # Prints *x* as an integer mantissa and exponent. - void arf_printd(const arf_t x, long d) + void arf_printd(const arf_t x, slong d) # Prints *x* as a decimal floating-point number, rounding to *d* digits. # Rounding is faithful (at most 1 ulp error). - char * arf_get_str(const arf_t x, long d) + char * arf_get_str(const arf_t x, slong d) # Returns *x* as a decimal floating-point number, rounding to *d* digits. # Rounding is faithful (at most 1 ulp error). void arf_fprint(FILE * file, const arf_t x) # Prints *x* as an integer mantissa and exponent to the stream *file*. - void arf_fprintd(FILE * file, const arf_t y, long d) + void arf_fprintd(FILE * file, const arf_t y, slong d) # Prints *x* as a decimal floating-point number to the stream *file*, # rounding to *d* digits. # Rounding is faithful (at most 1 ulp error). @@ -358,76 +358,76 @@ cdef extern from "flint_wrap.h": void arf_neg(arf_t res, const arf_t x) # Sets *res* to `-x` exactly. - int arf_neg_round(arf_t res, const arf_t x, long prec, arf_rnd_t rnd) + int arf_neg_round(arf_t res, const arf_t x, slong prec, arf_rnd_t rnd) # Sets *res* to `-x`. - int arf_add(arf_t res, const arf_t x, const arf_t y, long prec, arf_rnd_t rnd) + int arf_add(arf_t res, const arf_t x, const arf_t y, slong prec, arf_rnd_t rnd) - int arf_add_si(arf_t res, const arf_t x, long y, long prec, arf_rnd_t rnd) + int arf_add_si(arf_t res, const arf_t x, slong y, slong prec, arf_rnd_t rnd) - int arf_add_ui(arf_t res, const arf_t x, unsigned long y, long prec, arf_rnd_t rnd) + int arf_add_ui(arf_t res, const arf_t x, ulong y, slong prec, arf_rnd_t rnd) - int arf_add_fmpz(arf_t res, const arf_t x, const fmpz_t y, long prec, arf_rnd_t rnd) + int arf_add_fmpz(arf_t res, const arf_t x, const fmpz_t y, slong prec, arf_rnd_t rnd) # Sets *res* to `x + y`. - int arf_add_fmpz_2exp(arf_t res, const arf_t x, const fmpz_t y, const fmpz_t e, long prec, arf_rnd_t rnd) + int arf_add_fmpz_2exp(arf_t res, const arf_t x, const fmpz_t y, const fmpz_t e, slong prec, arf_rnd_t rnd) # Sets *res* to `x + y 2^e`. - int arf_sub(arf_t res, const arf_t x, const arf_t y, long prec, arf_rnd_t rnd) + int arf_sub(arf_t res, const arf_t x, const arf_t y, slong prec, arf_rnd_t rnd) - int arf_sub_si(arf_t res, const arf_t x, long y, long prec, arf_rnd_t rnd) + int arf_sub_si(arf_t res, const arf_t x, slong y, slong prec, arf_rnd_t rnd) - int arf_sub_ui(arf_t res, const arf_t x, unsigned long y, long prec, arf_rnd_t rnd) + int arf_sub_ui(arf_t res, const arf_t x, ulong y, slong prec, arf_rnd_t rnd) - int arf_sub_fmpz(arf_t res, const arf_t x, const fmpz_t y, long prec, arf_rnd_t rnd) + int arf_sub_fmpz(arf_t res, const arf_t x, const fmpz_t y, slong prec, arf_rnd_t rnd) # Sets *res* to `x - y`. - void arf_mul_2exp_si(arf_t res, const arf_t x, long e) + void arf_mul_2exp_si(arf_t res, const arf_t x, slong e) void arf_mul_2exp_fmpz(arf_t res, const arf_t x, const fmpz_t e) # Sets *res* to `x 2^e` exactly. - int arf_mul(arf_t res, const arf_t x, const arf_t y, long prec, arf_rnd_t rnd) + int arf_mul(arf_t res, const arf_t x, const arf_t y, slong prec, arf_rnd_t rnd) - int arf_mul_ui(arf_t res, const arf_t x, unsigned long y, long prec, arf_rnd_t rnd) + int arf_mul_ui(arf_t res, const arf_t x, ulong y, slong prec, arf_rnd_t rnd) - int arf_mul_si(arf_t res, const arf_t x, long y, long prec, arf_rnd_t rnd) + int arf_mul_si(arf_t res, const arf_t x, slong y, slong prec, arf_rnd_t rnd) - int arf_mul_mpz(arf_t res, const arf_t x, const mpz_t y, long prec, arf_rnd_t rnd) + int arf_mul_mpz(arf_t res, const arf_t x, const mpz_t y, slong prec, arf_rnd_t rnd) - int arf_mul_fmpz(arf_t res, const arf_t x, const fmpz_t y, long prec, arf_rnd_t rnd) + int arf_mul_fmpz(arf_t res, const arf_t x, const fmpz_t y, slong prec, arf_rnd_t rnd) # Sets *res* to `x \cdot y`. - int arf_addmul(arf_t z, const arf_t x, const arf_t y, long prec, arf_rnd_t rnd) + int arf_addmul(arf_t z, const arf_t x, const arf_t y, slong prec, arf_rnd_t rnd) - int arf_addmul_ui(arf_t z, const arf_t x, unsigned long y, long prec, arf_rnd_t rnd) + int arf_addmul_ui(arf_t z, const arf_t x, ulong y, slong prec, arf_rnd_t rnd) - int arf_addmul_si(arf_t z, const arf_t x, long y, long prec, arf_rnd_t rnd) + int arf_addmul_si(arf_t z, const arf_t x, slong y, slong prec, arf_rnd_t rnd) - int arf_addmul_mpz(arf_t z, const arf_t x, const mpz_t y, long prec, arf_rnd_t rnd) + int arf_addmul_mpz(arf_t z, const arf_t x, const mpz_t y, slong prec, arf_rnd_t rnd) - int arf_addmul_fmpz(arf_t z, const arf_t x, const fmpz_t y, long prec, arf_rnd_t rnd) + int arf_addmul_fmpz(arf_t z, const arf_t x, const fmpz_t y, slong prec, arf_rnd_t rnd) # Performs a fused multiply-add `z = z + x \cdot y`, updating *z* in-place. - int arf_submul(arf_t z, const arf_t x, const arf_t y, long prec, arf_rnd_t rnd) + int arf_submul(arf_t z, const arf_t x, const arf_t y, slong prec, arf_rnd_t rnd) - int arf_submul_ui(arf_t z, const arf_t x, unsigned long y, long prec, arf_rnd_t rnd) + int arf_submul_ui(arf_t z, const arf_t x, ulong y, slong prec, arf_rnd_t rnd) - int arf_submul_si(arf_t z, const arf_t x, long y, long prec, arf_rnd_t rnd) + int arf_submul_si(arf_t z, const arf_t x, slong y, slong prec, arf_rnd_t rnd) - int arf_submul_mpz(arf_t z, const arf_t x, const mpz_t y, long prec, arf_rnd_t rnd) + int arf_submul_mpz(arf_t z, const arf_t x, const mpz_t y, slong prec, arf_rnd_t rnd) - int arf_submul_fmpz(arf_t z, const arf_t x, const fmpz_t y, long prec, arf_rnd_t rnd) + int arf_submul_fmpz(arf_t z, const arf_t x, const fmpz_t y, slong prec, arf_rnd_t rnd) # Performs a fused multiply-subtract `z = z - x \cdot y`, updating *z* in-place. - int arf_fma(arf_t res, const arf_t x, const arf_t y, const arf_t z, long prec, arf_rnd_t rnd) + int arf_fma(arf_t res, const arf_t x, const arf_t y, const arf_t z, slong prec, arf_rnd_t rnd) # Sets *res* to `x \cdot y + z`. This is equivalent to an *addmul* except # that *res* and *z* can be separate variables. - int arf_sosq(arf_t res, const arf_t x, const arf_t y, long prec, arf_rnd_t rnd) + int arf_sosq(arf_t res, const arf_t x, const arf_t y, slong prec, arf_rnd_t rnd) # Sets *res* to `x^2 + y^2`, rounded to *prec* bits in the direction specified by *rnd*. - int arf_sum(arf_t res, arf_srcptr terms, long len, long prec, arf_rnd_t rnd) + int arf_sum(arf_t res, arf_srcptr terms, slong len, slong prec, arf_rnd_t rnd) # Sets *res* to the sum of the array *terms* of length *len*, rounded to # *prec* bits in the direction specified by *rnd*. The sum is computed as if # done without any intermediate rounding error, with only a single rounding @@ -436,52 +436,52 @@ cdef extern from "flint_wrap.h": # the terms are far apart. Warning: this function is implemented naively, # and the running time is quadratic with respect to *len* in the worst case. - void arf_approx_dot(arf_t res, const arf_t initial, int subtract, arf_srcptr x, long xstep, arf_srcptr y, long ystep, long len, long prec, arf_rnd_t rnd) + void arf_approx_dot(arf_t res, const arf_t initial, int subtract, arf_srcptr x, slong xstep, arf_srcptr y, slong ystep, slong len, slong prec, arf_rnd_t rnd) # Computes an approximate dot product, with the same meaning of # the parameters as :func:`arb_dot`. # This operation is not correctly rounded: the final rounding is done # in the direction ``rnd`` but intermediate roundings are # implementation-defined. - int arf_div(arf_t res, const arf_t x, const arf_t y, long prec, arf_rnd_t rnd) + int arf_div(arf_t res, const arf_t x, const arf_t y, slong prec, arf_rnd_t rnd) - int arf_div_ui(arf_t res, const arf_t x, unsigned long y, long prec, arf_rnd_t rnd) + int arf_div_ui(arf_t res, const arf_t x, ulong y, slong prec, arf_rnd_t rnd) - int arf_ui_div(arf_t res, unsigned long x, const arf_t y, long prec, arf_rnd_t rnd) + int arf_ui_div(arf_t res, ulong x, const arf_t y, slong prec, arf_rnd_t rnd) - int arf_div_si(arf_t res, const arf_t x, long y, long prec, arf_rnd_t rnd) + int arf_div_si(arf_t res, const arf_t x, slong y, slong prec, arf_rnd_t rnd) - int arf_si_div(arf_t res, long x, const arf_t y, long prec, arf_rnd_t rnd) + int arf_si_div(arf_t res, slong x, const arf_t y, slong prec, arf_rnd_t rnd) - int arf_div_fmpz(arf_t res, const arf_t x, const fmpz_t y, long prec, arf_rnd_t rnd) + int arf_div_fmpz(arf_t res, const arf_t x, const fmpz_t y, slong prec, arf_rnd_t rnd) - int arf_fmpz_div(arf_t res, const fmpz_t x, const arf_t y, long prec, arf_rnd_t rnd) + int arf_fmpz_div(arf_t res, const fmpz_t x, const arf_t y, slong prec, arf_rnd_t rnd) - int arf_fmpz_div_fmpz(arf_t res, const fmpz_t x, const fmpz_t y, long prec, arf_rnd_t rnd) + int arf_fmpz_div_fmpz(arf_t res, const fmpz_t x, const fmpz_t y, slong prec, arf_rnd_t rnd) # Sets *res* to `x / y`, rounded to *prec* bits in the direction specified by *rnd*, # returning nonzero iff the operation is inexact. The result is NaN if *y* is zero. - int arf_sqrt(arf_t res, const arf_t x, long prec, arf_rnd_t rnd) + int arf_sqrt(arf_t res, const arf_t x, slong prec, arf_rnd_t rnd) - int arf_sqrt_ui(arf_t res, unsigned long x, long prec, arf_rnd_t rnd) + int arf_sqrt_ui(arf_t res, ulong x, slong prec, arf_rnd_t rnd) - int arf_sqrt_fmpz(arf_t res, const fmpz_t x, long prec, arf_rnd_t rnd) + int arf_sqrt_fmpz(arf_t res, const fmpz_t x, slong prec, arf_rnd_t rnd) # Sets *res* to `\sqrt{x}`. The result is NaN if *x* is negative. - int arf_rsqrt(arf_t res, const arf_t x, long prec, arf_rnd_t rnd) + int arf_rsqrt(arf_t res, const arf_t x, slong prec, arf_rnd_t rnd) # Sets *res* to `1/\sqrt{x}`. The result is NaN if *x* is # negative, and `+\infty` if *x* is zero. - int arf_root(arf_t res, const arf_t x, unsigned long k, long prec, arf_rnd_t rnd) + int arf_root(arf_t res, const arf_t x, ulong k, slong prec, arf_rnd_t rnd) # Sets *res* to `x^{1/k}`. The result is NaN if *x* is negative. # Warning: this function is a wrapper around the MPFR root function. # It gets slow and uses much memory for large *k*. # Consider working with :func:`arb_root_ui` for large *k* instead of using this # function directly. - 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, long prec, arf_rnd_t rnd) + 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, long 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) # Computes the complex product `e + fi = (a + bi)(c + di)`, rounding both # `e` and `f` correctly to *prec* bits in the direction specified by *rnd*. # The first bit in the return code indicates inexactness of `e`, and the @@ -493,12 +493,12 @@ cdef extern from "flint_wrap.h": # The *fallback* version is implemented naively, for testing purposes. # No squaring optimization is implemented. - int arf_complex_sqr(arf_t e, arf_t f, const arf_t a, const arf_t b, long 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) # Computes the complex square `e + fi = (a + bi)^2`. This function has # identical semantics to :func:`arf_complex_mul` (with `c = a, b = d`), # but is faster. - int _arf_get_integer_mpn(mp_ptr y, mp_srcptr xp, mp_size_t xn, long exp) + int _arf_get_integer_mpn(mp_ptr y, mp_srcptr xp, mp_size_t xn, slong exp) # Given a floating-point number *x* represented by *xn* limbs at *xp* # and an exponent *exp*, writes the integer part of *x* to # *y*, returning whether the result is inexact. @@ -507,7 +507,7 @@ cdef extern from "flint_wrap.h": # Assumes that ``xp[0]`` is nonzero and that the # top bit of ``xp[xn-1]`` is set. - int _arf_set_mpn_fixed(arf_t z, mp_srcptr xp, mp_size_t xn, mp_size_t fixn, int negative, long prec, arf_rnd_t rnd) + 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) # Sets *z* to the fixed-point number having *xn* total limbs and *fixn* # fractional limbs, negated if *negative* is set, rounding *z* to *prec* # bits in the direction *rnd* and returning whether the result is inexact. @@ -515,18 +515,18 @@ cdef extern from "flint_wrap.h": # that the bit shift would overflow an *slong*, but otherwise no # assumptions are made about the input. - int _arf_set_round_ui(arf_t z, unsigned long x, int sgnbit, long prec, arf_rnd_t rnd) + int _arf_set_round_ui(arf_t z, ulong x, int sgnbit, slong prec, arf_rnd_t rnd) # Sets *z* to the integer *x*, negated if *sgnbit* is 1, rounded to *prec* # bits in the direction specified by *rnd*. There are no assumptions on *x*. - int _arf_set_round_uiui(arf_t z, long * fix, mp_limb_t hi, mp_limb_t lo, int sgnbit, long 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) # Sets the mantissa of *z* to the two-limb mantissa given by *hi* and *lo*, # negated if *sgnbit* is 1, rounded to *prec* bits in the direction specified # by *rnd*. Requires that not both *hi* and *lo* are zero. # Writes the exponent shift to *fix* without writing the exponent of *z* # directly. - int _arf_set_round_mpn(arf_t z, long * exp_shift, mp_srcptr x, mp_size_t xn, int sgnbit, long 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) # Sets the mantissa of *z* to the mantissa given by the *xn* limbs in *x*, # negated if *sgnbit* is 1, rounded to *prec* bits in the direction # specified by *rnd*. Returns the inexact flag. Requires that *xn* is positive diff --git a/src/sage/libs/flint/arith.pxd b/src/sage/libs/flint/arith.pxd index f784056e447..120fc49f6bd 100644 --- a/src/sage/libs/flint/arith.pxd +++ b/src/sage/libs/flint/arith.pxd @@ -12,19 +12,19 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void arith_primorial(fmpz_t res, long n) + void arith_primorial(fmpz_t res, slong n) # Sets ``res`` to ``n`` primorial or `n \#`, the product of all prime # numbers less than or equal to `n`. - void _arith_harmonic_number(fmpz_t num, fmpz_t den, long n) - void arith_harmonic_number(fmpq_t x, long n) + void _arith_harmonic_number(fmpz_t num, fmpz_t den, slong n) + void arith_harmonic_number(fmpq_t x, slong n) # These are aliases for the functions in the fmpq module. - void arith_stirling_number_1u(fmpz_t s, unsigned long n, unsigned long k) + void arith_stirling_number_1u(fmpz_t s, ulong n, ulong k) - void arith_stirling_number_1(fmpz_t s, unsigned long n, unsigned long k) + void arith_stirling_number_1(fmpz_t s, ulong n, ulong k) - void arith_stirling_number_2(fmpz_t s, unsigned long n, unsigned long k) + void arith_stirling_number_2(fmpz_t s, ulong n, ulong k) # Sets `s` to `S(n,k)` where `S(n,k)` denotes an unsigned Stirling # number of the first kind `|S_1(n, k)|`, a signed Stirling number # of the first kind `S_1(n, k)`, or a Stirling number of the second @@ -41,21 +41,21 @@ cdef extern from "flint_wrap.h": # numbers efficiently. To compute a range of numbers, the vector or # matrix versions should generally be used. - void arith_stirling_number_1u_vec(fmpz * row, unsigned long n, long klen) + void arith_stirling_number_1u_vec(fmpz * row, ulong n, slong klen) - void arith_stirling_number_1_vec(fmpz * row, unsigned long n, long klen) + void arith_stirling_number_1_vec(fmpz * row, ulong n, slong klen) - void arith_stirling_number_2_vec(fmpz * row, unsigned long n, long klen) + void arith_stirling_number_2_vec(fmpz * row, ulong n, slong klen) # Computes the row of Stirling numbers # ``S(n,0), S(n,1), S(n,2), ..., S(n,klen-1)``. # To compute a full row, this function can be called with # ``klen = n+1``. It is assumed that ``klen`` is at most `n + 1`. - void arith_stirling_number_1u_vec_next(fmpz * row, const fmpz * prev, long n, long klen) + void arith_stirling_number_1u_vec_next(fmpz * row, const fmpz * prev, slong n, slong klen) - void arith_stirling_number_1_vec_next(fmpz * row, const fmpz * prev, long n, long klen) + void arith_stirling_number_1_vec_next(fmpz * row, const fmpz * prev, slong n, slong klen) - void arith_stirling_number_2_vec_next(fmpz * row, const fmpz * prev, long n, long klen) + void arith_stirling_number_2_vec_next(fmpz * row, const fmpz * prev, slong n, slong klen) # Given the vector ``prev`` containing a row of Stirling numbers # ``S(n-1,0), S(n-1,1), S(n-1,2), ..., S(n-1,klen-1)``, computes # and stores in the row argument @@ -83,9 +83,9 @@ cdef extern from "flint_wrap.h": # For any `n`, the `S_1` and `S_2` matrices thus obtained are # inverses of each other. - void arith_bell_number(fmpz_t b, unsigned long n) - void arith_bell_number_dobinski(fmpz_t res, unsigned long n) - void arith_bell_number_multi_mod(fmpz_t res, unsigned long n) + void arith_bell_number(fmpz_t b, ulong n) + void arith_bell_number_dobinski(fmpz_t res, ulong n) + void arith_bell_number_multi_mod(fmpz_t res, ulong n) # Sets `b` to the Bell number `B_n`, defined as the # number of partitions of a set with `n` members. Equivalently, # `B_n = \sum_{k=0}^n S_2(n,k)` where `S_2(n,k)` denotes a Stirling number @@ -104,9 +104,9 @@ cdef extern from "flint_wrap.h": # A bound for the number of needed primes is computed using # ``arith_bell_number_size``. - void arith_bell_number_vec(fmpz * b, long n) - void arith_bell_number_vec_recursive(fmpz * b, long n) - void arith_bell_number_vec_multi_mod(fmpz * b, long n) + void arith_bell_number_vec(fmpz * b, slong n) + void arith_bell_number_vec_recursive(fmpz * b, slong n) + void arith_bell_number_vec_multi_mod(fmpz * b, slong n) # Sets `b` to the vector of Bell numbers `B_0, B_1, \ldots, B_{n-1}` # inclusive. The ``recursive`` version uses the `O(n^3 \log n)` # triangular recurrence, while the ``multi_mod`` version implements @@ -114,7 +114,7 @@ cdef extern from "flint_wrap.h": # running in time `O(n^2 \log^{O(1)} n)`. The default version # chooses an algorithm automatically. - mp_limb_t arith_bell_number_nmod(unsigned long n, nmod_t mod) + mp_limb_t arith_bell_number_nmod(ulong n, nmod_t mod) # Computes the Bell number `B_n` modulo an integer given by ``mod``. # After handling special cases, we use the formula # .. math :: @@ -128,10 +128,10 @@ cdef extern from "flint_wrap.h": # calling ``arith_bell_number_nmod_vec`` and reading the last # coefficient. - void arith_bell_number_nmod_vec(mp_ptr b, long n, nmod_t mod) - void arith_bell_number_nmod_vec_recursive(mp_ptr b, long n, nmod_t mod) - void arith_bell_number_nmod_vec_ogf(mp_ptr b, long n, nmod_t mod) - int arith_bell_number_nmod_vec_series(mp_ptr b, long 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) # Sets `b` to the vector of Bell numbers `B_0, B_1, \ldots, B_{n-1}` # inclusive modulo an integer given by ``mod``. # The *recursive* version uses the `O(n^2)` triangular recurrence. @@ -146,36 +146,36 @@ cdef extern from "flint_wrap.h": # The default version of this function selects an algorithm # automatically. - double arith_bell_number_size(unsigned long n) + double arith_bell_number_size(ulong n) # Returns `b` such that `B_n < 2^{\lfloor b \rfloor}`. A previous # version of this function used the inequality # `B_n < \left(\frac{0.792n}{\log(n+1)}\right)^n` which is given # in [BerTas2010]_; we now use a slightly better bound # based on an asymptotic expansion. - void _arith_bernoulli_number(fmpz_t num, fmpz_t den, unsigned long n) + void _arith_bernoulli_number(fmpz_t num, fmpz_t den, ulong n) # Sets ``(num, den)`` to the reduced numerator and denominator # of the `n`-th Bernoulli number. - void arith_bernoulli_number(fmpq_t x, unsigned long n) + void arith_bernoulli_number(fmpq_t x, ulong n) # Sets ``x`` to the `n`-th Bernoulli number. This function is # equivalent to ``_arith_bernoulli_number`` apart from the output # being a single ``fmpq_t`` variable. - void _arith_bernoulli_number_vec(fmpz * num, fmpz * den, long n) + void _arith_bernoulli_number_vec(fmpz * num, fmpz * den, slong n) # Sets the elements of ``num`` and ``den`` to the reduced # numerators and denominators of the Bernoulli numbers # `B_0, B_1, B_2, \ldots, B_{n-1}` inclusive. This function automatically # chooses between the ``recursive``, ``zeta`` and ``multi_mod`` # algorithms according to the size of `n`. - void arith_bernoulli_number_vec(fmpq * x, long n) + void arith_bernoulli_number_vec(fmpq * x, slong n) # Sets the ``x`` to the vector of Bernoulli numbers # `B_0, B_1, B_2, \ldots, B_{n-1}` inclusive. This function is # equivalent to ``_arith_bernoulli_number_vec`` apart # from the output being a single ``fmpq`` vector. - void arith_bernoulli_number_denom(fmpz_t den, unsigned long n) + void arith_bernoulli_number_denom(fmpz_t den, ulong n) # Sets ``den`` to the reduced denominator of the `n`-th # Bernoulli number `B_n`. For even `n`, the denominator is computed # as the product of all primes `p` for which `p - 1` divides `n`; @@ -184,20 +184,20 @@ cdef extern from "flint_wrap.h": # `B_n = 0`). The initial sequence of values smaller than `2^{32}` are # looked up directly from a table. - double arith_bernoulli_number_size(unsigned long n) + double arith_bernoulli_number_size(ulong n) # Returns `b` such that `|B_n| < 2^{\lfloor b \rfloor}`, using the inequality # `|B_n| < \frac{4 n!}{(2\pi)^n}` and `n! \le (n+1)^{n+1} e^{-n}`. # No special treatment is given to odd `n`. Accuracy is not guaranteed # if `n > 10^{14}`. - void arith_bernoulli_polynomial(fmpq_poly_t poly, unsigned long n) + void arith_bernoulli_polynomial(fmpq_poly_t poly, ulong n) # Sets ``poly`` to the Bernoulli polynomial of degree `n`, # `B_n(x) = \sum_{k=0}^n \binom{n}{k} B_k x^{n-k}` where `B_k` # is a Bernoulli number. This function basically calls # ``arith_bernoulli_number_vec`` and then rescales the coefficients # efficiently. - void _arith_bernoulli_number_vec_recursive(fmpz * num, fmpz * den, long n) + void _arith_bernoulli_number_vec_recursive(fmpz * num, fmpz * den, slong n) # Sets the elements of ``num`` and ``den`` to the reduced # numerators and denominators of `B_0, B_1, B_2, \ldots, B_{n-1}` # inclusive. @@ -211,7 +211,7 @@ cdef extern from "flint_wrap.h": # as the primorial of `n + 1`. # %[1] https://en.wikipedia.org/w/index.php?title=Bernoulli_number&oldid=405938876 - void _arith_bernoulli_number_vec_multi_mod(fmpz * num, fmpz * den, long n) + void _arith_bernoulli_number_vec_multi_mod(fmpz * num, fmpz * den, slong n) # Sets the elements of ``num`` and ``den`` to the reduced # numerators and denominators of `B_0, B_1, B_2, \ldots, B_{n-1}` # inclusive. Uses the generating function @@ -225,10 +225,10 @@ cdef extern from "flint_wrap.h": # half of the time compared to the usual generating function `x/(e^x-1)` # since the odd terms vanish. - void arith_euler_number(fmpz_t res, unsigned long n) + void arith_euler_number(fmpz_t res, ulong n) # Sets ``res`` to the Euler number `E_n`. - void arith_euler_number_vec(fmpz * res, long n) + void arith_euler_number_vec(fmpz * res, slong n) # Computes the Euler numbers `E_0, E_1, \dotsc, E_{n-1}` for `n \geq 0` # and stores the result in ``res``, which must be an initialised # ``fmpz`` vector of sufficient size. @@ -238,13 +238,13 @@ cdef extern from "flint_wrap.h": # ``arith_euler_number_size``, and the final integer values are recovered # using balanced CRT reconstruction. - double arith_euler_number_size(unsigned long n) + double arith_euler_number_size(ulong n) # Returns `b` such that `|E_n| < 2^{\lfloor b \rfloor}`, using the inequality # ``|E_n| < \frac{2^{n+2} n!}{\pi^{n+1}}`` and `n! \le (n+1)^{n+1} e^{-n}`. # No special treatment is given to odd `n`. # Accuracy is not guaranteed if `n > 10^{14}`. - void arith_euler_polynomial(fmpq_poly_t poly, unsigned long n) + void arith_euler_polynomial(fmpq_poly_t poly, ulong n) # Sets ``poly`` to the Euler polynomial `E_n(x)`. Uses the formula # .. math :: # E_n(x) = \frac{2}{n+1}\left(B_{n+1}(x) - @@ -254,7 +254,7 @@ cdef extern from "flint_wrap.h": 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, unsigned long k, const fmpz_t n) + void arith_divisor_sigma(fmpz_t res, ulong k, const fmpz_t n) # These are aliases for the functions in the fmpz module. void arith_divisors(fmpz_poly_t res, const fmpz_t n) @@ -276,7 +276,7 @@ cdef extern from "flint_wrap.h": # could be accomplished using a lookup table or by calling # ``arith_ramanujan_tau_series()`` directly. - void arith_ramanujan_tau_series(fmpz_poly_t res, long n) + void arith_ramanujan_tau_series(fmpz_poly_t res, slong n) # Sets ``res`` to the polynomial with coefficients # `\tau(0),\tau(1), \dotsc, \tau(n-1)`, giving the initial `n` terms # in the series expansion of @@ -287,7 +287,7 @@ cdef extern from "flint_wrap.h": # which is evaluated using three squarings. The first squaring is done # directly since the polynomial is very sparse at this point. - void arith_landau_function_vec(fmpz * res, long len) + void arith_landau_function_vec(fmpz * res, slong len) # Computes the first ``len`` values of Landau's function `g(n)` # starting with `g(0)`. Landau's function gives the largest order # of an element of the symmetric group `S_n`. @@ -302,11 +302,11 @@ cdef extern from "flint_wrap.h": void arith_dedekind_sum(fmpq_t s, const fmpz_t h, const fmpz_t k) # These are aliases for the functions in the fmpq module. - void arith_number_of_partitions_vec(fmpz * res, long len) + void arith_number_of_partitions_vec(fmpz * res, slong len) # Computes first ``len`` values of the partition function `p(n)` # starting with `p(0)`. Uses inversion of Euler's pentagonal series. - void arith_number_of_partitions_nmod_vec(mp_ptr res, long len, nmod_t mod) + void arith_number_of_partitions_nmod_vec(mp_ptr res, slong len, nmod_t mod) # Computes first ``len`` values of the partition function `p(n)` # starting with `p(0)`, modulo the modulus defined by ``mod``. # Uses inversion of Euler's pentagonal series. @@ -328,7 +328,7 @@ cdef extern from "flint_wrap.h": # If `n` is larger, it can be pre-reduced modulo `k`, since `A_k(n)` # only depends on the value of `n \bmod k`. - void arith_number_of_partitions_mpfr(mpfr_t x, unsigned long n) + void arith_number_of_partitions_mpfr(mpfr_t x, ulong n) # Sets the pre-initialised MPFR variable `x` to the exact value of `p(n)`. # The value is computed using the Hardy-Ramanujan-Rademacher formula. # The precision of `x` will be changed to allow `p(n)` to be represented @@ -375,13 +375,13 @@ cdef extern from "flint_wrap.h": # which gets added to the main sum periodically, in order to avoid # costly updates of the full-precision result when `n` is large. - void arith_number_of_partitions(fmpz_t x, unsigned long n) + void arith_number_of_partitions(fmpz_t x, ulong n) # Sets `x` to `p(n)`, the number of ways that `n` can be written # as a sum of positive integers without regard to order. # This function uses a lookup table for `n < 128` (where `p(n) < 2^{32}`), # and otherwise calls ``arith_number_of_partitions_mpfr``. - void arith_sum_of_squares(fmpz_t r, unsigned long k, const fmpz_t n) + void arith_sum_of_squares(fmpz_t r, ulong k, const fmpz_t n) # Sets `r` to the number of ways `r_k(n)` in which `n` can be represented # as a sum of `k` squares. # If `k = 2` or `k = 4`, we write `r_k(n)` as a divisor sum. @@ -389,7 +389,7 @@ cdef extern from "flint_wrap.h": # expansion up to `O(x^{n+1})` and read off the last coefficient. # This is generally optimal. - void arith_sum_of_squares_vec(fmpz * r, unsigned long k, long n) + void arith_sum_of_squares_vec(fmpz * r, ulong k, slong n) # For `i = 0, 1, \ldots, n-1`, sets `r_i` to the number of # representations of `i` a sum of `k` squares, `r_k(i)`. # This effectively computes the `q`-expansion of `\vartheta_3(q)` diff --git a/src/sage/libs/flint/bernoulli.pxd b/src/sage/libs/flint/bernoulli.pxd index 0e59332afcb..f94efba16b4 100644 --- a/src/sage/libs/flint/bernoulli.pxd +++ b/src/sage/libs/flint/bernoulli.pxd @@ -12,7 +12,7 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void bernoulli_rev_init(bernoulli_rev_t it, unsigned long n) + void bernoulli_rev_init(bernoulli_rev_t it, ulong n) # Initializes the iterator *iter*. The first Bernoulli number to # be generated by calling :func:`bernoulli_rev_next` is `B_n`. # It is assumed that `n` is even. @@ -25,7 +25,7 @@ cdef extern from "flint_wrap.h": void bernoulli_rev_clear(bernoulli_rev_t it) # Frees all memory allocated internally by *iter*. - void bernoulli_fmpq_vec_no_cache(fmpq * res, unsigned long a, long num) + void bernoulli_fmpq_vec_no_cache(fmpq * res, ulong a, slong num) # Writes *num* consecutive Bernoulli numbers to *res* starting # with `B_a`. This function is not currently optimized for a small # count *num*. The entries are not read from or written @@ -36,13 +36,13 @@ cdef extern from "flint_wrap.h": # This function is a wrapper for the *rev* iterators. It can use # multiple threads internally. - void bernoulli_cache_compute(long n) + void bernoulli_cache_compute(slong n) # Makes sure that the Bernoulli numbers up to at least `B_{n-1}` are cached. # Calling :func:`flint_cleanup()` frees the cache. # The cache is extended by calling :func:`bernoulli_fmpq_vec_no_cache` # internally. - long bernoulli_bound_2exp_si(unsigned long n) + slong bernoulli_bound_2exp_si(ulong n) # Returns an integer `b` such that `|B_n| \le 2^b`. Uses a lookup table # for small `n`, and for larger `n` uses the inequality # `|B_n| < 4 n! / (2 \pi)^n < 4 (n+1)^{n+1} e^{-n} / (2 \pi)^n`. @@ -54,14 +54,14 @@ cdef extern from "flint_wrap.h": # comfortably compute `B_n` exactly. It aborts if `n` is so large that # internal overflow occurs. - unsigned long bernoulli_mod_p_harvey(unsigned long n, unsigned long p) + ulong bernoulli_mod_p_harvey(ulong n, ulong p) # Returns the `B_n` modulo the prime number *p*, computed using # Harvey's algorithm [Har2010]_. The running time is linear in *p*. # If *p* divides the numerator of `B_n`, *UWORD_MAX* is returned # as an error code. - void _bernoulli_fmpq_ui_zeta(fmpz_t num, fmpz_t den, unsigned long n) - void _bernoulli_fmpq_ui_multi_mod(fmpz_t num, fmpz_t den, unsigned long n, double alpha) + void _bernoulli_fmpq_ui_zeta(fmpz_t num, fmpz_t den, ulong n) + void _bernoulli_fmpq_ui_multi_mod(fmpz_t num, fmpz_t den, ulong n, double alpha) # Sets *num* and *den* to the reduced numerator and denominator # of the Bernoulli number `B_n`. # The *zeta* version computes the denominator `d` using the von Staudt-Clausen @@ -73,8 +73,8 @@ cdef extern from "flint_wrap.h": # 0 and 1 controlling the number of bits to compute by the multimodular # algorithm. If set to a negative number, a default value will be used. - void _bernoulli_fmpq_ui(fmpz_t num, fmpz_t den, unsigned long n) - void bernoulli_fmpq_ui(fmpq_t b, unsigned long n) + void _bernoulli_fmpq_ui(fmpz_t num, fmpz_t den, ulong n) + void bernoulli_fmpq_ui(fmpq_t b, ulong n) # Computes the Bernoulli number `B_n` as an exact fraction, for an # isolated integer `n`. This function reads `B_n` from the global cache # if the number is already cached, but does not automatically extend diff --git a/src/sage/libs/flint/bool_mat.pxd b/src/sage/libs/flint/bool_mat.pxd index e92d2b1fe3a..3d5b648e118 100644 --- a/src/sage/libs/flint/bool_mat.pxd +++ b/src/sage/libs/flint/bool_mat.pxd @@ -12,13 +12,13 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - int bool_mat_get_entry(const bool_mat_t mat, long i, long j) + int bool_mat_get_entry(const bool_mat_t mat, slong i, slong j) # Returns the entry of matrix *mat* at row *i* and column *j*. - void bool_mat_set_entry(bool_mat_t mat, long i, long j, int x) + void bool_mat_set_entry(bool_mat_t mat, slong i, slong j, int x) # Sets the entry of matrix *mat* at row *i* and column *j* to *x*. - void bool_mat_init(bool_mat_t mat, long r, long c) + void bool_mat_init(bool_mat_t mat, slong r, slong c) # Initializes the matrix, setting it to the zero matrix with *r* rows # and *c* columns. @@ -110,7 +110,7 @@ cdef extern from "flint_wrap.h": void bool_mat_sqr(bool_mat_t B, const bool_mat_t A) - void bool_mat_pow_ui(bool_mat_t B, const bool_mat_t A, unsigned long exp) + void bool_mat_pow_ui(bool_mat_t B, const bool_mat_t A, ulong exp) # Sets *B* to *A* raised to the power *exp*. # Requires that *A* is a square matrix. @@ -120,7 +120,7 @@ cdef extern from "flint_wrap.h": # The sum is in the boolean semiring, so this function returns nonzero iff # any entry on the diagonal of *mat* is nonzero. - long bool_mat_nilpotency_degree(const bool_mat_t A) + slong bool_mat_nilpotency_degree(const bool_mat_t A) # Returns the nilpotency degree of the `n \times n` matrix *A*. # It returns the smallest positive `k` such that `A^k = 0`. # If no such `k` exists then the function returns `-1` if `n` is positive, @@ -130,7 +130,7 @@ cdef extern from "flint_wrap.h": # Sets *B* to the transitive closure `\sum_{k=1}^\infty A^k`. # The matrix *A* is required to be square. - long bool_mat_get_strongly_connected_components(long * p, const bool_mat_t A) + slong bool_mat_get_strongly_connected_components(slong * p, const bool_mat_t A) # Partitions the `n` row and column indices of the `n \times n` matrix *A* # according to the strongly connected components (SCC) of the graph # for which *A* is the adjacency matrix. @@ -140,7 +140,7 @@ cdef extern from "flint_wrap.h": # The SCCs themselves can be considered as nodes in a directed acyclic # graph (DAG), and the SCCs are indexed in postorder with respect to that DAG. - long bool_mat_all_pairs_longest_walk(fmpz_mat_t B, const bool_mat_t A) + slong bool_mat_all_pairs_longest_walk(fmpz_mat_t B, const bool_mat_t A) # Sets `B_{ij}` to the length of the longest walk with endpoint vertices # `i` and `j` in the graph whose adjacency matrix is *A*. # The matrix *A* must be square. Empty walks with zero length diff --git a/src/sage/libs/flint/ca.pxd b/src/sage/libs/flint/ca.pxd index b01ad1a85c3..aa74c15459d 100644 --- a/src/sage/libs/flint/ca.pxd +++ b/src/sage/libs/flint/ca.pxd @@ -36,7 +36,7 @@ cdef extern from "flint_wrap.h": void ca_swap(ca_t x, ca_t y, ca_ctx_t ctx) # Efficiently swaps the variables *x* and *y*. - void ca_get_fexpr(fexpr_t res, const ca_t x, unsigned long flags, ca_ctx_t ctx) + void ca_get_fexpr(fexpr_t res, const ca_t x, ulong flags, ca_ctx_t ctx) # Sets *res* to a symbolic expression representing *x*. int ca_set_fexpr(ca_t res, const fexpr_t expr, ca_ctx_t ctx) @@ -57,7 +57,7 @@ cdef extern from "flint_wrap.h": # Prints *x* to a string which is returned. # The user should free this string by calling ``flint_free``. - void ca_printn(const ca_t x, long n, ca_ctx_t ctx) + void ca_printn(const ca_t x, slong n, ca_ctx_t ctx) # Prints an *n*-digit numerical representation of *x* to standard output. void ca_zero(ca_t res, ca_ctx_t ctx) @@ -104,8 +104,8 @@ cdef extern from "flint_wrap.h": void ca_set(ca_t res, const ca_t x, ca_ctx_t ctx) # Sets *res* to a copy of *x*. - void ca_set_si(ca_t res, long v, ca_ctx_t ctx) - void ca_set_ui(ca_t res, unsigned long v, ca_ctx_t ctx) + void ca_set_si(ca_t res, slong v, ca_ctx_t ctx) + void ca_set_ui(ca_t res, ulong v, ca_ctx_t ctx) void ca_set_fmpz(ca_t res, const fmpz_t v, ca_ctx_t ctx) void ca_set_fmpq(ca_t res, const fmpq_t v, ca_ctx_t ctx) # Sets *res* to the integer or rational number *v*. This creates a canonical @@ -163,11 +163,11 @@ cdef extern from "flint_wrap.h": # this checks if all extension numbers are manifestly algebraic # numbers (without doing any evaluation). - void ca_randtest_rational(ca_t res, flint_rand_t state, long bits, ca_ctx_t ctx) + void ca_randtest_rational(ca_t res, flint_rand_t state, slong bits, ca_ctx_t ctx) # Sets *res* to a random rational number with numerator and denominator # up to *bits* bits in size. - void ca_randtest(ca_t res, flint_rand_t state, long depth, long bits, ca_ctx_t ctx) + void ca_randtest(ca_t res, flint_rand_t state, slong depth, slong bits, ca_ctx_t ctx) # Sets *res* to a random number generated by evaluating a random expression. # The algorithm randomly selects between generating a "simple" number # (a random rational number or quadratic field element with coefficients @@ -176,10 +176,10 @@ cdef extern from "flint_wrap.h": # function to operands produced through recursive calls with # *depth* - 1. The output is guaranteed to be a number, not a special value. - void ca_randtest_special(ca_t res, flint_rand_t state, long depth, long bits, ca_ctx_t ctx) + void ca_randtest_special(ca_t res, flint_rand_t state, slong depth, slong bits, ca_ctx_t ctx) # Randomly generates either a special value or a number. - void ca_randtest_same_nf(ca_t res, flint_rand_t state, const ca_t x, long bits, long den_bits, ca_ctx_t ctx) + void ca_randtest_same_nf(ca_t res, flint_rand_t state, const ca_t x, slong bits, slong den_bits, ca_ctx_t ctx) # Sets *res* to a random element in the same number field as *x*, # with numerator coefficients up to *bits* in size and denominator # up to *den_bits* in size. This function requires that *x* is an @@ -205,7 +205,7 @@ cdef extern from "flint_wrap.h": # of the representations of *x* and *y*; the return value does not say # anything meaningful about the numbers represented by *x* and *y*. - unsigned long ca_hash_repr(const ca_t x, ca_ctx_t ctx) + ulong ca_hash_repr(const ca_t x, ca_ctx_t ctx) # Hashes the representation of *x*. int ca_is_unknown(const ca_t x, ca_ctx_t ctx) @@ -229,7 +229,7 @@ cdef extern from "flint_wrap.h": # Returns whether *x* is represented as an element of a univariate # algebraic number field `\mathbb{Q}(a)`. - int ca_is_cyclotomic_nf_elem(long * p, unsigned long * q, const ca_t x, ca_ctx_t ctx) + int ca_is_cyclotomic_nf_elem(slong * p, ulong * q, const ca_t x, ca_ctx_t ctx) # Returns whether *x* is represented as an element of a univariate # cyclotomic field, i.e. `\mathbb{Q}(a)` where *a* is a root of unity. # If *p* and *q* are not *NULL* and *x* is represented as an @@ -345,8 +345,8 @@ cdef extern from "flint_wrap.h": void ca_add_fmpq(ca_t res, const ca_t x, const fmpq_t y, ca_ctx_t ctx) void ca_add_fmpz(ca_t res, const ca_t x, const fmpz_t y, ca_ctx_t ctx) - void ca_add_ui(ca_t res, const ca_t x, unsigned long y, ca_ctx_t ctx) - void ca_add_si(ca_t res, const ca_t x, long y, ca_ctx_t ctx) + void ca_add_ui(ca_t res, const ca_t x, ulong y, ca_ctx_t ctx) + void ca_add_si(ca_t res, const ca_t x, slong y, ca_ctx_t ctx) void ca_add(ca_t res, const ca_t x, const ca_t y, ca_ctx_t ctx) # Sets *res* to the sum of *x* and *y*. For special values, the following # rules apply (`c \infty` denotes a signed infinity, `|c| = 1`): @@ -361,20 +361,20 @@ cdef extern from "flint_wrap.h": void ca_sub_fmpq(ca_t res, const ca_t x, const fmpq_t y, ca_ctx_t ctx) void ca_sub_fmpz(ca_t res, const ca_t x, const fmpz_t y, ca_ctx_t ctx) - void ca_sub_ui(ca_t res, const ca_t x, unsigned long y, ca_ctx_t ctx) - void ca_sub_si(ca_t res, const ca_t x, long y, ca_ctx_t ctx) + void ca_sub_ui(ca_t res, const ca_t x, ulong y, ca_ctx_t ctx) + void ca_sub_si(ca_t res, const ca_t x, slong y, ca_ctx_t ctx) void ca_fmpq_sub(ca_t res, const fmpq_t x, const ca_t y, ca_ctx_t ctx) void ca_fmpz_sub(ca_t res, const fmpz_t x, const ca_t y, ca_ctx_t ctx) - void ca_ui_sub(ca_t res, unsigned long x, const ca_t y, ca_ctx_t ctx) - void ca_si_sub(ca_t res, long x, const ca_t y, ca_ctx_t ctx) + void ca_ui_sub(ca_t res, ulong x, const ca_t y, ca_ctx_t ctx) + void ca_si_sub(ca_t res, slong x, const ca_t y, ca_ctx_t ctx) void ca_sub(ca_t res, const ca_t x, const ca_t y, ca_ctx_t ctx) # Sets *res* to the difference of *x* and *y*. # This is equivalent to computing `x + (-y)`. void ca_mul_fmpq(ca_t res, const ca_t x, const fmpq_t y, ca_ctx_t ctx) void ca_mul_fmpz(ca_t res, const ca_t x, const fmpz_t y, ca_ctx_t ctx) - void ca_mul_ui(ca_t res, const ca_t x, unsigned long y, ca_ctx_t ctx) - void ca_mul_si(ca_t res, const ca_t x, long y, ca_ctx_t ctx) + void ca_mul_ui(ca_t res, const ca_t x, ulong y, ca_ctx_t ctx) + void ca_mul_si(ca_t res, const ca_t x, slong y, ca_ctx_t ctx) void ca_mul(ca_t res, const ca_t x, const ca_t y, ca_ctx_t ctx) # Sets *res* to the product of *x* and *y*. For special values, the following # rules apply (`c \infty` denotes a signed infinity, `|c| = 1`): @@ -404,12 +404,12 @@ cdef extern from "flint_wrap.h": void ca_fmpq_div(ca_t res, const fmpq_t x, const ca_t y, ca_ctx_t ctx) void ca_fmpz_div(ca_t res, const fmpz_t x, const ca_t y, ca_ctx_t ctx) - void ca_ui_div(ca_t res, unsigned long x, const ca_t y, ca_ctx_t ctx) - void ca_si_div(ca_t res, long x, const ca_t y, ca_ctx_t ctx) + void ca_ui_div(ca_t res, ulong x, const ca_t y, ca_ctx_t ctx) + void ca_si_div(ca_t res, slong x, const ca_t y, ca_ctx_t ctx) void ca_div_fmpq(ca_t res, const ca_t x, const fmpq_t y, ca_ctx_t ctx) void ca_div_fmpz(ca_t res, const ca_t x, const fmpz_t y, ca_ctx_t ctx) - void ca_div_ui(ca_t res, const ca_t x, unsigned long y, ca_ctx_t ctx) - void ca_div_si(ca_t res, const ca_t x, long y, ca_ctx_t ctx) + void ca_div_ui(ca_t res, const ca_t x, ulong y, ca_ctx_t ctx) + void ca_div_si(ca_t res, const ca_t x, slong y, ca_ctx_t ctx) void ca_div(ca_t res, const ca_t x, const ca_t y, ca_ctx_t ctx) # Sets *res* to the quotient of *x* and *y*. This is equivalent # to computing `x \cdot (1 / y)`. For special values and division @@ -426,7 +426,7 @@ cdef extern from "flint_wrap.h": # In any other case involving special values, or if the specific case cannot # be distinguished, the result is *Unknown*. - void ca_dot(ca_t res, const ca_t initial, int subtract, ca_srcptr x, long xstep, ca_srcptr y, long ystep, long len, ca_ctx_t ctx) + void ca_dot(ca_t res, const ca_t initial, int subtract, ca_srcptr x, slong xstep, ca_srcptr y, slong ystep, slong len, ca_ctx_t ctx) # Computes the dot product of the vectors *x* and *y*, setting # *res* to `s + (-1)^{subtract} \sum_{i=0}^{len-1} x_i y_i`. # The initial term *s* is optional and can be @@ -464,13 +464,13 @@ cdef extern from "flint_wrap.h": void ca_pow_fmpq(ca_t res, const ca_t x, const fmpq_t y, ca_ctx_t ctx) void ca_pow_fmpz(ca_t res, const ca_t x, const fmpz_t y, ca_ctx_t ctx) - void ca_pow_ui(ca_t res, const ca_t x, unsigned long y, ca_ctx_t ctx) - void ca_pow_si(ca_t res, const ca_t x, long y, ca_ctx_t ctx) + void ca_pow_ui(ca_t res, const ca_t x, ulong y, ca_ctx_t ctx) + void ca_pow_si(ca_t res, const ca_t x, slong y, ca_ctx_t ctx) void ca_pow(ca_t res, const ca_t x, const ca_t y, ca_ctx_t ctx) # Sets *res* to *x* raised to the power *y*. # Handling of special values is not yet implemented. - void ca_pow_si_arithmetic(ca_t res, const ca_t x, long n, ca_ctx_t ctx) + void ca_pow_si_arithmetic(ca_t res, const ca_t x, slong n, ca_ctx_t ctx) # Sets *res* to *x* raised to the power *n*. Whereas :func:`ca_pow`, # :func:`ca_pow_si` etc. may create `x^n` as an extension number # if *n* is large, this function always perform the exponentiation @@ -478,7 +478,7 @@ cdef extern from "flint_wrap.h": void ca_sqrt_inert(ca_t res, const ca_t x, ca_ctx_t ctx) void ca_sqrt_nofactor(ca_t res, const ca_t x, ca_ctx_t ctx) - void ca_sqrt_factor(ca_t res, const ca_t x, unsigned long flags, ca_ctx_t ctx) + void ca_sqrt_factor(ca_t res, const ca_t x, ulong flags, ca_ctx_t ctx) void ca_sqrt(ca_t res, const ca_t x, ca_ctx_t ctx) # Sets *res* to the principal square root of *x*. # For special values, the following definitions apply: @@ -499,7 +499,7 @@ cdef extern from "flint_wrap.h": # may still perform other simplifications. It may in particular attempt to # simplify `\sqrt{x}` to a single element in `\overline{\mathbb{Q}}`. - void ca_sqrt_ui(ca_t res, unsigned long n, ca_ctx_t ctx) + void ca_sqrt_ui(ca_t res, ulong n, ca_ctx_t ctx) # Sets *res* to the principal square root of *n*. void ca_abs(ca_t res, const ca_t x, ca_ctx_t ctx) @@ -726,14 +726,14 @@ cdef extern from "flint_wrap.h": void ca_erfi(ca_t res, const ca_t x, ca_ctx_t ctx) # Sets *res* to the imaginary error function of *x*. - void ca_get_acb_raw(acb_t res, const ca_t x, long prec, ca_ctx_t ctx) + void ca_get_acb_raw(acb_t res, const ca_t x, slong prec, ca_ctx_t ctx) # Sets *res* to an enclosure of the numerical value of *x*. # A working precision of *prec* bits is used internally for the evaluation, # without adaptive refinement. # If *x* is any special value, *res* is set to *acb_indeterminate*. - void ca_get_acb(acb_t res, const ca_t x, long prec, ca_ctx_t ctx) - void ca_get_acb_accurate_parts(acb_t res, const ca_t x, long prec, ca_ctx_t ctx) + void ca_get_acb(acb_t res, const ca_t x, slong prec, ca_ctx_t ctx) + void ca_get_acb_accurate_parts(acb_t res, const ca_t x, slong prec, ca_ctx_t ctx) # Sets *res* to an enclosure of the numerical value of *x*. # The working precision is increased adaptively to try to ensure *prec* # accurate bits in the output. The *accurate_parts* version tries to ensure @@ -746,7 +746,7 @@ cdef extern from "flint_wrap.h": # double rounding); the user may call *acb_set_round* when rounding # is desired. - char * ca_get_decimal_str(const ca_t x, long digits, unsigned long flags, ca_ctx_t ctx) + char * ca_get_decimal_str(const ca_t x, slong digits, ulong flags, ca_ctx_t ctx) # Returns a decimal approximation of *x* with precision up to # *digits*. The output is guaranteed to be correct within 1 ulp # in the returned digits, but the number of returned digits may @@ -795,7 +795,7 @@ cdef extern from "flint_wrap.h": # Expands *fac* back to a single :type:`ca_t` by evaluating the powers # and multiplying out the result. - void ca_factor(ca_factor_t res, const ca_t x, unsigned long flags, ca_ctx_t ctx) + void ca_factor(ca_factor_t res, const ca_t x, ulong flags, ca_ctx_t ctx) # Sets *res* to a factorization of *x* # of the form `x = b_1^{e_1} b_2^{e_2} \cdots b_n^{e_n}`. # Requires that *x* is not a special value. diff --git a/src/sage/libs/flint/ca_ext.pxd b/src/sage/libs/flint/ca_ext.pxd index 7deb4e37de1..aab1a5cbdc3 100644 --- a/src/sage/libs/flint/ca_ext.pxd +++ b/src/sage/libs/flint/ca_ext.pxd @@ -27,7 +27,7 @@ cdef extern from "flint_wrap.h": # Initializes *res* and sets it to the bivariate function value `f(x, y)` # where *f* is defined by *func* (example: *func* = *CA_Pow* for `x^y`). - void ca_ext_init_fxn(ca_ext_t res, calcium_func_code func, ca_srcptr x, long nargs, ca_ctx_t ctx) + void ca_ext_init_fxn(ca_ext_t res, calcium_func_code func, ca_srcptr x, slong nargs, ca_ctx_t ctx) # Initializes *res* and sets it to the multivariate function value # `f(x_1, \ldots, x_n)` where *f* is defined by *func* and *n* is # given by *nargs*. @@ -38,16 +38,16 @@ cdef extern from "flint_wrap.h": void ca_ext_clear(ca_ext_t res, ca_ctx_t ctx) # Clears *res*. - long ca_ext_nargs(const ca_ext_t x, ca_ctx_t ctx) + slong ca_ext_nargs(const ca_ext_t x, ca_ctx_t ctx) # Returns the number of function arguments of *x*. # The return value is 0 for any algebraic constant and for any built-in # symbolic constant such as `\pi`. - void ca_ext_get_arg(ca_t res, const ca_ext_t x, long i, ca_ctx_t ctx) + void ca_ext_get_arg(ca_t res, const ca_ext_t x, slong i, ca_ctx_t ctx) # Sets *res* to argument *i* (indexed from zero) of *x*. # This calls *flint_abort* if *i* is out of range. - unsigned long ca_ext_hash(const ca_ext_t x, ca_ctx_t ctx) + ulong ca_ext_hash(const ca_ext_t x, ca_ctx_t ctx) # Returns a hash of the structural representation of *x*. int ca_ext_equal_repr(const ca_ext_t x, const ca_ext_t y, ca_ctx_t ctx) @@ -62,7 +62,7 @@ cdef extern from "flint_wrap.h": void ca_ext_print(const ca_ext_t x, ca_ctx_t ctx) # Prints a description of *x* to standard output. - void ca_ext_get_acb_raw(acb_t res, ca_ext_t x, long prec, ca_ctx_t ctx) + void ca_ext_get_acb_raw(acb_t res, ca_ext_t x, slong prec, ca_ctx_t ctx) # Sets *res* to an enclosure of the numerical value of *x*. # A working precision of *prec* bits is used for the evaluation, # without adaptive refinement. diff --git a/src/sage/libs/flint/ca_field.pxd b/src/sage/libs/flint/ca_field.pxd index 3ee7134d48c..ebc4cd3af46 100644 --- a/src/sage/libs/flint/ca_field.pxd +++ b/src/sage/libs/flint/ca_field.pxd @@ -32,13 +32,13 @@ cdef extern from "flint_wrap.h": # Initializes *K* to represent the field # `\mathbb{Q}(a,b)` where `a = f(x, y)`. - void ca_field_init_multi(ca_field_t K, long len, ca_ctx_t ctx) + void ca_field_init_multi(ca_field_t K, slong len, ca_ctx_t ctx) # Initializes *K* to represent a multivariate field # `\mathbb{Q}(a_1, \ldots, a_n)` in *n* # extension numbers. The extension numbers must subsequently be # assigned one by one using :func:`ca_field_set_ext`. - void ca_field_set_ext(ca_field_t K, long i, ca_ext_srcptr x_index, ca_ctx_t ctx) + void ca_field_set_ext(ca_field_t K, slong i, ca_ext_srcptr x_index, ca_ctx_t ctx) # Sets the extension number at position *i* (here indexed from 0) of *K* # to the generator of the field with index *x_index* in *ctx*. # (It is assumed that the generating field is a univariate field.) @@ -79,7 +79,7 @@ cdef extern from "flint_wrap.h": # This does not clear the individual extension # numbers, which are only held as references. - ca_field_ptr ca_field_cache_insert_ext(ca_field_cache_t cache, ca_ext_struct ** x, long len, ca_ctx_t ctx) + ca_field_ptr ca_field_cache_insert_ext(ca_field_cache_t cache, ca_ext_struct ** x, slong len, ca_ctx_t ctx) # Adds the field defined by the length-*len* list of extension numbers *x* # to *cache* without duplication. If such a field already exists in *cache*, # a pointer to that instance is returned. Otherwise, a field with diff --git a/src/sage/libs/flint/ca_mat.pxd b/src/sage/libs/flint/ca_mat.pxd index 807e612f59d..ee344c2e1f5 100644 --- a/src/sage/libs/flint/ca_mat.pxd +++ b/src/sage/libs/flint/ca_mat.pxd @@ -12,11 +12,11 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - ca_ptr ca_mat_entry_ptr(ca_mat_t mat, long i, long j) + ca_ptr ca_mat_entry_ptr(ca_mat_t mat, slong i, slong j) # Returns a pointer to the entry at row *i* and column *j*. # Equivalent to :macro:`ca_mat_entry` but implemented as a function. - void ca_mat_init(ca_mat_t mat, long r, long c, ca_ctx_t ctx) + void ca_mat_init(ca_mat_t mat, slong r, slong c, ca_ctx_t ctx) # Initializes the matrix, setting it to the zero matrix with *r* rows # and *c* columns. @@ -26,7 +26,7 @@ cdef extern from "flint_wrap.h": void ca_mat_swap(ca_mat_t mat1, ca_mat_t mat2, ca_ctx_t ctx) # Efficiently swaps *mat1* and *mat2*. - void ca_mat_window_init(ca_mat_t window, const ca_mat_t mat, long r1, long c1, long r2, long c2, ca_ctx_t ctx) + void ca_mat_window_init(ca_mat_t window, const ca_mat_t mat, slong r1, slong c1, slong r2, slong c2, ca_ctx_t ctx) # Initializes *window* to a window matrix into the submatrix of *mat* # starting at the corner at row *r1* and column *c1* (inclusive) and ending # at row *r2* and column *c2* (exclusive). @@ -50,14 +50,14 @@ cdef extern from "flint_wrap.h": # but may result in a different internal representation depending on the # settings of the context objects. - void ca_mat_randtest(ca_mat_t mat, flint_rand_t state, long depth, long bits, ca_ctx_t ctx) + void ca_mat_randtest(ca_mat_t mat, flint_rand_t state, slong depth, slong bits, ca_ctx_t ctx) # Sets *mat* to a random matrix with entries having complexity up to # *depth* and *bits* (see :func:`ca_randtest`). - void ca_mat_randtest_rational(ca_mat_t mat, flint_rand_t state, long bits, ca_ctx_t ctx) + void ca_mat_randtest_rational(ca_mat_t mat, flint_rand_t state, slong bits, ca_ctx_t ctx) # Sets *mat* to a random rational matrix with entries up to *bits* bits in size. - void ca_mat_randops(ca_mat_t mat, flint_rand_t state, long count, ca_ctx_t ctx) + void ca_mat_randops(ca_mat_t mat, flint_rand_t state, slong count, ca_ctx_t ctx) # Randomizes *mat* in-place by performing elementary row or column operations. # More precisely, at most count random additions or subtractions of distinct # rows and columns will be performed. This leaves the rank (and for square matrices, @@ -66,7 +66,7 @@ cdef extern from "flint_wrap.h": void ca_mat_print(const ca_mat_t mat, ca_ctx_t ctx) # Prints *mat* to standard output. The entries are printed on separate lines. - void ca_mat_printn(const ca_mat_t mat, long digits, ca_ctx_t ctx) + void ca_mat_printn(const ca_mat_t mat, slong digits, ca_ctx_t ctx) # Prints a decimal representation of *mat* with precision specified by *digits*. # The entries are comma-separated with square brackets and comma separation # for the rows. @@ -150,13 +150,13 @@ cdef extern from "flint_wrap.h": # or in `\mathbb{Q}`. # The default version chooses an algorithm automatically. - void ca_mat_mul_si(ca_mat_t B, const ca_mat_t A, long c, ca_ctx_t ctx) + void ca_mat_mul_si(ca_mat_t B, const ca_mat_t A, slong c, ca_ctx_t ctx) void ca_mat_mul_fmpz(ca_mat_t B, const ca_mat_t A, const fmpz_t c, ca_ctx_t ctx) void ca_mat_mul_fmpq(ca_mat_t B, const ca_mat_t A, const fmpq_t c, ca_ctx_t ctx) void ca_mat_mul_ca(ca_mat_t B, const ca_mat_t A, const ca_t c, ca_ctx_t ctx) # Sets *B* to *A* multiplied by the scalar *c*. - void ca_mat_div_si(ca_mat_t B, const ca_mat_t A, long c, ca_ctx_t ctx) + void ca_mat_div_si(ca_mat_t B, const ca_mat_t A, slong c, ca_ctx_t ctx) void ca_mat_div_fmpz(ca_mat_t B, const ca_mat_t A, const fmpz_t c, ca_ctx_t ctx) void ca_mat_div_fmpq(ca_mat_t B, const ca_mat_t A, const fmpq_t c, ca_ctx_t ctx) void ca_mat_div_ca(ca_mat_t B, const ca_mat_t A, const ca_t c, ca_ctx_t ctx) @@ -173,16 +173,16 @@ cdef extern from "flint_wrap.h": void ca_mat_sqr(ca_mat_t B, const ca_mat_t A, ca_ctx_t ctx) # Sets *B* to the square of *A*. - void ca_mat_pow_ui_binexp(ca_mat_t B, const ca_mat_t A, unsigned long exp, ca_ctx_t ctx) + void ca_mat_pow_ui_binexp(ca_mat_t B, const ca_mat_t A, ulong exp, ca_ctx_t ctx) # Sets *B* to *A* raised to the power *exp*, evaluated using # binary exponentiation. - void _ca_mat_ca_poly_evaluate(ca_mat_t res, ca_srcptr poly, long len, const ca_mat_t A, ca_ctx_t ctx) + void _ca_mat_ca_poly_evaluate(ca_mat_t res, ca_srcptr poly, slong len, const ca_mat_t A, ca_ctx_t ctx) void ca_mat_ca_poly_evaluate(ca_mat_t res, const ca_poly_t poly, const ca_mat_t A, ca_ctx_t ctx) # Sets *res* to `f(A)` where *f* is the polynomial given by *poly* # and *A* is a square matrix. Uses the Paterson-Stockmeyer algorithm. - truth_t ca_mat_find_pivot(long * pivot_row, ca_mat_t mat, long start_row, long end_row, long column, ca_ctx_t ctx) + truth_t ca_mat_find_pivot(slong * pivot_row, ca_mat_t mat, slong start_row, slong end_row, slong column, ca_ctx_t ctx) # Attempts to find a nonzero entry in *mat* with column index *column* # and row index between *start_row* (inclusive) and *end_row* (exclusive). # If the return value is ``T_TRUE``, such an element exists, @@ -194,9 +194,9 @@ cdef extern from "flint_wrap.h": # This function is destructive: any elements that are nontrivially # zero but can be certified zero will be overwritten by exact zeros. - int ca_mat_lu_classical(long * rank, long * P, ca_mat_t LU, const ca_mat_t A, int rank_check, ca_ctx_t ctx) - int ca_mat_lu_recursive(long * rank, long * P, ca_mat_t LU, const ca_mat_t A, int rank_check, ca_ctx_t ctx) - int ca_mat_lu(long * rank, long * P, ca_mat_t LU, const ca_mat_t A, int rank_check, ca_ctx_t ctx) + int ca_mat_lu_classical(slong * rank, slong * P, ca_mat_t LU, const ca_mat_t A, int rank_check, ca_ctx_t ctx) + int ca_mat_lu_recursive(slong * rank, slong * P, ca_mat_t LU, const ca_mat_t A, int rank_check, ca_ctx_t ctx) + int ca_mat_lu(slong * rank, slong * P, ca_mat_t LU, const ca_mat_t A, int rank_check, ca_ctx_t ctx) # Computes a generalized LU decomposition `A = PLU` of a given # matrix *A*, writing the rank of *A* to *rank*. # If *A* is a nonsingular square matrix, *LU* will be set to @@ -221,14 +221,14 @@ cdef extern from "flint_wrap.h": # The *recursive* version uses a block recursive algorithm # to take advantage of fast matrix multiplication. - int ca_mat_fflu(long * rank, long * P, ca_mat_t LU, ca_t den, const ca_mat_t A, int rank_check, ca_ctx_t ctx) + int ca_mat_fflu(slong * rank, slong * P, ca_mat_t LU, ca_t den, const ca_mat_t A, int rank_check, ca_ctx_t ctx) # Similar to :func:`ca_mat_lu`, but computes a fraction-free # LU decomposition using the Bareiss algorithm. # The denominator is written to *den*. # Note that despite being "fraction-free", this algorithm may # introduce fractions due to incomplete symbolic simplifications. - truth_t ca_mat_nonsingular_lu(long * P, ca_mat_t LU, const ca_mat_t A, ca_ctx_t ctx) + truth_t ca_mat_nonsingular_lu(slong * P, ca_mat_t LU, const ca_mat_t A, ca_ctx_t ctx) # Wrapper for :func:`ca_mat_lu`. # If *A* can be proved to be invertible/nonsingular, returns ``T_TRUE`` and sets *P* and *LU* to a LU decomposition `A = PLU`. # If *A* can be proved to be singular, returns ``T_FALSE``. @@ -237,7 +237,7 @@ cdef extern from "flint_wrap.h": # LU factorization is not completed and the values of # *P* and *LU* are arbitrary. - truth_t ca_mat_nonsingular_fflu(long * P, ca_mat_t LU, ca_t den, const ca_mat_t A, ca_ctx_t ctx) + truth_t ca_mat_nonsingular_fflu(slong * P, ca_mat_t LU, ca_t den, const ca_mat_t A, ca_ctx_t ctx) # Wrapper for :func:`ca_mat_fflu`. # Similar to :func:`ca_mat_nonsingular_lu`, but computes a fraction-free # LU decomposition using the Bareiss algorithm. @@ -276,20 +276,20 @@ cdef extern from "flint_wrap.h": # way to benefit from fast matrix multiplication. The default versions # choose an algorithm automatically. - void ca_mat_solve_fflu_precomp(ca_mat_t X, const long * perm, const ca_mat_t A, const ca_t den, const ca_mat_t B, ca_ctx_t ctx) - void ca_mat_solve_lu_precomp(ca_mat_t X, const long * P, const ca_mat_t LU, const ca_mat_t B, ca_ctx_t ctx) + void ca_mat_solve_fflu_precomp(ca_mat_t X, const slong * perm, const ca_mat_t A, const ca_t den, const ca_mat_t B, ca_ctx_t ctx) + void ca_mat_solve_lu_precomp(ca_mat_t X, const slong * P, const ca_mat_t LU, const ca_mat_t B, ca_ctx_t ctx) # Solves `AX = B` given the precomputed nonsingular LU decomposition `A = PLU` # or fraction-free LU decomposition with denominator *den*. # The matrices `X` and `B` are allowed to be aliased with each other, # but `X` is not allowed to be aliased with `LU`. - int ca_mat_rank(long * rank, const ca_mat_t A, ca_ctx_t ctx) + int ca_mat_rank(slong * rank, const ca_mat_t A, ca_ctx_t ctx) # Computes the rank of the matrix *A*. If successful, returns 1 and # writes the rank to ``rank``. If unsuccessful, returns 0. - int ca_mat_rref_fflu(long * rank, ca_mat_t R, const ca_mat_t A, ca_ctx_t ctx) - int ca_mat_rref_lu(long * rank, ca_mat_t R, const ca_mat_t A, ca_ctx_t ctx) - int ca_mat_rref(long * rank, ca_mat_t R, const ca_mat_t A, ca_ctx_t ctx) + int ca_mat_rref_fflu(slong * rank, ca_mat_t R, const ca_mat_t A, ca_ctx_t ctx) + int ca_mat_rref_lu(slong * rank, ca_mat_t R, const ca_mat_t A, ca_ctx_t ctx) + int ca_mat_rref(slong * rank, ca_mat_t R, const ca_mat_t A, ca_ctx_t ctx) # Computes the reduced row echelon form (rref) of a given matrix. # On success, sets *R* to the rref of *A*, writes the rank to # *rank*, and returns 1. On failure to certify the correct rank, @@ -372,7 +372,7 @@ cdef extern from "flint_wrap.h": # It returns 0 if the leading coefficient of *poly* cannot be # proved nonzero or if the size of the output matrix does not match. - int ca_mat_eigenvalues(ca_vec_t lmbda, unsigned long * exp, const ca_mat_t mat, ca_ctx_t ctx) + int ca_mat_eigenvalues(ca_vec_t lmbda, ulong * exp, const ca_mat_t mat, ca_ctx_t ctx) # Attempts to compute all complex eigenvalues of the given matrix *mat*. # On success, returns 1 and sets *lambda* to the distinct eigenvalues # with corresponding multiplicities in *exp*. @@ -391,7 +391,7 @@ cdef extern from "flint_wrap.h": # If the return value is not ``T_TRUE``, the values in *D* and *P* # are arbitrary. - int ca_mat_jordan_blocks(ca_vec_t lmbda, long * num_blocks, long * block_lambda, long * block_size, const ca_mat_t A, ca_ctx_t ctx) + int ca_mat_jordan_blocks(ca_vec_t lmbda, slong * num_blocks, slong * block_lambda, slong * block_size, const ca_mat_t A, ca_ctx_t ctx) # Computes the blocks of the Jordan canonical form of *A*. # On success, returns 1 and sets *lambda* to the unique eigenvalues # of *A*, sets *num_blocks* to the number of Jordan blocks, @@ -404,13 +404,13 @@ cdef extern from "flint_wrap.h": # The Jordan form is unique up to the ordering of blocks, which # is arbitrary. - void ca_mat_set_jordan_blocks(ca_mat_t mat, const ca_vec_t lmbda, long num_blocks, long * block_lambda, long * block_size, ca_ctx_t ctx) + void ca_mat_set_jordan_blocks(ca_mat_t mat, const ca_vec_t lmbda, slong num_blocks, slong * block_lambda, slong * block_size, ca_ctx_t ctx) # Sets *mat* to the concatenation of the Jordan blocks # given in *lambda*, *num_blocks*, *block_lambda* and *block_size*. # See :func:`ca_mat_jordan_blocks` for an explanation of these # variables. - int ca_mat_jordan_transformation(ca_mat_t mat, const ca_vec_t lmbda, long num_blocks, long * block_lambda, long * block_size, const ca_mat_t A, ca_ctx_t ctx) + int ca_mat_jordan_transformation(ca_mat_t mat, const ca_vec_t lmbda, slong num_blocks, slong * block_lambda, slong * block_size, const ca_mat_t A, ca_ctx_t ctx) # Given the precomputed Jordan block decomposition # (*lambda*, *num_blocks*, *block_lambda*, *block_size*) of the # square matrix *A*, computes the corresponding transformation diff --git a/src/sage/libs/flint/ca_poly.pxd b/src/sage/libs/flint/ca_poly.pxd index 1a0846bdea6..c775c35a4db 100644 --- a/src/sage/libs/flint/ca_poly.pxd +++ b/src/sage/libs/flint/ca_poly.pxd @@ -19,11 +19,11 @@ cdef extern from "flint_wrap.h": # Clears the polynomial, deallocating all coefficients and the # coefficient array. - void ca_poly_fit_length(ca_poly_t poly, long len, ca_ctx_t ctx) + void ca_poly_fit_length(ca_poly_t poly, slong len, ca_ctx_t ctx) # Makes sure that the coefficient array of the polynomial contains at # least *len* initialized coefficients. - void _ca_poly_set_length(ca_poly_t poly, long len, ca_ctx_t ctx) + void _ca_poly_set_length(ca_poly_t poly, slong len, ca_ctx_t ctx) # Directly changes the length of the polynomial, without allocating or # deallocating coefficients. The value should not exceed the allocation length. @@ -40,7 +40,7 @@ cdef extern from "flint_wrap.h": # Sets *poly* to the monomial *x*. void ca_poly_set_ca(ca_poly_t poly, const ca_t c, ca_ctx_t ctx) - void ca_poly_set_si(ca_poly_t poly, long c, ca_ctx_t ctx) + void ca_poly_set_si(ca_poly_t poly, slong c, ca_ctx_t ctx) # Sets *poly* to the constant polynomial *c*. void ca_poly_set(ca_poly_t res, const ca_poly_t src, ca_ctx_t ctx) @@ -48,7 +48,7 @@ cdef extern from "flint_wrap.h": void ca_poly_set_fmpq_poly(ca_poly_t res, const fmpq_poly_t src, ca_ctx_t ctx) # Sets *poly* the polynomial *src*. - void ca_poly_set_coeff_ca(ca_poly_t poly, long n, const ca_t x, ca_ctx_t ctx) + void ca_poly_set_coeff_ca(ca_poly_t poly, slong n, const ca_t x, ca_ctx_t ctx) # Sets the coefficient at position *n* in *poly* to *x*. void ca_poly_transfer(ca_poly_t res, ca_ctx_t res_ctx, const ca_poly_t src, ca_ctx_t src_ctx) @@ -58,17 +58,17 @@ cdef extern from "flint_wrap.h": # but may result in a different internal representation depending on the # settings of the context objects. - void ca_poly_randtest(ca_poly_t poly, flint_rand_t state, long len, long depth, long bits, ca_ctx_t ctx) + void ca_poly_randtest(ca_poly_t poly, flint_rand_t state, slong len, slong depth, slong bits, ca_ctx_t ctx) # Sets *poly* to a random polynomial of length up to *len* and with entries having complexity up to # *depth* and *bits* (see :func:`ca_randtest`). - void ca_poly_randtest_rational(ca_poly_t poly, flint_rand_t state, long len, long bits, ca_ctx_t ctx) + void ca_poly_randtest_rational(ca_poly_t poly, flint_rand_t state, slong len, slong bits, ca_ctx_t ctx) # Sets *poly* to a random rational polynomial of length up to *len* and with entries up to *bits* bits in size. void ca_poly_print(const ca_poly_t poly, ca_ctx_t ctx) # Prints *poly* to standard output. The coefficients are printed on separate lines. - void ca_poly_printn(const ca_poly_t poly, long digits, ca_ctx_t ctx) + void ca_poly_printn(const ca_poly_t poly, slong digits, ca_ctx_t ctx) # Prints a decimal representation of *poly* with precision specified by *digits*. # The coefficients are comma-separated and the whole list is enclosed in square brackets. @@ -85,14 +85,14 @@ cdef extern from "flint_wrap.h": # and returns 1. Returns 0 if the leading coefficient cannot be # certified to be nonzero, or if *poly* is the zero polynomial. - void _ca_poly_reverse(ca_ptr res, ca_srcptr poly, long len, long n, ca_ctx_t ctx) + void _ca_poly_reverse(ca_ptr res, ca_srcptr poly, slong len, slong n, ca_ctx_t ctx) - void ca_poly_reverse(ca_poly_t res, const ca_poly_t poly, long n, ca_ctx_t ctx) + void ca_poly_reverse(ca_poly_t res, const ca_poly_t poly, slong n, ca_ctx_t ctx) # Sets *res* to the reversal of *poly* considered as a polynomial # of length *n*, zero-padding if needed. The underscore method # assumes that *len* is positive and less than or equal to *n*. - truth_t _ca_poly_check_equal(ca_srcptr poly1, long len1, ca_srcptr poly2, long len2, ca_ctx_t ctx) + truth_t _ca_poly_check_equal(ca_srcptr poly1, slong len1, ca_srcptr poly2, slong len2, ca_ctx_t ctx) truth_t ca_poly_check_equal(const ca_poly_t poly1, const ca_poly_t poly2, ca_ctx_t ctx) # Checks if *poly1* and *poly2* represent the same polynomial. # The underscore method assumes that *len1* is at least as @@ -104,33 +104,33 @@ cdef extern from "flint_wrap.h": truth_t ca_poly_check_is_one(const ca_poly_t poly, ca_ctx_t ctx) # Checks if *poly* is the constant polynomial 1. - void _ca_poly_shift_left(ca_ptr res, ca_srcptr poly, long len, long n, ca_ctx_t ctx) - void ca_poly_shift_left(ca_poly_t res, const ca_poly_t poly, long n, ca_ctx_t ctx) + void _ca_poly_shift_left(ca_ptr res, ca_srcptr poly, slong len, slong n, ca_ctx_t ctx) + void ca_poly_shift_left(ca_poly_t res, const ca_poly_t poly, slong n, ca_ctx_t ctx) # Sets *res* to *poly* shifted *n* coefficients to the left; that is, # multiplied by `x^n`. - void _ca_poly_shift_right(ca_ptr res, ca_srcptr poly, long len, long n, ca_ctx_t ctx) - void ca_poly_shift_right(ca_poly_t res, const ca_poly_t poly, long n, ca_ctx_t ctx) + void _ca_poly_shift_right(ca_ptr res, ca_srcptr poly, slong len, slong n, ca_ctx_t ctx) + void ca_poly_shift_right(ca_poly_t res, const ca_poly_t poly, slong n, ca_ctx_t ctx) # Sets *res* to *poly* shifted *n* coefficients to the right; that is, # divided by `x^n`. void ca_poly_neg(ca_poly_t res, const ca_poly_t src, ca_ctx_t ctx) # Sets *res* to the negation of *src*. - void _ca_poly_add(ca_ptr res, ca_srcptr poly1, long len1, ca_srcptr poly2, long len2, ca_ctx_t ctx) + void _ca_poly_add(ca_ptr res, ca_srcptr poly1, slong len1, ca_srcptr poly2, slong len2, ca_ctx_t ctx) void ca_poly_add(ca_poly_t res, const ca_poly_t poly1, const ca_poly_t poly2, ca_ctx_t ctx) # Sets *res* to the sum of *poly1* and *poly2*. - void _ca_poly_sub(ca_ptr res, ca_srcptr poly1, long len1, ca_srcptr poly2, long len2, ca_ctx_t ctx) + void _ca_poly_sub(ca_ptr res, ca_srcptr poly1, slong len1, ca_srcptr poly2, slong len2, ca_ctx_t ctx) void ca_poly_sub(ca_poly_t res, const ca_poly_t poly1, const ca_poly_t poly2, ca_ctx_t ctx) # Sets *res* to the difference of *poly1* and *poly2*. - void _ca_poly_mul(ca_ptr res, ca_srcptr poly1, long len1, ca_srcptr poly2, long len2, ca_ctx_t ctx) + void _ca_poly_mul(ca_ptr res, ca_srcptr poly1, slong len1, ca_srcptr poly2, slong len2, ca_ctx_t ctx) void ca_poly_mul(ca_poly_t res, const ca_poly_t poly1, const ca_poly_t poly2, ca_ctx_t ctx) # Sets *res* to the product of *poly1* and *poly2*. - void _ca_poly_mullow(ca_ptr C, ca_srcptr poly1, long len1, ca_srcptr poly2, long len2, long n, ca_ctx_t ctx) - void ca_poly_mullow(ca_poly_t res, const ca_poly_t poly1, const ca_poly_t poly2, long n, ca_ctx_t ctx) + void _ca_poly_mullow(ca_ptr C, ca_srcptr poly1, slong len1, ca_srcptr poly2, slong len2, slong n, ca_ctx_t ctx) + void ca_poly_mullow(ca_poly_t res, const ca_poly_t poly1, const ca_poly_t poly2, slong n, ca_ctx_t ctx) # Sets *res* to the product of *poly1* and *poly2* truncated to length *n*. void ca_poly_mul_ca(ca_poly_t res, const ca_poly_t poly, const ca_t c, ca_ctx_t ctx) @@ -139,9 +139,9 @@ cdef extern from "flint_wrap.h": void ca_poly_div_ca(ca_poly_t res, const ca_poly_t poly, const ca_t c, ca_ctx_t ctx) # Sets *res* to *poly* divided by the scalar *c*. - void _ca_poly_divrem_basecase(ca_ptr Q, ca_ptr R, ca_srcptr A, long lenA, ca_srcptr B, long lenB, const ca_t invB, ca_ctx_t ctx) + void _ca_poly_divrem_basecase(ca_ptr Q, ca_ptr R, ca_srcptr A, slong lenA, ca_srcptr B, slong lenB, const ca_t invB, ca_ctx_t ctx) int ca_poly_divrem_basecase(ca_poly_t Q, ca_poly_t R, const ca_poly_t A, const ca_poly_t B, ca_ctx_t ctx) - void _ca_poly_divrem(ca_ptr Q, ca_ptr R, ca_srcptr A, long lenA, ca_srcptr B, long lenB, const ca_t invB, ca_ctx_t ctx) + void _ca_poly_divrem(ca_ptr Q, ca_ptr R, ca_srcptr A, slong lenA, ca_srcptr B, slong lenB, const ca_t invB, ca_ctx_t ctx) int ca_poly_divrem(ca_poly_t Q, ca_poly_t R, const ca_poly_t A, const ca_poly_t B, ca_ctx_t ctx) int ca_poly_div(ca_poly_t Q, const ca_poly_t A, const ca_poly_t B, ca_ctx_t ctx) int ca_poly_rem(ca_poly_t R, const ca_poly_t A, const ca_poly_t B, ca_ctx_t ctx) @@ -151,60 +151,60 @@ cdef extern from "flint_wrap.h": # invertible, returns 0. # The underscore method takes a precomputed inverse of the leading coefficient of *B*. - void _ca_poly_pow_ui_trunc(ca_ptr res, ca_srcptr f, long flen, unsigned long exp, long len, ca_ctx_t ctx) - void ca_poly_pow_ui_trunc(ca_poly_t res, const ca_poly_t poly, unsigned long exp, long len, ca_ctx_t ctx) + void _ca_poly_pow_ui_trunc(ca_ptr res, ca_srcptr f, slong flen, ulong exp, slong len, ca_ctx_t ctx) + void ca_poly_pow_ui_trunc(ca_poly_t res, const ca_poly_t poly, ulong exp, slong len, ca_ctx_t ctx) # Sets *res* to *poly* raised to the power *exp*, truncated to length *len*. - void _ca_poly_pow_ui(ca_ptr res, ca_srcptr f, long flen, unsigned long exp, ca_ctx_t ctx) - void ca_poly_pow_ui(ca_poly_t res, const ca_poly_t poly, unsigned long exp, ca_ctx_t ctx) + void _ca_poly_pow_ui(ca_ptr res, ca_srcptr f, slong flen, ulong exp, ca_ctx_t ctx) + void ca_poly_pow_ui(ca_poly_t res, const ca_poly_t poly, ulong exp, ca_ctx_t ctx) # Sets *res* to *poly* raised to the power *exp*. - void _ca_poly_evaluate_horner(ca_t res, ca_srcptr f, long len, const ca_t x, ca_ctx_t ctx) + void _ca_poly_evaluate_horner(ca_t res, ca_srcptr f, slong len, const ca_t x, ca_ctx_t ctx) void ca_poly_evaluate_horner(ca_t res, const ca_poly_t f, const ca_t a, ca_ctx_t ctx) - void _ca_poly_evaluate(ca_t res, ca_srcptr f, long len, const ca_t x, ca_ctx_t ctx) + void _ca_poly_evaluate(ca_t res, ca_srcptr f, slong len, const ca_t x, ca_ctx_t ctx) void ca_poly_evaluate(ca_t res, const ca_poly_t f, const ca_t a, ca_ctx_t ctx) # Sets *res* to *f* evaluated at the point *a*. - void _ca_poly_compose(ca_ptr res, ca_srcptr poly1, long len1, ca_srcptr poly2, long len2, ca_ctx_t ctx) + void _ca_poly_compose(ca_ptr res, ca_srcptr poly1, slong len1, ca_srcptr poly2, slong len2, ca_ctx_t ctx) void ca_poly_compose(ca_poly_t res, const ca_poly_t poly1, const ca_poly_t poly2, ca_ctx_t ctx) # Sets *res* to the composition of *poly1* with *poly2*. - void _ca_poly_derivative(ca_ptr res, ca_srcptr poly, long len, ca_ctx_t ctx) + void _ca_poly_derivative(ca_ptr res, ca_srcptr poly, slong len, ca_ctx_t ctx) void ca_poly_derivative(ca_poly_t res, const ca_poly_t poly, ca_ctx_t ctx) # Sets *res* to the derivative of *poly*. The underscore method needs one less # coefficient than *len* for the output array. - void _ca_poly_integral(ca_ptr res, ca_srcptr poly, long len, ca_ctx_t ctx) + void _ca_poly_integral(ca_ptr res, ca_srcptr poly, slong len, ca_ctx_t ctx) void ca_poly_integral(ca_poly_t res, const ca_poly_t poly, ca_ctx_t ctx) # Sets *res* to the integral of *poly*. The underscore method needs one more # coefficient than *len* for the output array. - void _ca_poly_inv_series(ca_ptr res, ca_srcptr f, long flen, long len, ca_ctx_t ctx) - void ca_poly_inv_series(ca_poly_t res, const ca_poly_t f, long len, ca_ctx_t ctx) + void _ca_poly_inv_series(ca_ptr res, ca_srcptr f, slong flen, slong len, ca_ctx_t ctx) + void ca_poly_inv_series(ca_poly_t res, const ca_poly_t f, slong len, ca_ctx_t ctx) # Sets *res* to the power series inverse of *f* truncated # to length *len*. - void _ca_poly_div_series(ca_ptr res, ca_srcptr f, long flen, ca_srcptr g, long glen, long len, ca_ctx_t ctx) - void ca_poly_div_series(ca_poly_t res, const ca_poly_t f, const ca_poly_t g, long len, ca_ctx_t ctx) + void _ca_poly_div_series(ca_ptr res, ca_srcptr f, slong flen, ca_srcptr g, slong glen, slong len, ca_ctx_t ctx) + void ca_poly_div_series(ca_poly_t res, const ca_poly_t f, const ca_poly_t g, slong len, ca_ctx_t ctx) # Sets *res* to the power series quotient of *f* and *g* truncated # to length *len*. # This function divides by zero if *g* has constant term zero; # the user should manually remove initial zeros when an # exact cancellation is required. - void _ca_poly_exp_series(ca_ptr res, ca_srcptr f, long flen, long len, ca_ctx_t ctx) - void ca_poly_exp_series(ca_poly_t res, const ca_poly_t f, long len, ca_ctx_t ctx) + void _ca_poly_exp_series(ca_ptr res, ca_srcptr f, slong flen, slong len, ca_ctx_t ctx) + void ca_poly_exp_series(ca_poly_t res, const ca_poly_t f, slong len, ca_ctx_t ctx) # Sets *res* to the power series exponential of *f* truncated # to length *len*. - void _ca_poly_log_series(ca_ptr res, ca_srcptr f, long flen, long len, ca_ctx_t ctx) - void ca_poly_log_series(ca_poly_t res, const ca_poly_t f, long len, ca_ctx_t ctx) + void _ca_poly_log_series(ca_ptr res, ca_srcptr f, slong flen, slong len, ca_ctx_t ctx) + void ca_poly_log_series(ca_poly_t res, const ca_poly_t f, slong len, ca_ctx_t ctx) # Sets *res* to the power series logarithm of *f* truncated # to length *len*. - long _ca_poly_gcd_euclidean(ca_ptr res, ca_srcptr A, long lenA, ca_srcptr B, long lenB, ca_ctx_t ctx) + slong _ca_poly_gcd_euclidean(ca_ptr res, ca_srcptr A, slong lenA, ca_srcptr B, slong lenB, ca_ctx_t ctx) int ca_poly_gcd_euclidean(ca_poly_t res, const ca_poly_t A, const ca_poly_t B, ca_ctx_t ctx) - long _ca_poly_gcd(ca_ptr res, ca_srcptr A, long lenA, ca_srcptr B, long lenB, ca_ctx_t ctx) + slong _ca_poly_gcd(ca_ptr res, ca_srcptr A, slong lenA, ca_srcptr B, slong lenB, ca_ctx_t ctx) int ca_poly_gcd(ca_poly_t res, const ca_poly_t A, const ca_poly_t g, ca_ctx_t ctx) # Sets *res* to the GCD of *A* and *B* and returns 1 on success. # On failure, returns 0 leaving the value of *res* arbitrary. @@ -220,7 +220,7 @@ cdef extern from "flint_wrap.h": # and otherwise falls back to an automatic choice # of algorithm (currently only the Euclidean algorithm). - int ca_poly_factor_squarefree(ca_t c, ca_poly_vec_t fac, unsigned long * exp, const ca_poly_t F, ca_ctx_t ctx) + int ca_poly_factor_squarefree(ca_t c, ca_poly_vec_t fac, ulong * exp, const ca_poly_t F, ca_ctx_t ctx) # Computes the squarefree factorization of *F*, giving a product # `F = c f_1 f_2^2 \ldots f_n^n` where all `f_i` with `f_i \ne 1` # are squarefree and pairwise coprime. The nontrivial factors @@ -233,8 +233,8 @@ cdef extern from "flint_wrap.h": # This algorithm can fail if GCD computation fails internally. # Returns 1 on success and 0 on failure. - void _ca_poly_set_roots(ca_ptr poly, ca_srcptr roots, const unsigned long * exp, long n, ca_ctx_t ctx) - void ca_poly_set_roots(ca_poly_t poly, ca_vec_t roots, const unsigned long * exp, ca_ctx_t ctx) + void _ca_poly_set_roots(ca_ptr poly, ca_srcptr roots, const ulong * exp, slong n, ca_ctx_t ctx) + void ca_poly_set_roots(ca_poly_t poly, ca_vec_t roots, const ulong * exp, ca_ctx_t ctx) # Sets *poly* to the monic polynomial with the *n* roots # given in the vector *roots*, with multiplicities given # in the vector *exp*. In other words, this constructs @@ -242,8 +242,8 @@ cdef extern from "flint_wrap.h": # `(x-r_0)^{e_0} (x-r_1)^{e_1} \cdots (x-r_{n-1})^{e_{n-1}}`. # Uses binary splitting. - int _ca_poly_roots(ca_ptr roots, ca_srcptr poly, long len, ca_ctx_t ctx) - int ca_poly_roots(ca_vec_t roots, unsigned long * exp, const ca_poly_t poly, ca_ctx_t ctx) + int _ca_poly_roots(ca_ptr roots, ca_srcptr poly, slong len, ca_ctx_t ctx) + int ca_poly_roots(ca_vec_t roots, ulong * exp, const ca_poly_t poly, ca_ctx_t ctx) # Attempts to compute all complex roots of the given polynomial *poly*. # On success, returns 1 and sets *roots* to a vector containing all # the distinct roots with corresponding multiplicities in *exp*. @@ -256,17 +256,17 @@ cdef extern from "flint_wrap.h": # The underscore method assumes that the polynomial is squarefree. # The non-underscore method performs a squarefree factorization. - ca_poly_struct * _ca_poly_vec_init(long len, ca_ctx_t ctx) - void ca_poly_vec_init(ca_poly_vec_t res, long len, ca_ctx_t ctx) + ca_poly_struct * _ca_poly_vec_init(slong len, ca_ctx_t ctx) + void ca_poly_vec_init(ca_poly_vec_t res, slong len, ca_ctx_t ctx) # Initializes a vector with *len* polynomials. - void _ca_poly_vec_fit_length(ca_poly_vec_t vec, long len, ca_ctx_t ctx) + void _ca_poly_vec_fit_length(ca_poly_vec_t vec, slong len, ca_ctx_t ctx) # Allocates space for *len* polynomials in *vec*. - void ca_poly_vec_set_length(ca_poly_vec_t vec, long len, ca_ctx_t ctx) + void ca_poly_vec_set_length(ca_poly_vec_t vec, slong len, ca_ctx_t ctx) # Resizes *vec* to length *len*, zero-extending if needed. - void _ca_poly_vec_clear(ca_poly_struct * vec, long len, ca_ctx_t ctx) + void _ca_poly_vec_clear(ca_poly_struct * vec, slong len, ca_ctx_t ctx) void ca_poly_vec_clear(ca_poly_vec_t vec, ca_ctx_t ctx) # Clears the vector *vec*. diff --git a/src/sage/libs/flint/ca_vec.pxd b/src/sage/libs/flint/ca_vec.pxd index 6f756b25f70..df6ac842539 100644 --- a/src/sage/libs/flint/ca_vec.pxd +++ b/src/sage/libs/flint/ca_vec.pxd @@ -12,102 +12,102 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - ca_ptr _ca_vec_init(long len, ca_ctx_t ctx) + ca_ptr _ca_vec_init(slong len, ca_ctx_t ctx) # Returns a pointer to an array of *len* coefficients # initialized to zero. - void ca_vec_init(ca_vec_t vec, long len, ca_ctx_t ctx) + void ca_vec_init(ca_vec_t vec, slong len, ca_ctx_t ctx) # Initializes *vec* to a length *len* vector. All entries # are set to zero. - void _ca_vec_clear(ca_ptr vec, long len, ca_ctx_t ctx) + void _ca_vec_clear(ca_ptr vec, slong len, ca_ctx_t ctx) # Clears all *len* entries in *vec* and frees the pointer # *vec* itself. void ca_vec_clear(ca_vec_t vec, ca_ctx_t ctx) # Clears the vector *vec*. - void _ca_vec_swap(ca_ptr vec1, ca_ptr vec2, long len, ca_ctx_t ctx) + void _ca_vec_swap(ca_ptr vec1, ca_ptr vec2, slong len, ca_ctx_t ctx) # Swaps the entries in *vec1* and *vec2* efficiently. void ca_vec_swap(ca_vec_t vec1, ca_vec_t vec2, ca_ctx_t ctx) # Swaps the vectors *vec1* and *vec2* efficiently. - long ca_vec_length(const ca_vec_t vec, ca_ctx_t ctx) + slong ca_vec_length(const ca_vec_t vec, ca_ctx_t ctx) # Returns the length of *vec*. - void _ca_vec_fit_length(ca_vec_t vec, long len, ca_ctx_t ctx) + void _ca_vec_fit_length(ca_vec_t vec, slong len, ca_ctx_t ctx) # Allocates space in *vec* for *len* elements. - void ca_vec_set_length(ca_vec_t vec, long len, ca_ctx_t ctx) + void ca_vec_set_length(ca_vec_t vec, slong len, ca_ctx_t ctx) # Sets the length of *vec* to *len*. # If *vec* is shorter on input, it will be zero-extended. # If *vec* is longer on input, it will be truncated. - void _ca_vec_set(ca_ptr res, ca_srcptr src, long len, ca_ctx_t ctx) + void _ca_vec_set(ca_ptr res, ca_srcptr src, slong len, ca_ctx_t ctx) # Sets *res* to a copy of *src* of length *len*. void ca_vec_set(ca_vec_t res, const ca_vec_t src, ca_ctx_t ctx) # Sets *res* to a copy of *src*. - void _ca_vec_zero(ca_ptr res, long len, ca_ctx_t ctx) + void _ca_vec_zero(ca_ptr res, slong len, ca_ctx_t ctx) # Sets the *len* entries in *res* to zeros. - void ca_vec_zero(ca_vec_t res, long len, ca_ctx_t ctx) + void ca_vec_zero(ca_vec_t res, slong len, ca_ctx_t ctx) # Sets *res* to the length *len* zero vector. void ca_vec_print(const ca_vec_t vec, ca_ctx_t ctx) # Prints *vec* to standard output. The coefficients are printed on separate lines. - void ca_vec_printn(const ca_vec_t poly, long digits, ca_ctx_t ctx) + void ca_vec_printn(const ca_vec_t poly, slong digits, ca_ctx_t ctx) # Prints a decimal representation of *vec* with precision specified by *digits*. # The coefficients are comma-separated and the whole list is enclosed in square brackets. void ca_vec_append(ca_vec_t vec, const ca_t f, ca_ctx_t ctx) # Appends *f* to the end of *vec*. - void _ca_vec_neg(ca_ptr res, ca_srcptr src, long len, ca_ctx_t ctx) + void _ca_vec_neg(ca_ptr res, ca_srcptr src, slong len, ca_ctx_t ctx) void ca_vec_neg(ca_vec_t res, const ca_vec_t src, ca_ctx_t ctx) # Sets *res* to the negation of *src*. - void _ca_vec_add(ca_ptr res, ca_srcptr vec1, ca_srcptr vec2, long len, ca_ctx_t ctx) + void _ca_vec_add(ca_ptr res, ca_srcptr vec1, ca_srcptr vec2, slong len, ca_ctx_t ctx) - void _ca_vec_sub(ca_ptr res, ca_srcptr vec1, ca_srcptr vec2, long len, ca_ctx_t ctx) + void _ca_vec_sub(ca_ptr res, ca_srcptr vec1, ca_srcptr vec2, slong len, ca_ctx_t ctx) # Sets *res* to the sum or difference of *vec1* and *vec2*, # all vectors having length *len*. - void _ca_vec_scalar_mul_ca(ca_ptr res, ca_srcptr src, long len, const ca_t c, ca_ctx_t ctx) + void _ca_vec_scalar_mul_ca(ca_ptr res, ca_srcptr src, slong len, const ca_t c, ca_ctx_t ctx) # Sets *res* to *src* multiplied by *c*, all vectors having # length *len*. - void _ca_vec_scalar_div_ca(ca_ptr res, ca_srcptr src, long len, const ca_t c, ca_ctx_t ctx) + void _ca_vec_scalar_div_ca(ca_ptr res, ca_srcptr src, slong len, const ca_t c, ca_ctx_t ctx) # Sets *res* to *src* divided by *c*, all vectors having # length *len*. - void _ca_vec_scalar_addmul_ca(ca_ptr res, ca_srcptr src, long len, const ca_t c, ca_ctx_t ctx) + void _ca_vec_scalar_addmul_ca(ca_ptr res, ca_srcptr src, slong len, const ca_t c, ca_ctx_t ctx) # Adds *src* multiplied by *c* to the vector *res*, all vectors having # length *len*. - void _ca_vec_scalar_submul_ca(ca_ptr res, ca_srcptr src, long len, const ca_t c, ca_ctx_t ctx) + void _ca_vec_scalar_submul_ca(ca_ptr res, ca_srcptr src, slong len, const ca_t c, ca_ctx_t ctx) # Subtracts *src* multiplied by *c* from the vector *res*, all vectors having # length *len*. - truth_t _ca_vec_check_is_zero(ca_srcptr vec, long len, ca_ctx_t ctx) + truth_t _ca_vec_check_is_zero(ca_srcptr vec, slong len, ca_ctx_t ctx) # Returns whether *vec* is the zero vector. - int _ca_vec_is_fmpq_vec(ca_srcptr vec, long len, ca_ctx_t ctx) + int _ca_vec_is_fmpq_vec(ca_srcptr vec, slong len, ca_ctx_t ctx) # Checks if all elements of *vec* are structurally rational numbers. - int _ca_vec_fmpq_vec_is_fmpz_vec(ca_srcptr vec, long len, ca_ctx_t ctx) + int _ca_vec_fmpq_vec_is_fmpz_vec(ca_srcptr vec, slong len, ca_ctx_t ctx) # Assuming that all elements of *vec* are structurally rational numbers, # checks if all elements are integers. - void _ca_vec_fmpq_vec_get_fmpz_vec_den(fmpz * c, fmpz_t den, ca_srcptr vec, long len, ca_ctx_t ctx) + void _ca_vec_fmpq_vec_get_fmpz_vec_den(fmpz * c, fmpz_t den, ca_srcptr vec, slong len, ca_ctx_t ctx) # Assuming that all elements of *vec* are structurally rational numbers, # converts them to a vector of integers *c* on a common denominator # *den*. - void _ca_vec_set_fmpz_vec_div_fmpz(ca_ptr res, const fmpz * v, const fmpz_t den, long len, ca_ctx_t ctx) + void _ca_vec_set_fmpz_vec_div_fmpz(ca_ptr res, const fmpz * v, const fmpz_t den, slong len, ca_ctx_t ctx) # Sets *res* to the rational vector given by numerators *v* # and the common denominator *den*. diff --git a/src/sage/libs/flint/calcium.pxd b/src/sage/libs/flint/calcium.pxd index 8a0f33a978a..c5fd495c28b 100644 --- a/src/sage/libs/flint/calcium.pxd +++ b/src/sage/libs/flint/calcium.pxd @@ -15,7 +15,7 @@ cdef extern from "flint_wrap.h": const char * calcium_version() # Returns a pointer to the version of the library as a string ``X.Y.Z``. - unsigned long calcium_fmpz_hash(const fmpz_t x) + ulong calcium_fmpz_hash(const fmpz_t x) # Hash function for integers. The algorithm may change; # presently, this simply extracts the low word (with sign). @@ -35,12 +35,12 @@ cdef extern from "flint_wrap.h": void calcium_write_free(calcium_stream_t out, char * s) # Writes *s* to *out* and then frees *s* by calling ``flint_free()``. - void calcium_write_si(calcium_stream_t out, long x) + void calcium_write_si(calcium_stream_t out, slong x) void calcium_write_fmpz(calcium_stream_t out, const fmpz_t x) # Writes the integer *x* to *out*. - void calcium_write_arb(calcium_stream_t out, const arb_t z, long digits, unsigned long flags) - void calcium_write_acb(calcium_stream_t out, const acb_t z, long digits, unsigned long flags) + void calcium_write_arb(calcium_stream_t out, const arb_t z, slong digits, ulong flags) + void calcium_write_acb(calcium_stream_t out, const acb_t z, slong digits, ulong flags) # Writes the Arb number *z* to *out*, showing *digits* # digits and with the display style specified by *flags* # (``ARB_STR_NO_RADIUS``, etc.). diff --git a/src/sage/libs/flint/d_mat.pxd b/src/sage/libs/flint/d_mat.pxd index 5cbabced9c2..a329b3d079b 100644 --- a/src/sage/libs/flint/d_mat.pxd +++ b/src/sage/libs/flint/d_mat.pxd @@ -12,7 +12,7 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void d_mat_init(d_mat_t mat, long rows, long cols) + void d_mat_init(d_mat_t mat, slong rows, slong cols) # Initialises a matrix with the given number of rows and columns for use. void d_mat_clear(d_mat_t mat) @@ -30,16 +30,16 @@ cdef extern from "flint_wrap.h": # Swaps two matrices by swapping the individual entries rather than swapping # the contents of the structs. - double d_mat_entry(d_mat_t mat, long i, long j) + double d_mat_entry(d_mat_t mat, slong i, slong j) # Returns the entry of ``mat`` at row `i` and column `j`. # Both `i` and `j` must not exceed the dimensions of the matrix. # This function is implemented as a macro. - double d_mat_get_entry(const d_mat_t mat, long i, long j) + double d_mat_get_entry(const d_mat_t mat, slong i, slong j) # Returns the entry of ``mat`` at row `i` and column `j`. # Both `i` and `j` must not exceed the dimensions of the matrix. - double * d_mat_entry_ptr(const d_mat_t mat, long i, long j) + double * d_mat_entry_ptr(const d_mat_t mat, slong i, slong j) # Returns a pointer to the entry of ``mat`` at row `i` and column # `j`. Both `i` and `j` must not exceed the dimensions of the matrix. @@ -51,7 +51,7 @@ cdef extern from "flint_wrap.h": # and zeroes elsewhere. If ``mat`` is nonsquare, it is set to the # truncation of a unit matrix. - void d_mat_randtest(d_mat_t mat, flint_rand_t state, long minexp, long maxexp) + void d_mat_randtest(d_mat_t mat, flint_rand_t state, slong minexp, slong maxexp) # Sets the entries of ``mat`` to random signed numbers with exponents # between ``minexp`` and ``maxexp`` or zero. diff --git a/src/sage/libs/flint/d_vec.pxd b/src/sage/libs/flint/d_vec.pxd index c567d3d7907..bcd3ce07790 100644 --- a/src/sage/libs/flint/d_vec.pxd +++ b/src/sage/libs/flint/d_vec.pxd @@ -12,60 +12,60 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - double * _d_vec_init(long len) + double * _d_vec_init(slong len) # Returns an initialised vector of ``double``\s of given length. The # entries are not zeroed. void _d_vec_clear(double * vec) # Frees the space allocated for ``vec``. - void _d_vec_randtest(double * f, flint_rand_t state, long len, long minexp, long maxexp) + void _d_vec_randtest(double * f, flint_rand_t state, slong len, slong minexp, slong maxexp) # Sets the entries of a vector of the given length to random signed numbers # with exponents between ``minexp`` and ``maxexp`` or zero. - void _d_vec_set(double * vec1, const double * vec2, long len2) + void _d_vec_set(double * vec1, const double * vec2, slong len2) # Makes a copy of ``(vec2, len2)`` into ``vec1``. - void _d_vec_zero(double * vec, long len) + void _d_vec_zero(double * vec, slong len) # Zeros the entries of ``(vec, len)``. - int _d_vec_equal(const double * vec1, const double * vec2, long len) + int _d_vec_equal(const double * vec1, const double * vec2, slong len) # Compares two vectors of the given length and returns `1` if they are # equal, otherwise returns `0`. - int _d_vec_is_zero(const double * vec, long len) + int _d_vec_is_zero(const double * vec, slong len) # Returns `1` if ``(vec, len)`` is zero, and `0` otherwise. - int _d_vec_is_approx_zero(const double * vec, long len, double eps) + int _d_vec_is_approx_zero(const double * vec, slong len, double eps) # Returns `1` if the entries of ``(vec, len)`` are zero to within # ``eps``, and `0` otherwise. - int _d_vec_approx_equal(const double * vec1, const double * vec2, long len, double eps) + int _d_vec_approx_equal(const double * vec1, const double * vec2, slong len, double eps) # Compares two vectors of the given length and returns `1` if their entries # are within ``eps`` of each other, otherwise returns `0`. - void _d_vec_add(double * res, const double * vec1, const double * vec2, long len2) + void _d_vec_add(double * res, const double * vec1, const double * vec2, slong len2) # Sets ``(res, len2)`` to the sum of ``(vec1, len2)`` # and ``(vec2, len2)``. - void _d_vec_sub(double * res, const double * vec1, const double * vec2, long len2) + void _d_vec_sub(double * res, const double * vec1, const double * vec2, slong len2) # Sets ``(res, len2)`` to ``(vec1, len2)`` minus ``(vec2, len2)``. - double _d_vec_dot(const double * vec1, const double * vec2, long len2) + double _d_vec_dot(const double * vec1, const double * vec2, slong len2) # Returns the dot product of ``(vec1, len2)`` # and ``(vec2, len2)``. - double _d_vec_norm(const double * vec, long len) + double _d_vec_norm(const double * vec, slong len) # Returns the square of the Euclidean norm of ``(vec, len)``. - double _d_vec_dot_heuristic(const double * vec1, const double * vec2, long len2, double * err) + double _d_vec_dot_heuristic(const double * vec1, const double * vec2, slong len2, double * err) # Returns the dot product of ``(vec1, len2)`` # and ``(vec2, len2)`` by adding up the positive and negative products, # and doing a single subtraction of the two sums at the end. ``err`` is a # pointer to a double in which an error bound for the operation will be # stored. - double _d_vec_dot_thrice(const double * vec1, const double * vec2, long len2, double * err) + double _d_vec_dot_thrice(const double * vec1, const double * vec2, slong len2, double * err) # Returns the dot product of ``(vec1, len2)`` # and ``(vec2, len2)`` using error-free floating point sums and products # to compute the dot product with three times (thrice) the working precision. diff --git a/src/sage/libs/flint/dirichlet.pxd b/src/sage/libs/flint/dirichlet.pxd index 2850884e733..daaeb6d5bcb 100644 --- a/src/sage/libs/flint/dirichlet.pxd +++ b/src/sage/libs/flint/dirichlet.pxd @@ -12,7 +12,7 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - int dirichlet_group_init(dirichlet_group_t G, unsigned long q) + int dirichlet_group_init(dirichlet_group_t G, ulong q) # Initializes *G* to the group of Dirichlet characters mod *q*. # This method computes a canonical decomposition of *G* in terms of cyclic # groups, which are the mod `p^e` subgroups for `p^e\|q`, plus @@ -29,17 +29,17 @@ cdef extern from "flint_wrap.h": # be removed in the future. The function returns 1 on success and 0 # if a factor is too large. - void dirichlet_subgroup_init(dirichlet_group_t H, const dirichlet_group_t G, unsigned long h) + void dirichlet_subgroup_init(dirichlet_group_t H, const dirichlet_group_t G, ulong h) void dirichlet_group_clear(dirichlet_group_t G) # Clears *G*. Remark this function does *not* clear the discrete logarithm # tables stored in *G* (which may be shared with another group). - unsigned long dirichlet_group_size(const dirichlet_group_t G) + ulong dirichlet_group_size(const dirichlet_group_t G) - unsigned long dirichlet_group_num_primitive(const dirichlet_group_t G) + ulong dirichlet_group_num_primitive(const dirichlet_group_t G) - void dirichlet_group_dlog_precompute(dirichlet_group_t G, unsigned long num) + void dirichlet_group_dlog_precompute(dirichlet_group_t G, ulong num) # Precompute decomposition and tables for discrete log computations in *G*, # so as to minimize the complexity of *num* calls to discrete logarithms. # If *num* gets very large, the entire group may be indexed. @@ -56,14 +56,14 @@ cdef extern from "flint_wrap.h": void dirichlet_char_print(const dirichlet_group_t G, const dirichlet_char_t chi) # Prints the array of exponents representing this character. - void dirichlet_char_log(dirichlet_char_t x, const dirichlet_group_t G, unsigned long m) + void dirichlet_char_log(dirichlet_char_t x, const dirichlet_group_t G, ulong m) # Sets *x* to the character of number *m*, computing its log using discrete # logarithm in *G*. - unsigned long dirichlet_char_exp(const dirichlet_group_t G, const dirichlet_char_t x) + ulong dirichlet_char_exp(const dirichlet_group_t G, const dirichlet_char_t x) # Returns the number *m* corresponding to exponents in *x*. - unsigned long _dirichlet_char_exp(dirichlet_char_t x, const dirichlet_group_t G) + ulong _dirichlet_char_exp(dirichlet_char_t x, const dirichlet_group_t G) # Computes and returns the number *m* corresponding to exponents in *x*. # This function is for internal use. @@ -94,10 +94,10 @@ cdef extern from "flint_wrap.h": int dirichlet_char_next_primitive(dirichlet_char_t x, const dirichlet_group_t G) # Same as :func:`dirichlet_char_next`, but jumps to the next primitive character of *G*. - unsigned long dirichlet_index_char(const dirichlet_group_t G, const dirichlet_char_t x) + ulong dirichlet_index_char(const dirichlet_group_t G, const dirichlet_char_t x) # Returns the lexicographic index of the *log* of *x* as an integer in `0\dots \varphi(q)`. - void dirichlet_char_index(dirichlet_char_t x, const dirichlet_group_t G, unsigned long j) + void dirichlet_char_index(dirichlet_char_t x, const dirichlet_group_t G, ulong j) # Sets *x* to the character whose *log* has lexicographic index *j*. int dirichlet_char_eq(const dirichlet_char_t x, const dirichlet_char_t y) @@ -106,35 +106,35 @@ cdef extern from "flint_wrap.h": int dirichlet_char_is_principal(const dirichlet_group_t G, const dirichlet_char_t chi) - unsigned long dirichlet_conductor_ui(const dirichlet_group_t G, unsigned long a) + ulong dirichlet_conductor_ui(const dirichlet_group_t G, ulong a) - unsigned long dirichlet_conductor_char(const dirichlet_group_t G, const dirichlet_char_t x) + ulong dirichlet_conductor_char(const dirichlet_group_t G, const dirichlet_char_t x) - int dirichlet_parity_ui(const dirichlet_group_t G, unsigned long a) + int dirichlet_parity_ui(const dirichlet_group_t G, ulong a) int dirichlet_parity_char(const dirichlet_group_t G, const dirichlet_char_t x) - unsigned long dirichlet_order_ui(const dirichlet_group_t G, unsigned long a) + ulong dirichlet_order_ui(const dirichlet_group_t G, ulong a) - unsigned long dirichlet_order_char(const dirichlet_group_t G, const dirichlet_char_t x) + ulong dirichlet_order_char(const dirichlet_group_t G, const dirichlet_char_t x) int dirichlet_char_is_real(const dirichlet_group_t G, const dirichlet_char_t chi) int dirichlet_char_is_primitive(const dirichlet_group_t G, const dirichlet_char_t chi) - unsigned long dirichlet_pairing(const dirichlet_group_t G, unsigned long m, unsigned long n) + ulong dirichlet_pairing(const dirichlet_group_t G, ulong m, ulong n) - unsigned long dirichlet_pairing_char(const dirichlet_group_t G, const dirichlet_char_t chi, const dirichlet_char_t psi) + ulong dirichlet_pairing_char(const dirichlet_group_t G, const dirichlet_char_t chi, const dirichlet_char_t psi) - unsigned long dirichlet_chi(const dirichlet_group_t G, const dirichlet_char_t chi, unsigned long n) + ulong dirichlet_chi(const dirichlet_group_t G, const dirichlet_char_t chi, ulong n) - void dirichlet_chi_vec(unsigned long * v, const dirichlet_group_t G, const dirichlet_char_t chi, long nv) + void dirichlet_chi_vec(ulong * v, const dirichlet_group_t G, const dirichlet_char_t chi, slong nv) - void dirichlet_chi_vec_order(unsigned long * v, const dirichlet_group_t G, const dirichlet_char_t chi, unsigned long order, long nv) + void dirichlet_chi_vec_order(ulong * v, const dirichlet_group_t G, const dirichlet_char_t chi, ulong order, slong nv) void dirichlet_char_mul(dirichlet_char_t chi12, const dirichlet_group_t G, const dirichlet_char_t chi1, const dirichlet_char_t chi2) - void dirichlet_char_pow(dirichlet_char_t c, const dirichlet_group_t G, const dirichlet_char_t a, unsigned long n) + void dirichlet_char_pow(dirichlet_char_t c, const dirichlet_group_t G, const dirichlet_char_t a, ulong n) void dirichlet_char_lift(dirichlet_char_t chi_G, const dirichlet_group_t G, const dirichlet_char_t chi_H, const dirichlet_group_t H) # If *H* is a subgroup of *G*, computes the character in *G* corresponding to diff --git a/src/sage/libs/flint/dlog.pxd b/src/sage/libs/flint/dlog.pxd index 3d41a69958c..e48e8374203 100644 --- a/src/sage/libs/flint/dlog.pxd +++ b/src/sage/libs/flint/dlog.pxd @@ -12,74 +12,74 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - unsigned long dlog_once(unsigned long b, unsigned long a, const nmod_t mod, unsigned long n) + ulong dlog_once(ulong b, ulong a, const nmod_t mod, ulong n) - void dlog_precomp_n_init(dlog_precomp_t pre, unsigned long a, unsigned long mod, unsigned long n, unsigned long num) + void dlog_precomp_n_init(dlog_precomp_t pre, ulong a, ulong mod, ulong n, ulong num) - unsigned long dlog_precomp(const dlog_precomp_t pre, unsigned long b) + ulong dlog_precomp(const dlog_precomp_t pre, ulong b) void dlog_precomp_clear(dlog_precomp_t pre) - void dlog_precomp_modpe_init(dlog_precomp_t pre, unsigned long a, unsigned long p, unsigned long e, unsigned long pe, unsigned long num) + void dlog_precomp_modpe_init(dlog_precomp_t pre, ulong a, ulong p, ulong e, ulong pe, ulong num) - void dlog_precomp_p_init(dlog_precomp_t pre, unsigned long a, unsigned long mod, unsigned long p, unsigned long num) + void dlog_precomp_p_init(dlog_precomp_t pre, ulong a, ulong mod, ulong p, ulong num) - void dlog_precomp_pe_init(dlog_precomp_t pre, unsigned long a, unsigned long mod, unsigned long p, unsigned long e, unsigned long pe, unsigned long num) + void dlog_precomp_pe_init(dlog_precomp_t pre, ulong a, ulong mod, ulong p, ulong e, ulong pe, ulong num) - void dlog_precomp_small_init(dlog_precomp_t pre, unsigned long a, unsigned long mod, unsigned long n, unsigned long num) + void dlog_precomp_small_init(dlog_precomp_t pre, ulong a, ulong mod, ulong n, ulong num) - void dlog_vec_fill(unsigned long * v, unsigned long nv, unsigned long x) + void dlog_vec_fill(ulong * v, ulong nv, ulong x) - void dlog_vec_set_not_found(unsigned long * v, unsigned long nv, nmod_t mod) + void dlog_vec_set_not_found(ulong * v, ulong nv, nmod_t mod) - void dlog_vec(unsigned long * v, unsigned long nv, unsigned long a, unsigned long va, nmod_t mod, unsigned long na, nmod_t order) + void dlog_vec(ulong * v, ulong nv, ulong a, ulong va, nmod_t mod, ulong na, nmod_t order) - void dlog_vec_add(unsigned long * v, unsigned long nv, unsigned long a, unsigned long va, nmod_t mod, unsigned long na, nmod_t order) + void dlog_vec_add(ulong * v, ulong nv, ulong a, ulong va, nmod_t mod, ulong na, nmod_t order) - void dlog_vec_loop(unsigned long * v, unsigned long nv, unsigned long a, unsigned long va, nmod_t mod, unsigned long na, nmod_t order) + void dlog_vec_loop(ulong * v, ulong nv, ulong a, ulong va, nmod_t mod, ulong na, nmod_t order) - void dlog_vec_loop_add(unsigned long * v, unsigned long nv, unsigned long a, unsigned long va, nmod_t mod, unsigned long na, nmod_t order) + void dlog_vec_loop_add(ulong * v, ulong nv, ulong a, ulong va, nmod_t mod, ulong na, nmod_t order) - void dlog_vec_eratos(unsigned long * v, unsigned long nv, unsigned long a, unsigned long va, nmod_t mod, unsigned long na, nmod_t order) + void dlog_vec_eratos(ulong * v, ulong nv, ulong a, ulong va, nmod_t mod, ulong na, nmod_t order) - void dlog_vec_eratos_add(unsigned long * v, unsigned long nv, unsigned long a, unsigned long va, nmod_t mod, unsigned long na, nmod_t order) + void dlog_vec_eratos_add(ulong * v, ulong nv, ulong a, ulong va, nmod_t mod, ulong na, nmod_t order) - void dlog_vec_sieve_add(unsigned long * v, unsigned long nv, unsigned long a, unsigned long va, nmod_t mod, unsigned long na, nmod_t order) + void dlog_vec_sieve_add(ulong * v, ulong nv, ulong a, ulong va, nmod_t mod, ulong na, nmod_t order) - void dlog_vec_sieve(unsigned long * v, unsigned long nv, unsigned long a, unsigned long va, nmod_t mod, unsigned long na, nmod_t order) + void dlog_vec_sieve(ulong * v, ulong nv, ulong a, ulong va, nmod_t mod, ulong na, nmod_t order) - unsigned long dlog_table_init(dlog_table_t t, unsigned long a, unsigned long mod) + ulong dlog_table_init(dlog_table_t t, ulong a, ulong mod) void dlog_table_clear(dlog_table_t t) - unsigned long dlog_table(const dlog_table_t t, unsigned long b) + ulong dlog_table(const dlog_table_t t, ulong b) - unsigned long dlog_bsgs_init(dlog_bsgs_t t, unsigned long a, unsigned long mod, unsigned long n, unsigned long m) + ulong dlog_bsgs_init(dlog_bsgs_t t, ulong a, ulong mod, ulong n, ulong m) void dlog_bsgs_clear(dlog_bsgs_t t) - unsigned long dlog_bsgs(const dlog_bsgs_t t, unsigned long b) + ulong dlog_bsgs(const dlog_bsgs_t t, ulong b) - unsigned long dlog_modpe_init(dlog_modpe_t t, unsigned long a, unsigned long p, unsigned long e, unsigned long pe, unsigned long num) + ulong dlog_modpe_init(dlog_modpe_t t, ulong a, ulong p, ulong e, ulong pe, ulong num) void dlog_modpe_clear(dlog_modpe_t t) - unsigned long dlog_modpe(const dlog_modpe_t t, unsigned long b) + ulong dlog_modpe(const dlog_modpe_t t, ulong b) - unsigned long dlog_crt_init(dlog_crt_t t, unsigned long a, unsigned long mod, unsigned long n, unsigned long num) + ulong dlog_crt_init(dlog_crt_t t, ulong a, ulong mod, ulong n, ulong num) void dlog_crt_clear(dlog_crt_t t) - unsigned long dlog_crt(const dlog_crt_t t, unsigned long b) + ulong dlog_crt(const dlog_crt_t t, ulong b) - unsigned long dlog_power_init(dlog_power_t t, unsigned long a, unsigned long mod, unsigned long p, unsigned long e, unsigned long num) + ulong dlog_power_init(dlog_power_t t, ulong a, ulong mod, ulong p, ulong e, ulong num) void dlog_power_clear(dlog_power_t t) - unsigned long dlog_power(const dlog_power_t t, unsigned long b) + ulong dlog_power(const dlog_power_t t, ulong b) - void dlog_rho_init(dlog_rho_t t, unsigned long a, unsigned long mod, unsigned long n) + void dlog_rho_init(dlog_rho_t t, ulong a, ulong mod, ulong n) void dlog_rho_clear(dlog_rho_t t) - unsigned long dlog_rho(const dlog_rho_t t, unsigned long b) + ulong dlog_rho(const dlog_rho_t t, ulong b) diff --git a/src/sage/libs/flint/double_extras.pxd b/src/sage/libs/flint/double_extras.pxd index 73c9f88d781..f5b03b45b74 100644 --- a/src/sage/libs/flint/double_extras.pxd +++ b/src/sage/libs/flint/double_extras.pxd @@ -15,11 +15,11 @@ cdef extern from "flint_wrap.h": double d_randtest(flint_rand_t state) # Returns a random number in the interval `[0.5, 1)`. - double d_randtest_signed(flint_rand_t state, long minexp, long maxexp) + double d_randtest_signed(flint_rand_t state, slong minexp, slong maxexp) # Returns a random signed number with exponent between ``minexp`` and # ``maxexp`` or zero. - double d_randtest_special(flint_rand_t state, long minexp, long maxexp) + double d_randtest_special(flint_rand_t state, slong minexp, slong maxexp) # Returns a random signed number with exponent between ``minexp`` and # ``maxexp``, zero, ``D_NAN`` or `\pm`\ ``D_INF``. diff --git a/src/sage/libs/flint/double_interval.pxd b/src/sage/libs/flint/double_interval.pxd index 8abc10b775d..1d1717352b2 100644 --- a/src/sage/libs/flint/double_interval.pxd +++ b/src/sage/libs/flint/double_interval.pxd @@ -19,7 +19,7 @@ cdef extern from "flint_wrap.h": di_t arb_get_di(const arb_t x) # Returns the ball *x* converted to a double-precision interval. - void arb_set_di(arb_t res, di_t x, long prec) + void arb_set_di(arb_t res, di_t x, slong prec) # Sets the ball *res* to the double-precision interval *x*, # rounded to *prec* bits. diff --git a/src/sage/libs/flint/fexpr.pxd b/src/sage/libs/flint/fexpr.pxd index 83107681649..de11cc6f458 100644 --- a/src/sage/libs/flint/fexpr.pxd +++ b/src/sage/libs/flint/fexpr.pxd @@ -19,13 +19,13 @@ cdef extern from "flint_wrap.h": void fexpr_clear(fexpr_t expr) # Clears *expr*, freeing its allocated memory. - fexpr_ptr _fexpr_vec_init(long len) + fexpr_ptr _fexpr_vec_init(slong len) # Returns a heap-allocated vector of *len* initialized expressions. - void _fexpr_vec_clear(fexpr_ptr vec, long len) + void _fexpr_vec_clear(fexpr_ptr vec, slong len) # Clears the *len* expressions in *vec* and frees *vec* itself. - void fexpr_fit_size(fexpr_t expr, long size) + void fexpr_fit_size(fexpr_t expr, slong size) # Ensures that *expr* has room for *size* words. void fexpr_set(fexpr_t res, const fexpr_t expr) @@ -34,24 +34,24 @@ cdef extern from "flint_wrap.h": void fexpr_swap(fexpr_t a, fexpr_t b) # Swaps *a* and *b* efficiently. - long fexpr_depth(const fexpr_t expr) + slong fexpr_depth(const fexpr_t expr) # Returns the depth of *expr* as a symbolic expression tree. - long fexpr_num_leaves(const fexpr_t expr) + slong fexpr_num_leaves(const fexpr_t expr) # Returns the number of leaves (atoms, counted with repetition) # in the expression *expr*. - long fexpr_size(const fexpr_t expr) + slong fexpr_size(const fexpr_t expr) # Returns the number of words in the internal representation # of *expr*. - long fexpr_size_bytes(const fexpr_t expr) + slong fexpr_size_bytes(const fexpr_t expr) # Returns the number of bytes in the internal representation # of *expr*. The count excludes the size of the structure itself. # Add ``sizeof(fexpr_struct)`` to get the size of the object as a # whole. - long fexpr_allocated_bytes(const fexpr_t expr) + slong fexpr_allocated_bytes(const fexpr_t expr) # Returns the number of allocated bytes in the internal # representation of *expr*. The count excludes the size of the # structure itself. Add ``sizeof(fexpr_struct)`` to get the size of @@ -60,12 +60,12 @@ cdef extern from "flint_wrap.h": int fexpr_equal(const fexpr_t a, const fexpr_t b) # Checks if *a* and *b* are exactly equal as expressions. - int fexpr_equal_si(const fexpr_t expr, long c) + int fexpr_equal_si(const fexpr_t expr, slong c) - int fexpr_equal_ui(const fexpr_t expr, unsigned long c) + int fexpr_equal_ui(const fexpr_t expr, ulong c) # Checks if *expr* is an atomic integer exactly equal to *c*. - unsigned long fexpr_hash(const fexpr_t expr) + ulong fexpr_hash(const fexpr_t expr) # Returns a hash of the expression *expr*. int fexpr_cmp_fast(const fexpr_t a, const fexpr_t b) @@ -95,8 +95,8 @@ cdef extern from "flint_wrap.h": int fexpr_is_neg_integer(const fexpr_t expr) # Returns whether *expr* is any negative atomic integer. - void fexpr_set_si(fexpr_t res, long c) - void fexpr_set_ui(fexpr_t res, unsigned long c) + void fexpr_set_si(fexpr_t res, slong c) + void fexpr_set_ui(fexpr_t res, ulong c) void fexpr_set_fmpz(fexpr_t res, const fmpz_t c) # Sets *res* to the atomic integer *c*. @@ -104,11 +104,11 @@ cdef extern from "flint_wrap.h": # Sets *res* to the atomic integer in *expr*. This aborts # if *expr* is not an atomic integer. - void fexpr_set_symbol_builtin(fexpr_t res, long id) + void fexpr_set_symbol_builtin(fexpr_t res, slong id) # Sets *res* to the builtin symbol with internal index *id* # (see :ref:`fexpr-builtin`). - int fexpr_is_builtin_symbol(const fexpr_t expr, long id) + int fexpr_is_builtin_symbol(const fexpr_t expr, slong id) # Returns whether *expr* is the builtin symbol with index *id* # (see :ref:`fexpr-builtin`). @@ -143,19 +143,19 @@ cdef extern from "flint_wrap.h": # Warning: string literals appearing in expressions # are currently not escaped. - void fexpr_write_latex(calcium_stream_t stream, const fexpr_t expr, unsigned long flags) + void fexpr_write_latex(calcium_stream_t stream, const fexpr_t expr, ulong flags) # Writes the LaTeX representation of *expr* to *stream*. - void fexpr_print_latex(const fexpr_t expr, unsigned long flags) + void fexpr_print_latex(const fexpr_t expr, ulong flags) # Prints the LaTeX representation of *expr* to standard output. - char * fexpr_get_str_latex(const fexpr_t expr, unsigned long flags) + char * fexpr_get_str_latex(const fexpr_t expr, ulong flags) # Returns a string of the LaTeX representation of *expr*. The string # must be freed with :func:`flint_free`. # Warning: string literals appearing in expressions # are currently not escaped. - long fexpr_nargs(const fexpr_t expr) + slong fexpr_nargs(const fexpr_t expr) # Returns the number of arguments *n* in the function call # `f(e_1,\ldots,e_n)` represented # by *expr*. If *expr* is an atom, returns -1. @@ -171,13 +171,13 @@ cdef extern from "flint_wrap.h": # cleared after use, and *expr* must not be modified or cleared # as long as *view* is in use. - void fexpr_arg(fexpr_t res, const fexpr_t expr, long i) + void fexpr_arg(fexpr_t res, const fexpr_t expr, slong i) # Assuming that *expr* represents a function call # `f(e_1,\ldots,e_n)`, sets *res* to the argument `e_{i+1}`. # Note that indexing starts from 0. # The index must be in bounds, with `0 \le i < n`. - void fexpr_view_arg(fexpr_t view, const fexpr_t expr, long i) + void fexpr_view_arg(fexpr_t view, const fexpr_t expr, slong i) # As :func:`fexpr_arg`, but sets *view* to a shallow view # instead of copying the expression. # The variable *view* must not be initialized before use or @@ -193,7 +193,7 @@ cdef extern from "flint_wrap.h": # This function can also be called when *view* refers to the function *f*, # in which case it will make *view* point to `e_1`. - int fexpr_is_builtin_call(const fexpr_t expr, long id) + int fexpr_is_builtin_call(const fexpr_t expr, slong id) # Returns whether *expr* has the form `f(\ldots)` where *f* is # a builtin function defined by *id* (see :ref:`fexpr-builtin`). @@ -206,14 +206,14 @@ cdef extern from "flint_wrap.h": void fexpr_call2(fexpr_t res, const fexpr_t f, const fexpr_t x1, const fexpr_t x2) void fexpr_call3(fexpr_t res, const fexpr_t f, const fexpr_t x1, const fexpr_t x2, const fexpr_t x3) void fexpr_call4(fexpr_t res, const fexpr_t f, const fexpr_t x1, const fexpr_t x2, const fexpr_t x3, const fexpr_t x4) - void fexpr_call_vec(fexpr_t res, const fexpr_t f, fexpr_srcptr args, long len) + void fexpr_call_vec(fexpr_t res, const fexpr_t f, fexpr_srcptr args, slong len) # Creates the function call `f(x_1,\ldots,x_n)`. # The *vec* version takes the arguments as an array *args* # and *n* is given by *len*. # Warning: aliasing between inputs and outputs is not implemented. - void fexpr_call_builtin1(fexpr_t res, long f, const fexpr_t x1) - void fexpr_call_builtin2(fexpr_t res, long f, const fexpr_t x1, const fexpr_t x2) + void fexpr_call_builtin1(fexpr_t res, slong f, const fexpr_t x1) + void fexpr_call_builtin2(fexpr_t res, slong f, const fexpr_t x1, const fexpr_t x2) # Creates the function call `f(x_1,\ldots,x_n)`, where *f* defines # a builtin symbol. @@ -311,7 +311,7 @@ cdef extern from "flint_wrap.h": # If *NULL* is passed for *vars*, a default choice of symbols # is used. - int fexpr_expanded_normal_form(fexpr_t res, const fexpr_t expr, unsigned long flags) + int fexpr_expanded_normal_form(fexpr_t res, const fexpr_t expr, ulong flags) # Sets *res* to *expr* converted to expanded normal form viewed # as a formal rational function with its non-arithmetic subexpressions # as terminal nodes. @@ -321,7 +321,7 @@ cdef extern from "flint_wrap.h": # expression with :func:`fexpr_set_fmpz_mpoly_q`. # Optional *flags* are reserved for future use. - void fexpr_vec_init(fexpr_vec_t vec, long len) + void fexpr_vec_init(fexpr_vec_t vec, slong len) # Initializes *vec* to a vector of length *len*. All entries # are set to the atomic integer 0. @@ -334,7 +334,7 @@ cdef extern from "flint_wrap.h": void fexpr_vec_swap(fexpr_vec_t x, fexpr_vec_t y) # Swaps *x* and *y* efficiently. - void fexpr_vec_fit_length(fexpr_vec_t vec, long len) + void fexpr_vec_fit_length(fexpr_vec_t vec, slong len) # Ensures that *vec* has space for *len* entries. void fexpr_vec_set(fexpr_vec_t dest, const fexpr_vec_t src) @@ -343,14 +343,14 @@ cdef extern from "flint_wrap.h": void fexpr_vec_append(fexpr_vec_t vec, const fexpr_t expr) # Appends *expr* to the end of the vector *vec*. - long fexpr_vec_insert_unique(fexpr_vec_t vec, const fexpr_t expr) + slong fexpr_vec_insert_unique(fexpr_vec_t vec, const fexpr_t expr) # Inserts *expr* without duplication into vec, returning its # position. If this expression already exists, *vec* is unchanged. # If this expression does not exist in *vec*, it is appended. - void fexpr_vec_set_length(fexpr_vec_t vec, long len) + void fexpr_vec_set_length(fexpr_vec_t vec, slong len) # Sets the length of *vec* to *len*, truncating or zero-extending as needed. - void _fexpr_vec_sort_fast(fexpr_ptr vec, long len) + void _fexpr_vec_sort_fast(fexpr_ptr vec, slong len) # Sorts the *len* entries in *vec* using # the comparison function :func:`fexpr_cmp_fast`. diff --git a/src/sage/libs/flint/fexpr_builtin.pxd b/src/sage/libs/flint/fexpr_builtin.pxd index 7e703720544..57a63958f06 100644 --- a/src/sage/libs/flint/fexpr_builtin.pxd +++ b/src/sage/libs/flint/fexpr_builtin.pxd @@ -12,14 +12,14 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - long fexpr_builtin_lookup(const char * s) + slong fexpr_builtin_lookup(const char * s) # Returns the internal index used to encode the builtin symbol # with name *s* in expressions. If *s* is not the name of a builtin # symbol, returns -1. - const char * fexpr_builtin_name(long n) + const char * fexpr_builtin_name(slong n) # Returns a read-only pointer for a string giving the name of the # builtin symbol with index *n*. - long fexpr_builtin_length() + slong fexpr_builtin_length() # Returns the number of builtin symbols. diff --git a/src/sage/libs/flint/fft.pxd b/src/sage/libs/flint/fft.pxd index b00a80556cd..1abeff1cd2e 100644 --- a/src/sage/libs/flint/fft.pxd +++ b/src/sage/libs/flint/fft.pxd @@ -30,7 +30,7 @@ cdef extern from "flint_wrap.h": # is returned by the function and any coefficients beyond this point are # not touched. - void fft_combine_limbs(mp_limb_t * res, mp_limb_t ** poly, long length, mp_size_t coeff_limbs, mp_size_t output_limbs, mp_size_t total_limbs) + void fft_combine_limbs(mp_limb_t * res, mp_limb_t ** poly, slong length, mp_size_t coeff_limbs, mp_size_t output_limbs, mp_size_t total_limbs) # Evaluate the polynomial ``poly`` of the given ``length`` at # ``B^coeff_limbs``, where ``B = 2^FLINT_BITS``, and add the # result to the integer ``(res, total_limbs)`` throwing away any bits @@ -40,7 +40,7 @@ cdef extern from "flint_wrap.h": # If the integer is initially zero the result will just be the evaluation # of the polynomial. - void fft_combine_bits(mp_limb_t * res, mp_limb_t ** poly, long length, flint_bitcnt_t bits, mp_size_t output_limbs, mp_size_t total_limbs) + void fft_combine_bits(mp_limb_t * res, mp_limb_t ** poly, slong length, flint_bitcnt_t bits, mp_size_t output_limbs, mp_size_t total_limbs) # Evaluate the polynomial ``poly`` of the given ``length`` at # ``2^bits`` and add the result to the integer # ``(res, total_limbs)`` throwing away any bits that exceed the given @@ -385,7 +385,7 @@ cdef extern from "flint_wrap.h": # require that ``depth`` and ``w`` have been selected as per the # wrapper ``fft_mulmod_2expp1`` below. - long fft_adjust_limbs(mp_size_t limbs) + slong fft_adjust_limbs(mp_size_t limbs) # Given a number of limbs, returns a new number of limbs (no more than # the next power of 2) which will work with the Nussbaumer code. It is only # necessary to make this adjustment if @@ -421,7 +421,7 @@ cdef extern from "flint_wrap.h": # The main integer multiplication routine. Sets ``(r1, n1 + n2)`` to # ``(i1, n1)`` times ``(i2, n2)``. We require ``n1 >= n2 > 0``. - void fft_convolution(mp_limb_t ** ii, mp_limb_t ** jj, long depth, long limbs, long trunc, mp_limb_t ** t1, mp_limb_t ** t2, mp_limb_t ** s1, mp_limb_t ** tt) + void fft_convolution(mp_limb_t ** ii, mp_limb_t ** jj, slong depth, slong limbs, slong trunc, mp_limb_t ** t1, mp_limb_t ** t2, mp_limb_t ** s1, mp_limb_t ** tt) # Perform an FFT convolution of ``ii`` with ``jj``, both of length # ``4*n`` where ``n = 2^depth``. Assume that all but the first # ``trunc`` coefficients of the output (placed in ``ii``) are zero. @@ -430,11 +430,11 @@ cdef extern from "flint_wrap.h": # limbs of space and ``tt`` must have ``2*(limbs + 1)`` of free # space. - void fft_precache(mp_limb_t ** jj, long depth, long limbs, long trunc, mp_limb_t ** t1, mp_limb_t ** t2, mp_limb_t ** s1) + void fft_precache(mp_limb_t ** jj, slong depth, slong limbs, slong trunc, mp_limb_t ** t1, mp_limb_t ** t2, mp_limb_t ** s1) # Precompute the FFT of ``jj`` for use with precache functions. The # parameters are as for ``fft_convolution``. - void fft_convolution_precache(mp_limb_t ** ii, mp_limb_t ** jj, long depth, long limbs, long trunc, mp_limb_t ** t1, mp_limb_t ** t2, mp_limb_t ** s1, mp_limb_t ** tt) + void fft_convolution_precache(mp_limb_t ** ii, mp_limb_t ** jj, slong depth, slong limbs, slong trunc, mp_limb_t ** t1, mp_limb_t ** t2, mp_limb_t ** s1, mp_limb_t ** tt) # As per ``fft_convolution`` except that it is assumed ``fft_precache`` has # been called on ``jj`` with the same parameters. This will then run faster # than if ``fft_convolution`` had been run with the original ``jj``. diff --git a/src/sage/libs/flint/flint.pxd b/src/sage/libs/flint/flint.pxd index df9e6a1e870..e6be37bf54c 100644 --- a/src/sage/libs/flint/flint.pxd +++ b/src/sage/libs/flint/flint.pxd @@ -1,11 +1,95 @@ # distutils: libraries = flint -# distutils: depends = flint/flint.h flint/fmpz.h +# distutils: depends = flint/flint.h + +################################################################################ +# This file is auto-generated. Do not modify by hand +################################################################################ + +from libc.stdio cimport FILE +from sage.libs.gmp.types cimport * +from sage.libs.mpfr.types cimport * +from sage.libs.flint.types cimport * -# flint/flint.h cdef extern from "flint_wrap.h": - cdef unsigned long FLINT_BIT_COUNT(unsigned long) + + mp_limb_t FLINT_BIT_COUNT(mp_limb_t x) + # Returns the number of binary bits required to represent an ``ulong x``. If + # `x` is zero, returns `0`. + + void * flint_malloc(size_t size) + + void * flint_realloc(void * ptr, size_t size) + + void * flint_calloc(size_t num, size_t size) + void flint_free(void * ptr) -# flint/fmpz.h -cdef extern from "flint_wrap.h": - void _fmpz_cleanup_mpz_content() + flint_rand_s * flint_rand_alloc() + # Allocates a ``flint_rand_t`` object to be used like a heap-allocated + # ``flint_rand_t`` in external libraries. + # The random state is not initialised. + + void flint_rand_free(flint_rand_s * state) + # Frees a random state object as allocated using :func:`flint_rand_alloc`. + + void flint_randinit(flint_rand_t state) + # Initialize a :type:`flint_rand_t`. + + void flint_randclear(flint_rand_t state) + # Free all memory allocated by :func:`flint_rand_init`. + + void flint_set_num_threads(int num_threads) + # Set up a thread pool of ``num_threads - 1`` worker threads (in addition + # to the master thread) and set the maximum number of worker threads the + # master thread can start to ``num_threads - 1``. + # This function may only be called globally from the master thread. It can + # also be called at a global level to change the size of the thread pool, but + # an exception is raised if the thread pool is in use (threads have been + # woken but not given back). The function cannot be called from inside + # worker threads. + + int flint_get_num_threads() + # When called at the global level, this function returns one more than the + # number of worker threads in the Flint thread pool, i.e. it returns the + # number of workers in the thread pool plus one for the master thread. + # In general, this function returns one more than the number of additional + # worker threads that can be started by the current thread. + # Use :func:`thread_pool_wake` to set this number for a given worker thread. + # See also: :func:`flint_get_num_available_threads`. + + int flint_set_num_workers(int num_workers) + # Restricts the number of worker threads that can be started by the current + # thread to ``num_workers``. This function can be called from any thread. + # Assumes that the Flint thread pool is already set up. + # The function returns the old number of worker threads that can be started. + # The function can only be used to reduce the number of workers that can be + # started from a thread. It cannot be used to increase the number. If a + # higher number is passed, the function has no effect. + # The number of workers must be restored to the original value by a call to + # :func:`flint_reset_num_workers` before the thread is returned to the thread + # pool. + # The main use of this function and :func:`flint_reset_num_workers` is to cheaply + # and temporarily restrict the number of workers that can be started, e.g. by + # a function that one wishes to call from a thread, and cheaply restore the + # number of workers to its original value before exiting the current thread. + + void flint_reset_num_workers(int num_workers) + # After a call to :func:`flint_set_num_workers` this function must be called to + # set the number of workers that may be started by the current thread back to + # its original value. + + int flint_printf(const char * str, ...) + int flint_fprintf(FILE * f, const char * str, ...) + int flint_sprintf(char * s, const char * str, ...) + # These are equivalent to the standard library functions ``printf``, + # ``vprintf``, ``fprintf``, and ``sprintf`` with an additional length modifier + # "w" for use with an :type:`mp_limb_t` type. This modifier can be used with + # format specifiers "d", "x", or "u", thereby outputting the limb as a signed + # decimal, hexadecimal, or unsigned decimal integer. + + int flint_scanf(const char * str, ...) + int flint_fscanf(FILE * f, const char * str, ...) + int flint_sscanf(const char * s, const char * str, ...) + # These are equivalent to the standard library functions ``scanf``, + # ``fscanf``, and ``sscanf`` with an additional length modifier "w" for + # reading an :type:`mp_limb_t` type. diff --git a/src/sage/libs/flint/flint.pyx b/src/sage/libs/flint/flint.pyx deleted file mode 100644 index 19d76b4c867..00000000000 --- a/src/sage/libs/flint/flint.pyx +++ /dev/null @@ -1,45 +0,0 @@ -# distutils: extra_compile_args = -D_XPG6 -""" -Flint imports - -TESTS: - -Import this module:: - - sage: import sage.libs.flint.flint - -We verify that :trac:`6919` is correctly fixed:: - - sage: R. = PolynomialRing(ZZ) - sage: A = 2^(2^17+2^15) - sage: a = A * x^31 - sage: b = (A * x) * x^30 - sage: a == b - True -""" - -# cimport all .pxd files to make sure they compile -cimport sage.libs.flint.arith -cimport sage.libs.flint.fmpq_poly -cimport sage.libs.flint.fmpq -cimport sage.libs.flint.fmpz_mat -cimport sage.libs.flint.fmpz_mod_poly -cimport sage.libs.flint.fmpz_poly -cimport sage.libs.flint.fmpz -cimport sage.libs.flint.fmpz_vec -cimport sage.libs.flint.fq_nmod -cimport sage.libs.flint.fq -cimport sage.libs.flint.nmod_poly -cimport sage.libs.flint.nmod_vec -cimport sage.libs.flint.padic -cimport sage.libs.flint.types -cimport sage.libs.flint.ulong_extras - -# Try to clean up after ourselves before sage terminates. This -# probably doesn't do anything if your copy of flint is re-entrant -# (and most are). Moreover it isn't strictly necessary, because the OS -# will reclaim these resources anyway after sage terminates. However -# this might reveal other bugs, and can help tools like valgrind do -# their jobs. -import atexit -atexit.register(_fmpz_cleanup_mpz_content) diff --git a/src/sage/libs/flint/fmpq.pxd b/src/sage/libs/flint/fmpq.pxd index a0f708c7f08..7779c1f2dd2 100644 --- a/src/sage/libs/flint/fmpq.pxd +++ b/src/sage/libs/flint/fmpq.pxd @@ -81,16 +81,16 @@ cdef extern from "flint_wrap.h": int fmpq_cmp(const fmpq_t x, const fmpq_t y) int fmpq_cmp_fmpz(const fmpq_t x, const fmpz_t y) - int fmpq_cmp_ui(const fmpq_t x, unsigned long y) + int fmpq_cmp_ui(const fmpq_t x, ulong y) # Returns negative if `x < y`, zero if `x = y`, and positive if `x > y`. - int fmpq_cmp_si(const fmpq_t x, long y) + int fmpq_cmp_si(const fmpq_t x, slong y) # Returns negative if `x < y`, zero if `x = y`, and positive if `x > y`. - int fmpq_equal_ui(fmpq_t x, unsigned long y) + int fmpq_equal_ui(fmpq_t x, ulong y) # Returns `1` if `x = y`, otherwise returns `0`. - int fmpq_equal_si(fmpq_t x, long y) + int fmpq_equal_si(fmpq_t x, slong y) # Returns `1` if `x = y`, otherwise returns `0`. void fmpq_height(fmpz_t height, const fmpq_t x) @@ -109,17 +109,17 @@ cdef extern from "flint_wrap.h": # Sets ``a``, ``b`` to the numerator and denominator of ``c`` # respectively. - void fmpq_set_si(fmpq_t res, long p, unsigned long q) + void fmpq_set_si(fmpq_t res, slong p, ulong q) # Sets ``res`` to the canonical form of the fraction ``p / q``. - void _fmpq_set_si(fmpz_t rnum, fmpz_t rden, long p, unsigned long q) + void _fmpq_set_si(fmpz_t rnum, fmpz_t rden, slong p, ulong q) # Sets ``(rnum, rden)`` to the canonical form of the fraction # ``p / q``. ``rnum`` and ``rden`` may not be aliased. - void fmpq_set_ui(fmpq_t res, unsigned long p, unsigned long q) + void fmpq_set_ui(fmpq_t res, ulong p, ulong q) # Sets ``res`` to the canonical form of the fraction ``p / q``. - void _fmpq_set_ui(fmpz_t rnum, fmpz_t rden, unsigned long p, unsigned long q) + void _fmpq_set_ui(fmpz_t rnum, fmpz_t rden, ulong p, ulong q) # Sets ``(rnum, rden)`` to the canonical form of the fraction # ``p / q``. ``rnum`` and ``rden`` may not be aliased. @@ -276,30 +276,30 @@ cdef extern from "flint_wrap.h": # Aliasing between any combination of the variables is allowed, # whilst no numerator is aliased with a denominator. - void _fmpq_add_si(fmpz_t rnum, fmpz_t rden, const fmpz_t p, const fmpz_t q, long r) - void _fmpq_sub_si(fmpz_t rnum, fmpz_t rden, const fmpz_t p, const fmpz_t q, long r) - void _fmpq_add_ui(fmpz_t rnum, fmpz_t rden, const fmpz_t p, const fmpz_t q, unsigned long r) - void _fmpq_sub_ui(fmpz_t rnum, fmpz_t rden, const fmpz_t p, const fmpz_t q, unsigned long r) + void _fmpq_add_si(fmpz_t rnum, fmpz_t rden, const fmpz_t p, const fmpz_t q, slong r) + void _fmpq_sub_si(fmpz_t rnum, fmpz_t rden, const fmpz_t p, const fmpz_t q, slong r) + void _fmpq_add_ui(fmpz_t rnum, fmpz_t rden, const fmpz_t p, const fmpz_t q, ulong r) + void _fmpq_sub_ui(fmpz_t rnum, fmpz_t rden, const fmpz_t p, const fmpz_t q, ulong r) void _fmpq_add_fmpz(fmpz_t rnum, fmpz_t rden, const fmpz_t p, const fmpz_t q, const fmpz_t r) void _fmpq_sub_fmpz(fmpz_t rnum, fmpz_t rden, const fmpz_t p, const fmpz_t q, const fmpz_t r) # Sets ``(rnum, rden)`` to the canonical form of the sum or difference # respectively of the fractions represented by ``(p, q)`` and # ``(r, 1)``. Numerators may not be aliased with denominators. - void fmpq_add_si(fmpq_t res, const fmpq_t op1, long c) - void fmpq_sub_si(fmpq_t res, const fmpq_t op1, long c) - void fmpq_add_ui(fmpq_t res, const fmpq_t op1, unsigned long c) - void fmpq_sub_ui(fmpq_t res, const fmpq_t op1, unsigned long c) + void fmpq_add_si(fmpq_t res, const fmpq_t op1, slong c) + void fmpq_sub_si(fmpq_t res, const fmpq_t op1, slong c) + void fmpq_add_ui(fmpq_t res, const fmpq_t op1, ulong c) + void fmpq_sub_ui(fmpq_t res, const fmpq_t op1, ulong c) void fmpq_add_fmpz(fmpq_t res, const fmpq_t op1, const fmpz_t c) void fmpq_sub_fmpz(fmpq_t res, const fmpq_t op1, const fmpz_t c) - void _fmpq_mul_si(fmpz_t rnum, fmpz_t rden, const fmpz_t p, const fmpz_t q, long r) + void _fmpq_mul_si(fmpz_t rnum, fmpz_t rden, const fmpz_t p, const fmpz_t q, slong r) - void fmpq_mul_si(fmpq_t res, const fmpq_t op1, long c) + void fmpq_mul_si(fmpq_t res, const fmpq_t op1, slong c) - void _fmpq_mul_ui(fmpz_t rnum, fmpz_t rden, const fmpz_t p, const fmpz_t q, unsigned long r) + void _fmpq_mul_ui(fmpz_t rnum, fmpz_t rden, const fmpz_t p, const fmpz_t q, ulong r) - void fmpq_mul_ui(fmpq_t res, const fmpq_t op1, unsigned long c) + void fmpq_mul_ui(fmpq_t res, const fmpq_t op1, ulong c) void fmpq_addmul(fmpq_t res, const fmpq_t op1, const fmpq_t op2) void fmpq_submul(fmpq_t res, const fmpq_t op1, const fmpq_t op2) @@ -319,8 +319,8 @@ cdef extern from "flint_wrap.h": # Sets ``dest`` to ``1 / src``. The result is placed in canonical # form, assuming that ``src`` is already in canonical form. - void _fmpq_pow_si(fmpz_t rnum, fmpz_t rden, const fmpz_t opnum, const fmpz_t opden, long e) - void fmpq_pow_si(fmpq_t res, const fmpq_t op, long e) + void _fmpq_pow_si(fmpz_t rnum, fmpz_t rden, const fmpz_t opnum, const fmpz_t opden, slong e) + void fmpq_pow_si(fmpq_t res, const fmpq_t op, slong e) # Sets ``res`` to ``op`` raised to the power `e`, where `e` # is a ``slong``. If `e` is `0` and ``op`` is `0`, then # ``res`` will be set to `1`. @@ -360,12 +360,12 @@ cdef extern from "flint_wrap.h": # Set `g` to `\operatorname{gcd}(a,b)` as per :func:`fmpq_gcd` and also compute `\overline{a} = a/g` and `\overline{b} = b/g`. # Unlike :func:`fmpq_gcd`, this function requires canonical inputs. - void _fmpq_add_small(fmpz_t rnum, fmpz_t rden, long p1, unsigned long q1, long p2, unsigned long q2) + void _fmpq_add_small(fmpz_t rnum, fmpz_t rden, slong p1, ulong q1, slong p2, ulong q2) # Sets ``(rnum, rden)`` to the sum of ``(p1, q1)`` and ``(p2, q2)``. # Assumes that ``(p1, q1)`` and ``(p2, q2)`` are in canonical form # and that all inputs are between ``COEFF_MIN`` and ``COEFF_MAX``. - void _fmpq_mul_small(fmpz_t rnum, fmpz_t rden, long p1, unsigned long q1, long p2, unsigned long q2) + void _fmpq_mul_small(fmpz_t rnum, fmpz_t rden, slong p1, ulong q1, slong p2, ulong q2) # Sets ``(rnum, rden)`` to the product of ``(p1, q1)`` and ``(p2, q2)``. # Assumes that ``(p1, q1)`` and ``(p2, q2)`` are in canonical form # and that all inputs are between ``COEFF_MIN`` and ``COEFF_MAX``. @@ -451,8 +451,8 @@ cdef extern from "flint_wrap.h": # The endpoints `l` and `r` do not need to be reduced, but their denominators do need to be positive. # `x` will always be returned in canonical form. A canonical fraction `a_1/b_1` is defined to be simpler than `a_2/b_2` iff `b_1 0`, then ``rem`` will be canonical. # Therefore, applications relying on canonical ``fmpq_t``'s should not call this function with `n \le 0`. - void fmpq_set_cfrac(fmpq_t x, const fmpz * c, long n) + void fmpq_set_cfrac(fmpq_t x, const fmpz * c, slong n) # Sets `x` to the value of the continued fraction # .. math :: # x = c_0 + \cfrac{1}{c_1 + \cfrac{1}{c_2 + @@ -489,15 +489,15 @@ cdef extern from "flint_wrap.h": # This product is split in half recursively to balance the size # of the coefficients. - long fmpq_cfrac_bound(const fmpq_t x) + slong fmpq_cfrac_bound(const fmpq_t x) # Returns an upper bound for the number of terms in the continued # fraction expansion of `x`. The computed bound is not necessarily sharp. # We use the fact that the smallest denominator # that can give a continued fraction of length `n` is the Fibonacci # number `F_{n+1}`. - void _fmpq_harmonic_ui(fmpz_t num, fmpz_t den, unsigned long n) - void fmpq_harmonic_ui(fmpq_t x, unsigned long n) + void _fmpq_harmonic_ui(fmpz_t num, fmpz_t den, ulong n) + void fmpq_harmonic_ui(fmpq_t x, ulong n) # Computes the harmonic number `H_n = 1 + 1/2 + 1/3 + \dotsb + 1/n`. # Table lookup is used for `H_n` whose numerator and denominator # fit in single limb. For larger `n`, a divide and conquer strategy is used. diff --git a/src/sage/libs/flint/fmpq_mat.pxd b/src/sage/libs/flint/fmpq_mat.pxd index ff46f4a31b9..0f56efaf4ab 100644 --- a/src/sage/libs/flint/fmpq_mat.pxd +++ b/src/sage/libs/flint/fmpq_mat.pxd @@ -12,7 +12,7 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void fmpq_mat_init(fmpq_mat_t mat, long rows, long cols) + void fmpq_mat_init(fmpq_mat_t mat, slong rows, slong cols) # Initialises a matrix with the given number of rows and columns for use. void fmpq_mat_init_set(fmpq_mat_t mat1, const fmpq_mat_t mat2) @@ -30,28 +30,28 @@ cdef extern from "flint_wrap.h": # Swaps two matrices by swapping the individual entries rather than swapping # the contents of the structs. - fmpq * fmpq_mat_entry(const fmpq_mat_t mat, long i, long j) + fmpq * fmpq_mat_entry(const fmpq_mat_t mat, slong i, slong j) # Gives a reference to the entry at row ``i`` and column ``j``. # The reference can be passed as an input or output variable to any # ``fmpq`` function for direct manipulation of the matrix element. # No bounds checking is performed. - fmpz * fmpq_mat_entry_num(const fmpq_mat_t mat, long i, long j) + fmpz * fmpq_mat_entry_num(const fmpq_mat_t mat, slong i, slong j) # Gives a reference to the numerator of the entry at row ``i`` and # column ``j``. The reference can be passed as an input or output # variable to any ``fmpz`` function for direct manipulation of the # matrix element. No bounds checking is performed. - fmpz * fmpq_mat_entry_den(const fmpq_mat_t mat, long i, long j) + fmpz * fmpq_mat_entry_den(const fmpq_mat_t mat, slong i, slong j) # Gives a reference to the denominator of the entry at row ``i`` and # column ``j``. The reference can be passed as an input or output # variable to any ``fmpz`` function for direct manipulation of the # matrix element. No bounds checking is performed. - long fmpq_mat_nrows(const fmpq_mat_t mat) + slong fmpq_mat_nrows(const fmpq_mat_t mat) # Return the number of rows of the matrix ``mat``. - long fmpq_mat_ncols(const fmpq_mat_t mat) + slong fmpq_mat_ncols(const fmpq_mat_t mat) # Return the number of columns of the matrix ``mat``. void fmpq_mat_set(fmpq_mat_t dest, const fmpq_mat_t src) @@ -71,20 +71,20 @@ cdef extern from "flint_wrap.h": # Sets the matrix ``rop`` to the transpose of the matrix ``op``, # assuming that their dimensions are compatible. - void fmpq_mat_swap_rows(fmpq_mat_t mat, long * perm, long r, long s) + void fmpq_mat_swap_rows(fmpq_mat_t mat, slong * perm, slong r, slong s) # Swaps rows ``r`` and ``s`` of ``mat``. If ``perm`` is non-``NULL``, the # permutation of the rows will also be applied to ``perm``. - void fmpq_mat_swap_cols(fmpq_mat_t mat, long * perm, long r, long s) + void fmpq_mat_swap_cols(fmpq_mat_t mat, slong * perm, slong r, slong s) # Swaps columns ``r`` and ``s`` of ``mat``. If ``perm`` is non-``NULL``, the # permutation of the columns will also be applied to ``perm``. - void fmpq_mat_invert_rows(fmpq_mat_t mat, long * perm) + void fmpq_mat_invert_rows(fmpq_mat_t mat, slong * perm) # Swaps rows ``i`` and ``r - i`` of ``mat`` for ``0 <= i < r/2``, where # ``r`` is the number of rows of ``mat``. If ``perm`` is non-``NULL``, the # permutation of the rows will also be applied to ``perm``. - void fmpq_mat_invert_cols(fmpq_mat_t mat, long * perm) + void fmpq_mat_invert_cols(fmpq_mat_t mat, slong * perm) # Swaps columns ``i`` and ``c - i`` of ``mat`` for ``0 <= i < c/2``, where # ``c`` is the number of columns of ``mat``. If ``perm`` is non-``NULL``, the # permutation of the columns will also be applied to ``perm``. @@ -131,7 +131,7 @@ cdef extern from "flint_wrap.h": # This is equivalent to applying ``fmpq_randtest`` to all entries # in the matrix. - void fmpq_mat_window_init(fmpq_mat_t window, const fmpq_mat_t mat, long r1, long c1, long r2, long c2) + void fmpq_mat_window_init(fmpq_mat_t window, const fmpq_mat_t mat, slong r1, slong c1, slong r2, slong c2) # Initializes the matrix ``window`` to be an ``r2 - r1`` by # ``c2 - c1`` submatrix of ``mat`` whose ``(0,0)`` entry # is the ``(r1, c1)`` entry of ``mat``. The memory for the @@ -260,18 +260,18 @@ cdef extern from "flint_wrap.h": # an integer matrix. This function works efficiently by clearing # denominators of ``B``. - void fmpq_mat_mul_fmpq_vec(fmpq * c, const fmpq_mat_t A, const fmpq * b, long blen) - void fmpq_mat_mul_fmpz_vec(fmpq * c, const fmpq_mat_t A, const fmpz * b, long blen) - void fmpq_mat_mul_fmpq_vec_ptr(fmpq * const * c, const fmpq_mat_t A, const fmpq * const * b, long blen) - void fmpq_mat_mul_fmpz_vec_ptr(fmpq * const * c, const fmpq_mat_t A, const fmpz * const * b, long blen) + void fmpq_mat_mul_fmpq_vec(fmpq * c, const fmpq_mat_t A, const fmpq * b, slong blen) + void fmpq_mat_mul_fmpz_vec(fmpq * c, const fmpq_mat_t A, const fmpz * b, slong blen) + void fmpq_mat_mul_fmpq_vec_ptr(fmpq * const * c, const fmpq_mat_t A, const fmpq * const * b, slong blen) + void fmpq_mat_mul_fmpz_vec_ptr(fmpq * const * c, const fmpq_mat_t A, const fmpz * const * b, slong blen) # Compute a matrix-vector product of ``A`` and ``(b, blen)`` and store the result in ``c``. # The vector ``(b, blen)`` is either truncated or zero-extended to the number of columns of ``A``. # The number entries written to ``c`` is always equal to the number of rows of ``A``. - void fmpq_mat_fmpq_vec_mul(fmpq * c, const fmpq * a, long alen, const fmpq_mat_t B) - void fmpq_mat_fmpz_vec_mul(fmpq * c, const fmpz * a, long alen, const fmpq_mat_t B) - void fmpq_mat_fmpq_vec_mul_ptr(fmpq * const * c, const fmpq * const * a, long alen, const fmpq_mat_t B) - void fmpq_mat_fmpz_vec_mul_ptr(fmpq * const * c, const fmpz * const * a, long alen, const fmpq_mat_t B) + void fmpq_mat_fmpq_vec_mul(fmpq * c, const fmpq * a, slong alen, const fmpq_mat_t B) + void fmpq_mat_fmpz_vec_mul(fmpq * c, const fmpz * a, slong alen, const fmpq_mat_t B) + void fmpq_mat_fmpq_vec_mul_ptr(fmpq * const * c, const fmpq * const * a, slong alen, const fmpq_mat_t B) + void fmpq_mat_fmpz_vec_mul_ptr(fmpq * const * c, const fmpz * const * a, slong alen, const fmpq_mat_t B) # Compute a vector-matrix product of ``(a, alen)`` and ``B`` and and store the result in ``c``. # The vector ``(a, alen)`` is either truncated or zero-extended to the number of rows of ``B``. # The number entries written to ``c`` is always equal to the number of columns of ``B``. @@ -331,7 +331,7 @@ cdef extern from "flint_wrap.h": # Sets ``B`` to the inverse matrix of ``A`` and returns nonzero. # Returns zero if ``A`` is singular. ``A`` must be a square matrix. - int fmpq_mat_pivot(long * perm, fmpq_mat_t mat, long r, long c) + int fmpq_mat_pivot(slong * perm, fmpq_mat_t mat, slong r, slong c) # Helper function for row reduction. Returns 1 if the entry of ``mat`` # at row `r` and column `c` is nonzero. Otherwise searches for a nonzero # entry in the same column among rows `r+1, r+2, \ldots`. If a nonzero @@ -339,18 +339,18 @@ cdef extern from "flint_wrap.h": # entries in ``perm`` (unless ``NULL``) and returns -1. If no # nonzero pivot entry is found, leaves the inputs unchanged and returns 0. - long fmpq_mat_rref_classical(fmpq_mat_t B, const fmpq_mat_t A) + slong fmpq_mat_rref_classical(fmpq_mat_t B, const fmpq_mat_t A) # Sets ``B`` to the reduced row echelon form of ``A`` and returns # the rank. Performs Gauss-Jordan elimination directly over the rational # numbers. This algorithm is usually inefficient and is mainly intended # to be used for testing purposes. - long fmpq_mat_rref_fraction_free(fmpq_mat_t B, const fmpq_mat_t A) + slong fmpq_mat_rref_fraction_free(fmpq_mat_t B, const fmpq_mat_t A) # Sets ``B`` to the reduced row echelon form of ``A`` and returns # the rank. Clears denominators and performs fraction-free Gauss-Jordan # elimination using ``fmpz_mat`` functions. - long fmpq_mat_rref(fmpq_mat_t B, const fmpq_mat_t A) + slong fmpq_mat_rref(fmpq_mat_t B, const fmpq_mat_t A) # Sets ``B`` to the reduced row echelon form of ``A`` and returns # the rank. This function automatically chooses between the classical and # fraction-free algorithms depending on the size of the matrix. @@ -361,7 +361,7 @@ cdef extern from "flint_wrap.h": # `S' = \{b_1, b_2, \ldots ,b_n\}` (as the columns of the `m \times n` matrix # ``B``) that spans the same subspace of `\mathbb{Q}^m` as `S`. - void fmpq_mat_similarity(fmpq_mat_t A, long r, fmpq_t d) + void fmpq_mat_similarity(fmpq_mat_t A, slong r, fmpq_t d) # Applies a similarity transform to the `n\times n` matrix `M` in-place. # If `P` is the `n\times n` identity matrix the zero entries of whose row # `r` (`0`-indexed) have been replaced by `d`, this transform is equivalent @@ -377,7 +377,7 @@ cdef extern from "flint_wrap.h": # Set ``pol`` to the characteristic polynomial of the given `n\times n` # matrix. If ``mat`` is not square, an exception is raised. - long _fmpq_mat_minpoly(fmpz * coeffs, fmpz_t den, const fmpq_mat_t mat) + slong _fmpq_mat_minpoly(fmpz * coeffs, fmpz_t den, const fmpq_mat_t mat) # Set ``(coeffs, den)`` to the minimal polynomial of the given # `n\times n` matrix and return the length of the polynomial. diff --git a/src/sage/libs/flint/fmpq_mpoly.pxd b/src/sage/libs/flint/fmpq_mpoly.pxd index 9a8240d9b1b..1db7bd271ab 100644 --- a/src/sage/libs/flint/fmpq_mpoly.pxd +++ b/src/sage/libs/flint/fmpq_mpoly.pxd @@ -12,11 +12,11 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void fmpq_mpoly_ctx_init(fmpq_mpoly_ctx_t ctx, long nvars, const ordering_t ord) + void fmpq_mpoly_ctx_init(fmpq_mpoly_ctx_t ctx, slong nvars, const ordering_t ord) # Initialise a context object for a polynomial ring with the given number of variables and the given ordering. # The possibilities for the ordering are ``ORD_LEX``, ``ORD_DEGLEX`` and ``ORD_DEGREVLEX``. - long fmpq_mpoly_ctx_nvars(const fmpq_mpoly_ctx_t ctx) + slong fmpq_mpoly_ctx_nvars(const fmpq_mpoly_ctx_t ctx) # Return the number of variables used to initialize the context. ordering_t fmpq_mpoly_ctx_ord(const fmpq_mpoly_ctx_t ctx) @@ -28,21 +28,21 @@ cdef extern from "flint_wrap.h": void fmpq_mpoly_init(fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx) # Initialise *A* for use with the given and initialised context object. Its value is set to zero. - void fmpq_mpoly_init2(fmpq_mpoly_t A, long alloc, const fmpq_mpoly_ctx_t ctx) + void fmpq_mpoly_init2(fmpq_mpoly_t A, slong alloc, const fmpq_mpoly_ctx_t ctx) # Initialise *A* for use with the given and initialised context object. Its value is set to zero. # It is allocated with space for *alloc* terms and at least ``MPOLY_MIN_BITS`` bits for the exponents. - void fmpq_mpoly_init3(fmpq_mpoly_t A, long alloc, flint_bitcnt_t bits, const fmpq_mpoly_ctx_t ctx) + void fmpq_mpoly_init3(fmpq_mpoly_t A, slong alloc, flint_bitcnt_t bits, const fmpq_mpoly_ctx_t ctx) # Initialise *A* for use with the given and initialised context object. Its value is set to zero. # It is allocated with space for *alloc* terms and *bits* bits for the exponents. - void fmpq_mpoly_fit_length(fmpq_mpoly_t A, long len, const fmpq_mpoly_ctx_t ctx) + void fmpq_mpoly_fit_length(fmpq_mpoly_t A, slong len, const fmpq_mpoly_ctx_t ctx) # Ensure that *A* has space for at least *len* terms. void fmpq_mpoly_fit_bits(fmpq_mpoly_t A, flint_bitcnt_t bits, const fmpq_mpoly_ctx_t ctx) # Ensure that the exponent fields of *A* have at least *bits* bits. - void fmpq_mpoly_realloc(fmpq_mpoly_t A, long alloc, const fmpq_mpoly_ctx_t ctx) + void fmpq_mpoly_realloc(fmpq_mpoly_t A, slong alloc, const fmpq_mpoly_ctx_t ctx) # Reallocate *A* to have space for *alloc* terms. # Assumes the current length of the polynomial is not greater than *alloc*. @@ -64,10 +64,10 @@ cdef extern from "flint_wrap.h": # The operations ``+``, ``-``, ``*``, and ``/`` are permitted along with integers and the variables in ``x``. The character ``^`` must be immediately followed by the (integer) exponent. # If any division is not exact, parsing fails. - void fmpq_mpoly_gen(fmpq_mpoly_t A, long var, const fmpq_mpoly_ctx_t ctx) + void fmpq_mpoly_gen(fmpq_mpoly_t A, slong var, const fmpq_mpoly_ctx_t ctx) # Set *A* to the variable of index *var*, where ``var = 0`` corresponds to the variable with the most significance with respect to the ordering. - int fmpq_mpoly_is_gen(const fmpq_mpoly_t A, long var, const fmpq_mpoly_ctx_t ctx) + int fmpq_mpoly_is_gen(const fmpq_mpoly_t A, slong var, const fmpq_mpoly_ctx_t ctx) # If `var \ge 0`, return `1` if *A* is equal to the `var`-th generator, otherwise return `0`. # If `var < 0`, return `1` if the polynomial is equal to any generator, otherwise return `0`. @@ -89,8 +89,8 @@ cdef extern from "flint_wrap.h": void fmpq_mpoly_set_fmpq(fmpq_mpoly_t A, const fmpq_t c, const fmpq_mpoly_ctx_t ctx) void fmpq_mpoly_set_fmpz(fmpq_mpoly_t A, const fmpz_t c, const fmpq_mpoly_ctx_t ctx) - void fmpq_mpoly_set_ui(fmpq_mpoly_t A, unsigned long c, const fmpq_mpoly_ctx_t ctx) - void fmpq_mpoly_set_si(fmpq_mpoly_t A, long c, const fmpq_mpoly_ctx_t ctx) + void fmpq_mpoly_set_ui(fmpq_mpoly_t A, ulong c, const fmpq_mpoly_ctx_t ctx) + void fmpq_mpoly_set_si(fmpq_mpoly_t A, slong c, const fmpq_mpoly_ctx_t ctx) # Set *A* to the constant *c*. void fmpq_mpoly_zero(fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx) @@ -101,8 +101,8 @@ cdef extern from "flint_wrap.h": int fmpq_mpoly_equal_fmpq(const fmpq_mpoly_t A, const fmpq_t c, const fmpq_mpoly_ctx_t ctx) int fmpq_mpoly_equal_fmpz(const fmpq_mpoly_t A, const fmpz_t c, const fmpq_mpoly_ctx_t ctx) - int fmpq_mpoly_equal_ui(const fmpq_mpoly_t A, unsigned long c, const fmpq_mpoly_ctx_t ctx) - int fmpq_mpoly_equal_si(const fmpq_mpoly_t A, long c, const fmpq_mpoly_ctx_t ctx) + int fmpq_mpoly_equal_ui(const fmpq_mpoly_t A, ulong c, const fmpq_mpoly_ctx_t ctx) + int fmpq_mpoly_equal_si(const fmpq_mpoly_t A, slong c, const fmpq_mpoly_ctx_t ctx) # Return `1` if *A* is equal to the constant *c*, else return `0`. int fmpq_mpoly_is_zero(const fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx) @@ -115,12 +115,12 @@ cdef extern from "flint_wrap.h": # Return `1` if the degrees of *A* with respect to each variable fit into an ``slong``, otherwise return `0`. void fmpq_mpoly_degrees_fmpz(fmpz ** degs, const fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx) - void fmpq_mpoly_degrees_si(long * degs, const fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx) + void fmpq_mpoly_degrees_si(slong * degs, const fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx) # Set *degs* to the degrees of *A* with respect to each variable. # If *A* is zero, all degrees are set to `-1`. - void fmpq_mpoly_degree_fmpz(fmpz_t deg, const fmpq_mpoly_t A, long var, const fmpq_mpoly_ctx_t ctx) - long fmpq_mpoly_degree_si(const fmpq_mpoly_t A, long var, const fmpq_mpoly_ctx_t ctx) + void fmpq_mpoly_degree_fmpz(fmpz_t deg, const fmpq_mpoly_t A, slong var, const fmpq_mpoly_ctx_t ctx) + slong fmpq_mpoly_degree_si(const fmpq_mpoly_t A, slong var, const fmpq_mpoly_ctx_t ctx) # Either return or set *deg* to the degree of *A* with respect to the variable of index *var*. # If *A* is zero, the degree is defined to be `-1`. @@ -128,7 +128,7 @@ cdef extern from "flint_wrap.h": # Return `1` if the total degree of *A* fits into an ``slong``, otherwise return `0`. void fmpq_mpoly_total_degree_fmpz(fmpz_t tdeg, const fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx) - long fmpq_mpoly_total_degree_si(const fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx) + slong fmpq_mpoly_total_degree_si(const fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx) # Either return or set *tdeg* to the total degree of *A*. # If *A* is zero, the total degree is defined to be `-1`. @@ -147,14 +147,14 @@ cdef extern from "flint_wrap.h": # This function throws if *M* is not a monomial. void fmpq_mpoly_get_coeff_fmpq_fmpz(fmpq_t c, const fmpq_mpoly_t A, fmpz * const * exp, const fmpq_mpoly_ctx_t ctx) - void fmpq_mpoly_get_coeff_fmpq_ui(fmpq_t c, const fmpq_mpoly_t A, const unsigned long * exp, const fmpq_mpoly_ctx_t ctx) + void fmpq_mpoly_get_coeff_fmpq_ui(fmpq_t c, const fmpq_mpoly_t A, const ulong * exp, const fmpq_mpoly_ctx_t ctx) # Set *c* to the coefficient of the monomial with exponent *exp*. void fmpq_mpoly_set_coeff_fmpq_fmpz(fmpq_mpoly_t A, const fmpq_t c, fmpz * const * exp, const fmpq_mpoly_ctx_t ctx) - void fmpq_mpoly_set_coeff_fmpq_ui(fmpq_mpoly_t A, const fmpq_t c, const unsigned long * exp, const fmpq_mpoly_ctx_t ctx) + void fmpq_mpoly_set_coeff_fmpq_ui(fmpq_mpoly_t A, const fmpq_t c, const ulong * exp, const fmpq_mpoly_ctx_t ctx) # Set the coefficient of the monomial with exponent *exp* to *c*. - void fmpq_mpoly_get_coeff_vars_ui(fmpq_mpoly_t C, const fmpq_mpoly_t A, const long * vars, const unsigned long * exps, long length, const fmpq_mpoly_ctx_t ctx) + void fmpq_mpoly_get_coeff_vars_ui(fmpq_mpoly_t C, const fmpq_mpoly_t A, const slong * vars, const ulong * exps, slong length, const fmpq_mpoly_ctx_t ctx) # Set *C* to the coefficient of *A* with respect to the variables in *vars* with powers in the corresponding array *exps*. # Both *vars* and *exps* point to array of length *length*. It is assumed that `0 < length \le nvars(A)` and that the variables in *vars* are distinct. @@ -168,7 +168,7 @@ cdef extern from "flint_wrap.h": fmpz_mpoly_struct * fmpq_mpoly_zpoly_ref(fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx) # Return a reference to the integer polynomial of *A*. - fmpz * fmpq_mpoly_zpoly_term_coeff_ref(fmpq_mpoly_t A, long i, const fmpq_mpoly_ctx_t ctx) + fmpz * fmpq_mpoly_zpoly_term_coeff_ref(fmpq_mpoly_t A, slong i, const fmpq_mpoly_ctx_t ctx) # Return a reference to the coefficient of index *i* of the integer polynomial of *A*. int fmpq_mpoly_is_canonical(const fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx) @@ -179,57 +179,57 @@ cdef extern from "flint_wrap.h": # (2) both ``content`` and ``zpoly`` are nonzero and canonical and ``zpoly`` is reduced. # A nonzero ``zpoly`` is considered reduced when the coefficients have GCD one and the leading coefficient is positive. - long fmpq_mpoly_length(const fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx) + slong fmpq_mpoly_length(const fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx) # Return the number of terms stored in *A*. # If the polynomial is in canonical form, this will be the number of nonzero coefficients. - void fmpq_mpoly_resize(fmpq_mpoly_t A, long new_length, const fmpq_mpoly_ctx_t ctx) + void fmpq_mpoly_resize(fmpq_mpoly_t A, slong new_length, const fmpq_mpoly_ctx_t ctx) # Set the length of *A* to ``new_length``. # Terms are either deleted from the end, or new zero terms are appended. - void fmpq_mpoly_get_term_coeff_fmpq(fmpq_t c, const fmpq_mpoly_t A, long i, const fmpq_mpoly_ctx_t ctx) + void fmpq_mpoly_get_term_coeff_fmpq(fmpq_t c, const fmpq_mpoly_t A, slong i, const fmpq_mpoly_ctx_t ctx) # Set *c* to coefficient of index *i* - void fmpq_mpoly_set_term_coeff_fmpq(fmpq_mpoly_t A, long i, const fmpq_t c, const fmpq_mpoly_ctx_t ctx) + void fmpq_mpoly_set_term_coeff_fmpq(fmpq_mpoly_t A, slong i, const fmpq_t c, const fmpq_mpoly_ctx_t ctx) # Set the coefficient of index *i* to *c*. - int fmpq_mpoly_term_exp_fits_si(const fmpq_mpoly_t A, long i, const fmpq_mpoly_ctx_t ctx) - int fmpq_mpoly_term_exp_fits_ui(const fmpq_mpoly_t A, long i, const fmpq_mpoly_ctx_t ctx) + int fmpq_mpoly_term_exp_fits_si(const fmpq_mpoly_t A, slong i, const fmpq_mpoly_ctx_t ctx) + int fmpq_mpoly_term_exp_fits_ui(const fmpq_mpoly_t A, slong i, const fmpq_mpoly_ctx_t ctx) # Return `1` if all entries of the exponent vector of the term of index *i* fit into an ``slong`` (resp. a ``ulong``). Otherwise, return `0`. - void fmpq_mpoly_get_term_exp_fmpz(fmpz ** exps, const fmpq_mpoly_t A, long i, const fmpq_mpoly_ctx_t ctx) - void fmpq_mpoly_get_term_exp_ui(unsigned long * exps, const fmpq_mpoly_t A, long i, const fmpq_mpoly_ctx_t ctx) - void fmpq_mpoly_get_term_exp_si(long * exps, const fmpq_mpoly_t A, long i, const fmpq_mpoly_ctx_t ctx) + void fmpq_mpoly_get_term_exp_fmpz(fmpz ** exps, const fmpq_mpoly_t A, slong i, const fmpq_mpoly_ctx_t ctx) + void fmpq_mpoly_get_term_exp_ui(ulong * exps, const fmpq_mpoly_t A, slong i, const fmpq_mpoly_ctx_t ctx) + void fmpq_mpoly_get_term_exp_si(slong * exps, const fmpq_mpoly_t A, slong i, const fmpq_mpoly_ctx_t ctx) # Set *exp* to the exponent vector of the term of index *i*. # The ``_ui`` (resp. ``_si``) version throws if any entry does not fit into a ``ulong`` (resp. ``slong``). - unsigned long fmpq_mpoly_get_term_var_exp_ui(const fmpq_mpoly_t A, long i, long var, const fmpq_mpoly_ctx_t ctx) - long fmpq_mpoly_get_term_var_exp_si(const fmpq_mpoly_t A, long i, long var, const fmpq_mpoly_ctx_t ctx) + ulong fmpq_mpoly_get_term_var_exp_ui(const fmpq_mpoly_t A, slong i, slong var, const fmpq_mpoly_ctx_t ctx) + slong fmpq_mpoly_get_term_var_exp_si(const fmpq_mpoly_t A, slong i, slong var, const fmpq_mpoly_ctx_t ctx) # Return the exponent of the variable *var* of the term of index *i*. # This function throws if the exponent does not fit into a ``ulong`` (resp. ``slong``). - void fmpq_mpoly_set_term_exp_fmpz(fmpq_mpoly_t A, long i, fmpz * const * exps, const fmpq_mpoly_ctx_t ctx) - void fmpq_mpoly_set_term_exp_ui(fmpq_mpoly_t A, long i, const unsigned long * exps, const fmpq_mpoly_ctx_t ctx) + void fmpq_mpoly_set_term_exp_fmpz(fmpq_mpoly_t A, slong i, fmpz * const * exps, const fmpq_mpoly_ctx_t ctx) + void fmpq_mpoly_set_term_exp_ui(fmpq_mpoly_t A, slong i, const ulong * exps, const fmpq_mpoly_ctx_t ctx) # Set the exponent vector of the term of index *i* to *exp*. - void fmpq_mpoly_get_term(fmpq_mpoly_t M, const fmpq_mpoly_t A, long i, const fmpq_mpoly_ctx_t ctx) + void fmpq_mpoly_get_term(fmpq_mpoly_t M, const fmpq_mpoly_t A, slong i, const fmpq_mpoly_ctx_t ctx) # Set *M* to the term of index *i* in *A*. - void fmpq_mpoly_get_term_monomial(fmpq_mpoly_t M, const fmpq_mpoly_t A, long i, const fmpq_mpoly_ctx_t ctx) + void fmpq_mpoly_get_term_monomial(fmpq_mpoly_t M, const fmpq_mpoly_t A, slong i, const fmpq_mpoly_ctx_t ctx) # Set *M* to the monomial of the term of index *i* in *A*. The coefficient of *M* will be one. void fmpq_mpoly_push_term_fmpq_fmpz(fmpq_mpoly_t A, const fmpq_t c, fmpz * const * exp, const fmpq_mpoly_ctx_t ctx) void fmpq_mpoly_push_term_fmpq_ffmpz(fmpq_mpoly_t A, const fmpq_t c, const fmpz * exp, const fmpq_mpoly_ctx_t ctx) void fmpq_mpoly_push_term_fmpz_fmpz(fmpq_mpoly_t A, const fmpz_t c, fmpz * const * exp, const fmpq_mpoly_ctx_t ctx) void fmpq_mpoly_push_term_fmpz_ffmpz(fmpq_mpoly_t A, const fmpz_t c, const fmpz * exp, const fmpq_mpoly_ctx_t ctx) - void fmpq_mpoly_push_term_ui_fmpz(fmpq_mpoly_t A, unsigned long c, fmpz * const * exp, const fmpq_mpoly_ctx_t ctx) - void fmpq_mpoly_push_term_ui_ffmpz(fmpq_mpoly_t A, unsigned long c, const fmpz * exp, const fmpq_mpoly_ctx_t ctx) - void fmpq_mpoly_push_term_si_fmpz(fmpq_mpoly_t A, long c, fmpz * const * exp, const fmpq_mpoly_ctx_t ctx) - void fmpq_mpoly_push_term_si_ffmpz(fmpq_mpoly_t A, long c, const fmpz * exp, const fmpq_mpoly_ctx_t ctx) - void fmpq_mpoly_push_term_fmpq_ui(fmpq_mpoly_t A, const fmpq_t c, const unsigned long * exp, const fmpq_mpoly_ctx_t ctx) - void fmpq_mpoly_push_term_fmpz_ui(fmpq_mpoly_t A, const fmpz_t c, const unsigned long * exp, const fmpq_mpoly_ctx_t ctx) - void fmpq_mpoly_push_term_ui_ui(fmpq_mpoly_t A, unsigned long c, const unsigned long * exp, const fmpq_mpoly_ctx_t ctx) - void fmpq_mpoly_push_term_si_ui(fmpq_mpoly_t A, long c, const unsigned long * exp, const fmpq_mpoly_ctx_t ctx) + void fmpq_mpoly_push_term_ui_fmpz(fmpq_mpoly_t A, ulong c, fmpz * const * exp, const fmpq_mpoly_ctx_t ctx) + void fmpq_mpoly_push_term_ui_ffmpz(fmpq_mpoly_t A, ulong c, const fmpz * exp, const fmpq_mpoly_ctx_t ctx) + void fmpq_mpoly_push_term_si_fmpz(fmpq_mpoly_t A, slong c, fmpz * const * exp, const fmpq_mpoly_ctx_t ctx) + void fmpq_mpoly_push_term_si_ffmpz(fmpq_mpoly_t A, slong c, const fmpz * exp, const fmpq_mpoly_ctx_t ctx) + void fmpq_mpoly_push_term_fmpq_ui(fmpq_mpoly_t A, const fmpq_t c, const ulong * exp, const fmpq_mpoly_ctx_t ctx) + void fmpq_mpoly_push_term_fmpz_ui(fmpq_mpoly_t A, const fmpz_t c, const ulong * exp, const fmpq_mpoly_ctx_t ctx) + void fmpq_mpoly_push_term_ui_ui(fmpq_mpoly_t A, ulong c, const ulong * exp, const fmpq_mpoly_ctx_t ctx) + void fmpq_mpoly_push_term_si_ui(fmpq_mpoly_t A, slong c, const ulong * exp, const fmpq_mpoly_ctx_t ctx) # Append a term to *A* with coefficient *c* and exponent vector *exp*. # This function should run in constant average time if the terms pushed have bounded denominator. @@ -248,28 +248,28 @@ cdef extern from "flint_wrap.h": void fmpq_mpoly_reverse(fmpq_mpoly_t A, const fmpq_mpoly_t B, const fmpq_mpoly_ctx_t ctx) # Set *A* to the reversal of *B*. - void fmpq_mpoly_randtest_bound(fmpq_mpoly_t A, flint_rand_t state, long length, mp_limb_t coeff_bits, unsigned long exp_bound, 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) # Generate a random polynomial with length up to *length* and exponents in the range ``[0, exp_bound - 1]``. # The exponents of each variable are generated by calls to ``n_randint(state, exp_bound)``. - void fmpq_mpoly_randtest_bounds(fmpq_mpoly_t A, flint_rand_t state, long length, mp_limb_t coeff_bits, unsigned long * exp_bounds, 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) # Generate a random polynomial with length up to *length* and exponents in the range ``[0, exp_bounds[i] - 1]``. # The exponents of the variable of index *i* are generated by calls to ``n_randint(state, exp_bounds[i])``. - void fmpq_mpoly_randtest_bits(fmpq_mpoly_t A, flint_rand_t state, long length, mp_limb_t coeff_bits, mp_limb_t exp_bits, 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) # Generate a random polynomial with length up to *length* and exponents whose packed form does not exceed the given bit count. # The parameter ``coeff_bits`` to the three functions ``fmpq_mpoly_randtest_{bound|bounds|bits}`` is merely a suggestion for the approximate bit count of the resulting coefficients. 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, unsigned long c, const fmpq_mpoly_ctx_t ctx) - void fmpq_mpoly_add_si(fmpq_mpoly_t A, const fmpq_mpoly_t B, long 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) + void fmpq_mpoly_add_si(fmpq_mpoly_t A, const fmpq_mpoly_t B, slong c, const fmpq_mpoly_ctx_t ctx) # Set *A* to `B + c`. void fmpq_mpoly_sub_fmpq(fmpq_mpoly_t A, const fmpq_mpoly_t B, const fmpq_t c, const fmpq_mpoly_ctx_t ctx) void fmpq_mpoly_sub_fmpz(fmpq_mpoly_t A, const fmpq_mpoly_t B, const fmpz_t c, const fmpq_mpoly_ctx_t ctx) - void fmpq_mpoly_sub_ui(fmpq_mpoly_t A, const fmpq_mpoly_t B, unsigned long c, const fmpq_mpoly_ctx_t ctx) - void fmpq_mpoly_sub_si(fmpq_mpoly_t A, const fmpq_mpoly_t B, long c, const fmpq_mpoly_ctx_t ctx) + void fmpq_mpoly_sub_ui(fmpq_mpoly_t A, const fmpq_mpoly_t B, ulong c, const fmpq_mpoly_ctx_t ctx) + void fmpq_mpoly_sub_si(fmpq_mpoly_t A, const fmpq_mpoly_t B, slong c, const fmpq_mpoly_ctx_t ctx) # Set *A* to `B - c`. void fmpq_mpoly_add(fmpq_mpoly_t A, const fmpq_mpoly_t B, const fmpq_mpoly_t C, const fmpq_mpoly_ctx_t ctx) @@ -283,14 +283,14 @@ cdef extern from "flint_wrap.h": void fmpq_mpoly_scalar_mul_fmpq(fmpq_mpoly_t A, const fmpq_mpoly_t B, const fmpq_t c, const fmpq_mpoly_ctx_t ctx) void fmpq_mpoly_scalar_mul_fmpz(fmpq_mpoly_t A, const fmpq_mpoly_t B, const fmpz_t c, const fmpq_mpoly_ctx_t ctx) - void fmpq_mpoly_scalar_mul_ui(fmpq_mpoly_t A, const fmpq_mpoly_t B, unsigned long c, const fmpq_mpoly_ctx_t ctx) - void fmpq_mpoly_scalar_mul_si(fmpq_mpoly_t A, const fmpq_mpoly_t B, long c, const fmpq_mpoly_ctx_t ctx) + void fmpq_mpoly_scalar_mul_ui(fmpq_mpoly_t A, const fmpq_mpoly_t B, ulong c, const fmpq_mpoly_ctx_t ctx) + void fmpq_mpoly_scalar_mul_si(fmpq_mpoly_t A, const fmpq_mpoly_t B, slong c, const fmpq_mpoly_ctx_t ctx) # Set *A* to `B \times c`. void fmpq_mpoly_scalar_div_fmpq(fmpq_mpoly_t A, const fmpq_mpoly_t B, const fmpq_t c, const fmpq_mpoly_ctx_t ctx) void fmpq_mpoly_scalar_div_fmpz(fmpq_mpoly_t A, const fmpq_mpoly_t B, const fmpz_t c, const fmpq_mpoly_ctx_t ctx) - void fmpq_mpoly_scalar_div_ui(fmpq_mpoly_t A, const fmpq_mpoly_t B, unsigned long c, const fmpq_mpoly_ctx_t ctx) - void fmpq_mpoly_scalar_div_si(fmpq_mpoly_t A, const fmpq_mpoly_t B, long c, const fmpq_mpoly_ctx_t ctx) + void fmpq_mpoly_scalar_div_ui(fmpq_mpoly_t A, const fmpq_mpoly_t B, ulong c, const fmpq_mpoly_ctx_t ctx) + void fmpq_mpoly_scalar_div_si(fmpq_mpoly_t A, const fmpq_mpoly_t B, slong c, const fmpq_mpoly_ctx_t ctx) # Set *A* to `B/c`. void fmpq_mpoly_make_monic(fmpq_mpoly_t A, const fmpq_mpoly_t B, const fmpq_mpoly_ctx_t ctx) @@ -298,17 +298,17 @@ cdef extern from "flint_wrap.h": # This throws if *B* is zero. # All of these functions run quickly if *A* and *B* are aliased. - void fmpq_mpoly_derivative(fmpq_mpoly_t A, const fmpq_mpoly_t B, long var, const fmpq_mpoly_ctx_t ctx) + void fmpq_mpoly_derivative(fmpq_mpoly_t A, const fmpq_mpoly_t B, slong var, const fmpq_mpoly_ctx_t ctx) # Set *A* to the derivative of *B* with respect to the variable of index *var*. - void fmpq_mpoly_integral(fmpq_mpoly_t A, const fmpq_mpoly_t B, long var, const fmpq_mpoly_ctx_t ctx) + void fmpq_mpoly_integral(fmpq_mpoly_t A, const fmpq_mpoly_t B, slong var, const fmpq_mpoly_ctx_t ctx) # Set *A* to the integral with the fewest number of terms of *B* with respect to the variable of index *var*. int fmpq_mpoly_evaluate_all_fmpq(fmpq_t ev, const fmpq_mpoly_t A, fmpq * const * vals, const fmpq_mpoly_ctx_t ctx) # Set ``ev`` to the evaluation of *A* where the variables are replaced by the corresponding elements of the array ``vals``. # Return `1` for success and `0` for failure. - int fmpq_mpoly_evaluate_one_fmpq(fmpq_mpoly_t A, const fmpq_mpoly_t B, long var, const fmpq_t val, const fmpq_mpoly_ctx_t ctx) + int fmpq_mpoly_evaluate_one_fmpq(fmpq_mpoly_t A, const fmpq_mpoly_t B, slong var, const fmpq_t val, const fmpq_mpoly_ctx_t ctx) # Set *A* to the evaluation of *B* where the variable of index *var* is replaced by ``val``. # Return `1` for success and `0` for failure. @@ -323,7 +323,7 @@ cdef extern from "flint_wrap.h": # Neither *A* nor *B* is allowed to alias any other polynomial. # Return `1` for success and `0` for failure. - void fmpq_mpoly_compose_fmpq_mpoly_gen(fmpq_mpoly_t A, const fmpq_mpoly_t B, const long * c, const fmpq_mpoly_ctx_t ctxB, const fmpq_mpoly_ctx_t ctxAC) + void fmpq_mpoly_compose_fmpq_mpoly_gen(fmpq_mpoly_t A, const fmpq_mpoly_t B, const slong * c, const fmpq_mpoly_ctx_t ctxB, const fmpq_mpoly_ctx_t ctxAC) # Set *A* to the evaluation of *B* where the variable of index *i* in *ctxB* is replaced by the variable of index ``c[i]`` in *ctxAC*. # The length of the array *C* is the number of variables in *ctxB*. # If any ``c[i]`` is negative, the corresponding variable of *B* is replaced by zero. Otherwise, it is expected that ``c[i]`` is less than the number of variables in *ctxAC*. @@ -335,7 +335,7 @@ cdef extern from "flint_wrap.h": # Set *A* to *B* raised to the *k*-th power. # Return `1` for success and `0` for failure. - int fmpq_mpoly_pow_ui(fmpq_mpoly_t A, const fmpq_mpoly_t B, unsigned long k, const fmpq_mpoly_ctx_t ctx) + int fmpq_mpoly_pow_ui(fmpq_mpoly_t A, const fmpq_mpoly_t B, ulong k, const fmpq_mpoly_ctx_t ctx) # Set *A* to *B* raised to the *k*-th power. # Return `1` for success and `0` for failure. @@ -349,7 +349,7 @@ cdef extern from "flint_wrap.h": void fmpq_mpoly_divrem(fmpq_mpoly_t Q, fmpq_mpoly_t R, const fmpq_mpoly_t A, const fmpq_mpoly_t B, const fmpq_mpoly_ctx_t ctx) # Set *Q* and *R* to the quotient and remainder of *A* divided by *B*. - void fmpq_mpoly_divrem_ideal(fmpq_mpoly_struct ** Q, fmpq_mpoly_t R, const fmpq_mpoly_t A, fmpq_mpoly_struct * const * B, long len, const fmpq_mpoly_ctx_t ctx) + void fmpq_mpoly_divrem_ideal(fmpq_mpoly_struct ** Q, fmpq_mpoly_t R, const fmpq_mpoly_t A, fmpq_mpoly_struct * const * B, slong len, const fmpq_mpoly_ctx_t ctx) # This function is as per :func:`fmpq_mpoly_divrem` except that it takes an array of divisor polynomials *B* and it returns an array of quotient polynomials *Q*. # The number of divisor (and hence quotient) polynomials is given by *len*. @@ -360,7 +360,7 @@ cdef extern from "flint_wrap.h": # Set *M* to the GCD of the terms of *A*. # If *A* is zero, *M* will be zero. Otherwise, *M* will be a monomial with coefficient one. - int fmpq_mpoly_content_vars(fmpq_mpoly_t g, const fmpq_mpoly_t A, long * vars, long vars_length, const fmpq_mpoly_ctx_t ctx) + int fmpq_mpoly_content_vars(fmpq_mpoly_t g, const fmpq_mpoly_t A, slong * vars, slong vars_length, const fmpq_mpoly_ctx_t ctx) # Set *g* to the GCD of the coefficients of *A* when viewed as a polynomial in the variables *vars*. # Return `1` for success and `0` for failure. Upon success, *g* will be independent of the variables *vars*. @@ -378,10 +378,10 @@ cdef extern from "flint_wrap.h": int fmpq_mpoly_gcd_zippel2(fmpq_mpoly_t G, const fmpq_mpoly_t A, const fmpq_mpoly_t B, const fmpq_mpoly_ctx_t ctx) # Try to set *G* to the GCD of *A* and *B* using various algorithms. - int fmpq_mpoly_resultant(fmpq_mpoly_t R, const fmpq_mpoly_t A, const fmpq_mpoly_t B, long var, const fmpq_mpoly_ctx_t ctx) + int fmpq_mpoly_resultant(fmpq_mpoly_t R, const fmpq_mpoly_t A, const fmpq_mpoly_t B, slong var, const fmpq_mpoly_ctx_t ctx) # Try to set *R* to the resultant of *A* and *B* with respect to the variable of index *var*. - int fmpq_mpoly_discriminant(fmpq_mpoly_t D, const fmpq_mpoly_t A, long var, const fmpq_mpoly_ctx_t ctx) + int fmpq_mpoly_discriminant(fmpq_mpoly_t D, const fmpq_mpoly_t A, slong var, const fmpq_mpoly_ctx_t ctx) # Try to set *D* to the discriminant of *A* with respect to the variable of index *var*. int fmpq_mpoly_sqrt(fmpq_mpoly_t Q, const fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx) @@ -400,23 +400,23 @@ cdef extern from "flint_wrap.h": void fmpq_mpoly_univar_swap(fmpq_mpoly_univar_t A, fmpq_mpoly_univar_t B, const fmpq_mpoly_ctx_t ctx) # Swap *A* and *B*. - void fmpq_mpoly_to_univar(fmpq_mpoly_univar_t A, const fmpq_mpoly_t B, long var, const fmpq_mpoly_ctx_t ctx) + void fmpq_mpoly_to_univar(fmpq_mpoly_univar_t A, const fmpq_mpoly_t B, slong var, const fmpq_mpoly_ctx_t ctx) # Set *A* to a univariate form of *B* by pulling out the variable of index *var*. # The coefficients of *A* will still belong to the content *ctx* but will not depend on the variable of index *var*. - void fmpq_mpoly_from_univar(fmpq_mpoly_t A, const fmpq_mpoly_univar_t B, long var, const fmpq_mpoly_ctx_t ctx) + void fmpq_mpoly_from_univar(fmpq_mpoly_t A, const fmpq_mpoly_univar_t B, slong var, const fmpq_mpoly_ctx_t ctx) # Set *A* to the normal form of *B* by putting in the variable of index *var*. # This function is undefined if the coefficients of *B* depend on the variable of index *var*. int fmpq_mpoly_univar_degree_fits_si(const fmpq_mpoly_univar_t A, const fmpq_mpoly_ctx_t ctx) # Return `1` if the degree of *A* with respect to the main variable fits an ``slong``. Otherwise, return `0`. - long fmpq_mpoly_univar_length(const fmpq_mpoly_univar_t A, const fmpq_mpoly_ctx_t ctx) + slong fmpq_mpoly_univar_length(const fmpq_mpoly_univar_t A, const fmpq_mpoly_ctx_t ctx) # Return the number of terms in *A* with respect to the main variable. - long fmpq_mpoly_univar_get_term_exp_si(fmpq_mpoly_univar_t A, long i, const fmpq_mpoly_ctx_t ctx) + slong fmpq_mpoly_univar_get_term_exp_si(fmpq_mpoly_univar_t A, slong i, const fmpq_mpoly_ctx_t ctx) # Return the exponent of the term of index *i* of *A*. - void fmpq_mpoly_univar_get_term_coeff(fmpq_mpoly_t c, const fmpq_mpoly_univar_t A, long i, const fmpq_mpoly_ctx_t ctx) - void fmpq_mpoly_univar_swap_term_coeff(fmpq_mpoly_t c, fmpq_mpoly_univar_t A, long i, const fmpq_mpoly_ctx_t ctx) + void fmpq_mpoly_univar_get_term_coeff(fmpq_mpoly_t c, const fmpq_mpoly_univar_t A, slong i, const fmpq_mpoly_ctx_t ctx) + void fmpq_mpoly_univar_swap_term_coeff(fmpq_mpoly_t c, fmpq_mpoly_univar_t A, slong i, const fmpq_mpoly_ctx_t ctx) # Set (resp. swap) *c* to (resp. with) the coefficient of the term of index *i* of *A*. diff --git a/src/sage/libs/flint/fmpq_mpoly_factor.pxd b/src/sage/libs/flint/fmpq_mpoly_factor.pxd index c64b39474e0..aba63e6f731 100644 --- a/src/sage/libs/flint/fmpq_mpoly_factor.pxd +++ b/src/sage/libs/flint/fmpq_mpoly_factor.pxd @@ -21,17 +21,17 @@ cdef extern from "flint_wrap.h": void fmpq_mpoly_factor_swap(fmpq_mpoly_factor_t f, fmpq_mpoly_factor_t g, const fmpq_mpoly_ctx_t ctx) # Efficiently swap *f* and *g*. - long fmpq_mpoly_factor_length(const fmpq_mpoly_factor_t f, const fmpq_mpoly_ctx_t ctx) + slong fmpq_mpoly_factor_length(const fmpq_mpoly_factor_t f, const fmpq_mpoly_ctx_t ctx) # Return the length of the product in *f*. void fmpq_mpoly_factor_get_constant_fmpq(fmpq_t c, const fmpq_mpoly_factor_t f, const fmpq_mpoly_ctx_t ctx) # Set *c* to the constant of *f*. - void fmpq_mpoly_factor_get_base(fmpq_mpoly_t B, const fmpq_mpoly_factor_t f, long i, const fmpq_mpoly_ctx_t ctx) - void fmpq_mpoly_factor_swap_base(fmpq_mpoly_t B, fmpq_mpoly_factor_t f, long i, const fmpq_mpoly_ctx_t ctx) + void fmpq_mpoly_factor_get_base(fmpq_mpoly_t B, const fmpq_mpoly_factor_t f, slong i, const fmpq_mpoly_ctx_t ctx) + void fmpq_mpoly_factor_swap_base(fmpq_mpoly_t B, fmpq_mpoly_factor_t f, slong i, const fmpq_mpoly_ctx_t ctx) # Set (resp. swap) *B* to (resp. with) the base of the term of index *i* in *A*. - long fmpq_mpoly_factor_get_exp_si(fmpq_mpoly_factor_t f, long i, const fmpq_mpoly_ctx_t ctx) + slong fmpq_mpoly_factor_get_exp_si(fmpq_mpoly_factor_t f, slong i, const fmpq_mpoly_ctx_t ctx) # Return the exponent of the term of index *i* in *A*. It is assumed to fit an ``slong``. void fmpq_mpoly_factor_sort(fmpq_mpoly_factor_t f, const fmpq_mpoly_ctx_t ctx) diff --git a/src/sage/libs/flint/fmpq_poly.pxd b/src/sage/libs/flint/fmpq_poly.pxd index 7c18ee2e230..24c9ef46658 100644 --- a/src/sage/libs/flint/fmpq_poly.pxd +++ b/src/sage/libs/flint/fmpq_poly.pxd @@ -15,12 +15,12 @@ cdef extern from "flint_wrap.h": void fmpq_poly_init(fmpq_poly_t poly) # Initialises the polynomial for use. The length is set to zero. - void fmpq_poly_init2(fmpq_poly_t poly, long alloc) + void fmpq_poly_init2(fmpq_poly_t poly, slong alloc) # Initialises the polynomial with space for at least ``alloc`` # coefficients and sets the length to zero. The ``alloc`` coefficients # are all set to zero. - void fmpq_poly_realloc(fmpq_poly_t poly, long alloc) + void fmpq_poly_realloc(fmpq_poly_t poly, slong alloc) # Reallocates the given polynomial to have space for ``alloc`` # coefficients. If ``alloc`` is zero then the polynomial is cleared # and then reinitialised. If the current length is greater than @@ -28,7 +28,7 @@ cdef extern from "flint_wrap.h": # ``alloc``. Note that this might leave the rational polynomial in # non-canonical form. - void fmpq_poly_fit_length(fmpq_poly_t poly, long len) + void fmpq_poly_fit_length(fmpq_poly_t poly, slong len) # If ``len`` is greater than the number of coefficients currently # allocated, then the polynomial is reallocated to have space for at # least ``len`` coefficients. No data is lost when calling this @@ -37,7 +37,7 @@ cdef extern from "flint_wrap.h": # least doubling the number of allocated coefficients when ``len`` # is larger than the number of coefficients currently allocated. - void _fmpq_poly_set_length(fmpq_poly_t poly, long len) + void _fmpq_poly_set_length(fmpq_poly_t poly, slong len) # Sets the length of the numerator polynomial to ``len``, demoting # coefficients beyond the new length. Note that this method does # not guarantee that the rational polynomial is in canonical form. @@ -52,7 +52,7 @@ cdef extern from "flint_wrap.h": # Note that this function does not guarantee the coprimality of the # numerator polynomial and the integer denominator. - void _fmpq_poly_canonicalise(fmpz * poly, fmpz_t den, long len) + void _fmpq_poly_canonicalise(fmpz * poly, fmpz_t den, slong len) # Puts ``(poly, den)`` of length ``len`` into canonical form. # It is assumed that the array ``poly`` contains a non-zero entry in # position ``len - 1`` whenever ``len > 0``. Assumes that ``den`` @@ -65,17 +65,17 @@ cdef extern from "flint_wrap.h": # coprime and that the denominator is positive. The canonical form of the # zero polynomial is a zero numerator polynomial and a one denominator. - int _fmpq_poly_is_canonical(const fmpz * poly, const fmpz_t den, long len) + int _fmpq_poly_is_canonical(const fmpz * poly, const fmpz_t den, slong len) # Returns whether the polynomial is in canonical form. int fmpq_poly_is_canonical(const fmpq_poly_t poly) # Returns whether the polynomial is in canonical form. - long fmpq_poly_degree(const fmpq_poly_t poly) + slong fmpq_poly_degree(const fmpq_poly_t poly) # Returns the degree of ``poly``, which is one less than its length, as # a ``slong``. - long fmpq_poly_length(const fmpq_poly_t poly) + slong fmpq_poly_length(const fmpq_poly_t poly) # Returns the length of ``poly``. fmpz * fmpq_poly_numref(fmpq_poly_t poly) @@ -98,18 +98,18 @@ cdef extern from "flint_wrap.h": void fmpq_poly_get_denominator(fmpz_t den, const fmpq_poly_t poly) # Sets ``res`` to the denominator of ``poly``. - void fmpq_poly_randtest(fmpq_poly_t f, flint_rand_t state, long len, flint_bitcnt_t bits) + void fmpq_poly_randtest(fmpq_poly_t f, flint_rand_t state, slong len, flint_bitcnt_t bits) # Sets `f` to a random polynomial with coefficients up to the given # length and where each coefficient has up to the given number of bits. # The coefficients are signed randomly. One must call # :func:`flint_randinit` before calling this function. - void fmpq_poly_randtest_unsigned(fmpq_poly_t f, flint_rand_t state, long len, flint_bitcnt_t bits) + void fmpq_poly_randtest_unsigned(fmpq_poly_t f, flint_rand_t state, slong len, flint_bitcnt_t bits) # Sets `f` to a random polynomial with coefficients up to the given length # and where each coefficient has up to the given number of bits. One must # call :func:`flint_randinit` before calling this function. - void fmpq_poly_randtest_not_zero(fmpq_poly_t f, flint_rand_t state, long len, flint_bitcnt_t bits) + void fmpq_poly_randtest_not_zero(fmpq_poly_t f, flint_rand_t state, slong len, flint_bitcnt_t bits) # As for :func:`fmpq_poly_randtest` except that ``len`` and ``bits`` # may not be zero and the polynomial generated is guaranteed not to be the # zero polynomial. One must call :func:`flint_randinit` before calling @@ -118,10 +118,10 @@ cdef extern from "flint_wrap.h": void fmpq_poly_set(fmpq_poly_t poly1, const fmpq_poly_t poly2) # Sets ``poly1`` to equal ``poly2``. - void fmpq_poly_set_si(fmpq_poly_t poly, long x) + void fmpq_poly_set_si(fmpq_poly_t poly, slong x) # Sets ``poly`` to the integer `x`. - void fmpq_poly_set_ui(fmpq_poly_t poly, unsigned long x) + void fmpq_poly_set_ui(fmpq_poly_t poly, ulong x) # Sets ``poly`` to the integer `x`. void fmpq_poly_set_fmpz(fmpq_poly_t poly, const fmpz_t x) @@ -151,7 +151,7 @@ cdef extern from "flint_wrap.h": # multiplied by the inverse of the denominator of ``op``. In this case it is # assumed that the reduction of the denominator of ``op`` is invertible. - int _fmpq_poly_set_str(fmpz * poly, fmpz_t den, const char * str, long len) + int _fmpq_poly_set_str(fmpz * poly, fmpz_t den, const char * str, slong len) # Sets ``(poly, den)`` to the polynomial specified by the # null-terminated string ``str`` of ``len`` coefficients. The input # format is a sequence of coefficients separated by one space. @@ -198,55 +198,55 @@ cdef extern from "flint_wrap.h": void fmpq_poly_swap(fmpq_poly_t poly1, fmpq_poly_t poly2) # Efficiently swaps the polynomials ``poly1`` and ``poly2``. - void fmpq_poly_truncate(fmpq_poly_t poly, long n) + void fmpq_poly_truncate(fmpq_poly_t poly, slong n) # If the current length of ``poly`` is greater than `n`, it is # truncated to the given length. Discarded coefficients are demoted, # but they are not necessarily set to zero. - void fmpq_poly_set_trunc(fmpq_poly_t res, const fmpq_poly_t poly, long n) + void fmpq_poly_set_trunc(fmpq_poly_t res, const fmpq_poly_t poly, slong n) # Sets ``res`` to a copy of ``poly``, truncated to length ``n``. - void fmpq_poly_get_slice(fmpq_poly_t rop, const fmpq_poly_t op, long i, long j) + void fmpq_poly_get_slice(fmpq_poly_t rop, const fmpq_poly_t op, slong i, slong j) # Returns the slice with coefficients from `x^i` (including) to # `x^j` (excluding). - void fmpq_poly_reverse(fmpq_poly_t res, const fmpq_poly_t poly, long n) + void fmpq_poly_reverse(fmpq_poly_t res, const fmpq_poly_t poly, slong n) # This function considers the polynomial ``poly`` to be of length `n`, # notionally truncating and zero padding if required, and reverses # the result. Since the function normalises its result ``res`` may be # of length less than `n`. - void fmpq_poly_get_coeff_fmpz(fmpz_t x, const fmpq_poly_t poly, long n) + void fmpq_poly_get_coeff_fmpz(fmpz_t x, const fmpq_poly_t poly, slong n) # Retrieves the `n`\th coefficient of the numerator of ``poly``. - void fmpq_poly_get_coeff_fmpq(fmpq_t x, const fmpq_poly_t poly, long n) + void fmpq_poly_get_coeff_fmpq(fmpq_t x, const fmpq_poly_t poly, slong n) # Retrieves the `n`\th coefficient of ``poly``, in lowest terms. - void fmpq_poly_set_coeff_si(fmpq_poly_t poly, long n, long x) + void fmpq_poly_set_coeff_si(fmpq_poly_t poly, slong n, slong x) # Sets the `n`\th coefficient in ``poly`` to the integer `x`. - void fmpq_poly_set_coeff_ui(fmpq_poly_t poly, long n, unsigned long x) + void fmpq_poly_set_coeff_ui(fmpq_poly_t poly, slong n, ulong x) # Sets the `n`\th coefficient in ``poly`` to the integer `x`. - void fmpq_poly_set_coeff_fmpz(fmpq_poly_t poly, long n, const fmpz_t x) + void fmpq_poly_set_coeff_fmpz(fmpq_poly_t poly, slong n, const fmpz_t x) # Sets the `n`\th coefficient in ``poly`` to the integer `x`. - void fmpq_poly_set_coeff_fmpq(fmpq_poly_t poly, long n, const fmpq_t x) + void fmpq_poly_set_coeff_fmpq(fmpq_poly_t poly, slong n, const fmpq_t x) # Sets the `n`\th coefficient in ``poly`` to the rational `x`. int fmpq_poly_equal(const fmpq_poly_t poly1, const fmpq_poly_t poly2) # Returns `1` if ``poly1`` is equal to ``poly2``, # otherwise returns `0`. - int _fmpq_poly_equal_trunc(const fmpz * poly1, const fmpz_t den1, long len1, const fmpz * poly2, const fmpz_t den2, long len2, long n) + int _fmpq_poly_equal_trunc(const fmpz * poly1, const fmpz_t den1, slong len1, const fmpz * poly2, const fmpz_t den2, slong len2, slong n) # Returns `1` if ``poly1`` and ``poly2`` notionally truncated to length # `n` are equal, otherwise returns `0`. - int fmpq_poly_equal_trunc(const fmpq_poly_t poly1, const fmpq_poly_t poly2, long n) + int fmpq_poly_equal_trunc(const fmpq_poly_t poly1, const fmpq_poly_t poly2, slong n) # Returns `1` if ``poly1`` and ``poly2`` notionally truncated to length # `n` are equal, otherwise returns `0`. - int _fmpq_poly_cmp(const fmpz * lpoly, const fmpz_t lden, const fmpz * rpoly, const fmpz_t rden, long len) + int _fmpq_poly_cmp(const fmpz * lpoly, const fmpz_t lden, const fmpz * rpoly, const fmpz_t rden, slong len) # Compares two non-zero polynomials, assuming they have the same length # ``len > 0``. # The polynomials are expected to be provided in canonical form. @@ -270,7 +270,7 @@ cdef extern from "flint_wrap.h": # Returns `1` if ``poly`` is the degree `1` polynomial `x`, otherwise returns # `0`. - void _fmpq_poly_add(fmpz * rpoly, fmpz_t rden, const fmpz * poly1, const fmpz_t den1, long len1, const fmpz * poly2, const fmpz_t den2, long len2) + void _fmpq_poly_add(fmpz * rpoly, fmpz_t rden, const fmpz * poly1, const fmpz_t den1, slong len1, const fmpz * poly2, const fmpz_t den2, slong len2) # Forms the sum ``(rpoly, rden)`` of ``(poly1, den1, len1)`` and # ``(poly2, den2, len2)``, placing the result into canonical form. # Assumes that ``rpoly`` is an array of length the maximum of @@ -280,7 +280,7 @@ cdef extern from "flint_wrap.h": # but ``(rpoly, rden)`` and ``(poly2, den2)`` may *not* # be aliased. - void _fmpq_poly_add_can(fmpz * rpoly, fmpz_t rden, const fmpz * poly1, const fmpz_t den1, long len1, const fmpz * poly2, const fmpz_t den2, long len2, int can) + void _fmpq_poly_add_can(fmpz * rpoly, fmpz_t rden, const fmpz * poly1, const fmpz_t den1, slong len1, const fmpz * poly2, const fmpz_t den2, slong len2, int can) # As per ``_fmpq_poly_add`` except that one can specify whether to # canonicalise the output or not. This function is intended to be used with # weak canonicalisation to prevent explosion in memory usage. It exists for @@ -296,26 +296,26 @@ cdef extern from "flint_wrap.h": # weak canonicalisation to prevent explosion in memory usage. It exists for # performance reasons. - void _fmpq_poly_add_series(fmpz * rpoly, fmpz_t rden, const fmpz * poly1, const fmpz_t den1, long len1, const fmpz * poly2, const fmpz_t den2, long len2, long n) + void _fmpq_poly_add_series(fmpz * rpoly, fmpz_t rden, const fmpz * poly1, const fmpz_t den1, slong len1, const fmpz * poly2, const fmpz_t den2, slong len2, slong n) # As per ``_fmpq_poly_add`` but the inputs are first notionally truncated # to length `n`. If `n` is less than ``len1`` or ``len2`` then the # output only needs space for `n` coefficients. We require `n \geq 0`. - void _fmpq_poly_add_series_can(fmpz * rpoly, fmpz_t rden, const fmpz * poly1, const fmpz_t den1, long len1, const fmpz * poly2, const fmpz_t den2, long len2, long n, int can) + void _fmpq_poly_add_series_can(fmpz * rpoly, fmpz_t rden, const fmpz * poly1, const fmpz_t den1, slong len1, const fmpz * poly2, const fmpz_t den2, slong len2, slong n, int can) # As per ``_fmpq_poly_add_can`` but the inputs are first notionally # truncated to length `n`. If `n` is less than ``len1`` or ``len2`` # then the output only needs space for `n` coefficients. We require # `n \geq 0`. - void fmpq_poly_add_series(fmpq_poly_t res, const fmpq_poly_t poly1, const fmpq_poly_t poly2, long n) + void fmpq_poly_add_series(fmpq_poly_t res, const fmpq_poly_t poly1, const fmpq_poly_t poly2, slong n) # As per ``fmpq_poly_add`` but the inputs are first notionally # truncated to length `n`. - void fmpq_poly_add_series_can(fmpq_poly_t res, const fmpq_poly_t poly1, const fmpq_poly_t poly2, long n, int can) + void fmpq_poly_add_series_can(fmpq_poly_t res, const fmpq_poly_t poly1, const fmpq_poly_t poly2, slong n, int can) # As per ``fmpq_poly_add_can`` but the inputs are first notionally # truncated to length `n`. - void _fmpq_poly_sub(fmpz * rpoly, fmpz_t rden, const fmpz * poly1, const fmpz_t den1, long len1, const fmpz * poly2, const fmpz_t den2, long len2) + void _fmpq_poly_sub(fmpz * rpoly, fmpz_t rden, const fmpz * poly1, const fmpz_t den1, slong len1, const fmpz * poly2, const fmpz_t den2, slong len2) # Forms the difference ``(rpoly, rden)`` of ``(poly1, den1, len1)`` # and ``(poly2, den2, len2)``, placing the result into canonical form. # Assumes that ``rpoly`` is an array of length the maximum of @@ -325,7 +325,7 @@ cdef extern from "flint_wrap.h": # but ``(rpoly, rden)`` and ``(poly2, den2, len2)`` may *not* be # aliased. - void _fmpq_poly_sub_can(fmpz * rpoly, fmpz_t rden, const fmpz * poly1, const fmpz_t den1, long len1, const fmpz * poly2, const fmpz_t den2, long len2, int can) + void _fmpq_poly_sub_can(fmpz * rpoly, fmpz_t rden, const fmpz * poly1, const fmpz_t den1, slong len1, const fmpz * poly2, const fmpz_t den2, slong len2, int can) # As per ``_fmpq_poly_sub`` except that one can specify whether to # canonicalise the output or not. This function is intended to be used with # weak canonicalisation to prevent explosion in memory usage. It exists for @@ -341,26 +341,26 @@ cdef extern from "flint_wrap.h": # weak canonicalisation to prevent explosion in memory usage. It exists for # performance reasons. - void _fmpq_poly_sub_series(fmpz * rpoly, fmpz_t rden, const fmpz * poly1, const fmpz_t den1, long len1, const fmpz * poly2, const fmpz_t den2, long len2, long n) + void _fmpq_poly_sub_series(fmpz * rpoly, fmpz_t rden, const fmpz * poly1, const fmpz_t den1, slong len1, const fmpz * poly2, const fmpz_t den2, slong len2, slong n) # As per ``_fmpq_poly_sub`` but the inputs are first notionally truncated # to length `n`. If `n` is less than ``len1`` or ``len2`` then the # output only needs space for `n` coefficients. We require `n \geq 0`. - void _fmpq_poly_sub_series_can(fmpz * rpoly, fmpz_t rden, const fmpz * poly1, const fmpz_t den1, long len1, const fmpz * poly2, const fmpz_t den2, long len2, long n, int can) + void _fmpq_poly_sub_series_can(fmpz * rpoly, fmpz_t rden, const fmpz * poly1, const fmpz_t den1, slong len1, const fmpz * poly2, const fmpz_t den2, slong len2, slong n, int can) # As per ``_fmpq_poly_sub_can`` but the inputs are first notionally # truncated to length `n`. If `n` is less than ``len1`` or ``len2`` # then the output only needs space for `n` coefficients. We require # `n \geq 0`. - void fmpq_poly_sub_series(fmpq_poly_t res, const fmpq_poly_t poly1, const fmpq_poly_t poly2, long n) + void fmpq_poly_sub_series(fmpq_poly_t res, const fmpq_poly_t poly1, const fmpq_poly_t poly2, slong n) # As per ``fmpq_poly_sub`` but the inputs are first notionally # truncated to length `n`. - void fmpq_poly_sub_series_can(fmpq_poly_t res, const fmpq_poly_t poly1, const fmpq_poly_t poly2, long n, int can) + void fmpq_poly_sub_series_can(fmpq_poly_t res, const fmpq_poly_t poly1, const fmpq_poly_t poly2, slong n, int can) # As per ``fmpq_poly_sub_can`` but the inputs are first notionally # truncated to length `n`. - void _fmpq_poly_scalar_mul_si(fmpz * rpoly, fmpz_t rden, const fmpz * poly, const fmpz_t den, long len, long c) + void _fmpq_poly_scalar_mul_si(fmpz * rpoly, fmpz_t rden, const fmpz * poly, const fmpz_t den, slong len, slong c) # Sets ``(rpoly, rden, len)`` to the product of `c` of # ``(poly, den, len)``. # If the input is normalised, then so is the output, provided it is @@ -370,7 +370,7 @@ cdef extern from "flint_wrap.h": # Supports exact aliasing between ``(rpoly, den)`` # and ``(poly, den)``. - void _fmpq_poly_scalar_mul_ui(fmpz * rpoly, fmpz_t rden, const fmpz * poly, const fmpz_t den, long len, unsigned long c) + void _fmpq_poly_scalar_mul_ui(fmpz * rpoly, fmpz_t rden, const fmpz * poly, const fmpz_t den, slong len, ulong c) # Sets ``(rpoly, rden, len)`` to the product of `c` of # ``(poly, den, len)``. # If the input is normalised, then so is the output, provided it is @@ -380,7 +380,7 @@ cdef extern from "flint_wrap.h": # Supports exact aliasing between ``(rpoly, den)`` # and ``(poly, den)``. - void _fmpq_poly_scalar_mul_fmpz(fmpz * rpoly, fmpz_t rden, const fmpz * poly, const fmpz_t den, long len, const fmpz_t c) + void _fmpq_poly_scalar_mul_fmpz(fmpz * rpoly, fmpz_t rden, const fmpz * poly, const fmpz_t den, slong len, const fmpz_t c) # Sets ``(rpoly, rden, len)`` to the product of `c` of # ``(poly, den, len)``. # If the input is normalised, then so is the output, provided it is @@ -390,7 +390,7 @@ cdef extern from "flint_wrap.h": # Supports exact aliasing between ``(rpoly, den)`` # and ``(poly, den)``. - void _fmpq_poly_scalar_mul_fmpq(fmpz * rpoly, fmpz_t rden, const fmpz * poly, const fmpz_t den, long len, const fmpz_t r, const fmpz_t s) + void _fmpq_poly_scalar_mul_fmpq(fmpz * rpoly, fmpz_t rden, const fmpz * poly, const fmpz_t den, slong len, const fmpz_t r, const fmpz_t s) # Sets ``(rpoly, rden)`` to the product of `r/s` and # ``(poly, den, len)``, in lowest terms. # Assumes that ``(poly, den, len)`` and `r/s` are provided in lowest @@ -398,10 +398,10 @@ cdef extern from "flint_wrap.h": # Supports aliasing of ``(rpoly, den)`` and ``(poly, den)``. # The ``fmpz_t``'s `r` and `s` may not be part of ``(rpoly, rden)``. - void fmpq_poly_scalar_mul_si(fmpq_poly_t rop, const fmpq_poly_t op, long c) + void fmpq_poly_scalar_mul_si(fmpq_poly_t rop, const fmpq_poly_t op, slong c) # Sets ``rop`` to `c` times ``op``. - void fmpq_poly_scalar_mul_ui(fmpq_poly_t rop, const fmpq_poly_t op, unsigned long c) + void fmpq_poly_scalar_mul_ui(fmpq_poly_t rop, const fmpq_poly_t op, ulong c) # Sets ``rop`` to `c` times ``op``. void fmpq_poly_scalar_mul_fmpz(fmpq_poly_t rop, const fmpq_poly_t op, const fmpz_t c) @@ -411,26 +411,26 @@ cdef extern from "flint_wrap.h": void fmpq_poly_scalar_mul_mpq(fmpq_poly_t rop, const fmpq_poly_t op, const fmpq_t c) # Sets ``rop`` to `c` times ``op``. - void _fmpq_poly_scalar_div_fmpz(fmpz * rpoly, fmpz_t rden, const fmpz * poly, const fmpz_t den, long len, const fmpz_t c) + void _fmpq_poly_scalar_div_fmpz(fmpz * rpoly, fmpz_t rden, const fmpz * poly, const fmpz_t den, slong len, const fmpz_t c) # Sets ``(rpoly, rden, len)`` to ``(poly, den, len)`` divided by `c`, # in lowest terms. # Assumes that ``len`` is positive. Assumes that `c` is non-zero. # Supports aliasing between ``(rpoly, rden)`` and ``(poly, den)``. # Assumes that `c` is not part of ``(rpoly, rden)``. - void _fmpq_poly_scalar_div_si(fmpz * rpoly, fmpz_t rden, const fmpz * poly, const fmpz_t den, long len, long c) + void _fmpq_poly_scalar_div_si(fmpz * rpoly, fmpz_t rden, const fmpz * poly, const fmpz_t den, slong len, slong c) # Sets ``(rpoly, rden, len)`` to ``(poly, den, len)`` divided by `c`, # in lowest terms. # Assumes that ``len`` is positive. Assumes that `c` is non-zero. # Supports aliasing between ``(rpoly, rden)`` and ``(poly, den)``. - void _fmpq_poly_scalar_div_ui(fmpz * rpoly, fmpz_t rden, const fmpz * poly, const fmpz_t den, long len, unsigned long c) + void _fmpq_poly_scalar_div_ui(fmpz * rpoly, fmpz_t rden, const fmpz * poly, const fmpz_t den, slong len, ulong c) # Sets ``(rpoly, rden, len)`` to ``(poly, den, len)`` divided by `c`, # in lowest terms. # Assumes that ``len`` is positive. Assumes that `c` is non-zero. # Supports aliasing between ``(rpoly, rden)`` and ``(poly, den)``. - void _fmpq_poly_scalar_div_fmpq(fmpz * rpoly, fmpz_t rden, const fmpz * poly, const fmpz_t den, long len, const fmpz_t r, const fmpz_t s) + void _fmpq_poly_scalar_div_fmpq(fmpz * rpoly, fmpz_t rden, const fmpz * poly, const fmpz_t den, slong len, const fmpz_t r, const fmpz_t s) # Sets ``(rpoly, rden, len)`` to ``(poly, den, len)`` divided by `r/s`, # in lowest terms. # Assumes that ``len`` is positive. Assumes that `r/s` is non-zero and @@ -438,13 +438,13 @@ cdef extern from "flint_wrap.h": # ``(poly, den)``. The ``fmpz_t``'s `r` and `s` may not be part of # ``(rpoly, poly)``. - void fmpq_poly_scalar_div_si(fmpq_poly_t rop, const fmpq_poly_t op, long c) - void fmpq_poly_scalar_div_ui(fmpq_poly_t rop, const fmpq_poly_t op, unsigned long c) + void fmpq_poly_scalar_div_si(fmpq_poly_t rop, const fmpq_poly_t op, slong c) + void fmpq_poly_scalar_div_ui(fmpq_poly_t rop, const fmpq_poly_t op, ulong c) void fmpq_poly_scalar_div_fmpz(fmpq_poly_t rop, const fmpq_poly_t op, const fmpz_t c) void fmpq_poly_scalar_div_fmpq(fmpq_poly_t rop, const fmpq_poly_t op, const fmpq_t c) # Sets ``rop`` to ``op`` divided by the scalar ``c``. - void _fmpq_poly_mul(fmpz * rpoly, fmpz_t rden, const fmpz * poly1, const fmpz_t den1, long len1, const fmpz * poly2, const fmpz_t den2, long len2) + void _fmpq_poly_mul(fmpz * rpoly, fmpz_t rden, const fmpz * poly1, const fmpz_t den1, slong len1, const fmpz * poly2, const fmpz_t den2, slong len2) # Sets ``(rpoly, rden, len1 + len2 - 1)`` to the product of # ``(poly1, den1, len1)`` and ``(poly2, den2, len2)``. If the # input is provided in canonical form, then so is the output. @@ -454,7 +454,7 @@ cdef extern from "flint_wrap.h": void fmpq_poly_mul(fmpq_poly_t res, const fmpq_poly_t poly1, const fmpq_poly_t poly2) # Sets ``res`` to the product of ``poly1`` and ``poly2``. - void _fmpq_poly_mullow(fmpz * rpoly, fmpz_t rden, const fmpz * poly1, const fmpz_t den1, long len1, const fmpz * poly2, const fmpz_t den2, long len2, long n) + void _fmpq_poly_mullow(fmpz * rpoly, fmpz_t rden, const fmpz * poly1, const fmpz_t den1, slong len1, const fmpz * poly2, const fmpz_t den2, slong len2, slong n) # Sets ``(rpoly, rden, n)`` to the low `n` coefficients of # ``(poly1, den1)`` and ``(poly2, den2)``. The output is # not guaranteed to be in canonical form. @@ -462,7 +462,7 @@ cdef extern from "flint_wrap.h": # Allows for zero-padding in the inputs. Does not allow aliasing between # the inputs and outputs. - void fmpq_poly_mullow(fmpq_poly_t res, const fmpq_poly_t poly1, const fmpq_poly_t poly2, long n) + void fmpq_poly_mullow(fmpq_poly_t res, const fmpq_poly_t poly1, const fmpq_poly_t poly2, slong n) # Sets ``res`` to the product of ``poly1`` and ``poly2``, # truncated to length `n`. @@ -472,33 +472,33 @@ cdef extern from "flint_wrap.h": void fmpq_poly_submul(fmpq_poly_t rop, const fmpq_poly_t op1, const fmpq_poly_t op2) # Subtracts the product of ``op1`` and ``op2`` from ``rop``. - void _fmpq_poly_pow(fmpz * rpoly, fmpz_t rden, const fmpz * poly, const fmpz_t den, long len, unsigned long e) + void _fmpq_poly_pow(fmpz * rpoly, fmpz_t rden, const fmpz * poly, const fmpz_t den, slong len, ulong e) # Sets ``(rpoly, rden)`` to ``(poly, den)^e``, assuming # ``e, len > 0``. Assumes that ``rpoly`` is an array of # length at least ``e * (len - 1) + 1``. Supports aliasing # of ``(rpoly, den)`` and ``(poly, den)``. - void fmpq_poly_pow(fmpq_poly_t res, const fmpq_poly_t poly, unsigned long e) + void fmpq_poly_pow(fmpq_poly_t res, const fmpq_poly_t poly, ulong e) # Sets ``res`` to ``poly^e``, where the only special case `0^0` is # defined as `1`. - void _fmpq_poly_pow_trunc(fmpz * res, fmpz_t rden, const fmpz * f, const fmpz_t fden, long flen, unsigned long exp, long len) + void _fmpq_poly_pow_trunc(fmpz * res, fmpz_t rden, const fmpz * f, const fmpz_t fden, slong flen, ulong exp, slong len) # Sets ``(rpoly, rden, len)`` to ``(poly, den)^e`` truncated to length ``len``, # where ``len`` is at most ``e * (flen - 1) + 1``. - void fmpq_poly_pow_trunc(fmpq_poly_t res, const fmpq_poly_t poly, unsigned long e, long n) + void fmpq_poly_pow_trunc(fmpq_poly_t res, const fmpq_poly_t poly, ulong e, slong n) # Sets ``res`` to ``poly^e`` truncated to length ``n``. - void fmpq_poly_shift_left(fmpq_poly_t res, const fmpq_poly_t poly, long n) + void fmpq_poly_shift_left(fmpq_poly_t res, const fmpq_poly_t poly, slong n) # Set ``res`` to ``poly`` shifted left by `n` coefficients. Zero # coefficients are inserted. - void fmpq_poly_shift_right(fmpq_poly_t res, const fmpq_poly_t poly, long n) + void fmpq_poly_shift_right(fmpq_poly_t res, const fmpq_poly_t poly, slong n) # Set ``res`` to ``poly`` shifted right by `n` coefficients. # If `n` is equal to or greater than the current length of ``poly``, # ``res`` is set to the zero polynomial. - void _fmpq_poly_divrem(fmpz * Q, fmpz_t q, fmpz * R, fmpz_t r, const fmpz * A, const fmpz_t a, long lenA, const fmpz * B, const fmpz_t b, long lenB, const fmpz_preinvn_t inv) + void _fmpq_poly_divrem(fmpz * Q, fmpz_t q, fmpz * R, fmpz_t r, const fmpz * A, const fmpz_t a, slong lenA, const fmpz * B, const fmpz_t b, slong lenB, const fmpz_preinvn_t inv) # Finds the quotient ``(Q, q)`` and remainder ``(R, r)`` of the # Euclidean division of ``(A, a)`` by ``(B, b)``. # Assumes that ``lenA >= lenB > 0``. Assumes that `R` has space for @@ -515,7 +515,7 @@ cdef extern from "flint_wrap.h": # Finds the quotient `Q` and remainder `R` of the Euclidean division of # ``poly1`` by ``poly2``. - void _fmpq_poly_div(fmpz * Q, fmpz_t q, const fmpz * A, const fmpz_t a, long lenA, const fmpz * B, const fmpz_t b, long lenB, const fmpz_preinvn_t inv) + void _fmpq_poly_div(fmpz * Q, fmpz_t q, const fmpz * A, const fmpz_t a, slong lenA, const fmpz * B, const fmpz_t b, slong lenB, const fmpz_preinvn_t inv) # Finds the quotient ``(Q, q)`` of the Euclidean division # of ``(A, a)`` by ``(B, b)``. # Assumes that ``lenA >= lenB > 0``. Supports no aliasing @@ -530,7 +530,7 @@ cdef extern from "flint_wrap.h": # Finds the quotient `Q` and remainder `R` of the Euclidean division # of ``poly1`` by ``poly2``. - void _fmpq_poly_rem(fmpz * R, fmpz_t r, const fmpz * A, const fmpz_t a, long lenA, const fmpz * B, const fmpz_t b, long lenB, const fmpz_preinvn_t inv) + void _fmpq_poly_rem(fmpz * R, fmpz_t r, const fmpz * A, const fmpz_t a, slong lenA, const fmpz * B, const fmpz_t b, slong lenB, const fmpz_preinvn_t inv) # Finds the remainder ``(R, r)`` of the Euclidean division # of ``(A, a)`` by ``(B, b)``. # Assumes that ``lenA >= lenB > 0``. Supports no aliasing between @@ -545,7 +545,7 @@ cdef extern from "flint_wrap.h": # Finds the remainder `R` of the Euclidean division # of ``poly1`` by ``poly2``. - fmpq_poly_struct * _fmpq_poly_powers_precompute(const fmpz * B, const fmpz_t denB, long len) + fmpq_poly_struct * _fmpq_poly_powers_precompute(const fmpz * B, const fmpz_t denB, slong len) # Computes ``2*len - 1`` powers of `x` modulo the polynomial `B` of # the given length. This is used as a kind of precomputed inverse in # the remainder routine below. @@ -553,7 +553,7 @@ cdef extern from "flint_wrap.h": void fmpq_poly_powers_precompute(fmpq_poly_powers_precomp_t pinv, fmpq_poly_t poly) # Computes ``2*len - 1`` powers of `x` modulo the polynomial `B` of the given length. This is used as a kind of precomputed inverse in the remainder routine below. - void _fmpq_poly_powers_clear(fmpq_poly_struct * powers, long len) + void _fmpq_poly_powers_clear(fmpq_poly_struct * powers, slong len) # Clean up resources used by precomputed powers which have been computed # by ``_fmpq_poly_powers_precompute``. @@ -561,7 +561,7 @@ cdef extern from "flint_wrap.h": # Clean up resources used by precomputed powers which have been computed # by ``fmpq_poly_powers_precompute``. - void _fmpq_poly_rem_powers_precomp(fmpz * A, fmpz_t denA, long m, const fmpz * B, const fmpz_t denB, long n, fmpq_poly_struct * const powers) + void _fmpq_poly_rem_powers_precomp(fmpz * A, fmpz_t denA, slong m, const fmpz * B, const fmpz_t denB, slong n, fmpq_poly_struct * const powers) # Set `A` to the remainder of `A` divide `B` given precomputed powers mod `B` # provided by ``_fmpq_poly_powers_precompute``. No aliasing is allowed. # This function is only faster if `m \leq 2\cdot n - 1`. @@ -573,7 +573,7 @@ cdef extern from "flint_wrap.h": # This function is only faster if ``A->length <= 2*B->length - 1``. # The output of this function is *not* canonicalised. - int _fmpq_poly_divides(fmpz * qpoly, fmpz_t qden, const fmpz * poly1, const fmpz_t den1, long len1, const fmpz * poly2, const fmpz_t den2, long len2) + int _fmpq_poly_divides(fmpz * qpoly, fmpz_t qden, const fmpz * poly1, const fmpz_t den1, slong len1, const fmpz * poly2, const fmpz_t den2, slong len2) # Return `1` if ``(poly2, den2, len2)`` divides ``(poly1, den1, len1)`` and # set ``(qpoly, qden, len1 - len2 + 1)`` to the quotient. Otherwise return # `0`. Requires that ``qpoly`` has space for ``len1 - len2 + 1`` @@ -583,35 +583,35 @@ cdef extern from "flint_wrap.h": # Return `1` if ``poly2`` divides ``poly1`` and set ``q`` to the quotient. # Otherwise return `0`. - long fmpq_poly_remove(fmpq_poly_t q, const fmpq_poly_t poly1, const fmpq_poly_t poly2) + slong fmpq_poly_remove(fmpq_poly_t q, const fmpq_poly_t poly1, const fmpq_poly_t poly2) # Sets ``q`` to the quotient of ``poly1`` by the highest power of ``poly2`` # which divides it, and returns the power. The divisor ``poly2`` must not be # constant or an exception is raised. - void _fmpq_poly_inv_series_newton(fmpz * rpoly, fmpz_t rden, const fmpz * poly, const fmpz_t den, long len, long n) + void _fmpq_poly_inv_series_newton(fmpz * rpoly, fmpz_t rden, const fmpz * poly, const fmpz_t den, slong len, slong n) # Computes the first `n` terms of the inverse power series of # ``(poly, den, len)`` using Newton iteration. # The result is produced in canonical form. # Assumes that `n \geq 1` and that ``poly`` has non-zero constant term. # Does not support aliasing. - void fmpq_poly_inv_series_newton(fmpq_poly_t res, const fmpq_poly_t poly, long n) + void fmpq_poly_inv_series_newton(fmpq_poly_t res, const fmpq_poly_t poly, slong n) # Computes the first `n` terms of the inverse power series # of ``poly`` using Newton iteration, assuming that ``poly`` # has non-zero constant term and `n \geq 1`. - void _fmpq_poly_inv_series(fmpz * rpoly, fmpz_t rden, const fmpz * poly, const fmpz_t den, long den_len, long n) + void _fmpq_poly_inv_series(fmpz * rpoly, fmpz_t rden, const fmpz * poly, const fmpz_t den, slong den_len, slong n) # Computes the first `n` terms of the inverse power series of # ``(poly, den, len)``. # The result is produced in canonical form. # Assumes that `n \geq 1` and that ``poly`` has non-zero constant term. # Does not support aliasing. - void fmpq_poly_inv_series(fmpq_poly_t res, const fmpq_poly_t poly, long n) + void fmpq_poly_inv_series(fmpq_poly_t res, const fmpq_poly_t poly, slong n) # Computes the first `n` terms of the inverse power series of ``poly``, # assuming that ``poly`` has non-zero constant term and `n \geq 1`. - void _fmpq_poly_div_series(fmpz * Q, fmpz_t denQ, const fmpz * A, const fmpz_t denA, long lenA, const fmpz * B, const fmpz_t denB, long lenB, long n) + void _fmpq_poly_div_series(fmpz * Q, fmpz_t denQ, const fmpz * A, const fmpz_t denA, slong lenA, const fmpz * B, const fmpz_t denB, slong lenB, slong n) # Divides ``(A, denA, lenA)`` by ``(B, denB, lenB)`` as power series # over `\mathbb{Q}`, assuming `B` has non-zero constant term and that # all lengths are positive. @@ -619,13 +619,13 @@ cdef extern from "flint_wrap.h": # This function ensures that the numerator and denominator # are coprime on exit. - void fmpq_poly_div_series(fmpq_poly_t Q, const fmpq_poly_t A, const fmpq_poly_t B, long n) + void fmpq_poly_div_series(fmpq_poly_t Q, const fmpq_poly_t A, const fmpq_poly_t B, slong n) # Performs power series division in `\mathbb{Q}[[x]] / (x^n)`. The function # considers the polynomials `A` and `B` as power series of length `n` # starting with the constant terms. The function assumes that `B` has # non-zero constant term and `n \geq 1`. - void _fmpq_poly_gcd(fmpz *G, fmpz_t denG, const fmpz *A, long lenA, const fmpz *B, long lenB) + void _fmpq_poly_gcd(fmpz *G, fmpz_t denG, const fmpz *A, slong lenA, const fmpz *B, slong lenB) # Computes the monic greatest common divisor `G` of `A` and `B`. # Assumes that `G` has space for `\operatorname{len}(B)` coefficients, # where `\operatorname{len}(A) \geq \operatorname{len}(B) > 0`. @@ -636,7 +636,7 @@ cdef extern from "flint_wrap.h": # Computes the monic greatest common divisor `G` of `A` and `B`. # In the special case when `A = B = 0`, sets `G = 0`. - void _fmpq_poly_xgcd(fmpz *G, fmpz_t denG, fmpz *S, fmpz_t denS, fmpz *T, fmpz_t denT, const fmpz *A, const fmpz_t denA, long lenA, const fmpz *B, const fmpz_t denB, long lenB) + void _fmpq_poly_xgcd(fmpz *G, fmpz_t denG, fmpz *S, fmpz_t denS, fmpz *T, fmpz_t denT, const fmpz *A, const fmpz_t denA, slong lenA, const fmpz *B, const fmpz_t denB, slong lenB) # Computes polynomials `G`, `S`, and `T` such that # `G = \gcd(A, B) = S A + T B`, where `G` is the monic # greatest common divisor of `A` and `B`. @@ -654,7 +654,7 @@ cdef extern from "flint_wrap.h": # scalar multiple of `G = A`, `S = 1`, and `T = 0`. The case # when `A = 0`, `B \neq 0` is handled similarly. - void _fmpq_poly_lcm(fmpz *L, fmpz_t denL, const fmpz *A, long lenA, const fmpz *B, long lenB) + void _fmpq_poly_lcm(fmpz *L, fmpz_t denL, const fmpz *A, slong lenA, const fmpz *B, slong lenB) # Computes the monic least common multiple `L` of `A` and `B`. # Assumes that `L` has space for `\operatorname{len}(A) + \operatorname{len}(B) - 1` coefficients, # where `\operatorname{len}(A) \geq \operatorname{len}(B) > 0`. @@ -665,7 +665,7 @@ cdef extern from "flint_wrap.h": # Computes the monic least common multiple `L` of `A` and `B`. # In the special case when `A = B = 0`, sets `L = 0`. - void _fmpq_poly_resultant(fmpz_t rnum, fmpz_t rden, const fmpz *poly1, const fmpz_t den1, long len1, const fmpz *poly2, const fmpz_t den2, long len2) + void _fmpq_poly_resultant(fmpz_t rnum, fmpz_t rden, const fmpz *poly1, const fmpz_t den1, slong len1, const fmpz *poly2, const fmpz_t den2, slong len2) # Sets ``(rnum, rden)`` to the resultant of the two input # polynomials. # Assumes that ``len1 >= len2 > 0``. Does not support zero-padding @@ -684,12 +684,12 @@ cdef extern from "flint_wrap.h": # the resultant is zero. Note that otherwise if one of the polynomials is # constant, the last term in the above expression is the empty product. - void fmpq_poly_resultant_div(fmpq_t r, const fmpq_poly_t f, const fmpq_poly_t g, const fmpz_t div, long nbits) + void fmpq_poly_resultant_div(fmpq_t r, const fmpq_poly_t f, const fmpq_poly_t g, const fmpz_t div, slong nbits) # Returns the resultant of `f` and `g` divided by ``div`` under the # assumption that the result has at most ``nbits`` bits. The result must # be an integer. - void _fmpq_poly_derivative(fmpz * rpoly, fmpz_t rden, const fmpz * poly, const fmpz_t den, long len) + void _fmpq_poly_derivative(fmpz * rpoly, fmpz_t rden, const fmpz * poly, const fmpz_t den, slong len) # Sets ``(rpoly, rden, len - 1)`` to the derivative of # ``(poly, den, len)``. Does nothing if ``len <= 1``. # Supports aliasing between the two polynomials. @@ -697,15 +697,15 @@ cdef extern from "flint_wrap.h": void fmpq_poly_derivative(fmpq_poly_t res, const fmpq_poly_t poly) # Sets ``res`` to the derivative of ``poly``. - void _fmpq_poly_nth_derivative(fmpz * rpoly, fmpz_t rden, const fmpz * poly, const fmpz_t den, unsigned long n, long len) + void _fmpq_poly_nth_derivative(fmpz * rpoly, fmpz_t rden, const fmpz * poly, const fmpz_t den, ulong n, slong len) # Sets ``(rpoly, rden, len - n)`` to the nth derivative of # ``(poly, den, len)``. Does nothing if ``len <= n``. # Supports aliasing between the two polynomials. - void fmpq_poly_nth_derivative(fmpq_poly_t res, const fmpq_poly_t poly, unsigned long n) + void fmpq_poly_nth_derivative(fmpq_poly_t res, const fmpq_poly_t poly, ulong n) # Sets ``res`` to the nth derivative of ``poly``. - void _fmpq_poly_integral(fmpz * rpoly, fmpz_t rden, const fmpz * poly, const fmpz_t den, long len) + void _fmpq_poly_integral(fmpz * rpoly, fmpz_t rden, const fmpz * poly, const fmpz_t den, slong len) # Sets ``(rpoly, rden, len)`` to the integral of # ``(poly, den, len - 1)``. Assumes ``len >= 0``. # Supports aliasing between the two polynomials. @@ -717,37 +717,37 @@ cdef extern from "flint_wrap.h": # term is set to zero. In particular, the integral of the zero # polynomial is the zero polynomial. - void _fmpq_poly_sqrt_series(fmpz * g, fmpz_t gden, const fmpz * f, const fmpz_t fden, long flen, long n) + void _fmpq_poly_sqrt_series(fmpz * g, fmpz_t gden, const fmpz * f, const fmpz_t fden, slong flen, slong n) # Sets ``(g, gden, n)`` to the series expansion of the # square root of ``(f, fden, flen)``. Assumes ``n > 0`` and # that ``(f, fden, flen)`` has constant term 1. # Does not support aliasing between the input and output polynomials. - void fmpq_poly_sqrt_series(fmpq_poly_t res, const fmpq_poly_t f, long n) + void fmpq_poly_sqrt_series(fmpq_poly_t res, const fmpq_poly_t f, slong n) # Sets ``res`` to the series expansion of the square root of ``f`` # to order ``n > 1``. Requires ``f`` to have constant term 1. - void _fmpq_poly_invsqrt_series(fmpz * g, fmpz_t gden, const fmpz * f, const fmpz_t fden, long flen, long n) + void _fmpq_poly_invsqrt_series(fmpz * g, fmpz_t gden, const fmpz * f, const fmpz_t fden, slong flen, slong n) # Sets ``(g, gden, n)`` to the series expansion of the inverse # square root of ``(f, fden, flen)``. Assumes ``n > 0`` and # that ``(f, fden, flen)`` has constant term 1. # Does not support aliasing between the input and output polynomials. - void fmpq_poly_invsqrt_series(fmpq_poly_t res, const fmpq_poly_t f, long n) + void fmpq_poly_invsqrt_series(fmpq_poly_t res, const fmpq_poly_t f, slong n) # Sets ``res`` to the series expansion of the inverse square root of # ``f`` to order ``n > 0``. Requires ``f`` to have constant term 1. - void _fmpq_poly_power_sums(fmpz * res, fmpz_t rden, const fmpz * poly, long len, long n) + void _fmpq_poly_power_sums(fmpz * res, fmpz_t rden, const fmpz * poly, slong len, slong n) # Compute the (truncated) power sums series of the polynomial # ``(poly,len)`` up to length `n` using Newton identities. - void fmpq_poly_power_sums(fmpq_poly_t res, const fmpq_poly_t poly, long n) + void fmpq_poly_power_sums(fmpq_poly_t res, const fmpq_poly_t poly, slong n) # Compute the (truncated) power sum series of the monic polynomial # ``poly`` up to length `n` using Newton identities. That is the power # series whose coefficient of degree `i` is the sum of the `i`-th power of # all (complex) roots of the polynomial ``poly``. - void _fmpq_poly_power_sums_to_poly(fmpz * res, const fmpz * poly, const fmpz_t den, long len) + void _fmpq_poly_power_sums_to_poly(fmpz * res, const fmpz * poly, const fmpz_t den, slong len) # Compute an integer polynomial given by its power sums series ``(poly,den,len)``. void fmpq_poly_power_sums_to_fmpz_poly(fmpz_poly_t res, const fmpq_poly_t Q) @@ -757,167 +757,167 @@ cdef extern from "flint_wrap.h": void fmpq_poly_power_sums_to_poly(fmpq_poly_t res, const fmpq_poly_t Q) # Compute the monic polynomial from its power sums series ``Q``. - void _fmpq_poly_log_series(fmpz * g, fmpz_t gden, const fmpz * f, const fmpz_t fden, long flen, long n) + void _fmpq_poly_log_series(fmpz * g, fmpz_t gden, const fmpz * f, const fmpz_t fden, slong flen, slong n) # Sets ``(g, gden, n)`` to the series expansion of the # logarithm of ``(f, fden, flen)``. Assumes ``n > 0`` and # that ``(f, fden, flen)`` has constant term 1. # Supports aliasing between the input and output polynomials. - void fmpq_poly_log_series(fmpq_poly_t res, const fmpq_poly_t f, long n) + void fmpq_poly_log_series(fmpq_poly_t res, const fmpq_poly_t f, slong n) # Sets ``res`` to the series expansion of the logarithm of ``f`` # to order ``n > 0``. Requires ``f`` to have constant term 1. - void _fmpq_poly_exp_series(fmpz * g, fmpz_t gden, const fmpz * h, const fmpz_t hden, long hlen, long n) + void _fmpq_poly_exp_series(fmpz * g, fmpz_t gden, const fmpz * h, const fmpz_t hden, slong hlen, slong n) # Sets ``(g, gden, n)`` to the series expansion of the # exponential function of ``(h, hden, hlen)``. Assumes # ``n > 0, hlen > 0`` and # that ``(h, hden, hlen)`` has constant term 0. # Supports aliasing between the input and output polynomials. - void fmpq_poly_exp_series(fmpq_poly_t res, const fmpq_poly_t h, long n) + void fmpq_poly_exp_series(fmpq_poly_t res, const fmpq_poly_t h, slong n) # Sets ``res`` to the series expansion of the exponential function # of ``h`` to order ``n > 0``. Requires ``f`` to have # constant term 0. - void _fmpq_poly_exp_expinv_series(fmpz * res1, fmpz_t res1den, fmpz * res2, fmpz_t res2den, const fmpz * h, const fmpz_t hden, long hlen, long n) + void _fmpq_poly_exp_expinv_series(fmpz * res1, fmpz_t res1den, fmpz * res2, fmpz_t res2den, const fmpz * h, const fmpz_t hden, slong hlen, slong n) # The same as ``fmpq_poly_exp_series``, but simultaneously computes # the exponential (in ``res1``, ``res1den``) and its multiplicative inverse # (in ``res2``, ``res2den``). # Supports aliasing between the input and output polynomials. - void fmpq_poly_exp_expinv_series(fmpq_poly_t res1, fmpq_poly_t res2, const fmpq_poly_t h, long n) + void fmpq_poly_exp_expinv_series(fmpq_poly_t res1, fmpq_poly_t res2, const fmpq_poly_t h, slong n) # The same as ``fmpq_poly_exp_series``, but simultaneously computes # the exponential (in ``res1``) and its multiplicative inverse # (in ``res2``). - void _fmpq_poly_atan_series(fmpz * g, fmpz_t gden, const fmpz * f, const fmpz_t fden, long flen, long n) + void _fmpq_poly_atan_series(fmpz * g, fmpz_t gden, const fmpz * f, const fmpz_t fden, slong flen, slong n) # Sets ``(g, gden, n)`` to the series expansion of the # inverse tangent of ``(f, fden, flen)``. Assumes ``n > 0`` and # that ``(f, fden, flen)`` has constant term 0. # Supports aliasing between the input and output polynomials. - void fmpq_poly_atan_series(fmpq_poly_t res, const fmpq_poly_t f, long n) + void fmpq_poly_atan_series(fmpq_poly_t res, const fmpq_poly_t f, slong n) # Sets ``res`` to the series expansion of the inverse tangent of ``f`` # to order ``n > 0``. Requires ``f`` to have constant term 0. - void _fmpq_poly_atanh_series(fmpz * g, fmpz_t gden, const fmpz * f, const fmpz_t fden, long flen, long n) + void _fmpq_poly_atanh_series(fmpz * g, fmpz_t gden, const fmpz * f, const fmpz_t fden, slong flen, slong n) # Sets ``(g, gden, n)`` to the series expansion of the inverse # hyperbolic tangent of ``(f, fden, flen)``. Assumes ``n > 0`` and # that ``(f, fden, flen)`` has constant term 0. # Supports aliasing between the input and output polynomials. - void fmpq_poly_atanh_series(fmpq_poly_t res, const fmpq_poly_t f, long n) + void fmpq_poly_atanh_series(fmpq_poly_t res, const fmpq_poly_t f, slong n) # Sets ``res`` to the series expansion of the inverse hyperbolic # tangent of ``f`` to order ``n > 0``. Requires ``f`` to have # constant term 0. - void _fmpq_poly_asin_series(fmpz * g, fmpz_t gden, const fmpz * f, const fmpz_t fden, long flen, long n) + void _fmpq_poly_asin_series(fmpz * g, fmpz_t gden, const fmpz * f, const fmpz_t fden, slong flen, slong n) # Sets ``(g, gden, n)`` to the series expansion of the # inverse sine of ``(f, fden, flen)``. Assumes ``n > 0`` and # that ``(f, fden, flen)`` has constant term 0. # Supports aliasing between the input and output polynomials. - void fmpq_poly_asin_series(fmpq_poly_t res, const fmpq_poly_t f, long n) + void fmpq_poly_asin_series(fmpq_poly_t res, const fmpq_poly_t f, slong n) # Sets ``res`` to the series expansion of the inverse sine of ``f`` # to order ``n > 0``. Requires ``f`` to have constant term 0. - void _fmpq_poly_asinh_series(fmpz * g, fmpz_t gden, const fmpz * f, const fmpz_t fden, long flen, long n) + void _fmpq_poly_asinh_series(fmpz * g, fmpz_t gden, const fmpz * f, const fmpz_t fden, slong flen, slong n) # Sets ``(g, gden, n)`` to the series expansion of the inverse # hyperbolic sine of ``(f, fden, flen)``. Assumes ``n > 0`` and # that ``(f, fden, flen)`` has constant term 0. # Supports aliasing between the input and output polynomials. - void fmpq_poly_asinh_series(fmpq_poly_t res, const fmpq_poly_t f, long n) + void fmpq_poly_asinh_series(fmpq_poly_t res, const fmpq_poly_t f, slong n) # Sets ``res`` to the series expansion of the inverse hyperbolic # sine of ``f`` to order ``n > 0``. Requires ``f`` to have # constant term 0. - void _fmpq_poly_tan_series(fmpz * g, fmpz_t gden, const fmpz * f, const fmpz_t fden, long flen, long n) + void _fmpq_poly_tan_series(fmpz * g, fmpz_t gden, const fmpz * f, const fmpz_t fden, slong flen, slong n) # Sets ``(g, gden, n)`` to the series expansion of the # tangent function of ``(f, fden, flen)``. Assumes ``n > 0`` and # that ``(f, fden, flen)`` has constant term 0. # Does not support aliasing between the input and output polynomials. - void fmpq_poly_tan_series(fmpq_poly_t res, const fmpq_poly_t f, long n) + void fmpq_poly_tan_series(fmpq_poly_t res, const fmpq_poly_t f, slong n) # Sets ``res`` to the series expansion of the tangent function # of ``f`` to order ``n > 0``. Requires ``f`` to have # constant term 0. - void _fmpq_poly_sin_series(fmpz * g, fmpz_t gden, const fmpz * f, const fmpz_t fden, long flen, long n) + void _fmpq_poly_sin_series(fmpz * g, fmpz_t gden, const fmpz * f, const fmpz_t fden, slong flen, slong n) # Sets ``(g, gden, n)`` to the series expansion of the # sine of ``(f, fden, flen)``. Assumes ``n > 0`` and # that ``(f, fden, flen)`` has constant term 0. # Supports aliasing between the input and output polynomials. - void fmpq_poly_sin_series(fmpq_poly_t res, const fmpq_poly_t f, long n) + void fmpq_poly_sin_series(fmpq_poly_t res, const fmpq_poly_t f, slong n) # Sets ``res`` to the series expansion of the sine of ``f`` # to order ``n > 0``. Requires ``f`` to have constant term 0. - void _fmpq_poly_cos_series(fmpz * g, fmpz_t gden, const fmpz * f, const fmpz_t fden, long flen, long n) + void _fmpq_poly_cos_series(fmpz * g, fmpz_t gden, const fmpz * f, const fmpz_t fden, slong flen, slong n) # Sets ``(g, gden, n)`` to the series expansion of the # cosine of ``(f, fden, flen)``. Assumes ``n > 0`` and # that ``(f, fden, flen)`` has constant term 0. # Supports aliasing between the input and output polynomials. - void fmpq_poly_cos_series(fmpq_poly_t res, const fmpq_poly_t f, long n) + void fmpq_poly_cos_series(fmpq_poly_t res, const fmpq_poly_t f, slong n) # Sets ``res`` to the series expansion of the cosine of ``f`` # to order ``n > 0``. Requires ``f`` to have constant term 0. - void _fmpq_poly_sin_cos_series(fmpz * s, fmpz_t sden, fmpz * c, fmpz_t cden, const fmpz * f, const fmpz_t fden, long flen, long n) + void _fmpq_poly_sin_cos_series(fmpz * s, fmpz_t sden, fmpz * c, fmpz_t cden, const fmpz * f, const fmpz_t fden, slong flen, slong n) # Sets ``(s, sden, n)`` to the series expansion of the # sine of ``(f, fden, flen)``, and ``(c, cden, n)`` to the series # expansion of the cosine. Assumes ``n > 0`` and # that ``(f, fden, flen)`` has constant term 0. # Supports aliasing between the input and output polynomials. - void fmpq_poly_sin_cos_series(fmpq_poly_t res1, fmpq_poly_t res2, const fmpq_poly_t f, long n) + void fmpq_poly_sin_cos_series(fmpq_poly_t res1, fmpq_poly_t res2, const fmpq_poly_t f, slong n) # Sets ``res1`` to the series expansion of the sine of ``f`` # to order ``n > 0``, and ``res2`` to the series expansion # of the cosine. Requires ``f`` to have constant term 0. - void _fmpq_poly_sinh_series(fmpz * g, fmpz_t gden, const fmpz * f, const fmpz_t fden, long flen, long n) + void _fmpq_poly_sinh_series(fmpz * g, fmpz_t gden, const fmpz * f, const fmpz_t fden, slong flen, slong n) # Sets ``(g, gden, n)`` to the series expansion of the # hyperbolic sine of ``(f, fden, flen)``. Assumes ``n > 0`` and # that ``(f, fden, flen)`` has constant term 0. # Does not support aliasing between the input and output polynomials. - void fmpq_poly_sinh_series(fmpq_poly_t res, const fmpq_poly_t f, long n) + void fmpq_poly_sinh_series(fmpq_poly_t res, const fmpq_poly_t f, slong n) # Sets ``res`` to the series expansion of the hyperbolic sine of ``f`` # to order ``n > 0``. Requires ``f`` to have constant term 0. - void _fmpq_poly_cosh_series(fmpz * g, fmpz_t gden, const fmpz * f, const fmpz_t fden, long flen, long n) + void _fmpq_poly_cosh_series(fmpz * g, fmpz_t gden, const fmpz * f, const fmpz_t fden, slong flen, slong n) # Sets ``(g, gden, n)`` to the series expansion of the hyperbolic # cosine of ``(f, fden, flen)``. Assumes ``n > 0`` and # that ``(f, fden, flen)`` has constant term 0. # Does not support aliasing between the input and output polynomials. - void fmpq_poly_cosh_series(fmpq_poly_t res, const fmpq_poly_t f, long n) + void fmpq_poly_cosh_series(fmpq_poly_t res, const fmpq_poly_t f, slong n) # Sets ``res`` to the series expansion of the hyperbolic cosine of # ``f`` to order ``n > 0``. Requires ``f`` to have constant term 0. - void _fmpq_poly_sinh_cosh_series(fmpz * s, fmpz_t sden, fmpz * c, fmpz_t cden, const fmpz * f, const fmpz_t fden, long flen, long n) + void _fmpq_poly_sinh_cosh_series(fmpz * s, fmpz_t sden, fmpz * c, fmpz_t cden, const fmpz * f, const fmpz_t fden, slong flen, slong n) # Sets ``(s, sden, n)`` to the series expansion of the hyperbolic # sine of ``(f, fden, flen)``, and ``(c, cden, n)`` to the series # expansion of the hyperbolic cosine. Assumes ``n > 0`` and # that ``(f, fden, flen)`` has constant term 0. # Supports aliasing between the input and output polynomials. - void fmpq_poly_sinh_cosh_series(fmpq_poly_t res1, fmpq_poly_t res2, const fmpq_poly_t f, long n) + void fmpq_poly_sinh_cosh_series(fmpq_poly_t res1, fmpq_poly_t res2, const fmpq_poly_t f, slong n) # Sets ``res1`` to the series expansion of the hyperbolic sine of ``f`` # to order ``n > 0``, and ``res2`` to the series expansion # of the hyperbolic cosine. Requires ``f`` to have constant term 0. - void _fmpq_poly_tanh_series(fmpz * g, fmpz_t gden, const fmpz * f, const fmpz_t fden, long flen, long n) + void _fmpq_poly_tanh_series(fmpz * g, fmpz_t gden, const fmpz * f, const fmpz_t fden, slong flen, slong n) # Sets ``(g, gden, n)`` to the series expansion of the # hyperbolic tangent of ``(f, fden, flen)``. Assumes ``n > 0`` and # that ``(f, fden, flen)`` has constant term 0. # Does not support aliasing between the input and output polynomials. - void fmpq_poly_tanh_series(fmpq_poly_t res, const fmpq_poly_t f, long n) + void fmpq_poly_tanh_series(fmpq_poly_t res, const fmpq_poly_t f, slong n) # Sets ``res`` to the series expansion of the hyperbolic tangent of # ``f`` to order ``n > 0``. Requires ``f`` to have constant term 0. - void _fmpq_poly_legendre_p(fmpz * coeffs, fmpz_t den, unsigned long n) + void _fmpq_poly_legendre_p(fmpz * coeffs, fmpz_t den, ulong n) # Sets ``coeffs`` to the coefficient array of the Legendre polynomial # `P_n(x)`, defined by `(n+1) P_{n+1}(x) = (2n+1) x P_n(x) - n P_{n-1}(x)`, # for `n\ge0`. Sets ``den`` to the overall denominator. @@ -929,7 +929,7 @@ cdef extern from "flint_wrap.h": # `\gcd(n!,2^n) = 2^{\lfloor n/2 \rfloor + \lfloor n/4 \rfloor + \ldots}.` # See ``fmpz_poly`` for the shifted Legendre polynomials. - void fmpq_poly_legendre_p(fmpq_poly_t poly, unsigned long n) + void fmpq_poly_legendre_p(fmpq_poly_t poly, ulong n) # Sets ``poly`` to the Legendre polynomial `P_n(x)`, defined # by `(n+1) P_{n+1}(x) = (2n+1) x P_n(x) - n P_{n-1}(x)`, for `n\ge0`. # The coefficients are calculated using a hypergeometric recurrence. @@ -939,19 +939,19 @@ cdef extern from "flint_wrap.h": # `\gcd(n!,2^n) = 2^{\lfloor n/2 \rfloor + \lfloor n/4 \rfloor + \ldots}.` # See ``fmpz_poly`` for the shifted Legendre polynomials. - void _fmpq_poly_laguerre_l(fmpz * coeffs, fmpz_t den, unsigned long n) + void _fmpq_poly_laguerre_l(fmpz * coeffs, fmpz_t den, ulong n) # Sets ``coeffs`` to the coefficient array of the Laguerre polynomial # `L_n(x)`, defined by `(n+1) L_{n+1}(x) = (2n+1-x) L_n(x) - n L_{n-1}(x)`, # for `n\ge0`. Sets ``den`` to the overall denominator. # The coefficients are calculated using a hypergeometric recurrence. # The length of the array will be ``n+1``. - void fmpq_poly_laguerre_l(fmpq_poly_t poly, unsigned long n) + void fmpq_poly_laguerre_l(fmpq_poly_t poly, ulong n) # Sets ``poly`` to the Laguerre polynomial `L_n(x)`, defined by # `(n+1) L_{n+1}(x) = (2n+1-x) L_n(x) - n L_{n-1}(x)`, for `n\ge0`. # The coefficients are calculated using a hypergeometric recurrence. - void _fmpq_poly_gegenbauer_c(fmpz * coeffs, fmpz_t den, unsigned long n, const fmpq_t a) + void _fmpq_poly_gegenbauer_c(fmpz * coeffs, fmpz_t den, ulong n, const fmpq_t a) # Sets ``coeffs`` to the coefficient array of the Gegenbauer # (ultraspherical) polynomial # `C^{(\alpha)}_n(x) = \frac{(2\alpha)_n}{n!}{}_2F_1\left(-n,2\alpha+n; @@ -959,14 +959,14 @@ cdef extern from "flint_wrap.h": # `\alpha>0`. Sets ``den`` to the overall denominator. # The coefficients are calculated using a hypergeometric recurrence. - void fmpq_poly_gegenbauer_c(fmpq_poly_t poly, unsigned long n, const fmpq_t a) + void fmpq_poly_gegenbauer_c(fmpq_poly_t poly, ulong n, const fmpq_t a) # Sets ``poly`` to the Gegenbauer (ultraspherical) polynomial # `C^{(\alpha)}_n(x) = \frac{(2\alpha)_n}{n!}{}_2F_1\left(-n,2\alpha+n; # \alpha+\frac12;\frac{1-x}{2}\right)`, for integer `n\ge0` and rational # `\alpha>0`. # The coefficients are calculated using a hypergeometric recurrence. - void _fmpq_poly_evaluate_fmpz(fmpz_t rnum, fmpz_t rden, const fmpz * poly, const fmpz_t den, long len, const fmpz_t a) + void _fmpq_poly_evaluate_fmpz(fmpz_t rnum, fmpz_t rden, const fmpz * poly, const fmpz_t den, slong len, const fmpz_t a) # Evaluates the polynomial ``(poly, den, len)`` at the integer `a` and # sets ``(rnum, rden)`` to the result in lowest terms. @@ -974,7 +974,7 @@ cdef extern from "flint_wrap.h": # Evaluates the polynomial ``poly`` at the integer `a` and sets # ``res`` to the result. - void _fmpq_poly_evaluate_fmpq(fmpz_t rnum, fmpz_t rden, const fmpz * poly, const fmpz_t den, long len, const fmpz_t anum, const fmpz_t aden) + void _fmpq_poly_evaluate_fmpq(fmpz_t rnum, fmpz_t rden, const fmpz * poly, const fmpz_t den, slong len, const fmpz_t anum, const fmpz_t aden) # Evaluates the polynomial ``(poly, den, len)`` at the rational # ``(anum, aden)`` and sets ``(rnum, rden)`` to the result in # lowest terms. Aliasing between ``(rnum, rden)`` and @@ -984,7 +984,7 @@ cdef extern from "flint_wrap.h": # Evaluates the polynomial ``poly`` at the rational `a` and # sets ``res`` to the result. - void _fmpq_poly_interpolate_fmpz_vec(fmpz * poly, fmpz_t den, const fmpz * xs, const fmpz * ys, long n) + void _fmpq_poly_interpolate_fmpz_vec(fmpz * poly, fmpz_t den, const fmpz * xs, const fmpz * ys, slong n) # Sets ``poly`` / ``den`` to the unique interpolating polynomial of # degree at most `n - 1` satisfying `f(x_i) = y_i` for every pair `x_i, y_i` # in ``xs`` and ``ys``. @@ -997,12 +997,12 @@ cdef extern from "flint_wrap.h": # interpolation, clearing denominators to avoid working with fractions. # It is currently not designed to be efficient for large `n`. - void fmpq_poly_interpolate_fmpz_vec(fmpq_poly_t poly, const fmpz * xs, const fmpz * ys, long n) + void fmpq_poly_interpolate_fmpz_vec(fmpq_poly_t poly, const fmpz * xs, const fmpz * ys, slong n) # Sets ``poly`` to the unique interpolating polynomial of degree # at most `n - 1` satisfying `f(x_i) = y_i` for every pair `x_i, y_i` # in ``xs`` and ``ys``. It is assumed that the `x` values are distinct. - void _fmpq_poly_compose(fmpz * res, fmpz_t den, const fmpz * poly1, const fmpz_t den1, long len1, const fmpz * poly2, const fmpz_t den2, long len2) + void _fmpq_poly_compose(fmpz * res, fmpz_t den, const fmpz * poly1, const fmpz_t den1, slong len1, const fmpz * poly2, const fmpz_t den2, slong len2) # Sets ``(res, den)`` to the composition of ``(poly1, den1, len1)`` # and ``(poly2, den2, len2)``, assuming ``len1, len2 > 0``. # Assumes that ``res`` has space for ``(len1 - 1) * (len2 - 1) + 1`` @@ -1011,7 +1011,7 @@ cdef extern from "flint_wrap.h": void fmpq_poly_compose(fmpq_poly_t res, const fmpq_poly_t poly1, const fmpq_poly_t poly2) # Sets ``res`` to the composition of ``poly1`` and ``poly2``. - void _fmpq_poly_rescale(fmpz * res, fmpz_t denr, const fmpz * poly, const fmpz_t den, long len, const fmpz_t anum, const fmpz_t aden) + void _fmpq_poly_rescale(fmpz * res, fmpz_t denr, const fmpz * poly, const fmpz_t den, slong len, const fmpz_t anum, const fmpz_t aden) # Sets ``(res, denr, len)`` to ``(poly, den, len)`` with the # indeterminate rescaled by ``(anum, aden)``. # Assumes that ``len > 0`` and that ``(anum, aden)`` is non-zero and @@ -1021,7 +1021,7 @@ cdef extern from "flint_wrap.h": void fmpq_poly_rescale(fmpq_poly_t res, const fmpq_poly_t poly, const fmpq_t a) # Sets ``res`` to ``poly`` with the indeterminate rescaled by `a`. - void _fmpq_poly_compose_series_horner(fmpz * res, fmpz_t den, const fmpz * poly1, const fmpz_t den1, long len1, const fmpz * poly2, const fmpz_t den2, long len2, long n) + void _fmpq_poly_compose_series_horner(fmpz * res, fmpz_t den, const fmpz * poly1, const fmpz_t den1, slong len1, const fmpz * poly2, const fmpz_t den2, slong len2, slong n) # Sets ``(res, den, n)`` to the composition of # ``(poly1, den1, len1)`` and ``(poly2, den2, len2)`` modulo `x^n`, # where the constant term of ``poly2`` is required to be zero. @@ -1033,7 +1033,7 @@ cdef extern from "flint_wrap.h": # The default ``fmpz_poly`` composition algorithm is automatically # used when the composition can be performed over the integers. - void fmpq_poly_compose_series_horner(fmpq_poly_t res, const fmpq_poly_t poly1, const fmpq_poly_t poly2, long n) + void fmpq_poly_compose_series_horner(fmpq_poly_t res, const fmpq_poly_t poly1, const fmpq_poly_t poly2, slong n) # Sets ``res`` to the composition of ``poly1`` and ``poly2`` # modulo `x^n`, where the constant term of ``poly2`` is required # to be zero. @@ -1041,7 +1041,7 @@ cdef extern from "flint_wrap.h": # The default ``fmpz_poly`` composition algorithm is automatically # used when the composition can be performed over the integers. - void _fmpq_poly_compose_series_brent_kung(fmpz * res, fmpz_t den, const fmpz * poly1, const fmpz_t den1, long len1, const fmpz * poly2, const fmpz_t den2, long len2, long n) + void _fmpq_poly_compose_series_brent_kung(fmpz * res, fmpz_t den, const fmpz * poly1, const fmpz_t den1, slong len1, const fmpz * poly2, const fmpz_t den2, slong len2, slong n) # Sets ``(res, den, n)`` to the composition of # ``(poly1, den1, len1)`` and ``(poly2, den2, len2)`` modulo `x^n`, # where the constant term of ``poly2`` is required to be zero. @@ -1053,7 +1053,7 @@ cdef extern from "flint_wrap.h": # The default ``fmpz_poly`` composition algorithm is automatically # used when the composition can be performed over the integers. - void fmpq_poly_compose_series_brent_kung(fmpq_poly_t res, const fmpq_poly_t poly1, const fmpq_poly_t poly2, long n) + void fmpq_poly_compose_series_brent_kung(fmpq_poly_t res, const fmpq_poly_t poly1, const fmpq_poly_t poly2, slong n) # Sets ``res`` to the composition of ``poly1`` and ``poly2`` # modulo `x^n`, where the constant term of ``poly2`` is required # to be zero. @@ -1061,7 +1061,7 @@ cdef extern from "flint_wrap.h": # The default ``fmpz_poly`` composition algorithm is automatically # used when the composition can be performed over the integers. - void _fmpq_poly_compose_series(fmpz * res, fmpz_t den, const fmpz * poly1, const fmpz_t den1, long len1, const fmpz * poly2, const fmpz_t den2, long len2, long n) + void _fmpq_poly_compose_series(fmpz * res, fmpz_t den, const fmpz * poly1, const fmpz_t den1, slong len1, const fmpz * poly2, const fmpz_t den2, slong len2, slong n) # Sets ``(res, den, n)`` to the composition of # ``(poly1, den1, len1)`` and ``(poly2, den2, len2)`` modulo `x^n`, # where the constant term of ``poly2`` is required to be zero. @@ -1074,7 +1074,7 @@ cdef extern from "flint_wrap.h": # The default ``fmpz_poly`` composition algorithm is automatically # used when the composition can be performed over the integers. - void fmpq_poly_compose_series(fmpq_poly_t res, const fmpq_poly_t poly1, const fmpq_poly_t poly2, long n) + void fmpq_poly_compose_series(fmpq_poly_t res, const fmpq_poly_t poly1, const fmpq_poly_t poly2, slong n) # Sets ``res`` to the composition of ``poly1`` and ``poly2`` # modulo `x^n`, where the constant term of ``poly2`` is required # to be zero. @@ -1083,7 +1083,7 @@ cdef extern from "flint_wrap.h": # The default ``fmpz_poly`` composition algorithm is automatically # used when the composition can be performed over the integers. - void _fmpq_poly_revert_series_lagrange(fmpz * res, fmpz_t den, const fmpz * poly1, const fmpz_t den1, long len1, long n) + void _fmpq_poly_revert_series_lagrange(fmpz * res, fmpz_t den, const fmpz * poly1, const fmpz_t den1, slong len1, slong n) # Sets ``(res, den)`` to the power series reversion of # ``(poly1, den1, len1)`` modulo `x^n`. # The constant term of ``poly2`` is required to be zero and @@ -1093,7 +1093,7 @@ cdef extern from "flint_wrap.h": # The default ``fmpz_poly`` reversion algorithm is automatically # used when the reversion can be performed over the integers. - void fmpq_poly_revert_series_lagrange(fmpq_poly_t res, const fmpq_poly_t poly, long n) + void fmpq_poly_revert_series_lagrange(fmpq_poly_t res, const fmpq_poly_t poly, slong n) # Sets ``res`` to the power series reversion of ``poly1`` modulo `x^n`. # The constant term of ``poly2`` is required to be zero and # the linear term is required to be nonzero. @@ -1101,7 +1101,7 @@ cdef extern from "flint_wrap.h": # The default ``fmpz_poly`` reversion algorithm is automatically # used when the reversion can be performed over the integers. - void _fmpq_poly_revert_series_lagrange_fast(fmpz * res, fmpz_t den, const fmpz * poly1, const fmpz_t den1, long len1, long n) + void _fmpq_poly_revert_series_lagrange_fast(fmpz * res, fmpz_t den, const fmpz * poly1, const fmpz_t den1, slong len1, slong n) # Sets ``(res, den)`` to the power series reversion of # ``(poly1, den1, len1)`` modulo `x^n`. # The constant term of ``poly2`` is required to be zero and @@ -1112,7 +1112,7 @@ cdef extern from "flint_wrap.h": # The default ``fmpz_poly`` reversion algorithm is automatically # used when the reversion can be performed over the integers. - void fmpq_poly_revert_series_lagrange_fast(fmpq_poly_t res, const fmpq_poly_t poly, long n) + void fmpq_poly_revert_series_lagrange_fast(fmpq_poly_t res, const fmpq_poly_t poly, slong n) # Sets ``res`` to the power series reversion of ``poly1`` modulo `x^n`. # The constant term of ``poly2`` is required to be zero and # the linear term is required to be nonzero. @@ -1121,7 +1121,7 @@ cdef extern from "flint_wrap.h": # The default ``fmpz_poly`` reversion algorithm is automatically # used when the reversion can be performed over the integers. - void _fmpq_poly_revert_series_newton(fmpz * res, fmpz_t den, const fmpz * poly1, const fmpz_t den1, long len1, long n) + void _fmpq_poly_revert_series_newton(fmpz * res, fmpz_t den, const fmpz * poly1, const fmpz_t den1, slong len1, slong n) # Sets ``(res, den)`` to the power series reversion of # ``(poly1, den1, len1)`` modulo `x^n`. # The constant term of ``poly2`` is required to be zero and @@ -1131,7 +1131,7 @@ cdef extern from "flint_wrap.h": # The default ``fmpz_poly`` reversion algorithm is automatically # used when the reversion can be performed over the integers. - void fmpq_poly_revert_series_newton(fmpq_poly_t res, const fmpq_poly_t poly, long n) + void fmpq_poly_revert_series_newton(fmpq_poly_t res, const fmpq_poly_t poly, slong n) # Sets ``res`` to the power series reversion of ``poly1`` modulo `x^n`. # The constant term of ``poly2`` is required to be zero and # the linear term is required to be nonzero. @@ -1139,7 +1139,7 @@ cdef extern from "flint_wrap.h": # The default ``fmpz_poly`` reversion algorithm is automatically # used when the reversion can be performed over the integers. - void _fmpq_poly_revert_series(fmpz * res, fmpz_t den, const fmpz * poly1, const fmpz_t den1, long len1, long n) + void _fmpq_poly_revert_series(fmpz * res, fmpz_t den, const fmpz * poly1, const fmpz_t den1, slong len1, slong n) # Sets ``(res, den)`` to the power series reversion of # ``(poly1, den1, len1)`` modulo `x^n`. # The constant term of ``poly2`` is required to be zero and @@ -1149,7 +1149,7 @@ cdef extern from "flint_wrap.h": # The default ``fmpz_poly`` reversion algorithm is automatically # used when the reversion can be performed over the integers. - void fmpq_poly_revert_series(fmpq_poly_t res, const fmpq_poly_t poly, long n) + void fmpq_poly_revert_series(fmpq_poly_t res, const fmpq_poly_t poly, slong n) # Sets ``res`` to the power series reversion of ``poly1`` modulo `x^n`. # The constant term of ``poly2`` is required to be zero and # the linear term is required to be nonzero. @@ -1157,7 +1157,7 @@ cdef extern from "flint_wrap.h": # The default ``fmpz_poly`` reversion algorithm is automatically # used when the reversion can be performed over the integers. - void _fmpq_poly_content(fmpq_t res, const fmpz * poly, const fmpz_t den, long len) + void _fmpq_poly_content(fmpq_t res, const fmpz * poly, const fmpz_t den, slong len) # Sets ``res`` to the content of ``(poly, den, len)``. # If ``len == 0``, sets ``res`` to zero. @@ -1165,7 +1165,7 @@ cdef extern from "flint_wrap.h": # Sets ``res`` to the content of ``poly``. The content of the zero # polynomial is defined to be zero. - void _fmpq_poly_primitive_part(fmpz * rpoly, fmpz_t rden, const fmpz * poly, const fmpz_t den, long len) + void _fmpq_poly_primitive_part(fmpz * rpoly, fmpz_t rden, const fmpz * poly, const fmpz_t den, slong len) # Sets ``(rpoly, rden, len)`` to the primitive part, with non-negative # leading coefficient, of ``(poly, den, len)``. Assumes that # ``len > 0``. Supports aliasing between the two polynomials. @@ -1174,7 +1174,7 @@ cdef extern from "flint_wrap.h": # Sets ``res`` to the primitive part, with non-negative leading # coefficient, of ``poly``. - int _fmpq_poly_is_monic(const fmpz * poly, const fmpz_t den, long len) + int _fmpq_poly_is_monic(const fmpz * poly, const fmpz_t den, slong len) # Returns whether the polynomial ``(poly, den, len)`` is monic. # The zero polynomial is not monic by definition. @@ -1182,7 +1182,7 @@ cdef extern from "flint_wrap.h": # Returns whether the polynomial ``poly`` is monic. The zero # polynomial is not monic by definition. - void _fmpq_poly_make_monic(fmpz * rpoly, fmpz_t rden, const fmpz * poly, const fmpz_t den, long len) + void _fmpq_poly_make_monic(fmpz * rpoly, fmpz_t rden, const fmpz * poly, const fmpz_t den, slong len) # Sets ``(rpoly, rden, len)`` to the monic scalar multiple of # ``(poly, den, len)``. Assumes that ``len > 0``. Supports # aliasing between the two polynomials. @@ -1197,7 +1197,7 @@ cdef extern from "flint_wrap.h": # polynomial is defined to be square-free if it has no non-unit square # factors. We also define the zero polynomial to be square-free. - int _fmpq_poly_print(const fmpz * poly, const fmpz_t den, long len) + int _fmpq_poly_print(const fmpz * poly, const fmpz_t den, slong len) # Prints the polynomial ``(poly, den, len)`` to ``stdout``. # In case of success, returns a positive value. In case of failure, # returns a non-positive value. @@ -1207,7 +1207,7 @@ cdef extern from "flint_wrap.h": # In case of success, returns a positive value. In case of failure, # returns a non-positive value. - int _fmpq_poly_print_pretty(const fmpz *poly, const fmpz_t den, long len, const char * x) + int _fmpq_poly_print_pretty(const fmpz *poly, const fmpz_t den, slong len, const char * x) int fmpq_poly_print_pretty(const fmpq_poly_t poly, const char * var) # Prints the pretty representation of ``poly`` to ``stdout``, using @@ -1215,7 +1215,7 @@ cdef extern from "flint_wrap.h": # variable name. # In the current implementation always returns `1`. - int _fmpq_poly_fprint(FILE * file, const fmpz * poly, const fmpz_t den, long len) + int _fmpq_poly_fprint(FILE * file, const fmpz * poly, const fmpz_t den, slong len) # Prints the polynomial ``(poly, den, len)`` to the stream ``file``. # In case of success, returns a positive value. In case of failure, # returns a non-positive value. @@ -1225,7 +1225,7 @@ cdef extern from "flint_wrap.h": # In case of success, returns a positive value. In case of failure, # returns a non-positive value. - int _fmpq_poly_fprint_pretty(FILE * file, const fmpz *poly, const fmpz_t den, long len, const char * x) + int _fmpq_poly_fprint_pretty(FILE * file, const fmpz *poly, const fmpz_t den, slong len, const char * x) int fmpq_poly_fprint_pretty(FILE * file, const fmpq_poly_t poly, const char * var) # Prints the pretty representation of ``poly`` to ``stdout``, using diff --git a/src/sage/libs/flint/fmpq_vec.pxd b/src/sage/libs/flint/fmpq_vec.pxd new file mode 100644 index 00000000000..037d98e9156 --- /dev/null +++ b/src/sage/libs/flint/fmpq_vec.pxd @@ -0,0 +1,55 @@ +# distutils: libraries = flint +# distutils: depends = flint/fmpq_vec.h + +################################################################################ +# This file is auto-generated. Do not modify by hand +################################################################################ + +from libc.stdio cimport FILE +from sage.libs.gmp.types cimport * +from sage.libs.mpfr.types cimport * +from sage.libs.flint.types cimport * + +cdef extern from "flint_wrap.h": + + fmpq * _fmpq_vec_init(slong n) + # Initialises a vector of ``fmpq`` values of length `n` and sets + # all values to 0. This is equivalent to generating a ``fmpz`` vector + # of length `2n` with ``_fmpz_vec_init`` and setting all denominators + # to 1. + + void _fmpq_vec_clear(fmpq * vec, slong n) + # Frees an ``fmpq`` vector. + + void _fmpq_vec_randtest(fmpq * f, flint_rand_t state, slong len, flint_bitcnt_t bits) + # Sets the entries of a vector of the given length to random rationals with + # numerator and denominator having up to the given number of bits per entry. + + void _fmpq_vec_randtest_uniq_sorted(fmpq * vec, flint_rand_t state, slong len, flint_bitcnt_t bits) + # Sets the entries of a vector of the given length to random distinct + # rationals with numerator and denominator having up to the given number + # of bits per entry. The entries in the vector are sorted. + + void _fmpq_vec_sort(fmpq * vec, slong len) + # Sorts the entries of ``(vec, len)``. + + void _fmpq_vec_set_fmpz_vec(fmpq * res, const fmpz * vec, slong len) + # Sets ``(res, len)`` to ``(vec, len)``. + + void _fmpq_vec_get_fmpz_vec_fmpz(fmpz* num, fmpz_t den, const fmpq * a, slong len) + # Find a common denominator ``den`` of the entries of ``a`` and set ``(num, len)`` to the corresponding numerators. + + void _fmpq_vec_dot(fmpq_t res, const fmpq * vec1, const fmpq * vec2, slong len) + # Sets ``res`` to the dot product of the vectors ``(vec1, len)`` and + # ``(vec2, len)``. + + int _fmpq_vec_fprint(FILE * file, const fmpq * vec, slong len) + # Prints the vector of given length to the stream ``file``. The + # format is the length followed by two spaces, then a space separated + # list of coefficients. If the length is zero, only `0` is printed. + # In case of success, returns a positive value. In case of failure, + # returns a non-positive value. + + int _fmpq_vec_print(const fmpq * vec, slong len) + # Prints the vector of given length to ``stdout``. + # For further details, see :func:`_fmpq_vec_fprint()`. diff --git a/src/sage/libs/flint/fmpz.pxd b/src/sage/libs/flint/fmpz.pxd index f260cc6a2a4..c9b499f171e 100644 --- a/src/sage/libs/flint/fmpz.pxd +++ b/src/sage/libs/flint/fmpz.pxd @@ -38,7 +38,7 @@ cdef extern from "flint_wrap.h": # A small ``fmpz_t`` is initialised, i.e. just a ``slong``. # The value is set to zero. - void fmpz_init2(fmpz_t f, unsigned long limbs) + void fmpz_init2(fmpz_t f, ulong limbs) # Initialises the given ``fmpz_t`` to have space for the given # number of limbs. # If ``limbs`` is zero then a small ``fmpz_t`` is allocated, @@ -53,9 +53,9 @@ cdef extern from "flint_wrap.h": void fmpz_init_set(fmpz_t f, const fmpz_t g) - void fmpz_init_set_ui(fmpz_t f, unsigned long g) + void fmpz_init_set_ui(fmpz_t f, ulong g) - void fmpz_init_set_si(fmpz_t f, long g) + void fmpz_init_set_si(fmpz_t f, slong g) # Initialises `f` and sets it to the value of `g`. void fmpz_randbits(fmpz_t f, flint_rand_t state, flint_bitcnt_t bits) @@ -98,11 +98,11 @@ cdef extern from "flint_wrap.h": # If ``proved`` is nonzero, then the integer returned is # guaranteed to actually be prime. - long fmpz_get_si(const fmpz_t f) + slong fmpz_get_si(const fmpz_t f) # Returns `f` as a ``slong``. The result is undefined # if `f` does not fit into a ``slong``. - unsigned long fmpz_get_ui(const fmpz_t f) + ulong fmpz_get_ui(const fmpz_t f) # Returns `f` as an ``ulong``. The result is undefined # if `f` does not fit into an ``ulong`` or is negative. @@ -132,7 +132,7 @@ cdef extern from "flint_wrap.h": # **Note:** Requires that ``mpfr.h`` has been included before any FLINT # header is included. - double fmpz_get_d_2exp(long * exp, const fmpz_t f) + double fmpz_get_d_2exp(slong * exp, const fmpz_t f) # Returns `f` as a normalized ``double`` along with a `2`-exponent # ``exp``, i.e. if `r` is the return value then `f = r 2^{exp}`, # to within 1 ULP. @@ -152,10 +152,10 @@ cdef extern from "flint_wrap.h": # the function. Otherwise, it is up to the caller to ensure that # the allocated block of memory is sufficiently large. - void fmpz_set_si(fmpz_t f, long val) + void fmpz_set_si(fmpz_t f, slong val) # Sets `f` to the given ``slong`` value. - void fmpz_set_ui(fmpz_t f, unsigned long val) + void fmpz_set_ui(fmpz_t f, ulong val) # Sets `f` to the given ``ulong`` value. void fmpz_set_d(fmpz_t f, double c) @@ -163,10 +163,10 @@ cdef extern from "flint_wrap.h": # the value of `c` is fractional. The outcome is undefined if `c` is # infinite, not-a-number, or subnormal. - void fmpz_set_d_2exp(fmpz_t f, double d, long exp) + void fmpz_set_d_2exp(fmpz_t f, double d, slong exp) # Sets `f` to the nearest integer to `d 2^{exp}`. - void fmpz_neg_ui(fmpz_t f, unsigned long val) + void fmpz_neg_ui(fmpz_t f, ulong val) # Sets `f` to the given ``ulong`` value, and then negates `f`. void fmpz_set_uiui(fmpz_t f, mp_limb_t hi, mp_limb_t lo) @@ -177,41 +177,41 @@ cdef extern from "flint_wrap.h": # Sets `f` to ``lo``, plus ``hi`` shifted to the left by # ``FLINT_BITS``, and then negates `f`. - void fmpz_set_signed_uiui(fmpz_t f, unsigned long hi, unsigned long lo) + void fmpz_set_signed_uiui(fmpz_t f, ulong hi, ulong lo) # Sets `f` to ``lo``, plus ``hi`` shifted to the left by # ``FLINT_BITS``, interpreted as a signed two's complement # integer with ``2 * FLINT_BITS`` bits. - void fmpz_set_signed_uiuiui(fmpz_t f, unsigned long hi, unsigned long mid, unsigned long lo) + void fmpz_set_signed_uiuiui(fmpz_t f, ulong hi, ulong mid, ulong lo) # Sets `f` to ``lo``, plus ``mid`` shifted to the left by # ``FLINT_BITS``, plus ``hi`` shifted to the left by # ``2*FLINT_BITS`` bits, interpreted as a signed two's complement # integer with ``3 * FLINT_BITS`` bits. - void fmpz_set_ui_array(fmpz_t out, const unsigned long * input, long n) + void fmpz_set_ui_array(fmpz_t out, const ulong * input, slong n) # Sets ``out`` to the nonnegative integer # ``in[0] + in[1]*X + ... + in[n - 1]*X^(n - 1)`` # where ``X = 2^FLINT_BITS``. It is assumed that ``n > 0``. - void fmpz_set_signed_ui_array(fmpz_t out, const unsigned long * input, long n) + void fmpz_set_signed_ui_array(fmpz_t out, const ulong * input, slong n) # Sets ``out`` to the integer represented in ``in[0], ..., in[n - 1]`` # as a signed two's complement integer with ``n * FLINT_BITS`` bits. # It is assumed that ``n > 0``. The function operates as a call to # :func:`fmpz_set_ui_array` followed by a symmetric remainder modulo # `2^{n\cdot FLINT\_BITS}`. - void fmpz_get_ui_array(unsigned long * out, long n, const fmpz_t input) + void fmpz_get_ui_array(ulong * out, slong n, const fmpz_t input) # Assuming that the nonnegative integer ``in`` can be represented in the # form ``out[0] + out[1]*X + ... + out[n - 1]*X^(n - 1)``, # where `X = 2^{FLINT\_BITS}`, sets the corresponding elements of ``out`` # so that this is true. It is assumed that ``n > 0``. - void fmpz_get_signed_ui_array(unsigned long * out, long n, const fmpz_t input) + void fmpz_get_signed_ui_array(ulong * out, slong n, const fmpz_t input) # Retrieves the value of `in` modulo `2^{n * FLINT\_BITS}` and puts the `n` # words of the result in ``out[0], ..., out[n-1]``. This will give a signed # two's complement representation of `in` (assuming `in` doesn't overflow the array). - void fmpz_get_signed_uiui(unsigned long * hi, unsigned long * lo, const fmpz_t input) + void fmpz_get_signed_uiui(ulong * hi, ulong * lo, const fmpz_t input) # Retrieves the value of `in` modulo `2^{2 * FLINT\_BITS}` and puts the high # and low words into ``*hi`` and ``*lo`` respectively. @@ -381,19 +381,19 @@ cdef extern from "flint_wrap.h": int fmpz_fits_si(const fmpz_t f) # Returns whether the value of `f` fits into a ``slong``. - void fmpz_setbit(fmpz_t f, unsigned long i) + void fmpz_setbit(fmpz_t f, ulong i) # Sets bit index `i` of `f`. - int fmpz_tstbit(const fmpz_t f, unsigned long i) + int fmpz_tstbit(const fmpz_t f, ulong i) # Test bit index `i` of `f` and return `0` or `1`, accordingly. - mp_limb_t fmpz_abs_lbound_ui_2exp(long * exp, const fmpz_t x, int bits) + mp_limb_t fmpz_abs_lbound_ui_2exp(slong * exp, const fmpz_t x, int bits) # For nonzero `x`, returns a mantissa `m` with exactly ``bits`` bits and # sets ``exp`` to an exponent `e`, such that `|x| \ge m 2^e`. The number # of bits must be between 1 and ``FLINT_BITS`` inclusive. # The mantissa is guaranteed to be correctly rounded. - mp_limb_t fmpz_abs_ubound_ui_2exp(long * exp, const fmpz_t x, int bits) + mp_limb_t fmpz_abs_ubound_ui_2exp(slong * exp, const fmpz_t x, int bits) # For nonzero `x`, returns a mantissa `m` with exactly ``bits`` bits # and sets ``exp`` to an exponent `e`, such that `|x| \le m 2^e`. # The number of bits must be between 1 and ``FLINT_BITS`` inclusive. @@ -403,9 +403,9 @@ cdef extern from "flint_wrap.h": int fmpz_cmp(const fmpz_t f, const fmpz_t g) - int fmpz_cmp_ui(const fmpz_t f, unsigned long g) + int fmpz_cmp_ui(const fmpz_t f, ulong g) - int fmpz_cmp_si(const fmpz_t f, long g) + int fmpz_cmp_si(const fmpz_t f, slong g) # Returns a negative value if `f < g`, positive value if `g < f`, # otherwise returns `0`. @@ -419,9 +419,9 @@ cdef extern from "flint_wrap.h": int fmpz_equal(const fmpz_t f, const fmpz_t g) - int fmpz_equal_ui(const fmpz_t f, unsigned long g) + int fmpz_equal_ui(const fmpz_t f, ulong g) - int fmpz_equal_si(const fmpz_t f, long g) + int fmpz_equal_si(const fmpz_t f, slong g) # Returns `1` if `f` is equal to `g`, otherwise returns `0`. int fmpz_is_zero(const fmpz_t f) @@ -446,38 +446,38 @@ cdef extern from "flint_wrap.h": # Sets `f_1` to the absolute value of `f_2`. void fmpz_add(fmpz_t f, const fmpz_t g, const fmpz_t h) - void fmpz_add_ui(fmpz_t f, const fmpz_t g, unsigned long h) - void fmpz_add_si(fmpz_t f, const fmpz_t g, long h) + void fmpz_add_ui(fmpz_t f, const fmpz_t g, ulong h) + void fmpz_add_si(fmpz_t f, const fmpz_t g, slong h) # Sets `f` to `g + h`. void fmpz_sub(fmpz_t f, const fmpz_t g, const fmpz_t h) - void fmpz_sub_ui(fmpz_t f, const fmpz_t g, unsigned long h) - void fmpz_sub_si(fmpz_t f, const fmpz_t g, long h) + void fmpz_sub_ui(fmpz_t f, const fmpz_t g, ulong h) + void fmpz_sub_si(fmpz_t f, const fmpz_t g, slong h) # Sets `f` to `g - h`. void fmpz_mul(fmpz_t f, const fmpz_t g, const fmpz_t h) - void fmpz_mul_ui(fmpz_t f, const fmpz_t g, unsigned long h) - void fmpz_mul_si(fmpz_t f, const fmpz_t g, long h) + void fmpz_mul_ui(fmpz_t f, const fmpz_t g, ulong h) + void fmpz_mul_si(fmpz_t f, const fmpz_t g, slong h) # Sets `f` to `g \times h`. - void fmpz_mul2_uiui(fmpz_t f, const fmpz_t g, unsigned long x, unsigned long y) + void fmpz_mul2_uiui(fmpz_t f, const fmpz_t g, ulong x, ulong y) # Sets `f` to `g \times x \times y` where `x` and `y` are of type ``ulong``. - void fmpz_mul_2exp(fmpz_t f, const fmpz_t g, unsigned long e) + void fmpz_mul_2exp(fmpz_t f, const fmpz_t g, ulong e) # Sets `f` to `g \times 2^e`. # Note: Assumes that ``e + FLINT_BITS`` does not overflow. - void fmpz_one_2exp(fmpz_t f, unsigned long e) + void fmpz_one_2exp(fmpz_t f, ulong e) # Sets `f` to `2^e`. void fmpz_addmul(fmpz_t f, const fmpz_t g, const fmpz_t h) - void fmpz_addmul_ui(fmpz_t f, const fmpz_t g, unsigned long h) - void fmpz_addmul_si(fmpz_t f, const fmpz_t g, long h) + void fmpz_addmul_ui(fmpz_t f, const fmpz_t g, ulong h) + void fmpz_addmul_si(fmpz_t f, const fmpz_t g, slong h) # Sets `f` to `f + g \times h`. void fmpz_submul(fmpz_t f, const fmpz_t g, const fmpz_t h) - void fmpz_submul_ui(fmpz_t f, const fmpz_t g, unsigned long h) - void fmpz_submul_si(fmpz_t f, const fmpz_t g, long h) + void fmpz_submul_ui(fmpz_t f, const fmpz_t g, ulong h) + void fmpz_submul_si(fmpz_t f, const fmpz_t g, slong h) # Sets `f` to `f - g \times h`. void fmpz_fmma(fmpz_t f, const fmpz_t a, const fmpz_t b, const fmpz_t c, const fmpz_t d) @@ -500,31 +500,31 @@ cdef extern from "flint_wrap.h": void fmpz_tdiv_q(fmpz_t f, const fmpz_t g, const fmpz_t h) - void fmpz_cdiv_q_si(fmpz_t f, const fmpz_t g, long h) + void fmpz_cdiv_q_si(fmpz_t f, const fmpz_t g, slong h) - void fmpz_fdiv_q_si(fmpz_t f, const fmpz_t g, long h) + void fmpz_fdiv_q_si(fmpz_t f, const fmpz_t g, slong h) - void fmpz_tdiv_q_si(fmpz_t f, const fmpz_t g, long h) + void fmpz_tdiv_q_si(fmpz_t f, const fmpz_t g, slong h) - void fmpz_cdiv_q_ui(fmpz_t f, const fmpz_t g, unsigned long h) + void fmpz_cdiv_q_ui(fmpz_t f, const fmpz_t g, ulong h) - void fmpz_fdiv_q_ui(fmpz_t f, const fmpz_t g, unsigned long h) + void fmpz_fdiv_q_ui(fmpz_t f, const fmpz_t g, ulong h) - void fmpz_tdiv_q_ui(fmpz_t f, const fmpz_t g, unsigned long h) + void fmpz_tdiv_q_ui(fmpz_t f, const fmpz_t g, ulong h) - void fmpz_cdiv_q_2exp(fmpz_t f, const fmpz_t g, unsigned long exp) + void fmpz_cdiv_q_2exp(fmpz_t f, const fmpz_t g, ulong exp) - void fmpz_fdiv_q_2exp(fmpz_t f, const fmpz_t g, unsigned long exp) + void fmpz_fdiv_q_2exp(fmpz_t f, const fmpz_t g, ulong exp) - void fmpz_tdiv_q_2exp(fmpz_t f, const fmpz_t g, unsigned long exp) + void fmpz_tdiv_q_2exp(fmpz_t f, const fmpz_t g, ulong exp) void fmpz_fdiv_r(fmpz_t s, const fmpz_t g, const fmpz_t h) - void fmpz_cdiv_r_2exp(fmpz_t s, const fmpz_t g, unsigned long exp) + void fmpz_cdiv_r_2exp(fmpz_t s, const fmpz_t g, ulong exp) - void fmpz_fdiv_r_2exp(fmpz_t s, const fmpz_t g, unsigned long exp) + void fmpz_fdiv_r_2exp(fmpz_t s, const fmpz_t g, ulong exp) - void fmpz_tdiv_r_2exp(fmpz_t s, const fmpz_t g, unsigned long exp) + void fmpz_tdiv_r_2exp(fmpz_t s, const fmpz_t g, ulong exp) # Sets `f` to the quotient of `g` by `h` and/or `s` to the remainder. For the # ``2exp`` functions, ``g = 2^exp``. `If `h` is `0` an exception is raised. # Rounding is made in the following way: @@ -534,29 +534,29 @@ cdef extern from "flint_wrap.h": # * ``ndiv`` rounds the quotient such that the remainder has the smallest # absolute value. In case of ties, it rounds the quotient towards zero. - unsigned long fmpz_cdiv_ui(const fmpz_t g, unsigned long h) + ulong fmpz_cdiv_ui(const fmpz_t g, ulong h) - unsigned long fmpz_fdiv_ui(const fmpz_t g, unsigned long h) + ulong fmpz_fdiv_ui(const fmpz_t g, ulong h) - unsigned long fmpz_tdiv_ui(const fmpz_t g, unsigned long h) + ulong fmpz_tdiv_ui(const fmpz_t g, ulong h) void fmpz_divexact(fmpz_t f, const fmpz_t g, const fmpz_t h) - void fmpz_divexact_si(fmpz_t f, const fmpz_t g, long h) + void fmpz_divexact_si(fmpz_t f, const fmpz_t g, slong h) - void fmpz_divexact_ui(fmpz_t f, const fmpz_t g, unsigned long h) + void fmpz_divexact_ui(fmpz_t f, const fmpz_t g, ulong h) # Sets `f` to the quotient of `g` and `h`, assuming that the # division is exact, i.e. `g` is a multiple of `h`. If `h` # is `0` an exception is raised. - void fmpz_divexact2_uiui(fmpz_t f, const fmpz_t g, unsigned long x, unsigned long y) + void fmpz_divexact2_uiui(fmpz_t f, const fmpz_t g, ulong x, ulong y) # Sets `f` to the quotient of `g` and `h = x \times y`, assuming that # the division is exact, i.e. `g` is a multiple of `h`. # If `x` or `y` is `0` an exception is raised. int fmpz_divisible(const fmpz_t f, const fmpz_t g) - int fmpz_divisible_si(const fmpz_t f, long g) + int fmpz_divisible_si(const fmpz_t f, slong g) # Returns `1` if there is an integer `q` with `f = q g` and `0` if there is # none. @@ -568,7 +568,7 @@ cdef extern from "flint_wrap.h": # Sets `f` to the remainder of `g` divided by `h` such that the remainder is # positive. Assumes that `h` is not zero. - unsigned long fmpz_mod_ui(fmpz_t f, const fmpz_t g, unsigned long h) + ulong fmpz_mod_ui(fmpz_t f, const fmpz_t g, ulong h) # Sets `f` to the remainder of `g` divided by `h` such that the remainder is # positive and also returns this value. Raises an exception if `h` is zero. @@ -590,28 +590,28 @@ cdef extern from "flint_wrap.h": # This function will be faster than :func:`fmpz_fdiv_qr_preinvn` when the # number of limbs of `h` is at least ``PREINVN_CUTOFF``. - void fmpz_pow_ui(fmpz_t f, const fmpz_t g, unsigned long x) - void fmpz_ui_pow_ui(fmpz_t f, unsigned long g, unsigned long x) + void fmpz_pow_ui(fmpz_t f, const fmpz_t g, ulong x) + void fmpz_ui_pow_ui(fmpz_t f, ulong g, ulong x) # Sets `f` to `g^x`. Defines `0^0 = 1`. int fmpz_pow_fmpz(fmpz_t f, const fmpz_t g, const fmpz_t x) # Sets `f` to `g^x`. Defines `0^0 = 1`. Return `1` for success and `0` for # failure. The function throws only if `x` is negative. - void fmpz_powm_ui(fmpz_t f, const fmpz_t g, unsigned long e, const fmpz_t m) + void fmpz_powm_ui(fmpz_t f, const fmpz_t g, ulong e, const fmpz_t m) void fmpz_powm(fmpz_t f, const fmpz_t g, const fmpz_t e, const fmpz_t m) # Sets `f` to `g^e \bmod{m}`. If `e = 0`, sets `f` to `1`. # Assumes that `m \neq 0`, raises an ``abort`` signal otherwise. - long fmpz_clog(const fmpz_t x, const fmpz_t b) - long fmpz_clog_ui(const fmpz_t x, unsigned long b) + slong fmpz_clog(const fmpz_t x, const fmpz_t b) + slong fmpz_clog_ui(const fmpz_t x, ulong b) # Returns `\lceil\log_b x\rceil`. # Assumes that `x \geq 1` and `b \geq 2` and that # the return value fits into a signed ``slong``. - long fmpz_flog(const fmpz_t x, const fmpz_t b) - long fmpz_flog_ui(const fmpz_t x, unsigned long b) + slong fmpz_flog(const fmpz_t x, const fmpz_t b) + slong fmpz_flog_ui(const fmpz_t x, ulong b) # Returns `\lfloor\log_b x\rfloor`. # Assumes that `x \geq 1` and `b \geq 2` and that # the return value fits into a signed ``slong``. @@ -645,7 +645,7 @@ cdef extern from "flint_wrap.h": int fmpz_is_square(const fmpz_t f) # Returns nonzero if `f` is a perfect square and zero otherwise. - int fmpz_root(fmpz_t r, const fmpz_t f, long n) + int fmpz_root(fmpz_t r, const fmpz_t f, slong n) # Set `r` to the integer part of the `n`-th root of `f`. Requires that # `n > 0` and that if `n` is even then `f` be non-negative, otherwise an # exception is raised. The function returns `1` if the root was exact, @@ -657,35 +657,35 @@ cdef extern from "flint_wrap.h": # powers. No guarantee is made about `r` or `k` being the smallest # possible value. Negative values of `f` are permitted. - void fmpz_fac_ui(fmpz_t f, unsigned long n) + void fmpz_fac_ui(fmpz_t f, ulong n) # Sets `f` to the factorial `n!` where `n` is an ``ulong``. - void fmpz_fib_ui(fmpz_t f, unsigned long n) + void fmpz_fib_ui(fmpz_t f, ulong n) # Sets `f` to the Fibonacci number `F_n` where `n` is an # ``ulong``. - void fmpz_bin_uiui(fmpz_t f, unsigned long n, unsigned long k) + void fmpz_bin_uiui(fmpz_t f, ulong n, ulong k) # Sets `f` to the binomial coefficient `{n \choose k}`. - void _fmpz_rfac_ui(fmpz_t r, const fmpz_t x, unsigned long a, unsigned long b) + void _fmpz_rfac_ui(fmpz_t r, const fmpz_t x, ulong a, ulong b) # Sets `r` to the rising factorial `(x+a) (x+a+1) (x+a+2) \cdots (x+b-1)`. # Assumes `b > a`. - void fmpz_rfac_ui(fmpz_t r, const fmpz_t x, unsigned long k) + void fmpz_rfac_ui(fmpz_t r, const fmpz_t x, ulong k) # Sets `r` to the rising factorial `x (x+1) (x+2) \cdots (x+k-1)`. - void fmpz_rfac_uiui(fmpz_t r, unsigned long x, unsigned long k) + void fmpz_rfac_uiui(fmpz_t r, ulong x, ulong k) # Sets `r` to the rising factorial `x (x+1) (x+2) \cdots (x+k-1)`. - void fmpz_mul_tdiv_q_2exp(fmpz_t f, const fmpz_t g, const fmpz_t h, unsigned long exp) + void fmpz_mul_tdiv_q_2exp(fmpz_t f, const fmpz_t g, const fmpz_t h, ulong exp) # Sets `f` to the product of `g` and `h` divided by ``2^exp``, rounding # down towards zero. - void fmpz_mul_si_tdiv_q_2exp(fmpz_t f, const fmpz_t g, long x, unsigned long exp) + void fmpz_mul_si_tdiv_q_2exp(fmpz_t f, const fmpz_t g, slong x, ulong exp) # Sets `f` to the product of `g` and `x` divided by ``2^exp``, rounding # down towards zero. - void fmpz_gcd_ui(fmpz_t f, const fmpz_t g, unsigned long h) + void fmpz_gcd_ui(fmpz_t f, const fmpz_t g, ulong h) void fmpz_gcd(fmpz_t f, const fmpz_t g, const fmpz_t h) # Sets `f` to the greatest common divisor of `g` and `h`. The @@ -750,14 +750,14 @@ cdef extern from "flint_wrap.h": # Aliasing of inputs is not allowed. Similarly aliasing of inputs and outputs # is not allowed. - long _fmpz_remove(fmpz_t x, const fmpz_t f, double finv) + slong _fmpz_remove(fmpz_t x, const fmpz_t f, double finv) # Removes all factors `f` from `x` and returns the number of such. # Assumes that `x` is non-zero, that `f > 1` and that ``finv`` # is the precomputed ``double`` inverse of `f` whenever `f` is # a small integer and `0` otherwise. # Does not support aliasing. - long fmpz_remove(fmpz_t rop, const fmpz_t op, const fmpz_t f) + slong fmpz_remove(fmpz_t rop, const fmpz_t op, const fmpz_t f) # Remove all occurrences of the factor `f > 1` from the # integer ``op`` and sets ``rop`` to the resulting # integer. @@ -817,10 +817,10 @@ cdef extern from "flint_wrap.h": void fmpz_complement(fmpz_t r, const fmpz_t f) # The variable ``r`` is set to the ones-complement of ``f``. - void fmpz_clrbit(fmpz_t f, unsigned long i) + void fmpz_clrbit(fmpz_t f, ulong i) # Sets the ``i``\th bit in ``f`` to zero. - void fmpz_combit(fmpz_t f, unsigned long i) + void fmpz_combit(fmpz_t f, ulong i) # Complements the ``i``\th bit in ``f``. void fmpz_and(fmpz_t r, const fmpz_t a, const fmpz_t b) @@ -834,12 +834,12 @@ cdef extern from "flint_wrap.h": # Sets ``r`` to the bit-wise logical exclusive ``or`` of # ``a`` and ``b``. - unsigned long fmpz_popcnt(const fmpz_t a) + ulong fmpz_popcnt(const fmpz_t a) # Returns the number of '1' bits in the given Z (aka Hamming weight or # population count). # The return value is undefined if the input is negative. - void fmpz_CRT_ui(fmpz_t out, const fmpz_t r1, const fmpz_t m1, unsigned long r2, unsigned long m2, int sign) + void fmpz_CRT_ui(fmpz_t out, const fmpz_t r1, const fmpz_t m1, ulong r2, ulong m2, int sign) # Uses the Chinese Remainder Theorem to compute the unique integer # `0 \le x < M` (if sign = 0) or `-M/2 < x \le M/2` (if sign = 1) # congruent to `r_1` modulo `m_1` and `r_2` modulo `m_2`, @@ -877,7 +877,7 @@ cdef extern from "flint_wrap.h": # space which must be provided by :func:`fmpz_comb_temp_init` and # cleared by :func:`fmpz_comb_temp_clear`. - void fmpz_comb_init(fmpz_comb_t comb, mp_srcptr primes, long num_primes) + void fmpz_comb_init(fmpz_comb_t comb, mp_srcptr primes, slong num_primes) # Initialises a ``comb`` structure for multimodular reduction and # recombination. The array ``primes`` is assumed to contain # ``num_primes`` primes each of ``FLINT_BITS - 1`` bits. Modular @@ -899,7 +899,7 @@ cdef extern from "flint_wrap.h": void fmpz_multi_CRT_init(fmpz_multi_CRT_t CRT) # Initialize ``CRT`` for Chinese remaindering. - int fmpz_multi_CRT_precompute(fmpz_multi_CRT_t CRT, const fmpz * moduli, long len) + int fmpz_multi_CRT_precompute(fmpz_multi_CRT_t CRT, const fmpz * moduli, slong len) # Configure ``CRT`` for repeated Chinese remaindering of ``moduli``. The number of moduli, ``len``, should be positive. # A return of ``0`` indicates that the compilation failed and future # calls to :func:`fmpz_multi_CRT_precomp` will leave the output undefined. @@ -910,7 +910,7 @@ cdef extern from "flint_wrap.h": # Set ``output`` to an integer of smallest absolute value that is congruent to ``values + i`` modulo the ``moduli + i`` # in ``P``. - int fmpz_multi_CRT(fmpz_t output, const fmpz * moduli, const fmpz * values, long len, int sign) + int fmpz_multi_CRT(fmpz_t output, const fmpz * moduli, const fmpz * values, slong len, int sign) # Perform the same operation as :func:`fmpz_multi_CRT_precomp` while internally constructing and destroying the precomputed data. # All of the remarks in :func:`fmpz_multi_CRT_precompute` apply. @@ -973,7 +973,7 @@ cdef extern from "flint_wrap.h": # composite prime. However in that case an error is printed, as # that would be of independent interest. - int fmpz_is_prime_pocklington(fmpz_t F, fmpz_t R, const fmpz_t n, mp_ptr pm1, long num_pm1) + int fmpz_is_prime_pocklington(fmpz_t F, fmpz_t R, const fmpz_t n, mp_ptr pm1, slong num_pm1) # Applies the Pocklington primality test. The test computes a product # `F` of prime powers which divide `n - 1`. # The function then returns either `0` if `n` is definitely composite @@ -993,7 +993,7 @@ cdef extern from "flint_wrap.h": # limit. (See ``_fmpz_nm1_trial_factors``.) # Requires `n` to be odd. - void _fmpz_nm1_trial_factors(const fmpz_t n, mp_ptr pm1, long * num_pm1, unsigned long limit) + void _fmpz_nm1_trial_factors(const fmpz_t n, mp_ptr pm1, slong * num_pm1, ulong limit) # Trial factors `n - 1` up to the given limit (approximately) and stores # the factors in an array ``pm1`` whose length is written out to # ``num_pm1``. @@ -1001,7 +1001,7 @@ cdef extern from "flint_wrap.h": # be produced (and hence on the length of the array that needs to be # supplied). - int fmpz_is_prime_morrison(fmpz_t F, fmpz_t R, const fmpz_t n, mp_ptr pp1, long num_pp1) + int fmpz_is_prime_morrison(fmpz_t F, fmpz_t R, const fmpz_t n, mp_ptr pp1, slong num_pp1) # Applies the Morrison `p + 1` primality test. The test computes a # product `F` of primes which divide `n + 1`. # The function then returns either `0` if `n` is definitely composite @@ -1022,7 +1022,7 @@ cdef extern from "flint_wrap.h": # limit. (See ``_fmpz_np1_trial_factors``.) # Requires `n` to be odd and non-square. - void _fmpz_np1_trial_factors(const fmpz_t n, mp_ptr pp1, long * num_pp1, unsigned long limit) + void _fmpz_np1_trial_factors(const fmpz_t n, mp_ptr pp1, slong * num_pp1, ulong limit) # Trial factors `n + 1` up to the given limit (approximately) and stores # the factors in an array ``pp1`` whose length is written out to # ``num_pp1``. @@ -1099,7 +1099,7 @@ cdef extern from "flint_wrap.h": # GMP 6.1.2 this used Miller-Rabin iterations, and thereafter uses # a BPSW test. - void fmpz_primorial(fmpz_t res, unsigned long n) + void fmpz_primorial(fmpz_t res, ulong n) # Sets ``res`` to ``n`` primorial or `n \#`, the product of all prime # numbers less than or equal to `n`. @@ -1119,8 +1119,8 @@ cdef extern from "flint_wrap.h": # `\mu(0) = 0`. The factor version takes a precomputed # factorisation of `n`. - void fmpz_factor_divisor_sigma(fmpz_t res, unsigned long k, const fmpz_factor_t fac) - void fmpz_divisor_sigma(fmpz_t res, unsigned long k, const fmpz_t n) + void fmpz_factor_divisor_sigma(fmpz_t res, ulong k, const fmpz_factor_t fac) + void fmpz_divisor_sigma(fmpz_t res, ulong k, const fmpz_t n) # Sets ``res`` to `\sigma_k(n)`, the sum of `k`\th powers of all # divisors of `n`. The factor version takes a precomputed # factorisation of `n`. diff --git a/src/sage/libs/flint/fmpz_extras.pxd b/src/sage/libs/flint/fmpz_extras.pxd new file mode 100644 index 00000000000..4f41831cb9c --- /dev/null +++ b/src/sage/libs/flint/fmpz_extras.pxd @@ -0,0 +1,66 @@ +# distutils: libraries = flint +# distutils: depends = flint/fmpz_extras.h + +################################################################################ +# This file is auto-generated. Do not modify by hand +################################################################################ + +from libc.stdio cimport FILE +from sage.libs.gmp.types cimport * +from sage.libs.mpfr.types cimport * +from sage.libs.flint.types cimport * + +cdef extern from "flint_wrap.h": + + slong fmpz_allocated_bytes(const fmpz_t x) + # Returns the total number of bytes heap-allocated internally by this object. + # The count excludes the size of the structure itself. Add + # ``sizeof(fmpz)`` to get the size of the object as a whole. + + void fmpz_adiv_q_2exp(fmpz_t z, const fmpz_t x, flint_bitcnt_t exp) + # Sets *z* to `x / 2^{exp}`, rounded away from zero. + + void fmpz_ui_mul_ui(fmpz_t x, ulong a, ulong b) + # Sets *x* to *a* times *b*. + + void fmpz_max(fmpz_t z, const fmpz_t x, const fmpz_t y) + + void fmpz_min(fmpz_t z, const fmpz_t x, const fmpz_t y) + # Sets *z* to the maximum (respectively minimum) of *x* and *y*. + + void fmpz_add_inline(fmpz_t z, const fmpz_t x, const fmpz_t y) + + void fmpz_add_si_inline(fmpz_t z, const fmpz_t x, slong y) + + void fmpz_add_ui_inline(fmpz_t z, const fmpz_t x, ulong y) + # Sets *z* to the sum of *x* and *y*. + + void fmpz_sub_si_inline(fmpz_t z, const fmpz_t x, slong y) + # Sets *z* to the difference of *x* and *y*. + + void fmpz_add2_fmpz_si_inline(fmpz_t z, const fmpz_t x, const fmpz_t y, slong c) + # Sets *z* to the sum of *x*, *y*, and *c*. + + mp_size_t _fmpz_size(const fmpz_t x) + # Returns the number of limbs required to represent *x*. + + slong _fmpz_sub_small(const fmpz_t x, const fmpz_t y) + # Computes the difference of *x* and *y* and returns the result as + # an *slong*. The result is clamped between -*WORD_MAX* and *WORD_MAX*, + # i.e. between `\pm (2^{63}-1)` inclusive on a 64-bit machine. + + void _fmpz_set_si_small(fmpz_t x, slong v) + # Sets *x* to the integer *v* which is required to be a value + # between *COEFF_MIN* and *COEFF_MAX* so that promotion to + # a bignum cannot occur. + + void fmpz_set_mpn_large(fmpz_t z, mp_srcptr src, mp_size_t n, int negative) + # Sets *z* to the integer represented by the *n* limbs in the array *src*, + # or minus this value if *negative* is 1. + # Requires `n \ge 2` and that the top limb of *src* is nonzero. + # Note that *fmpz_set_ui*, *fmpz_neg_ui* can be used for single-limb integers. + + void fmpz_lshift_mpn(fmpz_t z, mp_srcptr src, mp_size_t n, int negative, flint_bitcnt_t shift) + # Sets *z* to the integer represented by the *n* limbs in the array *src*, + # or minus this value if *negative* is 1, shifted left by *shift* bits. + # Requires `n \ge 1` and that the top limb of *src* is nonzero. diff --git a/src/sage/libs/flint/fmpz_factor.pxd b/src/sage/libs/flint/fmpz_factor.pxd index 73461ec3854..a9b8b6421aa 100644 --- a/src/sage/libs/flint/fmpz_factor.pxd +++ b/src/sage/libs/flint/fmpz_factor.pxd @@ -18,11 +18,11 @@ cdef extern from "flint_wrap.h": void fmpz_factor_clear(fmpz_factor_t factor) # Clears an ``fmpz_factor_t`` structure. - void _fmpz_factor_append_ui(fmpz_factor_t factor, mp_limb_t p, unsigned long exp) + void _fmpz_factor_append_ui(fmpz_factor_t factor, mp_limb_t p, ulong exp) # Append a factor `p` to the given exponent to the # ``fmpz_factor_t`` structure ``factor``. - void _fmpz_factor_append(fmpz_factor_t factor, const fmpz_t p, unsigned long exp) + void _fmpz_factor_append(fmpz_factor_t factor, const fmpz_t p, ulong exp) # Append a factor `p` to the given exponent to the # ``fmpz_factor_t`` structure ``factor``. @@ -30,7 +30,7 @@ cdef extern from "flint_wrap.h": # Factors `n` into prime numbers. If `n` is zero or negative, the # sign field of the ``factor`` object will be set accordingly. - int fmpz_factor_smooth(fmpz_factor_t factor, const fmpz_t n, long bits, int proved) + int fmpz_factor_smooth(fmpz_factor_t factor, const fmpz_t n, slong bits, int proved) # Factors `n` into prime numbers up to approximately the given number of # bits and possibly one additional cofactor, which may or may not be prime. # If the number is definitely factored fully, the return value is `1`, @@ -58,10 +58,10 @@ cdef extern from "flint_wrap.h": # ``n_factor`` internally if `n` or the remainder after trial division # is smaller than one word, guaranteeing a complete factorisation. - void fmpz_factor_si(fmpz_factor_t factor, long n) + void fmpz_factor_si(fmpz_factor_t factor, slong n) # Like ``fmpz_factor``, but takes a machine integer `n` as input. - int fmpz_factor_trial_range(fmpz_factor_t factor, const fmpz_t n, unsigned long start, unsigned long num_primes) + int fmpz_factor_trial_range(fmpz_factor_t factor, const fmpz_t n, ulong start, ulong num_primes) # Factors `n` into prime factors using trial division. If `n` is # zero or negative, the sign field of the ``factor`` object will be # set accordingly. @@ -70,7 +70,7 @@ cdef extern from "flint_wrap.h": # The function returns 1 if `n` is completely factored, otherwise it returns # `0`. - int fmpz_factor_trial(fmpz_factor_t factor, const fmpz_t n, long num_primes) + int fmpz_factor_trial(fmpz_factor_t factor, const fmpz_t n, slong num_primes) # Factors `n` into prime factors using trial division. If `n` is # zero or negative, the sign field of the ``factor`` object will be # set accordingly. @@ -95,7 +95,7 @@ cdef extern from "flint_wrap.h": # them together one by one, although much more efficient algorithms # exist. - int fmpz_factor_pp1(fmpz_t factor, const fmpz_t n, unsigned long B1, unsigned long B2_sqrt, unsigned long c) + int fmpz_factor_pp1(fmpz_t factor, const fmpz_t n, ulong B1, ulong B2_sqrt, ulong c) # Use Williams' `p + 1` method to factor `n`, using a prime bound in # stage 1 of ``B1`` and a prime limit in stage 2 of at least the square # of ``B2_sqrt``. If a factor is found, the function returns `1` and diff --git a/src/sage/libs/flint/fmpz_factor.pyx b/src/sage/libs/flint/fmpz_factor.pyx deleted file mode 100644 index 8b137891791..00000000000 --- a/src/sage/libs/flint/fmpz_factor.pyx +++ /dev/null @@ -1 +0,0 @@ - diff --git a/src/sage/libs/flint/fmpz_lll.pxd b/src/sage/libs/flint/fmpz_lll.pxd index 13d98e60c4e..9b73ceeadf4 100644 --- a/src/sage/libs/flint/fmpz_lll.pxd +++ b/src/sage/libs/flint/fmpz_lll.pxd @@ -33,7 +33,7 @@ cdef extern from "flint_wrap.h": # set to `GRAM` or `Z\_BASIS` and ``fl->gt`` is set to `APPROX` or `EXACT` # in a pseudo random way. - double fmpz_lll_heuristic_dot(const double * vec1, const double * vec2, long len2, const fmpz_mat_t B, long k, long j, long exp_adj) + double fmpz_lll_heuristic_dot(const double * vec1, const double * vec2, slong len2, const fmpz_mat_t B, slong k, slong j, slong exp_adj) # Computes the dot product of two vectors of doubles ``vec1`` and # ``vec2``, which are respectively ``double`` approximations (up to # scaling by a power of 2) to rows ``k`` and ``j`` in the exact integer @@ -187,7 +187,7 @@ cdef extern from "flint_wrap.h": # ``fl->gt`` == `APPROX`, and finally to the mpf version # (:func:`fmpz_lll_mpf_with_removal`) if needed. - int fmpz_lll_with_removal_ulll(fmpz_mat_t FM, fmpz_mat_t UM, long new_size, const fmpz_t gs_B, const fmpz_lll_t fl) + int fmpz_lll_with_removal_ulll(fmpz_mat_t FM, fmpz_mat_t UM, slong new_size, const fmpz_t gs_B, const fmpz_lll_t fl) # ULLL is a new style of LLL which adjoins an identity matrix to the # input lattice ``FM``, then scales the lattice down to ``new_size`` # bits and reduces this augmented lattice. This tends to be more stable @@ -214,7 +214,7 @@ cdef extern from "flint_wrap.h": # * :func:`fmpz_mat_is_reduced_with_removal` or :func:`fmpz_mat_is_reduced_gram_with_removal` # are optimzied by calling the above heuristics first and returning right away if they give a conclusive answer. - void fmpz_lll_storjohann_ulll(fmpz_mat_t FM, long new_size, const fmpz_lll_t fl) + void fmpz_lll_storjohann_ulll(fmpz_mat_t FM, slong new_size, const fmpz_lll_t fl) # Performs ULLL using :func:`fmpz_mat_lll_storjohann` as the LLL function. void fmpz_lll(fmpz_mat_t B, fmpz_mat_t U, const fmpz_lll_t fl) diff --git a/src/sage/libs/flint/fmpz_mat.pxd b/src/sage/libs/flint/fmpz_mat.pxd index f5ba596ac8f..e116c2667d7 100644 --- a/src/sage/libs/flint/fmpz_mat.pxd +++ b/src/sage/libs/flint/fmpz_mat.pxd @@ -12,7 +12,7 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void fmpz_mat_init(fmpz_mat_t mat, long rows, long cols) + void fmpz_mat_init(fmpz_mat_t mat, slong rows, slong cols) # Initialises a matrix with the given number of rows and columns for use. void fmpz_mat_clear(fmpz_mat_t mat) @@ -26,8 +26,8 @@ cdef extern from "flint_wrap.h": # Initialises the matrix ``mat`` to the same size as ``src`` and # sets it to a copy of ``src``. - long fmpz_mat_nrows(const fmpz_mat_t mat) - long fmpz_mat_ncols(const fmpz_mat_t mat) + slong fmpz_mat_nrows(const fmpz_mat_t mat) + slong fmpz_mat_ncols(const fmpz_mat_t mat) # Returns respectively the number of rows and columns of the matrix. void fmpz_mat_swap(fmpz_mat_t mat1, fmpz_mat_t mat2) @@ -38,7 +38,7 @@ cdef extern from "flint_wrap.h": # Swaps two matrices by swapping the individual entries rather than swapping # the contents of the structs. - fmpz * fmpz_mat_entry(const fmpz_mat_t mat, long i, long j) + fmpz * fmpz_mat_entry(const fmpz_mat_t mat, slong i, slong j) # Returns a reference to the entry of ``mat`` at row `i` and column `j`. # This reference can be passed as an input or output variable to any # function in the ``fmpz`` module for direct manipulation. @@ -53,25 +53,25 @@ cdef extern from "flint_wrap.h": # and zeroes elsewhere. If ``mat`` is nonsquare, it is set to the # truncation of a unit matrix. - void fmpz_mat_swap_rows(fmpz_mat_t mat, long * perm, long r, long s) + void fmpz_mat_swap_rows(fmpz_mat_t mat, slong * perm, slong r, slong s) # Swaps rows ``r`` and ``s`` of ``mat``. If ``perm`` is non-``NULL``, the # permutation of the rows will also be applied to ``perm``. - void fmpz_mat_swap_cols(fmpz_mat_t mat, long * perm, long r, long s) + void fmpz_mat_swap_cols(fmpz_mat_t mat, slong * perm, slong r, slong s) # Swaps columns ``r`` and ``s`` of ``mat``. If ``perm`` is non-``NULL``, the # permutation of the columns will also be applied to ``perm``. - void fmpz_mat_invert_rows(fmpz_mat_t mat, long * perm) + void fmpz_mat_invert_rows(fmpz_mat_t mat, slong * perm) # Swaps rows ``i`` and ``r - i`` of ``mat`` for ``0 <= i < r/2``, where # ``r`` is the number of rows of ``mat``. If ``perm`` is non-``NULL``, the # permutation of the rows will also be applied to ``perm``. - void fmpz_mat_invert_cols(fmpz_mat_t mat, long * perm) + void fmpz_mat_invert_cols(fmpz_mat_t mat, slong * perm) # Swaps columns ``i`` and ``c - i`` of ``mat`` for ``0 <= i < c/2``, where # ``c`` is the number of columns of ``mat``. If ``perm`` is non-``NULL``, the # permutation of the columns will also be applied to ``perm``. - void fmpz_mat_window_init(fmpz_mat_t window, const fmpz_mat_t mat, long r1, long c1, long r2, long c2) + void fmpz_mat_window_init(fmpz_mat_t window, const fmpz_mat_t mat, slong r1, slong c1, slong r2, slong c2) # Initializes the matrix ``window`` to be an ``r2 - r1`` by # ``c2 - c1`` submatrix of ``mat`` whose ``(0,0)`` entry # is the ``(r1, c1)`` entry of ``mat``. The memory for the @@ -107,7 +107,7 @@ cdef extern from "flint_wrap.h": # Running down the rest of the diagonal are the values ``2^bits`` with # all remaining entries zero. - void fmpz_mat_randntrulike(fmpz_mat_t mat, flint_rand_t state, flint_bitcnt_t bits, unsigned long q) + void fmpz_mat_randntrulike(fmpz_mat_t mat, flint_rand_t state, flint_bitcnt_t bits, ulong q) # Sets a square matrix ``mat`` of even dimension to a random # *NTRU like* matrix. # The matrix is broken into four square submatrices. The top left submatrix @@ -118,7 +118,7 @@ cdef extern from "flint_wrap.h": # number of bits. Then entry `(i, j)` of the submatrix is set to # `h[i + j \bmod{r/2}]`. - void fmpz_mat_randntrulike2(fmpz_mat_t mat, flint_rand_t state, flint_bitcnt_t bits, unsigned long q) + void fmpz_mat_randntrulike2(fmpz_mat_t mat, flint_rand_t state, flint_bitcnt_t bits, ulong q) # Sets a square matrix ``mat`` of even dimension to a random # *NTRU like* matrix. # The matrix is broken into four square submatrices. The top left submatrix @@ -137,14 +137,14 @@ cdef extern from "flint_wrap.h": # are set to a random entry in the range `(-2^b + 1, 2^b - 1)` whilst the # entries to the right of the diagonal in row `i` are set to zero. - int fmpz_mat_randpermdiag(fmpz_mat_t mat, flint_rand_t state, const fmpz * diag, long n) + int fmpz_mat_randpermdiag(fmpz_mat_t mat, flint_rand_t state, const fmpz * diag, slong n) # Sets ``mat`` to a random permutation of the rows and columns of a # given diagonal matrix. The diagonal matrix is specified in the form of # an array of the `n` initial entries on the main diagonal. # The return value is `0` or `1` depending on whether the permutation is # even or odd. - void fmpz_mat_randrank(fmpz_mat_t mat, flint_rand_t state, long rank, flint_bitcnt_t bits) + void fmpz_mat_randrank(fmpz_mat_t mat, flint_rand_t state, slong rank, flint_bitcnt_t bits) # Sets ``mat`` to a random sparse matrix with the given rank, # having exactly as many non-zero elements as the rank, with the # nonzero elements being random integers of the given bit size. @@ -160,7 +160,7 @@ cdef extern from "flint_wrap.h": # The matrix can be transformed into a dense matrix with unchanged # determinant by subsequently calling :func:`fmpz_mat_randops`. - void fmpz_mat_randops(fmpz_mat_t mat, flint_rand_t state, long count) + void fmpz_mat_randops(fmpz_mat_t mat, flint_rand_t state, slong count) # Randomises ``mat`` by performing elementary row or column operations. # More precisely, at most ``count`` random additions or subtractions of # distinct rows and columns will be performed. This leaves the rank @@ -225,14 +225,14 @@ cdef extern from "flint_wrap.h": # Returns a non-zero value if the number of rows is equal to the # number of columns in ``mat``, and otherwise returns zero. - int fmpz_mat_is_zero_row(const fmpz_mat_t mat, long i) + int fmpz_mat_is_zero_row(const fmpz_mat_t mat, slong i) # Returns a non-zero value if row `i` of ``mat`` is zero. - int fmpz_mat_equal_col(fmpz_mat_t M, long m, long n) + int fmpz_mat_equal_col(fmpz_mat_t M, slong m, slong n) # Returns `1` if columns `m` and `n` of the matrix `M` are equal, otherwise # returns `0`. - int fmpz_mat_equal_row(fmpz_mat_t M, long m, long n) + int fmpz_mat_equal_row(fmpz_mat_t M, slong m, slong n) # Returns `1` if rows `m` and `n` of the matrix `M` are equal, otherwise # returns `0`. @@ -268,27 +268,27 @@ cdef extern from "flint_wrap.h": # with entries satisfying `-mn/2 <= c < mn/2` (if sign = 1) # or `0 <= c < mn` (if sign = 0). - void fmpz_mat_multi_mod_ui_precomp(nmod_mat_t * residues, long nres, const fmpz_mat_t mat, const fmpz_comb_t comb, fmpz_comb_temp_t temp) + void fmpz_mat_multi_mod_ui_precomp(nmod_mat_t * residues, slong nres, const fmpz_mat_t mat, const fmpz_comb_t comb, fmpz_comb_temp_t temp) # Sets each of the ``nres`` matrices in ``residues`` to ``mat`` reduced modulo # the modulus of the respective matrix, given precomputed ``comb`` and # ``comb_temp`` structures. # Note: ``fmpz.h`` must be included **before** ``fmpz_mat.h`` in order for # this function to be declared. - void fmpz_mat_multi_mod_ui(nmod_mat_t * residues, long nres, const fmpz_mat_t mat) + void fmpz_mat_multi_mod_ui(nmod_mat_t * residues, slong nres, const fmpz_mat_t mat) # Sets each of the ``nres`` matrices in ``residues`` to ``mat`` # reduced modulo the modulus of the respective matrix. # This function is provided for convenience purposes. # For reducing or reconstructing multiple integer matrices over the same # set of moduli, it is faster to use ``fmpz_mat_multi_mod_precomp``. - void fmpz_mat_multi_CRT_ui_precomp(fmpz_mat_t mat, nmod_mat_t * const residues, long nres, const fmpz_comb_t comb, fmpz_comb_temp_t temp, int sign) + void fmpz_mat_multi_CRT_ui_precomp(fmpz_mat_t mat, nmod_mat_t * const residues, slong nres, const fmpz_comb_t comb, fmpz_comb_temp_t temp, int sign) # Reconstructs ``mat`` from its images modulo the ``nres`` matrices in # ``residues``, given precomputed ``comb`` and ``comb_temp`` structures. # Note: ``fmpz.h`` must be included **before** ``fmpz_mat.h`` in order for # this function to be declared. - void fmpz_mat_multi_CRT_ui(fmpz_mat_t mat, nmod_mat_t * const residues, long nres, int sign) + void fmpz_mat_multi_CRT_ui(fmpz_mat_t mat, nmod_mat_t * const residues, slong nres, int sign) # Reconstructs ``mat`` from its images modulo the ``nres`` matrices # in ``residues``. # This function is provided for convenience purposes. @@ -307,49 +307,49 @@ cdef extern from "flint_wrap.h": # Sets ``B`` to the elementwise negation of ``A``. Both inputs # must be of the same size. Aliasing is allowed. - void fmpz_mat_scalar_mul_si(fmpz_mat_t B, const fmpz_mat_t A, long c) - void fmpz_mat_scalar_mul_ui(fmpz_mat_t B, const fmpz_mat_t A, unsigned long c) + void fmpz_mat_scalar_mul_si(fmpz_mat_t B, const fmpz_mat_t A, slong c) + void fmpz_mat_scalar_mul_ui(fmpz_mat_t B, const fmpz_mat_t A, ulong c) void fmpz_mat_scalar_mul_fmpz(fmpz_mat_t B, const fmpz_mat_t A, const fmpz_t c) # Set ``B = A*c`` where ``A`` is an ``fmpz_mat_t`` and ``c`` # is a scalar respectively of type ``slong``, ``ulong``, # or ``fmpz_t``. The dimensions of ``A`` and ``B`` must # be compatible. - void fmpz_mat_scalar_addmul_si(fmpz_mat_t B, const fmpz_mat_t A, long c) - void fmpz_mat_scalar_addmul_ui(fmpz_mat_t B, const fmpz_mat_t A, unsigned long c) + void fmpz_mat_scalar_addmul_si(fmpz_mat_t B, const fmpz_mat_t A, slong c) + void fmpz_mat_scalar_addmul_ui(fmpz_mat_t B, const fmpz_mat_t A, ulong c) void fmpz_mat_scalar_addmul_fmpz(fmpz_mat_t B, const fmpz_mat_t A, const fmpz_t c) # Set ``B = B + A*c`` where ``A`` is an ``fmpz_mat_t`` and ``c`` # is a scalar respectively of type ``slong``, ``ulong``, # or ``fmpz_t``. The dimensions of ``A`` and ``B`` must # be compatible. - void fmpz_mat_scalar_submul_si(fmpz_mat_t B, const fmpz_mat_t A, long c) - void fmpz_mat_scalar_submul_ui(fmpz_mat_t B, const fmpz_mat_t A, unsigned long c) + void fmpz_mat_scalar_submul_si(fmpz_mat_t B, const fmpz_mat_t A, slong c) + void fmpz_mat_scalar_submul_ui(fmpz_mat_t B, const fmpz_mat_t A, ulong c) void fmpz_mat_scalar_submul_fmpz(fmpz_mat_t B, const fmpz_mat_t A, const fmpz_t c) # Set ``B = B - A*c`` where ``A`` is an ``fmpz_mat_t`` and ``c`` # is a scalar respectively of type ``slong``, ``ulong``, # or ``fmpz_t``. The dimensions of ``A`` and ``B`` must # be compatible. - void fmpz_mat_scalar_addmul_nmod_mat_ui(fmpz_mat_t B, const nmod_mat_t A, unsigned long c) + void fmpz_mat_scalar_addmul_nmod_mat_ui(fmpz_mat_t B, const nmod_mat_t A, ulong c) void fmpz_mat_scalar_addmul_nmod_mat_fmpz(fmpz_mat_t B, const nmod_mat_t A, const fmpz_t c) # Set ``B = B + A*c`` where ``A`` is an ``nmod_mat_t`` and ``c`` # is a scalar respectively of type ``ulong`` or ``fmpz_t``. # The dimensions of ``A`` and ``B`` must be compatible. - void fmpz_mat_scalar_divexact_si(fmpz_mat_t B, const fmpz_mat_t A, long c) - void fmpz_mat_scalar_divexact_ui(fmpz_mat_t B, const fmpz_mat_t A, unsigned long c) + void fmpz_mat_scalar_divexact_si(fmpz_mat_t B, const fmpz_mat_t A, slong c) + void fmpz_mat_scalar_divexact_ui(fmpz_mat_t B, const fmpz_mat_t A, ulong c) void fmpz_mat_scalar_divexact_fmpz(fmpz_mat_t B, const fmpz_mat_t A, const fmpz_t c) # Set ``A = B / c``, where ``B`` is an ``fmpz_mat_t`` and ``c`` # is a scalar respectively of type ``slong``, ``ulong``, # or ``fmpz_t``, which is assumed to divide all elements of # ``B`` exactly. - void fmpz_mat_scalar_mul_2exp(fmpz_mat_t B, const fmpz_mat_t A, unsigned long exp) + void fmpz_mat_scalar_mul_2exp(fmpz_mat_t B, const fmpz_mat_t A, ulong exp) # Set the matrix ``B`` to the matrix ``A``, of the same dimensions, # multiplied by `2^{exp}`. - void fmpz_mat_scalar_tdiv_q_2exp(fmpz_mat_t B, const fmpz_mat_t A, unsigned long exp) + void fmpz_mat_scalar_tdiv_q_2exp(fmpz_mat_t B, const fmpz_mat_t A, ulong exp) # Set the matrix ``B`` to the matrix ``A``, of the same dimensions, # divided by `2^{exp}`, rounding down towards zero. @@ -413,7 +413,7 @@ cdef extern from "flint_wrap.h": # It is highly efficient for squaring matrices which satisfy both the # following conditions: (a) large elements, (b) dimensions less than 150. - void fmpz_mat_pow(fmpz_mat_t B, const fmpz_mat_t A, unsigned long e) + void fmpz_mat_pow(fmpz_mat_t B, const fmpz_mat_t A, ulong e) # Sets ``B`` to the matrix ``A`` raised to the power ``e``, # where ``A`` must be a square matrix. Aliasing is allowed. @@ -427,14 +427,14 @@ cdef extern from "flint_wrap.h": # - the entries of `A` and `B` are all nonnegative and strictly less than `2^{2*FLINT\_BITS}`, or # - the entries of `A` and `B` are all strictly less than `2^{2*FLINT\_BITS - 1}` in absolute value. - void fmpz_mat_mul_fmpz_vec(fmpz * c, const fmpz_mat_t A, const fmpz * b, long blen) - void fmpz_mat_mul_fmpz_vec_ptr(fmpz * const * c, const fmpz_mat_t A, const fmpz * const * b, long blen) + void fmpz_mat_mul_fmpz_vec(fmpz * c, const fmpz_mat_t A, const fmpz * b, slong blen) + void fmpz_mat_mul_fmpz_vec_ptr(fmpz * const * c, const fmpz_mat_t A, const fmpz * const * b, slong blen) # Compute a matrix-vector product of ``A`` and ``(b, blen)`` and store the result in ``c``. # The vector ``(b, blen)`` is either truncated or zero-extended to the number of columns of ``A``. # The number of entries written to ``c`` is always equal to the number of rows of ``A``. - void fmpz_mat_fmpz_vec_mul(fmpz * c, const fmpz * a, long alen, const fmpz_mat_t B) - void fmpz_mat_fmpz_vec_mul_ptr(fmpz * const * c, const fmpz * const * a, long alen, const fmpz_mat_t B) + void fmpz_mat_fmpz_vec_mul(fmpz * c, const fmpz * a, slong alen, const fmpz_mat_t B) + void fmpz_mat_fmpz_vec_mul_ptr(fmpz * const * c, const fmpz * const * a, slong alen, const fmpz_mat_t B) # Compute a vector-matrix product of ``(a, alen)`` and ``B`` and store the result in ``c``. # The vector ``(a, alen)`` is either truncated or zero-extended to the number of rows of ``B``. # The number of entries written to ``c`` is always equal to the number of columns of ``B``. @@ -533,7 +533,7 @@ cdef extern from "flint_wrap.h": # common multiple of the denominators in `x`. This yields a divisor `d` # such that `|\det(A)| / d` is tiny with very high probability. - void fmpz_mat_similarity(fmpz_mat_t A, long r, fmpz_t d) + void fmpz_mat_similarity(fmpz_mat_t A, slong r, fmpz_t d) # Applies a similarity transform to the `n\times n` matrix `M` in-place. # If `P` is the `n\times n` identity matrix the zero entries of whose row # `r` (`0`-indexed) have been replaced by `d`, this transform is equivalent @@ -567,7 +567,7 @@ cdef extern from "flint_wrap.h": # Computes the characteristic polynomial of length `n + 1` of # an `n \times n` square matrix. - long _fmpz_mat_minpoly_modular(fmpz * cp, const fmpz_mat_t mat) + slong _fmpz_mat_minpoly_modular(fmpz * cp, const fmpz_mat_t mat) # Sets ``(cp, n+1)`` to the modular polynomial of # an `n \times n` square matrix and returns its length. @@ -576,19 +576,19 @@ cdef extern from "flint_wrap.h": # Uses a modular method based on an average time `O(n^3)`, worst case # `O(n^4)` method over `\mathbb{Z}/n\mathbb{Z}`. - long _fmpz_mat_minpoly(fmpz * cp, const fmpz_mat_t mat) + slong _fmpz_mat_minpoly(fmpz * cp, const fmpz_mat_t mat) # Sets ``cp`` to the minimal polynomial of an `n \times n` square # matrix and returns its length. void fmpz_mat_minpoly(fmpz_poly_t cp, const fmpz_mat_t mat) # Computes the minimal polynomial of an `n \times n` square matrix. - long fmpz_mat_rank(const fmpz_mat_t A) + slong fmpz_mat_rank(const fmpz_mat_t A) # Returns the rank, that is, the number of linearly independent columns # (equivalently, rows), of `A`. The rank is computed by row reducing # a copy of `A`. - int fmpz_mat_col_partition(long * part, fmpz_mat_t M, int short_circuit) + int fmpz_mat_col_partition(slong * part, fmpz_mat_t M, int short_circuit) # Returns the number `p` of distinct columns of `M` (or `0` if the flag # ``short_circuit`` is set and this number is greater than the number # of rows of `M`). The entries of array ``part`` are set to values in @@ -615,7 +615,7 @@ cdef extern from "flint_wrap.h": # Uses fraction-free LU decomposition followed by fraction-free # forward and back substitution. - int fmpz_mat_solve_fflu_precomp(fmpz_mat_t X, const long * perm, const fmpz_mat_t FFLU, const fmpz_mat_t B) + int fmpz_mat_solve_fflu_precomp(fmpz_mat_t X, const slong * perm, const fmpz_mat_t FFLU, const fmpz_mat_t B) # Performs fraction-free forward and back substitution given a precomputed # fraction-free LU decomposition and corresponding permutation. If no # impossible division is encountered, the function returns `1`. This does not @@ -700,7 +700,7 @@ cdef extern from "flint_wrap.h": # Note that the matrices `A` and `B` may have any shape as long as they have # the same number of rows. - long fmpz_mat_find_pivot_any(const fmpz_mat_t mat, long start_row, long end_row, long c) + slong fmpz_mat_find_pivot_any(const fmpz_mat_t mat, slong start_row, slong end_row, slong c) # Attempts to find a pivot entry for row reduction. # Returns a row index `r` between ``start_row`` (inclusive) and # ``stop_row`` (exclusive) such that column `c` in ``mat`` has @@ -710,7 +710,7 @@ cdef extern from "flint_wrap.h": # entries in the matrix have roughly the same size, but can lead to # unnecessary coefficient growth if the entries vary in size. - long fmpz_mat_fflu(fmpz_mat_t B, fmpz_t den, long * perm, const fmpz_mat_t A, int rank_check) + slong fmpz_mat_fflu(fmpz_mat_t B, fmpz_t den, slong * perm, const fmpz_mat_t A, int rank_check) # Uses fraction-free Gaussian elimination to set (``B``, ``den``) to a # fraction-free LU decomposition of ``A`` and returns the # rank of ``A``. Aliasing of ``A`` and ``B`` is allowed. @@ -726,14 +726,14 @@ cdef extern from "flint_wrap.h": # determinant is not generally the minimal denominator. # The fraction-free LU decomposition is defined in [NakTurWil1997]_. - long fmpz_mat_rref(fmpz_mat_t B, fmpz_t den, const fmpz_mat_t A) + slong fmpz_mat_rref(fmpz_mat_t B, fmpz_t den, const fmpz_mat_t A) # Sets (``B``, ``den``) to the reduced row echelon form of ``A`` # and returns the rank of ``A``. Aliasing of ``A`` and ``B`` # is allowed. # The algorithm used chooses between ``fmpz_mat_rref_fflu`` and # ``fmpz_mat_rref_mul`` based on the dimensions of the input matrix. - long fmpz_mat_rref_fflu(fmpz_mat_t B, fmpz_t den, const fmpz_mat_t A) + slong fmpz_mat_rref_fflu(fmpz_mat_t B, fmpz_t den, const fmpz_mat_t A) # Sets (``B``, ``den``) to the reduced row echelon form of ``A`` # and returns the rank of ``A``. Aliasing of ``A`` and ``B`` # is allowed. @@ -750,7 +750,7 @@ cdef extern from "flint_wrap.h": # `S` is an appropriate submatrix of `A` (`S = A` if `A` is square). # Note that the determinant is not generally the minimal denominator. - long fmpz_mat_rref_mul(fmpz_mat_t B, fmpz_t den, const fmpz_mat_t A) + slong fmpz_mat_rref_mul(fmpz_mat_t B, fmpz_t den, const fmpz_mat_t A) # Sets (``B``, ``den``) to the reduced row echelon form of ``A`` # and returns the rank of ``A``. Aliasing of ``A`` and ``B`` # is allowed. @@ -761,11 +761,11 @@ cdef extern from "flint_wrap.h": # the reduced row echelon form of the whole of ``A``. This procedure is # described in [Stein2007]_. - int fmpz_mat_is_in_rref_with_rank(const fmpz_mat_t A, const fmpz_t den, long rank) + int fmpz_mat_is_in_rref_with_rank(const fmpz_mat_t A, const fmpz_t den, slong rank) # Checks that the matrix `A/den` is in reduced row echelon form of rank # ``rank``, returns 1 if so and 0 otherwise. - long fmpz_mat_rref_mod(long * perm, fmpz_mat_t A, const fmpz_t p) + slong fmpz_mat_rref_mod(slong * perm, fmpz_mat_t A, const fmpz_t p) # Uses fraction-free Gauss-Jordan elimination to set ``A`` # to its reduced row echelon form and returns the rank of ``A``. # All computations are done modulo p. @@ -780,7 +780,7 @@ cdef extern from "flint_wrap.h": # for a definition of the strong echelon form and the algorithm used here. # `A` must have at least as many rows as columns. - long fmpz_mat_howell_form_mod(fmpz_mat_t A, const fmpz_t mod) + slong fmpz_mat_howell_form_mod(fmpz_mat_t A, const fmpz_t mod) # Transforms `A` such that `A` modulo ``mod`` is the Howell form of the # input matrix modulo ``mod``. # For a definition of the Howell form see [StoMul1998]_. The Howell form @@ -788,7 +788,7 @@ cdef extern from "flint_wrap.h": # the rows. # `A` must have at least as many rows as columns. - long fmpz_mat_nullspace(fmpz_mat_t B, const fmpz_mat_t A) + slong fmpz_mat_nullspace(fmpz_mat_t B, const fmpz_mat_t A) # Computes a basis for the right rational nullspace of `A` and returns # the dimension of the nullspace (or nullity). `B` is set to a matrix with # linearly independent columns and maximal rank such that `AB = 0` @@ -799,7 +799,7 @@ cdef extern from "flint_wrap.h": # `B` must be allocated with sufficient space to represent the result # (at most `n \times n` where `n` is the number of columns of `A`). - long fmpz_mat_rref_fraction_free(long * perm, fmpz_mat_t B, fmpz_t den, const fmpz_mat_t A) + slong fmpz_mat_rref_fraction_free(slong * perm, fmpz_mat_t B, fmpz_t den, const fmpz_mat_t A) # Computes an integer matrix ``B`` and an integer ``den`` such that # ``B / den`` is the unique row reduced echelon form (RREF) of ``A`` # and returns the rank, i.e. the number of nonzero rows in ``B``. diff --git a/src/sage/libs/flint/fmpz_mod.pxd b/src/sage/libs/flint/fmpz_mod.pxd index 54df929e69a..12110dffb05 100644 --- a/src/sage/libs/flint/fmpz_mod.pxd +++ b/src/sage/libs/flint/fmpz_mod.pxd @@ -34,21 +34,21 @@ cdef extern from "flint_wrap.h": # Set `a` to `b+c` modulo `n`. void fmpz_mod_add_fmpz(fmpz_t a, const fmpz_t b, const fmpz_t c, const fmpz_mod_ctx_t ctx) - void fmpz_mod_add_ui(fmpz_t a, const fmpz_t b, unsigned long c, const fmpz_mod_ctx_t ctx) - void fmpz_mod_add_si(fmpz_t a, const fmpz_t b, long c, const fmpz_mod_ctx_t ctx) + void fmpz_mod_add_ui(fmpz_t a, const fmpz_t b, ulong c, const fmpz_mod_ctx_t ctx) + void fmpz_mod_add_si(fmpz_t a, const fmpz_t b, slong c, const fmpz_mod_ctx_t ctx) # Set `a` to `b+c` modulo `n` where only `b` is assumed to be canonical. void fmpz_mod_sub(fmpz_t a, const fmpz_t b, const fmpz_t c, const fmpz_mod_ctx_t ctx) # Set `a` to `b-c` modulo `n`. void fmpz_mod_sub_fmpz(fmpz_t a, const fmpz_t b, const fmpz_t c, const fmpz_mod_ctx_t ctx) - void fmpz_mod_sub_ui(fmpz_t a, const fmpz_t b, unsigned long c, const fmpz_mod_ctx_t ctx) - void fmpz_mod_sub_si(fmpz_t a, const fmpz_t b, long c, const fmpz_mod_ctx_t ctx) + void fmpz_mod_sub_ui(fmpz_t a, const fmpz_t b, ulong c, const fmpz_mod_ctx_t ctx) + void fmpz_mod_sub_si(fmpz_t a, const fmpz_t b, slong c, const fmpz_mod_ctx_t ctx) # Set `a` to `b-c` modulo `n` where only `b` is assumed to be canonical. void fmpz_mod_fmpz_sub(fmpz_t a, const fmpz_t b, const fmpz_t c, const fmpz_mod_ctx_t ctx) - void fmpz_mod_ui_sub(fmpz_t a, unsigned long b, const fmpz_t c, const fmpz_mod_ctx_t ctx) - void fmpz_mod_si_sub(fmpz_t a, long b, const fmpz_t c, const fmpz_mod_ctx_t ctx) + void fmpz_mod_ui_sub(fmpz_t a, ulong b, const fmpz_t c, const fmpz_mod_ctx_t ctx) + void fmpz_mod_si_sub(fmpz_t a, slong b, const fmpz_t c, const fmpz_mod_ctx_t ctx) # Set `a` to `b-c` modulo `n` where only `c` is assumed to be canonical. void fmpz_mod_neg(fmpz_t a, const fmpz_t b, const fmpz_mod_ctx_t ctx) @@ -65,7 +65,7 @@ cdef extern from "flint_wrap.h": int fmpz_mod_divides(fmpz_t a, const fmpz_t b, const fmpz_t c, const fmpz_mod_ctx_t ctx) # If `a\cdot c = b \mod n` has a solution for `a` return `1` and set `a` to such a solution. Otherwise return `0` and leave `a` undefined. - void fmpz_mod_pow_ui(fmpz_t a, const fmpz_t b, unsigned long e, const fmpz_mod_ctx_t ctx) + void fmpz_mod_pow_ui(fmpz_t a, const fmpz_t b, ulong e, const fmpz_mod_ctx_t ctx) # Set `a` to `b^e` modulo `n`. int fmpz_mod_pow_fmpz(fmpz_t a, const fmpz_t b, const fmpz_t e, const fmpz_mod_ctx_t ctx) diff --git a/src/sage/libs/flint/fmpz_mod_mat.pxd b/src/sage/libs/flint/fmpz_mod_mat.pxd index 5c2e009b5c0..8c86b964eef 100644 --- a/src/sage/libs/flint/fmpz_mod_mat.pxd +++ b/src/sage/libs/flint/fmpz_mod_mat.pxd @@ -12,13 +12,13 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - fmpz * fmpz_mod_mat_entry(const fmpz_mod_mat_t mat, long i, long j) + fmpz * fmpz_mod_mat_entry(const fmpz_mod_mat_t mat, slong i, slong j) # Return a reference to the element at row ``i`` and column ``j`` of ``mat``. - void fmpz_mod_mat_set_entry(fmpz_mod_mat_t mat, long i, long j, const fmpz_t val) + void fmpz_mod_mat_set_entry(fmpz_mod_mat_t mat, slong i, slong j, const fmpz_t val) # Set the entry at row ``i`` and column ``j`` of ``mat`` to ``val``. - void fmpz_mod_mat_init(fmpz_mod_mat_t mat, long rows, long cols, const fmpz_t n) + void fmpz_mod_mat_init(fmpz_mod_mat_t mat, slong rows, slong cols, const fmpz_t n) # Initialise ``mat`` as a matrix with the given number of ``rows`` and # ``cols`` and modulus ``n``. @@ -29,9 +29,9 @@ cdef extern from "flint_wrap.h": void fmpz_mod_mat_clear(fmpz_mod_mat_t mat) # Clear ``mat`` and release any memory it used. - long fmpz_mod_mat_nrows(const fmpz_mod_mat_t mat) + slong fmpz_mod_mat_nrows(const fmpz_mod_mat_t mat) - long fmpz_mod_mat_ncols(const fmpz_mod_mat_t mat) + slong fmpz_mod_mat_ncols(const fmpz_mod_mat_t mat) # Return the number of columns of ``mat``. void _fmpz_mod_mat_set_mod(fmpz_mod_mat_t mat, const fmpz_t n) @@ -64,7 +64,7 @@ cdef extern from "flint_wrap.h": # Generate a random matrix with the existing dimensions and entries in # `[0, n)` where ``n`` is the modulus. - void fmpz_mod_mat_window_init(fmpz_mod_mat_t window, const fmpz_mod_mat_t mat, long r1, long c1, long r2, long c2) + void fmpz_mod_mat_window_init(fmpz_mod_mat_t window, const fmpz_mod_mat_t mat, slong r1, slong c1, slong r2, slong c2) # Initializes the matrix ``window`` to be an ``r2 - r1`` by # ``c2 - c1`` submatrix of ``mat`` whose ``(0, 0)`` entry # is the ``(r1, c1)`` entry of ``mat``. The memory for the @@ -114,10 +114,10 @@ cdef extern from "flint_wrap.h": void fmpz_mod_mat_neg(fmpz_mod_mat_t B, const fmpz_mod_mat_t A) # Set ``B`` to `-A`. - void fmpz_mod_mat_scalar_mul_si(fmpz_mod_mat_t B, const fmpz_mod_mat_t A, long c) + void fmpz_mod_mat_scalar_mul_si(fmpz_mod_mat_t B, const fmpz_mod_mat_t A, slong c) # Set ``B`` to `cA` where ``c`` is a constant. - void fmpz_mod_mat_scalar_mul_ui(fmpz_mod_mat_t B, const fmpz_mod_mat_t A, unsigned long c) + void fmpz_mod_mat_scalar_mul_ui(fmpz_mod_mat_t B, const fmpz_mod_mat_t A, ulong c) # Set ``B`` to `cA` where ``c`` is a constant. void fmpz_mod_mat_scalar_mul_fmpz(fmpz_mod_mat_t B, const fmpz_mod_mat_t A, fmpz_t c) @@ -127,7 +127,7 @@ cdef extern from "flint_wrap.h": # Set ``C`` to ``A\times B``. The number of rows of ``B`` must match the # number of columns of ``A``. - void _fmpz_mod_mat_mul_classical_threaded_pool_op(fmpz_mod_mat_t D, const fmpz_mod_mat_t C, const fmpz_mod_mat_t A, const fmpz_mod_mat_t B, int op, thread_pool_handle * threads, long num_threads) + void _fmpz_mod_mat_mul_classical_threaded_pool_op(fmpz_mod_mat_t D, const fmpz_mod_mat_t C, const fmpz_mod_mat_t A, const fmpz_mod_mat_t B, int op, thread_pool_handle * threads, slong num_threads) # Set ``D`` to ``A\times B + op*C`` where ``op`` is ``+1``, ``-1`` or ``0``. void _fmpz_mod_mat_mul_classical_threaded_op(fmpz_mod_mat_t D, const fmpz_mod_mat_t C, const fmpz_mod_mat_t A, const fmpz_mod_mat_t B, int op) @@ -140,14 +140,14 @@ cdef extern from "flint_wrap.h": void fmpz_mod_mat_sqr(fmpz_mod_mat_t B, const fmpz_mod_mat_t A) # Set ``B`` to ``A^2``. The matrix ``A`` must be square. - void fmpz_mod_mat_mul_fmpz_vec(fmpz * c, const fmpz_mod_mat_t A, const fmpz * b, long blen) - void fmpz_mod_mat_mul_fmpz_vec_ptr(fmpz * const * c, const fmpz_mod_mat_t A, const fmpz * const * b, long blen) + void fmpz_mod_mat_mul_fmpz_vec(fmpz * c, const fmpz_mod_mat_t A, const fmpz * b, slong blen) + void fmpz_mod_mat_mul_fmpz_vec_ptr(fmpz * const * c, const fmpz_mod_mat_t A, const fmpz * const * b, slong blen) # Compute a matrix-vector product of ``A`` and ``(b, blen)`` and store the result in ``c``. # The vector ``(b, blen)`` is either truncated or zero-extended to the number of columns of ``A``. # The number entries written to ``c`` is always equal to the number of rows of ``A``. - void fmpz_mod_mat_fmpz_vec_mul(fmpz * c, const fmpz * a, long alen, const fmpz_mod_mat_t B) - void fmpz_mod_mat_fmpz_vec_mul_ptr(fmpz * const * c, const fmpz * const * a, long alen, const fmpz_mod_mat_t B) + void fmpz_mod_mat_fmpz_vec_mul(fmpz * c, const fmpz * a, slong alen, const fmpz_mod_mat_t B) + void fmpz_mod_mat_fmpz_vec_mul_ptr(fmpz * const * c, const fmpz * const * a, slong alen, const fmpz_mod_mat_t B) # Compute a vector-matrix product of ``(a, alen)`` and ``B`` and and store the result in ``c``. # The vector ``(a, alen)`` is either truncated or zero-extended to the number of rows of ``B``. # The number entries written to ``c`` is always equal to the number of columns of ``B``. @@ -155,7 +155,7 @@ cdef extern from "flint_wrap.h": void fmpz_mod_mat_trace(fmpz_t trace, const fmpz_mod_mat_t mat) # Set ``trace`` to the trace of the matrix ``mat``. - long fmpz_mod_mat_rref(long * perm, fmpz_mod_mat_t mat) + slong fmpz_mod_mat_rref(slong * perm, fmpz_mod_mat_t mat) # Uses Gauss-Jordan elimination to set ``mat`` to its reduced row echelon # form and returns the rank of ``mat``. # If ``perm`` is non-``NULL``, the permutation of @@ -169,7 +169,7 @@ cdef extern from "flint_wrap.h": # algorithm used here. # `mat` must have at least as many rows as columns. - long fmpz_mod_mat_howell_form(fmpz_mod_mat_t mat) + slong fmpz_mod_mat_howell_form(fmpz_mod_mat_t mat) # Transforms `mat` into the Howell form of `mat`. For a definition of the # Howell form see [StoMul1998]_. The Howell form is computed by first # putting `mat` into strong echelon form and then ordering the rows. @@ -181,7 +181,7 @@ cdef extern from "flint_wrap.h": # `A` and `B` must be square matrices with the same dimensions. # The modulus is assumed to be prime. - long fmpz_mod_mat_lu(long * P, fmpz_mod_mat_t A, int rank_check) + slong fmpz_mod_mat_lu(slong * P, fmpz_mod_mat_t A, int rank_check) # Computes a generalised LU decomposition `LU = PA` of a given # matrix `A`, returning the rank of `A`. # If `A` is a nonsingular square matrix, it will be overwritten with @@ -231,7 +231,7 @@ cdef extern from "flint_wrap.h": # There are no restrictions on the shape of `A` and it may be singular. # The modulus is assumed to be prime. - void fmpz_mod_mat_similarity(fmpz_mod_mat_t M, long r, fmpz_t d) + void fmpz_mod_mat_similarity(fmpz_mod_mat_t M, slong r, fmpz_t d) # Applies a similarity transform to the `n\times n` matrix `M` in-place. # If `P` is the `n\times n` identity matrix the zero entries of whose row # `r` (`0`-indexed) have been replaced by `d`, this transform is equivalent diff --git a/src/sage/libs/flint/fmpz_mod_mpoly.pxd b/src/sage/libs/flint/fmpz_mod_mpoly.pxd index 38a4f66f107..0f86a1b8e4b 100644 --- a/src/sage/libs/flint/fmpz_mod_mpoly.pxd +++ b/src/sage/libs/flint/fmpz_mod_mpoly.pxd @@ -12,11 +12,11 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void fmpz_mod_mpoly_ctx_init(fmpz_mod_mpoly_ctx_t ctx, long nvars, const ordering_t ord, const fmpz_t p) + void fmpz_mod_mpoly_ctx_init(fmpz_mod_mpoly_ctx_t ctx, slong nvars, const ordering_t ord, const fmpz_t p) # Initialise a context object for a polynomial ring modulo *n* with *nvars* variables and ordering *ord*. # The possibilities for the ordering are ``ORD_LEX``, ``ORD_DEGLEX`` and ``ORD_DEGREVLEX``. - long fmpz_mod_mpoly_ctx_nvars(const fmpz_mod_mpoly_ctx_t ctx) + slong fmpz_mod_mpoly_ctx_nvars(const fmpz_mod_mpoly_ctx_t ctx) # Return the number of variables used to initialize the context. ordering_t fmpz_mod_mpoly_ctx_ord(const fmpz_mod_mpoly_ctx_t ctx) @@ -31,11 +31,11 @@ cdef extern from "flint_wrap.h": void fmpz_mod_mpoly_init(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_ctx_t ctx) # Initialise *A* for use with the given an initialised context object. Its value is set to zero. - void fmpz_mod_mpoly_init2(fmpz_mod_mpoly_t A, long alloc, const fmpz_mod_mpoly_ctx_t ctx) + void fmpz_mod_mpoly_init2(fmpz_mod_mpoly_t A, slong alloc, const fmpz_mod_mpoly_ctx_t ctx) # Initialise *A* for use with the given an initialised context object. Its value is set to zero. # It is allocated with space for *alloc* terms and at least ``MPOLY_MIN_BITS`` bits for the exponents. - void fmpz_mod_mpoly_init3(fmpz_mod_mpoly_t A, long alloc, flint_bitcnt_t bits, const fmpz_mod_mpoly_ctx_t ctx) + void fmpz_mod_mpoly_init3(fmpz_mod_mpoly_t A, slong alloc, flint_bitcnt_t bits, const fmpz_mod_mpoly_ctx_t ctx) # Initialise *A* for use with the given an initialised context object. Its value is set to zero. # It is allocated with space for *alloc* terms and *bits* bits for the exponents. @@ -57,10 +57,10 @@ cdef extern from "flint_wrap.h": # The operations ``+``, ``-``, ``*``, and ``/`` are permitted along with integers and the variables in *x*. The character ``^`` must be immediately followed by the (integer) exponent. # If any division is not exact, parsing fails. - void fmpz_mod_mpoly_gen(fmpz_mod_mpoly_t A, long var, const fmpz_mod_mpoly_ctx_t ctx) + void fmpz_mod_mpoly_gen(fmpz_mod_mpoly_t A, slong var, const fmpz_mod_mpoly_ctx_t ctx) # Set *A* to the variable of index *var*, where `var = 0` corresponds to the variable with the most significance with respect to the ordering. - int fmpz_mod_mpoly_is_gen(const fmpz_mod_mpoly_t A, long var, const fmpz_mod_mpoly_ctx_t ctx) + int fmpz_mod_mpoly_is_gen(const fmpz_mod_mpoly_t A, slong var, const fmpz_mod_mpoly_ctx_t ctx) # If `var \ge 0`, return `1` if *A* is equal to the `var`-th generator, otherwise return `0`. # If `var < 0`, return `1` if the polynomial is equal to any generator, otherwise return `0`. @@ -81,8 +81,8 @@ cdef extern from "flint_wrap.h": # This function throws if *A* is not a constant. void fmpz_mod_mpoly_set_fmpz(fmpz_mod_mpoly_t A, const fmpz_t c, const fmpz_mod_mpoly_ctx_t ctx) - void fmpz_mod_mpoly_set_ui(fmpz_mod_mpoly_t A, unsigned long c, const fmpz_mod_mpoly_ctx_t ctx) - void fmpz_mod_mpoly_set_si(fmpz_mod_mpoly_t A, long c, const fmpz_mod_mpoly_ctx_t ctx) + void fmpz_mod_mpoly_set_ui(fmpz_mod_mpoly_t A, ulong c, const fmpz_mod_mpoly_ctx_t ctx) + void fmpz_mod_mpoly_set_si(fmpz_mod_mpoly_t A, slong c, const fmpz_mod_mpoly_ctx_t ctx) # Set *A* to the constant *c*. void fmpz_mod_mpoly_zero(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_ctx_t ctx) @@ -92,8 +92,8 @@ cdef extern from "flint_wrap.h": # Set *A* to the constant `1`. int fmpz_mod_mpoly_equal_fmpz(const fmpz_mod_mpoly_t A, const fmpz_t c, const fmpz_mod_mpoly_ctx_t ctx) - int fmpz_mod_mpoly_equal_ui(const fmpz_mod_mpoly_t A, unsigned long c, const fmpz_mod_mpoly_ctx_t ctx) - int fmpz_mod_mpoly_equal_si(const fmpz_mod_mpoly_t A, long c, const fmpz_mod_mpoly_ctx_t ctx) + int fmpz_mod_mpoly_equal_ui(const fmpz_mod_mpoly_t A, ulong c, const fmpz_mod_mpoly_ctx_t ctx) + int fmpz_mod_mpoly_equal_si(const fmpz_mod_mpoly_t A, slong c, const fmpz_mod_mpoly_ctx_t ctx) # Return `1` if *A* is equal to the constant *c*, else return `0`. int fmpz_mod_mpoly_is_zero(const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_ctx_t ctx) @@ -106,12 +106,12 @@ cdef extern from "flint_wrap.h": # Return `1` if the degrees of *A* with respect to each variable fit into an ``slong``, otherwise return `0`. void fmpz_mod_mpoly_degrees_fmpz(fmpz ** degs, const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_ctx_t ctx) - void fmpz_mod_mpoly_degrees_si(long * degs, const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_ctx_t ctx) + void fmpz_mod_mpoly_degrees_si(slong * degs, const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_ctx_t ctx) # Set *degs* to the degrees of *A* with respect to each variable. # If *A* is zero, all degrees are set to `-1`. - void fmpz_mod_mpoly_degree_fmpz(fmpz_t deg, const fmpz_mod_mpoly_t A, long var, const fmpz_mod_mpoly_ctx_t ctx) - long fmpz_mod_mpoly_degree_si(const fmpz_mod_mpoly_t A, long var, const fmpz_mod_mpoly_ctx_t ctx) + void fmpz_mod_mpoly_degree_fmpz(fmpz_t deg, const fmpz_mod_mpoly_t A, slong var, const fmpz_mod_mpoly_ctx_t ctx) + slong fmpz_mod_mpoly_degree_si(const fmpz_mod_mpoly_t A, slong var, const fmpz_mod_mpoly_ctx_t ctx) # Either return or set *deg* to the degree of *A* with respect to the variable of index *var*. # If *A* is zero, the degree is defined to be `-1`. @@ -119,7 +119,7 @@ cdef extern from "flint_wrap.h": # Return `1` if the total degree of *A* fits into an ``slong``, otherwise return `0`. void fmpz_mod_mpoly_total_degree_fmpz(fmpz_t tdeg, const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_ctx_t ctx) - long fmpz_mod_mpoly_total_degree_si(const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_ctx_t ctx) + slong fmpz_mod_mpoly_total_degree_si(const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_ctx_t ctx) # Either return or set *tdeg* to the total degree of *A*. # If *A* is zero, the total degree is defined to be `-1`. @@ -135,18 +135,18 @@ cdef extern from "flint_wrap.h": # This function throws if *M* is not a monomial. void fmpz_mod_mpoly_get_coeff_fmpz_fmpz(fmpz_t c, const fmpz_mod_mpoly_t A, fmpz * const * exp, const fmpz_mod_mpoly_ctx_t ctx) - void fmpz_mod_mpoly_get_coeff_fmpz_ui(fmpz_t c, const fmpz_mod_mpoly_t A, const unsigned long * exp, const fmpz_mod_mpoly_ctx_t ctx) + void fmpz_mod_mpoly_get_coeff_fmpz_ui(fmpz_t c, const fmpz_mod_mpoly_t A, const ulong * exp, const fmpz_mod_mpoly_ctx_t ctx) # Set *c* to the coefficient of the monomial with exponent vector *exp*. void fmpz_mod_mpoly_set_coeff_fmpz_fmpz(fmpz_mod_mpoly_t A, const fmpz_t c, fmpz * const * exp, const fmpz_mod_mpoly_ctx_t ctx) - void fmpz_mod_mpoly_set_coeff_ui_fmpz(fmpz_mod_mpoly_t A, unsigned long c, fmpz * const * exp, const fmpz_mod_mpoly_ctx_t ctx) - void fmpz_mod_mpoly_set_coeff_si_fmpz(fmpz_mod_mpoly_t A, long c, fmpz * const * exp, const fmpz_mod_mpoly_ctx_t ctx) - void fmpz_mod_mpoly_set_coeff_fmpz_ui(fmpz_mod_mpoly_t A, const fmpz_t c, const unsigned long * exp, const fmpz_mod_mpoly_ctx_t ctx) - void fmpz_mod_mpoly_set_coeff_ui_ui(fmpz_mod_mpoly_t A, unsigned long c, const unsigned long * exp, const fmpz_mod_mpoly_ctx_t ctx) - void fmpz_mod_mpoly_set_coeff_si_ui(fmpz_mod_mpoly_t A, long c, const unsigned long * exp, const fmpz_mod_mpoly_ctx_t ctx) + void fmpz_mod_mpoly_set_coeff_ui_fmpz(fmpz_mod_mpoly_t A, ulong c, fmpz * const * exp, const fmpz_mod_mpoly_ctx_t ctx) + void fmpz_mod_mpoly_set_coeff_si_fmpz(fmpz_mod_mpoly_t A, slong c, fmpz * const * exp, const fmpz_mod_mpoly_ctx_t ctx) + void fmpz_mod_mpoly_set_coeff_fmpz_ui(fmpz_mod_mpoly_t A, const fmpz_t c, const ulong * exp, const fmpz_mod_mpoly_ctx_t ctx) + void fmpz_mod_mpoly_set_coeff_ui_ui(fmpz_mod_mpoly_t A, ulong c, const ulong * exp, const fmpz_mod_mpoly_ctx_t ctx) + void fmpz_mod_mpoly_set_coeff_si_ui(fmpz_mod_mpoly_t A, slong c, const ulong * exp, const fmpz_mod_mpoly_ctx_t ctx) # Set the coefficient of the monomial with exponent vector *exp* to *c*. - void fmpz_mod_mpoly_get_coeff_vars_ui(fmpz_mod_mpoly_t C, const fmpz_mod_mpoly_t A, const long * vars, const unsigned long * exps, long length, const fmpz_mod_mpoly_ctx_t ctx) + void fmpz_mod_mpoly_get_coeff_vars_ui(fmpz_mod_mpoly_t C, const fmpz_mod_mpoly_t A, const slong * vars, const ulong * exps, slong length, const fmpz_mod_mpoly_ctx_t ctx) # Set *C* to the coefficient of *A* with respect to the variables in *vars* with powers in the corresponding array *exps*. # Both *vars* and *exps* point to array of length *length*. It is assumed that `0 < length \le nvars(A)` and that the variables in *vars* are distinct. @@ -158,56 +158,56 @@ cdef extern from "flint_wrap.h": # Return `1` if *A* is in canonical form. Otherwise, return `0`. # To be in canonical form, all of the terms must have nonzero coefficient, and the terms must be sorted from greatest to least. - long fmpz_mod_mpoly_length(const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_ctx_t ctx) + slong fmpz_mod_mpoly_length(const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_ctx_t ctx) # Return the number of terms in *A*. # If the polynomial is in canonical form, this will be the number of nonzero coefficients. - void fmpz_mod_mpoly_resize(fmpz_mod_mpoly_t A, long new_length, const fmpz_mod_mpoly_ctx_t ctx) + void fmpz_mod_mpoly_resize(fmpz_mod_mpoly_t A, slong new_length, const fmpz_mod_mpoly_ctx_t ctx) # Set the length of *A* to ``new_length``. # Terms are either deleted from the end, or new zero terms are appended. - void fmpz_mod_mpoly_get_term_coeff_fmpz(fmpz_t c, const fmpz_mod_mpoly_t A, long i, const fmpz_mod_mpoly_ctx_t ctx) + void fmpz_mod_mpoly_get_term_coeff_fmpz(fmpz_t c, const fmpz_mod_mpoly_t A, slong i, const fmpz_mod_mpoly_ctx_t ctx) # Set *c* to the coefficient of the term of index *i*. - void fmpz_mod_mpoly_set_term_coeff_fmpz(fmpz_mod_mpoly_t A, long i, const fmpz_t c, const fmpz_mod_mpoly_ctx_t ctx) - void fmpz_mod_mpoly_set_term_coeff_ui(fmpz_mod_mpoly_t A, long i, unsigned long c, const fmpz_mod_mpoly_ctx_t ctx) - void fmpz_mod_mpoly_set_term_coeff_si(fmpz_mod_mpoly_t A, long i, long c, const fmpz_mod_mpoly_ctx_t ctx) + void fmpz_mod_mpoly_set_term_coeff_fmpz(fmpz_mod_mpoly_t A, slong i, const fmpz_t c, const fmpz_mod_mpoly_ctx_t ctx) + void fmpz_mod_mpoly_set_term_coeff_ui(fmpz_mod_mpoly_t A, slong i, ulong c, const fmpz_mod_mpoly_ctx_t ctx) + void fmpz_mod_mpoly_set_term_coeff_si(fmpz_mod_mpoly_t A, slong i, slong c, const fmpz_mod_mpoly_ctx_t ctx) # Set the coefficient of the term of index *i* to *c*. - int fmpz_mod_mpoly_term_exp_fits_si(const fmpz_mod_mpoly_t poly, long i, const fmpz_mod_mpoly_ctx_t ctx) - int fmpz_mod_mpoly_term_exp_fits_ui(const fmpz_mod_mpoly_t poly, long i, const fmpz_mod_mpoly_ctx_t ctx) + int fmpz_mod_mpoly_term_exp_fits_si(const fmpz_mod_mpoly_t poly, slong i, const fmpz_mod_mpoly_ctx_t ctx) + int fmpz_mod_mpoly_term_exp_fits_ui(const fmpz_mod_mpoly_t poly, slong i, const fmpz_mod_mpoly_ctx_t ctx) # Return `1` if all entries of the exponent vector of the term of index *i* fit into an ``slong`` (resp. a ``ulong``). Otherwise, return `0`. - void fmpz_mod_mpoly_get_term_exp_fmpz(fmpz ** exp, const fmpz_mod_mpoly_t A, long i, const fmpz_mod_mpoly_ctx_t ctx) - void fmpz_mod_mpoly_get_term_exp_ui(unsigned long * exp, const fmpz_mod_mpoly_t A, long i, const fmpz_mod_mpoly_ctx_t ctx) - void fmpz_mod_mpoly_get_term_exp_si(long * exp, const fmpz_mod_mpoly_t A, long i, const fmpz_mod_mpoly_ctx_t ctx) + void fmpz_mod_mpoly_get_term_exp_fmpz(fmpz ** exp, const fmpz_mod_mpoly_t A, slong i, const fmpz_mod_mpoly_ctx_t ctx) + void fmpz_mod_mpoly_get_term_exp_ui(ulong * exp, const fmpz_mod_mpoly_t A, slong i, const fmpz_mod_mpoly_ctx_t ctx) + void fmpz_mod_mpoly_get_term_exp_si(slong * exp, const fmpz_mod_mpoly_t A, slong i, const fmpz_mod_mpoly_ctx_t ctx) # Set *exp* to the exponent vector of the term of index *i*. # The ``_ui`` (resp. ``_si``) version throws if any entry does not fit into a ``ulong`` (resp. ``slong``). - unsigned long fmpz_mod_mpoly_get_term_var_exp_ui(const fmpz_mod_mpoly_t A, long i, long var, const fmpz_mod_mpoly_ctx_t ctx) - long fmpz_mod_mpoly_get_term_var_exp_si(const fmpz_mod_mpoly_t A, long i, long var, const fmpz_mod_mpoly_ctx_t ctx) + ulong fmpz_mod_mpoly_get_term_var_exp_ui(const fmpz_mod_mpoly_t A, slong i, slong var, const fmpz_mod_mpoly_ctx_t ctx) + slong fmpz_mod_mpoly_get_term_var_exp_si(const fmpz_mod_mpoly_t A, slong i, slong var, const fmpz_mod_mpoly_ctx_t ctx) # Return the exponent of the variable *var* of the term of index *i*. # This function throws if the exponent does not fit into a ``ulong`` (resp. ``slong``). - void fmpz_mod_mpoly_set_term_exp_fmpz(fmpz_mod_mpoly_t A, long i, fmpz * const * exp, const fmpz_mod_mpoly_ctx_t ctx) - void fmpz_mod_mpoly_set_term_exp_ui(fmpz_mod_mpoly_t A, long i, const unsigned long * exp, const fmpz_mod_mpoly_ctx_t ctx) + void fmpz_mod_mpoly_set_term_exp_fmpz(fmpz_mod_mpoly_t A, slong i, fmpz * const * exp, const fmpz_mod_mpoly_ctx_t ctx) + void fmpz_mod_mpoly_set_term_exp_ui(fmpz_mod_mpoly_t A, slong i, const ulong * exp, const fmpz_mod_mpoly_ctx_t ctx) # Set the exponent vector of the term of index *i* to *exp*. - void fmpz_mod_mpoly_get_term(fmpz_mod_mpoly_t M, const fmpz_mod_mpoly_t A, long i, const fmpz_mod_mpoly_ctx_t ctx) + void fmpz_mod_mpoly_get_term(fmpz_mod_mpoly_t M, const fmpz_mod_mpoly_t A, slong i, const fmpz_mod_mpoly_ctx_t ctx) # Set *M* to the term of index *i* in *A*. - void fmpz_mod_mpoly_get_term_monomial(fmpz_mod_mpoly_t M, const fmpz_mod_mpoly_t A, long i, const fmpz_mod_mpoly_ctx_t ctx) + void fmpz_mod_mpoly_get_term_monomial(fmpz_mod_mpoly_t M, const fmpz_mod_mpoly_t A, slong i, const fmpz_mod_mpoly_ctx_t ctx) # Set *M* to the monomial of the term of index *i* in *A*. The coefficient of *M* will be one. void fmpz_mod_mpoly_push_term_fmpz_fmpz(fmpz_mod_mpoly_t A, const fmpz_t c, fmpz * const * exp, const fmpz_mod_mpoly_ctx_t ctx) void fmpz_mod_mpoly_push_term_fmpz_ffmpz(fmpz_mod_mpoly_t A, const fmpz_t c, const fmpz * exp, const fmpz_mod_mpoly_ctx_t ctx) - void fmpz_mod_mpoly_push_term_ui_fmpz(fmpz_mod_mpoly_t A, unsigned long c, fmpz * const * exp, const fmpz_mod_mpoly_ctx_t ctx) - void fmpz_mod_mpoly_push_term_ui_ffmpz(fmpz_mod_mpoly_t A, unsigned long c, const fmpz * exp, const fmpz_mod_mpoly_ctx_t ctx) - void fmpz_mod_mpoly_push_term_si_fmpz(fmpz_mod_mpoly_t A, long c, fmpz * const * exp, const fmpz_mod_mpoly_ctx_t ctx) - void fmpz_mod_mpoly_push_term_si_ffmpz(fmpz_mod_mpoly_t A, long c, const fmpz * exp, const fmpz_mod_mpoly_ctx_t ctx) - void fmpz_mod_mpoly_push_term_fmpz_ui(fmpz_mod_mpoly_t A, const fmpz_t c, const unsigned long * exp, const fmpz_mod_mpoly_ctx_t ctx) - void fmpz_mod_mpoly_push_term_ui_ui(fmpz_mod_mpoly_t A, unsigned long c, const unsigned long * exp, const fmpz_mod_mpoly_ctx_t ctx) - void fmpz_mod_mpoly_push_term_si_ui(fmpz_mod_mpoly_t A, long c, const unsigned long * exp, const fmpz_mod_mpoly_ctx_t ctx) + void fmpz_mod_mpoly_push_term_ui_fmpz(fmpz_mod_mpoly_t A, ulong c, fmpz * const * exp, const fmpz_mod_mpoly_ctx_t ctx) + void fmpz_mod_mpoly_push_term_ui_ffmpz(fmpz_mod_mpoly_t A, ulong c, const fmpz * exp, const fmpz_mod_mpoly_ctx_t ctx) + void fmpz_mod_mpoly_push_term_si_fmpz(fmpz_mod_mpoly_t A, slong c, fmpz * const * exp, const fmpz_mod_mpoly_ctx_t ctx) + void fmpz_mod_mpoly_push_term_si_ffmpz(fmpz_mod_mpoly_t A, slong c, const fmpz * exp, const fmpz_mod_mpoly_ctx_t ctx) + void fmpz_mod_mpoly_push_term_fmpz_ui(fmpz_mod_mpoly_t A, const fmpz_t c, const ulong * exp, const fmpz_mod_mpoly_ctx_t ctx) + void fmpz_mod_mpoly_push_term_ui_ui(fmpz_mod_mpoly_t A, ulong c, const ulong * exp, const fmpz_mod_mpoly_ctx_t ctx) + void fmpz_mod_mpoly_push_term_si_ui(fmpz_mod_mpoly_t A, slong c, const ulong * exp, const fmpz_mod_mpoly_ctx_t ctx) # Append a term to *A* with coefficient *c* and exponent vector *exp*. # This function runs in constant average time. @@ -224,25 +224,25 @@ cdef extern from "flint_wrap.h": void fmpz_mod_mpoly_reverse(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, const fmpz_mod_mpoly_ctx_t ctx) # Set *A* to the reversal of *B*. - void fmpz_mod_mpoly_randtest_bound(fmpz_mod_mpoly_t A, flint_rand_t state, long length, unsigned long exp_bound, const fmpz_mod_mpoly_ctx_t ctx) + void fmpz_mod_mpoly_randtest_bound(fmpz_mod_mpoly_t A, flint_rand_t state, slong length, ulong exp_bound, const fmpz_mod_mpoly_ctx_t ctx) # Generate a random polynomial with length up to *length* and exponents in the range ``[0, exp_bound - 1]``. # The exponents of each variable are generated by calls to ``n_randint(state, exp_bound)``. - void fmpz_mod_mpoly_randtest_bounds(fmpz_mod_mpoly_t A, flint_rand_t state, long length, unsigned long * exp_bounds, const fmpz_mod_mpoly_ctx_t ctx) + void fmpz_mod_mpoly_randtest_bounds(fmpz_mod_mpoly_t A, flint_rand_t state, slong length, ulong * exp_bounds, const fmpz_mod_mpoly_ctx_t ctx) # Generate a random polynomial with length up to *length* and exponents in the range ``[0, exp_bounds[i] - 1]``. # The exponents of the variable of index *i* are generated by calls to ``n_randint(state, exp_bounds[i])``. - void fmpz_mod_mpoly_randtest_bits(fmpz_mod_mpoly_t A, flint_rand_t state, long length, mp_limb_t exp_bits, const fmpz_mod_mpoly_ctx_t ctx) + void fmpz_mod_mpoly_randtest_bits(fmpz_mod_mpoly_t A, flint_rand_t state, slong length, mp_limb_t exp_bits, const fmpz_mod_mpoly_ctx_t ctx) # Generate a random polynomial with length up to *length* and exponents whose packed form does not exceed the given bit count. void fmpz_mod_mpoly_add_fmpz(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, const fmpz_t c, const fmpz_mod_mpoly_ctx_t ctx) - void fmpz_mod_mpoly_add_ui(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, unsigned long c, const fmpz_mod_mpoly_ctx_t ctx) - void fmpz_mod_mpoly_add_si(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, long c, const fmpz_mod_mpoly_ctx_t ctx) + void fmpz_mod_mpoly_add_ui(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, ulong c, const fmpz_mod_mpoly_ctx_t ctx) + void fmpz_mod_mpoly_add_si(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, slong c, const fmpz_mod_mpoly_ctx_t ctx) # Set *A* to `B + c`. void fmpz_mod_mpoly_sub_fmpz(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, const fmpz_t c, const fmpz_mod_mpoly_ctx_t ctx) - void fmpz_mod_mpoly_sub_ui(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, unsigned long c, const fmpz_mod_mpoly_ctx_t ctx) - void fmpz_mod_mpoly_sub_si(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, long c, const fmpz_mod_mpoly_ctx_t ctx) + void fmpz_mod_mpoly_sub_ui(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, ulong c, const fmpz_mod_mpoly_ctx_t ctx) + void fmpz_mod_mpoly_sub_si(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, slong c, const fmpz_mod_mpoly_ctx_t ctx) # Set *A* to `B - c`. void fmpz_mod_mpoly_add(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, const fmpz_mod_mpoly_t C, const fmpz_mod_mpoly_ctx_t ctx) @@ -255,8 +255,8 @@ cdef extern from "flint_wrap.h": # Set *A* to `-B`. void fmpz_mod_mpoly_scalar_mul_fmpz(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, const fmpz_t c, const fmpz_mod_mpoly_ctx_t ctx) - void fmpz_mod_mpoly_scalar_mul_ui(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, unsigned long c, const fmpz_mod_mpoly_ctx_t ctx) - void fmpz_mod_mpoly_scalar_mul_si(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, long c, const fmpz_mod_mpoly_ctx_t ctx) + void fmpz_mod_mpoly_scalar_mul_ui(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, ulong c, const fmpz_mod_mpoly_ctx_t ctx) + void fmpz_mod_mpoly_scalar_mul_si(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, slong c, const fmpz_mod_mpoly_ctx_t ctx) # Set *A* to `B \times c`. void fmpz_mod_mpoly_scalar_addmul_fmpz(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, const fmpz_mod_mpoly_t C, const fmpz_t d, const fmpz_mod_mpoly_ctx_t ctx) @@ -265,13 +265,13 @@ cdef extern from "flint_wrap.h": void fmpz_mod_mpoly_make_monic(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, const fmpz_mod_mpoly_ctx_t ctx) # Set *A* to *B* divided by the leading coefficient of *B*. This throws if *B* is zero or the leading coefficient is not invertible. - void fmpz_mod_mpoly_derivative(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, long var, const fmpz_mod_mpoly_ctx_t ctx) + void fmpz_mod_mpoly_derivative(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, slong var, const fmpz_mod_mpoly_ctx_t ctx) # Set *A* to the derivative of *B* with respect to the variable of index *var*. void fmpz_mod_mpoly_evaluate_all_fmpz(fmpz_t eval, const fmpz_mod_mpoly_t A, fmpz * const * vals, const fmpz_mod_mpoly_ctx_t ctx) # Set *ev* to the evaluation of *A* where the variables are replaced by the corresponding elements of the array *vals*. - void fmpz_mod_mpoly_evaluate_one_fmpz(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, long var, const fmpz_t val, const fmpz_mod_mpoly_ctx_t ctx) + void fmpz_mod_mpoly_evaluate_one_fmpz(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, slong var, const fmpz_t val, const fmpz_mod_mpoly_ctx_t ctx) # Set *A* to the evaluation of *B* where the variable of index *var* is replaced by *val*. # Return `1` for success and `0` for failure. @@ -289,7 +289,7 @@ cdef extern from "flint_wrap.h": # Return `1` for success and `0` for failure. # The main method attempts to perform the calculation using matrices and chooses heuristically between the ``geobucket`` and ``horner`` methods if needed. - void fmpz_mod_mpoly_compose_fmpz_mod_mpoly_gen(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, const long * c, const fmpz_mod_mpoly_ctx_t ctxB, const fmpz_mod_mpoly_ctx_t ctxAC) + void fmpz_mod_mpoly_compose_fmpz_mod_mpoly_gen(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, const slong * c, const fmpz_mod_mpoly_ctx_t ctxB, const fmpz_mod_mpoly_ctx_t ctxAC) # Set *A* to the evaluation of *B* where the variable of index *i* in *ctxB* is replaced by the variable of index ``c[i]`` in *ctxAC*. # The length of the array *C* is the number of variables in *ctxB*. # If any ``c[i]`` is negative, the corresponding variable of *B* is replaced by zero. Otherwise, it is expected that ``c[i]`` is less than the number of variables in *ctxAC*. @@ -308,7 +308,7 @@ cdef extern from "flint_wrap.h": # Set *A* to *B* raised to the `k`-th power. # Return `1` for success and `0` for failure. - int fmpz_mod_mpoly_pow_ui(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, unsigned long k, const fmpz_mod_mpoly_ctx_t ctx) + int fmpz_mod_mpoly_pow_ui(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, ulong k, const fmpz_mod_mpoly_ctx_t ctx) # Set *A* to *B* raised to the `k`-th power. # Return `1` for success and `0` for failure. @@ -321,7 +321,7 @@ cdef extern from "flint_wrap.h": void fmpz_mod_mpoly_divrem(fmpz_mod_mpoly_t Q, fmpz_mod_mpoly_t R, const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, const fmpz_mod_mpoly_ctx_t ctx) # Set *Q* and *R* to the quotient and remainder of *A* divided by *B*. - void fmpz_mod_mpoly_divrem_ideal(fmpz_mod_mpoly_struct ** Q, fmpz_mod_mpoly_t R, const fmpz_mod_mpoly_t A, fmpz_mod_mpoly_struct * const * B, long len, const fmpz_mod_mpoly_ctx_t ctx) + void fmpz_mod_mpoly_divrem_ideal(fmpz_mod_mpoly_struct ** Q, fmpz_mod_mpoly_t R, const fmpz_mod_mpoly_t A, fmpz_mod_mpoly_struct * const * B, slong len, const fmpz_mod_mpoly_ctx_t ctx) # This function is as per :func:`fmpz_mod_mpoly_divrem` except that it takes an array of divisor polynomials *B* and it returns an array of quotient polynomials *Q*. # The number of divisor (and hence quotient) polynomials, is given by *len*. @@ -329,7 +329,7 @@ cdef extern from "flint_wrap.h": # Set *M* to the GCD of the terms of *A*. # If *A* is zero, *M* will be zero. Otherwise, *M* will be a monomial with coefficient one. - int fmpz_mod_mpoly_content_vars(fmpz_mod_mpoly_t g, const fmpz_mod_mpoly_t A, long * vars, long vars_length, const fmpz_mod_mpoly_ctx_t ctx) + int fmpz_mod_mpoly_content_vars(fmpz_mod_mpoly_t g, const fmpz_mod_mpoly_t A, slong * vars, slong vars_length, const fmpz_mod_mpoly_ctx_t ctx) # Set *g* to the GCD of the coefficients of *A* when viewed as a polynomial in the variables *vars*. # Return `1` for success and `0` for failure. Upon success, *g* will be independent of the variables *vars*. @@ -347,10 +347,10 @@ cdef extern from "flint_wrap.h": int fmpz_mod_mpoly_gcd_zippel2(fmpz_mod_mpoly_t G, const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, const fmpz_mod_mpoly_ctx_t ctx) # Try to set *G* to the GCD of *A* and *B* using various algorithms. - int fmpz_mod_mpoly_resultant(fmpz_mod_mpoly_t R, const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, long var, const fmpz_mod_mpoly_ctx_t ctx) + int fmpz_mod_mpoly_resultant(fmpz_mod_mpoly_t R, const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, slong var, const fmpz_mod_mpoly_ctx_t ctx) # Try to set *R* to the resultant of *A* and *B* with respect to the variable of index *var*. - int fmpz_mod_mpoly_discriminant(fmpz_mod_mpoly_t D, const fmpz_mod_mpoly_t A, long var, const fmpz_mod_mpoly_ctx_t ctx) + int fmpz_mod_mpoly_discriminant(fmpz_mod_mpoly_t D, const fmpz_mod_mpoly_t A, slong var, const fmpz_mod_mpoly_ctx_t ctx) # Try to set *D* to the discriminant of *A* with respect to the variable of index *var*. int fmpz_mod_mpoly_sqrt(fmpz_mod_mpoly_t Q, const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_ctx_t ctx) @@ -371,28 +371,28 @@ cdef extern from "flint_wrap.h": void fmpz_mod_mpoly_univar_swap(fmpz_mod_mpoly_univar_t A, fmpz_mod_mpoly_univar_t B, const fmpz_mod_mpoly_ctx_t ctx) # Swap *A* and *B*. - void fmpz_mod_mpoly_to_univar(fmpz_mod_mpoly_univar_t A, const fmpz_mod_mpoly_t B, long var, const fmpz_mod_mpoly_ctx_t ctx) + void fmpz_mod_mpoly_to_univar(fmpz_mod_mpoly_univar_t A, const fmpz_mod_mpoly_t B, slong var, const fmpz_mod_mpoly_ctx_t ctx) # Set *A* to a univariate form of *B* by pulling out the variable of index *var*. # The coefficients of *A* will still belong to the content *ctx* but will not depend on the variable of index *var*. - void fmpz_mod_mpoly_from_univar(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_univar_t B, long var, const fmpz_mod_mpoly_ctx_t ctx) + void fmpz_mod_mpoly_from_univar(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_univar_t B, slong var, const fmpz_mod_mpoly_ctx_t ctx) # Set *A* to the normal form of *B* by putting in the variable of index *var*. # This function is undefined if the coefficients of *B* depend on the variable of index *var*. int fmpz_mod_mpoly_univar_degree_fits_si(const fmpz_mod_mpoly_univar_t A, const fmpz_mod_mpoly_ctx_t ctx) # Return `1` if the degree of *A* with respect to the main variable fits an ``slong``. Otherwise, return `0`. - long fmpz_mod_mpoly_univar_length(const fmpz_mod_mpoly_univar_t A, const fmpz_mod_mpoly_ctx_t ctx) + slong fmpz_mod_mpoly_univar_length(const fmpz_mod_mpoly_univar_t A, const fmpz_mod_mpoly_ctx_t ctx) # Return the number of terms in *A* with respect to the main variable. - long fmpz_mod_mpoly_univar_get_term_exp_si(fmpz_mod_mpoly_univar_t A, long i, const fmpz_mod_mpoly_ctx_t ctx) + slong fmpz_mod_mpoly_univar_get_term_exp_si(fmpz_mod_mpoly_univar_t A, slong i, const fmpz_mod_mpoly_ctx_t ctx) # Return the exponent of the term of index *i* of *A*. - void fmpz_mod_mpoly_univar_get_term_coeff(fmpz_mod_mpoly_t c, const fmpz_mod_mpoly_univar_t A, long i, const fmpz_mod_mpoly_ctx_t ctx) - void fmpz_mod_mpoly_univar_swap_term_coeff(fmpz_mod_mpoly_t c, fmpz_mod_mpoly_univar_t A, long i, const fmpz_mod_mpoly_ctx_t ctx) + void fmpz_mod_mpoly_univar_get_term_coeff(fmpz_mod_mpoly_t c, const fmpz_mod_mpoly_univar_t A, slong i, const fmpz_mod_mpoly_ctx_t ctx) + void fmpz_mod_mpoly_univar_swap_term_coeff(fmpz_mod_mpoly_t c, fmpz_mod_mpoly_univar_t A, slong i, const fmpz_mod_mpoly_ctx_t ctx) # Set (resp. swap) *c* to (resp. with) the coefficient of the term of index *i* of *A*. - void fmpz_mod_mpoly_univar_set_coeff_ui(fmpz_mod_mpoly_univar_t Ax, unsigned long e, const fmpz_mod_mpoly_t c, const fmpz_mod_mpoly_ctx_t ctx) + void fmpz_mod_mpoly_univar_set_coeff_ui(fmpz_mod_mpoly_univar_t Ax, ulong e, const fmpz_mod_mpoly_t c, const fmpz_mod_mpoly_ctx_t ctx) # Set the coefficient of `X^e` in *Ax* to *c*. int fmpz_mod_mpoly_univar_resultant(fmpz_mod_mpoly_t R, const fmpz_mod_mpoly_univar_t Ax, const fmpz_mod_mpoly_univar_t Bx, const fmpz_mod_mpoly_ctx_t ctx) diff --git a/src/sage/libs/flint/fmpz_mod_mpoly_factor.pxd b/src/sage/libs/flint/fmpz_mod_mpoly_factor.pxd index 252413b5da2..dd97d23afd4 100644 --- a/src/sage/libs/flint/fmpz_mod_mpoly_factor.pxd +++ b/src/sage/libs/flint/fmpz_mod_mpoly_factor.pxd @@ -21,17 +21,17 @@ cdef extern from "flint_wrap.h": void fmpz_mod_mpoly_factor_swap(fmpz_mod_mpoly_factor_t f, fmpz_mod_mpoly_factor_t g, const fmpz_mod_mpoly_ctx_t ctx) # Efficiently swap *f* and *g*. - long fmpz_mod_mpoly_factor_length(const fmpz_mod_mpoly_factor_t f, const fmpz_mod_mpoly_ctx_t ctx) + slong fmpz_mod_mpoly_factor_length(const fmpz_mod_mpoly_factor_t f, const fmpz_mod_mpoly_ctx_t ctx) # Return the length of the product in *f*. void fmpz_mod_mpoly_factor_get_constant_fmpz(fmpz_t c, const fmpz_mod_mpoly_factor_t f, const fmpz_mod_mpoly_ctx_t ctx) # Set *c* to the constant of *f*. - void fmpz_mod_mpoly_factor_get_base(fmpz_mod_mpoly_t B, const fmpz_mod_mpoly_factor_t f, long i, const fmpz_mod_mpoly_ctx_t ctx) - void fmpz_mod_mpoly_factor_swap_base(fmpz_mod_mpoly_t B, fmpz_mod_mpoly_factor_t f, long i, const fmpz_mod_mpoly_ctx_t ctx) + void fmpz_mod_mpoly_factor_get_base(fmpz_mod_mpoly_t B, const fmpz_mod_mpoly_factor_t f, slong i, const fmpz_mod_mpoly_ctx_t ctx) + void fmpz_mod_mpoly_factor_swap_base(fmpz_mod_mpoly_t B, fmpz_mod_mpoly_factor_t f, slong i, const fmpz_mod_mpoly_ctx_t ctx) # Set (resp. swap) *B* to (resp. with) the base of the term of index *i* in *f*. - long fmpz_mod_mpoly_factor_get_exp_si(fmpz_mod_mpoly_factor_t f, long i, const fmpz_mod_mpoly_ctx_t ctx) + slong fmpz_mod_mpoly_factor_get_exp_si(fmpz_mod_mpoly_factor_t f, slong i, const fmpz_mod_mpoly_ctx_t ctx) # Return the exponent of the term of index *i* in *f*. It is assumed to fit an ``slong``. void fmpz_mod_mpoly_factor_sort(fmpz_mod_mpoly_factor_t f, const fmpz_mod_mpoly_ctx_t ctx) diff --git a/src/sage/libs/flint/fmpz_mod_poly.pxd b/src/sage/libs/flint/fmpz_mod_poly.pxd index f9644855389..fe0f3a088de 100644 --- a/src/sage/libs/flint/fmpz_mod_poly.pxd +++ b/src/sage/libs/flint/fmpz_mod_poly.pxd @@ -16,7 +16,7 @@ cdef extern from "flint_wrap.h": # Initialises ``poly`` for use with context ``ctx`` and set it to zero. # A corresponding call to :func:`fmpz_mod_poly_clear` must be made to free the memory used by the polynomial. - void fmpz_mod_poly_init2(fmpz_mod_poly_t poly, long alloc, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_init2(fmpz_mod_poly_t poly, slong alloc, const fmpz_mod_ctx_t ctx) # Initialises ``poly`` with space for at least ``alloc`` coefficients # and sets the length to zero. The allocated coefficients are all set to # zero. @@ -25,13 +25,13 @@ cdef extern from "flint_wrap.h": # Clears the given polynomial, releasing any memory used. It must # be reinitialised in order to be used again. - void fmpz_mod_poly_realloc(fmpz_mod_poly_t poly, long alloc, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_realloc(fmpz_mod_poly_t poly, slong alloc, const fmpz_mod_ctx_t ctx) # Reallocates the given polynomial to have space for ``alloc`` # coefficients. If ``alloc`` is zero the polynomial is cleared # and then reinitialised. If the current length is greater than # ``alloc`` the polynomial is first truncated to length ``alloc``. - void fmpz_mod_poly_fit_length(fmpz_mod_poly_t poly, long len, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_fit_length(fmpz_mod_poly_t poly, slong len, const fmpz_mod_ctx_t ctx) # If ``len`` is greater than the number of coefficients currently # allocated, then the polynomial is reallocated to have space for at # least ``len`` coefficients. No data is lost when calling this @@ -46,44 +46,44 @@ cdef extern from "flint_wrap.h": # If all coefficients are zero, the length is set to zero. This function # is mainly used internally, as all functions guarantee normalisation. - void _fmpz_mod_poly_set_length(fmpz_mod_poly_t poly, long len) + void _fmpz_mod_poly_set_length(fmpz_mod_poly_t poly, slong len) # Demotes the coefficients of ``poly`` beyond ``len`` and sets # the length of ``poly`` to ``len``. - void fmpz_mod_poly_truncate(fmpz_mod_poly_t poly, long len, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_truncate(fmpz_mod_poly_t poly, slong len, const fmpz_mod_ctx_t ctx) # If the current length of ``poly`` is greater than ``len``, it # is truncated to have the given length. Discarded coefficients are # not necessarily set to zero. - void fmpz_mod_poly_set_trunc(fmpz_mod_poly_t res, const fmpz_mod_poly_t poly, long n, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_set_trunc(fmpz_mod_poly_t res, const fmpz_mod_poly_t poly, slong n, const fmpz_mod_ctx_t ctx) # Notionally truncate ``poly`` to length `n` and set ``res`` to the # result. The result is normalised. - void fmpz_mod_poly_randtest(fmpz_mod_poly_t f, flint_rand_t state, long len, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_randtest(fmpz_mod_poly_t f, flint_rand_t state, slong len, const fmpz_mod_ctx_t ctx) # Sets the polynomial~`f` to a random polynomial of length up~``len``. - void fmpz_mod_poly_randtest_irreducible(fmpz_mod_poly_t f, flint_rand_t state, long len, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_randtest_irreducible(fmpz_mod_poly_t f, flint_rand_t state, slong len, const fmpz_mod_ctx_t ctx) # Sets the polynomial~`f` to a random irreducible polynomial of length # up~``len``, assuming ``len`` is positive. - void fmpz_mod_poly_randtest_not_zero(fmpz_mod_poly_t f, flint_rand_t state, long len, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_randtest_not_zero(fmpz_mod_poly_t f, flint_rand_t state, slong len, const fmpz_mod_ctx_t ctx) # Sets the polynomial~`f` to a random polynomial of length up~``len``, # assuming ``len`` is positive. - void fmpz_mod_poly_randtest_monic(fmpz_mod_poly_t poly, flint_rand_t state, long len, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_randtest_monic(fmpz_mod_poly_t poly, flint_rand_t state, slong len, const fmpz_mod_ctx_t ctx) # Generates a random monic polynomial with length ``len``. - void fmpz_mod_poly_randtest_monic_irreducible(fmpz_mod_poly_t poly, flint_rand_t state, long len, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_randtest_monic_irreducible(fmpz_mod_poly_t poly, flint_rand_t state, slong len, const fmpz_mod_ctx_t ctx) # Generates a random monic irreducible polynomial with length ``len``. - void fmpz_mod_poly_randtest_monic_primitive(fmpz_mod_poly_t poly, flint_rand_t state, long len, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_randtest_monic_primitive(fmpz_mod_poly_t poly, flint_rand_t state, slong len, const fmpz_mod_ctx_t ctx) # Generates a random monic irreducible primitive polynomial with # length ``len``. - void fmpz_mod_poly_randtest_trinomial(fmpz_mod_poly_t poly, flint_rand_t state, long len, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_randtest_trinomial(fmpz_mod_poly_t poly, flint_rand_t state, slong len, const fmpz_mod_ctx_t ctx) # Generates a random monic trinomial of length ``len``. - int fmpz_mod_poly_randtest_trinomial_irreducible(fmpz_mod_poly_t poly, flint_rand_t state, long len, long max_attempts, const fmpz_mod_ctx_t ctx) + int fmpz_mod_poly_randtest_trinomial_irreducible(fmpz_mod_poly_t poly, flint_rand_t state, slong len, slong max_attempts, const fmpz_mod_ctx_t ctx) # Attempts to set ``poly`` to a monic irreducible trinomial of # length ``len``. It will generate up to ``max_attempts`` # trinomials in attempt to find an irreducible one. If @@ -91,10 +91,10 @@ cdef extern from "flint_wrap.h": # trinomials until an irreducible one is found. Returns `1` if one # is found and `0` otherwise. - void fmpz_mod_poly_randtest_pentomial(fmpz_mod_poly_t poly, flint_rand_t state, long len, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_randtest_pentomial(fmpz_mod_poly_t poly, flint_rand_t state, slong len, const fmpz_mod_ctx_t ctx) # Generates a random monic pentomial of length ``len``. - int fmpz_mod_poly_randtest_pentomial_irreducible(fmpz_mod_poly_t poly, flint_rand_t state, long len, long max_attempts, const fmpz_mod_ctx_t ctx) + int fmpz_mod_poly_randtest_pentomial_irreducible(fmpz_mod_poly_t poly, flint_rand_t state, slong len, slong max_attempts, const fmpz_mod_ctx_t ctx) # Attempts to set ``poly`` to a monic irreducible pentomial of # length ``len``. It will generate up to ``max_attempts`` # pentomials in attempt to find an irreducible one. If @@ -102,18 +102,18 @@ cdef extern from "flint_wrap.h": # pentomials until an irreducible one is found. Returns `1` if one # is found and `0` otherwise. - void fmpz_mod_poly_randtest_sparse_irreducible(fmpz_mod_poly_t poly, flint_rand_t state, long len, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_randtest_sparse_irreducible(fmpz_mod_poly_t poly, flint_rand_t state, slong len, const fmpz_mod_ctx_t ctx) # Attempts to set ``poly`` to a sparse, monic irreducible polynomial # with length ``len``. It attempts to find an irreducible # trinomial. If that does not succeed, it attempts to find a # irreducible pentomial. If that fails, then ``poly`` is just # set to a random monic irreducible polynomial. - long fmpz_mod_poly_degree(const fmpz_mod_poly_t poly, const fmpz_mod_ctx_t ctx) + slong fmpz_mod_poly_degree(const fmpz_mod_poly_t poly, const fmpz_mod_ctx_t ctx) # Returns the degree of the polynomial. The degree of the zero # polynomial is defined to be `-1`. - long fmpz_mod_poly_length(const fmpz_mod_poly_t poly, const fmpz_mod_ctx_t ctx) + slong fmpz_mod_poly_length(const fmpz_mod_poly_t poly, const fmpz_mod_ctx_t ctx) # Returns the length of the polynomial, which is one more than # its degree. @@ -134,17 +134,17 @@ cdef extern from "flint_wrap.h": void fmpz_mod_poly_one(fmpz_mod_poly_t poly, const fmpz_mod_ctx_t ctx) # Sets ``poly`` to the constant polynomial `1`. - void fmpz_mod_poly_zero_coeffs(fmpz_mod_poly_t poly, long i, long j, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_zero_coeffs(fmpz_mod_poly_t poly, slong i, slong j, const fmpz_mod_ctx_t ctx) # Sets the coefficients of `X^k` for `k \in [i, j)` in the polynomial # to zero. - void fmpz_mod_poly_reverse(fmpz_mod_poly_t res, const fmpz_mod_poly_t poly, long n, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_reverse(fmpz_mod_poly_t res, const fmpz_mod_poly_t poly, slong n, const fmpz_mod_ctx_t ctx) # This function considers the polynomial ``poly`` to be of length `n`, # notionally truncating and zero padding if required, and reverses # the result. Since the function normalises its result ``res`` may be # of length less than `n`. - void fmpz_mod_poly_set_ui(fmpz_mod_poly_t f, unsigned long c, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_set_ui(fmpz_mod_poly_t f, ulong c, const fmpz_mod_ctx_t ctx) # Sets the polynomial `f` to the constant `c` reduced modulo `p`. void fmpz_mod_poly_set_fmpz(fmpz_mod_poly_t f, const fmpz_t c, const fmpz_mod_ctx_t ctx) @@ -165,7 +165,7 @@ cdef extern from "flint_wrap.h": int fmpz_mod_poly_equal(const fmpz_mod_poly_t poly1, const fmpz_mod_poly_t poly2, const fmpz_mod_ctx_t ctx) # Returns non-zero if the two polynomials are equal, otherwise returns zero. - int fmpz_mod_poly_equal_trunc(const fmpz_mod_poly_t poly1, const fmpz_mod_poly_t poly2, long n, const fmpz_mod_ctx_t ctx) + int fmpz_mod_poly_equal_trunc(const fmpz_mod_poly_t poly1, const fmpz_mod_poly_t poly2, slong n, const fmpz_mod_ctx_t ctx) # Notionally truncates the two polynomials to length `n` and returns non-zero # if the two polynomials are equal, otherwise returns zero. @@ -178,38 +178,38 @@ cdef extern from "flint_wrap.h": int fmpz_mod_poly_is_gen(const fmpz_mod_poly_t poly, const fmpz_mod_ctx_t ctx) # Returns non-zero if the polynomial is the degree `1` polynomial `x`. - void fmpz_mod_poly_set_coeff_fmpz(fmpz_mod_poly_t poly, long n, const fmpz_t x, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_set_coeff_fmpz(fmpz_mod_poly_t poly, slong n, const fmpz_t x, const fmpz_mod_ctx_t ctx) # Sets the coefficient of `X^n` in the polynomial to `x`, # assuming `n \geq 0`. - void fmpz_mod_poly_set_coeff_ui(fmpz_mod_poly_t poly, long n, unsigned long x, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_set_coeff_ui(fmpz_mod_poly_t poly, slong n, ulong x, const fmpz_mod_ctx_t ctx) # Sets the coefficient of `X^n` in the polynomial to `x`, # assuming `n \geq 0`. - void fmpz_mod_poly_get_coeff_fmpz(fmpz_t x, const fmpz_mod_poly_t poly, long n, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_get_coeff_fmpz(fmpz_t x, const fmpz_mod_poly_t poly, slong n, const fmpz_mod_ctx_t ctx) # Sets `x` to the coefficient of `X^n` in the polynomial, # assuming `n \geq 0`. - void fmpz_mod_poly_set_coeff_mpz(fmpz_mod_poly_t poly, long n, const mpz_t x, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_set_coeff_mpz(fmpz_mod_poly_t poly, slong n, const mpz_t x, const fmpz_mod_ctx_t ctx) # Sets the coefficient of `X^n` in the polynomial to `x`, # assuming `n \geq 0`. - void fmpz_mod_poly_get_coeff_mpz(mpz_t x, const fmpz_mod_poly_t poly, long n, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_get_coeff_mpz(mpz_t x, const fmpz_mod_poly_t poly, slong n, const fmpz_mod_ctx_t ctx) # Sets `x` to the coefficient of `X^n` in the polynomial, # assuming `n \geq 0`. - void _fmpz_mod_poly_shift_left(fmpz * res, const fmpz * poly, long len, long n) + void _fmpz_mod_poly_shift_left(fmpz * res, const fmpz * poly, slong len, slong n) # Sets ``(res, len + n)`` to ``(poly, len)`` shifted left by # `n` coefficients. # Inserts zero coefficients at the lower end. Assumes that ``len`` # and `n` are positive, and that ``res`` fits ``len + n`` elements. # Supports aliasing between ``res`` and ``poly``. - void fmpz_mod_poly_shift_left(fmpz_mod_poly_t f, const fmpz_mod_poly_t g, long n, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_shift_left(fmpz_mod_poly_t f, const fmpz_mod_poly_t g, slong n, const fmpz_mod_ctx_t ctx) # Sets ``res`` to ``poly`` shifted left by `n` coeffs. Zero # coefficients are inserted. - void _fmpz_mod_poly_shift_right(fmpz * res, const fmpz * poly, long len, long n) + void _fmpz_mod_poly_shift_right(fmpz * res, const fmpz * poly, slong len, slong n) # Sets ``(res, len - n)`` to ``(poly, len)`` shifted right by # `n` coefficients. # Assumes that ``len`` and `n` are positive, that ``len > n``, @@ -217,12 +217,12 @@ cdef extern from "flint_wrap.h": # between ``res`` and ``poly``, although in this case the top # coefficients of ``poly`` are not set to zero. - void fmpz_mod_poly_shift_right(fmpz_mod_poly_t f, const fmpz_mod_poly_t g, long n, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_shift_right(fmpz_mod_poly_t f, const fmpz_mod_poly_t g, slong n, const fmpz_mod_ctx_t ctx) # Sets ``res`` to ``poly`` shifted right by `n` coefficients. If `n` # is equal to or greater than the current length of ``poly``, ``res`` # is set to the zero polynomial. - void _fmpz_mod_poly_add(fmpz *res, const fmpz *poly1, long len1, const fmpz *poly2, long len2, const fmpz_mod_ctx_t ctx) + void _fmpz_mod_poly_add(fmpz *res, const fmpz *poly1, slong len1, const fmpz *poly2, slong len2, const fmpz_mod_ctx_t ctx) # Sets ``res`` to the sum of ``(poly1, len1)`` and # ``(poly2, len2)``. It is assumed that ``res`` has # sufficient space for the longer of the two polynomials. @@ -230,11 +230,11 @@ cdef extern from "flint_wrap.h": void fmpz_mod_poly_add(fmpz_mod_poly_t res, const fmpz_mod_poly_t poly1, const fmpz_mod_poly_t poly2, const fmpz_mod_ctx_t ctx) # Sets ``res`` to the sum of ``poly1`` and ``poly2``. - void fmpz_mod_poly_add_series(fmpz_mod_poly_t res, const fmpz_mod_poly_t poly1, const fmpz_mod_poly_t poly2, long n, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_add_series(fmpz_mod_poly_t res, const fmpz_mod_poly_t poly1, const fmpz_mod_poly_t poly2, slong n, const fmpz_mod_ctx_t ctx) # Notionally truncate ``poly1`` and ``poly2`` to length `n` and set # ``res`` to the sum. - void _fmpz_mod_poly_sub(fmpz *res, const fmpz *poly1, long len1, const fmpz *poly2, long len2, const fmpz_mod_ctx_t ctx) + void _fmpz_mod_poly_sub(fmpz *res, const fmpz *poly1, slong len1, const fmpz *poly2, slong len2, const fmpz_mod_ctx_t ctx) # Sets ``res`` to ``(poly1, len1)`` minus ``(poly2, len2)``. It # is assumed that ``res`` has sufficient space for the longer of the # two polynomials. @@ -242,18 +242,18 @@ cdef extern from "flint_wrap.h": void fmpz_mod_poly_sub(fmpz_mod_poly_t res, const fmpz_mod_poly_t poly1, const fmpz_mod_poly_t poly2, const fmpz_mod_ctx_t ctx) # Sets ``res`` to ``poly1`` minus ``poly2``. - void fmpz_mod_poly_sub_series(fmpz_mod_poly_t res, const fmpz_mod_poly_t poly1, const fmpz_mod_poly_t poly2, long n, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_sub_series(fmpz_mod_poly_t res, const fmpz_mod_poly_t poly1, const fmpz_mod_poly_t poly2, slong n, const fmpz_mod_ctx_t ctx) # Notionally truncate ``poly1`` and ``poly2`` to length `n` and set # ``res`` to the difference. - void _fmpz_mod_poly_neg(fmpz *res, const fmpz *poly, long len, const fmpz_mod_ctx_t ctx) + void _fmpz_mod_poly_neg(fmpz *res, const fmpz *poly, slong len, const fmpz_mod_ctx_t ctx) # Sets ``(res, len)`` to the negative of ``(poly, len)`` # modulo `p`. void fmpz_mod_poly_neg(fmpz_mod_poly_t res, const fmpz_mod_poly_t poly, const fmpz_mod_ctx_t ctx) # Sets ``res`` to the negative of ``poly`` modulo `p`. - void _fmpz_mod_poly_scalar_mul_fmpz(fmpz *res, const fmpz *poly, long len, const fmpz_t x, const fmpz_mod_ctx_t ctx) + void _fmpz_mod_poly_scalar_mul_fmpz(fmpz *res, const fmpz *poly, slong len, const fmpz_t x, const fmpz_mod_ctx_t ctx) # Sets ``(res, len``) to ``(poly, len)`` multiplied by `x`, # reduced modulo `p`. @@ -263,7 +263,7 @@ cdef extern from "flint_wrap.h": void fmpz_mod_poly_scalar_addmul_fmpz(fmpz_mod_poly_t rop, const fmpz_mod_poly_t op, const fmpz_t x, const fmpz_mod_ctx_t ctx) # Adds to ``rop`` the product of ``op`` by the scalar ``x``. - void _fmpz_mod_poly_scalar_div_fmpz(fmpz *res, const fmpz *poly, long len, const fmpz_t x, const fmpz_mod_ctx_t ctx) + void _fmpz_mod_poly_scalar_div_fmpz(fmpz *res, const fmpz *poly, slong len, const fmpz_t x, const fmpz_mod_ctx_t ctx) # Sets ``(res, len``) to ``(poly, len)`` divided by `x` (i.e. # multiplied by the inverse of `x \pmod{p}`). The result is reduced modulo # `p`. @@ -272,7 +272,7 @@ cdef extern from "flint_wrap.h": # Sets ``res`` to ``poly`` divided by `x`, (i.e. multiplied by the # inverse of `x \pmod{p}`). The result is reduced modulo `p`. - void _fmpz_mod_poly_mul(fmpz *res, const fmpz *poly1, long len1, const fmpz *poly2, long len2, const fmpz_mod_ctx_t ctx) + void _fmpz_mod_poly_mul(fmpz *res, const fmpz *poly1, slong len1, const fmpz *poly2, slong len2, const fmpz_mod_ctx_t ctx) # Sets ``(res, len1 + len2 - 1)`` to the product of ``(poly1, len1)`` # and ``(poly2, len2)``. Assumes ``len1 >= len2 > 0``. Allows # zero-padding of the two input polynomials. @@ -280,29 +280,29 @@ cdef extern from "flint_wrap.h": void fmpz_mod_poly_mul(fmpz_mod_poly_t res, const fmpz_mod_poly_t poly1, const fmpz_mod_poly_t poly2, const fmpz_mod_ctx_t ctx) # Sets ``res`` to the product of ``poly1`` and ``poly2``. - void _fmpz_mod_poly_mullow(fmpz *res, const fmpz *poly1, long len1, const fmpz *poly2, long len2, long n, const fmpz_mod_ctx_t ctx) + void _fmpz_mod_poly_mullow(fmpz *res, const fmpz *poly1, slong len1, const fmpz *poly2, slong len2, slong n, const fmpz_mod_ctx_t ctx) # Sets ``(res, n)`` to the lowest `n` coefficients of the product of # ``(poly1, len1)`` and ``(poly2, len2)``. # Assumes ``len1 >= len2 > 0`` and ``0 < n <= len1 + len2 - 1``. # Allows for zero-padding in the inputs. Does not support aliasing between # the inputs and the output. - void fmpz_mod_poly_mullow(fmpz_mod_poly_t res, const fmpz_mod_poly_t poly1, const fmpz_mod_poly_t poly2, long n, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_mullow(fmpz_mod_poly_t res, const fmpz_mod_poly_t poly1, const fmpz_mod_poly_t poly2, slong n, const fmpz_mod_ctx_t ctx) # Sets ``res`` to the lowest `n` coefficients of the product of # ``poly1`` and ``poly2``. - void _fmpz_mod_poly_sqr(fmpz *res, const fmpz *poly, long len, const fmpz_mod_ctx_t ctx) + void _fmpz_mod_poly_sqr(fmpz *res, const fmpz *poly, slong len, const fmpz_mod_ctx_t ctx) # Sets ``res`` to the square of ``poly``. void fmpz_mod_poly_sqr(fmpz_mod_poly_t res, const fmpz_mod_poly_t poly, const fmpz_mod_ctx_t ctx) # Computes ``res`` as the square of ``poly``. - void fmpz_mod_poly_mulhigh(fmpz_mod_poly_t res, const fmpz_mod_poly_t poly1, const fmpz_mod_poly_t poly2, long start, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_mulhigh(fmpz_mod_poly_t res, const fmpz_mod_poly_t poly1, const fmpz_mod_poly_t poly2, slong start, const fmpz_mod_ctx_t ctx) # Computes the product of ``poly1`` and ``poly2`` and writes the # coefficients from ``start`` onwards into the high coefficients of # ``res``, the remaining coefficients being arbitrary. - void _fmpz_mod_poly_mulmod(fmpz * res, const fmpz * poly1, long len1, const fmpz * poly2, long len2, const fmpz * f, long lenf, const fmpz_mod_ctx_t ctx) + void _fmpz_mod_poly_mulmod(fmpz * res, const fmpz * poly1, slong len1, const fmpz * poly2, slong len2, const fmpz * f, slong lenf, const fmpz_mod_ctx_t ctx) # Sets ``res, len1 + len2 - 1`` to the remainder of the product of # ``poly1`` and ``poly2`` upon polynomial division by ``f``. # It is required that ``len1 + len2 - lenf > 0``, which is equivalent @@ -314,7 +314,7 @@ cdef extern from "flint_wrap.h": # Sets ``res`` to the remainder of the product of ``poly1`` and # ``poly2`` upon polynomial division by ``f``. - void _fmpz_mod_poly_mulmod_preinv(fmpz * res, const fmpz * poly1, long len1, const fmpz * poly2, long len2, const fmpz * f, long lenf, const fmpz* finv, long lenfinv, const fmpz_mod_ctx_t ctx) + void _fmpz_mod_poly_mulmod_preinv(fmpz * res, const fmpz * poly1, slong len1, const fmpz * poly2, slong len2, const fmpz * f, slong lenf, const fmpz* finv, slong lenfinv, const fmpz_mod_ctx_t ctx) # Sets ``res, len1 + len2 - 1`` to the remainder of the product of # ``poly1`` and ``poly2`` upon polynomial division by ``f``. # It is required that ``finv`` is the inverse of the reverse of ``f`` @@ -330,13 +330,13 @@ cdef extern from "flint_wrap.h": # inverse of the reverse of ``f``. It is required that ``poly1`` and # ``poly2`` are reduced modulo ``f``. - void _fmpz_mod_poly_product_roots_fmpz_vec(fmpz * poly, const fmpz * xs, long n, const fmpz_mod_ctx_t ctx) + void _fmpz_mod_poly_product_roots_fmpz_vec(fmpz * poly, const fmpz * xs, slong n, const fmpz_mod_ctx_t ctx) # Sets ``(poly, n + 1)`` to the monic polynomial which is the product # of `(x - x_0)(x - x_1) \cdots (x - x_{n-1})`, the roots `x_i` being # given by ``xs``. It is required that the roots are canonical. # Aliasing of the input and output is not allowed. - void fmpz_mod_poly_product_roots_fmpz_vec(fmpz_mod_poly_t poly, const fmpz * xs, long n, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_product_roots_fmpz_vec(fmpz_mod_poly_t poly, const fmpz * xs, slong n, const fmpz_mod_ctx_t ctx) # Sets ``poly`` to the monic polynomial which is the product # of `(x - x_0)(x - x_1) \cdots (x - x_{n-1})`, the roots `x_i` being # given by ``xs``. It is required that the roots are canonical. @@ -346,16 +346,16 @@ cdef extern from "flint_wrap.h": # Otherwise, return ``0``. It is assumed that ``A`` is nonzero and that the modulus of ``A`` is prime. # This function uses Rabin's probabilistic method via gcd's with `(x + \delta)^{\frac{p-1}{2}} - 1`. - void _fmpz_mod_poly_pow(fmpz *rop, const fmpz *op, long len, unsigned long e, const fmpz_mod_ctx_t ctx) + void _fmpz_mod_poly_pow(fmpz *rop, const fmpz *op, slong len, ulong e, const fmpz_mod_ctx_t ctx) # Sets ``rop = poly^e``, assuming that `e > 1` and ``elen > 0``, # and that ``res`` has space for ``e*(len - 1) + 1`` coefficients. # Does not support aliasing. - void fmpz_mod_poly_pow(fmpz_mod_poly_t rop, const fmpz_mod_poly_t op, unsigned long e, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_pow(fmpz_mod_poly_t rop, const fmpz_mod_poly_t op, ulong e, const fmpz_mod_ctx_t ctx) # Computes ``rop = poly^e``. If `e` is zero, returns one, # so that in particular ``0^0 = 1``. - void _fmpz_mod_poly_pow_trunc(fmpz * res, const fmpz * poly, unsigned long e, long trunc, const fmpz_mod_ctx_t ctx) + void _fmpz_mod_poly_pow_trunc(fmpz * res, const fmpz * poly, ulong e, slong trunc, const fmpz_mod_ctx_t ctx) # Sets ``res`` to the low ``trunc`` coefficients of ``poly`` # (assumed to be zero padded if necessary to length ``trunc``) to # the power ``e``. This is equivalent to doing a powering followed @@ -363,12 +363,12 @@ cdef extern from "flint_wrap.h": # ``trunc`` coefficients, that ``trunc > 0`` and that # ``e > 1``. Aliasing is not permitted. - void fmpz_mod_poly_pow_trunc(fmpz_mod_poly_t res, const fmpz_mod_poly_t poly, unsigned long e, long trunc, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_pow_trunc(fmpz_mod_poly_t res, const fmpz_mod_poly_t poly, ulong e, slong trunc, const fmpz_mod_ctx_t ctx) # Sets ``res`` to the low ``trunc`` coefficients of ``poly`` # to the power ``e``. This is equivalent to doing a powering # followed by a truncation. - void _fmpz_mod_poly_pow_trunc_binexp(fmpz * res, const fmpz * poly, unsigned long e, long trunc, const fmpz_mod_ctx_t ctx) + void _fmpz_mod_poly_pow_trunc_binexp(fmpz * res, const fmpz * poly, ulong e, slong trunc, const fmpz_mod_ctx_t ctx) # Sets ``res`` to the low ``trunc`` coefficients of ``poly`` # (assumed to be zero padded if necessary to length ``trunc``) to # the power ``e``. This is equivalent to doing a powering followed @@ -377,12 +377,12 @@ cdef extern from "flint_wrap.h": # ``e > 1``. Aliasing is not permitted. Uses the binary # exponentiation method. - void fmpz_mod_poly_pow_trunc_binexp(fmpz_mod_poly_t res, const fmpz_mod_poly_t poly, unsigned long e, long trunc, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_pow_trunc_binexp(fmpz_mod_poly_t res, const fmpz_mod_poly_t poly, ulong e, slong trunc, const fmpz_mod_ctx_t ctx) # Sets ``res`` to the low ``trunc`` coefficients of ``poly`` # to the power ``e``. This is equivalent to doing a powering # followed by a truncation. Uses the binary exponentiation method. - void _fmpz_mod_poly_powmod_ui_binexp(fmpz * res, const fmpz * poly, unsigned long e, const fmpz * f, long lenf, const fmpz_mod_ctx_t ctx) + void _fmpz_mod_poly_powmod_ui_binexp(fmpz * res, const fmpz * poly, ulong e, const fmpz * f, slong lenf, const fmpz_mod_ctx_t ctx) # Sets ``res`` to ``poly`` raised to the power ``e`` # modulo ``f``, using binary exponentiation. We require ``e > 0``. # We require ``lenf > 1``. It is assumed that ``poly`` is already @@ -390,11 +390,11 @@ cdef extern from "flint_wrap.h": # exactly ``lenf - 1``. The output ``res`` must have room for # ``lenf - 1`` coefficients. - void fmpz_mod_poly_powmod_ui_binexp(fmpz_mod_poly_t res, const fmpz_mod_poly_t poly, unsigned long e, const fmpz_mod_poly_t f, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_powmod_ui_binexp(fmpz_mod_poly_t res, const fmpz_mod_poly_t poly, ulong e, const fmpz_mod_poly_t f, const fmpz_mod_ctx_t ctx) # Sets ``res`` to ``poly`` raised to the power ``e`` # modulo ``f``, using binary exponentiation. We require ``e >= 0``. - void _fmpz_mod_poly_powmod_ui_binexp_preinv(fmpz * res, const fmpz * poly, unsigned long e, const fmpz * f, long lenf, const fmpz * finv, long lenfinv, const fmpz_mod_ctx_t ctx) + void _fmpz_mod_poly_powmod_ui_binexp_preinv(fmpz * res, const fmpz * poly, ulong e, const fmpz * f, slong lenf, const fmpz * finv, slong lenfinv, const fmpz_mod_ctx_t ctx) # Sets ``res`` to ``poly`` raised to the power ``e`` # modulo ``f``, using binary exponentiation. We require ``e > 0``. # We require ``finv`` to be the inverse of the reverse of ``f``. @@ -403,12 +403,12 @@ cdef extern from "flint_wrap.h": # exactly ``lenf - 1``. The output ``res`` must have room for # ``lenf - 1`` coefficients. - void fmpz_mod_poly_powmod_ui_binexp_preinv(fmpz_mod_poly_t res, const fmpz_mod_poly_t poly, unsigned long e, const fmpz_mod_poly_t f, const fmpz_mod_poly_t finv, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_powmod_ui_binexp_preinv(fmpz_mod_poly_t res, const fmpz_mod_poly_t poly, ulong e, const fmpz_mod_poly_t f, const fmpz_mod_poly_t finv, const fmpz_mod_ctx_t ctx) # Sets ``res`` to ``poly`` raised to the power ``e`` # modulo ``f``, using binary exponentiation. We require ``e >= 0``. # We require ``finv`` to be the inverse of the reverse of ``f``. - void _fmpz_mod_poly_powmod_fmpz_binexp(fmpz * res, const fmpz * poly, const fmpz_t e, const fmpz * f, long lenf, const fmpz_mod_ctx_t ctx) + void _fmpz_mod_poly_powmod_fmpz_binexp(fmpz * res, const fmpz * poly, const fmpz_t e, const fmpz * f, slong lenf, const fmpz_mod_ctx_t ctx) # Sets ``res`` to ``poly`` raised to the power ``e`` # modulo ``f``, using binary exponentiation. We require ``e > 0``. # We require ``lenf > 1``. It is assumed that ``poly`` is already @@ -420,7 +420,7 @@ cdef extern from "flint_wrap.h": # Sets ``res`` to ``poly`` raised to the power ``e`` # modulo ``f``, using binary exponentiation. We require ``e >= 0``. - void _fmpz_mod_poly_powmod_fmpz_binexp_preinv(fmpz * res, const fmpz * poly, const fmpz_t e, const fmpz * f, long lenf, const fmpz* finv, long lenfinv, const fmpz_mod_ctx_t ctx) + void _fmpz_mod_poly_powmod_fmpz_binexp_preinv(fmpz * res, const fmpz * poly, const fmpz_t e, const fmpz * f, slong lenf, const fmpz* finv, slong lenfinv, const fmpz_mod_ctx_t ctx) # Sets ``res`` to ``poly`` raised to the power ``e`` # modulo ``f``, using binary exponentiation. We require ``e > 0``. # We require ``finv`` to be the inverse of the reverse of ``f``. @@ -434,7 +434,7 @@ cdef extern from "flint_wrap.h": # modulo ``f``, using binary exponentiation. We require ``e >= 0``. # We require ``finv`` to be the inverse of the reverse of ``f``. - void _fmpz_mod_poly_powmod_x_fmpz_preinv(fmpz * res, const fmpz_t e, const fmpz * f, long lenf, const fmpz* finv, long lenfinv, const fmpz_mod_ctx_t ctx) + void _fmpz_mod_poly_powmod_x_fmpz_preinv(fmpz * res, const fmpz_t e, const fmpz * f, slong lenf, const fmpz* finv, slong lenfinv, const fmpz_mod_ctx_t ctx) # Sets ``res`` to ``x`` raised to the power ``e`` modulo ``f``, # using sliding window exponentiation. We require ``e > 0``. # We require ``finv`` to be the inverse of the reverse of ``f``. @@ -447,7 +447,7 @@ cdef extern from "flint_wrap.h": # ``e >= 0``. We require ``finv`` to be the inverse of the reverse of # `` - void _fmpz_mod_poly_powers_mod_preinv_naive(fmpz ** res, const fmpz * f, long flen, long n, const fmpz * g, long glen, const fmpz * ginv, long ginvlen, const fmpz_mod_ctx_t ctx) + void _fmpz_mod_poly_powers_mod_preinv_naive(fmpz ** res, const fmpz * f, slong flen, slong n, const fmpz * g, slong glen, const fmpz * ginv, slong ginvlen, const fmpz_mod_ctx_t ctx) # Compute ``f^0, f^1, ..., f^(n-1) mod g``, where ``g`` has length ``glen`` # and ``f`` is reduced mod ``g`` and has length ``flen`` (possibly zero # spaced). Assumes ``res`` is an array of ``n`` arrays each with space for @@ -455,12 +455,12 @@ cdef extern from "flint_wrap.h": # ``ginv`` of length ``ginvlen`` is set to the power series inverse of the # reverse of ``g``. - void fmpz_mod_poly_powers_mod_naive(fmpz_mod_poly_struct * res, const fmpz_mod_poly_t f, long n, const fmpz_mod_poly_t g, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_powers_mod_naive(fmpz_mod_poly_struct * res, const fmpz_mod_poly_t f, slong n, const fmpz_mod_poly_t g, const fmpz_mod_ctx_t ctx) # Set the entries of the array ``res`` to ``f^0, f^1, ..., f^(n-1) mod g``. # No aliasing is permitted between the entries of ``res`` and either of the # inputs. - void _fmpz_mod_poly_powers_mod_preinv_threaded_pool(fmpz ** res, const fmpz * f, long flen, long n, const fmpz * g, long glen, const fmpz * ginv, long ginvlen, const fmpz_mod_ctx_t p, thread_pool_handle * threads, long num_threads) + void _fmpz_mod_poly_powers_mod_preinv_threaded_pool(fmpz ** res, const fmpz * f, slong flen, slong n, const fmpz * g, slong glen, const fmpz * ginv, slong ginvlen, const fmpz_mod_ctx_t p, thread_pool_handle * threads, slong num_threads) # Compute ``f^0, f^1, ..., f^(n-1) mod g``, where ``g`` has length ``glen`` # and ``f`` is reduced mod ``g`` and has length ``flen`` (possibly zero # spaced). Assumes ``res`` is an array of ``n`` arrays each with space for @@ -468,12 +468,12 @@ cdef extern from "flint_wrap.h": # ``ginv`` of length ``ginvlen`` is set to the power series inverse of the # reverse of ``g``. - void fmpz_mod_poly_powers_mod_bsgs(fmpz_mod_poly_struct * res, const fmpz_mod_poly_t f, long n, const fmpz_mod_poly_t g, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_powers_mod_bsgs(fmpz_mod_poly_struct * res, const fmpz_mod_poly_t f, slong n, const fmpz_mod_poly_t g, const fmpz_mod_ctx_t ctx) # Set the entries of the array ``res`` to ``f^0, f^1, ..., f^(n-1) mod g``. # No aliasing is permitted between the entries of ``res`` and either of the # inputs. - void fmpz_mod_poly_frobenius_powers_2exp_precomp(fmpz_mod_poly_frobenius_powers_2exp_t pow, const fmpz_mod_poly_t f, const fmpz_mod_poly_t finv, unsigned long m, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_frobenius_powers_2exp_precomp(fmpz_mod_poly_frobenius_powers_2exp_t pow, const fmpz_mod_poly_t f, const fmpz_mod_poly_t finv, ulong m, const fmpz_mod_ctx_t ctx) # If ``p = f->p``, compute `x^{(p^1)}`, `x^{(p^2)}`, `x^{(p^4)}`, ..., # `x^{(p^{(2^l)})} \pmod{f}` where `2^l` is the greatest power of `2` less than # or equal to `m`. @@ -485,7 +485,7 @@ cdef extern from "flint_wrap.h": # Clear resources used by the ``fmpz_mod_poly_frobenius_powers_2exp_t`` # struct. - void fmpz_mod_poly_frobenius_power(fmpz_mod_poly_t res, fmpz_mod_poly_frobenius_powers_2exp_t pow, const fmpz_mod_poly_t f, unsigned long m, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_frobenius_power(fmpz_mod_poly_t res, fmpz_mod_poly_frobenius_powers_2exp_t pow, const fmpz_mod_poly_t f, ulong m, const fmpz_mod_ctx_t ctx) # If ``p = f->p``, compute `x^{(p^m)} \pmod{f}`. # Requires precomputed frobenius powers supplied by # ``fmpz_mod_poly_frobenius_powers_2exp_precomp``. @@ -493,7 +493,7 @@ cdef extern from "flint_wrap.h": # However an impossible inverse by the leading coefficient of `f` will have # been caught by ``fmpz_mod_poly_frobenius_powers_2exp_precomp``. - void fmpz_mod_poly_frobenius_powers_precomp(fmpz_mod_poly_frobenius_powers_t pow, const fmpz_mod_poly_t f, const fmpz_mod_poly_t finv, unsigned long m, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_frobenius_powers_precomp(fmpz_mod_poly_frobenius_powers_t pow, const fmpz_mod_poly_t f, const fmpz_mod_poly_t finv, ulong m, const fmpz_mod_ctx_t ctx) # If ``p = f->p``, compute `x^{(p^0)}`, `x^{(p^1)}`, `x^{(p^2)}`, `x^{(p^3)}`, # ..., `x^{(p^m)} \pmod{f}`. # Requires precomputed inverse of `f`, i.e. newton inverse. @@ -502,7 +502,7 @@ cdef extern from "flint_wrap.h": # Clear resources used by the ``fmpz_mod_poly_frobenius_powers_t`` # struct. - void _fmpz_mod_poly_divrem_basecase(fmpz * Q, fmpz * R, const fmpz * A, long lenA, const fmpz * B, long lenB, const fmpz_t invB, const fmpz_mod_ctx_t ctx) + void _fmpz_mod_poly_divrem_basecase(fmpz * Q, fmpz * R, const fmpz * A, slong lenA, const fmpz * B, slong lenB, const fmpz_t invB, const fmpz_mod_ctx_t ctx) # Computes ``(Q, lenA - lenB + 1)``, ``(R, lenA)`` such that # `A = B Q + R` with `0 \leq \operatorname{len}(R) < \operatorname{len}(B)`. # Assumes that the leading coefficient of `B` is invertible @@ -517,7 +517,7 @@ cdef extern from "flint_wrap.h": # Assumes that the leading coefficient of `B` is invertible # modulo `p`. - void _fmpz_mod_poly_divrem_newton_n_preinv (fmpz* Q, fmpz* R, const fmpz* A, long lenA, const fmpz* B, long lenB, const fmpz* Binv, long lenBinv, const fmpz_mod_ctx_t ctx) + void _fmpz_mod_poly_divrem_newton_n_preinv (fmpz* Q, fmpz* R, const fmpz* A, slong lenA, const fmpz* B, slong lenB, const fmpz* Binv, slong lenBinv, const fmpz_mod_ctx_t ctx) # Computes `Q` and `R` such that `A = BQ + R` with `\operatorname{len}(R)` less than # ``lenB``, where `A` is of length ``lenA`` and `B` is of length # ``lenB``. We require that `Q` have space for ``lenA - lenB + 1`` @@ -534,7 +534,7 @@ cdef extern from "flint_wrap.h": # The algorithm used is to call :func:`div_newton_n` and then multiply out # and compute the remainder. - void _fmpz_mod_poly_div_newton_n_preinv (fmpz* Q, const fmpz* A, long lenA, const fmpz* B, long lenB, const fmpz* Binv, long lenBinv, const fmpz_mod_ctx_t ctx) + void _fmpz_mod_poly_div_newton_n_preinv (fmpz* Q, const fmpz* A, slong lenA, const fmpz* B, slong lenB, const fmpz* Binv, slong lenBinv, const fmpz_mod_ctx_t ctx) # Notionally computes polynomials `Q` and `R` such that `A = BQ + R` with # `\operatorname{len}(R)` less than ``lenB``, where ``A`` is of length ``lenA`` # and ``B`` is of length ``lenB``, but return only `Q`. @@ -554,11 +554,11 @@ cdef extern from "flint_wrap.h": # The algorithm used is to reverse the polynomials and divide the # resulting power series, then reverse the result. - unsigned long fmpz_mod_poly_remove(fmpz_mod_poly_t f, const fmpz_mod_poly_t g, const fmpz_mod_ctx_t ctx) + ulong fmpz_mod_poly_remove(fmpz_mod_poly_t f, const fmpz_mod_poly_t g, const fmpz_mod_ctx_t ctx) # Removes the highest possible power of ``g`` from ``f`` and # returns the exponent. - void _fmpz_mod_poly_rem_basecase(fmpz * R, const fmpz * A, long lenA, const fmpz * B, long lenB, const fmpz_t invB, const fmpz_mod_ctx_t ctx) + void _fmpz_mod_poly_rem_basecase(fmpz * R, const fmpz * A, slong lenA, const fmpz * B, slong lenB, const fmpz_t invB, const fmpz_mod_ctx_t ctx) # Notationally, computes `Q`, `R` such that `A = B Q + R` with # `0 \leq \operatorname{len}(R) < \operatorname{len}(B)` but only sets ``(R, lenB - 1)``. # Allows aliasing only between `A` and `R`. Allows zero-padding @@ -570,7 +570,7 @@ cdef extern from "flint_wrap.h": # `0 \leq \operatorname{len}(R) < \operatorname{len}(B)` assuming that the leading term # of `B` is a unit. - void _fmpz_mod_poly_div(fmpz * Q, const fmpz * A, long lenA, const fmpz * B, long lenB, const fmpz_t invB, const fmpz_mod_ctx_t ctx) + void _fmpz_mod_poly_div(fmpz * Q, const fmpz * A, slong lenA, const fmpz * B, slong lenB, const fmpz_t invB, const fmpz_mod_ctx_t ctx) # Notationally, computes `Q`, `R` such that `A = B Q + R` with # `0 \leq \operatorname{len}(R) < \operatorname{len}(B)` but only sets ``(Q, lenA - lenB + 1)``. # Assumes that the leading coefficient of `B` is a unit modulo `p`. @@ -580,7 +580,7 @@ cdef extern from "flint_wrap.h": # `0 \leq \operatorname{len}(R) < \operatorname{len}(B)` assuming that the leading term # of `B` is a unit. - void _fmpz_mod_poly_divrem(fmpz * Q, fmpz * R, const fmpz * A, long lenA, const fmpz * B, long lenB, const fmpz_t invB, const fmpz_mod_ctx_t ctx) + void _fmpz_mod_poly_divrem(fmpz * Q, fmpz * R, const fmpz * A, slong lenA, const fmpz * B, slong lenB, const fmpz_t invB, const fmpz_mod_ctx_t ctx) # Computes ``(Q, lenA - lenB + 1)``, ``(R, lenB - 1)`` such that # `A = B Q + R` and `0 \leq \operatorname{len}(R) < \operatorname{len}(B)`. # Assumes that `B` is non-zero, that the leading coefficient @@ -605,7 +605,7 @@ cdef extern from "flint_wrap.h": # a non-trivial factor of `p` and `Q` and `R` are not touched. # Assumes that `B` is non-zero. - void _fmpz_mod_poly_rem(fmpz *R, const fmpz *A, long lenA, const fmpz *B, long lenB, const fmpz_t invB, const fmpz_mod_ctx_t ctx) + void _fmpz_mod_poly_rem(fmpz *R, const fmpz *A, slong lenA, const fmpz *B, slong lenB, const fmpz_t invB, const fmpz_mod_ctx_t ctx) # Notationally, computes ``(Q, lenA - lenB + 1)``, ``(R, lenB - 1)`` # such that `A = B Q + R` and `0 \leq \operatorname{len}(R) < \operatorname{len}(B)`, returning # only the remainder part. @@ -628,7 +628,7 @@ cdef extern from "flint_wrap.h": # Assumes that `B` is non-zero and that the leading coefficient # of `B` is invertible modulo `p`. - int _fmpz_mod_poly_divides_classical(fmpz * Q, const fmpz * A, long lenA, const fmpz * B, long lenB, const fmpz_mod_ctx_t ctx) + int _fmpz_mod_poly_divides_classical(fmpz * Q, const fmpz * A, slong lenA, const fmpz * B, slong lenB, const fmpz_mod_ctx_t ctx) # Returns `1` if `(B, lenB)` divides `(A, lenA)` and sets # `(Q, lenA - lenB + 1)` to the quotient. Otherwise, returns `0` and sets # `(Q, lenA - lenB + 1)` to zero. We require that `lenA >= lenB > 0`. @@ -637,7 +637,7 @@ cdef extern from "flint_wrap.h": # Returns `1` if `B` divides `A` and sets `Q` to the quotient. Otherwise # returns `0` and sets `Q` to zero. - int _fmpz_mod_poly_divides(fmpz * Q, const fmpz * A, long lenA, const fmpz * B, long lenB, const fmpz_mod_ctx_t ctx) + int _fmpz_mod_poly_divides(fmpz * Q, const fmpz * A, slong lenA, const fmpz * B, slong lenB, const fmpz_mod_ctx_t ctx) # Returns `1` if `(B, lenB)` divides `(A, lenA)` and sets # `(Q, lenA - lenB + 1)` to the quotient. Otherwise, returns `0` and sets # `(Q, lenA - lenB + 1)` to zero. We require that `lenA >= lenB > 0`. @@ -646,27 +646,27 @@ cdef extern from "flint_wrap.h": # Returns `1` if `B` divides `A` and sets `Q` to the quotient. Otherwise # returns `0` and sets `Q` to zero. - void _fmpz_mod_poly_inv_series(fmpz * Qinv, const fmpz * Q, long Qlen, long n, const fmpz_mod_ctx_t ctx) + void _fmpz_mod_poly_inv_series(fmpz * Qinv, const fmpz * Q, slong Qlen, slong n, const fmpz_mod_ctx_t ctx) # Sets ``(Qinv, n)`` to the inverse of ``(Q, n)`` modulo `x^n`, # where `n \geq 1`, assuming that the bottom coefficient of `Q` is # invertible modulo `p` and that its inverse is ``cinv``. - void fmpz_mod_poly_inv_series(fmpz_mod_poly_t Qinv, const fmpz_mod_poly_t Q, long n, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_inv_series(fmpz_mod_poly_t Qinv, const fmpz_mod_poly_t Q, slong n, const fmpz_mod_ctx_t ctx) # Sets ``Qinv`` to the inverse of ``Q`` modulo `x^n`, # where `n \geq 1`, assuming that the bottom coefficient of # `Q` is a unit. - void fmpz_mod_poly_inv_series_f(fmpz_t f, fmpz_mod_poly_t Qinv, const fmpz_mod_poly_t Q, long n, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_inv_series_f(fmpz_t f, fmpz_mod_poly_t Qinv, const fmpz_mod_poly_t Q, slong n, const fmpz_mod_ctx_t ctx) # Either sets `f` to a nontrivial factor of `p` with the value of # ``Qinv`` undefined, or sets ``Qinv`` to the inverse of ``Q`` # modulo `x^n`, where `n \geq 1`. - void _fmpz_mod_poly_div_series(fmpz * Q, const fmpz * A, long Alen, const fmpz * B, long Blen, long n, const fmpz_mod_ctx_t ctx) + void _fmpz_mod_poly_div_series(fmpz * Q, const fmpz * A, slong Alen, const fmpz * B, slong Blen, slong n, const fmpz_mod_ctx_t ctx) # Set ``(Q, n)`` to the quotient of the series ``(A, Alen``) and # ``(B, Blen)`` assuming ``Alen, Blen <= n``. We assume the bottom # coefficient of ``B`` is invertible modulo `p`. - void fmpz_mod_poly_div_series(fmpz_mod_poly_t Q, const fmpz_mod_poly_t A, const fmpz_mod_poly_t B, long n, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_div_series(fmpz_mod_poly_t Q, const fmpz_mod_poly_t A, const fmpz_mod_poly_t B, slong n, const fmpz_mod_ctx_t ctx) # Set `Q` to the quotient of the series `A` by `B`, thinking of the series as # though they were of length `n`. We assume that the bottom coefficient of # `B` is a unit. @@ -682,7 +682,7 @@ cdef extern from "flint_wrap.h": # coefficient or set `f` to a nontrivial factor of `p` and leave ``res`` # undefined. - long _fmpz_mod_poly_gcd(fmpz *G, const fmpz *A, long lenA, const fmpz *B, long lenB, const fmpz_mod_ctx_t ctx) + slong _fmpz_mod_poly_gcd(fmpz *G, const fmpz *A, slong lenA, const fmpz *B, slong lenB, const fmpz_mod_ctx_t ctx) # Sets `G` to the greatest common divisor of `(A, \operatorname{len}(A))` # and `(B, \operatorname{len}(B))` and returns its length. # Assumes that `\operatorname{len}(A) \geq \operatorname{len}(B) > 0` and that the vector `G` has @@ -696,7 +696,7 @@ cdef extern from "flint_wrap.h": # ring `(\mathbf{Z}/(p \mathbf{Z}))[X]` if and only if `p` is a prime # number. Thus, this function assumes that `p` is prime. - long _fmpz_mod_poly_gcd_euclidean_f(fmpz_t f, fmpz *G, const fmpz *A, long lenA, const fmpz *B, long lenB, const fmpz_mod_ctx_t ctx) + slong _fmpz_mod_poly_gcd_euclidean_f(fmpz_t f, fmpz *G, const fmpz *A, slong lenA, const fmpz *B, slong lenB, const fmpz_mod_ctx_t ctx) # Either sets `f = 1` and `G` to the greatest common divisor # of `(A, \operatorname{len}(A))` and `(B, \operatorname{len}(B))` and returns its length, # or sets `f \in (1,p)` to a non-trivial factor of `p` and @@ -713,7 +713,7 @@ cdef extern from "flint_wrap.h": # ring `(\mathbf{Z}/(p \mathbf{Z}))[X]` if and only if `p` is a prime # number. - long _fmpz_mod_poly_gcd_f(fmpz_t f, fmpz *G, const fmpz *A, long lenA, const fmpz *B, long lenB, const fmpz_mod_ctx_t ctx) + slong _fmpz_mod_poly_gcd_f(fmpz_t f, fmpz *G, const fmpz *A, slong lenA, const fmpz *B, slong lenB, const fmpz_mod_ctx_t ctx) # Either sets `f = 1` and `G` to the greatest common divisor # of `(A, \operatorname{len}(A))` and `(B, \operatorname{len}(B))` and returns its length, # or sets `f \in (1,p)` to a non-trivial factor of `p` and @@ -730,7 +730,7 @@ cdef extern from "flint_wrap.h": # ring `(\mathbf{Z}/(p \mathbf{Z}))[X]` if and only if `p` is a prime # number. - long _fmpz_mod_poly_hgcd(fmpz **M, long *lenM, fmpz *A, long *lenA, fmpz *B, long *lenB, const fmpz *a, long lena, const fmpz *b, long lenb, const fmpz_mod_ctx_t ctx) + slong _fmpz_mod_poly_hgcd(fmpz **M, slong *lenM, fmpz *A, slong *lenA, fmpz *B, slong *lenB, const fmpz *a, slong lena, const fmpz *b, slong lenb, const fmpz_mod_ctx_t ctx) # Computes the HGCD of `a` and `b`, that is, a matrix~`M`, a sign~`\sigma` # and two polynomials `A` and `B` such that # .. math :: @@ -742,7 +742,7 @@ cdef extern from "flint_wrap.h": # Assumes that ``M[0]``, ``M[1]``, ``M[2]``, and ``M[3]`` # each point to a vector of size at least `\operatorname{len}(a)`. - long _fmpz_mod_poly_xgcd_euclidean_f(fmpz_t f, fmpz *G, fmpz *S, fmpz *T, const fmpz *A, long lenA, const fmpz *B, long lenB, const fmpz_t invB, const fmpz_mod_ctx_t ctx) + slong _fmpz_mod_poly_xgcd_euclidean_f(fmpz_t f, fmpz *G, fmpz *S, fmpz *T, const fmpz *A, slong lenA, const fmpz *B, slong lenB, const fmpz_t invB, const fmpz_mod_ctx_t ctx) # If `f` returns with the value `1` then the function operates as per # ``_fmpz_mod_poly_xgcd_euclidean``, otherwise `f` is set to a nontrivial # factor of `p`. @@ -752,7 +752,7 @@ cdef extern from "flint_wrap.h": # ``fmpz_mod_poly_xgcd_euclidean``, otherwise `f` is set to a nontrivial # factor of `p`. - long _fmpz_mod_poly_xgcd(fmpz *G, fmpz *S, fmpz *T, const fmpz *A, long lenA, const fmpz *B, long lenB, const fmpz_t invB, const fmpz_mod_ctx_t ctx) + slong _fmpz_mod_poly_xgcd(fmpz *G, fmpz *S, fmpz *T, const fmpz *A, slong lenA, const fmpz *B, slong lenB, const fmpz_t invB, const fmpz_mod_ctx_t ctx) # Computes the GCD of `A` and `B` together with cofactors `S` and `T` # such that `S A + T B = G`. Returns the length of `G`. # Assumes that `\operatorname{len}(A) \geq \operatorname{len}(B) \geq 1` and @@ -778,7 +778,7 @@ cdef extern from "flint_wrap.h": # ``fmpz_mod_poly_xgcd``, otherwise `f` is set to a nontrivial # factor of `p`. - long _fmpz_mod_poly_gcdinv_euclidean(fmpz *G, fmpz *S, const fmpz *A, long lenA, const fmpz *B, long lenB, const fmpz_t invA, const fmpz_mod_ctx_t ctx) + slong _fmpz_mod_poly_gcdinv_euclidean(fmpz *G, fmpz *S, const fmpz *A, slong lenA, const fmpz *B, slong lenB, const fmpz_t invA, const fmpz_mod_ctx_t ctx) # Computes ``(G, lenA)``, ``(S, lenB-1)`` such that # `G \cong S A \pmod{B}`, returning the actual length of `G`. # Assumes that `0 < \operatorname{len}(A) < \operatorname{len}(B)`. @@ -789,7 +789,7 @@ cdef extern from "flint_wrap.h": # have `\operatorname{len}(B) \geq 2`. # In the case that `A = 0 \pmod{B}`, returns `G = S = 0`. - long _fmpz_mod_poly_gcdinv_euclidean_f(fmpz_t f, fmpz *G, fmpz *S, const fmpz *A, long lenA, const fmpz *B, long lenB, const fmpz_t invA, const fmpz_mod_ctx_t ctx) + slong _fmpz_mod_poly_gcdinv_euclidean_f(fmpz_t f, fmpz *G, fmpz *S, const fmpz *A, slong lenA, const fmpz *B, slong lenB, const fmpz_t invA, const fmpz_mod_ctx_t ctx) # If `f` returns with value `1` then the function operates as per # :func:`_fmpz_mod_poly_gcdinv_euclidean`, otherwise `f` is set to a # nontrivial factor of `p`. @@ -799,12 +799,12 @@ cdef extern from "flint_wrap.h": # :func:`fmpz_mod_poly_gcdinv_euclidean`, otherwise `f` is set to a # nontrivial factor of the modulus of `A`. - long _fmpz_mod_poly_gcdinv(fmpz *G, fmpz *S, const fmpz *A, long lenA, const fmpz *B, long lenB, const fmpz_mod_ctx_t ctx) + slong _fmpz_mod_poly_gcdinv(fmpz *G, fmpz *S, const fmpz *A, slong lenA, const fmpz *B, slong lenB, const fmpz_mod_ctx_t ctx) # Computes ``(G, lenA)``, ``(S, lenB-1)`` such that # `G \cong S A \pmod{B}`, returning the actual length of `G`. # Assumes that `0 < \operatorname{len}(A) < \operatorname{len}(B)`. - long _fmpz_mod_poly_gcdinv_f(fmpz_t f, fmpz *G, fmpz *S, const fmpz *A, long lenA, const fmpz *B, long lenB, const fmpz_mod_ctx_t ctx) + slong _fmpz_mod_poly_gcdinv_f(fmpz_t f, fmpz *G, fmpz *S, const fmpz *A, slong lenA, const fmpz *B, slong lenB, const fmpz_mod_ctx_t ctx) # If `f` returns with value `1` then the function operates as per # :func:`_fmpz_mod_poly_gcdinv`, otherwise `f` will be set to a nontrivial # factor of `p`. @@ -820,7 +820,7 @@ cdef extern from "flint_wrap.h": # :func:`fmpz_mod_poly_gcdinv`, otherwise `f` will be set to a nontrivial # factor of `p`. - int _fmpz_mod_poly_invmod(fmpz *A, const fmpz *B, long lenB, const fmpz *P, long lenP, const fmpz_mod_ctx_t ctx) + int _fmpz_mod_poly_invmod(fmpz *A, const fmpz *B, slong lenB, const fmpz *P, slong lenP, const fmpz_mod_ctx_t ctx) # Attempts to set ``(A, lenP-1)`` to the inverse of ``(B, lenB)`` # modulo the polynomial ``(P, lenP)``. Returns `1` if ``(B, lenB)`` # is invertible and `0` otherwise. @@ -829,7 +829,7 @@ cdef extern from "flint_wrap.h": # Does not support aliasing. # Assumes that `p` is a prime number. - int _fmpz_mod_poly_invmod_f(fmpz_t f, fmpz *A, const fmpz *B, long lenB, const fmpz *P, long lenP, const fmpz_mod_ctx_t ctx) + int _fmpz_mod_poly_invmod_f(fmpz_t f, fmpz *A, const fmpz *B, slong lenB, const fmpz *P, slong lenP, const fmpz_mod_ctx_t ctx) # If `f` returns with the value `1`, then the function operates as per # :func:`_fmpz_mod_poly_invmod`. Otherwise `f` is set to a nontrivial # factor of `p`. @@ -848,7 +848,7 @@ cdef extern from "flint_wrap.h": # :func:`fmpz_mod_poly_invmod`. Otherwise `f` is set to a nontrivial # factor of `p`. - long _fmpz_mod_poly_minpoly_bm(fmpz* poly, const fmpz* seq, long len, const fmpz_mod_ctx_t ctx) + slong _fmpz_mod_poly_minpoly_bm(fmpz* poly, const fmpz* seq, slong len, const fmpz_mod_ctx_t ctx) # Sets ``poly`` to the coefficients of a minimal generating # polynomial for sequence ``(seq, len)`` modulo `p`. # The return value equals the length of ``poly``. @@ -856,14 +856,14 @@ cdef extern from "flint_wrap.h": # `len+1` coefficients. No aliasing between inputs and outputs is # allowed. - void fmpz_mod_poly_minpoly_bm(fmpz_mod_poly_t poly, const fmpz* seq, long len, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_minpoly_bm(fmpz_mod_poly_t poly, const fmpz* seq, slong len, const fmpz_mod_ctx_t ctx) # Sets ``poly`` to a minimal generating polynomial for sequence # ``seq`` of length ``len``. # Assumes that the modulus is prime. # This version uses the Berlekamp-Massey algorithm, whose running time # is proportional to ``len`` times the size of the minimal generator. - long _fmpz_mod_poly_minpoly_hgcd(fmpz* poly, const fmpz* seq, long len, const fmpz_mod_ctx_t ctx) + slong _fmpz_mod_poly_minpoly_hgcd(fmpz* poly, const fmpz* seq, slong len, const fmpz_mod_ctx_t ctx) # Sets ``poly`` to the coefficients of a minimal generating # polynomial for sequence ``(seq, len)`` modulo `p`. # The return value equals the length of ``poly``. @@ -871,7 +871,7 @@ cdef extern from "flint_wrap.h": # `len+1` coefficients. No aliasing between inputs and outputs is # allowed. - void fmpz_mod_poly_minpoly_hgcd(fmpz_mod_poly_t poly, const fmpz* seq, long len, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_minpoly_hgcd(fmpz_mod_poly_t poly, const fmpz* seq, slong len, const fmpz_mod_ctx_t ctx) # Sets ``poly`` to a minimal generating polynomial for sequence # ``seq`` of length ``len``. # Assumes that the modulus is prime. @@ -879,7 +879,7 @@ cdef extern from "flint_wrap.h": # `O(n \log^2 n)` field operations, regardless of the actual size of # the minimal generator. - long _fmpz_mod_poly_minpoly(fmpz* poly, const fmpz* seq, long len, const fmpz_mod_ctx_t ctx) + slong _fmpz_mod_poly_minpoly(fmpz* poly, const fmpz* seq, slong len, const fmpz_mod_ctx_t ctx) # Sets ``poly`` to the coefficients of a minimal generating # polynomial for sequence ``(seq, len)`` modulo `p`. # The return value equals the length of ``poly``. @@ -887,7 +887,7 @@ cdef extern from "flint_wrap.h": # `len+1` coefficients. No aliasing between inputs and outputs is # allowed. - void fmpz_mod_poly_minpoly(fmpz_mod_poly_t poly, const fmpz* seq, long len, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_minpoly(fmpz_mod_poly_t poly, const fmpz* seq, slong len, const fmpz_mod_ctx_t ctx) # Sets ``poly`` to a minimal generating polynomial for sequence # ``seq`` of length ``len``. # A minimal generating polynomial is a monic polynomial @@ -899,7 +899,7 @@ cdef extern from "flint_wrap.h": # This version automatically chooses the fastest underlying # implementation based on ``len`` and the size of the modulus. - void _fmpz_mod_poly_resultant_euclidean(fmpz_t res, const fmpz *poly1, long len1, const fmpz *poly2, long len2, const fmpz_mod_ctx_t ctx) + void _fmpz_mod_poly_resultant_euclidean(fmpz_t res, const fmpz *poly1, slong len1, const fmpz *poly2, slong len2, const fmpz_mod_ctx_t ctx) # Sets `r` to the resultant of ``(poly1, len1)`` and # ``(poly2, len2)`` using the Euclidean algorithm. # Assumes that ``len1 >= len2 > 0``. @@ -915,7 +915,7 @@ cdef extern from "flint_wrap.h": # For convenience, we define the resultant to be equal to zero if either # of the two polynomials is zero. - void _fmpz_mod_poly_resultant_hgcd(fmpz_t res, const fmpz *A, long lenA, const fmpz *B, long lenB, const fmpz_mod_ctx_t ctx) + void _fmpz_mod_poly_resultant_hgcd(fmpz_t res, const fmpz *A, slong lenA, const fmpz *B, slong lenB, const fmpz_mod_ctx_t ctx) # Sets ``res`` to the resultant of ``(A, lenA)`` and # ``(B, lenB)`` using the half-gcd algorithm. # This algorithm computes the half-gcd as per @@ -956,7 +956,7 @@ cdef extern from "flint_wrap.h": # For convenience, we define the resultant to be equal to zero if either # of the two polynomials is zero. - void _fmpz_mod_poly_resultant(fmpz_t res, const fmpz *poly1, long len1, const fmpz *poly2, long len2, const fmpz_mod_ctx_t ctx) + void _fmpz_mod_poly_resultant(fmpz_t res, const fmpz *poly1, slong len1, const fmpz *poly2, slong len2, const fmpz_mod_ctx_t ctx) # Returns the resultant of ``(poly1, len1)`` and # ``(poly2, len2)``. # Assumes that ``len1 >= len2 > 0``. @@ -972,7 +972,7 @@ cdef extern from "flint_wrap.h": # For convenience, we define the resultant to be equal to zero if either # of the two polynomials is zero. - void _fmpz_mod_poly_discriminant(fmpz_t d, const fmpz *poly, long len, const fmpz_mod_ctx_t ctx) + void _fmpz_mod_poly_discriminant(fmpz_t d, const fmpz *poly, slong len, const fmpz_mod_ctx_t ctx) # Set `d` to the discriminant of ``(poly, len)``. Assumes ``len > 1``. void fmpz_mod_poly_discriminant(fmpz_t d, const fmpz_mod_poly_t f, const fmpz_mod_ctx_t ctx) @@ -985,7 +985,7 @@ cdef extern from "flint_wrap.h": # `\operatorname{lc}(f)` is the leading coefficient of `f` and `r_i` are the # roots of `f`. - void _fmpz_mod_poly_derivative(fmpz *res, const fmpz *poly, long len, const fmpz_mod_ctx_t ctx) + void _fmpz_mod_poly_derivative(fmpz *res, const fmpz *poly, slong len, const fmpz_mod_ctx_t ctx) # Sets ``(res, len - 1)`` to the derivative of ``(poly, len)``. # Also handles the cases where ``len`` is `0` or `1` correctly. # Supports aliasing of ``res`` and ``poly``. @@ -993,7 +993,7 @@ cdef extern from "flint_wrap.h": void fmpz_mod_poly_derivative(fmpz_mod_poly_t res, const fmpz_mod_poly_t poly, const fmpz_mod_ctx_t ctx) # Sets ``res`` to the derivative of ``poly``. - void _fmpz_mod_poly_evaluate_fmpz(fmpz_t res, const fmpz *poly, long len, const fmpz_t a, const fmpz_mod_ctx_t ctx) + void _fmpz_mod_poly_evaluate_fmpz(fmpz_t res, const fmpz *poly, slong len, const fmpz_t a, const fmpz_mod_ctx_t ctx) # Evaluates the polynomial ``(poly, len)`` at the integer `a` and sets # ``res`` to the result. Aliasing between ``res`` and `a` or any # of the coefficients of ``poly`` is not supported. @@ -1004,47 +1004,47 @@ cdef extern from "flint_wrap.h": # As expected, aliasing between ``res`` and `a` is supported. However, # ``res`` may not be aliased with a coefficient of ``poly``. - void _fmpz_mod_poly_evaluate_fmpz_vec_iter(fmpz * ys, const fmpz * coeffs, long len, const fmpz * xs, long n, const fmpz_mod_ctx_t ctx) + void _fmpz_mod_poly_evaluate_fmpz_vec_iter(fmpz * ys, const fmpz * coeffs, slong len, const fmpz * xs, slong n, const fmpz_mod_ctx_t ctx) # Evaluates (``coeffs``, ``len``) at the ``n`` values # given in the vector ``xs``, writing the output values # to ``ys``. The values in ``xs`` should be reduced # modulo the modulus. # Uses Horner's method iteratively. - void fmpz_mod_poly_evaluate_fmpz_vec_iter(fmpz * ys, const fmpz_mod_poly_t poly, const fmpz * xs, long n, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_evaluate_fmpz_vec_iter(fmpz * ys, const fmpz_mod_poly_t poly, const fmpz * xs, slong n, const fmpz_mod_ctx_t ctx) # Evaluates ``poly`` at the ``n`` values given in the vector # ``xs``, writing the output values to ``ys``. The values in # ``xs`` should be reduced modulo the modulus. # Uses Horner's method iteratively. - void _fmpz_mod_poly_evaluate_fmpz_vec_fast_precomp(fmpz * vs, const fmpz * poly, long plen, fmpz_poly_struct * const * tree, long len, const fmpz_mod_ctx_t ctx) + void _fmpz_mod_poly_evaluate_fmpz_vec_fast_precomp(fmpz * vs, const fmpz * poly, slong plen, fmpz_poly_struct * const * tree, slong len, const fmpz_mod_ctx_t ctx) # Evaluates (``poly``, ``plen``) at the ``len`` values given by the precomputed subproduct tree ``tree``. - void _fmpz_mod_poly_evaluate_fmpz_vec_fast(fmpz * ys, const fmpz * poly, long plen, const fmpz * xs, long n, const fmpz_mod_ctx_t ctx) + void _fmpz_mod_poly_evaluate_fmpz_vec_fast(fmpz * ys, const fmpz * poly, slong plen, const fmpz * xs, slong n, const fmpz_mod_ctx_t ctx) # Evaluates (``coeffs``, ``len``) at the ``n`` values # given in the vector ``xs``, writing the output values # to ``ys``. The values in ``xs`` should be reduced # modulo the modulus. # Uses fast multipoint evaluation, building a temporary subproduct tree. - void fmpz_mod_poly_evaluate_fmpz_vec_fast(fmpz * ys, const fmpz_mod_poly_t poly, const fmpz * xs, long n, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_evaluate_fmpz_vec_fast(fmpz * ys, const fmpz_mod_poly_t poly, const fmpz * xs, slong n, const fmpz_mod_ctx_t ctx) # Evaluates ``poly`` at the ``n`` values given in the vector # ``xs``, writing the output values to ``ys``. The values in # ``xs`` should be reduced modulo the modulus. # Uses fast multipoint evaluation, building a temporary subproduct tree. - void _fmpz_mod_poly_evaluate_fmpz_vec(fmpz * ys, const fmpz * coeffs, long len, const fmpz * xs, long n, const fmpz_mod_ctx_t ctx) + void _fmpz_mod_poly_evaluate_fmpz_vec(fmpz * ys, const fmpz * coeffs, slong len, const fmpz * xs, slong n, const fmpz_mod_ctx_t ctx) # Evaluates (``coeffs``, ``len``) at the ``n`` values # given in the vector ``xs``, writing the output values # to ``ys``. The values in ``xs`` should be reduced # modulo the modulus. - void fmpz_mod_poly_evaluate_fmpz_vec(fmpz * ys, const fmpz_mod_poly_t poly, const fmpz * xs, long n, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_evaluate_fmpz_vec(fmpz * ys, const fmpz_mod_poly_t poly, const fmpz * xs, slong n, const fmpz_mod_ctx_t ctx) # Evaluates ``poly`` at the ``n`` values given in the vector # ``xs``, writing the output values to ``ys``. The values in # ``xs`` should be reduced modulo the modulus. - void _fmpz_mod_poly_compose(fmpz *res, const fmpz *poly1, long len1, const fmpz *poly2, long len2, const fmpz_mod_ctx_t ctx) + void _fmpz_mod_poly_compose(fmpz *res, const fmpz *poly1, slong len1, const fmpz *poly2, slong len2, const fmpz_mod_ctx_t ctx) # Sets ``res`` to the composition of ``(poly1, len1)`` and # ``(poly2, len2)``. # Assumes that ``res`` has space for ``(len1-1)*(len2-1) + 1`` @@ -1059,23 +1059,23 @@ cdef extern from "flint_wrap.h": # ``poly1``, and ``poly2`` by `f`, `g`, and `h`, respectively, # sets `f(t) = g(h(t))`. - void _fmpz_mod_poly_invsqrt_series(fmpz * g, const fmpz * h, long hlen, long n, const fmpz_mod_ctx_t ctx) + void _fmpz_mod_poly_invsqrt_series(fmpz * g, const fmpz * h, slong hlen, slong n, const fmpz_mod_ctx_t ctx) # Set the first `n` terms of `g` to the series expansion of `1/\sqrt{h}`. # It is assumed that `n > 0` and `h > 0`. Aliasing is not permitted. - void fmpz_mod_poly_invsqrt_series(fmpz_mod_poly_t g, const fmpz_mod_poly_t h, long n, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_invsqrt_series(fmpz_mod_poly_t g, const fmpz_mod_poly_t h, slong n, const fmpz_mod_ctx_t ctx) # Set `g` to the series expansion of `1/\sqrt{h}` to order `O(x^n)`. # It is assumed that `h` has constant term 1. - void _fmpz_mod_poly_sqrt_series(fmpz * g, const fmpz * h, long hlen, long n, const fmpz_mod_ctx_t ctx) + void _fmpz_mod_poly_sqrt_series(fmpz * g, const fmpz * h, slong hlen, slong n, const fmpz_mod_ctx_t ctx) # Set the first `n` terms of `g` to the series expansion of `\sqrt{h}`. # It is assumed that `n > 0` and `h > 0`. Aliasing is not permitted. - void fmpz_mod_poly_sqrt_series(fmpz_mod_poly_t g, const fmpz_mod_poly_t h, long n, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_sqrt_series(fmpz_mod_poly_t g, const fmpz_mod_poly_t h, slong n, const fmpz_mod_ctx_t ctx) # Set `g` to the series expansion of `\sqrt{h}` to order `O(x^n)`. # It is assumed that `h` has constant term 1. - int _fmpz_mod_poly_sqrt(fmpz * s, const fmpz * p, long n, const fmpz_mod_ctx_t ctx) + int _fmpz_mod_poly_sqrt(fmpz * s, const fmpz * p, slong n, const fmpz_mod_ctx_t ctx) # If ``(p, n)`` is a perfect square, sets ``(s, n / 2 + 1)`` # to a square root of `p` and returns 1. Otherwise returns 0. @@ -1083,7 +1083,7 @@ cdef extern from "flint_wrap.h": # If `p` is a perfect square, sets `s` to a square root of `p` # and returns 1. Otherwise returns 0. - void _fmpz_mod_poly_compose_mod(fmpz * res, const fmpz * f, long lenf, const fmpz * g, const fmpz * h, long lenh, const fmpz_mod_ctx_t ctx) + void _fmpz_mod_poly_compose_mod(fmpz * res, const fmpz * f, slong lenf, const fmpz * g, const fmpz * h, slong lenh, const fmpz_mod_ctx_t ctx) # Sets ``res`` to the composition `f(g)` modulo `h`. We require that # `h` is nonzero and that the length of `g` is one less than the # length of `h` (possibly with zero padding). The output is not allowed @@ -1093,7 +1093,7 @@ cdef extern from "flint_wrap.h": # Sets ``res`` to the composition `f(g)` modulo `h`. We require that # `h` is nonzero. - void _fmpz_mod_poly_compose_mod_horner(fmpz * res, const fmpz * f, long lenf, const fmpz * g, const fmpz * h, long lenh, const fmpz_mod_ctx_t ctx) + void _fmpz_mod_poly_compose_mod_horner(fmpz * res, const fmpz * f, slong lenf, const fmpz * g, const fmpz * h, slong lenh, const fmpz_mod_ctx_t ctx) # Sets ``res`` to the composition `f(g)` modulo `h`. We require that # `h` is nonzero and that the length of `g` is one less than the # length of `h` (possibly with zero padding). The output is not allowed @@ -1104,7 +1104,7 @@ cdef extern from "flint_wrap.h": # Sets ``res`` to the composition `f(g)` modulo `h`. We require that # `h` is nonzero. The algorithm used is Horner's rule. - void _fmpz_mod_poly_compose_mod_brent_kung(fmpz * res, const fmpz * f, long len1, const fmpz * g, const fmpz * h, long len3, const fmpz_mod_ctx_t ctx) + void _fmpz_mod_poly_compose_mod_brent_kung(fmpz * res, const fmpz * f, slong len1, const fmpz * g, const fmpz * h, slong len3, const fmpz_mod_ctx_t ctx) # Sets ``res`` to the composition `f(g)` modulo `h`. We require that # `h` is nonzero and that the length of `g` is one less than the # length of `h` (possibly with zero padding). We also require that @@ -1126,7 +1126,7 @@ cdef extern from "flint_wrap.h": # Worker function version of ``_fmpz_mod_poly_precompute_matrix``. # Input/output is stored in ``fmpz_mod_poly_matrix_precompute_arg_t``. - void _fmpz_mod_poly_precompute_matrix (fmpz_mat_t A, const fmpz * f, const fmpz * g, long leng, const fmpz * ginv, long lenginv, const fmpz_mod_ctx_t ctx) + void _fmpz_mod_poly_precompute_matrix (fmpz_mat_t A, const fmpz * f, const fmpz * g, slong leng, const fmpz * ginv, slong lenginv, const fmpz_mod_ctx_t ctx) # Sets the ith row of ``A`` to `f^i` modulo `g` for # `i=1,\ldots,\sqrt{\deg(g)}`. We require `A` to be # a `\sqrt{\deg(g)}\times \deg(g)` matrix. We require @@ -1146,7 +1146,7 @@ cdef extern from "flint_wrap.h": # Input/output is stored in # ``fmpz_mod_poly_compose_mod_precomp_preinv_arg_t``. - void _fmpz_mod_poly_compose_mod_brent_kung_precomp_preinv(fmpz * res, const fmpz * f, long lenf, const fmpz_mat_t A, const fmpz * h, long lenh, const fmpz * hinv, long lenhinv, const fmpz_mod_ctx_t ctx) + void _fmpz_mod_poly_compose_mod_brent_kung_precomp_preinv(fmpz * res, const fmpz * f, slong lenf, const fmpz_mat_t A, const fmpz * h, slong lenh, const fmpz * hinv, slong lenhinv, const fmpz_mod_ctx_t ctx) # Sets ``res`` to the composition `f(g)` modulo `h`. We require that # `h` is nonzero. We require that the ith row of `A` contains `g^i` for # `i=1,\ldots,\sqrt{\deg(h)}`, i.e. `A` is a @@ -1165,7 +1165,7 @@ cdef extern from "flint_wrap.h": # modular composition is particularly useful if one has to perform several # modular composition of the form `f(g)` modulo `h` for fixed `g` and `h`. - void _fmpz_mod_poly_compose_mod_brent_kung_preinv(fmpz * res, const fmpz * f, long lenf, const fmpz * g, const fmpz * h, long lenh, const fmpz * hinv, long lenhinv, const fmpz_mod_ctx_t ctx) + void _fmpz_mod_poly_compose_mod_brent_kung_preinv(fmpz * res, const fmpz * f, slong lenf, const fmpz * g, const fmpz * h, slong lenh, const fmpz * hinv, slong lenhinv, const fmpz_mod_ctx_t ctx) # Sets ``res`` to the composition `f(g)` modulo `h`. We require that # `h` is nonzero and that the length of `g` is one less than the # length of `h` (possibly with zero padding). We also require that @@ -1180,7 +1180,7 @@ cdef extern from "flint_wrap.h": # we require ``hinv`` to be the inverse of the reverse of ``h``. # The algorithm used is the Brent-Kung matrix algorithm. - void _fmpz_mod_poly_compose_mod_brent_kung_vec_preinv(fmpz_mod_poly_struct * res, const fmpz_mod_poly_struct * polys, long len1, long l, const fmpz * g, long glen, const fmpz * h, long lenh, const fmpz * hinv, long lenhinv, const fmpz_mod_ctx_t ctx) + void _fmpz_mod_poly_compose_mod_brent_kung_vec_preinv(fmpz_mod_poly_struct * res, const fmpz_mod_poly_struct * polys, slong len1, slong l, const fmpz * g, slong glen, const fmpz * h, slong lenh, const fmpz * hinv, slong lenhinv, const fmpz_mod_ctx_t ctx) # Sets ``res`` to the composition `f_i(g)` modulo `h` for `1\leq i \leq l`, # where `f_i` are the ``l`` elements of ``polys``. We require that `h` is # nonzero and that the length of `g` is less than the length of `h`. We @@ -1192,7 +1192,7 @@ cdef extern from "flint_wrap.h": # aliased with any of the inputs. # The algorithm used is the Brent-Kung matrix algorithm. - void fmpz_mod_poly_compose_mod_brent_kung_vec_preinv(fmpz_mod_poly_struct * res, const fmpz_mod_poly_struct * polys, long len1, long n, const fmpz_mod_poly_t g, const fmpz_mod_poly_t h, const fmpz_mod_poly_t hinv, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_compose_mod_brent_kung_vec_preinv(fmpz_mod_poly_struct * res, const fmpz_mod_poly_struct * polys, slong len1, slong n, const fmpz_mod_poly_t g, const fmpz_mod_poly_t h, const fmpz_mod_poly_t hinv, const fmpz_mod_ctx_t ctx) # Sets ``res`` to the composition `f_i(g)` modulo `h` for `1\leq i \leq n` # where `f_i` are the ``n`` elements of ``polys``. We require ``res`` to # have enough memory allocated to hold ``n`` ``fmpz_mod_poly_struct``'s. @@ -1203,34 +1203,34 @@ cdef extern from "flint_wrap.h": # ``polys`` is allowed. # The algorithm used is the Brent-Kung matrix algorithm. - void _fmpz_mod_poly_compose_mod_brent_kung_vec_preinv_threaded_pool(fmpz_mod_poly_struct * res, const fmpz_mod_poly_struct * polys, long lenpolys, long l, const fmpz * g, long glen, const fmpz * poly, long len, const fmpz * polyinv, long leninv, const fmpz_mod_ctx_t ctx, thread_pool_handle * threads, long num_threads) + void _fmpz_mod_poly_compose_mod_brent_kung_vec_preinv_threaded_pool(fmpz_mod_poly_struct * res, const fmpz_mod_poly_struct * polys, slong lenpolys, slong l, const fmpz * g, slong glen, const fmpz * poly, slong len, const fmpz * polyinv, slong leninv, const fmpz_mod_ctx_t ctx, thread_pool_handle * threads, slong num_threads) # Multithreaded version of # :func:`_fmpz_mod_poly_compose_mod_brent_kung_vec_preinv`. Distributing the # Horner evaluations across :func:`flint_get_num_threads` threads. - void fmpz_mod_poly_compose_mod_brent_kung_vec_preinv_threaded_pool(fmpz_mod_poly_struct * res, const fmpz_mod_poly_struct * polys, long len1, long n, const fmpz_mod_poly_t g, const fmpz_mod_poly_t poly, const fmpz_mod_poly_t polyinv, const fmpz_mod_ctx_t ctx, thread_pool_handle * threads, long num_threads) + void fmpz_mod_poly_compose_mod_brent_kung_vec_preinv_threaded_pool(fmpz_mod_poly_struct * res, const fmpz_mod_poly_struct * polys, slong len1, slong n, const fmpz_mod_poly_t g, const fmpz_mod_poly_t poly, const fmpz_mod_poly_t polyinv, const fmpz_mod_ctx_t ctx, thread_pool_handle * threads, slong num_threads) # Multithreaded version of # :func:`fmpz_mod_poly_compose_mod_brent_kung_vec_preinv`. Distributing the # Horner evaluations across :func:`flint_get_num_threads` threads. - void fmpz_mod_poly_compose_mod_brent_kung_vec_preinv_threaded(fmpz_mod_poly_struct * res, const fmpz_mod_poly_struct * polys, long len1, long n, const fmpz_mod_poly_t g, const fmpz_mod_poly_t poly, const fmpz_mod_poly_t polyinv, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_compose_mod_brent_kung_vec_preinv_threaded(fmpz_mod_poly_struct * res, const fmpz_mod_poly_struct * polys, slong len1, slong n, const fmpz_mod_poly_t g, const fmpz_mod_poly_t poly, const fmpz_mod_poly_t polyinv, const fmpz_mod_ctx_t ctx) # Multithreaded version of # :func:`fmpz_mod_poly_compose_mod_brent_kung_vec_preinv`. Distributing the # Horner evaluations across :func:`flint_get_num_threads` threads. - fmpz_poly_struct ** _fmpz_mod_poly_tree_alloc(long len) + fmpz_poly_struct ** _fmpz_mod_poly_tree_alloc(slong len) # Allocates space for a subproduct tree of the given length, having # linear factors at the lowest level. - void _fmpz_mod_poly_tree_free(fmpz_poly_struct ** tree, long len) + void _fmpz_mod_poly_tree_free(fmpz_poly_struct ** tree, slong len) # Free the allocated space for the subproduct. - void _fmpz_mod_poly_tree_build(fmpz_poly_struct ** tree, const fmpz * roots, long len, const fmpz_mod_ctx_t ctx) + void _fmpz_mod_poly_tree_build(fmpz_poly_struct ** tree, const fmpz * roots, slong len, const fmpz_mod_ctx_t ctx) # Builds a subproduct tree in the preallocated space from # the ``len`` monic linear factors `(x-r_i)` where `r_i` are given by # ``roots``. The top level product is not computed. - void _fmpz_mod_poly_radix_init(fmpz **Rpow, fmpz **Rinv, const fmpz *R, long lenR, long k, const fmpz_t invL, const fmpz_mod_ctx_t ctx) + void _fmpz_mod_poly_radix_init(fmpz **Rpow, fmpz **Rinv, const fmpz *R, slong lenR, slong k, const fmpz_t invL, const fmpz_mod_ctx_t ctx) # Computes powers of `R` of the form `R^{2^i}` and their Newton inverses # modulo `x^{2^{i} \deg(R)}` for `i = 0, \dotsc, k-1`. # Assumes that the vectors ``Rpow[i]`` and ``Rinv[i]`` have space @@ -1244,13 +1244,13 @@ cdef extern from "flint_wrap.h": # Note that this precomputed data can be used for any `F` such that # `\operatorname{len}(F) \leq 2^k \deg(R)`. - void fmpz_mod_poly_radix_init(fmpz_mod_poly_radix_t D, const fmpz_mod_poly_t R, long degF, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_radix_init(fmpz_mod_poly_radix_t D, const fmpz_mod_poly_t R, slong degF, const fmpz_mod_ctx_t ctx) # Carries out the precomputation necessary to perform radix conversion # to radix~`R` for polynomials~`F` of degree at most ``degF``. # Assumes that `R` is non-constant, i.e. `\deg(R) \geq 1`, # and that the leading coefficient is a unit. - void _fmpz_mod_poly_radix(fmpz **B, const fmpz *F, fmpz **Rpow, fmpz **Rinv, long degR, long k, long i, fmpz *W, const fmpz_mod_ctx_t ctx) + void _fmpz_mod_poly_radix(fmpz **B, const fmpz *F, fmpz **Rpow, fmpz **Rinv, slong degR, slong k, slong i, fmpz *W, const fmpz_mod_ctx_t ctx) # This is the main recursive function used by the # function :func:`fmpz_mod_poly_radix`. # Assumes that, for all `i = 0, \dotsc, N`, the vector @@ -1276,7 +1276,7 @@ cdef extern from "flint_wrap.h": # Assumes that `R` is non-constant, i.e.\ `\deg(R) \geq 1`, # and that the leading coefficient is a unit. - int _fmpz_mod_poly_fprint(FILE * file, const fmpz *poly, long len, const fmpz_t p) + int _fmpz_mod_poly_fprint(FILE * file, const fmpz *poly, slong len, const fmpz_t p) # Prints the polynomial ``(poly, len)`` to the stream ``file``. # In case of success, returns a positive value. In case of failure, # returns a non-positive value. @@ -1303,16 +1303,16 @@ cdef extern from "flint_wrap.h": # In case of success, returns a positive value. In case of failure, # returns a non-positive value. - void fmpz_mod_poly_inflate(fmpz_mod_poly_t result, const fmpz_mod_poly_t input, unsigned long inflation, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_inflate(fmpz_mod_poly_t result, const fmpz_mod_poly_t input, ulong inflation, const fmpz_mod_ctx_t ctx) # Sets ``result`` to the inflated polynomial `p(x^n)` where # `p` is given by ``input`` and `n` is given by ``inflation``. - void fmpz_mod_poly_deflate(fmpz_mod_poly_t result, const fmpz_mod_poly_t input, unsigned long deflation, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_deflate(fmpz_mod_poly_t result, const fmpz_mod_poly_t input, ulong deflation, const fmpz_mod_ctx_t ctx) # Sets ``result`` to the deflated polynomial `p(x^{1/n})` where # `p` is given by ``input`` and `n` is given by ``deflation``. # Requires `n > 0`. - unsigned long fmpz_mod_poly_deflation(const fmpz_mod_poly_t input, const fmpz_mod_ctx_t ctx) + ulong fmpz_mod_poly_deflation(const fmpz_mod_poly_t input, const fmpz_mod_ctx_t ctx) # Returns the largest integer by which ``input`` can be deflated. # As special cases, returns 0 if ``input`` is the zero polynomial # and 1 of ``input`` is a constant polynomial. @@ -1326,8 +1326,8 @@ cdef extern from "flint_wrap.h": void fmpz_mod_berlekamp_massey_start_over(fmpz_mod_berlekamp_massey_t B, const fmpz_mod_ctx_t ctx) # Empty the stream of points in ``B``. - void fmpz_mod_berlekamp_massey_add_points(fmpz_mod_berlekamp_massey_t B, const fmpz * a, long count, const fmpz_mod_ctx_t ctx) - void fmpz_mod_berlekamp_massey_add_zeros(fmpz_mod_berlekamp_massey_t B, long count, const fmpz_mod_ctx_t ctx) + void fmpz_mod_berlekamp_massey_add_points(fmpz_mod_berlekamp_massey_t B, const fmpz * a, slong count, const fmpz_mod_ctx_t ctx) + void fmpz_mod_berlekamp_massey_add_zeros(fmpz_mod_berlekamp_massey_t B, slong count, const fmpz_mod_ctx_t ctx) void fmpz_mod_berlekamp_massey_add_point(fmpz_mod_berlekamp_massey_t B, const fmpz_t a, const fmpz_mod_ctx_t ctx) # Add point(s) to the stream processed by ``B``. The addition of any number of points will not update the `V` and `R` polynomial. @@ -1336,7 +1336,7 @@ cdef extern from "flint_wrap.h": # For example, if this function is called twice in a row without adding any points in between, the return of the second call should be ``0``. # As another example, suppose the object is emptied, the points `1, 1, 2, 3` are added, then reduce is called. This reduce should return ``1`` with `\deg(R) < \deg(V) = 2` because the Fibonacci sequence has been recognized. The further addition of the two points `5, 8` and a reduce will result in a return value of ``0``. - long fmpz_mod_berlekamp_massey_point_count(const fmpz_mod_berlekamp_massey_t B) + slong fmpz_mod_berlekamp_massey_point_count(const fmpz_mod_berlekamp_massey_t B) # Return the number of points stored in ``B``. const fmpz * fmpz_mod_berlekamp_massey_points(const fmpz_mod_berlekamp_massey_t B) diff --git a/src/sage/libs/flint/fmpz_mod_poly_factor.pxd b/src/sage/libs/flint/fmpz_mod_poly_factor.pxd index 8101ad69ebc..a99ebf607f1 100644 --- a/src/sage/libs/flint/fmpz_mod_poly_factor.pxd +++ b/src/sage/libs/flint/fmpz_mod_poly_factor.pxd @@ -18,11 +18,11 @@ cdef extern from "flint_wrap.h": void fmpz_mod_poly_factor_clear(fmpz_mod_poly_factor_t fac, const fmpz_mod_ctx_t ctx) # Frees all memory associated with ``fac``. - void fmpz_mod_poly_factor_realloc(fmpz_mod_poly_factor_t fac, long alloc, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_factor_realloc(fmpz_mod_poly_factor_t fac, slong alloc, const fmpz_mod_ctx_t ctx) # Reallocates the factor structure to provide space for # precisely ``alloc`` factors. - void fmpz_mod_poly_factor_fit_length(fmpz_mod_poly_factor_t fac, long len, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_factor_fit_length(fmpz_mod_poly_factor_t fac, slong len, const fmpz_mod_ctx_t ctx) # Ensures that the factor structure has space for at # least ``len`` factors. This function takes care # of the case of repeated calls by always at least @@ -34,7 +34,7 @@ cdef extern from "flint_wrap.h": void fmpz_mod_poly_factor_print(const fmpz_mod_poly_factor_t fac, const fmpz_mod_ctx_t ctx) # Prints the entries of ``fac`` to standard output. - void fmpz_mod_poly_factor_insert(fmpz_mod_poly_factor_t fac, const fmpz_mod_poly_t poly, long exp, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_factor_insert(fmpz_mod_poly_factor_t fac, const fmpz_mod_poly_t poly, slong exp, const fmpz_mod_ctx_t ctx) # Inserts the factor ``poly`` with multiplicity ``exp`` into # the factorisation ``fac``. # If ``fac`` already contains ``poly``, then ``exp`` simply @@ -46,7 +46,7 @@ cdef extern from "flint_wrap.h": # repeatedly with the individual factors of ``fac``. # Does not support aliasing between ``res`` and ``fac``. - void fmpz_mod_poly_factor_pow(fmpz_mod_poly_factor_t fac, long exp, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_factor_pow(fmpz_mod_poly_factor_t fac, slong exp, const fmpz_mod_ctx_t ctx) # Raises ``fac`` to the power ``exp``. int fmpz_mod_poly_is_irreducible(const fmpz_mod_poly_t f, const fmpz_mod_ctx_t ctx) @@ -68,12 +68,12 @@ cdef extern from "flint_wrap.h": # `\mathbb{Z}/p\mathbb{Z}`, even for composite `f`, or it finds a factor # of `p`. - int _fmpz_mod_poly_is_squarefree(const fmpz * f, long len, const fmpz_mod_ctx_t ctx) + int _fmpz_mod_poly_is_squarefree(const fmpz * f, slong len, const fmpz_mod_ctx_t ctx) # Returns 1 if ``(f, len)`` is squarefree, and 0 otherwise. As a # special case, the zero polynomial is not considered squarefree. # There are no restrictions on the length. - int _fmpz_mod_poly_is_squarefree_f(fmpz_t fac, const fmpz * f, long len, const fmpz_mod_ctx_t ctx) + int _fmpz_mod_poly_is_squarefree_f(fmpz_t fac, const fmpz * f, slong len, const fmpz_mod_ctx_t ctx) # If `fac` returns with the value `1` then the function operates as per # :func:`_fmpz_mod_poly_is_squarefree`, otherwise `f` is set to a nontrivial # factor of `p`. @@ -87,19 +87,19 @@ cdef extern from "flint_wrap.h": # :func:`fmpz_mod_poly_is_squarefree`, otherwise `f` is set to a nontrivial # factor of `p`. - int fmpz_mod_poly_factor_equal_deg_prob(fmpz_mod_poly_t factor, flint_rand_t state, const fmpz_mod_poly_t pol, long d, const fmpz_mod_ctx_t ctx) + int fmpz_mod_poly_factor_equal_deg_prob(fmpz_mod_poly_t factor, flint_rand_t state, const fmpz_mod_poly_t pol, slong d, const fmpz_mod_ctx_t ctx) # Probabilistic equal degree factorisation of ``pol`` into # irreducible factors of degree ``d``. If it passes, a factor is # placed in ``factor`` and 1 is returned, otherwise 0 is returned and # the value of factor is undetermined. # Requires that ``pol`` be monic, non-constant and squarefree. - void fmpz_mod_poly_factor_equal_deg(fmpz_mod_poly_factor_t factors, const fmpz_mod_poly_t pol, long d, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_factor_equal_deg(fmpz_mod_poly_factor_t factors, const fmpz_mod_poly_t pol, slong d, const fmpz_mod_ctx_t ctx) # Assuming ``pol`` is a product of irreducible factors all of # degree ``d``, finds all those factors and places them in factors. # Requires that ``pol`` be monic, non-constant and squarefree. - void fmpz_mod_poly_factor_distinct_deg(fmpz_mod_poly_factor_t res, const fmpz_mod_poly_t poly, long * const *degs, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_factor_distinct_deg(fmpz_mod_poly_factor_t res, const fmpz_mod_poly_t poly, slong * const *degs, const fmpz_mod_ctx_t ctx) # Factorises a monic non-constant squarefree polynomial ``poly`` # of degree `n` into factors `f[d]` such that for `1 \leq d \leq n` # `f[d]` is the product of the monic irreducible factors of ``poly`` @@ -108,7 +108,7 @@ cdef extern from "flint_wrap.h": # as the factors. # Requires that ``degs`` has enough space for `(n/2)+1 * sizeof(slong)`. - void fmpz_mod_poly_factor_distinct_deg_threaded(fmpz_mod_poly_factor_t res, const fmpz_mod_poly_t poly, long * const *degs, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_factor_distinct_deg_threaded(fmpz_mod_poly_factor_t res, const fmpz_mod_poly_t poly, slong * const *degs, const fmpz_mod_ctx_t ctx) # Multithreaded version of :func:`fmpz_mod_poly_factor_distinct_deg`. void fmpz_mod_poly_factor_squarefree(fmpz_mod_poly_factor_t res, const fmpz_mod_poly_t f, const fmpz_mod_ctx_t ctx) diff --git a/src/sage/libs/flint/fmpz_mod_vec.pxd b/src/sage/libs/flint/fmpz_mod_vec.pxd index 990b9d60c90..09cd74004e2 100644 --- a/src/sage/libs/flint/fmpz_mod_vec.pxd +++ b/src/sage/libs/flint/fmpz_mod_vec.pxd @@ -12,33 +12,33 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void _fmpz_mod_vec_set_fmpz_vec(fmpz * A, const fmpz * B, long len, const fmpz_mod_ctx_t ctx) + void _fmpz_mod_vec_set_fmpz_vec(fmpz * A, const fmpz * B, slong len, const fmpz_mod_ctx_t ctx) # Set the `fmpz_mod_vec` `(A, len)` to the `fmpz_vec` `(B, len)` after # reduction of each entry modulo the modulus.. - void _fmpz_mod_vec_neg(fmpz * A, const fmpz * B, long len, const fmpz_mod_ctx_t ctx) + void _fmpz_mod_vec_neg(fmpz * A, const fmpz * B, slong len, const fmpz_mod_ctx_t ctx) # Set `(A, len)` to `-(B, len)`. - void _fmpz_mod_vec_add(fmpz * a, const fmpz * b, const fmpz * c, long n, const fmpz_mod_ctx_t ctx) + void _fmpz_mod_vec_add(fmpz * a, const fmpz * b, const fmpz * c, slong n, const fmpz_mod_ctx_t ctx) # Set (A, len)` to `(B, len) + (C, len)`. - void _fmpz_mod_vec_sub(fmpz * a, const fmpz * b, const fmpz * c, long n, const fmpz_mod_ctx_t ctx) + void _fmpz_mod_vec_sub(fmpz * a, const fmpz * b, const fmpz * c, slong n, const fmpz_mod_ctx_t ctx) # Set (A, len)` to `(B, len) - (C, len)`. - void _fmpz_mod_vec_scalar_mul_fmpz_mod(fmpz * A, const fmpz * B, long len, const fmpz_t c, const fmpz_mod_ctx_t ctx) + void _fmpz_mod_vec_scalar_mul_fmpz_mod(fmpz * A, const fmpz * B, slong len, const fmpz_t c, const fmpz_mod_ctx_t ctx) # Set `(A, len)` to `(B, len)*c`. - void _fmpz_mod_vec_scalar_addmul_fmpz_mod(fmpz * A, const fmpz * B, long len, const fmpz_t c, const fmpz_mod_ctx_t ctx) + void _fmpz_mod_vec_scalar_addmul_fmpz_mod(fmpz * A, const fmpz * B, slong len, const fmpz_t c, const fmpz_mod_ctx_t ctx) # Set `(A, len)` to `(A, len) + (B, len)*c`. - void _fmpz_mod_vec_scalar_div_fmpz_mod(fmpz * A, const fmpz * B, long len, const fmpz_t c, const fmpz_mod_ctx_t ctx) + void _fmpz_mod_vec_scalar_div_fmpz_mod(fmpz * A, const fmpz * B, slong len, const fmpz_t c, const fmpz_mod_ctx_t ctx) # Set `(A, len)` to `(B, len)/c` assuming `c` is nonzero. - void _fmpz_mod_vec_dot(fmpz_t d, const fmpz * A, const fmpz * B, long len, const fmpz_mod_ctx_t ctx) + void _fmpz_mod_vec_dot(fmpz_t d, const fmpz * A, const fmpz * B, slong len, const fmpz_mod_ctx_t ctx) # Set `d` to the dot product of `(A, len)` with `(B, len)`. - void _fmpz_mod_vec_dot_rev(fmpz_t d, const fmpz * A, const fmpz * B, long len, const fmpz_mod_ctx_t ctx) + void _fmpz_mod_vec_dot_rev(fmpz_t d, const fmpz * A, const fmpz * B, slong len, const fmpz_mod_ctx_t ctx) # Set `d` to the dot product of `(A, len)` with the reverse of the vector `(B, len)`. - void _fmpz_mod_vec_mul(fmpz * A, const fmpz * B, const fmpz * C, long len, const fmpz_mod_ctx_t ctx) + void _fmpz_mod_vec_mul(fmpz * A, const fmpz * B, const fmpz * C, slong len, const fmpz_mod_ctx_t ctx) # Set `(A, len)` the pointwise multiplication of `(B, len)` and `(C, len)`. diff --git a/src/sage/libs/flint/fmpz_mpoly.pxd b/src/sage/libs/flint/fmpz_mpoly.pxd index 2db76877bb5..61cd5f2e1cb 100644 --- a/src/sage/libs/flint/fmpz_mpoly.pxd +++ b/src/sage/libs/flint/fmpz_mpoly.pxd @@ -12,11 +12,11 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void fmpz_mpoly_ctx_init(fmpz_mpoly_ctx_t ctx, long nvars, const ordering_t ord) + void fmpz_mpoly_ctx_init(fmpz_mpoly_ctx_t ctx, slong nvars, const ordering_t ord) # Initialise a context object for a polynomial ring with the given number of variables and the given ordering. # The possibilities for the ordering are ``ORD_LEX``, ``ORD_DEGLEX`` and ``ORD_DEGREVLEX``. - long fmpz_mpoly_ctx_nvars(const fmpz_mpoly_ctx_t ctx) + slong fmpz_mpoly_ctx_nvars(const fmpz_mpoly_ctx_t ctx) # Return the number of variables used to initialize the context. ordering_t fmpz_mpoly_ctx_ord(const fmpz_mpoly_ctx_t ctx) @@ -28,21 +28,21 @@ cdef extern from "flint_wrap.h": void fmpz_mpoly_init(fmpz_mpoly_t A, const fmpz_mpoly_ctx_t ctx) # Initialise *A* for use with the given and initialised context object. Its value is set to zero. - void fmpz_mpoly_init2(fmpz_mpoly_t A, long alloc, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_init2(fmpz_mpoly_t A, slong alloc, const fmpz_mpoly_ctx_t ctx) # Initialise *A* for use with the given and initialised context object. Its value is set to zero. # It is allocated with space for *alloc* terms and at least ``MPOLY_MIN_BITS`` bits for the exponents. - void fmpz_mpoly_init3(fmpz_mpoly_t A, long alloc, flint_bitcnt_t bits, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_init3(fmpz_mpoly_t A, slong alloc, flint_bitcnt_t bits, const fmpz_mpoly_ctx_t ctx) # Initialise *A* for use with the given and initialised context object. Its value is set to zero. # It is allocated with space for *alloc* terms and *bits* bits for the exponents. - void fmpz_mpoly_fit_length(fmpz_mpoly_t A, long len, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_fit_length(fmpz_mpoly_t A, slong len, const fmpz_mpoly_ctx_t ctx) # Ensure that *A* has space for at least *len* terms. void fmpz_mpoly_fit_bits(fmpz_mpoly_t A, flint_bitcnt_t bits, const fmpz_mpoly_ctx_t ctx) # Ensure that the exponent fields of *A* have at least *bits* bits. - void fmpz_mpoly_realloc(fmpz_mpoly_t A, long alloc, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_realloc(fmpz_mpoly_t A, slong alloc, const fmpz_mpoly_ctx_t ctx) # Reallocate *A* to have space for *alloc* terms. # Assumes the current length of the polynomial is not greater than *alloc*. @@ -64,10 +64,10 @@ cdef extern from "flint_wrap.h": # The operations ``+``, ``-``, ``*``, and ``/`` are permitted along with integers and the variables in *x*. The character ``^`` must be immediately followed by the (integer) exponent. # If any division is not exact, parsing fails. - void fmpz_mpoly_gen(fmpz_mpoly_t A, long var, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_gen(fmpz_mpoly_t A, slong var, const fmpz_mpoly_ctx_t ctx) # Set *A* to the variable of index *var*, where `var = 0` corresponds to the variable with the most significance with respect to the ordering. - int fmpz_mpoly_is_gen(const fmpz_mpoly_t A, long var, const fmpz_mpoly_ctx_t ctx) + int fmpz_mpoly_is_gen(const fmpz_mpoly_t A, slong var, const fmpz_mpoly_ctx_t ctx) # If `var \ge 0`, return `1` if *A* is equal to the `var`-th generator, otherwise return `0`. # If `var < 0`, return `1` if the polynomial is equal to any generator, otherwise return `0`. @@ -80,12 +80,12 @@ cdef extern from "flint_wrap.h": void fmpz_mpoly_swap(fmpz_mpoly_t poly1, fmpz_mpoly_t poly2, const fmpz_mpoly_ctx_t ctx) # Efficiently swap *A* and *B*. - int _fmpz_mpoly_fits_small(const fmpz * poly, long len) + int _fmpz_mpoly_fits_small(const fmpz * poly, slong len) # Return 1 if the array of coefficients of length *len* consists # entirely of values that are small ``fmpz`` values, i.e. of at most # ``FLINT_BITS - 2`` bits plus a sign bit. - long fmpz_mpoly_max_bits(const fmpz_mpoly_t A) + slong fmpz_mpoly_max_bits(const fmpz_mpoly_t A) # Computes the maximum number of bits `b` required to represent the absolute # values of the coefficients of *A*. If all of the coefficients are # positive, `b` is returned, otherwise `-b` is returned. @@ -98,8 +98,8 @@ cdef extern from "flint_wrap.h": # This function throws if *A* is not a constant. void fmpz_mpoly_set_fmpz(fmpz_mpoly_t A, const fmpz_t c, const fmpz_mpoly_ctx_t ctx) - void fmpz_mpoly_set_ui(fmpz_mpoly_t A, unsigned long c, const fmpz_mpoly_ctx_t ctx) - void fmpz_mpoly_set_si(fmpz_mpoly_t A, long c, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_set_ui(fmpz_mpoly_t A, ulong c, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_set_si(fmpz_mpoly_t A, slong c, const fmpz_mpoly_ctx_t ctx) # Set *A* to the constant *c*. void fmpz_mpoly_zero(fmpz_mpoly_t A, const fmpz_mpoly_ctx_t ctx) @@ -109,8 +109,8 @@ cdef extern from "flint_wrap.h": # Set *A* to the constant `1`. int fmpz_mpoly_equal_fmpz(const fmpz_mpoly_t A, const fmpz_t c, const fmpz_mpoly_ctx_t ctx) - int fmpz_mpoly_equal_ui(const fmpz_mpoly_t A, unsigned long c, const fmpz_mpoly_ctx_t ctx) - int fmpz_mpoly_equal_si(const fmpz_mpoly_t A, long c, const fmpz_mpoly_ctx_t ctx) + int fmpz_mpoly_equal_ui(const fmpz_mpoly_t A, ulong c, const fmpz_mpoly_ctx_t ctx) + int fmpz_mpoly_equal_si(const fmpz_mpoly_t A, slong c, const fmpz_mpoly_ctx_t ctx) # Return `1` if *A* is equal to the constant *c*, else return `0`. int fmpz_mpoly_is_zero(const fmpz_mpoly_t A, const fmpz_mpoly_ctx_t ctx) @@ -123,12 +123,12 @@ cdef extern from "flint_wrap.h": # Return `1` if the degrees of *A* with respect to each variable fit into an ``slong``, otherwise return `0`. void fmpz_mpoly_degrees_fmpz(fmpz ** degs, const fmpz_mpoly_t A, const fmpz_mpoly_ctx_t ctx) - void fmpz_mpoly_degrees_si(long * degs, const fmpz_mpoly_t A, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_degrees_si(slong * degs, const fmpz_mpoly_t A, const fmpz_mpoly_ctx_t ctx) # Set *degs* to the degrees of *A* with respect to each variable. # If *A* is zero, all degrees are set to `-1`. - void fmpz_mpoly_degree_fmpz(fmpz_t deg, const fmpz_mpoly_t A, long var, const fmpz_mpoly_ctx_t ctx) - long fmpz_mpoly_degree_si(const fmpz_mpoly_t A, long var, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_degree_fmpz(fmpz_t deg, const fmpz_mpoly_t A, slong var, const fmpz_mpoly_ctx_t ctx) + slong fmpz_mpoly_degree_si(const fmpz_mpoly_t A, slong var, const fmpz_mpoly_ctx_t ctx) # Either return or set *deg* to the degree of *A* with respect to the variable of index *var*. # If *A* is zero, the degree is defined to be `-1`. @@ -136,7 +136,7 @@ cdef extern from "flint_wrap.h": # Return `1` if the total degree of *A* fits into an ``slong``, otherwise return `0`. void fmpz_mpoly_total_degree_fmpz(fmpz_t tdeg, const fmpz_mpoly_t A, const fmpz_mpoly_ctx_t ctx) - long fmpz_mpoly_total_degree_si(const fmpz_mpoly_t A, const fmpz_mpoly_ctx_t ctx) + slong fmpz_mpoly_total_degree_si(const fmpz_mpoly_t A, const fmpz_mpoly_ctx_t ctx) # Either return or set *tdeg* to the total degree of *A*. # If *A* is zero, the total degree is defined to be `-1`. @@ -152,22 +152,22 @@ cdef extern from "flint_wrap.h": # This function throws if *M* is not a monomial. void fmpz_mpoly_get_coeff_fmpz_fmpz(fmpz_t c, const fmpz_mpoly_t A, fmpz * const * exp, const fmpz_mpoly_ctx_t ctx) - unsigned long fmpz_mpoly_get_coeff_ui_fmpz(const fmpz_mpoly_t A, fmpz * const * exp, const fmpz_mpoly_ctx_t ctx) - long fmpz_mpoly_get_coeff_si_fmpz(const fmpz_mpoly_t A, fmpz * const * exp, const fmpz_mpoly_ctx_t ctx) - void fmpz_mpoly_get_coeff_fmpz_ui(fmpz_t c, const fmpz_mpoly_t A, const unsigned long * exp, const fmpz_mpoly_ctx_t ctx) - unsigned long fmpz_mpoly_get_coeff_ui_ui(const fmpz_mpoly_t A, const unsigned long * exp, const fmpz_mpoly_ctx_t ctx) - long fmpz_mpoly_get_coeff_si_ui(const fmpz_mpoly_t A, const unsigned long * exp, const fmpz_mpoly_ctx_t ctx) + ulong fmpz_mpoly_get_coeff_ui_fmpz(const fmpz_mpoly_t A, fmpz * const * exp, const fmpz_mpoly_ctx_t ctx) + slong fmpz_mpoly_get_coeff_si_fmpz(const fmpz_mpoly_t A, fmpz * const * exp, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_get_coeff_fmpz_ui(fmpz_t c, const fmpz_mpoly_t A, const ulong * exp, const fmpz_mpoly_ctx_t ctx) + ulong fmpz_mpoly_get_coeff_ui_ui(const fmpz_mpoly_t A, const ulong * exp, const fmpz_mpoly_ctx_t ctx) + slong fmpz_mpoly_get_coeff_si_ui(const fmpz_mpoly_t A, const ulong * exp, const fmpz_mpoly_ctx_t ctx) # Either return or set *c* to the coefficient of the monomial with exponent vector *exp*. void fmpz_mpoly_set_coeff_fmpz_fmpz(fmpz_mpoly_t A, const fmpz_t c, fmpz * const * exp, const fmpz_mpoly_ctx_t ctx) - void fmpz_mpoly_set_coeff_ui_fmpz(fmpz_mpoly_t A, unsigned long c, fmpz * const * exp, const fmpz_mpoly_ctx_t ctx) - void fmpz_mpoly_set_coeff_si_fmpz(fmpz_mpoly_t A, long c, fmpz * const * exp, const fmpz_mpoly_ctx_t ctx) - void fmpz_mpoly_set_coeff_fmpz_ui(fmpz_mpoly_t A, const fmpz_t c, const unsigned long * exp, const fmpz_mpoly_ctx_t ctx) - void fmpz_mpoly_set_coeff_ui_ui(fmpz_mpoly_t A, unsigned long c, const unsigned long * exp, const fmpz_mpoly_ctx_t ctx) - void fmpz_mpoly_set_coeff_si_ui(fmpz_mpoly_t A, long c, const unsigned long * exp, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_set_coeff_ui_fmpz(fmpz_mpoly_t A, ulong c, fmpz * const * exp, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_set_coeff_si_fmpz(fmpz_mpoly_t A, slong c, fmpz * const * exp, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_set_coeff_fmpz_ui(fmpz_mpoly_t A, const fmpz_t c, const ulong * exp, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_set_coeff_ui_ui(fmpz_mpoly_t A, ulong c, const ulong * exp, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_set_coeff_si_ui(fmpz_mpoly_t A, slong c, const ulong * exp, const fmpz_mpoly_ctx_t ctx) # Set the coefficient of the monomial with exponent vector *exp* to *c*. - void fmpz_mpoly_get_coeff_vars_ui(fmpz_mpoly_t C, const fmpz_mpoly_t A, const long * vars, const unsigned long * exps, long length, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_get_coeff_vars_ui(fmpz_mpoly_t C, const fmpz_mpoly_t A, const slong * vars, const ulong * exps, slong length, const fmpz_mpoly_ctx_t ctx) # Set *C* to the coefficient of *A* with respect to the variables in *vars* with powers in the corresponding array *exps*. # Both *vars* and *exps* point to array of length *length*. It is assumed that `0 < length \le nvars(A)` and that the variables in *vars* are distinct. @@ -175,76 +175,76 @@ cdef extern from "flint_wrap.h": # Return `1` (resp. `-1`, or `0`) if *A* is after (resp. before, same as) *B* in some arbitrary but fixed total ordering of the polynomials. # This ordering agrees with the usual ordering of monomials when *A* and *B* are both monomials. - int fmpz_mpoly_is_fmpz_poly(const fmpz_mpoly_t A, long var, const fmpz_mpoly_ctx_t ctx) + int fmpz_mpoly_is_fmpz_poly(const fmpz_mpoly_t A, slong var, const fmpz_mpoly_ctx_t ctx) # Return whether *A* is a univariate polynomial in the variable with index *var*. - int fmpz_mpoly_get_fmpz_poly(fmpz_poly_t A, const fmpz_mpoly_t B, long var, const fmpz_mpoly_ctx_t ctx) + int fmpz_mpoly_get_fmpz_poly(fmpz_poly_t A, const fmpz_mpoly_t B, slong var, const fmpz_mpoly_ctx_t ctx) # If *B* is a univariate polynomial in the variable with index *var*, # set *A* to this polynomial and return 1; otherwise return 0. - void fmpz_mpoly_set_fmpz_poly(fmpz_mpoly_t A, const fmpz_poly_t B, long var, const fmpz_mpoly_ctx_t ctx) - void fmpz_mpoly_set_gen_fmpz_poly(fmpz_mpoly_t A, long var, const fmpz_poly_t B, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_set_fmpz_poly(fmpz_mpoly_t A, const fmpz_poly_t B, slong var, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_set_gen_fmpz_poly(fmpz_mpoly_t A, slong var, const fmpz_poly_t B, const fmpz_mpoly_ctx_t ctx) # Set *A* to the univariate polynomial *B* in the variable with index *var*. - fmpz * fmpz_mpoly_term_coeff_ref(fmpz_mpoly_t A, long i, const fmpz_mpoly_ctx_t ctx) + fmpz * fmpz_mpoly_term_coeff_ref(fmpz_mpoly_t A, slong i, const fmpz_mpoly_ctx_t ctx) # Return a reference to the coefficient of index *i* of *A*. int fmpz_mpoly_is_canonical(const fmpz_mpoly_t A, const fmpz_mpoly_ctx_t ctx) # Return `1` if *A* is in canonical form. Otherwise, return `0`. # To be in canonical form, all of the terms must have nonzero coefficient, and the terms must be sorted from greatest to least. - long fmpz_mpoly_length(const fmpz_mpoly_t A, const fmpz_mpoly_ctx_t ctx) + slong fmpz_mpoly_length(const fmpz_mpoly_t A, const fmpz_mpoly_ctx_t ctx) # Return the number of terms in *A*. # If the polynomial is in canonical form, this will be the number of nonzero coefficients. - void fmpz_mpoly_resize(fmpz_mpoly_t A, long new_length, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_resize(fmpz_mpoly_t A, slong new_length, const fmpz_mpoly_ctx_t ctx) # Set the length of *A* to `new\_length`. # Terms are either deleted from the end, or new zero terms are appended. - void fmpz_mpoly_get_term_coeff_fmpz(fmpz_t c, const fmpz_mpoly_t A, long i, const fmpz_mpoly_ctx_t ctx) - unsigned long fmpz_mpoly_get_term_coeff_ui(const fmpz_mpoly_t A, long i, const fmpz_mpoly_ctx_t ctx) - long fmpz_mpoly_get_term_coeff_si(const fmpz_mpoly_t poly, long i, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_get_term_coeff_fmpz(fmpz_t c, const fmpz_mpoly_t A, slong i, const fmpz_mpoly_ctx_t ctx) + ulong fmpz_mpoly_get_term_coeff_ui(const fmpz_mpoly_t A, slong i, const fmpz_mpoly_ctx_t ctx) + slong fmpz_mpoly_get_term_coeff_si(const fmpz_mpoly_t poly, slong i, const fmpz_mpoly_ctx_t ctx) # Either return or set *c* to the coefficient of the term of index *i*. - void fmpz_mpoly_set_term_coeff_fmpz(fmpz_mpoly_t A, long i, const fmpz_t c, const fmpz_mpoly_ctx_t ctx) - void fmpz_mpoly_set_term_coeff_ui(fmpz_mpoly_t A, long i, unsigned long c, const fmpz_mpoly_ctx_t ctx) - void fmpz_mpoly_set_term_coeff_si(fmpz_mpoly_t A, long i, long c, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_set_term_coeff_fmpz(fmpz_mpoly_t A, slong i, const fmpz_t c, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_set_term_coeff_ui(fmpz_mpoly_t A, slong i, ulong c, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_set_term_coeff_si(fmpz_mpoly_t A, slong i, slong c, const fmpz_mpoly_ctx_t ctx) # Set the coefficient of the term of index *i* to *c*. - int fmpz_mpoly_term_exp_fits_si(const fmpz_mpoly_t poly, long i, const fmpz_mpoly_ctx_t ctx) - int fmpz_mpoly_term_exp_fits_ui(const fmpz_mpoly_t poly, long i, const fmpz_mpoly_ctx_t ctx) + int fmpz_mpoly_term_exp_fits_si(const fmpz_mpoly_t poly, slong i, const fmpz_mpoly_ctx_t ctx) + int fmpz_mpoly_term_exp_fits_ui(const fmpz_mpoly_t poly, slong i, const fmpz_mpoly_ctx_t ctx) # Return `1` if all entries of the exponent vector of the term of index *i* fit into an ``slong`` (resp. a ``ulong``). Otherwise, return `0`. - void fmpz_mpoly_get_term_exp_fmpz(fmpz ** exp, const fmpz_mpoly_t A, long i, const fmpz_mpoly_ctx_t ctx) - void fmpz_mpoly_get_term_exp_ui(unsigned long * exp, const fmpz_mpoly_t A, long i, const fmpz_mpoly_ctx_t ctx) - void fmpz_mpoly_get_term_exp_si(long * exp, const fmpz_mpoly_t A, long i, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_get_term_exp_fmpz(fmpz ** exp, const fmpz_mpoly_t A, slong i, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_get_term_exp_ui(ulong * exp, const fmpz_mpoly_t A, slong i, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_get_term_exp_si(slong * exp, const fmpz_mpoly_t A, slong i, const fmpz_mpoly_ctx_t ctx) # Set *exp* to the exponent vector of the term of index *i*. # The ``_ui`` (resp. ``_si``) version throws if any entry does not fit into a ``ulong`` (resp. ``slong``). - unsigned long fmpz_mpoly_get_term_var_exp_ui(const fmpz_mpoly_t A, long i, long var, const fmpz_mpoly_ctx_t ctx) - long fmpz_mpoly_get_term_var_exp_si(const fmpz_mpoly_t A, long i, long var, const fmpz_mpoly_ctx_t ctx) + ulong fmpz_mpoly_get_term_var_exp_ui(const fmpz_mpoly_t A, slong i, slong var, const fmpz_mpoly_ctx_t ctx) + slong fmpz_mpoly_get_term_var_exp_si(const fmpz_mpoly_t A, slong i, slong var, const fmpz_mpoly_ctx_t ctx) # Return the exponent of the variable `var` of the term of index *i*. # This function throws if the exponent does not fit into a ``ulong`` (resp. ``slong``). - void fmpz_mpoly_set_term_exp_fmpz(fmpz_mpoly_t A, long i, fmpz * const * exp, const fmpz_mpoly_ctx_t ctx) - void fmpz_mpoly_set_term_exp_ui(fmpz_mpoly_t A, long i, const unsigned long * exp, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_set_term_exp_fmpz(fmpz_mpoly_t A, slong i, fmpz * const * exp, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_set_term_exp_ui(fmpz_mpoly_t A, slong i, const ulong * exp, const fmpz_mpoly_ctx_t ctx) # Set the exponent vector of the term of index *i* to *exp*. - void fmpz_mpoly_get_term(fmpz_mpoly_t M, const fmpz_mpoly_t A, long i, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_get_term(fmpz_mpoly_t M, const fmpz_mpoly_t A, slong i, const fmpz_mpoly_ctx_t ctx) # Set `M` to the term of index *i* in *A*. - void fmpz_mpoly_get_term_monomial(fmpz_mpoly_t M, const fmpz_mpoly_t A, long i, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_get_term_monomial(fmpz_mpoly_t M, const fmpz_mpoly_t A, slong i, const fmpz_mpoly_ctx_t ctx) # Set `M` to the monomial of the term of index *i* in *A*. The coefficient of `M` will be one. void fmpz_mpoly_push_term_fmpz_fmpz(fmpz_mpoly_t A, const fmpz_t c, fmpz * const * exp, const fmpz_mpoly_ctx_t ctx) void fmpz_mpoly_push_term_fmpz_ffmpz(fmpz_mpoly_t A, const fmpz_t c, const fmpz * exp, const fmpz_mpoly_ctx_t ctx) - void fmpz_mpoly_push_term_ui_fmpz(fmpz_mpoly_t A, unsigned long c, fmpz * const * exp, const fmpz_mpoly_ctx_t ctx) - void fmpz_mpoly_push_term_ui_ffmpz(fmpz_mpoly_t A, unsigned long c, const fmpz * exp, const fmpz_mpoly_ctx_t ctx) - void fmpz_mpoly_push_term_si_fmpz(fmpz_mpoly_t A, long c, fmpz * const * exp, const fmpz_mpoly_ctx_t ctx) - void fmpz_mpoly_push_term_si_ffmpz(fmpz_mpoly_t A, long c, const fmpz * exp, const fmpz_mpoly_ctx_t ctx) - void fmpz_mpoly_push_term_fmpz_ui(fmpz_mpoly_t A, const fmpz_t c, const unsigned long * exp, const fmpz_mpoly_ctx_t ctx) - void fmpz_mpoly_push_term_ui_ui(fmpz_mpoly_t A, unsigned long c, const unsigned long * exp, const fmpz_mpoly_ctx_t ctx) - void fmpz_mpoly_push_term_si_ui(fmpz_mpoly_t A, long c, const unsigned long * exp, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_push_term_ui_fmpz(fmpz_mpoly_t A, ulong c, fmpz * const * exp, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_push_term_ui_ffmpz(fmpz_mpoly_t A, ulong c, const fmpz * exp, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_push_term_si_fmpz(fmpz_mpoly_t A, slong c, fmpz * const * exp, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_push_term_si_ffmpz(fmpz_mpoly_t A, slong c, const fmpz * exp, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_push_term_fmpz_ui(fmpz_mpoly_t A, const fmpz_t c, const ulong * exp, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_push_term_ui_ui(fmpz_mpoly_t A, ulong c, const ulong * exp, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_push_term_si_ui(fmpz_mpoly_t A, slong c, const ulong * exp, const fmpz_mpoly_ctx_t ctx) # Append a term to *A* with coefficient *c* and exponent vector *exp*. # This function runs in constant average time. @@ -261,28 +261,28 @@ cdef extern from "flint_wrap.h": void fmpz_mpoly_reverse(fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_mpoly_ctx_t ctx) # Set *A* to the reversal of *B*. - void fmpz_mpoly_randtest_bound(fmpz_mpoly_t A, flint_rand_t state, long length, mp_limb_t coeff_bits, unsigned long exp_bound, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_randtest_bound(fmpz_mpoly_t A, flint_rand_t state, slong length, mp_limb_t coeff_bits, ulong exp_bound, const fmpz_mpoly_ctx_t ctx) # Generate a random polynomial with length up to *length* and exponents in the range ``[0, exp_bound - 1]``. # The exponents of each variable are generated by calls to ``n_randint(state, exp_bound)``. - void fmpz_mpoly_randtest_bounds(fmpz_mpoly_t A, flint_rand_t state, long length, mp_limb_t coeff_bits, unsigned long * exp_bounds, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_randtest_bounds(fmpz_mpoly_t A, flint_rand_t state, slong length, mp_limb_t coeff_bits, ulong * exp_bounds, const fmpz_mpoly_ctx_t ctx) # Generate a random polynomial with length up to *length* and exponents in the range ``[0, exp_bounds[i] - 1]``. # The exponents of the variable of index *i* are generated by calls to ``n_randint(state, exp_bounds[i])``. - void fmpz_mpoly_randtest_bits(fmpz_mpoly_t A, flint_rand_t state, long length, mp_limb_t coeff_bits, mp_limb_t exp_bits, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_randtest_bits(fmpz_mpoly_t A, flint_rand_t state, slong length, mp_limb_t coeff_bits, mp_limb_t exp_bits, const fmpz_mpoly_ctx_t ctx) # Generate a random polynomial with length up to the given length and exponents whose packed form does not exceed the given bit count. # The parameter ``coeff_bits`` to the three functions ``fmpz_mpoly_randtest_{bound|bounds|bits}`` is merely a suggestion for the approximate bit count of the resulting signed coefficients. # The function :func:`fmpz_mpoly_max_bits` will give the exact bit count of the result. void fmpz_mpoly_add_fmpz(fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_t c, const fmpz_mpoly_ctx_t ctx) - void fmpz_mpoly_add_ui(fmpz_mpoly_t A, const fmpz_mpoly_t B, unsigned long c, const fmpz_mpoly_ctx_t ctx) - void fmpz_mpoly_add_si(fmpz_mpoly_t A, const fmpz_mpoly_t B, long c, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_add_ui(fmpz_mpoly_t A, const fmpz_mpoly_t B, ulong c, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_add_si(fmpz_mpoly_t A, const fmpz_mpoly_t B, slong c, const fmpz_mpoly_ctx_t ctx) # Set *A* to `B + c`. # If *A* and *B* are aliased, this function will probably run quickly. void fmpz_mpoly_sub_fmpz(fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_t c, const fmpz_mpoly_ctx_t ctx) - void fmpz_mpoly_sub_ui(fmpz_mpoly_t A, const fmpz_mpoly_t B, unsigned long c, const fmpz_mpoly_ctx_t ctx) - void fmpz_mpoly_sub_si(fmpz_mpoly_t A, const fmpz_mpoly_t B, long c, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_sub_ui(fmpz_mpoly_t A, const fmpz_mpoly_t B, ulong c, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_sub_si(fmpz_mpoly_t A, const fmpz_mpoly_t B, slong c, const fmpz_mpoly_ctx_t ctx) # Set *A* to `B - c`. # If *A* and *B* are aliased, this function will probably run quickly. @@ -298,34 +298,34 @@ cdef extern from "flint_wrap.h": # Set *A* to `-B`. void fmpz_mpoly_scalar_mul_fmpz(fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_t c, const fmpz_mpoly_ctx_t ctx) - void fmpz_mpoly_scalar_mul_ui(fmpz_mpoly_t A, const fmpz_mpoly_t B, unsigned long c, const fmpz_mpoly_ctx_t ctx) - void fmpz_mpoly_scalar_mul_si(fmpz_mpoly_t A, const fmpz_mpoly_t B, long c, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_scalar_mul_ui(fmpz_mpoly_t A, const fmpz_mpoly_t B, ulong c, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_scalar_mul_si(fmpz_mpoly_t A, const fmpz_mpoly_t B, slong c, const fmpz_mpoly_ctx_t ctx) # Set *A* to `B \times c`. void fmpz_mpoly_scalar_fmma(fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_t c, const fmpz_mpoly_t D, const fmpz_t e, const fmpz_mpoly_ctx_t ctx) # Sets *A* to `B \times c + D \times e`. void fmpz_mpoly_scalar_divexact_fmpz(fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_t c, const fmpz_mpoly_ctx_t ctx) - void fmpz_mpoly_scalar_divexact_ui(fmpz_mpoly_t A, const fmpz_mpoly_t B, unsigned long c, const fmpz_mpoly_ctx_t ctx) - void fmpz_mpoly_scalar_divexact_si(fmpz_mpoly_t A, const fmpz_mpoly_t B, long c, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_scalar_divexact_ui(fmpz_mpoly_t A, const fmpz_mpoly_t B, ulong c, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_scalar_divexact_si(fmpz_mpoly_t A, const fmpz_mpoly_t B, slong c, const fmpz_mpoly_ctx_t ctx) # Set *A* to *B* divided by *c*. The division is assumed to be exact. int fmpz_mpoly_scalar_divides_fmpz(fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_t c, const fmpz_mpoly_ctx_t ctx) - int fmpz_mpoly_scalar_divides_ui(fmpz_mpoly_t A, const fmpz_mpoly_t B, unsigned long c, const fmpz_mpoly_ctx_t ctx) - int fmpz_mpoly_scalar_divides_si(fmpz_mpoly_t A, const fmpz_mpoly_t B, long c, const fmpz_mpoly_ctx_t ctx) + int fmpz_mpoly_scalar_divides_ui(fmpz_mpoly_t A, const fmpz_mpoly_t B, ulong c, const fmpz_mpoly_ctx_t ctx) + int fmpz_mpoly_scalar_divides_si(fmpz_mpoly_t A, const fmpz_mpoly_t B, slong c, const fmpz_mpoly_ctx_t ctx) # If *B* is divisible by *c*, set *A* to the exact quotient and return `1`, otherwise set *A* to zero and return `0`. - void fmpz_mpoly_derivative(fmpz_mpoly_t A, const fmpz_mpoly_t B, long var, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_derivative(fmpz_mpoly_t A, const fmpz_mpoly_t B, slong var, const fmpz_mpoly_ctx_t ctx) # Set *A* to the derivative of *B* with respect to the variable of index `var`. - void fmpz_mpoly_integral(fmpz_mpoly_t A, fmpz_t scale, const fmpz_mpoly_t B, long var, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_integral(fmpz_mpoly_t A, fmpz_t scale, const fmpz_mpoly_t B, slong var, const fmpz_mpoly_ctx_t ctx) # Set *A* and *scale* so that *A* is an integral of `scale \times B` with respect to the variable of index *var*, where *scale* is positive and as small as possible. int fmpz_mpoly_evaluate_all_fmpz(fmpz_t ev, const fmpz_mpoly_t A, fmpz * const * vals, const fmpz_mpoly_ctx_t ctx) # Set *ev* to the evaluation of *A* where the variables are replaced by the corresponding elements of the array *vals*. # Return `1` for success and `0` for failure. - int fmpz_mpoly_evaluate_one_fmpz(fmpz_mpoly_t A, const fmpz_mpoly_t B, long var, const fmpz_t val, const fmpz_mpoly_ctx_t ctx) + int fmpz_mpoly_evaluate_one_fmpz(fmpz_mpoly_t A, const fmpz_mpoly_t B, slong var, const fmpz_t val, const fmpz_mpoly_ctx_t ctx) # Set *A* to the evaluation of *B* where the variable of index *var* is replaced by ``val``. # Return `1` for success and `0` for failure. @@ -344,13 +344,13 @@ cdef extern from "flint_wrap.h": # Return `1` for success and `0` for failure. # The main method attempts to perform the calculation using matrices and chooses heuristically between the ``geobucket`` and ``horner`` methods if needed. - void fmpz_mpoly_compose_fmpz_mpoly_gen(fmpz_mpoly_t A, const fmpz_mpoly_t B, const long * c, const fmpz_mpoly_ctx_t ctxB, const fmpz_mpoly_ctx_t ctxAC) + void fmpz_mpoly_compose_fmpz_mpoly_gen(fmpz_mpoly_t A, const fmpz_mpoly_t B, const slong * c, const fmpz_mpoly_ctx_t ctxB, const fmpz_mpoly_ctx_t ctxAC) # Set *A* to the evaluation of *B* where the variable of index *i* in *ctxB* is replaced by the variable of index ``c[i]`` in *ctxAC*. # The length of the array *C* is the number of variables in *ctxB*. # If any ``c[i]`` is negative, the corresponding variable of *B* is replaced by zero. Otherwise, it is expected that ``c[i]`` is less than the number of variables in *ctxAC*. void fmpz_mpoly_mul(fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_mpoly_t C, const fmpz_mpoly_ctx_t ctx) - void fmpz_mpoly_mul_threaded(fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_mpoly_t C, const fmpz_mpoly_ctx_t ctx, long thread_limit) + void fmpz_mpoly_mul_threaded(fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_mpoly_t C, const fmpz_mpoly_ctx_t ctx, slong thread_limit) # Set *A* to `B \times C`. void fmpz_mpoly_mul_johnson(fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_mpoly_t C, const fmpz_mpoly_ctx_t ctx) @@ -372,7 +372,7 @@ cdef extern from "flint_wrap.h": # Set *A* to *B* raised to the *k*-th power. # Return `1` for success and `0` for failure. - int fmpz_mpoly_pow_ui(fmpz_mpoly_t A, const fmpz_mpoly_t B, unsigned long k, const fmpz_mpoly_ctx_t ctx) + int fmpz_mpoly_pow_ui(fmpz_mpoly_t A, const fmpz_mpoly_t B, ulong k, const fmpz_mpoly_ctx_t ctx) # Set *A* to *B* raised to the *k*-th power. # Return `1` for success and `0` for failure. @@ -393,12 +393,12 @@ cdef extern from "flint_wrap.h": void fmpz_mpoly_quasidiv(fmpz_t scale, fmpz_mpoly_t Q, const fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_mpoly_ctx_t ctx) # Perform the operation of :func:`fmpz_mpoly_quasidivrem` and discard *R*. - void fmpz_mpoly_divrem_ideal(fmpz_mpoly_struct ** Q, fmpz_mpoly_t R, const fmpz_mpoly_t A, fmpz_mpoly_struct * const * B, long len, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_divrem_ideal(fmpz_mpoly_struct ** Q, fmpz_mpoly_t R, const fmpz_mpoly_t A, fmpz_mpoly_struct * const * B, slong len, const fmpz_mpoly_ctx_t ctx) # This function is as per :func:`fmpz_mpoly_divrem` except that it takes an array of divisor polynomials *B* and it returns an array of quotient polynomials *Q*. # The number of divisor (and hence quotient) polynomials is given by *len*. # Note that this function is not very useful if there is no unit among the leading coefficients in the array *B*. - void fmpz_mpoly_quasidivrem_ideal(fmpz_t scale, fmpz_mpoly_struct ** Q, fmpz_mpoly_t R, const fmpz_mpoly_t A, fmpz_mpoly_struct * const * B, long len, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_quasidivrem_ideal(fmpz_t scale, fmpz_mpoly_struct ** Q, fmpz_mpoly_t R, const fmpz_mpoly_t A, fmpz_mpoly_struct * const * B, slong len, const fmpz_mpoly_ctx_t ctx) # This function is as per :func:`fmpz_mpoly_quasidivrem` except that it takes an array of divisor polynomials *B* and it returns an array of quotient polynomials *Q*. # The number of divisor (and hence quotient) polynomials is given by *len*. @@ -406,7 +406,7 @@ cdef extern from "flint_wrap.h": # Set *M* to the GCD of the terms of *A*. # If *A* is zero, *M* will be zero. Otherwise, *M* will be a monomial with positive coefficient. - int fmpz_mpoly_content_vars(fmpz_mpoly_t g, const fmpz_mpoly_t A, long * vars, long vars_length, const fmpz_mpoly_ctx_t ctx) + int fmpz_mpoly_content_vars(fmpz_mpoly_t g, const fmpz_mpoly_t A, slong * vars, slong vars_length, const fmpz_mpoly_ctx_t ctx) # Set *g* to the GCD of the coefficients of *A* when viewed as a polynomial in the variables *vars*. # Return `1` for success and `0` for failure. Upon success, *g* will be independent of the variables *vars*. @@ -424,10 +424,10 @@ cdef extern from "flint_wrap.h": int fmpz_mpoly_gcd_zippel2(fmpz_mpoly_t G, const fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_mpoly_ctx_t ctx) # Try to set *G* to the GCD of *A* and *B* using various algorithms. - int fmpz_mpoly_resultant(fmpz_mpoly_t R, const fmpz_mpoly_t A, const fmpz_mpoly_t B, long var, const fmpz_mpoly_ctx_t ctx) + int fmpz_mpoly_resultant(fmpz_mpoly_t R, const fmpz_mpoly_t A, const fmpz_mpoly_t B, slong var, const fmpz_mpoly_ctx_t ctx) # Try to set *R* to the resultant of *A* and *B* with respect to the variable of index *var*. - int fmpz_mpoly_discriminant(fmpz_mpoly_t D, const fmpz_mpoly_t A, long var, const fmpz_mpoly_ctx_t ctx) + int fmpz_mpoly_discriminant(fmpz_mpoly_t D, const fmpz_mpoly_t A, slong var, const fmpz_mpoly_ctx_t ctx) # Try to set *D* to the discriminant of *A* with respect to the variable of index *var*. void fmpz_mpoly_primitive_part(fmpz_mpoly_t res, const fmpz_mpoly_t f, const fmpz_mpoly_ctx_t ctx) @@ -459,25 +459,25 @@ cdef extern from "flint_wrap.h": void fmpz_mpoly_univar_swap(fmpz_mpoly_univar_t A, fmpz_mpoly_univar_t B, const fmpz_mpoly_ctx_t ctx) # Swap *A* and *B*. - void fmpz_mpoly_to_univar(fmpz_mpoly_univar_t A, const fmpz_mpoly_t B, long var, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_to_univar(fmpz_mpoly_univar_t A, const fmpz_mpoly_t B, slong var, const fmpz_mpoly_ctx_t ctx) # Set *A* to a univariate form of *B* by pulling out the variable of index *var*. # The coefficients of *A* will still belong to the content *ctx* but will not depend on the variable of index *var*. - void fmpz_mpoly_from_univar(fmpz_mpoly_t A, const fmpz_mpoly_univar_t B, long var, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_from_univar(fmpz_mpoly_t A, const fmpz_mpoly_univar_t B, slong var, const fmpz_mpoly_ctx_t ctx) # Set *A* to the normal form of *B* by putting in the variable of index *var*. # This function is undefined if the coefficients of *B* depend on the variable of index *var*. int fmpz_mpoly_univar_degree_fits_si(const fmpz_mpoly_univar_t A, const fmpz_mpoly_ctx_t ctx) # Return `1` if the degree of *A* with respect to the main variable fits an ``slong``. Otherwise, return `0`. - long fmpz_mpoly_univar_length(const fmpz_mpoly_univar_t A, const fmpz_mpoly_ctx_t ctx) + slong fmpz_mpoly_univar_length(const fmpz_mpoly_univar_t A, const fmpz_mpoly_ctx_t ctx) # Return the number of terms in *A* with respect to the main variable. - long fmpz_mpoly_univar_get_term_exp_si(fmpz_mpoly_univar_t A, long i, const fmpz_mpoly_ctx_t ctx) + slong fmpz_mpoly_univar_get_term_exp_si(fmpz_mpoly_univar_t A, slong i, const fmpz_mpoly_ctx_t ctx) # Return the exponent of the term of index *i* of *A*. - void fmpz_mpoly_univar_get_term_coeff(fmpz_mpoly_t c, const fmpz_mpoly_univar_t A, long i, const fmpz_mpoly_ctx_t ctx) - void fmpz_mpoly_univar_swap_term_coeff(fmpz_mpoly_t c, fmpz_mpoly_univar_t A, long i, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_univar_get_term_coeff(fmpz_mpoly_t c, const fmpz_mpoly_univar_t A, slong i, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_univar_swap_term_coeff(fmpz_mpoly_t c, fmpz_mpoly_univar_t A, slong i, const fmpz_mpoly_ctx_t ctx) # Set (resp. swap) *c* to (resp. with) the coefficient of the term of index *i* of *A*. void fmpz_mpoly_inflate(fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz * shift, const fmpz * stride, const fmpz_mpoly_ctx_t ctx) @@ -494,11 +494,11 @@ cdef extern from "flint_wrap.h": # Set ``shift[v]`` to `\operatorname{min}(S_v)` and set ``stride[v]`` to `\operatorname{gcd}(S-\operatorname{min}(S_v))`. # If *A* is zero, all shifts and strides are set to zero. - void fmpz_mpoly_pow_fps(fmpz_mpoly_t A, const fmpz_mpoly_t B, unsigned long k, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_pow_fps(fmpz_mpoly_t A, const fmpz_mpoly_t B, ulong k, const fmpz_mpoly_ctx_t ctx) # Set *A* to *B* raised to the *k*-th power, using the Monagan and Pearce FPS algorithm. # It is assumed that *B* is not zero and `k \geq 2`. - long _fmpz_mpoly_divides_array(fmpz ** poly1, unsigned long ** exp1, long * alloc, const fmpz * poly2, const unsigned long * exp2, long len2, const fmpz * poly3, const unsigned long * exp3, long len3, long * mults, long num, long bits) + slong _fmpz_mpoly_divides_array(fmpz ** poly1, ulong ** exp1, slong * alloc, const fmpz * poly2, const ulong * exp2, slong len2, const fmpz * poly3, const ulong * exp3, slong len3, slong * mults, slong num, slong bits) # Use dense array exact division to set ``(poly1, exp1, alloc)`` to # ``(poly2, exp3, len2)`` divided by ``(poly3, exp3, len3)`` in # ``num`` variables, given a list of multipliers to tightly pack exponents @@ -519,7 +519,7 @@ cdef extern from "flint_wrap.h": # ``fmpz_mpoly_div_monagan_pearce`` below may be much faster if the # quotient is known to be exact. - long _fmpz_mpoly_divides_monagan_pearce(fmpz ** poly1, unsigned long ** exp1, long * alloc, const fmpz * poly2, const unsigned long * exp2, long len2, const fmpz * poly3, const unsigned long * exp3, long len3, unsigned long bits, long N, const mp_limb_t *cmpmask) + slong _fmpz_mpoly_divides_monagan_pearce(fmpz ** poly1, ulong ** exp1, slong * alloc, const fmpz * poly2, const ulong * exp2, slong len2, const fmpz * poly3, const ulong * exp3, slong len3, ulong bits, slong N, const mp_limb_t *cmpmask) # Set ``(poly1, exp1, alloc)`` to ``(poly2, exp3, len2)`` divided by # ``(poly3, exp3, len3)`` and return 1 if the quotient is exact. Otherwise # return 0. The function assumes exponent vectors that each fit in `N` words, @@ -538,7 +538,7 @@ cdef extern from "flint_wrap.h": # quotient is known to be exact. # The threaded version takes an upper limit on the number of threads to use, while the first version always uses one thread. - long _fmpz_mpoly_div_monagan_pearce(fmpz ** polyq, unsigned long ** expq, long * allocq, const fmpz * poly2, const unsigned long * exp2, long len2, const fmpz * poly3, const unsigned long * exp3, long len3, long bits, long N, const mp_limb_t *cmpmask) + slong _fmpz_mpoly_div_monagan_pearce(fmpz ** polyq, ulong ** expq, slong * allocq, const fmpz * poly2, const ulong * exp2, slong len2, const fmpz * poly3, const ulong * exp3, slong len3, slong bits, slong N, const mp_limb_t *cmpmask) # Set ``(polyq, expq, allocq)`` to the quotient of # ``(poly2, exp2, len2)`` by ``(poly3, exp3, len3)`` discarding # remainder (with notional remainder coefficients reduced modulo the leading @@ -558,7 +558,7 @@ cdef extern from "flint_wrap.h": # Monagan and Roman Pearce. This function is exceptionally efficient if the # division is known to be exact. - long _fmpz_mpoly_divrem_monagan_pearce(long * lenr, fmpz ** polyq, unsigned long ** expq, long * allocq, fmpz ** polyr, unsigned long ** expr, long * allocr, const fmpz * poly2, const unsigned long * exp2, long len2, const fmpz * poly3, const unsigned long * exp3, long len3, long bits, long N, const mp_limb_t *cmpmask) + slong _fmpz_mpoly_divrem_monagan_pearce(slong * lenr, fmpz ** polyq, ulong ** expq, slong * allocq, fmpz ** polyr, ulong ** expr, slong * allocr, const fmpz * poly2, const ulong * exp2, slong len2, const fmpz * poly3, const ulong * exp3, slong len3, slong bits, slong N, const mp_limb_t *cmpmask) # Set ``(polyq, expq, allocq)`` and ``(polyr, expr, allocr)`` to the # quotient and remainder of ``(poly2, exp2, len2)`` by # ``(poly3, exp3, len3)`` (with remainder coefficients reduced modulo the @@ -577,7 +577,7 @@ cdef extern from "flint_wrap.h": # division using dynamic arrays, heaps and packed exponents" by Michael # Monagan and Roman Pearce. - long _fmpz_mpoly_divrem_array(long * lenr, fmpz ** polyq, unsigned long ** expq, long * allocq, fmpz ** polyr, unsigned long ** expr, long * allocr, const fmpz * poly2, const unsigned long * exp2, long len2, const fmpz * poly3, const unsigned long * exp3, long len3, long * mults, long num, long bits) + slong _fmpz_mpoly_divrem_array(slong * lenr, fmpz ** polyq, ulong ** expq, slong * allocq, fmpz ** polyr, ulong ** expr, slong * allocr, const fmpz * poly2, const ulong * exp2, slong len2, const fmpz * poly3, const ulong * exp3, slong len3, slong * mults, slong num, slong bits) # Use dense array division to set ``(polyq, expq, allocq)`` and # ``(polyr, expr, allocr)`` to the quotient and remainder of # ``(poly2, exp2, len2)`` divided by ``(poly3, exp3, len3)`` in @@ -605,7 +605,7 @@ cdef extern from "flint_wrap.h": # and as small as possible. This function throws an exception if # ``poly3`` is zero or if an exponent overflow occurs. - long _fmpz_mpoly_divrem_ideal_monagan_pearce(fmpz_mpoly_struct ** polyq, fmpz ** polyr, unsigned long ** expr, long * allocr, const fmpz * poly2, const unsigned long * exp2, long len2, fmpz_mpoly_struct * const * poly3, unsigned long * const * exp3, long len, long N, long bits, const fmpz_mpoly_ctx_t ctx, const mp_limb_t *cmpmask) + slong _fmpz_mpoly_divrem_ideal_monagan_pearce(fmpz_mpoly_struct ** polyq, fmpz ** polyr, ulong ** expr, slong * allocr, const fmpz * poly2, const ulong * exp2, slong len2, fmpz_mpoly_struct * const * poly3, ulong * const * exp3, slong len, slong N, slong bits, const fmpz_mpoly_ctx_t ctx, const mp_limb_t *cmpmask) # This function is as per ``_fmpz_mpoly_divrem_monagan_pearce`` except # that it takes an array of divisor polynomials ``poly3`` and an array of # repacked exponent arrays ``exp3``, which may alias the exponent arrays @@ -615,7 +615,7 @@ cdef extern from "flint_wrap.h": # `r = a - \sum_{i=0}^{\mbox{len - 1}} q_ib_i`, where the `q_i` are the # quotient polynomials and the `b_i` are the divisor polynomials. - void fmpz_mpoly_divrem_ideal_monagan_pearce(fmpz_mpoly_struct ** q, fmpz_mpoly_t r, const fmpz_mpoly_t poly2, fmpz_mpoly_struct * const * poly3, long len, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_divrem_ideal_monagan_pearce(fmpz_mpoly_struct ** q, fmpz_mpoly_t r, const fmpz_mpoly_t poly2, fmpz_mpoly_struct * const * poly3, slong len, const fmpz_mpoly_ctx_t ctx) # This function is as per ``fmpz_mpoly_divrem_monagan_pearce`` except # that it takes an array of divisor polynomials ``poly3``, and it returns # an array of quotient polynomials ``q``. The number of divisor (and hence @@ -623,7 +623,7 @@ cdef extern from "flint_wrap.h": # polynomials `q_i = q[i]` such that ``poly2`` is # `r + \sum_{i=0}^{\mbox{len - 1}} q_ib_i`, where `b_i =` ``poly3[i]``. - void fmpz_mpoly_vec_init(fmpz_mpoly_vec_t vec, long len, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_vec_init(fmpz_mpoly_vec_t vec, slong len, const fmpz_mpoly_ctx_t ctx) # Initializes *vec* to a vector of length *len*, setting all entries to the zero polynomial. void fmpz_mpoly_vec_clear(fmpz_mpoly_vec_t vec, const fmpz_mpoly_ctx_t ctx) @@ -635,7 +635,7 @@ cdef extern from "flint_wrap.h": void fmpz_mpoly_vec_swap(fmpz_mpoly_vec_t x, fmpz_mpoly_vec_t y, const fmpz_mpoly_ctx_t ctx) # Swaps *x* and *y* efficiently. - void fmpz_mpoly_vec_fit_length(fmpz_mpoly_vec_t vec, long len, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_vec_fit_length(fmpz_mpoly_vec_t vec, slong len, const fmpz_mpoly_ctx_t ctx) # Allocates room for *len* entries in *vec*. void fmpz_mpoly_vec_set(fmpz_mpoly_vec_t dest, const fmpz_mpoly_vec_t src, const fmpz_mpoly_ctx_t ctx) @@ -644,16 +644,16 @@ cdef extern from "flint_wrap.h": void fmpz_mpoly_vec_append(fmpz_mpoly_vec_t vec, const fmpz_mpoly_t f, const fmpz_mpoly_ctx_t ctx) # Appends *f* to the end of *vec*. - long fmpz_mpoly_vec_insert_unique(fmpz_mpoly_vec_t vec, const fmpz_mpoly_t f, const fmpz_mpoly_ctx_t ctx) + slong fmpz_mpoly_vec_insert_unique(fmpz_mpoly_vec_t vec, const fmpz_mpoly_t f, const fmpz_mpoly_ctx_t ctx) # Inserts *f* without duplication into *vec* and returns its index. # If this polynomial already exists, *vec* is unchanged. If this # polynomial does not exist in *vec*, it is appended. - void fmpz_mpoly_vec_set_length(fmpz_mpoly_vec_t vec, long len, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_vec_set_length(fmpz_mpoly_vec_t vec, slong len, const fmpz_mpoly_ctx_t ctx) # Sets the length of *vec* to *len*, truncating or zero-extending # as needed. - void fmpz_mpoly_vec_randtest_not_zero(fmpz_mpoly_vec_t vec, flint_rand_t state, long len, long poly_len, long bits, unsigned long exp_bound, fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_vec_randtest_not_zero(fmpz_mpoly_vec_t vec, flint_rand_t state, slong len, slong poly_len, slong bits, ulong exp_bound, fmpz_mpoly_ctx_t ctx) # Sets *vec* to a random vector with exactly *len* entries, all nonzero, # with random parameters defined by *poly_len*, *bits* and *exp_bound*. @@ -695,7 +695,7 @@ cdef extern from "flint_wrap.h": # Sets *G* to a Gröbner basis for *F*, computed using # a naive implementation of Buchberger's algorithm. - int fmpz_mpoly_buchberger_naive_with_limits(fmpz_mpoly_vec_t G, const fmpz_mpoly_vec_t F, long ideal_len_limit, long poly_len_limit, long poly_bits_limit, const fmpz_mpoly_ctx_t ctx) + int fmpz_mpoly_buchberger_naive_with_limits(fmpz_mpoly_vec_t G, const fmpz_mpoly_vec_t F, slong ideal_len_limit, slong poly_len_limit, slong poly_bits_limit, const fmpz_mpoly_ctx_t ctx) # As :func:`fmpz_mpoly_buchberger_naive`, but halts if during the # execution of Buchberger's algorithm the length of the # ideal basis set exceeds *ideal_len_limit*, the length of any @@ -704,9 +704,9 @@ cdef extern from "flint_wrap.h": # Returns 1 for success and 0 for failure. On failure, *G* is # a valid basis for *F* but it might not be a Gröbner basis. - void fmpz_mpoly_symmetric_gens(fmpz_mpoly_t res, unsigned long k, long * vars, long n, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_symmetric_gens(fmpz_mpoly_t res, ulong k, slong * vars, slong n, const fmpz_mpoly_ctx_t ctx) - void fmpz_mpoly_symmetric(fmpz_mpoly_t res, unsigned long k, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_symmetric(fmpz_mpoly_t res, ulong k, const fmpz_mpoly_ctx_t ctx) # Sets *res* to the elementary symmetric polynomial # `e_k(X_1,\ldots,X_n)`. # The *gens* version takes `X_1,\ldots,X_n` to be the subset of diff --git a/src/sage/libs/flint/fmpz_mpoly_factor.pxd b/src/sage/libs/flint/fmpz_mpoly_factor.pxd index 0903fc4ac6e..3544dff614a 100644 --- a/src/sage/libs/flint/fmpz_mpoly_factor.pxd +++ b/src/sage/libs/flint/fmpz_mpoly_factor.pxd @@ -21,18 +21,18 @@ cdef extern from "flint_wrap.h": void fmpz_mpoly_factor_swap(fmpz_mpoly_factor_t f, fmpz_mpoly_factor_t g, const fmpz_mpoly_ctx_t ctx) # Efficiently swap *f* and *g*. - long fmpz_mpoly_factor_length(const fmpz_mpoly_factor_t f, const fmpz_mpoly_ctx_t ctx) + slong fmpz_mpoly_factor_length(const fmpz_mpoly_factor_t f, const fmpz_mpoly_ctx_t ctx) # Return the length of the product in *f*. void fmpz_mpoly_factor_get_constant_fmpz(fmpz_t c, const fmpz_mpoly_factor_t f, const fmpz_mpoly_ctx_t ctx) void fmpz_mpoly_factor_get_constant_fmpq(fmpq_t c, const fmpz_mpoly_factor_t f, const fmpz_mpoly_ctx_t ctx) # Set `c` to the constant of *f*. - void fmpz_mpoly_factor_get_base(fmpz_mpoly_t B, const fmpz_mpoly_factor_t f, long i, const fmpz_mpoly_ctx_t ctx) - void fmpz_mpoly_factor_swap_base(fmpz_mpoly_t B, fmpz_mpoly_factor_t f, long i, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_factor_get_base(fmpz_mpoly_t B, const fmpz_mpoly_factor_t f, slong i, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_factor_swap_base(fmpz_mpoly_t B, fmpz_mpoly_factor_t f, slong i, const fmpz_mpoly_ctx_t ctx) # Set (resp. swap) *B* to (resp. with) the base of the term of index `i` in *A*. - long fmpz_mpoly_factor_get_exp_si(fmpz_mpoly_factor_t f, long i, const fmpz_mpoly_ctx_t ctx) + slong fmpz_mpoly_factor_get_exp_si(fmpz_mpoly_factor_t f, slong i, const fmpz_mpoly_ctx_t ctx) # Return the exponent of the term of index `i` in *A*. It is assumed to fit an ``slong``. void fmpz_mpoly_factor_sort(fmpz_mpoly_factor_t f, const fmpz_mpoly_ctx_t ctx) diff --git a/src/sage/libs/flint/fmpz_mpoly_q.pxd b/src/sage/libs/flint/fmpz_mpoly_q.pxd index 8259ea4d8c1..87bdb8838f9 100644 --- a/src/sage/libs/flint/fmpz_mpoly_q.pxd +++ b/src/sage/libs/flint/fmpz_mpoly_q.pxd @@ -24,7 +24,7 @@ cdef extern from "flint_wrap.h": void fmpz_mpoly_q_set(fmpz_mpoly_q_t res, const fmpz_mpoly_q_t x, const fmpz_mpoly_ctx_t ctx) void fmpz_mpoly_q_set_fmpq(fmpz_mpoly_q_t res, const fmpq_t x, const fmpz_mpoly_ctx_t ctx) void fmpz_mpoly_q_set_fmpz(fmpz_mpoly_q_t res, const fmpz_t x, const fmpz_mpoly_ctx_t ctx) - void fmpz_mpoly_q_set_si(fmpz_mpoly_q_t res, long x, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_q_set_si(fmpz_mpoly_q_t res, slong x, const fmpz_mpoly_ctx_t ctx) # Sets *res* to the value *x*. void fmpz_mpoly_q_canonicalise(fmpz_mpoly_q_t x, const fmpz_mpoly_ctx_t ctx) @@ -59,7 +59,7 @@ cdef extern from "flint_wrap.h": void fmpz_mpoly_q_one(fmpz_mpoly_q_t res, const fmpz_mpoly_ctx_t ctx) # Sets *res* to the constant 1. - void fmpz_mpoly_q_gen(fmpz_mpoly_q_t res, long i, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_q_gen(fmpz_mpoly_q_t res, slong i, const fmpz_mpoly_ctx_t ctx) # Sets *res* to the generator `x_{i+1}`. # Requires `0 \le i < n` where *n* is the number of variables of *ctx*. @@ -67,7 +67,7 @@ cdef extern from "flint_wrap.h": # Prints *res* to standard output. If *x* is not *NULL*, the strings in # *x* are used as the symbols for the variables. - void fmpz_mpoly_q_randtest(fmpz_mpoly_q_t res, flint_rand_t state, long length, mp_limb_t coeff_bits, long exp_bound, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_q_randtest(fmpz_mpoly_q_t res, flint_rand_t state, slong length, mp_limb_t coeff_bits, slong exp_bound, const fmpz_mpoly_ctx_t ctx) # Sets *res* to a random rational function where both numerator and denominator # have up to *length* terms, coefficients up to size *coeff_bits*, and # exponents strictly smaller than *exp_bound*. @@ -81,25 +81,25 @@ cdef extern from "flint_wrap.h": void fmpz_mpoly_q_add(fmpz_mpoly_q_t res, const fmpz_mpoly_q_t x, const fmpz_mpoly_q_t y, const fmpz_mpoly_ctx_t ctx) void fmpz_mpoly_q_add_fmpq(fmpz_mpoly_q_t res, const fmpz_mpoly_q_t x, const fmpq_t y, const fmpz_mpoly_ctx_t ctx) void fmpz_mpoly_q_add_fmpz(fmpz_mpoly_q_t res, const fmpz_mpoly_q_t x, const fmpz_t y, const fmpz_mpoly_ctx_t ctx) - void fmpz_mpoly_q_add_si(fmpz_mpoly_q_t res, const fmpz_mpoly_q_t x, long y, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_q_add_si(fmpz_mpoly_q_t res, const fmpz_mpoly_q_t x, slong y, const fmpz_mpoly_ctx_t ctx) # Sets *res* to the sum of *x* and *y*. void fmpz_mpoly_q_sub(fmpz_mpoly_q_t res, const fmpz_mpoly_q_t x, const fmpz_mpoly_q_t y, const fmpz_mpoly_ctx_t ctx) void fmpz_mpoly_q_sub_fmpq(fmpz_mpoly_q_t res, const fmpz_mpoly_q_t x, const fmpq_t y, const fmpz_mpoly_ctx_t ctx) void fmpz_mpoly_q_sub_fmpz(fmpz_mpoly_q_t res, const fmpz_mpoly_q_t x, const fmpz_t y, const fmpz_mpoly_ctx_t ctx) - void fmpz_mpoly_q_sub_si(fmpz_mpoly_q_t res, const fmpz_mpoly_q_t x, long y, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_q_sub_si(fmpz_mpoly_q_t res, const fmpz_mpoly_q_t x, slong y, const fmpz_mpoly_ctx_t ctx) # Sets *res* to the difference of *x* and *y*. void fmpz_mpoly_q_mul(fmpz_mpoly_q_t res, const fmpz_mpoly_q_t x, const fmpz_mpoly_q_t y, const fmpz_mpoly_ctx_t ctx) void fmpz_mpoly_q_mul_fmpq(fmpz_mpoly_q_t res, const fmpz_mpoly_q_t x, const fmpq_t y, const fmpz_mpoly_ctx_t ctx) void fmpz_mpoly_q_mul_fmpz(fmpz_mpoly_q_t res, const fmpz_mpoly_q_t x, const fmpz_t y, const fmpz_mpoly_ctx_t ctx) - void fmpz_mpoly_q_mul_si(fmpz_mpoly_q_t res, const fmpz_mpoly_q_t x, long y, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_q_mul_si(fmpz_mpoly_q_t res, const fmpz_mpoly_q_t x, slong y, const fmpz_mpoly_ctx_t ctx) # Sets *res* to the product of *x* and *y*. void fmpz_mpoly_q_div(fmpz_mpoly_q_t res, const fmpz_mpoly_q_t x, const fmpz_mpoly_q_t y, const fmpz_mpoly_ctx_t ctx) void fmpz_mpoly_q_div_fmpq(fmpz_mpoly_q_t res, const fmpz_mpoly_q_t x, const fmpq_t y, const fmpz_mpoly_ctx_t ctx) void fmpz_mpoly_q_div_fmpz(fmpz_mpoly_q_t res, const fmpz_mpoly_q_t x, const fmpz_t y, const fmpz_mpoly_ctx_t ctx) - void fmpz_mpoly_q_div_si(fmpz_mpoly_q_t res, const fmpz_mpoly_q_t x, long y, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_q_div_si(fmpz_mpoly_q_t res, const fmpz_mpoly_q_t x, slong y, const fmpz_mpoly_ctx_t ctx) # Sets *res* to the quotient of *x* and *y*. # Division by zero calls *flint_abort*. diff --git a/src/sage/libs/flint/fmpz_poly.pxd b/src/sage/libs/flint/fmpz_poly.pxd index e87c1fe0fbc..2405b20a5ea 100644 --- a/src/sage/libs/flint/fmpz_poly.pxd +++ b/src/sage/libs/flint/fmpz_poly.pxd @@ -18,18 +18,18 @@ cdef extern from "flint_wrap.h": # finishing with the ``fmpz_poly_t`` to free the memory used by # the polynomial. - void fmpz_poly_init2(fmpz_poly_t poly, long alloc) + void fmpz_poly_init2(fmpz_poly_t poly, slong alloc) # Initialises ``poly`` with space for at least ``alloc`` coefficients # and sets the length to zero. The allocated coefficients are all set to # zero. - void fmpz_poly_realloc(fmpz_poly_t poly, long alloc) + void fmpz_poly_realloc(fmpz_poly_t poly, slong alloc) # Reallocates the given polynomial to have space for ``alloc`` # coefficients. If ``alloc`` is zero the polynomial is cleared # and then reinitialised. If the current length is greater than # ``alloc`` the polynomial is first truncated to length ``alloc``. - void fmpz_poly_fit_length(fmpz_poly_t poly, long len) + void fmpz_poly_fit_length(fmpz_poly_t poly, slong len) # If ``len`` is greater than the number of coefficients currently # allocated, then the polynomial is reallocated to have space for at # least ``len`` coefficients. No data is lost when calling this @@ -48,36 +48,36 @@ cdef extern from "flint_wrap.h": # If all coefficients are zero, the length is set to zero. This function # is mainly used internally, as all functions guarantee normalisation. - void _fmpz_poly_set_length(fmpz_poly_t poly, long newlen) + void _fmpz_poly_set_length(fmpz_poly_t poly, slong newlen) # Demotes the coefficients of ``poly`` beyond ``newlen`` and sets # the length of ``poly`` to ``newlen``. - void fmpz_poly_attach_truncate(fmpz_poly_t trunc, const fmpz_poly_t poly, long n) + void fmpz_poly_attach_truncate(fmpz_poly_t trunc, const fmpz_poly_t poly, slong n) # This function sets the uninitialised polynomial ``trunc`` to the low # `n` coefficients of ``poly``, or to ``poly`` if the latter doesn't # have `n` coefficients. The polynomial ``trunc`` not be cleared or used # as the output of any Flint functions. - void fmpz_poly_attach_shift(fmpz_poly_t trunc, const fmpz_poly_t poly, long n) + void fmpz_poly_attach_shift(fmpz_poly_t trunc, const fmpz_poly_t poly, slong n) # This function sets the uninitialised polynomial ``trunc`` to the # high coefficients of ``poly``, i.e. the coefficients not among the low # `n` coefficients of ``poly``. If the latter doesn't have `n` # coefficients ``trunc`` is set to the zero polynomial. The polynomial # ``trunc`` not be cleared or used as the output of any Flint functions. - long fmpz_poly_length(const fmpz_poly_t poly) + slong fmpz_poly_length(const fmpz_poly_t poly) # Returns the length of ``poly``. The zero polynomial has length zero. - long fmpz_poly_degree(const fmpz_poly_t poly) + slong fmpz_poly_degree(const fmpz_poly_t poly) # Returns the degree of ``poly``, which is one less than its length. void fmpz_poly_set(fmpz_poly_t poly1, const fmpz_poly_t poly2) # Sets ``poly1`` to equal ``poly2``. - void fmpz_poly_set_si(fmpz_poly_t poly, long c) + void fmpz_poly_set_si(fmpz_poly_t poly, slong c) # Sets ``poly`` to the signed integer ``c``. - void fmpz_poly_set_ui(fmpz_poly_t poly, unsigned long c) + void fmpz_poly_set_ui(fmpz_poly_t poly, ulong c) # Sets ``poly`` to the unsigned integer ``c``. void fmpz_poly_set_fmpz(fmpz_poly_t poly, const fmpz_t c) @@ -102,7 +102,7 @@ cdef extern from "flint_wrap.h": # ``str`` is not null-terminated, calling this method might result in # a segmentation fault. - char * _fmpz_poly_get_str(const fmpz * poly, long len) + char * _fmpz_poly_get_str(const fmpz * poly, slong len) # Returns the plain FLINT string representation of the polynomial # ``(poly, len)``. @@ -110,7 +110,7 @@ cdef extern from "flint_wrap.h": # Returns the plain FLINT string representation of the polynomial # ``poly``. - char * _fmpz_poly_get_str_pretty(const fmpz * poly, long len, const char * x) + char * _fmpz_poly_get_str_pretty(const fmpz * poly, slong len, const char * x) # Returns a pretty representation of the polynomial # ``(poly, len)`` using the null-terminated string ``x`` as the # variable name. @@ -125,55 +125,55 @@ cdef extern from "flint_wrap.h": void fmpz_poly_one(fmpz_poly_t poly) # Sets ``poly`` to the constant polynomial one. - void fmpz_poly_zero_coeffs(fmpz_poly_t poly, long i, long j) + void fmpz_poly_zero_coeffs(fmpz_poly_t poly, slong i, slong j) # Sets the coefficients of `x^i, \dotsc, x^{j-1}` to zero. void fmpz_poly_swap(fmpz_poly_t poly1, fmpz_poly_t poly2) # Swaps ``poly1`` and ``poly2``. This is done efficiently without # copying data by swapping pointers, etc. - void _fmpz_poly_reverse(fmpz * res, const fmpz * poly, long len, long n) + void _fmpz_poly_reverse(fmpz * res, const fmpz * poly, slong len, slong n) # Sets ``(res, n)`` to the reverse of ``(poly, n)``, where # ``poly`` is in fact an array of length ``len``. Assumes that # ``0 < len <= n``. Supports aliasing of ``res`` and ``poly``, # but the behaviour is undefined in case of partial overlap. - void fmpz_poly_reverse(fmpz_poly_t res, const fmpz_poly_t poly, long n) + void fmpz_poly_reverse(fmpz_poly_t res, const fmpz_poly_t poly, slong n) # This function considers the polynomial ``poly`` to be of length `n`, # notionally truncating and zero padding if required, and reverses # the result. Since the function normalises its result ``res`` may be # of length less than `n`. - void fmpz_poly_truncate(fmpz_poly_t poly, long newlen) + void fmpz_poly_truncate(fmpz_poly_t poly, slong newlen) # If the current length of ``poly`` is greater than ``newlen``, it # is truncated to have the given length. Discarded coefficients are not # necessarily set to zero. - void fmpz_poly_set_trunc(fmpz_poly_t res, const fmpz_poly_t poly, long n) + void fmpz_poly_set_trunc(fmpz_poly_t res, const fmpz_poly_t poly, slong n) # Sets ``res`` to a copy of ``poly``, truncated to length ``n``. - void fmpz_poly_randtest(fmpz_poly_t f, flint_rand_t state, long len, flint_bitcnt_t bits) + void fmpz_poly_randtest(fmpz_poly_t f, flint_rand_t state, slong len, flint_bitcnt_t bits) # Sets `f` to a random polynomial with up to the given length and where # each coefficient has up to the given number of bits. The coefficients # are signed randomly. - void fmpz_poly_randtest_unsigned(fmpz_poly_t f, flint_rand_t state, long len, flint_bitcnt_t bits) + void fmpz_poly_randtest_unsigned(fmpz_poly_t f, flint_rand_t state, slong len, flint_bitcnt_t bits) # Sets `f` to a random polynomial with up to the given length and where # each coefficient has up to the given number of bits. - void fmpz_poly_randtest_not_zero(fmpz_poly_t f, flint_rand_t state, long len, flint_bitcnt_t bits) + void fmpz_poly_randtest_not_zero(fmpz_poly_t f, flint_rand_t state, slong len, flint_bitcnt_t bits) # As for :func:`fmpz_poly_randtest` except that ``len`` and bits may # not be zero and the polynomial generated is guaranteed not to be the # zero polynomial. - void fmpz_poly_randtest_no_real_root(fmpz_poly_t p, flint_rand_t state, long len, flint_bitcnt_t bits) + void fmpz_poly_randtest_no_real_root(fmpz_poly_t p, flint_rand_t state, slong len, flint_bitcnt_t bits) # Sets ``p`` to a random polynomial without any real root, whose # length is up to ``len`` and where each coefficient has up to the # given number of bits. - void fmpz_poly_randtest_irreducible1(fmpz_poly_t pol, flint_rand_t state, long len, mp_bitcnt_t bits) - void fmpz_poly_randtest_irreducible2(fmpz_poly_t pol, flint_rand_t state, long len, mp_bitcnt_t bits) - void fmpz_poly_randtest_irreducible(fmpz_poly_t pol, flint_rand_t state, long len, mp_bitcnt_t bits) + void fmpz_poly_randtest_irreducible1(fmpz_poly_t pol, flint_rand_t state, slong len, mp_bitcnt_t bits) + void fmpz_poly_randtest_irreducible2(fmpz_poly_t pol, flint_rand_t state, slong len, mp_bitcnt_t bits) + void fmpz_poly_randtest_irreducible(fmpz_poly_t pol, flint_rand_t state, slong len, mp_bitcnt_t bits) # Sets ``p`` to a random irreducible polynomial, whose # length is up to ``len`` and where each coefficient has up to the # given number of bits. There are two algorithms: *irreducible1* @@ -182,24 +182,24 @@ cdef extern from "flint_wrap.h": # integer polynomial, factors it, and returns a random factor. # The default function chooses randomly between these methods. - void fmpz_poly_get_coeff_fmpz(fmpz_t x, const fmpz_poly_t poly, long n) + void fmpz_poly_get_coeff_fmpz(fmpz_t x, const fmpz_poly_t poly, slong n) # Sets `x` to the `n`-th coefficient of ``poly``. Coefficient # numbering is from zero and if `n` is set to a value beyond the end of # the polynomial, zero is returned. - long fmpz_poly_get_coeff_si(const fmpz_poly_t poly, long n) + slong fmpz_poly_get_coeff_si(const fmpz_poly_t poly, slong n) # Returns coefficient `n` of ``poly`` as a ``slong``. The result is # undefined if the value does not fit into a ``slong``. Coefficient # numbering is from zero and if `n` is set to a value beyond the end of # the polynomial, zero is returned. - unsigned long fmpz_poly_get_coeff_ui(const fmpz_poly_t poly, long n) + ulong fmpz_poly_get_coeff_ui(const fmpz_poly_t poly, slong n) # Returns coefficient `n` of ``poly`` as a ``ulong``. The result is # undefined if the value does not fit into a ``ulong``. Coefficient # numbering is from zero and if `n` is set to a value beyond the end of the # polynomial, zero is returned. - fmpz * fmpz_poly_get_coeff_ptr(const fmpz_poly_t poly, long n) + fmpz * fmpz_poly_get_coeff_ptr(const fmpz_poly_t poly, slong n) # Returns a reference to the coefficient of `x^n` in the polynomial, # as an ``fmpz *``. This function is provided so that individual # coefficients can be accessed and operated on by functions in the @@ -217,19 +217,19 @@ cdef extern from "flint_wrap.h": # Returns ``NULL`` when the polynomial is zero. # This function is implemented as a macro. - void fmpz_poly_set_coeff_fmpz(fmpz_poly_t poly, long n, const fmpz_t x) + void fmpz_poly_set_coeff_fmpz(fmpz_poly_t poly, slong n, const fmpz_t x) # Sets coefficient `n` of ``poly`` to the ``fmpz`` value ``x``. # Coefficient numbering starts from zero and if `n` is beyond the current # length of ``poly`` then the polynomial is extended and zero # coefficients inserted if necessary. - void fmpz_poly_set_coeff_si(fmpz_poly_t poly, long n, long x) + void fmpz_poly_set_coeff_si(fmpz_poly_t poly, slong n, slong x) # Sets coefficient `n` of ``poly`` to the ``slong`` value ``x``. # Coefficient numbering starts from zero and if `n` is beyond the current # length of ``poly`` then the polynomial is extended and zero # coefficients inserted if necessary. - void fmpz_poly_set_coeff_ui(fmpz_poly_t poly, long n, unsigned long x) + void fmpz_poly_set_coeff_ui(fmpz_poly_t poly, slong n, ulong x) # Sets coefficient `n` of ``poly`` to the ``ulong`` value # ``x``. Coefficient numbering starts from zero and if `n` is beyond # the current length of ``poly`` then the polynomial is extended and @@ -239,7 +239,7 @@ cdef extern from "flint_wrap.h": # Returns `1` if ``poly1`` is equal to ``poly2``, otherwise # returns `0`. The polynomials are assumed to be normalised. - int fmpz_poly_equal_trunc(const fmpz_poly_t poly1, const fmpz_poly_t poly2, long n) + int fmpz_poly_equal_trunc(const fmpz_poly_t poly1, const fmpz_poly_t poly2, slong n) # Return `1` if ``poly1`` and ``poly2``, notionally truncated to # length `n` are equal, otherwise return `0`. @@ -258,7 +258,7 @@ cdef extern from "flint_wrap.h": # Returns `1` if the polynomial is the degree `1` polynomial `x`, and `0` # otherwise. - void _fmpz_poly_add(fmpz * res, const fmpz * poly1, long len1, const fmpz * poly2, long len2) + void _fmpz_poly_add(fmpz * res, const fmpz * poly1, slong len1, const fmpz * poly2, slong len2) # Sets ``res`` to the sum of ``(poly1, len1)`` and # ``(poly2, len2)``. It is assumed that ``res`` has # sufficient space for the longer of the two polynomials. @@ -266,11 +266,11 @@ cdef extern from "flint_wrap.h": void fmpz_poly_add(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2) # Sets ``res`` to the sum of ``poly1`` and ``poly2``. - void fmpz_poly_add_series(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2, long n) + void fmpz_poly_add_series(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2, slong n) # Notionally truncate ``poly1`` and ``poly2`` to length `n` and then # set ``res`` to the sum. - void _fmpz_poly_sub(fmpz * res, const fmpz * poly1, long len1, const fmpz * poly2, long len2) + void _fmpz_poly_sub(fmpz * res, const fmpz * poly1, slong len1, const fmpz * poly2, slong len2) # Sets ``res`` to ``(poly1, len1)`` minus ``(poly2, len2)``. It # is assumed that ``res`` has sufficient space for the longer of the # two polynomials. @@ -278,7 +278,7 @@ cdef extern from "flint_wrap.h": void fmpz_poly_sub(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2) # Sets ``res`` to ``poly1`` minus ``poly2``. - void fmpz_poly_sub_series(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2, long n) + void fmpz_poly_sub_series(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2, slong n) # Notionally truncate ``poly1`` and ``poly2`` to length `n` and then # set ``res`` to the sum. @@ -292,18 +292,18 @@ cdef extern from "flint_wrap.h": void fmpz_poly_scalar_mul_fmpz(fmpz_poly_t poly1, const fmpz_poly_t poly2, const fmpz_t x) # Sets ``poly1`` to ``poly2`` times `x`. - void fmpz_poly_scalar_mul_si(fmpz_poly_t poly1, const fmpz_poly_t poly2, long x) + void fmpz_poly_scalar_mul_si(fmpz_poly_t poly1, const fmpz_poly_t poly2, slong x) # Sets ``poly1`` to ``poly2`` times the signed ``slong x``. - void fmpz_poly_scalar_mul_ui(fmpz_poly_t poly1, const fmpz_poly_t poly2, unsigned long x) + void fmpz_poly_scalar_mul_ui(fmpz_poly_t poly1, const fmpz_poly_t poly2, ulong x) # Sets ``poly1`` to ``poly2`` times the ``ulong x``. - void fmpz_poly_scalar_mul_2exp(fmpz_poly_t poly1, const fmpz_poly_t poly2, unsigned long exp) + void fmpz_poly_scalar_mul_2exp(fmpz_poly_t poly1, const fmpz_poly_t poly2, ulong exp) # Sets ``poly1`` to ``poly2`` times ``2^exp``. - void fmpz_poly_scalar_addmul_si(fmpz_poly_t poly1, const fmpz_poly_t poly2, long x) + void fmpz_poly_scalar_addmul_si(fmpz_poly_t poly1, const fmpz_poly_t poly2, slong x) - void fmpz_poly_scalar_addmul_ui(fmpz_poly_t poly1, const fmpz_poly_t poly2, unsigned long x) + void fmpz_poly_scalar_addmul_ui(fmpz_poly_t poly1, const fmpz_poly_t poly2, ulong x) void fmpz_poly_scalar_addmul_fmpz(fmpz_poly_t poly1, const fmpz_poly_t poly2, const fmpz_t x) # Sets ``poly1`` to ``poly1 + x * poly2``. @@ -315,15 +315,15 @@ cdef extern from "flint_wrap.h": # Sets ``poly1`` to ``poly2`` divided by the ``fmpz_t x``, # rounding coefficients down toward `- \infty`. - void fmpz_poly_scalar_fdiv_si(fmpz_poly_t poly1, const fmpz_poly_t poly2, long x) + void fmpz_poly_scalar_fdiv_si(fmpz_poly_t poly1, const fmpz_poly_t poly2, slong x) # Sets ``poly1`` to ``poly2`` divided by the ``slong x``, # rounding coefficients down toward `- \infty`. - void fmpz_poly_scalar_fdiv_ui(fmpz_poly_t poly1, const fmpz_poly_t poly2, unsigned long x) + void fmpz_poly_scalar_fdiv_ui(fmpz_poly_t poly1, const fmpz_poly_t poly2, ulong x) # Sets ``poly1`` to ``poly2`` divided by the ``ulong x``, # rounding coefficients down toward `- \infty`. - void fmpz_poly_scalar_fdiv_2exp(fmpz_poly_t poly1, const fmpz_poly_t poly2, unsigned long x) + void fmpz_poly_scalar_fdiv_2exp(fmpz_poly_t poly1, const fmpz_poly_t poly2, ulong x) # Sets ``poly1`` to ``poly2`` divided by ``2^x``, # rounding coefficients down toward `- \infty`. @@ -331,15 +331,15 @@ cdef extern from "flint_wrap.h": # Sets ``poly1`` to ``poly2`` divided by the ``fmpz_t x``, # rounding coefficients toward `0`. - void fmpz_poly_scalar_tdiv_si(fmpz_poly_t poly1, const fmpz_poly_t poly2, long x) + void fmpz_poly_scalar_tdiv_si(fmpz_poly_t poly1, const fmpz_poly_t poly2, slong x) # Sets ``poly1`` to ``poly2`` divided by the ``slong x``, # rounding coefficients toward `0`. - void fmpz_poly_scalar_tdiv_ui(fmpz_poly_t poly1, const fmpz_poly_t poly2, unsigned long x) + void fmpz_poly_scalar_tdiv_ui(fmpz_poly_t poly1, const fmpz_poly_t poly2, ulong x) # Sets ``poly1`` to ``poly2`` divided by the ``ulong x``, # rounding coefficients toward `0`. - void fmpz_poly_scalar_tdiv_2exp(fmpz_poly_t poly1, const fmpz_poly_t poly2, unsigned long x) + void fmpz_poly_scalar_tdiv_2exp(fmpz_poly_t poly1, const fmpz_poly_t poly2, ulong x) # Sets ``poly1`` to ``poly2`` divided by ``2^x``, # rounding coefficients toward `0`. @@ -347,11 +347,11 @@ cdef extern from "flint_wrap.h": # Sets ``poly1`` to ``poly2`` divided by the ``fmpz_t x``, # assuming the division is exact for every coefficient. - void fmpz_poly_scalar_divexact_si(fmpz_poly_t poly1, const fmpz_poly_t poly2, long x) + void fmpz_poly_scalar_divexact_si(fmpz_poly_t poly1, const fmpz_poly_t poly2, slong x) # Sets ``poly1`` to ``poly2`` divided by the ``slong x``, # assuming the coefficient is exact for every coefficient. - void fmpz_poly_scalar_divexact_ui(fmpz_poly_t poly1, const fmpz_poly_t poly2, unsigned long x) + void fmpz_poly_scalar_divexact_ui(fmpz_poly_t poly1, const fmpz_poly_t poly2, ulong x) # Sets ``poly1`` to ``poly2`` divided by the ``ulong x``, # assuming the coefficient is exact for every coefficient. @@ -364,30 +364,30 @@ cdef extern from "flint_wrap.h": # each coefficient modulo `p > 0`, that is, choosing the unique # representative in the interval `(-p/2, p/2]`. - long _fmpz_poly_remove_content_2exp(fmpz * pol, long len) + slong _fmpz_poly_remove_content_2exp(fmpz * pol, slong len) # Remove the 2-content of ``pol`` and return the number `k` # that is the maximal non-negative integer so that `2^k` divides # all coefficients of the polynomial. For the zero polynomial, # `0` is returned. - void _fmpz_poly_scale_2exp(fmpz * pol, long len, long k) + void _fmpz_poly_scale_2exp(fmpz * pol, slong len, slong k) # Scale ``(pol, len)`` to `p(2^k X)` in-place and divide by the # 2-content (so that the gcd of coefficients is odd). If ``k`` # is negative the polynomial is multiplied by `2^{kd}`. - void _fmpz_poly_bit_pack(mp_ptr arr, const fmpz * poly, long len, flint_bitcnt_t bit_size, int negate) + void _fmpz_poly_bit_pack(mp_ptr arr, const fmpz * poly, slong len, flint_bitcnt_t bit_size, int negate) # Packs the coefficients of ``poly`` into bitfields of the given # ``bit_size``, negating the coefficients before packing # if ``negate`` is set to `-1`. - int _fmpz_poly_bit_unpack(fmpz * poly, long len, mp_srcptr arr, flint_bitcnt_t bit_size, int negate) + int _fmpz_poly_bit_unpack(fmpz * poly, slong len, mp_srcptr arr, flint_bitcnt_t bit_size, int negate) # Unpacks the polynomial of given length from the array as packed into # fields of the given ``bit_size``, finally negating the coefficients # if ``negate`` is set to `-1`. Returns borrow, which is nonzero if a # leading term with coefficient `\pm1` should be added at # position ``len`` of ``poly``. - void _fmpz_poly_bit_unpack_unsigned(fmpz * poly, long len, mp_srcptr arr, flint_bitcnt_t bit_size) + void _fmpz_poly_bit_unpack_unsigned(fmpz * poly, slong len, mp_srcptr arr, flint_bitcnt_t bit_size) # Unpacks the polynomial of given length from the array as packed into # fields of the given ``bit_size``. The coefficients are assumed to # be unsigned. @@ -406,7 +406,7 @@ cdef extern from "flint_wrap.h": # fields of size ``bit_size`` as represented by the integer ``f``. # It is required that ``f`` is nonnegative. - void _fmpz_poly_mul_classical(fmpz * res, const fmpz * poly1, long len1, const fmpz * poly2, long len2) + void _fmpz_poly_mul_classical(fmpz * res, const fmpz * poly1, slong len1, const fmpz * poly2, slong len2) # Sets ``(res, len1 + len2 - 1)`` to the product of ``(poly1, len1)`` # and ``(poly2, len2)``. # Assumes ``len1`` and ``len2`` are positive. Allows zero-padding @@ -417,28 +417,28 @@ cdef extern from "flint_wrap.h": # Sets ``res`` to the product of ``poly1`` and ``poly2``, computed # using the classical or schoolbook method. - void _fmpz_poly_mullow_classical(fmpz * res, const fmpz * poly1, long len1, const fmpz * poly2, long len2, long n) + void _fmpz_poly_mullow_classical(fmpz * res, const fmpz * poly1, slong len1, const fmpz * poly2, slong len2, slong n) # Sets ``(res, n)`` to the first `n` coefficients of ``(poly1, len1)`` # multiplied by ``(poly2, len2)``. # Assumes ``0 < n <= len1 + len2 - 1``. Assumes neither ``len1`` nor # ``len2`` is zero. - void fmpz_poly_mullow_classical(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2, long n) + void fmpz_poly_mullow_classical(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2, slong n) # Sets ``res`` to the first `n` coefficients of ``poly1 * poly2``. - void _fmpz_poly_mulhigh_classical(fmpz * res, const fmpz * poly1, long len1, const fmpz * poly2, long len2, long start) + void _fmpz_poly_mulhigh_classical(fmpz * res, const fmpz * poly1, slong len1, const fmpz * poly2, slong len2, slong start) # Sets the first ``start`` coefficients of ``res`` to zero and the # remainder to the corresponding coefficients of # ``(poly1, len1) * (poly2, len2)``. # Assumes ``start <= len1 + len2 - 1``. Assumes neither ``len1`` nor # ``len2`` is zero. - void fmpz_poly_mulhigh_classical(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2, long start) + void fmpz_poly_mulhigh_classical(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2, slong start) # Sets the first ``start`` coefficients of ``res`` to zero and the # remainder to the corresponding coefficients of the product of ``poly1`` # and ``poly2``. - void _fmpz_poly_mulmid_classical(fmpz * res, const fmpz * poly1, long len1, const fmpz * poly2, long len2) + void _fmpz_poly_mulmid_classical(fmpz * res, const fmpz * poly1, slong len1, const fmpz * poly2, slong len2) # Sets ``res`` to the middle ``len1 - len2 + 1`` coefficients of # the product of ``(poly1, len1)`` and ``(poly2, len2)``, i.e. the # coefficients from degree ``len2 - 1`` to ``len1 - 1`` inclusive. @@ -450,7 +450,7 @@ cdef extern from "flint_wrap.h": # ``len2 - 1`` to ``len1 - 1`` inclusive. Assumes that # ``len1 >= len2``. - void _fmpz_poly_mul_karatsuba(fmpz * res, const fmpz * poly1, long len1, const fmpz * poly2, long len2) + void _fmpz_poly_mul_karatsuba(fmpz * res, const fmpz * poly1, slong len1, const fmpz * poly2, slong len2) # Sets ``(res, len1 + len2 - 1)`` to the product of ``(poly1, len1)`` # and ``(poly2, len2)``. Assumes ``len1 >= len2 > 0``. Allows # zero-padding of the two input polynomials. No aliasing of inputs with @@ -459,30 +459,30 @@ cdef extern from "flint_wrap.h": void fmpz_poly_mul_karatsuba(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2) # Sets ``res`` to the product of ``poly1`` and ``poly2``. - void _fmpz_poly_mullow_karatsuba_n(fmpz * res, const fmpz * poly1, const fmpz * poly2, long n) + void _fmpz_poly_mullow_karatsuba_n(fmpz * res, const fmpz * poly1, const fmpz * poly2, slong n) # Sets ``res`` to the product of ``poly1`` and ``poly2`` and # truncates to the given length. It is assumed that ``poly1`` and # ``poly2`` are precisely the given length, possibly zero padded. # Assumes `n` is not zero. - void fmpz_poly_mullow_karatsuba_n(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2, long n) + void fmpz_poly_mullow_karatsuba_n(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2, slong n) # Sets ``res`` to the product of ``poly1`` and ``poly2`` and # truncates to the given length. - void _fmpz_poly_mulhigh_karatsuba_n(fmpz * res, const fmpz * poly1, const fmpz * poly2, long len) + void _fmpz_poly_mulhigh_karatsuba_n(fmpz * res, const fmpz * poly1, const fmpz * poly2, slong len) # Sets ``res`` to the product of ``poly1`` and ``poly2`` and # truncates at the top to the given length. The first ``len - 1`` # coefficients are set to zero. It is assumed that ``poly1`` and # ``poly2`` are precisely the given length, possibly zero padded. # Assumes ``len`` is not zero. - void fmpz_poly_mulhigh_karatsuba_n(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2, long len) + void fmpz_poly_mulhigh_karatsuba_n(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2, slong len) # Sets the first ``len - 1`` coefficients of the result to zero and the # remaining coefficients to the corresponding coefficients of the product of # ``poly1`` and ``poly2``. Assumes ``poly1`` and ``poly2`` are # at most of the given length. - void _fmpz_poly_mul_KS(fmpz * res, const fmpz * poly1, long len1, const fmpz * poly2, long len2) + void _fmpz_poly_mul_KS(fmpz * res, const fmpz * poly1, slong len1, const fmpz * poly2, slong len2) # Sets ``(res, len1 + len2 - 1)`` to the product of ``(poly1, len1)`` # and ``(poly2, len2)``. # Places no assumptions on ``len1`` and ``len2``. Allows zero-padding @@ -491,7 +491,7 @@ cdef extern from "flint_wrap.h": void fmpz_poly_mul_KS(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2) # Sets ``res`` to the product of ``poly1`` and ``poly2``. - void _fmpz_poly_mullow_KS(fmpz * res, const fmpz * poly1, long len1, const fmpz * poly2, long len2, long n) + void _fmpz_poly_mullow_KS(fmpz * res, const fmpz * poly1, slong len1, const fmpz * poly2, slong len2, slong n) # Sets ``(res, n)`` to the lowest `n` coefficients of the product of # ``(poly1, len1)`` and ``(poly2, len2)``. # Assumes that ``len1`` and ``len2`` are positive, but does allow @@ -499,11 +499,11 @@ cdef extern from "flint_wrap.h": # too. Assumes `n` is positive. Supports aliasing between ``res``, # ``poly1`` and ``poly2``. - void fmpz_poly_mullow_KS(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2, long n) + void fmpz_poly_mullow_KS(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2, slong n) # Sets ``res`` to the lowest `n` coefficients of the product of # ``poly1`` and ``poly2``. - void _fmpz_poly_mul_SS(fmpz * output, const fmpz * input1, long length1, const fmpz * input2, long length2) + void _fmpz_poly_mul_SS(fmpz * output, const fmpz * input1, slong length1, const fmpz * input2, slong length2) # Sets ``(output, length1 + length2 - 1)`` to the product of # ``(input1, length1)`` and ``(input2, length2)``. # We must have ``len1 > 1`` and ``len2 > 1``. Allows zero-padding @@ -513,7 +513,7 @@ cdef extern from "flint_wrap.h": # Sets ``res`` to the product of ``poly1`` and ``poly2``. Uses the # Schönhage-Strassen algorithm. - void _fmpz_poly_mullow_SS(fmpz * output, const fmpz * input1, long length1, const fmpz * input2, long length2, long n) + void _fmpz_poly_mullow_SS(fmpz * output, const fmpz * input1, slong length1, const fmpz * input2, slong length2, slong n) # Sets ``(res, n)`` to the lowest `n` coefficients of the product of # ``(poly1, len1)`` and ``(poly2, len2)``. # Assumes that ``len1`` and ``len2`` are positive, but does allow @@ -521,11 +521,11 @@ cdef extern from "flint_wrap.h": # and ``len2 > 1``. Assumes `n` is positive. Supports aliasing between # ``res``, ``poly1`` and ``poly2``. - void fmpz_poly_mullow_SS(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2, long n) + void fmpz_poly_mullow_SS(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2, slong n) # Sets ``res`` to the lowest `n` coefficients of the product of # ``poly1`` and ``poly2``. - void _fmpz_poly_mul(fmpz * res, const fmpz * poly1, long len1, const fmpz * poly2, long len2) + void _fmpz_poly_mul(fmpz * res, const fmpz * poly1, slong len1, const fmpz * poly2, slong len2) # Sets ``(res, len1 + len2 - 1)`` to the product of ``(poly1, len1)`` # and ``(poly2, len2)``. Assumes ``len1 >= len2 > 0``. Allows # zero-padding of the two input polynomials. Does not support aliasing @@ -535,31 +535,31 @@ cdef extern from "flint_wrap.h": # Sets ``res`` to the product of ``poly1`` and ``poly2``. Chooses # an optimal algorithm from the choices above. - void _fmpz_poly_mullow(fmpz * res, const fmpz * poly1, long len1, const fmpz * poly2, long len2, long n) + void _fmpz_poly_mullow(fmpz * res, const fmpz * poly1, slong len1, const fmpz * poly2, slong len2, slong n) # Sets ``(res, n)`` to the lowest `n` coefficients of the product of # ``(poly1, len1)`` and ``(poly2, len2)``. # Assumes ``len1 >= len2 > 0`` and ``0 < n <= len1 + len2 - 1``. # Allows for zero-padding in the inputs. Does not support aliasing between # the inputs and the output. - void fmpz_poly_mullow(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2, long n) + void fmpz_poly_mullow(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2, slong n) # Sets ``res`` to the lowest `n` coefficients of the product of # ``poly1`` and ``poly2``. - void fmpz_poly_mulhigh_n(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2, long n) + void fmpz_poly_mulhigh_n(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2, slong n) # Sets the high `n` coefficients of ``res`` to the high `n` coefficients # of the product of ``poly1`` and ``poly2``, assuming the latter are # precisely `n` coefficients in length, zero padded if necessary. The # remaining `n - 1` coefficients may be arbitrary. - void _fmpz_poly_mulhigh(fmpz * res, const fmpz * poly1, long len1, const fmpz * poly2, long len2, long start) + void _fmpz_poly_mulhigh(fmpz * res, const fmpz * poly1, slong len1, const fmpz * poly2, slong len2, slong start) # Sets all but the low `n` coefficients of `res` to the corresponding # coefficients of the product of `poly1` of length `len1` and `poly2` of # length `len2`, the remaining coefficients being arbitrary. It is assumed # that `len1 >= len2 > 0` and that `0 < n < len1 + len2 - 1`. Aliasing of # inputs is not permitted. - void fmpz_poly_mul_SS_precache_init(fmpz_poly_mul_precache_t pre, long len1, long bits1, const fmpz_poly_t poly2) + void fmpz_poly_mul_SS_precache_init(fmpz_poly_mul_precache_t pre, slong len1, slong bits1, const fmpz_poly_t poly2) # Precompute the FFT of ``poly2`` to enable repeated multiplication of # ``poly2`` by polynomials whose length does not exceed ``len1`` and # whose number of bits per coefficient does not exceed ``bits1``. @@ -584,14 +584,14 @@ cdef extern from "flint_wrap.h": void fmpz_poly_mul_precache_clear(fmpz_poly_mul_precache_t pre) # Clear the space allocated by ``fmpz_poly_mul_SS_precache_init``. - void _fmpz_poly_mullow_SS_precache(fmpz * output, const fmpz * input1, long len1, fmpz_poly_mul_precache_t pre, long trunc) + void _fmpz_poly_mullow_SS_precache(fmpz * output, const fmpz * input1, slong len1, fmpz_poly_mul_precache_t pre, slong trunc) # Write into ``output`` the first ``trunc`` coefficients of # the polynomial ``(input1, len1)`` by the polynomial whose FFT was precached # by ``fmpz_poly_mul_SS_precache_init`` and stored in ``pre``. # For performance reasons it is recommended that all polynomials be truncated # to at most ``trunc`` coefficients if possible. - void fmpz_poly_mullow_SS_precache(fmpz_poly_t res, const fmpz_poly_t poly1, fmpz_poly_mul_precache_t pre, long n) + void fmpz_poly_mullow_SS_precache(fmpz_poly_t res, const fmpz_poly_t poly1, fmpz_poly_mul_precache_t pre, slong n) # Set ``res`` to the product of ``poly1`` by the polynomial whose FFT was # precached by ``fmpz_poly_mul_SS_precache_init`` (and stored in pre). The # result is truncated to `n` coefficients (and normalised). @@ -604,7 +604,7 @@ cdef extern from "flint_wrap.h": # There are no restrictions on the length of ``poly1`` other than those given # in the call to ``fmpz_poly_mul_SS_precache_init``. - void _fmpz_poly_sqr_KS(fmpz * rop, const fmpz * op, long len) + void _fmpz_poly_sqr_KS(fmpz * rop, const fmpz * op, slong len) # Sets ``(rop, 2*len - 1)`` to the square of ``(op, len)``, # assuming that ``len > 0``. # Supports zero-padding in ``(op, len)``. Does not support aliasing. @@ -613,7 +613,7 @@ cdef extern from "flint_wrap.h": # Sets ``rop`` to the square of the polynomial ``op`` using # Kronecker segmentation. - void _fmpz_poly_sqr_karatsuba(fmpz * rop, const fmpz * op, long len) + void _fmpz_poly_sqr_karatsuba(fmpz * rop, const fmpz * op, slong len) # Sets ``(rop, 2*len - 1)`` to the square of ``(op, len)``, # assuming that ``len > 0``. # Supports zero-padding in ``(op, len)``. Does not support aliasing. @@ -622,7 +622,7 @@ cdef extern from "flint_wrap.h": # Sets ``rop`` to the square of the polynomial ``op`` using # the Karatsuba multiplication algorithm. - void _fmpz_poly_sqr_classical(fmpz * rop, const fmpz * op, long len) + void _fmpz_poly_sqr_classical(fmpz * rop, const fmpz * op, slong len) # Sets ``(rop, 2*len - 1)`` to the square of ``(op, len)``, # assuming that ``len > 0``. # Supports zero-padding in ``(op, len)``. Does not support aliasing. @@ -631,7 +631,7 @@ cdef extern from "flint_wrap.h": # Sets ``rop`` to the square of the polynomial ``op`` using # the classical or schoolbook method. - void _fmpz_poly_sqr(fmpz * rop, const fmpz * op, long len) + void _fmpz_poly_sqr(fmpz * rop, const fmpz * op, slong len) # Sets ``(rop, 2*len - 1)`` to the square of ``(op, len)``, # assuming that ``len > 0``. # Supports zero-padding in ``(op, len)``. Does not support aliasing. @@ -639,47 +639,47 @@ cdef extern from "flint_wrap.h": void fmpz_poly_sqr(fmpz_poly_t rop, const fmpz_poly_t op) # Sets ``rop`` to the square of the polynomial ``op``. - void _fmpz_poly_sqrlow_KS(fmpz * res, const fmpz * poly, long len, long n) + void _fmpz_poly_sqrlow_KS(fmpz * res, const fmpz * poly, slong len, slong n) # Sets ``(res, n)`` to the lowest `n` coefficients # of the square of ``(poly, len)``. # Assumes that ``len`` is positive, but does allow for the polynomial # to be zero-padded. The polynomial may be zero, too. Assumes `n` is # positive. Supports aliasing between ``res`` and ``poly``. - void fmpz_poly_sqrlow_KS(fmpz_poly_t res, const fmpz_poly_t poly, long n) + void fmpz_poly_sqrlow_KS(fmpz_poly_t res, const fmpz_poly_t poly, slong n) # Sets ``res`` to the lowest `n` coefficients # of the square of ``poly``. - void _fmpz_poly_sqrlow_karatsuba_n(fmpz * res, const fmpz * poly, long n) + void _fmpz_poly_sqrlow_karatsuba_n(fmpz * res, const fmpz * poly, slong n) # Sets ``(res, n)`` to the square of ``(poly, n)`` truncated # to length `n`, which is assumed to be positive. Allows for ``poly`` # to be zero-padded. - void fmpz_poly_sqrlow_karatsuba_n(fmpz_poly_t res, const fmpz_poly_t poly, long n) + void fmpz_poly_sqrlow_karatsuba_n(fmpz_poly_t res, const fmpz_poly_t poly, slong n) # Sets ``res`` to the square of ``poly`` and # truncates to the given length. - void _fmpz_poly_sqrlow_classical(fmpz * res, const fmpz * poly, long len, long n) + void _fmpz_poly_sqrlow_classical(fmpz * res, const fmpz * poly, slong len, slong n) # Sets ``(res, n)`` to the first `n` coefficients of the square # of ``(poly, len)``. # Assumes that ``0 < n <= 2 * len - 1``. - void fmpz_poly_sqrlow_classical(fmpz_poly_t res, const fmpz_poly_t poly, long n) + void fmpz_poly_sqrlow_classical(fmpz_poly_t res, const fmpz_poly_t poly, slong n) # Sets ``res`` to the first `n` coefficients of # the square of ``poly``. - void _fmpz_poly_sqrlow(fmpz * res, const fmpz * poly, long len, long n) + void _fmpz_poly_sqrlow(fmpz * res, const fmpz * poly, slong len, slong n) # Sets ``(res, n)`` to the lowest `n` coefficients # of the square of ``(poly, len)``. # Assumes ``len1 >= len2 > 0`` and ``0 < n <= 2 * len - 1``. # Allows for zero-padding in the input. Does not support aliasing # between the input and the output. - void fmpz_poly_sqrlow(fmpz_poly_t res, const fmpz_poly_t poly, long n) + void fmpz_poly_sqrlow(fmpz_poly_t res, const fmpz_poly_t poly, slong n) # Sets ``res`` to the lowest `n` coefficients # of the square of ``poly``. - void _fmpz_poly_pow_multinomial(fmpz * res, const fmpz * poly, long len, unsigned long e) + void _fmpz_poly_pow_multinomial(fmpz * res, const fmpz * poly, slong len, ulong e) # Computes ``res = poly^e``. This uses the J.C.P. Miller pure # recurrence as follows: # If `\ell` is the index of the lowest non-zero coefficient in ``poly``, @@ -688,7 +688,7 @@ cdef extern from "flint_wrap.h": # coefficients. # Assumes ``len > 0``, ``e > 0``. Does not support aliasing. - void fmpz_poly_pow_multinomial(fmpz_poly_t res, const fmpz_poly_t poly, unsigned long e) + void fmpz_poly_pow_multinomial(fmpz_poly_t res, const fmpz_poly_t poly, ulong e) # Computes ``res = poly^e`` using a generalisation of binomial expansion # called the J.C.P. Miller pure recurrence [1], [2]. # If `e` is zero, returns one, so that in particular ``0^0 = 1``. @@ -707,17 +707,17 @@ cdef extern from "flint_wrap.h": # Polynomial, and its q-Analog, Journal of Difference Equations and # Applications, 1995, Vol. 1, pp. 57--60 - void _fmpz_poly_pow_binomial(fmpz * res, const fmpz * poly, unsigned long e) + void _fmpz_poly_pow_binomial(fmpz * res, const fmpz * poly, ulong e) # Computes ``res = poly^e`` when poly is of length 2, using binomial # expansion. # Assumes `e > 0`. Does not support aliasing. - void fmpz_poly_pow_binomial(fmpz_poly_t res, const fmpz_poly_t poly, unsigned long e) + void fmpz_poly_pow_binomial(fmpz_poly_t res, const fmpz_poly_t poly, ulong e) # Computes ``res = poly^e`` when ``poly`` is of length `2`, using # binomial expansion. # If the length of ``poly`` is not `2`, raises an exception and aborts. - void _fmpz_poly_pow_addchains(fmpz * res, const fmpz * poly, long len, const int * a, int n) + void _fmpz_poly_pow_addchains(fmpz * res, const fmpz * poly, slong len, const int * a, int n) # Given a star chain `1 = a_0 < a_1 < \dotsb < a_n = e` computes # ``res = poly^e``. # A star chain is an addition chain `1 = a_0 < a_1 < \dotsb < a_n` such @@ -725,43 +725,43 @@ cdef extern from "flint_wrap.h": # Assumes that `e > 2`, or equivalently `n > 1`, and ``len > 0``. Does # not support aliasing. - void fmpz_poly_pow_addchains(fmpz_poly_t res, const fmpz_poly_t poly, unsigned long e) + void fmpz_poly_pow_addchains(fmpz_poly_t res, const fmpz_poly_t poly, ulong e) # Computes ``res = poly^e`` using addition chains whenever # `0 \leq e \leq 148`. # If `e > 148`, raises an exception and aborts. - void _fmpz_poly_pow_binexp(fmpz * res, const fmpz * poly, long len, unsigned long e) + void _fmpz_poly_pow_binexp(fmpz * res, const fmpz * poly, slong len, ulong e) # Sets ``res = poly^e`` using left-to-right binary exponentiation as # described on p. 461 of [Knu1997]_. # Assumes that ``len > 0``, ``e > 1``. Assumes that ``res`` is # an array of length at least ``e*(len - 1) + 1``. Does not support # aliasing. - void fmpz_poly_pow_binexp(fmpz_poly_t res, const fmpz_poly_t poly, unsigned long e) + void fmpz_poly_pow_binexp(fmpz_poly_t res, const fmpz_poly_t poly, ulong e) # Computes ``res = poly^e`` using the binary exponentiation algorithm. # If `e` is zero, returns one, so that in particular ``0^0 = 1``. - void _fmpz_poly_pow_small(fmpz * res, const fmpz * poly, long len, unsigned long e) + void _fmpz_poly_pow_small(fmpz * res, const fmpz * poly, slong len, ulong e) # Sets ``res = poly^e`` whenever `0 \leq e \leq 4`. # Assumes that ``len > 0`` and that ``res`` is an array of length # at least ``e*(len - 1) + 1``. Does not support aliasing. - void _fmpz_poly_pow(fmpz * res, const fmpz * poly, long len, unsigned long e) + void _fmpz_poly_pow(fmpz * res, const fmpz * poly, slong len, ulong e) # Sets ``res = poly^e``, assuming that ``e, len > 0`` and that # ``res`` has space for ``e*(len - 1) + 1`` coefficients. Does # not support aliasing. - void fmpz_poly_pow(fmpz_poly_t res, const fmpz_poly_t poly, unsigned long e) + void fmpz_poly_pow(fmpz_poly_t res, const fmpz_poly_t poly, ulong e) # Computes ``res = poly^e``. If `e` is zero, returns one, # so that in particular ``0^0 = 1``. - void _fmpz_poly_pow_trunc(fmpz * res, const fmpz * poly, unsigned long e, long n) + void _fmpz_poly_pow_trunc(fmpz * res, const fmpz * poly, ulong e, slong n) # Sets ``(res, n)`` to ``(poly, n)`` raised to the power `e` and # truncated to length `n`. # Assumes that `e, n > 0`. Allows zero-padding of ``(poly, n)``. # Does not support aliasing of any inputs and outputs. - void fmpz_poly_pow_trunc(fmpz_poly_t res, const fmpz_poly_t poly, unsigned long e, long n) + void fmpz_poly_pow_trunc(fmpz_poly_t res, const fmpz_poly_t poly, ulong e, slong n) # Notationally raises ``poly`` to the power `e`, truncates the result # to length `n` and writes the result in ``res``. This is computed # much more efficiently than simply powering the polynomial and truncating. @@ -770,18 +770,18 @@ cdef extern from "flint_wrap.h": # This function can be used to raise power series to a power in an # efficient way. - void _fmpz_poly_shift_left(fmpz * res, const fmpz * poly, long len, long n) + void _fmpz_poly_shift_left(fmpz * res, const fmpz * poly, slong len, slong n) # Sets ``(res, len + n)`` to ``(poly, len)`` shifted left by # `n` coefficients. # Inserts zero coefficients at the lower end. Assumes that ``len`` # and `n` are positive, and that ``res`` fits ``len + n`` elements. # Supports aliasing between ``res`` and ``poly``. - void fmpz_poly_shift_left(fmpz_poly_t res, const fmpz_poly_t poly, long n) + void fmpz_poly_shift_left(fmpz_poly_t res, const fmpz_poly_t poly, slong n) # Sets ``res`` to ``poly`` shifted left by `n` coeffs. Zero # coefficients are inserted. - void _fmpz_poly_shift_right(fmpz * res, const fmpz * poly, long len, long n) + void _fmpz_poly_shift_right(fmpz * res, const fmpz * poly, slong len, slong n) # Sets ``(res, len - n)`` to ``(poly, len)`` shifted right by # `n` coefficients. # Assumes that ``len`` and `n` are positive, that ``len > n``, @@ -789,16 +789,16 @@ cdef extern from "flint_wrap.h": # between ``res`` and ``poly``, although in this case the top # coefficients of ``poly`` are not set to zero. - void fmpz_poly_shift_right(fmpz_poly_t res, const fmpz_poly_t poly, long n) + void fmpz_poly_shift_right(fmpz_poly_t res, const fmpz_poly_t poly, slong n) # Sets ``res`` to ``poly`` shifted right by `n` coefficients. If `n` # is equal to or greater than the current length of ``poly``, ``res`` # is set to the zero polynomial. - unsigned long fmpz_poly_max_limbs(const fmpz_poly_t poly) + ulong fmpz_poly_max_limbs(const fmpz_poly_t poly) # Returns the maximum number of limbs required to store the absolute value # of coefficients of ``poly``. If ``poly`` is zero, returns `0`. - long fmpz_poly_max_bits(const fmpz_poly_t poly) + slong fmpz_poly_max_bits(const fmpz_poly_t poly) # Computes the maximum number of bits `b` required to store the absolute # value of coefficients of ``poly``. If all the coefficients of # ``poly`` are non-negative, `b` is returned, otherwise `-b` is returned. @@ -809,7 +809,7 @@ cdef extern from "flint_wrap.h": # gives the infinity norm of the coefficients. If ``poly`` is zero, # the height is `0`. - void _fmpz_poly_2norm(fmpz_t res, const fmpz * poly, long len) + void _fmpz_poly_2norm(fmpz_t res, const fmpz * poly, slong len) # Sets ``res`` to the Euclidean norm of ``(poly, len)``, that is, # the integer square root of the sum of the squares of the coefficients # of ``poly``. @@ -819,7 +819,7 @@ cdef extern from "flint_wrap.h": # integer square root of the sum of the squares of the coefficients of # ``poly``. - mp_limb_t _fmpz_poly_2norm_normalised_bits(const fmpz * poly, long len) + mp_limb_t _fmpz_poly_2norm_normalised_bits(const fmpz * poly, slong len) # Returns an upper bound on the number of bits of the normalised # Euclidean norm of ``(poly, len)``, i.e. the number of bits of # the Euclidean norm divided by the absolute value of the leading @@ -829,7 +829,7 @@ cdef extern from "flint_wrap.h": # It is assumed that ``len > 0``. The result only makes sense # if the leading coefficient is nonzero. - void _fmpz_poly_gcd_subresultant(fmpz * res, const fmpz * poly1, long len1, const fmpz * poly2, long len2) + void _fmpz_poly_gcd_subresultant(fmpz * res, const fmpz * poly1, slong len1, const fmpz * poly2, slong len2) # Computes the greatest common divisor ``(res, len2)`` of # ``(poly1, len1)`` and ``(poly2, len2)``, assuming # ``len1 >= len2 > 0``. The result is normalised to have @@ -842,7 +842,7 @@ cdef extern from "flint_wrap.h": # This function uses the subresultant algorithm as described # in Algorithm 3.3.1 of [Coh1996]_. - int _fmpz_poly_gcd_heuristic(fmpz * res, const fmpz * poly1, long len1, const fmpz * poly2, long len2) + int _fmpz_poly_gcd_heuristic(fmpz * res, const fmpz * poly1, slong len1, const fmpz * poly2, slong len2) # Computes the greatest common divisor ``(res, len2)`` of # ``(poly1, len1)`` and ``(poly2, len2)``, assuming # ``len1 >= len2 > 0``. The result is normalised to have @@ -862,7 +862,7 @@ cdef extern from "flint_wrap.h": # coefficients of the GCD) and take the integer GCD. Unpack the # result and test divisibility. - void _fmpz_poly_gcd_modular(fmpz * res, const fmpz * poly1, long len1, const fmpz * poly2, long len2) + void _fmpz_poly_gcd_modular(fmpz * res, const fmpz * poly1, slong len1, const fmpz * poly2, slong len2) # Computes the greatest common divisor ``(res, len2)`` of # ``(poly1, len1)`` and ``(poly2, len2)``, assuming # ``len1 >= len2 > 0``. The result is normalised to have @@ -878,7 +878,7 @@ cdef extern from "flint_wrap.h": # some bound is reached (or we can prove with trial division that # we have the GCD). - void _fmpz_poly_gcd(fmpz * res, const fmpz * poly1, long len1, const fmpz * poly2, long len2) + void _fmpz_poly_gcd(fmpz * res, const fmpz * poly1, slong len1, const fmpz * poly2, slong len2) # Computes the greatest common divisor ``res`` of ``(poly1, len1)`` # and ``(poly2, len2)``, assuming ``len1 >= len2 > 0``. The result # is normalised to have positive leading coefficient. @@ -890,7 +890,7 @@ cdef extern from "flint_wrap.h": # Computes the greatest common divisor ``res`` of ``poly1`` and # ``poly2``, normalised to have non-negative leading coefficient. - void _fmpz_poly_xgcd_modular(fmpz_t r, fmpz * s, fmpz * t, const fmpz * f, long len1, const fmpz * g, long len2) + void _fmpz_poly_xgcd_modular(fmpz_t r, fmpz * s, fmpz * t, const fmpz * f, slong len1, const fmpz * g, slong len2) # Set `r` to the resultant of ``(f, len1)`` and ``(g, len2)``. # If the resultant is zero, the function returns immediately. Otherwise it # finds polynomials `s` and `t` such that ``s*f + t*g = r``. The length @@ -913,7 +913,7 @@ cdef extern from "flint_wrap.h": # equal to 1). The result is undefined otherwise. # Uses the multimodular algorithm. - void _fmpz_poly_xgcd(fmpz_t r, fmpz * s, fmpz * t, const fmpz * f, long len1, const fmpz * g, long len2) + void _fmpz_poly_xgcd(fmpz_t r, fmpz * s, fmpz * t, const fmpz * f, slong len1, const fmpz * g, slong len2) # Set `r` to the resultant of ``(f, len1)`` and ``(g, len2)``. # If the resultant is zero, the function returns immediately. Otherwise it # finds polynomials `s` and `t` such that ``s*f + t*g = r``. The length @@ -931,7 +931,7 @@ cdef extern from "flint_wrap.h": # The function assumes that `f` and `g` are primitive (have Gaussian content # equal to 1). The result is undefined otherwise. - void _fmpz_poly_lcm(fmpz * res, const fmpz * poly1, long len1, const fmpz * poly2, long len2) + void _fmpz_poly_lcm(fmpz * res, const fmpz * poly1, slong len1, const fmpz * poly2, slong len2) # Sets ``(res, len1 + len2 - 1)`` to the least common multiple # of the two polynomials ``(poly1, len1)`` and ``(poly2, len2)``, # normalised to have non-negative leading coefficient. @@ -949,7 +949,7 @@ cdef extern from "flint_wrap.h": # f g = \gcd(f, g) \operatorname{lcm}(f, g) # holds up to sign. - void _fmpz_poly_resultant_modular(fmpz_t res, const fmpz * poly1, long len1, const fmpz * poly2, long len2) + void _fmpz_poly_resultant_modular(fmpz_t res, const fmpz * poly1, slong len1, const fmpz * poly2, slong len2) # Sets ``res`` to the resultant of ``(poly1, len1)`` and # ``(poly2, len2)``, assuming that ``len1 >= len2 > 0``. @@ -965,14 +965,14 @@ cdef extern from "flint_wrap.h": # This function uses the modular algorithm described # in [Col1971]_. - void fmpz_poly_resultant_modular_div(fmpz_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2, const fmpz_t div, long nbits) + void fmpz_poly_resultant_modular_div(fmpz_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2, const fmpz_t div, slong nbits) # Computes the resultant of ``poly1`` and ``poly2`` divided by # ``div`` using a slight modification of the above function. It is assumed that # the resultant is exactly divisible by ``div`` and the result ``res`` # has at most ``nbits`` bits. # This bypasses the computation of general bounds. - void _fmpz_poly_resultant_euclidean(fmpz_t res, const fmpz * poly1, long len1, const fmpz * poly2, long len2) + void _fmpz_poly_resultant_euclidean(fmpz_t res, const fmpz * poly1, slong len1, const fmpz * poly2, slong len2) # Sets ``res`` to the resultant of ``(poly1, len1)`` and # ``(poly2, len2)``, assuming that ``len1 >= len2 > 0``. @@ -988,7 +988,7 @@ cdef extern from "flint_wrap.h": # This function uses the algorithm described # in Algorithm 3.3.7 of [Coh1996]_. - void _fmpz_poly_resultant(fmpz_t res, const fmpz * poly1, long len1, const fmpz * poly2, long len2) + void _fmpz_poly_resultant(fmpz_t res, const fmpz * poly1, slong len1, const fmpz * poly2, slong len2) # Sets ``res`` to the resultant of ``(poly1, len1)`` and # ``(poly2, len2)``, assuming that ``len1 >= len2 > 0``. @@ -1002,7 +1002,7 @@ cdef extern from "flint_wrap.h": # For convenience, we define the resultant to be equal to zero if either # of the two polynomials is zero. - void _fmpz_poly_discriminant(fmpz_t res, const fmpz * poly, long len) + void _fmpz_poly_discriminant(fmpz_t res, const fmpz * poly, slong len) # Set ``res`` to the discriminant of ``(poly, len)``. Assumes # ``len > 1``. @@ -1014,7 +1014,7 @@ cdef extern from "flint_wrap.h": # - r_j)^2`, where `\operatorname{lc}(f)` is the leading coefficient of `f`, # `n` is the degree of `f` and `r_i` are the roots of `f`. - void _fmpz_poly_content(fmpz_t res, const fmpz * poly, long len) + void _fmpz_poly_content(fmpz_t res, const fmpz * poly, slong len) # Sets ``res`` to the non-negative content of ``(poly, len)``. # Aliasing between ``res`` and the coefficients of ``poly`` is # not supported. @@ -1024,7 +1024,7 @@ cdef extern from "flint_wrap.h": # of the zero polynomial is defined to be zero. Supports aliasing, that is, # ``res`` is allowed to be one of the coefficients of ``poly``. - void _fmpz_poly_primitive_part(fmpz * res, const fmpz * poly, long len) + void _fmpz_poly_primitive_part(fmpz * res, const fmpz * poly, slong len) # Sets ``(res, len)`` to ``(poly, len)`` divided by the content # of ``(poly, len)``, and normalises the result to have non-negative # leading coefficient. @@ -1036,7 +1036,7 @@ cdef extern from "flint_wrap.h": # and normalises the result to have non-negative leading coefficient. # If ``poly`` is zero, sets ``res`` to zero. - int _fmpz_poly_is_squarefree(const fmpz * poly, long len) + int _fmpz_poly_is_squarefree(const fmpz * poly, slong len) # Returns whether the polynomial ``(poly, len)`` is square-free. int fmpz_poly_is_squarefree(const fmpz_poly_t poly) @@ -1048,7 +1048,7 @@ cdef extern from "flint_wrap.h": # whether the greatest common divisor of ``poly`` and its derivative has # length `1`. - int _fmpz_poly_divrem_basecase(fmpz * Q, fmpz * R, const fmpz * A, long lenA, const fmpz * B, long lenB, int exact) + int _fmpz_poly_divrem_basecase(fmpz * Q, fmpz * R, const fmpz * A, slong lenA, const fmpz * B, slong lenB, int exact) # Computes ``(Q, lenA - lenB + 1)``, ``(R, lenA)`` such that # `A = B Q + R` and each coefficient of `R` beyond ``lenB`` is reduced # modulo the leading coefficient of `B`. @@ -1073,7 +1073,7 @@ cdef extern from "flint_wrap.h": # this is the same thing as division over `\mathbb{Q}`. An exception is raised # if `B` is zero. - int _fmpz_poly_divrem_divconquer_recursive(fmpz * Q, fmpz * BQ, fmpz * W, const fmpz * A, const fmpz * B, long lenB, int exact) + int _fmpz_poly_divrem_divconquer_recursive(fmpz * Q, fmpz * BQ, fmpz * W, const fmpz * A, const fmpz * B, slong lenB, int exact) # Computes ``(Q, lenB)``, ``(BQ, 2 lenB - 1)`` such that # `BQ = B \times Q` and `A = B Q + R` where each coefficient of `R` beyond # `\operatorname{len}(B) - 1` is reduced modulo the leading coefficient of `B`. We @@ -1095,7 +1095,7 @@ cdef extern from "flint_wrap.h": # For ordinary use set the flag ``exact`` to `0`. In this case, no checks # or early aborts occur and the function always returns `1`. - int _fmpz_poly_divrem_divconquer(fmpz * Q, fmpz * R, const fmpz * A, long lenA, const fmpz * B, long lenB, int exact) + int _fmpz_poly_divrem_divconquer(fmpz * Q, fmpz * R, const fmpz * A, slong lenA, const fmpz * B, slong lenB, int exact) # Computes ``(Q, lenA - lenB + 1)``, ``(R, lenA)`` such that # `A = B Q + R` and each coefficient of `R` beyond `\operatorname{len}(B) - 1` is # reduced modulo the leading coefficient of `B`. If the leading @@ -1120,7 +1120,7 @@ cdef extern from "flint_wrap.h": # this is the same as division over `\mathbb{Q}`. An exception is raised if `B` # is zero. - int _fmpz_poly_divrem(fmpz * Q, fmpz * R, const fmpz * A, long lenA, const fmpz * B, long lenB, int exact) + int _fmpz_poly_divrem(fmpz * Q, fmpz * R, const fmpz * A, slong lenA, const fmpz * B, slong lenB, int exact) # Computes ``(Q, lenA - lenB + 1)``, ``(R, lenA)`` such that # `A = B Q + R` and each coefficient of `R` beyond `\operatorname{len}(B) - 1` is # reduced modulo the leading coefficient of `B`. If the leading @@ -1145,7 +1145,7 @@ cdef extern from "flint_wrap.h": # this is the same as division over `\mathbb{Q}`. An exception is raised if `B` # is zero. - int _fmpz_poly_div_basecase(fmpz * Q, fmpz * R, const fmpz * A, long lenA, const fmpz * B, long lenB, int exact) + int _fmpz_poly_div_basecase(fmpz * Q, fmpz * R, const fmpz * A, slong lenA, const fmpz * B, slong lenB, int exact) # Computes the quotient ``(Q, lenA - lenB + 1)`` of ``(A, lenA)`` # divided by ``(B, lenB)``. # Notationally, computes `Q`, `R` such that `A = B Q + R` and each @@ -1176,7 +1176,7 @@ cdef extern from "flint_wrap.h": # this is the same as division over `\mathbb{Q}`. An exception is raised if `B` # is zero. - int _fmpz_poly_divremlow_divconquer_recursive(fmpz * Q, fmpz * BQ, const fmpz * A, const fmpz * B, long lenB, int exact) + int _fmpz_poly_divremlow_divconquer_recursive(fmpz * Q, fmpz * BQ, const fmpz * A, const fmpz * B, slong lenB, int exact) # Divide and conquer division of ``(A, 2 lenB - 1)`` by ``(B, lenB)``, # computing only the bottom `\operatorname{len}(B) - 1` coefficients of `B Q`. # Assumes `\operatorname{len}(B) > 0`. Requires `B Q` to have length at least @@ -1192,7 +1192,7 @@ cdef extern from "flint_wrap.h": # For ordinary use set the flag ``exact`` to `0`. In this case, no checks # or early aborts occur and the function always returns `1`. - int _fmpz_poly_div_divconquer_recursive(fmpz * Q, fmpz * temp, const fmpz * A, const fmpz * B, long lenB, int exact) + int _fmpz_poly_div_divconquer_recursive(fmpz * Q, fmpz * temp, const fmpz * A, const fmpz * B, slong lenB, int exact) # Recursive short division in the balanced case. # Computes the quotient ``(Q, lenB)`` of ``(A, 2 lenB - 1)`` upon # division by ``(B, lenB)``. Requires `\operatorname{len}(B) > 0`. Needs a @@ -1208,7 +1208,7 @@ cdef extern from "flint_wrap.h": # For ordinary use set the flag ``exact`` to `0`. In this case, no checks # or early aborts occur and the function always returns `1`. - int _fmpz_poly_div_divconquer(fmpz * Q, const fmpz * A, long lenA, const fmpz * B, long lenB, int exact) + int _fmpz_poly_div_divconquer(fmpz * Q, const fmpz * A, slong lenA, const fmpz * B, slong lenB, int exact) # Computes the quotient ``(Q, lenA - lenB + 1)`` of ``(A, lenA)`` # upon division by ``(B, lenB)``. Assumes that # `\operatorname{len}(A) \geq \operatorname{len}(B) > 0`. Does not support aliasing. @@ -1230,7 +1230,7 @@ cdef extern from "flint_wrap.h": # this is the same as division over `\mathbb{Q}`. An exception is raised if `B` # is zero. - int _fmpz_poly_div(fmpz * Q, const fmpz * A, long lenA, const fmpz * B, long lenB, int exact) + int _fmpz_poly_div(fmpz * Q, const fmpz * A, slong lenA, const fmpz * B, slong lenB, int exact) # Computes the quotient ``(Q, lenA - lenB + 1)`` of ``(A, lenA)`` # divided by ``(B, lenB)``. # Notationally, computes `Q`, `R` such that `A = B Q + R` and each @@ -1257,7 +1257,7 @@ cdef extern from "flint_wrap.h": # the division is exact, this is the same as division over `Q`. An # exception is raised if `B` is zero. - void _fmpz_poly_rem_basecase(fmpz * R, const fmpz * A, long lenA, const fmpz * B, long lenB) + void _fmpz_poly_rem_basecase(fmpz * R, const fmpz * A, slong lenA, const fmpz * B, slong lenB) # Computes the remainder ``(R, lenA)`` of ``(A, lenA)`` upon # division by ``(B, lenB)``. # Notationally, computes `Q`, `R` such that `A = B Q + R` and each @@ -1276,7 +1276,7 @@ cdef extern from "flint_wrap.h": # the division is exact, this is the same as division over `\mathbb{Q}`. An # exception is raised if `B` is zero. - void _fmpz_poly_rem(fmpz * R, const fmpz * A, long lenA, const fmpz * B, long lenB) + void _fmpz_poly_rem(fmpz * R, const fmpz * A, slong lenA, const fmpz * B, slong lenB) # Computes the remainder ``(R, lenA)`` of ``(A, lenA)`` upon division # by ``(B, lenB)``. # Notationally, computes `Q`, `R` such that `A = B Q + R` and each @@ -1294,7 +1294,7 @@ cdef extern from "flint_wrap.h": # the division is exact, this is the same as division over `\mathbb{Q}`. An # exception is raised if `B` is zero. - void _fmpz_poly_div_root(fmpz * Q, const fmpz * A, long len, const fmpz_t c) + void _fmpz_poly_div_root(fmpz * Q, const fmpz * A, slong len, const fmpz_t c) # Computes the quotient ``(Q, len-1)`` of ``(A, len)`` upon # division by `x - c`. # Supports aliasing of ``Q`` and ``A``, but the result is @@ -1304,7 +1304,7 @@ cdef extern from "flint_wrap.h": # Computes the quotient ``(Q, len-1)`` of ``(A, len)`` upon # division by `x - c`. - void _fmpz_poly_preinvert(fmpz * B_inv, const fmpz * B, long n) + void _fmpz_poly_preinvert(fmpz * B_inv, const fmpz * B, slong n) # Given a monic polynomial ``B`` of length ``n``, compute a precomputed # inverse ``B_inv`` of length ``n`` for use in the functions below. No # aliasing of ``B`` and ``B_inv`` is permitted. We assume ``n`` is not zero. @@ -1314,7 +1314,7 @@ cdef extern from "flint_wrap.h": # ``B_inv`` for use in the functions below. An exception is raised if # ``B`` is zero. - void _fmpz_poly_div_preinv(fmpz * Q, const fmpz * A, long len1, const fmpz * B, const fmpz * B_inv, long len2) + void _fmpz_poly_div_preinv(fmpz * Q, const fmpz * A, slong len1, const fmpz * B, const fmpz * B_inv, slong len2) # Given a precomputed inverse ``B_inv`` of the polynomial ``B`` of # length ``len2``, compute the quotient ``Q`` of ``A`` by ``B``. # We assume the length ``len1`` of ``A`` is at least ``len2``. The @@ -1326,7 +1326,7 @@ cdef extern from "flint_wrap.h": # compute the quotient ``Q`` of ``A`` by ``B``. Aliasing of ``B`` # and ``B_inv`` is not permitted. - void _fmpz_poly_divrem_preinv(fmpz * Q, fmpz * A, long len1, const fmpz * B, const fmpz * B_inv, long len2) + void _fmpz_poly_divrem_preinv(fmpz * Q, fmpz * A, slong len1, const fmpz * B, const fmpz * B_inv, slong len2) # Given a precomputed inverse ``B_inv`` of the polynomial ``B`` of # length ``len2``, compute the quotient ``Q`` of ``A`` by ``B``. # The remainder is then placed in ``A``. We assume the length ``len1`` @@ -1339,7 +1339,7 @@ cdef extern from "flint_wrap.h": # compute the quotient ``Q`` of ``A`` by ``B`` and the remainder # ``R``. Aliasing of ``B`` and ``B_inv`` is not permitted. - fmpz ** _fmpz_poly_powers_precompute(const fmpz * B, long len) + fmpz ** _fmpz_poly_powers_precompute(const fmpz * B, slong len) # Computes ``2*len - 1`` powers of `x` modulo the polynomial `B` of # the given length. This is used as a kind of precomputed inverse in # the remainder routine below. @@ -1349,7 +1349,7 @@ cdef extern from "flint_wrap.h": # the given length. This is used as a kind of precomputed inverse in # the remainder routine below. - void _fmpz_poly_powers_clear(fmpz ** powers, long len) + void _fmpz_poly_powers_clear(fmpz ** powers, slong len) # Clean up resources used by precomputed powers which have been computed # by ``_fmpz_poly_powers_precompute``. @@ -1357,7 +1357,7 @@ cdef extern from "flint_wrap.h": # Clean up resources used by precomputed powers which have been computed # by ``fmpz_poly_powers_precompute``. - void _fmpz_poly_rem_powers_precomp(fmpz * A, long m, const fmpz * B, long n, fmpz ** const powers) + void _fmpz_poly_rem_powers_precomp(fmpz * A, slong m, const fmpz * B, slong n, fmpz ** const powers) # Set `A` to the remainder of `A` divide `B` given precomputed powers mod `B` # provided by ``_fmpz_poly_powers_precompute``. No aliasing is allowed. @@ -1365,7 +1365,7 @@ cdef extern from "flint_wrap.h": # Set `R` to the remainder of `A` divide `B` given precomputed powers mod `B` # provided by ``fmpz_poly_powers_precompute``. - int _fmpz_poly_divides(fmpz * Q, const fmpz * A, long lenA, const fmpz * B, long lenB) + int _fmpz_poly_divides(fmpz * Q, const fmpz * A, slong lenA, const fmpz * B, slong lenB) # Returns 1 if ``(B, lenB)`` divides ``(A, lenA)`` exactly and # sets `Q` to the quotient, otherwise returns 0. # It is assumed that `\operatorname{len}(A) \geq \operatorname{len}(B) > 0` and that `Q` has space @@ -1380,12 +1380,12 @@ cdef extern from "flint_wrap.h": # This function is currently unoptimised and provided for convenience # only. - long fmpz_poly_remove(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2) + slong fmpz_poly_remove(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2) # Set ``res`` to ``poly1`` divided by the highest power of ``poly2`` that # divides it and return the power. The divisor ``poly2`` must not be zero or # `\pm 1`, otherwise an exception is raised. - void fmpz_poly_divlow_smodp(fmpz * res, const fmpz_poly_t f, const fmpz_poly_t g, const fmpz_t p, long n) + void fmpz_poly_divlow_smodp(fmpz * res, const fmpz_poly_t f, const fmpz_poly_t g, const fmpz_t p, slong n) # Compute the `n` lowest coefficients of `f` divided by `g`, assuming the # division is exact modulo `p`. The computed coefficients are reduced modulo # `p` using the symmetric remainder system. We require `f` to be at least `n` @@ -1393,7 +1393,7 @@ cdef extern from "flint_wrap.h": # coefficient of `g` must be coprime to `p`. This is a bespoke function used # by factoring. - void fmpz_poly_divhigh_smodp(fmpz * res, const fmpz_poly_t f, const fmpz_poly_t g, const fmpz_t p, long n) + void fmpz_poly_divhigh_smodp(fmpz * res, const fmpz_poly_t f, const fmpz_poly_t g, const fmpz_t p, slong n) # Compute the `n` highest coefficients of `f` divided by `g`, assuming the # division is exact modulo `p`. The computed coefficients are reduced modulo # `p` using the symmetric remainder system. We require `f` to be as output @@ -1401,57 +1401,57 @@ cdef extern from "flint_wrap.h": # length `n` as inputs. The leading coefficient of `g` must be coprime to # `p`. This is a bespoke function used by factoring. - void _fmpz_poly_inv_series_basecase(fmpz * Qinv, const fmpz * Q, long Qlen, long n) + void _fmpz_poly_inv_series_basecase(fmpz * Qinv, const fmpz * Q, slong Qlen, slong n) # Computes the first `n` terms of the inverse power series of # ``(Q, lenQ)`` using a recurrence. # Assumes that `n \geq 1` and that `Q` has constant term `\pm 1`. # Does not support aliasing. - void fmpz_poly_inv_series_basecase(fmpz_poly_t Qinv, const fmpz_poly_t Q, long n) + void fmpz_poly_inv_series_basecase(fmpz_poly_t Qinv, const fmpz_poly_t Q, slong n) # Computes the first `n` terms of the inverse power series of `Q` # using a recurrence, assuming that `Q` has constant term `\pm 1` # and `n \geq 1`. - void _fmpz_poly_inv_series_newton(fmpz * Qinv, const fmpz * Q, long Qlen, long n) + void _fmpz_poly_inv_series_newton(fmpz * Qinv, const fmpz * Q, slong Qlen, slong n) # Computes the first `n` terms of the inverse power series of # ``(Q, lenQ)`` using Newton iteration. # Assumes that `n \geq 1` and that `Q` has constant term `\pm 1`. # Does not support aliasing. - void fmpz_poly_inv_series_newton(fmpz_poly_t Qinv, const fmpz_poly_t Q, long n) + void fmpz_poly_inv_series_newton(fmpz_poly_t Qinv, const fmpz_poly_t Q, slong n) # Computes the first `n` terms of the inverse power series of `Q` using # Newton iteration, assuming `Q` has constant term `\pm 1` and `n \geq 1`. - void _fmpz_poly_inv_series(fmpz * Qinv, const fmpz * Q, long Qlen, long n) + void _fmpz_poly_inv_series(fmpz * Qinv, const fmpz * Q, slong Qlen, slong n) # Computes the first `n` terms of the inverse power series of # ``(Q, lenQ)``. # Assumes that `n \geq 1` and that `Q` has constant term `\pm 1`. # Does not support aliasing. - void fmpz_poly_inv_series(fmpz_poly_t Qinv, const fmpz_poly_t Q, long n) + void fmpz_poly_inv_series(fmpz_poly_t Qinv, const fmpz_poly_t Q, slong n) # Computes the first `n` terms of the inverse power series of `Q`, # assuming `Q` has constant term `\pm 1` and `n \geq 1`. - void _fmpz_poly_div_series_basecase(fmpz * Q, const fmpz * A, long Alen, const fmpz * B, long Blen, long n) + void _fmpz_poly_div_series_basecase(fmpz * Q, const fmpz * A, slong Alen, const fmpz * B, slong Blen, slong n) - void _fmpz_poly_div_series_divconquer(fmpz * Q, const fmpz * A, long Alen, const fmpz * B, long Blen, long n) + void _fmpz_poly_div_series_divconquer(fmpz * Q, const fmpz * A, slong Alen, const fmpz * B, slong Blen, slong n) - void _fmpz_poly_div_series(fmpz * Q, const fmpz * A, long Alen, const fmpz * B, long Blen, long n) + void _fmpz_poly_div_series(fmpz * Q, const fmpz * A, slong Alen, const fmpz * B, slong Blen, slong n) # Divides ``(A, Alen)`` by ``(B, Blen)`` as power series over `\mathbb{Z}`, # assuming `B` has constant term `\pm 1` and `n \geq 1`. # Aliasing is not supported. - void fmpz_poly_div_series_basecase(fmpz_poly_t Q, const fmpz_poly_t A, const fmpz_poly_t B, long n) + void fmpz_poly_div_series_basecase(fmpz_poly_t Q, const fmpz_poly_t A, const fmpz_poly_t B, slong n) - void fmpz_poly_div_series_divconquer(fmpz_poly_t Q, const fmpz_poly_t A, const fmpz_poly_t B, long n) + void fmpz_poly_div_series_divconquer(fmpz_poly_t Q, const fmpz_poly_t A, const fmpz_poly_t B, slong n) - void fmpz_poly_div_series(fmpz_poly_t Q, const fmpz_poly_t A, const fmpz_poly_t B, long n) + void fmpz_poly_div_series(fmpz_poly_t Q, const fmpz_poly_t A, const fmpz_poly_t B, slong n) # Performs power series division in `\mathbb{Z}[[x]] / (x^n)`. The function # considers the polynomials `A` and `B` as power series of length `n` # starting with the constant terms. The function assumes that `B` has # constant term `\pm 1` and `n \geq 1`. - void _fmpz_poly_pseudo_divrem_basecase(fmpz * Q, fmpz * R, unsigned long * d, const fmpz * A, long lenA, const fmpz * B, long lenB, const fmpz_preinvn_t inv) + void _fmpz_poly_pseudo_divrem_basecase(fmpz * Q, fmpz * R, ulong * d, const fmpz * A, slong lenA, const fmpz * B, slong lenB, const fmpz_preinvn_t inv) # If `\ell` is the leading coefficient of `B`, then computes `Q`, `R` such # that `\ell^d A = Q B + R`. This function is used for simulating division # over `\mathbb{Q}`. @@ -1465,12 +1465,12 @@ cdef extern from "flint_wrap.h": # Note: ``fmpz.h`` has to be included before ``fmpz_poly.h`` in order for # ``fmpz_poly.h`` to declare this function. - void fmpz_poly_pseudo_divrem_basecase(fmpz_poly_t Q, fmpz_poly_t R, unsigned long * d, const fmpz_poly_t A, const fmpz_poly_t B) + void fmpz_poly_pseudo_divrem_basecase(fmpz_poly_t Q, fmpz_poly_t R, ulong * d, const fmpz_poly_t A, const fmpz_poly_t B) # If `\ell` is the leading coefficient of `B`, then computes `Q`, `R` such # that `\ell^d A = Q B + R`. This function is used for simulating division # over `\mathbb{Q}`. - void _fmpz_poly_pseudo_divrem_divconquer(fmpz * Q, fmpz * R, unsigned long * d, const fmpz * A, long lenA, const fmpz * B, long lenB, const fmpz_preinvn_t inv) + void _fmpz_poly_pseudo_divrem_divconquer(fmpz * Q, fmpz * R, ulong * d, const fmpz * A, slong lenA, const fmpz * B, slong lenB, const fmpz_preinvn_t inv) # Computes ``(Q, lenA - lenB + 1)``, ``(R, lenA)`` such that # `\ell^d A = B Q + R`, only setting the bottom `\operatorname{len}(B) - 1` coefficients # of `R` to their correct values. The remaining top coefficients of @@ -1483,12 +1483,12 @@ cdef extern from "flint_wrap.h": # Note: ``fmpz.h`` has to be included before ``fmpz_poly.h`` in order for # ``fmpz_poly.h`` to declare this function. - void fmpz_poly_pseudo_divrem_divconquer(fmpz_poly_t Q, fmpz_poly_t R, unsigned long * d, const fmpz_poly_t A, const fmpz_poly_t B) + void fmpz_poly_pseudo_divrem_divconquer(fmpz_poly_t Q, fmpz_poly_t R, ulong * d, const fmpz_poly_t A, const fmpz_poly_t B) # Computes `Q`, `R`, and `d` such that `\ell^d A = B Q + R`, where `R` has # length less than the length of `B` and `\ell` is the leading coefficient # of `B`. An exception is raised if `B` is zero. - void _fmpz_poly_pseudo_divrem_cohen(fmpz * Q, fmpz * R, const fmpz * A, long lenA, const fmpz * B, long lenB) + void _fmpz_poly_pseudo_divrem_cohen(fmpz * Q, fmpz * R, const fmpz * A, slong lenA, const fmpz * B, slong lenB) # Assumes that `\operatorname{len}(A) \geq \operatorname{len}(B) > 0`. Assumes that `Q` can fit # `\operatorname{len}(A) - \operatorname{len}(B) + 1` coefficients, and that `R` can fit `\operatorname{len}(A)` # coefficients. Supports aliasing of ``(R, lenA)`` and ``(A, lenA)``. @@ -1503,7 +1503,7 @@ cdef extern from "flint_wrap.h": # is not asymptotically fast. It is efficient only for short polynomials, # e.g. when `\operatorname{len}(B) < 32`. - void _fmpz_poly_pseudo_rem_cohen(fmpz * R, const fmpz * A, long lenA, const fmpz * B, long lenB) + void _fmpz_poly_pseudo_rem_cohen(fmpz * R, const fmpz * A, slong lenA, const fmpz * B, slong lenB) # Assumes that `\operatorname{len}(A) \geq \operatorname{len}(B) > 0`. Assumes that `R` can fit # `\operatorname{len}(A)` coefficients. Supports aliasing of ``(R, lenA)`` and # ``(A, lenA)``. But other than this, no aliasing of the inputs and @@ -1521,7 +1521,7 @@ cdef extern from "flint_wrap.h": # This function uses the algorithm described # in Algorithm 3.1.2 of [Coh1996]_. - void _fmpz_poly_pseudo_divrem(fmpz * Q, fmpz * R, unsigned long * d, const fmpz * A, long lenA, const fmpz * B, long lenB, const fmpz_preinvn_t inv) + void _fmpz_poly_pseudo_divrem(fmpz * Q, fmpz * R, ulong * d, const fmpz * A, slong lenA, const fmpz * B, slong lenB, const fmpz_preinvn_t inv) # If `\ell` is the leading coefficient of `B`, then computes # ``(Q, lenA - lenB + 1)``, ``(R, lenB - 1)`` and `d` such that # `\ell^d A = B Q + R`. This function is used for simulating division @@ -1538,26 +1538,26 @@ cdef extern from "flint_wrap.h": # Note: ``fmpz.h`` has to be included before ``fmpz_poly.h`` in order for # ``fmpz_poly.h`` to declare this function. - void fmpz_poly_pseudo_divrem(fmpz_poly_t Q, fmpz_poly_t R, unsigned long * d, const fmpz_poly_t A, const fmpz_poly_t B) + void fmpz_poly_pseudo_divrem(fmpz_poly_t Q, fmpz_poly_t R, ulong * d, const fmpz_poly_t A, const fmpz_poly_t B) # Computes `Q`, `R`, and `d` such that `\ell^d A = B Q + R`. - void _fmpz_poly_pseudo_div(fmpz * Q, unsigned long * d, const fmpz * A, long lenA, const fmpz * B, long lenB, const fmpz_preinvn_t inv) + void _fmpz_poly_pseudo_div(fmpz * Q, ulong * d, const fmpz * A, slong lenA, const fmpz * B, slong lenB, const fmpz_preinvn_t inv) # Pseudo-division, only returning the quotient. # Note: ``fmpz.h`` has to be included before ``fmpz_poly.h`` in order for # ``fmpz_poly.h`` to declare this function. - void fmpz_poly_pseudo_div(fmpz_poly_t Q, unsigned long * d, const fmpz_poly_t A, const fmpz_poly_t B) + void fmpz_poly_pseudo_div(fmpz_poly_t Q, ulong * d, const fmpz_poly_t A, const fmpz_poly_t B) # Pseudo-division, only returning the quotient. - void _fmpz_poly_pseudo_rem(fmpz * R, unsigned long * d, const fmpz * A, long lenA, const fmpz * B, long lenB, const fmpz_preinvn_t inv) + void _fmpz_poly_pseudo_rem(fmpz * R, ulong * d, const fmpz * A, slong lenA, const fmpz * B, slong lenB, const fmpz_preinvn_t inv) # Pseudo-division, only returning the remainder. # Note: ``fmpz.h`` has to be included before ``fmpz_poly.h`` in order for # ``fmpz_poly.h`` to declare this function. - void fmpz_poly_pseudo_rem(fmpz_poly_t R, unsigned long * d, const fmpz_poly_t A, const fmpz_poly_t B) + void fmpz_poly_pseudo_rem(fmpz_poly_t R, ulong * d, const fmpz_poly_t A, const fmpz_poly_t B) # Pseudo-division, only returning the remainder. - void _fmpz_poly_derivative(fmpz * rpoly, const fmpz * poly, long len) + void _fmpz_poly_derivative(fmpz * rpoly, const fmpz * poly, slong len) # Sets ``(rpoly, len - 1)`` to the derivative of ``(poly, len)``. # Also handles the cases where ``len`` is `0` or `1` correctly. # Supports aliasing of ``rpoly`` and ``poly``. @@ -1565,15 +1565,15 @@ cdef extern from "flint_wrap.h": void fmpz_poly_derivative(fmpz_poly_t res, const fmpz_poly_t poly) # Sets ``res`` to the derivative of ``poly``. - void _fmpz_poly_nth_derivative(fmpz * rpoly, const fmpz * poly, unsigned long n, long len) + void _fmpz_poly_nth_derivative(fmpz * rpoly, const fmpz * poly, ulong n, slong len) # Sets ``(rpoly, len - n)`` to the nth derivative of ``(poly, len)``. # Also handles the cases where ``len <= n`` correctly. # Supports aliasing of ``rpoly`` and ``poly``. - void fmpz_poly_nth_derivative(fmpz_poly_t res, const fmpz_poly_t poly, unsigned long n) + void fmpz_poly_nth_derivative(fmpz_poly_t res, const fmpz_poly_t poly, ulong n) # Sets ``res`` to the nth derivative of ``poly``. - void _fmpz_poly_evaluate_divconquer_fmpz(fmpz_t res, const fmpz * poly, long len, const fmpz_t a) + void _fmpz_poly_evaluate_divconquer_fmpz(fmpz_t res, const fmpz * poly, slong len, const fmpz_t a) # Evaluates the polynomial ``(poly, len)`` at the integer `a` using # a divide and conquer approach. Assumes that the length of the polynomial # is at least one. Allows zero padding. Does not allow aliasing between @@ -1585,7 +1585,7 @@ cdef extern from "flint_wrap.h": # Aliasing between ``res`` and ``a`` is supported, however, # ``res`` may not be part of ``poly``. - void _fmpz_poly_evaluate_horner_fmpz(fmpz_t res, const fmpz * f, long len, const fmpz_t a) + void _fmpz_poly_evaluate_horner_fmpz(fmpz_t res, const fmpz * f, slong len, const fmpz_t a) # Evaluates the polynomial ``(f, len)`` at the integer `a` using # Horner's rule, and sets ``res`` to the result. Aliasing between # ``res`` and `a` or any of the coefficients of `f` is not supported. @@ -1596,7 +1596,7 @@ cdef extern from "flint_wrap.h": # As expected, aliasing between ``res`` and ``a`` is supported. # However, ``res`` may not be aliased with a coefficient of `f`. - void _fmpz_poly_evaluate_fmpz(fmpz_t res, const fmpz * f, long len, const fmpz_t a) + void _fmpz_poly_evaluate_fmpz(fmpz_t res, const fmpz * f, slong len, const fmpz_t a) # Evaluates the polynomial ``(f, len)`` at the integer `a` and sets # ``res`` to the result. Aliasing between ``res`` and `a` or any # of the coefficients of `f` is not supported. @@ -1607,7 +1607,7 @@ cdef extern from "flint_wrap.h": # As expected, aliasing between ``res`` and `a` is supported. However, # ``res`` may not be aliased with a coefficient of `f`. - void _fmpz_poly_evaluate_divconquer_fmpq(fmpz_t rnum, fmpz_t rden, const fmpz * f, long len, const fmpz_t anum, const fmpz_t aden) + void _fmpz_poly_evaluate_divconquer_fmpq(fmpz_t rnum, fmpz_t rden, const fmpz * f, slong len, const fmpz_t anum, const fmpz_t aden) # Evaluates the polynomial ``(f, len)`` at the rational # ``(anum, aden)`` using a divide and conquer approach, and sets # ``(rnum, rden)`` to the result in lowest terms. Assumes that @@ -1619,7 +1619,7 @@ cdef extern from "flint_wrap.h": # Evaluates the polynomial `f` at the rational `a` using a divide # and conquer approach, and sets ``res`` to the result. - void _fmpz_poly_evaluate_horner_fmpq(fmpz_t rnum, fmpz_t rden, const fmpz * f, long len, const fmpz_t anum, const fmpz_t aden) + void _fmpz_poly_evaluate_horner_fmpq(fmpz_t rnum, fmpz_t rden, const fmpz * f, slong len, const fmpz_t anum, const fmpz_t aden) # Evaluates the polynomial ``(f, len)`` at the rational # ``(anum, aden)`` using Horner's rule, and sets ``(rnum, rden)`` to # the result in lowest terms. @@ -1630,7 +1630,7 @@ cdef extern from "flint_wrap.h": # Evaluates the polynomial `f` at the rational `a` using Horner's rule, and # sets ``res`` to the result. - void _fmpz_poly_evaluate_fmpq(fmpz_t rnum, fmpz_t rden, const fmpz * f, long len, const fmpz_t anum, const fmpz_t aden) + void _fmpz_poly_evaluate_fmpq(fmpz_t rnum, fmpz_t rden, const fmpz * f, slong len, const fmpz_t anum, const fmpz_t aden) # Evaluates the polynomial ``(f, len)`` at the rational # ``(anum, aden)`` and sets ``(rnum, rden)`` to the result in lowest # terms. @@ -1641,7 +1641,7 @@ cdef extern from "flint_wrap.h": # Evaluates the polynomial `f` at the rational `a`, and # sets ``res`` to the result. - mp_limb_t _fmpz_poly_evaluate_mod(const fmpz * poly, long len, mp_limb_t a, mp_limb_t n, mp_limb_t ninv) + mp_limb_t _fmpz_poly_evaluate_mod(const fmpz * poly, slong len, mp_limb_t a, mp_limb_t n, mp_limb_t ninv) # Evaluates ``(poly, len)`` at the value `a` modulo `n` and # returns the result. The last argument ``ninv`` must be set # to the precomputed inverse of `n`, which can be obtained using @@ -1650,11 +1650,11 @@ cdef extern from "flint_wrap.h": mp_limb_t fmpz_poly_evaluate_mod(const fmpz_poly_t poly, mp_limb_t a, mp_limb_t n) # Evaluates ``poly`` at the value `a` modulo `n` and returns the result. - void fmpz_poly_evaluate_fmpz_vec(fmpz * res, const fmpz_poly_t f, const fmpz * a, long n) + void fmpz_poly_evaluate_fmpz_vec(fmpz * res, const fmpz_poly_t f, const fmpz * a, slong n) # Evaluates ``f`` at the `n` values given in the vector ``f``, # writing the results to ``res``. - double _fmpz_poly_evaluate_horner_d(const fmpz * poly, long n, double d) + double _fmpz_poly_evaluate_horner_d(const fmpz * poly, slong n, double d) # Evaluate ``(poly, n)`` at the double `d`. No attempt is made to do this # efficiently or in a numerically stable way. It is currently only used in # Flint for quick and dirty evaluations of polynomials with all coefficients @@ -1666,28 +1666,28 @@ cdef extern from "flint_wrap.h": # Flint for quick and dirty evaluations of polynomials with all coefficients # positive. - double _fmpz_poly_evaluate_horner_d_2exp(long * exp, const fmpz * poly, long n, double d) + double _fmpz_poly_evaluate_horner_d_2exp(slong * exp, const fmpz * poly, slong n, double d) # Evaluate ``(poly, n)`` at the double `d`. Return the result as a double # and an exponent ``exp`` combination. No attempt is made to do this # efficiently or in a numerically stable way. It is currently only used in # Flint for quick and dirty evaluations of polynomials with all coefficients # positive. - double fmpz_poly_evaluate_horner_d_2exp(long * exp, const fmpz_poly_t poly, double d) + double fmpz_poly_evaluate_horner_d_2exp(slong * exp, const fmpz_poly_t poly, double d) # Evaluate ``poly`` at the double `d`. Return the result as a double # and an exponent ``exp`` combination. No attempt is made to do this # efficiently or in a numerically stable way. It is currently only used in # Flint for quick and dirty evaluations of polynomials with all coefficients # positive. - double _fmpz_poly_evaluate_horner_d_2exp2(long * exp, const fmpz * poly, long n, double d, long dexp) + double _fmpz_poly_evaluate_horner_d_2exp2(slong * exp, const fmpz * poly, slong n, double d, slong dexp) # Evaluate ``poly`` at ``d*2^dexp``. Return the result as a double # and an exponent ``exp`` combination. No attempt is made to do this # efficiently or in a numerically stable way. It is currently only used in # Flint for quick and dirty evaluations of polynomials with all coefficients # positive. - void _fmpz_poly_monomial_to_newton(fmpz * poly, const fmpz * roots, long n) + void _fmpz_poly_monomial_to_newton(fmpz * poly, const fmpz * roots, slong n) # Converts ``(poly, n)`` in-place from its coefficients given # in the standard monomial basis to the Newton basis # for the roots `r_0, r_1, \ldots, r_{n-2}`. @@ -1696,7 +1696,7 @@ cdef extern from "flint_wrap.h": # is equal to the input polynomial. # Uses repeated polynomial division. - void _fmpz_poly_newton_to_monomial(fmpz * poly, const fmpz * roots, long n) + void _fmpz_poly_newton_to_monomial(fmpz * poly, const fmpz * roots, slong n) # Converts ``(poly, n)`` in-place from its coefficients given # in the Newton basis for the roots `r_0, r_1, \ldots, r_{n-2}` # to the standard monomial basis. In other words, this evaluates @@ -1704,7 +1704,7 @@ cdef extern from "flint_wrap.h": # where `c_i` are the input coefficients for ``poly``. # Uses Horner's rule. - void fmpz_poly_interpolate_fmpz_vec(fmpz_poly_t poly, const fmpz * xs, const fmpz * ys, long n) + void fmpz_poly_interpolate_fmpz_vec(fmpz_poly_t poly, const fmpz * xs, const fmpz * ys, slong n) # Sets ``poly`` to the unique interpolating polynomial of degree at # most `n - 1` satisfying `f(x_i) = y_i` for every pair `x_i, y_u` in # ``xs`` and ``ys``, assuming that this polynomial has integer @@ -1713,7 +1713,7 @@ cdef extern from "flint_wrap.h": # exist, a ``FLINT_INEXACT`` exception is thrown. # It is assumed that the `x` values are distinct. - void _fmpz_poly_compose_horner(fmpz * res, const fmpz * poly1, long len1, const fmpz * poly2, long len2) + void _fmpz_poly_compose_horner(fmpz * res, const fmpz * poly1, slong len1, const fmpz * poly2, slong len2) # Sets ``res`` to the composition of ``(poly1, len1)`` and # ``(poly2, len2)``. # Assumes that ``res`` has space for ``(len1-1)*(len2-1) + 1`` @@ -1727,7 +1727,7 @@ cdef extern from "flint_wrap.h": # by `f`, `g`, and `h`, sets `f(t) = g(h(t))`. # This implementation uses Horner's method. - void _fmpz_poly_compose_divconquer(fmpz * res, const fmpz * poly1, long len1, const fmpz * poly2, long len2) + void _fmpz_poly_compose_divconquer(fmpz * res, const fmpz * poly1, slong len1, const fmpz * poly2, slong len2) # Computes the composition of ``(poly1, len1)`` and ``(poly2, len2)`` # using a divide and conquer approach and places the result into ``res``, # assuming ``res`` can hold the output of length @@ -1741,7 +1741,7 @@ cdef extern from "flint_wrap.h": # ``poly1``, and ``poly2`` by `f`, `g`, and `h`, respectively, # sets `f(t) = g(h(t))`. - void _fmpz_poly_compose(fmpz * res, const fmpz * poly1, long len1, const fmpz * poly2, long len2) + void _fmpz_poly_compose(fmpz * res, const fmpz * poly1, slong len1, const fmpz * poly2, slong len2) # Sets ``res`` to the composition of ``(poly1, len1)`` and # ``(poly2, len2)``. # Assumes that ``res`` has space for ``(len1-1)*(len2-1) + 1`` @@ -1755,28 +1755,28 @@ cdef extern from "flint_wrap.h": # ``poly1``, and ``poly2`` by `f`, `g`, and `h`, respectively, # sets `f(t) = g(h(t))`. - void fmpz_poly_inflate(fmpz_poly_t result, const fmpz_poly_t input, unsigned long inflation) + void fmpz_poly_inflate(fmpz_poly_t result, const fmpz_poly_t input, ulong inflation) # Sets ``result`` to the inflated polynomial `p(x^n)` where # `p` is given by ``input`` and `n` is given by ``inflation``. - void fmpz_poly_deflate(fmpz_poly_t result, const fmpz_poly_t input, unsigned long deflation) + void fmpz_poly_deflate(fmpz_poly_t result, const fmpz_poly_t input, ulong deflation) # Sets ``result`` to the deflated polynomial `p(x^{1/n})` where # `p` is given by ``input`` and `n` is given by ``deflation``. # Requires `n > 0`. - unsigned long fmpz_poly_deflation(const fmpz_poly_t input) + ulong fmpz_poly_deflation(const fmpz_poly_t input) # Returns the largest integer by which ``input`` can be deflated. # As special cases, returns 0 if ``input`` is the zero polynomial # and 1 if ``input`` is a constant polynomial. - void _fmpz_poly_taylor_shift_horner(fmpz * poly, const fmpz_t c, long n) + void _fmpz_poly_taylor_shift_horner(fmpz * poly, const fmpz_t c, slong n) # Performs the Taylor shift composing ``poly`` by `x+c` in-place. # Uses an efficient version Horner's rule. void fmpz_poly_taylor_shift_horner(fmpz_poly_t g, const fmpz_poly_t f, const fmpz_t c) # Performs the Taylor shift composing ``f`` by `x+c`. - void _fmpz_poly_taylor_shift_divconquer(fmpz * poly, const fmpz_t c, long n) + void _fmpz_poly_taylor_shift_divconquer(fmpz * poly, const fmpz_t c, slong n) # Performs the Taylor shift composing ``poly`` by `x+c` in-place. # Uses the divide-and-conquer polynomial composition algorithm. @@ -1784,7 +1784,7 @@ cdef extern from "flint_wrap.h": # Performs the Taylor shift composing ``f`` by `x+c`. # Uses the divide-and-conquer polynomial composition algorithm. - void _fmpz_poly_taylor_shift_multi_mod(fmpz * poly, const fmpz_t c, long n) + void _fmpz_poly_taylor_shift_multi_mod(fmpz * poly, const fmpz_t c, slong n) # Performs the Taylor shift composing ``poly`` by `x+c` in-place. # Uses a multimodular algorithm, distributing the computation # across :func:`flint_get_num_threads` threads. @@ -1794,13 +1794,13 @@ cdef extern from "flint_wrap.h": # Uses a multimodular algorithm, distributing the computation # across :func:`flint_get_num_threads` threads. - void _fmpz_poly_taylor_shift(fmpz * poly, const fmpz_t c, long n) + void _fmpz_poly_taylor_shift(fmpz * poly, const fmpz_t c, slong n) # Performs the Taylor shift composing ``poly`` by `x+c` in-place. void fmpz_poly_taylor_shift(fmpz_poly_t g, const fmpz_poly_t f, const fmpz_t c) # Performs the Taylor shift composing ``f`` by `x+c`. - void _fmpz_poly_compose_series_horner(fmpz * res, const fmpz * poly1, long len1, const fmpz * poly2, long len2, long n) + void _fmpz_poly_compose_series_horner(fmpz * res, const fmpz * poly1, slong len1, const fmpz * poly2, slong len2, slong n) # Sets ``res`` to the composition of ``poly1`` and ``poly2`` # modulo `x^n`, where the constant term of ``poly2`` is required # to be zero. @@ -1810,13 +1810,13 @@ cdef extern from "flint_wrap.h": # of the inputs and the output. # This implementation uses the Horner scheme. - void fmpz_poly_compose_series_horner(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2, long n) + void fmpz_poly_compose_series_horner(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2, slong n) # Sets ``res`` to the composition of ``poly1`` and ``poly2`` # modulo `x^n`, where the constant term of ``poly2`` is required # to be zero. # This implementation uses the Horner scheme. - void _fmpz_poly_compose_series_brent_kung(fmpz * res, const fmpz * poly1, long len1, const fmpz * poly2, long len2, long n) + void _fmpz_poly_compose_series_brent_kung(fmpz * res, const fmpz * poly1, slong len1, const fmpz * poly2, slong len2, slong n) # Sets ``res`` to the composition of ``poly1`` and ``poly2`` # modulo `x^n`, where the constant term of ``poly2`` is required # to be zero. @@ -1826,13 +1826,13 @@ cdef extern from "flint_wrap.h": # of the inputs and the output. # This implementation uses Brent-Kung algorithm 2.1 [BrentKung1978]_. - void fmpz_poly_compose_series_brent_kung(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2, long n) + void fmpz_poly_compose_series_brent_kung(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2, slong n) # Sets ``res`` to the composition of ``poly1`` and ``poly2`` # modulo `x^n`, where the constant term of ``poly2`` is required # to be zero. # This implementation uses Brent-Kung algorithm 2.1 [BrentKung1978]_. - void _fmpz_poly_compose_series(fmpz * res, const fmpz * poly1, long len1, const fmpz * poly2, long len2, long n) + void _fmpz_poly_compose_series(fmpz * res, const fmpz * poly1, slong len1, const fmpz * poly2, slong len2, slong n) # Sets ``res`` to the composition of ``poly1`` and ``poly2`` # modulo `x^n`, where the constant term of ``poly2`` is required # to be zero. @@ -1843,14 +1843,14 @@ cdef extern from "flint_wrap.h": # This implementation automatically switches between the Horner scheme # and Brent-Kung algorithm 2.1 depending on the size of the inputs. - void fmpz_poly_compose_series(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2, long n) + void fmpz_poly_compose_series(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2, slong n) # Sets ``res`` to the composition of ``poly1`` and ``poly2`` # modulo `x^n`, where the constant term of ``poly2`` is required # to be zero. # This implementation automatically switches between the Horner scheme # and Brent-Kung algorithm 2.1 depending on the size of the inputs. - void _fmpz_poly_revert_series_lagrange(fmpz * Qinv, const fmpz * Q, long Qlen, long n) + void _fmpz_poly_revert_series_lagrange(fmpz * Qinv, const fmpz * Q, slong Qlen, slong n) # Sets ``Qinv`` to the compositional inverse or reversion of # ``(Q, Qlen)`` as a power series, i.e. computes `Q^{-1}` such that # `Q(Q^{-1}(x)) = Q^{-1}(Q(x)) = x \bmod x^n`. The arguments may not be @@ -1858,14 +1858,14 @@ cdef extern from "flint_wrap.h": # It is required that `Q_0 = 0` and `Q_1 = \pm 1`. # This implementation uses the Lagrange inversion formula. - void fmpz_poly_revert_series_lagrange(fmpz_poly_t Qinv, const fmpz_poly_t Q, long n) + void fmpz_poly_revert_series_lagrange(fmpz_poly_t Qinv, const fmpz_poly_t Q, slong n) # Sets ``Qinv`` to the compositional inverse or reversion of ``Q`` # as a power series, i.e. computes `Q^{-1}` such that # `Q(Q^{-1}(x)) = Q^{-1}(Q(x)) = x \bmod x^n`. # It is required that `Q_0 = 0` and `Q_1 = \pm 1`. # This implementation uses the Lagrange inversion formula. - void _fmpz_poly_revert_series_lagrange_fast(fmpz * Qinv, const fmpz * Q, long Qlen, long n) + void _fmpz_poly_revert_series_lagrange_fast(fmpz * Qinv, const fmpz * Q, slong Qlen, slong n) # Sets ``Qinv`` to the compositional inverse or reversion of # ``(Q, Qlen)`` # as a power series, i.e. computes `Q^{-1}` such that @@ -1875,7 +1875,7 @@ cdef extern from "flint_wrap.h": # This implementation uses a reduced-complexity implementation # of the Lagrange inversion formula. - void fmpz_poly_revert_series_lagrange_fast(fmpz_poly_t Qinv, const fmpz_poly_t Q, long n) + void fmpz_poly_revert_series_lagrange_fast(fmpz_poly_t Qinv, const fmpz_poly_t Q, slong n) # Sets ``Qinv`` to the compositional inverse or reversion of ``Q`` # as a power series, i.e. computes `Q^{-1}` such that # `Q(Q^{-1}(x)) = Q^{-1}(Q(x)) = x \bmod x^n`. @@ -1883,7 +1883,7 @@ cdef extern from "flint_wrap.h": # This implementation uses a reduced-complexity implementation # of the Lagrange inversion formula. - void _fmpz_poly_revert_series_newton(fmpz * Qinv, const fmpz * Q, long Qlen, long n) + void _fmpz_poly_revert_series_newton(fmpz * Qinv, const fmpz * Q, slong Qlen, slong n) # Sets ``Qinv`` to the compositional inverse or reversion of ``Q`` # as a power series, i.e. computes `Q^{-1}` such that # `Q(Q^{-1}(x)) = Q^{-1}(Q(x)) = x \bmod x^n`. The arguments may not be @@ -1891,14 +1891,14 @@ cdef extern from "flint_wrap.h": # It is required that `Q_0 = 0` and `Q_1 = \pm 1`. # This implementation uses Newton iteration [BrentKung1978]_. - void fmpz_poly_revert_series_newton(fmpz_poly_t Qinv, const fmpz_poly_t Q, long n) + void fmpz_poly_revert_series_newton(fmpz_poly_t Qinv, const fmpz_poly_t Q, slong n) # Sets ``Qinv`` to the compositional inverse or reversion of ``Q`` # as a power series, i.e. computes `Q^{-1}` such that # `Q(Q^{-1}(x)) = Q^{-1}(Q(x)) = x \bmod x^n`. # It is required that `Q_0 = 0` and `Q_1 = \pm 1`. # This implementation uses Newton iteration [BrentKung1978]_. - void _fmpz_poly_revert_series(fmpz * Qinv, const fmpz * Q, long Qlen, long n) + void _fmpz_poly_revert_series(fmpz * Qinv, const fmpz * Q, slong Qlen, slong n) # Sets ``Qinv`` to the compositional inverse or reversion of ``Q`` # as a power series, i.e. computes `Q^{-1}` such that # `Q(Q^{-1}(x)) = Q^{-1}(Q(x)) = x \bmod x^n`. The arguments may not be @@ -1907,7 +1907,7 @@ cdef extern from "flint_wrap.h": # This implementation defaults to the fast version of # Lagrange interpolation. - void fmpz_poly_revert_series(fmpz_poly_t Qinv, const fmpz_poly_t Q, long n) + void fmpz_poly_revert_series(fmpz_poly_t Qinv, const fmpz_poly_t Q, slong n) # Sets ``Qinv`` to the compositional inverse or reversion of ``Q`` # as a power series, i.e. computes `Q^{-1}` such that # `Q(Q^{-1}(x)) = Q^{-1}(Q(x)) = x \bmod x^n`. @@ -1915,7 +1915,7 @@ cdef extern from "flint_wrap.h": # This implementation defaults to the fast version of # Lagrange interpolation. - int _fmpz_poly_sqrtrem_classical(fmpz * res, fmpz * r, const fmpz * poly, long len) + int _fmpz_poly_sqrtrem_classical(fmpz * res, fmpz * r, const fmpz * poly, slong len) # Returns 1 if ``(poly, len)`` can be written in the form `A^2 + R` where # deg(`R`) < deg(``poly``), otherwise returns `0`. If it can be so # written, ``(res, m - 1)`` is set to `A` and ``(res, m)`` is set to @@ -1927,7 +1927,7 @@ cdef extern from "flint_wrap.h": # If `a` can be written as `b^2 + r` with `\deg(r) < \deg(a)/2`, return # `1` and set `b` and `r` appropriately. Otherwise return `0`. - int _fmpz_poly_sqrtrem_divconquer(fmpz * res, fmpz * r, const fmpz * poly, long len, fmpz * temp) + int _fmpz_poly_sqrtrem_divconquer(fmpz * res, fmpz * r, const fmpz * poly, slong len, fmpz * temp) # Returns 1 if ``(poly, len)`` can be written in the form `A^2 + R` where # deg(`R`) < deg(``poly``), otherwise returns `0`. If it can be so # written, ``(res, m - 1)`` is set to `A` and ``(res, m)`` is set to @@ -1940,7 +1940,7 @@ cdef extern from "flint_wrap.h": # If `a` can be written as `b^2 + r` with `\deg(r) < \deg(a)/2`, return # `1` and set `b` and `r` appropriately. Otherwise return `0`. - int _fmpz_poly_sqrt_classical(fmpz * res, const fmpz * poly, long len, int exact) + int _fmpz_poly_sqrt_classical(fmpz * res, const fmpz * poly, slong len, int exact) # If ``exact`` is `1` and ``(poly, len)`` is a perfect square, sets # ``(res, len / 2 + 1)`` to the square root of ``poly`` with positive # leading coefficient and returns 1. Otherwise returns 0. @@ -1955,7 +1955,7 @@ cdef extern from "flint_wrap.h": # ``a`` with positive leading coefficient and returns 1. # Otherwise returns 0. - int _fmpz_poly_sqrt_KS(fmpz * res, const fmpz * poly, long len) + int _fmpz_poly_sqrt_KS(fmpz * res, const fmpz * poly, slong len) # Heuristic square root. If the return value is `-1`, the function failed, # otherwise it succeeded and the following applies. # If ``(poly, len)`` is a perfect square, sets @@ -1971,7 +1971,7 @@ cdef extern from "flint_wrap.h": # ``a`` with positive leading coefficient and returns 1. # Otherwise returns 0. - int _fmpz_poly_sqrt_divconquer(fmpz * res, const fmpz * poly, long len, int exact) + int _fmpz_poly_sqrt_divconquer(fmpz * res, const fmpz * poly, slong len, int exact) # If ``exact`` is `1` and ``(poly, len)`` is a perfect square, sets # ``(res, len / 2 + 1)`` to the square root of ``poly`` with positive # leading coefficient and returns 1. Otherwise returns 0. @@ -1985,7 +1985,7 @@ cdef extern from "flint_wrap.h": # ``a`` with positive leading coefficient and returns 1. # Otherwise returns 0. - int _fmpz_poly_sqrt(fmpz * res, const fmpz * poly, long len) + int _fmpz_poly_sqrt(fmpz * res, const fmpz * poly, slong len) # If ``(poly, len)`` is a perfect square, sets ``(res, len / 2 + 1)`` # to the square root of ``poly`` with positive leading coefficient # and returns 1. Otherwise returns 0. @@ -1995,14 +1995,14 @@ cdef extern from "flint_wrap.h": # ``a`` with positive leading coefficient and returns 1. # Otherwise returns 0. - int _fmpz_poly_sqrt_series(fmpz * res, const fmpz * poly, long len, long n) + int _fmpz_poly_sqrt_series(fmpz * res, const fmpz * poly, slong len, slong n) # Set ``(res, n)`` to the square root of the series ``(poly, n)``, if it # exists, and return `1`, otherwise, return `0`. # If the valuation of ``poly`` is not zero, ``res`` is zero padded # to make up for the fact that the square root may not be known to precision # `n`. - int fmpz_poly_sqrt_series(fmpz_poly_t b, const fmpz_poly_t a, long n) + int fmpz_poly_sqrt_series(fmpz_poly_t b, const fmpz_poly_t a, slong n) # Set ``b`` to the square root of the series ``a``, where the latter # is taken to be a series of precision `n`. If such a square root exists, # return `1`, otherwise, return `0`. @@ -2010,31 +2010,31 @@ cdef extern from "flint_wrap.h": # not have precision ``n``. It is given only to the precision to which # the square root can be computed. - void _fmpz_poly_power_sums_naive(fmpz * res, const fmpz * poly, long len, long n) + void _fmpz_poly_power_sums_naive(fmpz * res, const fmpz * poly, slong len, slong n) # Compute the (truncated) power sums series of the monic polynomial # ``(poly,len)`` up to length `n` using Newton identities. - void fmpz_poly_power_sums_naive(fmpz_poly_t res, const fmpz_poly_t poly, long n) + void fmpz_poly_power_sums_naive(fmpz_poly_t res, const fmpz_poly_t poly, slong n) # Compute the (truncated) power sum series of the monic polynomial # ``poly`` up to length `n` using Newton identities. - void fmpz_poly_power_sums(fmpz_poly_t res, const fmpz_poly_t poly, long n) + void fmpz_poly_power_sums(fmpz_poly_t res, const fmpz_poly_t poly, slong n) # Compute the (truncated) power sums series of the monic polynomial ``poly`` # up to length `n`. That is the power series whose coefficient of degree `i` is # the sum of the `i`-th power of all (complex) roots of the polynomial # ``poly``. - void _fmpz_poly_power_sums_to_poly(fmpz * res, const fmpz * poly, long len) + void _fmpz_poly_power_sums_to_poly(fmpz * res, const fmpz * poly, slong len) # Compute the (monic) polynomial given by its power sums series ``(poly,len)``. void fmpz_poly_power_sums_to_poly(fmpz_poly_t res, const fmpz_poly_t Q) # Compute the (monic) polynomial given its power sums series ``(Q)``. - void _fmpz_poly_signature(long * r1, long * r2, const fmpz * poly, long len) + void _fmpz_poly_signature(slong * r1, slong * r2, const fmpz * poly, slong len) # Computes the signature `(r_1, r_2)` of the polynomial # ``(poly, len)``. Assumes that the polynomial is squarefree over `\mathbb{Q}`. - void fmpz_poly_signature(long * r1, long * r2, const fmpz_poly_t poly) + void fmpz_poly_signature(slong * r1, slong * r2, const fmpz_poly_t poly) # Computes the signature `(r_1, r_2)` of the polynomial ``poly``, # which is assumed to be square-free over `\mathbb{Q}`. The values of `r_1` and # `2 r_2` are the number of real and complex roots of the polynomial, @@ -2045,7 +2045,7 @@ cdef extern from "flint_wrap.h": # This function uses the algorithm described # in Algorithm 4.1.11 of [Coh1996]_. - void fmpz_poly_hensel_build_tree(long * link, fmpz_poly_t *v, fmpz_poly_t *w, const nmod_poly_factor_t fac) + void fmpz_poly_hensel_build_tree(slong * link, fmpz_poly_t *v, fmpz_poly_t *w, const nmod_poly_factor_t fac) # Initialises and builds a Hensel tree consisting of two arrays `v`, `w` # of polynomials and an array of links, called ``link``. # The caller supplies a set of `r` local factors (in the factor structure @@ -2104,7 +2104,7 @@ cdef extern from "flint_wrap.h": # lifts only the cofactors `a` and `b` modulo `P = p p_1`. # See :func:`fmpz_poly_hensel_lift`. - void fmpz_poly_hensel_lift_tree_recursive(long *link, fmpz_poly_t *v, fmpz_poly_t *w, fmpz_poly_t f, long j, long inv, const fmpz_t p0, const fmpz_t p1) + void fmpz_poly_hensel_lift_tree_recursive(slong *link, fmpz_poly_t *v, fmpz_poly_t *w, fmpz_poly_t f, slong j, slong inv, const fmpz_t p0, const fmpz_t p1) # Takes a current Hensel tree ``(link, v, w)`` and a pair `(j,j+1)` # of entries in the tree and lifts the tree from mod `p_0` to # mod `P = p_0 p_1`, where `1 < p_1 \leq p_0`. @@ -2117,7 +2117,7 @@ cdef extern from "flint_wrap.h": # the lists `v` and `w`. But the polynomials in these two lists # are not allowed to be aliases of each other. - void fmpz_poly_hensel_lift_tree(long *link, fmpz_poly_t *v, fmpz_poly_t *w, fmpz_poly_t f, long r, const fmpz_t p, long e0, long e1, long inv) + void fmpz_poly_hensel_lift_tree(slong *link, fmpz_poly_t *v, fmpz_poly_t *w, fmpz_poly_t f, slong r, const fmpz_t p, slong e0, slong e1, slong inv) # Computes `p_0 = p^{e_0}` and `p_1 = p^{e_1 - e_0}` for a small prime `p` # and `P = p^{e_1}`. # If we aim to lift to `p^b` then `f` is the polynomial whose factors we @@ -2132,7 +2132,7 @@ cdef extern from "flint_wrap.h": # Assumes that `f` is monic. # Assumes that `1 < p_1 \leq p_0`, that is, `0 < e_1 \leq e_0`. - long _fmpz_poly_hensel_start_lift(fmpz_poly_factor_t lifted_fac, long *link, fmpz_poly_t *v, fmpz_poly_t *w, const fmpz_poly_t f, const nmod_poly_factor_t local_fac, long N) + slong _fmpz_poly_hensel_start_lift(fmpz_poly_factor_t lifted_fac, slong *link, fmpz_poly_t *v, fmpz_poly_t *w, const fmpz_poly_t f, const nmod_poly_factor_t local_fac, slong N) # This function takes the local factors in ``local_fac`` # and Hensel lifts them until they are known mod `p^N`, where # `N \geq 1`. @@ -2150,7 +2150,7 @@ cdef extern from "flint_wrap.h": # over the local factors and convert them to polynomials over # `\mathbf{Z}`. - long _fmpz_poly_hensel_continue_lift(fmpz_poly_factor_t lifted_fac, long *link, fmpz_poly_t *v, fmpz_poly_t *w, const fmpz_poly_t f, long prev, long curr, long N, const fmpz_t p) + slong _fmpz_poly_hensel_continue_lift(fmpz_poly_factor_t lifted_fac, slong *link, fmpz_poly_t *v, fmpz_poly_t *w, const fmpz_poly_t f, slong prev, slong curr, slong N, const fmpz_t p) # This function restarts a stopped Hensel lift. # It lifts from ``curr`` to `N`. It also requires ``prev`` # (to lift the cofactors) given as the return value of the function @@ -2164,14 +2164,14 @@ cdef extern from "flint_wrap.h": # Currently, supports the case when ``prev`` and ``curr`` # are equal. - void fmpz_poly_hensel_lift_once(fmpz_poly_factor_t lifted_fac, const fmpz_poly_t f, const nmod_poly_factor_t local_fac, long N) + void fmpz_poly_hensel_lift_once(fmpz_poly_factor_t lifted_fac, const fmpz_poly_t f, const nmod_poly_factor_t local_fac, slong N) # This function does a Hensel lift. # It lifts local factors stored in ``local_fac`` of `f` to `p^N`, # where `N \geq 2`. The lifted factors will be stored in ``lifted_fac``. # This lift cannot be restarted. This function is a convenience function # intended for end users. The product of local factors must be squarefree. - int _fmpz_poly_print(const fmpz * poly, long len) + int _fmpz_poly_print(const fmpz * poly, slong len) # Prints the polynomial ``(poly, len)`` to ``stdout``. # In case of success, returns a positive value. In case of failure, # returns a non-positive value. @@ -2181,7 +2181,7 @@ cdef extern from "flint_wrap.h": # In case of success, returns a positive value. In case of failure, # returns a non-positive value. - int _fmpz_poly_print_pretty(const fmpz * poly, long len, const char * x) + int _fmpz_poly_print_pretty(const fmpz * poly, slong len, const char * x) # Prints the pretty representation of ``(poly, len)`` to ``stdout``, # using the string ``x`` to represent the indeterminate. # In case of success, returns a positive value. In case of failure, @@ -2193,7 +2193,7 @@ cdef extern from "flint_wrap.h": # In case of success, returns a positive value. In case of failure, # returns a non-positive value. - int _fmpz_poly_fprint(FILE * file, const fmpz * poly, long len) + int _fmpz_poly_fprint(FILE * file, const fmpz * poly, slong len) # Prints the polynomial ``(poly, len)`` to the stream ``file``. # In case of success, returns a positive value. In case of failure, # returns a non-positive value. @@ -2203,7 +2203,7 @@ cdef extern from "flint_wrap.h": # In case of success, returns a positive value. In case of failure, # returns a non-positive value. - int _fmpz_poly_fprint_pretty(FILE * file, const fmpz * poly, long len, const char * x) + int _fmpz_poly_fprint_pretty(FILE * file, const fmpz * poly, slong len, const char * x) # Prints the pretty representation of ``(poly, len)`` to the stream # ``file``, using the string ``x`` to represent the indeterminate. # In case of success, returns a positive value. In case of failure, @@ -2252,7 +2252,7 @@ cdef extern from "flint_wrap.h": # Sets the coefficients of ``A`` to the residues in ``Amod``, # normalised to the interval `0 \le r < m` where `m` is the modulus. - void _fmpz_poly_CRT_ui_precomp(fmpz * res, const fmpz * poly1, long len1, const fmpz_t m1, mp_srcptr poly2, long len2, mp_limb_t m2, mp_limb_t m2inv, fmpz_t m1m2, mp_limb_t c, int sign) + void _fmpz_poly_CRT_ui_precomp(fmpz * res, const fmpz * poly1, slong len1, const fmpz_t m1, mp_srcptr poly2, slong len2, mp_limb_t m2, mp_limb_t m2inv, fmpz_t m1m2, mp_limb_t c, int sign) # Sets the coefficients in ``res`` to the CRT reconstruction modulo # `m_1m_2` of the residues ``(poly1, len1)`` and ``(poly2, len2)`` # which are images modulo `m_1` and `m_2` respectively. @@ -2265,7 +2265,7 @@ cdef extern from "flint_wrap.h": # Coefficients of ``res`` are written up to the maximum of # ``len1`` and ``len2``. - void _fmpz_poly_CRT_ui(fmpz * res, const fmpz * poly1, long len1, const fmpz_t m1, mp_srcptr poly2, long len2, mp_limb_t m2, mp_limb_t m2inv, int sign) + void _fmpz_poly_CRT_ui(fmpz * res, const fmpz * poly1, slong len1, const fmpz_t m1, mp_srcptr poly2, slong len2, mp_limb_t m2, mp_limb_t m2inv, int sign) # This function is identical to ``_fmpz_poly_CRT_ui_precomp``, # apart from automatically computing `m_1m_2` and `c`. It also # aborts if `c` cannot be computed. @@ -2276,28 +2276,28 @@ cdef extern from "flint_wrap.h": # with coefficients satisfying `-mn/2 \le c < mn/2` (if sign = 1) # or `0 \le c < mn` (if sign = 0). - void _fmpz_poly_product_roots_fmpz_vec(fmpz * poly, const fmpz * xs, long n) + void _fmpz_poly_product_roots_fmpz_vec(fmpz * poly, const fmpz * xs, slong n) # Sets ``(poly, n + 1)`` to the monic polynomial which is the product # of `(x - x_0)(x - x_1) \cdots (x - x_{n-1})`, the roots `x_i` being # given by ``xs``. # Aliasing of the input and output is not allowed. - void fmpz_poly_product_roots_fmpz_vec(fmpz_poly_t poly, const fmpz * xs, long n) + void fmpz_poly_product_roots_fmpz_vec(fmpz_poly_t poly, const fmpz * xs, slong n) # Sets ``poly`` to the monic polynomial which is the product # of `(x - x_0)(x - x_1) \cdots (x - x_{n-1})`, the roots `x_i` being # given by ``xs``. - void _fmpz_poly_product_roots_fmpq_vec(fmpz * poly, const fmpq * xs, long n) + void _fmpz_poly_product_roots_fmpq_vec(fmpz * poly, const fmpq * xs, slong n) # Sets ``(poly, n + 1)`` to the product of # `(q_0 x - p_0)(q_1 x - p_1) \cdots (q_{n-1} x - p_{n-1})`, the roots # `p_i/q_i` being given by ``xs``. - void fmpz_poly_product_roots_fmpq_vec(fmpz_poly_t poly, const fmpq * xs, long n) + void fmpz_poly_product_roots_fmpq_vec(fmpz_poly_t poly, const fmpq * xs, slong n) # Sets ``poly`` to the polynomial which is the product # of `(q_0 x - p_0)(q_1 x - p_1) \cdots (q_{n-1} x - p_{n-1})`, the roots # `p_i/q_i` being given by ``xs``. - void _fmpz_poly_bound_roots(fmpz_t bound, const fmpz * poly, long len) + void _fmpz_poly_bound_roots(fmpz_t bound, const fmpz * poly, slong len) void fmpz_poly_bound_roots(fmpz_t bound, const fmpz_poly_t poly) # Computes a nonnegative integer ``bound`` that bounds the absolute # value of all complex roots of ``poly``. Uses Fujiwara's bound @@ -2310,7 +2310,7 @@ cdef extern from "flint_wrap.h": # \right) # where the coefficients of the polynomial are `a_0, \ldots, a_n`. - void _fmpz_poly_num_real_roots_sturm(long * n_neg, long * n_pos, const fmpz * pol, long len) + void _fmpz_poly_num_real_roots_sturm(slong * n_neg, slong * n_pos, const fmpz * pol, slong len) # Sets ``n_neg`` and ``n_pos`` to the number of negative and # positive roots of the polynomial ``(pol, len)`` using Sturm # sequence. The Sturm sequence is computed via subresultant @@ -2319,21 +2319,21 @@ cdef extern from "flint_wrap.h": # The polynomial is assumed to be squarefree, of degree larger than 1 # and with non-zero constant coefficient. - long fmpz_poly_num_real_roots_sturm(const fmpz_poly_t pol) + slong fmpz_poly_num_real_roots_sturm(const fmpz_poly_t pol) # Returns the number of real roots of the squarefree polynomial ``pol`` # using Sturm sequence. # The polynomial is assumed to be squarefree. - long _fmpz_poly_num_real_roots(const fmpz * pol, long len) + slong _fmpz_poly_num_real_roots(const fmpz * pol, slong len) # Returns the number of real roots of the squarefree polynomial # ``(pol, len)``. # The polynomial is assumed to be squarefree. - long fmpz_poly_num_real_roots(const fmpz_poly_t pol) + slong fmpz_poly_num_real_roots(const fmpz_poly_t pol) # Returns the number of real roots of the squarefree polynomial ``pol``. # The polynomial is assumed to be squarefree. - void _fmpz_poly_cyclotomic(fmpz * a, unsigned long n, mp_ptr factors, long num_factors, unsigned long phi) + void _fmpz_poly_cyclotomic(fmpz * a, ulong n, mp_ptr factors, slong num_factors, ulong phi) # Sets ``a`` to the lower half of the cyclotomic polynomial `\Phi_n(x)`, # given `n \ge 3` which must be squarefree. # A precomputed array containing the prime factors of `n` must be provided, @@ -2366,21 +2366,21 @@ cdef extern from "flint_wrap.h": # and if `n = 2m`, we use `\Phi_n(x) = \Phi_m(-x)` to fall back # to the case when `n` is odd. - void fmpz_poly_cyclotomic(fmpz_poly_t poly, unsigned long n) + void fmpz_poly_cyclotomic(fmpz_poly_t poly, ulong n) # Sets ``poly`` to the `n`-th cyclotomic polynomial, defined as # `\Phi_n(x) = \prod_{\omega} (x-\omega)` # where `\omega` runs over all the `n`-th primitive roots of unity. # We factor `n` into `n = qs` where `q` is squarefree, # and compute `\Phi_q(x)`. Then `\Phi_n(x) = \Phi_q(x^s)`. - unsigned long _fmpz_poly_is_cyclotomic(const fmpz * poly, long len) - unsigned long fmpz_poly_is_cyclotomic(const fmpz_poly_t poly) + ulong _fmpz_poly_is_cyclotomic(const fmpz * poly, slong len) + ulong fmpz_poly_is_cyclotomic(const fmpz_poly_t poly) # If ``poly`` is a cyclotomic polynomial, returns the index `n` of this # cyclotomic polynomial. If ``poly`` is not a cyclotomic polynomial, # returns 0. - void _fmpz_poly_cos_minpoly(fmpz * coeffs, unsigned long n) - void fmpz_poly_cos_minpoly(fmpz_poly_t poly, unsigned long n) + void _fmpz_poly_cos_minpoly(fmpz * coeffs, ulong n) + void fmpz_poly_cos_minpoly(fmpz_poly_t poly, ulong n) # Sets ``poly`` to the minimal polynomial of `2 \cos(2 \pi / n)`. # For suitable choice of `n`, this gives the minimal polynomial # of `2 \cos(a \pi)` or `2 \sin(a \pi)` for any rational `a`. @@ -2393,8 +2393,8 @@ cdef extern from "flint_wrap.h": # the output to be the constant polynomial 1. # See [WaktinsZeitlin1993]_. - void _fmpz_poly_swinnerton_dyer(fmpz * coeffs, unsigned long n) - void fmpz_poly_swinnerton_dyer(fmpz_poly_t poly, unsigned long n) + void _fmpz_poly_swinnerton_dyer(fmpz * coeffs, ulong n) + void fmpz_poly_swinnerton_dyer(fmpz_poly_t poly, ulong n) # Sets ``poly`` to the Swinnerton-Dyer polynomial `S_n`, defined as # the integer polynomial # `S_n = \prod (x \pm \sqrt{2} \pm \sqrt{3} \pm \sqrt{5} \pm \ldots \pm \sqrt{p_n})` @@ -2403,68 +2403,68 @@ cdef extern from "flint_wrap.h": # irreducible over the integers (it is the minimal polynomial # of `\sqrt{2} + \ldots + \sqrt{p_n}`). - void _fmpz_poly_chebyshev_t(fmpz * coeffs, unsigned long n) - void fmpz_poly_chebyshev_t(fmpz_poly_t poly, unsigned long n) + void _fmpz_poly_chebyshev_t(fmpz * coeffs, ulong n) + void fmpz_poly_chebyshev_t(fmpz_poly_t poly, ulong n) # Sets ``poly`` to the Chebyshev polynomial of the first kind `T_n(x)`, # defined by `T_n(x) = \cos(n \cos^{-1}(x))`, for `n\ge0`. The coefficients are # calculated using a hypergeometric recurrence. - void _fmpz_poly_chebyshev_u(fmpz * coeffs, unsigned long n) - void fmpz_poly_chebyshev_u(fmpz_poly_t poly, unsigned long n) + void _fmpz_poly_chebyshev_u(fmpz * coeffs, ulong n) + void fmpz_poly_chebyshev_u(fmpz_poly_t poly, ulong n) # Sets ``poly`` to the Chebyshev polynomial of the first kind `U_n(x)`, # defined by `(n+1) U_n(x) = T'_{n+1}(x)`, for `n\ge0`. # The coefficients are calculated using a hypergeometric recurrence. - void _fmpz_poly_legendre_pt(fmpz * coeffs, unsigned long n) + void _fmpz_poly_legendre_pt(fmpz * coeffs, ulong n) # Sets ``coeffs`` to the coefficient array of the shifted Legendre # polynomial `\tilde{P_n}(x)`, defined by `\tilde{P_n}(x) = P_n(2x-1)`, for `n\ge0`. # The coefficients are calculated using a hypergeometric recurrence. # The length of the array will be ``n+1``. # See ``fmpq_poly`` for the Legendre polynomials. - void fmpz_poly_legendre_pt(fmpz_poly_t poly, unsigned long n) + void fmpz_poly_legendre_pt(fmpz_poly_t poly, ulong n) # Sets ``poly`` to the shifted Legendre polynomial `\tilde{P_n}(x)`, # defined by `\tilde{P_n}(x) = P_n(2x-1)`, for `n\ge0`. The coefficients are # calculated using a hypergeometric recurrence. See ``fmpq_poly`` # for the Legendre polynomials. - void _fmpz_poly_hermite_h(fmpz * coeffs, unsigned long n) + void _fmpz_poly_hermite_h(fmpz * coeffs, ulong n) # Sets ``coeffs`` to the coefficient array of the Hermite # polynomial `H_n(x)`, defined by `H'_n(x) = 2nH_{n-1}(x)`, for `n\ge0`. # The coefficients are calculated using a hypergeometric recurrence. # The length of the array will be ``n+1``. - void fmpz_poly_hermite_h(fmpz_poly_t poly, unsigned long n) + void fmpz_poly_hermite_h(fmpz_poly_t poly, ulong n) # Sets ``poly`` to the Hermite polynomial `H_n(x)`, # defined by `H'_n(x) = 2nH_{n-1}(x)`, for `n\ge0`. The coefficients are # calculated using a hypergeometric recurrence. - void _fmpz_poly_hermite_he(fmpz * coeffs, unsigned long n) + void _fmpz_poly_hermite_he(fmpz * coeffs, ulong n) # Sets ``coeffs`` to the coefficient array of the Hermite # polynomial `He_n(x)`, defined by # `He_n(x) = 2^{-\tfrac{n}{2}}H_n\left(\frac{x}{\sqrt2}\right)`, for `n\ge0`. # The coefficients are calculated using a hypergeometric recurrence. # The length of the array will be ``n+1``. - void fmpz_poly_hermite_he(fmpz_poly_t poly, unsigned long n) + void fmpz_poly_hermite_he(fmpz_poly_t poly, ulong n) # Sets ``poly`` to the Hermite polynomial `He_n(x)`, # defined by `He_n(x) = 2^{-\tfrac{n}{2}}H_n\left(\frac{x}{\sqrt2}\right)`, for `n\ge0`. # The coefficients are calculated using a hypergeometric recurrence. - void _fmpz_poly_fibonacci(fmpz * coeffs, unsigned long n) + void _fmpz_poly_fibonacci(fmpz * coeffs, ulong n) # Sets ``coeffs`` to the coefficient array of the `n`-th Fibonacci polynomial. # The coefficients are calculated using a hypergeometric recurrence. - void fmpz_poly_fibonacci(fmpz_poly_t poly, unsigned long n) + void fmpz_poly_fibonacci(fmpz_poly_t poly, ulong n) # Sets ``poly`` to the `n`-th Fibonacci polynomial. # The coefficients are calculated using a hypergeometric recurrence. - void arith_eulerian_polynomial(fmpz_poly_t res, unsigned long n) + void arith_eulerian_polynomial(fmpz_poly_t res, ulong n) # Sets ``res`` to the Eulerian polynomial `A_n(x)`, where we define # `A_0(x) = 1`. The polynomial is calculated via a recursive relation. - void _fmpz_poly_eta_qexp(fmpz * f, long r, long len) - void fmpz_poly_eta_qexp(fmpz_poly_t f, long r, long n) + void _fmpz_poly_eta_qexp(fmpz * f, slong r, slong len) + void fmpz_poly_eta_qexp(fmpz_poly_t f, slong r, slong n) # Sets `f` to the `q`-expansion to length `n` of the # Dedekind eta function (without the leading factor # `q^{1/24}`) raised to the power `r`, i.e. @@ -2477,15 +2477,15 @@ cdef extern from "flint_wrap.h": # This function uses sparse formulas for `r = 1, 2, 3, 4, 6` # and otherwise reduces to one of those cases using power series arithmetic. - void _fmpz_poly_theta_qexp(fmpz * f, long r, long len) - void fmpz_poly_theta_qexp(fmpz_poly_t f, long r, long n) + void _fmpz_poly_theta_qexp(fmpz * f, slong r, slong len) + void fmpz_poly_theta_qexp(fmpz_poly_t f, slong r, slong n) # Sets `f` to the `q`-expansion to length `n` of the # Jacobi theta function raised to the power `r`, i.e. `\vartheta(q)^r` # where `\vartheta(q) = 1 + 2 \sum_{k=1}^{\infty} q^{k^2}`. # This function uses sparse formulas for `r = 1, 2` # and otherwise reduces to those cases using power series arithmetic. - void fmpz_poly_CLD_bound(fmpz_t res, const fmpz_poly_t f, long n) + void fmpz_poly_CLD_bound(fmpz_t res, const fmpz_poly_t f, slong n) # Compute a bound on the `n` coefficient of `fg'/g` where `g` is any # factor of `f`. diff --git a/src/sage/libs/flint/fmpz_poly_factor.pxd b/src/sage/libs/flint/fmpz_poly_factor.pxd index 5af3341e064..f5c2e97e5b5 100644 --- a/src/sage/libs/flint/fmpz_poly_factor.pxd +++ b/src/sage/libs/flint/fmpz_poly_factor.pxd @@ -15,15 +15,15 @@ cdef extern from "flint_wrap.h": void fmpz_poly_factor_init(fmpz_poly_factor_t fac) # Initialises a new factor structure. - void fmpz_poly_factor_init2(fmpz_poly_factor_t fac, long alloc) + void fmpz_poly_factor_init2(fmpz_poly_factor_t fac, slong alloc) # Initialises a new factor structure, providing space for # at least ``alloc`` factors. - void fmpz_poly_factor_realloc(fmpz_poly_factor_t fac, long alloc) + void fmpz_poly_factor_realloc(fmpz_poly_factor_t fac, slong alloc) # Reallocates the factor structure to provide space for # precisely ``alloc`` factors. - void fmpz_poly_factor_fit_length(fmpz_poly_factor_t fac, long len) + void fmpz_poly_factor_fit_length(fmpz_poly_factor_t fac, slong len) # Ensures that the factor structure has space for at # least ``len`` factors. This functions takes care # of the case of repeated calls by always at least @@ -35,7 +35,7 @@ cdef extern from "flint_wrap.h": void fmpz_poly_factor_set(fmpz_poly_factor_t res, const fmpz_poly_factor_t fac) # Sets ``res`` to the same factorisation as ``fac``. - void fmpz_poly_factor_insert(fmpz_poly_factor_t fac, const fmpz_poly_t p, long e) + void fmpz_poly_factor_insert(fmpz_poly_factor_t fac, const fmpz_poly_t p, slong e) # Adds the primitive polynomial `p^e` to the factorisation ``fac``. # Assumes that `\deg(p) \geq 2` and `e \neq 0`. @@ -58,7 +58,7 @@ cdef extern from "flint_wrap.h": # F = c \prod_{i} g_i^{e_i} # where `c` is the signed content of `F` and `\gcd(g_i, g_i') = 1`. - void fmpz_poly_factor_zassenhaus_recombination(fmpz_poly_factor_t final_fac, const fmpz_poly_factor_t lifted_fac, const fmpz_poly_t F, const fmpz_t P, long exp) + void fmpz_poly_factor_zassenhaus_recombination(fmpz_poly_factor_t final_fac, const fmpz_poly_factor_t lifted_fac, const fmpz_poly_t F, const fmpz_t P, slong exp) # Takes as input a factor structure ``lifted_fac`` containing a # squarefree factorization of the polynomial `F \bmod p`. The algorithm # does a brute force search for irreducible factors of `F` over the @@ -66,7 +66,7 @@ cdef extern from "flint_wrap.h": # The impact of the algorithm is to augment a factorization of # ``F^exp`` to the factor structure ``final_fac``. - void _fmpz_poly_factor_zassenhaus(fmpz_poly_factor_t final_fac, long exp, const fmpz_poly_t f, long cutoff, int use_van_hoeij) + void _fmpz_poly_factor_zassenhaus(fmpz_poly_factor_t final_fac, slong exp, const fmpz_poly_t f, slong cutoff, int use_van_hoeij) # This is the internal wrapper of Zassenhaus. # It will attempt to find a small prime such that `f` modulo `p` has # a minimal number of factors. If it cannot find a prime giving less @@ -88,8 +88,8 @@ cdef extern from "flint_wrap.h": # The complexity will be exponential in the number of local factors # we find for the components of a squarefree factorization of `F`. - void _fmpz_poly_factor_quadratic(fmpz_poly_factor_t fac, const fmpz_poly_t f, long exp) - void _fmpz_poly_factor_cubic(fmpz_poly_factor_t fac, const fmpz_poly_t f, long exp) + void _fmpz_poly_factor_quadratic(fmpz_poly_factor_t fac, const fmpz_poly_t f, slong exp) + void _fmpz_poly_factor_cubic(fmpz_poly_factor_t fac, const fmpz_poly_t f, slong exp) # Inserts the factorisation of the quadratic (resp. cubic) polynomial *f* into *fac* with # multiplicity *exp*. This function requires that the content of *f* has # been removed, and does not update the content of *fac*. diff --git a/src/sage/libs/flint/fmpz_poly_mat.pxd b/src/sage/libs/flint/fmpz_poly_mat.pxd index 50d814146d5..5e4ebdc9d5d 100644 --- a/src/sage/libs/flint/fmpz_poly_mat.pxd +++ b/src/sage/libs/flint/fmpz_poly_mat.pxd @@ -12,7 +12,7 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void fmpz_poly_mat_init(fmpz_poly_mat_t mat, long rows, long cols) + void fmpz_poly_mat_init(fmpz_poly_mat_t mat, slong rows, slong cols) # Initialises a matrix with the given number of rows and columns for use. void fmpz_poly_mat_init_set(fmpz_poly_mat_t mat, const fmpz_poly_mat_t src) @@ -23,13 +23,13 @@ cdef extern from "flint_wrap.h": # Frees all memory associated with the matrix. The matrix must be # reinitialised if it is to be used again. - long fmpz_poly_mat_nrows(const fmpz_poly_mat_t mat) + slong fmpz_poly_mat_nrows(const fmpz_poly_mat_t mat) # Returns the number of rows in ``mat``. - long fmpz_poly_mat_ncols(const fmpz_poly_mat_t mat) + slong fmpz_poly_mat_ncols(const fmpz_poly_mat_t mat) # Returns the number of columns in ``mat``. - fmpz_poly_struct * fmpz_poly_mat_entry(const fmpz_poly_mat_t mat, long i, long j) + fmpz_poly_struct * fmpz_poly_mat_entry(const fmpz_poly_mat_t mat, slong i, slong j) # Gives a reference to the entry at row ``i`` and column ``j``. # The reference can be passed as an input or output variable to any # ``fmpz_poly`` function for direct manipulation of the matrix element. @@ -49,15 +49,15 @@ cdef extern from "flint_wrap.h": # Prints the matrix ``mat`` to standard output, using the # variable ``x``. - void fmpz_poly_mat_randtest(fmpz_poly_mat_t mat, flint_rand_t state, long len, flint_bitcnt_t bits) + void fmpz_poly_mat_randtest(fmpz_poly_mat_t mat, flint_rand_t state, slong len, flint_bitcnt_t bits) # This is equivalent to applying ``fmpz_poly_randtest`` to all entries # in the matrix. - void fmpz_poly_mat_randtest_unsigned(fmpz_poly_mat_t mat, flint_rand_t state, long len, flint_bitcnt_t bits) + void fmpz_poly_mat_randtest_unsigned(fmpz_poly_mat_t mat, flint_rand_t state, slong len, flint_bitcnt_t bits) # This is equivalent to applying ``fmpz_poly_randtest_unsigned`` to # all entries in the matrix. - void fmpz_poly_mat_randtest_sparse(fmpz_poly_mat_t A, flint_rand_t state, long len, flint_bitcnt_t bits, float density) + void fmpz_poly_mat_randtest_sparse(fmpz_poly_mat_t A, flint_rand_t state, slong len, flint_bitcnt_t bits, float density) # Creates a random matrix with the amount of nonzero entries given # approximately by the ``density`` variable, which should be a fraction # between 0 (most sparse) and 1 (most dense). @@ -93,12 +93,12 @@ cdef extern from "flint_wrap.h": # Returns a non-zero value if the number of rows is equal to the # number of columns in ``mat``, and otherwise returns zero. - long fmpz_poly_mat_max_bits(const fmpz_poly_mat_t A) + slong fmpz_poly_mat_max_bits(const fmpz_poly_mat_t A) # Returns the maximum number of bits among the coefficients of the # entries in ``A``, or the negative of that value if any # coefficient is negative. - long fmpz_poly_mat_max_length(const fmpz_poly_mat_t A) + slong fmpz_poly_mat_max_length(const fmpz_poly_mat_t A) # Returns the maximum polynomial length among all the entries in ``A``. void fmpz_poly_mat_transpose(fmpz_poly_mat_t B, const fmpz_poly_mat_t A) @@ -142,7 +142,7 @@ cdef extern from "flint_wrap.h": # computed using Kronecker segmentation. The matrices must have # compatible dimensions for matrix multiplication. Aliasing is allowed. - void fmpz_poly_mat_mullow(fmpz_poly_mat_t C, const fmpz_poly_mat_t A, const fmpz_poly_mat_t B, long len) + void fmpz_poly_mat_mullow(fmpz_poly_mat_t C, const fmpz_poly_mat_t A, const fmpz_poly_mat_t B, slong len) # Sets ``C`` to the matrix product of ``A`` and ``B``, # truncating each entry in the result to length ``len``. # Uses classical matrix multiplication. The matrices must have @@ -162,27 +162,27 @@ cdef extern from "flint_wrap.h": # Sets ``B`` to the square of ``A``, which must be a square matrix. # Aliasing is allowed. This function uses Kronecker segmentation. - void fmpz_poly_mat_sqrlow(fmpz_poly_mat_t B, const fmpz_poly_mat_t A, long len) + void fmpz_poly_mat_sqrlow(fmpz_poly_mat_t B, const fmpz_poly_mat_t A, slong len) # Sets ``B`` to the square of ``A``, which must be a square matrix, # truncating all entries to length ``len``. # Aliasing is allowed. This function uses direct formulas for very small # matrices, and otherwise classical matrix multiplication. - void fmpz_poly_mat_pow(fmpz_poly_mat_t B, const fmpz_poly_mat_t A, unsigned long exp) + void fmpz_poly_mat_pow(fmpz_poly_mat_t B, const fmpz_poly_mat_t A, ulong exp) # Sets ``B`` to ``A`` raised to the power ``exp``, where ``A`` # is a square matrix. Uses exponentiation by squaring. Aliasing is allowed. - void fmpz_poly_mat_pow_trunc(fmpz_poly_mat_t B, const fmpz_poly_mat_t A, unsigned long exp, long len) + void fmpz_poly_mat_pow_trunc(fmpz_poly_mat_t B, const fmpz_poly_mat_t A, ulong exp, slong len) # Sets ``B`` to ``A`` raised to the power ``exp``, truncating # all entries to length ``len``, where ``A`` is a square matrix. # Uses exponentiation by squaring. Aliasing is allowed. - void fmpz_poly_mat_prod(fmpz_poly_mat_t res, fmpz_poly_mat_t * const factors, long n) + void fmpz_poly_mat_prod(fmpz_poly_mat_t res, fmpz_poly_mat_t * const factors, slong n) # Sets ``res`` to the product of the ``n`` matrices given in # the vector ``factors``, all of which must be square and of the # same size. Uses binary splitting. - long fmpz_poly_mat_find_pivot_any(const fmpz_poly_mat_t mat, long start_row, long end_row, long c) + slong fmpz_poly_mat_find_pivot_any(const fmpz_poly_mat_t mat, slong start_row, slong end_row, slong c) # Attempts to find a pivot entry for row reduction. # Returns a row index `r` between ``start_row`` (inclusive) and # ``stop_row`` (exclusive) such that column `c` in ``mat`` has @@ -192,7 +192,7 @@ cdef extern from "flint_wrap.h": # entries in the matrix have roughly the same size, but can lead to # unnecessary coefficient growth if the entries vary in size. - long fmpz_poly_mat_find_pivot_partial(const fmpz_poly_mat_t mat, long start_row, long end_row, long c) + slong fmpz_poly_mat_find_pivot_partial(const fmpz_poly_mat_t mat, slong start_row, slong end_row, slong c) # Attempts to find a pivot entry for row reduction. # Returns a row index `r` between ``start_row`` (inclusive) and # ``stop_row`` (exclusive) such that column `c` in ``mat`` has @@ -203,7 +203,7 @@ cdef extern from "flint_wrap.h": # the smallest coefficient bit bound. This heuristic typically reduces # coefficient growth when the matrix entries vary in size. - long fmpz_poly_mat_fflu(fmpz_poly_mat_t B, fmpz_poly_t den, long * perm, const fmpz_poly_mat_t A, int rank_check) + slong fmpz_poly_mat_fflu(fmpz_poly_mat_t B, fmpz_poly_t den, slong * perm, const fmpz_poly_mat_t A, int rank_check) # Uses fraction-free Gaussian elimination to set (``B``, ``den``) to a # fraction-free LU decomposition of ``A`` and returns the # rank of ``A``. Aliasing of ``A`` and ``B`` is allowed. @@ -217,7 +217,7 @@ cdef extern from "flint_wrap.h": # the sign is decided by the parity of the permutation. Note that the # determinant is not generally the minimal denominator. - long fmpz_poly_mat_rref(fmpz_poly_mat_t B, fmpz_poly_t den, const fmpz_poly_mat_t A) + slong fmpz_poly_mat_rref(fmpz_poly_mat_t B, fmpz_poly_t den, const fmpz_poly_mat_t A) # Sets (``B``, ``den``) to the reduced row echelon form of # ``A`` and returns the rank of ``A``. Aliasing of ``A`` and # ``B`` is allowed. @@ -244,7 +244,7 @@ cdef extern from "flint_wrap.h": # evaluating the matrix at `n` distinct points, computing the determinant # of each integer matrix, and forming the interpolating polynomial. - long fmpz_poly_mat_rank(const fmpz_poly_mat_t A) + slong fmpz_poly_mat_rank(const fmpz_poly_mat_t A) # Returns the rank of ``A``. Performs fraction-free LU decomposition # on a copy of ``A``. @@ -258,7 +258,7 @@ cdef extern from "flint_wrap.h": # Uses fraction-free LU decomposition, followed by solving for # the identity matrix. - long fmpz_poly_mat_nullspace(fmpz_poly_mat_t res, const fmpz_poly_mat_t mat) + slong fmpz_poly_mat_nullspace(fmpz_poly_mat_t res, const fmpz_poly_mat_t mat) # Computes the right rational nullspace of the matrix ``mat`` and # returns the nullity. # More precisely, assume that ``mat`` has rank `r` and nullity `n`. @@ -286,6 +286,6 @@ cdef extern from "flint_wrap.h": # Uses fraction-free LU decomposition followed by fraction-free # forward and back substitution. - void fmpz_poly_mat_solve_fflu_precomp(fmpz_poly_mat_t X, const long * perm, const fmpz_poly_mat_t FFLU, const fmpz_poly_mat_t B) + void fmpz_poly_mat_solve_fflu_precomp(fmpz_poly_mat_t X, const slong * perm, const fmpz_poly_mat_t FFLU, const fmpz_poly_mat_t B) # Performs fraction-free forward and back substitution given a precomputed # fraction-free LU decomposition and corresponding permutation. diff --git a/src/sage/libs/flint/fmpz_poly_q.pxd b/src/sage/libs/flint/fmpz_poly_q.pxd index 9dbc7adfdb1..eb7e4b4d915 100644 --- a/src/sage/libs/flint/fmpz_poly_q.pxd +++ b/src/sage/libs/flint/fmpz_poly_q.pxd @@ -32,16 +32,16 @@ cdef extern from "flint_wrap.h": # Checks whether the rational function ``op`` is in # canonical form. - void fmpz_poly_q_randtest(fmpz_poly_q_t poly, flint_rand_t state, long len1, flint_bitcnt_t bits1, long len2, flint_bitcnt_t bits2) + void fmpz_poly_q_randtest(fmpz_poly_q_t poly, flint_rand_t state, slong len1, flint_bitcnt_t bits1, slong len2, flint_bitcnt_t bits2) # Sets ``poly`` to a random rational function. - void fmpz_poly_q_randtest_not_zero(fmpz_poly_q_t poly, flint_rand_t state, long len1, flint_bitcnt_t bits1, long len2, flint_bitcnt_t bits2) + void fmpz_poly_q_randtest_not_zero(fmpz_poly_q_t poly, flint_rand_t state, slong len1, flint_bitcnt_t bits1, slong len2, flint_bitcnt_t bits2) # Sets ``poly`` to a random non-zero rational function. void fmpz_poly_q_set(fmpz_poly_q_t rop, const fmpz_poly_q_t op) # Sets the element ``rop`` to the same value as the element ``op``. - void fmpz_poly_q_set_si(fmpz_poly_q_t rop, long op) + void fmpz_poly_q_set_si(fmpz_poly_q_t rop, slong op) # Sets the element ``rop`` to the value given by the ``slong`` # ``op``. @@ -84,7 +84,7 @@ cdef extern from "flint_wrap.h": void fmpz_poly_q_submul(fmpz_poly_q_t rop, const fmpz_poly_q_t op1, const fmpz_poly_q_t op2) # Subtracts the product of ``op1`` and ``op2`` from ``rop``. - void fmpz_poly_q_scalar_mul_si(fmpz_poly_q_t rop, const fmpz_poly_q_t op, long x) + void fmpz_poly_q_scalar_mul_si(fmpz_poly_q_t rop, const fmpz_poly_q_t op, slong x) # Sets ``rop`` to the product of the rational function ``op`` # and the ``slong`` integer `x`. @@ -96,7 +96,7 @@ cdef extern from "flint_wrap.h": # Sets ``rop`` to the product of the rational function ``op`` # and the ``fmpq_t`` rational `x`. - void fmpz_poly_q_scalar_div_si(fmpz_poly_q_t rop, const fmpz_poly_q_t op, long x) + void fmpz_poly_q_scalar_div_si(fmpz_poly_q_t rop, const fmpz_poly_q_t op, slong x) # Sets ``rop`` to the quotient of the rational function ``op`` # and the ``slong`` integer `x`. @@ -114,7 +114,7 @@ cdef extern from "flint_wrap.h": void fmpz_poly_q_div(fmpz_poly_q_t rop, const fmpz_poly_q_t op1, const fmpz_poly_q_t op2) # Sets ``rop`` to the quotient of ``op1`` and ``op2``. - void fmpz_poly_q_pow(fmpz_poly_q_t rop, const fmpz_poly_q_t op, unsigned long exp) + void fmpz_poly_q_pow(fmpz_poly_q_t rop, const fmpz_poly_q_t op, ulong exp) # Sets ``rop`` to the ``exp``-th power of ``op``. # The corner case of ``exp == 0`` is handled by setting ``rop`` to # the constant function `1`. Note that this includes the case `0^0 = 1`. diff --git a/src/sage/libs/flint/fmpz_vec.pxd b/src/sage/libs/flint/fmpz_vec.pxd index 8d90aaf5ba5..a82d268cb0d 100644 --- a/src/sage/libs/flint/fmpz_vec.pxd +++ b/src/sage/libs/flint/fmpz_vec.pxd @@ -1,12 +1,292 @@ # distutils: libraries = flint # distutils: depends = flint/fmpz_vec.h -from sage.libs.flint.types cimport fmpz, slong, ulong, fmpz_t +################################################################################ +# This file is auto-generated. Do not modify by hand +################################################################################ + +from libc.stdio cimport FILE +from sage.libs.gmp.types cimport * +from sage.libs.mpfr.types cimport * +from sage.libs.flint.types cimport * -# flint/fmpz_vec.h cdef extern from "flint_wrap.h": - fmpz * _fmpz_vec_init(slong) - void _fmpz_vec_clear(fmpz *, slong) - ulong _fmpz_vec_max_limbs(const fmpz *, slong) - void _fmpz_vec_scalar_mod_fmpz(fmpz *, fmpz *, long, fmpz_t) - void _fmpz_vec_scalar_smod_fmpz(fmpz *, fmpz *, long, fmpz_t) + + fmpz * _fmpz_vec_init(slong len) + # Returns an initialised vector of ``fmpz``'s of given length. + + void _fmpz_vec_clear(fmpz * vec, slong len) + # Clears the entries of ``(vec, len)`` and frees the space allocated + # for ``vec``. + + void _fmpz_vec_randtest(fmpz * f, flint_rand_t state, slong len, flint_bitcnt_t bits) + # Sets the entries of a vector of the given length to random integers with + # up to the given number of bits per entry. + + void _fmpz_vec_randtest_unsigned(fmpz * f, flint_rand_t state, slong len, flint_bitcnt_t bits) + # Sets the entries of a vector of the given length to random unsigned + # integers with up to the given number of bits per entry. + + slong _fmpz_vec_max_bits(const fmpz * vec, slong len) + # If `b` is the maximum number of bits of the absolute value of any + # coefficient of ``vec``, then if any coefficient of ``vec`` is + # negative, `-b` is returned, else `b` is returned. + + slong _fmpz_vec_max_bits_ref(const fmpz * vec, slong len) + # If `b` is the maximum number of bits of the absolute value of any + # coefficient of ``vec``, then if any coefficient of ``vec`` is + # negative, `-b` is returned, else `b` is returned. + # This is a slower reference implementation of ``_fmpz_vec_max_bits``. + + void _fmpz_vec_sum_max_bits(slong * sumabs, slong * maxabs, const fmpz * vec, slong len) + # Sets ``sumabs`` to the bit count of the sum of the absolute values of + # the elements of ``vec``. Sets ``maxabs`` to the bit count of the + # maximum of the absolute values of the elements of ``vec``. + + mp_size_t _fmpz_vec_max_limbs(const fmpz * vec, slong len) + # Returns the maximum number of limbs needed to store the absolute value + # of any entry in ``(vec, len)``. If all entries are zero, returns + # zero. + + void _fmpz_vec_height(fmpz_t height, const fmpz * vec, slong len) + # Computes the height of ``(vec, len)``, defined as the largest of the + # absolute values the coefficients. Equivalently, this gives the infinity + # norm of the vector. If ``len`` is zero, the height is `0`. + + slong _fmpz_vec_height_index(const fmpz * vec, slong len) + # Returns the index of an entry of maximum absolute value in the vector. + # The length must be at least 1. + + int _fmpz_vec_fread(FILE * file, fmpz ** vec, slong * len) + # Reads a vector from the stream ``file`` and stores it at + # ``*vec``. The format is the same as the output format of + # ``_fmpz_vec_fprint()``, followed by either any character + # or the end of the file. + # The interpretation of the various input arguments depends on whether + # or not ``*vec`` is ``NULL``: + # If ``*vec == NULL``, the value of ``*len`` on input is ignored. + # Once the length has been read from ``file``, ``*len`` is set + # to that value and a vector of this length is allocated at ``*vec``. + # Finally, ``*len`` coefficients are read from the input stream. In + # case of a file or parsing error, clears the vector and sets ``*vec`` + # and ``*len`` to ``NULL`` and ``0``, respectively. + # Otherwise, if ``*vec != NULL``, it is assumed that ``(*vec, *len)`` + # is a properly initialised vector. If the length on the input stream + # does not match ``*len``, a parsing error is raised. Attempts to read + # the right number of coefficients from the input stream. In case of a + # file or parsing error, leaves the vector ``(*vec, *len)`` in its + # current state. + # In case of success, returns a positive value. In case of failure, + # returns a non-positive value. + + int _fmpz_vec_read(fmpz ** vec, slong * len) + # Reads a vector from ``stdin`` and stores it at ``*vec``. + # For further details, see ``_fmpz_vec_fread()``. + + int _fmpz_vec_fprint(FILE * file, const fmpz * vec, slong len) + # Prints the vector of given length to the stream ``file``. The + # format is the length followed by two spaces, then a space separated + # list of coefficients. If the length is zero, only `0` is printed. + # In case of success, returns a positive value. In case of failure, + # returns a non-positive value. + + int _fmpz_vec_print(const fmpz * vec, slong len) + # Prints the vector of given length to ``stdout``. + # For further details, see ``_fmpz_vec_fprint()``. + + void _fmpz_vec_get_nmod_vec(mp_ptr res, const fmpz * poly, slong len, nmod_t mod) + # Reduce the coefficients of ``(poly, len)`` modulo the given + # modulus and set ``(res, len)`` to the result. + + void _fmpz_vec_set_nmod_vec(fmpz * res, mp_srcptr poly, slong len, nmod_t mod) + # Set the coefficients of ``(res, len)`` to the symmetric modulus + # of the coefficients of ``(poly, len)``, i.e. convert the given + # coefficients modulo the given modulus `n` to their signed integer + # representatives in the range `[-n/2, n/2)`. + + void _fmpz_vec_get_fft(mp_limb_t ** coeffs_f, const fmpz * coeffs_m, slong l, slong length) + # Convert the vector of coeffs ``coeffs_m`` to an fft vector + # ``coeffs_f`` of the given ``length`` with ``l`` limbs per + # coefficient with an additional limb for overflow. + + void _fmpz_vec_set_fft(fmpz * coeffs_m, slong length, const mp_ptr * coeffs_f, slong limbs, slong sign) + # Convert an fft vector ``coeffs_f`` of fully reduced Fermat numbers of the + # given ``length`` to a vector of ``fmpz``'s. Each is assumed to be the given + # number of limbs in length with an additional limb for overflow. If the + # output coefficients are to be signed then set ``sign``, otherwise clear it. + # The resulting ``fmpz``s will be in the range `[-n,n]` in the signed case + # and in the range `[0,2n]` in the unsigned case where + # ``n = 2^(FLINT_BITS*limbs - 1)``. + + slong _fmpz_vec_get_d_vec_2exp(double * appv, const fmpz * vec, slong len) + # Export the array of ``len`` entries starting at the pointer ``vec`` + # to an array of doubles ``appv``, each entry of which is notionally + # multiplied by a single returned exponent to give the original entry. The + # returned exponent is set to be the maximum exponent of all the original + # entries so that all the doubles in ``appv`` have a maximum absolute + # value of 1.0. + + void _fmpz_vec_set(fmpz * vec1, const fmpz * vec2, slong len2) + # Makes a copy of ``(vec2, len2)`` into ``vec1``. + + void _fmpz_vec_swap(fmpz * vec1, fmpz * vec2, slong len2) + # Swaps the integers in ``(vec1, len2)`` and ``(vec2, len2)``. + + void _fmpz_vec_zero(fmpz * vec, slong len) + # Zeros the entries of ``(vec, len)``. + + void _fmpz_vec_neg(fmpz * vec1, const fmpz * vec2, slong len2) + # Negates ``(vec2, len2)`` and places it into ``vec1``. + + void _fmpz_vec_scalar_abs(fmpz * vec1, const fmpz * vec2, slong len2) + # Takes the absolute value of entries in ``(vec2, len2)`` and places the + # result into ``vec1``. + + int _fmpz_vec_equal(const fmpz * vec1, const fmpz * vec2, slong len) + # Compares two vectors of the given length and returns `1` if they are + # equal, otherwise returns `0`. + + int _fmpz_vec_is_zero(const fmpz * vec, slong len) + # Returns `1` if ``(vec, len)`` is zero, and `0` otherwise. + + void _fmpz_vec_max(fmpz * vec1, const fmpz * vec2, const fmpz * vec3, slong len) + # Sets ``vec1`` to the pointwise maximum of ``vec2`` and ``vec3``. + + void _fmpz_vec_max_inplace(fmpz * vec1, const fmpz * vec2, slong len) + # Sets ``vec1`` to the pointwise maximum of ``vec1`` and ``vec2``. + + void _fmpz_vec_sort(fmpz * vec, slong len) + # Sorts the coefficients of ``vec`` in ascending order. + + void _fmpz_vec_add(fmpz * res, const fmpz * vec1, const fmpz * vec2, slong len2) + # Sets ``(res, len2)`` to the sum of ``(vec1, len2)`` + # and ``(vec2, len2)``. + + void _fmpz_vec_sub(fmpz * res, const fmpz * vec1, const fmpz * vec2, slong len2) + # Sets ``(res, len2)`` to ``(vec1, len2)`` minus ``(vec2, len2)``. + + void _fmpz_vec_scalar_mul_fmpz(fmpz * vec1, const fmpz * vec2, slong len2, const fmpz_t x) + # Sets ``(vec1, len2)`` to ``(vec2, len2)`` multiplied by `c`, + # where `c` is an ``fmpz_t``. + + void _fmpz_vec_scalar_mul_si(fmpz * vec1, const fmpz * vec2, slong len2, slong c) + # Sets ``(vec1, len2)`` to ``(vec2, len2)`` multiplied by `c`, + # where `c` is a ``slong``. + + void _fmpz_vec_scalar_mul_ui(fmpz * vec1, const fmpz * vec2, slong len2, ulong c) + # Sets ``(vec1, len2)`` to ``(vec2, len2)`` multiplied by `c`, + # where `c` is an ``ulong``. + + void _fmpz_vec_scalar_mul_2exp(fmpz * vec1, const fmpz * vec2, slong len2, ulong exp) + # Sets ``(vec1, len2)`` to ``(vec2, len2)`` multiplied by ``2^exp``. + + void _fmpz_vec_scalar_divexact_fmpz(fmpz * vec1, const fmpz * vec2, slong len2, const fmpz_t x) + # Sets ``(vec1, len2)`` to ``(vec2, len2)`` divided by `x`, where the + # division is assumed to be exact for every entry in ``vec2``. + + void _fmpz_vec_scalar_divexact_si(fmpz * vec1, const fmpz * vec2, slong len2, slong c) + # Sets ``(vec1, len2)`` to ``(vec2, len2)`` divided by `x`, where the + # division is assumed to be exact for every entry in ``vec2``. + + void _fmpz_vec_scalar_divexact_ui(fmpz * vec1, const fmpz * vec2, slong len2, ulong c) + # Sets ``(vec1, len2)`` to ``(vec2, len2)`` divided by `x`, where the + # division is assumed to be exact for every entry in ``vec2``. + + void _fmpz_vec_scalar_fdiv_q_fmpz(fmpz * vec1, const fmpz * vec2, slong len2, const fmpz_t c) + # Sets ``(vec1, len2)`` to ``(vec2, len2)`` divided by `c`, rounding + # down towards minus infinity whenever the division is not exact. + + void _fmpz_vec_scalar_fdiv_q_si(fmpz * vec1, const fmpz * vec2, slong len2, slong c) + # Sets ``(vec1, len2)`` to ``(vec2, len2)`` divided by `c`, rounding + # down towards minus infinity whenever the division is not exact. + + void _fmpz_vec_scalar_fdiv_q_ui(fmpz * vec1, const fmpz * vec2, slong len2, ulong c) + # Sets ``(vec1, len2)`` to ``(vec2, len2)`` divided by `c`, rounding + # down towards minus infinity whenever the division is not exact. + + void _fmpz_vec_scalar_fdiv_q_2exp(fmpz * vec1, const fmpz * vec2, slong len2, ulong exp) + # Sets ``(vec1, len2)`` to ``(vec2, len2)`` divided by ``2^exp``, + # rounding down towards minus infinity whenever the division is not exact. + + void _fmpz_vec_scalar_fdiv_r_2exp(fmpz * vec1, const fmpz * vec2, slong len2, ulong exp) + # Sets ``(vec1, len2)`` to the remainder of ``(vec2, len2)`` + # divided by ``2^exp``, rounding down the quotient towards minus + # infinity whenever the division is not exact. + + void _fmpz_vec_scalar_tdiv_q_fmpz(fmpz * vec1, const fmpz * vec2, slong len2, const fmpz_t c) + # Sets ``(vec1, len2)`` to ``(vec2, len2)`` divided by `c`, rounding + # towards zero whenever the division is not exact. + + void _fmpz_vec_scalar_tdiv_q_si(fmpz * vec1, const fmpz * vec2, slong len2, slong c) + # Sets ``(vec1, len2)`` to ``(vec2, len2)`` divided by `c`, rounding + # towards zero whenever the division is not exact. + + void _fmpz_vec_scalar_tdiv_q_ui(fmpz * vec1, const fmpz * vec2, slong len2, ulong c) + # Sets ``(vec1, len2)`` to ``(vec2, len2)`` divided by `c`, rounding + # towards zero whenever the division is not exact. + + void _fmpz_vec_scalar_tdiv_q_2exp(fmpz * vec1, const fmpz * vec2, slong len2, ulong exp) + # Sets ``(vec1, len2)`` to ``(vec2, len2)`` divided by ``2^exp``, + # rounding down towards zero whenever the division is not exact. + + void _fmpz_vec_scalar_addmul_si(fmpz * vec1, const fmpz * vec2, slong len2, slong c) + + void _fmpz_vec_scalar_addmul_ui(fmpz * vec1, const fmpz * vec2, slong len2, ulong c) + + void _fmpz_vec_scalar_addmul_fmpz(fmpz * vec1, const fmpz * vec2, slong len2, const fmpz_t c) + # Adds ``(vec2, len2)`` times `c` to ``(vec1, len2)``. + + void _fmpz_vec_scalar_addmul_si_2exp(fmpz * vec1, const fmpz * vec2, slong len2, slong c, ulong exp) + # Adds ``(vec2, len2)`` times ``c * 2^exp`` to ``(vec1, len2)``, + # where `c` is a ``slong``. + + void _fmpz_vec_scalar_submul_fmpz(fmpz * vec1, const fmpz * vec2, slong len2, const fmpz_t x) + # Subtracts ``(vec2, len2)`` times `c` from ``(vec1, len2)``, + # where `c` is a ``fmpz_t``. + + void _fmpz_vec_scalar_submul_si(fmpz * vec1, const fmpz * vec2, slong len2, slong c) + # Subtracts ``(vec2, len2)`` times `c` from ``(vec1, len2)``, + # where `c` is a ``slong``. + + void _fmpz_vec_scalar_submul_si_2exp(fmpz * vec1, const fmpz * vec2, slong len2, slong c, ulong e) + # Subtracts ``(vec2, len2)`` times `c \times 2^e` + # from ``(vec1, len2)``, where `c` is a ``slong``. + + void _fmpz_vec_sum(fmpz_t res, const fmpz * vec, slong len) + # Sets ``res`` to the sum of the entries in ``(vec, len)``. + # Aliasing of ``res`` with the entries in ``vec`` is not permitted. + + void _fmpz_vec_prod(fmpz_t res, const fmpz * vec, slong len) + # Sets ``res`` to the product of the entries in ``(vec, len)``. + # Aliasing of ``res`` with the entries in ``vec`` is not permitted. + # Uses binary splitting. + + void _fmpz_vec_scalar_mod_fmpz(fmpz *res, const fmpz *vec, slong len, const fmpz_t p) + # Reduces all entries in ``(vec, len)`` modulo `p > 0`. + + void _fmpz_vec_scalar_smod_fmpz(fmpz *res, const fmpz *vec, slong len, const fmpz_t p) + # Reduces all entries in ``(vec, len)`` modulo `p > 0`, choosing + # the unique representative in `(-p/2, p/2]`. + + void _fmpz_vec_content(fmpz_t res, const fmpz * vec, slong len) + # Sets ``res`` to the non-negative content of the entries in ``vec``. + # The content of a zero vector, including the case when the length is zero, + # is defined to be zero. + + void _fmpz_vec_content_chained(fmpz_t res, const fmpz * vec, slong len, const fmpz_t input) + # Sets ``res`` to the non-negative content of ``input`` and the entries in ``vec``. + # This is useful for calculating the common content of several vectors. + + void _fmpz_vec_lcm(fmpz_t res, const fmpz * vec, slong len) + # Sets ``res`` to the nonnegative least common multiple of the entries + # in ``vec``. The least common multiple is zero if any entry in + # the vector is zero. The least common multiple of a length zero vector is + # defined to be one. + + void _fmpz_vec_dot(fmpz_t res, const fmpz * vec1, const fmpz * vec2, slong len2) + # Sets ``res`` to the dot product of ``(vec1, len2)`` and + # ``(vec2, len2)``. + + void _fmpz_vec_dot_ptr(fmpz_t res, const fmpz * vec1, fmpz ** const vec2, slong offset, slong len) + # Sets ``res`` to the dot product of ``len`` values at ``vec1`` and the + # ``len`` values ``vec2[i] + offset`` for `0 \leq i < len`. diff --git a/src/sage/libs/flint/fmpzi.pxd b/src/sage/libs/flint/fmpzi.pxd new file mode 100644 index 00000000000..e3b20ad1fe8 --- /dev/null +++ b/src/sage/libs/flint/fmpzi.pxd @@ -0,0 +1,94 @@ +# distutils: libraries = flint +# distutils: depends = flint/fmpzi.h + +################################################################################ +# This file is auto-generated. Do not modify by hand +################################################################################ + +from libc.stdio cimport FILE +from sage.libs.gmp.types cimport * +from sage.libs.mpfr.types cimport * +from sage.libs.flint.types cimport * + +cdef extern from "flint_wrap.h": + + void fmpzi_init(fmpzi_t x) + + void fmpzi_clear(fmpzi_t x) + + void fmpzi_swap(fmpzi_t x, fmpzi_t y) + + void fmpzi_zero(fmpzi_t x) + + void fmpzi_one(fmpzi_t x) + + void fmpzi_set(fmpzi_t res, const fmpzi_t x) + + void fmpzi_set_si_si(fmpzi_t res, slong a, slong b) + + void fmpzi_print(const fmpzi_t x) + + void fmpzi_randtest(fmpzi_t res, flint_rand_t state, mp_bitcnt_t bits) + + int fmpzi_equal(const fmpzi_t x, const fmpzi_t y) + + int fmpzi_is_zero(const fmpzi_t x) + + int fmpzi_is_one(const fmpzi_t x) + + int fmpzi_is_unit(const fmpzi_t x) + + slong fmpzi_canonical_unit_i_pow(const fmpzi_t x) + + void fmpzi_canonicalise_unit(fmpzi_t res, const fmpzi_t x) + + slong fmpzi_bits(const fmpzi_t x) + + void fmpzi_norm(fmpz_t res, const fmpzi_t x) + + void fmpzi_conj(fmpzi_t res, const fmpzi_t x) + + void fmpzi_neg(fmpzi_t res, const fmpzi_t x) + + void fmpzi_add(fmpzi_t res, const fmpzi_t x, const fmpzi_t y) + + void fmpzi_sub(fmpzi_t res, const fmpzi_t x, const fmpzi_t y) + + void fmpzi_sqr(fmpzi_t res, const fmpzi_t x) + + void fmpzi_mul(fmpzi_t res, const fmpzi_t x, const fmpzi_t y) + + void fmpzi_pow_ui(fmpzi_t res, const fmpzi_t x, ulong exp) + + void fmpzi_divexact(fmpzi_t q, const fmpzi_t x, const fmpzi_t y) + # Sets *q* to the quotient of *x* and *y*, assuming that the + # division is exact. + + void fmpzi_divrem(fmpzi_t q, fmpzi_t r, const fmpzi_t x, const fmpzi_t y) + # Computes a quotient and remainder satisfying + # `x = q y + r` with `N(r) \le N(y)/2`, with a canonical + # choice of remainder when breaking ties. + + void fmpzi_divrem_approx(fmpzi_t q, fmpzi_t r, const fmpzi_t x, const fmpzi_t y) + # Computes a quotient and remainder satisfying + # `x = q y + r` with `N(r) < N(y)`, with an implementation-defined, + # non-canonical choice of remainder. + + slong fmpzi_remove_one_plus_i(fmpzi_t res, const fmpzi_t x) + # Divide *x* exactly by the largest possible power `(1+i)^k` + # and return the exponent *k*. + + void fmpzi_gcd_euclidean(fmpzi_t res, const fmpzi_t x, const fmpzi_t y) + void fmpzi_gcd_euclidean_improved(fmpzi_t res, const fmpzi_t x, const fmpzi_t y) + void fmpzi_gcd_binary(fmpzi_t res, const fmpzi_t x, const fmpzi_t y) + void fmpzi_gcd_shortest(fmpzi_t res, const fmpzi_t x, const fmpzi_t y) + void fmpzi_gcd(fmpzi_t res, const fmpzi_t x, const fmpzi_t y) + # Computes the GCD of *x* and *y*. The result is in canonical + # unit form. + # The *euclidean* version is a straightforward implementation + # of Euclid's algorithm. The *euclidean_improved* version is + # optimized by performing approximate divisions. + # The *binary* version uses a (1+i)-ary analog of the binary + # GCD algorithm for integers [Wei2000]_. + # The *shortest* version finds the GCD as the shortest vector in a lattice. + # The default version chooses an algorithm automatically. diff --git a/src/sage/libs/flint/fq.pxd b/src/sage/libs/flint/fq.pxd index f03d61258f7..8e2fcc70fb2 100644 --- a/src/sage/libs/flint/fq.pxd +++ b/src/sage/libs/flint/fq.pxd @@ -12,7 +12,7 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void fq_ctx_init(fq_ctx_t ctx, const fmpz_t p, long d, const char *var) + void fq_ctx_init(fq_ctx_t ctx, const fmpz_t p, slong d, const char *var) # Initialises the context for prime `p` and extension degree `d`, # with name ``var`` for the generator. By default, it will try # use a Conway polynomial; if one is not available, a random @@ -21,7 +21,7 @@ cdef extern from "flint_wrap.h": # Assumes that the string ``var`` is a null-terminated string # of length at least one. - int _fq_ctx_init_conway(fq_ctx_t ctx, const fmpz_t p, long d, const char *var) + int _fq_ctx_init_conway(fq_ctx_t ctx, const fmpz_t p, slong d, const char *var) # Attempts to initialise the context for prime `p` and extension # degree `d`, with name ``var`` for the generator using a Conway # polynomial for the modulus. @@ -32,7 +32,7 @@ cdef extern from "flint_wrap.h": # Assumes that the string ``var`` is a null-terminated string # of length at least one. - void fq_ctx_init_conway(fq_ctx_t ctx, const fmpz_t p, long d, const char *var) + void fq_ctx_init_conway(fq_ctx_t ctx, const fmpz_t p, slong d, const char *var) # Initialises the context for prime `p` and extension degree `d`, # with name ``var`` for the generator using a Conway polynomial # for the modulus. @@ -53,7 +53,7 @@ cdef extern from "flint_wrap.h": const fmpz_mod_poly_struct* fq_ctx_modulus(const fq_ctx_t ctx) # Returns a pointer to the modulus in the context. - long fq_ctx_degree(const fq_ctx_t ctx) + slong fq_ctx_degree(const fq_ctx_t ctx) # Returns the degree of the field extension # `[\mathbf{F}_{q} : \mathbf{F}_{p}]`, which # is equal to `\log_{p} q`. @@ -90,15 +90,15 @@ cdef extern from "flint_wrap.h": void fq_clear(fq_t rop, const fq_ctx_t ctx) # Clears the element ``rop``. - void _fq_sparse_reduce(fmpz *R, long lenR, const fq_ctx_t ctx) + void _fq_sparse_reduce(fmpz *R, slong lenR, const fq_ctx_t ctx) # Reduces ``(R, lenR)`` modulo the polynomial `f` given by the # modulus of ``ctx``. - void _fq_dense_reduce(fmpz *R, long lenR, const fq_ctx_t ctx) + void _fq_dense_reduce(fmpz *R, slong lenR, const fq_ctx_t ctx) # Reduces ``(R, lenR)`` modulo the polynomial `f` given by the # modulus of ``ctx`` using Newton division. - void _fq_reduce(fmpz *r, long lenR, const fq_ctx_t ctx) + void _fq_reduce(fmpz *r, slong lenR, const fq_ctx_t ctx) # Reduces ``(R, lenR)`` modulo the polynomial `f` given by the # modulus of ``ctx``. Does either sparse or dense reduction # based on ``ctx->sparse_modulus``. @@ -127,11 +127,11 @@ cdef extern from "flint_wrap.h": # Sets ``rop`` to the product of ``op`` and `x`, # reducing the output in the given context. - void fq_mul_si(fq_t rop, const fq_t op, long x, const fq_ctx_t ctx) + void fq_mul_si(fq_t rop, const fq_t op, slong x, const fq_ctx_t ctx) # Sets ``rop`` to the product of ``op`` and `x`, # reducing the output in the given context. - void fq_mul_ui(fq_t rop, const fq_t op, unsigned long x, const fq_ctx_t ctx) + void fq_mul_ui(fq_t rop, const fq_t op, ulong x, const fq_ctx_t ctx) # Sets ``rop`` to the product of ``op`` and `x`, # reducing the output in the given context. @@ -143,7 +143,7 @@ cdef extern from "flint_wrap.h": # Sets ``rop`` to the quotient of ``op1`` and ``op2``, # reducing the output in the given context. - void _fq_inv(fmpz *rop, const fmpz *op, long len, const fq_ctx_t ctx) + void _fq_inv(fmpz *rop, const fmpz *op, slong len, const fq_ctx_t ctx) # Sets ``(rop, d)`` to the inverse of the non-zero element # ``(op, len)``. @@ -155,7 +155,7 @@ cdef extern from "flint_wrap.h": # of ``ctx``. If ``op`` is not invertible, then ``f`` is # set to a factor of the modulus; otherwise, it is set to one. - void _fq_pow(fmpz *rop, const fmpz *op, long len, const fmpz_t e, const fq_ctx_t ctx) + void _fq_pow(fmpz *rop, const fmpz *op, slong len, const fmpz_t e, const fq_ctx_t ctx) # Sets ``(rop, 2*d-1)`` to ``(op,len)`` raised to the power `e`, # reduced modulo `f(X)`, the modulus of ``ctx``. # Assumes that `e \geq 0` and that ``len`` is positive and at most `d`. @@ -170,7 +170,7 @@ cdef extern from "flint_wrap.h": # Note that for any input ``op``, ``rop`` is set to `1` # whenever `e = 0`. - void fq_pow_ui(fq_t rop, const fq_t op, const unsigned long e, const fq_ctx_t ctx) + void fq_pow_ui(fq_t rop, const fq_t op, const ulong e, const fq_ctx_t ctx) # Sets ``rop`` the ``op`` raised to the power `e`. # Currently assumes that `e \geq 0`. # Note that for any input ``op``, ``rop`` is set to `1` @@ -237,11 +237,11 @@ cdef extern from "flint_wrap.h": void fq_set(fq_t rop, const fq_t op, const fq_ctx_t ctx) # Sets ``rop`` to ``op``. - void fq_set_si(fq_t rop, const long x, const fq_ctx_t ctx) + void fq_set_si(fq_t rop, const slong x, const fq_ctx_t ctx) # Sets ``rop`` to ``x``, considered as an element of # `\mathbf{F}_p`. - void fq_set_ui(fq_t rop, const unsigned long x, const fq_ctx_t ctx) + void fq_set_ui(fq_t rop, const ulong x, const fq_ctx_t ctx) # Sets ``rop`` to ``x``, considered as an element of # `\mathbf{F}_p`. @@ -301,7 +301,7 @@ cdef extern from "flint_wrap.h": # Returns whether ``op`` is an invertible element. If it is not, # then ``f`` is set of a factor of the modulus. - void _fq_trace(fmpz_t rop, const fmpz *op, long len, const fq_ctx_t ctx) + void _fq_trace(fmpz_t rop, const fmpz *op, slong len, const fq_ctx_t ctx) # Sets ``rop`` to the trace of the non-zero element ``(op, len)`` # in `\mathbf{F}_{q}`. @@ -314,7 +314,7 @@ cdef extern from "flint_wrap.h": # `a` is equal to `\sum_{i=0}^{d-1} \Sigma^i (a)`, where `d = # \log_{p} q`. - void _fq_norm(fmpz_t rop, const fmpz *op, long len, const fq_ctx_t ctx) + void _fq_norm(fmpz_t rop, const fmpz *op, slong len, const fq_ctx_t ctx) # Sets ``rop`` to the norm of the non-zero element ``(op, len)`` # in `\mathbf{F}_{q}`. @@ -328,12 +328,12 @@ cdef extern from "flint_wrap.h": # `d = \text{dim}_{\mathbf{F}_p}(\mathbf{F}_q)`. # Algorithm selection is automatic depending on the input. - void _fq_frobenius(fmpz *rop, const fmpz *op, long len, long e, const fq_ctx_t ctx) + void _fq_frobenius(fmpz *rop, const fmpz *op, slong len, slong e, const fq_ctx_t ctx) # Sets ``(rop, 2d-1)`` to the image of ``(op, len)`` under the # Frobenius operator raised to the e-th power, assuming that neither # ``op`` nor ``e`` are zero. - void fq_frobenius(fq_t rop, const fq_t op, long e, const fq_ctx_t ctx) + void fq_frobenius(fq_t rop, const fq_t op, slong e, const fq_ctx_t ctx) # Evaluates the homomorphism `\Sigma^e` at ``op``. # Recall that `\mathbf{F}_q / \mathbf{F}_p` is Galois with Galois group # `\langle \sigma \rangle`, which is also isomorphic to diff --git a/src/sage/libs/flint/fq_default.pxd b/src/sage/libs/flint/fq_default.pxd index 01e7c55b3ee..fd7c389c95a 100644 --- a/src/sage/libs/flint/fq_default.pxd +++ b/src/sage/libs/flint/fq_default.pxd @@ -12,7 +12,7 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void fq_default_ctx_init(fq_default_ctx_t ctx, const fmpz_t p, long d, const char * var) + void fq_default_ctx_init(fq_default_ctx_t ctx, const fmpz_t p, slong d, const char * var) # Initialises the context for prime `p` and extension degree `d`, # with name ``var`` for the generator. By default, it will try # use a Conway polynomial; if one is not available, a random @@ -21,7 +21,7 @@ cdef extern from "flint_wrap.h": # Assumes that the string ``var`` is a null-terminated string # of length at least one. - void fq_default_ctx_init_type(fq_default_ctx_t ctx, const fmpz_t p, long d, const char * var, int type) + void fq_default_ctx_init_type(fq_default_ctx_t ctx, const fmpz_t p, slong d, const char * var, int type) # As per the previous function except that if ``type == 1`` an ``fq_zech`` # context is created, if ``type == 2`` an ``fq_nmod`` and if ``type == 3`` # an ``fq``. If ``type == 0`` the functionality is as per the previous @@ -62,7 +62,7 @@ cdef extern from "flint_wrap.h": # Returns `1` if the context contains an ``fq_zech`` context, `2` if it # contains an ``fq_mod`` context and `3` if it contains an ``fq`` context. - long fq_default_ctx_degree(const fq_default_ctx_t ctx) + slong fq_default_ctx_degree(const fq_default_ctx_t ctx) # Returns the degree of the field extension # `[\mathbf{F}_{q} : \mathbf{F}_{p}]`, which # is equal to `\log_{p} q`. @@ -87,7 +87,7 @@ cdef extern from "flint_wrap.h": # Initializes ``ctx`` to a random finite field. Assumes that # ``fq_default_ctx_init`` has not been called on ``ctx`` already. - void fq_default_get_coeff_fmpz(fmpz_t c, fq_default_t op, long n, const fq_default_ctx_t ctx) + void fq_default_get_coeff_fmpz(fmpz_t c, fq_default_t op, slong n, const fq_default_ctx_t ctx) # Set `c` to the degree `n` coefficient of the polynomial representation of # the finite field element ``op``. @@ -124,11 +124,11 @@ cdef extern from "flint_wrap.h": # Sets ``rop`` to the product of ``op`` and `x`, # reducing the output in the given context. - void fq_default_mul_si(fq_default_t rop, const fq_default_t op, long x, const fq_default_ctx_t ctx) + void fq_default_mul_si(fq_default_t rop, const fq_default_t op, slong x, const fq_default_ctx_t ctx) # Sets ``rop`` to the product of ``op`` and `x`, # reducing the output in the given context. - void fq_default_mul_ui(fq_default_t rop, const fq_default_t op, unsigned long x, const fq_default_ctx_t ctx) + void fq_default_mul_ui(fq_default_t rop, const fq_default_t op, ulong x, const fq_default_ctx_t ctx) # Sets ``rop`` to the product of ``op`` and `x`, # reducing the output in the given context. @@ -149,7 +149,7 @@ cdef extern from "flint_wrap.h": # Note that for any input ``op``, ``rop`` is set to `1` # whenever `e = 0`. - void fq_default_pow_ui(fq_default_t rop, const fq_default_t op, const unsigned long e, const fq_default_ctx_t ctx) + void fq_default_pow_ui(fq_default_t rop, const fq_default_t op, const ulong e, const fq_default_ctx_t ctx) # Sets ``rop`` the ``op`` raised to the power `e`. # Currently assumes that `e \geq 0`. # Note that for any input ``op``, ``rop`` is set to `1` @@ -208,11 +208,11 @@ cdef extern from "flint_wrap.h": void fq_default_set(fq_default_t rop, const fq_default_t op, const fq_default_ctx_t ctx) # Sets ``rop`` to ``op``. - void fq_default_set_si(fq_default_t rop, const long x, const fq_default_ctx_t ctx) + void fq_default_set_si(fq_default_t rop, const slong x, const fq_default_ctx_t ctx) # Sets ``rop`` to ``x``, considered as an element of # `\mathbf{F}_p`. - void fq_default_set_ui(fq_default_t rop, const unsigned long x, const fq_default_ctx_t ctx) + void fq_default_set_ui(fq_default_t rop, const ulong x, const fq_default_ctx_t ctx) # Sets ``rop`` to ``x``, considered as an element of # `\mathbf{F}_p`. @@ -296,7 +296,7 @@ cdef extern from "flint_wrap.h": # `d = \text{dim}_{\mathbf{F}_p}(\mathbf{F}_q)`. # Algorithm selection is automatic depending on the input. - void fq_default_frobenius(fq_default_t rop, const fq_default_t op, long e, const fq_default_ctx_t ctx) + void fq_default_frobenius(fq_default_t rop, const fq_default_t op, slong e, const fq_default_ctx_t ctx) # Evaluates the homomorphism `\Sigma^e` at ``op``. # Recall that `\mathbf{F}_q / \mathbf{F}_p` is Galois with Galois group # `\langle \sigma \rangle`, which is also isomorphic to diff --git a/src/sage/libs/flint/fq_default_mat.pxd b/src/sage/libs/flint/fq_default_mat.pxd index a525d5c22b9..e3b897a05e3 100644 --- a/src/sage/libs/flint/fq_default_mat.pxd +++ b/src/sage/libs/flint/fq_default_mat.pxd @@ -12,7 +12,7 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void fq_default_mat_init(fq_default_mat_t mat, long rows, long cols, const fq_default_ctx_t ctx) + void fq_default_mat_init(fq_default_mat_t mat, slong rows, slong cols, const fq_default_ctx_t ctx) # Initialises ``mat`` to a ``rows``-by-``cols`` matrix with # coefficients in `\mathbf{F}_{q}` given by ``ctx``. All elements # are set to zero. @@ -30,21 +30,21 @@ cdef extern from "flint_wrap.h": # Sets ``mat`` to a copy of ``src``. It is assumed # that ``mat`` and ``src`` have identical dimensions. - void fq_default_mat_entry(fq_default_t val, const fq_default_mat_t mat, long i, long j, const fq_default_ctx_t ctx) + void fq_default_mat_entry(fq_default_t val, const fq_default_mat_t mat, slong i, slong j, const fq_default_ctx_t ctx) # Directly accesses the entry in ``mat`` in row `i` and column `j`, # indexed from zero by setting ``val`` to the value of that entry. No bounds # checking is performed. - void fq_default_mat_entry_set(fq_default_mat_t mat, long i, long j, const fq_default_t x, const fq_default_ctx_t ctx) + void fq_default_mat_entry_set(fq_default_mat_t mat, slong i, slong j, const fq_default_t x, const fq_default_ctx_t ctx) # Sets the entry in ``mat`` in row `i` and column `j` to ``x``. - void fq_default_mat_entry_set_fmpz(fq_default_mat_t mat, long i, long j, const fmpz_t x, const fq_default_ctx_t ctx) + void fq_default_mat_entry_set_fmpz(fq_default_mat_t mat, slong i, slong j, const fmpz_t x, const fq_default_ctx_t ctx) # Sets the entry in ``mat`` in row `i` and column `j` to ``x``. - long fq_default_mat_nrows(const fq_default_mat_t mat, const fq_default_ctx_t ctx) + slong fq_default_mat_nrows(const fq_default_mat_t mat, const fq_default_ctx_t ctx) # Returns the number of rows in ``mat``. - long fq_default_mat_ncols(const fq_default_mat_t mat, const fq_default_ctx_t ctx) + slong fq_default_mat_ncols(const fq_default_mat_t mat, const fq_default_ctx_t ctx) # Returns the number of columns in ``mat``. void fq_default_mat_swap(fq_default_mat_t mat1, fq_default_mat_t mat2, const fq_default_ctx_t ctx) @@ -57,20 +57,20 @@ cdef extern from "flint_wrap.h": void fq_default_mat_one(fq_default_mat_t mat, const fq_default_ctx_t ctx) # Sets the diagonal entries of ``mat`` to 1 and all other entries to 0. - void fq_default_mat_swap_rows(fq_default_mat_t mat, long * perm, long r, long s, const fq_default_ctx_t ctx) + void fq_default_mat_swap_rows(fq_default_mat_t mat, slong * perm, slong r, slong s, const fq_default_ctx_t ctx) # Swaps rows ``r`` and ``s`` of ``mat``. If ``perm`` is non-``NULL``, the # permutation of the rows will also be applied to ``perm``. - void fq_default_mat_swap_cols(fq_default_mat_t mat, long * perm, long r, long s, const fq_default_ctx_t ctx) + void fq_default_mat_swap_cols(fq_default_mat_t mat, slong * perm, slong r, slong s, const fq_default_ctx_t ctx) # Swaps columns ``r`` and ``s`` of ``mat``. If ``perm`` is non-``NULL``, the # permutation of the columns will also be applied to ``perm``. - void fq_default_mat_invert_rows(fq_default_mat_t mat, long * perm, const fq_default_ctx_t ctx) + void fq_default_mat_invert_rows(fq_default_mat_t mat, slong * perm, const fq_default_ctx_t ctx) # Swaps rows ``i`` and ``r - i`` of ``mat`` for ``0 <= i < r/2``, where # ``r`` is the number of rows of ``mat``. If ``perm`` is non-``NULL``, the # permutation of the rows will also be applied to ``perm``. - void fq_default_mat_invert_cols(fq_default_mat_t mat, long * perm, const fq_default_ctx_t ctx) + void fq_default_mat_invert_cols(fq_default_mat_t mat, slong * perm, const fq_default_ctx_t ctx) # Swaps columns ``i`` and ``c - i`` of ``mat`` for ``0 <= i < c/2``, where # ``c`` is the number of columns of ``mat``. If ``perm`` is non-``NULL``, the # permutation of the columns will also be applied to ``perm``. @@ -111,7 +111,7 @@ cdef extern from "flint_wrap.h": # In case of success, returns a positive value. In case of failure, # returns a non-positive value. - void fq_default_mat_window_init(fq_default_mat_t window, const fq_default_mat_t mat, long r1, long c1, long r2, long c2, const fq_default_ctx_t ctx) + void fq_default_mat_window_init(fq_default_mat_t window, const fq_default_mat_t mat, slong r1, slong c1, slong r2, slong c2, const fq_default_ctx_t ctx) # Initializes the matrix ``window`` to be an ``r2 - r1`` by # ``c2 - c1`` submatrix of ``mat`` whose ``(0,0)`` entry # is the ``(r1, c1)`` entry of ``mat``. The memory for the @@ -126,7 +126,7 @@ cdef extern from "flint_wrap.h": # Sets the elements of ``mat`` to random elements of # `\mathbf{F}_{q}`, given by ``ctx``. - int fq_default_mat_randpermdiag(fq_mat_t mat, flint_rand_t state, fq_struct * diag, long n, const fq_ctx_t ctx) + int fq_default_mat_randpermdiag(fq_mat_t mat, flint_rand_t state, fq_struct * diag, slong n, const fq_ctx_t ctx) # Sets ``mat`` to a random permutation of the diagonal matrix # with `n` leading entries given by the vector ``diag``. It is # assumed that the main diagonal of ``mat`` has room for at @@ -134,7 +134,7 @@ cdef extern from "flint_wrap.h": # Returns `0` or `1`, depending on whether the permutation is even # or odd respectively. - void fq_default_mat_randrank(fq_default_mat_t mat, flint_rand_t state, long rank, const fq_default_ctx_t ctx) + void fq_default_mat_randrank(fq_default_mat_t mat, flint_rand_t state, slong rank, const fq_default_ctx_t ctx) # Sets ``mat`` to a random sparse matrix with the given rank, # having exactly as many non-zero elements as the rank, with the # non-zero elements being uniformly random elements of @@ -142,7 +142,7 @@ cdef extern from "flint_wrap.h": # The matrix can be transformed into a dense matrix with unchanged # rank by subsequently calling :func:`fq_default_mat_randops`. - void fq_default_mat_randops(fq_default_mat_t mat, long count, flint_rand_t state, const fq_default_ctx_t ctx) + void fq_default_mat_randops(fq_default_mat_t mat, slong count, flint_rand_t state, const fq_default_ctx_t ctx) # Randomises ``mat`` by performing elementary row or column # operations. More precisely, at most ``count`` random additions # or subtractions of distinct rows and columns will be performed. @@ -204,7 +204,7 @@ cdef extern from "flint_wrap.h": # returns `0` and sets the elements of `B` to undefined values. # `A` and `B` must be square matrices with the same dimensions. - long fq_default_mat_lu(long * P, fq_default_mat_t A, int rank_check, const fq_default_ctx_t ctx) + slong fq_default_mat_lu(slong * P, fq_default_mat_t A, int rank_check, const fq_default_ctx_t ctx) # Computes a generalised LU decomposition `LU = PA` of a given # matrix `A`, returning the rank of `A`. # If `A` is a nonsingular square matrix, it will be overwritten with @@ -221,7 +221,7 @@ cdef extern from "flint_wrap.h": # if `A` is detected to be rank-deficient. # This function calls ``fq_default_mat_lu_recursive``. - long fq_default_mat_rref(fq_default_mat_t A, const fq_default_ctx_t ctx) + slong fq_default_mat_rref(fq_default_mat_t A, const fq_default_ctx_t ctx) # Puts `A` in reduced row echelon form and returns the rank of `A`. # The rref is computed by first obtaining an unreduced row echelon # form via LU decomposition and then solving an additional @@ -256,7 +256,7 @@ cdef extern from "flint_wrap.h": # valid solutions is given. # There are no restrictions on the shape of `A` and it may be singular. - void fq_default_mat_similarity(fq_default_mat_t M, long r, fq_default_t d, const fq_default_ctx_t ctx) + void fq_default_mat_similarity(fq_default_mat_t M, slong r, fq_default_t d, const fq_default_ctx_t ctx) # Applies a similarity transform to the `n\times n` matrix `M` in-place. # If `P` is the `n\times n` identity matrix the zero entries of whose row # `r` (`0`-indexed) have been replaced by `d`, this transform is equivalent diff --git a/src/sage/libs/flint/fq_default_poly.pxd b/src/sage/libs/flint/fq_default_poly.pxd index a5950a6df14..989b6f19bbb 100644 --- a/src/sage/libs/flint/fq_default_poly.pxd +++ b/src/sage/libs/flint/fq_default_poly.pxd @@ -18,21 +18,21 @@ cdef extern from "flint_wrap.h": # must be made after finishing with the ``fq_default_poly_t`` to free the # memory used by the polynomial. - void fq_default_poly_init2(fq_default_poly_t poly, long alloc, const fq_default_ctx_t ctx) + void fq_default_poly_init2(fq_default_poly_t poly, slong alloc, const fq_default_ctx_t ctx) # Initialises ``poly`` with space for at least ``alloc`` # coefficients and sets the length to zero. The allocated # coefficients are all set to zero. A corresponding call to # :func:`fq_default_poly_clear` must be made after finishing with the # ``fq_default_poly_t`` to free the memory used by the polynomial. - void fq_default_poly_realloc(fq_default_poly_t poly, long alloc, const fq_default_ctx_t ctx) + void fq_default_poly_realloc(fq_default_poly_t poly, slong alloc, const fq_default_ctx_t ctx) # Reallocates the given polynomial to have space for ``alloc`` # coefficients. If ``alloc`` is zero the polynomial is cleared # and then reinitialised. If the current length is greater than # ``alloc`` the polynomial is first truncated to length # ``alloc``. - void fq_default_poly_fit_length(fq_default_poly_t poly, long len, const fq_default_ctx_t ctx) + void fq_default_poly_fit_length(fq_default_poly_t poly, slong len, const fq_default_ctx_t ctx) # If ``len`` is greater than the number of coefficients currently # allocated, then the polynomial is reallocated to have space for at # least ``len`` coefficients. No data is lost when calling this @@ -46,41 +46,41 @@ cdef extern from "flint_wrap.h": # Clears the given polynomial, releasing any memory used. It must # be reinitialised in order to be used again. - void _fq_default_poly_set_length(fq_default_poly_t poly, long len, const fq_default_ctx_t ctx) + void _fq_default_poly_set_length(fq_default_poly_t poly, slong len, const fq_default_ctx_t ctx) # Set the length of ``poly`` to ``len``. - void fq_default_poly_truncate(fq_default_poly_t poly, long newlen, const fq_default_ctx_t ctx) + void fq_default_poly_truncate(fq_default_poly_t poly, slong newlen, const fq_default_ctx_t ctx) # Truncates the polynomial to length at most `n`. - void fq_default_poly_set_trunc(fq_default_poly_t poly1, fq_default_poly_t poly2, long newlen, const fq_default_ctx_t ctx) + void fq_default_poly_set_trunc(fq_default_poly_t poly1, fq_default_poly_t poly2, slong newlen, const fq_default_ctx_t ctx) # Sets ``poly1`` to ``poly2`` truncated to length `n`. - void fq_default_poly_reverse(fq_default_poly_t output, const fq_default_poly_t input, long m, const fq_default_ctx_t ctx) + void fq_default_poly_reverse(fq_default_poly_t output, const fq_default_poly_t input, slong m, const fq_default_ctx_t ctx) # Sets ``output`` to the reverse of ``input``, thinking of it # as a polynomial of length ``m``, notionally zero-padded if # necessary). The length ``m`` must be non-negative, but there # are no other restrictions. The output polynomial will be set to # length ``m`` and then normalised. - long fq_default_poly_degree(const fq_default_poly_t poly, const fq_default_ctx_t ctx) + slong fq_default_poly_degree(const fq_default_poly_t poly, const fq_default_ctx_t ctx) # Returns the degree of the polynomial ``poly``. - long fq_default_poly_length(const fq_default_poly_t poly, const fq_default_ctx_t ctx) + slong fq_default_poly_length(const fq_default_poly_t poly, const fq_default_ctx_t ctx) # Returns the length of the polynomial ``poly``. - void fq_default_poly_randtest(fq_default_poly_t f, flint_rand_t state, long len, const fq_default_ctx_t ctx) + void fq_default_poly_randtest(fq_default_poly_t f, flint_rand_t state, slong len, const fq_default_ctx_t ctx) # Sets `f` to a random polynomial of length at most ``len`` # with entries in the field described by ``ctx``. - void fq_default_poly_randtest_not_zero(fq_default_poly_t f, flint_rand_t state, long len, const fq_default_ctx_t ctx) + void fq_default_poly_randtest_not_zero(fq_default_poly_t f, flint_rand_t state, slong len, const fq_default_ctx_t ctx) # Same as ``fq_default_poly_randtest`` but guarantees that the polynomial # is not zero. - void fq_default_poly_randtest_monic(fq_default_poly_t f, flint_rand_t state, long len, const fq_default_ctx_t ctx) + void fq_default_poly_randtest_monic(fq_default_poly_t f, flint_rand_t state, slong len, const fq_default_ctx_t ctx) # Sets `f` to a random monic polynomial of length ``len`` with # entries in the field described by ``ctx``. - void fq_default_poly_randtest_irreducible(fq_default_poly_t f, flint_rand_t state, long len, const fq_default_ctx_t ctx) + void fq_default_poly_randtest_irreducible(fq_default_poly_t f, flint_rand_t state, slong len, const fq_default_ctx_t ctx) # Sets `f` to a random monic, irreducible polynomial of length # ``len`` with entries in the field described by ``ctx``. @@ -114,13 +114,13 @@ cdef extern from "flint_wrap.h": void fq_default_poly_set_fmpz_poly(fq_default_poly_t rop, const fmpz_poly_t op, const fq_default_ctx_t ctx) # Sets the polynomial ``rop`` to the polynomial ``op``. - void fq_default_poly_get_coeff(fq_default_t x, const fq_default_poly_t poly, long n, const fq_default_ctx_t ctx) + void fq_default_poly_get_coeff(fq_default_t x, const fq_default_poly_t poly, slong n, const fq_default_ctx_t ctx) # Sets `x` to the coefficient of `X^n` in ``poly``. - void fq_default_poly_set_coeff(fq_default_poly_t poly, long n, const fq_default_t x, const fq_default_ctx_t ctx) + void fq_default_poly_set_coeff(fq_default_poly_t poly, slong n, const fq_default_t x, const fq_default_ctx_t ctx) # Sets the coefficient of `X^n` in ``poly`` to `x`. - void fq_default_poly_set_coeff_fmpz(fq_default_poly_t poly, long n, const fmpz_t x, const fq_default_ctx_t ctx) + void fq_default_poly_set_coeff_fmpz(fq_default_poly_t poly, slong n, const fmpz_t x, const fq_default_ctx_t ctx) # Sets the coefficient of `X^n` in the polynomial to `x`, # assuming `n \geq 0`. @@ -128,7 +128,7 @@ cdef extern from "flint_wrap.h": # Returns nonzero if the two polynomials ``poly1`` and ``poly2`` # are equal, otherwise returns zero. - int fq_default_poly_equal_trunc(const fq_default_poly_t poly1, const fq_default_poly_t poly2, long n, const fq_default_ctx_t ctx) + int fq_default_poly_equal_trunc(const fq_default_poly_t poly1, const fq_default_poly_t poly2, slong n, const fq_default_ctx_t ctx) # Notionally truncate ``poly1`` and ``poly2`` to length `n` and # return nonzero if they are equal, otherwise return zero. @@ -154,17 +154,17 @@ cdef extern from "flint_wrap.h": void fq_default_poly_add(fq_default_poly_t res, const fq_default_poly_t poly1, const fq_default_poly_t poly2, const fq_default_ctx_t ctx) # Sets ``res`` to the sum of ``poly1`` and ``poly2``. - void fq_default_poly_add_si(fq_default_poly_t res, const fq_default_poly_t poly1, long c, const fq_default_ctx_t ctx) + void fq_default_poly_add_si(fq_default_poly_t res, const fq_default_poly_t poly1, slong c, const fq_default_ctx_t ctx) # Sets ``res`` to the sum of ``poly1`` and ``c``. - void fq_default_poly_add_series(fq_default_poly_t res, const fq_default_poly_t poly1, const fq_default_poly_t poly2, long n, const fq_default_ctx_t ctx) + void fq_default_poly_add_series(fq_default_poly_t res, const fq_default_poly_t poly1, const fq_default_poly_t poly2, slong n, const fq_default_ctx_t ctx) # Notionally truncate ``poly1`` and ``poly2`` to length ``n`` and set # ``res`` to the sum. void fq_default_poly_sub(fq_default_poly_t res, const fq_default_poly_t poly1, const fq_default_poly_t poly2, const fq_default_ctx_t ctx) # Sets ``res`` to the difference of ``poly1`` and ``poly2``. - void fq_default_poly_sub_series(fq_default_poly_t res, const fq_default_poly_t poly1, const fq_default_poly_t poly2, long n, const fq_default_ctx_t ctx) + void fq_default_poly_sub_series(fq_default_poly_t res, const fq_default_poly_t poly1, const fq_default_poly_t poly2, slong n, const fq_default_ctx_t ctx) # Notionally truncate ``poly1`` and ``poly2`` to length ``n`` and set # ``res`` to the difference. @@ -191,11 +191,11 @@ cdef extern from "flint_wrap.h": # Sets ``rop`` to the product of ``op1`` and ``op2``, # choosing an appropriate algorithm. - void fq_default_poly_mullow(fq_default_poly_t rop, const fq_default_poly_t op1, const fq_default_poly_t op2, long n, const fq_default_ctx_t ctx) + void fq_default_poly_mullow(fq_default_poly_t rop, const fq_default_poly_t op1, const fq_default_poly_t op2, slong n, const fq_default_ctx_t ctx) # Sets ``rop`` to the lowest `n` coefficients of the product of # ``op1`` and ``op2``. - void fq_default_poly_mulhigh(fq_default_poly_t res, const fq_default_poly_t poly1, const fq_default_poly_t poly2, long start, const fq_default_ctx_t ctx) + void fq_default_poly_mulhigh(fq_default_poly_t res, const fq_default_poly_t poly1, const fq_default_poly_t poly2, slong start, const fq_default_ctx_t ctx) # Computes the product of ``poly1`` and ``poly2`` and writes the # coefficients from ``start`` onwards into the high coefficients of # ``res``, the remaining coefficients being arbitrary but reduced. @@ -208,11 +208,11 @@ cdef extern from "flint_wrap.h": # Sets ``rop`` to the square of ``op``, # choosing an appropriate algorithm. - void fq_default_poly_pow(fq_default_poly_t rop, const fq_default_poly_t op, unsigned long e, const fq_default_ctx_t ctx) + void fq_default_poly_pow(fq_default_poly_t rop, const fq_default_poly_t op, ulong e, const fq_default_ctx_t ctx) # Computes ``rop = op^e``. If `e` is zero, returns one, # so that in particular ``0^0 = 1``. - void fq_default_poly_powmod_ui_binexp(fq_default_poly_t res, const fq_default_poly_t poly, unsigned long e, const fq_default_poly_t f, const fq_default_ctx_t ctx) + void fq_default_poly_powmod_ui_binexp(fq_default_poly_t res, const fq_default_poly_t poly, ulong e, const fq_default_poly_t f, const fq_default_ctx_t ctx) # Sets ``res`` to ``poly`` raised to the power ``e`` modulo # ``f``, using binary exponentiation. We require ``e >= 0``. @@ -220,21 +220,21 @@ cdef extern from "flint_wrap.h": # Sets ``res`` to ``poly`` raised to the power ``e`` modulo # ``f``, using binary exponentiation. We require ``e >= 0``. - void fq_default_poly_pow_trunc(fq_default_poly_t res, const fq_default_poly_t poly, unsigned long e, long trunc, const fq_default_ctx_t ctx) + void fq_default_poly_pow_trunc(fq_default_poly_t res, const fq_default_poly_t poly, ulong e, slong trunc, const fq_default_ctx_t ctx) # Sets ``res`` to the low ``trunc`` coefficients of ``poly`` # to the power ``e``. This is equivalent to doing a powering # followed by a truncation. - void fq_default_poly_shift_left(fq_default_poly_t rop, const fq_default_poly_t op, long n, const fq_default_ctx_t ctx) + void fq_default_poly_shift_left(fq_default_poly_t rop, const fq_default_poly_t op, slong n, const fq_default_ctx_t ctx) # Sets ``rop`` to ``op`` shifted left by `n` coeffs. Zero # coefficients are inserted. - void fq_default_poly_shift_right(fq_default_poly_t rop, const fq_default_poly_t op, long n, const fq_default_ctx_t ctx) + void fq_default_poly_shift_right(fq_default_poly_t rop, const fq_default_poly_t op, slong n, const fq_default_ctx_t ctx) # Sets ``rop`` to ``op`` shifted right by `n` coefficients. # If `n` is equal to or greater than the current length of # ``op``, ``rop`` is set to the zero polynomial. - long fq_default_poly_hamming_weight(const fq_default_poly_t op, const fq_default_ctx_t ctx) + slong fq_default_poly_hamming_weight(const fq_default_poly_t op, const fq_default_ctx_t ctx) # Returns the number of non-zero entries in the polynomial ``op``. void fq_default_poly_divrem(fq_default_poly_t Q, fq_default_poly_t R, const fq_default_poly_t A, const fq_default_poly_t B, const fq_default_ctx_t ctx) @@ -248,13 +248,13 @@ cdef extern from "flint_wrap.h": # Sets ``R`` to the remainder of the division of ``A`` by # ``B`` in the context described by ``ctx``. - void fq_default_poly_inv_series(fq_default_poly_t Qinv, const fq_default_poly_t Q, long n, const fq_default_ctx_t ctx) + void fq_default_poly_inv_series(fq_default_poly_t Qinv, const fq_default_poly_t Q, slong n, const fq_default_ctx_t ctx) # Given ``Q`` find ``Qinv`` such that ``Q * Qinv`` is # ``1`` modulo `x^n`. The constant coefficient of ``Q`` must # be invertible modulo the modulus of ``Q``. An exception is # raised if this is not the case or if ``n = 0``. - void fq_default_poly_div_series(fq_default_poly_t Q, const fq_default_poly_t A, const fq_default_poly_t B, long n, const fq_default_ctx_t ctx) + void fq_default_poly_div_series(fq_default_poly_t Q, const fq_default_poly_t A, const fq_default_poly_t B, slong n, const fq_default_ctx_t ctx) # Set `Q` to the quotient of the series `A` by `B`, thinking of the series as # though they were of length `n`. We assume that the bottom coefficient of # `B` is invertible. @@ -285,11 +285,11 @@ cdef extern from "flint_wrap.h": void fq_default_poly_derivative(fq_default_poly_t rop, const fq_default_poly_t op, const fq_default_ctx_t ctx) # Sets ``rop`` to the derivative of ``op``. - void fq_default_poly_invsqrt_series(fq_default_poly_t g, const fq_default_poly_t h, long n, fq_default_ctx_t ctx) + void fq_default_poly_invsqrt_series(fq_default_poly_t g, const fq_default_poly_t h, slong n, fq_default_ctx_t ctx) # Set `g` to the series expansion of `1/\sqrt{h}` to order `O(x^n)`. # It is assumed that `h` has constant term 1. - void fq_default_poly_sqrt_series(fq_default_poly_t g, const fq_default_poly_t h, long n, fq_default_ctx_t ctx) + void fq_default_poly_sqrt_series(fq_default_poly_t g, const fq_default_poly_t h, slong n, fq_default_ctx_t ctx) # Set `g` to the series expansion of `\sqrt{h}` to order `O(x^n)`. # It is assumed that `h` has constant term 1. @@ -343,16 +343,16 @@ cdef extern from "flint_wrap.h": # Returns a pretty representation of the polynomial ``poly`` using the # null-terminated string ``x`` as the variable name - void fq_default_poly_inflate(fq_default_poly_t result, const fq_default_poly_t input, unsigned long inflation, const fq_default_ctx_t ctx) + void fq_default_poly_inflate(fq_default_poly_t result, const fq_default_poly_t input, ulong inflation, const fq_default_ctx_t ctx) # Sets ``result`` to the inflated polynomial `p(x^n)` where # `p` is given by ``input`` and `n` is given by ``inflation``. - void fq_default_poly_deflate(fq_default_poly_t result, const fq_default_poly_t input, unsigned long deflation, const fq_default_ctx_t ctx) + void fq_default_poly_deflate(fq_default_poly_t result, const fq_default_poly_t input, ulong deflation, const fq_default_ctx_t ctx) # Sets ``result`` to the deflated polynomial `p(x^{1/n})` where # `p` is given by ``input`` and `n` is given by ``deflation``. # Requires `n > 0`. - unsigned long fq_default_poly_deflation(const fq_default_poly_t input, const fq_default_ctx_t ctx) + ulong fq_default_poly_deflation(const fq_default_poly_t input, const fq_default_ctx_t ctx) # Returns the largest integer by which ``input`` can be deflated. # As special cases, returns 0 if ``input`` is the zero polynomial # and 1 of ``input`` is a constant polynomial. diff --git a/src/sage/libs/flint/fq_default_poly_factor.pxd b/src/sage/libs/flint/fq_default_poly_factor.pxd index 1d9acc1c491..d397f5cc809 100644 --- a/src/sage/libs/flint/fq_default_poly_factor.pxd +++ b/src/sage/libs/flint/fq_default_poly_factor.pxd @@ -20,11 +20,11 @@ cdef extern from "flint_wrap.h": void fq_default_poly_factor_clear(fq_default_poly_factor_t fac, const fq_default_ctx_t ctx) # Frees all memory associated with ``fac``. - void fq_default_poly_factor_realloc(fq_default_poly_factor_t fac, long alloc, const fq_default_ctx_t ctx) + void fq_default_poly_factor_realloc(fq_default_poly_factor_t fac, slong alloc, const fq_default_ctx_t ctx) # Reallocates the factor structure to provide space for # precisely ``alloc`` factors. - void fq_default_poly_factor_fit_length(fq_default_poly_factor_t fac, long len, const fq_default_ctx_t ctx) + void fq_default_poly_factor_fit_length(fq_default_poly_factor_t fac, slong len, const fq_default_ctx_t ctx) # Ensures that the factor structure has space for at least # ``len`` factors. This function takes care of the case of # repeated calls by always at least doubling the number of factors @@ -39,7 +39,7 @@ cdef extern from "flint_wrap.h": void fq_default_poly_factor_print(const fq_default_poly_factor_t fac, const fq_default_ctx_t ctx) # Prints the entries of ``fac`` to standard output. - void fq_default_poly_factor_insert(fq_default_poly_factor_t fac, const fq_default_poly_t poly, long exp, const fq_default_ctx_t ctx) + void fq_default_poly_factor_insert(fq_default_poly_factor_t fac, const fq_default_poly_t poly, slong exp, const fq_default_ctx_t ctx) # Inserts the factor ``poly`` with multiplicity ``exp`` into # the factorisation ``fac``. # If ``fac`` already contains ``poly``, then ``exp`` simply @@ -51,20 +51,20 @@ cdef extern from "flint_wrap.h": # repeatedly with the individual factors of ``fac``. # Does not support aliasing between ``res`` and ``fac``. - void fq_default_poly_factor_pow(fq_default_poly_factor_t fac, long exp, const fq_default_ctx_t ctx) + void fq_default_poly_factor_pow(fq_default_poly_factor_t fac, slong exp, const fq_default_ctx_t ctx) # Raises ``fac`` to the power ``exp``. - unsigned long fq_default_poly_remove(fq_default_poly_t f, const fq_default_poly_t p, const fq_default_ctx_t ctx) + ulong fq_default_poly_remove(fq_default_poly_t f, const fq_default_poly_t p, const fq_default_ctx_t ctx) # Removes the highest possible power of ``p`` from ``f`` and # returns the exponent. - long fq_default_poly_factor_length(fq_default_poly_factor_t fac, const fq_default_ctx_t ctx) + slong fq_default_poly_factor_length(fq_default_poly_factor_t fac, const fq_default_ctx_t ctx) # Return the number of factors, not including the unit. - void fq_default_poly_factor_get_poly(fq_default_poly_t poly, const fq_default_poly_factor_t fac, long i, const fq_default_ctx_t ctx) + void fq_default_poly_factor_get_poly(fq_default_poly_t poly, const fq_default_poly_factor_t fac, slong i, const fq_default_ctx_t ctx) # Set ``poly`` to factor ``i`` of ``fac`` (numbering starts at zero). - long fq_default_poly_factor_exp(fq_default_poly_factor_t fac, long i, const fq_default_ctx_t ctx) + slong fq_default_poly_factor_exp(fq_default_poly_factor_t fac, slong i, const fq_default_ctx_t ctx) # Return the exponent of factor ``i`` of ``fac``. int fq_default_poly_is_irreducible(const fq_default_poly_t f, const fq_default_ctx_t ctx) @@ -74,7 +74,7 @@ cdef extern from "flint_wrap.h": # Returns 1 if ``f`` is squarefree, and 0 otherwise. As a special # case, the zero polynomial is not considered squarefree. - void fq_default_poly_factor_equal_deg(fq_default_poly_factor_t factors, const fq_default_poly_t pol, long d, const fq_default_ctx_t ctx) + void fq_default_poly_factor_equal_deg(fq_default_poly_factor_t factors, const fq_default_poly_t pol, slong d, const fq_default_ctx_t ctx) # Assuming ``pol`` is a product of irreducible factors all of # degree ``d``, finds all those factors and places them in # factors. Requires that ``pol`` be monic, non-constant and @@ -85,7 +85,7 @@ cdef extern from "flint_wrap.h": # linear factor of ``input`` and places it in ``linfactor``. # Requires that ``input`` be monic and non-constant. - void fq_default_poly_factor_distinct_deg(fq_default_poly_factor_t res, const fq_default_poly_t poly, long * const * degs, const fq_default_ctx_t ctx) + void fq_default_poly_factor_distinct_deg(fq_default_poly_factor_t res, const fq_default_poly_t poly, slong * const * degs, const fq_default_ctx_t ctx) # Factorises a monic non-constant squarefree polynomial ``poly`` # of degree `n` into factors `f[d]` such that for `1 \leq d \leq n` # `f[d]` is the product of the monic irreducible factors of diff --git a/src/sage/libs/flint/fq_embed.pxd b/src/sage/libs/flint/fq_embed.pxd new file mode 100644 index 00000000000..c440b3515fd --- /dev/null +++ b/src/sage/libs/flint/fq_embed.pxd @@ -0,0 +1,97 @@ +# distutils: libraries = flint +# distutils: depends = flint/fq_embed.h + +################################################################################ +# This file is auto-generated. Do not modify by hand +################################################################################ + +from libc.stdio cimport FILE +from sage.libs.gmp.types cimport * +from sage.libs.mpfr.types cimport * +from sage.libs.flint.types cimport * + +cdef extern from "flint_wrap.h": + + void fq_embed_gens(fq_t gen_sub, fq_t gen_sup, fmpz_mod_poly_t minpoly, const fq_ctx_t sub_ctx, const fq_ctx_t sup_ctx) + # Given two contexts ``sub_ctx`` and ``sup_ctx``, such that + # ``degree(sub_ctx)`` divides ``degree(sup_ctx)``, compute: + # * an element ``gen_sub`` in ``sub_ctx`` such that + # ``gen_sub`` generates the finite field defined by + # ``sub_ctx``, + # * its minimal polynomial ``minpoly``, + # * a root ``gen_sup`` of ``minpoly`` inside the field + # defined by ``sup_ctx``. + # These data uniquely define an embedding of ``sub_ctx`` into + # ``sup_ctx``. + + void _fq_embed_gens_naive(fq_t gen_sub, fq_t gen_sup, fmpz_mod_poly_t minpoly, const fq_ctx_t sub_ctx, const fq_ctx_t sup_ctx) + # Given two contexts ``sub_ctx`` and ``sup_ctx``, such that + # ``degree(sub_ctx)`` divides ``degree(sup_ctx)``, compute an + # embedding of ``sub_ctx`` into ``sup_ctx`` defined as follows: + # * ``gen_sub`` is the canonical generator of ``sup_ctx`` + # (i.e., the class of `X`), + # * ``minpoly`` is the defining polynomial of ``sub_ctx``, + # * ``gen_sup`` is a root of ``minpoly`` inside the field + # defined by ``sup_ctx``. + + void fq_embed_matrices(fmpz_mod_mat_t embed, fmpz_mod_mat_t project, const fq_t gen_sub, const fq_ctx_t sub_ctx, const fq_t gen_sup, const fq_ctx_t sup_ctx, const fmpz_mod_poly_t gen_minpoly) + # Given: + # * two contexts ``sub_ctx`` and ``sup_ctx``, of + # respective degrees `m` and `n`, such that `m` divides `n`; + # * a generator ``gen_sub`` of ``sub_ctx``, its minimal + # polynomial ``gen_minpoly``, and a root ``gen_sup`` of + # ``gen_minpoly`` in ``sup_ctx``, as returned by + # :func:`fq_embed_gens`; + # Compute: + # * the `n\times m` matrix ``embed`` mapping ``gen_sub`` + # to ``gen_sup``, and all their powers accordingly; + # * an `m\times n` matrix ``project`` such that + # ``project`` `\times` ``embed`` is the `m\times m` identity + # matrix. + + void fq_embed_trace_matrix(fmpz_mod_mat_t res, const fmpz_mod_mat_t basis, const fq_ctx_t sub_ctx, const fq_ctx_t sup_ctx) + # Given: + # * two contexts ``sub_ctx`` and ``sup_ctx``, of degrees + # `m` and `n`, such that `m` divides `n`; + # * an `n\times m` matrix ``basis`` that maps ``sub_ctx`` + # to an isomorphic subfield in ``sup_ctx``; + # Compute the `m\times n` matrix of the trace from ``sup_ctx`` to + # ``sub_ctx``. + # This matrix is computed as + # ``embed_dual_to_mono_matrix(_, sub_ctx)`` + # `\times` ``basis``:sup:`t` `\times` + # ``embed_mono_to_dual_matrix(_, sup_ctx)``. + # **Note:** if + # `m=n`, ``basis`` represents a Frobenius, and the result is its + # inverse matrix. + + void fq_embed_composition_matrix(fmpz_mod_mat_t matrix, const fq_t gen, const fq_ctx_t ctx) + # Compute the *composition matrix* of ``gen``. + # For an element `a\in\mathbf{F}_{p^n}`, its composition matrix is the + # matrix whose columns are `a^0, a^1, \ldots, a^{n-1}`. + + void fq_embed_composition_matrix_sub(fmpz_mod_mat_t matrix, const fq_t gen, const fq_ctx_t ctx, slong trunc) + # Compute the *composition matrix* of ``gen``, truncated to + # ``trunc`` columns. + + void fq_embed_mul_matrix(fmpz_mod_mat_t matrix, const fq_t gen, const fq_ctx_t ctx) + # Compute the *multiplication matrix* of ``gen``. + # For an element `a` in `\mathbf{F}_{p^n}=\mathbf{F}_p[x]`, its + # multiplication matrix is the matrix whose columns are `a, ax, + # \dots, ax^{n-1}`. + + void fq_embed_mono_to_dual_matrix(fmpz_mod_mat_t res, const fq_ctx_t ctx) + # Compute the change of basis matrix from the monomial basis of + # ``ctx`` to its dual basis. + + void fq_embed_dual_to_mono_matrix(fmpz_mod_mat_t res, const fq_ctx_t ctx) + # Compute the change of basis matrix from the dual basis of + # ``ctx`` to its monomial basis. + + void fq_modulus_pow_series_inv(fmpz_mod_poly_t res, const fq_ctx_t ctx, slong trunc) + # Compute the power series inverse of the reverse of the modulus of + # ``ctx`` up to `O(x^\texttt{trunc})`. + + void fq_modulus_derivative_inv(fq_t m_prime, fq_t m_prime_inv, const fq_ctx_t ctx) + # Compute the derivative ``m_prime`` of the modulus of ``ctx`` + # as an element of ``ctx``, and its inverse ``m_prime_inv``. diff --git a/src/sage/libs/flint/fq_mat.pxd b/src/sage/libs/flint/fq_mat.pxd new file mode 100644 index 00000000000..ee3cd9853f1 --- /dev/null +++ b/src/sage/libs/flint/fq_mat.pxd @@ -0,0 +1,366 @@ +# distutils: libraries = flint +# distutils: depends = flint/fq_mat.h + +################################################################################ +# This file is auto-generated. Do not modify by hand +################################################################################ + +from libc.stdio cimport FILE +from sage.libs.gmp.types cimport * +from sage.libs.mpfr.types cimport * +from sage.libs.flint.types cimport * + +cdef extern from "flint_wrap.h": + + void fq_mat_init(fq_mat_t mat, slong rows, slong cols, const fq_ctx_t ctx) + # Initialises ``mat`` to a ``rows``-by-``cols`` matrix with + # coefficients in `\mathbf{F}_{q}` given by ``ctx``. All elements + # are set to zero. + + void fq_mat_init_set(fq_mat_t mat, const fq_mat_t src, const fq_ctx_t ctx) + # Initialises ``mat`` and sets its dimensions and elements to + # those of ``src``. + + void fq_mat_clear(fq_mat_t mat, const fq_ctx_t ctx) + # Clears the matrix and releases any memory it used. The matrix + # cannot be used again until it is initialised. This function must be + # called exactly once when finished using an ``fq_mat_t`` object. + + void fq_mat_set(fq_mat_t mat, const fq_mat_t src, const fq_ctx_t ctx) + # Sets ``mat`` to a copy of ``src``. It is assumed + # that ``mat`` and ``src`` have identical dimensions. + + fq_struct * fq_mat_entry(const fq_mat_t mat, slong i, slong j) + # Directly accesses the entry in ``mat`` in row `i` and column `j`, + # indexed from zero. No bounds checking is performed. + + void fq_mat_entry_set(fq_mat_t mat, slong i, slong j, const fq_t x, const fq_ctx_t ctx) + # Sets the entry in ``mat`` in row `i` and column `j` to ``x``. + + slong fq_mat_nrows(const fq_mat_t mat, const fq_ctx_t ctx) + # Returns the number of rows in ``mat``. + + slong fq_mat_ncols(const fq_mat_t mat, const fq_ctx_t ctx) + # Returns the number of columns in ``mat``. + + void fq_mat_swap(fq_mat_t mat1, fq_mat_t mat2, const fq_ctx_t ctx) + # Swaps two matrices. The dimensions of ``mat1`` and ``mat2`` + # are allowed to be different. + + void fq_mat_swap_entrywise(fq_mat_t mat1, fq_mat_t mat2, const fq_ctx_t ctx) + # Swaps two matrices by swapping the individual entries rather than swapping + # the contents of the structs. + + void fq_mat_zero(fq_mat_t mat, const fq_ctx_t ctx) + # Sets all entries of ``mat`` to 0. + + void fq_mat_one(fq_mat_t mat, const fq_ctx_t ctx) + # Sets all the diagonal entries of ``mat`` to 1 and all other entries to 0. + + void fq_mat_swap_rows(fq_mat_t mat, slong * perm, slong r, slong s, const fq_ctx_t ctx) + # Swaps rows ``r`` and ``s`` of ``mat``. If ``perm`` is non-``NULL``, the + # permutation of the rows will also be applied to ``perm``. + + void fq_mat_swap_cols(fq_mat_t mat, slong * perm, slong r, slong s, const fq_ctx_t ctx) + # Swaps columns ``r`` and ``s`` of ``mat``. If ``perm`` is non-``NULL``, the + # permutation of the columns will also be applied to ``perm``. + + void fq_mat_invert_rows(fq_mat_t mat, slong * perm, const fq_ctx_t ctx) + # Swaps rows ``i`` and ``r - i`` of ``mat`` for ``0 <= i < r/2``, where + # ``r`` is the number of rows of ``mat``. If ``perm`` is non-``NULL``, the + # permutation of the rows will also be applied to ``perm``. + + void fq_mat_invert_cols(fq_mat_t mat, slong * perm, const fq_ctx_t ctx) + # Swaps columns ``i`` and ``c - i`` of ``mat`` for ``0 <= i < c/2``, where + # ``c`` is the number of columns of ``mat``. If ``perm`` is non-``NULL``, the + # permutation of the columns will also be applied to ``perm``. + + void fq_mat_set_nmod_mat(fq_mat_t mat1, const nmod_mat_t mat2, const fq_ctx_t ctx) + # Sets the matrix ``mat1`` to the matrix ``mat2``. + + void fq_mat_set_fmpz_mod_mat(fq_mat_t mat1, const fmpz_mod_mat_t mat2, const fq_ctx_t ctx) + # Sets the matrix ``mat1`` to the matrix ``mat2``. + + void fq_mat_concat_vertical(fq_mat_t res, const fq_mat_t mat1, const fq_mat_t mat2, const fq_ctx_t ctx) + # Sets ``res`` to vertical concatenation of (``mat1``, ``mat2``) in that order. Matrix dimensions : ``mat1`` : `m \times n`, ``mat2`` : `k \times n`, ``res`` : `(m + k) \times n`. + + void fq_mat_concat_horizontal(fq_mat_t res, const fq_mat_t mat1, const fq_mat_t mat2, const fq_ctx_t ctx) + # Sets ``res`` to horizontal concatenation of (``mat1``, ``mat2``) in that order. Matrix dimensions : ``mat1`` : `m \times n`, ``mat2`` : `m \times k`, ``res`` : `m \times (n + k)`. + + int fq_mat_print_pretty(const fq_mat_t mat, const fq_ctx_t ctx) + # Pretty-prints ``mat`` to ``stdout``. A header is printed + # followed by the rows enclosed in brackets. + + int fq_mat_fprint_pretty(FILE * file, const fq_mat_t mat, const fq_ctx_t ctx) + # Pretty-prints ``mat`` to ``file``. A header is printed + # followed by the rows enclosed in brackets. + # In case of success, returns a positive value. In case of failure, + # returns a non-positive value. + + int fq_mat_print(const fq_mat_t mat, const fq_ctx_t ctx) + # Prints ``mat`` to ``stdout``. A header is printed followed + # by the rows enclosed in brackets. + + int fq_mat_fprint(FILE * file, const fq_mat_t mat, const fq_ctx_t ctx) + # Prints ``mat`` to ``file``. A header is printed followed by + # the rows enclosed in brackets. + # In case of success, returns a positive value. In case of failure, + # returns a non-positive value. + + void fq_mat_window_init(fq_mat_t window, const fq_mat_t mat, slong r1, slong c1, slong r2, slong c2, const fq_ctx_t ctx) + # Initializes the matrix ``window`` to be an ``r2 - r1`` by + # ``c2 - c1`` submatrix of ``mat`` whose ``(0,0)`` entry + # is the ``(r1, c1)`` entry of ``mat``. The memory for the + # elements of ``window`` is shared with ``mat``. + + void fq_mat_window_clear(fq_mat_t window, const fq_ctx_t ctx) + # Clears the matrix ``window`` and releases any memory that it + # uses. Note that the memory to the underlying matrix that + # ``window`` points to is not freed. + + void fq_mat_randtest(fq_mat_t mat, flint_rand_t state, const fq_ctx_t ctx) + # Sets the elements of ``mat`` to random elements of + # `\mathbf{F}_{q}`, given by ``ctx``. + + int fq_mat_randpermdiag(fq_mat_t mat, flint_rand_t state, fq_struct * diag, slong n, const fq_ctx_t ctx) + # Sets ``mat`` to a random permutation of the diagonal matrix + # with `n` leading entries given by the vector ``diag``. It is + # assumed that the main diagonal of ``mat`` has room for at + # least `n` entries. + # Returns `0` or `1`, depending on whether the permutation is even + # or odd respectively. + + void fq_mat_randrank(fq_mat_t mat, flint_rand_t state, slong rank, const fq_ctx_t ctx) + # Sets ``mat`` to a random sparse matrix with the given rank, + # having exactly as many non-zero elements as the rank, with the + # non-zero elements being uniformly random elements of + # `\mathbf{F}_{q}`. + # The matrix can be transformed into a dense matrix with unchanged + # rank by subsequently calling :func:`fq_mat_randops`. + + void fq_mat_randops(fq_mat_t mat, slong count, flint_rand_t state, const fq_ctx_t ctx) + # Randomises ``mat`` by performing elementary row or column + # operations. More precisely, at most ``count`` random additions + # or subtractions of distinct rows and columns will be performed. + # This leaves the rank (and for square matrices, determinant) + # unchanged. + + void fq_mat_randtril(fq_mat_t mat, flint_rand_t state, int unit, const fq_ctx_t ctx) + # Sets ``mat`` to a random lower triangular matrix. If + # ``unit`` is 1, it will have ones on the main diagonal, + # otherwise it will have random nonzero entries on the main + # diagonal. + + void fq_mat_randtriu(fq_mat_t mat, flint_rand_t state, int unit, const fq_ctx_t ctx) + # Sets ``mat`` to a random upper triangular matrix. If + # ``unit`` is 1, it will have ones on the main diagonal, + # otherwise it will have random nonzero entries on the main + # diagonal. + + int fq_mat_equal(const fq_mat_t mat1, const fq_mat_t mat2, const fq_ctx_t ctx) + # Returns nonzero if mat1 and mat2 have the same dimensions and elements, + # and zero otherwise. + + int fq_mat_is_zero(const fq_mat_t mat, const fq_ctx_t ctx) + # Returns a non-zero value if all entries of ``mat`` are zero, and + # otherwise returns zero. + + int fq_mat_is_one(const fq_mat_t mat, const fq_ctx_t ctx) + # Returns a non-zero value if all entries ``mat`` are zero except the + # diagonal entries which must be one, otherwise returns zero.. + + int fq_mat_is_empty(const fq_mat_t mat, const fq_ctx_t ctx) + # Returns a non-zero value if the number of rows or the number of + # columns in ``mat`` is zero, and otherwise returns zero. + + int fq_mat_is_square(const fq_mat_t mat, const fq_ctx_t ctx) + # Returns a non-zero value if the number of rows is equal to the + # number of columns in ``mat``, and otherwise returns zero. + + void fq_mat_add(fq_mat_t C, const fq_mat_t A, const fq_mat_t B, const fq_ctx_t ctx) + # Computes `C = A + B`. Dimensions must be identical. + + void fq_mat_sub(fq_mat_t C, const fq_mat_t A, const fq_mat_t B, const fq_ctx_t ctx) + # Computes `C = A - B`. Dimensions must be identical. + + void fq_mat_neg(fq_mat_t A, const fq_mat_t B, const fq_ctx_t ctx) + # Sets `B = -A`. Dimensions must be identical. + + void fq_mat_mul(fq_mat_t C, const fq_mat_t A, const fq_mat_t B, const fq_ctx_t ctx) + # Sets `C = AB`. Dimensions must be compatible for matrix + # multiplication. Aliasing is allowed. This function automatically chooses + # between classical and KS multiplication. + + void fq_mat_mul_classical(fq_mat_t C, const fq_mat_t A, const fq_mat_t B, const fq_ctx_t ctx) + # Sets `C = AB`. Dimensions must be compatible for matrix multiplication. + # `C` is not allowed to be aliased with `A` or `B`. Uses classical + # matrix multiplication. + + void fq_mat_mul_KS(fq_mat_t C, const fq_mat_t A, const fq_mat_t B, const fq_ctx_t ctx) + # Sets `C = AB`. Dimensions must be compatible for matrix + # multiplication. `C` is not allowed to be aliased with `A` or + # `B`. Uses Kronecker substitution to perform the multiplication + # over the integers. + + void fq_mat_submul(fq_mat_t D, const fq_mat_t C, const fq_mat_t A, const fq_mat_t B, const fq_ctx_t ctx) + # Sets `D = C + AB`. `C` and `D` may be aliased with each other but + # not with `A` or `B`. + + void fq_mat_mul_vec(fq_struct * c, const fq_mat_t A, const fq_struct * b, slong blen, const fq_ctx_t ctx) + void fq_mat_mul_vec_ptr(fq_struct * const * c, const fq_mat_t A, const fq_struct * const * b, slong blen, const fq_ctx_t ctx) + # Compute a matrix-vector product of ``A`` and ``(b, blen)`` and store the result in ``c``. + # The vector ``(b, blen)`` is either truncated or zero-extended to the number of columns of ``A``. + # The number entries written to ``c`` is always equal to the number of rows of ``A``. + + void fq_mat_vec_mul(fq_struct * c, const fq_struct * a, slong alen, const fq_mat_t B, const fq_ctx_t ctx) + void fq_mat_vec_mul_ptr(fq_struct * const * c, const fq_struct * const * a, slong alen, const fq_mat_t B, const fq_ctx_t ctx) + # Compute a vector-matrix product of ``(a, alen)`` and ``B`` and and store the result in ``c``. + # The vector ``(a, alen)`` is either truncated or zero-extended to the number of rows of ``B``. + # The number entries written to ``c`` is always equal to the number of columns of ``B``. + + int fq_mat_inv(fq_mat_t B, fq_mat_t A, const fq_ctx_t ctx) + # Sets `B = A^{-1}` and returns `1` if `A` is invertible. If `A` is singular, + # returns `0` and sets the elements of `B` to undefined values. + # `A` and `B` must be square matrices with the same dimensions. + + slong fq_mat_lu(slong * P, fq_mat_t A, int rank_check, const fq_ctx_t ctx) + # Computes a generalised LU decomposition `LU = PA` of a given + # matrix `A`, returning the rank of `A`. + # If `A` is a nonsingular square matrix, it will be overwritten with + # a unit diagonal lower triangular matrix `L` and an upper + # triangular matrix `U` (the diagonal of `L` will not be stored + # explicitly). + # If `A` is an arbitrary matrix of rank `r`, `U` will be in row + # echelon form having `r` nonzero rows, and `L` will be lower + # triangular but truncated to `r` columns, having implicit ones on + # the `r` first entries of the main diagonal. All other entries will + # be zero. + # If a nonzero value for ``rank_check`` is passed, the function + # will abandon the output matrix in an undefined state and return 0 + # if `A` is detected to be rank-deficient. + # This function calls ``fq_mat_lu_recursive``. + + slong fq_mat_lu_classical(slong * P, fq_mat_t A, int rank_check, const fq_ctx_t ctx) + # Computes a generalised LU decomposition `LU = PA` of a given + # matrix `A`, returning the rank of `A`. The behavior of this + # function is identical to that of ``fq_mat_lu``. Uses Gaussian + # elimination. + + slong fq_mat_lu_recursive(slong * P, fq_mat_t A, int rank_check, const fq_ctx_t ctx) + # Computes a generalised LU decomposition `LU = PA` of a given + # matrix `A`, returning the rank of `A`. The behavior of this + # function is identical to that of ``fq_mat_lu``. Uses recursive + # block decomposition, switching to classical Gaussian elimination + # for sufficiently small blocks. + + slong fq_mat_rref(fq_mat_t A, const fq_ctx_t ctx) + # Puts `A` in reduced row echelon form and returns the rank of `A`. + # The rref is computed by first obtaining an unreduced row echelon + # form via LU decomposition and then solving an additional + # triangular system. + + slong fq_mat_reduce_row(fq_mat_t A, slong * P, slong * L, slong n, const fq_ctx_t ctx) + # Reduce row n of the matrix `A`, assuming the prior rows are in Gauss + # form. However those rows may not be in order. The entry `i` of the array + # `P` is the row of `A` which has a pivot in the `i`-th column. If no such + # row exists, the entry of `P` will be `-1`. The function returns the column + # in which the `n`-th row has a pivot after reduction. This will always be + # chosen to be the first available column for a pivot from the left. This + # information is also updated in `P`. Entry `i` of the array `L` contains the + # number of possibly nonzero columns of `A` row `i`. This speeds up reduction + # in the case that `A` is chambered on the right. Otherwise the entries of + # `L` can all be set to the number of columns of `A`. We require the entries + # of `L` to be monotonic increasing. + + void fq_mat_solve_tril(fq_mat_t X, const fq_mat_t L, const fq_mat_t B, int unit, const fq_ctx_t ctx) + # Sets `X = L^{-1} B` where `L` is a full rank lower triangular + # square matrix. If ``unit`` = 1, `L` is assumed to have ones on + # its main diagonal, and the main diagonal will not be read. `X` + # and `B` are allowed to be the same matrix, but no other aliasing + # is allowed. Automatically chooses between the classical and + # recursive algorithms. + + void fq_mat_solve_tril_classical(fq_mat_t X, const fq_mat_t L, const fq_mat_t B, int unit, const fq_ctx_t ctx) + # Sets `X = L^{-1} B` where `L` is a full rank lower triangular + # square matrix. If ``unit`` = 1, `L` is assumed to have ones on + # its main diagonal, and the main diagonal will not be read. `X` + # and `B` are allowed to be the same matrix, but no other aliasing + # is allowed. Uses forward substitution. + + void fq_mat_solve_tril_recursive(fq_mat_t X, const fq_mat_t L, const fq_mat_t B, int unit, const fq_ctx_t ctx) + # Sets `X = L^{-1} B` where `L` is a full rank lower triangular + # square matrix. If ``unit`` = 1, `L` is assumed to have ones on + # its main diagonal, and the main diagonal will not be read. `X` + # and `B` are allowed to be the same matrix, but no other aliasing + # is allowed. + # Uses the block inversion formula + # .. math :: + # \begin{pmatrix} A & 0 \\ C & D \end{pmatrix}^{-1} + # \begin{pmatrix} X \\ Y \end{pmatrix} = + # \begin{pmatrix} A^{-1} X \\ D^{-1} ( Y - C A^{-1} X ) \end{pmatrix} + # to reduce the problem to matrix multiplication and triangular + # solving of smaller systems. + + void fq_mat_solve_triu(fq_mat_t X, const fq_mat_t U, const fq_mat_t B, int unit, const fq_ctx_t ctx) + # Sets `X = U^{-1} B` where `U` is a full rank upper triangular + # square matrix. If ``unit`` = 1, `U` is assumed to have ones on + # its main diagonal, and the main diagonal will not be read. `X` + # and `B` are allowed to be the same matrix, but no other aliasing + # is allowed. Automatically chooses between the classical and + # recursive algorithms. + + void fq_mat_solve_triu_classical(fq_mat_t X, const fq_mat_t U, const fq_mat_t B, int unit, const fq_ctx_t ctx) + # Sets `X = U^{-1} B` where `U` is a full rank upper triangular + # square matrix. If ``unit`` = 1, `U` is assumed to have ones on + # its main diagonal, and the main diagonal will not be read. `X` + # and `B` are allowed to be the same matrix, but no other aliasing + # is allowed. Uses forward substitution. + + void fq_mat_solve_triu_recursive(fq_mat_t X, const fq_mat_t U, const fq_mat_t B, int unit, const fq_ctx_t ctx) + # Sets `X = U^{-1} B` where `U` is a full rank upper triangular + # square matrix. If ``unit`` = 1, `U` is assumed to have ones on + # its main diagonal, and the main diagonal will not be read. `X` + # and `B` are allowed to be the same matrix, but no other aliasing + # is allowed. + # Uses the block inversion formula + # .. math :: + # \begin{pmatrix} A & B \\ 0 & D \end{pmatrix}^{-1} + # \begin{pmatrix} X \\ Y \end{pmatrix} = + # \begin{pmatrix} A^{-1} (X - B D^{-1} Y) \\ D^{-1} Y \end{pmatrix} + # to reduce the problem to matrix multiplication and triangular + # solving of smaller systems. + + int fq_mat_solve(fq_mat_t X, const fq_mat_t A, const fq_mat_t B, const fq_ctx_t ctx) + # Solves the matrix-matrix equation `AX = B`. + # Returns `1` if `A` has full rank; otherwise returns `0` and sets the + # elements of `X` to undefined values. + # The matrix `A` must be square. + + int fq_mat_can_solve(fq_mat_t X, const fq_mat_t A, const fq_mat_t B, const fq_ctx_t ctx) + # Solves the matrix-matrix equation `AX = B` over `Fq`. + # Returns `1` if a solution exists; otherwise returns `0` and sets the + # elements of `X` to zero. If more than one solution exists, one of the + # valid solutions is given. + # There are no restrictions on the shape of `A` and it may be singular. + + void fq_mat_similarity(fq_mat_t M, slong r, fq_t d, const fq_ctx_t ctx) + # Applies a similarity transform to the `n\times n` matrix `M` in-place. + # If `P` is the `n\times n` identity matrix the zero entries of whose row + # `r` (`0`-indexed) have been replaced by `d`, this transform is equivalent + # to `M = P^{-1}MP`. + # Similarity transforms preserve the determinant, characteristic polynomial + # and minimal polynomial. + # The value `d` is required to be reduced modulo the modulus of the entries + # in the matrix. + + void fq_mat_charpoly_danilevsky(fq_poly_t p, const fq_mat_t M, const fq_ctx_t ctx) + # Compute the characteristic polynomial `p` of the matrix `M`. The matrix + # is assumed to be square. + + void fq_mat_charpoly(fq_poly_t p, const fq_mat_t M, const fq_ctx_t ctx) + # Compute the characteristic polynomial `p` of the matrix `M`. The matrix + # is required to be square, otherwise an exception is raised. + + void fq_mat_minpoly(fq_poly_t p, const fq_mat_t M, const fq_ctx_t ctx) + # Compute the minimal polynomial `p` of the matrix `M`. The matrix + # is required to be square, otherwise an exception is raised. diff --git a/src/sage/libs/flint/fq_nmod.pxd b/src/sage/libs/flint/fq_nmod.pxd index dda3ec58de7..9af72d4cbc2 100644 --- a/src/sage/libs/flint/fq_nmod.pxd +++ b/src/sage/libs/flint/fq_nmod.pxd @@ -12,7 +12,7 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void fq_nmod_ctx_init(fq_nmod_ctx_t ctx, const fmpz_t p, long d, const char *var) + void fq_nmod_ctx_init(fq_nmod_ctx_t ctx, const fmpz_t p, slong d, const char *var) # Initialises the context for prime `p` and extension degree `d`, # with name ``var`` for the generator. By default, it will try # use a Conway polynomial; if one is not available, a random @@ -21,7 +21,7 @@ cdef extern from "flint_wrap.h": # Assumes that the string ``var`` is a null-terminated string # of length at least one. - int _fq_nmod_ctx_init_conway(fq_nmod_ctx_t ctx, const fmpz_t p, long d, const char *var) + int _fq_nmod_ctx_init_conway(fq_nmod_ctx_t ctx, const fmpz_t p, slong d, const char *var) # Attempts to initialise the context for prime `p` and extension # degree `d`, with name ``var`` for the generator using a Conway # polynomial for the modulus. @@ -32,7 +32,7 @@ cdef extern from "flint_wrap.h": # Assumes that the string ``var`` is a null-terminated string # of length at least one. - void fq_nmod_ctx_init_conway(fq_nmod_ctx_t ctx, const fmpz_t p, long d, const char *var) + void fq_nmod_ctx_init_conway(fq_nmod_ctx_t ctx, const fmpz_t p, slong d, const char *var) # Initialises the context for prime `p` and extension degree `d`, # with name ``var`` for the generator using a Conway polynomial # for the modulus. @@ -54,7 +54,7 @@ cdef extern from "flint_wrap.h": const nmod_poly_struct* fq_nmod_ctx_modulus(const fq_nmod_ctx_t ctx) # Returns a pointer to the modulus in the context. - long fq_nmod_ctx_degree(const fq_nmod_ctx_t ctx) + slong fq_nmod_ctx_degree(const fq_nmod_ctx_t ctx) # Returns the degree of the field extension # `[\mathbf{F}_{q} : \mathbf{F}_{p}]`, which # is equal to `\log_{p} q`. @@ -91,15 +91,15 @@ cdef extern from "flint_wrap.h": void fq_nmod_clear(fq_nmod_t rop, const fq_nmod_ctx_t ctx) # Clears the element ``rop``. - void _fq_nmod_sparse_reduce(mp_limb_t * R, long lenR, const fq_nmod_ctx_t ctx) + void _fq_nmod_sparse_reduce(mp_limb_t * R, slong lenR, const fq_nmod_ctx_t ctx) # Reduces ``(R, lenR)`` modulo the polynomial `f` given by the # modulus of ``ctx``. - void _fq_nmod_dense_reduce(mp_limb_t * R, long lenR, const fq_nmod_ctx_t ctx) + void _fq_nmod_dense_reduce(mp_limb_t * R, slong lenR, const fq_nmod_ctx_t ctx) # Reduces ``(R, lenR)`` modulo the polynomial `f` given by the # modulus of ``ctx`` using Newton division. - void _fq_nmod_reduce(mp_limb_t * r, long lenR, const fq_nmod_ctx_t ctx) + void _fq_nmod_reduce(mp_limb_t * r, slong lenR, const fq_nmod_ctx_t ctx) # Reduces ``(R, lenR)`` modulo the polynomial `f` given by the # modulus of ``ctx``. Does either sparse or dense reduction # based on ``ctx->sparse_modulus``. @@ -128,11 +128,11 @@ cdef extern from "flint_wrap.h": # Sets ``rop`` to the product of ``op`` and `x`, # reducing the output in the given context. - void fq_nmod_mul_si(fq_nmod_t rop, const fq_nmod_t op, long x, const fq_nmod_ctx_t ctx) + void fq_nmod_mul_si(fq_nmod_t rop, const fq_nmod_t op, slong x, const fq_nmod_ctx_t ctx) # Sets ``rop`` to the product of ``op`` and `x`, # reducing the output in the given context. - void fq_nmod_mul_ui(fq_nmod_t rop, const fq_nmod_t op, unsigned long x, const fq_nmod_ctx_t ctx) + void fq_nmod_mul_ui(fq_nmod_t rop, const fq_nmod_t op, ulong x, const fq_nmod_ctx_t ctx) # Sets ``rop`` to the product of ``op`` and `x`, # reducing the output in the given context. @@ -140,7 +140,7 @@ cdef extern from "flint_wrap.h": # Sets ``rop`` to the square of ``op``, # reducing the output in the given context. - void _fq_nmod_inv(mp_ptr * rop, mp_srcptr * op, long len, const fq_nmod_ctx_t ctx) + void _fq_nmod_inv(mp_ptr * rop, mp_srcptr * op, slong len, const fq_nmod_ctx_t ctx) # Sets ``(rop, d)`` to the inverse of the non-zero element # ``(op, len)``. @@ -152,7 +152,7 @@ cdef extern from "flint_wrap.h": # of ``ctx``. If ``op`` is not invertible, then ``f`` is # set to a factor of the modulus; otherwise, it is set to one. - void _fq_nmod_pow(mp_limb_t * rop, const mp_limb_t * op, long len, const fmpz_t e, const fq_nmod_ctx_t ctx) + void _fq_nmod_pow(mp_limb_t * rop, const mp_limb_t * op, slong len, const fmpz_t e, const fq_nmod_ctx_t ctx) # Sets ``(rop, 2*d-1)`` to ``(op,len)`` raised to the power `e`, # reduced modulo `f(X)`, the modulus of ``ctx``. # Assumes that `e \geq 0` and that ``len`` is positive and at most `d`. @@ -167,7 +167,7 @@ cdef extern from "flint_wrap.h": # Note that for any input ``op``, ``rop`` is set to `1` # whenever `e = 0`. - void fq_nmod_pow_ui(fq_nmod_t rop, const fq_nmod_t op, const unsigned long e, const fq_nmod_ctx_t ctx) + void fq_nmod_pow_ui(fq_nmod_t rop, const fq_nmod_t op, const ulong e, const fq_nmod_ctx_t ctx) # Sets ``rop`` to ``op`` raised to the power `e`. # Currently assumes that `e \geq 0`. # Note that for any input ``op``, ``rop`` is set to `1` @@ -232,11 +232,11 @@ cdef extern from "flint_wrap.h": void fq_nmod_set(fq_nmod_t rop, const fq_nmod_t op, const fq_nmod_ctx_t ctx) # Sets ``rop`` to ``op``. - void fq_nmod_set_si(fq_nmod_t rop, const long x, const fq_nmod_ctx_t ctx) + void fq_nmod_set_si(fq_nmod_t rop, const slong x, const fq_nmod_ctx_t ctx) # Sets ``rop`` to ``x``, considered as an element of # `\mathbf{F}_p`. - void fq_nmod_set_ui(fq_nmod_t rop, const unsigned long x, const fq_nmod_ctx_t ctx) + void fq_nmod_set_ui(fq_nmod_t rop, const ulong x, const fq_nmod_ctx_t ctx) # Sets ``rop`` to ``x``, considered as an element of # `\mathbf{F}_p`. @@ -295,7 +295,7 @@ cdef extern from "flint_wrap.h": int fq_nmod_cmp(const fq_nmod_t a, const fq_nmod_t b, const fq_nmod_ctx_t ctx) # Return ``1`` (resp. ``-1``, or ``0``) if ``a`` is after (resp. before, same as) ``b`` in some arbitrary but fixed total ordering of the elements. - void _fq_nmod_trace(fmpz_t rop, const mp_limb_t * op, long len, const fq_nmod_ctx_t ctx) + void _fq_nmod_trace(fmpz_t rop, const mp_limb_t * op, slong len, const fq_nmod_ctx_t ctx) # Sets ``rop`` to the trace of the non-zero element ``(op, len)`` # in `\mathbf{F}_{q}`. @@ -308,7 +308,7 @@ cdef extern from "flint_wrap.h": # `a` is equal to `\sum_{i=0}^{d-1} \Sigma^i (a)`, where `d = # \log_{p} q`. - void _fq_nmod_norm(fmpz_t rop, const mp_limb_t * op, long len, const fq_nmod_ctx_t ctx) + void _fq_nmod_norm(fmpz_t rop, const mp_limb_t * op, slong len, const fq_nmod_ctx_t ctx) # Sets ``rop`` to the norm of the non-zero element ``(op, len)`` # in `\mathbf{F}_{q}`. @@ -322,12 +322,12 @@ cdef extern from "flint_wrap.h": # `d = \text{dim}_{\mathbf{F}_p}(\mathbf{F}_q)`. # Algorithm selection is automatic depending on the input. - void _fq_nmod_frobenius(mp_limb_t * rop, const mp_limb_t * op, long len, long e, const fq_nmod_ctx_t ctx) + void _fq_nmod_frobenius(mp_limb_t * rop, const mp_limb_t * op, slong len, slong e, const fq_nmod_ctx_t ctx) # Sets ``(rop, 2d-1)`` to the image of ``(op, len)`` under the # Frobenius operator raised to the e-th power, assuming that neither # ``op`` nor ``e`` are zero. - void fq_nmod_frobenius(fq_nmod_t rop, const fq_nmod_t op, long e, const fq_nmod_ctx_t ctx) + void fq_nmod_frobenius(fq_nmod_t rop, const fq_nmod_t op, slong e, const fq_nmod_ctx_t ctx) # Evaluates the homomorphism `\Sigma^e` at ``op``. # Recall that `\mathbf{F}_q / \mathbf{F}_p` is Galois with Galois group # `\langle \sigma \rangle`, which is also isomorphic to diff --git a/src/sage/libs/flint/fq_nmod_embed.pxd b/src/sage/libs/flint/fq_nmod_embed.pxd index 331b7a2e9a0..03accc2a3d7 100644 --- a/src/sage/libs/flint/fq_nmod_embed.pxd +++ b/src/sage/libs/flint/fq_nmod_embed.pxd @@ -70,7 +70,7 @@ cdef extern from "flint_wrap.h": # For an element `a\in\mathbf{F}_{p^n}`, its composition matrix is the # matrix whose columns are `a^0, a^1, \ldots, a^{n-1}`. - void fq_nmod_embed_composition_matrix_sub(nmod_mat_t matrix, const fq_nmod_t gen, const fq_nmod_ctx_t ctx, long trunc) + void fq_nmod_embed_composition_matrix_sub(nmod_mat_t matrix, const fq_nmod_t gen, const fq_nmod_ctx_t ctx, slong trunc) # Compute the *composition matrix* of ``gen``, truncated to # ``trunc`` columns. @@ -88,7 +88,7 @@ cdef extern from "flint_wrap.h": # Compute the change of basis matrix from the dual basis of # ``ctx`` to its monomial basis. - void fq_nmod_modulus_pow_series_inv(nmod_poly_t res, const fq_nmod_ctx_t ctx, long trunc) + void fq_nmod_modulus_pow_series_inv(nmod_poly_t res, const fq_nmod_ctx_t ctx, slong trunc) # Compute the power series inverse of the reverse of the modulus of # ``ctx`` up to `O(x^\texttt{trunc})`. diff --git a/src/sage/libs/flint/fq_nmod_mat.pxd b/src/sage/libs/flint/fq_nmod_mat.pxd index a127af92231..37fc46b6cd6 100644 --- a/src/sage/libs/flint/fq_nmod_mat.pxd +++ b/src/sage/libs/flint/fq_nmod_mat.pxd @@ -12,7 +12,7 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void fq_nmod_mat_init(fq_nmod_mat_t mat, long rows, long cols, const fq_nmod_ctx_t ctx) + void fq_nmod_mat_init(fq_nmod_mat_t mat, slong rows, slong cols, const fq_nmod_ctx_t ctx) # Initialises ``mat`` to a ``rows``-by-``cols`` matrix with # coefficients in `\mathbf{F}_{q}` given by ``ctx``. All elements # are set to zero. @@ -30,17 +30,17 @@ cdef extern from "flint_wrap.h": # Sets ``mat`` to a copy of ``src``. It is assumed # that ``mat`` and ``src`` have identical dimensions. - fq_nmod_struct * fq_nmod_mat_entry(const fq_nmod_mat_t mat, long i, long j) + fq_nmod_struct * fq_nmod_mat_entry(const fq_nmod_mat_t mat, slong i, slong j) # Directly accesses the entry in ``mat`` in row `i` and column `j`, # indexed from zero. No bounds checking is performed. - void fq_nmod_mat_entry_set(fq_nmod_mat_t mat, long i, long j, const fq_nmod_t x, const fq_nmod_ctx_t ctx) + void fq_nmod_mat_entry_set(fq_nmod_mat_t mat, slong i, slong j, const fq_nmod_t x, const fq_nmod_ctx_t ctx) # Sets the entry in ``mat`` in row `i` and column `j` to ``x``. - long fq_nmod_mat_nrows(const fq_nmod_mat_t mat, const fq_nmod_ctx_t ctx) + slong fq_nmod_mat_nrows(const fq_nmod_mat_t mat, const fq_nmod_ctx_t ctx) # Returns the number of rows in ``mat``. - long fq_nmod_mat_ncols(const fq_nmod_mat_t mat, const fq_nmod_ctx_t ctx) + slong fq_nmod_mat_ncols(const fq_nmod_mat_t mat, const fq_nmod_ctx_t ctx) # Returns the number of columns in ``mat``. void fq_nmod_mat_swap(fq_nmod_mat_t mat1, fq_nmod_mat_t mat2, const fq_nmod_ctx_t ctx) @@ -57,20 +57,20 @@ cdef extern from "flint_wrap.h": void fq_nmod_mat_one(fq_nmod_mat_t mat, const fq_nmod_ctx_t ctx) # Sets all diagonal entries of ``mat`` to 1 and all other entries to 0. - void fq_nmod_mat_swap_rows(fq_nmod_mat_t mat, long * perm, long r, long s, const fq_nmod_ctx_t ctx) + void fq_nmod_mat_swap_rows(fq_nmod_mat_t mat, slong * perm, slong r, slong s, const fq_nmod_ctx_t ctx) # Swaps rows ``r`` and ``s`` of ``mat``. If ``perm`` is non-``NULL``, the # permutation of the rows will also be applied to ``perm``. - void fq_nmod_mat_swap_cols(fq_nmod_mat_t mat, long * perm, long r, long s, const fq_nmod_ctx_t ctx) + void fq_nmod_mat_swap_cols(fq_nmod_mat_t mat, slong * perm, slong r, slong s, const fq_nmod_ctx_t ctx) # Swaps columns ``r`` and ``s`` of ``mat``. If ``perm`` is non-``NULL``, the # permutation of the columns will also be applied to ``perm``. - void fq_nmod_mat_invert_rows(fq_nmod_mat_t mat, long * perm, const fq_nmod_ctx_t ctx) + void fq_nmod_mat_invert_rows(fq_nmod_mat_t mat, slong * perm, const fq_nmod_ctx_t ctx) # Swaps rows ``i`` and ``r - i`` of ``mat`` for ``0 <= i < r/2``, where # ``r`` is the number of rows of ``mat``. If ``perm`` is non-``NULL``, the # permutation of the rows will also be applied to ``perm``. - void fq_nmod_mat_invert_cols(fq_nmod_mat_t mat, long * perm, const fq_nmod_ctx_t ctx) + void fq_nmod_mat_invert_cols(fq_nmod_mat_t mat, slong * perm, const fq_nmod_ctx_t ctx) # Swaps columns ``i`` and ``c - i`` of ``mat`` for ``0 <= i < c/2``, where # ``c`` is the number of columns of ``mat``. If ``perm`` is non-``NULL``, the # permutation of the columns will also be applied to ``perm``. @@ -107,7 +107,7 @@ cdef extern from "flint_wrap.h": # In case of success, returns a positive value. In case of failure, # returns a non-positive value. - void fq_nmod_mat_window_init(fq_nmod_mat_t window, const fq_nmod_mat_t mat, long r1, long c1, long r2, long c2, const fq_nmod_ctx_t ctx) + void fq_nmod_mat_window_init(fq_nmod_mat_t window, const fq_nmod_mat_t mat, slong r1, slong c1, slong r2, slong c2, const fq_nmod_ctx_t ctx) # Initializes the matrix ``window`` to be an ``r2 - r1`` by # ``c2 - c1`` submatrix of ``mat`` whose ``(0,0)`` entry # is the ``(r1, c1)`` entry of ``mat``. The memory for the @@ -122,7 +122,7 @@ cdef extern from "flint_wrap.h": # Sets the elements of ``mat`` to random elements of # `\mathbf{F}_{q}`, given by ``ctx``. - int fq_nmod_mat_randpermdiag(fq_nmod_mat_t mat, flint_rand_t state, fq_nmod_struct * diag, long n, const fq_nmod_ctx_t ctx) + int fq_nmod_mat_randpermdiag(fq_nmod_mat_t mat, flint_rand_t state, fq_nmod_struct * diag, slong n, const fq_nmod_ctx_t ctx) # Sets ``mat`` to a random permutation of the diagonal matrix # with `n` leading entries given by the vector ``diag``. It is # assumed that the main diagonal of ``mat`` has room for at @@ -130,7 +130,7 @@ cdef extern from "flint_wrap.h": # Returns `0` or `1`, depending on whether the permutation is even # or odd respectively. - void fq_nmod_mat_randrank(fq_nmod_mat_t mat, flint_rand_t state, long rank, const fq_nmod_ctx_t ctx) + void fq_nmod_mat_randrank(fq_nmod_mat_t mat, flint_rand_t state, slong rank, const fq_nmod_ctx_t ctx) # Sets ``mat`` to a random sparse matrix with the given rank, # having exactly as many non-zero elements as the rank, with the # non-zero elements being uniformly random elements of @@ -138,7 +138,7 @@ cdef extern from "flint_wrap.h": # The matrix can be transformed into a dense matrix with unchanged # rank by subsequently calling :func:`fq_nmod_mat_randops`. - void fq_nmod_mat_randops(fq_nmod_mat_t mat, long count, flint_rand_t state, const fq_nmod_ctx_t ctx) + void fq_nmod_mat_randops(fq_nmod_mat_t mat, slong count, flint_rand_t state, const fq_nmod_ctx_t ctx) # Randomises ``mat`` by performing elementary row or column # operations. More precisely, at most ``count`` random additions # or subtractions of distinct rows and columns will be performed. @@ -206,14 +206,14 @@ cdef extern from "flint_wrap.h": # Sets `D = C + AB`. `C` and `D` may be aliased with each other but # not with `A` or `B`. - void fq_nmod_mat_mul_vec(fq_nmod_struct * c, const fq_nmod_mat_t A, const fq_nmod_struct * b, long blen, const fq_nmod_ctx_t ctx) - void fq_nmod_mat_mul_vec_ptr(fq_nmod_struct * const * c, const fq_nmod_mat_t A, const fq_nmod_struct * const * b, long blen, const fq_nmod_ctx_t ctx) + void fq_nmod_mat_mul_vec(fq_nmod_struct * c, const fq_nmod_mat_t A, const fq_nmod_struct * b, slong blen, const fq_nmod_ctx_t ctx) + void fq_nmod_mat_mul_vec_ptr(fq_nmod_struct * const * c, const fq_nmod_mat_t A, const fq_nmod_struct * const * b, slong blen, const fq_nmod_ctx_t ctx) # Compute a matrix-vector product of ``A`` and ``(b, blen)`` and store the result in ``c``. # The vector ``(b, blen)`` is either truncated or zero-extended to the number of columns of ``A``. # The number entries written to ``c`` is always equal to the number of rows of ``A``. - void fq_nmod_mat_vec_mul(fq_nmod_struct * c, const fq_nmod_struct * a, long alen, const fq_nmod_mat_t B, const fq_nmod_ctx_t ctx) - void fq_nmod_mat_vec_mul_ptr(fq_nmod_struct * const * c, const fq_nmod_struct * const * a, long alen, const fq_nmod_mat_t B, const fq_nmod_ctx_t ctx) + void fq_nmod_mat_vec_mul(fq_nmod_struct * c, const fq_nmod_struct * a, slong alen, const fq_nmod_mat_t B, const fq_nmod_ctx_t ctx) + void fq_nmod_mat_vec_mul_ptr(fq_nmod_struct * const * c, const fq_nmod_struct * const * a, slong alen, const fq_nmod_mat_t B, const fq_nmod_ctx_t ctx) # Compute a vector-matrix product of ``(a, alen)`` and ``B`` and and store the result in ``c``. # The vector ``(a, alen)`` is either truncated or zero-extended to the number of rows of ``B``. # The number entries written to ``c`` is always equal to the number of columns of ``B``. @@ -223,7 +223,7 @@ cdef extern from "flint_wrap.h": # returns `0` and sets the elements of `B` to undefined values. # `A` and `B` must be square matrices with the same dimensions. - long fq_nmod_mat_lu(long * P, fq_nmod_mat_t A, int rank_check, const fq_nmod_ctx_t ctx) + slong fq_nmod_mat_lu(slong * P, fq_nmod_mat_t A, int rank_check, const fq_nmod_ctx_t ctx) # Computes a generalised LU decomposition `LU = PA` of a given # matrix `A`, returning the rank of `A`. # If `A` is a nonsingular square matrix, it will be overwritten with @@ -240,26 +240,26 @@ cdef extern from "flint_wrap.h": # if `A` is detected to be rank-deficient. # This function calls ``fq_nmod_mat_lu_recursive``. - long fq_nmod_mat_lu_classical(long * P, fq_nmod_mat_t A, int rank_check, const fq_nmod_ctx_t ctx) + slong fq_nmod_mat_lu_classical(slong * P, fq_nmod_mat_t A, int rank_check, const fq_nmod_ctx_t ctx) # Computes a generalised LU decomposition `LU = PA` of a given # matrix `A`, returning the rank of `A`. The behavior of this # function is identical to that of ``fq_nmod_mat_lu``. Uses Gaussian # elimination. - long fq_nmod_mat_lu_recursive(long * P, fq_nmod_mat_t A, int rank_check, const fq_nmod_ctx_t ctx) + slong fq_nmod_mat_lu_recursive(slong * P, fq_nmod_mat_t A, int rank_check, const fq_nmod_ctx_t ctx) # Computes a generalised LU decomposition `LU = PA` of a given # matrix `A`, returning the rank of `A`. The behavior of this # function is identical to that of ``fq_nmod_mat_lu``. Uses recursive # block decomposition, switching to classical Gaussian elimination # for sufficiently small blocks. - long fq_nmod_mat_rref(fq_nmod_mat_t A, const fq_nmod_ctx_t ctx) + slong fq_nmod_mat_rref(fq_nmod_mat_t A, const fq_nmod_ctx_t ctx) # Puts `A` in reduced row echelon form and returns the rank of `A`. # The rref is computed by first obtaining an unreduced row echelon # form via LU decomposition and then solving an additional # triangular system. - long fq_nmod_mat_reduce_row(fq_nmod_mat_t A, long * P, long * L, long n, const fq_nmod_ctx_t ctx) + slong fq_nmod_mat_reduce_row(fq_nmod_mat_t A, slong * P, slong * L, slong n, const fq_nmod_ctx_t ctx) # Reduce row n of the matrix `A`, assuming the prior rows are in Gauss # form. However those rows may not be in order. The entry `i` of the array # `P` is the row of `A` which has a pivot in the `i`-th column. If no such @@ -343,7 +343,7 @@ cdef extern from "flint_wrap.h": # valid solutions is given. # There are no restrictions on the shape of `A` and it may be singular. - void fq_nmod_mat_similarity(fq_nmod_mat_t M, long r, fq_nmod_t d, const fq_nmod_ctx_t ctx) + void fq_nmod_mat_similarity(fq_nmod_mat_t M, slong r, fq_nmod_t d, const fq_nmod_ctx_t ctx) # Applies a similarity transform to the `n\times n` matrix `M` in-place. # If `P` is the `n\times n` identity matrix the zero entries of whose row # `r` (`0`-indexed) have been replaced by `d`, this transform is equivalent diff --git a/src/sage/libs/flint/fq_nmod_mpoly.pxd b/src/sage/libs/flint/fq_nmod_mpoly.pxd index a5ef24068e8..3ed0b2350ec 100644 --- a/src/sage/libs/flint/fq_nmod_mpoly.pxd +++ b/src/sage/libs/flint/fq_nmod_mpoly.pxd @@ -12,12 +12,12 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void fq_nmod_mpoly_ctx_init(fq_nmod_mpoly_ctx_t ctx, long nvars, const ordering_t ord, const fq_nmod_ctx_t fqctx) + void fq_nmod_mpoly_ctx_init(fq_nmod_mpoly_ctx_t ctx, slong nvars, const ordering_t ord, const fq_nmod_ctx_t fqctx) # Initialise a context object for a polynomial ring with the given number of variables and the given ordering. # It will have coefficients in the finite field *fqctx*. # The possibilities for the ordering are ``ORD_LEX``, ``ORD_DEGLEX`` and ``ORD_DEGREVLEX``. - long fq_nmod_mpoly_ctx_nvars(const fq_nmod_mpoly_ctx_t ctx) + slong fq_nmod_mpoly_ctx_nvars(const fq_nmod_mpoly_ctx_t ctx) # Return the number of variables used to initialize the context. ordering_t fq_nmod_mpoly_ctx_ord(const fq_nmod_mpoly_ctx_t ctx) @@ -29,18 +29,18 @@ cdef extern from "flint_wrap.h": void fq_nmod_mpoly_init(fq_nmod_mpoly_t A, const fq_nmod_mpoly_ctx_t ctx) # Initialise *A* for use with the given an initialised context object. Its value is set to zero. - void fq_nmod_mpoly_init2(fq_nmod_mpoly_t A, long alloc, const fq_nmod_mpoly_ctx_t ctx) + void fq_nmod_mpoly_init2(fq_nmod_mpoly_t A, slong alloc, const fq_nmod_mpoly_ctx_t ctx) # Initialise *A* for use with the given an initialised context object. Its value is set to zero. # It is allocated with space for *alloc* terms and at least ``MPOLY_MIN_BITS`` bits for the exponents. - void fq_nmod_mpoly_init3(fq_nmod_mpoly_t A, long alloc, flint_bitcnt_t bits, const fq_nmod_mpoly_ctx_t ctx) + void fq_nmod_mpoly_init3(fq_nmod_mpoly_t A, slong alloc, flint_bitcnt_t bits, const fq_nmod_mpoly_ctx_t ctx) # Initialise *A* for use with the given an initialised context object. Its value is set to zero. # It is allocated with space for *alloc* terms and *bits* bits for the exponents. - void fq_nmod_mpoly_fit_length(fq_nmod_mpoly_t A, long len, const fq_nmod_mpoly_ctx_t ctx) + void fq_nmod_mpoly_fit_length(fq_nmod_mpoly_t A, slong len, const fq_nmod_mpoly_ctx_t ctx) # Ensure that *A* has space for at least *len* terms. - void fq_nmod_mpoly_realloc(fq_nmod_mpoly_t A, long alloc, const fq_nmod_mpoly_ctx_t ctx) + void fq_nmod_mpoly_realloc(fq_nmod_mpoly_t A, slong alloc, const fq_nmod_mpoly_ctx_t ctx) # Reallocate *A* to have space for *alloc* terms. # Assumes the current length of the polynomial is not greater than *alloc*. @@ -62,10 +62,10 @@ cdef extern from "flint_wrap.h": # The operations ``+``, ``-``, ``*``, and ``/`` are permitted along with integers and the variables in *x*. The character ``^`` must be immediately followed by the (integer) exponent. # If any division is not exact, parsing fails. - void fq_nmod_mpoly_gen(fq_nmod_mpoly_t A, long var, const fq_nmod_mpoly_ctx_t ctx) + void fq_nmod_mpoly_gen(fq_nmod_mpoly_t A, slong var, const fq_nmod_mpoly_ctx_t ctx) # Set *A* to the variable of index *var*, where `var = 0` corresponds to the variable with the most significance with respect to the ordering. - int fq_nmod_mpoly_is_gen(const fq_nmod_mpoly_t A, long var, const fq_nmod_mpoly_ctx_t ctx) + int fq_nmod_mpoly_is_gen(const fq_nmod_mpoly_t A, slong var, const fq_nmod_mpoly_ctx_t ctx) # If `var \ge 0`, return `1` if *A* is equal to the `var`-th generator, otherwise return `0`. # If `var < 0`, return `1` if the polynomial is equal to any generator, otherwise return `0`. @@ -86,7 +86,7 @@ cdef extern from "flint_wrap.h": # This function throws if *A* is not a constant. void fq_nmod_mpoly_set_fq_nmod(fq_nmod_mpoly_t A, const fq_nmod_t c, const fq_nmod_mpoly_ctx_t ctx) - void fq_nmod_mpoly_set_ui(fq_nmod_mpoly_t A, unsigned long c, const fq_nmod_mpoly_ctx_t ctx) + void fq_nmod_mpoly_set_ui(fq_nmod_mpoly_t A, ulong c, const fq_nmod_mpoly_ctx_t ctx) # Set *A* to the constant *c*. void fq_nmod_mpoly_set_fq_nmod_gen(fq_nmod_mpoly_t A, const fq_nmod_mpoly_ctx_t ctx) @@ -111,12 +111,12 @@ cdef extern from "flint_wrap.h": # Return `1` if the degrees of *A* with respect to each variable fit into an ``slong``, otherwise return `0`. void fq_nmod_mpoly_degrees_fmpz(fmpz ** degs, const fq_nmod_mpoly_t A, const fq_nmod_mpoly_ctx_t ctx) - void fq_nmod_mpoly_degrees_si(long * degs, const fq_nmod_mpoly_t A, const fq_nmod_mpoly_ctx_t ctx) + void fq_nmod_mpoly_degrees_si(slong * degs, const fq_nmod_mpoly_t A, const fq_nmod_mpoly_ctx_t ctx) # Set *degs* to the degrees of *A* with respect to each variable. # If *A* is zero, all degrees are set to `-1`. - void fq_nmod_mpoly_degree_fmpz(fmpz_t deg, const fq_nmod_mpoly_t A, long var, const fq_nmod_mpoly_ctx_t ctx) - long fq_nmod_mpoly_degree_si(const fq_nmod_mpoly_t A, long var, const fq_nmod_mpoly_ctx_t ctx) + void fq_nmod_mpoly_degree_fmpz(fmpz_t deg, const fq_nmod_mpoly_t A, slong var, const fq_nmod_mpoly_ctx_t ctx) + slong fq_nmod_mpoly_degree_si(const fq_nmod_mpoly_t A, slong var, const fq_nmod_mpoly_ctx_t ctx) # Either return or set *deg* to the degree of *A* with respect to the variable of index *var*. # If *A* is zero, the degree is defined to be `-1`. @@ -124,7 +124,7 @@ cdef extern from "flint_wrap.h": # Return `1` if the total degree of *A* fits into an ``slong``, otherwise return `0`. void fq_nmod_mpoly_total_degree_fmpz(fmpz_t tdeg, const fq_nmod_mpoly_t A, const fq_nmod_mpoly_ctx_t ctx) - long fq_nmod_mpoly_total_degree_si(const fq_nmod_mpoly_t A, const fq_nmod_mpoly_ctx_t ctx) + slong fq_nmod_mpoly_total_degree_si(const fq_nmod_mpoly_t A, const fq_nmod_mpoly_ctx_t ctx) # Either return or set *tdeg* to the total degree of *A*. # If *A* is zero, the total degree is defined to be `-1`. @@ -140,14 +140,14 @@ cdef extern from "flint_wrap.h": # This function throws if *M* is not a monomial. void fq_nmod_mpoly_get_coeff_fq_nmod_fmpz(fq_nmod_t c, const fq_nmod_mpoly_t A, fmpz * const * exp, const fq_nmod_mpoly_ctx_t ctx) - void fq_nmod_mpoly_get_coeff_fq_nmod_ui(fq_nmod_t c, const fq_nmod_mpoly_t A, const unsigned long * exp, const fq_nmod_mpoly_ctx_t ctx) + void fq_nmod_mpoly_get_coeff_fq_nmod_ui(fq_nmod_t c, const fq_nmod_mpoly_t A, const ulong * exp, const fq_nmod_mpoly_ctx_t ctx) # Set *c* to the coefficient of the monomial with exponent vector *exp*. void fq_nmod_mpoly_set_coeff_fq_nmod_fmpz(fq_nmod_mpoly_t A, const fq_nmod_t c, fmpz * const * exp, const fq_nmod_mpoly_ctx_t ctx) - void fq_nmod_mpoly_set_coeff_fq_nmod_ui(fq_nmod_mpoly_t A, const fq_nmod_t c, const unsigned long * exp, const fq_nmod_mpoly_ctx_t ctx) + void fq_nmod_mpoly_set_coeff_fq_nmod_ui(fq_nmod_mpoly_t A, const fq_nmod_t c, const ulong * exp, const fq_nmod_mpoly_ctx_t ctx) # Set the coefficient of the monomial with exponent *exp* to *c*. - void fq_nmod_mpoly_get_coeff_vars_ui(fq_nmod_mpoly_t C, const fq_nmod_mpoly_t A, const long * vars, const unsigned long * exps, long length, const fq_nmod_mpoly_ctx_t ctx) + void fq_nmod_mpoly_get_coeff_vars_ui(fq_nmod_mpoly_t C, const fq_nmod_mpoly_t A, const slong * vars, const ulong * exps, slong length, const fq_nmod_mpoly_ctx_t ctx) # Set *C* to the coefficient of *A* with respect to the variables in *vars* with powers in the corresponding array *exps*. # Both *vars* and *exps* point to array of length *length*. It is assumed that `0 < length \le nvars(A)` and that the variables in *vars* are distinct. @@ -159,48 +159,48 @@ cdef extern from "flint_wrap.h": # Return `1` if *A* is in canonical form. Otherwise, return `0`. # To be in canonical form, all of the terms must have nonzero coefficients, and the terms must be sorted from greatest to least. - long fq_nmod_mpoly_length(const fq_nmod_mpoly_t A, const fq_nmod_mpoly_ctx_t ctx) + slong fq_nmod_mpoly_length(const fq_nmod_mpoly_t A, const fq_nmod_mpoly_ctx_t ctx) # Return the number of terms in *A*. # If the polynomial is in canonical form, this will be the number of nonzero coefficients. - void fq_nmod_mpoly_resize(fq_nmod_mpoly_t A, long new_length, const fq_nmod_mpoly_ctx_t ctx) + void fq_nmod_mpoly_resize(fq_nmod_mpoly_t A, slong new_length, const fq_nmod_mpoly_ctx_t ctx) # Set the length of *A* to ``new_length``. # Terms are either deleted from the end, or new zero terms are appended. - void fq_nmod_mpoly_get_term_coeff_fq_nmod(fq_nmod_t c, const fq_nmod_mpoly_t A, long i, const fq_nmod_mpoly_ctx_t ctx) + void fq_nmod_mpoly_get_term_coeff_fq_nmod(fq_nmod_t c, const fq_nmod_mpoly_t A, slong i, const fq_nmod_mpoly_ctx_t ctx) # Set *c* to the coefficient of the term of index *i*. - void fq_nmod_mpoly_set_term_coeff_ui(fq_nmod_mpoly_t A, long i, unsigned long c, const fq_nmod_mpoly_ctx_t ctx) + void fq_nmod_mpoly_set_term_coeff_ui(fq_nmod_mpoly_t A, slong i, ulong c, const fq_nmod_mpoly_ctx_t ctx) # Set the coefficient of the term of index *i* to *c*. - int fq_nmod_mpoly_term_exp_fits_si(const fq_nmod_mpoly_t A, long i, const fq_nmod_mpoly_ctx_t ctx) - int fq_nmod_mpoly_term_exp_fits_ui(const fq_nmod_mpoly_t A, long i, const fq_nmod_mpoly_ctx_t ctx) + int fq_nmod_mpoly_term_exp_fits_si(const fq_nmod_mpoly_t A, slong i, const fq_nmod_mpoly_ctx_t ctx) + int fq_nmod_mpoly_term_exp_fits_ui(const fq_nmod_mpoly_t A, slong i, const fq_nmod_mpoly_ctx_t ctx) # Return `1` if all entries of the exponent vector of the term of index `i` fit into an ``slong`` (resp. a ``ulong``). Otherwise, return `0`. - void fq_nmod_mpoly_get_term_exp_fmpz(fmpz ** exp, const fq_nmod_mpoly_t A, long i, const fq_nmod_mpoly_ctx_t ctx) - void fq_nmod_mpoly_get_term_exp_ui(unsigned long * exp, const fq_nmod_mpoly_t A, long i, const fq_nmod_mpoly_ctx_t ctx) - void fq_nmod_mpoly_get_term_exp_si(long * exp, const fq_nmod_mpoly_t A, long i, const fq_nmod_mpoly_ctx_t ctx) + void fq_nmod_mpoly_get_term_exp_fmpz(fmpz ** exp, const fq_nmod_mpoly_t A, slong i, const fq_nmod_mpoly_ctx_t ctx) + void fq_nmod_mpoly_get_term_exp_ui(ulong * exp, const fq_nmod_mpoly_t A, slong i, const fq_nmod_mpoly_ctx_t ctx) + void fq_nmod_mpoly_get_term_exp_si(slong * exp, const fq_nmod_mpoly_t A, slong i, const fq_nmod_mpoly_ctx_t ctx) # Set *exp* to the exponent vector of the term of index *i*. # The ``_ui`` (resp. ``_si``) version throws if any entry does not fit into a ``ulong`` (resp. ``slong``). - unsigned long fq_nmod_mpoly_get_term_var_exp_ui(const fq_nmod_mpoly_t A, long i, long var, const fq_nmod_mpoly_ctx_t ctx) - long fq_nmod_mpoly_get_term_var_exp_si(const fq_nmod_mpoly_t A, long i, long var, const fq_nmod_mpoly_ctx_t ctx) + ulong fq_nmod_mpoly_get_term_var_exp_ui(const fq_nmod_mpoly_t A, slong i, slong var, const fq_nmod_mpoly_ctx_t ctx) + slong fq_nmod_mpoly_get_term_var_exp_si(const fq_nmod_mpoly_t A, slong i, slong var, const fq_nmod_mpoly_ctx_t ctx) # Return the exponent of the variable *var* of the term of index *i*. # This function throws if the exponent does not fit into a ``ulong`` (resp. ``slong``). - void fq_nmod_mpoly_set_term_exp_fmpz(fq_nmod_mpoly_t A, long i, fmpz * const * exp, const fq_nmod_mpoly_ctx_t ctx) - void fq_nmod_mpoly_set_term_exp_ui(fq_nmod_mpoly_t A, long i, const unsigned long * exp, const fq_nmod_mpoly_ctx_t ctx) + void fq_nmod_mpoly_set_term_exp_fmpz(fq_nmod_mpoly_t A, slong i, fmpz * const * exp, const fq_nmod_mpoly_ctx_t ctx) + void fq_nmod_mpoly_set_term_exp_ui(fq_nmod_mpoly_t A, slong i, const ulong * exp, const fq_nmod_mpoly_ctx_t ctx) # Set the exponent of the term of index *i* to *exp*. - void fq_nmod_mpoly_get_term(fq_nmod_mpoly_t M, const fq_nmod_mpoly_t A, long i, const fq_nmod_mpoly_ctx_t ctx) + void fq_nmod_mpoly_get_term(fq_nmod_mpoly_t M, const fq_nmod_mpoly_t A, slong i, const fq_nmod_mpoly_ctx_t ctx) # Set *M* to the term of index *i* in *A*. - void fq_nmod_mpoly_get_term_monomial(fq_nmod_mpoly_t M, const fq_nmod_mpoly_t A, long i, const fq_nmod_mpoly_ctx_t ctx) + void fq_nmod_mpoly_get_term_monomial(fq_nmod_mpoly_t M, const fq_nmod_mpoly_t A, slong i, const fq_nmod_mpoly_ctx_t ctx) # Set *M* to the monomial of the term of index *i* in *A*. The coefficient of *M* will be one. void fq_nmod_mpoly_push_term_fq_nmod_fmpz(fq_nmod_mpoly_t A, const fq_nmod_t c, fmpz * const * exp, const fq_nmod_mpoly_ctx_t ctx) void fq_nmod_mpoly_push_term_fq_nmod_ffmpz(fq_nmod_mpoly_t A, const fq_nmod_t c, const fmpz * exp, const fq_nmod_mpoly_ctx_t ctx) - void fq_nmod_mpoly_push_term_fq_nmod_ui(fq_nmod_mpoly_t A, const fq_nmod_t c, const unsigned long * exp, const fq_nmod_mpoly_ctx_t ctx) + void fq_nmod_mpoly_push_term_fq_nmod_ui(fq_nmod_mpoly_t A, const fq_nmod_t c, const ulong * exp, const fq_nmod_mpoly_ctx_t ctx) # Append a term to *A* with coefficient *c* and exponent vector *exp*. # This function runs in constant average time. @@ -217,15 +217,15 @@ cdef extern from "flint_wrap.h": void fq_nmod_mpoly_reverse(fq_nmod_mpoly_t A, const fq_nmod_mpoly_t B, const fq_nmod_mpoly_ctx_t ctx) # Set *A* to the reversal of *B*. - void fq_nmod_mpoly_randtest_bound(fq_nmod_mpoly_t A, flint_rand_t state, long length, unsigned long exp_bound, const fq_nmod_mpoly_ctx_t ctx) + void fq_nmod_mpoly_randtest_bound(fq_nmod_mpoly_t A, flint_rand_t state, slong length, ulong exp_bound, const fq_nmod_mpoly_ctx_t ctx) # Generate a random polynomial with length up to *length* and exponents in the range ``[0, exp_bound - 1]``. # The exponents of each variable are generated by calls to ``n_randint(state, exp_bound)``. - void fq_nmod_mpoly_randtest_bounds(fq_nmod_mpoly_t A, flint_rand_t state, long length, unsigned long *exp_bounds, const fq_nmod_mpoly_ctx_t ctx) + void fq_nmod_mpoly_randtest_bounds(fq_nmod_mpoly_t A, flint_rand_t state, slong length, ulong *exp_bounds, const fq_nmod_mpoly_ctx_t ctx) # Generate a random polynomial with length up to *length* and exponents in the range ``[0, exp_bounds[i] - 1]``. # The exponents of the variable of index *i* are generated by calls to ``n_randint(state, exp_bounds[i])``. - void fq_nmod_mpoly_randtest_bits(fq_nmod_mpoly_t A, flint_rand_t state, long length, mp_limb_t exp_bits, const fq_nmod_mpoly_ctx_t ctx) + void fq_nmod_mpoly_randtest_bits(fq_nmod_mpoly_t A, flint_rand_t state, slong length, mp_limb_t exp_bits, const fq_nmod_mpoly_ctx_t ctx) # Generate a random polynomial with length up to *length* and exponents whose packed form does not exceed the given bit count. void fq_nmod_mpoly_add_fq_nmod(fq_nmod_mpoly_t A, const fq_nmod_mpoly_t B, const fq_nmod_t C, const fq_nmod_mpoly_ctx_t ctx) @@ -250,13 +250,13 @@ cdef extern from "flint_wrap.h": # Set *A* to *B* divided by the leading coefficient of *B*. # This throws if *B* is zero. - void fq_nmod_mpoly_derivative(fq_nmod_mpoly_t A, const fq_nmod_mpoly_t B, long var, const fq_nmod_mpoly_ctx_t ctx) + void fq_nmod_mpoly_derivative(fq_nmod_mpoly_t A, const fq_nmod_mpoly_t B, slong var, const fq_nmod_mpoly_ctx_t ctx) # Set *A* to the derivative of *B* with respect to the variable of index *var*. void fq_nmod_mpoly_evaluate_all_fq_nmod(fq_nmod_t ev, const fq_nmod_mpoly_t A, fq_nmod_struct * const * vals, const fq_nmod_mpoly_ctx_t ctx) # Set *ev* the evaluation of *A* where the variables are replaced by the corresponding elements of the array *vals*. - void fq_nmod_mpoly_evaluate_one_fq_nmod(fq_nmod_mpoly_t A, const fq_nmod_mpoly_t B, long var, const fq_nmod_t val, const fq_nmod_mpoly_ctx_t ctx) + void fq_nmod_mpoly_evaluate_one_fq_nmod(fq_nmod_mpoly_t A, const fq_nmod_mpoly_t B, slong var, const fq_nmod_t val, const fq_nmod_mpoly_ctx_t ctx) # Set *A* to the evaluation of *B* where the variable of index *var* is replaced by *val*. int fq_nmod_mpoly_compose_fq_nmod_poly(fq_nmod_poly_t A, const fq_nmod_mpoly_t B, fq_nmod_poly_struct * const * C, const fq_nmod_mpoly_ctx_t ctx) @@ -270,7 +270,7 @@ cdef extern from "flint_wrap.h": # Neither *A* nor *B* is allowed to alias any other polynomial. # Return `1` for success and `0` for failure. - void fq_nmod_mpoly_compose_fq_nmod_mpoly_gen(fq_nmod_mpoly_t A, const fq_nmod_mpoly_t B, const long * c, const fq_nmod_mpoly_ctx_t ctxB, const fq_nmod_mpoly_ctx_t ctxAC) + void fq_nmod_mpoly_compose_fq_nmod_mpoly_gen(fq_nmod_mpoly_t A, const fq_nmod_mpoly_t B, const slong * c, const fq_nmod_mpoly_ctx_t ctxB, const fq_nmod_mpoly_ctx_t ctxAC) # Set *A* to the evaluation of *B* where the variable of index *i* in *ctxB* is replaced by the variable of index ``c[i]`` in *ctxAC*. # The length of the array *C* is the number of variables in *ctxB*. # If any ``c[i]`` is negative, the corresponding variable of *B* is replaced by zero. Otherwise, it is expected that ``c[i]`` is less than the number of variables in *ctxAC*. @@ -282,7 +282,7 @@ cdef extern from "flint_wrap.h": # Set *A* to `B` raised to the *k*-th power. # Return `1` for success and `0` for failure. - int fq_nmod_mpoly_pow_ui(fq_nmod_mpoly_t A, const fq_nmod_mpoly_t B, unsigned long k, const fq_nmod_mpoly_ctx_t ctx) + int fq_nmod_mpoly_pow_ui(fq_nmod_mpoly_t A, const fq_nmod_mpoly_t B, ulong k, const fq_nmod_mpoly_ctx_t ctx) # Set *A* to `B` raised to the *k*-th power. # Return `1` for success and `0` for failure. @@ -295,7 +295,7 @@ cdef extern from "flint_wrap.h": void fq_nmod_mpoly_divrem(fq_nmod_mpoly_t Q, fq_nmod_mpoly_t R, const fq_nmod_mpoly_t A, const fq_nmod_mpoly_t B, const fq_nmod_mpoly_ctx_t ctx) # Set *Q* and *R* to the quotient and remainder of *A* divided by *B*. - void fq_nmod_mpoly_divrem_ideal(fq_nmod_mpoly_struct ** Q, fq_nmod_mpoly_t R, const fq_nmod_mpoly_t A, fq_nmod_mpoly_struct * const * B, long len, const fq_nmod_mpoly_ctx_t ctx) + void fq_nmod_mpoly_divrem_ideal(fq_nmod_mpoly_struct ** Q, fq_nmod_mpoly_t R, const fq_nmod_mpoly_t A, fq_nmod_mpoly_struct * const * B, slong len, const fq_nmod_mpoly_ctx_t ctx) # This function is as per :func:`fq_nmod_mpoly_divrem` except that it takes an array of divisor polynomials *B* and it returns an array of quotient polynomials *Q*. # The number of divisor (and hence quotient) polynomials, is given by *len*. @@ -303,7 +303,7 @@ cdef extern from "flint_wrap.h": # Set *M* to the GCD of the terms of *A*. # If *A* is zero, *M* will be zero. Otherwise, *M* will be a monomial with coefficient one. - int fq_nmod_mpoly_content_vars(fq_nmod_mpoly_t g, const fq_nmod_mpoly_t A, long * vars, long vars_length, const fq_nmod_mpoly_ctx_t ctx) + int fq_nmod_mpoly_content_vars(fq_nmod_mpoly_t g, const fq_nmod_mpoly_t A, slong * vars, slong vars_length, const fq_nmod_mpoly_ctx_t ctx) # Set *g* to the GCD of the coefficients of *A* when viewed as a polynomial in the variables *vars*. # Return `1` for success and `0` for failure. Upon success, *g* will be independent of the variables *vars*. @@ -319,10 +319,10 @@ cdef extern from "flint_wrap.h": int fq_nmod_mpoly_gcd_zippel(fq_nmod_mpoly_t G, const fq_nmod_mpoly_t A, const fq_nmod_mpoly_t B, const fq_nmod_mpoly_ctx_t ctx) # Try to set *G* to the GCD of *A* and *B* using various algorithms. - int fq_nmod_mpoly_resultant(fq_nmod_mpoly_t R, const fq_nmod_mpoly_t A, const fq_nmod_mpoly_t B, long var, const fq_nmod_mpoly_ctx_t ctx) + int fq_nmod_mpoly_resultant(fq_nmod_mpoly_t R, const fq_nmod_mpoly_t A, const fq_nmod_mpoly_t B, slong var, const fq_nmod_mpoly_ctx_t ctx) # Try to set *R* to the resultant of *A* and *B* with respect to the variable of index *var*. - int fq_nmod_mpoly_discriminant(fq_nmod_mpoly_t D, const fq_nmod_mpoly_t A, long var, const fq_nmod_mpoly_ctx_t ctx) + int fq_nmod_mpoly_discriminant(fq_nmod_mpoly_t D, const fq_nmod_mpoly_t A, slong var, const fq_nmod_mpoly_ctx_t ctx) # Try to set *D* to the discriminant of *A* with respect to the variable of index *var*. int fq_nmod_mpoly_sqrt(fq_nmod_mpoly_t Q, const fq_nmod_mpoly_t A, const fq_nmod_mpoly_ctx_t ctx) @@ -343,23 +343,23 @@ cdef extern from "flint_wrap.h": void fq_nmod_mpoly_univar_swap(fq_nmod_mpoly_univar_t A, fq_nmod_mpoly_univar_t B, const fq_nmod_mpoly_ctx_t ctx) # Swap *A* and `B`. - void fq_nmod_mpoly_to_univar(fq_nmod_mpoly_univar_t A, const fq_nmod_mpoly_t B, long var, const fq_nmod_mpoly_ctx_t ctx) + void fq_nmod_mpoly_to_univar(fq_nmod_mpoly_univar_t A, const fq_nmod_mpoly_t B, slong var, const fq_nmod_mpoly_ctx_t ctx) # Set *A* to a univariate form of *B* by pulling out the variable of index *var*. # The coefficients of *A* will still belong to the content *ctx* but will not depend on the variable of index *var*. - void fq_nmod_mpoly_from_univar(fq_nmod_mpoly_t A, const fq_nmod_mpoly_univar_t B, long var, const fq_nmod_mpoly_ctx_t ctx) + void fq_nmod_mpoly_from_univar(fq_nmod_mpoly_t A, const fq_nmod_mpoly_univar_t B, slong var, const fq_nmod_mpoly_ctx_t ctx) # Set *A* to the normal form of *B* by putting in the variable of index *var*. # This function is undefined if the coefficients of *B* depend on the variable of index *var*. int fq_nmod_mpoly_univar_degree_fits_si(const fq_nmod_mpoly_univar_t A, const fq_nmod_mpoly_ctx_t ctx) # Return `1` if the degree of *A* with respect to the main variable fits an ``slong``. Otherwise, return `0`. - long fq_nmod_mpoly_univar_length(const fq_nmod_mpoly_univar_t A, const fq_nmod_mpoly_ctx_t ctx) + slong fq_nmod_mpoly_univar_length(const fq_nmod_mpoly_univar_t A, const fq_nmod_mpoly_ctx_t ctx) # Return the number of terms in *A* with respect to the main variable. - long fq_nmod_mpoly_univar_get_term_exp_si(fq_nmod_mpoly_univar_t A, long i, const fq_nmod_mpoly_ctx_t ctx) + slong fq_nmod_mpoly_univar_get_term_exp_si(fq_nmod_mpoly_univar_t A, slong i, const fq_nmod_mpoly_ctx_t ctx) # Return the exponent of the term of index *i* of *A*. - void fq_nmod_mpoly_univar_get_term_coeff(fq_nmod_mpoly_t c, const fq_nmod_mpoly_univar_t A, long i, const fq_nmod_mpoly_ctx_t ctx) - void fq_nmod_mpoly_univar_swap_term_coeff(fq_nmod_mpoly_t c, fq_nmod_mpoly_univar_t A, long i, const fq_nmod_mpoly_ctx_t ctx) + void fq_nmod_mpoly_univar_get_term_coeff(fq_nmod_mpoly_t c, const fq_nmod_mpoly_univar_t A, slong i, const fq_nmod_mpoly_ctx_t ctx) + void fq_nmod_mpoly_univar_swap_term_coeff(fq_nmod_mpoly_t c, fq_nmod_mpoly_univar_t A, slong i, const fq_nmod_mpoly_ctx_t ctx) # Set (resp. swap) *c* to (resp. with) the coefficient of the term of index *i* of *A*. diff --git a/src/sage/libs/flint/fq_nmod_mpoly_factor.pxd b/src/sage/libs/flint/fq_nmod_mpoly_factor.pxd index a1ad523dede..f6564bc10ed 100644 --- a/src/sage/libs/flint/fq_nmod_mpoly_factor.pxd +++ b/src/sage/libs/flint/fq_nmod_mpoly_factor.pxd @@ -21,17 +21,17 @@ cdef extern from "flint_wrap.h": void fq_nmod_mpoly_factor_swap(fq_nmod_mpoly_factor_t f, fq_nmod_mpoly_factor_t g, const fq_nmod_mpoly_ctx_t ctx) # Efficiently swap *f* and *g*. - long fq_nmod_mpoly_factor_length(const fq_nmod_mpoly_factor_t f, const fq_nmod_mpoly_ctx_t ctx) + slong fq_nmod_mpoly_factor_length(const fq_nmod_mpoly_factor_t f, const fq_nmod_mpoly_ctx_t ctx) # Return the length of the product in *f*. void fq_nmod_mpoly_factor_get_constant_fq_nmod(fq_nmod_t c, const fq_nmod_mpoly_factor_t f, const fq_nmod_mpoly_ctx_t ctx) # Set `c` to the constant of *f*. - void fq_nmod_mpoly_factor_get_base(fq_nmod_mpoly_t p, const fq_nmod_mpoly_factor_t f, long i, const fq_nmod_mpoly_ctx_t ctx) - void fq_nmod_mpoly_factor_swap_base(fq_nmod_mpoly_t p, const fq_nmod_mpoly_factor_t f, long i, const fq_nmod_mpoly_ctx_t ctx) + void fq_nmod_mpoly_factor_get_base(fq_nmod_mpoly_t p, const fq_nmod_mpoly_factor_t f, slong i, const fq_nmod_mpoly_ctx_t ctx) + void fq_nmod_mpoly_factor_swap_base(fq_nmod_mpoly_t p, const fq_nmod_mpoly_factor_t f, slong i, const fq_nmod_mpoly_ctx_t ctx) # Set (resp. swap) *B* to (resp. with) the base of the term of index *i* in *A*. - long fq_nmod_mpoly_factor_get_exp_si(fq_nmod_mpoly_factor_t f, long i, const fq_nmod_mpoly_ctx_t ctx) + slong fq_nmod_mpoly_factor_get_exp_si(fq_nmod_mpoly_factor_t f, slong i, const fq_nmod_mpoly_ctx_t ctx) # Return the exponent of the term of index *i* in *A*. It is assumed to fit an ``slong``. void fq_nmod_mpoly_factor_sort(fq_nmod_mpoly_factor_t f, const fq_nmod_mpoly_ctx_t ctx) diff --git a/src/sage/libs/flint/fq_nmod_poly.pxd b/src/sage/libs/flint/fq_nmod_poly.pxd index b6ec5c6788f..d5b0fe2c72f 100644 --- a/src/sage/libs/flint/fq_nmod_poly.pxd +++ b/src/sage/libs/flint/fq_nmod_poly.pxd @@ -18,21 +18,21 @@ cdef extern from "flint_wrap.h": # must be made after finishing with the ``fq_nmod_poly_t`` to free the # memory used by the polynomial. - void fq_nmod_poly_init2(fq_nmod_poly_t poly, long alloc, const fq_nmod_ctx_t ctx) + void fq_nmod_poly_init2(fq_nmod_poly_t poly, slong alloc, const fq_nmod_ctx_t ctx) # Initialises ``poly`` with space for at least ``alloc`` # coefficients and sets the length to zero. The allocated # coefficients are all set to zero. A corresponding call to # :func:`fq_nmod_poly_clear` must be made after finishing with the # ``fq_nmod_poly_t`` to free the memory used by the polynomial. - void fq_nmod_poly_realloc(fq_nmod_poly_t poly, long alloc, const fq_nmod_ctx_t ctx) + void fq_nmod_poly_realloc(fq_nmod_poly_t poly, slong alloc, const fq_nmod_ctx_t ctx) # Reallocates the given polynomial to have space for ``alloc`` # coefficients. If ``alloc`` is zero the polynomial is cleared # and then reinitialised. If the current length is greater than # ``alloc`` the polynomial is first truncated to length # ``alloc``. - void fq_nmod_poly_fit_length(fq_nmod_poly_t poly, long len, const fq_nmod_ctx_t ctx) + void fq_nmod_poly_fit_length(fq_nmod_poly_t poly, slong len, const fq_nmod_ctx_t ctx) # If ``len`` is greater than the number of coefficients currently # allocated, then the polynomial is reallocated to have space for at # least ``len`` coefficients. No data is lost when calling this @@ -42,7 +42,7 @@ cdef extern from "flint_wrap.h": # least doubling the number of allocated coefficients when length is # larger than the number of coefficients currently allocated. - void _fq_nmod_poly_set_length(fq_nmod_poly_t poly, long newlen, const fq_nmod_ctx_t ctx) + void _fq_nmod_poly_set_length(fq_nmod_poly_t poly, slong newlen, const fq_nmod_ctx_t ctx) # Sets the coefficients of ``poly`` beyond ``len`` to zero and # sets the length of ``poly`` to ``len``. @@ -56,19 +56,19 @@ cdef extern from "flint_wrap.h": # zero. This function is mainly used internally, as all functions # guarantee normalisation. - void _fq_nmod_poly_normalise2(const fq_nmod_struct *poly, long *length, const fq_nmod_ctx_t ctx) + void _fq_nmod_poly_normalise2(const fq_nmod_struct *poly, slong *length, const fq_nmod_ctx_t ctx) # Sets the length ``length`` of ``(poly,length)`` so that the # top coefficient is non-zero. If all coefficients are zero, the # length is set to zero. This function is mainly used internally, as # all functions guarantee normalisation. - void fq_nmod_poly_truncate(fq_nmod_poly_t poly, long newlen, const fq_nmod_ctx_t ctx) + void fq_nmod_poly_truncate(fq_nmod_poly_t poly, slong newlen, const fq_nmod_ctx_t ctx) # Truncates the polynomial to length at most ``n``. - void fq_nmod_poly_set_trunc(fq_nmod_poly_t poly1, fq_nmod_poly_t poly2, long newlen, const fq_nmod_ctx_t ctx) + void fq_nmod_poly_set_trunc(fq_nmod_poly_t poly1, fq_nmod_poly_t poly2, slong newlen, const fq_nmod_ctx_t ctx) # Sets ``poly1`` to ``poly2`` truncated to length `n`. - void _fq_nmod_poly_reverse(fq_nmod_struct* output, const fq_nmod_struct* input, long len, long m, const fq_nmod_ctx_t ctx) + void _fq_nmod_poly_reverse(fq_nmod_struct* output, const fq_nmod_struct* input, slong len, slong m, const fq_nmod_ctx_t ctx) # Sets ``output`` to the reverse of ``input``, which is of # length ``len``, but thinking of it as a polynomial of # length ``m``, notionally zero-padded if necessary. The @@ -76,40 +76,40 @@ cdef extern from "flint_wrap.h": # restrictions. The polynomial ``output`` must have space for # ``m`` coefficients. - void fq_nmod_poly_reverse(fq_nmod_poly_t output, const fq_nmod_poly_t input, long m, const fq_nmod_ctx_t ctx) + void fq_nmod_poly_reverse(fq_nmod_poly_t output, const fq_nmod_poly_t input, slong m, const fq_nmod_ctx_t ctx) # Sets ``output`` to the reverse of ``input``, thinking of it # as a polynomial of length ``m``, notionally zero-padded if # necessary). The length ``m`` must be non-negative, but there # are no other restrictions. The output polynomial will be set to # length ``m`` and then normalised. - long fq_nmod_poly_degree(const fq_nmod_poly_t poly, const fq_nmod_ctx_t ctx) + slong fq_nmod_poly_degree(const fq_nmod_poly_t poly, const fq_nmod_ctx_t ctx) # Returns the degree of the polynomial ``poly``. - long fq_nmod_poly_length(const fq_nmod_poly_t poly, const fq_nmod_ctx_t ctx) + slong fq_nmod_poly_length(const fq_nmod_poly_t poly, const fq_nmod_ctx_t ctx) # Returns the length of the polynomial ``poly``. fq_nmod_struct * fq_nmod_poly_lead(const fq_nmod_poly_t poly, const fq_nmod_ctx_t ctx) # Returns a pointer to the leading coefficient of ``poly``, or # ``NULL`` if ``poly`` is the zero polynomial. - void fq_nmod_poly_randtest(fq_nmod_poly_t f, flint_rand_t state, long len, const fq_nmod_ctx_t ctx) + void fq_nmod_poly_randtest(fq_nmod_poly_t f, flint_rand_t state, slong len, const fq_nmod_ctx_t ctx) # Sets `f` to a random polynomial of length at most ``len`` # with entries in the field described by ``ctx``. - void fq_nmod_poly_randtest_not_zero(fq_nmod_poly_t f, flint_rand_t state, long len, const fq_nmod_ctx_t ctx) + void fq_nmod_poly_randtest_not_zero(fq_nmod_poly_t f, flint_rand_t state, slong len, const fq_nmod_ctx_t ctx) # Same as ``fq_nmod_poly_randtest`` but guarantees that the polynomial # is not zero. - void fq_nmod_poly_randtest_monic(fq_nmod_poly_t f, flint_rand_t state, long len, const fq_nmod_ctx_t ctx) + void fq_nmod_poly_randtest_monic(fq_nmod_poly_t f, flint_rand_t state, slong len, const fq_nmod_ctx_t ctx) # Sets `f` to a random monic polynomial of length ``len`` with # entries in the field described by ``ctx``. - void fq_nmod_poly_randtest_irreducible(fq_nmod_poly_t f, flint_rand_t state, long len, const fq_nmod_ctx_t ctx) + void fq_nmod_poly_randtest_irreducible(fq_nmod_poly_t f, flint_rand_t state, slong len, const fq_nmod_ctx_t ctx) # Sets `f` to a random monic, irreducible polynomial of length # ``len`` with entries in the field described by ``ctx``. - void _fq_nmod_poly_set(fq_nmod_struct *rop, const fq_nmod_struct *op, long len, const fq_nmod_ctx_t ctx) + void _fq_nmod_poly_set(fq_nmod_struct *rop, const fq_nmod_struct *op, slong len, const fq_nmod_ctx_t ctx) # Sets ``(rop, len``) to ``(op, len)``. void fq_nmod_poly_set(fq_nmod_poly_t poly1, const fq_nmod_poly_t poly2, const fq_nmod_ctx_t ctx) @@ -127,7 +127,7 @@ cdef extern from "flint_wrap.h": void fq_nmod_poly_swap(fq_nmod_poly_t op1, fq_nmod_poly_t op2, const fq_nmod_ctx_t ctx) # Swaps the two polynomials ``op1`` and ``op2``. - void _fq_nmod_poly_zero(fq_nmod_struct *rop, long len, const fq_nmod_ctx_t ctx) + void _fq_nmod_poly_zero(fq_nmod_struct *rop, slong len, const fq_nmod_ctx_t ctx) # Sets ``(rop, len)`` to the zero polynomial. void fq_nmod_poly_zero(fq_nmod_poly_t poly, const fq_nmod_ctx_t ctx) @@ -142,18 +142,18 @@ cdef extern from "flint_wrap.h": void fq_nmod_poly_make_monic(fq_nmod_poly_t rop, const fq_nmod_poly_t op, const fq_nmod_ctx_t ctx) # Sets ``rop`` to ``op``, normed to have leading coefficient 1. - void _fq_nmod_poly_make_monic(fq_nmod_struct *rop, const fq_nmod_struct *op, long length, const fq_nmod_ctx_t ctx) + void _fq_nmod_poly_make_monic(fq_nmod_struct *rop, const fq_nmod_struct *op, slong length, const fq_nmod_ctx_t ctx) # Sets ``rop`` to ``(op,length)``, normed to have leading coefficient 1. # Assumes that ``rop`` has enough space for the polynomial, assumes that # ``op`` is not zero (and thus has an invertible leading coefficient). - void fq_nmod_poly_get_coeff(fq_nmod_t x, const fq_nmod_poly_t poly, long n, const fq_nmod_ctx_t ctx) + void fq_nmod_poly_get_coeff(fq_nmod_t x, const fq_nmod_poly_t poly, slong n, const fq_nmod_ctx_t ctx) # Sets `x` to the coefficient of `X^n` in ``poly``. - void fq_nmod_poly_set_coeff(fq_nmod_poly_t poly, long n, const fq_nmod_t x, const fq_nmod_ctx_t ctx) + void fq_nmod_poly_set_coeff(fq_nmod_poly_t poly, slong n, const fq_nmod_t x, const fq_nmod_ctx_t ctx) # Sets the coefficient of `X^n` in ``poly`` to `x`. - void fq_nmod_poly_set_coeff_fmpz(fq_nmod_poly_t poly, long n, const fmpz_t x, const fq_nmod_ctx_t ctx) + void fq_nmod_poly_set_coeff_fmpz(fq_nmod_poly_t poly, slong n, const fmpz_t x, const fq_nmod_ctx_t ctx) # Sets the coefficient of `X^n` in the polynomial to `x`, # assuming `n \geq 0`. @@ -161,7 +161,7 @@ cdef extern from "flint_wrap.h": # Returns nonzero if the two polynomials ``poly1`` and ``poly2`` # are equal, otherwise return zero. - int fq_nmod_poly_equal_trunc(const fq_nmod_poly_t poly1, const fq_nmod_poly_t poly2, long n, const fq_nmod_ctx_t ctx) + int fq_nmod_poly_equal_trunc(const fq_nmod_poly_t poly1, const fq_nmod_poly_t poly2, slong n, const fq_nmod_ctx_t ctx) # Notionally truncate ``poly1`` and ``poly2`` to length `n` and # return nonzero if they are equal, otherwise return zero. @@ -184,37 +184,37 @@ cdef extern from "flint_wrap.h": # Returns whether the polynomial ``poly`` is equal the (constant) # `\mathbf{F}_q` element ``c`` - void _fq_nmod_poly_add(fq_nmod_struct *res, const fq_nmod_struct *poly1, long len1, const fq_nmod_struct *poly2, long len2, const fq_nmod_ctx_t ctx) + void _fq_nmod_poly_add(fq_nmod_struct *res, const fq_nmod_struct *poly1, slong len1, const fq_nmod_struct *poly2, slong len2, const fq_nmod_ctx_t ctx) # Sets ``res`` to the sum of ``(poly1,len1)`` and ``(poly2,len2)``. void fq_nmod_poly_add(fq_nmod_poly_t res, const fq_nmod_poly_t poly1, const fq_nmod_poly_t poly2, const fq_nmod_ctx_t ctx) # Sets ``res`` to the sum of ``poly1`` and ``poly2``. - void fq_nmod_poly_add_si(fq_nmod_poly_t res, const fq_nmod_poly_t poly1, long c, const fq_nmod_ctx_t ctx) + void fq_nmod_poly_add_si(fq_nmod_poly_t res, const fq_nmod_poly_t poly1, slong c, const fq_nmod_ctx_t ctx) # Sets ``res`` to the sum of ``poly1`` and ``c``. - void fq_nmod_poly_add_series(fq_nmod_poly_t res, const fq_nmod_poly_t poly1, const fq_nmod_poly_t poly2, long n, const fq_nmod_ctx_t ctx) + void fq_nmod_poly_add_series(fq_nmod_poly_t res, const fq_nmod_poly_t poly1, const fq_nmod_poly_t poly2, slong n, const fq_nmod_ctx_t ctx) # Notionally truncate ``poly1`` and ``poly2`` to length ``n`` and set # ``res`` to the sum. - void _fq_nmod_poly_sub(fq_nmod_struct *res, const fq_nmod_struct *poly1, long len1, const fq_nmod_struct *poly2, long len2, const fq_nmod_ctx_t ctx) + void _fq_nmod_poly_sub(fq_nmod_struct *res, const fq_nmod_struct *poly1, slong len1, const fq_nmod_struct *poly2, slong len2, const fq_nmod_ctx_t ctx) # Sets ``res`` to the difference of ``(poly1,len1)`` and # ``(poly2,len2)``. void fq_nmod_poly_sub(fq_nmod_poly_t res, const fq_nmod_poly_t poly1, const fq_nmod_poly_t poly2, const fq_nmod_ctx_t ctx) # Sets ``res`` to the difference of ``poly1`` and ``poly2``. - void fq_nmod_poly_sub_series(fq_nmod_poly_t res, const fq_nmod_poly_t poly1, const fq_nmod_poly_t poly2, long n, const fq_nmod_ctx_t ctx) + void fq_nmod_poly_sub_series(fq_nmod_poly_t res, const fq_nmod_poly_t poly1, const fq_nmod_poly_t poly2, slong n, const fq_nmod_ctx_t ctx) # Notionally truncate ``poly1`` and ``poly2`` to length ``n`` and set # ``res`` to the difference. - void _fq_nmod_poly_neg(fq_nmod_struct *rop, const fq_nmod_struct *op, long len, const fq_nmod_ctx_t ctx) + void _fq_nmod_poly_neg(fq_nmod_struct *rop, const fq_nmod_struct *op, slong len, const fq_nmod_ctx_t ctx) # Sets ``rop`` to the additive inverse of ``(poly,len)``. void fq_nmod_poly_neg(fq_nmod_poly_t res, const fq_nmod_poly_t poly, const fq_nmod_ctx_t ctx) # Sets ``res`` to the additive inverse of ``poly``. - void _fq_nmod_poly_scalar_mul_fq_nmod(fq_nmod_struct *rop, const fq_nmod_struct *op, long len, const fq_nmod_t x, const fq_nmod_ctx_t ctx) + void _fq_nmod_poly_scalar_mul_fq_nmod(fq_nmod_struct *rop, const fq_nmod_struct *op, slong len, const fq_nmod_t x, const fq_nmod_ctx_t ctx) # Sets ``(rop,len)`` to the product of ``(op,len)`` by the # scalar ``x``, in the context defined by ``ctx``. @@ -222,7 +222,7 @@ cdef extern from "flint_wrap.h": # Sets ``rop`` to the product of ``op`` by the scalar ``x``, in the context # defined by ``ctx``. - void _fq_nmod_poly_scalar_addmul_fq_nmod(fq_nmod_struct *rop, const fq_nmod_struct *op, long len, const fq_nmod_t x, const fq_nmod_ctx_t ctx) + void _fq_nmod_poly_scalar_addmul_fq_nmod(fq_nmod_struct *rop, const fq_nmod_struct *op, slong len, const fq_nmod_t x, const fq_nmod_ctx_t ctx) # Adds to ``(rop,len)`` the product of ``(op,len)`` by the # scalar ``x``, in the context defined by ``ctx``. # In particular, assumes the same length for ``op`` and @@ -232,7 +232,7 @@ cdef extern from "flint_wrap.h": # Adds to ``rop`` the product of ``op`` by the # scalar ``x``, in the context defined by ``ctx``. - void _fq_nmod_poly_scalar_submul_fq_nmod(fq_nmod_struct *rop, const fq_nmod_struct *op, long len, const fq_nmod_t x, const fq_nmod_ctx_t ctx) + void _fq_nmod_poly_scalar_submul_fq_nmod(fq_nmod_struct *rop, const fq_nmod_struct *op, slong len, const fq_nmod_t x, const fq_nmod_ctx_t ctx) # Subtracts from ``(rop,len)`` the product of ``(op,len)`` by the # scalar ``x``, in the context defined by ``ctx``. # In particular, assumes the same length for ``op`` and @@ -242,7 +242,7 @@ cdef extern from "flint_wrap.h": # Subtracts from ``rop`` the product of ``op`` by the # scalar ``x``, in the context defined by ``ctx``. - void _fq_nmod_poly_scalar_div_fq(fq_nmod_struct *rop, const fq_nmod_struct *op, long len, const fq_nmod_t x, const fq_nmod_ctx_t ctx) + void _fq_nmod_poly_scalar_div_fq(fq_nmod_struct *rop, const fq_nmod_struct *op, slong len, const fq_nmod_t x, const fq_nmod_ctx_t ctx) # Sets ``(rop,len)`` to the quotient of ``(op,len)`` by the # scalar ``x``, in the context defined by ``ctx``. An exception is raised # if ``x`` is zero. @@ -251,7 +251,7 @@ cdef extern from "flint_wrap.h": # Sets ``rop`` to the quotient of ``op`` by the scalar ``x``, in the context # defined by ``ctx``. An exception is raised if ``x`` is zero. - void _fq_nmod_poly_mul_classical(fq_nmod_struct *rop, const fq_nmod_struct *op1, long len1, const fq_nmod_struct *op2, long len2, const fq_nmod_ctx_t ctx) + void _fq_nmod_poly_mul_classical(fq_nmod_struct *rop, const fq_nmod_struct *op1, slong len1, const fq_nmod_struct *op2, slong len2, const fq_nmod_ctx_t ctx) # Sets ``(rop, len1 + len2 - 1)`` to the product of ``(op1, len1)`` # and ``(op2, len2)``, assuming that ``len1`` is at least ``len2`` # and neither is zero. @@ -262,7 +262,7 @@ cdef extern from "flint_wrap.h": # Sets ``rop`` to the product of ``op1`` and ``op2`` # using classical polynomial multiplication. - void _fq_nmod_poly_mul_reorder(fq_nmod_struct *rop, const fq_nmod_struct *op1, long len1, const fq_nmod_struct *op2, long len2, const fq_nmod_ctx_t ctx) + void _fq_nmod_poly_mul_reorder(fq_nmod_struct *rop, const fq_nmod_struct *op1, slong len1, const fq_nmod_struct *op2, slong len2, const fq_nmod_ctx_t ctx) # Sets ``(rop, len1 + len2 - 1)`` to the product of ``(op1, len1)`` # and ``(op2, len2)``, assuming that ``len1`` and ``len2`` are # non-zero. @@ -287,7 +287,7 @@ cdef extern from "flint_wrap.h": # multiplication routines in the `Y`-direction where the polynomial # degree `n` is large. - void _fq_nmod_poly_mul_univariate(fq_nmod_struct *rop, const fq_nmod_struct *op1, long len1, const fq_nmod_struct *op2, long len2, const fq_nmod_ctx_t ctx) + void _fq_nmod_poly_mul_univariate(fq_nmod_struct *rop, const fq_nmod_struct *op1, slong len1, const fq_nmod_struct *op2, slong len2, const fq_nmod_ctx_t ctx) # Sets ``(rop, len1 + len2 - 1)`` to the product of ``(op1, len1)`` # and ``(op2, len2)``. # Permits zero padding and makes no assumptions on ``len1`` and ``len2``. @@ -298,7 +298,7 @@ cdef extern from "flint_wrap.h": # using a bivariate to univariate transformation and reducing # this problem to multiplying two univariate polynomials. - void _fq_nmod_poly_mul_KS(fq_nmod_struct *rop, const fq_nmod_struct *op1, long len1, const fq_nmod_struct *op2, long len2, const fq_nmod_ctx_t ctx) + void _fq_nmod_poly_mul_KS(fq_nmod_struct *rop, const fq_nmod_struct *op1, slong len1, const fq_nmod_struct *op2, slong len2, const fq_nmod_ctx_t ctx) # Sets ``(rop, len1 + len2 - 1)`` to the product of ``(op1, len1)`` # and ``(op2, len2)``. # Permits zero padding and places no assumptions on the @@ -310,7 +310,7 @@ cdef extern from "flint_wrap.h": # coefficient in `\mathbf{F}_{q}` as an integer and reducing # this problem to multiplying two polynomials over the integers. - void _fq_nmod_poly_mul(fq_nmod_struct *rop, const fq_nmod_struct *op1, long len1, const fq_nmod_struct *op2, long len2, const fq_nmod_ctx_t ctx) + void _fq_nmod_poly_mul(fq_nmod_struct *rop, const fq_nmod_struct *op1, slong len1, const fq_nmod_struct *op2, slong len2, const fq_nmod_ctx_t ctx) # Sets ``(rop, len1 + len2 - 1)`` to the product of ``(op1, len1)`` # and ``(op2, len2)``, choosing an appropriate algorithm. # Permits zero padding. Does not support aliasing. @@ -319,17 +319,17 @@ cdef extern from "flint_wrap.h": # Sets ``rop`` to the product of ``op1`` and ``op2``, # choosing an appropriate algorithm. - void _fq_nmod_poly_mullow_classical(fq_nmod_struct *rop, const fq_nmod_struct *op1, long len1, const fq_nmod_struct *op2, long len2, long n, const fq_nmod_ctx_t ctx) + void _fq_nmod_poly_mullow_classical(fq_nmod_struct *rop, const fq_nmod_struct *op1, slong len1, const fq_nmod_struct *op2, slong len2, slong n, const fq_nmod_ctx_t ctx) # Sets ``(rop, n)`` to the first `n` coefficients of # ``(op1, len1)`` multiplied by ``(op2, len2)``. # Assumes ``0 < n <= len1 + len2 - 1``. Assumes neither # ``len1`` nor ``len2`` is zero. - void fq_nmod_poly_mullow_classical(fq_nmod_poly_t rop, const fq_nmod_poly_t op1, const fq_nmod_poly_t op2, long n, const fq_nmod_ctx_t ctx) + void fq_nmod_poly_mullow_classical(fq_nmod_poly_t rop, const fq_nmod_poly_t op1, const fq_nmod_poly_t op2, slong n, const fq_nmod_ctx_t ctx) # Sets ``rop`` to the product of ``op1`` and ``op2``, # computed using the classical or schoolbook method. - void _fq_nmod_poly_mullow_univariate(fq_nmod_struct *rop, const fq_nmod_struct *op1, long len1, const fq_nmod_struct *op2, long len2, long n, const fq_nmod_ctx_t ctx) + void _fq_nmod_poly_mullow_univariate(fq_nmod_struct *rop, const fq_nmod_struct *op1, slong len1, const fq_nmod_struct *op2, slong len2, slong n, const fq_nmod_ctx_t ctx) # Sets ``(rop, n)`` to the lowest `n` coefficients of the product of # ``(op1, len1)`` and ``(op2, len2)``, computed using a # bivariate to univariate transformation. @@ -338,12 +338,12 @@ cdef extern from "flint_wrap.h": # too. Assumes `n` is positive. Supports aliasing between ``rop``, # ``op1`` and ``op2``. - void fq_nmod_poly_mullow_univariate(fq_nmod_poly_t rop, const fq_nmod_poly_t op1, const fq_nmod_poly_t op2, long n, const fq_nmod_ctx_t ctx) + void fq_nmod_poly_mullow_univariate(fq_nmod_poly_t rop, const fq_nmod_poly_t op1, const fq_nmod_poly_t op2, slong n, const fq_nmod_ctx_t ctx) # Sets ``rop`` to the lowest `n` coefficients of the product of # ``poly1`` and ``poly2``, computed using a bivariate to # univariate transformation. - void _fq_nmod_poly_mullow_KS(fq_nmod_struct *rop, const fq_nmod_struct *op1, long len1, const fq_nmod_struct *op2, long len2, long n, const fq_nmod_ctx_t ctx) + void _fq_nmod_poly_mullow_KS(fq_nmod_struct *rop, const fq_nmod_struct *op1, slong len1, const fq_nmod_struct *op2, slong len2, slong n, const fq_nmod_ctx_t ctx) # Sets ``(rop, n)`` to the lowest `n` coefficients of the product of # ``(op1, len1)`` and ``(op2, len2)``. # Assumes that ``len1`` and ``len2`` are positive, but does allow @@ -351,45 +351,45 @@ cdef extern from "flint_wrap.h": # too. Assumes `n` is positive. Supports aliasing between ``rop``, # ``op1`` and ``op2``. - void fq_nmod_poly_mullow_KS(fq_nmod_poly_t rop, const fq_nmod_poly_t op1, const fq_nmod_poly_t op2, long n, const fq_nmod_ctx_t ctx) + void fq_nmod_poly_mullow_KS(fq_nmod_poly_t rop, const fq_nmod_poly_t op1, const fq_nmod_poly_t op2, slong n, const fq_nmod_ctx_t ctx) # Sets ``rop`` to the product of ``op1`` and ``op2``. - void _fq_nmod_poly_mullow(fq_nmod_struct *rop, const fq_nmod_struct *op1, long len1, const fq_nmod_struct *op2, long len2, long n, const fq_nmod_ctx_t ctx) + void _fq_nmod_poly_mullow(fq_nmod_struct *rop, const fq_nmod_struct *op1, slong len1, const fq_nmod_struct *op2, slong len2, slong n, const fq_nmod_ctx_t ctx) # Sets ``(rop, n)`` to the lowest `n` coefficients of the product of # ``(op1, len1)`` and ``(op2, len2)``. # Assumes ``0 < n <= len1 + len2 - 1``. Allows for zero-padding in # the inputs. Does not support aliasing between the inputs and the output. - void fq_nmod_poly_mullow(fq_nmod_poly_t rop, const fq_nmod_poly_t op1, const fq_nmod_poly_t op2, long n, const fq_nmod_ctx_t ctx) + void fq_nmod_poly_mullow(fq_nmod_poly_t rop, const fq_nmod_poly_t op1, const fq_nmod_poly_t op2, slong n, const fq_nmod_ctx_t ctx) # Sets ``rop`` to the lowest `n` coefficients of the product of # ``op1`` and ``op2``. - void _fq_nmod_poly_mulhigh_classical(fq_nmod_struct *res, const fq_nmod_struct *poly1, long len1, const fq_nmod_struct *poly2, long len2, long start, const fq_nmod_ctx_t ctx) + void _fq_nmod_poly_mulhigh_classical(fq_nmod_struct *res, const fq_nmod_struct *poly1, slong len1, const fq_nmod_struct *poly2, slong len2, slong start, const fq_nmod_ctx_t ctx) # Computes the product of ``(poly1, len1)`` and ``(poly2, len2)`` # and writes the coefficients from ``start`` onwards into the high # coefficients of ``res``, the remaining coefficients being arbitrary # but reduced. Assumes that ``len1 >= len2 > 0``. Aliasing of inputs # and output is not permitted. Algorithm is classical multiplication. - void fq_nmod_poly_mulhigh_classical(fq_nmod_poly_t res, const fq_nmod_poly_t poly1, const fq_nmod_poly_t poly2, long start, const fq_nmod_ctx_t ctx) + void fq_nmod_poly_mulhigh_classical(fq_nmod_poly_t res, const fq_nmod_poly_t poly1, const fq_nmod_poly_t poly2, slong start, const fq_nmod_ctx_t ctx) # Computes the product of ``poly1`` and ``poly2`` and writes the # coefficients from ``start`` onwards into the high coefficients of # ``res``, the remaining coefficients being arbitrary but reduced. # Algorithm is classical multiplication. - void _fq_nmod_poly_mulhigh(fq_nmod_struct *res, const fq_nmod_struct *poly1, long len1, const fq_nmod_struct *poly2, long len2, long start, fq_nmod_ctx_t ctx) + void _fq_nmod_poly_mulhigh(fq_nmod_struct *res, const fq_nmod_struct *poly1, slong len1, const fq_nmod_struct *poly2, slong len2, slong start, fq_nmod_ctx_t ctx) # Computes the product of ``(poly1, len1)`` and ``(poly2, len2)`` # and writes the coefficients from ``start`` onwards into the high # coefficients of ``res``, the remaining coefficients being arbitrary # but reduced. Assumes that ``len1 >= len2 > 0``. Aliasing of inputs # and output is not permitted. - void fq_nmod_poly_mulhigh(fq_nmod_poly_t res, const fq_nmod_poly_t poly1, const fq_nmod_poly_t poly2, long start, const fq_nmod_ctx_t ctx) + void fq_nmod_poly_mulhigh(fq_nmod_poly_t res, const fq_nmod_poly_t poly1, const fq_nmod_poly_t poly2, slong start, const fq_nmod_ctx_t ctx) # Computes the product of ``poly1`` and ``poly2`` and writes the # coefficients from ``start`` onwards into the high coefficients of # ``res``, the remaining coefficients being arbitrary but reduced. - void _fq_nmod_poly_mulmod(fq_nmod_struct* res, const fq_nmod_struct* poly1, long len1, const fq_nmod_struct* poly2, long len2, const fq_nmod_struct* f, long lenf, const fq_nmod_ctx_t ctx) + void _fq_nmod_poly_mulmod(fq_nmod_struct* res, const fq_nmod_struct* poly1, slong len1, const fq_nmod_struct* poly2, slong len2, const fq_nmod_struct* f, slong lenf, const fq_nmod_ctx_t ctx) # Sets ``res`` to the remainder of the product of ``poly1`` # and ``poly2`` upon polynomial division by ``f``. # It is required that ``len1 + len2 - lenf > 0``, which is @@ -401,7 +401,7 @@ cdef extern from "flint_wrap.h": # Sets ``res`` to the remainder of the product of ``poly1`` # and ``poly2`` upon polynomial division by ``f``. - void _fq_nmod_poly_mulmod_preinv(fq_nmod_struct* res, const fq_nmod_struct* poly1, long len1, const fq_nmod_struct* poly2, long len2, const fq_nmod_struct* f, long lenf, const fq_nmod_struct* finv, long lenfinv, const fq_nmod_ctx_t ctx) + void _fq_nmod_poly_mulmod_preinv(fq_nmod_struct* res, const fq_nmod_struct* poly1, slong len1, const fq_nmod_struct* poly2, slong len2, const fq_nmod_struct* f, slong lenf, const fq_nmod_struct* finv, slong lenfinv, const fq_nmod_ctx_t ctx) # Sets ``res`` to the remainder of the product of ``poly1`` # and ``poly2`` upon polynomial division by ``f``. # It is required that ``finv`` is the inverse of the reverse of @@ -413,7 +413,7 @@ cdef extern from "flint_wrap.h": # and ``poly2`` upon polynomial division by ``f``. ``finv`` # is the inverse of the reverse of ``f``. - void _fq_nmod_poly_sqr_classical(fq_nmod_struct *rop, const fq_nmod_struct *op, long len, const fq_nmod_ctx_t ctx) + void _fq_nmod_poly_sqr_classical(fq_nmod_struct *rop, const fq_nmod_struct *op, slong len, const fq_nmod_ctx_t ctx) # Sets ``(rop, 2*len - 1)`` to the square of ``(op, len)``, # assuming that ``(op,len)`` is not zero and using classical # polynomial multiplication. @@ -424,7 +424,7 @@ cdef extern from "flint_wrap.h": # Sets ``rop`` to the square of ``op`` using classical # polynomial multiplication. - void _fq_nmod_poly_sqr_KS(fq_nmod_struct *rop, const fq_nmod_struct *op, long len, const fq_nmod_ctx_t ctx) + void _fq_nmod_poly_sqr_KS(fq_nmod_struct *rop, const fq_nmod_struct *op, slong len, const fq_nmod_ctx_t ctx) # Sets ``(rop, 2*len - 1)`` to the square of ``(op, len)``. # Permits zero padding and places no assumptions on the # lengths ``len1`` and ``len2``. Supports aliasing. @@ -434,7 +434,7 @@ cdef extern from "flint_wrap.h": # that is, by encoding each coefficient in `\mathbf{F}_{q}` as an integer # and reducing this problem to multiplying two polynomials over the integers. - void _fq_nmod_poly_sqr(fq_nmod_struct *rop, const fq_nmod_struct *op, long len, const fq_nmod_ctx_t ctx) + void _fq_nmod_poly_sqr(fq_nmod_struct *rop, const fq_nmod_struct *op, slong len, const fq_nmod_ctx_t ctx) # Sets ``(rop, 2* len - 1)`` to the square of ``(op, len)``, # choosing an appropriate algorithm. # Permits zero padding. Does not support aliasing. @@ -443,16 +443,16 @@ cdef extern from "flint_wrap.h": # Sets ``rop`` to the square of ``op``, # choosing an appropriate algorithm. - void _fq_nmod_poly_pow(fq_nmod_struct *rop, const fq_nmod_struct *op, long len, unsigned long e, const fq_nmod_ctx_t ctx) + void _fq_nmod_poly_pow(fq_nmod_struct *rop, const fq_nmod_struct *op, slong len, ulong e, const fq_nmod_ctx_t ctx) # Sets ``rop = op^e``, assuming that ``e, len > 0`` and that # ``rop`` has space for ``e*(len - 1) + 1`` coefficients. Does # not support aliasing. - void fq_nmod_poly_pow(fq_nmod_poly_t rop, const fq_nmod_poly_t op, unsigned long e, const fq_nmod_ctx_t ctx) + void fq_nmod_poly_pow(fq_nmod_poly_t rop, const fq_nmod_poly_t op, ulong e, const fq_nmod_ctx_t ctx) # Computes ``rop = op^e``. If `e` is zero, returns one, # so that in particular ``0^0 = 1``. - void _fq_nmod_poly_powmod_ui_binexp(fq_nmod_struct* res, const fq_nmod_struct* poly, unsigned long e, const fq_nmod_struct* f, long lenf, const fq_nmod_ctx_t ctx) + void _fq_nmod_poly_powmod_ui_binexp(fq_nmod_struct* res, const fq_nmod_struct* poly, ulong e, const fq_nmod_struct* f, slong lenf, const fq_nmod_ctx_t ctx) # Sets ``res`` to ``poly`` raised to the power ``e`` modulo # ``f``, using binary exponentiation. We require ``e > 0``. # We require ``lenf > 1``. It is assumed that ``poly`` is @@ -460,11 +460,11 @@ cdef extern from "flint_wrap.h": # have length exactly ``lenf - 1``. The output ``res`` must # have room for ``lenf - 1`` coefficients. - void fq_nmod_poly_powmod_ui_binexp(fq_nmod_poly_t res, const fq_nmod_poly_t poly, unsigned long e, const fq_nmod_poly_t f, const fq_nmod_ctx_t ctx) + void fq_nmod_poly_powmod_ui_binexp(fq_nmod_poly_t res, const fq_nmod_poly_t poly, ulong e, const fq_nmod_poly_t f, const fq_nmod_ctx_t ctx) # Sets ``res`` to ``poly`` raised to the power ``e`` modulo # ``f``, using binary exponentiation. We require ``e >= 0``. - void _fq_nmod_poly_powmod_ui_binexp_preinv(fq_nmod_struct* res, const fq_nmod_struct* poly, unsigned long e, const fq_nmod_struct* f, long lenf, const fq_nmod_struct* finv, long lenfinv, const fq_nmod_ctx_t ctx) + void _fq_nmod_poly_powmod_ui_binexp_preinv(fq_nmod_struct* res, const fq_nmod_struct* poly, ulong e, const fq_nmod_struct* f, slong lenf, const fq_nmod_struct* finv, slong lenfinv, const fq_nmod_ctx_t ctx) # Sets ``res`` to ``poly`` raised to the power ``e`` modulo # ``f``, using binary exponentiation. We require ``e > 0``. # We require ``finv`` to be the inverse of the reverse of @@ -474,13 +474,13 @@ cdef extern from "flint_wrap.h": # have length exactly ``lenf - 1``. The output ``res`` must # have room for ``lenf - 1`` coefficients. - void fq_nmod_poly_powmod_ui_binexp_preinv(fq_nmod_poly_t res, const fq_nmod_poly_t poly, unsigned long e, const fq_nmod_poly_t f, const fq_nmod_poly_t finv, const fq_nmod_ctx_t ctx) + void fq_nmod_poly_powmod_ui_binexp_preinv(fq_nmod_poly_t res, const fq_nmod_poly_t poly, ulong e, const fq_nmod_poly_t f, const fq_nmod_poly_t finv, const fq_nmod_ctx_t ctx) # Sets ``res`` to ``poly`` raised to the power ``e`` modulo # ``f``, using binary exponentiation. We require ``e >= 0``. # We require ``finv`` to be the inverse of the reverse of # ``f``. - void _fq_nmod_poly_powmod_fmpz_binexp(fq_nmod_struct* res, const fq_nmod_struct* poly, const fmpz_t e, const fq_nmod_struct* f, long lenf, const fq_nmod_ctx_t ctx) + void _fq_nmod_poly_powmod_fmpz_binexp(fq_nmod_struct* res, const fq_nmod_struct* poly, const fmpz_t e, const fq_nmod_struct* f, slong lenf, const fq_nmod_ctx_t ctx) # Sets ``res`` to ``poly`` raised to the power ``e`` modulo # ``f``, using binary exponentiation. We require ``e > 0``. # We require ``lenf > 1``. It is assumed that ``poly`` is @@ -492,7 +492,7 @@ cdef extern from "flint_wrap.h": # Sets ``res`` to ``poly`` raised to the power ``e`` modulo # ``f``, using binary exponentiation. We require ``e >= 0``. - void _fq_nmod_poly_powmod_fmpz_binexp_preinv(fq_nmod_struct* res, const fq_nmod_struct* poly, const fmpz_t e, const fq_nmod_struct* f, long lenf, const fq_nmod_struct* finv, long lenfinv, const fq_nmod_ctx_t ctx) + void _fq_nmod_poly_powmod_fmpz_binexp_preinv(fq_nmod_struct* res, const fq_nmod_struct* poly, const fmpz_t e, const fq_nmod_struct* f, slong lenf, const fq_nmod_struct* finv, slong lenfinv, const fq_nmod_ctx_t ctx) # Sets ``res`` to ``poly`` raised to the power ``e`` modulo # ``f``, using binary exponentiation. We require ``e > 0``. # We require ``finv`` to be the inverse of the reverse of @@ -508,7 +508,7 @@ cdef extern from "flint_wrap.h": # We require ``finv`` to be the inverse of the reverse of # ``f``. - void _fq_nmod_poly_powmod_fmpz_sliding_preinv(fq_nmod_struct* res, const fq_nmod_struct* poly, const fmpz_t e, unsigned long k, const fq_nmod_struct* f, long lenf, const fq_nmod_struct* finv, long lenfinv, const fq_nmod_ctx_t ctx) + void _fq_nmod_poly_powmod_fmpz_sliding_preinv(fq_nmod_struct* res, const fq_nmod_struct* poly, const fmpz_t e, ulong k, const fq_nmod_struct* f, slong lenf, const fq_nmod_struct* finv, slong lenfinv, const fq_nmod_ctx_t ctx) # Sets ``res`` to ``poly`` raised to the power ``e`` modulo # ``f``, using sliding-window exponentiation with window size # ``k``. We require ``e > 0``. We require ``finv`` to be @@ -520,7 +520,7 @@ cdef extern from "flint_wrap.h": # have length exactly ``lenf - 1``. The output ``res`` must # have room for ``lenf - 1`` coefficients. - void fq_nmod_poly_powmod_fmpz_sliding_preinv(fq_nmod_poly_t res, const fq_nmod_poly_t poly, const fmpz_t e, unsigned long k, const fq_nmod_poly_t f, const fq_nmod_poly_t finv, const fq_nmod_ctx_t ctx) + void fq_nmod_poly_powmod_fmpz_sliding_preinv(fq_nmod_poly_t res, const fq_nmod_poly_t poly, const fmpz_t e, ulong k, const fq_nmod_poly_t f, const fq_nmod_poly_t finv, const fq_nmod_ctx_t ctx) # Sets ``res`` to ``poly`` raised to the power ``e`` modulo # ``f``, using sliding-window exponentiation with window size # ``k``. We require ``e >= 0``. We require ``finv`` to be @@ -528,7 +528,7 @@ cdef extern from "flint_wrap.h": # zero, then an "optimum" size will be selected automatically base # on ``e``. - void _fq_nmod_poly_powmod_x_fmpz_preinv(fq_nmod_struct * res, const fmpz_t e, const fq_nmod_struct * f, long lenf, const fq_nmod_struct * finv, long lenfinv, const fq_nmod_ctx_t ctx) + void _fq_nmod_poly_powmod_x_fmpz_preinv(fq_nmod_struct * res, const fmpz_t e, const fq_nmod_struct * f, slong lenf, const fq_nmod_struct * finv, slong lenfinv, const fq_nmod_ctx_t ctx) # Sets ``res`` to ``x`` raised to the power ``e`` modulo ``f``, # using sliding window exponentiation. We require ``e > 0``. # We require ``finv`` to be the inverse of the reverse of ``f``. @@ -541,7 +541,7 @@ cdef extern from "flint_wrap.h": # ``e >= 0``. We require ``finv`` to be the inverse of the reverse of # ``f``. - void _fq_nmod_poly_pow_trunc_binexp(fq_nmod_struct * res, const fq_nmod_struct * poly, unsigned long e, long trunc, const fq_nmod_ctx_t ctx) + void _fq_nmod_poly_pow_trunc_binexp(fq_nmod_struct * res, const fq_nmod_struct * poly, ulong e, slong trunc, const fq_nmod_ctx_t ctx) # Sets ``res`` to the low ``trunc`` coefficients of ``poly`` # (assumed to be zero padded if necessary to length ``trunc``) to # the power ``e``. This is equivalent to doing a powering followed @@ -550,12 +550,12 @@ cdef extern from "flint_wrap.h": # ``e > 1``. Aliasing is not permitted. Uses the binary # exponentiation method. - void fq_nmod_poly_pow_trunc_binexp(fq_nmod_poly_t res, const fq_nmod_poly_t poly, unsigned long e, long trunc, const fq_nmod_ctx_t ctx) + void fq_nmod_poly_pow_trunc_binexp(fq_nmod_poly_t res, const fq_nmod_poly_t poly, ulong e, slong trunc, const fq_nmod_ctx_t ctx) # Sets ``res`` to the low ``trunc`` coefficients of ``poly`` # to the power ``e``. This is equivalent to doing a powering # followed by a truncation. Uses the binary exponentiation method. - void _fq_nmod_poly_pow_trunc(fq_nmod_struct * res, const fq_nmod_struct * poly, unsigned long e, long trunc, const fq_nmod_ctx_t mod) + void _fq_nmod_poly_pow_trunc(fq_nmod_struct * res, const fq_nmod_struct * poly, ulong e, slong trunc, const fq_nmod_ctx_t mod) # Sets ``res`` to the low ``trunc`` coefficients of ``poly`` # (assumed to be zero padded if necessary to length ``trunc``) to # the power ``e``. This is equivalent to doing a powering followed @@ -563,12 +563,12 @@ cdef extern from "flint_wrap.h": # ``trunc`` coefficients, that ``trunc > 0`` and that # ``e > 1``. Aliasing is not permitted. - void fq_nmod_poly_pow_trunc(fq_nmod_poly_t res, const fq_nmod_poly_t poly, unsigned long e, long trunc, const fq_nmod_ctx_t ctx) + void fq_nmod_poly_pow_trunc(fq_nmod_poly_t res, const fq_nmod_poly_t poly, ulong e, slong trunc, const fq_nmod_ctx_t ctx) # Sets ``res`` to the low ``trunc`` coefficients of ``poly`` # to the power ``e``. This is equivalent to doing a powering # followed by a truncation. - void _fq_nmod_poly_shift_left(fq_nmod_struct *rop, const fq_nmod_struct *op, long len, long n, const fq_nmod_ctx_t ctx) + void _fq_nmod_poly_shift_left(fq_nmod_struct *rop, const fq_nmod_struct *op, slong len, slong n, const fq_nmod_ctx_t ctx) # Sets ``(rop, len + n)`` to ``(op, len)`` shifted left by # `n` coefficients. # Inserts zero coefficients at the lower end. Assumes that @@ -576,11 +576,11 @@ cdef extern from "flint_wrap.h": # ``len + n`` elements. Supports aliasing between ``rop`` and # ``op``. - void fq_nmod_poly_shift_left(fq_nmod_poly_t rop, const fq_nmod_poly_t op, long n, const fq_nmod_ctx_t ctx) + void fq_nmod_poly_shift_left(fq_nmod_poly_t rop, const fq_nmod_poly_t op, slong n, const fq_nmod_ctx_t ctx) # Sets ``rop`` to ``op`` shifted left by `n` coeffs. Zero # coefficients are inserted. - void _fq_nmod_poly_shift_right(fq_nmod_struct *rop, const fq_nmod_struct *op, long len, long n, const fq_nmod_ctx_t ctx) + void _fq_nmod_poly_shift_right(fq_nmod_struct *rop, const fq_nmod_struct *op, slong len, slong n, const fq_nmod_ctx_t ctx) # Sets ``(rop, len - n)`` to ``(op, len)`` shifted right by # `n` coefficients. # Assumes that ``len`` and `n` are positive, that ``len > n``, @@ -588,18 +588,18 @@ cdef extern from "flint_wrap.h": # aliasing between ``rop`` and ``op``, although in this case # the top coefficients of ``op`` are not set to zero. - void fq_nmod_poly_shift_right(fq_nmod_poly_t rop, const fq_nmod_poly_t op, long n, const fq_nmod_ctx_t ctx) + void fq_nmod_poly_shift_right(fq_nmod_poly_t rop, const fq_nmod_poly_t op, slong n, const fq_nmod_ctx_t ctx) # Sets ``rop`` to ``op`` shifted right by `n` coefficients. # If `n` is equal to or greater than the current length of # ``op``, ``rop`` is set to the zero polynomial. - long _fq_nmod_poly_hamming_weight(const fq_nmod_struct *op, long len, const fq_nmod_ctx_t ctx) + slong _fq_nmod_poly_hamming_weight(const fq_nmod_struct *op, slong len, const fq_nmod_ctx_t ctx) # Returns the number of non-zero entries in ``(op, len)``. - long fq_nmod_poly_hamming_weight(const fq_nmod_poly_t op, const fq_nmod_ctx_t ctx) + slong fq_nmod_poly_hamming_weight(const fq_nmod_poly_t op, const fq_nmod_ctx_t ctx) # Returns the number of non-zero entries in the polynomial ``op``. - void _fq_nmod_poly_divrem(fq_nmod_struct *Q, fq_nmod_struct *R, const fq_nmod_struct *A, long lenA, const fq_nmod_struct *B, long lenB, const fq_nmod_t invB, const fq_nmod_ctx_t ctx) + void _fq_nmod_poly_divrem(fq_nmod_struct *Q, fq_nmod_struct *R, const fq_nmod_struct *A, slong lenA, const fq_nmod_struct *B, slong lenB, const fq_nmod_t invB, const fq_nmod_ctx_t ctx) # Computes ``(Q, lenA - lenB + 1)``, ``(R, lenA)`` such that # `A = B Q + R` with `0 \leq \operatorname{len}(R) < \operatorname{len}(B)`. # Assumes that the leading coefficient of `B` is invertible @@ -625,7 +625,7 @@ cdef extern from "flint_wrap.h": # non-trivial factor of the modulus and `Q` and `R` are not touched. # Assumes that `B` is non-zero. - void _fq_nmod_poly_rem(fq_nmod_struct *R, const fq_nmod_struct *A, long lenA, const fq_nmod_struct *B, long lenB, const fq_nmod_t invB, const fq_nmod_ctx_t ctx) + void _fq_nmod_poly_rem(fq_nmod_struct *R, const fq_nmod_struct *A, slong lenA, const fq_nmod_struct *B, slong lenB, const fq_nmod_t invB, const fq_nmod_ctx_t ctx) # Sets ``R`` to the remainder of the division of ``(A,lenA)`` by # ``(B,lenB)``. Assumes that the leading coefficient of ``(B,lenB)`` # is invertible and that ``invB`` is its inverse. @@ -634,7 +634,7 @@ cdef extern from "flint_wrap.h": # Sets ``R`` to the remainder of the division of ``A`` by # ``B`` in the context described by ``ctx``. - void _fq_nmod_poly_div(fq_nmod_struct *Q, const fq_nmod_struct *A, long lenA, const fq_nmod_struct *B, long lenB, const fq_nmod_t invB, const fq_nmod_ctx_t ctx) + void _fq_nmod_poly_div(fq_nmod_struct *Q, const fq_nmod_struct *A, slong lenA, const fq_nmod_struct *B, slong lenB, const fq_nmod_t invB, const fq_nmod_ctx_t ctx) # Notationally, computes `Q`, `R` such that `A = B Q + R` with `0 # \leq \operatorname{len}(R) < \operatorname{len}(B)` but only sets ``(Q, lenA - lenB + 1)``. # Allows zero-padding in `A` but not in `B`. Assumes that the leading coefficient of `B` is a @@ -645,7 +645,7 @@ cdef extern from "flint_wrap.h": # `\operatorname{len}(R) < \operatorname{len}(B)`, but returns only ``Q``. If `\operatorname{len}(B) = 0` an # exception is raised. - void _fq_nmod_poly_div_newton_n_preinv(fq_nmod_struct* Q, const fq_nmod_struct* A, long lenA, const fq_nmod_struct* B, long lenB, const fq_nmod_struct* Binv, long lenBinv, const fq_nmod_ctx_t ctx) + void _fq_nmod_poly_div_newton_n_preinv(fq_nmod_struct* Q, const fq_nmod_struct* A, slong lenA, const fq_nmod_struct* B, slong lenB, const fq_nmod_struct* Binv, slong lenBinv, const fq_nmod_ctx_t ctx) # Notionally computes polynomials `Q` and `R` such that `A = BQ + R` with # `\operatorname{len}(R)` less than ``lenB``, where ``A`` is of length ``lenA`` # and ``B`` is of length ``lenB``, but return only `Q`. @@ -665,7 +665,7 @@ cdef extern from "flint_wrap.h": # The algorithm used is to reverse the polynomials and divide the # resulting power series, then reverse the result. - void _fq_nmod_poly_divrem_newton_n_preinv(fq_nmod_struct* Q, fq_nmod_struct* R, const fq_nmod_struct* A, long lenA, const fq_nmod_struct* B, long lenB, const fq_nmod_struct* Binv, long lenBinv, const fq_nmod_ctx_t ctx) + void _fq_nmod_poly_divrem_newton_n_preinv(fq_nmod_struct* Q, fq_nmod_struct* R, const fq_nmod_struct* A, slong lenA, const fq_nmod_struct* B, slong lenB, const fq_nmod_struct* Binv, slong lenBinv, const fq_nmod_ctx_t ctx) # Computes `Q` and `R` such that `A = BQ + R` with `\operatorname{len}(R)` less # than ``lenB``, where `A` is of length ``lenA`` and `B` is of # length ``lenB``. We require that `Q` have space for @@ -683,27 +683,27 @@ cdef extern from "flint_wrap.h": # The algorithm used is to call :func:`div_newton` and then # multiply out and compute the remainder. - void _fq_nmod_poly_inv_series_newton(fq_nmod_struct* Qinv, const fq_nmod_struct* Q, long n, const fq_nmod_t cinv, const fq_nmod_ctx_t ctx) + void _fq_nmod_poly_inv_series_newton(fq_nmod_struct* Qinv, const fq_nmod_struct* Q, slong n, const fq_nmod_t cinv, const fq_nmod_ctx_t ctx) # Given ``Q`` of length ``n`` whose constant coefficient is # invertible modulo the given modulus, find a polynomial ``Qinv`` # of length ``n`` such that ``Q * Qinv`` is ``1`` modulo # `x^n`. Requires ``n > 0``. This function can be viewed as # inverting a power series via Newton iteration. - void fq_nmod_poly_inv_series_newton(fq_nmod_poly_t Qinv, const fq_nmod_poly_t Q, long n, const fq_nmod_ctx_t ctx) + void fq_nmod_poly_inv_series_newton(fq_nmod_poly_t Qinv, const fq_nmod_poly_t Q, slong n, const fq_nmod_ctx_t ctx) # Given ``Q`` find ``Qinv`` such that ``Q * Qinv`` is # ``1`` modulo `x^n`. The constant coefficient of ``Q`` must # be invertible modulo the modulus of ``Q``. An exception is # raised if this is not the case or if ``n = 0``. This function # can be viewed as inverting a power series via Newton iteration. - void _fq_nmod_poly_inv_series(fq_nmod_struct* Qinv, const fq_nmod_struct* Q, long n, const fq_nmod_t cinv, const fq_nmod_ctx_t ctx) + void _fq_nmod_poly_inv_series(fq_nmod_struct* Qinv, const fq_nmod_struct* Q, slong n, const fq_nmod_t cinv, const fq_nmod_ctx_t ctx) # Given ``Q`` of length ``n`` whose constant coefficient is # invertible modulo the given modulus, find a polynomial ``Qinv`` # of length ``n`` such that ``Q * Qinv`` is ``1`` modulo # `x^n`. Requires ``n > 0``. - void fq_nmod_poly_inv_series(fq_nmod_poly_t Qinv, const fq_nmod_poly_t Q, long n, const fq_nmod_ctx_t ctx) + void fq_nmod_poly_inv_series(fq_nmod_poly_t Qinv, const fq_nmod_poly_t Q, slong n, const fq_nmod_ctx_t ctx) # Given ``Q`` find ``Qinv`` such that ``Q * Qinv`` is # ``1`` modulo `x^n`. The constant coefficient of ``Q`` must # be invertible modulo the modulus of ``Q``. An exception is @@ -714,7 +714,7 @@ cdef extern from "flint_wrap.h": # ``(B, Blen)`` assuming ``Alen, Blen <= n``. We assume the bottom # coefficient of ``B`` is invertible. - void fq_nmod_poly_div_series(fq_nmod_poly_t Q, const fq_nmod_poly_t A, const fq_nmod_poly_t B, long n, fq_nmod_ctx_t ctx) + void fq_nmod_poly_div_series(fq_nmod_poly_t Q, const fq_nmod_poly_t A, const fq_nmod_poly_t B, slong n, fq_nmod_ctx_t ctx) # Set `Q` to the quotient of the series `A` by `B`, thinking of the series as # though they were of length `n`. We assume that the bottom coefficient of # `B` is invertible. @@ -727,14 +727,14 @@ cdef extern from "flint_wrap.h": # `P`. Except in the case where the GCD is zero, the GCD `G` is made # monic. - long _fq_nmod_poly_gcd(fq_nmod_struct* G, const fq_nmod_struct* A, long lenA, const fq_nmod_struct* B, long lenB, const fq_nmod_ctx_t ctx) + slong _fq_nmod_poly_gcd(fq_nmod_struct* G, const fq_nmod_struct* A, slong lenA, const fq_nmod_struct* B, slong lenB, const fq_nmod_ctx_t ctx) # Computes the GCD of `A` of length ``lenA`` and `B` of length # ``lenB``, where ``lenA >= lenB > 0`` and sets `G` to it. The # length of the GCD `G` is returned by the function. No attempt is # made to make the GCD monic. It is required that `G` have space for # ``lenB`` coefficients. - long _fq_nmod_poly_gcd_euclidean_f(fq_nmod_t f, fq_nmod_struct *G, const fq_nmod_struct *A, long lenA, const fq_nmod_struct *B, long lenB, const fq_nmod_ctx_t ctx) + slong _fq_nmod_poly_gcd_euclidean_f(fq_nmod_t f, fq_nmod_struct *G, const fq_nmod_struct *A, slong lenA, const fq_nmod_struct *B, slong lenB, const fq_nmod_ctx_t ctx) # Either sets `f = 1` and `G` to the greatest common divisor of # `(A,\operatorname{len}(A))` and `(B, \operatorname{len}(B))` and returns its length, or sets # `f` to a non-trivial factor of the modulus of ``ctx`` and leaves @@ -746,7 +746,7 @@ cdef extern from "flint_wrap.h": # Either sets `f = 1` and `G` to the greatest common divisor of `A` # and `B` or sets `f` to a factor of the modulus of ``ctx``. - long _fq_nmod_poly_xgcd(fq_nmod_struct *G, fq_nmod_struct *S, fq_nmod_struct *T, const fq_nmod_struct *A, long lenA, const fq_nmod_struct *B, long lenB, const fq_nmod_ctx_t ctx) + slong _fq_nmod_poly_xgcd(fq_nmod_struct *G, fq_nmod_struct *S, fq_nmod_struct *T, const fq_nmod_struct *A, slong lenA, const fq_nmod_struct *B, slong lenB, const fq_nmod_ctx_t ctx) # Computes the GCD of `A` and `B` together with cofactors `S` and `T` # such that `S A + T B = G`. Returns the length of `G`. # Assumes that `\operatorname{len}(A) \geq \operatorname{len}(B) \geq 1` and @@ -767,7 +767,7 @@ cdef extern from "flint_wrap.h": # ``S*A + T*B = G``. The length of ``S`` will be at most # ``lenB`` and the length of ``T`` will be at most ``lenA``. - long _fq_nmod_poly_xgcd_euclidean_f(fq_nmod_t f, fq_nmod_struct *G, fq_nmod_struct *S, fq_nmod_struct *T, const fq_nmod_struct *A, long lenA, const fq_nmod_struct *B, long lenB, const fq_nmod_ctx_t ctx) + slong _fq_nmod_poly_xgcd_euclidean_f(fq_nmod_t f, fq_nmod_struct *G, fq_nmod_struct *S, fq_nmod_struct *T, const fq_nmod_struct *A, slong lenA, const fq_nmod_struct *B, slong lenB, const fq_nmod_ctx_t ctx) # Either sets `f = 1` and computes the GCD of `A` and `B` together # with cofactors `S` and `T` such that `S A + T B = G`; otherwise, # sets `f` to a non-trivial factor of the modulus of ``ctx`` and @@ -793,7 +793,7 @@ cdef extern from "flint_wrap.h": # be `P`. Except in the case where the GCD is zero, the GCD `G` is # made monic. - int _fq_nmod_poly_divides(fq_nmod_struct *Q, const fq_nmod_struct *A, long lenA, const fq_nmod_struct *B, long lenB, const fq_nmod_t invB, const fq_nmod_ctx_t ctx) + int _fq_nmod_poly_divides(fq_nmod_struct *Q, const fq_nmod_struct *A, slong lenA, const fq_nmod_struct *B, slong lenB, const fq_nmod_t invB, const fq_nmod_ctx_t ctx) # Returns `1` if ``(B, lenB)`` divides ``(A, lenA)`` exactly and # sets `Q` to the quotient, otherwise returns `0`. # It is assumed that `\operatorname{len}(A) \geq \operatorname{len}(B) > 0` and that `Q` has space @@ -808,7 +808,7 @@ cdef extern from "flint_wrap.h": # This function is currently unoptimised and provided for convenience # only. - void _fq_nmod_poly_derivative(fq_nmod_struct *rop, const fq_nmod_struct *op, long len, const fq_nmod_ctx_t ctx) + void _fq_nmod_poly_derivative(fq_nmod_struct *rop, const fq_nmod_struct *op, slong len, const fq_nmod_ctx_t ctx) # Sets ``(rop, len - 1)`` to the derivative of ``(op, len)``. # Also handles the cases where ``len`` is `0` or `1` correctly. # Supports aliasing of ``rop`` and ``op``. @@ -816,25 +816,25 @@ cdef extern from "flint_wrap.h": void fq_nmod_poly_derivative(fq_nmod_poly_t rop, const fq_nmod_poly_t op, const fq_nmod_ctx_t ctx) # Sets ``rop`` to the derivative of ``op``. - void _fq_nmod_poly_invsqrt_series(fq_nmod_struct * g, const fq_nmod_struct * h, long n, fq_nmod_ctx_t mod) + void _fq_nmod_poly_invsqrt_series(fq_nmod_struct * g, const fq_nmod_struct * h, slong n, fq_nmod_ctx_t mod) # Set the first `n` terms of `g` to the series expansion of `1/\sqrt{h}`. # It is assumed that `n > 0`, that `h` has constant term 1 and that `h` # is zero-padded as necessary to length `n`. Aliasing is not permitted. - void fq_nmod_poly_invsqrt_series(fq_nmod_poly_t g, const fq_nmod_poly_t h, long n, fq_nmod_ctx_t ctx) + void fq_nmod_poly_invsqrt_series(fq_nmod_poly_t g, const fq_nmod_poly_t h, slong n, fq_nmod_ctx_t ctx) # Set `g` to the series expansion of `1/\sqrt{h}` to order `O(x^n)`. # It is assumed that `h` has constant term 1. - void _fq_nmod_poly_sqrt_series(fq_nmod_struct * g, const fq_nmod_struct * h, long n, fq_nmod_ctx_t ctx) + void _fq_nmod_poly_sqrt_series(fq_nmod_struct * g, const fq_nmod_struct * h, slong n, fq_nmod_ctx_t ctx) # Set the first `n` terms of `g` to the series expansion of `\sqrt{h}`. # It is assumed that `n > 0`, that `h` has constant term 1 and that `h` # is zero-padded as necessary to length `n`. Aliasing is not permitted. - void fq_nmod_poly_sqrt_series(fq_nmod_poly_t g, const fq_nmod_poly_t h, long n, fq_nmod_ctx_t ctx) + void fq_nmod_poly_sqrt_series(fq_nmod_poly_t g, const fq_nmod_poly_t h, slong n, fq_nmod_ctx_t ctx) # Set `g` to the series expansion of `\sqrt{h}` to order `O(x^n)`. # It is assumed that `h` has constant term 1. - int _fq_nmod_poly_sqrt(fq_nmod_struct * s, const fq_nmod_struct * p, long n, fq_nmod_ctx_t mod) + int _fq_nmod_poly_sqrt(fq_nmod_struct * s, const fq_nmod_struct * p, slong n, fq_nmod_ctx_t mod) # If ``(p, n)`` is a perfect square, sets ``(s, n / 2 + 1)`` # to a square root of `p` and returns 1. Otherwise returns 0. @@ -842,7 +842,7 @@ cdef extern from "flint_wrap.h": # If `p` is a perfect square, sets `s` to a square root of `p` # and returns 1. Otherwise returns 0. - void _fq_nmod_poly_evaluate_fq_nmod(fq_nmod_t rop, const fq_nmod_struct *op, long len, const fq_nmod_t a, const fq_nmod_ctx_t ctx) + void _fq_nmod_poly_evaluate_fq_nmod(fq_nmod_t rop, const fq_nmod_struct *op, slong len, const fq_nmod_t a, const fq_nmod_ctx_t ctx) # Sets ``rop`` to ``(op, len)`` evaluated at `a`. # Supports zero padding. There are no restrictions on ``len``, that # is, ``len`` is allowed to be zero, too. @@ -852,7 +852,7 @@ cdef extern from "flint_wrap.h": # As the coefficient ring `\mathbf{F}_q` is finite, Horner's method # is sufficient. - void _fq_nmod_poly_compose(fq_nmod_struct *rop, const fq_nmod_struct *op1, long len1, const fq_nmod_struct *op2, long len2, const fq_nmod_ctx_t ctx) + void _fq_nmod_poly_compose(fq_nmod_struct *rop, const fq_nmod_struct *op1, slong len1, const fq_nmod_struct *op2, slong len2, const fq_nmod_ctx_t ctx) # Sets ``rop`` to the composition of ``(op1, len1)`` and # ``(op2, len2)``. # Assumes that ``rop`` has space for ``(len1-1)*(len2-1) + 1`` @@ -866,7 +866,7 @@ cdef extern from "flint_wrap.h": # ``op1``, and ``op2`` by `f`, `g`, and `h`, respectively, # sets `f(t) = g(h(t))`. - void _fq_nmod_poly_compose_mod_horner(fq_nmod_struct * res, const fq_nmod_struct * f, long lenf, const fq_nmod_struct * g, const fq_nmod_struct * h, long lenh, const fq_nmod_ctx_t ctx) + void _fq_nmod_poly_compose_mod_horner(fq_nmod_struct * res, const fq_nmod_struct * f, slong lenf, const fq_nmod_struct * g, const fq_nmod_struct * h, slong lenh, const fq_nmod_ctx_t ctx) # Sets ``res`` to the composition `f(g)` modulo `h`. We require that # `h` is nonzero and that the length of `g` is one less than the # length of `h` (possibly with zero padding). The output is not allowed @@ -877,7 +877,7 @@ cdef extern from "flint_wrap.h": # Sets ``res`` to the composition `f(g)` modulo `h`. We require that # `h` is nonzero. The algorithm used is Horner's rule. - void _fq_nmod_poly_compose_mod_horner_preinv(fq_nmod_struct * res, const fq_nmod_struct * f, long lenf, const fq_nmod_struct * g, const fq_nmod_struct * h, long lenh, const fq_nmod_struct * hinv, long lenhiv, const fq_nmod_ctx_t ctx) + void _fq_nmod_poly_compose_mod_horner_preinv(fq_nmod_struct * res, const fq_nmod_struct * f, slong lenf, const fq_nmod_struct * g, const fq_nmod_struct * h, slong lenh, const fq_nmod_struct * hinv, slong lenhiv, const fq_nmod_ctx_t ctx) # Sets ``res`` to the composition `f(g)` modulo `h`. We require # that `h` is nonzero and that the length of `g` is one less than # the length of `h` (possibly with zero padding). We also require @@ -893,7 +893,7 @@ cdef extern from "flint_wrap.h": # `h`. Furthermore, we require ``hinv`` to be the inverse of the # reverse of ``h``. The algorithm used is Horner's rule. - void _fq_nmod_poly_compose_mod_brent_kung(fq_nmod_struct * res, const fq_nmod_struct * f, long lenf, const fq_nmod_struct * g, const fq_nmod_struct * h, long lenh, const fq_nmod_ctx_t ctx) + void _fq_nmod_poly_compose_mod_brent_kung(fq_nmod_struct * res, const fq_nmod_struct * f, slong lenf, const fq_nmod_struct * g, const fq_nmod_struct * h, slong lenh, const fq_nmod_ctx_t ctx) # Sets ``res`` to the composition `f(g)` modulo `h`. We require # that `h` is nonzero and that the length of `g` is one less than # the length of `h` (possibly with zero padding). We also require @@ -906,7 +906,7 @@ cdef extern from "flint_wrap.h": # that `h` is nonzero and that `f` has smaller degree than `h`. The # algorithm used is the Brent-Kung matrix algorithm. - void _fq_nmod_poly_compose_mod_brent_kung_preinv(fq_nmod_struct * res, const fq_nmod_struct * f, long lenf, const fq_nmod_struct * g, const fq_nmod_struct * h, long lenh, const fq_nmod_struct * hinv, long lenhiv, const fq_nmod_ctx_t ctx) + void _fq_nmod_poly_compose_mod_brent_kung_preinv(fq_nmod_struct * res, const fq_nmod_struct * f, slong lenf, const fq_nmod_struct * g, const fq_nmod_struct * h, slong lenh, const fq_nmod_struct * hinv, slong lenhiv, const fq_nmod_ctx_t ctx) # Sets ``res`` to the composition `f(g)` modulo `h`. We require # that `h` is nonzero and that the length of `g` is one less than # the length of `h` (possibly with zero padding). We also require @@ -923,7 +923,7 @@ cdef extern from "flint_wrap.h": # reverse of ``h``. The algorithm used is the Brent-Kung matrix # algorithm. - void _fq_nmod_poly_compose_mod(fq_nmod_struct * res, const fq_nmod_struct * f, long lenf, const fq_nmod_struct * g, const fq_nmod_struct * h, long lenh, const fq_nmod_ctx_t ctx) + void _fq_nmod_poly_compose_mod(fq_nmod_struct * res, const fq_nmod_struct * f, slong lenf, const fq_nmod_struct * g, const fq_nmod_struct * h, slong lenh, const fq_nmod_ctx_t ctx) # Sets ``res`` to the composition `f(g)` modulo `h`. We require # that `h` is nonzero and that the length of `g` is one less than # the length of `h` (possibly with zero padding). The output is not @@ -933,7 +933,7 @@ cdef extern from "flint_wrap.h": # Sets ``res`` to the composition `f(g)` modulo `h`. We require # that `h` is nonzero. - void _fq_nmod_poly_compose_mod_preinv(fq_nmod_struct * res, const fq_nmod_struct * f, long lenf, const fq_nmod_struct * g, const fq_nmod_struct * h, long lenh, const fq_nmod_struct * hinv, long lenhiv, const fq_nmod_ctx_t ctx) + void _fq_nmod_poly_compose_mod_preinv(fq_nmod_struct * res, const fq_nmod_struct * f, slong lenf, const fq_nmod_struct * g, const fq_nmod_struct * h, slong lenh, const fq_nmod_struct * hinv, slong lenhiv, const fq_nmod_ctx_t ctx) # Sets ``res`` to the composition `f(g)` modulo `h`. We require # that `h` is nonzero and that the length of `g` is one less than # the length of `h` (possibly with zero padding). We also require @@ -953,7 +953,7 @@ cdef extern from "flint_wrap.h": # `f` for `i=1,\ldots,\sqrt{\deg(f)}`. We require `B` to be at least # a `\sqrt{\deg(f)}\times \deg(f)` matrix and `f` to be nonzero. - void _fq_nmod_poly_precompute_matrix (fq_nmod_mat_t A, const fq_nmod_struct* f, const fq_nmod_struct* g, long leng, const fq_nmod_struct* ginv, long lenginv, const fq_nmod_ctx_t ctx) + void _fq_nmod_poly_precompute_matrix (fq_nmod_mat_t A, const fq_nmod_struct* f, const fq_nmod_struct* g, slong leng, const fq_nmod_struct* ginv, slong lenginv, const fq_nmod_ctx_t ctx) # Sets the ith row of ``A`` to `f^i` modulo `g` for # `i=1,\ldots,\sqrt{\deg(g)}`. We require `A` to be a # `\sqrt{\deg(g)}\times \deg(g)` matrix. We require ``ginv`` to @@ -965,7 +965,7 @@ cdef extern from "flint_wrap.h": # `\sqrt{\deg(g)}\times \deg(g)` matrix. We require ``ginv`` to # be the inverse of the reverse of ``g``. - void _fq_nmod_poly_compose_mod_brent_kung_precomp_preinv(fq_nmod_struct* res, const fq_nmod_struct* f, long lenf, const fq_nmod_mat_t A, const fq_nmod_struct* h, long lenh, const fq_nmod_struct* hinv, long lenhinv, const fq_nmod_ctx_t ctx) + void _fq_nmod_poly_compose_mod_brent_kung_precomp_preinv(fq_nmod_struct* res, const fq_nmod_struct* f, slong lenf, const fq_nmod_mat_t A, const fq_nmod_struct* h, slong lenh, const fq_nmod_struct* hinv, slong lenhinv, const fq_nmod_ctx_t ctx) # Sets ``res`` to the composition `f(g)` modulo `h`. We require # that `h` is nonzero. We require that the ith row of `A` contains # `g^i` for `i=1,\ldots,\sqrt{\deg(h)}`, i.e. `A` is a @@ -986,7 +986,7 @@ cdef extern from "flint_wrap.h": # several modular composition of the form `f(g)` modulo `h` for # fixed `g` and `h`. - int _fq_nmod_poly_fprint_pretty(FILE *file, const fq_nmod_struct *poly, long len, const char *x, const fq_nmod_ctx_t ctx) + int _fq_nmod_poly_fprint_pretty(FILE *file, const fq_nmod_struct *poly, slong len, const char *x, const fq_nmod_ctx_t ctx) # Prints the pretty representation of ``(poly, len)`` to the stream # ``file``, using the string ``x`` to represent the indeterminate. # In case of success, returns a positive value. In case of failure, @@ -998,7 +998,7 @@ cdef extern from "flint_wrap.h": # In case of success, returns a positive value. In case of failure, # returns a non-positive value. - int _fq_nmod_poly_print_pretty(const fq_nmod_struct *poly, long len, const char *x, const fq_nmod_ctx_t ctx) + int _fq_nmod_poly_print_pretty(const fq_nmod_struct *poly, slong len, const char *x, const fq_nmod_ctx_t ctx) # Prints the pretty representation of ``(poly, len)`` to ``stdout``, # using the string ``x`` to represent the indeterminate. # In case of success, returns a positive value. In case of failure, @@ -1010,7 +1010,7 @@ cdef extern from "flint_wrap.h": # In case of success, returns a positive value. In case of failure, # returns a non-positive value. - int _fq_nmod_poly_fprint(FILE *file, const fq_nmod_struct *poly, long len, const fq_nmod_ctx_t ctx) + int _fq_nmod_poly_fprint(FILE *file, const fq_nmod_struct *poly, slong len, const fq_nmod_ctx_t ctx) # Prints the pretty representation of ``(poly, len)`` to the stream # ``file``. # In case of success, returns a positive value. In case of failure, @@ -1022,7 +1022,7 @@ cdef extern from "flint_wrap.h": # In case of success, returns a positive value. In case of failure, # returns a non-positive value. - int _fq_nmod_poly_print(const fq_nmod_struct *poly, long len, const fq_nmod_ctx_t ctx) + int _fq_nmod_poly_print(const fq_nmod_struct *poly, slong len, const fq_nmod_ctx_t ctx) # Prints the pretty representation of ``(poly, len)`` to ``stdout``. # In case of success, returns a positive value. In case of failure, # returns a non-positive value. @@ -1032,7 +1032,7 @@ cdef extern from "flint_wrap.h": # In case of success, returns a positive value. In case of failure, # returns a non-positive value. - char * _fq_nmod_poly_get_str(const fq_nmod_struct * poly, long len, const fq_nmod_ctx_t ctx) + char * _fq_nmod_poly_get_str(const fq_nmod_struct * poly, slong len, const fq_nmod_ctx_t ctx) # Returns the plain FLINT string representation of the polynomial # ``(poly, len)``. @@ -1040,7 +1040,7 @@ cdef extern from "flint_wrap.h": # Returns the plain FLINT string representation of the polynomial # ``poly``. - char * _fq_nmod_poly_get_str_pretty(const fq_nmod_struct * poly, long len, const char * x, const fq_nmod_ctx_t ctx) + char * _fq_nmod_poly_get_str_pretty(const fq_nmod_struct * poly, slong len, const char * x, const fq_nmod_ctx_t ctx) # Returns a pretty representation of the polynomial # ``(poly, len)`` using the null-terminated string ``x`` as the # variable name. @@ -1049,16 +1049,16 @@ cdef extern from "flint_wrap.h": # Returns a pretty representation of the polynomial ``poly`` using the # null-terminated string ``x`` as the variable name - void fq_nmod_poly_inflate(fq_nmod_poly_t result, const fq_nmod_poly_t input, unsigned long inflation, const fq_nmod_ctx_t ctx) + void fq_nmod_poly_inflate(fq_nmod_poly_t result, const fq_nmod_poly_t input, ulong inflation, const fq_nmod_ctx_t ctx) # Sets ``result`` to the inflated polynomial `p(x^n)` where # `p` is given by ``input`` and `n` is given by ``inflation``. - void fq_nmod_poly_deflate(fq_nmod_poly_t result, const fq_nmod_poly_t input, unsigned long deflation, const fq_nmod_ctx_t ctx) + void fq_nmod_poly_deflate(fq_nmod_poly_t result, const fq_nmod_poly_t input, ulong deflation, const fq_nmod_ctx_t ctx) # Sets ``result`` to the deflated polynomial `p(x^{1/n})` where # `p` is given by ``input`` and `n` is given by ``deflation``. # Requires `n > 0`. - unsigned long fq_nmod_poly_deflation(const fq_nmod_poly_t input, const fq_nmod_ctx_t ctx) + ulong fq_nmod_poly_deflation(const fq_nmod_poly_t input, const fq_nmod_ctx_t ctx) # Returns the largest integer by which ``input`` can be deflated. # As special cases, returns 0 if ``input`` is the zero polynomial # and 1 of ``input`` is a constant polynomial. diff --git a/src/sage/libs/flint/fq_nmod_poly_factor.pxd b/src/sage/libs/flint/fq_nmod_poly_factor.pxd index aae2f5f4336..83926d34452 100644 --- a/src/sage/libs/flint/fq_nmod_poly_factor.pxd +++ b/src/sage/libs/flint/fq_nmod_poly_factor.pxd @@ -20,11 +20,11 @@ cdef extern from "flint_wrap.h": void fq_nmod_poly_factor_clear(fq_nmod_poly_factor_t fac, const fq_nmod_ctx_t ctx) # Frees all memory associated with ``fac``. - void fq_nmod_poly_factor_realloc(fq_nmod_poly_factor_t fac, long alloc, const fq_nmod_ctx_t ctx) + void fq_nmod_poly_factor_realloc(fq_nmod_poly_factor_t fac, slong alloc, const fq_nmod_ctx_t ctx) # Reallocates the factor structure to provide space for # precisely ``alloc`` factors. - void fq_nmod_poly_factor_fit_length(fq_nmod_poly_factor_t fac, long len, const fq_nmod_ctx_t ctx) + void fq_nmod_poly_factor_fit_length(fq_nmod_poly_factor_t fac, slong len, const fq_nmod_ctx_t ctx) # Ensures that the factor structure has space for at least # ``len`` factors. This function takes care of the case of # repeated calls by always at least doubling the number of factors @@ -39,7 +39,7 @@ cdef extern from "flint_wrap.h": void fq_nmod_poly_factor_print(const fq_nmod_poly_factor_t fac, const fq_nmod_ctx_t ctx) # Prints the entries of ``fac`` to standard output. - void fq_nmod_poly_factor_insert(fq_nmod_poly_factor_t fac, const fq_nmod_poly_t poly, long exp, const fq_nmod_ctx_t ctx) + void fq_nmod_poly_factor_insert(fq_nmod_poly_factor_t fac, const fq_nmod_poly_t poly, slong exp, const fq_nmod_ctx_t ctx) # Inserts the factor ``poly`` with multiplicity ``exp`` into # the factorisation ``fac``. # If ``fac`` already contains ``poly``, then ``exp`` simply @@ -51,10 +51,10 @@ cdef extern from "flint_wrap.h": # repeatedly with the individual factors of ``fac``. # Does not support aliasing between ``res`` and ``fac``. - void fq_nmod_poly_factor_pow(fq_nmod_poly_factor_t fac, long exp, const fq_nmod_ctx_t ctx) + void fq_nmod_poly_factor_pow(fq_nmod_poly_factor_t fac, slong exp, const fq_nmod_ctx_t ctx) # Raises ``fac`` to the power ``exp``. - unsigned long fq_nmod_poly_remove(fq_nmod_poly_t f, const fq_nmod_poly_t p, const fq_nmod_ctx_t ctx) + ulong fq_nmod_poly_remove(fq_nmod_poly_t f, const fq_nmod_poly_t p, const fq_nmod_ctx_t ctx) # Removes the highest possible power of ``p`` from ``f`` and # returns the exponent. @@ -69,7 +69,7 @@ cdef extern from "flint_wrap.h": # Returns 1 if the polynomial ``f`` is irreducible, otherwise returns 0. # Uses Ben-Or's irreducibility test. - int _fq_nmod_poly_is_squarefree(const fq_nmod_struct * f, long len, const fq_nmod_ctx_t ctx) + int _fq_nmod_poly_is_squarefree(const fq_nmod_struct * f, slong len, const fq_nmod_ctx_t ctx) # Returns 1 if ``(f, len)`` is squarefree, and 0 otherwise. As a # special case, the zero polynomial is not considered squarefree. # There are no restrictions on the length. @@ -78,14 +78,14 @@ cdef extern from "flint_wrap.h": # Returns 1 if ``f`` is squarefree, and 0 otherwise. As a special # case, the zero polynomial is not considered squarefree. - int fq_nmod_poly_factor_equal_deg_prob(fq_nmod_poly_t factor, flint_rand_t state, const fq_nmod_poly_t pol, long d, const fq_nmod_ctx_t ctx) + int fq_nmod_poly_factor_equal_deg_prob(fq_nmod_poly_t factor, flint_rand_t state, const fq_nmod_poly_t pol, slong d, const fq_nmod_ctx_t ctx) # Probabilistic equal degree factorisation of ``pol`` into # irreducible factors of degree ``d``. If it passes, a factor is # placed in factor and 1 is returned, otherwise 0 is returned and # the value of factor is undetermined. # Requires that ``pol`` be monic, non-constant and squarefree. - void fq_nmod_poly_factor_equal_deg(fq_nmod_poly_factor_t factors, const fq_nmod_poly_t pol, long d, const fq_nmod_ctx_t ctx) + void fq_nmod_poly_factor_equal_deg(fq_nmod_poly_factor_t factors, const fq_nmod_poly_t pol, slong d, const fq_nmod_ctx_t ctx) # Assuming ``pol`` is a product of irreducible factors all of # degree ``d``, finds all those factors and places them in # factors. Requires that ``pol`` be monic, non-constant and @@ -96,7 +96,7 @@ cdef extern from "flint_wrap.h": # linear factor of ``input`` and places it in ``linfactor``. # Requires that ``input`` be monic and non-constant. - void fq_nmod_poly_factor_distinct_deg(fq_nmod_poly_factor_t res, const fq_nmod_poly_t poly, long * const *degs, const fq_nmod_ctx_t ctx) + void fq_nmod_poly_factor_distinct_deg(fq_nmod_poly_factor_t res, const fq_nmod_poly_t poly, slong * const *degs, const fq_nmod_ctx_t ctx) # Factorises a monic non-constant squarefree polynomial ``poly`` # of degree `n` into factors `f[d]` such that for `1 \leq d \leq n` # `f[d]` is the product of the monic irreducible factors of @@ -157,7 +157,7 @@ cdef extern from "flint_wrap.h": # performs a square-free factorisation, and finally runs # Kaltofen-Shoup on all the individual square-free factors. - void fq_nmod_poly_iterated_frobenius_preinv(fq_nmod_poly_t *rop, long n, const fq_nmod_poly_t v, const fq_nmod_poly_t vinv, const fq_nmod_ctx_t ctx) + void fq_nmod_poly_iterated_frobenius_preinv(fq_nmod_poly_t *rop, slong n, const fq_nmod_poly_t v, const fq_nmod_poly_t vinv, const fq_nmod_ctx_t ctx) # Sets ``rop[i]`` to be `x^{q^i} \bmod v` for `0 \le i < n`. # It is required that ``vinv`` is the inverse of the reverse of # ``v`` mod ``x^lenv``. diff --git a/src/sage/libs/flint/fq_nmod_vec.pxd b/src/sage/libs/flint/fq_nmod_vec.pxd index a24182e9d04..db11b49bbdd 100644 --- a/src/sage/libs/flint/fq_nmod_vec.pxd +++ b/src/sage/libs/flint/fq_nmod_vec.pxd @@ -12,62 +12,62 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - fq_nmod_struct * _fq_nmod_vec_init(long len, const fq_nmod_ctx_t ctx) + fq_nmod_struct * _fq_nmod_vec_init(slong len, const fq_nmod_ctx_t ctx) # Returns an initialised vector of ``fq_nmod``'s of given length. - void _fq_nmod_vec_clear(fq_nmod_struct * vec, long len, const fq_nmod_ctx_t ctx) + void _fq_nmod_vec_clear(fq_nmod_struct * vec, slong len, const fq_nmod_ctx_t ctx) # Clears the entries of ``(vec, len)`` and frees the space allocated # for ``vec``. - void _fq_nmod_vec_randtest(fq_nmod_struct * f, flint_rand_t state, long len, const fq_nmod_ctx_t ctx) + void _fq_nmod_vec_randtest(fq_nmod_struct * f, flint_rand_t state, slong len, const fq_nmod_ctx_t ctx) # Sets the entries of a vector of the given length to elements of # the finite field. - int _fq_nmod_vec_fprint(FILE * file, const fq_nmod_struct * vec, long len, const fq_nmod_ctx_t ctx) + int _fq_nmod_vec_fprint(FILE * file, const fq_nmod_struct * vec, slong len, const fq_nmod_ctx_t ctx) # Prints the vector of given length to the stream ``file``. The # format is the length followed by two spaces, then a space separated # list of coefficients. If the length is zero, only `0` is printed. # In case of success, returns a positive value. In case of failure, # returns a non-positive value. - int _fq_nmod_vec_print(const fq_nmod_struct * vec, long len, const fq_nmod_ctx_t ctx) + int _fq_nmod_vec_print(const fq_nmod_struct * vec, slong len, const fq_nmod_ctx_t ctx) # Prints the vector of given length to ``stdout``. # For further details, see ``_fq_nmod_vec_fprint()``. - void _fq_nmod_vec_set(fq_nmod_struct * vec1, const fq_nmod_struct * vec2, long len2, const fq_nmod_ctx_t ctx) + void _fq_nmod_vec_set(fq_nmod_struct * vec1, const fq_nmod_struct * vec2, slong len2, const fq_nmod_ctx_t ctx) # Makes a copy of ``(vec2, len2)`` into ``vec1``. - void _fq_nmod_vec_swap(fq_nmod_struct * vec1, fq_nmod_struct * vec2, long len2, const fq_nmod_ctx_t ctx) + void _fq_nmod_vec_swap(fq_nmod_struct * vec1, fq_nmod_struct * vec2, slong len2, const fq_nmod_ctx_t ctx) # Swaps the elements in ``(vec1, len2)`` and ``(vec2, len2)``. - void _fq_nmod_vec_zero(fq_nmod_struct * vec, long len, const fq_nmod_ctx_t ctx) + void _fq_nmod_vec_zero(fq_nmod_struct * vec, slong len, const fq_nmod_ctx_t ctx) # Zeros the entries of ``(vec, len)``. - void _fq_nmod_vec_neg(fq_nmod_struct * vec1, const fq_nmod_struct * vec2, long len2, const fq_nmod_ctx_t ctx) + void _fq_nmod_vec_neg(fq_nmod_struct * vec1, const fq_nmod_struct * vec2, slong len2, const fq_nmod_ctx_t ctx) # Negates ``(vec2, len2)`` and places it into ``vec1``. - int _fq_nmod_vec_equal(const fq_nmod_struct * vec1, const fq_nmod_struct * vec2, long len, const fq_nmod_ctx_t ctx) + int _fq_nmod_vec_equal(const fq_nmod_struct * vec1, const fq_nmod_struct * vec2, slong len, const fq_nmod_ctx_t ctx) # Compares two vectors of the given length and returns `1` if they are # equal, otherwise returns `0`. - int _fq_nmod_vec_is_zero(const fq_nmod_struct * vec, long len, const fq_nmod_ctx_t ctx) + int _fq_nmod_vec_is_zero(const fq_nmod_struct * vec, slong len, const fq_nmod_ctx_t ctx) # Returns `1` if ``(vec, len)`` is zero, and `0` otherwise. - void _fq_nmod_vec_add(fq_nmod_struct * res, const fq_nmod_struct * vec1, const fq_nmod_struct * vec2, long len2, const fq_nmod_ctx_t ctx) + void _fq_nmod_vec_add(fq_nmod_struct * res, const fq_nmod_struct * vec1, const fq_nmod_struct * vec2, slong len2, const fq_nmod_ctx_t ctx) # Sets ``(res, len2)`` to the sum of ``(vec1, len2)`` # and ``(vec2, len2)``. - void _fq_nmod_vec_sub(fq_nmod_struct * res, const fq_nmod_struct * vec1, const fq_nmod_struct * vec2, long len2, const fq_nmod_ctx_t ctx) + void _fq_nmod_vec_sub(fq_nmod_struct * res, const fq_nmod_struct * vec1, const fq_nmod_struct * vec2, slong len2, const fq_nmod_ctx_t ctx) # Sets ``(res, len2)`` to ``(vec1, len2)`` minus ``(vec2, len2)``. - void _fq_nmod_vec_scalar_addmul_fq_nmod(fq_nmod_struct * vec1, const fq_nmod_struct * vec2, long len2, const fq_nmod_t c, const fq_nmod_ctx_t ctx) + void _fq_nmod_vec_scalar_addmul_fq_nmod(fq_nmod_struct * vec1, const fq_nmod_struct * vec2, slong len2, const fq_nmod_t c, const fq_nmod_ctx_t ctx) # Adds ``(vec2, len2)`` times `c` to ``(vec1, len2)``, where # `c` is a ``fq_nmod_t``. - void _fq_nmod_vec_scalar_submul_fq_nmod(fq_nmod_struct * vec1, const fq_nmod_struct * vec2, long len2, const fq_nmod_t c, const fq_nmod_ctx_t ctx) + void _fq_nmod_vec_scalar_submul_fq_nmod(fq_nmod_struct * vec1, const fq_nmod_struct * vec2, slong len2, const fq_nmod_t c, const fq_nmod_ctx_t ctx) # Subtracts ``(vec2, len2)`` times `c` from ``(vec1, len2)``, # where `c` is a ``fq_nmod_t``. - void _fq_nmod_vec_dot(fq_nmod_t res, const fq_nmod_struct * vec1, const fq_nmod_struct * vec2, long len2, const fq_nmod_ctx_t ctx) + void _fq_nmod_vec_dot(fq_nmod_t res, const fq_nmod_struct * vec1, const fq_nmod_struct * vec2, slong len2, const fq_nmod_ctx_t ctx) # Sets ``res`` to the dot product of (``vec1``, ``len``) # and (``vec2``, ``len``). diff --git a/src/sage/libs/flint/fq_poly.pxd b/src/sage/libs/flint/fq_poly.pxd new file mode 100644 index 00000000000..ae28b7a3461 --- /dev/null +++ b/src/sage/libs/flint/fq_poly.pxd @@ -0,0 +1,1075 @@ +# distutils: libraries = flint +# distutils: depends = flint/fq_poly.h + +################################################################################ +# This file is auto-generated. Do not modify by hand +################################################################################ + +from libc.stdio cimport FILE +from sage.libs.gmp.types cimport * +from sage.libs.mpfr.types cimport * +from sage.libs.flint.types cimport * + +cdef extern from "flint_wrap.h": + + void fq_poly_init(fq_poly_t poly, const fq_ctx_t ctx) + # Initialises ``poly`` for use, with context ctx, and setting its + # length to zero. A corresponding call to :func:`fq_poly_clear` + # must be made after finishing with the ``fq_poly_t`` to free the + # memory used by the polynomial. + + void fq_poly_init2(fq_poly_t poly, slong alloc, const fq_ctx_t ctx) + # Initialises ``poly`` with space for at least ``alloc`` + # coefficients and sets the length to zero. The allocated + # coefficients are all set to zero. A corresponding call to + # :func:`fq_poly_clear` must be made after finishing with the + # ``fq_poly_t`` to free the memory used by the polynomial. + + void fq_poly_realloc(fq_poly_t poly, slong alloc, const fq_ctx_t ctx) + # Reallocates the given polynomial to have space for ``alloc`` + # coefficients. If ``alloc`` is zero the polynomial is cleared + # and then reinitialised. If the current length is greater than + # ``alloc`` the polynomial is first truncated to length + # ``alloc``. + + void fq_poly_fit_length(fq_poly_t poly, slong len, const fq_ctx_t ctx) + # If ``len`` is greater than the number of coefficients currently + # allocated, then the polynomial is reallocated to have space for at + # least ``len`` coefficients. No data is lost when calling this + # function. + # The function efficiently deals with the case where + # ``fit_length`` is called many times in small increments by at + # least doubling the number of allocated coefficients when length is + # larger than the number of coefficients currently allocated. + + void _fq_poly_set_length(fq_poly_t poly, slong newlen, const fq_ctx_t ctx) + # Sets the coefficients of ``poly`` beyond ``len`` to zero and + # sets the length of ``poly`` to ``len``. + + void fq_poly_clear(fq_poly_t poly, const fq_ctx_t ctx) + # Clears the given polynomial, releasing any memory used. It must + # be reinitialised in order to be used again. + + void _fq_poly_normalise(fq_poly_t poly, const fq_ctx_t ctx) + # Sets the length of ``poly`` so that the top coefficient is + # non-zero. If all coefficients are zero, the length is set to + # zero. This function is mainly used internally, as all functions + # guarantee normalisation. + + void _fq_poly_normalise2(const fq_struct *poly, slong *length, const fq_ctx_t ctx) + # Sets the length ``length`` of ``(poly,length)`` so that the + # top coefficient is non-zero. If all coefficients are zero, the + # length is set to zero. This function is mainly used internally, as + # all functions guarantee normalisation. + + void fq_poly_truncate(fq_poly_t poly, slong newlen, const fq_ctx_t ctx) + # Truncates the polynomial to length at most `n`. + + void fq_poly_set_trunc(fq_poly_t poly1, fq_poly_t poly2, slong newlen, const fq_ctx_t ctx) + # Sets ``poly1`` to ``poly2`` truncated to length `n`. + + void _fq_poly_reverse(fq_struct* output, const fq_struct* input, slong len, slong m, const fq_ctx_t ctx) + # Sets ``output`` to the reverse of ``input``, which is of + # length ``len``, but thinking of it as a polynomial of + # length ``m``, notionally zero-padded if necessary. The + # length ``m`` must be non-negative, but there are no other + # restrictions. The polynomial ``output`` must have space for + # ``m`` coefficients. + + void fq_poly_reverse(fq_poly_t output, const fq_poly_t input, slong m, const fq_ctx_t ctx) + # Sets ``output`` to the reverse of ``input``, thinking of it + # as a polynomial of length ``m``, notionally zero-padded if + # necessary). The length ``m`` must be non-negative, but there + # are no other restrictions. The output polynomial will be set to + # length ``m`` and then normalised. + + slong fq_poly_degree(const fq_poly_t poly, const fq_ctx_t ctx) + # Returns the degree of the polynomial ``poly``. + + slong fq_poly_length(const fq_poly_t poly, const fq_ctx_t ctx) + # Returns the length of the polynomial ``poly``. + + fq_struct * fq_poly_lead(const fq_poly_t poly, const fq_ctx_t ctx) + # Returns a pointer to the leading coefficient of ``poly``, or + # ``NULL`` if ``poly`` is the zero polynomial. + + void fq_poly_randtest(fq_poly_t f, flint_rand_t state, slong len, const fq_ctx_t ctx) + # Sets `f` to a random polynomial of length at most ``len`` + # with entries in the field described by ``ctx``. + + void fq_poly_randtest_not_zero(fq_poly_t f, flint_rand_t state, slong len, const fq_ctx_t ctx) + # Same as ``fq_poly_randtest`` but guarantees that the polynomial + # is not zero. + + void fq_poly_randtest_monic(fq_poly_t f, flint_rand_t state, slong len, const fq_ctx_t ctx) + # Sets `f` to a random monic polynomial of length ``len`` with + # entries in the field described by ``ctx``. + + void fq_poly_randtest_irreducible(fq_poly_t f, flint_rand_t state, slong len, const fq_ctx_t ctx) + # Sets `f` to a random monic, irreducible polynomial of length + # ``len`` with entries in the field described by ``ctx``. + + void _fq_poly_set(fq_struct *rop, const fq_struct *op, slong len, const fq_ctx_t ctx) + # Sets ``(rop, len``) to ``(op, len)``. + + void fq_poly_set(fq_poly_t poly1, const fq_poly_t poly2, const fq_ctx_t ctx) + # Sets the polynomial ``poly1`` to the polynomial ``poly2``. + + void fq_poly_set_fq(fq_poly_t poly, const fq_t c, const fq_ctx_t ctx) + # Sets the polynomial ``poly`` to ``c``. + + void fq_poly_set_fmpz_mod_poly(fq_poly_t rop, const fmpz_mod_poly_t op, const fq_ctx_t ctx) + # Sets the polynomial ``rop`` to the polynomial ``op`` + + void fq_poly_set_nmod_poly(fq_poly_t rop, const nmod_poly_t op, const fq_ctx_t ctx) + # Sets the polynomial ``rop`` to the polynomial ``op`` + + void fq_poly_swap(fq_poly_t op1, fq_poly_t op2, const fq_ctx_t ctx) + # Swaps the two polynomials ``op1`` and ``op2``. + + void _fq_poly_zero(fq_struct *rop, slong len, const fq_ctx_t ctx) + # Sets ``(rop, len)`` to the zero polynomial. + + void fq_poly_zero(fq_poly_t poly, const fq_ctx_t ctx) + # Sets ``poly`` to the zero polynomial. + + void fq_poly_one(fq_poly_t poly, const fq_ctx_t ctx) + # Sets ``poly`` to the constant polynomial `1`. + + void fq_poly_gen(fq_poly_t poly, const fq_ctx_t ctx) + # Sets ``poly`` to the polynomial `x`. + + void fq_poly_make_monic(fq_poly_t rop, const fq_poly_t op, const fq_ctx_t ctx) + # Sets ``rop`` to ``op``, normed to have leading coefficient 1. + + void _fq_poly_make_monic(fq_struct *rop, const fq_struct *op, slong length, const fq_ctx_t ctx) + # Sets ``rop`` to ``(op,length)``, normed to have leading coefficient 1. + # Assumes that ``rop`` has enough space for the polynomial, assumes that + # ``op`` is not zero (and thus has an invertible leading coefficient). + + void fq_poly_get_coeff(fq_t x, const fq_poly_t poly, slong n, const fq_ctx_t ctx) + # Sets `x` to the coefficient of `X^n` in ``poly``. + + void fq_poly_set_coeff(fq_poly_t poly, slong n, const fq_t x, const fq_ctx_t ctx) + # Sets the coefficient of `X^n` in ``poly`` to `x`. + + void fq_poly_set_coeff_fmpz(fq_poly_t poly, slong n, const fmpz_t x, const fq_ctx_t ctx) + # Sets the coefficient of `X^n` in the polynomial to `x`, + # assuming `n \geq 0`. + + int fq_poly_equal(const fq_poly_t poly1, const fq_poly_t poly2, const fq_ctx_t ctx) + # Returns nonzero if the two polynomials ``poly1`` and ``poly2`` + # are equal, otherwise returns zero. + + int fq_poly_equal_trunc(const fq_poly_t poly1, const fq_poly_t poly2, slong n, const fq_ctx_t ctx) + # Notionally truncate ``poly1`` and ``poly2`` to length `n` and + # return nonzero if they are equal, otherwise return zero. + + int fq_poly_is_zero(const fq_poly_t poly, const fq_ctx_t ctx) + # Returns whether the polynomial ``poly`` is the zero polynomial. + + int fq_poly_is_one(const fq_poly_t op, const fq_ctx_t ctx) + # Returns whether the polynomial ``poly`` is equal + # to the constant polynomial `1`. + + int fq_poly_is_gen(const fq_poly_t op, const fq_ctx_t ctx) + # Returns whether the polynomial ``poly`` is equal + # to the polynomial `x`. + + int fq_poly_is_unit(const fq_poly_t op, const fq_ctx_t ctx) + # Returns whether the polynomial ``poly`` is a unit in the polynomial + # ring `\mathbf{F}_q[X]`, i.e. if it has degree `0` and is non-zero. + + int fq_poly_equal_fq(const fq_poly_t poly, const fq_t c, const fq_ctx_t ctx) + # Returns whether the polynomial ``poly`` is equal the (constant) + # `\mathbf{F}_q` element ``c`` + + void _fq_poly_add(fq_struct *res, const fq_struct *poly1, slong len1, const fq_struct *poly2, slong len2, const fq_ctx_t ctx) + # Sets ``res`` to the sum of ``(poly1,len1)`` and ``(poly2,len2)``. + + void fq_poly_add(fq_poly_t res, const fq_poly_t poly1, const fq_poly_t poly2, const fq_ctx_t ctx) + # Sets ``res`` to the sum of ``poly1`` and ``poly2``. + + void fq_poly_add_si(fq_poly_t res, const fq_poly_t poly1, slong c, const fq_ctx_t ctx) + # Sets ``res`` to the sum of ``poly1`` and ``c``. + + void fq_poly_add_series(fq_poly_t res, const fq_poly_t poly1, const fq_poly_t poly2, slong n, const fq_ctx_t ctx) + # Notionally truncate ``poly1`` and ``poly2`` to length ``n`` and set + # ``res`` to the sum. + + void _fq_poly_sub(fq_struct *res, const fq_struct *poly1, slong len1, const fq_struct *poly2, slong len2, const fq_ctx_t ctx) + # Sets ``res`` to the difference of ``(poly1,len1)`` and ``(poly2,len2)``. + + void fq_poly_sub(fq_poly_t res, const fq_poly_t poly1, const fq_poly_t poly2, const fq_ctx_t ctx) + # Sets ``res`` to the difference of ``poly1`` and ``poly2``. + + void fq_poly_sub_series(fq_poly_t res, const fq_poly_t poly1, const fq_poly_t poly2, slong n, const fq_ctx_t ctx) + # Notionally truncate ``poly1`` and ``poly2`` to length ``n`` and set + # ``res`` to the difference. + + void _fq_poly_neg(fq_struct *rop, const fq_struct *op, slong len, const fq_ctx_t ctx) + # Sets ``rop`` to the additive inverse of ``(poly,len)``. + + void fq_poly_neg(fq_poly_t res, const fq_poly_t poly, const fq_ctx_t ctx) + # Sets ``res`` to the additive inverse of ``poly``. + + void _fq_poly_scalar_mul_fq(fq_struct *rop, const fq_struct *op, slong len, const fq_t x, const fq_ctx_t ctx) + # Sets ``(rop,len)`` to the product of ``(op,len)`` by the + # scalar ``x``, in the context defined by ``ctx``. + + void fq_poly_scalar_mul_fq(fq_poly_t rop, const fq_poly_t op, const fq_t x, const fq_ctx_t ctx) + # Sets ``rop`` to the product of ``op`` by the scalar ``x``, in the context + # defined by ``ctx``. + + void _fq_poly_scalar_addmul_fq(fq_struct *rop, const fq_struct *op, slong len, const fq_t x, const fq_ctx_t ctx) + # Adds to ``(rop,len)`` the product of ``(op,len)`` by the + # scalar ``x``, in the context defined by ``ctx``. + # In particular, assumes the same length for ``op`` and + # ``rop``. + + void fq_poly_scalar_addmul_fq(fq_poly_t rop, const fq_poly_t op, const fq_t x, const fq_ctx_t ctx) + # Adds to ``rop`` the product of ``op`` by the + # scalar ``x``, in the context defined by ``ctx``. + + void _fq_poly_scalar_submul_fq(fq_struct *rop, const fq_struct *op, slong len, const fq_t x, const fq_ctx_t ctx) + # Subtracts from ``(rop,len)`` the product of ``(op,len)`` by the + # scalar ``x``, in the context defined by ``ctx``. + # In particular, assumes the same length for ``op`` and + # ``rop``. + + void fq_poly_scalar_submul_fq(fq_poly_t rop, const fq_poly_t op, const fq_t x, const fq_ctx_t ctx) + # Subtracts from ``rop`` the product of ``op`` by the + # scalar ``x``, in the context defined by ``ctx``. + + void _fq_poly_scalar_div_fq(fq_struct *rop, const fq_struct *op, slong len, const fq_t x, const fq_ctx_t ctx) + # Sets ``(rop,len)`` to the quotient of ``(op,len)`` by the + # scalar ``x``, in the context defined by ``ctx``. An exception is raised + # if ``x`` is zero. + + void fq_poly_scalar_div_fq(fq_poly_t rop, const fq_poly_t op, const fq_t x, const fq_ctx_t ctx) + # Sets ``rop`` to the quotient of ``op`` by the scalar ``x``, in the context + # defined by ``ctx``. An exception is raised if ``x`` is zero. + + void _fq_poly_mul_classical(fq_struct *rop, const fq_struct *op1, slong len1, const fq_struct *op2, slong len2, const fq_ctx_t ctx) + # Sets ``(rop, len1 + len2 - 1)`` to the product of ``(op1, len1)`` + # and ``(op2, len2)``, assuming that ``len1`` is at least ``len2`` + # and neither is zero. + # Permits zero padding. Does not support aliasing of ``rop`` + # with either ``op1`` or ``op2``. + + void fq_poly_mul_classical(fq_poly_t rop, const fq_poly_t op1, const fq_poly_t op2, const fq_ctx_t ctx) + # Sets ``rop`` to the product of ``op1`` and ``op2`` + # using classical polynomial multiplication. + + void _fq_poly_mul_reorder(fq_struct *rop, const fq_struct *op1, slong len1, const fq_struct *op2, slong len2, const fq_ctx_t ctx) + # Sets ``(rop, len1 + len2 - 1)`` to the product of ``(op1, len1)`` + # and ``(op2, len2)``, assuming that ``len1`` and ``len2`` are + # non-zero. + # Permits zero padding. Supports aliasing. + + void fq_poly_mul_reorder(fq_poly_t rop, const fq_poly_t op1, const fq_poly_t op2, const fq_ctx_t ctx) + # Sets ``rop`` to the product of ``op1`` and ``op2``, + # reordering the two indeterminates `X` and `Y` when viewing + # the polynomials as elements of `\mathbf{F}_p[X,Y]`. + # Suppose `\mathbf{F}_q = \mathbf{F}_p[X]/ (f(X))` and recall + # that elements of `\mathbf{F}_q` are internally represented + # by elements of type ``fmpz_poly``. For small degree extensions + # but polynomials in `\mathbf{F}_q[Y]` of large degree `n`, we + # change the representation to + # .. math :: + # \begin{split} + # g(Y) & = \sum_{i=0}^{n} a_i(X) Y^i \\ + # & = \sum_{j=0}^{d} \sum_{i=0}^{n} \text{Coeff}(a_i(X), j) Y^i. + # \end{split} + # This allows us to use a poor algorithm (such as classical multiplication) + # in the `X`-direction and leverage the existing fast integer + # multiplication routines in the `Y`-direction where the polynomial + # degree `n` is large. + + void _fq_poly_mul_univariate(fq_struct *rop, const fq_struct *op1, slong len1, const fq_struct *op2, slong len2, const fq_ctx_t ctx) + # Sets ``(rop, len1 + len2 - 1)`` to the product of ``(op1, len1)`` + # and ``(op2, len2)``. + # Permits zero padding and places no assumptions on the + # lengths ``len1`` and ``len2``. Supports aliasing. + + void fq_poly_mul_univariate(fq_poly_t rop, const fq_poly_t op1, const fq_poly_t op2, const fq_ctx_t ctx) + # Sets ``rop`` to the product of ``op1`` and ``op2`` + # using a bivariate to univariate transformation and reducing + # this problem to multiplying two univariate polynomials. + + void _fq_poly_mul_KS(fq_struct *rop, const fq_struct *op1, slong len1, const fq_struct *op2, slong len2, const fq_ctx_t ctx) + # Sets ``(rop, len1 + len2 - 1)`` to the product of ``(op1, len1)`` + # and ``(op2, len2)``. + # Permits zero padding and places no assumptions on the + # lengths ``len1`` and ``len2``. Supports aliasing. + + void fq_poly_mul_KS(fq_poly_t rop, const fq_poly_t op1, const fq_poly_t op2, const fq_ctx_t ctx) + # Sets ``rop`` to the product of ``op1`` and ``op2`` + # using Kronecker substitution, that is, by encoding each + # coefficient in `\mathbf{F}_{q}` as an integer and reducing + # this problem to multiplying two polynomials over the integers. + + void _fq_poly_mul(fq_struct *rop, const fq_struct *op1, slong len1, const fq_struct *op2, slong len2, const fq_ctx_t ctx) + # Sets ``(rop, len1 + len2 - 1)`` to the product of ``(op1, len1)`` + # and ``(op2, len2)``, choosing an appropriate algorithm. + # Permits zero padding. Does not support aliasing. + + void fq_poly_mul(fq_poly_t rop, const fq_poly_t op1, const fq_poly_t op2, const fq_ctx_t ctx) + # Sets ``rop`` to the product of ``op1`` and ``op2``, + # choosing an appropriate algorithm. + + void _fq_poly_mullow_classical(fq_struct *rop, const fq_struct *op1, slong len1, const fq_struct *op2, slong len2, slong n, const fq_ctx_t ctx) + # Sets ``(rop, n)`` to the first `n` coefficients of ``(op1, len1)`` + # multiplied by ``(op2, len2)``. + # Assumes ``0 < n <= len1 + len2 - 1``. Assumes neither ``len1`` nor + # ``len2`` is zero. + + void fq_poly_mullow_classical(fq_poly_t rop, const fq_poly_t op1, const fq_poly_t op2, slong n, const fq_ctx_t ctx) + # Sets ``rop`` to the product of ``poly1`` and ``poly2``, computed + # using the classical or schoolbook method. + + void _fq_poly_mullow_univariate(fq_struct *rop, const fq_struct *op1, slong len1, const fq_struct *op2, slong len2, slong n, const fq_ctx_t ctx) + # Sets ``(rop, n)`` to the lowest `n` coefficients of the product of + # ``(op1, len1)`` and ``(op2, len2)``, computed using a + # bivariate to univariate transformation. + # Assumes that ``len1`` and ``len2`` are positive, but does allow + # for the polynomials to be zero-padded. The polynomials may be zero, + # too. Assumes `n` is positive. Supports aliasing between ``res``, + # ``poly1`` and ``poly2``. + + void fq_poly_mullow_univariate(fq_poly_t rop, const fq_poly_t op1, const fq_poly_t op2, slong n, const fq_ctx_t ctx) + # Sets ``rop`` to the lowest `n` coefficients of the product of + # ``op1`` and ``op2``, computed using a bivariate to univariate + # transformation. + + void _fq_poly_mullow_KS(fq_struct *rop, const fq_struct *op1, slong len1, const fq_struct *op2, slong len2, slong n, const fq_ctx_t ctx) + # Sets ``(rop, n)`` to the lowest `n` coefficients of the product of + # ``(op1, len1)`` and ``(op2, len2)``. + # Assumes that ``len1`` and ``len2`` are positive, but does allow + # for the polynomials to be zero-padded. The polynomials may be zero, + # too. Assumes `n` is positive. Supports aliasing between ``rop``, + # ``op1`` and ``op2``. + + void fq_poly_mullow_KS(fq_poly_t rop, const fq_poly_t op1, const fq_poly_t op2, slong n, const fq_ctx_t ctx) + # Sets ``rop`` to the lowest `n` coefficients of the product of + # ``op1`` and ``op2``. + + void _fq_poly_mullow(fq_struct *rop, const fq_struct *op1, slong len1, const fq_struct *op2, slong len2, slong n, const fq_ctx_t ctx) + # Sets ``(rop, n)`` to the lowest `n` coefficients of the product of + # ``(op1, len1)`` and ``(op2, len2)``. + # Assumes ``0 < n <= len1 + len2 - 1``. Allows for zero-padding in + # the inputs. Does not support aliasing between the inputs and the output. + + void fq_poly_mullow(fq_poly_t rop, const fq_poly_t op1, const fq_poly_t op2, slong n, const fq_ctx_t ctx) + # Sets ``rop`` to the lowest `n` coefficients of the product of + # ``op1`` and ``op2``. + + void _fq_poly_mulhigh_classical(fq_struct *res, const fq_struct *poly1, slong len1, const fq_struct *poly2, slong len2, slong start, const fq_ctx_t ctx) + # Computes the product of ``(poly1, len1)`` and ``(poly2, len2)`` + # and writes the coefficients from ``start`` onwards into the high + # coefficients of ``res``, the remaining coefficients being arbitrary + # but reduced. Assumes that ``len1 >= len2 > 0``. Aliasing of inputs + # and output is not permitted. Algorithm is classical multiplication. + + void fq_poly_mulhigh_classical(fq_poly_t res, const fq_poly_t poly1, const fq_poly_t poly2, slong start, const fq_ctx_t ctx) + # Computes the product of ``poly1`` and ``poly2`` and writes the + # coefficients from ``start`` onwards into the high coefficients of + # ``res``, the remaining coefficients being arbitrary but reduced. + # Algorithm is classical multiplication. + + void _fq_poly_mulhigh(fq_struct *res, const fq_struct *poly1, slong len1, const fq_struct *poly2, slong len2, slong start, fq_ctx_t ctx) + # Computes the product of ``(poly1, len1)`` and ``(poly2, len2)`` + # and writes the coefficients from ``start`` onwards into the high + # coefficients of ``res``, the remaining coefficients being arbitrary + # but reduced. Assumes that ``len1 >= len2 > 0``. Aliasing of inputs + # and output is not permitted. + + void fq_poly_mulhigh(fq_poly_t res, const fq_poly_t poly1, const fq_poly_t poly2, slong start, const fq_ctx_t ctx) + # Computes the product of ``poly1`` and ``poly2`` and writes the + # coefficients from ``start`` onwards into the high coefficients of + # ``res``, the remaining coefficients being arbitrary but reduced. + + void _fq_poly_mulmod(fq_struct* res, const fq_struct* poly1, slong len1, const fq_struct* poly2, slong len2, const fq_struct* f, slong lenf, const fq_ctx_t ctx) + # Sets ``res`` to the remainder of the product of ``poly1`` + # and ``poly2`` upon polynomial division by ``f``. + # It is required that ``len1 + len2 - lenf > 0``, which is + # equivalent to requiring that the result will actually be + # reduced. Otherwise, simply use ``_fq_poly_mul`` instead. + # Aliasing of ``f`` and ``res`` is not permitted. + + void fq_poly_mulmod(fq_poly_t res, const fq_poly_t poly1, const fq_poly_t poly2, const fq_poly_t f, const fq_ctx_t ctx) + # Sets ``res`` to the remainder of the product of ``poly1`` + # and ``poly2`` upon polynomial division by ``f``. + + void _fq_poly_mulmod_preinv(fq_struct* res, const fq_struct* poly1, slong len1, const fq_struct* poly2, slong len2, const fq_struct* f, slong lenf, const fq_struct* finv, slong lenfinv, const fq_ctx_t ctx) + # Sets ``res`` to the remainder of the product of ``poly1`` + # and ``poly2`` upon polynomial division by ``f``. + # It is required that ``finv`` is the inverse of the reverse of + # ``f`` mod ``x^lenf``. + # Aliasing of ``res`` with any of the inputs is not permitted. + + void fq_poly_mulmod_preinv(fq_poly_t res, const fq_poly_t poly1, const fq_poly_t poly2, const fq_poly_t f, const fq_poly_t finv, const fq_ctx_t ctx) + # Sets ``res`` to the remainder of the product of ``poly1`` + # and ``poly2`` upon polynomial division by ``f``. ``finv`` + # is the inverse of the reverse of ``f``. + + void _fq_poly_sqr_classical(fq_struct *rop, const fq_struct *op, slong len, const fq_ctx_t ctx) + # Sets ``(rop, 2*len - 1)`` to the square of ``(op, len)``, + # assuming that ``(op,len)`` is not zero and using classical + # polynomial multiplication. + # Permits zero padding. Does not support aliasing of ``rop`` + # with either ``op1`` or ``op2``. + + void fq_poly_sqr_classical(fq_poly_t rop, const fq_poly_t op, const fq_ctx_t ctx) + # Sets ``rop`` to the square of ``op`` using classical + # polynomial multiplication. + + void _fq_poly_sqr_reorder(fq_struct *rop, const fq_struct *op, slong len, const fq_ctx_t ctx) + # Sets ``(rop, 2*len- 1)`` to the square of ``(op, len)``, + # assuming that ``len`` is not zero reordering the two indeterminates + # `X` and `Y` when viewing the polynomials as elements of `\mathbf{F}_p[X,Y]`. + # Permits zero padding. Supports aliasing. + + void fq_poly_sqr_reorder(fq_poly_t rop, const fq_poly_t op, const fq_ctx_t ctx) + # Sets ``rop`` to the square of ``op``, + # assuming that ``len`` is not zero reordering the two indeterminates + # `X` and `Y` when viewing the polynomials as elements of `\mathbf{F}_p[X,Y]`. + # See ``fq_poly_mul_reorder``. + + void _fq_poly_sqr_KS(fq_struct *rop, const fq_struct *op, slong len, const fq_ctx_t ctx) + # Sets ``(rop, 2*len - 1)`` to the square of ``(op, len)``. + # Permits zero padding and places no assumptions on the + # lengths ``len1`` and ``len2``. Supports aliasing. + + void fq_poly_sqr_KS(fq_poly_t rop, const fq_poly_t op, const fq_ctx_t ctx) + # Sets ``rop`` to the square ``op`` using Kronecker substitution, + # that is, by encoding each coefficient in `\mathbf{F}_{q}` as an integer + # and reducing this problem to multiplying two polynomials over the integers. + + void _fq_poly_sqr(fq_struct *rop, const fq_struct *op, slong len, const fq_ctx_t ctx) + # Sets ``(rop, 2* len - 1)`` to the square of ``(op, len)``, + # choosing an appropriate algorithm. + # Permits zero padding. Does not support aliasing. + + void fq_poly_sqr(fq_poly_t rop, const fq_poly_t op, const fq_ctx_t ctx) + # Sets ``rop`` to the square of ``op``, + # choosing an appropriate algorithm. + + void _fq_poly_pow(fq_struct *rop, const fq_struct *op, slong len, ulong e, const fq_ctx_t ctx) + # Sets ``rop = op^e``, assuming that ``e, len > 0`` and that + # ``rop`` has space for ``e*(len - 1) + 1`` coefficients. Does + # not support aliasing. + + void fq_poly_pow(fq_poly_t rop, const fq_poly_t op, ulong e, const fq_ctx_t ctx) + # Computes ``rop = op^e``. If `e` is zero, returns one, + # so that in particular ``0^0 = 1``. + + void _fq_poly_powmod_ui_binexp(fq_struct* res, const fq_struct* poly, ulong e, const fq_struct* f, slong lenf, const fq_ctx_t ctx) + # Sets ``res`` to ``poly`` raised to the power ``e`` modulo + # ``f``, using binary exponentiation. We require ``e > 0``. + # We require ``lenf > 1``. It is assumed that ``poly`` is + # already reduced modulo ``f`` and zero-padded as necessary to + # have length exactly ``lenf - 1``. The output ``res`` must + # have room for ``lenf - 1`` coefficients. + + void fq_poly_powmod_ui_binexp(fq_poly_t res, const fq_poly_t poly, ulong e, const fq_poly_t f, const fq_ctx_t ctx) + # Sets ``res`` to ``poly`` raised to the power ``e`` modulo + # ``f``, using binary exponentiation. We require ``e >= 0``. + + void _fq_poly_powmod_ui_binexp_preinv(fq_struct* res, const fq_struct* poly, ulong e, const fq_struct* f, slong lenf, const fq_struct* finv, slong lenfinv, const fq_ctx_t ctx) + # Sets ``res`` to ``poly`` raised to the power ``e`` modulo + # ``f``, using binary exponentiation. We require ``e > 0``. + # We require ``finv`` to be the inverse of the reverse of + # ``f``. + # We require ``lenf > 1``. It is assumed that ``poly`` is + # already reduced modulo ``f`` and zero-padded as necessary to + # have length exactly ``lenf - 1``. The output ``res`` must + # have room for ``lenf - 1`` coefficients. + + void fq_poly_powmod_ui_binexp_preinv(fq_poly_t res, const fq_poly_t poly, ulong e, const fq_poly_t f, const fq_poly_t finv, const fq_ctx_t ctx) + # Sets ``res`` to ``poly`` raised to the power ``e`` modulo + # ``f``, using binary exponentiation. We require ``e >= 0``. + # We require ``finv`` to be the inverse of the reverse of + # ``f``. + + void _fq_poly_powmod_fmpz_binexp(fq_struct* res, const fq_struct* poly, const fmpz_t e, const fq_struct* f, slong lenf, const fq_ctx_t ctx) + # Sets ``res`` to ``poly`` raised to the power ``e`` modulo + # ``f``, using binary exponentiation. We require ``e > 0``. + # We require ``lenf > 1``. It is assumed that ``poly`` is + # already reduced modulo ``f`` and zero-padded as necessary to + # have length exactly ``lenf - 1``. The output ``res`` must + # have room for ``lenf - 1`` coefficients. + + void fq_poly_powmod_fmpz_binexp(fq_poly_t res, const fq_poly_t poly, const fmpz_t e, const fq_poly_t f, const fq_ctx_t ctx) + # Sets ``res`` to ``poly`` raised to the power ``e`` modulo + # ``f``, using binary exponentiation. We require ``e >= 0``. + + void _fq_poly_powmod_fmpz_binexp_preinv(fq_struct* res, const fq_struct* poly, const fmpz_t e, const fq_struct* f, slong lenf, const fq_struct* finv, slong lenfinv, const fq_ctx_t ctx) + # Sets ``res`` to ``poly`` raised to the power ``e`` modulo + # ``f``, using binary exponentiation. We require ``e > 0``. + # We require ``finv`` to be the inverse of the reverse of + # ``f``. + # We require ``lenf > 1``. It is assumed that ``poly`` is + # already reduced modulo ``f`` and zero-padded as necessary to + # have length exactly ``lenf - 1``. The output ``res`` must + # have room for ``lenf - 1`` coefficients. + + void fq_poly_powmod_fmpz_binexp_preinv(fq_poly_t res, const fq_poly_t poly, const fmpz_t e, const fq_poly_t f, const fq_poly_t finv, const fq_ctx_t ctx) + # Sets ``res`` to ``poly`` raised to the power ``e`` modulo + # ``f``, using binary exponentiation. We require ``e >= 0``. + # We require ``finv`` to be the inverse of the reverse of + # ``f``. + + void _fq_poly_powmod_fmpz_sliding_preinv(fq_struct* res, const fq_struct* poly, const fmpz_t e, ulong k, const fq_struct* f, slong lenf, const fq_struct* finv, slong lenfinv, const fq_ctx_t ctx) + # Sets ``res`` to ``poly`` raised to the power ``e`` modulo + # ``f``, using sliding-window exponentiation with window size + # ``k``. We require ``e > 0``. We require ``finv`` to be + # the inverse of the reverse of ``f``. If ``k`` is set to + # zero, then an "optimum" size will be selected automatically base + # on ``e``. + # We require ``lenf > 1``. It is assumed that ``poly`` is + # already reduced modulo ``f`` and zero-padded as necessary to + # have length exactly ``lenf - 1``. The output ``res`` must + # have room for ``lenf - 1`` coefficients. + + void fq_poly_powmod_fmpz_sliding_preinv(fq_poly_t res, const fq_poly_t poly, const fmpz_t e, ulong k, const fq_poly_t f, const fq_poly_t finv, const fq_ctx_t ctx) + # Sets ``res`` to ``poly`` raised to the power ``e`` modulo + # ``f``, using sliding-window exponentiation with window size + # ``k``. We require ``e >= 0``. We require ``finv`` to be + # the inverse of the reverse of ``f``. If ``k`` is set to + # zero, then an "optimum" size will be selected automatically base + # on ``e``. + + void _fq_poly_powmod_x_fmpz_preinv(fq_struct * res, const fmpz_t e, const fq_struct * f, slong lenf, const fq_struct * finv, slong lenfinv, const fq_ctx_t ctx) + # Sets ``res`` to ``x`` raised to the power ``e`` modulo ``f``, + # using sliding window exponentiation. We require ``e > 0``. + # We require ``finv`` to be the inverse of the reverse of ``f``. + # We require ``lenf > 2``. The output ``res`` must have room for + # ``lenf - 1`` coefficients. + + void fq_poly_powmod_x_fmpz_preinv(fq_poly_t res, const fmpz_t e, const fq_poly_t f, const fq_poly_t finv, const fq_ctx_t ctx) + # Sets ``res`` to ``x`` raised to the power ``e`` + # modulo ``f``, using sliding window exponentiation. We require + # ``e >= 0``. We require ``finv`` to be the inverse of the reverse of + # ``f``. + + void _fq_poly_pow_trunc_binexp(fq_struct * res, const fq_struct * poly, ulong e, slong trunc, const fq_ctx_t ctx) + # Sets ``res`` to the low ``trunc`` coefficients of ``poly`` + # (assumed to be zero padded if necessary to length ``trunc``) to + # the power ``e``. This is equivalent to doing a powering followed + # by a truncation. We require that ``res`` has enough space for + # ``trunc`` coefficients, that ``trunc > 0`` and that + # ``e > 1``. Aliasing is not permitted. Uses the binary + # exponentiation method. + + void fq_poly_pow_trunc_binexp(fq_poly_t res, const fq_poly_t poly, ulong e, slong trunc, const fq_ctx_t ctx) + # Sets ``res`` to the low ``trunc`` coefficients of ``poly`` + # to the power ``e``. This is equivalent to doing a powering + # followed by a truncation. Uses the binary exponentiation method. + + void _fq_poly_pow_trunc(fq_struct * res, const fq_struct * poly, ulong e, slong trunc, const fq_ctx_t mod) + # Sets ``res`` to the low ``trunc`` coefficients of ``poly`` + # (assumed to be zero padded if necessary to length ``trunc``) to + # the power ``e``. This is equivalent to doing a powering followed + # by a truncation. We require that ``res`` has enough space for + # ``trunc`` coefficients, that ``trunc > 0`` and that + # ``e > 1``. Aliasing is not permitted. + + void fq_poly_pow_trunc(fq_poly_t res, const fq_poly_t poly, ulong e, slong trunc, const fq_ctx_t ctx) + # Sets ``res`` to the low ``trunc`` coefficients of ``poly`` + # to the power ``e``. This is equivalent to doing a powering + # followed by a truncation. + + void _fq_poly_shift_left(fq_struct *rop, const fq_struct *op, slong len, slong n, const fq_ctx_t ctx) + # Sets ``(rop, len + n)`` to ``(op, len)`` shifted left by + # `n` coefficients. + # Inserts zero coefficients at the lower end. Assumes that + # ``len`` and `n` are positive, and that ``rop`` fits + # ``len + n`` elements. Supports aliasing between ``rop`` and + # ``op``. + + void fq_poly_shift_left(fq_poly_t rop, const fq_poly_t op, slong n, const fq_ctx_t ctx) + # Sets ``rop`` to ``op`` shifted left by `n` coeffs. Zero + # coefficients are inserted. + + void _fq_poly_shift_right(fq_struct *rop, const fq_struct *op, slong len, slong n, const fq_ctx_t ctx) + # Sets ``(rop, len - n)`` to ``(op, len)`` shifted right by + # `n` coefficients. + # Assumes that ``len`` and `n` are positive, that ``len > n``, + # and that ``rop`` fits ``len - n`` elements. Supports + # aliasing between ``rop`` and ``op``, although in this case + # the top coefficients of ``op`` are not set to zero. + + void fq_poly_shift_right(fq_poly_t rop, const fq_poly_t op, slong n, const fq_ctx_t ctx) + # Sets ``rop`` to ``op`` shifted right by `n` coefficients. + # If `n` is equal to or greater than the current length of + # ``op``, ``rop`` is set to the zero polynomial. + + slong _fq_poly_hamming_weight(const fq_struct *op, slong len, const fq_ctx_t ctx) + # Returns the number of non-zero entries in ``(op, len)``. + + slong fq_poly_hamming_weight(const fq_poly_t op, const fq_ctx_t ctx) + # Returns the number of non-zero entries in the polynomial ``op``. + + void _fq_poly_divrem(fq_struct *Q, fq_struct *R, const fq_struct *A, slong lenA, const fq_struct *B, slong lenB, const fq_t invB, const fq_ctx_t ctx) + # Computes ``(Q, lenA - lenB + 1)``, ``(R, lenA)`` such that + # `A = B Q + R` with `0 \leq \operatorname{len}(R) < \operatorname{len}(B)`. + # Assumes that the leading coefficient of `B` is invertible + # and that ``invB`` is its inverse. + # Assumes that `\operatorname{len}(A), \operatorname{len}(B) > 0`. Allows zero-padding in + # ``(A, lenA)``. `R` and `A` may be aliased, but apart from + # this no aliasing of input and output operands is allowed. + + void fq_poly_divrem(fq_poly_t Q, fq_poly_t R, const fq_poly_t A, const fq_poly_t B, const fq_ctx_t ctx) + # Computes `Q`, `R` such that `A = B Q + R` with + # `0 \leq \operatorname{len}(R) < \operatorname{len}(B)`. + # Assumes that the leading coefficient of `B` is invertible. This can + # be taken for granted the context is for a finite field, that is, when + # `p` is prime and `f(X)` is irreducible. + + void fq_poly_divrem_f(fq_t f, fq_poly_t Q, fq_poly_t R, const fq_poly_t A, const fq_poly_t B, const fq_ctx_t ctx) + # Either finds a non-trivial factor `f` of the modulus of + # ``ctx``, or computes `Q`, `R` such that `A = B Q + R` and + # `0 \leq \operatorname{len}(R) < \operatorname{len}(B)`. + # If the leading coefficient of `B` is invertible, the division with + # remainder operation is carried out, `Q` and `R` are computed + # correctly, and `f` is set to `1`. Otherwise, `f` is set to a + # non-trivial factor of the modulus and `Q` and `R` are not touched. + # Assumes that `B` is non-zero. + + void _fq_poly_rem(fq_struct *R, const fq_struct *A, slong lenA, const fq_struct *B, slong lenB, const fq_t invB, const fq_ctx_t ctx) + # Sets ``R`` to the remainder of the division of ``(A,lenA)`` by + # ``(B,lenB)``. Assumes that the leading coefficient of ``(B,lenB)`` + # is invertible and that ``invB`` is its inverse. + + void fq_poly_rem(fq_poly_t R, const fq_poly_t A, const fq_poly_t B, const fq_ctx_t ctx) + # Sets ``R`` to the remainder of the division of ``A`` by + # ``B`` in the context described by ``ctx``. + + void _fq_poly_div(fq_struct *Q, const fq_struct *A, slong lenA, const fq_struct *B, slong lenB, const fq_t invB, const fq_ctx_t ctx) + # Notationally, computes `Q`, `R` such that `A = B Q + R` with `0 + # \leq \operatorname{len}(R) < \operatorname{len}(B)` but only sets ``(Q, lenA - lenB + 1)``. + # Allows zero-padding in `A` but not in `B`. Assumes that the leading coefficient of `B` is a unit. + + void fq_poly_div(fq_poly_t Q, const fq_poly_t A, const fq_poly_t B, const fq_ctx_t ctx) + # Notionally finds polynomials `Q` and `R` such that `A = B Q + R` with + # `\operatorname{len}(R) < \operatorname{len}(B)`, but returns only ``Q``. If `\operatorname{len}(B) = 0` an + # exception is raised. + + void _fq_poly_div_newton_n_preinv(fq_struct* Q, const fq_struct* A, slong lenA, const fq_struct* B, slong lenB, const fq_struct* Binv, slong lenBinv, const fq_ctx_t ctx) + # Notionally computes polynomials `Q` and `R` such that `A = BQ + R` with + # `\operatorname{len}(R)` less than ``lenB``, where ``A`` is of length ``lenA`` + # and ``B`` is of length ``lenB``, but return only `Q`. + # We require that `Q` have space for ``lenA - lenB + 1`` coefficients + # and assume that the leading coefficient of `B` is a unit. Furthermore, we + # assume that `Binv` is the inverse of the reverse of `B` mod `x^{\operatorname{len}(B)}`. + # The algorithm used is to reverse the polynomials and divide the + # resulting power series, then reverse the result. + + void fq_poly_div_newton_n_preinv(fq_poly_t Q, const fq_poly_t A, const fq_poly_t B, const fq_poly_t Binv, const fq_ctx_t ctx) + # Notionally computes `Q` and `R` such that `A = BQ + R` with + # `\operatorname{len}(R) < \operatorname{len}(B)`, but returns only `Q`. + # We assume that the leading coefficient of `B` is a unit and that `Binv` is + # the inverse of the reverse of `B` mod `x^{\operatorname{len}(B)}`. + # It is required that the length of `A` is less than or equal to + # 2*the length of `B` - 2. + # The algorithm used is to reverse the polynomials and divide the + # resulting power series, then reverse the result. + + void _fq_poly_divrem_newton_n_preinv(fq_struct* Q, fq_struct* R, const fq_struct* A, slong lenA, const fq_struct* B, slong lenB, const fq_struct* Binv, slong lenBinv, const fq_ctx_t ctx) + # Computes `Q` and `R` such that `A = BQ + R` with `\operatorname{len}(R)` less + # than ``lenB``, where `A` is of length ``lenA`` and `B` is of + # length ``lenB``. We require that `Q` have space for + # ``lenA - lenB + 1`` coefficients. Furthermore, we assume that `Binv` is + # the inverse of the reverse of `B` mod `x^{\operatorname{len}(B)}`. The algorithm + # used is to call :func:`div_newton_n_preinv` and then multiply out + # and compute the remainder. + + void fq_poly_divrem_newton_n_preinv(fq_poly_t Q, fq_poly_t R, const fq_poly_t A, const fq_poly_t B, const fq_poly_t Binv, const fq_ctx_t ctx) + # Computes `Q` and `R` such that `A = BQ + R` with `\operatorname{len}(R) < + # \operatorname{len}(B)`. We assume `Binv` is the inverse of the reverse of `B` + # mod `x^{\operatorname{len}(B)}`. + # It is required that the length of `A` is less than or equal to + # 2*the length of `B` - 2. + # The algorithm used is to call :func:`div_newton_n` and then + # multiply out and compute the remainder. + + void _fq_poly_inv_series_newton(fq_struct* Qinv, const fq_struct* Q, slong n, const fq_t cinv, const fq_ctx_t ctx) + # Given ``Q`` of length ``n`` whose constant coefficient is + # invertible modulo the given modulus, find a polynomial ``Qinv`` + # of length ``n`` such that ``Q * Qinv`` is ``1`` modulo + # `x^n`. Requires ``n > 0``. This function can be viewed as + # inverting a power series via Newton iteration. + + void fq_poly_inv_series_newton(fq_poly_t Qinv, const fq_poly_t Q, slong n, const fq_ctx_t ctx) + # Given ``Q`` find ``Qinv`` such that ``Q * Qinv`` is + # ``1`` modulo `x^n`. The constant coefficient of ``Q`` must + # be invertible modulo the modulus of ``Q``. An exception is + # raised if this is not the case or if ``n = 0``. This function + # can be viewed as inverting a power series via Newton iteration. + + void _fq_poly_inv_series(fq_struct* Qinv, const fq_struct* Q, slong n, const fq_t cinv, const fq_ctx_t ctx) + # Given ``Q`` of length ``n`` whose constant coefficient is + # invertible modulo the given modulus, find a polynomial ``Qinv`` + # of length ``n`` such that ``Q * Qinv`` is ``1`` modulo + # `x^n`. Requires ``n > 0``. + + void fq_poly_inv_series(fq_poly_t Qinv, const fq_poly_t Q, slong n, const fq_ctx_t ctx) + # Given ``Q`` find ``Qinv`` such that ``Q * Qinv`` is + # ``1`` modulo `x^n`. The constant coefficient of ``Q`` must + # be invertible modulo the modulus of ``Q``. An exception is + # raised if this is not the case or if ``n = 0``. + + void _fq_poly_div_series(fq_struct * Q, const fq_struct * A, slong Alen, const fq_struct * B, slong Blen, slong n, const fq_ctx_t ctx) + # Set ``(Q, n)`` to the quotient of the series ``(A, Alen``) and + # ``(B, Blen)`` assuming ``Alen, Blen <= n``. We assume the bottom + # coefficient of ``B`` is invertible. + + void fq_poly_div_series(fq_poly_t Q, const fq_poly_t A, const fq_poly_t B, slong n, const fq_ctx_t ctx) + # Set `Q` to the quotient of the series `A` by `B`, thinking of the series as + # though they were of length `n`. We assume that the bottom coefficient of + # `B` is invertible. + + void fq_poly_gcd(fq_poly_t rop, const fq_poly_t op1, const fq_poly_t op2, const fq_ctx_t ctx) + # Sets ``rop`` to the greatest common divisor of ``op1`` and + # ``op2``, using the either the Euclidean or HGCD algorithm. The + # GCD of zero polynomials is defined to be zero, whereas the GCD of + # the zero polynomial and some other polynomial `P` is defined to be + # `P`. Except in the case where the GCD is zero, the GCD `G` is made + # monic. + + slong _fq_poly_gcd(fq_struct* G, const fq_struct* A, slong lenA, const fq_struct* B, slong lenB, const fq_ctx_t ctx) + # Computes the GCD of `A` of length ``lenA`` and `B` of length + # ``lenB``, where ``lenA >= lenB > 0`` and sets `G` to it. The + # length of the GCD `G` is returned by the function. No attempt is + # made to make the GCD monic. It is required that `G` have space for + # ``lenB`` coefficients. + + slong _fq_poly_gcd_euclidean_f(fq_t f, fq_struct *G, const fq_struct *A, slong lenA, const fq_struct *B, slong lenB, const fq_ctx_t ctx) + # Either sets `f = 1` and `G` to the greatest common divisor of + # `(A,\operatorname{len}(A))` and `(B, \operatorname{len}(B))` and returns its length, or sets + # `f` to a non-trivial factor of the modulus of ``ctx`` and leaves + # the contents of the vector `(G, lenB)` undefined. + # Assumes that `\operatorname{len}(A) \geq \operatorname{len}(B) > 0` and that the vector `G` + # has space for sufficiently many coefficients. + + void fq_poly_gcd_euclidean_f(fq_t f, fq_poly_t G, const fq_poly_t A, const fq_poly_t B, const fq_ctx_t ctx) + # Either sets `f = 1` and `G` to the greatest common divisor of `A` + # and `B` or sets `f` to a factor of the modulus of ``ctx``. + + slong _fq_poly_xgcd(fq_struct *G, fq_struct *S, fq_struct *T, const fq_struct *A, slong lenA, const fq_struct *B, slong lenB, const fq_ctx_t ctx) + # Computes the GCD of `A` and `B` together with cofactors `S` and `T` + # such that `S A + T B = G`. Returns the length of `G`. + # Assumes that `\operatorname{len}(A) \geq \operatorname{len}(B) \geq 1` and + # `(\operatorname{len}(A),\operatorname{len}(B)) \neq (1,1)`. + # No attempt is made to make the GCD monic. + # Requires that `G` have space for `\operatorname{len}(B)` coefficients. Writes + # `\operatorname{len}(B)-1` and `\operatorname{len}(A)-1` coefficients to `S` and `T`, respectively. + # Note that, in fact, `\operatorname{len}(S) \leq \max(\operatorname{len}(B) - \operatorname{len}(G), 1)` and + # `\operatorname{len}(T) \leq \max(\operatorname{len}(A) - \operatorname{len}(G), 1)`. + # No aliasing of input and output operands is permitted. + + void fq_poly_xgcd(fq_poly_t G, fq_poly_t S, fq_poly_t T, const fq_poly_t A, const fq_poly_t B, const fq_ctx_t ctx) + # Computes the GCD of `A` and `B`. The GCD of zero polynomials is + # defined to be zero, whereas the GCD of the zero polynomial and some other + # polynomial `P` is defined to be `P`. Except in the case where + # the GCD is zero, the GCD `G` is made monic. + # Polynomials ``S`` and ``T`` are computed such that + # ``S*A + T*B = G``. The length of ``S`` will be at most + # ``lenB`` and the length of ``T`` will be at most ``lenA``. + + slong _fq_poly_xgcd_euclidean_f(fq_t f, fq_struct *G, fq_struct *S, fq_struct *T, const fq_struct *A, slong lenA, const fq_struct *B, slong lenB, const fq_ctx_t ctx) + # Either sets `f = 1` and computes the GCD of `A` and `B` together + # with cofactors `S` and `T` such that `S A + T B = G`; otherwise, + # sets `f` to a non-trivial factor of the modulus of ``ctx`` and + # leaves `G`, `S`, and `T` undefined. Returns the length of `G`. + # Assumes that `\operatorname{len}(A) \geq \operatorname{len}(B) \geq 1` and + # `(\operatorname{len}(A),\operatorname{len}(B)) \neq (1,1)`. + # No attempt is made to make the GCD monic. + # Requires that `G` have space for `\operatorname{len}(B)` coefficients. Writes + # `\operatorname{len}(B)-1` and `\operatorname{len}(A)-1` coefficients to `S` and `T`, respectively. + # Note that, in fact, `\operatorname{len}(S) \leq \max(\operatorname{len}(B) - \operatorname{len}(G), 1)` and + # `\operatorname{len}(T) \leq \max(\operatorname{len}(A) - \operatorname{len}(G), 1)`. + # No aliasing of input and output operands is permitted. + + void fq_poly_xgcd_euclidean_f(fq_t f, fq_poly_t G, fq_poly_t S, fq_poly_t T, const fq_poly_t A, const fq_poly_t B, const fq_ctx_t ctx) + # Either sets `f = 1` and computes the GCD of `A` and `B` or sets + # `f` to a non-trivial factor of the modulus of ``ctx``. + # If the GCD is computed, polynomials ``S`` and ``T`` are + # computed such that ``S*A + T*B = G``; otherwise, they are + # undefined. The length of ``S`` will be at most ``lenB`` and + # the length of ``T`` will be at most ``lenA``. + # The GCD of zero polynomials is defined to be zero, whereas the GCD + # of the zero polynomial and some other polynomial `P` is defined to + # be `P`. Except in the case where the GCD is zero, the GCD `G` is + # made monic. + + int _fq_poly_divides(fq_struct *Q, const fq_struct *A, slong lenA, const fq_struct *B, slong lenB, const fq_t invB, const fq_ctx_t ctx) + # Returns `1` if ``(B, lenB)`` divides ``(A, lenA)`` exactly and + # sets `Q` to the quotient, otherwise returns `0`. + # It is assumed that `\operatorname{len}(A) \geq \operatorname{len}(B) > 0` and that `Q` has space + # for `\operatorname{len}(A) - \operatorname{len}(B) + 1` coefficients. + # Aliasing of `Q` with either of the inputs is not permitted. + # This function is currently unoptimised and provided for convenience + # only. + + int fq_poly_divides(fq_poly_t Q, const fq_poly_t A, const fq_poly_t B, const fq_ctx_t ctx) + # Returns `1` if `B` divides `A` exactly and sets `Q` to the quotient, + # otherwise returns `0`. + # This function is currently unoptimised and provided for convenience + # only. + + void _fq_poly_derivative(fq_struct *rop, const fq_struct *op, slong len, const fq_ctx_t ctx) + # Sets ``(rop, len - 1)`` to the derivative of ``(op, len)``. + # Also handles the cases where ``len`` is `0` or `1` correctly. + # Supports aliasing of ``rop`` and ``op``. + + void fq_poly_derivative(fq_poly_t rop, const fq_poly_t op, const fq_ctx_t ctx) + # Sets ``rop`` to the derivative of ``op``. + + void _fq_poly_invsqrt_series(fq_struct * g, const fq_struct * h, slong n, fq_ctx_t mod) + # Set the first `n` terms of `g` to the series expansion of `1/\sqrt{h}`. + # It is assumed that `n > 0`, that `h` has constant term 1 and that `h` + # is zero-padded as necessary to length `n`. Aliasing is not permitted. + + void fq_poly_invsqrt_series(fq_poly_t g, const fq_poly_t h, slong n, fq_ctx_t ctx) + # Set `g` to the series expansion of `1/\sqrt{h}` to order `O(x^n)`. + # It is assumed that `h` has constant term 1. + + void _fq_poly_sqrt_series(fq_struct * g, const fq_struct * h, slong n, fq_ctx_t ctx) + # Set the first `n` terms of `g` to the series expansion of `\sqrt{h}`. + # It is assumed that `n > 0`, that `h` has constant term 1 and that `h` + # is zero-padded as necessary to length `n`. Aliasing is not permitted. + + void fq_poly_sqrt_series(fq_poly_t g, const fq_poly_t h, slong n, fq_ctx_t ctx) + # Set `g` to the series expansion of `\sqrt{h}` to order `O(x^n)`. + # It is assumed that `h` has constant term 1. + + int _fq_poly_sqrt(fq_struct * s, const fq_struct * p, slong n, fq_ctx_t mod) + # If ``(p, n)`` is a perfect square, sets ``(s, n / 2 + 1)`` + # to a square root of `p` and returns 1. Otherwise returns 0. + + int fq_poly_sqrt(fq_poly_t s, const fq_poly_t p, fq_ctx_t mod) + # If `p` is a perfect square, sets `s` to a square root of `p` + # and returns 1. Otherwise returns 0. + + void _fq_poly_evaluate_fq(fq_t rop, const fq_struct *op, slong len, const fq_t a, const fq_ctx_t ctx) + # Sets ``rop`` to ``(op, len)`` evaluated at `a`. + # Supports zero padding. There are no restrictions on ``len``, that + # is, ``len`` is allowed to be zero, too. + + void fq_poly_evaluate_fq(fq_t rop, const fq_poly_t f, const fq_t a, const fq_ctx_t ctx) + # Sets ``rop`` to the value of `f(a)`. + # As the coefficient ring `\mathbf{F}_q` is finite, Horner's method + # is sufficient. + + void _fq_poly_compose(fq_struct *rop, const fq_struct *op1, slong len1, const fq_struct *op2, slong len2, const fq_ctx_t ctx) + # Sets ``rop`` to the composition of ``(op1, len1)`` and + # ``(op2, len2)``. + # Assumes that ``rop`` has space for ``(len1-1)*(len2-1) + 1`` + # coefficients. Assumes that ``op1`` and ``op2`` are non-zero + # polynomials. Does not support aliasing between any of the inputs and + # the output. + + void fq_poly_compose(fq_poly_t rop, const fq_poly_t op1, const fq_poly_t op2, const fq_ctx_t ctx) + # Sets ``rop`` to the composition of ``op1`` and ``op2``. + # To be precise about the order of composition, denoting ``rop``, + # ``op1``, and ``op2`` by `f`, `g`, and `h`, respectively, + # sets `f(t) = g(h(t))`. + + void _fq_poly_compose_mod_horner(fq_struct * res, const fq_struct * f, slong lenf, const fq_struct * g, const fq_struct * h, slong lenh, const fq_ctx_t ctx) + # Sets ``res`` to the composition `f(g)` modulo `h`. We require that + # `h` is nonzero and that the length of `g` is one less than the + # length of `h` (possibly with zero padding). The output is not allowed + # to be aliased with any of the inputs. + # The algorithm used is Horner's rule. + + void fq_poly_compose_mod_horner(fq_poly_t res, const fq_poly_t f, const fq_poly_t g, const fq_poly_t h, const fq_ctx_t ctx) + # Sets ``res`` to the composition `f(g)` modulo `h`. We require that + # `h` is nonzero. The algorithm used is Horner's rule. + + void _fq_poly_compose_mod_horner_preinv(fq_struct * res, const fq_struct * f, slong lenf, const fq_struct * g, const fq_struct * h, slong lenh, const fq_struct * hinv, slong lenhiv, const fq_ctx_t ctx) + # Sets ``res`` to the composition `f(g)` modulo `h`. We require + # that `h` is nonzero and that the length of `g` is one less than + # the length of `h` (possibly with zero padding). We also require + # that the length of `f` is less than the length of + # `h`. Furthermore, we require ``hinv`` to be the inverse of the + # reverse of ``h``. The output is not allowed to be aliased with + # any of the inputs. + # The algorithm used is Horner's rule. + + void fq_poly_compose_mod_horner_preinv(fq_poly_t res, const fq_poly_t f, const fq_poly_t g, const fq_poly_t h, const fq_poly_t hinv, const fq_ctx_t ctx) + # Sets ``res`` to the composition `f(g)` modulo `h`. We require + # that `h` is nonzero and that `f` has smaller degree than + # `h`. Furthermore, we require ``hinv`` to be the inverse of the + # reverse of ``h``. The algorithm used is Horner's rule. + + void _fq_poly_compose_mod_brent_kung(fq_struct * res, const fq_struct * f, slong lenf, const fq_struct * g, const fq_struct * h, slong lenh, const fq_ctx_t ctx) + # Sets ``res`` to the composition `f(g)` modulo `h`. We require + # that `h` is nonzero and that the length of `g` is one less than + # the length of `h` (possibly with zero padding). We also require + # that the length of `f` is less than the length of `h`. The output + # is not allowed to be aliased with any of the inputs. + # The algorithm used is the Brent-Kung matrix algorithm. + + void fq_poly_compose_mod_brent_kung(fq_poly_t res, const fq_poly_t f, const fq_poly_t g, const fq_poly_t h, const fq_ctx_t ctx) + # Sets ``res`` to the composition `f(g)` modulo `h`. We require + # that `h` is nonzero and that `f` has smaller degree than `h`. The + # algorithm used is the Brent-Kung matrix algorithm. + + void _fq_poly_compose_mod_brent_kung_preinv(fq_struct * res, const fq_struct * f, slong lenf, const fq_struct * g, const fq_struct * h, slong lenh, const fq_struct * hinv, slong lenhiv, const fq_ctx_t ctx) + # Sets ``res`` to the composition `f(g)` modulo `h`. We require + # that `h` is nonzero and that the length of `g` is one less than + # the length of `h` (possibly with zero padding). We also require + # that the length of `f` is less than the length of + # `h`. Furthermore, we require ``hinv`` to be the inverse of the + # reverse of ``h``. The output is not allowed to be aliased with + # any of the inputs. + # The algorithm used is the Brent-Kung matrix algorithm. + + void fq_poly_compose_mod_brent_kung_preinv(fq_poly_t res, const fq_poly_t f, const fq_poly_t g, const fq_poly_t h, const fq_poly_t hinv, const fq_ctx_t ctx) + # Sets ``res`` to the composition `f(g)` modulo `h`. We require + # that `h` is nonzero and that `f` has smaller degree than + # `h`. Furthermore, we require ``hinv`` to be the inverse of the + # reverse of ``h``. The algorithm used is the Brent-Kung matrix + # algorithm. + + void _fq_poly_compose_mod(fq_struct * res, const fq_struct * f, slong lenf, const fq_struct * g, const fq_struct * h, slong lenh, const fq_ctx_t ctx) + # Sets ``res`` to the composition `f(g)` modulo `h`. We require + # that `h` is nonzero and that the length of `g` is one less than + # the length of `h` (possibly with zero padding). The output is not + # allowed to be aliased with any of the inputs. + + void fq_poly_compose_mod(fq_poly_t res, const fq_poly_t f, const fq_poly_t g, const fq_poly_t h, const fq_ctx_t ctx) + # Sets ``res`` to the composition `f(g)` modulo `h`. We require + # that `h` is nonzero. + + void _fq_poly_compose_mod_preinv(fq_struct * res, const fq_struct * f, slong lenf, const fq_struct * g, const fq_struct * h, slong lenh, const fq_struct * hinv, slong lenhiv, const fq_ctx_t ctx) + # Sets ``res`` to the composition `f(g)` modulo `h`. We require + # that `h` is nonzero and that the length of `g` is one less than + # the length of `h` (possibly with zero padding). We also require + # that the length of `f` is less than the length of + # `h`. Furthermore, we require ``hinv`` to be the inverse of the + # reverse of ``h``. The output is not allowed to be aliased with + # any of the inputs. + + void fq_poly_compose_mod_preinv(fq_poly_t res, const fq_poly_t f, const fq_poly_t g, const fq_poly_t h, const fq_poly_t hinv, const fq_ctx_t ctx) + # Sets ``res`` to the composition `f(g)` modulo `h`. We require + # that `h` is nonzero and that `f` has smaller degree than + # `h`. Furthermore, we require ``hinv`` to be the inverse of the + # reverse of ``h``. + + void _fq_poly_reduce_matrix_mod_poly (fq_mat_t A, const fq_mat_t B, const fq_poly_t f, const fq_ctx_t ctx) + # Sets the ith row of ``A`` to the reduction of the ith row of `B` modulo + # `f` for `i=1,\ldots,\sqrt{\deg(f)}`. We require `B` to be at least + # a `\sqrt{\deg(f)}\times \deg(f)` matrix and `f` to be nonzero. + + void _fq_poly_precompute_matrix (fq_mat_t A, const fq_struct* f, const fq_struct* g, slong leng, const fq_struct* ginv, slong lenginv, const fq_ctx_t ctx) + # Sets the ith row of ``A`` to `f^i` modulo `g` for + # `i=1,\ldots,\sqrt{\deg(g)}`. We require `A` to be a + # `\sqrt{\deg(g)}\times \deg(g)` matrix. We require ``ginv`` to + # be the inverse of the reverse of ``g`` and `g` to be nonzero. + + void fq_poly_precompute_matrix (fq_mat_t A, const fq_poly_t f, const fq_poly_t g, const fq_poly_t ginv, const fq_ctx_t ctx) + # Sets the ith row of ``A`` to `f^i` modulo `g` for + # `i=1,\ldots,\sqrt{\deg(g)}`. We require `A` to be a + # `\sqrt{\deg(g)}\times \deg(g)` matrix. We require ``ginv`` to + # be the inverse of the reverse of ``g``. + + void _fq_poly_compose_mod_brent_kung_precomp_preinv(fq_struct* res, const fq_struct* f, slong lenf, const fq_mat_t A, const fq_struct* h, slong lenh, const fq_struct* hinv, slong lenhinv, const fq_ctx_t ctx) + # Sets ``res`` to the composition `f(g)` modulo `h`. We require + # that `h` is nonzero. We require that the ith row of `A` contains + # `g^i` for `i=1,\ldots,\sqrt{\deg(h)}`, i.e. `A` is a + # `\sqrt{\deg(h)}\times \deg(h)` matrix. We also require that the + # length of `f` is less than the length of `h`. Furthermore, we + # require ``hinv`` to be the inverse of the reverse of ``h``. + # The output is not allowed to be aliased with any of the inputs. + # The algorithm used is the Brent-Kung matrix algorithm. + + void fq_poly_compose_mod_brent_kung_precomp_preinv(fq_poly_t res, const fq_poly_t f, const fq_mat_t A, const fq_poly_t h, const fq_poly_t hinv, const fq_ctx_t ctx) + # Sets ``res`` to the composition `f(g)` modulo `h`. We require + # that the ith row of `A` contains `g^i` for + # `i=1,\ldots,\sqrt{\deg(h)}`, i.e. `A` is a `\sqrt{\deg(h)}\times + # \deg(h)` matrix. We require that `h` is nonzero and that `f` has + # smaller degree than `h`. Furthermore, we require ``hinv`` to be + # the inverse of the reverse of ``h``. This version of Brent-Kung + # modular composition is particularly useful if one has to perform + # several modular composition of the form `f(g)` modulo `h` for + # fixed `g` and `h`. + + int _fq_poly_fprint_pretty(FILE *file, const fq_struct *poly, slong len, const char *x, const fq_ctx_t ctx) + # Prints the pretty representation of ``(poly, len)`` to the stream + # ``file``, using the string ``x`` to represent the indeterminate. + # In case of success, returns a positive value. In case of failure, + # returns a non-positive value. + + int fq_poly_fprint_pretty(FILE * file, const fq_poly_t poly, const char *x, const fq_ctx_t ctx) + # Prints the pretty representation of ``poly`` to the stream + # ``file``, using the string ``x`` to represent the indeterminate. + # In case of success, returns a positive value. In case of failure, + # returns a non-positive value. + + int _fq_poly_print_pretty(const fq_struct *poly, slong len, const char *x, const fq_ctx_t ctx) + # Prints the pretty representation of ``(poly, len)`` to ``stdout``, + # using the string ``x`` to represent the indeterminate. + # In case of success, returns a positive value. In case of failure, + # returns a non-positive value. + + int fq_poly_print_pretty(const fq_poly_t poly, const char *x, const fq_ctx_t ctx) + # Prints the pretty representation of ``poly`` to ``stdout``, + # using the string ``x`` to represent the indeterminate. + # In case of success, returns a positive value. In case of failure, + # returns a non-positive value. + + int _fq_poly_fprint(FILE *file, const fq_struct *poly, slong len, const fq_ctx_t ctx) + # Prints the pretty representation of ``(poly, len)`` to the stream + # ``file``. + # In case of success, returns a positive value. In case of failure, + # returns a non-positive value. + + int fq_poly_fprint(FILE * file, const fq_poly_t poly, const fq_ctx_t ctx) + # Prints the pretty representation of ``poly`` to the stream + # ``file``. + # In case of success, returns a positive value. In case of failure, + # returns a non-positive value. + + int _fq_poly_print(const fq_struct *poly, slong len, const fq_ctx_t ctx) + # Prints the pretty representation of ``(poly, len)`` to ``stdout``. + # In case of success, returns a positive value. In case of failure, + # returns a non-positive value. + + int fq_poly_print(const fq_poly_t poly, const fq_ctx_t ctx) + # Prints the representation of ``poly`` to ``stdout``. + # In case of success, returns a positive value. In case of failure, + # returns a non-positive value. + + char * _fq_poly_get_str(const fq_struct * poly, slong len, const fq_ctx_t ctx) + # Returns the plain FLINT string representation of the polynomial + # ``(poly, len)``. + + char * fq_poly_get_str(const fq_poly_t poly, const fq_ctx_t ctx) + # Returns the plain FLINT string representation of the polynomial + # ``poly``. + + char * _fq_poly_get_str_pretty(const fq_struct * poly, slong len, const char * x, const fq_ctx_t ctx) + # Returns a pretty representation of the polynomial + # ``(poly, len)`` using the null-terminated string ``x`` as the + # variable name. + + char * fq_poly_get_str_pretty(const fq_poly_t poly, const char * x, const fq_ctx_t ctx) + # Returns a pretty representation of the polynomial ``poly`` using the + # null-terminated string ``x`` as the variable name + + void fq_poly_inflate(fq_poly_t result, const fq_poly_t input, ulong inflation, const fq_ctx_t ctx) + # Sets ``result`` to the inflated polynomial `p(x^n)` where + # `p` is given by ``input`` and `n` is given by ``inflation``. + + void fq_poly_deflate(fq_poly_t result, const fq_poly_t input, ulong deflation, const fq_ctx_t ctx) + # Sets ``result`` to the deflated polynomial `p(x^{1/n})` where + # `p` is given by ``input`` and `n` is given by ``deflation``. + # Requires `n > 0`. + + ulong fq_poly_deflation(const fq_poly_t input, const fq_ctx_t ctx) + # Returns the largest integer by which ``input`` can be deflated. + # As special cases, returns 0 if ``input`` is the zero polynomial + # and 1 of ``input`` is a constant polynomial. diff --git a/src/sage/libs/flint/fq_poly_factor.pxd b/src/sage/libs/flint/fq_poly_factor.pxd new file mode 100644 index 00000000000..56059aaf7e8 --- /dev/null +++ b/src/sage/libs/flint/fq_poly_factor.pxd @@ -0,0 +1,168 @@ +# distutils: libraries = flint +# distutils: depends = flint/fq_poly_factor.h + +################################################################################ +# This file is auto-generated. Do not modify by hand +################################################################################ + +from libc.stdio cimport FILE +from sage.libs.gmp.types cimport * +from sage.libs.mpfr.types cimport * +from sage.libs.flint.types cimport * + +cdef extern from "flint_wrap.h": + + void fq_poly_factor_init(fq_poly_factor_t fac, const fq_ctx_t ctx) + # Initialises ``fac`` for use. An :type:`fq_poly_factor_t` + # represents a polynomial in factorised form as a product of + # polynomials with associated exponents. + + void fq_poly_factor_clear(fq_poly_factor_t fac, const fq_ctx_t ctx) + # Frees all memory associated with ``fac``. + + void fq_poly_factor_realloc(fq_poly_factor_t fac, slong alloc, const fq_ctx_t ctx) + # Reallocates the factor structure to provide space for + # precisely ``alloc`` factors. + + void fq_poly_factor_fit_length(fq_poly_factor_t fac, slong len, const fq_ctx_t ctx) + # Ensures that the factor structure has space for at least + # ``len`` factors. This function takes care of the case of + # repeated calls by always at least doubling the number of factors + # the structure can hold. + + void fq_poly_factor_set(fq_poly_factor_t res, const fq_poly_factor_t fac, const fq_ctx_t ctx) + # Sets ``res`` to the same factorisation as ``fac``. + + void fq_poly_factor_print_pretty(const fq_poly_factor_t fac, const char * var, const fq_ctx_t ctx) + # Pretty-prints the entries of ``fac`` to standard output. + + void fq_poly_factor_print(const fq_poly_factor_t fac, const fq_ctx_t ctx) + # Prints the entries of ``fac`` to standard output. + + void fq_poly_factor_insert(fq_poly_factor_t fac, const fq_poly_t poly, slong exp, const fq_ctx_t ctx) + # Inserts the factor ``poly`` with multiplicity ``exp`` into + # the factorisation ``fac``. + # If ``fac`` already contains ``poly``, then ``exp`` simply + # gets added to the exponent of the existing entry. + + void fq_poly_factor_concat(fq_poly_factor_t res, const fq_poly_factor_t fac, const fq_ctx_t ctx) + # Concatenates two factorisations. + # This is equivalent to calling :func:`fq_poly_factor_insert` + # repeatedly with the individual factors of ``fac``. + # Does not support aliasing between ``res`` and ``fac``. + + void fq_poly_factor_pow(fq_poly_factor_t fac, slong exp, const fq_ctx_t ctx) + # Raises ``fac`` to the power ``exp``. + + ulong fq_poly_remove(fq_poly_t f, const fq_poly_t p, const fq_ctx_t ctx) + # Removes the highest possible power of ``p`` from ``f`` and + # returns the exponent. + + int fq_poly_is_irreducible(const fq_poly_t f, const fq_ctx_t ctx) + # Returns 1 if the polynomial ``f`` is irreducible, otherwise returns 0. + + int fq_poly_is_irreducible_ddf(const fq_poly_t f, const fq_ctx_t ctx) + # Returns 1 if the polynomial ``f`` is irreducible, otherwise returns 0. + # Uses fast distinct-degree factorisation. + + int fq_poly_is_irreducible_ben_or(const fq_poly_t f, const fq_ctx_t ctx) + # Returns 1 if the polynomial ``f`` is irreducible, otherwise returns 0. + # Uses Ben-Or's irreducibility test. + + int _fq_poly_is_squarefree(const fq_struct * f, slong len, const fq_ctx_t ctx) + # Returns 1 if ``(f, len)`` is squarefree, and 0 otherwise. As a + # special case, the zero polynomial is not considered squarefree. + # There are no restrictions on the length. + + int fq_poly_is_squarefree(const fq_poly_t f, const fq_ctx_t ctx) + # Returns 1 if ``f`` is squarefree, and 0 otherwise. As a special + # case, the zero polynomial is not considered squarefree. + + int fq_poly_factor_equal_deg_prob(fq_poly_t factor, flint_rand_t state, const fq_poly_t pol, slong d, const fq_ctx_t ctx) + # Probabilistic equal degree factorisation of ``pol`` into + # irreducible factors of degree ``d``. If it passes, a factor is + # placed in factor and 1 is returned, otherwise 0 is returned and + # the value of factor is undetermined. + # Requires that ``pol`` be monic, non-constant and squarefree. + + void fq_poly_factor_equal_deg(fq_poly_factor_t factors, const fq_poly_t pol, slong d, const fq_ctx_t ctx) + # Assuming ``pol`` is a product of irreducible factors all of + # degree ``d``, finds all those factors and places them in + # factors. Requires that ``pol`` be monic, non-constant and + # squarefree. + + void fq_poly_factor_split_single(fq_poly_t linfactor, const fq_poly_t input, const fq_ctx_t ctx) + # Assuming ``input`` is a product of factors all of degree 1, finds a single + # linear factor of ``input`` and places it in ``linfactor``. + # Requires that ``input`` be monic and non-constant. + + void fq_poly_factor_distinct_deg(fq_poly_factor_t res, const fq_poly_t poly, slong * const *degs, const fq_ctx_t ctx) + # Factorises a monic non-constant squarefree polynomial ``poly`` + # of degree `n` into factors `f[d]` such that for `1 \leq d \leq n` + # `f[d]` is the product of the monic irreducible factors of + # ``poly`` of degree `d`. Factors are stored in ``res``, + # associated powers of irreducible polynomials are stored in + # ``degs`` in the same order as factors. + # Requires that ``degs`` have enough space for irreducible polynomials' + # powers (maximum space required is ``n * sizeof(slong)``). + + void fq_poly_factor_squarefree(fq_poly_factor_t res, const fq_poly_t f, const fq_ctx_t ctx) + # Sets ``res`` to a squarefree factorization of ``f``. + + void fq_poly_factor(fq_poly_factor_t res, fq_t lead, const fq_poly_t f, const fq_ctx_t ctx) + # Factorises a non-constant polynomial ``f`` into monic + # irreducible factors choosing the best algorithm for given modulo + # and degree. The output ``lead`` is set to the leading coefficient of `f` + # upon return. Choice of algorithm is based on heuristic measurements. + + void fq_poly_factor_cantor_zassenhaus(fq_poly_factor_t res, const fq_poly_t f, const fq_ctx_t ctx) + # Factorises a non-constant polynomial ``f`` into monic + # irreducible factors using the Cantor-Zassenhaus algorithm. + + void fq_poly_factor_kaltofen_shoup(fq_poly_factor_t res, const fq_poly_t poly, const fq_ctx_t ctx) + # Factorises a non-constant polynomial ``f`` into monic + # irreducible factors using the fast version of Cantor-Zassenhaus + # algorithm proposed by Kaltofen and Shoup (1998). More precisely + # this algorithm uses a “baby step/giant step” strategy for the + # distinct-degree factorization step. + + void fq_poly_factor_berlekamp(fq_poly_factor_t factors, const fq_poly_t f, const fq_ctx_t ctx) + # Factorises a non-constant polynomial ``f`` into monic + # irreducible factors using the Berlekamp algorithm. + + void fq_poly_factor_with_berlekamp(fq_poly_factor_t res, fq_t leading_coeff, const fq_poly_t f, const fq_ctx_t ctx) + # Factorises a general polynomial ``f`` into monic irreducible + # factors and sets ``leading_coeff`` to the leading coefficient + # of ``f``, or 0 if ``f`` is the zero polynomial. + # This function first checks for small special cases, deflates + # ``f`` if it is of the form `p(x^m)` for some `m > 1`, then + # performs a square-free factorisation, and finally runs Berlekamp + # factorisation on all the individual square-free factors. + + void fq_poly_factor_with_cantor_zassenhaus(fq_poly_factor_t res, fq_t leading_coeff, const fq_poly_t f, const fq_ctx_t ctx) + # Factorises a general polynomial ``f`` into monic irreducible + # factors and sets ``leading_coeff`` to the leading coefficient + # of ``f``, or 0 if ``f`` is the zero polynomial. + # This function first checks for small special cases, deflates + # ``f`` if it is of the form `p(x^m)` for some `m > 1`, then + # performs a square-free factorisation, and finally runs + # Cantor-Zassenhaus on all the individual square-free factors. + + void fq_poly_factor_with_kaltofen_shoup(fq_poly_factor_t res, fq_t leading_coeff, const fq_poly_t f, const fq_ctx_t ctx) + # Factorises a general polynomial ``f`` into monic irreducible + # factors and sets ``leading_coeff`` to the leading coefficient + # of ``f``, or 0 if ``f`` is the zero polynomial. + # This function first checks for small special cases, deflates + # ``f`` if it is of the form `p(x^m)` for some `m > 1`, then + # performs a square-free factorisation, and finally runs + # Kaltofen-Shoup on all the individual square-free factors. + + void fq_poly_iterated_frobenius_preinv(fq_poly_t *rop, slong n, const fq_poly_t v, const fq_poly_t vinv, const fq_ctx_t ctx) + # Sets ``rop[i]`` to be `x^{q^i}\bmod v` for `0 \le i < n`. + # It is required that ``vinv`` is the inverse of the reverse of + # ``v`` mod ``x^lenv``. + + void fq_poly_roots(fq_poly_factor_t r, const fq_poly_t f, int with_multiplicity, const fq_ctx_t ctx) + # Fill `r` with factors of the form `x - r_i` where the `r_i` are the distinct roots of a nonzero `f` in `F_q`. + # If `with\_multiplicity` is zero, the exponent `e_i` of the factor `x - r_i` is `1`. Otherwise, it is the largest `e_i` such that `(x-r_i)^e_i` divides `f`. + # This function throws if `f` is zero, but is otherwise always successful. diff --git a/src/sage/libs/flint/fq_vec.pxd b/src/sage/libs/flint/fq_vec.pxd new file mode 100644 index 00000000000..23160909d9c --- /dev/null +++ b/src/sage/libs/flint/fq_vec.pxd @@ -0,0 +1,73 @@ +# distutils: libraries = flint +# distutils: depends = flint/fq_vec.h + +################################################################################ +# This file is auto-generated. Do not modify by hand +################################################################################ + +from libc.stdio cimport FILE +from sage.libs.gmp.types cimport * +from sage.libs.mpfr.types cimport * +from sage.libs.flint.types cimport * + +cdef extern from "flint_wrap.h": + + fq_struct * _fq_vec_init(slong len, const fq_ctx_t ctx) + # Returns an initialised vector of ``fq``'s of given length. + + void _fq_vec_clear(fq_struct * vec, slong len, const fq_ctx_t ctx) + # Clears the entries of ``(vec, len)`` and frees the space allocated + # for ``vec``. + + void _fq_vec_randtest(fq_struct * f, flint_rand_t state, slong len, const fq_ctx_t ctx) + # Sets the entries of a vector of the given length to elements of + # the finite field. + + int _fq_vec_fprint(FILE * file, const fq_struct * vec, slong len, const fq_ctx_t ctx) + # Prints the vector of given length to the stream ``file``. The + # format is the length followed by two spaces, then a space separated + # list of coefficients. If the length is zero, only `0` is printed. + # In case of success, returns a positive value. In case of failure, + # returns a non-positive value. + + int _fq_vec_print(const fq_struct * vec, slong len, const fq_ctx_t ctx) + # Prints the vector of given length to ``stdout``. + # For further details, see ``_fq_vec_fprint()``. + + void _fq_vec_set(fq_struct * vec1, const fq_struct * vec2, slong len2, const fq_ctx_t ctx) + # Makes a copy of ``(vec2, len2)`` into ``vec1``. + + void _fq_vec_swap(fq_struct * vec1, fq_struct * vec2, slong len2, const fq_ctx_t ctx) + # Swaps the elements in ``(vec1, len2)`` and ``(vec2, len2)``. + + void _fq_vec_zero(fq_struct * vec, slong len, const fq_ctx_t ctx) + # Zeros the entries of ``(vec, len)``. + + void _fq_vec_neg(fq_struct * vec1, const fq_struct * vec2, slong len2, const fq_ctx_t ctx) + # Negates ``(vec2, len2)`` and places it into ``vec1``. + + int _fq_vec_equal(const fq_struct * vec1, const fq_struct * vec2, slong len, const fq_ctx_t ctx) + # Compares two vectors of the given length and returns `1` if they are + # equal, otherwise returns `0`. + + int _fq_vec_is_zero(const fq_struct * vec, slong len, const fq_ctx_t ctx) + # Returns `1` if ``(vec, len)`` is zero, and `0` otherwise. + + void _fq_vec_add(fq_struct * res, const fq_struct * vec1, const fq_struct * vec2, slong len2, const fq_ctx_t ctx) + # Sets ``(res, len2)`` to the sum of ``(vec1, len2)`` + # and ``(vec2, len2)``. + + void _fq_vec_sub(fq_struct * res, const fq_struct * vec1, const fq_struct * vec2, slong len2, const fq_ctx_t ctx) + # Sets ``(res, len2)`` to ``(vec1, len2)`` minus ``(vec2, len2)``. + + void _fq_vec_scalar_addmul_fq(fq_struct * vec1, const fq_struct * vec2, slong len2, const fq_t c, const fq_ctx_t ctx) + # Adds ``(vec2, len2)`` times `c` to ``(vec1, len2)``, where + # `c` is a ``fq_t``. + + void _fq_vec_scalar_submul_fq(fq_struct * vec1, const fq_struct * vec2, slong len2, const fq_t c, const fq_ctx_t ctx) + # Subtracts ``(vec2, len2)`` times `c` from ``(vec1, len2)``, + # where `c` is a ``fq_t``. + + void _fq_vec_dot(fq_t res, const fq_struct * vec1, const fq_struct * vec2, slong len2, const fq_ctx_t ctx) + # Sets ``res`` to the dot product of (``vec1``, ``len``) + # and (``vec2``, ``len``). diff --git a/src/sage/libs/flint/fq_zech.pxd b/src/sage/libs/flint/fq_zech.pxd index 1ba59753e97..b0e702ada14 100644 --- a/src/sage/libs/flint/fq_zech.pxd +++ b/src/sage/libs/flint/fq_zech.pxd @@ -12,7 +12,7 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void fq_zech_ctx_init(fq_zech_ctx_t ctx, const fmpz_t p, long d, const char *var) + void fq_zech_ctx_init(fq_zech_ctx_t ctx, const fmpz_t p, slong d, const char *var) # Initialises the context for prime `p` and extension degree `d`, # with name ``var`` for the generator. By default, it will try # use a Conway polynomial; if one is not available, a random @@ -21,7 +21,7 @@ cdef extern from "flint_wrap.h": # Assumes that the string ``var`` is a null-terminated string # of length at least one. - int _fq_zech_ctx_init_conway(fq_zech_ctx_t ctx, const fmpz_t p, long d, const char *var) + int _fq_zech_ctx_init_conway(fq_zech_ctx_t ctx, const fmpz_t p, slong d, const char *var) # Attempts to initialise the context for prime `p` and extension # degree `d`, with name ``var`` for the generator using a Conway # polynomial for the modulus. @@ -32,7 +32,7 @@ cdef extern from "flint_wrap.h": # Assumes that the string ``var`` is a null-terminated string # of length at least one. - void fq_zech_ctx_init_conway(fq_zech_ctx_t ctx, const fmpz_t p, long d, const char *var) + void fq_zech_ctx_init_conway(fq_zech_ctx_t ctx, const fmpz_t p, slong d, const char *var) # Initialises the context for prime `p` and extension degree `d`, # with name ``var`` for the generator using a Conway polynomial # for the modulus. @@ -40,7 +40,7 @@ cdef extern from "flint_wrap.h": # Assumes that the string ``var`` is a null-terminated string # of length at least one. - void fq_zech_ctx_init_random(fq_zech_ctx_t ctx, const fmpz_t p, long d, const char *var) + void fq_zech_ctx_init_random(fq_zech_ctx_t ctx, const fmpz_t p, slong d, const char *var) # Initialises the context for prime `p` and extension degree `d`, # with name ``var`` for the generator using a random primitive # polynomial. @@ -77,7 +77,7 @@ cdef extern from "flint_wrap.h": const nmod_poly_struct* fq_zech_ctx_modulus(const fq_zech_ctx_t ctx) # Returns a pointer to the modulus in the context. - long fq_zech_ctx_degree(const fq_zech_ctx_t ctx) + slong fq_zech_ctx_degree(const fq_zech_ctx_t ctx) # Returns the degree of the field extension # `[\mathbf{F}_{q} : \mathbf{F}_{p}]`, which # is equal to `\log_{p} q`. @@ -117,15 +117,15 @@ cdef extern from "flint_wrap.h": void fq_zech_clear(fq_zech_t rop, const fq_zech_ctx_t ctx) # Clears the element ``rop``. - void _fq_zech_sparse_reduce(mp_ptr R, long lenR, const fq_zech_ctx_t ctx) + void _fq_zech_sparse_reduce(mp_ptr R, slong lenR, const fq_zech_ctx_t ctx) # Reduces ``(R, lenR)`` modulo the polynomial `f` given by the # modulus of ``ctx``. - void _fq_zech_dense_reduce(mp_ptr R, long lenR, const fq_zech_ctx_t ctx) + void _fq_zech_dense_reduce(mp_ptr R, slong lenR, const fq_zech_ctx_t ctx) # Reduces ``(R, lenR)`` modulo the polynomial `f` given by the # modulus of ``ctx`` using Newton division. - void _fq_zech_reduce(mp_ptr r, long lenR, const fq_zech_ctx_t ctx) + void _fq_zech_reduce(mp_ptr r, slong lenR, const fq_zech_ctx_t ctx) # Reduces ``(R, lenR)`` modulo the polynomial `f` given by the # modulus of ``ctx``. Does either sparse or dense reduction # based on ``ctx->sparse_modulus``. @@ -154,11 +154,11 @@ cdef extern from "flint_wrap.h": # Sets ``rop`` to the product of ``op`` and `x`, # reducing the output in the given context. - void fq_zech_mul_si(fq_zech_t rop, const fq_zech_t op, long x, const fq_zech_ctx_t ctx) + void fq_zech_mul_si(fq_zech_t rop, const fq_zech_t op, slong x, const fq_zech_ctx_t ctx) # Sets ``rop`` to the product of ``op`` and `x`, # reducing the output in the given context. - void fq_zech_mul_ui(fq_zech_t rop, const fq_zech_t op, unsigned long x, const fq_zech_ctx_t ctx) + void fq_zech_mul_ui(fq_zech_t rop, const fq_zech_t op, ulong x, const fq_zech_ctx_t ctx) # Sets ``rop`` to the product of ``op`` and `x`, # reducing the output in the given context. @@ -170,7 +170,7 @@ cdef extern from "flint_wrap.h": # Sets ``rop`` to the quotient of ``op1`` and ``op2``, # reducing the output in the given context. - void _fq_zech_inv(mp_ptr *rop, mp_srcptr *op, long len, const fq_zech_ctx_t ctx) + void _fq_zech_inv(mp_ptr *rop, mp_srcptr *op, slong len, const fq_zech_ctx_t ctx) # Sets ``(rop, d)`` to the inverse of the non-zero element # ``(op, len)``. @@ -182,7 +182,7 @@ cdef extern from "flint_wrap.h": # of ``ctx`` and sets ``f`` to one. Since the modulus for # ``ctx`` is always irreducible, ``op`` is always invertible. - void _fq_zech_pow(fmpz *rop, const fmpz *op, long len, const fmpz_t e, const fmpz * a, const long *j, long lena, const fmpz_t p) + void _fq_zech_pow(fmpz *rop, const fmpz *op, slong len, const fmpz_t e, const fmpz * a, const slong *j, slong lena, const fmpz_t p) # Sets ``(rop, 2*d-1)`` to ``(op,len)`` raised to the power `e`, # reduced modulo `f(X)`, the modulus of ``ctx``. # Assumes that `e \geq 0` and that ``len`` is positive and at most `d`. @@ -197,7 +197,7 @@ cdef extern from "flint_wrap.h": # Note that for any input ``op``, ``rop`` is set to `1` # whenever `e = 0`. - void fq_zech_pow_ui(fq_zech_t rop, const fq_zech_t op, const unsigned long e, const fq_zech_ctx_t ctx) + void fq_zech_pow_ui(fq_zech_t rop, const fq_zech_t op, const ulong e, const fq_zech_ctx_t ctx) # Sets ``rop`` the ``op`` raised to the power `e`. # Currently assumes that `e \geq 0`. # Note that for any input ``op``, ``rop`` is set to `1` @@ -260,11 +260,11 @@ cdef extern from "flint_wrap.h": void fq_zech_set(fq_zech_t rop, const fq_zech_t op, const fq_zech_ctx_t ctx) # Sets ``rop`` to ``op``. - void fq_zech_set_si(fq_zech_t rop, const long x, const fq_zech_ctx_t ctx) + void fq_zech_set_si(fq_zech_t rop, const slong x, const fq_zech_ctx_t ctx) # Sets ``rop`` to ``x``, considered as an element of # `\mathbf{F}_p`. - void fq_zech_set_ui(fq_zech_t rop, const unsigned long x, const fq_zech_ctx_t ctx) + void fq_zech_set_ui(fq_zech_t rop, const ulong x, const fq_zech_ctx_t ctx) # Sets ``rop`` to ``x``, considered as an element of # `\mathbf{F}_p`. @@ -348,7 +348,7 @@ cdef extern from "flint_wrap.h": # `d = \text{dim}_{\mathbf{F}_p}(\mathbf{F}_q)`. # Algorithm selection is automatic depending on the input. - void fq_zech_frobenius(fq_zech_t rop, const fq_zech_t op, long e, const fq_zech_ctx_t ctx) + void fq_zech_frobenius(fq_zech_t rop, const fq_zech_t op, slong e, const fq_zech_ctx_t ctx) # Evaluates the homomorphism `\Sigma^e` at ``op``. # Recall that `\mathbf{F}_q / \mathbf{F}_p` is Galois with Galois group # `\langle \sigma \rangle`, which is also isomorphic to diff --git a/src/sage/libs/flint/fq_zech_embed.pxd b/src/sage/libs/flint/fq_zech_embed.pxd index bcb53c83ffb..b008efebd5d 100644 --- a/src/sage/libs/flint/fq_zech_embed.pxd +++ b/src/sage/libs/flint/fq_zech_embed.pxd @@ -70,7 +70,7 @@ cdef extern from "flint_wrap.h": # For an element `a\in\mathbf{F}_{p^n}`, its composition matrix is the # matrix whose columns are `a^0, a^1, \ldots, a^{n-1}`. - void fq_zech_embed_composition_matrix_sub(nmod_mat_t matrix, const fq_zech_t gen, const fq_zech_ctx_t ctx, long trunc) + void fq_zech_embed_composition_matrix_sub(nmod_mat_t matrix, const fq_zech_t gen, const fq_zech_ctx_t ctx, slong trunc) # Compute the *composition matrix* of ``gen``, truncated to # ``trunc`` columns. @@ -88,7 +88,7 @@ cdef extern from "flint_wrap.h": # Compute the change of basis matrix from the dual basis of # ``ctx`` to its monomial basis. - void fq_zech_modulus_pow_series_inv(nmod_poly_t res, const fq_zech_ctx_t ctx, long trunc) + void fq_zech_modulus_pow_series_inv(nmod_poly_t res, const fq_zech_ctx_t ctx, slong trunc) # Compute the power series inverse of the reverse of the modulus of # ``ctx`` up to `O(x^\texttt{trunc})`. diff --git a/src/sage/libs/flint/fq_zech_mat.pxd b/src/sage/libs/flint/fq_zech_mat.pxd index d057b0b90cb..33a961840f9 100644 --- a/src/sage/libs/flint/fq_zech_mat.pxd +++ b/src/sage/libs/flint/fq_zech_mat.pxd @@ -12,7 +12,7 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void fq_zech_mat_init(fq_zech_mat_t mat, long rows, long cols, const fq_zech_ctx_t ctx) + void fq_zech_mat_init(fq_zech_mat_t mat, slong rows, slong cols, const fq_zech_ctx_t ctx) # Initialises ``mat`` to a ``rows``-by-``cols`` matrix with # coefficients in `\mathbf{F}_{q}` given by ``ctx``. All elements # are set to zero. @@ -30,17 +30,17 @@ cdef extern from "flint_wrap.h": # Sets ``mat`` to a copy of ``src``. It is assumed # that ``mat`` and ``src`` have identical dimensions. - fq_zech_struct * fq_zech_mat_entry(const fq_zech_mat_t mat, long i, long j) + fq_zech_struct * fq_zech_mat_entry(const fq_zech_mat_t mat, slong i, slong j) # Directly accesses the entry in ``mat`` in row `i` and column `j`, # indexed from zero. No bounds checking is performed. - void fq_zech_mat_entry_set(fq_zech_mat_t mat, long i, long j, const fq_zech_t x, const fq_zech_ctx_t ctx) + void fq_zech_mat_entry_set(fq_zech_mat_t mat, slong i, slong j, const fq_zech_t x, const fq_zech_ctx_t ctx) # Sets the entry in ``mat`` in row `i` and column `j` to ``x``. - long fq_zech_mat_nrows(const fq_zech_mat_t mat, const fq_zech_ctx_t ctx) + slong fq_zech_mat_nrows(const fq_zech_mat_t mat, const fq_zech_ctx_t ctx) # Returns the number of rows in ``mat``. - long fq_zech_mat_ncols(const fq_zech_mat_t mat, const fq_zech_ctx_t ctx) + slong fq_zech_mat_ncols(const fq_zech_mat_t mat, const fq_zech_ctx_t ctx) # Returns the number of columns in ``mat``. void fq_zech_mat_swap(fq_zech_mat_t mat1, fq_zech_mat_t mat2, const fq_zech_ctx_t ctx) @@ -89,7 +89,7 @@ cdef extern from "flint_wrap.h": # In case of success, returns a positive value. In case of failure, # returns a non-positive value. - void fq_zech_mat_window_init(fq_zech_mat_t window, const fq_zech_mat_t mat, long r1, long c1, long r2, long c2, const fq_zech_ctx_t ctx) + void fq_zech_mat_window_init(fq_zech_mat_t window, const fq_zech_mat_t mat, slong r1, slong c1, slong r2, slong c2, const fq_zech_ctx_t ctx) # Initializes the matrix ``window`` to be an ``r2 - r1`` by # ``c2 - c1`` submatrix of ``mat`` whose ``(0,0)`` entry # is the ``(r1, c1)`` entry of ``mat``. The memory for the @@ -104,7 +104,7 @@ cdef extern from "flint_wrap.h": # Sets the elements of ``mat`` to random elements of # `\mathbf{F}_{q}`, given by ``ctx``. - int fq_zech_mat_randpermdiag(fq_zech_mat_t mat, flint_rand_t state, fq_zech_struct * diag, long n, const fq_zech_ctx_t ctx) + int fq_zech_mat_randpermdiag(fq_zech_mat_t mat, flint_rand_t state, fq_zech_struct * diag, slong n, const fq_zech_ctx_t ctx) # Sets ``mat`` to a random permutation of the diagonal matrix # with `n` leading entries given by the vector ``diag``. It is # assumed that the main diagonal of ``mat`` has room for at @@ -112,7 +112,7 @@ cdef extern from "flint_wrap.h": # Returns `0` or `1`, depending on whether the permutation is even # or odd respectively. - void fq_zech_mat_randrank(fq_zech_mat_t mat, flint_rand_t state, long rank, const fq_zech_ctx_t ctx) + void fq_zech_mat_randrank(fq_zech_mat_t mat, flint_rand_t state, slong rank, const fq_zech_ctx_t ctx) # Sets ``mat`` to a random sparse matrix with the given rank, # having exactly as many non-zero elements as the rank, with the # non-zero elements being uniformly random elements of @@ -120,7 +120,7 @@ cdef extern from "flint_wrap.h": # The matrix can be transformed into a dense matrix with unchanged # rank by subsequently calling :func:`fq_zech_mat_randops`. - void fq_zech_mat_randops(fq_zech_mat_t mat, long count, flint_rand_t state, const fq_zech_ctx_t ctx) + void fq_zech_mat_randops(fq_zech_mat_t mat, slong count, flint_rand_t state, const fq_zech_ctx_t ctx) # Randomises ``mat`` by performing elementary row or column # operations. More precisely, at most ``count`` random additions # or subtractions of distinct rows and columns will be performed. @@ -189,19 +189,19 @@ cdef extern from "flint_wrap.h": # Sets `D = C + AB`. `C` and `D` may be aliased with each other but # not with `A` or `B`. - void fq_zech_mat_mul_vec(fq_zech_struct * c, const fq_zech_mat_t A, const fq_zech_struct * b, long blen, const fq_zech_ctx_t ctx) - void fq_zech_mat_mul_vec_ptr(fq_zech_struct * const * c, const fq_zech_mat_t A, const fq_zech_struct * const * b, long blen, const fq_zech_ctx_t ctx) + void fq_zech_mat_mul_vec(fq_zech_struct * c, const fq_zech_mat_t A, const fq_zech_struct * b, slong blen, const fq_zech_ctx_t ctx) + void fq_zech_mat_mul_vec_ptr(fq_zech_struct * const * c, const fq_zech_mat_t A, const fq_zech_struct * const * b, slong blen, const fq_zech_ctx_t ctx) # Compute a matrix-vector product of ``A`` and ``(b, blen)`` and store the result in ``c``. # The vector ``(b, blen)`` is either truncated or zero-extended to the number of columns of ``A``. # The number entries written to ``c`` is always equal to the number of rows of ``A``. - void fq_zech_mat_vec_mul(fq_zech_struct * c, const fq_zech_struct * a, long alen, const fq_zech_mat_t B, const fq_zech_ctx_t ctx) - void fq_zech_mat_vec_mul_ptr(fq_zech_struct * const * c, const fq_zech_struct * const * a, long alen, const fq_zech_mat_t B, const fq_zech_ctx_t ctx) + void fq_zech_mat_vec_mul(fq_zech_struct * c, const fq_zech_struct * a, slong alen, const fq_zech_mat_t B, const fq_zech_ctx_t ctx) + void fq_zech_mat_vec_mul_ptr(fq_zech_struct * const * c, const fq_zech_struct * const * a, slong alen, const fq_zech_mat_t B, const fq_zech_ctx_t ctx) # Compute a vector-matrix product of ``(a, alen)`` and ``B`` and and store the result in ``c``. # The vector ``(a, alen)`` is either truncated or zero-extended to the number of rows of ``B``. # The number entries written to ``c`` is always equal to the number of columns of ``B``. - long fq_zech_mat_lu(long * P, fq_zech_mat_t A, int rank_check, const fq_zech_ctx_t ctx) + slong fq_zech_mat_lu(slong * P, fq_zech_mat_t A, int rank_check, const fq_zech_ctx_t ctx) # Computes a generalised LU decomposition `LU = PA` of a given # matrix `A`, returning the rank of `A`. # If `A` is a nonsingular square matrix, it will be overwritten with @@ -218,26 +218,26 @@ cdef extern from "flint_wrap.h": # if `A` is detected to be rank-deficient. # This function calls ``fq_zech_mat_lu_recursive``. - long fq_zech_mat_lu_classical(long * P, fq_zech_mat_t A, int rank_check, const fq_zech_ctx_t ctx) + slong fq_zech_mat_lu_classical(slong * P, fq_zech_mat_t A, int rank_check, const fq_zech_ctx_t ctx) # Computes a generalised LU decomposition `LU = PA` of a given # matrix `A`, returning the rank of `A`. The behavior of this # function is identical to that of ``fq_zech_mat_lu``. Uses Gaussian # elimination. - long fq_zech_mat_lu_recursive(long * P, fq_zech_mat_t A, int rank_check, const fq_zech_ctx_t ctx) + slong fq_zech_mat_lu_recursive(slong * P, fq_zech_mat_t A, int rank_check, const fq_zech_ctx_t ctx) # Computes a generalised LU decomposition `LU = PA` of a given # matrix `A`, returning the rank of `A`. The behavior of this # function is identical to that of ``fq_zech_mat_lu``. Uses recursive # block decomposition, switching to classical Gaussian elimination # for sufficiently small blocks. - long fq_zech_mat_rref(fq_zech_mat_t A, const fq_zech_ctx_t ctx) + slong fq_zech_mat_rref(fq_zech_mat_t A, const fq_zech_ctx_t ctx) # Puts `A` in reduced row echelon form and returns the rank of `A`. # The rref is computed by first obtaining an unreduced row echelon # form via LU decomposition and then solving an additional # triangular system. - long fq_zech_mat_reduce_row(fq_zech_mat_t A, long * P, long * L, long n, const fq_zech_ctx_t ctx) + slong fq_zech_mat_reduce_row(fq_zech_mat_t A, slong * P, slong * L, slong n, const fq_zech_ctx_t ctx) # Reduce row n of the matrix `A`, assuming the prior rows are in Gauss # form. However those rows may not be in order. The entry `i` of the array # `P` is the row of `A` which has a pivot in the `i`-th column. If no such @@ -321,7 +321,7 @@ cdef extern from "flint_wrap.h": # valid solutions is given. # There are no restrictions on the shape of `A` and it may be singular. - void fq_zech_mat_similarity(fq_zech_mat_t M, long r, fq_zech_t d, const fq_zech_ctx_t ctx) + void fq_zech_mat_similarity(fq_zech_mat_t M, slong r, fq_zech_t d, const fq_zech_ctx_t ctx) # Applies a similarity transform to the `n\times n` matrix `M` in-place. # If `P` is the `n\times n` identity matrix the zero entries of whose row # `r` (`0`-indexed) have been replaced by `d`, this transform is equivalent diff --git a/src/sage/libs/flint/fq_zech_poly.pxd b/src/sage/libs/flint/fq_zech_poly.pxd index 31d19a35841..608a82eb32c 100644 --- a/src/sage/libs/flint/fq_zech_poly.pxd +++ b/src/sage/libs/flint/fq_zech_poly.pxd @@ -18,21 +18,21 @@ cdef extern from "flint_wrap.h": # must be made after finishing with the ``fq_zech_poly_t`` to free the # memory used by the polynomial. - void fq_zech_poly_init2(fq_zech_poly_t poly, long alloc, const fq_zech_ctx_t ctx) + void fq_zech_poly_init2(fq_zech_poly_t poly, slong alloc, const fq_zech_ctx_t ctx) # Initialises ``poly`` with space for at least ``alloc`` # coefficients and sets the length to zero. The allocated # coefficients are all set to zero. A corresponding call to # :func:`fq_zech_poly_clear` must be made after finishing with the # ``fq_zech_poly_t`` to free the memory used by the polynomial. - void fq_zech_poly_realloc(fq_zech_poly_t poly, long alloc, const fq_zech_ctx_t ctx) + void fq_zech_poly_realloc(fq_zech_poly_t poly, slong alloc, const fq_zech_ctx_t ctx) # Reallocates the given polynomial to have space for ``alloc`` # coefficients. If ``alloc`` is zero the polynomial is cleared # and then reinitialised. If the current length is greater than # ``alloc`` the polynomial is first truncated to length # ``alloc``. - void fq_zech_poly_fit_length(fq_zech_poly_t poly, long len, const fq_zech_ctx_t ctx) + void fq_zech_poly_fit_length(fq_zech_poly_t poly, slong len, const fq_zech_ctx_t ctx) # If ``len`` is greater than the number of coefficients currently # allocated, then the polynomial is reallocated to have space for at # least ``len`` coefficients. No data is lost when calling this @@ -42,7 +42,7 @@ cdef extern from "flint_wrap.h": # least doubling the number of allocated coefficients when length is # larger than the number of coefficients currently allocated. - void _fq_zech_poly_set_length(fq_zech_poly_t poly, long newlen, const fq_zech_ctx_t ctx) + void _fq_zech_poly_set_length(fq_zech_poly_t poly, slong newlen, const fq_zech_ctx_t ctx) # Sets the coefficients of ``poly`` beyond ``len`` to zero and # sets the length of ``poly`` to ``len``. @@ -56,19 +56,19 @@ cdef extern from "flint_wrap.h": # zero. This function is mainly used internally, as all functions # guarantee normalisation. - void _fq_zech_poly_normalise2(const fq_zech_struct *poly, long *length, const fq_zech_ctx_t ctx) + void _fq_zech_poly_normalise2(const fq_zech_struct *poly, slong *length, const fq_zech_ctx_t ctx) # Sets the length ``length`` of ``(poly,length)`` so that the # top coefficient is non-zero. If all coefficients are zero, the # length is set to zero. This function is mainly used internally, as # all functions guarantee normalisation. - void fq_zech_poly_truncate(fq_zech_poly_t poly, long newlen, const fq_zech_ctx_t ctx) + void fq_zech_poly_truncate(fq_zech_poly_t poly, slong newlen, const fq_zech_ctx_t ctx) # Truncates the polynomial to length at most `n`. - void fq_zech_poly_set_trunc(fq_zech_poly_t poly1, fq_zech_poly_t poly2, long newlen, const fq_zech_ctx_t ctx) + void fq_zech_poly_set_trunc(fq_zech_poly_t poly1, fq_zech_poly_t poly2, slong newlen, const fq_zech_ctx_t ctx) # Sets ``poly1`` to ``poly2`` truncated to length `n`. - void _fq_zech_poly_reverse(fq_zech_struct* output, const fq_zech_struct* input, long len, long m, const fq_zech_ctx_t ctx) + void _fq_zech_poly_reverse(fq_zech_struct* output, const fq_zech_struct* input, slong len, slong m, const fq_zech_ctx_t ctx) # Sets ``output`` to the reverse of ``input``, which is of # length ``len``, but thinking of it as a polynomial of # length ``m``, notionally zero-padded if necessary. The @@ -76,40 +76,40 @@ cdef extern from "flint_wrap.h": # restrictions. The polynomial ``output`` must have space for # ``m`` coefficients. - void fq_zech_poly_reverse(fq_zech_poly_t output, const fq_zech_poly_t input, long m, const fq_zech_ctx_t ctx) + void fq_zech_poly_reverse(fq_zech_poly_t output, const fq_zech_poly_t input, slong m, const fq_zech_ctx_t ctx) # Sets ``output`` to the reverse of ``input``, thinking of it # as a polynomial of length ``m``, notionally zero-padded if # necessary). The length ``m`` must be non-negative, but there # are no other restrictions. The output polynomial will be set to # length ``m`` and then normalised. - long fq_zech_poly_degree(const fq_zech_poly_t poly, const fq_zech_ctx_t ctx) + slong fq_zech_poly_degree(const fq_zech_poly_t poly, const fq_zech_ctx_t ctx) # Returns the degree of the polynomial ``poly``. - long fq_zech_poly_length(const fq_zech_poly_t poly, const fq_zech_ctx_t ctx) + slong fq_zech_poly_length(const fq_zech_poly_t poly, const fq_zech_ctx_t ctx) # Returns the length of the polynomial ``poly``. fq_zech_struct * fq_zech_poly_lead(const fq_zech_poly_t poly, const fq_zech_ctx_t ctx) # Returns a pointer to the leading coefficient of ``poly``, or # ``NULL`` if ``poly`` is the zero polynomial. - void fq_zech_poly_randtest(fq_zech_poly_t f, flint_rand_t state, long len, const fq_zech_ctx_t ctx) + void fq_zech_poly_randtest(fq_zech_poly_t f, flint_rand_t state, slong len, const fq_zech_ctx_t ctx) # Sets `f` to a random polynomial of length at most ``len`` # with entries in the field described by ``ctx``. - void fq_zech_poly_randtest_not_zero(fq_zech_poly_t f, flint_rand_t state, long len, const fq_zech_ctx_t ctx) + void fq_zech_poly_randtest_not_zero(fq_zech_poly_t f, flint_rand_t state, slong len, const fq_zech_ctx_t ctx) # Same as ``fq_zech_poly_randtest`` but guarantees that the polynomial # is not zero. - void fq_zech_poly_randtest_monic(fq_zech_poly_t f, flint_rand_t state, long len, const fq_zech_ctx_t ctx) + void fq_zech_poly_randtest_monic(fq_zech_poly_t f, flint_rand_t state, slong len, const fq_zech_ctx_t ctx) # Sets `f` to a random monic polynomial of length ``len`` with # entries in the field described by ``ctx``. - void fq_zech_poly_randtest_irreducible(fq_zech_poly_t f, flint_rand_t state, long len, const fq_zech_ctx_t ctx) + void fq_zech_poly_randtest_irreducible(fq_zech_poly_t f, flint_rand_t state, slong len, const fq_zech_ctx_t ctx) # Sets `f` to a random monic, irreducible polynomial of length # ``len`` with entries in the field described by ``ctx``. - void _fq_zech_poly_set(fq_zech_struct *rop, const fq_zech_struct *op, long len, const fq_zech_ctx_t ctx) + void _fq_zech_poly_set(fq_zech_struct *rop, const fq_zech_struct *op, slong len, const fq_zech_ctx_t ctx) # Sets ``(rop, len``) to ``(op, len)``. void fq_zech_poly_set(fq_zech_poly_t poly1, const fq_zech_poly_t poly2, const fq_zech_ctx_t ctx) @@ -127,7 +127,7 @@ cdef extern from "flint_wrap.h": void fq_zech_poly_swap(fq_zech_poly_t op1, fq_zech_poly_t op2, const fq_zech_ctx_t ctx) # Swaps the two polynomials ``op1`` and ``op2``. - void _fq_zech_poly_zero(fq_zech_struct *rop, long len, const fq_zech_ctx_t ctx) + void _fq_zech_poly_zero(fq_zech_struct *rop, slong len, const fq_zech_ctx_t ctx) # Sets ``(rop, len)`` to the zero polynomial. void fq_zech_poly_zero(fq_zech_poly_t poly, const fq_zech_ctx_t ctx) @@ -142,18 +142,18 @@ cdef extern from "flint_wrap.h": void fq_zech_poly_make_monic(fq_zech_poly_t rop, const fq_zech_poly_t op, const fq_zech_ctx_t ctx) # Sets ``rop`` to ``op``, normed to have leading coefficient 1. - void _fq_zech_poly_make_monic(fq_zech_struct *rop, const fq_zech_struct *op, long length, const fq_zech_ctx_t ctx) + void _fq_zech_poly_make_monic(fq_zech_struct *rop, const fq_zech_struct *op, slong length, const fq_zech_ctx_t ctx) # Sets ``rop`` to ``(op,length)``, normed to have leading coefficient 1. # Assumes that ``rop`` has enough space for the polynomial, assumes that # ``op`` is not zero (and thus has an invertible leading coefficient). - void fq_zech_poly_get_coeff(fq_zech_t x, const fq_zech_poly_t poly, long n, const fq_zech_ctx_t ctx) + void fq_zech_poly_get_coeff(fq_zech_t x, const fq_zech_poly_t poly, slong n, const fq_zech_ctx_t ctx) # Sets `x` to the coefficient of `X^n` in ``poly``. - void fq_zech_poly_set_coeff(fq_zech_poly_t poly, long n, const fq_zech_t x, const fq_zech_ctx_t ctx) + void fq_zech_poly_set_coeff(fq_zech_poly_t poly, slong n, const fq_zech_t x, const fq_zech_ctx_t ctx) # Sets the coefficient of `X^n` in ``poly`` to `x`. - void fq_zech_poly_set_coeff_fmpz(fq_zech_poly_t poly, long n, const fmpz_t x, const fq_zech_ctx_t ctx) + void fq_zech_poly_set_coeff_fmpz(fq_zech_poly_t poly, slong n, const fmpz_t x, const fq_zech_ctx_t ctx) # Sets the coefficient of `X^n` in the polynomial to `x`, # assuming `n \geq 0`. @@ -161,7 +161,7 @@ cdef extern from "flint_wrap.h": # Returns nonzero if the two polynomials ``poly1`` and ``poly2`` # are equal, otherwise return zero. - int fq_zech_poly_equal_trunc(const fq_zech_poly_t poly1, const fq_zech_poly_t poly2, long n, const fq_zech_ctx_t ctx) + int fq_zech_poly_equal_trunc(const fq_zech_poly_t poly1, const fq_zech_poly_t poly2, slong n, const fq_zech_ctx_t ctx) # Notionally truncate ``poly1`` and ``poly2`` to length `n` and # return nonzero if they are equal, otherwise return zero. @@ -184,37 +184,37 @@ cdef extern from "flint_wrap.h": # Returns whether the polynomial ``poly`` is equal the (constant) # `\mathbf{F}_q` element ``c`` - void _fq_zech_poly_add(fq_zech_struct *res, const fq_zech_struct *poly1, long len1, const fq_zech_struct *poly2, long len2, const fq_zech_ctx_t ctx) + void _fq_zech_poly_add(fq_zech_struct *res, const fq_zech_struct *poly1, slong len1, const fq_zech_struct *poly2, slong len2, const fq_zech_ctx_t ctx) # Sets ``res`` to the sum of ``(poly1,len1)`` and ``(poly2,len2)``. void fq_zech_poly_add(fq_zech_poly_t res, const fq_zech_poly_t poly1, const fq_zech_poly_t poly2, const fq_zech_ctx_t ctx) # Sets ``res`` to the sum of ``poly1`` and ``poly2``. - void fq_zech_poly_add_si(fq_zech_poly_t res, const fq_zech_poly_t poly1, long c, const fq_zech_ctx_t ctx) + void fq_zech_poly_add_si(fq_zech_poly_t res, const fq_zech_poly_t poly1, slong c, const fq_zech_ctx_t ctx) # Sets ``res`` to the sum of ``poly1`` and ``c``. - void fq_zech_poly_add_series(fq_zech_poly_t res, const fq_zech_poly_t poly1, const fq_zech_poly_t poly2, long n, const fq_zech_ctx_t ctx) + void fq_zech_poly_add_series(fq_zech_poly_t res, const fq_zech_poly_t poly1, const fq_zech_poly_t poly2, slong n, const fq_zech_ctx_t ctx) # Notionally truncate ``poly1`` and ``poly2`` to length ``n`` and set # ``res`` to the sum. - void _fq_zech_poly_sub(fq_zech_struct *res, const fq_zech_struct *poly1, long len1, const fq_zech_struct *poly2, long len2, const fq_zech_ctx_t ctx) + void _fq_zech_poly_sub(fq_zech_struct *res, const fq_zech_struct *poly1, slong len1, const fq_zech_struct *poly2, slong len2, const fq_zech_ctx_t ctx) # Sets ``res`` to the difference of ``(poly1,len1)`` and # ``(poly2,len2)``. void fq_zech_poly_sub(fq_zech_poly_t res, const fq_zech_poly_t poly1, const fq_zech_poly_t poly2, const fq_zech_ctx_t ctx) # Sets ``res`` to the difference of ``poly1`` and ``poly2``. - void fq_zech_poly_sub_series(fq_zech_poly_t res, const fq_zech_poly_t poly1, const fq_zech_poly_t poly2, long n, const fq_zech_ctx_t ctx) + void fq_zech_poly_sub_series(fq_zech_poly_t res, const fq_zech_poly_t poly1, const fq_zech_poly_t poly2, slong n, const fq_zech_ctx_t ctx) # Notionally truncate ``poly1`` and ``poly2`` to length ``n`` and set # ``res`` to the difference. - void _fq_zech_poly_neg(fq_zech_struct *rop, const fq_zech_struct *op, long len, const fq_zech_ctx_t ctx) + void _fq_zech_poly_neg(fq_zech_struct *rop, const fq_zech_struct *op, slong len, const fq_zech_ctx_t ctx) # Sets ``rop`` to the additive inverse of ``(op,len)``. void fq_zech_poly_neg(fq_zech_poly_t res, const fq_zech_poly_t poly, const fq_zech_ctx_t ctx) # Sets ``res`` to the additive inverse of ``poly``. - void _fq_zech_poly_scalar_mul_fq_zech(fq_zech_struct *rop, const fq_zech_struct *op, long len, const fq_zech_t x, const fq_zech_ctx_t ctx) + void _fq_zech_poly_scalar_mul_fq_zech(fq_zech_struct *rop, const fq_zech_struct *op, slong len, const fq_zech_t x, const fq_zech_ctx_t ctx) # Sets ``(rop,len)`` to the product of ``(op,len)`` by the # scalar ``x``, in the context defined by ``ctx``. @@ -222,7 +222,7 @@ cdef extern from "flint_wrap.h": # Sets ``rop`` to the product of ``op`` by the scalar ``x``, in the context # defined by ``ctx``. - void _fq_zech_poly_scalar_addmul_fq_zech(fq_zech_struct *rop, const fq_zech_struct *op, long len, const fq_zech_t x, const fq_zech_ctx_t ctx) + void _fq_zech_poly_scalar_addmul_fq_zech(fq_zech_struct *rop, const fq_zech_struct *op, slong len, const fq_zech_t x, const fq_zech_ctx_t ctx) # Adds to ``(rop,len)`` the product of ``(op,len)`` by the # scalar ``x``, in the context defined by ``ctx``. # In particular, assumes the same length for ``op`` and @@ -232,7 +232,7 @@ cdef extern from "flint_wrap.h": # Adds to ``rop`` the product of ``op`` by the # scalar ``x``, in the context defined by ``ctx``. - void _fq_zech_poly_scalar_submul_fq_zech(fq_zech_struct *rop, const fq_zech_struct *op, long len, const fq_zech_t x, const fq_zech_ctx_t ctx) + void _fq_zech_poly_scalar_submul_fq_zech(fq_zech_struct *rop, const fq_zech_struct *op, slong len, const fq_zech_t x, const fq_zech_ctx_t ctx) # Subtracts from ``(rop,len)`` the product of ``(op,len)`` by the # scalar ``x``, in the context defined by ``ctx``. # In particular, assumes the same length for ``op`` and @@ -242,7 +242,7 @@ cdef extern from "flint_wrap.h": # Subtracts from ``rop`` the product of ``op`` by the # scalar ``x``, in the context defined by ``ctx``. - void _fq_zech_poly_scalar_div_fq_zech(fq_zech_struct *rop, const fq_zech_struct *op, long len, const fq_zech_t x, const fq_zech_ctx_t ctx) + void _fq_zech_poly_scalar_div_fq_zech(fq_zech_struct *rop, const fq_zech_struct *op, slong len, const fq_zech_t x, const fq_zech_ctx_t ctx) # Sets ``(rop,len)`` to the quotient of ``(op,len)`` by the # scalar ``x``, in the context defined by ``ctx``. An exception is raised # if ``x`` is zero. @@ -251,7 +251,7 @@ cdef extern from "flint_wrap.h": # Sets ``rop`` to the quotient of ``op`` by the scalar ``x``, in the context # defined by ``ctx``. An exception is raised if ``x`` is zero. - void _fq_zech_poly_mul_classical(fq_zech_struct *rop, const fq_zech_struct *op1, long len1, const fq_zech_struct *op2, long len2, const fq_zech_ctx_t ctx) + void _fq_zech_poly_mul_classical(fq_zech_struct *rop, const fq_zech_struct *op1, slong len1, const fq_zech_struct *op2, slong len2, const fq_zech_ctx_t ctx) # Sets ``(rop, len1 + len2 - 1)`` to the product of ``(op1, len1)`` # and ``(op2, len2)``, assuming that ``len1`` is at least ``len2`` # and neither is zero. @@ -262,7 +262,7 @@ cdef extern from "flint_wrap.h": # Sets ``rop`` to the product of ``op1`` and ``op2`` # using classical polynomial multiplication. - void _fq_zech_poly_mul_reorder(fq_zech_struct *rop, const fq_zech_struct *op1, long len1, const fq_zech_struct *op2, long len2, const fq_zech_ctx_t ctx) + void _fq_zech_poly_mul_reorder(fq_zech_struct *rop, const fq_zech_struct *op1, slong len1, const fq_zech_struct *op2, slong len2, const fq_zech_ctx_t ctx) # Sets ``(rop, len1 + len2 - 1)`` to the product of ``(op1, len1)`` # and ``(op2, len2)``, assuming that ``len1`` and ``len2`` are # non-zero. @@ -287,7 +287,7 @@ cdef extern from "flint_wrap.h": # multiplication routines in the `Y`-direction where the polynomial # degree `n` is large. - void _fq_zech_poly_mul_KS(fq_zech_struct *rop, const fq_zech_struct *op1, long len1, const fq_zech_struct *op2, long len2, const fq_zech_ctx_t ctx) + void _fq_zech_poly_mul_KS(fq_zech_struct *rop, const fq_zech_struct *op1, slong len1, const fq_zech_struct *op2, slong len2, const fq_zech_ctx_t ctx) # Sets ``(rop, len1 + len2 - 1)`` to the product of ``(op1, len1)`` # and ``(op2, len2)``. # Permits zero padding and places no assumptions on the @@ -299,7 +299,7 @@ cdef extern from "flint_wrap.h": # coefficient in `\mathbf{F}_{q}` as an integer and reducing # this problem to multiplying two polynomials over the integers. - void _fq_zech_poly_mul(fq_zech_struct *rop, const fq_zech_struct *op1, long len1, const fq_zech_struct *op2, long len2, const fq_zech_ctx_t ctx) + void _fq_zech_poly_mul(fq_zech_struct *rop, const fq_zech_struct *op1, slong len1, const fq_zech_struct *op2, slong len2, const fq_zech_ctx_t ctx) # Sets ``(rop, len1 + len2 - 1)`` to the product of ``(op1, len1)`` # and ``(op2, len2)``, choosing an appropriate algorithm. # Permits zero padding. Does not support aliasing. @@ -308,17 +308,17 @@ cdef extern from "flint_wrap.h": # Sets ``rop`` to the product of ``op1`` and ``op2``, # choosing an appropriate algorithm. - void _fq_zech_poly_mullow_classical(fq_zech_struct *rop, const fq_zech_struct *op1, long len1, const fq_zech_struct *op2, long len2, long n, const fq_zech_ctx_t ctx) + void _fq_zech_poly_mullow_classical(fq_zech_struct *rop, const fq_zech_struct *op1, slong len1, const fq_zech_struct *op2, slong len2, slong n, const fq_zech_ctx_t ctx) # Sets ``(rop, n)`` to the first `n` coefficients of # ``(op1, len1)`` multiplied by ``(op2, len2)``. # Assumes ``0 < n <= len1 + len2 - 1``. Assumes neither # ``len1`` nor ``len2`` is zero. - void fq_zech_poly_mullow_classical(fq_zech_poly_t rop, const fq_zech_poly_t op1, const fq_zech_poly_t op2, long n, const fq_zech_ctx_t ctx) + void fq_zech_poly_mullow_classical(fq_zech_poly_t rop, const fq_zech_poly_t op1, const fq_zech_poly_t op2, slong n, const fq_zech_ctx_t ctx) # Sets ``rop`` to the product of ``op1`` and ``op2``, # computed using the classical or schoolbook method. - void _fq_zech_poly_mullow_KS(fq_zech_struct *rop, const fq_zech_struct *op1, long len1, const fq_zech_struct *op2, long len2, long n, const fq_zech_ctx_t ctx) + void _fq_zech_poly_mullow_KS(fq_zech_struct *rop, const fq_zech_struct *op1, slong len1, const fq_zech_struct *op2, slong len2, slong n, const fq_zech_ctx_t ctx) # Sets ``(rop, n)`` to the lowest `n` coefficients of the product of # ``(op1, len1)`` and ``(op2, len2)``. # Assumes that ``len1`` and ``len2`` are positive, but does allow @@ -326,45 +326,45 @@ cdef extern from "flint_wrap.h": # too. Assumes `n` is positive. Supports aliasing between ``rop``, # ``op1`` and ``op2``. - void fq_zech_poly_mullow_KS(fq_zech_poly_t rop, const fq_zech_poly_t op1, const fq_zech_poly_t op2, long n, const fq_zech_ctx_t ctx) + void fq_zech_poly_mullow_KS(fq_zech_poly_t rop, const fq_zech_poly_t op1, const fq_zech_poly_t op2, slong n, const fq_zech_ctx_t ctx) # Sets ``rop`` to the product of ``op1`` and ``op2``. - void _fq_zech_poly_mullow(fq_zech_struct *rop, const fq_zech_struct *op1, long len1, const fq_zech_struct *op2, long len2, long n, const fq_zech_ctx_t ctx) + void _fq_zech_poly_mullow(fq_zech_struct *rop, const fq_zech_struct *op1, slong len1, const fq_zech_struct *op2, slong len2, slong n, const fq_zech_ctx_t ctx) # Sets ``(rop, n)`` to the lowest `n` coefficients of the product of # ``(op1, len1)`` and ``(op2, len2)``. # Assumes ``0 < n <= len1 + len2 - 1``. Allows for zero-padding in # the inputs. Does not support aliasing between the inputs and the output. - void fq_zech_poly_mullow(fq_zech_poly_t rop, const fq_zech_poly_t op1, const fq_zech_poly_t op2, long n, const fq_zech_ctx_t ctx) + void fq_zech_poly_mullow(fq_zech_poly_t rop, const fq_zech_poly_t op1, const fq_zech_poly_t op2, slong n, const fq_zech_ctx_t ctx) # Sets ``rop`` to the lowest `n` coefficients of the product of # ``op1`` and ``op2``. - void _fq_zech_poly_mulhigh_classical(fq_zech_struct *res, const fq_zech_struct *poly1, long len1, const fq_zech_struct *poly2, long len2, long start, const fq_zech_ctx_t ctx) + void _fq_zech_poly_mulhigh_classical(fq_zech_struct *res, const fq_zech_struct *poly1, slong len1, const fq_zech_struct *poly2, slong len2, slong start, const fq_zech_ctx_t ctx) # Computes the product of ``(poly1, len1)`` and ``(poly2, len2)`` # and writes the coefficients from ``start`` onwards into the high # coefficients of ``res``, the remaining coefficients being arbitrary # but reduced. Assumes that ``len1 >= len2 > 0``. Aliasing of inputs # and output is not permitted. Algorithm is classical multiplication. - void fq_zech_poly_mulhigh_classical(fq_zech_poly_t res, const fq_zech_poly_t poly1, const fq_zech_poly_t poly2, long start, const fq_zech_ctx_t ctx) + void fq_zech_poly_mulhigh_classical(fq_zech_poly_t res, const fq_zech_poly_t poly1, const fq_zech_poly_t poly2, slong start, const fq_zech_ctx_t ctx) # Computes the product of ``poly1`` and ``poly2`` and writes the # coefficients from ``start`` onwards into the high coefficients of # ``res``, the remaining coefficients being arbitrary but reduced. # Algorithm is classical multiplication. - void _fq_zech_poly_mulhigh(fq_zech_struct *res, const fq_zech_struct *poly1, long len1, const fq_zech_struct *poly2, long len2, long start, fq_zech_ctx_t ctx) + void _fq_zech_poly_mulhigh(fq_zech_struct *res, const fq_zech_struct *poly1, slong len1, const fq_zech_struct *poly2, slong len2, slong start, fq_zech_ctx_t ctx) # Computes the product of ``(poly1, len1)`` and ``(poly2, len2)`` # and writes the coefficients from ``start`` onwards into the high # coefficients of ``res``, the remaining coefficients being arbitrary # but reduced. Assumes that ``len1 >= len2 > 0``. Aliasing of inputs # and output is not permitted. - void fq_zech_poly_mulhigh(fq_zech_poly_t res, const fq_zech_poly_t poly1, const fq_zech_poly_t poly2, long start, const fq_zech_ctx_t ctx) + void fq_zech_poly_mulhigh(fq_zech_poly_t res, const fq_zech_poly_t poly1, const fq_zech_poly_t poly2, slong start, const fq_zech_ctx_t ctx) # Computes the product of ``poly1`` and ``poly2`` and writes the # coefficients from ``start`` onwards into the high coefficients of # ``res``, the remaining coefficients being arbitrary but reduced. - void _fq_zech_poly_mulmod(fq_zech_struct* res, const fq_zech_struct* poly1, long len1, const fq_zech_struct* poly2, long len2, const fq_zech_struct* f, long lenf, const fq_zech_ctx_t ctx) + void _fq_zech_poly_mulmod(fq_zech_struct* res, const fq_zech_struct* poly1, slong len1, const fq_zech_struct* poly2, slong len2, const fq_zech_struct* f, slong lenf, const fq_zech_ctx_t ctx) # Sets ``res`` to the remainder of the product of ``poly1`` # and ``poly2`` upon polynomial division by ``f``. # It is required that ``len1 + len2 - lenf > 0``, which is @@ -376,7 +376,7 @@ cdef extern from "flint_wrap.h": # Sets ``res`` to the remainder of the product of ``poly1`` # and ``poly2`` upon polynomial division by ``f``. - void _fq_zech_poly_mulmod_preinv(fq_zech_struct* res, const fq_zech_struct* poly1, long len1, const fq_zech_struct* poly2, long len2, const fq_zech_struct* f, long lenf, const fq_zech_struct* finv, long lenfinv, const fq_zech_ctx_t ctx) + void _fq_zech_poly_mulmod_preinv(fq_zech_struct* res, const fq_zech_struct* poly1, slong len1, const fq_zech_struct* poly2, slong len2, const fq_zech_struct* f, slong lenf, const fq_zech_struct* finv, slong lenfinv, const fq_zech_ctx_t ctx) # Sets ``res`` to the remainder of the product of ``poly1`` # and ``poly2`` upon polynomial division by ``f``. # It is required that ``finv`` is the inverse of the reverse of @@ -388,7 +388,7 @@ cdef extern from "flint_wrap.h": # and ``poly2`` upon polynomial division by ``f``. ``finv`` # is the inverse of the reverse of ``f``. - void _fq_zech_poly_sqr_classical(fq_zech_struct *rop, const fq_zech_struct *op, long len, const fq_zech_ctx_t ctx) + void _fq_zech_poly_sqr_classical(fq_zech_struct *rop, const fq_zech_struct *op, slong len, const fq_zech_ctx_t ctx) # Sets ``(rop, 2*len - 1)`` to the square of ``(op, len)``, # assuming that ``(op,len)`` is not zero and using classical # polynomial multiplication. @@ -399,7 +399,7 @@ cdef extern from "flint_wrap.h": # Sets ``rop`` to the square of ``op`` using classical # polynomial multiplication. - void _fq_zech_poly_sqr_KS(fq_zech_struct *rop, const fq_zech_struct *op, long len, const fq_zech_ctx_t ctx) + void _fq_zech_poly_sqr_KS(fq_zech_struct *rop, const fq_zech_struct *op, slong len, const fq_zech_ctx_t ctx) # Sets ``(rop, 2*len - 1)`` to the square of ``(op, len)``. # Permits zero padding and places no assumptions on the # lengths ``len1`` and ``len2``. Supports aliasing. @@ -409,7 +409,7 @@ cdef extern from "flint_wrap.h": # that is, by encoding each coefficient in `\mathbf{F}_{q}` as an integer # and reducing this problem to multiplying two polynomials over the integers. - void _fq_zech_poly_sqr(fq_zech_struct *rop, const fq_zech_struct *op, long len, const fq_zech_ctx_t ctx) + void _fq_zech_poly_sqr(fq_zech_struct *rop, const fq_zech_struct *op, slong len, const fq_zech_ctx_t ctx) # Sets ``(rop, 2* len - 1)`` to the square of ``(op, len)``, # choosing an appropriate algorithm. # Permits zero padding. Does not support aliasing. @@ -418,16 +418,16 @@ cdef extern from "flint_wrap.h": # Sets ``rop`` to the square of ``op``, # choosing an appropriate algorithm. - void _fq_zech_poly_pow(fq_zech_struct *rop, const fq_zech_struct *op, long len, unsigned long e, const fq_zech_ctx_t ctx) + void _fq_zech_poly_pow(fq_zech_struct *rop, const fq_zech_struct *op, slong len, ulong e, const fq_zech_ctx_t ctx) # Sets ``rop = op^e``, assuming that ``e, len > 0`` and that # ``res`` has space for ``e*(len - 1) + 1`` coefficients. Does # not support aliasing. - void fq_zech_poly_pow(fq_zech_poly_t rop, const fq_zech_poly_t op, unsigned long e, const fq_zech_ctx_t ctx) + void fq_zech_poly_pow(fq_zech_poly_t rop, const fq_zech_poly_t op, ulong e, const fq_zech_ctx_t ctx) # Computes ``rop = op^e``. If `e` is zero, returns one, # so that in particular ``0^0 = 1``. - void _fq_zech_poly_powmod_ui_binexp(fq_zech_struct* res, const fq_zech_struct* poly, unsigned long e, const fq_zech_struct* f, long lenf, const fq_zech_ctx_t ctx) + void _fq_zech_poly_powmod_ui_binexp(fq_zech_struct* res, const fq_zech_struct* poly, ulong e, const fq_zech_struct* f, slong lenf, const fq_zech_ctx_t ctx) # Sets ``res`` to ``poly`` raised to the power ``e`` modulo # ``f``, using binary exponentiation. We require ``e > 0``. # We require ``lenf > 1``. It is assumed that ``poly`` is @@ -435,11 +435,11 @@ cdef extern from "flint_wrap.h": # have length exactly ``lenf - 1``. The output ``res`` must # have room for ``lenf - 1`` coefficients. - void fq_zech_poly_powmod_ui_binexp(fq_zech_poly_t res, const fq_zech_poly_t poly, unsigned long e, const fq_zech_poly_t f, const fq_zech_ctx_t ctx) + void fq_zech_poly_powmod_ui_binexp(fq_zech_poly_t res, const fq_zech_poly_t poly, ulong e, const fq_zech_poly_t f, const fq_zech_ctx_t ctx) # Sets ``res`` to ``poly`` raised to the power ``e`` modulo # ``f``, using binary exponentiation. We require ``e >= 0``. - void _fq_zech_poly_powmod_ui_binexp_preinv(fq_zech_struct* res, const fq_zech_struct* poly, unsigned long e, const fq_zech_struct* f, long lenf, const fq_zech_struct* finv, long lenfinv, const fq_zech_ctx_t ctx) + void _fq_zech_poly_powmod_ui_binexp_preinv(fq_zech_struct* res, const fq_zech_struct* poly, ulong e, const fq_zech_struct* f, slong lenf, const fq_zech_struct* finv, slong lenfinv, const fq_zech_ctx_t ctx) # Sets ``res`` to ``poly`` raised to the power ``e`` modulo # ``f``, using binary exponentiation. We require ``e > 0``. # We require ``finv`` to be the inverse of the reverse of @@ -449,13 +449,13 @@ cdef extern from "flint_wrap.h": # have length exactly ``lenf - 1``. The output ``res`` must # have room for ``lenf - 1`` coefficients. - void fq_zech_poly_powmod_ui_binexp_preinv(fq_zech_poly_t res, const fq_zech_poly_t poly, unsigned long e, const fq_zech_poly_t f, const fq_zech_poly_t finv, const fq_zech_ctx_t ctx) + void fq_zech_poly_powmod_ui_binexp_preinv(fq_zech_poly_t res, const fq_zech_poly_t poly, ulong e, const fq_zech_poly_t f, const fq_zech_poly_t finv, const fq_zech_ctx_t ctx) # Sets ``res`` to ``poly`` raised to the power ``e`` modulo # ``f``, using binary exponentiation. We require ``e >= 0``. # We require ``finv`` to be the inverse of the reverse of # ``f``. - void _fq_zech_poly_powmod_fmpz_binexp(fq_zech_struct* res, const fq_zech_struct* poly, const fmpz_t e, const fq_zech_struct* f, long lenf, const fq_zech_ctx_t ctx) + void _fq_zech_poly_powmod_fmpz_binexp(fq_zech_struct* res, const fq_zech_struct* poly, const fmpz_t e, const fq_zech_struct* f, slong lenf, const fq_zech_ctx_t ctx) # Sets ``res`` to ``poly`` raised to the power ``e`` modulo # ``f``, using binary exponentiation. We require ``e > 0``. # We require ``lenf > 1``. It is assumed that ``poly`` is @@ -467,7 +467,7 @@ cdef extern from "flint_wrap.h": # Sets ``res`` to ``poly`` raised to the power ``e`` modulo # ``f``, using binary exponentiation. We require ``e >= 0``. - void _fq_zech_poly_powmod_fmpz_binexp_preinv(fq_zech_struct* res, const fq_zech_struct* poly, const fmpz_t e, const fq_zech_struct* f, long lenf, const fq_zech_struct* finv, long lenfinv, const fq_zech_ctx_t ctx) + void _fq_zech_poly_powmod_fmpz_binexp_preinv(fq_zech_struct* res, const fq_zech_struct* poly, const fmpz_t e, const fq_zech_struct* f, slong lenf, const fq_zech_struct* finv, slong lenfinv, const fq_zech_ctx_t ctx) # Sets ``res`` to ``poly`` raised to the power ``e`` modulo # ``f``, using binary exponentiation. We require ``e > 0``. # We require ``finv`` to be the inverse of the reverse of @@ -483,7 +483,7 @@ cdef extern from "flint_wrap.h": # We require ``finv`` to be the inverse of the reverse of # ``f``. - void _fq_zech_poly_powmod_fmpz_sliding_preinv(fq_zech_struct* res, const fq_zech_struct* poly, const fmpz_t e, unsigned long k, const fq_zech_struct* f, long lenf, const fq_zech_struct* finv, long lenfinv, const fq_zech_ctx_t ctx) + void _fq_zech_poly_powmod_fmpz_sliding_preinv(fq_zech_struct* res, const fq_zech_struct* poly, const fmpz_t e, ulong k, const fq_zech_struct* f, slong lenf, const fq_zech_struct* finv, slong lenfinv, const fq_zech_ctx_t ctx) # Sets ``res`` to ``poly`` raised to the power ``e`` modulo # ``f``, using sliding-window exponentiation with window size # ``k``. We require ``e > 0``. We require ``finv`` to be @@ -495,7 +495,7 @@ cdef extern from "flint_wrap.h": # have length exactly ``lenf - 1``. The output ``res`` must # have room for ``lenf - 1`` coefficients. - void fq_zech_poly_powmod_fmpz_sliding_preinv(fq_zech_poly_t res, const fq_zech_poly_t poly, const fmpz_t e, unsigned long k, const fq_zech_poly_t f, const fq_zech_poly_t finv, const fq_zech_ctx_t ctx) + void fq_zech_poly_powmod_fmpz_sliding_preinv(fq_zech_poly_t res, const fq_zech_poly_t poly, const fmpz_t e, ulong k, const fq_zech_poly_t f, const fq_zech_poly_t finv, const fq_zech_ctx_t ctx) # Sets ``res`` to ``poly`` raised to the power ``e`` modulo # ``f``, using sliding-window exponentiation with window size # ``k``. We require ``e >= 0``. We require ``finv`` to be @@ -503,7 +503,7 @@ cdef extern from "flint_wrap.h": # zero, then an "optimum" size will be selected automatically base # on ``e``. - void _fq_zech_poly_powmod_x_fmpz_preinv(fq_zech_struct * res, const fmpz_t e, const fq_zech_struct * f, long lenf, const fq_zech_struct * finv, long lenfinv, const fq_zech_ctx_t ctx) + void _fq_zech_poly_powmod_x_fmpz_preinv(fq_zech_struct * res, const fmpz_t e, const fq_zech_struct * f, slong lenf, const fq_zech_struct * finv, slong lenfinv, const fq_zech_ctx_t ctx) # Sets ``res`` to ``x`` raised to the power ``e`` modulo ``f``, # using sliding window exponentiation. We require ``e > 0``. # We require ``finv`` to be the inverse of the reverse of ``f``. @@ -516,18 +516,18 @@ cdef extern from "flint_wrap.h": # ``e >= 0``. We require ``finv`` to be the inverse of the reverse of # ``f``. - void _fq_zech_poly_pow_trunc_binexp(fq_zech_struct * res, const fq_zech_struct * poly, unsigned long e, long trunc, const fq_zech_ctx_t ctx) + void _fq_zech_poly_pow_trunc_binexp(fq_zech_struct * res, const fq_zech_struct * poly, ulong e, slong trunc, const fq_zech_ctx_t ctx) # Sets ``res`` to the low ``trunc`` coefficients of ``poly`` # (assumed to be zero padded if necessary to length ``trunc``) to the power ``e``. This is equivalent to doing a powering followed # by a truncation. We require that ``res`` has enough space for # ``trunc`` coefficients, that ``trunc > 0`` and that ``e > 1``. Aliasing is not permitted. Uses the binary exponentiation method. - void fq_zech_poly_pow_trunc_binexp(fq_zech_poly_t res, const fq_zech_poly_t poly, unsigned long e, long trunc, const fq_zech_ctx_t ctx) + void fq_zech_poly_pow_trunc_binexp(fq_zech_poly_t res, const fq_zech_poly_t poly, ulong e, slong trunc, const fq_zech_ctx_t ctx) # Sets ``res`` to the low ``trunc`` coefficients of ``poly`` # to the power ``e``. This is equivalent to doing a powering # followed by a truncation. Uses the binary exponentiation method. - void _fq_zech_poly_pow_trunc(fq_zech_struct * res, const fq_zech_struct * poly, unsigned long e, long trunc, const fq_zech_ctx_t mod) + void _fq_zech_poly_pow_trunc(fq_zech_struct * res, const fq_zech_struct * poly, ulong e, slong trunc, const fq_zech_ctx_t mod) # Sets ``res`` to the low ``trunc`` coefficients of ``poly`` # (assumed to be zero padded if necessary to length ``trunc``) to # the power ``e``. This is equivalent to doing a powering followed @@ -535,12 +535,12 @@ cdef extern from "flint_wrap.h": # ``trunc`` coefficients, that ``trunc > 0`` and that # ``e > 1``. Aliasing is not permitted. - void fq_zech_poly_pow_trunc(fq_zech_poly_t res, const fq_zech_poly_t poly, unsigned long e, long trunc, const fq_zech_ctx_t ctx) + void fq_zech_poly_pow_trunc(fq_zech_poly_t res, const fq_zech_poly_t poly, ulong e, slong trunc, const fq_zech_ctx_t ctx) # Sets ``res`` to the low ``trunc`` coefficients of ``poly`` # to the power ``e``. This is equivalent to doing a powering # followed by a truncation. - void _fq_zech_poly_shift_left(fq_zech_struct *rop, const fq_zech_struct *op, long len, long n, const fq_zech_ctx_t ctx) + void _fq_zech_poly_shift_left(fq_zech_struct *rop, const fq_zech_struct *op, slong len, slong n, const fq_zech_ctx_t ctx) # Sets ``(rop, len + n)`` to ``(op, len)`` shifted left by # `n` coefficients. # Inserts zero coefficients at the lower end. Assumes that @@ -548,11 +548,11 @@ cdef extern from "flint_wrap.h": # ``len + n`` elements. Supports aliasing between ``rop`` and # ``op``. - void fq_zech_poly_shift_left(fq_zech_poly_t rop, const fq_zech_poly_t op, long n, const fq_zech_ctx_t ctx) + void fq_zech_poly_shift_left(fq_zech_poly_t rop, const fq_zech_poly_t op, slong n, const fq_zech_ctx_t ctx) # Sets ``rop`` to ``op`` shifted left by `n` coeffs. Zero # coefficients are inserted. - void _fq_zech_poly_shift_right(fq_zech_struct *rop, const fq_zech_struct *op, long len, long n, const fq_zech_ctx_t ctx) + void _fq_zech_poly_shift_right(fq_zech_struct *rop, const fq_zech_struct *op, slong len, slong n, const fq_zech_ctx_t ctx) # Sets ``(rop, len - n)`` to ``(op, len)`` shifted right by # `n` coefficients. # Assumes that ``len`` and `n` are positive, that ``len > n``, @@ -560,18 +560,18 @@ cdef extern from "flint_wrap.h": # aliasing between ``rop`` and ``op``, although in this case # the top coefficients of ``op`` are not set to zero. - void fq_zech_poly_shift_right(fq_zech_poly_t rop, const fq_zech_poly_t op, long n, const fq_zech_ctx_t ctx) + void fq_zech_poly_shift_right(fq_zech_poly_t rop, const fq_zech_poly_t op, slong n, const fq_zech_ctx_t ctx) # Sets ``rop`` to ``op`` shifted right by `n` coefficients. # If `n` is equal to or greater than the current length of # ``op``, ``rop`` is set to the zero polynomial. - long _fq_zech_poly_hamming_weight(const fq_zech_struct *op, long len, const fq_zech_ctx_t ctx) + slong _fq_zech_poly_hamming_weight(const fq_zech_struct *op, slong len, const fq_zech_ctx_t ctx) # Returns the number of non-zero entries in ``(op, len)``. - long fq_zech_poly_hamming_weight(const fq_zech_poly_t op, const fq_zech_ctx_t ctx) + slong fq_zech_poly_hamming_weight(const fq_zech_poly_t op, const fq_zech_ctx_t ctx) # Returns the number of non-zero entries in the polynomial ``op``. - void _fq_zech_poly_divrem(fq_zech_struct *Q, fq_zech_struct *R, const fq_zech_struct *A, long lenA, const fq_zech_struct *B, long lenB, const fq_zech_t invB, const fq_zech_ctx_t ctx) + void _fq_zech_poly_divrem(fq_zech_struct *Q, fq_zech_struct *R, const fq_zech_struct *A, slong lenA, const fq_zech_struct *B, slong lenB, const fq_zech_t invB, const fq_zech_ctx_t ctx) # Computes ``(Q, lenA - lenB + 1)``, ``(R, lenA)`` such that # `A = B Q + R` with `0 \leq \operatorname{len}(R) < \operatorname{len}(B)`. # Assumes that the leading coefficient of `B` is invertible @@ -597,7 +597,7 @@ cdef extern from "flint_wrap.h": # non-trivial factor of the modulus and `Q` and `R` are not touched. # Assumes that `B` is non-zero. - void _fq_zech_poly_rem(fq_zech_struct *R, const fq_zech_struct *A, long lenA, const fq_zech_struct *B, long lenB, const fq_zech_t invB, const fq_zech_ctx_t ctx) + void _fq_zech_poly_rem(fq_zech_struct *R, const fq_zech_struct *A, slong lenA, const fq_zech_struct *B, slong lenB, const fq_zech_t invB, const fq_zech_ctx_t ctx) # Sets ``R`` to the remainder of the division of ``(A,lenA)`` by # ``(B,lenB)``. Assumes that the leading coefficient of ``(B,lenB)`` # is invertible and that ``invB`` is its inverse. @@ -606,7 +606,7 @@ cdef extern from "flint_wrap.h": # Sets ``R`` to the remainder of the division of ``A`` by # ``B`` in the context described by ``ctx``. - void _fq_zech_poly_div(fq_zech_struct *Q, const fq_zech_struct *A, long lenA, const fq_zech_struct *B, long lenB, const fq_zech_t invB, const fq_zech_ctx_t ctx) + void _fq_zech_poly_div(fq_zech_struct *Q, const fq_zech_struct *A, slong lenA, const fq_zech_struct *B, slong lenB, const fq_zech_t invB, const fq_zech_ctx_t ctx) # Notationally, computes `Q`, `R` such that `A = B Q + R` with `0 # \leq \operatorname{len}(R) < \operatorname{len}(B)` but only sets ``(Q, lenA - lenB + 1)``. # Allows zero-padding in `A` but not in `B`. Assumes that the leading coefficient of `B` is a @@ -617,7 +617,7 @@ cdef extern from "flint_wrap.h": # `\operatorname{len}(R) < \operatorname{len}(B)`, but returns only ``Q``. If `\operatorname{len}(B) = 0` an # exception is raised. - void _fq_zech_poly_div_newton_n_preinv(fq_zech_struct* Q, const fq_zech_struct* A, long lenA, const fq_zech_struct* B, long lenB, const fq_zech_struct* Binv, long lenBinv, const fq_zech_ctx_t ctx) + void _fq_zech_poly_div_newton_n_preinv(fq_zech_struct* Q, const fq_zech_struct* A, slong lenA, const fq_zech_struct* B, slong lenB, const fq_zech_struct* Binv, slong lenBinv, const fq_zech_ctx_t ctx) # Notionally computes polynomials `Q` and `R` such that `A = BQ + R` with # `\operatorname{len}(R)` less than ``lenB``, where ``A`` is of length ``lenA`` # and ``B`` is of length ``lenB``, but return only `Q`. @@ -637,7 +637,7 @@ cdef extern from "flint_wrap.h": # The algorithm used is to reverse the polynomials and divide the # resulting power series, then reverse the result. - void _fq_zech_poly_divrem_newton_n_preinv(fq_zech_struct* Q, fq_zech_struct* R, const fq_zech_struct* A, long lenA, const fq_zech_struct* B, long lenB, const fq_zech_struct* Binv, long lenBinv, const fq_zech_ctx_t ctx) + void _fq_zech_poly_divrem_newton_n_preinv(fq_zech_struct* Q, fq_zech_struct* R, const fq_zech_struct* A, slong lenA, const fq_zech_struct* B, slong lenB, const fq_zech_struct* Binv, slong lenBinv, const fq_zech_ctx_t ctx) # Computes `Q` and `R` such that `A = BQ + R` with `\operatorname{len}(R)` less # than ``lenB``, where `A` is of length ``lenA`` and `B` is of # length ``lenB``. We require that `Q` have space for @@ -655,38 +655,38 @@ cdef extern from "flint_wrap.h": # The algorithm used is to call :func:`div_newton` and then # multiply out and compute the remainder. - void _fq_zech_poly_inv_series_newton(fq_zech_struct* Qinv, const fq_zech_struct* Q, long n, const fq_zech_t cinv, const fq_zech_ctx_t ctx) + void _fq_zech_poly_inv_series_newton(fq_zech_struct* Qinv, const fq_zech_struct* Q, slong n, const fq_zech_t cinv, const fq_zech_ctx_t ctx) # Given ``Q`` of length ``n`` whose constant coefficient is # invertible modulo the given modulus, find a polynomial ``Qinv`` # of length ``n`` such that ``Q * Qinv`` is ``1`` modulo # `x^n`. Requires ``n > 0``. This function can be viewed as # inverting a power series via Newton iteration. - void fq_zech_poly_inv_series_newton(fq_zech_poly_t Qinv, const fq_zech_poly_t Q, long n, const fq_zech_ctx_t ctx) + void fq_zech_poly_inv_series_newton(fq_zech_poly_t Qinv, const fq_zech_poly_t Q, slong n, const fq_zech_ctx_t ctx) # Given ``Q`` find ``Qinv`` such that ``Q * Qinv`` is # ``1`` modulo `x^n`. The constant coefficient of ``Q`` must # be invertible modulo the modulus of ``Q``. An exception is # raised if this is not the case or if ``n = 0``. This function # can be viewed as inverting a power series via Newton iteration. - void _fq_zech_poly_inv_series(fq_zech_struct* Qinv, const fq_zech_struct* Q, long n, const fq_zech_t cinv, const fq_zech_ctx_t ctx) + void _fq_zech_poly_inv_series(fq_zech_struct* Qinv, const fq_zech_struct* Q, slong n, const fq_zech_t cinv, const fq_zech_ctx_t ctx) # Given ``Q`` of length ``n`` whose constant coefficient is # invertible modulo the given modulus, find a polynomial ``Qinv`` # of length ``n`` such that ``Q * Qinv`` is ``1`` modulo # `x^n`. Requires ``n > 0``. - void fq_zech_poly_inv_series(fq_zech_poly_t Qinv, const fq_zech_poly_t Q, long n, const fq_zech_ctx_t ctx) + void fq_zech_poly_inv_series(fq_zech_poly_t Qinv, const fq_zech_poly_t Q, slong n, const fq_zech_ctx_t ctx) # Given ``Q`` find ``Qinv`` such that ``Q * Qinv`` is # ``1`` modulo `x^n`. The constant coefficient of ``Q`` must # be invertible modulo the modulus of ``Q``. An exception is # raised if this is not the case or if ``n = 0``. - void _fq_zech_poly_div_series(fq_zech_struct * Q, const fq_zech_struct * A, long Alen, const fq_zech_struct * B, long Blen, long n, const fq_zech_ctx_t ctx) + void _fq_zech_poly_div_series(fq_zech_struct * Q, const fq_zech_struct * A, slong Alen, const fq_zech_struct * B, slong Blen, slong n, const fq_zech_ctx_t ctx) # Set ``(Q, n)`` to the quotient of the series ``(A, Alen``) and # ``(B, Blen)`` assuming ``Alen, Blen <= n``. We assume the bottom # coefficient of ``B`` is invertible. - void fq_zech_poly_div_series(fq_zech_poly_t Q, const fq_zech_poly_t A, const fq_zech_poly_t B, long n, const fq_zech_ctx_t ctx) + void fq_zech_poly_div_series(fq_zech_poly_t Q, const fq_zech_poly_t A, const fq_zech_poly_t B, slong n, const fq_zech_ctx_t ctx) # Set `Q` to the quotient of the series `A` by `B`, thinking of the series as # though they were of length `n`. We assume that the bottom coefficient of # `B` is invertible. @@ -699,14 +699,14 @@ cdef extern from "flint_wrap.h": # `P`. Except in the case where the GCD is zero, the GCD `G` is made # monic. - long _fq_zech_poly_gcd(fq_zech_struct* G, const fq_zech_struct* A, long lenA, const fq_zech_struct* B, long lenB, const fq_zech_ctx_t ctx) + slong _fq_zech_poly_gcd(fq_zech_struct* G, const fq_zech_struct* A, slong lenA, const fq_zech_struct* B, slong lenB, const fq_zech_ctx_t ctx) # Computes the GCD of `A` of length ``lenA`` and `B` of length # ``lenB``, where ``lenA >= lenB > 0`` and sets `G` to it. The # length of the GCD `G` is returned by the function. No attempt is # made to make the GCD monic. It is required that `G` have space for # ``lenB`` coefficients. - long _fq_zech_poly_gcd_euclidean_f(fq_zech_t f, fq_zech_struct *G, const fq_zech_struct *A, long lenA, const fq_zech_struct *B, long lenB, const fq_zech_ctx_t ctx) + slong _fq_zech_poly_gcd_euclidean_f(fq_zech_t f, fq_zech_struct *G, const fq_zech_struct *A, slong lenA, const fq_zech_struct *B, slong lenB, const fq_zech_ctx_t ctx) # Either sets `f = 1` and `G` to the greatest common divisor of # `(A,\operatorname{len}(A))` and `(B, \operatorname{len}(B))` and returns its length, or sets # `f` to a non-trivial factor of the modulus of ``ctx`` and leaves @@ -718,7 +718,7 @@ cdef extern from "flint_wrap.h": # Either sets `f = 1` and `G` to the greatest common divisor of `A` # and `B` or sets `f` to a factor of the modulus of ``ctx``. - long _fq_zech_poly_xgcd(fq_zech_struct *G, fq_zech_struct *S, fq_zech_struct *T, const fq_zech_struct *A, long lenA, const fq_zech_struct *B, long lenB, const fq_zech_ctx_t ctx) + slong _fq_zech_poly_xgcd(fq_zech_struct *G, fq_zech_struct *S, fq_zech_struct *T, const fq_zech_struct *A, slong lenA, const fq_zech_struct *B, slong lenB, const fq_zech_ctx_t ctx) # Computes the GCD of `A` and `B` together with cofactors `S` and `T` # such that `S A + T B = G`. Returns the length of `G`. # Assumes that `\operatorname{len}(A) \geq \operatorname{len}(B) \geq 1` and @@ -739,7 +739,7 @@ cdef extern from "flint_wrap.h": # ``S*A + T*B = G``. The length of ``S`` will be at most # ``lenB`` and the length of ``T`` will be at most ``lenA``. - long _fq_zech_poly_xgcd_euclidean_f(fq_zech_t f, fq_zech_struct *G, fq_zech_struct *S, fq_zech_struct *T, const fq_zech_struct *A, long lenA, const fq_zech_struct *B, long lenB, const fq_zech_ctx_t ctx) + slong _fq_zech_poly_xgcd_euclidean_f(fq_zech_t f, fq_zech_struct *G, fq_zech_struct *S, fq_zech_struct *T, const fq_zech_struct *A, slong lenA, const fq_zech_struct *B, slong lenB, const fq_zech_ctx_t ctx) # Either sets `f = 1` and computes the GCD of `A` and `B` together # with cofactors `S` and `T` such that `S A + T B = G`; otherwise, # sets `f` to a non-trivial factor of the modulus of ``ctx`` and @@ -765,7 +765,7 @@ cdef extern from "flint_wrap.h": # be `P`. Except in the case where the GCD is zero, the GCD `G` is # made monic. - int _fq_zech_poly_divides(fq_zech_struct *Q, const fq_zech_struct *A, long lenA, const fq_zech_struct *B, long lenB, const fq_zech_t invB, const fq_zech_ctx_t ctx) + int _fq_zech_poly_divides(fq_zech_struct *Q, const fq_zech_struct *A, slong lenA, const fq_zech_struct *B, slong lenB, const fq_zech_t invB, const fq_zech_ctx_t ctx) # Returns `1` if ``(B, lenB)`` divides ``(A, lenA)`` exactly and # sets `Q` to the quotient, otherwise returns `0`. # It is assumed that `\operatorname{len}(A) \geq \operatorname{len}(B) > 0` and that `Q` has space @@ -780,7 +780,7 @@ cdef extern from "flint_wrap.h": # This function is currently unoptimised and provided for convenience # only. - void _fq_zech_poly_derivative(fq_zech_struct *rop, const fq_zech_struct *op, long len, const fq_zech_ctx_t ctx) + void _fq_zech_poly_derivative(fq_zech_struct *rop, const fq_zech_struct *op, slong len, const fq_zech_ctx_t ctx) # Sets ``(rop, len - 1)`` to the derivative of ``(op, len)``. # Also handles the cases where ``len`` is `0` or `1` correctly. # Supports aliasing of ``rop`` and ``op``. @@ -788,25 +788,25 @@ cdef extern from "flint_wrap.h": void fq_zech_poly_derivative(fq_zech_poly_t rop, const fq_zech_poly_t op, const fq_zech_ctx_t ctx) # Sets ``rop`` to the derivative of ``op``. - void _fq_zech_poly_invsqrt_series(fq_zech_struct * g, const fq_zech_struct * h, long n, fq_zech_ctx_t mod) + void _fq_zech_poly_invsqrt_series(fq_zech_struct * g, const fq_zech_struct * h, slong n, fq_zech_ctx_t mod) # Set the first `n` terms of `g` to the series expansion of `1/\sqrt{h}`. # It is assumed that `n > 0`, that `h` has constant term 1 and that `h` # is zero-padded as necessary to length `n`. Aliasing is not permitted. - void fq_zech_poly_invsqrt_series(fq_zech_poly_t g, const fq_zech_poly_t h, long n, fq_zech_ctx_t ctx) + void fq_zech_poly_invsqrt_series(fq_zech_poly_t g, const fq_zech_poly_t h, slong n, fq_zech_ctx_t ctx) # Set `g` to the series expansion of `1/\sqrt{h}` to order `O(x^n)`. # It is assumed that `h` has constant term 1. - void _fq_zech_poly_sqrt_series(fq_zech_struct * g, const fq_zech_struct * h, long n, fq_zech_ctx_t ctx) + void _fq_zech_poly_sqrt_series(fq_zech_struct * g, const fq_zech_struct * h, slong n, fq_zech_ctx_t ctx) # Set the first `n` terms of `g` to the series expansion of `\sqrt{h}`. # It is assumed that `n > 0`, that `h` has constant term 1 and that `h` # is zero-padded as necessary to length `n`. Aliasing is not permitted. - void fq_zech_poly_sqrt_series(fq_zech_poly_t g, const fq_zech_poly_t h, long n, fq_zech_ctx_t ctx) + void fq_zech_poly_sqrt_series(fq_zech_poly_t g, const fq_zech_poly_t h, slong n, fq_zech_ctx_t ctx) # Set `g` to the series expansion of `\sqrt{h}` to order `O(x^n)`. # It is assumed that `h` has constant term 1. - int _fq_zech_poly_sqrt(fq_zech_struct * s, const fq_zech_struct * p, long n, fq_zech_ctx_t mod) + int _fq_zech_poly_sqrt(fq_zech_struct * s, const fq_zech_struct * p, slong n, fq_zech_ctx_t mod) # If ``(p, n)`` is a perfect square, sets ``(s, n / 2 + 1)`` # to a square root of `p` and returns 1. Otherwise returns 0. @@ -814,7 +814,7 @@ cdef extern from "flint_wrap.h": # If `p` is a perfect square, sets `s` to a square root of `p` # and returns 1. Otherwise returns 0. - void _fq_zech_poly_evaluate_fq_zech(fq_zech_t rop, const fq_zech_struct *op, long len, const fq_zech_t a, const fq_zech_ctx_t ctx) + void _fq_zech_poly_evaluate_fq_zech(fq_zech_t rop, const fq_zech_struct *op, slong len, const fq_zech_t a, const fq_zech_ctx_t ctx) # Sets ``rop`` to ``(op, len)`` evaluated at `a`. # Supports zero padding. There are no restrictions on ``len``, that # is, ``len`` is allowed to be zero, too. @@ -824,7 +824,7 @@ cdef extern from "flint_wrap.h": # As the coefficient ring `\mathbf{F}_q` is finite, Horner's method # is sufficient. - void _fq_zech_poly_compose(fq_zech_struct *rop, const fq_zech_struct *op1, long len1, const fq_zech_struct *op2, long len2, const fq_zech_ctx_t ctx) + void _fq_zech_poly_compose(fq_zech_struct *rop, const fq_zech_struct *op1, slong len1, const fq_zech_struct *op2, slong len2, const fq_zech_ctx_t ctx) # Sets ``rop`` to the composition of ``(op1, len1)`` and # ``(op2, len2)``. # Assumes that ``rop`` has space for ``(len1-1)*(len2-1) + 1`` @@ -838,7 +838,7 @@ cdef extern from "flint_wrap.h": # ``op1``, and ``op2`` by `f`, `g`, and `h`, respectively, # sets `f(t) = g(h(t))`. - void _fq_zech_poly_compose_mod_horner(fq_zech_struct * res, const fq_zech_struct * f, long lenf, const fq_zech_struct * g, const fq_zech_struct * h, long lenh, const fq_zech_ctx_t ctx) + void _fq_zech_poly_compose_mod_horner(fq_zech_struct * res, const fq_zech_struct * f, slong lenf, const fq_zech_struct * g, const fq_zech_struct * h, slong lenh, const fq_zech_ctx_t ctx) # Sets ``res`` to the composition `f(g)` modulo `h`. We require that # `h` is nonzero and that the length of `g` is one less than the # length of `h` (possibly with zero padding). The output is not allowed @@ -849,7 +849,7 @@ cdef extern from "flint_wrap.h": # Sets ``res`` to the composition `f(g)` modulo `h`. We require that # `h` is nonzero. The algorithm used is Horner's rule. - void _fq_zech_poly_compose_mod_horner_preinv(fq_zech_struct * res, const fq_zech_struct * f, long lenf, const fq_zech_struct * g, const fq_zech_struct * h, long lenh, const fq_zech_struct * hinv, long lenhiv, const fq_zech_ctx_t ctx) + void _fq_zech_poly_compose_mod_horner_preinv(fq_zech_struct * res, const fq_zech_struct * f, slong lenf, const fq_zech_struct * g, const fq_zech_struct * h, slong lenh, const fq_zech_struct * hinv, slong lenhiv, const fq_zech_ctx_t ctx) # Sets ``res`` to the composition `f(g)` modulo `h`. We require # that `h` is nonzero and that the length of `g` is one less than # the length of `h` (possibly with zero padding). We also require @@ -865,7 +865,7 @@ cdef extern from "flint_wrap.h": # `h`. Furthermore, we require ``hinv`` to be the inverse of the # reverse of ``h``. The algorithm used is Horner's rule. - void _fq_zech_poly_compose_mod_brent_kung(fq_zech_struct * res, const fq_zech_struct * f, long lenf, const fq_zech_struct * g, const fq_zech_struct * h, long lenh, const fq_zech_ctx_t ctx) + void _fq_zech_poly_compose_mod_brent_kung(fq_zech_struct * res, const fq_zech_struct * f, slong lenf, const fq_zech_struct * g, const fq_zech_struct * h, slong lenh, const fq_zech_ctx_t ctx) # Sets ``res`` to the composition `f(g)` modulo `h`. We require # that `h` is nonzero and that the length of `g` is one less than # the length of `h` (possibly with zero padding). We also require @@ -878,7 +878,7 @@ cdef extern from "flint_wrap.h": # that `h` is nonzero and that `f` has smaller degree than `h`. The # algorithm used is the Brent-Kung matrix algorithm. - void _fq_zech_poly_compose_mod_brent_kung_preinv(fq_zech_struct * res, const fq_zech_struct * f, long lenf, const fq_zech_struct * g, const fq_zech_struct * h, long lenh, const fq_zech_struct * hinv, long lenhiv, const fq_zech_ctx_t ctx) + void _fq_zech_poly_compose_mod_brent_kung_preinv(fq_zech_struct * res, const fq_zech_struct * f, slong lenf, const fq_zech_struct * g, const fq_zech_struct * h, slong lenh, const fq_zech_struct * hinv, slong lenhiv, const fq_zech_ctx_t ctx) # Sets ``res`` to the composition `f(g)` modulo `h`. We require # that `h` is nonzero and that the length of `g` is one less than # the length of `h` (possibly with zero padding). We also require @@ -895,7 +895,7 @@ cdef extern from "flint_wrap.h": # reverse of ``h``. The algorithm used is the Brent-Kung matrix # algorithm. - void _fq_zech_poly_compose_mod(fq_zech_struct * res, const fq_zech_struct * f, long lenf, const fq_zech_struct * g, const fq_zech_struct * h, long lenh, const fq_zech_ctx_t ctx) + void _fq_zech_poly_compose_mod(fq_zech_struct * res, const fq_zech_struct * f, slong lenf, const fq_zech_struct * g, const fq_zech_struct * h, slong lenh, const fq_zech_ctx_t ctx) # Sets ``res`` to the composition `f(g)` modulo `h`. We require # that `h` is nonzero and that the length of `g` is one less than # the length of `h` (possibly with zero padding). The output is not @@ -905,7 +905,7 @@ cdef extern from "flint_wrap.h": # Sets ``res`` to the composition `f(g)` modulo `h`. We require # that `h` is nonzero. - void _fq_zech_poly_compose_mod_preinv(fq_zech_struct * res, const fq_zech_struct * f, long lenf, const fq_zech_struct * g, const fq_zech_struct * h, long lenh, const fq_zech_struct * hinv, long lenhiv, const fq_zech_ctx_t ctx) + void _fq_zech_poly_compose_mod_preinv(fq_zech_struct * res, const fq_zech_struct * f, slong lenf, const fq_zech_struct * g, const fq_zech_struct * h, slong lenh, const fq_zech_struct * hinv, slong lenhiv, const fq_zech_ctx_t ctx) # Sets ``res`` to the composition `f(g)` modulo `h`. We require # that `h` is nonzero and that the length of `g` is one less than # the length of `h` (possibly with zero padding). We also require @@ -925,7 +925,7 @@ cdef extern from "flint_wrap.h": # `f` for `i=1,\ldots,\sqrt{\deg(f)}`. We require `B` to be at least # a `\sqrt{\deg(f)}\times \deg(f)` matrix and `f` to be nonzero. - void _fq_zech_poly_precompute_matrix (fq_zech_mat_t A, const fq_zech_struct* f, const fq_zech_struct* g, long leng, const fq_zech_struct* ginv, long lenginv, const fq_zech_ctx_t ctx) + void _fq_zech_poly_precompute_matrix (fq_zech_mat_t A, const fq_zech_struct* f, const fq_zech_struct* g, slong leng, const fq_zech_struct* ginv, slong lenginv, const fq_zech_ctx_t ctx) # Sets the ith row of ``A`` to `f^i` modulo `g` for # `i=1,\ldots,\sqrt{\deg(g)}`. We require `A` to be a # `\sqrt{\deg(g)}\times \deg(g)` matrix. We require ``ginv`` to @@ -937,7 +937,7 @@ cdef extern from "flint_wrap.h": # `\sqrt{\deg(g)}\times \deg(g)` matrix. We require ``ginv`` to # be the inverse of the reverse of ``g``. - void _fq_zech_poly_compose_mod_brent_kung_precomp_preinv(fq_zech_struct* res, const fq_zech_struct* f, long lenf, const fq_zech_mat_t A, const fq_zech_struct* h, long lenh, const fq_zech_struct* hinv, long lenhinv, const fq_zech_ctx_t ctx) + void _fq_zech_poly_compose_mod_brent_kung_precomp_preinv(fq_zech_struct* res, const fq_zech_struct* f, slong lenf, const fq_zech_mat_t A, const fq_zech_struct* h, slong lenh, const fq_zech_struct* hinv, slong lenhinv, const fq_zech_ctx_t ctx) # Sets ``res`` to the composition `f(g)` modulo `h`. We require # that `h` is nonzero. We require that the ith row of `A` contains # `g^i` for `i=1,\ldots,\sqrt{\deg(h)}`, i.e. `A` is a @@ -958,7 +958,7 @@ cdef extern from "flint_wrap.h": # several modular composition of the form `f(g)` modulo `h` for # fixed `g` and `h`. - int _fq_zech_poly_fprint_pretty(FILE *file, const fq_zech_struct *poly, long len, const char *x, const fq_zech_ctx_t ctx) + int _fq_zech_poly_fprint_pretty(FILE *file, const fq_zech_struct *poly, slong len, const char *x, const fq_zech_ctx_t ctx) # Prints the pretty representation of ``(poly, len)`` to the stream # ``file``, using the string ``x`` to represent the indeterminate. # In case of success, returns a positive value. In case of failure, @@ -970,7 +970,7 @@ cdef extern from "flint_wrap.h": # In case of success, returns a positive value. In case of failure, # returns a non-positive value. - int _fq_zech_poly_print_pretty(const fq_zech_struct *poly, long len, const char *x, const fq_zech_ctx_t ctx) + int _fq_zech_poly_print_pretty(const fq_zech_struct *poly, slong len, const char *x, const fq_zech_ctx_t ctx) # Prints the pretty representation of ``(poly, len)`` to ``stdout``, # using the string ``x`` to represent the indeterminate. # In case of success, returns a positive value. In case of failure, @@ -982,7 +982,7 @@ cdef extern from "flint_wrap.h": # In case of success, returns a positive value. In case of failure, # returns a non-positive value. - int _fq_zech_poly_fprint(FILE *file, const fq_zech_struct *poly, long len, const fq_zech_ctx_t ctx) + int _fq_zech_poly_fprint(FILE *file, const fq_zech_struct *poly, slong len, const fq_zech_ctx_t ctx) # Prints the pretty representation of ``(poly, len)`` to the stream # ``file``. # In case of success, returns a positive value. In case of failure, @@ -994,7 +994,7 @@ cdef extern from "flint_wrap.h": # In case of success, returns a positive value. In case of failure, # returns a non-positive value. - int _fq_zech_poly_print(const fq_zech_struct *poly, long len, const fq_zech_ctx_t ctx) + int _fq_zech_poly_print(const fq_zech_struct *poly, slong len, const fq_zech_ctx_t ctx) # Prints the pretty representation of ``(poly, len)`` to ``stdout``. # In case of success, returns a positive value. In case of failure, # returns a non-positive value. @@ -1004,7 +1004,7 @@ cdef extern from "flint_wrap.h": # In case of success, returns a positive value. In case of failure, # returns a non-positive value. - char * _fq_zech_poly_get_str(const fq_zech_struct * poly, long len, const fq_zech_ctx_t ctx) + char * _fq_zech_poly_get_str(const fq_zech_struct * poly, slong len, const fq_zech_ctx_t ctx) # Returns the plain FLINT string representation of the polynomial # ``(poly, len)``. @@ -1012,7 +1012,7 @@ cdef extern from "flint_wrap.h": # Returns the plain FLINT string representation of the polynomial # ``poly``. - char * _fq_zech_poly_get_str_pretty(const fq_zech_struct * poly, long len, const char * x, const fq_zech_ctx_t ctx) + char * _fq_zech_poly_get_str_pretty(const fq_zech_struct * poly, slong len, const char * x, const fq_zech_ctx_t ctx) # Returns a pretty representation of the polynomial # ``(poly, len)`` using the null-terminated string ``x`` as the # variable name. @@ -1021,16 +1021,16 @@ cdef extern from "flint_wrap.h": # Returns a pretty representation of the polynomial ``poly`` using the # null-terminated string ``x`` as the variable name - void fq_zech_poly_inflate(fq_zech_poly_t result, const fq_zech_poly_t input, unsigned long inflation, const fq_zech_ctx_t ctx) + void fq_zech_poly_inflate(fq_zech_poly_t result, const fq_zech_poly_t input, ulong inflation, const fq_zech_ctx_t ctx) # Sets ``result`` to the inflated polynomial `p(x^n)` where # `p` is given by ``input`` and `n` is given by ``inflation``. - void fq_zech_poly_deflate(fq_zech_poly_t result, const fq_zech_poly_t input, unsigned long deflation, const fq_zech_ctx_t ctx) + void fq_zech_poly_deflate(fq_zech_poly_t result, const fq_zech_poly_t input, ulong deflation, const fq_zech_ctx_t ctx) # Sets ``result`` to the deflated polynomial `p(x^{1/n})` where # `p` is given by ``input`` and `n` is given by ``deflation``. # Requires `n > 0`. - unsigned long fq_zech_poly_deflation(const fq_zech_poly_t input, const fq_zech_ctx_t ctx) + ulong fq_zech_poly_deflation(const fq_zech_poly_t input, const fq_zech_ctx_t ctx) # Returns the largest integer by which ``input`` can be deflated. # As special cases, returns 0 if ``input`` is the zero polynomial # and 1 of ``input`` is a constant polynomial. diff --git a/src/sage/libs/flint/fq_zech_poly_factor.pxd b/src/sage/libs/flint/fq_zech_poly_factor.pxd index f41d590ecf3..076ac2c548f 100644 --- a/src/sage/libs/flint/fq_zech_poly_factor.pxd +++ b/src/sage/libs/flint/fq_zech_poly_factor.pxd @@ -20,11 +20,11 @@ cdef extern from "flint_wrap.h": void fq_zech_poly_factor_clear(fq_zech_poly_factor_t fac, const fq_zech_ctx_t ctx) # Frees all memory associated with ``fac``. - void fq_zech_poly_factor_realloc(fq_zech_poly_factor_t fac, long alloc, const fq_zech_ctx_t ctx) + void fq_zech_poly_factor_realloc(fq_zech_poly_factor_t fac, slong alloc, const fq_zech_ctx_t ctx) # Reallocates the factor structure to provide space for # precisely ``alloc`` factors. - void fq_zech_poly_factor_fit_length(fq_zech_poly_factor_t fac, long len, const fq_zech_ctx_t ctx) + void fq_zech_poly_factor_fit_length(fq_zech_poly_factor_t fac, slong len, const fq_zech_ctx_t ctx) # Ensures that the factor structure has space for at least # ``len`` factors. This function takes care of the case of # repeated calls by always at least doubling the number of factors @@ -39,7 +39,7 @@ cdef extern from "flint_wrap.h": void fq_zech_poly_factor_print(const fq_zech_poly_factor_t fac, const fq_zech_ctx_t ctx) # Prints the entries of ``fac`` to standard output. - void fq_zech_poly_factor_insert(fq_zech_poly_factor_t fac, const fq_zech_poly_t poly, long exp, const fq_zech_ctx_t ctx) + void fq_zech_poly_factor_insert(fq_zech_poly_factor_t fac, const fq_zech_poly_t poly, slong exp, const fq_zech_ctx_t ctx) # Inserts the factor ``poly`` with multiplicity ``exp`` into # the factorisation ``fac``. # If ``fac`` already contains ``poly``, then ``exp`` simply @@ -51,10 +51,10 @@ cdef extern from "flint_wrap.h": # repeatedly with the individual factors of ``fac``. # Does not support aliasing between ``res`` and ``fac``. - void fq_zech_poly_factor_pow(fq_zech_poly_factor_t fac, long exp, const fq_zech_ctx_t ctx) + void fq_zech_poly_factor_pow(fq_zech_poly_factor_t fac, slong exp, const fq_zech_ctx_t ctx) # Raises ``fac`` to the power ``exp``. - unsigned long fq_zech_poly_remove(fq_zech_poly_t f, const fq_zech_poly_t p, const fq_zech_ctx_t ctx) + ulong fq_zech_poly_remove(fq_zech_poly_t f, const fq_zech_poly_t p, const fq_zech_ctx_t ctx) # Removes the highest possible power of ``p`` from ``f`` and # returns the exponent. @@ -69,7 +69,7 @@ cdef extern from "flint_wrap.h": # Returns 1 if the polynomial ``f`` is irreducible, otherwise returns 0. # Uses Ben-Or's irreducibility test. - int _fq_zech_poly_is_squarefree(const fq_zech_struct * f, long len, const fq_zech_ctx_t ctx) + int _fq_zech_poly_is_squarefree(const fq_zech_struct * f, slong len, const fq_zech_ctx_t ctx) # Returns 1 if ``(f, len)`` is squarefree, and 0 otherwise. As a # special case, the zero polynomial is not considered squarefree. # There are no restrictions on the length. @@ -78,14 +78,14 @@ cdef extern from "flint_wrap.h": # Returns 1 if ``f`` is squarefree, and 0 otherwise. As a special # case, the zero polynomial is not considered squarefree. - int fq_zech_poly_factor_equal_deg_prob(fq_zech_poly_t factor, flint_rand_t state, const fq_zech_poly_t pol, long d, const fq_zech_ctx_t ctx) + int fq_zech_poly_factor_equal_deg_prob(fq_zech_poly_t factor, flint_rand_t state, const fq_zech_poly_t pol, slong d, const fq_zech_ctx_t ctx) # Probabilistic equal degree factorisation of ``pol`` into # irreducible factors of degree ``d``. If it passes, a factor is # placed in factor and 1 is returned, otherwise 0 is returned and # the value of factor is undetermined. # Requires that ``pol`` be monic, non-constant and squarefree. - void fq_zech_poly_factor_equal_deg(fq_zech_poly_factor_t factors, const fq_zech_poly_t pol, long d, const fq_zech_ctx_t ctx) + void fq_zech_poly_factor_equal_deg(fq_zech_poly_factor_t factors, const fq_zech_poly_t pol, slong d, const fq_zech_ctx_t ctx) # Assuming ``pol`` is a product of irreducible factors all of # degree ``d``, finds all those factors and places them in # factors. Requires that ``pol`` be monic, non-constant and @@ -96,7 +96,7 @@ cdef extern from "flint_wrap.h": # linear factor of ``input`` and places it in ``linfactor``. # Requires that ``input`` be monic and non-constant. - void fq_zech_poly_factor_distinct_deg(fq_zech_poly_factor_t res, const fq_zech_poly_t poly, long * const *degs, const fq_zech_ctx_t ctx) + void fq_zech_poly_factor_distinct_deg(fq_zech_poly_factor_t res, const fq_zech_poly_t poly, slong * const *degs, const fq_zech_ctx_t ctx) # Factorises a monic non-constant squarefree polynomial ``poly`` # of degree `n` into factors `f[d]` such that for `1 \leq d \leq n` # `f[d]` is the product of the monic irreducible factors of @@ -157,7 +157,7 @@ cdef extern from "flint_wrap.h": # performs a square-free factorisation, and finally runs # Kaltofen-Shoup on all the individual square-free factors. - void fq_zech_poly_iterated_frobenius_preinv(fq_zech_poly_t *rop, long n, const fq_zech_poly_t v, const fq_zech_poly_t vinv, const fq_zech_ctx_t ctx) + void fq_zech_poly_iterated_frobenius_preinv(fq_zech_poly_t *rop, slong n, const fq_zech_poly_t v, const fq_zech_poly_t vinv, const fq_zech_ctx_t ctx) # Sets ``rop[i]`` to be `x^{q^i} \bmod v` for `0 \le i < n`. # It is required that ``vinv`` is the inverse of the reverse of # ``v`` mod ``x^lenv``. diff --git a/src/sage/libs/flint/fq_zech_vec.pxd b/src/sage/libs/flint/fq_zech_vec.pxd index 9282f112d6d..f1277706f08 100644 --- a/src/sage/libs/flint/fq_zech_vec.pxd +++ b/src/sage/libs/flint/fq_zech_vec.pxd @@ -12,62 +12,62 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - fq_zech_struct * _fq_zech_vec_init(long len, const fq_zech_ctx_t ctx) + fq_zech_struct * _fq_zech_vec_init(slong len, const fq_zech_ctx_t ctx) # Returns an initialised vector of ``fq_zech``'s of given length. - void _fq_zech_vec_clear(fq_zech_struct * vec, long len, const fq_zech_ctx_t ctx) + void _fq_zech_vec_clear(fq_zech_struct * vec, slong len, const fq_zech_ctx_t ctx) # Clears the entries of ``(vec, len)`` and frees the space allocated # for ``vec``. - void _fq_zech_vec_randtest(fq_zech_struct * f, flint_rand_t state, long len, const fq_zech_ctx_t ctx) + void _fq_zech_vec_randtest(fq_zech_struct * f, flint_rand_t state, slong len, const fq_zech_ctx_t ctx) # Sets the entries of a vector of the given length to elements of # the finite field. - int _fq_zech_vec_fprint(FILE * file, const fq_zech_struct * vec, long len, const fq_zech_ctx_t ctx) + int _fq_zech_vec_fprint(FILE * file, const fq_zech_struct * vec, slong len, const fq_zech_ctx_t ctx) # Prints the vector of given length to the stream ``file``. The # format is the length followed by two spaces, then a space separated # list of coefficients. If the length is zero, only `0` is printed. # In case of success, returns a positive value. In case of failure, # returns a non-positive value. - int _fq_zech_vec_print(const fq_zech_struct * vec, long len, const fq_zech_ctx_t ctx) + int _fq_zech_vec_print(const fq_zech_struct * vec, slong len, const fq_zech_ctx_t ctx) # Prints the vector of given length to ``stdout``. # For further details, see ``_fq_zech_vec_fprint()``. - void _fq_zech_vec_set(fq_zech_struct * vec1, const fq_zech_struct * vec2, long len2, const fq_zech_ctx_t ctx) + void _fq_zech_vec_set(fq_zech_struct * vec1, const fq_zech_struct * vec2, slong len2, const fq_zech_ctx_t ctx) # Makes a copy of ``(vec2, len2)`` into ``vec1``. - void _fq_zech_vec_swap(fq_zech_struct * vec1, fq_zech_struct * vec2, long len2, const fq_zech_ctx_t ctx) + void _fq_zech_vec_swap(fq_zech_struct * vec1, fq_zech_struct * vec2, slong len2, const fq_zech_ctx_t ctx) # Swaps the elements in ``(vec1, len2)`` and ``(vec2, len2)``. - void _fq_zech_vec_zero(fq_zech_struct * vec, long len, const fq_zech_ctx_t ctx) + void _fq_zech_vec_zero(fq_zech_struct * vec, slong len, const fq_zech_ctx_t ctx) # Zeros the entries of ``(vec, len)``. - void _fq_zech_vec_neg(fq_zech_struct * vec1, const fq_zech_struct * vec2, long len2, const fq_zech_ctx_t ctx) + void _fq_zech_vec_neg(fq_zech_struct * vec1, const fq_zech_struct * vec2, slong len2, const fq_zech_ctx_t ctx) # Negates ``(vec2, len2)`` and places it into ``vec1``. - int _fq_zech_vec_equal(const fq_zech_struct * vec1, const fq_zech_struct * vec2, long len, const fq_zech_ctx_t ctx) + int _fq_zech_vec_equal(const fq_zech_struct * vec1, const fq_zech_struct * vec2, slong len, const fq_zech_ctx_t ctx) # Compares two vectors of the given length and returns `1` if they are # equal, otherwise returns `0`. - int _fq_zech_vec_is_zero(const fq_zech_struct * vec, long len, const fq_zech_ctx_t ctx) + int _fq_zech_vec_is_zero(const fq_zech_struct * vec, slong len, const fq_zech_ctx_t ctx) # Returns `1` if ``(vec, len)`` is zero, and `0` otherwise. - void _fq_zech_vec_add(fq_zech_struct * res, const fq_zech_struct * vec1, const fq_zech_struct * vec2, long len2, const fq_zech_ctx_t ctx) + void _fq_zech_vec_add(fq_zech_struct * res, const fq_zech_struct * vec1, const fq_zech_struct * vec2, slong len2, const fq_zech_ctx_t ctx) # Sets ``(res, len2)`` to the sum of ``(vec1, len2)`` # and ``(vec2, len2)``. - void _fq_zech_vec_sub(fq_zech_struct * res, const fq_zech_struct * vec1, const fq_zech_struct * vec2, long len2, const fq_zech_ctx_t ctx) + void _fq_zech_vec_sub(fq_zech_struct * res, const fq_zech_struct * vec1, const fq_zech_struct * vec2, slong len2, const fq_zech_ctx_t ctx) # Sets ``(res, len2)`` to ``(vec1, len2)`` minus ``(vec2, len2)``. - void _fq_zech_vec_scalar_addmul_fq_zech(fq_zech_struct * vec1, const fq_zech_struct * vec2, long len2, const fq_zech_t c, const fq_zech_ctx_t ctx) + void _fq_zech_vec_scalar_addmul_fq_zech(fq_zech_struct * vec1, const fq_zech_struct * vec2, slong len2, const fq_zech_t c, const fq_zech_ctx_t ctx) # Adds ``(vec2, len2)`` times `c` to ``(vec1, len2)``, where # `c` is a ``fq_zech_t``. - void _fq_zech_vec_scalar_submul_fq_zech(fq_zech_struct * vec1, const fq_zech_struct * vec2, long len2, const fq_zech_t c, const fq_zech_ctx_t ctx) + void _fq_zech_vec_scalar_submul_fq_zech(fq_zech_struct * vec1, const fq_zech_struct * vec2, slong len2, const fq_zech_t c, const fq_zech_ctx_t ctx) # Subtracts ``(vec2, len2)`` times `c` from ``(vec1, len2)``, # where `c` is a ``fq_zech_t``. - void _fq_zech_vec_dot(fq_zech_t res, const fq_zech_struct * vec1, const fq_zech_struct * vec2, long len2, const fq_zech_ctx_t ctx) + void _fq_zech_vec_dot(fq_zech_t res, const fq_zech_struct * vec1, const fq_zech_struct * vec2, slong len2, const fq_zech_ctx_t ctx) # Sets ``res`` to the dot product of (``vec1``, ``len``) # and (``vec2``, ``len``). diff --git a/src/sage/libs/flint/gr.pxd b/src/sage/libs/flint/gr.pxd index 0e7be38c48f..7f72ee3a2ba 100644 --- a/src/sage/libs/flint/gr.pxd +++ b/src/sage/libs/flint/gr.pxd @@ -12,7 +12,7 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - long gr_ctx_sizeof_elem(gr_ctx_t ctx) + slong gr_ctx_sizeof_elem(gr_ctx_t ctx) # Return ``sizeof(type)`` where ``type`` is the underlying C # type for elements of *ctx*. @@ -64,11 +64,11 @@ cdef extern from "flint_wrap.h": # Free the single heap-allocated element *x* of *ctx* which should # have been created with :func:`gr_heap_init`. - gr_ptr gr_heap_init_vec(long len, gr_ctx_t ctx) + gr_ptr gr_heap_init_vec(slong len, gr_ctx_t ctx) # Return a pointer to a new heap-allocated vector of *len* # initialized elements. - void gr_heap_clear_vec(gr_ptr x, long len, gr_ctx_t ctx) + void gr_heap_clear_vec(gr_ptr x, slong len, gr_ctx_t ctx) # Clear the *len* elements in the heap-allocated vector *len* and # free the vector itself. @@ -100,8 +100,8 @@ cdef extern from "flint_wrap.h": int gr_set_str(gr_ptr res, const char * x, gr_ctx_t ctx) # Sets *res* to the string description in *x*. - int gr_write_n(gr_stream_t out, gr_srcptr x, long n, gr_ctx_t ctx) - int gr_get_str_n(char ** s, gr_srcptr x, long n, gr_ctx_t ctx) + int gr_write_n(gr_stream_t out, gr_srcptr x, slong n, gr_ctx_t ctx) + int gr_get_str_n(char ** s, gr_srcptr x, slong n, gr_ctx_t ctx) # String conversion where real and complex numbers may be rounded # to *n* digits. @@ -115,16 +115,16 @@ cdef extern from "flint_wrap.h": # unambiguously to *ctx*. The ``GR_UNABLE`` flag is returned # if the conversion is not implemented. - int gr_set_ui(gr_ptr res, unsigned long x, gr_ctx_t ctx) - int gr_set_si(gr_ptr res, long x, gr_ctx_t ctx) + int gr_set_ui(gr_ptr res, ulong x, gr_ctx_t ctx) + int gr_set_si(gr_ptr res, slong x, gr_ctx_t ctx) int gr_set_fmpz(gr_ptr res, const fmpz_t x, gr_ctx_t ctx) int gr_set_fmpq(gr_ptr res, const fmpq_t x, gr_ctx_t ctx) int gr_set_d(gr_ptr res, double x, gr_ctx_t ctx) # Sets *res* to the value *x*. If no reasonable conversion to the # domain *ctx* is possible, returns ``GR_DOMAIN``. - int gr_get_si(long * res, gr_srcptr x, gr_ctx_t ctx) - int gr_get_ui(unsigned long * res, gr_srcptr x, gr_ctx_t ctx) + int gr_get_si(slong * res, gr_srcptr x, gr_ctx_t ctx) + int gr_get_ui(ulong * res, gr_srcptr x, gr_ctx_t ctx) int gr_get_fmpz(fmpz_t res, gr_srcptr x, gr_ctx_t ctx) int gr_get_fmpq(fmpq_t res, gr_srcptr x, gr_ctx_t ctx) int gr_get_d(double * res, gr_srcptr x, gr_ctx_t ctx) @@ -183,8 +183,8 @@ cdef extern from "flint_wrap.h": # Sets *res* to `-x`. int gr_add(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) - int gr_add_ui(gr_ptr res, gr_srcptr x, unsigned long y, gr_ctx_t ctx) - int gr_add_si(gr_ptr res, gr_srcptr x, long y, gr_ctx_t ctx) + int gr_add_ui(gr_ptr res, gr_srcptr x, ulong y, gr_ctx_t ctx) + int gr_add_si(gr_ptr res, gr_srcptr x, slong y, gr_ctx_t ctx) int gr_add_fmpz(gr_ptr res, gr_srcptr x, const fmpz_t y, gr_ctx_t ctx) int gr_add_fmpq(gr_ptr res, gr_srcptr x, const fmpq_t y, gr_ctx_t ctx) int gr_add_other(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t y_ctx, gr_ctx_t ctx) @@ -192,8 +192,8 @@ cdef extern from "flint_wrap.h": # Sets *res* to `x + y`. int gr_sub(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) - int gr_sub_ui(gr_ptr res, gr_srcptr x, unsigned long y, gr_ctx_t ctx) - int gr_sub_si(gr_ptr res, gr_srcptr x, long y, gr_ctx_t ctx) + int gr_sub_ui(gr_ptr res, gr_srcptr x, ulong y, gr_ctx_t ctx) + int gr_sub_si(gr_ptr res, gr_srcptr x, slong y, gr_ctx_t ctx) int gr_sub_fmpz(gr_ptr res, gr_srcptr x, const fmpz_t y, gr_ctx_t ctx) int gr_sub_fmpq(gr_ptr res, gr_srcptr x, const fmpq_t y, gr_ctx_t ctx) int gr_sub_other(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t y_ctx, gr_ctx_t ctx) @@ -201,8 +201,8 @@ cdef extern from "flint_wrap.h": # Sets *res* to `x - y`. int gr_mul(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) - int gr_mul_ui(gr_ptr res, gr_srcptr x, unsigned long y, gr_ctx_t ctx) - int gr_mul_si(gr_ptr res, gr_srcptr x, long y, gr_ctx_t ctx) + int gr_mul_ui(gr_ptr res, gr_srcptr x, ulong y, gr_ctx_t ctx) + int gr_mul_si(gr_ptr res, gr_srcptr x, slong y, gr_ctx_t ctx) int gr_mul_fmpz(gr_ptr res, gr_srcptr x, const fmpz_t y, gr_ctx_t ctx) int gr_mul_fmpq(gr_ptr res, gr_srcptr x, const fmpq_t y, gr_ctx_t ctx) int gr_mul_other(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t y_ctx, gr_ctx_t ctx) @@ -210,8 +210,8 @@ cdef extern from "flint_wrap.h": # Sets *res* to `x \cdot y`. int gr_addmul(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) - int gr_addmul_ui(gr_ptr res, gr_srcptr x, unsigned long y, gr_ctx_t ctx) - int gr_addmul_si(gr_ptr res, gr_srcptr x, long y, gr_ctx_t ctx) + int gr_addmul_ui(gr_ptr res, gr_srcptr x, ulong y, gr_ctx_t ctx) + int gr_addmul_si(gr_ptr res, gr_srcptr x, slong y, gr_ctx_t ctx) int gr_addmul_fmpz(gr_ptr res, gr_srcptr x, const fmpz_t y, gr_ctx_t ctx) int gr_addmul_fmpq(gr_ptr res, gr_srcptr x, const fmpq_t y, gr_ctx_t ctx) int gr_addmul_other(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t y_ctx, gr_ctx_t ctx) @@ -221,8 +221,8 @@ cdef extern from "flint_wrap.h": # allocating a temporary variable, without intermediate rounding, etc. int gr_submul(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) - int gr_submul_ui(gr_ptr res, gr_srcptr x, unsigned long y, gr_ctx_t ctx) - int gr_submul_si(gr_ptr res, gr_srcptr x, long y, gr_ctx_t ctx) + int gr_submul_ui(gr_ptr res, gr_srcptr x, ulong y, gr_ctx_t ctx) + int gr_submul_si(gr_ptr res, gr_srcptr x, slong y, gr_ctx_t ctx) int gr_submul_fmpz(gr_ptr res, gr_srcptr x, const fmpz_t y, gr_ctx_t ctx) int gr_submul_fmpq(gr_ptr res, gr_srcptr x, const fmpq_t y, gr_ctx_t ctx) int gr_submul_other(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t y_ctx, gr_ctx_t ctx) @@ -239,15 +239,15 @@ cdef extern from "flint_wrap.h": # Sets *res* to `x ^ 2`. The default implementation multiplies *x* # with itself. - int gr_mul_2exp_si(gr_ptr res, gr_srcptr x, long y, gr_ctx_t ctx) + int gr_mul_2exp_si(gr_ptr res, gr_srcptr x, slong y, gr_ctx_t ctx) int gr_mul_2exp_fmpz(gr_ptr res, gr_srcptr x, const fmpz_t y, gr_ctx_t ctx) # Sets *res* to `x \cdot 2^y`. This may perform `x \cdot 2^{-y}` # when *y* is negative, allowing exact division by powers of two # even if `2^{y}` is not representable. int gr_div(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) - int gr_div_ui(gr_ptr res, gr_srcptr x, unsigned long y, gr_ctx_t ctx) - int gr_div_si(gr_ptr res, gr_srcptr x, long y, gr_ctx_t ctx) + int gr_div_ui(gr_ptr res, gr_srcptr x, ulong y, gr_ctx_t ctx) + int gr_div_si(gr_ptr res, gr_srcptr x, slong y, gr_ctx_t ctx) int gr_div_fmpz(gr_ptr res, gr_srcptr x, const fmpz_t y, gr_ctx_t ctx) int gr_div_fmpq(gr_ptr res, gr_srcptr x, const fmpq_t y, gr_ctx_t ctx) int gr_div_other(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t y_ctx, gr_ctx_t ctx) @@ -279,8 +279,8 @@ cdef extern from "flint_wrap.h": # Returns whether *x* divides *y*. int gr_divexact(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) - int gr_divexact_ui(gr_ptr res, gr_srcptr x, unsigned long y, gr_ctx_t ctx) - int gr_divexact_si(gr_ptr res, gr_srcptr x, long y, gr_ctx_t ctx) + int gr_divexact_ui(gr_ptr res, gr_srcptr x, ulong y, gr_ctx_t ctx) + int gr_divexact_si(gr_ptr res, gr_srcptr x, slong y, gr_ctx_t ctx) int gr_divexact_fmpz(gr_ptr res, gr_srcptr x, const fmpz_t y, gr_ctx_t ctx) int gr_divexact_other(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t y_ctx, gr_ctx_t ctx) int gr_other_divexact(gr_ptr res, gr_srcptr x, gr_ctx_t x_ctx, gr_srcptr y, gr_ctx_t ctx) @@ -302,8 +302,8 @@ cdef extern from "flint_wrap.h": # Euclidean division with remainder. int gr_pow(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) - int gr_pow_ui(gr_ptr res, gr_srcptr x, unsigned long y, gr_ctx_t ctx) - int gr_pow_si(gr_ptr res, gr_srcptr x, long y, gr_ctx_t ctx) + int gr_pow_ui(gr_ptr res, gr_srcptr x, ulong y, gr_ctx_t ctx) + int gr_pow_si(gr_ptr res, gr_srcptr x, slong y, gr_ctx_t ctx) int gr_pow_fmpz(gr_ptr res, gr_srcptr x, const fmpz_t y, gr_ctx_t ctx) int gr_pow_fmpq(gr_ptr res, gr_srcptr x, const fmpq_t y, gr_ctx_t ctx) int gr_pow_other(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t y_ctx, gr_ctx_t ctx) @@ -412,11 +412,11 @@ cdef extern from "flint_wrap.h": int gr_ctx_fq_prime(fmpz_t p, gr_ctx_t ctx) - int gr_ctx_fq_degree(long * deg, gr_ctx_t ctx) + int gr_ctx_fq_degree(slong * deg, gr_ctx_t ctx) int gr_ctx_fq_order(fmpz_t q, gr_ctx_t ctx) - int gr_fq_frobenius(gr_ptr res, gr_srcptr x, long e, gr_ctx_t ctx) + int gr_fq_frobenius(gr_ptr res, gr_srcptr x, slong e, gr_ctx_t ctx) int gr_fq_multiplicative_order(fmpz_t res, gr_srcptr x, gr_ctx_t ctx) diff --git a/src/sage/libs/flint/gr_generic.pxd b/src/sage/libs/flint/gr_generic.pxd index 5a6b9b357c2..ebc302726d1 100644 --- a/src/sage/libs/flint/gr_generic.pxd +++ b/src/sage/libs/flint/gr_generic.pxd @@ -33,7 +33,7 @@ cdef extern from "flint_wrap.h": void gr_generic_set_shallow(gr_ptr res, gr_srcptr x, const gr_ctx_t ctx) - int gr_generic_write_n(gr_stream_t out, gr_srcptr x, long n, gr_ctx_t ctx) + int gr_generic_write_n(gr_stream_t out, gr_srcptr x, slong n, gr_ctx_t ctx) int gr_generic_randtest_not_zero(gr_ptr x, flint_rand_t state, gr_ctx_t ctx) @@ -49,36 +49,36 @@ cdef extern from "flint_wrap.h": int gr_generic_set_fmpq(gr_ptr res, const fmpq_t y, gr_ctx_t ctx) int gr_generic_add_fmpz(gr_ptr res, gr_srcptr x, const fmpz_t y, gr_ctx_t ctx) - int gr_generic_add_ui(gr_ptr res, gr_srcptr x, unsigned long y, gr_ctx_t ctx) - int gr_generic_add_si(gr_ptr res, gr_srcptr x, long y, gr_ctx_t ctx) + int gr_generic_add_ui(gr_ptr res, gr_srcptr x, ulong y, gr_ctx_t ctx) + int gr_generic_add_si(gr_ptr res, gr_srcptr x, slong y, gr_ctx_t ctx) int gr_generic_add_fmpq(gr_ptr res, gr_srcptr x, const fmpq_t y, gr_ctx_t ctx) int gr_generic_add_other(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t y_ctx, gr_ctx_t ctx) int gr_generic_other_add(gr_ptr res, gr_srcptr x, gr_ctx_t x_ctx, gr_srcptr y, gr_ctx_t ctx) - int gr_generic_sub_ui(gr_ptr res, gr_srcptr x, unsigned long y, gr_ctx_t ctx) - int gr_generic_sub_si(gr_ptr res, gr_srcptr x, long y, gr_ctx_t ctx) + int gr_generic_sub_ui(gr_ptr res, gr_srcptr x, ulong y, gr_ctx_t ctx) + int gr_generic_sub_si(gr_ptr res, gr_srcptr x, slong y, gr_ctx_t ctx) int gr_generic_sub_fmpz(gr_ptr res, gr_srcptr x, const fmpz_t y, gr_ctx_t ctx) int gr_generic_sub_fmpq(gr_ptr res, gr_srcptr x, const fmpq_t y, gr_ctx_t ctx) int gr_generic_sub_other(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t y_ctx, gr_ctx_t ctx) int gr_generic_other_sub(gr_ptr res, gr_srcptr x, gr_ctx_t x_ctx, gr_srcptr y, gr_ctx_t ctx) int gr_generic_mul_fmpz(gr_ptr res, gr_srcptr x, const fmpz_t y, gr_ctx_t ctx) - int gr_generic_mul_ui(gr_ptr res, gr_srcptr x, unsigned long y, gr_ctx_t ctx) - int gr_generic_mul_si(gr_ptr res, gr_srcptr x, long y, gr_ctx_t ctx) + int gr_generic_mul_ui(gr_ptr res, gr_srcptr x, ulong y, gr_ctx_t ctx) + int gr_generic_mul_si(gr_ptr res, gr_srcptr x, slong y, gr_ctx_t ctx) int gr_generic_mul_fmpq(gr_ptr res, gr_srcptr x, const fmpq_t y, gr_ctx_t ctx) int gr_generic_mul_other(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t y_ctx, gr_ctx_t ctx) int gr_generic_other_mul(gr_ptr res, gr_srcptr x, gr_ctx_t x_ctx, gr_srcptr y, gr_ctx_t ctx) int gr_generic_addmul(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) - int gr_generic_addmul_ui(gr_ptr res, gr_srcptr x, unsigned long y, gr_ctx_t ctx) - int gr_generic_addmul_si(gr_ptr res, gr_srcptr x, long y, gr_ctx_t ctx) + int gr_generic_addmul_ui(gr_ptr res, gr_srcptr x, ulong y, gr_ctx_t ctx) + int gr_generic_addmul_si(gr_ptr res, gr_srcptr x, slong y, gr_ctx_t ctx) int gr_generic_addmul_fmpz(gr_ptr res, gr_srcptr x, const fmpz_t y, gr_ctx_t ctx) int gr_generic_addmul_fmpq(gr_ptr res, gr_srcptr x, const fmpq_t y, gr_ctx_t ctx) int gr_generic_addmul_other(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t y_ctx, gr_ctx_t ctx) int gr_generic_submul(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) - int gr_generic_submul_ui(gr_ptr res, gr_srcptr x, unsigned long y, gr_ctx_t ctx) - int gr_generic_submul_si(gr_ptr res, gr_srcptr x, long y, gr_ctx_t ctx) + int gr_generic_submul_ui(gr_ptr res, gr_srcptr x, ulong y, gr_ctx_t ctx) + int gr_generic_submul_si(gr_ptr res, gr_srcptr x, slong y, gr_ctx_t ctx) int gr_generic_submul_fmpz(gr_ptr res, gr_srcptr x, const fmpz_t y, gr_ctx_t ctx) int gr_generic_submul_fmpq(gr_ptr res, gr_srcptr x, const fmpq_t y, gr_ctx_t ctx) int gr_generic_submul_other(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t y_ctx, gr_ctx_t ctx) @@ -87,7 +87,7 @@ cdef extern from "flint_wrap.h": int gr_generic_sqr(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) - int gr_generic_mul_2exp_si(gr_ptr res, gr_srcptr x, long y, gr_ctx_t ctx) + int gr_generic_mul_2exp_si(gr_ptr res, gr_srcptr x, slong y, gr_ctx_t ctx) int gr_generic_mul_2exp_fmpz(gr_ptr res, gr_srcptr x, const fmpz_t y, gr_ctx_t ctx) int gr_generic_set_fmpz_2exp_fmpz(gr_ptr res, const fmpz_t x, const fmpz_t y, gr_ctx_t ctx) @@ -99,8 +99,8 @@ cdef extern from "flint_wrap.h": truth_t gr_generic_is_invertible(gr_srcptr x, gr_ctx_t ctx) int gr_generic_div_fmpz(gr_ptr res, gr_srcptr x, const fmpz_t y, gr_ctx_t ctx) - int gr_generic_div_ui(gr_ptr res, gr_srcptr x, unsigned long y, gr_ctx_t ctx) - int gr_generic_div_si(gr_ptr res, gr_srcptr x, long y, gr_ctx_t ctx) + int gr_generic_div_ui(gr_ptr res, gr_srcptr x, ulong y, gr_ctx_t ctx) + int gr_generic_div_si(gr_ptr res, gr_srcptr x, slong y, gr_ctx_t ctx) int gr_generic_div_fmpq(gr_ptr res, gr_srcptr x, const fmpq_t y, gr_ctx_t ctx) int gr_generic_div_other(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t y_ctx, gr_ctx_t ctx) int gr_generic_other_div(gr_ptr res, gr_srcptr x, gr_ctx_t x_ctx, gr_srcptr y, gr_ctx_t ctx) @@ -108,22 +108,22 @@ cdef extern from "flint_wrap.h": int gr_generic_divexact(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) int gr_generic_pow_fmpz_sliding(gr_ptr f, gr_srcptr g, const fmpz_t pow, gr_ctx_t ctx) - int gr_generic_pow_ui_sliding(gr_ptr f, gr_srcptr g, unsigned long pow, gr_ctx_t ctx) + int gr_generic_pow_ui_sliding(gr_ptr f, gr_srcptr g, ulong pow, gr_ctx_t ctx) int gr_generic_pow_fmpz_binexp(gr_ptr res, gr_srcptr x, const fmpz_t exp, gr_ctx_t ctx) - int gr_generic_pow_ui_binexp(gr_ptr res, gr_srcptr x, unsigned long e, gr_ctx_t ctx) + int gr_generic_pow_ui_binexp(gr_ptr res, gr_srcptr x, ulong e, gr_ctx_t ctx) int gr_generic_pow_fmpz(gr_ptr res, gr_srcptr x, const fmpz_t e, gr_ctx_t ctx) - int gr_generic_pow_si(gr_ptr res, gr_srcptr x, long e, gr_ctx_t ctx) - int gr_generic_pow_ui(gr_ptr res, gr_srcptr x, unsigned long e, gr_ctx_t ctx) + int gr_generic_pow_si(gr_ptr res, gr_srcptr x, slong e, gr_ctx_t ctx) + int gr_generic_pow_ui(gr_ptr res, gr_srcptr x, ulong e, gr_ctx_t ctx) int gr_generic_pow_fmpq(gr_ptr res, gr_srcptr x, const fmpq_t y, gr_ctx_t ctx) int gr_generic_pow_other(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t y_ctx, gr_ctx_t ctx) int gr_generic_other_pow(gr_ptr res, gr_srcptr x, gr_ctx_t x_ctx, gr_srcptr y, gr_ctx_t ctx) - int _gr_fmpz_poly_evaluate_horner(gr_ptr res, const fmpz * f, long len, gr_srcptr x, gr_ctx_t ctx) + int _gr_fmpz_poly_evaluate_horner(gr_ptr res, const fmpz * f, slong len, gr_srcptr x, gr_ctx_t ctx) int gr_fmpz_poly_evaluate_horner(gr_ptr res, const fmpz_poly_t f, gr_srcptr x, gr_ctx_t ctx) - int _gr_fmpz_poly_evaluate_rectangular(gr_ptr res, const fmpz * f, long len, gr_srcptr x, gr_ctx_t ctx) + int _gr_fmpz_poly_evaluate_rectangular(gr_ptr res, const fmpz * f, slong len, gr_srcptr x, gr_ctx_t ctx) int gr_fmpz_poly_evaluate_rectangular(gr_ptr res, const fmpz_poly_t f, gr_srcptr x, gr_ctx_t ctx) - int _gr_fmpz_poly_evaluate(gr_ptr res, const fmpz * f, long len, gr_srcptr x, gr_ctx_t ctx) + int _gr_fmpz_poly_evaluate(gr_ptr res, const fmpz * f, slong len, gr_srcptr x, gr_ctx_t ctx) int gr_fmpz_poly_evaluate(gr_ptr res, const fmpz_poly_t f, gr_srcptr x, gr_ctx_t ctx) # Sets *res* to the value of the integer polynomial *f* evaluated # at the argument *x*. @@ -146,126 +146,126 @@ cdef extern from "flint_wrap.h": int gr_generic_cmp_other(int * res, gr_srcptr x, gr_srcptr y, gr_ctx_t y_ctx, gr_ctx_t ctx) int gr_generic_cmpabs_other(int * res, gr_srcptr x, gr_srcptr y, gr_ctx_t y_ctx, gr_ctx_t ctx) - int gr_generic_bernoulli_ui(gr_ptr res, unsigned long n, gr_ctx_t ctx) + int gr_generic_bernoulli_ui(gr_ptr res, ulong n, gr_ctx_t ctx) int gr_generic_bernoulli_fmpz(gr_ptr res, const fmpz_t n, gr_ctx_t ctx) - int gr_generic_bernoulli_vec(gr_ptr res, long len, gr_ctx_t ctx) - int gr_generic_eulernum_ui(gr_ptr res, unsigned long n, gr_ctx_t ctx) + int gr_generic_bernoulli_vec(gr_ptr res, slong len, gr_ctx_t ctx) + int gr_generic_eulernum_ui(gr_ptr res, ulong n, gr_ctx_t ctx) int gr_generic_eulernum_fmpz(gr_ptr res, const fmpz_t n, gr_ctx_t ctx) - int gr_generic_eulernum_vec(gr_ptr res, long len, gr_ctx_t ctx) - int gr_generic_stirling_s1u_uiui(gr_ptr res, unsigned long x, unsigned long y, gr_ctx_t ctx) - int gr_generic_stirling_s1_uiui(gr_ptr res, unsigned long x, unsigned long y, gr_ctx_t ctx) - int gr_generic_stirling_s2_uiui(gr_ptr res, unsigned long x, unsigned long y, gr_ctx_t ctx) - int gr_generic_stirling_s1u_ui_vec(gr_ptr res, unsigned long x, long len, gr_ctx_t ctx) - int gr_generic_stirling_s1_ui_vec(gr_ptr res, unsigned long x, long len, gr_ctx_t ctx) - int gr_generic_stirling_s2_ui_vec(gr_ptr res, unsigned long x, long len, gr_ctx_t ctx) - - void gr_generic_vec_init(gr_ptr vec, long len, gr_ctx_t ctx) - - void gr_generic_vec_clear(gr_ptr vec, long len, gr_ctx_t ctx) - - void gr_generic_vec_swap(gr_ptr vec1, gr_ptr vec2, long len, gr_ctx_t ctx) - - int gr_generic_vec_zero(gr_ptr vec, long len, gr_ctx_t ctx) - - int gr_generic_vec_set(gr_ptr res, gr_srcptr src, long len, gr_ctx_t ctx) - - int gr_generic_vec_neg(gr_ptr res, gr_srcptr src, long len, gr_ctx_t ctx) - - int gr_generic_vec_normalise(long * res, gr_srcptr vec, long len, gr_ctx_t ctx) - - long gr_generic_vec_normalise_weak(gr_srcptr vec, long len, gr_ctx_t ctx) - - int gr_generic_vec_mul_scalar_2exp_si(gr_ptr vec1, gr_srcptr vec2, long len, long c, gr_ctx_t ctx) - - int gr_generic_vec_scalar_addmul(gr_ptr vec1, gr_srcptr vec2, long len, gr_srcptr c, gr_ctx_t ctx) - - int gr_generic_vec_scalar_submul(gr_ptr vec1, gr_srcptr vec2, long len, gr_srcptr c, gr_ctx_t ctx) - - int gr_generic_vec_scalar_addmul_si(gr_ptr vec1, gr_srcptr vec2, long len, long c, gr_ctx_t ctx) - - int gr_generic_vec_scalar_submul_si(gr_ptr vec1, gr_srcptr vec2, long len, long c, gr_ctx_t ctx) - - truth_t gr_generic_vec_equal(gr_srcptr vec1, gr_srcptr vec2, long len, gr_ctx_t ctx) - - int gr_generic_vec_is_zero(gr_srcptr vec, long len, gr_ctx_t ctx) - - int gr_generic_vec_dot(gr_ptr res, gr_srcptr initial, int subtract, gr_srcptr vec1, gr_srcptr vec2, long len, gr_ctx_t ctx) - - int gr_generic_vec_dot_rev(gr_ptr res, gr_srcptr initial, int subtract, gr_srcptr vec1, gr_srcptr vec2, long len, gr_ctx_t ctx) - - int gr_generic_vec_dot_ui(gr_ptr res, gr_srcptr initial, int subtract, gr_srcptr vec1, const unsigned long * vec2, long len, gr_ctx_t ctx) - - int gr_generic_vec_dot_si(gr_ptr res, gr_srcptr initial, int subtract, gr_srcptr vec1, const long * vec2, long len, gr_ctx_t ctx) - - int gr_generic_vec_dot_fmpz(gr_ptr res, gr_srcptr initial, int subtract, gr_srcptr vec1, const fmpz * vec2, long len, gr_ctx_t ctx) - - int gr_generic_vec_set_powers(gr_ptr res, gr_srcptr x, long len, gr_ctx_t ctx) - - int gr_generic_vec_reciprocals(gr_ptr res, long len, gr_ctx_t ctx) - - int gr_generic_vec_add(gr_ptr res, gr_srcptr src1, gr_srcptr src2, long len, gr_ctx_t ctx) - int gr_generic_vec_sub(gr_ptr res, gr_srcptr src1, gr_srcptr src2, long len, gr_ctx_t ctx) - int gr_generic_vec_mul(gr_ptr res, gr_srcptr src1, gr_srcptr src2, long len, gr_ctx_t ctx) - int gr_generic_vec_div(gr_ptr res, gr_srcptr src1, gr_srcptr src2, long len, gr_ctx_t ctx) - int gr_generic_vec_divexact(gr_ptr res, gr_srcptr src1, gr_srcptr src2, long len, gr_ctx_t ctx) - int gr_generic_vec_pow(gr_ptr res, gr_srcptr src1, gr_srcptr src2, long len, gr_ctx_t ctx) - int gr_generic_vec_add_scalar(gr_ptr vec1, gr_srcptr vec2, long len, gr_srcptr c, gr_ctx_t ctx) - int gr_generic_vec_sub_scalar(gr_ptr vec1, gr_srcptr vec2, long len, gr_srcptr c, gr_ctx_t ctx) - int gr_generic_vec_mul_scalar(gr_ptr vec1, gr_srcptr vec2, long len, gr_srcptr c, gr_ctx_t ctx) - int gr_generic_vec_div_scalar(gr_ptr vec1, gr_srcptr vec2, long len, gr_srcptr c, gr_ctx_t ctx) - int gr_generic_vec_divexact_scalar(gr_ptr vec1, gr_srcptr vec2, long len, gr_srcptr c, gr_ctx_t ctx) - int gr_generic_vec_pow_scalar(gr_ptr vec1, gr_srcptr vec2, long len, gr_srcptr c, gr_ctx_t ctx) - int gr_generic_vec_add_scalar_si(gr_ptr vec1, gr_srcptr vec2, long len, long c, gr_ctx_t ctx) - int gr_generic_vec_sub_scalar_si(gr_ptr vec1, gr_srcptr vec2, long len, long c, gr_ctx_t ctx) - int gr_generic_vec_mul_scalar_si(gr_ptr vec1, gr_srcptr vec2, long len, long c, gr_ctx_t ctx) - int gr_generic_vec_div_scalar_si(gr_ptr vec1, gr_srcptr vec2, long len, long c, gr_ctx_t ctx) - int gr_generic_vec_divexact_scalar_si(gr_ptr vec1, gr_srcptr vec2, long len, long c, gr_ctx_t ctx) - int gr_generic_vec_pow_scalar_si(gr_ptr vec1, gr_srcptr vec2, long len, long c, gr_ctx_t ctx) - int gr_generic_vec_add_scalar_ui(gr_ptr vec1, gr_srcptr vec2, long len, unsigned long c, gr_ctx_t ctx) - int gr_generic_vec_sub_scalar_ui(gr_ptr vec1, gr_srcptr vec2, long len, unsigned long c, gr_ctx_t ctx) - int gr_generic_vec_mul_scalar_ui(gr_ptr vec1, gr_srcptr vec2, long len, unsigned long c, gr_ctx_t ctx) - int gr_generic_vec_div_scalar_ui(gr_ptr vec1, gr_srcptr vec2, long len, unsigned long c, gr_ctx_t ctx) - int gr_generic_vec_divexact_scalar_ui(gr_ptr vec1, gr_srcptr vec2, long len, unsigned long c, gr_ctx_t ctx) - int gr_generic_vec_pow_scalar_ui(gr_ptr vec1, gr_srcptr vec2, long len, unsigned long c, gr_ctx_t ctx) - int gr_generic_vec_add_scalar_fmpz(gr_ptr vec1, gr_srcptr vec2, long len, const fmpz_t c, gr_ctx_t ctx) - int gr_generic_vec_sub_scalar_fmpz(gr_ptr vec1, gr_srcptr vec2, long len, const fmpz_t c, gr_ctx_t ctx) - int gr_generic_vec_mul_scalar_fmpz(gr_ptr vec1, gr_srcptr vec2, long len, const fmpz_t c, gr_ctx_t ctx) - int gr_generic_vec_div_scalar_fmpz(gr_ptr vec1, gr_srcptr vec2, long len, const fmpz_t c, gr_ctx_t ctx) - int gr_generic_vec_divexact_scalar_fmpz(gr_ptr vec1, gr_srcptr vec2, long len, const fmpz_t c, gr_ctx_t ctx) - int gr_generic_vec_pow_scalar_fmpz(gr_ptr vec1, gr_srcptr vec2, long len, const fmpz_t c, gr_ctx_t ctx) - int gr_generic_vec_add_scalar_fmpq(gr_ptr vec1, gr_srcptr vec2, long len, const fmpq_t c, gr_ctx_t ctx) - int gr_generic_vec_sub_scalar_fmpq(gr_ptr vec1, gr_srcptr vec2, long len, const fmpq_t c, gr_ctx_t ctx) - int gr_generic_vec_mul_scalar_fmpq(gr_ptr vec1, gr_srcptr vec2, long len, const fmpq_t c, gr_ctx_t ctx) - int gr_generic_vec_div_scalar_fmpq(gr_ptr vec1, gr_srcptr vec2, long len, const fmpq_t c, gr_ctx_t ctx) - int gr_generic_vec_divexact_scalar_fmpq(gr_ptr vec1, gr_srcptr vec2, long len, const fmpq_t c, gr_ctx_t ctx) - int gr_generic_vec_pow_scalar_fmpq(gr_ptr vec1, gr_srcptr vec2, long len, const fmpq_t c, gr_ctx_t ctx) - int gr_generic_scalar_add_vec(gr_ptr vec1, gr_srcptr c, gr_srcptr vec2, long len, gr_ctx_t ctx) - int gr_generic_scalar_sub_vec(gr_ptr vec1, gr_srcptr c, gr_srcptr vec2, long len, gr_ctx_t ctx) - int gr_generic_scalar_mul_vec(gr_ptr vec1, gr_srcptr c, gr_srcptr vec2, long len, gr_ctx_t ctx) - int gr_generic_scalar_div_vec(gr_ptr vec1, gr_srcptr c, gr_srcptr vec2, long len, gr_ctx_t ctx) - int gr_generic_scalar_divexact_vec(gr_ptr vec1, gr_srcptr c, gr_srcptr vec2, long len, gr_ctx_t ctx) - int gr_generic_scalar_pow_vec(gr_ptr vec1, gr_srcptr c, gr_srcptr vec2, long len, gr_ctx_t ctx) - int gr_generic_vec_add_other(gr_ptr vec1, gr_srcptr vec2, gr_srcptr vec3, gr_ctx_t ctx3, long len, gr_ctx_t ctx) - int gr_generic_vec_sub_other(gr_ptr vec1, gr_srcptr vec2, gr_srcptr vec3, gr_ctx_t ctx3, long len, gr_ctx_t ctx) - int gr_generic_vec_mul_other(gr_ptr vec1, gr_srcptr vec2, gr_srcptr vec3, gr_ctx_t ctx3, long len, gr_ctx_t ctx) - int gr_generic_vec_div_other(gr_ptr vec1, gr_srcptr vec2, gr_srcptr vec3, gr_ctx_t ctx3, long len, gr_ctx_t ctx) - int gr_generic_vec_divexact_other(gr_ptr vec1, gr_srcptr vec2, gr_srcptr vec3, gr_ctx_t ctx3, long len, gr_ctx_t ctx) - int gr_generic_vec_pow_other(gr_ptr vec1, gr_srcptr vec2, gr_srcptr vec3, gr_ctx_t ctx3, long len, gr_ctx_t ctx) - int gr_generic_other_add_vec(gr_ptr vec1, gr_srcptr vec2, gr_ctx_t ctx2, gr_srcptr vec3, long len, gr_ctx_t ctx) - int gr_generic_other_sub_vec(gr_ptr vec1, gr_srcptr vec2, gr_ctx_t ctx2, gr_srcptr vec3, long len, gr_ctx_t ctx) - int gr_generic_other_mul_vec(gr_ptr vec1, gr_srcptr vec2, gr_ctx_t ctx2, gr_srcptr vec3, long len, gr_ctx_t ctx) - int gr_generic_other_div_vec(gr_ptr vec1, gr_srcptr vec2, gr_ctx_t ctx2, gr_srcptr vec3, long len, gr_ctx_t ctx) - int gr_generic_other_divexact_vec(gr_ptr vec1, gr_srcptr vec2, gr_ctx_t ctx2, gr_srcptr vec3, long len, gr_ctx_t ctx) - int gr_generic_other_pow_vec(gr_ptr vec1, gr_srcptr vec2, gr_ctx_t ctx2, gr_srcptr vec3, long len, gr_ctx_t ctx) - int gr_generic_vec_add_scalar_other(gr_ptr vec1, gr_srcptr vec2, long len, gr_srcptr c, gr_ctx_t cctx, gr_ctx_t ctx) - int gr_generic_vec_sub_scalar_other(gr_ptr vec1, gr_srcptr vec2, long len, gr_srcptr c, gr_ctx_t cctx, gr_ctx_t ctx) - int gr_generic_vec_mul_scalar_other(gr_ptr vec1, gr_srcptr vec2, long len, gr_srcptr c, gr_ctx_t cctx, gr_ctx_t ctx) - int gr_generic_vec_div_scalar_other(gr_ptr vec1, gr_srcptr vec2, long len, gr_srcptr c, gr_ctx_t cctx, gr_ctx_t ctx) - int gr_generic_vec_divexact_scalar_other(gr_ptr vec1, gr_srcptr vec2, long len, gr_srcptr c, gr_ctx_t cctx, gr_ctx_t ctx) - int gr_generic_vec_pow_scalar_other(gr_ptr vec1, gr_srcptr vec2, long len, gr_srcptr c, gr_ctx_t cctx, gr_ctx_t ctx) - int gr_generic_scalar_other_add_vec(gr_ptr vec1, gr_srcptr c, gr_ctx_t cctx, gr_srcptr vec2, long len, gr_ctx_t ctx) - int gr_generic_scalar_other_sub_vec(gr_ptr vec1, gr_srcptr c, gr_ctx_t cctx, gr_srcptr vec2, long len, gr_ctx_t ctx) - int gr_generic_scalar_other_mul_vec(gr_ptr vec1, gr_srcptr c, gr_ctx_t cctx, gr_srcptr vec2, long len, gr_ctx_t ctx) - int gr_generic_scalar_other_div_vec(gr_ptr vec1, gr_srcptr c, gr_ctx_t cctx, gr_srcptr vec2, long len, gr_ctx_t ctx) - int gr_generic_scalar_other_divexact_vec(gr_ptr vec1, gr_srcptr c, gr_ctx_t cctx, gr_srcptr vec2, long len, gr_ctx_t ctx) - int gr_generic_scalar_other_pow_vec(gr_ptr vec1, gr_srcptr c, gr_ctx_t cctx, gr_srcptr vec2, long len, gr_ctx_t ctx) + int gr_generic_eulernum_vec(gr_ptr res, slong len, gr_ctx_t ctx) + int gr_generic_stirling_s1u_uiui(gr_ptr res, ulong x, ulong y, gr_ctx_t ctx) + int gr_generic_stirling_s1_uiui(gr_ptr res, ulong x, ulong y, gr_ctx_t ctx) + int gr_generic_stirling_s2_uiui(gr_ptr res, ulong x, ulong y, gr_ctx_t ctx) + int gr_generic_stirling_s1u_ui_vec(gr_ptr res, ulong x, slong len, gr_ctx_t ctx) + int gr_generic_stirling_s1_ui_vec(gr_ptr res, ulong x, slong len, gr_ctx_t ctx) + int gr_generic_stirling_s2_ui_vec(gr_ptr res, ulong x, slong len, gr_ctx_t ctx) + + void gr_generic_vec_init(gr_ptr vec, slong len, gr_ctx_t ctx) + + void gr_generic_vec_clear(gr_ptr vec, slong len, gr_ctx_t ctx) + + void gr_generic_vec_swap(gr_ptr vec1, gr_ptr vec2, slong len, gr_ctx_t ctx) + + int gr_generic_vec_zero(gr_ptr vec, slong len, gr_ctx_t ctx) + + int gr_generic_vec_set(gr_ptr res, gr_srcptr src, slong len, gr_ctx_t ctx) + + int gr_generic_vec_neg(gr_ptr res, gr_srcptr src, slong len, gr_ctx_t ctx) + + int gr_generic_vec_normalise(slong * res, gr_srcptr vec, slong len, gr_ctx_t ctx) + + slong gr_generic_vec_normalise_weak(gr_srcptr vec, slong len, gr_ctx_t ctx) + + int gr_generic_vec_mul_scalar_2exp_si(gr_ptr vec1, gr_srcptr vec2, slong len, slong c, gr_ctx_t ctx) + + int gr_generic_vec_scalar_addmul(gr_ptr vec1, gr_srcptr vec2, slong len, gr_srcptr c, gr_ctx_t ctx) + + int gr_generic_vec_scalar_submul(gr_ptr vec1, gr_srcptr vec2, slong len, gr_srcptr c, gr_ctx_t ctx) + + int gr_generic_vec_scalar_addmul_si(gr_ptr vec1, gr_srcptr vec2, slong len, slong c, gr_ctx_t ctx) + + int gr_generic_vec_scalar_submul_si(gr_ptr vec1, gr_srcptr vec2, slong len, slong c, gr_ctx_t ctx) + + truth_t gr_generic_vec_equal(gr_srcptr vec1, gr_srcptr vec2, slong len, gr_ctx_t ctx) + + int gr_generic_vec_is_zero(gr_srcptr vec, slong len, gr_ctx_t ctx) + + int gr_generic_vec_dot(gr_ptr res, gr_srcptr initial, int subtract, gr_srcptr vec1, gr_srcptr vec2, slong len, gr_ctx_t ctx) + + int gr_generic_vec_dot_rev(gr_ptr res, gr_srcptr initial, int subtract, gr_srcptr vec1, gr_srcptr vec2, slong len, gr_ctx_t ctx) + + int gr_generic_vec_dot_ui(gr_ptr res, gr_srcptr initial, int subtract, gr_srcptr vec1, const ulong * vec2, slong len, gr_ctx_t ctx) + + int gr_generic_vec_dot_si(gr_ptr res, gr_srcptr initial, int subtract, gr_srcptr vec1, const slong * vec2, slong len, gr_ctx_t ctx) + + int gr_generic_vec_dot_fmpz(gr_ptr res, gr_srcptr initial, int subtract, gr_srcptr vec1, const fmpz * vec2, slong len, gr_ctx_t ctx) + + int gr_generic_vec_set_powers(gr_ptr res, gr_srcptr x, slong len, gr_ctx_t ctx) + + int gr_generic_vec_reciprocals(gr_ptr res, slong len, gr_ctx_t ctx) + + int gr_generic_vec_add(gr_ptr res, gr_srcptr src1, gr_srcptr src2, slong len, gr_ctx_t ctx) + int gr_generic_vec_sub(gr_ptr res, gr_srcptr src1, gr_srcptr src2, slong len, gr_ctx_t ctx) + int gr_generic_vec_mul(gr_ptr res, gr_srcptr src1, gr_srcptr src2, slong len, gr_ctx_t ctx) + int gr_generic_vec_div(gr_ptr res, gr_srcptr src1, gr_srcptr src2, slong len, gr_ctx_t ctx) + int gr_generic_vec_divexact(gr_ptr res, gr_srcptr src1, gr_srcptr src2, slong len, gr_ctx_t ctx) + int gr_generic_vec_pow(gr_ptr res, gr_srcptr src1, gr_srcptr src2, slong len, gr_ctx_t ctx) + int gr_generic_vec_add_scalar(gr_ptr vec1, gr_srcptr vec2, slong len, gr_srcptr c, gr_ctx_t ctx) + int gr_generic_vec_sub_scalar(gr_ptr vec1, gr_srcptr vec2, slong len, gr_srcptr c, gr_ctx_t ctx) + int gr_generic_vec_mul_scalar(gr_ptr vec1, gr_srcptr vec2, slong len, gr_srcptr c, gr_ctx_t ctx) + int gr_generic_vec_div_scalar(gr_ptr vec1, gr_srcptr vec2, slong len, gr_srcptr c, gr_ctx_t ctx) + int gr_generic_vec_divexact_scalar(gr_ptr vec1, gr_srcptr vec2, slong len, gr_srcptr c, gr_ctx_t ctx) + int gr_generic_vec_pow_scalar(gr_ptr vec1, gr_srcptr vec2, slong len, gr_srcptr c, gr_ctx_t ctx) + int gr_generic_vec_add_scalar_si(gr_ptr vec1, gr_srcptr vec2, slong len, slong c, gr_ctx_t ctx) + int gr_generic_vec_sub_scalar_si(gr_ptr vec1, gr_srcptr vec2, slong len, slong c, gr_ctx_t ctx) + int gr_generic_vec_mul_scalar_si(gr_ptr vec1, gr_srcptr vec2, slong len, slong c, gr_ctx_t ctx) + int gr_generic_vec_div_scalar_si(gr_ptr vec1, gr_srcptr vec2, slong len, slong c, gr_ctx_t ctx) + int gr_generic_vec_divexact_scalar_si(gr_ptr vec1, gr_srcptr vec2, slong len, slong c, gr_ctx_t ctx) + int gr_generic_vec_pow_scalar_si(gr_ptr vec1, gr_srcptr vec2, slong len, slong c, gr_ctx_t ctx) + int gr_generic_vec_add_scalar_ui(gr_ptr vec1, gr_srcptr vec2, slong len, ulong c, gr_ctx_t ctx) + int gr_generic_vec_sub_scalar_ui(gr_ptr vec1, gr_srcptr vec2, slong len, ulong c, gr_ctx_t ctx) + int gr_generic_vec_mul_scalar_ui(gr_ptr vec1, gr_srcptr vec2, slong len, ulong c, gr_ctx_t ctx) + int gr_generic_vec_div_scalar_ui(gr_ptr vec1, gr_srcptr vec2, slong len, ulong c, gr_ctx_t ctx) + int gr_generic_vec_divexact_scalar_ui(gr_ptr vec1, gr_srcptr vec2, slong len, ulong c, gr_ctx_t ctx) + int gr_generic_vec_pow_scalar_ui(gr_ptr vec1, gr_srcptr vec2, slong len, ulong c, gr_ctx_t ctx) + int gr_generic_vec_add_scalar_fmpz(gr_ptr vec1, gr_srcptr vec2, slong len, const fmpz_t c, gr_ctx_t ctx) + int gr_generic_vec_sub_scalar_fmpz(gr_ptr vec1, gr_srcptr vec2, slong len, const fmpz_t c, gr_ctx_t ctx) + int gr_generic_vec_mul_scalar_fmpz(gr_ptr vec1, gr_srcptr vec2, slong len, const fmpz_t c, gr_ctx_t ctx) + int gr_generic_vec_div_scalar_fmpz(gr_ptr vec1, gr_srcptr vec2, slong len, const fmpz_t c, gr_ctx_t ctx) + int gr_generic_vec_divexact_scalar_fmpz(gr_ptr vec1, gr_srcptr vec2, slong len, const fmpz_t c, gr_ctx_t ctx) + int gr_generic_vec_pow_scalar_fmpz(gr_ptr vec1, gr_srcptr vec2, slong len, const fmpz_t c, gr_ctx_t ctx) + int gr_generic_vec_add_scalar_fmpq(gr_ptr vec1, gr_srcptr vec2, slong len, const fmpq_t c, gr_ctx_t ctx) + int gr_generic_vec_sub_scalar_fmpq(gr_ptr vec1, gr_srcptr vec2, slong len, const fmpq_t c, gr_ctx_t ctx) + int gr_generic_vec_mul_scalar_fmpq(gr_ptr vec1, gr_srcptr vec2, slong len, const fmpq_t c, gr_ctx_t ctx) + int gr_generic_vec_div_scalar_fmpq(gr_ptr vec1, gr_srcptr vec2, slong len, const fmpq_t c, gr_ctx_t ctx) + int gr_generic_vec_divexact_scalar_fmpq(gr_ptr vec1, gr_srcptr vec2, slong len, const fmpq_t c, gr_ctx_t ctx) + int gr_generic_vec_pow_scalar_fmpq(gr_ptr vec1, gr_srcptr vec2, slong len, const fmpq_t c, gr_ctx_t ctx) + int gr_generic_scalar_add_vec(gr_ptr vec1, gr_srcptr c, gr_srcptr vec2, slong len, gr_ctx_t ctx) + int gr_generic_scalar_sub_vec(gr_ptr vec1, gr_srcptr c, gr_srcptr vec2, slong len, gr_ctx_t ctx) + int gr_generic_scalar_mul_vec(gr_ptr vec1, gr_srcptr c, gr_srcptr vec2, slong len, gr_ctx_t ctx) + int gr_generic_scalar_div_vec(gr_ptr vec1, gr_srcptr c, gr_srcptr vec2, slong len, gr_ctx_t ctx) + int gr_generic_scalar_divexact_vec(gr_ptr vec1, gr_srcptr c, gr_srcptr vec2, slong len, gr_ctx_t ctx) + int gr_generic_scalar_pow_vec(gr_ptr vec1, gr_srcptr c, gr_srcptr vec2, slong len, gr_ctx_t ctx) + int gr_generic_vec_add_other(gr_ptr vec1, gr_srcptr vec2, gr_srcptr vec3, gr_ctx_t ctx3, slong len, gr_ctx_t ctx) + int gr_generic_vec_sub_other(gr_ptr vec1, gr_srcptr vec2, gr_srcptr vec3, gr_ctx_t ctx3, slong len, gr_ctx_t ctx) + int gr_generic_vec_mul_other(gr_ptr vec1, gr_srcptr vec2, gr_srcptr vec3, gr_ctx_t ctx3, slong len, gr_ctx_t ctx) + int gr_generic_vec_div_other(gr_ptr vec1, gr_srcptr vec2, gr_srcptr vec3, gr_ctx_t ctx3, slong len, gr_ctx_t ctx) + int gr_generic_vec_divexact_other(gr_ptr vec1, gr_srcptr vec2, gr_srcptr vec3, gr_ctx_t ctx3, slong len, gr_ctx_t ctx) + int gr_generic_vec_pow_other(gr_ptr vec1, gr_srcptr vec2, gr_srcptr vec3, gr_ctx_t ctx3, slong len, gr_ctx_t ctx) + int gr_generic_other_add_vec(gr_ptr vec1, gr_srcptr vec2, gr_ctx_t ctx2, gr_srcptr vec3, slong len, gr_ctx_t ctx) + int gr_generic_other_sub_vec(gr_ptr vec1, gr_srcptr vec2, gr_ctx_t ctx2, gr_srcptr vec3, slong len, gr_ctx_t ctx) + int gr_generic_other_mul_vec(gr_ptr vec1, gr_srcptr vec2, gr_ctx_t ctx2, gr_srcptr vec3, slong len, gr_ctx_t ctx) + int gr_generic_other_div_vec(gr_ptr vec1, gr_srcptr vec2, gr_ctx_t ctx2, gr_srcptr vec3, slong len, gr_ctx_t ctx) + int gr_generic_other_divexact_vec(gr_ptr vec1, gr_srcptr vec2, gr_ctx_t ctx2, gr_srcptr vec3, slong len, gr_ctx_t ctx) + int gr_generic_other_pow_vec(gr_ptr vec1, gr_srcptr vec2, gr_ctx_t ctx2, gr_srcptr vec3, slong len, gr_ctx_t ctx) + int gr_generic_vec_add_scalar_other(gr_ptr vec1, gr_srcptr vec2, slong len, gr_srcptr c, gr_ctx_t cctx, gr_ctx_t ctx) + int gr_generic_vec_sub_scalar_other(gr_ptr vec1, gr_srcptr vec2, slong len, gr_srcptr c, gr_ctx_t cctx, gr_ctx_t ctx) + int gr_generic_vec_mul_scalar_other(gr_ptr vec1, gr_srcptr vec2, slong len, gr_srcptr c, gr_ctx_t cctx, gr_ctx_t ctx) + int gr_generic_vec_div_scalar_other(gr_ptr vec1, gr_srcptr vec2, slong len, gr_srcptr c, gr_ctx_t cctx, gr_ctx_t ctx) + int gr_generic_vec_divexact_scalar_other(gr_ptr vec1, gr_srcptr vec2, slong len, gr_srcptr c, gr_ctx_t cctx, gr_ctx_t ctx) + int gr_generic_vec_pow_scalar_other(gr_ptr vec1, gr_srcptr vec2, slong len, gr_srcptr c, gr_ctx_t cctx, gr_ctx_t ctx) + int gr_generic_scalar_other_add_vec(gr_ptr vec1, gr_srcptr c, gr_ctx_t cctx, gr_srcptr vec2, slong len, gr_ctx_t ctx) + int gr_generic_scalar_other_sub_vec(gr_ptr vec1, gr_srcptr c, gr_ctx_t cctx, gr_srcptr vec2, slong len, gr_ctx_t ctx) + int gr_generic_scalar_other_mul_vec(gr_ptr vec1, gr_srcptr c, gr_ctx_t cctx, gr_srcptr vec2, slong len, gr_ctx_t ctx) + int gr_generic_scalar_other_div_vec(gr_ptr vec1, gr_srcptr c, gr_ctx_t cctx, gr_srcptr vec2, slong len, gr_ctx_t ctx) + int gr_generic_scalar_other_divexact_vec(gr_ptr vec1, gr_srcptr c, gr_ctx_t cctx, gr_srcptr vec2, slong len, gr_ctx_t ctx) + int gr_generic_scalar_other_pow_vec(gr_ptr vec1, gr_srcptr c, gr_ctx_t cctx, gr_srcptr vec2, slong len, gr_ctx_t ctx) diff --git a/src/sage/libs/flint/gr_mat.pxd b/src/sage/libs/flint/gr_mat.pxd index d75f4b7c7e5..5d42e52d699 100644 --- a/src/sage/libs/flint/gr_mat.pxd +++ b/src/sage/libs/flint/gr_mat.pxd @@ -12,11 +12,11 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - gr_ptr gr_mat_entry_ptr(gr_mat_t mat, long i, long j, gr_ctx_t ctx) + gr_ptr gr_mat_entry_ptr(gr_mat_t mat, slong i, slong j, gr_ctx_t ctx) # Function returning a pointer to the entry at row *i* and column # *j* of the matrix *mat*. The indices must be in bounds. - void gr_mat_init(gr_mat_t mat, long rows, long cols, gr_ctx_t ctx) + void gr_mat_init(gr_mat_t mat, slong rows, slong cols, gr_ctx_t ctx) # Initializes *mat* to a matrix with the given number of rows and # columns. @@ -33,7 +33,7 @@ cdef extern from "flint_wrap.h": # Performs a deep swap of *mat1* and *mat2*, swapping the individual # entries rather than the top-level structures. - void gr_mat_window_init(gr_mat_t window, const gr_mat_t mat, long r1, long c1, long r2, long c2, gr_ctx_t ctx) + void gr_mat_window_init(gr_mat_t window, const gr_mat_t mat, slong r1, slong c1, slong r2, slong c2, gr_ctx_t ctx) # Initializes *window* to a window matrix into the submatrix of *mat* # starting at the corner at row *r1* and column *c1* (inclusive) and ending # at row *r2* and column *c2* (exclusive). @@ -74,8 +74,8 @@ cdef extern from "flint_wrap.h": # Sets *res* to the value of *mat*. int gr_mat_set_scalar(gr_mat_t res, gr_srcptr c, gr_ctx_t ctx) - int gr_mat_set_ui(gr_mat_t res, unsigned long c, gr_ctx_t ctx) - int gr_mat_set_si(gr_mat_t res, long c, gr_ctx_t ctx) + int gr_mat_set_ui(gr_mat_t res, ulong c, gr_ctx_t ctx) + int gr_mat_set_si(gr_mat_t res, slong c, gr_ctx_t ctx) int gr_mat_set_fmpz(gr_mat_t res, const fmpz_t c, gr_ctx_t ctx) int gr_mat_set_fmpq(gr_mat_t res, const fmpq_t c, gr_ctx_t ctx) # Set *res* to the scalar matrix with *c* on the main diagonal @@ -88,20 +88,20 @@ cdef extern from "flint_wrap.h": int gr_mat_transpose(gr_mat_t B, const gr_mat_t A, gr_ctx_t ctx) # Sets *B* to the transpose of *A*. - int gr_mat_swap_rows(gr_mat_t mat, long * perm, long r, long s, gr_ctx_t ctx) + int gr_mat_swap_rows(gr_mat_t mat, slong * perm, slong r, slong s, gr_ctx_t ctx) # Swaps rows ``r`` and ``s`` of ``mat``. If ``perm`` is non-``NULL``, the # permutation of the rows will also be applied to ``perm``. - int gr_mat_swap_cols(gr_mat_t mat, long * perm, long r, long s, gr_ctx_t ctx) + int gr_mat_swap_cols(gr_mat_t mat, slong * perm, slong r, slong s, gr_ctx_t ctx) # Swaps columns ``r`` and ``s`` of ``mat``. If ``perm`` is non-``NULL``, the # permutation of the columns will also be applied to ``perm``. - int gr_mat_invert_rows(gr_mat_t mat, long * perm, gr_ctx_t ctx) + int gr_mat_invert_rows(gr_mat_t mat, slong * perm, gr_ctx_t ctx) # Swaps rows ``i`` and ``r - i`` of ``mat`` for ``0 <= i < r/2``, where # ``r`` is the number of rows of ``mat``. If ``perm`` is non-``NULL``, the # permutation of the rows will also be applied to ``perm``. - int gr_mat_invert_cols(gr_mat_t mat, long * perm, gr_ctx_t ctx) + int gr_mat_invert_cols(gr_mat_t mat, slong * perm, gr_ctx_t ctx) # Swaps columns ``i`` and ``c - i`` of ``mat`` for ``0 <= i < c/2``, where # ``c`` is the number of columns of ``mat``. If ``perm`` is non-``NULL``, the # permutation of the columns will also be applied to ``perm``. @@ -141,7 +141,7 @@ cdef extern from "flint_wrap.h": int gr_mat_submul_scalar(gr_mat_t res, const gr_mat_t mat, gr_srcptr c, gr_ctx_t ctx) int gr_mat_div_scalar(gr_mat_t res, const gr_mat_t mat, gr_srcptr c, gr_ctx_t ctx) - int _gr_mat_gr_poly_evaluate(gr_mat_t res, gr_srcptr poly, long len, const gr_mat_t mat, gr_ctx_t ctx) + int _gr_mat_gr_poly_evaluate(gr_mat_t res, gr_srcptr poly, slong len, const gr_mat_t mat, gr_ctx_t ctx) int gr_mat_gr_poly_evaluate(gr_mat_t res, const gr_poly_t poly, const gr_mat_t mat, gr_ctx_t ctx) # Sets *res* to the matrix obtained by evaluating the # scalar polynomial *poly* with matrix argument *mat*. @@ -162,9 +162,9 @@ cdef extern from "flint_wrap.h": # Set *res* to the product `AD` or `DA` respectively, where `D` is # a diagonal matrix represented as a vector of entries. - int gr_mat_find_nonzero_pivot_large_abs(long * pivot_row, gr_mat_t mat, long start_row, long end_row, long column, gr_ctx_t ctx) - int gr_mat_find_nonzero_pivot_generic(long * pivot_row, gr_mat_t mat, long start_row, long end_row, long column, gr_ctx_t ctx) - int gr_mat_find_nonzero_pivot(long * pivot_row, gr_mat_t mat, long start_row, long end_row, long column, gr_ctx_t ctx) + int gr_mat_find_nonzero_pivot_large_abs(slong * pivot_row, gr_mat_t mat, slong start_row, slong end_row, slong column, gr_ctx_t ctx) + int gr_mat_find_nonzero_pivot_generic(slong * pivot_row, gr_mat_t mat, slong start_row, slong end_row, slong column, gr_ctx_t ctx) + int gr_mat_find_nonzero_pivot(slong * pivot_row, gr_mat_t mat, slong start_row, slong end_row, slong column, gr_ctx_t ctx) # Attempts to find a nonzero element in column number *column* # of the matrix *mat* in a row between *start_row* (inclusive) # and *end_row* (exclusive). @@ -175,9 +175,9 @@ cdef extern from "flint_wrap.h": # This function may be destructive: any elements that are nontrivially # zero but can be certified zero may be overwritten by exact zeros. - int gr_mat_lu_classical(long * rank, long * P, gr_mat_t LU, const gr_mat_t A, int rank_check, gr_ctx_t ctx) - int gr_mat_lu_recursive(long * rank, long * P, gr_mat_t LU, const gr_mat_t A, int rank_check, gr_ctx_t ctx) - int gr_mat_lu(long * rank, long * P, gr_mat_t LU, const gr_mat_t A, int rank_check, gr_ctx_t ctx) + int gr_mat_lu_classical(slong * rank, slong * P, gr_mat_t LU, const gr_mat_t A, int rank_check, gr_ctx_t ctx) + int gr_mat_lu_recursive(slong * rank, slong * P, gr_mat_t LU, const gr_mat_t A, int rank_check, gr_ctx_t ctx) + int gr_mat_lu(slong * rank, slong * P, gr_mat_t LU, const gr_mat_t A, int rank_check, gr_ctx_t ctx) # Computes a generalized LU decomposition `A = PLU` of a given # matrix *A*, writing the rank of *A* to *rank*. # If *A* is a nonsingular square matrix, *LU* will be set to @@ -204,7 +204,7 @@ cdef extern from "flint_wrap.h": # The *recursive* version uses a block recursive algorithm # to take advantage of fast matrix multiplication. - int gr_mat_fflu(long * rank, long * P, gr_mat_t LU, gr_ptr den, const gr_mat_t A, int rank_check, gr_ctx_t ctx) + int gr_mat_fflu(slong * rank, slong * P, gr_mat_t LU, gr_ptr den, const gr_mat_t A, int rank_check, gr_ctx_t ctx) # Similar to :func:`gr_mat_lu`, but computes a fraction-free # LU decomposition using the Bareiss algorithm. # The denominator is written to *den*. @@ -233,8 +233,8 @@ cdef extern from "flint_wrap.h": # Solves `AX = B`. If *A* is not invertible, # returns ``GR_DOMAIN`` even if the system has a solution. - int gr_mat_nonsingular_solve_fflu_precomp(gr_mat_t X, const long * perm, const gr_mat_t LU, const gr_mat_t B, gr_ctx_t ctx) - int gr_mat_nonsingular_solve_lu_precomp(gr_mat_t X, const long * perm, const gr_mat_t LU, const gr_mat_t B, gr_ctx_t ctx) + int gr_mat_nonsingular_solve_fflu_precomp(gr_mat_t X, const slong * perm, const gr_mat_t LU, const gr_mat_t B, gr_ctx_t ctx) + int gr_mat_nonsingular_solve_lu_precomp(gr_mat_t X, const slong * perm, const gr_mat_t LU, const gr_mat_t B, gr_ctx_t ctx) # Solves `AX = B` given a precomputed FFLU or LU factorization of *A*. int gr_mat_nonsingular_solve_den_fflu(gr_mat_t X, gr_ptr den, const gr_mat_t A, const gr_mat_t B, gr_ctx_t ctx) @@ -283,9 +283,9 @@ cdef extern from "flint_wrap.h": # the square matrix *mat*. # If the matrix is not square, ``GR_DOMAIN`` is returned. - int gr_mat_rank_fflu(long * rank, const gr_mat_t mat, gr_ctx_t ctx) - int gr_mat_rank_lu(long * rank, const gr_mat_t mat, gr_ctx_t ctx) - int gr_mat_rank(long * rank, const gr_mat_t mat, gr_ctx_t ctx) + int gr_mat_rank_fflu(slong * rank, const gr_mat_t mat, gr_ctx_t ctx) + int gr_mat_rank_lu(slong * rank, const gr_mat_t mat, gr_ctx_t ctx) + int gr_mat_rank(slong * rank, const gr_mat_t mat, gr_ctx_t ctx) # Sets *res* to the rank of *mat*. # The default method returns ``GR_DOMAIN`` if the element ring # is not an integral domain, in which case the usual rank is @@ -294,14 +294,14 @@ cdef extern from "flint_wrap.h": # encounter an impossible inverse in the execution of the # respective algorithms. - int gr_mat_rref_lu(long * rank, gr_mat_t R, const gr_mat_t A, gr_ctx_t ctx) - int gr_mat_rref_fflu(long * rank, gr_mat_t R, const gr_mat_t A, gr_ctx_t ctx) - int gr_mat_rref(long * rank, gr_mat_t R, const gr_mat_t A, gr_ctx_t ctx) + int gr_mat_rref_lu(slong * rank, gr_mat_t R, const gr_mat_t A, gr_ctx_t ctx) + int gr_mat_rref_fflu(slong * rank, gr_mat_t R, const gr_mat_t A, gr_ctx_t ctx) + int gr_mat_rref(slong * rank, gr_mat_t R, const gr_mat_t A, gr_ctx_t ctx) # Sets *R* to the reduced row echelon form of *A*, also setting # *rank* to its rank. - int gr_mat_rref_den_fflu(long * rank, gr_mat_t R, gr_ptr den, const gr_mat_t A, gr_ctx_t ctx) - int gr_mat_rref_den(long * rank, gr_mat_t R, gr_ptr den, const gr_mat_t A, gr_ctx_t ctx) + int gr_mat_rref_den_fflu(slong * rank, gr_mat_t R, gr_ptr den, const gr_mat_t A, gr_ctx_t ctx) + int gr_mat_rref_den(slong * rank, gr_mat_t R, gr_ptr den, const gr_mat_t A, gr_ctx_t ctx) # Like *rref*, but computes the reduced row echelon multiplied # by a common (not necessarily minimal) denominator which is written # to *den*. This can be used to compute the rref over an integral @@ -405,7 +405,7 @@ cdef extern from "flint_wrap.h": # Compute the minimal polynomial of the matrix *mat*. # The algorithm assumes that the coefficient ring is a field. - int gr_mat_apply_row_similarity(gr_mat_t M, long r, gr_ptr d, gr_ctx_t ctx) + int gr_mat_apply_row_similarity(gr_mat_t M, slong r, gr_ptr d, gr_ctx_t ctx) # Applies an elementary similarity transform to the `n\times n` matrix `M` # in-place. # If `P` is the `n\times n` identity matrix the zero entries of whose row @@ -442,9 +442,9 @@ cdef extern from "flint_wrap.h": # with corresponding multiplicities, which can be computed # with :func:`gr_mat_eigenvalues`. - int gr_mat_set_jordan_blocks(gr_mat_t mat, const gr_vec_t lmbda, long num_blocks, long * block_lambda, long * block_size, gr_ctx_t ctx) - int gr_mat_jordan_blocks(gr_vec_t lmbda, long * num_blocks, long * block_lambda, long * block_size, const gr_mat_t A, gr_ctx_t ctx) - int gr_mat_jordan_transformation(gr_mat_t mat, const gr_vec_t lmbda, long num_blocks, long * block_lambda, long * block_size, const gr_mat_t A, gr_ctx_t ctx) + int gr_mat_set_jordan_blocks(gr_mat_t mat, const gr_vec_t lmbda, slong num_blocks, slong * block_lambda, slong * block_size, gr_ctx_t ctx) + int gr_mat_jordan_blocks(gr_vec_t lmbda, slong * num_blocks, slong * block_lambda, slong * block_size, const gr_mat_t A, gr_ctx_t ctx) + int gr_mat_jordan_transformation(gr_mat_t mat, const gr_vec_t lmbda, slong num_blocks, slong * block_lambda, slong * block_size, const gr_mat_t A, gr_ctx_t ctx) int gr_mat_jordan_form(gr_mat_t J, gr_mat_t P, const gr_mat_t A, gr_ctx_t ctx) int gr_mat_exp_jordan(gr_mat_t res, const gr_mat_t A, gr_ctx_t ctx) @@ -471,18 +471,18 @@ cdef extern from "flint_wrap.h": int gr_mat_randtest(gr_mat_t res, flint_rand_t state, gr_ctx_t ctx) # Sets *res* to a random matrix. The distribution is nonuniform. - int gr_mat_randops(gr_mat_t mat, flint_rand_t state, long count, gr_ctx_t ctx) + int gr_mat_randops(gr_mat_t mat, flint_rand_t state, slong count, gr_ctx_t ctx) # Randomises *mat* in-place by performing elementary row or column # operations. More precisely, at most *count* random additions or # subtractions of distinct rows and columns will be performed. - int gr_mat_randpermdiag(int * parity, gr_mat_t mat, flint_rand_t state, gr_ptr diag, long n, gr_ctx_t ctx) + int gr_mat_randpermdiag(int * parity, gr_mat_t mat, flint_rand_t state, gr_ptr diag, slong n, gr_ctx_t ctx) # Sets mat to a random permutation of the diagonal matrix with *n* leading entries given by # the vector ``diag``. Returns ``GR_DOMAIN`` if the main diagonal of ``mat`` # does not have room for at least *n* entries. # The parity (0 or 1) of the permutation is written to ``parity``. - int gr_mat_randrank(gr_mat_t mat, flint_rand_t state, long rank, gr_ctx_t ctx) + int gr_mat_randrank(gr_mat_t mat, flint_rand_t state, slong rank, gr_ctx_t ctx) # Sets ``mat`` to a random sparse matrix with the given rank, having exactly as many # non-zero elements as the rank. The matrix can be transformed into a dense matrix # with unchanged rank by subsequently calling :func:`gr_mat_randops`. @@ -527,7 +527,7 @@ cdef extern from "flint_wrap.h": # known to exist but for which this construction fails are # 92, 116, 156, ... (OEIS A046116). - int gr_mat_reduce_row(long * column, gr_mat_t A, long * P, long * L, long m, gr_ctx_t ctx) + int gr_mat_reduce_row(slong * column, gr_mat_t A, slong * P, slong * L, slong m, gr_ctx_t ctx) # Reduce row n of the matrix `A`, assuming the prior rows are in Gauss # form. However those rows may not be in order. The entry `i` of the array # `P` is the row of `A` which has a pivot in the `i`-th column. If no such diff --git a/src/sage/libs/flint/gr_mpoly.pxd b/src/sage/libs/flint/gr_mpoly.pxd index eb9741016b0..dcdc9a02273 100644 --- a/src/sage/libs/flint/gr_mpoly.pxd +++ b/src/sage/libs/flint/gr_mpoly.pxd @@ -15,8 +15,8 @@ cdef extern from "flint_wrap.h": void gr_mpoly_init(gr_mpoly_t A, const mpoly_ctx_t mctx, gr_ctx_t cctx) # Initializes and sets *A* to the zero polynomial. - void gr_mpoly_init3(gr_mpoly_t A, long alloc, flint_bitcnt_t bits, const mpoly_ctx_t mctx, gr_ctx_t cctx) - void gr_mpoly_init2(gr_mpoly_t A, long alloc, const mpoly_ctx_t mctx, gr_ctx_t cctx) + void gr_mpoly_init3(gr_mpoly_t A, slong alloc, flint_bitcnt_t bits, const mpoly_ctx_t mctx, gr_ctx_t cctx) + void gr_mpoly_init2(gr_mpoly_t A, slong alloc, const mpoly_ctx_t mctx, gr_ctx_t cctx) # Initializes *A* with space allocated for the given number # of coefficients and exponents with the given number of bits. @@ -35,16 +35,16 @@ cdef extern from "flint_wrap.h": truth_t gr_mpoly_is_zero(const gr_mpoly_t A, const mpoly_ctx_t mctx, gr_ctx_t cctx) # Returns whether *A* is the zero polynomial. - int gr_mpoly_gen(gr_mpoly_t A, long var, const mpoly_ctx_t mctx, gr_ctx_t cctx) + int gr_mpoly_gen(gr_mpoly_t A, slong var, const mpoly_ctx_t mctx, gr_ctx_t cctx) # Sets *A* to the generator with index *var* (indexed from zero). - truth_t gr_mpoly_is_gen(const gr_mpoly_t A, long var, const mpoly_ctx_t mctx, gr_ctx_t cctx) + truth_t gr_mpoly_is_gen(const gr_mpoly_t A, slong var, const mpoly_ctx_t mctx, gr_ctx_t cctx) # Returns whether *A* is the generator with index *var* (indexed from zero). truth_t gr_mpoly_equal(const gr_mpoly_t A, const gr_mpoly_t B, const mpoly_ctx_t mctx, gr_ctx_t cctx) # Returns whether *A* and *B* are equal. - int gr_mpoly_randtest_bits(gr_mpoly_t A, flint_rand_t state, long length, flint_bitcnt_t exp_bits, const mpoly_ctx_t mctx, gr_ctx_t cctx) + int gr_mpoly_randtest_bits(gr_mpoly_t A, flint_rand_t state, slong length, flint_bitcnt_t exp_bits, const mpoly_ctx_t mctx, gr_ctx_t cctx) # Sets *A* to a random polynomial with up to *length* terms # and up to *exp_bits* bits in the exponents. @@ -54,20 +54,20 @@ cdef extern from "flint_wrap.h": # If *x* is *NULL*, defaults are used. int gr_mpoly_get_coeff_scalar_fmpz(gr_ptr c, const gr_mpoly_t A, const fmpz * exp, const mpoly_ctx_t mctx, gr_ctx_t cctx) - int gr_mpoly_get_coeff_scalar_ui(gr_ptr c, const gr_mpoly_t A, const unsigned long * exp, const mpoly_ctx_t mctx, gr_ctx_t cctx) + int gr_mpoly_get_coeff_scalar_ui(gr_ptr c, const gr_mpoly_t A, const ulong * exp, const mpoly_ctx_t mctx, gr_ctx_t cctx) # Sets *c* to the coefficient in *A* with exponents *exp*. int gr_mpoly_set_coeff_scalar_fmpz(gr_mpoly_t A, gr_srcptr c, const fmpz * exp, const mpoly_ctx_t mctx, gr_ctx_t cctx) - int gr_mpoly_set_coeff_ui_fmpz(gr_mpoly_t A, unsigned long c, const fmpz * exp, const mpoly_ctx_t mctx, gr_ctx_t cctx) - int gr_mpoly_set_coeff_si_fmpz(gr_mpoly_t A, long c, const fmpz * exp, const mpoly_ctx_t mctx, gr_ctx_t cctx) + int gr_mpoly_set_coeff_ui_fmpz(gr_mpoly_t A, ulong c, const fmpz * exp, const mpoly_ctx_t mctx, gr_ctx_t cctx) + int gr_mpoly_set_coeff_si_fmpz(gr_mpoly_t A, slong c, const fmpz * exp, const mpoly_ctx_t mctx, gr_ctx_t cctx) int gr_mpoly_set_coeff_fmpz_fmpz(gr_mpoly_t A, const fmpz_t c, const fmpz * exp, const mpoly_ctx_t mctx, gr_ctx_t cctx) int gr_mpoly_set_coeff_fmpq_fmpz(gr_mpoly_t A, const fmpq_t c, const fmpz * exp, const mpoly_ctx_t mctx, gr_ctx_t cctx) - int gr_mpoly_set_coeff_scalar_ui(gr_mpoly_t poly, gr_srcptr c, const unsigned long * exp, const mpoly_ctx_t mctx, gr_ctx_t cctx) - int gr_mpoly_set_coeff_ui_ui(gr_mpoly_t A, unsigned long c, const unsigned long * exp, const mpoly_ctx_t mctx, gr_ctx_t cctx) - int gr_mpoly_set_coeff_si_ui(gr_mpoly_t A, long c, const unsigned long * exp, const mpoly_ctx_t mctx, gr_ctx_t cctx) - int gr_mpoly_set_coeff_fmpz_ui(gr_mpoly_t A, const fmpz_t c, const unsigned long * exp, const mpoly_ctx_t mctx, gr_ctx_t cctx) - int gr_mpoly_set_coeff_fmpq_ui(gr_mpoly_t A, const fmpq_t c, const unsigned long * exp, const mpoly_ctx_t mctx, gr_ctx_t cctx) + int gr_mpoly_set_coeff_scalar_ui(gr_mpoly_t poly, gr_srcptr c, const ulong * exp, const mpoly_ctx_t mctx, gr_ctx_t cctx) + int gr_mpoly_set_coeff_ui_ui(gr_mpoly_t A, ulong c, const ulong * exp, const mpoly_ctx_t mctx, gr_ctx_t cctx) + int gr_mpoly_set_coeff_si_ui(gr_mpoly_t A, slong c, const ulong * exp, const mpoly_ctx_t mctx, gr_ctx_t cctx) + int gr_mpoly_set_coeff_fmpz_ui(gr_mpoly_t A, const fmpz_t c, const ulong * exp, const mpoly_ctx_t mctx, gr_ctx_t cctx) + int gr_mpoly_set_coeff_fmpq_ui(gr_mpoly_t A, const fmpq_t c, const ulong * exp, const mpoly_ctx_t mctx, gr_ctx_t cctx) # Sets the coefficient with exponents *exp* in *A* to the scalar *c* # which must be an element of or coercible to the coefficient ring. @@ -87,29 +87,29 @@ cdef extern from "flint_wrap.h": # The *monomial* version assumes that *C* is a monomial. int gr_mpoly_mul_scalar(gr_mpoly_t A, const gr_mpoly_t B, gr_srcptr c, const mpoly_ctx_t mctx, gr_ctx_t cctx) - int gr_mpoly_mul_si(gr_mpoly_t A, const gr_mpoly_t B, long c, const mpoly_ctx_t mctx, gr_ctx_t cctx) - int gr_mpoly_mul_ui(gr_mpoly_t A, const gr_mpoly_t B, unsigned long c, const mpoly_ctx_t mctx, gr_ctx_t cctx) + int gr_mpoly_mul_si(gr_mpoly_t A, const gr_mpoly_t B, slong c, const mpoly_ctx_t mctx, gr_ctx_t cctx) + int gr_mpoly_mul_ui(gr_mpoly_t A, const gr_mpoly_t B, ulong c, const mpoly_ctx_t mctx, gr_ctx_t cctx) int gr_mpoly_mul_fmpz(gr_mpoly_t A, const gr_mpoly_t B, const fmpz_t c, const mpoly_ctx_t mctx, gr_ctx_t cctx) int gr_mpoly_mul_fmpq(gr_mpoly_t A, const gr_mpoly_t B, const fmpq_t c, const mpoly_ctx_t mctx, gr_ctx_t cctx) # Sets *A* to *B* multiplied by the scalar *c* which must be # an element of or coercible to the coefficient ring. - void _gr_mpoly_fit_length(gr_ptr * coeffs, long * coeffs_alloc, unsigned long ** exps, long * exps_alloc, long N, long length, gr_ctx_t cctx) + void _gr_mpoly_fit_length(gr_ptr * coeffs, slong * coeffs_alloc, ulong ** exps, slong * exps_alloc, slong N, slong length, gr_ctx_t cctx) - void gr_mpoly_fit_length(gr_mpoly_t A, long len, const mpoly_ctx_t mctx, gr_ctx_t cctx) + void gr_mpoly_fit_length(gr_mpoly_t A, slong len, const mpoly_ctx_t mctx, gr_ctx_t cctx) # Ensures that *A* has space for *len* coefficients and exponents. void gr_mpoly_fit_bits(gr_mpoly_t A, flint_bitcnt_t bits, const mpoly_ctx_t mctx, gr_ctx_t cctx) - void gr_mpoly_fit_length_fit_bits(gr_mpoly_t A, long len, flint_bitcnt_t bits, const mpoly_ctx_t mctx, gr_ctx_t cctx) + void gr_mpoly_fit_length_fit_bits(gr_mpoly_t A, slong len, flint_bitcnt_t bits, const mpoly_ctx_t mctx, gr_ctx_t cctx) - void gr_mpoly_fit_length_reset_bits(gr_mpoly_t A, long len, flint_bitcnt_t bits, const mpoly_ctx_t mctx, gr_ctx_t cctx) + void gr_mpoly_fit_length_reset_bits(gr_mpoly_t A, slong len, flint_bitcnt_t bits, const mpoly_ctx_t mctx, gr_ctx_t cctx) - void _gr_mpoly_set_length(gr_mpoly_t A, long newlen, const mpoly_ctx_t mctx, gr_ctx_t cctx) + void _gr_mpoly_set_length(gr_mpoly_t A, slong newlen, const mpoly_ctx_t mctx, gr_ctx_t cctx) - void _gr_mpoly_push_exp_ui(gr_mpoly_t A, const unsigned long * exp, const mpoly_ctx_t mctx, gr_ctx_t cctx) + void _gr_mpoly_push_exp_ui(gr_mpoly_t A, const ulong * exp, const mpoly_ctx_t mctx, gr_ctx_t cctx) - int gr_mpoly_push_term_scalar_ui(gr_mpoly_t A, gr_srcptr c, const unsigned long * exp, const mpoly_ctx_t mctx, gr_ctx_t cctx) + int gr_mpoly_push_term_scalar_ui(gr_mpoly_t A, gr_srcptr c, const ulong * exp, const mpoly_ctx_t mctx, gr_ctx_t cctx) void _gr_mpoly_push_exp_fmpz(gr_mpoly_t A, const fmpz * exp, const mpoly_ctx_t mctx, gr_ctx_t cctx) diff --git a/src/sage/libs/flint/gr_poly.pxd b/src/sage/libs/flint/gr_poly.pxd index 632363b7146..436f7f25623 100644 --- a/src/sage/libs/flint/gr_poly.pxd +++ b/src/sage/libs/flint/gr_poly.pxd @@ -14,19 +14,19 @@ cdef extern from "flint_wrap.h": void gr_poly_init(gr_poly_t poly, gr_ctx_t ctx) - void gr_poly_init2(gr_poly_t poly, long len, gr_ctx_t ctx) + void gr_poly_init2(gr_poly_t poly, slong len, gr_ctx_t ctx) void gr_poly_clear(gr_poly_t poly, gr_ctx_t ctx) - gr_ptr gr_poly_entry_ptr(gr_poly_t poly, long i, gr_ctx_t ctx) + gr_ptr gr_poly_entry_ptr(gr_poly_t poly, slong i, gr_ctx_t ctx) - long gr_poly_length(const gr_poly_t poly, gr_ctx_t ctx) + slong gr_poly_length(const gr_poly_t poly, gr_ctx_t ctx) void gr_poly_swap(gr_poly_t poly1, gr_poly_t poly2, gr_ctx_t ctx) - void gr_poly_fit_length(gr_poly_t poly, long len, gr_ctx_t ctx) + void gr_poly_fit_length(gr_poly_t poly, slong len, gr_ctx_t ctx) - void _gr_poly_set_length(gr_poly_t poly, long len, gr_ctx_t ctx) + void _gr_poly_set_length(gr_poly_t poly, slong len, gr_ctx_t ctx) void _gr_poly_normalise(gr_poly_t poly, gr_ctx_t ctx) @@ -35,10 +35,10 @@ cdef extern from "flint_wrap.h": int gr_poly_set_fmpq_poly(gr_poly_t res, const fmpq_poly_t src, gr_ctx_t ctx) int gr_poly_set_gr_poly_other(gr_poly_t res, const gr_poly_t x, gr_ctx_t x_ctx, gr_ctx_t ctx) - int _gr_poly_reverse(gr_ptr res, gr_srcptr poly, long len, long n, gr_ctx_t ctx) - int gr_poly_reverse(gr_poly_t res, const gr_poly_t poly, long n, gr_ctx_t ctx) + int _gr_poly_reverse(gr_ptr res, gr_srcptr poly, slong len, slong n, gr_ctx_t ctx) + int gr_poly_reverse(gr_poly_t res, const gr_poly_t poly, slong n, gr_ctx_t ctx) - int gr_poly_truncate(gr_poly_t res, const gr_poly_t poly, long newlen, gr_ctx_t ctx) + int gr_poly_truncate(gr_poly_t res, const gr_poly_t poly, slong newlen, gr_ctx_t ctx) int gr_poly_zero(gr_poly_t poly, gr_ctx_t ctx) int gr_poly_one(gr_poly_t poly, gr_ctx_t ctx) @@ -48,9 +48,9 @@ cdef extern from "flint_wrap.h": int gr_poly_write(gr_stream_t out, const gr_poly_t poly, const char * x, gr_ctx_t ctx) int gr_poly_print(const gr_poly_t poly, gr_ctx_t ctx) - int gr_poly_randtest(gr_poly_t poly, flint_rand_t state, long len, gr_ctx_t ctx) + int gr_poly_randtest(gr_poly_t poly, flint_rand_t state, slong len, gr_ctx_t ctx) - truth_t _gr_poly_equal(gr_srcptr poly1, long len1, gr_srcptr poly2, long len2, gr_ctx_t ctx) + truth_t _gr_poly_equal(gr_srcptr poly1, slong len1, gr_srcptr poly2, slong len2, gr_ctx_t ctx) truth_t gr_poly_equal(const gr_poly_t poly1, const gr_poly_t poly2, gr_ctx_t ctx) truth_t gr_poly_is_zero(const gr_poly_t poly, gr_ctx_t ctx) @@ -59,70 +59,70 @@ cdef extern from "flint_wrap.h": truth_t gr_poly_is_scalar(const gr_poly_t poly, gr_ctx_t ctx) int gr_poly_set_scalar(gr_poly_t poly, gr_srcptr c, gr_ctx_t ctx) - int gr_poly_set_si(gr_poly_t poly, long c, gr_ctx_t ctx) - int gr_poly_set_ui(gr_poly_t poly, unsigned long c, gr_ctx_t ctx) + int gr_poly_set_si(gr_poly_t poly, slong c, gr_ctx_t ctx) + int gr_poly_set_ui(gr_poly_t poly, ulong c, gr_ctx_t ctx) int gr_poly_set_fmpz(gr_poly_t poly, const fmpz_t c, gr_ctx_t ctx) int gr_poly_set_fmpq(gr_poly_t poly, const fmpq_t c, gr_ctx_t ctx) - int gr_poly_set_coeff_scalar(gr_poly_t poly, long n, gr_srcptr c, gr_ctx_t ctx) - int gr_poly_set_coeff_si(gr_poly_t poly, long n, long c, gr_ctx_t ctx) - int gr_poly_set_coeff_ui(gr_poly_t poly, long n, unsigned long c, gr_ctx_t ctx) - int gr_poly_set_coeff_fmpz(gr_poly_t poly, long n, const fmpz_t c, gr_ctx_t ctx) - int gr_poly_set_coeff_fmpq(gr_poly_t poly, long n, const fmpq_t c, gr_ctx_t ctx) + int gr_poly_set_coeff_scalar(gr_poly_t poly, slong n, gr_srcptr c, gr_ctx_t ctx) + int gr_poly_set_coeff_si(gr_poly_t poly, slong n, slong c, gr_ctx_t ctx) + int gr_poly_set_coeff_ui(gr_poly_t poly, slong n, ulong c, gr_ctx_t ctx) + int gr_poly_set_coeff_fmpz(gr_poly_t poly, slong n, const fmpz_t c, gr_ctx_t ctx) + int gr_poly_set_coeff_fmpq(gr_poly_t poly, slong n, const fmpq_t c, gr_ctx_t ctx) - int gr_poly_get_coeff_scalar(gr_ptr res, const gr_poly_t poly, long n, gr_ctx_t ctx) + int gr_poly_get_coeff_scalar(gr_ptr res, const gr_poly_t poly, slong n, gr_ctx_t ctx) int gr_poly_neg(gr_poly_t res, const gr_poly_t src, gr_ctx_t ctx) - int _gr_poly_add(gr_ptr res, gr_srcptr poly1, long len1, gr_srcptr poly2, long len2, gr_ctx_t ctx) + int _gr_poly_add(gr_ptr res, gr_srcptr poly1, slong len1, gr_srcptr poly2, slong len2, gr_ctx_t ctx) int gr_poly_add(gr_poly_t res, const gr_poly_t poly1, const gr_poly_t poly2, gr_ctx_t ctx) - int _gr_poly_sub(gr_ptr res, gr_srcptr poly1, long len1, gr_srcptr poly2, long len2, gr_ctx_t ctx) + int _gr_poly_sub(gr_ptr res, gr_srcptr poly1, slong len1, gr_srcptr poly2, slong len2, gr_ctx_t ctx) int gr_poly_sub(gr_poly_t res, const gr_poly_t poly1, const gr_poly_t poly2, gr_ctx_t ctx) - int _gr_poly_mul(gr_ptr res, gr_srcptr poly1, long len1, gr_srcptr poly2, long len2, gr_ctx_t ctx) + int _gr_poly_mul(gr_ptr res, gr_srcptr poly1, slong len1, gr_srcptr poly2, slong len2, gr_ctx_t ctx) int gr_poly_mul(gr_poly_t res, const gr_poly_t poly1, const gr_poly_t poly2, gr_ctx_t ctx) - int _gr_poly_mullow_generic(gr_ptr res, gr_srcptr poly1, long len1, gr_srcptr poly2, long len2, long len, gr_ctx_t ctx) - int _gr_poly_mullow(gr_ptr res, gr_srcptr poly1, long len1, gr_srcptr poly2, long len2, long len, gr_ctx_t ctx) - int gr_poly_mullow(gr_poly_t res, const gr_poly_t poly1, const gr_poly_t poly2, long len, gr_ctx_t ctx) + int _gr_poly_mullow_generic(gr_ptr res, gr_srcptr poly1, slong len1, gr_srcptr poly2, slong len2, slong len, gr_ctx_t ctx) + int _gr_poly_mullow(gr_ptr res, gr_srcptr poly1, slong len1, gr_srcptr poly2, slong len2, slong len, gr_ctx_t ctx) + int gr_poly_mullow(gr_poly_t res, const gr_poly_t poly1, const gr_poly_t poly2, slong len, gr_ctx_t ctx) int gr_poly_mul_scalar(gr_poly_t res, const gr_poly_t poly, gr_srcptr c, gr_ctx_t ctx) - int _gr_poly_pow_series_ui_binexp(gr_ptr res, gr_srcptr f, long flen, unsigned long exp, long len, gr_ctx_t ctx) - int gr_poly_pow_series_ui_binexp(gr_poly_t res, const gr_poly_t poly, unsigned long exp, long len, gr_ctx_t ctx) + int _gr_poly_pow_series_ui_binexp(gr_ptr res, gr_srcptr f, slong flen, ulong exp, slong len, gr_ctx_t ctx) + int gr_poly_pow_series_ui_binexp(gr_poly_t res, const gr_poly_t poly, ulong exp, slong len, gr_ctx_t ctx) - int _gr_poly_pow_series_ui(gr_ptr res, gr_srcptr f, long flen, unsigned long exp, long len, gr_ctx_t ctx) - int gr_poly_pow_series_ui(gr_poly_t res, const gr_poly_t poly, unsigned long exp, long len, gr_ctx_t ctx) + int _gr_poly_pow_series_ui(gr_ptr res, gr_srcptr f, slong flen, ulong exp, slong len, gr_ctx_t ctx) + int gr_poly_pow_series_ui(gr_poly_t res, const gr_poly_t poly, ulong exp, slong len, gr_ctx_t ctx) - int _gr_poly_pow_ui_binexp(gr_ptr res, gr_srcptr f, long flen, unsigned long exp, gr_ctx_t ctx) - int gr_poly_pow_ui_binexp(gr_poly_t res, const gr_poly_t poly, unsigned long exp, gr_ctx_t ctx) + int _gr_poly_pow_ui_binexp(gr_ptr res, gr_srcptr f, slong flen, ulong exp, gr_ctx_t ctx) + int gr_poly_pow_ui_binexp(gr_poly_t res, const gr_poly_t poly, ulong exp, gr_ctx_t ctx) - int _gr_poly_pow_ui(gr_ptr res, gr_srcptr f, long flen, unsigned long exp, gr_ctx_t ctx) - int gr_poly_pow_ui(gr_poly_t res, const gr_poly_t poly, unsigned long exp, gr_ctx_t ctx) + int _gr_poly_pow_ui(gr_ptr res, gr_srcptr f, slong flen, ulong exp, gr_ctx_t ctx) + int gr_poly_pow_ui(gr_poly_t res, const gr_poly_t poly, ulong exp, gr_ctx_t ctx) int gr_poly_pow_fmpz(gr_poly_t res, const gr_poly_t poly, const fmpz_t exp, gr_ctx_t ctx) - int _gr_poly_pow_series_fmpq_recurrence(gr_ptr h, gr_srcptr f, long flen, const fmpq_t exp, long len, int precomp, gr_ctx_t ctx) - int gr_poly_pow_series_fmpq_recurrence(gr_poly_t res, const gr_poly_t poly, const fmpq_t exp, long len, gr_ctx_t ctx) + int _gr_poly_pow_series_fmpq_recurrence(gr_ptr h, gr_srcptr f, slong flen, const fmpq_t exp, slong len, int precomp, gr_ctx_t ctx) + int gr_poly_pow_series_fmpq_recurrence(gr_poly_t res, const gr_poly_t poly, const fmpq_t exp, slong len, gr_ctx_t ctx) - int _gr_poly_shift_left(gr_ptr res, gr_srcptr poly, long len, long n, gr_ctx_t ctx) - int gr_poly_shift_left(gr_poly_t res, const gr_poly_t poly, long n, gr_ctx_t ctx) + int _gr_poly_shift_left(gr_ptr res, gr_srcptr poly, slong len, slong n, gr_ctx_t ctx) + int gr_poly_shift_left(gr_poly_t res, const gr_poly_t poly, slong n, gr_ctx_t ctx) - int _gr_poly_shift_right(gr_ptr res, gr_srcptr poly, long len, long n, gr_ctx_t ctx) - int gr_poly_shift_right(gr_poly_t res, const gr_poly_t poly, long n, gr_ctx_t ctx) + int _gr_poly_shift_right(gr_ptr res, gr_srcptr poly, slong len, slong n, gr_ctx_t ctx) + int gr_poly_shift_right(gr_poly_t res, const gr_poly_t poly, slong n, gr_ctx_t ctx) - int _gr_poly_divrem_divconquer_preinv1(gr_ptr Q, gr_ptr R, gr_srcptr A, long lenA, gr_srcptr B, long lenB, gr_srcptr invB, long cutoff, gr_ctx_t ctx) - int _gr_poly_divrem_divconquer_noinv(gr_ptr Q, gr_ptr R, gr_srcptr A, long lenA, gr_srcptr B, long lenB, long cutoff, gr_ctx_t ctx) - int _gr_poly_divrem_divconquer(gr_ptr Q, gr_ptr R, gr_srcptr A, long lenA, gr_srcptr B, long lenB, long cutoff, gr_ctx_t ctx) - int gr_poly_divrem_divconquer(gr_poly_t Q, gr_poly_t R, const gr_poly_t A, const gr_poly_t B, long cutoff, gr_ctx_t ctx) - int _gr_poly_divrem_basecase_preinv1(gr_ptr Q, gr_ptr R, gr_srcptr A, long lenA, gr_srcptr B, long lenB, gr_srcptr invB, gr_ctx_t ctx) - int _gr_poly_divrem_basecase_noinv(gr_ptr Q, gr_ptr R, gr_srcptr A, long lenA, gr_srcptr B, long lenB, gr_ctx_t ctx) - int _gr_poly_divrem_basecase(gr_ptr Q, gr_ptr R, gr_srcptr A, long lenA, gr_srcptr B, long lenB, gr_ctx_t ctx) + int _gr_poly_divrem_divconquer_preinv1(gr_ptr Q, gr_ptr R, gr_srcptr A, slong lenA, gr_srcptr B, slong lenB, gr_srcptr invB, slong cutoff, gr_ctx_t ctx) + int _gr_poly_divrem_divconquer_noinv(gr_ptr Q, gr_ptr R, gr_srcptr A, slong lenA, gr_srcptr B, slong lenB, slong cutoff, gr_ctx_t ctx) + int _gr_poly_divrem_divconquer(gr_ptr Q, gr_ptr R, gr_srcptr A, slong lenA, gr_srcptr B, slong lenB, slong cutoff, gr_ctx_t ctx) + int gr_poly_divrem_divconquer(gr_poly_t Q, gr_poly_t R, const gr_poly_t A, const gr_poly_t B, slong cutoff, gr_ctx_t ctx) + int _gr_poly_divrem_basecase_preinv1(gr_ptr Q, gr_ptr R, gr_srcptr A, slong lenA, gr_srcptr B, slong lenB, gr_srcptr invB, gr_ctx_t ctx) + int _gr_poly_divrem_basecase_noinv(gr_ptr Q, gr_ptr R, gr_srcptr A, slong lenA, gr_srcptr B, slong lenB, gr_ctx_t ctx) + int _gr_poly_divrem_basecase(gr_ptr Q, gr_ptr R, gr_srcptr A, slong lenA, gr_srcptr B, slong lenB, gr_ctx_t ctx) int gr_poly_divrem_basecase(gr_poly_t Q, gr_poly_t R, const gr_poly_t A, const gr_poly_t B, gr_ctx_t ctx) - int _gr_poly_divrem_newton(gr_ptr Q, gr_ptr R, gr_srcptr A, long lenA, gr_srcptr B, long lenB, gr_ctx_t ctx) + int _gr_poly_divrem_newton(gr_ptr Q, gr_ptr R, gr_srcptr A, slong lenA, gr_srcptr B, slong lenB, gr_ctx_t ctx) int gr_poly_divrem_newton(gr_poly_t Q, gr_poly_t R, const gr_poly_t A, const gr_poly_t B, gr_ctx_t ctx) - int _gr_poly_divrem(gr_ptr Q, gr_ptr R, gr_srcptr A, long lenA, gr_srcptr B, long lenB, gr_ctx_t ctx) + int _gr_poly_divrem(gr_ptr Q, gr_ptr R, gr_srcptr A, slong lenA, gr_srcptr B, slong lenB, gr_ctx_t ctx) int gr_poly_divrem(gr_poly_t Q, gr_poly_t R, const gr_poly_t A, const gr_poly_t B, gr_ctx_t ctx) # These functions implement Euclidean division with remainder: # given polynomials `A, B \in K[x]` where `K` is a field, with `B \ne 0`, @@ -158,118 +158,118 @@ cdef extern from "flint_wrap.h": # The *noinv* versions perform repeated checked divisions # by the leading coefficient. - int _gr_poly_div_divconquer_preinv1(gr_ptr Q, gr_srcptr A, long lenA, gr_srcptr B, long lenB, gr_srcptr invB, long cutoff, gr_ctx_t ctx) - int _gr_poly_div_divconquer_noinv(gr_ptr Q, gr_srcptr A, long lenA, gr_srcptr B, long lenB, long cutoff, gr_ctx_t ctx) - int _gr_poly_div_divconquer(gr_ptr Q, gr_srcptr A, long lenA, gr_srcptr B, long lenB, long cutoff, gr_ctx_t ctx) - int gr_poly_div_divconquer(gr_poly_t Q, const gr_poly_t A, const gr_poly_t B, long cutoff, gr_ctx_t ctx) - int _gr_poly_div_basecase_preinv1(gr_ptr Q, gr_srcptr A, long lenA, gr_srcptr B, long lenB, gr_srcptr invB, gr_ctx_t ctx) - int _gr_poly_div_basecase_noinv(gr_ptr Q, gr_srcptr A, long lenA, gr_srcptr B, long lenB, gr_ctx_t ctx) - int _gr_poly_div_basecase(gr_ptr Q, gr_srcptr A, long lenA, gr_srcptr B, long lenB, gr_ctx_t ctx) + int _gr_poly_div_divconquer_preinv1(gr_ptr Q, gr_srcptr A, slong lenA, gr_srcptr B, slong lenB, gr_srcptr invB, slong cutoff, gr_ctx_t ctx) + int _gr_poly_div_divconquer_noinv(gr_ptr Q, gr_srcptr A, slong lenA, gr_srcptr B, slong lenB, slong cutoff, gr_ctx_t ctx) + int _gr_poly_div_divconquer(gr_ptr Q, gr_srcptr A, slong lenA, gr_srcptr B, slong lenB, slong cutoff, gr_ctx_t ctx) + int gr_poly_div_divconquer(gr_poly_t Q, const gr_poly_t A, const gr_poly_t B, slong cutoff, gr_ctx_t ctx) + int _gr_poly_div_basecase_preinv1(gr_ptr Q, gr_srcptr A, slong lenA, gr_srcptr B, slong lenB, gr_srcptr invB, gr_ctx_t ctx) + int _gr_poly_div_basecase_noinv(gr_ptr Q, gr_srcptr A, slong lenA, gr_srcptr B, slong lenB, gr_ctx_t ctx) + int _gr_poly_div_basecase(gr_ptr Q, gr_srcptr A, slong lenA, gr_srcptr B, slong lenB, gr_ctx_t ctx) int gr_poly_div_basecase(gr_poly_t Q, const gr_poly_t A, const gr_poly_t B, gr_ctx_t ctx) - int _gr_poly_div_newton(gr_ptr Q, gr_srcptr A, long lenA, gr_srcptr B, long lenB, gr_ctx_t ctx) + int _gr_poly_div_newton(gr_ptr Q, gr_srcptr A, slong lenA, gr_srcptr B, slong lenB, gr_ctx_t ctx) int gr_poly_div_newton(gr_poly_t Q, const gr_poly_t A, const gr_poly_t B, gr_ctx_t ctx) - int _gr_poly_div(gr_ptr Q, gr_srcptr A, long lenA, gr_srcptr B, long lenB, gr_ctx_t ctx) + int _gr_poly_div(gr_ptr Q, gr_srcptr A, slong lenA, gr_srcptr B, slong lenB, gr_ctx_t ctx) int gr_poly_div(gr_poly_t Q, const gr_poly_t A, const gr_poly_t B, gr_ctx_t ctx) # Versions of the *divrem* functions which output only the quotient. # These are generally faster. - int _gr_poly_rem(gr_ptr R, gr_srcptr A, long lenA, gr_srcptr B, long lenB, gr_ctx_t ctx) + int _gr_poly_rem(gr_ptr R, gr_srcptr A, slong lenA, gr_srcptr B, slong lenB, gr_ctx_t ctx) int gr_poly_rem(gr_poly_t R, const gr_poly_t A, const gr_poly_t B, gr_ctx_t ctx) # Versions of the *divrem* functions which output only the remainder. - int _gr_poly_inv_series_newton(gr_ptr res, gr_srcptr A, long Alen, long len, long cutoff, gr_ctx_t ctx) - int gr_poly_inv_series_newton(gr_poly_t res, const gr_poly_t A, long len, long cutoff, gr_ctx_t ctx) - int _gr_poly_inv_series_basecase_preinv1(gr_ptr res, gr_srcptr A, long Alen, gr_srcptr Ainv, long len, gr_ctx_t ctx) - int _gr_poly_inv_series_basecase(gr_ptr res, gr_srcptr A, long Alen, long len, gr_ctx_t ctx) - int gr_poly_inv_series_basecase(gr_poly_t res, const gr_poly_t A, long len, gr_ctx_t ctx) - int _gr_poly_inv_series(gr_ptr res, gr_srcptr A, long Alen, long len, gr_ctx_t ctx) - int gr_poly_inv_series(gr_poly_t res, const gr_poly_t A, long len, gr_ctx_t ctx) - - int _gr_poly_div_series_newton(gr_ptr res, gr_srcptr A, long Alen, gr_srcptr B, long Blen, long len, long cutoff, gr_ctx_t ctx) - int gr_poly_div_series_newton(gr_poly_t res, const gr_poly_t A, const gr_poly_t B, long len, long cutoff, gr_ctx_t ctx) - int _gr_poly_div_series_divconquer(gr_ptr res, gr_srcptr B, long Blen, gr_srcptr A, long Alen, long len, long cutoff, gr_ctx_t ctx) - int gr_poly_div_series_divconquer(gr_poly_t Q, const gr_poly_t A, const gr_poly_t B, long len, long cutoff, gr_ctx_t ctx) - int _gr_poly_div_series_invmul(gr_ptr res, gr_srcptr B, long Blen, gr_srcptr A, long Alen, long len, gr_ctx_t ctx) - int gr_poly_div_series_invmul(gr_poly_t res, const gr_poly_t A, const gr_poly_t B, long len, gr_ctx_t ctx) - int _gr_poly_div_series_basecase_preinv1(gr_ptr Q, gr_srcptr A, long Alen, gr_srcptr B, long Blen, gr_srcptr Binv, long len, gr_ctx_t ctx) - int _gr_poly_div_series_basecase_noinv(gr_ptr Q, gr_srcptr A, long Alen, gr_srcptr B, long Blen, long len, gr_ctx_t ctx) - int _gr_poly_div_series_basecase(gr_ptr res, gr_srcptr A, long Alen, gr_srcptr B, long Blen, long len, gr_ctx_t ctx) - int gr_poly_div_series_basecase(gr_poly_t res, const gr_poly_t A, const gr_poly_t B, long len, gr_ctx_t ctx) - int _gr_poly_div_series(gr_ptr res, gr_srcptr A, long Alen, gr_srcptr B, long Blen, long len, gr_ctx_t ctx) - int gr_poly_div_series(gr_poly_t res, const gr_poly_t A, const gr_poly_t B, long len, gr_ctx_t ctx) - - int _gr_poly_divexact_basecase_bidirectional(gr_ptr Q, gr_srcptr A, long Alen, gr_srcptr B, long Blen, gr_ctx_t ctx) + int _gr_poly_inv_series_newton(gr_ptr res, gr_srcptr A, slong Alen, slong len, slong cutoff, gr_ctx_t ctx) + int gr_poly_inv_series_newton(gr_poly_t res, const gr_poly_t A, slong len, slong cutoff, gr_ctx_t ctx) + int _gr_poly_inv_series_basecase_preinv1(gr_ptr res, gr_srcptr A, slong Alen, gr_srcptr Ainv, slong len, gr_ctx_t ctx) + int _gr_poly_inv_series_basecase(gr_ptr res, gr_srcptr A, slong Alen, slong len, gr_ctx_t ctx) + int gr_poly_inv_series_basecase(gr_poly_t res, const gr_poly_t A, slong len, gr_ctx_t ctx) + int _gr_poly_inv_series(gr_ptr res, gr_srcptr A, slong Alen, slong len, gr_ctx_t ctx) + int gr_poly_inv_series(gr_poly_t res, const gr_poly_t A, slong len, gr_ctx_t ctx) + + int _gr_poly_div_series_newton(gr_ptr res, gr_srcptr A, slong Alen, gr_srcptr B, slong Blen, slong len, slong cutoff, gr_ctx_t ctx) + int gr_poly_div_series_newton(gr_poly_t res, const gr_poly_t A, const gr_poly_t B, slong len, slong cutoff, gr_ctx_t ctx) + int _gr_poly_div_series_divconquer(gr_ptr res, gr_srcptr B, slong Blen, gr_srcptr A, slong Alen, slong len, slong cutoff, gr_ctx_t ctx) + int gr_poly_div_series_divconquer(gr_poly_t Q, const gr_poly_t A, const gr_poly_t B, slong len, slong cutoff, gr_ctx_t ctx) + int _gr_poly_div_series_invmul(gr_ptr res, gr_srcptr B, slong Blen, gr_srcptr A, slong Alen, slong len, gr_ctx_t ctx) + int gr_poly_div_series_invmul(gr_poly_t res, const gr_poly_t A, const gr_poly_t B, slong len, gr_ctx_t ctx) + int _gr_poly_div_series_basecase_preinv1(gr_ptr Q, gr_srcptr A, slong Alen, gr_srcptr B, slong Blen, gr_srcptr Binv, slong len, gr_ctx_t ctx) + int _gr_poly_div_series_basecase_noinv(gr_ptr Q, gr_srcptr A, slong Alen, gr_srcptr B, slong Blen, slong len, gr_ctx_t ctx) + int _gr_poly_div_series_basecase(gr_ptr res, gr_srcptr A, slong Alen, gr_srcptr B, slong Blen, slong len, gr_ctx_t ctx) + int gr_poly_div_series_basecase(gr_poly_t res, const gr_poly_t A, const gr_poly_t B, slong len, gr_ctx_t ctx) + int _gr_poly_div_series(gr_ptr res, gr_srcptr A, slong Alen, gr_srcptr B, slong Blen, slong len, gr_ctx_t ctx) + int gr_poly_div_series(gr_poly_t res, const gr_poly_t A, const gr_poly_t B, slong len, gr_ctx_t ctx) + + int _gr_poly_divexact_basecase_bidirectional(gr_ptr Q, gr_srcptr A, slong Alen, gr_srcptr B, slong Blen, gr_ctx_t ctx) int gr_poly_divexact_basecase_bidirectional(gr_poly_t Q, const gr_poly_t A, const gr_poly_t B, gr_ctx_t ctx) - int _gr_poly_divexact_bidirectional(gr_ptr Q, gr_srcptr A, long Alen, gr_srcptr B, long Blen, gr_ctx_t ctx) + int _gr_poly_divexact_bidirectional(gr_ptr Q, gr_srcptr A, slong Alen, gr_srcptr B, slong Blen, gr_ctx_t ctx) int gr_poly_divexact_bidirectional(gr_poly_t Q, const gr_poly_t A, const gr_poly_t B, gr_ctx_t ctx) - int _gr_poly_divexact_basecase_noinv(gr_ptr Q, gr_srcptr A, long Alen, gr_srcptr B, long Blen, gr_ctx_t ctx) - int _gr_poly_divexact_basecase(gr_ptr Q, gr_srcptr A, long Alen, gr_srcptr B, long Blen, gr_ctx_t ctx) + int _gr_poly_divexact_basecase_noinv(gr_ptr Q, gr_srcptr A, slong Alen, gr_srcptr B, slong Blen, gr_ctx_t ctx) + int _gr_poly_divexact_basecase(gr_ptr Q, gr_srcptr A, slong Alen, gr_srcptr B, slong Blen, gr_ctx_t ctx) int gr_poly_divexact_basecase(gr_poly_t Q, const gr_poly_t A, const gr_poly_t B, gr_ctx_t ctx) - int _gr_poly_divexact_series_basecase_noinv(gr_ptr Q, gr_srcptr A, long Alen, gr_srcptr B, long Blen, long len, gr_ctx_t ctx) - int _gr_poly_divexact_series_basecase(gr_ptr Q, gr_srcptr A, long Alen, gr_srcptr B, long Blen, long len, gr_ctx_t ctx) - int gr_poly_divexact_series_basecase(gr_poly_t Q, const gr_poly_t A, const gr_poly_t B, long len, gr_ctx_t ctx) - - int _gr_poly_sqrt_series_newton(gr_ptr res, gr_srcptr f, long flen, long len, long cutoff, gr_ctx_t ctx) - int gr_poly_sqrt_series_newton(gr_poly_t res, const gr_poly_t f, long len, long cutoff, gr_ctx_t ctx) - int _gr_poly_sqrt_series_basecase(gr_ptr res, gr_srcptr f, long flen, long len, gr_ctx_t ctx) - int gr_poly_sqrt_series_basecase(gr_poly_t res, const gr_poly_t f, long len, gr_ctx_t ctx) - int _gr_poly_sqrt_series_miller(gr_ptr res, gr_srcptr f, long flen, long len, gr_ctx_t ctx) - int gr_poly_sqrt_series_miller(gr_poly_t res, const gr_poly_t f, long len, gr_ctx_t ctx) - int _gr_poly_sqrt_series(gr_ptr res, gr_srcptr f, long flen, long len, gr_ctx_t ctx) - int gr_poly_sqrt_series(gr_poly_t res, const gr_poly_t f, long len, gr_ctx_t ctx) - - int _gr_poly_rsqrt_series_newton(gr_ptr res, gr_srcptr f, long flen, long len, long cutoff, gr_ctx_t ctx) - int gr_poly_rsqrt_series_newton(gr_poly_t res, const gr_poly_t f, long len, long cutoff, gr_ctx_t ctx) - int _gr_poly_rsqrt_series_basecase(gr_ptr res, gr_srcptr f, long flen, long len, gr_ctx_t ctx) - int gr_poly_rsqrt_series_basecase(gr_poly_t res, const gr_poly_t f, long len, gr_ctx_t ctx) - int _gr_poly_rsqrt_series_miller(gr_ptr res, gr_srcptr f, long flen, long len, gr_ctx_t ctx) - int gr_poly_rsqrt_series_miller(gr_poly_t res, const gr_poly_t f, long len, gr_ctx_t ctx) - int _gr_poly_rsqrt_series(gr_ptr res, gr_srcptr f, long flen, long len, gr_ctx_t ctx) - int gr_poly_rsqrt_series(gr_poly_t res, const gr_poly_t f, long len, gr_ctx_t ctx) - - int _gr_poly_evaluate_rectangular(gr_ptr res, gr_srcptr poly, long len, gr_srcptr x, gr_ctx_t ctx) + int _gr_poly_divexact_series_basecase_noinv(gr_ptr Q, gr_srcptr A, slong Alen, gr_srcptr B, slong Blen, slong len, gr_ctx_t ctx) + int _gr_poly_divexact_series_basecase(gr_ptr Q, gr_srcptr A, slong Alen, gr_srcptr B, slong Blen, slong len, gr_ctx_t ctx) + int gr_poly_divexact_series_basecase(gr_poly_t Q, const gr_poly_t A, const gr_poly_t B, slong len, gr_ctx_t ctx) + + int _gr_poly_sqrt_series_newton(gr_ptr res, gr_srcptr f, slong flen, slong len, slong cutoff, gr_ctx_t ctx) + int gr_poly_sqrt_series_newton(gr_poly_t res, const gr_poly_t f, slong len, slong cutoff, gr_ctx_t ctx) + int _gr_poly_sqrt_series_basecase(gr_ptr res, gr_srcptr f, slong flen, slong len, gr_ctx_t ctx) + int gr_poly_sqrt_series_basecase(gr_poly_t res, const gr_poly_t f, slong len, gr_ctx_t ctx) + int _gr_poly_sqrt_series_miller(gr_ptr res, gr_srcptr f, slong flen, slong len, gr_ctx_t ctx) + int gr_poly_sqrt_series_miller(gr_poly_t res, const gr_poly_t f, slong len, gr_ctx_t ctx) + int _gr_poly_sqrt_series(gr_ptr res, gr_srcptr f, slong flen, slong len, gr_ctx_t ctx) + int gr_poly_sqrt_series(gr_poly_t res, const gr_poly_t f, slong len, gr_ctx_t ctx) + + int _gr_poly_rsqrt_series_newton(gr_ptr res, gr_srcptr f, slong flen, slong len, slong cutoff, gr_ctx_t ctx) + int gr_poly_rsqrt_series_newton(gr_poly_t res, const gr_poly_t f, slong len, slong cutoff, gr_ctx_t ctx) + int _gr_poly_rsqrt_series_basecase(gr_ptr res, gr_srcptr f, slong flen, slong len, gr_ctx_t ctx) + int gr_poly_rsqrt_series_basecase(gr_poly_t res, const gr_poly_t f, slong len, gr_ctx_t ctx) + int _gr_poly_rsqrt_series_miller(gr_ptr res, gr_srcptr f, slong flen, slong len, gr_ctx_t ctx) + int gr_poly_rsqrt_series_miller(gr_poly_t res, const gr_poly_t f, slong len, gr_ctx_t ctx) + int _gr_poly_rsqrt_series(gr_ptr res, gr_srcptr f, slong flen, slong len, gr_ctx_t ctx) + int gr_poly_rsqrt_series(gr_poly_t res, const gr_poly_t f, slong len, gr_ctx_t ctx) + + int _gr_poly_evaluate_rectangular(gr_ptr res, gr_srcptr poly, slong len, gr_srcptr x, gr_ctx_t ctx) int gr_poly_evaluate_rectangular(gr_ptr res, const gr_poly_t poly, gr_srcptr x, gr_ctx_t ctx) - int _gr_poly_evaluate_horner(gr_ptr res, gr_srcptr poly, long len, gr_srcptr x, gr_ctx_t ctx) + int _gr_poly_evaluate_horner(gr_ptr res, gr_srcptr poly, slong len, gr_srcptr x, gr_ctx_t ctx) int gr_poly_evaluate_horner(gr_ptr res, const gr_poly_t poly, gr_srcptr x, gr_ctx_t ctx) - int _gr_poly_evaluate(gr_ptr res, gr_srcptr poly, long len, gr_srcptr x, gr_ctx_t ctx) + int _gr_poly_evaluate(gr_ptr res, gr_srcptr poly, slong len, gr_srcptr x, gr_ctx_t ctx) int gr_poly_evaluate(gr_ptr res, const gr_poly_t poly, gr_srcptr x, gr_ctx_t ctx) # Set *res* to *poly* evaluated at *x*. - int _gr_poly_evaluate_other_horner(gr_ptr res, gr_srcptr f, long len, const gr_srcptr x, gr_ctx_t x_ctx, gr_ctx_t ctx) + int _gr_poly_evaluate_other_horner(gr_ptr res, gr_srcptr f, slong len, const gr_srcptr x, gr_ctx_t x_ctx, gr_ctx_t ctx) int gr_poly_evaluate_other_horner(gr_ptr res, const gr_poly_t f, gr_srcptr x, gr_ctx_t x_ctx, gr_ctx_t ctx) - int _gr_poly_evaluate_other_rectangular(gr_ptr res, gr_srcptr f, long len, const gr_srcptr x, gr_ctx_t x_ctx, gr_ctx_t ctx) + int _gr_poly_evaluate_other_rectangular(gr_ptr res, gr_srcptr f, slong len, const gr_srcptr x, gr_ctx_t x_ctx, gr_ctx_t ctx) int gr_poly_evaluate_other_rectangular(gr_ptr res, const gr_poly_t f, gr_srcptr x, gr_ctx_t x_ctx, gr_ctx_t ctx) - int _gr_poly_evaluate_other(gr_ptr res, gr_srcptr f, long len, const gr_srcptr x, gr_ctx_t x_ctx, gr_ctx_t ctx) + int _gr_poly_evaluate_other(gr_ptr res, gr_srcptr f, slong len, const gr_srcptr x, gr_ctx_t x_ctx, gr_ctx_t ctx) int gr_poly_evaluate_other(gr_ptr res, const gr_poly_t f, gr_srcptr x, gr_ctx_t x_ctx, gr_ctx_t ctx) # Set *res* to *poly* evaluated at *x*, where the coefficients of *f* # belong to *ctx* while both *x* and *res* belong to *x_ctx*. - gr_ptr * _gr_poly_tree_alloc(long len, gr_ctx_t ctx) + gr_ptr * _gr_poly_tree_alloc(slong len, gr_ctx_t ctx) - void _gr_poly_tree_free(gr_ptr * tree, long len, gr_ctx_t ctx) + void _gr_poly_tree_free(gr_ptr * tree, slong len, gr_ctx_t ctx) - int _gr_poly_tree_build(gr_ptr * tree, gr_srcptr roots, long len, gr_ctx_t ctx) + int _gr_poly_tree_build(gr_ptr * tree, gr_srcptr roots, slong len, gr_ctx_t ctx) - int _gr_poly_evaluate_vec_fast_precomp(gr_ptr vs, gr_srcptr poly, long plen, gr_ptr * tree, long len, gr_ctx_t ctx) + int _gr_poly_evaluate_vec_fast_precomp(gr_ptr vs, gr_srcptr poly, slong plen, gr_ptr * tree, slong len, gr_ctx_t ctx) - int _gr_poly_evaluate_vec_fast(gr_ptr ys, gr_srcptr poly, long plen, gr_srcptr xs, long n, gr_ctx_t ctx) + int _gr_poly_evaluate_vec_fast(gr_ptr ys, gr_srcptr poly, slong plen, gr_srcptr xs, slong n, gr_ctx_t ctx) int gr_poly_evaluate_vec_fast(gr_vec_t ys, const gr_poly_t poly, const gr_vec_t xs, gr_ctx_t ctx) - int _gr_poly_evaluate_vec_iter(gr_ptr ys, gr_srcptr poly, long plen, gr_srcptr xs, long n, gr_ctx_t ctx) + int _gr_poly_evaluate_vec_iter(gr_ptr ys, gr_srcptr poly, slong plen, gr_srcptr xs, slong n, gr_ctx_t ctx) int gr_poly_evaluate_vec_iter(gr_vec_t ys, const gr_poly_t poly, const gr_vec_t xs, gr_ctx_t ctx) - int _gr_poly_taylor_shift_horner(gr_ptr res, gr_srcptr poly, long len, gr_srcptr c, gr_ctx_t ctx) + int _gr_poly_taylor_shift_horner(gr_ptr res, gr_srcptr poly, slong len, gr_srcptr c, gr_ctx_t ctx) int gr_poly_taylor_shift_horner(gr_poly_t res, const gr_poly_t poly, gr_srcptr c, gr_ctx_t ctx) - int _gr_poly_taylor_shift_divconquer(gr_ptr res, gr_srcptr poly, long len, gr_srcptr c, gr_ctx_t ctx) + int _gr_poly_taylor_shift_divconquer(gr_ptr res, gr_srcptr poly, slong len, gr_srcptr c, gr_ctx_t ctx) int gr_poly_taylor_shift_divconquer(gr_poly_t res, const gr_poly_t poly, gr_srcptr c, gr_ctx_t ctx) - int _gr_poly_taylor_shift_convolution(gr_ptr res, gr_srcptr poly, long len, gr_srcptr c, gr_ctx_t ctx) + int _gr_poly_taylor_shift_convolution(gr_ptr res, gr_srcptr poly, slong len, gr_srcptr c, gr_ctx_t ctx) int gr_poly_taylor_shift_convolution(gr_poly_t res, const gr_poly_t poly, gr_srcptr c, gr_ctx_t ctx) - int _gr_poly_taylor_shift(gr_ptr res, gr_srcptr poly, long len, gr_srcptr c, gr_ctx_t ctx) + int _gr_poly_taylor_shift(gr_ptr res, gr_srcptr poly, slong len, gr_srcptr c, gr_ctx_t ctx) int gr_poly_taylor_shift(gr_poly_t res, const gr_poly_t poly, gr_srcptr c, gr_ctx_t ctx) # Sets *res* to the Taylor shift `f(x+c)`, where *f* is given by # *poly*, computed respectively using @@ -277,11 +277,11 @@ cdef extern from "flint_wrap.h": # convolution, and an automatic choice between the three algorithms. # The underscore methods support aliasing. - int _gr_poly_compose_horner(gr_ptr res, gr_srcptr poly1, long len1, gr_srcptr poly2, long len2, gr_ctx_t ctx) + int _gr_poly_compose_horner(gr_ptr res, gr_srcptr poly1, slong len1, gr_srcptr poly2, slong len2, gr_ctx_t ctx) int gr_poly_compose_horner(gr_poly_t res, const gr_poly_t poly1, const gr_poly_t poly2, gr_ctx_t ctx) - int _gr_poly_compose_divconquer(gr_ptr res, gr_srcptr poly1, long len1, gr_srcptr poly2, long len2, gr_ctx_t ctx) + int _gr_poly_compose_divconquer(gr_ptr res, gr_srcptr poly1, slong len1, gr_srcptr poly2, slong len2, gr_ctx_t ctx) int gr_poly_compose_divconquer(gr_poly_t res, const gr_poly_t poly1, const gr_poly_t poly2, gr_ctx_t ctx) - int _gr_poly_compose(gr_ptr res, gr_srcptr poly1, long len1, gr_srcptr poly2, long len2, gr_ctx_t ctx) + int _gr_poly_compose(gr_ptr res, gr_srcptr poly1, slong len1, gr_srcptr poly2, slong len2, gr_ctx_t ctx) int gr_poly_compose(gr_poly_t res, const gr_poly_t poly1, const gr_poly_t poly2, gr_ctx_t ctx) # Sets *res* to the composition `f(g(x))` where *f* is given by *poly1* # and *g* is given by *poly2*, respectively using Horner's rule, @@ -291,14 +291,14 @@ cdef extern from "flint_wrap.h": # The underscore methods do not support aliasing of the output # with either input polynomial. - int _gr_poly_compose_series_horner(gr_ptr res, gr_srcptr poly1, long len1, gr_srcptr poly2, long len2, long n, gr_ctx_t ctx) - int gr_poly_compose_series_horner(gr_poly_t res, const gr_poly_t poly1, const gr_poly_t poly2, long n, gr_ctx_t ctx) - int _gr_poly_compose_series_brent_kung(gr_ptr res, gr_srcptr poly1, long len1, gr_srcptr poly2, long len2, long n, gr_ctx_t ctx) - int gr_poly_compose_series_brent_kung(gr_poly_t res, const gr_poly_t poly1, const gr_poly_t poly2, long n, gr_ctx_t ctx) - int _gr_poly_compose_series_divconquer(gr_ptr res, gr_srcptr poly1, long len1, gr_srcptr poly2, long len2, long n, gr_ctx_t ctx) - int gr_poly_compose_series_divconquer(gr_poly_t res, const gr_poly_t poly1, const gr_poly_t poly2, long n, gr_ctx_t ctx) - int _gr_poly_compose_series(gr_ptr res, gr_srcptr poly1, long len1, gr_srcptr poly2, long len2, long n, gr_ctx_t ctx) - int gr_poly_compose_series(gr_poly_t res, const gr_poly_t poly1, const gr_poly_t poly2, long n, gr_ctx_t ctx) + int _gr_poly_compose_series_horner(gr_ptr res, gr_srcptr poly1, slong len1, gr_srcptr poly2, slong len2, slong n, gr_ctx_t ctx) + int gr_poly_compose_series_horner(gr_poly_t res, const gr_poly_t poly1, const gr_poly_t poly2, slong n, gr_ctx_t ctx) + int _gr_poly_compose_series_brent_kung(gr_ptr res, gr_srcptr poly1, slong len1, gr_srcptr poly2, slong len2, slong n, gr_ctx_t ctx) + int gr_poly_compose_series_brent_kung(gr_poly_t res, const gr_poly_t poly1, const gr_poly_t poly2, slong n, gr_ctx_t ctx) + int _gr_poly_compose_series_divconquer(gr_ptr res, gr_srcptr poly1, slong len1, gr_srcptr poly2, slong len2, slong n, gr_ctx_t ctx) + int gr_poly_compose_series_divconquer(gr_poly_t res, const gr_poly_t poly1, const gr_poly_t poly2, slong n, gr_ctx_t ctx) + int _gr_poly_compose_series(gr_ptr res, gr_srcptr poly1, slong len1, gr_srcptr poly2, slong len2, slong n, gr_ctx_t ctx) + int gr_poly_compose_series(gr_poly_t res, const gr_poly_t poly1, const gr_poly_t poly2, slong n, gr_ctx_t ctx) # Sets *res* to the power series composition `h(x) = f(g(x))` truncated # to order `O(x^n)` where `f` is given by *poly1* and `g` is given by *poly2*, # respectively using Horner's rule, the Brent-Kung baby step-giant step @@ -309,22 +309,22 @@ cdef extern from "flint_wrap.h": # The underscore methods do not support aliasing of the output # with either input polynomial, and do not zero-pad the result. - int _gr_poly_derivative(gr_ptr res, gr_srcptr poly, long len, gr_ctx_t ctx) + int _gr_poly_derivative(gr_ptr res, gr_srcptr poly, slong len, gr_ctx_t ctx) int gr_poly_derivative(gr_poly_t res, const gr_poly_t poly, gr_ctx_t ctx) - int _gr_poly_nth_derivative(gr_ptr res, gr_srcptr poly, unsigned long n, long len, gr_ctx_t ctx) - int gr_poly_nth_derivative(gr_poly_t res, const gr_poly_t poly, unsigned long n, gr_ctx_t ctx) + int _gr_poly_nth_derivative(gr_ptr res, gr_srcptr poly, ulong n, slong len, gr_ctx_t ctx) + int gr_poly_nth_derivative(gr_poly_t res, const gr_poly_t poly, ulong n, gr_ctx_t ctx) - int _gr_poly_integral(gr_ptr res, gr_srcptr poly, long len, gr_ctx_t ctx) + int _gr_poly_integral(gr_ptr res, gr_srcptr poly, slong len, gr_ctx_t ctx) int gr_poly_integral(gr_poly_t res, const gr_poly_t poly, gr_ctx_t ctx) - int _gr_poly_make_monic(gr_ptr res, gr_srcptr poly, long len, gr_ctx_t ctx) + int _gr_poly_make_monic(gr_ptr res, gr_srcptr poly, slong len, gr_ctx_t ctx) int gr_poly_make_monic(gr_poly_t res, const gr_poly_t src, gr_ctx_t ctx) - truth_t _gr_poly_is_monic(gr_srcptr poly, long len, gr_ctx_t ctx) + truth_t _gr_poly_is_monic(gr_srcptr poly, slong len, gr_ctx_t ctx) truth_t gr_poly_is_monic(const gr_poly_t res, gr_ctx_t ctx) - int _gr_poly_hgcd(gr_ptr r, long * sgn, gr_ptr * M, long * lenM, gr_ptr A, long * lenA, gr_ptr B, long * lenB, gr_srcptr a, long lena, gr_srcptr b, long lenb, long cutoff, gr_ctx_t ctx) + int _gr_poly_hgcd(gr_ptr r, slong * sgn, gr_ptr * M, slong * lenM, gr_ptr A, slong * lenA, gr_ptr B, slong * lenB, gr_srcptr a, slong lena, gr_srcptr b, slong lenb, slong cutoff, gr_ctx_t ctx) # Computes the HGCD of `a` and `b`, that is, a matrix `M`, a sign `\sigma` # and two polynomials `A` and `B` such that # .. math :: @@ -338,11 +338,11 @@ cdef extern from "flint_wrap.h": # If `r` is not ``NULL``, writes to that variable the corresponding value # for computing resultants using the HGCD algorithm. - int _gr_poly_gcd_hgcd(gr_ptr G, long * _lenG, gr_srcptr A, long lenA, gr_srcptr B, long lenB, long inner_cutoff, long cutoff, gr_ctx_t ctx) - int gr_poly_gcd_hgcd(gr_poly_t G, const gr_poly_t A, const gr_poly_t B, long inner_cutoff, long cutoff, gr_ctx_t ctx) - int _gr_poly_gcd_euclidean(gr_ptr G, long * lenG, gr_srcptr A, long lenA, gr_srcptr B, long lenB, gr_ctx_t ctx) + int _gr_poly_gcd_hgcd(gr_ptr G, slong * _lenG, gr_srcptr A, slong lenA, gr_srcptr B, slong lenB, slong inner_cutoff, slong cutoff, gr_ctx_t ctx) + int gr_poly_gcd_hgcd(gr_poly_t G, const gr_poly_t A, const gr_poly_t B, slong inner_cutoff, slong cutoff, gr_ctx_t ctx) + int _gr_poly_gcd_euclidean(gr_ptr G, slong * lenG, gr_srcptr A, slong lenA, gr_srcptr B, slong lenB, gr_ctx_t ctx) int gr_poly_gcd_euclidean(gr_poly_t G, const gr_poly_t A, const gr_poly_t B, gr_ctx_t ctx) - int _gr_poly_gcd(gr_ptr G, long * lenG, gr_srcptr A, long lenA, gr_srcptr B, long lenB, gr_ctx_t ctx) + int _gr_poly_gcd(gr_ptr G, slong * lenG, gr_srcptr A, slong lenA, gr_srcptr B, slong lenB, gr_ctx_t ctx) int gr_poly_gcd(gr_poly_t G, const gr_poly_t A, const gr_poly_t B, gr_ctx_t ctx) # Polynomial GCD. Currently only useful over fields. # The underscore methods assume ``lenA >= lenB >= 1`` and that both @@ -351,21 +351,21 @@ cdef extern from "flint_wrap.h": # The time complexity of the half-GCD algorithm is `\mathcal{O}(n \log^2 n)` # ring operations. For further details, see [ThullYap1990]_. - int _gr_poly_xgcd_euclidean(long * lenG, gr_ptr G, gr_ptr S, gr_ptr T, gr_srcptr A, long lenA, gr_srcptr B, long lenB, gr_ctx_t ctx) + int _gr_poly_xgcd_euclidean(slong * lenG, gr_ptr G, gr_ptr S, gr_ptr T, gr_srcptr A, slong lenA, gr_srcptr B, slong lenB, gr_ctx_t ctx) int gr_poly_xgcd_euclidean(gr_poly_t G, gr_poly_t S, gr_poly_t T, const gr_poly_t A, const gr_poly_t B, gr_ctx_t ctx) - int _gr_poly_xgcd_hgcd(long * Glen, gr_ptr G, gr_ptr S, gr_ptr T, gr_srcptr A, long lenA, gr_srcptr B, long lenB, long hgcd_cutoff, long cutoff, gr_ctx_t ctx) - int gr_poly_xgcd_hgcd(gr_poly_t G, gr_poly_t S, gr_poly_t T, const gr_poly_t A, const gr_poly_t B, long hgcd_cutoff, long cutoff, gr_ctx_t ctx) + int _gr_poly_xgcd_hgcd(slong * Glen, gr_ptr G, gr_ptr S, gr_ptr T, gr_srcptr A, slong lenA, gr_srcptr B, slong lenB, slong hgcd_cutoff, slong cutoff, gr_ctx_t ctx) + int gr_poly_xgcd_hgcd(gr_poly_t G, gr_poly_t S, gr_poly_t T, const gr_poly_t A, const gr_poly_t B, slong hgcd_cutoff, slong cutoff, gr_ctx_t ctx) - int _gr_poly_resultant_euclidean(gr_ptr res, gr_srcptr poly1, long len1, gr_srcptr poly2, long len2, gr_ctx_t ctx) + int _gr_poly_resultant_euclidean(gr_ptr res, gr_srcptr poly1, slong len1, gr_srcptr poly2, slong len2, gr_ctx_t ctx) int gr_poly_resultant_euclidean(gr_ptr res, const gr_poly_t f, const gr_poly_t g, gr_ctx_t ctx) - int _gr_poly_resultant_hgcd(gr_ptr res, gr_srcptr A, long lenA, gr_srcptr B, long lenB, long inner_cutoff, long cutoff, gr_ctx_t ctx) - int gr_poly_resultant_hgcd(gr_ptr res, const gr_poly_t f, const gr_poly_t g, long inner_cutoff, long cutoff, gr_ctx_t ctx) - int _gr_poly_resultant_sylvester(gr_ptr res, gr_srcptr poly1, long len1, gr_srcptr poly2, long len2, gr_ctx_t ctx) + int _gr_poly_resultant_hgcd(gr_ptr res, gr_srcptr A, slong lenA, gr_srcptr B, slong lenB, slong inner_cutoff, slong cutoff, gr_ctx_t ctx) + int gr_poly_resultant_hgcd(gr_ptr res, const gr_poly_t f, const gr_poly_t g, slong inner_cutoff, slong cutoff, gr_ctx_t ctx) + int _gr_poly_resultant_sylvester(gr_ptr res, gr_srcptr poly1, slong len1, gr_srcptr poly2, slong len2, gr_ctx_t ctx) int gr_poly_resultant_sylvester(gr_ptr res, const gr_poly_t f, const gr_poly_t g, gr_ctx_t ctx) - int _gr_poly_resultant_small(gr_ptr res, gr_srcptr poly1, long len1, gr_srcptr poly2, long len2, gr_ctx_t ctx) + int _gr_poly_resultant_small(gr_ptr res, gr_srcptr poly1, slong len1, gr_srcptr poly2, slong len2, gr_ctx_t ctx) int gr_poly_resultant_small(gr_ptr res, const gr_poly_t f, const gr_poly_t g, gr_ctx_t ctx) - int _gr_poly_resultant(gr_ptr res, gr_srcptr poly1, long len1, gr_srcptr poly2, long len2, gr_ctx_t ctx) + int _gr_poly_resultant(gr_ptr res, gr_srcptr poly1, slong len1, gr_srcptr poly2, slong len2, gr_ctx_t ctx) int gr_poly_resultant(gr_ptr res, const gr_poly_t f, const gr_poly_t g, gr_ctx_t ctx) # Sets *res* to the resultant of *poly1* and *poly2*. # The underscore methods assume that `len1 \ge len2 \ge 1` @@ -420,38 +420,38 @@ cdef extern from "flint_wrap.h": # We consider roots of the zero polynomial to be ill-defined and return # ``GR_DOMAIN`` in that case. - int _gr_poly_asin_series(gr_ptr res, gr_srcptr f, long flen, long len, gr_ctx_t ctx) - int gr_poly_asin_series(gr_poly_t res, const gr_poly_t f, long len, gr_ctx_t ctx) - int _gr_poly_asinh_series(gr_ptr res, gr_srcptr f, long flen, long len, gr_ctx_t ctx) - int gr_poly_asinh_series(gr_poly_t res, const gr_poly_t f, long len, gr_ctx_t ctx) - int _gr_poly_acos_series(gr_ptr res, gr_srcptr f, long flen, long len, gr_ctx_t ctx) - int gr_poly_acos_series(gr_poly_t res, const gr_poly_t f, long len, gr_ctx_t ctx) - int _gr_poly_acosh_series(gr_ptr res, gr_srcptr f, long flen, long len, gr_ctx_t ctx) - int gr_poly_acosh_series(gr_poly_t res, const gr_poly_t f, long len, gr_ctx_t ctx) - int _gr_poly_atan_series(gr_ptr res, gr_srcptr f, long flen, long len, gr_ctx_t ctx) - int gr_poly_atan_series(gr_poly_t res, const gr_poly_t f, long len, gr_ctx_t ctx) - int _gr_poly_atanh_series(gr_ptr res, gr_srcptr f, long flen, long len, gr_ctx_t ctx) - int gr_poly_atanh_series(gr_poly_t res, const gr_poly_t f, long len, gr_ctx_t ctx) - - int _gr_poly_log_series(gr_ptr res, gr_srcptr f, long flen, long len, gr_ctx_t ctx) - int gr_poly_log_series(gr_poly_t res, const gr_poly_t f, long len, gr_ctx_t ctx) - int _gr_poly_log1p_series(gr_ptr res, gr_srcptr f, long flen, long len, gr_ctx_t ctx) - int gr_poly_log1p_series(gr_poly_t res, const gr_poly_t f, long len, gr_ctx_t ctx) - - int _gr_poly_exp_series_basecase(gr_ptr f, gr_srcptr h, long hlen, long n, gr_ctx_t ctx) - int gr_poly_exp_series_basecase(gr_poly_t f, const gr_poly_t h, long n, gr_ctx_t ctx) - int _gr_poly_exp_series_basecase_mul(gr_ptr f, gr_srcptr h, long hlen, long n, gr_ctx_t ctx) - int gr_poly_exp_series_basecase_mul(gr_poly_t f, const gr_poly_t h, long n, gr_ctx_t ctx) - int _gr_poly_exp_series_newton(gr_ptr f, gr_ptr g, gr_srcptr h, long hlen, long n, long cutoff, gr_ctx_t ctx) - int gr_poly_exp_series_newton(gr_poly_t f, const gr_poly_t h, long n, long cutoff, gr_ctx_t ctx) - int _gr_poly_exp_series_generic(gr_ptr f, gr_srcptr h, long hlen, long n, gr_ctx_t ctx) - int _gr_poly_exp_series(gr_ptr res, gr_srcptr f, long flen, long len, gr_ctx_t ctx) - int gr_poly_exp_series(gr_poly_t f, const gr_poly_t h, long n, gr_ctx_t ctx) - - int _gr_poly_sin_cos_series_basecase(gr_ptr s, gr_ptr c, gr_srcptr h, long hlen, long n, int times_pi, gr_ctx_t ctx) - int gr_poly_sin_cos_series_basecase(gr_poly_t s, gr_poly_t c, const gr_poly_t h, long n, int times_pi, gr_ctx_t ctx) - int _gr_poly_sin_cos_series_tangent(gr_ptr s, gr_ptr c, gr_srcptr h, long hlen, long n, int times_pi, gr_ctx_t ctx) - int gr_poly_sin_cos_series_tangent(gr_poly_t s, gr_poly_t c, const gr_poly_t h, long n, int times_pi, gr_ctx_t ctx) + int _gr_poly_asin_series(gr_ptr res, gr_srcptr f, slong flen, slong len, gr_ctx_t ctx) + int gr_poly_asin_series(gr_poly_t res, const gr_poly_t f, slong len, gr_ctx_t ctx) + int _gr_poly_asinh_series(gr_ptr res, gr_srcptr f, slong flen, slong len, gr_ctx_t ctx) + int gr_poly_asinh_series(gr_poly_t res, const gr_poly_t f, slong len, gr_ctx_t ctx) + int _gr_poly_acos_series(gr_ptr res, gr_srcptr f, slong flen, slong len, gr_ctx_t ctx) + int gr_poly_acos_series(gr_poly_t res, const gr_poly_t f, slong len, gr_ctx_t ctx) + int _gr_poly_acosh_series(gr_ptr res, gr_srcptr f, slong flen, slong len, gr_ctx_t ctx) + int gr_poly_acosh_series(gr_poly_t res, const gr_poly_t f, slong len, gr_ctx_t ctx) + int _gr_poly_atan_series(gr_ptr res, gr_srcptr f, slong flen, slong len, gr_ctx_t ctx) + int gr_poly_atan_series(gr_poly_t res, const gr_poly_t f, slong len, gr_ctx_t ctx) + int _gr_poly_atanh_series(gr_ptr res, gr_srcptr f, slong flen, slong len, gr_ctx_t ctx) + int gr_poly_atanh_series(gr_poly_t res, const gr_poly_t f, slong len, gr_ctx_t ctx) + + int _gr_poly_log_series(gr_ptr res, gr_srcptr f, slong flen, slong len, gr_ctx_t ctx) + int gr_poly_log_series(gr_poly_t res, const gr_poly_t f, slong len, gr_ctx_t ctx) + int _gr_poly_log1p_series(gr_ptr res, gr_srcptr f, slong flen, slong len, gr_ctx_t ctx) + int gr_poly_log1p_series(gr_poly_t res, const gr_poly_t f, slong len, gr_ctx_t ctx) + + int _gr_poly_exp_series_basecase(gr_ptr f, gr_srcptr h, slong hlen, slong n, gr_ctx_t ctx) + int gr_poly_exp_series_basecase(gr_poly_t f, const gr_poly_t h, slong n, gr_ctx_t ctx) + int _gr_poly_exp_series_basecase_mul(gr_ptr f, gr_srcptr h, slong hlen, slong n, gr_ctx_t ctx) + int gr_poly_exp_series_basecase_mul(gr_poly_t f, const gr_poly_t h, slong n, gr_ctx_t ctx) + int _gr_poly_exp_series_newton(gr_ptr f, gr_ptr g, gr_srcptr h, slong hlen, slong n, slong cutoff, gr_ctx_t ctx) + int gr_poly_exp_series_newton(gr_poly_t f, const gr_poly_t h, slong n, slong cutoff, gr_ctx_t ctx) + int _gr_poly_exp_series_generic(gr_ptr f, gr_srcptr h, slong hlen, slong n, gr_ctx_t ctx) + int _gr_poly_exp_series(gr_ptr res, gr_srcptr f, slong flen, slong len, gr_ctx_t ctx) + int gr_poly_exp_series(gr_poly_t f, const gr_poly_t h, slong n, gr_ctx_t ctx) + + int _gr_poly_sin_cos_series_basecase(gr_ptr s, gr_ptr c, gr_srcptr h, slong hlen, slong n, int times_pi, gr_ctx_t ctx) + int gr_poly_sin_cos_series_basecase(gr_poly_t s, gr_poly_t c, const gr_poly_t h, slong n, int times_pi, gr_ctx_t ctx) + int _gr_poly_sin_cos_series_tangent(gr_ptr s, gr_ptr c, gr_srcptr h, slong hlen, slong n, int times_pi, gr_ctx_t ctx) + int gr_poly_sin_cos_series_tangent(gr_poly_t s, gr_poly_t c, const gr_poly_t h, slong n, int times_pi, gr_ctx_t ctx) # The *basecase* version uses a simple recurrence for the coefficients, # requiring `O(nm)` operations where `m` is the length of `h`. # The *tangent* version uses the tangent half-angle formulas to compute @@ -464,9 +464,9 @@ cdef extern from "flint_wrap.h": # The *basecase* and *tangent* versions take a flag *times_pi* # specifying that the input is to be multiplied by `\pi`. - int _gr_poly_tan_series_basecase(gr_ptr f, gr_srcptr h, long hlen, long n, gr_ctx_t ctx) - int gr_poly_tan_series_basecase(gr_poly_t f, const gr_poly_t h, long n, gr_ctx_t ctx) - int _gr_poly_tan_series_newton(gr_ptr f, gr_srcptr h, long hlen, long n, long cutoff, gr_ctx_t ctx) - int gr_poly_tan_series_newton(gr_poly_t f, const gr_poly_t h, long n, long cutoff, gr_ctx_t ctx) - int _gr_poly_tan_series(gr_ptr f, gr_srcptr h, long hlen, long n, gr_ctx_t ctx) - int gr_poly_tan_series(gr_poly_t f, const gr_poly_t h, long n, gr_ctx_t ctx) + int _gr_poly_tan_series_basecase(gr_ptr f, gr_srcptr h, slong hlen, slong n, gr_ctx_t ctx) + int gr_poly_tan_series_basecase(gr_poly_t f, const gr_poly_t h, slong n, gr_ctx_t ctx) + int _gr_poly_tan_series_newton(gr_ptr f, gr_srcptr h, slong hlen, slong n, slong cutoff, gr_ctx_t ctx) + int gr_poly_tan_series_newton(gr_poly_t f, const gr_poly_t h, slong n, slong cutoff, gr_ctx_t ctx) + int _gr_poly_tan_series(gr_ptr f, gr_srcptr h, slong hlen, slong n, gr_ctx_t ctx) + int gr_poly_tan_series(gr_poly_t f, const gr_poly_t h, slong n, gr_ctx_t ctx) diff --git a/src/sage/libs/flint/gr_special.pxd b/src/sage/libs/flint/gr_special.pxd index 5481319e131..7eceb713c57 100644 --- a/src/sage/libs/flint/gr_special.pxd +++ b/src/sage/libs/flint/gr_special.pxd @@ -84,26 +84,26 @@ cdef extern from "flint_wrap.h": int gr_lambertw_fmpz(gr_ptr res, gr_srcptr x, const fmpz_t k, gr_ctx_t ctx) int gr_fac(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) - int gr_fac_ui(gr_ptr res, unsigned long x, gr_ctx_t ctx) + int gr_fac_ui(gr_ptr res, ulong x, gr_ctx_t ctx) int gr_fac_fmpz(gr_ptr res, const fmpz_t x, gr_ctx_t ctx) - int gr_fac_vec(gr_ptr res, long len, gr_ctx_t ctx) + int gr_fac_vec(gr_ptr res, slong len, gr_ctx_t ctx) # Factorial `x!`. The *vec* version writes the first *len* # consecutive values `1, 1, 2, 6, \ldots, (len-1)!` # to the preallocated vector *res*. int gr_rfac(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) - int gr_rfac_ui(gr_ptr res, unsigned long x, gr_ctx_t ctx) + int gr_rfac_ui(gr_ptr res, ulong x, gr_ctx_t ctx) int gr_rfac_fmpz(gr_ptr res, const fmpz_t x, gr_ctx_t ctx) - int gr_rfac_vec(gr_ptr res, long len, gr_ctx_t ctx) + int gr_rfac_vec(gr_ptr res, slong len, gr_ctx_t ctx) # Reciprocal factorial. The *vec* version writes the first *len* # consecutive values `1, 1, 1/2, 1/6, \ldots, 1/(len-1)!` # to the preallocated vector *res*. int gr_bin(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) - int gr_bin_ui(gr_ptr res, gr_srcptr x, unsigned long y, gr_ctx_t ctx) - int gr_bin_uiui(gr_ptr res, unsigned long x, unsigned long y, gr_ctx_t ctx) - int gr_bin_vec(gr_ptr res, gr_srcptr x, long len, gr_ctx_t ctx) - int gr_bin_ui_vec(gr_ptr res, unsigned long x, long len, gr_ctx_t ctx) + int gr_bin_ui(gr_ptr res, gr_srcptr x, ulong y, gr_ctx_t ctx) + int gr_bin_uiui(gr_ptr res, ulong x, ulong y, gr_ctx_t ctx) + int gr_bin_vec(gr_ptr res, gr_srcptr x, slong len, gr_ctx_t ctx) + int gr_bin_ui_vec(gr_ptr res, ulong x, slong len, gr_ctx_t ctx) # Binomial coefficient `{x \choose y}`. The *vec* versions write the # first *len* consecutive values `{x \choose 0}, {x \choose 1}, \ldots, {x \choose len-1}` # to the preallocated vector *res*. @@ -112,9 +112,9 @@ cdef extern from "flint_wrap.h": # call :func:`gr_mat_pascal` than to call these functions repeatedly. int gr_rising(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) - int gr_rising_ui(gr_ptr res, gr_srcptr x, unsigned long y, gr_ctx_t ctx) + int gr_rising_ui(gr_ptr res, gr_srcptr x, ulong y, gr_ctx_t ctx) int gr_falling(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) - int gr_falling_ui(gr_ptr res, gr_srcptr x, unsigned long y, gr_ctx_t ctx) + int gr_falling_ui(gr_ptr res, gr_srcptr x, ulong y, gr_ctx_t ctx) # Rising and falling factorials `x (x+1) \cdots (x+y-1)` # and `x (x-1) \cdots (x-y+1)`, or their generalizations # to non-integer `y` via the gamma function. @@ -137,34 +137,34 @@ cdef extern from "flint_wrap.h": # Beta function `B(x,y)`. int gr_doublefac(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) - int gr_doublefac_ui(gr_ptr res, unsigned long x, gr_ctx_t ctx) + int gr_doublefac_ui(gr_ptr res, ulong x, gr_ctx_t ctx) # Double factorial `x!!`. int gr_harmonic(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) - int gr_harmonic_ui(gr_ptr res, unsigned long x, gr_ctx_t ctx) + int gr_harmonic_ui(gr_ptr res, ulong x, gr_ctx_t ctx) # Harmonic number `H_x`. - int gr_bernoulli_ui(gr_ptr res, unsigned long n, gr_ctx_t ctx) + int gr_bernoulli_ui(gr_ptr res, ulong n, gr_ctx_t ctx) int gr_bernoulli_fmpz(gr_ptr res, const fmpz_t n, gr_ctx_t ctx) - int gr_bernoulli_vec(gr_ptr res, long len, gr_ctx_t ctx) + int gr_bernoulli_vec(gr_ptr res, slong len, gr_ctx_t ctx) # Bernoulli numbers `B_n`. - int gr_eulernum_ui(gr_ptr res, unsigned long x, gr_ctx_t ctx) + int gr_eulernum_ui(gr_ptr res, ulong x, gr_ctx_t ctx) int gr_eulernum_fmpz(gr_ptr res, const fmpz_t x, gr_ctx_t ctx) - int gr_eulernum_vec(gr_ptr res, long len, gr_ctx_t ctx) + int gr_eulernum_vec(gr_ptr res, slong len, gr_ctx_t ctx) # Euler numbers `E_n`. - int gr_fib_ui(gr_ptr res, unsigned long n, gr_ctx_t ctx) + int gr_fib_ui(gr_ptr res, ulong n, gr_ctx_t ctx) int gr_fib_fmpz(gr_ptr res, const fmpz_t n, gr_ctx_t ctx) - int gr_fib_vec(gr_ptr res, long len, gr_ctx_t ctx) + int gr_fib_vec(gr_ptr res, slong len, gr_ctx_t ctx) # Fibonacci numbers `F_n`. - int gr_stirling_s1u_uiui(gr_ptr res, unsigned long x, unsigned long y, gr_ctx_t ctx) - int gr_stirling_s1_uiui(gr_ptr res, unsigned long x, unsigned long y, gr_ctx_t ctx) - int gr_stirling_s2_uiui(gr_ptr res, unsigned long x, unsigned long y, gr_ctx_t ctx) - int gr_stirling_s1u_ui_vec(gr_ptr res, unsigned long x, long len, gr_ctx_t ctx) - int gr_stirling_s1_ui_vec(gr_ptr res, unsigned long x, long len, gr_ctx_t ctx) - int gr_stirling_s2_ui_vec(gr_ptr res, unsigned long x, long len, gr_ctx_t ctx) + int gr_stirling_s1u_uiui(gr_ptr res, ulong x, ulong y, gr_ctx_t ctx) + int gr_stirling_s1_uiui(gr_ptr res, ulong x, ulong y, gr_ctx_t ctx) + int gr_stirling_s2_uiui(gr_ptr res, ulong x, ulong y, gr_ctx_t ctx) + int gr_stirling_s1u_ui_vec(gr_ptr res, ulong x, slong len, gr_ctx_t ctx) + int gr_stirling_s1_ui_vec(gr_ptr res, ulong x, slong len, gr_ctx_t ctx) + int gr_stirling_s2_ui_vec(gr_ptr res, ulong x, slong len, gr_ctx_t ctx) # Stirling numbers `S(x,y)`: unsigned of the first kind, # signed of the first kind, and second kind. The *vec* versions # write the *len* consecutive values `S(x,0), S(x,1), \ldots, S(x, len-1)` @@ -173,14 +173,14 @@ cdef extern from "flint_wrap.h": # it is more efficient to # call :func:`gr_mat_stirling` than to call these functions repeatedly. - int gr_bellnum_ui(gr_ptr res, unsigned long x, gr_ctx_t ctx) + int gr_bellnum_ui(gr_ptr res, ulong x, gr_ctx_t ctx) int gr_bellnum_fmpz(gr_ptr res, const fmpz_t x, gr_ctx_t ctx) - int gr_bellnum_vec(gr_ptr res, long len, gr_ctx_t ctx) + int gr_bellnum_vec(gr_ptr res, slong len, gr_ctx_t ctx) # Bell numbers `B_n`. - int gr_partitions_ui(gr_ptr res, unsigned long x, gr_ctx_t ctx) + int gr_partitions_ui(gr_ptr res, ulong x, gr_ctx_t ctx) int gr_partitions_fmpz(gr_ptr res, const fmpz_t x, gr_ctx_t ctx) - int gr_partitions_vec(gr_ptr res, long len, gr_ctx_t ctx) + int gr_partitions_vec(gr_ptr res, slong len, gr_ctx_t ctx) # Partition numbers `p(n)`. int gr_erf(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) @@ -218,8 +218,8 @@ cdef extern from "flint_wrap.h": int gr_hermite_h(gr_ptr res, gr_srcptr n, gr_srcptr z, gr_ctx_t ctx) int gr_legendre_p(gr_ptr res, gr_srcptr n, gr_srcptr m, gr_srcptr z, int type, gr_ctx_t ctx) int gr_legendre_q(gr_ptr res, gr_srcptr n, gr_srcptr m, gr_srcptr z, int type, gr_ctx_t ctx) - int gr_spherical_y_si(gr_ptr res, long n, long m, gr_srcptr theta, gr_srcptr phi, gr_ctx_t ctx) - int gr_legendre_p_root_ui(gr_ptr root, gr_ptr weight, unsigned long n, unsigned long k, gr_ctx_t ctx) + int gr_spherical_y_si(gr_ptr res, slong n, slong m, gr_srcptr theta, gr_srcptr phi, gr_ctx_t ctx) + int gr_legendre_p_root_ui(gr_ptr root, gr_ptr weight, ulong n, ulong k, gr_ctx_t ctx) int gr_bessel_j(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) int gr_bessel_y(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) @@ -253,7 +253,7 @@ cdef extern from "flint_wrap.h": int gr_hypgeom_pfq(gr_ptr res, const gr_vec_t a, const gr_vec_t b, gr_srcptr z, int flags, gr_ctx_t ctx) int gr_zeta(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) - int gr_zeta_ui(gr_ptr res, unsigned long x, gr_ctx_t ctx) + int gr_zeta_ui(gr_ptr res, ulong x, gr_ctx_t ctx) int gr_hurwitz_zeta(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) int gr_polygamma(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) int gr_polylog(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) @@ -263,11 +263,11 @@ cdef extern from "flint_wrap.h": int gr_dirichlet_eta(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) int gr_riemann_xi(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) int gr_zeta_zero(gr_ptr res, const fmpz_t n, gr_ctx_t ctx) - int gr_zeta_zero_vec(gr_ptr res, const fmpz_t n, long len, gr_ctx_t ctx) + int gr_zeta_zero_vec(gr_ptr res, const fmpz_t n, slong len, gr_ctx_t ctx) int gr_zeta_nzeros(gr_ptr res, gr_srcptr t, gr_ctx_t ctx) int gr_dirichlet_chi_fmpz(gr_ptr res, const dirichlet_group_t G, const dirichlet_char_t chi, const fmpz_t n, gr_ctx_t ctx) - int gr_dirichlet_chi_vec(gr_ptr res, const dirichlet_group_t G, const dirichlet_char_t chi, long len, gr_ctx_t ctx) + int gr_dirichlet_chi_vec(gr_ptr res, const dirichlet_group_t G, const dirichlet_char_t chi, slong len, gr_ctx_t ctx) int gr_dirichlet_l(gr_ptr res, const dirichlet_group_t G, const dirichlet_char_t chi, gr_srcptr s, gr_ctx_t ctx) int gr_dirichlet_l_all(gr_vec_t res, const dirichlet_group_t G, gr_srcptr s, gr_ctx_t ctx) int gr_dirichlet_hardy_theta(gr_ptr res, const dirichlet_group_t G, const dirichlet_char_t chi, gr_srcptr t, gr_ctx_t ctx) @@ -302,11 +302,11 @@ cdef extern from "flint_wrap.h": int gr_modular_lambda(gr_ptr res, gr_srcptr tau, gr_ctx_t ctx) int gr_modular_delta(gr_ptr res, gr_srcptr tau, gr_ctx_t ctx) - int gr_hilbert_class_poly(gr_ptr res, long D, gr_srcptr x, gr_ctx_t ctx) + int gr_hilbert_class_poly(gr_ptr res, slong D, gr_srcptr x, gr_ctx_t ctx) - int gr_eisenstein_e(gr_ptr res, unsigned long n, gr_srcptr tau, gr_ctx_t ctx) - int gr_eisenstein_g(gr_ptr res, unsigned long n, gr_srcptr tau, gr_ctx_t ctx) - int gr_eisenstein_g_vec(gr_ptr res, gr_srcptr tau, long len, gr_ctx_t ctx) + int gr_eisenstein_e(gr_ptr res, ulong n, gr_srcptr tau, gr_ctx_t ctx) + int gr_eisenstein_g(gr_ptr res, ulong n, gr_srcptr tau, gr_ctx_t ctx) + int gr_eisenstein_g_vec(gr_ptr res, gr_srcptr tau, slong len, gr_ctx_t ctx) int gr_elliptic_invariants(gr_ptr res1, gr_ptr res2, gr_srcptr tau, gr_ctx_t ctx) int gr_elliptic_roots(gr_ptr res1, gr_ptr res2, gr_ptr res3, gr_srcptr tau, gr_ctx_t ctx) diff --git a/src/sage/libs/flint/gr_vec.pxd b/src/sage/libs/flint/gr_vec.pxd index e9ec82b6a2d..3abe7600f21 100644 --- a/src/sage/libs/flint/gr_vec.pxd +++ b/src/sage/libs/flint/gr_vec.pxd @@ -12,7 +12,7 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void gr_vec_init(gr_vec_t vec, long len, gr_ctx_t ctx) + void gr_vec_init(gr_vec_t vec, slong len, gr_ctx_t ctx) # Initializes *vec* to a vector of length *len* with elements # in the ring *ctx*. The length must be nonnegative. # All entries are set to zero. @@ -20,18 +20,18 @@ cdef extern from "flint_wrap.h": void gr_vec_clear(gr_vec_t vec, gr_ctx_t ctx) # Clears the vector *vec*. - gr_ptr gr_vec_entry_ptr(gr_vec_t vec, long i, gr_ctx_t ctx) + gr_ptr gr_vec_entry_ptr(gr_vec_t vec, slong i, gr_ctx_t ctx) # Returns a pointer to the *i*-th element in the vector *vec*, # indexed from zero. The index must be in bounds. - long gr_vec_length(const gr_vec_t vec, gr_ctx_t ctx) + slong gr_vec_length(const gr_vec_t vec, gr_ctx_t ctx) # Returns the length of the vector *vec*. - void gr_vec_fit_length(gr_vec_t vec, long len, gr_ctx_t ctx) + void gr_vec_fit_length(gr_vec_t vec, slong len, gr_ctx_t ctx) # Allocates space for at least *len* elements in the vector *vec*. # This does not change the size of the vector. - void gr_vec_set_length(gr_vec_t vec, long len, gr_ctx_t ctx) + void gr_vec_set_length(gr_vec_t vec, slong len, gr_ctx_t ctx) # Resizes the vector to length *len*, which must be nonnegative. # The vector will be extended with zeros. @@ -41,136 +41,136 @@ cdef extern from "flint_wrap.h": int gr_vec_append(gr_vec_t vec, gr_srcptr x, gr_ctx_t ctx) # Appends the element *x* to the end of vector *vec*. - int _gr_vec_write(gr_stream_t out, gr_srcptr vec, long len, gr_ctx_t ctx) + int _gr_vec_write(gr_stream_t out, gr_srcptr vec, slong len, gr_ctx_t ctx) int gr_vec_write(gr_stream_t out, const gr_vec_t vec, gr_ctx_t ctx) int gr_vec_print(const gr_vec_t vec, gr_ctx_t ctx) - void _gr_vec_init(gr_ptr vec, long len, gr_ctx_t ctx) + void _gr_vec_init(gr_ptr vec, slong len, gr_ctx_t ctx) # Initialize *len* elements of *vec* to the value 0. # The pointer *vec* must already refer to allocated memory. - void _gr_vec_clear(gr_ptr vec, long len, gr_ctx_t ctx) + void _gr_vec_clear(gr_ptr vec, slong len, gr_ctx_t ctx) # Clears *len* elements of *vec*. # This frees memory allocated by individual elements, but # does not free the memory allocated by *vec* itself. - void _gr_vec_swap(gr_ptr vec1, gr_ptr vec2, long len, gr_ctx_t ctx) + void _gr_vec_swap(gr_ptr vec1, gr_ptr vec2, slong len, gr_ctx_t ctx) # Swap the entries of *vec1* and *vec2*. - int _gr_vec_randtest(gr_ptr res, flint_rand_t state, long len, gr_ctx_t ctx) + int _gr_vec_randtest(gr_ptr res, flint_rand_t state, slong len, gr_ctx_t ctx) - int _gr_vec_set(gr_ptr res, gr_srcptr src, long len, gr_ctx_t ctx) + int _gr_vec_set(gr_ptr res, gr_srcptr src, slong len, gr_ctx_t ctx) - truth_t _gr_vec_equal(gr_srcptr vec1, gr_srcptr vec2, long len, gr_ctx_t ctx) + truth_t _gr_vec_equal(gr_srcptr vec1, gr_srcptr vec2, slong len, gr_ctx_t ctx) - int _gr_vec_zero(gr_ptr vec, long len, gr_ctx_t ctx) + int _gr_vec_zero(gr_ptr vec, slong len, gr_ctx_t ctx) - truth_t _gr_vec_is_zero(gr_srcptr vec, long len, gr_ctx_t ctx) + truth_t _gr_vec_is_zero(gr_srcptr vec, slong len, gr_ctx_t ctx) - int _gr_vec_normalise(long * res, gr_srcptr vec, long len, gr_ctx_t ctx) + int _gr_vec_normalise(slong * res, gr_srcptr vec, slong len, gr_ctx_t ctx) - long _gr_vec_normalise_weak(gr_srcptr vec, long len, gr_ctx_t ctx) + slong _gr_vec_normalise_weak(gr_srcptr vec, slong len, gr_ctx_t ctx) - int _gr_vec_neg(gr_ptr res, gr_srcptr src, long len, gr_ctx_t ctx) + int _gr_vec_neg(gr_ptr res, gr_srcptr src, slong len, gr_ctx_t ctx) - int _gr_vec_add(gr_ptr res, gr_srcptr src1, gr_srcptr src2, long len, gr_ctx_t ctx) - int _gr_vec_sub(gr_ptr res, gr_srcptr src1, gr_srcptr src2, long len, gr_ctx_t ctx) - int _gr_vec_mul(gr_ptr res, gr_srcptr src1, gr_srcptr src2, long len, gr_ctx_t ctx) - int _gr_vec_div(gr_ptr res, gr_srcptr src1, gr_srcptr src2, long len, gr_ctx_t ctx) - int _gr_vec_divexact(gr_ptr res, gr_srcptr src1, gr_srcptr src2, long len, gr_ctx_t ctx) - int _gr_vec_pow(gr_ptr res, gr_srcptr src1, gr_srcptr src2, long len, gr_ctx_t ctx) + int _gr_vec_add(gr_ptr res, gr_srcptr src1, gr_srcptr src2, slong len, gr_ctx_t ctx) + int _gr_vec_sub(gr_ptr res, gr_srcptr src1, gr_srcptr src2, slong len, gr_ctx_t ctx) + int _gr_vec_mul(gr_ptr res, gr_srcptr src1, gr_srcptr src2, slong len, gr_ctx_t ctx) + int _gr_vec_div(gr_ptr res, gr_srcptr src1, gr_srcptr src2, slong len, gr_ctx_t ctx) + int _gr_vec_divexact(gr_ptr res, gr_srcptr src1, gr_srcptr src2, slong len, gr_ctx_t ctx) + int _gr_vec_pow(gr_ptr res, gr_srcptr src1, gr_srcptr src2, slong len, gr_ctx_t ctx) # Binary operations applied elementwise. - int _gr_vec_add_scalar(gr_ptr vec1, gr_srcptr vec2, long len, gr_srcptr c, gr_ctx_t ctx) - int _gr_vec_sub_scalar(gr_ptr vec1, gr_srcptr vec2, long len, gr_srcptr c, gr_ctx_t ctx) - int _gr_vec_mul_scalar(gr_ptr vec1, gr_srcptr vec2, long len, gr_srcptr c, gr_ctx_t ctx) - int _gr_vec_div_scalar(gr_ptr vec1, gr_srcptr vec2, long len, gr_srcptr c, gr_ctx_t ctx) - int _gr_vec_divexact_scalar(gr_ptr vec1, gr_srcptr vec2, long len, gr_srcptr c, gr_ctx_t ctx) - int _gr_vec_pow_scalar(gr_ptr vec1, gr_srcptr vec2, long len, gr_srcptr c, gr_ctx_t ctx) - int _gr_scalar_add_vec(gr_ptr vec1, gr_srcptr c, gr_srcptr vec2, long len, gr_ctx_t ctx) - int _gr_scalar_sub_vec(gr_ptr vec1, gr_srcptr c, gr_srcptr vec2, long len, gr_ctx_t ctx) - int _gr_scalar_mul_vec(gr_ptr vec1, gr_srcptr c, gr_srcptr vec2, long len, gr_ctx_t ctx) - int _gr_scalar_div_vec(gr_ptr vec1, gr_srcptr c, gr_srcptr vec2, long len, gr_ctx_t ctx) - int _gr_scalar_divexact_vec(gr_ptr vec1, gr_srcptr c, gr_srcptr vec2, long len, gr_ctx_t ctx) - int _gr_scalar_pow_vec(gr_ptr vec1, gr_srcptr c, gr_srcptr vec2, long len, gr_ctx_t ctx) + int _gr_vec_add_scalar(gr_ptr vec1, gr_srcptr vec2, slong len, gr_srcptr c, gr_ctx_t ctx) + int _gr_vec_sub_scalar(gr_ptr vec1, gr_srcptr vec2, slong len, gr_srcptr c, gr_ctx_t ctx) + int _gr_vec_mul_scalar(gr_ptr vec1, gr_srcptr vec2, slong len, gr_srcptr c, gr_ctx_t ctx) + int _gr_vec_div_scalar(gr_ptr vec1, gr_srcptr vec2, slong len, gr_srcptr c, gr_ctx_t ctx) + int _gr_vec_divexact_scalar(gr_ptr vec1, gr_srcptr vec2, slong len, gr_srcptr c, gr_ctx_t ctx) + int _gr_vec_pow_scalar(gr_ptr vec1, gr_srcptr vec2, slong len, gr_srcptr c, gr_ctx_t ctx) + int _gr_scalar_add_vec(gr_ptr vec1, gr_srcptr c, gr_srcptr vec2, slong len, gr_ctx_t ctx) + int _gr_scalar_sub_vec(gr_ptr vec1, gr_srcptr c, gr_srcptr vec2, slong len, gr_ctx_t ctx) + int _gr_scalar_mul_vec(gr_ptr vec1, gr_srcptr c, gr_srcptr vec2, slong len, gr_ctx_t ctx) + int _gr_scalar_div_vec(gr_ptr vec1, gr_srcptr c, gr_srcptr vec2, slong len, gr_ctx_t ctx) + int _gr_scalar_divexact_vec(gr_ptr vec1, gr_srcptr c, gr_srcptr vec2, slong len, gr_ctx_t ctx) + int _gr_scalar_pow_vec(gr_ptr vec1, gr_srcptr c, gr_srcptr vec2, slong len, gr_ctx_t ctx) # Binary operations applied elementwise with a fixed scalar operand. - int _gr_vec_add_other(gr_ptr vec1, gr_srcptr vec2, gr_srcptr vec3, gr_ctx_t ctx3, long len, gr_ctx_t ctx) - int _gr_vec_sub_other(gr_ptr vec1, gr_srcptr vec2, gr_srcptr vec3, gr_ctx_t ctx3, long len, gr_ctx_t ctx) - int _gr_vec_mul_other(gr_ptr vec1, gr_srcptr vec2, gr_srcptr vec3, gr_ctx_t ctx3, long len, gr_ctx_t ctx) - int _gr_vec_div_other(gr_ptr vec1, gr_srcptr vec2, gr_srcptr vec3, gr_ctx_t ctx3, long len, gr_ctx_t ctx) - int _gr_vec_divexact_other(gr_ptr vec1, gr_srcptr vec2, gr_srcptr vec3, gr_ctx_t ctx3, long len, gr_ctx_t ctx) - int _gr_vec_pow_other(gr_ptr vec1, gr_srcptr vec2, gr_srcptr vec3, gr_ctx_t ctx3, long len, gr_ctx_t ctx) - int _gr_other_add_vec(gr_ptr vec1, gr_srcptr vec2, gr_ctx_t ctx2, gr_srcptr vec3, long len, gr_ctx_t ctx) - int _gr_other_sub_vec(gr_ptr vec1, gr_srcptr vec2, gr_ctx_t ctx2, gr_srcptr vec3, long len, gr_ctx_t ctx) - int _gr_other_mul_vec(gr_ptr vec1, gr_srcptr vec2, gr_ctx_t ctx2, gr_srcptr vec3, long len, gr_ctx_t ctx) - int _gr_other_div_vec(gr_ptr vec1, gr_srcptr vec2, gr_ctx_t ctx2, gr_srcptr vec3, long len, gr_ctx_t ctx) - int _gr_other_divexact_vec(gr_ptr vec1, gr_srcptr vec2, gr_ctx_t ctx2, gr_srcptr vec3, long len, gr_ctx_t ctx) - int _gr_other_pow_vec(gr_ptr vec1, gr_srcptr vec2, gr_ctx_t ctx2, gr_srcptr vec3, long len, gr_ctx_t ctx) + int _gr_vec_add_other(gr_ptr vec1, gr_srcptr vec2, gr_srcptr vec3, gr_ctx_t ctx3, slong len, gr_ctx_t ctx) + int _gr_vec_sub_other(gr_ptr vec1, gr_srcptr vec2, gr_srcptr vec3, gr_ctx_t ctx3, slong len, gr_ctx_t ctx) + int _gr_vec_mul_other(gr_ptr vec1, gr_srcptr vec2, gr_srcptr vec3, gr_ctx_t ctx3, slong len, gr_ctx_t ctx) + int _gr_vec_div_other(gr_ptr vec1, gr_srcptr vec2, gr_srcptr vec3, gr_ctx_t ctx3, slong len, gr_ctx_t ctx) + int _gr_vec_divexact_other(gr_ptr vec1, gr_srcptr vec2, gr_srcptr vec3, gr_ctx_t ctx3, slong len, gr_ctx_t ctx) + int _gr_vec_pow_other(gr_ptr vec1, gr_srcptr vec2, gr_srcptr vec3, gr_ctx_t ctx3, slong len, gr_ctx_t ctx) + int _gr_other_add_vec(gr_ptr vec1, gr_srcptr vec2, gr_ctx_t ctx2, gr_srcptr vec3, slong len, gr_ctx_t ctx) + int _gr_other_sub_vec(gr_ptr vec1, gr_srcptr vec2, gr_ctx_t ctx2, gr_srcptr vec3, slong len, gr_ctx_t ctx) + int _gr_other_mul_vec(gr_ptr vec1, gr_srcptr vec2, gr_ctx_t ctx2, gr_srcptr vec3, slong len, gr_ctx_t ctx) + int _gr_other_div_vec(gr_ptr vec1, gr_srcptr vec2, gr_ctx_t ctx2, gr_srcptr vec3, slong len, gr_ctx_t ctx) + int _gr_other_divexact_vec(gr_ptr vec1, gr_srcptr vec2, gr_ctx_t ctx2, gr_srcptr vec3, slong len, gr_ctx_t ctx) + int _gr_other_pow_vec(gr_ptr vec1, gr_srcptr vec2, gr_ctx_t ctx2, gr_srcptr vec3, slong len, gr_ctx_t ctx) # Binary operations applied elementwise, allowing a different type for one of the vectors. - int _gr_vec_add_scalar_other(gr_ptr vec1, gr_srcptr vec2, long len, gr_srcptr c, gr_ctx_t cctx, gr_ctx_t ctx) - int _gr_vec_sub_scalar_other(gr_ptr vec1, gr_srcptr vec2, long len, gr_srcptr c, gr_ctx_t cctx, gr_ctx_t ctx) - int _gr_vec_mul_scalar_other(gr_ptr vec1, gr_srcptr vec2, long len, gr_srcptr c, gr_ctx_t cctx, gr_ctx_t ctx) - int _gr_vec_div_scalar_other(gr_ptr vec1, gr_srcptr vec2, long len, gr_srcptr c, gr_ctx_t cctx, gr_ctx_t ctx) - int _gr_vec_divexact_scalar_other(gr_ptr vec1, gr_srcptr vec2, long len, gr_srcptr c, gr_ctx_t cctx, gr_ctx_t ctx) - int _gr_vec_pow_scalar_other(gr_ptr vec1, gr_srcptr vec2, long len, gr_srcptr c, gr_ctx_t cctx, gr_ctx_t ctx) - int _gr_scalar_other_add_vec(gr_ptr vec1, gr_srcptr c, gr_ctx_t cctx, gr_srcptr vec2, long len, gr_ctx_t ctx) - int _gr_scalar_other_sub_vec(gr_ptr vec1, gr_srcptr c, gr_ctx_t cctx, gr_srcptr vec2, long len, gr_ctx_t ctx) - int _gr_scalar_other_mul_vec(gr_ptr vec1, gr_srcptr c, gr_ctx_t cctx, gr_srcptr vec2, long len, gr_ctx_t ctx) - int _gr_scalar_other_div_vec(gr_ptr vec1, gr_srcptr c, gr_ctx_t cctx, gr_srcptr vec2, long len, gr_ctx_t ctx) - int _gr_scalar_other_divexact_vec(gr_ptr vec1, gr_srcptr c, gr_ctx_t cctx, gr_srcptr vec2, long len, gr_ctx_t ctx) - int _gr_scalar_other_pow_vec(gr_ptr vec1, gr_srcptr c, gr_ctx_t cctx, gr_srcptr vec2, long len, gr_ctx_t ctx) - int _gr_vec_add_scalar_si(gr_ptr vec1, gr_srcptr vec2, long len, long c, gr_ctx_t ctx) - int _gr_vec_sub_scalar_si(gr_ptr vec1, gr_srcptr vec2, long len, long c, gr_ctx_t ctx) - int _gr_vec_mul_scalar_si(gr_ptr vec1, gr_srcptr vec2, long len, long c, gr_ctx_t ctx) - int _gr_vec_div_scalar_si(gr_ptr vec1, gr_srcptr vec2, long len, long c, gr_ctx_t ctx) - int _gr_vec_divexact_scalar_si(gr_ptr vec1, gr_srcptr vec2, long len, long c, gr_ctx_t ctx) - int _gr_vec_pow_scalar_si(gr_ptr vec1, gr_srcptr vec2, long len, long c, gr_ctx_t ctx) - int _gr_vec_add_scalar_ui(gr_ptr vec1, gr_srcptr vec2, long len, unsigned long c, gr_ctx_t ctx) - int _gr_vec_sub_scalar_ui(gr_ptr vec1, gr_srcptr vec2, long len, unsigned long c, gr_ctx_t ctx) - int _gr_vec_mul_scalar_ui(gr_ptr vec1, gr_srcptr vec2, long len, unsigned long c, gr_ctx_t ctx) - int _gr_vec_div_scalar_ui(gr_ptr vec1, gr_srcptr vec2, long len, unsigned long c, gr_ctx_t ctx) - int _gr_vec_divexact_scalar_ui(gr_ptr vec1, gr_srcptr vec2, long len, unsigned long c, gr_ctx_t ctx) - int _gr_vec_pow_scalar_ui(gr_ptr vec1, gr_srcptr vec2, long len, unsigned long c, gr_ctx_t ctx) - int _gr_vec_add_scalar_fmpz(gr_ptr vec1, gr_srcptr vec2, long len, const fmpz_t c, gr_ctx_t ctx) - int _gr_vec_sub_scalar_fmpz(gr_ptr vec1, gr_srcptr vec2, long len, const fmpz_t c, gr_ctx_t ctx) - int _gr_vec_mul_scalar_fmpz(gr_ptr vec1, gr_srcptr vec2, long len, const fmpz_t c, gr_ctx_t ctx) - int _gr_vec_div_scalar_fmpz(gr_ptr vec1, gr_srcptr vec2, long len, const fmpz_t c, gr_ctx_t ctx) - int _gr_vec_divexact_scalar_fmpz(gr_ptr vec1, gr_srcptr vec2, long len, const fmpz_t c, gr_ctx_t ctx) - int _gr_vec_pow_scalar_fmpz(gr_ptr vec1, gr_srcptr vec2, long len, const fmpz_t c, gr_ctx_t ctx) - int _gr_vec_add_scalar_fmpq(gr_ptr vec1, gr_srcptr vec2, long len, const fmpq_t c, gr_ctx_t ctx) - int _gr_vec_sub_scalar_fmpq(gr_ptr vec1, gr_srcptr vec2, long len, const fmpq_t c, gr_ctx_t ctx) - int _gr_vec_mul_scalar_fmpq(gr_ptr vec1, gr_srcptr vec2, long len, const fmpq_t c, gr_ctx_t ctx) - int _gr_vec_div_scalar_fmpq(gr_ptr vec1, gr_srcptr vec2, long len, const fmpq_t c, gr_ctx_t ctx) - int _gr_vec_divexact_scalar_fmpq(gr_ptr vec1, gr_srcptr vec2, long len, const fmpq_t c, gr_ctx_t ctx) - int _gr_vec_pow_scalar_fmpq(gr_ptr vec1, gr_srcptr vec2, long len, const fmpq_t c, gr_ctx_t ctx) + int _gr_vec_add_scalar_other(gr_ptr vec1, gr_srcptr vec2, slong len, gr_srcptr c, gr_ctx_t cctx, gr_ctx_t ctx) + int _gr_vec_sub_scalar_other(gr_ptr vec1, gr_srcptr vec2, slong len, gr_srcptr c, gr_ctx_t cctx, gr_ctx_t ctx) + int _gr_vec_mul_scalar_other(gr_ptr vec1, gr_srcptr vec2, slong len, gr_srcptr c, gr_ctx_t cctx, gr_ctx_t ctx) + int _gr_vec_div_scalar_other(gr_ptr vec1, gr_srcptr vec2, slong len, gr_srcptr c, gr_ctx_t cctx, gr_ctx_t ctx) + int _gr_vec_divexact_scalar_other(gr_ptr vec1, gr_srcptr vec2, slong len, gr_srcptr c, gr_ctx_t cctx, gr_ctx_t ctx) + int _gr_vec_pow_scalar_other(gr_ptr vec1, gr_srcptr vec2, slong len, gr_srcptr c, gr_ctx_t cctx, gr_ctx_t ctx) + int _gr_scalar_other_add_vec(gr_ptr vec1, gr_srcptr c, gr_ctx_t cctx, gr_srcptr vec2, slong len, gr_ctx_t ctx) + int _gr_scalar_other_sub_vec(gr_ptr vec1, gr_srcptr c, gr_ctx_t cctx, gr_srcptr vec2, slong len, gr_ctx_t ctx) + int _gr_scalar_other_mul_vec(gr_ptr vec1, gr_srcptr c, gr_ctx_t cctx, gr_srcptr vec2, slong len, gr_ctx_t ctx) + int _gr_scalar_other_div_vec(gr_ptr vec1, gr_srcptr c, gr_ctx_t cctx, gr_srcptr vec2, slong len, gr_ctx_t ctx) + int _gr_scalar_other_divexact_vec(gr_ptr vec1, gr_srcptr c, gr_ctx_t cctx, gr_srcptr vec2, slong len, gr_ctx_t ctx) + int _gr_scalar_other_pow_vec(gr_ptr vec1, gr_srcptr c, gr_ctx_t cctx, gr_srcptr vec2, slong len, gr_ctx_t ctx) + int _gr_vec_add_scalar_si(gr_ptr vec1, gr_srcptr vec2, slong len, slong c, gr_ctx_t ctx) + int _gr_vec_sub_scalar_si(gr_ptr vec1, gr_srcptr vec2, slong len, slong c, gr_ctx_t ctx) + int _gr_vec_mul_scalar_si(gr_ptr vec1, gr_srcptr vec2, slong len, slong c, gr_ctx_t ctx) + int _gr_vec_div_scalar_si(gr_ptr vec1, gr_srcptr vec2, slong len, slong c, gr_ctx_t ctx) + int _gr_vec_divexact_scalar_si(gr_ptr vec1, gr_srcptr vec2, slong len, slong c, gr_ctx_t ctx) + int _gr_vec_pow_scalar_si(gr_ptr vec1, gr_srcptr vec2, slong len, slong c, gr_ctx_t ctx) + int _gr_vec_add_scalar_ui(gr_ptr vec1, gr_srcptr vec2, slong len, ulong c, gr_ctx_t ctx) + int _gr_vec_sub_scalar_ui(gr_ptr vec1, gr_srcptr vec2, slong len, ulong c, gr_ctx_t ctx) + int _gr_vec_mul_scalar_ui(gr_ptr vec1, gr_srcptr vec2, slong len, ulong c, gr_ctx_t ctx) + int _gr_vec_div_scalar_ui(gr_ptr vec1, gr_srcptr vec2, slong len, ulong c, gr_ctx_t ctx) + int _gr_vec_divexact_scalar_ui(gr_ptr vec1, gr_srcptr vec2, slong len, ulong c, gr_ctx_t ctx) + int _gr_vec_pow_scalar_ui(gr_ptr vec1, gr_srcptr vec2, slong len, ulong c, gr_ctx_t ctx) + int _gr_vec_add_scalar_fmpz(gr_ptr vec1, gr_srcptr vec2, slong len, const fmpz_t c, gr_ctx_t ctx) + int _gr_vec_sub_scalar_fmpz(gr_ptr vec1, gr_srcptr vec2, slong len, const fmpz_t c, gr_ctx_t ctx) + int _gr_vec_mul_scalar_fmpz(gr_ptr vec1, gr_srcptr vec2, slong len, const fmpz_t c, gr_ctx_t ctx) + int _gr_vec_div_scalar_fmpz(gr_ptr vec1, gr_srcptr vec2, slong len, const fmpz_t c, gr_ctx_t ctx) + int _gr_vec_divexact_scalar_fmpz(gr_ptr vec1, gr_srcptr vec2, slong len, const fmpz_t c, gr_ctx_t ctx) + int _gr_vec_pow_scalar_fmpz(gr_ptr vec1, gr_srcptr vec2, slong len, const fmpz_t c, gr_ctx_t ctx) + int _gr_vec_add_scalar_fmpq(gr_ptr vec1, gr_srcptr vec2, slong len, const fmpq_t c, gr_ctx_t ctx) + int _gr_vec_sub_scalar_fmpq(gr_ptr vec1, gr_srcptr vec2, slong len, const fmpq_t c, gr_ctx_t ctx) + int _gr_vec_mul_scalar_fmpq(gr_ptr vec1, gr_srcptr vec2, slong len, const fmpq_t c, gr_ctx_t ctx) + int _gr_vec_div_scalar_fmpq(gr_ptr vec1, gr_srcptr vec2, slong len, const fmpq_t c, gr_ctx_t ctx) + int _gr_vec_divexact_scalar_fmpq(gr_ptr vec1, gr_srcptr vec2, slong len, const fmpq_t c, gr_ctx_t ctx) + int _gr_vec_pow_scalar_fmpq(gr_ptr vec1, gr_srcptr vec2, slong len, const fmpq_t c, gr_ctx_t ctx) # Binary operations applied elementwise with a fixed scalar operand, allowing a different type # for the scalar. - int _gr_vec_addmul_scalar(gr_ptr vec1, gr_srcptr vec2, long len, gr_srcptr c, gr_ctx_t ctx) - int _gr_vec_submul_scalar(gr_ptr vec1, gr_srcptr vec2, long len, gr_srcptr c, gr_ctx_t ctx) - int _gr_vec_addmul_scalar_si(gr_ptr vec1, gr_srcptr vec2, long len, long c, gr_ctx_t ctx) - int _gr_vec_submul_scalar_si(gr_ptr vec1, gr_srcptr vec2, long len, long c, gr_ctx_t ctx) + int _gr_vec_addmul_scalar(gr_ptr vec1, gr_srcptr vec2, slong len, gr_srcptr c, gr_ctx_t ctx) + int _gr_vec_submul_scalar(gr_ptr vec1, gr_srcptr vec2, slong len, gr_srcptr c, gr_ctx_t ctx) + int _gr_vec_addmul_scalar_si(gr_ptr vec1, gr_srcptr vec2, slong len, slong c, gr_ctx_t ctx) + int _gr_vec_submul_scalar_si(gr_ptr vec1, gr_srcptr vec2, slong len, slong c, gr_ctx_t ctx) - int _gr_vec_mul_scalar_2exp_si(gr_ptr res, gr_srcptr vec, long len, long c, gr_ctx_t ctx) + int _gr_vec_mul_scalar_2exp_si(gr_ptr res, gr_srcptr vec, slong len, slong c, gr_ctx_t ctx) - int _gr_vec_sum(gr_ptr res, gr_srcptr vec, long len, gr_ctx_t ctx) + int _gr_vec_sum(gr_ptr res, gr_srcptr vec, slong len, gr_ctx_t ctx) - int _gr_vec_product(gr_ptr res, gr_srcptr vec, long len, gr_ctx_t ctx) + int _gr_vec_product(gr_ptr res, gr_srcptr vec, slong len, gr_ctx_t ctx) - int _gr_vec_dot(gr_ptr res, gr_srcptr initial, int subtract, gr_srcptr vec1, gr_srcptr vec2, long len, gr_ctx_t ctx) - int _gr_vec_dot_si(gr_ptr res, gr_srcptr initial, int subtract, gr_srcptr vec1, const long * vec2, long len, gr_ctx_t ctx) - int _gr_vec_dot_ui(gr_ptr res, gr_srcptr initial, int subtract, gr_srcptr vec1, const unsigned long * vec2, long len, gr_ctx_t ctx) - int _gr_vec_dot_fmpz(gr_ptr res, gr_srcptr initial, int subtract, gr_srcptr vec1, const fmpz * vec2, long len, gr_ctx_t ctx) + int _gr_vec_dot(gr_ptr res, gr_srcptr initial, int subtract, gr_srcptr vec1, gr_srcptr vec2, slong len, gr_ctx_t ctx) + int _gr_vec_dot_si(gr_ptr res, gr_srcptr initial, int subtract, gr_srcptr vec1, const slong * vec2, slong len, gr_ctx_t ctx) + int _gr_vec_dot_ui(gr_ptr res, gr_srcptr initial, int subtract, gr_srcptr vec1, const ulong * vec2, slong len, gr_ctx_t ctx) + int _gr_vec_dot_fmpz(gr_ptr res, gr_srcptr initial, int subtract, gr_srcptr vec1, const fmpz * vec2, slong len, gr_ctx_t ctx) # Sets *res* to `c \pm \sum_{i=0}^{n-1} a_i b_i`. - int _gr_vec_dot_rev(gr_ptr res, gr_srcptr initial, int subtract, gr_srcptr vec1, gr_srcptr vec2, long len, gr_ctx_t ctx) + int _gr_vec_dot_rev(gr_ptr res, gr_srcptr initial, int subtract, gr_srcptr vec1, gr_srcptr vec2, slong len, gr_ctx_t ctx) # Sets *res* to `c \pm \sum_{i=0}^{n-1} a_i b_{n-1-i}`. - int _gr_vec_step(gr_ptr vec, gr_srcptr start, gr_srcptr step, long len, gr_ctx_t ctx) + int _gr_vec_step(gr_ptr vec, gr_srcptr start, gr_srcptr step, slong len, gr_ctx_t ctx) - int _gr_vec_reciprocals(gr_ptr res, long len, gr_ctx_t ctx) + int _gr_vec_reciprocals(gr_ptr res, slong len, gr_ctx_t ctx) # Sets *res* to the vector of reciprocals of the positive integers 1, 2, ... up to *len* inclusive. - int _gr_vec_set_powers(gr_ptr res, gr_srcptr x, long len, gr_ctx_t ctx) + int _gr_vec_set_powers(gr_ptr res, gr_srcptr x, slong len, gr_ctx_t ctx) diff --git a/src/sage/libs/flint/hypgeom.pxd b/src/sage/libs/flint/hypgeom.pxd new file mode 100644 index 00000000000..6d5cfe4113b --- /dev/null +++ b/src/sage/libs/flint/hypgeom.pxd @@ -0,0 +1,63 @@ +# distutils: libraries = flint +# distutils: depends = flint/hypgeom.h + +################################################################################ +# This file is auto-generated. Do not modify by hand +################################################################################ + +from libc.stdio cimport FILE +from sage.libs.gmp.types cimport * +from sage.libs.mpfr.types cimport * +from sage.libs.flint.types cimport * + +cdef extern from "flint_wrap.h": + + void hypgeom_init(hypgeom_t hyp) + + void hypgeom_clear(hypgeom_t hyp) + + slong hypgeom_estimate_terms(const mag_t z, int r, slong d) + # Computes an approximation of the largest `n` such + # that `|z|^n/(n!)^r = 2^{-d}`, giving a first-order estimate of the + # number of terms needed to approximate the sum of a hypergeometric + # series of weight `r \ge 0` and argument `z` to an absolute + # precision of `d \ge 0` bits. If `r = 0`, the direct solution of the + # equation is given by `n = (\log(1-z) - d \log 2) / \log z`. + # If `r > 0`, using `\log n! \approx n \log n - n` gives an equation + # that can be solved in terms of the Lambert *W*-function as + # `n = (d \log 2) / (r\,W\!(t))` where + # `t = (d \log 2) / (e r z^{1/r})`. + # The evaluation is done using double precision arithmetic. + # The function aborts if the computed value of `n` is greater + # than or equal to LONG_MAX / 2. + + slong hypgeom_bound(mag_t error, int r, slong C, slong D, slong K, const mag_t TK, const mag_t z, slong prec) + # Computes a truncation parameter sufficient to achieve *prec* bits + # of absolute accuracy, according to the strategy described above. + # The input consists of `r`, `C`, `D`, `K`, precomputed bound for `T(K)`, + # and `\tilde z = z (a_p / b_q)`, such that for `k > K`, the hypergeometric + # term ratio is bounded by + # .. math :: + # \frac{\tilde z}{k^r} \frac{k(k-D)}{(k-C)(k-2D)}. + # Given this information, we compute a `\varepsilon` and an + # integer `n` such that + # `\left| \sum_{k=n}^{\infty} T(k) \right| \le \varepsilon \le 2^{-\mathrm{prec}}`. + # The output variable *error* is set to the value of `\varepsilon`, + # and `n` is returned. + + void hypgeom_precompute(hypgeom_t hyp) + # Precomputes the bounds data `C`, `D`, `K` and an upper bound for `T(K)`. + + void arb_hypgeom_sum(arb_t P, arb_t Q, const hypgeom_t hyp, slong n, slong prec) + # Computes `P, Q` such that `P / Q = \sum_{k=0}^{n-1} T(k)` where `T(k)` + # is defined by *hyp*, + # using binary splitting and a working precision of *prec* bits. + + void arb_hypgeom_infsum(arb_t P, arb_t Q, hypgeom_t hyp, slong tol, slong prec) + # Computes `P, Q` such that `P / Q = \sum_{k=0}^{\infty} T(k)` where `T(k)` + # is defined by *hyp*, using binary splitting and + # working precision of *prec* bits. + # The number of terms is chosen automatically to bound the + # truncation error by at most `2^{-\mathrm{tol}}`. + # The bound for the truncation error is included in the output + # as part of *P*. diff --git a/src/sage/libs/flint/long_extras.pxd b/src/sage/libs/flint/long_extras.pxd new file mode 100644 index 00000000000..3efb8c50d2e --- /dev/null +++ b/src/sage/libs/flint/long_extras.pxd @@ -0,0 +1,39 @@ +# distutils: libraries = flint +# distutils: depends = flint/long_extras.h + +################################################################################ +# This file is auto-generated. Do not modify by hand +################################################################################ + +from libc.stdio cimport FILE +from sage.libs.gmp.types cimport * +from sage.libs.mpfr.types cimport * +from sage.libs.flint.types cimport * + +cdef extern from "flint_wrap.h": + + size_t z_sizeinbase(slong n, int b) + # Returns the number of digits in the base `b` representation + # of the absolute value of the integer `n`. + # Assumes that `b \geq 2`. + + int z_mul_checked(slong * a, slong b, slong c) + # Set `*a` to `b` times `c` and return `1` if the product overflowed. Otherwise, return `0`. + + mp_limb_signed_t z_randtest(flint_rand_t state) + # Returns a pseudo random number with a random number of bits, from + # `0` to ``FLINT_BITS``. The probability of the special values `0`, + # `\pm 1`, ``COEFF_MAX``, ``COEFF_MIN``, ``WORD_MAX`` and + # ``WORD_MIN`` is increased. + # This random function is mainly used for testing purposes. + + mp_limb_signed_t z_randtest_not_zero(flint_rand_t state) + # As for ``z_randtest(state)``, but does not return `0`. + + mp_limb_signed_t z_randint(flint_rand_t state, mp_limb_t limit) + # Returns a pseudo random number of absolute value less than + # ``limit``. If ``limit`` is zero or exceeds ``WORD_MAX``, + # it is interpreted as ``WORD_MAX``. + + int z_kronecker(slong a, slong n) + # Return the Kronecker symbol `\left(\frac{a}{n}\right)` for any `a` and any `n`. diff --git a/src/sage/libs/flint/mag.pxd b/src/sage/libs/flint/mag.pxd index e288fc1ad74..2063965d9e5 100644 --- a/src/sage/libs/flint/mag.pxd +++ b/src/sage/libs/flint/mag.pxd @@ -21,13 +21,13 @@ cdef extern from "flint_wrap.h": void mag_swap(mag_t x, mag_t y) # Swaps *x* and *y* efficiently. - mag_ptr _mag_vec_init(long n) + mag_ptr _mag_vec_init(slong n) # Allocates a vector of length *n*. All entries are set to zero. - void _mag_vec_clear(mag_ptr v, long n) + void _mag_vec_clear(mag_ptr v, slong n) # Clears a vector of length *n*. - long mag_allocated_bytes(const mag_t x) + slong mag_allocated_bytes(const mag_t x) # Returns the total number of bytes heap-allocated internally by this object. # The count excludes the size of the structure itself. Add # ``sizeof(mag_struct)`` to get the size of the object as a whole. @@ -62,7 +62,7 @@ cdef extern from "flint_wrap.h": void mag_set_d(mag_t res, double x) - void mag_set_ui(mag_t res, unsigned long x) + void mag_set_ui(mag_t res, ulong x) void mag_set_fmpz(mag_t res, const fmpz_t x) # Sets *res* to an upper bound for `|x|`. The operation may be inexact @@ -70,7 +70,7 @@ cdef extern from "flint_wrap.h": void mag_set_d_lower(mag_t res, double x) - void mag_set_ui_lower(mag_t res, unsigned long x) + void mag_set_ui_lower(mag_t res, ulong x) void mag_set_fmpz_lower(mag_t res, const fmpz_t x) # Sets *res* to a lower bound for `|x|`. @@ -80,7 +80,7 @@ cdef extern from "flint_wrap.h": void mag_set_fmpz_2exp_fmpz(mag_t res, const fmpz_t x, const fmpz_t y) - void mag_set_ui_2exp_si(mag_t res, unsigned long x, long y) + void mag_set_ui_2exp_si(mag_t res, ulong x, slong y) # Sets *res* to an upper bound for `|x| \cdot 2^y`. void mag_set_d_2exp_fmpz_lower(mag_t res, double x, const fmpz_t y) @@ -116,7 +116,7 @@ cdef extern from "flint_wrap.h": # Returns negative, zero, or positive, depending on whether *x* # is smaller, equal, or larger than *y*. - int mag_cmp_2exp_si(const mag_t x, long y) + int mag_cmp_2exp_si(const mag_t x, slong y) # Returns negative, zero, or positive, depending on whether *x* # is smaller, equal, or larger than `2^y`. @@ -152,26 +152,26 @@ cdef extern from "flint_wrap.h": # values with :func:`mag_dump_file` make sure to insert a whitespace to # separate consecutive values. - void mag_randtest(mag_t res, flint_rand_t state, long expbits) + void mag_randtest(mag_t res, flint_rand_t state, slong expbits) # Sets *res* to a random finite value, with an exponent up to *expbits* bits large. - void mag_randtest_special(mag_t res, flint_rand_t state, long expbits) + void mag_randtest_special(mag_t res, flint_rand_t state, slong expbits) # Like :func:`mag_randtest`, but also sometimes sets *res* to infinity. void mag_add(mag_t res, const mag_t x, const mag_t y) - void mag_add_ui(mag_t res, const mag_t x, unsigned long y) + void mag_add_ui(mag_t res, const mag_t x, ulong y) # Sets *res* to an upper bound for `x + y`. void mag_add_lower(mag_t res, const mag_t x, const mag_t y) - void mag_add_ui_lower(mag_t res, const mag_t x, unsigned long y) + void mag_add_ui_lower(mag_t res, const mag_t x, ulong y) # Sets *res* to a lower bound for `x + y`. void mag_add_2exp_fmpz(mag_t res, const mag_t x, const fmpz_t e) # Sets *res* to an upper bound for `x + 2^e`. - void mag_add_ui_2exp_si(mag_t res, const mag_t x, unsigned long y, long e) + void mag_add_ui_2exp_si(mag_t res, const mag_t x, ulong y, slong e) # Sets *res* to an upper bound for `x + y 2^e`. void mag_sub(mag_t res, const mag_t x, const mag_t y) @@ -180,21 +180,21 @@ cdef extern from "flint_wrap.h": void mag_sub_lower(mag_t res, const mag_t x, const mag_t y) # Sets *res* to a lower bound for `\max(x-y, 0)`. - void mag_mul_2exp_si(mag_t res, const mag_t x, long y) + void mag_mul_2exp_si(mag_t res, const mag_t x, slong y) void mag_mul_2exp_fmpz(mag_t res, const mag_t x, const fmpz_t y) # Sets *res* to `x \cdot 2^y`. This operation is exact. void mag_mul(mag_t res, const mag_t x, const mag_t y) - void mag_mul_ui(mag_t res, const mag_t x, unsigned long y) + void mag_mul_ui(mag_t res, const mag_t x, ulong y) void mag_mul_fmpz(mag_t res, const mag_t x, const fmpz_t y) # Sets *res* to an upper bound for `xy`. void mag_mul_lower(mag_t res, const mag_t x, const mag_t y) - void mag_mul_ui_lower(mag_t res, const mag_t x, unsigned long y) + void mag_mul_ui_lower(mag_t res, const mag_t x, ulong y) void mag_mul_fmpz_lower(mag_t res, const mag_t x, const fmpz_t y) # Sets *res* to a lower bound for `xy`. @@ -204,7 +204,7 @@ cdef extern from "flint_wrap.h": void mag_div(mag_t res, const mag_t x, const mag_t y) - void mag_div_ui(mag_t res, const mag_t x, unsigned long y) + void mag_div_ui(mag_t res, const mag_t x, ulong y) void mag_div_fmpz(mag_t res, const mag_t x, const fmpz_t y) # Sets *res* to an upper bound for `x / y`. @@ -233,18 +233,18 @@ cdef extern from "flint_wrap.h": void mag_fast_addmul(mag_t z, const mag_t x, const mag_t y) # Sets *z* to an upper bound for `z + xy`. - void mag_fast_add_2exp_si(mag_t res, const mag_t x, long e) + void mag_fast_add_2exp_si(mag_t res, const mag_t x, slong e) # Sets *res* to an upper bound for `x + 2^e`. - void mag_fast_mul_2exp_si(mag_t res, const mag_t x, long e) + void mag_fast_mul_2exp_si(mag_t res, const mag_t x, slong e) # Sets *res* to an upper bound for `x 2^e`. - void mag_pow_ui(mag_t res, const mag_t x, unsigned long e) + void mag_pow_ui(mag_t res, const mag_t x, ulong e) void mag_pow_fmpz(mag_t res, const mag_t x, const fmpz_t e) # Sets *res* to an upper bound for `x^e`. - void mag_pow_ui_lower(mag_t res, const mag_t x, unsigned long e) + void mag_pow_ui_lower(mag_t res, const mag_t x, ulong e) void mag_pow_fmpz_lower(mag_t res, const mag_t x, const fmpz_t e) # Sets *res* to a lower bound for `x^e`. @@ -264,7 +264,7 @@ cdef extern from "flint_wrap.h": void mag_hypot(mag_t res, const mag_t x, const mag_t y) # Sets *res* to an upper bound for `\sqrt{x^2 + y^2}`. - void mag_root(mag_t res, const mag_t x, unsigned long n) + void mag_root(mag_t res, const mag_t x, ulong n) # Sets *res* to an upper bound for `x^{1/n}`. void mag_log(mag_t res, const mag_t x) @@ -281,7 +281,7 @@ cdef extern from "flint_wrap.h": # Sets *res* to a lower bound for `-\log(\min(1,x))`, i.e. a lower # bound for `|\log(x)|` for `x \le 1`. - void mag_log_ui(mag_t res, unsigned long n) + void mag_log_ui(mag_t res, ulong n) # Sets *res* to an upper bound for `\log(n)`. void mag_log1p(mag_t res, const mag_t x) @@ -304,13 +304,13 @@ cdef extern from "flint_wrap.h": # Sets *res* to an upper bound for `\exp(x) - 1`. The bound is computed # accurately for small *x*. - void mag_exp_tail(mag_t res, const mag_t x, unsigned long N) + void mag_exp_tail(mag_t res, const mag_t x, ulong N) # Sets *res* to an upper bound for `\sum_{k=N}^{\infty} x^k / k!`. - void mag_binpow_uiui(mag_t res, unsigned long m, unsigned long n) + void mag_binpow_uiui(mag_t res, ulong m, ulong n) # Sets *res* to an upper bound for `(1 + 1/m)^n`. - void mag_geom_series(mag_t res, const mag_t x, unsigned long N) + void mag_geom_series(mag_t res, const mag_t x, ulong N) # Sets *res* to an upper bound for `\sum_{k=N}^{\infty} x^k`. void mag_const_pi(mag_t res) @@ -332,20 +332,20 @@ cdef extern from "flint_wrap.h": void mag_sinh_lower(mag_t res, const mag_t x) # Sets *res* to an upper or lower bound for `\cosh(x)` or `\sinh(x)`. - void mag_fac_ui(mag_t res, unsigned long n) + void mag_fac_ui(mag_t res, ulong n) # Sets *res* to an upper bound for `n!`. - void mag_rfac_ui(mag_t res, unsigned long n) + void mag_rfac_ui(mag_t res, ulong n) # Sets *res* to an upper bound for `1/n!`. - void mag_bin_uiui(mag_t res, unsigned long n, unsigned long k) + void mag_bin_uiui(mag_t res, ulong n, ulong k) # Sets *res* to an upper bound for the binomial coefficient `{n \choose k}`. - void mag_bernoulli_div_fac_ui(mag_t res, unsigned long n) + void mag_bernoulli_div_fac_ui(mag_t res, ulong n) # Sets *res* to an upper bound for `|B_n| / n!` where `B_n` denotes # a Bernoulli number. - void mag_polylog_tail(mag_t res, const mag_t z, long s, unsigned long d, unsigned long N) + void mag_polylog_tail(mag_t res, const mag_t z, slong s, ulong d, ulong N) # Sets *res* to an upper bound for # .. math :: # \sum_{k=N}^{\infty} \frac{z^k \log^d(k)}{k^s}. @@ -354,7 +354,7 @@ cdef extern from "flint_wrap.h": # real or complex, the user can simply # substitute any convenient integer `s'` such that `s' \le \operatorname{Re}(s)`. - void mag_hurwitz_zeta_uiui(mag_t res, unsigned long s, unsigned long a) + void mag_hurwitz_zeta_uiui(mag_t res, ulong s, ulong a) # Sets *res* to an upper bound for `\zeta(s,a) = \sum_{k=0}^{\infty} (k+a)^{-s}`. # We use the formula # .. math :: diff --git a/src/sage/libs/flint/mpf_mat.pxd b/src/sage/libs/flint/mpf_mat.pxd new file mode 100644 index 00000000000..ee97e2b022f --- /dev/null +++ b/src/sage/libs/flint/mpf_mat.pxd @@ -0,0 +1,100 @@ +# distutils: libraries = flint +# distutils: depends = flint/mpf_mat.h + +################################################################################ +# This file is auto-generated. Do not modify by hand +################################################################################ + +from libc.stdio cimport FILE +from sage.libs.gmp.types cimport * +from sage.libs.mpfr.types cimport * +from sage.libs.flint.types cimport * + +cdef extern from "flint_wrap.h": + + void mpf_mat_init(mpf_mat_t mat, slong rows, slong cols, flint_bitcnt_t prec) + # Initialises a matrix with the given number of rows and columns and the + # given precision for use. The precision is at least the precision of the + # entries. + + void mpf_mat_clear(mpf_mat_t mat) + # Clears the given matrix. + + void mpf_mat_set(mpf_mat_t mat1, const mpf_mat_t mat2) + # Sets ``mat1`` to a copy of ``mat2``. The dimensions of + # ``mat1`` and ``mat2`` must be the same. + + void mpf_mat_swap(mpf_mat_t mat1, mpf_mat_t mat2) + # Swaps two matrices. The dimensions of ``mat1`` and ``mat2`` + # are allowed to be different. + + void mpf_mat_swap_entrywise(mpf_mat_t mat1, mpf_mat_t mat2) + # Swaps two matrices by swapping the individual entries rather than swapping + # the contents of the structs. + + mpf * mpf_mat_entry(const mpf_mat_t mat, slong i, slong j) + # Returns a reference to the entry of ``mat`` at row `i` and column `j`. + # Both `i` and `j` must not exceed the dimensions of the matrix. + # The return value can be used to either retrieve or set the given entry. + + void mpf_mat_zero(mpf_mat_t mat) + # Sets all entries of ``mat`` to 0. + + void mpf_mat_one(mpf_mat_t mat) + # Sets ``mat`` to the unit matrix, having ones on the main diagonal + # and zeroes elsewhere. If ``mat`` is nonsquare, it is set to the + # truncation of a unit matrix. + + void mpf_mat_set_fmpz_mat(mpf_mat_t B, const fmpz_mat_t A) + # Sets the entries of ``B`` as mpfs corresponding to the entries of + # ``A``. + + void mpf_mat_randtest(mpf_mat_t mat, flint_rand_t state, flint_bitcnt_t bits) + # Sets the entries of ``mat`` to random numbers in the + # interval `[0, 1)` with ``bits`` significant bits in the mantissa or less if + # their precision is smaller. + + void mpf_mat_print(const mpf_mat_t mat) + # Prints the given matrix to the stream ``stdout``. + + int mpf_mat_equal(const mpf_mat_t mat1, const mpf_mat_t mat2) + # Returns a non-zero value if ``mat1`` and ``mat2`` have + # the same dimensions and entries, and zero otherwise. + + int mpf_mat_approx_equal(const mpf_mat_t mat1, const mpf_mat_t mat2, flint_bitcnt_t bits) + # Returns a non-zero value if ``mat1`` and ``mat2`` have + # the same dimensions and the first ``bits`` bits of their entries + # are equal, and zero otherwise. + + int mpf_mat_is_zero(const mpf_mat_t mat) + # Returns a non-zero value if all entries ``mat`` are zero, and + # otherwise returns zero. + + int mpf_mat_is_empty(const mpf_mat_t mat) + # Returns a non-zero value if the number of rows or the number of + # columns in ``mat`` is zero, and otherwise returns + # zero. + + int mpf_mat_is_square(const mpf_mat_t mat) + # Returns a non-zero value if the number of rows is equal to the + # number of columns in ``mat``, and otherwise returns zero. + + void mpf_mat_mul(mpf_mat_t C, const mpf_mat_t A, const mpf_mat_t B) + # Sets ``C`` to the matrix product `C = A B`. The matrices must have + # compatible dimensions for matrix multiplication (an exception is raised + # otherwise). Aliasing is allowed. + + void mpf_mat_gso(mpf_mat_t B, const mpf_mat_t A) + # Takes a subset of `R^m` `S = {a_1, a_2, \ldots ,a_n}` (as the columns of + # a `m \times n` matrix ``A``) and generates an orthonormal set + # `S' = {b_1, b_2, \ldots ,b_n}` (as the columns of the `m \times n` matrix + # ``B``) that spans the same subspace of `R^m` as `S`. + # This uses an algorithm of Schwarz-Rutishauser. See pp. 9 of + # https://people.inf.ethz.ch/gander/papers/qrneu.pdf + + void mpf_mat_qr(mpf_mat_t Q, mpf_mat_t R, const mpf_mat_t A) + # Computes the `QR` decomposition of a matrix ``A`` using the Gram-Schmidt + # process. (Sets ``Q`` and ``R`` such that `A = QR` where ``R`` is + # an upper triangular matrix and ``Q`` is an orthogonal matrix.) + # This uses an algorithm of Schwarz-Rutishauser. See pp. 9 of + # https://people.inf.ethz.ch/gander/papers/qrneu.pdf diff --git a/src/sage/libs/flint/mpf_vec.pxd b/src/sage/libs/flint/mpf_vec.pxd new file mode 100644 index 00000000000..0be034230ad --- /dev/null +++ b/src/sage/libs/flint/mpf_vec.pxd @@ -0,0 +1,80 @@ +# distutils: libraries = flint +# distutils: depends = flint/mpf_vec.h + +################################################################################ +# This file is auto-generated. Do not modify by hand +################################################################################ + +from libc.stdio cimport FILE +from sage.libs.gmp.types cimport * +from sage.libs.mpfr.types cimport * +from sage.libs.flint.types cimport * + +cdef extern from "flint_wrap.h": + + mpf * _mpf_vec_init(slong len, mp_limb_t prec) + # Returns a vector of the given length of initialised ``mpf``'s + # with at least the given precision. + + void _mpf_vec_clear(mpf * vec, slong len) + # Clears the given vector. + + void _mpf_vec_randtest(mpf * f, flint_rand_t state, slong len, flint_bitcnt_t bits) + # Sets the entries of a vector of the given length to random numbers in the + # interval `[0, 1)` with ``bits`` significant bits in the mantissa or less if + # their precision is smaller. + + void _mpf_vec_zero(mpf * vec, slong len) + # Zeros the vector ``(vec, len)``. + + void _mpf_vec_set(mpf * vec1, const mpf * vec2, slong len2) + # Copies the vector ``vec2`` of the given length into ``vec1``. + # A check is made to ensure ``vec1`` and ``vec2`` are different. + + void _mpf_vec_set_fmpz_vec(mpf * appv, const fmpz * vec, slong len) + # Export the array of ``len`` entries starting at the pointer ``vec`` + # to an array of mpfs ``appv``. + + int _mpf_vec_equal(const mpf * vec1, const mpf * vec2, slong len) + # Compares two vectors of the given length and returns `1` if they are + # equal, otherwise returns `0`. + + int _mpf_vec_is_zero(const mpf * vec, slong len) + # Returns `1` if ``(vec, len)`` is zero, and `0` otherwise. + + int _mpf_vec_approx_equal(const mpf * vec1, const mpf * vec2, slong len, flint_bitcnt_t bits) + # Compares two vectors of the given length and returns `1` if the first + # ``bits`` bits of their entries are equal, otherwise returns `0`. + + void _mpf_vec_add(mpf * res, const mpf * vec1, const mpf * vec2, slong len2) + # Adds the given vectors of the given length together and stores the + # result in ``res``. + + void _mpf_vec_sub(mpf * res, const mpf * vec1, const mpf * vec2, slong len2) + # Sets ``(res, len2)`` to ``(vec1, len2)`` minus ``(vec2, len2)``. + + void _mpf_vec_scalar_mul_mpf(mpf * res, const mpf * vec, slong len, mpf_t c) + # Multiplies the vector with given length by the scalar `c` and + # sets ``res`` to the result. + + void _mpf_vec_scalar_mul_2exp(mpf * res, const mpf * vec, slong len, flint_bitcnt_t exp) + # Multiplies the given vector of the given length by ``2^exp``. + + void _mpf_vec_dot(mpf_t res, const mpf * vec1, const mpf * vec2, slong len2) + # Sets ``res`` to the dot product of ``(vec1, len2)`` with + # ``(vec2, len2)``. + + void _mpf_vec_norm(mpf_t res, const mpf * vec, slong len) + # Sets ``res`` to the square of the Euclidean norm of + # ``(vec, len)``. + + int _mpf_vec_dot2(mpf_t res, const mpf * vec1, const mpf * vec2, slong len2, flint_bitcnt_t prec) + # Sets ``res`` to the dot product of ``(vec1, len2)`` with + # ``(vec2, len2)``. The temporary variable used has its precision + # set to be at least ``prec`` bits. Returns 0 if a probable + # cancellation is detected, and otherwise returns a non-zero value. + + void _mpf_vec_norm2(mpf_t res, const mpf * vec, slong len, flint_bitcnt_t prec) + # Sets ``res`` to the square of the Euclidean norm of + # ``(vec, len)``. The temporary variable used has its precision + # set to be at least ``prec`` bits. diff --git a/src/sage/libs/flint/mpfr_mat.pxd b/src/sage/libs/flint/mpfr_mat.pxd new file mode 100644 index 00000000000..b673775b899 --- /dev/null +++ b/src/sage/libs/flint/mpfr_mat.pxd @@ -0,0 +1,50 @@ +# distutils: libraries = flint +# distutils: depends = flint/mpfr_mat.h + +################################################################################ +# This file is auto-generated. Do not modify by hand +################################################################################ + +from libc.stdio cimport FILE +from sage.libs.gmp.types cimport * +from sage.libs.mpfr.types cimport * +from sage.libs.flint.types cimport * + +cdef extern from "flint_wrap.h": + + void mpfr_mat_init(mpfr_mat_t mat, slong rows, slong cols, mpfr_prec_t prec) + # Initialises a matrix with the given number of rows and columns and the + # given precision for use. The precision is the exact precision of the + # entries. + + void mpfr_mat_clear(mpfr_mat_t mat) + # Clears the given matrix. + + __mpfr_struct * mpfr_mat_entry(const mpfr_mat_t mat, slong i, slong j) + # Return a reference to the entry at row `i` and column `j` of the given + # matrix. The values `i` and `j` must be within the bounds for the matrix. + # The reference can be used to either return or set the given entry. + + void mpfr_mat_swap(mpfr_mat_t mat1, mpfr_mat_t mat2) + # Efficiently swap matrices ``mat1`` and ``mat2``. + + void mpfr_mat_swap_entrywise(mpfr_mat_t mat1, mpfr_mat_t mat2) + # Swaps two matrices by swapping the individual entries rather than swapping + # the contents of the structs. + + void mpfr_mat_set(mpfr_mat_t mat1, const mpfr_mat_t mat2) + # Set ``mat1`` to the value of ``mat2``. + + void mpfr_mat_zero(mpfr_mat_t mat) + # Set ``mat`` to the zero matrix. + + int mpfr_mat_equal(const mpfr_mat_t mat1, const mpfr_mat_t mat2) + # Return `1` if the two given matrices are equal, otherwise return `0`. + + void mpfr_mat_randtest(mpfr_mat_t mat, flint_rand_t state) + # Generate a random matrix with random number of rows and columns and random + # entries for use in test code. + + void mpfr_mat_mul_classical(mpfr_mat_t C, const mpfr_mat_t A, const mpfr_mat_t B, mpfr_rnd_t rnd) + # Set `C` to the product of `A` and `B` with the given rounding mode, using + # the classical algorithm. diff --git a/src/sage/libs/flint/mpfr_vec.pxd b/src/sage/libs/flint/mpfr_vec.pxd new file mode 100644 index 00000000000..bd6811b547f --- /dev/null +++ b/src/sage/libs/flint/mpfr_vec.pxd @@ -0,0 +1,40 @@ +# distutils: libraries = flint +# distutils: depends = flint/mpfr_vec.h + +################################################################################ +# This file is auto-generated. Do not modify by hand +################################################################################ + +from libc.stdio cimport FILE +from sage.libs.gmp.types cimport * +from sage.libs.mpfr.types cimport * +from sage.libs.flint.types cimport * + +cdef extern from "flint_wrap.h": + + mpfr_ptr _mpfr_vec_init(slong len, flint_bitcnt_t prec) + # Returns a vector of the given length of initialised ``mpfr``'s + # with the given exact precision. + + void _mpfr_vec_clear(mpfr_ptr vec, slong len) + # Clears the given vector. + + void _mpfr_vec_zero(mpfr_ptr vec, slong len) + # Zeros the vector ``(vec, len)``. + + void _mpfr_vec_set(mpfr_ptr vec1, mpfr_srcptr vec2, slong len) + # Copies the vector ``vec2`` of the given length into ``vec1``. + # No check is made to ensure ``vec1`` and ``vec2`` are different. + + void _mpfr_vec_add(mpfr_ptr res, mpfr_srcptr vec1, mpfr_srcptr vec2, slong len) + # Adds the given vectors of the given length together and stores the + # result in ``res``. + + void _mpfr_vec_scalar_mul_mpfr(mpfr_ptr res, mpfr_srcptr vec, slong len, mpfr_t c) + # Multiplies the vector with given length by the scalar `c` and + # sets ``res`` to the result. + + void _mpfr_vec_scalar_mul_2exp(mpfr_ptr res, mpfr_srcptr vec, slong len, flint_bitcnt_t exp) + # Multiplies the given vector of the given length by ``2^exp``. + + void _mpfr_vec_scalar_product(mpfr_t res, mpfr_srcptr vec1, mpfr_srcptr vec2, slong len) diff --git a/src/sage/libs/flint/mpn_extras.pxd b/src/sage/libs/flint/mpn_extras.pxd new file mode 100644 index 00000000000..5f5b3bbf99d --- /dev/null +++ b/src/sage/libs/flint/mpn_extras.pxd @@ -0,0 +1,182 @@ +# distutils: libraries = flint +# distutils: depends = flint/mpn_extras.h + +################################################################################ +# This file is auto-generated. Do not modify by hand +################################################################################ + +from libc.stdio cimport FILE +from sage.libs.gmp.types cimport * +from sage.libs.mpfr.types cimport * +from sage.libs.flint.types cimport * + +cdef extern from "flint_wrap.h": + + void flint_mpn_debug(mp_srcptr x, mp_size_t xsize) + # Prints debug information about ``(x, xsize)`` to ``stdout``. + # In particular, this will print binary representations of all the limbs. + + int flint_mpn_zero_p(mp_srcptr x, mp_size_t xsize) + # Returns `1` if all limbs of ``(x, xsize)`` are zero, otherwise `0`. + + mp_limb_t flint_mpn_mul(mp_ptr z, mp_srcptr x, mp_size_t xn, mp_srcptr y, mp_size_t yn) + # Sets ``(z, xn+yn)`` to the product of ``(x, xn)`` and ``(y, yn)`` + # and returns the top limb of the result. + # We require `xn \ge yn \ge 1` + # and that ``z`` is not aliased with either input operand. + # This function uses FFT multiplication if the operands are large enough + # and otherwise calls ``mpn_mul``. + + void flint_mpn_mul_n(mp_ptr z, mp_srcptr x, mp_srcptr y, mp_size_t n) + # Sets ``z`` to the product of ``(x, n)`` and ``(y, n)``. + # We require `n \ge 1` + # and that ``z`` is not aliased with either input operand. + # This function uses FFT multiplication if the operands are large enough + # and otherwise calls ``mpn_mul_n``. + + void flint_mpn_sqr(mp_ptr z, mp_srcptr x, mp_size_t n) + # Sets ``z`` to the square of ``(x, n)``. + # We require `n \ge 1` + # and that ``z`` is not aliased with either input operand. + # This function uses FFT multiplication if the operands are large enough + # and otherwise calls ``mpn_sqr``. + + mp_size_t flint_mpn_fmms1(mp_ptr y, mp_limb_t a1, mp_srcptr x1, mp_limb_t a2, mp_srcptr x2, mp_size_t n) + # Given not-necessarily-normalized `x_1` and `x_2` of length `n > 0` and output `y` of length `n`, try to compute `y = a_1\cdot x_1 - a_2\cdot x_2`. + # Return the normalized length of `y` if `y \ge 0` and `y` fits into `n` limbs. Otherwise, return `-1`. + # `y` may alias `x_1` but is not allowed to alias `x_2`. + + int flint_mpn_divisible_1_odd(mp_srcptr x, mp_size_t xsize, mp_limb_t d) + # Expression determining whether ``(x, xsize)`` is divisible by the + # ``mp_limb_t d`` which is assumed to be odd-valued and at least `3`. + # This function is implemented as a macro. + + mp_size_t flint_mpn_divexact_1(mp_ptr x, mp_size_t xsize, mp_limb_t d) + # Divides `x` once by a known single-limb divisor, returns the new size. + + mp_size_t flint_mpn_remove_2exp(mp_ptr x, mp_size_t xsize, flint_bitcnt_t *bits) + # Divides ``(x, xsize)`` by `2^n` where `n` is the number of trailing + # zero bits in `x`. The new size of `x` is returned, and `n` is stored in + # the bits argument. `x` may not be zero. + + mp_size_t flint_mpn_remove_power_ascending(mp_ptr x, mp_size_t xsize, mp_ptr p, mp_size_t psize, ulong *exp) + # Divides ``(x, xsize)`` by the largest power `n` of ``(p, psize)`` + # that is an exact divisor of `x`. The new size of `x` is returned, and + # `n` is stored in the ``exp`` argument. `x` may not be zero, and `p` + # must be greater than `2`. + # This function works by testing divisibility by ascending squares + # `p, p^2, p^4, p^8, \dotsc`, making it efficient for removing potentially + # large powers. Because of its high overhead, it should not be used as + # the first stage of trial division. + + int flint_mpn_factor_trial(mp_srcptr x, mp_size_t xsize, slong start, slong stop) + # Searches for a factor of ``(x, xsize)`` among the primes in positions + # ``start, ..., stop-1`` of ``flint_primes``. Returns `i` if + # ``flint_primes[i]`` is a factor, otherwise returns `0` if no factor + # is found. It is assumed that ``start >= 1``. + + int flint_mpn_factor_trial_tree(slong * factors, mp_srcptr x, mp_size_t xsize, slong num_primes) + # Searches for a factor of ``(x, xsize)`` among the primes in positions + # approximately in the range ``0, ..., num_primes - 1`` of ``flint_primes``. + # Returns the number of prime factors found and fills ``factors`` with their + # indices in ``flint_primes``. It is assumed that ``num_primes`` is in the + # range ``0, ..., 3512``. + # If the input fits in a small ``fmpz`` the number is fully factored instead. + # The algorithm used is a tree based gcd with a product of primes, the tree + # for which is cached globally (it is threadsafe). + + int flint_mpn_divides(mp_ptr q, mp_srcptr array1, mp_size_t limbs1, mp_srcptr arrayg, mp_size_t limbsg, mp_ptr temp) + # If ``(arrayg, limbsg)`` divides ``(array1, limbs1)`` then + # ``(q, limbs1 - limbsg + 1)`` is set to the quotient and 1 is + # returned, otherwise 0 is returned. The temporary space ``temp`` + # must have space for ``limbsg`` limbs. + # Assumes ``limbs1 >= limbsg > 0``. + + mp_limb_t flint_mpn_preinv1(mp_limb_t d, mp_limb_t d2) + # Computes a precomputed inverse from the leading two limbs of the + # divisor ``b, n`` to be used with the ``preinv1`` functions. + # We require the most significant bit of ``b, n`` to be 1. + + mp_limb_t flint_mpn_divrem_preinv1(mp_ptr q, mp_ptr a, mp_size_t m, mp_srcptr b, mp_size_t n, mp_limb_t dinv) + # Divide ``a, m`` by ``b, n``, returning the high limb of the + # quotient (which will either be 0 or 1), storing the remainder in-place + # in ``a, n`` and the rest of the quotient in ``q, m - n``. + # We require the most significant bit of ``b, n`` to be 1. + # ``dinv`` must be computed from ``b[n - 1]``, ``b[n - 2]`` by + # ``flint_mpn_preinv1``. We also require ``m >= n >= 2``. + + void flint_mpn_mulmod_preinv1(mp_ptr r, mp_srcptr a, mp_srcptr b, mp_size_t n, mp_srcptr d, mp_limb_t dinv, ulong norm) + # Given a normalised integer `d` with precomputed inverse ``dinv`` + # provided by ``flint_mpn_preinv1``, computes `ab \pmod{d}` and + # stores the result in `r`. Each of `a`, `b` and `r` is expected to + # have `n` limbs of space, with zero padding if necessary. + # The value ``norm`` is provided for convenience. If `a`, `b` and + # `d` have been shifted left by ``norm`` bits so that `d` is + # normalised, then `r` will be shifted right by ``norm`` bits + # so that it has the same shift as all the inputs. + # We require `a` and `b` to be reduced modulo `n` before calling the + # function. + + void flint_mpn_preinvn(mp_ptr dinv, mp_srcptr d, mp_size_t n) + # Compute an `n` limb precomputed inverse ``dinv`` of the `n` limb + # integer `d`. + # We require that `d` is normalised, i.e. with the most significant + # bit of the most significant limb set. + + void flint_mpn_mod_preinvn(mp_ptr r, mp_srcptr a, mp_size_t m, mp_srcptr d, mp_size_t n, mp_srcptr dinv) + # Given a normalised integer `d` of `n` limbs, with precomputed inverse + # ``dinv`` provided by ``flint_mpn_preinvn`` and integer `a` of `m` + # limbs, computes `a \pmod{d}` and stores the result in-place in the lower + # `n` limbs of `a`. The remaining limbs of `a` are destroyed. + # We require `m \geq n`. No aliasing of `a` with any of the other operands + # is permitted. + # Note that this function is not always as fast as ordinary division. + + mp_limb_t flint_mpn_divrem_preinvn(mp_ptr q, mp_ptr r, mp_srcptr a, mp_size_t m, mp_srcptr d, mp_size_t n, mp_srcptr dinv) + # Given a normalised integer `d` with precomputed inverse ``dinv`` + # provided by ``flint_mpn_preinvn``, computes the quotient of `a` by `d` + # and stores the result in `q` and the remainder in the lower `n` limbs of + # `a`. The remaining limbs of `a` are destroyed. + # The value `q` is expected to have space for `m - n` limbs and we require + # `m \ge n`. No aliasing is permitted between `q` and `a` or between these + # and any of the other operands. + # Note that this function is not always as fast as ordinary division. + + void flint_mpn_mulmod_preinvn(mp_ptr r, mp_srcptr a, mp_srcptr b, mp_size_t n, mp_srcptr d, mp_srcptr dinv, ulong norm) + # Given a normalised integer `d` with precomputed inverse ``dinv`` + # provided by ``flint_mpn_preinvn``, computes `ab \pmod{d}` and + # stores the result in `r`. Each of `a`, `b` and `r` is expected to + # have `n` limbs of space, with zero padding if necessary. + # The value ``norm`` is provided for convenience. If `a`, `b` and + # `d` have been shifted left by ``norm`` bits so that `d` is + # normalised, then `r` will be shifted right by ``norm`` bits + # so that it has the same shift as all the inputs. + # We require `a` and `b` to be reduced modulo `n` before calling the + # function. + # Note that this function is not always as fast as ordinary division. + + mp_size_t flint_mpn_gcd_full2(mp_ptr arrayg, mp_srcptr array1, mp_size_t limbs1, mp_srcptr array2, mp_size_t limbs2, mp_ptr temp) + # Sets ``(arrayg, retvalue)`` to the gcd of ``(array1, limbs1)`` and + # ``(array2, limbs2)``. + # The only assumption is that neither ``limbs1`` nor ``limbs2`` is + # zero. + # The function must be supplied with ``limbs1 + limbs2`` limbs of temporary + # space, or ``NULL`` must be passed to ``temp`` if the function should + # allocate its own space. + + mp_size_t flint_mpn_gcd_full(mp_ptr arrayg, mp_srcptr array1, mp_size_t limbs1, mp_srcptr array2, mp_size_t limbs2) + # Sets ``(arrayg, retvalue)`` to the gcd of ``(array1, limbs1)`` and + # ``(array2, limbs2)``. + # The only assumption is that neither ``limbs1`` nor ``limbs2`` is + # zero. + + void flint_mpn_rrandom(mp_limb_t *rp, gmp_randstate_t state, mp_size_t n) + # Generates a random number with ``n`` limbs and stores + # it on ``rp``. The number it generates will tend to have + # long strings of zeros and ones in the binary representation. + # Useful for testing functions and algorithms, since this kind of random + # numbers have proven to be more likely to trigger corner-case bugs. + + void flint_mpn_urandomb(mp_limb_t *rp, gmp_randstate_t state, flint_bitcnt_t n) + # Generates a uniform random number of ``n`` bits and stores + # it on ``rp``. diff --git a/src/sage/libs/flint/mpoly.pxd b/src/sage/libs/flint/mpoly.pxd index 51c9a1ae939..fdf7101a3a6 100644 --- a/src/sage/libs/flint/mpoly.pxd +++ b/src/sage/libs/flint/mpoly.pxd @@ -12,7 +12,7 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void mpoly_ctx_init(mpoly_ctx_t ctx, long nvars, const ordering_t ord) + void mpoly_ctx_init(mpoly_ctx_t ctx, slong nvars, const ordering_t ord) # Initialize a context for specified number of variables and ordering. void mpoly_ctx_clear(mpoly_ctx_t mctx) @@ -22,7 +22,7 @@ cdef extern from "flint_wrap.h": # Return a random ordering. The possibilities are ``ORD_LEX``, # ``ORD_DEGLEX`` and ``ORD_DEGREVLEX``. - void mpoly_ctx_init_rand(mpoly_ctx_t mctx, flint_rand_t state, long max_nvars) + void mpoly_ctx_init_rand(mpoly_ctx_t mctx, flint_rand_t state, slong max_nvars) # Initialize a context with a random choice for the ordering. int mpoly_ordering_isdeg(const mpoly_ctx_t ctx) @@ -36,87 +36,87 @@ cdef extern from "flint_wrap.h": # Print a string (either "lex", "deglex" or "degrevlex") to standard # output, corresponding to the given ordering. - void mpoly_monomial_add(unsigned long * exp_ptr, const unsigned long * exp2, const unsigned long * exp3, long N) + void mpoly_monomial_add(ulong * exp_ptr, const ulong * exp2, const ulong * exp3, slong N) # Set ``(exp_ptr, N)`` to the sum of the monomials ``(exp2, N)`` and # ``(exp3, N)``, assuming ``bits <= FLINT_BITS`` - void mpoly_monomial_add_mp(unsigned long * exp_ptr, const unsigned long * exp2, const unsigned long * exp3, long N) + void mpoly_monomial_add_mp(ulong * exp_ptr, const ulong * exp2, const ulong * exp3, slong N) # Set ``(exp_ptr, N)`` to the sum of the monomials ``(exp2, N)`` and # ``(exp3, N)``. - void mpoly_monomial_sub(unsigned long * exp_ptr, const unsigned long * exp2, const unsigned long * exp3, long N) + void mpoly_monomial_sub(ulong * exp_ptr, const ulong * exp2, const ulong * exp3, slong N) # Set ``(exp_ptr, N)`` to the difference of the monomials ``(exp2, N)`` and ``(exp3, N)``, assuming ``bits <= FLINT_BITS`` - void mpoly_monomial_sub_mp(unsigned long * exp_ptr, const unsigned long * exp2, const unsigned long * exp3, long N) + void mpoly_monomial_sub_mp(ulong * exp_ptr, const ulong * exp2, const ulong * exp3, slong N) # Set ``(exp_ptr, N)`` to the difference of the monomials ``(exp2, N)`` and ``(exp3, N)``. - int mpoly_monomial_overflows(unsigned long * exp2, long N, unsigned long mask) + int mpoly_monomial_overflows(ulong * exp2, slong N, ulong mask) # Return true if any of the fields of the given monomial ``(exp2, N)`` has # overflowed (or is negative). The ``mask`` is a word with the high bit of # each field set to 1. In other words, the function returns 1 if any word of # ``exp2`` has any of the nonzero bits in ``mask`` set. Assumes that # ``bits <= FLINT_BITS``. - int mpoly_monomial_overflows_mp(unsigned long * exp_ptr, long N, flint_bitcnt_t bits) + int mpoly_monomial_overflows_mp(ulong * exp_ptr, slong N, flint_bitcnt_t bits) # Return true if any of the fields of the given monomial ``(exp_ptr, N)`` # has overflowed. Assumes that ``bits >= FLINT_BITS``. - int mpoly_monomial_overflows1(unsigned long exp, unsigned long mask) + int mpoly_monomial_overflows1(ulong exp, ulong mask) # As per ``mpoly_monomial_overflows`` with ``N = 1``. - void mpoly_monomial_set(unsigned long * exp2, const unsigned long * exp3, long N) + void mpoly_monomial_set(ulong * exp2, const ulong * exp3, slong N) # Set the monomial ``(exp2, N)`` to ``(exp3, N)``. - void mpoly_monomial_swap(unsigned long * exp2, unsigned long * exp3, long N) + void mpoly_monomial_swap(ulong * exp2, ulong * exp3, slong N) # Swap the words in ``(exp2, N)`` and ``(exp3, N)``. - void mpoly_monomial_mul_ui(unsigned long * exp2, const unsigned long * exp3, long N, unsigned long c) + void mpoly_monomial_mul_ui(ulong * exp2, const ulong * exp3, slong N, ulong c) # Set the words of ``(exp2, N)`` to the words of ``(exp3, N)`` # multiplied by ``c``. - int mpoly_monomial_is_zero(const unsigned long * exp, long N) + int mpoly_monomial_is_zero(const ulong * exp, slong N) # Return 1 if ``(exp, N)`` is zero. - int mpoly_monomial_equal(const unsigned long * exp2, const unsigned long * exp3, long N) + int mpoly_monomial_equal(const ulong * exp2, const ulong * exp3, slong N) # Return 1 if the monomials ``(exp2, N)`` and ``(exp3, N)`` are equal. - void mpoly_get_cmpmask(unsigned long * cmpmask, long N, unsigned long bits, const mpoly_ctx_t mctx) + void mpoly_get_cmpmask(ulong * cmpmask, slong N, ulong bits, const mpoly_ctx_t mctx) # Get the mask ``(cmpmask, N)`` for comparisons. # ``bits`` should be set to the number of bits in the exponents # to be compared. Any function that compares monomials should use this # comparison mask. - int mpoly_monomial_lt(const unsigned long * exp2, const unsigned long * exp3, long N, const unsigned long * cmpmask) + int mpoly_monomial_lt(const ulong * exp2, const ulong * exp3, slong N, const ulong * cmpmask) # Return 1 if ``(exp2, N)`` is less than ``(exp3, N)``. - int mpoly_monomial_gt(const unsigned long * exp2, const unsigned long * exp3, long N, const unsigned long * cmpmask) + int mpoly_monomial_gt(const ulong * exp2, const ulong * exp3, slong N, const ulong * cmpmask) # Return 1 if ``(exp2, N)`` is greater than ``(exp3, N)``. - int mpoly_monomial_cmp(const unsigned long * exp2, const unsigned long * exp3, long N, const unsigned long * cmpmask) + int mpoly_monomial_cmp(const ulong * exp2, const ulong * exp3, slong N, const ulong * cmpmask) # Return `1` if ``(exp2, N)`` is greater than, `0` if it is equal to and # `-1` if it is less than ``(exp3, N)``. - int mpoly_monomial_divides(unsigned long * exp_ptr, const unsigned long * exp2, const unsigned long * exp3, long N, unsigned long mask) + int mpoly_monomial_divides(ulong * exp_ptr, const ulong * exp2, const ulong * exp3, slong N, ulong mask) # Return 1 if the monomial ``(exp3, N)`` divides ``(exp2, N)``. If so # set ``(exp_ptr, N)`` to the quotient monomial. The ``mask`` is a word # with the high bit of each bit field set to 1. Assumes that # ``bits <= FLINT_BITS``. - int mpoly_monomial_divides_mp(unsigned long * exp_ptr, const unsigned long * exp2, const unsigned long * exp3, long N, flint_bitcnt_t bits) + int mpoly_monomial_divides_mp(ulong * exp_ptr, const ulong * exp2, const ulong * exp3, slong N, flint_bitcnt_t bits) # Return 1 if the monomial ``(exp3, N)`` divides ``(exp2, N)``. If so # set ``(exp_ptr, N)`` to the quotient monomial. Assumes that # ``bits >= FLINT_BITS``. - int mpoly_monomial_divides1(unsigned long * exp_ptr, const unsigned long exp2, const unsigned long exp3, unsigned long mask) + int mpoly_monomial_divides1(ulong * exp_ptr, const ulong exp2, const ulong exp3, ulong mask) # As per ``mpoly_monomial_divides`` with ``N = 1``. - int mpoly_monomial_divides_tight(long e1, long e2, long * prods, long num) + int mpoly_monomial_divides_tight(slong e1, slong e2, slong * prods, slong num) # Return 1 if the monomial ``e2`` divides the monomial ``e1``, where # the monomials are stored using factorial representation. The array # ``(prods, num)`` should consist of `1`, `b_1, b_1\times b_2, \ldots`, # where the `b_i` are the bases of the factorial number representation. - flint_bitcnt_t mpoly_exp_bits_required_ui(const unsigned long * user_exp, const mpoly_ctx_t mctx) + flint_bitcnt_t mpoly_exp_bits_required_ui(const ulong * user_exp, const mpoly_ctx_t mctx) # Returns the number of bits required to store ``user_exp`` in packed # format. The returned number of bits includes space for a zeroed signed bit. @@ -128,16 +128,16 @@ cdef extern from "flint_wrap.h": # Returns the number of bits required to store ``user_exp`` in packed # format. The returned number of bits includes space for a zeroed signed bit. - void mpoly_max_fields_ui_sp(unsigned long * max_fields, const unsigned long * poly_exps, long len, unsigned long bits, const mpoly_ctx_t mctx) + void mpoly_max_fields_ui_sp(ulong * max_fields, const ulong * poly_exps, slong len, ulong bits, const mpoly_ctx_t mctx) # Compute the field-wise maximum of packed exponents from ``poly_exps`` # of length ``len`` and unpack the result into ``max_fields``. # The maximums are assumed to fit a ulong. - void mpoly_max_fields_fmpz(fmpz * max_fields, const unsigned long * poly_exps, long len, unsigned long bits, const mpoly_ctx_t mctx) + void mpoly_max_fields_fmpz(fmpz * max_fields, const ulong * poly_exps, slong len, ulong bits, const mpoly_ctx_t mctx) # Compute the field-wise maximum of packed exponents from ``poly_exps`` # of length ``len`` and unpack the result into ``max_fields``. - void mpoly_max_degrees_tight(long * max_exp, unsigned long * exps, long len, long * prods, long num) + void mpoly_max_degrees_tight(slong * max_exp, ulong * exps, slong len, slong * prods, slong num) # Return an array of ``num`` integers corresponding to the maximum degrees # of the exponents in the array of exponent vectors ``(exps, len)``, # assuming that the exponent are packed in a factorial representation. The @@ -147,7 +147,7 @@ cdef extern from "flint_wrap.h": # with the entry corresponding to the most significant base of the factorial # representation first in the array. - int mpoly_monomial_exists(long * index, const unsigned long * poly_exps, const unsigned long * exp, long len, long N, const unsigned long * cmpmask) + int mpoly_monomial_exists(slong * index, const ulong * poly_exps, const ulong * exp, slong len, slong N, const ulong * cmpmask) # Returns true if the given exponent vector ``exp`` exists in the array of # exponent vectors ``(poly_exps, len)``, otherwise, returns false. If the # exponent vector is found, its index into the array of exponent vectors is @@ -155,7 +155,7 @@ cdef extern from "flint_wrap.h": # could be inserted to preserve the ordering. The index can be in the range # ``[0, len]``. - void mpoly_search_monomials(long ** e_ind, unsigned long * e, long * e_score, long * t1, long * t2, long *t3, long lower, long upper, const unsigned long * a, long a_len, const unsigned long * b, long b_len, long N, const unsigned long * cmpmask) + void mpoly_search_monomials(slong ** e_ind, ulong * e, slong * e_score, slong * t1, slong * t2, slong *t3, slong lower, slong upper, const ulong * a, slong a_len, const ulong * b, slong b_len, slong N, const ulong * cmpmask) # Given packed exponent vectors ``a`` and ``b``, compute a packed # exponent ``e`` such that the number of monomials in the cross product # ``a`` X ``b`` that are less than or equal to ``e`` is between @@ -167,64 +167,64 @@ cdef extern from "flint_wrap.h": # of ``t1``, ``t2``, and ``t3`` and gives the locations of the # monomials in ``a`` X ``b``. - int mpoly_term_exp_fits_ui(unsigned long * exps, unsigned long bits, long n, const mpoly_ctx_t mctx) + int mpoly_term_exp_fits_ui(ulong * exps, ulong bits, slong n, const mpoly_ctx_t mctx) # Return whether every entry of the exponent vector of index `n` in # ``exps`` fits into a ``ulong``. - int mpoly_term_exp_fits_si(unsigned long * exps, unsigned long bits, long n, const mpoly_ctx_t mctx) + int mpoly_term_exp_fits_si(ulong * exps, ulong bits, slong n, const mpoly_ctx_t mctx) # Return whether every entry of the exponent vector of index `n` in # ``exps`` fits into a ``slong``. - void mpoly_get_monomial_ui(unsigned long * exps, const unsigned long * poly_exps, unsigned long bits, const mpoly_ctx_t mctx) + void mpoly_get_monomial_ui(ulong * exps, const ulong * poly_exps, ulong bits, const mpoly_ctx_t mctx) # Convert the packed exponent ``poly_exps`` of bit count ``bits`` to a # monomial from the user's perspective. The exponents are assumed to fit # a ulong. - void mpoly_get_monomial_ffmpz(fmpz * exps, const unsigned long * poly_exps, flint_bitcnt_t bits, const mpoly_ctx_t mctx) + void mpoly_get_monomial_ffmpz(fmpz * exps, const ulong * poly_exps, flint_bitcnt_t bits, const mpoly_ctx_t mctx) # Convert the packed exponent ``poly_exps`` of bit count ``bits`` to a # monomial from the user's perspective. - void mpoly_get_monomial_pfmpz(fmpz ** exps, const unsigned long * poly_exps, flint_bitcnt_t bits, const mpoly_ctx_t mctx) + void mpoly_get_monomial_pfmpz(fmpz ** exps, const ulong * poly_exps, flint_bitcnt_t bits, const mpoly_ctx_t mctx) # Convert the packed exponent ``poly_exps`` of bit count ``bits`` to a # monomial from the user's perspective. - void mpoly_set_monomial_ui(unsigned long * exp1, const unsigned long * exp2, unsigned long bits, const mpoly_ctx_t mctx) + void mpoly_set_monomial_ui(ulong * exp1, const ulong * exp2, ulong bits, const mpoly_ctx_t mctx) # Convert the user monomial ``exp2`` to packed format using ``bits``. - void mpoly_set_monomial_ffmpz(unsigned long * exp1, const fmpz * exp2, flint_bitcnt_t bits, const mpoly_ctx_t mctx) + void mpoly_set_monomial_ffmpz(ulong * exp1, const fmpz * exp2, flint_bitcnt_t bits, const mpoly_ctx_t mctx) # Convert the user monomial ``exp2`` to packed format using ``bits``. - void mpoly_set_monomial_pfmpz(unsigned long * exp1, fmpz * const * exp2, flint_bitcnt_t bits, const mpoly_ctx_t mctx) + void mpoly_set_monomial_pfmpz(ulong * exp1, fmpz * const * exp2, flint_bitcnt_t bits, const mpoly_ctx_t mctx) # Convert the user monomial ``exp2`` to packed format using ``bits``. - void mpoly_pack_vec_ui(unsigned long * exp1, const unsigned long * exp2, unsigned long bits, long nfields, long len) + void mpoly_pack_vec_ui(ulong * exp1, const ulong * exp2, ulong bits, slong nfields, slong len) # Packs a vector ``exp2`` into \{exp1} using a bit count of ``bits``. # No checking is done to ensure that the vector actually fits # into ``bits`` bits. The number of fields in each vector is # ``nfields`` and the total number of vectors to unpack is ``len``. - void mpoly_pack_vec_fmpz(unsigned long * exp1, const fmpz * exp2, flint_bitcnt_t bits, long nfields, long len) + void mpoly_pack_vec_fmpz(ulong * exp1, const fmpz * exp2, flint_bitcnt_t bits, slong nfields, slong len) # Packs a vector ``exp2`` into \{exp1} using a bit count of ``bits``. # No checking is done to ensure that the vector actually fits # into ``bits`` bits. The number of fields in each vector is # ``nfields`` and the total number of vectors to unpack is ``len``. - void mpoly_unpack_vec_ui(unsigned long * exp1, const unsigned long * exp2, unsigned long bits, long nfields, long len) + void mpoly_unpack_vec_ui(ulong * exp1, const ulong * exp2, ulong bits, slong nfields, slong len) # Unpacks vector ``exp2`` of bit count ``bits`` into ``exp1``. # The number of fields in each vector is # ``nfields`` and the total number of vectors to unpack is ``len``. - void mpoly_unpack_vec_fmpz(fmpz * exp1, const unsigned long * exp2, flint_bitcnt_t bits, long nfields, long len) + void mpoly_unpack_vec_fmpz(fmpz * exp1, const ulong * exp2, flint_bitcnt_t bits, slong nfields, slong len) # Unpacks vector ``exp2`` of bit count ``bits`` into ``exp1``. # The number of fields in each vector is # ``nfields`` and the total number of vectors to unpack is ``len``. - int mpoly_repack_monomials(unsigned long * exps1, unsigned long bits1, const unsigned long * exps2, unsigned long bits2, long len, const mpoly_ctx_t mctx) + int mpoly_repack_monomials(ulong * exps1, ulong bits1, const ulong * exps2, ulong bits2, slong len, const mpoly_ctx_t mctx) # Convert an array of length ``len`` of exponents ``exps2`` packed # using bits ``bits2`` into an array ``exps1`` using bits ``bits1``. # No checking is done to ensure that the result fits into bits ``bits1``. - void mpoly_pack_monomials_tight(unsigned long * exp1, const unsigned long * exp2, long len, const long * mults, long num, long bits) + void mpoly_pack_monomials_tight(ulong * exp1, const ulong * exp2, slong len, const slong * mults, slong num, slong bits) # Given an array of possibly packed exponent vectors ``exp2`` of length # ``len``, where each field of each exponent vector is packed into the # given number of bits, return the corresponding array of monomial vectors @@ -237,7 +237,7 @@ cdef extern from "flint_wrap.h": # least significant ``num`` fields of each exponent vectors and ignores # the rest. The number of ignored fields should be passed in ``extras``. - void mpoly_unpack_monomials_tight(unsigned long * e1, unsigned long * e2, long len, long * mults, long num, long bits) + void mpoly_unpack_monomials_tight(ulong * e1, ulong * e2, slong len, slong * mults, slong num, slong bits) # Given an array of exponent vectors ``e2`` of length ``len`` packed # using a factorial numbering scheme, unpack the monomials into an array # ``e1`` of exponent vectors in standard packed format, where each field @@ -246,7 +246,7 @@ cdef extern from "flint_wrap.h": # entry of which corresponds to the field of least significance in each # exponent vector. - void mpoly_main_variable_terms1(long * i1, long * n1, const unsigned long * exp1, long l1, long len1, long k, long num, long bits) + void mpoly_main_variable_terms1(slong * i1, slong * n1, const ulong * exp1, slong l1, slong len1, slong k, slong num, slong bits) # Given an array of exponent vectors ``(exp1, len1)``, each exponent # vector taking one word of space, with each exponent being packed into the # given number of bits, compute ``l1`` starting offsets ``i1`` and @@ -256,7 +256,7 @@ cdef extern from "flint_wrap.h": # from the variable of least significance, starting from `0`. The value # ``l1`` should be the degree in the main variable, plus one. - int _mpoly_heap_insert(mpoly_heap_s * heap, unsigned long * exp, void * x, long * next_loc, long * heap_len, long N, const unsigned long * cmpmask) + int _mpoly_heap_insert(mpoly_heap_s * heap, ulong * exp, void * x, slong * next_loc, slong * heap_len, slong N, const ulong * cmpmask) # Given a heap, insert a new node `x` corresponding to the given exponent # into the heap. Heap elements are ordered by the exponent ``(exp, N)``, # with the largest element at the head of the heap. A pointer to the current @@ -264,11 +264,11 @@ cdef extern from "flint_wrap.h": # the function. Note that the index 0 position in the heap is not used, so # the length is always one greater than the number of elements. - void _mpoly_heap_insert1(mpoly_heap1_s * heap, unsigned long exp, void * x, long * next_loc, long * heap_len, unsigned long maskhi) + void _mpoly_heap_insert1(mpoly_heap1_s * heap, ulong exp, void * x, slong * next_loc, slong * heap_len, ulong maskhi) # As per ``_mpoly_heap_insert`` except that ``N = 1``, and # ``maskhi = cmpmask[0]``. - void * _mpoly_heap_pop(mpoly_heap_s * heap, long * heap_len, long N, const unsigned long * cmpmask) + void * _mpoly_heap_pop(mpoly_heap_s * heap, slong * heap_len, slong N, const ulong * cmpmask) # Pop the head of the heap. It is cast to a ``void *``. A pointer to the # current heap length must be passed in via ``heap_len``. This will be # updated by the function. Note that the index 0 position in the heap is not @@ -276,6 +276,6 @@ cdef extern from "flint_wrap.h": # ``maskhi`` and ``masklo`` values are zero except for degrevlex # ordering, where they are as per the monomial comparison operations above. - void * _mpoly_heap_pop1(mpoly_heap1_s * heap, long * heap_len, unsigned long maskhi) + void * _mpoly_heap_pop1(mpoly_heap1_s * heap, slong * heap_len, ulong maskhi) # As per ``_mpoly_heap_pop1`` except that ``N = 1``, and # ``maskhi = cmpmask[0]``. diff --git a/src/sage/libs/flint/nf.pxd b/src/sage/libs/flint/nf.pxd new file mode 100644 index 00000000000..3df152c7c74 --- /dev/null +++ b/src/sage/libs/flint/nf.pxd @@ -0,0 +1,21 @@ +# distutils: libraries = flint +# distutils: depends = flint/nf.h + +################################################################################ +# This file is auto-generated. Do not modify by hand +################################################################################ + +from libc.stdio cimport FILE +from sage.libs.gmp.types cimport * +from sage.libs.mpfr.types cimport * +from sage.libs.flint.types cimport * + +cdef extern from "flint_wrap.h": + + void nf_init(nf_t nf, const fmpq_poly_t pol) + # Perform basic initialisation of a number field (for element arithmetic) + # given a defining polynomial over `\mathbb{Q}`. + + void nf_clear(nf_t nf) + # Release resources used by a number field object. The object will need + # initialisation again before it can be used. diff --git a/src/sage/libs/flint/nf_elem.pxd b/src/sage/libs/flint/nf_elem.pxd new file mode 100644 index 00000000000..b48d890f8ce --- /dev/null +++ b/src/sage/libs/flint/nf_elem.pxd @@ -0,0 +1,274 @@ +# distutils: libraries = flint +# distutils: depends = flint/nf_elem.h + +################################################################################ +# This file is auto-generated. Do not modify by hand +################################################################################ + +from libc.stdio cimport FILE +from sage.libs.gmp.types cimport * +from sage.libs.mpfr.types cimport * +from sage.libs.flint.types cimport * + +cdef extern from "flint_wrap.h": + + void nf_elem_init(nf_elem_t a, const nf_t nf) + # Initialise a number field element to belong to the given number field + # ``nf``. The element is set to zero. + + void nf_elem_clear(nf_elem_t a, const nf_t nf) + # Clear resources allocated by the given number field element in the given + # number field. + + void nf_elem_randtest(nf_elem_t a, flint_rand_t state, mp_bitcnt_t bits, const nf_t nf) + # Generate a random number field element `a` in the number field ``nf`` + # whose coefficients have up to the given number of bits. + + void nf_elem_canonicalise(nf_elem_t a, const nf_t nf) + # Canonicalise a number field element, i.e. reduce numerator and denominator + # to lowest terms. If the numerator is `0`, set the denominator to `1`. + + void _nf_elem_reduce(nf_elem_t a, const nf_t nf) + # Reduce a number field element modulo the defining polynomial. This is used + # with functions such as ``nf_elem_mul_red`` which allow reduction to be + # delayed. Does not canonicalise. + + void nf_elem_reduce(nf_elem_t a, const nf_t nf) + # Reduce a number field element modulo the defining polynomial. This is used + # with functions such as ``nf_elem_mul_red`` which allow reduction to be + # delayed. + + int _nf_elem_invertible_check(nf_elem_t a, const nf_t nf) + # Whilst the defining polynomial for a number field should by definition be + # irreducible, it is not enforced. Thus in test code, it is convenient to be + # able to check that a given number field element is invertible modulo the + # defining polynomial of the number field. This function does precisely this. + # If `a` is invertible modulo the defining polynomial of ``nf`` the value + # `1` is returned, otherwise `0` is returned. + # The function is only intended to be used in test code. + + void nf_elem_set_fmpz_mat_row(nf_elem_t b, const fmpz_mat_t M, const slong i, fmpz_t den, const nf_t nf) + # Set `b` to the element specified by row `i` of the matrix `M` and with the + # given denominator `d`. Column `0` of the matrix corresponds to the constant + # coefficient of the number field element. + + void nf_elem_get_fmpz_mat_row(fmpz_mat_t M, const slong i, fmpz_t den, const nf_elem_t b, const nf_t nf) + # Set the row `i` of the matrix `M` to the coefficients of the numerator of + # the element `b` and `d` to the denominator of `b`. Column `0` of the matrix + # corresponds to the constant coefficient of the number field element. + + void nf_elem_set_fmpq_poly(nf_elem_t a, const fmpq_poly_t pol, const nf_t nf) + # Set `a` to the element corresponding to the polynomial ``pol``. + + void nf_elem_get_fmpq_poly(fmpq_poly_t pol, const nf_elem_t a, const nf_t nf) + # Set ``pol`` to a polynomial corresponding to `a`, reduced modulo the + # defining polynomial of ``nf``. + + void nf_elem_get_nmod_poly_den(nmod_poly_t pol, const nf_elem_t a, const nf_t nf, int den) + # Set ``pol`` to the reduction of the polynomial corresponding to the + # numerator of `a`. If ``den == 1``, the result is multiplied by the + # inverse of the denominator of `a`. In this case it is assumed that the + # reduction of the denominator of `a` is invertible. + + void nf_elem_get_nmod_poly(nmod_poly_t pol, const nf_elem_t a, const nf_t nf) + # Set ``pol`` to the reduction of the polynomial corresponding to the + # numerator of `a`. The result is multiplied by the inverse of the + # denominator of `a`. It is assumed that the reduction of the denominator of + # `a` is invertible. + + void nf_elem_get_fmpz_mod_poly_den(fmpz_mod_poly_t pol, const nf_elem_t a, const nf_t nf, int den, const fmpz_mod_ctx_t ctx) + # Set ``pol`` to the reduction of the polynomial corresponding to the + # numerator of `a`. If ``den == 1``, the result is multiplied by the + # inverse of the denominator of `a`. In this case it is assumed that the + # reduction of the denominator of `a` is invertible. + + void nf_elem_get_fmpz_mod_poly(fmpz_mod_poly_t pol, const nf_elem_t a, const nf_t nf, const fmpz_mod_ctx_t ctx) + # Set ``pol`` to the reduction of the polynomial corresponding to the + # numerator of `a`. The result is multiplied by the inverse of the + # denominator of `a`. It is assumed that the reduction of the denominator of + # `a` is invertible. + + void nf_elem_set_den(nf_elem_t b, fmpz_t d, const nf_t nf) + # Set the denominator of the ``nf_elem_t b`` to the given integer `d`. + # Assumes `d > 0`. + + void nf_elem_get_den(fmpz_t d, const nf_elem_t b, const nf_t nf) + # Set `d` to the denominator of the ``nf_elem_t b``. + + void _nf_elem_set_coeff_num_fmpz(nf_elem_t a, slong i, const fmpz_t d, const nf_t nf) + # Set the `i`-th coefficient of the denominator of `a` to the given integer + # `d`. + + int _nf_elem_equal(const nf_elem_t a, const nf_elem_t b, const nf_t nf) + # Return `1` if the given number field elements are equal in the given + # number field ``nf``. This function does \emph{not} assume `a` and `b` + # are canonicalised. + + int nf_elem_equal(const nf_elem_t a, const nf_elem_t b, const nf_t nf) + # Return `1` if the given number field elements are equal in the given + # number field ``nf``. This function assumes `a` and `b` \emph{are} + # canonicalised. + + int nf_elem_is_zero(const nf_elem_t a, const nf_t nf) + # Return `1` if the given number field element is equal to zero, + # otherwise return `0`. + + int nf_elem_is_one(const nf_elem_t a, const nf_t nf) + # Return `1` if the given number field element is equal to one, + # otherwise return `0`. + + void nf_elem_print_pretty(const nf_elem_t a, const nf_t nf, const char * var) + # Print the given number field element to ``stdout`` using the + # null-terminated string ``var`` not equal to ``"\0"`` as the + # name of the primitive element. + + void nf_elem_zero(nf_elem_t a, const nf_t nf) + + void nf_elem_one(nf_elem_t a, const nf_t nf) + + void nf_elem_set(nf_elem_t a, const nf_elem_t b, const nf_t nf) + # Set the number field element `a` to equal the number field element `b`, + # i.e. set `a = b`. + + void nf_elem_neg(nf_elem_t a, const nf_elem_t b, const nf_t nf) + # Set the number field element `a` to minus the number field element `b`, + # i.e. set `a = -b`. + + void nf_elem_swap(nf_elem_t a, nf_elem_t b, const nf_t nf) + # Efficiently swap the two number field elements `a` and `b`. + + void nf_elem_mul_gen(nf_elem_t a, const nf_elem_t b, const nf_t nf) + # Multiply the element `b` with the generator of the number field. + + void _nf_elem_add(nf_elem_t r, const nf_elem_t a, const nf_elem_t b, const nf_t nf) + # Add two elements of a number field ``nf``, i.e. set `r = a + b`. + # Canonicalisation is not performed. + + void nf_elem_add(nf_elem_t r, const nf_elem_t a, const nf_elem_t b, const nf_t nf) + # Add two elements of a number field ``nf``, i.e. set `r = a + b`. + + void _nf_elem_sub(nf_elem_t r, const nf_elem_t a, const nf_elem_t b, const nf_t nf) + # Subtract two elements of a number field ``nf``, i.e. set `r = a - b`. + # Canonicalisation is not performed. + + void nf_elem_sub(nf_elem_t r, const nf_elem_t a, const nf_elem_t b, const nf_t nf) + # Subtract two elements of a number field ``nf``, i.e. set `r = a - b`. + + void _nf_elem_mul(nf_elem_t a, const nf_elem_t b, const nf_elem_t c, const nf_t nf) + # Multiply two elements of a number field ``nf``, i.e. set `r = a * b`. + # Does not canonicalise. Aliasing of inputs with output is not supported. + + void _nf_elem_mul_red(nf_elem_t a, const nf_elem_t b, const nf_elem_t c, const nf_t nf, int red) + # As per ``_nf_elem_mul``, but reduction modulo the defining polynomial + # of the number field is only carried out if ``red == 1``. Assumes both + # inputs are reduced. + + void nf_elem_mul(nf_elem_t a, const nf_elem_t b, const nf_elem_t c, const nf_t nf) + # Multiply two elements of a number field ``nf``, i.e. set `r = a * b`. + + void nf_elem_mul_red(nf_elem_t a, const nf_elem_t b, const nf_elem_t c, const nf_t nf, int red) + # As per ``nf_elem_mul``, but reduction modulo the defining polynomial + # of the number field is only carried out if ``red == 1``. Assumes both + # inputs are reduced. + + void _nf_elem_inv(nf_elem_t r, const nf_elem_t a, const nf_t nf) + # Invert an element of a number field ``nf``, i.e. set `r = a^{-1}`. + # Aliasing of the input with the output is not supported. + + void nf_elem_inv(nf_elem_t r, const nf_elem_t a, const nf_t nf) + # Invert an element of a number field ``nf``, i.e. set `r = a^{-1}`. + + void _nf_elem_div(nf_elem_t a, const nf_elem_t b, const nf_elem_t c, const nf_t nf) + # Set `a` to `b/c` in the given number field. Aliasing of `a` and `b` is not + # permitted. + + void nf_elem_div(nf_elem_t a, const nf_elem_t b, const nf_elem_t c, const nf_t nf) + # Set `a` to `b/c` in the given number field. + + void _nf_elem_pow(nf_elem_t res, const nf_elem_t a, ulong e, const nf_t nf) + # Set ``res`` to `a^e` using left-to-right binary exponentiation as + # described on p. 461 of [Knu1997]_. + # Assumes that `a \neq 0` and `e > 1`. Does not support aliasing. + + void nf_elem_pow(nf_elem_t res, const nf_elem_t a, ulong e, const nf_t nf) + # Set ``res`` = ``a^e`` using the binary exponentiation algorithm. + # If `e` is zero, returns one, so that in particular ``0^0 = 1``. + + void _nf_elem_norm(fmpz_t rnum, fmpz_t rden, const nf_elem_t a, const nf_t nf) + # Set ``rnum, rden`` to the absolute norm of the given number field + # element `a`. + + void nf_elem_norm(fmpq_t res, const nf_elem_t a, const nf_t nf) + # Set ``res`` to the absolute norm of the given number field + # element `a`. + + void nf_elem_norm_div(fmpq_t res, const nf_elem_t a, const nf_t nf, const fmpz_t div, slong nbits) + # Set ``res`` to the absolute norm of the given number field element `a`, + # divided by ``div`` . Assumes the result to be an integer and having + # at most ``nbits`` bits. + + void _nf_elem_norm_div(fmpz_t rnum, fmpz_t rden, const nf_elem_t a, const nf_t nf, const fmpz_t divisor, slong nbits) + # Set ``rnum, rden`` to the absolute norm of the given number field element `a`, + # divided by ``div`` . Assumes the result to be an integer and having + # at most ``nbits`` bits. + + void _nf_elem_trace(fmpz_t rnum, fmpz_t rden, const nf_elem_t a, const nf_t nf) + # Set ``rnum, rden`` to the absolute trace of the given number field + # element `a`. + + void nf_elem_trace(fmpq_t res, const nf_elem_t a, const nf_t nf) + # Set ``res`` to the absolute trace of the given number field + # element `a`. + + void nf_elem_rep_mat(fmpq_mat_t res, const nf_elem_t a, const nf_t nf) + # Set ``res`` to the matrix representing the multiplication with `a` with + # respect to the basis `1, a, \dotsc, a^{d - 1}`, where `a` is the generator + # of the number field of `d` is its degree. + + void nf_elem_rep_mat_fmpz_mat_den(fmpz_mat_t res, fmpz_t den, const nf_elem_t a, const nf_t nf) + # Return a tuple `M, d` such that `M/d` is the matrix representing the + # multiplication with `a` with respect to the basis `1, a, \dotsc, a^{d - 1}`, + # where `a` is the generator of the number field of `d` is its degree. + # The integral matrix `M` is primitive. + + void nf_elem_mod_fmpz_den(nf_elem_t z, const nf_elem_t a, const fmpz_t mod, const nf_t nf, int den) + # If ``den == 0``, return an element `z` with denominator `1`, such that + # the coefficients of `z - da` are divisble by ``mod``, where `d` is the + # denominator of `a`. The coefficients of `z` are reduced modulo ``mod``. + # If ``den == 1``, return an element `z`, such that `z - a` has + # denominator `1` and the coefficients of `z - a` are divisible by ``mod``. + # The coefficients of `z` are reduced modulo `\mathtt{mod} \cdot d`, where `d` is the + # denominator of `a`. + # Reduction takes place with respect to the positive residue system. + + void nf_elem_smod_fmpz_den(nf_elem_t z, const nf_elem_t a, const fmpz_t mod, const nf_t nf, int den) + # If ``den == 0``, return an element `z` with denominator `1`, such that + # the coefficients of `z - da` are divisble by ``mod``, where `d` is the + # denominator of `a`. The coefficients of `z` are reduced modulo ``mod``. + # If ``den == 1``, return an element `z`, such that `z - a` has + # denominator `1` and the coefficients of `z - a` are divisible by ``mod``. + # The coefficients of `z` are reduced modulo `\mathtt{mod} \cdot d`, where `d` is the + # denominator of `a`. + # Reduction takes place with respect to the symmetric residue system. + + void nf_elem_mod_fmpz(nf_elem_t res, const nf_elem_t a, const fmpz_t mod, const nf_t nf) + # Return an element `z` such that `z - a` has denominator `1` and the + # coefficients of `z - a` are divisible by ``mod``. The coefficients of + # `z` are reduced modulo `\mathtt{mod} \cdot d`, where `d` is the denominator of `b`. + # Reduction takes place with respect to the positive residue system. + + void nf_elem_smod_fmpz(nf_elem_t res, const nf_elem_t a, const fmpz_t mod, const nf_t nf) + # Return an element `z` such that `z - a` has denominator `1` and the + # coefficients of `z - a` are divisible by ``mod``. The coefficients of + # `z` are reduced modulo `\mathtt{mod} \cdot d`, where `d` is the denominator of `b`. + # Reduction takes place with respect to the symmetric residue system. + + void nf_elem_coprime_den(nf_elem_t res, const nf_elem_t a, const fmpz_t mod, const nf_t nf) + # Return an element `z` such that the denominator of `z - a` is coprime to + # ``mod``. + # Reduction takes place with respect to the positive residue system. + + void nf_elem_coprime_den_signed(nf_elem_t res, const nf_elem_t a, const fmpz_t mod, const nf_t nf) + # Return an element `z` such that the denominator of `z - a` is coprime to + # ``mod``. + # Reduction takes place with respect to the symmetric residue system. diff --git a/src/sage/libs/flint/nmod.pxd b/src/sage/libs/flint/nmod.pxd new file mode 100644 index 00000000000..a4d8cf20e03 --- /dev/null +++ b/src/sage/libs/flint/nmod.pxd @@ -0,0 +1,86 @@ +# distutils: libraries = flint +# distutils: depends = flint/nmod.h + +################################################################################ +# This file is auto-generated. Do not modify by hand +################################################################################ + +from libc.stdio cimport FILE +from sage.libs.gmp.types cimport * +from sage.libs.mpfr.types cimport * +from sage.libs.flint.types cimport * + +cdef extern from "flint_wrap.h": + + void nmod_init(nmod_t * mod, mp_limb_t n) + # Initialises the given ``nmod_t`` structure for reduction modulo `n` + # with a precomputed inverse. + + mp_limb_t _nmod_add(mp_limb_t a, mp_limb_t b, nmod_t mod) + # Returns `a + b` modulo ``mod.n``. It is assumed that ``mod`` is + # no more than ``FLINT_BITS - 1`` bits. It is assumed that `a` and `b` + # are already reduced modulo ``mod.n``. + + mp_limb_t nmod_add(mp_limb_t a, mp_limb_t b, nmod_t mod) + # Returns `a + b` modulo ``mod.n``. No assumptions are made about + # ``mod.n``. It is assumed that `a` and `b` are already reduced + # modulo ``mod.n``. + + mp_limb_t _nmod_sub(mp_limb_t a, mp_limb_t b, nmod_t mod) + # Returns `a - b` modulo ``mod.n``. It is assumed that ``mod`` + # is no more than ``FLINT_BITS - 1`` bits. It is assumed that + # `a` and `b` are already reduced modulo ``mod.n``. + + mp_limb_t nmod_sub(mp_limb_t a, mp_limb_t b, nmod_t mod) + # Returns `a - b` modulo ``mod.n``. No assumptions are made about + # ``mod.n``. It is assumed that `a` and `b` are already reduced + # modulo ``mod.n``. + + mp_limb_t nmod_neg(mp_limb_t a, nmod_t mod) + # Returns `-a` modulo ``mod.n``. It is assumed that `a` is already + # reduced modulo ``mod.n``, but no assumptions are made about the + # latter. + + mp_limb_t nmod_mul(mp_limb_t a, mp_limb_t b, nmod_t mod) + # Returns `ab` modulo ``mod.n``. No assumptions are made about + # ``mod.n``. It is assumed that `a` and `b` are already reduced + # modulo ``mod.n``. + + mp_limb_t _nmod_mul_fullword(mp_limb_t a, mp_limb_t b, nmod_t mod) + # Returns `ab` modulo ``mod.n``. Requires that ``mod.n`` is exactly + # ``FLINT_BITS`` large. It is assumed that `a` and `b` are already + # reduced modulo ``mod.n``. + + mp_limb_t nmod_inv(mp_limb_t a, nmod_t mod) + # Returns `a^{-1}` modulo ``mod.n``. The inverse is assumed to exist. + + mp_limb_t nmod_div(mp_limb_t a, mp_limb_t b, nmod_t mod) + # Returns `ab^{-1}` modulo ``mod.n``. The inverse of `b` is assumed to + # exist. It is assumed that `a` is already reduced modulo ``mod.n``. + + mp_limb_t nmod_pow_ui(mp_limb_t a, ulong e, nmod_t mod) + # Returns `a^e` modulo ``mod.n``. No assumptions are made about + # ``mod.n``. It is assumed that `a` is already reduced + # modulo ``mod.n``. + + mp_limb_t nmod_pow_fmpz(mp_limb_t a, const fmpz_t e, nmod_t mod) + # Returns `a^e` modulo ``mod.n``. No assumptions are made about + # ``mod.n``. It is assumed that `a` is already reduced + # modulo ``mod.n`` and that `e` is not negative. + + void nmod_discrete_log_pohlig_hellman_init(nmod_discrete_log_pohlig_hellman_t L) + # Initialize ``L``. Upon initialization ``L`` is not ready for computation. + + void nmod_discrete_log_pohlig_hellman_clear(nmod_discrete_log_pohlig_hellman_t L) + # Free any space used by ``L``. + + double nmod_discrete_log_pohlig_hellman_precompute_prime(nmod_discrete_log_pohlig_hellman_t L, mp_limb_t p) + # Configure ``L`` for discrete logarithms modulo ``p`` to an internally chosen base. It is assumed that ``p`` is prime. + # The return is an estimate on the number of multiplications needed for one run. + + mp_limb_t nmod_discrete_log_pohlig_hellman_primitive_root(const nmod_discrete_log_pohlig_hellman_t L) + # Return the internally stored base. + + ulong nmod_discrete_log_pohlig_hellman_run(const nmod_discrete_log_pohlig_hellman_t L, mp_limb_t y) + # Return the logarithm of ``y`` with respect to the internally stored base. ``y`` is expected to be reduced modulo the ``p``. + # The function is undefined if the logarithm does not exist. diff --git a/src/sage/libs/flint/nmod_mat.pxd b/src/sage/libs/flint/nmod_mat.pxd new file mode 100644 index 00000000000..fa0e6a253a6 --- /dev/null +++ b/src/sage/libs/flint/nmod_mat.pxd @@ -0,0 +1,456 @@ +# distutils: libraries = flint +# distutils: depends = flint/nmod_mat.h + +################################################################################ +# This file is auto-generated. Do not modify by hand +################################################################################ + +from libc.stdio cimport FILE +from sage.libs.gmp.types cimport * +from sage.libs.mpfr.types cimport * +from sage.libs.flint.types cimport * + +cdef extern from "flint_wrap.h": + + void nmod_mat_init(nmod_mat_t mat, slong rows, slong cols, mp_limb_t n) + # Initialises ``mat`` to a ``rows``-by-``cols`` matrix with + # coefficients modulo `n`, where `n` can be any nonzero integer that + # fits in a limb. All elements are set to zero. + + void nmod_mat_init_set(nmod_mat_t mat, const nmod_mat_t src) + # Initialises ``mat`` and sets its dimensions, modulus and elements + # to those of ``src``. + + void nmod_mat_clear(nmod_mat_t mat) + # Clears the matrix and releases any memory it used. The matrix + # cannot be used again until it is initialised. This function must be + # called exactly once when finished using an ``nmod_mat_t`` object. + + void nmod_mat_set(nmod_mat_t mat, const nmod_mat_t src) + # Sets ``mat`` to a copy of ``src``. It is assumed + # that ``mat`` and ``src`` have identical dimensions. + + void nmod_mat_swap(nmod_mat_t mat1, nmod_mat_t mat2) + # Exchanges ``mat1`` and ``mat2``. + + void nmod_mat_swap_entrywise(nmod_mat_t mat1, nmod_mat_t mat2) + # Swaps two matrices by swapping the individual entries rather than swapping + # the contents of the structs. + + MACRO nmod_mat_entry(nmod_mat_t mat, slong i, slong j) + # Directly accesses the entry in ``mat`` in row `i` and column `j`, + # indexed from zero. No bounds checking is performed. This macro can be + # used both for reading and writing coefficients. + + mp_limb_t nmod_mat_get_entry(const nmod_mat_t mat, slong i, slong j) + # Get the entry at row `i` and column `j` of the matrix ``mat``. + + mp_limb_t * nmod_mat_entry_ptr(const nmod_mat_t mat, slong i, slong j) + # Return a pointer to the entry at row `i` and column `j` of the matrix + # ``mat``. + + void nmod_mat_set_entry(nmod_mat_t mat, slong i, slong j, mp_limb_t x) + # Set the entry at row `i` and column `j` of the matrix ``mat`` to + # ``x``. + + slong nmod_mat_nrows(const nmod_mat_t mat) + # Returns the number of rows in ``mat``. + + slong nmod_mat_ncols(const nmod_mat_t mat) + # Returns the number of columns in ``mat``. + + void nmod_mat_zero(nmod_mat_t mat) + # Sets all entries of the matrix ``mat`` to zero. + + int nmod_mat_is_zero(const nmod_mat_t mat) + # Returns `1` if all entries of the matrix ``mat`` are zero. + + void nmod_mat_window_init(nmod_mat_t window, const nmod_mat_t mat, slong r1, slong c1, slong r2, slong c2) + # Initializes the matrix ``window`` to be an ``r2 - r1`` by + # ``c2 - c1`` submatrix of ``mat`` whose ``(0,0)`` entry + # is the ``(r1, c1)`` entry of ``mat``. The memory for the + # elements of ``window`` is shared with ``mat``. + + void nmod_mat_window_clear(nmod_mat_t window) + # Clears the matrix ``window`` and releases any memory that it + # uses. Note that the memory to the underlying matrix that + # ``window`` points to is not freed. + + void nmod_mat_concat_vertical(nmod_mat_t res, const nmod_mat_t mat1, const nmod_mat_t mat2) + # Sets ``res`` to vertical concatenation of (`mat1`, ``mat2``) in that order. Matrix dimensions : ``mat1`` : `m \times n`, ``mat2`` : `k \times n`, ``res`` : `(m + k) \times n`. + + void nmod_mat_concat_horizontal(nmod_mat_t res, const nmod_mat_t mat1, const nmod_mat_t mat2) + # Sets ``res`` to horizontal concatenation of (``mat1``, ``mat2``) in that order. Matrix dimensions : ``mat1`` : `m \times n`, ``mat2`` : `m \times k`, ``res`` : `m \times (n + k)`. + + void nmod_mat_print_pretty(const nmod_mat_t mat) + # Pretty-prints ``mat`` to ``stdout``. A header is printed followed + # by the rows enclosed in brackets. Each column is right-aligned to the + # width of the modulus written in decimal, and the columns are separated by + # spaces. + # For example:: + # <2 x 3 integer matrix mod 2903> + # [ 0 0 2607] + # [ 622 0 0] + + int nmod_mat_fprint_pretty(FILE * file, const nmod_mat_t mat) + # Same as ``nmod_mat_print_pretty`` but printing to ``file``. + + int nmod_mat_print(const nmod_mat_t mat) + # Currently, same as ``nmod_mat_print_pretty``. + + int nmod_mat_fprint(FILE * f, const nmod_mat_t mat) + # Currently, same as ``nmod_mat_fprint_pretty``. + + void nmod_mat_randtest(nmod_mat_t mat, flint_rand_t state) + # Sets the elements to a random matrix with entries between `0` and `m-1` + # inclusive, where `m` is the modulus of ``mat``. A sparse matrix is + # generated with increased probability. + + void nmod_mat_randfull(nmod_mat_t mat, flint_rand_t state) + # Sets the element to random numbers likely to be close to the modulus + # of the matrix. This is used to test potential overflow-related bugs. + + int nmod_mat_randpermdiag(nmod_mat_t mat, flint_rand_t state, mp_srcptr diag, slong n) + # Sets ``mat`` to a random permutation of the diagonal matrix + # with `n` leading entries given by the vector ``diag``. It is + # assumed that the main diagonal of ``mat`` has room for at + # least `n` entries. + # Returns `0` or `1`, depending on whether the permutation is even + # or odd respectively. + + void nmod_mat_randrank(nmod_mat_t mat, flint_rand_t state, slong rank) + # Sets ``mat`` to a random sparse matrix with the given rank, + # having exactly as many non-zero elements as the rank, with the + # non-zero elements being uniformly random integers between `0` + # and `m-1` inclusive, where `m` is the modulus of ``mat``. + # The matrix can be transformed into a dense matrix with unchanged + # rank by subsequently calling :func:`nmod_mat_randops`. + + void nmod_mat_randops(nmod_mat_t mat, slong count, flint_rand_t state) + # Randomises ``mat`` by performing elementary row or column + # operations. More precisely, at most ``count`` random additions + # or subtractions of distinct rows and columns will be performed. + # This leaves the rank (and for square matrices, determinant) + # unchanged. + + void nmod_mat_randtril(nmod_mat_t mat, flint_rand_t state, int unit) + # Sets ``mat`` to a random lower triangular matrix. If ``unit`` is 1, + # it will have ones on the main diagonal, otherwise it will have random + # nonzero entries on the main diagonal. + + void nmod_mat_randtriu(nmod_mat_t mat, flint_rand_t state, int unit) + # Sets ``mat`` to a random upper triangular matrix. If ``unit`` is 1, + # it will have ones on the main diagonal, otherwise it will have random + # nonzero entries on the main diagonal. + + int nmod_mat_equal(const nmod_mat_t mat1, const nmod_mat_t mat2) + # Returns nonzero if ``mat1`` and ``mat2`` have the same dimensions and elements, + # and zero otherwise. The moduli are ignored. + + int nmod_mat_is_zero_row(const nmod_mat_t mat, slong i) + # Returns a non-zero value if row `i` of ``mat`` is zero. + + void nmod_mat_transpose(nmod_mat_t B, const nmod_mat_t A) + # Sets `B` to the transpose of `A`. Dimensions must be compatible. + # `B` and `A` may be the same object if and only if the matrix is square. + + void nmod_mat_swap_rows(nmod_mat_t mat, slong * perm, slong r, slong s) + # Swaps rows ``r`` and ``s`` of ``mat``. If ``perm`` is non-``NULL``, the + # permutation of the rows will also be applied to ``perm``. + + void nmod_mat_swap_cols(nmod_mat_t mat, slong * perm, slong r, slong s) + # Swaps columns ``r`` and ``s`` of ``mat``. If ``perm`` is non-``NULL``, the + # permutation of the columns will also be applied to ``perm``. + + void nmod_mat_invert_rows(nmod_mat_t mat, slong * perm) + # Swaps rows ``i`` and ``r - i`` of ``mat`` for ``0 <= i < r/2``, where + # ``r`` is the number of rows of ``mat``. If ``perm`` is non-``NULL``, the + # permutation of the rows will also be applied to ``perm``. + + void nmod_mat_invert_cols(nmod_mat_t mat, slong * perm) + # Swaps columns ``i`` and ``c - i`` of ``mat`` for ``0 <= i < c/2``, where + # ``c`` is the number of columns of ``mat``. If ``perm`` is non-``NULL``, the + # permutation of the columns will also be applied to ``perm``. + + void nmod_mat_permute_rows(nmod_mat_t mat, const slong * perm_act, slong * perm_store) + # Permutes rows of the matrix ``mat`` according to permutation ``perm_act`` + # and, if ``perm_store`` is not ``NULL``, apply the same permutation to it. + + void nmod_mat_add(nmod_mat_t C, const nmod_mat_t A, const nmod_mat_t B) + # Computes `C = A + B`. Dimensions must be identical. + + void nmod_mat_sub(nmod_mat_t C, const nmod_mat_t A, const nmod_mat_t B) + # Computes `C = A - B`. Dimensions must be identical. + + void nmod_mat_neg(nmod_mat_t A, const nmod_mat_t B) + # Sets `B = -A`. Dimensions must be identical. + + void nmod_mat_scalar_mul(nmod_mat_t B, const nmod_mat_t A, mp_limb_t c) + # Sets `B = cA`, where the scalar `c` is assumed to be reduced + # modulo the modulus. Dimensions of `A` and `B` must be identical. + + void nmod_mat_scalar_addmul_ui(nmod_mat_t dest, const nmod_mat_t X, const nmod_mat_t Y, const mp_limb_t b) + # Sets `dest = X + bY`, where the scalar `b` is assumed to be reduced + # modulo the modulus. Dimensions of dest, X and Y must be identical. + # dest can be aliased with X or Y. + + void nmod_mat_scalar_mul_fmpz(nmod_mat_t res, const nmod_mat_t M, const fmpz_t c) + # Sets `B = cA`, where the scalar `c` is of type ``fmpz_t``. Dimensions of `A` + # and `B` must be identical. + + void nmod_mat_mul(nmod_mat_t C, const nmod_mat_t A, const nmod_mat_t B) + # Sets `C = AB`. Dimensions must be compatible for matrix multiplication. + # Aliasing is allowed. This function automatically chooses between classical + # and Strassen multiplication. + + void _nmod_mat_mul_classical_op(nmod_mat_t D, const nmod_mat_t C, const nmod_mat_t A, const nmod_mat_t B, int op) + + void nmod_mat_mul_classical(nmod_mat_t C, const nmod_mat_t A, const nmod_mat_t B) + # Sets `C = AB`. Dimensions must be compatible for matrix multiplication. + # `C` is not allowed to be aliased with `A` or `B`. Uses classical + # matrix multiplication, creating a temporary transposed copy of `B` + # to improve memory locality if the matrices are large enough, + # and packing several entries of `B` into each word if the modulus + # is very small. + + void _nmod_mat_mul_classical_threaded_pool_op(nmod_mat_t D, const nmod_mat_t C, const nmod_mat_t A, const nmod_mat_t B, int op, thread_pool_handle * threads, slong num_threads) + # Multithreaded version of ``_nmod_mat_mul_classical``. + + void _nmod_mat_mul_classical_threaded_op(nmod_mat_t D, const nmod_mat_t C, const nmod_mat_t A, const nmod_mat_t B, int op) + # Multithreaded version of ``_nmod_mat_mul_classical``. + + void nmod_mat_mul_classical_threaded(nmod_mat_t C, const nmod_mat_t A, const nmod_mat_t B) + # Multithreaded version of ``nmod_mat_mul_classical``. + + void nmod_mat_mul_strassen(nmod_mat_t C, const nmod_mat_t A, const nmod_mat_t B) + # Sets `C = AB`. Dimensions must be compatible for matrix multiplication. + # `C` is not allowed to be aliased with `A` or `B`. Uses Strassen + # multiplication (the Strassen-Winograd variant). + + int nmod_mat_mul_blas(nmod_mat_t C, const nmod_mat_t A, const nmod_mat_t B) + # Tries to set `C = AB` using BLAS and returns `1` for success and `0` for failure. Dimensions must be compatible for matrix multiplication. + + void nmod_mat_addmul(nmod_mat_t D, const nmod_mat_t C, const nmod_mat_t A, const nmod_mat_t B) + # Sets `D = C + AB`. `C` and `D` may be aliased with each other but + # not with `A` or `B`. Automatically selects between classical + # and Strassen multiplication. + + void nmod_mat_submul(nmod_mat_t D, const nmod_mat_t C, const nmod_mat_t A, const nmod_mat_t B) + # Sets `D = C + AB`. `C` and `D` may be aliased with each other but + # not with `A` or `B`. + + void nmod_mat_mul_nmod_vec(mp_limb_t * c, const nmod_mat_t A, const mp_limb_t * b, slong blen) + void nmod_mat_mul_nmod_vec_ptr(mp_limb_t * const * c, const nmod_mat_t A, const mp_limb_t * const * b, slong blen) + # Compute a matrix-vector product of ``A`` and ``(b, blen)`` and store the result in ``c``. + # The vector ``(b, blen)`` is either truncated or zero-extended to the number of columns of ``A``. + # The number entries written to ``c`` is always equal to the number of rows of ``A``. + + void nmod_mat_nmod_vec_mul(mp_limb_t * c, const mp_limb_t * a, slong alen, const nmod_mat_t B) + void nmod_mat_nmod_vec_mul_ptr(mp_limb_t * const * c, const mp_limb_t * const * a, slong alen, const nmod_mat_t B) + # Compute a vector-matrix product of ``(a, alen)`` and ``B`` and and store the result in ``c``. + # The vector ``(a, alen)`` is either truncated or zero-extended to the number of rows of ``B``. + # The number entries written to ``c`` is always equal to the number of columns of ``B``. + + void _nmod_mat_pow(nmod_mat_t dest, const nmod_mat_t mat, ulong pow) + + void nmod_mat_pow(nmod_mat_t dest, const nmod_mat_t mat, ulong pow) + # Sets `dest = mat^{pow}`. ``dest`` and ``mat`` may be aliased. Implements + + mp_limb_t nmod_mat_trace(const nmod_mat_t mat) + # Computes the trace of the matrix, i.e. the sum of the entries on + # the main diagonal. The matrix is required to be square. + + mp_limb_t nmod_mat_det_howell(const nmod_mat_t A) + # Returns the determinant of `A`. + + mp_limb_t nmod_mat_det(const nmod_mat_t A) + # Returns the determinant of `A`. + + slong nmod_mat_rank(const nmod_mat_t A) + # Returns the rank of `A`. The modulus of `A` must be a prime number. + + int nmod_mat_inv(nmod_mat_t B, const nmod_mat_t A) + # Sets `B = A^{-1}` and returns `1` if `A` is invertible. + # If `A` is singular, returns `0` and sets the elements of + # `B` to undefined values. + # `A` and `B` must be square matrices with the same dimensions + # and modulus. The modulus must be prime. + + void nmod_mat_solve_tril(nmod_mat_t X, const nmod_mat_t L, const nmod_mat_t B, int unit) + # Sets `X = L^{-1} B` where `L` is a full rank lower triangular square + # matrix. If ``unit`` = 1, `L` is assumed to have ones on its + # main diagonal, and the main diagonal will not be read. + # `X` and `B` are allowed to be the same matrix, but no other + # aliasing is allowed. Automatically chooses between the classical and + # recursive algorithms. + + void nmod_mat_solve_tril_classical(nmod_mat_t X, const nmod_mat_t L, const nmod_mat_t B, int unit) + # Sets `X = L^{-1} B` where `L` is a full rank lower triangular square + # matrix. If ``unit`` = 1, `L` is assumed to have ones on its + # main diagonal, and the main diagonal will not be read. + # `X` and `B` are allowed to be the same matrix, but no other + # aliasing is allowed. Uses forward substitution. + + void nmod_mat_solve_tril_recursive(nmod_mat_t X, const nmod_mat_t L, const nmod_mat_t B, int unit) + # Sets `X = L^{-1} B` where `L` is a full rank lower triangular square + # matrix. If ``unit`` = 1, `L` is assumed to have ones on its + # main diagonal, and the main diagonal will not be read. + # `X` and `B` are allowed to be the same matrix, but no other + # aliasing is allowed. + # Uses the block inversion formula + # .. math :: + # \begin{pmatrix} A & 0 \\ C & D \end{pmatrix}^{-1} + # \begin{pmatrix} X \\ Y \end{pmatrix} = + # \begin{pmatrix} A^{-1} X \\ D^{-1} ( Y - C A^{-1} X ) \end{pmatrix} + # to reduce the problem to matrix multiplication and triangular solving + # of smaller systems. + + void nmod_mat_solve_triu(nmod_mat_t X, const nmod_mat_t U, const nmod_mat_t B, int unit) + # Sets `X = U^{-1} B` where `U` is a full rank upper triangular square + # matrix. If ``unit`` = 1, `U` is assumed to have ones on its + # main diagonal, and the main diagonal will not be read. + # `X` and `B` are allowed to be the same matrix, but no other + # aliasing is allowed. Automatically chooses between the classical and + # recursive algorithms. + + void nmod_mat_solve_triu_classical(nmod_mat_t X, const nmod_mat_t U, const nmod_mat_t B, int unit) + # Sets `X = U^{-1} B` where `U` is a full rank upper triangular square + # matrix. If ``unit`` = 1, `U` is assumed to have ones on its + # main diagonal, and the main diagonal will not be read. + # `X` and `B` are allowed to be the same matrix, but no other + # aliasing is allowed. Uses forward substitution. + + void nmod_mat_solve_triu_recursive(nmod_mat_t X, const nmod_mat_t U, const nmod_mat_t B, int unit) + # Sets `X = U^{-1} B` where `U` is a full rank upper triangular square + # matrix. If ``unit`` = 1, `U` is assumed to have ones on its + # main diagonal, and the main diagonal will not be read. + # `X` and `B` are allowed to be the same matrix, but no other + # aliasing is allowed. + # Uses the block inversion formula + # .. math :: + # \begin{pmatrix} A & B \\ 0 & D \end{pmatrix}^{-1} + # \begin{pmatrix} X \\ Y \end{pmatrix} = + # \begin{pmatrix} A^{-1} (X - B D^{-1} Y) \\ D^{-1} Y \end{pmatrix} + # to reduce the problem to matrix multiplication and triangular solving + # of smaller systems. + + int nmod_mat_solve(nmod_mat_t X, const nmod_mat_t A, const nmod_mat_t B) + # Solves the matrix-matrix equation `AX = B` over `\mathbb{Z} / p \mathbb{Z}` where `p` + # is the modulus of `X` which must be a prime number. `X`, `A`, and `B` + # should have the same moduli. + # Returns `1` if `A` has full rank; otherwise returns `0` and sets the + # elements of `X` to undefined values. + # The matrix `A` must be square. + + int nmod_mat_can_solve_inner(slong * rank, slong * perm, slong * pivots, nmod_mat_t X, const nmod_mat_t A, const nmod_mat_t B) + # As for :func:`nmod_mat_can_solve` except that if `rank` is not `NULL` the + # value it points to will be set to the rank of `A`. If `perm` is not `NULL` + # then it must be a valid initialised permutation whose length is the number + # of rows of `A`. After the function call it will be set to the row + # permutation given by LU decomposition of `A`. If `pivots` is not `NULL` + # then it must an initialised vector. Only the first `*rank` of these will be + # set by the function call. They are set to the columns of the pivots chosen + # by the LU decomposition of `A`. + + int nmod_mat_can_solve(nmod_mat_t X, const nmod_mat_t A, const nmod_mat_t B) + # Solves the matrix-matrix equation `AX = B` over `\mathbb{Z} / p \mathbb{Z}` where `p` + # is the modulus of `X` which must be a prime number. `X`, `A`, and `B` + # should have the same moduli. + # Returns `1` if a solution exists; otherwise returns `0` and sets the + # elements of `X` to zero. If more than one solution exists, one of the + # valid solutions is given. + # There are no restrictions on the shape of `A` and it may be singular. + + int nmod_mat_solve_vec(mp_ptr x, const nmod_mat_t A, mp_srcptr b) + # Solves the matrix-vector equation `Ax = b` over `\mathbb{Z} / p \mathbb{Z}` where `p` + # is the modulus of `A` which must be a prime number. + # Returns `1` if `A` has full rank; otherwise returns `0` and sets the + # elements of `x` to undefined values. + + slong nmod_mat_lu(slong * P, nmod_mat_t A, int rank_check) + slong nmod_mat_lu_classical(slong * P, nmod_mat_t A, int rank_check) + slong nmod_mat_lu_classical_delayed(slong * P, nmod_mat_t A, int rank_check) + slong nmod_mat_lu_recursive(slong * P, nmod_mat_t A, int rank_check) + # Computes a generalised LU decomposition `LU = PA` of a given + # matrix `A`, returning the rank of `A`. + # If `A` is a nonsingular square matrix, it will be overwritten with + # a unit diagonal lower triangular matrix `L` and an upper triangular + # matrix `U` (the diagonal of `L` will not be stored explicitly). + # If `A` is an arbitrary matrix of rank `r`, `U` will be in row echelon + # form having `r` nonzero rows, and `L` will be lower triangular + # but truncated to `r` columns, having implicit ones on the `r` first + # entries of the main diagonal. All other entries will be zero. + # If a nonzero value for ``rank_check`` is passed, the + # function will abandon the output matrix in an undefined state and + # return 0 if `A` is detected to be rank-deficient. + # The *classical* version uses direct Gaussian elimination. + # The *classical_delayed* version also uses Gaussian elimination, + # but performs delayed modular reductions. + # The *recursive* version uses block recursive decomposition. + # The default function chooses an algorithm automatically. + + slong nmod_mat_rref(nmod_mat_t A) + # Puts `A` in reduced row echelon form and returns the rank of `A`. + # The rref is computed by first obtaining an unreduced row echelon + # form via LU decomposition and then solving an additional + # triangular system. + + slong nmod_mat_reduce_row(nmod_mat_t A, slong * P, slong * L, slong n) + # Reduce row n of the matrix `A`, assuming the prior rows are in Gauss + # form. However those rows may not be in order. The entry `i` of the array + # `P` is the row of `A` which has a pivot in the `i`-th column. If no such + # row exists, the entry of `P` will be `-1`. The function returns the column + # in which the `n`-th row has a pivot after reduction. This will always be + # chosen to be the first available column for a pivot from the left. This + # information is also updated in `P`. Entry `i` of the array `L` contains the + # number of possibly nonzero columns of `A` row `i`. This speeds up reduction + # in the case that `A` is chambered on the right. Otherwise the entries of `L` + # can all be set to the number of columns of `A`. We require the entries of + # `L` to be monotonic increasing. + + slong nmod_mat_nullspace(nmod_mat_t X, const nmod_mat_t A) + # Computes the nullspace of `A` and returns the nullity. + # More precisely, this function sets `X` to a maximum rank matrix + # such that `AX = 0` and returns the rank of `X`. The columns of + # `X` will form a basis for the nullspace of `A`. + # `X` must have sufficient space to store all basis vectors + # in the nullspace. + # This function computes the reduced row echelon form and then reads + # off the basis vectors. + + void nmod_mat_similarity(nmod_mat_t M, slong r, ulong d) + # Applies a similarity transform to the `n\times n` matrix `M` in-place. + # If `P` is the `n\times n` identity matrix the zero entries of whose row + # `r` (`0`-indexed) have been replaced by `d`, this transform is equivalent + # to `M = P^{-1}MP`. + # Similarity transforms preserve the determinant, characteristic polynomial + # and minimal polynomial. + # The value `d` is required to be reduced modulo the modulus of the entries + # in the matrix. + + void nmod_mat_charpoly_berkowitz(nmod_poly_t p, const nmod_mat_t M) + void nmod_mat_charpoly_danilevsky(nmod_poly_t p, const nmod_mat_t M) + void nmod_mat_charpoly(nmod_poly_t p, const nmod_mat_t M) + # Compute the characteristic polynomial `p` of the matrix `M`. The matrix + # is required to be square, otherwise an exception is raised. + # The *danilevsky* algorithm assumes that the modulus is prime. + + void nmod_mat_minpoly(nmod_poly_t p, const nmod_mat_t M) + # Compute the minimal polynomial `p` of the matrix `M`. The matrix + # is required to be square, otherwise an exception is raised. + + void nmod_mat_strong_echelon_form(nmod_mat_t A) + # Puts `A` into strong echelon form. The Howell form and the strong echelon + # form are equal up to permutation of the rows, see [FieHof2014]_ for a + # definition of the strong echelon form and the algorithm used here. + # Note that [FieHof2014]_ defines strong echelon form as a lower left normal form, + # while the implemented version returns an upper right normal form, + # agreeing with the definition of Howell form in [StoMul1998]_. + # `A` must have at least as many rows as columns. + + slong nmod_mat_howell_form(nmod_mat_t A) + # Puts `A` into Howell form and returns the number of non-zero rows. + # For a definition of the Howell form see [StoMul1998]_. The Howell form + # is computed by first putting `A` into strong echelon form and then ordering + # the rows. + # `A` must have at least as many rows as columns. diff --git a/src/sage/libs/flint/nmod_mpoly.pxd b/src/sage/libs/flint/nmod_mpoly.pxd index bd76005f0e1..815dfb7dcb2 100644 --- a/src/sage/libs/flint/nmod_mpoly.pxd +++ b/src/sage/libs/flint/nmod_mpoly.pxd @@ -12,12 +12,12 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void nmod_mpoly_ctx_init(nmod_mpoly_ctx_t ctx, long nvars, const ordering_t ord, mp_limb_t n) + void nmod_mpoly_ctx_init(nmod_mpoly_ctx_t ctx, slong nvars, const ordering_t ord, mp_limb_t n) # Initialise a context object for a polynomial ring with the given number of variables and the given ordering. # It will have coefficients modulo *n*. Setting `n = 0` will give undefined behavior. # The possibilities for the ordering are ``ORD_LEX``, ``ORD_DEGLEX`` and ``ORD_DEGREVLEX``. - long nmod_mpoly_ctx_nvars(const nmod_mpoly_ctx_t ctx) + slong nmod_mpoly_ctx_nvars(const nmod_mpoly_ctx_t ctx) # Return the number of variables used to initialize the context. ordering_t nmod_mpoly_ctx_ord(const nmod_mpoly_ctx_t ctx) @@ -32,18 +32,18 @@ cdef extern from "flint_wrap.h": void nmod_mpoly_init(nmod_mpoly_t A, const nmod_mpoly_ctx_t ctx) # Initialise *A* for use with the given an initialised context object. Its value is set to zero. - void nmod_mpoly_init2(nmod_mpoly_t A, long alloc, const nmod_mpoly_ctx_t ctx) + void nmod_mpoly_init2(nmod_mpoly_t A, slong alloc, const nmod_mpoly_ctx_t ctx) # Initialise *A* for use with the given an initialised context object. Its value is set to zero. # It is allocated with space for *alloc* terms and at least ``MPOLY_MIN_BITS`` bits for the exponent widths. - void nmod_mpoly_init3(nmod_mpoly_t A, long alloc, flint_bitcnt_t bits, const nmod_mpoly_ctx_t ctx) + void nmod_mpoly_init3(nmod_mpoly_t A, slong alloc, flint_bitcnt_t bits, const nmod_mpoly_ctx_t ctx) # Initialise *A* for use with the given an initialised context object. Its value is set to zero. # It is allocated with space for *alloc* terms and *bits* bits for the exponents. - void nmod_mpoly_fit_length(nmod_mpoly_t A, long len, const nmod_mpoly_ctx_t ctx) + void nmod_mpoly_fit_length(nmod_mpoly_t A, slong len, const nmod_mpoly_ctx_t ctx) # Ensure that *A* has space for at least *len* terms. - void nmod_mpoly_realloc(nmod_mpoly_t A, long alloc, const nmod_mpoly_ctx_t ctx) + void nmod_mpoly_realloc(nmod_mpoly_t A, slong alloc, const nmod_mpoly_ctx_t ctx) # Reallocate *A* to have space for *alloc* terms. # Assumes the current length of the polynomial is not greater than *alloc*. @@ -65,10 +65,10 @@ cdef extern from "flint_wrap.h": # The operations ``+``, ``-``, ``*``, and ``/`` are permitted along with integers and the variables in *x*. The character ``^`` must be immediately followed by the (integer) exponent. # If any division is not exact, parsing fails. - void nmod_mpoly_gen(nmod_mpoly_t A, long var, const nmod_mpoly_ctx_t ctx) + void nmod_mpoly_gen(nmod_mpoly_t A, slong var, const nmod_mpoly_ctx_t ctx) # Set *A* to the variable of index *var*, where `var = 0` corresponds to the variable with the most significance with respect to the ordering. - int nmod_mpoly_is_gen(const nmod_mpoly_t A, long var, const nmod_mpoly_ctx_t ctx) + int nmod_mpoly_is_gen(const nmod_mpoly_t A, slong var, const nmod_mpoly_ctx_t ctx) # If `var \ge 0`, return `1` if *A* is equal to the `var`-th generator, otherwise return `0`. # If `var < 0`, return `1` if the polynomial is equal to any generator, otherwise return `0`. @@ -84,11 +84,11 @@ cdef extern from "flint_wrap.h": int nmod_mpoly_is_ui(const nmod_mpoly_t A, const nmod_mpoly_ctx_t ctx) # Return `1` if *A* is a constant, else return `0`. - unsigned long nmod_mpoly_get_ui(const nmod_mpoly_t A, const nmod_mpoly_ctx_t ctx) + ulong nmod_mpoly_get_ui(const nmod_mpoly_t A, const nmod_mpoly_ctx_t ctx) # Assuming that *A* is a constant, return this constant. # This function throws if *A* is not a constant. - void nmod_mpoly_set_ui(nmod_mpoly_t A, unsigned long c, const nmod_mpoly_ctx_t ctx) + void nmod_mpoly_set_ui(nmod_mpoly_t A, ulong c, const nmod_mpoly_ctx_t ctx) # Set *A* to the constant *c*. void nmod_mpoly_zero(nmod_mpoly_t A, const nmod_mpoly_ctx_t ctx) @@ -97,7 +97,7 @@ cdef extern from "flint_wrap.h": void nmod_mpoly_one(nmod_mpoly_t A, const nmod_mpoly_ctx_t ctx) # Set *A* to the constant `1`. - int nmod_mpoly_equal_ui(const nmod_mpoly_t A, unsigned long c, const nmod_mpoly_ctx_t ctx) + int nmod_mpoly_equal_ui(const nmod_mpoly_t A, ulong c, const nmod_mpoly_ctx_t ctx) # Return `1` if *A* is equal to the constant *c*, else return `0`. int nmod_mpoly_is_zero(const nmod_mpoly_t A, const nmod_mpoly_ctx_t ctx) @@ -110,12 +110,12 @@ cdef extern from "flint_wrap.h": # Return `1` if the degrees of *A* with respect to each variable fit into an ``slong``, otherwise return `0`. void nmod_mpoly_degrees_fmpz(fmpz ** degs, const nmod_mpoly_t A, const nmod_mpoly_ctx_t ctx) - void nmod_mpoly_degrees_si(long * degs, const nmod_mpoly_t A, const nmod_mpoly_ctx_t ctx) + void nmod_mpoly_degrees_si(slong * degs, const nmod_mpoly_t A, const nmod_mpoly_ctx_t ctx) # Set *degs* to the degrees of *A* with respect to each variable. # If *A* is zero, all degrees are set to `-1`. - void nmod_mpoly_degree_fmpz(fmpz_t deg, const nmod_mpoly_t A, long var, const nmod_mpoly_ctx_t ctx) - long nmod_mpoly_degree_si(const nmod_mpoly_t A, long var, const nmod_mpoly_ctx_t ctx) + void nmod_mpoly_degree_fmpz(fmpz_t deg, const nmod_mpoly_t A, slong var, const nmod_mpoly_ctx_t ctx) + slong nmod_mpoly_degree_si(const nmod_mpoly_t A, slong var, const nmod_mpoly_ctx_t ctx) # Either return or set *deg* to the degree of *A* with respect to the variable of index *var*. # If *A* is zero, the degree is defined to be `-1`. @@ -123,30 +123,30 @@ cdef extern from "flint_wrap.h": # Return `1` if the total degree of *A* fits into an ``slong``, otherwise return `0`. void nmod_mpoly_total_degree_fmpz(fmpz_t tdeg, const nmod_mpoly_t A, const nmod_mpoly_ctx_t ctx) - long nmod_mpoly_total_degree_si(const nmod_mpoly_t A, const nmod_mpoly_ctx_t ctx) + slong nmod_mpoly_total_degree_si(const nmod_mpoly_t A, const nmod_mpoly_ctx_t ctx) # Either return or set *tdeg* to the total degree of *A*. # If *A* is zero, the total degree is defined to be `-1`. void nmod_mpoly_used_vars(int * used, const nmod_mpoly_t A, const nmod_mpoly_ctx_t ctx) # For each variable index *i*, set ``used[i]`` to nonzero if the variable of index *i* appears in *A* and to zero otherwise. - unsigned long nmod_mpoly_get_coeff_ui_monomial(const nmod_mpoly_t A, const nmod_mpoly_t M, const nmod_mpoly_ctx_t ctx) + ulong nmod_mpoly_get_coeff_ui_monomial(const nmod_mpoly_t A, const nmod_mpoly_t M, const nmod_mpoly_ctx_t ctx) # Assuming that *M* is a monomial, return the coefficient of the corresponding monomial in *A*. # This function throws if *M* is not a monomial. - void nmod_mpoly_set_coeff_ui_monomial(nmod_mpoly_t A, unsigned long c, const nmod_mpoly_t M, const nmod_mpoly_ctx_t ctx) + void nmod_mpoly_set_coeff_ui_monomial(nmod_mpoly_t A, ulong c, const nmod_mpoly_t M, const nmod_mpoly_ctx_t ctx) # Assuming that *M* is a monomial, set the coefficient of the corresponding monomial in *A* to *c*. # This function throws if *M* is not a monomial. - unsigned long nmod_mpoly_get_coeff_ui_fmpz(const nmod_mpoly_t A, fmpz * const * exp, const nmod_mpoly_ctx_t ctx) - unsigned long nmod_mpoly_get_coeff_ui_ui(const nmod_mpoly_t A, const unsigned long * exp, const nmod_mpoly_ctx_t ctx) + ulong nmod_mpoly_get_coeff_ui_fmpz(const nmod_mpoly_t A, fmpz * const * exp, const nmod_mpoly_ctx_t ctx) + ulong nmod_mpoly_get_coeff_ui_ui(const nmod_mpoly_t A, const ulong * exp, const nmod_mpoly_ctx_t ctx) # Return the coefficient of the monomial with exponent *exp*. - void nmod_mpoly_set_coeff_ui_fmpz(nmod_mpoly_t A, unsigned long c, fmpz * const * exp, const nmod_mpoly_ctx_t ctx) - void nmod_mpoly_set_coeff_ui_ui(nmod_mpoly_t A, unsigned long c, const unsigned long * exp, const nmod_mpoly_ctx_t ctx) + void nmod_mpoly_set_coeff_ui_fmpz(nmod_mpoly_t A, ulong c, fmpz * const * exp, const nmod_mpoly_ctx_t ctx) + void nmod_mpoly_set_coeff_ui_ui(nmod_mpoly_t A, ulong c, const ulong * exp, const nmod_mpoly_ctx_t ctx) # Set the coefficient of the monomial with exponent *exp* to `c`. - void nmod_mpoly_get_coeff_vars_ui(nmod_mpoly_t C, const nmod_mpoly_t A, const long * vars, const unsigned long * exps, long length, const nmod_mpoly_ctx_t ctx) + void nmod_mpoly_get_coeff_vars_ui(nmod_mpoly_t C, const nmod_mpoly_t A, const slong * vars, const ulong * exps, slong length, const nmod_mpoly_ctx_t ctx) # Set *C* to the coefficient of *A* with respect to the variables in *vars* with powers in the corresponding array *exps*. # Both *vars* and *exps* point to array of length *length*. It is assumed that ``0 < length \le nvars(A)`` and that the variables in *vars* are distinct. @@ -154,56 +154,56 @@ cdef extern from "flint_wrap.h": # Return `1` (resp. `-1`, or `0`) if *A* is after (resp. before, same as) *B* in some arbitrary but fixed total ordering of the polynomials. # This ordering agrees with the usual ordering of monomials when *A* and *B* are both monomials. - mp_limb_t * nmod_mpoly_term_coeff_ref(nmod_mpoly_t A, long i, const nmod_mpoly_ctx_t ctx) + mp_limb_t * nmod_mpoly_term_coeff_ref(nmod_mpoly_t A, slong i, const nmod_mpoly_ctx_t ctx) # Return a reference to the coefficient of index *i* of *A*. int nmod_mpoly_is_canonical(const nmod_mpoly_t A, const nmod_mpoly_ctx_t ctx) # Return `1` if *A* is in canonical form. Otherwise, return `0`. # To be in canonical form, all of the terms must have nonzero coefficients, and the terms must be sorted from greatest to least. - long nmod_mpoly_length(const nmod_mpoly_t A, const nmod_mpoly_ctx_t ctx) + slong nmod_mpoly_length(const nmod_mpoly_t A, const nmod_mpoly_ctx_t ctx) # Return the number of terms in *A*. # If the polynomial is in canonical form, this will be the number of nonzero coefficients. - void nmod_mpoly_resize(nmod_mpoly_t A, long new_length, const nmod_mpoly_ctx_t ctx) + void nmod_mpoly_resize(nmod_mpoly_t A, slong new_length, const nmod_mpoly_ctx_t ctx) # Set the length of *A* to ``new_length``. # Terms are either deleted from the end, or new zero terms are appended. - unsigned long nmod_mpoly_get_term_coeff_ui(const nmod_mpoly_t A, long i, const nmod_mpoly_ctx_t ctx) + ulong nmod_mpoly_get_term_coeff_ui(const nmod_mpoly_t A, slong i, const nmod_mpoly_ctx_t ctx) # Return the coefficient of the term of index *i*. - void nmod_mpoly_set_term_coeff_ui(nmod_mpoly_t A, long i, unsigned long c, const nmod_mpoly_ctx_t ctx) + void nmod_mpoly_set_term_coeff_ui(nmod_mpoly_t A, slong i, ulong c, const nmod_mpoly_ctx_t ctx) # Set the coefficient of the term of index *i* to *c*. - int nmod_mpoly_term_exp_fits_si(const nmod_mpoly_t A, long i, const nmod_mpoly_ctx_t ctx) - int nmod_mpoly_term_exp_fits_ui(const nmod_mpoly_t A, long i, const nmod_mpoly_ctx_t ctx) + int nmod_mpoly_term_exp_fits_si(const nmod_mpoly_t A, slong i, const nmod_mpoly_ctx_t ctx) + int nmod_mpoly_term_exp_fits_ui(const nmod_mpoly_t A, slong i, const nmod_mpoly_ctx_t ctx) # Return `1` if all entries of the exponent vector of the term of index *i* fit into an ``slong`` (resp. a ``ulong``). Otherwise, return `0`. - void nmod_mpoly_get_term_exp_fmpz(fmpz ** exp, const nmod_mpoly_t A, long i, const nmod_mpoly_ctx_t ctx) - void nmod_mpoly_get_term_exp_ui(unsigned long * exp, const nmod_mpoly_t A, long i, const nmod_mpoly_ctx_t ctx) + void nmod_mpoly_get_term_exp_fmpz(fmpz ** exp, const nmod_mpoly_t A, slong i, const nmod_mpoly_ctx_t ctx) + void nmod_mpoly_get_term_exp_ui(ulong * exp, const nmod_mpoly_t A, slong i, const nmod_mpoly_ctx_t ctx) - void nmod_mpoly_get_term_exp_si(long * exp, const nmod_mpoly_t A, long i, const nmod_mpoly_ctx_t ctx) + void nmod_mpoly_get_term_exp_si(slong * exp, const nmod_mpoly_t A, slong i, const nmod_mpoly_ctx_t ctx) # Set *exp* to the exponent vector of the term of index *i*. # The ``_ui`` (resp. ``_si``) version throws if any entry does not fit into a ``ulong`` (resp. ``slong``). - unsigned long nmod_mpoly_get_term_var_exp_ui(const nmod_mpoly_t A, long i, long var, const nmod_mpoly_ctx_t ctx) - long nmod_mpoly_get_term_var_exp_si(const nmod_mpoly_t A, long i, long var, const nmod_mpoly_ctx_t ctx) + ulong nmod_mpoly_get_term_var_exp_ui(const nmod_mpoly_t A, slong i, slong var, const nmod_mpoly_ctx_t ctx) + slong nmod_mpoly_get_term_var_exp_si(const nmod_mpoly_t A, slong i, slong var, const nmod_mpoly_ctx_t ctx) # Return the exponent of the variable *var* of the term of index *i*. # This function throws if the exponent does not fit into a ``ulong`` (resp. ``slong``). - void nmod_mpoly_set_term_exp_fmpz(nmod_mpoly_t A, long i, fmpz * const * exp, const nmod_mpoly_ctx_t ctx) - void nmod_mpoly_set_term_exp_ui(nmod_mpoly_t A, long i, const unsigned long * exp, const nmod_mpoly_ctx_t ctx) + void nmod_mpoly_set_term_exp_fmpz(nmod_mpoly_t A, slong i, fmpz * const * exp, const nmod_mpoly_ctx_t ctx) + void nmod_mpoly_set_term_exp_ui(nmod_mpoly_t A, slong i, const ulong * exp, const nmod_mpoly_ctx_t ctx) # Set the exponent of the term of index *i* to *exp*. - void nmod_mpoly_get_term(nmod_mpoly_t M, const nmod_mpoly_t A, long i, const nmod_mpoly_ctx_t ctx) + void nmod_mpoly_get_term(nmod_mpoly_t M, const nmod_mpoly_t A, slong i, const nmod_mpoly_ctx_t ctx) # Set *M* to the term of index *i* in *A*. - void nmod_mpoly_get_term_monomial(nmod_mpoly_t M, const nmod_mpoly_t A, long i, const nmod_mpoly_ctx_t ctx) + void nmod_mpoly_get_term_monomial(nmod_mpoly_t M, const nmod_mpoly_t A, slong i, const nmod_mpoly_ctx_t ctx) # Set *M* to the monomial of the term of index *i* in *A*. The coefficient of *M* will be one. - void nmod_mpoly_push_term_ui_fmpz(nmod_mpoly_t A, unsigned long c, fmpz * const * exp, const nmod_mpoly_ctx_t ctx) - void nmod_mpoly_push_term_ui_ffmpz(nmod_mpoly_t A, unsigned long c, const fmpz * exp, const nmod_mpoly_ctx_t ctx) - void nmod_mpoly_push_term_ui_ui(nmod_mpoly_t A, unsigned long c, const unsigned long * exp, const nmod_mpoly_ctx_t ctx) + void nmod_mpoly_push_term_ui_fmpz(nmod_mpoly_t A, ulong c, fmpz * const * exp, const nmod_mpoly_ctx_t ctx) + void nmod_mpoly_push_term_ui_ffmpz(nmod_mpoly_t A, ulong c, const fmpz * exp, const nmod_mpoly_ctx_t ctx) + void nmod_mpoly_push_term_ui_ui(nmod_mpoly_t A, ulong c, const ulong * exp, const nmod_mpoly_ctx_t ctx) # Append a term to *A* with coefficient *c* and exponent vector *exp*. # This function runs in constant average time. @@ -220,21 +220,21 @@ cdef extern from "flint_wrap.h": void nmod_mpoly_reverse(nmod_mpoly_t A, const nmod_mpoly_t B, const nmod_mpoly_ctx_t ctx) # Set *A* to the reversal of *B*. - void nmod_mpoly_randtest_bound(nmod_mpoly_t A, flint_rand_t state, long length, unsigned long exp_bound, const nmod_mpoly_ctx_t ctx) + void nmod_mpoly_randtest_bound(nmod_mpoly_t A, flint_rand_t state, slong length, ulong exp_bound, const nmod_mpoly_ctx_t ctx) # Generate a random polynomial with length up to *length* and exponents in the range ``[0, exp_bound - 1]``. # The exponents of each variable are generated by calls to ``n_randint(state, exp_bound)``. - void nmod_mpoly_randtest_bounds(nmod_mpoly_t A, flint_rand_t state, long length, unsigned long * exp_bounds, const nmod_mpoly_ctx_t ctx) + void nmod_mpoly_randtest_bounds(nmod_mpoly_t A, flint_rand_t state, slong length, ulong * exp_bounds, const nmod_mpoly_ctx_t ctx) # Generate a random polynomial with length up to *length* and exponents in the range ``[0, exp_bounds[i] - 1]``. # The exponents of the variable of index *i* are generated by calls to ``n_randint(state, exp_bounds[i])``. - void nmod_mpoly_randtest_bits(nmod_mpoly_t A, flint_rand_t state, long length, mp_limb_t exp_bits, const nmod_mpoly_ctx_t ctx) + void nmod_mpoly_randtest_bits(nmod_mpoly_t A, flint_rand_t state, slong length, mp_limb_t exp_bits, const nmod_mpoly_ctx_t ctx) # Generate a random polynomial with length up to *length* and exponents whose packed form does not exceed the given bit count. - void nmod_mpoly_add_ui(nmod_mpoly_t A, const nmod_mpoly_t B, unsigned long c, const nmod_mpoly_ctx_t ctx) + void nmod_mpoly_add_ui(nmod_mpoly_t A, const nmod_mpoly_t B, ulong c, const nmod_mpoly_ctx_t ctx) # Set *A* to `B + c`. - void nmod_mpoly_sub_ui(nmod_mpoly_t A, const nmod_mpoly_t B, unsigned long c, const nmod_mpoly_ctx_t ctx) + void nmod_mpoly_sub_ui(nmod_mpoly_t A, const nmod_mpoly_t B, ulong c, const nmod_mpoly_ctx_t ctx) # Set *A* to `B - c`. void nmod_mpoly_add(nmod_mpoly_t A, const nmod_mpoly_t B, const nmod_mpoly_t C, const nmod_mpoly_ctx_t ctx) @@ -246,20 +246,20 @@ cdef extern from "flint_wrap.h": void nmod_mpoly_neg(nmod_mpoly_t A, const nmod_mpoly_t B, const nmod_mpoly_ctx_t ctx) # Set *A* to `-B`. - void nmod_mpoly_scalar_mul_ui(nmod_mpoly_t A, const nmod_mpoly_t B, unsigned long c, const nmod_mpoly_ctx_t ctx) + void nmod_mpoly_scalar_mul_ui(nmod_mpoly_t A, const nmod_mpoly_t B, ulong c, const nmod_mpoly_ctx_t ctx) # Set *A* to `B \times c`. void nmod_mpoly_make_monic(nmod_mpoly_t A, const nmod_mpoly_t B, const nmod_mpoly_ctx_t ctx) # Set *A* to *B* divided by the leading coefficient of *B*. # This throws if *B* is zero or the leading coefficient is not invertible. - void nmod_mpoly_derivative(nmod_mpoly_t A, const nmod_mpoly_t B, long var, const nmod_mpoly_ctx_t ctx) + void nmod_mpoly_derivative(nmod_mpoly_t A, const nmod_mpoly_t B, slong var, const nmod_mpoly_ctx_t ctx) # Set *A* to the derivative of *B* with respect to the variable of index *var*. - unsigned long nmod_mpoly_evaluate_all_ui(const nmod_mpoly_t A, const unsigned long * vals, const nmod_mpoly_ctx_t ctx) + ulong nmod_mpoly_evaluate_all_ui(const nmod_mpoly_t A, const ulong * vals, const nmod_mpoly_ctx_t ctx) # Return the evaluation of *A* where the variables are replaced by the corresponding elements of the array *vals*. - void nmod_mpoly_evaluate_one_ui(nmod_mpoly_t A, const nmod_mpoly_t B, long var, unsigned long val, const nmod_mpoly_ctx_t ctx) + void nmod_mpoly_evaluate_one_ui(nmod_mpoly_t A, const nmod_mpoly_t B, slong var, ulong val, const nmod_mpoly_ctx_t ctx) # Set *A* to the evaluation of *B* where the variable of index *var* is replaced by *val*. int nmod_mpoly_compose_nmod_poly(nmod_poly_t A, const nmod_mpoly_t B, nmod_poly_struct * const * C, const nmod_mpoly_ctx_t ctx) @@ -276,7 +276,7 @@ cdef extern from "flint_wrap.h": # Return `1` for success and `0` for failure. # The main method attempts to perform the calculation using matrices and chooses heuristically between the ``geobucket`` and ``horner`` methods if needed. - void nmod_mpoly_compose_nmod_mpoly_gen(nmod_mpoly_t A, const nmod_mpoly_t B, const long * c, const nmod_mpoly_ctx_t ctxB, const nmod_mpoly_ctx_t ctxAC) + void nmod_mpoly_compose_nmod_mpoly_gen(nmod_mpoly_t A, const nmod_mpoly_t B, const slong * c, const nmod_mpoly_ctx_t ctxB, const nmod_mpoly_ctx_t ctxAC) # Set *A* to the evaluation of *B* where the variable of index *i* in *ctxB* is replaced by the variable of index ``c[i]`` in *ctxAC*. # The length of the array *C* is the number of variables in *ctxB*. # If any ``c[i]`` is negative, the corresponding variable of *B* is replaced by zero. Otherwise, it is expected that ``c[i]`` is less than the number of variables in *ctxAC*. @@ -303,7 +303,7 @@ cdef extern from "flint_wrap.h": # Set *A* to *B* raised to the *k*-th power. # Return `1` for success and `0` for failure. - int nmod_mpoly_pow_ui(nmod_mpoly_t A, const nmod_mpoly_t B, unsigned long k, const nmod_mpoly_ctx_t ctx) + int nmod_mpoly_pow_ui(nmod_mpoly_t A, const nmod_mpoly_t B, ulong k, const nmod_mpoly_ctx_t ctx) # Set *A* to *B* raised to the *k*-th power. # Return `1` for success and `0` for failure. @@ -317,7 +317,7 @@ cdef extern from "flint_wrap.h": void nmod_mpoly_divrem(nmod_mpoly_t Q, nmod_mpoly_t R, const nmod_mpoly_t A, const nmod_mpoly_t B, const nmod_mpoly_ctx_t ctx) # Set *Q* and *R* to the quotient and remainder of *A* divided by *B*. - void nmod_mpoly_divrem_ideal(nmod_mpoly_struct ** Q, nmod_mpoly_t R, const nmod_mpoly_t A, nmod_mpoly_struct * const * B, long len, const nmod_mpoly_ctx_t ctx) + void nmod_mpoly_divrem_ideal(nmod_mpoly_struct ** Q, nmod_mpoly_t R, const nmod_mpoly_t A, nmod_mpoly_struct * const * B, slong len, const nmod_mpoly_ctx_t ctx) # This function is as per :func:`nmod_mpoly_divrem` except that it takes an array of divisor polynomials *B* and it returns an array of quotient polynomials *Q*. # The number of divisor (and hence quotient) polynomials, is given by *len*. @@ -336,7 +336,7 @@ cdef extern from "flint_wrap.h": # Set *M* to the GCD of the terms of *A*. # If *A* is zero, *M* will be zero. Otherwise, *M* will be a monomial with coefficient one. - int nmod_mpoly_content_vars(nmod_mpoly_t g, const nmod_mpoly_t A, long * vars, long vars_length, const nmod_mpoly_ctx_t ctx) + int nmod_mpoly_content_vars(nmod_mpoly_t g, const nmod_mpoly_t A, slong * vars, slong vars_length, const nmod_mpoly_ctx_t ctx) # Set *g* to the GCD of the coefficients of *A* when viewed as a polynomial in the variables *vars*. # Return `1` for success and `0` for failure. Upon success, *g* will be independent of the variables *vars*. @@ -352,10 +352,10 @@ cdef extern from "flint_wrap.h": int nmod_mpoly_gcd_zippel(nmod_mpoly_t G, const nmod_mpoly_t A, const nmod_mpoly_t B, const nmod_mpoly_ctx_t ctx) # Try to set *G* to the GCD of *A* and *B* using various algorithms. - int nmod_mpoly_resultant(nmod_mpoly_t R, const nmod_mpoly_t A, const nmod_mpoly_t B, long var, const nmod_mpoly_ctx_t ctx) + int nmod_mpoly_resultant(nmod_mpoly_t R, const nmod_mpoly_t A, const nmod_mpoly_t B, slong var, const nmod_mpoly_ctx_t ctx) # Try to set *R* to the resultant of *A* and *B* with respect to the variable of index *var*. - int nmod_mpoly_discriminant(nmod_mpoly_t D, const nmod_mpoly_t A, long var, const nmod_mpoly_ctx_t ctx) + int nmod_mpoly_discriminant(nmod_mpoly_t D, const nmod_mpoly_t A, slong var, const nmod_mpoly_ctx_t ctx) # Try to set *D* to the discriminant of *A* with respect to the variable of index *var*. int nmod_mpoly_sqrt(nmod_mpoly_t Q, const nmod_mpoly_t A, const nmod_mpoly_ctx_t ctx) @@ -376,28 +376,28 @@ cdef extern from "flint_wrap.h": void nmod_mpoly_univar_swap(nmod_mpoly_univar_t A, nmod_mpoly_univar_t B, const nmod_mpoly_ctx_t ctx) # Swap *A* and *B*. - void nmod_mpoly_to_univar(nmod_mpoly_univar_t A, const nmod_mpoly_t B, long var, const nmod_mpoly_ctx_t ctx) + void nmod_mpoly_to_univar(nmod_mpoly_univar_t A, const nmod_mpoly_t B, slong var, const nmod_mpoly_ctx_t ctx) # Set *A* to a univariate form of *B* by pulling out the variable of index *var*. # The coefficients of *A* will still belong to the content *ctx* but will not depend on the variable of index *var*. - void nmod_mpoly_from_univar(nmod_mpoly_t A, const nmod_mpoly_univar_t B, long var, const nmod_mpoly_ctx_t ctx) + void nmod_mpoly_from_univar(nmod_mpoly_t A, const nmod_mpoly_univar_t B, slong var, const nmod_mpoly_ctx_t ctx) # Set *A* to the normal form of *B* by putting in the variable of index *var*. # This function is undefined if the coefficients of *B* depend on the variable of index *var*. int nmod_mpoly_univar_degree_fits_si(const nmod_mpoly_univar_t A, const nmod_mpoly_ctx_t ctx) # Return `1` if the degree of *A* with respect to the main variable fits an ``slong``. Otherwise, return `0`. - long nmod_mpoly_univar_length(const nmod_mpoly_univar_t A, const nmod_mpoly_ctx_t ctx) + slong nmod_mpoly_univar_length(const nmod_mpoly_univar_t A, const nmod_mpoly_ctx_t ctx) # Return the number of terms in *A* with respect to the main variable. - long nmod_mpoly_univar_get_term_exp_si(nmod_mpoly_univar_t A, long i, const nmod_mpoly_ctx_t ctx) + slong nmod_mpoly_univar_get_term_exp_si(nmod_mpoly_univar_t A, slong i, const nmod_mpoly_ctx_t ctx) # Return the exponent of the term of index *i* of *A*. - void nmod_mpoly_univar_get_term_coeff(nmod_mpoly_t c, const nmod_mpoly_univar_t A, long i, const nmod_mpoly_ctx_t ctx) - void nmod_mpoly_univar_swap_term_coeff(nmod_mpoly_t c, nmod_mpoly_univar_t A, long i, const nmod_mpoly_ctx_t ctx) + void nmod_mpoly_univar_get_term_coeff(nmod_mpoly_t c, const nmod_mpoly_univar_t A, slong i, const nmod_mpoly_ctx_t ctx) + void nmod_mpoly_univar_swap_term_coeff(nmod_mpoly_t c, nmod_mpoly_univar_t A, slong i, const nmod_mpoly_ctx_t ctx) # Set (resp. swap) *c* to (resp. with) the coefficient of the term of index *i* of *A*. - void nmod_mpoly_pow_rmul(nmod_mpoly_t A, const nmod_mpoly_t B, unsigned long k, const nmod_mpoly_ctx_t ctx) + void nmod_mpoly_pow_rmul(nmod_mpoly_t A, const nmod_mpoly_t B, ulong k, const nmod_mpoly_ctx_t ctx) # Set *A* to *B* raised to the *k*-th power using repeated multiplications. void nmod_mpoly_div_monagan_pearce(nmod_mpoly_t polyq, const nmod_mpoly_t poly2, const nmod_mpoly_t poly3, const nmod_mpoly_ctx_t ctx) @@ -415,7 +415,7 @@ cdef extern from "flint_wrap.h": # division using dynamic arrays, heaps and packed exponents" by Michael # Monagan and Roman Pearce. - void nmod_mpoly_divrem_ideal_monagan_pearce(nmod_mpoly_struct ** q, nmod_mpoly_t r, const nmod_mpoly_t poly2, nmod_mpoly_struct * const * poly3, long len, const nmod_mpoly_ctx_t ctx) + void nmod_mpoly_divrem_ideal_monagan_pearce(nmod_mpoly_struct ** q, nmod_mpoly_t r, const nmod_mpoly_t poly2, nmod_mpoly_struct * const * poly3, slong len, const nmod_mpoly_ctx_t ctx) # This function is as per ``nmod_mpoly_divrem_monagan_pearce`` except # that it takes an array of divisor polynomials ``poly3``, and it returns # an array of quotient polynomials ``q``. The number of divisor (and hence diff --git a/src/sage/libs/flint/nmod_mpoly_factor.pxd b/src/sage/libs/flint/nmod_mpoly_factor.pxd index b9fd8aa4937..50f70e80748 100644 --- a/src/sage/libs/flint/nmod_mpoly_factor.pxd +++ b/src/sage/libs/flint/nmod_mpoly_factor.pxd @@ -21,17 +21,17 @@ cdef extern from "flint_wrap.h": void nmod_mpoly_factor_swap(nmod_mpoly_factor_t f, nmod_mpoly_factor_t g, const nmod_mpoly_ctx_t ctx) # Efficiently swap *f* and *g*. - long nmod_mpoly_factor_length(const nmod_mpoly_factor_t f, const nmod_mpoly_ctx_t ctx) + slong nmod_mpoly_factor_length(const nmod_mpoly_factor_t f, const nmod_mpoly_ctx_t ctx) # Return the length of the product in *f*. - unsigned long nmod_mpoly_factor_get_constant_ui(const nmod_mpoly_factor_t f, const nmod_mpoly_ctx_t ctx) + ulong nmod_mpoly_factor_get_constant_ui(const nmod_mpoly_factor_t f, const nmod_mpoly_ctx_t ctx) # Return the constant of *f*. - void nmod_mpoly_factor_get_base(nmod_mpoly_t p, const nmod_mpoly_factor_t f, long i, const nmod_mpoly_ctx_t ctx) - void nmod_mpoly_factor_swap_base(nmod_mpoly_t p, nmod_mpoly_factor_t f, long i, const nmod_mpoly_ctx_t ctx) + void nmod_mpoly_factor_get_base(nmod_mpoly_t p, const nmod_mpoly_factor_t f, slong i, const nmod_mpoly_ctx_t ctx) + void nmod_mpoly_factor_swap_base(nmod_mpoly_t p, nmod_mpoly_factor_t f, slong i, const nmod_mpoly_ctx_t ctx) # Set (resp. swap) *B* to (resp. with) the base of the term of index `i` in *A*. - long nmod_mpoly_factor_get_exp_si(nmod_mpoly_factor_t f, long i, const nmod_mpoly_ctx_t ctx) + slong nmod_mpoly_factor_get_exp_si(nmod_mpoly_factor_t f, slong i, const nmod_mpoly_ctx_t ctx) # Return the exponent of the term of index `i` in *A*. It is assumed to fit an ``slong``. void nmod_mpoly_factor_sort(nmod_mpoly_factor_t f, const nmod_mpoly_ctx_t ctx) diff --git a/src/sage/libs/flint/nmod_poly.pxd b/src/sage/libs/flint/nmod_poly.pxd index fdf00910a16..bae767aca2f 100644 --- a/src/sage/libs/flint/nmod_poly.pxd +++ b/src/sage/libs/flint/nmod_poly.pxd @@ -12,7 +12,7 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - int signed_mpn_sub_n(mp_ptr res, mp_srcptr op1, mp_srcptr op2, long n) + int signed_mpn_sub_n(mp_ptr res, mp_srcptr op1, mp_srcptr op2, slong n) # If ``op1 >= op2`` return 0 and set ``res`` to ``op1 - op2`` # else return 1 and set ``res`` to ``op2 - op1``. @@ -27,17 +27,17 @@ cdef extern from "flint_wrap.h": void nmod_poly_init_mod(nmod_poly_t poly, const nmod_t mod) # Initialises ``poly`` using an already initialised modulus ``mod``. - void nmod_poly_init2(nmod_poly_t poly, mp_limb_t n, long alloc) + void nmod_poly_init2(nmod_poly_t poly, mp_limb_t n, slong alloc) # Initialises ``poly``. It will have coefficients modulo `n`. # Up to ``alloc`` coefficients may be stored in ``poly``. - void nmod_poly_init2_preinv(nmod_poly_t poly, mp_limb_t n, mp_limb_t ninv, long alloc) + void nmod_poly_init2_preinv(nmod_poly_t poly, mp_limb_t n, mp_limb_t ninv, slong alloc) # Initialises ``poly``. It will have coefficients modulo `n`. # The caller supplies a precomputed inverse limb generated by # :func:`n_preinvert_limb`. Up to ``alloc`` coefficients may # be stored in ``poly``. - void nmod_poly_realloc(nmod_poly_t poly, long alloc) + void nmod_poly_realloc(nmod_poly_t poly, slong alloc) # Reallocates ``poly`` to the given length. If the current # length is less than ``alloc``, the polynomial is truncated # and normalised. If ``alloc`` is zero, the polynomial is @@ -47,7 +47,7 @@ cdef extern from "flint_wrap.h": # Clears the polynomial and releases any memory it used. The polynomial # cannot be used again until it is initialised. - void nmod_poly_fit_length(nmod_poly_t poly, long alloc) + void nmod_poly_fit_length(nmod_poly_t poly, slong alloc) # Ensures ``poly`` has space for at least ``alloc`` coefficients. # This function only ever grows the allocated space, so no data loss can # occur. @@ -56,11 +56,11 @@ cdef extern from "flint_wrap.h": # Internal function for normalising a polynomial so that the top # coefficient, if there is one at all, is not zero. - long nmod_poly_length(const nmod_poly_t poly) + slong nmod_poly_length(const nmod_poly_t poly) # Returns the length of the polynomial ``poly``. The zero polynomial # has length zero. - long nmod_poly_degree(const nmod_poly_t poly) + slong nmod_poly_degree(const nmod_poly_t poly) # Returns the degree of the polynomial ``poly``. The zero polynomial # is deemed to have degree `-1`. @@ -85,16 +85,16 @@ cdef extern from "flint_wrap.h": void nmod_poly_zero(nmod_poly_t res) # Sets ``res`` to the zero polynomial. - void nmod_poly_truncate(nmod_poly_t poly, long len) + void nmod_poly_truncate(nmod_poly_t poly, slong len) # Truncates ``poly`` to the given length and normalises it. # If ``len`` is greater than the current length of ``poly``, # then nothing happens. - void nmod_poly_set_trunc(nmod_poly_t res, const nmod_poly_t poly, long len) + void nmod_poly_set_trunc(nmod_poly_t res, const nmod_poly_t poly, slong len) # Notionally truncate ``poly`` to length ``len`` and set ``res`` to the # result. The result is normalised. - void _nmod_poly_reverse(mp_ptr output, mp_srcptr input, long len, long m) + void _nmod_poly_reverse(mp_ptr output, mp_srcptr input, slong len, slong m) # Sets ``output`` to the reverse of ``input``, which is of length # ``len``, but thinking of it as a polynomial of length ``m``, # notionally zero-padded if necessary. The length ``m`` must be @@ -103,33 +103,33 @@ cdef extern from "flint_wrap.h": # aliasing of ``output`` and ``input``, but the behaviour is # undefined in case of partial overlap. - void nmod_poly_reverse(nmod_poly_t output, const nmod_poly_t input, long m) + void nmod_poly_reverse(nmod_poly_t output, const nmod_poly_t input, slong m) # Sets ``output`` to the reverse of ``input``, thinking of it as # a polynomial of length ``m``, notionally zero-padded if necessary). # The length ``m`` must be non-negative, but there are no other # restrictions. The output polynomial will be set to length ``m`` # and then normalised. - void nmod_poly_randtest(nmod_poly_t poly, flint_rand_t state, long len) + void nmod_poly_randtest(nmod_poly_t poly, flint_rand_t state, slong len) # Generates a random polynomial with length up to ``len``. - void nmod_poly_randtest_irreducible(nmod_poly_t poly, flint_rand_t state, long len) + void nmod_poly_randtest_irreducible(nmod_poly_t poly, flint_rand_t state, slong len) # Generates a random irreducible polynomial with length up to ``len``. - void nmod_poly_randtest_monic(nmod_poly_t poly, flint_rand_t state, long len) + void nmod_poly_randtest_monic(nmod_poly_t poly, flint_rand_t state, slong len) # Generates a random monic polynomial with length ``len``. - void nmod_poly_randtest_monic_irreducible(nmod_poly_t poly, flint_rand_t state, long len) + void nmod_poly_randtest_monic_irreducible(nmod_poly_t poly, flint_rand_t state, slong len) # Generates a random monic irreducible polynomial with length ``len``. - void nmod_poly_randtest_monic_primitive(nmod_poly_t poly, flint_rand_t state, long len) + void nmod_poly_randtest_monic_primitive(nmod_poly_t poly, flint_rand_t state, slong len) # Generates a random monic irreducible primitive polynomial with # length ``len``. - void nmod_poly_randtest_trinomial(nmod_poly_t poly, flint_rand_t state, long len) + void nmod_poly_randtest_trinomial(nmod_poly_t poly, flint_rand_t state, slong len) # Generates a random monic trinomial of length ``len``. - int nmod_poly_randtest_trinomial_irreducible(nmod_poly_t poly, flint_rand_t state, long len, long max_attempts) + int nmod_poly_randtest_trinomial_irreducible(nmod_poly_t poly, flint_rand_t state, slong len, slong max_attempts) # Attempts to set ``poly`` to a monic irreducible trinomial of # length ``len``. It will generate up to ``max_attempts`` # trinomials in attempt to find an irreducible one. If @@ -137,10 +137,10 @@ cdef extern from "flint_wrap.h": # trinomials until an irreducible one is found. Returns `1` if one # is found and `0` otherwise. - void nmod_poly_randtest_pentomial(nmod_poly_t poly, flint_rand_t state, long len) + void nmod_poly_randtest_pentomial(nmod_poly_t poly, flint_rand_t state, slong len) # Generates a random monic pentomial of length ``len``. - int nmod_poly_randtest_pentomial_irreducible(nmod_poly_t poly, flint_rand_t state, long len, long max_attempts) + int nmod_poly_randtest_pentomial_irreducible(nmod_poly_t poly, flint_rand_t state, slong len, slong max_attempts) # Attempts to set ``poly`` to a monic irreducible pentomial of # length ``len``. It will generate up to ``max_attempts`` # pentomials in attempt to find an irreducible one. If @@ -148,20 +148,20 @@ cdef extern from "flint_wrap.h": # pentomials until an irreducible one is found. Returns `1` if one # is found and `0` otherwise. - void nmod_poly_randtest_sparse_irreducible(nmod_poly_t poly, flint_rand_t state, long len) + void nmod_poly_randtest_sparse_irreducible(nmod_poly_t poly, flint_rand_t state, slong len) # Attempts to set ``poly`` to a sparse, monic irreducible polynomial # with length ``len``. It attempts to find an irreducible # trinomial. If that does not succeed, it attempts to find a # irreducible pentomial. If that fails, then ``poly`` is just # set to a random monic irreducible polynomial. - unsigned long nmod_poly_get_coeff_ui(const nmod_poly_t poly, long j) + ulong nmod_poly_get_coeff_ui(const nmod_poly_t poly, slong j) # Returns the coefficient of ``poly`` at index ``j``, where # coefficients are numbered with zero being the constant coefficient, # and returns it as an ``ulong``. If ``j`` refers to a # coefficient beyond the end of ``poly``, zero is returned. - void nmod_poly_set_coeff_ui(nmod_poly_t poly, long j, unsigned long c) + void nmod_poly_set_coeff_ui(nmod_poly_t poly, slong j, ulong c) # Sets the coefficient of ``poly`` at index ``j``, where # coefficients are numbered with zero being the constant coefficient, # to the value ``c`` reduced modulo the modulus of ``poly``. @@ -237,17 +237,17 @@ cdef extern from "flint_wrap.h": int nmod_poly_equal(const nmod_poly_t a, const nmod_poly_t b) # Returns `1` if the polynomials are equal, otherwise `0`. - int nmod_poly_equal_nmod(const nmod_poly_t poly, unsigned long cst) + int nmod_poly_equal_nmod(const nmod_poly_t poly, ulong cst) # Returns `1` if the polynomial ``poly`` is constant, equal to ``cst``, # otherwise `0`. # ``cst`` is assumed to be already reduced, i.e. less than the modulus of # ``poly``. - int nmod_poly_equal_ui(const nmod_poly_t poly, unsigned long cst) + int nmod_poly_equal_ui(const nmod_poly_t poly, ulong cst) # Returns `1` if the polynomial ``poly`` is constant and equal to ``cst`` up to # reduction modulo the modulus of ``poly``, otherwise returns `0`. - int nmod_poly_equal_trunc(const nmod_poly_t poly1, const nmod_poly_t poly2, long n) + int nmod_poly_equal_trunc(const nmod_poly_t poly1, const nmod_poly_t poly2, slong n) # Notionally truncate ``poly1`` and ``poly2`` to length `n` and return # `1` if the truncations are equal, otherwise return `0`. @@ -261,56 +261,56 @@ cdef extern from "flint_wrap.h": int nmod_poly_is_gen(const nmod_poly_t poly) - void _nmod_poly_shift_left(mp_ptr res, mp_srcptr poly, long len, long k) + void _nmod_poly_shift_left(mp_ptr res, mp_srcptr poly, slong len, slong k) # Sets ``(res, len + k)`` to ``(poly, len)`` shifted left by # ``k`` coefficients. Assumes that ``res`` has space for # ``len + k`` coefficients. - void nmod_poly_shift_left(nmod_poly_t res, const nmod_poly_t poly, long k) + void nmod_poly_shift_left(nmod_poly_t res, const nmod_poly_t poly, slong k) # Sets ``res`` to ``poly`` shifted left by ``k`` coefficients, # i.e. multiplied by `x^k`. - void _nmod_poly_shift_right(mp_ptr res, mp_srcptr poly, long len, long k) + void _nmod_poly_shift_right(mp_ptr res, mp_srcptr poly, slong len, slong k) # Sets ``(res, len - k)`` to ``(poly, len)`` shifted left by # ``k`` coefficients. It is assumed that ``k <= len`` and that # ``res`` has space for at least ``len - k`` coefficients. - void nmod_poly_shift_right(nmod_poly_t res, const nmod_poly_t poly, long k) + void nmod_poly_shift_right(nmod_poly_t res, const nmod_poly_t poly, slong k) # Sets ``res`` to ``poly`` shifted right by ``k`` coefficients, # i.e. divide by `x^k` and throw away the remainder. If ``k`` is # greater than or equal to the length of ``poly``, the result is the # zero polynomial. - void _nmod_poly_add(mp_ptr res, mp_srcptr poly1, long len1, mp_srcptr poly2, long len2, nmod_t mod) + void _nmod_poly_add(mp_ptr res, mp_srcptr poly1, slong len1, mp_srcptr poly2, slong len2, nmod_t mod) # Sets ``res`` to the sum of ``(poly1, len1)`` and # ``(poly2, len2)``. There are no restrictions on the lengths. void nmod_poly_add(nmod_poly_t res, const nmod_poly_t poly1, const nmod_poly_t poly2) # Sets ``res`` to the sum of ``poly1`` and ``poly2``. - void nmod_poly_add_series(nmod_poly_t res, const nmod_poly_t poly1, const nmod_poly_t poly2, long n) + void nmod_poly_add_series(nmod_poly_t res, const nmod_poly_t poly1, const nmod_poly_t poly2, slong n) # Notionally truncate ``poly1`` and ``poly2`` to length `n` and set # ``res`` to the sum. - void _nmod_poly_sub(mp_ptr res, mp_srcptr poly1, long len1, mp_srcptr poly2, long len2, nmod_t mod) + void _nmod_poly_sub(mp_ptr res, mp_srcptr poly1, slong len1, mp_srcptr poly2, slong len2, nmod_t mod) # Sets ``res`` to the difference of ``(poly1, len1)`` and # ``(poly2, len2)``. There are no restrictions on the lengths. void nmod_poly_sub(nmod_poly_t res, const nmod_poly_t poly1, const nmod_poly_t poly2) # Sets ``res`` to the difference of ``poly1`` and ``poly2``. - void nmod_poly_sub_series(nmod_poly_t res, const nmod_poly_t poly1, const nmod_poly_t poly2, long n) + void nmod_poly_sub_series(nmod_poly_t res, const nmod_poly_t poly1, const nmod_poly_t poly2, slong n) # Notionally truncate ``poly1`` and ``poly2`` to length `n` and set # ``res`` to the difference. void nmod_poly_neg(nmod_poly_t res, const nmod_poly_t poly) # Sets ``res`` to the negation of ``poly``. - void nmod_poly_scalar_mul_nmod(nmod_poly_t res, const nmod_poly_t poly, unsigned long c) + void nmod_poly_scalar_mul_nmod(nmod_poly_t res, const nmod_poly_t poly, ulong c) # Sets ``res`` to ``(poly, len)`` multiplied by `c`, # where `c` is reduced modulo the modulus of ``poly``. - void _nmod_poly_make_monic(mp_ptr output, mp_srcptr input, long len, nmod_t mod) + void _nmod_poly_make_monic(mp_ptr output, mp_srcptr input, slong len, nmod_t mod) # Sets ``output`` to be the scalar multiple of ``input`` of # length ``len > 0`` that has leading coefficient one, if such a # polynomial exists. If the leading coefficient of ``input`` is not @@ -326,7 +326,7 @@ cdef extern from "flint_wrap.h": # leading coefficient is the greatest common divisor of the leading # coefficient and the modulus of ``input``. - void _nmod_poly_bit_pack(mp_ptr res, mp_srcptr poly, long len, flint_bitcnt_t bits) + void _nmod_poly_bit_pack(mp_ptr res, mp_srcptr poly, slong len, flint_bitcnt_t bits) # Packs ``len`` coefficients of ``poly`` into fields of the given # number of bits in the large integer ``res``, i.e. evaluates # ``poly`` at ``2^bits`` and store the result in ``res``. @@ -334,7 +334,7 @@ cdef extern from "flint_wrap.h": # coefficient of ``poly`` is bigger than ``bits/2`` bits. We # also assume ``bits < 3 * FLINT_BITS``. - void _nmod_poly_bit_unpack(mp_ptr res, long len, mp_srcptr mpn, unsigned long bits, nmod_t mod) + void _nmod_poly_bit_unpack(mp_ptr res, slong len, mp_srcptr mpn, ulong bits, nmod_t mod) # Unpacks ``len`` coefficients stored in the big integer ``mpn`` # in bit fields of the given number of bits, reduces them modulo the # given modulus, then stores them in the polynomial ``res``. @@ -350,52 +350,52 @@ cdef extern from "flint_wrap.h": # Unpacks the polynomial from fields of size ``bit_size`` as # represented by the integer ``f``. - void _nmod_poly_KS2_pack1(mp_ptr res, mp_srcptr op, long n, long s, unsigned long b, unsigned long k, long r) + void _nmod_poly_KS2_pack1(mp_ptr res, mp_srcptr op, slong n, slong s, ulong b, ulong k, slong r) # Same as ``_nmod_poly_KS2_pack``, but requires ``b <= FLINT_BITS``. - void _nmod_poly_KS2_pack(mp_ptr res, mp_srcptr op, long n, long s, unsigned long b, unsigned long k, long r) + void _nmod_poly_KS2_pack(mp_ptr res, mp_srcptr op, slong n, slong s, ulong b, ulong k, slong r) # Bit packing routine used by KS2 and KS4 multiplication. - void _nmod_poly_KS2_unpack1(mp_ptr res, mp_srcptr op, long n, unsigned long b, unsigned long k) + void _nmod_poly_KS2_unpack1(mp_ptr res, mp_srcptr op, slong n, ulong b, ulong k) # Same as ``_nmod_poly_KS2_unpack``, but requires ``b <= FLINT_BITS`` # (i.e. writes one word per coefficient). - void _nmod_poly_KS2_unpack2(mp_ptr res, mp_srcptr op, long n, unsigned long b, unsigned long k) + void _nmod_poly_KS2_unpack2(mp_ptr res, mp_srcptr op, slong n, ulong b, ulong k) # Same as ``_nmod_poly_KS2_unpack``, but requires # ``FLINT_BITS < b <= 2 * FLINT_BITS`` (i.e. writes two words per # coefficient). - void _nmod_poly_KS2_unpack3(mp_ptr res, mp_srcptr op, long n, unsigned long b, unsigned long k) + void _nmod_poly_KS2_unpack3(mp_ptr res, mp_srcptr op, slong n, ulong b, ulong k) # Same as ``_nmod_poly_KS2_unpack``, but requires # ``2 * FLINT_BITS < b < 3 * FLINT_BITS`` (i.e. writes three words per # coefficient). - void _nmod_poly_KS2_unpack(mp_ptr res, mp_srcptr op, long n, unsigned long b, unsigned long k) + void _nmod_poly_KS2_unpack(mp_ptr res, mp_srcptr op, slong n, ulong b, ulong k) # Bit unpacking code used by KS2 and KS4 multiplication. - void _nmod_poly_KS2_reduce(mp_ptr res, long s, mp_srcptr op, long n, unsigned long w, nmod_t mod) + void _nmod_poly_KS2_reduce(mp_ptr res, slong s, mp_srcptr op, slong n, ulong w, nmod_t mod) # Reduction code used by KS2 and KS4 multiplication. - void _nmod_poly_KS2_recover_reduce1(mp_ptr res, long s, mp_srcptr op1, mp_srcptr op2, long n, unsigned long b, nmod_t mod) + void _nmod_poly_KS2_recover_reduce1(mp_ptr res, slong s, mp_srcptr op1, mp_srcptr op2, slong n, ulong b, nmod_t mod) # Same as ``_nmod_poly_KS2_recover_reduce``, but requires # ``0 < 2 * b <= FLINT_BITS``. - void _nmod_poly_KS2_recover_reduce2(mp_ptr res, long s, mp_srcptr op1, mp_srcptr op2, long n, unsigned long b, nmod_t mod) + void _nmod_poly_KS2_recover_reduce2(mp_ptr res, slong s, mp_srcptr op1, mp_srcptr op2, slong n, ulong b, nmod_t mod) # Same as ``_nmod_poly_KS2_recover_reduce``, but requires # ``FLINT_BITS < 2 * b < 2*FLINT_BITS``. - void _nmod_poly_KS2_recover_reduce2b(mp_ptr res, long s, mp_srcptr op1, mp_srcptr op2, long n, unsigned long b, nmod_t mod) + void _nmod_poly_KS2_recover_reduce2b(mp_ptr res, slong s, mp_srcptr op1, mp_srcptr op2, slong n, ulong b, nmod_t mod) # Same as ``_nmod_poly_KS2_recover_reduce``, but requires # ``b == FLINT_BITS``. - void _nmod_poly_KS2_recover_reduce3(mp_ptr res, long s, mp_srcptr op1, mp_srcptr op2, long n, unsigned long b, nmod_t mod) + void _nmod_poly_KS2_recover_reduce3(mp_ptr res, slong s, mp_srcptr op1, mp_srcptr op2, slong n, ulong b, nmod_t mod) # Same as ``_nmod_poly_KS2_recover_reduce``, but requires # ``2 * FLINT_BITS < 2 * b <= 3 * FLINT_BITS``. - void _nmod_poly_KS2_recover_reduce(mp_ptr res, long s, mp_srcptr op1, mp_srcptr op2, long n, unsigned long b, nmod_t mod) + void _nmod_poly_KS2_recover_reduce(mp_ptr res, slong s, mp_srcptr op1, mp_srcptr op2, slong n, ulong b, nmod_t mod) # Reduction code used by KS4 multiplication. - void _nmod_poly_mul_classical(mp_ptr res, mp_srcptr poly1, long len1, mp_srcptr poly2, long len2, nmod_t mod) + void _nmod_poly_mul_classical(mp_ptr res, mp_srcptr poly1, slong len1, mp_srcptr poly2, slong len2, nmod_t mod) # Sets ``(res, len1 + len2 - 1)`` to the product of ``(poly1, len1)`` # and ``(poly2, len2)``. Assumes ``len1 >= len2 > 0``. Aliasing of # inputs and output is not permitted. @@ -403,29 +403,29 @@ cdef extern from "flint_wrap.h": void nmod_poly_mul_classical(nmod_poly_t res, const nmod_poly_t poly1, const nmod_poly_t poly2) # Sets ``res`` to the product of ``poly1`` and ``poly2``. - void _nmod_poly_mullow_classical(mp_ptr res, mp_srcptr poly1, long len1, mp_srcptr poly2, long len2, long trunc, nmod_t mod) + void _nmod_poly_mullow_classical(mp_ptr res, mp_srcptr poly1, slong len1, mp_srcptr poly2, slong len2, slong trunc, nmod_t mod) # Sets ``res`` to the lower ``trunc`` coefficients of the product of # ``(poly1, len1)`` and ``(poly2, len2)``. Assumes that # ``len1 >= len2 > 0`` and ``trunc > 0``. Aliasing of inputs and # output is not permitted. - void nmod_poly_mullow_classical(nmod_poly_t res, const nmod_poly_t poly1, const nmod_poly_t poly2, long trunc) + void nmod_poly_mullow_classical(nmod_poly_t res, const nmod_poly_t poly1, const nmod_poly_t poly2, slong trunc) # Sets ``res`` to the lower ``trunc`` coefficients of the product # of ``poly1`` and ``poly2``. - void _nmod_poly_mulhigh_classical(mp_ptr res, mp_srcptr poly1, long len1, mp_srcptr poly2, long len2, long start, nmod_t mod) + void _nmod_poly_mulhigh_classical(mp_ptr res, mp_srcptr poly1, slong len1, mp_srcptr poly2, slong len2, slong start, nmod_t mod) # Computes the product of ``(poly1, len1)`` and ``(poly2, len2)`` # and writes the coefficients from ``start`` onwards into the high # coefficients of ``res``, the remaining coefficients being arbitrary # but reduced. Assumes that ``len1 >= len2 > 0``. Aliasing of inputs # and output is not permitted. - void nmod_poly_mulhigh_classical(nmod_poly_t res, const nmod_poly_t poly1, const nmod_poly_t poly2, long start) + void nmod_poly_mulhigh_classical(nmod_poly_t res, const nmod_poly_t poly1, const nmod_poly_t poly2, slong start) # Computes the product of ``poly1`` and ``poly2`` and writes the # coefficients from ``start`` onwards into the high coefficients of # ``res``, the remaining coefficients being arbitrary but reduced. - void _nmod_poly_mul_KS(mp_ptr out, mp_srcptr in1, long len1, mp_srcptr in2, long len2, flint_bitcnt_t bits, nmod_t mod) + void _nmod_poly_mul_KS(mp_ptr out, mp_srcptr in1, slong len1, mp_srcptr in2, slong len2, flint_bitcnt_t bits, nmod_t mod) # Sets ``res`` to the product of ``in1`` and ``in2`` # assuming the output coefficients are at most the given number of # bits wide. If ``bits`` is set to `0` an appropriate value is @@ -437,31 +437,31 @@ cdef extern from "flint_wrap.h": # bits wide. If ``bits`` is set to `0` an appropriate value # is computed automatically. - void _nmod_poly_mul_KS2(mp_ptr res, mp_srcptr op1, long n1, mp_srcptr op2, long n2, nmod_t mod) + void _nmod_poly_mul_KS2(mp_ptr res, mp_srcptr op1, slong n1, mp_srcptr op2, slong n2, nmod_t mod) # Sets ``res`` to the product of ``op1`` and ``op2``. # Assumes that ``len1 >= len2 > 0``. void nmod_poly_mul_KS2(nmod_poly_t res, const nmod_poly_t poly1, const nmod_poly_t poly2) # Sets ``res`` to the product of ``poly1`` and ``poly2``. - void _nmod_poly_mul_KS4(mp_ptr res, mp_srcptr op1, long n1, mp_srcptr op2, long n2, nmod_t mod) + void _nmod_poly_mul_KS4(mp_ptr res, mp_srcptr op1, slong n1, mp_srcptr op2, slong n2, nmod_t mod) # Sets ``res`` to the product of ``op1`` and ``op2``. # Assumes that ``len1 >= len2 > 0``. void nmod_poly_mul_KS4(nmod_poly_t res, const nmod_poly_t poly1, const nmod_poly_t poly2) # Sets ``res`` to the product of ``poly1`` and ``poly2``. - void _nmod_poly_mullow_KS(mp_ptr out, mp_srcptr in1, long len1, mp_srcptr in2, long len2, flint_bitcnt_t bits, long n, nmod_t mod) + void _nmod_poly_mullow_KS(mp_ptr out, mp_srcptr in1, slong len1, mp_srcptr in2, slong len2, flint_bitcnt_t bits, slong n, nmod_t mod) # Sets ``out`` to the low `n` coefficients of ``in1`` of length # ``len1`` times ``in2`` of length ``len2``. The output must have # space for ``n`` coefficients. We assume that ``len1 >= len2 > 0`` # and that ``0 < n <= len1 + len2 - 1``. - void nmod_poly_mullow_KS(nmod_poly_t res, const nmod_poly_t poly1, const nmod_poly_t poly2, flint_bitcnt_t bits, long n) + void nmod_poly_mullow_KS(nmod_poly_t res, const nmod_poly_t poly1, const nmod_poly_t poly2, flint_bitcnt_t bits, slong n) # Set ``res`` to the low `n` coefficients of ``in1`` of length # ``len1`` times ``in2`` of length ``len2``. - void _nmod_poly_mul(mp_ptr res, mp_srcptr poly1, long len1, mp_srcptr poly2, long len2, nmod_t mod) + void _nmod_poly_mul(mp_ptr res, mp_srcptr poly1, slong len1, mp_srcptr poly2, slong len2, nmod_t mod) # Sets ``res`` to the product of ``poly1`` of length ``len1`` # and ``poly2`` of length ``len2``. Assumes ``len1 >= len2 > 0``. # No aliasing is permitted between the inputs and the output. @@ -469,18 +469,18 @@ cdef extern from "flint_wrap.h": void nmod_poly_mul(nmod_poly_t res, const nmod_poly_t poly, const nmod_poly_t poly2) # Sets ``res`` to the product of ``poly1`` and ``poly2``. - void _nmod_poly_mullow(mp_ptr res, mp_srcptr poly1, long len1, mp_srcptr poly2, long len2, long n, nmod_t mod) + void _nmod_poly_mullow(mp_ptr res, mp_srcptr poly1, slong len1, mp_srcptr poly2, slong len2, slong n, nmod_t mod) # Sets ``res`` to the first ``n`` coefficients of the # product of ``poly1`` of length ``len1`` and ``poly2`` of # length ``len2``. It is assumed that ``0 < n <= len1 + len2 - 1`` # and that ``len1 >= len2 > 0``. No aliasing of inputs and output # is permitted. - void nmod_poly_mullow(nmod_poly_t res, const nmod_poly_t poly1, const nmod_poly_t poly2, long trunc) + void nmod_poly_mullow(nmod_poly_t res, const nmod_poly_t poly1, const nmod_poly_t poly2, slong trunc) # Sets ``res`` to the first ``trunc`` coefficients of the # product of ``poly1`` and ``poly2``. - void _nmod_poly_mulhigh(mp_ptr res, mp_srcptr poly1, long len1, mp_srcptr poly2, long len2, long n, nmod_t mod) + void _nmod_poly_mulhigh(mp_ptr res, mp_srcptr poly1, slong len1, mp_srcptr poly2, slong len2, slong n, nmod_t mod) # Sets all but the low `n` coefficients of ``res`` to the # corresponding coefficients of the product of ``poly1`` of length # ``len1`` and ``poly2`` of length ``len2``, the other @@ -488,12 +488,12 @@ cdef extern from "flint_wrap.h": # ``len1 >= len2 > 0`` and that ``0 < n <= len1 + len2 - 1``. # Aliasing of inputs and output is not permitted. - void nmod_poly_mulhigh(nmod_poly_t res, const nmod_poly_t poly1, const nmod_poly_t poly2, long n) + void nmod_poly_mulhigh(nmod_poly_t res, const nmod_poly_t poly1, const nmod_poly_t poly2, slong n) # Sets all but the low `n` coefficients of ``res`` to the # corresponding coefficients of the product of ``poly1`` and # ``poly2``, the remaining coefficients being arbitrary. - void _nmod_poly_mulmod(mp_ptr res, mp_srcptr poly1, long len1, mp_srcptr poly2, long len2, mp_srcptr f, long lenf, nmod_t mod) + void _nmod_poly_mulmod(mp_ptr res, mp_srcptr poly1, slong len1, mp_srcptr poly2, slong len2, mp_srcptr f, slong lenf, nmod_t mod) # Sets ``res`` to the remainder of the product of ``poly1`` and # ``poly2`` upon polynomial division by ``f``. # It is required that ``len1 + len2 - lenf > 0``, which is equivalent @@ -505,7 +505,7 @@ cdef extern from "flint_wrap.h": # Sets ``res`` to the remainder of the product of ``poly1`` and # ``poly2`` upon polynomial division by ``f``. - void _nmod_poly_mulmod_preinv(mp_ptr res, mp_srcptr poly1, long len1, mp_srcptr poly2, long len2, mp_srcptr f, long lenf, mp_srcptr finv, long lenfinv, nmod_t mod) + void _nmod_poly_mulmod_preinv(mp_ptr res, mp_srcptr poly1, slong len1, mp_srcptr poly2, slong len2, mp_srcptr f, slong lenf, mp_srcptr finv, slong lenfinv, nmod_t mod) # Sets ``res`` to the remainder of the product of ``poly1`` and # ``poly2`` upon polynomial division by ``f``. # It is required that ``finv`` is the inverse of the reverse of ``f`` @@ -521,28 +521,28 @@ cdef extern from "flint_wrap.h": # inverse of the reverse of ``f``. It is required that ``poly1`` and # ``poly2`` are reduced modulo ``f``. - void _nmod_poly_pow_binexp(mp_ptr res, mp_srcptr poly, long len, unsigned long e, nmod_t mod) + void _nmod_poly_pow_binexp(mp_ptr res, mp_srcptr poly, slong len, ulong e, nmod_t mod) # Raises ``poly`` of length ``len`` to the power ``e`` and sets # ``res`` to the result. We require that ``res`` has enough space # for ``(len - 1)*e + 1`` coefficients. Assumes that ``len > 0``, # ``e > 1``. Aliasing is not permitted. Uses the binary exponentiation # method. - void nmod_poly_pow_binexp(nmod_poly_t res, const nmod_poly_t poly, unsigned long e) + void nmod_poly_pow_binexp(nmod_poly_t res, const nmod_poly_t poly, ulong e) # Raises ``poly`` to the power ``e`` and sets ``res`` to the # result. Uses the binary exponentiation method. - void _nmod_poly_pow(mp_ptr res, mp_srcptr poly, long len, unsigned long e, nmod_t mod) + void _nmod_poly_pow(mp_ptr res, mp_srcptr poly, slong len, ulong e, nmod_t mod) # Raises ``poly`` of length ``len`` to the power ``e`` and sets # ``res`` to the result. We require that ``res`` has enough space # for ``(len - 1)*e + 1`` coefficients. Assumes that ``len > 0``, # ``e > 1``. Aliasing is not permitted. - void nmod_poly_pow(nmod_poly_t res, const nmod_poly_t poly, unsigned long e) + void nmod_poly_pow(nmod_poly_t res, const nmod_poly_t poly, ulong e) # Raises ``poly`` to the power ``e`` and sets ``res`` to the # result. - void _nmod_poly_pow_trunc_binexp(mp_ptr res, mp_srcptr poly, unsigned long e, long trunc, nmod_t mod) + void _nmod_poly_pow_trunc_binexp(mp_ptr res, mp_srcptr poly, ulong e, slong trunc, nmod_t mod) # Sets ``res`` to the low ``trunc`` coefficients of ``poly`` # (assumed to be zero padded if necessary to length ``trunc``) to # the power ``e``. This is equivalent to doing a powering followed @@ -551,12 +551,12 @@ cdef extern from "flint_wrap.h": # ``e > 1``. Aliasing is not permitted. Uses the binary # exponentiation method. - void nmod_poly_pow_trunc_binexp(nmod_poly_t res, const nmod_poly_t poly, unsigned long e, long trunc) + void nmod_poly_pow_trunc_binexp(nmod_poly_t res, const nmod_poly_t poly, ulong e, slong trunc) # Sets ``res`` to the low ``trunc`` coefficients of ``poly`` # to the power ``e``. This is equivalent to doing a powering # followed by a truncation. Uses the binary exponentiation method. - void _nmod_poly_pow_trunc(mp_ptr res, mp_srcptr poly, unsigned long e, long trunc, nmod_t mod) + void _nmod_poly_pow_trunc(mp_ptr res, mp_srcptr poly, ulong e, slong trunc, nmod_t mod) # Sets ``res`` to the low ``trunc`` coefficients of ``poly`` # (assumed to be zero padded if necessary to length ``trunc``) to # the power ``e``. This is equivalent to doing a powering followed @@ -564,12 +564,12 @@ cdef extern from "flint_wrap.h": # ``trunc`` coefficients, that ``trunc > 0`` and that # ``e > 1``. Aliasing is not permitted. - void nmod_poly_pow_trunc(nmod_poly_t res, const nmod_poly_t poly, unsigned long e, long trunc) + void nmod_poly_pow_trunc(nmod_poly_t res, const nmod_poly_t poly, ulong e, slong trunc) # Sets ``res`` to the low ``trunc`` coefficients of ``poly`` # to the power ``e``. This is equivalent to doing a powering # followed by a truncation. - void _nmod_poly_powmod_ui_binexp(mp_ptr res, mp_srcptr poly, unsigned long e, mp_srcptr f, long lenf, nmod_t mod) + void _nmod_poly_powmod_ui_binexp(mp_ptr res, mp_srcptr poly, ulong e, mp_srcptr f, slong lenf, nmod_t mod) # Sets ``res`` to ``poly`` raised to the power ``e`` # modulo ``f``, using binary exponentiation. We require ``e > 0``. # We require ``lenf > 1``. It is assumed that ``poly`` is already @@ -577,11 +577,11 @@ cdef extern from "flint_wrap.h": # exactly ``lenf - 1``. The output ``res`` must have room for # ``lenf - 1`` coefficients. - void nmod_poly_powmod_ui_binexp(nmod_poly_t res, const nmod_poly_t poly, unsigned long e, const nmod_poly_t f) + void nmod_poly_powmod_ui_binexp(nmod_poly_t res, const nmod_poly_t poly, ulong e, const nmod_poly_t f) # Sets ``res`` to ``poly`` raised to the power ``e`` # modulo ``f``, using binary exponentiation. We require ``e >= 0``. - void _nmod_poly_powmod_fmpz_binexp(mp_ptr res, mp_srcptr poly, fmpz_t e, mp_srcptr f, long lenf, nmod_t mod) + void _nmod_poly_powmod_fmpz_binexp(mp_ptr res, mp_srcptr poly, fmpz_t e, mp_srcptr f, slong lenf, nmod_t mod) # Sets ``res`` to ``poly`` raised to the power ``e`` # modulo ``f``, using binary exponentiation. We require ``e > 0``. # We require ``lenf > 1``. It is assumed that ``poly`` is already @@ -592,7 +592,7 @@ cdef extern from "flint_wrap.h": # Sets ``res`` to ``poly`` raised to the power ``e`` # modulo ``f``, using binary exponentiation. We require ``e >= 0``. - void _nmod_poly_powmod_ui_binexp_preinv (mp_ptr res, mp_srcptr poly, unsigned long e, mp_srcptr f, long lenf, mp_srcptr finv, long lenfinv, nmod_t mod) + void _nmod_poly_powmod_ui_binexp_preinv (mp_ptr res, mp_srcptr poly, ulong e, mp_srcptr f, slong lenf, mp_srcptr finv, slong lenfinv, nmod_t mod) # Sets ``res`` to ``poly`` raised to the power ``e`` # modulo ``f``, using binary exponentiation. We require ``e > 0``. # We require ``finv`` to be the inverse of the reverse of ``f``. @@ -601,12 +601,12 @@ cdef extern from "flint_wrap.h": # exactly ``lenf - 1``. The output ``res`` must have room for # ``lenf - 1`` coefficients. - void nmod_poly_powmod_ui_binexp_preinv(nmod_poly_t res, const nmod_poly_t poly, unsigned long e, const nmod_poly_t f, const nmod_poly_t finv) + void nmod_poly_powmod_ui_binexp_preinv(nmod_poly_t res, const nmod_poly_t poly, ulong e, const nmod_poly_t f, const nmod_poly_t finv) # Sets ``res`` to ``poly`` raised to the power ``e`` # modulo ``f``, using binary exponentiation. We require ``e >= 0``. # We require ``finv`` to be the inverse of the reverse of ``f``. - void _nmod_poly_powmod_fmpz_binexp_preinv (mp_ptr res, mp_srcptr poly, fmpz_t e, mp_srcptr f, long lenf, mp_srcptr finv, long lenfinv, nmod_t mod) + void _nmod_poly_powmod_fmpz_binexp_preinv (mp_ptr res, mp_srcptr poly, fmpz_t e, mp_srcptr f, slong lenf, mp_srcptr finv, slong lenfinv, nmod_t mod) # Sets ``res`` to ``poly`` raised to the power ``e`` # modulo ``f``, using binary exponentiation. We require ``e > 0``. # We require ``finv`` to be the inverse of the reverse of ``f``. @@ -620,20 +620,20 @@ cdef extern from "flint_wrap.h": # modulo ``f``, using binary exponentiation. We require ``e >= 0``. # We require ``finv`` to be the inverse of the reverse of ``f``. - void _nmod_poly_powmod_x_ui_preinv (mp_ptr res, unsigned long e, mp_srcptr f, long lenf, mp_srcptr finv, long lenfinv, nmod_t mod) + void _nmod_poly_powmod_x_ui_preinv (mp_ptr res, ulong e, mp_srcptr f, slong lenf, mp_srcptr finv, slong lenfinv, nmod_t mod) # Sets ``res`` to ``x`` raised to the power ``e`` modulo ``f``, # using sliding window exponentiation. We require ``e > 0``. # We require ``finv`` to be the inverse of the reverse of ``f``. # We require ``lenf > 2``. The output ``res`` must have room for # ``lenf - 1`` coefficients. - void nmod_poly_powmod_x_ui_preinv(nmod_poly_t res, unsigned long e, const nmod_poly_t f, const nmod_poly_t finv) + void nmod_poly_powmod_x_ui_preinv(nmod_poly_t res, ulong e, const nmod_poly_t f, const nmod_poly_t finv) # Sets ``res`` to ``x`` raised to the power ``e`` # modulo ``f``, using sliding window exponentiation. We require # ``e >= 0``. We require ``finv`` to be the inverse of the reverse of # ``f``. - void _nmod_poly_powmod_x_fmpz_preinv (mp_ptr res, fmpz_t e, mp_srcptr f, long lenf, mp_srcptr finv, long lenfinv, nmod_t mod) + void _nmod_poly_powmod_x_fmpz_preinv (mp_ptr res, fmpz_t e, mp_srcptr f, slong lenf, mp_srcptr finv, slong lenfinv, nmod_t mod) # Sets ``res`` to ``x`` raised to the power ``e`` modulo ``f``, # using sliding window exponentiation. We require ``e > 0``. # We require ``finv`` to be the inverse of the reverse of ``f``. @@ -646,7 +646,7 @@ cdef extern from "flint_wrap.h": # ``e >= 0``. We require ``finv`` to be the inverse of the reverse of # ``f``. - void _nmod_poly_powers_mod_preinv_naive(mp_ptr * res, mp_srcptr f, long flen, long n, mp_srcptr g, long glen, mp_srcptr ginv, long ginvlen, const nmod_t mod) + void _nmod_poly_powers_mod_preinv_naive(mp_ptr * res, mp_srcptr f, slong flen, slong n, mp_srcptr g, slong glen, mp_srcptr ginv, slong ginvlen, const nmod_t mod) # Compute ``f^0, f^1, ..., f^(n-1) mod g``, where ``g`` has length ``glen`` # and ``f`` is reduced mod ``g`` and has length ``flen`` (possibly zero # spaced). Assumes ``res`` is an array of ``n`` arrays each with space for @@ -654,12 +654,12 @@ cdef extern from "flint_wrap.h": # ``ginv`` of length ``ginvlen`` is set to the power series inverse of the # reverse of ``g``. - void nmod_poly_powers_mod_naive(nmod_poly_struct * res, const nmod_poly_t f, long n, const nmod_poly_t g) + void nmod_poly_powers_mod_naive(nmod_poly_struct * res, const nmod_poly_t f, slong n, const nmod_poly_t g) # Set the entries of the array ``res`` to ``f^0, f^1, ..., f^(n-1) mod g``. # No aliasing is permitted between the entries of ``res`` and either of the # inputs. - void _nmod_poly_powers_mod_preinv_threaded_pool(mp_ptr * res, mp_srcptr f, long flen, long n, mp_srcptr g, long glen, mp_srcptr ginv, long ginvlen, const nmod_t mod, thread_pool_handle * threads, long num_threads) + void _nmod_poly_powers_mod_preinv_threaded_pool(mp_ptr * res, mp_srcptr f, slong flen, slong n, mp_srcptr g, slong glen, mp_srcptr ginv, slong ginvlen, const nmod_t mod, thread_pool_handle * threads, slong num_threads) # Compute ``f^0, f^1, ..., f^(n-1) mod g``, where ``g`` has length ``glen`` # and ``f`` is reduced mod ``g`` and has length ``flen`` (possibly zero # spaced). Assumes ``res`` is an array of ``n`` arrays each with space for @@ -667,7 +667,7 @@ cdef extern from "flint_wrap.h": # ``ginv`` of length ``ginvlen`` is set to the power series inverse of the # reverse of ``g``. - void _nmod_poly_powers_mod_preinv_threaded(mp_ptr * res, mp_srcptr f, long flen, long n, mp_srcptr g, long glen, mp_srcptr ginv, long ginvlen, const nmod_t mod) + void _nmod_poly_powers_mod_preinv_threaded(mp_ptr * res, mp_srcptr f, slong flen, slong n, mp_srcptr g, slong glen, mp_srcptr ginv, slong ginvlen, const nmod_t mod) # Compute ``f^0, f^1, ..., f^(n-1) mod g``, where ``g`` has length ``glen`` # and ``f`` is reduced mod ``g`` and has length ``flen`` (possibly zero # spaced). Assumes ``res`` is an array of ``n`` arrays each with space for @@ -675,12 +675,12 @@ cdef extern from "flint_wrap.h": # ``ginv`` of length ``ginvlen`` is set to the power series inverse of the # reverse of ``g``. - void nmod_poly_powers_mod_bsgs(nmod_poly_struct * res, const nmod_poly_t f, long n, const nmod_poly_t g) + void nmod_poly_powers_mod_bsgs(nmod_poly_struct * res, const nmod_poly_t f, slong n, const nmod_poly_t g) # Set the entries of the array ``res`` to ``f^0, f^1, ..., f^(n-1) mod g``. # No aliasing is permitted between the entries of ``res`` and either of the # inputs. - void _nmod_poly_divrem_basecase(mp_ptr Q, mp_ptr R, mp_srcptr A, long A_len, mp_srcptr B, long B_len, nmod_t mod) + void _nmod_poly_divrem_basecase(mp_ptr Q, mp_ptr R, mp_srcptr A, slong A_len, mp_srcptr B, slong B_len, nmod_t mod) # Finds `Q` and `R` such that `A = B Q + R` with `\operatorname{len}(R) < \operatorname{len}(B)`. # If `\operatorname{len}(B) = 0` an exception is raised. We require that ``W`` # is temporary space of ``NMOD_DIVREM_BC_ITCH(A_len, B_len, mod)`` @@ -690,7 +690,7 @@ cdef extern from "flint_wrap.h": # Finds `Q` and `R` such that `A = B Q + R` with `\operatorname{len}(R) < \operatorname{len}(B)`. # If `\operatorname{len}(B) = 0` an exception is raised. - void _nmod_poly_divrem(mp_ptr Q, mp_ptr R, mp_srcptr A, long lenA, mp_srcptr B, long lenB, nmod_t mod) + void _nmod_poly_divrem(mp_ptr Q, mp_ptr R, mp_srcptr A, slong lenA, mp_srcptr B, slong lenB, nmod_t mod) # Computes `Q` and `R` such that `A = BQ + R` with `\operatorname{len}(R)` less than # ``lenB``, where ``A`` is of length ``lenA`` and ``B`` is of # length ``lenB``. We require that ``Q`` have space for @@ -699,7 +699,7 @@ cdef extern from "flint_wrap.h": void nmod_poly_divrem(nmod_poly_t Q, nmod_poly_t R, const nmod_poly_t A, const nmod_poly_t B) # Computes `Q` and `R` such that `A = BQ + R` with `\operatorname{len}(R) < \operatorname{len}(B)`. - void _nmod_poly_div(mp_ptr Q, mp_srcptr A, long lenA, mp_srcptr B, long lenB, nmod_t mod) + void _nmod_poly_div(mp_ptr Q, mp_srcptr A, slong lenA, mp_srcptr B, slong lenB, nmod_t mod) # Notionally computes polynomials `Q` and `R` such that `A = BQ + R` with # `\operatorname{len}(R)` less than ``lenB``, where ``A`` is of length ``lenA`` # and ``B`` is of length ``lenB``, but returns only ``Q``. We @@ -708,22 +708,22 @@ cdef extern from "flint_wrap.h": void nmod_poly_div(nmod_poly_t Q, const nmod_poly_t A, const nmod_poly_t B) # Computes the quotient `Q` on polynomial division of `A` and `B`. - void _nmod_poly_rem_q1(mp_ptr R, mp_srcptr A, long lenA, mp_srcptr B, long lenB, nmod_t mod) + void _nmod_poly_rem_q1(mp_ptr R, mp_srcptr A, slong lenA, mp_srcptr B, slong lenB, nmod_t mod) - void _nmod_poly_rem(mp_ptr R, mp_srcptr A, long lenA, mp_srcptr B, long lenB, nmod_t mod) + void _nmod_poly_rem(mp_ptr R, mp_srcptr A, slong lenA, mp_srcptr B, slong lenB, nmod_t mod) # Computes the remainder `R` on polynomial division of `A` by `B`. void nmod_poly_rem(nmod_poly_t R, const nmod_poly_t A, const nmod_poly_t B) # Computes the remainder `R` on polynomial division of `A` by `B`. - void _nmod_poly_inv_series_basecase(mp_ptr Qinv, mp_srcptr Q, long Qlen, long n, nmod_t mod) + void _nmod_poly_inv_series_basecase(mp_ptr Qinv, mp_srcptr Q, slong Qlen, slong n, nmod_t mod) # Given ``Q`` of length ``Qlen`` whose leading coefficient is invertible # modulo the given modulus, finds a polynomial ``Qinv`` of length ``n`` # such that the top ``n`` coefficients of the product ``Q * Qinv`` is # `x^{n - 1}`. Requires that ``n > 0``. This function can be viewed as # inverting a power series. - void nmod_poly_inv_series_basecase(nmod_poly_t Qinv, const nmod_poly_t Q, long n) + void nmod_poly_inv_series_basecase(nmod_poly_t Qinv, const nmod_poly_t Q, slong n) # Given ``Q`` of length at least ``n`` find ``Qinv`` of length # ``n`` such that the top ``n`` coefficients of the product # ``Q * Qinv`` is `x^{n - 1}`. An exception is raised if ``n = 0`` @@ -731,34 +731,34 @@ cdef extern from "flint_wrap.h": # coefficient of ``Q`` must be invertible modulo the modulus of # ``Q``. This function can be viewed as inverting a power series. - void _nmod_poly_inv_series_newton(mp_ptr Qinv, mp_srcptr Q, long Qlen, long n, nmod_t mod) + void _nmod_poly_inv_series_newton(mp_ptr Qinv, mp_srcptr Q, slong Qlen, slong n, nmod_t mod) # Given ``Q`` of length ``Qlen`` whose constant coefficient is invertible # modulo the given modulus, find a polynomial ``Qinv`` of length ``n`` # such that ``Q * Qinv`` is ``1`` modulo `x^n`. Requires ``n > 0``. # This function can be viewed as inverting a power series via Newton # iteration. - void nmod_poly_inv_series_newton(nmod_poly_t Qinv, const nmod_poly_t Q, long n) + void nmod_poly_inv_series_newton(nmod_poly_t Qinv, const nmod_poly_t Q, slong n) # Given ``Q`` find ``Qinv`` such that ``Q * Qinv`` is ``1`` # modulo `x^n`. The constant coefficient of ``Q`` must be invertible # modulo the modulus of ``Q``. An exception is raised if this is not # the case or if ``n = 0``. This function can be viewed as inverting # a power series via Newton iteration. - void _nmod_poly_inv_series(mp_ptr Qinv, mp_srcptr Q, long Qlen, long n, nmod_t mod) + void _nmod_poly_inv_series(mp_ptr Qinv, mp_srcptr Q, slong Qlen, slong n, nmod_t mod) # Given ``Q`` of length ``Qlenn`` whose constant coefficient is invertible # modulo the given modulus, find a polynomial ``Qinv`` of length ``n`` # such that ``Q * Qinv`` is ``1`` modulo `x^n`. Requires ``n > 0``. # This function can be viewed as inverting a power series. - void nmod_poly_inv_series(nmod_poly_t Qinv, const nmod_poly_t Q, long n) + void nmod_poly_inv_series(nmod_poly_t Qinv, const nmod_poly_t Q, slong n) # Given ``Q`` find ``Qinv`` such that ``Q * Qinv`` is ``1`` # modulo `x^n`. The constant coefficient of ``Q`` must be invertible # modulo the modulus of ``Q``. An exception is raised if this is not # the case or if ``n = 0``. This function can be viewed as inverting # a power series. - void _nmod_poly_div_series_basecase(mp_ptr Q, mp_srcptr A, long Alen, mp_srcptr B, long Blen, long n, nmod_t mod) + void _nmod_poly_div_series_basecase(mp_ptr Q, mp_srcptr A, slong Alen, mp_srcptr B, slong Blen, slong n, nmod_t mod) # Given polynomials ``A`` and ``B`` of length ``Alen`` and # ``Blen``, finds the # polynomial ``Q`` of length ``n`` such that ``Q * B = A`` @@ -766,7 +766,7 @@ cdef extern from "flint_wrap.h": # of ``B`` is invertible modulo the given modulus. The polynomial # ``Q`` must have space for ``n`` coefficients. - void nmod_poly_div_series_basecase(nmod_poly_t Q, const nmod_poly_t A, const nmod_poly_t B, long n) + void nmod_poly_div_series_basecase(nmod_poly_t Q, const nmod_poly_t A, const nmod_poly_t B, slong n) # Given polynomials ``A`` and ``B`` considered modulo ``n``, # finds the polynomial ``Q`` of length at most ``n`` such that # ``Q * B = A`` modulo `x^n`. We assume ``n > 0`` and that the @@ -774,7 +774,7 @@ cdef extern from "flint_wrap.h": # An exception is raised if ``n == 0`` or the constant coefficient # of ``B`` is zero. - void _nmod_poly_div_series(mp_ptr Q, mp_srcptr A, long Alen, mp_srcptr B, long Blen, long n, nmod_t mod) + void _nmod_poly_div_series(mp_ptr Q, mp_srcptr A, slong Alen, mp_srcptr B, slong Blen, slong n, nmod_t mod) # Given polynomials ``A`` and ``B`` of length ``Alen`` and # ``Blen``, finds the # polynomial ``Q`` of length ``n`` such that ``Q * B = A`` @@ -782,7 +782,7 @@ cdef extern from "flint_wrap.h": # of ``B`` is invertible modulo the given modulus. The polynomial # ``Q`` must have space for ``n`` coefficients. - void nmod_poly_div_series(nmod_poly_t Q, const nmod_poly_t A, const nmod_poly_t B, long n) + void nmod_poly_div_series(nmod_poly_t Q, const nmod_poly_t A, const nmod_poly_t B, slong n) # Given polynomials ``A`` and ``B`` considered modulo ``n``, # finds the polynomial ``Q`` of length at most ``n`` such that # ``Q * B = A`` modulo `x^n`. We assume ``n > 0`` and that the @@ -790,7 +790,7 @@ cdef extern from "flint_wrap.h": # An exception is raised if ``n == 0`` or the constant coefficient # of ``B`` is zero. - void _nmod_poly_div_newton_n_preinv (mp_ptr Q, mp_srcptr A, long lenA, mp_srcptr B, long lenB, mp_srcptr Binv, long lenBinv, nmod_t mod) + void _nmod_poly_div_newton_n_preinv (mp_ptr Q, mp_srcptr A, slong lenA, mp_srcptr B, slong lenB, mp_srcptr Binv, slong lenBinv, nmod_t mod) # Notionally computes polynomials `Q` and `R` such that `A = BQ + R` with # `\operatorname{len}(R)` less than ``lenB``, where ``A`` is of length ``lenA`` # and ``B`` is of length ``lenB``, but return only `Q`. @@ -810,7 +810,7 @@ cdef extern from "flint_wrap.h": # The algorithm used is to reverse the polynomials and divide the # resulting power series, then reverse the result. - void _nmod_poly_divrem_newton_n_preinv (mp_ptr Q, mp_ptr R, mp_srcptr A, long lenA, mp_srcptr B, long lenB, mp_srcptr Binv, long lenBinv, nmod_t mod) + void _nmod_poly_divrem_newton_n_preinv (mp_ptr Q, mp_ptr R, mp_srcptr A, slong lenA, mp_srcptr B, slong lenB, mp_srcptr Binv, slong lenBinv, nmod_t mod) # Computes `Q` and `R` such that `A = BQ + R` with `\operatorname{len}(R)` less than # ``lenB``, where `A` is of length ``lenA`` and `B` is of length # ``lenB``. We require that `Q` have space for ``lenA - lenB + 1`` @@ -827,7 +827,7 @@ cdef extern from "flint_wrap.h": # The algorithm used is to call :func:`div_newton_n` and then multiply out # and compute the remainder. - mp_limb_t _nmod_poly_div_root(mp_ptr Q, mp_srcptr A, long len, mp_limb_t c, nmod_t mod) + mp_limb_t _nmod_poly_div_root(mp_ptr Q, mp_srcptr A, slong len, mp_limb_t c, nmod_t mod) # Sets ``(Q, len-1)`` to the quotient of ``(A, len)`` on division # by `(x - c)`, and returns the remainder, equal to the value of `A` # evaluated at `c`. `A` and `Q` are allowed to be the same, but may @@ -837,7 +837,7 @@ cdef extern from "flint_wrap.h": # Sets `Q` to the quotient of `A` on division by `(x - c)`, and returns # the remainder, equal to the value of `A` evaluated at `c`. - int _nmod_poly_divides_classical(mp_ptr Q, mp_srcptr A, long lenA, mp_srcptr B, long lenB, nmod_t mod) + int _nmod_poly_divides_classical(mp_ptr Q, mp_srcptr A, slong lenA, mp_srcptr B, slong lenB, nmod_t mod) # Returns `1` if `(B, lenB)` divides `(A, lenA)` and sets # `(Q, lenA - lenB + 1)` to the quotient. Otherwise, returns `0` and sets # `(Q, lenA - lenB + 1)` to zero. We require that `lenA >= lenB > 0`. @@ -846,7 +846,7 @@ cdef extern from "flint_wrap.h": # Returns `1` if `B` divides `A` and sets `Q` to the quotient. Otherwise # returns `0` and sets `Q` to zero. - int _nmod_poly_divides(mp_ptr Q, mp_srcptr A, long lenA, mp_srcptr B, long lenB, nmod_t mod) + int _nmod_poly_divides(mp_ptr Q, mp_srcptr A, slong lenA, mp_srcptr B, slong lenB, nmod_t mod) # Returns `1` if `(B, lenB)` divides `(A, lenA)` and sets # `(Q, lenA - lenB + 1)` to the quotient. Otherwise, returns `0` and sets # `(Q, lenA - lenB + 1)` to zero. We require that `lenA >= lenB > 0`. @@ -855,7 +855,7 @@ cdef extern from "flint_wrap.h": # Returns `1` if `B` divides `A` and sets `Q` to the quotient. Otherwise # returns `0` and sets `Q` to zero. - void _nmod_poly_derivative(mp_ptr x_prime, mp_srcptr x, long len, nmod_t mod) + void _nmod_poly_derivative(mp_ptr x_prime, mp_srcptr x, slong len, nmod_t mod) # Sets the first ``len - 1`` coefficients of ``x_prime`` to the # derivative of ``x`` which is assumed to be of length ``len``. # It is assumed that ``len > 0``. @@ -863,7 +863,7 @@ cdef extern from "flint_wrap.h": void nmod_poly_derivative(nmod_poly_t x_prime, const nmod_poly_t x) # Sets ``x_prime`` to the derivative of ``x``. - void _nmod_poly_integral(mp_ptr x_int, mp_srcptr x, long len, nmod_t mod) + void _nmod_poly_integral(mp_ptr x_int, mp_srcptr x, slong len, nmod_t mod) # Set the first ``len`` coefficients of ``x_int`` to the # integral of ``x`` which is assumed to be of length ``len - 1``. # The constant term of ``x_int`` is set to zero. @@ -876,7 +876,7 @@ cdef extern from "flint_wrap.h": # term zero. The result is only well-defined if the modulus # is a prime number strictly larger than the degree of ``x``. - mp_limb_t _nmod_poly_evaluate_nmod(mp_srcptr poly, long len, mp_limb_t c, nmod_t mod) + mp_limb_t _nmod_poly_evaluate_nmod(mp_srcptr poly, slong len, mp_limb_t c, nmod_t mod) # Evaluates ``poly`` at the value ``c`` and reduces modulo the # given modulus of ``poly``. The value ``c`` should be reduced # modulo the modulus. The algorithm used is Horner's method. @@ -906,48 +906,48 @@ cdef extern from "flint_wrap.h": # ``c`` may be aliased. This function automatically switches between # Horner's method and the Paterson-Stockmeyer algorithm. - void _nmod_poly_evaluate_nmod_vec_iter(mp_ptr ys, mp_srcptr poly, long len, mp_srcptr xs, long n, nmod_t mod) + void _nmod_poly_evaluate_nmod_vec_iter(mp_ptr ys, mp_srcptr poly, slong len, mp_srcptr xs, slong n, nmod_t mod) # Evaluates (``coeffs``, ``len``) at the ``n`` values # given in the vector ``xs``, writing the output values # to ``ys``. The values in ``xs`` should be reduced # modulo the modulus. # Uses Horner's method iteratively. - void nmod_poly_evaluate_nmod_vec_iter(mp_ptr ys, const nmod_poly_t poly, mp_srcptr xs, long n) + void nmod_poly_evaluate_nmod_vec_iter(mp_ptr ys, const nmod_poly_t poly, mp_srcptr xs, slong n) # Evaluates ``poly`` at the ``n`` values given in the vector # ``xs``, writing the output values to ``ys``. The values in # ``xs`` should be reduced modulo the modulus. # Uses Horner's method iteratively. - void _nmod_poly_evaluate_nmod_vec_fast_precomp(mp_ptr vs, mp_srcptr poly, long plen, const mp_ptr * tree, long len, nmod_t mod) + void _nmod_poly_evaluate_nmod_vec_fast_precomp(mp_ptr vs, mp_srcptr poly, slong plen, const mp_ptr * tree, slong len, nmod_t mod) # Evaluates (``poly``, ``plen``) at the ``len`` values given # by the precomputed subproduct tree ``tree``. - void _nmod_poly_evaluate_nmod_vec_fast(mp_ptr ys, mp_srcptr poly, long len, mp_srcptr xs, long n, nmod_t mod) + void _nmod_poly_evaluate_nmod_vec_fast(mp_ptr ys, mp_srcptr poly, slong len, mp_srcptr xs, slong n, nmod_t mod) # Evaluates (``coeffs``, ``len``) at the ``n`` values # given in the vector ``xs``, writing the output values # to ``ys``. The values in ``xs`` should be reduced # modulo the modulus. # Uses fast multipoint evaluation, building a temporary subproduct tree. - void nmod_poly_evaluate_nmod_vec_fast(mp_ptr ys, const nmod_poly_t poly, mp_srcptr xs, long n) + void nmod_poly_evaluate_nmod_vec_fast(mp_ptr ys, const nmod_poly_t poly, mp_srcptr xs, slong n) # Evaluates ``poly`` at the ``n`` values given in the vector # ``xs``, writing the output values to ``ys``. The values in # ``xs`` should be reduced modulo the modulus. # Uses fast multipoint evaluation, building a temporary subproduct tree. - void _nmod_poly_evaluate_nmod_vec(mp_ptr ys, mp_srcptr poly, long len, mp_srcptr xs, long n, nmod_t mod) + void _nmod_poly_evaluate_nmod_vec(mp_ptr ys, mp_srcptr poly, slong len, mp_srcptr xs, slong n, nmod_t mod) # Evaluates (``poly``, ``len``) at the ``n`` values # given in the vector ``xs``, writing the output values # to ``ys``. The values in ``xs`` should be reduced # modulo the modulus. - void nmod_poly_evaluate_nmod_vec(mp_ptr ys, const nmod_poly_t poly, mp_srcptr xs, long n) + void nmod_poly_evaluate_nmod_vec(mp_ptr ys, const nmod_poly_t poly, mp_srcptr xs, slong n) # Evaluates ``poly`` at the ``n`` values given in the vector # ``xs``, writing the output values to ``ys``. The values in # ``xs`` should be reduced modulo the modulus. - void _nmod_poly_interpolate_nmod_vec(mp_ptr poly, mp_srcptr xs, mp_srcptr ys, long n, nmod_t mod) + void _nmod_poly_interpolate_nmod_vec(mp_ptr poly, mp_srcptr xs, mp_srcptr ys, slong n, nmod_t mod) # Sets ``poly`` to the unique polynomial of length at most ``n`` # that interpolates the ``n`` given evaluation points ``xs`` and # values ``ys``. If the interpolating polynomial is shorter than @@ -956,17 +956,17 @@ cdef extern from "flint_wrap.h": # modulus, and all ``xs`` must be distinct. Aliasing between # ``poly`` and ``xs`` or ``ys`` is not allowed. - void nmod_poly_interpolate_nmod_vec(nmod_poly_t poly, mp_srcptr xs, mp_srcptr ys, long n) + void nmod_poly_interpolate_nmod_vec(nmod_poly_t poly, mp_srcptr xs, mp_srcptr ys, slong n) # Sets ``poly`` to the unique polynomial of length ``n`` that # interpolates the ``n`` given evaluation points ``xs`` and # values ``ys``. The values in ``xs`` and ``ys`` should be # reduced modulo the modulus, and all ``xs`` must be distinct. - void _nmod_poly_interpolation_weights(mp_ptr w, const mp_ptr * tree, long len, nmod_t mod) + void _nmod_poly_interpolation_weights(mp_ptr w, const mp_ptr * tree, slong len, nmod_t mod) # Sets ``w`` to the barycentric interpolation weights for fast # Lagrange interpolation with respect to a given subproduct tree. - void _nmod_poly_interpolate_nmod_vec_fast_precomp(mp_ptr poly, mp_srcptr ys, const mp_ptr * tree, mp_srcptr weights, long len, nmod_t mod) + void _nmod_poly_interpolate_nmod_vec_fast_precomp(mp_ptr poly, mp_srcptr ys, const mp_ptr * tree, mp_srcptr weights, slong len, nmod_t mod) # Performs interpolation using the fast Lagrange interpolation # algorithm, generating a temporary subproduct tree. # The function values are given as ``ys``. The function takes @@ -974,33 +974,33 @@ cdef extern from "flint_wrap.h": # interpolation weights ``weights`` corresponding to the # roots. - void _nmod_poly_interpolate_nmod_vec_fast(mp_ptr poly, mp_srcptr xs, mp_srcptr ys, long n, nmod_t mod) + void _nmod_poly_interpolate_nmod_vec_fast(mp_ptr poly, mp_srcptr xs, mp_srcptr ys, slong n, nmod_t mod) # Performs interpolation using the fast Lagrange interpolation # algorithm, generating a temporary subproduct tree. - void nmod_poly_interpolate_nmod_vec_fast(nmod_poly_t poly, mp_srcptr xs, mp_srcptr ys, long n) + void nmod_poly_interpolate_nmod_vec_fast(nmod_poly_t poly, mp_srcptr xs, mp_srcptr ys, slong n) # Performs interpolation using the fast Lagrange interpolation algorithm, # generating a temporary subproduct tree. - void _nmod_poly_interpolate_nmod_vec_newton(mp_ptr poly, mp_srcptr xs, mp_srcptr ys, long n, nmod_t mod) + void _nmod_poly_interpolate_nmod_vec_newton(mp_ptr poly, mp_srcptr xs, mp_srcptr ys, slong n, nmod_t mod) # Forms the interpolating polynomial in the Newton basis using # the method of divided differences and then converts it to # monomial form. - void nmod_poly_interpolate_nmod_vec_newton(nmod_poly_t poly, mp_srcptr xs, mp_srcptr ys, long n) + void nmod_poly_interpolate_nmod_vec_newton(nmod_poly_t poly, mp_srcptr xs, mp_srcptr ys, slong n) # Forms the interpolating polynomial in the Newton basis using # the method of divided differences and then converts it to # monomial form. - void _nmod_poly_interpolate_nmod_vec_barycentric(mp_ptr poly, mp_srcptr xs, mp_srcptr ys, long n, nmod_t mod) + void _nmod_poly_interpolate_nmod_vec_barycentric(mp_ptr poly, mp_srcptr xs, mp_srcptr ys, slong n, nmod_t mod) # Forms the interpolating polynomial using a naive implementation # of the barycentric form of Lagrange interpolation. - void nmod_poly_interpolate_nmod_vec_barycentric(nmod_poly_t poly, mp_srcptr xs, mp_srcptr ys, long n) + void nmod_poly_interpolate_nmod_vec_barycentric(nmod_poly_t poly, mp_srcptr xs, mp_srcptr ys, slong n) # Forms the interpolating polynomial using a naive implementation # of the barycentric form of Lagrange interpolation. - void _nmod_poly_compose_horner(mp_ptr res, mp_srcptr poly1, long len1, mp_srcptr poly2, long len2, nmod_t mod) + void _nmod_poly_compose_horner(mp_ptr res, mp_srcptr poly1, slong len1, mp_srcptr poly2, slong len2, nmod_t mod) # Composes ``poly1`` of length ``len1`` with ``poly2`` of length # ``len2`` and sets ``res`` to the result, i.e. evaluates # ``poly1`` at ``poly2``. The algorithm used is Horner's algorithm. @@ -1012,7 +1012,7 @@ cdef extern from "flint_wrap.h": # i.e. evaluates ``poly1`` at ``poly2``. The algorithm used is # Horner's algorithm. - void _nmod_poly_compose_divconquer(mp_ptr res, mp_srcptr poly1, long len1, mp_srcptr poly2, long len2, nmod_t mod) + void _nmod_poly_compose_divconquer(mp_ptr res, mp_srcptr poly1, slong len1, mp_srcptr poly2, slong len2, nmod_t mod) # Composes ``poly1`` of length ``len1`` with ``poly2`` of length # ``len2`` and sets ``res`` to the result, i.e. evaluates # ``poly1`` at ``poly2``. The algorithm used is the divide and @@ -1025,7 +1025,7 @@ cdef extern from "flint_wrap.h": # i.e. evaluates ``poly1`` at ``poly2``. The algorithm used is # the divide and conquer algorithm. - void _nmod_poly_compose(mp_ptr res, mp_srcptr poly1, long len1, mp_srcptr poly2, long len2, nmod_t mod) + void _nmod_poly_compose(mp_ptr res, mp_srcptr poly1, slong len1, mp_srcptr poly2, slong len2, nmod_t mod) # Composes ``poly1`` of length ``len1`` with ``poly2`` of length # ``len2`` and sets ``res`` to the result, i.e. evaluates ``poly1`` # at ``poly2``. We require that ``res`` have space for @@ -1036,14 +1036,14 @@ cdef extern from "flint_wrap.h": # Composes ``poly1`` with ``poly2`` and sets ``res`` to the result, # that is, evaluates ``poly1`` at ``poly2``. - void _nmod_poly_taylor_shift_horner(mp_ptr poly, mp_limb_t c, long len, nmod_t mod) + void _nmod_poly_taylor_shift_horner(mp_ptr poly, mp_limb_t c, slong len, nmod_t mod) # Performs the Taylor shift composing ``poly`` by `x+c` in-place. # Uses an efficient version Horner's rule. void nmod_poly_taylor_shift_horner(nmod_poly_t g, const nmod_poly_t f, mp_limb_t c) # Performs the Taylor shift composing ``f`` by `x+c`. - void _nmod_poly_taylor_shift_convolution(mp_ptr poly, mp_limb_t c, long len, nmod_t mod) + void _nmod_poly_taylor_shift_convolution(mp_ptr poly, mp_limb_t c, slong len, nmod_t mod) # Performs the Taylor shift composing ``poly`` by `x+c` in-place. # Writes the composition as a single convolution with cost `O(M(n))`. # We require that the modulus is a prime at least as large as the length. @@ -1053,7 +1053,7 @@ cdef extern from "flint_wrap.h": # Writes the composition as a single convolution with cost `O(M(n))`. # We require that the modulus is a prime at least as large as the length. - void _nmod_poly_taylor_shift(mp_ptr poly, mp_limb_t c, long len, nmod_t mod) + void _nmod_poly_taylor_shift(mp_ptr poly, mp_limb_t c, slong len, nmod_t mod) # Performs the Taylor shift composing ``poly`` by `x+c` in-place. # We require that the modulus is a prime. @@ -1061,7 +1061,7 @@ cdef extern from "flint_wrap.h": # Performs the Taylor shift composing ``f`` by `x+c`. # We require that the modulus is a prime. - void _nmod_poly_compose_mod_horner(mp_ptr res, mp_srcptr f, long lenf, mp_srcptr g, mp_srcptr h, long lenh, nmod_t mod) + void _nmod_poly_compose_mod_horner(mp_ptr res, mp_srcptr f, slong lenf, mp_srcptr g, mp_srcptr h, slong lenh, nmod_t mod) # Sets ``res`` to the composition `f(g)` modulo `h`. We require that # `h` is nonzero and that the length of `g` is one less than the # length of `h` (possibly with zero padding). The output is not allowed @@ -1072,7 +1072,7 @@ cdef extern from "flint_wrap.h": # Sets ``res`` to the composition `f(g)` modulo `h`. We require that # `h` is nonzero. The algorithm used is Horner's rule. - void _nmod_poly_compose_mod_brent_kung(mp_ptr res, mp_srcptr f, long lenf, mp_srcptr g, mp_srcptr h, long lenh, nmod_t mod) + void _nmod_poly_compose_mod_brent_kung(mp_ptr res, mp_srcptr f, slong lenf, mp_srcptr g, mp_srcptr h, slong lenh, nmod_t mod) # Sets ``res`` to the composition `f(g)` modulo `h`. We require that # `h` is nonzero and that the length of `g` is one less than the # length of `h` (possibly with zero padding). We also require that @@ -1085,7 +1085,7 @@ cdef extern from "flint_wrap.h": # `h` is nonzero and that `f` has smaller degree than `h`. # The algorithm used is the Brent-Kung matrix algorithm. - void _nmod_poly_compose_mod_brent_kung_preinv(mp_ptr res, mp_srcptr f, long lenf, mp_srcptr g, mp_srcptr h, long lenh, mp_srcptr hinv, long lenhinv, nmod_t mod) + void _nmod_poly_compose_mod_brent_kung_preinv(mp_ptr res, mp_srcptr f, slong lenf, mp_srcptr g, mp_srcptr h, slong lenh, mp_srcptr hinv, slong lenhinv, nmod_t mod) # Sets ``res`` to the composition `f(g)` modulo `h`. We require that # `h` is nonzero and that the length of `g` is one less than the # length of `h` (possibly with zero padding). We also require that @@ -1109,7 +1109,7 @@ cdef extern from "flint_wrap.h": # Worker function version of ``_nmod_poly_precompute_matrix``. # Input/output is stored in ``nmod_poly_matrix_precompute_arg_t``. - void _nmod_poly_precompute_matrix (nmod_mat_t A, mp_srcptr f, mp_srcptr g, long leng, mp_srcptr ginv, long lenginv, nmod_t mod) + void _nmod_poly_precompute_matrix (nmod_mat_t A, mp_srcptr f, mp_srcptr g, slong leng, mp_srcptr ginv, slong lenginv, nmod_t mod) # Sets the ith row of ``A`` to `f^i` modulo `g` for # `i=1,\ldots,\sqrt{\deg(g)}`. We require `A` to be # a `\sqrt{\deg(g)}\times \deg(g)` matrix. We require @@ -1129,7 +1129,7 @@ cdef extern from "flint_wrap.h": # Input/output is stored in # ``nmod_poly_compose_mod_precomp_preinv_arg_t``. - void _nmod_poly_compose_mod_brent_kung_precomp_preinv(mp_ptr res, mp_srcptr f, long lenf, const nmod_mat_t A, mp_srcptr h, long lenh, mp_srcptr hinv, long lenhinv, nmod_t mod) + void _nmod_poly_compose_mod_brent_kung_precomp_preinv(mp_ptr res, mp_srcptr f, slong lenf, const nmod_mat_t A, mp_srcptr h, slong lenh, mp_srcptr hinv, slong lenhinv, nmod_t mod) # Sets ``res`` to the composition `f(g)` modulo `h`. We require that # `h` is nonzero. We require that the ith row of `A` contains `g^i` for # `i=1,\ldots,\sqrt{\deg(h)}`, i.e. `A` is a @@ -1148,7 +1148,7 @@ cdef extern from "flint_wrap.h": # modular composition is particularly useful if one has to perform several # modular composition of the form `f(g)` modulo `h` for fixed `g` and `h`. - void _nmod_poly_compose_mod_brent_kung_vec_preinv(nmod_poly_struct * res, const nmod_poly_struct * polys, long len1, long l, mp_srcptr g, long leng, mp_srcptr h, long lenh, mp_srcptr hinv, long lenhinv, nmod_t mod) + void _nmod_poly_compose_mod_brent_kung_vec_preinv(nmod_poly_struct * res, const nmod_poly_struct * polys, slong len1, slong l, mp_srcptr g, slong leng, mp_srcptr h, slong lenh, mp_srcptr hinv, slong lenhinv, nmod_t mod) # Sets ``res`` to the composition `f_i(g)` modulo `h` for `1\leq i \leq l`, # where `f_i` are the first ``l`` elements of ``polys``. We require that `h` # is nonzero and that the length of `g` is less than the length of `h`. We @@ -1160,7 +1160,7 @@ cdef extern from "flint_wrap.h": # aliased with any of the inputs. # The algorithm used is the Brent-Kung matrix algorithm. - void nmod_poly_compose_mod_brent_kung_vec_preinv(nmod_poly_struct * res, const nmod_poly_struct * polys, long len1, long n, const nmod_poly_t g, const nmod_poly_t h, const nmod_poly_t hinv) + void nmod_poly_compose_mod_brent_kung_vec_preinv(nmod_poly_struct * res, const nmod_poly_struct * polys, slong len1, slong n, const nmod_poly_t g, const nmod_poly_t h, const nmod_poly_t hinv) # Sets ``res`` to the composition `f_i(g)` modulo `h` for `1\leq i \leq n` # where `f_i` are the first ``n`` elements of ``polys``. We require ``res`` # to have enough memory allocated to hold ``n`` ``nmod_poly_struct``. The @@ -1170,22 +1170,22 @@ cdef extern from "flint_wrap.h": # of the reverse of ``h``. No aliasing of ``res`` and ``polys`` is allowed. # The algorithm used is the Brent-Kung matrix algorithm. - void _nmod_poly_compose_mod_brent_kung_vec_preinv_threaded_pool(nmod_poly_struct * res, const nmod_poly_struct * polys, long lenpolys, long l, mp_srcptr g, long glen, mp_srcptr poly, long len, mp_srcptr polyinv, long leninv, nmod_t mod, thread_pool_handle * threads, long num_threads) + void _nmod_poly_compose_mod_brent_kung_vec_preinv_threaded_pool(nmod_poly_struct * res, const nmod_poly_struct * polys, slong lenpolys, slong l, mp_srcptr g, slong glen, mp_srcptr poly, slong len, mp_srcptr polyinv, slong leninv, nmod_t mod, thread_pool_handle * threads, slong num_threads) # Multithreaded version of # :func:`_nmod_poly_compose_mod_brent_kung_vec_preinv`. Distributing the # Horner evaluations across :func:`flint_get_num_threads` threads. - void nmod_poly_compose_mod_brent_kung_vec_preinv_threaded_pool(nmod_poly_struct * res, const nmod_poly_struct * polys, long len1, long n, const nmod_poly_t g, const nmod_poly_t poly, const nmod_poly_t polyinv, thread_pool_handle * threads, long num_threads) + void nmod_poly_compose_mod_brent_kung_vec_preinv_threaded_pool(nmod_poly_struct * res, const nmod_poly_struct * polys, slong len1, slong n, const nmod_poly_t g, const nmod_poly_t poly, const nmod_poly_t polyinv, thread_pool_handle * threads, slong num_threads) # Multithreaded version of # :func:`nmod_poly_compose_mod_brent_kung_vec_preinv`. Distributing the # Horner evaluations across :func:`flint_get_num_threads` threads. - void nmod_poly_compose_mod_brent_kung_vec_preinv_threaded(nmod_poly_struct * res, const nmod_poly_struct * polys, long len1, long n, const nmod_poly_t g, const nmod_poly_t poly, const nmod_poly_t polyinv) + void nmod_poly_compose_mod_brent_kung_vec_preinv_threaded(nmod_poly_struct * res, const nmod_poly_struct * polys, slong len1, slong n, const nmod_poly_t g, const nmod_poly_t poly, const nmod_poly_t polyinv) # Multithreaded version of # :func:`nmod_poly_compose_mod_brent_kung_vec_preinv`. Distributing the # Horner evaluations across :func:`flint_get_num_threads` threads. - void _nmod_poly_compose_mod(mp_ptr res, mp_srcptr f, long lenf, mp_srcptr g, mp_srcptr h, long lenh, nmod_t mod) + void _nmod_poly_compose_mod(mp_ptr res, mp_srcptr f, slong lenf, mp_srcptr g, mp_srcptr h, slong lenh, nmod_t mod) # Sets ``res`` to the composition `f(g)` modulo `h`. We require that # `h` is nonzero and that the length of `g` is one less than the # length of `h` (possibly with zero padding). The output is not allowed @@ -1195,7 +1195,7 @@ cdef extern from "flint_wrap.h": # Sets ``res`` to the composition `f(g)` modulo `h`. We require that # `h` is nonzero. - long _nmod_poly_gcd_euclidean(mp_ptr G, mp_srcptr A, long lenA, mp_srcptr B, long lenB, nmod_t mod) + slong _nmod_poly_gcd_euclidean(mp_ptr G, mp_srcptr A, slong lenA, mp_srcptr B, slong lenB, nmod_t mod) # Computes the GCD of `A` of length ``lenA`` and `B` of length # ``lenB``, where ``lenA >= lenB > 0``. The length of the GCD `G` # is returned by the function. No attempt is made to make the GCD monic. It @@ -1207,7 +1207,7 @@ cdef extern from "flint_wrap.h": # polynomial `P` is defined to be `P`. Except in the case where # the GCD is zero, the GCD `G` is made monic. - long _nmod_poly_hgcd(mp_ptr *M, long *lenM, mp_ptr A, long *lenA, mp_ptr B, long *lenB, mp_srcptr a, long lena, mp_srcptr b, long lenb, nmod_t mod) + slong _nmod_poly_hgcd(mp_ptr *M, slong *lenM, mp_ptr A, slong *lenA, mp_ptr B, slong *lenB, mp_srcptr a, slong lena, mp_srcptr b, slong lenb, nmod_t mod) # Computes the HGCD of `a` and `b`, that is, a matrix `M`, a sign `\sigma` # and two polynomials `A` and `B` such that # .. math :: @@ -1222,7 +1222,7 @@ cdef extern from "flint_wrap.h": # Assumes that ``M[0]``, ``M[1]``, ``M[2]``, and ``M[3]`` # each point to a vector of size at least `\operatorname{len}(a)`. - long _nmod_poly_gcd_hgcd(mp_ptr G, mp_srcptr A, long lenA, mp_srcptr B, long lenB, nmod_t mod) + slong _nmod_poly_gcd_hgcd(mp_ptr G, mp_srcptr A, slong lenA, mp_srcptr B, slong lenB, nmod_t mod) # Computes the monic GCD of `A` and `B`, assuming that # `\operatorname{len}(A) \geq \operatorname{len}(B) > 0`. # Assumes that `G` has space for `\operatorname{len}(B)` coefficients and @@ -1235,7 +1235,7 @@ cdef extern from "flint_wrap.h": # The time complexity of the algorithm is `\mathcal{O}(n \log^2 n)`. # For further details, see [ThullYap1990]_. - long _nmod_poly_gcd(mp_ptr G, mp_srcptr A, long lenA, mp_srcptr B, long lenB, nmod_t mod) + slong _nmod_poly_gcd(mp_ptr G, mp_srcptr A, slong lenA, mp_srcptr B, slong lenB, nmod_t mod) # Computes the GCD of `A` of length ``lenA`` and `B` of length # ``lenB``, where ``lenA >= lenB > 0``. The length of the GCD `G` # is returned by the function. No attempt is made to make the GCD monic. It @@ -1247,7 +1247,7 @@ cdef extern from "flint_wrap.h": # polynomial `P` is defined to be `P`. Except in the case where # the GCD is zero, the GCD `G` is made monic. - long _nmod_poly_xgcd_euclidean(mp_ptr G, mp_ptr S, mp_ptr T, mp_srcptr A, long A_len, mp_srcptr B, long B_len, nmod_t mod) + slong _nmod_poly_xgcd_euclidean(mp_ptr G, mp_ptr S, mp_ptr T, mp_srcptr A, slong A_len, mp_srcptr B, slong B_len, nmod_t mod) # Computes the GCD of `A` and `B` together with cofactors `S` and `T` # such that `S A + T B = G`. Returns the length of `G`. # Assumes that `\operatorname{len}(A) \geq \operatorname{len}(B) \geq 1` and @@ -1268,7 +1268,7 @@ cdef extern from "flint_wrap.h": # ``S*A + T*B = G``. The length of ``S`` will be at most # ``lenB`` and the length of ``T`` will be at most ``lenA``. - long _nmod_poly_xgcd_hgcd(mp_ptr G, mp_ptr S, mp_ptr T, mp_srcptr A, long A_len, mp_srcptr B, long B_len, nmod_t mod) + slong _nmod_poly_xgcd_hgcd(mp_ptr G, mp_ptr S, mp_ptr T, mp_srcptr A, slong A_len, mp_srcptr B, slong B_len, nmod_t mod) # Computes the GCD of `A` and `B`, where `\operatorname{len}(A) \geq \operatorname{len}(B) > 0`, # together with cofactors `S` and `T` such that `S A + T B = G`. Returns # the length of `G`. @@ -1289,7 +1289,7 @@ cdef extern from "flint_wrap.h": # ``S*A + T*B = G``. The length of ``S`` will be at most # ``lenB`` and the length of ``T`` will be at most ``lenA``. - long _nmod_poly_xgcd(mp_ptr G, mp_ptr S, mp_ptr T, mp_srcptr A, long lenA, mp_srcptr B, long lenB, nmod_t mod) + slong _nmod_poly_xgcd(mp_ptr G, mp_ptr S, mp_ptr T, mp_srcptr A, slong lenA, mp_srcptr B, slong lenB, nmod_t mod) # Computes the GCD of `A` and `B`, where `\operatorname{len}(A) \geq \operatorname{len}(B) > 0`, # together with cofactors `S` and `T` such that `S A + T B = G`. Returns # the length of `G`. @@ -1309,7 +1309,7 @@ cdef extern from "flint_wrap.h": # ``S*A + T*B = G``. The length of ``S`` will be at most # ``lenB`` and the length of ``T`` will be at most ``lenA``. - mp_limb_t _nmod_poly_resultant_euclidean(mp_srcptr poly1, long len1, mp_srcptr poly2, long len2, nmod_t mod) + mp_limb_t _nmod_poly_resultant_euclidean(mp_srcptr poly1, slong len1, mp_srcptr poly2, slong len2, nmod_t mod) # Returns the resultant of ``(poly1, len1)`` and # ``(poly2, len2)`` using the Euclidean algorithm. # Assumes that ``len1 >= len2 > 0``. @@ -1325,7 +1325,7 @@ cdef extern from "flint_wrap.h": # For convenience, we define the resultant to be equal to zero if either # of the two polynomials is zero. - mp_limb_t _nmod_poly_resultant_hgcd(mp_srcptr poly1, long len1, mp_srcptr poly2, long len2, nmod_t mod) + mp_limb_t _nmod_poly_resultant_hgcd(mp_srcptr poly1, slong len1, mp_srcptr poly2, slong len2, nmod_t mod) # Returns the resultant of ``(poly1, len1)`` and # ``(poly2, len2)`` using the half-gcd algorithm. # This algorithm computes the half-gcd as per :func:`_nmod_poly_gcd_hgcd` @@ -1365,7 +1365,7 @@ cdef extern from "flint_wrap.h": # For convenience, we define the resultant to be equal to zero if either # of the two polynomials is zero. - mp_limb_t _nmod_poly_resultant(mp_srcptr poly1, long len1, mp_srcptr poly2, long len2, nmod_t mod) + mp_limb_t _nmod_poly_resultant(mp_srcptr poly1, slong len1, mp_srcptr poly2, slong len2, nmod_t mod) # Returns the resultant of ``(poly1, len1)`` and # ``(poly2, len2)``. # Assumes that ``len1 >= len2 > 0``. @@ -1381,7 +1381,7 @@ cdef extern from "flint_wrap.h": # For convenience, we define the resultant to be equal to zero if either # of the two polynomials is zero. - long _nmod_poly_gcdinv(mp_limb_t *G, mp_limb_t *S, const mp_limb_t *A, long lenA, const mp_limb_t *B, long lenB, const nmod_t mod) + slong _nmod_poly_gcdinv(mp_limb_t *G, mp_limb_t *S, const mp_limb_t *A, slong lenA, const mp_limb_t *B, slong lenB, const nmod_t mod) # Computes ``(G, lenA)``, ``(S, lenB-1)`` such that # `G \cong S A \pmod{B}`, returning the actual length of `G`. # Assumes that `0 < \operatorname{len}(A) < \operatorname{len}(B)`. @@ -1392,7 +1392,7 @@ cdef extern from "flint_wrap.h": # have `\operatorname{len}(B) \geq 2`. # In the case that `A = 0 \pmod{B}`, returns `G = S = 0`. - int _nmod_poly_invmod(mp_limb_t *A, const mp_limb_t *B, long lenB, const mp_limb_t *P, long lenP, const nmod_t mod) + int _nmod_poly_invmod(mp_limb_t *A, const mp_limb_t *B, slong lenB, const mp_limb_t *P, slong lenP, const nmod_t mod) # Attempts to set ``(A, lenP-1)`` to the inverse of ``(B, lenB)`` # modulo the polynomial ``(P, lenP)``. Returns `1` if ``(B, lenB)`` # is invertible and `0` otherwise. @@ -1410,7 +1410,7 @@ cdef extern from "flint_wrap.h": # sets `A` to the inverse of `B`. Otherwise, returns `0` and the value # of `A` on exit is undefined. - mp_limb_t _nmod_poly_discriminant(mp_srcptr poly, long len, nmod_t mod) + mp_limb_t _nmod_poly_discriminant(mp_srcptr poly, slong len, nmod_t mod) # Return the discriminant of ``(poly, len)``. Assumes ``len > 1``. mp_limb_t nmod_poly_discriminant(const nmod_poly_t f) @@ -1423,7 +1423,7 @@ cdef extern from "flint_wrap.h": # `\operatorname{lc}(f)` is the leading coefficient of `f` and `r_i` are the # roots of `f`. - void _nmod_poly_compose_series(mp_ptr res, mp_srcptr poly1, long len1, mp_srcptr poly2, long len2, long n, nmod_t mod) + void _nmod_poly_compose_series(mp_ptr res, mp_srcptr poly1, slong len1, mp_srcptr poly2, slong len2, slong n, nmod_t mod) # Sets ``res`` to the composition of ``poly1`` and ``poly2`` # modulo `x^n`, where the constant term of ``poly2`` is required # to be zero. @@ -1434,12 +1434,12 @@ cdef extern from "flint_wrap.h": # Wraps :func:`_gr_poly_compose_series` which chooses automatically # between various algorithms. - void nmod_poly_compose_series(nmod_poly_t res, const nmod_poly_t poly1, const nmod_poly_t poly2, long n) + void nmod_poly_compose_series(nmod_poly_t res, const nmod_poly_t poly1, const nmod_poly_t poly2, slong n) # Sets ``res`` to the composition of ``poly1`` and ``poly2`` # modulo `x^n`, where the constant term of ``poly2`` is required # to be zero. - void _nmod_poly_revert_series_lagrange(mp_ptr Qinv, mp_srcptr Q, long n, nmod_t mod) + void _nmod_poly_revert_series_lagrange(mp_ptr Qinv, mp_srcptr Q, slong n, nmod_t mod) # Sets ``Qinv`` to the compositional inverse or reversion of ``Q`` # as a power series, i.e. computes `Q^{-1}` such that # `Q(Q^{-1}(x)) = Q^{-1}(Q(x)) = x \bmod x^n`. The arguments must @@ -1448,7 +1448,7 @@ cdef extern from "flint_wrap.h": # `1, 2, \ldots, n-1` are invertible modulo the modulus. # This implementation uses the Lagrange inversion formula. - void nmod_poly_revert_series_lagrange(nmod_poly_t Qinv, const nmod_poly_t Q, long n) + void nmod_poly_revert_series_lagrange(nmod_poly_t Qinv, const nmod_poly_t Q, slong n) # Sets ``Qinv`` to the compositional inverse or reversion of ``Q`` # as a power series, i.e. computes `Q^{-1}` such that # `Q(Q^{-1}(x)) = Q^{-1}(Q(x)) = x \bmod x^n`. @@ -1456,7 +1456,7 @@ cdef extern from "flint_wrap.h": # `1, 2, \ldots, n-1` are invertible modulo the modulus. # This implementation uses the Lagrange inversion formula. - void _nmod_poly_revert_series_lagrange_fast(mp_ptr Qinv, mp_srcptr Q, long n, nmod_t mod) + void _nmod_poly_revert_series_lagrange_fast(mp_ptr Qinv, mp_srcptr Q, slong n, nmod_t mod) # Sets ``Qinv`` to the compositional inverse or reversion of ``Q`` # as a power series, i.e. computes `Q^{-1}` such that # `Q(Q^{-1}(x)) = Q^{-1}(Q(x)) = x \bmod x^n`. The arguments must @@ -1466,7 +1466,7 @@ cdef extern from "flint_wrap.h": # This implementation uses a reduced-complexity implementation # of the Lagrange inversion formula. - void nmod_poly_revert_series_lagrange_fast(nmod_poly_t Qinv, const nmod_poly_t Q, long n) + void nmod_poly_revert_series_lagrange_fast(nmod_poly_t Qinv, const nmod_poly_t Q, slong n) # Sets ``Qinv`` to the compositional inverse or reversion of ``Q`` # as a power series, i.e. computes `Q^{-1}` such that # `Q(Q^{-1}(x)) = Q^{-1}(Q(x)) = x \bmod x^n`. @@ -1475,7 +1475,7 @@ cdef extern from "flint_wrap.h": # This implementation uses a reduced-complexity implementation # of the Lagrange inversion formula. - void _nmod_poly_revert_series_newton(mp_ptr Qinv, mp_srcptr Q, long n, nmod_t mod) + void _nmod_poly_revert_series_newton(mp_ptr Qinv, mp_srcptr Q, slong n, nmod_t mod) # Sets ``Qinv`` to the compositional inverse or reversion of ``Q`` # as a power series, i.e. computes `Q^{-1}` such that # `Q(Q^{-1}(x)) = Q^{-1}(Q(x)) = x \bmod x^n`. The arguments must @@ -1484,7 +1484,7 @@ cdef extern from "flint_wrap.h": # `1, 2, \ldots, n-1` are invertible modulo the modulus. # This implementation uses Newton iteration [BrentKung1978]_. - void nmod_poly_revert_series_newton(nmod_poly_t Qinv, const nmod_poly_t Q, long n) + void nmod_poly_revert_series_newton(nmod_poly_t Qinv, const nmod_poly_t Q, slong n) # Sets ``Qinv`` to the compositional inverse or reversion of ``Q`` # as a power series, i.e. computes `Q^{-1}` such that # `Q(Q^{-1}(x)) = Q^{-1}(Q(x)) = x \bmod x^n`. @@ -1492,7 +1492,7 @@ cdef extern from "flint_wrap.h": # `1, 2, \ldots, n-1` are invertible modulo the modulus. # This implementation uses Newton iteration [BrentKung1978]_. - void _nmod_poly_revert_series(mp_ptr Qinv, mp_srcptr Q, long n, nmod_t mod) + void _nmod_poly_revert_series(mp_ptr Qinv, mp_srcptr Q, slong n, nmod_t mod) # Sets ``Qinv`` to the compositional inverse or reversion of ``Q`` # as a power series, i.e. computes `Q^{-1}` such that # `Q(Q^{-1}(x)) = Q^{-1}(Q(x)) = x \bmod x^n`. The arguments must @@ -1503,7 +1503,7 @@ cdef extern from "flint_wrap.h": # inversion formula and Newton iteration based on the size of the # input. - void nmod_poly_revert_series(nmod_poly_t Qinv, const nmod_poly_t Q, long n) + void nmod_poly_revert_series(nmod_poly_t Qinv, const nmod_poly_t Q, slong n) # Sets ``Qinv`` to the compositional inverse or reversion of ``Q`` # as a power series, i.e. computes `Q^{-1}` such that # `Q(Q^{-1}(x)) = Q^{-1}(Q(x)) = x \bmod x^n`. @@ -1513,23 +1513,23 @@ cdef extern from "flint_wrap.h": # inversion formula and Newton iteration based on the size of the # input. - void _nmod_poly_invsqrt_series(mp_ptr g, mp_srcptr h, long hlen, long n, nmod_t mod) + void _nmod_poly_invsqrt_series(mp_ptr g, mp_srcptr h, slong hlen, slong n, nmod_t mod) # Set the first `n` terms of `g` to the series expansion of `1/\sqrt{h}`. # It is assumed that `n > 0`, that `h` has constant term 1. Aliasing is not permitted. - void nmod_poly_invsqrt_series(nmod_poly_t g, const nmod_poly_t h, long n) + void nmod_poly_invsqrt_series(nmod_poly_t g, const nmod_poly_t h, slong n) # Set `g` to the series expansion of `1/\sqrt{h}` to order `O(x^n)`. # It is assumed that `h` has constant term 1. - void _nmod_poly_sqrt_series(mp_ptr g, mp_srcptr h, long hlen, long n, nmod_t mod) + void _nmod_poly_sqrt_series(mp_ptr g, mp_srcptr h, slong hlen, slong n, nmod_t mod) # Set the first `n` terms of `g` to the series expansion of `\sqrt{h}`. # It is assumed that `n > 0`, that `h` has constant term 1. Aliasing is not permitted. - void nmod_poly_sqrt_series(nmod_poly_t g, const nmod_poly_t h, long n) + void nmod_poly_sqrt_series(nmod_poly_t g, const nmod_poly_t h, slong n) # Set `g` to the series expansion of `\sqrt{h}` to order `O(x^n)`. # It is assumed that `h` has constant term 1. - int _nmod_poly_sqrt(mp_ptr s, mp_srcptr p, long n, nmod_t mod) + int _nmod_poly_sqrt(mp_ptr s, mp_srcptr p, slong n, nmod_t mod) # If ``(p, n)`` is a perfect square, sets ``(s, n / 2 + 1)`` # to a square root of `p` and returns 1. Otherwise returns 0. @@ -1537,33 +1537,33 @@ cdef extern from "flint_wrap.h": # If `p` is a perfect square, sets `s` to a square root of `p` # and returns 1. Otherwise returns 0. - void _nmod_poly_power_sums_naive(mp_ptr res, mp_srcptr poly, long len, long n, nmod_t mod) + void _nmod_poly_power_sums_naive(mp_ptr res, mp_srcptr poly, slong len, slong n, nmod_t mod) # Compute the (truncated) power sums series of the polynomial # ``(poly,len)`` up to length `n` using Newton identities. - void nmod_poly_power_sums_naive(nmod_poly_t res, const nmod_poly_t poly, long n) + void nmod_poly_power_sums_naive(nmod_poly_t res, const nmod_poly_t poly, slong n) # Compute the (truncated) power sum series of the polynomial # ``poly`` up to length `n` using Newton identities. - void _nmod_poly_power_sums_schoenhage(mp_ptr res, mp_srcptr poly, long len, long n, nmod_t mod) + void _nmod_poly_power_sums_schoenhage(mp_ptr res, mp_srcptr poly, slong len, slong n, nmod_t mod) # Compute the (truncated) power sums series of the polynomial # ``(poly,len)`` up to length `n` using a series expansion # (a formula due to Schoenhage). - void nmod_poly_power_sums_schoenhage(nmod_poly_t res, const nmod_poly_t poly, long n) + void nmod_poly_power_sums_schoenhage(nmod_poly_t res, const nmod_poly_t poly, slong n) # Compute the (truncated) power sums series of the polynomial # ``poly`` up to length `n` using a series expansion # (a formula due to Schoenhage). - void _nmod_poly_power_sums(mp_ptr res, mp_srcptr poly, long len, long n, nmod_t mod) + void _nmod_poly_power_sums(mp_ptr res, mp_srcptr poly, slong len, slong n, nmod_t mod) # Compute the (truncated) power sums series of the polynomial # ``(poly,len)`` up to length `n`. - void nmod_poly_power_sums(nmod_poly_t res, const nmod_poly_t poly, long n) + void nmod_poly_power_sums(nmod_poly_t res, const nmod_poly_t poly, slong n) # Compute the (truncated) power sums series of the polynomial # ``poly`` up to length `n`. - void _nmod_poly_power_sums_to_poly_naive(mp_ptr res, mp_srcptr poly, long len, nmod_t mod) + void _nmod_poly_power_sums_to_poly_naive(mp_ptr res, mp_srcptr poly, slong len, nmod_t mod) # Compute the (monic) polynomial given by its power sums series # ``(poly,len)`` using Newton identities. @@ -1571,7 +1571,7 @@ cdef extern from "flint_wrap.h": # Compute the (monic) polynomial given by its power sums series # ``Q`` using Newton identities. - void _nmod_poly_power_sums_to_poly_schoenhage(mp_ptr res, mp_srcptr poly, long len, nmod_t mod) + void _nmod_poly_power_sums_to_poly_schoenhage(mp_ptr res, mp_srcptr poly, slong len, nmod_t mod) # Compute the (monic) polynomial given by its power sums series # ``(poly,len)`` using series expansion (a formula due to Schoenhage). @@ -1579,29 +1579,29 @@ cdef extern from "flint_wrap.h": # Compute the (monic) polynomial given by its power sums series # ``Q`` using series expansion (a formula due to Schoenhage). - void _nmod_poly_power_sums_to_poly(mp_ptr res, mp_srcptr poly, long len, nmod_t mod) + void _nmod_poly_power_sums_to_poly(mp_ptr res, mp_srcptr poly, slong len, nmod_t mod) # Compute the (monic) polynomial given by its power sums series # ``(poly,len)``. void nmod_poly_power_sums_to_poly(nmod_poly_t res, const nmod_poly_t Q) # Compute the (monic) polynomial given by its power sums series ``Q``. - void _nmod_poly_log_series(mp_ptr g, mp_srcptr h, long hlen, long n, nmod_t mod) + void _nmod_poly_log_series(mp_ptr g, mp_srcptr h, slong hlen, slong n, nmod_t mod) # Set `g = \log(h) + O(x^n)`. Assumes `n > 0` and ``hlen > 0``. # Aliasing of `g` and `h` is allowed. - void nmod_poly_log_series(nmod_poly_t g, const nmod_poly_t h, long n) + void nmod_poly_log_series(nmod_poly_t g, const nmod_poly_t h, slong n) # Set `g = \log(h) + O(x^n)`. The case `h = 1+cx^r` is automatically # detected and handled efficiently. - void _nmod_poly_exp_series(mp_ptr f, mp_srcptr h, long hlen, long n, nmod_t mod) + void _nmod_poly_exp_series(mp_ptr f, mp_srcptr h, slong hlen, slong n, nmod_t mod) # Set `f = \exp(h) + O(x^n)` where ``h`` is a polynomial. Assume # `n > 0`. Aliasing of `g` and `h` is not allowed. # Uses Newton iteration (an improved version of the # algorithm in [HanZim2004]_). # For small `n`, falls back to the basecase algorithm. - void _nmod_poly_exp_expinv_series(mp_ptr f, mp_ptr g, mp_srcptr h, long hlen, long n, nmod_t mod) + void _nmod_poly_exp_expinv_series(mp_ptr f, mp_ptr g, mp_srcptr h, slong hlen, slong n, nmod_t mod) # Set `f = \exp(h) + O(x^n)` and `g = \exp(-h) + O(x^n)`, more efficiently # for large `n` than performing a separate inversion to obtain `g`. # Assumes `n > 0` and that `h` is zero-padded @@ -1609,97 +1609,97 @@ cdef extern from "flint_wrap.h": # Uses Newton iteration (the version given in [HanZim2004]_). # For small `n`, falls back to the basecase algorithm. - void nmod_poly_exp_series(nmod_poly_t g, const nmod_poly_t h, long n) + void nmod_poly_exp_series(nmod_poly_t g, const nmod_poly_t h, slong n) # Set `g = \exp(h) + O(x^n)`. The case `h = cx^r` is automatically # detected and handled efficiently. Otherwise this function automatically # uses the basecase algorithm for small `n` and Newton iteration otherwise. - void _nmod_poly_atan_series(mp_ptr g, mp_srcptr h, long hlen, long n, nmod_t mod) + void _nmod_poly_atan_series(mp_ptr g, mp_srcptr h, slong hlen, slong n, nmod_t mod) # Set `g = \operatorname{atan}(h) + O(x^n)`. Assumes `n > 0`. # Aliasing of `g` and `h` is allowed. - void nmod_poly_atan_series(nmod_poly_t g, const nmod_poly_t h, long n) + void nmod_poly_atan_series(nmod_poly_t g, const nmod_poly_t h, slong n) # Set `g = \operatorname{atan}(h) + O(x^n)`. - void _nmod_poly_atanh_series(mp_ptr g, mp_srcptr h, long hlen, long n, nmod_t mod) + void _nmod_poly_atanh_series(mp_ptr g, mp_srcptr h, slong hlen, slong n, nmod_t mod) # Set `g = \operatorname{atanh}(h) + O(x^n)`. Assumes `n > 0`. # Aliasing of `g` and `h` is allowed. - void nmod_poly_atanh_series(nmod_poly_t g, const nmod_poly_t h, long n) + void nmod_poly_atanh_series(nmod_poly_t g, const nmod_poly_t h, slong n) # Set `g = \operatorname{atanh}(h) + O(x^n)`. - void _nmod_poly_asin_series(mp_ptr g, mp_srcptr h, long hlen, long n, nmod_t mod) + void _nmod_poly_asin_series(mp_ptr g, mp_srcptr h, slong hlen, slong n, nmod_t mod) # Set `g = \operatorname{asin}(h) + O(x^n)`. Assumes `n > 0`. # Aliasing of `g` and `h` is allowed. - void nmod_poly_asin_series(nmod_poly_t g, const nmod_poly_t h, long n) + void nmod_poly_asin_series(nmod_poly_t g, const nmod_poly_t h, slong n) # Set `g = \operatorname{asin}(h) + O(x^n)`. - void _nmod_poly_asinh_series(mp_ptr g, mp_srcptr h, long hlen, long n, nmod_t mod) + void _nmod_poly_asinh_series(mp_ptr g, mp_srcptr h, slong hlen, slong n, nmod_t mod) # Set `g = \operatorname{asinh}(h) + O(x^n)`. Assumes `n > 0`. # Aliasing of `g` and `h` is allowed. - void nmod_poly_asinh_series(nmod_poly_t g, const nmod_poly_t h, long n) + void nmod_poly_asinh_series(nmod_poly_t g, const nmod_poly_t h, slong n) # Set `g = \operatorname{asinh}(h) + O(x^n)`. - void _nmod_poly_sin_series(mp_ptr g, mp_srcptr h, long n, nmod_t mod) + void _nmod_poly_sin_series(mp_ptr g, mp_srcptr h, slong n, nmod_t mod) # Set `g = \operatorname{sin}(h) + O(x^n)`. Assumes `n > 0` and that `h` # is zero-padded as necessary to length `n`. Aliasing of `g` and `h` is # allowed. The value is computed using the identity # `\sin(x) = 2 \tan(x/2)) / (1 + \tan^2(x/2)).` - void nmod_poly_sin_series(nmod_poly_t g, const nmod_poly_t h, long n) + void nmod_poly_sin_series(nmod_poly_t g, const nmod_poly_t h, slong n) # Set `g = \operatorname{sin}(h) + O(x^n)`. - void _nmod_poly_cos_series(mp_ptr g, mp_srcptr h, long n, nmod_t mod) + void _nmod_poly_cos_series(mp_ptr g, mp_srcptr h, slong n, nmod_t mod) # Set `g = \operatorname{cos}(h) + O(x^n)`. Assumes `n > 0` and that `h` # is zero-padded as necessary to length `n`. Aliasing of `g` and `h` is # allowed. The value is computed using the identity # `\cos(x) = (1-\tan^2(x/2)) / (1 + \tan^2(x/2)).` - void nmod_poly_cos_series(nmod_poly_t g, const nmod_poly_t h, long n) + void nmod_poly_cos_series(nmod_poly_t g, const nmod_poly_t h, slong n) # Set `g = \operatorname{cos}(h) + O(x^n)`. - void _nmod_poly_tan_series(mp_ptr g, mp_srcptr h, long hlen, long n, nmod_t mod) + void _nmod_poly_tan_series(mp_ptr g, mp_srcptr h, slong hlen, slong n, nmod_t mod) # Set `g = \operatorname{tan}(h) + O(x^n)`. Assumes `n > 0` and that `h` # is zero-padded as necessary to length `n`. Aliasing of `g` and `h` is # not allowed. Uses Newton iteration to invert the atan function. - void nmod_poly_tan_series(nmod_poly_t g, const nmod_poly_t h, long n) + void nmod_poly_tan_series(nmod_poly_t g, const nmod_poly_t h, slong n) # Set `g = \operatorname{tan}(h) + O(x^n)`. - void _nmod_poly_sinh_series(mp_ptr g, mp_srcptr h, long n, nmod_t mod) + void _nmod_poly_sinh_series(mp_ptr g, mp_srcptr h, slong n, nmod_t mod) # Set `g = \operatorname{sinh}(h) + O(x^n)`. Assumes `n > 0` and that `h` # is zero-padded as necessary to length `n`. Aliasing of `g` and `h` is # not allowed. Uses the identity `\sinh(x) = (e^x - e^{-x})/2`. - void nmod_poly_sinh_series(nmod_poly_t g, const nmod_poly_t h, long n) + void nmod_poly_sinh_series(nmod_poly_t g, const nmod_poly_t h, slong n) # Set `g = \operatorname{sinh}(h) + O(x^n)`. - void _nmod_poly_cosh_series(mp_ptr g, mp_srcptr h, long n, nmod_t mod) + void _nmod_poly_cosh_series(mp_ptr g, mp_srcptr h, slong n, nmod_t mod) # Set `g = \operatorname{cos}(h) + O(x^n)`. Assumes `n > 0` and that `h` # is zero-padded as necessary to length `n`. Aliasing of `g` and `h` is # not allowed. # Uses the identity `\cosh(x) = (e^x + e^{-x})/2`. - void nmod_poly_cosh_series(nmod_poly_t g, const nmod_poly_t h, long n) + void nmod_poly_cosh_series(nmod_poly_t g, const nmod_poly_t h, slong n) # Set `g = \operatorname{cosh}(h) + O(x^n)`. - void _nmod_poly_tanh_series(mp_ptr g, mp_srcptr h, long n, nmod_t mod) + void _nmod_poly_tanh_series(mp_ptr g, mp_srcptr h, slong n, nmod_t mod) # Set `g = \operatorname{tanh}(h) + O(x^n)`. Assumes `n > 0` and that `h` # is zero-padded as necessary to length `n`. Uses the identity # `\tanh(x) = (e^{2x}-1)/(e^{2x}+1)`. - void nmod_poly_tanh_series(nmod_poly_t g, const nmod_poly_t h, long n) + void nmod_poly_tanh_series(nmod_poly_t g, const nmod_poly_t h, slong n) # Set `g = \operatorname{tanh}(h) + O(x^n)`. - void _nmod_poly_product_roots_nmod_vec(mp_ptr poly, mp_srcptr xs, long n, nmod_t mod) + void _nmod_poly_product_roots_nmod_vec(mp_ptr poly, mp_srcptr xs, slong n, nmod_t mod) # Sets ``(poly, n + 1)`` to the monic polynomial which is the product # of `(x - x_0)(x - x_1) \cdots (x - x_{n-1})`, the roots `x_i` being # given by ``xs``. # Aliasing of the input and output is not allowed. - void nmod_poly_product_roots_nmod_vec(nmod_poly_t poly, mp_srcptr xs, long n) + void nmod_poly_product_roots_nmod_vec(nmod_poly_t poly, mp_srcptr xs, slong n) # Sets ``poly`` to the monic polynomial which is the product # of `(x - x_0)(x - x_1) \cdots (x - x_{n-1})`, the roots `x_i` being # given by ``xs``. @@ -1709,7 +1709,7 @@ cdef extern from "flint_wrap.h": # Otherwise, return ``0``. It is assumed that ``A`` is nonzero and that the modulus of ``A`` is prime. # This function uses Rabin's probabilistic method via gcd's with `(x + \delta)^{\frac{p-1}{2}} - 1`. - mp_ptr * _nmod_poly_tree_alloc(long len) + mp_ptr * _nmod_poly_tree_alloc(slong len) # Allocates space for a subproduct tree of the given length, having # linear factors at the lowest level. # Entry `i` in the tree is a pointer to a single array of limbs, @@ -1724,24 +1724,24 @@ cdef extern from "flint_wrap.h": # XXXX1 XX1 X1 # XXXXXXX1 - void _nmod_poly_tree_free(mp_ptr * tree, long len) + void _nmod_poly_tree_free(mp_ptr * tree, slong len) # Free the allocated space for the subproduct. - void _nmod_poly_tree_build(mp_ptr * tree, mp_srcptr roots, long len, nmod_t mod) + void _nmod_poly_tree_build(mp_ptr * tree, mp_srcptr roots, slong len, nmod_t mod) # Builds a subproduct tree in the preallocated space from # the ``len`` monic linear factors `(x-r_i)`. The top level # product is not computed. - void nmod_poly_inflate(nmod_poly_t result, const nmod_poly_t input, unsigned long inflation) + void nmod_poly_inflate(nmod_poly_t result, const nmod_poly_t input, ulong inflation) # Sets ``result`` to the inflated polynomial `p(x^n)` where # `p` is given by ``input`` and `n` is given by ``deflation``. - void nmod_poly_deflate(nmod_poly_t result, const nmod_poly_t input, unsigned long deflation) + void nmod_poly_deflate(nmod_poly_t result, const nmod_poly_t input, ulong deflation) # Sets ``result`` to the deflated polynomial `p(x^{1/n})` where # `p` is given by ``input`` and `n` is given by ``deflation``. # Requires `n > 0`. - unsigned long nmod_poly_deflation(const nmod_poly_t input) + ulong nmod_poly_deflation(const nmod_poly_t input) # Returns the largest integer by which ``input`` can be deflated. # As special cases, returns 0 if ``input`` is the zero polynomial # and 1 of ``input`` is a constant polynomial. @@ -1749,8 +1749,8 @@ cdef extern from "flint_wrap.h": void nmod_poly_multi_crt_init(nmod_poly_multi_crt_t CRT) # Initialize ``CRT`` for Chinese remaindering. - int nmod_poly_multi_crt_precompute(nmod_poly_multi_crt_t CRT, const nmod_poly_struct * moduli, long len) - int nmod_poly_multi_crt_precompute_p(nmod_poly_multi_crt_t CRT, const nmod_poly_struct * const * moduli, long len) + int nmod_poly_multi_crt_precompute(nmod_poly_multi_crt_t CRT, const nmod_poly_struct * moduli, slong len) + int nmod_poly_multi_crt_precompute_p(nmod_poly_multi_crt_t CRT, const nmod_poly_struct * const * moduli, slong len) # Configure ``CRT`` for repeated Chinese remaindering of ``moduli``. The number of moduli, ``len``, should be positive. # A return of ``0`` indicates that the compilation failed and future calls to :func:`nmod_poly_multi_crt_precomp` will leave the output undefined. # A return of ``1`` indicates that the compilation was successful, which occurs if and only if either (1) ``len == 1`` and ``modulus + 0`` is nonzero, or (2) all of the moduli have positive degree and are pairwise relatively prime. @@ -1760,14 +1760,14 @@ cdef extern from "flint_wrap.h": # Set ``output`` to the polynomial of lowest possible degree that is congruent to ``values + i`` modulo the ``moduli + i`` in :func:`nmod_poly_multi_crt_precompute`. # The inputs ``values + 0, ..., values + len - 1`` where ``len`` was used in :func:`nmod_poly_multi_crt_precompute` are expected to be valid and have modulus matching the modulus of the moduli used in :func:`nmod_poly_multi_crt_precompute`. - int nmod_poly_multi_crt(nmod_poly_t output, const nmod_poly_struct * moduli, const nmod_poly_struct * values, long len) + int nmod_poly_multi_crt(nmod_poly_t output, const nmod_poly_struct * moduli, const nmod_poly_struct * values, slong len) # Perform the same operation as :func:`nmod_poly_multi_crt_precomp` while internally constructing and destroying the precomputed data. # All of the remarks in :func:`nmod_poly_multi_crt_precompute` apply. void nmod_poly_multi_crt_clear(nmod_poly_multi_crt_t CRT) # Free all space used by ``CRT``. - long _nmod_poly_multi_crt_local_size(const nmod_poly_multi_crt_t CRT) + slong _nmod_poly_multi_crt_local_size(const nmod_poly_multi_crt_t CRT) # Return the required length of the output for :func:`_nmod_poly_multi_crt_run`. void _nmod_poly_multi_crt_run(nmod_poly_struct * outputs, const nmod_poly_multi_crt_t CRT, const nmod_poly_struct * inputs) @@ -1788,8 +1788,8 @@ cdef extern from "flint_wrap.h": void nmod_berlekamp_massey_set_prime(nmod_berlekamp_massey_t B, mp_limb_t p) # Set the characteristic of the field and empty the stream of points in ``B``. - void nmod_berlekamp_massey_add_points(nmod_berlekamp_massey_t B, const mp_limb_t * a, long count) - void nmod_berlekamp_massey_add_zeros(nmod_berlekamp_massey_t B, long count) + void nmod_berlekamp_massey_add_points(nmod_berlekamp_massey_t B, const mp_limb_t * a, slong count) + void nmod_berlekamp_massey_add_zeros(nmod_berlekamp_massey_t B, slong count) void nmod_berlekamp_massey_add_point(nmod_berlekamp_massey_t B, mp_limb_t a) # Add point(s) to the stream processed by ``B``. The addition of any number of points will not update the `V` and `R` polynomial. @@ -1798,7 +1798,7 @@ cdef extern from "flint_wrap.h": # For example, if this function is called twice in a row without adding any points in between, the return of the second call should be ``0``. # As another example, suppose the object is emptied, the points `1, 1, 2, 3` are added, then reduce is called. This reduce should return ``1`` with `\deg(R) < \deg(V) = 2` because the Fibonacci sequence has been recognized. The further addition of the two points `5, 8` and a reduce will result in a return value of ``0``. - long nmod_berlekamp_massey_point_count(const nmod_berlekamp_massey_t B) + slong nmod_berlekamp_massey_point_count(const nmod_berlekamp_massey_t B) # Return the number of points stored in ``B``. const mp_limb_t * nmod_berlekamp_massey_points(const nmod_berlekamp_massey_t B) diff --git a/src/sage/libs/flint/nmod_poly_factor.pxd b/src/sage/libs/flint/nmod_poly_factor.pxd index 93442d54682..81a119ed719 100644 --- a/src/sage/libs/flint/nmod_poly_factor.pxd +++ b/src/sage/libs/flint/nmod_poly_factor.pxd @@ -20,11 +20,11 @@ cdef extern from "flint_wrap.h": void nmod_poly_factor_clear(nmod_poly_factor_t fac) # Frees all memory associated with ``fac``. - void nmod_poly_factor_realloc(nmod_poly_factor_t fac, long alloc) + void nmod_poly_factor_realloc(nmod_poly_factor_t fac, slong alloc) # Reallocates the factor structure to provide space for # precisely ``alloc`` factors. - void nmod_poly_factor_fit_length(nmod_poly_factor_t fac, long len) + void nmod_poly_factor_fit_length(nmod_poly_factor_t fac, slong len) # Ensures that the factor structure has space for at # least ``len`` factors. This function takes care # of the case of repeated calls by always at least @@ -36,7 +36,7 @@ cdef extern from "flint_wrap.h": void nmod_poly_factor_print(const nmod_poly_factor_t fac) # Prints the entries of ``fac`` to standard output. - void nmod_poly_factor_insert(nmod_poly_factor_t fac, const nmod_poly_t poly, long exp) + void nmod_poly_factor_insert(nmod_poly_factor_t fac, const nmod_poly_t poly, slong exp) # Inserts the factor ``poly`` with multiplicity ``exp`` into # the factorisation ``fac``. # If ``fac`` already contains ``poly``, then ``exp`` simply @@ -48,10 +48,10 @@ cdef extern from "flint_wrap.h": # repeatedly with the individual factors of ``fac``. # Does not support aliasing between ``res`` and ``fac``. - void nmod_poly_factor_pow(nmod_poly_factor_t fac, long exp) + void nmod_poly_factor_pow(nmod_poly_factor_t fac, slong exp) # Raises ``fac`` to the power ``exp``. - unsigned long nmod_poly_remove(nmod_poly_t f, const nmod_poly_t p) + ulong nmod_poly_remove(nmod_poly_t f, const nmod_poly_t p) # Removes the highest possible power of ``p`` from ``f`` and # returns the exponent. @@ -66,7 +66,7 @@ cdef extern from "flint_wrap.h": # Returns 1 if the polynomial ``f`` is irreducible, otherwise returns 0. # Uses Rabin irreducibility test. - int _nmod_poly_is_squarefree(mp_srcptr f, long len, nmod_t mod) + int _nmod_poly_is_squarefree(mp_srcptr f, slong len, nmod_t mod) # Returns 1 if ``(f, len)`` is squarefree, and 0 otherwise. As a # special case, the zero polynomial is not considered squarefree. # There are no restrictions on the length. @@ -78,19 +78,19 @@ cdef extern from "flint_wrap.h": void nmod_poly_factor_squarefree(nmod_poly_factor_t res, const nmod_poly_t f) # Sets ``res`` to a square-free factorization of ``f``. - int nmod_poly_factor_equal_deg_prob(nmod_poly_t factor, flint_rand_t state, const nmod_poly_t pol, long d) + int nmod_poly_factor_equal_deg_prob(nmod_poly_t factor, flint_rand_t state, const nmod_poly_t pol, slong d) # Probabilistic equal degree factorisation of ``pol`` into # irreducible factors of degree ``d``. If it passes, a factor is # placed in factor and 1 is returned, otherwise 0 is returned and # the value of factor is undetermined. # Requires that ``pol`` be monic, non-constant and squarefree. - void nmod_poly_factor_equal_deg(nmod_poly_factor_t factors, const nmod_poly_t pol, long d) + void nmod_poly_factor_equal_deg(nmod_poly_factor_t factors, const nmod_poly_t pol, slong d) # Assuming ``pol`` is a product of irreducible factors all of # degree ``d``, finds all those factors and places them in factors. # Requires that ``pol`` be monic, non-constant and squarefree. - void nmod_poly_factor_distinct_deg(nmod_poly_factor_t res, const nmod_poly_t poly, long * const *degs) + void nmod_poly_factor_distinct_deg(nmod_poly_factor_t res, const nmod_poly_t poly, slong * const *degs) # Factorises a monic non-constant squarefree polynomial ``poly`` # of degree n into factors `f[d]` such that for `1 \leq d \leq n` # `f[d]` is the product of the monic irreducible factors of ``poly`` @@ -99,7 +99,7 @@ cdef extern from "flint_wrap.h": # as the factors. # Requires that ``degs`` has enough space for ``(n/2)+1 * sizeof(slong)``. - void nmod_poly_factor_distinct_deg_threaded(nmod_poly_factor_t res, const nmod_poly_t poly, long * const *degs) + void nmod_poly_factor_distinct_deg_threaded(nmod_poly_factor_t res, const nmod_poly_t poly, slong * const *degs) # Multithreaded version of :func:`nmod_poly_factor_distinct_deg`. void nmod_poly_factor_cantor_zassenhaus(nmod_poly_factor_t res, const nmod_poly_t f) diff --git a/src/sage/libs/flint/nmod_poly_mat.pxd b/src/sage/libs/flint/nmod_poly_mat.pxd new file mode 100644 index 00000000000..64e3d15a5fe --- /dev/null +++ b/src/sage/libs/flint/nmod_poly_mat.pxd @@ -0,0 +1,324 @@ +# distutils: libraries = flint +# distutils: depends = flint/nmod_poly_mat.h + +################################################################################ +# This file is auto-generated. Do not modify by hand +################################################################################ + +from libc.stdio cimport FILE +from sage.libs.gmp.types cimport * +from sage.libs.mpfr.types cimport * +from sage.libs.flint.types cimport * + +cdef extern from "flint_wrap.h": + + void nmod_poly_mat_init(nmod_poly_mat_t mat, slong rows, slong cols, mp_limb_t n) + # Initialises a matrix with the given number of rows and columns for use. + # The modulus is set to `n`. + + void nmod_poly_mat_init_set(nmod_poly_mat_t mat, const nmod_poly_mat_t src) + # Initialises a matrix ``mat`` of the same dimensions and modulus + # as ``src``, and sets it to a copy of ``src``. + + void nmod_poly_mat_clear(nmod_poly_mat_t mat) + # Frees all memory associated with the matrix. The matrix must be + # reinitialised if it is to be used again. + + void nmod_poly_mat_set_trunc(nmod_poly_mat_t res, const nmod_poly_mat_t pmat, long len) + # Set ``res`` to the truncation of ``pmat`` to length ``len``. Entries of + # ``res`` are normalized. + + void nmod_poly_mat_truncate(nmod_poly_mat_t pmat, long len) + # Truncates ``pmat`` to the given length ``len``, and normalize its entries. + # If ``len`` is greater than the maximum length of the entries of ``pmat``, + # then nothing happens. + + void nmod_poly_mat_shift_left(nmod_poly_mat_t res, const nmod_poly_mat_t pmat, slong k) + # Sets ``res`` to ``pmat`` shifted left by ``k`` coefficients, that is, + # multiplied by `x^k`. + + void nmod_poly_mat_shift_right(nmod_poly_mat_t res, const nmod_poly_mat_t pmat, slong k) + # Sets ``res`` to ``pmat`` shifted right by ``k`` coefficients, that is, + # divide by `x^k` and throw away the remainder. If ``k`` is greater than or + # equal to the length of ``pmat``, the result is the zero polynomial matrix. + + slong nmod_poly_mat_nrows(const nmod_poly_mat_t mat) + # Returns the number of rows in ``mat``. + + slong nmod_poly_mat_ncols(const nmod_poly_mat_t mat) + # Returns the number of columns in ``mat``. + + mp_limb_t nmod_poly_mat_modulus(const nmod_poly_mat_t mat) + # Returns the modulus of ``mat``. + + nmod_poly_struct * nmod_poly_mat_entry(const nmod_poly_mat_t mat, slong i, slong j) + # Gives a reference to the entry at row ``i`` and column ``j``. + # The reference can be passed as an input or output variable to any + # ``nmod_poly`` function for direct manipulation of the matrix element. + # No bounds checking is performed. + + void nmod_poly_mat_set(nmod_poly_mat_t mat1, const nmod_poly_mat_t mat2) + # Sets ``mat1`` to a copy of ``mat2``. + + void nmod_poly_mat_set_nmod_mat(nmod_poly_mat_t pmat, const nmod_mat_t cmat) + # Sets the already-initialized polynomial matrix ``pmat`` to a constant + # matrix with the same entries as ``cmat``. Both input matrices must have the + # same dimensions and modulus. + + void nmod_poly_mat_swap(nmod_poly_mat_t mat1, nmod_poly_mat_t mat2) + # Swaps ``mat1`` and ``mat2`` efficiently. + + void nmod_poly_mat_swap_entrywise(nmod_poly_mat_t mat1, nmod_poly_mat_t mat2) + # Swaps two matrices by swapping the individual entries rather than swapping + # the contents of the structs. + + void nmod_poly_mat_print(const nmod_poly_mat_t mat, const char * x) + # Prints the matrix ``mat`` to standard output, using the + # variable ``x``. + + void nmod_poly_mat_randtest(nmod_poly_mat_t mat, flint_rand_t state, slong len) + # This is equivalent to applying ``nmod_poly_randtest`` to all entries + # in the matrix. + + void nmod_poly_mat_randtest_sparse(nmod_poly_mat_t A, flint_rand_t state, slong len, float density) + # Creates a random matrix with the amount of nonzero entries given + # approximately by the ``density`` variable, which should be a fraction + # between 0 (most sparse) and 1 (most dense). + # The nonzero entries will have random lengths between 1 and ``len``. + + void nmod_poly_mat_zero(nmod_poly_mat_t mat) + # Sets ``mat`` to the zero matrix. + + void nmod_poly_mat_one(nmod_poly_mat_t mat) + # Sets ``mat`` to the unit or identity matrix of given shape, + # having the element 1 on the main diagonal and zeros elsewhere. + # If ``mat`` is nonsquare, it is set to the truncation of a unit matrix. + + int nmod_poly_mat_equal(const nmod_poly_mat_t mat1, const nmod_poly_mat_t mat2) + # Returns nonzero if ``mat1`` and ``mat2`` have the same shape and + # all their entries agree, and returns zero otherwise. + + int nmod_poly_mat_equal_nmod_mat(const nmod_poly_mat_t pmat, const nmod_mat_t cmat) + # Returns nonzero if ``pmat`` is a constant matrix with the same dimensions + # and entries as ``cmat``; returns zero otherwise. + + int nmod_poly_mat_is_zero(const nmod_poly_mat_t mat) + # Returns nonzero if all entries in ``mat`` are zero, and returns + # zero otherwise. + + int nmod_poly_mat_is_one(const nmod_poly_mat_t mat) + # Returns nonzero if all entry of ``mat`` on the main diagonal + # are the constant polynomial 1 and all remaining entries are zero, + # and returns zero otherwise. The matrix need not be square. + + int nmod_poly_mat_is_empty(const nmod_poly_mat_t mat) + # Returns a non-zero value if the number of rows or the number of + # columns in ``mat`` is zero, and otherwise returns + # zero. + + int nmod_poly_mat_is_square(const nmod_poly_mat_t mat) + # Returns a non-zero value if the number of rows is equal to the + # number of columns in ``mat``, and otherwise returns zero. + + void nmod_poly_mat_get_coeff_mat(nmod_mat_t coeff, const nmod_poly_mat_t pmat, slong deg) + # Sets ``coeff`` to be the coefficient of ``pmat`` of degree ``deg``, where + # ``pmat`` is seen as a polynomial with matrix coefficients and coefficients + # are numbered from zero. ``coeff`` must be already initialized with the + # right dimensions and modulus. For entries of ``pmat`` of degree less than + # ``deg``, the corresponding entry of ``coeff`` is zero. + + void nmod_poly_mat_set_coeff_mat(nmod_poly_mat_t pmat, const nmod_mat_t coeff, slong deg) + # Sets the coefficient of ``pmat`` of degree ``deg`` to ``coeff``, where + # ``pmat`` is seen as a polynomial with matrix coefficients and coefficients + # are numbered from zero. For each entry of ``pmat``, if ``deg`` is larger + # than its degree, this entry is first resized to the appropriate length, + # with intervening coefficients being set to zero. + + slong nmod_poly_mat_max_length(const nmod_poly_mat_t A) + # Returns the maximum polynomial length among all the entries in ``A``. + + slong nmod_poly_mat_degree(const nmod_poly_mat_t pmat) + # Returns the degree of the polynomial matrix ``pmat``. The zero matrix is + # deemed to have degree `-1`. + + void nmod_poly_mat_evaluate_nmod(nmod_mat_t B, const nmod_poly_mat_t A, mp_limb_t x) + # Sets the ``nmod_mat_t`` ``B`` to ``A`` evaluated entrywise + # at the point ``x``. + + void nmod_poly_mat_scalar_mul_nmod_poly(nmod_poly_mat_t B, const nmod_poly_mat_t A, const nmod_poly_t c) + # Sets ``B`` to ``A`` multiplied entrywise by the polynomial ``c``. + + void nmod_poly_mat_scalar_mul_nmod(nmod_poly_mat_t B, const nmod_poly_mat_t A, mp_limb_t c) + # Sets ``B`` to ``A`` multiplied entrywise by the coefficient + # ``c``, which is assumed to be reduced modulo the modulus. + + void nmod_poly_mat_add(nmod_poly_mat_t C, const nmod_poly_mat_t A, const nmod_poly_mat_t B) + # Sets ``C`` to the sum of ``A`` and ``B``. + # All matrices must have the same shape. Aliasing is allowed. + + void nmod_poly_mat_sub(nmod_poly_mat_t C, const nmod_poly_mat_t A, const nmod_poly_mat_t B) + # Sets ``C`` to the sum of ``A`` and ``B``. + # All matrices must have the same shape. Aliasing is allowed. + + void nmod_poly_mat_neg(nmod_poly_mat_t B, const nmod_poly_mat_t A) + # Sets ``B`` to the negation of ``A``. + # The matrices must have the same shape. Aliasing is allowed. + + void nmod_poly_mat_mul(nmod_poly_mat_t C, const nmod_poly_mat_t A, const nmod_poly_mat_t B) + # Sets ``C`` to the matrix product of ``A`` and ``B``. + # The matrices must have compatible dimensions for matrix multiplication. + # Aliasing is allowed. This function automatically chooses between + # classical, KS and evaluation-interpolation multiplication. + + void nmod_poly_mat_mul_classical(nmod_poly_mat_t C, const nmod_poly_mat_t A, const nmod_poly_mat_t B) + # Sets ``C`` to the matrix product of ``A`` and ``B``, + # computed using the classical algorithm. The matrices must have + # compatible dimensions for matrix multiplication. Aliasing is allowed. + + void nmod_poly_mat_mul_KS(nmod_poly_mat_t C, const nmod_poly_mat_t A, const nmod_poly_mat_t B) + # Sets ``C`` to the matrix product of ``A`` and ``B``, + # computed using Kronecker segmentation. The matrices must have + # compatible dimensions for matrix multiplication. Aliasing is allowed. + + void nmod_poly_mat_mul_interpolate(nmod_poly_mat_t C, const nmod_poly_mat_t A, const nmod_poly_mat_t B) + # Sets ``C`` to the matrix product of ``A`` and ``B``, + # computed through evaluation and interpolation. The matrices must have + # compatible dimensions for matrix multiplication. For interpolation + # to be well-defined, we require that the modulus is a prime at least as + # large as `m + n - 1` where `m` and `n` are the maximum lengths of + # polynomials in the input matrices. Aliasing is allowed. + + void nmod_poly_mat_sqr(nmod_poly_mat_t B, const nmod_poly_mat_t A) + # Sets ``B`` to the square of ``A``, which must be a square matrix. + # Aliasing is allowed. This function automatically chooses between + # classical and KS squaring. + + void nmod_poly_mat_sqr_classical(nmod_poly_mat_t B, const nmod_poly_mat_t A) + # Sets ``B`` to the square of ``A``, which must be a square matrix. + # Aliasing is allowed. This function uses direct formulas for very small + # matrices, and otherwise classical matrix multiplication. + + void nmod_poly_mat_sqr_KS(nmod_poly_mat_t B, const nmod_poly_mat_t A) + # Sets ``B`` to the square of ``A``, which must be a square matrix. + # Aliasing is allowed. This function uses Kronecker segmentation. + + void nmod_poly_mat_sqr_interpolate(nmod_poly_mat_t B, const nmod_poly_mat_t A) + # Sets ``B`` to the square of ``A``, which must be a square matrix, + # computed through evaluation and interpolation. For interpolation + # to be well-defined, we require that the modulus is a prime at least as + # large as `2n - 1` where `n` is the maximum length of + # polynomials in the input matrix. Aliasing is allowed. + + void nmod_poly_mat_pow(nmod_poly_mat_t B, const nmod_poly_mat_t A, ulong exp) + # Sets ``B`` to ``A`` raised to the power ``exp``, where ``A`` + # is a square matrix. Uses exponentiation by squaring. Aliasing is allowed. + + slong nmod_poly_mat_find_pivot_any(const nmod_poly_mat_t mat, slong start_row, slong end_row, slong c) + # Attempts to find a pivot entry for row reduction. + # Returns a row index `r` between ``start_row`` (inclusive) and + # ``stop_row`` (exclusive) such that column `c` in ``mat`` has + # a nonzero entry on row `r`, or returns -1 if no such entry exists. + # This implementation simply chooses the first nonzero entry from + # it encounters. This is likely to be a nearly optimal choice if all + # entries in the matrix have roughly the same size, but can lead to + # unnecessary coefficient growth if the entries vary in size. + + slong nmod_poly_mat_find_pivot_partial(const nmod_poly_mat_t mat, slong start_row, slong end_row, slong c) + # Attempts to find a pivot entry for row reduction. + # Returns a row index `r` between ``start_row`` (inclusive) and + # ``stop_row`` (exclusive) such that column `c` in ``mat`` has + # a nonzero entry on row `r`, or returns -1 if no such entry exists. + # This implementation searches all the rows in the column and + # chooses the nonzero entry of smallest degree. This heuristic + # typically reduces coefficient growth when the matrix entries + # vary in size. + + slong nmod_poly_mat_fflu(nmod_poly_mat_t B, nmod_poly_t den, slong * perm, const nmod_poly_mat_t A, int rank_check) + # Uses fraction-free Gaussian elimination to set (``B``, ``den``) to a + # fraction-free LU decomposition of ``A`` and returns the + # rank of ``A``. Aliasing of ``A`` and ``B`` is allowed. + # Pivot elements are chosen with ``nmod_poly_mat_find_pivot_partial``. + # If ``perm`` is non-``NULL``, the permutation of + # rows in the matrix will also be applied to ``perm``. + # If ``rank_check`` is set, the function aborts and returns 0 if the + # matrix is detected not to have full rank without completing the + # elimination. + # The denominator ``den`` is set to `\pm \operatorname{det}(A)`, where + # the sign is decided by the parity of the permutation. Note that the + # determinant is not generally the minimal denominator. + + slong nmod_poly_mat_rref(nmod_poly_mat_t B, nmod_poly_t den, const nmod_poly_mat_t A) + # Sets (``B``, ``den``) to the reduced row echelon form of ``A`` + # and returns the rank of ``A``. + # Aliasing of ``A`` and ``B`` is allowed. + # The denominator ``den`` is set to `\pm \operatorname{det}(A)`. + # Note that the determinant is not generally the minimal denominator. + + void nmod_poly_mat_trace(nmod_poly_t trace, const nmod_poly_mat_t mat) + # Computes the trace of the matrix, i.e. the sum of the entries on + # the main diagonal. The matrix is required to be square. + + void nmod_poly_mat_det(nmod_poly_t det, const nmod_poly_mat_t A) + # Sets ``det`` to the determinant of the square matrix ``A``. Uses + # a direct formula, fraction-free LU decomposition, or interpolation, + # depending on the size of the matrix. + + void nmod_poly_mat_det_fflu(nmod_poly_t det, const nmod_poly_mat_t A) + # Sets ``det`` to the determinant of the square matrix ``A``. + # The determinant is computed by performing a fraction-free LU + # decomposition on a copy of ``A``. + + void nmod_poly_mat_det_interpolate(nmod_poly_t det, const nmod_poly_mat_t A) + # Sets ``det`` to the determinant of the square matrix ``A``. + # The determinant is computed by determining a bound `n` for its length, + # evaluating the matrix at `n` distinct points, computing the determinant + # of each coefficient matrix, and forming the interpolating polynomial. + # If the coefficient ring does not contain `n` distinct points (that is, + # if working over `\mathbf{Z}/p\mathbf{Z}` where `p < n`), + # this function automatically falls back to ``nmod_poly_mat_det_fflu``. + + slong nmod_poly_mat_rank(const nmod_poly_mat_t A) + # Returns the rank of ``A``. Performs fraction-free LU decomposition + # on a copy of ``A``. + + int nmod_poly_mat_inv(nmod_poly_mat_t Ainv, nmod_poly_t den, const nmod_poly_mat_t A) + # Sets (``Ainv``, ``den``) to the inverse matrix of ``A``. + # Returns 1 if ``A`` is nonsingular and 0 if ``A`` is singular. + # Aliasing of ``Ainv`` and ``A`` is allowed. + # More precisely, ``det`` will be set to the determinant of ``A`` + # and ``Ainv`` will be set to the adjugate matrix of ``A``. + # Note that the determinant is not necessarily the minimal denominator. + # Uses fraction-free LU decomposition, followed by solving for + # the identity matrix. + + slong nmod_poly_mat_nullspace(nmod_poly_mat_t res, const nmod_poly_mat_t mat) + # Computes the right rational nullspace of the matrix ``mat`` and + # returns the nullity. + # More precisely, assume that ``mat`` has rank `r` and nullity `n`. + # Then this function sets the first `n` columns of ``res`` + # to linearly independent vectors spanning the nullspace of ``mat``. + # As a result, we always have rank(``res``) `= n`, and + # ``mat`` `\times` ``res`` is the zero matrix. + # The computed basis vectors will not generally be in a reduced form. + # In general, the polynomials in each column vector in the result + # will have a nontrivial common GCD. + + int nmod_poly_mat_solve(nmod_poly_mat_t X, nmod_poly_t den, const nmod_poly_mat_t A, const nmod_poly_mat_t B) + # Solves the equation `AX = B` for nonsingular `A`. More precisely, computes + # (``X``, ``den``) such that `AX = B \times \operatorname{den}`. + # Returns 1 if `A` is nonsingular and 0 if `A` is singular. + # The computed denominator will not generally be minimal. + # Uses fraction-free LU decomposition followed by fraction-free + # forward and back substitution. + + int nmod_poly_mat_solve_fflu(nmod_poly_mat_t X, nmod_poly_t den, const nmod_poly_mat_t A, const nmod_poly_mat_t B) + # Solves the equation `AX = B` for nonsingular `A`. More precisely, computes + # (``X``, ``den``) such that `AX = B \times \operatorname{den}`. + # Returns 1 if `A` is nonsingular and 0 if `A` is singular. + # The computed denominator will not generally be minimal. + # Uses fraction-free LU decomposition followed by fraction-free + # forward and back substitution. + + void nmod_poly_mat_solve_fflu_precomp(nmod_poly_mat_t X, const slong * perm, const nmod_poly_mat_t FFLU, const nmod_poly_mat_t B) + # Performs fraction-free forward and back substitution given a precomputed + # fraction-free LU decomposition and corresponding permutation. diff --git a/src/sage/libs/flint/nmod_vec.pxd b/src/sage/libs/flint/nmod_vec.pxd index b839447bb56..ebfee4249fa 100644 --- a/src/sage/libs/flint/nmod_vec.pxd +++ b/src/sage/libs/flint/nmod_vec.pxd @@ -1,44 +1,109 @@ # distutils: libraries = flint # distutils: depends = flint/nmod_vec.h -# This file was (manually) generated from FLINT's nmod_vec.h. -#***************************************************************************** -# Copyright (C) 2010 William Hart -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 2 of the License, or -# (at your option) any later version. -# http://www.gnu.org/licenses/ -#***************************************************************************** +################################################################################ +# This file is auto-generated. Do not modify by hand +################################################################################ +from libc.stdio cimport FILE +from sage.libs.gmp.types cimport * +from sage.libs.mpfr.types cimport * from sage.libs.flint.types cimport * -# flint/nmod_vec.h cdef extern from "flint_wrap.h": - mp_limb_t _nmod_add(mp_limb_t a, mp_limb_t b, nmod_t mod) - mp_limb_t _nmod_sub(mp_limb_t a, mp_limb_t b, nmod_t mod) - mp_limb_t nmod_add(mp_limb_t a, mp_limb_t b, nmod_t mod) - mp_limb_t nmod_sub(mp_limb_t a, mp_limb_t b, nmod_t mod) - mp_limb_t nmod_neg(mp_limb_t a, nmod_t mod) - mp_limb_t nmod_mul(mp_limb_t a, mp_limb_t b, nmod_t mod) - mp_limb_t nmod_div(mp_limb_t a, mp_limb_t b, nmod_t mod) - void nmod_init(nmod_t * mod, mp_limb_t n) - mp_ptr _nmod_vec_init(long len) + + mp_ptr _nmod_vec_init(slong len) + # Returns a vector of the given length. The entries are not necessarily + # zero. + void _nmod_vec_clear(mp_ptr vec) - void _nmod_vec_randtest(mp_ptr vec, flint_rand_t state, long len, nmod_t mod) - void _nmod_vec_zero(mp_ptr vec, long len) - mp_bitcnt_t _nmod_vec_max_bits(mp_srcptr vec, long len) - void _nmod_vec_set(mp_ptr res, mp_srcptr vec, long len) - void _nmod_vec_swap(mp_ptr a, mp_ptr b, long length) - int _nmod_vec_equal(mp_ptr vec, mp_srcptr vec2, long len) - int _nmod_vec_is_zero(mp_srcptr vec, long len) - void _nmod_vec_reduce(mp_ptr res, mp_srcptr vec, long len, nmod_t mod) - void _nmod_vec_add(mp_ptr res, mp_srcptr vec1, mp_srcptr vec2, long len, nmod_t mod) - void _nmod_vec_sub(mp_ptr res, mp_srcptr vec1, mp_srcptr vec2, long len, nmod_t mod) - void _nmod_vec_neg(mp_ptr res, mp_srcptr vec, long len, nmod_t mod) - void _nmod_vec_scalar_mul_nmod(mp_ptr res, mp_srcptr vec, long len, mp_limb_t c, nmod_t mod) - void _nmod_vec_scalar_addmul_nmod(mp_ptr res, mp_srcptr vec, long len, mp_limb_t c, nmod_t mod) - int _nmod_vec_dot_bound_limbs(long len, nmod_t mod) - mp_limb_t _nmod_vec_dot(mp_srcptr vec1, mp_srcptr vec2, long len, nmod_t mod, int nlimbs) - mp_limb_t _nmod_vec_dot_ptr(mp_srcptr vec1, mp_ptr * vec2, long offset, long len, nmod_t mod, int nlimbs) + # Frees the memory used by the given vector. + + void _nmod_vec_randtest(mp_ptr vec, flint_rand_t state, slong len, nmod_t mod) + # Sets ``vec`` to a random vector of the given length with entries + # reduced modulo ``mod.n``. + + void _nmod_vec_set(mp_ptr res, mp_srcptr vec, slong len) + # Copies ``len`` entries from the vector ``vec`` to ``res``. + + void _nmod_vec_zero(mp_ptr vec, slong len) + # Zeros the given vector of the given length. + + void _nmod_vec_swap(mp_ptr a, mp_ptr b, slong length) + # Swaps the vectors ``a`` and ``b`` of length `n` by actually + # swapping the entries. + + void _nmod_vec_reduce(mp_ptr res, mp_srcptr vec, slong len, nmod_t mod) + # Reduces the entries of ``(vec, len)`` modulo ``mod.n`` and set + # ``res`` to the result. + + flint_bitcnt_t _nmod_vec_max_bits(mp_srcptr vec, slong len) + # Returns the maximum number of bits of any entry in the vector. + + int _nmod_vec_equal(mp_srcptr vec, mp_srcptr vec2, slong len) + # Returns~`1` if ``(vec, len)`` is equal to ``(vec2, len)``, + # otherwise returns~`0`. + + void _nmod_vec_print_pretty(mp_srcptr vec, slong len, nmod_t mod) + # Pretty-prints ``vec`` to ``stdout``. A header is printed followed by the + # vector enclosed in brackets. Each entry is right-aligned to the width of + # the modulus written in decimal, and the entries are separated by spaces. + # For example:: + # + # [ 33 181 107 61 32 11 80 138 34 171 86 156] + + int _nmod_vec_fprint_pretty(FILE * file, mp_srcptr vec, slong len, nmod_t mod) + # Same as ``_nmod_vec_print_pretty`` but printing to ``file``. + + int _nmod_vec_print(mp_srcptr vec, slong len, nmod_t mod) + # Currently, same as ``_nmod_vec_print_pretty``. + + int _nmod_vec_fprint(FILE * f, mp_srcptr vec, slong len, nmod_t mod) + # Currently, same as ``_nmod_vec_fprint_pretty``. + + void _nmod_vec_add(mp_ptr res, mp_srcptr vec1, mp_srcptr vec2, slong len, nmod_t mod) + # Sets ``(res, len)`` to the sum of ``(vec1, len)`` + # and ``(vec2, len)``. + + void _nmod_vec_sub(mp_ptr res, mp_srcptr vec1, mp_srcptr vec2, slong len, nmod_t mod) + # Sets ``(res, len)`` to the difference of ``(vec1, len)`` + # and ``(vec2, len)``. + + void _nmod_vec_neg(mp_ptr res, mp_srcptr vec, slong len, nmod_t mod) + # Sets ``(res, len)`` to the negation of ``(vec, len)``. + + void _nmod_vec_scalar_mul_nmod(mp_ptr res, mp_srcptr vec, slong len, mp_limb_t c, nmod_t mod) + # Sets ``(res, len)`` to ``(vec, len)`` multiplied by `c`. The element + # `c` and all elements of `vec` are assumed to be less than `mod.n`. + + void _nmod_vec_scalar_mul_nmod_shoup(mp_ptr res, mp_srcptr vec, slong len, mp_limb_t c, nmod_t mod) + # Sets ``(res, len)`` to ``(vec, len)`` multiplied by `c` using + # :func:`n_mulmod_shoup`. `mod.n` should be less than `2^{\mathtt{FLINT\_BITS} - 1}`. `c` + # and all elements of `vec` should be less than `mod.n`. + + void _nmod_vec_scalar_addmul_nmod(mp_ptr res, mp_srcptr vec, slong len, mp_limb_t c, nmod_t mod) + # Adds ``(vec, len)`` times `c` to the vector ``(res, len)``. The element + # `c` and all elements of `vec` are assumed to be less than `mod.n`. + + int _nmod_vec_dot_bound_limbs(slong len, nmod_t mod) + # Returns the number of limbs (0, 1, 2 or 3) needed to represent the + # unreduced dot product of two vectors of length ``len`` having entries + # modulo ``mod.n``, assuming that ``len`` is nonnegative and that + # ``mod.n`` is nonzero. The computed bound is tight. In other words, + # this function returns the precise limb size of ``len`` times + # ``(mod.n - 1) ^ 2``. + + mp_limb_t _nmod_vec_dot(mp_srcptr vec1, mp_srcptr vec2, slong len, nmod_t mod, int nlimbs) + # Returns the dot product of (``vec1``, ``len``) and + # (``vec2``, ``len``). The ``nlimbs`` parameter should be + # 0, 1, 2 or 3, specifying the number of limbs needed to represent the + # unreduced result. + + mp_limb_t _nmod_vec_dot_rev(mp_srcptr vec1, mp_srcptr vec2, slong len, nmod_t mod, int nlimbs) + # The same as ``_nmod_vec_dot``, but reverses ``vec2``. + + mp_limb_t _nmod_vec_dot_ptr(mp_srcptr vec1, const mp_ptr * vec2, slong offset, slong len, nmod_t mod, int nlimbs) + # Returns the dot product of (``vec1``, ``len``) and the values at + # ``vec2[i][offset]``. The ``nlimbs`` parameter should be + # 0, 1, 2 or 3, specifying the number of limbs needed to represent the + # unreduced result. diff --git a/src/sage/libs/flint/padic.pxd b/src/sage/libs/flint/padic.pxd index a8cc1202a40..dcac2d712df 100644 --- a/src/sage/libs/flint/padic.pxd +++ b/src/sage/libs/flint/padic.pxd @@ -16,25 +16,25 @@ cdef extern from "flint_wrap.h": # Returns the unit part of the `p`-adic number as a FLINT integer, which # can be used as an operand for the ``fmpz`` functions. - long padic_val(const padic_t op) + slong padic_val(const padic_t op) # Returns the valuation part of the `p`-adic number. # Note that this function is implemented as a macro and that # the expression ``padic_val(op)`` can be used as both an # *lvalue* and an *rvalue*. - long padic_get_val(const padic_t op) + slong padic_get_val(const padic_t op) # Returns the valuation part of the `p`-adic number. - long padic_prec(const padic_t op) + slong padic_prec(const padic_t op) # Returns the precision of the `p`-adic number. # Note that this function is implemented as a macro and that # the expression ``padic_prec(op)`` can be used as both an # *lvalue* and an *rvalue*. - long padic_get_prec(const padic_t op) + slong padic_get_prec(const padic_t op) # Returns the precision of the `p`-adic number. - void padic_ctx_init(padic_ctx_t ctx, const fmpz_t p, long min, long max, padic_print_mode mode) + void padic_ctx_init(padic_ctx_t ctx, const fmpz_t p, slong min, slong max, padic_print_mode mode) # Initialises the context ``ctx`` with the given data. # Assumes that `p` is a prime. This is not verified but the subsequent # behaviour is undefined if `p` is a composite number. @@ -55,7 +55,7 @@ cdef extern from "flint_wrap.h": void padic_ctx_clear(padic_ctx_t ctx) # Clears all memory that has been allocated as part of the context. - int _padic_ctx_pow_ui(fmpz_t rop, unsigned long e, const padic_ctx_t ctx) + int _padic_ctx_pow_ui(fmpz_t rop, ulong e, const padic_ctx_t ctx) # Sets ``rop`` to `p^e` as efficiently as possible, where # ``rop`` is expected to be an uninitialised ``fmpz_t``. # If the return value is non-zero, it is the responsibility of @@ -65,7 +65,7 @@ cdef extern from "flint_wrap.h": # Initialises the `p`-adic number with the precision set to # ``PADIC_DEFAULT_PREC``, which is defined as `20`. - void padic_init2(padic_t rop, long N) + void padic_init2(padic_t rop, slong N) # Initialises the `p`-adic number ``rop`` with precision `N`. void padic_clear(padic_t rop) @@ -101,11 +101,11 @@ cdef extern from "flint_wrap.h": void padic_set(padic_t rop, const padic_t op, const padic_ctx_t ctx) # Sets ``rop`` to the `p`-adic number ``op``. - void padic_set_si(padic_t rop, long op, const padic_ctx_t ctx) + void padic_set_si(padic_t rop, slong op, const padic_ctx_t ctx) # Sets the `p`-adic number ``rop`` to the # ``slong`` integer ``op``. - void padic_set_ui(padic_t rop, unsigned long op, const padic_ctx_t ctx) + void padic_set_ui(padic_t rop, ulong op, const padic_ctx_t ctx) # Sets the `p`-adic number ``rop`` to the ``ulong`` # integer ``op``. @@ -160,13 +160,13 @@ cdef extern from "flint_wrap.h": # Returns whether ``op1`` and ``op2`` are equal, that is, # whether `u_1 = u_2` and `v_1 = v_2`. - long * _padic_lifts_exps(long *n, long N) + slong * _padic_lifts_exps(slong *n, slong N) # Given a positive integer `N` define the sequence # `a_0 = N, a_1 = \lceil a_0/2\rceil, \dotsc, a_{n-1} = \lceil a_{n-2}/2\rceil = 1`. # Then `n = \lceil\log_2 N\rceil + 1`. # This function sets `n` and allocates and returns the array `a`. - void _padic_lifts_pows(fmpz *pow, const long *a, long n, const fmpz_t p) + void _padic_lifts_pows(fmpz *pow, const slong *a, slong n, const fmpz_t p) # Given an array `a` as computed above, this function # computes the corresponding powers of `p`, that is, # ``pow[i]`` is equal to `p^{a_i}`. @@ -183,13 +183,13 @@ cdef extern from "flint_wrap.h": void padic_mul(padic_t rop, const padic_t op1, const padic_t op2, const padic_ctx_t ctx) # Sets ``rop`` to the product of ``op1`` and ``op2``. - void padic_shift(padic_t rop, const padic_t op, long v, const padic_ctx_t ctx) + void padic_shift(padic_t rop, const padic_t op, slong v, const padic_ctx_t ctx) # Sets ``rop`` to the product of ``op`` and `p^v`. void padic_div(padic_t rop, const padic_t op1, const padic_t op2, const padic_ctx_t ctx) # Sets ``rop`` to the quotient of ``op1`` and ``op2``. - void _padic_inv_precompute(padic_inv_t S, const fmpz_t p, long N) + void _padic_inv_precompute(padic_inv_t S, const fmpz_t p, slong N) # Pre-computes some data and allocates temporary space for # `p`-adic inversion using Hensel lifting. @@ -208,7 +208,7 @@ cdef extern from "flint_wrap.h": # this function to avoid repeated memory allocations, as used # e.g. by the function :func:`padic_log`. - void _padic_inv(fmpz_t rop, const fmpz_t op, const fmpz_t p, long N) + void _padic_inv(fmpz_t rop, const fmpz_t op, const fmpz_t p, slong N) # Sets ``rop`` to the inverse of ``op`` modulo `p^N`, # assuming that ``op`` is a unit and `N \geq 1`. # In the current implementation, allows aliasing, but this might @@ -232,7 +232,7 @@ cdef extern from "flint_wrap.h": # `u \bmod 8` is a square in `\mathbf{Z} / 8 \mathbf{Z}`, # for `p = 2`. - void padic_pow_si(padic_t rop, const padic_t op, long e, const padic_ctx_t ctx) + void padic_pow_si(padic_t rop, const padic_t op, slong e, const padic_ctx_t ctx) # Sets ``rop`` to ``op`` raised to the power `e`, # which is defined as one whenever `e = 0`. # Assumes that some computations involving `e` and the @@ -242,7 +242,7 @@ cdef extern from "flint_wrap.h": # then `x^e = p^{ev} u^e` is defined modulo `p^{N + (e - 1) v}`, # which is a precision loss in case `v < 0`. - long _padic_exp_bound(long v, long N, const fmpz_t p) + slong _padic_exp_bound(slong v, slong N, const fmpz_t p) # Returns an integer `i` such that for all `j \geq i` we have # `\operatorname{ord}_p(x^j / j!) \geq N`, where `\operatorname{ord}_p(x) = v`. # When `p` is a word-sized prime, @@ -251,9 +251,9 @@ cdef extern from "flint_wrap.h": # Assumes that `v < N`. Moreover, `v` has to be at least `2` or `1`, # depending on whether `p` is `2` or odd. - void _padic_exp_rectangular(fmpz_t rop, const fmpz_t u, long v, const fmpz_t p, long N) - void _padic_exp_balanced(fmpz_t rop, const fmpz_t u, long v, const fmpz_t p, long N) - void _padic_exp(fmpz_t rop, const fmpz_t u, long v, const fmpz_t p, long N) + void _padic_exp_rectangular(fmpz_t rop, const fmpz_t u, slong v, const fmpz_t p, slong N) + void _padic_exp_balanced(fmpz_t rop, const fmpz_t u, slong v, const fmpz_t p, slong N) + void _padic_exp(fmpz_t rop, const fmpz_t u, slong v, const fmpz_t p, slong N) # Sets ``rop`` to the `p`-exponential function evaluated at # `x = p^v u`, reduced modulo `p^N`. # Assumes that `x \neq 0`, that `\operatorname{ord}_p(x) < N` and that @@ -284,7 +284,7 @@ cdef extern from "flint_wrap.h": # with the valuation and hence the rate of convergence, which # results in a quasi-linear algorithm in `N`, for fixed `p`. - long _padic_log_bound(long v, long N, const fmpz_t p) + slong _padic_log_bound(slong v, slong N, const fmpz_t p) # Returns `b` such that for all `i \geq b` we have # .. math :: # i v - \operatorname{ord}_p(i) \geq N @@ -293,10 +293,10 @@ cdef extern from "flint_wrap.h": # odd or `p = 2`, respectively, and also that `N < 2^{f-2}` # where `f` is ``FLINT_BITS``. - void _padic_log(fmpz_t z, const fmpz_t y, long v, const fmpz_t p, long N) - void _padic_log_rectangular(fmpz_t z, const fmpz_t y, long v, const fmpz_t p, long N) - void _padic_log_satoh(fmpz_t z, const fmpz_t y, long v, const fmpz_t p, long N) - void _padic_log_balanced(fmpz_t z, const fmpz_t y, long v, const fmpz_t p, long N) + void _padic_log(fmpz_t z, const fmpz_t y, slong v, const fmpz_t p, slong N) + void _padic_log_rectangular(fmpz_t z, const fmpz_t y, slong v, const fmpz_t p, slong N) + void _padic_log_satoh(fmpz_t z, const fmpz_t y, slong v, const fmpz_t p, slong N) + void _padic_log_balanced(fmpz_t z, const fmpz_t y, slong v, const fmpz_t p, slong N) # Computes # .. math :: # z = - \sum_{i = 1}^{\infty} \frac{y^i}{i} \pmod{p^N}, @@ -344,7 +344,7 @@ cdef extern from "flint_wrap.h": # the `p`-adic number ``op``, and if so sets ``rop`` to its # value. - void _padic_teichmuller(fmpz_t rop, const fmpz_t op, const fmpz_t p, long N) + void _padic_teichmuller(fmpz_t rop, const fmpz_t op, const fmpz_t p, slong N) # Computes the Teichm\"uller lift of the `p`-adic unit ``op``, # assuming that `N \geq 1`. # Supports aliasing between ``rop`` and ``op``. @@ -356,12 +356,12 @@ cdef extern from "flint_wrap.h": # a `(p-1)`-st root of unity. # If ``op`` has negative valuation, raises an ``abort`` signal. - unsigned long padic_val_fac_ui_2(unsigned long n) + ulong padic_val_fac_ui_2(ulong n) # Computes the `2`-adic valuation of `n!`. # Note that since `n` fits into an ``ulong``, so does # `\operatorname{ord}_2(n!)` since `\operatorname{ord}_2(n!) \leq (n - 1) / (p - 1) = n - 1`. - unsigned long padic_val_fac_ui(unsigned long n, const fmpz_t p) + ulong padic_val_fac_ui(ulong n, const fmpz_t p) # Computes the `p`-adic valuation of `n!`. # Note that since `n` fits into an ``ulong``, so does # `\operatorname{ord}_p(n!)` since `\operatorname{ord}_p(n!) \leq (n - 1) / (p - 1)`. @@ -378,13 +378,13 @@ cdef extern from "flint_wrap.h": # the string ``str`` is large enough to hold the representation and # it is also the return value. - int _padic_fprint(FILE * file, const fmpz_t u, long v, const padic_ctx_t ctx) + int _padic_fprint(FILE * file, const fmpz_t u, slong v, const padic_ctx_t ctx) int padic_fprint(FILE * file, const padic_t op, const padic_ctx_t ctx) # Prints the string representation of the `p`-adic number ``op`` # to the stream ``file``. # In the current implementation, always returns `1`. - int _padic_print(const fmpz_t u, long v, const padic_ctx_t ctx) + int _padic_print(const fmpz_t u, slong v, const padic_ctx_t ctx) int padic_print(const padic_t op, const padic_ctx_t ctx) # Prints the string representation of the `p`-adic number ``op`` # to the stream ``stdout``. diff --git a/src/sage/libs/flint/padic_mat.pxd b/src/sage/libs/flint/padic_mat.pxd index c4ad9dbf7ea..37bb36d3ce2 100644 --- a/src/sage/libs/flint/padic_mat.pxd +++ b/src/sage/libs/flint/padic_mat.pxd @@ -18,37 +18,37 @@ cdef extern from "flint_wrap.h": # The return value can be used as an argument to # the functions in the ``fmpz_mat`` module. - fmpz * padic_mat_entry(const padic_mat_t A, long i, long j) + fmpz * padic_mat_entry(const padic_mat_t A, slong i, slong j) # Returns a pointer to unit part of the entry in position `(i, j)`. # Note that this is not necessarily a unit. # The return value can be used as an argument to # the functions in the ``fmpz`` module. - long padic_mat_val(const padic_mat_t A) + slong padic_mat_val(const padic_mat_t A) # Allow access (as L-value or R-value) to ``val`` field of `A`. # This function is implemented as a macro. - long padic_mat_prec(const padic_mat_t A) + slong padic_mat_prec(const padic_mat_t A) # Allow access (as L-value or R-value) to ``prec`` field of `A`. # This function is implemented as a macro. - long padic_mat_get_val(const padic_mat_t A) + slong padic_mat_get_val(const padic_mat_t A) # Returns the valuation of the matrix. - long padic_mat_get_prec(const padic_mat_t A) + slong padic_mat_get_prec(const padic_mat_t A) # Returns the `p`-adic precision of the matrix. - long padic_mat_nrows(const padic_mat_t A) + slong padic_mat_nrows(const padic_mat_t A) # Returns the number of rows of the matrix `A`. - long padic_mat_ncols(const padic_mat_t A) + slong padic_mat_ncols(const padic_mat_t A) # Returns the number of columns of the matrix `A`. - void padic_mat_init(padic_mat_t A, long r, long c) + void padic_mat_init(padic_mat_t A, slong r, slong c) # Initialises the matrix `A` as a zero matrix with the specified numbers # of rows and columns and precision ``PADIC_DEFAULT_PREC``. - void padic_mat_init2(padic_mat_t A, long r, long c, long prec) + void padic_mat_init2(padic_mat_t A, slong r, slong c, slong prec) # Initialises the matrix `A` as a zero matrix with the specified numbers # of rows and columns and the given precision. @@ -102,10 +102,10 @@ cdef extern from "flint_wrap.h": # Sets the rational matrix `B` to the `p`-adic matrices `A`; # no reduction takes place. - void padic_mat_get_entry_padic(padic_t rop, const padic_mat_t op, long i, long j, const padic_ctx_t ctx) + void padic_mat_get_entry_padic(padic_t rop, const padic_mat_t op, slong i, slong j, const padic_ctx_t ctx) # Sets ``rop`` to the entry in position `(i, j)` in the matrix ``op``. - void padic_mat_set_entry_padic(padic_mat_t rop, long i, long j, const padic_t op, const padic_ctx_t ctx) + void padic_mat_set_entry_padic(padic_mat_t rop, slong i, slong j, const padic_t op, const padic_ctx_t ctx) # Sets the entry in position `(i, j)` in the matrix to ``rop``. int padic_mat_equal(const padic_mat_t A, const padic_mat_t B) diff --git a/src/sage/libs/flint/padic_poly.pxd b/src/sage/libs/flint/padic_poly.pxd index c9198d3caf4..b706daa47eb 100644 --- a/src/sage/libs/flint/padic_poly.pxd +++ b/src/sage/libs/flint/padic_poly.pxd @@ -19,18 +19,18 @@ cdef extern from "flint_wrap.h": # after finishing with the :type:`padic_poly_t` to free the memory # used by the polynomial. - void padic_poly_init2(padic_poly_t poly, long alloc, long prec) + void padic_poly_init2(padic_poly_t poly, slong alloc, slong prec) # Initialises ``poly`` with space for at least ``alloc`` coefficients # and sets the length to zero. The allocated coefficients are all set to # zero. The precision is set to ``prec``. - void padic_poly_realloc(padic_poly_t poly, long alloc, const fmpz_t p) + void padic_poly_realloc(padic_poly_t poly, slong alloc, const fmpz_t p) # Reallocates the given polynomial to have space for ``alloc`` # coefficients. If ``alloc`` is zero the polynomial is cleared # and then reinitialised. If the current length is greater than # ``alloc`` the polynomial is first truncated to length ``alloc``. - void padic_poly_fit_length(padic_poly_t poly, long len) + void padic_poly_fit_length(padic_poly_t poly, slong len) # If ``len`` is greater than the number of coefficients currently # allocated, then the polynomial is reallocated to have space for at # least ``len`` coefficients. No data is lost when calling this @@ -40,7 +40,7 @@ cdef extern from "flint_wrap.h": # of allocated coefficients when length is larger than the number of # coefficients currently allocated. - void _padic_poly_set_length(padic_poly_t poly, long len) + void _padic_poly_set_length(padic_poly_t poly, slong len) # Demotes the coefficients of ``poly`` beyond ``len`` and sets # the length of ``poly`` to ``len``. # Note that if the current length is greater than ``len`` the @@ -55,7 +55,7 @@ cdef extern from "flint_wrap.h": # If all coefficients are zero, the length is set to zero. This function # is mainly used internally, as all functions guarantee normalisation. - void _padic_poly_canonicalise(fmpz *poly, long *v, long len, const fmpz_t p) + void _padic_poly_canonicalise(fmpz *poly, slong *v, slong len, const fmpz_t p) void padic_poly_canonicalise(padic_poly_t poly, const fmpz_t p) # Brings the polynomial ``poly`` into canonical form, # assuming that it is normalised already. Does *not* @@ -65,16 +65,16 @@ cdef extern from "flint_wrap.h": # Reduces the polynomial ``poly`` modulo `p^N`, assuming # that it is in canonical form already. - void padic_poly_truncate(padic_poly_t poly, long n, const fmpz_t p) + void padic_poly_truncate(padic_poly_t poly, slong n, const fmpz_t p) # Truncates the polynomial to length at most~`n`. - long padic_poly_degree(const padic_poly_t poly) + slong padic_poly_degree(const padic_poly_t poly) # Returns the degree of the polynomial ``poly``. - long padic_poly_length(const padic_poly_t poly) + slong padic_poly_length(const padic_poly_t poly) # Returns the length of the polynomial ``poly``. - long padic_poly_val(const padic_poly_t poly) + slong padic_poly_val(const padic_poly_t poly) # Returns the valuation of the polynomial ``poly``, # which is defined to be the minimum valuation of all # its coefficients. @@ -82,22 +82,22 @@ cdef extern from "flint_wrap.h": # Note that this is implemented as a macro and can be # used as either a ``lvalue`` or a ``rvalue``. - long padic_poly_prec(padic_poly_t poly) + slong padic_poly_prec(padic_poly_t poly) # Returns the precision of the polynomial ``poly``. # Note that this is implemented as a macro and can be # used as either a ``lvalue`` or a ``rvalue``. # Note that increasing the precision might require # a call to :func:`padic_poly_reduce`. - void padic_poly_randtest(padic_poly_t f, flint_rand_t state, long len, const padic_ctx_t ctx) + void padic_poly_randtest(padic_poly_t f, flint_rand_t state, slong len, const padic_ctx_t ctx) # Sets `f` to a random polynomial of length at most ``len`` # with entries reduced modulo `p^N`. - void padic_poly_randtest_not_zero(padic_poly_t f, flint_rand_t state, long len, const padic_ctx_t ctx) + void padic_poly_randtest_not_zero(padic_poly_t f, flint_rand_t state, slong len, const padic_ctx_t ctx) # Sets `f` to a non-zero random polynomial of length at most ``len`` # with entries reduced modulo `p^N`. - void padic_poly_randtest_val(padic_poly_t f, flint_rand_t state, long val, long len, const padic_ctx_t ctx) + void padic_poly_randtest_val(padic_poly_t f, flint_rand_t state, slong val, slong len, const padic_ctx_t ctx) # Sets `f` to a random polynomial of length at most ``len`` # with at most the prescribed valuation ``val`` and entries # reduced modulo `p^N`. @@ -113,11 +113,11 @@ cdef extern from "flint_wrap.h": # Sets the polynomial ``poly1`` to the polynomial ``poly2``, # reduced to the precision of ``poly1``. - void padic_poly_set_si(padic_poly_t poly, long x, const padic_ctx_t ctx) + void padic_poly_set_si(padic_poly_t poly, slong x, const padic_ctx_t ctx) # Sets the polynomial ``poly`` to the ``signed slong`` # integer `x` reduced to the precision of the polynomial. - void padic_poly_set_ui(padic_poly_t poly, unsigned long x, const padic_ctx_t ctx) + void padic_poly_set_ui(padic_poly_t poly, ulong x, const padic_ctx_t ctx) # Sets the polynomial ``poly`` to the ``unsigned slong`` # integer `x` reduced to the precision of the polynomial. @@ -158,11 +158,11 @@ cdef extern from "flint_wrap.h": # including their precisions. # This is done efficiently by swapping pointers. - void padic_poly_get_coeff_padic(padic_t c, const padic_poly_t poly, long n, const padic_ctx_t ctx) + void padic_poly_get_coeff_padic(padic_t c, const padic_poly_t poly, slong n, const padic_ctx_t ctx) # Sets `c` to the coefficient of `x^n` in the polynomial, # reduced modulo the precision of `c`. - void padic_poly_set_coeff_padic(padic_poly_t f, long n, const padic_t c, const padic_ctx_t ctx) + void padic_poly_set_coeff_padic(padic_poly_t f, slong n, const padic_t c, const padic_ctx_t ctx) # Sets the coefficient of `x^n` in the polynomial `f` to `c`, # reduced to the precision of the polynomial `f`. # Note that this operation can take linear time in the length @@ -180,7 +180,7 @@ cdef extern from "flint_wrap.h": # to the constant polynomial~`1`, taking the precision # of the polynomial into account. - void _padic_poly_add(fmpz *rop, long *rval, long N, const fmpz *op1, long val1, long len1, long N1, const fmpz *op2, long val2, long len2, long N2, const padic_ctx_t ctx) + void _padic_poly_add(fmpz *rop, slong *rval, slong N, const fmpz *op1, slong val1, slong len1, slong N1, const fmpz *op2, slong val2, slong len2, slong N2, const padic_ctx_t ctx) # Sets ``(rop, *val, FLINT_MAX(len1, len2)`` to the sum of # ``(op1, val1, len1)`` and ``(op2, val2, len2)``. # Assumes that the input is reduced and guarantees that this is @@ -191,7 +191,7 @@ cdef extern from "flint_wrap.h": void padic_poly_add(padic_poly_t f, const padic_poly_t g, const padic_poly_t h, const padic_ctx_t ctx) # Sets `f` to the sum `g + h`. - void _padic_poly_sub(fmpz *rop, long *rval, long N, const fmpz *op1, long val1, long len1, long N1, const fmpz *op2, long val2, long len2, long N2, const padic_ctx_t ctx) + void _padic_poly_sub(fmpz *rop, slong *rval, slong N, const fmpz *op1, slong val1, slong len1, slong N1, const fmpz *op2, slong val2, slong len2, slong N2, const padic_ctx_t ctx) # Sets ``(rop, *val, FLINT_MAX(len1, len2)`` to the difference of # ``(op1, val1, len1)`` and ``(op2, val2, len2)``. # Assumes that the input is reduced and guarantees that this is @@ -205,7 +205,7 @@ cdef extern from "flint_wrap.h": void padic_poly_neg(padic_poly_t f, const padic_poly_t g, const padic_ctx_t ctx) # Sets `f` to `-g`. - void _padic_poly_scalar_mul_padic(fmpz *rop, long *rval, long N, const fmpz *op, long val, long len, const padic_t c, const padic_ctx_t ctx) + void _padic_poly_scalar_mul_padic(fmpz *rop, slong *rval, slong N, const fmpz *op, slong val, slong len, const padic_t c, const padic_ctx_t ctx) # Sets ``(rop, *rval, len)`` to ``(op, val, len)`` multiplied # by the scalar `c`. # The result will only be correctly reduced if the polynomial @@ -217,7 +217,7 @@ cdef extern from "flint_wrap.h": # polynomial ``op`` and the `p`-adic number `c`, # reducing the result modulo `p^N`. - void _padic_poly_mul(fmpz *rop, long *rval, long N, const fmpz *op1, long val1, long len1, const fmpz *op2, long val2, long len2, const padic_ctx_t ctx) + void _padic_poly_mul(fmpz *rop, slong *rval, slong N, const fmpz *op1, slong val1, slong len1, const fmpz *op2, slong val2, slong len2, const padic_ctx_t ctx) # Sets ``(rop, *rval, len1 + len2 - 1)`` to the product of # ``(op1, val1, len1)`` and ``(op2, val2, len2)``. # Assumes that the resulting valuation ``*rval``, which is @@ -229,13 +229,13 @@ cdef extern from "flint_wrap.h": # Sets the polynomial ``res`` to the product of the two polynomials # ``poly1`` and ``poly2``, reduced modulo `p^N`. - void _padic_poly_pow(fmpz *rop, long *rval, long N, const fmpz *op, long val, long len, unsigned long e, const padic_ctx_t ctx) + void _padic_poly_pow(fmpz *rop, slong *rval, slong N, const fmpz *op, slong val, slong len, ulong e, const padic_ctx_t ctx) # Sets the polynomial ``(rop, *rval, e (len - 1) + 1)`` to the # polynomial ``(op, val, len)`` raised to the power~`e`. # Assumes that `e > 1` and ``len > 0``. # Does not support aliasing between the input and output arguments. - void padic_poly_pow(padic_poly_t rop, const padic_poly_t op, unsigned long e, const padic_ctx_t ctx) + void padic_poly_pow(padic_poly_t rop, const padic_poly_t op, ulong e, const padic_ctx_t ctx) # Sets the polynomial ``rop`` to the polynomial ``op`` raised # to the power~`e`, reduced to the precision in ``rop``. # In the special case `e = 0`, sets ``rop`` to the constant @@ -248,7 +248,7 @@ cdef extern from "flint_wrap.h": # has valuation~`v < 0`. The result then has valuation # `e v < 0` but is only correct to precision `N + (e - 1) v`. - void padic_poly_inv_series(padic_poly_t g, const padic_poly_t f, long n, const padic_ctx_t ctx) + void padic_poly_inv_series(padic_poly_t g, const padic_poly_t f, slong n, const padic_ctx_t ctx) # Computes the power series inverse `g` of `f` modulo `X^n`, # where `n \geq 1`. # Given the polynomial `f \in \mathbf{Q}[X] \subset \mathbf{Q}_p[X]`, @@ -260,7 +260,7 @@ cdef extern from "flint_wrap.h": # of `f` is minimal among the coefficients of `f`. # Note that the result `g` is zero if and only if `- \operatorname{ord}_p(f) \geq N`. - void _padic_poly_derivative(fmpz *rop, long *rval, long N, const fmpz *op, long val, long len, const padic_ctx_t ctx) + void _padic_poly_derivative(fmpz *rop, slong *rval, slong N, const fmpz *op, slong val, slong len, const padic_ctx_t ctx) # Sets ``(rop, rval)`` to the derivative of ``(op, val)`` reduced # modulo `p^N`. # Supports aliasing of the input and the output parameters. @@ -269,16 +269,16 @@ cdef extern from "flint_wrap.h": # Sets ``rop`` to the derivative of ``op``, reducing the # result modulo the precision of ``rop``. - void padic_poly_shift_left(padic_poly_t rop, const padic_poly_t op, long n, const padic_ctx_t ctx) + void padic_poly_shift_left(padic_poly_t rop, const padic_poly_t op, slong n, const padic_ctx_t ctx) # Notationally, sets the polynomial ``rop`` to the polynomial ``op`` # multiplied by `x^n`, where `n \geq 0`, and reduces the result. - void padic_poly_shift_right(padic_poly_t rop, const padic_poly_t op, long n, const padic_ctx_t ctx) + void padic_poly_shift_right(padic_poly_t rop, const padic_poly_t op, slong n, const padic_ctx_t ctx) # Notationally, sets the polynomial ``rop`` to the polynomial # ``op`` after floor division by `x^n`, where `n \geq 0`, ensuring # the result is reduced. - void _padic_poly_evaluate_padic(fmpz_t u, long *v, long N, const fmpz *poly, long val, long len, const fmpz_t a, long b, const padic_ctx_t ctx) + void _padic_poly_evaluate_padic(fmpz_t u, slong *v, slong N, const fmpz *poly, slong val, slong len, const fmpz_t a, slong b, const padic_ctx_t ctx) void padic_poly_evaluate_padic(padic_t y, const padic_poly_t poly, const padic_t a, const padic_ctx_t ctx) # Sets the `p`-adic number ``y`` to ``poly`` evaluated at `a`, # reduced in the given context. @@ -290,7 +290,7 @@ cdef extern from "flint_wrap.h": # `y = F(a)` is defined to precision `N` when `a` is integral and # `N+(n-1)b` when `b < 0`. - void _padic_poly_compose(fmpz *rop, long *rval, long N, const fmpz *op1, long val1, long len1, const fmpz *op2, long val2, long len2, const padic_ctx_t ctx) + void _padic_poly_compose(fmpz *rop, slong *rval, slong N, const fmpz *op1, slong val1, slong len1, const fmpz *op2, slong val2, slong len2, const padic_ctx_t ctx) # Sets ``(rop, *rval, (len1-1)*(len2-1)+1)`` to the composition # of the two input polynomials, reducing the result modulo `p^N`. # Assumes that ``len1`` is non-zero. @@ -303,13 +303,13 @@ cdef extern from "flint_wrap.h": # denote the polynomials ``op1`` and ``op2``, respectively. # Then ``rop`` is set to `f(g(X))`. - void _padic_poly_compose_pow(fmpz *rop, long *rval, long N, const fmpz *op, long val, long len, long k, const padic_ctx_t ctx) + void _padic_poly_compose_pow(fmpz *rop, slong *rval, slong N, const fmpz *op, slong val, slong len, slong k, const padic_ctx_t ctx) # Sets ``(rop, *rval, (len - 1)*k + 1)`` to the composition of # ``(op, val, len)`` and the monomial `x^k`, where `k \geq 1`. # Assumes that ``len`` is positive. # Supports aliasing between the input and output polynomials. - void padic_poly_compose_pow(padic_poly_t rop, const padic_poly_t op, long k, const padic_ctx_t ctx) + void padic_poly_compose_pow(padic_poly_t rop, const padic_poly_t op, slong k, const padic_ctx_t ctx) # Sets ``rop`` to the composition of ``op`` and the monomial `x^k`, # where `k \geq 1`. # Note that no reduction takes place. @@ -319,7 +319,7 @@ cdef extern from "flint_wrap.h": # in a simple format useful for debugging purposes. # In the current implementation, always returns `1`. - int _padic_poly_fprint(FILE *file, const fmpz *poly, long val, long len, const padic_ctx_t ctx) + int _padic_poly_fprint(FILE *file, const fmpz *poly, slong val, slong len, const padic_ctx_t ctx) int padic_poly_fprint(FILE *file, const padic_poly_t poly, const padic_ctx_t ctx) # Prints a simple representation of the polynomial ``poly`` # to the stream ``file``. @@ -335,18 +335,18 @@ cdef extern from "flint_wrap.h": # The zero polynomial is represented by ``"0"``. # In the current implementation, always returns `1`. - int _padic_poly_print(const fmpz *poly, long val, long len, const padic_ctx_t ctx) + int _padic_poly_print(const fmpz *poly, slong val, slong len, const padic_ctx_t ctx) int padic_poly_print(const padic_poly_t poly, const padic_ctx_t ctx) # Prints a simple representation of the polynomial ``poly`` # to ``stdout``. # In the current implementation, always returns `1`. - int _padic_poly_fprint_pretty(FILE *file, const fmpz *poly, long val, long len, const char *var, const padic_ctx_t ctx) + int _padic_poly_fprint_pretty(FILE *file, const fmpz *poly, slong val, slong len, const char *var, const padic_ctx_t ctx) int padic_poly_fprint_pretty(FILE *file, const padic_poly_t poly, const char *var, const padic_ctx_t ctx) - int _padic_poly_print_pretty(const fmpz *poly, long val, long len, const char *var, const padic_ctx_t ctx) + int _padic_poly_print_pretty(const fmpz *poly, slong val, slong len, const char *var, const padic_ctx_t ctx) int padic_poly_print_pretty(const padic_poly_t poly, const char *var, const padic_ctx_t ctx) - int _padic_poly_is_canonical(const fmpz *op, long val, long len, const padic_ctx_t ctx) + int _padic_poly_is_canonical(const fmpz *op, slong val, slong len, const padic_ctx_t ctx) int padic_poly_is_canonical(const padic_poly_t op, const padic_ctx_t ctx) - int _padic_poly_is_reduced(const fmpz *op, long val, long len, long N, const padic_ctx_t ctx) + int _padic_poly_is_reduced(const fmpz *op, slong val, slong len, slong N, const padic_ctx_t ctx) int padic_poly_is_reduced(const padic_poly_t op, const padic_ctx_t ctx) diff --git a/src/sage/libs/flint/partitions.pxd b/src/sage/libs/flint/partitions.pxd index 99133e80fb4..044fa3c584b 100644 --- a/src/sage/libs/flint/partitions.pxd +++ b/src/sage/libs/flint/partitions.pxd @@ -12,7 +12,7 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void partitions_rademacher_bound(arf_t b, const fmpz_t n, unsigned long N) + void partitions_rademacher_bound(arf_t b, const fmpz_t n, ulong N) # Sets `b` to an upper bound for # .. math :: # M(n,N) = \frac{44 \pi^2}{225 \sqrt 3} N^{-1/2} @@ -22,7 +22,7 @@ cdef extern from "flint_wrap.h": # Hardy-Ramanujan-Rademacher formula when the series is taken up # to the term `t(n,N)` inclusive. - void partitions_hrr_sum_arb(arb_t x, const fmpz_t n, long N0, long N, int use_doubles) + void partitions_hrr_sum_arb(arb_t x, const fmpz_t n, slong N0, slong N, int use_doubles) # Evaluates the partial sum `\sum_{k=N_0}^N t(n,k)` of the # Hardy-Ramanujan-Rademacher series. # If *use_doubles* is nonzero, doubles and the system's standard library math @@ -44,18 +44,18 @@ cdef extern from "flint_wrap.h": # See :func:`partitions_hrr_sum_arb` for an explanation of the # *use_doubles* option. - void partitions_fmpz_ui(fmpz_t p, unsigned long n) + void partitions_fmpz_ui(fmpz_t p, ulong n) # Computes the partition function `p(n)` using the Hardy-Ramanujan-Rademacher # formula. This function computes a numerical ball containing `p(n)` # and verifies that the ball contains a unique integer. - void partitions_fmpz_ui_using_doubles(fmpz_t p, unsigned long n) + void partitions_fmpz_ui_using_doubles(fmpz_t p, ulong n) # Computes the partition function `p(n)`, enabling the use of doubles # internally. This significantly speeds up evaluation for small `n` # (e.g. `n < 10^6`), but the error bounds are not certified # (see remarks for :func:`partitions_hrr_sum_arb`). - void partitions_leading_fmpz(arb_t res, const fmpz_t n, long prec) + void partitions_leading_fmpz(arb_t res, const fmpz_t n, slong prec) # Sets *res* to the leading term in the Hardy-Ramanujan series # for `p(n)` (without Rademacher's correction of this term, which is # vanishingly small when `n` is large), that is, diff --git a/src/sage/libs/flint/perm.pxd b/src/sage/libs/flint/perm.pxd index c6c65b2a816..c2216d70f85 100644 --- a/src/sage/libs/flint/perm.pxd +++ b/src/sage/libs/flint/perm.pxd @@ -12,37 +12,37 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - long * _perm_init(long n) + slong * _perm_init(slong n) # Initialises the permutation for use. - void _perm_clear(long *vec) + void _perm_clear(slong *vec) # Clears the permutation. - void _perm_set(long *res, const long *vec, long n) + void _perm_set(slong *res, const slong *vec, slong n) # Sets the permutation ``res`` to the same as the permutation ``vec``. - void _perm_set_one(long *vec, long n) + void _perm_set_one(slong *vec, slong n) # Sets the permutation to the identity permutation. - void _perm_inv(long *res, const long *vec, long n) + void _perm_inv(slong *res, const slong *vec, slong n) # Sets ``res`` to the inverse permutation of ``vec``. # Allows aliasing of ``res`` and ``vec``. - void _perm_compose(long *res, const long *vec1, const long *vec2, long n) + void _perm_compose(slong *res, const slong *vec1, const slong *vec2, slong n) # Forms the composition `\pi_1 \circ \pi_2` of two permutations # `\pi_1` and `\pi_2`. Here, `\pi_2` is applied first, that is, # `(\pi_1 \circ \pi_2)(i) = \pi_1(\pi_2(i))`. # Allows aliasing of ``res``, ``vec1`` and ``vec2``. - int _perm_parity(const long *vec, long n) + int _perm_parity(const slong *vec, slong n) # Returns the parity of ``vec``, 0 if the permutation is even and 1 if # the permutation is odd. - int _perm_randtest(long *vec, long n, flint_rand_t state) + int _perm_randtest(slong *vec, slong n, flint_rand_t state) # Generates a random permutation vector of length `n` and returns # its parity, 0 or 1. # This function uses the Knuth shuffle algorithm to generate a uniformly # random permutation without retries. - int _perm_print(const long * vec, long n) + int _perm_print(const slong * vec, slong n) # Prints the permutation vector of length `n` to ``stdout``. diff --git a/src/sage/libs/flint/profiler.pxd b/src/sage/libs/flint/profiler.pxd new file mode 100644 index 00000000000..6738f843a3e --- /dev/null +++ b/src/sage/libs/flint/profiler.pxd @@ -0,0 +1,87 @@ +# distutils: libraries = flint +# distutils: depends = flint/profiler.h + +################################################################################ +# This file is auto-generated. Do not modify by hand +################################################################################ + +from libc.stdio cimport FILE +from sage.libs.gmp.types cimport * +from sage.libs.mpfr.types cimport * +from sage.libs.flint.types cimport * + +cdef extern from "flint_wrap.h": + + void timeit_start(timeit_t t) + void timeit_stop(timeit_t t) + # Gives wall and user time - useful for parallel programming. + # Example usage:: + # timeit_t t0; + # // ... + # timeit_start(t0); + # // do stuff, take some time + # timeit_stop(t0); + # flint_printf("cpu = %wd ms wall = %wd ms\n", t0->cpu, t0->wall); + + void start_clock(int n) + + void stop_clock(int n) + + double get_clock(int n) + # Gives time based on cycle counter. + # First one must ensure the processor speed in cycles per second + # is set correctly in ``profiler.h``, in the macro definition + # ``#define FLINT_CLOCKSPEED``. + # One can access the cycle counter directly by :func:`get_cycle_counter` + # which returns the current cycle counter as a ``double``. + # A sample usage of clocks is:: + # init_all_clocks(); + # start_clock(n); + # // do something + # stop_clock(n); + # flint_printf("Time in seconds is %f.3\n", get_clock(n)); + # where ``n`` is a clock number (from 0-19 by default). The number of + # clocks can be changed by altering ``FLINT_NUM_CLOCKS``. One can also + # initialise an individual clock with ``init_clock(n)``. + + void prof_repeat(double *min, double *max, profile_target_t target, void *arg) + # Allows one to automatically time a given function. Here is a sample usage: + # Suppose one has a function one wishes to profile:: + # void myfunc(ulong a, ulong b); + # One creates a struct for passing arguments to our function:: + # typedef struct + # { + # ulong a, b; + # } myfunc_t; + # a sample function:: + # void sample_myfunc(void * arg, ulong count) + # { + # myfunc_t * params = (myfunc_t *) arg; + # ulong a = params->a; + # ulong b = params->b; + # for (ulong i = 0; i < count; i++) + # { + # prof_start(); + # myfunc(a, b); + # prof_stop(); + # } + # } + # Then we do the profile:: + # double min, max; + # myfunc_t params; + # params.a = 3; + # params.b = 4; + # prof_repeat(&min, &max, sample_myfunc, ¶ms); + # flint_printf("Min time is %lf.3s, max time is %lf.3s\n", min, max); + # If either of the first two parameters to ``prof_repeat`` is + # ``NULL``, that value is not stored. + # One may set the minimum time in microseconds for a timing run by + # adjusting ``DURATION_THRESHOLD`` and one may set a target duration + # in microseconds by adjusting ``DURATION_TARGET`` in ``profiler.h``. + + void get_memory_usage(meminfo_t meminfo) + # Obtains information about the memory usage of the current process. + # The meminfo object contains the slots ``size`` (virtual memory size), + # ``peak`` (peak virtual memory size), ``rss`` (resident set size), + # ``hwm`` (peak resident set size). The values are stored in kilobytes + # (1024 bytes). This function currently only works on Linux. diff --git a/src/sage/libs/flint/qadic.pxd b/src/sage/libs/flint/qadic.pxd index 86fc1237bf7..fbcd6fe7134 100644 --- a/src/sage/libs/flint/qadic.pxd +++ b/src/sage/libs/flint/qadic.pxd @@ -12,7 +12,7 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void qadic_ctx_init(qadic_ctx_t ctx, const fmpz_t p, long d, long min, long max, const char *var, padic_print_mode mode) + void qadic_ctx_init(qadic_ctx_t ctx, const fmpz_t p, slong d, slong min, slong max, const char *var, padic_print_mode mode) # Initialises the context ``ctx`` with prime `p`, extension degree `d`, # variable name ``var`` and printing mode ``mode``. The defining polynomial # is chosen as a Conway polynomial if possible and otherwise as a random @@ -28,7 +28,7 @@ cdef extern from "flint_wrap.h": # arithmetic in `\mathbf{Q}_p / (p^N)` such as powers of `p` close # to `p^N`. - void qadic_ctx_init_conway(qadic_ctx_t ctx, const fmpz_t p, long d, long min, long max, const char *var, padic_print_mode mode) + void qadic_ctx_init_conway(qadic_ctx_t ctx, const fmpz_t p, slong d, slong min, slong max, const char *var, padic_print_mode mode) # Initialises the context ``ctx`` with prime `p`, extension degree `d`, # variable name ``var`` and printing mode ``mode``. The defining polynomial # is chosen as a Conway polynomial, hence has restrictions on the @@ -47,7 +47,7 @@ cdef extern from "flint_wrap.h": void qadic_ctx_clear(qadic_ctx_t ctx) # Clears all memory that has been allocated as part of the context. - long qadic_ctx_degree(const qadic_ctx_t ctx) + slong qadic_ctx_degree(const qadic_ctx_t ctx) # Returns the extension degree. void qadic_ctx_print(const qadic_ctx_t ctx) @@ -56,14 +56,14 @@ cdef extern from "flint_wrap.h": void qadic_init(qadic_t rop) # Initialises the element ``rop``, setting its value to `0`. - void qadic_init2(qadic_t rop, long prec) + void qadic_init2(qadic_t rop, slong prec) # Initialises the element ``rop`` with the given output precision, # setting the value to `0`. void qadic_clear(qadic_t rop) # Clears the element ``rop``. - void _fmpz_poly_reduce(fmpz *R, long lenR, const fmpz *a, const long *j, long len) + void _fmpz_poly_reduce(fmpz *R, slong lenR, const fmpz *a, const slong *j, slong len) # Reduces a polynomial ``(R, lenR)`` modulo a sparse monic # polynomial `f(X) = \sum_{i} a_{i} X^{j_{i}}` of degree at # least `2`. @@ -71,7 +71,7 @@ cdef extern from "flint_wrap.h": # sorted in ascending order. # Allows zero-padding in ``(R, lenR)``. - void _fmpz_mod_poly_reduce(fmpz *R, long lenR, const fmpz *a, const long *j, long len, const fmpz_t p) + void _fmpz_mod_poly_reduce(fmpz *R, slong lenR, const fmpz *a, const slong *j, slong len, const fmpz_t p) # Reduces a polynomial ``(R, lenR)`` modulo a sparse monic # polynomial `f(X) = \sum_{i} a_{i} X^{j_{i}}` of degree at # least `2` in `\mathbf{Z}/(p)`, where `p` is typically a prime @@ -83,10 +83,10 @@ cdef extern from "flint_wrap.h": void qadic_reduce(qadic_t rop, const qadic_ctx_t ctx) # Reduces ``rop`` modulo `f(X)` and `p^N`. - long qadic_val(const qadic_t op) + slong qadic_val(const qadic_t op) # Returns the valuation of ``op``. - long qadic_prec(const qadic_t op) + slong qadic_prec(const qadic_t op) # Returns the precision of ``op``. void qadic_randtest(qadic_t rop, flint_rand_t state, const qadic_ctx_t ctx) @@ -95,7 +95,7 @@ cdef extern from "flint_wrap.h": void qadic_randtest_not_zero(qadic_t rop, flint_rand_t state, const qadic_ctx_t ctx) # Generates a random non-zero element of `\mathbf{Q}_q`. - void qadic_randtest_val(qadic_t rop, flint_rand_t state, long v, const qadic_ctx_t ctx) + void qadic_randtest_val(qadic_t rop, flint_rand_t state, slong v, const qadic_ctx_t ctx) # Generates a random element of `\mathbf{Q}_q` with prescribed # valuation ``val``. # Note that if `v \geq N` then the element is necessarily zero. @@ -119,7 +119,7 @@ cdef extern from "flint_wrap.h": # when `N > 0`, and zero otherwise. If the extension degree # is one, raises an abort signal. - void qadic_set_ui(qadic_t rop, unsigned long op, const qadic_ctx_t ctx) + void qadic_set_ui(qadic_t rop, ulong op, const qadic_ctx_t ctx) # Sets ``rop`` to the integer ``op``, reduced in the # context. @@ -156,7 +156,7 @@ cdef extern from "flint_wrap.h": # Sets ``rop`` to the product of ``op1`` and ``op2``, # reducing the output in the given context. - void _qadic_inv(fmpz *rop, const fmpz *op, long len, const fmpz *a, const long *j, long lena, const fmpz_t p, long N) + void _qadic_inv(fmpz *rop, const fmpz *op, slong len, const fmpz *a, const slong *j, slong lena, const fmpz_t p, slong N) # Sets ``(rop, d)`` to the inverse of ``(op, len)`` # modulo `f(X)` given by ``(a,j,lena)`` and `p^N`. # Assumes that ``(op,len)`` has valuation `0`, that is, @@ -167,7 +167,7 @@ cdef extern from "flint_wrap.h": void qadic_inv(qadic_t rop, const qadic_t op, const qadic_ctx_t ctx) # Sets ``rop`` to the inverse of ``op``, reduced in the given context. - void _qadic_pow(fmpz *rop, const fmpz *op, long len, const fmpz_t e, const fmpz *a, const long *j, long lena, const fmpz_t p) + void _qadic_pow(fmpz *rop, const fmpz *op, slong len, const fmpz_t e, const fmpz *a, const slong *j, slong lena, const fmpz_t p) # Sets ``(rop, 2*d-1)`` to ``(op,len)`` raised to the power `e`, # reduced modulo `f(X)` given by ``(a, j, lena)`` and `p`, which # is expected to be a prime power. @@ -187,7 +187,7 @@ cdef extern from "flint_wrap.h": # Return ``1`` if the input is a square (to input precision). If so, set # ``rop`` to a square root (truncated to output precision). - void _qadic_exp_rectangular(fmpz *rop, const fmpz *op, long v, long len, const fmpz *a, const long *j, long lena, const fmpz_t p, long N, const fmpz_t pN) + void _qadic_exp_rectangular(fmpz *rop, const fmpz *op, slong v, slong len, const fmpz *a, const slong *j, slong lena, const fmpz_t p, slong N, const fmpz_t pN) # Sets ``(rop, 2*d - 1)`` to the exponential of ``(op, v, len)`` # reduced modulo `p^N`, assuming that the series converges. # Assumes that ``(op, v, len)`` is non-zero. @@ -198,7 +198,7 @@ cdef extern from "flint_wrap.h": # and sets ``rop`` to its value reduced modulo in the given # context. - void _qadic_exp_balanced(fmpz *rop, const fmpz *x, long v, long len, const fmpz *a, const long *j, long lena, const fmpz_t p, long N, const fmpz_t pN) + void _qadic_exp_balanced(fmpz *rop, const fmpz *x, slong v, slong len, const fmpz *a, const slong *j, slong lena, const fmpz_t p, slong N, const fmpz_t pN) # Sets ``(rop, d)`` to the exponential of ``(op, v, len)`` # reduced modulo `p^N`, assuming that the series converges. # Assumes that ``len`` is in `[1,d)` but supports zero padding, @@ -210,7 +210,7 @@ cdef extern from "flint_wrap.h": # and sets ``rop`` to its value reduced modulo in the given # context. - void _qadic_exp(fmpz *rop, const fmpz *op, long v, long len, const fmpz *a, const long *j, long lena, const fmpz_t p, long N, const fmpz_t pN) + void _qadic_exp(fmpz *rop, const fmpz *op, slong v, slong len, const fmpz *a, const slong *j, slong lena, const fmpz_t p, slong N, const fmpz_t pN) # Sets ``(rop, 2*d - 1)`` to the exponential of ``(op, v, len)`` # reduced modulo `p^N`, assuming that the series converges. # Assumes that ``(op, v, len)`` is non-zero. @@ -223,7 +223,7 @@ cdef extern from "flint_wrap.h": # The exponential series converges if the valuation of ``op`` # is at least `2` or `1` when `p` is even or odd, respectively. - void _qadic_log_rectangular(fmpz *z, const fmpz *y, long v, long len, const fmpz *a, const long *j, long lena, const fmpz_t p, long N, const fmpz_t pN) + void _qadic_log_rectangular(fmpz *z, const fmpz *y, slong v, slong len, const fmpz *a, const slong *j, slong lena, const fmpz_t p, slong N, const fmpz_t pN) # Computes # .. math :: # z = - \sum_{i = 1}^{\infty} \frac{y^i}{i} \pmod{p^N}. @@ -243,7 +243,7 @@ cdef extern from "flint_wrap.h": # Returns whether the `p`-adic logarithm function converges at # ``op``, and if so sets ``rop`` to its value. - void _qadic_log_balanced(fmpz *z, const fmpz *y, long len, const fmpz *a, const long *j, long lena, const fmpz_t p, long N, const fmpz_t pN) + void _qadic_log_balanced(fmpz *z, const fmpz *y, slong len, const fmpz *a, const slong *j, slong lena, const fmpz_t p, slong N, const fmpz_t pN) # Computes `(z, d)` as # .. math :: # z = - \sum_{i = 1}^{\infty} \frac{y^i}{i} \pmod{p^N}. @@ -255,7 +255,7 @@ cdef extern from "flint_wrap.h": # Returns whether the `p`-adic logarithm function converges at # ``op``, and if so sets ``rop`` to its value. - void _qadic_log(fmpz *z, const fmpz *y, long v, long len, const fmpz *a, const long *j, long lena, const fmpz_t p, long N, const fmpz_t pN) + void _qadic_log(fmpz *z, const fmpz *y, slong v, slong len, const fmpz *a, const slong *j, slong lena, const fmpz_t p, slong N, const fmpz_t pN) # Computes `(z, d)` as # .. math :: # z = - \sum_{i = 1}^{\infty} \frac{y^i}{i} \pmod{p^N}. @@ -280,7 +280,7 @@ cdef extern from "flint_wrap.h": # but this only converges when `\operatorname{ord}_p(x)` is at least `2` or `1` # when `p = 2` or `p > 2`, respectively. - void _qadic_frobenius_a(fmpz *rop, long e, const fmpz *a, const long *j, long lena, const fmpz_t p, long N) + void _qadic_frobenius_a(fmpz *rop, slong e, const fmpz *a, const slong *j, slong lena, const fmpz_t p, slong N) # Computes `\sigma^e(X) \bmod{p^N}` where `X` is such that # `\mathbf{Q}_q \cong \mathbf{Q}_p[X]/(f(X))`. # Assumes that the precision `N` is at least `2` and that the @@ -289,13 +289,13 @@ cdef extern from "flint_wrap.h": # Sets ``(rop, 2*d-1)``, although the actual length of the # output will be at most `d`. - void _qadic_frobenius(fmpz *rop, const fmpz *op, long len, long e, const fmpz *a, const long *j, long lena, const fmpz_t p, long N) + void _qadic_frobenius(fmpz *rop, const fmpz *op, slong len, slong e, const fmpz *a, const slong *j, slong lena, const fmpz_t p, slong N) # Sets ``(rop, 2*d-1)`` to `\Sigma` evaluated at ``(op, len)``. # Assumes that ``len`` is positive but at most `d`. # Assumes that `0 < e < d`. # Does not support aliasing. - void qadic_frobenius(qadic_t rop, const qadic_t op, long e, const qadic_ctx_t ctx) + void qadic_frobenius(qadic_t rop, const qadic_t op, slong e, const qadic_ctx_t ctx) # Evaluates the homomorphism `\Sigma^e` at ``op``. # Recall that `\mathbf{Q}_q / \mathbf{Q}_p` is Galois with Galois group # `\langle \Sigma \rangle \cong \langle \sigma \rangle`, which is also @@ -305,7 +305,7 @@ cdef extern from "flint_wrap.h": # `\operatorname{Gal}(\mathbf{Q}_q/\mathbf{Q}_p)`. # This functionality is implemented as ``GaloisImage()`` in Magma. - void _qadic_teichmuller(fmpz *rop, const fmpz *op, long len, const fmpz *a, const long *j, long lena, const fmpz_t p, long N) + void _qadic_teichmuller(fmpz *rop, const fmpz *op, slong len, const fmpz *a, const slong *j, slong lena, const fmpz_t p, slong N) # Sets ``(rop, d)`` to the Teichmüller lift of ``(op, len)`` # modulo `p^N`. # Does not support aliasing. @@ -318,7 +318,7 @@ cdef extern from "flint_wrap.h": # Sets ``rop`` to zero if ``op`` is zero in the given context. # Raises an exception if the valuation of ``op`` is negative. - void _qadic_trace(fmpz_t rop, const fmpz *op, long len, const fmpz *a, const long *j, long lena, const fmpz_t pN) + void _qadic_trace(fmpz_t rop, const fmpz *op, slong len, const fmpz *a, const slong *j, slong lena, const fmpz_t pN) void qadic_trace(padic_t rop, const qadic_t op, const qadic_ctx_t ctx) # Sets ``rop`` to the trace of ``op``. # For an element `a \in \mathbf{Q}_q`, multiplication by `a` defines @@ -327,7 +327,7 @@ cdef extern from "flint_wrap.h": # `\operatorname{Gal}(\mathbf{Q}_q / \mathbf{Q}_p)` then the trace of `a` is equal to # `\sum_{i=0}^{d-1} \Sigma^i (a)`. - void _qadic_norm(fmpz_t rop, const fmpz *op, long len, const fmpz *a, const long *j, long lena, const fmpz_t p, long N) + void _qadic_norm(fmpz_t rop, const fmpz *op, slong len, const fmpz *a, const slong *j, slong lena, const fmpz_t p, slong N) # Sets ``rop`` to the norm of the element ``(op,len)`` # in `\mathbf{Z}_q` to precision `N`, where ``len`` is at # least one. diff --git a/src/sage/libs/flint/qfb.pxd b/src/sage/libs/flint/qfb.pxd new file mode 100644 index 00000000000..669d144b68c --- /dev/null +++ b/src/sage/libs/flint/qfb.pxd @@ -0,0 +1,158 @@ +# distutils: libraries = flint +# distutils: depends = flint/qfb.h + +################################################################################ +# This file is auto-generated. Do not modify by hand +################################################################################ + +from libc.stdio cimport FILE +from sage.libs.gmp.types cimport * +from sage.libs.mpfr.types cimport * +from sage.libs.flint.types cimport * + +cdef extern from "flint_wrap.h": + + void qfb_init(qfb_t q) + # Initialise a ``qfb_t`` `q` for use. + + void qfb_clear(qfb_t q) + # Clear a ``qfb_t`` after use. This releases any memory allocated for + # `q` back to flint. + + void qfb_array_clear(qfb ** forms, slong num) + # Clean up an array of ``qfb`` structs allocated by a qfb function. + # The parameter ``num`` must be set to the length of the array. + + qfb_hash_t * qfb_hash_init(slong depth) + # Initialises a hash table of size `2^{depth}`. + + void qfb_hash_clear(qfb_hash_t * qhash, slong depth) + # Frees all memory used by a hash table of size `2^{depth}`. + + void qfb_hash_insert(qfb_hash_t * qhash, qfb_t q, qfb_t q2, slong it, slong depth) + # Insert the binary quadratic form ``q`` into the given hash table + # of size `2^{depth}` in the field ``q`` of the hash structure. + # Also store the second binary quadratic form ``q2`` (if not + # ``NULL``) in the similarly named field and ``iter`` in the + # similarly named field of the hash structure. + + slong qfb_hash_find(qfb_hash_t * qhash, qfb_t q, slong depth) + # Search for the given binary quadratic form or its inverse in the + # given hash table of size `2^{depth}`. If it is found, return + # the index in the table (which is an array of ``qfb_hash_t`` + # structs), otherwise return ``-1``. + + void qfb_set(qfb_t f, qfb_t g) + # Set the binary quadratic form `f` to be equal to `g`. + + int qfb_equal(qfb_t f, qfb_t g) + # Returns `1` if `f` and `g` are identical binary quadratic forms, + # otherwise returns `0`. + + void qfb_print(qfb_t q) + # Print a binary quadratic form `q` in the format `(a, b, c)` where + # `a`, `b`, `c` are the entries of `q`. + + void qfb_discriminant(fmpz_t D, qfb_t f) + # Set `D` to the discriminant of the binary quadratic form `f`, i.e. to + # `b^2 - 4ac`, where `f = (a, b, c)`. + + void qfb_reduce(qfb_t r, qfb_t f, fmpz_t D) + # Set `r` to a reduced form equivalent to the binary quadratic form `f` + # of discriminant `D`. + + int qfb_is_reduced(qfb_t r) + # Returns `1` if `q` is a reduced binary quadratic form, otherwise + # returns `0`. Note that this only tests for definite quadratic + # forms, so a form `r = (a,b,c)` is reduced if and only if `|b| \le a \le + # c` and if either inequality is an equality, then `b \ge 0`. + + slong qfb_reduced_forms(qfb ** forms, slong d) + # Given a discriminant `d` (negative for negative definite forms), compute + # all the reduced binary quadratic forms of that discriminant. The function + # allocates space for these and returns it in the variable ``forms`` + # (the user is responsible for cleaning this up by a single call to + # ``qfb_array_clear`` on ``forms``, after use.) The function returns + # the number of forms generated (the form class number). The forms are + # stored in an array of ``qfb`` structs, which contain fields + # ``a, b, c`` corresponding to forms `(a, b, c)`. + + slong qfb_reduced_forms_large(qfb ** forms, slong d) + # As for ``qfb_reduced_forms``. However, for small `|d|` it requires + # fewer primes to be computed at a small cost in speed. It is called + # automatically by ``qfb_reduced_forms`` for large `|d|` so that + # ``flint_primes`` is not exhausted. + + void qfb_nucomp(qfb_t r, const qfb_t f, const qfb_t g, fmpz_t D, fmpz_t L) + # Shanks' NUCOMP as described in [JvdP2002]_. + # Computes the near reduced composition of forms `f` and `g` given + # `L = \lfloor |D|^{1/4} \rfloor` where `D` is the common discriminant of + # `f` and `g`. The result is returned in `r`. + # We require that `f` is a primitive form. + + void qfb_nudupl(qfb_t r, const qfb_t f, fmpz_t D, fmpz_t L) + # As for ``nucomp`` except that the form `f` is composed with itself. + # We require that `f` is a primitive form. + + void qfb_pow_ui(qfb_t r, qfb_t f, fmpz_t D, ulong exp) + # Compute the near reduced form `r` which is the result of composing the + # principal form (identity) with `f` ``exp`` times. + # We require `D` to be set to the discriminant of `f` and that `f` is a + # primitive form. + + void qfb_pow(qfb_t r, qfb_t f, fmpz_t D, fmpz_t exp) + # As per ``qfb_pow_ui``. + + void qfb_inverse(qfb_t r, qfb_t f) + # Set `r` to the inverse of the binary quadratic form `f`. + + int qfb_is_principal_form(qfb_t f, fmpz_t D) + # Return `1` if `f` is the reduced principal form of discriminant `D`, + # i.e. the identity in the form class group, else `0`. + + void qfb_principal_form(qfb_t f, fmpz_t D) + # Set `f` to the principal form of discriminant `D`, i.e. the identity in + # the form class group. + + int qfb_is_primitive(qfb_t f) + # Return `1` if `f` is primitive, i.e. the greatest common divisor of its + # three coefficients is `1`. Otherwise the function returns `0`. + + void qfb_prime_form(qfb_t r, fmpz_t D, fmpz_t p) + # Sets `r` to the unique prime `(p, b, c)` of discriminant `D`, i.e. with + # `0 < b \leq p`. We require that `p` is a prime. + + int qfb_exponent_element(fmpz_t exponent, qfb_t f, fmpz_t n, ulong B1, ulong B2_sqrt) + # Find the exponent of the element `f` in the form class group of forms of + # discriminant `n`, doing a stage `1` with primes up to at least ``B1`` + # and a stage `2` for a single large prime up to at least the square of + # ``B2_sqrt``. If the function fails to find the exponent it returns `0`, + # otherwise the function returns `1` and ``exponent`` is set to the + # exponent of `f`, i.e. the minimum power of `f` which gives the identity. + # It is assumed that the form `f` is reduced. We require that ``iters`` + # is a power of `2` and that ``iters`` `\ge 1024`. + # The function performs a stage `2` which stores up to `4\times` + # ``iters`` binary quadratic forms, and `12\times` ``iters`` + # additional limbs of data in a hash table, where ``iters`` is the + # square root of ``B2``. + + int qfb_exponent(fmpz_t exponent, fmpz_t n, ulong B1, ulong B2_sqrt, slong c) + # Compute the exponent of the class group of discriminant `n`, doing + # a stage `1` with primes up to at least ``B1`` and a stage `2` for + # a single large prime up to at least the square of ``B2_sqrt``, and + # with probability at least `1 - 2^{-c}`. If the prime limits are + # exhausted without finding the exponent, the function returns `0`, + # otherwise it returns `1` and ``exponent`` is set to the computed + # exponent, i.e. the minimum power to which every element of the + # class group has to be raised in order to get the identity. + # The function performs a stage `2` which stores up to `4\times` + # ``iters`` binary quadratic forms, and `12\times` ``iters`` + # additional limbs of data in a hash table, where ``iters`` is the + # square root of ``B2``. + # We use algorithm 8.1 of [Sut2007]_. + + int qfb_exponent_grh(fmpz_t exponent, fmpz_t n, ulong B1, ulong B2_sqrt) + # Similar to ``qfb_exponent`` except that the bound ``c`` is + # automatically generated such that the exponent is guaranteed to be + # correct, if found, assuming the GRH, namely that the class group is + # generated by primes less than `6\log^2(|n|)` as described in [BD1992]_. diff --git a/src/sage/libs/flint/qqbar.pxd b/src/sage/libs/flint/qqbar.pxd index 0bdbad8db5e..6fd9dfcbac5 100644 --- a/src/sage/libs/flint/qqbar.pxd +++ b/src/sage/libs/flint/qqbar.pxd @@ -18,10 +18,10 @@ cdef extern from "flint_wrap.h": void qqbar_clear(qqbar_t res) # Clears the variable *res*, freeing or recycling its allocated memory. - qqbar_ptr _qqbar_vec_init(long len) + qqbar_ptr _qqbar_vec_init(slong len) # Returns a pointer to an array of *len* initialized *qqbar_struct*:s. - void _qqbar_vec_clear(qqbar_ptr vec, long len) + void _qqbar_vec_clear(qqbar_ptr vec, slong len) # Clears all *len* entries in the vector *vec* and frees the # vector itself. @@ -29,8 +29,8 @@ cdef extern from "flint_wrap.h": # Swaps the values of *x* and *y* efficiently. void qqbar_set(qqbar_t res, const qqbar_t x) - void qqbar_set_si(qqbar_t res, long x) - void qqbar_set_ui(qqbar_t res, unsigned long x) + void qqbar_set_si(qqbar_t res, slong x) + void qqbar_set_ui(qqbar_t res, ulong x) void qqbar_set_fmpz(qqbar_t res, const fmpz_t x) void qqbar_set_fmpq(qqbar_t res, const fmpq_t x) # Sets *res* to the value *x*. @@ -45,7 +45,7 @@ cdef extern from "flint_wrap.h": # and the return flag is 1. If *x* or *y* is non-finite (infinity or NaN), # the conversion fails and the return flag is 0. - long qqbar_degree(const qqbar_t x) + slong qqbar_degree(const qqbar_t x) # Returns the degree of *x*, i.e. the degree of the minimal polynomial. int qqbar_is_rational(const qqbar_t x) @@ -74,17 +74,17 @@ cdef extern from "flint_wrap.h": # Sets *res* to the height of *x* (the largest absolute value of the # coefficients of the minimal polynomial of *x*). - long qqbar_height_bits(const qqbar_t x) + slong qqbar_height_bits(const qqbar_t x) # Returns the height of *x* (the largest absolute value of the # coefficients of the minimal polynomial of *x*) measured in bits. - int qqbar_within_limits(const qqbar_t x, long deg_limit, long bits_limit) + int qqbar_within_limits(const qqbar_t x, slong deg_limit, slong bits_limit) # Checks if *x* has degree bounded by *deg_limit* and height # bounded by *bits_limit* bits, returning 0 (false) or 1 (true). # If *deg_limit* is set to 0, the degree check is skipped, # and similarly for *bits_limit*. - int qqbar_binop_within_limits(const qqbar_t x, const qqbar_t y, long deg_limit, long bits_limit) + int qqbar_binop_within_limits(const qqbar_t x, const qqbar_t y, slong deg_limit, slong bits_limit) # Checks if `x + y`, `x - y`, `x \cdot y` and `x / y` certainly have # degree bounded by *deg_limit* (by multiplying the degrees for *x* and *y* # to obtain a trivial bound). For *bits_limits*, the sum of the bit heights @@ -120,23 +120,23 @@ cdef extern from "flint_wrap.h": # of the minimal polynomial followed by a decimal representation of # the enclosing interval. This function is mainly intended for debugging. - void qqbar_printn(const qqbar_t x, long n) + void qqbar_printn(const qqbar_t x, slong n) # Prints *res* to standard output. The output shows a decimal # approximation to *n* digits. - void qqbar_printnd(const qqbar_t x, long n) + void qqbar_printnd(const qqbar_t x, slong n) # Prints *res* to standard output. The output shows a decimal # approximation to *n* digits, followed by the degree of the number. - void qqbar_randtest(qqbar_t res, flint_rand_t state, long deg, long bits) + void qqbar_randtest(qqbar_t res, flint_rand_t state, slong deg, slong bits) # Sets *res* to a random algebraic number with degree up to *deg* and # with height (measured in bits) up to *bits*. - void qqbar_randtest_real(qqbar_t res, flint_rand_t state, long deg, long bits) + void qqbar_randtest_real(qqbar_t res, flint_rand_t state, slong deg, slong bits) # Sets *res* to a random real algebraic number with degree up to *deg* and # with height (measured in bits) up to *bits*. - void qqbar_randtest_nonreal(qqbar_t res, flint_rand_t state, long deg, long bits) + void qqbar_randtest_nonreal(qqbar_t res, flint_rand_t state, slong deg, slong bits) # Sets *res* to a random nonreal algebraic number with degree up to *deg* and # with height (measured in bits) up to *bits*. Since all algebraic numbers # of degree 1 are real, *deg* must be at least 2. @@ -174,7 +174,7 @@ cdef extern from "flint_wrap.h": # order of the sign. This implies that complex conjugate roots # are adjacent, with the root in the upper half plane first. - unsigned long qqbar_hash(const qqbar_t x) + ulong qqbar_hash(const qqbar_t x) # Returns a hash of *x*. As currently implemented, this function # only hashes the minimal polynomial of *x*. The user should # mix in some bits based on the numerical value if it is critical @@ -234,29 +234,29 @@ cdef extern from "flint_wrap.h": void qqbar_add(qqbar_t res, const qqbar_t x, const qqbar_t y) void qqbar_add_fmpq(qqbar_t res, const qqbar_t x, const fmpq_t y) void qqbar_add_fmpz(qqbar_t res, const qqbar_t x, const fmpz_t y) - void qqbar_add_ui(qqbar_t res, const qqbar_t x, unsigned long y) - void qqbar_add_si(qqbar_t res, const qqbar_t x, long y) + void qqbar_add_ui(qqbar_t res, const qqbar_t x, ulong y) + void qqbar_add_si(qqbar_t res, const qqbar_t x, slong y) # Sets *res* to the sum of *x* and *y*. void qqbar_sub(qqbar_t res, const qqbar_t x, const qqbar_t y) void qqbar_sub_fmpq(qqbar_t res, const qqbar_t x, const fmpq_t y) void qqbar_sub_fmpz(qqbar_t res, const qqbar_t x, const fmpz_t y) - void qqbar_sub_ui(qqbar_t res, const qqbar_t x, unsigned long y) - void qqbar_sub_si(qqbar_t res, const qqbar_t x, long y) + void qqbar_sub_ui(qqbar_t res, const qqbar_t x, ulong y) + void qqbar_sub_si(qqbar_t res, const qqbar_t x, slong y) void qqbar_fmpq_sub(qqbar_t res, const fmpq_t x, const qqbar_t y) void qqbar_fmpz_sub(qqbar_t res, const fmpz_t x, const qqbar_t y) - void qqbar_ui_sub(qqbar_t res, unsigned long x, const qqbar_t y) - void qqbar_si_sub(qqbar_t res, long x, const qqbar_t y) + void qqbar_ui_sub(qqbar_t res, ulong x, const qqbar_t y) + void qqbar_si_sub(qqbar_t res, slong x, const qqbar_t y) # Sets *res* to the difference of *x* and *y*. void qqbar_mul(qqbar_t res, const qqbar_t x, const qqbar_t y) void qqbar_mul_fmpq(qqbar_t res, const qqbar_t x, const fmpq_t y) void qqbar_mul_fmpz(qqbar_t res, const qqbar_t x, const fmpz_t y) - void qqbar_mul_ui(qqbar_t res, const qqbar_t x, unsigned long y) - void qqbar_mul_si(qqbar_t res, const qqbar_t x, long y) + void qqbar_mul_ui(qqbar_t res, const qqbar_t x, ulong y) + void qqbar_mul_si(qqbar_t res, const qqbar_t x, slong y) # Sets *res* to the product of *x* and *y*. - void qqbar_mul_2exp_si(qqbar_t res, const qqbar_t x, long e) + void qqbar_mul_2exp_si(qqbar_t res, const qqbar_t x, slong e) # Sets *res* to *x* multiplied by `2^e`. void qqbar_sqr(qqbar_t res, const qqbar_t x) @@ -269,12 +269,12 @@ cdef extern from "flint_wrap.h": void qqbar_div(qqbar_t res, const qqbar_t x, const qqbar_t y) void qqbar_div_fmpq(qqbar_t res, const qqbar_t x, const fmpq_t y) void qqbar_div_fmpz(qqbar_t res, const qqbar_t x, const fmpz_t y) - void qqbar_div_ui(qqbar_t res, const qqbar_t x, unsigned long y) - void qqbar_div_si(qqbar_t res, const qqbar_t x, long y) + void qqbar_div_ui(qqbar_t res, const qqbar_t x, ulong y) + void qqbar_div_si(qqbar_t res, const qqbar_t x, slong y) void qqbar_fmpq_div(qqbar_t res, const fmpq_t x, const qqbar_t y) void qqbar_fmpz_div(qqbar_t res, const fmpz_t x, const qqbar_t y) - void qqbar_ui_div(qqbar_t res, unsigned long x, const qqbar_t y) - void qqbar_si_div(qqbar_t res, long x, const qqbar_t y) + void qqbar_ui_div(qqbar_t res, ulong x, const qqbar_t y) + void qqbar_si_div(qqbar_t res, slong x, const qqbar_t y) # Sets *res* to the quotient of *x* and *y*. # Division by zero calls *flint_abort*. @@ -284,26 +284,26 @@ cdef extern from "flint_wrap.h": # except that *c* must be nonzero. Division by zero calls *flint_abort*. void qqbar_sqrt(qqbar_t res, const qqbar_t x) - void qqbar_sqrt_ui(qqbar_t res, unsigned long x) + void qqbar_sqrt_ui(qqbar_t res, ulong x) # Sets *res* to the principal square root of *x*. void qqbar_rsqrt(qqbar_t res, const qqbar_t x) # Sets *res* to the reciprocal of the principal square root of *x*. # Division by zero calls *flint_abort*. - void qqbar_pow_ui(qqbar_t res, const qqbar_t x, unsigned long n) - void qqbar_pow_si(qqbar_t res, const qqbar_t x, long n) + void qqbar_pow_ui(qqbar_t res, const qqbar_t x, ulong n) + void qqbar_pow_si(qqbar_t res, const qqbar_t x, slong n) void qqbar_pow_fmpz(qqbar_t res, const qqbar_t x, const fmpz_t n) void qqbar_pow_fmpq(qqbar_t res, const qqbar_t x, const fmpq_t n) # Sets *res* to *x* raised to the *n*-th power. # Raising zero to a negative power aborts. - void qqbar_root_ui(qqbar_t res, const qqbar_t x, unsigned long n) - void qqbar_fmpq_root_ui(qqbar_t res, const fmpq_t x, unsigned long n) + void qqbar_root_ui(qqbar_t res, const qqbar_t x, ulong n) + void qqbar_fmpq_root_ui(qqbar_t res, const fmpq_t x, ulong n) # Sets *res* to the principal *n*-th root of *x*. The order *n* # must be positive. - void qqbar_fmpq_pow_si_ui(qqbar_t res, const fmpq_t x, long m, unsigned long n) + void qqbar_fmpq_pow_si_ui(qqbar_t res, const fmpq_t x, slong m, ulong n) # Sets *res* to the principal branch of `x^{m/n}`. The order *n* # must be positive. Division by zero calls *flint_abort*. @@ -313,21 +313,21 @@ cdef extern from "flint_wrap.h": # undefined, returns 0. Note that this function returns 0 instead of # aborting on division zero. - void qqbar_get_acb(acb_t res, const qqbar_t x, long prec) + void qqbar_get_acb(acb_t res, const qqbar_t x, slong prec) # Sets *res* to an enclosure of *x* rounded to *prec* bits. - void qqbar_get_arb(arb_t res, const qqbar_t x, long prec) + void qqbar_get_arb(arb_t res, const qqbar_t x, slong prec) # Sets *res* to an enclosure of *x* rounded to *prec* bits, assuming that # *x* is a real number. If *x* is not real, *res* is set to # `[\operatorname{NaN} \pm \infty]`. - void qqbar_get_arb_re(arb_t res, const qqbar_t x, long prec) + void qqbar_get_arb_re(arb_t res, const qqbar_t x, slong prec) # Sets *res* to an enclosure of the real part of *x* rounded to *prec* bits. - void qqbar_get_arb_im(arb_t res, const qqbar_t x, long prec) + void qqbar_get_arb_im(arb_t res, const qqbar_t x, slong prec) # Sets *res* to an enclosure of the imaginary part of *x* rounded to *prec* bits. - void qqbar_cache_enclosure(qqbar_t res, long prec) + void qqbar_cache_enclosure(qqbar_t res, slong prec) # Polishes the internal enclosure of *res* to at least *prec* bits # of precision in-place. Normally, *qqbar* operations that need # high-precision enclosures compute them on the fly without caching the results; @@ -347,9 +347,9 @@ cdef extern from "flint_wrap.h": # *x*, including *x* itself, where *d* is the degree of *x*. The output # is sorted in a canonical order (as defined by :func:`qqbar_cmp_root_order`). - void _qqbar_evaluate_fmpq_poly(qqbar_t res, const fmpz * poly, const fmpz_t den, long len, const qqbar_t x) + void _qqbar_evaluate_fmpq_poly(qqbar_t res, const fmpz * poly, const fmpz_t den, slong len, const qqbar_t x) void qqbar_evaluate_fmpq_poly(qqbar_t res, const fmpq_poly_t poly, const qqbar_t x) - void _qqbar_evaluate_fmpz_poly(qqbar_t res, const fmpz * poly, long len, const qqbar_t x) + void _qqbar_evaluate_fmpz_poly(qqbar_t res, const fmpz * poly, slong len, const qqbar_t x) void qqbar_evaluate_fmpz_poly(qqbar_t res, const fmpz_poly_t poly, const qqbar_t x) # Sets *res* to the value of the given polynomial *poly* evaluated at # the algebraic number *x*. These methods detect simple special cases and @@ -357,9 +357,9 @@ cdef extern from "flint_wrap.h": # to that of the minimal polynomial of *x*. In the generic case, evaluation # is done by computing minimal polynomials of representation matrices. - int qqbar_evaluate_fmpz_mpoly_iter(qqbar_t res, const fmpz_mpoly_t poly, qqbar_srcptr x, long deg_limit, long bits_limit, const fmpz_mpoly_ctx_t ctx) - int qqbar_evaluate_fmpz_mpoly_horner(qqbar_t res, const fmpz_mpoly_t poly, qqbar_srcptr x, long deg_limit, long bits_limit, const fmpz_mpoly_ctx_t ctx) - int qqbar_evaluate_fmpz_mpoly(qqbar_t res, const fmpz_mpoly_t poly, qqbar_srcptr x, long deg_limit, long bits_limit, const fmpz_mpoly_ctx_t ctx) + int qqbar_evaluate_fmpz_mpoly_iter(qqbar_t res, const fmpz_mpoly_t poly, qqbar_srcptr x, slong deg_limit, slong bits_limit, const fmpz_mpoly_ctx_t ctx) + int qqbar_evaluate_fmpz_mpoly_horner(qqbar_t res, const fmpz_mpoly_t poly, qqbar_srcptr x, slong deg_limit, slong bits_limit, const fmpz_mpoly_ctx_t ctx) + int qqbar_evaluate_fmpz_mpoly(qqbar_t res, const fmpz_mpoly_t poly, qqbar_srcptr x, slong deg_limit, slong bits_limit, const fmpz_mpoly_ctx_t ctx) # Sets *res* to the value of *poly* evaluated at the algebraic numbers # given in the vector *x*. The number of variables is defined by # the context object *ctx*. @@ -395,73 +395,73 @@ cdef extern from "flint_wrap.h": # of *mat* and then call :func:`qqbar_roots_fmpz_poly` with the same # flags. - void qqbar_root_of_unity(qqbar_t res, long p, unsigned long q) + void qqbar_root_of_unity(qqbar_t res, slong p, ulong q) # Sets *res* to the root of unity `e^{2 \pi i p / q}`. - int qqbar_is_root_of_unity(long * p, unsigned long * q, const qqbar_t x) + int qqbar_is_root_of_unity(slong * p, ulong * q, const qqbar_t x) # If *x* is not a root of unity, returns 0. # If *x* is a root of unity, returns 1. # If *p* and *q* are not *NULL* and *x* is a root of unity, # this also sets *p* and *q* to the minimal integers with `0 \le p < q` # such that `x = e^{2 \pi i p / q}`. - void qqbar_exp_pi_i(qqbar_t res, long p, unsigned long q) + void qqbar_exp_pi_i(qqbar_t res, slong p, ulong q) # Sets *res* to the root of unity `e^{\pi i p / q}`. - void qqbar_cos_pi(qqbar_t res, long p, unsigned long q) - void qqbar_sin_pi(qqbar_t res, long p, unsigned long q) - int qqbar_tan_pi(qqbar_t res, long p, unsigned long q) - int qqbar_cot_pi(qqbar_t res, long p, unsigned long q) - int qqbar_sec_pi(qqbar_t res, long p, unsigned long q) - int qqbar_csc_pi(qqbar_t res, long p, unsigned long q) + void qqbar_cos_pi(qqbar_t res, slong p, ulong q) + void qqbar_sin_pi(qqbar_t res, slong p, ulong q) + int qqbar_tan_pi(qqbar_t res, slong p, ulong q) + int qqbar_cot_pi(qqbar_t res, slong p, ulong q) + int qqbar_sec_pi(qqbar_t res, slong p, ulong q) + int qqbar_csc_pi(qqbar_t res, slong p, ulong q) # Sets *res* to the trigonometric function `\cos(\pi x)`, # `\sin(\pi x)`, etc., with `x = \tfrac{p}{q}`. # The functions tan, cot, sec and csc return the flag 1 if the value exists, # and return 0 if the evaluation point is a pole of the function. - int qqbar_log_pi_i(long * p, unsigned long * q, const qqbar_t x) + int qqbar_log_pi_i(slong * p, ulong * q, const qqbar_t x) # If `y = \operatorname{log}(x) / (\pi i)` is algebraic, and hence # necessarily rational, sets `y = p / q` to the reduced such # fraction with `-1 < y \le 1` and returns 1. # If *y* is not algebraic, returns 0. - int qqbar_atan_pi(long * p, unsigned long * q, const qqbar_t x) + int qqbar_atan_pi(slong * p, ulong * q, const qqbar_t x) # If `y = \operatorname{atan}(x) / \pi` is algebraic, and hence # necessarily rational, sets `y = p / q` to the reduced such # fraction with `|y| < \tfrac{1}{2}` and returns 1. # If *y* is not algebraic, returns 0. - int qqbar_asin_pi(long * p, unsigned long * q, const qqbar_t x) + int qqbar_asin_pi(slong * p, ulong * q, const qqbar_t x) # If `y = \operatorname{asin}(x) / \pi` is algebraic, and hence # necessarily rational, sets `y = p / q` to the reduced such # fraction with `|y| \le \tfrac{1}{2}` and returns 1. # If *y* is not algebraic, returns 0. - int qqbar_acos_pi(long * p, unsigned long * q, const qqbar_t x) + int qqbar_acos_pi(slong * p, ulong * q, const qqbar_t x) # If `y = \operatorname{acos}(x) / \pi` is algebraic, and hence # necessarily rational, sets `y = p / q` to the reduced such # fraction with `0 \le y \le 1` and returns 1. # If *y* is not algebraic, returns 0. - int qqbar_acot_pi(long * p, unsigned long * q, const qqbar_t x) + int qqbar_acot_pi(slong * p, ulong * q, const qqbar_t x) # If `y = \operatorname{acot}(x) / \pi` is algebraic, and hence # necessarily rational, sets `y = p / q` to the reduced such # fraction with `-\tfrac{1}{2} < y \le \tfrac{1}{2}` and returns 1. # If *y* is not algebraic, returns 0. - int qqbar_asec_pi(long * p, unsigned long * q, const qqbar_t x) + int qqbar_asec_pi(slong * p, ulong * q, const qqbar_t x) # If `y = \operatorname{asec}(x) / \pi` is algebraic, and hence # necessarily rational, sets `y = p / q` to the reduced such # fraction with `0 \le y \le 1` and returns 1. # If *y* is not algebraic, returns 0. - int qqbar_acsc_pi(long * p, unsigned long * q, const qqbar_t x) + int qqbar_acsc_pi(slong * p, ulong * q, const qqbar_t x) # If `y = \operatorname{acsc}(x) / \pi` is algebraic, and hence # necessarily rational, sets `y = p / q` to the reduced such # fraction with `-\tfrac{1}{2} \le y \le \tfrac{1}{2}` and returns 1. # If *y* is not algebraic, returns 0. - int qqbar_guess(qqbar_t res, const acb_t z, long max_deg, long max_bits, int flags, long prec) + int qqbar_guess(qqbar_t res, const acb_t z, slong max_deg, slong max_bits, int flags, slong prec) # Attempts to find an algebraic number *res* of degree at most *max_deg* and # height at most *max_bits* bits matching the numerical enclosure *z*. # The return flag indicates success. @@ -478,7 +478,7 @@ cdef extern from "flint_wrap.h": # repeatedly with successively larger parameters when the size of the # intended solution is unknown or may be much smaller than a worst-case bound. - int qqbar_express_in_field(fmpq_poly_t res, const qqbar_t alpha, const qqbar_t x, long max_bits, int flags, long prec) + int qqbar_express_in_field(fmpq_poly_t res, const qqbar_t alpha, const qqbar_t x, slong max_bits, int flags, slong prec) # Attempts to express *x* in the number field generated by *alpha*, returning # success (0 or 1). On success, *res* is set to a polynomial *f* of degree # less than the degree of *alpha* and with height (counting both the numerator @@ -588,7 +588,7 @@ cdef extern from "flint_wrap.h": # presentation when the numerical value is important, but serialization # and deserialization can be expensive. - int qqbar_get_fexpr_formula(fexpr_t res, const qqbar_t x, unsigned long flags) + int qqbar_get_fexpr_formula(fexpr_t res, const qqbar_t x, ulong flags) # Attempts to express the algebraic number *x* as a closed-form expression # using arithmetic operations, radicals, and possibly exponentials # or trigonometric functions, but without using ``PolynomialRootNearest`` @@ -649,7 +649,7 @@ cdef extern from "flint_wrap.h": # Performs a binary operation using a generic algorithm. This does not # check for special cases. - int _qqbar_validate_uniqueness(acb_t res, const fmpz_poly_t poly, const acb_t z, long max_prec) + int _qqbar_validate_uniqueness(acb_t res, const fmpz_poly_t poly, const acb_t z, slong max_prec) # Given *z* known to be an enclosure of at least one root of *poly*, # certifies that the enclosure contains a unique root, and in that # case sets *res* to a new (possibly improved) enclosure for the same @@ -663,7 +663,7 @@ cdef extern from "flint_wrap.h": # existence; when existence has not been ensured a priori, # :func:`_qqbar_validate_existence_uniqueness` should be used instead. - int _qqbar_validate_existence_uniqueness(acb_t res, const fmpz_poly_t poly, const acb_t z, long max_prec) + int _qqbar_validate_existence_uniqueness(acb_t res, const fmpz_poly_t poly, const acb_t z, slong max_prec) # Given any complex interval *z*, certifies that the enclosure contains a # unique root of *poly*, and in that case sets *res* to a new (possibly # improved) enclosure for the same root, returning 1. Returns 0 if @@ -672,8 +672,8 @@ cdef extern from "flint_wrap.h": # interval Newton method. The working precision is determined from the # accuracy of *z*, but limited by *max_prec* bits. - void _qqbar_enclosure_raw(acb_t res, const fmpz_poly_t poly, const acb_t z, long prec) - void qqbar_enclosure_raw(acb_t res, const qqbar_t x, long prec) + void _qqbar_enclosure_raw(acb_t res, const fmpz_poly_t poly, const acb_t z, slong prec) + void qqbar_enclosure_raw(acb_t res, const qqbar_t x, slong prec) # Sets *res* to an enclosure of *x* accurate to about *prec* bits # (the actual accuracy can be slightly lower, or higher). # This function uses repeated interval Newton steps to polish the initial @@ -683,7 +683,7 @@ cdef extern from "flint_wrap.h": # If the initial enclosure is accurate enough, *res* is set to this value # without rounding and without further computation. - int _qqbar_acb_lindep(fmpz * rel, acb_srcptr vec, long len, int check, long prec) + int _qqbar_acb_lindep(fmpz * rel, acb_srcptr vec, slong len, int check, slong prec) # Attempts to find an integer vector *rel* giving a linear relation between # the elements of the real or complex vector *vec*, using the LLL algorithm. # The working precision is set to the minimum of *prec* and the relative diff --git a/src/sage/libs/flint/qsieve.pxd b/src/sage/libs/flint/qsieve.pxd index ceab7a684a6..170ffef4339 100644 --- a/src/sage/libs/flint/qsieve.pxd +++ b/src/sage/libs/flint/qsieve.pxd @@ -1,8 +1,130 @@ # distutils: libraries = flint # distutils: depends = flint/qsieve.h +################################################################################ +# This file is auto-generated. Do not modify by hand +################################################################################ + +from libc.stdio cimport FILE +from sage.libs.gmp.types cimport * +from sage.libs.mpfr.types cimport * from sage.libs.flint.types cimport * -# flint/qsieve.h cdef extern from "flint_wrap.h": - void qsieve_factor(fmpz_factor_t, const fmpz_t) + + mp_limb_t qsieve_knuth_schroeppel(qs_t qs_inf) + # Return the Knuth-Schroeppel multiplier for the `n`, integer to be factored + # based upon the Knuth-Schroeppel function. + + mp_limb_t qsieve_primes_init(qs_t qs_inf) + # Compute the factor base prime along with there inverse for `kn`, where `k` + # is Knuth-Schroeppel multiplier and `n` is the integer to be factored. It + # also computes the square root of `kn` modulo factor base primes. + + mp_limb_t qsieve_primes_increment(qs_t qs_inf, mp_limb_t delta) + # It increase the number of factor base primes by amount 'delta' and + # calculate inverse of those primes along with the square root of `kn` modulo + # those primes. + + void qsieve_init_A0(qs_t qs_inf) + # First it chooses the possible range of factor of `A _0`, based on the number + # of bits in optimal value of `A _0`. It tries to select range such that we have + # plenty of primes to choose from as well as number of factor in `A _0` are + # sufficient. For input of size less than 130 bit, this selection method doesn't + # work therefore we randomly generate 2 or 3-subset of all the factor base prime + # as the factor of `A _0`. + # Otherwise, if we have to select `s` factor for `A _0`, we generate `s - 1`- + # subset from odd indices of the possible range of factor and then search last + # factor using binary search from the even indices of possible range of factor + # such that value of `A _0` is close to it's optimal value. + + void qsieve_next_A0(qs_t qs_inf) + # Find next candidate for `A _0` as follows: + # generate next lexicographic `s - 1`-subset from the odd indices of possible + # range of factor base and choose the last factor from even indices using binary + # search so that value `A _0` is close to it's optimal value. + + void qsieve_compute_pre_data(qs_t qs_inf) + # Precompute all the data associated with factor's of `A _0`, since `A _0` is going + # to be fixed for several `A`. + + void qsieve_init_poly_first(qs_t qs_inf) + # Initializes the value of `A = q _0 * A _0`, where `q _0` is non-factor base prime. + # precompute the data necessary for generating different `B` value using grey code + # formula. Combine the data calculated for the factor of `A _0` along with the + # parameter `q _0` to obtain data as for factor of `A`. It also calculates the sieve + # offset for all the factor base prime, for first polynomial. + + void qsieve_init_poly_next(qs_t qs_inf, slong i) + # Generate next polynomial or next `B` value for particular `A` and also updates the + # sieve offsets for all the factor base prime, for this `B` value. + + void qsieve_compute_C(fmpz_t C, qs_t qs_inf, qs_poly_t poly) + # Given `A` and `B`, calculate `C = (B ^2 - A) / N`. + + void qsieve_do_sieving(qs_t qs_inf, unsigned char * sieve, qs_poly_t poly) + # First initialize the sieve array to zero, then for each `p \in` ``factor base``, add + # `\log_2(p)` to the locations `\operatorname{soln1} _p + i * p` and `\operatorname{soln2} _p + i * p` for + # `i = 0, 1, 2,\dots`, where `\operatorname{soln1} _p` and `\operatorname{soln2} _p` are the sieve offsets calculated + # for `p`. + + void qsieve_do_sieving2(qs_t qs_inf, unsigned char * seive, qs_poly_t poly) + # Perform the same task as above but instead of sieving over whole array at once divide + # the array in blocks and then sieve over each block for all the primes in factor base. + + slong qsieve_evaluate_candidate(qs_t qs_inf, ulong i, unsigned char * sieve, qs_poly_t poly) + # For location `i` in sieve array value at which, is greater than sieve threshold, check + # the value of `Q(x)` at position `i` for smoothness. If value is found to be smooth then + # store it for later processing, else check the residue for the partial if it is found to + # be partial then store it for late processing. + + slong qsieve_evaluate_sieve(qs_t qs_inf, unsigned char * sieve, qs_poly_t poly) + # Scan the sieve array for location at, which accumulated value is greater than sieve + # threshold. + + slong qsieve_collect_relations(qs_t qs_inf, unsigned char * sieve) + # Call for initialization of polynomial, sieving, and scanning of sieve + # for all the possible polynomials for particular hypercube i.e. `A`. + + void qsieve_write_to_file(qs_t qs_inf, mp_limb_t prime, fmpz_t Y, qs_poly_t poly) + # Write a relation to the file. Format is as follows, + # first write large prime, in case of full relation it is 1, then write exponent + # of small primes, then write number of factor followed by offset of factor in + # factor base and their exponent and at last value of `Q(x)` for particular relation. + # each relation is written in new line. + + hash_t * qsieve_get_table_entry(qs_t qs_inf, mp_limb_t prime) + # Return the pointer to the location of 'prime' is hash table if it exist, else + # create and entry for it in hash table and return pointer to that. + + void qsieve_add_to_hashtable(qs_t qs_inf, mp_limb_t prime) + # Add 'prime' to the hast table. + + relation_t qsieve_parse_relation(qs_t qs_inf, char * str) + # Given a string representation of relation from the file, parse it to obtain + # all the parameters of relation. + + relation_t qsieve_merge_relation(qs_t qs_inf, relation_t a, relation_t b) + # Given two partial relation having same large prime, merge them to obtain a full + # relation. + + int qsieve_compare_relation(const void * a, const void * b) + # Compare two relation based on, first large prime, then number of factor and then + # offsets of factor in factor base. + + int qsieve_remove_duplicates(relation_t * rel_list, slong num_relations) + # Remove duplicate from given list of relations by sorting relations in the list. + + void qsieve_insert_relation2(qs_t qs_inf, relation_t * rel_list, slong num_relations) + # Given a list of relations, insert each relation from the list into the matrix for + # further processing. + + int qsieve_process_relation(qs_t qs_inf) + # After we have accumulated required number of relations, first process the file by + # reading all the relations, removes singleton. Then merge all the possible partial + # to obtain full relations. + + void qsieve_factor(fmpz_factor_t factors, const fmpz_t n) + # Factor `n` using the quadratic sieve method. It is required that `n` is not a + # prime and not a perfect power. There is no guarantee that the factors found will + # be prime, or distinct. diff --git a/src/sage/libs/flint/qsieve.pyx b/src/sage/libs/flint/qsieve_sage.pyx similarity index 95% rename from src/sage/libs/flint/qsieve.pyx rename to src/sage/libs/flint/qsieve_sage.pyx index 78c28198718..6f8fb58fe52 100644 --- a/src/sage/libs/flint/qsieve.pyx +++ b/src/sage/libs/flint/qsieve_sage.pyx @@ -5,10 +5,11 @@ been absorbed into flint. """ from cysignals.signals cimport sig_on, sig_off -from .types cimport fmpz_t +from .types cimport fmpz_t, fmpz_factor_t from .fmpz cimport fmpz_init, fmpz_set_mpz from .fmpz_factor cimport fmpz_factor_init, fmpz_factor_clear from .fmpz_factor_extra cimport fmpz_factor_to_pairlist +from .qsieve cimport qsieve_factor from sage.rings.integer cimport Integer diff --git a/src/sage/libs/flint/thread_pool.pxd b/src/sage/libs/flint/thread_pool.pxd index 98a7f0149bb..55517e2fee9 100644 --- a/src/sage/libs/flint/thread_pool.pxd +++ b/src/sage/libs/flint/thread_pool.pxd @@ -1,45 +1,49 @@ # distutils: libraries = flint # distutils: depends = flint/thread_pool.h -#***************************************************************************** -# Copyright (C) 2021 Vincent Delecroix -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 2 of the License, or -# (at your option) any later version. -# http://www.gnu.org/licenses/ -#***************************************************************************** +################################################################################ +# This file is auto-generated. Do not modify by hand +################################################################################ -from .types cimport slong, thread_pool_entry_t, thread_pool_t +from libc.stdio cimport FILE +from sage.libs.gmp.types cimport * +from sage.libs.mpfr.types cimport * +from sage.libs.flint.types cimport * -# flint/thread_pool.h -cdef extern from "flint/thread_pool.h": - extern thread_pool_t global_thread_pool - extern int global_thread_pool_initialized +cdef extern from "flint_wrap.h": - void * thread_pool_idle_loop(void * varg) - - void thread_pool_init(thread_pool_t T, slong l) - - int thread_pool_set_affinity(thread_pool_t T, - int * cpus, slong length) - - int thread_pool_restore_affinity(thread_pool_t T) + void thread_pool_init(thread_pool_t T, slong size) + # Initialise ``T`` and create ``size`` sleeping + # threads that are available to work. + # If `size \le 0` no threads are created and future calls to + # :func:`thread_pool_request` will return `0` (unless + # :func:`thread_pool_set_size` has been called). slong thread_pool_get_size(thread_pool_t T) + # Return the number of threads in ``T``. int thread_pool_set_size(thread_pool_t T, slong new_size) + # If all threads in ``T`` are in the available state, resize ``T`` and return 1. + # Otherwise, return ``0``. - slong thread_pool_request(thread_pool_t T, - thread_pool_handle * out, slong requested) + slong thread_pool_request(thread_pool_t T, thread_pool_handle * out, slong requested) + # Put at most ``requested`` threads in the unavailable state and return + # their handles. The handles are written to ``out`` and the number of + # handles written is returned. These threads must be released by a call to + # ``thread_pool_give_back``. - void thread_pool_wake(thread_pool_t T, thread_pool_handle i, - int max_workers, void (*f)(void*), void * a) + void thread_pool_wake(thread_pool_t T, thread_pool_handle i, int max_workers, void (*f)(void*), void * a) + # Wake up a sleeping thread ``i`` and have it work on ``f(a)``. The thread + # being woken will be allowed to start ``max_workers`` additional worker + # threads. Usually this value should be set to ``0``. void thread_pool_wait(thread_pool_t T, thread_pool_handle i) + # Wait for thread ``i`` to finish working and go back to sleep. void thread_pool_give_back(thread_pool_t T, thread_pool_handle i) + # Put thread ``i`` back in the available state. This thread should be sleeping + # when this function is called. void thread_pool_clear(thread_pool_t T) - + # Release any resources used by ``T``. All threads should be given back before + # this function is called. diff --git a/src/sage/libs/flint/types.pxd b/src/sage/libs/flint/types.pxd index 4b85230ce5b..b9f5f9f11df 100644 --- a/src/sage/libs/flint/types.pxd +++ b/src/sage/libs/flint/types.pxd @@ -173,6 +173,10 @@ cdef extern from "flint_wrap.h": # flint/flint.h + ctypedef struct flint_rand_s: + pass + ctypedef flint_rand_s flint_rand_t[1] + ctypedef void* flint_rand_t cdef long FLINT_BITS cdef long FLINT_D_BITS @@ -535,6 +539,31 @@ cdef extern from "flint_wrap.h": ctypedef padic_poly_t qadic_t + # flint/qsieve.h + ctypedef struct prime_t: + pass + + ctypedef struct fac_t: + pass + + ctypedef struct la_col_t: + pass + + ctypedef struct hash_t: + pass + + ctypedef struct relation_t: + pass + + ctypedef struct qs_poly_s: + pass + ctypedef qs_poly_s qs_poly_t[1] + + ctypedef struct qs_s: + pass + ctypedef qs_s qs_t[1]; + + # flint/thread_pool.h ctypedef struct thread_pool_entry_struct: pass @@ -552,3 +581,93 @@ cdef extern from "flint_wrap.h": ctypedef struct bernoulli_rev_struct: pass ctypedef bernoulli_rev_struct bernoulli_rev_t[1] + + + # flint/nf.h + ctypedef struct nf_struct: + pass + ctypedef nf_struct nf_t[1] + + + # flint/nf_elem.h + ctypedef struct lnf_elem_struct: + pass + ctypedef lnf_elem_struct lnf_elem_t[1] + + ctypedef struct qnf_elem_struct: + pass + ctypedef qnf_elem_struct qnf_elem_t[1] + + ctypedef union nf_elem_struct: + fmpq_poly_t elem + lnf_elem_t lelem + qnf_elem_t qelem + ctypedef nf_elem_struct nf_elem_t[1] + + + # flint/ca.h + ctypedef union ca_elem_struct: + fmpq q + nf_elem_struct nf + fmpz_mpoly_q_struct * mpoly_q + + ctypedef struct ca_struct: + ulong field + ca_elem_struct elem + + ctypedef ca_struct ca_t[1] + ctypedef ca_struct * ca_ptr + ctypedef const ca_struct * ca_srcptr + + ctypedef struct ca_ext_qqbar: + pass + + ctypedef struct ca_ext_func_data: + pass + + ctypedef struct ca_ext_struct: + pass + + ctypedef ca_ext_struct ca_ext_t[1] + ctypedef ca_ext_struct * ca_ext_ptr + ctypedef const ca_ext_struct * ca_ext_srcptr + + ctypedef struct ca_ext_cache_struct: + pass + + ctypedef ca_ext_cache_struct ca_ext_cache_t[1] + + ctypedef struct ca_field_struct: + pass + + ctypedef ca_field_struct ca_field_t[1] + ctypedef ca_field_struct * ca_field_ptr + ctypedef const ca_field_struct * ca_field_srcptr + + ctypedef struct ca_field_cache_struct: + pass + + ctypedef ca_field_cache_struct ca_field_cache_t[1]; + + cdef enum: + CA_OPT_VERBOSE + CA_OPT_PRINT_FLAGS + CA_OPT_MPOLY_ORD + CA_OPT_PREC_LIMIT + CA_OPT_QQBAR_DEG_LIMIT + CA_OPT_LOW_PREC + CA_OPT_SMOOTH_LIMIT + CA_OPT_LLL_PREC + CA_OPT_POW_LIMIT + CA_OPT_USE_GROEBNER + CA_OPT_GROEBNER_LENGTH_LIMIT + CA_OPT_GROEBNER_POLY_LENGTH_LIMIT + CA_OPT_GROEBNER_POLY_BITS_LIMIT + CA_OPT_VIETA_LIMIT + CA_OPT_TRIG_FORM + CA_OPT_NUM_OPTIONS + + ctypedef struct ca_ctx_struct: + pass + + ctypedef ca_ctx_struct ca_ctx_t[1] diff --git a/src/sage/libs/flint/ulong_extras.pxd b/src/sage/libs/flint/ulong_extras.pxd index e9a73640a98..d5c4e444be0 100644 --- a/src/sage/libs/flint/ulong_extras.pxd +++ b/src/sage/libs/flint/ulong_extras.pxd @@ -12,7 +12,7 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - unsigned long n_randlimb(flint_rand_t state) + ulong n_randlimb(flint_rand_t state) # Returns a uniformly pseudo random limb. # The algorithm generates two random half limbs `s_j`, `j = 0, 1`, # by iterating respectively `v_{i+1} = (v_i a + b) \bmod{p_j}` for @@ -21,31 +21,31 @@ cdef extern from "flint_wrap.h": # and ``p_0 = nextprime(2^16)`` on a 32-bit machine and # ``p_1 = nextprime(p_0)``. - unsigned long n_randbits(flint_rand_t state, unsigned int bits) + ulong n_randbits(flint_rand_t state, unsigned int bits) # Returns a uniformly pseudo random number with the given number of # bits. The most significant bit is always set, unless zero is passed, # in which case zero is returned. - unsigned long n_randtest_bits(flint_rand_t state, int bits) + ulong n_randtest_bits(flint_rand_t state, int bits) # Returns a uniformly pseudo random number with the given number of # bits. The most significant bit is always set, unless zero is passed, # in which case zero is returned. The probability of a value with a # sparse binary representation being returned is increased. This # function is intended for use in test code. - unsigned long n_randint(flint_rand_t state, unsigned long limit) + ulong n_randint(flint_rand_t state, ulong limit) # Returns a uniformly pseudo random number up to but not including # the given limit. If zero is passed as a parameter, an entire random # limb is returned. - unsigned long n_urandint(flint_rand_t state, unsigned long limit) + ulong n_urandint(flint_rand_t state, ulong limit) # Returns a uniformly pseudo random number up to but not including # the given limit. If zero is passed as a parameter, an entire # random limb is returned. This function provides somewhat better # randomness as compared to :func:`n_randint`, especially for larger # values of limit. - unsigned long n_randtest(flint_rand_t state) + ulong n_randtest(flint_rand_t state) # Returns a pseudo random number with a random number of bits, # from `0` to ``FLINT_BITS``. The probability of the special # values `0`, `1`, ``COEFF_MAX`` and ``WORD_MAX`` is increased @@ -53,50 +53,50 @@ cdef extern from "flint_wrap.h": # This random function is mainly used for testing purposes. # This function is intended for use in test code. - unsigned long n_randtest_not_zero(flint_rand_t state) + ulong n_randtest_not_zero(flint_rand_t state) # As for :func:`n_randtest`, but does not return `0`. # This function is intended for use in test code. - unsigned long n_randprime(flint_rand_t state, unsigned long bits, int proved) + ulong n_randprime(flint_rand_t state, ulong bits, int proved) # Returns a random prime number ``(proved = 1)`` or probable prime # ``(proved = 0)`` # with ``bits`` bits, where ``bits`` must be at least 2 and # at most ``FLINT_BITS``. - unsigned long n_randtest_prime(flint_rand_t state, int proved) + ulong n_randtest_prime(flint_rand_t state, int proved) # Returns a random prime number ``(proved = 1)`` or probable # prime ``(proved = 0)`` # with size randomly chosen between 2 and ``FLINT_BITS`` bits. # This function is intended for use in test code. - unsigned long n_pow(unsigned long n, unsigned long exp) + ulong n_pow(ulong n, ulong exp) # Returns ``n^exp``. No checking is done for overflow. The exponent # may be zero. We define `0^0 = 1`. # The algorithm simply uses a for loop. Repeated squaring is # unlikely to speed up this algorithm. - unsigned long n_flog(unsigned long n, unsigned long b) + ulong n_flog(ulong n, ulong b) # Returns `\lfloor\log_b n\rfloor`. # Assumes that `n \geq 1` and `b \geq 2`. - unsigned long n_clog(unsigned long n, unsigned long b) + ulong n_clog(ulong n, ulong b) # Returns `\lceil\log_b n\rceil`. # Assumes that `n \geq 1` and `b \geq 2`. - unsigned long n_clog_2exp(unsigned long n, unsigned long b) + ulong n_clog_2exp(ulong n, ulong b) # Returns `\lceil\log_b 2^n\rceil`. # Assumes that `b \geq 2`. - unsigned long n_revbin(unsigned long n, unsigned long b) + ulong n_revbin(ulong n, ulong b) # Returns the binary reverse of `n`, assuming it is `b` bits in length, # e.g. ``n_revbin(10110, 6)`` will return ``110100``. - int n_sizeinbase(unsigned long n, int base) + int n_sizeinbase(ulong n, int base) # Returns the exact number of digits needed to represent `n` as a # string in base ``base`` assumed to be between 2 and 36. # Returns 1 when `n = 0`. - unsigned long n_preinvert_limb_prenorm(unsigned long n) + ulong n_preinvert_limb_prenorm(ulong n) # Computes an approximate inverse ``invxl`` of the limb ``xl``, # with an implicit leading~`1`. More formally it computes:: # invxl = (B^2 - B*x - 1)/x = (B^2 - 1)/x - B @@ -119,19 +119,19 @@ cdef extern from "flint_wrap.h": # then from the theorem, we have `0 \leq n - q_1 d < 3 d`, i.e. the # quotient is out by at most `2` and is always either correct or too small. - unsigned long n_preinvert_limb(unsigned long n) + ulong n_preinvert_limb(ulong n) # Returns a precomputed inverse of `n`, as defined in [GraMol2010]_. # This precomputed inverse can be used with all of the functions that # take a precomputed inverse whose names are suffixed by ``_preinv``. # We require `n > 0`. - double n_precompute_inverse(unsigned long n) + double n_precompute_inverse(ulong n) # Returns a precomputed inverse of `n` with double precision value `1/n`. # This precomputed inverse can be used with all of the functions that # take a precomputed inverse whose names are suffixed by ``_precomp``. # We require `n > 0`. - unsigned long n_mod_precomp(unsigned long a, unsigned long n, double ninv) + ulong n_mod_precomp(ulong a, ulong n, double ninv) # Returns `a \bmod{n}` given a precomputed inverse of `n` computed # by :func:`n_precompute_inverse`. We require ``n < 2^FLINT_D_BITS`` # and ``a < 2^(FLINT_BITS-1)`` and `0 \leq a < n^2`. @@ -159,7 +159,7 @@ cdef extern from "flint_wrap.h": # subtracting 1 from the quotient. Then the quotient we have computed is # either exactly what we are after, or one too small. - unsigned long n_mod2_precomp(unsigned long a, unsigned long n, double ninv) + ulong n_mod2_precomp(ulong a, ulong n, double ninv) # Returns `a \bmod{n}` given a precomputed inverse of `n` computed by # :func:`n_precompute_inverse`. There are no restrictions on `a` or # on `n`. @@ -173,7 +173,7 @@ cdef extern from "flint_wrap.h": # negative or positive, so the quotient we compute may be one # out in either direction. - unsigned long n_divrem2_preinv(unsigned long * q, unsigned long a, unsigned long n, unsigned long ninv) + ulong n_divrem2_preinv(ulong * q, ulong a, ulong n, ulong ninv) # Returns `a \bmod{n}` and sets `q` to the quotient of `a` by `n`, given a # precomputed inverse of `n` computed by :func:`n_preinvert_limb()`. There are # no restrictions on `a` and the only restriction on `n` is that it be @@ -182,7 +182,7 @@ cdef extern from "flint_wrap.h": # `n` is normalised and `a` is shifted into two limbs to compensate. Then # their algorithm is applied verbatim and the remainder shifted back. - unsigned long n_div2_preinv(unsigned long a, unsigned long n, unsigned long ninv) + ulong n_div2_preinv(ulong a, ulong n, ulong ninv) # Returns the Euclidean quotient of `a` by `n` given a precomputed inverse of # `n` computed by :func:`n_preinvert_limb`. There are no restrictions on `a` # and the only restriction on `n` is that it be nonzero. @@ -190,7 +190,7 @@ cdef extern from "flint_wrap.h": # `n` is normalised and `a` is shifted into two limbs to compensate. Then # their algorithm is applied verbatim. - unsigned long n_mod2_preinv(unsigned long a, unsigned long n, unsigned long ninv) + ulong n_mod2_preinv(ulong a, ulong n, ulong ninv) # Returns `a \bmod{n}` given a precomputed inverse of `n` computed by # :func:`n_preinvert_limb()`. There are no restrictions on `a` and the only # restriction on `n` is that it be nonzero. @@ -198,7 +198,7 @@ cdef extern from "flint_wrap.h": # `n` is normalised and `a` is shifted into two limbs to compensate. Then # their algorithm is applied verbatim and the result shifted back. - unsigned long n_divrem2_precomp(unsigned long * q, unsigned long a, unsigned long n, double npre) + ulong n_divrem2_precomp(ulong * q, ulong a, ulong n, double npre) # Returns `a \bmod{n}` given a precomputed inverse of `n` computed by # :func:`n_precompute_inverse` and sets `q` to the quotient. There # are no restrictions on `a` or on `n`. @@ -207,7 +207,7 @@ cdef extern from "flint_wrap.h": # cases to deal with the case where `a` is already reduced modulo # `n` and where `n` is `64` bits and `a` is not reduced modulo `n`. - unsigned long n_ll_mod_preinv(unsigned long a_hi, unsigned long a_lo, unsigned long n, unsigned long ninv) + ulong n_ll_mod_preinv(ulong a_hi, ulong a_lo, ulong n, ulong ninv) # Returns `a \bmod{n}` given a precomputed inverse of `n` computed by # :func:`n_preinvert_limb`. There are no restrictions on `a`, which # will be two limbs ``(a_hi, a_lo)``, or on `n`. @@ -218,7 +218,7 @@ cdef extern from "flint_wrap.h": # :func:`n_mod2_preinv` and then the algorithm of Granlund and # Möller [GraMol2010]_ is used again to reduce modulo `n`. - unsigned long n_lll_mod_preinv(unsigned long a_hi, unsigned long a_mi, unsigned long a_lo, unsigned long n, unsigned long ninv) + ulong n_lll_mod_preinv(ulong a_hi, ulong a_mi, ulong a_lo, ulong n, ulong ninv) # Returns `a \bmod{n}`, where `a` has three limbs ``(a_hi, a_mi, a_lo)``, # given a precomputed inverse of `n` computed by :func:`n_preinvert_limb`. # It is assumed that ``a_hi`` is reduced modulo `n`. There are no @@ -227,7 +227,7 @@ cdef extern from "flint_wrap.h": # Möller [GraMol2010]_ to first reduce the top two limbs # modulo `n`, then does the same on the bottom two limbs. - unsigned long n_mulmod_precomp(unsigned long a, unsigned long b, unsigned long n, double ninv) + ulong n_mulmod_precomp(ulong a, ulong b, ulong n, double ninv) # Returns `a b \bmod{n}` given a precomputed inverse of `n` # computed by :func:`n_precompute_inverse`. We require # ``n < 2^FLINT_D_BITS`` and `0 \leq a, b < n`. @@ -247,19 +247,19 @@ cdef extern from "flint_wrap.h": # computed integer quotient is at most two above and one below the quotient # we are after. - unsigned long n_mulmod2_preinv(unsigned long a, unsigned long b, unsigned long n, unsigned long ninv) + ulong n_mulmod2_preinv(ulong a, ulong b, ulong n, ulong ninv) # Returns `a b \bmod{n}` given a precomputed inverse of `n` computed by # :func:`n_preinvert_limb`. There are no restrictions on `a`, `b` or # on `n`. This is implemented by multiplying using :func:`umul_ppmm` and # then reducing using :func:`n_ll_mod_preinv`. - unsigned long n_mulmod2(unsigned long a, unsigned long b, unsigned long n) + ulong n_mulmod2(ulong a, ulong b, ulong n) # Returns `a b \bmod{n}`. There are no restrictions on `a`, `b` or # on `n`. This is implemented by multiplying using :func:`umul_ppmm` and # then reducing using :func:`n_ll_mod_preinv` after computing a precomputed # inverse. - unsigned long n_mulmod_preinv(unsigned long a, unsigned long b, unsigned long n, unsigned long ninv, unsigned long norm) + ulong n_mulmod_preinv(ulong a, ulong b, ulong n, ulong ninv, ulong norm) # Returns `a b \pmod{n}` given a precomputed inverse of `n` computed by # :func:`n_preinvert_limb`, assuming `a` and `b` are reduced modulo `n` # and `n` is normalised, i.e. with most significant bit set. There are @@ -272,12 +272,12 @@ cdef extern from "flint_wrap.h": # reducing it. # The algorithm used is that of Granlund and Möller [GraMol2010]_. - unsigned long n_gcd(unsigned long x, unsigned long y) + ulong n_gcd(ulong x, ulong y) # Returns the greatest common divisor `g` of `x` and `y`. No assumptions # are made about the values `x` and `y`. # This function wraps GMP's ``mpn_gcd_1``. - unsigned long n_gcdinv(unsigned long * a, unsigned long x, unsigned long y) + ulong n_gcdinv(ulong * a, ulong x, ulong y) # Returns the greatest common divisor `g` of `x` and `y` and computes # `a` such that `0 \leq a < y` and `a x = \gcd(x, y) \bmod{y}`, when # this is defined. We require `x < y`. @@ -286,7 +286,7 @@ cdef extern from "flint_wrap.h": # This is merely an adaption of the extended Euclidean algorithm # computing just one cofactor and reducing it modulo `y`. - unsigned long n_xgcd(unsigned long * a, unsigned long * b, unsigned long x, unsigned long y) + ulong n_xgcd(ulong * a, ulong * b, ulong x, ulong y) # Returns the greatest common divisor `g` of `x` and `y` and unsigned # values `a` and `b` such that `a x - b y = g`. We require `x \geq y`. # We claim that computing the extended greatest common divisor via the @@ -305,25 +305,25 @@ cdef extern from "flint_wrap.h": # See the documentation of :func:`n_gcd` for a description of the # branching in the algorithm, which is faster than using division. - int n_jacobi(mp_limb_signed_t x, unsigned long y) + int n_jacobi(mp_limb_signed_t x, ulong y) # Computes the Jacobi symbol `\left(\frac{x}{y}\right)` for any `x` and odd `y`. - int n_jacobi_unsigned(unsigned long x, unsigned long y) + int n_jacobi_unsigned(ulong x, ulong y) # Computes the Jacobi symbol, allowing `x` to go up to a full limb. - unsigned long n_addmod(unsigned long a, unsigned long b, unsigned long n) + ulong n_addmod(ulong a, ulong b, ulong n) # Returns `(a + b) \bmod{n}`. - unsigned long n_submod(unsigned long a, unsigned long b, unsigned long n) + ulong n_submod(ulong a, ulong b, ulong n) # Returns `(a - b) \bmod{n}`. - unsigned long n_invmod(unsigned long x, unsigned long y) + ulong n_invmod(ulong x, ulong y) # Returns the inverse of `x` modulo `y`, if it exists. Otherwise an exception # is thrown. # This is merely an adaption of the extended Euclidean algorithm # with appropriate normalisation. - unsigned long n_powmod_precomp(unsigned long a, mp_limb_signed_t exp, unsigned long n, double npre) + ulong n_powmod_precomp(ulong a, mp_limb_signed_t exp, ulong n, double npre) # Returns ``a^exp`` modulo `n` given a precomputed inverse of `n` # computed by :func:`n_precompute_inverse`. We require `n < 2^{53}` # and `0 \leq a < n`. There are no restrictions on ``exp``, i.e. @@ -331,7 +331,7 @@ cdef extern from "flint_wrap.h": # This is implemented as a standard binary powering algorithm using # repeated squaring and reducing modulo `n` at each step. - unsigned long n_powmod_ui_precomp(unsigned long a, unsigned long exp, unsigned long n, double npre) + ulong n_powmod_ui_precomp(ulong a, ulong exp, ulong n, double npre) # Returns ``a^exp`` modulo `n` given a precomputed inverse of `n` # computed by :func:`n_precompute_inverse`. We require `n < 2^{53}` # and `0 \leq a < n`. The exponent ``exp`` is unsigned and so @@ -339,14 +339,14 @@ cdef extern from "flint_wrap.h": # This is implemented as a standard binary powering algorithm using # repeated squaring and reducing modulo `n` at each step. - unsigned long n_powmod(unsigned long a, mp_limb_signed_t exp, unsigned long n) + ulong n_powmod(ulong a, mp_limb_signed_t exp, ulong n) # Returns ``a^exp`` modulo `n`. We require ``n < 2^FLINT_D_BITS`` # and `0 \leq a < n`. There are no restrictions on ``exp``, i.e. # it can be negative. # This is implemented by precomputing an inverse and calling the # ``precomp`` version of this function. - unsigned long n_powmod2_preinv(unsigned long a, mp_limb_signed_t exp, unsigned long n, unsigned long ninv) + ulong n_powmod2_preinv(ulong a, mp_limb_signed_t exp, ulong n, ulong ninv) # Returns ``(a^exp) % n`` given a precomputed inverse of `n` computed # by :func:`n_preinvert_limb`. We require `0 \leq a < n`, but there are no # restrictions on `n` or on ``exp``, i.e. it can be negative. @@ -355,7 +355,7 @@ cdef extern from "flint_wrap.h": # If ``exp`` is negative but `a` is not invertible modulo `n`, an # exception is raised. - unsigned long n_powmod2(unsigned long a, mp_limb_signed_t exp, unsigned long n) + ulong n_powmod2(ulong a, mp_limb_signed_t exp, ulong n) # Returns ``(a^exp) % n``. We require `0 \leq a < n`, but there are # no restrictions on `n` or on ``exp``, i.e. it can be negative. # This is implemented by precomputing an inverse limb and calling the @@ -363,7 +363,7 @@ cdef extern from "flint_wrap.h": # If ``exp`` is negative but `a` is not invertible modulo `n`, an # exception is raised. - unsigned long n_powmod2_ui_preinv(unsigned long a, unsigned long exp, unsigned long n, unsigned long ninv) + ulong n_powmod2_ui_preinv(ulong a, ulong exp, ulong n, ulong ninv) # Returns ``(a^exp) % n`` given a precomputed inverse of `n` computed # by :func:`n_preinvert_limb`. We require `0 \leq a < n`, but there are no # restrictions on `n`. The exponent ``exp`` is unsigned and so can be @@ -371,14 +371,14 @@ cdef extern from "flint_wrap.h": # This is implemented as a standard binary powering algorithm using # repeated squaring and reducing modulo `n` at each step. - unsigned long n_powmod2_fmpz_preinv(unsigned long a, const fmpz_t exp, unsigned long n, unsigned long ninv) + ulong n_powmod2_fmpz_preinv(ulong a, const fmpz_t exp, ulong n, ulong ninv) # Returns ``(a^exp) % n`` given a precomputed inverse of `n` computed # by :func:`n_preinvert_limb`. We require `0 \leq a < n`, but there are no # restrictions on `n`. The exponent ``exp`` must not be negative. # This is implemented as a standard binary powering algorithm using # repeated squaring and reducing modulo `n` at each step. - unsigned long n_sqrtmod(unsigned long a, unsigned long p) + ulong n_sqrtmod(ulong a, ulong p) # If `p` is prime, compute a square root of `a` modulo `p` if `a` is a # quadratic residue modulo `p`, otherwise return `0`. # If `p` is not prime the result is with high probability `0`, indicating @@ -386,7 +386,7 @@ cdef extern from "flint_wrap.h": # result is meaningless. # Assumes that `a` is reduced modulo `p`. - long n_sqrtmod_2pow(unsigned long ** sqrt, unsigned long a, long exp) + slong n_sqrtmod_2pow(ulong ** sqrt, ulong a, slong exp) # Computes all the square roots of ``a`` modulo ``2^exp``. The roots # are stored in an array which is created and whose address is stored in # the location pointed to by ``sqrt``. The array of roots is allocated @@ -396,7 +396,7 @@ cdef extern from "flint_wrap.h": # returned by the function and the location ``sqrt`` points to is set to # NULL. - long n_sqrtmod_primepow(unsigned long ** sqrt, unsigned long a, unsigned long p, long exp) + slong n_sqrtmod_primepow(ulong ** sqrt, ulong a, ulong p, slong exp) # Computes all the square roots of ``a`` modulo ``p^exp``. The roots # are stored in an array which is created and whose address is stored in # the location pointed to by ``sqrt``. The array of roots is allocated @@ -406,7 +406,7 @@ cdef extern from "flint_wrap.h": # returned by the function and the location ``sqrt`` points to is set to # NULL. - long n_sqrtmodn(unsigned long ** sqrt, unsigned long a, n_factor_t * fac) + slong n_sqrtmodn(ulong ** sqrt, ulong a, n_factor_t * fac) # Computes all the square roots of ``a`` modulo ``m`` given the # factorisation of ``m`` in ``fac``. The roots are stored in an array # which is created and whose address is stored in the location pointed to by @@ -435,41 +435,41 @@ cdef extern from "flint_wrap.h": void n_primes_clear(n_primes_t it) # Clears memory allocated by the prime number iterator ``iter``. - unsigned long n_primes_next(n_primes_t it) + ulong n_primes_next(n_primes_t it) # Returns the next prime number and advances the state of ``iter``. # The first call returns 2. # Small primes are looked up from ``flint_small_primes``. # When this table is exhausted, primes are generated in blocks # by calling :func:`n_primes_sieve_range`. - void n_primes_jump_after(n_primes_t it, unsigned long n) + void n_primes_jump_after(n_primes_t it, ulong n) # Changes the state of ``iter`` to start generating primes # after `n` (excluding `n` itself). - void n_primes_extend_small(n_primes_t it, unsigned long bound) + void n_primes_extend_small(n_primes_t it, ulong bound) # Extends the table of small primes in ``iter`` to contain # at least two primes larger than or equal to ``bound``. - void n_primes_sieve_range(n_primes_t it, unsigned long a, unsigned long b) + void n_primes_sieve_range(n_primes_t it, ulong a, ulong b) # Sets the block endpoints of ``iter`` to the smallest and # largest odd numbers between `a` and `b` inclusive, and # sieves to mark all odd primes in this range. # The iterator state is changed to point to the first # number in the sieved range. - void n_compute_primes(unsigned long num_primes) + void n_compute_primes(ulong num_primes) # Precomputes at least ``num_primes`` primes and their ``double`` # precomputed inverses and stores them in an internal cache. # Assuming that FLINT has been built with support for thread-local storage, # each thread has its own cache. - const unsigned long * n_primes_arr_readonly(unsigned long num_primes) + const ulong * n_primes_arr_readonly(ulong num_primes) # Returns a pointer to a read-only array of the first ``num_primes`` # prime numbers. The computed primes are cached for repeated calls. # The pointer is valid until the user calls :func:`n_cleanup_primes` # in the same thread. - const double * n_prime_inverses_arr_readonly(unsigned long n) + const double * n_prime_inverses_arr_readonly(ulong n) # Returns a pointer to a read-only array of inverses of the first # ``num_primes`` prime numbers. The computed primes are cached for # repeated calls. The pointer is valid until the user calls @@ -480,19 +480,19 @@ cdef extern from "flint_wrap.h": # This will invalidate any pointers returned by # :func:`n_primes_arr_readonly` or :func:`n_prime_inverses_arr_readonly`. - unsigned long n_nextprime(unsigned long n, int proved) + ulong n_nextprime(ulong n, int proved) # Returns the next prime after `n`. Assumes the result will fit in an # ``ulong``. If proved is `0`, i.e. false, the prime is not # proven prime, otherwise it is. - unsigned long n_prime_pi(unsigned long n) + ulong n_prime_pi(ulong n) # Returns the value of the prime counting function `\pi(n)`, i.e. the # number of primes less than or equal to `n`. The invariant # ``n_prime_pi(n_nth_prime(n)) == n``. # Currently, this function simply extends the table of cached primes up to # an upper limit and then performs a binary search. - void n_prime_pi_bounds(unsigned long *lo, unsigned long *hi, unsigned long n) + void n_prime_pi_bounds(ulong *lo, ulong *hi, ulong n) # Calculates lower and upper bounds for the value of the prime counting # function ``lo <= pi(n) <= hi``. If ``lo`` and ``hi`` point to # the same location, the high value will be stored. @@ -505,13 +505,13 @@ cdef extern from "flint_wrap.h": # approximation to `\ln n`, taking care to use a value too # small or too large to maintain the inequality. - unsigned long n_nth_prime(unsigned long n) + ulong n_nth_prime(ulong n) # Returns the `n`\th prime number `p_n`, using the mathematical indexing # convention `p_1 = 2, p_2 = 3, \dotsc`. # This function simply ensures that the table of cached primes is large # enough and then looks up the entry. - void n_nth_prime_bounds(unsigned long *lo, unsigned long *hi, unsigned long n) + void n_nth_prime_bounds(ulong *lo, ulong *hi, ulong n) # Calculates lower and upper bounds for the `n`\th prime number `p_n` , # ``lo <= p_n <= hi``. If ``lo`` and ``hi`` point to the same # location, the high value will be stored. Note that this function will @@ -528,14 +528,14 @@ cdef extern from "flint_wrap.h": # ``n_prime_pi_bounds()``, and estimate `\ln \ln n` to the nearest # integer; this function is nearly constant. - int n_is_oddprime_small(unsigned long n) + int n_is_oddprime_small(ulong n) # Returns `1` if `n` is an odd prime smaller than # ``FLINT_ODDPRIME_SMALL_CUTOFF``. Expects `n` # to be odd and smaller than the cutoff. # This function merely uses a lookup table with one bit allocated for each # odd number up to the cutoff. - int n_is_oddprime_binary(unsigned long n) + int n_is_oddprime_binary(ulong n) # This function performs a simple binary search through # the table of cached primes for `n`. If it exists in the array it returns # `1`, otherwise `0`. For the algorithm to operate correctly @@ -545,7 +545,7 @@ cdef extern from "flint_wrap.h": # refine our search with a simple binary algorithm, taking # the top or bottom of the current interval as necessary. - int n_is_prime_pocklington(unsigned long n, unsigned long iterations) + int n_is_prime_pocklington(ulong n, ulong iterations) # Tests if `n` is a prime using the Pocklington--Lehmer primality # test. If `1` is returned `n` has been proved prime. If `0` is returned # `n` is composite. However `-1` may be returned if nothing was proved @@ -565,7 +565,7 @@ cdef extern from "flint_wrap.h": # https://mathworld.wolfram.com/PocklingtonsTheorem.html # for a description of the algorithm. - int n_is_prime_pseudosquare(unsigned long n) + int n_is_prime_pseudosquare(ulong n) # Tests if `n` is a prime according to Theorem 2.7 [LukPatWil1996]_. # We first factor `N` using trial division up to some limit `B`. # In fact, the number of primes used in the trial factoring is at @@ -591,7 +591,7 @@ cdef extern from "flint_wrap.h": # composite prime. However in that case an error is printed, as # that would be of independent interest. - int n_is_prime(unsigned long n) + int n_is_prime(ulong n) # Tests if `n` is a prime. This first sieves for small prime factors, # then simply calls :func:`n_is_probabprime`. This has been checked # against the tables of Feitsma and Galway @@ -602,7 +602,7 @@ cdef extern from "flint_wrap.h": # primality. This is likely to be significantly slower for prime # inputs. - int n_is_strong_probabprime_precomp(unsigned long n, double npre, unsigned long a, unsigned long d) + int n_is_strong_probabprime_precomp(ulong n, double npre, ulong a, ulong d) # Tests if `n` is a strong probable prime to the base `a`. We # require that `d` is set to the largest odd factor of `n - 1` and # ``npre`` is a precomputed inverse of `n` computed with @@ -615,7 +615,7 @@ cdef extern from "flint_wrap.h": # A description of strong probable primes is given here: # https://mathworld.wolfram.com/StrongPseudoprime.html - int n_is_strong_probabprime2_preinv(unsigned long n, unsigned long ninv, unsigned long a, unsigned long d) + int n_is_strong_probabprime2_preinv(ulong n, ulong ninv, ulong a, ulong d) # Tests if `n` is a strong probable prime to the base `a`. We require # that `d` is set to the largest odd factor of `n - 1` and ``npre`` # is a precomputed inverse of `n` computed with :func:`n_preinvert_limb`. @@ -626,13 +626,13 @@ cdef extern from "flint_wrap.h": # A description of strong probable primes is given here: # https://mathworld.wolfram.com/StrongPseudoprime.html - int n_is_probabprime_fermat(unsigned long n, unsigned long i) + int n_is_probabprime_fermat(ulong n, ulong i) # Returns `1` if `n` is a base `i` Fermat probable prime. Requires # `1 < i < n` and that `i` does not divide `n`. # By Fermat's Little Theorem if `i^{n-1}` is not congruent to `1` # then `n` is not prime. - int n_is_probabprime_fibonacci(unsigned long n) + int n_is_probabprime_fibonacci(ulong n) # Let `F_j` be the `j`\th element of the Fibonacci sequence # `0, 1, 1, 2, 3, 5, \dotsc`, starting at `j = 0`. Then if `n` is prime # we have `F_{n - (n/5)} = 0 \pmod n`, where `(n/5)` is the Jacobi @@ -640,7 +640,7 @@ cdef extern from "flint_wrap.h": # For further details, see pp. 142 [CraPom2005]_. # We require that `n` is not divisible by `2` or `5`. - int n_is_probabprime_BPSW(unsigned long n) + int n_is_probabprime_BPSW(ulong n) # Implements a Baillie--Pomerance--Selfridge--Wagstaff probable primality # test. This is a variant of the usual BPSW test (which only uses strong # base-2 probable prime and Lucas-Selfridge tests, see Baillie and @@ -653,12 +653,12 @@ cdef extern from "flint_wrap.h": # Up to `2^{64}` the test we use has been checked against tables of # pseudoprimes. Thus it is a primality test up to this limit. - int n_is_probabprime_lucas(unsigned long n) + int n_is_probabprime_lucas(ulong n) # For details on Lucas pseudoprimes, see [pp. 143] [CraPom2005]_. # We implement a variant of the Lucas pseudoprime test similar to that # described by Baillie and Wagstaff [BaiWag1980]_. - int n_is_probabprime(unsigned long n) + int n_is_probabprime(ulong n) # Tests if `n` is a probable prime. Up to ``FLINT_ODDPRIME_SMALL_CUTOFF`` # this algorithm uses :func:`n_is_oddprime_small` which uses a lookup table. # Next it calls :func:`n_compute_primes` with the maximum table size and @@ -674,14 +674,14 @@ cdef extern from "flint_wrap.h": # and Galway and up to the accuracy of those tables, this is an exhaustive # check up to `2^{64}`, i.e. there are no counterexamples. - unsigned long n_CRT(unsigned long r1, unsigned long m1, unsigned long r2, unsigned long m2) + ulong n_CRT(ulong r1, ulong m1, ulong r2, ulong m2) # Use the Chinese Remainder Theorem to return the unique value # `0 \le x < M` congruent to `r_1` modulo `m_1` and `r_2` modulo `m_2`, # where `M = m_1 \times m_2` is assumed to fit a ulong. # It is assumed that `m_1` and `m_2` are positive integers greater # than `1` and coprime. It is assumed that `0 \le r_1 < m_1` and `0 \le r_2 < m_2`. - unsigned long n_sqrt(unsigned long a) + ulong n_sqrt(ulong a) # Computes the integer truncation of the square root of `a`. # The implementation uses a call to the IEEE floating point sqrt function. # The integer itself is represented by the nearest double and its square @@ -694,7 +694,7 @@ cdef extern from "flint_wrap.h": # precision float provided the square root itself can be represented # in a single float, i.e. for `a < 281474976710656 = 2^{46}`. - unsigned long n_sqrtrem(unsigned long * r, unsigned long a) + ulong n_sqrtrem(ulong * r, ulong a) # Computes the integer truncation of the square root of `a`. # The integer itself is represented by the nearest double and its square # root is computed to the nearest place. If `a` is one below a square, the @@ -709,14 +709,14 @@ cdef extern from "flint_wrap.h": # The remainder is computed by subtracting the square of the computed square # root from `a`. - int n_is_square(unsigned long x) + int n_is_square(ulong x) # Returns `1` if `x` is a square, otherwise `0`. # This code first checks if `x` is a square modulo `64`, # `63 = 3 \times 3 \times 7` and `65 = 5 \times 13`, using lookup tables, # and if so it then takes a square root and checks that the square of this # equals the original value. - int n_is_perfect_power235(unsigned long n) + int n_is_perfect_power235(ulong n) # Returns `1` if `n` is a perfect square, cube or fifth power. # This function uses a series of modular tests to reject most # non 235-powers. Each modular test returns a value from 0 to 7 @@ -729,12 +729,12 @@ cdef extern from "flint_wrap.h": # root can be taken, if indicated, to determine whether the power # of that root is exactly equal to `n`. - int n_is_perfect_power(unsigned long * root, unsigned long n) + int n_is_perfect_power(ulong * root, ulong n) # If `n = r^k`, return `k` and set ``root`` to `r`. Note that `0` and # `1` are considered squares. No guarantees are made about `r` or `k` # being the minimum possible value. - unsigned long n_rootrem(unsigned long* remainder, unsigned long n, unsigned long root) + ulong n_rootrem(ulong* remainder, ulong n, ulong root) # This function uses the Newton iteration method to calculate the nth root of # a number. # First approximation is calculated by an algorithm mentioned in this @@ -743,7 +743,7 @@ cdef extern from "flint_wrap.h": # Returns the integer part of ``n ^ 1/root``. Remainder is set as # ``n - base^root``. In case `n < 1` or ``root < 1``, `0` is returned. - unsigned long n_cbrt(unsigned long n) + ulong n_cbrt(ulong n) # This function returns the integer truncation of the cube root of `n`. # First approximation is calculated by an algorithm mentioned in this # article: https://en.wikipedia.org/wiki/Fast_inverse_square_root . @@ -754,16 +754,16 @@ cdef extern from "flint_wrap.h": # `x \leftarrow x - (x\cdot x\cdot x - a)\cdot x/(2\cdot x\cdot x\cdot x + a)` for getting a good estimate, # as mentioned in the paper by W. Kahan [Kahan1991]_ . - unsigned long n_cbrt_newton_iteration(unsigned long n) + ulong n_cbrt_newton_iteration(ulong n) # This function returns the integer truncation of the cube root of `n`. # Makes use of Newton iterations to get a close value, and then adjusts the # estimate so as to get the correct value. - unsigned long n_cbrt_binary_search(unsigned long n) + ulong n_cbrt_binary_search(ulong n) # This function returns the integer truncation of the cube root of `n`. # Uses binary search to get the correct value. - unsigned long n_cbrt_chebyshev_approx(unsigned long n) + ulong n_cbrt_chebyshev_approx(ulong n) # This function returns the integer truncation of the cube root of `n`. # The number is first expressed in the form ``x * 2^exp``. This ensures # `x` is in the range [0.5, 1]. Cube root of x is calculated using @@ -772,14 +772,14 @@ cdef extern from "flint_wrap.h": # https://mpmath.org, using the function chebyfit. x is multiplied # by ``2^exp`` and the cube root of 1, 2 or 4 (according to ``exp%3``). - unsigned long n_cbrtrem(unsigned long* remainder, unsigned long n) + ulong n_cbrtrem(ulong* remainder, ulong n) # This function returns the integer truncation of the cube root of `n`. # Remainder is set as `n` minus the cube of the value returned. void n_factor_init(n_factor_t * factors) # Initializes factors. - int n_remove(unsigned long * n, unsigned long p) + int n_remove(ulong * n, ulong p) # Removes the highest possible power of `p` from `n`, replacing # `n` with the quotient. The return value is the highest # power of `p` that divided `n`. Assumes `n` is not `0`. @@ -790,7 +790,7 @@ cdef extern from "flint_wrap.h": # proceeds down the power tree again removing powers of `p` # until none remain. - int n_remove2_precomp(unsigned long * n, unsigned long p, double ppre) + int n_remove2_precomp(ulong * n, ulong p, double ppre) # Removes the highest possible power of `p` from `n`, replacing # `n` with the quotient. The return value is the highest # power of `p` that divided `n`. Assumes `n` is not `0`. We require @@ -800,7 +800,7 @@ cdef extern from "flint_wrap.h": # `p` we make repeated use of :func:`n_divrem2_precomp` until division # by `p` is no longer possible. - void n_factor_insert(n_factor_t * factors, unsigned long p, unsigned long exp) + void n_factor_insert(n_factor_t * factors, ulong p, ulong exp) # Inserts the given prime power factor ``p^exp`` into # the ``n_factor_t`` ``factors``. See the documentation for # :func:`n_factor_trial` for a description of the ``n_factor_t`` type. @@ -811,7 +811,7 @@ cdef extern from "flint_wrap.h": # There is no test code for this function other than its use by # the various factoring functions, which have test code. - unsigned long n_factor_trial_range(n_factor_t * factors, unsigned long n, unsigned long start, unsigned long num_primes) + ulong n_factor_trial_range(n_factor_t * factors, ulong n, ulong start, ulong num_primes) # Trial factor `n` with the first ``num_primes`` primes, but # starting at the prime with index start (counting from zero). # One requires an initialised ``n_factor_t`` structure, but factors @@ -833,12 +833,12 @@ cdef extern from "flint_wrap.h": # :func:`n_compute_primes` are utilised with the :func:`n_remove2_precomp` # function. - unsigned long n_factor_trial(n_factor_t * factors, unsigned long n, unsigned long num_primes) + ulong n_factor_trial(n_factor_t * factors, ulong n, ulong num_primes) # This function calls :func:`n_factor_trial_range`, with the value of # `0` for ``start``. By default this adds factors to an already existing # ``n_factor_t`` or to a newly initialised one. - unsigned long n_factor_power235(unsigned long *exp, unsigned long n) + ulong n_factor_power235(ulong *exp, ulong n) # Returns `0` if `n` is not a perfect square, cube or fifth power. # Otherwise it returns the root and sets ``exp`` to either `2`, # `3` or `5` appropriately. @@ -853,18 +853,18 @@ cdef extern from "flint_wrap.h": # root can be taken, if indicated, to determine whether the power # of that root is exactly equal to `n`. - unsigned long n_factor_one_line(unsigned long n, unsigned long iters) + ulong n_factor_one_line(ulong n, ulong iters) # This implements Bill Hart's one line factoring algorithm [Har2012]_. # It is a variant of Fermat's algorithm which cycles through a large number # of multipliers instead of incrementing the square root. It is faster than # SQUFOF for `n` less than about `2^{40}`. - unsigned long n_factor_lehman(unsigned long n) + ulong n_factor_lehman(ulong n) # Lehman's factoring algorithm. Currently works up to `10^{16}`, but is # not particularly efficient and so is not used in the general factor # function. Always returns a factor of `n`. - unsigned long n_factor_SQUFOF(unsigned long n, unsigned long iters) + ulong n_factor_SQUFOF(ulong n, ulong iters) # Attempts to split `n` using the given number of iterations # of SQUFOF. Simply set ``iters`` to ``WORD(0)`` for maximum # persistence. @@ -879,7 +879,7 @@ cdef extern from "flint_wrap.h": # If SQUFOF fails to factor `n` we return `0`, however with # ``iters`` large enough this should never happen. - void n_factor(n_factor_t * factors, unsigned long n, int proved) + void n_factor(n_factor_t * factors, ulong n, int proved) # Factors `n` with no restrictions on `n`. If the prime factors are # required to be checked with a primality test, one may set # ``proved`` to `1`, otherwise set it to `0`, and they will only be @@ -906,7 +906,7 @@ cdef extern from "flint_wrap.h": # ``FLINT_FACTOR_SQUFOF_ITERS``. If that fails an error results and # the program aborts. However this should not happen in practice. - unsigned long n_factor_trial_partial(n_factor_t * factors, unsigned long n, unsigned long * prod, unsigned long num_primes, unsigned long limit) + ulong n_factor_trial_partial(n_factor_t * factors, ulong n, ulong * prod, ulong num_primes, ulong limit) # Attempts trial factoring of `n` with the first ``num_primes primes``, # but stops when the product of prime factors so far exceeds ``limit``. # One requires an initialised ``n_factor_t`` structure, but factors @@ -929,7 +929,7 @@ cdef extern from "flint_wrap.h": # :func:`n_compute_primes` are utilised with the :func:`n_remove2_precomp` # function. - unsigned long n_factor_partial(n_factor_t * factors, unsigned long n, unsigned long limit, int proved) + ulong n_factor_partial(n_factor_t * factors, ulong n, ulong limit, int proved) # Factors `n`, but stops when the product of prime factors so far # exceeds ``limit``. # One requires an initialised ``n_factor_t`` structure, but factors @@ -944,7 +944,7 @@ cdef extern from "flint_wrap.h": # The factors are proved prime if ``proved`` is `1`, otherwise # they are merely probably prime. - unsigned long n_factor_pp1(unsigned long n, unsigned long B1, unsigned long c) + ulong n_factor_pp1(ulong n, ulong B1, ulong c) # Factors `n` using Williams' `p + 1` factoring algorithm, with prime # limit set to `B1`. We require `c` to be set to a random value. Each # trial of the algorithm with a different value of `c` gives another @@ -955,7 +955,7 @@ cdef extern from "flint_wrap.h": # If the algorithm succeeds, it returns the factor, otherwise it # returns `0` or `1` (the trivial factors modulo `n`). - unsigned long n_factor_pp1_wrapper(unsigned long n) + ulong n_factor_pp1_wrapper(ulong n) # A simple wrapper around ``n_factor_pp1`` which works in the range # `31`-`64` bits. Below this point, trial factoring will always succeed. # This function mainly exists for ``n_factor`` and is tuned to minimise @@ -989,7 +989,7 @@ cdef extern from "flint_wrap.h": # is successful. In such a case, 1 is returned. Otherwise, 0 is returned. Factor # discovered is not necessarily prime. - int n_moebius_mu(unsigned long n) + int n_moebius_mu(ulong n) # Computes the Moebius function `\mu(n)`, which is defined as `\mu(n) = 0` # if `n` has a prime factor of multiplicity greater than `1`, `\mu(n) = -1` # if `n` has an odd number of distinct prime factors, and `\mu(n) = 1` if @@ -1001,28 +1001,28 @@ cdef extern from "flint_wrap.h": # For larger `n`, we first check if `n` is divisible by a small odd square # and otherwise call ``n_factor()`` and count the factors. - void n_moebius_mu_vec(int * mu, unsigned long len) + void n_moebius_mu_vec(int * mu, ulong len) # Computes `\mu(n)` for ``n = 0, 1, ..., len - 1``. This # is done by sieving over each prime in the range, flipping the sign # of `\mu(n)` for every multiple of a prime `p` and setting `\mu(n) = 0` # for every multiple of `p^2`. - int n_is_squarefree(unsigned long n) + int n_is_squarefree(ulong n) # Returns `0` if `n` is divisible by some perfect square, and `1` otherwise. # This simply amounts to testing whether `\mu(n) \neq 0`. As special # cases, `1` is considered squarefree and `0` is not considered squarefree. - unsigned long n_euler_phi(unsigned long n) + ulong n_euler_phi(ulong n) # Computes the Euler totient function `\phi(n)`, counting the number of # positive integers less than or equal to `n` that are coprime to `n`. - unsigned long n_factorial_fast_mod2_preinv(unsigned long n, unsigned long p, unsigned long pinv) + ulong n_factorial_fast_mod2_preinv(ulong n, ulong p, ulong pinv) # Returns `n! \bmod p` given a precomputed inverse of `p` as computed # by :func:`n_preinvert_limb`. `p` is not required to be a prime, but # no special optimisations are made for composite `p`. # Uses fast multipoint evaluation, running in about `O(n^{1/2})` time. - unsigned long n_factorial_mod2_preinv(unsigned long n, unsigned long p, unsigned long pinv) + ulong n_factorial_mod2_preinv(ulong n, ulong p, ulong pinv) # Returns `n! \bmod p` given a precomputed inverse of `p` as computed # by :func:`n_preinvert_limb`. `p` is not required to be a prime, but # no special optimisations are made for composite `p`. @@ -1030,15 +1030,15 @@ cdef extern from "flint_wrap.h": # if `n` is not too large, and calls the fast algorithm for extremely # large `n`. - unsigned long n_primitive_root_prime_prefactor(unsigned long p, n_factor_t * factors) + ulong n_primitive_root_prime_prefactor(ulong p, n_factor_t * factors) # Returns a primitive root for the multiplicative subgroup of `\mathbb{Z}/p\mathbb{Z}` # where `p` is prime given the factorisation (``factors``) of `p - 1`. - unsigned long n_primitive_root_prime(unsigned long p) + ulong n_primitive_root_prime(ulong p) # Returns a primitive root for the multiplicative subgroup of `\mathbb{Z}/p\mathbb{Z}` # where `p` is prime. - unsigned long n_discrete_log_bsgs(unsigned long b, unsigned long a, unsigned long n) + ulong n_discrete_log_bsgs(ulong b, ulong a, ulong n) # Returns the discrete logarithm of `b` with respect to `a` in the # multiplicative subgroup of `\mathbb{Z}/n\mathbb{Z}` when `\mathbb{Z}/n\mathbb{Z}` # is cyclic. That is, From d374dee959eec7bab8bc5d2db4a41227d954a72a Mon Sep 17 00:00:00 2001 From: Vincent Delecroix Date: Sat, 14 Oct 2023 09:20:02 +0200 Subject: [PATCH 10/41] adaptation of sage source code --- src/sage/algebras/quatalg/quaternion_algebra_element.pyx | 1 + src/sage/graphs/matchpoly.pyx | 2 ++ src/sage/libs/linbox/linbox_flint_interface.pyx | 3 ++- src/sage/libs/linkages/padics/fmpz_poly_unram.pxi | 2 ++ src/sage/libs/linkages/padics/relaxed/flint.pxi | 1 + src/sage/matrix/matrix_integer_sparse.pyx | 3 ++- src/sage/modular/modform/eis_series_cython.pyx | 2 +- src/sage/modular/modform/vm_basis.py | 2 +- src/sage/modular/modsym/apply.pyx | 1 + src/sage/rings/complex_arb.pyx | 2 +- src/sage/rings/polynomial/evaluation_flint.pyx | 2 ++ src/sage/rings/polynomial/polynomial_integer_dense_flint.pyx | 1 + src/sage/rings/polynomial/polynomial_rational_flint.pyx | 1 + src/sage/schemes/elliptic_curves/descent_two_isogeny.pyx | 1 + 14 files changed, 19 insertions(+), 5 deletions(-) diff --git a/src/sage/algebras/quatalg/quaternion_algebra_element.pyx b/src/sage/algebras/quatalg/quaternion_algebra_element.pyx index b4c5eed5b49..73e88f40d67 100644 --- a/src/sage/algebras/quatalg/quaternion_algebra_element.pyx +++ b/src/sage/algebras/quatalg/quaternion_algebra_element.pyx @@ -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 diff --git a/src/sage/graphs/matchpoly.pyx b/src/sage/graphs/matchpoly.pyx index 5d70faf40a1..861d05df8af 100644 --- a/src/sage/graphs/matchpoly.pyx +++ b/src/sage/graphs/matchpoly.pyx @@ -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') diff --git a/src/sage/libs/linbox/linbox_flint_interface.pyx b/src/sage/libs/linbox/linbox_flint_interface.pyx index 37a340c457f..ed3fa183032 100644 --- a/src/sage/libs/linbox/linbox_flint_interface.pyx +++ b/src/sage/libs/linbox/linbox_flint_interface.pyx @@ -37,7 +37,8 @@ from sage.libs.gmp.types cimport mpz_t from sage.libs.flint.types cimport fmpz_t from sage.libs.flint.fmpz cimport fmpz_get_mpz, fmpz_set_mpz from sage.libs.flint.fmpz_mat cimport fmpz_mat_entry, fmpz_mat_nrows, fmpz_mat_ncols -from sage.libs.flint.fmpz_poly cimport fmpz_poly_set_coeff_mpz, fmpz_poly_fit_length, _fmpz_poly_set_length +from sage.libs.flint.fmpz_poly cimport fmpz_poly_fit_length, _fmpz_poly_set_length +from sage.libs.flint.fmpz_poly_sage cimport fmpz_poly_set_coeff_mpz cimport sage.libs.linbox.givaro as givaro cimport sage.libs.linbox.linbox as linbox diff --git a/src/sage/libs/linkages/padics/fmpz_poly_unram.pxi b/src/sage/libs/linkages/padics/fmpz_poly_unram.pxi index afb9d191609..18f710fad36 100644 --- a/src/sage/libs/linkages/padics/fmpz_poly_unram.pxi +++ b/src/sage/libs/linkages/padics/fmpz_poly_unram.pxi @@ -32,6 +32,8 @@ from sage.rings.finite_rings.integer_mod_ring import Zmod from sage.libs.flint.fmpz cimport * from sage.libs.flint.fmpz_poly cimport * +from sage.libs.flint.fmpz_poly_sage cimport * + DEF CELEMENT_IS_PY_OBJECT = False diff --git a/src/sage/libs/linkages/padics/relaxed/flint.pxi b/src/sage/libs/linkages/padics/relaxed/flint.pxi index 3dab6ecbc30..a1cbdeedf81 100644 --- a/src/sage/libs/linkages/padics/relaxed/flint.pxi +++ b/src/sage/libs/linkages/padics/relaxed/flint.pxi @@ -19,6 +19,7 @@ AUTHOR: from sage.libs.flint.types cimport flint_rand_t from sage.libs.flint.fmpz cimport * from sage.libs.flint.fmpz_poly cimport * +from sage.libs.flint.fmpz_poly_sage cimport * cdef extern from "sage/libs/linkages/padics/relaxed/flint_helper.c": cdef void flint_randseed(flint_rand_t state, ulong seed1, ulong seed2) diff --git a/src/sage/matrix/matrix_integer_sparse.pyx b/src/sage/matrix/matrix_integer_sparse.pyx index 6c5c20dbc6b..979dbf50c4e 100644 --- a/src/sage/matrix/matrix_integer_sparse.pyx +++ b/src/sage/matrix/matrix_integer_sparse.pyx @@ -58,7 +58,8 @@ from sage.matrix.matrix cimport Matrix from sage.matrix.args cimport SparseEntry, MatrixArgs_init from sage.matrix.matrix_integer_dense cimport Matrix_integer_dense from sage.libs.flint.fmpz cimport fmpz_set_mpz, fmpz_get_mpz -from sage.libs.flint.fmpz_poly cimport fmpz_poly_fit_length, fmpz_poly_set_coeff_mpz, _fmpz_poly_set_length +from sage.libs.flint.fmpz_poly cimport fmpz_poly_fit_length, _fmpz_poly_set_length +from sage.libs.flint.fmpz_poly_sage cimport fmpz_poly_set_coeff_mpz from sage.libs.flint.fmpz_mat cimport fmpz_mat_entry from sage.matrix.matrix_modn_sparse cimport Matrix_modn_sparse diff --git a/src/sage/modular/modform/eis_series_cython.pyx b/src/sage/modular/modform/eis_series_cython.pyx index 29ba08039d7..fb8501622f6 100644 --- a/src/sage/modular/modform/eis_series_cython.pyx +++ b/src/sage/modular/modform/eis_series_cython.pyx @@ -12,7 +12,7 @@ from sage.rings.fast_arith cimport prime_range from cpython.list cimport PyList_GET_ITEM from sage.libs.flint.fmpz_poly cimport * from sage.libs.gmp.mpz cimport * -from sage.libs.flint.fmpz_poly cimport Fmpz_poly +from sage.libs.flint.fmpz_poly_sage cimport Fmpz_poly, fmpz_poly_set_coeff_mpz, fmpz_poly_scalar_mul_mpz cpdef Ek_ZZ(int k, int prec=10) noexcept: """ diff --git a/src/sage/modular/modform/vm_basis.py b/src/sage/modular/modform/vm_basis.py index e79408d6f93..38e81409287 100644 --- a/src/sage/modular/modform/vm_basis.py +++ b/src/sage/modular/modform/vm_basis.py @@ -30,7 +30,7 @@ import math -from sage.libs.flint.fmpz_poly import Fmpz_poly +from sage.libs.flint.fmpz_poly_sage import Fmpz_poly from sage.misc.verbose import verbose from sage.rings.big_oh import O as bigO from sage.rings.finite_rings.integer_mod_ring import Integers diff --git a/src/sage/modular/modsym/apply.pyx b/src/sage/modular/modsym/apply.pyx index 40488868b37..4e253c2f805 100644 --- a/src/sage/modular/modsym/apply.pyx +++ b/src/sage/modular/modsym/apply.pyx @@ -17,6 +17,7 @@ Monomial expansion of `(aX + bY)^i (cX + dY)^{j-i}` from sage.ext.stdsage cimport PY_NEW from sage.libs.flint.fmpz_poly cimport * +from sage.libs.flint.fmpz_poly_sage cimport * from sage.rings.integer cimport Integer cdef class Apply: diff --git a/src/sage/rings/complex_arb.pyx b/src/sage/rings/complex_arb.pyx index 0786de7fc81..b7384f628dc 100644 --- a/src/sage/rings/complex_arb.pyx +++ b/src/sage/rings/complex_arb.pyx @@ -161,7 +161,7 @@ from cpython.complex cimport PyComplex_FromDoubles from sage.ext.stdsage cimport PY_NEW from sage.libs.mpfr cimport MPFR_RNDU, MPFR_RNDD, MPFR_PREC_MIN, mpfr_get_d_2exp -from sage.libs.arb.types cimport ARF_RND_NEAR +from sage.libs.arb.types cimport ARF_RND_NEAR, arf_t, mag_t from sage.libs.arb.arb cimport * from sage.libs.arb.acb cimport * from sage.libs.arb.acb_calc cimport * diff --git a/src/sage/rings/polynomial/evaluation_flint.pyx b/src/sage/rings/polynomial/evaluation_flint.pyx index 94204c0556b..fef3bddecb5 100644 --- a/src/sage/rings/polynomial/evaluation_flint.pyx +++ b/src/sage/rings/polynomial/evaluation_flint.pyx @@ -33,6 +33,8 @@ from sage.libs.gmp.mpz cimport * from sage.libs.gmp.mpq cimport * from sage.libs.flint.fmpz cimport * from sage.libs.flint.fmpz_poly cimport * +from sage.libs.flint.fmpz_poly_sage cimport * + cdef fmpz_poly_evaluation_mpfr(mpfr_t res, const fmpz_poly_t poly, const mpfr_t a) noexcept: cdef mpz_t c diff --git a/src/sage/rings/polynomial/polynomial_integer_dense_flint.pyx b/src/sage/rings/polynomial/polynomial_integer_dense_flint.pyx index c9d196ff893..fc0e2431b9c 100644 --- a/src/sage/rings/polynomial/polynomial_integer_dense_flint.pyx +++ b/src/sage/rings/polynomial/polynomial_integer_dense_flint.pyx @@ -64,6 +64,7 @@ from sage.arith.functions import lcm from sage.libs.arb.arb_fmpz_poly cimport arb_fmpz_poly_evaluate_arb, arb_fmpz_poly_evaluate_acb 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.types cimport ulong, fmpz_poly_t from sage.libs.flint.ntl_interface cimport fmpz_set_ZZ, fmpz_poly_set_ZZX, fmpz_poly_get_ZZX from sage.libs.ntl.ZZX cimport * diff --git a/src/sage/rings/polynomial/polynomial_rational_flint.pyx b/src/sage/rings/polynomial/polynomial_rational_flint.pyx index d99f0d3b98c..c83bd1a2d67 100644 --- a/src/sage/rings/polynomial/polynomial_rational_flint.pyx +++ b/src/sage/rings/polynomial/polynomial_rational_flint.pyx @@ -37,6 +37,7 @@ from sage.libs.flint.fmpz cimport * from sage.libs.flint.fmpq cimport * from sage.libs.flint.fmpz_poly cimport * from sage.libs.flint.fmpq_poly cimport * +from sage.libs.flint.fmpq_poly_sage cimport * from sage.interfaces.singular import singular as singular_default diff --git a/src/sage/schemes/elliptic_curves/descent_two_isogeny.pyx b/src/sage/schemes/elliptic_curves/descent_two_isogeny.pyx index 2f65456c2ad..01626ef03ea 100644 --- a/src/sage/schemes/elliptic_curves/descent_two_isogeny.pyx +++ b/src/sage/schemes/elliptic_curves/descent_two_isogeny.pyx @@ -25,6 +25,7 @@ import sage.libs.ntl.all as ntl from sage.rings.integer cimport Integer from sage.libs.gmp.mpz cimport * from sage.libs.flint.fmpz_poly cimport * +from sage.libs.flint.fmpz_poly_sage cimport * from sage.libs.flint.nmod_poly cimport * from sage.libs.flint.nmod_poly_factor cimport * from sage.libs.flint.ulong_extras cimport * From 536393b62383a506bc60997e1f0727a687051dc4 Mon Sep 17 00:00:00 2001 From: Vincent Delecroix Date: Sat, 14 Oct 2023 10:26:04 +0200 Subject: [PATCH 11/41] make linter happier --- src/sage/libs/flint/arb.pxd | 4 ++-- src/sage/libs/flint/arb_hypgeom.pxd | 2 +- src/sage/libs/flint/arb_poly.pxd | 2 +- src/sage/libs/flint/fmpz.pxd | 2 +- src/sage/libs/flint/gr_special.pxd | 4 ++-- src/sage/libs/flint/mag.pxd | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/sage/libs/flint/arb.pxd b/src/sage/libs/flint/arb.pxd index a18e6fca1fb..a67268148b8 100644 --- a/src/sage/libs/flint/arb.pxd +++ b/src/sage/libs/flint/arb.pxd @@ -1023,8 +1023,8 @@ cdef extern from "flint_wrap.h": void arb_bin_ui(arb_t z, const arb_t n, ulong k, slong prec) void arb_bin_uiui(arb_t z, ulong n, ulong k, slong prec) - # Computes the binomial coefficient `z = {n \choose k}`, via the - # rising factorial as `{n \choose k} = (n-k+1)_k / k!`. + # Computes the binomial coefficient `z = {n choose k}`, via the + # rising factorial as `{n choose k} = (n-k+1)_k / k!`. void arb_gamma(arb_t z, const arb_t x, slong prec) void arb_gamma_fmpq(arb_t z, const fmpq_t x, slong prec) diff --git a/src/sage/libs/flint/arb_hypgeom.pxd b/src/sage/libs/flint/arb_hypgeom.pxd index 6bdbd4e5f9b..5369f0c3997 100644 --- a/src/sage/libs/flint/arb_hypgeom.pxd +++ b/src/sage/libs/flint/arb_hypgeom.pxd @@ -99,7 +99,7 @@ cdef extern from "flint_wrap.h": # algorithm choice. void arb_hypgeom_central_bin_ui(arb_t res, ulong n, slong prec) - # Computes the central binomial coefficient `{2n \choose n}`. + # Computes the central binomial coefficient `{2n choose n}`. void arb_hypgeom_pfq(arb_t res, arb_srcptr a, slong p, arb_srcptr b, slong q, const arb_t z, int regularized, slong prec) # Computes the generalized hypergeometric function `{}_pF_{q}(z)`, diff --git a/src/sage/libs/flint/arb_poly.pxd b/src/sage/libs/flint/arb_poly.pxd index 7ae13775803..e225038abc2 100644 --- a/src/sage/libs/flint/arb_poly.pxd +++ b/src/sage/libs/flint/arb_poly.pxd @@ -504,7 +504,7 @@ cdef extern from "flint_wrap.h": # the output to length *len*. # The binomial transform maps the coefficients `a_k` in the input polynomial # to the coefficients `b_k` in the output polynomial via - # `b_n = \sum_{k=0}^n (-1)^k {n \choose k} a_k`. + # `b_n = \sum_{k=0}^n (-1)^k {n choose k} a_k`. # The binomial transform is equivalent to the power series composition # `f(x) \to (1-x)^{-1} f(x/(x-1))`, and is its own inverse. # The *basecase* version evaluates coefficients one by one from the diff --git a/src/sage/libs/flint/fmpz.pxd b/src/sage/libs/flint/fmpz.pxd index c9b499f171e..38d7407de33 100644 --- a/src/sage/libs/flint/fmpz.pxd +++ b/src/sage/libs/flint/fmpz.pxd @@ -665,7 +665,7 @@ cdef extern from "flint_wrap.h": # ``ulong``. void fmpz_bin_uiui(fmpz_t f, ulong n, ulong k) - # Sets `f` to the binomial coefficient `{n \choose k}`. + # Sets `f` to the binomial coefficient `{n choose k}`. void _fmpz_rfac_ui(fmpz_t r, const fmpz_t x, ulong a, ulong b) # Sets `r` to the rising factorial `(x+a) (x+a+1) (x+a+2) \cdots (x+b-1)`. diff --git a/src/sage/libs/flint/gr_special.pxd b/src/sage/libs/flint/gr_special.pxd index 7eceb713c57..4438c818246 100644 --- a/src/sage/libs/flint/gr_special.pxd +++ b/src/sage/libs/flint/gr_special.pxd @@ -104,8 +104,8 @@ cdef extern from "flint_wrap.h": int gr_bin_uiui(gr_ptr res, ulong x, ulong y, gr_ctx_t ctx) int gr_bin_vec(gr_ptr res, gr_srcptr x, slong len, gr_ctx_t ctx) int gr_bin_ui_vec(gr_ptr res, ulong x, slong len, gr_ctx_t ctx) - # Binomial coefficient `{x \choose y}`. The *vec* versions write the - # first *len* consecutive values `{x \choose 0}, {x \choose 1}, \ldots, {x \choose len-1}` + # Binomial coefficient `{x choose y}`. The *vec* versions write the + # first *len* consecutive values `{x choose 0}, {x choose 1}, \ldots, {x choose len-1}` # to the preallocated vector *res*. # For constructing a two-dimensional array of binomial # coefficients (Pascal's triangle), it is more efficient to diff --git a/src/sage/libs/flint/mag.pxd b/src/sage/libs/flint/mag.pxd index 2063965d9e5..76a58ebb1ee 100644 --- a/src/sage/libs/flint/mag.pxd +++ b/src/sage/libs/flint/mag.pxd @@ -339,7 +339,7 @@ cdef extern from "flint_wrap.h": # Sets *res* to an upper bound for `1/n!`. void mag_bin_uiui(mag_t res, ulong n, ulong k) - # Sets *res* to an upper bound for the binomial coefficient `{n \choose k}`. + # Sets *res* to an upper bound for the binomial coefficient `{n choose k}`. void mag_bernoulli_div_fac_ui(mag_t res, ulong n) # Sets *res* to an upper bound for `|B_n| / n!` where `B_n` denotes From f37b004863e94a9a06ec14e6416d92a5cd37f2e0 Mon Sep 17 00:00:00 2001 From: Vincent Delecroix Date: Sat, 14 Oct 2023 10:54:04 +0200 Subject: [PATCH 12/41] number_of_partitions moved --- src/sage/combinat/partition.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sage/combinat/partition.py b/src/sage/combinat/partition.py index 7d16d5d3410..4e78caf306d 100644 --- a/src/sage/combinat/partition.py +++ b/src/sage/combinat/partition.py @@ -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 From 057e1e54e2d18f2a45a3086a6886fbc00cc0b454 Mon Sep 17 00:00:00 2001 From: Vincent Delecroix Date: Sat, 14 Oct 2023 19:04:02 +0200 Subject: [PATCH 13/41] fix doctests in libs/flint/ --- src/sage/libs/flint/arith_sage.pyx | 16 ++++----- src/sage/libs/flint/fmpz_poly_sage.pyx | 40 +++++++++++------------ src/sage/libs/flint/ulong_extras_sage.pyx | 2 +- 3 files changed, 29 insertions(+), 29 deletions(-) diff --git a/src/sage/libs/flint/arith_sage.pyx b/src/sage/libs/flint/arith_sage.pyx index 842d9782869..dcd22bbdf9a 100644 --- a/src/sage/libs/flint/arith_sage.pyx +++ b/src/sage/libs/flint/arith_sage.pyx @@ -33,7 +33,7 @@ def bell_number(unsigned long n): EXAMPLES:: - sage: from sage.libs.flint.arith import bell_number + sage: from sage.libs.flint.arith_sage import bell_number sage: [bell_number(i) for i in range(10)] [1, 1, 2, 5, 15, 52, 203, 877, 4140, 21147] sage: bell_number(10) @@ -67,7 +67,7 @@ def bernoulli_number(unsigned long n): EXAMPLES:: - sage: from sage.libs.flint.arith import bernoulli_number + sage: from sage.libs.flint.arith_sage import bernoulli_number sage: [bernoulli_number(i) for i in range(10)] [1, -1/2, 1/6, 0, -1/30, 0, 1/42, 0, -1/30, 0] sage: bernoulli_number(10) @@ -98,7 +98,7 @@ def euler_number(unsigned long n): EXAMPLES:: - sage: from sage.libs.flint.arith import euler_number + sage: from sage.libs.flint.arith_sage import euler_number sage: [euler_number(i) for i in range(8)] [1, 0, -1, 0, 5, 0, -61, 0] """ @@ -124,7 +124,7 @@ def stirling_number_1(long n, long k): EXAMPLES:: - sage: from sage.libs.flint.arith import stirling_number_1 + sage: from sage.libs.flint.arith_sage import stirling_number_1 sage: [stirling_number_1(8,i) for i in range(9)] [0, 5040, 13068, 13132, 6769, 1960, 322, 28, 1] """ @@ -149,7 +149,7 @@ def stirling_number_2(long n, long k): EXAMPLES:: - sage: from sage.libs.flint.arith import stirling_number_2 + sage: from sage.libs.flint.arith_sage import stirling_number_2 sage: [stirling_number_2(8,i) for i in range(9)] [0, 1, 127, 966, 1701, 1050, 266, 28, 1] """ @@ -176,7 +176,7 @@ def number_of_partitions(unsigned long n): EXAMPLES:: - sage: from sage.libs.flint.arith import number_of_partitions + sage: from sage.libs.flint.arith_sage import number_of_partitions sage: number_of_partitions(3) 3 sage: number_of_partitions(10) @@ -245,7 +245,7 @@ def dedekind_sum(p, q): EXAMPLES:: - sage: from sage.libs.flint.arith import dedekind_sum + sage: from sage.libs.flint.arith_sage import dedekind_sum sage: dedekind_sum(4, 5) -1/5 """ @@ -282,7 +282,7 @@ def harmonic_number(unsigned long n): EXAMPLES:: - sage: from sage.libs.flint.arith import harmonic_number + sage: from sage.libs.flint.arith_sage import harmonic_number sage: n = 500 + randint(0,500) sage: bool( sum(1/k for k in range(1,n+1)) == harmonic_number(n) ) True diff --git a/src/sage/libs/flint/fmpz_poly_sage.pyx b/src/sage/libs/flint/fmpz_poly_sage.pyx index c20db2eed7b..1c422ce8100 100644 --- a/src/sage/libs/flint/fmpz_poly_sage.pyx +++ b/src/sage/libs/flint/fmpz_poly_sage.pyx @@ -42,7 +42,7 @@ cdef class Fmpz_poly(SageObject): EXAMPLES:: - sage: from sage.libs.flint.fmpz_poly import Fmpz_poly + sage: from sage.libs.flint.fmpz_poly_sage import Fmpz_poly sage: Fmpz_poly([1,2,3]) 3 1 2 3 sage: Fmpz_poly(5) @@ -79,7 +79,7 @@ cdef class Fmpz_poly(SageObject): EXAMPLES:: - sage: from sage.libs.flint.fmpz_poly import Fmpz_poly + sage: from sage.libs.flint.fmpz_poly_sage import Fmpz_poly sage: f = Fmpz_poly(range(10)) sage: f[7] = 100; f 10 0 1 2 3 4 5 6 100 8 9 @@ -98,7 +98,7 @@ cdef class Fmpz_poly(SageObject): EXAMPLES:: - sage: from sage.libs.flint.fmpz_poly import Fmpz_poly + sage: from sage.libs.flint.fmpz_poly_sage import Fmpz_poly sage: f = Fmpz_poly(range(100)) sage: f[13] 13 @@ -115,7 +115,7 @@ cdef class Fmpz_poly(SageObject): EXAMPLES:: - sage: from sage.libs.flint.fmpz_poly import Fmpz_poly + sage: from sage.libs.flint.fmpz_poly_sage import Fmpz_poly sage: f = Fmpz_poly([0,1]); f^7 8 0 0 0 0 0 0 0 1 """ @@ -130,7 +130,7 @@ cdef class Fmpz_poly(SageObject): EXAMPLES:: - sage: from sage.libs.flint.fmpz_poly import Fmpz_poly + sage: from sage.libs.flint.fmpz_poly_sage import Fmpz_poly sage: f = Fmpz_poly([1,2,3]); f 3 1 2 3 sage: f.degree() @@ -148,7 +148,7 @@ cdef class Fmpz_poly(SageObject): EXAMPLES:: - sage: from sage.libs.flint.fmpz_poly import Fmpz_poly + sage: from sage.libs.flint.fmpz_poly_sage import Fmpz_poly sage: f = Fmpz_poly([2,1,0,-1]) sage: f.list() [2, 1, 0, -1] @@ -161,7 +161,7 @@ cdef class Fmpz_poly(SageObject): EXAMPLES:: - sage: from sage.libs.flint.fmpz_poly import Fmpz_poly + sage: from sage.libs.flint.fmpz_poly_sage import Fmpz_poly sage: Fmpz_poly([1,2,3]) + Fmpz_poly(range(6)) 6 1 3 5 3 4 5 """ @@ -177,7 +177,7 @@ cdef class Fmpz_poly(SageObject): EXAMPLES:: - sage: from sage.libs.flint.fmpz_poly import Fmpz_poly + sage: from sage.libs.flint.fmpz_poly_sage import Fmpz_poly sage: Fmpz_poly([10,2,3]) - Fmpz_poly([4,-2,1]) 3 6 4 2 """ @@ -193,7 +193,7 @@ cdef class Fmpz_poly(SageObject): EXAMPLES:: - sage: from sage.libs.flint.fmpz_poly import Fmpz_poly + sage: from sage.libs.flint.fmpz_poly_sage import Fmpz_poly sage: -Fmpz_poly([2,10,2,3,18,-5]) 6 -2 -10 -2 -3 -18 5 """ @@ -207,7 +207,7 @@ cdef class Fmpz_poly(SageObject): EXAMPLES:: - sage: from sage.libs.flint.fmpz_poly import Fmpz_poly + sage: from sage.libs.flint.fmpz_poly_sage import Fmpz_poly sage: f = Fmpz_poly([0,1]); g = Fmpz_poly([2,3,4]) sage: f*g 4 0 2 3 4 @@ -243,7 +243,7 @@ cdef class Fmpz_poly(SageObject): EXAMPLES:: - sage: from sage.libs.flint.fmpz_poly import Fmpz_poly + sage: from sage.libs.flint.fmpz_poly_sage import Fmpz_poly sage: f = Fmpz_poly([1,1]) sage: f**6 7 1 6 15 20 15 6 1 @@ -271,7 +271,7 @@ cdef class Fmpz_poly(SageObject): EXAMPLES:: - sage: from sage.libs.flint.fmpz_poly import Fmpz_poly + sage: from sage.libs.flint.fmpz_poly_sage import Fmpz_poly sage: f = Fmpz_poly([1,2]) sage: f.pow_truncate(10,3) 3 1 20 180 @@ -293,7 +293,7 @@ cdef class Fmpz_poly(SageObject): EXAMPLES:: - sage: from sage.libs.flint.fmpz_poly import Fmpz_poly + sage: from sage.libs.flint.fmpz_poly_sage import Fmpz_poly sage: f = Fmpz_poly([3,4,5]) sage: g = f^5; g 11 243 1620 6345 16560 32190 47224 53650 46000 29375 12500 3125 @@ -314,7 +314,7 @@ cdef class Fmpz_poly(SageObject): EXAMPLES:: - sage: from sage.libs.flint.fmpz_poly import Fmpz_poly + sage: from sage.libs.flint.fmpz_poly_sage import Fmpz_poly sage: f = Fmpz_poly([1,3,4,5]) sage: g = f^23 sage: g.div_rem(f)[1] @@ -342,7 +342,7 @@ cdef class Fmpz_poly(SageObject): EXAMPLES:: - sage: from sage.libs.flint.fmpz_poly import Fmpz_poly + sage: from sage.libs.flint.fmpz_poly_sage import Fmpz_poly sage: f = Fmpz_poly([1,2]) sage: f.left_shift(1).list() == [0,1,2] True @@ -359,7 +359,7 @@ cdef class Fmpz_poly(SageObject): EXAMPLES:: - sage: from sage.libs.flint.fmpz_poly import Fmpz_poly + sage: from sage.libs.flint.fmpz_poly_sage import Fmpz_poly sage: f = Fmpz_poly([1,2]) sage: f.right_shift(1).list() == [2] True @@ -389,7 +389,7 @@ cdef class Fmpz_poly(SageObject): EXAMPLES:: - sage: from sage.libs.flint.fmpz_poly import Fmpz_poly + sage: from sage.libs.flint.fmpz_poly_sage import Fmpz_poly sage: f = Fmpz_poly([1,2,6]) sage: f.derivative().list() == [2, 12] True @@ -411,7 +411,7 @@ cdef class Fmpz_poly(SageObject): EXAMPLES:: - sage: from sage.libs.flint.fmpz_poly import Fmpz_poly + sage: from sage.libs.flint.fmpz_poly_sage import Fmpz_poly sage: f = Fmpz_poly([1,1]) sage: g = f**10; g 11 1 10 45 120 210 252 210 120 45 10 1 @@ -431,7 +431,7 @@ cdef class Fmpz_poly(SageObject): EXAMPLES:: - sage: from sage.libs.flint.fmpz_poly import Fmpz_poly + sage: from sage.libs.flint.fmpz_poly_sage import Fmpz_poly sage: f = Fmpz_poly([1,1]) sage: g = f**10; g 11 1 10 45 120 210 252 210 120 45 10 1 @@ -447,7 +447,7 @@ cdef class Fmpz_poly(SageObject): EXAMPLES:: - sage: from sage.libs.flint.fmpz_poly import Fmpz_poly + sage: from sage.libs.flint.fmpz_poly_sage import Fmpz_poly sage: f = Fmpz_poly([1,1]) sage: f._sage_('t') t + 1 diff --git a/src/sage/libs/flint/ulong_extras_sage.pyx b/src/sage/libs/flint/ulong_extras_sage.pyx index db634ba9dc9..da2503d9fb7 100644 --- a/src/sage/libs/flint/ulong_extras_sage.pyx +++ b/src/sage/libs/flint/ulong_extras_sage.pyx @@ -8,7 +8,7 @@ def n_factor_to_list(unsigned long n, int proved): EXAMPLES:: - sage: from sage.libs.flint.ulong_extras import n_factor_to_list + sage: from sage.libs.flint.ulong_extras_sage import n_factor_to_list sage: n_factor_to_list(60, 20) [(2, 2), (3, 1), (5, 1)] sage: n_factor_to_list((10**6).next_prime() + 1, 0) From 84fe7bf2f5cbc1a23416248ee8c54639fb78cc5f Mon Sep 17 00:00:00 2001 From: Vincent Delecroix Date: Sat, 14 Oct 2023 19:04:24 +0200 Subject: [PATCH 14/41] int -> bint --- src/sage/libs/flint/acb.pxd | 40 +++++------ src/sage/libs/flint/acb_mat.pxd | 32 ++++----- src/sage/libs/flint/acb_modular.pxd | 8 +-- src/sage/libs/flint/acb_poly.pxd | 20 +++--- src/sage/libs/flint/acf.pxd | 2 +- src/sage/libs/flint/aprcl.pxd | 18 ++--- src/sage/libs/flint/arb.pxd | 70 +++++++++---------- src/sage/libs/flint/arb_mat.pxd | 30 ++++---- src/sage/libs/flint/arb_poly.pxd | 18 ++--- src/sage/libs/flint/arf.pxd | 30 ++++---- src/sage/libs/flint/bool_mat.pxd | 14 ++-- src/sage/libs/flint/ca.pxd | 20 +++--- src/sage/libs/flint/ca_ext.pxd | 2 +- src/sage/libs/flint/ca_poly.pxd | 2 +- src/sage/libs/flint/ca_vec.pxd | 4 +- src/sage/libs/flint/d_mat.pxd | 12 ++-- src/sage/libs/flint/d_vec.pxd | 8 +-- src/sage/libs/flint/dirichlet.pxd | 8 +-- src/sage/libs/flint/double_extras.pxd | 2 +- src/sage/libs/flint/fexpr.pxd | 30 ++++---- src/sage/libs/flint/fmpq.pxd | 16 ++--- src/sage/libs/flint/fmpq_mat.pxd | 12 ++-- src/sage/libs/flint/fmpq_mpoly.pxd | 22 +++--- src/sage/libs/flint/fmpq_poly.pxd | 22 +++--- src/sage/libs/flint/fmpz.pxd | 36 +++++----- src/sage/libs/flint/fmpz_lll.pxd | 12 ++-- src/sage/libs/flint/fmpz_mat.pxd | 32 ++++----- src/sage/libs/flint/fmpz_mod.pxd | 4 +- src/sage/libs/flint/fmpz_mod_mat.pxd | 6 +- src/sage/libs/flint/fmpz_mod_mpoly.pxd | 20 +++--- src/sage/libs/flint/fmpz_mod_poly.pxd | 10 +-- src/sage/libs/flint/fmpz_mod_poly_factor.pxd | 18 ++--- src/sage/libs/flint/fmpz_mpoly.pxd | 26 +++---- src/sage/libs/flint/fmpz_mpoly_q.pxd | 8 +-- src/sage/libs/flint/fmpz_poly.pxd | 16 ++--- src/sage/libs/flint/fmpz_poly_mat.pxd | 10 +-- src/sage/libs/flint/fmpz_poly_q.pxd | 8 +-- src/sage/libs/flint/fmpz_vec.pxd | 4 +- src/sage/libs/flint/fmpzi.pxd | 8 +-- src/sage/libs/flint/fq.pxd | 14 ++-- src/sage/libs/flint/fq_default.pxd | 10 +-- src/sage/libs/flint/fq_default_mat.pxd | 10 +-- src/sage/libs/flint/fq_default_poly.pxd | 14 ++-- .../libs/flint/fq_default_poly_factor.pxd | 4 +- src/sage/libs/flint/fq_mat.pxd | 10 +-- src/sage/libs/flint/fq_nmod.pxd | 14 ++-- src/sage/libs/flint/fq_nmod_mat.pxd | 10 +-- src/sage/libs/flint/fq_nmod_mpoly.pxd | 16 ++--- src/sage/libs/flint/fq_nmod_poly.pxd | 14 ++-- src/sage/libs/flint/fq_nmod_poly_factor.pxd | 12 ++-- src/sage/libs/flint/fq_nmod_vec.pxd | 4 +- src/sage/libs/flint/fq_poly.pxd | 14 ++-- src/sage/libs/flint/fq_poly_factor.pxd | 12 ++-- src/sage/libs/flint/fq_vec.pxd | 4 +- src/sage/libs/flint/fq_zech.pxd | 14 ++-- src/sage/libs/flint/fq_zech_mat.pxd | 10 +-- src/sage/libs/flint/fq_zech_poly.pxd | 14 ++-- src/sage/libs/flint/fq_zech_poly_factor.pxd | 12 ++-- src/sage/libs/flint/fq_zech_vec.pxd | 4 +- src/sage/libs/flint/gr_generic.pxd | 2 +- src/sage/libs/flint/mag.pxd | 12 ++-- src/sage/libs/flint/mpf_mat.pxd | 10 +-- src/sage/libs/flint/mpf_vec.pxd | 6 +- src/sage/libs/flint/mpfr_mat.pxd | 2 +- src/sage/libs/flint/mpoly.pxd | 8 +-- src/sage/libs/flint/nf_elem.pxd | 8 +-- src/sage/libs/flint/nmod_mat.pxd | 6 +- src/sage/libs/flint/nmod_mpoly.pxd | 16 ++--- src/sage/libs/flint/nmod_poly.pxd | 18 ++--- src/sage/libs/flint/nmod_poly_factor.pxd | 12 ++-- src/sage/libs/flint/nmod_poly_mat.pxd | 12 ++-- src/sage/libs/flint/nmod_vec.pxd | 2 +- src/sage/libs/flint/padic.pxd | 6 +- src/sage/libs/flint/padic_mat.pxd | 10 +-- src/sage/libs/flint/padic_poly.pxd | 14 ++-- src/sage/libs/flint/qadic.pxd | 6 +- src/sage/libs/flint/qfb.pxd | 8 +-- src/sage/libs/flint/qqbar.pxd | 24 +++---- src/sage/libs/flint/types.pxd | 4 +- src/sage/libs/flint/ulong_extras.pxd | 32 ++++----- 80 files changed, 547 insertions(+), 547 deletions(-) diff --git a/src/sage/libs/flint/acb.pxd b/src/sage/libs/flint/acb.pxd index 196d7588f08..8cd4df5603c 100644 --- a/src/sage/libs/flint/acb.pxd +++ b/src/sage/libs/flint/acb.pxd @@ -132,25 +132,25 @@ cdef extern from "flint_wrap.h": # Generates a random complex number, with very high probability of # generating integers and half-integers. - int acb_is_zero(const acb_t z) + bint acb_is_zero(const acb_t z) # Returns nonzero iff *z* is zero. - int acb_is_one(const acb_t z) + bint acb_is_one(const acb_t z) # Returns nonzero iff *z* is exactly 1. - int acb_is_finite(const acb_t z) + bint acb_is_finite(const acb_t z) # Returns nonzero iff *z* certainly is finite. - int acb_is_exact(const acb_t z) + bint acb_is_exact(const acb_t z) # Returns nonzero iff *z* is exact. - int acb_is_int(const acb_t z) + bint acb_is_int(const acb_t z) # Returns nonzero iff *z* is an exact integer. - int acb_is_int_2exp_si(const acb_t x, slong e) + bint acb_is_int_2exp_si(const acb_t x, slong e) # Returns nonzero iff *z* exactly equals `n 2^e` for some integer *n*. - int acb_equal(const acb_t x, const acb_t y) + bint acb_equal(const acb_t x, const acb_t y) # Returns nonzero iff *x* and *y* are identical as sets, i.e. # if the real and imaginary parts are equal as balls. # Note that this is not the same thing as testing whether both @@ -160,19 +160,19 @@ cdef extern from "flint_wrap.h": # quantity, use :func:`acb_overlaps` or :func:`acb_contains`, # depending on the circumstance. - int acb_equal_si(const acb_t x, slong y) + bint acb_equal_si(const acb_t x, slong y) # Returns nonzero iff *x* is equal to the integer *y*. - int acb_eq(const acb_t x, const acb_t y) + bint acb_eq(const acb_t x, const acb_t y) # Returns nonzero iff *x* and *y* are certainly equal, as determined # by testing that :func:`arb_eq` holds for both the real and imaginary # parts. - int acb_ne(const acb_t x, const acb_t y) + bint acb_ne(const acb_t x, const acb_t y) # Returns nonzero iff *x* and *y* are certainly not equal, as determined # by testing that :func:`arb_ne` holds for either the real or imaginary parts. - int acb_overlaps(const acb_t x, const acb_t y) + bint acb_overlaps(const acb_t x, const acb_t y) # Returns nonzero iff *x* and *y* have some point in common. void acb_union(acb_t z, const acb_t x, const acb_t y, slong prec) @@ -196,21 +196,21 @@ cdef extern from "flint_wrap.h": void acb_get_mag_lower(mag_t u, const acb_t x) # Sets *u* to a lower bound for the absolute value of *x*. - int acb_contains_fmpq(const acb_t x, const fmpq_t y) + bint acb_contains_fmpq(const acb_t x, const fmpq_t y) - int acb_contains_fmpz(const acb_t x, const fmpz_t y) + bint acb_contains_fmpz(const acb_t x, const fmpz_t y) - int acb_contains(const acb_t x, const acb_t y) + bint acb_contains(const acb_t x, const acb_t y) # Returns nonzero iff *y* is contained in *x*. - int acb_contains_zero(const acb_t x) + bint acb_contains_zero(const acb_t x) # Returns nonzero iff zero is contained in *x*. - int acb_contains_int(const acb_t x) + bint acb_contains_int(const acb_t x) # Returns nonzero iff the complex interval represented by *x* contains # an integer. - int acb_contains_interior(const acb_t x, const acb_t y) + bint acb_contains_interior(const acb_t x, const acb_t y) # Tests if *y* is contained in the interior of *x*. # This predicate always evaluates to false if *x* and *y* are both # real-valued, since an imaginary part of 0 is not considered contained in @@ -248,7 +248,7 @@ cdef extern from "flint_wrap.h": # Sets *y* to a a copy of *x* with both the real and imaginary # parts trimmed (see :func:`arb_trim`). - int acb_is_real(const acb_t x) + bint acb_is_real(const acb_t x) # Returns nonzero iff the imaginary part of *x* is zero. # It does not test whether the real part of *x* also is finite. @@ -840,10 +840,10 @@ cdef extern from "flint_wrap.h": void _acb_vec_zero(acb_ptr A, slong n) # Sets all entries in *vec* to zero. - int _acb_vec_is_zero(acb_srcptr vec, slong len) + bint _acb_vec_is_zero(acb_srcptr vec, slong len) # Returns nonzero iff all entries in *x* are zero. - int _acb_vec_is_real(acb_srcptr v, slong len) + bint _acb_vec_is_real(acb_srcptr v, slong len) # Returns nonzero iff all entries in *x* have zero imaginary part. void _acb_vec_set(acb_ptr res, acb_srcptr vec, slong len) diff --git a/src/sage/libs/flint/acb_mat.pxd b/src/sage/libs/flint/acb_mat.pxd index d54cf768c1c..498ae0a4552 100644 --- a/src/sage/libs/flint/acb_mat.pxd +++ b/src/sage/libs/flint/acb_mat.pxd @@ -62,55 +62,55 @@ cdef extern from "flint_wrap.h": # Prints each entry in the matrix with the specified number of decimal # digits to the stream *file*. - int acb_mat_equal(const acb_mat_t mat1, const acb_mat_t mat2) + bint acb_mat_equal(const acb_mat_t mat1, const acb_mat_t mat2) # Returns whether the matrices have the same dimensions and identical # intervals as entries. - int acb_mat_overlaps(const acb_mat_t mat1, const acb_mat_t mat2) + bint acb_mat_overlaps(const acb_mat_t mat1, const acb_mat_t mat2) # Returns whether the matrices have the same dimensions # and each entry in *mat1* overlaps with the corresponding entry in *mat2*. - int acb_mat_contains(const acb_mat_t mat1, const acb_mat_t mat2) + bint acb_mat_contains(const acb_mat_t mat1, const acb_mat_t mat2) - int acb_mat_contains_fmpz_mat(const acb_mat_t mat1, const fmpz_mat_t mat2) + bint acb_mat_contains_fmpz_mat(const acb_mat_t mat1, const fmpz_mat_t mat2) - int acb_mat_contains_fmpq_mat(const acb_mat_t mat1, const fmpq_mat_t mat2) + bint acb_mat_contains_fmpq_mat(const acb_mat_t mat1, const fmpq_mat_t mat2) # Returns whether the matrices have the same dimensions and each entry # in *mat2* is contained in the corresponding entry in *mat1*. - int acb_mat_eq(const acb_mat_t mat1, const acb_mat_t mat2) + bint acb_mat_eq(const acb_mat_t mat1, const acb_mat_t mat2) # Returns whether *mat1* and *mat2* certainly represent the same matrix. - int acb_mat_ne(const acb_mat_t mat1, const acb_mat_t mat2) + bint acb_mat_ne(const acb_mat_t mat1, const acb_mat_t mat2) # Returns whether *mat1* and *mat2* certainly do not represent the same matrix. - int acb_mat_is_real(const acb_mat_t mat) + bint acb_mat_is_real(const acb_mat_t mat) # Returns whether all entries in *mat* have zero imaginary part. - int acb_mat_is_empty(const acb_mat_t mat) + bint acb_mat_is_empty(const acb_mat_t mat) # Returns whether the number of rows or the number of columns in *mat* is zero. - int acb_mat_is_square(const acb_mat_t mat) + bint acb_mat_is_square(const acb_mat_t mat) # Returns whether the number of rows is equal to the number of columns in *mat*. - int acb_mat_is_exact(const acb_mat_t mat) + bint acb_mat_is_exact(const acb_mat_t mat) # Returns whether all entries in *mat* have zero radius. - int acb_mat_is_zero(const acb_mat_t mat) + bint acb_mat_is_zero(const acb_mat_t mat) # Returns whether all entries in *mat* are exactly zero. - int acb_mat_is_finite(const acb_mat_t mat) + bint acb_mat_is_finite(const acb_mat_t mat) # Returns whether all entries in *mat* are finite. - int acb_mat_is_triu(const acb_mat_t mat) + bint acb_mat_is_triu(const acb_mat_t mat) # Returns whether *mat* is upper triangular; that is, all entries # below the main diagonal are exactly zero. - int acb_mat_is_tril(const acb_mat_t mat) + bint acb_mat_is_tril(const acb_mat_t mat) # Returns whether *mat* is lower triangular; that is, all entries # above the main diagonal are exactly zero. - int acb_mat_is_diag(const acb_mat_t mat) + bint acb_mat_is_diag(const acb_mat_t mat) # Returns whether *mat* is a diagonal matrix; that is, all entries # off the main diagonal are exactly zero. diff --git a/src/sage/libs/flint/acb_modular.pxd b/src/sage/libs/flint/acb_modular.pxd index 382eb9afc05..761ba81e103 100644 --- a/src/sage/libs/flint/acb_modular.pxd +++ b/src/sage/libs/flint/acb_modular.pxd @@ -27,7 +27,7 @@ cdef extern from "flint_wrap.h": void psl2z_one(psl2z_t g) # Sets *g* to the identity element. - int psl2z_is_one(const psl2z_t g) + bint psl2z_is_one(const psl2z_t g) # Returns nonzero iff *g* is the identity element. void psl2z_print(const psl2z_t g) @@ -36,7 +36,7 @@ cdef extern from "flint_wrap.h": void psl2z_fprint(FILE * file, const psl2z_t g) # Prints *g* to the stream *file*. - int psl2z_equal(const psl2z_t f, const psl2z_t g) + bint psl2z_equal(const psl2z_t f, const psl2z_t g) # Returns nonzero iff *f* and *g* are equal. void psl2z_mul(psl2z_t h, const psl2z_t f, const psl2z_t g) @@ -46,7 +46,7 @@ cdef extern from "flint_wrap.h": void psl2z_inv(psl2z_t h, const psl2z_t g) # Sets *h* to the inverse of *g*. - int psl2z_is_correct(const psl2z_t g) + bint psl2z_is_correct(const psl2z_t g) # Returns nonzero iff *g* contains correct data, i.e. # satisfying `ad-bc = 1`, `c \ge 0`, and `d > 0` if `c = 0`. @@ -97,7 +97,7 @@ cdef extern from "flint_wrap.h": # but it is up to the user to verify a posteriori that `w` is close enough # to the fundamental domain. - int acb_modular_is_in_fundamental_domain(const acb_t z, const arf_t tol, slong prec) + bint acb_modular_is_in_fundamental_domain(const acb_t z, const arf_t tol, slong prec) # Returns nonzero if it is certainly true that `|z| \ge 1 - \varepsilon` and # `|\operatorname{Re}(z)| \le 1/2 + \varepsilon` where `\varepsilon` is # specified by *tol*. Returns zero if this is false or cannot be determined. diff --git a/src/sage/libs/flint/acb_poly.pxd b/src/sage/libs/flint/acb_poly.pxd index aa6207b1373..e70e60587da 100644 --- a/src/sage/libs/flint/acb_poly.pxd +++ b/src/sage/libs/flint/acb_poly.pxd @@ -51,11 +51,11 @@ cdef extern from "flint_wrap.h": # so the return value of this function is effectively # an upper bound. - int acb_poly_is_zero(const acb_poly_t poly) + bint acb_poly_is_zero(const acb_poly_t poly) - int acb_poly_is_one(const acb_poly_t poly) + bint acb_poly_is_one(const acb_poly_t poly) - int acb_poly_is_x(const acb_poly_t poly) + bint acb_poly_is_x(const acb_poly_t poly) # Returns 1 if *poly* is exactly the polynomial 0, 1 or *x* # respectively. Returns 0 otherwise. @@ -117,19 +117,19 @@ cdef extern from "flint_wrap.h": void acb_poly_randtest(acb_poly_t poly, flint_rand_t state, slong len, slong prec, slong mag_bits) # Creates a random polynomial with length at most *len*. - int acb_poly_equal(const acb_poly_t A, const acb_poly_t B) + bint acb_poly_equal(const acb_poly_t A, const acb_poly_t B) # Returns nonzero iff *A* and *B* are identical as interval polynomials. - int acb_poly_contains(const acb_poly_t poly1, const acb_poly_t poly2) + bint acb_poly_contains(const acb_poly_t poly1, const acb_poly_t poly2) - int acb_poly_contains_fmpz_poly(const acb_poly_t poly1, const fmpz_poly_t poly2) + bint acb_poly_contains_fmpz_poly(const acb_poly_t poly1, const fmpz_poly_t poly2) - int acb_poly_contains_fmpq_poly(const acb_poly_t poly1, const fmpq_poly_t poly2) + bint acb_poly_contains_fmpq_poly(const acb_poly_t poly1, const fmpq_poly_t poly2) # Returns nonzero iff *poly2* is contained in *poly1*. - int _acb_poly_overlaps(acb_srcptr poly1, slong len1, acb_srcptr poly2, slong len2) + bint _acb_poly_overlaps(acb_srcptr poly1, slong len1, acb_srcptr poly2, slong len2) - int acb_poly_overlaps(const acb_poly_t poly1, const acb_poly_t poly2) + bint acb_poly_overlaps(const acb_poly_t poly1, const acb_poly_t poly2) # Returns nonzero iff *poly1* overlaps with *poly2*. The underscore # function requires that *len1* is at least as large as *len2*. @@ -138,7 +138,7 @@ cdef extern from "flint_wrap.h": # nonzero. Otherwise (if *x* represents no integers or more than one integer), # returns zero, possibly partially modifying *z*. - int acb_poly_is_real(const acb_poly_t poly) + bint acb_poly_is_real(const acb_poly_t poly) # Returns nonzero iff all coefficients in *poly* have zero imaginary part. void acb_poly_set_fmpz_poly(acb_poly_t poly, const fmpz_poly_t re, slong prec) diff --git a/src/sage/libs/flint/acf.pxd b/src/sage/libs/flint/acf.pxd index 8ada9eff7bd..ef753271a14 100644 --- a/src/sage/libs/flint/acf.pxd +++ b/src/sage/libs/flint/acf.pxd @@ -33,7 +33,7 @@ cdef extern from "flint_wrap.h": void acf_set(acf_t z, const acf_t x) # Sets *z* to the value *x*. - int acf_equal(const acf_t x, const acf_t y) + bint acf_equal(const acf_t x, const acf_t y) # Returns whether *x* and *y* are equal. int acf_add(acf_t res, const acf_t x, const acf_t y, slong prec, arf_rnd_t rnd) diff --git a/src/sage/libs/flint/aprcl.pxd b/src/sage/libs/flint/aprcl.pxd index 64e1d10ac10..1c3fd3d5554 100644 --- a/src/sage/libs/flint/aprcl.pxd +++ b/src/sage/libs/flint/aprcl.pxd @@ -12,11 +12,11 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - int aprcl_is_prime(const fmpz_t n) + bint aprcl_is_prime(const fmpz_t n) # Tests `n` for primality using the APRCL test. # This is the same as :func:`aprcl_is_prime_jacobi`. - int aprcl_is_prime_jacobi(const fmpz_t n) + bint aprcl_is_prime_jacobi(const fmpz_t n) # If `n` is prime returns 1; otherwise returns 0. The algorithm is well described # in "Implementation of a New Primality Test" by H. Cohen and A.K. Lenstra and # "A Course in Computational Algebraic Number Theory" by H. Cohen. @@ -25,7 +25,7 @@ cdef extern from "flint_wrap.h": # To handle this condition, the :func:`_aprcl_is_prime_jacobi` function # can be used. - int aprcl_is_prime_gauss(const fmpz_t n) + bint aprcl_is_prime_gauss(const fmpz_t n) # If `n` is prime returns 1; otherwise returns 0. # Uses the cyclotomic primality testing algorithm described in # "Four primality testing algorithms" by Rene Schoof. @@ -46,10 +46,10 @@ cdef extern from "flint_wrap.h": # ``PRIME``, ``COMPOSITE`` and ``PROBABPRIME`` # (if we cannot prove primality). - int aprcl_is_prime_gauss_min_R(const fmpz_t n, ulong R) + bint aprcl_is_prime_gauss_min_R(const fmpz_t n, ulong R) # Same as :func:`aprcl_is_prime_gauss` with fixed minimum value of `R`. - int aprcl_is_prime_final_division(const fmpz_t n, const fmpz_t s, ulong r) + bint aprcl_is_prime_final_division(const fmpz_t n, const fmpz_t s, ulong r) # Returns 0 if for some `a = n^k \bmod s`, where `k \in [1, r - 1]`, # we have that `a \mid n`; otherwise returns 1. @@ -99,7 +99,7 @@ cdef extern from "flint_wrap.h": slong unity_zp_is_unity(unity_zp f) # If `f = \zeta^h` returns h; otherwise returns -1. - int unity_zp_equal(unity_zp f, unity_zp g) + bint unity_zp_equal(unity_zp f, unity_zp g) # Returns nonzero if `f = g` reduced by the `p^{exp}`-th cyclotomic # polynomial. @@ -227,16 +227,16 @@ cdef extern from "flint_wrap.h": # Swaps `f` and `g`. `f` and `g` must be initialized with # same `p`, `q` and `n`. - int unity_zpq_equal(const unity_zpq f, const unity_zpq g) + bint unity_zpq_equal(const unity_zpq f, const unity_zpq g) # Returns nonzero if `f = g`. slong unity_zpq_p_unity(const unity_zpq f) # If `f = \zeta_p^x` returns `x \in [0, p - 1]`; otherwise returns `p`. - int unity_zpq_is_p_unity(const unity_zpq f) + bint unity_zpq_is_p_unity(const unity_zpq f) # Returns nonzero if `f = \zeta_p^x`. - int unity_zpq_is_p_unity_generator(const unity_zpq f) + bint unity_zpq_is_p_unity_generator(const unity_zpq f) # Returns nonzero if `f` is a generator of the cyclic group `\langle\zeta_p\rangle`. void unity_zpq_coeff_set_fmpz(unity_zpq f, slong i, slong j, const fmpz_t x) diff --git a/src/sage/libs/flint/arb.pxd b/src/sage/libs/flint/arb.pxd index a67268148b8..9f9349e2e3c 100644 --- a/src/sage/libs/flint/arb.pxd +++ b/src/sage/libs/flint/arb.pxd @@ -414,30 +414,30 @@ cdef extern from "flint_wrap.h": # To be conservative, zero is returned when *x* is non-finite, even if it # is an "exact" infinity. - int arb_is_zero(const arb_t x) + bint arb_is_zero(const arb_t x) # Returns nonzero iff the midpoint and radius of *x* are both zero. - int arb_is_nonzero(const arb_t x) + bint arb_is_nonzero(const arb_t x) # Returns nonzero iff zero is not contained in the interval represented # by *x*. - int arb_is_one(const arb_t f) + bint arb_is_one(const arb_t f) # Returns nonzero iff *x* is exactly 1. - int arb_is_finite(const arb_t x) + bint arb_is_finite(const arb_t x) # Returns nonzero iff the midpoint and radius of *x* are both finite # floating-point numbers, i.e. not infinities or NaN. - int arb_is_exact(const arb_t x) + bint arb_is_exact(const arb_t x) # Returns nonzero iff the radius of *x* is zero. - int arb_is_int(const arb_t x) + bint arb_is_int(const arb_t x) # Returns nonzero iff *x* is an exact integer. - int arb_is_int_2exp_si(const arb_t x, slong e) + bint arb_is_int_2exp_si(const arb_t x, slong e) # Returns nonzero iff *x* exactly equals `n 2^e` for some integer *n*. - int arb_equal(const arb_t x, const arb_t y) + bint arb_equal(const arb_t x, const arb_t y) # Returns nonzero iff *x* and *y* are equal as balls, i.e. have both the # same midpoint and radius. # Note that this is not the same thing as testing whether both @@ -447,37 +447,37 @@ cdef extern from "flint_wrap.h": # quantity, use :func:`arb_overlaps` or :func:`arb_contains`, # depending on the circumstance. - int arb_equal_si(const arb_t x, slong y) + bint arb_equal_si(const arb_t x, slong y) # Returns nonzero iff *x* is equal to the integer *y*. - int arb_is_positive(const arb_t x) + bint arb_is_positive(const arb_t x) - int arb_is_nonnegative(const arb_t x) + bint arb_is_nonnegative(const arb_t x) - int arb_is_negative(const arb_t x) + bint arb_is_negative(const arb_t x) - int arb_is_nonpositive(const arb_t x) + bint arb_is_nonpositive(const arb_t x) # Returns nonzero iff all points *p* in the interval represented by *x* # satisfy, respectively, `p > 0`, `p \ge 0`, `p < 0`, `p \le 0`. # If *x* contains NaN, returns zero. - int arb_overlaps(const arb_t x, const arb_t y) + bint arb_overlaps(const arb_t x, const arb_t y) # Returns nonzero iff *x* and *y* have some point in common. # If either *x* or *y* contains NaN, this function always returns nonzero # (as a NaN could be anything, it could in particular contain any # number that is included in the other operand). - int arb_contains_arf(const arb_t x, const arf_t y) + bint arb_contains_arf(const arb_t x, const arf_t y) - int arb_contains_fmpq(const arb_t x, const fmpq_t y) + bint arb_contains_fmpq(const arb_t x, const fmpq_t y) - int arb_contains_fmpz(const arb_t x, const fmpz_t y) + bint arb_contains_fmpz(const arb_t x, const fmpz_t y) - int arb_contains_si(const arb_t x, slong y) + bint arb_contains_si(const arb_t x, slong y) - int arb_contains_mpfr(const arb_t x, const mpfr_t y) + bint arb_contains_mpfr(const arb_t x, const mpfr_t y) - int arb_contains(const arb_t x, const arb_t y) + bint arb_contains(const arb_t x, const arb_t y) # Returns nonzero iff the given number (or ball) *y* is contained in # the interval represented by *x*. # If *x* contains NaN, this function always returns nonzero (as it @@ -485,37 +485,37 @@ cdef extern from "flint_wrap.h": # the points included in *y*). # If *y* contains NaN and *x* does not, it always returns zero. - int arb_contains_int(const arb_t x) + bint arb_contains_int(const arb_t x) # Returns nonzero iff the interval represented by *x* contains an integer. - int arb_contains_zero(const arb_t x) + bint arb_contains_zero(const arb_t x) - int arb_contains_negative(const arb_t x) + bint arb_contains_negative(const arb_t x) - int arb_contains_nonpositive(const arb_t x) + bint arb_contains_nonpositive(const arb_t x) - int arb_contains_positive(const arb_t x) + bint arb_contains_positive(const arb_t x) - int arb_contains_nonnegative(const arb_t x) + bint arb_contains_nonnegative(const arb_t x) # Returns nonzero iff there is any point *p* in the interval represented # by *x* satisfying, respectively, `p = 0`, `p < 0`, `p \le 0`, `p > 0`, `p \ge 0`. # If *x* contains NaN, returns nonzero. - int arb_contains_interior(const arb_t x, const arb_t y) + bint arb_contains_interior(const arb_t x, const arb_t y) # Tests if *y* is contained in the interior of *x*; that is, contained # in *x* and not touching either endpoint. - int arb_eq(const arb_t x, const arb_t y) + bint arb_eq(const arb_t x, const arb_t y) - int arb_ne(const arb_t x, const arb_t y) + bint arb_ne(const arb_t x, const arb_t y) - int arb_lt(const arb_t x, const arb_t y) + bint arb_lt(const arb_t x, const arb_t y) - int arb_le(const arb_t x, const arb_t y) + bint arb_le(const arb_t x, const arb_t y) - int arb_gt(const arb_t x, const arb_t y) + bint arb_gt(const arb_t x, const arb_t y) - int arb_ge(const arb_t x, const arb_t y) + bint arb_ge(const arb_t x, const arb_t y) # Respectively performs the comparison `x = y`, `x \ne y`, # `x < y`, `x \le y`, `x > y`, `x \ge y` in a mathematically meaningful way. # If the comparison `t \, (\operatorname{op}) \, u` holds for all @@ -1432,10 +1432,10 @@ cdef extern from "flint_wrap.h": void _arb_vec_zero(arb_ptr vec, slong n) # Sets all entries in *vec* to zero. - int _arb_vec_is_zero(arb_srcptr vec, slong len) + bint _arb_vec_is_zero(arb_srcptr vec, slong len) # Returns nonzero iff all entries in *x* are zero. - int _arb_vec_is_finite(arb_srcptr x, slong len) + bint _arb_vec_is_finite(arb_srcptr x, slong len) # Returns nonzero iff all entries in *x* certainly are finite. void _arb_vec_set(arb_ptr res, arb_srcptr vec, slong len) diff --git a/src/sage/libs/flint/arb_mat.pxd b/src/sage/libs/flint/arb_mat.pxd index 9d97362250a..9d05facd91c 100644 --- a/src/sage/libs/flint/arb_mat.pxd +++ b/src/sage/libs/flint/arb_mat.pxd @@ -52,52 +52,52 @@ cdef extern from "flint_wrap.h": # Prints each entry in the matrix with the specified number of decimal # digits to the stream *file*. - int arb_mat_equal(const arb_mat_t mat1, const arb_mat_t mat2) + bint arb_mat_equal(const arb_mat_t mat1, const arb_mat_t mat2) # Returns whether the matrices have the same dimensions # and identical intervals as entries. - int arb_mat_overlaps(const arb_mat_t mat1, const arb_mat_t mat2) + bint arb_mat_overlaps(const arb_mat_t mat1, const arb_mat_t mat2) # Returns whether the matrices have the same dimensions # and each entry in *mat1* overlaps with the corresponding entry in *mat2*. - int arb_mat_contains(const arb_mat_t mat1, const arb_mat_t mat2) + bint arb_mat_contains(const arb_mat_t mat1, const arb_mat_t mat2) - int arb_mat_contains_fmpz_mat(const arb_mat_t mat1, const fmpz_mat_t mat2) + bint arb_mat_contains_fmpz_mat(const arb_mat_t mat1, const fmpz_mat_t mat2) - int arb_mat_contains_fmpq_mat(const arb_mat_t mat1, const fmpq_mat_t mat2) + bint arb_mat_contains_fmpq_mat(const arb_mat_t mat1, const fmpq_mat_t mat2) # Returns whether the matrices have the same dimensions and each entry # in *mat2* is contained in the corresponding entry in *mat1*. - int arb_mat_eq(const arb_mat_t mat1, const arb_mat_t mat2) + bint arb_mat_eq(const arb_mat_t mat1, const arb_mat_t mat2) # Returns whether *mat1* and *mat2* certainly represent the same matrix. - int arb_mat_ne(const arb_mat_t mat1, const arb_mat_t mat2) + bint arb_mat_ne(const arb_mat_t mat1, const arb_mat_t mat2) # Returns whether *mat1* and *mat2* certainly do not represent the same matrix. - int arb_mat_is_empty(const arb_mat_t mat) + bint arb_mat_is_empty(const arb_mat_t mat) # Returns whether the number of rows or the number of columns in *mat* is zero. - int arb_mat_is_square(const arb_mat_t mat) + bint arb_mat_is_square(const arb_mat_t mat) # Returns whether the number of rows is equal to the number of columns in *mat*. - int arb_mat_is_exact(const arb_mat_t mat) + bint arb_mat_is_exact(const arb_mat_t mat) # Returns whether all entries in *mat* have zero radius. - int arb_mat_is_zero(const arb_mat_t mat) + bint arb_mat_is_zero(const arb_mat_t mat) # Returns whether all entries in *mat* are exactly zero. - int arb_mat_is_finite(const arb_mat_t mat) + bint arb_mat_is_finite(const arb_mat_t mat) # Returns whether all entries in *mat* are finite. - int arb_mat_is_triu(const arb_mat_t mat) + bint arb_mat_is_triu(const arb_mat_t mat) # Returns whether *mat* is upper triangular; that is, all entries # below the main diagonal are exactly zero. - int arb_mat_is_tril(const arb_mat_t mat) + bint arb_mat_is_tril(const arb_mat_t mat) # Returns whether *mat* is lower triangular; that is, all entries # above the main diagonal are exactly zero. - int arb_mat_is_diag(const arb_mat_t mat) + bint arb_mat_is_diag(const arb_mat_t mat) # Returns whether *mat* is a diagonal matrix; that is, all entries # off the main diagonal are exactly zero. diff --git a/src/sage/libs/flint/arb_poly.pxd b/src/sage/libs/flint/arb_poly.pxd index e225038abc2..4b1c5150948 100644 --- a/src/sage/libs/flint/arb_poly.pxd +++ b/src/sage/libs/flint/arb_poly.pxd @@ -48,11 +48,11 @@ cdef extern from "flint_wrap.h": # so the return value of this function is effectively # an upper bound. - int arb_poly_is_zero(const arb_poly_t poly) + bint arb_poly_is_zero(const arb_poly_t poly) - int arb_poly_is_one(const arb_poly_t poly) + bint arb_poly_is_one(const arb_poly_t poly) - int arb_poly_is_x(const arb_poly_t poly) + bint arb_poly_is_x(const arb_poly_t poly) # Returns 1 if *poly* is exactly the polynomial 0, 1 or *x* # respectively. Returns 0 otherwise. @@ -120,20 +120,20 @@ cdef extern from "flint_wrap.h": void arb_poly_randtest(arb_poly_t poly, flint_rand_t state, slong len, slong prec, slong mag_bits) # Creates a random polynomial with length at most *len*. - int arb_poly_contains(const arb_poly_t poly1, const arb_poly_t poly2) + bint arb_poly_contains(const arb_poly_t poly1, const arb_poly_t poly2) - int arb_poly_contains_fmpz_poly(const arb_poly_t poly1, const fmpz_poly_t poly2) + bint arb_poly_contains_fmpz_poly(const arb_poly_t poly1, const fmpz_poly_t poly2) - int arb_poly_contains_fmpq_poly(const arb_poly_t poly1, const fmpq_poly_t poly2) + bint arb_poly_contains_fmpq_poly(const arb_poly_t poly1, const fmpq_poly_t poly2) # Returns nonzero iff *poly1* contains *poly2*. - int arb_poly_equal(const arb_poly_t A, const arb_poly_t B) + bint arb_poly_equal(const arb_poly_t A, const arb_poly_t B) # Returns nonzero iff *A* and *B* are equal as polynomial balls, i.e. all # coefficients have equal midpoint and radius. - int _arb_poly_overlaps(arb_srcptr poly1, slong len1, arb_srcptr poly2, slong len2) + bint _arb_poly_overlaps(arb_srcptr poly1, slong len1, arb_srcptr poly2, slong len2) - int arb_poly_overlaps(const arb_poly_t poly1, const arb_poly_t poly2) + bint arb_poly_overlaps(const arb_poly_t poly1, const arb_poly_t poly2) # Returns nonzero iff *poly1* overlaps with *poly2*. The underscore # function requires that *len1* is at least as large as *len2*. diff --git a/src/sage/libs/flint/arf.pxd b/src/sage/libs/flint/arf.pxd index 89d4556442e..cdf727292c4 100644 --- a/src/sage/libs/flint/arf.pxd +++ b/src/sage/libs/flint/arf.pxd @@ -34,30 +34,30 @@ cdef extern from "flint_wrap.h": void arf_nan(arf_t res) # Sets *res* respectively to 0, 1, `+\infty`, `-\infty`, NaN. - int arf_is_zero(const arf_t x) + bint arf_is_zero(const arf_t x) - int arf_is_one(const arf_t x) + bint arf_is_one(const arf_t x) - int arf_is_pos_inf(const arf_t x) + bint arf_is_pos_inf(const arf_t x) - int arf_is_neg_inf(const arf_t x) + bint arf_is_neg_inf(const arf_t x) - int arf_is_nan(const arf_t x) + bint arf_is_nan(const arf_t x) # Returns nonzero iff *x* respectively equals 0, 1, `+\infty`, `-\infty`, NaN. - int arf_is_inf(const arf_t x) + bint arf_is_inf(const arf_t x) # Returns nonzero iff *x* equals either `+\infty` or `-\infty`. - int arf_is_normal(const arf_t x) + bint arf_is_normal(const arf_t x) # Returns nonzero iff *x* is a finite, nonzero floating-point value, i.e. # not one of the special values 0, `+\infty`, `-\infty`, NaN. - int arf_is_special(const arf_t x) + bint arf_is_special(const arf_t x) # Returns nonzero iff *x* is one of the special values # 0, `+\infty`, `-\infty`, NaN, i.e. not a finite, nonzero # floating-point value. - int arf_is_finite(const arf_t x) + bint arf_is_finite(const arf_t x) # Returns nonzero iff *x* is a finite floating-point value, # i.e. not one of the values `+\infty`, `-\infty`, NaN. # (Note that this is not equivalent to the negation of @@ -176,10 +176,10 @@ cdef extern from "flint_wrap.h": # This method aborts if *x* is infinite or NaN, or if the exponent of *x* # is so large that allocating memory for the result fails. - int arf_equal(const arf_t x, const arf_t y) - int arf_equal_si(const arf_t x, slong y) - int arf_equal_ui(const arf_t x, ulong y) - int arf_equal_d(const arf_t x, double y) + bint arf_equal(const arf_t x, const arf_t y) + bint arf_equal_si(const arf_t x, slong y) + bint arf_equal_ui(const arf_t x, ulong y) + bint arf_equal_d(const arf_t x, double y) # Returns nonzero iff *x* and *y* are exactly equal. NaN is not # treated specially, i.e. NaN compares as equal to itself. # For comparison with a *double*, the values -0 and +0 are @@ -224,10 +224,10 @@ cdef extern from "flint_wrap.h": # of the mantissa of *x*, i.e. the minimum precision sufficient to represent # *x* exactly. Returns 0 if *x* is a special value. - int arf_is_int(const arf_t x) + bint arf_is_int(const arf_t x) # Returns nonzero iff *x* is integer-valued. - int arf_is_int_2exp_si(const arf_t x, slong e) + bint arf_is_int_2exp_si(const arf_t x, slong e) # Returns nonzero iff *x* equals `n 2^e` for some integer *n*. void arf_abs_bound_lt_2exp_fmpz(fmpz_t res, const arf_t x) diff --git a/src/sage/libs/flint/bool_mat.pxd b/src/sage/libs/flint/bool_mat.pxd index 3d5b648e118..214df9bc4dc 100644 --- a/src/sage/libs/flint/bool_mat.pxd +++ b/src/sage/libs/flint/bool_mat.pxd @@ -25,11 +25,11 @@ cdef extern from "flint_wrap.h": void bool_mat_clear(bool_mat_t mat) # Clears the matrix, deallocating all entries. - int bool_mat_is_empty(const bool_mat_t mat) + bint bool_mat_is_empty(const bool_mat_t mat) # Returns nonzero iff the number of rows or the number of columns in *mat* # is zero. Note that this does not depend on the entry values of *mat*. - int bool_mat_is_square(const bool_mat_t mat) + bint bool_mat_is_square(const bool_mat_t mat) # Returns nonzero iff the number of rows is equal to the number of columns in *mat*. void bool_mat_set(bool_mat_t dest, const bool_mat_t src) @@ -41,7 +41,7 @@ cdef extern from "flint_wrap.h": void bool_mat_fprint(FILE * file, const bool_mat_t mat) # Prints each entry in the matrix to the stream *file*. - int bool_mat_equal(const bool_mat_t mat1, const bool_mat_t mat2) + bint bool_mat_equal(const bool_mat_t mat1, const bool_mat_t mat2) # Returns nonzero iff the matrices have the same dimensions # and identical entries. @@ -51,16 +51,16 @@ cdef extern from "flint_wrap.h": int bool_mat_all(const bool_mat_t mat) # Returns nonzero iff all entries of *mat* are nonzero. - int bool_mat_is_diagonal(const bool_mat_t A) + bint bool_mat_is_diagonal(const bool_mat_t A) # Returns nonzero iff `i \ne j \implies \bar{A_{ij}}`. - int bool_mat_is_lower_triangular(const bool_mat_t A) + bint bool_mat_is_lower_triangular(const bool_mat_t A) # Returns nonzero iff `i < j \implies \bar{A_{ij}}`. - int bool_mat_is_transitive(const bool_mat_t mat) + bint bool_mat_is_transitive(const bool_mat_t mat) # Returns nonzero iff `A_{ij} \wedge A_{jk} \implies A_{ik}`. - int bool_mat_is_nilpotent(const bool_mat_t A) + bint bool_mat_is_nilpotent(const bool_mat_t A) # Returns nonzero iff some positive matrix power of `A` is zero. void bool_mat_randtest(bool_mat_t mat, flint_rand_t state) diff --git a/src/sage/libs/flint/ca.pxd b/src/sage/libs/flint/ca.pxd index aa74c15459d..a4ba2618cad 100644 --- a/src/sage/libs/flint/ca.pxd +++ b/src/sage/libs/flint/ca.pxd @@ -185,7 +185,7 @@ cdef extern from "flint_wrap.h": # up to *den_bits* in size. This function requires that *x* is an # element of an absolute number field. - int ca_equal_repr(const ca_t x, const ca_t y, ca_ctx_t ctx) + bint ca_equal_repr(const ca_t x, const ca_t y, ca_ctx_t ctx) # Returns whether *x* and *y* have identical representation. For field # elements, this checks if *x* and *y* belong to the same formal field # (with generators having identical representation) and are represented by @@ -208,28 +208,28 @@ cdef extern from "flint_wrap.h": ulong ca_hash_repr(const ca_t x, ca_ctx_t ctx) # Hashes the representation of *x*. - int ca_is_unknown(const ca_t x, ca_ctx_t ctx) + bint ca_is_unknown(const ca_t x, ca_ctx_t ctx) # Returns whether *x* is Unknown. - int ca_is_special(const ca_t x, ca_ctx_t ctx) + bint ca_is_special(const ca_t x, ca_ctx_t ctx) # Returns whether *x* is a special value or metavalue # (not a field element). - int ca_is_qq_elem(const ca_t x, ca_ctx_t ctx) + bint ca_is_qq_elem(const ca_t x, ca_ctx_t ctx) # Returns whether *x* is represented as an element of the # rational field `\mathbb{Q}`. - int ca_is_qq_elem_zero(const ca_t x, ca_ctx_t ctx) - int ca_is_qq_elem_one(const ca_t x, ca_ctx_t ctx) - int ca_is_qq_elem_integer(const ca_t x, ca_ctx_t ctx) + bint ca_is_qq_elem_zero(const ca_t x, ca_ctx_t ctx) + bint ca_is_qq_elem_one(const ca_t x, ca_ctx_t ctx) + bint ca_is_qq_elem_integer(const ca_t x, ca_ctx_t ctx) # Returns whether *x* is represented as the element 0, 1 or # any integer in the rational field `\mathbb{Q}`. - int ca_is_nf_elem(const ca_t x, ca_ctx_t ctx) + bint ca_is_nf_elem(const ca_t x, ca_ctx_t ctx) # Returns whether *x* is represented as an element of a univariate # algebraic number field `\mathbb{Q}(a)`. - int ca_is_cyclotomic_nf_elem(slong * p, ulong * q, const ca_t x, ca_ctx_t ctx) + bint ca_is_cyclotomic_nf_elem(slong * p, ulong * q, const ca_t x, ca_ctx_t ctx) # Returns whether *x* is represented as an element of a univariate # cyclotomic field, i.e. `\mathbb{Q}(a)` where *a* is a root of unity. # If *p* and *q* are not *NULL* and *x* is represented as an @@ -244,7 +244,7 @@ cdef extern from "flint_wrap.h": # cyclotomic fields count; the return value is 0 if *x* # is represented as a rational number. - int ca_is_generic_elem(const ca_t x, ca_ctx_t ctx) + bint ca_is_generic_elem(const ca_t x, ca_ctx_t ctx) # Returns whether *x* is represented as a generic field element; # i.e. it is not a special value, not represented as # an element of the rational field, and not represented as diff --git a/src/sage/libs/flint/ca_ext.pxd b/src/sage/libs/flint/ca_ext.pxd index aab1a5cbdc3..8ea2f62cf88 100644 --- a/src/sage/libs/flint/ca_ext.pxd +++ b/src/sage/libs/flint/ca_ext.pxd @@ -50,7 +50,7 @@ cdef extern from "flint_wrap.h": ulong ca_ext_hash(const ca_ext_t x, ca_ctx_t ctx) # Returns a hash of the structural representation of *x*. - int ca_ext_equal_repr(const ca_ext_t x, const ca_ext_t y, ca_ctx_t ctx) + bint ca_ext_equal_repr(const ca_ext_t x, const ca_ext_t y, ca_ctx_t ctx) # Tests *x* and *y* for structural equality, returning 0 (false) or 1 (true). int ca_ext_cmp_repr(const ca_ext_t x, const ca_ext_t y, ca_ctx_t ctx) diff --git a/src/sage/libs/flint/ca_poly.pxd b/src/sage/libs/flint/ca_poly.pxd index c775c35a4db..00d4a4cd4b1 100644 --- a/src/sage/libs/flint/ca_poly.pxd +++ b/src/sage/libs/flint/ca_poly.pxd @@ -72,7 +72,7 @@ cdef extern from "flint_wrap.h": # Prints a decimal representation of *poly* with precision specified by *digits*. # The coefficients are comma-separated and the whole list is enclosed in square brackets. - int ca_poly_is_proper(const ca_poly_t poly, ca_ctx_t ctx) + bint ca_poly_is_proper(const ca_poly_t poly, ca_ctx_t ctx) # Checks that *poly* represents an element of `\mathbb{C}[X]` with # well-defined degree. This returns 1 if the leading coefficient # of *poly* is nonzero and all coefficients of *poly* are diff --git a/src/sage/libs/flint/ca_vec.pxd b/src/sage/libs/flint/ca_vec.pxd index df6ac842539..f392b36a8f6 100644 --- a/src/sage/libs/flint/ca_vec.pxd +++ b/src/sage/libs/flint/ca_vec.pxd @@ -96,10 +96,10 @@ cdef extern from "flint_wrap.h": truth_t _ca_vec_check_is_zero(ca_srcptr vec, slong len, ca_ctx_t ctx) # Returns whether *vec* is the zero vector. - int _ca_vec_is_fmpq_vec(ca_srcptr vec, slong len, ca_ctx_t ctx) + bint _ca_vec_is_fmpq_vec(ca_srcptr vec, slong len, ca_ctx_t ctx) # Checks if all elements of *vec* are structurally rational numbers. - int _ca_vec_fmpq_vec_is_fmpz_vec(ca_srcptr vec, slong len, ca_ctx_t ctx) + bint _ca_vec_fmpq_vec_is_fmpz_vec(ca_srcptr vec, slong len, ca_ctx_t ctx) # Assuming that all elements of *vec* are structurally rational numbers, # checks if all elements are integers. diff --git a/src/sage/libs/flint/d_mat.pxd b/src/sage/libs/flint/d_mat.pxd index a329b3d079b..dd735aa99f0 100644 --- a/src/sage/libs/flint/d_mat.pxd +++ b/src/sage/libs/flint/d_mat.pxd @@ -58,29 +58,29 @@ cdef extern from "flint_wrap.h": void d_mat_print(const d_mat_t mat) # Prints the given matrix to the stream ``stdout``. - int d_mat_equal(const d_mat_t mat1, const d_mat_t mat2) + bint d_mat_equal(const d_mat_t mat1, const d_mat_t mat2) # Returns a non-zero value if ``mat1`` and ``mat2`` have # the same dimensions and entries, and zero otherwise. - int d_mat_approx_equal(const d_mat_t mat1, const d_mat_t mat2, double eps) + bint d_mat_approx_equal(const d_mat_t mat1, const d_mat_t mat2, double eps) # Returns a non-zero value if ``mat1`` and ``mat2`` have # the same dimensions and entries within ``eps`` of each other, # and zero otherwise. - int d_mat_is_zero(const d_mat_t mat) + bint d_mat_is_zero(const d_mat_t mat) # Returns a non-zero value if all entries ``mat`` are zero, and # otherwise returns zero. - int d_mat_is_approx_zero(const d_mat_t mat, double eps) + bint d_mat_is_approx_zero(const d_mat_t mat, double eps) # Returns a non-zero value if all entries ``mat`` are zero to within # ``eps`` and otherwise returns zero. - int d_mat_is_empty(const d_mat_t mat) + bint d_mat_is_empty(const d_mat_t mat) # Returns a non-zero value if the number of rows or the number of # columns in ``mat`` is zero, and otherwise returns # zero. - int d_mat_is_square(const d_mat_t mat) + bint d_mat_is_square(const d_mat_t mat) # Returns a non-zero value if the number of rows is equal to the # number of columns in ``mat``, and otherwise returns zero. diff --git a/src/sage/libs/flint/d_vec.pxd b/src/sage/libs/flint/d_vec.pxd index bcd3ce07790..0da40b9ceb2 100644 --- a/src/sage/libs/flint/d_vec.pxd +++ b/src/sage/libs/flint/d_vec.pxd @@ -29,18 +29,18 @@ cdef extern from "flint_wrap.h": void _d_vec_zero(double * vec, slong len) # Zeros the entries of ``(vec, len)``. - int _d_vec_equal(const double * vec1, const double * vec2, slong len) + bint _d_vec_equal(const double * vec1, const double * vec2, slong len) # Compares two vectors of the given length and returns `1` if they are # equal, otherwise returns `0`. - int _d_vec_is_zero(const double * vec, slong len) + bint _d_vec_is_zero(const double * vec, slong len) # Returns `1` if ``(vec, len)`` is zero, and `0` otherwise. - int _d_vec_is_approx_zero(const double * vec, slong len, double eps) + bint _d_vec_is_approx_zero(const double * vec, slong len, double eps) # Returns `1` if the entries of ``(vec, len)`` are zero to within # ``eps``, and `0` otherwise. - int _d_vec_approx_equal(const double * vec1, const double * vec2, slong len, double eps) + bint _d_vec_approx_equal(const double * vec1, const double * vec2, slong len, double eps) # Compares two vectors of the given length and returns `1` if their entries # are within ``eps`` of each other, otherwise returns `0`. diff --git a/src/sage/libs/flint/dirichlet.pxd b/src/sage/libs/flint/dirichlet.pxd index daaeb6d5bcb..b96b2fefc0b 100644 --- a/src/sage/libs/flint/dirichlet.pxd +++ b/src/sage/libs/flint/dirichlet.pxd @@ -100,11 +100,11 @@ cdef extern from "flint_wrap.h": void dirichlet_char_index(dirichlet_char_t x, const dirichlet_group_t G, ulong j) # Sets *x* to the character whose *log* has lexicographic index *j*. - int dirichlet_char_eq(const dirichlet_char_t x, const dirichlet_char_t y) + bint dirichlet_char_eq(const dirichlet_char_t x, const dirichlet_char_t y) int dirichlet_char_eq_deep(const dirichlet_group_t G, const dirichlet_char_t x, const dirichlet_char_t y) - int dirichlet_char_is_principal(const dirichlet_group_t G, const dirichlet_char_t chi) + bint dirichlet_char_is_principal(const dirichlet_group_t G, const dirichlet_char_t chi) ulong dirichlet_conductor_ui(const dirichlet_group_t G, ulong a) @@ -118,9 +118,9 @@ cdef extern from "flint_wrap.h": ulong dirichlet_order_char(const dirichlet_group_t G, const dirichlet_char_t x) - int dirichlet_char_is_real(const dirichlet_group_t G, const dirichlet_char_t chi) + bint dirichlet_char_is_real(const dirichlet_group_t G, const dirichlet_char_t chi) - int dirichlet_char_is_primitive(const dirichlet_group_t G, const dirichlet_char_t chi) + bint dirichlet_char_is_primitive(const dirichlet_group_t G, const dirichlet_char_t chi) ulong dirichlet_pairing(const dirichlet_group_t G, ulong m, ulong n) diff --git a/src/sage/libs/flint/double_extras.pxd b/src/sage/libs/flint/double_extras.pxd index f5b03b45b74..2505ea963e3 100644 --- a/src/sage/libs/flint/double_extras.pxd +++ b/src/sage/libs/flint/double_extras.pxd @@ -42,7 +42,7 @@ cdef extern from "flint_wrap.h": # However, accuracy may be worse depending on compiler flags and # the accuracy of the system libm functions. - int d_is_nan(double x) + bint d_is_nan(double x) # Returns a nonzero integral value if ``x`` is ``D_NAN``, and otherwise # returns 0. diff --git a/src/sage/libs/flint/fexpr.pxd b/src/sage/libs/flint/fexpr.pxd index de11cc6f458..c9bf6c5b11a 100644 --- a/src/sage/libs/flint/fexpr.pxd +++ b/src/sage/libs/flint/fexpr.pxd @@ -57,12 +57,12 @@ cdef extern from "flint_wrap.h": # structure itself. Add ``sizeof(fexpr_struct)`` to get the size of # the object as a whole. - int fexpr_equal(const fexpr_t a, const fexpr_t b) + bint fexpr_equal(const fexpr_t a, const fexpr_t b) # Checks if *a* and *b* are exactly equal as expressions. - int fexpr_equal_si(const fexpr_t expr, slong c) + bint fexpr_equal_si(const fexpr_t expr, slong c) - int fexpr_equal_ui(const fexpr_t expr, ulong c) + bint fexpr_equal_ui(const fexpr_t expr, ulong c) # Checks if *expr* is an atomic integer exactly equal to *c*. ulong fexpr_hash(const fexpr_t expr) @@ -74,25 +74,25 @@ cdef extern from "flint_wrap.h": # instance, to maintain sorted arrays of expressions for binary # search; the sort order has no mathematical significance. - int fexpr_is_integer(const fexpr_t expr) + bint fexpr_is_integer(const fexpr_t expr) # Returns whether *expr* is an atomic integer - int fexpr_is_symbol(const fexpr_t expr) + bint fexpr_is_symbol(const fexpr_t expr) # Returns whether *expr* is an atomic symbol. - int fexpr_is_string(const fexpr_t expr) + bint fexpr_is_string(const fexpr_t expr) # Returns whether *expr* is an atomic string. - int fexpr_is_atom(const fexpr_t expr) + bint fexpr_is_atom(const fexpr_t expr) # Returns whether *expr* is any atom. void fexpr_zero(fexpr_t res) # Sets *res* to the atomic integer 0. - int fexpr_is_zero(const fexpr_t expr) + bint fexpr_is_zero(const fexpr_t expr) # Returns whether *expr* is the atomic integer 0. - int fexpr_is_neg_integer(const fexpr_t expr) + bint fexpr_is_neg_integer(const fexpr_t expr) # Returns whether *expr* is any negative atomic integer. void fexpr_set_si(fexpr_t res, slong c) @@ -108,11 +108,11 @@ cdef extern from "flint_wrap.h": # Sets *res* to the builtin symbol with internal index *id* # (see :ref:`fexpr-builtin`). - int fexpr_is_builtin_symbol(const fexpr_t expr, slong id) + bint fexpr_is_builtin_symbol(const fexpr_t expr, slong id) # Returns whether *expr* is the builtin symbol with index *id* # (see :ref:`fexpr-builtin`). - int fexpr_is_any_builtin_symbol(const fexpr_t expr) + bint fexpr_is_any_builtin_symbol(const fexpr_t expr) # Returns whether *expr* is any builtin symbol # (see :ref:`fexpr-builtin`). @@ -193,11 +193,11 @@ cdef extern from "flint_wrap.h": # This function can also be called when *view* refers to the function *f*, # in which case it will make *view* point to `e_1`. - int fexpr_is_builtin_call(const fexpr_t expr, slong id) + bint fexpr_is_builtin_call(const fexpr_t expr, slong id) # Returns whether *expr* has the form `f(\ldots)` where *f* is # a builtin function defined by *id* (see :ref:`fexpr-builtin`). - int fexpr_is_any_builtin_call(const fexpr_t expr) + bint fexpr_is_any_builtin_call(const fexpr_t expr) # Returns whether *expr* has the form `f(\ldots)` where *f* is # any builtin function (see :ref:`fexpr-builtin`). @@ -217,7 +217,7 @@ cdef extern from "flint_wrap.h": # Creates the function call `f(x_1,\ldots,x_n)`, where *f* defines # a builtin symbol. - int fexpr_contains(const fexpr_t expr, const fexpr_t x) + bint fexpr_contains(const fexpr_t expr, const fexpr_t x) # Returns whether *expr* contains the expression *x* as a subexpression # (this includes the case where *expr* and *x* are equal). @@ -267,7 +267,7 @@ cdef extern from "flint_wrap.h": # Constructs an arithmetic expression with given arguments. # No simplifications whatsoever are performed. - int fexpr_is_arithmetic_operation(const fexpr_t expr) + bint fexpr_is_arithmetic_operation(const fexpr_t expr) # Returns whether *expr* is of the form `f(e_1,\ldots,e_n)` # where *f* is one of the arithmetic operators ``Pos``, ``Neg``, # ``Add``, ``Sub``, ``Mul``, ``Div``. diff --git a/src/sage/libs/flint/fmpq.pxd b/src/sage/libs/flint/fmpq.pxd index 7779c1f2dd2..811287875c3 100644 --- a/src/sage/libs/flint/fmpq.pxd +++ b/src/sage/libs/flint/fmpq.pxd @@ -36,11 +36,11 @@ cdef extern from "flint_wrap.h": # and denominator given explicitly as ``fmpz_t`` variables. Aliasing # of ``num`` and ``den`` is not allowed. - int fmpq_is_canonical(const fmpq_t x) + bint fmpq_is_canonical(const fmpq_t x) # Returns nonzero if ``fmpq_t`` x is in canonical form # (as produced by ``fmpq_canonicalise``), and zero otherwise. - int _fmpq_is_canonical(const fmpz_t num, const fmpz_t den) + bint _fmpq_is_canonical(const fmpz_t num, const fmpz_t den) # Does the same thing as ``fmpq_is_canonical``, but for numerator # and denominator given explicitly as ``fmpz_t`` variables. @@ -63,16 +63,16 @@ cdef extern from "flint_wrap.h": void fmpq_one(fmpq_t res) # Sets the value of ``res`` to `1`. - int fmpq_is_zero(const fmpq_t res) + bint fmpq_is_zero(const fmpq_t res) # Returns nonzero if ``res`` has value 0, and returns zero otherwise. - int fmpq_is_one(const fmpq_t res) + bint fmpq_is_one(const fmpq_t res) # Returns nonzero if ``res`` has value `1`, and returns zero otherwise. - int fmpq_is_pm1(const fmpq_t res) + bint fmpq_is_pm1(const fmpq_t res) # Returns nonzero if ``res`` has value `\pm{1}` and zero otherwise. - int fmpq_equal(const fmpq_t x, const fmpq_t y) + bint fmpq_equal(const fmpq_t x, const fmpq_t y) # Returns nonzero if ``x`` and ``y`` are equal, and zero otherwise. # Assumes that ``x`` and ``y`` are both in canonical form. @@ -87,10 +87,10 @@ cdef extern from "flint_wrap.h": int fmpq_cmp_si(const fmpq_t x, slong y) # Returns negative if `x < y`, zero if `x = y`, and positive if `x > y`. - int fmpq_equal_ui(fmpq_t x, ulong y) + bint fmpq_equal_ui(fmpq_t x, ulong y) # Returns `1` if `x = y`, otherwise returns `0`. - int fmpq_equal_si(fmpq_t x, slong y) + bint fmpq_equal_si(fmpq_t x, slong y) # Returns `1` if `x = y`, otherwise returns `0`. void fmpq_height(fmpz_t height, const fmpq_t x) diff --git a/src/sage/libs/flint/fmpq_mat.pxd b/src/sage/libs/flint/fmpq_mat.pxd index 0f56efaf4ab..1764be93cba 100644 --- a/src/sage/libs/flint/fmpq_mat.pxd +++ b/src/sage/libs/flint/fmpq_mat.pxd @@ -152,30 +152,30 @@ cdef extern from "flint_wrap.h": # Sets ``mat`` to a Hilbert matrix of the given size. That is, # the entry at row `i` and column `j` is set to `1/(i+j+1)`. - int fmpq_mat_equal(const fmpq_mat_t mat1, const fmpq_mat_t mat2) + bint fmpq_mat_equal(const fmpq_mat_t mat1, const fmpq_mat_t mat2) # Returns nonzero if ``mat1`` and ``mat2`` have the same shape and # all their entries agree, and returns zero otherwise. Assumes the # entries in both ``mat1`` and ``mat2`` are in canonical form. - int fmpq_mat_is_integral(const fmpq_mat_t mat) + bint fmpq_mat_is_integral(const fmpq_mat_t mat) # Returns nonzero if all entries in ``mat`` are integer-valued, and # returns zero otherwise. Assumes that the entries in ``mat`` # are in canonical form. - int fmpq_mat_is_zero(const fmpq_mat_t mat) + bint fmpq_mat_is_zero(const fmpq_mat_t mat) # Returns nonzero if all entries in ``mat`` are zero, and returns # zero otherwise. - int fmpq_mat_is_one(const fmpq_mat_t mat) + bint fmpq_mat_is_one(const fmpq_mat_t mat) # Returns nonzero if ``mat`` ones along the diagonal and zeros elsewhere, # and returns zero otherwise. - int fmpq_mat_is_empty(const fmpq_mat_t mat) + bint fmpq_mat_is_empty(const fmpq_mat_t mat) # Returns a non-zero value if the number of rows or the number of # columns in ``mat`` is zero, and otherwise returns # zero. - int fmpq_mat_is_square(const fmpq_mat_t mat) + bint fmpq_mat_is_square(const fmpq_mat_t mat) # Returns a non-zero value if the number of rows is equal to the # number of columns in ``mat``, and otherwise returns zero. diff --git a/src/sage/libs/flint/fmpq_mpoly.pxd b/src/sage/libs/flint/fmpq_mpoly.pxd index 1db7bd271ab..d40a28e9336 100644 --- a/src/sage/libs/flint/fmpq_mpoly.pxd +++ b/src/sage/libs/flint/fmpq_mpoly.pxd @@ -67,20 +67,20 @@ cdef extern from "flint_wrap.h": void fmpq_mpoly_gen(fmpq_mpoly_t A, slong var, const fmpq_mpoly_ctx_t ctx) # Set *A* to the variable of index *var*, where ``var = 0`` corresponds to the variable with the most significance with respect to the ordering. - int fmpq_mpoly_is_gen(const fmpq_mpoly_t A, slong var, const fmpq_mpoly_ctx_t ctx) + bint fmpq_mpoly_is_gen(const fmpq_mpoly_t A, slong var, const fmpq_mpoly_ctx_t ctx) # If `var \ge 0`, return `1` if *A* is equal to the `var`-th generator, otherwise return `0`. # If `var < 0`, return `1` if the polynomial is equal to any generator, otherwise return `0`. void fmpq_mpoly_set(fmpq_mpoly_t A, const fmpq_mpoly_t B, const fmpq_mpoly_ctx_t ctx) # Set *A* to *B*. - int fmpq_mpoly_equal(const fmpq_mpoly_t A, const fmpq_mpoly_t B, const fmpq_mpoly_ctx_t ctx) + bint fmpq_mpoly_equal(const fmpq_mpoly_t A, const fmpq_mpoly_t B, const fmpq_mpoly_ctx_t ctx) # Return `1` if *A* is equal to *B*, else return `0`. void fmpq_mpoly_swap(fmpq_mpoly_t A, fmpq_mpoly_t B, const fmpq_mpoly_ctx_t ctx) # Efficiently swap *A* and *B*. - int fmpq_mpoly_is_fmpq(const fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx) + bint fmpq_mpoly_is_fmpq(const fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx) # Return `1` if *A* is a constant, else return `0`. void fmpq_mpoly_get_fmpq(fmpq_t c, const fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx) @@ -99,16 +99,16 @@ cdef extern from "flint_wrap.h": void fmpq_mpoly_one(fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx) # Set *A* to the constant `1`. - int fmpq_mpoly_equal_fmpq(const fmpq_mpoly_t A, const fmpq_t c, const fmpq_mpoly_ctx_t ctx) - int fmpq_mpoly_equal_fmpz(const fmpq_mpoly_t A, const fmpz_t c, const fmpq_mpoly_ctx_t ctx) - int fmpq_mpoly_equal_ui(const fmpq_mpoly_t A, ulong c, const fmpq_mpoly_ctx_t ctx) - int fmpq_mpoly_equal_si(const fmpq_mpoly_t A, slong c, const fmpq_mpoly_ctx_t ctx) + bint fmpq_mpoly_equal_fmpq(const fmpq_mpoly_t A, const fmpq_t c, const fmpq_mpoly_ctx_t ctx) + bint fmpq_mpoly_equal_fmpz(const fmpq_mpoly_t A, const fmpz_t c, const fmpq_mpoly_ctx_t ctx) + bint fmpq_mpoly_equal_ui(const fmpq_mpoly_t A, ulong c, const fmpq_mpoly_ctx_t ctx) + bint fmpq_mpoly_equal_si(const fmpq_mpoly_t A, slong c, const fmpq_mpoly_ctx_t ctx) # Return `1` if *A* is equal to the constant *c*, else return `0`. - int fmpq_mpoly_is_zero(const fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx) + bint fmpq_mpoly_is_zero(const fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx) # Return `1` if *A* is equal to the constant `0`, else return `0`. - int fmpq_mpoly_is_one(const fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx) + bint fmpq_mpoly_is_one(const fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx) # Return `1` if *A* is equal to the constant `1`, else return `0`. int fmpq_mpoly_degrees_fit_si(const fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx) @@ -171,7 +171,7 @@ cdef extern from "flint_wrap.h": fmpz * fmpq_mpoly_zpoly_term_coeff_ref(fmpq_mpoly_t A, slong i, const fmpq_mpoly_ctx_t ctx) # Return a reference to the coefficient of index *i* of the integer polynomial of *A*. - int fmpq_mpoly_is_canonical(const fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx) + bint fmpq_mpoly_is_canonical(const fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx) # Return `1` if *A* is in canonical form. Otherwise, return `0`. # An ``fmpq_mpoly_t`` is represented as the product of an ``fmpq_t content`` and an ``fmpz_mpoly_t zpoly``. # The representation is considered canonical when either @@ -388,7 +388,7 @@ cdef extern from "flint_wrap.h": # If *A* is a perfect square return `1` and set *Q* to the square root # with positive leading coefficient. Otherwise return `0` and set *Q* to zero. - int fmpq_mpoly_is_square(const fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx) + bint fmpq_mpoly_is_square(const fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx) # Return `1` if *A* is a perfect square, otherwise return `0`. void fmpq_mpoly_univar_init(fmpq_mpoly_univar_t A, const fmpq_mpoly_ctx_t ctx) diff --git a/src/sage/libs/flint/fmpq_poly.pxd b/src/sage/libs/flint/fmpq_poly.pxd index 24c9ef46658..7e570d11a2a 100644 --- a/src/sage/libs/flint/fmpq_poly.pxd +++ b/src/sage/libs/flint/fmpq_poly.pxd @@ -65,10 +65,10 @@ cdef extern from "flint_wrap.h": # coprime and that the denominator is positive. The canonical form of the # zero polynomial is a zero numerator polynomial and a one denominator. - int _fmpq_poly_is_canonical(const fmpz * poly, const fmpz_t den, slong len) + bint _fmpq_poly_is_canonical(const fmpz * poly, const fmpz_t den, slong len) # Returns whether the polynomial is in canonical form. - int fmpq_poly_is_canonical(const fmpq_poly_t poly) + bint fmpq_poly_is_canonical(const fmpq_poly_t poly) # Returns whether the polynomial is in canonical form. slong fmpq_poly_degree(const fmpq_poly_t poly) @@ -234,15 +234,15 @@ cdef extern from "flint_wrap.h": void fmpq_poly_set_coeff_fmpq(fmpq_poly_t poly, slong n, const fmpq_t x) # Sets the `n`\th coefficient in ``poly`` to the rational `x`. - int fmpq_poly_equal(const fmpq_poly_t poly1, const fmpq_poly_t poly2) + bint fmpq_poly_equal(const fmpq_poly_t poly1, const fmpq_poly_t poly2) # Returns `1` if ``poly1`` is equal to ``poly2``, # otherwise returns `0`. - int _fmpq_poly_equal_trunc(const fmpz * poly1, const fmpz_t den1, slong len1, const fmpz * poly2, const fmpz_t den2, slong len2, slong n) + bint _fmpq_poly_equal_trunc(const fmpz * poly1, const fmpz_t den1, slong len1, const fmpz * poly2, const fmpz_t den2, slong len2, slong n) # Returns `1` if ``poly1`` and ``poly2`` notionally truncated to length # `n` are equal, otherwise returns `0`. - int fmpq_poly_equal_trunc(const fmpq_poly_t poly1, const fmpq_poly_t poly2, slong n) + bint fmpq_poly_equal_trunc(const fmpq_poly_t poly1, const fmpq_poly_t poly2, slong n) # Returns `1` if ``poly1`` and ``poly2`` notionally truncated to length # `n` are equal, otherwise returns `0`. @@ -259,14 +259,14 @@ cdef extern from "flint_wrap.h": # then, in case of a tie, by the individual coefficients from highest # to lowest. - int fmpq_poly_is_one(const fmpq_poly_t poly) + bint fmpq_poly_is_one(const fmpq_poly_t poly) # Returns `1` if ``poly`` is the constant polynomial `1`, otherwise # returns `0`. - int fmpq_poly_is_zero(const fmpq_poly_t poly) + bint fmpq_poly_is_zero(const fmpq_poly_t poly) # Returns `1` if ``poly`` is the zero polynomial, otherwise returns `0`. - int fmpq_poly_is_gen(const fmpq_poly_t poly) + bint fmpq_poly_is_gen(const fmpq_poly_t poly) # Returns `1` if ``poly`` is the degree `1` polynomial `x`, otherwise returns # `0`. @@ -1174,11 +1174,11 @@ cdef extern from "flint_wrap.h": # Sets ``res`` to the primitive part, with non-negative leading # coefficient, of ``poly``. - int _fmpq_poly_is_monic(const fmpz * poly, const fmpz_t den, slong len) + bint _fmpq_poly_is_monic(const fmpz * poly, const fmpz_t den, slong len) # Returns whether the polynomial ``(poly, den, len)`` is monic. # The zero polynomial is not monic by definition. - int fmpq_poly_is_monic(const fmpq_poly_t poly) + bint fmpq_poly_is_monic(const fmpq_poly_t poly) # Returns whether the polynomial ``poly`` is monic. The zero # polynomial is not monic by definition. @@ -1192,7 +1192,7 @@ cdef extern from "flint_wrap.h": # ``poly`` is non-zero. If ``poly`` is the zero polynomial, sets # ``res`` to zero. - int fmpq_poly_is_squarefree(const fmpq_poly_t poly) + bint fmpq_poly_is_squarefree(const fmpq_poly_t poly) # Returns whether the polynomial ``poly`` is square-free. A non-zero # polynomial is defined to be square-free if it has no non-unit square # factors. We also define the zero polynomial to be square-free. diff --git a/src/sage/libs/flint/fmpz.pxd b/src/sage/libs/flint/fmpz.pxd index 38d7407de33..adcb826706a 100644 --- a/src/sage/libs/flint/fmpz.pxd +++ b/src/sage/libs/flint/fmpz.pxd @@ -417,26 +417,26 @@ cdef extern from "flint_wrap.h": # Returns a negative value if `\lvert f\rvert < \lvert 2g\rvert`, positive value if # `\lvert 2g\rvert < \lvert f \rvert`, otherwise returns `0`. - int fmpz_equal(const fmpz_t f, const fmpz_t g) + bint fmpz_equal(const fmpz_t f, const fmpz_t g) - int fmpz_equal_ui(const fmpz_t f, ulong g) + bint fmpz_equal_ui(const fmpz_t f, ulong g) - int fmpz_equal_si(const fmpz_t f, slong g) + bint fmpz_equal_si(const fmpz_t f, slong g) # Returns `1` if `f` is equal to `g`, otherwise returns `0`. - int fmpz_is_zero(const fmpz_t f) + bint fmpz_is_zero(const fmpz_t f) # Returns `1` if `f` is `0`, otherwise returns `0`. - int fmpz_is_one(const fmpz_t f) + bint fmpz_is_one(const fmpz_t f) # Returns `1` if `f` is equal to one, otherwise returns `0`. - int fmpz_is_pm1(const fmpz_t f) + bint fmpz_is_pm1(const fmpz_t f) # Returns `1` if `f` is equal to one or minus one, otherwise returns `0`. - int fmpz_is_even(const fmpz_t f) + bint fmpz_is_even(const fmpz_t f) # Returns whether the integer `f` is even. - int fmpz_is_odd(const fmpz_t f) + bint fmpz_is_odd(const fmpz_t f) # Returns whether the integer `f` is odd. void fmpz_neg(fmpz_t f1, const fmpz_t f2) @@ -642,7 +642,7 @@ cdef extern from "flint_wrap.h": # the difference `g - f^2`. If `g` is negative, an exception is raised. # The behaviour is undefined if `f` and `r` are aliases. - int fmpz_is_square(const fmpz_t f) + bint fmpz_is_square(const fmpz_t f) # Returns nonzero if `f` is a perfect square and zero otherwise. int fmpz_root(fmpz_t r, const fmpz_t f, slong n) @@ -651,7 +651,7 @@ cdef extern from "flint_wrap.h": # exception is raised. The function returns `1` if the root was exact, # otherwise `0`. - int fmpz_is_perfect_power(fmpz_t root, const fmpz_t f) + bint fmpz_is_perfect_power(fmpz_t root, const fmpz_t f) # If `f` is a perfect power `r^k` set ``root`` to `r` and return `k`, # otherwise return `0`. Note that `-1, 0, 1` are all considered perfect # powers. No guarantee is made about `r` or `k` being the smallest @@ -917,17 +917,17 @@ cdef extern from "flint_wrap.h": void fmpz_multi_CRT_clear(fmpz_multi_CRT_t P) # Free all space used by ``CRT``. - int fmpz_is_strong_probabprime(const fmpz_t n, const fmpz_t a) + bint fmpz_is_strong_probabprime(const fmpz_t n, const fmpz_t a) # Returns `1` if `n` is a strong probable prime to base `a`, otherwise it # returns `0`. - int fmpz_is_probabprime_lucas(const fmpz_t n) + bint fmpz_is_probabprime_lucas(const fmpz_t n) # Performs a Lucas probable prime test with parameters chosen by Selfridge's # method `A` as per [BaiWag1980]_. # Return `1` if `n` is a Lucas probable prime, otherwise return `0`. This # function declares some composites probably prime, but no primes composite. - int fmpz_is_probabprime_BPSW(const fmpz_t n) + bint fmpz_is_probabprime_BPSW(const fmpz_t n) # Perform a Baillie-PSW probable prime test with parameters chosen by # Selfridge's method `A` as per [BaiWag1980]_. # Return `1` if `n` is a Lucas probable prime, otherwise return `0`. @@ -935,7 +935,7 @@ cdef extern from "flint_wrap.h": # infinitely many probably exist. The test will declare no primes # composite. - int fmpz_is_probabprime(const fmpz_t p) + bint fmpz_is_probabprime(const fmpz_t p) # Performs some trial division and then some probabilistic primality tests. # If `p` is definitely composite, the function returns `0`, otherwise it # is declared probably prime, i.e. prime for most practical purposes, and @@ -944,7 +944,7 @@ cdef extern from "flint_wrap.h": # Subsequent calls to the same function do not increase the probability of # the number being prime. - int fmpz_is_prime_pseudosquare(const fmpz_t n) + bint fmpz_is_prime_pseudosquare(const fmpz_t n) # Return `0` is `n` is composite. If `n` is too large (greater than about # `94` bits) the function fails silently and returns `-1`, otherwise, if # `n` is proven prime by the pseudosquares method, return `1`. @@ -973,7 +973,7 @@ cdef extern from "flint_wrap.h": # composite prime. However in that case an error is printed, as # that would be of independent interest. - int fmpz_is_prime_pocklington(fmpz_t F, fmpz_t R, const fmpz_t n, mp_ptr pm1, slong num_pm1) + bint fmpz_is_prime_pocklington(fmpz_t F, fmpz_t R, const fmpz_t n, mp_ptr pm1, slong num_pm1) # Applies the Pocklington primality test. The test computes a product # `F` of prime powers which divide `n - 1`. # The function then returns either `0` if `n` is definitely composite @@ -1001,7 +1001,7 @@ cdef extern from "flint_wrap.h": # be produced (and hence on the length of the array that needs to be # supplied). - int fmpz_is_prime_morrison(fmpz_t F, fmpz_t R, const fmpz_t n, mp_ptr pp1, slong num_pp1) + bint fmpz_is_prime_morrison(fmpz_t F, fmpz_t R, const fmpz_t n, mp_ptr pp1, slong num_pp1) # Applies the Morrison `p + 1` primality test. The test computes a # product `F` of primes which divide `n + 1`. # The function then returns either `0` if `n` is definitely composite @@ -1030,7 +1030,7 @@ cdef extern from "flint_wrap.h": # be produced (and hence on the length of the array that needs to be # supplied). - int fmpz_is_prime(const fmpz_t n) + bint fmpz_is_prime(const fmpz_t n) # Attempts to prove `n` prime. If `n` is proven prime, the function # returns `1`. If `n` is definitely composite, the function returns `0`. # This function calls :func:`n_is_prime` for `n` that fits in a single word. diff --git a/src/sage/libs/flint/fmpz_lll.pxd b/src/sage/libs/flint/fmpz_lll.pxd index 9b73ceeadf4..6e46a35a9cd 100644 --- a/src/sage/libs/flint/fmpz_lll.pxd +++ b/src/sage/libs/flint/fmpz_lll.pxd @@ -197,18 +197,18 @@ cdef extern from "flint_wrap.h": # transformations, while ``gs_B`` and ``fl`` have the same role as in # the previous routines. The function is optimised for factoring polynomials. - int fmpz_lll_is_reduced_d(const fmpz_mat_t B, const fmpz_lll_t fl) - int fmpz_lll_is_reduced_mpfr(const fmpz_mat_t B, const fmpz_lll_t fl, flint_bitcnt_t prec) - int fmpz_lll_is_reduced_d_with_removal(const fmpz_mat_t B, const fmpz_lll_t fl, const fmpz_t gs_B, int newd) - int fmpz_lll_is_reduced_mpfr_with_removal(const fmpz_mat_t B, const fmpz_lll_t fl, const fmpz_t gs_B, int newd, flint_bitcnt_t prec) + bint fmpz_lll_is_reduced_d(const fmpz_mat_t B, const fmpz_lll_t fl) + bint fmpz_lll_is_reduced_mpfr(const fmpz_mat_t B, const fmpz_lll_t fl, flint_bitcnt_t prec) + bint fmpz_lll_is_reduced_d_with_removal(const fmpz_mat_t B, const fmpz_lll_t fl, const fmpz_t gs_B, int newd) + bint fmpz_lll_is_reduced_mpfr_with_removal(const fmpz_mat_t B, const fmpz_lll_t fl, const fmpz_t gs_B, int newd, flint_bitcnt_t prec) # A non-zero return indicates the matrix is definitely reduced, that is, that # * :func:`fmpz_mat_is_reduced` or :func:`fmpz_mat_is_reduced_gram` (for the first two) # * :func:`fmpz_mat_is_reduced_with_removal` or :func:`fmpz_mat_is_reduced_gram_with_removal` (for the last two) # return non-zero. A zero return value is inconclusive. # The `_d` variants are performed in machine precision, while the `_mpfr` uses a precision of `prec` bits. - int fmpz_lll_is_reduced(const fmpz_mat_t B, const fmpz_lll_t fl, flint_bitcnt_t prec) - int fmpz_lll_is_reduced_with_removal(const fmpz_mat_t B, const fmpz_lll_t fl, const fmpz_t gs_B, int newd, flint_bitcnt_t prec) + bint fmpz_lll_is_reduced(const fmpz_mat_t B, const fmpz_lll_t fl, flint_bitcnt_t prec) + bint fmpz_lll_is_reduced_with_removal(const fmpz_mat_t B, const fmpz_lll_t fl, const fmpz_t gs_B, int newd, flint_bitcnt_t prec) # The return from these functions is always conclusive: the functions # * :func:`fmpz_mat_is_reduced` or :func:`fmpz_mat_is_reduced_gram` # * :func:`fmpz_mat_is_reduced_with_removal` or :func:`fmpz_mat_is_reduced_gram_with_removal` diff --git a/src/sage/libs/flint/fmpz_mat.pxd b/src/sage/libs/flint/fmpz_mat.pxd index e116c2667d7..5641d01e5f3 100644 --- a/src/sage/libs/flint/fmpz_mat.pxd +++ b/src/sage/libs/flint/fmpz_mat.pxd @@ -204,35 +204,35 @@ cdef extern from "flint_wrap.h": # In case of success, returns a positive number. In case of failure, # returns a non-positive value. - int fmpz_mat_equal(const fmpz_mat_t mat1, const fmpz_mat_t mat2) + bint fmpz_mat_equal(const fmpz_mat_t mat1, const fmpz_mat_t mat2) # Returns a non-zero value if ``mat1`` and ``mat2`` have # the same dimensions and entries, and zero otherwise. - int fmpz_mat_is_zero(const fmpz_mat_t mat) + bint fmpz_mat_is_zero(const fmpz_mat_t mat) # Returns a non-zero value if all entries ``mat`` are zero, and # otherwise returns zero. - int fmpz_mat_is_one(const fmpz_mat_t mat) + bint fmpz_mat_is_one(const fmpz_mat_t mat) # Returns a non-zero value if ``mat`` is the unit matrix or the truncation # of a unit matrix, and otherwise returns zero. - int fmpz_mat_is_empty(const fmpz_mat_t mat) + bint fmpz_mat_is_empty(const fmpz_mat_t mat) # Returns a non-zero value if the number of rows or the number of # columns in ``mat`` is zero, and otherwise returns # zero. - int fmpz_mat_is_square(const fmpz_mat_t mat) + bint fmpz_mat_is_square(const fmpz_mat_t mat) # Returns a non-zero value if the number of rows is equal to the # number of columns in ``mat``, and otherwise returns zero. - int fmpz_mat_is_zero_row(const fmpz_mat_t mat, slong i) + bint fmpz_mat_is_zero_row(const fmpz_mat_t mat, slong i) # Returns a non-zero value if row `i` of ``mat`` is zero. - int fmpz_mat_equal_col(fmpz_mat_t M, slong m, slong n) + bint fmpz_mat_equal_col(fmpz_mat_t M, slong m, slong n) # Returns `1` if columns `m` and `n` of the matrix `M` are equal, otherwise # returns `0`. - int fmpz_mat_equal_row(fmpz_mat_t M, slong m, slong n) + bint fmpz_mat_equal_row(fmpz_mat_t M, slong m, slong n) # Returns `1` if rows `m` and `n` of the matrix `M` are equal, otherwise # returns `0`. @@ -761,7 +761,7 @@ cdef extern from "flint_wrap.h": # the reduced row echelon form of the whole of ``A``. This procedure is # described in [Stein2007]_. - int fmpz_mat_is_in_rref_with_rank(const fmpz_mat_t A, const fmpz_t den, slong rank) + bint fmpz_mat_is_in_rref_with_rank(const fmpz_mat_t A, const fmpz_t den, slong rank) # Checks that the matrix `A/den` is in reduced row echelon form of rank # ``rank``, returns 1 if so and 0 otherwise. @@ -877,7 +877,7 @@ cdef extern from "flint_wrap.h": # Aliasing of ``H`` and ``A`` is allowed. The size of ``H`` must be # the same as that of ``A``. - int fmpz_mat_is_in_hnf(const fmpz_mat_t A) + bint fmpz_mat_is_in_hnf(const fmpz_mat_t A) # Checks that the given matrix is in Hermite normal form, returns 1 if so and # 0 otherwise. @@ -910,7 +910,7 @@ cdef extern from "flint_wrap.h": # Aliasing of ``S`` and ``A`` is allowed. The size of ``S`` must be # the same as that of ``A``. - int fmpz_mat_is_in_snf(const fmpz_mat_t A) + bint fmpz_mat_is_in_snf(const fmpz_mat_t A) # Checks that the given matrix is in Smith normal form, returns 1 if so and 0 # otherwise. @@ -921,7 +921,7 @@ cdef extern from "flint_wrap.h": # ``A`` and ``B`` are allowed to be the same object if ``A`` is a # square matrix. - int fmpz_mat_is_hadamard(const fmpz_mat_t H) + bint fmpz_mat_is_hadamard(const fmpz_mat_t H) # Returns nonzero iff `H` is a Hadamard matrix, meaning # that it is a square matrix, only has entries that are `\pm 1`, # and satisfies `H^T = n H^{-1}` where `n` is the matrix size. @@ -955,14 +955,14 @@ cdef extern from "flint_wrap.h": # matrix ``A`` using the Cholesky decomposition process. (Sets ``R`` # such that `A = RR^{T}` where ``R`` is a lower triangular matrix.) - int fmpz_mat_is_reduced(const fmpz_mat_t A, double delta, double eta) - int fmpz_mat_is_reduced_gram(const fmpz_mat_t A, double delta, double eta) + bint fmpz_mat_is_reduced(const fmpz_mat_t A, double delta, double eta) + bint fmpz_mat_is_reduced_gram(const fmpz_mat_t A, double delta, double eta) # Returns a non-zero value if the basis ``A`` is LLL-reduced with factor # (``delta``, ``eta``), and otherwise returns zero. # The second version assumes ``A`` is the Gram matrix of the basis. - int fmpz_mat_is_reduced_with_removal(const fmpz_mat_t A, double delta, double eta, const fmpz_t gs_B, int newd) - int fmpz_mat_is_reduced_gram_with_removal(const fmpz_mat_t A, double delta, double eta, const fmpz_t gs_B, int newd) + bint fmpz_mat_is_reduced_with_removal(const fmpz_mat_t A, double delta, double eta, const fmpz_t gs_B, int newd) + bint fmpz_mat_is_reduced_gram_with_removal(const fmpz_mat_t A, double delta, double eta, const fmpz_t gs_B, int newd) # Returns a non-zero value if the basis ``A`` is LLL-reduced with factor # (``delta``, ``eta``) for each of the first ``newd`` vectors and the squared # Gram-Schmidt length of each of the remaining `i`-th vectors diff --git a/src/sage/libs/flint/fmpz_mod.pxd b/src/sage/libs/flint/fmpz_mod.pxd index 12110dffb05..4fe576901d8 100644 --- a/src/sage/libs/flint/fmpz_mod.pxd +++ b/src/sage/libs/flint/fmpz_mod.pxd @@ -24,10 +24,10 @@ cdef extern from "flint_wrap.h": void fmpz_mod_set_fmpz(fmpz_t a, const fmpz_t b, const fmpz_mod_ctx_t ctx) # Set ``a`` to ``b`` after reduction modulo the modulus. - int fmpz_mod_is_canonical(const fmpz_t a, const fmpz_mod_ctx_t ctx) + bint fmpz_mod_is_canonical(const fmpz_t a, const fmpz_mod_ctx_t ctx) # Return ``1`` if `a` is in the canonical range `[0,n)` and ``0`` otherwise. - int fmpz_mod_is_one(const fmpz_t a, const fmpz_mod_ctx_t ctx) + bint fmpz_mod_is_one(const fmpz_t a, const fmpz_mod_ctx_t ctx) # Return ``1`` if `a` is `1` modulo `n` and return ``0`` otherwise. void fmpz_mod_add(fmpz_t a, const fmpz_t b, const fmpz_t c, const fmpz_mod_ctx_t ctx) diff --git a/src/sage/libs/flint/fmpz_mod_mat.pxd b/src/sage/libs/flint/fmpz_mod_mat.pxd index 8c86b964eef..1ef5933f129 100644 --- a/src/sage/libs/flint/fmpz_mod_mat.pxd +++ b/src/sage/libs/flint/fmpz_mod_mat.pxd @@ -50,10 +50,10 @@ cdef extern from "flint_wrap.h": # Swaps two matrices by swapping the individual entries rather than swapping # the contents of the structs. - int fmpz_mod_mat_is_empty(const fmpz_mod_mat_t mat) + bint fmpz_mod_mat_is_empty(const fmpz_mod_mat_t mat) # Return `1` if ``mat`` has either zero rows or columns. - int fmpz_mod_mat_is_square(const fmpz_mod_mat_t mat) + bint fmpz_mod_mat_is_square(const fmpz_mod_mat_t mat) # Return `1` if ``mat`` has the same number of rows and columns. void _fmpz_mod_mat_reduce(fmpz_mod_mat_t mat) @@ -90,7 +90,7 @@ cdef extern from "flint_wrap.h": # bracket followed by a space separated list of coefficients followed # by a closing square bracket. - int fmpz_mod_mat_is_zero(const fmpz_mod_mat_t mat) + bint fmpz_mod_mat_is_zero(const fmpz_mod_mat_t mat) # Return `1` if ``mat`` is the zero matrix. void fmpz_mod_mat_set(fmpz_mod_mat_t B, const fmpz_mod_mat_t A) diff --git a/src/sage/libs/flint/fmpz_mod_mpoly.pxd b/src/sage/libs/flint/fmpz_mod_mpoly.pxd index 0f86a1b8e4b..83053a0e356 100644 --- a/src/sage/libs/flint/fmpz_mod_mpoly.pxd +++ b/src/sage/libs/flint/fmpz_mod_mpoly.pxd @@ -60,20 +60,20 @@ cdef extern from "flint_wrap.h": void fmpz_mod_mpoly_gen(fmpz_mod_mpoly_t A, slong var, const fmpz_mod_mpoly_ctx_t ctx) # Set *A* to the variable of index *var*, where `var = 0` corresponds to the variable with the most significance with respect to the ordering. - int fmpz_mod_mpoly_is_gen(const fmpz_mod_mpoly_t A, slong var, const fmpz_mod_mpoly_ctx_t ctx) + bint fmpz_mod_mpoly_is_gen(const fmpz_mod_mpoly_t A, slong var, const fmpz_mod_mpoly_ctx_t ctx) # If `var \ge 0`, return `1` if *A* is equal to the `var`-th generator, otherwise return `0`. # If `var < 0`, return `1` if the polynomial is equal to any generator, otherwise return `0`. void fmpz_mod_mpoly_set(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, const fmpz_mod_mpoly_ctx_t ctx) # Set *A* to *B*. - int fmpz_mod_mpoly_equal(const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, const fmpz_mod_mpoly_ctx_t ctx) + bint fmpz_mod_mpoly_equal(const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, const fmpz_mod_mpoly_ctx_t ctx) # Return `1` if *A* is equal to *B*, else return `0`. void fmpz_mod_mpoly_swap(fmpz_mod_mpoly_t poly1, fmpz_mod_mpoly_t poly2, const fmpz_mod_mpoly_ctx_t ctx) # Efficiently swap *A* and *B*. - int fmpz_mod_mpoly_is_fmpz(const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_ctx_t ctx) + bint fmpz_mod_mpoly_is_fmpz(const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_ctx_t ctx) # Return `1` if *A* is a constant, else return `0`. void fmpz_mod_mpoly_get_fmpz(fmpz_t c, const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_ctx_t ctx) @@ -91,15 +91,15 @@ cdef extern from "flint_wrap.h": void fmpz_mod_mpoly_one(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_ctx_t ctx) # Set *A* to the constant `1`. - int fmpz_mod_mpoly_equal_fmpz(const fmpz_mod_mpoly_t A, const fmpz_t c, const fmpz_mod_mpoly_ctx_t ctx) - int fmpz_mod_mpoly_equal_ui(const fmpz_mod_mpoly_t A, ulong c, const fmpz_mod_mpoly_ctx_t ctx) - int fmpz_mod_mpoly_equal_si(const fmpz_mod_mpoly_t A, slong c, const fmpz_mod_mpoly_ctx_t ctx) + bint fmpz_mod_mpoly_equal_fmpz(const fmpz_mod_mpoly_t A, const fmpz_t c, const fmpz_mod_mpoly_ctx_t ctx) + bint fmpz_mod_mpoly_equal_ui(const fmpz_mod_mpoly_t A, ulong c, const fmpz_mod_mpoly_ctx_t ctx) + bint fmpz_mod_mpoly_equal_si(const fmpz_mod_mpoly_t A, slong c, const fmpz_mod_mpoly_ctx_t ctx) # Return `1` if *A* is equal to the constant *c*, else return `0`. - int fmpz_mod_mpoly_is_zero(const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_ctx_t ctx) + bint fmpz_mod_mpoly_is_zero(const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_ctx_t ctx) # Return `1` if *A* is the constant `0`, else return `0`. - int fmpz_mod_mpoly_is_one(const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_ctx_t ctx) + bint fmpz_mod_mpoly_is_one(const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_ctx_t ctx) # Return `1` if *A* is the constant `1`, else return `0`. int fmpz_mod_mpoly_degrees_fit_si(const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_ctx_t ctx) @@ -154,7 +154,7 @@ cdef extern from "flint_wrap.h": # Return `1` (resp. `-1`, or `0`) if *A* is after (resp. before, same as) *B* in some arbitrary but fixed total ordering of the polynomials. # This ordering agrees with the usual ordering of monomials when *A* and *B* are both monomials. - int fmpz_mod_mpoly_is_canonical(const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_ctx_t ctx) + bint fmpz_mod_mpoly_is_canonical(const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_ctx_t ctx) # Return `1` if *A* is in canonical form. Otherwise, return `0`. # To be in canonical form, all of the terms must have nonzero coefficient, and the terms must be sorted from greatest to least. @@ -356,7 +356,7 @@ cdef extern from "flint_wrap.h": int fmpz_mod_mpoly_sqrt(fmpz_mod_mpoly_t Q, const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_ctx_t ctx) # If `Q^2=A` has a solution, set *Q* to a solution and return `1`, otherwise return `0` and set *Q* to zero. - int fmpz_mod_mpoly_is_square(const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_ctx_t ctx) + bint fmpz_mod_mpoly_is_square(const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_ctx_t ctx) # Return `1` if *A* is a perfect square, otherwise return `0`. int fmpz_mod_mpoly_quadratic_root(fmpz_mod_mpoly_t Q, const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, const fmpz_mod_mpoly_ctx_t ctx) diff --git a/src/sage/libs/flint/fmpz_mod_poly.pxd b/src/sage/libs/flint/fmpz_mod_poly.pxd index fe0f3a088de..da85a2583fc 100644 --- a/src/sage/libs/flint/fmpz_mod_poly.pxd +++ b/src/sage/libs/flint/fmpz_mod_poly.pxd @@ -162,20 +162,20 @@ cdef extern from "flint_wrap.h": void fmpz_mod_poly_set_nmod_poly(fmpz_mod_poly_t f, const nmod_poly_t g) - int fmpz_mod_poly_equal(const fmpz_mod_poly_t poly1, const fmpz_mod_poly_t poly2, const fmpz_mod_ctx_t ctx) + bint fmpz_mod_poly_equal(const fmpz_mod_poly_t poly1, const fmpz_mod_poly_t poly2, const fmpz_mod_ctx_t ctx) # Returns non-zero if the two polynomials are equal, otherwise returns zero. - int fmpz_mod_poly_equal_trunc(const fmpz_mod_poly_t poly1, const fmpz_mod_poly_t poly2, slong n, const fmpz_mod_ctx_t ctx) + bint fmpz_mod_poly_equal_trunc(const fmpz_mod_poly_t poly1, const fmpz_mod_poly_t poly2, slong n, const fmpz_mod_ctx_t ctx) # Notionally truncates the two polynomials to length `n` and returns non-zero # if the two polynomials are equal, otherwise returns zero. - int fmpz_mod_poly_is_zero(const fmpz_mod_poly_t poly, const fmpz_mod_ctx_t ctx) + bint fmpz_mod_poly_is_zero(const fmpz_mod_poly_t poly, const fmpz_mod_ctx_t ctx) # Returns non-zero if the polynomial is zero. - int fmpz_mod_poly_is_one(const fmpz_mod_poly_t poly, const fmpz_mod_ctx_t ctx) + bint fmpz_mod_poly_is_one(const fmpz_mod_poly_t poly, const fmpz_mod_ctx_t ctx) # Returns non-zero if the polynomial is the constant `1`. - int fmpz_mod_poly_is_gen(const fmpz_mod_poly_t poly, const fmpz_mod_ctx_t ctx) + bint fmpz_mod_poly_is_gen(const fmpz_mod_poly_t poly, const fmpz_mod_ctx_t ctx) # Returns non-zero if the polynomial is the degree `1` polynomial `x`. void fmpz_mod_poly_set_coeff_fmpz(fmpz_mod_poly_t poly, slong n, const fmpz_t x, const fmpz_mod_ctx_t ctx) diff --git a/src/sage/libs/flint/fmpz_mod_poly_factor.pxd b/src/sage/libs/flint/fmpz_mod_poly_factor.pxd index a99ebf607f1..f790ec3fe26 100644 --- a/src/sage/libs/flint/fmpz_mod_poly_factor.pxd +++ b/src/sage/libs/flint/fmpz_mod_poly_factor.pxd @@ -49,18 +49,18 @@ cdef extern from "flint_wrap.h": void fmpz_mod_poly_factor_pow(fmpz_mod_poly_factor_t fac, slong exp, const fmpz_mod_ctx_t ctx) # Raises ``fac`` to the power ``exp``. - int fmpz_mod_poly_is_irreducible(const fmpz_mod_poly_t f, const fmpz_mod_ctx_t ctx) + bint fmpz_mod_poly_is_irreducible(const fmpz_mod_poly_t f, const fmpz_mod_ctx_t ctx) # Returns 1 if the polynomial ``f`` is irreducible, otherwise returns 0. - int fmpz_mod_poly_is_irreducible_ddf(const fmpz_mod_poly_t f, const fmpz_mod_ctx_t ctx) + bint fmpz_mod_poly_is_irreducible_ddf(const fmpz_mod_poly_t f, const fmpz_mod_ctx_t ctx) # Returns 1 if the polynomial ``f`` is irreducible, otherwise returns 0. # Uses fast distinct-degree factorisation. - int fmpz_mod_poly_is_irreducible_rabin(const fmpz_mod_poly_t f, const fmpz_mod_ctx_t ctx) + bint fmpz_mod_poly_is_irreducible_rabin(const fmpz_mod_poly_t f, const fmpz_mod_ctx_t ctx) # Returns 1 if the polynomial ``f`` is irreducible, otherwise returns 0. # Uses Rabin irreducibility test. - int fmpz_mod_poly_is_irreducible_rabin_f(fmpz_t r, const fmpz_mod_poly_t f, const fmpz_mod_ctx_t ctx) + bint fmpz_mod_poly_is_irreducible_rabin_f(fmpz_t r, const fmpz_mod_poly_t f, const fmpz_mod_ctx_t ctx) # Either sets `r` to `1` and returns 1 if the polynomial ``f`` is # irreducible or `0` otherwise, or sets `r` to a nontrivial factor of # `p`. @@ -68,26 +68,26 @@ cdef extern from "flint_wrap.h": # `\mathbb{Z}/p\mathbb{Z}`, even for composite `f`, or it finds a factor # of `p`. - int _fmpz_mod_poly_is_squarefree(const fmpz * f, slong len, const fmpz_mod_ctx_t ctx) + bint _fmpz_mod_poly_is_squarefree(const fmpz * f, slong len, const fmpz_mod_ctx_t ctx) # Returns 1 if ``(f, len)`` is squarefree, and 0 otherwise. As a # special case, the zero polynomial is not considered squarefree. # There are no restrictions on the length. - int _fmpz_mod_poly_is_squarefree_f(fmpz_t fac, const fmpz * f, slong len, const fmpz_mod_ctx_t ctx) + bint _fmpz_mod_poly_is_squarefree_f(fmpz_t fac, const fmpz * f, slong len, const fmpz_mod_ctx_t ctx) # If `fac` returns with the value `1` then the function operates as per # :func:`_fmpz_mod_poly_is_squarefree`, otherwise `f` is set to a nontrivial # factor of `p`. - int fmpz_mod_poly_is_squarefree(const fmpz_mod_poly_t f, const fmpz_mod_ctx_t ctx) + bint fmpz_mod_poly_is_squarefree(const fmpz_mod_poly_t f, const fmpz_mod_ctx_t ctx) # Returns 1 if ``f`` is squarefree, and 0 otherwise. As a special # case, the zero polynomial is not considered squarefree. - int fmpz_mod_poly_is_squarefree_f(fmpz_t fac, const fmpz_mod_poly_t f, const fmpz_mod_ctx_t ctx) + bint fmpz_mod_poly_is_squarefree_f(fmpz_t fac, const fmpz_mod_poly_t f, const fmpz_mod_ctx_t ctx) # If `fac` returns with the value `1` then the function operates as per # :func:`fmpz_mod_poly_is_squarefree`, otherwise `f` is set to a nontrivial # factor of `p`. - int fmpz_mod_poly_factor_equal_deg_prob(fmpz_mod_poly_t factor, flint_rand_t state, const fmpz_mod_poly_t pol, slong d, const fmpz_mod_ctx_t ctx) + bint fmpz_mod_poly_factor_equal_deg_prob(fmpz_mod_poly_t factor, flint_rand_t state, const fmpz_mod_poly_t pol, slong d, const fmpz_mod_ctx_t ctx) # Probabilistic equal degree factorisation of ``pol`` into # irreducible factors of degree ``d``. If it passes, a factor is # placed in ``factor`` and 1 is returned, otherwise 0 is returned and diff --git a/src/sage/libs/flint/fmpz_mpoly.pxd b/src/sage/libs/flint/fmpz_mpoly.pxd index 61cd5f2e1cb..3b26e4dd9de 100644 --- a/src/sage/libs/flint/fmpz_mpoly.pxd +++ b/src/sage/libs/flint/fmpz_mpoly.pxd @@ -67,14 +67,14 @@ cdef extern from "flint_wrap.h": void fmpz_mpoly_gen(fmpz_mpoly_t A, slong var, const fmpz_mpoly_ctx_t ctx) # Set *A* to the variable of index *var*, where `var = 0` corresponds to the variable with the most significance with respect to the ordering. - int fmpz_mpoly_is_gen(const fmpz_mpoly_t A, slong var, const fmpz_mpoly_ctx_t ctx) + bint fmpz_mpoly_is_gen(const fmpz_mpoly_t A, slong var, const fmpz_mpoly_ctx_t ctx) # If `var \ge 0`, return `1` if *A* is equal to the `var`-th generator, otherwise return `0`. # If `var < 0`, return `1` if the polynomial is equal to any generator, otherwise return `0`. void fmpz_mpoly_set(fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_mpoly_ctx_t ctx) # Set *A* to *B*. - int fmpz_mpoly_equal(const fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_mpoly_ctx_t ctx) + bint fmpz_mpoly_equal(const fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_mpoly_ctx_t ctx) # Return `1` if *A* is equal to *B*, else return `0`. void fmpz_mpoly_swap(fmpz_mpoly_t poly1, fmpz_mpoly_t poly2, const fmpz_mpoly_ctx_t ctx) @@ -90,7 +90,7 @@ cdef extern from "flint_wrap.h": # values of the coefficients of *A*. If all of the coefficients are # positive, `b` is returned, otherwise `-b` is returned. - int fmpz_mpoly_is_fmpz(const fmpz_mpoly_t A, const fmpz_mpoly_ctx_t ctx) + bint fmpz_mpoly_is_fmpz(const fmpz_mpoly_t A, const fmpz_mpoly_ctx_t ctx) # Return `1` if *A* is a constant, else return `0`. void fmpz_mpoly_get_fmpz(fmpz_t c, const fmpz_mpoly_t A, const fmpz_mpoly_ctx_t ctx) @@ -108,15 +108,15 @@ cdef extern from "flint_wrap.h": void fmpz_mpoly_one(fmpz_mpoly_t A, const fmpz_mpoly_ctx_t ctx) # Set *A* to the constant `1`. - int fmpz_mpoly_equal_fmpz(const fmpz_mpoly_t A, const fmpz_t c, const fmpz_mpoly_ctx_t ctx) - int fmpz_mpoly_equal_ui(const fmpz_mpoly_t A, ulong c, const fmpz_mpoly_ctx_t ctx) - int fmpz_mpoly_equal_si(const fmpz_mpoly_t A, slong c, const fmpz_mpoly_ctx_t ctx) + bint fmpz_mpoly_equal_fmpz(const fmpz_mpoly_t A, const fmpz_t c, const fmpz_mpoly_ctx_t ctx) + bint fmpz_mpoly_equal_ui(const fmpz_mpoly_t A, ulong c, const fmpz_mpoly_ctx_t ctx) + bint fmpz_mpoly_equal_si(const fmpz_mpoly_t A, slong c, const fmpz_mpoly_ctx_t ctx) # Return `1` if *A* is equal to the constant *c*, else return `0`. - int fmpz_mpoly_is_zero(const fmpz_mpoly_t A, const fmpz_mpoly_ctx_t ctx) + bint fmpz_mpoly_is_zero(const fmpz_mpoly_t A, const fmpz_mpoly_ctx_t ctx) # Return `1` if *A* is the constant `0`, else return `0`. - int fmpz_mpoly_is_one(const fmpz_mpoly_t A, const fmpz_mpoly_ctx_t ctx) + bint fmpz_mpoly_is_one(const fmpz_mpoly_t A, const fmpz_mpoly_ctx_t ctx) # Return `1` if *A* is the constant `1`, else return `0`. int fmpz_mpoly_degrees_fit_si(const fmpz_mpoly_t A, const fmpz_mpoly_ctx_t ctx) @@ -175,7 +175,7 @@ cdef extern from "flint_wrap.h": # Return `1` (resp. `-1`, or `0`) if *A* is after (resp. before, same as) *B* in some arbitrary but fixed total ordering of the polynomials. # This ordering agrees with the usual ordering of monomials when *A* and *B* are both monomials. - int fmpz_mpoly_is_fmpz_poly(const fmpz_mpoly_t A, slong var, const fmpz_mpoly_ctx_t ctx) + bint fmpz_mpoly_is_fmpz_poly(const fmpz_mpoly_t A, slong var, const fmpz_mpoly_ctx_t ctx) # Return whether *A* is a univariate polynomial in the variable with index *var*. int fmpz_mpoly_get_fmpz_poly(fmpz_poly_t A, const fmpz_mpoly_t B, slong var, const fmpz_mpoly_ctx_t ctx) @@ -189,7 +189,7 @@ cdef extern from "flint_wrap.h": fmpz * fmpz_mpoly_term_coeff_ref(fmpz_mpoly_t A, slong i, const fmpz_mpoly_ctx_t ctx) # Return a reference to the coefficient of index *i* of *A*. - int fmpz_mpoly_is_canonical(const fmpz_mpoly_t A, const fmpz_mpoly_ctx_t ctx) + bint fmpz_mpoly_is_canonical(const fmpz_mpoly_t A, const fmpz_mpoly_ctx_t ctx) # Return `1` if *A* is in canonical form. Otherwise, return `0`. # To be in canonical form, all of the terms must have nonzero coefficient, and the terms must be sorted from greatest to least. @@ -447,7 +447,7 @@ cdef extern from "flint_wrap.h": # If *A* is a perfect square return `1` and set *Q* to the square root # with positive leading coefficient. Otherwise return `0` and set *Q* to zero. - int fmpz_mpoly_is_square(const fmpz_mpoly_t A, const fmpz_mpoly_ctx_t ctx) + bint fmpz_mpoly_is_square(const fmpz_mpoly_t A, const fmpz_mpoly_ctx_t ctx) # Return `1` if *A* is a perfect square, otherwise return `0`. void fmpz_mpoly_univar_init(fmpz_mpoly_univar_t A, const fmpz_mpoly_ctx_t ctx) @@ -670,11 +670,11 @@ cdef extern from "flint_wrap.h": # Sets *res* to the primitive part of the reduction (remainder of multivariate # quasidivision with remainder) with respect to the polynomials *vec*. - int fmpz_mpoly_vec_is_groebner(const fmpz_mpoly_vec_t G, const fmpz_mpoly_vec_t F, const fmpz_mpoly_ctx_t ctx) + bint fmpz_mpoly_vec_is_groebner(const fmpz_mpoly_vec_t G, const fmpz_mpoly_vec_t F, const fmpz_mpoly_ctx_t ctx) # If *F* is *NULL*, checks if *G* is a Gröbner basis. If *F* is not *NULL*, # checks if *G* is a Gröbner basis for *F*. - int fmpz_mpoly_vec_is_autoreduced(const fmpz_mpoly_vec_t F, const fmpz_mpoly_ctx_t ctx) + bint fmpz_mpoly_vec_is_autoreduced(const fmpz_mpoly_vec_t F, const fmpz_mpoly_ctx_t ctx) # Checks whether the vector *F* is autoreduced (or inter-reduced). void fmpz_mpoly_vec_autoreduction(fmpz_mpoly_vec_t H, const fmpz_mpoly_vec_t F, const fmpz_mpoly_ctx_t ctx) diff --git a/src/sage/libs/flint/fmpz_mpoly_q.pxd b/src/sage/libs/flint/fmpz_mpoly_q.pxd index 87bdb8838f9..02c696865aa 100644 --- a/src/sage/libs/flint/fmpz_mpoly_q.pxd +++ b/src/sage/libs/flint/fmpz_mpoly_q.pxd @@ -31,7 +31,7 @@ cdef extern from "flint_wrap.h": # Puts the numerator and denominator of *x* in canonical form by removing # common content and making the leading term of the denominator positive. - int fmpz_mpoly_q_is_canonical(const fmpz_mpoly_q_t x, const fmpz_mpoly_ctx_t ctx) + bint fmpz_mpoly_q_is_canonical(const fmpz_mpoly_q_t x, const fmpz_mpoly_ctx_t ctx) # Returns whether *x* is in canonical form. # In addition to verifying that the numerator and denominator # have no common content and that the leading term of the denominator @@ -40,10 +40,10 @@ cdef extern from "flint_wrap.h": # (these properties should normally hold; verifying them # provides an extra consistency check for test code). - int fmpz_mpoly_q_is_zero(const fmpz_mpoly_q_t x, const fmpz_mpoly_ctx_t ctx) + bint fmpz_mpoly_q_is_zero(const fmpz_mpoly_q_t x, const fmpz_mpoly_ctx_t ctx) # Returns whether *x* is the constant 0. - int fmpz_mpoly_q_is_one(const fmpz_mpoly_q_t x, const fmpz_mpoly_ctx_t ctx) + bint fmpz_mpoly_q_is_one(const fmpz_mpoly_q_t x, const fmpz_mpoly_ctx_t ctx) # Returns whether *x* is the constant 1. void fmpz_mpoly_q_used_vars(int * used, const fmpz_mpoly_q_t f, const fmpz_mpoly_ctx_t ctx) @@ -72,7 +72,7 @@ cdef extern from "flint_wrap.h": # have up to *length* terms, coefficients up to size *coeff_bits*, and # exponents strictly smaller than *exp_bound*. - int fmpz_mpoly_q_equal(const fmpz_mpoly_q_t x, const fmpz_mpoly_q_t y, const fmpz_mpoly_ctx_t ctx) + bint fmpz_mpoly_q_equal(const fmpz_mpoly_q_t x, const fmpz_mpoly_q_t y, const fmpz_mpoly_ctx_t ctx) # Returns whether *x* and *y* are equal. void fmpz_mpoly_q_neg(fmpz_mpoly_q_t res, const fmpz_mpoly_q_t x, const fmpz_mpoly_ctx_t ctx) diff --git a/src/sage/libs/flint/fmpz_poly.pxd b/src/sage/libs/flint/fmpz_poly.pxd index 2405b20a5ea..941e24c886f 100644 --- a/src/sage/libs/flint/fmpz_poly.pxd +++ b/src/sage/libs/flint/fmpz_poly.pxd @@ -235,26 +235,26 @@ cdef extern from "flint_wrap.h": # the current length of ``poly`` then the polynomial is extended and # zero coefficients inserted if necessary. - int fmpz_poly_equal(const fmpz_poly_t poly1, const fmpz_poly_t poly2) + bint fmpz_poly_equal(const fmpz_poly_t poly1, const fmpz_poly_t poly2) # Returns `1` if ``poly1`` is equal to ``poly2``, otherwise # returns `0`. The polynomials are assumed to be normalised. - int fmpz_poly_equal_trunc(const fmpz_poly_t poly1, const fmpz_poly_t poly2, slong n) + bint fmpz_poly_equal_trunc(const fmpz_poly_t poly1, const fmpz_poly_t poly2, slong n) # Return `1` if ``poly1`` and ``poly2``, notionally truncated to # length `n` are equal, otherwise return `0`. - int fmpz_poly_is_zero(const fmpz_poly_t poly) + bint fmpz_poly_is_zero(const fmpz_poly_t poly) # Returns `1` if the polynomial is zero and `0` otherwise. # This function is implemented as a macro. - int fmpz_poly_is_one(const fmpz_poly_t poly) + bint fmpz_poly_is_one(const fmpz_poly_t poly) # Returns `1` if the polynomial is one and `0` otherwise. - int fmpz_poly_is_unit(const fmpz_poly_t poly) + bint fmpz_poly_is_unit(const fmpz_poly_t poly) # Returns `1` if the polynomial is the constant polynomial `\pm 1`, # and `0` otherwise. - int fmpz_poly_is_gen(const fmpz_poly_t poly) + bint fmpz_poly_is_gen(const fmpz_poly_t poly) # Returns `1` if the polynomial is the degree `1` polynomial `x`, and `0` # otherwise. @@ -1036,10 +1036,10 @@ cdef extern from "flint_wrap.h": # and normalises the result to have non-negative leading coefficient. # If ``poly`` is zero, sets ``res`` to zero. - int _fmpz_poly_is_squarefree(const fmpz * poly, slong len) + bint _fmpz_poly_is_squarefree(const fmpz * poly, slong len) # Returns whether the polynomial ``(poly, len)`` is square-free. - int fmpz_poly_is_squarefree(const fmpz_poly_t poly) + bint fmpz_poly_is_squarefree(const fmpz_poly_t poly) # Returns whether the polynomial ``poly`` is square-free. A non-zero # polynomial is defined to be square-free if it has no non-unit square # factors. We also define the zero polynomial to be square-free. diff --git a/src/sage/libs/flint/fmpz_poly_mat.pxd b/src/sage/libs/flint/fmpz_poly_mat.pxd index 5e4ebdc9d5d..a1972258fc1 100644 --- a/src/sage/libs/flint/fmpz_poly_mat.pxd +++ b/src/sage/libs/flint/fmpz_poly_mat.pxd @@ -71,25 +71,25 @@ cdef extern from "flint_wrap.h": # having the element 1 on the main diagonal and zeros elsewhere. # If ``mat`` is nonsquare, it is set to the truncation of a unit matrix. - int fmpz_poly_mat_equal(const fmpz_poly_mat_t mat1, const fmpz_poly_mat_t mat2) + bint fmpz_poly_mat_equal(const fmpz_poly_mat_t mat1, const fmpz_poly_mat_t mat2) # Returns nonzero if ``mat1`` and ``mat2`` have the same shape and # all their entries agree, and returns zero otherwise. - int fmpz_poly_mat_is_zero(const fmpz_poly_mat_t mat) + bint fmpz_poly_mat_is_zero(const fmpz_poly_mat_t mat) # Returns nonzero if all entries in ``mat`` are zero, and returns # zero otherwise. - int fmpz_poly_mat_is_one(const fmpz_poly_mat_t mat) + bint fmpz_poly_mat_is_one(const fmpz_poly_mat_t mat) # Returns nonzero if all entries of ``mat`` on the main diagonal # are the constant polynomial 1 and all remaining entries are zero, # and returns zero otherwise. The matrix need not be square. - int fmpz_poly_mat_is_empty(const fmpz_poly_mat_t mat) + bint fmpz_poly_mat_is_empty(const fmpz_poly_mat_t mat) # Returns a non-zero value if the number of rows or the number of # columns in ``mat`` is zero, and otherwise returns # zero. - int fmpz_poly_mat_is_square(const fmpz_poly_mat_t mat) + bint fmpz_poly_mat_is_square(const fmpz_poly_mat_t mat) # Returns a non-zero value if the number of rows is equal to the # number of columns in ``mat``, and otherwise returns zero. diff --git a/src/sage/libs/flint/fmpz_poly_q.pxd b/src/sage/libs/flint/fmpz_poly_q.pxd index eb7e4b4d915..396dec3a2f6 100644 --- a/src/sage/libs/flint/fmpz_poly_q.pxd +++ b/src/sage/libs/flint/fmpz_poly_q.pxd @@ -28,7 +28,7 @@ cdef extern from "flint_wrap.h": # Brings ``rop`` into canonical form, only assuming that # the denominator is non-zero. - int fmpz_poly_q_is_canonical(const fmpz_poly_q_t op) + bint fmpz_poly_q_is_canonical(const fmpz_poly_q_t op) # Checks whether the rational function ``op`` is in # canonical form. @@ -62,14 +62,14 @@ cdef extern from "flint_wrap.h": # Sets the element ``rop`` to the multiplicative inverse of ``op``. # Assumes that the element ``op`` is non-zero. - int fmpz_poly_q_is_zero(const fmpz_poly_q_t op) + bint fmpz_poly_q_is_zero(const fmpz_poly_q_t op) # Returns whether the element ``op`` is zero. - int fmpz_poly_q_is_one(const fmpz_poly_q_t op) + bint fmpz_poly_q_is_one(const fmpz_poly_q_t op) # Returns whether the element ``rop`` is equal to the constant # polynomial `1`. - int fmpz_poly_q_equal(const fmpz_poly_q_t op1, const fmpz_poly_q_t op2) + bint fmpz_poly_q_equal(const fmpz_poly_q_t op1, const fmpz_poly_q_t op2) # Returns whether the two elements ``op1`` and ``op2`` are equal. void fmpz_poly_q_add(fmpz_poly_q_t rop, const fmpz_poly_q_t op1, const fmpz_poly_q_t op2) diff --git a/src/sage/libs/flint/fmpz_vec.pxd b/src/sage/libs/flint/fmpz_vec.pxd index a82d268cb0d..40486fe2ce2 100644 --- a/src/sage/libs/flint/fmpz_vec.pxd +++ b/src/sage/libs/flint/fmpz_vec.pxd @@ -142,11 +142,11 @@ cdef extern from "flint_wrap.h": # Takes the absolute value of entries in ``(vec2, len2)`` and places the # result into ``vec1``. - int _fmpz_vec_equal(const fmpz * vec1, const fmpz * vec2, slong len) + bint _fmpz_vec_equal(const fmpz * vec1, const fmpz * vec2, slong len) # Compares two vectors of the given length and returns `1` if they are # equal, otherwise returns `0`. - int _fmpz_vec_is_zero(const fmpz * vec, slong len) + bint _fmpz_vec_is_zero(const fmpz * vec, slong len) # Returns `1` if ``(vec, len)`` is zero, and `0` otherwise. void _fmpz_vec_max(fmpz * vec1, const fmpz * vec2, const fmpz * vec3, slong len) diff --git a/src/sage/libs/flint/fmpzi.pxd b/src/sage/libs/flint/fmpzi.pxd index e3b20ad1fe8..90c103bf7dd 100644 --- a/src/sage/libs/flint/fmpzi.pxd +++ b/src/sage/libs/flint/fmpzi.pxd @@ -30,13 +30,13 @@ cdef extern from "flint_wrap.h": void fmpzi_randtest(fmpzi_t res, flint_rand_t state, mp_bitcnt_t bits) - int fmpzi_equal(const fmpzi_t x, const fmpzi_t y) + bint fmpzi_equal(const fmpzi_t x, const fmpzi_t y) - int fmpzi_is_zero(const fmpzi_t x) + bint fmpzi_is_zero(const fmpzi_t x) - int fmpzi_is_one(const fmpzi_t x) + bint fmpzi_is_one(const fmpzi_t x) - int fmpzi_is_unit(const fmpzi_t x) + bint fmpzi_is_unit(const fmpzi_t x) slong fmpzi_canonical_unit_i_pow(const fmpzi_t x) diff --git a/src/sage/libs/flint/fq.pxd b/src/sage/libs/flint/fq.pxd index 8e2fcc70fb2..f94f23043f9 100644 --- a/src/sage/libs/flint/fq.pxd +++ b/src/sage/libs/flint/fq.pxd @@ -185,7 +185,7 @@ cdef extern from "flint_wrap.h": # this computes the root by raising ``op1`` to `p^{d-1}` where # `d` is the degree of the extension. - int fq_is_square(const fq_t op, const fq_ctx_t ctx) + bint fq_is_square(const fq_t op, const fq_ctx_t ctx) # Return ``1`` if ``op`` is a square. int fq_fprint_pretty(FILE *file, const fq_t op, const fq_ctx_t ctx) @@ -285,19 +285,19 @@ cdef extern from "flint_wrap.h": void fq_set_fmpz_mod_mat(fq_t a, const fmpz_mod_mat_t col, const fq_ctx_t ctx) # Convert a column vector ``col`` of length ``degree(ctx)`` to an element of ``ctx``. - int fq_is_zero(const fq_t op, const fq_ctx_t ctx) + bint fq_is_zero(const fq_t op, const fq_ctx_t ctx) # Returns whether ``op`` is equal to zero. - int fq_is_one(const fq_t op, const fq_ctx_t ctx) + bint fq_is_one(const fq_t op, const fq_ctx_t ctx) # Returns whether ``op`` is equal to one. - int fq_equal(const fq_t op1, const fq_t op2, const fq_ctx_t ctx) + bint fq_equal(const fq_t op1, const fq_t op2, const fq_ctx_t ctx) # Returns whether ``op1`` and ``op2`` are equal. - int fq_is_invertible(const fq_t op, const fq_ctx_t ctx) + bint fq_is_invertible(const fq_t op, const fq_ctx_t ctx) # Returns whether ``op`` is an invertible element. - int fq_is_invertible_f(fq_t f, const fq_t op, const fq_ctx_t ctx) + bint fq_is_invertible_f(fq_t f, const fq_t op, const fq_ctx_t ctx) # Returns whether ``op`` is an invertible element. If it is not, # then ``f`` is set of a factor of the modulus. @@ -349,7 +349,7 @@ cdef extern from "flint_wrap.h": # This function can also be used to check primitivity of a generator of # a finite field whose defining polynomial is not primitive. - int fq_is_primitive(const fq_t op, const fq_ctx_t ctx) + bint fq_is_primitive(const fq_t op, const fq_ctx_t ctx) # Returns whether ``op`` is primitive, i.e., whether it is a # generator of the multiplicative group of ``ctx``. diff --git a/src/sage/libs/flint/fq_default.pxd b/src/sage/libs/flint/fq_default.pxd index fd7c389c95a..c85ec98d7dc 100644 --- a/src/sage/libs/flint/fq_default.pxd +++ b/src/sage/libs/flint/fq_default.pxd @@ -101,7 +101,7 @@ cdef extern from "flint_wrap.h": void fq_default_clear(fq_default_t rop, const fq_default_ctx_t ctx) # Clears the element ``rop``. - int fq_default_is_invertible(const fq_default_t op, const fq_default_ctx_t ctx) + bint fq_default_is_invertible(const fq_default_t op, const fq_default_ctx_t ctx) # Return ``1`` if ``op`` is an invertible element. void fq_default_add(fq_default_t rop, const fq_default_t op1, const fq_default_t op2, const fq_default_ctx_t ctx) @@ -164,7 +164,7 @@ cdef extern from "flint_wrap.h": # this computes the root by raising ``op1`` to `p^{d-1}` where # `d` is the degree of the extension. - int fq_default_is_square(const fq_default_t op, const fq_default_ctx_t ctx) + bint fq_default_is_square(const fq_default_t op, const fq_default_ctx_t ctx) # Return ``1`` if ``op`` is a square. int fq_default_fprint_pretty(FILE *file, const fq_default_t op, const fq_default_ctx_t ctx) @@ -268,13 +268,13 @@ cdef extern from "flint_wrap.h": # The representatives are taken in `(\mathbb{Z}/p\mathbb{Z})[x]/h(x)` where # `h(x)` is the defining polynomial in ``ctx``. - int fq_default_is_zero(const fq_default_t op, const fq_default_ctx_t ctx) + bint fq_default_is_zero(const fq_default_t op, const fq_default_ctx_t ctx) # Returns whether ``op`` is equal to zero. - int fq_default_is_one(const fq_default_t op, const fq_default_ctx_t ctx) + bint fq_default_is_one(const fq_default_t op, const fq_default_ctx_t ctx) # Returns whether ``op`` is equal to one. - int fq_default_equal(const fq_default_t op1, const fq_default_t op2, const fq_default_ctx_t ctx) + bint fq_default_equal(const fq_default_t op1, const fq_default_t op2, const fq_default_ctx_t ctx) # Returns whether ``op1`` and ``op2`` are equal. void fq_default_trace(fmpz_t rop, const fq_default_t op, const fq_default_ctx_t ctx) diff --git a/src/sage/libs/flint/fq_default_mat.pxd b/src/sage/libs/flint/fq_default_mat.pxd index e3b897a05e3..b8bf8cdd5c1 100644 --- a/src/sage/libs/flint/fq_default_mat.pxd +++ b/src/sage/libs/flint/fq_default_mat.pxd @@ -161,23 +161,23 @@ cdef extern from "flint_wrap.h": # otherwise it will have random nonzero entries on the main # diagonal. - int fq_default_mat_equal(const fq_default_mat_t mat1, const fq_default_mat_t mat2, const fq_default_ctx_t ctx) + bint fq_default_mat_equal(const fq_default_mat_t mat1, const fq_default_mat_t mat2, const fq_default_ctx_t ctx) # Returns nonzero if mat1 and mat2 have the same dimensions and elements, # and zero otherwise. - int fq_default_mat_is_zero(const fq_default_mat_t mat, const fq_default_ctx_t ctx) + bint fq_default_mat_is_zero(const fq_default_mat_t mat, const fq_default_ctx_t ctx) # Returns a non-zero value if all entries of ``mat`` are zero, and # otherwise returns zero. - int fq_default_mat_is_one(const fq_default_mat_t mat, const fq_default_ctx_t ctx) + bint fq_default_mat_is_one(const fq_default_mat_t mat, const fq_default_ctx_t ctx) # Returns a non-zero value if all diagonal entries of ``mat`` are one and # all other entries are zero, and otherwise returns zero. - int fq_default_mat_is_empty(const fq_default_mat_t mat, const fq_default_ctx_t ctx) + bint fq_default_mat_is_empty(const fq_default_mat_t mat, const fq_default_ctx_t ctx) # Returns a non-zero value if the number of rows or the number of # columns in ``mat`` is zero, and otherwise returns zero. - int fq_default_mat_is_square(const fq_default_mat_t mat, const fq_default_ctx_t ctx) + bint fq_default_mat_is_square(const fq_default_mat_t mat, const fq_default_ctx_t ctx) # Returns a non-zero value if the number of rows is equal to the # number of columns in ``mat``, and otherwise returns zero. diff --git a/src/sage/libs/flint/fq_default_poly.pxd b/src/sage/libs/flint/fq_default_poly.pxd index 989b6f19bbb..69d18c6c7a4 100644 --- a/src/sage/libs/flint/fq_default_poly.pxd +++ b/src/sage/libs/flint/fq_default_poly.pxd @@ -124,30 +124,30 @@ cdef extern from "flint_wrap.h": # Sets the coefficient of `X^n` in the polynomial to `x`, # assuming `n \geq 0`. - int fq_default_poly_equal(const fq_default_poly_t poly1, const fq_default_poly_t poly2, const fq_default_ctx_t ctx) + bint fq_default_poly_equal(const fq_default_poly_t poly1, const fq_default_poly_t poly2, const fq_default_ctx_t ctx) # Returns nonzero if the two polynomials ``poly1`` and ``poly2`` # are equal, otherwise returns zero. - int fq_default_poly_equal_trunc(const fq_default_poly_t poly1, const fq_default_poly_t poly2, slong n, const fq_default_ctx_t ctx) + bint fq_default_poly_equal_trunc(const fq_default_poly_t poly1, const fq_default_poly_t poly2, slong n, const fq_default_ctx_t ctx) # Notionally truncate ``poly1`` and ``poly2`` to length `n` and # return nonzero if they are equal, otherwise return zero. - int fq_default_poly_is_zero(const fq_default_poly_t poly, const fq_default_ctx_t ctx) + bint fq_default_poly_is_zero(const fq_default_poly_t poly, const fq_default_ctx_t ctx) # Returns whether the polynomial ``poly`` is the zero polynomial. - int fq_default_poly_is_one(const fq_default_poly_t op, const fq_default_ctx_t ctx) + bint fq_default_poly_is_one(const fq_default_poly_t op, const fq_default_ctx_t ctx) # Returns whether the polynomial ``poly`` is equal # to the constant polynomial `1`. - int fq_default_poly_is_gen(const fq_default_poly_t op, const fq_default_ctx_t ctx) + bint fq_default_poly_is_gen(const fq_default_poly_t op, const fq_default_ctx_t ctx) # Returns whether the polynomial ``poly`` is equal # to the polynomial `x`. - int fq_default_poly_is_unit(const fq_default_poly_t op, const fq_default_ctx_t ctx) + bint fq_default_poly_is_unit(const fq_default_poly_t op, const fq_default_ctx_t ctx) # Returns whether the polynomial ``poly`` is a unit in the polynomial # ring `\mathbf{F}_q[X]`, i.e. if it has degree `0` and is non-zero. - int fq_default_poly_equal_fq_default(const fq_default_poly_t poly, const fq_default_t c, const fq_default_ctx_t ctx) + bint fq_default_poly_equal_fq_default(const fq_default_poly_t poly, const fq_default_t c, const fq_default_ctx_t ctx) # Returns whether the polynomial ``poly`` is equal the (constant) # `\mathbf{F}_q` element ``c`` diff --git a/src/sage/libs/flint/fq_default_poly_factor.pxd b/src/sage/libs/flint/fq_default_poly_factor.pxd index d397f5cc809..f707e03cd2a 100644 --- a/src/sage/libs/flint/fq_default_poly_factor.pxd +++ b/src/sage/libs/flint/fq_default_poly_factor.pxd @@ -67,10 +67,10 @@ cdef extern from "flint_wrap.h": slong fq_default_poly_factor_exp(fq_default_poly_factor_t fac, slong i, const fq_default_ctx_t ctx) # Return the exponent of factor ``i`` of ``fac``. - int fq_default_poly_is_irreducible(const fq_default_poly_t f, const fq_default_ctx_t ctx) + bint fq_default_poly_is_irreducible(const fq_default_poly_t f, const fq_default_ctx_t ctx) # Returns 1 if the polynomial ``f`` is irreducible, otherwise returns 0. - int fq_default_poly_is_squarefree(const fq_default_poly_t f, const fq_default_ctx_t ctx) + bint fq_default_poly_is_squarefree(const fq_default_poly_t f, const fq_default_ctx_t ctx) # Returns 1 if ``f`` is squarefree, and 0 otherwise. As a special # case, the zero polynomial is not considered squarefree. diff --git a/src/sage/libs/flint/fq_mat.pxd b/src/sage/libs/flint/fq_mat.pxd index ee3cd9853f1..6bdba3d3bbd 100644 --- a/src/sage/libs/flint/fq_mat.pxd +++ b/src/sage/libs/flint/fq_mat.pxd @@ -157,23 +157,23 @@ cdef extern from "flint_wrap.h": # otherwise it will have random nonzero entries on the main # diagonal. - int fq_mat_equal(const fq_mat_t mat1, const fq_mat_t mat2, const fq_ctx_t ctx) + bint fq_mat_equal(const fq_mat_t mat1, const fq_mat_t mat2, const fq_ctx_t ctx) # Returns nonzero if mat1 and mat2 have the same dimensions and elements, # and zero otherwise. - int fq_mat_is_zero(const fq_mat_t mat, const fq_ctx_t ctx) + bint fq_mat_is_zero(const fq_mat_t mat, const fq_ctx_t ctx) # Returns a non-zero value if all entries of ``mat`` are zero, and # otherwise returns zero. - int fq_mat_is_one(const fq_mat_t mat, const fq_ctx_t ctx) + bint fq_mat_is_one(const fq_mat_t mat, const fq_ctx_t ctx) # Returns a non-zero value if all entries ``mat`` are zero except the # diagonal entries which must be one, otherwise returns zero.. - int fq_mat_is_empty(const fq_mat_t mat, const fq_ctx_t ctx) + bint fq_mat_is_empty(const fq_mat_t mat, const fq_ctx_t ctx) # Returns a non-zero value if the number of rows or the number of # columns in ``mat`` is zero, and otherwise returns zero. - int fq_mat_is_square(const fq_mat_t mat, const fq_ctx_t ctx) + bint fq_mat_is_square(const fq_mat_t mat, const fq_ctx_t ctx) # Returns a non-zero value if the number of rows is equal to the # number of columns in ``mat``, and otherwise returns zero. diff --git a/src/sage/libs/flint/fq_nmod.pxd b/src/sage/libs/flint/fq_nmod.pxd index 9af72d4cbc2..5c661eeaf96 100644 --- a/src/sage/libs/flint/fq_nmod.pxd +++ b/src/sage/libs/flint/fq_nmod.pxd @@ -182,7 +182,7 @@ cdef extern from "flint_wrap.h": # this computes the root by raising ``op1`` to `p^{d-1}` where # `d` is the degree of the extension. - int fq_nmod_is_square(const fq_nmod_t op, const fq_nmod_ctx_t ctx) + bint fq_nmod_is_square(const fq_nmod_t op, const fq_nmod_ctx_t ctx) # Return ``1`` if ``op`` is a square. int fq_nmod_fprint_pretty(FILE * file, const fq_nmod_t op, const fq_nmod_ctx_t ctx) @@ -276,19 +276,19 @@ cdef extern from "flint_wrap.h": void fq_nmod_set_nmod_mat(fq_nmod_t a, const nmod_mat_t col, const fq_nmod_ctx_t ctx) # Convert a column vector ``col`` of length ``degree(ctx)`` to an element of ``ctx``. - int fq_nmod_is_zero(const fq_nmod_t op, const fq_nmod_ctx_t ctx) + bint fq_nmod_is_zero(const fq_nmod_t op, const fq_nmod_ctx_t ctx) # Returns whether ``op`` is equal to zero. - int fq_nmod_is_one(const fq_nmod_t op, const fq_nmod_ctx_t ctx) + bint fq_nmod_is_one(const fq_nmod_t op, const fq_nmod_ctx_t ctx) # Returns whether ``op`` is equal to one. - int fq_nmod_equal(const fq_nmod_t op1, const fq_nmod_t op2, const fq_nmod_ctx_t ctx) + bint fq_nmod_equal(const fq_nmod_t op1, const fq_nmod_t op2, const fq_nmod_ctx_t ctx) # Returns whether ``op1`` and ``op2`` are equal. - int fq_nmod_is_invertible(const fq_nmod_t op, const fq_nmod_ctx_t ctx) + bint fq_nmod_is_invertible(const fq_nmod_t op, const fq_nmod_ctx_t ctx) # Returns whether ``op`` is an invertible element. - int fq_nmod_is_invertible_f(fq_nmod_t f, const fq_nmod_t op, const fq_nmod_ctx_t ctx) + bint fq_nmod_is_invertible_f(fq_nmod_t f, const fq_nmod_t op, const fq_nmod_ctx_t ctx) # Returns whether ``op`` is an invertible element. If it is not, # then ``f`` is set to a factor of the modulus. @@ -343,7 +343,7 @@ cdef extern from "flint_wrap.h": # This function can also be used to check primitivity of a generator of # a finite field whose defining polynomial is not primitive. - int fq_nmod_is_primitive(const fq_nmod_t op, const fq_nmod_ctx_t ctx) + bint fq_nmod_is_primitive(const fq_nmod_t op, const fq_nmod_ctx_t ctx) # Returns whether ``op`` is primitive, i.e., whether it is a # generator of the multiplicative group of ``ctx``. diff --git a/src/sage/libs/flint/fq_nmod_mat.pxd b/src/sage/libs/flint/fq_nmod_mat.pxd index 37fc46b6cd6..ecb12cf7b4f 100644 --- a/src/sage/libs/flint/fq_nmod_mat.pxd +++ b/src/sage/libs/flint/fq_nmod_mat.pxd @@ -157,23 +157,23 @@ cdef extern from "flint_wrap.h": # otherwise it will have random nonzero entries on the main # diagonal. - int fq_nmod_mat_equal(const fq_nmod_mat_t mat1, const fq_nmod_mat_t mat2, const fq_nmod_ctx_t ctx) + bint fq_nmod_mat_equal(const fq_nmod_mat_t mat1, const fq_nmod_mat_t mat2, const fq_nmod_ctx_t ctx) # Returns nonzero if mat1 and mat2 have the same dimensions and elements, # and zero otherwise. - int fq_nmod_mat_is_zero(const fq_nmod_mat_t mat, const fq_nmod_ctx_t ctx) + bint fq_nmod_mat_is_zero(const fq_nmod_mat_t mat, const fq_nmod_ctx_t ctx) # Returns a non-zero value if all entries ``mat`` are zero, and # otherwise returns zero. - int fq_nmod_mat_is_one(const fq_nmod_mat_t mat, const fq_nmod_ctx_t ctx) + bint fq_nmod_mat_is_one(const fq_nmod_mat_t mat, const fq_nmod_ctx_t ctx) # Returns a non-zero value if all entries ``mat`` are zero except the # diagonal entries which must be one, otherwise returns zero. - int fq_nmod_mat_is_empty(const fq_nmod_mat_t mat, const fq_nmod_ctx_t ctx) + bint fq_nmod_mat_is_empty(const fq_nmod_mat_t mat, const fq_nmod_ctx_t ctx) # Returns a non-zero value if the number of rows or the number of # columns in ``mat`` is zero, and otherwise returns zero. - int fq_nmod_mat_is_square(const fq_nmod_mat_t mat, const fq_nmod_ctx_t ctx) + bint fq_nmod_mat_is_square(const fq_nmod_mat_t mat, const fq_nmod_ctx_t ctx) # Returns a non-zero value if the number of rows is equal to the # number of columns in ``mat``, and otherwise returns zero. diff --git a/src/sage/libs/flint/fq_nmod_mpoly.pxd b/src/sage/libs/flint/fq_nmod_mpoly.pxd index 3ed0b2350ec..bbab91a5de6 100644 --- a/src/sage/libs/flint/fq_nmod_mpoly.pxd +++ b/src/sage/libs/flint/fq_nmod_mpoly.pxd @@ -65,20 +65,20 @@ cdef extern from "flint_wrap.h": void fq_nmod_mpoly_gen(fq_nmod_mpoly_t A, slong var, const fq_nmod_mpoly_ctx_t ctx) # Set *A* to the variable of index *var*, where `var = 0` corresponds to the variable with the most significance with respect to the ordering. - int fq_nmod_mpoly_is_gen(const fq_nmod_mpoly_t A, slong var, const fq_nmod_mpoly_ctx_t ctx) + bint fq_nmod_mpoly_is_gen(const fq_nmod_mpoly_t A, slong var, const fq_nmod_mpoly_ctx_t ctx) # If `var \ge 0`, return `1` if *A* is equal to the `var`-th generator, otherwise return `0`. # If `var < 0`, return `1` if the polynomial is equal to any generator, otherwise return `0`. void fq_nmod_mpoly_set(fq_nmod_mpoly_t A, const fq_nmod_mpoly_t B, const fq_nmod_mpoly_ctx_t ctx) # Set *A* to *B*. - int fq_nmod_mpoly_equal(const fq_nmod_mpoly_t A, const fq_nmod_mpoly_t B, const fq_nmod_mpoly_ctx_t ctx) + bint fq_nmod_mpoly_equal(const fq_nmod_mpoly_t A, const fq_nmod_mpoly_t B, const fq_nmod_mpoly_ctx_t ctx) # Return `1` if *A* is equal to *B*, else return `0`. void fq_nmod_mpoly_swap(fq_nmod_mpoly_t A, fq_nmod_mpoly_t B, const fq_nmod_mpoly_ctx_t ctx) # Efficiently swap *A* and *B*. - int fq_nmod_mpoly_is_fq_nmod(const fq_nmod_mpoly_t A, const fq_nmod_mpoly_ctx_t ctx) + bint fq_nmod_mpoly_is_fq_nmod(const fq_nmod_mpoly_t A, const fq_nmod_mpoly_ctx_t ctx) # Return `1` if *A* is a constant, else return `0`. void fq_nmod_mpoly_get_fq_nmod(fq_nmod_t c, const fq_nmod_mpoly_t A, const fq_nmod_mpoly_ctx_t ctx) @@ -98,13 +98,13 @@ cdef extern from "flint_wrap.h": void fq_nmod_mpoly_one(fq_nmod_mpoly_t A, const fq_nmod_mpoly_ctx_t ctx) # Set *A* to the constant `1`. - int fq_nmod_mpoly_equal_fq_nmod(const fq_nmod_mpoly_t A, const fq_nmod_t c, const fq_nmod_mpoly_ctx_t ctx) + bint fq_nmod_mpoly_equal_fq_nmod(const fq_nmod_mpoly_t A, const fq_nmod_t c, const fq_nmod_mpoly_ctx_t ctx) # Return `1` if *A* is equal to the constant *c*, else return `0`. - int fq_nmod_mpoly_is_zero(const fq_nmod_mpoly_t A, const fq_nmod_mpoly_ctx_t ctx) + bint fq_nmod_mpoly_is_zero(const fq_nmod_mpoly_t A, const fq_nmod_mpoly_ctx_t ctx) # Return `1` if *A* is the constant `0`, else return `0`. - int fq_nmod_mpoly_is_one(const fq_nmod_mpoly_t A, const fq_nmod_mpoly_ctx_t ctx) + bint fq_nmod_mpoly_is_one(const fq_nmod_mpoly_t A, const fq_nmod_mpoly_ctx_t ctx) # Return `1` if *A* is the constant `1`, else return `0`. int fq_nmod_mpoly_degrees_fit_si(const fq_nmod_mpoly_t A, const fq_nmod_mpoly_ctx_t ctx) @@ -155,7 +155,7 @@ cdef extern from "flint_wrap.h": # Return `1` (resp. `-1`, or `0`) if *A* is after (resp. before, same as) *B* in some arbitrary but fixed total ordering of the polynomials. # This ordering agrees with the usual ordering of monomials when *A* and *B* are both monomials. - int fq_nmod_mpoly_is_canonical(const fq_nmod_mpoly_t A, const fq_nmod_mpoly_ctx_t ctx) + bint fq_nmod_mpoly_is_canonical(const fq_nmod_mpoly_t A, const fq_nmod_mpoly_ctx_t ctx) # Return `1` if *A* is in canonical form. Otherwise, return `0`. # To be in canonical form, all of the terms must have nonzero coefficients, and the terms must be sorted from greatest to least. @@ -328,7 +328,7 @@ cdef extern from "flint_wrap.h": int fq_nmod_mpoly_sqrt(fq_nmod_mpoly_t Q, const fq_nmod_mpoly_t A, const fq_nmod_mpoly_ctx_t ctx) # If `Q^2=A` has a solution, set `Q` to a solution and return `1`, otherwise return `0` and set `Q` to zero. - int fq_nmod_mpoly_is_square(const fq_nmod_mpoly_t A, const fq_nmod_mpoly_ctx_t ctx) + bint fq_nmod_mpoly_is_square(const fq_nmod_mpoly_t A, const fq_nmod_mpoly_ctx_t ctx) # Return `1` if *A* is a perfect square, otherwise return `0`. int fq_nmod_mpoly_quadratic_root(fq_nmod_mpoly_t Q, const fq_nmod_mpoly_t A, const fq_nmod_mpoly_t B, const fq_nmod_mpoly_ctx_t ctx) diff --git a/src/sage/libs/flint/fq_nmod_poly.pxd b/src/sage/libs/flint/fq_nmod_poly.pxd index d5b0fe2c72f..8f079a6f324 100644 --- a/src/sage/libs/flint/fq_nmod_poly.pxd +++ b/src/sage/libs/flint/fq_nmod_poly.pxd @@ -157,30 +157,30 @@ cdef extern from "flint_wrap.h": # Sets the coefficient of `X^n` in the polynomial to `x`, # assuming `n \geq 0`. - int fq_nmod_poly_equal(const fq_nmod_poly_t poly1, const fq_nmod_poly_t poly2, const fq_nmod_ctx_t ctx) + bint fq_nmod_poly_equal(const fq_nmod_poly_t poly1, const fq_nmod_poly_t poly2, const fq_nmod_ctx_t ctx) # Returns nonzero if the two polynomials ``poly1`` and ``poly2`` # are equal, otherwise return zero. - int fq_nmod_poly_equal_trunc(const fq_nmod_poly_t poly1, const fq_nmod_poly_t poly2, slong n, const fq_nmod_ctx_t ctx) + bint fq_nmod_poly_equal_trunc(const fq_nmod_poly_t poly1, const fq_nmod_poly_t poly2, slong n, const fq_nmod_ctx_t ctx) # Notionally truncate ``poly1`` and ``poly2`` to length `n` and # return nonzero if they are equal, otherwise return zero. - int fq_nmod_poly_is_zero(const fq_nmod_poly_t poly, const fq_nmod_ctx_t ctx) + bint fq_nmod_poly_is_zero(const fq_nmod_poly_t poly, const fq_nmod_ctx_t ctx) # Returns whether the polynomial ``poly`` is the zero polynomial. - int fq_nmod_poly_is_one(const fq_nmod_poly_t op, const fq_nmod_ctx_t ctx) + bint fq_nmod_poly_is_one(const fq_nmod_poly_t op, const fq_nmod_ctx_t ctx) # Returns whether the polynomial ``poly`` is equal # to the constant polynomial `1`. - int fq_nmod_poly_is_gen(const fq_nmod_poly_t op, const fq_nmod_ctx_t ctx) + bint fq_nmod_poly_is_gen(const fq_nmod_poly_t op, const fq_nmod_ctx_t ctx) # Returns whether the polynomial ``poly`` is equal # to the polynomial `x`. - int fq_nmod_poly_is_unit(const fq_nmod_poly_t op, const fq_nmod_ctx_t ctx) + bint fq_nmod_poly_is_unit(const fq_nmod_poly_t op, const fq_nmod_ctx_t ctx) # Returns whether the polynomial ``poly`` is a unit in the polynomial # ring `\mathbf{F}_q[X]`, i.e. if it has degree `0` and is non-zero. - int fq_nmod_poly_equal_fq_nmod(const fq_nmod_poly_t poly, const fq_nmod_t c, const fq_nmod_ctx_t ctx) + bint fq_nmod_poly_equal_fq_nmod(const fq_nmod_poly_t poly, const fq_nmod_t c, const fq_nmod_ctx_t ctx) # Returns whether the polynomial ``poly`` is equal the (constant) # `\mathbf{F}_q` element ``c`` diff --git a/src/sage/libs/flint/fq_nmod_poly_factor.pxd b/src/sage/libs/flint/fq_nmod_poly_factor.pxd index 83926d34452..84684bad90b 100644 --- a/src/sage/libs/flint/fq_nmod_poly_factor.pxd +++ b/src/sage/libs/flint/fq_nmod_poly_factor.pxd @@ -58,27 +58,27 @@ cdef extern from "flint_wrap.h": # Removes the highest possible power of ``p`` from ``f`` and # returns the exponent. - int fq_nmod_poly_is_irreducible(const fq_nmod_poly_t f, const fq_nmod_ctx_t ctx) + bint fq_nmod_poly_is_irreducible(const fq_nmod_poly_t f, const fq_nmod_ctx_t ctx) # Returns 1 if the polynomial ``f`` is irreducible, otherwise returns 0. - int fq_nmod_poly_is_irreducible_ddf(const fq_nmod_poly_t f, const fq_nmod_ctx_t ctx) + bint fq_nmod_poly_is_irreducible_ddf(const fq_nmod_poly_t f, const fq_nmod_ctx_t ctx) # Returns 1 if the polynomial ``f`` is irreducible, otherwise returns 0. # Uses fast distinct-degree factorisation. - int fq_nmod_poly_is_irreducible_ben_or(const fq_nmod_poly_t f, const fq_nmod_ctx_t ctx) + bint fq_nmod_poly_is_irreducible_ben_or(const fq_nmod_poly_t f, const fq_nmod_ctx_t ctx) # Returns 1 if the polynomial ``f`` is irreducible, otherwise returns 0. # Uses Ben-Or's irreducibility test. - int _fq_nmod_poly_is_squarefree(const fq_nmod_struct * f, slong len, const fq_nmod_ctx_t ctx) + bint _fq_nmod_poly_is_squarefree(const fq_nmod_struct * f, slong len, const fq_nmod_ctx_t ctx) # Returns 1 if ``(f, len)`` is squarefree, and 0 otherwise. As a # special case, the zero polynomial is not considered squarefree. # There are no restrictions on the length. - int fq_nmod_poly_is_squarefree(const fq_nmod_poly_t f, const fq_nmod_ctx_t ctx) + bint fq_nmod_poly_is_squarefree(const fq_nmod_poly_t f, const fq_nmod_ctx_t ctx) # Returns 1 if ``f`` is squarefree, and 0 otherwise. As a special # case, the zero polynomial is not considered squarefree. - int fq_nmod_poly_factor_equal_deg_prob(fq_nmod_poly_t factor, flint_rand_t state, const fq_nmod_poly_t pol, slong d, const fq_nmod_ctx_t ctx) + bint fq_nmod_poly_factor_equal_deg_prob(fq_nmod_poly_t factor, flint_rand_t state, const fq_nmod_poly_t pol, slong d, const fq_nmod_ctx_t ctx) # Probabilistic equal degree factorisation of ``pol`` into # irreducible factors of degree ``d``. If it passes, a factor is # placed in factor and 1 is returned, otherwise 0 is returned and diff --git a/src/sage/libs/flint/fq_nmod_vec.pxd b/src/sage/libs/flint/fq_nmod_vec.pxd index db11b49bbdd..6bbf21fe295 100644 --- a/src/sage/libs/flint/fq_nmod_vec.pxd +++ b/src/sage/libs/flint/fq_nmod_vec.pxd @@ -46,11 +46,11 @@ cdef extern from "flint_wrap.h": void _fq_nmod_vec_neg(fq_nmod_struct * vec1, const fq_nmod_struct * vec2, slong len2, const fq_nmod_ctx_t ctx) # Negates ``(vec2, len2)`` and places it into ``vec1``. - int _fq_nmod_vec_equal(const fq_nmod_struct * vec1, const fq_nmod_struct * vec2, slong len, const fq_nmod_ctx_t ctx) + bint _fq_nmod_vec_equal(const fq_nmod_struct * vec1, const fq_nmod_struct * vec2, slong len, const fq_nmod_ctx_t ctx) # Compares two vectors of the given length and returns `1` if they are # equal, otherwise returns `0`. - int _fq_nmod_vec_is_zero(const fq_nmod_struct * vec, slong len, const fq_nmod_ctx_t ctx) + bint _fq_nmod_vec_is_zero(const fq_nmod_struct * vec, slong len, const fq_nmod_ctx_t ctx) # Returns `1` if ``(vec, len)`` is zero, and `0` otherwise. void _fq_nmod_vec_add(fq_nmod_struct * res, const fq_nmod_struct * vec1, const fq_nmod_struct * vec2, slong len2, const fq_nmod_ctx_t ctx) diff --git a/src/sage/libs/flint/fq_poly.pxd b/src/sage/libs/flint/fq_poly.pxd index ae28b7a3461..dcea06d428a 100644 --- a/src/sage/libs/flint/fq_poly.pxd +++ b/src/sage/libs/flint/fq_poly.pxd @@ -157,30 +157,30 @@ cdef extern from "flint_wrap.h": # Sets the coefficient of `X^n` in the polynomial to `x`, # assuming `n \geq 0`. - int fq_poly_equal(const fq_poly_t poly1, const fq_poly_t poly2, const fq_ctx_t ctx) + bint fq_poly_equal(const fq_poly_t poly1, const fq_poly_t poly2, const fq_ctx_t ctx) # Returns nonzero if the two polynomials ``poly1`` and ``poly2`` # are equal, otherwise returns zero. - int fq_poly_equal_trunc(const fq_poly_t poly1, const fq_poly_t poly2, slong n, const fq_ctx_t ctx) + bint fq_poly_equal_trunc(const fq_poly_t poly1, const fq_poly_t poly2, slong n, const fq_ctx_t ctx) # Notionally truncate ``poly1`` and ``poly2`` to length `n` and # return nonzero if they are equal, otherwise return zero. - int fq_poly_is_zero(const fq_poly_t poly, const fq_ctx_t ctx) + bint fq_poly_is_zero(const fq_poly_t poly, const fq_ctx_t ctx) # Returns whether the polynomial ``poly`` is the zero polynomial. - int fq_poly_is_one(const fq_poly_t op, const fq_ctx_t ctx) + bint fq_poly_is_one(const fq_poly_t op, const fq_ctx_t ctx) # Returns whether the polynomial ``poly`` is equal # to the constant polynomial `1`. - int fq_poly_is_gen(const fq_poly_t op, const fq_ctx_t ctx) + bint fq_poly_is_gen(const fq_poly_t op, const fq_ctx_t ctx) # Returns whether the polynomial ``poly`` is equal # to the polynomial `x`. - int fq_poly_is_unit(const fq_poly_t op, const fq_ctx_t ctx) + bint fq_poly_is_unit(const fq_poly_t op, const fq_ctx_t ctx) # Returns whether the polynomial ``poly`` is a unit in the polynomial # ring `\mathbf{F}_q[X]`, i.e. if it has degree `0` and is non-zero. - int fq_poly_equal_fq(const fq_poly_t poly, const fq_t c, const fq_ctx_t ctx) + bint fq_poly_equal_fq(const fq_poly_t poly, const fq_t c, const fq_ctx_t ctx) # Returns whether the polynomial ``poly`` is equal the (constant) # `\mathbf{F}_q` element ``c`` diff --git a/src/sage/libs/flint/fq_poly_factor.pxd b/src/sage/libs/flint/fq_poly_factor.pxd index 56059aaf7e8..a914d98b427 100644 --- a/src/sage/libs/flint/fq_poly_factor.pxd +++ b/src/sage/libs/flint/fq_poly_factor.pxd @@ -58,27 +58,27 @@ cdef extern from "flint_wrap.h": # Removes the highest possible power of ``p`` from ``f`` and # returns the exponent. - int fq_poly_is_irreducible(const fq_poly_t f, const fq_ctx_t ctx) + bint fq_poly_is_irreducible(const fq_poly_t f, const fq_ctx_t ctx) # Returns 1 if the polynomial ``f`` is irreducible, otherwise returns 0. - int fq_poly_is_irreducible_ddf(const fq_poly_t f, const fq_ctx_t ctx) + bint fq_poly_is_irreducible_ddf(const fq_poly_t f, const fq_ctx_t ctx) # Returns 1 if the polynomial ``f`` is irreducible, otherwise returns 0. # Uses fast distinct-degree factorisation. - int fq_poly_is_irreducible_ben_or(const fq_poly_t f, const fq_ctx_t ctx) + bint fq_poly_is_irreducible_ben_or(const fq_poly_t f, const fq_ctx_t ctx) # Returns 1 if the polynomial ``f`` is irreducible, otherwise returns 0. # Uses Ben-Or's irreducibility test. - int _fq_poly_is_squarefree(const fq_struct * f, slong len, const fq_ctx_t ctx) + bint _fq_poly_is_squarefree(const fq_struct * f, slong len, const fq_ctx_t ctx) # Returns 1 if ``(f, len)`` is squarefree, and 0 otherwise. As a # special case, the zero polynomial is not considered squarefree. # There are no restrictions on the length. - int fq_poly_is_squarefree(const fq_poly_t f, const fq_ctx_t ctx) + bint fq_poly_is_squarefree(const fq_poly_t f, const fq_ctx_t ctx) # Returns 1 if ``f`` is squarefree, and 0 otherwise. As a special # case, the zero polynomial is not considered squarefree. - int fq_poly_factor_equal_deg_prob(fq_poly_t factor, flint_rand_t state, const fq_poly_t pol, slong d, const fq_ctx_t ctx) + bint fq_poly_factor_equal_deg_prob(fq_poly_t factor, flint_rand_t state, const fq_poly_t pol, slong d, const fq_ctx_t ctx) # Probabilistic equal degree factorisation of ``pol`` into # irreducible factors of degree ``d``. If it passes, a factor is # placed in factor and 1 is returned, otherwise 0 is returned and diff --git a/src/sage/libs/flint/fq_vec.pxd b/src/sage/libs/flint/fq_vec.pxd index 23160909d9c..7475e0dc8f7 100644 --- a/src/sage/libs/flint/fq_vec.pxd +++ b/src/sage/libs/flint/fq_vec.pxd @@ -46,11 +46,11 @@ cdef extern from "flint_wrap.h": void _fq_vec_neg(fq_struct * vec1, const fq_struct * vec2, slong len2, const fq_ctx_t ctx) # Negates ``(vec2, len2)`` and places it into ``vec1``. - int _fq_vec_equal(const fq_struct * vec1, const fq_struct * vec2, slong len, const fq_ctx_t ctx) + bint _fq_vec_equal(const fq_struct * vec1, const fq_struct * vec2, slong len, const fq_ctx_t ctx) # Compares two vectors of the given length and returns `1` if they are # equal, otherwise returns `0`. - int _fq_vec_is_zero(const fq_struct * vec, slong len, const fq_ctx_t ctx) + bint _fq_vec_is_zero(const fq_struct * vec, slong len, const fq_ctx_t ctx) # Returns `1` if ``(vec, len)`` is zero, and `0` otherwise. void _fq_vec_add(fq_struct * res, const fq_struct * vec1, const fq_struct * vec2, slong len2, const fq_ctx_t ctx) diff --git a/src/sage/libs/flint/fq_zech.pxd b/src/sage/libs/flint/fq_zech.pxd index b0e702ada14..a6b22cd4589 100644 --- a/src/sage/libs/flint/fq_zech.pxd +++ b/src/sage/libs/flint/fq_zech.pxd @@ -212,7 +212,7 @@ cdef extern from "flint_wrap.h": # this computes the root by raising ``op1`` to `p^{d-1}` where # `d` is the degree of the extension. - int fq_zech_is_square(const fq_zech_t op, const fq_zech_ctx_t ctx) + bint fq_zech_is_square(const fq_zech_t op, const fq_zech_ctx_t ctx) # Return ``1`` if ``op`` is a square. int fq_zech_fprint_pretty(FILE *file, const fq_zech_t op, const fq_zech_ctx_t ctx) @@ -311,19 +311,19 @@ cdef extern from "flint_wrap.h": # Convert a column vector ``col`` of length ``degree(ctx)`` to # an element of ``ctx``. - int fq_zech_is_zero(const fq_zech_t op, const fq_zech_ctx_t ctx) + bint fq_zech_is_zero(const fq_zech_t op, const fq_zech_ctx_t ctx) # Returns whether ``op`` is equal to zero. - int fq_zech_is_one(const fq_zech_t op, const fq_zech_ctx_t ctx) + bint fq_zech_is_one(const fq_zech_t op, const fq_zech_ctx_t ctx) # Returns whether ``op`` is equal to one. - int fq_zech_equal(const fq_zech_t op1, const fq_zech_t op2, const fq_zech_ctx_t ctx) + bint fq_zech_equal(const fq_zech_t op1, const fq_zech_t op2, const fq_zech_ctx_t ctx) # Returns whether ``op1`` and ``op2`` are equal. - int fq_zech_is_invertible(const fq_zech_t op, const fq_zech_ctx_t ctx) + bint fq_zech_is_invertible(const fq_zech_t op, const fq_zech_ctx_t ctx) # Returns whether ``op`` is an invertible element. - int fq_zech_is_invertible_f(fq_zech_t f, const fq_zech_t op, const fq_zech_ctx_t ctx) + bint fq_zech_is_invertible_f(fq_zech_t f, const fq_zech_t op, const fq_zech_ctx_t ctx) # Returns whether ``op`` is an invertible element. If it is not, # then ``f`` is set of a factor of the modulus. Since the # modulus for an ``fq_zech_ctx_t`` is always irreducible, then @@ -366,7 +366,7 @@ cdef extern from "flint_wrap.h": # primitivity of the generator, but can be used to check that other elements # are primitive. - int fq_zech_is_primitive(const fq_zech_t op, const fq_zech_ctx_t ctx) + bint fq_zech_is_primitive(const fq_zech_t op, const fq_zech_ctx_t ctx) # Returns whether ``op`` is primitive, i.e., whether it is a # generator of the multiplicative group of ``ctx``. diff --git a/src/sage/libs/flint/fq_zech_mat.pxd b/src/sage/libs/flint/fq_zech_mat.pxd index 33a961840f9..72ea94dfdb6 100644 --- a/src/sage/libs/flint/fq_zech_mat.pxd +++ b/src/sage/libs/flint/fq_zech_mat.pxd @@ -139,23 +139,23 @@ cdef extern from "flint_wrap.h": # otherwise it will have random nonzero entries on the main # diagonal. - int fq_zech_mat_equal(const fq_zech_mat_t mat1, const fq_zech_mat_t mat2, const fq_zech_ctx_t ctx) + bint fq_zech_mat_equal(const fq_zech_mat_t mat1, const fq_zech_mat_t mat2, const fq_zech_ctx_t ctx) # Returns nonzero if mat1 and mat2 have the same dimensions and elements, # and zero otherwise. - int fq_zech_mat_is_zero(const fq_zech_mat_t mat, const fq_zech_ctx_t ctx) + bint fq_zech_mat_is_zero(const fq_zech_mat_t mat, const fq_zech_ctx_t ctx) # Returns a non-zero value if all entries ``mat`` are zero, and # otherwise returns zero. - int fq_zech_mat_is_one(const fq_zech_mat_t mat, const fq_zech_ctx_t ctx) + bint fq_zech_mat_is_one(const fq_zech_mat_t mat, const fq_zech_ctx_t ctx) # Returns a non-zero value if all entries ``mat`` are zero except the # diagonal entries which must be one, otherwise returns zero. - int fq_zech_mat_is_empty(const fq_zech_mat_t mat, const fq_zech_ctx_t ctx) + bint fq_zech_mat_is_empty(const fq_zech_mat_t mat, const fq_zech_ctx_t ctx) # Returns a non-zero value if the number of rows or the number of # columns in ``mat`` is zero, and otherwise returns zero. - int fq_zech_mat_is_square(const fq_zech_mat_t mat, const fq_zech_ctx_t ctx) + bint fq_zech_mat_is_square(const fq_zech_mat_t mat, const fq_zech_ctx_t ctx) # Returns a non-zero value if the number of rows is equal to the # number of columns in ``mat``, and otherwise returns zero. diff --git a/src/sage/libs/flint/fq_zech_poly.pxd b/src/sage/libs/flint/fq_zech_poly.pxd index 608a82eb32c..7ec51dd3005 100644 --- a/src/sage/libs/flint/fq_zech_poly.pxd +++ b/src/sage/libs/flint/fq_zech_poly.pxd @@ -157,30 +157,30 @@ cdef extern from "flint_wrap.h": # Sets the coefficient of `X^n` in the polynomial to `x`, # assuming `n \geq 0`. - int fq_zech_poly_equal(const fq_zech_poly_t poly1, const fq_zech_poly_t poly2, const fq_zech_ctx_t ctx) + bint fq_zech_poly_equal(const fq_zech_poly_t poly1, const fq_zech_poly_t poly2, const fq_zech_ctx_t ctx) # Returns nonzero if the two polynomials ``poly1`` and ``poly2`` # are equal, otherwise return zero. - int fq_zech_poly_equal_trunc(const fq_zech_poly_t poly1, const fq_zech_poly_t poly2, slong n, const fq_zech_ctx_t ctx) + bint fq_zech_poly_equal_trunc(const fq_zech_poly_t poly1, const fq_zech_poly_t poly2, slong n, const fq_zech_ctx_t ctx) # Notionally truncate ``poly1`` and ``poly2`` to length `n` and # return nonzero if they are equal, otherwise return zero. - int fq_zech_poly_is_zero(const fq_zech_poly_t poly, const fq_zech_ctx_t ctx) + bint fq_zech_poly_is_zero(const fq_zech_poly_t poly, const fq_zech_ctx_t ctx) # Returns whether the polynomial ``poly`` is the zero polynomial. - int fq_zech_poly_is_one(const fq_zech_poly_t op, const fq_zech_ctx_t ctx) + bint fq_zech_poly_is_one(const fq_zech_poly_t op, const fq_zech_ctx_t ctx) # Returns whether the polynomial ``poly`` is equal # to the constant polynomial `1`. - int fq_zech_poly_is_gen(const fq_zech_poly_t op, const fq_zech_ctx_t ctx) + bint fq_zech_poly_is_gen(const fq_zech_poly_t op, const fq_zech_ctx_t ctx) # Returns whether the polynomial ``poly`` is equal # to the polynomial `x`. - int fq_zech_poly_is_unit(const fq_zech_poly_t op, const fq_zech_ctx_t ctx) + bint fq_zech_poly_is_unit(const fq_zech_poly_t op, const fq_zech_ctx_t ctx) # Returns whether the polynomial ``poly`` is a unit in the polynomial # ring `\mathbf{F}_q[X]`, i.e. if it has degree `0` and is non-zero. - int fq_zech_poly_equal_fq_zech(const fq_zech_poly_t poly, const fq_zech_t c, const fq_zech_ctx_t ctx) + bint fq_zech_poly_equal_fq_zech(const fq_zech_poly_t poly, const fq_zech_t c, const fq_zech_ctx_t ctx) # Returns whether the polynomial ``poly`` is equal the (constant) # `\mathbf{F}_q` element ``c`` diff --git a/src/sage/libs/flint/fq_zech_poly_factor.pxd b/src/sage/libs/flint/fq_zech_poly_factor.pxd index 076ac2c548f..362f7556338 100644 --- a/src/sage/libs/flint/fq_zech_poly_factor.pxd +++ b/src/sage/libs/flint/fq_zech_poly_factor.pxd @@ -58,27 +58,27 @@ cdef extern from "flint_wrap.h": # Removes the highest possible power of ``p`` from ``f`` and # returns the exponent. - int fq_zech_poly_is_irreducible(const fq_zech_poly_t f, const fq_zech_ctx_t ctx) + bint fq_zech_poly_is_irreducible(const fq_zech_poly_t f, const fq_zech_ctx_t ctx) # Returns 1 if the polynomial ``f`` is irreducible, otherwise returns 0. - int fq_zech_poly_is_irreducible_ddf(const fq_zech_poly_t f, const fq_zech_ctx_t ctx) + bint fq_zech_poly_is_irreducible_ddf(const fq_zech_poly_t f, const fq_zech_ctx_t ctx) # Returns 1 if the polynomial ``f`` is irreducible, otherwise returns 0. # Uses fast distinct-degree factorisation. - int fq_zech_poly_is_irreducible_ben_or(const fq_zech_poly_t f, const fq_zech_ctx_t ctx) + bint fq_zech_poly_is_irreducible_ben_or(const fq_zech_poly_t f, const fq_zech_ctx_t ctx) # Returns 1 if the polynomial ``f`` is irreducible, otherwise returns 0. # Uses Ben-Or's irreducibility test. - int _fq_zech_poly_is_squarefree(const fq_zech_struct * f, slong len, const fq_zech_ctx_t ctx) + bint _fq_zech_poly_is_squarefree(const fq_zech_struct * f, slong len, const fq_zech_ctx_t ctx) # Returns 1 if ``(f, len)`` is squarefree, and 0 otherwise. As a # special case, the zero polynomial is not considered squarefree. # There are no restrictions on the length. - int fq_zech_poly_is_squarefree(const fq_zech_poly_t f, const fq_zech_ctx_t ctx) + bint fq_zech_poly_is_squarefree(const fq_zech_poly_t f, const fq_zech_ctx_t ctx) # Returns 1 if ``f`` is squarefree, and 0 otherwise. As a special # case, the zero polynomial is not considered squarefree. - int fq_zech_poly_factor_equal_deg_prob(fq_zech_poly_t factor, flint_rand_t state, const fq_zech_poly_t pol, slong d, const fq_zech_ctx_t ctx) + bint fq_zech_poly_factor_equal_deg_prob(fq_zech_poly_t factor, flint_rand_t state, const fq_zech_poly_t pol, slong d, const fq_zech_ctx_t ctx) # Probabilistic equal degree factorisation of ``pol`` into # irreducible factors of degree ``d``. If it passes, a factor is # placed in factor and 1 is returned, otherwise 0 is returned and diff --git a/src/sage/libs/flint/fq_zech_vec.pxd b/src/sage/libs/flint/fq_zech_vec.pxd index f1277706f08..cfe0f2c5770 100644 --- a/src/sage/libs/flint/fq_zech_vec.pxd +++ b/src/sage/libs/flint/fq_zech_vec.pxd @@ -46,11 +46,11 @@ cdef extern from "flint_wrap.h": void _fq_zech_vec_neg(fq_zech_struct * vec1, const fq_zech_struct * vec2, slong len2, const fq_zech_ctx_t ctx) # Negates ``(vec2, len2)`` and places it into ``vec1``. - int _fq_zech_vec_equal(const fq_zech_struct * vec1, const fq_zech_struct * vec2, slong len, const fq_zech_ctx_t ctx) + bint _fq_zech_vec_equal(const fq_zech_struct * vec1, const fq_zech_struct * vec2, slong len, const fq_zech_ctx_t ctx) # Compares two vectors of the given length and returns `1` if they are # equal, otherwise returns `0`. - int _fq_zech_vec_is_zero(const fq_zech_struct * vec, slong len, const fq_zech_ctx_t ctx) + bint _fq_zech_vec_is_zero(const fq_zech_struct * vec, slong len, const fq_zech_ctx_t ctx) # Returns `1` if ``(vec, len)`` is zero, and `0` otherwise. void _fq_zech_vec_add(fq_zech_struct * res, const fq_zech_struct * vec1, const fq_zech_struct * vec2, slong len2, const fq_zech_ctx_t ctx) diff --git a/src/sage/libs/flint/gr_generic.pxd b/src/sage/libs/flint/gr_generic.pxd index ebc302726d1..95dbf3336ab 100644 --- a/src/sage/libs/flint/gr_generic.pxd +++ b/src/sage/libs/flint/gr_generic.pxd @@ -187,7 +187,7 @@ cdef extern from "flint_wrap.h": truth_t gr_generic_vec_equal(gr_srcptr vec1, gr_srcptr vec2, slong len, gr_ctx_t ctx) - int gr_generic_vec_is_zero(gr_srcptr vec, slong len, gr_ctx_t ctx) + bint gr_generic_vec_is_zero(gr_srcptr vec, slong len, gr_ctx_t ctx) int gr_generic_vec_dot(gr_ptr res, gr_srcptr initial, int subtract, gr_srcptr vec1, gr_srcptr vec2, slong len, gr_ctx_t ctx) diff --git a/src/sage/libs/flint/mag.pxd b/src/sage/libs/flint/mag.pxd index 76a58ebb1ee..5ab2c7a5139 100644 --- a/src/sage/libs/flint/mag.pxd +++ b/src/sage/libs/flint/mag.pxd @@ -41,16 +41,16 @@ cdef extern from "flint_wrap.h": void mag_inf(mag_t res) # Sets *res* to positive infinity. - int mag_is_special(const mag_t x) + bint mag_is_special(const mag_t x) # Returns nonzero iff *x* is zero or positive infinity. - int mag_is_zero(const mag_t x) + bint mag_is_zero(const mag_t x) # Returns nonzero iff *x* is zero. - int mag_is_inf(const mag_t x) + bint mag_is_inf(const mag_t x) # Returns nonzero iff *x* is positive infinity. - int mag_is_finite(const mag_t x) + bint mag_is_finite(const mag_t x) # Returns nonzero iff *x* is not positive infinity (since there is no # NaN value, this function is exactly the logical negation of :func:`mag_is_inf`). @@ -109,7 +109,7 @@ cdef extern from "flint_wrap.h": # abort will be raised. If the exponent otherwise is too large or too small, # the available memory could be exhausted resulting in undefined behavior. - int mag_equal(const mag_t x, const mag_t y) + bint mag_equal(const mag_t x, const mag_t y) # Returns nonzero iff *x* and *y* have the same value. int mag_cmp(const mag_t x, const mag_t y) @@ -224,7 +224,7 @@ cdef extern from "flint_wrap.h": void mag_fast_zero(mag_t res) # Sets *res* to zero. - int mag_fast_is_zero(const mag_t x) + bint mag_fast_is_zero(const mag_t x) # Returns nonzero iff *x* to zero. void mag_fast_mul(mag_t res, const mag_t x, const mag_t y) diff --git a/src/sage/libs/flint/mpf_mat.pxd b/src/sage/libs/flint/mpf_mat.pxd index ee97e2b022f..529cb9996c9 100644 --- a/src/sage/libs/flint/mpf_mat.pxd +++ b/src/sage/libs/flint/mpf_mat.pxd @@ -57,25 +57,25 @@ cdef extern from "flint_wrap.h": void mpf_mat_print(const mpf_mat_t mat) # Prints the given matrix to the stream ``stdout``. - int mpf_mat_equal(const mpf_mat_t mat1, const mpf_mat_t mat2) + bint mpf_mat_equal(const mpf_mat_t mat1, const mpf_mat_t mat2) # Returns a non-zero value if ``mat1`` and ``mat2`` have # the same dimensions and entries, and zero otherwise. - int mpf_mat_approx_equal(const mpf_mat_t mat1, const mpf_mat_t mat2, flint_bitcnt_t bits) + bint mpf_mat_approx_equal(const mpf_mat_t mat1, const mpf_mat_t mat2, flint_bitcnt_t bits) # Returns a non-zero value if ``mat1`` and ``mat2`` have # the same dimensions and the first ``bits`` bits of their entries # are equal, and zero otherwise. - int mpf_mat_is_zero(const mpf_mat_t mat) + bint mpf_mat_is_zero(const mpf_mat_t mat) # Returns a non-zero value if all entries ``mat`` are zero, and # otherwise returns zero. - int mpf_mat_is_empty(const mpf_mat_t mat) + bint mpf_mat_is_empty(const mpf_mat_t mat) # Returns a non-zero value if the number of rows or the number of # columns in ``mat`` is zero, and otherwise returns # zero. - int mpf_mat_is_square(const mpf_mat_t mat) + bint mpf_mat_is_square(const mpf_mat_t mat) # Returns a non-zero value if the number of rows is equal to the # number of columns in ``mat``, and otherwise returns zero. diff --git a/src/sage/libs/flint/mpf_vec.pxd b/src/sage/libs/flint/mpf_vec.pxd index 0be034230ad..05005c8b2b6 100644 --- a/src/sage/libs/flint/mpf_vec.pxd +++ b/src/sage/libs/flint/mpf_vec.pxd @@ -35,14 +35,14 @@ cdef extern from "flint_wrap.h": # Export the array of ``len`` entries starting at the pointer ``vec`` # to an array of mpfs ``appv``. - int _mpf_vec_equal(const mpf * vec1, const mpf * vec2, slong len) + bint _mpf_vec_equal(const mpf * vec1, const mpf * vec2, slong len) # Compares two vectors of the given length and returns `1` if they are # equal, otherwise returns `0`. - int _mpf_vec_is_zero(const mpf * vec, slong len) + bint _mpf_vec_is_zero(const mpf * vec, slong len) # Returns `1` if ``(vec, len)`` is zero, and `0` otherwise. - int _mpf_vec_approx_equal(const mpf * vec1, const mpf * vec2, slong len, flint_bitcnt_t bits) + bint _mpf_vec_approx_equal(const mpf * vec1, const mpf * vec2, slong len, flint_bitcnt_t bits) # Compares two vectors of the given length and returns `1` if the first # ``bits`` bits of their entries are equal, otherwise returns `0`. diff --git a/src/sage/libs/flint/mpfr_mat.pxd b/src/sage/libs/flint/mpfr_mat.pxd index b673775b899..7a821764a55 100644 --- a/src/sage/libs/flint/mpfr_mat.pxd +++ b/src/sage/libs/flint/mpfr_mat.pxd @@ -38,7 +38,7 @@ cdef extern from "flint_wrap.h": void mpfr_mat_zero(mpfr_mat_t mat) # Set ``mat`` to the zero matrix. - int mpfr_mat_equal(const mpfr_mat_t mat1, const mpfr_mat_t mat2) + bint mpfr_mat_equal(const mpfr_mat_t mat1, const mpfr_mat_t mat2) # Return `1` if the two given matrices are equal, otherwise return `0`. void mpfr_mat_randtest(mpfr_mat_t mat, flint_rand_t state) diff --git a/src/sage/libs/flint/mpoly.pxd b/src/sage/libs/flint/mpoly.pxd index fdf7101a3a6..83905ccef53 100644 --- a/src/sage/libs/flint/mpoly.pxd +++ b/src/sage/libs/flint/mpoly.pxd @@ -74,10 +74,10 @@ cdef extern from "flint_wrap.h": # Set the words of ``(exp2, N)`` to the words of ``(exp3, N)`` # multiplied by ``c``. - int mpoly_monomial_is_zero(const ulong * exp, slong N) + bint mpoly_monomial_is_zero(const ulong * exp, slong N) # Return 1 if ``(exp, N)`` is zero. - int mpoly_monomial_equal(const ulong * exp2, const ulong * exp3, slong N) + bint mpoly_monomial_equal(const ulong * exp2, const ulong * exp3, slong N) # Return 1 if the monomials ``(exp2, N)`` and ``(exp3, N)`` are equal. void mpoly_get_cmpmask(ulong * cmpmask, slong N, ulong bits, const mpoly_ctx_t mctx) @@ -86,10 +86,10 @@ cdef extern from "flint_wrap.h": # to be compared. Any function that compares monomials should use this # comparison mask. - int mpoly_monomial_lt(const ulong * exp2, const ulong * exp3, slong N, const ulong * cmpmask) + bint mpoly_monomial_lt(const ulong * exp2, const ulong * exp3, slong N, const ulong * cmpmask) # Return 1 if ``(exp2, N)`` is less than ``(exp3, N)``. - int mpoly_monomial_gt(const ulong * exp2, const ulong * exp3, slong N, const ulong * cmpmask) + bint mpoly_monomial_gt(const ulong * exp2, const ulong * exp3, slong N, const ulong * cmpmask) # Return 1 if ``(exp2, N)`` is greater than ``(exp3, N)``. int mpoly_monomial_cmp(const ulong * exp2, const ulong * exp3, slong N, const ulong * cmpmask) diff --git a/src/sage/libs/flint/nf_elem.pxd b/src/sage/libs/flint/nf_elem.pxd index b48d890f8ce..a0034c21fef 100644 --- a/src/sage/libs/flint/nf_elem.pxd +++ b/src/sage/libs/flint/nf_elem.pxd @@ -99,21 +99,21 @@ cdef extern from "flint_wrap.h": # Set the `i`-th coefficient of the denominator of `a` to the given integer # `d`. - int _nf_elem_equal(const nf_elem_t a, const nf_elem_t b, const nf_t nf) + bint _nf_elem_equal(const nf_elem_t a, const nf_elem_t b, const nf_t nf) # Return `1` if the given number field elements are equal in the given # number field ``nf``. This function does \emph{not} assume `a` and `b` # are canonicalised. - int nf_elem_equal(const nf_elem_t a, const nf_elem_t b, const nf_t nf) + bint nf_elem_equal(const nf_elem_t a, const nf_elem_t b, const nf_t nf) # Return `1` if the given number field elements are equal in the given # number field ``nf``. This function assumes `a` and `b` \emph{are} # canonicalised. - int nf_elem_is_zero(const nf_elem_t a, const nf_t nf) + bint nf_elem_is_zero(const nf_elem_t a, const nf_t nf) # Return `1` if the given number field element is equal to zero, # otherwise return `0`. - int nf_elem_is_one(const nf_elem_t a, const nf_t nf) + bint nf_elem_is_one(const nf_elem_t a, const nf_t nf) # Return `1` if the given number field element is equal to one, # otherwise return `0`. diff --git a/src/sage/libs/flint/nmod_mat.pxd b/src/sage/libs/flint/nmod_mat.pxd index fa0e6a253a6..d5432e00ac7 100644 --- a/src/sage/libs/flint/nmod_mat.pxd +++ b/src/sage/libs/flint/nmod_mat.pxd @@ -62,7 +62,7 @@ cdef extern from "flint_wrap.h": void nmod_mat_zero(nmod_mat_t mat) # Sets all entries of the matrix ``mat`` to zero. - int nmod_mat_is_zero(const nmod_mat_t mat) + bint nmod_mat_is_zero(const nmod_mat_t mat) # Returns `1` if all entries of the matrix ``mat`` are zero. void nmod_mat_window_init(nmod_mat_t window, const nmod_mat_t mat, slong r1, slong c1, slong r2, slong c2) @@ -143,11 +143,11 @@ cdef extern from "flint_wrap.h": # it will have ones on the main diagonal, otherwise it will have random # nonzero entries on the main diagonal. - int nmod_mat_equal(const nmod_mat_t mat1, const nmod_mat_t mat2) + bint nmod_mat_equal(const nmod_mat_t mat1, const nmod_mat_t mat2) # Returns nonzero if ``mat1`` and ``mat2`` have the same dimensions and elements, # and zero otherwise. The moduli are ignored. - int nmod_mat_is_zero_row(const nmod_mat_t mat, slong i) + bint nmod_mat_is_zero_row(const nmod_mat_t mat, slong i) # Returns a non-zero value if row `i` of ``mat`` is zero. void nmod_mat_transpose(nmod_mat_t B, const nmod_mat_t A) diff --git a/src/sage/libs/flint/nmod_mpoly.pxd b/src/sage/libs/flint/nmod_mpoly.pxd index 815dfb7dcb2..c6902fa6a5d 100644 --- a/src/sage/libs/flint/nmod_mpoly.pxd +++ b/src/sage/libs/flint/nmod_mpoly.pxd @@ -68,20 +68,20 @@ cdef extern from "flint_wrap.h": void nmod_mpoly_gen(nmod_mpoly_t A, slong var, const nmod_mpoly_ctx_t ctx) # Set *A* to the variable of index *var*, where `var = 0` corresponds to the variable with the most significance with respect to the ordering. - int nmod_mpoly_is_gen(const nmod_mpoly_t A, slong var, const nmod_mpoly_ctx_t ctx) + bint nmod_mpoly_is_gen(const nmod_mpoly_t A, slong var, const nmod_mpoly_ctx_t ctx) # If `var \ge 0`, return `1` if *A* is equal to the `var`-th generator, otherwise return `0`. # If `var < 0`, return `1` if the polynomial is equal to any generator, otherwise return `0`. void nmod_mpoly_set(nmod_mpoly_t A, const nmod_mpoly_t B, const nmod_mpoly_ctx_t ctx) # Set *A* to *B*. - int nmod_mpoly_equal(const nmod_mpoly_t A, const nmod_mpoly_t B, const nmod_mpoly_ctx_t ctx) + bint nmod_mpoly_equal(const nmod_mpoly_t A, const nmod_mpoly_t B, const nmod_mpoly_ctx_t ctx) # Return `1` if *A* is equal to *B*, else return `0`. void nmod_mpoly_swap(nmod_mpoly_t A, nmod_mpoly_t B, const nmod_mpoly_ctx_t ctx) # Efficiently swap *A* and *B*. - int nmod_mpoly_is_ui(const nmod_mpoly_t A, const nmod_mpoly_ctx_t ctx) + bint nmod_mpoly_is_ui(const nmod_mpoly_t A, const nmod_mpoly_ctx_t ctx) # Return `1` if *A* is a constant, else return `0`. ulong nmod_mpoly_get_ui(const nmod_mpoly_t A, const nmod_mpoly_ctx_t ctx) @@ -97,13 +97,13 @@ cdef extern from "flint_wrap.h": void nmod_mpoly_one(nmod_mpoly_t A, const nmod_mpoly_ctx_t ctx) # Set *A* to the constant `1`. - int nmod_mpoly_equal_ui(const nmod_mpoly_t A, ulong c, const nmod_mpoly_ctx_t ctx) + bint nmod_mpoly_equal_ui(const nmod_mpoly_t A, ulong c, const nmod_mpoly_ctx_t ctx) # Return `1` if *A* is equal to the constant *c*, else return `0`. - int nmod_mpoly_is_zero(const nmod_mpoly_t A, const nmod_mpoly_ctx_t ctx) + bint nmod_mpoly_is_zero(const nmod_mpoly_t A, const nmod_mpoly_ctx_t ctx) # Return `1` if *A* is the constant `0`, else return `0`. - int nmod_mpoly_is_one(const nmod_mpoly_t A, const nmod_mpoly_ctx_t ctx) + bint nmod_mpoly_is_one(const nmod_mpoly_t A, const nmod_mpoly_ctx_t ctx) # Return `1` if *A* is the constant `1`, else return `0`. int nmod_mpoly_degrees_fit_si(const nmod_mpoly_t A, const nmod_mpoly_ctx_t ctx) @@ -157,7 +157,7 @@ cdef extern from "flint_wrap.h": mp_limb_t * nmod_mpoly_term_coeff_ref(nmod_mpoly_t A, slong i, const nmod_mpoly_ctx_t ctx) # Return a reference to the coefficient of index *i* of *A*. - int nmod_mpoly_is_canonical(const nmod_mpoly_t A, const nmod_mpoly_ctx_t ctx) + bint nmod_mpoly_is_canonical(const nmod_mpoly_t A, const nmod_mpoly_ctx_t ctx) # Return `1` if *A* is in canonical form. Otherwise, return `0`. # To be in canonical form, all of the terms must have nonzero coefficients, and the terms must be sorted from greatest to least. @@ -361,7 +361,7 @@ cdef extern from "flint_wrap.h": int nmod_mpoly_sqrt(nmod_mpoly_t Q, const nmod_mpoly_t A, const nmod_mpoly_ctx_t ctx) # If `Q^2=A` has a solution, set *Q* to a solution and return `1`, otherwise return `0` and set *Q* to zero. - int nmod_mpoly_is_square(const nmod_mpoly_t A, const nmod_mpoly_ctx_t ctx) + bint nmod_mpoly_is_square(const nmod_mpoly_t A, const nmod_mpoly_ctx_t ctx) # Return `1` if *A* is a perfect square, otherwise return `0`. int nmod_mpoly_quadratic_root(nmod_mpoly_t Q, const nmod_mpoly_t A, const nmod_mpoly_t B, const nmod_mpoly_ctx_t ctx) diff --git a/src/sage/libs/flint/nmod_poly.pxd b/src/sage/libs/flint/nmod_poly.pxd index bae767aca2f..422f5b365d0 100644 --- a/src/sage/libs/flint/nmod_poly.pxd +++ b/src/sage/libs/flint/nmod_poly.pxd @@ -71,9 +71,9 @@ cdef extern from "flint_wrap.h": flint_bitcnt_t nmod_poly_max_bits(const nmod_poly_t poly) # Returns the maximum number of bits of any coefficient of ``poly``. - int nmod_poly_is_unit(const nmod_poly_t poly) + bint nmod_poly_is_unit(const nmod_poly_t poly) - int nmod_poly_is_monic(const nmod_poly_t poly) + bint nmod_poly_is_monic(const nmod_poly_t poly) void nmod_poly_set(nmod_poly_t a, const nmod_poly_t b) # Sets ``a`` to a copy of ``b``. @@ -234,32 +234,32 @@ cdef extern from "flint_wrap.h": # :func:`nmod_poly_print`. If a polynomial in the correct format is read, a # positive value is returned, otherwise a non-positive value is returned. - int nmod_poly_equal(const nmod_poly_t a, const nmod_poly_t b) + bint nmod_poly_equal(const nmod_poly_t a, const nmod_poly_t b) # Returns `1` if the polynomials are equal, otherwise `0`. - int nmod_poly_equal_nmod(const nmod_poly_t poly, ulong cst) + bint nmod_poly_equal_nmod(const nmod_poly_t poly, ulong cst) # Returns `1` if the polynomial ``poly`` is constant, equal to ``cst``, # otherwise `0`. # ``cst`` is assumed to be already reduced, i.e. less than the modulus of # ``poly``. - int nmod_poly_equal_ui(const nmod_poly_t poly, ulong cst) + bint nmod_poly_equal_ui(const nmod_poly_t poly, ulong cst) # Returns `1` if the polynomial ``poly`` is constant and equal to ``cst`` up to # reduction modulo the modulus of ``poly``, otherwise returns `0`. - int nmod_poly_equal_trunc(const nmod_poly_t poly1, const nmod_poly_t poly2, slong n) + bint nmod_poly_equal_trunc(const nmod_poly_t poly1, const nmod_poly_t poly2, slong n) # Notionally truncate ``poly1`` and ``poly2`` to length `n` and return # `1` if the truncations are equal, otherwise return `0`. - int nmod_poly_is_zero(const nmod_poly_t poly) + bint nmod_poly_is_zero(const nmod_poly_t poly) # Returns `1` if the polynomial ``poly`` is the zero polynomial, # otherwise returns `0`. - int nmod_poly_is_one(const nmod_poly_t poly) + bint nmod_poly_is_one(const nmod_poly_t poly) # Returns `1` if the polynomial ``poly`` is the constant polynomial 1, # otherwise returns `0`. - int nmod_poly_is_gen(const nmod_poly_t poly) + bint nmod_poly_is_gen(const nmod_poly_t poly) void _nmod_poly_shift_left(mp_ptr res, mp_srcptr poly, slong len, slong k) # Sets ``(res, len + k)`` to ``(poly, len)`` shifted left by diff --git a/src/sage/libs/flint/nmod_poly_factor.pxd b/src/sage/libs/flint/nmod_poly_factor.pxd index 81a119ed719..b4f3d03573e 100644 --- a/src/sage/libs/flint/nmod_poly_factor.pxd +++ b/src/sage/libs/flint/nmod_poly_factor.pxd @@ -55,30 +55,30 @@ cdef extern from "flint_wrap.h": # Removes the highest possible power of ``p`` from ``f`` and # returns the exponent. - int nmod_poly_is_irreducible(const nmod_poly_t f) + bint nmod_poly_is_irreducible(const nmod_poly_t f) # Returns 1 if the polynomial ``f`` is irreducible, otherwise returns 0. - int nmod_poly_is_irreducible_ddf(const nmod_poly_t f) + bint nmod_poly_is_irreducible_ddf(const nmod_poly_t f) # Returns 1 if the polynomial ``f`` is irreducible, otherwise returns 0. # Uses fast distinct-degree factorisation. - int nmod_poly_is_irreducible_rabin(const nmod_poly_t f) + bint nmod_poly_is_irreducible_rabin(const nmod_poly_t f) # Returns 1 if the polynomial ``f`` is irreducible, otherwise returns 0. # Uses Rabin irreducibility test. - int _nmod_poly_is_squarefree(mp_srcptr f, slong len, nmod_t mod) + bint _nmod_poly_is_squarefree(mp_srcptr f, slong len, nmod_t mod) # Returns 1 if ``(f, len)`` is squarefree, and 0 otherwise. As a # special case, the zero polynomial is not considered squarefree. # There are no restrictions on the length. - int nmod_poly_is_squarefree(const nmod_poly_t f) + bint nmod_poly_is_squarefree(const nmod_poly_t f) # Returns 1 if ``f`` is squarefree, and 0 otherwise. As a special # case, the zero polynomial is not considered squarefree. void nmod_poly_factor_squarefree(nmod_poly_factor_t res, const nmod_poly_t f) # Sets ``res`` to a square-free factorization of ``f``. - int nmod_poly_factor_equal_deg_prob(nmod_poly_t factor, flint_rand_t state, const nmod_poly_t pol, slong d) + bint nmod_poly_factor_equal_deg_prob(nmod_poly_t factor, flint_rand_t state, const nmod_poly_t pol, slong d) # Probabilistic equal degree factorisation of ``pol`` into # irreducible factors of degree ``d``. If it passes, a factor is # placed in factor and 1 is returned, otherwise 0 is returned and diff --git a/src/sage/libs/flint/nmod_poly_mat.pxd b/src/sage/libs/flint/nmod_poly_mat.pxd index 64e3d15a5fe..0fa57b73920 100644 --- a/src/sage/libs/flint/nmod_poly_mat.pxd +++ b/src/sage/libs/flint/nmod_poly_mat.pxd @@ -94,29 +94,29 @@ cdef extern from "flint_wrap.h": # having the element 1 on the main diagonal and zeros elsewhere. # If ``mat`` is nonsquare, it is set to the truncation of a unit matrix. - int nmod_poly_mat_equal(const nmod_poly_mat_t mat1, const nmod_poly_mat_t mat2) + bint nmod_poly_mat_equal(const nmod_poly_mat_t mat1, const nmod_poly_mat_t mat2) # Returns nonzero if ``mat1`` and ``mat2`` have the same shape and # all their entries agree, and returns zero otherwise. - int nmod_poly_mat_equal_nmod_mat(const nmod_poly_mat_t pmat, const nmod_mat_t cmat) + bint nmod_poly_mat_equal_nmod_mat(const nmod_poly_mat_t pmat, const nmod_mat_t cmat) # Returns nonzero if ``pmat`` is a constant matrix with the same dimensions # and entries as ``cmat``; returns zero otherwise. - int nmod_poly_mat_is_zero(const nmod_poly_mat_t mat) + bint nmod_poly_mat_is_zero(const nmod_poly_mat_t mat) # Returns nonzero if all entries in ``mat`` are zero, and returns # zero otherwise. - int nmod_poly_mat_is_one(const nmod_poly_mat_t mat) + bint nmod_poly_mat_is_one(const nmod_poly_mat_t mat) # Returns nonzero if all entry of ``mat`` on the main diagonal # are the constant polynomial 1 and all remaining entries are zero, # and returns zero otherwise. The matrix need not be square. - int nmod_poly_mat_is_empty(const nmod_poly_mat_t mat) + bint nmod_poly_mat_is_empty(const nmod_poly_mat_t mat) # Returns a non-zero value if the number of rows or the number of # columns in ``mat`` is zero, and otherwise returns # zero. - int nmod_poly_mat_is_square(const nmod_poly_mat_t mat) + bint nmod_poly_mat_is_square(const nmod_poly_mat_t mat) # Returns a non-zero value if the number of rows is equal to the # number of columns in ``mat``, and otherwise returns zero. diff --git a/src/sage/libs/flint/nmod_vec.pxd b/src/sage/libs/flint/nmod_vec.pxd index ebfee4249fa..8009c859d49 100644 --- a/src/sage/libs/flint/nmod_vec.pxd +++ b/src/sage/libs/flint/nmod_vec.pxd @@ -40,7 +40,7 @@ cdef extern from "flint_wrap.h": flint_bitcnt_t _nmod_vec_max_bits(mp_srcptr vec, slong len) # Returns the maximum number of bits of any entry in the vector. - int _nmod_vec_equal(mp_srcptr vec, mp_srcptr vec2, slong len) + bint _nmod_vec_equal(mp_srcptr vec, mp_srcptr vec2, slong len) # Returns~`1` if ``(vec, len)`` is equal to ``(vec2, len)``, # otherwise returns~`0`. diff --git a/src/sage/libs/flint/padic.pxd b/src/sage/libs/flint/padic.pxd index dcac2d712df..ab2a2328cb3 100644 --- a/src/sage/libs/flint/padic.pxd +++ b/src/sage/libs/flint/padic.pxd @@ -149,14 +149,14 @@ cdef extern from "flint_wrap.h": # Sets the `p`-adic number ``rop`` to one, reduced modulo the # precision of ``rop``. - int padic_is_zero(const padic_t op) + bint padic_is_zero(const padic_t op) # Returns whether ``op`` is equal to zero. - int padic_is_one(const padic_t op) + bint padic_is_one(const padic_t op) # Returns whether ``op`` is equal to one, that is, whether # `u = 1` and `v = 0`. - int padic_equal(const padic_t op1, const padic_t op2) + bint padic_equal(const padic_t op1, const padic_t op2) # Returns whether ``op1`` and ``op2`` are equal, that is, # whether `u_1 = u_2` and `v_1 = v_2`. diff --git a/src/sage/libs/flint/padic_mat.pxd b/src/sage/libs/flint/padic_mat.pxd index 37bb36d3ce2..d0e0c541f4c 100644 --- a/src/sage/libs/flint/padic_mat.pxd +++ b/src/sage/libs/flint/padic_mat.pxd @@ -66,14 +66,14 @@ cdef extern from "flint_wrap.h": # Ensures that the matrix `A` is reduced modulo `p^N`, # without assuming that it is necessarily in canonical form. - int padic_mat_is_empty(const padic_mat_t A) + bint padic_mat_is_empty(const padic_mat_t A) # Returns whether the matrix `A` is empty, that is, # whether it has zero rows or zero columns. - int padic_mat_is_square(const padic_mat_t A) + bint padic_mat_is_square(const padic_mat_t A) # Returns whether the matrix `A` is square. - int padic_mat_is_canonical(const padic_mat_t A, const padic_ctx_t p) + bint padic_mat_is_canonical(const padic_mat_t A, const padic_ctx_t p) # Returns whether the matrix `A` is in canonical form. void padic_mat_set(padic_mat_t B, const padic_mat_t A, const padic_ctx_t p) @@ -108,10 +108,10 @@ cdef extern from "flint_wrap.h": void padic_mat_set_entry_padic(padic_mat_t rop, slong i, slong j, const padic_t op, const padic_ctx_t ctx) # Sets the entry in position `(i, j)` in the matrix to ``rop``. - int padic_mat_equal(const padic_mat_t A, const padic_mat_t B) + bint padic_mat_equal(const padic_mat_t A, const padic_mat_t B) # Returns whether the two matrices `A` and `B` are equal. - int padic_mat_is_zero(const padic_mat_t A) + bint padic_mat_is_zero(const padic_mat_t A) # Returns whether the matrix `A` is zero. int padic_mat_fprint(FILE * file, const padic_mat_t A, const padic_ctx_t ctx) diff --git a/src/sage/libs/flint/padic_poly.pxd b/src/sage/libs/flint/padic_poly.pxd index b706daa47eb..37cf4d0435e 100644 --- a/src/sage/libs/flint/padic_poly.pxd +++ b/src/sage/libs/flint/padic_poly.pxd @@ -168,14 +168,14 @@ cdef extern from "flint_wrap.h": # Note that this operation can take linear time in the length # of the polynomial. - int padic_poly_equal(const padic_poly_t poly1, const padic_poly_t poly2) + bint padic_poly_equal(const padic_poly_t poly1, const padic_poly_t poly2) # Returns whether the two polynomials ``poly1`` and ``poly2`` # are equal. - int padic_poly_is_zero(const padic_poly_t poly) + bint padic_poly_is_zero(const padic_poly_t poly) # Returns whether the polynomial ``poly`` is the zero polynomial. - int padic_poly_is_one(const padic_poly_t poly) + bint padic_poly_is_one(const padic_poly_t poly) # Returns whether the polynomial ``poly`` is equal # to the constant polynomial~`1`, taking the precision # of the polynomial into account. @@ -346,7 +346,7 @@ cdef extern from "flint_wrap.h": int _padic_poly_print_pretty(const fmpz *poly, slong val, slong len, const char *var, const padic_ctx_t ctx) int padic_poly_print_pretty(const padic_poly_t poly, const char *var, const padic_ctx_t ctx) - int _padic_poly_is_canonical(const fmpz *op, slong val, slong len, const padic_ctx_t ctx) - int padic_poly_is_canonical(const padic_poly_t op, const padic_ctx_t ctx) - int _padic_poly_is_reduced(const fmpz *op, slong val, slong len, slong N, const padic_ctx_t ctx) - int padic_poly_is_reduced(const padic_poly_t op, const padic_ctx_t ctx) + bint _padic_poly_is_canonical(const fmpz *op, slong val, slong len, const padic_ctx_t ctx) + bint padic_poly_is_canonical(const padic_poly_t op, const padic_ctx_t ctx) + bint _padic_poly_is_reduced(const fmpz *op, slong val, slong len, slong N, const padic_ctx_t ctx) + bint padic_poly_is_reduced(const padic_poly_t op, const padic_ctx_t ctx) diff --git a/src/sage/libs/flint/qadic.pxd b/src/sage/libs/flint/qadic.pxd index fbcd6fe7134..6d3cb1b50ad 100644 --- a/src/sage/libs/flint/qadic.pxd +++ b/src/sage/libs/flint/qadic.pxd @@ -127,14 +127,14 @@ cdef extern from "flint_wrap.h": # If the element ``op`` lies in `\mathbf{Q}_p`, sets ``rop`` # to its value and returns `1`; otherwise, returns `0`. - int qadic_is_zero(const qadic_t op) + bint qadic_is_zero(const qadic_t op) # Returns whether ``op`` is equal to zero. - int qadic_is_one(const qadic_t op) + bint qadic_is_one(const qadic_t op) # Returns whether ``op`` is equal to one in the given # context. - int qadic_equal(const qadic_t op1, const qadic_t op2) + bint qadic_equal(const qadic_t op1, const qadic_t op2) # Returns whether ``op1`` and ``op2`` are equal. void qadic_add(qadic_t rop, const qadic_t op1, const qadic_t op2, const qadic_ctx_t ctx) diff --git a/src/sage/libs/flint/qfb.pxd b/src/sage/libs/flint/qfb.pxd index 669d144b68c..ce978aa0503 100644 --- a/src/sage/libs/flint/qfb.pxd +++ b/src/sage/libs/flint/qfb.pxd @@ -45,7 +45,7 @@ cdef extern from "flint_wrap.h": void qfb_set(qfb_t f, qfb_t g) # Set the binary quadratic form `f` to be equal to `g`. - int qfb_equal(qfb_t f, qfb_t g) + bint qfb_equal(qfb_t f, qfb_t g) # Returns `1` if `f` and `g` are identical binary quadratic forms, # otherwise returns `0`. @@ -61,7 +61,7 @@ cdef extern from "flint_wrap.h": # Set `r` to a reduced form equivalent to the binary quadratic form `f` # of discriminant `D`. - int qfb_is_reduced(qfb_t r) + bint qfb_is_reduced(qfb_t r) # Returns `1` if `q` is a reduced binary quadratic form, otherwise # returns `0`. Note that this only tests for definite quadratic # forms, so a form `r = (a,b,c)` is reduced if and only if `|b| \le a \le @@ -106,7 +106,7 @@ cdef extern from "flint_wrap.h": void qfb_inverse(qfb_t r, qfb_t f) # Set `r` to the inverse of the binary quadratic form `f`. - int qfb_is_principal_form(qfb_t f, fmpz_t D) + bint qfb_is_principal_form(qfb_t f, fmpz_t D) # Return `1` if `f` is the reduced principal form of discriminant `D`, # i.e. the identity in the form class group, else `0`. @@ -114,7 +114,7 @@ cdef extern from "flint_wrap.h": # Set `f` to the principal form of discriminant `D`, i.e. the identity in # the form class group. - int qfb_is_primitive(qfb_t f) + bint qfb_is_primitive(qfb_t f) # Return `1` if `f` is primitive, i.e. the greatest common divisor of its # three coefficients is `1`. Otherwise the function returns `0`. diff --git a/src/sage/libs/flint/qqbar.pxd b/src/sage/libs/flint/qqbar.pxd index 6fd9dfcbac5..cb220973c5d 100644 --- a/src/sage/libs/flint/qqbar.pxd +++ b/src/sage/libs/flint/qqbar.pxd @@ -48,26 +48,26 @@ cdef extern from "flint_wrap.h": slong qqbar_degree(const qqbar_t x) # Returns the degree of *x*, i.e. the degree of the minimal polynomial. - int qqbar_is_rational(const qqbar_t x) + bint qqbar_is_rational(const qqbar_t x) # Returns whether *x* is a rational number. - int qqbar_is_integer(const qqbar_t x) + bint qqbar_is_integer(const qqbar_t x) # Returns whether *x* is an integer (an element of `\mathbb{Z}`). - int qqbar_is_algebraic_integer(const qqbar_t x) + bint qqbar_is_algebraic_integer(const qqbar_t x) # Returns whether *x* is an algebraic integer, i.e. whether its minimal # polynomial has leading coefficient 1. - int qqbar_is_zero(const qqbar_t x) - int qqbar_is_one(const qqbar_t x) - int qqbar_is_neg_one(const qqbar_t x) + bint qqbar_is_zero(const qqbar_t x) + bint qqbar_is_one(const qqbar_t x) + bint qqbar_is_neg_one(const qqbar_t x) # Returns whether *x* is the number `0`, `1`, `-1`. - int qqbar_is_i(const qqbar_t x) - int qqbar_is_neg_i(const qqbar_t x) + bint qqbar_is_i(const qqbar_t x) + bint qqbar_is_neg_i(const qqbar_t x) # Returns whether *x* is the imaginary unit `i` (respectively `-i`). - int qqbar_is_real(const qqbar_t x) + bint qqbar_is_real(const qqbar_t x) # Returns whether *x* is a real number. void qqbar_height(fmpz_t res, const qqbar_t x) @@ -141,10 +141,10 @@ cdef extern from "flint_wrap.h": # with height (measured in bits) up to *bits*. Since all algebraic numbers # of degree 1 are real, *deg* must be at least 2. - int qqbar_equal(const qqbar_t x, const qqbar_t y) + bint qqbar_equal(const qqbar_t x, const qqbar_t y) # Returns whether *x* and *y* are equal. - int qqbar_equal_fmpq_poly_val(const qqbar_t x, const fmpq_poly_t f, const qqbar_t y) + bint qqbar_equal_fmpq_poly_val(const qqbar_t x, const fmpq_poly_t f, const qqbar_t y) # Returns whether *x* is equal to `f(y)`. This function is more efficient # than evaluating `f(y)` and comparing the results. @@ -398,7 +398,7 @@ cdef extern from "flint_wrap.h": void qqbar_root_of_unity(qqbar_t res, slong p, ulong q) # Sets *res* to the root of unity `e^{2 \pi i p / q}`. - int qqbar_is_root_of_unity(slong * p, ulong * q, const qqbar_t x) + bint qqbar_is_root_of_unity(slong * p, ulong * q, const qqbar_t x) # If *x* is not a root of unity, returns 0. # If *x* is a root of unity, returns 1. # If *p* and *q* are not *NULL* and *x* is a root of unity, diff --git a/src/sage/libs/flint/types.pxd b/src/sage/libs/flint/types.pxd index b9f5f9f11df..2ffc8bfe237 100644 --- a/src/sage/libs/flint/types.pxd +++ b/src/sage/libs/flint/types.pxd @@ -44,7 +44,8 @@ cdef extern from "flint_wrap.h": ctypedef struct fmpz_comb_temp_struct: slong Alen, Tlen - fmpz * A, * T + fmpz * A + fmpz * T ctypedef fmpz_comb_temp_struct fmpz_comb_temp_t[1] @@ -177,7 +178,6 @@ cdef extern from "flint_wrap.h": pass ctypedef flint_rand_s flint_rand_t[1] - ctypedef void* flint_rand_t cdef long FLINT_BITS cdef long FLINT_D_BITS diff --git a/src/sage/libs/flint/ulong_extras.pxd b/src/sage/libs/flint/ulong_extras.pxd index d5c4e444be0..1c3a82f057a 100644 --- a/src/sage/libs/flint/ulong_extras.pxd +++ b/src/sage/libs/flint/ulong_extras.pxd @@ -528,14 +528,14 @@ cdef extern from "flint_wrap.h": # ``n_prime_pi_bounds()``, and estimate `\ln \ln n` to the nearest # integer; this function is nearly constant. - int n_is_oddprime_small(ulong n) + bint n_is_oddprime_small(ulong n) # Returns `1` if `n` is an odd prime smaller than # ``FLINT_ODDPRIME_SMALL_CUTOFF``. Expects `n` # to be odd and smaller than the cutoff. # This function merely uses a lookup table with one bit allocated for each # odd number up to the cutoff. - int n_is_oddprime_binary(ulong n) + bint n_is_oddprime_binary(ulong n) # This function performs a simple binary search through # the table of cached primes for `n`. If it exists in the array it returns # `1`, otherwise `0`. For the algorithm to operate correctly @@ -545,7 +545,7 @@ cdef extern from "flint_wrap.h": # refine our search with a simple binary algorithm, taking # the top or bottom of the current interval as necessary. - int n_is_prime_pocklington(ulong n, ulong iterations) + bint n_is_prime_pocklington(ulong n, ulong iterations) # Tests if `n` is a prime using the Pocklington--Lehmer primality # test. If `1` is returned `n` has been proved prime. If `0` is returned # `n` is composite. However `-1` may be returned if nothing was proved @@ -565,7 +565,7 @@ cdef extern from "flint_wrap.h": # https://mathworld.wolfram.com/PocklingtonsTheorem.html # for a description of the algorithm. - int n_is_prime_pseudosquare(ulong n) + bint n_is_prime_pseudosquare(ulong n) # Tests if `n` is a prime according to Theorem 2.7 [LukPatWil1996]_. # We first factor `N` using trial division up to some limit `B`. # In fact, the number of primes used in the trial factoring is at @@ -591,7 +591,7 @@ cdef extern from "flint_wrap.h": # composite prime. However in that case an error is printed, as # that would be of independent interest. - int n_is_prime(ulong n) + bint n_is_prime(ulong n) # Tests if `n` is a prime. This first sieves for small prime factors, # then simply calls :func:`n_is_probabprime`. This has been checked # against the tables of Feitsma and Galway @@ -602,7 +602,7 @@ cdef extern from "flint_wrap.h": # primality. This is likely to be significantly slower for prime # inputs. - int n_is_strong_probabprime_precomp(ulong n, double npre, ulong a, ulong d) + bint n_is_strong_probabprime_precomp(ulong n, double npre, ulong a, ulong d) # Tests if `n` is a strong probable prime to the base `a`. We # require that `d` is set to the largest odd factor of `n - 1` and # ``npre`` is a precomputed inverse of `n` computed with @@ -615,7 +615,7 @@ cdef extern from "flint_wrap.h": # A description of strong probable primes is given here: # https://mathworld.wolfram.com/StrongPseudoprime.html - int n_is_strong_probabprime2_preinv(ulong n, ulong ninv, ulong a, ulong d) + bint n_is_strong_probabprime2_preinv(ulong n, ulong ninv, ulong a, ulong d) # Tests if `n` is a strong probable prime to the base `a`. We require # that `d` is set to the largest odd factor of `n - 1` and ``npre`` # is a precomputed inverse of `n` computed with :func:`n_preinvert_limb`. @@ -626,13 +626,13 @@ cdef extern from "flint_wrap.h": # A description of strong probable primes is given here: # https://mathworld.wolfram.com/StrongPseudoprime.html - int n_is_probabprime_fermat(ulong n, ulong i) + bint n_is_probabprime_fermat(ulong n, ulong i) # Returns `1` if `n` is a base `i` Fermat probable prime. Requires # `1 < i < n` and that `i` does not divide `n`. # By Fermat's Little Theorem if `i^{n-1}` is not congruent to `1` # then `n` is not prime. - int n_is_probabprime_fibonacci(ulong n) + bint n_is_probabprime_fibonacci(ulong n) # Let `F_j` be the `j`\th element of the Fibonacci sequence # `0, 1, 1, 2, 3, 5, \dotsc`, starting at `j = 0`. Then if `n` is prime # we have `F_{n - (n/5)} = 0 \pmod n`, where `(n/5)` is the Jacobi @@ -640,7 +640,7 @@ cdef extern from "flint_wrap.h": # For further details, see pp. 142 [CraPom2005]_. # We require that `n` is not divisible by `2` or `5`. - int n_is_probabprime_BPSW(ulong n) + bint n_is_probabprime_BPSW(ulong n) # Implements a Baillie--Pomerance--Selfridge--Wagstaff probable primality # test. This is a variant of the usual BPSW test (which only uses strong # base-2 probable prime and Lucas-Selfridge tests, see Baillie and @@ -653,12 +653,12 @@ cdef extern from "flint_wrap.h": # Up to `2^{64}` the test we use has been checked against tables of # pseudoprimes. Thus it is a primality test up to this limit. - int n_is_probabprime_lucas(ulong n) + bint n_is_probabprime_lucas(ulong n) # For details on Lucas pseudoprimes, see [pp. 143] [CraPom2005]_. # We implement a variant of the Lucas pseudoprime test similar to that # described by Baillie and Wagstaff [BaiWag1980]_. - int n_is_probabprime(ulong n) + bint n_is_probabprime(ulong n) # Tests if `n` is a probable prime. Up to ``FLINT_ODDPRIME_SMALL_CUTOFF`` # this algorithm uses :func:`n_is_oddprime_small` which uses a lookup table. # Next it calls :func:`n_compute_primes` with the maximum table size and @@ -709,14 +709,14 @@ cdef extern from "flint_wrap.h": # The remainder is computed by subtracting the square of the computed square # root from `a`. - int n_is_square(ulong x) + bint n_is_square(ulong x) # Returns `1` if `x` is a square, otherwise `0`. # This code first checks if `x` is a square modulo `64`, # `63 = 3 \times 3 \times 7` and `65 = 5 \times 13`, using lookup tables, # and if so it then takes a square root and checks that the square of this # equals the original value. - int n_is_perfect_power235(ulong n) + bint n_is_perfect_power235(ulong n) # Returns `1` if `n` is a perfect square, cube or fifth power. # This function uses a series of modular tests to reject most # non 235-powers. Each modular test returns a value from 0 to 7 @@ -729,7 +729,7 @@ cdef extern from "flint_wrap.h": # root can be taken, if indicated, to determine whether the power # of that root is exactly equal to `n`. - int n_is_perfect_power(ulong * root, ulong n) + bint n_is_perfect_power(ulong * root, ulong n) # If `n = r^k`, return `k` and set ``root`` to `r`. Note that `0` and # `1` are considered squares. No guarantees are made about `r` or `k` # being the minimum possible value. @@ -1007,7 +1007,7 @@ cdef extern from "flint_wrap.h": # of `\mu(n)` for every multiple of a prime `p` and setting `\mu(n) = 0` # for every multiple of `p^2`. - int n_is_squarefree(ulong n) + bint n_is_squarefree(ulong n) # Returns `0` if `n` is divisible by some perfect square, and `1` otherwise. # This simply amounts to testing whether `\mu(n) \neq 0`. As special # cases, `1` is considered squarefree and `0` is not considered squarefree. From 0de64d8ef6a0269a0594b3a56f7bd44e90fecd11 Mon Sep 17 00:00:00 2001 From: Vincent Delecroix Date: Sat, 14 Oct 2023 19:05:01 +0200 Subject: [PATCH 15/41] fix change in imports --- src/sage/arith/misc.py | 2 +- src/sage/combinat/combinat.py | 8 ++++---- src/sage/functions/log.py | 2 +- src/sage/interfaces/qsieve.py | 4 ++-- src/sage/libs/all.py | 2 +- src/sage/misc/cython.py | 3 ++- 6 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/sage/arith/misc.py b/src/sage/arith/misc.py index 5d3ef49f7c5..3307de93458 100644 --- a/src/sage/arith/misc.py +++ b/src/sage/arith/misc.py @@ -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 diff --git a/src/sage/combinat/combinat.py b/src/sage/combinat/combinat.py index 451f8093393..8eebda8244a 100644 --- a/src/sage/combinat/combinat.py +++ b/src/sage/combinat/combinat.py @@ -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 @@ -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'") diff --git a/src/sage/functions/log.py b/src/sage/functions/log.py index 38c6ca08bbe..22357977d4b 100644 --- a/src/sage/functions/log.py +++ b/src/sage/functions/log.py @@ -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') diff --git a/src/sage/interfaces/qsieve.py b/src/sage/interfaces/qsieve.py index 94764b7f76a..d7b0c5c18eb 100644 --- a/src/sage/interfaces/qsieve.py +++ b/src/sage/interfaces/qsieve.py @@ -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) diff --git a/src/sage/libs/all.py b/src/sage/libs/all.py index 50423191ca4..f85115a4da2 100644 --- a/src/sage/libs/all.py +++ b/src/sage/libs/all.py @@ -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') diff --git a/src/sage/misc/cython.py b/src/sage/misc/cython.py index 2af3bc65943..02f1d15855f 100644 --- a/src/sage/misc/cython.py +++ b/src/sage/misc/cython.py @@ -638,7 +638,8 @@ def compile_and_load(code, **kwds): sage: code = ''' ....: from sage.rings.rational cimport Rational ....: from sage.rings.polynomial.polynomial_rational_flint cimport Polynomial_rational_flint - ....: from sage.libs.flint.fmpq_poly cimport fmpq_poly_length, fmpq_poly_get_coeff_mpq, fmpq_poly_set_coeff_mpq + ....: from sage.libs.flint.fmpq_poly cimport fmpq_poly_length + ....: from sage.libs.flint.fmpq_poly_sage cimport fmpq_poly_get_coeff_mpq, fmpq_poly_set_coeff_mpq ....: ....: def evaluate_at_power_of_gen(Polynomial_rational_flint f, unsigned long n): ....: assert n >= 1 From 4c7fbad8089795c2728d6772e6f18c8a012acc56 Mon Sep 17 00:00:00 2001 From: Vincent Delecroix Date: Sun, 15 Oct 2023 16:00:56 +0200 Subject: [PATCH 16/41] Flint documentation --- src/doc/en/reference/libs/index.rst | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/doc/en/reference/libs/index.rst b/src/doc/en/reference/libs/index.rst index 0fde7b179e0..b7b8fc0abe0 100644 --- a/src/doc/en/reference/libs/index.rst +++ b/src/doc/en/reference/libs/index.rst @@ -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 ---- From 77afb76c275f9f35b9e37f5c726af1beb5e3d0b3 Mon Sep 17 00:00:00 2001 From: Vincent Delecroix Date: Sun, 15 Oct 2023 16:14:22 +0200 Subject: [PATCH 17/41] deprecations --- src/sage/libs/flint/arith.py | 74 +++++++++++++++++++++++++++++ src/sage/libs/flint/fmpz_poly.py | 20 ++++++++ src/sage/libs/flint/qsieve.py | 22 +++++++++ src/sage/libs/flint/ulong_extras.py | 22 +++++++++ 4 files changed, 138 insertions(+) create mode 100644 src/sage/libs/flint/arith.py create mode 100644 src/sage/libs/flint/fmpz_poly.py create mode 100644 src/sage/libs/flint/qsieve.py create mode 100644 src/sage/libs/flint/ulong_extras.py diff --git a/src/sage/libs/flint/arith.py b/src/sage/libs/flint/arith.py new file mode 100644 index 00000000000..2b8436f3321 --- /dev/null +++ b/src/sage/libs/flint/arith.py @@ -0,0 +1,74 @@ +r""" +Deprecated module. + +Functions were moved in arith_sage.pyx + +TESTS:: + + sage: from sage.libs.flint.arith import bell_number, bernoulli_number, euler_number, stirling_number_1, stirling_number_2, number_of_partitions, dedekind_sum, harmonic_number + sage: bell_number(4) + doctest:warning + ... + DeprecationWarning: + Importing bell_number from here is deprecated; please use "from sage.libs.flint.arith_sage import bell_number" instead. + See https://github.com/sagemath/sage/issues/36449 for details. + 15 + sage: bernoulli_number(4) + doctest:warning + ... + DeprecationWarning: + Importing bernoulli_number from here is deprecated; please use "from sage.libs.flint.arith_sage import bernoulli_number" instead. + See https://github.com/sagemath/sage/issues/36449 for details. + -1/30 + sage: euler_number(4) + doctest:warning + ... + DeprecationWarning: + Importing euler_number from here is deprecated; please use "from sage.libs.flint.arith_sage import euler_number" instead. + See https://github.com/sagemath/sage/issues/36449 for details. + 5 + sage: stirling_number_1(2, 4) + doctest:warning + ... + DeprecationWarning: + Importing stirling_number_1 from here is deprecated; please use "from sage.libs.flint.arith_sage import stirling_number_1" instead. + See https://github.com/sagemath/sage/issues/36449 for details. + 0 + sage: stirling_number_2(2, 4) + doctest:warning + ... + DeprecationWarning: + Importing stirling_number_2 from here is deprecated; please use "from sage.libs.flint.arith_sage import stirling_number_2" instead. + See https://github.com/sagemath/sage/issues/36449 for details. + 0 + sage: number_of_partitions(4) + doctest:warning + ... + DeprecationWarning: + Importing number_of_partitions from here is deprecated; please use "from sage.libs.flint.arith_sage import number_of_partitions" instead. + See https://github.com/sagemath/sage/issues/36449 for details. + 5 + sage: dedekind_sum(4, 5) + doctest:warning + ... + DeprecationWarning: + Importing dedekind_sum from here is deprecated; please use "from sage.libs.flint.arith_sage import dedekind_sum" instead. + See https://github.com/sagemath/sage/issues/36449 for details. + -1/5 + sage: harmonic_number(4) + doctest:warning + ... + DeprecationWarning: + Importing harmonic_number from here is deprecated; please use "from sage.libs.flint.arith_sage import harmonic_number" instead. + See https://github.com/sagemath/sage/issues/36449 for details. + 25/12 +""" + +from sage.misc.lazy_import import lazy_import + +lazy_import('sage.libs.flint.arith_sage', ['bell_number', 'bernoulli_number', + 'euler_number', 'stirling_number_1', 'stirling_number_2', + 'number_of_partitions', 'dedekind_sum', 'harmonic_number'], + deprecation=36449) + +del lazy_import diff --git a/src/sage/libs/flint/fmpz_poly.py b/src/sage/libs/flint/fmpz_poly.py new file mode 100644 index 00000000000..7d9455f6f33 --- /dev/null +++ b/src/sage/libs/flint/fmpz_poly.py @@ -0,0 +1,20 @@ +r""" +Deprecated module + +TESTS:: + + sage: from sage.libs.flint.fmpz_poly import Fmpz_poly + sage: Fmpz_poly([1, 1]) + doctest:warning + ... + DeprecationWarning: + Importing Fmpz_poly from here is deprecated; please use "from sage.libs.flint.fmpz_poly_sage import Fmpz_poly" instead. + See https://github.com/sagemath/sage/issues/36449 for details. + 2 1 1 +""" + +from sage.misc.lazy_import import lazy_import + +lazy_import('sage.libs.flint.fmpz_poly_sage', 'Fmpz_poly', deprecation=36449) + +del lazy_import diff --git a/src/sage/libs/flint/qsieve.py b/src/sage/libs/flint/qsieve.py new file mode 100644 index 00000000000..7fc32bebf96 --- /dev/null +++ b/src/sage/libs/flint/qsieve.py @@ -0,0 +1,22 @@ +r""" +Deprecated module. + +Functions were moved in qsieve_sage.pyx. + +TESTS:: + + sage: from sage.libs.flint.qsieve import qsieve + sage: qsieve(1000) + doctest:warning + ... + DeprecationWarning: + Importing qsieve from here is deprecated; please use "from sage.libs.flint.qsieve_sage import qsieve" instead. + See https://github.com/sagemath/sage/issues/36449 for details. + [(2, 3), (5, 3)] +""" + +from sage.misc.lazy_import import lazy_import + +lazy_import('sage.libs.flint.qsieve_sage', 'qsieve', deprecation=36449) + +del lazy_import diff --git a/src/sage/libs/flint/ulong_extras.py b/src/sage/libs/flint/ulong_extras.py new file mode 100644 index 00000000000..a3fcbf59f5e --- /dev/null +++ b/src/sage/libs/flint/ulong_extras.py @@ -0,0 +1,22 @@ +r""" +Deprecated modules. + +Functions were moved in ulong_extras_sage.pyx + +TESTS:: + + sage: from sage.libs.flint.ulong_extras import n_factor_to_list + sage: n_factor_to_list(60, 20) + doctest:warning + ... + DeprecationWarning: + Importing n_factor_to_list from here is deprecated; please use "from sage.libs.flint.ulong_extras_sage import n_factor_to_list" instead. + See https://github.com/sagemath/sage/issues/36449 for details. + [(2, 2), (3, 1), (5, 1)] +""" + +from sage.misc.lazy_import import lazy_import + +lazy_import('sage.libs.flint.ulong_extras_sage', 'n_factor_to_list', deprecation=36449) + +del lazy_import From 7090959cf2b885f3fe2e9e994bcc5ea2986c3815 Mon Sep 17 00:00:00 2001 From: Vincent Delecroix Date: Mon, 16 Oct 2023 07:50:18 +0200 Subject: [PATCH 18/41] fix declarations and test inclusion of all headers in flint_sage.pyx --- src/sage/libs/flint/fft.pxd | 8 +- src/sage/libs/flint/flint_sage.pyx | 158 +++ src/sage/libs/flint/fmpz_mpoly.pxd | 5 - src/sage/libs/flint/nmod_mat.pxd | 5 - src/sage/libs/flint/types.pxd | 1548 ++++++++++++++++++++++++++-- 5 files changed, 1619 insertions(+), 105 deletions(-) create mode 100644 src/sage/libs/flint/flint_sage.pyx diff --git a/src/sage/libs/flint/fft.pxd b/src/sage/libs/flint/fft.pxd index 1abeff1cd2e..75803b47b32 100644 --- a/src/sage/libs/flint/fft.pxd +++ b/src/sage/libs/flint/fft.pxd @@ -275,25 +275,25 @@ cdef extern from "flint_wrap.h": # by ``z1^(-rc)`` for row `r` and column `c` of the matrix of # coefficients. Aliasing is not allowed. - void fft_radix2_twiddle(mp_limb_t ** ii, mp_size_t is, mp_size_t n, flint_bitcnt_t w, mp_limb_t ** t1, mp_limb_t ** t2, mp_size_t ws, mp_size_t r, mp_size_t c, mp_size_t rs) + void fft_radix2_twiddle(mp_limb_t ** ii, mp_size_t iis, mp_size_t n, flint_bitcnt_t w, mp_limb_t ** t1, mp_limb_t ** t2, mp_size_t ws, mp_size_t r, mp_size_t c, mp_size_t rs) # As for ``fft_radix2`` except that the coefficients are spaced by # ``is`` in the array ``ii`` and an additional twist by ``z^c*i`` # is applied to each coefficient where `i` starts at `r` and increases by # ``rs`` as one moves from one coefficient to the next. Here ``z`` # corresponds to multiplication by ``2^ws``. - void ifft_radix2_twiddle(mp_limb_t ** ii, mp_size_t is, mp_size_t n, flint_bitcnt_t w, mp_limb_t ** t1, mp_limb_t ** t2, mp_size_t ws, mp_size_t r, mp_size_t c, mp_size_t rs) + void ifft_radix2_twiddle(mp_limb_t ** ii, mp_size_t iis, mp_size_t n, flint_bitcnt_t w, mp_limb_t ** t1, mp_limb_t ** t2, mp_size_t ws, mp_size_t r, mp_size_t c, mp_size_t rs) # As for ``ifft_radix2`` except that the coefficients are spaced by # ``is`` in the array ``ii`` and an additional twist by # ``z^(-c*i)`` is applied to each coefficient where `i` starts at `r` # and increases by ``rs`` as one moves from one coefficient to the next. # Here ``z`` corresponds to multiplication by ``2^ws``. - void fft_truncate1_twiddle(mp_limb_t ** ii, mp_size_t is, mp_size_t n, flint_bitcnt_t w, mp_limb_t ** t1, mp_limb_t ** t2, mp_size_t ws, mp_size_t r, mp_size_t c, mp_size_t rs, mp_size_t trunc) + void fft_truncate1_twiddle(mp_limb_t ** ii, mp_size_t iis, mp_size_t n, flint_bitcnt_t w, mp_limb_t ** t1, mp_limb_t ** t2, mp_size_t ws, mp_size_t r, mp_size_t c, mp_size_t rs, mp_size_t trunc) # As per ``fft_radix2_twiddle`` except that the transform is truncated # as per ``fft_truncate1``. - void ifft_truncate1_twiddle(mp_limb_t ** ii, mp_size_t is, mp_size_t n, flint_bitcnt_t w, mp_limb_t ** t1, mp_limb_t ** t2, mp_size_t ws, mp_size_t r, mp_size_t c, mp_size_t rs, mp_size_t trunc) + void ifft_truncate1_twiddle(mp_limb_t ** ii, mp_size_t iis, mp_size_t n, flint_bitcnt_t w, mp_limb_t ** t1, mp_limb_t ** t2, mp_size_t ws, mp_size_t r, mp_size_t c, mp_size_t rs, mp_size_t trunc) # As per ``ifft_radix2_twiddle`` except that the transform is truncated # as per ``ifft_truncate1``. diff --git a/src/sage/libs/flint/flint_sage.pyx b/src/sage/libs/flint/flint_sage.pyx new file mode 100644 index 00000000000..1c5d3f911a4 --- /dev/null +++ b/src/sage/libs/flint/flint_sage.pyx @@ -0,0 +1,158 @@ +# distutils: extra_compile_args = -D_XPG6 +""" +Flint imports + +TESTS: + +Import this module:: + + sage: import sage.libs.flint.flint_sage + +We verify that :trac:`6919` is correctly fixed:: + + sage: R. = PolynomialRing(ZZ) + sage: A = 2^(2^17+2^15) + sage: a = A * x^31 + sage: b = (A * x) * x^30 + sage: a == b + True +""" + +# cimport all .pxd files to make sure they compile +from .fmpz_poly_mat cimport * +from .fmpq_mpoly cimport * +from .nmod_poly_mat cimport * +from .perm cimport * +from .nmod_vec cimport * +from .fmpzi cimport * +from .mpoly cimport * +from .mpfr_mat cimport * +from .nmod_poly cimport * +from .long_extras cimport * +from .partitions cimport * +from .fq_nmod_poly_factor cimport * +from .mpf_mat cimport * +from .fmpz_poly_q cimport * +from .ca_vec cimport * +from .double_extras cimport * +from .fq_nmod_mpoly_factor cimport * +from .fmpz_mpoly cimport * +from .fmpq_vec cimport * +from .fq_poly cimport * +from .fq_nmod_mat cimport * +from .calcium cimport * +from .fmpz_vec cimport * +from .fexpr_builtin cimport * +from .ca_poly cimport * +from .fq_embed cimport * +from .nmod_poly_factor cimport * +from .fmpz_extras cimport * +from .acb_mat cimport * +from .gr_generic cimport * +from .gr_poly cimport * +from .fq_zech_poly_factor cimport * +from .fmpz_mpoly_q cimport * +from .nmod cimport * +from .ca_mat cimport * +from .fq_zech_vec cimport * +from .arb cimport * +from .nf_elem cimport * +from .fmpz_poly cimport * +from .fq_nmod_embed cimport * +from .arb_poly cimport * +from .fmpq cimport * +from .fmpq_mpoly_factor cimport * +from .acb_calc cimport * +from .fq_vec cimport * +from .padic_mat cimport * +from .fmpz cimport * +from .fmpz_mat cimport * +from .fmpz_mod_mat cimport * +from .fq_zech cimport * +from .double_interval cimport * +from .fq_default_mat cimport * +from .fmpz_mod_mpoly cimport * +from .qsieve cimport * +from .qfb cimport * +from .thread_pool cimport * +from .fmpz_mod_mpoly_factor cimport * +from .acb_modular cimport * +from .fq_nmod_poly cimport * +from .profiler cimport * +from .acb_hypgeom cimport * +from .d_mat cimport * +from .fq_zech_poly cimport * +from .fmpz_mod cimport * +from .qqbar cimport * +from .hypgeom cimport * +from .acb_elliptic cimport * +from .acb_dft cimport * +from .d_vec cimport * +from .ulong_extras cimport * +from .dlog cimport * +from .bool_mat cimport * +from .fmpq_poly cimport * +from .fexpr cimport * +from .mag cimport * +from .fmpz_mpoly_factor cimport * +from .mpfr_vec cimport * +from .ca_ext cimport * +from .gr cimport * +from .acb_poly cimport * +from .fft cimport * +from .padic cimport * +from .dirichlet cimport * +from .fmpz_mod_poly_factor cimport * +from .fq_default cimport * +from .fq cimport * +from .gr_vec cimport * +from .fq_nmod cimport * +from .fq_zech_embed cimport * +from .nmod_mpoly_factor cimport * +from .flint cimport * +from .fmpz_factor cimport * +from .qadic cimport * +from .nf cimport * +from .gr_mpoly cimport * +from .arb_fpwrap cimport * +from .fq_default_poly cimport * +from .aprcl cimport * +from .acf cimport * +from .gr_special cimport * +from .arf cimport * +from .fq_zech_mat cimport * +from .gr_mat cimport * +from .arb_fmpz_poly cimport * +from .fq_nmod_vec cimport * +from .fmpz_mod_poly cimport * +from .bernoulli cimport * +from .fq_default_poly_factor cimport * +from .arb_mat cimport * +from .arb_hypgeom cimport * +from .fq_poly_factor cimport * +from .nmod_mpoly cimport * +from .acb cimport * +from .fmpz_lll cimport * +from .fmpz_poly_factor cimport * +from .ca_field cimport * +from .acb_dirichlet cimport * +from .arith cimport * +from .fmpz_mod_vec cimport * +from .fmpq_mat cimport * +from .fq_mat cimport * +from .mpn_extras cimport * +from .mpf_vec cimport * +from .ca cimport * +from .padic_poly cimport * +from .nmod_mat cimport * +from .fq_nmod_mpoly cimport * +from .arb_calc cimport * + +# Try to clean up after ourselves before sage terminates. This +# probably doesn't do anything if your copy of flint is re-entrant +# (and most are). Moreover it isn't strictly necessary, because the OS +# will reclaim these resources anyway after sage terminates. However +# this might reveal other bugs, and can help tools like valgrind do +# their jobs. +import atexit +atexit.register(_fmpz_cleanup_mpz_content) diff --git a/src/sage/libs/flint/fmpz_mpoly.pxd b/src/sage/libs/flint/fmpz_mpoly.pxd index 3b26e4dd9de..dbbd02143cb 100644 --- a/src/sage/libs/flint/fmpz_mpoly.pxd +++ b/src/sage/libs/flint/fmpz_mpoly.pxd @@ -686,11 +686,6 @@ cdef extern from "flint_wrap.h": # This produces a reduced Gröbner basis, which is unique # (up to the sort order of the entries in the vector). - pair_t fmpz_mpoly_select_pop_pair(pairs_t pairs, const fmpz_mpoly_vec_t G, const fmpz_mpoly_ctx_t ctx) - # Given a vector *pairs* of indices `(i, j)` into *G*, selects one pair - # for elimination in Buchberger's algorithm. The pair is removed - # from *pairs* and returned. - void fmpz_mpoly_buchberger_naive(fmpz_mpoly_vec_t G, const fmpz_mpoly_vec_t F, const fmpz_mpoly_ctx_t ctx) # Sets *G* to a Gröbner basis for *F*, computed using # a naive implementation of Buchberger's algorithm. diff --git a/src/sage/libs/flint/nmod_mat.pxd b/src/sage/libs/flint/nmod_mat.pxd index d5432e00ac7..c2f0b32bd41 100644 --- a/src/sage/libs/flint/nmod_mat.pxd +++ b/src/sage/libs/flint/nmod_mat.pxd @@ -37,11 +37,6 @@ cdef extern from "flint_wrap.h": # Swaps two matrices by swapping the individual entries rather than swapping # the contents of the structs. - MACRO nmod_mat_entry(nmod_mat_t mat, slong i, slong j) - # Directly accesses the entry in ``mat`` in row `i` and column `j`, - # indexed from zero. No bounds checking is performed. This macro can be - # used both for reading and writing coefficients. - mp_limb_t nmod_mat_get_entry(const nmod_mat_t mat, slong i, slong j) # Get the entry at row `i` and column `j` of the matrix ``mat``. diff --git a/src/sage/libs/flint/types.pxd b/src/sage/libs/flint/types.pxd index 2ffc8bfe237..c0b4428f4eb 100644 --- a/src/sage/libs/flint/types.pxd +++ b/src/sage/libs/flint/types.pxd @@ -71,15 +71,10 @@ cdef extern from "flint_wrap.h": # flint/ulong_extras.pxd ctypedef struct n_ecm_s: pass - ctypedef n_ecm_s n_ecm_t[1]; + ctypedef n_ecm_s n_ecm_t[1] # flint/arf.h - ctypedef struct arf_struct: - pass - ctypedef arf_struct arf_t[1] - ctypedef arf_struct * arf_ptr - ctypedef const arf_struct * arf_srcptr cdef enum arf_rnd_t: ARF_RND_DOWN ARF_RND_UP @@ -89,6 +84,31 @@ cdef extern from "flint_wrap.h": long ARF_PREC_EXACT + # flint/arf_types.h + ctypedef struct mantissa_noptr_struct: + pass + + ctypedef struct mantissa_ptr_struct: + pass + + ctypedef union mantissa_struct: + mantissa_noptr_struct noptr + mantissa_ptr_struct ptr + + ctypedef struct arf_struct: + pass + ctypedef arf_struct arf_t[1] + ctypedef arf_struct * arf_ptr + ctypedef const arf_struct * arf_srcptr + + ctypedef struct arf_interval_struct: + arf_struct a + arf_struct b + ctypedef arf_interval_struct arf_interval_t[1] + ctypedef arf_interval_struct * arf_interval_ptr + ctypedef const arf_interval_struct * arf_interval_srcptr + + # flint/arb_types.h ctypedef struct mag_struct: pass @@ -142,7 +162,7 @@ cdef extern from "flint_wrap.h": fmpz b fmpz c fmpz d - ctypedef psl2z_struct psl2z_t[1]; + ctypedef psl2z_struct psl2z_t[1] # flint/acb_poly.h @@ -163,6 +183,67 @@ cdef extern from "flint_wrap.h": ctypedef int (*acb_calc_func_t)(acb_ptr out, const acb_t inp, void * param, long order, long prec) + + # flint/acb_dft.h + ctypedef struct crt_struct: + pass + ctypedef crt_struct crt_t[1] + + ctypedef struct acb_dft_step_struct: + pass + ctypedef acb_dft_step_struct * acb_dft_step_ptr + + ctypedef struct acb_dft_cyc_struct: + pass + ctypedef acb_dft_cyc_struct acb_dft_cyc_t[1] + + ctypedef struct acb_dft_rad2_struct: + pass + ctypedef acb_dft_rad2_struct acb_dft_rad2_t[1] + + ctypedef struct acb_dft_bluestein_struct: + pass + ctypedef acb_dft_bluestein_struct acb_dft_bluestein_t[1] + + ctypedef struct acb_dft_prod_struct: + pass + ctypedef acb_dft_prod_struct acb_dft_prod_t[1] + + ctypedef struct acb_dft_crt_struct: + pass + ctypedef acb_dft_crt_struct acb_dft_crt_t[1] + + ctypedef struct acb_dft_naive_struct: + pass + ctypedef acb_dft_naive_struct acb_dft_naive_t[1] + + ctypedef struct acb_dft_pre_struct: + pass + ctypedef acb_dft_pre_struct acb_dft_pre_t[1] + + + # flint/acb_dirichlet.h + ctypedef struct acb_dirichlet_hurwitz_precomp_struct: + pass + ctypedef acb_dirichlet_hurwitz_precomp_struct acb_dirichlet_hurwitz_precomp_t[1] + + ctypedef struct acb_dirichlet_roots_struct: + pass + ctypedef acb_dirichlet_roots_struct acb_dirichlet_roots_t[1] + + ctypedef struct acb_dirichlet_platt_c_precomp_struct: + pass + ctypedef acb_dirichlet_platt_c_precomp_struct acb_dirichlet_platt_c_precomp_t[1] + + ctypedef struct acb_dirichlet_platt_i_precomp_struct: + pass + ctypedef acb_dirichlet_platt_i_precomp_struct acb_dirichlet_platt_i_precomp_t[1] + + ctypedef struct acb_dirichlet_platt_ws_precomp_struct: + pass + ctypedef acb_dirichlet_platt_ws_precomp_struct acb_dirichlet_platt_ws_precomp_t[1] + + # flint/d_mat.h ctypedef struct d_mat_struct: double * entries @@ -213,6 +294,23 @@ cdef extern from "flint_wrap.h": ctypedef fmpz_mod_discrete_log_pohlig_hellman_struct fmpz_mod_discrete_log_pohlig_hellman_t[1] + # flint/nmod_poly.h + ctypedef struct nmod_t: + mp_limb_t n + mp_limb_t ninv + mp_bitcnt_t norm + + ctypedef struct nmod_poly_multi_crt_struct: + pass + + ctypedef nmod_poly_multi_crt_struct nmod_poly_multi_crt_t[1] + + ctypedef struct nmod_berlekamp_massey_struct: + pass + + ctypedef nmod_berlekamp_massey_struct nmod_berlekamp_massey_t[1] + + # flint/fmpz_types.h ctypedef struct fmpz_factor_struct: int sign @@ -253,7 +351,7 @@ cdef extern from "flint_wrap.h": ctypedef struct fmpz_mpoly_factor_struct: pass - ctypedef fmpz_mpoly_factor_struct fmpz_mpoly_factor_t[1]; + ctypedef fmpz_mpoly_factor_struct fmpz_mpoly_factor_t[1] ctypedef struct fmpz_poly_q_struct: fmpz_poly_struct *num @@ -273,6 +371,170 @@ cdef extern from "flint_wrap.h": ctypedef fmpzi_struct fmpzi_t[1] + # flint/fmpq_types.h + ctypedef struct fmpq_mat_struct: + pass + ctypedef fmpq_mat_struct fmpq_mat_t[1] + + ctypedef struct fmpq_poly_struct: + pass + ctypedef fmpq_poly_struct fmpq_poly_t[1] + + ctypedef struct fmpq_mpoly_struct: + pass + ctypedef fmpq_mpoly_struct fmpq_mpoly_t[1] + + ctypedef struct fmpq_mpoly_factor_struct: + pass + ctypedef fmpq_mpoly_factor_struct fmpq_mpoly_factor_t[1] + + + # flint/nmod_types.h + ctypedef struct nmod_mat_struct: + mp_limb_t * entries + slong r + slong c + mp_limb_t ** rows + nmod_t mod + + ctypedef nmod_mat_struct nmod_mat_t[1] + + ctypedef struct nmod_poly_struct: + mp_ptr coeffs + slong alloc + slong length + nmod_t mod + + ctypedef nmod_poly_struct nmod_poly_t[1] + + ctypedef struct nmod_poly_factor_struct: + nmod_poly_struct * p + slong *exp + slong num + slong alloc + + ctypedef nmod_poly_factor_struct nmod_poly_factor_t[1] + + ctypedef struct nmod_poly_mat_struct: + nmod_poly_struct * entries + slong r + slong c + nmod_poly_struct ** rows + mp_limb_t modulus + + ctypedef nmod_poly_mat_struct nmod_poly_mat_t[1] + + ctypedef struct nmod_mpoly_struct: + mp_limb_t * coeffs + ulong * exps + slong length + flint_bitcnt_t bits + slong coeffs_alloc + slong exps_alloc + + ctypedef nmod_mpoly_struct nmod_mpoly_t[1] + + ctypedef struct nmod_mpoly_factor_struct: + mp_limb_t constant + nmod_mpoly_struct * poly + fmpz * exp + slong num + slong alloc + + ctypedef nmod_mpoly_factor_struct nmod_mpoly_factor_t[1] + + + # flint/nmod_mpoly.h + ctypedef struct nmod_mpoly_univar_struct: + pass + ctypedef nmod_mpoly_univar_struct nmod_mpoly_univar_t[1] + + ctypedef struct nmod_mpolyu_struct: + pass + ctypedef nmod_mpolyu_struct nmod_mpolyu_t[1] + + ctypedef struct nmod_mpolyn_struct: + pass + ctypedef nmod_mpolyn_struct nmod_mpolyn_t[1] + + ctypedef struct nmod_mpolyun_struct: + pass + ctypedef nmod_mpolyun_struct nmod_mpolyun_t[1] + + ctypedef struct nmod_mpolyd_struct: + pass + ctypedef nmod_mpolyd_struct nmod_mpolyd_t[1] + + ctypedef struct nmod_poly_stack_struct: + pass + ctypedef nmod_poly_stack_struct nmod_poly_stack_t[1] + + + # flint/fq_nmod_types.h + ctypedef nmod_poly_t fq_nmod_t + ctypedef nmod_poly_struct fq_nmod_struct + + ctypedef struct fq_nmod_ctx_struct: + pass + ctypedef fq_nmod_ctx_struct fq_nmod_ctx_t[1] + + ctypedef struct fq_nmod_mat_struct: + pass + ctypedef fq_nmod_mat_struct fq_nmod_mat_t[1] + + ctypedef struct fq_nmod_poly_struct: + pass + ctypedef fq_nmod_poly_struct fq_nmod_poly_t[1] + + ctypedef struct fq_nmod_poly_factor_struct: + pass + ctypedef fq_nmod_poly_factor_struct fq_nmod_poly_factor_t[1] + + + # flint2/fq_nmod_mpoly.h + ctypedef struct fq_nmod_mpoly_ctx_struct: + pass + ctypedef fq_nmod_mpoly_ctx_struct fq_nmod_mpoly_ctx_t[1] + + ctypedef struct fq_nmod_mpoly_struct: + pass + ctypedef fq_nmod_mpoly_struct fq_nmod_mpoly_t[1] + + ctypedef struct fq_nmod_mpoly_univar_struct: + pass + ctypedef fq_nmod_mpoly_univar_struct fq_nmod_mpoly_univar_t[1] + + ctypedef struct fq_nmod_mpolyu_struct: + pass + ctypedef fq_nmod_mpolyu_struct fq_nmod_mpolyu_t[1] + + ctypedef struct fq_nmod_mpolyn_struct: + pass + ctypedef fq_nmod_mpolyn_struct fq_nmod_mpolyn_t[1] + + ctypedef struct fq_nmod_mpolyun_struct: + pass + ctypedef fq_nmod_mpolyun_struct fq_nmod_mpolyun_t[1] + + ctypedef struct bad_fq_nmod_embed_struct: + pass + ctypedef bad_fq_nmod_embed_struct bad_fq_nmod_embed_t[1] + + + # flint2/fq_nmod_mpoly_factor.h + ctypedef struct fq_nmod_mpoly_factor_struct: + pass + ctypedef fq_nmod_mpoly_factor_struct fq_nmod_mpoly_factor_t[1] + + ctypedef struct fq_nmod_mpolyv_struct: + pass + ctypedef fq_nmod_mpolyv_struct fq_nmod_mpolyv_t[1] + + ctypedef struct fq_nmod_mpoly_pfrac_struct: + pass + ctypedef fq_nmod_mpoly_pfrac_struct fq_nmod_mpoly_pfrac_t[1] + + # flint/fmpz_poly.h ctypedef struct fmpz_poly_powers_precomp_struct: fmpz ** powers @@ -340,11 +602,6 @@ cdef extern from "flint_wrap.h": # flint/fmpq_poly.h - ctypedef struct fmpq_poly_struct: - pass - - ctypedef fmpq_poly_struct fmpq_poly_t[1] - ctypedef struct fmpq_poly_powers_precomp_struct: fmpq_poly_struct * powers slong len @@ -352,13 +609,6 @@ cdef extern from "flint_wrap.h": ctypedef fmpq_poly_powers_precomp_struct fmpq_poly_powers_precomp_t[1] - # flint/fmpq_mat.h - ctypedef struct fmpq_mat_struct: - pass - - ctypedef fmpq_mat_struct fmpq_mat_t[1] - - # flint/fmpz_mod_poly.h: ctypedef struct fmpz_mod_poly_res_struct: pass @@ -392,96 +642,70 @@ cdef extern from "flint_wrap.h": ctypedef fmpz_mod_berlekamp_massey_struct fmpz_mod_berlekamp_massey_t[1] - # flint/nmod_poly.h - ctypedef struct nmod_t: - mp_limb_t n - mp_limb_t ninv - mp_bitcnt_t norm - - ctypedef struct nmod_poly_multi_crt_struct: + # flint/nmod.h + ctypedef struct nmod_discrete_log_pohlig_hellman_table_entry_struct: pass - ctypedef nmod_poly_multi_crt_struct nmod_poly_multi_crt_t[1] - - ctypedef struct nmod_berlekamp_massey_struct: + ctypedef struct nmod_discrete_log_pohlig_hellman_entry_struct: pass - ctypedef nmod_berlekamp_massey_struct nmod_berlekamp_massey_t[1] - - - # flint/nmod_types.h - ctypedef struct nmod_mat_struct: - mp_limb_t * entries - slong r - slong c - mp_limb_t ** rows - nmod_t mod - - ctypedef nmod_mat_struct nmod_mat_t[1] - - ctypedef struct nmod_poly_struct: - mp_ptr coeffs - slong alloc - slong length - nmod_t mod + ctypedef struct nmod_discrete_log_pohlig_hellman_struct: + pass + ctypedef nmod_discrete_log_pohlig_hellman_struct nmod_discrete_log_pohlig_hellman_t[1] - ctypedef nmod_poly_struct nmod_poly_t[1] - ctypedef struct nmod_poly_factor_struct: - nmod_poly_struct * p - slong *exp - slong num - slong alloc + # flint/fq_nmod.h + ctypedef struct fq_nmod_ctx_struct: + nmod_poly_t modulus - ctypedef nmod_poly_factor_struct nmod_poly_factor_t[1] + ctypedef fq_nmod_ctx_struct fq_nmod_ctx_t[1] - ctypedef struct nmod_poly_mat_struct: - nmod_poly_struct * entries - slong r - slong c - nmod_poly_struct ** rows - mp_limb_t modulus + ctypedef nmod_poly_struct fq_nmod_struct + ctypedef nmod_poly_t fq_nmod_t - ctypedef nmod_poly_mat_struct nmod_poly_mat_t[1] - ctypedef struct nmod_mpoly_struct: - mp_limb_t * coeffs - ulong * exps - slong length - flint_bitcnt_t bits - slong coeffs_alloc - slong exps_alloc + # flint/fq_types.h + ctypedef fmpz_poly_t fq_t + ctypedef fmpz_poly_struct fq_struct - ctypedef nmod_mpoly_struct nmod_mpoly_t[1] + ctypedef struct fq_ctx_struct: + pass - ctypedef struct nmod_mpoly_factor_struct: - mp_limb_t constant - nmod_mpoly_struct * poly - fmpz * exp - slong num - slong alloc + ctypedef fq_ctx_struct fq_ctx_t[1] - ctypedef nmod_mpoly_factor_struct nmod_mpoly_factor_t[1] + ctypedef struct fq_mat_struct: + pass + ctypedef fq_mat_struct fq_mat_t[1] + ctypedef struct fq_poly_struct: + pass + ctypedef fq_poly_struct fq_poly_t[1] - # flint/fq.h - ctypedef struct fq_ctx_struct: - fmpz_mod_poly_t modulus + ctypedef struct fq_poly_factor_struct: + pass + ctypedef fq_poly_factor_struct fq_poly_factor_t[1] - ctypedef fq_ctx_struct fq_ctx_t[1] - ctypedef fmpz_poly_struct fq_struct - ctypedef fmpz_poly_t fq_t + # flint/fq_zech_types.h + ctypedef struct fq_zech_struct: + pass + ctypedef fq_zech_struct fq_zech_t[1] + ctypedef struct fq_zech_ctx_struct: + pass + ctypedef fq_zech_ctx_struct fq_zech_ctx_t[1] - # flint/fq_nmod.h - ctypedef struct fq_nmod_ctx_struct: - nmod_poly_t modulus + ctypedef struct fq_zech_mat_struct: + pass + ctypedef fq_zech_mat_struct fq_zech_mat_t[1] - ctypedef fq_nmod_ctx_struct fq_nmod_ctx_t[1] + ctypedef struct fq_zech_poly_struct: + pass + ctypedef fq_zech_poly_struct fq_zech_poly_t[1] - ctypedef nmod_poly_struct fq_nmod_struct - ctypedef nmod_poly_t fq_nmod_t + ctypedef struct fq_zech_poly_factor_struct: + pass + ctypedef fq_zech_poly_factor_struct fq_zech_poly_factor_t[1] # flint/padic.h @@ -514,6 +738,12 @@ cdef extern from "flint_wrap.h": ctypedef padic_inv_struct padic_inv_t[1] + # flint/fmpz_mod_mpoly.h + ctypedef struct fmpz_mod_mpoly_univar_struct: + pass + ctypedef fmpz_mod_mpoly_univar_struct fmpz_mod_mpoly_univar_t[1] + + # flint/padic_poly.h ctypedef struct padic_poly_struct: fmpz *coeffs @@ -525,6 +755,12 @@ cdef extern from "flint_wrap.h": ctypedef padic_poly_struct padic_poly_t[1] + # flint/padic_mat.h + ctypedef struct padic_mat_struct: + pass + ctypedef padic_mat_struct padic_mat_t[1] + + # flint/qadic.h ctypedef struct qadic_ctx_struct: padic_ctx_struct pctx @@ -561,7 +797,7 @@ cdef extern from "flint_wrap.h": ctypedef struct qs_s: pass - ctypedef qs_s qs_t[1]; + ctypedef qs_s qs_t[1] # flint/thread_pool.h @@ -583,6 +819,118 @@ cdef extern from "flint_wrap.h": ctypedef bernoulli_rev_struct bernoulli_rev_t[1] + # flint/mpoly_types.h + ctypedef enum ordering_t: + ORD_LEX + ORD_DEGLEX + ORD_DEGREVLEX + + ctypedef struct mpoly_ctx_struct: + pass + ctypedef mpoly_ctx_struct mpoly_ctx_t[1] + + ctypedef struct nmod_mpoly_ctx_struct: + pass + ctypedef nmod_mpoly_ctx_struct nmod_mpoly_ctx_t[1] + + ctypedef struct fmpz_mpoly_ctx_struct: + pass + ctypedef fmpz_mpoly_ctx_struct fmpz_mpoly_ctx_t[1] + + ctypedef struct fmpq_mpoly_ctx_struct: + pass + + ctypedef fmpq_mpoly_ctx_struct fmpq_mpoly_ctx_t[1] + + ctypedef struct fmpz_mod_mpoly_ctx_struct: + pass + ctypedef fmpz_mod_mpoly_ctx_struct fmpz_mod_mpoly_ctx_t[1] + + + # flint/mpoly.h + ctypedef struct mpoly_heap_t: + pass + + ctypedef struct mpoly_nheap_t: + pass + + ctypedef struct mpoly_heap1_s: + pass + + ctypedef struct mpoly_heap_s: + pass + + ctypedef struct mpoly_rbnode_ui_struct: + pass + + ctypedef struct mpoly_rbtree_ui_struct: + pass + + ctypedef mpoly_rbtree_ui_struct mpoly_rbtree_ui_t[1] + + ctypedef struct mpoly_rbnode_fmpz_struct: + pass + + ctypedef struct mpoly_rbtree_fmpz_struct: + pass + ctypedef mpoly_rbtree_fmpz_struct mpoly_rbtree_fmpz_t[1] + + ctypedef struct mpoly_gcd_info_struct: + pass + ctypedef mpoly_gcd_info_struct mpoly_gcd_info_t[1] + + ctypedef struct mpoly_compression_struct: + pass + ctypedef mpoly_compression_struct mpoly_compression_t[1] + + ctypedef struct mpoly_univar_struct: + pass + ctypedef mpoly_univar_struct mpoly_univar_t[1] + + ctypedef struct mpoly_void_ring_struct: + pass + ctypedef mpoly_void_ring_struct mpoly_void_ring_t[1] + + ctypedef struct string_with_length_struct: + pass + + ctypedef struct mpoly_parse_struct: + pass + ctypedef mpoly_parse_struct mpoly_parse_t[1] + + + # flint/fmpz_mpoly.h + ctypedef struct fmpz_mpoly_univar_struct: + pass + ctypedef fmpz_mpoly_univar_struct fmpz_mpoly_univar_t[1] + + ctypedef struct fmpz_mpolyd_struct: + pass + ctypedef fmpz_mpolyd_struct fmpz_mpolyd_t[1] + + ctypedef struct fmpz_mpoly_vec_struct: + pass + ctypedef fmpz_mpoly_vec_struct fmpz_mpoly_vec_t[1] + + ctypedef struct fmpz_mpolyd_ctx_struct: + pass + ctypedef fmpz_mpolyd_ctx_struct fmpz_mpolyd_ctx_t[1] + + ctypedef struct fmpz_pow_cache_struct: + pass + ctypedef fmpz_pow_cache_struct fmpz_pow_cache_t[1] + + ctypedef struct fmpz_mpoly_geobucket_struct: + pass + ctypedef fmpz_mpoly_geobucket_struct fmpz_mpoly_geobucket_t[1] + + + # flint/fmpq_mpoly.h + ctypedef struct fmpq_mpoly_univar_struct: + pass + ctypedef fmpq_mpoly_univar_struct fmpq_mpoly_univar_t[1] + + # flint/nf.h ctypedef struct nf_struct: pass @@ -605,6 +953,67 @@ cdef extern from "flint_wrap.h": ctypedef nf_elem_struct nf_elem_t[1] + # flint/calcium.h + ctypedef struct calcium_stream_struct: + pass + ctypedef calcium_stream_struct calcium_stream_t[1] + + + ctypedef enum truth_t: + T_TRUE + T_FALSE + T_UNKNOWN + + ctypedef enum calcium_func_code: + CA_QQBar + CA_Neg + CA_Add + CA_Sub + CA_Mul + CA_Div + CA_Sqrt + CA_Cbrt + CA_Root + CA_Floor + CA_Ceil + CA_Abs + CA_Sign + CA_Re + CA_Im + CA_Arg + CA_Conjugate + CA_Pi + CA_Sin + CA_Cos + CA_Exp + CA_Log + CA_Pow + CA_Tan + CA_Cot + CA_Cosh + CA_Sinh + CA_Tanh + CA_Coth + CA_Atan + CA_Acos + CA_Asin + CA_Acot + CA_Atanh + CA_Acosh + CA_Asinh + CA_Acoth + CA_Euler + CA_Gamma + CA_LogGamma + CA_Psi + CA_Erf + CA_Erfc + CA_Erfi + CA_RiemannZeta + CA_HurwitzZeta + CA_FUNC_CODE_LENGTH + + # flint/ca.h ctypedef union ca_elem_struct: fmpq q @@ -647,7 +1056,7 @@ cdef extern from "flint_wrap.h": ctypedef struct ca_field_cache_struct: pass - ctypedef ca_field_cache_struct ca_field_cache_t[1]; + ctypedef ca_field_cache_struct ca_field_cache_t[1] cdef enum: CA_OPT_VERBOSE @@ -671,3 +1080,960 @@ cdef extern from "flint_wrap.h": pass ctypedef ca_ctx_struct ca_ctx_t[1] + + ctypedef struct ca_factor_struct: + pass + ctypedef ca_factor_struct ca_factor_t[1] + + + # flint/ca_poly.h + ctypedef struct ca_poly_struct: + pass + ctypedef ca_poly_struct ca_poly_t[1] + + ctypedef struct ca_poly_vec_struct: + pass + ctypedef ca_poly_vec_struct ca_poly_vec_t[1] + + + # flint/ca_vec.h + ctypedef struct ca_vec_struct: + pass + ctypedef ca_vec_struct ca_vec_t[1] + + + # flint/ca_mat.h + ctypedef struct ca_mat_struct: + pass + ctypedef ca_mat_struct ca_mat_t[1] + + + # flint/mpf_vec.h + ctypedef __mpf_struct mpf + + + # flint/mpf_mat.h + ctypedef struct mpf_mat_struct: + pass + ctypedef mpf_mat_struct mpf_mat_t[1] + + + # flint/mpfr_mat.h + ctypedef struct mpfr_mat_struct: + pass + ctypedef mpfr_mat_struct mpfr_mat_t[1] + + + # flint/gr.h + ctypedef int (*gr_funcptr)() + + ctypedef struct gr_stream_struct: + pass + ctypedef gr_stream_struct gr_stream_t[1] + + ctypedef void * gr_ptr + ctypedef const void * gr_srcptr + ctypedef void * gr_ctx_ptr + + ctypedef struct gr_vec_struct: + pass + ctypedef gr_vec_struct gr_vec_t[1] + + ctypedef enum gr_method: + GR_METHOD_CTX_WRITE + GR_METHOD_CTX_CLEAR + GR_METHOD_CTX_IS_RING + GR_METHOD_CTX_IS_COMMUTATIVE_RING + GR_METHOD_CTX_IS_INTEGRAL_DOMAIN + GR_METHOD_CTX_IS_FIELD + GR_METHOD_CTX_IS_UNIQUE_FACTORIZATION_DOMAIN + GR_METHOD_CTX_IS_FINITE + GR_METHOD_CTX_IS_FINITE_CHARACTERISTIC + GR_METHOD_CTX_IS_ALGEBRAICALLY_CLOSED + GR_METHOD_CTX_IS_ORDERED_RING + GR_METHOD_CTX_IS_MULTIPLICATIVE_GROUP + GR_METHOD_CTX_IS_EXACT + GR_METHOD_CTX_IS_CANONICAL + GR_METHOD_CTX_IS_THREADSAFE + GR_METHOD_CTX_HAS_REAL_PREC + GR_METHOD_CTX_SET_REAL_PREC + GR_METHOD_CTX_GET_REAL_PREC + GR_METHOD_CTX_SET_GEN_NAME + GR_METHOD_CTX_SET_GEN_NAMES + GR_METHOD_INIT + GR_METHOD_CLEAR + GR_METHOD_SWAP + GR_METHOD_SET_SHALLOW + GR_METHOD_WRITE + GR_METHOD_WRITE_N + GR_METHOD_RANDTEST + GR_METHOD_RANDTEST_NOT_ZERO + GR_METHOD_RANDTEST_SMALL + GR_METHOD_ZERO + GR_METHOD_ONE + GR_METHOD_NEG_ONE + GR_METHOD_IS_ZERO + GR_METHOD_IS_ONE + GR_METHOD_IS_NEG_ONE + GR_METHOD_EQUAL + GR_METHOD_SET + GR_METHOD_SET_UI + GR_METHOD_SET_SI + GR_METHOD_SET_FMPZ + GR_METHOD_SET_FMPQ + GR_METHOD_SET_D + GR_METHOD_SET_OTHER + GR_METHOD_SET_STR + GR_METHOD_GET_SI + GR_METHOD_GET_UI + GR_METHOD_GET_FMPZ + GR_METHOD_GET_FMPQ + GR_METHOD_GET_D + GR_METHOD_GET_FEXPR + GR_METHOD_GET_FEXPR_SERIALIZE + GR_METHOD_SET_FEXPR + GR_METHOD_NEG + GR_METHOD_ADD + GR_METHOD_ADD_UI + GR_METHOD_ADD_SI + GR_METHOD_ADD_FMPZ + GR_METHOD_ADD_FMPQ + GR_METHOD_ADD_OTHER + GR_METHOD_OTHER_ADD + GR_METHOD_SUB + GR_METHOD_SUB_UI + GR_METHOD_SUB_SI + GR_METHOD_SUB_FMPZ + GR_METHOD_SUB_FMPQ + GR_METHOD_SUB_OTHER + GR_METHOD_OTHER_SUB + GR_METHOD_MUL + GR_METHOD_MUL_UI + GR_METHOD_MUL_SI + GR_METHOD_MUL_FMPZ + GR_METHOD_MUL_FMPQ + GR_METHOD_MUL_OTHER + GR_METHOD_OTHER_MUL + GR_METHOD_ADDMUL + GR_METHOD_ADDMUL_UI + GR_METHOD_ADDMUL_SI + GR_METHOD_ADDMUL_FMPZ + GR_METHOD_ADDMUL_FMPQ + GR_METHOD_ADDMUL_OTHER + GR_METHOD_SUBMUL + GR_METHOD_SUBMUL_UI + GR_METHOD_SUBMUL_SI + GR_METHOD_SUBMUL_FMPZ + GR_METHOD_SUBMUL_FMPQ + GR_METHOD_SUBMUL_OTHER + GR_METHOD_FMA + GR_METHOD_FMS + GR_METHOD_FMMA + GR_METHOD_FMMS + GR_METHOD_MUL_TWO + GR_METHOD_SQR + GR_METHOD_MUL_2EXP_SI + GR_METHOD_MUL_2EXP_FMPZ + GR_METHOD_SET_FMPZ_2EXP_FMPZ + GR_METHOD_GET_FMPZ_2EXP_FMPZ + GR_METHOD_IS_INVERTIBLE + GR_METHOD_INV + GR_METHOD_DIV + GR_METHOD_DIV_UI + GR_METHOD_DIV_SI + GR_METHOD_DIV_FMPZ + GR_METHOD_DIV_FMPQ + GR_METHOD_DIV_OTHER + GR_METHOD_OTHER_DIV + GR_METHOD_DIVEXACT + GR_METHOD_DIVEXACT_UI + GR_METHOD_DIVEXACT_SI + GR_METHOD_DIVEXACT_FMPZ + GR_METHOD_DIVEXACT_FMPQ + GR_METHOD_DIVEXACT_OTHER + GR_METHOD_OTHER_DIVEXACT + GR_METHOD_POW + GR_METHOD_POW_UI + GR_METHOD_POW_SI + GR_METHOD_POW_FMPZ + GR_METHOD_POW_FMPQ + GR_METHOD_POW_OTHER + GR_METHOD_OTHER_POW + GR_METHOD_IS_SQUARE + GR_METHOD_SQRT + GR_METHOD_RSQRT + GR_METHOD_HYPOT + GR_METHOD_IS_PERFECT_POWER + GR_METHOD_FACTOR_PERFECT_POWER + GR_METHOD_ROOT_UI + GR_METHOD_DIVIDES + GR_METHOD_EUCLIDEAN_DIV + GR_METHOD_EUCLIDEAN_REM + GR_METHOD_EUCLIDEAN_DIVREM + GR_METHOD_GCD + GR_METHOD_LCM + GR_METHOD_FACTOR + GR_METHOD_NUMERATOR + GR_METHOD_DENOMINATOR + GR_METHOD_FLOOR + GR_METHOD_CEIL + GR_METHOD_TRUNC + GR_METHOD_NINT + GR_METHOD_CMP + GR_METHOD_CMPABS + GR_METHOD_CMP_OTHER + GR_METHOD_CMPABS_OTHER + GR_METHOD_MIN + GR_METHOD_MAX + GR_METHOD_ABS + GR_METHOD_ABS2 + GR_METHOD_I + GR_METHOD_CONJ + GR_METHOD_RE + GR_METHOD_IM + GR_METHOD_SGN + GR_METHOD_CSGN + GR_METHOD_ARG + GR_METHOD_POS_INF + GR_METHOD_NEG_INF + GR_METHOD_UINF + GR_METHOD_UNDEFINED + GR_METHOD_UNKNOWN + GR_METHOD_IS_INTEGER + GR_METHOD_IS_RATIONAL + GR_METHOD_IS_REAL + GR_METHOD_IS_POSITIVE_INTEGER + GR_METHOD_IS_NONNEGATIVE_INTEGER + GR_METHOD_IS_NEGATIVE_INTEGER + GR_METHOD_IS_NONPOSITIVE_INTEGER + GR_METHOD_IS_POSITIVE_REAL + GR_METHOD_IS_NONNEGATIVE_REAL + GR_METHOD_IS_NEGATIVE_REAL + GR_METHOD_IS_NONPOSITIVE_REAL + GR_METHOD_IS_ROOT_OF_UNITY + GR_METHOD_ROOT_OF_UNITY_UI + GR_METHOD_ROOT_OF_UNITY_UI_VEC + GR_METHOD_PI + GR_METHOD_EXP + GR_METHOD_EXPM1 + GR_METHOD_EXP_PI_I + GR_METHOD_EXP2 + GR_METHOD_EXP10 + GR_METHOD_LOG + GR_METHOD_LOG1P + GR_METHOD_LOG_PI_I + GR_METHOD_LOG2 + GR_METHOD_LOG10 + GR_METHOD_SIN + GR_METHOD_COS + GR_METHOD_SIN_COS + GR_METHOD_TAN + GR_METHOD_COT + GR_METHOD_SEC + GR_METHOD_CSC + GR_METHOD_SIN_PI + GR_METHOD_COS_PI + GR_METHOD_SIN_COS_PI + GR_METHOD_TAN_PI + GR_METHOD_COT_PI + GR_METHOD_SEC_PI + GR_METHOD_CSC_PI + GR_METHOD_SINC + GR_METHOD_SINC_PI + GR_METHOD_SINH + GR_METHOD_COSH + GR_METHOD_SINH_COSH + GR_METHOD_TANH + GR_METHOD_COTH + GR_METHOD_SECH + GR_METHOD_CSCH + GR_METHOD_ASIN + GR_METHOD_ACOS + GR_METHOD_ATAN + GR_METHOD_ATAN2 + GR_METHOD_ACOT + GR_METHOD_ASEC + GR_METHOD_ACSC + GR_METHOD_ASINH + GR_METHOD_ACOSH + GR_METHOD_ATANH + GR_METHOD_ACOTH + GR_METHOD_ASECH + GR_METHOD_ACSCH + GR_METHOD_ASIN_PI + GR_METHOD_ACOS_PI + GR_METHOD_ATAN_PI + GR_METHOD_ACOT_PI + GR_METHOD_ASEC_PI + GR_METHOD_ACSC_PI + GR_METHOD_FAC + GR_METHOD_FAC_UI + GR_METHOD_FAC_FMPZ + GR_METHOD_FAC_VEC + GR_METHOD_RFAC + GR_METHOD_RFAC_UI + GR_METHOD_RFAC_FMPZ + GR_METHOD_RFAC_VEC + GR_METHOD_BIN + GR_METHOD_BIN_UI + GR_METHOD_BIN_UIUI + GR_METHOD_BIN_VEC + GR_METHOD_BIN_UI_VEC + GR_METHOD_RISING_UI + GR_METHOD_RISING + GR_METHOD_FALLING_UI + GR_METHOD_FALLING + GR_METHOD_GAMMA + GR_METHOD_GAMMA_FMPZ + GR_METHOD_GAMMA_FMPQ + GR_METHOD_RGAMMA + GR_METHOD_LGAMMA + GR_METHOD_DIGAMMA + GR_METHOD_BETA + GR_METHOD_DOUBLEFAC + GR_METHOD_DOUBLEFAC_UI + GR_METHOD_BARNES_G + GR_METHOD_LOG_BARNES_G + GR_METHOD_HARMONIC + GR_METHOD_HARMONIC_UI + GR_METHOD_BERNOULLI_UI + GR_METHOD_BERNOULLI_FMPZ + GR_METHOD_BERNOULLI_VEC + GR_METHOD_FIB_UI + GR_METHOD_FIB_FMPZ + GR_METHOD_FIB_VEC + GR_METHOD_STIRLING_S1U_UIUI + GR_METHOD_STIRLING_S1_UIUI + GR_METHOD_STIRLING_S2_UIUI + GR_METHOD_STIRLING_S1U_UI_VEC + GR_METHOD_STIRLING_S1_UI_VEC + GR_METHOD_STIRLING_S2_UI_VEC + GR_METHOD_EULERNUM_UI + GR_METHOD_EULERNUM_FMPZ + GR_METHOD_EULERNUM_VEC + GR_METHOD_BELLNUM_UI + GR_METHOD_BELLNUM_FMPZ + GR_METHOD_BELLNUM_VEC + GR_METHOD_PARTITIONS_UI + GR_METHOD_PARTITIONS_FMPZ + GR_METHOD_PARTITIONS_VEC + GR_METHOD_CHEBYSHEV_T_FMPZ + GR_METHOD_CHEBYSHEV_U_FMPZ + GR_METHOD_CHEBYSHEV_T + GR_METHOD_CHEBYSHEV_U + GR_METHOD_JACOBI_P + GR_METHOD_GEGENBAUER_C + GR_METHOD_LAGUERRE_L + GR_METHOD_HERMITE_H + GR_METHOD_LEGENDRE_P + GR_METHOD_LEGENDRE_Q + GR_METHOD_LEGENDRE_P_ROOT_UI + GR_METHOD_SPHERICAL_Y_SI + GR_METHOD_EULER + GR_METHOD_CATALAN + GR_METHOD_KHINCHIN + GR_METHOD_GLAISHER + GR_METHOD_LAMBERTW + GR_METHOD_LAMBERTW_FMPZ + GR_METHOD_ERF + GR_METHOD_ERFC + GR_METHOD_ERFCX + GR_METHOD_ERFI + GR_METHOD_ERFINV + GR_METHOD_ERFCINV + GR_METHOD_FRESNEL_S + GR_METHOD_FRESNEL_C + GR_METHOD_FRESNEL + GR_METHOD_GAMMA_UPPER + GR_METHOD_GAMMA_LOWER + GR_METHOD_BETA_LOWER + GR_METHOD_EXP_INTEGRAL + GR_METHOD_EXP_INTEGRAL_EI + GR_METHOD_SIN_INTEGRAL + GR_METHOD_COS_INTEGRAL + GR_METHOD_SINH_INTEGRAL + GR_METHOD_COSH_INTEGRAL + GR_METHOD_LOG_INTEGRAL + GR_METHOD_DILOG + GR_METHOD_BESSEL_J + GR_METHOD_BESSEL_Y + GR_METHOD_BESSEL_J_Y + GR_METHOD_BESSEL_I + GR_METHOD_BESSEL_I_SCALED + GR_METHOD_BESSEL_K + GR_METHOD_BESSEL_K_SCALED + GR_METHOD_AIRY + GR_METHOD_AIRY_AI + GR_METHOD_AIRY_BI + GR_METHOD_AIRY_AI_PRIME + GR_METHOD_AIRY_BI_PRIME + GR_METHOD_AIRY_AI_ZERO + GR_METHOD_AIRY_BI_ZERO + GR_METHOD_AIRY_AI_PRIME_ZERO + GR_METHOD_AIRY_BI_PRIME_ZERO + GR_METHOD_COULOMB + GR_METHOD_COULOMB_F + GR_METHOD_COULOMB_G + GR_METHOD_COULOMB_HPOS + GR_METHOD_COULOMB_HNEG + GR_METHOD_ZETA + GR_METHOD_ZETA_UI + GR_METHOD_HURWITZ_ZETA + GR_METHOD_LERCH_PHI + GR_METHOD_STIELTJES + GR_METHOD_DIRICHLET_ETA + GR_METHOD_DIRICHLET_BETA + GR_METHOD_RIEMANN_XI + GR_METHOD_ZETA_ZERO + GR_METHOD_ZETA_ZERO_VEC + GR_METHOD_ZETA_NZEROS + GR_METHOD_DIRICHLET_CHI_UI + GR_METHOD_DIRICHLET_CHI_FMPZ + GR_METHOD_DIRICHLET_L + GR_METHOD_DIRICHLET_HARDY_THETA + GR_METHOD_DIRICHLET_HARDY_Z + GR_METHOD_BERNPOLY_UI + GR_METHOD_EULERPOLY_UI + GR_METHOD_POLYLOG + GR_METHOD_POLYGAMMA + GR_METHOD_HYPGEOM_0F1 + GR_METHOD_HYPGEOM_1F1 + GR_METHOD_HYPGEOM_2F0 + GR_METHOD_HYPGEOM_2F1 + GR_METHOD_HYPGEOM_U + GR_METHOD_HYPGEOM_PFQ + GR_METHOD_JACOBI_THETA + GR_METHOD_JACOBI_THETA_1 + GR_METHOD_JACOBI_THETA_2 + GR_METHOD_JACOBI_THETA_3 + GR_METHOD_JACOBI_THETA_4 + GR_METHOD_JACOBI_THETA_Q + GR_METHOD_JACOBI_THETA_Q_1 + GR_METHOD_JACOBI_THETA_Q_2 + GR_METHOD_JACOBI_THETA_Q_3 + GR_METHOD_JACOBI_THETA_Q_4 + GR_METHOD_MODULAR_J + GR_METHOD_MODULAR_LAMBDA + GR_METHOD_MODULAR_DELTA + GR_METHOD_HILBERT_CLASS_POLY + GR_METHOD_DEDEKIND_ETA + GR_METHOD_DEDEKIND_ETA_Q + GR_METHOD_EISENSTEIN_E + GR_METHOD_EISENSTEIN_G + GR_METHOD_EISENSTEIN_G_VEC + GR_METHOD_AGM + GR_METHOD_AGM1 + GR_METHOD_ELLIPTIC_K + GR_METHOD_ELLIPTIC_E + GR_METHOD_ELLIPTIC_PI + GR_METHOD_ELLIPTIC_F + GR_METHOD_ELLIPTIC_E_INC + GR_METHOD_ELLIPTIC_PI_INC + GR_METHOD_CARLSON_RF + GR_METHOD_CARLSON_RC + GR_METHOD_CARLSON_RJ + GR_METHOD_CARLSON_RG + GR_METHOD_CARLSON_RD + GR_METHOD_ELLIPTIC_ROOTS + GR_METHOD_ELLIPTIC_INVARIANTS + GR_METHOD_WEIERSTRASS_P + GR_METHOD_WEIERSTRASS_P_PRIME + GR_METHOD_WEIERSTRASS_P_INV + GR_METHOD_WEIERSTRASS_ZETA + GR_METHOD_WEIERSTRASS_SIGMA + GR_METHOD_GEN + GR_METHOD_GENS + GR_METHOD_CTX_FQ_PRIME + GR_METHOD_CTX_FQ_DEGREE + GR_METHOD_CTX_FQ_ORDER + GR_METHOD_FQ_FROBENIUS + GR_METHOD_FQ_MULTIPLICATIVE_ORDER + GR_METHOD_FQ_NORM + GR_METHOD_FQ_TRACE + GR_METHOD_FQ_IS_PRIMITIVE + GR_METHOD_FQ_PTH_ROOT + GR_METHOD_VEC_INIT + GR_METHOD_VEC_CLEAR + GR_METHOD_VEC_SWAP + GR_METHOD_VEC_SET + GR_METHOD_VEC_ZERO + GR_METHOD_VEC_EQUAL + GR_METHOD_VEC_IS_ZERO + GR_METHOD_VEC_NEG + GR_METHOD_VEC_NORMALISE + GR_METHOD_VEC_NORMALISE_WEAK + GR_METHOD_VEC_ADD + GR_METHOD_VEC_SUB + GR_METHOD_VEC_MUL + GR_METHOD_VEC_DIV + GR_METHOD_VEC_DIVEXACT + GR_METHOD_VEC_POW + GR_METHOD_VEC_ADD_SCALAR + GR_METHOD_VEC_SUB_SCALAR + GR_METHOD_VEC_MUL_SCALAR + GR_METHOD_VEC_DIV_SCALAR + GR_METHOD_VEC_DIVEXACT_SCALAR + GR_METHOD_VEC_POW_SCALAR + GR_METHOD_SCALAR_ADD_VEC + GR_METHOD_SCALAR_SUB_VEC + GR_METHOD_SCALAR_MUL_VEC + GR_METHOD_SCALAR_DIV_VEC + GR_METHOD_SCALAR_DIVEXACT_VEC + GR_METHOD_SCALAR_POW_VEC + GR_METHOD_VEC_ADD_OTHER + GR_METHOD_VEC_SUB_OTHER + GR_METHOD_VEC_MUL_OTHER + GR_METHOD_VEC_DIV_OTHER + GR_METHOD_VEC_DIVEXACT_OTHER + GR_METHOD_VEC_POW_OTHER + GR_METHOD_OTHER_ADD_VEC + GR_METHOD_OTHER_SUB_VEC + GR_METHOD_OTHER_MUL_VEC + GR_METHOD_OTHER_DIV_VEC + GR_METHOD_OTHER_DIVEXACT_VEC + GR_METHOD_OTHER_POW_VEC + GR_METHOD_VEC_ADD_SCALAR_OTHER + GR_METHOD_VEC_SUB_SCALAR_OTHER + GR_METHOD_VEC_MUL_SCALAR_OTHER + GR_METHOD_VEC_DIV_SCALAR_OTHER + GR_METHOD_VEC_DIVEXACT_SCALAR_OTHER + GR_METHOD_VEC_POW_SCALAR_OTHER + GR_METHOD_SCALAR_OTHER_ADD_VEC + GR_METHOD_SCALAR_OTHER_SUB_VEC + GR_METHOD_SCALAR_OTHER_MUL_VEC + GR_METHOD_SCALAR_OTHER_DIV_VEC + GR_METHOD_SCALAR_OTHER_DIVEXACT_VEC + GR_METHOD_SCALAR_OTHER_POW_VEC + GR_METHOD_VEC_ADD_SCALAR_SI + GR_METHOD_VEC_ADD_SCALAR_UI + GR_METHOD_VEC_ADD_SCALAR_FMPZ + GR_METHOD_VEC_ADD_SCALAR_FMPQ + GR_METHOD_VEC_SUB_SCALAR_SI + GR_METHOD_VEC_SUB_SCALAR_UI + GR_METHOD_VEC_SUB_SCALAR_FMPZ + GR_METHOD_VEC_SUB_SCALAR_FMPQ + GR_METHOD_VEC_MUL_SCALAR_SI + GR_METHOD_VEC_MUL_SCALAR_UI + GR_METHOD_VEC_MUL_SCALAR_FMPZ + GR_METHOD_VEC_MUL_SCALAR_FMPQ + GR_METHOD_VEC_DIV_SCALAR_SI + GR_METHOD_VEC_DIV_SCALAR_UI + GR_METHOD_VEC_DIV_SCALAR_FMPZ + GR_METHOD_VEC_DIV_SCALAR_FMPQ + GR_METHOD_VEC_DIVEXACT_SCALAR_SI + GR_METHOD_VEC_DIVEXACT_SCALAR_UI + GR_METHOD_VEC_DIVEXACT_SCALAR_FMPZ + GR_METHOD_VEC_DIVEXACT_SCALAR_FMPQ + GR_METHOD_VEC_POW_SCALAR_SI + GR_METHOD_VEC_POW_SCALAR_UI + GR_METHOD_VEC_POW_SCALAR_FMPZ + GR_METHOD_VEC_POW_SCALAR_FMPQ + GR_METHOD_VEC_MUL_SCALAR_2EXP_SI + GR_METHOD_VEC_MUL_SCALAR_2EXP_FMPZ + GR_METHOD_VEC_ADDMUL_SCALAR + GR_METHOD_VEC_SUBMUL_SCALAR + GR_METHOD_VEC_ADDMUL_SCALAR_SI + GR_METHOD_VEC_SUBMUL_SCALAR_SI + GR_METHOD_VEC_SUM + GR_METHOD_VEC_PRODUCT + GR_METHOD_VEC_DOT + GR_METHOD_VEC_DOT_REV + GR_METHOD_VEC_DOT_UI + GR_METHOD_VEC_DOT_SI + GR_METHOD_VEC_DOT_FMPZ + GR_METHOD_VEC_SET_POWERS + GR_METHOD_VEC_RECIPROCALS + GR_METHOD_POLY_MULLOW + GR_METHOD_POLY_DIV + GR_METHOD_POLY_DIVREM + GR_METHOD_POLY_DIVEXACT + GR_METHOD_POLY_TAYLOR_SHIFT + GR_METHOD_POLY_INV_SERIES + GR_METHOD_POLY_INV_SERIES_BASECASE + GR_METHOD_POLY_DIV_SERIES + GR_METHOD_POLY_DIV_SERIES_BASECASE + GR_METHOD_POLY_RSQRT_SERIES + GR_METHOD_POLY_SQRT_SERIES + GR_METHOD_POLY_EXP_SERIES + GR_METHOD_POLY_FACTOR + GR_METHOD_POLY_ROOTS + GR_METHOD_POLY_ROOTS_OTHER + GR_METHOD_MAT_MUL + GR_METHOD_MAT_DET + GR_METHOD_MAT_EXP + GR_METHOD_MAT_LOG + GR_METHOD_MAT_FIND_NONZERO_PIVOT + GR_METHOD_MAT_DIAGONALIZATION + GR_METHOD_TAB_SIZE + + ctypedef struct gr_method_tab_input: + pass + + ctypedef enum gr_which_structure: + GR_CTX_FMPZ + GR_CTX_FMPQ + GR_CTX_FMPZI + GR_CTX_FMPZ_MOD + GR_CTX_NMOD + GR_CTX_NMOD8 + GR_CTX_NMOD32 + GR_CTX_FQ + GR_CTX_FQ_NMOD + GR_CTX_FQ_ZECH + GR_CTX_NF + GR_CTX_REAL_ALGEBRAIC_QQBAR + GR_CTX_COMPLEX_ALGEBRAIC_QQBAR + GR_CTX_REAL_ALGEBRAIC_CA + GR_CTX_COMPLEX_ALGEBRAIC_CA + GR_CTX_RR_CA + GR_CTX_CC_CA + GR_CTX_COMPLEX_EXTENDED_CA + GR_CTX_RR_ARB + GR_CTX_CC_ACB + GR_CTX_REAL_FLOAT_ARF + GR_CTX_COMPLEX_FLOAT_ACF + GR_CTX_FMPZ_POLY + GR_CTX_FMPQ_POLY + GR_CTX_GR_POLY + GR_CTX_FMPZ_MPOLY + GR_CTX_GR_MPOLY + GR_CTX_FMPZ_MPOLY_Q + GR_CTX_GR_SERIES + GR_CTX_GR_SERIES_MOD + GR_CTX_GR_MAT + GR_CTX_GR_VEC + GR_CTX_PSL2Z + GR_CTX_DIRICHLET_GROUP + GR_CTX_PERM + GR_CTX_FEXPR + GR_CTX_UNKNOWN_DOMAIN + GR_CTX_WHICH_STRUCTURE_TAB_SIZE + + ctypedef struct gr_ctx_struct: + pass + ctypedef gr_ctx_struct gr_ctx_t[1] + + ctypedef void ((*gr_method_init_clear_op)(gr_ptr, gr_ctx_ptr)) + ctypedef void ((*gr_method_swap_op)(gr_ptr, gr_ptr, gr_ctx_ptr)) + ctypedef int ((*gr_method_ctx)(gr_ctx_ptr)) + # Cython is confused!? + ## ctypedef truth_t ((*gr_method_ctx_predicate)(gr_ctx_ptr)) + ctypedef int ((*gr_method_ctx_set_si)(gr_ctx_ptr, slong)) + ctypedef int ((*gr_method_ctx_get_si)(slong *, gr_ctx_ptr)) + ctypedef int ((*gr_method_ctx_stream)(gr_stream_t, gr_ctx_ptr)) + ctypedef int ((*gr_method_ctx_set_str)(gr_ctx_ptr, const char *)) + ctypedef int ((*gr_method_ctx_set_strs)(gr_ctx_ptr, const char **)) + ctypedef int ((*gr_method_stream_in)(gr_stream_t, gr_srcptr, gr_ctx_ptr)) + ctypedef int ((*gr_method_stream_in_si)(gr_stream_t, gr_srcptr, slong, gr_ctx_ptr)) + ctypedef int ((*gr_method_randtest)(gr_ptr, flint_rand_t state, gr_ctx_ptr)) + ctypedef int ((*gr_method_constant_op)(gr_ptr, gr_ctx_ptr)) + ctypedef int ((*gr_method_constant_op_get_si)(slong *, gr_ctx_ptr)) + ctypedef int ((*gr_method_constant_op_get_fmpz)(fmpz_t, gr_ctx_ptr)) + ctypedef void ((*gr_method_void_unary_op)(gr_ptr, gr_srcptr, gr_ctx_ptr)) + ctypedef int ((*gr_method_unary_op)(gr_ptr, gr_srcptr, gr_ctx_ptr)) + ctypedef int ((*gr_method_unary_op_si)(gr_ptr, slong, gr_ctx_ptr)) + ctypedef int ((*gr_method_unary_op_ui)(gr_ptr, ulong, gr_ctx_ptr)) + ctypedef int ((*gr_method_unary_op_fmpz)(gr_ptr, const fmpz_t, gr_ctx_ptr)) + ctypedef int ((*gr_method_unary_op_fmpq)(gr_ptr, const fmpq_t, gr_ctx_ptr)) + ctypedef int ((*gr_method_unary_op_d)(gr_ptr, double, gr_ctx_ptr)) + ctypedef int ((*gr_method_unary_op_other)(gr_ptr, gr_srcptr, gr_ctx_ptr, gr_ctx_ptr)) + ctypedef int ((*gr_method_unary_op_str)(gr_ptr, const char *, gr_ctx_ptr)) + ctypedef int ((*gr_method_unary_op_get_ui)(ulong *, gr_srcptr, gr_ctx_ptr)) + ctypedef int ((*gr_method_unary_op_get_si)(slong *, gr_srcptr, gr_ctx_ptr)) + ctypedef int ((*gr_method_unary_op_get_fmpz)(fmpz_t, gr_srcptr, gr_ctx_ptr)) + ctypedef int ((*gr_method_unary_op_get_fmpq)(fmpq_t, gr_srcptr, gr_ctx_ptr)) + ctypedef int ((*gr_method_unary_op_get_d)(double *, gr_srcptr, gr_ctx_ptr)) + ctypedef int ((*gr_method_unary_op_get_fmpz_fmpz)(fmpz_t, fmpz_t, gr_srcptr, gr_ctx_ptr)) + ctypedef int ((*gr_method_unary_op_with_flag)(gr_ptr, gr_srcptr, int, gr_ctx_ptr)) + ctypedef int ((*gr_method_binary_unary_op)(gr_ptr, gr_ptr, gr_srcptr, gr_ctx_ptr)) + ctypedef int ((*gr_method_binary_unary_op_with_flag)(gr_ptr, gr_ptr, gr_srcptr, int, gr_ctx_ptr)) + ctypedef int ((*gr_method_quaternary_unary_op)(gr_ptr, gr_ptr, gr_ptr, gr_ptr, gr_srcptr, gr_ctx_ptr)) + ctypedef int ((*gr_method_binary_op)(gr_ptr, gr_srcptr, gr_srcptr, gr_ctx_ptr)) + ctypedef int ((*gr_method_binary_op_si)(gr_ptr, gr_srcptr, slong, gr_ctx_ptr)) + ctypedef int ((*gr_method_binary_op_ui)(gr_ptr, gr_srcptr, ulong, gr_ctx_ptr)) + ctypedef int ((*gr_method_binary_op_fmpz)(gr_ptr, gr_srcptr, const fmpz_t, gr_ctx_ptr)) + ctypedef int ((*gr_method_binary_op_fmpz_fmpz)(gr_ptr, const fmpz_t, const fmpz_t, gr_ctx_ptr)) + ctypedef int ((*gr_method_binary_op_fmpz_si)(gr_ptr, const fmpz_t, slong, gr_ctx_ptr)) + ctypedef int ((*gr_method_binary_op_fmpq)(gr_ptr, gr_srcptr, const fmpq_t, gr_ctx_ptr)) + ctypedef int ((*gr_method_binary_op_other)(gr_ptr, gr_srcptr, gr_srcptr, gr_ctx_ptr, gr_ctx_ptr)) + ctypedef int ((*gr_method_other_binary_op)(gr_ptr, gr_srcptr, gr_ctx_ptr, gr_srcptr, gr_ctx_ptr)) + ctypedef int ((*gr_method_si_binary_op)(gr_ptr, slong, gr_srcptr, gr_ctx_ptr)) + ctypedef int ((*gr_method_ui_binary_op)(gr_ptr, ulong, gr_srcptr, gr_ctx_ptr)) + ctypedef int ((*gr_method_fmpz_binary_op)(gr_ptr, const fmpz_t, gr_srcptr, gr_ctx_ptr)) + ctypedef int ((*gr_method_fmpq_binary_op)(gr_ptr, const fmpq_t, gr_srcptr, gr_ctx_ptr)) + ctypedef int ((*gr_method_binary_op_ui_ui)(gr_ptr, ulong, ulong, gr_ctx_ptr)) + ctypedef int ((*gr_method_binary_op_ui_si)(gr_ptr, ulong, slong, gr_ctx_ptr)) + ctypedef int ((*gr_method_binary_op_get_int)(int *, gr_srcptr, gr_srcptr, gr_ctx_ptr)) + ctypedef int ((*gr_method_binary_op_other_get_int)(int *, gr_srcptr, gr_srcptr, gr_ctx_ptr, gr_ctx_ptr)) + ctypedef int ((*gr_method_binary_binary_op)(gr_ptr, gr_ptr, gr_srcptr, gr_srcptr, gr_ctx_ptr)) + ctypedef int ((*gr_method_binary_op_with_flag)(gr_ptr, gr_srcptr, gr_srcptr, int, gr_ctx_ptr)) + ctypedef int ((*gr_method_binary_binary_op_ui_ui)(gr_ptr, gr_ptr, ulong, ulong, gr_ctx_ptr)) + ctypedef int ((*gr_method_ternary_op)(gr_ptr, gr_srcptr, gr_srcptr, gr_srcptr, gr_ctx_ptr)) + ctypedef int ((*gr_method_ternary_op_with_flag)(gr_ptr, gr_srcptr, gr_srcptr, gr_srcptr, int, gr_ctx_ptr)) + ctypedef int ((*gr_method_ternary_unary_op)(gr_ptr, gr_ptr, gr_ptr, gr_srcptr, gr_ctx_ptr)) + ctypedef int ((*gr_method_quaternary_op)(gr_ptr, gr_srcptr, gr_srcptr, gr_srcptr, gr_srcptr, gr_ctx_ptr)) + ctypedef int ((*gr_method_quaternary_op_with_flag)(gr_ptr, gr_srcptr, gr_srcptr, gr_srcptr, gr_srcptr, int, gr_ctx_ptr)) + ctypedef int ((*gr_method_quaternary_binary_op)(gr_ptr, gr_ptr, gr_ptr, gr_ptr, gr_srcptr, gr_srcptr, gr_ctx_ptr)) + ctypedef int ((*gr_method_quaternary_ternary_op)(gr_ptr, gr_ptr, gr_ptr, gr_ptr, gr_srcptr, gr_srcptr, gr_srcptr, gr_ctx_ptr)) + ctypedef int ((*gr_method_si_si_quaternary_op)(gr_ptr, slong, slong, gr_srcptr, gr_srcptr, gr_ctx_ptr)) + # Cython is confused!? + ## ctypedef truth_t ((*gr_method_unary_predicate)(gr_srcptr, gr_ctx_ptr)) + ## ctypedef truth_t ((*gr_method_binary_predicate)(gr_srcptr, gr_srcptr, gr_ctx_ptr)) + ctypedef void ((*gr_method_vec_init_clear_op)(gr_ptr, slong, gr_ctx_ptr)) + ctypedef void ((*gr_method_vec_swap_op)(gr_ptr, gr_ptr, slong, gr_ctx_ptr)) + ctypedef int ((*gr_method_vec_constant_op)(gr_ptr, slong, gr_ctx_ptr)) + ctypedef int ((*gr_method_vec_op)(gr_ptr, gr_srcptr, slong, gr_ctx_ptr)) + ctypedef int ((*gr_method_vec_vec_op)(gr_ptr, gr_srcptr, gr_srcptr, slong, gr_ctx_ptr)) + ctypedef int ((*gr_method_vec_scalar_op)(gr_ptr, gr_srcptr, slong, gr_srcptr, gr_ctx_ptr)) + ctypedef int ((*gr_method_scalar_vec_op)(gr_ptr, gr_srcptr, gr_srcptr, slong, gr_ctx_ptr)) + ctypedef int ((*gr_method_vec_op_other)(gr_ptr, gr_srcptr, gr_srcptr, gr_ctx_ptr, slong, gr_ctx_ptr)) + ctypedef int ((*gr_method_other_op_vec)(gr_ptr, gr_srcptr, gr_ctx_ptr, gr_srcptr, slong, gr_ctx_ptr)) + ctypedef int ((*gr_method_vec_op_scalar_other)(gr_ptr, gr_srcptr, slong, gr_srcptr, gr_ctx_ptr, gr_ctx_ptr)) + ctypedef int ((*gr_method_scalar_other_op_vec)(gr_ptr, gr_srcptr, gr_ctx_ptr, gr_srcptr, slong, gr_ctx_ptr)) + ctypedef int ((*gr_method_vec_scalar_op_si)(gr_ptr, gr_srcptr, slong, slong, gr_ctx_ptr)) + ctypedef int ((*gr_method_vec_scalar_op_ui)(gr_ptr, gr_srcptr, slong, ulong, gr_ctx_ptr)) + ctypedef int ((*gr_method_vec_scalar_op_fmpz)(gr_ptr, gr_srcptr, slong, const fmpz_t, gr_ctx_ptr)) + ctypedef int ((*gr_method_vec_scalar_op_fmpq)(gr_ptr, gr_srcptr, slong, const fmpq_t, gr_ctx_ptr)) + # Cython is confused!? + ## ctypedef truth_t ((*gr_method_vec_predicate)(gr_srcptr, slong, gr_ctx_ptr)) + ## ctypedef truth_t ((*gr_method_vec_vec_predicate)(gr_srcptr, gr_srcptr, slong, gr_ctx_ptr)) + ctypedef int ((*gr_method_factor_op)(gr_ptr, gr_vec_t, gr_vec_t, gr_srcptr, int, gr_ctx_ptr)) + ctypedef int ((*gr_method_poly_unary_trunc_op)(gr_ptr, gr_srcptr, slong, slong, gr_ctx_ptr)) + ctypedef int ((*gr_method_poly_binary_op)(gr_ptr, gr_srcptr, slong, gr_srcptr, slong, gr_ctx_ptr)) + ctypedef int ((*gr_method_poly_binary_binary_op)(gr_ptr, gr_ptr, gr_srcptr, slong, gr_srcptr, slong, gr_ctx_ptr)) + ctypedef int ((*gr_method_poly_binary_trunc_op)(gr_ptr, gr_srcptr, slong, gr_srcptr, slong, slong, gr_ctx_ptr)) + ctypedef int ((*gr_method_vec_ctx_op)(gr_vec_t, gr_ctx_ptr)) + + ctypedef struct polynomial_ctx_t: + pass + + ctypedef struct vector_ctx_t: + pass + + ctypedef struct matrix_ctx_t: + pass + + + # flint/gr_poly.h + ctypedef struct gr_poly_struct: + pass + ctypedef gr_poly_struct gr_poly_t[1] + + + # flint/gr_mat.h + ctypedef struct gr_mat_struct: + pass + ctypedef gr_mat_struct gr_mat_t[1] + + + # flint/gr_mpoly.h + ctypedef struct gr_mpoly_struct: + pass + ctypedef gr_mpoly_struct gr_mpoly_t[1] + + + # flint/double_interval.h + ctypedef struct di_t: + double a + double b + + + # flint/fq_default.h + ctypedef union fq_default_struct: + fq_t fq + fq_nmod_t fq_nmod + fq_zech_t fq_zech + ulong nmod + fmpz_t fmpz_mod + ctypedef fq_default_struct fq_default_t[1] + + ctypedef struct fq_default_ctx_struct: + pass + ctypedef fq_default_ctx_struct fq_default_ctx_t[1] + + + # flint/fq_default_poly.h + ctypedef union fq_default_poly_struct: + fq_poly_t fq + fq_nmod_poly_t fq_nmod + fq_zech_poly_t fq_zech + nmod_poly_t nmod + fmpz_mod_poly_t fmpz_mod + ctypedef fq_default_poly_struct fq_default_poly_t[1] + + + # flint/fq_poly_factor.h + ctypedef union fq_default_poly_factor_struct: + fq_poly_factor_t fq + fq_nmod_poly_factor_t fq_nmod + fq_zech_poly_factor_t fq_zech + nmod_poly_factor_t nmod + fmpz_mod_poly_factor_t fmpz_mod + ctypedef fq_default_poly_factor_struct fq_default_poly_factor_t[1] + + + # flint/fq_default_mat.h + ctypedef union fq_default_mat_struct: + pass + ctypedef fq_default_mat_struct fq_default_mat_t[1] + + + # flint/qfb.h + ctypedef struct qfb: + pass + ctypedef qfb qfb_t[1] + + ctypedef struct qfb_hash_t: + pass + + + # flint/qqbar.h + ctypedef struct qqbar_struct: + pass + ctypedef qqbar_struct qqbar_t[1] + ctypedef qqbar_struct * qqbar_ptr + ctypedef const qqbar_struct * qqbar_srcptr + + + # flint/profiler.h + ctypedef struct struct_meminfo: + pass + ctypedef struct_meminfo meminfo_t[1] + + ctypedef struct struct_timeit: + pass + ctypedef struct_timeit timeit_t[1] + + ctypedef void (*profile_target_t)(void* arg, ulong count) + + + # flint/fexpr.h + ctypedef struct fexpr_struct: + pass + ctypedef fexpr_struct fexpr_t[1] + ctypedef fexpr_struct * fexpr_ptr + ctypedef const fexpr_struct * fexpr_srcptr + + ctypedef struct fexpr_vec_struct: + pass + ctypedef fexpr_vec_struct fexpr_vec_t[1] + + + # flint/hypgeom.h + ctypedef struct hypgeom_struct: + pass + ctypedef hypgeom_struct hypgeom_t[1] + + + # flint/dlog.h + ctypedef struct dlog_precomp_struct: + pass + ctypedef dlog_precomp_struct * dlog_precomp_ptr + ctypedef dlog_precomp_struct dlog_precomp_t[1] + + ctypedef struct dlog_1modpe_struct: + pass + ctypedef dlog_1modpe_struct dlog_1modpe_t[1] + + ctypedef struct dlog_modpe_struct: + pass + ctypedef dlog_modpe_struct dlog_modpe_t[1] + + ctypedef struct dlog_table_struct: + pass + ctypedef dlog_table_struct dlog_table_t[1] + + ctypedef struct apow_t: + pass + + ctypedef struct dlog_bsgs_struct: + pass + ctypedef dlog_bsgs_struct dlog_bsgs_t[1] + + ctypedef struct dlog_rho_struct: + pass + ctypedef dlog_rho_struct dlog_rho_t[1] + + ctypedef struct dlog_crt_struct: + pass + ctypedef dlog_crt_struct dlog_crt_t[1] + + ctypedef struct dlog_power_struct: + pass + ctypedef dlog_power_struct dlog_power_t[1] + + ctypedef ulong dlog_order23_t[1] + + + # flint/bool_mat.h + ctypedef struct bool_mat_struct: + pass + ctypedef bool_mat_struct bool_mat_t[1] + + + # flint/dirichlet.h + ctypedef struct dirichlet_prime_group_struct: + pass + + ctypedef struct dirichlet_group_struct: + pass + ctypedef dirichlet_group_struct dirichlet_group_t[1] + + ctypedef struct dirichlet_char_struct: + pass + ctypedef dirichlet_char_struct dirichlet_char_t[1] + + + # flint/arb_fpwrap.h + ctypedef struct complex_double: + double real + double imag + + + # flint/aprcl.h + ctypedef struct _aprcl_config: + pass + ctypedef _aprcl_config aprcl_config[1]; + + ctypedef struct _unity_zpq: + pass + ctypedef _unity_zpq unity_zpq[1] + + ctypedef struct _unity_zp: + pass + ctypedef _unity_zp unity_zp[1] + + ctypedef enum primality_test_status: + UNKNOWN + PRIME + COMPOSITE + PROBABPRIME + + + # flint/acf.h + ctypedef struct acf_struct: + pass + + ctypedef acf_struct acf_t[1] + ctypedef acf_struct * acf_ptr + ctypedef const acf_struct * acf_srcptr + + + # flint/fmpz_lll.h + ctypedef enum rep_type: + GRAM + Z_BASIS + + ctypedef enum gram_type: + APPROX + EXACT + + ctypedef struct fmpz_lll_struct: + pass + ctypedef fmpz_lll_struct fmpz_lll_t[1] + + ctypedef union fmpz_gram_union: + d_mat_t appSP + mpf_mat_t appSP2 + fmpz_mat_t exactSP + ctypedef fmpz_gram_union fmpz_gram_t[1] From f67acd57ff0f7516c81107915549ff8a3a714c78 Mon Sep 17 00:00:00 2001 From: Vincent Delecroix Date: Sun, 22 Oct 2023 15:06:23 +0200 Subject: [PATCH 19/41] some fixes in flint headers --- src/sage/libs/flint/types.pxd | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/src/sage/libs/flint/types.pxd b/src/sage/libs/flint/types.pxd index c0b4428f4eb..132a2146fb0 100644 --- a/src/sage/libs/flint/types.pxd +++ b/src/sage/libs/flint/types.pxd @@ -75,7 +75,7 @@ cdef extern from "flint_wrap.h": # flint/arf.h - cdef enum arf_rnd_t: + ctypedef enum arf_rnd_t: ARF_RND_DOWN ARF_RND_UP ARF_RND_FLOOR @@ -654,16 +654,6 @@ cdef extern from "flint_wrap.h": ctypedef nmod_discrete_log_pohlig_hellman_struct nmod_discrete_log_pohlig_hellman_t[1] - # flint/fq_nmod.h - ctypedef struct fq_nmod_ctx_struct: - nmod_poly_t modulus - - ctypedef fq_nmod_ctx_struct fq_nmod_ctx_t[1] - - ctypedef nmod_poly_struct fq_nmod_struct - ctypedef nmod_poly_t fq_nmod_t - - # flint/fq_types.h ctypedef fmpz_poly_t fq_t ctypedef fmpz_poly_struct fq_struct @@ -820,7 +810,7 @@ cdef extern from "flint_wrap.h": # flint/mpoly_types.h - ctypedef enum ordering_t: + ctypedef enum ordering_t: ORD_LEX ORD_DEGLEX ORD_DEGREVLEX From 3a3736b17cdf2d3ff10044c53569a17bb86f4ba5 Mon Sep 17 00:00:00 2001 From: Vincent Delecroix Date: Sun, 22 Oct 2023 16:41:28 +0200 Subject: [PATCH 20/41] remove extra parenthesis to make cython less confused --- src/sage/libs/flint/types.pxd | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/sage/libs/flint/types.pxd b/src/sage/libs/flint/types.pxd index 132a2146fb0..4ef65f1d3a7 100644 --- a/src/sage/libs/flint/types.pxd +++ b/src/sage/libs/flint/types.pxd @@ -1706,8 +1706,9 @@ cdef extern from "flint_wrap.h": ctypedef void ((*gr_method_init_clear_op)(gr_ptr, gr_ctx_ptr)) ctypedef void ((*gr_method_swap_op)(gr_ptr, gr_ptr, gr_ctx_ptr)) ctypedef int ((*gr_method_ctx)(gr_ctx_ptr)) - # Cython is confused!? - ## ctypedef truth_t ((*gr_method_ctx_predicate)(gr_ctx_ptr)) + # NOTE: we removed an extra paranthesis so that Cython is less confused + # see https://github.com/cython/cython/issues/5779 + ctypedef truth_t (*gr_method_ctx_predicate)(gr_ctx_ptr) ctypedef int ((*gr_method_ctx_set_si)(gr_ctx_ptr, slong)) ctypedef int ((*gr_method_ctx_get_si)(slong *, gr_ctx_ptr)) ctypedef int ((*gr_method_ctx_stream)(gr_stream_t, gr_ctx_ptr)) @@ -1766,9 +1767,10 @@ cdef extern from "flint_wrap.h": ctypedef int ((*gr_method_quaternary_binary_op)(gr_ptr, gr_ptr, gr_ptr, gr_ptr, gr_srcptr, gr_srcptr, gr_ctx_ptr)) ctypedef int ((*gr_method_quaternary_ternary_op)(gr_ptr, gr_ptr, gr_ptr, gr_ptr, gr_srcptr, gr_srcptr, gr_srcptr, gr_ctx_ptr)) ctypedef int ((*gr_method_si_si_quaternary_op)(gr_ptr, slong, slong, gr_srcptr, gr_srcptr, gr_ctx_ptr)) - # Cython is confused!? - ## ctypedef truth_t ((*gr_method_unary_predicate)(gr_srcptr, gr_ctx_ptr)) - ## ctypedef truth_t ((*gr_method_binary_predicate)(gr_srcptr, gr_srcptr, gr_ctx_ptr)) + # NOTE: we removed an extra paranthesis so that Cython is less confused + # see https://github.com/cython/cython/issues/5779 + ctypedef truth_t (*gr_method_unary_predicate)(gr_srcptr, gr_ctx_ptr) + ctypedef truth_t (*gr_method_binary_predicate)(gr_srcptr, gr_srcptr, gr_ctx_ptr) ctypedef void ((*gr_method_vec_init_clear_op)(gr_ptr, slong, gr_ctx_ptr)) ctypedef void ((*gr_method_vec_swap_op)(gr_ptr, gr_ptr, slong, gr_ctx_ptr)) ctypedef int ((*gr_method_vec_constant_op)(gr_ptr, slong, gr_ctx_ptr)) @@ -1784,9 +1786,10 @@ cdef extern from "flint_wrap.h": ctypedef int ((*gr_method_vec_scalar_op_ui)(gr_ptr, gr_srcptr, slong, ulong, gr_ctx_ptr)) ctypedef int ((*gr_method_vec_scalar_op_fmpz)(gr_ptr, gr_srcptr, slong, const fmpz_t, gr_ctx_ptr)) ctypedef int ((*gr_method_vec_scalar_op_fmpq)(gr_ptr, gr_srcptr, slong, const fmpq_t, gr_ctx_ptr)) - # Cython is confused!? - ## ctypedef truth_t ((*gr_method_vec_predicate)(gr_srcptr, slong, gr_ctx_ptr)) - ## ctypedef truth_t ((*gr_method_vec_vec_predicate)(gr_srcptr, gr_srcptr, slong, gr_ctx_ptr)) + # NOTE: we removed an extra paranthesis so that Cython is less confused + # see https://github.com/cython/cython/issues/5779 + ctypedef truth_t (*gr_method_vec_predicate)(gr_srcptr, slong, gr_ctx_ptr) + ctypedef truth_t (*gr_method_vec_vec_predicate)(gr_srcptr, gr_srcptr, slong, gr_ctx_ptr) ctypedef int ((*gr_method_factor_op)(gr_ptr, gr_vec_t, gr_vec_t, gr_srcptr, int, gr_ctx_ptr)) ctypedef int ((*gr_method_poly_unary_trunc_op)(gr_ptr, gr_srcptr, slong, slong, gr_ctx_ptr)) ctypedef int ((*gr_method_poly_binary_op)(gr_ptr, gr_srcptr, slong, gr_srcptr, slong, gr_ctx_ptr)) From 43f676aa786baa91778358ffc4e19191a2aabe48 Mon Sep 17 00:00:00 2001 From: Vincent Delecroix <20100.delecroix@gmail.com> Date: Mon, 11 Dec 2023 10:27:38 +0100 Subject: [PATCH 21/41] noexcept --- src/sage/libs/flint/acb.pxd | 476 +++++------ src/sage/libs/flint/acb_calc.pxd | 10 +- src/sage/libs/flint/acb_dft.pxd | 68 +- src/sage/libs/flint/acb_dirichlet.pxd | 190 ++--- src/sage/libs/flint/acb_elliptic.pxd | 50 +- src/sage/libs/flint/acb_hypgeom.pxd | 304 +++---- src/sage/libs/flint/acb_mat.pxd | 218 ++--- src/sage/libs/flint/acb_modular.pxd | 90 +- src/sage/libs/flint/acb_poly.pxd | 476 +++++------ src/sage/libs/flint/acf.pxd | 30 +- src/sage/libs/flint/aprcl.pxd | 134 +-- src/sage/libs/flint/arb.pxd | 712 ++++++++-------- src/sage/libs/flint/arb_calc.pxd | 28 +- src/sage/libs/flint/arb_fmpz_poly.pxd | 34 +- src/sage/libs/flint/arb_fpwrap.pxd | 396 ++++----- src/sage/libs/flint/arb_hypgeom.pxd | 260 +++--- src/sage/libs/flint/arb_mat.pxd | 224 ++--- src/sage/libs/flint/arb_poly.pxd | 452 +++++----- src/sage/libs/flint/arf.pxd | 300 +++---- src/sage/libs/flint/arith.pxd | 118 +-- src/sage/libs/flint/bernoulli.pxd | 22 +- src/sage/libs/flint/bool_mat.pxd | 70 +- src/sage/libs/flint/ca.pxd | 372 ++++----- src/sage/libs/flint/ca_ext.pxd | 34 +- src/sage/libs/flint/ca_field.pxd | 30 +- src/sage/libs/flint/ca_mat.pxd | 200 ++--- src/sage/libs/flint/ca_poly.pxd | 174 ++-- src/sage/libs/flint/ca_vec.pxd | 58 +- src/sage/libs/flint/calcium.pxd | 20 +- src/sage/libs/flint/d_mat.pxd | 44 +- src/sage/libs/flint/d_vec.pxd | 30 +- src/sage/libs/flint/dirichlet.pxd | 80 +- src/sage/libs/flint/dlog.pxd | 72 +- src/sage/libs/flint/double_extras.pxd | 14 +- src/sage/libs/flint/double_interval.pxd | 38 +- src/sage/libs/flint/fexpr.pxd | 174 ++-- src/sage/libs/flint/fexpr_builtin.pxd | 6 +- src/sage/libs/flint/fft.pxd | 98 +-- src/sage/libs/flint/flint.pxd | 38 +- src/sage/libs/flint/fmpq.pxd | 244 +++--- src/sage/libs/flint/fmpq_mat.pxd | 172 ++-- src/sage/libs/flint/fmpq_mpoly.pxd | 296 +++---- src/sage/libs/flint/fmpq_mpoly_factor.pxd | 26 +- src/sage/libs/flint/fmpq_poly.pxd | 452 +++++----- src/sage/libs/flint/fmpq_poly_sage.pxd | 12 +- src/sage/libs/flint/fmpq_poly_sage.pyx | 13 +- src/sage/libs/flint/fmpq_vec.pxd | 20 +- src/sage/libs/flint/fmpz.pxd | 474 +++++------ src/sage/libs/flint/fmpz_extras.pxd | 30 +- src/sage/libs/flint/fmpz_factor.pxd | 50 +- src/sage/libs/flint/fmpz_lll.pxd | 64 +- src/sage/libs/flint/fmpz_mat.pxd | 328 ++++---- src/sage/libs/flint/fmpz_mod.pxd | 58 +- src/sage/libs/flint/fmpz_mod_mat.pxd | 108 +-- src/sage/libs/flint/fmpz_mod_mpoly.pxd | 288 +++---- src/sage/libs/flint/fmpz_mod_mpoly_factor.pxd | 22 +- src/sage/libs/flint/fmpz_mod_poly.pxd | 464 +++++------ src/sage/libs/flint/fmpz_mod_poly_factor.pxd | 58 +- src/sage/libs/flint/fmpz_mod_vec.pxd | 20 +- src/sage/libs/flint/fmpz_mpoly.pxd | 414 ++++----- src/sage/libs/flint/fmpz_mpoly_factor.pxd | 24 +- src/sage/libs/flint/fmpz_mpoly_q.pxd | 80 +- src/sage/libs/flint/fmpz_poly.pxd | 788 +++++++++--------- src/sage/libs/flint/fmpz_poly_factor.pxd | 32 +- src/sage/libs/flint/fmpz_poly_mat.pxd | 108 +-- src/sage/libs/flint/fmpz_poly_q.pxd | 76 +- src/sage/libs/flint/fmpz_poly_sage.pxd | 12 +- src/sage/libs/flint/fmpz_poly_sage.pyx | 12 +- src/sage/libs/flint/fmpz_vec.pxd | 126 +-- src/sage/libs/flint/fmpzi.pxd | 66 +- src/sage/libs/flint/fq.pxd | 160 ++-- src/sage/libs/flint/fq_default.pxd | 134 +-- src/sage/libs/flint/fq_default_mat.pxd | 106 +-- src/sage/libs/flint/fq_default_poly.pxd | 160 ++-- .../libs/flint/fq_default_poly_factor.pxd | 44 +- src/sage/libs/flint/fq_embed.pxd | 22 +- src/sage/libs/flint/fq_mat.pxd | 132 +-- src/sage/libs/flint/fq_nmod.pxd | 156 ++-- src/sage/libs/flint/fq_nmod_embed.pxd | 22 +- src/sage/libs/flint/fq_nmod_mat.pxd | 132 +-- src/sage/libs/flint/fq_nmod_mpoly.pxd | 226 ++--- src/sage/libs/flint/fq_nmod_mpoly_factor.pxd | 22 +- src/sage/libs/flint/fq_nmod_poly.pxd | 370 ++++---- src/sage/libs/flint/fq_nmod_poly_factor.pxd | 60 +- src/sage/libs/flint/fq_nmod_vec.pxd | 32 +- src/sage/libs/flint/fq_poly.pxd | 374 ++++----- src/sage/libs/flint/fq_poly_factor.pxd | 60 +- src/sage/libs/flint/fq_vec.pxd | 32 +- src/sage/libs/flint/fq_zech.pxd | 164 ++-- src/sage/libs/flint/fq_zech_embed.pxd | 22 +- src/sage/libs/flint/fq_zech_mat.pxd | 122 +-- src/sage/libs/flint/fq_zech_poly.pxd | 362 ++++---- src/sage/libs/flint/fq_zech_poly_factor.pxd | 60 +- src/sage/libs/flint/fq_zech_vec.pxd | 32 +- src/sage/libs/flint/gr.pxd | 312 +++---- src/sage/libs/flint/gr_generic.pxd | 494 +++++------ src/sage/libs/flint/gr_mat.pxd | 288 +++---- src/sage/libs/flint/gr_mpoly.pxd | 104 +-- src/sage/libs/flint/gr_poly.pxd | 524 ++++++------ src/sage/libs/flint/gr_special.pxd | 504 +++++------ src/sage/libs/flint/gr_vec.pxd | 206 ++--- src/sage/libs/flint/hypgeom.pxd | 14 +- src/sage/libs/flint/long_extras.pxd | 12 +- src/sage/libs/flint/mag.pxd | 224 ++--- src/sage/libs/flint/mpf_mat.pxd | 38 +- src/sage/libs/flint/mpf_vec.pxd | 34 +- src/sage/libs/flint/mpfr_mat.pxd | 20 +- src/sage/libs/flint/mpfr_vec.pxd | 16 +- src/sage/libs/flint/mpn_extras.pxd | 48 +- src/sage/libs/flint/mpoly.pxd | 110 +-- src/sage/libs/flint/nf.pxd | 4 +- src/sage/libs/flint/nf_elem.pxd | 114 +-- src/sage/libs/flint/nmod.pxd | 34 +- src/sage/libs/flint/nmod_mat.pxd | 174 ++-- src/sage/libs/flint/nmod_mpoly.pxd | 254 +++--- src/sage/libs/flint/nmod_mpoly_factor.pxd | 22 +- src/sage/libs/flint/nmod_poly.pxd | 652 +++++++-------- src/sage/libs/flint/nmod_poly_factor.pxd | 56 +- src/sage/libs/flint/nmod_poly_mat.pxd | 118 +-- src/sage/libs/flint/nmod_vec.pxd | 46 +- src/sage/libs/flint/padic.pxd | 152 ++-- src/sage/libs/flint/padic_mat.pxd | 94 +-- src/sage/libs/flint/padic_poly.pxd | 142 ++-- src/sage/libs/flint/partitions.pxd | 12 +- src/sage/libs/flint/perm.pxd | 18 +- src/sage/libs/flint/profiler.pxd | 14 +- src/sage/libs/flint/qadic.pxd | 120 +-- src/sage/libs/flint/qfb.pxd | 54 +- src/sage/libs/flint/qqbar.pxd | 310 +++---- src/sage/libs/flint/qsieve.pxd | 48 +- src/sage/libs/flint/thread_pool.pxd | 16 +- src/sage/libs/flint/ulong_extras.pxd | 248 +++--- 132 files changed, 9867 insertions(+), 9870 deletions(-) diff --git a/src/sage/libs/flint/acb.pxd b/src/sage/libs/flint/acb.pxd index 8cd4df5603c..9ed8853dee8 100644 --- a/src/sage/libs/flint/acb.pxd +++ b/src/sage/libs/flint/acb.pxd @@ -12,101 +12,101 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void acb_init(acb_t x) + void acb_init(acb_t x) noexcept # Initializes the variable *x* for use, and sets its value to zero. - void acb_clear(acb_t x) + void acb_clear(acb_t x) noexcept # Clears the variable *x*, freeing or recycling its allocated memory. - acb_ptr _acb_vec_init(slong n) + acb_ptr _acb_vec_init(slong n) noexcept # Returns a pointer to an array of *n* initialized *acb_struct*:s. - void _acb_vec_clear(acb_ptr v, slong n) + void _acb_vec_clear(acb_ptr v, slong n) noexcept # Clears an array of *n* initialized *acb_struct*:s. - slong acb_allocated_bytes(const acb_t x) + slong acb_allocated_bytes(const acb_t x) noexcept # Returns the total number of bytes heap-allocated internally by this object. # The count excludes the size of the structure itself. Add # ``sizeof(acb_struct)`` to get the size of the object as a whole. - slong _acb_vec_allocated_bytes(acb_srcptr vec, slong len) + slong _acb_vec_allocated_bytes(acb_srcptr vec, slong len) noexcept # Returns the total number of bytes allocated for this vector, i.e. the # space taken up by the vector itself plus the sum of the internal heap # allocation sizes for all its member elements. - double _acb_vec_estimate_allocated_bytes(slong len, slong prec) + double _acb_vec_estimate_allocated_bytes(slong len, slong prec) noexcept # Estimates the number of bytes that need to be allocated for a vector of # *len* elements with *prec* bits of precision, including the space for # internal limb data. # See comments for :func:`_arb_vec_estimate_allocated_bytes`. - void acb_zero(acb_t z) + void acb_zero(acb_t z) noexcept - void acb_one(acb_t z) + void acb_one(acb_t z) noexcept - void acb_onei(acb_t z) + void acb_onei(acb_t z) noexcept # Sets *z* respectively to 0, 1, `i = \sqrt{-1}`. - void acb_set(acb_t z, const acb_t x) + void acb_set(acb_t z, const acb_t x) noexcept - void acb_set_ui(acb_t z, ulong x) + void acb_set_ui(acb_t z, ulong x) noexcept - void acb_set_si(acb_t z, slong x) + void acb_set_si(acb_t z, slong x) noexcept - void acb_set_d(acb_t z, double x) + void acb_set_d(acb_t z, double x) noexcept - void acb_set_fmpz(acb_t z, const fmpz_t x) + void acb_set_fmpz(acb_t z, const fmpz_t x) noexcept - void acb_set_arb(acb_t z, const arb_t c) + void acb_set_arb(acb_t z, const arb_t c) noexcept # Sets *z* to the value of *x*. - void acb_set_si_si(acb_t z, slong x, slong y) + void acb_set_si_si(acb_t z, slong x, slong y) noexcept - void acb_set_d_d(acb_t z, double x, double y) + void acb_set_d_d(acb_t z, double x, double y) noexcept - void acb_set_fmpz_fmpz(acb_t z, const fmpz_t x, const fmpz_t y) + void acb_set_fmpz_fmpz(acb_t z, const fmpz_t x, const fmpz_t y) noexcept - void acb_set_arb_arb(acb_t z, const arb_t x, const arb_t y) + void acb_set_arb_arb(acb_t z, const arb_t x, const arb_t y) noexcept # Sets the real and imaginary part of *z* to the values *x* and *y* respectively - void acb_set_fmpq(acb_t z, const fmpq_t x, slong prec) + void acb_set_fmpq(acb_t z, const fmpq_t x, slong prec) noexcept - void acb_set_round(acb_t z, const acb_t x, slong prec) + void acb_set_round(acb_t z, const acb_t x, slong prec) noexcept - void acb_set_round_fmpz(acb_t z, const fmpz_t x, slong prec) + void acb_set_round_fmpz(acb_t z, const fmpz_t x, slong prec) noexcept - void acb_set_round_arb(acb_t z, const arb_t x, slong prec) + void acb_set_round_arb(acb_t z, const arb_t x, slong prec) noexcept # Sets *z* to *x*, rounded to *prec* bits. - void acb_swap(acb_t z, acb_t x) + void acb_swap(acb_t z, acb_t x) noexcept # Swaps *z* and *x* efficiently. - void acb_add_error_arf(acb_t x, const arf_t err) + void acb_add_error_arf(acb_t x, const arf_t err) noexcept - void acb_add_error_mag(acb_t x, const mag_t err) + void acb_add_error_mag(acb_t x, const mag_t err) noexcept - void acb_add_error_arb(acb_t x, const arb_t err) + void acb_add_error_arb(acb_t x, const arb_t err) noexcept # Adds *err* to the error bounds of both the real and imaginary # parts of *x*, modifying *x* in-place. - void acb_get_mid(acb_t m, const acb_t x) + void acb_get_mid(acb_t m, const acb_t x) noexcept # Sets *m* to the midpoint of *x*. - void acb_print(const acb_t x) + void acb_print(const acb_t x) noexcept - void acb_fprint(FILE * file, const acb_t x) + void acb_fprint(FILE * file, const acb_t x) noexcept # Prints the internal representation of *x*. - void acb_printd(const acb_t x, slong digits) + void acb_printd(const acb_t x, slong digits) noexcept - void acb_fprintd(FILE * file, const acb_t x, slong digits) + void acb_fprintd(FILE * file, const acb_t x, slong digits) noexcept # Prints *x* in decimal. The printed value of the radius is not adjusted # to compensate for the fact that the binary-to-decimal conversion # of both the midpoint and the radius introduces additional error. - void acb_printn(const acb_t x, slong digits, ulong flags) + void acb_printn(const acb_t x, slong digits, ulong flags) noexcept - void acb_fprintn(FILE * file, const acb_t x, slong digits, ulong flags) + void acb_fprintn(FILE * file, const acb_t x, slong digits, ulong flags) noexcept # Prints a nice decimal representation of *x*, using the format of # :func:`arb_get_str` (or the corresponding :func:`arb_printn`) for the # real and imaginary parts. @@ -117,40 +117,40 @@ cdef extern from "flint_wrap.h": # Any flags understood by :func:`arb_get_str` can be passed via *flags* # to control the format of the real and imaginary parts. - void acb_randtest(acb_t z, flint_rand_t state, slong prec, slong mag_bits) + void acb_randtest(acb_t z, flint_rand_t state, slong prec, slong mag_bits) noexcept # Generates a random complex number by generating separate random # real and imaginary parts. - void acb_randtest_special(acb_t z, flint_rand_t state, slong prec, slong mag_bits) + void acb_randtest_special(acb_t z, flint_rand_t state, slong prec, slong mag_bits) noexcept # Generates a random complex number by generating separate random # real and imaginary parts. Also generates NaNs and infinities. - void acb_randtest_precise(acb_t z, flint_rand_t state, slong prec, slong mag_bits) + void acb_randtest_precise(acb_t z, flint_rand_t state, slong prec, slong mag_bits) noexcept # Generates a random complex number with precise real and imaginary parts. - void acb_randtest_param(acb_t z, flint_rand_t state, slong prec, slong mag_bits) + void acb_randtest_param(acb_t z, flint_rand_t state, slong prec, slong mag_bits) noexcept # Generates a random complex number, with very high probability of # generating integers and half-integers. - bint acb_is_zero(const acb_t z) + bint acb_is_zero(const acb_t z) noexcept # Returns nonzero iff *z* is zero. - bint acb_is_one(const acb_t z) + bint acb_is_one(const acb_t z) noexcept # Returns nonzero iff *z* is exactly 1. - bint acb_is_finite(const acb_t z) + bint acb_is_finite(const acb_t z) noexcept # Returns nonzero iff *z* certainly is finite. - bint acb_is_exact(const acb_t z) + bint acb_is_exact(const acb_t z) noexcept # Returns nonzero iff *z* is exact. - bint acb_is_int(const acb_t z) + bint acb_is_int(const acb_t z) noexcept # Returns nonzero iff *z* is an exact integer. - bint acb_is_int_2exp_si(const acb_t x, slong e) + bint acb_is_int_2exp_si(const acb_t x, slong e) noexcept # Returns nonzero iff *z* exactly equals `n 2^e` for some integer *n*. - bint acb_equal(const acb_t x, const acb_t y) + bint acb_equal(const acb_t x, const acb_t y) noexcept # Returns nonzero iff *x* and *y* are identical as sets, i.e. # if the real and imaginary parts are equal as balls. # Note that this is not the same thing as testing whether both @@ -160,57 +160,57 @@ cdef extern from "flint_wrap.h": # quantity, use :func:`acb_overlaps` or :func:`acb_contains`, # depending on the circumstance. - bint acb_equal_si(const acb_t x, slong y) + bint acb_equal_si(const acb_t x, slong y) noexcept # Returns nonzero iff *x* is equal to the integer *y*. - bint acb_eq(const acb_t x, const acb_t y) + bint acb_eq(const acb_t x, const acb_t y) noexcept # Returns nonzero iff *x* and *y* are certainly equal, as determined # by testing that :func:`arb_eq` holds for both the real and imaginary # parts. - bint acb_ne(const acb_t x, const acb_t y) + bint acb_ne(const acb_t x, const acb_t y) noexcept # Returns nonzero iff *x* and *y* are certainly not equal, as determined # by testing that :func:`arb_ne` holds for either the real or imaginary parts. - bint acb_overlaps(const acb_t x, const acb_t y) + bint acb_overlaps(const acb_t x, const acb_t y) noexcept # Returns nonzero iff *x* and *y* have some point in common. - void acb_union(acb_t z, const acb_t x, const acb_t y, slong prec) + void acb_union(acb_t z, const acb_t x, const acb_t y, slong prec) noexcept # Sets *z* to a complex interval containing both *x* and *y*. - void acb_get_abs_ubound_arf(arf_t u, const acb_t z, slong prec) + void acb_get_abs_ubound_arf(arf_t u, const acb_t z, slong prec) noexcept # Sets *u* to an upper bound for the absolute value of *z*, computed # using a working precision of *prec* bits. - void acb_get_abs_lbound_arf(arf_t u, const acb_t z, slong prec) + void acb_get_abs_lbound_arf(arf_t u, const acb_t z, slong prec) noexcept # Sets *u* to a lower bound for the absolute value of *z*, computed # using a working precision of *prec* bits. - void acb_get_rad_ubound_arf(arf_t u, const acb_t z, slong prec) + void acb_get_rad_ubound_arf(arf_t u, const acb_t z, slong prec) noexcept # Sets *u* to an upper bound for the error radius of *z* (the value # is currently not computed tightly). - void acb_get_mag(mag_t u, const acb_t x) + void acb_get_mag(mag_t u, const acb_t x) noexcept # Sets *u* to an upper bound for the absolute value of *x*. - void acb_get_mag_lower(mag_t u, const acb_t x) + void acb_get_mag_lower(mag_t u, const acb_t x) noexcept # Sets *u* to a lower bound for the absolute value of *x*. - bint acb_contains_fmpq(const acb_t x, const fmpq_t y) + bint acb_contains_fmpq(const acb_t x, const fmpq_t y) noexcept - bint acb_contains_fmpz(const acb_t x, const fmpz_t y) + bint acb_contains_fmpz(const acb_t x, const fmpz_t y) noexcept - bint acb_contains(const acb_t x, const acb_t y) + bint acb_contains(const acb_t x, const acb_t y) noexcept # Returns nonzero iff *y* is contained in *x*. - bint acb_contains_zero(const acb_t x) + bint acb_contains_zero(const acb_t x) noexcept # Returns nonzero iff zero is contained in *x*. - bint acb_contains_int(const acb_t x) + bint acb_contains_int(const acb_t x) noexcept # Returns nonzero iff the complex interval represented by *x* contains # an integer. - bint acb_contains_interior(const acb_t x, const acb_t y) + bint acb_contains_interior(const acb_t x, const acb_t y) noexcept # Tests if *y* is contained in the interior of *x*. # This predicate always evaluates to false if *x* and *y* are both # real-valued, since an imaginary part of 0 is not considered contained in @@ -219,51 +219,51 @@ cdef extern from "flint_wrap.h": # Such intervals must be handled specially by the user where a different # interpretation is intended. - slong acb_rel_error_bits(const acb_t x) + slong acb_rel_error_bits(const acb_t x) noexcept # Returns the effective relative error of *x* measured in bits. # This is computed as if calling :func:`arb_rel_error_bits` on the # real ball whose midpoint is the larger out of the real and imaginary # midpoints of *x*, and whose radius is the larger out of the real # and imaginary radiuses of *x*. - slong acb_rel_accuracy_bits(const acb_t x) + slong acb_rel_accuracy_bits(const acb_t x) noexcept # Returns the effective relative accuracy of *x* measured in bits, # equal to the negative of the return value from :func:`acb_rel_error_bits`. - slong acb_rel_one_accuracy_bits(const acb_t x) + slong acb_rel_one_accuracy_bits(const acb_t x) noexcept # Given a ball with midpoint *m* and radius *r*, returns an approximation of # the relative accuracy of `[\max(1,|m|) \pm r]` measured in bits. - slong acb_bits(const acb_t x) + slong acb_bits(const acb_t x) noexcept # Returns the maximum of *arb_bits* applied to the real # and imaginary parts of *x*, i.e. the minimum precision sufficient # to represent *x* exactly. - void acb_indeterminate(acb_t x) + void acb_indeterminate(acb_t x) noexcept # Sets *x* to # `[\operatorname{NaN} \pm \infty] + [\operatorname{NaN} \pm \infty]i`, # representing an indeterminate result. - void acb_trim(acb_t y, const acb_t x) + void acb_trim(acb_t y, const acb_t x) noexcept # Sets *y* to a a copy of *x* with both the real and imaginary # parts trimmed (see :func:`arb_trim`). - bint acb_is_real(const acb_t x) + bint acb_is_real(const acb_t x) noexcept # Returns nonzero iff the imaginary part of *x* is zero. # It does not test whether the real part of *x* also is finite. - int acb_get_unique_fmpz(fmpz_t z, const acb_t x) + int acb_get_unique_fmpz(fmpz_t z, const acb_t x) noexcept # If *x* contains a unique integer, sets *z* to that value and returns # nonzero. Otherwise (if *x* represents no integers or more than one integer), # returns zero. - void acb_get_real(arb_t re, const acb_t z) + void acb_get_real(arb_t re, const acb_t z) noexcept # Sets *re* to the real part of *z*. - void acb_get_imag(arb_t im, const acb_t z) + void acb_get_imag(arb_t im, const acb_t z) noexcept # Sets *im* to the imaginary part of *z*. - void acb_arg(arb_t r, const acb_t z, slong prec) + void acb_arg(arb_t r, const acb_t z, slong prec) noexcept # Sets *r* to a real interval containing the complex argument (phase) of *z*. # We define the complex argument have a discontinuity on `(-\infty,0]`, with # the special value `\operatorname{arg}(0) = 0`, and @@ -271,122 +271,122 @@ cdef extern from "flint_wrap.h": # `z = a+bi`, the argument is given by `\operatorname{atan2}(b,a)` # (see :func:`arb_atan2`). - void acb_abs(arb_t r, const acb_t z, slong prec) + void acb_abs(arb_t r, const acb_t z, slong prec) noexcept # Sets *r* to the absolute value of *z*. - void acb_sgn(acb_t r, const acb_t z, slong prec) + void acb_sgn(acb_t r, const acb_t z, slong prec) noexcept # Sets *r* to the complex sign of *z*, defined as 0 if *z* is exactly zero # and the projection onto the unit circle `z / |z| = \exp(i \arg(z))` otherwise. - void acb_csgn(arb_t r, const acb_t z) + void acb_csgn(arb_t r, const acb_t z) noexcept # Sets *r* to the extension of the real sign function taking the # value 1 for *z* strictly in the right half plane, -1 for *z* strictly # in the left half plane, and the sign of the imaginary part when *z* is on # the imaginary axis. Equivalently, `\operatorname{csgn}(z) = z / \sqrt{z^2}` # except that the value is 0 when *z* is exactly zero. - void acb_neg(acb_t z, const acb_t x) + void acb_neg(acb_t z, const acb_t x) noexcept - void acb_neg_round(acb_t z, const acb_t x, slong prec) + void acb_neg_round(acb_t z, const acb_t x, slong prec) noexcept # Sets *z* to the negation of *x*. - void acb_conj(acb_t z, const acb_t x) + void acb_conj(acb_t z, const acb_t x) noexcept # Sets *z* to the complex conjugate of *x*. - void acb_add_ui(acb_t z, const acb_t x, ulong y, slong prec) + void acb_add_ui(acb_t z, const acb_t x, ulong y, slong prec) noexcept - void acb_add_si(acb_t z, const acb_t x, slong y, slong prec) + void acb_add_si(acb_t z, const acb_t x, slong y, slong prec) noexcept - void acb_add_fmpz(acb_t z, const acb_t x, const fmpz_t y, slong prec) + void acb_add_fmpz(acb_t z, const acb_t x, const fmpz_t y, slong prec) noexcept - void acb_add_arb(acb_t z, const acb_t x, const arb_t y, slong prec) + void acb_add_arb(acb_t z, const acb_t x, const arb_t y, slong prec) noexcept - void acb_add(acb_t z, const acb_t x, const acb_t y, slong prec) + void acb_add(acb_t z, const acb_t x, const acb_t y, slong prec) noexcept # Sets *z* to the sum of *x* and *y*. - void acb_sub_ui(acb_t z, const acb_t x, ulong y, slong prec) + void acb_sub_ui(acb_t z, const acb_t x, ulong y, slong prec) noexcept - void acb_sub_si(acb_t z, const acb_t x, slong y, slong prec) + void acb_sub_si(acb_t z, const acb_t x, slong y, slong prec) noexcept - void acb_sub_fmpz(acb_t z, const acb_t x, const fmpz_t y, slong prec) + void acb_sub_fmpz(acb_t z, const acb_t x, const fmpz_t y, slong prec) noexcept - void acb_sub_arb(acb_t z, const acb_t x, const arb_t y, slong prec) + void acb_sub_arb(acb_t z, const acb_t x, const arb_t y, slong prec) noexcept - void acb_sub(acb_t z, const acb_t x, const acb_t y, slong prec) + void acb_sub(acb_t z, const acb_t x, const acb_t y, slong prec) noexcept # Sets *z* to the difference of *x* and *y*. - void acb_mul_onei(acb_t z, const acb_t x) + void acb_mul_onei(acb_t z, const acb_t x) noexcept # Sets *z* to *x* multiplied by the imaginary unit. - void acb_div_onei(acb_t z, const acb_t x) + void acb_div_onei(acb_t z, const acb_t x) noexcept # Sets *z* to *x* divided by the imaginary unit. - void acb_mul_ui(acb_t z, const acb_t x, ulong y, slong prec) + void acb_mul_ui(acb_t z, const acb_t x, ulong y, slong prec) noexcept - void acb_mul_si(acb_t z, const acb_t x, slong y, slong prec) + void acb_mul_si(acb_t z, const acb_t x, slong y, slong prec) noexcept - void acb_mul_fmpz(acb_t z, const acb_t x, const fmpz_t y, slong prec) + void acb_mul_fmpz(acb_t z, const acb_t x, const fmpz_t y, slong prec) noexcept - void acb_mul_arb(acb_t z, const acb_t x, const arb_t y, slong prec) + void acb_mul_arb(acb_t z, const acb_t x, const arb_t y, slong prec) noexcept # Sets *z* to the product of *x* and *y*. - void acb_mul(acb_t z, const acb_t x, const acb_t y, slong prec) + void acb_mul(acb_t z, const acb_t x, const acb_t y, slong prec) noexcept # Sets *z* to the product of *x* and *y*. If at least one part of # *x* or *y* is zero, the operations is reduced to two real multiplications. # If *x* and *y* are the same pointers, they are assumed to represent # the same mathematical quantity and the squaring formula is used. - void acb_mul_2exp_si(acb_t z, const acb_t x, slong e) + void acb_mul_2exp_si(acb_t z, const acb_t x, slong e) noexcept - void acb_mul_2exp_fmpz(acb_t z, const acb_t x, const fmpz_t e) + void acb_mul_2exp_fmpz(acb_t z, const acb_t x, const fmpz_t e) noexcept # Sets *z* to *x* multiplied by `2^e`, without rounding. - void acb_sqr(acb_t z, const acb_t x, slong prec) + void acb_sqr(acb_t z, const acb_t x, slong prec) noexcept # Sets *z* to *x* squared. - void acb_cube(acb_t z, const acb_t x, slong prec) + void acb_cube(acb_t z, const acb_t x, slong prec) noexcept # Sets *z* to *x* cubed, computed efficiently using two real squarings, # two real multiplications, and scalar operations. - void acb_addmul(acb_t z, const acb_t x, const acb_t y, slong prec) + void acb_addmul(acb_t z, const acb_t x, const acb_t y, slong prec) noexcept - void acb_addmul_ui(acb_t z, const acb_t x, ulong y, slong prec) + void acb_addmul_ui(acb_t z, const acb_t x, ulong y, slong prec) noexcept - void acb_addmul_si(acb_t z, const acb_t x, slong y, slong prec) + void acb_addmul_si(acb_t z, const acb_t x, slong y, slong prec) noexcept - void acb_addmul_fmpz(acb_t z, const acb_t x, const fmpz_t y, slong prec) + void acb_addmul_fmpz(acb_t z, const acb_t x, const fmpz_t y, slong prec) noexcept - void acb_addmul_arb(acb_t z, const acb_t x, const arb_t y, slong prec) + void acb_addmul_arb(acb_t z, const acb_t x, const arb_t y, slong prec) noexcept # Sets *z* to *z* plus the product of *x* and *y*. - void acb_submul(acb_t z, const acb_t x, const acb_t y, slong prec) + void acb_submul(acb_t z, const acb_t x, const acb_t y, slong prec) noexcept - void acb_submul_ui(acb_t z, const acb_t x, ulong y, slong prec) + void acb_submul_ui(acb_t z, const acb_t x, ulong y, slong prec) noexcept - void acb_submul_si(acb_t z, const acb_t x, slong y, slong prec) + void acb_submul_si(acb_t z, const acb_t x, slong y, slong prec) noexcept - void acb_submul_fmpz(acb_t z, const acb_t x, const fmpz_t y, slong prec) + void acb_submul_fmpz(acb_t z, const acb_t x, const fmpz_t y, slong prec) noexcept - void acb_submul_arb(acb_t z, const acb_t x, const arb_t y, slong prec) + void acb_submul_arb(acb_t z, const acb_t x, const arb_t y, slong prec) noexcept # Sets *z* to *z* minus the product of *x* and *y*. - void acb_inv(acb_t z, const acb_t x, slong prec) + void acb_inv(acb_t z, const acb_t x, slong prec) noexcept # Sets *z* to the multiplicative inverse of *x*. - void acb_div_ui(acb_t z, const acb_t x, ulong y, slong prec) + void acb_div_ui(acb_t z, const acb_t x, ulong y, slong prec) noexcept - void acb_div_si(acb_t z, const acb_t x, slong y, slong prec) + void acb_div_si(acb_t z, const acb_t x, slong y, slong prec) noexcept - void acb_div_fmpz(acb_t z, const acb_t x, const fmpz_t y, slong prec) + void acb_div_fmpz(acb_t z, const acb_t x, const fmpz_t y, slong prec) noexcept - void acb_div_arb(acb_t z, const acb_t x, const arb_t y, slong prec) + void acb_div_arb(acb_t z, const acb_t x, const arb_t y, slong prec) noexcept - void acb_div(acb_t z, const acb_t x, const acb_t y, slong prec) + void acb_div(acb_t z, const acb_t x, const acb_t y, slong prec) noexcept # Sets *z* to the quotient of *x* and *y*. - void acb_dot_precise(acb_t res, const acb_t s, int subtract, acb_srcptr x, slong xstep, acb_srcptr y, slong ystep, slong len, slong prec) - void acb_dot_simple(acb_t res, const acb_t s, int subtract, acb_srcptr x, slong xstep, acb_srcptr y, slong ystep, slong len, slong prec) - void acb_dot(acb_t res, const acb_t s, int subtract, acb_srcptr x, slong xstep, acb_srcptr y, slong ystep, slong len, slong prec) + void acb_dot_precise(acb_t res, const acb_t s, int subtract, acb_srcptr x, slong xstep, acb_srcptr y, slong ystep, slong len, slong prec) noexcept + void acb_dot_simple(acb_t res, const acb_t s, int subtract, acb_srcptr x, slong xstep, acb_srcptr y, slong ystep, slong len, slong prec) noexcept + void acb_dot(acb_t res, const acb_t s, int subtract, acb_srcptr x, slong xstep, acb_srcptr y, slong ystep, slong len, slong prec) noexcept # Computes the dot product of the vectors *x* and *y*, setting # *res* to `s + (-1)^{subtract} \sum_{i=0}^{len-1} x_i y_i`. # The initial term *s* is optional and can be @@ -414,206 +414,206 @@ cdef extern from "flint_wrap.h": # final rounding. This can be extremely slow and is only intended # for testing. - void acb_approx_dot(acb_t res, const acb_t s, int subtract, acb_srcptr x, slong xstep, acb_srcptr y, slong ystep, slong len, slong prec) + void acb_approx_dot(acb_t res, const acb_t s, int subtract, acb_srcptr x, slong xstep, acb_srcptr y, slong ystep, slong len, slong prec) noexcept # Computes an approximate dot product *without error bounds*. # The radii of the inputs are ignored (only the midpoints are read) # and only the midpoint of the output is written. - void acb_dot_ui(acb_t res, const acb_t initial, int subtract, acb_srcptr x, slong xstep, const ulong * y, slong ystep, slong len, slong prec) - void acb_dot_si(acb_t res, const acb_t initial, int subtract, acb_srcptr x, slong xstep, const slong * y, slong ystep, slong len, slong prec) - void acb_dot_uiui(acb_t res, const acb_t initial, int subtract, acb_srcptr x, slong xstep, const ulong * y, slong ystep, slong len, slong prec) - void acb_dot_siui(acb_t res, const acb_t initial, int subtract, acb_srcptr x, slong xstep, const ulong * y, slong ystep, slong len, slong prec) - void acb_dot_fmpz(acb_t res, const acb_t initial, int subtract, acb_srcptr x, slong xstep, const fmpz * y, slong ystep, slong len, slong prec) + void acb_dot_ui(acb_t res, const acb_t initial, int subtract, acb_srcptr x, slong xstep, const ulong * y, slong ystep, slong len, slong prec) noexcept + void acb_dot_si(acb_t res, const acb_t initial, int subtract, acb_srcptr x, slong xstep, const slong * y, slong ystep, slong len, slong prec) noexcept + void acb_dot_uiui(acb_t res, const acb_t initial, int subtract, acb_srcptr x, slong xstep, const ulong * y, slong ystep, slong len, slong prec) noexcept + void acb_dot_siui(acb_t res, const acb_t initial, int subtract, acb_srcptr x, slong xstep, const ulong * y, slong ystep, slong len, slong prec) noexcept + void acb_dot_fmpz(acb_t res, const acb_t initial, int subtract, acb_srcptr x, slong xstep, const fmpz * y, slong ystep, slong len, slong prec) noexcept # Equivalent to :func:`acb_dot`, but with integers in the array *y*. # The *uiui* and *siui* versions take an array of double-limb integers # as input; the *siui* version assumes that these represent signed # integers in two's complement form. - void acb_const_pi(acb_t y, slong prec) + void acb_const_pi(acb_t y, slong prec) noexcept # Sets *y* to the constant `\pi`. - void acb_sqrt(acb_t r, const acb_t z, slong prec) + void acb_sqrt(acb_t r, const acb_t z, slong prec) noexcept # Sets *r* to the square root of *z*. # If either the real or imaginary part is exactly zero, only # a single real square root is needed. Generally, we use the formula # `\sqrt{a+bi} = u/2 + ib/u, u = \sqrt{2(|a+bi|+a)}`, # requiring two real square root extractions. - void acb_sqrt_analytic(acb_t r, const acb_t z, int analytic, slong prec) + void acb_sqrt_analytic(acb_t r, const acb_t z, int analytic, slong prec) noexcept # Computes the square root. If *analytic* is set, gives a NaN-containing # result if *z* touches the branch cut. - void acb_rsqrt(acb_t r, const acb_t z, slong prec) + void acb_rsqrt(acb_t r, const acb_t z, slong prec) noexcept # Sets *r* to the reciprocal square root of *z*. # If either the real or imaginary part is exactly zero, only # a single real reciprocal square root is needed. Generally, we use the # formula `1/\sqrt{a+bi} = ((a+r) - bi)/v, r = |a+bi|, v = \sqrt{r |a+bi+r|^2}`, # requiring one real square root and one real reciprocal square root. - void acb_rsqrt_analytic(acb_t r, const acb_t z, int analytic, slong prec) + void acb_rsqrt_analytic(acb_t r, const acb_t z, int analytic, slong prec) noexcept # Computes the reciprocal square root. If *analytic* is set, gives a # NaN-containing result if *z* touches the branch cut. - void acb_quadratic_roots_fmpz(acb_t r1, acb_t r2, const fmpz_t a, const fmpz_t b, const fmpz_t c, slong prec) + void acb_quadratic_roots_fmpz(acb_t r1, acb_t r2, const fmpz_t a, const fmpz_t b, const fmpz_t c, slong prec) noexcept # Sets *r1* and *r2* to the roots of the quadratic polynomial # `ax^2 + bx + c`. Requires that *a* is nonzero. # This function is implemented so that both roots are computed accurately # even when direct use of the quadratic formula would lose accuracy. - void acb_root_ui(acb_t r, const acb_t z, ulong k, slong prec) + void acb_root_ui(acb_t r, const acb_t z, ulong k, slong prec) noexcept # Sets *r* to the principal *k*-th root of *z*. - void acb_pow_fmpz(acb_t y, const acb_t b, const fmpz_t e, slong prec) + void acb_pow_fmpz(acb_t y, const acb_t b, const fmpz_t e, slong prec) noexcept - void acb_pow_ui(acb_t y, const acb_t b, ulong e, slong prec) + void acb_pow_ui(acb_t y, const acb_t b, ulong e, slong prec) noexcept - void acb_pow_si(acb_t y, const acb_t b, slong e, slong prec) + void acb_pow_si(acb_t y, const acb_t b, slong e, slong prec) noexcept # Sets `y = b^e` using binary exponentiation (with an initial division # if `e < 0`). Note that these functions can get slow if the exponent is # extremely large (in such cases :func:`acb_pow` may be superior). - void acb_pow_arb(acb_t z, const acb_t x, const arb_t y, slong prec) + void acb_pow_arb(acb_t z, const acb_t x, const arb_t y, slong prec) noexcept - void acb_pow(acb_t z, const acb_t x, const acb_t y, slong prec) + void acb_pow(acb_t z, const acb_t x, const acb_t y, slong prec) noexcept # Sets `z = x^y`, computed using binary exponentiation if `y` if # a small exact integer, as `z = (x^{1/2})^{2y}` if `y` is a small exact # half-integer, and generally as `z = \exp(y \log x)`. - void acb_pow_analytic(acb_t r, const acb_t x, const acb_t y, int analytic, slong prec) + void acb_pow_analytic(acb_t r, const acb_t x, const acb_t y, int analytic, slong prec) noexcept # Computes the power `x^y`. If *analytic* is set, gives a # NaN-containing result if *x* touches the branch cut (unless *y* is # an integer). - void acb_unit_root(acb_t res, ulong order, slong prec) + void acb_unit_root(acb_t res, ulong order, slong prec) noexcept # Sets *res* to `\exp(\frac{2i\pi}{\mathrm{order}})` to precision *prec*. - void acb_exp(acb_t y, const acb_t z, slong prec) + void acb_exp(acb_t y, const acb_t z, slong prec) noexcept # Sets *y* to the exponential function of *z*, computed as # `\exp(a+bi) = \exp(a) \left( \cos(b) + \sin(b) i \right)`. - void acb_exp_pi_i(acb_t y, const acb_t z, slong prec) + void acb_exp_pi_i(acb_t y, const acb_t z, slong prec) noexcept # Sets *y* to `\exp(\pi i z)`. - void acb_exp_invexp(acb_t s, acb_t t, const acb_t z, slong prec) + void acb_exp_invexp(acb_t s, acb_t t, const acb_t z, slong prec) noexcept # Sets `s = \exp(z)` and `t = \exp(-z)`. - void acb_expm1(acb_t res, const acb_t z, slong prec) + void acb_expm1(acb_t res, const acb_t z, slong prec) noexcept # Sets *res* to `\exp(z)-1`, using a more accurate method when `z \approx 0`. - void acb_log(acb_t y, const acb_t z, slong prec) + void acb_log(acb_t y, const acb_t z, slong prec) noexcept # Sets *y* to the principal branch of the natural logarithm of *z*, # computed as # `\log(a+bi) = \frac{1}{2} \log(a^2 + b^2) + i \operatorname{arg}(a+bi)`. - void acb_log_analytic(acb_t r, const acb_t z, int analytic, slong prec) + void acb_log_analytic(acb_t r, const acb_t z, int analytic, slong prec) noexcept # Computes the natural logarithm. If *analytic* is set, gives a # NaN-containing result if *z* touches the branch cut. - void acb_log1p(acb_t z, const acb_t x, slong prec) + void acb_log1p(acb_t z, const acb_t x, slong prec) noexcept # Sets `z = \log(1+x)`, computed accurately when `x \approx 0`. - void acb_sin(acb_t s, const acb_t z, slong prec) + void acb_sin(acb_t s, const acb_t z, slong prec) noexcept - void acb_cos(acb_t c, const acb_t z, slong prec) + void acb_cos(acb_t c, const acb_t z, slong prec) noexcept - void acb_sin_cos(acb_t s, acb_t c, const acb_t z, slong prec) + void acb_sin_cos(acb_t s, acb_t c, const acb_t z, slong prec) noexcept # Sets `s = \sin(z)`, `c = \cos(z)`, evaluated as # `\sin(a+bi) = \sin(a)\cosh(b) + i \cos(a)\sinh(b)`, # `\cos(a+bi) = \cos(a)\cosh(b) - i \sin(a)\sinh(b)`. - void acb_tan(acb_t s, const acb_t z, slong prec) + void acb_tan(acb_t s, const acb_t z, slong prec) noexcept # Sets `s = \tan(z) = \sin(z) / \cos(z)`. For large imaginary parts, # the function is evaluated in a numerically stable way as `\pm i` # plus a decreasing exponential factor. - void acb_cot(acb_t s, const acb_t z, slong prec) + void acb_cot(acb_t s, const acb_t z, slong prec) noexcept # Sets `s = \cot(z) = \cos(z) / \sin(z)`. For large imaginary parts, # the function is evaluated in a numerically stable way as `\pm i` # plus a decreasing exponential factor. - void acb_sin_pi(acb_t s, const acb_t z, slong prec) + void acb_sin_pi(acb_t s, const acb_t z, slong prec) noexcept - void acb_cos_pi(acb_t s, const acb_t z, slong prec) + void acb_cos_pi(acb_t s, const acb_t z, slong prec) noexcept - void acb_sin_cos_pi(acb_t s, acb_t c, const acb_t z, slong prec) + void acb_sin_cos_pi(acb_t s, acb_t c, const acb_t z, slong prec) noexcept # Sets `s = \sin(\pi z)`, `c = \cos(\pi z)`, evaluating the trigonometric # factors of the real and imaginary part accurately via :func:`arb_sin_cos_pi`. - void acb_tan_pi(acb_t s, const acb_t z, slong prec) + void acb_tan_pi(acb_t s, const acb_t z, slong prec) noexcept # Sets `s = \tan(\pi z)`. Uses the same algorithm as :func:`acb_tan`, # but evaluates the sine and cosine accurately via :func:`arb_sin_cos_pi`. - void acb_cot_pi(acb_t s, const acb_t z, slong prec) + void acb_cot_pi(acb_t s, const acb_t z, slong prec) noexcept # Sets `s = \cot(\pi z)`. Uses the same algorithm as :func:`acb_cot`, # but evaluates the sine and cosine accurately via :func:`arb_sin_cos_pi`. - void acb_sec(acb_t res, const acb_t z, slong prec) + void acb_sec(acb_t res, const acb_t z, slong prec) noexcept # Computes `\sec(z) = 1 / \cos(z)`. - void acb_csc(acb_t res, const acb_t z, slong prec) + void acb_csc(acb_t res, const acb_t z, slong prec) noexcept # Computes `\csc(x) = 1 / \sin(z)`. - void acb_csc_pi(acb_t res, const acb_t z, slong prec) + void acb_csc_pi(acb_t res, const acb_t z, slong prec) noexcept # Computes `\csc(\pi x) = 1 / \sin(\pi z)`. Evaluates the sine accurately # via :func:`acb_sin_pi`. - void acb_sinc(acb_t s, const acb_t z, slong prec) + void acb_sinc(acb_t s, const acb_t z, slong prec) noexcept # Sets `s = \operatorname{sinc}(x) = \sin(z) / z`. - void acb_sinc_pi(acb_t s, const acb_t z, slong prec) + void acb_sinc_pi(acb_t s, const acb_t z, slong prec) noexcept # Sets `s = \operatorname{sinc}(\pi x) = \sin(\pi z) / (\pi z)`. - void acb_asin(acb_t res, const acb_t z, slong prec) + void acb_asin(acb_t res, const acb_t z, slong prec) noexcept # Sets *res* to `\operatorname{asin}(z) = -i \log(iz + \sqrt{1-z^2})`. - void acb_acos(acb_t res, const acb_t z, slong prec) + void acb_acos(acb_t res, const acb_t z, slong prec) noexcept # Sets *res* to `\operatorname{acos}(z) = \tfrac{1}{2} \pi - \operatorname{asin}(z)`. - void acb_atan(acb_t res, const acb_t z, slong prec) + void acb_atan(acb_t res, const acb_t z, slong prec) noexcept # Sets *res* to `\operatorname{atan}(z) = \tfrac{1}{2} i (\log(1-iz)-\log(1+iz))`. - void acb_sinh(acb_t s, const acb_t z, slong prec) + void acb_sinh(acb_t s, const acb_t z, slong prec) noexcept - void acb_cosh(acb_t c, const acb_t z, slong prec) + void acb_cosh(acb_t c, const acb_t z, slong prec) noexcept - void acb_sinh_cosh(acb_t s, acb_t c, const acb_t z, slong prec) + void acb_sinh_cosh(acb_t s, acb_t c, const acb_t z, slong prec) noexcept - void acb_tanh(acb_t s, const acb_t z, slong prec) + void acb_tanh(acb_t s, const acb_t z, slong prec) noexcept - void acb_coth(acb_t s, const acb_t z, slong prec) + void acb_coth(acb_t s, const acb_t z, slong prec) noexcept # Respectively computes `\sinh(z) = -i\sin(iz)`, `\cosh(z) = \cos(iz)`, # `\tanh(z) = -i\tan(iz)`, `\coth(z) = i\cot(iz)`. - void acb_sech(acb_t res, const acb_t z, slong prec) + void acb_sech(acb_t res, const acb_t z, slong prec) noexcept # Computes `\operatorname{sech}(z) = 1 / \cosh(z)`. - void acb_csch(acb_t res, const acb_t z, slong prec) + void acb_csch(acb_t res, const acb_t z, slong prec) noexcept # Computes `\operatorname{csch}(z) = 1 / \sinh(z)`. - void acb_asinh(acb_t res, const acb_t z, slong prec) + void acb_asinh(acb_t res, const acb_t z, slong prec) noexcept # Sets *res* to `\operatorname{asinh}(z) = -i \operatorname{asin}(iz)`. - void acb_acosh(acb_t res, const acb_t z, slong prec) + void acb_acosh(acb_t res, const acb_t z, slong prec) noexcept # Sets *res* to `\operatorname{acosh}(z) = \log(z + \sqrt{z+1} \sqrt{z-1})`. - void acb_atanh(acb_t res, const acb_t z, slong prec) + void acb_atanh(acb_t res, const acb_t z, slong prec) noexcept # Sets *res* to `\operatorname{atanh}(z) = -i \operatorname{atan}(iz)`. - void acb_lambertw_asymp(acb_t res, const acb_t z, const fmpz_t k, slong L, slong M, slong prec) + void acb_lambertw_asymp(acb_t res, const acb_t z, const fmpz_t k, slong L, slong M, slong prec) noexcept # Sets *res* to the Lambert W function `W_k(z)` computed using *L* and *M* # terms in the bivariate series giving the asymptotic expansion at # zero or infinity. This algorithm is valid # everywhere, but the error bound is only finite when `|\log(z)|` is # sufficiently large. - int acb_lambertw_check_branch(const acb_t w, const fmpz_t k, slong prec) + int acb_lambertw_check_branch(const acb_t w, const fmpz_t k, slong prec) noexcept # Tests if *w* definitely lies in the image of the branch `W_k(z)`. # This function is used internally to verify that a computed approximation # of the Lambert W function lies on the intended branch. Note that this will # necessarily evaluate to false for points exactly on (or overlapping) the # branch cuts, where a different algorithm has to be used. - void acb_lambertw_bound_deriv(mag_t res, const acb_t z, const acb_t ez1, const fmpz_t k) + void acb_lambertw_bound_deriv(mag_t res, const acb_t z, const acb_t ez1, const fmpz_t k) noexcept # Sets *res* to an upper bound for `|W_k'(z)|`. The input *ez1* should # contain the precomputed value of `ez+1`. # Along the real line, the directional derivative of `W_k(z)` is understood @@ -621,7 +621,7 @@ cdef extern from "flint_wrap.h": # discontinuity separately when using this function to bound perturbations # in the value of `W_k(z)`. - void acb_lambertw(acb_t res, const acb_t z, const fmpz_t k, int flags, slong prec) + void acb_lambertw(acb_t res, const acb_t z, const fmpz_t k, int flags, slong prec) noexcept # Sets *res* to the Lambert W function `W_k(z)` where the index *k* selects # the branch (with `k = 0` giving the principal branch). # The placement of branch cuts follows [CGHJK1996]_. @@ -646,22 +646,22 @@ cdef extern from "flint_wrap.h": # The algorithm used to compute the Lambert W function is described # in [Joh2017b]_. - void acb_rising_ui(acb_t z, const acb_t x, ulong n, slong prec) - void acb_rising(acb_t z, const acb_t x, const acb_t n, slong prec) + void acb_rising_ui(acb_t z, const acb_t x, ulong n, slong prec) noexcept + void acb_rising(acb_t z, const acb_t x, const acb_t n, slong prec) noexcept # Computes the rising factorial `z = x (x+1) (x+2) \cdots (x+n-1)`. # These functions are aliases for :func:`acb_hypgeom_rising_ui` # and :func:`acb_hypgeom_rising`. - void acb_gamma(acb_t y, const acb_t x, slong prec) + void acb_gamma(acb_t y, const acb_t x, slong prec) noexcept # Computes the gamma function `y = \Gamma(x)`. # This is an alias for :func:`acb_hypgeom_gamma`. - void acb_rgamma(acb_t y, const acb_t x, slong prec) + void acb_rgamma(acb_t y, const acb_t x, slong prec) noexcept # Computes the reciprocal gamma function `y = 1/\Gamma(x)`, # avoiding division by zero at the poles of the gamma function. # This is an alias for :func:`acb_hypgeom_rgamma`. - void acb_lgamma(acb_t y, const acb_t x, slong prec) + void acb_lgamma(acb_t y, const acb_t x, slong prec) noexcept # Computes the logarithmic gamma function `y = \log \Gamma(x)`. # This is an alias for :func:`acb_hypgeom_lgamma`. # The branch cut of the logarithmic gamma function is placed on the @@ -671,10 +671,10 @@ cdef extern from "flint_wrap.h": # In the left half plane, the reflection formula with correct # branch structure is evaluated via :func:`acb_log_sin_pi`. - void acb_digamma(acb_t y, const acb_t x, slong prec) + void acb_digamma(acb_t y, const acb_t x, slong prec) noexcept # Computes the digamma function `y = \psi(x) = (\log \Gamma(x))' = \Gamma'(x) / \Gamma(x)`. - void acb_log_sin_pi(acb_t res, const acb_t z, slong prec) + void acb_log_sin_pi(acb_t res, const acb_t z, slong prec) noexcept # Computes the logarithmic sine function defined by # .. math :: # S(z) = \log(\pi) - \log \Gamma(z) + \log \Gamma(1-z) @@ -700,7 +700,7 @@ cdef extern from "flint_wrap.h": # is computed from `S'(z)` to get a continuous change # when `z` is non-real and `n` spans more than one possible integer value. - void acb_polygamma(acb_t res, const acb_t s, const acb_t z, slong prec) + void acb_polygamma(acb_t res, const acb_t s, const acb_t z, slong prec) noexcept # Sets *res* to the value of the generalized polygamma function `\psi(s,z)`. # If *s* is a nonnegative order, this is simply the *s*-order derivative # of the digamma function. If `s = 0`, this function simply @@ -713,9 +713,9 @@ cdef extern from "flint_wrap.h": # .. math :: # \psi(s,z) = \frac{\zeta'(s+1,z) + (\gamma + \psi(-s)) \zeta(s+1,z)}{\Gamma(-s)} - void acb_barnes_g(acb_t res, const acb_t z, slong prec) + void acb_barnes_g(acb_t res, const acb_t z, slong prec) noexcept - void acb_log_barnes_g(acb_t res, const acb_t z, slong prec) + void acb_log_barnes_g(acb_t res, const acb_t z, slong prec) noexcept # Computes Barnes *G*-function or the logarithmic Barnes *G*-function, # respectively. The logarithmic version has branch cuts on the negative # real axis and is continuous elsewhere in the complex plane, @@ -730,42 +730,42 @@ cdef extern from "flint_wrap.h": # .. math :: # \log G(z) = (z-1) \log \Gamma(z) - \zeta'(-1,z) + \zeta'(-1). - void acb_zeta(acb_t z, const acb_t s, slong prec) + void acb_zeta(acb_t z, const acb_t s, slong prec) noexcept # Sets *z* to the value of the Riemann zeta function `\zeta(s)`. # Note: for computing derivatives with respect to `s`, # use :func:`acb_poly_zeta_series` or related methods. # This is a wrapper of :func:`acb_dirichlet_zeta`. - void acb_hurwitz_zeta(acb_t z, const acb_t s, const acb_t a, slong prec) + void acb_hurwitz_zeta(acb_t z, const acb_t s, const acb_t a, slong prec) noexcept # Sets *z* to the value of the Hurwitz zeta function `\zeta(s, a)`. # Note: for computing derivatives with respect to `s`, # use :func:`acb_poly_zeta_series` or related methods. # This is a wrapper of :func:`acb_dirichlet_hurwitz`. - void acb_bernoulli_poly_ui(acb_t res, ulong n, const acb_t x, slong prec) + void acb_bernoulli_poly_ui(acb_t res, ulong n, const acb_t x, slong prec) noexcept # Sets *res* to the value of the Bernoulli polynomial `B_n(x)`. # Warning: this function is only fast if either *n* or *x* is a small integer. # This function reads Bernoulli numbers from the global cache if they # are already cached, but does not automatically extend the cache by itself. - void acb_polylog(acb_t w, const acb_t s, const acb_t z, slong prec) + void acb_polylog(acb_t w, const acb_t s, const acb_t z, slong prec) noexcept - void acb_polylog_si(acb_t w, slong s, const acb_t z, slong prec) + void acb_polylog_si(acb_t w, slong s, const acb_t z, slong prec) noexcept # Sets *w* to the polylogarithm `\operatorname{Li}_s(z)`. - void acb_agm1(acb_t m, const acb_t z, slong prec) + void acb_agm1(acb_t m, const acb_t z, slong prec) noexcept # Sets *m* to the arithmetic-geometric mean `M(z) = \operatorname{agm}(1,z)`, # defined such that the function is continuous in the complex plane except for # a branch cut along the negative half axis (where it is continuous # from above). This corresponds to always choosing an "optimal" branch for # the square root in the arithmetic-geometric mean iteration. - void acb_agm1_cpx(acb_ptr m, const acb_t z, slong len, slong prec) + void acb_agm1_cpx(acb_ptr m, const acb_t z, slong len, slong prec) noexcept # Sets the coefficients in the array *m* to the power series expansion of the # arithmetic-geometric mean at the point *z* truncated to length *len*, i.e. # `M(z+x) \in \mathbb{C}[[x]]`. - void acb_agm(acb_t m, const acb_t x, const acb_t y, slong prec) + void acb_agm(acb_t m, const acb_t x, const acb_t y, slong prec) noexcept # Sets *m* to the arithmetic-geometric mean of *x* and *y*. The square # roots in the AGM iteration are chosen so as to form the "optimal" # AGM sequence. This gives a well-defined function of *x* and *y* except @@ -774,61 +774,61 @@ cdef extern from "flint_wrap.h": # choice is made (if a decision cannot be made due to inexact arithmetic, # the union of both choices is returned). - void acb_chebyshev_t_ui(acb_t a, ulong n, const acb_t x, slong prec) + void acb_chebyshev_t_ui(acb_t a, ulong n, const acb_t x, slong prec) noexcept - void acb_chebyshev_u_ui(acb_t a, ulong n, const acb_t x, slong prec) + void acb_chebyshev_u_ui(acb_t a, ulong n, const acb_t x, slong prec) noexcept # Evaluates the Chebyshev polynomial of the first kind `a = T_n(x)` # or the Chebyshev polynomial of the second kind `a = U_n(x)`. - void acb_chebyshev_t2_ui(acb_t a, acb_t b, ulong n, const acb_t x, slong prec) + void acb_chebyshev_t2_ui(acb_t a, acb_t b, ulong n, const acb_t x, slong prec) noexcept - void acb_chebyshev_u2_ui(acb_t a, acb_t b, ulong n, const acb_t x, slong prec) + void acb_chebyshev_u2_ui(acb_t a, acb_t b, ulong n, const acb_t x, slong prec) noexcept # Simultaneously evaluates `a = T_n(x), b = T_{n-1}(x)` or # `a = U_n(x), b = U_{n-1}(x)`. # Aliasing between *a*, *b* and *x* is not permitted. - void acb_real_abs(acb_t res, const acb_t z, int analytic, slong prec) + void acb_real_abs(acb_t res, const acb_t z, int analytic, slong prec) noexcept # The absolute value is extended to `+z` in the right half plane and # `-z` in the left half plane, with a discontinuity on the vertical line # `\operatorname{Re}(z) = 0`. - void acb_real_sgn(acb_t res, const acb_t z, int analytic, slong prec) + void acb_real_sgn(acb_t res, const acb_t z, int analytic, slong prec) noexcept # The sign function is extended to `+1` in the right half plane and # `-1` in the left half plane, with a discontinuity on the vertical line # `\operatorname{Re}(z) = 0`. # If *analytic* is not set, this is effectively the same function as # :func:`acb_csgn`. - void acb_real_heaviside(acb_t res, const acb_t z, int analytic, slong prec) + void acb_real_heaviside(acb_t res, const acb_t z, int analytic, slong prec) noexcept # The Heaviside step function (or unit step function) is extended to `+1` in # the right half plane and `0` in the left half plane, with a discontinuity on # the vertical line `\operatorname{Re}(z) = 0`. - void acb_real_floor(acb_t res, const acb_t z, int analytic, slong prec) + void acb_real_floor(acb_t res, const acb_t z, int analytic, slong prec) noexcept # The floor function is extended to a piecewise constant function # equal to `n` in the strips with real part `(n,n+1)`, with discontinuities # on the vertical lines `\operatorname{Re}(z) = n`. - void acb_real_ceil(acb_t res, const acb_t z, int analytic, slong prec) + void acb_real_ceil(acb_t res, const acb_t z, int analytic, slong prec) noexcept # The ceiling function is extended to a piecewise constant function # equal to `n+1` in the strips with real part `(n,n+1)`, with discontinuities # on the vertical lines `\operatorname{Re}(z) = n`. - void acb_real_max(acb_t res, const acb_t x, const acb_t y, int analytic, slong prec) + void acb_real_max(acb_t res, const acb_t x, const acb_t y, int analytic, slong prec) noexcept # The real function `\max(x,y)` is extended to a piecewise analytic function # of two variables by returning `x` when # `\operatorname{Re}(x) \ge \operatorname{Re}(y)` # and returning `y` when `\operatorname{Re}(x) < \operatorname{Re}(y)`, # with discontinuities where `\operatorname{Re}(x) = \operatorname{Re}(y)`. - void acb_real_min(acb_t res, const acb_t x, const acb_t y, int analytic, slong prec) + void acb_real_min(acb_t res, const acb_t x, const acb_t y, int analytic, slong prec) noexcept # The real function `\min(x,y)` is extended to a piecewise analytic function # of two variables by returning `x` when # `\operatorname{Re}(x) \le \operatorname{Re}(y)` # and returning `y` when `\operatorname{Re}(x) > \operatorname{Re}(y)`, # with discontinuities where `\operatorname{Re}(x) = \operatorname{Re}(y)`. - void acb_real_sqrtpos(acb_t res, const acb_t z, int analytic, slong prec) + void acb_real_sqrtpos(acb_t res, const acb_t z, int analytic, slong prec) noexcept # Extends the real square root function on `[0,+\infty)` to the usual # complex square root on the cut plane. Like :func:`arb_sqrtpos`, only # the nonnegative part of *z* is considered if *z* is purely real @@ -837,83 +837,83 @@ cdef extern from "flint_wrap.h": # no spurious imaginary terms `[\pm \varepsilon] i` are created when the # balls computed for `f(x)` straddle zero. - void _acb_vec_zero(acb_ptr A, slong n) + void _acb_vec_zero(acb_ptr A, slong n) noexcept # Sets all entries in *vec* to zero. - bint _acb_vec_is_zero(acb_srcptr vec, slong len) + bint _acb_vec_is_zero(acb_srcptr vec, slong len) noexcept # Returns nonzero iff all entries in *x* are zero. - bint _acb_vec_is_real(acb_srcptr v, slong len) + bint _acb_vec_is_real(acb_srcptr v, slong len) noexcept # Returns nonzero iff all entries in *x* have zero imaginary part. - void _acb_vec_set(acb_ptr res, acb_srcptr vec, slong len) + void _acb_vec_set(acb_ptr res, acb_srcptr vec, slong len) noexcept # Sets *res* to a copy of *vec*. - void _acb_vec_set_round(acb_ptr res, acb_srcptr vec, slong len, slong prec) + void _acb_vec_set_round(acb_ptr res, acb_srcptr vec, slong len, slong prec) noexcept # Sets *res* to a copy of *vec*, rounding each entry to *prec* bits. - void _acb_vec_swap(acb_ptr vec1, acb_ptr vec2, slong len) + void _acb_vec_swap(acb_ptr vec1, acb_ptr vec2, slong len) noexcept # Swaps the entries of *vec1* and *vec2*. - void _acb_vec_neg(acb_ptr res, acb_srcptr vec, slong len) + void _acb_vec_neg(acb_ptr res, acb_srcptr vec, slong len) noexcept - void _acb_vec_add(acb_ptr res, acb_srcptr vec1, acb_srcptr vec2, slong len, slong prec) + void _acb_vec_add(acb_ptr res, acb_srcptr vec1, acb_srcptr vec2, slong len, slong prec) noexcept - void _acb_vec_sub(acb_ptr res, acb_srcptr vec1, acb_srcptr vec2, slong len, slong prec) + void _acb_vec_sub(acb_ptr res, acb_srcptr vec1, acb_srcptr vec2, slong len, slong prec) noexcept - void _acb_vec_scalar_submul(acb_ptr res, acb_srcptr vec, slong len, const acb_t c, slong prec) + void _acb_vec_scalar_submul(acb_ptr res, acb_srcptr vec, slong len, const acb_t c, slong prec) noexcept - void _acb_vec_scalar_addmul(acb_ptr res, acb_srcptr vec, slong len, const acb_t c, slong prec) + void _acb_vec_scalar_addmul(acb_ptr res, acb_srcptr vec, slong len, const acb_t c, slong prec) noexcept - void _acb_vec_scalar_mul(acb_ptr res, acb_srcptr vec, slong len, const acb_t c, slong prec) + void _acb_vec_scalar_mul(acb_ptr res, acb_srcptr vec, slong len, const acb_t c, slong prec) noexcept - void _acb_vec_scalar_mul_ui(acb_ptr res, acb_srcptr vec, slong len, ulong c, slong prec) + void _acb_vec_scalar_mul_ui(acb_ptr res, acb_srcptr vec, slong len, ulong c, slong prec) noexcept - void _acb_vec_scalar_mul_2exp_si(acb_ptr res, acb_srcptr vec, slong len, slong c) + void _acb_vec_scalar_mul_2exp_si(acb_ptr res, acb_srcptr vec, slong len, slong c) noexcept - void _acb_vec_scalar_mul_onei(acb_ptr res, acb_srcptr vec, slong len) + void _acb_vec_scalar_mul_onei(acb_ptr res, acb_srcptr vec, slong len) noexcept - void _acb_vec_scalar_div_ui(acb_ptr res, acb_srcptr vec, slong len, ulong c, slong prec) + void _acb_vec_scalar_div_ui(acb_ptr res, acb_srcptr vec, slong len, ulong c, slong prec) noexcept - void _acb_vec_scalar_div(acb_ptr res, acb_srcptr vec, slong len, const acb_t c, slong prec) + void _acb_vec_scalar_div(acb_ptr res, acb_srcptr vec, slong len, const acb_t c, slong prec) noexcept - void _acb_vec_scalar_mul_arb(acb_ptr res, acb_srcptr vec, slong len, const arb_t c, slong prec) + void _acb_vec_scalar_mul_arb(acb_ptr res, acb_srcptr vec, slong len, const arb_t c, slong prec) noexcept - void _acb_vec_scalar_div_arb(acb_ptr res, acb_srcptr vec, slong len, const arb_t c, slong prec) + void _acb_vec_scalar_div_arb(acb_ptr res, acb_srcptr vec, slong len, const arb_t c, slong prec) noexcept - void _acb_vec_scalar_mul_fmpz(acb_ptr res, acb_srcptr vec, slong len, const fmpz_t c, slong prec) + void _acb_vec_scalar_mul_fmpz(acb_ptr res, acb_srcptr vec, slong len, const fmpz_t c, slong prec) noexcept - void _acb_vec_scalar_div_fmpz(acb_ptr res, acb_srcptr vec, slong len, const fmpz_t c, slong prec) + void _acb_vec_scalar_div_fmpz(acb_ptr res, acb_srcptr vec, slong len, const fmpz_t c, slong prec) noexcept - slong _acb_vec_bits(acb_srcptr vec, slong len) + slong _acb_vec_bits(acb_srcptr vec, slong len) noexcept # Returns the maximum of :func:`arb_bits` for all entries in *vec*. - void _acb_vec_set_powers(acb_ptr xs, const acb_t x, slong len, slong prec) + void _acb_vec_set_powers(acb_ptr xs, const acb_t x, slong len, slong prec) noexcept # Sets *xs* to the powers `1, x, x^2, \ldots, x^{len-1}`. - void _acb_vec_unit_roots(acb_ptr z, slong order, slong len, slong prec) + void _acb_vec_unit_roots(acb_ptr z, slong order, slong len, slong prec) noexcept # Sets *z* to the powers `1,z,z^2,\dots z^{\mathrm{len}-1}` where `z=\exp(\frac{2i\pi}{\mathrm{order}})` to precision *prec*. # *order* can be taken negative. # In order to avoid precision loss, this function does not simply compute powers of a primitive root. - void _acb_vec_add_error_arf_vec(acb_ptr res, arf_srcptr err, slong len) + void _acb_vec_add_error_arf_vec(acb_ptr res, arf_srcptr err, slong len) noexcept - void _acb_vec_add_error_mag_vec(acb_ptr res, mag_srcptr err, slong len) + void _acb_vec_add_error_mag_vec(acb_ptr res, mag_srcptr err, slong len) noexcept # Adds the magnitude of each entry in *err* to the radius of the # corresponding entry in *res*. - void _acb_vec_indeterminate(acb_ptr vec, slong len) + void _acb_vec_indeterminate(acb_ptr vec, slong len) noexcept # Applies :func:`acb_indeterminate` elementwise. - void _acb_vec_trim(acb_ptr res, acb_srcptr vec, slong len) + void _acb_vec_trim(acb_ptr res, acb_srcptr vec, slong len) noexcept # Applies :func:`acb_trim` elementwise. - int _acb_vec_get_unique_fmpz_vec(fmpz * res, acb_srcptr vec, slong len) + int _acb_vec_get_unique_fmpz_vec(fmpz * res, acb_srcptr vec, slong len) noexcept # Calls :func:`acb_get_unique_fmpz` elementwise and returns nonzero if # all entries can be rounded uniquely to integers. If any entry in *vec* # cannot be rounded uniquely to an integer, returns zero. - void _acb_vec_sort_pretty(acb_ptr vec, slong len) + void _acb_vec_sort_pretty(acb_ptr vec, slong len) noexcept # Sorts the vector of complex numbers based on the real and imaginary parts. # This is intended to reveal structure when printing a set of complex numbers, # not to apply an order relation in a rigorous way. diff --git a/src/sage/libs/flint/acb_calc.pxd b/src/sage/libs/flint/acb_calc.pxd index 788857bddb5..c0a78d68dc9 100644 --- a/src/sage/libs/flint/acb_calc.pxd +++ b/src/sage/libs/flint/acb_calc.pxd @@ -12,7 +12,7 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - int acb_calc_integrate(acb_t res, acb_calc_func_t func, void * param, const acb_t a, const acb_t b, slong rel_goal, const mag_t abs_tol, const acb_calc_integrate_opt_t options, slong prec) + int acb_calc_integrate(acb_t res, acb_calc_func_t func, void * param, const acb_t a, const acb_t b, slong rel_goal, const mag_t abs_tol, const acb_calc_integrate_opt_t options, slong prec) noexcept # Computes a rigorous enclosure of the integral # .. math :: # I = \int_a^b f(t) dt @@ -87,11 +87,11 @@ cdef extern from "flint_wrap.h": # parameter (documented below). To use all defaults, *NULL* can be passed # for *options*. - void acb_calc_integrate_opt_init(acb_calc_integrate_opt_t options) + void acb_calc_integrate_opt_init(acb_calc_integrate_opt_t options) noexcept # Initializes *options* for use, setting all fields to 0 indicating # default values. - int acb_calc_integrate_gl_auto_deg(acb_t res, slong * num_eval, acb_calc_func_t func, void * param, const acb_t a, const acb_t b, const mag_t tol, slong deg_limit, int flags, slong prec) + int acb_calc_integrate_gl_auto_deg(acb_t res, slong * num_eval, acb_calc_func_t func, void * param, const acb_t a, const acb_t b, const mag_t tol, slong deg_limit, int flags, slong prec) noexcept # Attempts to compute `I = \int_a^b f(t) dt` using a single application # of Gauss-Legendre quadrature with automatic determination of the # quadrature degree so that the error is smaller than *tol*. @@ -119,7 +119,7 @@ cdef extern from "flint_wrap.h": # since this either means that we have hit a singularity or a branch cut or # that overestimation in the evaluation of `f` is becoming too severe. - void acb_calc_cauchy_bound(arb_t bound, acb_calc_func_t func, void * param, const acb_t x, const arb_t radius, slong maxdepth, slong prec) + void acb_calc_cauchy_bound(arb_t bound, acb_calc_func_t func, void * param, const acb_t x, const arb_t radius, slong maxdepth, slong prec) noexcept # Sets *bound* to a ball containing the value of the integral # .. math :: # C(x,r) = \frac{1}{2 \pi r} \oint_{|z-x| = r} |f(z)| dz @@ -133,7 +133,7 @@ cdef extern from "flint_wrap.h": # repeatedly subdivides the whole integration range instead of # performing adaptive subdivisions. - int acb_calc_integrate_taylor(acb_t res, acb_calc_func_t func, void * param, const acb_t a, const acb_t b, const arf_t inner_radius, const arf_t outer_radius, slong accuracy_goal, slong prec) + int acb_calc_integrate_taylor(acb_t res, acb_calc_func_t func, void * param, const acb_t a, const acb_t b, const arf_t inner_radius, const arf_t outer_radius, slong accuracy_goal, slong prec) noexcept # Computes the integral # .. math :: # I = \int_a^b f(t) dt diff --git a/src/sage/libs/flint/acb_dft.pxd b/src/sage/libs/flint/acb_dft.pxd index 626cdf22c78..7cee8b2291a 100644 --- a/src/sage/libs/flint/acb_dft.pxd +++ b/src/sage/libs/flint/acb_dft.pxd @@ -12,70 +12,70 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void acb_dft(acb_ptr w, acb_srcptr v, slong n, slong prec) + void acb_dft(acb_ptr w, acb_srcptr v, slong n, slong prec) noexcept - void acb_dft_inverse(acb_ptr w, acb_srcptr v, slong n, slong prec) + void acb_dft_inverse(acb_ptr w, acb_srcptr v, slong n, slong prec) noexcept - void acb_dft_precomp_init(acb_dft_pre_t pre, slong len, slong prec) + void acb_dft_precomp_init(acb_dft_pre_t pre, slong len, slong prec) noexcept - void acb_dft_precomp_clear(acb_dft_pre_t pre) + void acb_dft_precomp_clear(acb_dft_pre_t pre) noexcept - void acb_dft_precomp(acb_ptr w, acb_srcptr v, const acb_dft_pre_t pre, slong prec) + void acb_dft_precomp(acb_ptr w, acb_srcptr v, const acb_dft_pre_t pre, slong prec) noexcept - void acb_dft_inverse_precomp(acb_ptr w, acb_srcptr v, const acb_dft_pre_t pre, slong prec) + void acb_dft_inverse_precomp(acb_ptr w, acb_srcptr v, const acb_dft_pre_t pre, slong prec) noexcept - void acb_dirichlet_dft_prod(acb_ptr w, acb_srcptr v, slong * cyc, slong num, slong prec) + void acb_dirichlet_dft_prod(acb_ptr w, acb_srcptr v, slong * cyc, slong num, slong prec) noexcept - void acb_dft_prod_init(acb_dft_prod_t t, slong * cyc, slong num, slong prec) + void acb_dft_prod_init(acb_dft_prod_t t, slong * cyc, slong num, slong prec) noexcept - void acb_dft_prod_clear(acb_dft_prod_t t) + void acb_dft_prod_clear(acb_dft_prod_t t) noexcept - void acb_dirichlet_dft_prod_precomp(acb_ptr w, acb_srcptr v, const acb_dft_prod_t prod, slong prec) + void acb_dirichlet_dft_prod_precomp(acb_ptr w, acb_srcptr v, const acb_dft_prod_t prod, slong prec) noexcept - void acb_dft_convol_naive(acb_ptr w, acb_srcptr f, acb_srcptr g, slong len, slong prec) + void acb_dft_convol_naive(acb_ptr w, acb_srcptr f, acb_srcptr g, slong len, slong prec) noexcept - void acb_dft_convol_rad2(acb_ptr w, acb_srcptr f, acb_srcptr g, slong len, slong prec) + void acb_dft_convol_rad2(acb_ptr w, acb_srcptr f, acb_srcptr g, slong len, slong prec) noexcept - void acb_dft_convol(acb_ptr w, acb_srcptr f, acb_srcptr g, slong len, slong prec) + void acb_dft_convol(acb_ptr w, acb_srcptr f, acb_srcptr g, slong len, slong prec) noexcept - void acb_dft_naive(acb_ptr w, acb_srcptr v, slong n, slong prec) + void acb_dft_naive(acb_ptr w, acb_srcptr v, slong n, slong prec) noexcept - void acb_dft_naive_init(acb_dft_naive_t t, slong len, slong prec) + void acb_dft_naive_init(acb_dft_naive_t t, slong len, slong prec) noexcept - void acb_dft_naive_clear(acb_dft_naive_t t) + void acb_dft_naive_clear(acb_dft_naive_t t) noexcept - void acb_dft_naive_precomp(acb_ptr w, acb_srcptr v, const acb_dft_naive_t t, slong prec) + void acb_dft_naive_precomp(acb_ptr w, acb_srcptr v, const acb_dft_naive_t t, slong prec) noexcept - void acb_dft_crt(acb_ptr w, acb_srcptr v, slong n, slong prec) + void acb_dft_crt(acb_ptr w, acb_srcptr v, slong n, slong prec) noexcept - void acb_dft_crt_init(acb_dft_crt_t t, slong len, slong prec) + void acb_dft_crt_init(acb_dft_crt_t t, slong len, slong prec) noexcept - void acb_dft_crt_clear(acb_dft_crt_t t) + void acb_dft_crt_clear(acb_dft_crt_t t) noexcept - void acb_dft_crt_precomp(acb_ptr w, acb_srcptr v, const acb_dft_crt_t t, slong prec) + void acb_dft_crt_precomp(acb_ptr w, acb_srcptr v, const acb_dft_crt_t t, slong prec) noexcept - void acb_dft_cyc(acb_ptr w, acb_srcptr v, slong n, slong prec) + void acb_dft_cyc(acb_ptr w, acb_srcptr v, slong n, slong prec) noexcept - void acb_dft_cyc_init(acb_dft_cyc_t t, slong len, slong prec) + void acb_dft_cyc_init(acb_dft_cyc_t t, slong len, slong prec) noexcept - void acb_dft_cyc_clear(acb_dft_cyc_t t) + void acb_dft_cyc_clear(acb_dft_cyc_t t) noexcept - void acb_dft_cyc_precomp(acb_ptr w, acb_srcptr v, const acb_dft_cyc_t t, slong prec) + void acb_dft_cyc_precomp(acb_ptr w, acb_srcptr v, const acb_dft_cyc_t t, slong prec) noexcept - void acb_dft_rad2(acb_ptr w, acb_srcptr v, int e, slong prec) + void acb_dft_rad2(acb_ptr w, acb_srcptr v, int e, slong prec) noexcept - void acb_dft_inverse_rad2(acb_ptr w, acb_srcptr v, int e, slong prec) + void acb_dft_inverse_rad2(acb_ptr w, acb_srcptr v, int e, slong prec) noexcept - void acb_dft_rad2_init(acb_dft_rad2_t t, int e, slong prec) + void acb_dft_rad2_init(acb_dft_rad2_t t, int e, slong prec) noexcept - void acb_dft_rad2_clear(acb_dft_rad2_t t) + void acb_dft_rad2_clear(acb_dft_rad2_t t) noexcept - void acb_dft_rad2_precomp(acb_ptr w, acb_srcptr v, const acb_dft_rad2_t t, slong prec) + void acb_dft_rad2_precomp(acb_ptr w, acb_srcptr v, const acb_dft_rad2_t t, slong prec) noexcept - void acb_dft_bluestein(acb_ptr w, acb_srcptr v, slong n, slong prec) + void acb_dft_bluestein(acb_ptr w, acb_srcptr v, slong n, slong prec) noexcept - void acb_dft_bluestein_init(acb_dft_bluestein_t t, slong len, slong prec) + void acb_dft_bluestein_init(acb_dft_bluestein_t t, slong len, slong prec) noexcept - void acb_dft_bluestein_clear(acb_dft_bluestein_t t) + void acb_dft_bluestein_clear(acb_dft_bluestein_t t) noexcept - void acb_dft_bluestein_precomp(acb_ptr w, acb_srcptr v, const acb_dft_bluestein_t t, slong prec) + void acb_dft_bluestein_precomp(acb_ptr w, acb_srcptr v, const acb_dft_bluestein_t t, slong prec) noexcept diff --git a/src/sage/libs/flint/acb_dirichlet.pxd b/src/sage/libs/flint/acb_dirichlet.pxd index 7cbbc3426b1..1b6f09dd74c 100644 --- a/src/sage/libs/flint/acb_dirichlet.pxd +++ b/src/sage/libs/flint/acb_dirichlet.pxd @@ -12,7 +12,7 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void acb_dirichlet_roots_init(acb_dirichlet_roots_t roots, ulong n, slong num, slong prec) + void acb_dirichlet_roots_init(acb_dirichlet_roots_t roots, ulong n, slong num, slong prec) noexcept # Initializes *roots* with precomputed data for fast evaluation of roots of # unity `e^{2\pi i k/n}` of a fixed order *n*. The precomputation is # optimized for *num* evaluations. @@ -26,13 +26,13 @@ cdef extern from "flint_wrap.h": # large *n* if too much memory would be used. For intermediate *num*, # baby-step giant-step tables are computed. - void acb_dirichlet_roots_clear(acb_dirichlet_roots_t roots) + void acb_dirichlet_roots_clear(acb_dirichlet_roots_t roots) noexcept # Clears the structure. - void acb_dirichlet_root(acb_t res, const acb_dirichlet_roots_t roots, ulong k, slong prec) + void acb_dirichlet_root(acb_t res, const acb_dirichlet_roots_t roots, ulong k, slong prec) noexcept # Computes `e^{2\pi i k/n}`. - void acb_dirichlet_powsum_term(acb_ptr res, arb_t log_prev, ulong * prev, const acb_t s, ulong k, int integer, int critical_line, slong len, slong prec) + void acb_dirichlet_powsum_term(acb_ptr res, arb_t log_prev, ulong * prev, const acb_t s, ulong k, int integer, int critical_line, slong len, slong prec) noexcept # Sets *res* to `k^{-(s+x)}` as a power series in *x* truncated to length *len*. # The flags *integer* and *critical_line* respectively specify optimizing # for *s* being an integer or having real part 1/2. @@ -43,7 +43,7 @@ cdef extern from "flint_wrap.h": # overwritten by *k*, allowing *log_prev* to be recycled for the next # term when evaluating a power sum. - void acb_dirichlet_powsum_sieved(acb_ptr res, const acb_t s, ulong n, slong len, slong prec) + void acb_dirichlet_powsum_sieved(acb_ptr res, const acb_t s, ulong n, slong len, slong prec) noexcept # Sets *res* to `\sum_{k=1}^n k^{-(s+x)}` # as a power series in *x* truncated to length *len*. # This function stores a table of powers that have already been calculated, @@ -55,7 +55,7 @@ cdef extern from "flint_wrap.h": # power series multiplications, it is only faster than the naive # algorithm when *len* is small. - void acb_dirichlet_powsum_smooth(acb_ptr res, const acb_t s, ulong n, slong len, slong prec) + void acb_dirichlet_powsum_smooth(acb_ptr res, const acb_t s, ulong n, slong len, slong prec) noexcept # Sets *res* to `\sum_{k=1}^n k^{-(s+x)}` # as a power series in *x* truncated to length *len*. # This function performs partial sieving by adding multiples of 5-smooth *k* @@ -66,75 +66,75 @@ cdef extern from "flint_wrap.h": # A slightly bigger gain for larger *n* could be achieved by using more # small prime factors, at the expense of space. - void acb_dirichlet_zeta(acb_t res, const acb_t s, slong prec) + void acb_dirichlet_zeta(acb_t res, const acb_t s, slong prec) noexcept # Computes `\zeta(s)` using an automatic choice of algorithm. - void acb_dirichlet_zeta_jet(acb_t res, const acb_t s, int deflate, slong len, slong prec) + void acb_dirichlet_zeta_jet(acb_t res, const acb_t s, int deflate, slong len, slong prec) noexcept # Computes the first *len* terms of the Taylor series of the Riemann zeta # function at *s*. If *deflate* is nonzero, computes the deflated # function `\zeta(s) - 1/(s-1)` instead. - void acb_dirichlet_zeta_bound(mag_t res, const acb_t s) + void acb_dirichlet_zeta_bound(mag_t res, const acb_t s) noexcept # Computes an upper bound for `|\zeta(s)|` quickly. On the critical strip (and # slightly outside of it), formula (43.3) in [Rad1973]_ is used. # To the right, evaluating at the real part of *s* gives a trivial bound. # To the left, the functional equation is used. - void acb_dirichlet_zeta_deriv_bound(mag_t der1, mag_t der2, const acb_t s) + void acb_dirichlet_zeta_deriv_bound(mag_t der1, mag_t der2, const acb_t s) noexcept # Sets *der1* to a bound for `|\zeta'(s)|` and *der2* to a bound for # `|\zeta''(s)|`. These bounds are mainly intended for use in the critical # strip and will not be tight. - void acb_dirichlet_eta(acb_t res, const acb_t s, slong prec) + void acb_dirichlet_eta(acb_t res, const acb_t s, slong prec) noexcept # Sets *res* to the Dirichlet eta function # `\eta(s) = \sum_{k=1}^{\infty} (-1)^{k+1} / k^s = (1-2^{1-s}) \zeta(s)`, # also known as the alternating zeta function. # Note that the alternating character `\{1,-1\}` is not itself # a Dirichlet character. - void acb_dirichlet_xi(acb_t res, const acb_t s, slong prec) + void acb_dirichlet_xi(acb_t res, const acb_t s, slong prec) noexcept # Sets *res* to the Riemann xi function # `\xi(s) = \frac{1}{2} s (s-1) \pi^{-s/2} \Gamma(\frac{1}{2} s) \zeta(s)`. # The functional equation for xi is `\xi(1-s) = \xi(s)`. - void acb_dirichlet_zeta_rs_f_coeffs(acb_ptr f, const arb_t p, slong n, slong prec) + void acb_dirichlet_zeta_rs_f_coeffs(acb_ptr f, const arb_t p, slong n, slong prec) noexcept # Computes the coefficients `F^{(j)}(p)` for `0 \le j < n`. # Uses power series division. This method breaks down when `p = \pm 1/2` # (which is not problem if *s* is an exact floating-point number). - void acb_dirichlet_zeta_rs_d_coeffs(arb_ptr d, const arb_t sigma, slong k, slong prec) + void acb_dirichlet_zeta_rs_d_coeffs(arb_ptr d, const arb_t sigma, slong k, slong prec) noexcept # Computes the coefficients `d_j^{(k)}` for `0 \le j \le \lfloor 3k/2 \rfloor + 1`. # On input, the array *d* must contain the coefficients for `d_j^{(k-1)}` # unless `k = 0`, and these coefficients will be updated in-place. - void acb_dirichlet_zeta_rs_bound(mag_t err, const acb_t s, slong K) + void acb_dirichlet_zeta_rs_bound(mag_t err, const acb_t s, slong K) noexcept # Bounds the error term `RS_K` following Theorem 4.2 in Arias de Reyna. - void acb_dirichlet_zeta_rs_r(acb_t res, const acb_t s, slong K, slong prec) + void acb_dirichlet_zeta_rs_r(acb_t res, const acb_t s, slong K, slong prec) noexcept # Computes `\mathcal{R}(s)` in the upper half plane. Uses precisely *K* # asymptotic terms in the RS formula if this input parameter is positive; # otherwise chooses the number of terms automatically based on *s* and the # precision. - void acb_dirichlet_zeta_rs(acb_t res, const acb_t s, slong K, slong prec) + void acb_dirichlet_zeta_rs(acb_t res, const acb_t s, slong K, slong prec) noexcept # Computes `\zeta(s)` using the Riemann-Siegel formula. Uses precisely # *K* asymptotic terms in the RS formula if this input parameter is positive; # otherwise chooses the number of terms automatically based on *s* and the # precision. - void acb_dirichlet_zeta_jet_rs(acb_ptr res, const acb_t s, slong len, slong prec) + void acb_dirichlet_zeta_jet_rs(acb_ptr res, const acb_t s, slong len, slong prec) noexcept # Computes the first *len* terms of the Taylor series of the Riemann zeta # function at *s* using the Riemann Siegel formula. This function currently # only supports *len* = 1 or *len* = 2. A finite difference is used # to compute the first derivative. - void acb_dirichlet_hurwitz(acb_t res, const acb_t s, const acb_t a, slong prec) + void acb_dirichlet_hurwitz(acb_t res, const acb_t s, const acb_t a, slong prec) noexcept # Computes the Hurwitz zeta function `\zeta(s, a)`. # This function automatically delegates to the code for the Riemann zeta function # when `a = 1`. Some other special cases may also be handled by direct # formulas. In general, Euler-Maclaurin summation is used. - void acb_dirichlet_hurwitz_precomp_init(acb_dirichlet_hurwitz_precomp_t pre, const acb_t s, int deflate, slong A, slong K, slong N, slong prec) + void acb_dirichlet_hurwitz_precomp_init(acb_dirichlet_hurwitz_precomp_t pre, const acb_t s, int deflate, slong A, slong K, slong N, slong prec) noexcept # Precomputes a grid of Taylor polynomials for fast evaluation of # `\zeta(s,a)` on `a \in (0,1]` with fixed *s*. # *A* is the initial shift to apply to *a*, *K* is the number of Taylor terms, @@ -153,15 +153,15 @@ cdef extern from "flint_wrap.h": # If *deflate* is set, the deflated Hurwitz zeta function is used, # removing the pole at `s = 1`. - void acb_dirichlet_hurwitz_precomp_init_num(acb_dirichlet_hurwitz_precomp_t pre, const acb_t s, int deflate, double num_eval, slong prec) + void acb_dirichlet_hurwitz_precomp_init_num(acb_dirichlet_hurwitz_precomp_t pre, const acb_t s, int deflate, double num_eval, slong prec) noexcept # Initializes *pre*, choosing the parameters *A*, *K*, and *N* # automatically to minimize the cost of *num_eval* evaluations of the # Hurwitz zeta function at argument *s* to precision *prec*. - void acb_dirichlet_hurwitz_precomp_clear(acb_dirichlet_hurwitz_precomp_t pre) + void acb_dirichlet_hurwitz_precomp_clear(acb_dirichlet_hurwitz_precomp_t pre) noexcept # Clears the precomputed data. - void acb_dirichlet_hurwitz_precomp_choose_param(ulong * A, ulong * K, ulong * N, const acb_t s, double num_eval, slong prec) + void acb_dirichlet_hurwitz_precomp_choose_param(ulong * A, ulong * K, ulong * N, const acb_t s, double num_eval, slong prec) noexcept # Chooses precomputation parameters *A*, *K* and *N* to minimize # the cost of *num_eval* evaluations of the Hurwitz zeta function # at argument *s* to precision *prec*. @@ -169,18 +169,18 @@ cdef extern from "flint_wrap.h": # scratch would be better than performing a precomputation, *A*, *K* and *N* # are all set to 0. - void acb_dirichlet_hurwitz_precomp_bound(mag_t res, const acb_t s, slong A, slong K, slong N) + void acb_dirichlet_hurwitz_precomp_bound(mag_t res, const acb_t s, slong A, slong K, slong N) noexcept # Computes an upper bound for the truncation error (not accounting for # roundoff error) when evaluating `\zeta(s,a)` with precomputation parameters # *A*, *K*, *N*, assuming that `0 < a \le 1`. # For details, see :ref:`algorithms_hurwitz`. - void acb_dirichlet_hurwitz_precomp_eval(acb_t res, const acb_dirichlet_hurwitz_precomp_t pre, ulong p, ulong q, slong prec) + void acb_dirichlet_hurwitz_precomp_eval(acb_t res, const acb_dirichlet_hurwitz_precomp_t pre, ulong p, ulong q, slong prec) noexcept # Evaluates `\zeta(s,p/q)` using precomputed data, assuming that `0 < p/q \le 1`. - void acb_dirichlet_lerch_phi_integral(acb_t res, const acb_t z, const acb_t s, const acb_t a, slong prec) - void acb_dirichlet_lerch_phi_direct(acb_t res, const acb_t z, const acb_t s, const acb_t a, slong prec) - void acb_dirichlet_lerch_phi(acb_t res, const acb_t z, const acb_t s, const acb_t a, slong prec) + void acb_dirichlet_lerch_phi_integral(acb_t res, const acb_t z, const acb_t s, const acb_t a, slong prec) noexcept + void acb_dirichlet_lerch_phi_direct(acb_t res, const acb_t z, const acb_t s, const acb_t a, slong prec) noexcept + void acb_dirichlet_lerch_phi(acb_t res, const acb_t z, const acb_t s, const acb_t a, slong prec) noexcept # Computes the Lerch transcendent # .. math :: # \Phi(z,s,a) = \sum_{k=0}^{\infty} \frac{z^k}{(k+a)^s} @@ -195,7 +195,7 @@ cdef extern from "flint_wrap.h": # checks for some special cases where the function can be expressed # in terms of simpler functions (Hurwitz zeta, polylogarithms). - void acb_dirichlet_stieltjes(acb_t res, const fmpz_t n, const acb_t a, slong prec) + void acb_dirichlet_stieltjes(acb_t res, const fmpz_t n, const acb_t a, slong prec) noexcept # Given a nonnegative integer *n*, sets *res* to the generalized Stieltjes constant # `\gamma_n(a)` which is the coefficient in the Laurent series of the # Hurwitz zeta function at the pole @@ -213,42 +213,42 @@ cdef extern from "flint_wrap.h": # expansion once at `s = 1` than to call this function repeatedly, # unless *n* is extremely large (at least several hundred). - void acb_dirichlet_chi(acb_t res, const dirichlet_group_t G, const dirichlet_char_t chi, ulong n, slong prec) + void acb_dirichlet_chi(acb_t res, const dirichlet_group_t G, const dirichlet_char_t chi, ulong n, slong prec) noexcept # Sets *res* to `\chi(n)`, the value of the Dirichlet character *chi* # at the integer *n*. - void acb_dirichlet_chi_vec(acb_ptr v, const dirichlet_group_t G, const dirichlet_char_t chi, slong nv, slong prec) + void acb_dirichlet_chi_vec(acb_ptr v, const dirichlet_group_t G, const dirichlet_char_t chi, slong nv, slong prec) noexcept # Compute the *nv* first Dirichlet values. - void acb_dirichlet_pairing(acb_t res, const dirichlet_group_t G, ulong m, ulong n, slong prec) + void acb_dirichlet_pairing(acb_t res, const dirichlet_group_t G, ulong m, ulong n, slong prec) noexcept - void acb_dirichlet_pairing_char(acb_t res, const dirichlet_group_t G, const dirichlet_char_t a, const dirichlet_char_t b, slong prec) + void acb_dirichlet_pairing_char(acb_t res, const dirichlet_group_t G, const dirichlet_char_t a, const dirichlet_char_t b, slong prec) noexcept # Sets *res* to the value of the Dirichlet pairing `\chi(m,n)` at numbers `m` and `n`. # The second form takes two characters as input. - void acb_dirichlet_gauss_sum_naive(acb_t res, const dirichlet_group_t G, const dirichlet_char_t chi, slong prec) + void acb_dirichlet_gauss_sum_naive(acb_t res, const dirichlet_group_t G, const dirichlet_char_t chi, slong prec) noexcept - void acb_dirichlet_gauss_sum_factor(acb_t res, const dirichlet_group_t G, const dirichlet_char_t chi, slong prec) + void acb_dirichlet_gauss_sum_factor(acb_t res, const dirichlet_group_t G, const dirichlet_char_t chi, slong prec) noexcept - void acb_dirichlet_gauss_sum_order2(acb_t res, const dirichlet_group_t G, const dirichlet_char_t chi, slong prec) + void acb_dirichlet_gauss_sum_order2(acb_t res, const dirichlet_group_t G, const dirichlet_char_t chi, slong prec) noexcept - void acb_dirichlet_gauss_sum_theta(acb_t res, const dirichlet_group_t G, const dirichlet_char_t chi, slong prec) + void acb_dirichlet_gauss_sum_theta(acb_t res, const dirichlet_group_t G, const dirichlet_char_t chi, slong prec) noexcept - void acb_dirichlet_gauss_sum(acb_t res, const dirichlet_group_t G, const dirichlet_char_t chi, slong prec) + void acb_dirichlet_gauss_sum(acb_t res, const dirichlet_group_t G, const dirichlet_char_t chi, slong prec) noexcept - void acb_dirichlet_jacobi_sum_naive(acb_t res, const dirichlet_group_t G, const dirichlet_char_t chi1, const dirichlet_char_t chi2, slong prec) + void acb_dirichlet_jacobi_sum_naive(acb_t res, const dirichlet_group_t G, const dirichlet_char_t chi1, const dirichlet_char_t chi2, slong prec) noexcept - void acb_dirichlet_jacobi_sum_factor(acb_t res, const dirichlet_group_t G, const dirichlet_char_t chi1, const dirichlet_char_t chi2, slong prec) + void acb_dirichlet_jacobi_sum_factor(acb_t res, const dirichlet_group_t G, const dirichlet_char_t chi1, const dirichlet_char_t chi2, slong prec) noexcept - void acb_dirichlet_jacobi_sum_gauss(acb_t res, const dirichlet_group_t G, const dirichlet_char_t chi1, const dirichlet_char_t chi2, slong prec) + void acb_dirichlet_jacobi_sum_gauss(acb_t res, const dirichlet_group_t G, const dirichlet_char_t chi1, const dirichlet_char_t chi2, slong prec) noexcept - void acb_dirichlet_jacobi_sum(acb_t res, const dirichlet_group_t G, const dirichlet_char_t chi1, const dirichlet_char_t chi2, slong prec) + void acb_dirichlet_jacobi_sum(acb_t res, const dirichlet_group_t G, const dirichlet_char_t chi1, const dirichlet_char_t chi2, slong prec) noexcept - void acb_dirichlet_jacobi_sum_ui(acb_t res, const dirichlet_group_t G, ulong a, ulong b, slong prec) + void acb_dirichlet_jacobi_sum_ui(acb_t res, const dirichlet_group_t G, ulong a, ulong b, slong prec) noexcept - void acb_dirichlet_chi_theta_arb(acb_t res, const dirichlet_group_t G, const dirichlet_char_t chi, const arb_t t, slong prec) + void acb_dirichlet_chi_theta_arb(acb_t res, const dirichlet_group_t G, const dirichlet_char_t chi, const arb_t t, slong prec) noexcept - void acb_dirichlet_ui_theta_arb(acb_t res, const dirichlet_group_t G, ulong a, const arb_t t, slong prec) + void acb_dirichlet_ui_theta_arb(acb_t res, const dirichlet_group_t G, ulong a, const arb_t t, slong prec) noexcept # Compute the theta series `\Theta_q(a,t)` for real argument `t>0`. # Beware that if `t<1` the functional equation # .. math:: @@ -263,21 +263,21 @@ cdef extern from "flint_wrap.h": # .. math:: # \Theta_q(a,t) = \sum_{n\geq 0} \chi_q(a, n) x(t)^{n^2}. - ulong acb_dirichlet_theta_length(ulong q, const arb_t t, slong prec) + ulong acb_dirichlet_theta_length(ulong q, const arb_t t, slong prec) noexcept - void acb_dirichlet_qseries_arb_powers_naive(acb_t res, const arb_t x, int p, const ulong * a, const acb_dirichlet_roots_t z, slong len, slong prec) + void acb_dirichlet_qseries_arb_powers_naive(acb_t res, const arb_t x, int p, const ulong * a, const acb_dirichlet_roots_t z, slong len, slong prec) noexcept - void acb_dirichlet_qseries_arb_powers_smallorder(acb_t res, const arb_t x, int p, const ulong * a, const acb_dirichlet_roots_t z, slong len, slong prec) + void acb_dirichlet_qseries_arb_powers_smallorder(acb_t res, const arb_t x, int p, const ulong * a, const acb_dirichlet_roots_t z, slong len, slong prec) noexcept - void acb_dirichlet_dft_conrey(acb_ptr w, acb_srcptr v, const dirichlet_group_t G, slong prec) + void acb_dirichlet_dft_conrey(acb_ptr w, acb_srcptr v, const dirichlet_group_t G, slong prec) noexcept - void acb_dirichlet_dft(acb_ptr w, acb_srcptr v, const dirichlet_group_t G, slong prec) + void acb_dirichlet_dft(acb_ptr w, acb_srcptr v, const dirichlet_group_t G, slong prec) noexcept - void acb_dirichlet_root_number_theta(acb_t res, const dirichlet_group_t G, const dirichlet_char_t chi, slong prec) + void acb_dirichlet_root_number_theta(acb_t res, const dirichlet_group_t G, const dirichlet_char_t chi, slong prec) noexcept - void acb_dirichlet_root_number(acb_t res, const dirichlet_group_t G, const dirichlet_char_t chi, slong prec) + void acb_dirichlet_root_number(acb_t res, const dirichlet_group_t G, const dirichlet_char_t chi, slong prec) noexcept - void acb_dirichlet_l_hurwitz(acb_t res, const acb_t s, const acb_dirichlet_hurwitz_precomp_t precomp, const dirichlet_group_t G, const dirichlet_char_t chi, slong prec) + void acb_dirichlet_l_hurwitz(acb_t res, const acb_t s, const acb_dirichlet_hurwitz_precomp_t precomp, const dirichlet_group_t G, const dirichlet_char_t chi, slong prec) noexcept # Computes `L(s,\chi)` using decomposition in terms of the Hurwitz zeta function # .. math:: # L(s,\chi) = q^{-s}\sum_{k=1}^q \chi(k) \,\zeta\!\left(s,\frac kq\right). @@ -287,9 +287,9 @@ cdef extern from "flint_wrap.h": # directly. If a pre-initialized *precomp* object is provided, this will be # used instead to evaluate the Hurwitz zeta function. - void acb_dirichlet_l_euler_product(acb_t res, const acb_t s, const dirichlet_group_t G, const dirichlet_char_t chi, slong prec) + void acb_dirichlet_l_euler_product(acb_t res, const acb_t s, const dirichlet_group_t G, const dirichlet_char_t chi, slong prec) noexcept - void _acb_dirichlet_euler_product_real_ui(arb_t res, ulong s, const signed char * chi, int mod, int reciprocal, slong prec) + void _acb_dirichlet_euler_product_real_ui(arb_t res, ulong s, const signed char * chi, int mod, int reciprocal, slong prec) noexcept # Computes `L(s,\chi)` directly using the Euler product. This is # efficient if *s* has large positive real part. As implemented, this # function only gives a finite result if `\operatorname{re}(s) \ge 2`. @@ -307,16 +307,16 @@ cdef extern from "flint_wrap.h": # values at 0, 1, ..., *mod* - 1. If *reciprocal* is set, it computes # `1 / L(s,\chi)` (this is faster if the reciprocal can be used directly). - void acb_dirichlet_l(acb_t res, const acb_t s, const dirichlet_group_t G, const dirichlet_char_t chi, slong prec) + void acb_dirichlet_l(acb_t res, const acb_t s, const dirichlet_group_t G, const dirichlet_char_t chi, slong prec) noexcept # Computes `L(s,\chi)` using a default choice of algorithm. - void acb_dirichlet_l_fmpq(acb_t res, const fmpq_t s, const dirichlet_group_t G, const dirichlet_char_t chi, slong prec) - void acb_dirichlet_l_fmpq_afe(acb_t res, const fmpq_t s, const dirichlet_group_t G, const dirichlet_char_t chi, slong prec) + void acb_dirichlet_l_fmpq(acb_t res, const fmpq_t s, const dirichlet_group_t G, const dirichlet_char_t chi, slong prec) noexcept + void acb_dirichlet_l_fmpq_afe(acb_t res, const fmpq_t s, const dirichlet_group_t G, const dirichlet_char_t chi, slong prec) noexcept # Computes `L(s,\chi)` where *s* is a rational number. # The *afe* version uses the approximate functional equation; # the default version chooses an algorithm automatically. - void acb_dirichlet_l_vec_hurwitz(acb_ptr res, const acb_t s, const acb_dirichlet_hurwitz_precomp_t precomp, const dirichlet_group_t G, slong prec) + void acb_dirichlet_l_vec_hurwitz(acb_ptr res, const acb_t s, const acb_dirichlet_hurwitz_precomp_t precomp, const dirichlet_group_t G, slong prec) noexcept # Compute all values `L(s,\chi)` for `\chi` mod `q`, using the # Hurwitz zeta function and a discrete Fourier transform. # The output *res* is assumed to have length *G->phi_q* and values @@ -326,7 +326,7 @@ cdef extern from "flint_wrap.h": # directly. If a pre-initialized *precomp* object is provided, this will be # used instead to evaluate the Hurwitz zeta function. - void acb_dirichlet_l_jet(acb_ptr res, const acb_t s, const dirichlet_group_t G, const dirichlet_char_t chi, int deflate, slong len, slong prec) + void acb_dirichlet_l_jet(acb_ptr res, const acb_t s, const dirichlet_group_t G, const dirichlet_char_t chi, int deflate, slong len, slong prec) noexcept # Computes the Taylor expansion of `L(s,\chi)` to length *len*, # i.e. `L(s), L'(s), \ldots, L^{(len-1)}(s) / (len-1)!`. # If *deflate* is set, computes the expansion of @@ -338,13 +338,13 @@ cdef extern from "flint_wrap.h": # gives the regular part of the Laurent expansion. # When *chi* is non-principal, *deflate* has no effect. - void _acb_dirichlet_l_series(acb_ptr res, acb_srcptr s, slong slen, const dirichlet_group_t G, const dirichlet_char_t chi, int deflate, slong len, slong prec) + void _acb_dirichlet_l_series(acb_ptr res, acb_srcptr s, slong slen, const dirichlet_group_t G, const dirichlet_char_t chi, int deflate, slong len, slong prec) noexcept - void acb_dirichlet_l_series(acb_poly_t res, const acb_poly_t s, const dirichlet_group_t G, const dirichlet_char_t chi, int deflate, slong len, slong prec) + void acb_dirichlet_l_series(acb_poly_t res, const acb_poly_t s, const dirichlet_group_t G, const dirichlet_char_t chi, int deflate, slong len, slong prec) noexcept # Sets *res* to the power series `L(s,\chi)` where *s* is a given power series, truncating the result to length *len*. # See :func:`acb_dirichlet_l_jet` for the meaning of the *deflate* flag. - void acb_dirichlet_hardy_theta(acb_ptr res, const acb_t t, const dirichlet_group_t G, const dirichlet_char_t chi, slong len, slong prec) + void acb_dirichlet_hardy_theta(acb_ptr res, const acb_t t, const dirichlet_group_t G, const dirichlet_char_t chi, slong len, slong prec) noexcept # Computes the phase function used to construct the Z-function. # We have # .. math :: @@ -354,28 +354,28 @@ cdef extern from "flint_wrap.h": # is the root number as computed by :func:`acb_dirichlet_root_number`. # The first *len* terms in the Taylor expansion are written to the output. - void acb_dirichlet_hardy_z(acb_ptr res, const acb_t t, const dirichlet_group_t G, const dirichlet_char_t chi, slong len, slong prec) + void acb_dirichlet_hardy_z(acb_ptr res, const acb_t t, const dirichlet_group_t G, const dirichlet_char_t chi, slong len, slong prec) noexcept # Computes the Hardy Z-function, also known as the Riemann-Siegel Z-function # `Z(t) = e^{i \theta(t)} L(1/2+it)`, which is real-valued for real *t*. # The first *len* terms in the Taylor expansion are written to the output. - void _acb_dirichlet_hardy_theta_series(acb_ptr res, acb_srcptr t, slong tlen, const dirichlet_group_t G, const dirichlet_char_t chi, slong len, slong prec) + void _acb_dirichlet_hardy_theta_series(acb_ptr res, acb_srcptr t, slong tlen, const dirichlet_group_t G, const dirichlet_char_t chi, slong len, slong prec) noexcept - void acb_dirichlet_hardy_theta_series(acb_poly_t res, const acb_poly_t t, const dirichlet_group_t G, const dirichlet_char_t chi, slong len, slong prec) + void acb_dirichlet_hardy_theta_series(acb_poly_t res, const acb_poly_t t, const dirichlet_group_t G, const dirichlet_char_t chi, slong len, slong prec) noexcept # Sets *res* to the power series `\theta(t)` where *t* is a given power series, truncating the result to length *len*. - void _acb_dirichlet_hardy_z_series(acb_ptr res, acb_srcptr t, slong tlen, const dirichlet_group_t G, const dirichlet_char_t chi, slong len, slong prec) + void _acb_dirichlet_hardy_z_series(acb_ptr res, acb_srcptr t, slong tlen, const dirichlet_group_t G, const dirichlet_char_t chi, slong len, slong prec) noexcept - void acb_dirichlet_hardy_z_series(acb_poly_t res, const acb_poly_t t, const dirichlet_group_t G, const dirichlet_char_t chi, slong len, slong prec) + void acb_dirichlet_hardy_z_series(acb_poly_t res, const acb_poly_t t, const dirichlet_group_t G, const dirichlet_char_t chi, slong len, slong prec) noexcept # Sets *res* to the power series `Z(t)` where *t* is a given power series, truncating the result to length *len*. - void acb_dirichlet_gram_point(arb_t res, const fmpz_t n, const dirichlet_group_t G, const dirichlet_char_t chi, slong prec) + void acb_dirichlet_gram_point(arb_t res, const fmpz_t n, const dirichlet_group_t G, const dirichlet_char_t chi, slong prec) noexcept # Sets *res* to the *n*-th Gram point `g_n`, defined as the unique solution # in `[7, \infty)` of `\theta(g_n) = \pi n`. Currently only the Gram points # corresponding to the Riemann zeta function are supported and *G* and *chi* # must both be set to *NULL*. Requires `n \ge -1`. - ulong acb_dirichlet_turing_method_bound(const fmpz_t p) + ulong acb_dirichlet_turing_method_bound(const fmpz_t p) noexcept # Computes an upper bound *B* for the minimum number of consecutive good # Gram blocks sufficient to count nontrivial zeros of the Riemann zeta # function using Turing's method [Tur1953]_ as updated by [Leh1970]_, @@ -385,56 +385,56 @@ cdef extern from "flint_wrap.h": # If at least *B* consecutive Gram blocks with union `[g_n, g_p)` # satisfy Rosser's rule, then `N(g_n) \le n + 1` and `N(g_p) \ge p + 1`. - int _acb_dirichlet_definite_hardy_z(arb_t res, const arf_t t, slong * pprec) + int _acb_dirichlet_definite_hardy_z(arb_t res, const arf_t t, slong * pprec) noexcept # Sets *res* to the Hardy Z-function `Z(t)`. # The initial precision (* *pprec*) is increased as necessary # to determine the sign of `Z(t)`. The sign is returned. - void _acb_dirichlet_isolate_gram_hardy_z_zero(arf_t a, arf_t b, const fmpz_t n) + void _acb_dirichlet_isolate_gram_hardy_z_zero(arf_t a, arf_t b, const fmpz_t n) noexcept # Uses Gram's law to compute an interval `(a, b)` that # contains the *n*-th zero of the Hardy Z-function and no other zero. # Requires `1 \le n \le 126`. - void _acb_dirichlet_isolate_rosser_hardy_z_zero(arf_t a, arf_t b, const fmpz_t n) + void _acb_dirichlet_isolate_rosser_hardy_z_zero(arf_t a, arf_t b, const fmpz_t n) noexcept # Uses Rosser's rule to compute an interval `(a, b)` that # contains the *n*-th zero of the Hardy Z-function and no other zero. # Requires `1 \le n \le 13999526`. - void _acb_dirichlet_isolate_turing_hardy_z_zero(arf_t a, arf_t b, const fmpz_t n) + void _acb_dirichlet_isolate_turing_hardy_z_zero(arf_t a, arf_t b, const fmpz_t n) noexcept # Computes an interval `(a, b)` that contains the *n*-th zero of the # Hardy Z-function and no other zero, following Turing's method. # Requires `n \ge 2`. - void acb_dirichlet_isolate_hardy_z_zero(arf_t a, arf_t b, const fmpz_t n) + void acb_dirichlet_isolate_hardy_z_zero(arf_t a, arf_t b, const fmpz_t n) noexcept # Computes an interval `(a, b)` that contains the *n*-th zero of the # Hardy Z-function and contains no other zero, using the most appropriate # underscore version of this function. Requires `n \ge 1`. - void _acb_dirichlet_refine_hardy_z_zero(arb_t res, const arf_t a, const arf_t b, slong prec) + void _acb_dirichlet_refine_hardy_z_zero(arb_t res, const arf_t a, const arf_t b, slong prec) noexcept # Sets *res* to the unique zero of the Hardy Z-function in the # interval `(a, b)`. - void acb_dirichlet_hardy_z_zero(arb_t res, const fmpz_t n, slong prec) + void acb_dirichlet_hardy_z_zero(arb_t res, const fmpz_t n, slong prec) noexcept # Sets *res* to the *n*-th zero of the Hardy Z-function, requiring `n \ge 1`. - void acb_dirichlet_hardy_z_zeros(arb_ptr res, const fmpz_t n, slong len, slong prec) + void acb_dirichlet_hardy_z_zeros(arb_ptr res, const fmpz_t n, slong len, slong prec) noexcept # Sets the entries of *res* to *len* consecutive zeros of the # Hardy Z-function, beginning with the *n*-th zero. Requires positive *n*. - void acb_dirichlet_zeta_zero(acb_t res, const fmpz_t n, slong prec) + void acb_dirichlet_zeta_zero(acb_t res, const fmpz_t n, slong prec) noexcept # Sets *res* to the *n*-th nontrivial zero of `\zeta(s)`, requiring `n \ge 1`. - void acb_dirichlet_zeta_zeros(acb_ptr res, const fmpz_t n, slong len, slong prec) + void acb_dirichlet_zeta_zeros(acb_ptr res, const fmpz_t n, slong len, slong prec) noexcept # Sets the entries of *res* to *len* consecutive nontrivial zeros of `\zeta(s)` # beginning with the *n*-th zero. Requires positive *n*. - void _acb_dirichlet_exact_zeta_nzeros(fmpz_t res, const arf_t t) + void _acb_dirichlet_exact_zeta_nzeros(fmpz_t res, const arf_t t) noexcept - void acb_dirichlet_zeta_nzeros(arb_t res, const arb_t t, slong prec) + void acb_dirichlet_zeta_nzeros(arb_t res, const arb_t t, slong prec) noexcept # Compute the number of zeros (counted according to their multiplicities) # of `\zeta(s)` in the region `0 < \operatorname{Im}(s) \le t`. - void acb_dirichlet_backlund_s(arb_t res, const arb_t t, slong prec) + void acb_dirichlet_backlund_s(arb_t res, const arb_t t, slong prec) noexcept # Compute `S(t) = \frac{1}{\pi}\operatorname{arg}\zeta(\frac{1}{2} + it)` # where the argument is defined by continuous variation of `s` in `\zeta(s)` # starting at `s = 2`, then vertically to `s = 2 + it`, then horizontally @@ -445,20 +445,20 @@ cdef extern from "flint_wrap.h": # :func:`acb_dirichlet_zeta_nzeros` and `\theta(t)` is # :func:`acb_dirichlet_hardy_theta`. - void acb_dirichlet_backlund_s_bound(mag_t res, const arb_t t) + void acb_dirichlet_backlund_s_bound(mag_t res, const arb_t t) noexcept # Compute an upper bound for `|S(t)|` quickly. Theorem 1 # and the bounds in (1.2) in [Tru2014]_ are used. - void acb_dirichlet_zeta_nzeros_gram(fmpz_t res, const fmpz_t n) + void acb_dirichlet_zeta_nzeros_gram(fmpz_t res, const fmpz_t n) noexcept # Compute `N(g_n)`. That is, compute the number of zeros (counted according # to their multiplicities) of `\zeta(s)` in the region # `0 < \operatorname{Im}(s) \le g_n` where `g_n` is the *n*-th Gram point. # Requires `n \ge -1`. - slong acb_dirichlet_backlund_s_gram(const fmpz_t n) + slong acb_dirichlet_backlund_s_gram(const fmpz_t n) noexcept # Compute `S(g_n)` where `g_n` is the *n*-th Gram point. Requires `n \ge -1`. - void acb_dirichlet_platt_scaled_lambda(arb_t res, const arb_t t, slong prec) + void acb_dirichlet_platt_scaled_lambda(arb_t res, const arb_t t, slong prec) noexcept # Compute `\Lambda(t) e^{\pi t/4}` where # .. math :: # \Lambda(t) = \pi^{-\frac{it}{2}} @@ -469,11 +469,11 @@ cdef extern from "flint_wrap.h": # real-valued by the functional equation, and the exponential factor is # designed to counteract the decay of the gamma factor as `t` increases. - void acb_dirichlet_platt_scaled_lambda_vec(arb_ptr res, const fmpz_t T, slong A, slong B, slong prec) + void acb_dirichlet_platt_scaled_lambda_vec(arb_ptr res, const fmpz_t T, slong A, slong B, slong prec) noexcept - void acb_dirichlet_platt_multieval(arb_ptr res, const fmpz_t T, slong A, slong B, const arb_t h, const fmpz_t J, slong K, slong sigma, slong prec) + void acb_dirichlet_platt_multieval(arb_ptr res, const fmpz_t T, slong A, slong B, const arb_t h, const fmpz_t J, slong K, slong sigma, slong prec) noexcept - void acb_dirichlet_platt_multieval_threaded(arb_ptr res, const fmpz_t T, slong A, slong B, const arb_t h, const fmpz_t J, slong K, slong sigma, slong prec) + void acb_dirichlet_platt_multieval_threaded(arb_ptr res, const fmpz_t T, slong A, slong B, const arb_t h, const fmpz_t J, slong K, slong sigma, slong prec) noexcept # Compute :func:`acb_dirichlet_platt_scaled_lambda` at `N=AB` points on a # grid, following the notation of [Pla2017]_. The first point on the grid # is `T - B/2` and the distance between grid points is `1/A`. The product @@ -485,7 +485,7 @@ cdef extern from "flint_wrap.h": # *flint_get_num_threads()*, while the default multieval version chooses # whether to use multithreading automatically. - void acb_dirichlet_platt_ws_interpolation(arb_t res, arf_t deriv, const arb_t t0, arb_srcptr p, const fmpz_t T, slong A, slong B, slong Ns_max, const arb_t H, slong sigma, slong prec) + void acb_dirichlet_platt_ws_interpolation(arb_t res, arf_t deriv, const arb_t t0, arb_srcptr p, const fmpz_t T, slong A, slong B, slong Ns_max, const arb_t H, slong sigma, slong prec) noexcept # Compute :func:`acb_dirichlet_platt_scaled_lambda` at *t0* by # Gaussian-windowed Whittaker-Shannon interpolation of points evaluated by # :func:`acb_dirichlet_platt_scaled_lambda_vec`. The derivative is @@ -496,11 +496,11 @@ cdef extern from "flint_wrap.h": # interpolation. *sigma* is an odd positive integer tuning parameter # `\sigma \in 2\mathbb{Z}_{>0}+1` used in computing error bounds. - slong _acb_dirichlet_platt_local_hardy_z_zeros(arb_ptr res, const fmpz_t n, slong len, const fmpz_t T, slong A, slong B, const arb_t h, const fmpz_t J, slong K, slong sigma_grid, slong Ns_max, const arb_t H, slong sigma_interp, slong prec) + slong _acb_dirichlet_platt_local_hardy_z_zeros(arb_ptr res, const fmpz_t n, slong len, const fmpz_t T, slong A, slong B, const arb_t h, const fmpz_t J, slong K, slong sigma_grid, slong Ns_max, const arb_t H, slong sigma_interp, slong prec) noexcept - slong acb_dirichlet_platt_local_hardy_z_zeros(arb_ptr res, const fmpz_t n, slong len, slong prec) + slong acb_dirichlet_platt_local_hardy_z_zeros(arb_ptr res, const fmpz_t n, slong len, slong prec) noexcept - slong acb_dirichlet_platt_hardy_z_zeros(arb_ptr res, const fmpz_t n, slong len, slong prec) + slong acb_dirichlet_platt_hardy_z_zeros(arb_ptr res, const fmpz_t n, slong len, slong prec) noexcept # Sets at most the first *len* entries of *res* to consecutive # zeros of the Hardy Z-function starting with the *n*-th zero. # The number of obtained consecutive zeros is returned. The first two @@ -513,7 +513,7 @@ cdef extern from "flint_wrap.h": # variants currently expect `10^4 \leq n \leq 10^{23}`. The user has the # option of multi-threading through *flint_set_num_threads(numthreads)*. - slong acb_dirichlet_platt_zeta_zeros(acb_ptr res, const fmpz_t n, slong len, slong prec) + slong acb_dirichlet_platt_zeta_zeros(acb_ptr res, const fmpz_t n, slong len, slong prec) noexcept # Sets at most the first *len* entries of *res* to consecutive # zeros of the Riemann zeta function starting with the *n*-th zero. # The number of obtained consecutive zeros is returned. It currently diff --git a/src/sage/libs/flint/acb_elliptic.pxd b/src/sage/libs/flint/acb_elliptic.pxd index 6424ab675a5..8fe3b2b571c 100644 --- a/src/sage/libs/flint/acb_elliptic.pxd +++ b/src/sage/libs/flint/acb_elliptic.pxd @@ -12,7 +12,7 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void acb_elliptic_k(acb_t res, const acb_t m, slong prec) + void acb_elliptic_k(acb_t res, const acb_t m, slong prec) noexcept # Computes the complete elliptic integral of the first kind # .. math :: # K(m) = \int_0^{\pi/2} \frac{dt}{\sqrt{1-m \sin^2 t}} @@ -20,18 +20,18 @@ cdef extern from "flint_wrap.h": # \frac{dt}{\left(\sqrt{1-t^2}\right)\left(\sqrt{1-mt^2}\right)} # using the arithmetic-geometric mean: `K(m) = \pi / (2 M(\sqrt{1-m}))`. - void acb_elliptic_k_jet(acb_ptr res, const acb_t m, slong len, slong prec) + void acb_elliptic_k_jet(acb_ptr res, const acb_t m, slong len, slong prec) noexcept # Sets the coefficients in the array *res* to the power series expansion of the # complete elliptic integral of the first kind at the point *m* truncated to # length *len*, i.e. `K(m+x) \in \mathbb{C}[[x]]`. - void _acb_elliptic_k_series(acb_ptr res, acb_srcptr m, slong mlen, slong len, slong prec) + void _acb_elliptic_k_series(acb_ptr res, acb_srcptr m, slong mlen, slong len, slong prec) noexcept - void acb_elliptic_k_series(acb_poly_t res, const acb_poly_t m, slong len, slong prec) + void acb_elliptic_k_series(acb_poly_t res, const acb_poly_t m, slong len, slong prec) noexcept # Sets *res* to the complete elliptic integral of the first kind of the # power series *m*, truncated to length *len*. - void acb_elliptic_e(acb_t res, const acb_t m, slong prec) + void acb_elliptic_e(acb_t res, const acb_t m, slong prec) noexcept # Computes the complete elliptic integral of the second kind # .. math :: # E(m) = \int_0^{\pi/2} \sqrt{1-m \sin^2 t} \, dt = @@ -40,7 +40,7 @@ cdef extern from "flint_wrap.h": # using `E(m) = (1-m)(2m K'(m) + K(m))` (where the prime # denotes a derivative, not a complementary integral). - void acb_elliptic_pi(acb_t res, const acb_t n, const acb_t m, slong prec) + void acb_elliptic_pi(acb_t res, const acb_t n, const acb_t m, slong prec) noexcept # Evaluates the complete elliptic integral of the third kind # .. math :: # \Pi(n, m) = \int_0^{\pi/2} @@ -51,7 +51,7 @@ cdef extern from "flint_wrap.h": # incomplete integral. It is therefore less efficient than the implementations # of the first two complete elliptic integrals which use the AGM. - void acb_elliptic_f(acb_t res, const acb_t phi, const acb_t m, int pi, slong prec) + void acb_elliptic_f(acb_t res, const acb_t phi, const acb_t m, int pi, slong prec) noexcept # Evaluates the Legendre incomplete elliptic integral of the first kind, # given by # .. math :: @@ -70,7 +70,7 @@ cdef extern from "flint_wrap.h": # when `\phi = \frac{\pi}{2}`; that is, # `F\left(\frac{\pi}{2}, m\right) = K(m)`. - void acb_elliptic_e_inc(acb_t res, const acb_t phi, const acb_t m, int pi, slong prec) + void acb_elliptic_e_inc(acb_t res, const acb_t phi, const acb_t m, int pi, slong prec) noexcept # Evaluates the Legendre incomplete elliptic integral of the second kind, # given by # .. math :: @@ -89,7 +89,7 @@ cdef extern from "flint_wrap.h": # when `\phi = \frac{\pi}{2}`; that is, # `E\left(\frac{\pi}{2}, m\right) = E(m)`. - void acb_elliptic_pi_inc(acb_t res, const acb_t n, const acb_t phi, const acb_t m, int pi, slong prec) + void acb_elliptic_pi_inc(acb_t res, const acb_t n, const acb_t phi, const acb_t m, int pi, slong prec) noexcept # Evaluates the Legendre incomplete elliptic integral of the third kind, # given by # .. math :: @@ -109,7 +109,7 @@ cdef extern from "flint_wrap.h": # when `\phi = \frac{\pi}{2}`; that is, # `\Pi\left(n, \frac{\pi}{2}, m\right) = \Pi(n, m)`. - void acb_elliptic_rf(acb_t res, const acb_t x, const acb_t y, const acb_t z, int flags, slong prec) + void acb_elliptic_rf(acb_t res, const acb_t x, const acb_t y, const acb_t z, int flags, slong prec) noexcept # Evaluates the Carlson symmetric elliptic integral of the first kind # .. math :: # R_F(x,y,z) = \frac{1}{2} @@ -129,7 +129,7 @@ cdef extern from "flint_wrap.h": # The *flags* parameter is reserved for future use and currently # does nothing. Passing 0 results in default behavior. - void acb_elliptic_rg(acb_t res, const acb_t x, const acb_t y, const acb_t z, int flags, slong prec) + void acb_elliptic_rg(acb_t res, const acb_t x, const acb_t y, const acb_t z, int flags, slong prec) noexcept # Evaluates the Carlson symmetric elliptic integral of the second kind # .. math :: # R_G(x,y,z) = \frac{1}{4} \int_0^{\infty} @@ -139,11 +139,11 @@ cdef extern from "flint_wrap.h": # The evaluation is done by expressing `R_G` in terms of `R_F` and `R_D`. # There are no restrictions on the variables. - void acb_elliptic_rj(acb_t res, const acb_t x, const acb_t y, const acb_t z, const acb_t p, int flags, slong prec) + void acb_elliptic_rj(acb_t res, const acb_t x, const acb_t y, const acb_t z, const acb_t p, int flags, slong prec) noexcept - void acb_elliptic_rj_carlson(acb_t res, const acb_t x, const acb_t y, const acb_t z, const acb_t p, int flags, slong prec) + void acb_elliptic_rj_carlson(acb_t res, const acb_t x, const acb_t y, const acb_t z, const acb_t p, int flags, slong prec) noexcept - void acb_elliptic_rj_integration(acb_t res, const acb_t x, const acb_t y, const acb_t z, const acb_t p, int flags, slong prec) + void acb_elliptic_rj_integration(acb_t res, const acb_t x, const acb_t y, const acb_t z, const acb_t p, int flags, slong prec) noexcept # Evaluates the Carlson symmetric elliptic integral of the third kind # .. math :: # R_J(x,y,z,p) = \frac{3}{2} @@ -175,12 +175,12 @@ cdef extern from "flint_wrap.h": # The *flags* parameter is reserved for future use and currently # does nothing. Passing 0 results in default behavior. - void acb_elliptic_rc1(acb_t res, const acb_t x, slong prec) + void acb_elliptic_rc1(acb_t res, const acb_t x, slong prec) noexcept # This helper function computes the special case # `R_C(1, 1+x) = \operatorname{atan}(\sqrt{x})/\sqrt{x} = {}_2F_1(1,1/2,3/2,-x)`, # which is needed in the evaluation of `R_J`. - void acb_elliptic_p(acb_t res, const acb_t z, const acb_t tau, slong prec) + void acb_elliptic_p(acb_t res, const acb_t z, const acb_t tau, slong prec) noexcept # Computes Weierstrass's elliptic function # .. math :: # \wp(z, \tau) = \frac{1}{z^2} + \sum_{n^2+m^2 \ne 0} @@ -192,33 +192,33 @@ cdef extern from "flint_wrap.h": # \frac{\theta_4^2(z,\tau)}{\theta_1^2(z,\tau)} - # \frac{\pi^2}{3} \left[ \theta_2^4(0,\tau) + \theta_3^4(0,\tau)\right]. - void acb_elliptic_p_prime(acb_t res, const acb_t z, const acb_t tau, slong prec) + void acb_elliptic_p_prime(acb_t res, const acb_t z, const acb_t tau, slong prec) noexcept # Computes the derivative `\wp'(z, \tau)` of Weierstrass's elliptic function `\wp(z, \tau)`. - void acb_elliptic_p_jet(acb_ptr res, const acb_t z, const acb_t tau, slong len, slong prec) + void acb_elliptic_p_jet(acb_ptr res, const acb_t z, const acb_t tau, slong len, slong prec) noexcept # Computes the formal power series `\wp(z + x, \tau) \in \mathbb{C}[[x]]`, # truncated to length *len*. In particular, with *len* = 2, simultaneously # computes `\wp(z, \tau), \wp'(z, \tau)` which together generate # the field of elliptic functions with periods 1 and `\tau`. - void _acb_elliptic_p_series(acb_ptr res, acb_srcptr z, slong zlen, const acb_t tau, slong len, slong prec) + void _acb_elliptic_p_series(acb_ptr res, acb_srcptr z, slong zlen, const acb_t tau, slong len, slong prec) noexcept - void acb_elliptic_p_series(acb_poly_t res, const acb_poly_t z, const acb_t tau, slong len, slong prec) + void acb_elliptic_p_series(acb_poly_t res, const acb_poly_t z, const acb_t tau, slong len, slong prec) noexcept # Sets *res* to the Weierstrass elliptic function of the power series *z*, # with periods 1 and *tau*, truncated to length *len*. - void acb_elliptic_invariants(acb_t g2, acb_t g3, const acb_t tau, slong prec) + void acb_elliptic_invariants(acb_t g2, acb_t g3, const acb_t tau, slong prec) noexcept # Computes the lattice invariants `g_2, g_3`. The Weierstrass elliptic # function satisfies the differential equation # `[\wp'(z, \tau)]^2 = 4 [\wp(z,\tau)]^3 - g_2 \wp(z,\tau) - g_3`. # Up to constant factors, the lattice invariants are the first two # Eisenstein series (see :func:`acb_modular_eisenstein`). - void acb_elliptic_roots(acb_t e1, acb_t e2, acb_t e3, const acb_t tau, slong prec) + void acb_elliptic_roots(acb_t e1, acb_t e2, acb_t e3, const acb_t tau, slong prec) noexcept # Computes the lattice roots `e_1, e_2, e_3`, which are the roots of # the polynomial `4z^3 - g_2 z - g_3`. - void acb_elliptic_inv_p(acb_t res, const acb_t z, const acb_t tau, slong prec) + void acb_elliptic_inv_p(acb_t res, const acb_t z, const acb_t tau, slong prec) noexcept # Computes the inverse of the Weierstrass elliptic function, which # satisfies `\wp(\wp^{-1}(z, \tau), \tau) = z`. This function is given # by the elliptic integral @@ -226,7 +226,7 @@ cdef extern from "flint_wrap.h": # \wp^{-1}(z, \tau) = \frac{1}{2} \int_z^{\infty} \frac{dt}{\sqrt{(t-e_1)(t-e_2)(t-e_3)}} # = R_F(z-e_1,z-e_2,z-e_3). - void acb_elliptic_zeta(acb_t res, const acb_t z, const acb_t tau, slong prec) + void acb_elliptic_zeta(acb_t res, const acb_t z, const acb_t tau, slong prec) noexcept # Computes the Weierstrass zeta function # .. math :: # \zeta(z, \tau) = \frac{1}{z} + \sum_{n^2+m^2 \ne 0} @@ -234,7 +234,7 @@ cdef extern from "flint_wrap.h": # which is quasiperiodic with `\zeta(z + 1, \tau) = \zeta(z, \tau) + \zeta(1/2, \tau)` # and `\zeta(z + \tau, \tau) = \zeta(z, \tau) + \zeta(\tau/2, \tau)`. - void acb_elliptic_sigma(acb_t res, const acb_t z, const acb_t tau, slong prec) + void acb_elliptic_sigma(acb_t res, const acb_t z, const acb_t tau, slong prec) noexcept # Computes the Weierstrass sigma function # .. math :: # \sigma(z, \tau) = z \prod_{n^2+m^2 \ne 0} diff --git a/src/sage/libs/flint/acb_hypgeom.pxd b/src/sage/libs/flint/acb_hypgeom.pxd index 23335f58407..b1498db6015 100644 --- a/src/sage/libs/flint/acb_hypgeom.pxd +++ b/src/sage/libs/flint/acb_hypgeom.pxd @@ -12,12 +12,12 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void acb_hypgeom_rising_ui_forward(acb_t res, const acb_t x, ulong n, slong prec) - void acb_hypgeom_rising_ui_bs(acb_t res, const acb_t x, ulong n, slong prec) - void acb_hypgeom_rising_ui_rs(acb_t res, const acb_t x, ulong n, ulong m, slong prec) - void acb_hypgeom_rising_ui_rec(acb_t res, const acb_t x, ulong n, slong prec) - void acb_hypgeom_rising_ui(acb_t res, const acb_t x, ulong n, slong prec) - void acb_hypgeom_rising(acb_t res, const acb_t x, const acb_t n, slong prec) + void acb_hypgeom_rising_ui_forward(acb_t res, const acb_t x, ulong n, slong prec) noexcept + void acb_hypgeom_rising_ui_bs(acb_t res, const acb_t x, ulong n, slong prec) noexcept + void acb_hypgeom_rising_ui_rs(acb_t res, const acb_t x, ulong n, ulong m, slong prec) noexcept + void acb_hypgeom_rising_ui_rec(acb_t res, const acb_t x, ulong n, slong prec) noexcept + void acb_hypgeom_rising_ui(acb_t res, const acb_t x, ulong n, slong prec) noexcept + void acb_hypgeom_rising(acb_t res, const acb_t x, const acb_t n, slong prec) noexcept # Computes the rising factorial `(x)_n`. # The *forward* version uses the forward recurrence. # The *bs* version uses binary splitting. @@ -29,10 +29,10 @@ cdef extern from "flint_wrap.h": # The default versions (*rising_ui* and *rising_ui*) choose an algorithm # automatically and may additionally fall back on the gamma function. - void acb_hypgeom_rising_ui_jet_powsum(acb_ptr res, const acb_t x, ulong n, slong len, slong prec) - void acb_hypgeom_rising_ui_jet_bs(acb_ptr res, const acb_t x, ulong n, slong len, slong prec) - void acb_hypgeom_rising_ui_jet_rs(acb_ptr res, const acb_t x, ulong n, ulong m, slong len, slong prec) - void acb_hypgeom_rising_ui_jet(acb_ptr res, const acb_t x, ulong n, slong len, slong prec) + void acb_hypgeom_rising_ui_jet_powsum(acb_ptr res, const acb_t x, ulong n, slong len, slong prec) noexcept + void acb_hypgeom_rising_ui_jet_bs(acb_ptr res, const acb_t x, ulong n, slong len, slong prec) noexcept + void acb_hypgeom_rising_ui_jet_rs(acb_ptr res, const acb_t x, ulong n, ulong m, slong len, slong prec) noexcept + void acb_hypgeom_rising_ui_jet(acb_ptr res, const acb_t x, ulong n, slong len, slong prec) noexcept # Computes the jet of the rising factorial `(x)_n`, truncated to length *len*. # In other words, constructs the polynomial `(X + x)_n \in \mathbb{R}[X]`, # truncated if `\operatorname{len} < n + 1` (and zero-extended @@ -44,7 +44,7 @@ cdef extern from "flint_wrap.h": # parameter *m* which can be set to zero to choose automatically. # The default version chooses an algorithm automatically. - void acb_hypgeom_log_rising_ui(acb_ptr res, const acb_t x, ulong n, slong prec) + void acb_hypgeom_log_rising_ui(acb_ptr res, const acb_t x, ulong n, slong prec) noexcept # Computes the log-rising factorial `\log \, (x)_n = \sum_{k=0}^{n-1} \log(x+k)`. # This first computes the ordinary rising factorial and then determines # the branch correction `2 \pi i m` with respect to the principal @@ -52,12 +52,12 @@ cdef extern from "flint_wrap.h": # floating-point arithmetic if this is safe; otherwise, # a direct computation of `\sum_{k=0}^{n-1} \arg(x+k)` is used as a fallback. - void acb_hypgeom_log_rising_ui_jet(acb_ptr res, const acb_t x, ulong n, slong len, slong prec) + void acb_hypgeom_log_rising_ui_jet(acb_ptr res, const acb_t x, ulong n, slong len, slong prec) noexcept # Computes the jet of the log-rising factorial `\log \, (x)_n`, # truncated to length *len*. - void acb_hypgeom_gamma_stirling_sum_horner(acb_t s, const acb_t z, slong N, slong prec) - void acb_hypgeom_gamma_stirling_sum_improved(acb_t s, const acb_t z, slong N, slong K, slong prec) + void acb_hypgeom_gamma_stirling_sum_horner(acb_t s, const acb_t z, slong N, slong prec) noexcept + void acb_hypgeom_gamma_stirling_sum_improved(acb_t s, const acb_t z, slong N, slong K, slong prec) noexcept # Sets *res* to the final sum in the Stirling series for the gamma function # truncated before the term with index *N*, i.e. computes # `\sum_{n=1}^{N-1} B_{2n} / (2n(2n-1) z^{2n-1})`. @@ -67,38 +67,38 @@ cdef extern from "flint_wrap.h": # using a splitting parameter *K* (which can be set to 0 to use a default # value). - void acb_hypgeom_gamma_stirling(acb_t res, const acb_t x, int reciprocal, slong prec) + void acb_hypgeom_gamma_stirling(acb_t res, const acb_t x, int reciprocal, slong prec) noexcept # Sets *res* to the gamma function of *x* computed using the Stirling # series together with argument reduction. If *reciprocal* is set, # the reciprocal gamma function is computed instead. - int acb_hypgeom_gamma_taylor(acb_t res, const acb_t x, int reciprocal, slong prec) + int acb_hypgeom_gamma_taylor(acb_t res, const acb_t x, int reciprocal, slong prec) noexcept # Attempts to compute the gamma function of *x* using Taylor series # together with argument reduction. This is only supported if *x* and *prec* # are both small enough. If successful, returns 1; otherwise, does nothing # and returns 0. If *reciprocal* is set, the reciprocal gamma function is # computed instead. - void acb_hypgeom_gamma(acb_t res, const acb_t x, slong prec) + void acb_hypgeom_gamma(acb_t res, const acb_t x, slong prec) noexcept # Sets *res* to the gamma function of *x* computed using a default # algorithm choice. - void acb_hypgeom_rgamma(acb_t res, const acb_t x, slong prec) + void acb_hypgeom_rgamma(acb_t res, const acb_t x, slong prec) noexcept # Sets *res* to the reciprocal gamma function of *x* computed using a default # algorithm choice. - void acb_hypgeom_lgamma(acb_t res, const acb_t x, slong prec) + void acb_hypgeom_lgamma(acb_t res, const acb_t x, slong prec) noexcept # Sets *res* to the principal branch of the log-gamma function of *x* # computed using a default algorithm choice. - void acb_hypgeom_pfq_bound_factor(mag_t C, acb_srcptr a, slong p, acb_srcptr b, slong q, const acb_t z, ulong n) + void acb_hypgeom_pfq_bound_factor(mag_t C, acb_srcptr a, slong p, acb_srcptr b, slong q, const acb_t z, ulong n) noexcept # Computes a factor *C* such that # `\left|\sum_{k=n}^{\infty} T(k)\right| \le C |T(n)|`. # See :ref:`algorithms_hypergeometric_convergent`. # As currently implemented, the bound becomes infinite when `n` is # too small, even if the series converges. - slong acb_hypgeom_pfq_choose_n(acb_srcptr a, slong p, acb_srcptr b, slong q, const acb_t z, slong prec) + slong acb_hypgeom_pfq_choose_n(acb_srcptr a, slong p, acb_srcptr b, slong q, const acb_t z, slong prec) noexcept # Heuristically attempts to choose a number of terms *n* to # sum of a hypergeometric series at a working precision of *prec* bits. # Uses double precision arithmetic internally. As currently implemented, @@ -110,15 +110,15 @@ cdef extern from "flint_wrap.h": # This function will also attempt to pick a reasonable # truncation point for divergent series. - void acb_hypgeom_pfq_sum_forward(acb_t s, acb_t t, acb_srcptr a, slong p, acb_srcptr b, slong q, const acb_t z, slong n, slong prec) + void acb_hypgeom_pfq_sum_forward(acb_t s, acb_t t, acb_srcptr a, slong p, acb_srcptr b, slong q, const acb_t z, slong n, slong prec) noexcept - void acb_hypgeom_pfq_sum_rs(acb_t s, acb_t t, acb_srcptr a, slong p, acb_srcptr b, slong q, const acb_t z, slong n, slong prec) + void acb_hypgeom_pfq_sum_rs(acb_t s, acb_t t, acb_srcptr a, slong p, acb_srcptr b, slong q, const acb_t z, slong n, slong prec) noexcept - void acb_hypgeom_pfq_sum_bs(acb_t s, acb_t t, acb_srcptr a, slong p, acb_srcptr b, slong q, const acb_t z, slong n, slong prec) + void acb_hypgeom_pfq_sum_bs(acb_t s, acb_t t, acb_srcptr a, slong p, acb_srcptr b, slong q, const acb_t z, slong n, slong prec) noexcept - void acb_hypgeom_pfq_sum_fme(acb_t s, acb_t t, acb_srcptr a, slong p, acb_srcptr b, slong q, const acb_t z, slong n, slong prec) + void acb_hypgeom_pfq_sum_fme(acb_t s, acb_t t, acb_srcptr a, slong p, acb_srcptr b, slong q, const acb_t z, slong n, slong prec) noexcept - void acb_hypgeom_pfq_sum(acb_t s, acb_t t, acb_srcptr a, slong p, acb_srcptr b, slong q, const acb_t z, slong n, slong prec) + void acb_hypgeom_pfq_sum(acb_t s, acb_t t, acb_srcptr a, slong p, acb_srcptr b, slong q, const acb_t z, slong n, slong prec) noexcept # Computes `s = \sum_{k=0}^{n-1} T(k)` and `t = T(n)`. # Does not allow aliasing between input and output variables. # We require `n \ge 0`. @@ -132,13 +132,13 @@ cdef extern from "flint_wrap.h": # The default version automatically chooses an algorithm # depending on the inputs. - void acb_hypgeom_pfq_sum_bs_invz(acb_t s, acb_t t, acb_srcptr a, slong p, acb_srcptr b, slong q, const acb_t w, slong n, slong prec) + void acb_hypgeom_pfq_sum_bs_invz(acb_t s, acb_t t, acb_srcptr a, slong p, acb_srcptr b, slong q, const acb_t w, slong n, slong prec) noexcept - void acb_hypgeom_pfq_sum_invz(acb_t s, acb_t t, acb_srcptr a, slong p, acb_srcptr b, slong q, const acb_t z, const acb_t w, slong n, slong prec) + void acb_hypgeom_pfq_sum_invz(acb_t s, acb_t t, acb_srcptr a, slong p, acb_srcptr b, slong q, const acb_t z, const acb_t w, slong n, slong prec) noexcept # Like :func:`acb_hypgeom_pfq_sum`, but taking advantage of # `w = 1/z` possibly having few bits. - void acb_hypgeom_pfq_direct(acb_t res, acb_srcptr a, slong p, acb_srcptr b, slong q, const acb_t z, slong n, slong prec) + void acb_hypgeom_pfq_direct(acb_t res, acb_srcptr a, slong p, acb_srcptr b, slong q, const acb_t z, slong n, slong prec) noexcept # Computes # .. math :: # {}_pf_{q}(z) @@ -149,13 +149,13 @@ cdef extern from "flint_wrap.h": # If `n < 0`, this function chooses a number of terms automatically # using :func:`acb_hypgeom_pfq_choose_n`. - void acb_hypgeom_pfq_series_sum_forward(acb_poly_t s, acb_poly_t t, const acb_poly_struct * a, slong p, const acb_poly_struct * b, slong q, const acb_poly_t z, int regularized, slong n, slong len, slong prec) + void acb_hypgeom_pfq_series_sum_forward(acb_poly_t s, acb_poly_t t, const acb_poly_struct * a, slong p, const acb_poly_struct * b, slong q, const acb_poly_t z, int regularized, slong n, slong len, slong prec) noexcept - void acb_hypgeom_pfq_series_sum_bs(acb_poly_t s, acb_poly_t t, const acb_poly_struct * a, slong p, const acb_poly_struct * b, slong q, const acb_poly_t z, int regularized, slong n, slong len, slong prec) + void acb_hypgeom_pfq_series_sum_bs(acb_poly_t s, acb_poly_t t, const acb_poly_struct * a, slong p, const acb_poly_struct * b, slong q, const acb_poly_t z, int regularized, slong n, slong len, slong prec) noexcept - void acb_hypgeom_pfq_series_sum_rs(acb_poly_t s, acb_poly_t t, const acb_poly_struct * a, slong p, const acb_poly_struct * b, slong q, const acb_poly_t z, int regularized, slong n, slong len, slong prec) + void acb_hypgeom_pfq_series_sum_rs(acb_poly_t s, acb_poly_t t, const acb_poly_struct * a, slong p, const acb_poly_struct * b, slong q, const acb_poly_t z, int regularized, slong n, slong len, slong prec) noexcept - void acb_hypgeom_pfq_series_sum(acb_poly_t s, acb_poly_t t, const acb_poly_struct * a, slong p, const acb_poly_struct * b, slong q, const acb_poly_t z, int regularized, slong n, slong len, slong prec) + void acb_hypgeom_pfq_series_sum(acb_poly_t s, acb_poly_t t, const acb_poly_struct * a, slong p, const acb_poly_struct * b, slong q, const acb_poly_t z, int regularized, slong n, slong len, slong prec) noexcept # Computes `s = \sum_{k=0}^{n-1} T(k)` and `t = T(n)` given parameters # and argument that are power series. # Does not allow aliasing between input and output variables. @@ -166,7 +166,7 @@ cdef extern from "flint_wrap.h": # binary splitting, rectangular splitting, and an automatic algorithm # choice. - void acb_hypgeom_pfq_series_direct(acb_poly_t res, const acb_poly_struct * a, slong p, const acb_poly_struct * b, slong q, const acb_poly_t z, int regularized, slong n, slong len, slong prec) + void acb_hypgeom_pfq_series_direct(acb_poly_t res, const acb_poly_struct * a, slong p, const acb_poly_struct * b, slong q, const acb_poly_t z, int regularized, slong n, slong len, slong prec) noexcept # Computes `{}_pf_{q}(z)` directly using the defining series, given # parameters and argument that are power series. # The result is a power series of length *len*. @@ -177,17 +177,17 @@ cdef extern from "flint_wrap.h": # If *regularized* is set, the regularized hypergeometric function # is computed instead. - void acb_hypgeom_u_asymp(acb_t res, const acb_t a, const acb_t b, const acb_t z, slong n, slong prec) + void acb_hypgeom_u_asymp(acb_t res, const acb_t a, const acb_t b, const acb_t z, slong n, slong prec) noexcept # Sets *res* to `U^{*}(a,b,z)` computed using *n* terms of the asymptotic series, # with a rigorous bound for the error included in the output. # We require `n \ge 0`. - int acb_hypgeom_u_use_asymp(const acb_t z, slong prec) + int acb_hypgeom_u_use_asymp(const acb_t z, slong prec) noexcept # Heuristically determines whether the asymptotic series can be used # to evaluate `U(a,b,z)` to *prec* accurate bits (assuming that *a* and *b* # are small). - void acb_hypgeom_pfq(acb_t res, acb_srcptr a, slong p, acb_srcptr b, slong q, const acb_t z, int regularized, slong prec) + void acb_hypgeom_pfq(acb_t res, acb_srcptr a, slong p, acb_srcptr b, slong q, const acb_t z, int regularized, slong prec) noexcept # Computes the generalized hypergeometric function `{}_pF_{q}(z)`, # or the regularized version if *regularized* is set. # This function automatically delegates to a specialized implementation @@ -199,7 +199,7 @@ cdef extern from "flint_wrap.h": # done ahead of time by the user in applications where duplicate # parameters are likely to occur. - void acb_hypgeom_u_1f1_series(acb_poly_t res, const acb_poly_t a, const acb_poly_t b, const acb_poly_t z, slong len, slong prec) + void acb_hypgeom_u_1f1_series(acb_poly_t res, const acb_poly_t a, const acb_poly_t b, const acb_poly_t z, slong len, slong prec) noexcept # Computes `U(a,b,z)` as a power series truncated to length *len*, # given `a, b, z \in \mathbb{C}[[x]]`. # If `b[0] \in \mathbb{Z}`, it computes one extra derivative and removes @@ -207,38 +207,38 @@ cdef extern from "flint_wrap.h": # As currently implemented, the output is indeterminate if `b` is nonexact # and contains an integer. - void acb_hypgeom_u_1f1(acb_t res, const acb_t a, const acb_t b, const acb_t z, slong prec) + void acb_hypgeom_u_1f1(acb_t res, const acb_t a, const acb_t b, const acb_t z, slong prec) noexcept # Computes `U(a,b,z)` as a sum of two convergent hypergeometric series. # If `b \in \mathbb{Z}`, it computes # the limit value via :func:`acb_hypgeom_u_1f1_series`. # As currently implemented, the output is indeterminate if `b` is nonexact # and contains an integer. - void acb_hypgeom_u(acb_t res, const acb_t a, const acb_t b, const acb_t z, slong prec) + void acb_hypgeom_u(acb_t res, const acb_t a, const acb_t b, const acb_t z, slong prec) noexcept # Computes `U(a,b,z)` using an automatic algorithm choice. The # function :func:`acb_hypgeom_u_asymp` is used # if `a` or `a-b+1` is a nonpositive integer (in which # case the asymptotic series terminates), or if *z* is sufficiently large. # Otherwise :func:`acb_hypgeom_u_1f1` is used. - void acb_hypgeom_m_asymp(acb_t res, const acb_t a, const acb_t b, const acb_t z, int regularized, slong prec) + void acb_hypgeom_m_asymp(acb_t res, const acb_t a, const acb_t b, const acb_t z, int regularized, slong prec) noexcept - void acb_hypgeom_m_1f1(acb_t res, const acb_t a, const acb_t b, const acb_t z, int regularized, slong prec) + void acb_hypgeom_m_1f1(acb_t res, const acb_t a, const acb_t b, const acb_t z, int regularized, slong prec) noexcept - void acb_hypgeom_m(acb_t res, const acb_t a, const acb_t b, const acb_t z, int regularized, slong prec) + void acb_hypgeom_m(acb_t res, const acb_t a, const acb_t b, const acb_t z, int regularized, slong prec) noexcept # Computes the confluent hypergeometric function # `M(a,b,z) = {}_1F_1(a,b,z)`, or # `\mathbf{M}(a,b,z) = \frac{1}{\Gamma(b)} {}_1F_1(a,b,z)` if *regularized* # is set. - void acb_hypgeom_1f1(acb_t res, const acb_t a, const acb_t b, const acb_t z, int regularized, slong prec) + void acb_hypgeom_1f1(acb_t res, const acb_t a, const acb_t b, const acb_t z, int regularized, slong prec) noexcept # Alias for :func:`acb_hypgeom_m`. - void acb_hypgeom_0f1_asymp(acb_t res, const acb_t a, const acb_t z, int regularized, slong prec) + void acb_hypgeom_0f1_asymp(acb_t res, const acb_t a, const acb_t z, int regularized, slong prec) noexcept - void acb_hypgeom_0f1_direct(acb_t res, const acb_t a, const acb_t z, int regularized, slong prec) + void acb_hypgeom_0f1_direct(acb_t res, const acb_t a, const acb_t z, int regularized, slong prec) noexcept - void acb_hypgeom_0f1(acb_t res, const acb_t a, const acb_t z, int regularized, slong prec) + void acb_hypgeom_0f1(acb_t res, const acb_t a, const acb_t z, int regularized, slong prec) noexcept # Computes the confluent hypergeometric function # `{}_0F_1(a,z)`, or `\frac{1}{\Gamma(a)} {}_0F_1(a,z)` if *regularized* # is set, using asymptotic expansions, direct summation, @@ -252,17 +252,17 @@ cdef extern from "flint_wrap.h": # Bessel-*I* function is used in the right half-plane, to avoid loss # of accuracy due to evaluating the square root on the branch cut. - void acb_hypgeom_erf_propagated_error(mag_t re, mag_t im, const acb_t z) + void acb_hypgeom_erf_propagated_error(mag_t re, mag_t im, const acb_t z) noexcept # Sets *re* and *im* to upper bounds for the error in the real and imaginary # part resulting from approximating the error function of *z* by # the error function evaluated at the midpoint of *z*. Uses # the first derivative. - void acb_hypgeom_erf_1f1a(acb_t res, const acb_t z, slong prec) + void acb_hypgeom_erf_1f1a(acb_t res, const acb_t z, slong prec) noexcept - void acb_hypgeom_erf_1f1b(acb_t res, const acb_t z, slong prec) + void acb_hypgeom_erf_1f1b(acb_t res, const acb_t z, slong prec) noexcept - void acb_hypgeom_erf_asymp(acb_t res, const acb_t z, int complementary, slong prec, slong prec2) + void acb_hypgeom_erf_asymp(acb_t res, const acb_t z, int complementary, slong prec, slong prec2) noexcept # Computes the error function respectively using # .. math :: # \operatorname{erf}(z) &= \frac{2z}{\sqrt{\pi}} @@ -278,42 +278,42 @@ cdef extern from "flint_wrap.h": # It also takes an extra flag *complementary*, computing the complementary # error function if set. - void acb_hypgeom_erf(acb_t res, const acb_t z, slong prec) + void acb_hypgeom_erf(acb_t res, const acb_t z, slong prec) noexcept # Computes the error function using an automatic algorithm choice. # If *z* is too small to use the asymptotic expansion, a working precision # sufficient to circumvent cancellation in the hypergeometric series is # determined automatically, and a bound for the propagated error is # computed with :func:`acb_hypgeom_erf_propagated_error`. - void _acb_hypgeom_erf_series(acb_ptr res, acb_srcptr z, slong zlen, slong len, slong prec) + void _acb_hypgeom_erf_series(acb_ptr res, acb_srcptr z, slong zlen, slong len, slong prec) noexcept - void acb_hypgeom_erf_series(acb_poly_t res, const acb_poly_t z, slong len, slong prec) + void acb_hypgeom_erf_series(acb_poly_t res, const acb_poly_t z, slong len, slong prec) noexcept # Computes the error function of the power series *z*, # truncated to length *len*. - void acb_hypgeom_erfc(acb_t res, const acb_t z, slong prec) + void acb_hypgeom_erfc(acb_t res, const acb_t z, slong prec) noexcept # Computes the complementary error function # `\operatorname{erfc}(z) = 1 - \operatorname{erf}(z)`. # This function avoids catastrophic cancellation for large positive *z*. - void _acb_hypgeom_erfc_series(acb_ptr res, acb_srcptr z, slong zlen, slong len, slong prec) + void _acb_hypgeom_erfc_series(acb_ptr res, acb_srcptr z, slong zlen, slong len, slong prec) noexcept - void acb_hypgeom_erfc_series(acb_poly_t res, const acb_poly_t z, slong len, slong prec) + void acb_hypgeom_erfc_series(acb_poly_t res, const acb_poly_t z, slong len, slong prec) noexcept # Computes the complementary error function of the power series *z*, # truncated to length *len*. - void acb_hypgeom_erfi(acb_t res, const acb_t z, slong prec) + void acb_hypgeom_erfi(acb_t res, const acb_t z, slong prec) noexcept # Computes the imaginary error function # `\operatorname{erfi}(z) = -i\operatorname{erf}(iz)`. This is a trivial wrapper # of :func:`acb_hypgeom_erf`. - void _acb_hypgeom_erfi_series(acb_ptr res, acb_srcptr z, slong zlen, slong len, slong prec) + void _acb_hypgeom_erfi_series(acb_ptr res, acb_srcptr z, slong zlen, slong len, slong prec) noexcept - void acb_hypgeom_erfi_series(acb_poly_t res, const acb_poly_t z, slong len, slong prec) + void acb_hypgeom_erfi_series(acb_poly_t res, const acb_poly_t z, slong len, slong prec) noexcept # Computes the imaginary error function of the power series *z*, # truncated to length *len*. - void acb_hypgeom_fresnel(acb_t res1, acb_t res2, const acb_t z, int normalized, slong prec) + void acb_hypgeom_fresnel(acb_t res1, acb_t res2, const acb_t z, int normalized, slong prec) noexcept # Sets *res1* to the Fresnel sine integral `S(z)` and *res2* to # the Fresnel cosine integral `C(z)`. Optionally, just a single function # can be computed by passing *NULL* as the other output variable. @@ -322,15 +322,15 @@ cdef extern from "flint_wrap.h": # *normalized* is 1 (the latter is the Abramowitz & Stegun convention). # `C(z)` is defined analogously. - void _acb_hypgeom_fresnel_series(acb_ptr res1, acb_ptr res2, acb_srcptr z, slong zlen, int normalized, slong len, slong prec) + void _acb_hypgeom_fresnel_series(acb_ptr res1, acb_ptr res2, acb_srcptr z, slong zlen, int normalized, slong len, slong prec) noexcept - void acb_hypgeom_fresnel_series(acb_poly_t res1, acb_poly_t res2, const acb_poly_t z, int normalized, slong len, slong prec) + void acb_hypgeom_fresnel_series(acb_poly_t res1, acb_poly_t res2, const acb_poly_t z, int normalized, slong len, slong prec) noexcept # Sets *res1* to the Fresnel sine integral and *res2* to the Fresnel # cosine integral of the power series *z*, truncated to length *len*. # Optionally, just a single function can be computed by passing *NULL* # as the other output variable. - void acb_hypgeom_bessel_j_asymp(acb_t res, const acb_t nu, const acb_t z, slong prec) + void acb_hypgeom_bessel_j_asymp(acb_t res, const acb_t nu, const acb_t z, slong prec) noexcept # Computes the Bessel function of the first kind # via :func:`acb_hypgeom_u_asymp`. # For all complex `\nu, z`, we have @@ -347,17 +347,17 @@ cdef extern from "flint_wrap.h": # `A_{\pm} = (\pm i)^{n} (2 \pi z)^{-1/2}`. # And if `\operatorname{Re}(z) > 0`, we have `A_{\pm} = \exp(\mp i [(2\nu+1)/4] \pi) (2 \pi z)^{-1/2}`. - void acb_hypgeom_bessel_j_0f1(acb_t res, const acb_t nu, const acb_t z, slong prec) + void acb_hypgeom_bessel_j_0f1(acb_t res, const acb_t nu, const acb_t z, slong prec) noexcept # Computes the Bessel function of the first kind from # .. math :: # J_{\nu}(z) = \frac{1}{\Gamma(\nu+1)} \left(\frac{z}{2}\right)^{\nu} # {}_0F_1\left(\nu+1, -\frac{z^2}{4}\right). - void acb_hypgeom_bessel_j(acb_t res, const acb_t nu, const acb_t z, slong prec) + void acb_hypgeom_bessel_j(acb_t res, const acb_t nu, const acb_t z, slong prec) noexcept # Computes the Bessel function of the first kind `J_{\nu}(z)` using # an automatic algorithm choice. - void acb_hypgeom_bessel_y(acb_t res, const acb_t nu, const acb_t z, slong prec) + void acb_hypgeom_bessel_y(acb_t res, const acb_t nu, const acb_t z, slong prec) noexcept # Computes the Bessel function of the second kind `Y_{\nu}(z)` from the # formula # .. math :: @@ -370,19 +370,19 @@ cdef extern from "flint_wrap.h": # As currently implemented, the output is indeterminate if `\nu` is nonexact # and contains an integer. - void acb_hypgeom_bessel_jy(acb_t res1, acb_t res2, const acb_t nu, const acb_t z, slong prec) + void acb_hypgeom_bessel_jy(acb_t res1, acb_t res2, const acb_t nu, const acb_t z, slong prec) noexcept # Sets *res1* to `J_{\nu}(z)` and *res2* to `Y_{\nu}(z)`, computed # simultaneously. From these values, the user can easily # construct the Bessel functions of the third kind (Hankel functions) # `H_{\nu}^{(1)}(z), H_{\nu}^{(2)}(z) = J_{\nu}(z) \pm i Y_{\nu}(z)`. - void acb_hypgeom_bessel_i_asymp(acb_t res, const acb_t nu, const acb_t z, int scaled, slong prec) + void acb_hypgeom_bessel_i_asymp(acb_t res, const acb_t nu, const acb_t z, int scaled, slong prec) noexcept - void acb_hypgeom_bessel_i_0f1(acb_t res, const acb_t nu, const acb_t z, int scaled, slong prec) + void acb_hypgeom_bessel_i_0f1(acb_t res, const acb_t nu, const acb_t z, int scaled, slong prec) noexcept - void acb_hypgeom_bessel_i(acb_t res, const acb_t nu, const acb_t z, slong prec) + void acb_hypgeom_bessel_i(acb_t res, const acb_t nu, const acb_t z, slong prec) noexcept - void acb_hypgeom_bessel_i_scaled(acb_t res, const acb_t nu, const acb_t z, slong prec) + void acb_hypgeom_bessel_i_scaled(acb_t res, const acb_t nu, const acb_t z, slong prec) noexcept # Computes the modified Bessel function of the first kind # `I_{\nu}(z) = z^{\nu} (iz)^{-\nu} J_{\nu}(iz)` respectively using # asymptotic series (see :func:`acb_hypgeom_bessel_j_asymp`), @@ -394,7 +394,7 @@ cdef extern from "flint_wrap.h": # The *scaled* version computes the function `e^{-z} I_{\nu}(z)`. The *asymp* # and *0f1* functions implement both variants and allow choosing with a flag. - void acb_hypgeom_bessel_k_asymp(acb_t res, const acb_t nu, const acb_t z, int scaled, slong prec) + void acb_hypgeom_bessel_k_asymp(acb_t res, const acb_t nu, const acb_t z, int scaled, slong prec) noexcept # Computes the modified Bessel function of the second kind via # via :func:`acb_hypgeom_u_asymp`. For all `\nu` and all `z \ne 0`, we have # .. math :: @@ -402,7 +402,7 @@ cdef extern from "flint_wrap.h": # U^{*}(\nu+\tfrac{1}{2}, 2\nu+1, 2z). # If *scaled* is set, computes the function `e^{z} K_{\nu}(z)`. - void acb_hypgeom_bessel_k_0f1_series(acb_poly_t res, const acb_poly_t nu, const acb_poly_t z, int scaled, slong len, slong prec) + void acb_hypgeom_bessel_k_0f1_series(acb_poly_t res, const acb_poly_t nu, const acb_poly_t z, int scaled, slong len, slong prec) noexcept # Computes the modified Bessel function of the second kind `K_{\nu}(z)` # as a power series truncated to length *len*, # given `\nu, z \in \mathbb{C}[[x]]`. Uses the formula @@ -420,7 +420,7 @@ cdef extern from "flint_wrap.h": # and contains an integer. # If *scaled* is set, computes the function `e^{z} K_{\nu}(z)`. - void acb_hypgeom_bessel_k_0f1(acb_t res, const acb_t nu, const acb_t z, int scaled, slong prec) + void acb_hypgeom_bessel_k_0f1(acb_t res, const acb_t nu, const acb_t z, int scaled, slong prec) noexcept # Computes the modified Bessel function of the second kind from # .. math :: # K_{\nu}(z) = \frac{1}{2} \left[ @@ -438,30 +438,30 @@ cdef extern from "flint_wrap.h": # and contains an integer. # If *scaled* is set, computes the function `e^{z} K_{\nu}(z)`. - void acb_hypgeom_bessel_k(acb_t res, const acb_t nu, const acb_t z, slong prec) + void acb_hypgeom_bessel_k(acb_t res, const acb_t nu, const acb_t z, slong prec) noexcept # Computes the modified Bessel function of the second kind `K_{\nu}(z)` using # an automatic algorithm choice. - void acb_hypgeom_bessel_k_scaled(acb_t res, const acb_t nu, const acb_t z, slong prec) + void acb_hypgeom_bessel_k_scaled(acb_t res, const acb_t nu, const acb_t z, slong prec) noexcept # Computes the function `e^{z} K_{\nu}(z)`. - void acb_hypgeom_airy_direct(acb_t ai, acb_t ai_prime, acb_t bi, acb_t bi_prime, const acb_t z, slong n, slong prec) + void acb_hypgeom_airy_direct(acb_t ai, acb_t ai_prime, acb_t bi, acb_t bi_prime, const acb_t z, slong n, slong prec) noexcept # Computes the Airy functions using direct series expansions truncated at *n* terms. # Error bounds are included in the output. - void acb_hypgeom_airy_asymp(acb_t ai, acb_t ai_prime, acb_t bi, acb_t bi_prime, const acb_t z, slong n, slong prec) + void acb_hypgeom_airy_asymp(acb_t ai, acb_t ai_prime, acb_t bi, acb_t bi_prime, const acb_t z, slong n, slong prec) noexcept # Computes the Airy functions using asymptotic expansions truncated at *n* terms. # Error bounds are included in the output. # For details about how the error bounds are computed, see # :ref:`algorithms_hypergeometric_asymptotic_airy`. - void acb_hypgeom_airy_bound(mag_t ai, mag_t ai_prime, mag_t bi, mag_t bi_prime, const acb_t z) + void acb_hypgeom_airy_bound(mag_t ai, mag_t ai_prime, mag_t bi, mag_t bi_prime, const acb_t z) noexcept # Computes bounds for the Airy functions using first-order asymptotic # expansions together with error bounds. This function uses some # shortcuts to make it slightly faster than calling # :func:`acb_hypgeom_airy_asymp` with `n = 1`. - void acb_hypgeom_airy(acb_t ai, acb_t ai_prime, acb_t bi, acb_t bi_prime, const acb_t z, slong prec) + void acb_hypgeom_airy(acb_t ai, acb_t ai_prime, acb_t bi, acb_t bi_prime, const acb_t z, slong prec) noexcept # Computes Airy functions using an automatic algorithm choice. # We use :func:`acb_hypgeom_airy_asymp` whenever this gives full accuracy # and :func:`acb_hypgeom_airy_direct` otherwise. @@ -476,7 +476,7 @@ cdef extern from "flint_wrap.h": # bound the propagated error using derivatives. Derivatives are # bounded using :func:`acb_hypgeom_airy_bound`. - void acb_hypgeom_airy_jet(acb_ptr ai, acb_ptr bi, const acb_t z, slong len, slong prec) + void acb_hypgeom_airy_jet(acb_ptr ai, acb_ptr bi, const acb_t z, slong len, slong prec) noexcept # Writes to *ai* and *bi* the respective Taylor expansions of the Airy functions # at the point *z*, truncated to length *len*. # Either of the outputs can be *NULL* to avoid computing that function. @@ -486,37 +486,37 @@ cdef extern from "flint_wrap.h": # easily obtained by computing one extra coefficient and differentiating # the output with :func:`_acb_poly_derivative`. - void _acb_hypgeom_airy_series(acb_ptr ai, acb_ptr ai_prime, acb_ptr bi, acb_ptr bi_prime, acb_srcptr z, slong zlen, slong len, slong prec) + void _acb_hypgeom_airy_series(acb_ptr ai, acb_ptr ai_prime, acb_ptr bi, acb_ptr bi_prime, acb_srcptr z, slong zlen, slong len, slong prec) noexcept - void acb_hypgeom_airy_series(acb_poly_t ai, acb_poly_t ai_prime, acb_poly_t bi, acb_poly_t bi_prime, const acb_poly_t z, slong len, slong prec) + void acb_hypgeom_airy_series(acb_poly_t ai, acb_poly_t ai_prime, acb_poly_t bi, acb_poly_t bi_prime, const acb_poly_t z, slong len, slong prec) noexcept # Computes the Airy functions evaluated at the power series *z*, # truncated to length *len*. As with the other Airy methods, any of the # outputs can be *NULL*. - void acb_hypgeom_coulomb(acb_t F, acb_t G, acb_t Hpos, acb_t Hneg, const acb_t l, const acb_t eta, const acb_t z, slong prec) + void acb_hypgeom_coulomb(acb_t F, acb_t G, acb_t Hpos, acb_t Hneg, const acb_t l, const acb_t eta, const acb_t z, slong prec) noexcept # Writes to *F*, *G*, *Hpos*, *Hneg* the values of the respective # Coulomb wave functions. Any of the outputs can be *NULL*. - void acb_hypgeom_coulomb_jet(acb_ptr F, acb_ptr G, acb_ptr Hpos, acb_ptr Hneg, const acb_t l, const acb_t eta, const acb_t z, slong len, slong prec) + void acb_hypgeom_coulomb_jet(acb_ptr F, acb_ptr G, acb_ptr Hpos, acb_ptr Hneg, const acb_t l, const acb_t eta, const acb_t z, slong len, slong prec) noexcept # Writes to *F*, *G*, *Hpos*, *Hneg* the respective Taylor expansions of the # Coulomb wave functions at the point *z*, truncated to length *len*. # Any of the outputs can be *NULL*. - void _acb_hypgeom_coulomb_series(acb_ptr F, acb_ptr G, acb_ptr Hpos, acb_ptr Hneg, const acb_t l, const acb_t eta, acb_srcptr z, slong zlen, slong len, slong prec) + void _acb_hypgeom_coulomb_series(acb_ptr F, acb_ptr G, acb_ptr Hpos, acb_ptr Hneg, const acb_t l, const acb_t eta, acb_srcptr z, slong zlen, slong len, slong prec) noexcept - void acb_hypgeom_coulomb_series(acb_poly_t F, acb_poly_t G, acb_poly_t Hpos, acb_poly_t Hneg, const acb_t l, const acb_t eta, const acb_poly_t z, slong len, slong prec) + void acb_hypgeom_coulomb_series(acb_poly_t F, acb_poly_t G, acb_poly_t Hpos, acb_poly_t Hneg, const acb_t l, const acb_t eta, const acb_poly_t z, slong len, slong prec) noexcept # Computes the Coulomb wave functions evaluated at the power series *z*, # truncated to length *len*. Any of the outputs can be *NULL*. - void acb_hypgeom_gamma_upper_asymp(acb_t res, const acb_t s, const acb_t z, int regularized, slong prec) + void acb_hypgeom_gamma_upper_asymp(acb_t res, const acb_t s, const acb_t z, int regularized, slong prec) noexcept - void acb_hypgeom_gamma_upper_1f1a(acb_t res, const acb_t s, const acb_t z, int regularized, slong prec) + void acb_hypgeom_gamma_upper_1f1a(acb_t res, const acb_t s, const acb_t z, int regularized, slong prec) noexcept - void acb_hypgeom_gamma_upper_1f1b(acb_t res, const acb_t s, const acb_t z, int regularized, slong prec) + void acb_hypgeom_gamma_upper_1f1b(acb_t res, const acb_t s, const acb_t z, int regularized, slong prec) noexcept - void acb_hypgeom_gamma_upper_singular(acb_t res, slong s, const acb_t z, int regularized, slong prec) + void acb_hypgeom_gamma_upper_singular(acb_t res, slong s, const acb_t z, int regularized, slong prec) noexcept - void acb_hypgeom_gamma_upper(acb_t res, const acb_t s, const acb_t z, int regularized, slong prec) + void acb_hypgeom_gamma_upper(acb_t res, const acb_t s, const acb_t z, int regularized, slong prec) noexcept # If *regularized* is 0, computes the upper incomplete gamma function # `\Gamma(s,z)`. # If *regularized* is 1, computes the regularized upper incomplete @@ -542,15 +542,15 @@ cdef extern from "flint_wrap.h": # The *singular* version evaluates the finite sum directly and therefore # assumes that *s* is not too large. - void _acb_hypgeom_gamma_upper_series(acb_ptr res, const acb_t s, acb_srcptr z, slong zlen, int regularized, slong n, slong prec) + void _acb_hypgeom_gamma_upper_series(acb_ptr res, const acb_t s, acb_srcptr z, slong zlen, int regularized, slong n, slong prec) noexcept - void acb_hypgeom_gamma_upper_series(acb_poly_t res, const acb_t s, const acb_poly_t z, int regularized, slong n, slong prec) + void acb_hypgeom_gamma_upper_series(acb_poly_t res, const acb_t s, const acb_poly_t z, int regularized, slong n, slong prec) noexcept # Sets *res* to an upper incomplete gamma function where *s* is # a constant and *z* is a power series, truncated to length *n*. # The *regularized* argument has the same interpretation as in # :func:`acb_hypgeom_gamma_upper`. - void acb_hypgeom_gamma_lower(acb_t res, const acb_t s, const acb_t z, int regularized, slong prec) + void acb_hypgeom_gamma_lower(acb_t res, const acb_t s, const acb_t z, int regularized, slong prec) noexcept # If *regularized* is 0, computes the lower incomplete gamma function # `\gamma(s,z) = \frac{z^s}{s} {}_1F_1(s, s+1, -z)`. # If *regularized* is 1, computes the regularized lower incomplete @@ -558,15 +558,15 @@ cdef extern from "flint_wrap.h": # If *regularized* is 2, computes a further regularized lower incomplete # gamma function `\gamma^{*}(s,z) = z^{-s} P(s,z)`. - void _acb_hypgeom_gamma_lower_series(acb_ptr res, const acb_t s, acb_srcptr z, slong zlen, int regularized, slong n, slong prec) + void _acb_hypgeom_gamma_lower_series(acb_ptr res, const acb_t s, acb_srcptr z, slong zlen, int regularized, slong n, slong prec) noexcept - void acb_hypgeom_gamma_lower_series(acb_poly_t res, const acb_t s, const acb_poly_t z, int regularized, slong n, slong prec) + void acb_hypgeom_gamma_lower_series(acb_poly_t res, const acb_t s, const acb_poly_t z, int regularized, slong n, slong prec) noexcept # Sets *res* to an lower incomplete gamma function where *s* is # a constant and *z* is a power series, truncated to length *n*. # The *regularized* argument has the same interpretation as in # :func:`acb_hypgeom_gamma_lower`. - void acb_hypgeom_beta_lower(acb_t res, const acb_t a, const acb_t b, const acb_t z, int regularized, slong prec) + void acb_hypgeom_beta_lower(acb_t res, const acb_t a, const acb_t b, const acb_t z, int regularized, slong prec) noexcept # Computes the (lower) incomplete beta function, defined by # `B(a,b;z) = \int_0^z t^{a-1} (1-t)^{b-1}`, # optionally the regularized incomplete beta function @@ -581,24 +581,24 @@ cdef extern from "flint_wrap.h": # for nonpositive integer *a*, and *I* is undefined for nonpositive integer # `a + b`. - void _acb_hypgeom_beta_lower_series(acb_ptr res, const acb_t a, const acb_t b, acb_srcptr z, slong zlen, int regularized, slong n, slong prec) + void _acb_hypgeom_beta_lower_series(acb_ptr res, const acb_t a, const acb_t b, acb_srcptr z, slong zlen, int regularized, slong n, slong prec) noexcept - void acb_hypgeom_beta_lower_series(acb_poly_t res, const acb_t a, const acb_t b, const acb_poly_t z, int regularized, slong n, slong prec) + void acb_hypgeom_beta_lower_series(acb_poly_t res, const acb_t a, const acb_t b, const acb_poly_t z, int regularized, slong n, slong prec) noexcept # Sets *res* to the lower incomplete beta function `B(a,b;z)` (optionally # the regularized version `I(a,b;z)`) where *a* and *b* are constants # and *z* is a power series, truncating the result to length *n*. # The underscore method requires positive lengths and does not support # aliasing. - void acb_hypgeom_expint(acb_t res, const acb_t s, const acb_t z, slong prec) + void acb_hypgeom_expint(acb_t res, const acb_t s, const acb_t z, slong prec) noexcept # Computes the generalized exponential integral `E_s(z)`. This is a # trivial wrapper of :func:`acb_hypgeom_gamma_upper`. - void acb_hypgeom_ei_asymp(acb_t res, const acb_t z, slong prec) + void acb_hypgeom_ei_asymp(acb_t res, const acb_t z, slong prec) noexcept - void acb_hypgeom_ei_2f2(acb_t res, const acb_t z, slong prec) + void acb_hypgeom_ei_2f2(acb_t res, const acb_t z, slong prec) noexcept - void acb_hypgeom_ei(acb_t res, const acb_t z, slong prec) + void acb_hypgeom_ei(acb_t res, const acb_t z, slong prec) noexcept # Computes the exponential integral `\operatorname{Ei}(z)`, respectively # using # .. math :: @@ -609,17 +609,17 @@ cdef extern from "flint_wrap.h": # + \frac{1}{2} \left(\log(z) - \log\left(\frac{1}{z}\right) \right) # and an automatic algorithm choice. - void _acb_hypgeom_ei_series(acb_ptr res, acb_srcptr z, slong zlen, slong len, slong prec) + void _acb_hypgeom_ei_series(acb_ptr res, acb_srcptr z, slong zlen, slong len, slong prec) noexcept - void acb_hypgeom_ei_series(acb_poly_t res, const acb_poly_t z, slong len, slong prec) + void acb_hypgeom_ei_series(acb_poly_t res, const acb_poly_t z, slong len, slong prec) noexcept # Computes the exponential integral of the power series *z*, # truncated to length *len*. - void acb_hypgeom_si_asymp(acb_t res, const acb_t z, slong prec) + void acb_hypgeom_si_asymp(acb_t res, const acb_t z, slong prec) noexcept - void acb_hypgeom_si_1f2(acb_t res, const acb_t z, slong prec) + void acb_hypgeom_si_1f2(acb_t res, const acb_t z, slong prec) noexcept - void acb_hypgeom_si(acb_t res, const acb_t z, slong prec) + void acb_hypgeom_si(acb_t res, const acb_t z, slong prec) noexcept # Computes the sine integral `\operatorname{Si}(z)`, respectively # using # .. math :: @@ -630,17 +630,17 @@ cdef extern from "flint_wrap.h": # \operatorname{Si}(z) = z {}_1F_2(\tfrac{1}{2}; \tfrac{3}{2}, \tfrac{3}{2}; -\tfrac{z^2}{4}) # and an automatic algorithm choice. - void _acb_hypgeom_si_series(acb_ptr res, acb_srcptr z, slong zlen, slong len, slong prec) + void _acb_hypgeom_si_series(acb_ptr res, acb_srcptr z, slong zlen, slong len, slong prec) noexcept - void acb_hypgeom_si_series(acb_poly_t res, const acb_poly_t z, slong len, slong prec) + void acb_hypgeom_si_series(acb_poly_t res, const acb_poly_t z, slong len, slong prec) noexcept # Computes the sine integral of the power series *z*, # truncated to length *len*. - void acb_hypgeom_ci_asymp(acb_t res, const acb_t z, slong prec) + void acb_hypgeom_ci_asymp(acb_t res, const acb_t z, slong prec) noexcept - void acb_hypgeom_ci_2f3(acb_t res, const acb_t z, slong prec) + void acb_hypgeom_ci_2f3(acb_t res, const acb_t z, slong prec) noexcept - void acb_hypgeom_ci(acb_t res, const acb_t z, slong prec) + void acb_hypgeom_ci(acb_t res, const acb_t z, slong prec) noexcept # Computes the cosine integral `\operatorname{Ci}(z)`, respectively # using # .. math :: @@ -653,28 +653,28 @@ cdef extern from "flint_wrap.h": # + \log(z) + \gamma # and an automatic algorithm choice. - void _acb_hypgeom_ci_series(acb_ptr res, acb_srcptr z, slong zlen, slong len, slong prec) + void _acb_hypgeom_ci_series(acb_ptr res, acb_srcptr z, slong zlen, slong len, slong prec) noexcept - void acb_hypgeom_ci_series(acb_poly_t res, const acb_poly_t z, slong len, slong prec) + void acb_hypgeom_ci_series(acb_poly_t res, const acb_poly_t z, slong len, slong prec) noexcept # Computes the cosine integral of the power series *z*, # truncated to length *len*. - void acb_hypgeom_shi(acb_t res, const acb_t z, slong prec) + void acb_hypgeom_shi(acb_t res, const acb_t z, slong prec) noexcept # Computes the hyperbolic sine integral # `\operatorname{Shi}(z) = -i \operatorname{Si}(iz)`. # This is a trivial wrapper of :func:`acb_hypgeom_si`. - void _acb_hypgeom_shi_series(acb_ptr res, acb_srcptr z, slong zlen, slong len, slong prec) + void _acb_hypgeom_shi_series(acb_ptr res, acb_srcptr z, slong zlen, slong len, slong prec) noexcept - void acb_hypgeom_shi_series(acb_poly_t res, const acb_poly_t z, slong len, slong prec) + void acb_hypgeom_shi_series(acb_poly_t res, const acb_poly_t z, slong len, slong prec) noexcept # Computes the hyperbolic sine integral of the power series *z*, # truncated to length *len*. - void acb_hypgeom_chi_asymp(acb_t res, const acb_t z, slong prec) + void acb_hypgeom_chi_asymp(acb_t res, const acb_t z, slong prec) noexcept - void acb_hypgeom_chi_2f3(acb_t res, const acb_t z, slong prec) + void acb_hypgeom_chi_2f3(acb_t res, const acb_t z, slong prec) noexcept - void acb_hypgeom_chi(acb_t res, const acb_t z, slong prec) + void acb_hypgeom_chi(acb_t res, const acb_t z, slong prec) noexcept # Computes the hyperbolic cosine integral `\operatorname{Chi}(z)`, respectively # using # .. math :: @@ -687,39 +687,39 @@ cdef extern from "flint_wrap.h": # + \log(z) + \gamma # and an automatic algorithm choice. - void _acb_hypgeom_chi_series(acb_ptr res, acb_srcptr z, slong zlen, slong len, slong prec) + void _acb_hypgeom_chi_series(acb_ptr res, acb_srcptr z, slong zlen, slong len, slong prec) noexcept - void acb_hypgeom_chi_series(acb_poly_t res, const acb_poly_t z, slong len, slong prec) + void acb_hypgeom_chi_series(acb_poly_t res, const acb_poly_t z, slong len, slong prec) noexcept # Computes the hyperbolic cosine integral of the power series *z*, # truncated to length *len*. - void acb_hypgeom_li(acb_t res, const acb_t z, int offset, slong prec) + void acb_hypgeom_li(acb_t res, const acb_t z, int offset, slong prec) noexcept # If *offset* is zero, computes the logarithmic integral # `\operatorname{li}(z) = \operatorname{Ei}(\log(z))`. # If *offset* is nonzero, computes the offset logarithmic integral # `\operatorname{Li}(z) = \operatorname{li}(z) - \operatorname{li}(2)`. - void _acb_hypgeom_li_series(acb_ptr res, acb_srcptr z, slong zlen, int offset, slong len, slong prec) + void _acb_hypgeom_li_series(acb_ptr res, acb_srcptr z, slong zlen, int offset, slong len, slong prec) noexcept - void acb_hypgeom_li_series(acb_poly_t res, const acb_poly_t z, int offset, slong len, slong prec) + void acb_hypgeom_li_series(acb_poly_t res, const acb_poly_t z, int offset, slong len, slong prec) noexcept # Computes the logarithmic integral (optionally the offset version) # of the power series *z*, truncated to length *len*. - void acb_hypgeom_2f1_continuation(acb_t res0, acb_t res1, const acb_t a, const acb_t b, const acb_t c, const acb_t z0, const acb_t z1, const acb_t f0, const acb_t f1, slong prec) + void acb_hypgeom_2f1_continuation(acb_t res0, acb_t res1, const acb_t a, const acb_t b, const acb_t c, const acb_t z0, const acb_t z1, const acb_t f0, const acb_t f1, slong prec) noexcept # Given `F(z_0), F'(z_0)` in *f0*, *f1*, sets *res0* and *res1* to `F(z_1), F'(z_1)` # by integrating the hypergeometric differential equation along a straight-line path. # The evaluation points should be well-isolated from the singular points 0 and 1. - void acb_hypgeom_2f1_series_direct(acb_poly_t res, const acb_poly_t a, const acb_poly_t b, const acb_poly_t c, const acb_poly_t z, int regularized, slong len, slong prec) + void acb_hypgeom_2f1_series_direct(acb_poly_t res, const acb_poly_t a, const acb_poly_t b, const acb_poly_t c, const acb_poly_t z, int regularized, slong len, slong prec) noexcept # Computes `F(z)` of the given power series truncated to length *len*, using # direct summation of the hypergeometric series. - void acb_hypgeom_2f1_direct(acb_t res, const acb_t a, const acb_t b, const acb_t c, const acb_t z, int regularized, slong prec) + void acb_hypgeom_2f1_direct(acb_t res, const acb_t a, const acb_t b, const acb_t c, const acb_t z, int regularized, slong prec) noexcept # Computes `F(z)` using direct summation of the hypergeometric series. - void acb_hypgeom_2f1_transform(acb_t res, const acb_t a, const acb_t b, const acb_t c, const acb_t z, int flags, int which, slong prec) + void acb_hypgeom_2f1_transform(acb_t res, const acb_t a, const acb_t b, const acb_t c, const acb_t z, int flags, int which, slong prec) noexcept - void acb_hypgeom_2f1_transform_limit(acb_t res, const acb_t a, const acb_t b, const acb_t c, const acb_t z, int regularized, int which, slong prec) + void acb_hypgeom_2f1_transform_limit(acb_t res, const acb_t a, const acb_t b, const acb_t c, const acb_t z, int regularized, int which, slong prec) noexcept # Computes `F(z)` using an argument transformation determined by the flag *which*. # Legal values are 1 for `z/(z-1)`, # 2 for `1/z`, 3 for `1/(1-z)`, 4 for `1-z`, and 5 for `1-1/z`. @@ -729,18 +729,18 @@ cdef extern from "flint_wrap.h": # In these cases, it computes the correct limit value. # See :func:`acb_hypgeom_2f1` for the meaning of *flags*. - void acb_hypgeom_2f1_corner(acb_t res, const acb_t a, const acb_t b, const acb_t c, const acb_t z, int regularized, slong prec) + void acb_hypgeom_2f1_corner(acb_t res, const acb_t a, const acb_t b, const acb_t c, const acb_t z, int regularized, slong prec) noexcept # Computes `F(z)` near the corner cases `\exp(\pm \pi i \sqrt{3})` # by analytic continuation. - int acb_hypgeom_2f1_choose(const acb_t z) + int acb_hypgeom_2f1_choose(const acb_t z) noexcept # Chooses a method to compute the function based on the location of *z* # in the complex plane. If the return value is 0, direct summation should be used. # If the return value is 1 to 5, the transformation with this index in # :func:`acb_hypgeom_2f1_transform` should be used. # If the return value is 6, the corner case algorithm should be used. - void acb_hypgeom_2f1(acb_t res, const acb_t a, const acb_t b, const acb_t c, const acb_t z, int flags, slong prec) + void acb_hypgeom_2f1(acb_t res, const acb_t a, const acb_t b, const acb_t c, const acb_t z, int flags, slong prec) noexcept # Computes `F(z)` or `\operatorname{\mathbf{F}}(z)` # using an automatic algorithm choice. # The following bit fields can be set in *flags*: @@ -764,9 +764,9 @@ cdef extern from "flint_wrap.h": # Currently, only the *AB* and *ABC* flags are used this way; # the *AC* and *BC* flags might be used in the future. - void acb_hypgeom_chebyshev_t(acb_t res, const acb_t n, const acb_t z, slong prec) + void acb_hypgeom_chebyshev_t(acb_t res, const acb_t n, const acb_t z, slong prec) noexcept - void acb_hypgeom_chebyshev_u(acb_t res, const acb_t n, const acb_t z, slong prec) + void acb_hypgeom_chebyshev_u(acb_t res, const acb_t n, const acb_t z, slong prec) noexcept # Computes the Chebyshev polynomial (or Chebyshev function) of first or second kind # .. math :: # T_n(z) = {}_2F_1\left(-n,n,\frac{1}{2},\frac{1-z}{2}\right) @@ -777,7 +777,7 @@ cdef extern from "flint_wrap.h": # For word-size integer *n*, :func:`acb_chebyshev_t_ui` and # :func:`acb_chebyshev_u_ui` are called. - void acb_hypgeom_jacobi_p(acb_t res, const acb_t n, const acb_t a, const acb_t b, const acb_t z, slong prec) + void acb_hypgeom_jacobi_p(acb_t res, const acb_t n, const acb_t a, const acb_t b, const acb_t z, slong prec) noexcept # Computes the Jacobi polynomial (or Jacobi function) # .. math :: # P_n^{(a,b)}(z)=\frac{(a+1)_n}{\Gamma(n+1)} {}_2F_1\left(-n,n+a+b+1,a+1,\frac{1-z}{2}\right). @@ -786,7 +786,7 @@ cdef extern from "flint_wrap.h": # is undefined. In such cases, the polynomial is evaluated using # direct methods. - void acb_hypgeom_gegenbauer_c(acb_t res, const acb_t n, const acb_t m, const acb_t z, slong prec) + void acb_hypgeom_gegenbauer_c(acb_t res, const acb_t n, const acb_t m, const acb_t z, slong prec) noexcept # Computes the Gegenbauer polynomial (or Gegenbauer function) # .. math :: # C_n^{m}(z)=\frac{(2m)_n}{\Gamma(n+1)} {}_2F_1\left(-n,2m+n,m+\frac{1}{2},\frac{1-z}{2}\right). @@ -795,7 +795,7 @@ cdef extern from "flint_wrap.h": # is undefined. In such cases, the polynomial is evaluated using # direct methods. - void acb_hypgeom_laguerre_l(acb_t res, const acb_t n, const acb_t m, const acb_t z, slong prec) + void acb_hypgeom_laguerre_l(acb_t res, const acb_t n, const acb_t m, const acb_t z, slong prec) noexcept # Computes the Laguerre polynomial (or Laguerre function) # .. math :: # L_n^{m}(z)=\frac{(m+1)_n}{\Gamma(n+1)} {}_1F_1\left(-n,m+1,z\right). @@ -809,7 +809,7 @@ cdef extern from "flint_wrap.h": # case with the recurrence relation `L_{n-1}^m(z) + L_n^{m-1}(z) = L_n^m(z)`. # Currently, we leave this case undefined (returning indeterminate). - void acb_hypgeom_hermite_h(acb_t res, const acb_t n, const acb_t z, slong prec) + void acb_hypgeom_hermite_h(acb_t res, const acb_t n, const acb_t z, slong prec) noexcept # Computes the Hermite polynomial (or Hermite function) # .. math :: # H_n(z) = 2^n \sqrt{\pi} \left( @@ -817,7 +817,7 @@ cdef extern from "flint_wrap.h": # - # \frac{2z}{\Gamma(-n/2)} {}_1F_1\left(\frac{1-n}{2},\frac{3}{2},z^2\right)\right). - void acb_hypgeom_legendre_p(acb_t res, const acb_t n, const acb_t m, const acb_t z, int type, slong prec) + void acb_hypgeom_legendre_p(acb_t res, const acb_t n, const acb_t m, const acb_t z, int type, slong prec) noexcept # Sets *res* to the associated Legendre function of the first kind # evaluated for degree *n*, order *m*, and argument *z*. # When *m* is zero, this reduces to the Legendre polynomial `P_n(z)`. @@ -833,7 +833,7 @@ cdef extern from "flint_wrap.h": # is computed. Type 0 and type 1 respectively correspond to # type 2 and type 3 in *Mathematica* and *mpmath*. - void acb_hypgeom_legendre_q(acb_t res, const acb_t n, const acb_t m, const acb_t z, int type, slong prec) + void acb_hypgeom_legendre_q(acb_t res, const acb_t n, const acb_t m, const acb_t z, int type, slong prec) noexcept # Sets *res* to the associated Legendre function of the second kind # evaluated for degree *n*, order *m*, and argument *z*. # When *m* is zero, this reduces to the Legendre function `Q_n(z)`. @@ -860,11 +860,11 @@ cdef extern from "flint_wrap.h": # .. [WQ3c] http://functions.wolfram.com/07.12.26.0003.01 # .. [WQ3d] http://functions.wolfram.com/07.12.26.0088.01 - void acb_hypgeom_legendre_p_uiui_rec(acb_t res, ulong n, ulong m, const acb_t z, slong prec) + void acb_hypgeom_legendre_p_uiui_rec(acb_t res, ulong n, ulong m, const acb_t z, slong prec) noexcept # For nonnegative integer *n* and *m*, uses recurrence relations to evaluate # `(1-z^2)^{-m/2} P_n^m(z)` which is a polynomial in *z*. - void acb_hypgeom_spherical_y(acb_t res, slong n, slong m, const acb_t theta, const acb_t phi, slong prec) + void acb_hypgeom_spherical_y(acb_t res, slong n, slong m, const acb_t theta, const acb_t phi, slong prec) noexcept # Computes the spherical harmonic of degree *n*, order *m*, # latitude angle *theta*, and longitude angle *phi*, normalized # such that @@ -874,15 +874,15 @@ cdef extern from "flint_wrap.h": # This function is a polynomial in `\cos(\theta)` and `\sin(\theta)`. # We evaluate it using :func:`acb_hypgeom_legendre_p_uiui_rec`. - void acb_hypgeom_dilog_zero_taylor(acb_t res, const acb_t z, slong prec) + void acb_hypgeom_dilog_zero_taylor(acb_t res, const acb_t z, slong prec) noexcept # Computes the dilogarithm for *z* close to 0 using the hypergeometric series # (effective only when `|z| \ll 1`). - void acb_hypgeom_dilog_zero(acb_t res, const acb_t z, slong prec) + void acb_hypgeom_dilog_zero(acb_t res, const acb_t z, slong prec) noexcept # Computes the dilogarithm for *z* close to 0, using the bit-burst algorithm # instead of the hypergeometric series directly at very high precision. - void acb_hypgeom_dilog_transform(acb_t res, const acb_t z, int algorithm, slong prec) + void acb_hypgeom_dilog_transform(acb_t res, const acb_t z, int algorithm, slong prec) noexcept # Computes the dilogarithm by applying one of the transformations # `1/z`, `1-z`, `z/(z-1)`, `1/(1-z)`, indexed by *algorithm* from 1 to 4, # and calling :func:`acb_hypgeom_dilog_zero` with the reduced variable. @@ -891,7 +891,7 @@ cdef extern from "flint_wrap.h": # chosen according to the midpoint of *z*) # and computes the dilogarithm by the bit-burst method. - void acb_hypgeom_dilog_continuation(acb_t res, const acb_t a, const acb_t z, slong prec) + void acb_hypgeom_dilog_continuation(acb_t res, const acb_t a, const acb_t z, slong prec) noexcept # Computes `\operatorname{Li}_2(z) - \operatorname{Li}_2(a)` using # Taylor expansion at *a*. Binary splitting is used. Both *a* and *z* # should be well isolated from the points 0 and 1, except that *a* may @@ -899,10 +899,10 @@ cdef extern from "flint_wrap.h": # cut, this method provides continuous analytic continuation instead of # computing the principal branch. - void acb_hypgeom_dilog_bitburst(acb_t res, acb_t z0, const acb_t z, slong prec) + void acb_hypgeom_dilog_bitburst(acb_t res, acb_t z0, const acb_t z, slong prec) noexcept # Sets *z0* to a point with short bit expansion close to *z* and sets # *res* to `\operatorname{Li}_2(z) - \operatorname{Li}_2(z_0)`, computed # using the bit-burst algorithm. - void acb_hypgeom_dilog(acb_t res, const acb_t z, slong prec) + void acb_hypgeom_dilog(acb_t res, const acb_t z, slong prec) noexcept # Computes the dilogarithm using a default algorithm choice. diff --git a/src/sage/libs/flint/acb_mat.pxd b/src/sage/libs/flint/acb_mat.pxd index 498ae0a4552..521af44f0c0 100644 --- a/src/sage/libs/flint/acb_mat.pxd +++ b/src/sage/libs/flint/acb_mat.pxd @@ -12,122 +12,122 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void acb_mat_init(acb_mat_t mat, slong r, slong c) + void acb_mat_init(acb_mat_t mat, slong r, slong c) noexcept # Initializes the matrix, setting it to the zero matrix with *r* rows # and *c* columns. - void acb_mat_clear(acb_mat_t mat) + void acb_mat_clear(acb_mat_t mat) noexcept # Clears the matrix, deallocating all entries. - slong acb_mat_allocated_bytes(const acb_mat_t x) + slong acb_mat_allocated_bytes(const acb_mat_t x) noexcept # Returns the total number of bytes heap-allocated internally by this object. # The count excludes the size of the structure itself. Add # ``sizeof(acb_mat_struct)`` to get the size of the object as a whole. - void acb_mat_window_init(acb_mat_t window, const acb_mat_t mat, slong r1, slong c1, slong r2, slong c2) + void acb_mat_window_init(acb_mat_t window, const acb_mat_t mat, slong r1, slong c1, slong r2, slong c2) noexcept # Initializes *window* to a window matrix into the submatrix of *mat* # starting at the corner at row *r1* and column *c1* (inclusive) and ending # at row *r2* and column *c2* (exclusive). - void acb_mat_window_clear(acb_mat_t window) + void acb_mat_window_clear(acb_mat_t window) noexcept # Frees the window matrix. - void acb_mat_set(acb_mat_t dest, const acb_mat_t src) + void acb_mat_set(acb_mat_t dest, const acb_mat_t src) noexcept - void acb_mat_set_fmpz_mat(acb_mat_t dest, const fmpz_mat_t src) + void acb_mat_set_fmpz_mat(acb_mat_t dest, const fmpz_mat_t src) noexcept - void acb_mat_set_round_fmpz_mat(acb_mat_t dest, const fmpz_mat_t src, slong prec) + void acb_mat_set_round_fmpz_mat(acb_mat_t dest, const fmpz_mat_t src, slong prec) noexcept - void acb_mat_set_fmpq_mat(acb_mat_t dest, const fmpq_mat_t src, slong prec) + void acb_mat_set_fmpq_mat(acb_mat_t dest, const fmpq_mat_t src, slong prec) noexcept - void acb_mat_set_arb_mat(acb_mat_t dest, const arb_mat_t src) + void acb_mat_set_arb_mat(acb_mat_t dest, const arb_mat_t src) noexcept - void acb_mat_set_round_arb_mat(acb_mat_t dest, const arb_mat_t src, slong prec) + void acb_mat_set_round_arb_mat(acb_mat_t dest, const arb_mat_t src, slong prec) noexcept # Sets *dest* to *src*. The operands must have identical dimensions. - void acb_mat_randtest(acb_mat_t mat, flint_rand_t state, slong prec, slong mag_bits) + void acb_mat_randtest(acb_mat_t mat, flint_rand_t state, slong prec, slong mag_bits) noexcept # Sets *mat* to a random matrix with up to *prec* bits of precision # and with exponents of width up to *mag_bits*. - void acb_mat_randtest_eig(acb_mat_t mat, flint_rand_t state, acb_srcptr E, slong prec) + void acb_mat_randtest_eig(acb_mat_t mat, flint_rand_t state, acb_srcptr E, slong prec) noexcept # Sets *mat* to a random matrix with the prescribed eigenvalues # supplied as the vector *E*. The output matrix is required to be # square. We generate a random unitary matrix via a matrix # exponential, and then evaluate an inverse Schur decomposition. - void acb_mat_printd(const acb_mat_t mat, slong digits) + void acb_mat_printd(const acb_mat_t mat, slong digits) noexcept # Prints each entry in the matrix with the specified number of decimal digits. - void acb_mat_fprintd(FILE * file, const acb_mat_t mat, slong digits) + void acb_mat_fprintd(FILE * file, const acb_mat_t mat, slong digits) noexcept # Prints each entry in the matrix with the specified number of decimal # digits to the stream *file*. - bint acb_mat_equal(const acb_mat_t mat1, const acb_mat_t mat2) + bint acb_mat_equal(const acb_mat_t mat1, const acb_mat_t mat2) noexcept # Returns whether the matrices have the same dimensions and identical # intervals as entries. - bint acb_mat_overlaps(const acb_mat_t mat1, const acb_mat_t mat2) + bint acb_mat_overlaps(const acb_mat_t mat1, const acb_mat_t mat2) noexcept # Returns whether the matrices have the same dimensions # and each entry in *mat1* overlaps with the corresponding entry in *mat2*. - bint acb_mat_contains(const acb_mat_t mat1, const acb_mat_t mat2) + bint acb_mat_contains(const acb_mat_t mat1, const acb_mat_t mat2) noexcept - bint acb_mat_contains_fmpz_mat(const acb_mat_t mat1, const fmpz_mat_t mat2) + bint acb_mat_contains_fmpz_mat(const acb_mat_t mat1, const fmpz_mat_t mat2) noexcept - bint acb_mat_contains_fmpq_mat(const acb_mat_t mat1, const fmpq_mat_t mat2) + bint acb_mat_contains_fmpq_mat(const acb_mat_t mat1, const fmpq_mat_t mat2) noexcept # Returns whether the matrices have the same dimensions and each entry # in *mat2* is contained in the corresponding entry in *mat1*. - bint acb_mat_eq(const acb_mat_t mat1, const acb_mat_t mat2) + bint acb_mat_eq(const acb_mat_t mat1, const acb_mat_t mat2) noexcept # Returns whether *mat1* and *mat2* certainly represent the same matrix. - bint acb_mat_ne(const acb_mat_t mat1, const acb_mat_t mat2) + bint acb_mat_ne(const acb_mat_t mat1, const acb_mat_t mat2) noexcept # Returns whether *mat1* and *mat2* certainly do not represent the same matrix. - bint acb_mat_is_real(const acb_mat_t mat) + bint acb_mat_is_real(const acb_mat_t mat) noexcept # Returns whether all entries in *mat* have zero imaginary part. - bint acb_mat_is_empty(const acb_mat_t mat) + bint acb_mat_is_empty(const acb_mat_t mat) noexcept # Returns whether the number of rows or the number of columns in *mat* is zero. - bint acb_mat_is_square(const acb_mat_t mat) + bint acb_mat_is_square(const acb_mat_t mat) noexcept # Returns whether the number of rows is equal to the number of columns in *mat*. - bint acb_mat_is_exact(const acb_mat_t mat) + bint acb_mat_is_exact(const acb_mat_t mat) noexcept # Returns whether all entries in *mat* have zero radius. - bint acb_mat_is_zero(const acb_mat_t mat) + bint acb_mat_is_zero(const acb_mat_t mat) noexcept # Returns whether all entries in *mat* are exactly zero. - bint acb_mat_is_finite(const acb_mat_t mat) + bint acb_mat_is_finite(const acb_mat_t mat) noexcept # Returns whether all entries in *mat* are finite. - bint acb_mat_is_triu(const acb_mat_t mat) + bint acb_mat_is_triu(const acb_mat_t mat) noexcept # Returns whether *mat* is upper triangular; that is, all entries # below the main diagonal are exactly zero. - bint acb_mat_is_tril(const acb_mat_t mat) + bint acb_mat_is_tril(const acb_mat_t mat) noexcept # Returns whether *mat* is lower triangular; that is, all entries # above the main diagonal are exactly zero. - bint acb_mat_is_diag(const acb_mat_t mat) + bint acb_mat_is_diag(const acb_mat_t mat) noexcept # Returns whether *mat* is a diagonal matrix; that is, all entries # off the main diagonal are exactly zero. - void acb_mat_zero(acb_mat_t mat) + void acb_mat_zero(acb_mat_t mat) noexcept # Sets all entries in mat to zero. - void acb_mat_one(acb_mat_t mat) + void acb_mat_one(acb_mat_t mat) noexcept # Sets the entries on the main diagonal to ones, # and all other entries to zero. - void acb_mat_ones(acb_mat_t mat) + void acb_mat_ones(acb_mat_t mat) noexcept # Sets all entries in the matrix to ones. - void acb_mat_indeterminate(acb_mat_t mat) + void acb_mat_indeterminate(acb_mat_t mat) noexcept # Sets all entries in the matrix to indeterminate (NaN). - void acb_mat_dft(acb_mat_t mat, int type, slong prec) + void acb_mat_dft(acb_mat_t mat, int type, slong prec) noexcept # Sets *mat* to the DFT (discrete Fourier transform) matrix of order *n* # where *n* is the smallest dimension of *mat* (if *mat* is not square, # the matrix is extended periodically along the larger dimension). @@ -137,46 +137,46 @@ cdef extern from "flint_wrap.h": # The *type* parameter is currently ignored and should be set to 0. # In the future, it might be used to select a different convention. - void acb_mat_transpose(acb_mat_t dest, const acb_mat_t src) + void acb_mat_transpose(acb_mat_t dest, const acb_mat_t src) noexcept # Sets *dest* to the exact transpose *src*. The operands must have # compatible dimensions. Aliasing is allowed. - void acb_mat_conjugate_transpose(acb_mat_t dest, const acb_mat_t src) + void acb_mat_conjugate_transpose(acb_mat_t dest, const acb_mat_t src) noexcept # Sets *dest* to the conjugate transpose of *src*. The operands must have # compatible dimensions. Aliasing is allowed. - void acb_mat_conjugate(acb_mat_t dest, const acb_mat_t src) + void acb_mat_conjugate(acb_mat_t dest, const acb_mat_t src) noexcept # Sets *dest* to the elementwise complex conjugate of *src*. - void acb_mat_bound_inf_norm(mag_t b, const acb_mat_t A) + void acb_mat_bound_inf_norm(mag_t b, const acb_mat_t A) noexcept # Sets *b* to an upper bound for the infinity norm (i.e. the largest # absolute value row sum) of *A*. - void acb_mat_frobenius_norm(arb_t res, const acb_mat_t A, slong prec) + void acb_mat_frobenius_norm(arb_t res, const acb_mat_t A, slong prec) noexcept # Sets *res* to the Frobenius norm (i.e. the square root of the sum # of squares of entries) of *A*. - void acb_mat_bound_frobenius_norm(mag_t res, const acb_mat_t A) + void acb_mat_bound_frobenius_norm(mag_t res, const acb_mat_t A) noexcept # Sets *res* to an upper bound for the Frobenius norm of *A*. - void acb_mat_neg(acb_mat_t dest, const acb_mat_t src) + void acb_mat_neg(acb_mat_t dest, const acb_mat_t src) noexcept # Sets *dest* to the exact negation of *src*. The operands must have # the same dimensions. - void acb_mat_add(acb_mat_t res, const acb_mat_t mat1, const acb_mat_t mat2, slong prec) + void acb_mat_add(acb_mat_t res, const acb_mat_t mat1, const acb_mat_t mat2, slong prec) noexcept # Sets res to the sum of *mat1* and *mat2*. The operands must have the same dimensions. - void acb_mat_sub(acb_mat_t res, const acb_mat_t mat1, const acb_mat_t mat2, slong prec) + void acb_mat_sub(acb_mat_t res, const acb_mat_t mat1, const acb_mat_t mat2, slong prec) noexcept # Sets *res* to the difference of *mat1* and *mat2*. The operands must have # the same dimensions. - void acb_mat_mul_classical(acb_mat_t res, const acb_mat_t mat1, const acb_mat_t mat2, slong prec) + void acb_mat_mul_classical(acb_mat_t res, const acb_mat_t mat1, const acb_mat_t mat2, slong prec) noexcept - void acb_mat_mul_threaded(acb_mat_t res, const acb_mat_t mat1, const acb_mat_t mat2, slong prec) + void acb_mat_mul_threaded(acb_mat_t res, const acb_mat_t mat1, const acb_mat_t mat2, slong prec) noexcept - void acb_mat_mul_reorder(acb_mat_t res, const acb_mat_t mat1, const acb_mat_t mat2, slong prec) + void acb_mat_mul_reorder(acb_mat_t res, const acb_mat_t mat1, const acb_mat_t mat2, slong prec) noexcept - void acb_mat_mul(acb_mat_t res, const acb_mat_t mat1, const acb_mat_t mat2, slong prec) + void acb_mat_mul(acb_mat_t res, const acb_mat_t mat1, const acb_mat_t mat2, slong prec) noexcept # Sets *res* to the matrix product of *mat1* and *mat2*. The operands must have # compatible dimensions for matrix multiplication. # The *classical* version performs matrix multiplication in the trivial way. @@ -186,62 +186,62 @@ cdef extern from "flint_wrap.h": # matrix multiplications via :func:`arb_mat_mul`. # The default version chooses an algorithm automatically. - void acb_mat_mul_entrywise(acb_mat_t res, const acb_mat_t mat1, const acb_mat_t mat2, slong prec) + void acb_mat_mul_entrywise(acb_mat_t res, const acb_mat_t mat1, const acb_mat_t mat2, slong prec) noexcept # Sets *res* to the entrywise product of *mat1* and *mat2*. # The operands must have the same dimensions. - void acb_mat_sqr_classical(acb_mat_t res, const acb_mat_t mat, slong prec) + void acb_mat_sqr_classical(acb_mat_t res, const acb_mat_t mat, slong prec) noexcept - void acb_mat_sqr(acb_mat_t res, const acb_mat_t mat, slong prec) + void acb_mat_sqr(acb_mat_t res, const acb_mat_t mat, slong prec) noexcept # Sets *res* to the matrix square of *mat*. The operands must both be square # with the same dimensions. - void acb_mat_pow_ui(acb_mat_t res, const acb_mat_t mat, ulong exp, slong prec) + void acb_mat_pow_ui(acb_mat_t res, const acb_mat_t mat, ulong exp, slong prec) noexcept # Sets *res* to *mat* raised to the power *exp*. Requires that *mat* # is a square matrix. - void acb_mat_approx_mul(acb_mat_t res, const acb_mat_t mat1, const acb_mat_t mat2, slong prec) + void acb_mat_approx_mul(acb_mat_t res, const acb_mat_t mat1, const acb_mat_t mat2, slong prec) noexcept # Approximate matrix multiplication. The input radii are ignored and # the output matrix is set to an approximate floating-point result. # For performance reasons, the radii in the output matrix will *not* # necessarily be written (zeroed), but will remain zero if they # are already zeroed in *res* before calling this function. - void acb_mat_scalar_mul_2exp_si(acb_mat_t B, const acb_mat_t A, slong c) + void acb_mat_scalar_mul_2exp_si(acb_mat_t B, const acb_mat_t A, slong c) noexcept # Sets *B* to *A* multiplied by `2^c`. - void acb_mat_scalar_addmul_si(acb_mat_t B, const acb_mat_t A, slong c, slong prec) + void acb_mat_scalar_addmul_si(acb_mat_t B, const acb_mat_t A, slong c, slong prec) noexcept - void acb_mat_scalar_addmul_fmpz(acb_mat_t B, const acb_mat_t A, const fmpz_t c, slong prec) + void acb_mat_scalar_addmul_fmpz(acb_mat_t B, const acb_mat_t A, const fmpz_t c, slong prec) noexcept - void acb_mat_scalar_addmul_arb(acb_mat_t B, const acb_mat_t A, const arb_t c, slong prec) + void acb_mat_scalar_addmul_arb(acb_mat_t B, const acb_mat_t A, const arb_t c, slong prec) noexcept - void acb_mat_scalar_addmul_acb(acb_mat_t B, const acb_mat_t A, const acb_t c, slong prec) + void acb_mat_scalar_addmul_acb(acb_mat_t B, const acb_mat_t A, const acb_t c, slong prec) noexcept # Sets *B* to `B + A \times c`. - void acb_mat_scalar_mul_si(acb_mat_t B, const acb_mat_t A, slong c, slong prec) + void acb_mat_scalar_mul_si(acb_mat_t B, const acb_mat_t A, slong c, slong prec) noexcept - void acb_mat_scalar_mul_fmpz(acb_mat_t B, const acb_mat_t A, const fmpz_t c, slong prec) + void acb_mat_scalar_mul_fmpz(acb_mat_t B, const acb_mat_t A, const fmpz_t c, slong prec) noexcept - void acb_mat_scalar_mul_arb(acb_mat_t B, const acb_mat_t A, const arb_t c, slong prec) + void acb_mat_scalar_mul_arb(acb_mat_t B, const acb_mat_t A, const arb_t c, slong prec) noexcept - void acb_mat_scalar_mul_acb(acb_mat_t B, const acb_mat_t A, const acb_t c, slong prec) + void acb_mat_scalar_mul_acb(acb_mat_t B, const acb_mat_t A, const acb_t c, slong prec) noexcept # Sets *B* to `A \times c`. - void acb_mat_scalar_div_si(acb_mat_t B, const acb_mat_t A, slong c, slong prec) + void acb_mat_scalar_div_si(acb_mat_t B, const acb_mat_t A, slong c, slong prec) noexcept - void acb_mat_scalar_div_fmpz(acb_mat_t B, const acb_mat_t A, const fmpz_t c, slong prec) + void acb_mat_scalar_div_fmpz(acb_mat_t B, const acb_mat_t A, const fmpz_t c, slong prec) noexcept - void acb_mat_scalar_div_arb(acb_mat_t B, const acb_mat_t A, const arb_t c, slong prec) + void acb_mat_scalar_div_arb(acb_mat_t B, const acb_mat_t A, const arb_t c, slong prec) noexcept - void acb_mat_scalar_div_acb(acb_mat_t B, const acb_mat_t A, const acb_t c, slong prec) + void acb_mat_scalar_div_acb(acb_mat_t B, const acb_mat_t A, const acb_t c, slong prec) noexcept # Sets *B* to `A / c`. - int acb_mat_lu_classical(slong * perm, acb_mat_t LU, const acb_mat_t A, slong prec) + int acb_mat_lu_classical(slong * perm, acb_mat_t LU, const acb_mat_t A, slong prec) noexcept - int acb_mat_lu_recursive(slong * perm, acb_mat_t LU, const acb_mat_t A, slong prec) + int acb_mat_lu_recursive(slong * perm, acb_mat_t LU, const acb_mat_t A, slong prec) noexcept - int acb_mat_lu(slong * perm, acb_mat_t LU, const acb_mat_t A, slong prec) + int acb_mat_lu(slong * perm, acb_mat_t LU, const acb_mat_t A, slong prec) noexcept # Given an `n \times n` matrix `A`, computes an LU decomposition `PLU = A` # using Gaussian elimination with partial pivoting. # The input and output matrices can be the same, performing the @@ -261,17 +261,17 @@ cdef extern from "flint_wrap.h": # way to benefit from fast matrix multiplication. The default version # chooses an algorithm automatically. - void acb_mat_solve_tril_classical(acb_mat_t X, const acb_mat_t L, const acb_mat_t B, int unit, slong prec) + void acb_mat_solve_tril_classical(acb_mat_t X, const acb_mat_t L, const acb_mat_t B, int unit, slong prec) noexcept - void acb_mat_solve_tril_recursive(acb_mat_t X, const acb_mat_t L, const acb_mat_t B, int unit, slong prec) + void acb_mat_solve_tril_recursive(acb_mat_t X, const acb_mat_t L, const acb_mat_t B, int unit, slong prec) noexcept - void acb_mat_solve_tril(acb_mat_t X, const acb_mat_t L, const acb_mat_t B, int unit, slong prec) + void acb_mat_solve_tril(acb_mat_t X, const acb_mat_t L, const acb_mat_t B, int unit, slong prec) noexcept - void acb_mat_solve_triu_classical(acb_mat_t X, const acb_mat_t U, const acb_mat_t B, int unit, slong prec) + void acb_mat_solve_triu_classical(acb_mat_t X, const acb_mat_t U, const acb_mat_t B, int unit, slong prec) noexcept - void acb_mat_solve_triu_recursive(acb_mat_t X, const acb_mat_t U, const acb_mat_t B, int unit, slong prec) + void acb_mat_solve_triu_recursive(acb_mat_t X, const acb_mat_t U, const acb_mat_t B, int unit, slong prec) noexcept - void acb_mat_solve_triu(acb_mat_t X, const acb_mat_t U, const acb_mat_t B, int unit, slong prec) + void acb_mat_solve_triu(acb_mat_t X, const acb_mat_t U, const acb_mat_t B, int unit, slong prec) noexcept # Solves the lower triangular system `LX = B` or the upper triangular system # `UX = B`, respectively. If *unit* is set, the main diagonal of *L* or *U* # is taken to consist of all ones, and in that case the actual entries on @@ -281,16 +281,16 @@ cdef extern from "flint_wrap.h": # way to benefit from fast matrix multiplication. The default versions # choose an algorithm automatically. - void acb_mat_solve_lu_precomp(acb_mat_t X, const slong * perm, const acb_mat_t LU, const acb_mat_t B, slong prec) + void acb_mat_solve_lu_precomp(acb_mat_t X, const slong * perm, const acb_mat_t LU, const acb_mat_t B, slong prec) noexcept # Solves `AX = B` given the precomputed nonsingular LU decomposition `A = PLU`. # The matrices `X` and `B` are allowed to be aliased with each other, # but `X` is not allowed to be aliased with `LU`. - int acb_mat_solve(acb_mat_t X, const acb_mat_t A, const acb_mat_t B, slong prec) + int acb_mat_solve(acb_mat_t X, const acb_mat_t A, const acb_mat_t B, slong prec) noexcept - int acb_mat_solve_lu(acb_mat_t X, const acb_mat_t A, const acb_mat_t B, slong prec) + int acb_mat_solve_lu(acb_mat_t X, const acb_mat_t A, const acb_mat_t B, slong prec) noexcept - int acb_mat_solve_precond(acb_mat_t X, const acb_mat_t A, const acb_mat_t B, slong prec) + int acb_mat_solve_precond(acb_mat_t X, const acb_mat_t A, const acb_mat_t B, slong prec) noexcept # Solves `AX = B` where `A` is a nonsingular `n \times n` matrix # and `X` and `B` are `n \times m` matrices. # If `m > 0` and `A` cannot be inverted numerically (indicating either that @@ -314,7 +314,7 @@ cdef extern from "flint_wrap.h": # For example, the *lu* solver often performs better for ill-conditioned # systems where use of very high precision is unavoidable. - int acb_mat_inv(acb_mat_t X, const acb_mat_t A, slong prec) + int acb_mat_inv(acb_mat_t X, const acb_mat_t A, slong prec) noexcept # Sets `X = A^{-1}` where `A` is a square matrix, computed by solving # the system `AX = I`. # If `A` cannot be inverted numerically (indicating either that @@ -323,11 +323,11 @@ cdef extern from "flint_wrap.h": # A nonzero return value guarantees that the matrix is invertible # and that the exact inverse is contained in the output. - void acb_mat_det_lu(acb_t det, const acb_mat_t A, slong prec) + void acb_mat_det_lu(acb_t det, const acb_mat_t A, slong prec) noexcept - void acb_mat_det_precond(acb_t det, const acb_mat_t A, slong prec) + void acb_mat_det_precond(acb_t det, const acb_mat_t A, slong prec) noexcept - void acb_mat_det(acb_t det, const acb_mat_t A, slong prec) + void acb_mat_det(acb_t det, const acb_mat_t A, slong prec) noexcept # Sets *det* to the determinant of the matrix *A*. # The *lu* version uses Gaussian elimination with partial pivoting. If at # some point an invertible pivot element cannot be found, the elimination is @@ -343,17 +343,17 @@ cdef extern from "flint_wrap.h": # versions and additionally handles small or triangular matrices # by direct formulas. - void acb_mat_approx_solve_triu(acb_mat_t X, const acb_mat_t U, const acb_mat_t B, int unit, slong prec) + void acb_mat_approx_solve_triu(acb_mat_t X, const acb_mat_t U, const acb_mat_t B, int unit, slong prec) noexcept - void acb_mat_approx_solve_tril(acb_mat_t X, const acb_mat_t L, const acb_mat_t B, int unit, slong prec) + void acb_mat_approx_solve_tril(acb_mat_t X, const acb_mat_t L, const acb_mat_t B, int unit, slong prec) noexcept - int acb_mat_approx_lu(slong * P, acb_mat_t LU, const acb_mat_t A, slong prec) + int acb_mat_approx_lu(slong * P, acb_mat_t LU, const acb_mat_t A, slong prec) noexcept - void acb_mat_approx_solve_lu_precomp(acb_mat_t X, const slong * perm, const acb_mat_t A, const acb_mat_t B, slong prec) + void acb_mat_approx_solve_lu_precomp(acb_mat_t X, const slong * perm, const acb_mat_t A, const acb_mat_t B, slong prec) noexcept - int acb_mat_approx_solve(acb_mat_t X, const acb_mat_t A, const acb_mat_t B, slong prec) + int acb_mat_approx_solve(acb_mat_t X, const acb_mat_t A, const acb_mat_t B, slong prec) noexcept - int acb_mat_approx_inv(acb_mat_t X, const acb_mat_t A, slong prec) + int acb_mat_approx_inv(acb_mat_t X, const acb_mat_t A, slong prec) noexcept # These methods perform approximate solving *without any error control*. # The radii in the input matrices are ignored, the computations are done # numerically with floating-point arithmetic (using ordinary @@ -362,26 +362,26 @@ cdef extern from "flint_wrap.h": # output matrices are set to the approximate floating-point results with # zeroed error bounds. - void _acb_mat_charpoly(acb_ptr poly, const acb_mat_t mat, slong prec) + void _acb_mat_charpoly(acb_ptr poly, const acb_mat_t mat, slong prec) noexcept - void acb_mat_charpoly(acb_poly_t poly, const acb_mat_t mat, slong prec) + void acb_mat_charpoly(acb_poly_t poly, const acb_mat_t mat, slong prec) noexcept # Sets *poly* to the characteristic polynomial of *mat* which must be # a square matrix. If the matrix has *n* rows, the underscore method # requires space for `n + 1` output coefficients. # Employs a division-free algorithm using `O(n^4)` operations. - void _acb_mat_companion(acb_mat_t mat, acb_srcptr poly, slong prec) + void _acb_mat_companion(acb_mat_t mat, acb_srcptr poly, slong prec) noexcept - void acb_mat_companion(acb_mat_t mat, const acb_poly_t poly, slong prec) + void acb_mat_companion(acb_mat_t mat, const acb_poly_t poly, slong prec) noexcept # Sets the *n* by *n* matrix *mat* to the companion matrix of the polynomial # *poly* which must have degree *n*. # The underscore method reads `n + 1` input coefficients. - void acb_mat_exp_taylor_sum(acb_mat_t S, const acb_mat_t A, slong N, slong prec) + void acb_mat_exp_taylor_sum(acb_mat_t S, const acb_mat_t A, slong N, slong prec) noexcept # Sets *S* to the truncated exponential Taylor series `S = \sum_{k=0}^{N-1} A^k / k!`. # See :func:`arb_mat_exp_taylor_sum` for implementation notes. - void acb_mat_exp(acb_mat_t B, const acb_mat_t A, slong prec) + void acb_mat_exp(acb_mat_t B, const acb_mat_t A, slong prec) noexcept # Sets *B* to the exponential of the matrix *A*, defined by the Taylor series # .. math :: # \exp(A) = \sum_{k=0}^{\infty} \frac{A^k}{k!}. @@ -389,24 +389,24 @@ cdef extern from "flint_wrap.h": # to give rapid convergence of the Taylor series. # Error bounds are computed as for :func:`arb_mat_exp`. - void acb_mat_trace(acb_t trace, const acb_mat_t mat, slong prec) + void acb_mat_trace(acb_t trace, const acb_mat_t mat, slong prec) noexcept # Sets *trace* to the trace of the matrix, i.e. the sum of entries on the # main diagonal of *mat*. The matrix is required to be square. - void _acb_mat_diag_prod(acb_t res, const acb_mat_t mat, slong a, slong b, slong prec) + void _acb_mat_diag_prod(acb_t res, const acb_mat_t mat, slong a, slong b, slong prec) noexcept - void acb_mat_diag_prod(acb_t res, const acb_mat_t mat, slong prec) + void acb_mat_diag_prod(acb_t res, const acb_mat_t mat, slong prec) noexcept # Sets *res* to the product of the entries on the main diagonal of *mat*. # The underscore method computes the product of the entries between # index *a* inclusive and *b* exclusive (the indices must be in range). - void acb_mat_get_mid(acb_mat_t B, const acb_mat_t A) + void acb_mat_get_mid(acb_mat_t B, const acb_mat_t A) noexcept # Sets the entries of *B* to the exact midpoints of the entries of *A*. - void acb_mat_add_error_mag(acb_mat_t mat, const mag_t err) + void acb_mat_add_error_mag(acb_mat_t mat, const mag_t err) noexcept # Adds *err* in-place to the radii of the entries of *mat*. - int acb_mat_approx_eig_qr(acb_ptr E, acb_mat_t L, acb_mat_t R, const acb_mat_t A, const mag_t tol, slong maxiter, slong prec) + int acb_mat_approx_eig_qr(acb_ptr E, acb_mat_t L, acb_mat_t R, const acb_mat_t A, const mag_t tol, slong maxiter, slong prec) noexcept # Computes floating-point approximations of all the *n* eigenvalues # (and optionally eigenvectors) of the # given *n* by *n* matrix *A*. The approximations of the @@ -427,7 +427,7 @@ cdef extern from "flint_wrap.h": # any statement whatsoever about error bounds. # The output may also be accurate even if this function returns zero. - void acb_mat_eig_global_enclosure(mag_t eps, const acb_mat_t A, acb_srcptr E, const acb_mat_t R, slong prec) + void acb_mat_eig_global_enclosure(mag_t eps, const acb_mat_t A, acb_srcptr E, const acb_mat_t R, slong prec) noexcept # Given an *n* by *n* matrix *A*, a length-*n* vector *E* # containing approximations of the eigenvalues of *A*, # and an *n* by *n* matrix *R* containing approximations of @@ -466,7 +466,7 @@ cdef extern from "flint_wrap.h": # No assumptions are made about the structure of *A* or the # quality of the given approximations. - void acb_mat_eig_enclosure_rump(acb_t lmbda, acb_mat_t J, acb_mat_t R, const acb_mat_t A, const acb_t lambda_approx, const acb_mat_t R_approx, slong prec) + void acb_mat_eig_enclosure_rump(acb_t lmbda, acb_mat_t J, acb_mat_t R, const acb_mat_t A, const acb_t lambda_approx, const acb_mat_t R_approx, slong prec) noexcept # Given an *n* by *n* matrix *A* and an approximate # eigenvalue-eigenvector pair *lambda_approx* and *R_approx* (where # *R_approx* is an *n* by 1 matrix), computes an enclosure @@ -502,11 +502,11 @@ cdef extern from "flint_wrap.h": # No assumptions are made about the structure of *A* or the # quality of the given approximations. - int acb_mat_eig_simple_rump(acb_ptr E, acb_mat_t L, acb_mat_t R, const acb_mat_t A, acb_srcptr E_approx, const acb_mat_t R_approx, slong prec) + int acb_mat_eig_simple_rump(acb_ptr E, acb_mat_t L, acb_mat_t R, const acb_mat_t A, acb_srcptr E_approx, const acb_mat_t R_approx, slong prec) noexcept - int acb_mat_eig_simple_vdhoeven_mourrain(acb_ptr E, acb_mat_t L, acb_mat_t R, const acb_mat_t A, acb_srcptr E_approx, const acb_mat_t R_approx, slong prec) + int acb_mat_eig_simple_vdhoeven_mourrain(acb_ptr E, acb_mat_t L, acb_mat_t R, const acb_mat_t A, acb_srcptr E_approx, const acb_mat_t R_approx, slong prec) noexcept - int acb_mat_eig_simple(acb_ptr E, acb_mat_t L, acb_mat_t R, const acb_mat_t A, acb_srcptr E_approx, const acb_mat_t R_approx, slong prec) + int acb_mat_eig_simple(acb_ptr E, acb_mat_t L, acb_mat_t R, const acb_mat_t A, acb_srcptr E_approx, const acb_mat_t R_approx, slong prec) noexcept # Computes all the eigenvalues (and optionally corresponding # eigenvectors) of the given *n* by *n* matrix *A*. # Attempts to prove that *A* has *n* simple (isolated) @@ -542,9 +542,9 @@ cdef extern from "flint_wrap.h": # :func:`acb_mat_eig_multiple_rump` may be used as a fallback, # or :func:`acb_mat_eig_multiple` may be used in the first place. - int acb_mat_eig_multiple_rump(acb_ptr E, const acb_mat_t A, acb_srcptr E_approx, const acb_mat_t R_approx, slong prec) + int acb_mat_eig_multiple_rump(acb_ptr E, const acb_mat_t A, acb_srcptr E_approx, const acb_mat_t R_approx, slong prec) noexcept - int acb_mat_eig_multiple(acb_ptr E, const acb_mat_t A, acb_srcptr E_approx, const acb_mat_t R_approx, slong prec) + int acb_mat_eig_multiple(acb_ptr E, const acb_mat_t A, acb_srcptr E_approx, const acb_mat_t R_approx, slong prec) noexcept # Computes all the eigenvalues of the given *n* by *n* matrix *A*. # On success, the output vector *E* contains *n* complex intervals, # each representing one eigenvalue of *A* with the correct diff --git a/src/sage/libs/flint/acb_modular.pxd b/src/sage/libs/flint/acb_modular.pxd index 761ba81e103..f45c197338e 100644 --- a/src/sage/libs/flint/acb_modular.pxd +++ b/src/sage/libs/flint/acb_modular.pxd @@ -12,59 +12,59 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void psl2z_init(psl2z_t g) + void psl2z_init(psl2z_t g) noexcept # Initializes *g* and set it to the identity element. - void psl2z_clear(psl2z_t g) + void psl2z_clear(psl2z_t g) noexcept # Clears *g*. - void psl2z_swap(psl2z_t f, psl2z_t g) + void psl2z_swap(psl2z_t f, psl2z_t g) noexcept # Swaps *f* and *g* efficiently. - void psl2z_set(psl2z_t f, const psl2z_t g) + void psl2z_set(psl2z_t f, const psl2z_t g) noexcept # Sets *f* to a copy of *g*. - void psl2z_one(psl2z_t g) + void psl2z_one(psl2z_t g) noexcept # Sets *g* to the identity element. - bint psl2z_is_one(const psl2z_t g) + bint psl2z_is_one(const psl2z_t g) noexcept # Returns nonzero iff *g* is the identity element. - void psl2z_print(const psl2z_t g) + void psl2z_print(const psl2z_t g) noexcept # Prints *g* to standard output. - void psl2z_fprint(FILE * file, const psl2z_t g) + void psl2z_fprint(FILE * file, const psl2z_t g) noexcept # Prints *g* to the stream *file*. - bint psl2z_equal(const psl2z_t f, const psl2z_t g) + bint psl2z_equal(const psl2z_t f, const psl2z_t g) noexcept # Returns nonzero iff *f* and *g* are equal. - void psl2z_mul(psl2z_t h, const psl2z_t f, const psl2z_t g) + void psl2z_mul(psl2z_t h, const psl2z_t f, const psl2z_t g) noexcept # Sets *h* to the product of *f* and *g*, namely the matrix product # with the signs canonicalized. - void psl2z_inv(psl2z_t h, const psl2z_t g) + void psl2z_inv(psl2z_t h, const psl2z_t g) noexcept # Sets *h* to the inverse of *g*. - bint psl2z_is_correct(const psl2z_t g) + bint psl2z_is_correct(const psl2z_t g) noexcept # Returns nonzero iff *g* contains correct data, i.e. # satisfying `ad-bc = 1`, `c \ge 0`, and `d > 0` if `c = 0`. - void psl2z_randtest(psl2z_t g, flint_rand_t state, slong bits) + void psl2z_randtest(psl2z_t g, flint_rand_t state, slong bits) noexcept # Sets *g* to a random element of `\text{PSL}(2, \mathbb{Z})` # with entries of bit length at most *bits* # (or 1, if *bits* is not positive). We first generate *a* and *d*, compute # their Bezout coefficients, divide by the GCD, and then correct the signs. - void acb_modular_transform(acb_t w, const psl2z_t g, const acb_t z, slong prec) + void acb_modular_transform(acb_t w, const psl2z_t g, const acb_t z, slong prec) noexcept # Applies the modular transformation *g* to the complex number *z*, # evaluating # .. math :: # w = g z = \frac{az+b}{cz+d}. - void acb_modular_fundamental_domain_approx_d(psl2z_t g, double x, double y, double one_minus_eps) + void acb_modular_fundamental_domain_approx_d(psl2z_t g, double x, double y, double one_minus_eps) noexcept - void acb_modular_fundamental_domain_approx_arf(psl2z_t g, const arf_t x, const arf_t y, const arf_t one_minus_eps, slong prec) + void acb_modular_fundamental_domain_approx_arf(psl2z_t g, const arf_t x, const arf_t y, const arf_t one_minus_eps, slong prec) noexcept # Attempts to determine a modular transformation *g* that maps the # complex number `x+yi` to the fundamental domain or just # slightly outside the fundamental domain, where the target tolerance @@ -81,7 +81,7 @@ cdef extern from "flint_wrap.h": # but it is up to the user to verify a posteriori that *g* maps `x+yi` # close enough to the fundamental domain. - void acb_modular_fundamental_domain_approx(acb_t w, psl2z_t g, const acb_t z, const arf_t one_minus_eps, slong prec) + void acb_modular_fundamental_domain_approx(acb_t w, psl2z_t g, const acb_t z, const arf_t one_minus_eps, slong prec) noexcept # Attempts to determine a modular transformation *g* that maps the # complex number `z` to the fundamental domain or just # slightly outside the fundamental domain, where the target tolerance @@ -97,12 +97,12 @@ cdef extern from "flint_wrap.h": # but it is up to the user to verify a posteriori that `w` is close enough # to the fundamental domain. - bint acb_modular_is_in_fundamental_domain(const acb_t z, const arf_t tol, slong prec) + bint acb_modular_is_in_fundamental_domain(const acb_t z, const arf_t tol, slong prec) noexcept # Returns nonzero if it is certainly true that `|z| \ge 1 - \varepsilon` and # `|\operatorname{Re}(z)| \le 1/2 + \varepsilon` where `\varepsilon` is # specified by *tol*. Returns zero if this is false or cannot be determined. - void acb_modular_fill_addseq(slong * tab, slong len) + void acb_modular_fill_addseq(slong * tab, slong len) noexcept # Builds a near-optimal addition sequence for a sequence of integers # which is assumed to be reasonably dense. # As input, the caller should set each entry in *tab* to `-1` if @@ -113,7 +113,7 @@ cdef extern from "flint_wrap.h": # The first two entries in *tab* are ignored (the number 1 is always # assumed to be part of the sequence). - void acb_modular_theta_transform(int * R, int * S, int * C, const psl2z_t g) + void acb_modular_theta_transform(int * R, int * S, int * C, const psl2z_t g) noexcept # We wish to write a theta function with quasiperiod `\tau` in terms # of a theta function with quasiperiod `\tau' = g \tau`, given # some `g = (a, b; c, d) \in \text{PSL}(2, \mathbb{Z})`. @@ -170,11 +170,11 @@ cdef extern from "flint_wrap.h": # and his "`\varepsilon`" differs from ours by a constant # offset in the phase). - void acb_modular_addseq_theta(slong * exponents, slong * aindex, slong * bindex, slong num) + void acb_modular_addseq_theta(slong * exponents, slong * aindex, slong * bindex, slong num) noexcept # Constructs an addition sequence for the first *num* squares and triangular # numbers interleaved (excluding zero), i.e. 1, 2, 4, 6, 9, 12, 16, 20, 25, 30 etc. - void acb_modular_theta_sum(acb_ptr theta1, acb_ptr theta2, acb_ptr theta3, acb_ptr theta4, const acb_t w, int w_is_unit, const acb_t q, slong len, slong prec) + void acb_modular_theta_sum(acb_ptr theta1, acb_ptr theta2, acb_ptr theta3, acb_ptr theta4, const acb_t w, int w_is_unit, const acb_t q, slong len, slong prec) noexcept # Simultaneously computes the first *len* coefficients of each of the # formal power series # .. math :: @@ -245,9 +245,9 @@ cdef extern from "flint_wrap.h": # This function does not permit aliasing between input and output # arguments. - void acb_modular_theta_const_sum_basecase(acb_t theta2, acb_t theta3, acb_t theta4, const acb_t q, slong N, slong prec) + void acb_modular_theta_const_sum_basecase(acb_t theta2, acb_t theta3, acb_t theta4, const acb_t q, slong N, slong prec) noexcept - void acb_modular_theta_const_sum_rs(acb_t theta2, acb_t theta3, acb_t theta4, const acb_t q, slong N, slong prec) + void acb_modular_theta_const_sum_rs(acb_t theta2, acb_t theta3, acb_t theta4, const acb_t q, slong N, slong prec) noexcept # Computes the truncated theta constant sums # `\theta_2 = \sum_{k(k+1) < N} q^{k(k+1)}`, # `\theta_3 = \sum_{k^2 < N} q^{k^2}`, @@ -256,7 +256,7 @@ cdef extern from "flint_wrap.h": # The *rs* version uses rectangular splitting. # The algorithms are described in [EHJ2016]_. - void acb_modular_theta_const_sum(acb_t theta2, acb_t theta3, acb_t theta4, const acb_t q, slong prec) + void acb_modular_theta_const_sum(acb_t theta2, acb_t theta3, acb_t theta4, const acb_t q, slong prec) noexcept # Computes the respective theta constants by direct summation # (without applying modular transformations). This function # selects an appropriate *N*, calls either @@ -264,38 +264,38 @@ cdef extern from "flint_wrap.h": # :func:`acb_modular_theta_const_sum_rs` or depending on *N*, # and adds a bound for the truncation error. - void acb_modular_theta_notransform(acb_t theta1, acb_t theta2, acb_t theta3, acb_t theta4, const acb_t z, const acb_t tau, slong prec) + void acb_modular_theta_notransform(acb_t theta1, acb_t theta2, acb_t theta3, acb_t theta4, const acb_t z, const acb_t tau, slong prec) noexcept # Evaluates the Jacobi theta functions `\theta_i(z,\tau)`, `i = 1, 2, 3, 4` # simultaneously. This function does not move `\tau` to the fundamental domain. # This is generally worse than :func:`acb_modular_theta`, but can # be slightly better for moderate input. - void acb_modular_theta(acb_t theta1, acb_t theta2, acb_t theta3, acb_t theta4, const acb_t z, const acb_t tau, slong prec) + void acb_modular_theta(acb_t theta1, acb_t theta2, acb_t theta3, acb_t theta4, const acb_t z, const acb_t tau, slong prec) noexcept # Evaluates the Jacobi theta functions `\theta_i(z,\tau)`, `i = 1, 2, 3, 4` # simultaneously. This function moves `\tau` to the fundamental domain # and then also reduces `z` modulo `\tau` # before calling :func:`acb_modular_theta_sum`. - void acb_modular_theta_jet_notransform(acb_ptr theta1, acb_ptr theta2, acb_ptr theta3, acb_ptr theta4, const acb_t z, const acb_t tau, slong len, slong prec) + void acb_modular_theta_jet_notransform(acb_ptr theta1, acb_ptr theta2, acb_ptr theta3, acb_ptr theta4, const acb_t z, const acb_t tau, slong len, slong prec) noexcept - void acb_modular_theta_jet(acb_ptr theta1, acb_ptr theta2, acb_ptr theta3, acb_ptr theta4, const acb_t z, const acb_t tau, slong len, slong prec) + void acb_modular_theta_jet(acb_ptr theta1, acb_ptr theta2, acb_ptr theta3, acb_ptr theta4, const acb_t z, const acb_t tau, slong len, slong prec) noexcept # Evaluates the Jacobi theta functions along with their derivatives # with respect to *z*, writing the first *len* coefficients in the power # series `\theta_i(z+x,\tau) \in \mathbb{C}[[x]]` to # each respective output variable. The *notransform* version does not # move `\tau` to the fundamental domain or reduce `z` during the computation. - void _acb_modular_theta_series(acb_ptr theta1, acb_ptr theta2, acb_ptr theta3, acb_ptr theta4, acb_srcptr z, slong zlen, const acb_t tau, slong len, slong prec) + void _acb_modular_theta_series(acb_ptr theta1, acb_ptr theta2, acb_ptr theta3, acb_ptr theta4, acb_srcptr z, slong zlen, const acb_t tau, slong len, slong prec) noexcept - void acb_modular_theta_series(acb_poly_t theta1, acb_poly_t theta2, acb_poly_t theta3, acb_poly_t theta4, const acb_poly_t z, const acb_t tau, slong len, slong prec) + void acb_modular_theta_series(acb_poly_t theta1, acb_poly_t theta2, acb_poly_t theta3, acb_poly_t theta4, const acb_poly_t z, const acb_t tau, slong len, slong prec) noexcept # Evaluates the respective Jacobi theta functions of the power series *z*, # truncated to length *len*. Either of the output variables can be *NULL*. - void acb_modular_addseq_eta(slong * exponents, slong * aindex, slong * bindex, slong num) + void acb_modular_addseq_eta(slong * exponents, slong * aindex, slong * bindex, slong num) noexcept # Constructs an addition sequence for the first *num* generalized pentagonal # numbers (excluding zero), i.e. 1, 2, 5, 7, 12, 15, 22, 26, 35, 40 etc. - void acb_modular_eta_sum(acb_t eta, const acb_t q, slong prec) + void acb_modular_eta_sum(acb_t eta, const acb_t q, slong prec) noexcept # Evaluates the Dedekind eta function # without the leading 24th root, i.e. # .. math :: \exp(-\pi i \tau/12) \eta(\tau) = \sum_{n=-\infty}^{\infty} (-1)^n q^{(3n^2-n)/2} @@ -308,7 +308,7 @@ cdef extern from "flint_wrap.h": # rectangular splitting, depending on the number of terms. # The algorithms are described in [EHJ2016]_. - int acb_modular_epsilon_arg(const psl2z_t g) + int acb_modular_epsilon_arg(const psl2z_t g) noexcept # Given `g = (a, b; c, d)`, computes an integer `R` such that # `\varepsilon(a,b,c,d) = \exp(\pi i R / 12)` is the 24th root of unity in # the transformation formula for the Dedekind eta function, @@ -316,13 +316,13 @@ cdef extern from "flint_wrap.h": # \eta\left(\frac{a\tau+b}{c\tau+d}\right) = \varepsilon (a,b,c,d) # \sqrt{c\tau+d} \eta(\tau). - void acb_modular_eta(acb_t r, const acb_t tau, slong prec) + void acb_modular_eta(acb_t r, const acb_t tau, slong prec) noexcept # Computes the Dedekind eta function `\eta(\tau)` given `\tau` in the upper # half-plane. This function applies the functional equation to move # `\tau` to the fundamental domain before calling # :func:`acb_modular_eta_sum`. - void acb_modular_j(acb_t r, const acb_t tau, slong prec) + void acb_modular_j(acb_t r, const acb_t tau, slong prec) noexcept # Computes Klein's j-invariant `j(\tau)` given `\tau` in the upper # half-plane. The function is normalized so that `j(i) = 1728`. # We first move `\tau` to the fundamental domain, which does not change @@ -330,13 +330,13 @@ cdef extern from "flint_wrap.h": # `j(\tau) = 32 (\theta_2^8+\theta_3^8+\theta_4^8)^3 / (\theta_2 \theta_3 \theta_4)^8` where # `\theta_i = \theta_i(0,\tau)`. - void acb_modular_lambda(acb_t r, const acb_t tau, slong prec) + void acb_modular_lambda(acb_t r, const acb_t tau, slong prec) noexcept # Computes the lambda function # `\lambda(\tau) = \theta_2^4(0,\tau) / \theta_3^4(0,\tau)`, which # is invariant under modular transformations `(a, b; c, d)` # where `a, d` are odd and `b, c` are even. - void acb_modular_delta(acb_t r, const acb_t tau, slong prec) + void acb_modular_delta(acb_t r, const acb_t tau, slong prec) noexcept # Computes the modular discriminant `\Delta(\tau) = \eta(\tau)^{24}`, # which transforms as # .. math :: @@ -344,7 +344,7 @@ cdef extern from "flint_wrap.h": # The modular discriminant is sometimes defined with an extra factor # `(2\pi)^{12}`, which we omit in this implementation. - void acb_modular_eisenstein(acb_ptr r, const acb_t tau, slong len, slong prec) + void acb_modular_eisenstein(acb_ptr r, const acb_t tau, slong len, slong prec) noexcept # Computes simultaneously the first *len* entries in the sequence # of Eisenstein series `G_4(\tau), G_6(\tau), G_8(\tau), \ldots`, # defined by @@ -357,17 +357,17 @@ cdef extern from "flint_wrap.h": # domain using theta functions, and then compute the Eisenstein series # of higher index using a recurrence relation. - void acb_modular_elliptic_k(acb_t w, const acb_t m, slong prec) + void acb_modular_elliptic_k(acb_t w, const acb_t m, slong prec) noexcept - void acb_modular_elliptic_k_cpx(acb_ptr w, const acb_t m, slong len, slong prec) + void acb_modular_elliptic_k_cpx(acb_ptr w, const acb_t m, slong len, slong prec) noexcept - void acb_modular_elliptic_e(acb_t w, const acb_t m, slong prec) + void acb_modular_elliptic_e(acb_t w, const acb_t m, slong prec) noexcept - void acb_modular_elliptic_p(acb_t wp, const acb_t z, const acb_t tau, slong prec) + void acb_modular_elliptic_p(acb_t wp, const acb_t z, const acb_t tau, slong prec) noexcept - void acb_modular_elliptic_p_zpx(acb_ptr wp, const acb_t z, const acb_t tau, slong len, slong prec) + void acb_modular_elliptic_p_zpx(acb_ptr wp, const acb_t z, const acb_t tau, slong len, slong prec) noexcept - void acb_modular_hilbert_class_poly(fmpz_poly_t res, slong D) + void acb_modular_hilbert_class_poly(fmpz_poly_t res, slong D) noexcept # Sets *res* to the Hilbert class polynomial of discriminant *D*, # defined as # .. math :: diff --git a/src/sage/libs/flint/acb_poly.pxd b/src/sage/libs/flint/acb_poly.pxd index e70e60587da..8ca5fab29d4 100644 --- a/src/sage/libs/flint/acb_poly.pxd +++ b/src/sage/libs/flint/acb_poly.pxd @@ -12,38 +12,38 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void acb_poly_init(acb_poly_t poly) + void acb_poly_init(acb_poly_t poly) noexcept # Initializes the polynomial for use, setting it to the zero polynomial. - void acb_poly_clear(acb_poly_t poly) + void acb_poly_clear(acb_poly_t poly) noexcept # Clears the polynomial, deallocating all coefficients and the # coefficient array. - void acb_poly_fit_length(acb_poly_t poly, slong len) + void acb_poly_fit_length(acb_poly_t poly, slong len) noexcept # Makes sure that the coefficient array of the polynomial contains at # least *len* initialized coefficients. - void _acb_poly_set_length(acb_poly_t poly, slong len) + void _acb_poly_set_length(acb_poly_t poly, slong len) noexcept # Directly changes the length of the polynomial, without allocating or # deallocating coefficients. The value should not exceed the allocation length. - void _acb_poly_normalise(acb_poly_t poly) + void _acb_poly_normalise(acb_poly_t poly) noexcept # Strips any trailing coefficients which are identical to zero. - void acb_poly_swap(acb_poly_t poly1, acb_poly_t poly2) + void acb_poly_swap(acb_poly_t poly1, acb_poly_t poly2) noexcept # Swaps *poly1* and *poly2* efficiently. - slong acb_poly_allocated_bytes(const acb_poly_t x) + slong acb_poly_allocated_bytes(const acb_poly_t x) noexcept # Returns the total number of bytes heap-allocated internally by this object. # The count excludes the size of the structure itself. Add # ``sizeof(acb_poly_struct)`` to get the size of the object as a whole. - slong acb_poly_length(const acb_poly_t poly) + slong acb_poly_length(const acb_poly_t poly) noexcept # Returns the length of *poly*, i.e. zero if *poly* is # identically zero, and otherwise one more than the index # of the highest term that is not identically zero. - slong acb_poly_degree(const acb_poly_t poly) + slong acb_poly_degree(const acb_poly_t poly) noexcept # Returns the degree of *poly*, defined as one less than its length. # Note that if one or several leading coefficients are balls # containing zero, this value can be larger than the true @@ -51,163 +51,163 @@ cdef extern from "flint_wrap.h": # so the return value of this function is effectively # an upper bound. - bint acb_poly_is_zero(const acb_poly_t poly) + bint acb_poly_is_zero(const acb_poly_t poly) noexcept - bint acb_poly_is_one(const acb_poly_t poly) + bint acb_poly_is_one(const acb_poly_t poly) noexcept - bint acb_poly_is_x(const acb_poly_t poly) + bint acb_poly_is_x(const acb_poly_t poly) noexcept # Returns 1 if *poly* is exactly the polynomial 0, 1 or *x* # respectively. Returns 0 otherwise. - void acb_poly_zero(acb_poly_t poly) + void acb_poly_zero(acb_poly_t poly) noexcept # Sets *poly* to the zero polynomial. - void acb_poly_one(acb_poly_t poly) + void acb_poly_one(acb_poly_t poly) noexcept # Sets *poly* to the constant polynomial 1. - void acb_poly_set(acb_poly_t dest, const acb_poly_t src) + void acb_poly_set(acb_poly_t dest, const acb_poly_t src) noexcept # Sets *dest* to a copy of *src*. - void acb_poly_set_round(acb_poly_t dest, const acb_poly_t src, slong prec) + void acb_poly_set_round(acb_poly_t dest, const acb_poly_t src, slong prec) noexcept # Sets *dest* to a copy of *src*, rounded to *prec* bits. - void acb_poly_set_trunc(acb_poly_t dest, const acb_poly_t src, slong n) + void acb_poly_set_trunc(acb_poly_t dest, const acb_poly_t src, slong n) noexcept - void acb_poly_set_trunc_round(acb_poly_t dest, const acb_poly_t src, slong n, slong prec) + void acb_poly_set_trunc_round(acb_poly_t dest, const acb_poly_t src, slong n, slong prec) noexcept # Sets *dest* to a copy of *src*, truncated to length *n* and rounded to *prec* bits. - void acb_poly_set_coeff_si(acb_poly_t poly, slong n, slong c) + void acb_poly_set_coeff_si(acb_poly_t poly, slong n, slong c) noexcept - void acb_poly_set_coeff_acb(acb_poly_t poly, slong n, const acb_t c) + void acb_poly_set_coeff_acb(acb_poly_t poly, slong n, const acb_t c) noexcept # Sets the coefficient with index *n* in *poly* to the value *c*. # We require that *n* is nonnegative. - void acb_poly_get_coeff_acb(acb_t v, const acb_poly_t poly, slong n) + void acb_poly_get_coeff_acb(acb_t v, const acb_poly_t poly, slong n) noexcept # Sets *v* to the value of the coefficient with index *n* in *poly*. # We require that *n* is nonnegative. - void _acb_poly_shift_right(acb_ptr res, acb_srcptr poly, slong len, slong n) + void _acb_poly_shift_right(acb_ptr res, acb_srcptr poly, slong len, slong n) noexcept - void acb_poly_shift_right(acb_poly_t res, const acb_poly_t poly, slong n) + void acb_poly_shift_right(acb_poly_t res, const acb_poly_t poly, slong n) noexcept # Sets *res* to *poly* divided by `x^n`, throwing away the lower coefficients. # We require that *n* is nonnegative. - void _acb_poly_shift_left(acb_ptr res, acb_srcptr poly, slong len, slong n) + void _acb_poly_shift_left(acb_ptr res, acb_srcptr poly, slong len, slong n) noexcept - void acb_poly_shift_left(acb_poly_t res, const acb_poly_t poly, slong n) + void acb_poly_shift_left(acb_poly_t res, const acb_poly_t poly, slong n) noexcept # Sets *res* to *poly* multiplied by `x^n`. # We require that *n* is nonnegative. - void acb_poly_truncate(acb_poly_t poly, slong n) + void acb_poly_truncate(acb_poly_t poly, slong n) noexcept # Truncates *poly* to have length at most *n*, i.e. degree # strictly smaller than *n*. We require that *n* is nonnegative. - slong acb_poly_valuation(const acb_poly_t poly) + slong acb_poly_valuation(const acb_poly_t poly) noexcept # Returns the degree of the lowest term that is not exactly zero in *poly*. # Returns -1 if *poly* is the zero polynomial. - void acb_poly_printd(const acb_poly_t poly, slong digits) + void acb_poly_printd(const acb_poly_t poly, slong digits) noexcept # Prints the polynomial as an array of coefficients, printing each # coefficient using *acb_printd*. - void acb_poly_fprintd(FILE * file, const acb_poly_t poly, slong digits) + void acb_poly_fprintd(FILE * file, const acb_poly_t poly, slong digits) noexcept # Prints the polynomial as an array of coefficients to the stream *file*, # printing each coefficient using *acb_fprintd*. - void acb_poly_randtest(acb_poly_t poly, flint_rand_t state, slong len, slong prec, slong mag_bits) + void acb_poly_randtest(acb_poly_t poly, flint_rand_t state, slong len, slong prec, slong mag_bits) noexcept # Creates a random polynomial with length at most *len*. - bint acb_poly_equal(const acb_poly_t A, const acb_poly_t B) + bint acb_poly_equal(const acb_poly_t A, const acb_poly_t B) noexcept # Returns nonzero iff *A* and *B* are identical as interval polynomials. - bint acb_poly_contains(const acb_poly_t poly1, const acb_poly_t poly2) + bint acb_poly_contains(const acb_poly_t poly1, const acb_poly_t poly2) noexcept - bint acb_poly_contains_fmpz_poly(const acb_poly_t poly1, const fmpz_poly_t poly2) + bint acb_poly_contains_fmpz_poly(const acb_poly_t poly1, const fmpz_poly_t poly2) noexcept - bint acb_poly_contains_fmpq_poly(const acb_poly_t poly1, const fmpq_poly_t poly2) + bint acb_poly_contains_fmpq_poly(const acb_poly_t poly1, const fmpq_poly_t poly2) noexcept # Returns nonzero iff *poly2* is contained in *poly1*. - bint _acb_poly_overlaps(acb_srcptr poly1, slong len1, acb_srcptr poly2, slong len2) + bint _acb_poly_overlaps(acb_srcptr poly1, slong len1, acb_srcptr poly2, slong len2) noexcept - bint acb_poly_overlaps(const acb_poly_t poly1, const acb_poly_t poly2) + bint acb_poly_overlaps(const acb_poly_t poly1, const acb_poly_t poly2) noexcept # Returns nonzero iff *poly1* overlaps with *poly2*. The underscore # function requires that *len1* is at least as large as *len2*. - int acb_poly_get_unique_fmpz_poly(fmpz_poly_t z, const acb_poly_t x) + int acb_poly_get_unique_fmpz_poly(fmpz_poly_t z, const acb_poly_t x) noexcept # If *x* contains a unique integer polynomial, sets *z* to that value and returns # nonzero. Otherwise (if *x* represents no integers or more than one integer), # returns zero, possibly partially modifying *z*. - bint acb_poly_is_real(const acb_poly_t poly) + bint acb_poly_is_real(const acb_poly_t poly) noexcept # Returns nonzero iff all coefficients in *poly* have zero imaginary part. - void acb_poly_set_fmpz_poly(acb_poly_t poly, const fmpz_poly_t re, slong prec) + void acb_poly_set_fmpz_poly(acb_poly_t poly, const fmpz_poly_t re, slong prec) noexcept - void acb_poly_set2_fmpz_poly(acb_poly_t poly, const fmpz_poly_t re, const fmpz_poly_t im, slong prec) + void acb_poly_set2_fmpz_poly(acb_poly_t poly, const fmpz_poly_t re, const fmpz_poly_t im, slong prec) noexcept - void acb_poly_set_arb_poly(acb_poly_t poly, const arb_poly_t re) + void acb_poly_set_arb_poly(acb_poly_t poly, const arb_poly_t re) noexcept - void acb_poly_set2_arb_poly(acb_poly_t poly, const arb_poly_t re, const arb_poly_t im) + void acb_poly_set2_arb_poly(acb_poly_t poly, const arb_poly_t re, const arb_poly_t im) noexcept - void acb_poly_set_fmpq_poly(acb_poly_t poly, const fmpq_poly_t re, slong prec) + void acb_poly_set_fmpq_poly(acb_poly_t poly, const fmpq_poly_t re, slong prec) noexcept - void acb_poly_set2_fmpq_poly(acb_poly_t poly, const fmpq_poly_t re, const fmpq_poly_t im, slong prec) + void acb_poly_set2_fmpq_poly(acb_poly_t poly, const fmpq_poly_t re, const fmpq_poly_t im, slong prec) noexcept # Sets *poly* to the given real part *re* plus the imaginary part *im*, # both rounded to *prec* bits. - void acb_poly_set_acb(acb_poly_t poly, const acb_t src) + void acb_poly_set_acb(acb_poly_t poly, const acb_t src) noexcept - void acb_poly_set_si(acb_poly_t poly, slong src) + void acb_poly_set_si(acb_poly_t poly, slong src) noexcept # Sets *poly* to *src*. - void _acb_poly_majorant(arb_ptr res, acb_srcptr poly, slong len, slong prec) + void _acb_poly_majorant(arb_ptr res, acb_srcptr poly, slong len, slong prec) noexcept - void acb_poly_majorant(arb_poly_t res, const acb_poly_t poly, slong prec) + void acb_poly_majorant(arb_poly_t res, const acb_poly_t poly, slong prec) noexcept # Sets *res* to an exact real polynomial whose coefficients are # upper bounds for the absolute values of the coefficients in *poly*, # rounded to *prec* bits. - void _acb_poly_add(acb_ptr C, acb_srcptr A, slong lenA, acb_srcptr B, slong lenB, slong prec) + void _acb_poly_add(acb_ptr C, acb_srcptr A, slong lenA, acb_srcptr B, slong lenB, slong prec) noexcept # Sets *{C, max(lenA, lenB)}* to the sum of *{A, lenA}* and *{B, lenB}*. # Allows aliasing of the input and output operands. - void acb_poly_add(acb_poly_t C, const acb_poly_t A, const acb_poly_t B, slong prec) + void acb_poly_add(acb_poly_t C, const acb_poly_t A, const acb_poly_t B, slong prec) noexcept - void acb_poly_add_si(acb_poly_t C, const acb_poly_t A, slong B, slong prec) + void acb_poly_add_si(acb_poly_t C, const acb_poly_t A, slong B, slong prec) noexcept # Sets *C* to the sum of *A* and *B*. - void _acb_poly_sub(acb_ptr C, acb_srcptr A, slong lenA, acb_srcptr B, slong lenB, slong prec) + void _acb_poly_sub(acb_ptr C, acb_srcptr A, slong lenA, acb_srcptr B, slong lenB, slong prec) noexcept # Sets *{C, max(lenA, lenB)}* to the difference of *{A, lenA}* and *{B, lenB}*. # Allows aliasing of the input and output operands. - void acb_poly_sub(acb_poly_t C, const acb_poly_t A, const acb_poly_t B, slong prec) + void acb_poly_sub(acb_poly_t C, const acb_poly_t A, const acb_poly_t B, slong prec) noexcept # Sets *C* to the difference of *A* and *B*. - void acb_poly_add_series(acb_poly_t C, const acb_poly_t A, const acb_poly_t B, slong len, slong prec) + void acb_poly_add_series(acb_poly_t C, const acb_poly_t A, const acb_poly_t B, slong len, slong prec) noexcept # Sets *C* to the sum of *A* and *B*, truncated to length *len*. - void acb_poly_sub_series(acb_poly_t C, const acb_poly_t A, const acb_poly_t B, slong len, slong prec) + void acb_poly_sub_series(acb_poly_t C, const acb_poly_t A, const acb_poly_t B, slong len, slong prec) noexcept # Sets *C* to the difference of *A* and *B*, truncated to length *len*. - void acb_poly_neg(acb_poly_t C, const acb_poly_t A) + void acb_poly_neg(acb_poly_t C, const acb_poly_t A) noexcept # Sets *C* to the negation of *A*. - void acb_poly_scalar_mul_2exp_si(acb_poly_t C, const acb_poly_t A, slong c) + void acb_poly_scalar_mul_2exp_si(acb_poly_t C, const acb_poly_t A, slong c) noexcept # Sets *C* to *A* multiplied by `2^c`. - void acb_poly_scalar_mul(acb_poly_t C, const acb_poly_t A, const acb_t c, slong prec) + void acb_poly_scalar_mul(acb_poly_t C, const acb_poly_t A, const acb_t c, slong prec) noexcept # Sets *C* to *A* multiplied by *c*. - void acb_poly_scalar_div(acb_poly_t C, const acb_poly_t A, const acb_t c, slong prec) + void acb_poly_scalar_div(acb_poly_t C, const acb_poly_t A, const acb_t c, slong prec) noexcept # Sets *C* to *A* divided by *c*. - void _acb_poly_mullow_classical(acb_ptr C, acb_srcptr A, slong lenA, acb_srcptr B, slong lenB, slong n, slong prec) + void _acb_poly_mullow_classical(acb_ptr C, acb_srcptr A, slong lenA, acb_srcptr B, slong lenB, slong n, slong prec) noexcept - void _acb_poly_mullow_transpose(acb_ptr C, acb_srcptr A, slong lenA, acb_srcptr B, slong lenB, slong n, slong prec) + void _acb_poly_mullow_transpose(acb_ptr C, acb_srcptr A, slong lenA, acb_srcptr B, slong lenB, slong n, slong prec) noexcept - void _acb_poly_mullow_transpose_gauss(acb_ptr C, acb_srcptr A, slong lenA, acb_srcptr B, slong lenB, slong n, slong prec) + void _acb_poly_mullow_transpose_gauss(acb_ptr C, acb_srcptr A, slong lenA, acb_srcptr B, slong lenB, slong n, slong prec) noexcept - void _acb_poly_mullow(acb_ptr C, acb_srcptr A, slong lenA, acb_srcptr B, slong lenB, slong n, slong prec) + void _acb_poly_mullow(acb_ptr C, acb_srcptr A, slong lenA, acb_srcptr B, slong lenB, slong n, slong prec) noexcept # Sets *{C, n}* to the product of *{A, lenA}* and *{B, lenB}*, truncated to # length *n*. The output is not allowed to be aliased with either of the # inputs. We require `\mathrm{lenA} \ge \mathrm{lenB} > 0`, @@ -225,18 +225,18 @@ cdef extern from "flint_wrap.h": # they are assumed to represent the same polynomial, and its # square is computed. - void acb_poly_mullow_classical(acb_poly_t C, const acb_poly_t A, const acb_poly_t B, slong n, slong prec) + void acb_poly_mullow_classical(acb_poly_t C, const acb_poly_t A, const acb_poly_t B, slong n, slong prec) noexcept - void acb_poly_mullow_transpose(acb_poly_t C, const acb_poly_t A, const acb_poly_t B, slong n, slong prec) + void acb_poly_mullow_transpose(acb_poly_t C, const acb_poly_t A, const acb_poly_t B, slong n, slong prec) noexcept - void acb_poly_mullow_transpose_gauss(acb_poly_t C, const acb_poly_t A, const acb_poly_t B, slong n, slong prec) + void acb_poly_mullow_transpose_gauss(acb_poly_t C, const acb_poly_t A, const acb_poly_t B, slong n, slong prec) noexcept - void acb_poly_mullow(acb_poly_t C, const acb_poly_t A, const acb_poly_t B, slong n, slong prec) + void acb_poly_mullow(acb_poly_t C, const acb_poly_t A, const acb_poly_t B, slong n, slong prec) noexcept # Sets *C* to the product of *A* and *B*, truncated to length *n*. # If the same variable is passed for *A* and *B*, sets *C* to the # square of *A* truncated to length *n*. - void _acb_poly_mul(acb_ptr C, acb_srcptr A, slong lenA, acb_srcptr B, slong lenB, slong prec) + void _acb_poly_mul(acb_ptr C, acb_srcptr A, slong lenA, acb_srcptr B, slong lenB, slong prec) noexcept # Sets *{C, lenA + lenB - 1}* to the product of *{A, lenA}* and *{B, lenB}*. # The output is not allowed to be aliased with either of the # inputs. We require `\mathrm{lenA} \ge \mathrm{lenB} > 0`. @@ -245,31 +245,31 @@ cdef extern from "flint_wrap.h": # they are assumed to represent the same polynomial, and its # square is computed. - void acb_poly_mul(acb_poly_t C, const acb_poly_t A1, const acb_poly_t B2, slong prec) + void acb_poly_mul(acb_poly_t C, const acb_poly_t A1, const acb_poly_t B2, slong prec) noexcept # Sets *C* to the product of *A* and *B*. # If the same variable is passed for *A* and *B*, sets *C* to # the square of *A*. - void _acb_poly_inv_series(acb_ptr Qinv, acb_srcptr Q, slong Qlen, slong len, slong prec) + void _acb_poly_inv_series(acb_ptr Qinv, acb_srcptr Q, slong Qlen, slong len, slong prec) noexcept # Sets *{Qinv, len}* to the power series inverse of *{Q, Qlen}*. Uses Newton iteration. - void acb_poly_inv_series(acb_poly_t Qinv, const acb_poly_t Q, slong n, slong prec) + void acb_poly_inv_series(acb_poly_t Qinv, const acb_poly_t Q, slong n, slong prec) noexcept # Sets *Qinv* to the power series inverse of *Q*. - void _acb_poly_div_series(acb_ptr Q, acb_srcptr A, slong Alen, acb_srcptr B, slong Blen, slong n, slong prec) + void _acb_poly_div_series(acb_ptr Q, acb_srcptr A, slong Alen, acb_srcptr B, slong Blen, slong n, slong prec) noexcept # Sets *{Q, n}* to the power series quotient of *{A, Alen}* by *{B, Blen}*. # Uses Newton iteration followed by multiplication. - void acb_poly_div_series(acb_poly_t Q, const acb_poly_t A, const acb_poly_t B, slong n, slong prec) + void acb_poly_div_series(acb_poly_t Q, const acb_poly_t A, const acb_poly_t B, slong n, slong prec) noexcept # Sets *Q* to the power series quotient *A* divided by *B*, truncated to length *n*. - void _acb_poly_div(acb_ptr Q, acb_srcptr A, slong lenA, acb_srcptr B, slong lenB, slong prec) + void _acb_poly_div(acb_ptr Q, acb_srcptr A, slong lenA, acb_srcptr B, slong lenB, slong prec) noexcept - void _acb_poly_rem(acb_ptr R, acb_srcptr A, slong lenA, acb_srcptr B, slong lenB, slong prec) + void _acb_poly_rem(acb_ptr R, acb_srcptr A, slong lenA, acb_srcptr B, slong lenB, slong prec) noexcept - void _acb_poly_divrem(acb_ptr Q, acb_ptr R, acb_srcptr A, slong lenA, acb_srcptr B, slong lenB, slong prec) + void _acb_poly_divrem(acb_ptr Q, acb_ptr R, acb_srcptr A, slong lenA, acb_srcptr B, slong lenB, slong prec) noexcept - int acb_poly_divrem(acb_poly_t Q, acb_poly_t R, const acb_poly_t A, const acb_poly_t B, slong prec) + int acb_poly_divrem(acb_poly_t Q, acb_poly_t R, const acb_poly_t A, const acb_poly_t B, slong prec) noexcept # Performs polynomial division with remainder, computing a quotient `Q` and # a remainder `R` such that `A = BQ + R`. The implementation reverses the # inputs and performs power series division. @@ -277,24 +277,24 @@ cdef extern from "flint_wrap.h": # zero), returns 0 indicating failure without modifying the outputs. # Otherwise returns nonzero. - void _acb_poly_div_root(acb_ptr Q, acb_t R, acb_srcptr A, slong len, const acb_t c, slong prec) + void _acb_poly_div_root(acb_ptr Q, acb_t R, acb_srcptr A, slong len, const acb_t c, slong prec) noexcept # Divides `A` by the polynomial `x - c`, computing the quotient `Q` as well # as the remainder `R = f(c)`. - void _acb_poly_taylor_shift(acb_ptr g, const acb_t c, slong n, slong prec) - void acb_poly_taylor_shift(acb_poly_t g, const acb_poly_t f, const acb_t c, slong prec) + void _acb_poly_taylor_shift(acb_ptr g, const acb_t c, slong n, slong prec) noexcept + void acb_poly_taylor_shift(acb_poly_t g, const acb_poly_t f, const acb_t c, slong prec) noexcept # Sets *g* to the Taylor shift `f(x+c)`. # The underscore methods act in-place on *g* = *f* which has length *n*. - void _acb_poly_compose(acb_ptr res, acb_srcptr poly1, slong len1, acb_srcptr poly2, slong len2, slong prec) - void acb_poly_compose(acb_poly_t res, const acb_poly_t poly1, const acb_poly_t poly2, slong prec) + void _acb_poly_compose(acb_ptr res, acb_srcptr poly1, slong len1, acb_srcptr poly2, slong len2, slong prec) noexcept + void acb_poly_compose(acb_poly_t res, const acb_poly_t poly1, const acb_poly_t poly2, slong prec) noexcept # Sets *res* to the composition `h(x) = f(g(x))` where `f` is given by # *poly1* and `g` is given by *poly2*. # The underscore method does not support aliasing of the output # with either input polynomial. - void _acb_poly_compose_series(acb_ptr res, acb_srcptr poly1, slong len1, acb_srcptr poly2, slong len2, slong n, slong prec) - void acb_poly_compose_series(acb_poly_t res, const acb_poly_t poly1, const acb_poly_t poly2, slong n, slong prec) + void _acb_poly_compose_series(acb_ptr res, acb_srcptr poly1, slong len1, acb_srcptr poly2, slong len2, slong n, slong prec) noexcept + void acb_poly_compose_series(acb_poly_t res, const acb_poly_t poly1, const acb_poly_t poly2, slong n, slong prec) noexcept # Sets *res* to the power series composition `h(x) = f(g(x))` truncated # to order `O(x^n)` where `f` is given by *poly1* and `g` is given by *poly2*. # Wraps :func:`_gr_poly_compose_series` which chooses automatically @@ -303,21 +303,21 @@ cdef extern from "flint_wrap.h": # The underscore method does not support aliasing of the output # with either input polynomial. - void _acb_poly_revert_series_lagrange(acb_ptr h, acb_srcptr f, slong flen, slong n, slong prec) + void _acb_poly_revert_series_lagrange(acb_ptr h, acb_srcptr f, slong flen, slong n, slong prec) noexcept - void acb_poly_revert_series_lagrange(acb_poly_t h, const acb_poly_t f, slong n, slong prec) + void acb_poly_revert_series_lagrange(acb_poly_t h, const acb_poly_t f, slong n, slong prec) noexcept - void _acb_poly_revert_series_newton(acb_ptr h, acb_srcptr f, slong flen, slong n, slong prec) + void _acb_poly_revert_series_newton(acb_ptr h, acb_srcptr f, slong flen, slong n, slong prec) noexcept - void acb_poly_revert_series_newton(acb_poly_t h, const acb_poly_t f, slong n, slong prec) + void acb_poly_revert_series_newton(acb_poly_t h, const acb_poly_t f, slong n, slong prec) noexcept - void _acb_poly_revert_series_lagrange_fast(acb_ptr h, acb_srcptr f, slong flen, slong n, slong prec) + void _acb_poly_revert_series_lagrange_fast(acb_ptr h, acb_srcptr f, slong flen, slong n, slong prec) noexcept - void acb_poly_revert_series_lagrange_fast(acb_poly_t h, const acb_poly_t f, slong n, slong prec) + void acb_poly_revert_series_lagrange_fast(acb_poly_t h, const acb_poly_t f, slong n, slong prec) noexcept - void _acb_poly_revert_series(acb_ptr h, acb_srcptr f, slong flen, slong n, slong prec) + void _acb_poly_revert_series(acb_ptr h, acb_srcptr f, slong flen, slong n, slong prec) noexcept - void acb_poly_revert_series(acb_poly_t h, const acb_poly_t f, slong n, slong prec) + void acb_poly_revert_series(acb_poly_t h, const acb_poly_t f, slong n, slong prec) noexcept # Sets `h` to the power series reversion of `f`, i.e. the expansion # of the compositional inverse function `f^{-1}(x)`, # truncated to order `O(x^n)`, using respectively @@ -327,31 +327,31 @@ cdef extern from "flint_wrap.h": # linear term is nonzero. The underscore methods assume that *flen* # is at least 2, and do not support aliasing. - void _acb_poly_evaluate_horner(acb_t y, acb_srcptr f, slong len, const acb_t x, slong prec) + void _acb_poly_evaluate_horner(acb_t y, acb_srcptr f, slong len, const acb_t x, slong prec) noexcept - void acb_poly_evaluate_horner(acb_t y, const acb_poly_t f, const acb_t x, slong prec) + void acb_poly_evaluate_horner(acb_t y, const acb_poly_t f, const acb_t x, slong prec) noexcept - void _acb_poly_evaluate_rectangular(acb_t y, acb_srcptr f, slong len, const acb_t x, slong prec) + void _acb_poly_evaluate_rectangular(acb_t y, acb_srcptr f, slong len, const acb_t x, slong prec) noexcept - void acb_poly_evaluate_rectangular(acb_t y, const acb_poly_t f, const acb_t x, slong prec) + void acb_poly_evaluate_rectangular(acb_t y, const acb_poly_t f, const acb_t x, slong prec) noexcept - void _acb_poly_evaluate(acb_t y, acb_srcptr f, slong len, const acb_t x, slong prec) + void _acb_poly_evaluate(acb_t y, acb_srcptr f, slong len, const acb_t x, slong prec) noexcept - void acb_poly_evaluate(acb_t y, const acb_poly_t f, const acb_t x, slong prec) + void acb_poly_evaluate(acb_t y, const acb_poly_t f, const acb_t x, slong prec) noexcept # Sets `y = f(x)`, evaluated respectively using Horner's rule, # rectangular splitting, and an automatic algorithm choice. - void _acb_poly_evaluate2_horner(acb_t y, acb_t z, acb_srcptr f, slong len, const acb_t x, slong prec) + void _acb_poly_evaluate2_horner(acb_t y, acb_t z, acb_srcptr f, slong len, const acb_t x, slong prec) noexcept - void acb_poly_evaluate2_horner(acb_t y, acb_t z, const acb_poly_t f, const acb_t x, slong prec) + void acb_poly_evaluate2_horner(acb_t y, acb_t z, const acb_poly_t f, const acb_t x, slong prec) noexcept - void _acb_poly_evaluate2_rectangular(acb_t y, acb_t z, acb_srcptr f, slong len, const acb_t x, slong prec) + void _acb_poly_evaluate2_rectangular(acb_t y, acb_t z, acb_srcptr f, slong len, const acb_t x, slong prec) noexcept - void acb_poly_evaluate2_rectangular(acb_t y, acb_t z, const acb_poly_t f, const acb_t x, slong prec) + void acb_poly_evaluate2_rectangular(acb_t y, acb_t z, const acb_poly_t f, const acb_t x, slong prec) noexcept - void _acb_poly_evaluate2(acb_t y, acb_t z, acb_srcptr f, slong len, const acb_t x, slong prec) + void _acb_poly_evaluate2(acb_t y, acb_t z, acb_srcptr f, slong len, const acb_t x, slong prec) noexcept - void acb_poly_evaluate2(acb_t y, acb_t z, const acb_poly_t f, const acb_t x, slong prec) + void acb_poly_evaluate2(acb_t y, acb_t z, const acb_poly_t f, const acb_t x, slong prec) noexcept # Sets `y = f(x), z = f'(x)`, evaluated respectively using Horner's rule, # rectangular splitting, and an automatic algorithm choice. # When Horner's rule is used, the only advantage of evaluating the @@ -360,123 +360,123 @@ cdef extern from "flint_wrap.h": # With the rectangular splitting algorithm, the powers can be reused, # making simultaneous evaluation slightly faster. - void _acb_poly_product_roots(acb_ptr poly, acb_srcptr xs, slong n, slong prec) + void _acb_poly_product_roots(acb_ptr poly, acb_srcptr xs, slong n, slong prec) noexcept - void acb_poly_product_roots(acb_poly_t poly, acb_srcptr xs, slong n, slong prec) + void acb_poly_product_roots(acb_poly_t poly, acb_srcptr xs, slong n, slong prec) noexcept # Generates the polynomial `(x-x_0)(x-x_1)\cdots(x-x_{n-1})`. - acb_ptr * _acb_poly_tree_alloc(slong len) + acb_ptr * _acb_poly_tree_alloc(slong len) noexcept # Returns an initialized data structured capable of representing a # remainder tree (product tree) of *len* roots. - void _acb_poly_tree_free(acb_ptr * tree, slong len) + void _acb_poly_tree_free(acb_ptr * tree, slong len) noexcept # Deallocates a tree structure as allocated using *_acb_poly_tree_alloc*. - void _acb_poly_tree_build(acb_ptr * tree, acb_srcptr roots, slong len, slong prec) + void _acb_poly_tree_build(acb_ptr * tree, acb_srcptr roots, slong len, slong prec) noexcept # Constructs a product tree from a given array of *len* roots. The tree # structure must be pre-allocated to the specified length using # :func:`_acb_poly_tree_alloc`. - void _acb_poly_evaluate_vec_iter(acb_ptr ys, acb_srcptr poly, slong plen, acb_srcptr xs, slong n, slong prec) + void _acb_poly_evaluate_vec_iter(acb_ptr ys, acb_srcptr poly, slong plen, acb_srcptr xs, slong n, slong prec) noexcept - void acb_poly_evaluate_vec_iter(acb_ptr ys, const acb_poly_t poly, acb_srcptr xs, slong n, slong prec) + void acb_poly_evaluate_vec_iter(acb_ptr ys, const acb_poly_t poly, acb_srcptr xs, slong n, slong prec) noexcept # Evaluates the polynomial simultaneously at *n* given points, calling # :func:`_acb_poly_evaluate` repeatedly. - void _acb_poly_evaluate_vec_fast_precomp(acb_ptr vs, acb_srcptr poly, slong plen, acb_ptr * tree, slong len, slong prec) + void _acb_poly_evaluate_vec_fast_precomp(acb_ptr vs, acb_srcptr poly, slong plen, acb_ptr * tree, slong len, slong prec) noexcept - void _acb_poly_evaluate_vec_fast(acb_ptr ys, acb_srcptr poly, slong plen, acb_srcptr xs, slong n, slong prec) + void _acb_poly_evaluate_vec_fast(acb_ptr ys, acb_srcptr poly, slong plen, acb_srcptr xs, slong n, slong prec) noexcept - void acb_poly_evaluate_vec_fast(acb_ptr ys, const acb_poly_t poly, acb_srcptr xs, slong n, slong prec) + void acb_poly_evaluate_vec_fast(acb_ptr ys, const acb_poly_t poly, acb_srcptr xs, slong n, slong prec) noexcept # Evaluates the polynomial simultaneously at *n* given points, using # fast multipoint evaluation. - void _acb_poly_interpolate_newton(acb_ptr poly, acb_srcptr xs, acb_srcptr ys, slong n, slong prec) + void _acb_poly_interpolate_newton(acb_ptr poly, acb_srcptr xs, acb_srcptr ys, slong n, slong prec) noexcept - void acb_poly_interpolate_newton(acb_poly_t poly, acb_srcptr xs, acb_srcptr ys, slong n, slong prec) + void acb_poly_interpolate_newton(acb_poly_t poly, acb_srcptr xs, acb_srcptr ys, slong n, slong prec) noexcept # Recovers the unique polynomial of length at most *n* that interpolates # the given *x* and *y* values. This implementation first interpolates in the # Newton basis and then converts back to the monomial basis. - void _acb_poly_interpolate_barycentric(acb_ptr poly, acb_srcptr xs, acb_srcptr ys, slong n, slong prec) + void _acb_poly_interpolate_barycentric(acb_ptr poly, acb_srcptr xs, acb_srcptr ys, slong n, slong prec) noexcept - void acb_poly_interpolate_barycentric(acb_poly_t poly, acb_srcptr xs, acb_srcptr ys, slong n, slong prec) + void acb_poly_interpolate_barycentric(acb_poly_t poly, acb_srcptr xs, acb_srcptr ys, slong n, slong prec) noexcept # Recovers the unique polynomial of length at most *n* that interpolates # the given *x* and *y* values. This implementation uses the barycentric # form of Lagrange interpolation. - void _acb_poly_interpolation_weights(acb_ptr w, acb_ptr * tree, slong len, slong prec) + void _acb_poly_interpolation_weights(acb_ptr w, acb_ptr * tree, slong len, slong prec) noexcept - void _acb_poly_interpolate_fast_precomp(acb_ptr poly, acb_srcptr ys, acb_ptr * tree, acb_srcptr weights, slong len, slong prec) + void _acb_poly_interpolate_fast_precomp(acb_ptr poly, acb_srcptr ys, acb_ptr * tree, acb_srcptr weights, slong len, slong prec) noexcept - void _acb_poly_interpolate_fast(acb_ptr poly, acb_srcptr xs, acb_srcptr ys, slong len, slong prec) + void _acb_poly_interpolate_fast(acb_ptr poly, acb_srcptr xs, acb_srcptr ys, slong len, slong prec) noexcept - void acb_poly_interpolate_fast(acb_poly_t poly, acb_srcptr xs, acb_srcptr ys, slong n, slong prec) + void acb_poly_interpolate_fast(acb_poly_t poly, acb_srcptr xs, acb_srcptr ys, slong n, slong prec) noexcept # Recovers the unique polynomial of length at most *n* that interpolates # the given *x* and *y* values, using fast Lagrange interpolation. # The precomp function takes a precomputed product tree over the # *x* values and a vector of interpolation weights as additional inputs. - void _acb_poly_derivative(acb_ptr res, acb_srcptr poly, slong len, slong prec) + void _acb_poly_derivative(acb_ptr res, acb_srcptr poly, slong len, slong prec) noexcept # Sets *{res, len - 1}* to the derivative of *{poly, len}*. # Allows aliasing of the input and output. - void acb_poly_derivative(acb_poly_t res, const acb_poly_t poly, slong prec) + void acb_poly_derivative(acb_poly_t res, const acb_poly_t poly, slong prec) noexcept # Sets *res* to the derivative of *poly*. - void _acb_poly_nth_derivative(acb_ptr res, acb_srcptr poly, ulong n, slong len, slong prec) + void _acb_poly_nth_derivative(acb_ptr res, acb_srcptr poly, ulong n, slong len, slong prec) noexcept # Sets *{res, len - n}* to the nth derivative of *{poly, len}*. Does # nothing if *len <= n*. Allows aliasing of the input and output. - void acb_poly_nth_derivative(acb_poly_t res, const acb_poly_t poly, ulong n, slong prec) + void acb_poly_nth_derivative(acb_poly_t res, const acb_poly_t poly, ulong n, slong prec) noexcept # Sets *res* to the nth derivative of *poly*. - void _acb_poly_integral(acb_ptr res, acb_srcptr poly, slong len, slong prec) + void _acb_poly_integral(acb_ptr res, acb_srcptr poly, slong len, slong prec) noexcept # Sets *{res, len}* to the integral of *{poly, len - 1}*. # Allows aliasing of the input and output. - void acb_poly_integral(acb_poly_t res, const acb_poly_t poly, slong prec) + void acb_poly_integral(acb_poly_t res, const acb_poly_t poly, slong prec) noexcept # Sets *res* to the integral of *poly*. - void _acb_poly_borel_transform(acb_ptr res, acb_srcptr poly, slong len, slong prec) + void _acb_poly_borel_transform(acb_ptr res, acb_srcptr poly, slong len, slong prec) noexcept - void acb_poly_borel_transform(acb_poly_t res, const acb_poly_t poly, slong prec) + void acb_poly_borel_transform(acb_poly_t res, const acb_poly_t poly, slong prec) noexcept # Computes the Borel transform of the input polynomial, mapping `\sum_k a_k x^k` # to `\sum_k (a_k / k!) x^k`. The underscore method allows aliasing. - void _acb_poly_inv_borel_transform(acb_ptr res, acb_srcptr poly, slong len, slong prec) + void _acb_poly_inv_borel_transform(acb_ptr res, acb_srcptr poly, slong len, slong prec) noexcept - void acb_poly_inv_borel_transform(acb_poly_t res, const acb_poly_t poly, slong prec) + void acb_poly_inv_borel_transform(acb_poly_t res, const acb_poly_t poly, slong prec) noexcept # Computes the inverse Borel transform of the input polynomial, mapping `\sum_k a_k x^k` # to `\sum_k a_k k! x^k`. The underscore method allows aliasing. - void _acb_poly_binomial_transform_basecase(acb_ptr b, acb_srcptr a, slong alen, slong len, slong prec) + void _acb_poly_binomial_transform_basecase(acb_ptr b, acb_srcptr a, slong alen, slong len, slong prec) noexcept - void acb_poly_binomial_transform_basecase(acb_poly_t b, const acb_poly_t a, slong len, slong prec) + void acb_poly_binomial_transform_basecase(acb_poly_t b, const acb_poly_t a, slong len, slong prec) noexcept - void _acb_poly_binomial_transform_convolution(acb_ptr b, acb_srcptr a, slong alen, slong len, slong prec) + void _acb_poly_binomial_transform_convolution(acb_ptr b, acb_srcptr a, slong alen, slong len, slong prec) noexcept - void acb_poly_binomial_transform_convolution(acb_poly_t b, const acb_poly_t a, slong len, slong prec) + void acb_poly_binomial_transform_convolution(acb_poly_t b, const acb_poly_t a, slong len, slong prec) noexcept - void _acb_poly_binomial_transform(acb_ptr b, acb_srcptr a, slong alen, slong len, slong prec) + void _acb_poly_binomial_transform(acb_ptr b, acb_srcptr a, slong alen, slong len, slong prec) noexcept - void acb_poly_binomial_transform(acb_poly_t b, const acb_poly_t a, slong len, slong prec) + void acb_poly_binomial_transform(acb_poly_t b, const acb_poly_t a, slong len, slong prec) noexcept # Computes the binomial transform of the input polynomial, truncating # the output to length *len*. See :func:`arb_poly_binomial_transform` for # details. # The underscore methods do not support aliasing, and assume that # the lengths are nonzero. - void _acb_poly_graeffe_transform(acb_ptr b, acb_srcptr a, slong len, slong prec) + void _acb_poly_graeffe_transform(acb_ptr b, acb_srcptr a, slong len, slong prec) noexcept - void acb_poly_graeffe_transform(acb_poly_t b, const acb_poly_t a, slong prec) + void acb_poly_graeffe_transform(acb_poly_t b, const acb_poly_t a, slong prec) noexcept # Computes the Graeffe transform of input polynomial, which is of length *len*. # See :func:`arb_poly_graeffe_transform` for details. # The underscore method assumes that *a* and *b* are initialized, # *a* is of length *len*, and *b* is of length at least *len*. # Both methods allow aliasing. - void _acb_poly_pow_ui_trunc_binexp(acb_ptr res, acb_srcptr f, slong flen, ulong exp, slong len, slong prec) + void _acb_poly_pow_ui_trunc_binexp(acb_ptr res, acb_srcptr f, slong flen, ulong exp, slong len, slong prec) noexcept # Sets *{res, len}* to *{f, flen}* raised to the power *exp*, truncated # to length *len*. Requires that *len* is no longer than the length # of the power as computed without truncation (i.e. no zero-padding is performed). @@ -484,19 +484,19 @@ cdef extern from "flint_wrap.h": # that *flen* and *len* are positive. # Uses binary exponentiation. - void acb_poly_pow_ui_trunc_binexp(acb_poly_t res, const acb_poly_t poly, ulong exp, slong len, slong prec) + void acb_poly_pow_ui_trunc_binexp(acb_poly_t res, const acb_poly_t poly, ulong exp, slong len, slong prec) noexcept # Sets *res* to *poly* raised to the power *exp*, truncated to length *len*. # Uses binary exponentiation. - void _acb_poly_pow_ui(acb_ptr res, acb_srcptr f, slong flen, ulong exp, slong prec) + void _acb_poly_pow_ui(acb_ptr res, acb_srcptr f, slong flen, ulong exp, slong prec) noexcept # Sets *res* to *{f, flen}* raised to the power *exp*. Does not # support aliasing of the input and output, and requires that # *flen* is positive. - void acb_poly_pow_ui(acb_poly_t res, const acb_poly_t poly, ulong exp, slong prec) + void acb_poly_pow_ui(acb_poly_t res, const acb_poly_t poly, ulong exp, slong prec) noexcept # Sets *res* to *poly* raised to the power *exp*. - void _acb_poly_pow_series(acb_ptr h, acb_srcptr f, slong flen, acb_srcptr g, slong glen, slong len, slong prec) + void _acb_poly_pow_series(acb_ptr h, acb_srcptr f, slong flen, acb_srcptr g, slong glen, slong len, slong prec) noexcept # Sets *{h, len}* to the power series `f(x)^{g(x)} = \exp(g(x) \log f(x))` truncated # to length *len*. This function detects special cases such as *g* being an # exact small integer or `\pm 1/2`, and computes such powers more @@ -504,13 +504,13 @@ cdef extern from "flint_wrap.h": # with either of the input operands. It requires that all lengths # are positive, and assumes that *flen* and *glen* do not exceed *len*. - void acb_poly_pow_series(acb_poly_t h, const acb_poly_t f, const acb_poly_t g, slong len, slong prec) + void acb_poly_pow_series(acb_poly_t h, const acb_poly_t f, const acb_poly_t g, slong len, slong prec) noexcept # Sets *h* to the power series `f(x)^{g(x)} = \exp(g(x) \log f(x))` truncated # to length *len*. This function detects special cases such as *g* being an # exact small integer or `\pm 1/2`, and computes such powers more # efficiently. - void _acb_poly_pow_acb_series(acb_ptr h, acb_srcptr f, slong flen, const acb_t g, slong len, slong prec) + void _acb_poly_pow_acb_series(acb_ptr h, acb_srcptr f, slong flen, const acb_t g, slong len, slong prec) noexcept # Sets *{h, len}* to the power series `f(x)^g = \exp(g \log f(x))` truncated # to length *len*. This function detects special cases such as *g* being an # exact small integer or `\pm 1/2`, and computes such powers more @@ -518,44 +518,44 @@ cdef extern from "flint_wrap.h": # with either of the input operands. It requires that all lengths # are positive, and assumes that *flen* does not exceed *len*. - void acb_poly_pow_acb_series(acb_poly_t h, const acb_poly_t f, const acb_t g, slong len, slong prec) + void acb_poly_pow_acb_series(acb_poly_t h, const acb_poly_t f, const acb_t g, slong len, slong prec) noexcept # Sets *h* to the power series `f(x)^g = \exp(g \log f(x))` truncated # to length *len*. - void _acb_poly_sqrt_series(acb_ptr g, acb_srcptr h, slong hlen, slong n, slong prec) + void _acb_poly_sqrt_series(acb_ptr g, acb_srcptr h, slong hlen, slong n, slong prec) noexcept - void acb_poly_sqrt_series(acb_poly_t g, const acb_poly_t h, slong n, slong prec) + void acb_poly_sqrt_series(acb_poly_t g, const acb_poly_t h, slong n, slong prec) noexcept # Sets *g* to the power series square root of *h*, truncated to length *n*. # Uses division-free Newton iteration for the reciprocal square root, # followed by a multiplication. # The underscore method does not support aliasing of the input and output # arrays. It requires that *hlen* and *n* are greater than zero. - void _acb_poly_rsqrt_series(acb_ptr g, acb_srcptr h, slong hlen, slong n, slong prec) + void _acb_poly_rsqrt_series(acb_ptr g, acb_srcptr h, slong hlen, slong n, slong prec) noexcept - void acb_poly_rsqrt_series(acb_poly_t g, const acb_poly_t h, slong n, slong prec) + void acb_poly_rsqrt_series(acb_poly_t g, const acb_poly_t h, slong n, slong prec) noexcept # Sets *g* to the reciprocal power series square root of *h*, truncated to length *n*. # Uses division-free Newton iteration. # The underscore method does not support aliasing of the input and output # arrays. It requires that *hlen* and *n* are greater than zero. - void _acb_poly_log_series(acb_ptr res, acb_srcptr f, slong flen, slong n, slong prec) + void _acb_poly_log_series(acb_ptr res, acb_srcptr f, slong flen, slong n, slong prec) noexcept - void acb_poly_log_series(acb_poly_t res, const acb_poly_t f, slong n, slong prec) + void acb_poly_log_series(acb_poly_t res, const acb_poly_t f, slong n, slong prec) noexcept # Sets *res* to the power series logarithm of *f*, truncated to length *n*. # Uses the formula `\log(f(x)) = \int f'(x) / f(x) dx`, adding the logarithm of the # constant term in *f* as the constant of integration. # The underscore method supports aliasing of the input and output # arrays. It requires that *flen* and *n* are greater than zero. - void _acb_poly_log1p_series(acb_ptr res, acb_srcptr f, slong flen, slong n, slong prec) + void _acb_poly_log1p_series(acb_ptr res, acb_srcptr f, slong flen, slong n, slong prec) noexcept - void acb_poly_log1p_series(acb_poly_t res, const acb_poly_t f, slong n, slong prec) + void acb_poly_log1p_series(acb_poly_t res, const acb_poly_t f, slong n, slong prec) noexcept # Computes the power series `\log(1+f)`, with better accuracy when the constant term of *f* is small. - void _acb_poly_atan_series(acb_ptr res, acb_srcptr f, slong flen, slong n, slong prec) + void _acb_poly_atan_series(acb_ptr res, acb_srcptr f, slong flen, slong n, slong prec) noexcept - void acb_poly_atan_series(acb_poly_t res, const acb_poly_t f, slong n, slong prec) + void acb_poly_atan_series(acb_poly_t res, const acb_poly_t f, slong n, slong prec) noexcept # Sets *res* the power series inverse tangent of *f*, truncated to length *n*. # Uses the formula # .. math :: @@ -564,13 +564,13 @@ cdef extern from "flint_wrap.h": # The underscore method supports aliasing of the input and output # arrays. It requires that *flen* and *n* are greater than zero. - void _acb_poly_exp_series_basecase(acb_ptr f, acb_srcptr h, slong hlen, slong n, slong prec) + void _acb_poly_exp_series_basecase(acb_ptr f, acb_srcptr h, slong hlen, slong n, slong prec) noexcept - void acb_poly_exp_series_basecase(acb_poly_t f, const acb_poly_t h, slong n, slong prec) + void acb_poly_exp_series_basecase(acb_poly_t f, const acb_poly_t h, slong n, slong prec) noexcept - void _acb_poly_exp_series(acb_ptr f, acb_srcptr h, slong hlen, slong n, slong prec) + void _acb_poly_exp_series(acb_ptr f, acb_srcptr h, slong hlen, slong n, slong prec) noexcept - void acb_poly_exp_series(acb_poly_t f, const acb_poly_t h, slong n, slong prec) + void acb_poly_exp_series(acb_poly_t f, const acb_poly_t h, slong n, slong prec) noexcept # Sets `f` to the power series exponential of `h`, truncated to length `n`. # The basecase version uses a simple recurrence for the coefficients, # requiring `O(nm)` operations where `m` is the length of `h`. @@ -581,33 +581,33 @@ cdef extern from "flint_wrap.h": # The underscore methods support aliasing and allow the input to be # shorter than the output, but require the lengths to be nonzero. - void _acb_poly_exp_pi_i_series(acb_ptr f, acb_srcptr h, slong hlen, slong n, slong prec) + void _acb_poly_exp_pi_i_series(acb_ptr f, acb_srcptr h, slong hlen, slong n, slong prec) noexcept - void acb_poly_exp_pi_i_series(acb_poly_t f, const acb_poly_t h, slong n, slong prec) + void acb_poly_exp_pi_i_series(acb_poly_t f, const acb_poly_t h, slong n, slong prec) noexcept # Sets *f* to the power series `\exp(\pi i h)` truncated to length *n*. # The underscore method supports aliasing and allows the input to be # shorter than the output, but requires the lengths to be nonzero. - void _acb_poly_sin_cos_series(acb_ptr s, acb_ptr c, acb_srcptr h, slong hlen, slong n, slong prec) - void acb_poly_sin_cos_series(acb_poly_t s, acb_poly_t c, const acb_poly_t h, slong n, slong prec) + void _acb_poly_sin_cos_series(acb_ptr s, acb_ptr c, acb_srcptr h, slong hlen, slong n, slong prec) noexcept + void acb_poly_sin_cos_series(acb_poly_t s, acb_poly_t c, const acb_poly_t h, slong n, slong prec) noexcept # Sets *s* and *c* to the power series sine and cosine of *h*, computed # simultaneously. # The underscore method supports aliasing and requires the lengths to be nonzero. - void _acb_poly_sin_series(acb_ptr s, acb_srcptr h, slong hlen, slong n, slong prec) + void _acb_poly_sin_series(acb_ptr s, acb_srcptr h, slong hlen, slong n, slong prec) noexcept - void acb_poly_sin_series(acb_poly_t s, const acb_poly_t h, slong n, slong prec) + void acb_poly_sin_series(acb_poly_t s, const acb_poly_t h, slong n, slong prec) noexcept - void _acb_poly_cos_series(acb_ptr c, acb_srcptr h, slong hlen, slong n, slong prec) + void _acb_poly_cos_series(acb_ptr c, acb_srcptr h, slong hlen, slong n, slong prec) noexcept - void acb_poly_cos_series(acb_poly_t c, const acb_poly_t h, slong n, slong prec) + void acb_poly_cos_series(acb_poly_t c, const acb_poly_t h, slong n, slong prec) noexcept # Respectively evaluates the power series sine or cosine. These functions # simply wrap :func:`_acb_poly_sin_cos_series`. The underscore methods # support aliasing and require the lengths to be nonzero. - void _acb_poly_tan_series(acb_ptr g, acb_srcptr h, slong hlen, slong len, slong prec) + void _acb_poly_tan_series(acb_ptr g, acb_srcptr h, slong hlen, slong len, slong prec) noexcept - void acb_poly_tan_series(acb_poly_t g, const acb_poly_t h, slong n, slong prec) + void acb_poly_tan_series(acb_poly_t g, const acb_poly_t h, slong n, slong prec) noexcept # Sets *g* to the power series tangent of *h*. # For small *n* takes the quotient of the sine and cosine as computed # using the basecase algorithm. For large *n*, uses Newton iteration @@ -615,77 +615,77 @@ cdef extern from "flint_wrap.h": # The underscore version does not support aliasing, and requires # the lengths to be nonzero. - void _acb_poly_sin_cos_pi_series(acb_ptr s, acb_ptr c, acb_srcptr h, slong hlen, slong n, slong prec) + void _acb_poly_sin_cos_pi_series(acb_ptr s, acb_ptr c, acb_srcptr h, slong hlen, slong n, slong prec) noexcept - void acb_poly_sin_cos_pi_series(acb_poly_t s, acb_poly_t c, const acb_poly_t h, slong n, slong prec) + void acb_poly_sin_cos_pi_series(acb_poly_t s, acb_poly_t c, const acb_poly_t h, slong n, slong prec) noexcept - void _acb_poly_sin_pi_series(acb_ptr s, acb_srcptr h, slong hlen, slong n, slong prec) + void _acb_poly_sin_pi_series(acb_ptr s, acb_srcptr h, slong hlen, slong n, slong prec) noexcept - void acb_poly_sin_pi_series(acb_poly_t s, const acb_poly_t h, slong n, slong prec) + void acb_poly_sin_pi_series(acb_poly_t s, const acb_poly_t h, slong n, slong prec) noexcept - void _acb_poly_cos_pi_series(acb_ptr c, acb_srcptr h, slong hlen, slong n, slong prec) + void _acb_poly_cos_pi_series(acb_ptr c, acb_srcptr h, slong hlen, slong n, slong prec) noexcept - void acb_poly_cos_pi_series(acb_poly_t c, const acb_poly_t h, slong n, slong prec) + void acb_poly_cos_pi_series(acb_poly_t c, const acb_poly_t h, slong n, slong prec) noexcept - void _acb_poly_cot_pi_series(acb_ptr c, acb_srcptr h, slong hlen, slong n, slong prec) + void _acb_poly_cot_pi_series(acb_ptr c, acb_srcptr h, slong hlen, slong n, slong prec) noexcept - void acb_poly_cot_pi_series(acb_poly_t c, const acb_poly_t h, slong n, slong prec) + void acb_poly_cot_pi_series(acb_poly_t c, const acb_poly_t h, slong n, slong prec) noexcept # Compute the respective trigonometric functions of the input # multiplied by `\pi`. - void _acb_poly_sinh_cosh_series_basecase(acb_ptr s, acb_ptr c, acb_srcptr h, slong hlen, slong n, slong prec) + void _acb_poly_sinh_cosh_series_basecase(acb_ptr s, acb_ptr c, acb_srcptr h, slong hlen, slong n, slong prec) noexcept - void acb_poly_sinh_cosh_series_basecase(acb_poly_t s, acb_poly_t c, const acb_poly_t h, slong n, slong prec) + void acb_poly_sinh_cosh_series_basecase(acb_poly_t s, acb_poly_t c, const acb_poly_t h, slong n, slong prec) noexcept - void _acb_poly_sinh_cosh_series_exponential(acb_ptr s, acb_ptr c, acb_srcptr h, slong hlen, slong n, slong prec) + void _acb_poly_sinh_cosh_series_exponential(acb_ptr s, acb_ptr c, acb_srcptr h, slong hlen, slong n, slong prec) noexcept - void acb_poly_sinh_cosh_series_exponential(acb_poly_t s, acb_poly_t c, const acb_poly_t h, slong n, slong prec) + void acb_poly_sinh_cosh_series_exponential(acb_poly_t s, acb_poly_t c, const acb_poly_t h, slong n, slong prec) noexcept - void _acb_poly_sinh_cosh_series(acb_ptr s, acb_ptr c, acb_srcptr h, slong hlen, slong n, slong prec) + void _acb_poly_sinh_cosh_series(acb_ptr s, acb_ptr c, acb_srcptr h, slong hlen, slong n, slong prec) noexcept - void acb_poly_sinh_cosh_series(acb_poly_t s, acb_poly_t c, const acb_poly_t h, slong n, slong prec) + void acb_poly_sinh_cosh_series(acb_poly_t s, acb_poly_t c, const acb_poly_t h, slong n, slong prec) noexcept - void _acb_poly_sinh_series(acb_ptr s, acb_srcptr h, slong hlen, slong n, slong prec) + void _acb_poly_sinh_series(acb_ptr s, acb_srcptr h, slong hlen, slong n, slong prec) noexcept - void acb_poly_sinh_series(acb_poly_t s, const acb_poly_t h, slong n, slong prec) + void acb_poly_sinh_series(acb_poly_t s, const acb_poly_t h, slong n, slong prec) noexcept - void _acb_poly_cosh_series(acb_ptr c, acb_srcptr h, slong hlen, slong n, slong prec) + void _acb_poly_cosh_series(acb_ptr c, acb_srcptr h, slong hlen, slong n, slong prec) noexcept - void acb_poly_cosh_series(acb_poly_t c, const acb_poly_t h, slong n, slong prec) + void acb_poly_cosh_series(acb_poly_t c, const acb_poly_t h, slong n, slong prec) noexcept # Sets *s* and *c* respectively to the hyperbolic sine and cosine of the # power series *h*, truncated to length *n*. # The implementations mirror those for sine and cosine, except that # the *exponential* version computes both functions using the exponential # function instead of the hyperbolic tangent. - void _acb_poly_sinc_series(acb_ptr s, acb_srcptr h, slong hlen, slong n, slong prec) + void _acb_poly_sinc_series(acb_ptr s, acb_srcptr h, slong hlen, slong n, slong prec) noexcept - void acb_poly_sinc_series(acb_poly_t s, const acb_poly_t h, slong n, slong prec) + void acb_poly_sinc_series(acb_poly_t s, const acb_poly_t h, slong n, slong prec) noexcept # Sets *s* to the sinc function of the power series *h*, truncated # to length *n*. - void _acb_poly_lambertw_series(acb_ptr res, acb_srcptr z, slong zlen, const fmpz_t k, int flags, slong len, slong prec) + void _acb_poly_lambertw_series(acb_ptr res, acb_srcptr z, slong zlen, const fmpz_t k, int flags, slong len, slong prec) noexcept - void acb_poly_lambertw_series(acb_poly_t res, const acb_poly_t z, const fmpz_t k, int flags, slong len, slong prec) + void acb_poly_lambertw_series(acb_poly_t res, const acb_poly_t z, const fmpz_t k, int flags, slong len, slong prec) noexcept # Sets *res* to branch *k* of the Lambert W function of the power series *z*. # The argument *flags* is reserved for future use. # The underscore method allows aliasing, but assumes that the lengths are nonzero. - void _acb_poly_gamma_series(acb_ptr res, acb_srcptr h, slong hlen, slong n, slong prec) + void _acb_poly_gamma_series(acb_ptr res, acb_srcptr h, slong hlen, slong n, slong prec) noexcept - void acb_poly_gamma_series(acb_poly_t res, const acb_poly_t h, slong n, slong prec) + void acb_poly_gamma_series(acb_poly_t res, const acb_poly_t h, slong n, slong prec) noexcept - void _acb_poly_rgamma_series(acb_ptr res, acb_srcptr h, slong hlen, slong n, slong prec) + void _acb_poly_rgamma_series(acb_ptr res, acb_srcptr h, slong hlen, slong n, slong prec) noexcept - void acb_poly_rgamma_series(acb_poly_t res, const acb_poly_t h, slong n, slong prec) + void acb_poly_rgamma_series(acb_poly_t res, const acb_poly_t h, slong n, slong prec) noexcept - void _acb_poly_lgamma_series(acb_ptr res, acb_srcptr h, slong hlen, slong n, slong prec) + void _acb_poly_lgamma_series(acb_ptr res, acb_srcptr h, slong hlen, slong n, slong prec) noexcept - void acb_poly_lgamma_series(acb_poly_t res, const acb_poly_t h, slong n, slong prec) + void acb_poly_lgamma_series(acb_poly_t res, const acb_poly_t h, slong n, slong prec) noexcept - void _acb_poly_digamma_series(acb_ptr res, acb_srcptr h, slong hlen, slong n, slong prec) + void _acb_poly_digamma_series(acb_ptr res, acb_srcptr h, slong hlen, slong n, slong prec) noexcept - void acb_poly_digamma_series(acb_poly_t res, const acb_poly_t h, slong n, slong prec) + void acb_poly_digamma_series(acb_poly_t res, const acb_poly_t h, slong n, slong prec) noexcept # Sets *res* to the series expansion of `\Gamma(h(x))`, `1/\Gamma(h(x))`, # or `\log \Gamma(h(x))`, `\psi(h(x))`, truncated to length *n*. # These functions first generate the Taylor series at the constant @@ -694,16 +694,16 @@ cdef extern from "flint_wrap.h": # The underscore methods support aliasing of the input and output # arrays, and require that *hlen* and *n* are greater than zero. - void _acb_poly_rising_ui_series(acb_ptr res, acb_srcptr f, slong flen, ulong r, slong trunc, slong prec) + void _acb_poly_rising_ui_series(acb_ptr res, acb_srcptr f, slong flen, ulong r, slong trunc, slong prec) noexcept - void acb_poly_rising_ui_series(acb_poly_t res, const acb_poly_t f, ulong r, slong trunc, slong prec) + void acb_poly_rising_ui_series(acb_poly_t res, const acb_poly_t f, ulong r, slong trunc, slong prec) noexcept # Sets *res* to the rising factorial `(f) (f+1) (f+2) \cdots (f+r-1)`, truncated # to length *trunc*. The underscore method assumes that *flen*, *r* and *trunc* # are at least 1, and does not support aliasing. Uses binary splitting. - void _acb_poly_powsum_series_naive(acb_ptr z, const acb_t s, const acb_t a, const acb_t q, slong n, slong len, slong prec) + void _acb_poly_powsum_series_naive(acb_ptr z, const acb_t s, const acb_t a, const acb_t q, slong n, slong len, slong prec) noexcept - void _acb_poly_powsum_series_naive_threaded(acb_ptr z, const acb_t s, const acb_t a, const acb_t q, slong n, slong len, slong prec) + void _acb_poly_powsum_series_naive_threaded(acb_ptr z, const acb_t s, const acb_t a, const acb_t q, slong n, slong len, slong prec) noexcept # Computes # .. math :: # z = S(s,a,n) = \sum_{k=0}^{n-1} \frac{q^k}{(k+a)^{s+t}} @@ -712,7 +712,7 @@ cdef extern from "flint_wrap.h": # The *threaded* version splits the computation # over the number of threads returned by *flint_get_num_threads()*. - void _acb_poly_powsum_one_series_sieved(acb_ptr z, const acb_t s, slong n, slong len, slong prec) + void _acb_poly_powsum_one_series_sieved(acb_ptr z, const acb_t s, slong n, slong len, slong prec) noexcept # Computes # .. math :: # z = S(s,1,n) \sum_{k=1}^n \frac{1}{k^{s+t}} @@ -726,23 +726,23 @@ cdef extern from "flint_wrap.h": # power series multiplications, it is only faster than the naive # algorithm when *len* is small. - void _acb_poly_zeta_em_choose_param(mag_t bound, ulong * N, ulong * M, const acb_t s, const acb_t a, slong d, slong target, slong prec) + void _acb_poly_zeta_em_choose_param(mag_t bound, ulong * N, ulong * M, const acb_t s, const acb_t a, slong d, slong target, slong prec) noexcept # Chooses *N* and *M* for Euler-Maclaurin summation of the # Hurwitz zeta function, using a default algorithm. - void _acb_poly_zeta_em_bound1(mag_t bound, const acb_t s, const acb_t a, slong N, slong M, slong d, slong wp) + void _acb_poly_zeta_em_bound1(mag_t bound, const acb_t s, const acb_t a, slong N, slong M, slong d, slong wp) noexcept - void _acb_poly_zeta_em_bound(arb_ptr vec, const acb_t s, const acb_t a, ulong N, ulong M, slong d, slong wp) + void _acb_poly_zeta_em_bound(arb_ptr vec, const acb_t s, const acb_t a, ulong N, ulong M, slong d, slong wp) noexcept # Compute bounds for Euler-Maclaurin evaluation of the Hurwitz zeta function # or its power series, using the formulas in [Joh2013]_. - void _acb_poly_zeta_em_tail_naive(acb_ptr z, const acb_t s, const acb_t Na, acb_srcptr Nasx, slong M, slong len, slong prec) + void _acb_poly_zeta_em_tail_naive(acb_ptr z, const acb_t s, const acb_t Na, acb_srcptr Nasx, slong M, slong len, slong prec) noexcept - void _acb_poly_zeta_em_tail_bsplit(acb_ptr z, const acb_t s, const acb_t Na, acb_srcptr Nasx, slong M, slong len, slong prec) + void _acb_poly_zeta_em_tail_bsplit(acb_ptr z, const acb_t s, const acb_t Na, acb_srcptr Nasx, slong M, slong len, slong prec) noexcept # Evaluates the tail in the Euler-Maclaurin sum for the Hurwitz zeta # function, respectively using the naive recurrence and binary splitting. - void _acb_poly_zeta_em_sum(acb_ptr z, const acb_t s, const acb_t a, int deflate, ulong N, ulong M, slong d, slong prec) + void _acb_poly_zeta_em_sum(acb_ptr z, const acb_t s, const acb_t a, int deflate, ulong N, ulong M, slong d, slong prec) noexcept # Evaluates the truncated Euler-Maclaurin sum of order `N, M` for the # length-*d* truncated Taylor series of the Hurwitz zeta function # `\zeta(s,a)` at `s`, using a working precision of *prec* bits. @@ -750,16 +750,16 @@ cdef extern from "flint_wrap.h": # If *deflate* is nonzero, `\zeta(s,a) - 1/(s-1)` is evaluated # (which permits series expansion at `s = 1`). - void _acb_poly_zeta_cpx_series(acb_ptr z, const acb_t s, const acb_t a, int deflate, slong d, slong prec) + void _acb_poly_zeta_cpx_series(acb_ptr z, const acb_t s, const acb_t a, int deflate, slong d, slong prec) noexcept # Computes the series expansion of `\zeta(s+x,a)` (or # `\zeta(s+x,a) - 1/(s+x-1)` if *deflate* is nonzero) to order *d*. # This function wraps :func:`_acb_poly_zeta_em_sum`, automatically choosing # default values for `N, M` using :func:`_acb_poly_zeta_em_choose_param` to # target an absolute truncation error of `2^{-\operatorname{prec}}`. - void _acb_poly_zeta_series(acb_ptr res, acb_srcptr h, slong hlen, const acb_t a, int deflate, slong len, slong prec) + void _acb_poly_zeta_series(acb_ptr res, acb_srcptr h, slong hlen, const acb_t a, int deflate, slong len, slong prec) noexcept - void acb_poly_zeta_series(acb_poly_t res, const acb_poly_t f, const acb_t a, int deflate, slong n, slong prec) + void acb_poly_zeta_series(acb_poly_t res, const acb_poly_t f, const acb_t a, int deflate, slong n, slong prec) noexcept # Sets *res* to the Hurwitz zeta function `\zeta(s,a)` where `s` a power # series and `a` is a constant, truncated to length *n*. # To evaluate the usual Riemann zeta function, set `a = 1`. @@ -772,11 +772,11 @@ cdef extern from "flint_wrap.h": # If `a = 1`, this implementation uses the reflection formula if the midpoint # of the constant term of `s` is negative. - void _acb_poly_polylog_cpx_small(acb_ptr w, const acb_t s, const acb_t z, slong len, slong prec) + void _acb_poly_polylog_cpx_small(acb_ptr w, const acb_t s, const acb_t z, slong len, slong prec) noexcept - void _acb_poly_polylog_cpx_zeta(acb_ptr w, const acb_t s, const acb_t z, slong len, slong prec) + void _acb_poly_polylog_cpx_zeta(acb_ptr w, const acb_t s, const acb_t z, slong len, slong prec) noexcept - void _acb_poly_polylog_cpx(acb_ptr w, const acb_t s, const acb_t z, slong len, slong prec) + void _acb_poly_polylog_cpx(acb_ptr w, const acb_t s, const acb_t z, slong len, slong prec) noexcept # Sets *w* to the Taylor series with respect to *x* of the polylogarithm # `\operatorname{Li}_{s+x}(z)`, where *s* and *z* are given complex # constants. The output is computed to length *len* which must be positive. @@ -788,39 +788,39 @@ cdef extern from "flint_wrap.h": # when *z* is close to zero, and the *zeta* version otherwise. # For further details, see :ref:`algorithms_polylogarithms`. - void _acb_poly_polylog_series(acb_ptr w, acb_srcptr s, slong slen, const acb_t z, slong len, slong prec) + void _acb_poly_polylog_series(acb_ptr w, acb_srcptr s, slong slen, const acb_t z, slong len, slong prec) noexcept - void acb_poly_polylog_series(acb_poly_t w, const acb_poly_t s, const acb_t z, slong len, slong prec) + void acb_poly_polylog_series(acb_poly_t w, const acb_poly_t s, const acb_t z, slong len, slong prec) noexcept # Sets *w* to the polylogarithm `\operatorname{Li}_{s}(z)` where *s* is a given # power series, truncating the output to length *len*. The underscore method # requires all lengths to be positive and supports aliasing between # all inputs and outputs. - void _acb_poly_erf_series(acb_ptr res, acb_srcptr z, slong zlen, slong n, slong prec) + void _acb_poly_erf_series(acb_ptr res, acb_srcptr z, slong zlen, slong n, slong prec) noexcept - void acb_poly_erf_series(acb_poly_t res, const acb_poly_t z, slong n, slong prec) + void acb_poly_erf_series(acb_poly_t res, const acb_poly_t z, slong n, slong prec) noexcept # Sets *res* to the error function of the power series *z*, truncated to length *n*. # These methods are provided for backwards compatibility. # See :func:`acb_hypgeom_erf_series`, :func:`acb_hypgeom_erfc_series`, # :func:`acb_hypgeom_erfi_series`. - void _acb_poly_agm1_series(acb_ptr res, acb_srcptr z, slong zlen, slong len, slong prec) + void _acb_poly_agm1_series(acb_ptr res, acb_srcptr z, slong zlen, slong len, slong prec) noexcept - void acb_poly_agm1_series(acb_poly_t res, const acb_poly_t z, slong n, slong prec) + void acb_poly_agm1_series(acb_poly_t res, const acb_poly_t z, slong n, slong prec) noexcept # Sets *res* to the arithmetic-geometric mean of 1 and the power series *z*, # truncated to length *n*. - void _acb_poly_elliptic_k_series(acb_ptr res, acb_srcptr z, slong zlen, slong len, slong prec) + void _acb_poly_elliptic_k_series(acb_ptr res, acb_srcptr z, slong zlen, slong len, slong prec) noexcept - void acb_poly_elliptic_k_series(acb_poly_t res, const acb_poly_t z, slong n, slong prec) + void acb_poly_elliptic_k_series(acb_poly_t res, const acb_poly_t z, slong n, slong prec) noexcept - void _acb_poly_elliptic_p_series(acb_ptr res, acb_srcptr z, slong zlen, const acb_t tau, slong len, slong prec) + void _acb_poly_elliptic_p_series(acb_ptr res, acb_srcptr z, slong zlen, const acb_t tau, slong len, slong prec) noexcept - void acb_poly_elliptic_p_series(acb_poly_t res, const acb_poly_t z, const acb_t tau, slong n, slong prec) + void acb_poly_elliptic_p_series(acb_poly_t res, const acb_poly_t z, const acb_t tau, slong n, slong prec) noexcept - void _acb_poly_root_bound_fujiwara(mag_t bound, acb_srcptr poly, slong len) + void _acb_poly_root_bound_fujiwara(mag_t bound, acb_srcptr poly, slong len) noexcept - void acb_poly_root_bound_fujiwara(mag_t bound, acb_poly_t poly) + void acb_poly_root_bound_fujiwara(mag_t bound, acb_poly_t poly) noexcept # Sets *bound* to an upper bound for the magnitude of all the complex # roots of *poly*. Uses Fujiwara's bound # .. math :: @@ -832,7 +832,7 @@ cdef extern from "flint_wrap.h": # \right\} # where `a_0, \ldots, a_n` are the coefficients of *poly*. - void _acb_poly_root_inclusion(acb_t r, const acb_t m, acb_srcptr poly, acb_srcptr polyder, slong len, slong prec) + void _acb_poly_root_inclusion(acb_t r, const acb_t m, acb_srcptr poly, acb_srcptr polyder, slong len, slong prec) noexcept # Given any complex number `m`, and a nonconstant polynomial `f` and its # derivative `f'`, sets *r* to a complex interval centered on `m` that is # guaranteed to contain at least one root of `f`. @@ -846,7 +846,7 @@ cdef extern from "flint_wrap.h": # < \frac{n}{r} = \left|\frac{f'(m)}{f(m)}\right| # which is a contradiction (see [Kob2010]_). - slong _acb_poly_validate_roots(acb_ptr roots, acb_srcptr poly, slong len, slong prec) + slong _acb_poly_validate_roots(acb_ptr roots, acb_srcptr poly, slong len, slong prec) noexcept # Given a list of approximate roots of the input polynomial, this # function sets a rigorous bounding interval for each root, and determines # which roots are isolated from all the other roots. @@ -858,15 +858,15 @@ cdef extern from "flint_wrap.h": # it is possible that not all of the polynomial's roots are contained # among them. - void _acb_poly_refine_roots_durand_kerner(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) noexcept # Refines the given roots simultaneously using a single iteration # of the Durand-Kerner method. The radius of each root is set to an # approximation of the correction, giving a rough estimate of its error (not # a rigorous bound). - 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, acb_srcptr poly, acb_srcptr initial, slong len, slong maxiter, slong prec) noexcept - slong acb_poly_find_roots(acb_ptr roots, const acb_poly_t poly, acb_srcptr initial, slong maxiter, slong prec) + slong acb_poly_find_roots(acb_ptr roots, const acb_poly_t poly, acb_srcptr initial, slong maxiter, slong prec) noexcept # Attempts to compute all the roots of the given nonzero polynomial *poly* # using a working precision of *prec* bits. If *n* denotes the degree of *poly*, # the function writes *n* approximate roots with rigorous error bounds to @@ -887,9 +887,9 @@ cdef extern from "flint_wrap.h": # roots, the iteration is likely to find them (with low numerical accuracy), # but the error bounds will not converge as the precision increases. - int _acb_poly_validate_real_roots(acb_srcptr roots, acb_srcptr poly, slong len, slong prec) + int _acb_poly_validate_real_roots(acb_srcptr roots, acb_srcptr poly, slong len, slong prec) noexcept - int acb_poly_validate_real_roots(acb_srcptr roots, const acb_poly_t poly, slong prec) + int acb_poly_validate_real_roots(acb_srcptr roots, const acb_poly_t poly, slong prec) noexcept # Given a strictly real polynomial *poly* (of length *len*) and isolating # intervals for all its complex roots, determines if all the real roots # are separated from the non-real roots. If this function returns nonzero, diff --git a/src/sage/libs/flint/acf.pxd b/src/sage/libs/flint/acf.pxd index ef753271a14..1cde16d26ea 100644 --- a/src/sage/libs/flint/acf.pxd +++ b/src/sage/libs/flint/acf.pxd @@ -12,46 +12,46 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void acf_init(acf_t x) + void acf_init(acf_t x) noexcept # Initializes the variable *x* for use, and sets its value to zero. - void acf_clear(acf_t x) + void acf_clear(acf_t x) noexcept # Clears the variable *x*, freeing or recycling its allocated memory. - void acf_swap(acf_t z, acf_t x) + void acf_swap(acf_t z, acf_t x) noexcept # Swaps *z* and *x* efficiently. - slong acf_allocated_bytes(const acf_t x) + slong acf_allocated_bytes(const acf_t x) noexcept # Returns the total number of bytes heap-allocated internally by this object. # The count excludes the size of the structure itself. Add # ``sizeof(acf_struct)`` to get the size of the object as a whole. - arf_ptr acf_real_ptr(acf_t z) - arf_ptr acf_imag_ptr(acf_t z) + arf_ptr acf_real_ptr(acf_t z) noexcept + arf_ptr acf_imag_ptr(acf_t z) noexcept # Returns a pointer to the real or imaginary part of *z*. - void acf_set(acf_t z, const acf_t x) + void acf_set(acf_t z, const acf_t x) noexcept # Sets *z* to the value *x*. - bint acf_equal(const acf_t x, const acf_t y) + bint acf_equal(const acf_t x, const acf_t y) noexcept # Returns whether *x* and *y* are equal. - int acf_add(acf_t res, const acf_t x, const acf_t y, slong prec, arf_rnd_t rnd) + int acf_add(acf_t res, const acf_t x, const acf_t y, slong prec, arf_rnd_t rnd) noexcept - int acf_sub(acf_t res, const acf_t x, const acf_t y, slong prec, arf_rnd_t rnd) + int acf_sub(acf_t res, const acf_t x, const acf_t y, slong prec, arf_rnd_t rnd) noexcept - int acf_mul(acf_t res, const acf_t x, const acf_t y, slong prec, arf_rnd_t rnd) + int acf_mul(acf_t res, const acf_t x, const acf_t y, slong prec, arf_rnd_t rnd) noexcept # Sets *res* to the sum, difference or product of *x* or *y*, correctly # rounding the real and imaginary parts in direction *rnd*. # The return flag has the least significant bit set if the real # part is inexact, and the second least significant bit set if # the imaginary part is inexact. - void acf_approx_inv(acf_t res, const acf_t x, slong prec, arf_rnd_t rnd) - void acf_approx_div(acf_t res, const acf_t x, const acf_t y, slong prec, arf_rnd_t rnd) - void acf_approx_sqrt(acf_t res, const acf_t x, slong prec, arf_rnd_t rnd) + void acf_approx_inv(acf_t res, const acf_t x, slong prec, arf_rnd_t rnd) noexcept + void acf_approx_div(acf_t res, const acf_t x, const acf_t y, slong prec, arf_rnd_t rnd) noexcept + void acf_approx_sqrt(acf_t res, const acf_t x, slong prec, arf_rnd_t rnd) noexcept # Computes an approximate inverse, quotient or square root. - void acf_approx_dot(acf_t res, const acf_t initial, int subtract, acf_srcptr x, slong xstep, acf_srcptr y, slong ystep, slong len, slong prec, arf_rnd_t rnd) + void acf_approx_dot(acf_t res, const acf_t initial, int subtract, acf_srcptr x, slong xstep, acf_srcptr y, slong ystep, slong len, slong prec, arf_rnd_t rnd) noexcept # Computes an approximate dot product, with the same meaning of # the parameters as :func:`arb_dot`. diff --git a/src/sage/libs/flint/aprcl.pxd b/src/sage/libs/flint/aprcl.pxd index 1c3fd3d5554..95be5a520dd 100644 --- a/src/sage/libs/flint/aprcl.pxd +++ b/src/sage/libs/flint/aprcl.pxd @@ -12,11 +12,11 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - bint aprcl_is_prime(const fmpz_t n) + bint aprcl_is_prime(const fmpz_t n) noexcept # Tests `n` for primality using the APRCL test. # This is the same as :func:`aprcl_is_prime_jacobi`. - bint aprcl_is_prime_jacobi(const fmpz_t n) + bint aprcl_is_prime_jacobi(const fmpz_t n) noexcept # If `n` is prime returns 1; otherwise returns 0. The algorithm is well described # in "Implementation of a New Primality Test" by H. Cohen and A.K. Lenstra and # "A Course in Computational Algebraic Number Theory" by H. Cohen. @@ -25,7 +25,7 @@ cdef extern from "flint_wrap.h": # To handle this condition, the :func:`_aprcl_is_prime_jacobi` function # can be used. - bint aprcl_is_prime_gauss(const fmpz_t n) + bint aprcl_is_prime_gauss(const fmpz_t n) noexcept # If `n` is prime returns 1; otherwise returns 0. # Uses the cyclotomic primality testing algorithm described in # "Four primality testing algorithms" by Rene Schoof. @@ -36,244 +36,244 @@ cdef extern from "flint_wrap.h": # To handle this condition, the :func:`_aprcl_is_prime_jacobi` function # can be used. - primality_test_status _aprcl_is_prime_jacobi(const fmpz_t n, const aprcl_config config) + primality_test_status _aprcl_is_prime_jacobi(const fmpz_t n, const aprcl_config config) noexcept # Jacobi sum test for `n`. Possible return values: # ``PRIME``, ``COMPOSITE`` and ``UNKNOWN`` (if we cannot # prove primality). - primality_test_status _aprcl_is_prime_gauss(const fmpz_t n, const aprcl_config config) + primality_test_status _aprcl_is_prime_gauss(const fmpz_t n, const aprcl_config config) noexcept # Tests `n` for primality with fixed ``config``. Possible return values: # ``PRIME``, ``COMPOSITE`` and ``PROBABPRIME`` # (if we cannot prove primality). - bint aprcl_is_prime_gauss_min_R(const fmpz_t n, ulong R) + bint aprcl_is_prime_gauss_min_R(const fmpz_t n, ulong R) noexcept # Same as :func:`aprcl_is_prime_gauss` with fixed minimum value of `R`. - bint aprcl_is_prime_final_division(const fmpz_t n, const fmpz_t s, ulong r) + bint aprcl_is_prime_final_division(const fmpz_t n, const fmpz_t s, ulong r) noexcept # Returns 0 if for some `a = n^k \bmod s`, where `k \in [1, r - 1]`, # we have that `a \mid n`; otherwise returns 1. - void aprcl_config_gauss_init(aprcl_config conf, const fmpz_t n) + void aprcl_config_gauss_init(aprcl_config conf, const fmpz_t n) noexcept # Computes the `s` and `R` values used in the cyclotomic primality test, # `s^2 > n` and `s=\prod\limits_{\substack{q-1\mid R \\ q \text{ prime}}}q`. # Also stores factors of `R` and `s`. - void aprcl_config_gauss_init_min_R(aprcl_config conf, const fmpz_t n, ulong R) + void aprcl_config_gauss_init_min_R(aprcl_config conf, const fmpz_t n, ulong R) noexcept # Computes the `s` with fixed minimum `R` such that `a^R \equiv 1 \mod{s}` # for all integers `a` coprime to `s`. - void aprcl_config_gauss_clear(aprcl_config conf) + void aprcl_config_gauss_clear(aprcl_config conf) noexcept # Clears the given ``aprcl_config`` element. It must be reinitialised in # order to be used again. - ulong aprcl_R_value(const fmpz_t n) + ulong aprcl_R_value(const fmpz_t n) noexcept # Returns a precomputed `R` value for APRCL, such that the # corresponding `s` value is greater than `\sqrt{n}`. The maximum # stored value `6983776800` allows to test numbers up to `6000` digits. - void aprcl_config_jacobi_init(aprcl_config conf, const fmpz_t n) + void aprcl_config_jacobi_init(aprcl_config conf, const fmpz_t n) noexcept # Computes the `s` and `R` values used in the cyclotomic primality test, # `s^2 > n` and `a^R \equiv 1 \mod{s}` for all `a` coprime to `s`. # Also stores factors of `R` and `s`. - void aprcl_config_jacobi_clear(aprcl_config conf) + void aprcl_config_jacobi_clear(aprcl_config conf) noexcept # Clears the given ``aprcl_config`` element. It must be reinitialised in # order to be used again. - void unity_zp_init(unity_zp f, ulong p, ulong exp, const fmpz_t n) + void unity_zp_init(unity_zp f, ulong p, ulong exp, const fmpz_t n) noexcept # Initializes `f` as an element of `\mathbb{Z}[\zeta_{p^{exp}}]/(n)`. - void unity_zp_clear(unity_zp f) + void unity_zp_clear(unity_zp f) noexcept # Clears the given element. It must be reinitialised in # order to be used again. - void unity_zp_copy(unity_zp f, const unity_zp g) + void unity_zp_copy(unity_zp f, const unity_zp g) noexcept # Sets `f` to `g`. `f` and `g` must be initialized with same `p` and `n`. - void unity_zp_swap(unity_zp f, unity_zp q) + void unity_zp_swap(unity_zp f, unity_zp q) noexcept # Swaps `f` and `g`. `f` and `g` must be initialized with same `p` and `n`. - void unity_zp_set_zero(unity_zp f) + void unity_zp_set_zero(unity_zp f) noexcept # Sets `f` to zero. - slong unity_zp_is_unity(unity_zp f) + slong unity_zp_is_unity(unity_zp f) noexcept # If `f = \zeta^h` returns h; otherwise returns -1. - bint unity_zp_equal(unity_zp f, unity_zp g) + bint unity_zp_equal(unity_zp f, unity_zp g) noexcept # Returns nonzero if `f = g` reduced by the `p^{exp}`-th cyclotomic # polynomial. - void unity_zp_print(const unity_zp f) + void unity_zp_print(const unity_zp f) noexcept # Prints the contents of the `f`. - void unity_zp_coeff_set_fmpz(unity_zp f, ulong ind, const fmpz_t x) - void unity_zp_coeff_set_ui(unity_zp f, ulong ind, ulong x) + void unity_zp_coeff_set_fmpz(unity_zp f, ulong ind, const fmpz_t x) noexcept + void unity_zp_coeff_set_ui(unity_zp f, ulong ind, ulong x) noexcept # Sets the coefficient of `\zeta^{ind}` to `x`. # `ind` must be less than `p^{exp}`. - void unity_zp_coeff_add_fmpz(unity_zp f, ulong ind, const fmpz_t x) - void unity_zp_coeff_add_ui(unity_zp f, ulong ind, ulong x) + void unity_zp_coeff_add_fmpz(unity_zp f, ulong ind, const fmpz_t x) noexcept + void unity_zp_coeff_add_ui(unity_zp f, ulong ind, ulong x) noexcept # Adds `x` to the coefficient of `\zeta^{ind}`. # `x` must be less than `n`. # `ind` must be less than `p^{exp}`. - void unity_zp_coeff_inc(unity_zp f, ulong ind) + void unity_zp_coeff_inc(unity_zp f, ulong ind) noexcept # Increments the coefficient of `\zeta^{ind}`. # `ind` must be less than `p^{exp}`. - void unity_zp_coeff_dec(unity_zp f, ulong ind) + void unity_zp_coeff_dec(unity_zp f, ulong ind) noexcept # Decrements the coefficient of `\zeta^{ind}`. # `ind` must be less than `p^{exp}`. - void unity_zp_mul_scalar_fmpz(unity_zp f, const unity_zp g, const fmpz_t s) + void unity_zp_mul_scalar_fmpz(unity_zp f, const unity_zp g, const fmpz_t s) noexcept # Sets `f` to `s \cdot g`. `f` and `g` must be initialized with # same `p`, `exp` and `n`. - void unity_zp_mul_scalar_ui(unity_zp f, const unity_zp g, ulong s) + void unity_zp_mul_scalar_ui(unity_zp f, const unity_zp g, ulong s) noexcept # Sets `f` to `s \cdot g`. `f` and `g` must be initialized with # same `p`, `exp` and `n`. - void unity_zp_add(unity_zp f, const unity_zp g, const unity_zp h) + void unity_zp_add(unity_zp f, const unity_zp g, const unity_zp h) noexcept # Sets `f` to `g + h`. # `f`, `g` and `h` must be initialized with same `p`, `exp` and `n`. - void unity_zp_mul(unity_zp f, const unity_zp g, const unity_zp h) + void unity_zp_mul(unity_zp f, const unity_zp g, const unity_zp h) noexcept # Sets `f` to `g \cdot h`. # `f`, `g` and `h` must be initialized with same `p`, `exp` and `n`. - void unity_zp_sqr(unity_zp f, const unity_zp g) + void unity_zp_sqr(unity_zp f, const unity_zp g) noexcept # Sets `f` to `g \cdot g`. # `f`, `g` and `h` must be initialized with same `p`, `exp` and `n`. - void unity_zp_mul_inplace(unity_zp f, const unity_zp g, const unity_zp h, fmpz_t * t) + void unity_zp_mul_inplace(unity_zp f, const unity_zp g, const unity_zp h, fmpz_t * t) noexcept # Sets `f` to `g \cdot h`. If `p^{exp} = 3, 4, 5, 7, 8, 9, 11, 16` special # multiplication functions are used. The preallocated array `t` of ``fmpz_t`` is # used for all computations in this case. # `f`, `g` and `h` must be initialized with same `p`, `exp` and `n`. - void unity_zp_sqr_inplace(unity_zp f, const unity_zp g, fmpz_t * t) + void unity_zp_sqr_inplace(unity_zp f, const unity_zp g, fmpz_t * t) noexcept # Sets `f` to `g \cdot g`. If `p^{exp} = 3, 4, 5, 7, 8, 9, 11, 16` special # multiplication functions are used. The preallocated array `t` of ``fmpz_t`` is # used for all computations in this case. # `f` and `g` must be initialized with same `p`, `exp` and `n`. - void unity_zp_pow_fmpz(unity_zp f, const unity_zp g, const fmpz_t pow) + void unity_zp_pow_fmpz(unity_zp f, const unity_zp g, const fmpz_t pow) noexcept # Sets `f` to `g^{pow}`. `f` and `g` must be initialized with # same `p`, `exp` and `n`. - void unity_zp_pow_ui(unity_zp f, const unity_zp g, ulong pow) + void unity_zp_pow_ui(unity_zp f, const unity_zp g, ulong pow) noexcept # Sets `f` to `g^{pow}`. `f` and `g` must be initialized with # same `p`, `exp` and `n`. - ulong _unity_zp_pow_select_k(const fmpz_t n) + ulong _unity_zp_pow_select_k(const fmpz_t n) noexcept # Returns the smallest integer `k` satisfying # `\log (n) < (k(k + 1)2^{2k}) / (2^{k + 1} - k - 2) + 1` - void unity_zp_pow_2k_fmpz(unity_zp f, const unity_zp g, const fmpz_t pow) + void unity_zp_pow_2k_fmpz(unity_zp f, const unity_zp g, const fmpz_t pow) noexcept # Sets `f` to `g^{pow}` using the `2^k`-ary exponentiation method. # `f` and `g` must be initialized with same `p`, `exp` and `n`. - void unity_zp_pow_2k_ui(unity_zp f, const unity_zp g, ulong pow) + void unity_zp_pow_2k_ui(unity_zp f, const unity_zp g, ulong pow) noexcept # Sets `f` to `g^{pow}` using the `2^k`-ary exponentiation method. # `f` and `g` must be initialized with same `p`, `exp` and `n`. - void unity_zp_pow_sliding_fmpz(unity_zp f, unity_zp g, const fmpz_t pow) + void unity_zp_pow_sliding_fmpz(unity_zp f, unity_zp g, const fmpz_t pow) noexcept # Sets `f` to `g^{pow}` using the sliding window exponentiation method. # `f` and `g` must be initialized with same `p`, `exp` and `n`. - void _unity_zp_reduce_cyclotomic_divmod(unity_zp f) - void _unity_zp_reduce_cyclotomic(unity_zp f) + void _unity_zp_reduce_cyclotomic_divmod(unity_zp f) noexcept + void _unity_zp_reduce_cyclotomic(unity_zp f) noexcept # Sets `f = f \bmod \Phi_{p^{exp}}`. `\Phi_{p^{exp}}` is the `p^{exp}`-th # cyclotomic polynomial. `g` must be reduced by `x^{p^{exp}}-1` poly. # `f` and `g` must be initialized with same `p`, `exp` and `n`. - void unity_zp_reduce_cyclotomic(unity_zp f, const unity_zp g) + void unity_zp_reduce_cyclotomic(unity_zp f, const unity_zp g) noexcept # Sets `f = g \bmod \Phi_{p^{exp}}`. `\Phi_{p^{exp}}` is the `p^{exp}`-th # cyclotomic polynomial. - void unity_zp_aut(unity_zp f, const unity_zp g, ulong x) + void unity_zp_aut(unity_zp f, const unity_zp g, ulong x) noexcept # Sets `f = \sigma_x(g)`, the automorphism `\sigma_x(\zeta)=\zeta^x`. # `f` and `g` must be initialized with the same `p`, `exp` and `n`. - void unity_zp_aut_inv(unity_zp f, const unity_zp g, ulong x) + void unity_zp_aut_inv(unity_zp f, const unity_zp g, ulong x) noexcept # Sets `f = \sigma_x^{-1}(g)`, so `\sigma_x(f) = g`. # `g` must be reduced by `\Phi_{p^{exp}}`. # `f` and `g` must be initialized with the same `p`, `exp` and `n`. - void unity_zp_jacobi_sum_pq(unity_zp f, ulong q, ulong p) + void unity_zp_jacobi_sum_pq(unity_zp f, ulong q, ulong p) noexcept # Sets `f` to the Jacobi sum `J(p, q) = j(\chi_{p, q}, \chi_{p, q})`. - void unity_zp_jacobi_sum_2q_one(unity_zp f, ulong q) + void unity_zp_jacobi_sum_2q_one(unity_zp f, ulong q) noexcept # Sets `f` to the Jacobi sum # `J_2(q) = j(\chi_{2, q}^{2^{k - 3}}, \chi_{2, q}^{3 \cdot 2^{k - 3}}))^2`. - void unity_zp_jacobi_sum_2q_two(unity_zp f, ulong q) + void unity_zp_jacobi_sum_2q_two(unity_zp f, ulong q) noexcept # Sets `f` to the Jacobi sum # `J_3(1) = j(\chi_{2, q}, \chi_{2, q}, \chi_{2, q}) = # J(2, q) \cdot j(\chi_{2, q}^2, \chi_{2, q})`. - void unity_zpq_init(unity_zpq f, ulong q, ulong p, const fmpz_t n) + void unity_zpq_init(unity_zpq f, ulong q, ulong p, const fmpz_t n) noexcept # Initializes `f` as an element of `\mathbb{Z}[\zeta_q, \zeta_p]/(n)`. - void unity_zpq_clear(unity_zpq f) + void unity_zpq_clear(unity_zpq f) noexcept # Clears the given element. It must be reinitialized in # order to be used again. - void unity_zpq_copy(unity_zpq f, const unity_zpq g) + void unity_zpq_copy(unity_zpq f, const unity_zpq g) noexcept # Sets `f` to `g`. `f` and `g` must be initialized with # same `p`, `q` and `n`. - void unity_zpq_swap(unity_zpq f, unity_zpq q) + void unity_zpq_swap(unity_zpq f, unity_zpq q) noexcept # Swaps `f` and `g`. `f` and `g` must be initialized with # same `p`, `q` and `n`. - bint unity_zpq_equal(const unity_zpq f, const unity_zpq g) + bint unity_zpq_equal(const unity_zpq f, const unity_zpq g) noexcept # Returns nonzero if `f = g`. - slong unity_zpq_p_unity(const unity_zpq f) + slong unity_zpq_p_unity(const unity_zpq f) noexcept # If `f = \zeta_p^x` returns `x \in [0, p - 1]`; otherwise returns `p`. - bint unity_zpq_is_p_unity(const unity_zpq f) + bint unity_zpq_is_p_unity(const unity_zpq f) noexcept # Returns nonzero if `f = \zeta_p^x`. - bint unity_zpq_is_p_unity_generator(const unity_zpq f) + bint unity_zpq_is_p_unity_generator(const unity_zpq f) noexcept # Returns nonzero if `f` is a generator of the cyclic group `\langle\zeta_p\rangle`. - void unity_zpq_coeff_set_fmpz(unity_zpq f, slong i, slong j, const fmpz_t x) + void unity_zpq_coeff_set_fmpz(unity_zpq f, slong i, slong j, const fmpz_t x) noexcept # Sets the coefficient of `\zeta_q^i \zeta_p^j` to `x`. # `i` must be less than `q` and `j` must be less than `p`. - void unity_zpq_coeff_set_ui(unity_zpq f, slong i, slong j, ulong x) + void unity_zpq_coeff_set_ui(unity_zpq f, slong i, slong j, ulong x) noexcept # Sets the coefficient of `\zeta_q^i \zeta_p^j` to `x`. # `i` must be less than `q` and `j` must be less then `p`. - void unity_zpq_coeff_add(unity_zpq f, slong i, slong j, const fmpz_t x) + void unity_zpq_coeff_add(unity_zpq f, slong i, slong j, const fmpz_t x) noexcept # Adds `x` to the coefficient of `\zeta_p^i \zeta_q^j`. `x` must be less than `n`. - void unity_zpq_add(unity_zpq f, const unity_zpq g, const unity_zpq h) + void unity_zpq_add(unity_zpq f, const unity_zpq g, const unity_zpq h) noexcept # Sets `f` to `g + h`. # `f`, `g` and `h` must be initialized with same # `q`, `p` and `n`. - void unity_zpq_mul(unity_zpq f, const unity_zpq g, const unity_zpq h) + void unity_zpq_mul(unity_zpq f, const unity_zpq g, const unity_zpq h) noexcept # Sets the `f` to `g \cdot h`. # `f`, `g` and `h` must be initialized with same # `q`, `p` and `n`. - void _unity_zpq_mul_unity_p(unity_zpq f) + void _unity_zpq_mul_unity_p(unity_zpq f) noexcept # Sets `f = f \cdot \zeta_p`. - void unity_zpq_mul_unity_p_pow(unity_zpq f, const unity_zpq g, slong k) + void unity_zpq_mul_unity_p_pow(unity_zpq f, const unity_zpq g, slong k) noexcept # Sets `f` to `g \cdot \zeta_p^k`. - void unity_zpq_pow(unity_zpq f, const unity_zpq g, const fmpz_t p) + void unity_zpq_pow(unity_zpq f, const unity_zpq g, const fmpz_t p) noexcept # Sets `f` to `g^p`. `f` and `g` must be initialized with same `p`, `q` and `n`. - void unity_zpq_pow_ui(unity_zpq f, const unity_zpq g, ulong p) + void unity_zpq_pow_ui(unity_zpq f, const unity_zpq g, ulong p) noexcept # Sets `f` to `g^p`. `f` and `g` must be initialized with same `p`, `q` and `n`. - void unity_zpq_gauss_sum(unity_zpq f, ulong q, ulong p) + void unity_zpq_gauss_sum(unity_zpq f, ulong q, ulong p) noexcept # Sets `f = \tau(\chi_{p, q})`. - void unity_zpq_gauss_sum_sigma_pow(unity_zpq f, ulong q, ulong p) + void unity_zpq_gauss_sum_sigma_pow(unity_zpq f, ulong q, ulong p) noexcept # Sets `f = \tau^{\sigma_n}(\chi_{p, q})`. diff --git a/src/sage/libs/flint/arb.pxd b/src/sage/libs/flint/arb.pxd index 9f9349e2e3c..d7bf72f9409 100644 --- a/src/sage/libs/flint/arb.pxd +++ b/src/sage/libs/flint/arb.pxd @@ -12,34 +12,34 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void arb_init(arb_t x) + void arb_init(arb_t x) noexcept # Initializes the variable *x* for use. Its midpoint and radius are both # set to zero. - void arb_clear(arb_t x) + void arb_clear(arb_t x) noexcept # Clears the variable *x*, freeing or recycling its allocated memory. - arb_ptr _arb_vec_init(slong n) + arb_ptr _arb_vec_init(slong n) noexcept # Returns a pointer to an array of *n* initialized :type:`arb_struct` # entries. - void _arb_vec_clear(arb_ptr v, slong n) + void _arb_vec_clear(arb_ptr v, slong n) noexcept # Clears an array of *n* initialized :type:`arb_struct` entries. - void arb_swap(arb_t x, arb_t y) + void arb_swap(arb_t x, arb_t y) noexcept # Swaps *x* and *y* efficiently. - slong arb_allocated_bytes(const arb_t x) + slong arb_allocated_bytes(const arb_t x) noexcept # Returns the total number of bytes heap-allocated internally by this object. # The count excludes the size of the structure itself. Add # ``sizeof(arb_struct)`` to get the size of the object as a whole. - slong _arb_vec_allocated_bytes(arb_srcptr vec, slong len) + slong _arb_vec_allocated_bytes(arb_srcptr vec, slong len) noexcept # Returns the total number of bytes allocated for this vector, i.e. the # space taken up by the vector itself plus the sum of the internal heap # allocation sizes for all its member elements. - double _arb_vec_estimate_allocated_bytes(slong len, slong prec) + double _arb_vec_estimate_allocated_bytes(slong len, slong prec) noexcept # Estimates the number of bytes that need to be allocated for a vector of # *len* elements with *prec* bits of precision, including the space for # internal limb data. @@ -53,37 +53,37 @@ cdef extern from "flint_wrap.h": # The actual amount may also be higher or lower due to overhead in the # memory allocator or overcommitment by the operating system. - void arb_set(arb_t y, const arb_t x) + void arb_set(arb_t y, const arb_t x) noexcept - void arb_set_arf(arb_t y, const arf_t x) + void arb_set_arf(arb_t y, const arf_t x) noexcept - void arb_set_si(arb_t y, slong x) + void arb_set_si(arb_t y, slong x) noexcept - void arb_set_ui(arb_t y, ulong x) + void arb_set_ui(arb_t y, ulong x) noexcept - void arb_set_d(arb_t y, double x) + void arb_set_d(arb_t y, double x) noexcept - void arb_set_fmpz(arb_t y, const fmpz_t x) + void arb_set_fmpz(arb_t y, const fmpz_t x) noexcept # Sets *y* to the value of *x* without rounding. - void arb_set_fmpz_2exp(arb_t y, const fmpz_t x, const fmpz_t e) + void arb_set_fmpz_2exp(arb_t y, const fmpz_t x, const fmpz_t e) noexcept # Sets *y* to `x \cdot 2^e`. - void arb_set_round(arb_t y, const arb_t x, slong prec) + void arb_set_round(arb_t y, const arb_t x, slong prec) noexcept - void arb_set_round_fmpz(arb_t y, const fmpz_t x, slong prec) + void arb_set_round_fmpz(arb_t y, const fmpz_t x, slong prec) noexcept # Sets *y* to the value of *x*, rounded to *prec* bits in the direction # towards zero. - void arb_set_round_fmpz_2exp(arb_t y, const fmpz_t x, const fmpz_t e, slong prec) + void arb_set_round_fmpz_2exp(arb_t y, const fmpz_t x, const fmpz_t e, slong prec) noexcept # Sets *y* to `x \cdot 2^e`, rounded to *prec* bits in the direction # towards zero. - void arb_set_fmpq(arb_t y, const fmpq_t x, slong prec) + void arb_set_fmpq(arb_t y, const fmpq_t x, slong prec) noexcept # Sets *y* to the rational number *x*, rounded to *prec* bits in the direction # towards zero. - int arb_set_str(arb_t res, const char * inp, slong prec) + int arb_set_str(arb_t res, const char * inp, slong prec) noexcept # Sets *res* to the value specified by the human-readable string *inp*. # The input may be a decimal floating-point literal, # such as "25", "0.001", "7e+141" or "-31.4159e-1", and may also consist @@ -97,7 +97,7 @@ cdef extern from "flint_wrap.h": # Returns 0 if successful and nonzero if unsuccessful. If unsuccessful, # the result is set to an indeterminate interval. - char * arb_get_str(const arb_t x, slong n, ulong flags) + char * arb_get_str(const arb_t x, slong n, ulong flags) noexcept # Returns a nice human-readable representation of *x*, with at most *n* # digits of the midpoint printed. # With default flags, the output can be parsed back with :func:`arb_set_str`, @@ -120,46 +120,46 @@ cdef extern from "flint_wrap.h": # brackets indicating the number of digits omitted # (useful when computing values to extremely high precision). - void arb_zero(arb_t x) + void arb_zero(arb_t x) noexcept # Sets *x* to zero. - void arb_one(arb_t f) + void arb_one(arb_t f) noexcept # Sets *x* to the exact integer 1. - void arb_pos_inf(arb_t x) + void arb_pos_inf(arb_t x) noexcept # Sets *x* to positive infinity, with a zero radius. - void arb_neg_inf(arb_t x) + void arb_neg_inf(arb_t x) noexcept # Sets *x* to negative infinity, with a zero radius. - void arb_zero_pm_inf(arb_t x) + void arb_zero_pm_inf(arb_t x) noexcept # Sets *x* to `[0 \pm \infty]`, representing the whole extended real line. - void arb_indeterminate(arb_t x) + void arb_indeterminate(arb_t x) noexcept # Sets *x* to `[\operatorname{NaN} \pm \infty]`, representing # an indeterminate result. - void arb_zero_pm_one(arb_t x) + void arb_zero_pm_one(arb_t x) noexcept # Sets *x* to the interval `[0 \pm 1]`. - void arb_unit_interval(arb_t x) + void arb_unit_interval(arb_t x) noexcept # Sets *x* to the interval `[0, 1]`. - void arb_print(const arb_t x) + void arb_print(const arb_t x) noexcept - void arb_fprint(FILE * file, const arb_t x) + void arb_fprint(FILE * file, const arb_t x) noexcept # Prints the internal representation of *x*. - void arb_printd(const arb_t x, slong digits) + void arb_printd(const arb_t x, slong digits) noexcept - void arb_fprintd(FILE * file, const arb_t x, slong digits) + void arb_fprintd(FILE * file, const arb_t x, slong digits) noexcept # Prints *x* in decimal. The printed value of the radius is not adjusted # to compensate for the fact that the binary-to-decimal conversion # of both the midpoint and the radius introduces additional error. - void arb_printn(const arb_t x, slong digits, ulong flags) + void arb_printn(const arb_t x, slong digits, ulong flags) noexcept - void arb_fprintn(FILE * file, const arb_t x, slong digits, ulong flags) + void arb_fprintn(FILE * file, const arb_t x, slong digits, ulong flags) noexcept # Prints a nice decimal representation of *x*. # By default, the output shows the midpoint with a guaranteed error of at # most one unit in the last decimal place. In addition, an explicit error @@ -167,7 +167,7 @@ cdef extern from "flint_wrap.h": # enclose *x*. # See :func:`arb_get_str` for details. - char * arb_dump_str(const arb_t x) + char * arb_dump_str(const arb_t x) noexcept # Returns a serialized representation of *x* as a null-terminated # ASCII string that can be read by :func:`arb_load_str`. The format consists # of four hexadecimal integers representing the midpoint mantissa, @@ -176,16 +176,16 @@ cdef extern from "flint_wrap.h": # separated by single spaces. The returned string needs to be deallocated # with *flint_free*. - int arb_load_str(arb_t x, const char * str) + int arb_load_str(arb_t x, const char * str) noexcept # Sets *x* to the serialized representation given in *str*. Returns a # nonzero value if *str* is not formatted correctly (see :func:`arb_dump_str`). - int arb_dump_file(FILE * stream, const arb_t x) + int arb_dump_file(FILE * stream, const arb_t x) noexcept # Writes a serialized ASCII representation of *x* to *stream* in a form that # can be read by :func:`arb_load_file`. Returns a nonzero value if the data # could not be written. - int arb_load_file(arb_t x, FILE * stream) + int arb_load_file(arb_t x, FILE * stream) noexcept # Reads *x* from a serialized ASCII representation in *stream*. Returns a # nonzero value if the data is not # formatted correctly or the read failed. Note that the data is assumed to be @@ -209,25 +209,25 @@ cdef extern from "flint_wrap.h": # } # fclose(fp); - void arb_randtest(arb_t x, flint_rand_t state, slong prec, slong mag_bits) + void arb_randtest(arb_t x, flint_rand_t state, slong prec, slong mag_bits) noexcept # Generates a random ball. The midpoint and radius will both be finite. - void arb_randtest_exact(arb_t x, flint_rand_t state, slong prec, slong mag_bits) + void arb_randtest_exact(arb_t x, flint_rand_t state, slong prec, slong mag_bits) noexcept # Generates a random number with zero radius. - void arb_randtest_precise(arb_t x, flint_rand_t state, slong prec, slong mag_bits) + void arb_randtest_precise(arb_t x, flint_rand_t state, slong prec, slong mag_bits) noexcept # Generates a random number with radius around `2^{-\text{prec}}` # the magnitude of the midpoint. - void arb_randtest_wide(arb_t x, flint_rand_t state, slong prec, slong mag_bits) + void arb_randtest_wide(arb_t x, flint_rand_t state, slong prec, slong mag_bits) noexcept # Generates a random number with midpoint and radius chosen independently, # possibly giving a very large interval. - void arb_randtest_special(arb_t x, flint_rand_t state, slong prec, slong mag_bits) + void arb_randtest_special(arb_t x, flint_rand_t state, slong prec, slong mag_bits) noexcept # Generates a random interval, possibly having NaN or an infinity # as the midpoint and possibly having an infinite radius. - void arb_get_rand_fmpq(fmpq_t q, flint_rand_t state, const arb_t x, slong bits) + void arb_get_rand_fmpq(fmpq_t q, flint_rand_t state, const arb_t x, slong bits) noexcept # Sets *q* to a random rational number from the interval represented by *x*. # A denominator is chosen by multiplying the binary denominator of *x* # by a random integer up to *bits* bits. @@ -236,77 +236,77 @@ cdef extern from "flint_wrap.h": # that representing the endpoints as exact rational numbers would # cause overflows. - void arb_urandom(arb_t x, flint_rand_t state, slong prec) + void arb_urandom(arb_t x, flint_rand_t state, slong prec) noexcept # Sets *x* to a uniformly distributed random number in the interval # `[0, 1]`. The method uses rounding from integers to floats, hence the # radius might not be `0`. - void arb_get_mid_arb(arb_t m, const arb_t x) + void arb_get_mid_arb(arb_t m, const arb_t x) noexcept # Sets *m* to the midpoint of *x*. - void arb_get_rad_arb(arb_t r, const arb_t x) + void arb_get_rad_arb(arb_t r, const arb_t x) noexcept # Sets *r* to the radius of *x*. - void arb_add_error_arf(arb_t x, const arf_t err) + void arb_add_error_arf(arb_t x, const arf_t err) noexcept - void arb_add_error_mag(arb_t x, const mag_t err) + void arb_add_error_mag(arb_t x, const mag_t err) noexcept - void arb_add_error(arb_t x, const arb_t err) + void arb_add_error(arb_t x, const arb_t err) noexcept # Adds the absolute value of *err* to the radius of *x* (the operation # is done in-place). - void arb_add_error_2exp_si(arb_t x, slong e) + void arb_add_error_2exp_si(arb_t x, slong e) noexcept - void arb_add_error_2exp_fmpz(arb_t x, const fmpz_t e) + void arb_add_error_2exp_fmpz(arb_t x, const fmpz_t e) noexcept # Adds `2^e` to the radius of *x*. - void arb_union(arb_t z, const arb_t x, const arb_t y, slong prec) + void arb_union(arb_t z, const arb_t x, const arb_t y, slong prec) noexcept # Sets *z* to a ball containing both *x* and *y*. - int arb_intersection(arb_t z, const arb_t x, const arb_t y, slong prec) + int arb_intersection(arb_t z, const arb_t x, const arb_t y, slong prec) noexcept # If *x* and *y* overlap according to :func:`arb_overlaps`, # then *z* is set to a ball containing the intersection of *x* and *y* # and a nonzero value is returned. # Otherwise zero is returned and the value of *z* is undefined. # If *x* or *y* contains NaN, the result is NaN. - void arb_nonnegative_part(arb_t res, const arb_t x) + void arb_nonnegative_part(arb_t res, const arb_t x) noexcept # Sets *res* to the intersection of *x* with `[0,\infty]`. If *x* is # nonnegative, an exact copy is made. If *x* is finite and contains negative # numbers, an interval of the form `[r/2 \pm r/2]` is produced, which # certainly contains no negative points. # In the special case when *x* is strictly negative, *res* is set to zero. - void arb_get_abs_ubound_arf(arf_t u, const arb_t x, slong prec) + void arb_get_abs_ubound_arf(arf_t u, const arb_t x, slong prec) noexcept # Sets *u* to the upper bound for the absolute value of *x*, # rounded up to *prec* bits. If *x* contains NaN, the result is NaN. - void arb_get_abs_lbound_arf(arf_t u, const arb_t x, slong prec) + void arb_get_abs_lbound_arf(arf_t u, const arb_t x, slong prec) noexcept # Sets *u* to the lower bound for the absolute value of *x*, # rounded down to *prec* bits. If *x* contains NaN, the result is NaN. - void arb_get_ubound_arf(arf_t u, const arb_t x, slong prec) + void arb_get_ubound_arf(arf_t u, const arb_t x, slong prec) noexcept # Sets *u* to the upper bound for the value of *x*, # rounded up to *prec* bits. If *x* contains NaN, the result is NaN. - void arb_get_lbound_arf(arf_t u, const arb_t x, slong prec) + void arb_get_lbound_arf(arf_t u, const arb_t x, slong prec) noexcept # Sets *u* to the lower bound for the value of *x*, # rounded down to *prec* bits. If *x* contains NaN, the result is NaN. - void arb_get_mag(mag_t z, const arb_t x) + void arb_get_mag(mag_t z, const arb_t x) noexcept # Sets *z* to an upper bound for the absolute value of *x*. If *x* contains # NaN, the result is positive infinity. - void arb_get_mag_lower(mag_t z, const arb_t x) + void arb_get_mag_lower(mag_t z, const arb_t x) noexcept # Sets *z* to a lower bound for the absolute value of *x*. If *x* contains # NaN, the result is zero. - void arb_get_mag_lower_nonnegative(mag_t z, const arb_t x) + void arb_get_mag_lower_nonnegative(mag_t z, const arb_t x) noexcept # Sets *z* to a lower bound for the signed value of *x*, or zero # if *x* overlaps with the negative half-axis. If *x* contains NaN, # the result is zero. - void arb_get_interval_fmpz_2exp(fmpz_t a, fmpz_t b, fmpz_t exp, const arb_t x) + void arb_get_interval_fmpz_2exp(fmpz_t a, fmpz_t b, fmpz_t exp, const arb_t x) noexcept # Computes the exact interval represented by *x*, in the form of an integer # interval multiplied by a power of two, i.e. `x = [a, b] \times 2^{\text{exp}}`. # The result is normalized by removing common trailing zeros @@ -321,51 +321,51 @@ cdef extern from "flint_wrap.h": # to check that the midpoint and radius of *x* both are within a # reasonable range before calling this method. - void arb_set_interval_mag(arb_t x, const mag_t a, const mag_t b, slong prec) + void arb_set_interval_mag(arb_t x, const mag_t a, const mag_t b, slong prec) noexcept - void arb_set_interval_arf(arb_t x, const arf_t a, const arf_t b, slong prec) + void arb_set_interval_arf(arb_t x, const arf_t a, const arf_t b, slong prec) noexcept - void arb_set_interval_mpfr(arb_t x, const mpfr_t a, const mpfr_t b, slong prec) + void arb_set_interval_mpfr(arb_t x, const mpfr_t a, const mpfr_t b, slong prec) noexcept # Sets *x* to a ball containing the interval `[a, b]`. We # require that `a \le b`. - void arb_set_interval_neg_pos_mag(arb_t x, const mag_t a, const mag_t b, slong prec) + void arb_set_interval_neg_pos_mag(arb_t x, const mag_t a, const mag_t b, slong prec) noexcept # Sets *x* to a ball containing the interval `[-a, b]`. - void arb_get_interval_arf(arf_t a, arf_t b, const arb_t x, slong prec) + void arb_get_interval_arf(arf_t a, arf_t b, const arb_t x, slong prec) noexcept - void arb_get_interval_mpfr(mpfr_t a, mpfr_t b, const arb_t x) + void arb_get_interval_mpfr(mpfr_t a, mpfr_t b, const arb_t x) noexcept # Constructs an interval `[a, b]` containing the ball *x*. The MPFR version # uses the precision of the output variables. - slong arb_rel_error_bits(const arb_t x) + slong arb_rel_error_bits(const arb_t x) noexcept # Returns the effective relative error of *x* measured in bits, defined as # the difference between the position of the top bit in the radius # and the top bit in the midpoint, plus one. # The result is clamped between plus/minus *ARF_PREC_EXACT*. - slong arb_rel_accuracy_bits(const arb_t x) + slong arb_rel_accuracy_bits(const arb_t x) noexcept # Returns the effective relative accuracy of *x* measured in bits, # equal to the negative of the return value from :func:`arb_rel_error_bits`. - slong arb_rel_one_accuracy_bits(const arb_t x) + slong arb_rel_one_accuracy_bits(const arb_t x) noexcept # Given a ball with midpoint *m* and radius *r*, returns an approximation of # the relative accuracy of `[\max(1,|m|) \pm r]` measured in bits. - slong arb_bits(const arb_t x) + slong arb_bits(const arb_t x) noexcept # Returns the number of bits needed to represent the absolute value # of the mantissa of the midpoint of *x*, i.e. the minimum precision # sufficient to represent *x* exactly. Returns 0 if the midpoint # of *x* is a special value. - void arb_trim(arb_t y, const arb_t x) + void arb_trim(arb_t y, const arb_t x) noexcept # Sets *y* to a trimmed copy of *x*: rounds *x* to a number of bits # equal to the accuracy of *x* (as indicated by its radius), # plus a few guard bits. The resulting ball is guaranteed to # contain *x*, but is more economical if *x* has # less than full accuracy. - int arb_get_unique_fmpz(fmpz_t z, const arb_t x) + int arb_get_unique_fmpz(fmpz_t z, const arb_t x) noexcept # If *x* contains a unique integer, sets *z* to that value and returns # nonzero. Otherwise (if *x* represents no integers or more than one integer), # returns zero. @@ -378,24 +378,24 @@ cdef extern from "flint_wrap.h": # in swapping. It is recommended to check that the midpoint of *x* is # within a reasonable range before calling this method. - void arb_floor(arb_t y, const arb_t x, slong prec) - void arb_ceil(arb_t y, const arb_t x, slong prec) - void arb_trunc(arb_t y, const arb_t x, slong prec) - void arb_nint(arb_t y, const arb_t x, slong prec) + void arb_floor(arb_t y, const arb_t x, slong prec) noexcept + void arb_ceil(arb_t y, const arb_t x, slong prec) noexcept + void arb_trunc(arb_t y, const arb_t x, slong prec) noexcept + void arb_nint(arb_t y, const arb_t x, slong prec) noexcept # Sets *y* to a ball containing respectively, `\lfloor x \rfloor` and # `\lceil x \rceil`, `\operatorname{trunc}(x)`, `\operatorname{nint}(x)`, # with the midpoint of *y* rounded to at most *prec* bits. - void arb_get_fmpz_mid_rad_10exp(fmpz_t mid, fmpz_t rad, fmpz_t exp, const arb_t x, slong n) + void arb_get_fmpz_mid_rad_10exp(fmpz_t mid, fmpz_t rad, fmpz_t exp, const arb_t x, slong n) noexcept # Assuming that *x* is finite and not exactly zero, computes integers *mid*, # *rad*, *exp* such that `x \in [m-r, m+r] \times 10^e` and such that the # larger out of *mid* and *rad* has at least *n* digits plus a few guard # digits. If *x* is infinite or exactly zero, the outputs are all set # to zero. - int arb_can_round_arf(const arb_t x, slong prec, arf_rnd_t rnd) + int arb_can_round_arf(const arb_t x, slong prec, arf_rnd_t rnd) noexcept - int arb_can_round_mpfr(const arb_t x, slong prec, mpfr_rnd_t rnd) + int arb_can_round_mpfr(const arb_t x, slong prec, mpfr_rnd_t rnd) noexcept # Returns nonzero if rounding the midpoint of *x* to *prec* bits in # the direction *rnd* is guaranteed to give the unique correctly # rounded floating-point approximation for the real number represented by *x*. @@ -414,30 +414,30 @@ cdef extern from "flint_wrap.h": # To be conservative, zero is returned when *x* is non-finite, even if it # is an "exact" infinity. - bint arb_is_zero(const arb_t x) + bint arb_is_zero(const arb_t x) noexcept # Returns nonzero iff the midpoint and radius of *x* are both zero. - bint arb_is_nonzero(const arb_t x) + bint arb_is_nonzero(const arb_t x) noexcept # Returns nonzero iff zero is not contained in the interval represented # by *x*. - bint arb_is_one(const arb_t f) + bint arb_is_one(const arb_t f) noexcept # Returns nonzero iff *x* is exactly 1. - bint arb_is_finite(const arb_t x) + bint arb_is_finite(const arb_t x) noexcept # Returns nonzero iff the midpoint and radius of *x* are both finite # floating-point numbers, i.e. not infinities or NaN. - bint arb_is_exact(const arb_t x) + bint arb_is_exact(const arb_t x) noexcept # Returns nonzero iff the radius of *x* is zero. - bint arb_is_int(const arb_t x) + bint arb_is_int(const arb_t x) noexcept # Returns nonzero iff *x* is an exact integer. - bint arb_is_int_2exp_si(const arb_t x, slong e) + bint arb_is_int_2exp_si(const arb_t x, slong e) noexcept # Returns nonzero iff *x* exactly equals `n 2^e` for some integer *n*. - bint arb_equal(const arb_t x, const arb_t y) + bint arb_equal(const arb_t x, const arb_t y) noexcept # Returns nonzero iff *x* and *y* are equal as balls, i.e. have both the # same midpoint and radius. # Note that this is not the same thing as testing whether both @@ -447,37 +447,37 @@ cdef extern from "flint_wrap.h": # quantity, use :func:`arb_overlaps` or :func:`arb_contains`, # depending on the circumstance. - bint arb_equal_si(const arb_t x, slong y) + bint arb_equal_si(const arb_t x, slong y) noexcept # Returns nonzero iff *x* is equal to the integer *y*. - bint arb_is_positive(const arb_t x) + bint arb_is_positive(const arb_t x) noexcept - bint arb_is_nonnegative(const arb_t x) + bint arb_is_nonnegative(const arb_t x) noexcept - bint arb_is_negative(const arb_t x) + bint arb_is_negative(const arb_t x) noexcept - bint arb_is_nonpositive(const arb_t x) + bint arb_is_nonpositive(const arb_t x) noexcept # Returns nonzero iff all points *p* in the interval represented by *x* # satisfy, respectively, `p > 0`, `p \ge 0`, `p < 0`, `p \le 0`. # If *x* contains NaN, returns zero. - bint arb_overlaps(const arb_t x, const arb_t y) + bint arb_overlaps(const arb_t x, const arb_t y) noexcept # Returns nonzero iff *x* and *y* have some point in common. # If either *x* or *y* contains NaN, this function always returns nonzero # (as a NaN could be anything, it could in particular contain any # number that is included in the other operand). - bint arb_contains_arf(const arb_t x, const arf_t y) + bint arb_contains_arf(const arb_t x, const arf_t y) noexcept - bint arb_contains_fmpq(const arb_t x, const fmpq_t y) + bint arb_contains_fmpq(const arb_t x, const fmpq_t y) noexcept - bint arb_contains_fmpz(const arb_t x, const fmpz_t y) + bint arb_contains_fmpz(const arb_t x, const fmpz_t y) noexcept - bint arb_contains_si(const arb_t x, slong y) + bint arb_contains_si(const arb_t x, slong y) noexcept - bint arb_contains_mpfr(const arb_t x, const mpfr_t y) + bint arb_contains_mpfr(const arb_t x, const mpfr_t y) noexcept - bint arb_contains(const arb_t x, const arb_t y) + bint arb_contains(const arb_t x, const arb_t y) noexcept # Returns nonzero iff the given number (or ball) *y* is contained in # the interval represented by *x*. # If *x* contains NaN, this function always returns nonzero (as it @@ -485,37 +485,37 @@ cdef extern from "flint_wrap.h": # the points included in *y*). # If *y* contains NaN and *x* does not, it always returns zero. - bint arb_contains_int(const arb_t x) + bint arb_contains_int(const arb_t x) noexcept # Returns nonzero iff the interval represented by *x* contains an integer. - bint arb_contains_zero(const arb_t x) + bint arb_contains_zero(const arb_t x) noexcept - bint arb_contains_negative(const arb_t x) + bint arb_contains_negative(const arb_t x) noexcept - bint arb_contains_nonpositive(const arb_t x) + bint arb_contains_nonpositive(const arb_t x) noexcept - bint arb_contains_positive(const arb_t x) + bint arb_contains_positive(const arb_t x) noexcept - bint arb_contains_nonnegative(const arb_t x) + bint arb_contains_nonnegative(const arb_t x) noexcept # Returns nonzero iff there is any point *p* in the interval represented # by *x* satisfying, respectively, `p = 0`, `p < 0`, `p \le 0`, `p > 0`, `p \ge 0`. # If *x* contains NaN, returns nonzero. - bint arb_contains_interior(const arb_t x, const arb_t y) + bint arb_contains_interior(const arb_t x, const arb_t y) noexcept # Tests if *y* is contained in the interior of *x*; that is, contained # in *x* and not touching either endpoint. - bint arb_eq(const arb_t x, const arb_t y) + bint arb_eq(const arb_t x, const arb_t y) noexcept - bint arb_ne(const arb_t x, const arb_t y) + bint arb_ne(const arb_t x, const arb_t y) noexcept - bint arb_lt(const arb_t x, const arb_t y) + bint arb_lt(const arb_t x, const arb_t y) noexcept - bint arb_le(const arb_t x, const arb_t y) + bint arb_le(const arb_t x, const arb_t y) noexcept - bint arb_gt(const arb_t x, const arb_t y) + bint arb_gt(const arb_t x, const arb_t y) noexcept - bint arb_ge(const arb_t x, const arb_t y) + bint arb_ge(const arb_t x, const arb_t y) noexcept # Respectively performs the comparison `x = y`, `x \ne y`, # `x < y`, `x \le y`, `x > y`, `x \ge y` in a mathematically meaningful way. # If the comparison `t \, (\operatorname{op}) \, u` holds for all @@ -527,130 +527,130 @@ cdef extern from "flint_wrap.h": # Also `[-\infty] \le [\infty \pm \infty]`. # The output is always 0 if either input has NaN as midpoint. - void arb_neg(arb_t y, const arb_t x) + void arb_neg(arb_t y, const arb_t x) noexcept - void arb_neg_round(arb_t y, const arb_t x, slong prec) + void arb_neg_round(arb_t y, const arb_t x, slong prec) noexcept # Sets *y* to the negation of *x*. - void arb_abs(arb_t y, const arb_t x) + void arb_abs(arb_t y, const arb_t x) noexcept # Sets *y* to the absolute value of *x*. No attempt is made to improve the # interval represented by *x* if it contains zero. - void arb_nonnegative_abs(arb_t y, const arb_t x) + void arb_nonnegative_abs(arb_t y, const arb_t x) noexcept # Sets *y* to the absolute value of *x*. If *x* is finite and it contains # zero, sets *y* to some interval `[r \pm r]` that contains the absolute # value of *x*. - void arb_sgn(arb_t y, const arb_t x) + void arb_sgn(arb_t y, const arb_t x) noexcept # Sets *y* to the sign function of *x*. The result is `[0 \pm 1]` if # *x* contains both zero and nonzero numbers. - int arb_sgn_nonzero(const arb_t x) + int arb_sgn_nonzero(const arb_t x) noexcept # Returns 1 if *x* is strictly positive, -1 if *x* is strictly negative, # and 0 if *x* is zero or a ball containing zero so that its sign # is not determined. - void arb_min(arb_t z, const arb_t x, const arb_t y, slong prec) + void arb_min(arb_t z, const arb_t x, const arb_t y, slong prec) noexcept - void arb_max(arb_t z, const arb_t x, const arb_t y, slong prec) + void arb_max(arb_t z, const arb_t x, const arb_t y, slong prec) noexcept # Sets *z* respectively to the minimum and the maximum of *x* and *y*. - void arb_minmax(arb_t z1, arb_t z2, const arb_t x, const arb_t y, slong prec) + void arb_minmax(arb_t z1, arb_t z2, const arb_t x, const arb_t y, slong prec) noexcept # Sets *z1* and *z2* respectively to the minimum and the maximum of *x* and *y*. - void arb_add(arb_t z, const arb_t x, const arb_t y, slong prec) + void arb_add(arb_t z, const arb_t x, const arb_t y, slong prec) noexcept - void arb_add_arf(arb_t z, const arb_t x, const arf_t y, slong prec) + void arb_add_arf(arb_t z, const arb_t x, const arf_t y, slong prec) noexcept - void arb_add_ui(arb_t z, const arb_t x, ulong y, slong prec) + void arb_add_ui(arb_t z, const arb_t x, ulong y, slong prec) noexcept - void arb_add_si(arb_t z, const arb_t x, slong y, slong prec) + void arb_add_si(arb_t z, const arb_t x, slong y, slong prec) noexcept - void arb_add_fmpz(arb_t z, const arb_t x, const fmpz_t y, slong prec) + void arb_add_fmpz(arb_t z, const arb_t x, const fmpz_t y, slong prec) noexcept # Sets `z = x + y`, rounded to *prec* bits. The precision can be # *ARF_PREC_EXACT* provided that the result fits in memory. - void arb_add_fmpz_2exp(arb_t z, const arb_t x, const fmpz_t m, const fmpz_t e, slong prec) + void arb_add_fmpz_2exp(arb_t z, const arb_t x, const fmpz_t m, const fmpz_t e, slong prec) noexcept # Sets `z = x + m \cdot 2^e`, rounded to *prec* bits. The precision can be # *ARF_PREC_EXACT* provided that the result fits in memory. - void arb_sub(arb_t z, const arb_t x, const arb_t y, slong prec) + void arb_sub(arb_t z, const arb_t x, const arb_t y, slong prec) noexcept - void arb_sub_arf(arb_t z, const arb_t x, const arf_t y, slong prec) + void arb_sub_arf(arb_t z, const arb_t x, const arf_t y, slong prec) noexcept - void arb_sub_ui(arb_t z, const arb_t x, ulong y, slong prec) + void arb_sub_ui(arb_t z, const arb_t x, ulong y, slong prec) noexcept - void arb_sub_si(arb_t z, const arb_t x, slong y, slong prec) + void arb_sub_si(arb_t z, const arb_t x, slong y, slong prec) noexcept - void arb_sub_fmpz(arb_t z, const arb_t x, const fmpz_t y, slong prec) + void arb_sub_fmpz(arb_t z, const arb_t x, const fmpz_t y, slong prec) noexcept # Sets `z = x - y`, rounded to *prec* bits. The precision can be # *ARF_PREC_EXACT* provided that the result fits in memory. - void arb_mul(arb_t z, const arb_t x, const arb_t y, slong prec) + void arb_mul(arb_t z, const arb_t x, const arb_t y, slong prec) noexcept - void arb_mul_arf(arb_t z, const arb_t x, const arf_t y, slong prec) + void arb_mul_arf(arb_t z, const arb_t x, const arf_t y, slong prec) noexcept - void arb_mul_si(arb_t z, const arb_t x, slong y, slong prec) + void arb_mul_si(arb_t z, const arb_t x, slong y, slong prec) noexcept - void arb_mul_ui(arb_t z, const arb_t x, ulong y, slong prec) + void arb_mul_ui(arb_t z, const arb_t x, ulong y, slong prec) noexcept - void arb_mul_fmpz(arb_t z, const arb_t x, const fmpz_t y, slong prec) + void arb_mul_fmpz(arb_t z, const arb_t x, const fmpz_t y, slong prec) noexcept # Sets `z = x \cdot y`, rounded to *prec* bits. The precision can be # *ARF_PREC_EXACT* provided that the result fits in memory. - void arb_mul_2exp_si(arb_t y, const arb_t x, slong e) + void arb_mul_2exp_si(arb_t y, const arb_t x, slong e) noexcept - void arb_mul_2exp_fmpz(arb_t y, const arb_t x, const fmpz_t e) + void arb_mul_2exp_fmpz(arb_t y, const arb_t x, const fmpz_t e) noexcept # Sets *y* to *x* multiplied by `2^e`. - void arb_addmul(arb_t z, const arb_t x, const arb_t y, slong prec) + void arb_addmul(arb_t z, const arb_t x, const arb_t y, slong prec) noexcept - void arb_addmul_arf(arb_t z, const arb_t x, const arf_t y, slong prec) + void arb_addmul_arf(arb_t z, const arb_t x, const arf_t y, slong prec) noexcept - void arb_addmul_si(arb_t z, const arb_t x, slong y, slong prec) + void arb_addmul_si(arb_t z, const arb_t x, slong y, slong prec) noexcept - void arb_addmul_ui(arb_t z, const arb_t x, ulong y, slong prec) + void arb_addmul_ui(arb_t z, const arb_t x, ulong y, slong prec) noexcept - void arb_addmul_fmpz(arb_t z, const arb_t x, const fmpz_t y, slong prec) + void arb_addmul_fmpz(arb_t z, const arb_t x, const fmpz_t y, slong prec) noexcept # Sets `z = z + x \cdot y`, rounded to prec bits. The precision can be # *ARF_PREC_EXACT* provided that the result fits in memory. - void arb_submul(arb_t z, const arb_t x, const arb_t y, slong prec) + void arb_submul(arb_t z, const arb_t x, const arb_t y, slong prec) noexcept - void arb_submul_arf(arb_t z, const arb_t x, const arf_t y, slong prec) + void arb_submul_arf(arb_t z, const arb_t x, const arf_t y, slong prec) noexcept - void arb_submul_si(arb_t z, const arb_t x, slong y, slong prec) + void arb_submul_si(arb_t z, const arb_t x, slong y, slong prec) noexcept - void arb_submul_ui(arb_t z, const arb_t x, ulong y, slong prec) + void arb_submul_ui(arb_t z, const arb_t x, ulong y, slong prec) noexcept - void arb_submul_fmpz(arb_t z, const arb_t x, const fmpz_t y, slong prec) + void arb_submul_fmpz(arb_t z, const arb_t x, const fmpz_t y, slong prec) noexcept # Sets `z = z - x \cdot y`, rounded to prec bits. The precision can be # *ARF_PREC_EXACT* provided that the result fits in memory. - void arb_fma(arb_t res, const arb_t x, const arb_t y, const arb_t z, slong prec) - void arb_fma_arf(arb_t res, const arb_t x, const arf_t y, const arb_t z, slong prec) - void arb_fma_si(arb_t res, const arb_t x, slong y, const arb_t z, slong prec) - void arb_fma_ui(arb_t res, const arb_t x, ulong y, const arb_t z, slong prec) - void arb_fma_fmpz(arb_t res, const arb_t x, const fmpz_t y, const arb_t z, slong prec) + void arb_fma(arb_t res, const arb_t x, const arb_t y, const arb_t z, slong prec) noexcept + void arb_fma_arf(arb_t res, const arb_t x, const arf_t y, const arb_t z, slong prec) noexcept + void arb_fma_si(arb_t res, const arb_t x, slong y, const arb_t z, slong prec) noexcept + void arb_fma_ui(arb_t res, const arb_t x, ulong y, const arb_t z, slong prec) noexcept + void arb_fma_fmpz(arb_t res, const arb_t x, const fmpz_t y, const arb_t z, slong prec) noexcept # Sets *res* to `x \cdot y + z`. This is equivalent to an *addmul* except # that *res* and *z* can be separate variables. - void arb_inv(arb_t z, const arb_t x, slong prec) + void arb_inv(arb_t z, const arb_t x, slong prec) noexcept # Sets *z* to `1 / x`. - void arb_div(arb_t z, const arb_t x, const arb_t y, slong prec) + void arb_div(arb_t z, const arb_t x, const arb_t y, slong prec) noexcept - void arb_div_arf(arb_t z, const arb_t x, const arf_t y, slong prec) + void arb_div_arf(arb_t z, const arb_t x, const arf_t y, slong prec) noexcept - void arb_div_si(arb_t z, const arb_t x, slong y, slong prec) + void arb_div_si(arb_t z, const arb_t x, slong y, slong prec) noexcept - void arb_div_ui(arb_t z, const arb_t x, ulong y, slong prec) + void arb_div_ui(arb_t z, const arb_t x, ulong y, slong prec) noexcept - void arb_div_fmpz(arb_t z, const arb_t x, const fmpz_t y, slong prec) + void arb_div_fmpz(arb_t z, const arb_t x, const fmpz_t y, slong prec) noexcept - void arb_fmpz_div_fmpz(arb_t z, const fmpz_t x, const fmpz_t y, slong prec) + void arb_fmpz_div_fmpz(arb_t z, const fmpz_t x, const fmpz_t y, slong prec) noexcept - void arb_ui_div(arb_t z, ulong x, const arb_t y, slong prec) + void arb_ui_div(arb_t z, ulong x, const arb_t y, slong prec) noexcept # Sets `z = x / y`, rounded to *prec* bits. If *y* contains zero, *z* is # set to `0 \pm \infty`. Otherwise, error propagation uses the rule # .. math :: @@ -661,12 +661,12 @@ cdef extern from "flint_wrap.h": # where the triangle inequality has been applied to the numerator and # the reverse triangle inequality has been applied to the denominator. - void arb_div_2expm1_ui(arb_t z, const arb_t x, ulong n, slong prec) + void arb_div_2expm1_ui(arb_t z, const arb_t x, ulong n, slong prec) noexcept # Sets `z = x / (2^n - 1)`, rounded to *prec* bits. - void arb_dot_precise(arb_t res, const arb_t s, int subtract, arb_srcptr x, slong xstep, arb_srcptr y, slong ystep, slong len, slong prec) - void arb_dot_simple(arb_t res, const arb_t s, int subtract, arb_srcptr x, slong xstep, arb_srcptr y, slong ystep, slong len, slong prec) - void arb_dot(arb_t res, const arb_t s, int subtract, arb_srcptr x, slong xstep, arb_srcptr y, slong ystep, slong len, slong prec) + void arb_dot_precise(arb_t res, const arb_t s, int subtract, arb_srcptr x, slong xstep, arb_srcptr y, slong ystep, slong len, slong prec) noexcept + void arb_dot_simple(arb_t res, const arb_t s, int subtract, arb_srcptr x, slong xstep, arb_srcptr y, slong ystep, slong len, slong prec) noexcept + void arb_dot(arb_t res, const arb_t s, int subtract, arb_srcptr x, slong xstep, arb_srcptr y, slong ystep, slong len, slong prec) noexcept # Computes the dot product of the vectors *x* and *y*, setting # *res* to `s + (-1)^{subtract} \sum_{i=0}^{len-1} x_i y_i`. # The initial term *s* is optional and can be @@ -694,50 +694,50 @@ cdef extern from "flint_wrap.h": # final rounding. This can be extremely slow and is only intended # for testing. - void arb_approx_dot(arb_t res, const arb_t s, int subtract, arb_srcptr x, slong xstep, arb_srcptr y, slong ystep, slong len, slong prec) + void arb_approx_dot(arb_t res, const arb_t s, int subtract, arb_srcptr x, slong xstep, arb_srcptr y, slong ystep, slong len, slong prec) noexcept # Computes an approximate dot product *without error bounds*. # The radii of the inputs are ignored (only the midpoints are read) # and only the midpoint of the output is written. - void arb_dot_ui(arb_t res, const arb_t initial, int subtract, arb_srcptr x, slong xstep, const ulong * y, slong ystep, slong len, slong prec) - void arb_dot_si(arb_t res, const arb_t initial, int subtract, arb_srcptr x, slong xstep, const slong * y, slong ystep, slong len, slong prec) - void arb_dot_uiui(arb_t res, const arb_t initial, int subtract, arb_srcptr x, slong xstep, const ulong * y, slong ystep, slong len, slong prec) - void arb_dot_siui(arb_t res, const arb_t initial, int subtract, arb_srcptr x, slong xstep, const ulong * y, slong ystep, slong len, slong prec) - void arb_dot_fmpz(arb_t res, const arb_t initial, int subtract, arb_srcptr x, slong xstep, const fmpz * y, slong ystep, slong len, slong prec) + void arb_dot_ui(arb_t res, const arb_t initial, int subtract, arb_srcptr x, slong xstep, const ulong * y, slong ystep, slong len, slong prec) noexcept + void arb_dot_si(arb_t res, const arb_t initial, int subtract, arb_srcptr x, slong xstep, const slong * y, slong ystep, slong len, slong prec) noexcept + void arb_dot_uiui(arb_t res, const arb_t initial, int subtract, arb_srcptr x, slong xstep, const ulong * y, slong ystep, slong len, slong prec) noexcept + void arb_dot_siui(arb_t res, const arb_t initial, int subtract, arb_srcptr x, slong xstep, const ulong * y, slong ystep, slong len, slong prec) noexcept + void arb_dot_fmpz(arb_t res, const arb_t initial, int subtract, arb_srcptr x, slong xstep, const fmpz * y, slong ystep, slong len, slong prec) noexcept # Equivalent to :func:`arb_dot`, but with integers in the array *y*. # The *uiui* and *siui* versions take an array of double-limb integers # as input; the *siui* version assumes that these represent signed # integers in two's complement form. - void arb_sqrt(arb_t z, const arb_t x, slong prec) + void arb_sqrt(arb_t z, const arb_t x, slong prec) noexcept - void arb_sqrt_arf(arb_t z, const arf_t x, slong prec) + void arb_sqrt_arf(arb_t z, const arf_t x, slong prec) noexcept - void arb_sqrt_fmpz(arb_t z, const fmpz_t x, slong prec) + void arb_sqrt_fmpz(arb_t z, const fmpz_t x, slong prec) noexcept - void arb_sqrt_ui(arb_t z, ulong x, slong prec) + void arb_sqrt_ui(arb_t z, ulong x, slong prec) noexcept # Sets *z* to the square root of *x*, rounded to *prec* bits. # If `x = m \pm x` where `m \ge r \ge 0`, the propagated error is bounded by # `\sqrt{m} - \sqrt{m-r} = \sqrt{m} (1 - \sqrt{1 - r/m}) \le \sqrt{m} (r/m + (r/m)^2)/2`. - void arb_sqrtpos(arb_t z, const arb_t x, slong prec) + void arb_sqrtpos(arb_t z, const arb_t x, slong prec) noexcept # Sets *z* to the square root of *x*, assuming that *x* represents a # nonnegative number (i.e. discarding any negative numbers in the input # interval). - void arb_hypot(arb_t z, const arb_t x, const arb_t y, slong prec) + void arb_hypot(arb_t z, const arb_t x, const arb_t y, slong prec) noexcept # Sets *z* to `\sqrt{x^2 + y^2}`. - void arb_rsqrt(arb_t z, const arb_t x, slong prec) + void arb_rsqrt(arb_t z, const arb_t x, slong prec) noexcept - void arb_rsqrt_ui(arb_t z, ulong x, slong prec) + void arb_rsqrt_ui(arb_t z, ulong x, slong prec) noexcept # Sets *z* to the reciprocal square root of *x*, rounded to *prec* bits. # At high precision, this is faster than computing a square root. - void arb_sqrt1pm1(arb_t z, const arb_t x, slong prec) + void arb_sqrt1pm1(arb_t z, const arb_t x, slong prec) noexcept # Sets `z = \sqrt{1+x}-1`, computed accurately when `x \approx 0`. - void arb_root_ui(arb_t z, const arb_t x, ulong k, slong prec) + void arb_root_ui(arb_t z, const arb_t x, ulong k, slong prec) noexcept # Sets *z* to the *k*-th root of *x*, rounded to *prec* bits. # This function selects between different algorithms. For large *k*, # it evaluates `\exp(\log(x)/k)`. For small *k*, it uses :func:`arf_root` @@ -751,21 +751,21 @@ cdef extern from "flint_wrap.h": # = m^{1/k} \min(1, \log(1+r/(m-r))/k). # This is evaluated using :func:`mag_log1p`. - void arb_root(arb_t z, const arb_t x, ulong k, slong prec) + void arb_root(arb_t z, const arb_t x, ulong k, slong prec) noexcept # Alias for :func:`arb_root_ui`, provided for backwards compatibility. - void arb_sqr(arb_t y, const arb_t x, slong prec) + void arb_sqr(arb_t y, const arb_t x, slong prec) noexcept # Sets *y* to be the square of *x*. - void arb_pow_fmpz_binexp(arb_t y, const arb_t b, const fmpz_t e, slong prec) + void arb_pow_fmpz_binexp(arb_t y, const arb_t b, const fmpz_t e, slong prec) noexcept - void arb_pow_fmpz(arb_t y, const arb_t b, const fmpz_t e, slong prec) + void arb_pow_fmpz(arb_t y, const arb_t b, const fmpz_t e, slong prec) noexcept - void arb_pow_ui(arb_t y, const arb_t b, ulong e, slong prec) + void arb_pow_ui(arb_t y, const arb_t b, ulong e, slong prec) noexcept - void arb_ui_pow_ui(arb_t y, ulong b, ulong e, slong prec) + void arb_ui_pow_ui(arb_t y, ulong b, ulong e, slong prec) noexcept - void arb_si_pow_ui(arb_t y, slong b, ulong e, slong prec) + void arb_si_pow_ui(arb_t y, slong b, ulong e, slong prec) noexcept # Sets `y = b^e` using binary exponentiation (with an initial division # if `e < 0`). Provided that *b* and *e* # are small enough and the exponent is positive, the exact power can be @@ -773,25 +773,25 @@ cdef extern from "flint_wrap.h": # Note that these functions can get slow if the exponent is # extremely large (in such cases :func:`arb_pow` may be superior). - void arb_pow_fmpq(arb_t y, const arb_t x, const fmpq_t a, slong prec) + void arb_pow_fmpq(arb_t y, const arb_t x, const fmpq_t a, slong prec) noexcept # Sets `y = b^e`, computed as `y = (b^{1/q})^p` if the denominator of # `e = p/q` is small, and generally as `y = \exp(e \log b)`. # Note that this function can get slow if the exponent is # extremely large (in such cases :func:`arb_pow` may be superior). - void arb_pow(arb_t z, const arb_t x, const arb_t y, slong prec) + void arb_pow(arb_t z, const arb_t x, const arb_t y, slong prec) noexcept # Sets `z = x^y`, computed using binary exponentiation if `y` is # a small exact integer, as `z = (x^{1/2})^{2y}` if `y` is a small exact # half-integer, and generally as `z = \exp(y \log x)`, except giving the # obvious finite result if `x` is `a \pm a` and `y` is positive. - void arb_log_ui(arb_t z, ulong x, slong prec) + void arb_log_ui(arb_t z, ulong x, slong prec) noexcept - void arb_log_fmpz(arb_t z, const fmpz_t x, slong prec) + void arb_log_fmpz(arb_t z, const fmpz_t x, slong prec) noexcept - void arb_log_arf(arb_t z, const arf_t x, slong prec) + void arb_log_arf(arb_t z, const arf_t x, slong prec) noexcept - void arb_log(arb_t z, const arb_t x, slong prec) + void arb_log(arb_t z, const arb_t x, slong prec) noexcept # Sets `z = \log(x)`. # At low to medium precision (up to about 4096 bits), :func:`arb_log_arf` # uses table-based argument reduction and fast Taylor series evaluation @@ -799,7 +799,7 @@ cdef extern from "flint_wrap.h": # The function :func:`arb_log` simply calls :func:`arb_log_arf` with # the midpoint as input, and separately adds the propagated error. - void arb_log_ui_from_prev(arb_t log_k1, ulong k1, arb_t log_k0, ulong k0, slong prec) + void arb_log_ui_from_prev(arb_t log_k1, ulong k1, arb_t log_k0, ulong k0, slong prec) noexcept # Computes `\log(k_1)`, given `\log(k_0)` where `k_0 < k_1`. # At high precision, this function uses the formula # `\log(k_1) = \log(k_0) + 2 \operatorname{atanh}((k_1-k_0)/(k_1+k_0))`, @@ -808,53 +808,53 @@ cdef extern from "flint_wrap.h": # be small). Otherwise, it ignores `\log(k_0)` and evaluates the logarithm # the usual way. - void arb_log1p(arb_t z, const arb_t x, slong prec) + void arb_log1p(arb_t z, const arb_t x, slong prec) noexcept # Sets `z = \log(1+x)`, computed accurately when `x \approx 0`. - void arb_log_base_ui(arb_t res, const arb_t x, ulong b, slong prec) + void arb_log_base_ui(arb_t res, const arb_t x, ulong b, slong prec) noexcept # Sets *res* to `\log_b(x)`. The result is computed exactly when possible. - void arb_log_hypot(arb_t res, const arb_t x, const arb_t y, slong prec) + void arb_log_hypot(arb_t res, const arb_t x, const arb_t y, slong prec) noexcept # Sets *res* to `\log(\sqrt{x^2+y^2})`. - void arb_exp(arb_t z, const arb_t x, slong prec) + void arb_exp(arb_t z, const arb_t x, slong prec) noexcept # Sets `z = \exp(x)`. Error propagation is done using the following rule: # assuming `x = m \pm r`, the error is largest at `m + r`, and we have # `\exp(m+r) - \exp(m) = \exp(m) (\exp(r)-1) \le r \exp(m+r)`. - void arb_expm1(arb_t z, const arb_t x, slong prec) + void arb_expm1(arb_t z, const arb_t x, slong prec) noexcept # Sets `z = \exp(x)-1`, using a more accurate method when `x \approx 0`. - void arb_exp_invexp(arb_t z, arb_t w, const arb_t x, slong prec) + void arb_exp_invexp(arb_t z, arb_t w, const arb_t x, slong prec) noexcept # Sets `z = \exp(x)` and `w = \exp(-x)`. The second exponential is computed # from the first using a division, but propagated error bounds are # computed separately. - void arb_sin(arb_t s, const arb_t x, slong prec) + void arb_sin(arb_t s, const arb_t x, slong prec) noexcept - void arb_cos(arb_t c, const arb_t x, slong prec) + void arb_cos(arb_t c, const arb_t x, slong prec) noexcept - void arb_sin_cos(arb_t s, arb_t c, const arb_t x, slong prec) + void arb_sin_cos(arb_t s, arb_t c, const arb_t x, slong prec) noexcept # Sets `s = \sin(x)`, `c = \cos(x)`. - void arb_sin_pi(arb_t s, const arb_t x, slong prec) + void arb_sin_pi(arb_t s, const arb_t x, slong prec) noexcept - void arb_cos_pi(arb_t c, const arb_t x, slong prec) + void arb_cos_pi(arb_t c, const arb_t x, slong prec) noexcept - void arb_sin_cos_pi(arb_t s, arb_t c, const arb_t x, slong prec) + void arb_sin_cos_pi(arb_t s, arb_t c, const arb_t x, slong prec) noexcept # Sets `s = \sin(\pi x)`, `c = \cos(\pi x)`. - void arb_tan(arb_t y, const arb_t x, slong prec) + void arb_tan(arb_t y, const arb_t x, slong prec) noexcept # Sets `y = \tan(x) = \sin(x) / \cos(y)`. - void arb_cot(arb_t y, const arb_t x, slong prec) + void arb_cot(arb_t y, const arb_t x, slong prec) noexcept # Sets `y = \cot(x) = \cos(x) / \sin(y)`. - void arb_sin_cos_pi_fmpq(arb_t s, arb_t c, const fmpq_t x, slong prec) + void arb_sin_cos_pi_fmpq(arb_t s, arb_t c, const fmpq_t x, slong prec) noexcept - void arb_sin_pi_fmpq(arb_t s, const fmpq_t x, slong prec) + void arb_sin_pi_fmpq(arb_t s, const fmpq_t x, slong prec) noexcept - void arb_cos_pi_fmpq(arb_t c, const fmpq_t x, slong prec) + void arb_cos_pi_fmpq(arb_t c, const fmpq_t x, slong prec) noexcept # Sets `s = \sin(\pi x)`, `c = \cos(\pi x)` where `x` is a rational # number (whose numerator and denominator are assumed to be reduced). # We first use trigonometric symmetries to reduce the argument to the @@ -865,30 +865,30 @@ cdef extern from "flint_wrap.h": # first of these two methods gives full accuracy even if the original # argument is close to some root other the origin. - void arb_tan_pi(arb_t y, const arb_t x, slong prec) + void arb_tan_pi(arb_t y, const arb_t x, slong prec) noexcept # Sets `y = \tan(\pi x)`. - void arb_cot_pi(arb_t y, const arb_t x, slong prec) + void arb_cot_pi(arb_t y, const arb_t x, slong prec) noexcept # Sets `y = \cot(\pi x)`. - void arb_sec(arb_t res, const arb_t x, slong prec) + void arb_sec(arb_t res, const arb_t x, slong prec) noexcept # Computes `\sec(x) = 1 / \cos(x)`. - void arb_csc(arb_t res, const arb_t x, slong prec) + void arb_csc(arb_t res, const arb_t x, slong prec) noexcept # Computes `\csc(x) = 1 / \sin(x)`. - void arb_csc_pi(arb_t res, const arb_t x, slong prec) + void arb_csc_pi(arb_t res, const arb_t x, slong prec) noexcept # Computes `\csc(\pi x) = 1 / \sin(\pi x)`. - void arb_sinc(arb_t z, const arb_t x, slong prec) + void arb_sinc(arb_t z, const arb_t x, slong prec) noexcept # Sets `z = \operatorname{sinc}(x) = \sin(x) / x`. - void arb_sinc_pi(arb_t z, const arb_t x, slong prec) + void arb_sinc_pi(arb_t z, const arb_t x, slong prec) noexcept # Sets `z = \operatorname{sinc}(\pi x) = \sin(\pi x) / (\pi x)`. - void arb_atan_arf(arb_t z, const arf_t x, slong prec) + void arb_atan_arf(arb_t z, const arf_t x, slong prec) noexcept - void arb_atan(arb_t z, const arb_t x, slong prec) + void arb_atan(arb_t z, const arb_t x, slong prec) noexcept # Sets `z = \operatorname{atan}(x)`. # At low to medium precision (up to about 4096 bits), :func:`arb_atan_arf` # uses table-based argument reduction and fast Taylor series evaluation @@ -898,94 +898,94 @@ cdef extern from "flint_wrap.h": # The function :func:`arb_atan_arf` uses lookup tables if # possible, and otherwise falls back to :func:`arb_atan_arf_bb`. - void arb_atan2(arb_t z, const arb_t b, const arb_t a, slong prec) + void arb_atan2(arb_t z, const arb_t b, const arb_t a, slong prec) noexcept # Sets *r* to an the argument (phase) of the complex number # `a + bi`, with the branch cut discontinuity on `(-\infty,0]`. # We define `\operatorname{atan2}(0,0) = 0`, and for `a < 0`, # `\operatorname{atan2}(0,a) = \pi`. - void arb_asin(arb_t z, const arb_t x, slong prec) + void arb_asin(arb_t z, const arb_t x, slong prec) noexcept # Sets `z = \operatorname{asin}(x) = \operatorname{atan}(x / \sqrt{1-x^2})`. # If `x` is not contained in the domain `[-1,1]`, the result is an # indeterminate interval. - void arb_acos(arb_t z, const arb_t x, slong prec) + void arb_acos(arb_t z, const arb_t x, slong prec) noexcept # Sets `z = \operatorname{acos}(x) = \pi/2 - \operatorname{asin}(x)`. # If `x` is not contained in the domain `[-1,1]`, the result is an # indeterminate interval. - void arb_sinh(arb_t s, const arb_t x, slong prec) + void arb_sinh(arb_t s, const arb_t x, slong prec) noexcept - void arb_cosh(arb_t c, const arb_t x, slong prec) + void arb_cosh(arb_t c, const arb_t x, slong prec) noexcept - void arb_sinh_cosh(arb_t s, arb_t c, const arb_t x, slong prec) + void arb_sinh_cosh(arb_t s, arb_t c, const arb_t x, slong prec) noexcept # Sets `s = \sinh(x)`, `c = \cosh(x)`. If the midpoint of `x` is close # to zero and the hyperbolic sine is to be computed, # evaluates `(e^{2x}\pm1) / (2e^x)` via :func:`arb_expm1` # to avoid loss of accuracy. Otherwise evaluates `(e^x \pm e^{-x}) / 2`. - void arb_tanh(arb_t y, const arb_t x, slong prec) + void arb_tanh(arb_t y, const arb_t x, slong prec) noexcept # Sets `y = \tanh(x) = \sinh(x) / \cosh(x)`, evaluated # via :func:`arb_expm1` as `\tanh(x) = (e^{2x} - 1) / (e^{2x} + 1)` # if `|x|` is small, and as # `\tanh(\pm x) = 1 - 2 e^{\mp 2x} / (1 + e^{\mp 2x})` # if `|x|` is large. - void arb_coth(arb_t y, const arb_t x, slong prec) + void arb_coth(arb_t y, const arb_t x, slong prec) noexcept # Sets `y = \coth(x) = \cosh(x) / \sinh(x)`, evaluated using # the same strategy as :func:`arb_tanh`. - void arb_sech(arb_t res, const arb_t x, slong prec) + void arb_sech(arb_t res, const arb_t x, slong prec) noexcept # Computes `\operatorname{sech}(x) = 1 / \cosh(x)`. - void arb_csch(arb_t res, const arb_t x, slong prec) + void arb_csch(arb_t res, const arb_t x, slong prec) noexcept # Computes `\operatorname{csch}(x) = 1 / \sinh(x)`. - void arb_atanh(arb_t z, const arb_t x, slong prec) + void arb_atanh(arb_t z, const arb_t x, slong prec) noexcept # Sets `z = \operatorname{atanh}(x)`. - void arb_asinh(arb_t z, const arb_t x, slong prec) + void arb_asinh(arb_t z, const arb_t x, slong prec) noexcept # Sets `z = \operatorname{asinh}(x)`. - void arb_acosh(arb_t z, const arb_t x, slong prec) + void arb_acosh(arb_t z, const arb_t x, slong prec) noexcept # Sets `z = \operatorname{acosh}(x)`. # If `x < 1`, the result is an indeterminate interval. - void arb_const_pi(arb_t z, slong prec) + void arb_const_pi(arb_t z, slong prec) noexcept # Computes `\pi`. - void arb_const_sqrt_pi(arb_t z, slong prec) + void arb_const_sqrt_pi(arb_t z, slong prec) noexcept # Computes `\sqrt{\pi}`. - void arb_const_log_sqrt2pi(arb_t z, slong prec) + void arb_const_log_sqrt2pi(arb_t z, slong prec) noexcept # Computes `\log \sqrt{2 \pi}`. - void arb_const_log2(arb_t z, slong prec) + void arb_const_log2(arb_t z, slong prec) noexcept # Computes `\log(2)`. - void arb_const_log10(arb_t z, slong prec) + void arb_const_log10(arb_t z, slong prec) noexcept # Computes `\log(10)`. - void arb_const_euler(arb_t z, slong prec) + void arb_const_euler(arb_t z, slong prec) noexcept # Computes Euler's constant `\gamma = \lim_{k \rightarrow \infty} (H_k - \log k)` # where `H_k = 1 + 1/2 + \ldots + 1/k`. - void arb_const_catalan(arb_t z, slong prec) + void arb_const_catalan(arb_t z, slong prec) noexcept # Computes Catalan's constant `C = \sum_{n=0}^{\infty} (-1)^n / (2n+1)^2`. - void arb_const_e(arb_t z, slong prec) + void arb_const_e(arb_t z, slong prec) noexcept # Computes `e = \exp(1)`. - void arb_const_khinchin(arb_t z, slong prec) + void arb_const_khinchin(arb_t z, slong prec) noexcept # Computes Khinchin's constant `K_0`. - void arb_const_glaisher(arb_t z, slong prec) + void arb_const_glaisher(arb_t z, slong prec) noexcept # Computes the Glaisher-Kinkelin constant `A = \exp(1/12 - \zeta'(-1))`. - void arb_const_apery(arb_t z, slong prec) + void arb_const_apery(arb_t z, slong prec) noexcept # Computes Apery's constant `\zeta(3)`. - void arb_lambertw(arb_t res, const arb_t x, int flags, slong prec) + void arb_lambertw(arb_t res, const arb_t x, int flags, slong prec) noexcept # Computes the Lambert W function, which solves the equation `w e^w = x`. # The Lambert W function has infinitely many complex branches `W_k(x)`, # two of which are real on a part of the real line. @@ -1002,52 +1002,52 @@ cdef extern from "flint_wrap.h": # The algorithm used to compute the Lambert W function is described # in [Joh2017b]_, which follows the main ideas in [CGHJK1996]_. - void arb_rising_ui(arb_t z, const arb_t x, ulong n, slong prec) - void arb_rising(arb_t z, const arb_t x, const arb_t n, slong prec) + void arb_rising_ui(arb_t z, const arb_t x, ulong n, slong prec) noexcept + void arb_rising(arb_t z, const arb_t x, const arb_t n, slong prec) noexcept # Computes the rising factorial `z = x (x+1) (x+2) \cdots (x+n-1)`. # These functions are aliases for :func:`arb_hypgeom_rising_ui` # and :func:`arb_hypgeom_rising`. - void arb_rising_fmpq_ui(arb_t z, const fmpq_t x, ulong n, slong prec) + void arb_rising_fmpq_ui(arb_t z, const fmpq_t x, ulong n, slong prec) noexcept # Computes the rising factorial `z = x (x+1) (x+2) \cdots (x+n-1)` using # binary splitting. If the denominator or numerator of *x* is large # compared to *prec*, it is more efficient to convert *x* to an approximation # and use :func:`arb_rising_ui`. - void arb_fac_ui(arb_t z, ulong n, slong prec) + void arb_fac_ui(arb_t z, ulong n, slong prec) noexcept # Computes the factorial `z = n!` via the gamma function. - void arb_doublefac_ui(arb_t z, ulong n, slong prec) + void arb_doublefac_ui(arb_t z, ulong n, slong prec) noexcept # Computes the double factorial `z = n!!` via the gamma function. - void arb_bin_ui(arb_t z, const arb_t n, ulong k, slong prec) + void arb_bin_ui(arb_t z, const arb_t n, ulong k, slong prec) noexcept - void arb_bin_uiui(arb_t z, ulong n, ulong k, slong prec) + void arb_bin_uiui(arb_t z, ulong n, ulong k, slong prec) noexcept # Computes the binomial coefficient `z = {n choose k}`, via the # rising factorial as `{n choose k} = (n-k+1)_k / k!`. - void arb_gamma(arb_t z, const arb_t x, slong prec) - void arb_gamma_fmpq(arb_t z, const fmpq_t x, slong prec) - void arb_gamma_fmpz(arb_t z, const fmpz_t x, slong prec) + void arb_gamma(arb_t z, const arb_t x, slong prec) noexcept + void arb_gamma_fmpq(arb_t z, const fmpq_t x, slong prec) noexcept + void arb_gamma_fmpz(arb_t z, const fmpz_t x, slong prec) noexcept # Computes the gamma function `z = \Gamma(x)`. # These functions are aliases for :func:`arb_hypgeom_gamma`, # :func:`arb_hypgeom_gamma_fmpq`, :func:`arb_hypgeom_gamma_fmpz`. - void arb_lgamma(arb_t z, const arb_t x, slong prec) + void arb_lgamma(arb_t z, const arb_t x, slong prec) noexcept # Computes the logarithmic gamma function `z = \log \Gamma(x)`. # The complex branch structure is assumed, so if `x \le 0`, the # result is an indeterminate interval. # This function is an alias for :func:`arb_hypgeom_lgamma`. - void arb_rgamma(arb_t z, const arb_t x, slong prec) + void arb_rgamma(arb_t z, const arb_t x, slong prec) noexcept # Computes the reciprocal gamma function `z = 1/\Gamma(x)`, # avoiding division by zero at the poles of the gamma function. # This function is an alias for :func:`arb_hypgeom_rgamma`. - void arb_digamma(arb_t y, const arb_t x, slong prec) + void arb_digamma(arb_t y, const arb_t x, slong prec) noexcept # Computes the digamma function `z = \psi(x) = (\log \Gamma(x))' = \Gamma'(x) / \Gamma(x)`. - void arb_zeta_ui_vec_borwein(arb_ptr z, ulong start, slong num, ulong step, slong prec) + void arb_zeta_ui_vec_borwein(arb_ptr z, ulong start, slong num, ulong step, slong prec) noexcept # Evaluates `\zeta(s)` at `\mathrm{num}` consecutive integers *s* beginning # with *start* and proceeding in increments of *step*. # Uses Borwein's formula ([Bor2000]_, [GS2003]_), @@ -1072,49 +1072,49 @@ cdef extern from "flint_wrap.h": # additional rounding error, so by induction, the error per term # is always smaller than 2 units. - void arb_zeta_ui_asymp(arb_t x, ulong s, slong prec) + void arb_zeta_ui_asymp(arb_t x, ulong s, slong prec) noexcept - void arb_zeta_ui_euler_product(arb_t z, ulong s, slong prec) + void arb_zeta_ui_euler_product(arb_t z, ulong s, slong prec) noexcept # Computes `\zeta(s)` using the Euler product. This is fast only if *s* # is large compared to the precision. Both methods are trivial wrappers # for :func:`_acb_dirichlet_euler_product_real_ui`. - void arb_zeta_ui_bernoulli(arb_t x, ulong s, slong prec) + void arb_zeta_ui_bernoulli(arb_t x, ulong s, slong prec) noexcept # Computes `\zeta(s)` for even *s* via the corresponding Bernoulli number. - void arb_zeta_ui_borwein_bsplit(arb_t x, ulong s, slong prec) + void arb_zeta_ui_borwein_bsplit(arb_t x, ulong s, slong prec) noexcept # Computes `\zeta(s)` for arbitrary `s \ge 2` using a binary splitting # implementation of Borwein's algorithm. This has quasilinear complexity # with respect to the precision (assuming that `s` is fixed). - void arb_zeta_ui_vec(arb_ptr x, ulong start, slong num, slong prec) + void arb_zeta_ui_vec(arb_ptr x, ulong start, slong num, slong prec) noexcept - void arb_zeta_ui_vec_even(arb_ptr x, ulong start, slong num, slong prec) + void arb_zeta_ui_vec_even(arb_ptr x, ulong start, slong num, slong prec) noexcept - void arb_zeta_ui_vec_odd(arb_ptr x, ulong start, slong num, slong prec) + void arb_zeta_ui_vec_odd(arb_ptr x, ulong start, slong num, slong prec) noexcept # Computes `\zeta(s)` at *num* consecutive integers (respectively *num* # even or *num* odd integers) beginning with `s = \mathrm{start} \ge 2`, # automatically choosing an appropriate algorithm. - void arb_zeta_ui(arb_t x, ulong s, slong prec) + void arb_zeta_ui(arb_t x, ulong s, slong prec) noexcept # Computes `\zeta(s)` for nonnegative integer `s \ne 1`, automatically # choosing an appropriate algorithm. This function is # intended for numerical evaluation of isolated zeta values; for # multi-evaluation, the vector versions are more efficient. - void arb_zeta(arb_t z, const arb_t s, slong prec) + void arb_zeta(arb_t z, const arb_t s, slong prec) noexcept # Sets *z* to the value of the Riemann zeta function `\zeta(s)`. # For computing derivatives with respect to `s`, # use :func:`arb_poly_zeta_series`. - void arb_hurwitz_zeta(arb_t z, const arb_t s, const arb_t a, slong prec) + void arb_hurwitz_zeta(arb_t z, const arb_t s, const arb_t a, slong prec) noexcept # Sets *z* to the value of the Hurwitz zeta function `\zeta(s,a)`. # For computing derivatives with respect to `s`, # use :func:`arb_poly_zeta_series`. - void arb_bernoulli_ui(arb_t b, ulong n, slong prec) + void arb_bernoulli_ui(arb_t b, ulong n, slong prec) noexcept - void arb_bernoulli_fmpz(arb_t b, const fmpz_t n, slong prec) + void arb_bernoulli_fmpz(arb_t b, const fmpz_t n, slong prec) noexcept # Sets `b` to the numerical value of the Bernoulli number `B_n` # approximated to *prec* bits. # The internal precision is increased automatically to give an accurate @@ -1128,7 +1128,7 @@ cdef extern from "flint_wrap.h": # if the number is already cached, but does not automatically extend # the cache by itself. - void arb_bernoulli_ui_zeta(arb_t b, ulong n, slong prec) + void arb_bernoulli_ui_zeta(arb_t b, ulong n, slong prec) noexcept # Sets `b` to the numerical value of `B_n` accurate to *prec* bits, # computed using the formula `B_{2n} = (-1)^{n+1} 2 (2n)! \zeta(2n) / (2 \pi)^n`. # To avoid potential infinite recursion, we explicitly call the @@ -1136,13 +1136,13 @@ cdef extern from "flint_wrap.h": # This method will only give high accuracy if the precision is small # enough compared to `n` for the Euler product to converge rapidly. - void arb_bernoulli_poly_ui(arb_t res, ulong n, const arb_t x, slong prec) + void arb_bernoulli_poly_ui(arb_t res, ulong n, const arb_t x, slong prec) noexcept # Sets *res* to the value of the Bernoulli polynomial `B_n(x)`. # Warning: this function is only fast if either *n* or *x* is a small integer. # This function reads Bernoulli numbers from the global cache if they # are already cached, but does not automatically extend the cache by itself. - void arb_power_sum_vec(arb_ptr res, const arb_t a, const arb_t b, slong len, slong prec) + void arb_power_sum_vec(arb_ptr res, const arb_t a, const arb_t b, slong len, slong prec) noexcept # For *n* from 0 to *len* - 1, sets entry *n* in the output vector *res* to # .. math :: # S_n(a,b) = \frac{1}{n+1}\left(B_{n+1}(b) - B_{n+1}(a)\right) @@ -1152,83 +1152,83 @@ cdef extern from "flint_wrap.h": # S_n(a,b) = \sum_{k=a}^{b-1} k^n. # The computation uses the generating function for Bernoulli polynomials. - void arb_polylog(arb_t w, const arb_t s, const arb_t z, slong prec) + void arb_polylog(arb_t w, const arb_t s, const arb_t z, slong prec) noexcept - void arb_polylog_si(arb_t w, slong s, const arb_t z, slong prec) + void arb_polylog_si(arb_t w, slong s, const arb_t z, slong prec) noexcept # Sets *w* to the polylogarithm `\operatorname{Li}_s(z)`. - void arb_fib_fmpz(arb_t z, const fmpz_t n, slong prec) - void arb_fib_ui(arb_t z, ulong n, slong prec) + void arb_fib_fmpz(arb_t z, const fmpz_t n, slong prec) noexcept + void arb_fib_ui(arb_t z, ulong n, slong prec) noexcept # Computes the Fibonacci number `F_n` using binary squaring. - void arb_agm(arb_t z, const arb_t x, const arb_t y, slong prec) + void arb_agm(arb_t z, const arb_t x, const arb_t y, slong prec) noexcept # Sets *z* to the arithmetic-geometric mean of *x* and *y*. - void arb_chebyshev_t_ui(arb_t a, ulong n, const arb_t x, slong prec) + void arb_chebyshev_t_ui(arb_t a, ulong n, const arb_t x, slong prec) noexcept - void arb_chebyshev_u_ui(arb_t a, ulong n, const arb_t x, slong prec) + void arb_chebyshev_u_ui(arb_t a, ulong n, const arb_t x, slong prec) noexcept # Evaluates the Chebyshev polynomial of the first kind `a = T_n(x)` # or the Chebyshev polynomial of the second kind `a = U_n(x)`. - void arb_chebyshev_t2_ui(arb_t a, arb_t b, ulong n, const arb_t x, slong prec) + void arb_chebyshev_t2_ui(arb_t a, arb_t b, ulong n, const arb_t x, slong prec) noexcept - void arb_chebyshev_u2_ui(arb_t a, arb_t b, ulong n, const arb_t x, slong prec) + void arb_chebyshev_u2_ui(arb_t a, arb_t b, ulong n, const arb_t x, slong prec) noexcept # Simultaneously evaluates `a = T_n(x), b = T_{n-1}(x)` or # `a = U_n(x), b = U_{n-1}(x)`. # Aliasing between *a*, *b* and *x* is not permitted. - void arb_bell_sum_bsplit(arb_t res, const fmpz_t n, const fmpz_t a, const fmpz_t b, const fmpz_t mmag, slong prec) + void arb_bell_sum_bsplit(arb_t res, const fmpz_t n, const fmpz_t a, const fmpz_t b, const fmpz_t mmag, slong prec) noexcept - void arb_bell_sum_taylor(arb_t res, const fmpz_t n, const fmpz_t a, const fmpz_t b, const fmpz_t mmag, slong prec) + void arb_bell_sum_taylor(arb_t res, const fmpz_t n, const fmpz_t a, const fmpz_t b, const fmpz_t mmag, slong prec) noexcept # Helper functions for Bell numbers, evaluating the sum # `\sum_{k=a}^{b-1} k^n / k!`. If *mmag* is non-NULL, it may be used # to indicate that the target error tolerance should be # `2^{mmag - prec}`. - void arb_bell_fmpz(arb_t res, const fmpz_t n, slong prec) + void arb_bell_fmpz(arb_t res, const fmpz_t n, slong prec) noexcept - void arb_bell_ui(arb_t res, ulong n, slong prec) + void arb_bell_ui(arb_t res, ulong n, slong prec) noexcept # Sets *res* to the Bell number `B_n`. If the number is too large to # fit exactly in *prec* bits, a numerical approximation is computed # efficiently. # The algorithm to compute Bell numbers, including error analysis, # is described in detail in [Joh2015]_. - void arb_euler_number_fmpz(arb_t res, const fmpz_t n, slong prec) - void arb_euler_number_ui(arb_t res, ulong n, slong prec) + void arb_euler_number_fmpz(arb_t res, const fmpz_t n, slong prec) noexcept + void arb_euler_number_ui(arb_t res, ulong n, slong prec) noexcept # Sets *res* to the Euler number `E_n`, which is defined by # the exponential generating function `1 / \cosh(x)`. # The result will be exact if `E_n` is exactly representable # at the requested precision. - void arb_fmpz_euler_number_ui_multi_mod(fmpz_t res, ulong n, double alpha) - void arb_fmpz_euler_number_ui(fmpz_t res, ulong n) + void arb_fmpz_euler_number_ui_multi_mod(fmpz_t res, ulong n, double alpha) noexcept + void arb_fmpz_euler_number_ui(fmpz_t res, ulong n) noexcept # Computes the Euler number `E_n` as an exact integer. The default # algorithm uses a table lookup, the Dirichlet beta function or a # hybrid modular algorithm depending on the size of *n*. # The *multi_mod* algorithm accepts a tuning parameter *alpha* which # can be set to a negative value to use defaults. - void arb_partitions_fmpz(arb_t res, const fmpz_t n, slong prec) + void arb_partitions_fmpz(arb_t res, const fmpz_t n, slong prec) noexcept - void arb_partitions_ui(arb_t res, ulong n, slong prec) + void arb_partitions_ui(arb_t res, ulong n, slong prec) noexcept # Sets *res* to the partition function `p(n)`. # When *n* is large and `\log_2 p(n)` is more than twice *prec*, # the leading term in the Hardy-Ramanujan asymptotic series is used # together with an error bound. Otherwise, the exact value is computed # and rounded. - void arb_primorial_nth_ui(arb_t res, ulong n, slong prec) + void arb_primorial_nth_ui(arb_t res, ulong n, slong prec) noexcept # Sets *res* to the *nth* primorial, defined as the product of the # first *n* prime numbers. The running time is quasilinear in *n*. - void arb_primorial_ui(arb_t res, ulong n, slong prec) + void arb_primorial_ui(arb_t res, ulong n, slong prec) noexcept # Sets *res* to the primorial defined as the product of the positive # integers up to and including *n*. The running time is quasilinear in *n*. - 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_naive(mp_ptr y, mp_limb_t * error, mp_srcptr x, mp_size_t xn, ulong N, int alternating) noexcept - 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_atan_taylor_rs(mp_ptr y, mp_limb_t * error, mp_srcptr x, mp_size_t xn, ulong N, int alternating) noexcept # Computes an approximation of `y = \sum_{k=0}^{N-1} x^{2k+1} / (2k+1)` # (if *alternating* is 0) or `y = \sum_{k=0}^{N-1} (-1)^k x^{2k+1} / (2k+1)` # (if *alternating* is 1). Used internally for computing arctangents @@ -1238,9 +1238,9 @@ cdef extern from "flint_wrap.h": # The input *x* and output *y* are fixed-point numbers with *xn* fractional # limbs. A bound for the ulp error is written to *error*. - 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_naive(mp_ptr y, mp_limb_t * error, mp_srcptr x, mp_size_t xn, ulong N) noexcept - void _arb_exp_taylor_rs(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) noexcept # Computes an approximation of `y = \sum_{k=0}^{N-1} x^k / k!`. Used internally # for computing exponentials. The *naive* version uses the forward recurrence, # and the *rs* version uses a division-avoiding rectangular splitting scheme. @@ -1250,9 +1250,9 @@ cdef extern from "flint_wrap.h": # limbs plus one extra limb for the integer part of the result. # A bound for the ulp error is written to *error*. - 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_naive(mp_ptr ysin, mp_ptr ycos, mp_limb_t * error, mp_srcptr x, mp_size_t xn, ulong N) noexcept - 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) + 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) noexcept # Computes approximations of `y_s = \sum_{k=0}^{N-1} (-1)^k x^{2k+1} / (2k+1)!` # and `y_c = \sum_{k=0}^{N-1} (-1)^k x^{2k} / (2k)!`. # Used internally for computing sines and cosines. The *naive* version uses @@ -1267,24 +1267,24 @@ cdef extern from "flint_wrap.h": # the hyperbolic sine is computed (this is currently only intended to # be used together with *sinonly*). - 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_log2(mp_ptr w, fmpz_t q, mp_limb_t * error, const arf_t x, mp_size_t wn) noexcept # Attempts to write `w = x - q \log(2)` with `0 \le w < \log(2)`, where *w* # is a fixed-point number with *wn* limbs and ulp error *error*. # Returns success. - 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) + 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) noexcept # Attempts to write `w = |x| - q \pi/4` with `0 \le w < \pi/4`, where *w* # is a fixed-point number with *wn* limbs and ulp error *error*. # Returns success. # The value of *q* mod 8 is written to *octant*. The output variable *q* # can be NULL, in which case the full value of *q* is not stored. - slong _arb_exp_taylor_bound(slong mag, slong prec) + slong _arb_exp_taylor_bound(slong mag, slong prec) noexcept # Returns *n* such that # `\left|\sum_{k=n}^{\infty} x^k / k!\right| \le 2^{-\mathrm{prec}}`, # assuming `|x| \le 2^{\mathrm{mag}} \le 1/4`. - void arb_exp_arf_bb(arb_t z, const arf_t x, slong prec, int m1) + void arb_exp_arf_bb(arb_t z, const arf_t x, slong prec, int m1) noexcept # Computes the exponential function using the bit-burst algorithm. # If *m1* is nonzero, the exponential function minus one is computed # accurately. @@ -1299,9 +1299,9 @@ cdef extern from "flint_wrap.h": # could be improved by using `\log(2)` based reduction at precision low # enough that the value can be assumed to be cached. - 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) + 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) noexcept - void _arb_exp_sum_bs_powtab(fmpz_t T, fmpz_t Q, flint_bitcnt_t * Qexp, const fmpz_t x, flint_bitcnt_t r, slong N) + void _arb_exp_sum_bs_powtab(fmpz_t T, fmpz_t Q, flint_bitcnt_t * Qexp, const fmpz_t x, flint_bitcnt_t r, slong N) noexcept # Computes *T*, *Q* and *Qexp* such that # `T / (Q 2^{\text{Qexp}}) = \sum_{k=1}^N (x/2^r)^k/k!` using binary splitting. # Note that the sum is taken to *N* inclusive and omits the constant term. @@ -1309,13 +1309,13 @@ cdef extern from "flint_wrap.h": # resulting in slightly higher memory usage but better speed. For best # efficiency, *N* should have many trailing zero bits. - void arb_exp_arf_rs_generic(arb_t res, const arf_t x, slong prec, int minus_one) + void arb_exp_arf_rs_generic(arb_t res, const arf_t x, slong prec, int minus_one) noexcept # Computes the exponential function using a generic version of the rectangular # splitting strategy, intended for intermediate precision. - void _arb_atan_sum_bs_simple(fmpz_t T, fmpz_t Q, flint_bitcnt_t * Qexp, const fmpz_t x, flint_bitcnt_t r, slong N) + void _arb_atan_sum_bs_simple(fmpz_t T, fmpz_t Q, flint_bitcnt_t * Qexp, const fmpz_t x, flint_bitcnt_t r, slong N) noexcept - void _arb_atan_sum_bs_powtab(fmpz_t T, fmpz_t Q, flint_bitcnt_t * Qexp, const fmpz_t x, flint_bitcnt_t r, slong N) + void _arb_atan_sum_bs_powtab(fmpz_t T, fmpz_t Q, flint_bitcnt_t * Qexp, const fmpz_t x, flint_bitcnt_t r, slong N) noexcept # Computes *T*, *Q* and *Qexp* such that # `T / (Q 2^{\text{Qexp}}) = \sum_{k=1}^N (-1)^k (x/2^r)^{2k} / (2k+1)` # using binary splitting. @@ -1326,7 +1326,7 @@ cdef extern from "flint_wrap.h": # resulting in slightly higher memory usage but better speed. For best # efficiency, *N* should have many trailing zero bits. - void arb_atan_arf_bb(arb_t z, const arf_t x, slong prec) + void arb_atan_arf_bb(arb_t z, const arf_t x, slong prec) noexcept # Computes the arctangent of *x*. # Initially, the argument-halving formula # .. math :: @@ -1342,11 +1342,11 @@ cdef extern from "flint_wrap.h": # is applied repeatedly instead of integrating a differential # equation for the arctangent, as this appears to be more efficient. - void arb_atan_frac_bsplit(arb_t s, const fmpz_t p, const fmpz_t q, int hyperbolic, slong prec) + void arb_atan_frac_bsplit(arb_t s, const fmpz_t p, const fmpz_t q, int hyperbolic, slong prec) noexcept # Computes the arctangent of `p/q`, optionally the hyperbolic # arctangent, using direct series summation with binary splitting. - void arb_sin_cos_arf_generic(arb_t s, arb_t c, const arf_t x, slong prec) + void arb_sin_cos_arf_generic(arb_t s, arb_t c, const arf_t x, slong prec) noexcept # Computes the sine and cosine of *x* using a generic strategy. # This function gets called internally by the main sin and cos functions # when the precision for argument reduction or series evaluation @@ -1360,11 +1360,11 @@ cdef extern from "flint_wrap.h": # of the rectangular splitting algorithm if the precision is not too high, # and otherwise invokes the asymptotically fast bit-burst algorithm. - void arb_sin_cos_arf_bb(arb_t s, arb_t c, const arf_t x, slong prec) + void arb_sin_cos_arf_bb(arb_t s, arb_t c, const arf_t x, slong prec) noexcept # Computes the sine and cosine of *x* using the bit-burst algorithm. # It is required that `|x| < \pi / 2` (this is not checked). - void arb_sin_cos_wide(arb_t s, arb_t c, const arb_t x, slong prec) + void arb_sin_cos_wide(arb_t s, arb_t c, const arb_t x, slong prec) noexcept # Computes an accurate enclosure (with both endpoints optimal to within # about `2^{-30}` as afforded by the radius format) of the range of # sine and cosine on a given wide interval. The computation is done @@ -1380,111 +1380,111 @@ cdef extern from "flint_wrap.h": # slower reduction using :type:`arb_t` arithmetic is done as a # preprocessing step. - void arb_sin_cos_generic(arb_t s, arb_t c, const arb_t x, slong prec) + void arb_sin_cos_generic(arb_t s, arb_t c, const arb_t x, slong prec) noexcept # Computes the sine and cosine of *x* by taking care of various special # cases and computing the propagated error before calling # :func:`arb_sin_cos_arf_generic`. This is used as a fallback inside # :func:`arb_sin_cos` to take care of all cases without a fast # path in that function. - void arb_log_primes_vec_bsplit(arb_ptr res, slong n, slong prec) + void arb_log_primes_vec_bsplit(arb_ptr res, slong n, slong prec) noexcept # Sets *res* to a vector containing the natural logarithms of # the first *n* prime numbers, computed using binary splitting # applied to simultaneous Machine-type formulas. This function is not # optimized for large *n* or small *prec*. - void _arb_log_p_ensure_cached(slong prec) + void _arb_log_p_ensure_cached(slong prec) noexcept # Ensure that the internal cache of logarithms of small prime # numbers has entries to at least *prec* bits. - void arb_exp_arf_log_reduction(arb_t res, const arf_t x, slong prec, int minus_one) + void arb_exp_arf_log_reduction(arb_t res, const arf_t x, slong prec, int minus_one) noexcept # Computes the exponential function using log reduction. - void arb_exp_arf_generic(arb_t z, const arf_t x, slong prec, int minus_one) + void arb_exp_arf_generic(arb_t z, const arf_t x, slong prec, int minus_one) noexcept # Computes the exponential function using an automatic choice # between rectangular splitting and the bit-burst algorithm, # without precomputation. - void arb_exp_arf(arb_t z, const arf_t x, slong prec, int minus_one, slong maglim) + void arb_exp_arf(arb_t z, const arf_t x, slong prec, int minus_one, slong maglim) noexcept # Computes the exponential function using an automatic choice # between all implemented algorithms. - void arb_log_newton(arb_t res, const arb_t x, slong prec) - void arb_log_arf_newton(arb_t res, const arf_t x, slong prec) + void arb_log_newton(arb_t res, const arb_t x, slong prec) noexcept + void arb_log_arf_newton(arb_t res, const arf_t x, slong prec) noexcept # Computes the logarithm using Newton iteration. - void arb_atan_gauss_primes_vec_bsplit(arb_ptr res, slong n, slong prec) + void arb_atan_gauss_primes_vec_bsplit(arb_ptr res, slong n, slong prec) noexcept # Sets *res* to the primitive angles corresponding to the # first *n* nonreal Gaussian primes (ignoring symmetries), # computed using binary splitting # applied to simultaneous Machine-type formulas. This function is not # optimized for large *n* or small *prec*. - void _arb_atan_gauss_p_ensure_cached(slong prec) + void _arb_atan_gauss_p_ensure_cached(slong prec) noexcept - void arb_sin_cos_arf_atan_reduction(arb_t res1, arb_t res2, const arf_t x, slong prec) + void arb_sin_cos_arf_atan_reduction(arb_t res1, arb_t res2, const arf_t x, slong prec) noexcept # Computes sin and/or cos using reduction by primitive angles. - void arb_atan_newton(arb_t res, const arb_t x, slong prec) - void arb_atan_arf_newton(arb_t res, const arf_t x, slong prec) + void arb_atan_newton(arb_t res, const arb_t x, slong prec) noexcept + void arb_atan_arf_newton(arb_t res, const arf_t x, slong prec) noexcept # Computes the arctangent using Newton iteration. - void _arb_vec_zero(arb_ptr vec, slong n) + void _arb_vec_zero(arb_ptr vec, slong n) noexcept # Sets all entries in *vec* to zero. - bint _arb_vec_is_zero(arb_srcptr vec, slong len) + bint _arb_vec_is_zero(arb_srcptr vec, slong len) noexcept # Returns nonzero iff all entries in *x* are zero. - bint _arb_vec_is_finite(arb_srcptr x, slong len) + bint _arb_vec_is_finite(arb_srcptr x, slong len) noexcept # Returns nonzero iff all entries in *x* certainly are finite. - void _arb_vec_set(arb_ptr res, arb_srcptr vec, slong len) + void _arb_vec_set(arb_ptr res, arb_srcptr vec, slong len) noexcept # Sets *res* to a copy of *vec*. - void _arb_vec_set_round(arb_ptr res, arb_srcptr vec, slong len, slong prec) + void _arb_vec_set_round(arb_ptr res, arb_srcptr vec, slong len, slong prec) noexcept # Sets *res* to a copy of *vec*, rounding each entry to *prec* bits. - void _arb_vec_swap(arb_ptr vec1, arb_ptr vec2, slong len) + void _arb_vec_swap(arb_ptr vec1, arb_ptr vec2, slong len) noexcept # Swaps the entries of *vec1* and *vec2*. - void _arb_vec_neg(arb_ptr B, arb_srcptr A, slong n) + void _arb_vec_neg(arb_ptr B, arb_srcptr A, slong n) noexcept - void _arb_vec_sub(arb_ptr C, arb_srcptr A, arb_srcptr B, slong n, slong prec) + void _arb_vec_sub(arb_ptr C, arb_srcptr A, arb_srcptr B, slong n, slong prec) noexcept - void _arb_vec_add(arb_ptr C, arb_srcptr A, arb_srcptr B, slong n, slong prec) + void _arb_vec_add(arb_ptr C, arb_srcptr A, arb_srcptr B, slong n, slong prec) noexcept - void _arb_vec_scalar_mul(arb_ptr res, arb_srcptr vec, slong len, const arb_t c, slong prec) + void _arb_vec_scalar_mul(arb_ptr res, arb_srcptr vec, slong len, const arb_t c, slong prec) noexcept - void _arb_vec_scalar_div(arb_ptr res, arb_srcptr vec, slong len, const arb_t c, slong prec) + void _arb_vec_scalar_div(arb_ptr res, arb_srcptr vec, slong len, const arb_t c, slong prec) noexcept - void _arb_vec_scalar_mul_fmpz(arb_ptr res, arb_srcptr vec, slong len, const fmpz_t c, slong prec) + void _arb_vec_scalar_mul_fmpz(arb_ptr res, arb_srcptr vec, slong len, const fmpz_t c, slong prec) noexcept - void _arb_vec_scalar_mul_2exp_si(arb_ptr res, arb_srcptr src, slong len, slong c) + void _arb_vec_scalar_mul_2exp_si(arb_ptr res, arb_srcptr src, slong len, slong c) noexcept - void _arb_vec_scalar_addmul(arb_ptr res, arb_srcptr vec, slong len, const arb_t c, slong prec) + void _arb_vec_scalar_addmul(arb_ptr res, arb_srcptr vec, slong len, const arb_t c, slong prec) noexcept - void _arb_vec_get_mag(mag_t bound, arb_srcptr vec, slong len) + void _arb_vec_get_mag(mag_t bound, arb_srcptr vec, slong len) noexcept # Sets *bound* to an upper bound for the entries in *vec*. - slong _arb_vec_bits(arb_srcptr x, slong len) + slong _arb_vec_bits(arb_srcptr x, slong len) noexcept # Returns the maximum of :func:`arb_bits` for all entries in *vec*. - void _arb_vec_set_powers(arb_ptr xs, const arb_t x, slong len, slong prec) + void _arb_vec_set_powers(arb_ptr xs, const arb_t x, slong len, slong prec) noexcept # Sets *xs* to the powers `1, x, x^2, \ldots, x^{len-1}`. - void _arb_vec_add_error_arf_vec(arb_ptr res, arf_srcptr err, slong len) + void _arb_vec_add_error_arf_vec(arb_ptr res, arf_srcptr err, slong len) noexcept - void _arb_vec_add_error_mag_vec(arb_ptr res, mag_srcptr err, slong len) + void _arb_vec_add_error_mag_vec(arb_ptr res, mag_srcptr err, slong len) noexcept # Adds the magnitude of each entry in *err* to the radius of the # corresponding entry in *res*. - void _arb_vec_indeterminate(arb_ptr vec, slong len) + void _arb_vec_indeterminate(arb_ptr vec, slong len) noexcept # Applies :func:`arb_indeterminate` elementwise. - void _arb_vec_trim(arb_ptr res, arb_srcptr vec, slong len) + void _arb_vec_trim(arb_ptr res, arb_srcptr vec, slong len) noexcept # Applies :func:`arb_trim` elementwise. - int _arb_vec_get_unique_fmpz_vec(fmpz * res, arb_srcptr vec, slong len) + int _arb_vec_get_unique_fmpz_vec(fmpz * res, arb_srcptr vec, slong len) noexcept # Calls :func:`arb_get_unique_fmpz` elementwise and returns nonzero if # all entries can be rounded uniquely to integers. If any entry in *vec* # cannot be rounded uniquely to an integer, returns zero. diff --git a/src/sage/libs/flint/arb_calc.pxd b/src/sage/libs/flint/arb_calc.pxd index 27b6601ec59..2d872e59343 100644 --- a/src/sage/libs/flint/arb_calc.pxd +++ b/src/sage/libs/flint/arb_calc.pxd @@ -12,27 +12,27 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void arf_interval_init(arf_interval_t v) + void arf_interval_init(arf_interval_t v) noexcept - void arf_interval_clear(arf_interval_t v) + void arf_interval_clear(arf_interval_t v) noexcept - arf_interval_ptr _arf_interval_vec_init(slong n) + arf_interval_ptr _arf_interval_vec_init(slong n) noexcept - void _arf_interval_vec_clear(arf_interval_ptr v, slong n) + void _arf_interval_vec_clear(arf_interval_ptr v, slong n) noexcept - void arf_interval_set(arf_interval_t v, const arf_interval_t u) + void arf_interval_set(arf_interval_t v, const arf_interval_t u) noexcept - void arf_interval_swap(arf_interval_t v, arf_interval_t u) + void arf_interval_swap(arf_interval_t v, arf_interval_t u) noexcept - void arf_interval_get_arb(arb_t x, const arf_interval_t v, slong prec) + void arf_interval_get_arb(arb_t x, const arf_interval_t v, slong prec) noexcept - void arf_interval_printd(const arf_interval_t v, slong n) + void arf_interval_printd(const arf_interval_t v, slong n) noexcept # Helper functions for endpoint-based intervals. - void arf_interval_fprintd(FILE * file, const arf_interval_t v, slong n) + void arf_interval_fprintd(FILE * file, const arf_interval_t v, slong n) noexcept # Helper functions for endpoint-based intervals. - slong arb_calc_isolate_roots(arf_interval_ptr * found, int ** flags, arb_calc_func_t func, void * param, const arf_interval_t interval, slong maxdepth, slong maxeval, slong maxfound, slong prec) + slong arb_calc_isolate_roots(arf_interval_ptr * found, int ** flags, arb_calc_func_t func, void * param, const arf_interval_t interval, slong maxdepth, slong maxeval, slong maxfound, slong prec) noexcept # Rigorously isolates single roots of a real analytic function # on the interior of an interval. # This routine writes an array of *n* interesting subintervals of @@ -75,14 +75,14 @@ cdef extern from "flint_wrap.h": # represented exactly as floating-point numbers in memory. # Do not pass `1 \pm 2^{-10^{100}}` as input. - int arb_calc_refine_root_bisect(arf_interval_t r, arb_calc_func_t func, void * param, const arf_interval_t start, slong it, slong prec) + int arb_calc_refine_root_bisect(arf_interval_t r, arb_calc_func_t func, void * param, const arf_interval_t start, slong it, slong prec) noexcept # Given an interval *start* known to contain a single root of *func*, # refines it using *iter* bisection steps. The algorithm can # return a failure code if the sign of the function at an evaluation # point is ambiguous. The output *r* is set to a valid isolating interval # (possibly just *start*) even if the algorithm fails. - void arb_calc_newton_conv_factor(arf_t conv_factor, arb_calc_func_t func, void * param, const arb_t conv_region, slong prec) + void arb_calc_newton_conv_factor(arf_t conv_factor, arb_calc_func_t func, void * param, const arb_t conv_region, slong prec) noexcept # Given an interval `I` specified by *conv_region*, evaluates a bound # for `C = \sup_{t,u \in I} \frac{1}{2} |f''(t)| / |f'(u)|`, # where `f` is the function specified by *func* and *param*. @@ -90,7 +90,7 @@ cdef extern from "flint_wrap.h": # If `f` is ill-conditioned, `I` may need to be extremely precise in # order to get an effective, finite bound for *C*. - int arb_calc_newton_step(arb_t xnew, arb_calc_func_t func, void * param, const arb_t x, const arb_t conv_region, const arf_t conv_factor, slong prec) + int arb_calc_newton_step(arb_t xnew, arb_calc_func_t func, void * param, const arb_t x, const arb_t conv_region, const arf_t conv_factor, slong prec) noexcept # Performs a single step with an interval version of Newton's method. # The input consists of the function `f` specified # by *func* and *param*, a ball `x = [m-r, m+r]` known @@ -109,7 +109,7 @@ cdef extern from "flint_wrap.h": # *ARB_CALC_NO_CONVERGENCE*, indicating that no progress # is made. - int arb_calc_refine_root_newton(arb_t r, arb_calc_func_t func, void * param, const arb_t start, const arb_t conv_region, const arf_t conv_factor, slong eval_extra_prec, slong prec) + int arb_calc_refine_root_newton(arb_t r, arb_calc_func_t func, void * param, const arb_t start, const arb_t conv_region, const arf_t conv_factor, slong eval_extra_prec, slong prec) noexcept # Refines a precise estimate of a single root of a function # to high precision by performing several Newton steps, using # nearly optimally chosen doubling precision steps. diff --git a/src/sage/libs/flint/arb_fmpz_poly.pxd b/src/sage/libs/flint/arb_fmpz_poly.pxd index 0ef6725ffaa..6a5b28a0301 100644 --- a/src/sage/libs/flint/arb_fmpz_poly.pxd +++ b/src/sage/libs/flint/arb_fmpz_poly.pxd @@ -12,40 +12,40 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void _arb_fmpz_poly_evaluate_arb_horner(arb_t res, const fmpz * poly, slong len, const arb_t x, slong prec) + void _arb_fmpz_poly_evaluate_arb_horner(arb_t res, const fmpz * poly, slong len, const arb_t x, slong prec) noexcept - void arb_fmpz_poly_evaluate_arb_horner(arb_t res, const fmpz_poly_t poly, const arb_t x, slong prec) + void arb_fmpz_poly_evaluate_arb_horner(arb_t res, const fmpz_poly_t poly, const arb_t x, slong prec) noexcept - void _arb_fmpz_poly_evaluate_arb_rectangular(arb_t res, const fmpz * poly, slong len, const arb_t x, slong prec) + void _arb_fmpz_poly_evaluate_arb_rectangular(arb_t res, const fmpz * poly, slong len, const arb_t x, slong prec) noexcept - void arb_fmpz_poly_evaluate_arb_rectangular(arb_t res, const fmpz_poly_t poly, const arb_t x, slong prec) + void arb_fmpz_poly_evaluate_arb_rectangular(arb_t res, const fmpz_poly_t poly, const arb_t x, slong prec) noexcept - void _arb_fmpz_poly_evaluate_arb(arb_t res, const fmpz * poly, slong len, const arb_t x, slong prec) + void _arb_fmpz_poly_evaluate_arb(arb_t res, const fmpz * poly, slong len, const arb_t x, slong prec) noexcept - void arb_fmpz_poly_evaluate_arb(arb_t res, const fmpz_poly_t poly, const arb_t x, slong prec) + void arb_fmpz_poly_evaluate_arb(arb_t res, const fmpz_poly_t poly, const arb_t x, slong prec) noexcept - void _arb_fmpz_poly_evaluate_acb_horner(acb_t res, const fmpz * poly, slong len, const acb_t x, slong prec) + void _arb_fmpz_poly_evaluate_acb_horner(acb_t res, const fmpz * poly, slong len, const acb_t x, slong prec) noexcept - void arb_fmpz_poly_evaluate_acb_horner(acb_t res, const fmpz_poly_t poly, const acb_t x, slong prec) + void arb_fmpz_poly_evaluate_acb_horner(acb_t res, const fmpz_poly_t poly, const acb_t x, slong prec) noexcept - void _arb_fmpz_poly_evaluate_acb_rectangular(acb_t res, const fmpz * poly, slong len, const acb_t x, slong prec) + void _arb_fmpz_poly_evaluate_acb_rectangular(acb_t res, const fmpz * poly, slong len, const acb_t x, slong prec) noexcept - void arb_fmpz_poly_evaluate_acb_rectangular(acb_t res, const fmpz_poly_t poly, const acb_t x, slong prec) + void arb_fmpz_poly_evaluate_acb_rectangular(acb_t res, const fmpz_poly_t poly, const acb_t x, slong prec) noexcept - void _arb_fmpz_poly_evaluate_acb(acb_t res, const fmpz * poly, slong len, const acb_t x, slong prec) + void _arb_fmpz_poly_evaluate_acb(acb_t res, const fmpz * poly, slong len, const acb_t x, slong prec) noexcept - void arb_fmpz_poly_evaluate_acb(acb_t res, const fmpz_poly_t poly, const acb_t x, slong prec) + void arb_fmpz_poly_evaluate_acb(acb_t res, const fmpz_poly_t poly, const acb_t x, slong prec) noexcept # Evaluates *poly* (given by a polynomial object or an array with *len* coefficients) # at the given real or complex number, respectively using Horner's rule, rectangular # splitting, or a default algorithm choice. - ulong arb_fmpz_poly_deflation(const fmpz_poly_t poly) + ulong arb_fmpz_poly_deflation(const fmpz_poly_t poly) noexcept # Finds the maximal exponent by which *poly* can be deflated. - void arb_fmpz_poly_deflate(fmpz_poly_t res, const fmpz_poly_t poly, ulong deflation) + void arb_fmpz_poly_deflate(fmpz_poly_t res, const fmpz_poly_t poly, ulong deflation) noexcept # Sets *res* to a copy of *poly* deflated by the exponent *deflation*. - void arb_fmpz_poly_complex_roots(acb_ptr roots, const fmpz_poly_t poly, int flags, slong prec) + void arb_fmpz_poly_complex_roots(acb_ptr roots, const fmpz_poly_t poly, int flags, slong prec) noexcept # Writes to *roots* all the real and complex roots of the polynomial *poly*, # computed to at least *prec* accurate bits. # The root enclosures are guaranteed to be disjoint, so that @@ -80,12 +80,12 @@ cdef extern from "flint_wrap.h": # The following *flags* are supported: # * *ARB_FMPZ_POLY_ROOTS_VERBOSE* - void arb_fmpz_poly_cos_minpoly(fmpz_poly_t res, ulong n) + void arb_fmpz_poly_cos_minpoly(fmpz_poly_t res, ulong n) noexcept # Sets *res* to the monic minimal polynomial of `2 \cos(2 \pi / n)`. # This is a wrapper of FLINT's *fmpz_poly_cos_minpoly*, provided here # for backward compatibility. - void arb_fmpz_poly_gauss_period_minpoly(fmpz_poly_t res, ulong q, ulong n) + void arb_fmpz_poly_gauss_period_minpoly(fmpz_poly_t res, ulong q, ulong n) noexcept # Sets *res* to the minimal polynomial of the Gaussian periods # `\sum_{a \in H} \zeta^a` where `\zeta = \exp(2 \pi i / q)` # and *H* are the cosets of the subgroups of order `d = (q - 1) / n` of diff --git a/src/sage/libs/flint/arb_fpwrap.pxd b/src/sage/libs/flint/arb_fpwrap.pxd index beb5e912a64..2c5095c9f85 100644 --- a/src/sage/libs/flint/arb_fpwrap.pxd +++ b/src/sage/libs/flint/arb_fpwrap.pxd @@ -12,337 +12,337 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - int arb_fpwrap_double_exp(double * res, double x, int flags) - int arb_fpwrap_cdouble_exp(complex_double * res, complex_double x, int flags) + int arb_fpwrap_double_exp(double * res, double x, int flags) noexcept + int arb_fpwrap_cdouble_exp(complex_double * res, complex_double x, int flags) noexcept - int arb_fpwrap_double_expm1(double * res, double x, int flags) - int arb_fpwrap_cdouble_expm1(complex_double * res, complex_double x, int flags) + int arb_fpwrap_double_expm1(double * res, double x, int flags) noexcept + int arb_fpwrap_cdouble_expm1(complex_double * res, complex_double x, int flags) noexcept - int arb_fpwrap_double_log(double * res, double x, int flags) - int arb_fpwrap_cdouble_log(complex_double * res, complex_double x, int flags) + int arb_fpwrap_double_log(double * res, double x, int flags) noexcept + int arb_fpwrap_cdouble_log(complex_double * res, complex_double x, int flags) noexcept - int arb_fpwrap_double_log1p(double * res, double x, int flags) - int arb_fpwrap_cdouble_log1p(complex_double * res, complex_double x, int flags) + int arb_fpwrap_double_log1p(double * res, double x, int flags) noexcept + int arb_fpwrap_cdouble_log1p(complex_double * res, complex_double x, int flags) noexcept - int arb_fpwrap_double_pow(double * res, double x, double y, int flags) - int arb_fpwrap_cdouble_pow(complex_double * res, complex_double x, complex_double y, int flags) + int arb_fpwrap_double_pow(double * res, double x, double y, int flags) noexcept + int arb_fpwrap_cdouble_pow(complex_double * res, complex_double x, complex_double y, int flags) noexcept - int arb_fpwrap_double_sqrt(double * res, double x, int flags) - int arb_fpwrap_cdouble_sqrt(complex_double * res, complex_double x, int flags) + int arb_fpwrap_double_sqrt(double * res, double x, int flags) noexcept + int arb_fpwrap_cdouble_sqrt(complex_double * res, complex_double x, int flags) noexcept - int arb_fpwrap_double_rsqrt(double * res, double x, int flags) - int arb_fpwrap_cdouble_rsqrt(complex_double * res, complex_double x, int flags) + int arb_fpwrap_double_rsqrt(double * res, double x, int flags) noexcept + int arb_fpwrap_cdouble_rsqrt(complex_double * res, complex_double x, int flags) noexcept - int arb_fpwrap_double_cbrt(double * res, double x, int flags) - int arb_fpwrap_cdouble_cbrt(complex_double * res, complex_double x, int flags) + int arb_fpwrap_double_cbrt(double * res, double x, int flags) noexcept + int arb_fpwrap_cdouble_cbrt(complex_double * res, complex_double x, int flags) noexcept - int arb_fpwrap_double_sin(double * res, double x, int flags) - int arb_fpwrap_cdouble_sin(complex_double * res, complex_double x, int flags) + int arb_fpwrap_double_sin(double * res, double x, int flags) noexcept + int arb_fpwrap_cdouble_sin(complex_double * res, complex_double x, int flags) noexcept - int arb_fpwrap_double_cos(double * res, double x, int flags) - int arb_fpwrap_cdouble_cos(complex_double * res, complex_double x, int flags) + int arb_fpwrap_double_cos(double * res, double x, int flags) noexcept + int arb_fpwrap_cdouble_cos(complex_double * res, complex_double x, int flags) noexcept - int arb_fpwrap_double_tan(double * res, double x, int flags) - int arb_fpwrap_cdouble_tan(complex_double * res, complex_double x, int flags) + int arb_fpwrap_double_tan(double * res, double x, int flags) noexcept + int arb_fpwrap_cdouble_tan(complex_double * res, complex_double x, int flags) noexcept - int arb_fpwrap_double_cot(double * res, double x, int flags) - int arb_fpwrap_cdouble_cot(complex_double * res, complex_double x, int flags) + int arb_fpwrap_double_cot(double * res, double x, int flags) noexcept + int arb_fpwrap_cdouble_cot(complex_double * res, complex_double x, int flags) noexcept - int arb_fpwrap_double_sec(double * res, double x, int flags) - int arb_fpwrap_cdouble_sec(complex_double * res, complex_double x, int flags) + int arb_fpwrap_double_sec(double * res, double x, int flags) noexcept + int arb_fpwrap_cdouble_sec(complex_double * res, complex_double x, int flags) noexcept - int arb_fpwrap_double_csc(double * res, double x, int flags) - int arb_fpwrap_cdouble_csc(complex_double * res, complex_double x, int flags) + int arb_fpwrap_double_csc(double * res, double x, int flags) noexcept + int arb_fpwrap_cdouble_csc(complex_double * res, complex_double x, int flags) noexcept - int arb_fpwrap_double_sinc(double * res, double x, int flags) - int arb_fpwrap_cdouble_sinc(complex_double * res, complex_double x, int flags) + int arb_fpwrap_double_sinc(double * res, double x, int flags) noexcept + int arb_fpwrap_cdouble_sinc(complex_double * res, complex_double x, int flags) noexcept - int arb_fpwrap_double_sin_pi(double * res, double x, int flags) - int arb_fpwrap_cdouble_sin_pi(complex_double * res, complex_double x, int flags) + int arb_fpwrap_double_sin_pi(double * res, double x, int flags) noexcept + int arb_fpwrap_cdouble_sin_pi(complex_double * res, complex_double x, int flags) noexcept - int arb_fpwrap_double_cos_pi(double * res, double x, int flags) - int arb_fpwrap_cdouble_cos_pi(complex_double * res, complex_double x, int flags) + int arb_fpwrap_double_cos_pi(double * res, double x, int flags) noexcept + int arb_fpwrap_cdouble_cos_pi(complex_double * res, complex_double x, int flags) noexcept - int arb_fpwrap_double_tan_pi(double * res, double x, int flags) - int arb_fpwrap_cdouble_tan_pi(complex_double * res, complex_double x, int flags) + int arb_fpwrap_double_tan_pi(double * res, double x, int flags) noexcept + int arb_fpwrap_cdouble_tan_pi(complex_double * res, complex_double x, int flags) noexcept - int arb_fpwrap_double_cot_pi(double * res, double x, int flags) - int arb_fpwrap_cdouble_cot_pi(complex_double * res, complex_double x, int flags) + int arb_fpwrap_double_cot_pi(double * res, double x, int flags) noexcept + int arb_fpwrap_cdouble_cot_pi(complex_double * res, complex_double x, int flags) noexcept - int arb_fpwrap_double_sinc_pi(double * res, double x, int flags) - int arb_fpwrap_cdouble_sinc_pi(complex_double * res, complex_double x, int flags) + int arb_fpwrap_double_sinc_pi(double * res, double x, int flags) noexcept + int arb_fpwrap_cdouble_sinc_pi(complex_double * res, complex_double x, int flags) noexcept - int arb_fpwrap_double_asin(double * res, double x, int flags) - int arb_fpwrap_cdouble_asin(complex_double * res, complex_double x, int flags) + int arb_fpwrap_double_asin(double * res, double x, int flags) noexcept + int arb_fpwrap_cdouble_asin(complex_double * res, complex_double x, int flags) noexcept - int arb_fpwrap_double_acos(double * res, double x, int flags) - int arb_fpwrap_cdouble_acos(complex_double * res, complex_double x, int flags) + int arb_fpwrap_double_acos(double * res, double x, int flags) noexcept + int arb_fpwrap_cdouble_acos(complex_double * res, complex_double x, int flags) noexcept - int arb_fpwrap_double_atan(double * res, double x, int flags) - int arb_fpwrap_cdouble_atan(complex_double * res, complex_double x, int flags) + int arb_fpwrap_double_atan(double * res, double x, int flags) noexcept + int arb_fpwrap_cdouble_atan(complex_double * res, complex_double x, int flags) noexcept - int arb_fpwrap_double_atan2(double * res, double x1, double x2, int flags) + int arb_fpwrap_double_atan2(double * res, double x1, double x2, int flags) noexcept - int arb_fpwrap_double_asinh(double * res, double x, int flags) - int arb_fpwrap_cdouble_asinh(complex_double * res, complex_double x, int flags) + int arb_fpwrap_double_asinh(double * res, double x, int flags) noexcept + int arb_fpwrap_cdouble_asinh(complex_double * res, complex_double x, int flags) noexcept - int arb_fpwrap_double_acosh(double * res, double x, int flags) - int arb_fpwrap_cdouble_acosh(complex_double * res, complex_double x, int flags) + int arb_fpwrap_double_acosh(double * res, double x, int flags) noexcept + int arb_fpwrap_cdouble_acosh(complex_double * res, complex_double x, int flags) noexcept - int arb_fpwrap_double_atanh(double * res, double x, int flags) - int arb_fpwrap_cdouble_atanh(complex_double * res, complex_double x, int flags) + int arb_fpwrap_double_atanh(double * res, double x, int flags) noexcept + int arb_fpwrap_cdouble_atanh(complex_double * res, complex_double x, int flags) noexcept - int arb_fpwrap_double_lambertw(double * res, double x, slong branch, int flags) - int arb_fpwrap_cdouble_lambertw(complex_double * res, complex_double x, slong branch, int flags) + int arb_fpwrap_double_lambertw(double * res, double x, slong branch, int flags) noexcept + int arb_fpwrap_cdouble_lambertw(complex_double * res, complex_double x, slong branch, int flags) noexcept - int arb_fpwrap_double_rising(double * res, double x, double n, int flags) - int arb_fpwrap_cdouble_rising(complex_double * res, complex_double x, complex_double n, int flags) + int arb_fpwrap_double_rising(double * res, double x, double n, int flags) noexcept + int arb_fpwrap_cdouble_rising(complex_double * res, complex_double x, complex_double n, int flags) noexcept # Rising factorial. - int arb_fpwrap_double_gamma(double * res, double x, int flags) - int arb_fpwrap_cdouble_gamma(complex_double * res, complex_double x, int flags) + int arb_fpwrap_double_gamma(double * res, double x, int flags) noexcept + int arb_fpwrap_cdouble_gamma(complex_double * res, complex_double x, int flags) noexcept # Gamma function. - int arb_fpwrap_double_rgamma(double * res, double x, int flags) - int arb_fpwrap_cdouble_rgamma(complex_double * res, complex_double x, int flags) + int arb_fpwrap_double_rgamma(double * res, double x, int flags) noexcept + int arb_fpwrap_cdouble_rgamma(complex_double * res, complex_double x, int flags) noexcept # Reciprocal gamma function. - int arb_fpwrap_double_lgamma(double * res, double x, int flags) - int arb_fpwrap_cdouble_lgamma(complex_double * res, complex_double x, int flags) + int arb_fpwrap_double_lgamma(double * res, double x, int flags) noexcept + int arb_fpwrap_cdouble_lgamma(complex_double * res, complex_double x, int flags) noexcept # Log-gamma function. - int arb_fpwrap_double_digamma(double * res, double x, int flags) - int arb_fpwrap_cdouble_digamma(complex_double * res, complex_double x, int flags) + int arb_fpwrap_double_digamma(double * res, double x, int flags) noexcept + int arb_fpwrap_cdouble_digamma(complex_double * res, complex_double x, int flags) noexcept # Digamma function. - int arb_fpwrap_double_zeta(double * res, double x, int flags) - int arb_fpwrap_cdouble_zeta(complex_double * res, complex_double x, int flags) + int arb_fpwrap_double_zeta(double * res, double x, int flags) noexcept + int arb_fpwrap_cdouble_zeta(complex_double * res, complex_double x, int flags) noexcept # Riemann zeta function. - int arb_fpwrap_double_hurwitz_zeta(double * res, double s, double z, int flags) - int arb_fpwrap_cdouble_hurwitz_zeta(complex_double * res, complex_double s, complex_double z, int flags) + int arb_fpwrap_double_hurwitz_zeta(double * res, double s, double z, int flags) noexcept + int arb_fpwrap_cdouble_hurwitz_zeta(complex_double * res, complex_double s, complex_double z, int flags) noexcept # Hurwitz zeta function. - int arb_fpwrap_double_lerch_phi(double * res, double z, double s, double a, int flags) - int arb_fpwrap_cdouble_lerch_phi(complex_double * res, complex_double z, complex_double s, complex_double a, int flags) + int arb_fpwrap_double_lerch_phi(double * res, double z, double s, double a, int flags) noexcept + int arb_fpwrap_cdouble_lerch_phi(complex_double * res, complex_double z, complex_double s, complex_double a, int flags) noexcept # Lerch transcendent. - int arb_fpwrap_double_barnes_g(double * res, double x, int flags) - int arb_fpwrap_cdouble_barnes_g(complex_double * res, complex_double x, int flags) + int arb_fpwrap_double_barnes_g(double * res, double x, int flags) noexcept + int arb_fpwrap_cdouble_barnes_g(complex_double * res, complex_double x, int flags) noexcept # Barnes G-function. - int arb_fpwrap_double_log_barnes_g(double * res, double x, int flags) - int arb_fpwrap_cdouble_log_barnes_g(complex_double * res, complex_double x, int flags) + int arb_fpwrap_double_log_barnes_g(double * res, double x, int flags) noexcept + int arb_fpwrap_cdouble_log_barnes_g(complex_double * res, complex_double x, int flags) noexcept # Logarithmic Barnes G-function. - int arb_fpwrap_double_polygamma(double * res, double s, double z, int flags) - int arb_fpwrap_cdouble_polygamma(complex_double * res, complex_double s, complex_double z, int flags) + int arb_fpwrap_double_polygamma(double * res, double s, double z, int flags) noexcept + int arb_fpwrap_cdouble_polygamma(complex_double * res, complex_double s, complex_double z, int flags) noexcept # Polygamma function. - int arb_fpwrap_double_polylog(double * res, double s, double z, int flags) - int arb_fpwrap_cdouble_polylog(complex_double * res, complex_double s, complex_double z, int flags) + int arb_fpwrap_double_polylog(double * res, double s, double z, int flags) noexcept + int arb_fpwrap_cdouble_polylog(complex_double * res, complex_double s, complex_double z, int flags) noexcept # Polylogarithm. - int arb_fpwrap_cdouble_dirichlet_eta(complex_double * res, complex_double s, int flags) + int arb_fpwrap_cdouble_dirichlet_eta(complex_double * res, complex_double s, int flags) noexcept - int arb_fpwrap_cdouble_riemann_xi(complex_double * res, complex_double s, int flags) + int arb_fpwrap_cdouble_riemann_xi(complex_double * res, complex_double s, int flags) noexcept - int arb_fpwrap_cdouble_hardy_theta(complex_double * res, complex_double z, int flags) + int arb_fpwrap_cdouble_hardy_theta(complex_double * res, complex_double z, int flags) noexcept - int arb_fpwrap_cdouble_hardy_z(complex_double * res, complex_double z, int flags) + int arb_fpwrap_cdouble_hardy_z(complex_double * res, complex_double z, int flags) noexcept - int arb_fpwrap_cdouble_zeta_zero(complex_double * res, ulong n, int flags) + int arb_fpwrap_cdouble_zeta_zero(complex_double * res, ulong n, int flags) noexcept - int arb_fpwrap_double_erf(double * res, double x, int flags) - int arb_fpwrap_cdouble_erf(complex_double * res, complex_double x, int flags) + int arb_fpwrap_double_erf(double * res, double x, int flags) noexcept + int arb_fpwrap_cdouble_erf(complex_double * res, complex_double x, int flags) noexcept - int arb_fpwrap_double_erfc(double * res, double x, int flags) - int arb_fpwrap_cdouble_erfc(complex_double * res, complex_double x, int flags) + int arb_fpwrap_double_erfc(double * res, double x, int flags) noexcept + int arb_fpwrap_cdouble_erfc(complex_double * res, complex_double x, int flags) noexcept - int arb_fpwrap_double_erfi(double * res, double x, int flags) - int arb_fpwrap_cdouble_erfi(complex_double * res, complex_double x, int flags) + int arb_fpwrap_double_erfi(double * res, double x, int flags) noexcept + int arb_fpwrap_cdouble_erfi(complex_double * res, complex_double x, int flags) noexcept - int arb_fpwrap_double_erfinv(double * res, double x, int flags) + int arb_fpwrap_double_erfinv(double * res, double x, int flags) noexcept - int arb_fpwrap_double_erfcinv(double * res, double x, int flags) + int arb_fpwrap_double_erfcinv(double * res, double x, int flags) noexcept - int arb_fpwrap_double_fresnel_s(double * res, double x, int normalized, int flags) - int arb_fpwrap_cdouble_fresnel_s(complex_double * res, complex_double x, int normalized, int flags) + int arb_fpwrap_double_fresnel_s(double * res, double x, int normalized, int flags) noexcept + int arb_fpwrap_cdouble_fresnel_s(complex_double * res, complex_double x, int normalized, int flags) noexcept - int arb_fpwrap_double_fresnel_c(double * res, double x, int normalized, int flags) - int arb_fpwrap_cdouble_fresnel_c(complex_double * res, complex_double x, int normalized, int flags) + int arb_fpwrap_double_fresnel_c(double * res, double x, int normalized, int flags) noexcept + int arb_fpwrap_cdouble_fresnel_c(complex_double * res, complex_double x, int normalized, int flags) noexcept - int arb_fpwrap_double_gamma_upper(double * res, double s, double z, int regularized, int flags) - int arb_fpwrap_cdouble_gamma_upper(complex_double * res, complex_double s, complex_double z, int regularized, int flags) + int arb_fpwrap_double_gamma_upper(double * res, double s, double z, int regularized, int flags) noexcept + int arb_fpwrap_cdouble_gamma_upper(complex_double * res, complex_double s, complex_double z, int regularized, int flags) noexcept - int arb_fpwrap_double_gamma_lower(double * res, double s, double z, int regularized, int flags) - int arb_fpwrap_cdouble_gamma_lower(complex_double * res, complex_double s, complex_double z, int regularized, int flags) + int arb_fpwrap_double_gamma_lower(double * res, double s, double z, int regularized, int flags) noexcept + int arb_fpwrap_cdouble_gamma_lower(complex_double * res, complex_double s, complex_double z, int regularized, int flags) noexcept - int arb_fpwrap_double_beta_lower(double * res, double a, double b, double z, int regularized, int flags) - int arb_fpwrap_cdouble_beta_lower(complex_double * res, complex_double a, complex_double b, complex_double z, int regularized, int flags) + int arb_fpwrap_double_beta_lower(double * res, double a, double b, double z, int regularized, int flags) noexcept + int arb_fpwrap_cdouble_beta_lower(complex_double * res, complex_double a, complex_double b, complex_double z, int regularized, int flags) noexcept - int arb_fpwrap_double_exp_integral_e(double * res, double s, double z, int flags) - int arb_fpwrap_cdouble_exp_integral_e(complex_double * res, complex_double s, complex_double z, int flags) + int arb_fpwrap_double_exp_integral_e(double * res, double s, double z, int flags) noexcept + int arb_fpwrap_cdouble_exp_integral_e(complex_double * res, complex_double s, complex_double z, int flags) noexcept - int arb_fpwrap_double_exp_integral_ei(double * res, double x, int flags) - int arb_fpwrap_cdouble_exp_integral_ei(complex_double * res, complex_double x, int flags) + int arb_fpwrap_double_exp_integral_ei(double * res, double x, int flags) noexcept + int arb_fpwrap_cdouble_exp_integral_ei(complex_double * res, complex_double x, int flags) noexcept - int arb_fpwrap_double_sin_integral(double * res, double x, int flags) - int arb_fpwrap_cdouble_sin_integral(complex_double * res, complex_double x, int flags) + int arb_fpwrap_double_sin_integral(double * res, double x, int flags) noexcept + int arb_fpwrap_cdouble_sin_integral(complex_double * res, complex_double x, int flags) noexcept - int arb_fpwrap_double_cos_integral(double * res, double x, int flags) - int arb_fpwrap_cdouble_cos_integral(complex_double * res, complex_double x, int flags) + int arb_fpwrap_double_cos_integral(double * res, double x, int flags) noexcept + int arb_fpwrap_cdouble_cos_integral(complex_double * res, complex_double x, int flags) noexcept - int arb_fpwrap_double_sinh_integral(double * res, double x, int flags) - int arb_fpwrap_cdouble_sinh_integral(complex_double * res, complex_double x, int flags) + int arb_fpwrap_double_sinh_integral(double * res, double x, int flags) noexcept + int arb_fpwrap_cdouble_sinh_integral(complex_double * res, complex_double x, int flags) noexcept - int arb_fpwrap_double_cosh_integral(double * res, double x, int flags) - int arb_fpwrap_cdouble_cosh_integral(complex_double * res, complex_double x, int flags) + int arb_fpwrap_double_cosh_integral(double * res, double x, int flags) noexcept + int arb_fpwrap_cdouble_cosh_integral(complex_double * res, complex_double x, int flags) noexcept - int arb_fpwrap_double_log_integral(double * res, double x, int offset, int flags) - int arb_fpwrap_cdouble_log_integral(complex_double * res, complex_double x, int offset, int flags) + int arb_fpwrap_double_log_integral(double * res, double x, int offset, int flags) noexcept + int arb_fpwrap_cdouble_log_integral(complex_double * res, complex_double x, int offset, int flags) noexcept - int arb_fpwrap_double_dilog(double * res, double x, int flags) - int arb_fpwrap_cdouble_dilog(complex_double * res, complex_double x, int flags) + int arb_fpwrap_double_dilog(double * res, double x, int flags) noexcept + int arb_fpwrap_cdouble_dilog(complex_double * res, complex_double x, int flags) noexcept - int arb_fpwrap_double_bessel_j(double * res, double nu, double x, int flags) - int arb_fpwrap_cdouble_bessel_j(complex_double * res, complex_double nu, complex_double x, int flags) + int arb_fpwrap_double_bessel_j(double * res, double nu, double x, int flags) noexcept + int arb_fpwrap_cdouble_bessel_j(complex_double * res, complex_double nu, complex_double x, int flags) noexcept - int arb_fpwrap_double_bessel_y(double * res, double nu, double x, int flags) - int arb_fpwrap_cdouble_bessel_y(complex_double * res, complex_double nu, complex_double x, int flags) + int arb_fpwrap_double_bessel_y(double * res, double nu, double x, int flags) noexcept + int arb_fpwrap_cdouble_bessel_y(complex_double * res, complex_double nu, complex_double x, int flags) noexcept - int arb_fpwrap_double_bessel_i(double * res, double nu, double x, int flags) - int arb_fpwrap_cdouble_bessel_i(complex_double * res, complex_double nu, complex_double x, int flags) + int arb_fpwrap_double_bessel_i(double * res, double nu, double x, int flags) noexcept + int arb_fpwrap_cdouble_bessel_i(complex_double * res, complex_double nu, complex_double x, int flags) noexcept - int arb_fpwrap_double_bessel_k(double * res, double nu, double x, int flags) - int arb_fpwrap_cdouble_bessel_k(complex_double * res, complex_double nu, complex_double x, int flags) + int arb_fpwrap_double_bessel_k(double * res, double nu, double x, int flags) noexcept + int arb_fpwrap_cdouble_bessel_k(complex_double * res, complex_double nu, complex_double x, int flags) noexcept - int arb_fpwrap_double_bessel_k_scaled(double * res, double nu, double x, int flags) - int arb_fpwrap_cdouble_bessel_k_scaled(complex_double * res, complex_double nu, complex_double x, int flags) + int arb_fpwrap_double_bessel_k_scaled(double * res, double nu, double x, int flags) noexcept + int arb_fpwrap_cdouble_bessel_k_scaled(complex_double * res, complex_double nu, complex_double x, int flags) noexcept - int arb_fpwrap_double_airy_ai(double * res, double x, int flags) - int arb_fpwrap_cdouble_airy_ai(complex_double * res, complex_double x, int flags) + int arb_fpwrap_double_airy_ai(double * res, double x, int flags) noexcept + int arb_fpwrap_cdouble_airy_ai(complex_double * res, complex_double x, int flags) noexcept - int arb_fpwrap_double_airy_ai_prime(double * res, double x, int flags) - int arb_fpwrap_cdouble_airy_ai_prime(complex_double * res, complex_double x, int flags) + int arb_fpwrap_double_airy_ai_prime(double * res, double x, int flags) noexcept + int arb_fpwrap_cdouble_airy_ai_prime(complex_double * res, complex_double x, int flags) noexcept - int arb_fpwrap_double_airy_bi(double * res, double x, int flags) - int arb_fpwrap_cdouble_airy_bi(complex_double * res, complex_double x, int flags) + int arb_fpwrap_double_airy_bi(double * res, double x, int flags) noexcept + int arb_fpwrap_cdouble_airy_bi(complex_double * res, complex_double x, int flags) noexcept - int arb_fpwrap_double_airy_bi_prime(double * res, double x, int flags) - int arb_fpwrap_cdouble_airy_bi_prime(complex_double * res, complex_double x, int flags) + int arb_fpwrap_double_airy_bi_prime(double * res, double x, int flags) noexcept + int arb_fpwrap_cdouble_airy_bi_prime(complex_double * res, complex_double x, int flags) noexcept - int arb_fpwrap_double_airy_ai_zero(double * res, ulong n, int flags) + int arb_fpwrap_double_airy_ai_zero(double * res, ulong n, int flags) noexcept - int arb_fpwrap_double_airy_ai_prime_zero(double * res, ulong n, int flags) + int arb_fpwrap_double_airy_ai_prime_zero(double * res, ulong n, int flags) noexcept - int arb_fpwrap_double_airy_bi_zero(double * res, ulong n, int flags) + int arb_fpwrap_double_airy_bi_zero(double * res, ulong n, int flags) noexcept - int arb_fpwrap_double_airy_bi_prime_zero(double * res, ulong n, int flags) + int arb_fpwrap_double_airy_bi_prime_zero(double * res, ulong n, int flags) noexcept - int arb_fpwrap_double_coulomb_f(double * res, double l, double eta, double x, int flags) - int arb_fpwrap_cdouble_coulomb_f(complex_double * res, complex_double l, complex_double eta, complex_double x, int flags) + int arb_fpwrap_double_coulomb_f(double * res, double l, double eta, double x, int flags) noexcept + int arb_fpwrap_cdouble_coulomb_f(complex_double * res, complex_double l, complex_double eta, complex_double x, int flags) noexcept - int arb_fpwrap_double_coulomb_g(double * res, double l, double eta, double x, int flags) - int arb_fpwrap_cdouble_coulomb_g(complex_double * res, complex_double l, complex_double eta, complex_double x, int flags) + int arb_fpwrap_double_coulomb_g(double * res, double l, double eta, double x, int flags) noexcept + int arb_fpwrap_cdouble_coulomb_g(complex_double * res, complex_double l, complex_double eta, complex_double x, int flags) noexcept - int arb_fpwrap_cdouble_coulomb_hpos(complex_double * res, complex_double l, complex_double eta, complex_double x, int flags) - int arb_fpwrap_cdouble_coulomb_hneg(complex_double * res, complex_double l, complex_double eta, complex_double x, int flags) + int arb_fpwrap_cdouble_coulomb_hpos(complex_double * res, complex_double l, complex_double eta, complex_double x, int flags) noexcept + int arb_fpwrap_cdouble_coulomb_hneg(complex_double * res, complex_double l, complex_double eta, complex_double x, int flags) noexcept - int arb_fpwrap_double_chebyshev_t(double * res, double n, double x, int flags) - int arb_fpwrap_cdouble_chebyshev_t(complex_double * res, complex_double n, complex_double x, int flags) + int arb_fpwrap_double_chebyshev_t(double * res, double n, double x, int flags) noexcept + int arb_fpwrap_cdouble_chebyshev_t(complex_double * res, complex_double n, complex_double x, int flags) noexcept - int arb_fpwrap_double_chebyshev_u(double * res, double n, double x, int flags) - int arb_fpwrap_cdouble_chebyshev_u(complex_double * res, complex_double n, complex_double x, int flags) + int arb_fpwrap_double_chebyshev_u(double * res, double n, double x, int flags) noexcept + int arb_fpwrap_cdouble_chebyshev_u(complex_double * res, complex_double n, complex_double x, int flags) noexcept - int arb_fpwrap_double_jacobi_p(double * res, double n, double a, double b, double x, int flags) - int arb_fpwrap_cdouble_jacobi_p(complex_double * res, complex_double n, complex_double a, complex_double b, complex_double x, int flags) + int arb_fpwrap_double_jacobi_p(double * res, double n, double a, double b, double x, int flags) noexcept + int arb_fpwrap_cdouble_jacobi_p(complex_double * res, complex_double n, complex_double a, complex_double b, complex_double x, int flags) noexcept - int arb_fpwrap_double_gegenbauer_c(double * res, double n, double m, double x, int flags) - int arb_fpwrap_cdouble_gegenbauer_c(complex_double * res, complex_double n, complex_double m, complex_double x, int flags) + int arb_fpwrap_double_gegenbauer_c(double * res, double n, double m, double x, int flags) noexcept + int arb_fpwrap_cdouble_gegenbauer_c(complex_double * res, complex_double n, complex_double m, complex_double x, int flags) noexcept - int arb_fpwrap_double_laguerre_l(double * res, double n, double m, double x, int flags) - int arb_fpwrap_cdouble_laguerre_l(complex_double * res, complex_double n, complex_double m, complex_double x, int flags) + int arb_fpwrap_double_laguerre_l(double * res, double n, double m, double x, int flags) noexcept + int arb_fpwrap_cdouble_laguerre_l(complex_double * res, complex_double n, complex_double m, complex_double x, int flags) noexcept - int arb_fpwrap_double_hermite_h(double * res, double n, double x, int flags) - int arb_fpwrap_cdouble_hermite_h(complex_double * res, complex_double n, complex_double x, int flags) + int arb_fpwrap_double_hermite_h(double * res, double n, double x, int flags) noexcept + int arb_fpwrap_cdouble_hermite_h(complex_double * res, complex_double n, complex_double x, int flags) noexcept - int arb_fpwrap_double_legendre_p(double * res, double n, double m, double x, int type, int flags) - int arb_fpwrap_cdouble_legendre_p(complex_double * res, complex_double n, complex_double m, complex_double x, int type, int flags) + int arb_fpwrap_double_legendre_p(double * res, double n, double m, double x, int type, int flags) noexcept + int arb_fpwrap_cdouble_legendre_p(complex_double * res, complex_double n, complex_double m, complex_double x, int type, int flags) noexcept - int arb_fpwrap_double_legendre_q(double * res, double n, double m, double x, int type, int flags) - int arb_fpwrap_cdouble_legendre_q(complex_double * res, complex_double n, complex_double m, complex_double x, int type, int flags) + int arb_fpwrap_double_legendre_q(double * res, double n, double m, double x, int type, int flags) noexcept + int arb_fpwrap_cdouble_legendre_q(complex_double * res, complex_double n, complex_double m, complex_double x, int type, int flags) noexcept - int arb_fpwrap_double_legendre_root(double * res1, double * res2, ulong n, ulong k, int flags) + int arb_fpwrap_double_legendre_root(double * res1, double * res2, ulong n, ulong k, int flags) noexcept # Sets *res1* to the index *k* root of the Legendre polynomial `P_n(x)`, # and simultaneously sets *res2* to the corresponding weight for # Gauss-Legendre quadrature. - int arb_fpwrap_cdouble_spherical_y(complex_double * res, slong n, slong m, complex_double x1, complex_double x2, int flags) + int arb_fpwrap_cdouble_spherical_y(complex_double * res, slong n, slong m, complex_double x1, complex_double x2, int flags) noexcept - int arb_fpwrap_double_hypgeom_0f1(double * res, double a, double x, int regularized, int flags) - int arb_fpwrap_cdouble_hypgeom_0f1(complex_double * res, complex_double a, complex_double x, int regularized, int flags) + int arb_fpwrap_double_hypgeom_0f1(double * res, double a, double x, int regularized, int flags) noexcept + int arb_fpwrap_cdouble_hypgeom_0f1(complex_double * res, complex_double a, complex_double x, int regularized, int flags) noexcept - int arb_fpwrap_double_hypgeom_1f1(double * res, double a, double b, double x, int regularized, int flags) - int arb_fpwrap_cdouble_hypgeom_1f1(complex_double * res, complex_double a, complex_double b, complex_double x, int regularized, int flags) + int arb_fpwrap_double_hypgeom_1f1(double * res, double a, double b, double x, int regularized, int flags) noexcept + int arb_fpwrap_cdouble_hypgeom_1f1(complex_double * res, complex_double a, complex_double b, complex_double x, int regularized, int flags) noexcept - int arb_fpwrap_double_hypgeom_u(double * res, double a, double b, double x, int flags) - int arb_fpwrap_cdouble_hypgeom_u(complex_double * res, complex_double a, complex_double b, complex_double x, int flags) + int arb_fpwrap_double_hypgeom_u(double * res, double a, double b, double x, int flags) noexcept + int arb_fpwrap_cdouble_hypgeom_u(complex_double * res, complex_double a, complex_double b, complex_double x, int flags) noexcept - int arb_fpwrap_double_hypgeom_2f1(double * res, double a, double b, double c, double x, int regularized, int flags) - int arb_fpwrap_cdouble_hypgeom_2f1(complex_double * res, complex_double a, complex_double b, complex_double c, complex_double x, int regularized, int flags) + int arb_fpwrap_double_hypgeom_2f1(double * res, double a, double b, double c, double x, int regularized, int flags) noexcept + int arb_fpwrap_cdouble_hypgeom_2f1(complex_double * res, complex_double a, complex_double b, complex_double c, complex_double x, int regularized, int flags) noexcept - int arb_fpwrap_double_hypgeom_pfq(double * res, const double * a, slong p, const double * b, slong q, double z, int regularized, int flags) - int arb_fpwrap_cdouble_hypgeom_pfq(complex_double * res, const complex_double * a, slong p, const complex_double * b, slong q, complex_double z, int regularized, int flags) + int arb_fpwrap_double_hypgeom_pfq(double * res, const double * a, slong p, const double * b, slong q, double z, int regularized, int flags) noexcept + int arb_fpwrap_cdouble_hypgeom_pfq(complex_double * res, const complex_double * a, slong p, const complex_double * b, slong q, complex_double z, int regularized, int flags) noexcept - int arb_fpwrap_double_agm(double * res, double x, double y, int flags) - int arb_fpwrap_cdouble_agm(complex_double * res, complex_double x, complex_double y, int flags) + int arb_fpwrap_double_agm(double * res, double x, double y, int flags) noexcept + int arb_fpwrap_cdouble_agm(complex_double * res, complex_double x, complex_double y, int flags) noexcept # Arithmetic-geometric mean. - int arb_fpwrap_cdouble_elliptic_k(complex_double * res, complex_double m, int flags) + int arb_fpwrap_cdouble_elliptic_k(complex_double * res, complex_double m, int flags) noexcept - int arb_fpwrap_cdouble_elliptic_e(complex_double * res, complex_double m, int flags) + int arb_fpwrap_cdouble_elliptic_e(complex_double * res, complex_double m, int flags) noexcept - int arb_fpwrap_cdouble_elliptic_pi(complex_double * res, complex_double n, complex_double m, int flags) + int arb_fpwrap_cdouble_elliptic_pi(complex_double * res, complex_double n, complex_double m, int flags) noexcept - int arb_fpwrap_cdouble_elliptic_f(complex_double * res, complex_double phi, complex_double m, int pi, int flags) + int arb_fpwrap_cdouble_elliptic_f(complex_double * res, complex_double phi, complex_double m, int pi, int flags) noexcept - int arb_fpwrap_cdouble_elliptic_e_inc(complex_double * res, complex_double phi, complex_double m, int pi, int flags) + int arb_fpwrap_cdouble_elliptic_e_inc(complex_double * res, complex_double phi, complex_double m, int pi, int flags) noexcept - int arb_fpwrap_cdouble_elliptic_pi_inc(complex_double * res, complex_double n, complex_double phi, complex_double m, int pi, int flags) + int arb_fpwrap_cdouble_elliptic_pi_inc(complex_double * res, complex_double n, complex_double phi, complex_double m, int pi, int flags) noexcept # Complete and incomplete elliptic integrals. - int arb_fpwrap_cdouble_elliptic_rf(complex_double * res, complex_double x, complex_double y, complex_double z, int option, int flags) + int arb_fpwrap_cdouble_elliptic_rf(complex_double * res, complex_double x, complex_double y, complex_double z, int option, int flags) noexcept - int arb_fpwrap_cdouble_elliptic_rg(complex_double * res, complex_double x, complex_double y, complex_double z, int option, int flags) + int arb_fpwrap_cdouble_elliptic_rg(complex_double * res, complex_double x, complex_double y, complex_double z, int option, int flags) noexcept - int arb_fpwrap_cdouble_elliptic_rj(complex_double * res, complex_double x, complex_double y, complex_double z, complex_double w, int option, int flags) + int arb_fpwrap_cdouble_elliptic_rj(complex_double * res, complex_double x, complex_double y, complex_double z, complex_double w, int option, int flags) noexcept # Carlson symmetric elliptic integrals. - int arb_fpwrap_cdouble_elliptic_p(complex_double * res, complex_double z, complex_double tau, int flags) + int arb_fpwrap_cdouble_elliptic_p(complex_double * res, complex_double z, complex_double tau, int flags) noexcept - int arb_fpwrap_cdouble_elliptic_p_prime(complex_double * res, complex_double z, complex_double tau, int flags) + int arb_fpwrap_cdouble_elliptic_p_prime(complex_double * res, complex_double z, complex_double tau, int flags) noexcept - int arb_fpwrap_cdouble_elliptic_inv_p(complex_double * res, complex_double z, complex_double tau, int flags) + int arb_fpwrap_cdouble_elliptic_inv_p(complex_double * res, complex_double z, complex_double tau, int flags) noexcept - int arb_fpwrap_cdouble_elliptic_zeta(complex_double * res, complex_double z, complex_double tau, int flags) + int arb_fpwrap_cdouble_elliptic_zeta(complex_double * res, complex_double z, complex_double tau, int flags) noexcept - int arb_fpwrap_cdouble_elliptic_sigma(complex_double * res, complex_double z, complex_double tau, int flags) + int arb_fpwrap_cdouble_elliptic_sigma(complex_double * res, complex_double z, complex_double tau, int flags) noexcept # Weierstrass elliptic functions. - int arb_fpwrap_cdouble_jacobi_theta_1(complex_double * res, complex_double z, complex_double tau, int flags) + int arb_fpwrap_cdouble_jacobi_theta_1(complex_double * res, complex_double z, complex_double tau, int flags) noexcept - int arb_fpwrap_cdouble_jacobi_theta_2(complex_double * res, complex_double z, complex_double tau, int flags) + int arb_fpwrap_cdouble_jacobi_theta_2(complex_double * res, complex_double z, complex_double tau, int flags) noexcept - int arb_fpwrap_cdouble_jacobi_theta_3(complex_double * res, complex_double z, complex_double tau, int flags) + int arb_fpwrap_cdouble_jacobi_theta_3(complex_double * res, complex_double z, complex_double tau, int flags) noexcept - int arb_fpwrap_cdouble_jacobi_theta_4(complex_double * res, complex_double z, complex_double tau, int flags) + int arb_fpwrap_cdouble_jacobi_theta_4(complex_double * res, complex_double z, complex_double tau, int flags) noexcept # Jacobi theta functions. - int arb_fpwrap_cdouble_dedekind_eta(complex_double * res, complex_double tau, int flags) + int arb_fpwrap_cdouble_dedekind_eta(complex_double * res, complex_double tau, int flags) noexcept - int arb_fpwrap_cdouble_modular_j(complex_double * res, complex_double tau, int flags) + int arb_fpwrap_cdouble_modular_j(complex_double * res, complex_double tau, int flags) noexcept - int arb_fpwrap_cdouble_modular_lambda(complex_double * res, complex_double tau, int flags) + int arb_fpwrap_cdouble_modular_lambda(complex_double * res, complex_double tau, int flags) noexcept - int arb_fpwrap_cdouble_modular_delta(complex_double * res, complex_double tau, int flags) + int arb_fpwrap_cdouble_modular_delta(complex_double * res, complex_double tau, int flags) noexcept diff --git a/src/sage/libs/flint/arb_hypgeom.pxd b/src/sage/libs/flint/arb_hypgeom.pxd index 5369f0c3997..84c37c726de 100644 --- a/src/sage/libs/flint/arb_hypgeom.pxd +++ b/src/sage/libs/flint/arb_hypgeom.pxd @@ -12,9 +12,9 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void _arb_hypgeom_rising_coeffs_1(ulong * c, ulong k, slong n) - void _arb_hypgeom_rising_coeffs_2(ulong * c, ulong k, slong n) - void _arb_hypgeom_rising_coeffs_fmpz(fmpz * c, ulong k, slong n) + void _arb_hypgeom_rising_coeffs_1(ulong * c, ulong k, slong n) noexcept + void _arb_hypgeom_rising_coeffs_2(ulong * c, ulong k, slong n) noexcept + void _arb_hypgeom_rising_coeffs_fmpz(fmpz * c, ulong k, slong n) noexcept # Sets *c* to the coefficients of the rising factorial polynomial # `(X+k)_n`. The *1* and *2* versions respectively # compute single-word and double-word coefficients, without checking for @@ -23,12 +23,12 @@ cdef extern from "flint_wrap.h": # does not use an asymptotically fast algorithm. # The degree *n* must be at least 2. - void arb_hypgeom_rising_ui_forward(arb_t res, const arb_t x, ulong n, slong prec) - void arb_hypgeom_rising_ui_bs(arb_t res, const arb_t x, ulong n, slong prec) - void arb_hypgeom_rising_ui_rs(arb_t res, const arb_t x, ulong n, ulong m, slong prec) - void arb_hypgeom_rising_ui_rec(arb_t res, const arb_t x, ulong n, slong prec) - void arb_hypgeom_rising_ui(arb_t res, const arb_t x, ulong n, slong prec) - void arb_hypgeom_rising(arb_t res, const arb_t x, const arb_t n, slong prec) + void arb_hypgeom_rising_ui_forward(arb_t res, const arb_t x, ulong n, slong prec) noexcept + void arb_hypgeom_rising_ui_bs(arb_t res, const arb_t x, ulong n, slong prec) noexcept + void arb_hypgeom_rising_ui_rs(arb_t res, const arb_t x, ulong n, ulong m, slong prec) noexcept + void arb_hypgeom_rising_ui_rec(arb_t res, const arb_t x, ulong n, slong prec) noexcept + void arb_hypgeom_rising_ui(arb_t res, const arb_t x, ulong n, slong prec) noexcept + void arb_hypgeom_rising(arb_t res, const arb_t x, const arb_t n, slong prec) noexcept # Computes the rising factorial `(x)_n`. # The *forward* version uses the forward recurrence. # The *bs* version uses binary splitting. @@ -40,10 +40,10 @@ cdef extern from "flint_wrap.h": # The default versions (*rising_ui* and *rising_ui*) choose an algorithm # automatically and may additionally fall back on the gamma function. - void arb_hypgeom_rising_ui_jet_powsum(arb_ptr res, const arb_t x, ulong n, slong len, slong prec) - void arb_hypgeom_rising_ui_jet_bs(arb_ptr res, const arb_t x, ulong n, slong len, slong prec) - void arb_hypgeom_rising_ui_jet_rs(arb_ptr res, const arb_t x, ulong n, ulong m, slong len, slong prec) - void arb_hypgeom_rising_ui_jet(arb_ptr res, const arb_t x, ulong n, slong len, slong prec) + void arb_hypgeom_rising_ui_jet_powsum(arb_ptr res, const arb_t x, ulong n, slong len, slong prec) noexcept + void arb_hypgeom_rising_ui_jet_bs(arb_ptr res, const arb_t x, ulong n, slong len, slong prec) noexcept + void arb_hypgeom_rising_ui_jet_rs(arb_ptr res, const arb_t x, ulong n, ulong m, slong len, slong prec) noexcept + void arb_hypgeom_rising_ui_jet(arb_ptr res, const arb_t x, ulong n, slong len, slong prec) noexcept # Computes the jet of the rising factorial `(x)_n`, truncated to length *len*. # In other words, constructs the polynomial `(X + x)_n \in \mathbb{R}[X]`, # truncated if `\operatorname{len} < n + 1` (and zero-extended @@ -55,14 +55,14 @@ cdef extern from "flint_wrap.h": # parameter *m* which can be set to zero to choose automatically. # The default version chooses an algorithm automatically. - void _arb_hypgeom_gamma_stirling_term_bounds(slong * bound, const mag_t zinv, slong N) + void _arb_hypgeom_gamma_stirling_term_bounds(slong * bound, const mag_t zinv, slong N) noexcept # For `1 \le n < N`, sets *bound* to an exponent bounding the *n*-th term # in the Stirling series for the gamma function, given a precomputed upper # bound for `|z|^{-1}`. This function is intended for internal use and # does not check for underflow or underflow in the exponents. - void arb_hypgeom_gamma_stirling_sum_horner(arb_t res, const arb_t z, slong N, slong prec) - void arb_hypgeom_gamma_stirling_sum_improved(arb_t res, const arb_t z, slong N, slong K, slong prec) + void arb_hypgeom_gamma_stirling_sum_horner(arb_t res, const arb_t z, slong N, slong prec) noexcept + void arb_hypgeom_gamma_stirling_sum_improved(arb_t res, const arb_t z, slong N, slong K, slong prec) noexcept # Sets *res* to the final sum in the Stirling series for the gamma function # truncated before the term with index *N*, i.e. computes # `\sum_{n=1}^{N-1} B_{2n} / (2n(2n-1) z^{2n-1})`. @@ -72,53 +72,53 @@ cdef extern from "flint_wrap.h": # using a splitting parameter *K* (which can be set to 0 to use a default # value). - void arb_hypgeom_gamma_stirling(arb_t res, const arb_t x, int reciprocal, slong prec) + void arb_hypgeom_gamma_stirling(arb_t res, const arb_t x, int reciprocal, slong prec) noexcept # Sets *res* to the gamma function of *x* computed using the Stirling # series together with argument reduction. If *reciprocal* is set, # the reciprocal gamma function is computed instead. - int arb_hypgeom_gamma_taylor(arb_t res, const arb_t x, int reciprocal, slong prec) + int arb_hypgeom_gamma_taylor(arb_t res, const arb_t x, int reciprocal, slong prec) noexcept # Attempts to compute the gamma function of *x* using Taylor series # together with argument reduction. This is only supported if *x* and *prec* # are both small enough. If successful, returns 1; otherwise, does nothing # and returns 0. If *reciprocal* is set, the reciprocal gamma function is # computed instead. - void arb_hypgeom_gamma(arb_t res, const arb_t x, slong prec) - void arb_hypgeom_gamma_fmpq(arb_t res, const fmpq_t x, slong prec) - void arb_hypgeom_gamma_fmpz(arb_t res, const fmpz_t x, slong prec) + void arb_hypgeom_gamma(arb_t res, const arb_t x, slong prec) noexcept + void arb_hypgeom_gamma_fmpq(arb_t res, const fmpq_t x, slong prec) noexcept + void arb_hypgeom_gamma_fmpz(arb_t res, const fmpz_t x, slong prec) noexcept # Sets *res* to the gamma function of *x* computed using a default # algorithm choice. - void arb_hypgeom_rgamma(arb_t res, const arb_t x, slong prec) + void arb_hypgeom_rgamma(arb_t res, const arb_t x, slong prec) noexcept # Sets *res* to the reciprocal gamma function of *x* computed using a default # algorithm choice. - void arb_hypgeom_lgamma(arb_t res, const arb_t x, slong prec) + void arb_hypgeom_lgamma(arb_t res, const arb_t x, slong prec) noexcept # Sets *res* to the log-gamma function of *x* computed using a default # algorithm choice. - void arb_hypgeom_central_bin_ui(arb_t res, ulong n, slong prec) + void arb_hypgeom_central_bin_ui(arb_t res, ulong n, slong prec) noexcept # Computes the central binomial coefficient `{2n choose n}`. - void arb_hypgeom_pfq(arb_t res, arb_srcptr a, slong p, arb_srcptr b, slong q, const arb_t z, int regularized, slong prec) + void arb_hypgeom_pfq(arb_t res, arb_srcptr a, slong p, arb_srcptr b, slong q, const arb_t z, int regularized, slong prec) noexcept # Computes the generalized hypergeometric function `{}_pF_{q}(z)`, # or the regularized version if *regularized* is set. - void arb_hypgeom_0f1(arb_t res, const arb_t a, const arb_t z, int regularized, slong prec) + void arb_hypgeom_0f1(arb_t res, const arb_t a, const arb_t z, int regularized, slong prec) noexcept # Computes the confluent hypergeometric limit function # `{}_0F_1(a,z)`, or `\frac{1}{\Gamma(a)} {}_0F_1(a,z)` if *regularized* # is set. - void arb_hypgeom_m(arb_t res, const arb_t a, const arb_t b, const arb_t z, int regularized, slong prec) + void arb_hypgeom_m(arb_t res, const arb_t a, const arb_t b, const arb_t z, int regularized, slong prec) noexcept # Computes the confluent hypergeometric function # `M(a,b,z) = {}_1F_1(a,b,z)`, or # `\mathbf{M}(a,b,z) = \frac{1}{\Gamma(b)} {}_1F_1(a,b,z)` if *regularized* is set. - void arb_hypgeom_1f1(arb_t res, const arb_t a, const arb_t b, const arb_t z, int regularized, slong prec) + void arb_hypgeom_1f1(arb_t res, const arb_t a, const arb_t b, const arb_t z, int regularized, slong prec) noexcept # Alias for :func:`arb_hypgeom_m`. - void arb_hypgeom_1f1_integration(arb_t res, const arb_t a, const arb_t b, const arb_t z, int regularized, slong prec) + void arb_hypgeom_1f1_integration(arb_t res, const arb_t a, const arb_t b, const arb_t z, int regularized, slong prec) noexcept # Computes the confluent hypergeometric function using numerical integration # of the representation # .. math :: @@ -126,10 +126,10 @@ cdef extern from "flint_wrap.h": # This algorithm can be useful if the parameters are large. This will currently # only return a finite enclosure if `a \ge 1` and `b - a \ge 1`. - void arb_hypgeom_u(arb_t res, const arb_t a, const arb_t b, const arb_t z, slong prec) + void arb_hypgeom_u(arb_t res, const arb_t a, const arb_t b, const arb_t z, slong prec) noexcept # Computes the confluent hypergeometric function `U(a,b,z)`. - void arb_hypgeom_u_integration(arb_t res, const arb_t a, const arb_t b, const arb_t z, slong prec) + void arb_hypgeom_u_integration(arb_t res, const arb_t a, const arb_t b, const arb_t z, slong prec) noexcept # Computes the confluent hypergeometric function `U(a,b,z)` using numerical integration # of the representation # .. math :: @@ -137,7 +137,7 @@ cdef extern from "flint_wrap.h": # This algorithm can be useful if the parameters are large. This will currently # only return a finite enclosure if `a \ge 1` and `z > 0`. - void arb_hypgeom_2f1(arb_t res, const arb_t a, const arb_t b, const arb_t c, const arb_t z, int regularized, slong prec) + void arb_hypgeom_2f1(arb_t res, const arb_t a, const arb_t b, const arb_t c, const arb_t z, int regularized, slong prec) noexcept # Computes the Gauss hypergeometric function # `{}_2F_1(a,b,c,z)`, or # `\mathbf{F}(a,b,c,z) = \frac{1}{\Gamma(c)} {}_2F_1(a,b,c,z)` @@ -145,7 +145,7 @@ cdef extern from "flint_wrap.h": # Additional evaluation flags can be passed via the *regularized* # argument; see :func:`acb_hypgeom_2f1` for documentation. - void arb_hypgeom_2f1_integration(arb_t res, const arb_t a, const arb_t b, const arb_t c, const arb_t z, int regularized, slong prec) + void arb_hypgeom_2f1_integration(arb_t res, const arb_t a, const arb_t b, const arb_t c, const arb_t z, int regularized, slong prec) noexcept # Computes the Gauss hypergeometric function using numerical integration # of the representation # .. math :: @@ -154,39 +154,39 @@ cdef extern from "flint_wrap.h": # only return a finite enclosure if `b \ge 1` and `c - b \ge 1` and # `z < 1`, possibly with *a* and *b* exchanged. - void arb_hypgeom_erf(arb_t res, const arb_t z, slong prec) + void arb_hypgeom_erf(arb_t res, const arb_t z, slong prec) noexcept # Computes the error function `\operatorname{erf}(z)`. - void _arb_hypgeom_erf_series(arb_ptr res, arb_srcptr z, slong zlen, slong len, slong prec) - void arb_hypgeom_erf_series(arb_poly_t res, const arb_poly_t z, slong len, slong prec) + void _arb_hypgeom_erf_series(arb_ptr res, arb_srcptr z, slong zlen, slong len, slong prec) noexcept + void arb_hypgeom_erf_series(arb_poly_t res, const arb_poly_t z, slong len, slong prec) noexcept # Computes the error function of the power series *z*, # truncated to length *len*. - void arb_hypgeom_erfc(arb_t res, const arb_t z, slong prec) + void arb_hypgeom_erfc(arb_t res, const arb_t z, slong prec) noexcept # Computes the complementary error function # `\operatorname{erfc}(z) = 1 - \operatorname{erf}(z)`. # This function avoids catastrophic cancellation for large positive *z*. - void _arb_hypgeom_erfc_series(arb_ptr res, arb_srcptr z, slong zlen, slong len, slong prec) - void arb_hypgeom_erfc_series(arb_poly_t res, const arb_poly_t z, slong len, slong prec) + void _arb_hypgeom_erfc_series(arb_ptr res, arb_srcptr z, slong zlen, slong len, slong prec) noexcept + void arb_hypgeom_erfc_series(arb_poly_t res, const arb_poly_t z, slong len, slong prec) noexcept # Computes the complementary error function of the power series *z*, # truncated to length *len*. - void arb_hypgeom_erfi(arb_t res, const arb_t z, slong prec) + void arb_hypgeom_erfi(arb_t res, const arb_t z, slong prec) noexcept # Computes the imaginary error function # `\operatorname{erfi}(z) = -i\operatorname{erf}(iz)`. - void _arb_hypgeom_erfi_series(arb_ptr res, arb_srcptr z, slong zlen, slong len, slong prec) - void arb_hypgeom_erfi_series(arb_poly_t res, const arb_poly_t z, slong len, slong prec) + void _arb_hypgeom_erfi_series(arb_ptr res, arb_srcptr z, slong zlen, slong len, slong prec) noexcept + void arb_hypgeom_erfi_series(arb_poly_t res, const arb_poly_t z, slong len, slong prec) noexcept # Computes the imaginary error function of the power series *z*, # truncated to length *len*. - void arb_hypgeom_erfinv(arb_t res, const arb_t z, slong prec) - void arb_hypgeom_erfcinv(arb_t res, const arb_t z, slong prec) + void arb_hypgeom_erfinv(arb_t res, const arb_t z, slong prec) noexcept + void arb_hypgeom_erfcinv(arb_t res, const arb_t z, slong prec) noexcept # Computes the inverse error function `\operatorname{erf}^{-1}(z)` # or inverse complementary error function `\operatorname{erfc}^{-1}(z)`. - void arb_hypgeom_fresnel(arb_t res1, arb_t res2, const arb_t z, int normalized, slong prec) + void arb_hypgeom_fresnel(arb_t res1, arb_t res2, const arb_t z, int normalized, slong prec) noexcept # Sets *res1* to the Fresnel sine integral `S(z)` and *res2* to # the Fresnel cosine integral `C(z)`. Optionally, just a single function # can be computed by passing *NULL* as the other output variable. @@ -195,14 +195,14 @@ cdef extern from "flint_wrap.h": # *normalized* is 1 (the latter is the Abramowitz & Stegun convention). # `C(z)` is defined analogously. - void _arb_hypgeom_fresnel_series(arb_ptr res1, arb_ptr res2, arb_srcptr z, slong zlen, int normalized, slong len, slong prec) - void arb_hypgeom_fresnel_series(arb_poly_t res1, arb_poly_t res2, const arb_poly_t z, int normalized, slong len, slong prec) + void _arb_hypgeom_fresnel_series(arb_ptr res1, arb_ptr res2, arb_srcptr z, slong zlen, int normalized, slong len, slong prec) noexcept + void arb_hypgeom_fresnel_series(arb_poly_t res1, arb_poly_t res2, const arb_poly_t z, int normalized, slong len, slong prec) noexcept # Sets *res1* to the Fresnel sine integral and *res2* to the Fresnel # cosine integral of the power series *z*, truncated to length *len*. # Optionally, just a single function can be computed by passing *NULL* # as the other output variable. - void arb_hypgeom_gamma_upper(arb_t res, const arb_t s, const arb_t z, int regularized, slong prec) + void arb_hypgeom_gamma_upper(arb_t res, const arb_t s, const arb_t z, int regularized, slong prec) noexcept # If *regularized* is 0, computes the upper incomplete gamma function # `\Gamma(s,z)`. # If *regularized* is 1, computes the regularized upper incomplete @@ -212,18 +212,18 @@ cdef extern from "flint_wrap.h": # intended for internal use; :func:`arb_hypgeom_expint` is the intended # interface for computing the exponential integral). - void arb_hypgeom_gamma_upper_integration(arb_t res, const arb_t s, const arb_t z, int regularized, slong prec) + void arb_hypgeom_gamma_upper_integration(arb_t res, const arb_t s, const arb_t z, int regularized, slong prec) noexcept # Computes the upper incomplete gamma function using numerical # integration. - void _arb_hypgeom_gamma_upper_series(arb_ptr res, const arb_t s, arb_srcptr z, slong zlen, int regularized, slong n, slong prec) - void arb_hypgeom_gamma_upper_series(arb_poly_t res, const arb_t s, const arb_poly_t z, int regularized, slong n, slong prec) + void _arb_hypgeom_gamma_upper_series(arb_ptr res, const arb_t s, arb_srcptr z, slong zlen, int regularized, slong n, slong prec) noexcept + void arb_hypgeom_gamma_upper_series(arb_poly_t res, const arb_t s, const arb_poly_t z, int regularized, slong n, slong prec) noexcept # Sets *res* to an upper incomplete gamma function where *s* is # a constant and *z* is a power series, truncated to length *n*. # The *regularized* argument has the same interpretation as in # :func:`arb_hypgeom_gamma_upper`. - void arb_hypgeom_gamma_lower(arb_t res, const arb_t s, const arb_t z, int regularized, slong prec) + void arb_hypgeom_gamma_lower(arb_t res, const arb_t s, const arb_t z, int regularized, slong prec) noexcept # If *regularized* is 0, computes the lower incomplete gamma function # `\gamma(s,z) = \frac{z^s}{s} {}_1F_1(s, s+1, -z)`. # If *regularized* is 1, computes the regularized lower incomplete @@ -231,167 +231,167 @@ cdef extern from "flint_wrap.h": # If *regularized* is 2, computes a further regularized lower incomplete # gamma function `\gamma^{*}(s,z) = z^{-s} P(s,z)`. - void _arb_hypgeom_gamma_lower_series(arb_ptr res, const arb_t s, arb_srcptr z, slong zlen, int regularized, slong n, slong prec) - void arb_hypgeom_gamma_lower_series(arb_poly_t res, const arb_t s, const arb_poly_t z, int regularized, slong n, slong prec) + void _arb_hypgeom_gamma_lower_series(arb_ptr res, const arb_t s, arb_srcptr z, slong zlen, int regularized, slong n, slong prec) noexcept + void arb_hypgeom_gamma_lower_series(arb_poly_t res, const arb_t s, const arb_poly_t z, int regularized, slong n, slong prec) noexcept # Sets *res* to an lower incomplete gamma function where *s* is # a constant and *z* is a power series, truncated to length *n*. # The *regularized* argument has the same interpretation as in # :func:`arb_hypgeom_gamma_lower`. - void arb_hypgeom_beta_lower(arb_t res, const arb_t a, const arb_t b, const arb_t z, int regularized, slong prec) + void arb_hypgeom_beta_lower(arb_t res, const arb_t a, const arb_t b, const arb_t z, int regularized, slong prec) noexcept # Computes the (lower) incomplete beta function, defined by # `B(a,b;z) = \int_0^z t^{a-1} (1-t)^{b-1}`, # optionally the regularized incomplete beta function # `I(a,b;z) = B(a,b;z) / B(a,b;1)`. - void _arb_hypgeom_beta_lower_series(arb_ptr res, const arb_t a, const arb_t b, arb_srcptr z, slong zlen, int regularized, slong n, slong prec) - void arb_hypgeom_beta_lower_series(arb_poly_t res, const arb_t a, const arb_t b, const arb_poly_t z, int regularized, slong n, slong prec) + void _arb_hypgeom_beta_lower_series(arb_ptr res, const arb_t a, const arb_t b, arb_srcptr z, slong zlen, int regularized, slong n, slong prec) noexcept + void arb_hypgeom_beta_lower_series(arb_poly_t res, const arb_t a, const arb_t b, const arb_poly_t z, int regularized, slong n, slong prec) noexcept # Sets *res* to the lower incomplete beta function `B(a,b;z)` (optionally # the regularized version `I(a,b;z)`) where *a* and *b* are constants # and *z* is a power series, truncating the result to length *n*. # The underscore method requires positive lengths and does not support # aliasing. - void _arb_hypgeom_gamma_lower_sum_rs_1(arb_t res, ulong p, ulong q, const arb_t z, slong N, slong prec) + void _arb_hypgeom_gamma_lower_sum_rs_1(arb_t res, ulong p, ulong q, const arb_t z, slong N, slong prec) noexcept # Computes `\sum_{k=0}^{N-1} z^k / (a)_k` where `a = p/q` using # rectangular splitting. It is assumed that `p + qN` fits in a limb. - void _arb_hypgeom_gamma_upper_sum_rs_1(arb_t res, ulong p, ulong q, const arb_t z, slong N, slong prec) + void _arb_hypgeom_gamma_upper_sum_rs_1(arb_t res, ulong p, ulong q, const arb_t z, slong N, slong prec) noexcept # Computes `\sum_{k=0}^{N-1} (a)_k / z^k` where `a = p/q` using # rectangular splitting. It is assumed that `p + qN` fits in a limb. - slong _arb_hypgeom_gamma_upper_fmpq_inf_choose_N(mag_t err, const fmpq_t a, const arb_t z, const mag_t abs_tol) + slong _arb_hypgeom_gamma_upper_fmpq_inf_choose_N(mag_t err, const fmpq_t a, const arb_t z, const mag_t abs_tol) noexcept # Returns number of terms *N* and sets *err* to the truncation error for evaluating # `\Gamma(a,z)` using the asymptotic series at infinity, targeting an absolute # tolerance of *abs_tol*. The error may be set to *err* if the tolerance # cannot be achieved. Assumes that *z* is positive. - void _arb_hypgeom_gamma_upper_fmpq_inf_bsplit(arb_t res, const fmpq_t a, const arb_t z, slong N, slong prec) + void _arb_hypgeom_gamma_upper_fmpq_inf_bsplit(arb_t res, const fmpq_t a, const arb_t z, slong N, slong prec) noexcept # Sets *res* to the approximation of `\Gamma(a,z)` obtained by truncating # the asymptotic series at infinity before term *N*. # The truncation error bound has to be added separately. - slong _arb_hypgeom_gamma_lower_fmpq_0_choose_N(mag_t err, const fmpq_t a, const arb_t z, const mag_t abs_tol) + slong _arb_hypgeom_gamma_lower_fmpq_0_choose_N(mag_t err, const fmpq_t a, const arb_t z, const mag_t abs_tol) noexcept # Returns number of terms *N* and sets *err* to the truncation error for evaluating # `\gamma(a,z)` using the Taylor series at zero, targeting an absolute # tolerance of *abs_tol*. Assumes that *z* is positive. - void _arb_hypgeom_gamma_lower_fmpq_0_bsplit(arb_t res, const fmpq_t a, const arb_t z, slong N, slong prec) + void _arb_hypgeom_gamma_lower_fmpq_0_bsplit(arb_t res, const fmpq_t a, const arb_t z, slong N, slong prec) noexcept # Sets *res* to the approximation of `\gamma(a,z)` obtained by truncating # the Taylor series at zero before term *N*. # The truncation error bound has to be added separately. - slong _arb_hypgeom_gamma_upper_singular_si_choose_N(mag_t err, slong n, const arb_t z, const mag_t abs_tol) + slong _arb_hypgeom_gamma_upper_singular_si_choose_N(mag_t err, slong n, const arb_t z, const mag_t abs_tol) noexcept # Returns number of terms *N* and sets *err* to the truncation error for evaluating # `\Gamma(-n,z)` using the Taylor series at zero, targeting an absolute # tolerance of *abs_tol*. - void _arb_hypgeom_gamma_upper_singular_si_bsplit(arb_t res, slong n, const arb_t z, slong N, slong prec) + void _arb_hypgeom_gamma_upper_singular_si_bsplit(arb_t res, slong n, const arb_t z, slong N, slong prec) noexcept # Sets *res* to the approximation of `\Gamma(-n,z)` obtained by truncating # the Taylor series at zero before term *N*. # The truncation error bound has to be added separately. - void _arb_gamma_upper_fmpq_step_bsplit(arb_t Gz1, const fmpq_t a, const arb_t z0, const arb_t z1, const arb_t Gz0, const arb_t expmz0, const mag_t abs_tol, slong prec) + void _arb_gamma_upper_fmpq_step_bsplit(arb_t Gz1, const fmpq_t a, const arb_t z0, const arb_t z1, const arb_t Gz0, const arb_t expmz0, const mag_t abs_tol, slong prec) noexcept # Given *Gz0* and *expmz0* representing the values `\Gamma(a,z_0)` and `\exp(-z_0)`, # computes `\Gamma(a,z_1)` using the Taylor series at `z_0` evaluated # using binary splitting, # targeting an absolute error of *abs_tol*. # Assumes that `z_0` and `z_1` are positive. - void arb_hypgeom_expint(arb_t res, const arb_t s, const arb_t z, slong prec) + void arb_hypgeom_expint(arb_t res, const arb_t s, const arb_t z, slong prec) noexcept # Computes the generalized exponential integral `E_s(z)`. - void arb_hypgeom_ei(arb_t res, const arb_t z, slong prec) + void arb_hypgeom_ei(arb_t res, const arb_t z, slong prec) noexcept # Computes the exponential integral `\operatorname{Ei}(z)`. - void _arb_hypgeom_ei_series(arb_ptr res, arb_srcptr z, slong zlen, slong len, slong prec) - void arb_hypgeom_ei_series(arb_poly_t res, const arb_poly_t z, slong len, slong prec) + void _arb_hypgeom_ei_series(arb_ptr res, arb_srcptr z, slong zlen, slong len, slong prec) noexcept + void arb_hypgeom_ei_series(arb_poly_t res, const arb_poly_t z, slong len, slong prec) noexcept # Computes the exponential integral of the power series *z*, # truncated to length *len*. - void _arb_hypgeom_si_asymp(arb_t res, const arb_t z, slong N, slong prec) - void _arb_hypgeom_si_1f2(arb_t res, const arb_t z, slong N, slong wp, slong prec) - void arb_hypgeom_si(arb_t res, const arb_t z, slong prec) + void _arb_hypgeom_si_asymp(arb_t res, const arb_t z, slong N, slong prec) noexcept + void _arb_hypgeom_si_1f2(arb_t res, const arb_t z, slong N, slong wp, slong prec) noexcept + void arb_hypgeom_si(arb_t res, const arb_t z, slong prec) noexcept # Computes the sine integral `\operatorname{Si}(z)`. - void _arb_hypgeom_si_series(arb_ptr res, arb_srcptr z, slong zlen, slong len, slong prec) - void arb_hypgeom_si_series(arb_poly_t res, const arb_poly_t z, slong len, slong prec) + void _arb_hypgeom_si_series(arb_ptr res, arb_srcptr z, slong zlen, slong len, slong prec) noexcept + void arb_hypgeom_si_series(arb_poly_t res, const arb_poly_t z, slong len, slong prec) noexcept # Computes the sine integral of the power series *z*, # truncated to length *len*. - void _arb_hypgeom_ci_asymp(arb_t res, const arb_t z, slong N, slong prec) - void _arb_hypgeom_ci_2f3(arb_t res, const arb_t z, slong N, slong wp, slong prec) - void arb_hypgeom_ci(arb_t res, const arb_t z, slong prec) + void _arb_hypgeom_ci_asymp(arb_t res, const arb_t z, slong N, slong prec) noexcept + void _arb_hypgeom_ci_2f3(arb_t res, const arb_t z, slong N, slong wp, slong prec) noexcept + void arb_hypgeom_ci(arb_t res, const arb_t z, slong prec) noexcept # Computes the cosine integral `\operatorname{Ci}(z)`. # The result is indeterminate if `z < 0` since the value of the function would be complex. - void _arb_hypgeom_ci_series(arb_ptr res, arb_srcptr z, slong zlen, slong len, slong prec) - void arb_hypgeom_ci_series(arb_poly_t res, const arb_poly_t z, slong len, slong prec) + void _arb_hypgeom_ci_series(arb_ptr res, arb_srcptr z, slong zlen, slong len, slong prec) noexcept + void arb_hypgeom_ci_series(arb_poly_t res, const arb_poly_t z, slong len, slong prec) noexcept # Computes the cosine integral of the power series *z*, # truncated to length *len*. - void arb_hypgeom_shi(arb_t res, const arb_t z, slong prec) + void arb_hypgeom_shi(arb_t res, const arb_t z, slong prec) noexcept # Computes the hyperbolic sine integral `\operatorname{Shi}(z) = -i \operatorname{Si}(iz)`. - void _arb_hypgeom_shi_series(arb_ptr res, arb_srcptr z, slong zlen, slong len, slong prec) - void arb_hypgeom_shi_series(arb_poly_t res, const arb_poly_t z, slong len, slong prec) + void _arb_hypgeom_shi_series(arb_ptr res, arb_srcptr z, slong zlen, slong len, slong prec) noexcept + void arb_hypgeom_shi_series(arb_poly_t res, const arb_poly_t z, slong len, slong prec) noexcept # Computes the hyperbolic sine integral of the power series *z*, # truncated to length *len*. - void arb_hypgeom_chi(arb_t res, const arb_t z, slong prec) + void arb_hypgeom_chi(arb_t res, const arb_t z, slong prec) noexcept # Computes the hyperbolic cosine integral `\operatorname{Chi}(z)`. # The result is indeterminate if `z < 0` since the value of the function would be complex. - void _arb_hypgeom_chi_series(arb_ptr res, arb_srcptr z, slong zlen, slong len, slong prec) - void arb_hypgeom_chi_series(arb_poly_t res, const arb_poly_t z, slong len, slong prec) + void _arb_hypgeom_chi_series(arb_ptr res, arb_srcptr z, slong zlen, slong len, slong prec) noexcept + void arb_hypgeom_chi_series(arb_poly_t res, const arb_poly_t z, slong len, slong prec) noexcept # Computes the hyperbolic cosine integral of the power series *z*, # truncated to length *len*. - void arb_hypgeom_li(arb_t res, const arb_t z, int offset, slong prec) + void arb_hypgeom_li(arb_t res, const arb_t z, int offset, slong prec) noexcept # If *offset* is zero, computes the logarithmic integral # `\operatorname{li}(z) = \operatorname{Ei}(\log(z))`. # If *offset* is nonzero, computes the offset logarithmic integral # `\operatorname{Li}(z) = \operatorname{li}(z) - \operatorname{li}(2)`. # The result is indeterminate if `z < 0` since the value of the function would be complex. - void _arb_hypgeom_li_series(arb_ptr res, arb_srcptr z, slong zlen, int offset, slong len, slong prec) - void arb_hypgeom_li_series(arb_poly_t res, const arb_poly_t z, int offset, slong len, slong prec) + void _arb_hypgeom_li_series(arb_ptr res, arb_srcptr z, slong zlen, int offset, slong len, slong prec) noexcept + void arb_hypgeom_li_series(arb_poly_t res, const arb_poly_t z, int offset, slong len, slong prec) noexcept # Computes the logarithmic integral (optionally the offset version) # of the power series *z*, truncated to length *len*. - void arb_hypgeom_bessel_j(arb_t res, const arb_t nu, const arb_t z, slong prec) + void arb_hypgeom_bessel_j(arb_t res, const arb_t nu, const arb_t z, slong prec) noexcept # Computes the Bessel function of the first kind `J_{\nu}(z)`. - void arb_hypgeom_bessel_y(arb_t res, const arb_t nu, const arb_t z, slong prec) + void arb_hypgeom_bessel_y(arb_t res, const arb_t nu, const arb_t z, slong prec) noexcept # Computes the Bessel function of the second kind `Y_{\nu}(z)`. - void arb_hypgeom_bessel_jy(arb_t res1, arb_t res2, const arb_t nu, const arb_t z, slong prec) + void arb_hypgeom_bessel_jy(arb_t res1, arb_t res2, const arb_t nu, const arb_t z, slong prec) noexcept # Sets *res1* to `J_{\nu}(z)` and *res2* to `Y_{\nu}(z)`, computed # simultaneously. - void arb_hypgeom_bessel_i(arb_t res, const arb_t nu, const arb_t z, slong prec) + void arb_hypgeom_bessel_i(arb_t res, const arb_t nu, const arb_t z, slong prec) noexcept # Computes the modified Bessel function of the first kind # `I_{\nu}(z) = z^{\nu} (iz)^{-\nu} J_{\nu}(iz)`. - void arb_hypgeom_bessel_i_scaled(arb_t res, const arb_t nu, const arb_t z, slong prec) + void arb_hypgeom_bessel_i_scaled(arb_t res, const arb_t nu, const arb_t z, slong prec) noexcept # Computes the function `e^{-z} I_{\nu}(z)`. - void arb_hypgeom_bessel_k(arb_t res, const arb_t nu, const arb_t z, slong prec) + void arb_hypgeom_bessel_k(arb_t res, const arb_t nu, const arb_t z, slong prec) noexcept # Computes the modified Bessel function of the second kind `K_{\nu}(z)`. - void arb_hypgeom_bessel_k_scaled(arb_t res, const arb_t nu, const arb_t z, slong prec) + void arb_hypgeom_bessel_k_scaled(arb_t res, const arb_t nu, const arb_t z, slong prec) noexcept # Computes the function `e^{z} K_{\nu}(z)`. - void arb_hypgeom_bessel_i_integration(arb_t res, const arb_t nu, const arb_t z, int scaled, slong prec) - void arb_hypgeom_bessel_k_integration(arb_t res, const arb_t nu, const arb_t z, int scaled, slong prec) + void arb_hypgeom_bessel_i_integration(arb_t res, const arb_t nu, const arb_t z, int scaled, slong prec) noexcept + void arb_hypgeom_bessel_k_integration(arb_t res, const arb_t nu, const arb_t z, int scaled, slong prec) noexcept # Computes the modified Bessel functions using numerical integration. - void arb_hypgeom_airy(arb_t ai, arb_t ai_prime, arb_t bi, arb_t bi_prime, const arb_t z, slong prec) + void arb_hypgeom_airy(arb_t ai, arb_t ai_prime, arb_t bi, arb_t bi_prime, const arb_t z, slong prec) noexcept # Computes the Airy functions `(\operatorname{Ai}(z), \operatorname{Ai}'(z), \operatorname{Bi}(z), \operatorname{Bi}'(z))` # simultaneously. Any of the four function values can be omitted by passing # *NULL* for the unwanted output variables, speeding up the evaluation. - void arb_hypgeom_airy_jet(arb_ptr ai, arb_ptr bi, const arb_t z, slong len, slong prec) + void arb_hypgeom_airy_jet(arb_ptr ai, arb_ptr bi, const arb_t z, slong len, slong prec) noexcept # Writes to *ai* and *bi* the respective Taylor expansions of the Airy functions # at the point *z*, truncated to length *len*. # Either of the outputs can be *NULL* to avoid computing that function. @@ -401,13 +401,13 @@ cdef extern from "flint_wrap.h": # easily obtained by computing one extra coefficient and differentiating # the output with :func:`_arb_poly_derivative`. - void _arb_hypgeom_airy_series(arb_ptr ai, arb_ptr ai_prime, arb_ptr bi, arb_ptr bi_prime, arb_srcptr z, slong zlen, slong len, slong prec) - void arb_hypgeom_airy_series(arb_poly_t ai, arb_poly_t ai_prime, arb_poly_t bi, arb_poly_t bi_prime, const arb_poly_t z, slong len, slong prec) + void _arb_hypgeom_airy_series(arb_ptr ai, arb_ptr ai_prime, arb_ptr bi, arb_ptr bi_prime, arb_srcptr z, slong zlen, slong len, slong prec) noexcept + void arb_hypgeom_airy_series(arb_poly_t ai, arb_poly_t ai_prime, arb_poly_t bi, arb_poly_t bi_prime, const arb_poly_t z, slong len, slong prec) noexcept # Computes the Airy functions evaluated at the power series *z*, # truncated to length *len*. As with the other Airy methods, any of the # outputs can be *NULL*. - void arb_hypgeom_airy_zero(arb_t a, arb_t a_prime, arb_t b, arb_t b_prime, const fmpz_t n, slong prec) + void arb_hypgeom_airy_zero(arb_t a, arb_t a_prime, arb_t b, arb_t b_prime, const fmpz_t n, slong prec) noexcept # Computes the *n*-th real zero `a_n`, `a'_n`, `b_n`, or `b'_n` # for the respective Airy function or Airy function derivative. # Any combination of the four output variables can be *NULL*. @@ -417,48 +417,48 @@ cdef extern from "flint_wrap.h": # The implementation uses asymptotic expansions for the zeros # [PS1991]_ together with the interval Newton method for refinement. - void arb_hypgeom_coulomb(arb_t F, arb_t G, const arb_t l, const arb_t eta, const arb_t z, slong prec) + void arb_hypgeom_coulomb(arb_t F, arb_t G, const arb_t l, const arb_t eta, const arb_t z, slong prec) noexcept # Writes to *F*, *G* the values of the respective # Coulomb wave functions `F_{\ell}(\eta,z)` and `G_{\ell}(\eta,z)`. # Either of the outputs can be *NULL*. - void arb_hypgeom_coulomb_jet(arb_ptr F, arb_ptr G, const arb_t l, const arb_t eta, const arb_t z, slong len, slong prec) + void arb_hypgeom_coulomb_jet(arb_ptr F, arb_ptr G, const arb_t l, const arb_t eta, const arb_t z, slong len, slong prec) noexcept # Writes to *F*, *G* the respective Taylor expansions of the # Coulomb wave functions at the point *z*, truncated to length *len*. # Either of the outputs can be *NULL*. - void _arb_hypgeom_coulomb_series(arb_ptr F, arb_ptr G, const arb_t l, const arb_t eta, arb_srcptr z, slong zlen, slong len, slong prec) - void arb_hypgeom_coulomb_series(arb_poly_t F, arb_poly_t G, const arb_t l, const arb_t eta, const arb_poly_t z, slong len, slong prec) + void _arb_hypgeom_coulomb_series(arb_ptr F, arb_ptr G, const arb_t l, const arb_t eta, arb_srcptr z, slong zlen, slong len, slong prec) noexcept + void arb_hypgeom_coulomb_series(arb_poly_t F, arb_poly_t G, const arb_t l, const arb_t eta, const arb_poly_t z, slong len, slong prec) noexcept # Computes the Coulomb wave functions evaluated at the power series *z*, # truncated to length *len*. Either of the outputs can be *NULL*. - void arb_hypgeom_chebyshev_t(arb_t res, const arb_t nu, const arb_t z, slong prec) - void arb_hypgeom_chebyshev_u(arb_t res, const arb_t nu, const arb_t z, slong prec) - void arb_hypgeom_jacobi_p(arb_t res, const arb_t n, const arb_t a, const arb_t b, const arb_t z, slong prec) - void arb_hypgeom_gegenbauer_c(arb_t res, const arb_t n, const arb_t m, const arb_t z, slong prec) - void arb_hypgeom_laguerre_l(arb_t res, const arb_t n, const arb_t m, const arb_t z, slong prec) - void arb_hypgeom_hermite_h(arb_t res, const arb_t nu, const arb_t z, slong prec) + void arb_hypgeom_chebyshev_t(arb_t res, const arb_t nu, const arb_t z, slong prec) noexcept + void arb_hypgeom_chebyshev_u(arb_t res, const arb_t nu, const arb_t z, slong prec) noexcept + void arb_hypgeom_jacobi_p(arb_t res, const arb_t n, const arb_t a, const arb_t b, const arb_t z, slong prec) noexcept + void arb_hypgeom_gegenbauer_c(arb_t res, const arb_t n, const arb_t m, const arb_t z, slong prec) noexcept + void arb_hypgeom_laguerre_l(arb_t res, const arb_t n, const arb_t m, const arb_t z, slong prec) noexcept + void arb_hypgeom_hermite_h(arb_t res, const arb_t nu, const arb_t z, slong prec) noexcept # Computes Chebyshev, Jacobi, Gegenbauer, Laguerre or Hermite polynomials, # or their extensions to non-integer orders. - void arb_hypgeom_legendre_p(arb_t res, const arb_t n, const arb_t m, const arb_t z, int type, slong prec) - void arb_hypgeom_legendre_q(arb_t res, const arb_t n, const arb_t m, const arb_t z, int type, slong prec) + void arb_hypgeom_legendre_p(arb_t res, const arb_t n, const arb_t m, const arb_t z, int type, slong prec) noexcept + void arb_hypgeom_legendre_q(arb_t res, const arb_t n, const arb_t m, const arb_t z, int type, slong prec) noexcept # Computes Legendre functions of the first and second kind. # See :func:`acb_hypgeom_legendre_p` and :func:`acb_hypgeom_legendre_q` # for definitions. - void arb_hypgeom_legendre_p_ui_deriv_bound(mag_t dp, mag_t dp2, ulong n, const arb_t x, const arb_t x2sub1) + void arb_hypgeom_legendre_p_ui_deriv_bound(mag_t dp, mag_t dp2, ulong n, const arb_t x, const arb_t x2sub1) noexcept # Sets *dp* to an upper bound for `P'_n(x)` and *dp2* to an upper # bound for `P''_n(x)` given *x* assumed to represent a real # number with `|x| \le 1`. The variable *x2sub1* must contain # the precomputed value `1-x^2` (or `x^2-1`). This method is used # internally to bound the propagated error for Legendre polynomials. - void arb_hypgeom_legendre_p_ui_zero(arb_t res, arb_t res_prime, ulong n, const arb_t x, slong K, slong prec) - void arb_hypgeom_legendre_p_ui_one(arb_t res, arb_t res_prime, ulong n, const arb_t x, slong K, slong prec) - void arb_hypgeom_legendre_p_ui_asymp(arb_t res, arb_t res_prime, ulong n, const arb_t x, slong K, slong prec) - void arb_hypgeom_legendre_p_ui_rec(arb_t res, arb_t res_prime, ulong n, const arb_t x, slong prec) - void arb_hypgeom_legendre_p_ui(arb_t res, arb_t res_prime, ulong n, const arb_t x, slong prec) + void arb_hypgeom_legendre_p_ui_zero(arb_t res, arb_t res_prime, ulong n, const arb_t x, slong K, slong prec) noexcept + void arb_hypgeom_legendre_p_ui_one(arb_t res, arb_t res_prime, ulong n, const arb_t x, slong K, slong prec) noexcept + void arb_hypgeom_legendre_p_ui_asymp(arb_t res, arb_t res_prime, ulong n, const arb_t x, slong K, slong prec) noexcept + void arb_hypgeom_legendre_p_ui_rec(arb_t res, arb_t res_prime, ulong n, const arb_t x, slong prec) noexcept + void arb_hypgeom_legendre_p_ui(arb_t res, arb_t res_prime, ulong n, const arb_t x, slong prec) noexcept # Evaluates the ordinary Legendre polynomial `P_n(x)`. If *res_prime* is # non-NULL, simultaneously evaluates the derivative `P'_n(x)`. # The overall algorithm is described in [JM2018]_. @@ -477,7 +477,7 @@ cdef extern from "flint_wrap.h": # and increases the working precision to compensate, bounding the # propagated error using derivative bounds. - void arb_hypgeom_legendre_p_ui_root(arb_t res, arb_t weight, ulong n, ulong k, slong prec) + void arb_hypgeom_legendre_p_ui_root(arb_t res, arb_t weight, ulong n, ulong k, slong prec) noexcept # Sets *res* to the *k*-th root of the Legendre polynomial `P_n(x)`. # We index the roots in decreasing order # .. math :: @@ -494,12 +494,12 @@ cdef extern from "flint_wrap.h": # subsequently refined using interval Newton steps with doubling working # precision. - void arb_hypgeom_dilog(arb_t res, const arb_t z, slong prec) + void arb_hypgeom_dilog(arb_t res, const arb_t z, slong prec) noexcept # Computes the dilogarithm `\operatorname{Li}_2(z)`. - void arb_hypgeom_sum_fmpq_arb_forward(arb_t res, const fmpq * a, slong alen, const fmpq * b, slong blen, const arb_t z, int reciprocal, slong N, slong prec) - void arb_hypgeom_sum_fmpq_arb_rs(arb_t res, const fmpq * a, slong alen, const fmpq * b, slong blen, const arb_t z, int reciprocal, slong N, slong prec) - void arb_hypgeom_sum_fmpq_arb(arb_t res, const fmpq * a, slong alen, const fmpq * b, slong blen, const arb_t z, int reciprocal, slong N, slong prec) + void arb_hypgeom_sum_fmpq_arb_forward(arb_t res, const fmpq * a, slong alen, const fmpq * b, slong blen, const arb_t z, int reciprocal, slong N, slong prec) noexcept + void arb_hypgeom_sum_fmpq_arb_rs(arb_t res, const fmpq * a, slong alen, const fmpq * b, slong blen, const arb_t z, int reciprocal, slong N, slong prec) noexcept + void arb_hypgeom_sum_fmpq_arb(arb_t res, const fmpq * a, slong alen, const fmpq * b, slong blen, const arb_t z, int reciprocal, slong N, slong prec) noexcept # Sets *res* to the finite hypergeometric sum # `\sum_{n=0}^{N-1} (\textbf{a})_n z^n / (\textbf{b})_n` # where `\textbf{x}_n = (x_1)_n (x_2)_n \cdots`, @@ -511,10 +511,10 @@ cdef extern from "flint_wrap.h": # uses rectangular splitting, and the default version uses # an automatic algorithm choice. - void arb_hypgeom_sum_fmpq_imag_arb_forward(arb_t res1, arb_t res2, const fmpq * a, slong alen, const fmpq * b, slong blen, const arb_t z, int reciprocal, slong N, slong prec) - void arb_hypgeom_sum_fmpq_imag_arb_rs(arb_t res1, arb_t res2, const fmpq * a, slong alen, const fmpq * b, slong blen, const arb_t z, int reciprocal, slong N, slong prec) - void arb_hypgeom_sum_fmpq_imag_arb_bs(arb_t res1, arb_t res2, const fmpq * a, slong alen, const fmpq * b, slong blen, const arb_t z, int reciprocal, slong N, slong prec) - void arb_hypgeom_sum_fmpq_imag_arb(arb_t res1, arb_t res2, const fmpq * a, slong alen, const fmpq * b, slong blen, const arb_t z, int reciprocal, slong N, slong prec) + void arb_hypgeom_sum_fmpq_imag_arb_forward(arb_t res1, arb_t res2, const fmpq * a, slong alen, const fmpq * b, slong blen, const arb_t z, int reciprocal, slong N, slong prec) noexcept + void arb_hypgeom_sum_fmpq_imag_arb_rs(arb_t res1, arb_t res2, const fmpq * a, slong alen, const fmpq * b, slong blen, const arb_t z, int reciprocal, slong N, slong prec) noexcept + void arb_hypgeom_sum_fmpq_imag_arb_bs(arb_t res1, arb_t res2, const fmpq * a, slong alen, const fmpq * b, slong blen, const arb_t z, int reciprocal, slong N, slong prec) noexcept + void arb_hypgeom_sum_fmpq_imag_arb(arb_t res1, arb_t res2, const fmpq * a, slong alen, const fmpq * b, slong blen, const arb_t z, int reciprocal, slong N, slong prec) noexcept # Sets *res1* and *res2* to the real and imaginary part of the # finite hypergeometric sum # `\sum_{n=0}^{N-1} (\textbf{a})_n (i z)^n / (\textbf{b})_n`. diff --git a/src/sage/libs/flint/arb_mat.pxd b/src/sage/libs/flint/arb_mat.pxd index 9d05facd91c..fd13b5105a3 100644 --- a/src/sage/libs/flint/arb_mat.pxd +++ b/src/sage/libs/flint/arb_mat.pxd @@ -12,112 +12,112 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void arb_mat_init(arb_mat_t mat, slong r, slong c) + void arb_mat_init(arb_mat_t mat, slong r, slong c) noexcept # Initializes the matrix, setting it to the zero matrix with *r* rows # and *c* columns. - void arb_mat_clear(arb_mat_t mat) + void arb_mat_clear(arb_mat_t mat) noexcept # Clears the matrix, deallocating all entries. - slong arb_mat_allocated_bytes(const arb_mat_t x) + slong arb_mat_allocated_bytes(const arb_mat_t x) noexcept # Returns the total number of bytes heap-allocated internally by this object. # The count excludes the size of the structure itself. Add # ``sizeof(arb_mat_struct)`` to get the size of the object as a whole. - void arb_mat_window_init(arb_mat_t window, const arb_mat_t mat, slong r1, slong c1, slong r2, slong c2) + void arb_mat_window_init(arb_mat_t window, const arb_mat_t mat, slong r1, slong c1, slong r2, slong c2) noexcept # Initializes *window* to a window matrix into the submatrix of *mat* # starting at the corner at row *r1* and column *c1* (inclusive) and ending # at row *r2* and column *c2* (exclusive). - void arb_mat_window_clear(arb_mat_t window) + void arb_mat_window_clear(arb_mat_t window) noexcept # Frees the window matrix. - void arb_mat_set(arb_mat_t dest, const arb_mat_t src) + void arb_mat_set(arb_mat_t dest, const arb_mat_t src) noexcept - void arb_mat_set_fmpz_mat(arb_mat_t dest, const fmpz_mat_t src) + void arb_mat_set_fmpz_mat(arb_mat_t dest, const fmpz_mat_t src) noexcept - void arb_mat_set_round_fmpz_mat(arb_mat_t dest, const fmpz_mat_t src, slong prec) + void arb_mat_set_round_fmpz_mat(arb_mat_t dest, const fmpz_mat_t src, slong prec) noexcept - void arb_mat_set_fmpq_mat(arb_mat_t dest, const fmpq_mat_t src, slong prec) + void arb_mat_set_fmpq_mat(arb_mat_t dest, const fmpq_mat_t src, slong prec) noexcept # Sets *dest* to *src*. The operands must have identical dimensions. - void arb_mat_randtest(arb_mat_t mat, flint_rand_t state, slong prec, slong mag_bits) + void arb_mat_randtest(arb_mat_t mat, flint_rand_t state, slong prec, slong mag_bits) noexcept # Sets *mat* to a random matrix with up to *prec* bits of precision # and with exponents of width up to *mag_bits*. - void arb_mat_printd(const arb_mat_t mat, slong digits) + void arb_mat_printd(const arb_mat_t mat, slong digits) noexcept # Prints each entry in the matrix with the specified number of decimal digits. - void arb_mat_fprintd(FILE * file, const arb_mat_t mat, slong digits) + void arb_mat_fprintd(FILE * file, const arb_mat_t mat, slong digits) noexcept # Prints each entry in the matrix with the specified number of decimal # digits to the stream *file*. - bint arb_mat_equal(const arb_mat_t mat1, const arb_mat_t mat2) + bint arb_mat_equal(const arb_mat_t mat1, const arb_mat_t mat2) noexcept # Returns whether the matrices have the same dimensions # and identical intervals as entries. - bint arb_mat_overlaps(const arb_mat_t mat1, const arb_mat_t mat2) + bint arb_mat_overlaps(const arb_mat_t mat1, const arb_mat_t mat2) noexcept # Returns whether the matrices have the same dimensions # and each entry in *mat1* overlaps with the corresponding entry in *mat2*. - bint arb_mat_contains(const arb_mat_t mat1, const arb_mat_t mat2) + bint arb_mat_contains(const arb_mat_t mat1, const arb_mat_t mat2) noexcept - bint arb_mat_contains_fmpz_mat(const arb_mat_t mat1, const fmpz_mat_t mat2) + bint arb_mat_contains_fmpz_mat(const arb_mat_t mat1, const fmpz_mat_t mat2) noexcept - bint arb_mat_contains_fmpq_mat(const arb_mat_t mat1, const fmpq_mat_t mat2) + bint arb_mat_contains_fmpq_mat(const arb_mat_t mat1, const fmpq_mat_t mat2) noexcept # Returns whether the matrices have the same dimensions and each entry # in *mat2* is contained in the corresponding entry in *mat1*. - bint arb_mat_eq(const arb_mat_t mat1, const arb_mat_t mat2) + bint arb_mat_eq(const arb_mat_t mat1, const arb_mat_t mat2) noexcept # Returns whether *mat1* and *mat2* certainly represent the same matrix. - bint arb_mat_ne(const arb_mat_t mat1, const arb_mat_t mat2) + bint arb_mat_ne(const arb_mat_t mat1, const arb_mat_t mat2) noexcept # Returns whether *mat1* and *mat2* certainly do not represent the same matrix. - bint arb_mat_is_empty(const arb_mat_t mat) + bint arb_mat_is_empty(const arb_mat_t mat) noexcept # Returns whether the number of rows or the number of columns in *mat* is zero. - bint arb_mat_is_square(const arb_mat_t mat) + bint arb_mat_is_square(const arb_mat_t mat) noexcept # Returns whether the number of rows is equal to the number of columns in *mat*. - bint arb_mat_is_exact(const arb_mat_t mat) + bint arb_mat_is_exact(const arb_mat_t mat) noexcept # Returns whether all entries in *mat* have zero radius. - bint arb_mat_is_zero(const arb_mat_t mat) + bint arb_mat_is_zero(const arb_mat_t mat) noexcept # Returns whether all entries in *mat* are exactly zero. - bint arb_mat_is_finite(const arb_mat_t mat) + bint arb_mat_is_finite(const arb_mat_t mat) noexcept # Returns whether all entries in *mat* are finite. - bint arb_mat_is_triu(const arb_mat_t mat) + bint arb_mat_is_triu(const arb_mat_t mat) noexcept # Returns whether *mat* is upper triangular; that is, all entries # below the main diagonal are exactly zero. - bint arb_mat_is_tril(const arb_mat_t mat) + bint arb_mat_is_tril(const arb_mat_t mat) noexcept # Returns whether *mat* is lower triangular; that is, all entries # above the main diagonal are exactly zero. - bint arb_mat_is_diag(const arb_mat_t mat) + bint arb_mat_is_diag(const arb_mat_t mat) noexcept # Returns whether *mat* is a diagonal matrix; that is, all entries # off the main diagonal are exactly zero. - void arb_mat_zero(arb_mat_t mat) + void arb_mat_zero(arb_mat_t mat) noexcept # Sets all entries in mat to zero. - void arb_mat_one(arb_mat_t mat) + void arb_mat_one(arb_mat_t mat) noexcept # Sets the entries on the main diagonal to ones, # and all other entries to zero. - void arb_mat_ones(arb_mat_t mat) + void arb_mat_ones(arb_mat_t mat) noexcept # Sets all entries in the matrix to ones. - void arb_mat_indeterminate(arb_mat_t mat) + void arb_mat_indeterminate(arb_mat_t mat) noexcept # Sets all entries in the matrix to indeterminate (NaN). - void arb_mat_hilbert(arb_mat_t mat, slong prec) + void arb_mat_hilbert(arb_mat_t mat, slong prec) noexcept # Sets *mat* to the Hilbert matrix, which has entries `A_{j,k} = 1/(j+k+1)`. - void arb_mat_pascal(arb_mat_t mat, int triangular, slong prec) + void arb_mat_pascal(arb_mat_t mat, int triangular, slong prec) noexcept # Sets *mat* to a Pascal matrix, whose entries are binomial coefficients. # If *triangular* is 0, constructs a full symmetric matrix # with the rows of Pascal's triangle as successive antidiagonals. @@ -130,7 +130,7 @@ cdef extern from "flint_wrap.h": # case, the user may wish to create the matrix at slightly higher precision # and then round it to the final precision. - void arb_mat_stirling(arb_mat_t mat, int kind, slong prec) + void arb_mat_stirling(arb_mat_t mat, int kind, slong prec) noexcept # Sets *mat* to a Stirling matrix, whose entries are Stirling numbers. # If *kind* is 0, the entries are set to the unsigned Stirling numbers # of the first kind. If *kind* is 1, the entries are set to the signed @@ -141,7 +141,7 @@ cdef extern from "flint_wrap.h": # case, the user may wish to create the matrix at slightly higher precision # and then round it to the final precision. - void arb_mat_dct(arb_mat_t mat, int type, slong prec) + void arb_mat_dct(arb_mat_t mat, int type, slong prec) noexcept # Sets *mat* to the DCT (discrete cosine transform) matrix of order *n* # where *n* is the smallest dimension of *mat* (if *mat* is not square, # the matrix is extended periodically along the larger dimension). @@ -153,39 +153,39 @@ cdef extern from "flint_wrap.h": # The *type* parameter is currently ignored and should be set to 0. # In the future, it might be used to select a different convention. - void arb_mat_transpose(arb_mat_t dest, const arb_mat_t src) + void arb_mat_transpose(arb_mat_t dest, const arb_mat_t src) noexcept # Sets *dest* to the exact transpose *src*. The operands must have # compatible dimensions. Aliasing is allowed. - void arb_mat_bound_inf_norm(mag_t b, const arb_mat_t A) + void arb_mat_bound_inf_norm(mag_t b, const arb_mat_t A) noexcept # Sets *b* to an upper bound for the infinity norm (i.e. the largest # absolute value row sum) of *A*. - void arb_mat_frobenius_norm(arb_t res, const arb_mat_t A, slong prec) + void arb_mat_frobenius_norm(arb_t res, const arb_mat_t A, slong prec) noexcept # Sets *res* to the Frobenius norm (i.e. the square root of the sum # of squares of entries) of *A*. - void arb_mat_bound_frobenius_norm(mag_t res, const arb_mat_t A) + void arb_mat_bound_frobenius_norm(mag_t res, const arb_mat_t A) noexcept # Sets *res* to an upper bound for the Frobenius norm of *A*. - void arb_mat_neg(arb_mat_t dest, const arb_mat_t src) + void arb_mat_neg(arb_mat_t dest, const arb_mat_t src) noexcept # Sets *dest* to the exact negation of *src*. The operands must have # the same dimensions. - void arb_mat_add(arb_mat_t res, const arb_mat_t mat1, const arb_mat_t mat2, slong prec) + void arb_mat_add(arb_mat_t res, const arb_mat_t mat1, const arb_mat_t mat2, slong prec) noexcept # Sets res to the sum of *mat1* and *mat2*. The operands must have the same dimensions. - void arb_mat_sub(arb_mat_t res, const arb_mat_t mat1, const arb_mat_t mat2, slong prec) + void arb_mat_sub(arb_mat_t res, const arb_mat_t mat1, const arb_mat_t mat2, slong prec) noexcept # Sets *res* to the difference of *mat1* and *mat2*. The operands must have # the same dimensions. - void arb_mat_mul_classical(arb_mat_t C, const arb_mat_t A, const arb_mat_t B, slong prec) + void arb_mat_mul_classical(arb_mat_t C, const arb_mat_t A, const arb_mat_t B, slong prec) noexcept - void arb_mat_mul_threaded(arb_mat_t C, const arb_mat_t A, const arb_mat_t B, slong prec) + void arb_mat_mul_threaded(arb_mat_t C, const arb_mat_t A, const arb_mat_t B, slong prec) noexcept - void arb_mat_mul_block(arb_mat_t C, const arb_mat_t A, const arb_mat_t B, slong prec) + void arb_mat_mul_block(arb_mat_t C, const arb_mat_t A, const arb_mat_t B, slong prec) noexcept - void arb_mat_mul(arb_mat_t res, const arb_mat_t mat1, const arb_mat_t mat2, slong prec) + void arb_mat_mul(arb_mat_t res, const arb_mat_t mat1, const arb_mat_t mat2, slong prec) noexcept # Sets *res* to the matrix product of *mat1* and *mat2*. The operands must have # compatible dimensions for matrix multiplication. # The *classical* version performs matrix multiplication in the trivial way. @@ -197,19 +197,19 @@ cdef extern from "flint_wrap.h": # computation over the number of threads returned by *flint_get_num_threads()*. # The default version chooses an algorithm automatically. - void arb_mat_mul_entrywise(arb_mat_t C, const arb_mat_t A, const arb_mat_t B, slong prec) + void arb_mat_mul_entrywise(arb_mat_t C, const arb_mat_t A, const arb_mat_t B, slong prec) noexcept # Sets *C* to the entrywise product of *A* and *B*. # The operands must have the same dimensions. - void arb_mat_sqr_classical(arb_mat_t B, const arb_mat_t A, slong prec) + void arb_mat_sqr_classical(arb_mat_t B, const arb_mat_t A, slong prec) noexcept - void arb_mat_sqr(arb_mat_t res, const arb_mat_t mat, slong prec) + void arb_mat_sqr(arb_mat_t res, const arb_mat_t mat, slong prec) noexcept - void arb_mat_pow_ui(arb_mat_t res, const arb_mat_t mat, ulong exp, slong prec) + void arb_mat_pow_ui(arb_mat_t res, const arb_mat_t mat, ulong exp, slong prec) noexcept # Sets *res* to *mat* raised to the power *exp*. Requires that *mat* # is a square matrix. - void _arb_mat_addmul_rad_mag_fast(arb_mat_t C, mag_srcptr A, mag_srcptr B, slong ar, slong ac, slong bc) + void _arb_mat_addmul_rad_mag_fast(arb_mat_t C, mag_srcptr A, mag_srcptr B, slong ar, slong ac, slong bc) noexcept # Helper function for matrix multiplication. # Adds to the radii of *C* the matrix product of the matrices represented # by *A* and *B*, where *A* is a linear array of coefficients in row-major @@ -217,40 +217,40 @@ cdef extern from "flint_wrap.h": # This function assumes that all exponents are small and is unsafe # for general use. - void arb_mat_approx_mul(arb_mat_t res, const arb_mat_t mat1, const arb_mat_t mat2, slong prec) + void arb_mat_approx_mul(arb_mat_t res, const arb_mat_t mat1, const arb_mat_t mat2, slong prec) noexcept # Approximate matrix multiplication. The input radii are ignored and # the output matrix is set to an approximate floating-point result. # The radii in the output matrix will *not* necessarily be zeroed. - void arb_mat_scalar_mul_2exp_si(arb_mat_t B, const arb_mat_t A, slong c) + void arb_mat_scalar_mul_2exp_si(arb_mat_t B, const arb_mat_t A, slong c) noexcept # Sets *B* to *A* multiplied by `2^c`. - void arb_mat_scalar_addmul_si(arb_mat_t B, const arb_mat_t A, slong c, slong prec) + void arb_mat_scalar_addmul_si(arb_mat_t B, const arb_mat_t A, slong c, slong prec) noexcept - void arb_mat_scalar_addmul_fmpz(arb_mat_t B, const arb_mat_t A, const fmpz_t c, slong prec) + void arb_mat_scalar_addmul_fmpz(arb_mat_t B, const arb_mat_t A, const fmpz_t c, slong prec) noexcept - void arb_mat_scalar_addmul_arb(arb_mat_t B, const arb_mat_t A, const arb_t c, slong prec) + void arb_mat_scalar_addmul_arb(arb_mat_t B, const arb_mat_t A, const arb_t c, slong prec) noexcept # Sets *B* to `B + A \times c`. - void arb_mat_scalar_mul_si(arb_mat_t B, const arb_mat_t A, slong c, slong prec) + void arb_mat_scalar_mul_si(arb_mat_t B, const arb_mat_t A, slong c, slong prec) noexcept - void arb_mat_scalar_mul_fmpz(arb_mat_t B, const arb_mat_t A, const fmpz_t c, slong prec) + void arb_mat_scalar_mul_fmpz(arb_mat_t B, const arb_mat_t A, const fmpz_t c, slong prec) noexcept - void arb_mat_scalar_mul_arb(arb_mat_t B, const arb_mat_t A, const arb_t c, slong prec) + void arb_mat_scalar_mul_arb(arb_mat_t B, const arb_mat_t A, const arb_t c, slong prec) noexcept # Sets *B* to `A \times c`. - void arb_mat_scalar_div_si(arb_mat_t B, const arb_mat_t A, slong c, slong prec) + void arb_mat_scalar_div_si(arb_mat_t B, const arb_mat_t A, slong c, slong prec) noexcept - void arb_mat_scalar_div_fmpz(arb_mat_t B, const arb_mat_t A, const fmpz_t c, slong prec) + void arb_mat_scalar_div_fmpz(arb_mat_t B, const arb_mat_t A, const fmpz_t c, slong prec) noexcept - void arb_mat_scalar_div_arb(arb_mat_t B, const arb_mat_t A, const arb_t c, slong prec) + void arb_mat_scalar_div_arb(arb_mat_t B, const arb_mat_t A, const arb_t c, slong prec) noexcept # Sets *B* to `A / c`. - int arb_mat_lu_classical(slong * perm, arb_mat_t LU, const arb_mat_t A, slong prec) + int arb_mat_lu_classical(slong * perm, arb_mat_t LU, const arb_mat_t A, slong prec) noexcept - int arb_mat_lu_recursive(slong * perm, arb_mat_t LU, const arb_mat_t A, slong prec) + int arb_mat_lu_recursive(slong * perm, arb_mat_t LU, const arb_mat_t A, slong prec) noexcept - int arb_mat_lu(slong * perm, arb_mat_t LU, const arb_mat_t A, slong prec) + int arb_mat_lu(slong * perm, arb_mat_t LU, const arb_mat_t A, slong prec) noexcept # Given an `n \times n` matrix `A`, computes an LU decomposition `PLU = A` # using Gaussian elimination with partial pivoting. # The input and output matrices can be the same, performing the @@ -270,17 +270,17 @@ cdef extern from "flint_wrap.h": # way to benefit from fast matrix multiplication. The default version # chooses an algorithm automatically. - void arb_mat_solve_tril_classical(arb_mat_t X, const arb_mat_t L, const arb_mat_t B, int unit, slong prec) + void arb_mat_solve_tril_classical(arb_mat_t X, const arb_mat_t L, const arb_mat_t B, int unit, slong prec) noexcept - void arb_mat_solve_tril_recursive(arb_mat_t X, const arb_mat_t L, const arb_mat_t B, int unit, slong prec) + void arb_mat_solve_tril_recursive(arb_mat_t X, const arb_mat_t L, const arb_mat_t B, int unit, slong prec) noexcept - void arb_mat_solve_tril(arb_mat_t X, const arb_mat_t L, const arb_mat_t B, int unit, slong prec) + void arb_mat_solve_tril(arb_mat_t X, const arb_mat_t L, const arb_mat_t B, int unit, slong prec) noexcept - void arb_mat_solve_triu_classical(arb_mat_t X, const arb_mat_t U, const arb_mat_t B, int unit, slong prec) + void arb_mat_solve_triu_classical(arb_mat_t X, const arb_mat_t U, const arb_mat_t B, int unit, slong prec) noexcept - void arb_mat_solve_triu_recursive(arb_mat_t X, const arb_mat_t U, const arb_mat_t B, int unit, slong prec) + void arb_mat_solve_triu_recursive(arb_mat_t X, const arb_mat_t U, const arb_mat_t B, int unit, slong prec) noexcept - void arb_mat_solve_triu(arb_mat_t X, const arb_mat_t U, const arb_mat_t B, int unit, slong prec) + void arb_mat_solve_triu(arb_mat_t X, const arb_mat_t U, const arb_mat_t B, int unit, slong prec) noexcept # Solves the lower triangular system `LX = B` or the upper triangular system # `UX = B`, respectively. If *unit* is set, the main diagonal of *L* or *U* # is taken to consist of all ones, and in that case the actual entries on @@ -290,16 +290,16 @@ cdef extern from "flint_wrap.h": # way to benefit from fast matrix multiplication. The default versions # choose an algorithm automatically. - void arb_mat_solve_lu_precomp(arb_mat_t X, const slong * perm, const arb_mat_t LU, const arb_mat_t B, slong prec) + void arb_mat_solve_lu_precomp(arb_mat_t X, const slong * perm, const arb_mat_t LU, const arb_mat_t B, slong prec) noexcept # Solves `AX = B` given the precomputed nonsingular LU decomposition `A = PLU`. # The matrices `X` and `B` are allowed to be aliased with each other, # but `X` is not allowed to be aliased with `LU`. - int arb_mat_solve(arb_mat_t X, const arb_mat_t A, const arb_mat_t B, slong prec) + int arb_mat_solve(arb_mat_t X, const arb_mat_t A, const arb_mat_t B, slong prec) noexcept - int arb_mat_solve_lu(arb_mat_t X, const arb_mat_t A, const arb_mat_t B, slong prec) + int arb_mat_solve_lu(arb_mat_t X, const arb_mat_t A, const arb_mat_t B, slong prec) noexcept - int arb_mat_solve_precond(arb_mat_t X, const arb_mat_t A, const arb_mat_t B, slong prec) + int arb_mat_solve_precond(arb_mat_t X, const arb_mat_t A, const arb_mat_t B, slong prec) noexcept # Solves `AX = B` where `A` is a nonsingular `n \times n` matrix # and `X` and `B` are `n \times m` matrices. # If `m > 0` and `A` cannot be inverted numerically (indicating either that @@ -323,7 +323,7 @@ cdef extern from "flint_wrap.h": # For example, the *lu* solver often performs better for ill-conditioned # systems where use of very high precision is unavoidable. - int arb_mat_solve_preapprox(arb_mat_t X, const arb_mat_t A, const arb_mat_t B, const arb_mat_t R, const arb_mat_t T, slong prec) + int arb_mat_solve_preapprox(arb_mat_t X, const arb_mat_t A, const arb_mat_t B, const arb_mat_t R, const arb_mat_t T, slong prec) noexcept # Solves `AX = B` where `A` is a nonsingular `n \times n` matrix # and `X` and `B` are `n \times m` matrices, given an approximation # `R` of the matrix inverse of `A`, and given the approximation `T` @@ -335,7 +335,7 @@ cdef extern from "flint_wrap.h": # value guarantees that `A` is invertible and that the exact solution # matrix is contained in the output. - int arb_mat_inv(arb_mat_t X, const arb_mat_t A, slong prec) + int arb_mat_inv(arb_mat_t X, const arb_mat_t A, slong prec) noexcept # Sets `X = A^{-1}` where `A` is a square matrix, computed by solving # the system `AX = I`. # If `A` cannot be inverted numerically (indicating either that @@ -344,11 +344,11 @@ cdef extern from "flint_wrap.h": # A nonzero return value guarantees that the matrix is invertible # and that the exact inverse is contained in the output. - void arb_mat_det_lu(arb_t det, const arb_mat_t A, slong prec) + void arb_mat_det_lu(arb_t det, const arb_mat_t A, slong prec) noexcept - void arb_mat_det_precond(arb_t det, const arb_mat_t A, slong prec) + void arb_mat_det_precond(arb_t det, const arb_mat_t A, slong prec) noexcept - void arb_mat_det(arb_t det, const arb_mat_t A, slong prec) + void arb_mat_det(arb_t det, const arb_mat_t A, slong prec) noexcept # Sets *det* to the determinant of the matrix *A*. # The *lu* version uses Gaussian elimination with partial pivoting. If at # some point an invertible pivot element cannot be found, the elimination is @@ -364,17 +364,17 @@ cdef extern from "flint_wrap.h": # versions and additionally handles small or triangular matrices # by direct formulas. - void arb_mat_approx_solve_triu(arb_mat_t X, const arb_mat_t U, const arb_mat_t B, int unit, slong prec) + void arb_mat_approx_solve_triu(arb_mat_t X, const arb_mat_t U, const arb_mat_t B, int unit, slong prec) noexcept - void arb_mat_approx_solve_tril(arb_mat_t X, const arb_mat_t L, const arb_mat_t B, int unit, slong prec) + void arb_mat_approx_solve_tril(arb_mat_t X, const arb_mat_t L, const arb_mat_t B, int unit, slong prec) noexcept - int arb_mat_approx_lu(slong * P, arb_mat_t LU, const arb_mat_t A, slong prec) + int arb_mat_approx_lu(slong * P, arb_mat_t LU, const arb_mat_t A, slong prec) noexcept - void arb_mat_approx_solve_lu_precomp(arb_mat_t X, const slong * perm, const arb_mat_t A, const arb_mat_t B, slong prec) + void arb_mat_approx_solve_lu_precomp(arb_mat_t X, const slong * perm, const arb_mat_t A, const arb_mat_t B, slong prec) noexcept - int arb_mat_approx_solve(arb_mat_t X, const arb_mat_t A, const arb_mat_t B, slong prec) + int arb_mat_approx_solve(arb_mat_t X, const arb_mat_t A, const arb_mat_t B, slong prec) noexcept - int arb_mat_approx_inv(arb_mat_t X, const arb_mat_t A, slong prec) + int arb_mat_approx_inv(arb_mat_t X, const arb_mat_t A, slong prec) noexcept # These methods perform approximate solving *without any error control*. # The radii in the input matrices are ignored, the computations are done # numerically with floating-point arithmetic (using ordinary @@ -387,9 +387,9 @@ cdef extern from "flint_wrap.h": # for doing ordinary numerical linear algebra in applications where # error bounds are not needed. - int _arb_mat_cholesky_banachiewicz(arb_mat_t A, slong prec) + int _arb_mat_cholesky_banachiewicz(arb_mat_t A, slong prec) noexcept - int arb_mat_cho(arb_mat_t L, const arb_mat_t A, slong prec) + int arb_mat_cho(arb_mat_t L, const arb_mat_t A, slong prec) noexcept # Computes the Cholesky decomposition of *A*, returning nonzero iff # the symmetric matrix defined by the lower triangular part of *A* # is certainly positive definite. @@ -401,12 +401,12 @@ cdef extern from "flint_wrap.h": # The underscore method computes *L* from *A* in-place, leaving the # strict upper triangular region undefined. - void arb_mat_solve_cho_precomp(arb_mat_t X, const arb_mat_t L, const arb_mat_t B, slong prec) + void arb_mat_solve_cho_precomp(arb_mat_t X, const arb_mat_t L, const arb_mat_t B, slong prec) noexcept # Solves `AX = B` given the precomputed Cholesky decomposition `A = L L^T`. # The matrices *X* and *B* are allowed to be aliased with each other, # but *X* is not allowed to be aliased with *L*. - int arb_mat_spd_solve(arb_mat_t X, const arb_mat_t A, const arb_mat_t B, slong prec) + int arb_mat_spd_solve(arb_mat_t X, const arb_mat_t A, const arb_mat_t B, slong prec) noexcept # Solves `AX = B` where *A* is a symmetric positive definite matrix # and *X* and *B* are `n \times m` matrices, using Cholesky decomposition. # If `m > 0` and *A* cannot be factored using Cholesky decomposition @@ -417,14 +417,14 @@ cdef extern from "flint_wrap.h": # triangular part of *A* is invertible and that the exact solution matrix # is contained in the output. - void arb_mat_inv_cho_precomp(arb_mat_t X, const arb_mat_t L, slong prec) + void arb_mat_inv_cho_precomp(arb_mat_t X, const arb_mat_t L, slong prec) noexcept # Sets `X = A^{-1}` where `A` is a symmetric positive definite matrix # whose Cholesky decomposition *L* has been computed with # :func:`arb_mat_cho`. # The inverse is calculated using the method of [Kri2013]_ which is more # efficient than solving `AX = I` with :func:`arb_mat_solve_cho_precomp`. - int arb_mat_spd_inv(arb_mat_t X, const arb_mat_t A, slong prec) + int arb_mat_spd_inv(arb_mat_t X, const arb_mat_t A, slong prec) noexcept # Sets `X = A^{-1}` where *A* is a symmetric positive definite matrix. # It is calculated using the method of [Kri2013]_ which computes fewer # intermediate results than solving `AX = I` with :func:`arb_mat_spd_solve`. @@ -436,11 +436,11 @@ cdef extern from "flint_wrap.h": # triangular part of *A* is invertible and that the exact inverse # is contained in the output. - int _arb_mat_ldl_inplace(arb_mat_t A, slong prec) + int _arb_mat_ldl_inplace(arb_mat_t A, slong prec) noexcept - int _arb_mat_ldl_golub_and_van_loan(arb_mat_t A, slong prec) + int _arb_mat_ldl_golub_and_van_loan(arb_mat_t A, slong prec) noexcept - int arb_mat_ldl(arb_mat_t res, const arb_mat_t A, slong prec) + int arb_mat_ldl(arb_mat_t res, const arb_mat_t A, slong prec) noexcept # Computes the `LDL^T` decomposition of *A*, returning nonzero iff # the symmetric matrix defined by the lower triangular part of *A* # is certainly positive definite. @@ -456,34 +456,34 @@ cdef extern from "flint_wrap.h": # strict upper triangular region undefined. # The default method uses algorithm 4.1.2 from [GVL1996]_. - void arb_mat_solve_ldl_precomp(arb_mat_t X, const arb_mat_t L, const arb_mat_t B, slong prec) + void arb_mat_solve_ldl_precomp(arb_mat_t X, const arb_mat_t L, const arb_mat_t B, slong prec) noexcept # Solves `AX = B` given the precomputed `A = LDL^T` decomposition # encoded by *L*. The matrices *X* and *B* are allowed to be aliased # with each other, but *X* is not allowed to be aliased with *L*. - void arb_mat_inv_ldl_precomp(arb_mat_t X, const arb_mat_t L, slong prec) + void arb_mat_inv_ldl_precomp(arb_mat_t X, const arb_mat_t L, slong prec) noexcept # Sets `X = A^{-1}` where `A` is a symmetric positive definite matrix # whose `LDL^T` decomposition encoded by *L* has been computed with # :func:`arb_mat_ldl`. # The inverse is calculated using the method of [Kri2013]_ which is more # efficient than solving `AX = I` with :func:`arb_mat_solve_ldl_precomp`. - void _arb_mat_charpoly(arb_ptr poly, const arb_mat_t mat, slong prec) + void _arb_mat_charpoly(arb_ptr poly, const arb_mat_t mat, slong prec) noexcept - void arb_mat_charpoly(arb_poly_t poly, const arb_mat_t mat, slong prec) + void arb_mat_charpoly(arb_poly_t poly, const arb_mat_t mat, slong prec) noexcept # Sets *poly* to the characteristic polynomial of *mat* which must be # a square matrix. If the matrix has *n* rows, the underscore method # requires space for `n + 1` output coefficients. # Employs a division-free algorithm using `O(n^4)` operations. - void _arb_mat_companion(arb_mat_t mat, arb_srcptr poly, slong prec) + void _arb_mat_companion(arb_mat_t mat, arb_srcptr poly, slong prec) noexcept - void arb_mat_companion(arb_mat_t mat, const arb_poly_t poly, slong prec) + void arb_mat_companion(arb_mat_t mat, const arb_poly_t poly, slong prec) noexcept # Sets the *n* by *n* matrix *mat* to the companion matrix of the polynomial # *poly* which must have degree *n*. # The underscore method reads `n + 1` input coefficients. - void arb_mat_exp_taylor_sum(arb_mat_t S, const arb_mat_t A, slong N, slong prec) + void arb_mat_exp_taylor_sum(arb_mat_t S, const arb_mat_t A, slong N, slong prec) noexcept # Sets *S* to the truncated exponential Taylor series `S = \sum_{k=0}^{N-1} A^k / k!`. # Uses rectangular splitting to compute the sum using `O(\sqrt{N})` # matrix multiplications. The recurrence relation for factorials @@ -493,7 +493,7 @@ cdef extern from "flint_wrap.h": # The scalars could be reduced by doing more divisions, but this # appears to be slower in most cases. - void arb_mat_exp(arb_mat_t B, const arb_mat_t A, slong prec) + void arb_mat_exp(arb_mat_t B, const arb_mat_t A, slong prec) noexcept # Sets *B* to the exponential of the matrix *A*, defined by the Taylor series # .. math :: # \exp(A) = \sum_{k=0}^{\infty} \frac{A^k}{k!}. @@ -510,40 +510,40 @@ cdef extern from "flint_wrap.h": # Truncation error is not added to entries whose values are determined # by the sparsity structure of `A`. - void arb_mat_trace(arb_t trace, const arb_mat_t mat, slong prec) + void arb_mat_trace(arb_t trace, const arb_mat_t mat, slong prec) noexcept # Sets *trace* to the trace of the matrix, i.e. the sum of entries on the # main diagonal of *mat*. The matrix is required to be square. - void _arb_mat_diag_prod(arb_t res, const arb_mat_t mat, slong a, slong b, slong prec) + void _arb_mat_diag_prod(arb_t res, const arb_mat_t mat, slong a, slong b, slong prec) noexcept - void arb_mat_diag_prod(arb_t res, const arb_mat_t mat, slong prec) + void arb_mat_diag_prod(arb_t res, const arb_mat_t mat, slong prec) noexcept # Sets *res* to the product of the entries on the main diagonal of *mat*. # The underscore method computes the product of the entries between # index *a* inclusive and *b* exclusive (the indices must be in range). - void arb_mat_entrywise_is_zero(fmpz_mat_t dest, const arb_mat_t src) + void arb_mat_entrywise_is_zero(fmpz_mat_t dest, const arb_mat_t src) noexcept # Sets each entry of *dest* to indicate whether the corresponding # entry of *src* is certainly zero. # If the entry of *src* at row `i` and column `j` is zero according to # :func:`arb_is_zero` then the entry of *dest* at that row and column # is set to one, otherwise that entry of *dest* is set to zero. - void arb_mat_entrywise_not_is_zero(fmpz_mat_t dest, const arb_mat_t src) + void arb_mat_entrywise_not_is_zero(fmpz_mat_t dest, const arb_mat_t src) noexcept # Sets each entry of *dest* to indicate whether the corresponding # entry of *src* is not certainly zero. # This the complement of :func:`arb_mat_entrywise_is_zero`. - slong arb_mat_count_is_zero(const arb_mat_t mat) + slong arb_mat_count_is_zero(const arb_mat_t mat) noexcept # Returns the number of entries of *mat* that are certainly zero # according to :func:`arb_is_zero`. - slong arb_mat_count_not_is_zero(const arb_mat_t mat) + slong arb_mat_count_not_is_zero(const arb_mat_t mat) noexcept # Returns the number of entries of *mat* that are not certainly zero. - void arb_mat_get_mid(arb_mat_t B, const arb_mat_t A) + void arb_mat_get_mid(arb_mat_t B, const arb_mat_t A) noexcept # Sets the entries of *B* to the exact midpoints of the entries of *A*. - void arb_mat_add_error_mag(arb_mat_t mat, const mag_t err) + void arb_mat_add_error_mag(arb_mat_t mat, const mag_t err) noexcept # Adds *err* in-place to the radii of the entries of *mat*. from .arb_mat_macros cimport * diff --git a/src/sage/libs/flint/arb_poly.pxd b/src/sage/libs/flint/arb_poly.pxd index 4b1c5150948..20f4fdc0d80 100644 --- a/src/sage/libs/flint/arb_poly.pxd +++ b/src/sage/libs/flint/arb_poly.pxd @@ -12,35 +12,35 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void arb_poly_init(arb_poly_t poly) + void arb_poly_init(arb_poly_t poly) noexcept # Initializes the polynomial for use, setting it to the zero polynomial. - void arb_poly_clear(arb_poly_t poly) + void arb_poly_clear(arb_poly_t poly) noexcept # Clears the polynomial, deallocating all coefficients and the # coefficient array. - void arb_poly_fit_length(arb_poly_t poly, slong len) + void arb_poly_fit_length(arb_poly_t poly, slong len) noexcept # Makes sure that the coefficient array of the polynomial contains at # least *len* initialized coefficients. - void _arb_poly_set_length(arb_poly_t poly, slong len) + void _arb_poly_set_length(arb_poly_t poly, slong len) noexcept # Directly changes the length of the polynomial, without allocating or # deallocating coefficients. The value should not exceed the allocation length. - void _arb_poly_normalise(arb_poly_t poly) + void _arb_poly_normalise(arb_poly_t poly) noexcept # Strips any trailing coefficients which are identical to zero. - slong arb_poly_allocated_bytes(const arb_poly_t x) + slong arb_poly_allocated_bytes(const arb_poly_t x) noexcept # Returns the total number of bytes heap-allocated internally by this object. # The count excludes the size of the structure itself. Add # ``sizeof(arb_poly_struct)`` to get the size of the object as a whole. - slong arb_poly_length(const arb_poly_t poly) + slong arb_poly_length(const arb_poly_t poly) noexcept # Returns the length of *poly*, i.e. zero if *poly* is # identically zero, and otherwise one more than the index # of the highest term that is not identically zero. - slong arb_poly_degree(const arb_poly_t poly) + slong arb_poly_degree(const arb_poly_t poly) noexcept # Returns the degree of *poly*, defined as one less than its length. # Note that if one or several leading coefficients are balls # containing zero, this value can be larger than the true @@ -48,146 +48,146 @@ cdef extern from "flint_wrap.h": # so the return value of this function is effectively # an upper bound. - bint arb_poly_is_zero(const arb_poly_t poly) + bint arb_poly_is_zero(const arb_poly_t poly) noexcept - bint arb_poly_is_one(const arb_poly_t poly) + bint arb_poly_is_one(const arb_poly_t poly) noexcept - bint arb_poly_is_x(const arb_poly_t poly) + bint arb_poly_is_x(const arb_poly_t poly) noexcept # Returns 1 if *poly* is exactly the polynomial 0, 1 or *x* # respectively. Returns 0 otherwise. - void arb_poly_zero(arb_poly_t poly) + void arb_poly_zero(arb_poly_t poly) noexcept - void arb_poly_one(arb_poly_t poly) + void arb_poly_one(arb_poly_t poly) noexcept # Sets *poly* to the constant 0 respectively 1. - void arb_poly_set(arb_poly_t dest, const arb_poly_t src) + void arb_poly_set(arb_poly_t dest, const arb_poly_t src) noexcept # Sets *dest* to a copy of *src*. - void arb_poly_set_round(arb_poly_t dest, const arb_poly_t src, slong prec) + void arb_poly_set_round(arb_poly_t dest, const arb_poly_t src, slong prec) noexcept # Sets *dest* to a copy of *src*, rounded to *prec* bits. - void arb_poly_set_trunc(arb_poly_t dest, const arb_poly_t src, slong n) + void arb_poly_set_trunc(arb_poly_t dest, const arb_poly_t src, slong n) noexcept - void arb_poly_set_trunc_round(arb_poly_t dest, const arb_poly_t src, slong n, slong prec) + void arb_poly_set_trunc_round(arb_poly_t dest, const arb_poly_t src, slong n, slong prec) noexcept # Sets *dest* to a copy of *src*, truncated to length *n* and rounded to *prec* bits. - void arb_poly_set_coeff_si(arb_poly_t poly, slong n, slong c) + void arb_poly_set_coeff_si(arb_poly_t poly, slong n, slong c) noexcept - void arb_poly_set_coeff_arb(arb_poly_t poly, slong n, const arb_t c) + void arb_poly_set_coeff_arb(arb_poly_t poly, slong n, const arb_t c) noexcept # Sets the coefficient with index *n* in *poly* to the value *c*. # We require that *n* is nonnegative. - void arb_poly_get_coeff_arb(arb_t v, const arb_poly_t poly, slong n) + void arb_poly_get_coeff_arb(arb_t v, const arb_poly_t poly, slong n) noexcept # Sets *v* to the value of the coefficient with index *n* in *poly*. # We require that *n* is nonnegative. - void _arb_poly_shift_right(arb_ptr res, arb_srcptr poly, slong len, slong n) + void _arb_poly_shift_right(arb_ptr res, arb_srcptr poly, slong len, slong n) noexcept - void arb_poly_shift_right(arb_poly_t res, const arb_poly_t poly, slong n) + void arb_poly_shift_right(arb_poly_t res, const arb_poly_t poly, slong n) noexcept # Sets *res* to *poly* divided by `x^n`, throwing away the lower coefficients. # We require that *n* is nonnegative. - void _arb_poly_shift_left(arb_ptr res, arb_srcptr poly, slong len, slong n) + void _arb_poly_shift_left(arb_ptr res, arb_srcptr poly, slong len, slong n) noexcept - void arb_poly_shift_left(arb_poly_t res, const arb_poly_t poly, slong n) + void arb_poly_shift_left(arb_poly_t res, const arb_poly_t poly, slong n) noexcept # Sets *res* to *poly* multiplied by `x^n`. # We require that *n* is nonnegative. - void arb_poly_truncate(arb_poly_t poly, slong n) + void arb_poly_truncate(arb_poly_t poly, slong n) noexcept # Truncates *poly* to have length at most *n*, i.e. degree # strictly smaller than *n*. We require that *n* is nonnegative. - slong arb_poly_valuation(const arb_poly_t poly) + slong arb_poly_valuation(const arb_poly_t poly) noexcept # Returns the degree of the lowest term that is not exactly zero in *poly*. # Returns -1 if *poly* is the zero polynomial. - void arb_poly_set_fmpz_poly(arb_poly_t poly, const fmpz_poly_t src, slong prec) + void arb_poly_set_fmpz_poly(arb_poly_t poly, const fmpz_poly_t src, slong prec) noexcept - void arb_poly_set_fmpq_poly(arb_poly_t poly, const fmpq_poly_t src, slong prec) + void arb_poly_set_fmpq_poly(arb_poly_t poly, const fmpq_poly_t src, slong prec) noexcept - void arb_poly_set_si(arb_poly_t poly, slong src) + void arb_poly_set_si(arb_poly_t poly, slong src) noexcept # Sets *poly* to *src*, rounding the coefficients to *prec* bits. - void arb_poly_printd(const arb_poly_t poly, slong digits) + void arb_poly_printd(const arb_poly_t poly, slong digits) noexcept # Prints the polynomial as an array of coefficients, printing each # coefficient using *arb_printd*. - void arb_poly_fprintd(FILE * file, const arb_poly_t poly, slong digits) + void arb_poly_fprintd(FILE * file, const arb_poly_t poly, slong digits) noexcept # Prints the polynomial as an array of coefficients to the stream *file*, # printing each coefficient using *arb_fprintd*. - void arb_poly_randtest(arb_poly_t poly, flint_rand_t state, slong len, slong prec, slong mag_bits) + void arb_poly_randtest(arb_poly_t poly, flint_rand_t state, slong len, slong prec, slong mag_bits) noexcept # Creates a random polynomial with length at most *len*. - bint arb_poly_contains(const arb_poly_t poly1, const arb_poly_t poly2) + bint arb_poly_contains(const arb_poly_t poly1, const arb_poly_t poly2) noexcept - bint arb_poly_contains_fmpz_poly(const arb_poly_t poly1, const fmpz_poly_t poly2) + bint arb_poly_contains_fmpz_poly(const arb_poly_t poly1, const fmpz_poly_t poly2) noexcept - bint arb_poly_contains_fmpq_poly(const arb_poly_t poly1, const fmpq_poly_t poly2) + bint arb_poly_contains_fmpq_poly(const arb_poly_t poly1, const fmpq_poly_t poly2) noexcept # Returns nonzero iff *poly1* contains *poly2*. - bint arb_poly_equal(const arb_poly_t A, const arb_poly_t B) + bint arb_poly_equal(const arb_poly_t A, const arb_poly_t B) noexcept # Returns nonzero iff *A* and *B* are equal as polynomial balls, i.e. all # coefficients have equal midpoint and radius. - bint _arb_poly_overlaps(arb_srcptr poly1, slong len1, arb_srcptr poly2, slong len2) + bint _arb_poly_overlaps(arb_srcptr poly1, slong len1, arb_srcptr poly2, slong len2) noexcept - bint arb_poly_overlaps(const arb_poly_t poly1, const arb_poly_t poly2) + bint arb_poly_overlaps(const arb_poly_t poly1, const arb_poly_t poly2) noexcept # Returns nonzero iff *poly1* overlaps with *poly2*. The underscore # function requires that *len1* is at least as large as *len2*. - int arb_poly_get_unique_fmpz_poly(fmpz_poly_t z, const arb_poly_t x) + int arb_poly_get_unique_fmpz_poly(fmpz_poly_t z, const arb_poly_t x) noexcept # If *x* contains a unique integer polynomial, sets *z* to that value and returns # nonzero. Otherwise (if *x* represents no integers or more than one integer), # returns zero, possibly partially modifying *z*. - void _arb_poly_majorant(arb_ptr res, arb_srcptr poly, slong len, slong prec) + void _arb_poly_majorant(arb_ptr res, arb_srcptr poly, slong len, slong prec) noexcept - void arb_poly_majorant(arb_poly_t res, const arb_poly_t poly, slong prec) + void arb_poly_majorant(arb_poly_t res, const arb_poly_t poly, slong prec) noexcept # Sets *res* to an exact real polynomial whose coefficients are # upper bounds for the absolute values of the coefficients in *poly*, # rounded to *prec* bits. - void _arb_poly_add(arb_ptr C, arb_srcptr A, slong lenA, arb_srcptr B, slong lenB, slong prec) + void _arb_poly_add(arb_ptr C, arb_srcptr A, slong lenA, arb_srcptr B, slong lenB, slong prec) noexcept # Sets *{C, max(lenA, lenB)}* to the sum of *{A, lenA}* and *{B, lenB}*. # Allows aliasing of the input and output operands. - void arb_poly_add(arb_poly_t C, const arb_poly_t A, const arb_poly_t B, slong prec) + void arb_poly_add(arb_poly_t C, const arb_poly_t A, const arb_poly_t B, slong prec) noexcept - void arb_poly_add_si(arb_poly_t C, const arb_poly_t A, slong B, slong prec) + void arb_poly_add_si(arb_poly_t C, const arb_poly_t A, slong B, slong prec) noexcept # Sets *C* to the sum of *A* and *B*. - void _arb_poly_sub(arb_ptr C, arb_srcptr A, slong lenA, arb_srcptr B, slong lenB, slong prec) + void _arb_poly_sub(arb_ptr C, arb_srcptr A, slong lenA, arb_srcptr B, slong lenB, slong prec) noexcept # Sets *{C, max(lenA, lenB)}* to the difference of *{A, lenA}* and *{B, lenB}*. # Allows aliasing of the input and output operands. - void arb_poly_sub(arb_poly_t C, const arb_poly_t A, const arb_poly_t B, slong prec) + void arb_poly_sub(arb_poly_t C, const arb_poly_t A, const arb_poly_t B, slong prec) noexcept # Sets *C* to the difference of *A* and *B*. - void arb_poly_add_series(arb_poly_t C, const arb_poly_t A, const arb_poly_t B, slong len, slong prec) + void arb_poly_add_series(arb_poly_t C, const arb_poly_t A, const arb_poly_t B, slong len, slong prec) noexcept # Sets *C* to the sum of *A* and *B*, truncated to length *len*. - void arb_poly_sub_series(arb_poly_t C, const arb_poly_t A, const arb_poly_t B, slong len, slong prec) + void arb_poly_sub_series(arb_poly_t C, const arb_poly_t A, const arb_poly_t B, slong len, slong prec) noexcept # Sets *C* to the difference of *A* and *B*, truncated to length *len*. - void arb_poly_neg(arb_poly_t C, const arb_poly_t A) + void arb_poly_neg(arb_poly_t C, const arb_poly_t A) noexcept # Sets *C* to the negation of *A*. - void arb_poly_scalar_mul_2exp_si(arb_poly_t C, const arb_poly_t A, slong c) + void arb_poly_scalar_mul_2exp_si(arb_poly_t C, const arb_poly_t A, slong c) noexcept # Sets *C* to *A* multiplied by `2^c`. - void arb_poly_scalar_mul(arb_poly_t C, const arb_poly_t A, const arb_t c, slong prec) + void arb_poly_scalar_mul(arb_poly_t C, const arb_poly_t A, const arb_t c, slong prec) noexcept # Sets *C* to *A* multiplied by *c*. - void arb_poly_scalar_div(arb_poly_t C, const arb_poly_t A, const arb_t c, slong prec) + void arb_poly_scalar_div(arb_poly_t C, const arb_poly_t A, const arb_t c, slong prec) noexcept # Sets *C* to *A* divided by *c*. - void _arb_poly_mullow_classical(arb_ptr C, arb_srcptr A, slong lenA, arb_srcptr B, slong lenB, slong n, slong prec) + void _arb_poly_mullow_classical(arb_ptr C, arb_srcptr A, slong lenA, arb_srcptr B, slong lenB, slong n, slong prec) noexcept - void _arb_poly_mullow_block(arb_ptr C, arb_srcptr A, slong lenA, arb_srcptr B, slong lenB, slong n, slong prec) + void _arb_poly_mullow_block(arb_ptr C, arb_srcptr A, slong lenA, arb_srcptr B, slong lenB, slong n, slong prec) noexcept - void _arb_poly_mullow(arb_ptr C, arb_srcptr A, slong lenA, arb_srcptr B, slong lenB, slong n, slong prec) + void _arb_poly_mullow(arb_ptr C, arb_srcptr A, slong lenA, arb_srcptr B, slong lenB, slong n, slong prec) noexcept # Sets *{C, n}* to the product of *{A, lenA}* and *{B, lenB}*, truncated to # length *n*. The output is not allowed to be aliased with either of the # inputs. We require `\mathrm{lenA} \ge \mathrm{lenB} > 0`, @@ -220,18 +220,18 @@ cdef extern from "flint_wrap.h": # they are assumed to represent the same polynomial, and its # square is computed. - void arb_poly_mullow_classical(arb_poly_t C, const arb_poly_t A, const arb_poly_t B, slong n, slong prec) + void arb_poly_mullow_classical(arb_poly_t C, const arb_poly_t A, const arb_poly_t B, slong n, slong prec) noexcept - void arb_poly_mullow_ztrunc(arb_poly_t C, const arb_poly_t A, const arb_poly_t B, slong n, slong prec) + void arb_poly_mullow_ztrunc(arb_poly_t C, const arb_poly_t A, const arb_poly_t B, slong n, slong prec) noexcept - void arb_poly_mullow_block(arb_poly_t C, const arb_poly_t A, const arb_poly_t B, slong n, slong prec) + void arb_poly_mullow_block(arb_poly_t C, const arb_poly_t A, const arb_poly_t B, slong n, slong prec) noexcept - void arb_poly_mullow(arb_poly_t C, const arb_poly_t A, const arb_poly_t B, slong n, slong prec) + void arb_poly_mullow(arb_poly_t C, const arb_poly_t A, const arb_poly_t B, slong n, slong prec) noexcept # Sets *C* to the product of *A* and *B*, truncated to length *n*. # If the same variable is passed for *A* and *B*, sets *C* to the square # of *A* truncated to length *n*. - void _arb_poly_mul(arb_ptr C, arb_srcptr A, slong lenA, arb_srcptr B, slong lenB, slong prec) + void _arb_poly_mul(arb_ptr C, arb_srcptr A, slong lenA, arb_srcptr B, slong lenB, slong prec) noexcept # Sets *{C, lenA + lenB - 1}* to the product of *{A, lenA}* and *{B, lenB}*. # The output is not allowed to be aliased with either of the # inputs. We require `\mathrm{lenA} \ge \mathrm{lenB} > 0`. @@ -240,31 +240,31 @@ cdef extern from "flint_wrap.h": # they are assumed to represent the same polynomial, and its # square is computed. - void arb_poly_mul(arb_poly_t C, const arb_poly_t A, const arb_poly_t B, slong prec) + void arb_poly_mul(arb_poly_t C, const arb_poly_t A, const arb_poly_t B, slong prec) noexcept # Sets *C* to the product of *A* and *B*. # If the same variable is passed for *A* and *B*, sets *C* to the # square of *A*. - void _arb_poly_inv_series(arb_ptr Q, arb_srcptr A, slong Alen, slong len, slong prec) + void _arb_poly_inv_series(arb_ptr Q, arb_srcptr A, slong Alen, slong len, slong prec) noexcept # Sets *{Q, len}* to the power series inverse of *{A, Alen}*. Uses Newton iteration. - void arb_poly_inv_series(arb_poly_t Q, const arb_poly_t A, slong n, slong prec) + void arb_poly_inv_series(arb_poly_t Q, const arb_poly_t A, slong n, slong prec) noexcept # Sets *Q* to the power series inverse of *A*, truncated to length *n*. - void _arb_poly_div_series(arb_ptr Q, arb_srcptr A, slong Alen, arb_srcptr B, slong Blen, slong n, slong prec) + void _arb_poly_div_series(arb_ptr Q, arb_srcptr A, slong Alen, arb_srcptr B, slong Blen, slong n, slong prec) noexcept # Sets *{Q, n}* to the power series quotient of *{A, Alen}* by *{B, Blen}*. # Uses Newton iteration followed by multiplication. - void arb_poly_div_series(arb_poly_t Q, const arb_poly_t A, const arb_poly_t B, slong n, slong prec) + void arb_poly_div_series(arb_poly_t Q, const arb_poly_t A, const arb_poly_t B, slong n, slong prec) noexcept # Sets *Q* to the power series quotient *A* divided by *B*, truncated to length *n*. - void _arb_poly_div(arb_ptr Q, arb_srcptr A, slong lenA, arb_srcptr B, slong lenB, slong prec) + void _arb_poly_div(arb_ptr Q, arb_srcptr A, slong lenA, arb_srcptr B, slong lenB, slong prec) noexcept - void _arb_poly_rem(arb_ptr R, arb_srcptr A, slong lenA, arb_srcptr B, slong lenB, slong prec) + void _arb_poly_rem(arb_ptr R, arb_srcptr A, slong lenA, arb_srcptr B, slong lenB, slong prec) noexcept - void _arb_poly_divrem(arb_ptr Q, arb_ptr R, arb_srcptr A, slong lenA, arb_srcptr B, slong lenB, slong prec) + void _arb_poly_divrem(arb_ptr Q, arb_ptr R, arb_srcptr A, slong lenA, arb_srcptr B, slong lenB, slong prec) noexcept - int arb_poly_divrem(arb_poly_t Q, arb_poly_t R, const arb_poly_t A, const arb_poly_t B, slong prec) + int arb_poly_divrem(arb_poly_t Q, arb_poly_t R, const arb_poly_t A, const arb_poly_t B, slong prec) noexcept # Performs polynomial division with remainder, computing a quotient `Q` and # a remainder `R` such that `A = BQ + R`. The implementation reverses the # inputs and performs power series division. @@ -272,24 +272,24 @@ cdef extern from "flint_wrap.h": # zero), returns 0 indicating failure without modifying the outputs. # Otherwise returns nonzero. - void _arb_poly_div_root(arb_ptr Q, arb_t R, arb_srcptr A, slong len, const arb_t c, slong prec) + void _arb_poly_div_root(arb_ptr Q, arb_t R, arb_srcptr A, slong len, const arb_t c, slong prec) noexcept # Divides `A` by the polynomial `x - c`, computing the quotient `Q` as well # as the remainder `R = f(c)`. - void _arb_poly_taylor_shift(arb_ptr g, const arb_t c, slong n, slong prec) - void arb_poly_taylor_shift(arb_poly_t g, const arb_poly_t f, const arb_t c, slong prec) + void _arb_poly_taylor_shift(arb_ptr g, const arb_t c, slong n, slong prec) noexcept + void arb_poly_taylor_shift(arb_poly_t g, const arb_poly_t f, const arb_t c, slong prec) noexcept # Sets *g* to the Taylor shift `f(x+c)`. # The underscore methods act in-place on *g* = *f* which has length *n*. - void _arb_poly_compose(arb_ptr res, arb_srcptr poly1, slong len1, arb_srcptr poly2, slong len2, slong prec) - void arb_poly_compose(arb_poly_t res, const arb_poly_t poly1, const arb_poly_t poly2, slong prec) + void _arb_poly_compose(arb_ptr res, arb_srcptr poly1, slong len1, arb_srcptr poly2, slong len2, slong prec) noexcept + void arb_poly_compose(arb_poly_t res, const arb_poly_t poly1, const arb_poly_t poly2, slong prec) noexcept # Sets *res* to the composition `h(x) = f(g(x))` where `f` is given by # *poly1* and `g` is given by *poly2*. # The underscore method does not support aliasing of the output # with either input polynomial. - void _arb_poly_compose_series(arb_ptr res, arb_srcptr poly1, slong len1, arb_srcptr poly2, slong len2, slong n, slong prec) - void arb_poly_compose_series(arb_poly_t res, const arb_poly_t poly1, const arb_poly_t poly2, slong n, slong prec) + void _arb_poly_compose_series(arb_ptr res, arb_srcptr poly1, slong len1, arb_srcptr poly2, slong len2, slong n, slong prec) noexcept + void arb_poly_compose_series(arb_poly_t res, const arb_poly_t poly1, const arb_poly_t poly2, slong n, slong prec) noexcept # Sets *res* to the power series composition `h(x) = f(g(x))` truncated # to order `O(x^n)` where `f` is given by *poly1* and `g` is given by *poly2*. # Wraps :func:`_gr_poly_compose_series` which chooses automatically @@ -298,21 +298,21 @@ cdef extern from "flint_wrap.h": # The underscore method does not support aliasing of the output # with either input polynomial. - void _arb_poly_revert_series_lagrange(arb_ptr h, arb_srcptr f, slong flen, slong n, slong prec) + void _arb_poly_revert_series_lagrange(arb_ptr h, arb_srcptr f, slong flen, slong n, slong prec) noexcept - void arb_poly_revert_series_lagrange(arb_poly_t h, const arb_poly_t f, slong n, slong prec) + void arb_poly_revert_series_lagrange(arb_poly_t h, const arb_poly_t f, slong n, slong prec) noexcept - void _arb_poly_revert_series_newton(arb_ptr h, arb_srcptr f, slong flen, slong n, slong prec) + void _arb_poly_revert_series_newton(arb_ptr h, arb_srcptr f, slong flen, slong n, slong prec) noexcept - void arb_poly_revert_series_newton(arb_poly_t h, const arb_poly_t f, slong n, slong prec) + void arb_poly_revert_series_newton(arb_poly_t h, const arb_poly_t f, slong n, slong prec) noexcept - void _arb_poly_revert_series_lagrange_fast(arb_ptr h, arb_srcptr f, slong flen, slong n, slong prec) + void _arb_poly_revert_series_lagrange_fast(arb_ptr h, arb_srcptr f, slong flen, slong n, slong prec) noexcept - void arb_poly_revert_series_lagrange_fast(arb_poly_t h, const arb_poly_t f, slong n, slong prec) + void arb_poly_revert_series_lagrange_fast(arb_poly_t h, const arb_poly_t f, slong n, slong prec) noexcept - void _arb_poly_revert_series(arb_ptr h, arb_srcptr f, slong flen, slong n, slong prec) + void _arb_poly_revert_series(arb_ptr h, arb_srcptr f, slong flen, slong n, slong prec) noexcept - void arb_poly_revert_series(arb_poly_t h, const arb_poly_t f, slong n, slong prec) + void arb_poly_revert_series(arb_poly_t h, const arb_poly_t f, slong n, slong prec) noexcept # Sets `h` to the power series reversion of `f`, i.e. the expansion # of the compositional inverse function `f^{-1}(x)`, # truncated to order `O(x^n)`, using respectively @@ -322,46 +322,46 @@ cdef extern from "flint_wrap.h": # linear term is nonzero. The underscore methods assume that *flen* # is at least 2, and do not support aliasing. - void _arb_poly_evaluate_horner(arb_t y, arb_srcptr f, slong len, const arb_t x, slong prec) + void _arb_poly_evaluate_horner(arb_t y, arb_srcptr f, slong len, const arb_t x, slong prec) noexcept - void arb_poly_evaluate_horner(arb_t y, const arb_poly_t f, const arb_t x, slong prec) + void arb_poly_evaluate_horner(arb_t y, const arb_poly_t f, const arb_t x, slong prec) noexcept - void _arb_poly_evaluate_rectangular(arb_t y, arb_srcptr f, slong len, const arb_t x, slong prec) + void _arb_poly_evaluate_rectangular(arb_t y, arb_srcptr f, slong len, const arb_t x, slong prec) noexcept - void arb_poly_evaluate_rectangular(arb_t y, const arb_poly_t f, const arb_t x, slong prec) + void arb_poly_evaluate_rectangular(arb_t y, const arb_poly_t f, const arb_t x, slong prec) noexcept - void _arb_poly_evaluate(arb_t y, arb_srcptr f, slong len, const arb_t x, slong prec) + void _arb_poly_evaluate(arb_t y, arb_srcptr f, slong len, const arb_t x, slong prec) noexcept - void arb_poly_evaluate(arb_t y, const arb_poly_t f, const arb_t x, slong prec) + void arb_poly_evaluate(arb_t y, const arb_poly_t f, const arb_t x, slong prec) noexcept # Sets `y = f(x)`, evaluated respectively using Horner's rule, # rectangular splitting, and an automatic algorithm choice. - void _arb_poly_evaluate_acb_horner(acb_t y, arb_srcptr f, slong len, const acb_t x, slong prec) + void _arb_poly_evaluate_acb_horner(acb_t y, arb_srcptr f, slong len, const acb_t x, slong prec) noexcept - void arb_poly_evaluate_acb_horner(acb_t y, const arb_poly_t f, const acb_t x, slong prec) + void arb_poly_evaluate_acb_horner(acb_t y, const arb_poly_t f, const acb_t x, slong prec) noexcept - void _arb_poly_evaluate_acb_rectangular(acb_t y, arb_srcptr f, slong len, const acb_t x, slong prec) + void _arb_poly_evaluate_acb_rectangular(acb_t y, arb_srcptr f, slong len, const acb_t x, slong prec) noexcept - void arb_poly_evaluate_acb_rectangular(acb_t y, const arb_poly_t f, const acb_t x, slong prec) + void arb_poly_evaluate_acb_rectangular(acb_t y, const arb_poly_t f, const acb_t x, slong prec) noexcept - void _arb_poly_evaluate_acb(acb_t y, arb_srcptr f, slong len, const acb_t x, slong prec) + void _arb_poly_evaluate_acb(acb_t y, arb_srcptr f, slong len, const acb_t x, slong prec) noexcept - void arb_poly_evaluate_acb(acb_t y, const arb_poly_t f, const acb_t x, slong prec) + void arb_poly_evaluate_acb(acb_t y, const arb_poly_t f, const acb_t x, slong prec) noexcept # Sets `y = f(x)` where `x` is a complex number, evaluating the # polynomial respectively using Horner's rule, # rectangular splitting, and an automatic algorithm choice. - void _arb_poly_evaluate2_horner(arb_t y, arb_t z, arb_srcptr f, slong len, const arb_t x, slong prec) + void _arb_poly_evaluate2_horner(arb_t y, arb_t z, arb_srcptr f, slong len, const arb_t x, slong prec) noexcept - void arb_poly_evaluate2_horner(arb_t y, arb_t z, const arb_poly_t f, const arb_t x, slong prec) + void arb_poly_evaluate2_horner(arb_t y, arb_t z, const arb_poly_t f, const arb_t x, slong prec) noexcept - void _arb_poly_evaluate2_rectangular(arb_t y, arb_t z, arb_srcptr f, slong len, const arb_t x, slong prec) + void _arb_poly_evaluate2_rectangular(arb_t y, arb_t z, arb_srcptr f, slong len, const arb_t x, slong prec) noexcept - void arb_poly_evaluate2_rectangular(arb_t y, arb_t z, const arb_poly_t f, const arb_t x, slong prec) + void arb_poly_evaluate2_rectangular(arb_t y, arb_t z, const arb_poly_t f, const arb_t x, slong prec) noexcept - void _arb_poly_evaluate2(arb_t y, arb_t z, arb_srcptr f, slong len, const arb_t x, slong prec) + void _arb_poly_evaluate2(arb_t y, arb_t z, arb_srcptr f, slong len, const arb_t x, slong prec) noexcept - void arb_poly_evaluate2(arb_t y, arb_t z, const arb_poly_t f, const arb_t x, slong prec) + void arb_poly_evaluate2(arb_t y, arb_t z, const arb_poly_t f, const arb_t x, slong prec) noexcept # Sets `y = f(x), z = f'(x)`, evaluated respectively using Horner's rule, # rectangular splitting, and an automatic algorithm choice. # When Horner's rule is used, the only advantage of evaluating the @@ -370,28 +370,28 @@ cdef extern from "flint_wrap.h": # With the rectangular splitting algorithm, the powers can be reused, # making simultaneous evaluation slightly faster. - void _arb_poly_evaluate2_acb_horner(acb_t y, acb_t z, arb_srcptr f, slong len, const acb_t x, slong prec) + void _arb_poly_evaluate2_acb_horner(acb_t y, acb_t z, arb_srcptr f, slong len, const acb_t x, slong prec) noexcept - void arb_poly_evaluate2_acb_horner(acb_t y, acb_t z, const arb_poly_t f, const acb_t x, slong prec) + void arb_poly_evaluate2_acb_horner(acb_t y, acb_t z, const arb_poly_t f, const acb_t x, slong prec) noexcept - void _arb_poly_evaluate2_acb_rectangular(acb_t y, acb_t z, arb_srcptr f, slong len, const acb_t x, slong prec) + void _arb_poly_evaluate2_acb_rectangular(acb_t y, acb_t z, arb_srcptr f, slong len, const acb_t x, slong prec) noexcept - void arb_poly_evaluate2_acb_rectangular(acb_t y, acb_t z, const arb_poly_t f, const acb_t x, slong prec) + void arb_poly_evaluate2_acb_rectangular(acb_t y, acb_t z, const arb_poly_t f, const acb_t x, slong prec) noexcept - void _arb_poly_evaluate2_acb(acb_t y, acb_t z, arb_srcptr f, slong len, const acb_t x, slong prec) + void _arb_poly_evaluate2_acb(acb_t y, acb_t z, arb_srcptr f, slong len, const acb_t x, slong prec) noexcept - void arb_poly_evaluate2_acb(acb_t y, acb_t z, const arb_poly_t f, const acb_t x, slong prec) + void arb_poly_evaluate2_acb(acb_t y, acb_t z, const arb_poly_t f, const acb_t x, slong prec) noexcept # Sets `y = f(x), z = f'(x)`, evaluated respectively using Horner's rule, # rectangular splitting, and an automatic algorithm choice. - void _arb_poly_product_roots(arb_ptr poly, arb_srcptr xs, slong n, slong prec) + void _arb_poly_product_roots(arb_ptr poly, arb_srcptr xs, slong n, slong prec) noexcept - void arb_poly_product_roots(arb_poly_t poly, arb_srcptr xs, slong n, slong prec) + void arb_poly_product_roots(arb_poly_t poly, arb_srcptr xs, slong n, slong prec) noexcept # Generates the polynomial `(x-x_0)(x-x_1)\cdots(x-x_{n-1})`. - void _arb_poly_product_roots_complex(arb_ptr poly, arb_srcptr r, slong rn, acb_srcptr c, slong cn, slong prec) + void _arb_poly_product_roots_complex(arb_ptr poly, arb_srcptr r, slong rn, acb_srcptr c, slong cn, slong prec) noexcept - void arb_poly_product_roots_complex(arb_poly_t poly, arb_srcptr r, slong rn, acb_srcptr c, slong cn, slong prec) + void arb_poly_product_roots_complex(arb_poly_t poly, arb_srcptr r, slong rn, acb_srcptr c, slong cn, slong prec) noexcept # Generates the polynomial # .. math :: # \left(\prod_{i=0}^{rn-1} (x-r_i)\right) \left(\prod_{i=0}^{cn-1} (x-c_i)(x-\bar{c_i})\right) @@ -404,102 +404,102 @@ cdef extern from "flint_wrap.h": # To construct a polynomial from complex roots where the conjugate pairs # have not been distinguished, use :func:`acb_poly_product_roots` instead. - arb_ptr * _arb_poly_tree_alloc(slong len) + arb_ptr * _arb_poly_tree_alloc(slong len) noexcept # Returns an initialized data structured capable of representing a # remainder tree (product tree) of *len* roots. - void _arb_poly_tree_free(arb_ptr * tree, slong len) + void _arb_poly_tree_free(arb_ptr * tree, slong len) noexcept # Deallocates a tree structure as allocated using *_arb_poly_tree_alloc*. - void _arb_poly_tree_build(arb_ptr * tree, arb_srcptr roots, slong len, slong prec) + void _arb_poly_tree_build(arb_ptr * tree, arb_srcptr roots, slong len, slong prec) noexcept # Constructs a product tree from a given array of *len* roots. The tree # structure must be pre-allocated to the specified length using # :func:`_arb_poly_tree_alloc`. - void _arb_poly_evaluate_vec_iter(arb_ptr ys, arb_srcptr poly, slong plen, arb_srcptr xs, slong n, slong prec) + void _arb_poly_evaluate_vec_iter(arb_ptr ys, arb_srcptr poly, slong plen, arb_srcptr xs, slong n, slong prec) noexcept - void arb_poly_evaluate_vec_iter(arb_ptr ys, const arb_poly_t poly, arb_srcptr xs, slong n, slong prec) + void arb_poly_evaluate_vec_iter(arb_ptr ys, const arb_poly_t poly, arb_srcptr xs, slong n, slong prec) noexcept # Evaluates the polynomial simultaneously at *n* given points, calling # :func:`_arb_poly_evaluate` repeatedly. - void _arb_poly_evaluate_vec_fast_precomp(arb_ptr vs, arb_srcptr poly, slong plen, arb_ptr * tree, slong len, slong prec) + void _arb_poly_evaluate_vec_fast_precomp(arb_ptr vs, arb_srcptr poly, slong plen, arb_ptr * tree, slong len, slong prec) noexcept - void _arb_poly_evaluate_vec_fast(arb_ptr ys, arb_srcptr poly, slong plen, arb_srcptr xs, slong n, slong prec) + void _arb_poly_evaluate_vec_fast(arb_ptr ys, arb_srcptr poly, slong plen, arb_srcptr xs, slong n, slong prec) noexcept - void arb_poly_evaluate_vec_fast(arb_ptr ys, const arb_poly_t poly, arb_srcptr xs, slong n, slong prec) + void arb_poly_evaluate_vec_fast(arb_ptr ys, const arb_poly_t poly, arb_srcptr xs, slong n, slong prec) noexcept # Evaluates the polynomial simultaneously at *n* given points, using # fast multipoint evaluation. - void _arb_poly_interpolate_newton(arb_ptr poly, arb_srcptr xs, arb_srcptr ys, slong n, slong prec) + void _arb_poly_interpolate_newton(arb_ptr poly, arb_srcptr xs, arb_srcptr ys, slong n, slong prec) noexcept - void arb_poly_interpolate_newton(arb_poly_t poly, arb_srcptr xs, arb_srcptr ys, slong n, slong prec) + void arb_poly_interpolate_newton(arb_poly_t poly, arb_srcptr xs, arb_srcptr ys, slong n, slong prec) noexcept # Recovers the unique polynomial of length at most *n* that interpolates # the given *x* and *y* values. This implementation first interpolates in the # Newton basis and then converts back to the monomial basis. - void _arb_poly_interpolate_barycentric(arb_ptr poly, arb_srcptr xs, arb_srcptr ys, slong n, slong prec) + void _arb_poly_interpolate_barycentric(arb_ptr poly, arb_srcptr xs, arb_srcptr ys, slong n, slong prec) noexcept - void arb_poly_interpolate_barycentric(arb_poly_t poly, arb_srcptr xs, arb_srcptr ys, slong n, slong prec) + void arb_poly_interpolate_barycentric(arb_poly_t poly, arb_srcptr xs, arb_srcptr ys, slong n, slong prec) noexcept # Recovers the unique polynomial of length at most *n* that interpolates # the given *x* and *y* values. This implementation uses the barycentric # form of Lagrange interpolation. - void _arb_poly_interpolation_weights(arb_ptr w, arb_ptr * tree, slong len, slong prec) + void _arb_poly_interpolation_weights(arb_ptr w, arb_ptr * tree, slong len, slong prec) noexcept - void _arb_poly_interpolate_fast_precomp(arb_ptr poly, arb_srcptr ys, arb_ptr * tree, arb_srcptr weights, slong len, slong prec) + void _arb_poly_interpolate_fast_precomp(arb_ptr poly, arb_srcptr ys, arb_ptr * tree, arb_srcptr weights, slong len, slong prec) noexcept - void _arb_poly_interpolate_fast(arb_ptr poly, arb_srcptr xs, arb_srcptr ys, slong len, slong prec) + void _arb_poly_interpolate_fast(arb_ptr poly, arb_srcptr xs, arb_srcptr ys, slong len, slong prec) noexcept - void arb_poly_interpolate_fast(arb_poly_t poly, arb_srcptr xs, arb_srcptr ys, slong n, slong prec) + void arb_poly_interpolate_fast(arb_poly_t poly, arb_srcptr xs, arb_srcptr ys, slong n, slong prec) noexcept # Recovers the unique polynomial of length at most *n* that interpolates # the given *x* and *y* values, using fast Lagrange interpolation. # The precomp function takes a precomputed product tree over the # *x* values and a vector of interpolation weights as additional inputs. - void _arb_poly_derivative(arb_ptr res, arb_srcptr poly, slong len, slong prec) + void _arb_poly_derivative(arb_ptr res, arb_srcptr poly, slong len, slong prec) noexcept # Sets *{res, len - 1}* to the derivative of *{poly, len}*. # Allows aliasing of the input and output. - void arb_poly_derivative(arb_poly_t res, const arb_poly_t poly, slong prec) + void arb_poly_derivative(arb_poly_t res, const arb_poly_t poly, slong prec) noexcept # Sets *res* to the derivative of *poly*. - void _arb_poly_nth_derivative(arb_ptr res, arb_srcptr poly, ulong n, slong len, slong prec) + void _arb_poly_nth_derivative(arb_ptr res, arb_srcptr poly, ulong n, slong len, slong prec) noexcept # Sets *{res, len - n}* to the nth derivative of *{poly, len}*. Does # nothing if *len <= n*. Allows aliasing of the input and output. - void arb_poly_nth_derivative(arb_poly_t res, const arb_poly_t poly, ulong n, slong prec) + void arb_poly_nth_derivative(arb_poly_t res, const arb_poly_t poly, ulong n, slong prec) noexcept # Sets *res* to the nth derivative of *poly*. - void _arb_poly_integral(arb_ptr res, arb_srcptr poly, slong len, slong prec) + void _arb_poly_integral(arb_ptr res, arb_srcptr poly, slong len, slong prec) noexcept # Sets *{res, len}* to the integral of *{poly, len - 1}*. # Allows aliasing of the input and output. - void arb_poly_integral(arb_poly_t res, const arb_poly_t poly, slong prec) + void arb_poly_integral(arb_poly_t res, const arb_poly_t poly, slong prec) noexcept # Sets *res* to the integral of *poly*. - void _arb_poly_borel_transform(arb_ptr res, arb_srcptr poly, slong len, slong prec) + void _arb_poly_borel_transform(arb_ptr res, arb_srcptr poly, slong len, slong prec) noexcept - void arb_poly_borel_transform(arb_poly_t res, const arb_poly_t poly, slong prec) + void arb_poly_borel_transform(arb_poly_t res, const arb_poly_t poly, slong prec) noexcept # Computes the Borel transform of the input polynomial, mapping `\sum_k a_k x^k` # to `\sum_k (a_k / k!) x^k`. The underscore method allows aliasing. - void _arb_poly_inv_borel_transform(arb_ptr res, arb_srcptr poly, slong len, slong prec) + void _arb_poly_inv_borel_transform(arb_ptr res, arb_srcptr poly, slong len, slong prec) noexcept - void arb_poly_inv_borel_transform(arb_poly_t res, const arb_poly_t poly, slong prec) + void arb_poly_inv_borel_transform(arb_poly_t res, const arb_poly_t poly, slong prec) noexcept # Computes the inverse Borel transform of the input polynomial, mapping `\sum_k a_k x^k` # to `\sum_k a_k k! x^k`. The underscore method allows aliasing. - void _arb_poly_binomial_transform_basecase(arb_ptr b, arb_srcptr a, slong alen, slong len, slong prec) + void _arb_poly_binomial_transform_basecase(arb_ptr b, arb_srcptr a, slong alen, slong len, slong prec) noexcept - void arb_poly_binomial_transform_basecase(arb_poly_t b, const arb_poly_t a, slong len, slong prec) + void arb_poly_binomial_transform_basecase(arb_poly_t b, const arb_poly_t a, slong len, slong prec) noexcept - void _arb_poly_binomial_transform_convolution(arb_ptr b, arb_srcptr a, slong alen, slong len, slong prec) + void _arb_poly_binomial_transform_convolution(arb_ptr b, arb_srcptr a, slong alen, slong len, slong prec) noexcept - void arb_poly_binomial_transform_convolution(arb_poly_t b, const arb_poly_t a, slong len, slong prec) + void arb_poly_binomial_transform_convolution(arb_poly_t b, const arb_poly_t a, slong len, slong prec) noexcept - void _arb_poly_binomial_transform(arb_ptr b, arb_srcptr a, slong alen, slong len, slong prec) + void _arb_poly_binomial_transform(arb_ptr b, arb_srcptr a, slong alen, slong len, slong prec) noexcept - void arb_poly_binomial_transform(arb_poly_t b, const arb_poly_t a, slong len, slong prec) + void arb_poly_binomial_transform(arb_poly_t b, const arb_poly_t a, slong len, slong prec) noexcept # Computes the binomial transform of the input polynomial, truncating # the output to length *len*. # The binomial transform maps the coefficients `a_k` in the input polynomial @@ -519,9 +519,9 @@ cdef extern from "flint_wrap.h": # The underscore methods do not support aliasing, and assume that # the lengths are nonzero. - void _arb_poly_graeffe_transform(arb_ptr b, arb_srcptr a, slong len, slong prec) + void _arb_poly_graeffe_transform(arb_ptr b, arb_srcptr a, slong len, slong prec) noexcept - void arb_poly_graeffe_transform(arb_poly_t b, const arb_poly_t a, slong prec) + void arb_poly_graeffe_transform(arb_poly_t b, const arb_poly_t a, slong prec) noexcept # Computes the Graeffe transform of input polynomial. # The Graeffe transform `G` of a polynomial `P` is defined through the # equation `G(x^2) = \pm P(x)P(-x)`. @@ -532,7 +532,7 @@ cdef extern from "flint_wrap.h": # *a* is of length *len*, and *b* is of length at least *len*. # Both methods allow aliasing. - void _arb_poly_pow_ui_trunc_binexp(arb_ptr res, arb_srcptr f, slong flen, ulong exp, slong len, slong prec) + void _arb_poly_pow_ui_trunc_binexp(arb_ptr res, arb_srcptr f, slong flen, ulong exp, slong len, slong prec) noexcept # Sets *{res, len}* to *{f, flen}* raised to the power *exp*, truncated # to length *len*. Requires that *len* is no longer than the length # of the power as computed without truncation (i.e. no zero-padding is performed). @@ -540,19 +540,19 @@ cdef extern from "flint_wrap.h": # that *flen* and *len* are positive. # Uses binary exponentiation. - void arb_poly_pow_ui_trunc_binexp(arb_poly_t res, const arb_poly_t poly, ulong exp, slong len, slong prec) + void arb_poly_pow_ui_trunc_binexp(arb_poly_t res, const arb_poly_t poly, ulong exp, slong len, slong prec) noexcept # Sets *res* to *poly* raised to the power *exp*, truncated to length *len*. # Uses binary exponentiation. - void _arb_poly_pow_ui(arb_ptr res, arb_srcptr f, slong flen, ulong exp, slong prec) + void _arb_poly_pow_ui(arb_ptr res, arb_srcptr f, slong flen, ulong exp, slong prec) noexcept # Sets *res* to *{f, flen}* raised to the power *exp*. Does not # support aliasing of the input and output, and requires that # *flen* is positive. - void arb_poly_pow_ui(arb_poly_t res, const arb_poly_t poly, ulong exp, slong prec) + void arb_poly_pow_ui(arb_poly_t res, const arb_poly_t poly, ulong exp, slong prec) noexcept # Sets *res* to *poly* raised to the power *exp*. - void _arb_poly_pow_series(arb_ptr h, arb_srcptr f, slong flen, arb_srcptr g, slong glen, slong len, slong prec) + void _arb_poly_pow_series(arb_ptr h, arb_srcptr f, slong flen, arb_srcptr g, slong glen, slong len, slong prec) noexcept # Sets *{h, len}* to the power series `f(x)^{g(x)} = \exp(g(x) \log f(x))` truncated # to length *len*. This function detects special cases such as *g* being an # exact small integer or `\pm 1/2`, and computes such powers more @@ -560,13 +560,13 @@ cdef extern from "flint_wrap.h": # with either of the input operands. It requires that all lengths # are positive, and assumes that *flen* and *glen* do not exceed *len*. - void arb_poly_pow_series(arb_poly_t h, const arb_poly_t f, const arb_poly_t g, slong len, slong prec) + void arb_poly_pow_series(arb_poly_t h, const arb_poly_t f, const arb_poly_t g, slong len, slong prec) noexcept # Sets *h* to the power series `f(x)^{g(x)} = \exp(g(x) \log f(x))` truncated # to length *len*. This function detects special cases such as *g* being an # exact small integer or `\pm 1/2`, and computes such powers more # efficiently. - void _arb_poly_pow_arb_series(arb_ptr h, arb_srcptr f, slong flen, const arb_t g, slong len, slong prec) + void _arb_poly_pow_arb_series(arb_ptr h, arb_srcptr f, slong flen, const arb_t g, slong len, slong prec) noexcept # Sets *{h, len}* to the power series `f(x)^g = \exp(g \log f(x))` truncated # to length *len*. This function detects special cases such as *g* being an # exact small integer or `\pm 1/2`, and computes such powers more @@ -574,52 +574,52 @@ cdef extern from "flint_wrap.h": # with either of the input operands. It requires that all lengths # are positive, and assumes that *flen* does not exceed *len*. - void arb_poly_pow_arb_series(arb_poly_t h, const arb_poly_t f, const arb_t g, slong len, slong prec) + void arb_poly_pow_arb_series(arb_poly_t h, const arb_poly_t f, const arb_t g, slong len, slong prec) noexcept # Sets *h* to the power series `f(x)^g = \exp(g \log f(x))` truncated # to length *len*. - void _arb_poly_sqrt_series(arb_ptr g, arb_srcptr h, slong hlen, slong n, slong prec) + void _arb_poly_sqrt_series(arb_ptr g, arb_srcptr h, slong hlen, slong n, slong prec) noexcept - void arb_poly_sqrt_series(arb_poly_t g, const arb_poly_t h, slong n, slong prec) + void arb_poly_sqrt_series(arb_poly_t g, const arb_poly_t h, slong n, slong prec) noexcept # Sets *g* to the power series square root of *h*, truncated to length *n*. # Uses division-free Newton iteration for the reciprocal square root, # followed by a multiplication. # The underscore method does not support aliasing of the input and output # arrays. It requires that *hlen* and *n* are greater than zero. - void _arb_poly_rsqrt_series(arb_ptr g, arb_srcptr h, slong hlen, slong n, slong prec) + void _arb_poly_rsqrt_series(arb_ptr g, arb_srcptr h, slong hlen, slong n, slong prec) noexcept - void arb_poly_rsqrt_series(arb_poly_t g, const arb_poly_t h, slong n, slong prec) + void arb_poly_rsqrt_series(arb_poly_t g, const arb_poly_t h, slong n, slong prec) noexcept # Sets *g* to the reciprocal power series square root of *h*, truncated to length *n*. # Uses division-free Newton iteration. # The underscore method does not support aliasing of the input and output # arrays. It requires that *hlen* and *n* are greater than zero. - void _arb_poly_log_series(arb_ptr res, arb_srcptr f, slong flen, slong n, slong prec) + void _arb_poly_log_series(arb_ptr res, arb_srcptr f, slong flen, slong n, slong prec) noexcept - void arb_poly_log_series(arb_poly_t res, const arb_poly_t f, slong n, slong prec) + void arb_poly_log_series(arb_poly_t res, const arb_poly_t f, slong n, slong prec) noexcept # Sets *res* to the power series logarithm of *f*, truncated to length *n*. # Uses the formula `\log(f(x)) = \int f'(x) / f(x) dx`, adding the logarithm of the # constant term in *f* as the constant of integration. # The underscore method supports aliasing of the input and output # arrays. It requires that *flen* and *n* are greater than zero. - void _arb_poly_log1p_series(arb_ptr res, arb_srcptr f, slong flen, slong n, slong prec) + void _arb_poly_log1p_series(arb_ptr res, arb_srcptr f, slong flen, slong n, slong prec) noexcept - void arb_poly_log1p_series(arb_poly_t res, const arb_poly_t f, slong n, slong prec) + void arb_poly_log1p_series(arb_poly_t res, const arb_poly_t f, slong n, slong prec) noexcept # Computes the power series `\log(1+f)`, with better accuracy when the constant term of *f* is small. - void _arb_poly_atan_series(arb_ptr res, arb_srcptr f, slong flen, slong n, slong prec) + void _arb_poly_atan_series(arb_ptr res, arb_srcptr f, slong flen, slong n, slong prec) noexcept - void arb_poly_atan_series(arb_poly_t res, const arb_poly_t f, slong n, slong prec) + void arb_poly_atan_series(arb_poly_t res, const arb_poly_t f, slong n, slong prec) noexcept - void _arb_poly_asin_series(arb_ptr res, arb_srcptr f, slong flen, slong n, slong prec) + void _arb_poly_asin_series(arb_ptr res, arb_srcptr f, slong flen, slong n, slong prec) noexcept - void arb_poly_asin_series(arb_poly_t res, const arb_poly_t f, slong n, slong prec) + void arb_poly_asin_series(arb_poly_t res, const arb_poly_t f, slong n, slong prec) noexcept - void _arb_poly_acos_series(arb_ptr res, arb_srcptr f, slong flen, slong n, slong prec) + void _arb_poly_acos_series(arb_ptr res, arb_srcptr f, slong flen, slong n, slong prec) noexcept - void arb_poly_acos_series(arb_poly_t res, const arb_poly_t f, slong n, slong prec) + void arb_poly_acos_series(arb_poly_t res, const arb_poly_t f, slong n, slong prec) noexcept # Sets *res* respectively to the power series inverse tangent, # inverse sine and inverse cosine of *f*, truncated to length *n*. # Uses the formulas @@ -632,13 +632,13 @@ cdef extern from "flint_wrap.h": # The underscore methods supports aliasing of the input and output # arrays. They require that *flen* and *n* are greater than zero. - void _arb_poly_exp_series_basecase(arb_ptr f, arb_srcptr h, slong hlen, slong n, slong prec) + void _arb_poly_exp_series_basecase(arb_ptr f, arb_srcptr h, slong hlen, slong n, slong prec) noexcept - void arb_poly_exp_series_basecase(arb_poly_t f, const arb_poly_t h, slong n, slong prec) + void arb_poly_exp_series_basecase(arb_poly_t f, const arb_poly_t h, slong n, slong prec) noexcept - void _arb_poly_exp_series(arb_ptr f, arb_srcptr h, slong hlen, slong n, slong prec) + void _arb_poly_exp_series(arb_ptr f, arb_srcptr h, slong hlen, slong n, slong prec) noexcept - void arb_poly_exp_series(arb_poly_t f, const arb_poly_t h, slong n, slong prec) + void arb_poly_exp_series(arb_poly_t f, const arb_poly_t h, slong n, slong prec) noexcept # Sets `f` to the power series exponential of `h`, truncated to length `n`. # The basecase version uses a simple recurrence for the coefficients, # requiring `O(nm)` operations where `m` is the length of `h`. @@ -649,26 +649,26 @@ cdef extern from "flint_wrap.h": # The underscore methods support aliasing and allow the input to be # shorter than the output, but require the lengths to be nonzero. - void _arb_poly_sin_cos_series(arb_ptr s, arb_ptr c, arb_srcptr h, slong hlen, slong n, slong prec) - void arb_poly_sin_cos_series(arb_poly_t s, arb_poly_t c, const arb_poly_t h, slong n, slong prec) + void _arb_poly_sin_cos_series(arb_ptr s, arb_ptr c, arb_srcptr h, slong hlen, slong n, slong prec) noexcept + void arb_poly_sin_cos_series(arb_poly_t s, arb_poly_t c, const arb_poly_t h, slong n, slong prec) noexcept # Sets *s* and *c* to the power series sine and cosine of *h*, computed # simultaneously. # The underscore method supports aliasing and requires the lengths to be nonzero. - void _arb_poly_sin_series(arb_ptr s, arb_srcptr h, slong hlen, slong n, slong prec) + void _arb_poly_sin_series(arb_ptr s, arb_srcptr h, slong hlen, slong n, slong prec) noexcept - void arb_poly_sin_series(arb_poly_t s, const arb_poly_t h, slong n, slong prec) + void arb_poly_sin_series(arb_poly_t s, const arb_poly_t h, slong n, slong prec) noexcept - void _arb_poly_cos_series(arb_ptr c, arb_srcptr h, slong hlen, slong n, slong prec) + void _arb_poly_cos_series(arb_ptr c, arb_srcptr h, slong hlen, slong n, slong prec) noexcept - void arb_poly_cos_series(arb_poly_t c, const arb_poly_t h, slong n, slong prec) + void arb_poly_cos_series(arb_poly_t c, const arb_poly_t h, slong n, slong prec) noexcept # Respectively evaluates the power series sine or cosine. These functions # simply wrap :func:`_arb_poly_sin_cos_series`. The underscore methods # support aliasing and require the lengths to be nonzero. - void _arb_poly_tan_series(arb_ptr g, arb_srcptr h, slong hlen, slong len, slong prec) + void _arb_poly_tan_series(arb_ptr g, arb_srcptr h, slong hlen, slong len, slong prec) noexcept - void arb_poly_tan_series(arb_poly_t g, const arb_poly_t h, slong n, slong prec) + void arb_poly_tan_series(arb_poly_t g, const arb_poly_t h, slong n, slong prec) noexcept # Sets *g* to the power series tangent of *h*. # For small *n* takes the quotient of the sine and cosine as computed # using the basecase algorithm. For large *n*, uses Newton iteration @@ -676,83 +676,83 @@ cdef extern from "flint_wrap.h": # The underscore version does not support aliasing, and requires # the lengths to be nonzero. - void _arb_poly_sin_cos_pi_series(arb_ptr s, arb_ptr c, arb_srcptr h, slong hlen, slong n, slong prec) + void _arb_poly_sin_cos_pi_series(arb_ptr s, arb_ptr c, arb_srcptr h, slong hlen, slong n, slong prec) noexcept - void arb_poly_sin_cos_pi_series(arb_poly_t s, arb_poly_t c, const arb_poly_t h, slong n, slong prec) + void arb_poly_sin_cos_pi_series(arb_poly_t s, arb_poly_t c, const arb_poly_t h, slong n, slong prec) noexcept - void _arb_poly_sin_pi_series(arb_ptr s, arb_srcptr h, slong hlen, slong n, slong prec) + void _arb_poly_sin_pi_series(arb_ptr s, arb_srcptr h, slong hlen, slong n, slong prec) noexcept - void arb_poly_sin_pi_series(arb_poly_t s, const arb_poly_t h, slong n, slong prec) + void arb_poly_sin_pi_series(arb_poly_t s, const arb_poly_t h, slong n, slong prec) noexcept - void _arb_poly_cos_pi_series(arb_ptr c, arb_srcptr h, slong hlen, slong n, slong prec) + void _arb_poly_cos_pi_series(arb_ptr c, arb_srcptr h, slong hlen, slong n, slong prec) noexcept - void arb_poly_cos_pi_series(arb_poly_t c, const arb_poly_t h, slong n, slong prec) + void arb_poly_cos_pi_series(arb_poly_t c, const arb_poly_t h, slong n, slong prec) noexcept - void _arb_poly_cot_pi_series(arb_ptr c, arb_srcptr h, slong hlen, slong n, slong prec) + void _arb_poly_cot_pi_series(arb_ptr c, arb_srcptr h, slong hlen, slong n, slong prec) noexcept - void arb_poly_cot_pi_series(arb_poly_t c, const arb_poly_t h, slong n, slong prec) + void arb_poly_cot_pi_series(arb_poly_t c, const arb_poly_t h, slong n, slong prec) noexcept # Compute the respective trigonometric functions of the input # multiplied by `\pi`. - void _arb_poly_sinh_cosh_series_basecase(arb_ptr s, arb_ptr c, arb_srcptr h, slong hlen, slong n, slong prec) + void _arb_poly_sinh_cosh_series_basecase(arb_ptr s, arb_ptr c, arb_srcptr h, slong hlen, slong n, slong prec) noexcept - void arb_poly_sinh_cosh_series_basecase(arb_poly_t s, arb_poly_t c, const arb_poly_t h, slong n, slong prec) + void arb_poly_sinh_cosh_series_basecase(arb_poly_t s, arb_poly_t c, const arb_poly_t h, slong n, slong prec) noexcept - void _arb_poly_sinh_cosh_series_exponential(arb_ptr s, arb_ptr c, arb_srcptr h, slong hlen, slong n, slong prec) + void _arb_poly_sinh_cosh_series_exponential(arb_ptr s, arb_ptr c, arb_srcptr h, slong hlen, slong n, slong prec) noexcept - void arb_poly_sinh_cosh_series_exponential(arb_poly_t s, arb_poly_t c, const arb_poly_t h, slong n, slong prec) + void arb_poly_sinh_cosh_series_exponential(arb_poly_t s, arb_poly_t c, const arb_poly_t h, slong n, slong prec) noexcept - void _arb_poly_sinh_cosh_series(arb_ptr s, arb_ptr c, arb_srcptr h, slong hlen, slong n, slong prec) + void _arb_poly_sinh_cosh_series(arb_ptr s, arb_ptr c, arb_srcptr h, slong hlen, slong n, slong prec) noexcept - void arb_poly_sinh_cosh_series(arb_poly_t s, arb_poly_t c, const arb_poly_t h, slong n, slong prec) + void arb_poly_sinh_cosh_series(arb_poly_t s, arb_poly_t c, const arb_poly_t h, slong n, slong prec) noexcept - void _arb_poly_sinh_series(arb_ptr s, arb_srcptr h, slong hlen, slong n, slong prec) + void _arb_poly_sinh_series(arb_ptr s, arb_srcptr h, slong hlen, slong n, slong prec) noexcept - void arb_poly_sinh_series(arb_poly_t s, const arb_poly_t h, slong n, slong prec) + void arb_poly_sinh_series(arb_poly_t s, const arb_poly_t h, slong n, slong prec) noexcept - void _arb_poly_cosh_series(arb_ptr c, arb_srcptr h, slong hlen, slong n, slong prec) + void _arb_poly_cosh_series(arb_ptr c, arb_srcptr h, slong hlen, slong n, slong prec) noexcept - void arb_poly_cosh_series(arb_poly_t c, const arb_poly_t h, slong n, slong prec) + void arb_poly_cosh_series(arb_poly_t c, const arb_poly_t h, slong n, slong prec) noexcept # Sets *s* and *c* respectively to the hyperbolic sine and cosine of the # power series *h*, truncated to length *n*. # The implementations mirror those for sine and cosine, except that # the *exponential* version computes both functions using the exponential # function instead of the hyperbolic tangent. - void _arb_poly_sinc_series(arb_ptr s, arb_srcptr h, slong hlen, slong n, slong prec) + void _arb_poly_sinc_series(arb_ptr s, arb_srcptr h, slong hlen, slong n, slong prec) noexcept - void arb_poly_sinc_series(arb_poly_t s, const arb_poly_t h, slong n, slong prec) + void arb_poly_sinc_series(arb_poly_t s, const arb_poly_t h, slong n, slong prec) noexcept # Sets *c* to the sinc function of the power series *h*, truncated # to length *n*. - void _arb_poly_sinc_pi_series(arb_ptr s, arb_srcptr h, slong hlen, slong n, slong prec) + void _arb_poly_sinc_pi_series(arb_ptr s, arb_srcptr h, slong hlen, slong n, slong prec) noexcept - void arb_poly_sinc_pi_series(arb_poly_t s, const arb_poly_t h, slong n, slong prec) + void arb_poly_sinc_pi_series(arb_poly_t s, const arb_poly_t h, slong n, slong prec) noexcept # Compute the sinc function of the input multiplied by `\pi`. - void _arb_poly_lambertw_series(arb_ptr res, arb_srcptr z, slong zlen, int flags, slong len, slong prec) + void _arb_poly_lambertw_series(arb_ptr res, arb_srcptr z, slong zlen, int flags, slong len, slong prec) noexcept - void arb_poly_lambertw_series(arb_poly_t res, const arb_poly_t z, int flags, slong len, slong prec) + void arb_poly_lambertw_series(arb_poly_t res, const arb_poly_t z, int flags, slong len, slong prec) noexcept # Sets *res* to the Lambert W function of the power series *z*. # If *flags* is 0, the principal branch is computed; if *flags* is 1, # the second real branch `W_{-1}(z)` is computed. # The underscore method allows aliasing, but assumes that the lengths are nonzero. - void _arb_poly_gamma_series(arb_ptr res, arb_srcptr h, slong hlen, slong n, slong prec) + void _arb_poly_gamma_series(arb_ptr res, arb_srcptr h, slong hlen, slong n, slong prec) noexcept - void arb_poly_gamma_series(arb_poly_t res, const arb_poly_t h, slong n, slong prec) + void arb_poly_gamma_series(arb_poly_t res, const arb_poly_t h, slong n, slong prec) noexcept - void _arb_poly_rgamma_series(arb_ptr res, arb_srcptr h, slong hlen, slong n, slong prec) + void _arb_poly_rgamma_series(arb_ptr res, arb_srcptr h, slong hlen, slong n, slong prec) noexcept - void arb_poly_rgamma_series(arb_poly_t res, const arb_poly_t h, slong n, slong prec) + void arb_poly_rgamma_series(arb_poly_t res, const arb_poly_t h, slong n, slong prec) noexcept - void _arb_poly_lgamma_series(arb_ptr res, arb_srcptr h, slong hlen, slong n, slong prec) + void _arb_poly_lgamma_series(arb_ptr res, arb_srcptr h, slong hlen, slong n, slong prec) noexcept - void arb_poly_lgamma_series(arb_poly_t res, const arb_poly_t h, slong n, slong prec) + void arb_poly_lgamma_series(arb_poly_t res, const arb_poly_t h, slong n, slong prec) noexcept - void _arb_poly_digamma_series(arb_ptr res, arb_srcptr h, slong hlen, slong n, slong prec) + void _arb_poly_digamma_series(arb_ptr res, arb_srcptr h, slong hlen, slong n, slong prec) noexcept - void arb_poly_digamma_series(arb_poly_t res, const arb_poly_t h, slong n, slong prec) + void arb_poly_digamma_series(arb_poly_t res, const arb_poly_t h, slong n, slong prec) noexcept # Sets *res* to the series expansion of `\Gamma(h(x))`, `1/\Gamma(h(x))`, # or `\log \Gamma(h(x))`, `\psi(h(x))`, truncated to length *n*. # These functions first generate the Taylor series at the constant @@ -763,14 +763,14 @@ cdef extern from "flint_wrap.h": # The underscore methods support aliasing of the input and output # arrays, and require that *hlen* and *n* are greater than zero. - void _arb_poly_rising_ui_series(arb_ptr res, arb_srcptr f, slong flen, ulong r, slong trunc, slong prec) + void _arb_poly_rising_ui_series(arb_ptr res, arb_srcptr f, slong flen, ulong r, slong trunc, slong prec) noexcept - void arb_poly_rising_ui_series(arb_poly_t res, const arb_poly_t f, ulong r, slong trunc, slong prec) + void arb_poly_rising_ui_series(arb_poly_t res, const arb_poly_t f, ulong r, slong trunc, slong prec) noexcept # Sets *res* to the rising factorial `(f) (f+1) (f+2) \cdots (f+r-1)`, truncated # to length *trunc*. The underscore method assumes that *flen*, *r* and *trunc* # are at least 1, and does not support aliasing. Uses binary splitting. - void arb_poly_zeta_series(arb_poly_t res, const arb_poly_t s, const arb_t a, int deflate, slong n, slong prec) + void arb_poly_zeta_series(arb_poly_t res, const arb_poly_t s, const arb_t a, int deflate, slong n, slong prec) noexcept # Sets *res* to the Hurwitz zeta function `\zeta(s,a)` where `s` a power # series and `a` is a constant, truncated to length *n*. # To evaluate the usual Riemann zeta function, set `a = 1`. @@ -783,9 +783,9 @@ cdef extern from "flint_wrap.h": # If `a = 1`, this implementation uses the reflection formula if the midpoint # of the constant term of `s` is negative. - void _arb_poly_riemann_siegel_theta_series(arb_ptr res, arb_srcptr h, slong hlen, slong n, slong prec) + void _arb_poly_riemann_siegel_theta_series(arb_ptr res, arb_srcptr h, slong hlen, slong n, slong prec) noexcept - void arb_poly_riemann_siegel_theta_series(arb_poly_t res, const arb_poly_t h, slong n, slong prec) + void arb_poly_riemann_siegel_theta_series(arb_poly_t res, const arb_poly_t h, slong n, slong prec) noexcept # Sets *res* to the series expansion of the Riemann-Siegel theta # function # .. math :: @@ -796,9 +796,9 @@ cdef extern from "flint_wrap.h": # and output arrays, and requires that the lengths are greater # than zero. - void _arb_poly_riemann_siegel_z_series(arb_ptr res, arb_srcptr h, slong hlen, slong n, slong prec) + void _arb_poly_riemann_siegel_z_series(arb_ptr res, arb_srcptr h, slong hlen, slong n, slong prec) noexcept - void arb_poly_riemann_siegel_z_series(arb_poly_t res, const arb_poly_t h, slong n, slong prec) + void arb_poly_riemann_siegel_z_series(arb_poly_t res, const arb_poly_t h, slong n, slong prec) noexcept # Sets *res* to the series expansion of the Riemann-Siegel Z-function # .. math :: # Z(h) = e^{i\theta(h)} \zeta(1/2+ih). @@ -809,9 +809,9 @@ cdef extern from "flint_wrap.h": # and output arrays, and requires that the lengths are greater # than zero. - void _arb_poly_root_bound_fujiwara(mag_t bound, arb_srcptr poly, slong len) + void _arb_poly_root_bound_fujiwara(mag_t bound, arb_srcptr poly, slong len) noexcept - void arb_poly_root_bound_fujiwara(mag_t bound, arb_poly_t poly) + void arb_poly_root_bound_fujiwara(mag_t bound, arb_poly_t poly) noexcept # Sets *bound* to an upper bound for the magnitude of all the complex # roots of *poly*. Uses Fujiwara's bound # .. math :: @@ -823,7 +823,7 @@ cdef extern from "flint_wrap.h": # \right\} # where `a_0, \ldots, a_n` are the coefficients of *poly*. - void _arb_poly_newton_convergence_factor(arf_t convergence_factor, arb_srcptr poly, slong len, const arb_t convergence_interval, slong prec) + void _arb_poly_newton_convergence_factor(arf_t convergence_factor, arb_srcptr poly, slong len, const arb_t convergence_interval, slong prec) noexcept # Given an interval `I` specified by *convergence_interval*, evaluates a bound # for `C = \sup_{t,u \in I} \frac{1}{2} |f''(t)| / |f'(u)|`, # where `f` is the polynomial defined by the coefficients *{poly, len}*. @@ -831,7 +831,7 @@ cdef extern from "flint_wrap.h": # If `f` has large coefficients, `I` must be extremely precise in order to # get a finite factor. - int _arb_poly_newton_step(arb_t xnew, arb_srcptr poly, slong len, const arb_t x, const arb_t convergence_interval, const arf_t convergence_factor, slong prec) + int _arb_poly_newton_step(arb_t xnew, arb_srcptr poly, slong len, const arb_t x, const arb_t convergence_interval, const arf_t convergence_factor, slong prec) noexcept # Performs a single step with Newton's method. # The input consists of the polynomial `f` specified by the coefficients # *{poly, len}*, an interval `x = [m-r, m+r]` known to contain a single root of `f`, @@ -849,7 +849,7 @@ cdef extern from "flint_wrap.h": # If either condition fails, we set *xnew* to `x` and return zero, # indicating that no progress was made. - void _arb_poly_newton_refine_root(arb_t r, arb_srcptr poly, slong len, const arb_t start, const arb_t convergence_interval, const arf_t convergence_factor, slong eval_extra_prec, slong prec) + void _arb_poly_newton_refine_root(arb_t r, arb_srcptr poly, slong len, const arb_t start, const arb_t convergence_interval, const arf_t convergence_factor, slong eval_extra_prec, slong prec) noexcept # Refines a precise estimate of a polynomial root to high precision # by performing several Newton steps, using nearly optimally # chosen doubling precision steps. @@ -860,9 +860,9 @@ cdef extern from "flint_wrap.h": # (typically, if the polynomial has large coefficients of alternating # signs, this needs to be approximately the bit size of the coefficients). - void _arb_poly_swinnerton_dyer_ui(arb_ptr poly, ulong n, slong trunc, slong prec) + void _arb_poly_swinnerton_dyer_ui(arb_ptr poly, ulong n, slong trunc, slong prec) noexcept - void arb_poly_swinnerton_dyer_ui(arb_poly_t poly, ulong n, slong prec) + void arb_poly_swinnerton_dyer_ui(arb_poly_t poly, ulong n, slong prec) noexcept # Computes the Swinnerton-Dyer polynomial `S_n`, which has degree `2^n` # and is the rational minimal polynomial of the sum # of the square roots of the first *n* prime numbers. diff --git a/src/sage/libs/flint/arf.pxd b/src/sage/libs/flint/arf.pxd index cdf727292c4..0f0424ecd05 100644 --- a/src/sage/libs/flint/arf.pxd +++ b/src/sage/libs/flint/arf.pxd @@ -12,121 +12,121 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void arf_init(arf_t x) + void arf_init(arf_t x) noexcept # Initializes the variable *x* for use. Its value is set to zero. - void arf_clear(arf_t x) + void arf_clear(arf_t x) noexcept # Clears the variable *x*, freeing or recycling its allocated memory. - slong arf_allocated_bytes(const arf_t x) + slong arf_allocated_bytes(const arf_t x) noexcept # Returns the total number of bytes heap-allocated internally by this object. # The count excludes the size of the structure itself. Add # ``sizeof(arf_struct)`` to get the size of the object as a whole. - void arf_zero(arf_t res) + void arf_zero(arf_t res) noexcept - void arf_one(arf_t res) + void arf_one(arf_t res) noexcept - void arf_pos_inf(arf_t res) + void arf_pos_inf(arf_t res) noexcept - void arf_neg_inf(arf_t res) + void arf_neg_inf(arf_t res) noexcept - void arf_nan(arf_t res) + void arf_nan(arf_t res) noexcept # Sets *res* respectively to 0, 1, `+\infty`, `-\infty`, NaN. - bint arf_is_zero(const arf_t x) + bint arf_is_zero(const arf_t x) noexcept - bint arf_is_one(const arf_t x) + bint arf_is_one(const arf_t x) noexcept - bint arf_is_pos_inf(const arf_t x) + bint arf_is_pos_inf(const arf_t x) noexcept - bint arf_is_neg_inf(const arf_t x) + bint arf_is_neg_inf(const arf_t x) noexcept - bint arf_is_nan(const arf_t x) + bint arf_is_nan(const arf_t x) noexcept # Returns nonzero iff *x* respectively equals 0, 1, `+\infty`, `-\infty`, NaN. - bint arf_is_inf(const arf_t x) + bint arf_is_inf(const arf_t x) noexcept # Returns nonzero iff *x* equals either `+\infty` or `-\infty`. - bint arf_is_normal(const arf_t x) + bint arf_is_normal(const arf_t x) noexcept # Returns nonzero iff *x* is a finite, nonzero floating-point value, i.e. # not one of the special values 0, `+\infty`, `-\infty`, NaN. - bint arf_is_special(const arf_t x) + bint arf_is_special(const arf_t x) noexcept # Returns nonzero iff *x* is one of the special values # 0, `+\infty`, `-\infty`, NaN, i.e. not a finite, nonzero # floating-point value. - bint arf_is_finite(const arf_t x) + bint arf_is_finite(const arf_t x) noexcept # Returns nonzero iff *x* is a finite floating-point value, # i.e. not one of the values `+\infty`, `-\infty`, NaN. # (Note that this is not equivalent to the negation of # :func:`arf_is_inf`.) - void arf_set(arf_t res, const arf_t x) + void arf_set(arf_t res, const arf_t x) noexcept - void arf_set_mpz(arf_t res, const mpz_t x) + void arf_set_mpz(arf_t res, const mpz_t x) noexcept - void arf_set_fmpz(arf_t res, const fmpz_t x) + void arf_set_fmpz(arf_t res, const fmpz_t x) noexcept - void arf_set_ui(arf_t res, ulong x) + void arf_set_ui(arf_t res, ulong x) noexcept - void arf_set_si(arf_t res, slong x) + void arf_set_si(arf_t res, slong x) noexcept - void arf_set_mpfr(arf_t res, const mpfr_t x) + void arf_set_mpfr(arf_t res, const mpfr_t x) noexcept - void arf_set_d(arf_t res, double x) + void arf_set_d(arf_t res, double x) noexcept # Sets *res* to the exact value of *x*. - void arf_swap(arf_t x, arf_t y) + void arf_swap(arf_t x, arf_t y) noexcept # Swaps *x* and *y* efficiently. - void arf_init_set_ui(arf_t res, ulong x) + void arf_init_set_ui(arf_t res, ulong x) noexcept - void arf_init_set_si(arf_t res, slong x) + void arf_init_set_si(arf_t res, slong x) noexcept # Initializes *res* and sets it to *x* in a single operation. - int arf_set_round(arf_t res, const arf_t x, slong prec, arf_rnd_t rnd) + int arf_set_round(arf_t res, const arf_t x, slong prec, arf_rnd_t rnd) noexcept - int arf_set_round_si(arf_t res, slong x, slong prec, arf_rnd_t rnd) + int arf_set_round_si(arf_t res, slong x, slong prec, arf_rnd_t rnd) noexcept - int arf_set_round_ui(arf_t res, ulong x, slong prec, arf_rnd_t rnd) + int arf_set_round_ui(arf_t res, ulong x, slong prec, arf_rnd_t rnd) noexcept - int arf_set_round_mpz(arf_t res, const mpz_t x, slong prec, arf_rnd_t rnd) + int arf_set_round_mpz(arf_t res, const mpz_t x, slong prec, arf_rnd_t rnd) noexcept - int arf_set_round_fmpz(arf_t res, const fmpz_t x, slong prec, arf_rnd_t rnd) + int arf_set_round_fmpz(arf_t res, const fmpz_t x, slong prec, arf_rnd_t rnd) noexcept # Sets *res* to *x*, rounded to *prec* bits in the direction # specified by *rnd*. - void arf_set_si_2exp_si(arf_t res, slong m, slong e) + void arf_set_si_2exp_si(arf_t res, slong m, slong e) noexcept - void arf_set_ui_2exp_si(arf_t res, ulong m, slong e) + void arf_set_ui_2exp_si(arf_t res, ulong m, slong e) noexcept - void arf_set_fmpz_2exp(arf_t res, const fmpz_t m, const fmpz_t e) + void arf_set_fmpz_2exp(arf_t res, const fmpz_t m, const fmpz_t e) noexcept # Sets *res* to `m \cdot 2^e`. - int arf_set_round_fmpz_2exp(arf_t res, const fmpz_t x, const fmpz_t e, slong prec, arf_rnd_t rnd) + int arf_set_round_fmpz_2exp(arf_t res, const fmpz_t x, const fmpz_t e, slong prec, arf_rnd_t rnd) noexcept # Sets *res* to `x \cdot 2^e`, rounded to *prec* bits in the direction # specified by *rnd*. - void arf_get_fmpz_2exp(fmpz_t m, fmpz_t e, const arf_t x) + void arf_get_fmpz_2exp(fmpz_t m, fmpz_t e, const arf_t x) noexcept # Sets *m* and *e* to the unique integers such that # `x = m \cdot 2^e` and *m* is odd, # provided that *x* is a nonzero finite fraction. # If *x* is zero, both *m* and *e* are set to zero. If *x* is # infinite or NaN, the result is undefined. - void arf_frexp(arf_t m, fmpz_t e, const arf_t x) + void arf_frexp(arf_t m, fmpz_t e, const arf_t x) noexcept # Writes *x* as `m \cdot 2^e`, where `0.5 \le |m| < 1` if *x* is a normal # value. If *x* is a special value, copies this to *m* and sets *e* to zero. # Note: for the inverse operation (*ldexp*), use :func:`arf_mul_2exp_fmpz`. - double arf_get_d(const arf_t x, arf_rnd_t rnd) + double arf_get_d(const arf_t x, arf_rnd_t rnd) noexcept # Returns *x* rounded to a double in the direction specified by *rnd*. # This method rounds correctly when overflowing or underflowing # the double exponent range (this was not the case in an earlier version). - int arf_get_mpfr(mpfr_t res, const arf_t x, mpfr_rnd_t rnd) + int arf_get_mpfr(mpfr_t res, const arf_t x, mpfr_rnd_t rnd) noexcept # Sets the MPFR variable *res* to the value of *x*. If the precision of *x* # is too small to allow *res* to be represented exactly, it is rounded in # the specified MPFR rounding mode. The return value (-1, 0 or 1) @@ -136,7 +136,7 @@ cdef extern from "flint_wrap.h": # result overflows to an infinity or underflows to a (signed) zero, # and the corresponding MPFR exception flags are set. - int arf_get_fmpz(fmpz_t res, const arf_t x, arf_rnd_t rnd) + int arf_get_fmpz(fmpz_t res, const arf_t x, arf_rnd_t rnd) noexcept # Sets *res* to *x* rounded to the nearest integer in the direction # specified by *rnd*. If rnd is *ARF_RND_NEAR*, rounds to the nearest # even integer in case of a tie. Returns inexact (beware: accordingly @@ -149,134 +149,134 @@ cdef extern from "flint_wrap.h": # memory available on the machine, resulting in swapping. It is recommended # to check that *x* is within a reasonable range before calling this method. - slong arf_get_si(const arf_t x, arf_rnd_t rnd) + slong arf_get_si(const arf_t x, arf_rnd_t rnd) noexcept # Returns *x* rounded to the nearest integer in the direction specified by # *rnd*. If *rnd* is *ARF_RND_NEAR*, rounds to the nearest even integer # in case of a tie. Aborts if *x* is infinite, NaN, or the value is # too large to fit in a slong. - int arf_get_fmpz_fixed_fmpz(fmpz_t res, const arf_t x, const fmpz_t e) + int arf_get_fmpz_fixed_fmpz(fmpz_t res, const arf_t x, const fmpz_t e) noexcept - int arf_get_fmpz_fixed_si(fmpz_t res, const arf_t x, slong e) + int arf_get_fmpz_fixed_si(fmpz_t res, const arf_t x, slong e) noexcept # Converts *x* to a mantissa with predetermined exponent, i.e. sets *res* to # an integer *y* such that `y \times 2^e \approx x`, truncating if necessary. # Returns 0 if exact and 1 if truncation occurred. # The warnings for :func:`arf_get_fmpz` apply. - void arf_floor(arf_t res, const arf_t x) + void arf_floor(arf_t res, const arf_t x) noexcept - void arf_ceil(arf_t res, const arf_t x) + void arf_ceil(arf_t res, const arf_t x) noexcept # Sets *res* to `\lfloor x \rfloor` and `\lceil x \rceil` respectively. # The result is always represented exactly, requiring no more bits to # store than the input. To round the result to a floating-point number # with a lower precision, call :func:`arf_set_round` afterwards. - void arf_get_fmpq(fmpq_t res, const arf_t x) + void arf_get_fmpq(fmpq_t res, const arf_t x) noexcept # Set *res* to the exact rational value of *x*. # This method aborts if *x* is infinite or NaN, or if the exponent of *x* # is so large that allocating memory for the result fails. - bint arf_equal(const arf_t x, const arf_t y) - bint arf_equal_si(const arf_t x, slong y) - bint arf_equal_ui(const arf_t x, ulong y) - bint arf_equal_d(const arf_t x, double y) + bint arf_equal(const arf_t x, const arf_t y) noexcept + bint arf_equal_si(const arf_t x, slong y) noexcept + bint arf_equal_ui(const arf_t x, ulong y) noexcept + bint arf_equal_d(const arf_t x, double y) noexcept # Returns nonzero iff *x* and *y* are exactly equal. NaN is not # treated specially, i.e. NaN compares as equal to itself. # For comparison with a *double*, the values -0 and +0 are # both treated as zero, and all NaN values are treated as identical. - int arf_cmp(const arf_t x, const arf_t y) + int arf_cmp(const arf_t x, const arf_t y) noexcept - int arf_cmp_si(const arf_t x, slong y) + int arf_cmp_si(const arf_t x, slong y) noexcept - int arf_cmp_ui(const arf_t x, ulong y) + int arf_cmp_ui(const arf_t x, ulong y) noexcept - int arf_cmp_d(const arf_t x, double y) + int arf_cmp_d(const arf_t x, double y) noexcept # Returns negative, zero, or positive, depending on whether *x* is # respectively smaller, equal, or greater compared to *y*. # Comparison with NaN is undefined. - int arf_cmpabs(const arf_t x, const arf_t y) + int arf_cmpabs(const arf_t x, const arf_t y) noexcept - int arf_cmpabs_ui(const arf_t x, ulong y) + int arf_cmpabs_ui(const arf_t x, ulong y) noexcept - int arf_cmpabs_d(const arf_t x, double y) + int arf_cmpabs_d(const arf_t x, double y) noexcept - int arf_cmpabs_mag(const arf_t x, const mag_t y) + int arf_cmpabs_mag(const arf_t x, const mag_t y) noexcept # Compares the absolute values of *x* and *y*. - int arf_cmp_2exp_si(const arf_t x, slong e) + int arf_cmp_2exp_si(const arf_t x, slong e) noexcept - int arf_cmpabs_2exp_si(const arf_t x, slong e) + int arf_cmpabs_2exp_si(const arf_t x, slong e) noexcept # Compares *x* (respectively its absolute value) with `2^e`. - int arf_sgn(const arf_t x) + int arf_sgn(const arf_t x) noexcept # Returns `-1`, `0` or `+1` according to the sign of *x*. The sign # of NaN is undefined. - void arf_min(arf_t res, const arf_t a, const arf_t b) + void arf_min(arf_t res, const arf_t a, const arf_t b) noexcept - void arf_max(arf_t res, const arf_t a, const arf_t b) + void arf_max(arf_t res, const arf_t a, const arf_t b) noexcept # Sets *res* respectively to the minimum and the maximum of *a* and *b*. - slong arf_bits(const arf_t x) + slong arf_bits(const arf_t x) noexcept # Returns the number of bits needed to represent the absolute value # of the mantissa of *x*, i.e. the minimum precision sufficient to represent # *x* exactly. Returns 0 if *x* is a special value. - bint arf_is_int(const arf_t x) + bint arf_is_int(const arf_t x) noexcept # Returns nonzero iff *x* is integer-valued. - bint arf_is_int_2exp_si(const arf_t x, slong e) + bint arf_is_int_2exp_si(const arf_t x, slong e) noexcept # Returns nonzero iff *x* equals `n 2^e` for some integer *n*. - void arf_abs_bound_lt_2exp_fmpz(fmpz_t res, const arf_t x) + void arf_abs_bound_lt_2exp_fmpz(fmpz_t res, const arf_t x) noexcept # Sets *res* to the smallest integer *b* such that `|x| < 2^b`. # If *x* is zero, infinity or NaN, the result is undefined. - void arf_abs_bound_le_2exp_fmpz(fmpz_t res, const arf_t x) + void arf_abs_bound_le_2exp_fmpz(fmpz_t res, const arf_t x) noexcept # Sets *res* to the smallest integer *b* such that `|x| \le 2^b`. # If *x* is zero, infinity or NaN, the result is undefined. - slong arf_abs_bound_lt_2exp_si(const arf_t x) + slong arf_abs_bound_lt_2exp_si(const arf_t x) noexcept # Returns the smallest integer *b* such that `|x| < 2^b`, clamping # the result to lie between -*ARF_PREC_EXACT* and *ARF_PREC_EXACT* # inclusive. If *x* is zero, -*ARF_PREC_EXACT* is returned, # and if *x* is infinity or NaN, *ARF_PREC_EXACT* is returned. - void arf_get_mag(mag_t res, const arf_t x) + void arf_get_mag(mag_t res, const arf_t x) noexcept # Sets *res* to an upper bound for the absolute value of *x*. - void arf_get_mag_lower(mag_t res, const arf_t x) + void arf_get_mag_lower(mag_t res, const arf_t x) noexcept # Sets *res* to a lower bound for the absolute value of *x*. - void arf_set_mag(arf_t res, const mag_t x) + void arf_set_mag(arf_t res, const mag_t x) noexcept # Sets *res* to *x*. This operation is exact. - void mag_init_set_arf(mag_t res, const arf_t x) + void mag_init_set_arf(mag_t res, const arf_t x) noexcept # Initializes *res* and sets it to an upper bound for *x*. - void mag_fast_init_set_arf(mag_t res, const arf_t x) + void mag_fast_init_set_arf(mag_t res, const arf_t x) noexcept # Initializes *res* and sets it to an upper bound for *x*. # Assumes that the exponent of *res* is small (this function is unsafe). - void arf_mag_set_ulp(mag_t res, const arf_t x, slong prec) + void arf_mag_set_ulp(mag_t res, const arf_t x, slong prec) noexcept # Sets *res* to the magnitude of the unit in the last place (ulp) of *x* # at precision *prec*. - void arf_mag_add_ulp(mag_t res, const mag_t x, const arf_t y, slong prec) + void arf_mag_add_ulp(mag_t res, const mag_t x, const arf_t y, slong prec) noexcept # Sets *res* to an upper bound for the sum of *x* and the # magnitude of the unit in the last place (ulp) of *y* # at precision *prec*. - void arf_mag_fast_add_ulp(mag_t res, const mag_t x, const arf_t y, slong prec) + void arf_mag_fast_add_ulp(mag_t res, const mag_t x, const arf_t y, slong prec) noexcept # Sets *res* to an upper bound for the sum of *x* and the # magnitude of the unit in the last place (ulp) of *y* # at precision *prec*. Assumes that all exponents are small. - void arf_init_set_shallow(arf_t z, const arf_t x) + void arf_init_set_shallow(arf_t z, const arf_t x) noexcept - void arf_init_set_mag_shallow(arf_t z, const mag_t x) + void arf_init_set_mag_shallow(arf_t z, const mag_t x) noexcept # Initializes *z* to a shallow copy of *x*. A shallow copy just involves # copying struct data (no heap allocation is performed). # The target variable *z* may not be cleared or modified in any way (it can @@ -284,150 +284,150 @@ cdef extern from "flint_wrap.h": # *x* has been cleared. Moreover, after *x* has been assigned shallowly # to *z*, no modification of *x* is permitted as slong as *z* is in use. - void arf_init_neg_shallow(arf_t z, const arf_t x) + void arf_init_neg_shallow(arf_t z, const arf_t x) noexcept - void arf_init_neg_mag_shallow(arf_t z, const mag_t x) + void arf_init_neg_mag_shallow(arf_t z, const mag_t x) noexcept # Initializes *z* shallowly to the negation of *x*. - void arf_randtest(arf_t res, flint_rand_t state, slong bits, slong mag_bits) + void arf_randtest(arf_t res, flint_rand_t state, slong bits, slong mag_bits) noexcept # Generates a finite random number whose mantissa has precision at most # *bits* and whose exponent has at most *mag_bits* bits. The # values are distributed non-uniformly: special bit patterns are generated # with high probability in order to allow the test code to exercise corner # cases. - void arf_randtest_not_zero(arf_t res, flint_rand_t state, slong bits, slong mag_bits) + void arf_randtest_not_zero(arf_t res, flint_rand_t state, slong bits, slong mag_bits) noexcept # Identical to :func:`arf_randtest`, except that zero is never produced # as an output. - void arf_randtest_special(arf_t res, flint_rand_t state, slong bits, slong mag_bits) + void arf_randtest_special(arf_t res, flint_rand_t state, slong bits, slong mag_bits) noexcept # Identical to :func:`arf_randtest`, except that the output occasionally # is set to an infinity or NaN. - void arf_urandom(arf_t res, flint_rand_t state, slong bits, arf_rnd_t rnd) + void arf_urandom(arf_t res, flint_rand_t state, slong bits, arf_rnd_t rnd) noexcept # Sets *res* to a uniformly distributed random number in the interval # `[0, 1]`. The method uses rounding from integers to floats based on the # rounding mode *rnd*. - void arf_debug(const arf_t x) + void arf_debug(const arf_t x) noexcept # Prints information about the internal representation of *x*. - void arf_print(const arf_t x) + void arf_print(const arf_t x) noexcept # Prints *x* as an integer mantissa and exponent. - void arf_printd(const arf_t x, slong d) + void arf_printd(const arf_t x, slong d) noexcept # Prints *x* as a decimal floating-point number, rounding to *d* digits. # Rounding is faithful (at most 1 ulp error). - char * arf_get_str(const arf_t x, slong d) + char * arf_get_str(const arf_t x, slong d) noexcept # Returns *x* as a decimal floating-point number, rounding to *d* digits. # Rounding is faithful (at most 1 ulp error). - void arf_fprint(FILE * file, const arf_t x) + void arf_fprint(FILE * file, const arf_t x) noexcept # Prints *x* as an integer mantissa and exponent to the stream *file*. - void arf_fprintd(FILE * file, const arf_t y, slong d) + void arf_fprintd(FILE * file, const arf_t y, slong d) noexcept # Prints *x* as a decimal floating-point number to the stream *file*, # rounding to *d* digits. # Rounding is faithful (at most 1 ulp error). - char * arf_dump_str(const arf_t x) + char * arf_dump_str(const arf_t x) noexcept # Allocates a string and writes a binary representation of *x* to it that can # be read by :func:`arf_load_str`. The returned string needs to be # deallocated with *flint_free*. - int arf_load_str(arf_t x, const char * str) + int arf_load_str(arf_t x, const char * str) noexcept # Parses *str* into *x*. Returns a nonzero value if *str* is not formatted # correctly. - int arf_dump_file(FILE * stream, const arf_t x) + int arf_dump_file(FILE * stream, const arf_t x) noexcept # Writes a binary representation of *x* to *stream* that can be read by # :func:`arf_load_file`. Returns a nonzero value if the data could not be # written. - int arf_load_file(arf_t x, FILE * stream) + int arf_load_file(arf_t x, FILE * stream) noexcept # Reads *x* from *stream*. Returns a nonzero value if the data is not # formatted correctly or the read failed. Note that the data is assumed to be # delimited by a whitespace or end-of-file, i.e., when writing multiple # values with :func:`arf_dump_file` make sure to insert a whitespace to # separate consecutive values. - void arf_abs(arf_t res, const arf_t x) + void arf_abs(arf_t res, const arf_t x) noexcept # Sets *res* to the absolute value of *x* exactly. - void arf_neg(arf_t res, const arf_t x) + void arf_neg(arf_t res, const arf_t x) noexcept # Sets *res* to `-x` exactly. - int arf_neg_round(arf_t res, const arf_t x, slong prec, arf_rnd_t rnd) + int arf_neg_round(arf_t res, const arf_t x, slong prec, arf_rnd_t rnd) noexcept # Sets *res* to `-x`. - int arf_add(arf_t res, const arf_t x, const arf_t y, slong prec, arf_rnd_t rnd) + int arf_add(arf_t res, const arf_t x, const arf_t y, slong prec, arf_rnd_t rnd) noexcept - int arf_add_si(arf_t res, const arf_t x, slong y, slong prec, arf_rnd_t rnd) + int arf_add_si(arf_t res, const arf_t x, slong y, slong prec, arf_rnd_t rnd) noexcept - int arf_add_ui(arf_t res, const arf_t x, ulong y, slong prec, arf_rnd_t rnd) + int arf_add_ui(arf_t res, const arf_t x, ulong y, slong prec, arf_rnd_t rnd) noexcept - int arf_add_fmpz(arf_t res, const arf_t x, const fmpz_t y, slong prec, arf_rnd_t rnd) + int arf_add_fmpz(arf_t res, const arf_t x, const fmpz_t y, slong prec, arf_rnd_t rnd) noexcept # Sets *res* to `x + y`. - int arf_add_fmpz_2exp(arf_t res, const arf_t x, const fmpz_t y, const fmpz_t e, slong prec, arf_rnd_t rnd) + int arf_add_fmpz_2exp(arf_t res, const arf_t x, const fmpz_t y, const fmpz_t e, slong prec, arf_rnd_t rnd) noexcept # Sets *res* to `x + y 2^e`. - int arf_sub(arf_t res, const arf_t x, const arf_t y, slong prec, arf_rnd_t rnd) + int arf_sub(arf_t res, const arf_t x, const arf_t y, slong prec, arf_rnd_t rnd) noexcept - int arf_sub_si(arf_t res, const arf_t x, slong y, slong prec, arf_rnd_t rnd) + int arf_sub_si(arf_t res, const arf_t x, slong y, slong prec, arf_rnd_t rnd) noexcept - int arf_sub_ui(arf_t res, const arf_t x, ulong y, slong prec, arf_rnd_t rnd) + int arf_sub_ui(arf_t res, const arf_t x, ulong y, slong prec, arf_rnd_t rnd) noexcept - int arf_sub_fmpz(arf_t res, const arf_t x, const fmpz_t y, slong prec, arf_rnd_t rnd) + int arf_sub_fmpz(arf_t res, const arf_t x, const fmpz_t y, slong prec, arf_rnd_t rnd) noexcept # Sets *res* to `x - y`. - void arf_mul_2exp_si(arf_t res, const arf_t x, slong e) + void arf_mul_2exp_si(arf_t res, const arf_t x, slong e) noexcept - void arf_mul_2exp_fmpz(arf_t res, const arf_t x, const fmpz_t e) + void arf_mul_2exp_fmpz(arf_t res, const arf_t x, const fmpz_t e) noexcept # Sets *res* to `x 2^e` exactly. - int arf_mul(arf_t res, const arf_t x, const arf_t y, slong prec, arf_rnd_t rnd) + int arf_mul(arf_t res, const arf_t x, const arf_t y, slong prec, arf_rnd_t rnd) noexcept - int arf_mul_ui(arf_t res, const arf_t x, ulong y, slong prec, arf_rnd_t rnd) + int arf_mul_ui(arf_t res, const arf_t x, ulong y, slong prec, arf_rnd_t rnd) noexcept - int arf_mul_si(arf_t res, const arf_t x, slong y, slong prec, arf_rnd_t rnd) + int arf_mul_si(arf_t res, const arf_t x, slong y, slong prec, arf_rnd_t rnd) noexcept - int arf_mul_mpz(arf_t res, const arf_t x, const mpz_t y, slong prec, arf_rnd_t rnd) + int arf_mul_mpz(arf_t res, const arf_t x, const mpz_t y, slong prec, arf_rnd_t rnd) noexcept - int arf_mul_fmpz(arf_t res, const arf_t x, const fmpz_t y, slong prec, arf_rnd_t rnd) + int arf_mul_fmpz(arf_t res, const arf_t x, const fmpz_t y, slong prec, arf_rnd_t rnd) noexcept # Sets *res* to `x \cdot y`. - int arf_addmul(arf_t z, const arf_t x, const arf_t y, slong prec, arf_rnd_t rnd) + int arf_addmul(arf_t z, const arf_t x, const arf_t y, slong prec, arf_rnd_t rnd) noexcept - int arf_addmul_ui(arf_t z, const arf_t x, ulong y, slong prec, arf_rnd_t rnd) + int arf_addmul_ui(arf_t z, const arf_t x, ulong y, slong prec, arf_rnd_t rnd) noexcept - int arf_addmul_si(arf_t z, const arf_t x, slong y, slong prec, arf_rnd_t rnd) + int arf_addmul_si(arf_t z, const arf_t x, slong y, slong prec, arf_rnd_t rnd) noexcept - int arf_addmul_mpz(arf_t z, const arf_t x, const mpz_t y, slong prec, arf_rnd_t rnd) + int arf_addmul_mpz(arf_t z, const arf_t x, const mpz_t y, slong prec, arf_rnd_t rnd) noexcept - int arf_addmul_fmpz(arf_t z, const arf_t x, const fmpz_t y, slong prec, arf_rnd_t rnd) + int arf_addmul_fmpz(arf_t z, const arf_t x, const fmpz_t y, slong prec, arf_rnd_t rnd) noexcept # Performs a fused multiply-add `z = z + x \cdot y`, updating *z* in-place. - int arf_submul(arf_t z, const arf_t x, const arf_t y, slong prec, arf_rnd_t rnd) + int arf_submul(arf_t z, const arf_t x, const arf_t y, slong prec, arf_rnd_t rnd) noexcept - int arf_submul_ui(arf_t z, const arf_t x, ulong y, slong prec, arf_rnd_t rnd) + int arf_submul_ui(arf_t z, const arf_t x, ulong y, slong prec, arf_rnd_t rnd) noexcept - int arf_submul_si(arf_t z, const arf_t x, slong y, slong prec, arf_rnd_t rnd) + int arf_submul_si(arf_t z, const arf_t x, slong y, slong prec, arf_rnd_t rnd) noexcept - int arf_submul_mpz(arf_t z, const arf_t x, const mpz_t y, slong prec, arf_rnd_t rnd) + int arf_submul_mpz(arf_t z, const arf_t x, const mpz_t y, slong prec, arf_rnd_t rnd) noexcept - int arf_submul_fmpz(arf_t z, const arf_t x, const fmpz_t y, slong prec, arf_rnd_t rnd) + int arf_submul_fmpz(arf_t z, const arf_t x, const fmpz_t y, slong prec, arf_rnd_t rnd) noexcept # Performs a fused multiply-subtract `z = z - x \cdot y`, updating *z* in-place. - int arf_fma(arf_t res, const arf_t x, const arf_t y, const arf_t z, slong prec, arf_rnd_t rnd) + int arf_fma(arf_t res, const arf_t x, const arf_t y, const arf_t z, slong prec, arf_rnd_t rnd) noexcept # Sets *res* to `x \cdot y + z`. This is equivalent to an *addmul* except # that *res* and *z* can be separate variables. - int arf_sosq(arf_t res, const arf_t x, const arf_t y, slong prec, arf_rnd_t rnd) + int arf_sosq(arf_t res, const arf_t x, const arf_t y, slong prec, arf_rnd_t rnd) noexcept # Sets *res* to `x^2 + y^2`, rounded to *prec* bits in the direction specified by *rnd*. - int arf_sum(arf_t res, arf_srcptr terms, slong len, slong prec, arf_rnd_t rnd) + int arf_sum(arf_t res, arf_srcptr terms, slong len, slong prec, arf_rnd_t rnd) noexcept # Sets *res* to the sum of the array *terms* of length *len*, rounded to # *prec* bits in the direction specified by *rnd*. The sum is computed as if # done without any intermediate rounding error, with only a single rounding @@ -436,52 +436,52 @@ cdef extern from "flint_wrap.h": # the terms are far apart. Warning: this function is implemented naively, # and the running time is quadratic with respect to *len* in the worst case. - void arf_approx_dot(arf_t res, const arf_t initial, int subtract, arf_srcptr x, slong xstep, arf_srcptr y, slong ystep, slong len, slong prec, arf_rnd_t rnd) + void arf_approx_dot(arf_t res, const arf_t initial, int subtract, arf_srcptr x, slong xstep, arf_srcptr y, slong ystep, slong len, slong prec, arf_rnd_t rnd) noexcept # Computes an approximate dot product, with the same meaning of # the parameters as :func:`arb_dot`. # This operation is not correctly rounded: the final rounding is done # in the direction ``rnd`` but intermediate roundings are # implementation-defined. - int arf_div(arf_t res, const arf_t x, const arf_t y, slong prec, arf_rnd_t rnd) + int arf_div(arf_t res, const arf_t x, const arf_t y, slong prec, arf_rnd_t rnd) noexcept - int arf_div_ui(arf_t res, const arf_t x, ulong y, slong prec, arf_rnd_t rnd) + int arf_div_ui(arf_t res, const arf_t x, ulong y, slong prec, arf_rnd_t rnd) noexcept - int arf_ui_div(arf_t res, ulong x, const arf_t y, slong prec, arf_rnd_t rnd) + int arf_ui_div(arf_t res, ulong x, const arf_t y, slong prec, arf_rnd_t rnd) noexcept - int arf_div_si(arf_t res, const arf_t x, slong y, slong prec, arf_rnd_t rnd) + int arf_div_si(arf_t res, const arf_t x, slong y, slong prec, arf_rnd_t rnd) noexcept - int arf_si_div(arf_t res, slong x, const arf_t y, slong prec, arf_rnd_t rnd) + int arf_si_div(arf_t res, slong x, const arf_t y, slong prec, arf_rnd_t rnd) noexcept - int arf_div_fmpz(arf_t res, const arf_t x, const fmpz_t y, slong prec, arf_rnd_t rnd) + int arf_div_fmpz(arf_t res, const arf_t x, const fmpz_t y, slong prec, arf_rnd_t rnd) noexcept - int arf_fmpz_div(arf_t res, const fmpz_t x, const arf_t y, slong prec, arf_rnd_t rnd) + int arf_fmpz_div(arf_t res, const fmpz_t x, const arf_t y, slong prec, arf_rnd_t rnd) noexcept - int arf_fmpz_div_fmpz(arf_t res, const fmpz_t x, const fmpz_t y, slong prec, arf_rnd_t rnd) + int arf_fmpz_div_fmpz(arf_t res, const fmpz_t x, const fmpz_t y, slong prec, arf_rnd_t rnd) noexcept # Sets *res* to `x / y`, rounded to *prec* bits in the direction specified by *rnd*, # returning nonzero iff the operation is inexact. The result is NaN if *y* is zero. - int arf_sqrt(arf_t res, const arf_t x, slong prec, arf_rnd_t rnd) + int arf_sqrt(arf_t res, const arf_t x, slong prec, arf_rnd_t rnd) noexcept - int arf_sqrt_ui(arf_t res, ulong x, slong prec, arf_rnd_t rnd) + int arf_sqrt_ui(arf_t res, ulong x, slong prec, arf_rnd_t rnd) noexcept - int arf_sqrt_fmpz(arf_t res, const fmpz_t x, slong prec, arf_rnd_t rnd) + int arf_sqrt_fmpz(arf_t res, const fmpz_t x, slong prec, arf_rnd_t rnd) noexcept # Sets *res* to `\sqrt{x}`. The result is NaN if *x* is negative. - int arf_rsqrt(arf_t res, const arf_t x, slong prec, arf_rnd_t rnd) + int arf_rsqrt(arf_t res, const arf_t x, slong prec, arf_rnd_t rnd) noexcept # Sets *res* to `1/\sqrt{x}`. The result is NaN if *x* is # negative, and `+\infty` if *x* is zero. - int arf_root(arf_t res, const arf_t x, ulong k, slong prec, arf_rnd_t rnd) + int arf_root(arf_t res, const arf_t x, ulong k, slong prec, arf_rnd_t rnd) noexcept # Sets *res* to `x^{1/k}`. The result is NaN if *x* is negative. # Warning: this function is a wrapper around the MPFR root function. # It gets slow and uses much memory for large *k*. # Consider working with :func:`arb_root_ui` for large *k* instead of using this # function directly. - 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(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) noexcept - 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_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) noexcept # Computes the complex product `e + fi = (a + bi)(c + di)`, rounding both # `e` and `f` correctly to *prec* bits in the direction specified by *rnd*. # The first bit in the return code indicates inexactness of `e`, and the @@ -493,12 +493,12 @@ cdef extern from "flint_wrap.h": # The *fallback* version is implemented naively, for testing purposes. # No squaring optimization is implemented. - 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_complex_sqr(arf_t e, arf_t f, const arf_t a, const arf_t b, slong prec, arf_rnd_t rnd) noexcept # Computes the complex square `e + fi = (a + bi)^2`. This function has # identical semantics to :func:`arf_complex_mul` (with `c = a, b = d`), # but is faster. - int _arf_get_integer_mpn(mp_ptr y, mp_srcptr xp, mp_size_t xn, slong exp) + int _arf_get_integer_mpn(mp_ptr y, mp_srcptr xp, mp_size_t xn, slong exp) noexcept # Given a floating-point number *x* represented by *xn* limbs at *xp* # and an exponent *exp*, writes the integer part of *x* to # *y*, returning whether the result is inexact. @@ -507,7 +507,7 @@ cdef extern from "flint_wrap.h": # Assumes that ``xp[0]`` is nonzero and that the # top bit of ``xp[xn-1]`` is set. - 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_mpn_fixed(arf_t z, mp_srcptr xp, mp_size_t xn, mp_size_t fixn, int negative, slong prec, arf_rnd_t rnd) noexcept # Sets *z* to the fixed-point number having *xn* total limbs and *fixn* # fractional limbs, negated if *negative* is set, rounding *z* to *prec* # bits in the direction *rnd* and returning whether the result is inexact. @@ -515,18 +515,18 @@ cdef extern from "flint_wrap.h": # that the bit shift would overflow an *slong*, but otherwise no # assumptions are made about the input. - int _arf_set_round_ui(arf_t z, ulong x, int sgnbit, slong prec, arf_rnd_t rnd) + int _arf_set_round_ui(arf_t z, ulong x, int sgnbit, slong prec, arf_rnd_t rnd) noexcept # Sets *z* to the integer *x*, negated if *sgnbit* is 1, rounded to *prec* # bits in the direction specified by *rnd*. There are no assumptions on *x*. - 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_uiui(arf_t z, slong * fix, mp_limb_t hi, mp_limb_t lo, int sgnbit, slong prec, arf_rnd_t rnd) noexcept # Sets the mantissa of *z* to the two-limb mantissa given by *hi* and *lo*, # negated if *sgnbit* is 1, rounded to *prec* bits in the direction specified # by *rnd*. Requires that not both *hi* and *lo* are zero. # Writes the exponent shift to *fix* without writing the exponent of *z* # directly. - 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) + 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) noexcept # Sets the mantissa of *z* to the mantissa given by the *xn* limbs in *x*, # negated if *sgnbit* is 1, rounded to *prec* bits in the direction # specified by *rnd*. Returns the inexact flag. Requires that *xn* is positive diff --git a/src/sage/libs/flint/arith.pxd b/src/sage/libs/flint/arith.pxd index 120fc49f6bd..5a4b5f3d06d 100644 --- a/src/sage/libs/flint/arith.pxd +++ b/src/sage/libs/flint/arith.pxd @@ -12,19 +12,19 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void arith_primorial(fmpz_t res, slong n) + void arith_primorial(fmpz_t res, slong n) noexcept # Sets ``res`` to ``n`` primorial or `n \#`, the product of all prime # numbers less than or equal to `n`. - void _arith_harmonic_number(fmpz_t num, fmpz_t den, slong n) - void arith_harmonic_number(fmpq_t x, slong n) + void _arith_harmonic_number(fmpz_t num, fmpz_t den, slong n) noexcept + void arith_harmonic_number(fmpq_t x, slong n) noexcept # These are aliases for the functions in the fmpq module. - void arith_stirling_number_1u(fmpz_t s, ulong n, ulong k) + void arith_stirling_number_1u(fmpz_t s, ulong n, ulong k) noexcept - void arith_stirling_number_1(fmpz_t s, ulong n, ulong k) + void arith_stirling_number_1(fmpz_t s, ulong n, ulong k) noexcept - void arith_stirling_number_2(fmpz_t s, ulong n, ulong k) + void arith_stirling_number_2(fmpz_t s, ulong n, ulong k) noexcept # Sets `s` to `S(n,k)` where `S(n,k)` denotes an unsigned Stirling # number of the first kind `|S_1(n, k)|`, a signed Stirling number # of the first kind `S_1(n, k)`, or a Stirling number of the second @@ -41,21 +41,21 @@ cdef extern from "flint_wrap.h": # numbers efficiently. To compute a range of numbers, the vector or # matrix versions should generally be used. - void arith_stirling_number_1u_vec(fmpz * row, ulong n, slong klen) + void arith_stirling_number_1u_vec(fmpz * row, ulong n, slong klen) noexcept - void arith_stirling_number_1_vec(fmpz * row, ulong n, slong klen) + void arith_stirling_number_1_vec(fmpz * row, ulong n, slong klen) noexcept - void arith_stirling_number_2_vec(fmpz * row, ulong n, slong klen) + void arith_stirling_number_2_vec(fmpz * row, ulong n, slong klen) noexcept # Computes the row of Stirling numbers # ``S(n,0), S(n,1), S(n,2), ..., S(n,klen-1)``. # To compute a full row, this function can be called with # ``klen = n+1``. It is assumed that ``klen`` is at most `n + 1`. - void arith_stirling_number_1u_vec_next(fmpz * row, const fmpz * prev, slong n, slong klen) + void arith_stirling_number_1u_vec_next(fmpz * row, const fmpz * prev, slong n, slong klen) noexcept - void arith_stirling_number_1_vec_next(fmpz * row, const fmpz * prev, slong n, slong klen) + void arith_stirling_number_1_vec_next(fmpz * row, const fmpz * prev, slong n, slong klen) noexcept - void arith_stirling_number_2_vec_next(fmpz * row, const fmpz * prev, slong n, slong klen) + void arith_stirling_number_2_vec_next(fmpz * row, const fmpz * prev, slong n, slong klen) noexcept # Given the vector ``prev`` containing a row of Stirling numbers # ``S(n-1,0), S(n-1,1), S(n-1,2), ..., S(n-1,klen-1)``, computes # and stores in the row argument @@ -67,11 +67,11 @@ cdef extern from "flint_wrap.h": # The ``row`` and ``prev`` arguments are permitted to be the # same, meaning that the row will be updated in-place. - void arith_stirling_matrix_1u(fmpz_mat_t mat) + void arith_stirling_matrix_1u(fmpz_mat_t mat) noexcept - void arith_stirling_matrix_1(fmpz_mat_t mat) + void arith_stirling_matrix_1(fmpz_mat_t mat) noexcept - void arith_stirling_matrix_2(fmpz_mat_t mat) + void arith_stirling_matrix_2(fmpz_mat_t mat) noexcept # For an arbitrary `m`-by-`n` matrix, writes the truncation of the # infinite Stirling number matrix:: # row 0 : S(0,0) @@ -83,9 +83,9 @@ cdef extern from "flint_wrap.h": # For any `n`, the `S_1` and `S_2` matrices thus obtained are # inverses of each other. - void arith_bell_number(fmpz_t b, ulong n) - void arith_bell_number_dobinski(fmpz_t res, ulong n) - void arith_bell_number_multi_mod(fmpz_t res, ulong n) + void arith_bell_number(fmpz_t b, ulong n) noexcept + void arith_bell_number_dobinski(fmpz_t res, ulong n) noexcept + void arith_bell_number_multi_mod(fmpz_t res, ulong n) noexcept # Sets `b` to the Bell number `B_n`, defined as the # number of partitions of a set with `n` members. Equivalently, # `B_n = \sum_{k=0}^n S_2(n,k)` where `S_2(n,k)` denotes a Stirling number @@ -104,9 +104,9 @@ cdef extern from "flint_wrap.h": # A bound for the number of needed primes is computed using # ``arith_bell_number_size``. - void arith_bell_number_vec(fmpz * b, slong n) - void arith_bell_number_vec_recursive(fmpz * b, slong n) - void arith_bell_number_vec_multi_mod(fmpz * b, slong n) + void arith_bell_number_vec(fmpz * b, slong n) noexcept + void arith_bell_number_vec_recursive(fmpz * b, slong n) noexcept + void arith_bell_number_vec_multi_mod(fmpz * b, slong n) noexcept # Sets `b` to the vector of Bell numbers `B_0, B_1, \ldots, B_{n-1}` # inclusive. The ``recursive`` version uses the `O(n^3 \log n)` # triangular recurrence, while the ``multi_mod`` version implements @@ -114,7 +114,7 @@ cdef extern from "flint_wrap.h": # running in time `O(n^2 \log^{O(1)} n)`. The default version # chooses an algorithm automatically. - mp_limb_t arith_bell_number_nmod(ulong n, nmod_t mod) + mp_limb_t arith_bell_number_nmod(ulong n, nmod_t mod) noexcept # Computes the Bell number `B_n` modulo an integer given by ``mod``. # After handling special cases, we use the formula # .. math :: @@ -128,10 +128,10 @@ cdef extern from "flint_wrap.h": # calling ``arith_bell_number_nmod_vec`` and reading the last # coefficient. - 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) + void arith_bell_number_nmod_vec(mp_ptr b, slong n, nmod_t mod) noexcept + void arith_bell_number_nmod_vec_recursive(mp_ptr b, slong n, nmod_t mod) noexcept + void arith_bell_number_nmod_vec_ogf(mp_ptr b, slong n, nmod_t mod) noexcept + int arith_bell_number_nmod_vec_series(mp_ptr b, slong n, nmod_t mod) noexcept # Sets `b` to the vector of Bell numbers `B_0, B_1, \ldots, B_{n-1}` # inclusive modulo an integer given by ``mod``. # The *recursive* version uses the `O(n^2)` triangular recurrence. @@ -146,36 +146,36 @@ cdef extern from "flint_wrap.h": # The default version of this function selects an algorithm # automatically. - double arith_bell_number_size(ulong n) + double arith_bell_number_size(ulong n) noexcept # Returns `b` such that `B_n < 2^{\lfloor b \rfloor}`. A previous # version of this function used the inequality # `B_n < \left(\frac{0.792n}{\log(n+1)}\right)^n` which is given # in [BerTas2010]_; we now use a slightly better bound # based on an asymptotic expansion. - void _arith_bernoulli_number(fmpz_t num, fmpz_t den, ulong n) + void _arith_bernoulli_number(fmpz_t num, fmpz_t den, ulong n) noexcept # Sets ``(num, den)`` to the reduced numerator and denominator # of the `n`-th Bernoulli number. - void arith_bernoulli_number(fmpq_t x, ulong n) + void arith_bernoulli_number(fmpq_t x, ulong n) noexcept # Sets ``x`` to the `n`-th Bernoulli number. This function is # equivalent to ``_arith_bernoulli_number`` apart from the output # being a single ``fmpq_t`` variable. - void _arith_bernoulli_number_vec(fmpz * num, fmpz * den, slong n) + void _arith_bernoulli_number_vec(fmpz * num, fmpz * den, slong n) noexcept # Sets the elements of ``num`` and ``den`` to the reduced # numerators and denominators of the Bernoulli numbers # `B_0, B_1, B_2, \ldots, B_{n-1}` inclusive. This function automatically # chooses between the ``recursive``, ``zeta`` and ``multi_mod`` # algorithms according to the size of `n`. - void arith_bernoulli_number_vec(fmpq * x, slong n) + void arith_bernoulli_number_vec(fmpq * x, slong n) noexcept # Sets the ``x`` to the vector of Bernoulli numbers # `B_0, B_1, B_2, \ldots, B_{n-1}` inclusive. This function is # equivalent to ``_arith_bernoulli_number_vec`` apart # from the output being a single ``fmpq`` vector. - void arith_bernoulli_number_denom(fmpz_t den, ulong n) + void arith_bernoulli_number_denom(fmpz_t den, ulong n) noexcept # Sets ``den`` to the reduced denominator of the `n`-th # Bernoulli number `B_n`. For even `n`, the denominator is computed # as the product of all primes `p` for which `p - 1` divides `n`; @@ -184,20 +184,20 @@ cdef extern from "flint_wrap.h": # `B_n = 0`). The initial sequence of values smaller than `2^{32}` are # looked up directly from a table. - double arith_bernoulli_number_size(ulong n) + double arith_bernoulli_number_size(ulong n) noexcept # Returns `b` such that `|B_n| < 2^{\lfloor b \rfloor}`, using the inequality # `|B_n| < \frac{4 n!}{(2\pi)^n}` and `n! \le (n+1)^{n+1} e^{-n}`. # No special treatment is given to odd `n`. Accuracy is not guaranteed # if `n > 10^{14}`. - void arith_bernoulli_polynomial(fmpq_poly_t poly, ulong n) + void arith_bernoulli_polynomial(fmpq_poly_t poly, ulong n) noexcept # Sets ``poly`` to the Bernoulli polynomial of degree `n`, # `B_n(x) = \sum_{k=0}^n \binom{n}{k} B_k x^{n-k}` where `B_k` # is a Bernoulli number. This function basically calls # ``arith_bernoulli_number_vec`` and then rescales the coefficients # efficiently. - void _arith_bernoulli_number_vec_recursive(fmpz * num, fmpz * den, slong n) + void _arith_bernoulli_number_vec_recursive(fmpz * num, fmpz * den, slong n) noexcept # Sets the elements of ``num`` and ``den`` to the reduced # numerators and denominators of `B_0, B_1, B_2, \ldots, B_{n-1}` # inclusive. @@ -211,7 +211,7 @@ cdef extern from "flint_wrap.h": # as the primorial of `n + 1`. # %[1] https://en.wikipedia.org/w/index.php?title=Bernoulli_number&oldid=405938876 - void _arith_bernoulli_number_vec_multi_mod(fmpz * num, fmpz * den, slong n) + void _arith_bernoulli_number_vec_multi_mod(fmpz * num, fmpz * den, slong n) noexcept # Sets the elements of ``num`` and ``den`` to the reduced # numerators and denominators of `B_0, B_1, B_2, \ldots, B_{n-1}` # inclusive. Uses the generating function @@ -225,10 +225,10 @@ cdef extern from "flint_wrap.h": # half of the time compared to the usual generating function `x/(e^x-1)` # since the odd terms vanish. - void arith_euler_number(fmpz_t res, ulong n) + void arith_euler_number(fmpz_t res, ulong n) noexcept # Sets ``res`` to the Euler number `E_n`. - void arith_euler_number_vec(fmpz * res, slong n) + void arith_euler_number_vec(fmpz * res, slong n) noexcept # Computes the Euler numbers `E_0, E_1, \dotsc, E_{n-1}` for `n \geq 0` # and stores the result in ``res``, which must be an initialised # ``fmpz`` vector of sufficient size. @@ -238,13 +238,13 @@ cdef extern from "flint_wrap.h": # ``arith_euler_number_size``, and the final integer values are recovered # using balanced CRT reconstruction. - double arith_euler_number_size(ulong n) + double arith_euler_number_size(ulong n) noexcept # Returns `b` such that `|E_n| < 2^{\lfloor b \rfloor}`, using the inequality # ``|E_n| < \frac{2^{n+2} n!}{\pi^{n+1}}`` and `n! \le (n+1)^{n+1} e^{-n}`. # No special treatment is given to odd `n`. # Accuracy is not guaranteed if `n > 10^{14}`. - void arith_euler_polynomial(fmpq_poly_t poly, ulong n) + void arith_euler_polynomial(fmpq_poly_t poly, ulong n) noexcept # Sets ``poly`` to the Euler polynomial `E_n(x)`. Uses the formula # .. math :: # E_n(x) = \frac{2}{n+1}\left(B_{n+1}(x) - @@ -252,16 +252,16 @@ cdef extern from "flint_wrap.h": # with the Bernoulli polynomial `B_{n+1}(x)` evaluated once # using ``bernoulli_polynomial`` and then rescaled. - 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_euler_phi(fmpz_t res, const fmpz_t n) noexcept + int arith_moebius_mu(const fmpz_t n) noexcept + void arith_divisor_sigma(fmpz_t res, ulong k, const fmpz_t n) noexcept # These are aliases for the functions in the fmpz module. - void arith_divisors(fmpz_poly_t res, const fmpz_t n) + void arith_divisors(fmpz_poly_t res, const fmpz_t n) noexcept # Set the coefficients of the polynomial ``res`` to the divisors of `n`, # including `1` and `n` itself, in ascending order. - void arith_ramanujan_tau(fmpz_t res, const fmpz_t n) + void arith_ramanujan_tau(fmpz_t res, const fmpz_t n) noexcept # Sets ``res`` to the Ramanujan tau function `\tau(n)` which is the # coefficient of `q^n` in the series expansion of # `f(q) = q \prod_{k \geq 1} \bigl(1 - q^k\bigr)^{24}`. @@ -276,7 +276,7 @@ cdef extern from "flint_wrap.h": # could be accomplished using a lookup table or by calling # ``arith_ramanujan_tau_series()`` directly. - void arith_ramanujan_tau_series(fmpz_poly_t res, slong n) + void arith_ramanujan_tau_series(fmpz_poly_t res, slong n) noexcept # Sets ``res`` to the polynomial with coefficients # `\tau(0),\tau(1), \dotsc, \tau(n-1)`, giving the initial `n` terms # in the series expansion of @@ -287,7 +287,7 @@ cdef extern from "flint_wrap.h": # which is evaluated using three squarings. The first squaring is done # directly since the polynomial is very sparse at this point. - void arith_landau_function_vec(fmpz * res, slong len) + void arith_landau_function_vec(fmpz * res, slong len) noexcept # Computes the first ``len`` values of Landau's function `g(n)` # starting with `g(0)`. Landau's function gives the largest order # of an element of the symmetric group `S_n`. @@ -295,23 +295,23 @@ cdef extern from "flint_wrap.h": # [DelegliseNicolasZimmermann2009]_. The running time is # `O(n^{3/2} / \sqrt{\log n})`. - 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_dedekind_sum_naive(fmpq_t s, const fmpz_t h, const fmpz_t k) noexcept + double arith_dedekind_sum_coprime_d(double h, double k) noexcept + void arith_dedekind_sum_coprime_large(fmpq_t s, const fmpz_t h, const fmpz_t k) noexcept + void arith_dedekind_sum_coprime(fmpq_t s, const fmpz_t h, const fmpz_t k) noexcept + void arith_dedekind_sum(fmpq_t s, const fmpz_t h, const fmpz_t k) noexcept # These are aliases for the functions in the fmpq module. - void arith_number_of_partitions_vec(fmpz * res, slong len) + void arith_number_of_partitions_vec(fmpz * res, slong len) noexcept # Computes first ``len`` values of the partition function `p(n)` # starting with `p(0)`. Uses inversion of Euler's pentagonal series. - void arith_number_of_partitions_nmod_vec(mp_ptr res, slong len, nmod_t mod) + void arith_number_of_partitions_nmod_vec(mp_ptr res, slong len, nmod_t mod) noexcept # Computes first ``len`` values of the partition function `p(n)` # starting with `p(0)`, modulo the modulus defined by ``mod``. # Uses inversion of Euler's pentagonal series. - void arith_hrr_expsum_factored(trig_prod_t prod, mp_limb_t k, mp_limb_t n) + void arith_hrr_expsum_factored(trig_prod_t prod, mp_limb_t k, mp_limb_t n) noexcept # Symbolically evaluates the exponential sum # .. math :: # A_k(n) = \sum_{h=0}^{k-1} @@ -328,7 +328,7 @@ cdef extern from "flint_wrap.h": # If `n` is larger, it can be pre-reduced modulo `k`, since `A_k(n)` # only depends on the value of `n \bmod k`. - void arith_number_of_partitions_mpfr(mpfr_t x, ulong n) + void arith_number_of_partitions_mpfr(mpfr_t x, ulong n) noexcept # Sets the pre-initialised MPFR variable `x` to the exact value of `p(n)`. # The value is computed using the Hardy-Ramanujan-Rademacher formula. # The precision of `x` will be changed to allow `p(n)` to be represented @@ -375,13 +375,13 @@ cdef extern from "flint_wrap.h": # which gets added to the main sum periodically, in order to avoid # costly updates of the full-precision result when `n` is large. - void arith_number_of_partitions(fmpz_t x, ulong n) + void arith_number_of_partitions(fmpz_t x, ulong n) noexcept # Sets `x` to `p(n)`, the number of ways that `n` can be written # as a sum of positive integers without regard to order. # This function uses a lookup table for `n < 128` (where `p(n) < 2^{32}`), # and otherwise calls ``arith_number_of_partitions_mpfr``. - void arith_sum_of_squares(fmpz_t r, ulong k, const fmpz_t n) + void arith_sum_of_squares(fmpz_t r, ulong k, const fmpz_t n) noexcept # Sets `r` to the number of ways `r_k(n)` in which `n` can be represented # as a sum of `k` squares. # If `k = 2` or `k = 4`, we write `r_k(n)` as a divisor sum. @@ -389,7 +389,7 @@ cdef extern from "flint_wrap.h": # expansion up to `O(x^{n+1})` and read off the last coefficient. # This is generally optimal. - void arith_sum_of_squares_vec(fmpz * r, ulong k, slong n) + void arith_sum_of_squares_vec(fmpz * r, ulong k, slong n) noexcept # For `i = 0, 1, \ldots, n-1`, sets `r_i` to the number of # representations of `i` a sum of `k` squares, `r_k(i)`. # This effectively computes the `q`-expansion of `\vartheta_3(q)` diff --git a/src/sage/libs/flint/bernoulli.pxd b/src/sage/libs/flint/bernoulli.pxd index f94efba16b4..fa07fb100e0 100644 --- a/src/sage/libs/flint/bernoulli.pxd +++ b/src/sage/libs/flint/bernoulli.pxd @@ -12,20 +12,20 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void bernoulli_rev_init(bernoulli_rev_t it, ulong n) + void bernoulli_rev_init(bernoulli_rev_t it, ulong n) noexcept # Initializes the iterator *iter*. The first Bernoulli number to # be generated by calling :func:`bernoulli_rev_next` is `B_n`. # It is assumed that `n` is even. - void bernoulli_rev_next(fmpz_t numer, fmpz_t denom, bernoulli_rev_t it) + void bernoulli_rev_next(fmpz_t numer, fmpz_t denom, bernoulli_rev_t it) noexcept # Sets *numer* and *denom* to the exact, reduced numerator and denominator # of the Bernoulli number `B_k` and advances the state of *iter* # so that the next invocation generates `B_{k-2}`. - void bernoulli_rev_clear(bernoulli_rev_t it) + void bernoulli_rev_clear(bernoulli_rev_t it) noexcept # Frees all memory allocated internally by *iter*. - void bernoulli_fmpq_vec_no_cache(fmpq * res, ulong a, slong num) + void bernoulli_fmpq_vec_no_cache(fmpq * res, ulong a, slong num) noexcept # Writes *num* consecutive Bernoulli numbers to *res* starting # with `B_a`. This function is not currently optimized for a small # count *num*. The entries are not read from or written @@ -36,13 +36,13 @@ cdef extern from "flint_wrap.h": # This function is a wrapper for the *rev* iterators. It can use # multiple threads internally. - void bernoulli_cache_compute(slong n) + void bernoulli_cache_compute(slong n) noexcept # Makes sure that the Bernoulli numbers up to at least `B_{n-1}` are cached. # Calling :func:`flint_cleanup()` frees the cache. # The cache is extended by calling :func:`bernoulli_fmpq_vec_no_cache` # internally. - slong bernoulli_bound_2exp_si(ulong n) + slong bernoulli_bound_2exp_si(ulong n) noexcept # Returns an integer `b` such that `|B_n| \le 2^b`. Uses a lookup table # for small `n`, and for larger `n` uses the inequality # `|B_n| < 4 n! / (2 \pi)^n < 4 (n+1)^{n+1} e^{-n} / (2 \pi)^n`. @@ -54,14 +54,14 @@ cdef extern from "flint_wrap.h": # comfortably compute `B_n` exactly. It aborts if `n` is so large that # internal overflow occurs. - ulong bernoulli_mod_p_harvey(ulong n, ulong p) + ulong bernoulli_mod_p_harvey(ulong n, ulong p) noexcept # Returns the `B_n` modulo the prime number *p*, computed using # Harvey's algorithm [Har2010]_. The running time is linear in *p*. # If *p* divides the numerator of `B_n`, *UWORD_MAX* is returned # as an error code. - void _bernoulli_fmpq_ui_zeta(fmpz_t num, fmpz_t den, ulong n) - void _bernoulli_fmpq_ui_multi_mod(fmpz_t num, fmpz_t den, ulong n, double alpha) + void _bernoulli_fmpq_ui_zeta(fmpz_t num, fmpz_t den, ulong n) noexcept + void _bernoulli_fmpq_ui_multi_mod(fmpz_t num, fmpz_t den, ulong n, double alpha) noexcept # Sets *num* and *den* to the reduced numerator and denominator # of the Bernoulli number `B_n`. # The *zeta* version computes the denominator `d` using the von Staudt-Clausen @@ -73,8 +73,8 @@ cdef extern from "flint_wrap.h": # 0 and 1 controlling the number of bits to compute by the multimodular # algorithm. If set to a negative number, a default value will be used. - void _bernoulli_fmpq_ui(fmpz_t num, fmpz_t den, ulong n) - void bernoulli_fmpq_ui(fmpq_t b, ulong n) + void _bernoulli_fmpq_ui(fmpz_t num, fmpz_t den, ulong n) noexcept + void bernoulli_fmpq_ui(fmpq_t b, ulong n) noexcept # Computes the Bernoulli number `B_n` as an exact fraction, for an # isolated integer `n`. This function reads `B_n` from the global cache # if the number is already cached, but does not automatically extend diff --git a/src/sage/libs/flint/bool_mat.pxd b/src/sage/libs/flint/bool_mat.pxd index 214df9bc4dc..11ecdb2809d 100644 --- a/src/sage/libs/flint/bool_mat.pxd +++ b/src/sage/libs/flint/bool_mat.pxd @@ -12,125 +12,125 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - int bool_mat_get_entry(const bool_mat_t mat, slong i, slong j) + int bool_mat_get_entry(const bool_mat_t mat, slong i, slong j) noexcept # Returns the entry of matrix *mat* at row *i* and column *j*. - void bool_mat_set_entry(bool_mat_t mat, slong i, slong j, int x) + void bool_mat_set_entry(bool_mat_t mat, slong i, slong j, int x) noexcept # Sets the entry of matrix *mat* at row *i* and column *j* to *x*. - void bool_mat_init(bool_mat_t mat, slong r, slong c) + void bool_mat_init(bool_mat_t mat, slong r, slong c) noexcept # Initializes the matrix, setting it to the zero matrix with *r* rows # and *c* columns. - void bool_mat_clear(bool_mat_t mat) + void bool_mat_clear(bool_mat_t mat) noexcept # Clears the matrix, deallocating all entries. - bint bool_mat_is_empty(const bool_mat_t mat) + bint bool_mat_is_empty(const bool_mat_t mat) noexcept # Returns nonzero iff the number of rows or the number of columns in *mat* # is zero. Note that this does not depend on the entry values of *mat*. - bint bool_mat_is_square(const bool_mat_t mat) + bint bool_mat_is_square(const bool_mat_t mat) noexcept # Returns nonzero iff the number of rows is equal to the number of columns in *mat*. - void bool_mat_set(bool_mat_t dest, const bool_mat_t src) + void bool_mat_set(bool_mat_t dest, const bool_mat_t src) noexcept # Sets *dest* to *src*. The operands must have identical dimensions. - void bool_mat_print(const bool_mat_t mat) + void bool_mat_print(const bool_mat_t mat) noexcept # Prints each entry in the matrix. - void bool_mat_fprint(FILE * file, const bool_mat_t mat) + void bool_mat_fprint(FILE * file, const bool_mat_t mat) noexcept # Prints each entry in the matrix to the stream *file*. - bint bool_mat_equal(const bool_mat_t mat1, const bool_mat_t mat2) + bint bool_mat_equal(const bool_mat_t mat1, const bool_mat_t mat2) noexcept # Returns nonzero iff the matrices have the same dimensions # and identical entries. - int bool_mat_any(const bool_mat_t mat) + int bool_mat_any(const bool_mat_t mat) noexcept # Returns nonzero iff *mat* has a nonzero entry. - int bool_mat_all(const bool_mat_t mat) + int bool_mat_all(const bool_mat_t mat) noexcept # Returns nonzero iff all entries of *mat* are nonzero. - bint bool_mat_is_diagonal(const bool_mat_t A) + bint bool_mat_is_diagonal(const bool_mat_t A) noexcept # Returns nonzero iff `i \ne j \implies \bar{A_{ij}}`. - bint bool_mat_is_lower_triangular(const bool_mat_t A) + bint bool_mat_is_lower_triangular(const bool_mat_t A) noexcept # Returns nonzero iff `i < j \implies \bar{A_{ij}}`. - bint bool_mat_is_transitive(const bool_mat_t mat) + bint bool_mat_is_transitive(const bool_mat_t mat) noexcept # Returns nonzero iff `A_{ij} \wedge A_{jk} \implies A_{ik}`. - bint bool_mat_is_nilpotent(const bool_mat_t A) + bint bool_mat_is_nilpotent(const bool_mat_t A) noexcept # Returns nonzero iff some positive matrix power of `A` is zero. - void bool_mat_randtest(bool_mat_t mat, flint_rand_t state) + void bool_mat_randtest(bool_mat_t mat, flint_rand_t state) noexcept # Sets *mat* to a random matrix. - void bool_mat_randtest_diagonal(bool_mat_t mat, flint_rand_t state) + void bool_mat_randtest_diagonal(bool_mat_t mat, flint_rand_t state) noexcept # Sets *mat* to a random diagonal matrix. - void bool_mat_randtest_nilpotent(bool_mat_t mat, flint_rand_t state) + void bool_mat_randtest_nilpotent(bool_mat_t mat, flint_rand_t state) noexcept # Sets *mat* to a random nilpotent matrix. - void bool_mat_zero(bool_mat_t mat) + void bool_mat_zero(bool_mat_t mat) noexcept # Sets all entries in mat to zero. - void bool_mat_one(bool_mat_t mat) + void bool_mat_one(bool_mat_t mat) noexcept # Sets the entries on the main diagonal to ones, # and all other entries to zero. - void bool_mat_directed_path(bool_mat_t A) + void bool_mat_directed_path(bool_mat_t A) noexcept # Sets `A_{ij}` to `j = i + 1`. # Requires that `A` is a square matrix. - void bool_mat_directed_cycle(bool_mat_t A) + void bool_mat_directed_cycle(bool_mat_t A) noexcept # Sets `A_{ij}` to `j = (i + 1) \mod n` # where `n` is the order of the square matrix `A`. - void bool_mat_transpose(bool_mat_t dest, const bool_mat_t src) + void bool_mat_transpose(bool_mat_t dest, const bool_mat_t src) noexcept # Sets *dest* to the transpose of *src*. The operands must have # compatible dimensions. Aliasing is allowed. - void bool_mat_complement(bool_mat_t B, const bool_mat_t A) + void bool_mat_complement(bool_mat_t B, const bool_mat_t A) noexcept # Sets *B* to the logical complement of *A*. # That is `B_{ij}` is set to `\bar{A_{ij}}`. # The operands must have the same dimensions. - void bool_mat_add(bool_mat_t res, const bool_mat_t mat1, const bool_mat_t mat2) + void bool_mat_add(bool_mat_t res, const bool_mat_t mat1, const bool_mat_t mat2) noexcept # Sets *res* to the sum of *mat1* and *mat2*. # The operands must have the same dimensions. - void bool_mat_mul(bool_mat_t res, const bool_mat_t mat1, const bool_mat_t mat2) + void bool_mat_mul(bool_mat_t res, const bool_mat_t mat1, const bool_mat_t mat2) noexcept # Sets *res* to the matrix product of *mat1* and *mat2*. # The operands must have compatible dimensions for matrix multiplication. - void bool_mat_mul_entrywise(bool_mat_t res, const bool_mat_t mat1, const bool_mat_t mat2) + void bool_mat_mul_entrywise(bool_mat_t res, const bool_mat_t mat1, const bool_mat_t mat2) noexcept # Sets *res* to the entrywise product of *mat1* and *mat2*. # The operands must have the same dimensions. - void bool_mat_sqr(bool_mat_t B, const bool_mat_t A) + void bool_mat_sqr(bool_mat_t B, const bool_mat_t A) noexcept - void bool_mat_pow_ui(bool_mat_t B, const bool_mat_t A, ulong exp) + void bool_mat_pow_ui(bool_mat_t B, const bool_mat_t A, ulong exp) noexcept # Sets *B* to *A* raised to the power *exp*. # Requires that *A* is a square matrix. - int bool_mat_trace(const bool_mat_t mat) + int bool_mat_trace(const bool_mat_t mat) noexcept # Returns the trace of the matrix, i.e. the sum of entries on the # main diagonal of *mat*. The matrix is required to be square. # The sum is in the boolean semiring, so this function returns nonzero iff # any entry on the diagonal of *mat* is nonzero. - slong bool_mat_nilpotency_degree(const bool_mat_t A) + slong bool_mat_nilpotency_degree(const bool_mat_t A) noexcept # Returns the nilpotency degree of the `n \times n` matrix *A*. # It returns the smallest positive `k` such that `A^k = 0`. # If no such `k` exists then the function returns `-1` if `n` is positive, # and otherwise it returns `0`. - void bool_mat_transitive_closure(bool_mat_t B, const bool_mat_t A) + void bool_mat_transitive_closure(bool_mat_t B, const bool_mat_t A) noexcept # Sets *B* to the transitive closure `\sum_{k=1}^\infty A^k`. # The matrix *A* is required to be square. - slong bool_mat_get_strongly_connected_components(slong * p, const bool_mat_t A) + slong bool_mat_get_strongly_connected_components(slong * p, const bool_mat_t A) noexcept # Partitions the `n` row and column indices of the `n \times n` matrix *A* # according to the strongly connected components (SCC) of the graph # for which *A* is the adjacency matrix. @@ -140,7 +140,7 @@ cdef extern from "flint_wrap.h": # The SCCs themselves can be considered as nodes in a directed acyclic # graph (DAG), and the SCCs are indexed in postorder with respect to that DAG. - slong bool_mat_all_pairs_longest_walk(fmpz_mat_t B, const bool_mat_t A) + slong bool_mat_all_pairs_longest_walk(fmpz_mat_t B, const bool_mat_t A) noexcept # Sets `B_{ij}` to the length of the longest walk with endpoint vertices # `i` and `j` in the graph whose adjacency matrix is *A*. # The matrix *A* must be square. Empty walks with zero length diff --git a/src/sage/libs/flint/ca.pxd b/src/sage/libs/flint/ca.pxd index a4ba2618cad..743ffae3f76 100644 --- a/src/sage/libs/flint/ca.pxd +++ b/src/sage/libs/flint/ca.pxd @@ -12,34 +12,34 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void ca_ctx_init(ca_ctx_t ctx) + void ca_ctx_init(ca_ctx_t ctx) noexcept # Initializes the context object *ctx* for use. # Any evaluation options stored in the context object # are set to default values. - void ca_ctx_clear(ca_ctx_t ctx) + void ca_ctx_clear(ca_ctx_t ctx) noexcept # Clears the context object *ctx*, freeing any memory allocated internally. # This function should only be called after all :type:`ca_t` instances # referring to this context have been cleared. - void ca_ctx_print(ca_ctx_t ctx) + void ca_ctx_print(ca_ctx_t ctx) noexcept # Prints a description of the context *ctx* to standard output. # This will give a complete listing of the cached fields in *ctx*. - void ca_init(ca_t x, ca_ctx_t ctx) + void ca_init(ca_t x, ca_ctx_t ctx) noexcept # Initializes the variable *x* for use, associating it with the # context object *ctx*. The value of *x* is set to the rational number 0. - void ca_clear(ca_t x, ca_ctx_t ctx) + void ca_clear(ca_t x, ca_ctx_t ctx) noexcept # Clears the variable *x*. - void ca_swap(ca_t x, ca_t y, ca_ctx_t ctx) + void ca_swap(ca_t x, ca_t y, ca_ctx_t ctx) noexcept # Efficiently swaps the variables *x* and *y*. - void ca_get_fexpr(fexpr_t res, const ca_t x, ulong flags, ca_ctx_t ctx) + void ca_get_fexpr(fexpr_t res, const ca_t x, ulong flags, ca_ctx_t ctx) noexcept # Sets *res* to a symbolic expression representing *x*. - int ca_set_fexpr(ca_t res, const fexpr_t expr, ca_ctx_t ctx) + int ca_set_fexpr(ca_t res, const fexpr_t expr, ca_ctx_t ctx) noexcept # Sets *res* to the value represented by the symbolic expression *expr*. # Returns 1 on success and 0 on failure. # This function essentially just traverses the expression tree using @@ -47,84 +47,84 @@ cdef extern from "flint_wrap.h": # It is guaranteed to at least be able to parse the output of # :func:`ca_get_fexpr`. - void ca_print(const ca_t x, ca_ctx_t ctx) + void ca_print(const ca_t x, ca_ctx_t ctx) noexcept # Prints *x* to standard output. - void ca_fprint(FILE * fp, const ca_t x, ca_ctx_t ctx) + void ca_fprint(FILE * fp, const ca_t x, ca_ctx_t ctx) noexcept # Prints *x* to the file *fp*. - char * ca_get_str(const ca_t x, ca_ctx_t ctx) + char * ca_get_str(const ca_t x, ca_ctx_t ctx) noexcept # Prints *x* to a string which is returned. # The user should free this string by calling ``flint_free``. - void ca_printn(const ca_t x, slong n, ca_ctx_t ctx) + void ca_printn(const ca_t x, slong n, ca_ctx_t ctx) noexcept # Prints an *n*-digit numerical representation of *x* to standard output. - void ca_zero(ca_t res, ca_ctx_t ctx) - void ca_one(ca_t res, ca_ctx_t ctx) - void ca_neg_one(ca_t res, ca_ctx_t ctx) + void ca_zero(ca_t res, ca_ctx_t ctx) noexcept + void ca_one(ca_t res, ca_ctx_t ctx) noexcept + void ca_neg_one(ca_t res, ca_ctx_t ctx) noexcept # Sets *res* to the integer 0, 1 or -1. This creates a canonical representation # of this number as an element of the trivial field `\mathbb{Q}`. - void ca_i(ca_t res, ca_ctx_t ctx) - void ca_neg_i(ca_t res, ca_ctx_t ctx) + void ca_i(ca_t res, ca_ctx_t ctx) noexcept + void ca_neg_i(ca_t res, ca_ctx_t ctx) noexcept # Sets *res* to the imaginary unit `i = \sqrt{-1}`, or its negation `-i`. # This creates a canonical representation of `i` as the generator of the # algebraic number field `\mathbb{Q}(i)`. - void ca_pi(ca_t res, ca_ctx_t ctx) + void ca_pi(ca_t res, ca_ctx_t ctx) noexcept # Sets *res* to the constant `\pi`. This creates an element # of the transcendental number field `\mathbb{Q}(\pi)`. - void ca_pi_i(ca_t res, ca_ctx_t ctx) + void ca_pi_i(ca_t res, ca_ctx_t ctx) noexcept # Sets *res* to the constant `\pi i`. This creates an element of the # composite field `\mathbb{Q}(i,\pi)` rather than representing `\pi i` # (or even `2 \pi i`, which for some purposes would be more elegant) # as an atomic quantity. - void ca_euler(ca_t res, ca_ctx_t ctx) + void ca_euler(ca_t res, ca_ctx_t ctx) noexcept # Sets *res* to Euler's constant `\gamma`. This creates an element # of the (transcendental?) number field `\mathbb{Q}(\gamma)`. - void ca_unknown(ca_t res, ca_ctx_t ctx) + void ca_unknown(ca_t res, ca_ctx_t ctx) noexcept # Sets *res* to the meta-value *Unknown*. - void ca_undefined(ca_t res, ca_ctx_t ctx) + void ca_undefined(ca_t res, ca_ctx_t ctx) noexcept # Sets *res* to *Undefined*. - void ca_uinf(ca_t res, ca_ctx_t ctx) + void ca_uinf(ca_t res, ca_ctx_t ctx) noexcept # Sets *res* to unsigned infinity `{\tilde \infty}`. - void ca_pos_inf(ca_t res, ca_ctx_t ctx) - void ca_neg_inf(ca_t res, ca_ctx_t ctx) - void ca_pos_i_inf(ca_t res, ca_ctx_t ctx) - void ca_neg_i_inf(ca_t res, ca_ctx_t ctx) + void ca_pos_inf(ca_t res, ca_ctx_t ctx) noexcept + void ca_neg_inf(ca_t res, ca_ctx_t ctx) noexcept + void ca_pos_i_inf(ca_t res, ca_ctx_t ctx) noexcept + void ca_neg_i_inf(ca_t res, ca_ctx_t ctx) noexcept # Sets *res* to the signed infinity `+\infty`, `-\infty`, `+i \infty` or `-i \infty`. - void ca_set(ca_t res, const ca_t x, ca_ctx_t ctx) + void ca_set(ca_t res, const ca_t x, ca_ctx_t ctx) noexcept # Sets *res* to a copy of *x*. - void ca_set_si(ca_t res, slong v, ca_ctx_t ctx) - void ca_set_ui(ca_t res, ulong v, ca_ctx_t ctx) - void ca_set_fmpz(ca_t res, const fmpz_t v, ca_ctx_t ctx) - void ca_set_fmpq(ca_t res, const fmpq_t v, ca_ctx_t ctx) + void ca_set_si(ca_t res, slong v, ca_ctx_t ctx) noexcept + void ca_set_ui(ca_t res, ulong v, ca_ctx_t ctx) noexcept + void ca_set_fmpz(ca_t res, const fmpz_t v, ca_ctx_t ctx) noexcept + void ca_set_fmpq(ca_t res, const fmpq_t v, ca_ctx_t ctx) noexcept # Sets *res* to the integer or rational number *v*. This creates a canonical # representation of this number as an element of the trivial field # `\mathbb{Q}`. - void ca_set_d(ca_t res, double x, ca_ctx_t ctx) - void ca_set_d_d(ca_t res, double x, double y, ca_ctx_t ctx) + void ca_set_d(ca_t res, double x, ca_ctx_t ctx) noexcept + void ca_set_d_d(ca_t res, double x, double y, ca_ctx_t ctx) noexcept # Sets *res* to the value of *x*, or the complex value `x + yi`. # NaN is interpreted as *Unknown* (not *Undefined*). - void ca_transfer(ca_t res, ca_ctx_t res_ctx, const ca_t src, ca_ctx_t src_ctx) + void ca_transfer(ca_t res, ca_ctx_t res_ctx, const ca_t src, ca_ctx_t src_ctx) noexcept # Sets *res* to *src* where the corresponding context objects *res_ctx* and # *src_ctx* may be different. # This operation preserves the mathematical value represented by *src*, # but may result in a different internal representation depending on the # settings of the context objects. - void ca_set_qqbar(ca_t res, const qqbar_t x, ca_ctx_t ctx) + void ca_set_qqbar(ca_t res, const qqbar_t x, ca_ctx_t ctx) noexcept # Sets *res* to the algebraic number *x*. # If *x* is rational, *res* is set to the canonical representation as # an element in the trivial field `\mathbb{Q}`. @@ -139,9 +139,9 @@ cdef extern from "flint_wrap.h": # (obtained by performing a smooth factorization of the discriminant). # * TODO: if possible, coerce *x* to a low-degree cyclotomic field. - int ca_get_fmpz(fmpz_t res, const ca_t x, ca_ctx_t ctx) - int ca_get_fmpq(fmpq_t res, const ca_t x, ca_ctx_t ctx) - int ca_get_qqbar(qqbar_t res, const ca_t x, ca_ctx_t ctx) + int ca_get_fmpz(fmpz_t res, const ca_t x, ca_ctx_t ctx) noexcept + int ca_get_fmpq(fmpq_t res, const ca_t x, ca_ctx_t ctx) noexcept + int ca_get_qqbar(qqbar_t res, const ca_t x, ca_ctx_t ctx) noexcept # Attempts to evaluate *x* to an explicit integer, rational or # algebraic number. If successful, sets *res* to this number and # returns 1. If unsuccessful, returns 0. @@ -158,16 +158,16 @@ cdef extern from "flint_wrap.h": # has been implemented for the functions appearing in the construction # of *x*. - int ca_can_evaluate_qqbar(const ca_t x, ca_ctx_t ctx) + int ca_can_evaluate_qqbar(const ca_t x, ca_ctx_t ctx) noexcept # Checks if :func:`ca_get_qqbar` has a chance to succeed. In effect, # this checks if all extension numbers are manifestly algebraic # numbers (without doing any evaluation). - void ca_randtest_rational(ca_t res, flint_rand_t state, slong bits, ca_ctx_t ctx) + void ca_randtest_rational(ca_t res, flint_rand_t state, slong bits, ca_ctx_t ctx) noexcept # Sets *res* to a random rational number with numerator and denominator # up to *bits* bits in size. - void ca_randtest(ca_t res, flint_rand_t state, slong depth, slong bits, ca_ctx_t ctx) + void ca_randtest(ca_t res, flint_rand_t state, slong depth, slong bits, ca_ctx_t ctx) noexcept # Sets *res* to a random number generated by evaluating a random expression. # The algorithm randomly selects between generating a "simple" number # (a random rational number or quadratic field element with coefficients @@ -176,16 +176,16 @@ cdef extern from "flint_wrap.h": # function to operands produced through recursive calls with # *depth* - 1. The output is guaranteed to be a number, not a special value. - void ca_randtest_special(ca_t res, flint_rand_t state, slong depth, slong bits, ca_ctx_t ctx) + void ca_randtest_special(ca_t res, flint_rand_t state, slong depth, slong bits, ca_ctx_t ctx) noexcept # Randomly generates either a special value or a number. - void ca_randtest_same_nf(ca_t res, flint_rand_t state, const ca_t x, slong bits, slong den_bits, ca_ctx_t ctx) + void ca_randtest_same_nf(ca_t res, flint_rand_t state, const ca_t x, slong bits, slong den_bits, ca_ctx_t ctx) noexcept # Sets *res* to a random element in the same number field as *x*, # with numerator coefficients up to *bits* in size and denominator # up to *den_bits* in size. This function requires that *x* is an # element of an absolute number field. - bint ca_equal_repr(const ca_t x, const ca_t y, ca_ctx_t ctx) + bint ca_equal_repr(const ca_t x, const ca_t y, ca_ctx_t ctx) noexcept # Returns whether *x* and *y* have identical representation. For field # elements, this checks if *x* and *y* belong to the same formal field # (with generators having identical representation) and are represented by @@ -199,37 +199,37 @@ cdef extern from "flint_wrap.h": # either operand is *Unknown*, the result is meaningless for # mathematical comparison. - int ca_cmp_repr(const ca_t x, const ca_t y, ca_ctx_t ctx) + int ca_cmp_repr(const ca_t x, const ca_t y, ca_ctx_t ctx) noexcept # Compares the representations of *x* and *y* in a canonical sort order, # returning -1, 0 or 1. This only performs a lexicographic comparison # of the representations of *x* and *y*; the return value does not say # anything meaningful about the numbers represented by *x* and *y*. - ulong ca_hash_repr(const ca_t x, ca_ctx_t ctx) + ulong ca_hash_repr(const ca_t x, ca_ctx_t ctx) noexcept # Hashes the representation of *x*. - bint ca_is_unknown(const ca_t x, ca_ctx_t ctx) + bint ca_is_unknown(const ca_t x, ca_ctx_t ctx) noexcept # Returns whether *x* is Unknown. - bint ca_is_special(const ca_t x, ca_ctx_t ctx) + bint ca_is_special(const ca_t x, ca_ctx_t ctx) noexcept # Returns whether *x* is a special value or metavalue # (not a field element). - bint ca_is_qq_elem(const ca_t x, ca_ctx_t ctx) + bint ca_is_qq_elem(const ca_t x, ca_ctx_t ctx) noexcept # Returns whether *x* is represented as an element of the # rational field `\mathbb{Q}`. - bint ca_is_qq_elem_zero(const ca_t x, ca_ctx_t ctx) - bint ca_is_qq_elem_one(const ca_t x, ca_ctx_t ctx) - bint ca_is_qq_elem_integer(const ca_t x, ca_ctx_t ctx) + bint ca_is_qq_elem_zero(const ca_t x, ca_ctx_t ctx) noexcept + bint ca_is_qq_elem_one(const ca_t x, ca_ctx_t ctx) noexcept + bint ca_is_qq_elem_integer(const ca_t x, ca_ctx_t ctx) noexcept # Returns whether *x* is represented as the element 0, 1 or # any integer in the rational field `\mathbb{Q}`. - bint ca_is_nf_elem(const ca_t x, ca_ctx_t ctx) + bint ca_is_nf_elem(const ca_t x, ca_ctx_t ctx) noexcept # Returns whether *x* is represented as an element of a univariate # algebraic number field `\mathbb{Q}(a)`. - bint ca_is_cyclotomic_nf_elem(slong * p, ulong * q, const ca_t x, ca_ctx_t ctx) + bint ca_is_cyclotomic_nf_elem(slong * p, ulong * q, const ca_t x, ca_ctx_t ctx) noexcept # Returns whether *x* is represented as an element of a univariate # cyclotomic field, i.e. `\mathbb{Q}(a)` where *a* is a root of unity. # If *p* and *q* are not *NULL* and *x* is represented as an @@ -244,72 +244,72 @@ cdef extern from "flint_wrap.h": # cyclotomic fields count; the return value is 0 if *x* # is represented as a rational number. - bint ca_is_generic_elem(const ca_t x, ca_ctx_t ctx) + bint ca_is_generic_elem(const ca_t x, ca_ctx_t ctx) noexcept # Returns whether *x* is represented as a generic field element; # i.e. it is not a special value, not represented as # an element of the rational field, and not represented as # an element of a univariate algebraic number field. - truth_t ca_check_is_number(const ca_t x, ca_ctx_t ctx) + truth_t ca_check_is_number(const ca_t x, ca_ctx_t ctx) noexcept # Tests if *x* is a number. The result is ``T_TRUE`` is *x* is # a field element (and hence a complex number), ``T_FALSE`` if *x* is # an infinity or *Undefined*, and ``T_UNKNOWN`` if *x* is *Unknown*. - truth_t ca_check_is_zero(const ca_t x, ca_ctx_t ctx) - truth_t ca_check_is_one(const ca_t x, ca_ctx_t ctx) - truth_t ca_check_is_neg_one(const ca_t x, ca_ctx_t ctx) - truth_t ca_check_is_i(const ca_t x, ca_ctx_t ctx) - truth_t ca_check_is_neg_i(const ca_t x, ca_ctx_t ctx) + truth_t ca_check_is_zero(const ca_t x, ca_ctx_t ctx) noexcept + truth_t ca_check_is_one(const ca_t x, ca_ctx_t ctx) noexcept + truth_t ca_check_is_neg_one(const ca_t x, ca_ctx_t ctx) noexcept + truth_t ca_check_is_i(const ca_t x, ca_ctx_t ctx) noexcept + truth_t ca_check_is_neg_i(const ca_t x, ca_ctx_t ctx) noexcept # Tests if *x* is equal to the number `0`, `1`, `-1`, `i`, or `-i`. - truth_t ca_check_is_algebraic(const ca_t x, ca_ctx_t ctx) - truth_t ca_check_is_rational(const ca_t x, ca_ctx_t ctx) - truth_t ca_check_is_integer(const ca_t x, ca_ctx_t ctx) + truth_t ca_check_is_algebraic(const ca_t x, ca_ctx_t ctx) noexcept + truth_t ca_check_is_rational(const ca_t x, ca_ctx_t ctx) noexcept + truth_t ca_check_is_integer(const ca_t x, ca_ctx_t ctx) noexcept # Tests if *x* is respectively an algebraic number, a rational number, # or an integer. - truth_t ca_check_is_real(const ca_t x, ca_ctx_t ctx) + truth_t ca_check_is_real(const ca_t x, ca_ctx_t ctx) noexcept # Tests if *x* is a real number. Warning: this returns ``T_FALSE`` if *x* is an # infinity with real sign. - truth_t ca_check_is_negative_real(const ca_t x, ca_ctx_t ctx) + truth_t ca_check_is_negative_real(const ca_t x, ca_ctx_t ctx) noexcept # Tests if *x* is a negative real number. Warning: this returns ``T_FALSE`` # if *x* is negative infinity. - truth_t ca_check_is_imaginary(const ca_t x, ca_ctx_t ctx) + truth_t ca_check_is_imaginary(const ca_t x, ca_ctx_t ctx) noexcept # Tests if *x* is an imaginary number. Warning: this returns ``T_FALSE`` if # *x* is an infinity with imaginary sign. - truth_t ca_check_is_undefined(const ca_t x, ca_ctx_t ctx) + truth_t ca_check_is_undefined(const ca_t x, ca_ctx_t ctx) noexcept # Tests if *x* is the special value *Undefined*. - truth_t ca_check_is_infinity(const ca_t x, ca_ctx_t ctx) + truth_t ca_check_is_infinity(const ca_t x, ca_ctx_t ctx) noexcept # Tests if *x* is any infinity (unsigned or signed). - truth_t ca_check_is_uinf(const ca_t x, ca_ctx_t ctx) + truth_t ca_check_is_uinf(const ca_t x, ca_ctx_t ctx) noexcept # Tests if *x* is unsigned infinity `{\tilde \infty}`. - truth_t ca_check_is_signed_inf(const ca_t x, ca_ctx_t ctx) + truth_t ca_check_is_signed_inf(const ca_t x, ca_ctx_t ctx) noexcept # Tests if *x* is any signed infinity. - truth_t ca_check_is_pos_inf(const ca_t x, ca_ctx_t ctx) - truth_t ca_check_is_neg_inf(const ca_t x, ca_ctx_t ctx) - truth_t ca_check_is_pos_i_inf(const ca_t x, ca_ctx_t ctx) - truth_t ca_check_is_neg_i_inf(const ca_t x, ca_ctx_t ctx) + truth_t ca_check_is_pos_inf(const ca_t x, ca_ctx_t ctx) noexcept + truth_t ca_check_is_neg_inf(const ca_t x, ca_ctx_t ctx) noexcept + truth_t ca_check_is_pos_i_inf(const ca_t x, ca_ctx_t ctx) noexcept + truth_t ca_check_is_neg_i_inf(const ca_t x, ca_ctx_t ctx) noexcept # Tests if *x* is equal to the signed infinity `+\infty`, `-\infty`, # `+i \infty`, `-i \infty`, respectively. - truth_t ca_check_equal(const ca_t x, const ca_t y, ca_ctx_t ctx) + truth_t ca_check_equal(const ca_t x, const ca_t y, ca_ctx_t ctx) noexcept # Tests `x = y` as a mathematical equality. # The result is ``T_UNKNOWN`` if either operand is *Unknown*. # The result may also be ``T_UNKNOWN`` if *x* and *y* are numerically # indistinguishable and cannot be proved equal or unequal by # an exact computation. - truth_t ca_check_lt(const ca_t x, const ca_t y, ca_ctx_t ctx) - truth_t ca_check_le(const ca_t x, const ca_t y, ca_ctx_t ctx) - truth_t ca_check_gt(const ca_t x, const ca_t y, ca_ctx_t ctx) - truth_t ca_check_ge(const ca_t x, const ca_t y, ca_ctx_t ctx) + truth_t ca_check_lt(const ca_t x, const ca_t y, ca_ctx_t ctx) noexcept + truth_t ca_check_le(const ca_t x, const ca_t y, ca_ctx_t ctx) noexcept + truth_t ca_check_gt(const ca_t x, const ca_t y, ca_ctx_t ctx) noexcept + truth_t ca_check_ge(const ca_t x, const ca_t y, ca_ctx_t ctx) noexcept # Compares *x* and *y*, implementing the respective operations # `x < y`, `x \le y`, `x > y`, `x \ge y`. # Only real numbers and `-\infty` and `+\infty` are considered comparable. @@ -317,37 +317,37 @@ cdef extern from "flint_wrap.h": # comparable (being a nonreal complex number, unsigned infinity, or # undefined). - void ca_merge_fields(ca_t resx, ca_t resy, const ca_t x, const ca_t y, ca_ctx_t ctx) + void ca_merge_fields(ca_t resx, ca_t resy, const ca_t x, const ca_t y, ca_ctx_t ctx) noexcept # Sets *resx* and *resy* to copies of *x* and *y* coerced to a common field. # Both *x* and *y* must be field elements (not special values). # In the present implementation, this simply merges the lists of generators, # avoiding duplication. In the future, it will be able to eliminate # generators satisfying algebraic relations. - void ca_condense_field(ca_t res, ca_ctx_t ctx) + void ca_condense_field(ca_t res, ca_ctx_t ctx) noexcept # Attempts to demote the value of *res* to a trivial subfield of its # current field by removing unused generators. In particular, this demotes # any obviously rational value to the trivial field `\mathbb{Q}`. # This function is applied automatically in most operations # (arithmetic operations, etc.). - ca_ext_ptr ca_is_gen_as_ext(const ca_t x, ca_ctx_t ctx) + ca_ext_ptr ca_is_gen_as_ext(const ca_t x, ca_ctx_t ctx) noexcept # If *x* is a generator of its formal field, `x = a_k \in \mathbb{Q}(a_1,\ldots,a_n)`, # returns a pointer to the extension number defining `a_k`. If *x* is # not a generator, returns *NULL*. - void ca_neg(ca_t res, const ca_t x, ca_ctx_t ctx) + void ca_neg(ca_t res, const ca_t x, ca_ctx_t ctx) noexcept # Sets *res* to the negation of *x*. # For numbers, this operation amounts to a direct negation within the # formal field. # For a signed infinity `c \infty`, negation gives `(-c) \infty`; all other # special values are unchanged. - void ca_add_fmpq(ca_t res, const ca_t x, const fmpq_t y, ca_ctx_t ctx) - void ca_add_fmpz(ca_t res, const ca_t x, const fmpz_t y, ca_ctx_t ctx) - void ca_add_ui(ca_t res, const ca_t x, ulong y, ca_ctx_t ctx) - void ca_add_si(ca_t res, const ca_t x, slong y, ca_ctx_t ctx) - void ca_add(ca_t res, const ca_t x, const ca_t y, ca_ctx_t ctx) + void ca_add_fmpq(ca_t res, const ca_t x, const fmpq_t y, ca_ctx_t ctx) noexcept + void ca_add_fmpz(ca_t res, const ca_t x, const fmpz_t y, ca_ctx_t ctx) noexcept + void ca_add_ui(ca_t res, const ca_t x, ulong y, ca_ctx_t ctx) noexcept + void ca_add_si(ca_t res, const ca_t x, slong y, ca_ctx_t ctx) noexcept + void ca_add(ca_t res, const ca_t x, const ca_t y, ca_ctx_t ctx) noexcept # Sets *res* to the sum of *x* and *y*. For special values, the following # rules apply (`c \infty` denotes a signed infinity, `|c| = 1`): # * `c \infty + d \infty = c \infty` if `c = d` @@ -359,23 +359,23 @@ cdef extern from "flint_wrap.h": # In any other case involving special values, or if the specific case cannot # be distinguished, the result is *Unknown*. - void ca_sub_fmpq(ca_t res, const ca_t x, const fmpq_t y, ca_ctx_t ctx) - void ca_sub_fmpz(ca_t res, const ca_t x, const fmpz_t y, ca_ctx_t ctx) - void ca_sub_ui(ca_t res, const ca_t x, ulong y, ca_ctx_t ctx) - void ca_sub_si(ca_t res, const ca_t x, slong y, ca_ctx_t ctx) - void ca_fmpq_sub(ca_t res, const fmpq_t x, const ca_t y, ca_ctx_t ctx) - void ca_fmpz_sub(ca_t res, const fmpz_t x, const ca_t y, ca_ctx_t ctx) - void ca_ui_sub(ca_t res, ulong x, const ca_t y, ca_ctx_t ctx) - void ca_si_sub(ca_t res, slong x, const ca_t y, ca_ctx_t ctx) - void ca_sub(ca_t res, const ca_t x, const ca_t y, ca_ctx_t ctx) + void ca_sub_fmpq(ca_t res, const ca_t x, const fmpq_t y, ca_ctx_t ctx) noexcept + void ca_sub_fmpz(ca_t res, const ca_t x, const fmpz_t y, ca_ctx_t ctx) noexcept + void ca_sub_ui(ca_t res, const ca_t x, ulong y, ca_ctx_t ctx) noexcept + void ca_sub_si(ca_t res, const ca_t x, slong y, ca_ctx_t ctx) noexcept + void ca_fmpq_sub(ca_t res, const fmpq_t x, const ca_t y, ca_ctx_t ctx) noexcept + void ca_fmpz_sub(ca_t res, const fmpz_t x, const ca_t y, ca_ctx_t ctx) noexcept + void ca_ui_sub(ca_t res, ulong x, const ca_t y, ca_ctx_t ctx) noexcept + void ca_si_sub(ca_t res, slong x, const ca_t y, ca_ctx_t ctx) noexcept + void ca_sub(ca_t res, const ca_t x, const ca_t y, ca_ctx_t ctx) noexcept # Sets *res* to the difference of *x* and *y*. # This is equivalent to computing `x + (-y)`. - void ca_mul_fmpq(ca_t res, const ca_t x, const fmpq_t y, ca_ctx_t ctx) - void ca_mul_fmpz(ca_t res, const ca_t x, const fmpz_t y, ca_ctx_t ctx) - void ca_mul_ui(ca_t res, const ca_t x, ulong y, ca_ctx_t ctx) - void ca_mul_si(ca_t res, const ca_t x, slong y, ca_ctx_t ctx) - void ca_mul(ca_t res, const ca_t x, const ca_t y, ca_ctx_t ctx) + void ca_mul_fmpq(ca_t res, const ca_t x, const fmpq_t y, ca_ctx_t ctx) noexcept + void ca_mul_fmpz(ca_t res, const ca_t x, const fmpz_t y, ca_ctx_t ctx) noexcept + void ca_mul_ui(ca_t res, const ca_t x, ulong y, ca_ctx_t ctx) noexcept + void ca_mul_si(ca_t res, const ca_t x, slong y, ca_ctx_t ctx) noexcept + void ca_mul(ca_t res, const ca_t x, const ca_t y, ca_ctx_t ctx) noexcept # Sets *res* to the product of *x* and *y*. For special values, the following # rules apply (`c \infty` denotes a signed infinity, `|c| = 1`): # * `c \infty \cdot d \infty = c d \infty` @@ -388,7 +388,7 @@ cdef extern from "flint_wrap.h": # In any other case involving special values, or if the specific case cannot # be distinguished, the result is *Unknown*. - void ca_inv(ca_t res, const ca_t x, ca_ctx_t ctx) + void ca_inv(ca_t res, const ca_t x, ca_ctx_t ctx) noexcept # Sets *res* to the multiplicative inverse of *x*. In a univariate algebraic # number field, this always produces a rational denominator, but the # denominator might not be rationalized in a multivariate @@ -402,15 +402,15 @@ cdef extern from "flint_wrap.h": # If it cannot be determined whether *x* is zero or nonzero, # the result is *Unknown*. - void ca_fmpq_div(ca_t res, const fmpq_t x, const ca_t y, ca_ctx_t ctx) - void ca_fmpz_div(ca_t res, const fmpz_t x, const ca_t y, ca_ctx_t ctx) - void ca_ui_div(ca_t res, ulong x, const ca_t y, ca_ctx_t ctx) - void ca_si_div(ca_t res, slong x, const ca_t y, ca_ctx_t ctx) - void ca_div_fmpq(ca_t res, const ca_t x, const fmpq_t y, ca_ctx_t ctx) - void ca_div_fmpz(ca_t res, const ca_t x, const fmpz_t y, ca_ctx_t ctx) - void ca_div_ui(ca_t res, const ca_t x, ulong y, ca_ctx_t ctx) - void ca_div_si(ca_t res, const ca_t x, slong y, ca_ctx_t ctx) - void ca_div(ca_t res, const ca_t x, const ca_t y, ca_ctx_t ctx) + void ca_fmpq_div(ca_t res, const fmpq_t x, const ca_t y, ca_ctx_t ctx) noexcept + void ca_fmpz_div(ca_t res, const fmpz_t x, const ca_t y, ca_ctx_t ctx) noexcept + void ca_ui_div(ca_t res, ulong x, const ca_t y, ca_ctx_t ctx) noexcept + void ca_si_div(ca_t res, slong x, const ca_t y, ca_ctx_t ctx) noexcept + void ca_div_fmpq(ca_t res, const ca_t x, const fmpq_t y, ca_ctx_t ctx) noexcept + void ca_div_fmpz(ca_t res, const ca_t x, const fmpz_t y, ca_ctx_t ctx) noexcept + void ca_div_ui(ca_t res, const ca_t x, ulong y, ca_ctx_t ctx) noexcept + void ca_div_si(ca_t res, const ca_t x, slong y, ca_ctx_t ctx) noexcept + void ca_div(ca_t res, const ca_t x, const ca_t y, ca_ctx_t ctx) noexcept # Sets *res* to the quotient of *x* and *y*. This is equivalent # to computing `x \cdot (1 / y)`. For special values and division # by zero, this implies the following rules @@ -426,7 +426,7 @@ cdef extern from "flint_wrap.h": # In any other case involving special values, or if the specific case cannot # be distinguished, the result is *Unknown*. - void ca_dot(ca_t res, const ca_t initial, int subtract, ca_srcptr x, slong xstep, ca_srcptr y, slong ystep, slong len, ca_ctx_t ctx) + void ca_dot(ca_t res, const ca_t initial, int subtract, ca_srcptr x, slong xstep, ca_srcptr y, slong ystep, slong len, ca_ctx_t ctx) noexcept # Computes the dot product of the vectors *x* and *y*, setting # *res* to `s + (-1)^{subtract} \sum_{i=0}^{len-1} x_i y_i`. # The initial term *s* is optional and can be @@ -441,45 +441,45 @@ cdef extern from "flint_wrap.h": # Aliasing is allowed between *res* and *s* but not between # *res* and the entries of *x* and *y*. - void ca_fmpz_poly_evaluate(ca_t res, const fmpz_poly_t poly, const ca_t x, ca_ctx_t ctx) - void ca_fmpq_poly_evaluate(ca_t res, const fmpq_poly_t poly, const ca_t x, ca_ctx_t ctx) + void ca_fmpz_poly_evaluate(ca_t res, const fmpz_poly_t poly, const ca_t x, ca_ctx_t ctx) noexcept + void ca_fmpq_poly_evaluate(ca_t res, const fmpq_poly_t poly, const ca_t x, ca_ctx_t ctx) noexcept # Sets *res* to the polynomial *poly* evaluated at *x*. - void ca_fmpz_mpoly_evaluate_horner(ca_t res, const fmpz_mpoly_t f, ca_srcptr x, const fmpz_mpoly_ctx_t mctx, ca_ctx_t ctx) - void ca_fmpz_mpoly_evaluate_iter(ca_t res, const fmpz_mpoly_t f, ca_srcptr x, const fmpz_mpoly_ctx_t mctx, ca_ctx_t ctx) - void ca_fmpz_mpoly_evaluate(ca_t res, const fmpz_mpoly_t f, ca_srcptr x, const fmpz_mpoly_ctx_t mctx, ca_ctx_t ctx) + void ca_fmpz_mpoly_evaluate_horner(ca_t res, const fmpz_mpoly_t f, ca_srcptr x, const fmpz_mpoly_ctx_t mctx, ca_ctx_t ctx) noexcept + void ca_fmpz_mpoly_evaluate_iter(ca_t res, const fmpz_mpoly_t f, ca_srcptr x, const fmpz_mpoly_ctx_t mctx, ca_ctx_t ctx) noexcept + void ca_fmpz_mpoly_evaluate(ca_t res, const fmpz_mpoly_t f, ca_srcptr x, const fmpz_mpoly_ctx_t mctx, ca_ctx_t ctx) noexcept # Sets *res* to the multivariate polynomial *f* evaluated at the vector of arguments *x*. - void ca_fmpz_mpoly_q_evaluate(ca_t res, const fmpz_mpoly_q_t f, ca_srcptr x, const fmpz_mpoly_ctx_t mctx, ca_ctx_t ctx) + void ca_fmpz_mpoly_q_evaluate(ca_t res, const fmpz_mpoly_q_t f, ca_srcptr x, const fmpz_mpoly_ctx_t mctx, ca_ctx_t ctx) noexcept # Sets *res* to the multivariate rational function *f* evaluated at the vector of arguments *x*. - void ca_fmpz_mpoly_q_evaluate_no_division_by_zero(ca_t res, const fmpz_mpoly_q_t f, ca_srcptr x, const fmpz_mpoly_ctx_t mctx, ca_ctx_t ctx) - void ca_inv_no_division_by_zero(ca_t res, const ca_t x, ca_ctx_t ctx) + void ca_fmpz_mpoly_q_evaluate_no_division_by_zero(ca_t res, const fmpz_mpoly_q_t f, ca_srcptr x, const fmpz_mpoly_ctx_t mctx, ca_ctx_t ctx) noexcept + void ca_inv_no_division_by_zero(ca_t res, const ca_t x, ca_ctx_t ctx) noexcept # These functions behave like the normal arithmetic functions, # but assume (and do not check) that division by zero cannot occur. # Division by zero will result in undefined behavior. - void ca_sqr(ca_t res, const ca_t x, ca_ctx_t ctx) + void ca_sqr(ca_t res, const ca_t x, ca_ctx_t ctx) noexcept # Sets *res* to the square of *x*. - void ca_pow_fmpq(ca_t res, const ca_t x, const fmpq_t y, ca_ctx_t ctx) - void ca_pow_fmpz(ca_t res, const ca_t x, const fmpz_t y, ca_ctx_t ctx) - void ca_pow_ui(ca_t res, const ca_t x, ulong y, ca_ctx_t ctx) - void ca_pow_si(ca_t res, const ca_t x, slong y, ca_ctx_t ctx) - void ca_pow(ca_t res, const ca_t x, const ca_t y, ca_ctx_t ctx) + void ca_pow_fmpq(ca_t res, const ca_t x, const fmpq_t y, ca_ctx_t ctx) noexcept + void ca_pow_fmpz(ca_t res, const ca_t x, const fmpz_t y, ca_ctx_t ctx) noexcept + void ca_pow_ui(ca_t res, const ca_t x, ulong y, ca_ctx_t ctx) noexcept + void ca_pow_si(ca_t res, const ca_t x, slong y, ca_ctx_t ctx) noexcept + void ca_pow(ca_t res, const ca_t x, const ca_t y, ca_ctx_t ctx) noexcept # Sets *res* to *x* raised to the power *y*. # Handling of special values is not yet implemented. - void ca_pow_si_arithmetic(ca_t res, const ca_t x, slong n, ca_ctx_t ctx) + void ca_pow_si_arithmetic(ca_t res, const ca_t x, slong n, ca_ctx_t ctx) noexcept # Sets *res* to *x* raised to the power *n*. Whereas :func:`ca_pow`, # :func:`ca_pow_si` etc. may create `x^n` as an extension number # if *n* is large, this function always perform the exponentiation # using field arithmetic. - void ca_sqrt_inert(ca_t res, const ca_t x, ca_ctx_t ctx) - void ca_sqrt_nofactor(ca_t res, const ca_t x, ca_ctx_t ctx) - void ca_sqrt_factor(ca_t res, const ca_t x, ulong flags, ca_ctx_t ctx) - void ca_sqrt(ca_t res, const ca_t x, ca_ctx_t ctx) + void ca_sqrt_inert(ca_t res, const ca_t x, ca_ctx_t ctx) noexcept + void ca_sqrt_nofactor(ca_t res, const ca_t x, ca_ctx_t ctx) noexcept + void ca_sqrt_factor(ca_t res, const ca_t x, ulong flags, ca_ctx_t ctx) noexcept + void ca_sqrt(ca_t res, const ca_t x, ca_ctx_t ctx) noexcept # Sets *res* to the principal square root of *x*. # For special values, the following definitions apply: # * `\sqrt{c \infty} = \sqrt{c} \infty` @@ -499,10 +499,10 @@ cdef extern from "flint_wrap.h": # may still perform other simplifications. It may in particular attempt to # simplify `\sqrt{x}` to a single element in `\overline{\mathbb{Q}}`. - void ca_sqrt_ui(ca_t res, ulong n, ca_ctx_t ctx) + void ca_sqrt_ui(ca_t res, ulong n, ca_ctx_t ctx) noexcept # Sets *res* to the principal square root of *n*. - void ca_abs(ca_t res, const ca_t x, ca_ctx_t ctx) + void ca_abs(ca_t res, const ca_t x, ca_ctx_t ctx) noexcept # Sets *res* to the absolute value of *x*. # For special values, the following definitions apply: # * `|c \infty| = |\tilde \infty| = +\infty`. @@ -513,7 +513,7 @@ cdef extern from "flint_wrap.h": # In the generic case, this function outputs an element of the formal # field `\mathbb{Q}(|x|)`. - void ca_sgn(ca_t res, const ca_t x, ca_ctx_t ctx) + void ca_sgn(ca_t res, const ca_t x, ca_ctx_t ctx) noexcept # Sets *res* to the sign of *x*, defined by # .. math :: # \operatorname{sgn}(x) = \begin{cases} 0 & x = 0 \\ \frac{x}{|x|} & x \ne 0 \end{cases} @@ -527,7 +527,7 @@ cdef extern from "flint_wrap.h": # In the generic case, this function outputs an element of the formal # field `\mathbb{Q}(\operatorname{sgn}(x))`. - void ca_csgn(ca_t res, const ca_t x, ca_ctx_t ctx) + void ca_csgn(ca_t res, const ca_t x, ca_ctx_t ctx) noexcept # Sets *res* to the extension of the real sign function taking the # value 1 for *z* strictly in the right half plane, -1 for *z* strictly # in the left half plane, and the sign of the imaginary part when *z* is on @@ -537,7 +537,7 @@ cdef extern from "flint_wrap.h": # and `\operatorname{csgn}(\operatorname{sgn}(c \infty)) = \operatorname{csgn}(c)` for # signed infinities. - void ca_arg(ca_t res, const ca_t x, ca_ctx_t ctx) + void ca_arg(ca_t res, const ca_t x, ca_ctx_t ctx) noexcept # Sets *res* to the complex argument (phase) of *x*, normalized # to the range `(-\pi, +\pi]`. The argument of 0 is defined as 0. # For special values, the following definitions apply: @@ -545,17 +545,17 @@ cdef extern from "flint_wrap.h": # * `\operatorname{arg}(\tilde \infty) = \operatorname{Undefined}`. # * Both *Undefined* and *Unknown* map to themselves. - void ca_re(ca_t res, const ca_t x, ca_ctx_t ctx) + void ca_re(ca_t res, const ca_t x, ca_ctx_t ctx) noexcept # Sets *res* to the real part of *x*. The result is *Undefined* if *x* # is any infinity (including a real infinity). - void ca_im(ca_t res, const ca_t x, ca_ctx_t ctx) + void ca_im(ca_t res, const ca_t x, ca_ctx_t ctx) noexcept # Sets *res* to the imaginary part of *x*. The result is *Undefined* if *x* # is any infinity (including an imaginary infinity). - void ca_conj_deep(ca_t res, const ca_t x, ca_ctx_t ctx) - void ca_conj_shallow(ca_t res, const ca_t x, ca_ctx_t ctx) - void ca_conj(ca_t res, const ca_t x, ca_ctx_t ctx) + void ca_conj_deep(ca_t res, const ca_t x, ca_ctx_t ctx) noexcept + void ca_conj_shallow(ca_t res, const ca_t x, ca_ctx_t ctx) noexcept + void ca_conj(ca_t res, const ca_t x, ca_ctx_t ctx) noexcept # Sets *res* to the complex conjugate of *x*. # The *shallow* version creates a new extension element # `\overline{x}` unless *x* can be trivially conjugated in-place @@ -563,19 +563,19 @@ cdef extern from "flint_wrap.h": # The *deep* version recursively conjugates the extension numbers # in the field of *x*. - void ca_floor(ca_t res, const ca_t x, ca_ctx_t ctx) + void ca_floor(ca_t res, const ca_t x, ca_ctx_t ctx) noexcept # Sets *res* to the floor function of *x*. The result is *Undefined* if *x* # is any infinity (including a real infinity). # For complex numbers, this is presently defined to take the floor of the # real part. - void ca_ceil(ca_t res, const ca_t x, ca_ctx_t ctx) + void ca_ceil(ca_t res, const ca_t x, ca_ctx_t ctx) noexcept # Sets *res* to the ceiling function of *x*. The result is *Undefined* if *x* # is any infinity (including a real infinity). # For complex numbers, this is presently defined to take the ceiling of the # real part. - void ca_exp(ca_t res, const ca_t x, ca_ctx_t ctx) + void ca_exp(ca_t res, const ca_t x, ca_ctx_t ctx) noexcept # Sets *res* to the exponential function of *x*. # For special values, the following definitions apply: # * `e^{+\infty} = +\infty` @@ -592,7 +592,7 @@ cdef extern from "flint_wrap.h": # In the generic case, this function outputs an element of the formal # field `\mathbb{Q}(e^x)`. - void ca_log(ca_t res, const ca_t x, ca_ctx_t ctx) + void ca_log(ca_t res, const ca_t x, ca_ctx_t ctx) noexcept # Sets *res* to the natural logarithm of *x*. # For special values and at the origin, the following definitions apply: # * For any infinity, `\log(c\infty) = \log(\tilde \infty) = +\infty`. @@ -607,10 +607,10 @@ cdef extern from "flint_wrap.h": # In the generic case, this function outputs an element of the formal # field `\mathbb{Q}(\log(x))`. - void ca_sin_cos_exponential(ca_t res1, ca_t res2, const ca_t x, ca_ctx_t ctx) - void ca_sin_cos_direct(ca_t res1, ca_t res2, const ca_t x, ca_ctx_t ctx) - void ca_sin_cos_tangent(ca_t res1, ca_t res2, const ca_t x, ca_ctx_t ctx) - void ca_sin_cos(ca_t res1, ca_t res2, const ca_t x, ca_ctx_t ctx) + void ca_sin_cos_exponential(ca_t res1, ca_t res2, const ca_t x, ca_ctx_t ctx) noexcept + void ca_sin_cos_direct(ca_t res1, ca_t res2, const ca_t x, ca_ctx_t ctx) noexcept + void ca_sin_cos_tangent(ca_t res1, ca_t res2, const ca_t x, ca_ctx_t ctx) noexcept + void ca_sin_cos(ca_t res1, ca_t res2, const ca_t x, ca_ctx_t ctx) noexcept # Sets *res1* to the sine of *x* and *res2* to the cosine of *x*. # Either *res1* or *res2* can be *NULL* to compute only the other function. # Various representations are implemented: @@ -638,15 +638,15 @@ cdef extern from "flint_wrap.h": # * `\cos(\pm i \infty) = +\infty` # * All other infinities give `\operatorname{Undefined}` - void ca_sin(ca_t res, const ca_t x, ca_ctx_t ctx) - void ca_cos(ca_t res, const ca_t x, ca_ctx_t ctx) + void ca_sin(ca_t res, const ca_t x, ca_ctx_t ctx) noexcept + void ca_cos(ca_t res, const ca_t x, ca_ctx_t ctx) noexcept # Sets *res* to the sine or cosine of *x*. # These functions are shortcuts for :func:`ca_sin_cos`. - void ca_tan_sine_cosine(ca_t res, const ca_t x, ca_ctx_t ctx) - void ca_tan_exponential(ca_t res, const ca_t x, ca_ctx_t ctx) - void ca_tan_direct(ca_t res, const ca_t x, ca_ctx_t ctx) - void ca_tan(ca_t res, const ca_t x, ca_ctx_t ctx) + void ca_tan_sine_cosine(ca_t res, const ca_t x, ca_ctx_t ctx) noexcept + void ca_tan_exponential(ca_t res, const ca_t x, ca_ctx_t ctx) noexcept + void ca_tan_direct(ca_t res, const ca_t x, ca_ctx_t ctx) noexcept + void ca_tan(ca_t res, const ca_t x, ca_ctx_t ctx) noexcept # Sets *res* to the tangent of *x*. # The *sine_cosine* version evaluates the tangent as a quotient of # a sine and cosine, the *direct* version evaluates it directly @@ -667,13 +667,13 @@ cdef extern from "flint_wrap.h": # * `\tan(e^{i \theta} \infty) = -i, \quad -\pi < \theta < 0` # * `\tan(\pm \infty) = \tan(\tilde \infty) = \operatorname{Undefined}` - void ca_cot(ca_t res, const ca_t x, ca_ctx_t ctx) + void ca_cot(ca_t res, const ca_t x, ca_ctx_t ctx) noexcept # Sets *res* to the cotangent *x*. This is equivalent to # computing the reciprocal of the tangent. - void ca_atan_logarithm(ca_t res, const ca_t x, ca_ctx_t ctx) - void ca_atan_direct(ca_t res, const ca_t x, ca_ctx_t ctx) - void ca_atan(ca_t res, const ca_t x, ca_ctx_t ctx) + void ca_atan_logarithm(ca_t res, const ca_t x, ca_ctx_t ctx) noexcept + void ca_atan_direct(ca_t res, const ca_t x, ca_ctx_t ctx) noexcept + void ca_atan(ca_t res, const ca_t x, ca_ctx_t ctx) noexcept # Sets *res* to the inverse tangent of *x*. # The *direct* version expresses the result as an inverse tangent # (possibly after transforming the variable). The *logarithm* @@ -692,12 +692,12 @@ cdef extern from "flint_wrap.h": # * `\operatorname{atan}(c \infty) = \operatorname{csgn}(c) \pi / 2` # * `\operatorname{atan}(\tilde \infty) = \operatorname{Undefined}` - void ca_asin_logarithm(ca_t res, const ca_t x, ca_ctx_t ctx) - void ca_acos_logarithm(ca_t res, const ca_t x, ca_ctx_t ctx) - void ca_asin_direct(ca_t res, const ca_t x, ca_ctx_t ctx) - void ca_acos_direct(ca_t res, const ca_t x, ca_ctx_t ctx) - void ca_asin(ca_t res, const ca_t x, ca_ctx_t ctx) - void ca_acos(ca_t res, const ca_t x, ca_ctx_t ctx) + void ca_asin_logarithm(ca_t res, const ca_t x, ca_ctx_t ctx) noexcept + void ca_acos_logarithm(ca_t res, const ca_t x, ca_ctx_t ctx) noexcept + void ca_asin_direct(ca_t res, const ca_t x, ca_ctx_t ctx) noexcept + void ca_acos_direct(ca_t res, const ca_t x, ca_ctx_t ctx) noexcept + void ca_asin(ca_t res, const ca_t x, ca_ctx_t ctx) noexcept + void ca_acos(ca_t res, const ca_t x, ca_ctx_t ctx) noexcept # Sets *res* to the inverse sine (respectively, cosine) of *x*. # The *direct* version expresses the result as an inverse sine or # cosine (possibly after transforming the variable). The *logarithm* @@ -714,26 +714,26 @@ cdef extern from "flint_wrap.h": # The inverse cosine is presently implemented as # `\operatorname{acos}(x) = \pi/2 - \operatorname{asin}(x)`. - void ca_gamma(ca_t res, const ca_t x, ca_ctx_t ctx) + void ca_gamma(ca_t res, const ca_t x, ca_ctx_t ctx) noexcept # Sets *res* to the gamma function of *x*. - void ca_erf(ca_t res, const ca_t x, ca_ctx_t ctx) + void ca_erf(ca_t res, const ca_t x, ca_ctx_t ctx) noexcept # Sets *res* to the error function of *x*. - void ca_erfc(ca_t res, const ca_t x, ca_ctx_t ctx) + void ca_erfc(ca_t res, const ca_t x, ca_ctx_t ctx) noexcept # Sets *res* to the complementary error function of *x*. - void ca_erfi(ca_t res, const ca_t x, ca_ctx_t ctx) + void ca_erfi(ca_t res, const ca_t x, ca_ctx_t ctx) noexcept # Sets *res* to the imaginary error function of *x*. - void ca_get_acb_raw(acb_t res, const ca_t x, slong prec, ca_ctx_t ctx) + void ca_get_acb_raw(acb_t res, const ca_t x, slong prec, ca_ctx_t ctx) noexcept # Sets *res* to an enclosure of the numerical value of *x*. # A working precision of *prec* bits is used internally for the evaluation, # without adaptive refinement. # If *x* is any special value, *res* is set to *acb_indeterminate*. - void ca_get_acb(acb_t res, const ca_t x, slong prec, ca_ctx_t ctx) - void ca_get_acb_accurate_parts(acb_t res, const ca_t x, slong prec, ca_ctx_t ctx) + void ca_get_acb(acb_t res, const ca_t x, slong prec, ca_ctx_t ctx) noexcept + void ca_get_acb_accurate_parts(acb_t res, const ca_t x, slong prec, ca_ctx_t ctx) noexcept # Sets *res* to an enclosure of the numerical value of *x*. # The working precision is increased adaptively to try to ensure *prec* # accurate bits in the output. The *accurate_parts* version tries to ensure @@ -746,7 +746,7 @@ cdef extern from "flint_wrap.h": # double rounding); the user may call *acb_set_round* when rounding # is desired. - char * ca_get_decimal_str(const ca_t x, slong digits, ulong flags, ca_ctx_t ctx) + char * ca_get_decimal_str(const ca_t x, slong digits, ulong flags, ca_ctx_t ctx) noexcept # Returns a decimal approximation of *x* with precision up to # *digits*. The output is guaranteed to be correct within 1 ulp # in the returned digits, but the number of returned digits may @@ -758,7 +758,7 @@ cdef extern from "flint_wrap.h": # returns the string "?". # The user should free the returned string with ``flint_free``. - void ca_rewrite_complex_normal_form(ca_t res, const ca_t x, int deep, ca_ctx_t ctx) + void ca_rewrite_complex_normal_form(ca_t res, const ca_t x, int deep, ca_ctx_t ctx) noexcept # Sets *res* to *x* rewritten using standardizing transformations # over the complex numbers: # * Elementary functions are rewritten in terms of (complex) exponentials, roots and logarithms @@ -772,41 +772,41 @@ cdef extern from "flint_wrap.h": # this transformation), but in practice this is a powerful heuristic # for simplification. - void ca_factor_init(ca_factor_t fac, ca_ctx_t ctx) + void ca_factor_init(ca_factor_t fac, ca_ctx_t ctx) noexcept # Initializes *fac* and sets it to the empty factorization # (equivalent to the number 1). - void ca_factor_clear(ca_factor_t fac, ca_ctx_t ctx) + void ca_factor_clear(ca_factor_t fac, ca_ctx_t ctx) noexcept # Clears the factorization structure *fac*. - void ca_factor_one(ca_factor_t fac, ca_ctx_t ctx) + void ca_factor_one(ca_factor_t fac, ca_ctx_t ctx) noexcept # Sets *fac* to the empty factorization (equivalent to the number 1). - void ca_factor_print(const ca_factor_t fac, ca_ctx_t ctx) + void ca_factor_print(const ca_factor_t fac, ca_ctx_t ctx) noexcept # Prints a description of *fac* to standard output. - void ca_factor_insert(ca_factor_t fac, const ca_t base, const ca_t exp, ca_ctx_t ctx) + void ca_factor_insert(ca_factor_t fac, const ca_t base, const ca_t exp, ca_ctx_t ctx) noexcept # Inserts `b^e` into *fac* where *b* is given by *base* and *e* # is given by *exp*. If a base element structurally identical to *base* # already exists in *fac*, the corresponding exponent is incremented by *exp*; # otherwise, this factor is appended. - void ca_factor_get_ca(ca_t res, const ca_factor_t fac, ca_ctx_t ctx) + void ca_factor_get_ca(ca_t res, const ca_factor_t fac, ca_ctx_t ctx) noexcept # Expands *fac* back to a single :type:`ca_t` by evaluating the powers # and multiplying out the result. - void ca_factor(ca_factor_t res, const ca_t x, ulong flags, ca_ctx_t ctx) + void ca_factor(ca_factor_t res, const ca_t x, ulong flags, ca_ctx_t ctx) noexcept # Sets *res* to a factorization of *x* # of the form `x = b_1^{e_1} b_2^{e_2} \cdots b_n^{e_n}`. # Requires that *x* is not a special value. # The type of factorization is controlled by *flags*, which can be set # to a combination of constants in the following section. - void _ca_make_field_element(ca_t x, ca_field_srcptr new_index, ca_ctx_t ctx) + void _ca_make_field_element(ca_t x, ca_field_srcptr new_index, ca_ctx_t ctx) noexcept # Changes the internal representation of *x* to that of an element # of the field with index *new_index* in the context object *ctx*. # This may destroy the value of *x*. - void _ca_make_fmpq(ca_t x, ca_ctx_t ctx) + void _ca_make_fmpq(ca_t x, ca_ctx_t ctx) noexcept # Changes the internal representation of *x* to that of an element of # the trivial field `\mathbb{Q}`. This may destroy the value of *x*. diff --git a/src/sage/libs/flint/ca_ext.pxd b/src/sage/libs/flint/ca_ext.pxd index 8ea2f62cf88..3748622e07b 100644 --- a/src/sage/libs/flint/ca_ext.pxd +++ b/src/sage/libs/flint/ca_ext.pxd @@ -12,68 +12,68 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void ca_ext_init_qqbar(ca_ext_t res, const qqbar_t x, ca_ctx_t ctx) + void ca_ext_init_qqbar(ca_ext_t res, const qqbar_t x, ca_ctx_t ctx) noexcept # Initializes *res* and sets it to the algebraic constant *x*. - void ca_ext_init_const(ca_ext_t res, calcium_func_code func, ca_ctx_t ctx) + void ca_ext_init_const(ca_ext_t res, calcium_func_code func, ca_ctx_t ctx) noexcept # Initializes *res* and sets it to the constant defined by *func* # (example: *func* = *CA_Pi* for `x = \pi`). - void ca_ext_init_fx(ca_ext_t res, calcium_func_code func, const ca_t x, ca_ctx_t ctx) + void ca_ext_init_fx(ca_ext_t res, calcium_func_code func, const ca_t x, ca_ctx_t ctx) noexcept # Initializes *res* and sets it to the univariate function value `f(x)` # where *f* is defined by *func* (example: *func* = *CA_Exp* for `e^x`). - void ca_ext_init_fxy(ca_ext_t res, calcium_func_code func, const ca_t x, const ca_t y, ca_ctx_t ctx) + void ca_ext_init_fxy(ca_ext_t res, calcium_func_code func, const ca_t x, const ca_t y, ca_ctx_t ctx) noexcept # Initializes *res* and sets it to the bivariate function value `f(x, y)` # where *f* is defined by *func* (example: *func* = *CA_Pow* for `x^y`). - void ca_ext_init_fxn(ca_ext_t res, calcium_func_code func, ca_srcptr x, slong nargs, ca_ctx_t ctx) + void ca_ext_init_fxn(ca_ext_t res, calcium_func_code func, ca_srcptr x, slong nargs, ca_ctx_t ctx) noexcept # Initializes *res* and sets it to the multivariate function value # `f(x_1, \ldots, x_n)` where *f* is defined by *func* and *n* is # given by *nargs*. - void ca_ext_init_set(ca_ext_t res, const ca_ext_t x, ca_ctx_t ctx) + void ca_ext_init_set(ca_ext_t res, const ca_ext_t x, ca_ctx_t ctx) noexcept # Initializes *res* and sets it to a copy of *x*. - void ca_ext_clear(ca_ext_t res, ca_ctx_t ctx) + void ca_ext_clear(ca_ext_t res, ca_ctx_t ctx) noexcept # Clears *res*. - slong ca_ext_nargs(const ca_ext_t x, ca_ctx_t ctx) + slong ca_ext_nargs(const ca_ext_t x, ca_ctx_t ctx) noexcept # Returns the number of function arguments of *x*. # The return value is 0 for any algebraic constant and for any built-in # symbolic constant such as `\pi`. - void ca_ext_get_arg(ca_t res, const ca_ext_t x, slong i, ca_ctx_t ctx) + void ca_ext_get_arg(ca_t res, const ca_ext_t x, slong i, ca_ctx_t ctx) noexcept # Sets *res* to argument *i* (indexed from zero) of *x*. # This calls *flint_abort* if *i* is out of range. - ulong ca_ext_hash(const ca_ext_t x, ca_ctx_t ctx) + ulong ca_ext_hash(const ca_ext_t x, ca_ctx_t ctx) noexcept # Returns a hash of the structural representation of *x*. - bint ca_ext_equal_repr(const ca_ext_t x, const ca_ext_t y, ca_ctx_t ctx) + bint ca_ext_equal_repr(const ca_ext_t x, const ca_ext_t y, ca_ctx_t ctx) noexcept # Tests *x* and *y* for structural equality, returning 0 (false) or 1 (true). - int ca_ext_cmp_repr(const ca_ext_t x, const ca_ext_t y, ca_ctx_t ctx) + int ca_ext_cmp_repr(const ca_ext_t x, const ca_ext_t y, ca_ctx_t ctx) noexcept # Compares the representations of *x* and *y* in a canonical sort order, # returning -1, 0 or 1. This only performs a structural comparison # of the symbolic representations; the return value does not say # anything meaningful about the numbers represented by *x* and *y*. - void ca_ext_print(const ca_ext_t x, ca_ctx_t ctx) + void ca_ext_print(const ca_ext_t x, ca_ctx_t ctx) noexcept # Prints a description of *x* to standard output. - void ca_ext_get_acb_raw(acb_t res, ca_ext_t x, slong prec, ca_ctx_t ctx) + void ca_ext_get_acb_raw(acb_t res, ca_ext_t x, slong prec, ca_ctx_t ctx) noexcept # Sets *res* to an enclosure of the numerical value of *x*. # A working precision of *prec* bits is used for the evaluation, # without adaptive refinement. - void ca_ext_cache_init(ca_ext_cache_t cache, ca_ctx_t ctx) + void ca_ext_cache_init(ca_ext_cache_t cache, ca_ctx_t ctx) noexcept # Initializes *cache* for use. - void ca_ext_cache_clear(ca_ext_cache_t cache, ca_ctx_t ctx) + void ca_ext_cache_clear(ca_ext_cache_t cache, ca_ctx_t ctx) noexcept # Clears *cache*, freeing the memory allocated internally. - ca_ext_ptr ca_ext_cache_insert(ca_ext_cache_t cache, const ca_ext_t x, ca_ctx_t ctx) + ca_ext_ptr ca_ext_cache_insert(ca_ext_cache_t cache, const ca_ext_t x, ca_ctx_t ctx) noexcept # Adds *x* to *cache* without duplication. If a structurally identical # instance already exists in *cache*, a pointer to that instance is returned. # Otherwise, a copy of *x* is inserted into *cache* and a pointer to that new diff --git a/src/sage/libs/flint/ca_field.pxd b/src/sage/libs/flint/ca_field.pxd index ebc4cd3af46..bd67f953468 100644 --- a/src/sage/libs/flint/ca_field.pxd +++ b/src/sage/libs/flint/ca_field.pxd @@ -12,51 +12,51 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void ca_field_init_qq(ca_field_t K, ca_ctx_t ctx) + void ca_field_init_qq(ca_field_t K, ca_ctx_t ctx) noexcept # Initializes *K* to represent the trivial field `\mathbb{Q}`. - void ca_field_init_nf(ca_field_t K, const qqbar_t x, ca_ctx_t ctx) + void ca_field_init_nf(ca_field_t K, const qqbar_t x, ca_ctx_t ctx) noexcept # Initializes *K* to represent the algebraic number field `\mathbb{Q}(x)`. - void ca_field_init_const(ca_field_t K, calcium_func_code func, ca_ctx_t ctx) + void ca_field_init_const(ca_field_t K, calcium_func_code func, ca_ctx_t ctx) noexcept # Initializes *K* to represent the field # `\mathbb{Q}(x)` where *x* is a builtin constant defined by # *func* (example: *func* = *CA_Pi* for `x = \pi`). - void ca_field_init_fx(ca_field_t K, calcium_func_code func, const ca_t x, ca_ctx_t ctx) + void ca_field_init_fx(ca_field_t K, calcium_func_code func, const ca_t x, ca_ctx_t ctx) noexcept # Initializes *K* to represent the field # `\mathbb{Q}(a)` where `a = f(x)`, given a number *x* and a builtin # univariate function *func* (example: *func* = *CA_Exp* for `e^x`). - void ca_field_init_fxy(ca_field_t K, calcium_func_code func, const ca_t x, const ca_t y, ca_ctx_t ctx) + void ca_field_init_fxy(ca_field_t K, calcium_func_code func, const ca_t x, const ca_t y, ca_ctx_t ctx) noexcept # Initializes *K* to represent the field # `\mathbb{Q}(a,b)` where `a = f(x, y)`. - void ca_field_init_multi(ca_field_t K, slong len, ca_ctx_t ctx) + void ca_field_init_multi(ca_field_t K, slong len, ca_ctx_t ctx) noexcept # Initializes *K* to represent a multivariate field # `\mathbb{Q}(a_1, \ldots, a_n)` in *n* # extension numbers. The extension numbers must subsequently be # assigned one by one using :func:`ca_field_set_ext`. - void ca_field_set_ext(ca_field_t K, slong i, ca_ext_srcptr x_index, ca_ctx_t ctx) + void ca_field_set_ext(ca_field_t K, slong i, ca_ext_srcptr x_index, ca_ctx_t ctx) noexcept # Sets the extension number at position *i* (here indexed from 0) of *K* # to the generator of the field with index *x_index* in *ctx*. # (It is assumed that the generating field is a univariate field.) # This only inserts a shallow reference: the field at index *x_index* must # be kept alive until *K* has been cleared. - void ca_field_clear(ca_field_t K, ca_ctx_t ctx) + void ca_field_clear(ca_field_t K, ca_ctx_t ctx) noexcept # Clears the field *K*. This does not clear the individual extension # numbers, which are only held as references. - void ca_field_print(const ca_field_t K, ca_ctx_t ctx) + void ca_field_print(const ca_field_t K, ca_ctx_t ctx) noexcept # Prints a description of the field *K* to standard output. - void ca_field_build_ideal(ca_field_t K, ca_ctx_t ctx) + void ca_field_build_ideal(ca_field_t K, ca_ctx_t ctx) noexcept # Given *K* with assigned extension numbers, # builds the reduction ideal in-place. - void ca_field_build_ideal_erf(ca_field_t K, ca_ctx_t ctx) + void ca_field_build_ideal_erf(ca_field_t K, ca_ctx_t ctx) noexcept # Builds relations for error functions present among the extension # numbers in *K*. This heuristic adds relations that are consequences # of the functional equations @@ -64,22 +64,22 @@ cdef extern from "flint_wrap.h": # `\operatorname{erfc}(x) = 1-\operatorname{erf}(x)`, # `\operatorname{erfi}(x) = -i\operatorname{erf}(ix)`. - int ca_field_cmp(const ca_field_t K1, const ca_field_t K2, ca_ctx_t ctx) + int ca_field_cmp(const ca_field_t K1, const ca_field_t K2, ca_ctx_t ctx) noexcept # Compares the field objects *K1* and *K2* in a canonical sort order, # returning -1, 0 or 1. This only performs a lexicographic comparison # of the representations of *K1* and *K2*; the return value does not say # anything meaningful about the relative structures of *K1* and *K2* # as mathematical fields. - void ca_field_cache_init(ca_field_cache_t cache, ca_ctx_t ctx) + void ca_field_cache_init(ca_field_cache_t cache, ca_ctx_t ctx) noexcept # Initializes *cache* for use. - void ca_field_cache_clear(ca_field_cache_t cache, ca_ctx_t ctx) + void ca_field_cache_clear(ca_field_cache_t cache, ca_ctx_t ctx) noexcept # Clears *cache*, freeing the memory allocated internally. # This does not clear the individual extension # numbers, which are only held as references. - ca_field_ptr ca_field_cache_insert_ext(ca_field_cache_t cache, ca_ext_struct ** x, slong len, ca_ctx_t ctx) + ca_field_ptr ca_field_cache_insert_ext(ca_field_cache_t cache, ca_ext_struct ** x, slong len, ca_ctx_t ctx) noexcept # Adds the field defined by the length-*len* list of extension numbers *x* # to *cache* without duplication. If such a field already exists in *cache*, # a pointer to that instance is returned. Otherwise, a field with diff --git a/src/sage/libs/flint/ca_mat.pxd b/src/sage/libs/flint/ca_mat.pxd index ee344c2e1f5..243214f4397 100644 --- a/src/sage/libs/flint/ca_mat.pxd +++ b/src/sage/libs/flint/ca_mat.pxd @@ -12,76 +12,76 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - ca_ptr ca_mat_entry_ptr(ca_mat_t mat, slong i, slong j) + ca_ptr ca_mat_entry_ptr(ca_mat_t mat, slong i, slong j) noexcept # Returns a pointer to the entry at row *i* and column *j*. # Equivalent to :macro:`ca_mat_entry` but implemented as a function. - void ca_mat_init(ca_mat_t mat, slong r, slong c, ca_ctx_t ctx) + void ca_mat_init(ca_mat_t mat, slong r, slong c, ca_ctx_t ctx) noexcept # Initializes the matrix, setting it to the zero matrix with *r* rows # and *c* columns. - void ca_mat_clear(ca_mat_t mat, ca_ctx_t ctx) + void ca_mat_clear(ca_mat_t mat, ca_ctx_t ctx) noexcept # Clears the matrix, deallocating all entries. - void ca_mat_swap(ca_mat_t mat1, ca_mat_t mat2, ca_ctx_t ctx) + void ca_mat_swap(ca_mat_t mat1, ca_mat_t mat2, ca_ctx_t ctx) noexcept # Efficiently swaps *mat1* and *mat2*. - void ca_mat_window_init(ca_mat_t window, const ca_mat_t mat, slong r1, slong c1, slong r2, slong c2, ca_ctx_t ctx) + void ca_mat_window_init(ca_mat_t window, const ca_mat_t mat, slong r1, slong c1, slong r2, slong c2, ca_ctx_t ctx) noexcept # Initializes *window* to a window matrix into the submatrix of *mat* # starting at the corner at row *r1* and column *c1* (inclusive) and ending # at row *r2* and column *c2* (exclusive). - void ca_mat_window_clear(ca_mat_t window, ca_ctx_t ctx) + void ca_mat_window_clear(ca_mat_t window, ca_ctx_t ctx) noexcept # Frees the window matrix. - void ca_mat_set(ca_mat_t dest, const ca_mat_t src, ca_ctx_t ctx) - void ca_mat_set_fmpz_mat(ca_mat_t dest, const fmpz_mat_t src, ca_ctx_t ctx) - void ca_mat_set_fmpq_mat(ca_mat_t dest, const fmpq_mat_t src, ca_ctx_t ctx) + void ca_mat_set(ca_mat_t dest, const ca_mat_t src, ca_ctx_t ctx) noexcept + void ca_mat_set_fmpz_mat(ca_mat_t dest, const fmpz_mat_t src, ca_ctx_t ctx) noexcept + void ca_mat_set_fmpq_mat(ca_mat_t dest, const fmpq_mat_t src, ca_ctx_t ctx) noexcept # Sets *dest* to *src*. The operands must have identical dimensions. - void ca_mat_set_ca(ca_mat_t mat, const ca_t c, ca_ctx_t ctx) + void ca_mat_set_ca(ca_mat_t mat, const ca_t c, ca_ctx_t ctx) noexcept # Sets *mat* to the matrix with the scalar *c* on the main diagonal # and zeros elsewhere. - void ca_mat_transfer(ca_mat_t res, ca_ctx_t res_ctx, const ca_mat_t src, ca_ctx_t src_ctx) + void ca_mat_transfer(ca_mat_t res, ca_ctx_t res_ctx, const ca_mat_t src, ca_ctx_t src_ctx) noexcept # Sets *res* to *src* where the corresponding context objects *res_ctx* and # *src_ctx* may be different. # This operation preserves the mathematical value represented by *src*, # but may result in a different internal representation depending on the # settings of the context objects. - void ca_mat_randtest(ca_mat_t mat, flint_rand_t state, slong depth, slong bits, ca_ctx_t ctx) + void ca_mat_randtest(ca_mat_t mat, flint_rand_t state, slong depth, slong bits, ca_ctx_t ctx) noexcept # Sets *mat* to a random matrix with entries having complexity up to # *depth* and *bits* (see :func:`ca_randtest`). - void ca_mat_randtest_rational(ca_mat_t mat, flint_rand_t state, slong bits, ca_ctx_t ctx) + void ca_mat_randtest_rational(ca_mat_t mat, flint_rand_t state, slong bits, ca_ctx_t ctx) noexcept # Sets *mat* to a random rational matrix with entries up to *bits* bits in size. - void ca_mat_randops(ca_mat_t mat, flint_rand_t state, slong count, ca_ctx_t ctx) + void ca_mat_randops(ca_mat_t mat, flint_rand_t state, slong count, ca_ctx_t ctx) noexcept # Randomizes *mat* in-place by performing elementary row or column operations. # More precisely, at most count random additions or subtractions of distinct # rows and columns will be performed. This leaves the rank (and for square matrices, # the determinant) unchanged. - void ca_mat_print(const ca_mat_t mat, ca_ctx_t ctx) + void ca_mat_print(const ca_mat_t mat, ca_ctx_t ctx) noexcept # Prints *mat* to standard output. The entries are printed on separate lines. - void ca_mat_printn(const ca_mat_t mat, slong digits, ca_ctx_t ctx) + void ca_mat_printn(const ca_mat_t mat, slong digits, ca_ctx_t ctx) noexcept # Prints a decimal representation of *mat* with precision specified by *digits*. # The entries are comma-separated with square brackets and comma separation # for the rows. - void ca_mat_zero(ca_mat_t mat, ca_ctx_t ctx) + void ca_mat_zero(ca_mat_t mat, ca_ctx_t ctx) noexcept # Sets all entries in *mat* to zero. - void ca_mat_one(ca_mat_t mat, ca_ctx_t ctx) + void ca_mat_one(ca_mat_t mat, ca_ctx_t ctx) noexcept # Sets the entries on the main diagonal of *mat* to one, and # all other entries to zero. - void ca_mat_ones(ca_mat_t mat, ca_ctx_t ctx) + void ca_mat_ones(ca_mat_t mat, ca_ctx_t ctx) noexcept # Sets all entries in *mat* to one. - void ca_mat_pascal(ca_mat_t mat, int triangular, ca_ctx_t ctx) + void ca_mat_pascal(ca_mat_t mat, int triangular, ca_ctx_t ctx) noexcept # Sets *mat* to a Pascal matrix, whose entries are binomial coefficients. # If *triangular* is 0, constructs a full symmetric matrix # with the rows of Pascal's triangle as successive antidiagonals. @@ -90,17 +90,17 @@ cdef extern from "flint_wrap.h": # constructs the lower triangular matrix with the rows of Pascal's # triangle as rows. - void ca_mat_stirling(ca_mat_t mat, int kind, ca_ctx_t ctx) + void ca_mat_stirling(ca_mat_t mat, int kind, ca_ctx_t ctx) noexcept # Sets *mat* to a Stirling matrix, whose entries are Stirling numbers. # If *kind* is 0, the entries are set to the unsigned Stirling numbers # of the first kind. If *kind* is 1, the entries are set to the signed # Stirling numbers of the first kind. If *kind* is 2, the entries are # set to the Stirling numbers of the second kind. - void ca_mat_hilbert(ca_mat_t mat, ca_ctx_t ctx) + void ca_mat_hilbert(ca_mat_t mat, ca_ctx_t ctx) noexcept # Sets *mat* to the Hilbert matrix, which has entries `A_{i,j} = 1/(i+j+1)`. - void ca_mat_dft(ca_mat_t mat, int type, ca_ctx_t ctx) + void ca_mat_dft(ca_mat_t mat, int type, ca_ctx_t ctx) noexcept # Sets *mat* to the DFT (discrete Fourier transform) matrix of order *n* # where *n* is the smallest dimension of *mat* (if *mat* is not square, # the matrix is extended periodically along the larger dimension). @@ -113,36 +113,36 @@ cdef extern from "flint_wrap.h": # The type 0 and 1 matrices are inverse pairs, and similarly for the # type 2 and 3 matrices. - truth_t ca_mat_check_equal(const ca_mat_t A, const ca_mat_t B, ca_ctx_t ctx) + truth_t ca_mat_check_equal(const ca_mat_t A, const ca_mat_t B, ca_ctx_t ctx) noexcept # Compares *A* and *B* for equality. - truth_t ca_mat_check_is_zero(const ca_mat_t A, ca_ctx_t ctx) + truth_t ca_mat_check_is_zero(const ca_mat_t A, ca_ctx_t ctx) noexcept # Tests if *A* is the zero matrix. - truth_t ca_mat_check_is_one(const ca_mat_t A, ca_ctx_t ctx) + truth_t ca_mat_check_is_one(const ca_mat_t A, ca_ctx_t ctx) noexcept # Tests if *A* has ones on the main diagonal and zeros elsewhere. - void ca_mat_transpose(ca_mat_t res, const ca_mat_t A, ca_ctx_t ctx) + void ca_mat_transpose(ca_mat_t res, const ca_mat_t A, ca_ctx_t ctx) noexcept # Sets *res* to the transpose of *A*. - void ca_mat_conj(ca_mat_t res, const ca_mat_t A, ca_ctx_t ctx) + void ca_mat_conj(ca_mat_t res, const ca_mat_t A, ca_ctx_t ctx) noexcept # Sets *res* to the entrywise complex conjugate of *A*. - void ca_mat_conj_transpose(ca_mat_t res, const ca_mat_t A, ca_ctx_t ctx) + void ca_mat_conj_transpose(ca_mat_t res, const ca_mat_t A, ca_ctx_t ctx) noexcept # Sets *res* to the conjugate transpose (Hermitian transpose) of *A*. - void ca_mat_neg(ca_mat_t res, const ca_mat_t A, ca_ctx_t ctx) + void ca_mat_neg(ca_mat_t res, const ca_mat_t A, ca_ctx_t ctx) noexcept # Sets *res* to the negation of *A*. - void ca_mat_add(ca_mat_t res, const ca_mat_t A, const ca_mat_t B, ca_ctx_t ctx) + void ca_mat_add(ca_mat_t res, const ca_mat_t A, const ca_mat_t B, ca_ctx_t ctx) noexcept # Sets *res* to the sum of *A* and *B*. - void ca_mat_sub(ca_mat_t res, const ca_mat_t A, const ca_mat_t B, ca_ctx_t ctx) + void ca_mat_sub(ca_mat_t res, const ca_mat_t A, const ca_mat_t B, ca_ctx_t ctx) noexcept # Sets *res* to the difference of *A* and *B*. - void ca_mat_mul_classical(ca_mat_t res, const ca_mat_t A, const ca_mat_t B, ca_ctx_t ctx) - void ca_mat_mul_same_nf(ca_mat_t res, const ca_mat_t A, const ca_mat_t B, ca_field_t K, ca_ctx_t ctx) - void ca_mat_mul(ca_mat_t res, const ca_mat_t A, const ca_mat_t B, ca_ctx_t ctx) + void ca_mat_mul_classical(ca_mat_t res, const ca_mat_t A, const ca_mat_t B, ca_ctx_t ctx) noexcept + void ca_mat_mul_same_nf(ca_mat_t res, const ca_mat_t A, const ca_mat_t B, ca_field_t K, ca_ctx_t ctx) noexcept + void ca_mat_mul(ca_mat_t res, const ca_mat_t A, const ca_mat_t B, ca_ctx_t ctx) noexcept # Sets *res* to the matrix product of *A* and *B*. # The *classical* version uses classical multiplication. # The *same_nf* version assumes (not checked) that both *A* and *B* @@ -150,39 +150,39 @@ cdef extern from "flint_wrap.h": # or in `\mathbb{Q}`. # The default version chooses an algorithm automatically. - void ca_mat_mul_si(ca_mat_t B, const ca_mat_t A, slong c, ca_ctx_t ctx) - void ca_mat_mul_fmpz(ca_mat_t B, const ca_mat_t A, const fmpz_t c, ca_ctx_t ctx) - void ca_mat_mul_fmpq(ca_mat_t B, const ca_mat_t A, const fmpq_t c, ca_ctx_t ctx) - void ca_mat_mul_ca(ca_mat_t B, const ca_mat_t A, const ca_t c, ca_ctx_t ctx) + void ca_mat_mul_si(ca_mat_t B, const ca_mat_t A, slong c, ca_ctx_t ctx) noexcept + void ca_mat_mul_fmpz(ca_mat_t B, const ca_mat_t A, const fmpz_t c, ca_ctx_t ctx) noexcept + void ca_mat_mul_fmpq(ca_mat_t B, const ca_mat_t A, const fmpq_t c, ca_ctx_t ctx) noexcept + void ca_mat_mul_ca(ca_mat_t B, const ca_mat_t A, const ca_t c, ca_ctx_t ctx) noexcept # Sets *B* to *A* multiplied by the scalar *c*. - void ca_mat_div_si(ca_mat_t B, const ca_mat_t A, slong c, ca_ctx_t ctx) - void ca_mat_div_fmpz(ca_mat_t B, const ca_mat_t A, const fmpz_t c, ca_ctx_t ctx) - void ca_mat_div_fmpq(ca_mat_t B, const ca_mat_t A, const fmpq_t c, ca_ctx_t ctx) - void ca_mat_div_ca(ca_mat_t B, const ca_mat_t A, const ca_t c, ca_ctx_t ctx) + void ca_mat_div_si(ca_mat_t B, const ca_mat_t A, slong c, ca_ctx_t ctx) noexcept + void ca_mat_div_fmpz(ca_mat_t B, const ca_mat_t A, const fmpz_t c, ca_ctx_t ctx) noexcept + void ca_mat_div_fmpq(ca_mat_t B, const ca_mat_t A, const fmpq_t c, ca_ctx_t ctx) noexcept + void ca_mat_div_ca(ca_mat_t B, const ca_mat_t A, const ca_t c, ca_ctx_t ctx) noexcept # Sets *B* to *A* divided by the scalar *c*. - void ca_mat_add_ca(ca_mat_t B, const ca_mat_t A, const ca_t c, ca_ctx_t ctx) - void ca_mat_sub_ca(ca_mat_t B, const ca_mat_t A, const ca_t c, ca_ctx_t ctx) + void ca_mat_add_ca(ca_mat_t B, const ca_mat_t A, const ca_t c, ca_ctx_t ctx) noexcept + void ca_mat_sub_ca(ca_mat_t B, const ca_mat_t A, const ca_t c, ca_ctx_t ctx) noexcept # Sets *B* to *A* plus or minus the scalar *c* (interpreted as a diagonal matrix). - void ca_mat_addmul_ca(ca_mat_t B, const ca_mat_t A, const ca_t c, ca_ctx_t ctx) - void ca_mat_submul_ca(ca_mat_t B, const ca_mat_t A, const ca_t c, ca_ctx_t ctx) + void ca_mat_addmul_ca(ca_mat_t B, const ca_mat_t A, const ca_t c, ca_ctx_t ctx) noexcept + void ca_mat_submul_ca(ca_mat_t B, const ca_mat_t A, const ca_t c, ca_ctx_t ctx) noexcept # Sets the matrix *B* to *B* plus (or minus) the matrix *A* multiplied by the scalar *c*. - void ca_mat_sqr(ca_mat_t B, const ca_mat_t A, ca_ctx_t ctx) + void ca_mat_sqr(ca_mat_t B, const ca_mat_t A, ca_ctx_t ctx) noexcept # Sets *B* to the square of *A*. - void ca_mat_pow_ui_binexp(ca_mat_t B, const ca_mat_t A, ulong exp, ca_ctx_t ctx) + void ca_mat_pow_ui_binexp(ca_mat_t B, const ca_mat_t A, ulong exp, ca_ctx_t ctx) noexcept # Sets *B* to *A* raised to the power *exp*, evaluated using # binary exponentiation. - void _ca_mat_ca_poly_evaluate(ca_mat_t res, ca_srcptr poly, slong len, const ca_mat_t A, ca_ctx_t ctx) - void ca_mat_ca_poly_evaluate(ca_mat_t res, const ca_poly_t poly, const ca_mat_t A, ca_ctx_t ctx) + void _ca_mat_ca_poly_evaluate(ca_mat_t res, ca_srcptr poly, slong len, const ca_mat_t A, ca_ctx_t ctx) noexcept + void ca_mat_ca_poly_evaluate(ca_mat_t res, const ca_poly_t poly, const ca_mat_t A, ca_ctx_t ctx) noexcept # Sets *res* to `f(A)` where *f* is the polynomial given by *poly* # and *A* is a square matrix. Uses the Paterson-Stockmeyer algorithm. - truth_t ca_mat_find_pivot(slong * pivot_row, ca_mat_t mat, slong start_row, slong end_row, slong column, ca_ctx_t ctx) + truth_t ca_mat_find_pivot(slong * pivot_row, ca_mat_t mat, slong start_row, slong end_row, slong column, ca_ctx_t ctx) noexcept # Attempts to find a nonzero entry in *mat* with column index *column* # and row index between *start_row* (inclusive) and *end_row* (exclusive). # If the return value is ``T_TRUE``, such an element exists, @@ -194,9 +194,9 @@ cdef extern from "flint_wrap.h": # This function is destructive: any elements that are nontrivially # zero but can be certified zero will be overwritten by exact zeros. - int ca_mat_lu_classical(slong * rank, slong * P, ca_mat_t LU, const ca_mat_t A, int rank_check, ca_ctx_t ctx) - int ca_mat_lu_recursive(slong * rank, slong * P, ca_mat_t LU, const ca_mat_t A, int rank_check, ca_ctx_t ctx) - int ca_mat_lu(slong * rank, slong * P, ca_mat_t LU, const ca_mat_t A, int rank_check, ca_ctx_t ctx) + int ca_mat_lu_classical(slong * rank, slong * P, ca_mat_t LU, const ca_mat_t A, int rank_check, ca_ctx_t ctx) noexcept + int ca_mat_lu_recursive(slong * rank, slong * P, ca_mat_t LU, const ca_mat_t A, int rank_check, ca_ctx_t ctx) noexcept + int ca_mat_lu(slong * rank, slong * P, ca_mat_t LU, const ca_mat_t A, int rank_check, ca_ctx_t ctx) noexcept # Computes a generalized LU decomposition `A = PLU` of a given # matrix *A*, writing the rank of *A* to *rank*. # If *A* is a nonsingular square matrix, *LU* will be set to @@ -221,14 +221,14 @@ cdef extern from "flint_wrap.h": # The *recursive* version uses a block recursive algorithm # to take advantage of fast matrix multiplication. - int ca_mat_fflu(slong * rank, slong * P, ca_mat_t LU, ca_t den, const ca_mat_t A, int rank_check, ca_ctx_t ctx) + int ca_mat_fflu(slong * rank, slong * P, ca_mat_t LU, ca_t den, const ca_mat_t A, int rank_check, ca_ctx_t ctx) noexcept # Similar to :func:`ca_mat_lu`, but computes a fraction-free # LU decomposition using the Bareiss algorithm. # The denominator is written to *den*. # Note that despite being "fraction-free", this algorithm may # introduce fractions due to incomplete symbolic simplifications. - truth_t ca_mat_nonsingular_lu(slong * P, ca_mat_t LU, const ca_mat_t A, ca_ctx_t ctx) + truth_t ca_mat_nonsingular_lu(slong * P, ca_mat_t LU, const ca_mat_t A, ca_ctx_t ctx) noexcept # Wrapper for :func:`ca_mat_lu`. # If *A* can be proved to be invertible/nonsingular, returns ``T_TRUE`` and sets *P* and *LU* to a LU decomposition `A = PLU`. # If *A* can be proved to be singular, returns ``T_FALSE``. @@ -237,7 +237,7 @@ cdef extern from "flint_wrap.h": # LU factorization is not completed and the values of # *P* and *LU* are arbitrary. - truth_t ca_mat_nonsingular_fflu(slong * P, ca_mat_t LU, ca_t den, const ca_mat_t A, ca_ctx_t ctx) + truth_t ca_mat_nonsingular_fflu(slong * P, ca_mat_t LU, ca_t den, const ca_mat_t A, ca_ctx_t ctx) noexcept # Wrapper for :func:`ca_mat_fflu`. # Similar to :func:`ca_mat_nonsingular_lu`, but computes a fraction-free # LU decomposition using the Bareiss algorithm. @@ -245,27 +245,27 @@ cdef extern from "flint_wrap.h": # Note that despite being "fraction-free", this algorithm may # introduce fractions due to incomplete symbolic simplifications. - truth_t ca_mat_inv(ca_mat_t X, const ca_mat_t A, ca_ctx_t ctx) + truth_t ca_mat_inv(ca_mat_t X, const ca_mat_t A, ca_ctx_t ctx) noexcept # Determines if the square matrix *A* is nonsingular, and if successful, # sets `X = A^{-1}` and returns ``T_TRUE``. # Returns ``T_FALSE`` if *A* is singular, and ``T_UNKNOWN`` if the # rank of *A* cannot be determined. - truth_t ca_mat_nonsingular_solve_adjugate(ca_mat_t X, const ca_mat_t A, const ca_mat_t B, ca_ctx_t ctx) - truth_t ca_mat_nonsingular_solve_fflu(ca_mat_t X, const ca_mat_t A, const ca_mat_t B, ca_ctx_t ctx) - truth_t ca_mat_nonsingular_solve_lu(ca_mat_t X, const ca_mat_t A, const ca_mat_t B, ca_ctx_t ctx) - truth_t ca_mat_nonsingular_solve(ca_mat_t X, const ca_mat_t A, const ca_mat_t B, ca_ctx_t ctx) + truth_t ca_mat_nonsingular_solve_adjugate(ca_mat_t X, const ca_mat_t A, const ca_mat_t B, ca_ctx_t ctx) noexcept + truth_t ca_mat_nonsingular_solve_fflu(ca_mat_t X, const ca_mat_t A, const ca_mat_t B, ca_ctx_t ctx) noexcept + truth_t ca_mat_nonsingular_solve_lu(ca_mat_t X, const ca_mat_t A, const ca_mat_t B, ca_ctx_t ctx) noexcept + truth_t ca_mat_nonsingular_solve(ca_mat_t X, const ca_mat_t A, const ca_mat_t B, ca_ctx_t ctx) noexcept # Determines if the square matrix *A* is nonsingular, and if successful, # solves `AX = B` and returns ``T_TRUE``. # Returns ``T_FALSE`` if *A* is singular, and ``T_UNKNOWN`` if the # rank of *A* cannot be determined. - void ca_mat_solve_tril_classical(ca_mat_t X, const ca_mat_t L, const ca_mat_t B, int unit, ca_ctx_t ctx) - void ca_mat_solve_tril_recursive(ca_mat_t X, const ca_mat_t L, const ca_mat_t B, int unit, ca_ctx_t ctx) - void ca_mat_solve_tril(ca_mat_t X, const ca_mat_t L, const ca_mat_t B, int unit, ca_ctx_t ctx) - void ca_mat_solve_triu_classical(ca_mat_t X, const ca_mat_t U, const ca_mat_t B, int unit, ca_ctx_t ctx) - void ca_mat_solve_triu_recursive(ca_mat_t X, const ca_mat_t U, const ca_mat_t B, int unit, ca_ctx_t ctx) - void ca_mat_solve_triu(ca_mat_t X, const ca_mat_t U, const ca_mat_t B, int unit, ca_ctx_t ctx) + void ca_mat_solve_tril_classical(ca_mat_t X, const ca_mat_t L, const ca_mat_t B, int unit, ca_ctx_t ctx) noexcept + void ca_mat_solve_tril_recursive(ca_mat_t X, const ca_mat_t L, const ca_mat_t B, int unit, ca_ctx_t ctx) noexcept + void ca_mat_solve_tril(ca_mat_t X, const ca_mat_t L, const ca_mat_t B, int unit, ca_ctx_t ctx) noexcept + void ca_mat_solve_triu_classical(ca_mat_t X, const ca_mat_t U, const ca_mat_t B, int unit, ca_ctx_t ctx) noexcept + void ca_mat_solve_triu_recursive(ca_mat_t X, const ca_mat_t U, const ca_mat_t B, int unit, ca_ctx_t ctx) noexcept + void ca_mat_solve_triu(ca_mat_t X, const ca_mat_t U, const ca_mat_t B, int unit, ca_ctx_t ctx) noexcept # Solves the lower triangular system `LX = B` or the upper triangular system # `UX = B`, respectively. It is assumed (not checked) that the diagonal # entries are nonzero. If *unit* is set, the main diagonal of *L* or *U* @@ -276,20 +276,20 @@ cdef extern from "flint_wrap.h": # way to benefit from fast matrix multiplication. The default versions # choose an algorithm automatically. - void ca_mat_solve_fflu_precomp(ca_mat_t X, const slong * perm, const ca_mat_t A, const ca_t den, const ca_mat_t B, ca_ctx_t ctx) - void ca_mat_solve_lu_precomp(ca_mat_t X, const slong * P, const ca_mat_t LU, const ca_mat_t B, ca_ctx_t ctx) + void ca_mat_solve_fflu_precomp(ca_mat_t X, const slong * perm, const ca_mat_t A, const ca_t den, const ca_mat_t B, ca_ctx_t ctx) noexcept + void ca_mat_solve_lu_precomp(ca_mat_t X, const slong * P, const ca_mat_t LU, const ca_mat_t B, ca_ctx_t ctx) noexcept # Solves `AX = B` given the precomputed nonsingular LU decomposition `A = PLU` # or fraction-free LU decomposition with denominator *den*. # The matrices `X` and `B` are allowed to be aliased with each other, # but `X` is not allowed to be aliased with `LU`. - int ca_mat_rank(slong * rank, const ca_mat_t A, ca_ctx_t ctx) + int ca_mat_rank(slong * rank, const ca_mat_t A, ca_ctx_t ctx) noexcept # Computes the rank of the matrix *A*. If successful, returns 1 and # writes the rank to ``rank``. If unsuccessful, returns 0. - int ca_mat_rref_fflu(slong * rank, ca_mat_t R, const ca_mat_t A, ca_ctx_t ctx) - int ca_mat_rref_lu(slong * rank, ca_mat_t R, const ca_mat_t A, ca_ctx_t ctx) - int ca_mat_rref(slong * rank, ca_mat_t R, const ca_mat_t A, ca_ctx_t ctx) + int ca_mat_rref_fflu(slong * rank, ca_mat_t R, const ca_mat_t A, ca_ctx_t ctx) noexcept + int ca_mat_rref_lu(slong * rank, ca_mat_t R, const ca_mat_t A, ca_ctx_t ctx) noexcept + int ca_mat_rref(slong * rank, ca_mat_t R, const ca_mat_t A, ca_ctx_t ctx) noexcept # Computes the reduced row echelon form (rref) of a given matrix. # On success, sets *R* to the rref of *A*, writes the rank to # *rank*, and returns 1. On failure to certify the correct rank, @@ -300,21 +300,21 @@ cdef extern from "flint_wrap.h": # The default version uses an automatic algorithm choice and may # implement additional methods for special cases. - int ca_mat_right_kernel(ca_mat_t X, const ca_mat_t A, ca_ctx_t ctx) + int ca_mat_right_kernel(ca_mat_t X, const ca_mat_t A, ca_ctx_t ctx) noexcept # Sets *X* to a basis of the right kernel (nullspace) of *A*. # The output matrix *X* will be resized in-place to have a number # of columns equal to the nullity of *A*. # Returns 1 on success. On failure, returns 0 and leaves the data # in *X* meaningless. - void ca_mat_trace(ca_t trace, const ca_mat_t mat, ca_ctx_t ctx) + void ca_mat_trace(ca_t trace, const ca_mat_t mat, ca_ctx_t ctx) noexcept # Sets *trace* to the sum of the entries on the main diagonal of *mat*. - void ca_mat_det_berkowitz(ca_t det, const ca_mat_t A, ca_ctx_t ctx) - int ca_mat_det_lu(ca_t det, const ca_mat_t A, ca_ctx_t ctx) - int ca_mat_det_bareiss(ca_t det, const ca_mat_t A, ca_ctx_t ctx) - void ca_mat_det_cofactor(ca_t det, const ca_mat_t A, ca_ctx_t ctx) - void ca_mat_det(ca_t det, const ca_mat_t A, ca_ctx_t ctx) + void ca_mat_det_berkowitz(ca_t det, const ca_mat_t A, ca_ctx_t ctx) noexcept + int ca_mat_det_lu(ca_t det, const ca_mat_t A, ca_ctx_t ctx) noexcept + int ca_mat_det_bareiss(ca_t det, const ca_mat_t A, ca_ctx_t ctx) noexcept + void ca_mat_det_cofactor(ca_t det, const ca_mat_t A, ca_ctx_t ctx) noexcept + void ca_mat_det(ca_t det, const ca_mat_t A, ca_ctx_t ctx) noexcept # Sets *det* to the determinant of the square matrix *A*. # Various algorithms are available: # * The *berkowitz* version uses the division-free Berkowitz algorithm @@ -338,9 +338,9 @@ cdef extern from "flint_wrap.h": # depends strongly and sometimes # unpredictably on the structure of the matrix. - void ca_mat_adjugate_cofactor(ca_mat_t adj, ca_t det, const ca_mat_t A, ca_ctx_t ctx) - void ca_mat_adjugate_charpoly(ca_mat_t adj, ca_t det, const ca_mat_t A, ca_ctx_t ctx) - void ca_mat_adjugate(ca_mat_t adj, ca_t det, const ca_mat_t A, ca_ctx_t ctx) + void ca_mat_adjugate_cofactor(ca_mat_t adj, ca_t det, const ca_mat_t A, ca_ctx_t ctx) noexcept + void ca_mat_adjugate_charpoly(ca_mat_t adj, ca_t det, const ca_mat_t A, ca_ctx_t ctx) noexcept + void ca_mat_adjugate(ca_mat_t adj, ca_t det, const ca_mat_t A, ca_ctx_t ctx) noexcept # Sets *adj* to the adjuate matrix of *A* and *det* to the determinant # of *A*, both computed simultaneously. # The *cofactor* version uses cofactor expansion. @@ -348,12 +348,12 @@ cdef extern from "flint_wrap.h": # evaluates the characteristic polynomial. # The default version uses an automatic algorithm choice. - void _ca_mat_charpoly_berkowitz(ca_ptr cp, const ca_mat_t mat, ca_ctx_t ctx) - void ca_mat_charpoly_berkowitz(ca_poly_t cp, const ca_mat_t mat, ca_ctx_t ctx) - int _ca_mat_charpoly_danilevsky(ca_ptr cp, const ca_mat_t mat, ca_ctx_t ctx) - int ca_mat_charpoly_danilevsky(ca_poly_t cp, const ca_mat_t mat, ca_ctx_t ctx) - void _ca_mat_charpoly(ca_ptr cp, const ca_mat_t mat, ca_ctx_t ctx) - void ca_mat_charpoly(ca_poly_t cp, const ca_mat_t mat, ca_ctx_t ctx) + void _ca_mat_charpoly_berkowitz(ca_ptr cp, const ca_mat_t mat, ca_ctx_t ctx) noexcept + void ca_mat_charpoly_berkowitz(ca_poly_t cp, const ca_mat_t mat, ca_ctx_t ctx) noexcept + int _ca_mat_charpoly_danilevsky(ca_ptr cp, const ca_mat_t mat, ca_ctx_t ctx) noexcept + int ca_mat_charpoly_danilevsky(ca_poly_t cp, const ca_mat_t mat, ca_ctx_t ctx) noexcept + void _ca_mat_charpoly(ca_ptr cp, const ca_mat_t mat, ca_ctx_t ctx) noexcept + void ca_mat_charpoly(ca_poly_t cp, const ca_mat_t mat, ca_ctx_t ctx) noexcept # Sets *poly* to the characteristic polynomial of *mat* which must be # a square matrix. If the matrix has *n* rows, the underscore method # requires space for `n + 1` output coefficients. @@ -364,7 +364,7 @@ cdef extern from "flint_wrap.h": # This version returns 1 on success and 0 on failure. # The default version chooses an algorithm automatically. - int ca_mat_companion(ca_mat_t mat, const ca_poly_t poly, ca_ctx_t ctx) + int ca_mat_companion(ca_mat_t mat, const ca_poly_t poly, ca_ctx_t ctx) noexcept # Sets *mat* to the companion matrix of *poly*. # This function verifies that the leading coefficient of *poly* # is provably nonzero and that the output matrix has the right size, @@ -372,7 +372,7 @@ cdef extern from "flint_wrap.h": # It returns 0 if the leading coefficient of *poly* cannot be # proved nonzero or if the size of the output matrix does not match. - int ca_mat_eigenvalues(ca_vec_t lmbda, ulong * exp, const ca_mat_t mat, ca_ctx_t ctx) + int ca_mat_eigenvalues(ca_vec_t lmbda, ulong * exp, const ca_mat_t mat, ca_ctx_t ctx) noexcept # Attempts to compute all complex eigenvalues of the given matrix *mat*. # On success, returns 1 and sets *lambda* to the distinct eigenvalues # with corresponding multiplicities in *exp*. @@ -382,7 +382,7 @@ cdef extern from "flint_wrap.h": # This function effectively computes the characteristic polynomial # and then calls :type:`ca_poly_roots`. - truth_t ca_mat_diagonalization(ca_mat_t D, ca_mat_t P, const ca_mat_t A, ca_ctx_t ctx) + truth_t ca_mat_diagonalization(ca_mat_t D, ca_mat_t P, const ca_mat_t A, ca_ctx_t ctx) noexcept # Matrix diagonalization: attempts to compute a diagonal matrix *D* # and an invertible matrix *P* such that `A = PDP^{-1}`. # Returns ``T_TRUE`` if *A* is diagonalizable and the computation @@ -391,7 +391,7 @@ cdef extern from "flint_wrap.h": # If the return value is not ``T_TRUE``, the values in *D* and *P* # are arbitrary. - int ca_mat_jordan_blocks(ca_vec_t lmbda, slong * num_blocks, slong * block_lambda, slong * block_size, const ca_mat_t A, ca_ctx_t ctx) + int ca_mat_jordan_blocks(ca_vec_t lmbda, slong * num_blocks, slong * block_lambda, slong * block_size, const ca_mat_t A, ca_ctx_t ctx) noexcept # Computes the blocks of the Jordan canonical form of *A*. # On success, returns 1 and sets *lambda* to the unique eigenvalues # of *A*, sets *num_blocks* to the number of Jordan blocks, @@ -404,13 +404,13 @@ cdef extern from "flint_wrap.h": # The Jordan form is unique up to the ordering of blocks, which # is arbitrary. - void ca_mat_set_jordan_blocks(ca_mat_t mat, const ca_vec_t lmbda, slong num_blocks, slong * block_lambda, slong * block_size, ca_ctx_t ctx) + void ca_mat_set_jordan_blocks(ca_mat_t mat, const ca_vec_t lmbda, slong num_blocks, slong * block_lambda, slong * block_size, ca_ctx_t ctx) noexcept # Sets *mat* to the concatenation of the Jordan blocks # given in *lambda*, *num_blocks*, *block_lambda* and *block_size*. # See :func:`ca_mat_jordan_blocks` for an explanation of these # variables. - int ca_mat_jordan_transformation(ca_mat_t mat, const ca_vec_t lmbda, slong num_blocks, slong * block_lambda, slong * block_size, const ca_mat_t A, ca_ctx_t ctx) + int ca_mat_jordan_transformation(ca_mat_t mat, const ca_vec_t lmbda, slong num_blocks, slong * block_lambda, slong * block_size, const ca_mat_t A, ca_ctx_t ctx) noexcept # Given the precomputed Jordan block decomposition # (*lambda*, *num_blocks*, *block_lambda*, *block_size*) of the # square matrix *A*, computes the corresponding transformation @@ -418,7 +418,7 @@ cdef extern from "flint_wrap.h": # On success, writes *P* to *mat* and returns 1. On failure, # returns 0, leaving the value of *mat* arbitrary. - int ca_mat_jordan_form(ca_mat_t J, ca_mat_t P, const ca_mat_t A, ca_ctx_t ctx) + int ca_mat_jordan_form(ca_mat_t J, ca_mat_t P, const ca_mat_t A, ca_ctx_t ctx) noexcept # Computes the Jordan decomposition `A = P J P^{-1}` of the given # square matrix *A*. The user can pass *NULL* for the output # variable *P*, in which case only *J* is computed. @@ -431,7 +431,7 @@ cdef extern from "flint_wrap.h": # methods directly since they give direct access to the # spectrum and block structure. - int ca_mat_exp(ca_mat_t res, const ca_mat_t A, ca_ctx_t ctx) + int ca_mat_exp(ca_mat_t res, const ca_mat_t A, ca_ctx_t ctx) noexcept # Matrix exponential: given a square matrix *A*, sets *res* to # `e^A` and returns 1 on success. If unsuccessful, returns 0, # leaving the values in *res* arbitrary. @@ -439,7 +439,7 @@ cdef extern from "flint_wrap.h": # always exists, but computation can fail if computing the Jordan # decomposition fails. - truth_t ca_mat_log(ca_mat_t res, const ca_mat_t A, ca_ctx_t ctx) + truth_t ca_mat_log(ca_mat_t res, const ca_mat_t A, ca_ctx_t ctx) noexcept # Matrix logarithm: given a square matrix *A*, sets *res* to a # logarithm `\log(A)` and returns ``T_TRUE`` on success. # If *A* can be proved to have no logarithm, returns ``T_FALSE``. diff --git a/src/sage/libs/flint/ca_poly.pxd b/src/sage/libs/flint/ca_poly.pxd index 00d4a4cd4b1..67ab0f8c8ab 100644 --- a/src/sage/libs/flint/ca_poly.pxd +++ b/src/sage/libs/flint/ca_poly.pxd @@ -12,67 +12,67 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void ca_poly_init(ca_poly_t poly, ca_ctx_t ctx) + void ca_poly_init(ca_poly_t poly, ca_ctx_t ctx) noexcept # Initializes the polynomial for use, setting it to the zero polynomial. - void ca_poly_clear(ca_poly_t poly, ca_ctx_t ctx) + void ca_poly_clear(ca_poly_t poly, ca_ctx_t ctx) noexcept # Clears the polynomial, deallocating all coefficients and the # coefficient array. - void ca_poly_fit_length(ca_poly_t poly, slong len, ca_ctx_t ctx) + void ca_poly_fit_length(ca_poly_t poly, slong len, ca_ctx_t ctx) noexcept # Makes sure that the coefficient array of the polynomial contains at # least *len* initialized coefficients. - void _ca_poly_set_length(ca_poly_t poly, slong len, ca_ctx_t ctx) + void _ca_poly_set_length(ca_poly_t poly, slong len, ca_ctx_t ctx) noexcept # Directly changes the length of the polynomial, without allocating or # deallocating coefficients. The value should not exceed the allocation length. - void _ca_poly_normalise(ca_poly_t poly, ca_ctx_t ctx) + void _ca_poly_normalise(ca_poly_t poly, ca_ctx_t ctx) noexcept # Strips any top coefficients which can be proved identical to zero. - void ca_poly_zero(ca_poly_t poly, ca_ctx_t ctx) + void ca_poly_zero(ca_poly_t poly, ca_ctx_t ctx) noexcept # Sets *poly* to the zero polynomial. - void ca_poly_one(ca_poly_t poly, ca_ctx_t ctx) + void ca_poly_one(ca_poly_t poly, ca_ctx_t ctx) noexcept # Sets *poly* to the constant polynomial 1. - void ca_poly_x(ca_poly_t poly, ca_ctx_t ctx) + void ca_poly_x(ca_poly_t poly, ca_ctx_t ctx) noexcept # Sets *poly* to the monomial *x*. - void ca_poly_set_ca(ca_poly_t poly, const ca_t c, ca_ctx_t ctx) - void ca_poly_set_si(ca_poly_t poly, slong c, ca_ctx_t ctx) + void ca_poly_set_ca(ca_poly_t poly, const ca_t c, ca_ctx_t ctx) noexcept + void ca_poly_set_si(ca_poly_t poly, slong c, ca_ctx_t ctx) noexcept # Sets *poly* to the constant polynomial *c*. - void ca_poly_set(ca_poly_t res, const ca_poly_t src, ca_ctx_t ctx) - void ca_poly_set_fmpz_poly(ca_poly_t res, const fmpz_poly_t src, ca_ctx_t ctx) - void ca_poly_set_fmpq_poly(ca_poly_t res, const fmpq_poly_t src, ca_ctx_t ctx) + void ca_poly_set(ca_poly_t res, const ca_poly_t src, ca_ctx_t ctx) noexcept + void ca_poly_set_fmpz_poly(ca_poly_t res, const fmpz_poly_t src, ca_ctx_t ctx) noexcept + void ca_poly_set_fmpq_poly(ca_poly_t res, const fmpq_poly_t src, ca_ctx_t ctx) noexcept # Sets *poly* the polynomial *src*. - void ca_poly_set_coeff_ca(ca_poly_t poly, slong n, const ca_t x, ca_ctx_t ctx) + void ca_poly_set_coeff_ca(ca_poly_t poly, slong n, const ca_t x, ca_ctx_t ctx) noexcept # Sets the coefficient at position *n* in *poly* to *x*. - void ca_poly_transfer(ca_poly_t res, ca_ctx_t res_ctx, const ca_poly_t src, ca_ctx_t src_ctx) + void ca_poly_transfer(ca_poly_t res, ca_ctx_t res_ctx, const ca_poly_t src, ca_ctx_t src_ctx) noexcept # Sets *res* to *src* where the corresponding context objects *res_ctx* and # *src_ctx* may be different. # This operation preserves the mathematical value represented by *src*, # but may result in a different internal representation depending on the # settings of the context objects. - void ca_poly_randtest(ca_poly_t poly, flint_rand_t state, slong len, slong depth, slong bits, ca_ctx_t ctx) + void ca_poly_randtest(ca_poly_t poly, flint_rand_t state, slong len, slong depth, slong bits, ca_ctx_t ctx) noexcept # Sets *poly* to a random polynomial of length up to *len* and with entries having complexity up to # *depth* and *bits* (see :func:`ca_randtest`). - void ca_poly_randtest_rational(ca_poly_t poly, flint_rand_t state, slong len, slong bits, ca_ctx_t ctx) + void ca_poly_randtest_rational(ca_poly_t poly, flint_rand_t state, slong len, slong bits, ca_ctx_t ctx) noexcept # Sets *poly* to a random rational polynomial of length up to *len* and with entries up to *bits* bits in size. - void ca_poly_print(const ca_poly_t poly, ca_ctx_t ctx) + void ca_poly_print(const ca_poly_t poly, ca_ctx_t ctx) noexcept # Prints *poly* to standard output. The coefficients are printed on separate lines. - void ca_poly_printn(const ca_poly_t poly, slong digits, ca_ctx_t ctx) + void ca_poly_printn(const ca_poly_t poly, slong digits, ca_ctx_t ctx) noexcept # Prints a decimal representation of *poly* with precision specified by *digits*. # The coefficients are comma-separated and the whole list is enclosed in square brackets. - bint ca_poly_is_proper(const ca_poly_t poly, ca_ctx_t ctx) + bint ca_poly_is_proper(const ca_poly_t poly, ca_ctx_t ctx) noexcept # Checks that *poly* represents an element of `\mathbb{C}[X]` with # well-defined degree. This returns 1 if the leading coefficient # of *poly* is nonzero and all coefficients of *poly* are @@ -80,132 +80,132 @@ cdef extern from "flint_wrap.h": # It returns 1 when *poly* is precisely the zero polynomial (which # does not have a leading coefficient). - int ca_poly_make_monic(ca_poly_t res, const ca_poly_t poly, ca_ctx_t ctx) + int ca_poly_make_monic(ca_poly_t res, const ca_poly_t poly, ca_ctx_t ctx) noexcept # Makes *poly* monic by dividing by the leading coefficient if possible # and returns 1. Returns 0 if the leading coefficient cannot be # certified to be nonzero, or if *poly* is the zero polynomial. - void _ca_poly_reverse(ca_ptr res, ca_srcptr poly, slong len, slong n, ca_ctx_t ctx) + void _ca_poly_reverse(ca_ptr res, ca_srcptr poly, slong len, slong n, ca_ctx_t ctx) noexcept - void ca_poly_reverse(ca_poly_t res, const ca_poly_t poly, slong n, ca_ctx_t ctx) + void ca_poly_reverse(ca_poly_t res, const ca_poly_t poly, slong n, ca_ctx_t ctx) noexcept # Sets *res* to the reversal of *poly* considered as a polynomial # of length *n*, zero-padding if needed. The underscore method # assumes that *len* is positive and less than or equal to *n*. - truth_t _ca_poly_check_equal(ca_srcptr poly1, slong len1, ca_srcptr poly2, slong len2, ca_ctx_t ctx) - truth_t ca_poly_check_equal(const ca_poly_t poly1, const ca_poly_t poly2, ca_ctx_t ctx) + truth_t _ca_poly_check_equal(ca_srcptr poly1, slong len1, ca_srcptr poly2, slong len2, ca_ctx_t ctx) noexcept + truth_t ca_poly_check_equal(const ca_poly_t poly1, const ca_poly_t poly2, ca_ctx_t ctx) noexcept # Checks if *poly1* and *poly2* represent the same polynomial. # The underscore method assumes that *len1* is at least as # large as *len2*. - truth_t ca_poly_check_is_zero(const ca_poly_t poly, ca_ctx_t ctx) + truth_t ca_poly_check_is_zero(const ca_poly_t poly, ca_ctx_t ctx) noexcept # Checks if *poly* is the zero polynomial. - truth_t ca_poly_check_is_one(const ca_poly_t poly, ca_ctx_t ctx) + truth_t ca_poly_check_is_one(const ca_poly_t poly, ca_ctx_t ctx) noexcept # Checks if *poly* is the constant polynomial 1. - void _ca_poly_shift_left(ca_ptr res, ca_srcptr poly, slong len, slong n, ca_ctx_t ctx) - void ca_poly_shift_left(ca_poly_t res, const ca_poly_t poly, slong n, ca_ctx_t ctx) + void _ca_poly_shift_left(ca_ptr res, ca_srcptr poly, slong len, slong n, ca_ctx_t ctx) noexcept + void ca_poly_shift_left(ca_poly_t res, const ca_poly_t poly, slong n, ca_ctx_t ctx) noexcept # Sets *res* to *poly* shifted *n* coefficients to the left; that is, # multiplied by `x^n`. - void _ca_poly_shift_right(ca_ptr res, ca_srcptr poly, slong len, slong n, ca_ctx_t ctx) - void ca_poly_shift_right(ca_poly_t res, const ca_poly_t poly, slong n, ca_ctx_t ctx) + void _ca_poly_shift_right(ca_ptr res, ca_srcptr poly, slong len, slong n, ca_ctx_t ctx) noexcept + void ca_poly_shift_right(ca_poly_t res, const ca_poly_t poly, slong n, ca_ctx_t ctx) noexcept # Sets *res* to *poly* shifted *n* coefficients to the right; that is, # divided by `x^n`. - void ca_poly_neg(ca_poly_t res, const ca_poly_t src, ca_ctx_t ctx) + void ca_poly_neg(ca_poly_t res, const ca_poly_t src, ca_ctx_t ctx) noexcept # Sets *res* to the negation of *src*. - void _ca_poly_add(ca_ptr res, ca_srcptr poly1, slong len1, ca_srcptr poly2, slong len2, ca_ctx_t ctx) - void ca_poly_add(ca_poly_t res, const ca_poly_t poly1, const ca_poly_t poly2, ca_ctx_t ctx) + void _ca_poly_add(ca_ptr res, ca_srcptr poly1, slong len1, ca_srcptr poly2, slong len2, ca_ctx_t ctx) noexcept + void ca_poly_add(ca_poly_t res, const ca_poly_t poly1, const ca_poly_t poly2, ca_ctx_t ctx) noexcept # Sets *res* to the sum of *poly1* and *poly2*. - void _ca_poly_sub(ca_ptr res, ca_srcptr poly1, slong len1, ca_srcptr poly2, slong len2, ca_ctx_t ctx) - void ca_poly_sub(ca_poly_t res, const ca_poly_t poly1, const ca_poly_t poly2, ca_ctx_t ctx) + void _ca_poly_sub(ca_ptr res, ca_srcptr poly1, slong len1, ca_srcptr poly2, slong len2, ca_ctx_t ctx) noexcept + void ca_poly_sub(ca_poly_t res, const ca_poly_t poly1, const ca_poly_t poly2, ca_ctx_t ctx) noexcept # Sets *res* to the difference of *poly1* and *poly2*. - void _ca_poly_mul(ca_ptr res, ca_srcptr poly1, slong len1, ca_srcptr poly2, slong len2, ca_ctx_t ctx) - void ca_poly_mul(ca_poly_t res, const ca_poly_t poly1, const ca_poly_t poly2, ca_ctx_t ctx) + void _ca_poly_mul(ca_ptr res, ca_srcptr poly1, slong len1, ca_srcptr poly2, slong len2, ca_ctx_t ctx) noexcept + void ca_poly_mul(ca_poly_t res, const ca_poly_t poly1, const ca_poly_t poly2, ca_ctx_t ctx) noexcept # Sets *res* to the product of *poly1* and *poly2*. - void _ca_poly_mullow(ca_ptr C, ca_srcptr poly1, slong len1, ca_srcptr poly2, slong len2, slong n, ca_ctx_t ctx) - void ca_poly_mullow(ca_poly_t res, const ca_poly_t poly1, const ca_poly_t poly2, slong n, ca_ctx_t ctx) + void _ca_poly_mullow(ca_ptr C, ca_srcptr poly1, slong len1, ca_srcptr poly2, slong len2, slong n, ca_ctx_t ctx) noexcept + void ca_poly_mullow(ca_poly_t res, const ca_poly_t poly1, const ca_poly_t poly2, slong n, ca_ctx_t ctx) noexcept # Sets *res* to the product of *poly1* and *poly2* truncated to length *n*. - void ca_poly_mul_ca(ca_poly_t res, const ca_poly_t poly, const ca_t c, ca_ctx_t ctx) + void ca_poly_mul_ca(ca_poly_t res, const ca_poly_t poly, const ca_t c, ca_ctx_t ctx) noexcept # Sets *res* to *poly* multiplied by the scalar *c*. - void ca_poly_div_ca(ca_poly_t res, const ca_poly_t poly, const ca_t c, ca_ctx_t ctx) + void ca_poly_div_ca(ca_poly_t res, const ca_poly_t poly, const ca_t c, ca_ctx_t ctx) noexcept # Sets *res* to *poly* divided by the scalar *c*. - void _ca_poly_divrem_basecase(ca_ptr Q, ca_ptr R, ca_srcptr A, slong lenA, ca_srcptr B, slong lenB, const ca_t invB, ca_ctx_t ctx) - int ca_poly_divrem_basecase(ca_poly_t Q, ca_poly_t R, const ca_poly_t A, const ca_poly_t B, ca_ctx_t ctx) - void _ca_poly_divrem(ca_ptr Q, ca_ptr R, ca_srcptr A, slong lenA, ca_srcptr B, slong lenB, const ca_t invB, ca_ctx_t ctx) - int ca_poly_divrem(ca_poly_t Q, ca_poly_t R, const ca_poly_t A, const ca_poly_t B, ca_ctx_t ctx) - int ca_poly_div(ca_poly_t Q, const ca_poly_t A, const ca_poly_t B, ca_ctx_t ctx) - int ca_poly_rem(ca_poly_t R, const ca_poly_t A, const ca_poly_t B, ca_ctx_t ctx) + void _ca_poly_divrem_basecase(ca_ptr Q, ca_ptr R, ca_srcptr A, slong lenA, ca_srcptr B, slong lenB, const ca_t invB, ca_ctx_t ctx) noexcept + int ca_poly_divrem_basecase(ca_poly_t Q, ca_poly_t R, const ca_poly_t A, const ca_poly_t B, ca_ctx_t ctx) noexcept + void _ca_poly_divrem(ca_ptr Q, ca_ptr R, ca_srcptr A, slong lenA, ca_srcptr B, slong lenB, const ca_t invB, ca_ctx_t ctx) noexcept + int ca_poly_divrem(ca_poly_t Q, ca_poly_t R, const ca_poly_t A, const ca_poly_t B, ca_ctx_t ctx) noexcept + int ca_poly_div(ca_poly_t Q, const ca_poly_t A, const ca_poly_t B, ca_ctx_t ctx) noexcept + int ca_poly_rem(ca_poly_t R, const ca_poly_t A, const ca_poly_t B, ca_ctx_t ctx) noexcept # If the leading coefficient of *B* can be proved invertible, sets *Q* and *R* # to the quotient and remainder of polynomial division of *A* by *B* # and returns 1. If the leading coefficient cannot be proved # invertible, returns 0. # The underscore method takes a precomputed inverse of the leading coefficient of *B*. - void _ca_poly_pow_ui_trunc(ca_ptr res, ca_srcptr f, slong flen, ulong exp, slong len, ca_ctx_t ctx) - void ca_poly_pow_ui_trunc(ca_poly_t res, const ca_poly_t poly, ulong exp, slong len, ca_ctx_t ctx) + void _ca_poly_pow_ui_trunc(ca_ptr res, ca_srcptr f, slong flen, ulong exp, slong len, ca_ctx_t ctx) noexcept + void ca_poly_pow_ui_trunc(ca_poly_t res, const ca_poly_t poly, ulong exp, slong len, ca_ctx_t ctx) noexcept # Sets *res* to *poly* raised to the power *exp*, truncated to length *len*. - void _ca_poly_pow_ui(ca_ptr res, ca_srcptr f, slong flen, ulong exp, ca_ctx_t ctx) - void ca_poly_pow_ui(ca_poly_t res, const ca_poly_t poly, ulong exp, ca_ctx_t ctx) + void _ca_poly_pow_ui(ca_ptr res, ca_srcptr f, slong flen, ulong exp, ca_ctx_t ctx) noexcept + void ca_poly_pow_ui(ca_poly_t res, const ca_poly_t poly, ulong exp, ca_ctx_t ctx) noexcept # Sets *res* to *poly* raised to the power *exp*. - void _ca_poly_evaluate_horner(ca_t res, ca_srcptr f, slong len, const ca_t x, ca_ctx_t ctx) - void ca_poly_evaluate_horner(ca_t res, const ca_poly_t f, const ca_t a, ca_ctx_t ctx) - void _ca_poly_evaluate(ca_t res, ca_srcptr f, slong len, const ca_t x, ca_ctx_t ctx) - void ca_poly_evaluate(ca_t res, const ca_poly_t f, const ca_t a, ca_ctx_t ctx) + void _ca_poly_evaluate_horner(ca_t res, ca_srcptr f, slong len, const ca_t x, ca_ctx_t ctx) noexcept + void ca_poly_evaluate_horner(ca_t res, const ca_poly_t f, const ca_t a, ca_ctx_t ctx) noexcept + void _ca_poly_evaluate(ca_t res, ca_srcptr f, slong len, const ca_t x, ca_ctx_t ctx) noexcept + void ca_poly_evaluate(ca_t res, const ca_poly_t f, const ca_t a, ca_ctx_t ctx) noexcept # Sets *res* to *f* evaluated at the point *a*. - void _ca_poly_compose(ca_ptr res, ca_srcptr poly1, slong len1, ca_srcptr poly2, slong len2, ca_ctx_t ctx) - void ca_poly_compose(ca_poly_t res, const ca_poly_t poly1, const ca_poly_t poly2, ca_ctx_t ctx) + void _ca_poly_compose(ca_ptr res, ca_srcptr poly1, slong len1, ca_srcptr poly2, slong len2, ca_ctx_t ctx) noexcept + void ca_poly_compose(ca_poly_t res, const ca_poly_t poly1, const ca_poly_t poly2, ca_ctx_t ctx) noexcept # Sets *res* to the composition of *poly1* with *poly2*. - void _ca_poly_derivative(ca_ptr res, ca_srcptr poly, slong len, ca_ctx_t ctx) - void ca_poly_derivative(ca_poly_t res, const ca_poly_t poly, ca_ctx_t ctx) + void _ca_poly_derivative(ca_ptr res, ca_srcptr poly, slong len, ca_ctx_t ctx) noexcept + void ca_poly_derivative(ca_poly_t res, const ca_poly_t poly, ca_ctx_t ctx) noexcept # Sets *res* to the derivative of *poly*. The underscore method needs one less # coefficient than *len* for the output array. - void _ca_poly_integral(ca_ptr res, ca_srcptr poly, slong len, ca_ctx_t ctx) - void ca_poly_integral(ca_poly_t res, const ca_poly_t poly, ca_ctx_t ctx) + void _ca_poly_integral(ca_ptr res, ca_srcptr poly, slong len, ca_ctx_t ctx) noexcept + void ca_poly_integral(ca_poly_t res, const ca_poly_t poly, ca_ctx_t ctx) noexcept # Sets *res* to the integral of *poly*. The underscore method needs one more # coefficient than *len* for the output array. - void _ca_poly_inv_series(ca_ptr res, ca_srcptr f, slong flen, slong len, ca_ctx_t ctx) - void ca_poly_inv_series(ca_poly_t res, const ca_poly_t f, slong len, ca_ctx_t ctx) + void _ca_poly_inv_series(ca_ptr res, ca_srcptr f, slong flen, slong len, ca_ctx_t ctx) noexcept + void ca_poly_inv_series(ca_poly_t res, const ca_poly_t f, slong len, ca_ctx_t ctx) noexcept # Sets *res* to the power series inverse of *f* truncated # to length *len*. - void _ca_poly_div_series(ca_ptr res, ca_srcptr f, slong flen, ca_srcptr g, slong glen, slong len, ca_ctx_t ctx) - void ca_poly_div_series(ca_poly_t res, const ca_poly_t f, const ca_poly_t g, slong len, ca_ctx_t ctx) + void _ca_poly_div_series(ca_ptr res, ca_srcptr f, slong flen, ca_srcptr g, slong glen, slong len, ca_ctx_t ctx) noexcept + void ca_poly_div_series(ca_poly_t res, const ca_poly_t f, const ca_poly_t g, slong len, ca_ctx_t ctx) noexcept # Sets *res* to the power series quotient of *f* and *g* truncated # to length *len*. # This function divides by zero if *g* has constant term zero; # the user should manually remove initial zeros when an # exact cancellation is required. - void _ca_poly_exp_series(ca_ptr res, ca_srcptr f, slong flen, slong len, ca_ctx_t ctx) - void ca_poly_exp_series(ca_poly_t res, const ca_poly_t f, slong len, ca_ctx_t ctx) + void _ca_poly_exp_series(ca_ptr res, ca_srcptr f, slong flen, slong len, ca_ctx_t ctx) noexcept + void ca_poly_exp_series(ca_poly_t res, const ca_poly_t f, slong len, ca_ctx_t ctx) noexcept # Sets *res* to the power series exponential of *f* truncated # to length *len*. - void _ca_poly_log_series(ca_ptr res, ca_srcptr f, slong flen, slong len, ca_ctx_t ctx) - void ca_poly_log_series(ca_poly_t res, const ca_poly_t f, slong len, ca_ctx_t ctx) + void _ca_poly_log_series(ca_ptr res, ca_srcptr f, slong flen, slong len, ca_ctx_t ctx) noexcept + void ca_poly_log_series(ca_poly_t res, const ca_poly_t f, slong len, ca_ctx_t ctx) noexcept # Sets *res* to the power series logarithm of *f* truncated # to length *len*. - slong _ca_poly_gcd_euclidean(ca_ptr res, ca_srcptr A, slong lenA, ca_srcptr B, slong lenB, ca_ctx_t ctx) - int ca_poly_gcd_euclidean(ca_poly_t res, const ca_poly_t A, const ca_poly_t B, ca_ctx_t ctx) - slong _ca_poly_gcd(ca_ptr res, ca_srcptr A, slong lenA, ca_srcptr B, slong lenB, ca_ctx_t ctx) - int ca_poly_gcd(ca_poly_t res, const ca_poly_t A, const ca_poly_t g, ca_ctx_t ctx) + slong _ca_poly_gcd_euclidean(ca_ptr res, ca_srcptr A, slong lenA, ca_srcptr B, slong lenB, ca_ctx_t ctx) noexcept + int ca_poly_gcd_euclidean(ca_poly_t res, const ca_poly_t A, const ca_poly_t B, ca_ctx_t ctx) noexcept + slong _ca_poly_gcd(ca_ptr res, ca_srcptr A, slong lenA, ca_srcptr B, slong lenB, ca_ctx_t ctx) noexcept + int ca_poly_gcd(ca_poly_t res, const ca_poly_t A, const ca_poly_t g, ca_ctx_t ctx) noexcept # Sets *res* to the GCD of *A* and *B* and returns 1 on success. # On failure, returns 0 leaving the value of *res* arbitrary. # The computation can fail if testing a leading coefficient @@ -220,7 +220,7 @@ cdef extern from "flint_wrap.h": # and otherwise falls back to an automatic choice # of algorithm (currently only the Euclidean algorithm). - int ca_poly_factor_squarefree(ca_t c, ca_poly_vec_t fac, ulong * exp, const ca_poly_t F, ca_ctx_t ctx) + int ca_poly_factor_squarefree(ca_t c, ca_poly_vec_t fac, ulong * exp, const ca_poly_t F, ca_ctx_t ctx) noexcept # Computes the squarefree factorization of *F*, giving a product # `F = c f_1 f_2^2 \ldots f_n^n` where all `f_i` with `f_i \ne 1` # are squarefree and pairwise coprime. The nontrivial factors @@ -228,13 +228,13 @@ cdef extern from "flint_wrap.h": # are written to *exp*. This algorithm can fail if GCD computation # fails internally. Returns 1 on success and 0 on failure. - int ca_poly_squarefree_part(ca_poly_t res, const ca_poly_t poly, ca_ctx_t ctx) + int ca_poly_squarefree_part(ca_poly_t res, const ca_poly_t poly, ca_ctx_t ctx) noexcept # Sets *res* to the squarefree part of *poly*, normalized to be monic. # This algorithm can fail if GCD computation fails internally. # Returns 1 on success and 0 on failure. - void _ca_poly_set_roots(ca_ptr poly, ca_srcptr roots, const ulong * exp, slong n, ca_ctx_t ctx) - void ca_poly_set_roots(ca_poly_t poly, ca_vec_t roots, const ulong * exp, ca_ctx_t ctx) + void _ca_poly_set_roots(ca_ptr poly, ca_srcptr roots, const ulong * exp, slong n, ca_ctx_t ctx) noexcept + void ca_poly_set_roots(ca_poly_t poly, ca_vec_t roots, const ulong * exp, ca_ctx_t ctx) noexcept # Sets *poly* to the monic polynomial with the *n* roots # given in the vector *roots*, with multiplicities given # in the vector *exp*. In other words, this constructs @@ -242,8 +242,8 @@ cdef extern from "flint_wrap.h": # `(x-r_0)^{e_0} (x-r_1)^{e_1} \cdots (x-r_{n-1})^{e_{n-1}}`. # Uses binary splitting. - int _ca_poly_roots(ca_ptr roots, ca_srcptr poly, slong len, ca_ctx_t ctx) - int ca_poly_roots(ca_vec_t roots, ulong * exp, const ca_poly_t poly, ca_ctx_t ctx) + int _ca_poly_roots(ca_ptr roots, ca_srcptr poly, slong len, ca_ctx_t ctx) noexcept + int ca_poly_roots(ca_vec_t roots, ulong * exp, const ca_poly_t poly, ca_ctx_t ctx) noexcept # Attempts to compute all complex roots of the given polynomial *poly*. # On success, returns 1 and sets *roots* to a vector containing all # the distinct roots with corresponding multiplicities in *exp*. @@ -256,19 +256,19 @@ cdef extern from "flint_wrap.h": # The underscore method assumes that the polynomial is squarefree. # The non-underscore method performs a squarefree factorization. - ca_poly_struct * _ca_poly_vec_init(slong len, ca_ctx_t ctx) - void ca_poly_vec_init(ca_poly_vec_t res, slong len, ca_ctx_t ctx) + ca_poly_struct * _ca_poly_vec_init(slong len, ca_ctx_t ctx) noexcept + void ca_poly_vec_init(ca_poly_vec_t res, slong len, ca_ctx_t ctx) noexcept # Initializes a vector with *len* polynomials. - void _ca_poly_vec_fit_length(ca_poly_vec_t vec, slong len, ca_ctx_t ctx) + void _ca_poly_vec_fit_length(ca_poly_vec_t vec, slong len, ca_ctx_t ctx) noexcept # Allocates space for *len* polynomials in *vec*. - void ca_poly_vec_set_length(ca_poly_vec_t vec, slong len, ca_ctx_t ctx) + void ca_poly_vec_set_length(ca_poly_vec_t vec, slong len, ca_ctx_t ctx) noexcept # Resizes *vec* to length *len*, zero-extending if needed. - void _ca_poly_vec_clear(ca_poly_struct * vec, slong len, ca_ctx_t ctx) - void ca_poly_vec_clear(ca_poly_vec_t vec, ca_ctx_t ctx) + void _ca_poly_vec_clear(ca_poly_struct * vec, slong len, ca_ctx_t ctx) noexcept + void ca_poly_vec_clear(ca_poly_vec_t vec, ca_ctx_t ctx) noexcept # Clears the vector *vec*. - void ca_poly_vec_append(ca_poly_vec_t vec, const ca_poly_t poly, ca_ctx_t ctx) + void ca_poly_vec_append(ca_poly_vec_t vec, const ca_poly_t poly, ca_ctx_t ctx) noexcept # Appends *poly* to the end of the vector *vec*. diff --git a/src/sage/libs/flint/ca_vec.pxd b/src/sage/libs/flint/ca_vec.pxd index f392b36a8f6..76c993b3365 100644 --- a/src/sage/libs/flint/ca_vec.pxd +++ b/src/sage/libs/flint/ca_vec.pxd @@ -12,102 +12,102 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - ca_ptr _ca_vec_init(slong len, ca_ctx_t ctx) + ca_ptr _ca_vec_init(slong len, ca_ctx_t ctx) noexcept # Returns a pointer to an array of *len* coefficients # initialized to zero. - void ca_vec_init(ca_vec_t vec, slong len, ca_ctx_t ctx) + void ca_vec_init(ca_vec_t vec, slong len, ca_ctx_t ctx) noexcept # Initializes *vec* to a length *len* vector. All entries # are set to zero. - void _ca_vec_clear(ca_ptr vec, slong len, ca_ctx_t ctx) + void _ca_vec_clear(ca_ptr vec, slong len, ca_ctx_t ctx) noexcept # Clears all *len* entries in *vec* and frees the pointer # *vec* itself. - void ca_vec_clear(ca_vec_t vec, ca_ctx_t ctx) + void ca_vec_clear(ca_vec_t vec, ca_ctx_t ctx) noexcept # Clears the vector *vec*. - void _ca_vec_swap(ca_ptr vec1, ca_ptr vec2, slong len, ca_ctx_t ctx) + void _ca_vec_swap(ca_ptr vec1, ca_ptr vec2, slong len, ca_ctx_t ctx) noexcept # Swaps the entries in *vec1* and *vec2* efficiently. - void ca_vec_swap(ca_vec_t vec1, ca_vec_t vec2, ca_ctx_t ctx) + void ca_vec_swap(ca_vec_t vec1, ca_vec_t vec2, ca_ctx_t ctx) noexcept # Swaps the vectors *vec1* and *vec2* efficiently. - slong ca_vec_length(const ca_vec_t vec, ca_ctx_t ctx) + slong ca_vec_length(const ca_vec_t vec, ca_ctx_t ctx) noexcept # Returns the length of *vec*. - void _ca_vec_fit_length(ca_vec_t vec, slong len, ca_ctx_t ctx) + void _ca_vec_fit_length(ca_vec_t vec, slong len, ca_ctx_t ctx) noexcept # Allocates space in *vec* for *len* elements. - void ca_vec_set_length(ca_vec_t vec, slong len, ca_ctx_t ctx) + void ca_vec_set_length(ca_vec_t vec, slong len, ca_ctx_t ctx) noexcept # Sets the length of *vec* to *len*. # If *vec* is shorter on input, it will be zero-extended. # If *vec* is longer on input, it will be truncated. - void _ca_vec_set(ca_ptr res, ca_srcptr src, slong len, ca_ctx_t ctx) + void _ca_vec_set(ca_ptr res, ca_srcptr src, slong len, ca_ctx_t ctx) noexcept # Sets *res* to a copy of *src* of length *len*. - void ca_vec_set(ca_vec_t res, const ca_vec_t src, ca_ctx_t ctx) + void ca_vec_set(ca_vec_t res, const ca_vec_t src, ca_ctx_t ctx) noexcept # Sets *res* to a copy of *src*. - void _ca_vec_zero(ca_ptr res, slong len, ca_ctx_t ctx) + void _ca_vec_zero(ca_ptr res, slong len, ca_ctx_t ctx) noexcept # Sets the *len* entries in *res* to zeros. - void ca_vec_zero(ca_vec_t res, slong len, ca_ctx_t ctx) + void ca_vec_zero(ca_vec_t res, slong len, ca_ctx_t ctx) noexcept # Sets *res* to the length *len* zero vector. - void ca_vec_print(const ca_vec_t vec, ca_ctx_t ctx) + void ca_vec_print(const ca_vec_t vec, ca_ctx_t ctx) noexcept # Prints *vec* to standard output. The coefficients are printed on separate lines. - void ca_vec_printn(const ca_vec_t poly, slong digits, ca_ctx_t ctx) + void ca_vec_printn(const ca_vec_t poly, slong digits, ca_ctx_t ctx) noexcept # Prints a decimal representation of *vec* with precision specified by *digits*. # The coefficients are comma-separated and the whole list is enclosed in square brackets. - void ca_vec_append(ca_vec_t vec, const ca_t f, ca_ctx_t ctx) + void ca_vec_append(ca_vec_t vec, const ca_t f, ca_ctx_t ctx) noexcept # Appends *f* to the end of *vec*. - void _ca_vec_neg(ca_ptr res, ca_srcptr src, slong len, ca_ctx_t ctx) + void _ca_vec_neg(ca_ptr res, ca_srcptr src, slong len, ca_ctx_t ctx) noexcept - void ca_vec_neg(ca_vec_t res, const ca_vec_t src, ca_ctx_t ctx) + void ca_vec_neg(ca_vec_t res, const ca_vec_t src, ca_ctx_t ctx) noexcept # Sets *res* to the negation of *src*. - void _ca_vec_add(ca_ptr res, ca_srcptr vec1, ca_srcptr vec2, slong len, ca_ctx_t ctx) + void _ca_vec_add(ca_ptr res, ca_srcptr vec1, ca_srcptr vec2, slong len, ca_ctx_t ctx) noexcept - void _ca_vec_sub(ca_ptr res, ca_srcptr vec1, ca_srcptr vec2, slong len, ca_ctx_t ctx) + void _ca_vec_sub(ca_ptr res, ca_srcptr vec1, ca_srcptr vec2, slong len, ca_ctx_t ctx) noexcept # Sets *res* to the sum or difference of *vec1* and *vec2*, # all vectors having length *len*. - void _ca_vec_scalar_mul_ca(ca_ptr res, ca_srcptr src, slong len, const ca_t c, ca_ctx_t ctx) + void _ca_vec_scalar_mul_ca(ca_ptr res, ca_srcptr src, slong len, const ca_t c, ca_ctx_t ctx) noexcept # Sets *res* to *src* multiplied by *c*, all vectors having # length *len*. - void _ca_vec_scalar_div_ca(ca_ptr res, ca_srcptr src, slong len, const ca_t c, ca_ctx_t ctx) + void _ca_vec_scalar_div_ca(ca_ptr res, ca_srcptr src, slong len, const ca_t c, ca_ctx_t ctx) noexcept # Sets *res* to *src* divided by *c*, all vectors having # length *len*. - void _ca_vec_scalar_addmul_ca(ca_ptr res, ca_srcptr src, slong len, const ca_t c, ca_ctx_t ctx) + void _ca_vec_scalar_addmul_ca(ca_ptr res, ca_srcptr src, slong len, const ca_t c, ca_ctx_t ctx) noexcept # Adds *src* multiplied by *c* to the vector *res*, all vectors having # length *len*. - void _ca_vec_scalar_submul_ca(ca_ptr res, ca_srcptr src, slong len, const ca_t c, ca_ctx_t ctx) + void _ca_vec_scalar_submul_ca(ca_ptr res, ca_srcptr src, slong len, const ca_t c, ca_ctx_t ctx) noexcept # Subtracts *src* multiplied by *c* from the vector *res*, all vectors having # length *len*. - truth_t _ca_vec_check_is_zero(ca_srcptr vec, slong len, ca_ctx_t ctx) + truth_t _ca_vec_check_is_zero(ca_srcptr vec, slong len, ca_ctx_t ctx) noexcept # Returns whether *vec* is the zero vector. - bint _ca_vec_is_fmpq_vec(ca_srcptr vec, slong len, ca_ctx_t ctx) + bint _ca_vec_is_fmpq_vec(ca_srcptr vec, slong len, ca_ctx_t ctx) noexcept # Checks if all elements of *vec* are structurally rational numbers. - bint _ca_vec_fmpq_vec_is_fmpz_vec(ca_srcptr vec, slong len, ca_ctx_t ctx) + bint _ca_vec_fmpq_vec_is_fmpz_vec(ca_srcptr vec, slong len, ca_ctx_t ctx) noexcept # Assuming that all elements of *vec* are structurally rational numbers, # checks if all elements are integers. - void _ca_vec_fmpq_vec_get_fmpz_vec_den(fmpz * c, fmpz_t den, ca_srcptr vec, slong len, ca_ctx_t ctx) + void _ca_vec_fmpq_vec_get_fmpz_vec_den(fmpz * c, fmpz_t den, ca_srcptr vec, slong len, ca_ctx_t ctx) noexcept # Assuming that all elements of *vec* are structurally rational numbers, # converts them to a vector of integers *c* on a common denominator # *den*. - void _ca_vec_set_fmpz_vec_div_fmpz(ca_ptr res, const fmpz * v, const fmpz_t den, slong len, ca_ctx_t ctx) + void _ca_vec_set_fmpz_vec_div_fmpz(ca_ptr res, const fmpz * v, const fmpz_t den, slong len, ca_ctx_t ctx) noexcept # Sets *res* to the rational vector given by numerators *v* # and the common denominator *den*. diff --git a/src/sage/libs/flint/calcium.pxd b/src/sage/libs/flint/calcium.pxd index c5fd495c28b..18278abc5c5 100644 --- a/src/sage/libs/flint/calcium.pxd +++ b/src/sage/libs/flint/calcium.pxd @@ -12,35 +12,35 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - const char * calcium_version() + const char * calcium_version() noexcept # Returns a pointer to the version of the library as a string ``X.Y.Z``. - ulong calcium_fmpz_hash(const fmpz_t x) + ulong calcium_fmpz_hash(const fmpz_t x) noexcept # Hash function for integers. The algorithm may change; # presently, this simply extracts the low word (with sign). - void calcium_stream_init_file(calcium_stream_t out, FILE * fp) + void calcium_stream_init_file(calcium_stream_t out, FILE * fp) noexcept # Initializes the stream *out* for writing to the file *fp*. # The file can be *stdout*, *stderr*, or any file opened for writing # by the user. - void calcium_stream_init_str(calcium_stream_t out) + void calcium_stream_init_str(calcium_stream_t out) noexcept # Initializes the stream *out* for writing to a string in memory. # When finished, the user should free the string (the *s* member # of *out* with ``flint_free()``). - void calcium_write(calcium_stream_t out, const char * s) + void calcium_write(calcium_stream_t out, const char * s) noexcept # Writes the string *s* to *out*. - void calcium_write_free(calcium_stream_t out, char * s) + void calcium_write_free(calcium_stream_t out, char * s) noexcept # Writes *s* to *out* and then frees *s* by calling ``flint_free()``. - void calcium_write_si(calcium_stream_t out, slong x) - void calcium_write_fmpz(calcium_stream_t out, const fmpz_t x) + void calcium_write_si(calcium_stream_t out, slong x) noexcept + void calcium_write_fmpz(calcium_stream_t out, const fmpz_t x) noexcept # Writes the integer *x* to *out*. - void calcium_write_arb(calcium_stream_t out, const arb_t z, slong digits, ulong flags) - void calcium_write_acb(calcium_stream_t out, const acb_t z, slong digits, ulong flags) + void calcium_write_arb(calcium_stream_t out, const arb_t z, slong digits, ulong flags) noexcept + void calcium_write_acb(calcium_stream_t out, const acb_t z, slong digits, ulong flags) noexcept # Writes the Arb number *z* to *out*, showing *digits* # digits and with the display style specified by *flags* # (``ARB_STR_NO_RADIUS``, etc.). diff --git a/src/sage/libs/flint/d_mat.pxd b/src/sage/libs/flint/d_mat.pxd index dd735aa99f0..b9d9a2911ee 100644 --- a/src/sage/libs/flint/d_mat.pxd +++ b/src/sage/libs/flint/d_mat.pxd @@ -12,88 +12,88 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void d_mat_init(d_mat_t mat, slong rows, slong cols) + void d_mat_init(d_mat_t mat, slong rows, slong cols) noexcept # Initialises a matrix with the given number of rows and columns for use. - void d_mat_clear(d_mat_t mat) + void d_mat_clear(d_mat_t mat) noexcept # Clears the given matrix. - void d_mat_set(d_mat_t mat1, const d_mat_t mat2) + void d_mat_set(d_mat_t mat1, const d_mat_t mat2) noexcept # Sets ``mat1`` to a copy of ``mat2``. The dimensions of # ``mat1`` and ``mat2`` must be the same. - void d_mat_swap(d_mat_t mat1, d_mat_t mat2) + void d_mat_swap(d_mat_t mat1, d_mat_t mat2) noexcept # Swaps two matrices. The dimensions of ``mat1`` and ``mat2`` # are allowed to be different. - void d_mat_swap_entrywise(d_mat_t mat1, d_mat_t mat2) + void d_mat_swap_entrywise(d_mat_t mat1, d_mat_t mat2) noexcept # Swaps two matrices by swapping the individual entries rather than swapping # the contents of the structs. - double d_mat_entry(d_mat_t mat, slong i, slong j) + double d_mat_entry(d_mat_t mat, slong i, slong j) noexcept # Returns the entry of ``mat`` at row `i` and column `j`. # Both `i` and `j` must not exceed the dimensions of the matrix. # This function is implemented as a macro. - double d_mat_get_entry(const d_mat_t mat, slong i, slong j) + double d_mat_get_entry(const d_mat_t mat, slong i, slong j) noexcept # Returns the entry of ``mat`` at row `i` and column `j`. # Both `i` and `j` must not exceed the dimensions of the matrix. - double * d_mat_entry_ptr(const d_mat_t mat, slong i, slong j) + double * d_mat_entry_ptr(const d_mat_t mat, slong i, slong j) noexcept # Returns a pointer to the entry of ``mat`` at row `i` and column # `j`. Both `i` and `j` must not exceed the dimensions of the matrix. - void d_mat_zero(d_mat_t mat) + void d_mat_zero(d_mat_t mat) noexcept # Sets all entries of ``mat`` to 0. - void d_mat_one(d_mat_t mat) + void d_mat_one(d_mat_t mat) noexcept # Sets ``mat`` to the unit matrix, having ones on the main diagonal # and zeroes elsewhere. If ``mat`` is nonsquare, it is set to the # truncation of a unit matrix. - void d_mat_randtest(d_mat_t mat, flint_rand_t state, slong minexp, slong maxexp) + void d_mat_randtest(d_mat_t mat, flint_rand_t state, slong minexp, slong maxexp) noexcept # Sets the entries of ``mat`` to random signed numbers with exponents # between ``minexp`` and ``maxexp`` or zero. - void d_mat_print(const d_mat_t mat) + void d_mat_print(const d_mat_t mat) noexcept # Prints the given matrix to the stream ``stdout``. - bint d_mat_equal(const d_mat_t mat1, const d_mat_t mat2) + bint d_mat_equal(const d_mat_t mat1, const d_mat_t mat2) noexcept # Returns a non-zero value if ``mat1`` and ``mat2`` have # the same dimensions and entries, and zero otherwise. - bint d_mat_approx_equal(const d_mat_t mat1, const d_mat_t mat2, double eps) + bint d_mat_approx_equal(const d_mat_t mat1, const d_mat_t mat2, double eps) noexcept # Returns a non-zero value if ``mat1`` and ``mat2`` have # the same dimensions and entries within ``eps`` of each other, # and zero otherwise. - bint d_mat_is_zero(const d_mat_t mat) + bint d_mat_is_zero(const d_mat_t mat) noexcept # Returns a non-zero value if all entries ``mat`` are zero, and # otherwise returns zero. - bint d_mat_is_approx_zero(const d_mat_t mat, double eps) + bint d_mat_is_approx_zero(const d_mat_t mat, double eps) noexcept # Returns a non-zero value if all entries ``mat`` are zero to within # ``eps`` and otherwise returns zero. - bint d_mat_is_empty(const d_mat_t mat) + bint d_mat_is_empty(const d_mat_t mat) noexcept # Returns a non-zero value if the number of rows or the number of # columns in ``mat`` is zero, and otherwise returns # zero. - bint d_mat_is_square(const d_mat_t mat) + bint d_mat_is_square(const d_mat_t mat) noexcept # Returns a non-zero value if the number of rows is equal to the # number of columns in ``mat``, and otherwise returns zero. - void d_mat_transpose(d_mat_t B, const d_mat_t A) + void d_mat_transpose(d_mat_t B, const d_mat_t A) noexcept # Sets `B` to `A^T`, the transpose of `A`. Dimensions must be compatible. # `A` and `B` are allowed to be the same object if `A` is a square matrix. - void d_mat_mul_classical(d_mat_t C, const d_mat_t A, const d_mat_t B) + void d_mat_mul_classical(d_mat_t C, const d_mat_t A, const d_mat_t B) noexcept # Sets ``C`` to the matrix product `C = A B`. The matrices must have # compatible dimensions for matrix multiplication (an exception is raised # otherwise). Aliasing is allowed. - void d_mat_gso(d_mat_t B, const d_mat_t A) + void d_mat_gso(d_mat_t B, const d_mat_t A) noexcept # Takes a subset of `R^m` `S = {a_1, a_2, \ldots, a_n}` (as the columns of # a `m \times n` matrix ``A``) and generates an orthonormal set # `S' = {b_1, b_2, \ldots, b_n}` (as the columns of the `m \times n` matrix @@ -101,7 +101,7 @@ cdef extern from "flint_wrap.h": # This uses an algorithm of Schwarz-Rutishauser. See pp. 9 of # https://people.inf.ethz.ch/gander/papers/qrneu.pdf - void d_mat_qr(d_mat_t Q, d_mat_t R, const d_mat_t A) + void d_mat_qr(d_mat_t Q, d_mat_t R, const d_mat_t A) noexcept # Computes the `QR` decomposition of a matrix ``A`` using the Gram-Schmidt # process. (Sets ``Q`` and ``R`` such that `A = QR` where ``R`` is # an upper triangular matrix and ``Q`` is an orthogonal matrix.) diff --git a/src/sage/libs/flint/d_vec.pxd b/src/sage/libs/flint/d_vec.pxd index 0da40b9ceb2..c546e782abd 100644 --- a/src/sage/libs/flint/d_vec.pxd +++ b/src/sage/libs/flint/d_vec.pxd @@ -12,60 +12,60 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - double * _d_vec_init(slong len) + double * _d_vec_init(slong len) noexcept # Returns an initialised vector of ``double``\s of given length. The # entries are not zeroed. - void _d_vec_clear(double * vec) + void _d_vec_clear(double * vec) noexcept # Frees the space allocated for ``vec``. - void _d_vec_randtest(double * f, flint_rand_t state, slong len, slong minexp, slong maxexp) + void _d_vec_randtest(double * f, flint_rand_t state, slong len, slong minexp, slong maxexp) noexcept # Sets the entries of a vector of the given length to random signed numbers # with exponents between ``minexp`` and ``maxexp`` or zero. - void _d_vec_set(double * vec1, const double * vec2, slong len2) + void _d_vec_set(double * vec1, const double * vec2, slong len2) noexcept # Makes a copy of ``(vec2, len2)`` into ``vec1``. - void _d_vec_zero(double * vec, slong len) + void _d_vec_zero(double * vec, slong len) noexcept # Zeros the entries of ``(vec, len)``. - bint _d_vec_equal(const double * vec1, const double * vec2, slong len) + bint _d_vec_equal(const double * vec1, const double * vec2, slong len) noexcept # Compares two vectors of the given length and returns `1` if they are # equal, otherwise returns `0`. - bint _d_vec_is_zero(const double * vec, slong len) + bint _d_vec_is_zero(const double * vec, slong len) noexcept # Returns `1` if ``(vec, len)`` is zero, and `0` otherwise. - bint _d_vec_is_approx_zero(const double * vec, slong len, double eps) + bint _d_vec_is_approx_zero(const double * vec, slong len, double eps) noexcept # Returns `1` if the entries of ``(vec, len)`` are zero to within # ``eps``, and `0` otherwise. - bint _d_vec_approx_equal(const double * vec1, const double * vec2, slong len, double eps) + bint _d_vec_approx_equal(const double * vec1, const double * vec2, slong len, double eps) noexcept # Compares two vectors of the given length and returns `1` if their entries # are within ``eps`` of each other, otherwise returns `0`. - void _d_vec_add(double * res, const double * vec1, const double * vec2, slong len2) + void _d_vec_add(double * res, const double * vec1, const double * vec2, slong len2) noexcept # Sets ``(res, len2)`` to the sum of ``(vec1, len2)`` # and ``(vec2, len2)``. - void _d_vec_sub(double * res, const double * vec1, const double * vec2, slong len2) + void _d_vec_sub(double * res, const double * vec1, const double * vec2, slong len2) noexcept # Sets ``(res, len2)`` to ``(vec1, len2)`` minus ``(vec2, len2)``. - double _d_vec_dot(const double * vec1, const double * vec2, slong len2) + double _d_vec_dot(const double * vec1, const double * vec2, slong len2) noexcept # Returns the dot product of ``(vec1, len2)`` # and ``(vec2, len2)``. - double _d_vec_norm(const double * vec, slong len) + double _d_vec_norm(const double * vec, slong len) noexcept # Returns the square of the Euclidean norm of ``(vec, len)``. - double _d_vec_dot_heuristic(const double * vec1, const double * vec2, slong len2, double * err) + double _d_vec_dot_heuristic(const double * vec1, const double * vec2, slong len2, double * err) noexcept # Returns the dot product of ``(vec1, len2)`` # and ``(vec2, len2)`` by adding up the positive and negative products, # and doing a single subtraction of the two sums at the end. ``err`` is a # pointer to a double in which an error bound for the operation will be # stored. - double _d_vec_dot_thrice(const double * vec1, const double * vec2, slong len2, double * err) + double _d_vec_dot_thrice(const double * vec1, const double * vec2, slong len2, double * err) noexcept # Returns the dot product of ``(vec1, len2)`` # and ``(vec2, len2)`` using error-free floating point sums and products # to compute the dot product with three times (thrice) the working precision. diff --git a/src/sage/libs/flint/dirichlet.pxd b/src/sage/libs/flint/dirichlet.pxd index b96b2fefc0b..11249bbcca0 100644 --- a/src/sage/libs/flint/dirichlet.pxd +++ b/src/sage/libs/flint/dirichlet.pxd @@ -12,7 +12,7 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - int dirichlet_group_init(dirichlet_group_t G, ulong q) + int dirichlet_group_init(dirichlet_group_t G, ulong q) noexcept # Initializes *G* to the group of Dirichlet characters mod *q*. # This method computes a canonical decomposition of *G* in terms of cyclic # groups, which are the mod `p^e` subgroups for `p^e\|q`, plus @@ -29,55 +29,55 @@ cdef extern from "flint_wrap.h": # be removed in the future. The function returns 1 on success and 0 # if a factor is too large. - void dirichlet_subgroup_init(dirichlet_group_t H, const dirichlet_group_t G, ulong h) + void dirichlet_subgroup_init(dirichlet_group_t H, const dirichlet_group_t G, ulong h) noexcept - void dirichlet_group_clear(dirichlet_group_t G) + void dirichlet_group_clear(dirichlet_group_t G) noexcept # Clears *G*. Remark this function does *not* clear the discrete logarithm # tables stored in *G* (which may be shared with another group). - ulong dirichlet_group_size(const dirichlet_group_t G) + ulong dirichlet_group_size(const dirichlet_group_t G) noexcept - ulong dirichlet_group_num_primitive(const dirichlet_group_t G) + ulong dirichlet_group_num_primitive(const dirichlet_group_t G) noexcept - void dirichlet_group_dlog_precompute(dirichlet_group_t G, ulong num) + void dirichlet_group_dlog_precompute(dirichlet_group_t G, ulong num) noexcept # Precompute decomposition and tables for discrete log computations in *G*, # so as to minimize the complexity of *num* calls to discrete logarithms. # If *num* gets very large, the entire group may be indexed. - void dirichlet_group_dlog_clear(dirichlet_group_t G) + void dirichlet_group_dlog_clear(dirichlet_group_t G) noexcept - void dirichlet_char_init(dirichlet_char_t chi, const dirichlet_group_t G) + void dirichlet_char_init(dirichlet_char_t chi, const dirichlet_group_t G) noexcept # Initializes *chi* to an element of the group *G* and sets its value # to the principal character. - void dirichlet_char_clear(dirichlet_char_t chi) + void dirichlet_char_clear(dirichlet_char_t chi) noexcept # Clears *chi*. - void dirichlet_char_print(const dirichlet_group_t G, const dirichlet_char_t chi) + void dirichlet_char_print(const dirichlet_group_t G, const dirichlet_char_t chi) noexcept # Prints the array of exponents representing this character. - void dirichlet_char_log(dirichlet_char_t x, const dirichlet_group_t G, ulong m) + void dirichlet_char_log(dirichlet_char_t x, const dirichlet_group_t G, ulong m) noexcept # Sets *x* to the character of number *m*, computing its log using discrete # logarithm in *G*. - ulong dirichlet_char_exp(const dirichlet_group_t G, const dirichlet_char_t x) + ulong dirichlet_char_exp(const dirichlet_group_t G, const dirichlet_char_t x) noexcept # Returns the number *m* corresponding to exponents in *x*. - ulong _dirichlet_char_exp(dirichlet_char_t x, const dirichlet_group_t G) + ulong _dirichlet_char_exp(dirichlet_char_t x, const dirichlet_group_t G) noexcept # Computes and returns the number *m* corresponding to exponents in *x*. # This function is for internal use. - void dirichlet_char_one(dirichlet_char_t x, const dirichlet_group_t G) + void dirichlet_char_one(dirichlet_char_t x, const dirichlet_group_t G) noexcept # Sets *x* to the principal character in *G*, having *log* `[0,\dots 0]`. - void dirichlet_char_first_primitive(dirichlet_char_t x, const dirichlet_group_t G) + void dirichlet_char_first_primitive(dirichlet_char_t x, const dirichlet_group_t G) noexcept # Sets *x* to the first primitive character of *G*, having *log* `[1,\dots 1]`, # or `[0, 1, \dots 1]` if `8\mid q`. - void dirichlet_char_set(dirichlet_char_t x, const dirichlet_group_t G, const dirichlet_char_t y) + void dirichlet_char_set(dirichlet_char_t x, const dirichlet_group_t G, const dirichlet_char_t y) noexcept # Sets *x* to the element *y*. - int dirichlet_char_next(dirichlet_char_t x, const dirichlet_group_t G) + int dirichlet_char_next(dirichlet_char_t x, const dirichlet_group_t G) noexcept # Sets *x* to the next character in *G* according to lexicographic ordering # of *log*. # The return value @@ -91,56 +91,56 @@ cdef extern from "flint_wrap.h": # /* use character chi */ # } while (dirichlet_char_next(chi, G) >= 0); - int dirichlet_char_next_primitive(dirichlet_char_t x, const dirichlet_group_t G) + int dirichlet_char_next_primitive(dirichlet_char_t x, const dirichlet_group_t G) noexcept # Same as :func:`dirichlet_char_next`, but jumps to the next primitive character of *G*. - ulong dirichlet_index_char(const dirichlet_group_t G, const dirichlet_char_t x) + ulong dirichlet_index_char(const dirichlet_group_t G, const dirichlet_char_t x) noexcept # Returns the lexicographic index of the *log* of *x* as an integer in `0\dots \varphi(q)`. - void dirichlet_char_index(dirichlet_char_t x, const dirichlet_group_t G, ulong j) + void dirichlet_char_index(dirichlet_char_t x, const dirichlet_group_t G, ulong j) noexcept # Sets *x* to the character whose *log* has lexicographic index *j*. - bint dirichlet_char_eq(const dirichlet_char_t x, const dirichlet_char_t y) + bint dirichlet_char_eq(const dirichlet_char_t x, const dirichlet_char_t y) noexcept - int dirichlet_char_eq_deep(const dirichlet_group_t G, const dirichlet_char_t x, const dirichlet_char_t y) + int dirichlet_char_eq_deep(const dirichlet_group_t G, const dirichlet_char_t x, const dirichlet_char_t y) noexcept - bint dirichlet_char_is_principal(const dirichlet_group_t G, const dirichlet_char_t chi) + bint dirichlet_char_is_principal(const dirichlet_group_t G, const dirichlet_char_t chi) noexcept - ulong dirichlet_conductor_ui(const dirichlet_group_t G, ulong a) + ulong dirichlet_conductor_ui(const dirichlet_group_t G, ulong a) noexcept - ulong dirichlet_conductor_char(const dirichlet_group_t G, const dirichlet_char_t x) + ulong dirichlet_conductor_char(const dirichlet_group_t G, const dirichlet_char_t x) noexcept - int dirichlet_parity_ui(const dirichlet_group_t G, ulong a) + int dirichlet_parity_ui(const dirichlet_group_t G, ulong a) noexcept - int dirichlet_parity_char(const dirichlet_group_t G, const dirichlet_char_t x) + int dirichlet_parity_char(const dirichlet_group_t G, const dirichlet_char_t x) noexcept - ulong dirichlet_order_ui(const dirichlet_group_t G, ulong a) + ulong dirichlet_order_ui(const dirichlet_group_t G, ulong a) noexcept - ulong dirichlet_order_char(const dirichlet_group_t G, const dirichlet_char_t x) + ulong dirichlet_order_char(const dirichlet_group_t G, const dirichlet_char_t x) noexcept - bint dirichlet_char_is_real(const dirichlet_group_t G, const dirichlet_char_t chi) + bint dirichlet_char_is_real(const dirichlet_group_t G, const dirichlet_char_t chi) noexcept - bint dirichlet_char_is_primitive(const dirichlet_group_t G, const dirichlet_char_t chi) + bint dirichlet_char_is_primitive(const dirichlet_group_t G, const dirichlet_char_t chi) noexcept - ulong dirichlet_pairing(const dirichlet_group_t G, ulong m, ulong n) + ulong dirichlet_pairing(const dirichlet_group_t G, ulong m, ulong n) noexcept - ulong dirichlet_pairing_char(const dirichlet_group_t G, const dirichlet_char_t chi, const dirichlet_char_t psi) + ulong dirichlet_pairing_char(const dirichlet_group_t G, const dirichlet_char_t chi, const dirichlet_char_t psi) noexcept - ulong dirichlet_chi(const dirichlet_group_t G, const dirichlet_char_t chi, ulong n) + ulong dirichlet_chi(const dirichlet_group_t G, const dirichlet_char_t chi, ulong n) noexcept - void dirichlet_chi_vec(ulong * v, const dirichlet_group_t G, const dirichlet_char_t chi, slong nv) + void dirichlet_chi_vec(ulong * v, const dirichlet_group_t G, const dirichlet_char_t chi, slong nv) noexcept - void dirichlet_chi_vec_order(ulong * v, const dirichlet_group_t G, const dirichlet_char_t chi, ulong order, slong nv) + void dirichlet_chi_vec_order(ulong * v, const dirichlet_group_t G, const dirichlet_char_t chi, ulong order, slong nv) noexcept - void dirichlet_char_mul(dirichlet_char_t chi12, const dirichlet_group_t G, const dirichlet_char_t chi1, const dirichlet_char_t chi2) + void dirichlet_char_mul(dirichlet_char_t chi12, const dirichlet_group_t G, const dirichlet_char_t chi1, const dirichlet_char_t chi2) noexcept - void dirichlet_char_pow(dirichlet_char_t c, const dirichlet_group_t G, const dirichlet_char_t a, ulong n) + void dirichlet_char_pow(dirichlet_char_t c, const dirichlet_group_t G, const dirichlet_char_t a, ulong n) noexcept - void dirichlet_char_lift(dirichlet_char_t chi_G, const dirichlet_group_t G, const dirichlet_char_t chi_H, const dirichlet_group_t H) + void dirichlet_char_lift(dirichlet_char_t chi_G, const dirichlet_group_t G, const dirichlet_char_t chi_H, const dirichlet_group_t H) noexcept # If *H* is a subgroup of *G*, computes the character in *G* corresponding to # *chi_H* in *H*. - void dirichlet_char_lower(dirichlet_char_t chi_H, const dirichlet_group_t H, const dirichlet_char_t chi_G, const dirichlet_group_t G) + void dirichlet_char_lower(dirichlet_char_t chi_H, const dirichlet_group_t H, const dirichlet_char_t chi_G, const dirichlet_group_t G) noexcept # If *chi_G* is a character of *G* which factors through *H*, sets *chi_H* to # the corresponding restriction in *H*. # This requires `c(\chi_G)\mid q_H\mid q_G`, where `c(\chi_G)` is the diff --git a/src/sage/libs/flint/dlog.pxd b/src/sage/libs/flint/dlog.pxd index e48e8374203..cca9f7a886d 100644 --- a/src/sage/libs/flint/dlog.pxd +++ b/src/sage/libs/flint/dlog.pxd @@ -12,74 +12,74 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - ulong dlog_once(ulong b, ulong a, const nmod_t mod, ulong n) + ulong dlog_once(ulong b, ulong a, const nmod_t mod, ulong n) noexcept - void dlog_precomp_n_init(dlog_precomp_t pre, ulong a, ulong mod, ulong n, ulong num) + void dlog_precomp_n_init(dlog_precomp_t pre, ulong a, ulong mod, ulong n, ulong num) noexcept - ulong dlog_precomp(const dlog_precomp_t pre, ulong b) + ulong dlog_precomp(const dlog_precomp_t pre, ulong b) noexcept - void dlog_precomp_clear(dlog_precomp_t pre) + void dlog_precomp_clear(dlog_precomp_t pre) noexcept - void dlog_precomp_modpe_init(dlog_precomp_t pre, ulong a, ulong p, ulong e, ulong pe, ulong num) + void dlog_precomp_modpe_init(dlog_precomp_t pre, ulong a, ulong p, ulong e, ulong pe, ulong num) noexcept - void dlog_precomp_p_init(dlog_precomp_t pre, ulong a, ulong mod, ulong p, ulong num) + void dlog_precomp_p_init(dlog_precomp_t pre, ulong a, ulong mod, ulong p, ulong num) noexcept - void dlog_precomp_pe_init(dlog_precomp_t pre, ulong a, ulong mod, ulong p, ulong e, ulong pe, ulong num) + void dlog_precomp_pe_init(dlog_precomp_t pre, ulong a, ulong mod, ulong p, ulong e, ulong pe, ulong num) noexcept - void dlog_precomp_small_init(dlog_precomp_t pre, ulong a, ulong mod, ulong n, ulong num) + void dlog_precomp_small_init(dlog_precomp_t pre, ulong a, ulong mod, ulong n, ulong num) noexcept - void dlog_vec_fill(ulong * v, ulong nv, ulong x) + void dlog_vec_fill(ulong * v, ulong nv, ulong x) noexcept - void dlog_vec_set_not_found(ulong * v, ulong nv, nmod_t mod) + void dlog_vec_set_not_found(ulong * v, ulong nv, nmod_t mod) noexcept - void dlog_vec(ulong * v, ulong nv, ulong a, ulong va, nmod_t mod, ulong na, nmod_t order) + void dlog_vec(ulong * v, ulong nv, ulong a, ulong va, nmod_t mod, ulong na, nmod_t order) noexcept - void dlog_vec_add(ulong * v, ulong nv, ulong a, ulong va, nmod_t mod, ulong na, nmod_t order) + void dlog_vec_add(ulong * v, ulong nv, ulong a, ulong va, nmod_t mod, ulong na, nmod_t order) noexcept - void dlog_vec_loop(ulong * v, ulong nv, ulong a, ulong va, nmod_t mod, ulong na, nmod_t order) + void dlog_vec_loop(ulong * v, ulong nv, ulong a, ulong va, nmod_t mod, ulong na, nmod_t order) noexcept - void dlog_vec_loop_add(ulong * v, ulong nv, ulong a, ulong va, nmod_t mod, ulong na, nmod_t order) + void dlog_vec_loop_add(ulong * v, ulong nv, ulong a, ulong va, nmod_t mod, ulong na, nmod_t order) noexcept - void dlog_vec_eratos(ulong * v, ulong nv, ulong a, ulong va, nmod_t mod, ulong na, nmod_t order) + void dlog_vec_eratos(ulong * v, ulong nv, ulong a, ulong va, nmod_t mod, ulong na, nmod_t order) noexcept - void dlog_vec_eratos_add(ulong * v, ulong nv, ulong a, ulong va, nmod_t mod, ulong na, nmod_t order) + void dlog_vec_eratos_add(ulong * v, ulong nv, ulong a, ulong va, nmod_t mod, ulong na, nmod_t order) noexcept - void dlog_vec_sieve_add(ulong * v, ulong nv, ulong a, ulong va, nmod_t mod, ulong na, nmod_t order) + void dlog_vec_sieve_add(ulong * v, ulong nv, ulong a, ulong va, nmod_t mod, ulong na, nmod_t order) noexcept - void dlog_vec_sieve(ulong * v, ulong nv, ulong a, ulong va, nmod_t mod, ulong na, nmod_t order) + void dlog_vec_sieve(ulong * v, ulong nv, ulong a, ulong va, nmod_t mod, ulong na, nmod_t order) noexcept - ulong dlog_table_init(dlog_table_t t, ulong a, ulong mod) + ulong dlog_table_init(dlog_table_t t, ulong a, ulong mod) noexcept - void dlog_table_clear(dlog_table_t t) + void dlog_table_clear(dlog_table_t t) noexcept - ulong dlog_table(const dlog_table_t t, ulong b) + ulong dlog_table(const dlog_table_t t, ulong b) noexcept - ulong dlog_bsgs_init(dlog_bsgs_t t, ulong a, ulong mod, ulong n, ulong m) + ulong dlog_bsgs_init(dlog_bsgs_t t, ulong a, ulong mod, ulong n, ulong m) noexcept - void dlog_bsgs_clear(dlog_bsgs_t t) + void dlog_bsgs_clear(dlog_bsgs_t t) noexcept - ulong dlog_bsgs(const dlog_bsgs_t t, ulong b) + ulong dlog_bsgs(const dlog_bsgs_t t, ulong b) noexcept - ulong dlog_modpe_init(dlog_modpe_t t, ulong a, ulong p, ulong e, ulong pe, ulong num) + ulong dlog_modpe_init(dlog_modpe_t t, ulong a, ulong p, ulong e, ulong pe, ulong num) noexcept - void dlog_modpe_clear(dlog_modpe_t t) + void dlog_modpe_clear(dlog_modpe_t t) noexcept - ulong dlog_modpe(const dlog_modpe_t t, ulong b) + ulong dlog_modpe(const dlog_modpe_t t, ulong b) noexcept - ulong dlog_crt_init(dlog_crt_t t, ulong a, ulong mod, ulong n, ulong num) + ulong dlog_crt_init(dlog_crt_t t, ulong a, ulong mod, ulong n, ulong num) noexcept - void dlog_crt_clear(dlog_crt_t t) + void dlog_crt_clear(dlog_crt_t t) noexcept - ulong dlog_crt(const dlog_crt_t t, ulong b) + ulong dlog_crt(const dlog_crt_t t, ulong b) noexcept - ulong dlog_power_init(dlog_power_t t, ulong a, ulong mod, ulong p, ulong e, ulong num) + ulong dlog_power_init(dlog_power_t t, ulong a, ulong mod, ulong p, ulong e, ulong num) noexcept - void dlog_power_clear(dlog_power_t t) + void dlog_power_clear(dlog_power_t t) noexcept - ulong dlog_power(const dlog_power_t t, ulong b) + ulong dlog_power(const dlog_power_t t, ulong b) noexcept - void dlog_rho_init(dlog_rho_t t, ulong a, ulong mod, ulong n) + void dlog_rho_init(dlog_rho_t t, ulong a, ulong mod, ulong n) noexcept - void dlog_rho_clear(dlog_rho_t t) + void dlog_rho_clear(dlog_rho_t t) noexcept - ulong dlog_rho(const dlog_rho_t t, ulong b) + ulong dlog_rho(const dlog_rho_t t, ulong b) noexcept diff --git a/src/sage/libs/flint/double_extras.pxd b/src/sage/libs/flint/double_extras.pxd index 2505ea963e3..ec6204b1b81 100644 --- a/src/sage/libs/flint/double_extras.pxd +++ b/src/sage/libs/flint/double_extras.pxd @@ -12,22 +12,22 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - double d_randtest(flint_rand_t state) + double d_randtest(flint_rand_t state) noexcept # Returns a random number in the interval `[0.5, 1)`. - double d_randtest_signed(flint_rand_t state, slong minexp, slong maxexp) + double d_randtest_signed(flint_rand_t state, slong minexp, slong maxexp) noexcept # Returns a random signed number with exponent between ``minexp`` and # ``maxexp`` or zero. - double d_randtest_special(flint_rand_t state, slong minexp, slong maxexp) + double d_randtest_special(flint_rand_t state, slong minexp, slong maxexp) noexcept # Returns a random signed number with exponent between ``minexp`` and # ``maxexp``, zero, ``D_NAN`` or `\pm`\ ``D_INF``. - double d_polyval(const double * poly, int len, double x) + double d_polyval(const double * poly, int len, double x) noexcept # Uses Horner's rule to evaluate the polynomial defined by the given # ``len`` coefficients. Requires that ``len`` is nonzero. - double d_lambertw(double x) + double d_lambertw(double x) noexcept # Computes the principal branch of the Lambert W function, solving # the equation `x = W(x) \exp(W(x))`. If `x < -1/e`, the solution is # complex, and NaN is returned. @@ -42,10 +42,10 @@ cdef extern from "flint_wrap.h": # However, accuracy may be worse depending on compiler flags and # the accuracy of the system libm functions. - bint d_is_nan(double x) + bint d_is_nan(double x) noexcept # Returns a nonzero integral value if ``x`` is ``D_NAN``, and otherwise # returns 0. - double d_log2(double x) + double d_log2(double x) noexcept # Returns the base 2 logarithm of ``x`` provided ``x`` is positive. If # a domain or pole error occurs, the appropriate error value is returned. diff --git a/src/sage/libs/flint/double_interval.pxd b/src/sage/libs/flint/double_interval.pxd index 1d1717352b2..58077fa48d1 100644 --- a/src/sage/libs/flint/double_interval.pxd +++ b/src/sage/libs/flint/double_interval.pxd @@ -12,55 +12,55 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - di_t di_interval(double a, double b) + di_t di_interval(double a, double b) noexcept # Returns the interval `[a, b]`. We require that the endpoints # are ordered and not NaN. - di_t arb_get_di(const arb_t x) + di_t arb_get_di(const arb_t x) noexcept # Returns the ball *x* converted to a double-precision interval. - void arb_set_di(arb_t res, di_t x, slong prec) + void arb_set_di(arb_t res, di_t x, slong prec) noexcept # Sets the ball *res* to the double-precision interval *x*, # rounded to *prec* bits. - void di_print(di_t x) + void di_print(di_t x) noexcept # Prints *x* to standard output. This simply prints decimal # representations of the floating-point endpoints; the # decimals are not guaranteed to be rounded outward. - double d_randtest2(flint_rand_t state) + double d_randtest2(flint_rand_t state) noexcept # Returns a random non-NaN ``double`` with any exponent. # The value can be infinite or subnormal. - di_t di_randtest(flint_rand_t state) + di_t di_randtest(flint_rand_t state) noexcept # Returns an interval with random endpoints. - di_t di_neg(di_t x) + di_t di_neg(di_t x) noexcept # Returns the exact negation of *x*. - di_t di_fast_add(di_t x, di_t y) - di_t di_fast_sub(di_t x, di_t y) - di_t di_fast_mul(di_t x, di_t y) - di_t di_fast_div(di_t x, di_t y) + di_t di_fast_add(di_t x, di_t y) noexcept + di_t di_fast_sub(di_t x, di_t y) noexcept + di_t di_fast_mul(di_t x, di_t y) noexcept + di_t di_fast_div(di_t x, di_t y) noexcept # Returns the sum, difference, product or quotient of *x* and *y*. # Division by zero is currently defined to return `[-\infty, +\infty]`. - di_t di_fast_sqr(di_t x) + di_t di_fast_sqr(di_t x) noexcept # Returns the square of *x*. The output is clamped to # be nonnegative. - di_t di_fast_add_d(di_t x, double y) - di_t di_fast_sub_d(di_t x, double y) - di_t di_fast_mul_d(di_t x, double y) - di_t di_fast_div_d(di_t x, double y) + di_t di_fast_add_d(di_t x, double y) noexcept + di_t di_fast_sub_d(di_t x, double y) noexcept + di_t di_fast_mul_d(di_t x, double y) noexcept + di_t di_fast_div_d(di_t x, double y) noexcept # Arithmetic with an exact ``double`` operand. - di_t di_fast_log_nonnegative(di_t x) + di_t di_fast_log_nonnegative(di_t x) noexcept # Returns an enclosure of `\log(x)`. The lower endpoint of *x* # is rounded up to 0 if it is negative. - di_t di_fast_mid(di_t x) + di_t di_fast_mid(di_t x) noexcept # Returns an enclosure of the midpoint of *x*. - double di_fast_ubound_radius(di_t x) + double di_fast_ubound_radius(di_t x) noexcept # Returns an upper bound for the radius of *x*. diff --git a/src/sage/libs/flint/fexpr.pxd b/src/sage/libs/flint/fexpr.pxd index c9bf6c5b11a..dd2ac046e88 100644 --- a/src/sage/libs/flint/fexpr.pxd +++ b/src/sage/libs/flint/fexpr.pxd @@ -12,179 +12,179 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void fexpr_init(fexpr_t expr) + void fexpr_init(fexpr_t expr) noexcept # Initializes *expr* for use. Its value is set to the atomic # integer 0. - void fexpr_clear(fexpr_t expr) + void fexpr_clear(fexpr_t expr) noexcept # Clears *expr*, freeing its allocated memory. - fexpr_ptr _fexpr_vec_init(slong len) + fexpr_ptr _fexpr_vec_init(slong len) noexcept # Returns a heap-allocated vector of *len* initialized expressions. - void _fexpr_vec_clear(fexpr_ptr vec, slong len) + void _fexpr_vec_clear(fexpr_ptr vec, slong len) noexcept # Clears the *len* expressions in *vec* and frees *vec* itself. - void fexpr_fit_size(fexpr_t expr, slong size) + void fexpr_fit_size(fexpr_t expr, slong size) noexcept # Ensures that *expr* has room for *size* words. - void fexpr_set(fexpr_t res, const fexpr_t expr) + void fexpr_set(fexpr_t res, const fexpr_t expr) noexcept # Sets *res* to the a copy of *expr*. - void fexpr_swap(fexpr_t a, fexpr_t b) + void fexpr_swap(fexpr_t a, fexpr_t b) noexcept # Swaps *a* and *b* efficiently. - slong fexpr_depth(const fexpr_t expr) + slong fexpr_depth(const fexpr_t expr) noexcept # Returns the depth of *expr* as a symbolic expression tree. - slong fexpr_num_leaves(const fexpr_t expr) + slong fexpr_num_leaves(const fexpr_t expr) noexcept # Returns the number of leaves (atoms, counted with repetition) # in the expression *expr*. - slong fexpr_size(const fexpr_t expr) + slong fexpr_size(const fexpr_t expr) noexcept # Returns the number of words in the internal representation # of *expr*. - slong fexpr_size_bytes(const fexpr_t expr) + slong fexpr_size_bytes(const fexpr_t expr) noexcept # Returns the number of bytes in the internal representation # of *expr*. The count excludes the size of the structure itself. # Add ``sizeof(fexpr_struct)`` to get the size of the object as a # whole. - slong fexpr_allocated_bytes(const fexpr_t expr) + slong fexpr_allocated_bytes(const fexpr_t expr) noexcept # Returns the number of allocated bytes in the internal # representation of *expr*. The count excludes the size of the # structure itself. Add ``sizeof(fexpr_struct)`` to get the size of # the object as a whole. - bint fexpr_equal(const fexpr_t a, const fexpr_t b) + bint fexpr_equal(const fexpr_t a, const fexpr_t b) noexcept # Checks if *a* and *b* are exactly equal as expressions. - bint fexpr_equal_si(const fexpr_t expr, slong c) + bint fexpr_equal_si(const fexpr_t expr, slong c) noexcept - bint fexpr_equal_ui(const fexpr_t expr, ulong c) + bint fexpr_equal_ui(const fexpr_t expr, ulong c) noexcept # Checks if *expr* is an atomic integer exactly equal to *c*. - ulong fexpr_hash(const fexpr_t expr) + ulong fexpr_hash(const fexpr_t expr) noexcept # Returns a hash of the expression *expr*. - int fexpr_cmp_fast(const fexpr_t a, const fexpr_t b) + int fexpr_cmp_fast(const fexpr_t a, const fexpr_t b) noexcept # Compares *a* and *b* using an ordering based on the internal # representation, returning -1, 0 or 1. This can be used, for # instance, to maintain sorted arrays of expressions for binary # search; the sort order has no mathematical significance. - bint fexpr_is_integer(const fexpr_t expr) + bint fexpr_is_integer(const fexpr_t expr) noexcept # Returns whether *expr* is an atomic integer - bint fexpr_is_symbol(const fexpr_t expr) + bint fexpr_is_symbol(const fexpr_t expr) noexcept # Returns whether *expr* is an atomic symbol. - bint fexpr_is_string(const fexpr_t expr) + bint fexpr_is_string(const fexpr_t expr) noexcept # Returns whether *expr* is an atomic string. - bint fexpr_is_atom(const fexpr_t expr) + bint fexpr_is_atom(const fexpr_t expr) noexcept # Returns whether *expr* is any atom. - void fexpr_zero(fexpr_t res) + void fexpr_zero(fexpr_t res) noexcept # Sets *res* to the atomic integer 0. - bint fexpr_is_zero(const fexpr_t expr) + bint fexpr_is_zero(const fexpr_t expr) noexcept # Returns whether *expr* is the atomic integer 0. - bint fexpr_is_neg_integer(const fexpr_t expr) + bint fexpr_is_neg_integer(const fexpr_t expr) noexcept # Returns whether *expr* is any negative atomic integer. - void fexpr_set_si(fexpr_t res, slong c) - void fexpr_set_ui(fexpr_t res, ulong c) - void fexpr_set_fmpz(fexpr_t res, const fmpz_t c) + void fexpr_set_si(fexpr_t res, slong c) noexcept + void fexpr_set_ui(fexpr_t res, ulong c) noexcept + void fexpr_set_fmpz(fexpr_t res, const fmpz_t c) noexcept # Sets *res* to the atomic integer *c*. - int fexpr_get_fmpz(fmpz_t res, const fexpr_t expr) + int fexpr_get_fmpz(fmpz_t res, const fexpr_t expr) noexcept # Sets *res* to the atomic integer in *expr*. This aborts # if *expr* is not an atomic integer. - void fexpr_set_symbol_builtin(fexpr_t res, slong id) + void fexpr_set_symbol_builtin(fexpr_t res, slong id) noexcept # Sets *res* to the builtin symbol with internal index *id* # (see :ref:`fexpr-builtin`). - bint fexpr_is_builtin_symbol(const fexpr_t expr, slong id) + bint fexpr_is_builtin_symbol(const fexpr_t expr, slong id) noexcept # Returns whether *expr* is the builtin symbol with index *id* # (see :ref:`fexpr-builtin`). - bint fexpr_is_any_builtin_symbol(const fexpr_t expr) + bint fexpr_is_any_builtin_symbol(const fexpr_t expr) noexcept # Returns whether *expr* is any builtin symbol # (see :ref:`fexpr-builtin`). - void fexpr_set_symbol_str(fexpr_t res, const char * s) + void fexpr_set_symbol_str(fexpr_t res, const char * s) noexcept # Sets *res* to the symbol given by *s*. - char * fexpr_get_symbol_str(const fexpr_t expr) + char * fexpr_get_symbol_str(const fexpr_t expr) noexcept # Returns the symbol in *expr* as a string. The string must # be freed with :func:`flint_free`. # This aborts if *expr* is not an atomic symbol. - void fexpr_set_string(fexpr_t res, const char * s) + void fexpr_set_string(fexpr_t res, const char * s) noexcept # Sets *res* to the atomic string *s*. - char * fexpr_get_string(const fexpr_t expr) + char * fexpr_get_string(const fexpr_t expr) noexcept # Assuming that *expr* is an atomic string, returns a copy of this # string. The string must be freed with :func:`flint_free`. - void fexpr_write(calcium_stream_t stream, const fexpr_t expr) + void fexpr_write(calcium_stream_t stream, const fexpr_t expr) noexcept # Writes *expr* to *stream*. - void fexpr_print(const fexpr_t expr) + void fexpr_print(const fexpr_t expr) noexcept # Prints *expr* to standard output. - char * fexpr_get_str(const fexpr_t expr) + char * fexpr_get_str(const fexpr_t expr) noexcept # Returns a string representation of *expr*. The string must # be freed with :func:`flint_free`. # Warning: string literals appearing in expressions # are currently not escaped. - void fexpr_write_latex(calcium_stream_t stream, const fexpr_t expr, ulong flags) + void fexpr_write_latex(calcium_stream_t stream, const fexpr_t expr, ulong flags) noexcept # Writes the LaTeX representation of *expr* to *stream*. - void fexpr_print_latex(const fexpr_t expr, ulong flags) + void fexpr_print_latex(const fexpr_t expr, ulong flags) noexcept # Prints the LaTeX representation of *expr* to standard output. - char * fexpr_get_str_latex(const fexpr_t expr, ulong flags) + char * fexpr_get_str_latex(const fexpr_t expr, ulong flags) noexcept # Returns a string of the LaTeX representation of *expr*. The string # must be freed with :func:`flint_free`. # Warning: string literals appearing in expressions # are currently not escaped. - slong fexpr_nargs(const fexpr_t expr) + slong fexpr_nargs(const fexpr_t expr) noexcept # Returns the number of arguments *n* in the function call # `f(e_1,\ldots,e_n)` represented # by *expr*. If *expr* is an atom, returns -1. - void fexpr_func(fexpr_t res, const fexpr_t expr) + void fexpr_func(fexpr_t res, const fexpr_t expr) noexcept # Assuming that *expr* represents a function call # `f(e_1,\ldots,e_n)`, sets *res* to the function expression *f*. - void fexpr_view_func(fexpr_t view, const fexpr_t expr) + void fexpr_view_func(fexpr_t view, const fexpr_t expr) noexcept # As :func:`fexpr_func`, but sets *view* to a shallow view # instead of copying the expression. # The variable *view* must not be initialized before use or # cleared after use, and *expr* must not be modified or cleared # as long as *view* is in use. - void fexpr_arg(fexpr_t res, const fexpr_t expr, slong i) + void fexpr_arg(fexpr_t res, const fexpr_t expr, slong i) noexcept # Assuming that *expr* represents a function call # `f(e_1,\ldots,e_n)`, sets *res* to the argument `e_{i+1}`. # Note that indexing starts from 0. # The index must be in bounds, with `0 \le i < n`. - void fexpr_view_arg(fexpr_t view, const fexpr_t expr, slong i) + void fexpr_view_arg(fexpr_t view, const fexpr_t expr, slong i) noexcept # As :func:`fexpr_arg`, but sets *view* to a shallow view # instead of copying the expression. # The variable *view* must not be initialized before use or # cleared after use, and *expr* must not be modified or cleared # as long as *view* is in use. - void fexpr_view_next(fexpr_t view) + void fexpr_view_next(fexpr_t view) noexcept # Assuming that *view* is a shallow view of a function argument `e_i` # in a function call `f(e_1,\ldots,e_n)`, sets *view* to # a view of the next argument `e_{i+1}`. @@ -193,46 +193,46 @@ cdef extern from "flint_wrap.h": # This function can also be called when *view* refers to the function *f*, # in which case it will make *view* point to `e_1`. - bint fexpr_is_builtin_call(const fexpr_t expr, slong id) + bint fexpr_is_builtin_call(const fexpr_t expr, slong id) noexcept # Returns whether *expr* has the form `f(\ldots)` where *f* is # a builtin function defined by *id* (see :ref:`fexpr-builtin`). - bint fexpr_is_any_builtin_call(const fexpr_t expr) + bint fexpr_is_any_builtin_call(const fexpr_t expr) noexcept # Returns whether *expr* has the form `f(\ldots)` where *f* is # any builtin function (see :ref:`fexpr-builtin`). - void fexpr_call0(fexpr_t res, const fexpr_t f) - void fexpr_call1(fexpr_t res, const fexpr_t f, const fexpr_t x1) - void fexpr_call2(fexpr_t res, const fexpr_t f, const fexpr_t x1, const fexpr_t x2) - void fexpr_call3(fexpr_t res, const fexpr_t f, const fexpr_t x1, const fexpr_t x2, const fexpr_t x3) - void fexpr_call4(fexpr_t res, const fexpr_t f, const fexpr_t x1, const fexpr_t x2, const fexpr_t x3, const fexpr_t x4) - void fexpr_call_vec(fexpr_t res, const fexpr_t f, fexpr_srcptr args, slong len) + void fexpr_call0(fexpr_t res, const fexpr_t f) noexcept + void fexpr_call1(fexpr_t res, const fexpr_t f, const fexpr_t x1) noexcept + void fexpr_call2(fexpr_t res, const fexpr_t f, const fexpr_t x1, const fexpr_t x2) noexcept + void fexpr_call3(fexpr_t res, const fexpr_t f, const fexpr_t x1, const fexpr_t x2, const fexpr_t x3) noexcept + void fexpr_call4(fexpr_t res, const fexpr_t f, const fexpr_t x1, const fexpr_t x2, const fexpr_t x3, const fexpr_t x4) noexcept + void fexpr_call_vec(fexpr_t res, const fexpr_t f, fexpr_srcptr args, slong len) noexcept # Creates the function call `f(x_1,\ldots,x_n)`. # The *vec* version takes the arguments as an array *args* # and *n* is given by *len*. # Warning: aliasing between inputs and outputs is not implemented. - void fexpr_call_builtin1(fexpr_t res, slong f, const fexpr_t x1) - void fexpr_call_builtin2(fexpr_t res, slong f, const fexpr_t x1, const fexpr_t x2) + void fexpr_call_builtin1(fexpr_t res, slong f, const fexpr_t x1) noexcept + void fexpr_call_builtin2(fexpr_t res, slong f, const fexpr_t x1, const fexpr_t x2) noexcept # Creates the function call `f(x_1,\ldots,x_n)`, where *f* defines # a builtin symbol. - bint fexpr_contains(const fexpr_t expr, const fexpr_t x) + bint fexpr_contains(const fexpr_t expr, const fexpr_t x) noexcept # Returns whether *expr* contains the expression *x* as a subexpression # (this includes the case where *expr* and *x* are equal). - int fexpr_replace(fexpr_t res, const fexpr_t expr, const fexpr_t x, const fexpr_t y) + int fexpr_replace(fexpr_t res, const fexpr_t expr, const fexpr_t x, const fexpr_t y) noexcept # Sets *res* to the expression *expr* with all occurrences of the subexpression # *x* replaced by the expression *y*. Returns a boolean value indicating whether # any replacements have been performed. # Aliasing is allowed between *res* and *expr* but not between *res* # and *x* or *y*. - int fexpr_replace2(fexpr_t res, const fexpr_t expr, const fexpr_t x1, const fexpr_t y1, const fexpr_t x2, const fexpr_t y2) + int fexpr_replace2(fexpr_t res, const fexpr_t expr, const fexpr_t x1, const fexpr_t y1, const fexpr_t x2, const fexpr_t y2) noexcept # Like :func:`fexpr_replace`, but simultaneously replaces *x1* by *y1* # and *x2* by *y2*. - int fexpr_replace_vec(fexpr_t res, const fexpr_t expr, const fexpr_vec_t xs, const fexpr_vec_t ys) + int fexpr_replace_vec(fexpr_t res, const fexpr_t expr, const fexpr_vec_t xs, const fexpr_vec_t ys) noexcept # Sets *res* to the expression *expr* with all occurrences of the # subexpressions given by entries in *xs* replaced by the corresponding # expressions in *ys*. It is required that *xs* and *ys* have the same length. @@ -241,38 +241,38 @@ cdef extern from "flint_wrap.h": # Aliasing is allowed between *res* and *expr* but not between *res* # and the entries of *xs* or *ys*. - void fexpr_set_fmpq(fexpr_t res, const fmpq_t x) + void fexpr_set_fmpq(fexpr_t res, const fmpq_t x) noexcept # Sets *res* to the rational number *x*. This creates an atomic # integer if the denominator of *x* is one, and otherwise creates a # division expression. - void fexpr_set_arf(fexpr_t res, const arf_t x) - void fexpr_set_d(fexpr_t res, double x) + void fexpr_set_arf(fexpr_t res, const arf_t x) noexcept + void fexpr_set_d(fexpr_t res, double x) noexcept # Sets *res* to an expression for the value of the # floating-point number *x*. NaN is represented # as ``Undefined``. For a regular value, this creates an atomic integer # or a rational fraction if the exponent is small, and otherwise # creates an expression of the form ``Mul(m, Pow(2, e))``. - void fexpr_set_re_im_d(fexpr_t res, double x, double y) + void fexpr_set_re_im_d(fexpr_t res, double x, double y) noexcept # Sets *res* to an expression for the complex number with real part # *x* and imaginary part *y*. - void fexpr_neg(fexpr_t res, const fexpr_t a) - void fexpr_add(fexpr_t res, const fexpr_t a, const fexpr_t b) - void fexpr_sub(fexpr_t res, const fexpr_t a, const fexpr_t b) - void fexpr_mul(fexpr_t res, const fexpr_t a, const fexpr_t b) - void fexpr_div(fexpr_t res, const fexpr_t a, const fexpr_t b) - void fexpr_pow(fexpr_t res, const fexpr_t a, const fexpr_t b) + void fexpr_neg(fexpr_t res, const fexpr_t a) noexcept + void fexpr_add(fexpr_t res, const fexpr_t a, const fexpr_t b) noexcept + void fexpr_sub(fexpr_t res, const fexpr_t a, const fexpr_t b) noexcept + void fexpr_mul(fexpr_t res, const fexpr_t a, const fexpr_t b) noexcept + void fexpr_div(fexpr_t res, const fexpr_t a, const fexpr_t b) noexcept + void fexpr_pow(fexpr_t res, const fexpr_t a, const fexpr_t b) noexcept # Constructs an arithmetic expression with given arguments. # No simplifications whatsoever are performed. - bint fexpr_is_arithmetic_operation(const fexpr_t expr) + bint fexpr_is_arithmetic_operation(const fexpr_t expr) noexcept # Returns whether *expr* is of the form `f(e_1,\ldots,e_n)` # where *f* is one of the arithmetic operators ``Pos``, ``Neg``, # ``Add``, ``Sub``, ``Mul``, ``Div``. - void fexpr_arithmetic_nodes(fexpr_vec_t nodes, const fexpr_t expr) + void fexpr_arithmetic_nodes(fexpr_vec_t nodes, const fexpr_t expr) noexcept # Sets *nodes* to a vector of subexpressions of *expr* such that *expr* # is an arithmetic expression with *nodes* as leaves. # More precisely, *expr* will be constructed out of nested application @@ -283,7 +283,7 @@ cdef extern from "flint_wrap.h": # The nodes are output without repetition but are not automatically sorted in # a canonical order. - int fexpr_get_fmpz_mpoly_q(fmpz_mpoly_q_t res, const fexpr_t expr, const fexpr_vec_t vars, const fmpz_mpoly_ctx_t ctx) + int fexpr_get_fmpz_mpoly_q(fmpz_mpoly_q_t res, const fexpr_t expr, const fexpr_vec_t vars, const fmpz_mpoly_ctx_t ctx) noexcept # Sets *res* to the expression *expr* as a formal rational # function of the subexpressions in *vars*. # The vector *vars* must have the same length as the number of @@ -302,8 +302,8 @@ cdef extern from "flint_wrap.h": # and can implicitly divide by zero if *vars* are not algebraically # independent. - void fexpr_set_fmpz_mpoly(fexpr_t res, const fmpz_mpoly_t poly, const fexpr_vec_t vars, const fmpz_mpoly_ctx_t ctx) - void fexpr_set_fmpz_mpoly_q(fexpr_t res, const fmpz_mpoly_q_t frac, const fexpr_vec_t vars, const fmpz_mpoly_ctx_t ctx) + void fexpr_set_fmpz_mpoly(fexpr_t res, const fmpz_mpoly_t poly, const fexpr_vec_t vars, const fmpz_mpoly_ctx_t ctx) noexcept + void fexpr_set_fmpz_mpoly_q(fexpr_t res, const fmpz_mpoly_q_t frac, const fexpr_vec_t vars, const fmpz_mpoly_ctx_t ctx) noexcept # Sets *res* to an expression for the multivariate polynomial *poly* # (or rational function *frac*), # using the expressions in *vars* as the variables. The length @@ -311,7 +311,7 @@ cdef extern from "flint_wrap.h": # If *NULL* is passed for *vars*, a default choice of symbols # is used. - int fexpr_expanded_normal_form(fexpr_t res, const fexpr_t expr, ulong flags) + int fexpr_expanded_normal_form(fexpr_t res, const fexpr_t expr, ulong flags) noexcept # Sets *res* to *expr* converted to expanded normal form viewed # as a formal rational function with its non-arithmetic subexpressions # as terminal nodes. @@ -321,36 +321,36 @@ cdef extern from "flint_wrap.h": # expression with :func:`fexpr_set_fmpz_mpoly_q`. # Optional *flags* are reserved for future use. - void fexpr_vec_init(fexpr_vec_t vec, slong len) + void fexpr_vec_init(fexpr_vec_t vec, slong len) noexcept # Initializes *vec* to a vector of length *len*. All entries # are set to the atomic integer 0. - void fexpr_vec_clear(fexpr_vec_t vec) + void fexpr_vec_clear(fexpr_vec_t vec) noexcept # Clears the vector *vec*. - void fexpr_vec_print(const fexpr_vec_t vec) + void fexpr_vec_print(const fexpr_vec_t vec) noexcept # Prints *vec* to standard output. - void fexpr_vec_swap(fexpr_vec_t x, fexpr_vec_t y) + void fexpr_vec_swap(fexpr_vec_t x, fexpr_vec_t y) noexcept # Swaps *x* and *y* efficiently. - void fexpr_vec_fit_length(fexpr_vec_t vec, slong len) + void fexpr_vec_fit_length(fexpr_vec_t vec, slong len) noexcept # Ensures that *vec* has space for *len* entries. - void fexpr_vec_set(fexpr_vec_t dest, const fexpr_vec_t src) + void fexpr_vec_set(fexpr_vec_t dest, const fexpr_vec_t src) noexcept # Sets *dest* to a copy of *src*. - void fexpr_vec_append(fexpr_vec_t vec, const fexpr_t expr) + void fexpr_vec_append(fexpr_vec_t vec, const fexpr_t expr) noexcept # Appends *expr* to the end of the vector *vec*. - slong fexpr_vec_insert_unique(fexpr_vec_t vec, const fexpr_t expr) + slong fexpr_vec_insert_unique(fexpr_vec_t vec, const fexpr_t expr) noexcept # Inserts *expr* without duplication into vec, returning its # position. If this expression already exists, *vec* is unchanged. # If this expression does not exist in *vec*, it is appended. - void fexpr_vec_set_length(fexpr_vec_t vec, slong len) + void fexpr_vec_set_length(fexpr_vec_t vec, slong len) noexcept # Sets the length of *vec* to *len*, truncating or zero-extending as needed. - void _fexpr_vec_sort_fast(fexpr_ptr vec, slong len) + void _fexpr_vec_sort_fast(fexpr_ptr vec, slong len) noexcept # Sorts the *len* entries in *vec* using # the comparison function :func:`fexpr_cmp_fast`. diff --git a/src/sage/libs/flint/fexpr_builtin.pxd b/src/sage/libs/flint/fexpr_builtin.pxd index 57a63958f06..068a6feee89 100644 --- a/src/sage/libs/flint/fexpr_builtin.pxd +++ b/src/sage/libs/flint/fexpr_builtin.pxd @@ -12,14 +12,14 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - slong fexpr_builtin_lookup(const char * s) + slong fexpr_builtin_lookup(const char * s) noexcept # Returns the internal index used to encode the builtin symbol # with name *s* in expressions. If *s* is not the name of a builtin # symbol, returns -1. - const char * fexpr_builtin_name(slong n) + const char * fexpr_builtin_name(slong n) noexcept # Returns a read-only pointer for a string giving the name of the # builtin symbol with index *n*. - slong fexpr_builtin_length() + slong fexpr_builtin_length() noexcept # Returns the number of builtin symbols. diff --git a/src/sage/libs/flint/fft.pxd b/src/sage/libs/flint/fft.pxd index 75803b47b32..68d0dc09ae8 100644 --- a/src/sage/libs/flint/fft.pxd +++ b/src/sage/libs/flint/fft.pxd @@ -12,7 +12,7 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - mp_size_t fft_split_limbs(mp_limb_t ** poly, mp_srcptr limbs, mp_size_t total_limbs, mp_size_t coeff_limbs, mp_size_t output_limbs) + mp_size_t fft_split_limbs(mp_limb_t ** poly, mp_srcptr limbs, mp_size_t total_limbs, mp_size_t coeff_limbs, mp_size_t output_limbs) noexcept # Split an integer ``(limbs, total_limbs)`` into coefficients of length # ``coeff_limbs`` limbs and store as the coefficients of ``poly`` # which are assumed to have space for ``output_limbs + 1`` limbs per @@ -21,7 +21,7 @@ cdef extern from "flint_wrap.h": # is returned by the function and any coefficients beyond this point are # not touched. - mp_size_t fft_split_bits(mp_limb_t ** poly, mp_srcptr limbs, mp_size_t total_limbs, flint_bitcnt_t bits, mp_size_t output_limbs) + mp_size_t fft_split_bits(mp_limb_t ** poly, mp_srcptr limbs, mp_size_t total_limbs, flint_bitcnt_t bits, mp_size_t output_limbs) noexcept # Split an integer ``(limbs, total_limbs)`` into coefficients of the # given number of ``bits`` and store as the coefficients of ``poly`` # which are assumed to have space for ``output_limbs + 1`` limbs per @@ -30,7 +30,7 @@ cdef extern from "flint_wrap.h": # is returned by the function and any coefficients beyond this point are # not touched. - void fft_combine_limbs(mp_limb_t * res, mp_limb_t ** poly, slong length, mp_size_t coeff_limbs, mp_size_t output_limbs, mp_size_t total_limbs) + void fft_combine_limbs(mp_limb_t * res, mp_limb_t ** poly, slong length, mp_size_t coeff_limbs, mp_size_t output_limbs, mp_size_t total_limbs) noexcept # Evaluate the polynomial ``poly`` of the given ``length`` at # ``B^coeff_limbs``, where ``B = 2^FLINT_BITS``, and add the # result to the integer ``(res, total_limbs)`` throwing away any bits @@ -40,7 +40,7 @@ cdef extern from "flint_wrap.h": # If the integer is initially zero the result will just be the evaluation # of the polynomial. - void fft_combine_bits(mp_limb_t * res, mp_limb_t ** poly, slong length, flint_bitcnt_t bits, mp_size_t output_limbs, mp_size_t total_limbs) + void fft_combine_bits(mp_limb_t * res, mp_limb_t ** poly, slong length, flint_bitcnt_t bits, mp_size_t output_limbs, mp_size_t total_limbs) noexcept # Evaluate the polynomial ``poly`` of the given ``length`` at # ``2^bits`` and add the result to the integer # ``(res, total_limbs)`` throwing away any bits that exceed the given @@ -49,80 +49,80 @@ cdef extern from "flint_wrap.h": # If the integer is initially zero the result will just be the evaluation # of the polynomial. - void fermat_to_mpz(mpz_t m, mp_limb_t * i, mp_size_t limbs) + void fermat_to_mpz(mpz_t m, mp_limb_t * i, mp_size_t limbs) noexcept # Convert the Fermat number ``(i, limbs)`` modulo ``B^limbs + 1`` to # an ``mpz_t m``. Assumes ``m`` has been initialised. This function # is used only in test code. - void mpn_negmod_2expp1(mp_limb_t* z, const mp_limb_t* a, mp_size_t limbs) + void mpn_negmod_2expp1(mp_limb_t* z, const mp_limb_t* a, mp_size_t limbs) noexcept # Set ``z`` to the negation of the Fermat number `a` modulo ``B^limbs + 1``. # The input ``a`` is expected to be fully reduced, and the output is fully reduced. # Aliasing is permitted. - void mpn_addmod_2expp1_1(mp_limb_t * r, mp_size_t limbs, mp_limb_signed_t c) + void mpn_addmod_2expp1_1(mp_limb_t * r, mp_size_t limbs, mp_limb_signed_t c) noexcept # Adds the signed limb ``c`` to the generalised Fermat number ``r`` # modulo ``B^limbs + 1``. The compiler should be able to inline # this for the case that there is no overflow from the first limb. - void mpn_normmod_2expp1(mp_limb_t * t, mp_size_t limbs) + void mpn_normmod_2expp1(mp_limb_t * t, mp_size_t limbs) noexcept # Given ``t`` a signed integer of ``limbs + 1`` limbs in two's # complement format, reduce ``t`` to the corresponding value modulo the # generalised Fermat number ``B^limbs + 1``, where # ``B = 2^FLINT_BITS``. - void mpn_mul_2expmod_2expp1(mp_limb_t * t, mp_limb_t * i1, mp_size_t limbs, flint_bitcnt_t d) + void mpn_mul_2expmod_2expp1(mp_limb_t * t, mp_limb_t * i1, mp_size_t limbs, flint_bitcnt_t d) noexcept # Given ``i1`` a signed integer of ``limbs + 1`` limbs in two's # complement format reduced modulo ``B^limbs + 1`` up to some # overflow, compute ``t = i1*2^d`` modulo `p`. The result will not # necessarily be fully reduced. The number of bits ``d`` must be # nonnegative and less than ``FLINT_BITS``. Aliasing is permitted. - void mpn_div_2expmod_2expp1(mp_limb_t * t, mp_limb_t * i1, mp_size_t limbs, flint_bitcnt_t d) + void mpn_div_2expmod_2expp1(mp_limb_t * t, mp_limb_t * i1, mp_size_t limbs, flint_bitcnt_t d) noexcept # Given ``i1`` a signed integer of ``limbs + 1`` limbs in two's # complement format reduced modulo ``B^limbs + 1`` up to some # overflow, compute ``t = i1/2^d`` modulo `p`. The result will not # necessarily be fully reduced. The number of bits ``d`` must be # nonnegative and less than ``FLINT_BITS``. Aliasing is permitted. - void fft_adjust(mp_limb_t * r, mp_limb_t * i1, mp_size_t i, mp_size_t limbs, flint_bitcnt_t w) + void fft_adjust(mp_limb_t * r, mp_limb_t * i1, mp_size_t i, mp_size_t limbs, flint_bitcnt_t w) noexcept # Set ``r`` to ``i1`` times `z^i` modulo ``B^limbs + 1`` where # `z` corresponds to multiplication by `2^w`. This can be thought of as part # of a butterfly operation. We require `0 \leq i < n` where `nw =` # ``limbs*FLINT_BITS``. Aliasing is not supported. - void fft_adjust_sqrt2(mp_limb_t * r, mp_limb_t * i1, mp_size_t i, mp_size_t limbs, flint_bitcnt_t w, mp_limb_t * temp) + void fft_adjust_sqrt2(mp_limb_t * r, mp_limb_t * i1, mp_size_t i, mp_size_t limbs, flint_bitcnt_t w, mp_limb_t * temp) noexcept # Set ``r`` to ``i1`` times `z^i` modulo ``B^limbs + 1`` where # `z` corresponds to multiplication by `\sqrt{2}^w`. This can be thought of # as part of a butterfly operation. We require `0 \leq i < 2\cdot n` and odd # where `nw =` ``limbs*FLINT_BITS``. - void butterfly_lshB(mp_limb_t * t, mp_limb_t * u, mp_limb_t * i1, mp_limb_t * i2, mp_size_t limbs, mp_size_t x, mp_size_t y) + void butterfly_lshB(mp_limb_t * t, mp_limb_t * u, mp_limb_t * i1, mp_limb_t * i2, mp_size_t limbs, mp_size_t x, mp_size_t y) noexcept # We are given two integers ``i1`` and ``i2`` modulo # ``B^limbs + 1`` which are not necessarily normalised. We compute # ``t = (i1 + i2)*B^x`` and ``u = (i1 - i2)*B^y`` modulo `p`. Aliasing # between inputs and outputs is not permitted. We require ``x`` and # ``y`` to be less than ``limbs`` and nonnegative. - void butterfly_rshB(mp_limb_t * t, mp_limb_t * u, mp_limb_t * i1, mp_limb_t * i2, mp_size_t limbs, mp_size_t x, mp_size_t y) + void butterfly_rshB(mp_limb_t * t, mp_limb_t * u, mp_limb_t * i1, mp_limb_t * i2, mp_size_t limbs, mp_size_t x, mp_size_t y) noexcept # We are given two integers ``i1`` and ``i2`` modulo # ``B^limbs + 1`` which are not necessarily normalised. We compute # ``t = (i1 + i2)/B^x`` and ``u = (i1 - i2)/B^y`` modulo `p`. Aliasing # between inputs and outputs is not permitted. We require ``x`` and # ``y`` to be less than ``limbs`` and nonnegative. - void fft_butterfly(mp_limb_t * s, mp_limb_t * t, mp_limb_t * i1, mp_limb_t * i2, mp_size_t i, mp_size_t limbs, flint_bitcnt_t w) + void fft_butterfly(mp_limb_t * s, mp_limb_t * t, mp_limb_t * i1, mp_limb_t * i2, mp_size_t i, mp_size_t limbs, flint_bitcnt_t w) noexcept # Set ``s = i1 + i2``, ``t = z1^i*(i1 - i2)`` modulo # ``B^limbs + 1`` where ``z1 = exp(Pi*I/n)`` corresponds to # multiplication by `2^w`. Requires `0 \leq i < n` where `nw =` # ``limbs*FLINT_BITS``. - void ifft_butterfly(mp_limb_t * s, mp_limb_t * t, mp_limb_t * i1, mp_limb_t * i2, mp_size_t i, mp_size_t limbs, flint_bitcnt_t w) + void ifft_butterfly(mp_limb_t * s, mp_limb_t * t, mp_limb_t * i1, mp_limb_t * i2, mp_size_t i, mp_size_t limbs, flint_bitcnt_t w) noexcept # Set ``s = i1 + z1^i*i2``, ``t = i1 - z1^i*i2`` modulo # ``B^limbs + 1`` where ``z1 = exp(-Pi*I/n)`` corresponds to # division by `2^w`. Requires `0 \leq i < 2n` where `nw =` # ``limbs*FLINT_BITS``. - void fft_radix2(mp_limb_t ** ii, mp_size_t n, flint_bitcnt_t w, mp_limb_t ** t1, mp_limb_t ** t2) + void fft_radix2(mp_limb_t ** ii, mp_size_t n, flint_bitcnt_t w, mp_limb_t ** t1, mp_limb_t ** t2) noexcept # The radix 2 DIF FFT works as follows: # Input: ``[i0, i1, ..., i(m-1)]``, for `m = 2n` a power of `2`. # Output: ``[r0, r1, ..., r(m-1)]`` ``= FFT[i0, i1, ..., i(m-1)]``. @@ -150,7 +150,7 @@ cdef extern from "flint_wrap.h": # We require `nw` to be at least 64 and the two temporary space pointers to # point to blocks of size ``n*w + FLINT_BITS`` bits. - void fft_truncate(mp_limb_t ** ii, mp_size_t n, flint_bitcnt_t w, mp_limb_t ** t1, mp_limb_t ** t2, mp_size_t trunc) + void fft_truncate(mp_limb_t ** ii, mp_size_t n, flint_bitcnt_t w, mp_limb_t ** t1, mp_limb_t ** t2, mp_size_t trunc) noexcept # As for ``fft_radix2`` except that only the first ``trunc`` # coefficients of the output are computed and the input is regarded as # having (implied) zero coefficients from coefficient ``trunc`` onwards. @@ -158,12 +158,12 @@ cdef extern from "flint_wrap.h": # space, but their value is irrelevant. The value of ``trunc`` must be # divisible by 2. - void fft_truncate1(mp_limb_t ** ii, mp_size_t n, flint_bitcnt_t w, mp_limb_t ** t1, mp_limb_t ** t2, mp_size_t trunc) + void fft_truncate1(mp_limb_t ** ii, mp_size_t n, flint_bitcnt_t w, mp_limb_t ** t1, mp_limb_t ** t2, mp_size_t trunc) noexcept # As for ``fft_radix2`` except that only the first ``trunc`` # coefficients of the output are computed. The transform still needs all # `2n` input coefficients to be specified. - void ifft_radix2(mp_limb_t ** ii, mp_size_t n, flint_bitcnt_t w, mp_limb_t ** t1, mp_limb_t ** t2) + void ifft_radix2(mp_limb_t ** ii, mp_size_t n, flint_bitcnt_t w, mp_limb_t ** t1, mp_limb_t ** t2) noexcept # The radix 2 DIF IFFT works as follows: # Input: ``[i0, i1, ..., i(m-1)]``, for `m = 2n` a power of `2`. # Output: ``[r0, r1, ..., r(m-1)]`` @@ -186,7 +186,7 @@ cdef extern from "flint_wrap.h": # We require `nw` to be at least 64 and the two temporary space pointers # to point to blocks of size ``n*w + FLINT_BITS`` bits. - void ifft_truncate(mp_limb_t ** ii, mp_size_t n, flint_bitcnt_t w, mp_limb_t ** t1, mp_limb_t ** t2, mp_size_t trunc) + void ifft_truncate(mp_limb_t ** ii, mp_size_t n, flint_bitcnt_t w, mp_limb_t ** t1, mp_limb_t ** t2, mp_size_t trunc) noexcept # As for ``ifft_radix2`` except that the output is assumed to have # zeros from coefficient trunc onwards and only the first trunc # coefficients of the input are specified. The remaining coefficients need @@ -206,7 +206,7 @@ cdef extern from "flint_wrap.h": # up to ``trunc`` being careful to note that this involves doubling the # coefficients from ``trunc - n`` up to ``n``. - void ifft_truncate1(mp_limb_t ** ii, mp_size_t n, flint_bitcnt_t w, mp_limb_t ** t1, mp_limb_t ** t2, mp_size_t trunc) + void ifft_truncate1(mp_limb_t ** ii, mp_size_t n, flint_bitcnt_t w, mp_limb_t ** t1, mp_limb_t ** t2, mp_size_t trunc) noexcept # Computes the first ``trunc`` coefficients of the radix 2 inverse # transform assuming the first ``trunc`` coefficients are given and that # the remaining coefficients have been set to the value they would have if @@ -215,7 +215,7 @@ cdef extern from "flint_wrap.h": # coefficients from ``trunc`` onwards after the inverse transform are # not inferred to be zero but the supplied values. - void fft_butterfly_sqrt2(mp_limb_t * s, mp_limb_t * t, mp_limb_t * i1, mp_limb_t * i2, mp_size_t i, mp_size_t limbs, flint_bitcnt_t w, mp_limb_t * temp) + void fft_butterfly_sqrt2(mp_limb_t * s, mp_limb_t * t, mp_limb_t * i1, mp_limb_t * i2, mp_size_t i, mp_size_t limbs, flint_bitcnt_t w, mp_limb_t * temp) noexcept # Let `w = 2k + 1`, `i = 2j + 1`. Set ``s = i1 + i2``, # ``t = z1^i*(i1 - i2)`` modulo ``B^limbs + 1`` where # ``z1^2 = exp(Pi*I/n)`` corresponds to multiplication by `2^w`. Requires @@ -226,7 +226,7 @@ cdef extern from "flint_wrap.h": # We first multiply by ``2^(j + ik + wn/4)`` then multiply by an # additional ``2^(nw/2)`` and subtract. - void ifft_butterfly_sqrt2(mp_limb_t * s, mp_limb_t * t, mp_limb_t * i1, mp_limb_t * i2, mp_size_t i, mp_size_t limbs, flint_bitcnt_t w, mp_limb_t * temp) + void ifft_butterfly_sqrt2(mp_limb_t * s, mp_limb_t * t, mp_limb_t * i1, mp_limb_t * i2, mp_size_t i, mp_size_t limbs, flint_bitcnt_t w, mp_limb_t * temp) noexcept # Let `w = 2k + 1`, `i = 2j + 1`. Set ``s = i1 + z1^i*i2``, # ``t = i1 - z1^i*i2`` modulo ``B^limbs + 1`` where # ``z1^2 = exp(-Pi*I/n)`` corresponds to division by `2^w`. Requires @@ -242,7 +242,7 @@ cdef extern from "flint_wrap.h": # We first multiply by ``2^(2*wn - j - ik - 1 + wn/4)`` then multiply by # an additional ``2^(nw/2)`` and subtract. - void fft_truncate_sqrt2(mp_limb_t ** ii, mp_size_t n, flint_bitcnt_t w, mp_limb_t ** t1, mp_limb_t ** t2, mp_limb_t ** temp, mp_size_t trunc) + void fft_truncate_sqrt2(mp_limb_t ** ii, mp_size_t n, flint_bitcnt_t w, mp_limb_t ** t1, mp_limb_t ** t2, mp_limb_t ** temp, mp_size_t trunc) noexcept # As per ``fft_truncate`` except that the transform is twice the usual # length, i.e. length `4n` rather than `2n`. This is achieved by making use # of twiddles by powers of a square root of 2, not powers of 2 in the first @@ -250,7 +250,7 @@ cdef extern from "flint_wrap.h": # We require `nw` to be at least 64 and the three temporary space pointers # to point to blocks of size ``n*w + FLINT_BITS`` bits. - void ifft_truncate_sqrt2(mp_limb_t ** ii, mp_size_t n, flint_bitcnt_t w, mp_limb_t ** t1, mp_limb_t ** t2, mp_limb_t ** temp, mp_size_t trunc) + void ifft_truncate_sqrt2(mp_limb_t ** ii, mp_size_t n, flint_bitcnt_t w, mp_limb_t ** t1, mp_limb_t ** t2, mp_limb_t ** temp, mp_size_t trunc) noexcept # As per ``ifft_truncate`` except that the transform is twice the usual # length, i.e. length `4n` instead of `2n`. This is achieved by making use # of twiddles by powers of a square root of 2, not powers of 2 in the final @@ -258,7 +258,7 @@ cdef extern from "flint_wrap.h": # We require `nw` to be at least 64 and the three temporary space pointers # to point to blocks of size ``n*w + FLINT_BITS`` bits. - void fft_butterfly_twiddle(mp_limb_t * u, mp_limb_t * v, mp_limb_t * s, mp_limb_t * t, mp_size_t limbs, flint_bitcnt_t b1, flint_bitcnt_t b2) + void fft_butterfly_twiddle(mp_limb_t * u, mp_limb_t * v, mp_limb_t * s, mp_limb_t * t, mp_size_t limbs, flint_bitcnt_t b1, flint_bitcnt_t b2) noexcept # Set ``u = 2^b1*(s + t)``, ``v = 2^b2*(s - t)`` modulo # ``B^limbs + 1``. This is used to compute # ``u = 2^(ws*tw1)*(s + t)``, ``v = 2^(w+ws*tw2)*(s - t)`` in the @@ -266,7 +266,7 @@ cdef extern from "flint_wrap.h": # with additional twiddles by ``z1^rc`` for row `r` and column `c` of the # matrix of coefficients. Aliasing is not allowed. - void ifft_butterfly_twiddle(mp_limb_t * u, mp_limb_t * v, mp_limb_t * s, mp_limb_t * t, mp_size_t limbs, flint_bitcnt_t b1, flint_bitcnt_t b2) + void ifft_butterfly_twiddle(mp_limb_t * u, mp_limb_t * v, mp_limb_t * s, mp_limb_t * t, mp_size_t limbs, flint_bitcnt_t b1, flint_bitcnt_t b2) noexcept # Set ``u = s/2^b1 + t/2^b1)``, ``v = s/2^b1 - t/2^b1`` modulo # ``B^limbs + 1``. This is used to compute # ``u = 2^(-ws*tw1)*s + 2^(-ws*tw2)*t)``, @@ -275,29 +275,29 @@ cdef extern from "flint_wrap.h": # by ``z1^(-rc)`` for row `r` and column `c` of the matrix of # coefficients. Aliasing is not allowed. - void fft_radix2_twiddle(mp_limb_t ** ii, mp_size_t iis, mp_size_t n, flint_bitcnt_t w, mp_limb_t ** t1, mp_limb_t ** t2, mp_size_t ws, mp_size_t r, mp_size_t c, mp_size_t rs) + void fft_radix2_twiddle(mp_limb_t ** ii, mp_size_t iis, mp_size_t n, flint_bitcnt_t w, mp_limb_t ** t1, mp_limb_t ** t2, mp_size_t ws, mp_size_t r, mp_size_t c, mp_size_t rs) noexcept # As for ``fft_radix2`` except that the coefficients are spaced by # ``is`` in the array ``ii`` and an additional twist by ``z^c*i`` # is applied to each coefficient where `i` starts at `r` and increases by # ``rs`` as one moves from one coefficient to the next. Here ``z`` # corresponds to multiplication by ``2^ws``. - void ifft_radix2_twiddle(mp_limb_t ** ii, mp_size_t iis, mp_size_t n, flint_bitcnt_t w, mp_limb_t ** t1, mp_limb_t ** t2, mp_size_t ws, mp_size_t r, mp_size_t c, mp_size_t rs) + void ifft_radix2_twiddle(mp_limb_t ** ii, mp_size_t iis, mp_size_t n, flint_bitcnt_t w, mp_limb_t ** t1, mp_limb_t ** t2, mp_size_t ws, mp_size_t r, mp_size_t c, mp_size_t rs) noexcept # As for ``ifft_radix2`` except that the coefficients are spaced by # ``is`` in the array ``ii`` and an additional twist by # ``z^(-c*i)`` is applied to each coefficient where `i` starts at `r` # and increases by ``rs`` as one moves from one coefficient to the next. # Here ``z`` corresponds to multiplication by ``2^ws``. - void fft_truncate1_twiddle(mp_limb_t ** ii, mp_size_t iis, mp_size_t n, flint_bitcnt_t w, mp_limb_t ** t1, mp_limb_t ** t2, mp_size_t ws, mp_size_t r, mp_size_t c, mp_size_t rs, mp_size_t trunc) + void fft_truncate1_twiddle(mp_limb_t ** ii, mp_size_t iis, mp_size_t n, flint_bitcnt_t w, mp_limb_t ** t1, mp_limb_t ** t2, mp_size_t ws, mp_size_t r, mp_size_t c, mp_size_t rs, mp_size_t trunc) noexcept # As per ``fft_radix2_twiddle`` except that the transform is truncated # as per ``fft_truncate1``. - void ifft_truncate1_twiddle(mp_limb_t ** ii, mp_size_t iis, mp_size_t n, flint_bitcnt_t w, mp_limb_t ** t1, mp_limb_t ** t2, mp_size_t ws, mp_size_t r, mp_size_t c, mp_size_t rs, mp_size_t trunc) + void ifft_truncate1_twiddle(mp_limb_t ** ii, mp_size_t iis, mp_size_t n, flint_bitcnt_t w, mp_limb_t ** t1, mp_limb_t ** t2, mp_size_t ws, mp_size_t r, mp_size_t c, mp_size_t rs, mp_size_t trunc) noexcept # As per ``ifft_radix2_twiddle`` except that the transform is truncated # as per ``ifft_truncate1``. - void fft_mfa_truncate_sqrt2(mp_limb_t ** ii, mp_size_t n, flint_bitcnt_t w, mp_limb_t ** t1, mp_limb_t ** t2, mp_limb_t ** temp, mp_size_t n1, mp_size_t trunc) + void fft_mfa_truncate_sqrt2(mp_limb_t ** ii, mp_size_t n, flint_bitcnt_t w, mp_limb_t ** t1, mp_limb_t ** t2, mp_limb_t ** temp, mp_size_t n1, mp_size_t trunc) noexcept # This is as per the ``fft_truncate_sqrt2`` function except that the # matrix Fourier algorithm is used for the left and right FFTs. The total # transform length is `4n` where ``n = 2^depth`` so that the left and @@ -332,7 +332,7 @@ cdef extern from "flint_wrap.h": # We require `nw` to be at least 64 and the three temporary space pointers # to point to blocks of size ``n*w + FLINT_BITS`` bits. - void ifft_mfa_truncate_sqrt2(mp_limb_t ** ii, mp_size_t n, flint_bitcnt_t w, mp_limb_t ** t1, mp_limb_t ** t2, mp_limb_t ** temp, mp_size_t n1, mp_size_t trunc) + void ifft_mfa_truncate_sqrt2(mp_limb_t ** ii, mp_size_t n, flint_bitcnt_t w, mp_limb_t ** t1, mp_limb_t ** t2, mp_limb_t ** temp, mp_size_t n1, mp_size_t trunc) noexcept # This is as per the ``ifft_truncate_sqrt2`` function except that the # matrix Fourier algorithm is used for the left and right IFFTs. The total # transform length is `4n` where ``n = 2^depth`` so that the left and @@ -346,18 +346,18 @@ cdef extern from "flint_wrap.h": # We require `nw` to be at least 64 and the three temporary space pointers # to point to blocks of size ``n*w + FLINT_BITS`` bits. - void fft_mfa_truncate_sqrt2_outer(mp_limb_t ** ii, mp_size_t n, flint_bitcnt_t w, mp_limb_t ** t1, mp_limb_t ** t2, mp_limb_t ** temp, mp_size_t n1, mp_size_t trunc) + void fft_mfa_truncate_sqrt2_outer(mp_limb_t ** ii, mp_size_t n, flint_bitcnt_t w, mp_limb_t ** t1, mp_limb_t ** t2, mp_limb_t ** temp, mp_size_t n1, mp_size_t trunc) noexcept # Just the outer layers of ``fft_mfa_truncate_sqrt2``. - void fft_mfa_truncate_sqrt2_inner(mp_limb_t ** ii, mp_limb_t ** jj, mp_size_t n, flint_bitcnt_t w, mp_limb_t ** t1, mp_limb_t ** t2, mp_limb_t ** temp, mp_size_t n1, mp_size_t trunc, mp_limb_t ** tt) + void fft_mfa_truncate_sqrt2_inner(mp_limb_t ** ii, mp_limb_t ** jj, mp_size_t n, flint_bitcnt_t w, mp_limb_t ** t1, mp_limb_t ** t2, mp_limb_t ** temp, mp_size_t n1, mp_size_t trunc, mp_limb_t ** tt) noexcept # The inner layers of ``fft_mfa_truncate_sqrt2`` and # ``ifft_mfa_truncate_sqrt2`` combined with pointwise mults. - void ifft_mfa_truncate_sqrt2_outer(mp_limb_t ** ii, mp_size_t n, flint_bitcnt_t w, mp_limb_t ** t1, mp_limb_t ** t2, mp_limb_t ** temp, mp_size_t n1, mp_size_t trunc) + void ifft_mfa_truncate_sqrt2_outer(mp_limb_t ** ii, mp_size_t n, flint_bitcnt_t w, mp_limb_t ** t1, mp_limb_t ** t2, mp_limb_t ** temp, mp_size_t n1, mp_size_t trunc) noexcept # The outer layers of ``ifft_mfa_truncate_sqrt2`` combined with # normalisation. - void fft_negacyclic(mp_limb_t ** ii, mp_size_t n, flint_bitcnt_t w, mp_limb_t ** t1, mp_limb_t ** t2, mp_limb_t ** temp) + void fft_negacyclic(mp_limb_t ** ii, mp_size_t n, flint_bitcnt_t w, mp_limb_t ** t1, mp_limb_t ** t2, mp_limb_t ** temp) noexcept # As per ``fft_radix2`` except that it performs a sqrt2 negacyclic # transform of length `2n`. This is the same as the radix 2 transform # except that the `i`-th coefficient of the input is first multiplied by @@ -365,7 +365,7 @@ cdef extern from "flint_wrap.h": # We require `nw` to be at least 64 and the two temporary space pointers to # point to blocks of size ``n*w + FLINT_BITS`` bits. - void ifft_negacyclic(mp_limb_t ** ii, mp_size_t n, flint_bitcnt_t w, mp_limb_t ** t1, mp_limb_t ** t2, mp_limb_t ** temp) + void ifft_negacyclic(mp_limb_t ** ii, mp_size_t n, flint_bitcnt_t w, mp_limb_t ** t1, mp_limb_t ** t2, mp_limb_t ** temp) noexcept # As per ``ifft_radix2`` except that it performs a sqrt2 negacyclic # inverse transform of length `2n`. This is the same as the radix 2 inverse # transform except that the `i`-th coefficient of the output is finally @@ -373,25 +373,25 @@ cdef extern from "flint_wrap.h": # We require `nw` to be at least 64 and the two temporary space pointers to # point to blocks of size ``n*w + FLINT_BITS`` bits. - void fft_naive_convolution_1(mp_limb_t * r, mp_limb_t * ii, mp_limb_t * jj, mp_size_t m) + void fft_naive_convolution_1(mp_limb_t * r, mp_limb_t * ii, mp_limb_t * jj, mp_size_t m) noexcept # Performs a naive negacyclic convolution of ``ii`` with ``jj``, # both of length `m`, and sets `r` to the result. This is essentially # multiplication of polynomials modulo `x^m + 1`. - void _fft_mulmod_2expp1(mp_limb_t * r1, mp_limb_t * i1, mp_limb_t * i2, mp_size_t r_limbs, flint_bitcnt_t depth, flint_bitcnt_t w) + void _fft_mulmod_2expp1(mp_limb_t * r1, mp_limb_t * i1, mp_limb_t * i2, mp_size_t r_limbs, flint_bitcnt_t depth, flint_bitcnt_t w) noexcept # Multiply ``i1`` by ``i2`` modulo ``B^r_limbs + 1`` where # ``r_limbs = nw/FLINT_BITS`` with ``n = 2^depth``. Uses the # negacyclic FFT convolution CRT'd with a 1 limb naive convolution. We # require that ``depth`` and ``w`` have been selected as per the # wrapper ``fft_mulmod_2expp1`` below. - slong fft_adjust_limbs(mp_size_t limbs) + slong fft_adjust_limbs(mp_size_t limbs) noexcept # Given a number of limbs, returns a new number of limbs (no more than # the next power of 2) which will work with the Nussbaumer code. It is only # necessary to make this adjustment if # ``limbs > FFT_MULMOD_2EXPP1_CUTOFF``. - void fft_mulmod_2expp1(mp_limb_t * r, mp_limb_t * i1, mp_limb_t * i2, mp_size_t n, mp_size_t w, mp_limb_t * tt) + void fft_mulmod_2expp1(mp_limb_t * r, mp_limb_t * i1, mp_limb_t * i2, mp_size_t n, mp_size_t w, mp_limb_t * tt) noexcept # As per ``_fft_mulmod_2expp1`` but with a tuned cutoff below which more # classical methods are used for the convolution. The temporary space is # required to fit ``n*w + FLINT_BITS`` bits. There are no restrictions @@ -399,7 +399,7 @@ cdef extern from "flint_wrap.h": # ``FFT_MULMOD_2EXPP1_CUTOFF`` the function ``fft_adjust_limbs`` must # be called to increase the number of limbs to an appropriate value. - void mul_truncate_sqrt2(mp_ptr r1, mp_srcptr i1, mp_size_t n1, mp_srcptr i2, mp_size_t n2, flint_bitcnt_t depth, flint_bitcnt_t w) + void mul_truncate_sqrt2(mp_ptr r1, mp_srcptr i1, mp_size_t n1, mp_srcptr i2, mp_size_t n2, flint_bitcnt_t depth, flint_bitcnt_t w) noexcept # Integer multiplication using the radix 2 truncated sqrt2 transforms. # Set ``(r1, n1 + n2)`` to the product of ``(i1, n1)`` by # ``(i2, n2)``. This is achieved through an FFT convolution of length at @@ -411,17 +411,17 @@ cdef extern from "flint_wrap.h": # ``j2`` chunks then ``j1 + j2 - 1 <= 2^(depth + 2)``. # If ``n = 2^depth`` then we require `nw` to be at least 64. - void mul_mfa_truncate_sqrt2(mp_ptr r1, mp_srcptr i1, mp_size_t n1, mp_srcptr i2, mp_size_t n2, flint_bitcnt_t depth, flint_bitcnt_t w) + void mul_mfa_truncate_sqrt2(mp_ptr r1, mp_srcptr i1, mp_size_t n1, mp_srcptr i2, mp_size_t n2, flint_bitcnt_t depth, flint_bitcnt_t w) noexcept # As for ``mul_truncate_sqrt2`` except that the cache friendly matrix # Fourier algorithm is used. # If ``n = 2^depth`` then we require `nw` to be at least 64. Here we # also require `w` to be `2^i` for some `i \geq 0`. - void flint_mpn_mul_fft_main(mp_ptr r1, mp_srcptr i1, mp_size_t n1, mp_srcptr i2, mp_size_t n2) + void flint_mpn_mul_fft_main(mp_ptr r1, mp_srcptr i1, mp_size_t n1, mp_srcptr i2, mp_size_t n2) noexcept # The main integer multiplication routine. Sets ``(r1, n1 + n2)`` to # ``(i1, n1)`` times ``(i2, n2)``. We require ``n1 >= n2 > 0``. - void fft_convolution(mp_limb_t ** ii, mp_limb_t ** jj, slong depth, slong limbs, slong trunc, mp_limb_t ** t1, mp_limb_t ** t2, mp_limb_t ** s1, mp_limb_t ** tt) + void fft_convolution(mp_limb_t ** ii, mp_limb_t ** jj, slong depth, slong limbs, slong trunc, mp_limb_t ** t1, mp_limb_t ** t2, mp_limb_t ** s1, mp_limb_t ** tt) noexcept # Perform an FFT convolution of ``ii`` with ``jj``, both of length # ``4*n`` where ``n = 2^depth``. Assume that all but the first # ``trunc`` coefficients of the output (placed in ``ii``) are zero. @@ -430,11 +430,11 @@ cdef extern from "flint_wrap.h": # limbs of space and ``tt`` must have ``2*(limbs + 1)`` of free # space. - void fft_precache(mp_limb_t ** jj, slong depth, slong limbs, slong trunc, mp_limb_t ** t1, mp_limb_t ** t2, mp_limb_t ** s1) + void fft_precache(mp_limb_t ** jj, slong depth, slong limbs, slong trunc, mp_limb_t ** t1, mp_limb_t ** t2, mp_limb_t ** s1) noexcept # Precompute the FFT of ``jj`` for use with precache functions. The # parameters are as for ``fft_convolution``. - void fft_convolution_precache(mp_limb_t ** ii, mp_limb_t ** jj, slong depth, slong limbs, slong trunc, mp_limb_t ** t1, mp_limb_t ** t2, mp_limb_t ** s1, mp_limb_t ** tt) + void fft_convolution_precache(mp_limb_t ** ii, mp_limb_t ** jj, slong depth, slong limbs, slong trunc, mp_limb_t ** t1, mp_limb_t ** t2, mp_limb_t ** s1, mp_limb_t ** tt) noexcept # As per ``fft_convolution`` except that it is assumed ``fft_precache`` has # been called on ``jj`` with the same parameters. This will then run faster # than if ``fft_convolution`` had been run with the original ``jj``. diff --git a/src/sage/libs/flint/flint.pxd b/src/sage/libs/flint/flint.pxd index e6be37bf54c..7794cbbf28e 100644 --- a/src/sage/libs/flint/flint.pxd +++ b/src/sage/libs/flint/flint.pxd @@ -12,33 +12,33 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - mp_limb_t FLINT_BIT_COUNT(mp_limb_t x) + mp_limb_t FLINT_BIT_COUNT(mp_limb_t x) noexcept # Returns the number of binary bits required to represent an ``ulong x``. If # `x` is zero, returns `0`. - void * flint_malloc(size_t size) + void * flint_malloc(size_t size) noexcept - void * flint_realloc(void * ptr, size_t size) + void * flint_realloc(void * ptr, size_t size) noexcept - void * flint_calloc(size_t num, size_t size) + void * flint_calloc(size_t num, size_t size) noexcept - void flint_free(void * ptr) + void flint_free(void * ptr) noexcept - flint_rand_s * flint_rand_alloc() + flint_rand_s * flint_rand_alloc() noexcept # Allocates a ``flint_rand_t`` object to be used like a heap-allocated # ``flint_rand_t`` in external libraries. # The random state is not initialised. - void flint_rand_free(flint_rand_s * state) + void flint_rand_free(flint_rand_s * state) noexcept # Frees a random state object as allocated using :func:`flint_rand_alloc`. - void flint_randinit(flint_rand_t state) + void flint_randinit(flint_rand_t state) noexcept # Initialize a :type:`flint_rand_t`. - void flint_randclear(flint_rand_t state) + void flint_randclear(flint_rand_t state) noexcept # Free all memory allocated by :func:`flint_rand_init`. - void flint_set_num_threads(int num_threads) + void flint_set_num_threads(int num_threads) noexcept # Set up a thread pool of ``num_threads - 1`` worker threads (in addition # to the master thread) and set the maximum number of worker threads the # master thread can start to ``num_threads - 1``. @@ -48,7 +48,7 @@ cdef extern from "flint_wrap.h": # woken but not given back). The function cannot be called from inside # worker threads. - int flint_get_num_threads() + int flint_get_num_threads() noexcept # When called at the global level, this function returns one more than the # number of worker threads in the Flint thread pool, i.e. it returns the # number of workers in the thread pool plus one for the master thread. @@ -57,7 +57,7 @@ cdef extern from "flint_wrap.h": # Use :func:`thread_pool_wake` to set this number for a given worker thread. # See also: :func:`flint_get_num_available_threads`. - int flint_set_num_workers(int num_workers) + int flint_set_num_workers(int num_workers) noexcept # Restricts the number of worker threads that can be started by the current # thread to ``num_workers``. This function can be called from any thread. # Assumes that the Flint thread pool is already set up. @@ -73,23 +73,23 @@ cdef extern from "flint_wrap.h": # a function that one wishes to call from a thread, and cheaply restore the # number of workers to its original value before exiting the current thread. - void flint_reset_num_workers(int num_workers) + void flint_reset_num_workers(int num_workers) noexcept # After a call to :func:`flint_set_num_workers` this function must be called to # set the number of workers that may be started by the current thread back to # its original value. - int flint_printf(const char * str, ...) - int flint_fprintf(FILE * f, const char * str, ...) - int flint_sprintf(char * s, const char * str, ...) + int flint_printf(const char * str, ...) noexcept + int flint_fprintf(FILE * f, const char * str, ...) noexcept + int flint_sprintf(char * s, const char * str, ...) noexcept # These are equivalent to the standard library functions ``printf``, # ``vprintf``, ``fprintf``, and ``sprintf`` with an additional length modifier # "w" for use with an :type:`mp_limb_t` type. This modifier can be used with # format specifiers "d", "x", or "u", thereby outputting the limb as a signed # decimal, hexadecimal, or unsigned decimal integer. - int flint_scanf(const char * str, ...) - int flint_fscanf(FILE * f, const char * str, ...) - int flint_sscanf(const char * s, const char * str, ...) + int flint_scanf(const char * str, ...) noexcept + int flint_fscanf(FILE * f, const char * str, ...) noexcept + int flint_sscanf(const char * s, const char * str, ...) noexcept # These are equivalent to the standard library functions ``scanf``, # ``fscanf``, and ``sscanf`` with an additional length modifier "w" for # reading an :type:`mp_limb_t` type. diff --git a/src/sage/libs/flint/fmpq.pxd b/src/sage/libs/flint/fmpq.pxd index 811287875c3..89dd1058362 100644 --- a/src/sage/libs/flint/fmpq.pxd +++ b/src/sage/libs/flint/fmpq.pxd @@ -12,140 +12,140 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - fmpz * fmpq_numref(const fmpq_t x) - fmpz * fmpq_denref(const fmpq_t x) + fmpz * fmpq_numref(const fmpq_t x) noexcept + fmpz * fmpq_denref(const fmpq_t x) noexcept # Returns respectively a pointer to the numerator and denominator of x. - void fmpq_init(fmpq_t x) + void fmpq_init(fmpq_t x) noexcept # Initialises the ``fmpq_t`` variable ``x`` for use. Its value # is set to 0. - void fmpq_clear(fmpq_t x) + void fmpq_clear(fmpq_t x) noexcept # Clears the ``fmpq_t`` variable ``x``. To use the variable again, # it must be re-initialised with ``fmpq_init``. - void fmpq_canonicalise(fmpq_t res) + void fmpq_canonicalise(fmpq_t res) noexcept # Puts ``res`` in canonical form: the numerator and denominator are # reduced to lowest terms, and the denominator is made positive. # If the numerator is zero, the denominator is set to one. # If the denominator is zero, the outcome of calling this function is # undefined, regardless of the value of the numerator. - void _fmpq_canonicalise(fmpz_t num, fmpz_t den) + void _fmpq_canonicalise(fmpz_t num, fmpz_t den) noexcept # Does the same thing as ``fmpq_canonicalise``, but for numerator # and denominator given explicitly as ``fmpz_t`` variables. Aliasing # of ``num`` and ``den`` is not allowed. - bint fmpq_is_canonical(const fmpq_t x) + bint fmpq_is_canonical(const fmpq_t x) noexcept # Returns nonzero if ``fmpq_t`` x is in canonical form # (as produced by ``fmpq_canonicalise``), and zero otherwise. - bint _fmpq_is_canonical(const fmpz_t num, const fmpz_t den) + bint _fmpq_is_canonical(const fmpz_t num, const fmpz_t den) noexcept # Does the same thing as ``fmpq_is_canonical``, but for numerator # and denominator given explicitly as ``fmpz_t`` variables. - void fmpq_set(fmpq_t dest, const fmpq_t src) + void fmpq_set(fmpq_t dest, const fmpq_t src) noexcept # Sets ``dest`` to a copy of ``src``. No canonicalisation # is performed. - void fmpq_swap(fmpq_t op1, fmpq_t op2) + void fmpq_swap(fmpq_t op1, fmpq_t op2) noexcept # Swaps the two rational numbers ``op1`` and ``op2``. - void fmpq_neg(fmpq_t dest, const fmpq_t src) + void fmpq_neg(fmpq_t dest, const fmpq_t src) noexcept # Sets ``dest`` to the additive inverse of ``src``. - void fmpq_abs(fmpq_t dest, const fmpq_t src) + void fmpq_abs(fmpq_t dest, const fmpq_t src) noexcept # Sets ``dest`` to the absolute value of ``src``. - void fmpq_zero(fmpq_t res) + void fmpq_zero(fmpq_t res) noexcept # Sets the value of ``res`` to 0. - void fmpq_one(fmpq_t res) + void fmpq_one(fmpq_t res) noexcept # Sets the value of ``res`` to `1`. - bint fmpq_is_zero(const fmpq_t res) + bint fmpq_is_zero(const fmpq_t res) noexcept # Returns nonzero if ``res`` has value 0, and returns zero otherwise. - bint fmpq_is_one(const fmpq_t res) + bint fmpq_is_one(const fmpq_t res) noexcept # Returns nonzero if ``res`` has value `1`, and returns zero otherwise. - bint fmpq_is_pm1(const fmpq_t res) + bint fmpq_is_pm1(const fmpq_t res) noexcept # Returns nonzero if ``res`` has value `\pm{1}` and zero otherwise. - bint fmpq_equal(const fmpq_t x, const fmpq_t y) + bint fmpq_equal(const fmpq_t x, const fmpq_t y) noexcept # Returns nonzero if ``x`` and ``y`` are equal, and zero otherwise. # Assumes that ``x`` and ``y`` are both in canonical form. - int fmpq_sgn(const fmpq_t x) + int fmpq_sgn(const fmpq_t x) noexcept # Returns the sign of the rational number `x`. - int fmpq_cmp(const fmpq_t x, const fmpq_t y) - int fmpq_cmp_fmpz(const fmpq_t x, const fmpz_t y) - int fmpq_cmp_ui(const fmpq_t x, ulong y) + int fmpq_cmp(const fmpq_t x, const fmpq_t y) noexcept + int fmpq_cmp_fmpz(const fmpq_t x, const fmpz_t y) noexcept + int fmpq_cmp_ui(const fmpq_t x, ulong y) noexcept # Returns negative if `x < y`, zero if `x = y`, and positive if `x > y`. - int fmpq_cmp_si(const fmpq_t x, slong y) + int fmpq_cmp_si(const fmpq_t x, slong y) noexcept # Returns negative if `x < y`, zero if `x = y`, and positive if `x > y`. - bint fmpq_equal_ui(fmpq_t x, ulong y) + bint fmpq_equal_ui(fmpq_t x, ulong y) noexcept # Returns `1` if `x = y`, otherwise returns `0`. - bint fmpq_equal_si(fmpq_t x, slong y) + bint fmpq_equal_si(fmpq_t x, slong y) noexcept # Returns `1` if `x = y`, otherwise returns `0`. - void fmpq_height(fmpz_t height, const fmpq_t x) + void fmpq_height(fmpz_t height, const fmpq_t x) noexcept # Sets ``height`` to the height of `x`, defined as the larger of # the absolute values of the numerator and denominator of `x`. - flint_bitcnt_t fmpq_height_bits(const fmpq_t x) + flint_bitcnt_t fmpq_height_bits(const fmpq_t x) noexcept # Returns the number of bits in the height of `x`. - void fmpq_set_fmpz_frac(fmpq_t res, const fmpz_t p, const fmpz_t q) + void fmpq_set_fmpz_frac(fmpq_t res, const fmpz_t p, const fmpz_t q) noexcept # Sets ``res`` to the canonical form of the fraction ``p / q``. # This is equivalent to assigning the numerator and denominator # separately and calling ``fmpq_canonicalise``. - void fmpq_get_mpz_frac(mpz_t a, mpz_t b, fmpq_t c) + void fmpq_get_mpz_frac(mpz_t a, mpz_t b, fmpq_t c) noexcept # Sets ``a``, ``b`` to the numerator and denominator of ``c`` # respectively. - void fmpq_set_si(fmpq_t res, slong p, ulong q) + void fmpq_set_si(fmpq_t res, slong p, ulong q) noexcept # Sets ``res`` to the canonical form of the fraction ``p / q``. - void _fmpq_set_si(fmpz_t rnum, fmpz_t rden, slong p, ulong q) + void _fmpq_set_si(fmpz_t rnum, fmpz_t rden, slong p, ulong q) noexcept # Sets ``(rnum, rden)`` to the canonical form of the fraction # ``p / q``. ``rnum`` and ``rden`` may not be aliased. - void fmpq_set_ui(fmpq_t res, ulong p, ulong q) + void fmpq_set_ui(fmpq_t res, ulong p, ulong q) noexcept # Sets ``res`` to the canonical form of the fraction ``p / q``. - void _fmpq_set_ui(fmpz_t rnum, fmpz_t rden, ulong p, ulong q) + void _fmpq_set_ui(fmpz_t rnum, fmpz_t rden, ulong p, ulong q) noexcept # Sets ``(rnum, rden)`` to the canonical form of the fraction # ``p / q``. ``rnum`` and ``rden`` may not be aliased. - void fmpq_set_mpq(fmpq_t dest, const mpq_t src) + void fmpq_set_mpq(fmpq_t dest, const mpq_t src) noexcept # Sets the value of ``dest`` to that of the ``mpq_t`` variable # ``src``. - int fmpq_set_str(fmpq_t dest, const char * s, int base) + int fmpq_set_str(fmpq_t dest, const char * s, int base) noexcept # Sets the value of ``dest`` to the value represented in the string # ``s`` in base ``base``. # Returns 0 if no error occurs. Otherwise returns -1 and ``dest`` is # set to zero. - void fmpq_init_set_mpz_frac_readonly(fmpq_t z, const mpz_t p, const mpz_t q) + void fmpq_init_set_mpz_frac_readonly(fmpq_t z, const mpz_t p, const mpz_t q) noexcept # Assuming ``z`` is an ``fmpz_t`` which will not be cleaned up, # this temporarily copies ``p`` and ``q`` into the numerator and # denominator of ``z`` for read only operations only. The user must not # run ``fmpq_clear`` on ``z``. - double fmpq_get_d(const fmpq_t f) + double fmpq_get_d(const fmpq_t f) noexcept # Returns `f` as a ``double``, rounding towards zero if ``f`` cannot be represented exactly. The return is system dependent if ``f`` is too large or too small to fit in a ``double``. - void fmpq_get_mpq(mpq_t dest, const fmpq_t src) + void fmpq_get_mpq(mpq_t dest, const fmpq_t src) noexcept # Sets the value of ``dest`` - int fmpq_get_mpfr(mpfr_t dest, const fmpq_t src, mpfr_rnd_t rnd) + int fmpq_get_mpfr(mpfr_t dest, const fmpq_t src, mpfr_rnd_t rnd) noexcept # Sets the MPFR variable ``dest`` to the value of ``src``, # rounded to the nearest representable binary floating-point value # in direction ``rnd``. Returns the sign of the rounding, @@ -153,15 +153,15 @@ cdef extern from "flint_wrap.h": # **Note:** Requires that ``mpfr.h`` has been included before any FLINT # header is included. - char * _fmpq_get_str(char * str, int b, const fmpz_t num, const fmpz_t den) - char * fmpq_get_str(char * str, int b, const fmpq_t x) + char * _fmpq_get_str(char * str, int b, const fmpz_t num, const fmpz_t den) noexcept + char * fmpq_get_str(char * str, int b, const fmpq_t x) noexcept # Prints the string representation of `x` in base `b \in [2, 36]` # to a suitable buffer. # If ``str`` is not ``NULL``, this is used as the buffer and # also the return value. If ``str`` is ``NULL``, allocates # sufficient space and returns a pointer to the string. - void flint_mpq_init_set_readonly(mpq_t z, const fmpq_t f) + void flint_mpq_init_set_readonly(mpq_t z, const fmpq_t f) noexcept # Sets the uninitialised ``mpq_t`` `z` to the value of the # readonly ``fmpq_t`` `f`. # Note that it is assumed that `f` does not change during @@ -180,10 +180,10 @@ cdef extern from "flint_wrap.h": # This provides a convenient function for user code, only # requiring to work with the types ``fmpq_t`` and ``mpq_t``. - void flint_mpq_clear_readonly(mpq_t z) + void flint_mpq_clear_readonly(mpq_t z) noexcept # Clears the readonly ``mpq_t`` `z`. - void fmpq_init_set_readonly(fmpq_t f, const mpq_t z) + void fmpq_init_set_readonly(fmpq_t f, const mpq_t z) noexcept # Sets the uninitialised ``fmpq_t`` `f` to a readonly # version of the rational `z`. # Note that the value of `z` is assumed to remain constant @@ -200,150 +200,150 @@ cdef extern from "flint_wrap.h": # fmpq_clear_readonly(f); # } - void fmpq_clear_readonly(fmpq_t f) + void fmpq_clear_readonly(fmpq_t f) noexcept # Clears the readonly ``fmpq_t`` `f`. - int fmpq_fprint(FILE * file, const fmpq_t x) + int fmpq_fprint(FILE * file, const fmpq_t x) noexcept # Prints ``x`` as a fraction to the stream ``file``. # The numerator and denominator are printed verbatim as integers, # with a forward slash (/) printed in between. # In case of success, returns a positive number. In case of failure, # returns a non-positive number. - int _fmpq_fprint(FILE * file, const fmpz_t num, const fmpz_t den) + int _fmpq_fprint(FILE * file, const fmpz_t num, const fmpz_t den) noexcept # Does the same thing as ``fmpq_fprint``, but for numerator # and denominator given explicitly as ``fmpz_t`` variables. # In case of success, returns a positive number. In case of failure, # returns a non-positive number. - int fmpq_print(const fmpq_t x) + int fmpq_print(const fmpq_t x) noexcept # Prints ``x`` as a fraction. The numerator and denominator are # printed verbatim as integers, with a forward slash (/) printed in # between. # In case of success, returns a positive number. In case of failure, # returns a non-positive number. - int _fmpq_print(const fmpz_t num, const fmpz_t den) + int _fmpq_print(const fmpz_t num, const fmpz_t den) noexcept # Does the same thing as ``fmpq_print``, but for numerator # and denominator given explicitly as ``fmpz_t`` variables. # In case of success, returns a positive number. In case of failure, # returns a non-positive number. - void fmpq_randtest(fmpq_t res, flint_rand_t state, flint_bitcnt_t bits) + void fmpq_randtest(fmpq_t res, flint_rand_t state, flint_bitcnt_t bits) noexcept # Sets ``res`` to a random value, with numerator and denominator # having up to ``bits`` bits. The fraction will be in canonical # form. This function has an increased probability of generating # special values which are likely to trigger corner cases. - void _fmpq_randtest(fmpz_t num, fmpz_t den, flint_rand_t state, flint_bitcnt_t bits) + void _fmpq_randtest(fmpz_t num, fmpz_t den, flint_rand_t state, flint_bitcnt_t bits) noexcept # Does the same thing as ``fmpq_randtest``, but for numerator # and denominator given explicitly as ``fmpz_t`` variables. Aliasing # of ``num`` and ``den`` is not allowed. - void fmpq_randtest_not_zero(fmpq_t res, flint_rand_t state, flint_bitcnt_t bits) + void fmpq_randtest_not_zero(fmpq_t res, flint_rand_t state, flint_bitcnt_t bits) noexcept # As per ``fmpq_randtest``, but the result will not be `0`. # If ``bits`` is set to `0`, an exception will result. - void fmpq_randbits(fmpq_t res, flint_rand_t state, flint_bitcnt_t bits) + void fmpq_randbits(fmpq_t res, flint_rand_t state, flint_bitcnt_t bits) noexcept # Sets ``res`` to a random value, with numerator and denominator # both having exactly ``bits`` bits before canonicalisation, # and then puts ``res`` in canonical form. Note that as a result # of the canonicalisation, the resulting numerator and denominator can # be slightly smaller than ``bits`` bits. - void _fmpq_randbits(fmpz_t num, fmpz_t den, flint_rand_t state, flint_bitcnt_t bits) + void _fmpq_randbits(fmpz_t num, fmpz_t den, flint_rand_t state, flint_bitcnt_t bits) noexcept # Does the same thing as ``fmpq_randbits``, but for numerator # and denominator given explicitly as ``fmpz_t`` variables. Aliasing # of ``num`` and ``den`` is not allowed. - void fmpq_add(fmpq_t res, const fmpq_t op1, const fmpq_t op2) - void fmpq_sub(fmpq_t res, const fmpq_t op1, const fmpq_t op2) - void fmpq_mul(fmpq_t res, const fmpq_t op1, const fmpq_t op2) - void fmpq_div(fmpq_t res, const fmpq_t op1, const fmpq_t op2) + void fmpq_add(fmpq_t res, const fmpq_t op1, const fmpq_t op2) noexcept + void fmpq_sub(fmpq_t res, const fmpq_t op1, const fmpq_t op2) noexcept + void fmpq_mul(fmpq_t res, const fmpq_t op1, const fmpq_t op2) noexcept + void fmpq_div(fmpq_t res, const fmpq_t op1, const fmpq_t op2) noexcept # Sets ``res`` respectively to ``op1 + op2``, ``op1 - op2``, # ``op1 * op2``, or ``op1 / op2``. Assumes that the inputs # are in canonical form, and produces output in canonical form. # Division by zero results in an error. # Aliasing between any combination of the variables is allowed. - void _fmpq_add(fmpz_t rnum, fmpz_t rden, const fmpz_t op1num, const fmpz_t op1den, const fmpz_t op2num, const fmpz_t op2den) - void _fmpq_sub(fmpz_t rnum, fmpz_t rden, const fmpz_t op1num, const fmpz_t op1den, const fmpz_t op2num, const fmpz_t op2den) - void _fmpq_mul(fmpz_t rnum, fmpz_t rden, const fmpz_t op1num, const fmpz_t op1den, const fmpz_t op2num, const fmpz_t op2den) - void _fmpq_div(fmpz_t rnum, fmpz_t rden, const fmpz_t op1num, const fmpz_t op1den, const fmpz_t op2num, const fmpz_t op2den) + void _fmpq_add(fmpz_t rnum, fmpz_t rden, const fmpz_t op1num, const fmpz_t op1den, const fmpz_t op2num, const fmpz_t op2den) noexcept + void _fmpq_sub(fmpz_t rnum, fmpz_t rden, const fmpz_t op1num, const fmpz_t op1den, const fmpz_t op2num, const fmpz_t op2den) noexcept + void _fmpq_mul(fmpz_t rnum, fmpz_t rden, const fmpz_t op1num, const fmpz_t op1den, const fmpz_t op2num, const fmpz_t op2den) noexcept + void _fmpq_div(fmpz_t rnum, fmpz_t rden, const fmpz_t op1num, const fmpz_t op1den, const fmpz_t op2num, const fmpz_t op2den) noexcept # Sets ``(rnum, rden)`` to the canonical form of the sum, # difference, product or quotient respectively of the fractions # represented by ``(op1num, op1den)`` and ``(op2num, op2den)``. # Aliasing between any combination of the variables is allowed, # whilst no numerator is aliased with a denominator. - void _fmpq_add_si(fmpz_t rnum, fmpz_t rden, const fmpz_t p, const fmpz_t q, slong r) - void _fmpq_sub_si(fmpz_t rnum, fmpz_t rden, const fmpz_t p, const fmpz_t q, slong r) - void _fmpq_add_ui(fmpz_t rnum, fmpz_t rden, const fmpz_t p, const fmpz_t q, ulong r) - void _fmpq_sub_ui(fmpz_t rnum, fmpz_t rden, const fmpz_t p, const fmpz_t q, ulong r) - void _fmpq_add_fmpz(fmpz_t rnum, fmpz_t rden, const fmpz_t p, const fmpz_t q, const fmpz_t r) - void _fmpq_sub_fmpz(fmpz_t rnum, fmpz_t rden, const fmpz_t p, const fmpz_t q, const fmpz_t r) + void _fmpq_add_si(fmpz_t rnum, fmpz_t rden, const fmpz_t p, const fmpz_t q, slong r) noexcept + void _fmpq_sub_si(fmpz_t rnum, fmpz_t rden, const fmpz_t p, const fmpz_t q, slong r) noexcept + void _fmpq_add_ui(fmpz_t rnum, fmpz_t rden, const fmpz_t p, const fmpz_t q, ulong r) noexcept + void _fmpq_sub_ui(fmpz_t rnum, fmpz_t rden, const fmpz_t p, const fmpz_t q, ulong r) noexcept + void _fmpq_add_fmpz(fmpz_t rnum, fmpz_t rden, const fmpz_t p, const fmpz_t q, const fmpz_t r) noexcept + void _fmpq_sub_fmpz(fmpz_t rnum, fmpz_t rden, const fmpz_t p, const fmpz_t q, const fmpz_t r) noexcept # Sets ``(rnum, rden)`` to the canonical form of the sum or difference # respectively of the fractions represented by ``(p, q)`` and # ``(r, 1)``. Numerators may not be aliased with denominators. - void fmpq_add_si(fmpq_t res, const fmpq_t op1, slong c) - void fmpq_sub_si(fmpq_t res, const fmpq_t op1, slong c) - void fmpq_add_ui(fmpq_t res, const fmpq_t op1, ulong c) - void fmpq_sub_ui(fmpq_t res, const fmpq_t op1, ulong c) - void fmpq_add_fmpz(fmpq_t res, const fmpq_t op1, const fmpz_t c) - void fmpq_sub_fmpz(fmpq_t res, const fmpq_t op1, const fmpz_t c) + void fmpq_add_si(fmpq_t res, const fmpq_t op1, slong c) noexcept + void fmpq_sub_si(fmpq_t res, const fmpq_t op1, slong c) noexcept + void fmpq_add_ui(fmpq_t res, const fmpq_t op1, ulong c) noexcept + void fmpq_sub_ui(fmpq_t res, const fmpq_t op1, ulong c) noexcept + void fmpq_add_fmpz(fmpq_t res, const fmpq_t op1, const fmpz_t c) noexcept + void fmpq_sub_fmpz(fmpq_t res, const fmpq_t op1, const fmpz_t c) noexcept - void _fmpq_mul_si(fmpz_t rnum, fmpz_t rden, const fmpz_t p, const fmpz_t q, slong r) + void _fmpq_mul_si(fmpz_t rnum, fmpz_t rden, const fmpz_t p, const fmpz_t q, slong r) noexcept - void fmpq_mul_si(fmpq_t res, const fmpq_t op1, slong c) + void fmpq_mul_si(fmpq_t res, const fmpq_t op1, slong c) noexcept - void _fmpq_mul_ui(fmpz_t rnum, fmpz_t rden, const fmpz_t p, const fmpz_t q, ulong r) + void _fmpq_mul_ui(fmpz_t rnum, fmpz_t rden, const fmpz_t p, const fmpz_t q, ulong r) noexcept - void fmpq_mul_ui(fmpq_t res, const fmpq_t op1, ulong c) + void fmpq_mul_ui(fmpq_t res, const fmpq_t op1, ulong c) noexcept - void fmpq_addmul(fmpq_t res, const fmpq_t op1, const fmpq_t op2) - void fmpq_submul(fmpq_t res, const fmpq_t op1, const fmpq_t op2) + void fmpq_addmul(fmpq_t res, const fmpq_t op1, const fmpq_t op2) noexcept + void fmpq_submul(fmpq_t res, const fmpq_t op1, const fmpq_t op2) noexcept # Sets ``res`` to ``res + op1 * op2`` or ``res - op1 * op2`` # respectively, placing the result in canonical form. Aliasing # between any combination of the variables is allowed. - void _fmpq_addmul(fmpz_t rnum, fmpz_t rden, const fmpz_t op1num, const fmpz_t op1den, const fmpz_t op2num, const fmpz_t op2den) - void _fmpq_submul(fmpz_t rnum, fmpz_t rden, const fmpz_t op1num, const fmpz_t op1den, const fmpz_t op2num, const fmpz_t op2den) + void _fmpq_addmul(fmpz_t rnum, fmpz_t rden, const fmpz_t op1num, const fmpz_t op1den, const fmpz_t op2num, const fmpz_t op2den) noexcept + void _fmpq_submul(fmpz_t rnum, fmpz_t rden, const fmpz_t op1num, const fmpz_t op1den, const fmpz_t op2num, const fmpz_t op2den) noexcept # Sets ``(rnum, rden)`` to the canonical form of the fraction # ``(rnum, rden)`` + ``(op1num, op1den)`` * ``(op2num, op2den)`` or # ``(rnum, rden)`` - ``(op1num, op1den)`` * ``(op2num, op2den)`` # respectively. Aliasing between any combination of the variables is allowed, # whilst no numerator is aliased with a denominator. - void fmpq_inv(fmpq_t dest, const fmpq_t src) + void fmpq_inv(fmpq_t dest, const fmpq_t src) noexcept # Sets ``dest`` to ``1 / src``. The result is placed in canonical # form, assuming that ``src`` is already in canonical form. - void _fmpq_pow_si(fmpz_t rnum, fmpz_t rden, const fmpz_t opnum, const fmpz_t opden, slong e) - void fmpq_pow_si(fmpq_t res, const fmpq_t op, slong e) + void _fmpq_pow_si(fmpz_t rnum, fmpz_t rden, const fmpz_t opnum, const fmpz_t opden, slong e) noexcept + void fmpq_pow_si(fmpq_t res, const fmpq_t op, slong e) noexcept # Sets ``res`` to ``op`` raised to the power `e`, where `e` # is a ``slong``. If `e` is `0` and ``op`` is `0`, then # ``res`` will be set to `1`. - int fmpq_pow_fmpz(fmpq_t a, const fmpq_t b, const fmpz_t e) + int fmpq_pow_fmpz(fmpq_t a, const fmpq_t b, const fmpz_t e) noexcept # Set ``res`` to ``op`` raised to the power `e`. # Return `1` for success and `0` for failure. - void fmpq_mul_fmpz(fmpq_t res, const fmpq_t op, const fmpz_t x) + void fmpq_mul_fmpz(fmpq_t res, const fmpq_t op, const fmpz_t x) noexcept # Sets ``res`` to the product of the rational number ``op`` # and the integer ``x``. - void fmpq_div_fmpz(fmpq_t res, const fmpq_t op, const fmpz_t x) + void fmpq_div_fmpz(fmpq_t res, const fmpq_t op, const fmpz_t x) noexcept # Sets ``res`` to the quotient of the rational number ``op`` # and the integer ``x``. - void fmpq_mul_2exp(fmpq_t res, const fmpq_t x, flint_bitcnt_t exp) + void fmpq_mul_2exp(fmpq_t res, const fmpq_t x, flint_bitcnt_t exp) noexcept # Sets ``res`` to ``x`` multiplied by ``2^exp``. - void fmpq_div_2exp(fmpq_t res, const fmpq_t x, flint_bitcnt_t exp) + void fmpq_div_2exp(fmpq_t res, const fmpq_t x, flint_bitcnt_t exp) noexcept # Sets ``res`` to ``x`` divided by ``2^exp``. - void _fmpq_gcd(fmpz_t rnum, fmpz_t rden, const fmpz_t p, const fmpz_t q, const fmpz_t r, const fmpz_t s) + void _fmpq_gcd(fmpz_t rnum, fmpz_t rden, const fmpz_t p, const fmpz_t q, const fmpz_t r, const fmpz_t s) noexcept # Set ``(rnum, rden)`` to the gcd of ``(p, q)`` and ``(r, s)`` # which we define to be the canonicalisation of `\operatorname{gcd}(ps, qr)/(qs)`. # (This is apparently Euclid's original definition and is stable under scaling of @@ -351,36 +351,36 @@ cdef extern from "flint_wrap.h": # Note that it does not agree with gcd as defined in ``fmpq_poly``.) # This definition agrees with the result as output by Sage and Pari/GP. - void fmpq_gcd(fmpq_t res, const fmpq_t op1, const fmpq_t op2) + void fmpq_gcd(fmpq_t res, const fmpq_t op1, const fmpq_t op2) noexcept # Set ``res`` to the gcd of ``op1`` and ``op2``. See the low # level function ``_fmpq_gcd`` for our definition of gcd. - void _fmpq_gcd_cofactors(fmpz_t gnum, fmpz_t gden, fmpz_t abar, fmpz_t bbar, const fmpz_t anum, const fmpz_t aden, const fmpz_t bnum, const fmpz_t bden) - void fmpq_gcd_cofactors(fmpq_t g, fmpz_t abar, fmpz_t bbar, const fmpq_t a, const fmpq_t b) + void _fmpq_gcd_cofactors(fmpz_t gnum, fmpz_t gden, fmpz_t abar, fmpz_t bbar, const fmpz_t anum, const fmpz_t aden, const fmpz_t bnum, const fmpz_t bden) noexcept + void fmpq_gcd_cofactors(fmpq_t g, fmpz_t abar, fmpz_t bbar, const fmpq_t a, const fmpq_t b) noexcept # Set `g` to `\operatorname{gcd}(a,b)` as per :func:`fmpq_gcd` and also compute `\overline{a} = a/g` and `\overline{b} = b/g`. # Unlike :func:`fmpq_gcd`, this function requires canonical inputs. - void _fmpq_add_small(fmpz_t rnum, fmpz_t rden, slong p1, ulong q1, slong p2, ulong q2) + void _fmpq_add_small(fmpz_t rnum, fmpz_t rden, slong p1, ulong q1, slong p2, ulong q2) noexcept # Sets ``(rnum, rden)`` to the sum of ``(p1, q1)`` and ``(p2, q2)``. # Assumes that ``(p1, q1)`` and ``(p2, q2)`` are in canonical form # and that all inputs are between ``COEFF_MIN`` and ``COEFF_MAX``. - void _fmpq_mul_small(fmpz_t rnum, fmpz_t rden, slong p1, ulong q1, slong p2, ulong q2) + void _fmpq_mul_small(fmpz_t rnum, fmpz_t rden, slong p1, ulong q1, slong p2, ulong q2) noexcept # Sets ``(rnum, rden)`` to the product of ``(p1, q1)`` and ``(p2, q2)``. # Assumes that ``(p1, q1)`` and ``(p2, q2)`` are in canonical form # and that all inputs are between ``COEFF_MIN`` and ``COEFF_MAX``. - int _fmpq_mod_fmpz(fmpz_t res, const fmpz_t num, const fmpz_t den, const fmpz_t mod) - int fmpq_mod_fmpz(fmpz_t res, const fmpq_t x, const fmpz_t mod) + int _fmpq_mod_fmpz(fmpz_t res, const fmpz_t num, const fmpz_t den, const fmpz_t mod) noexcept + int fmpq_mod_fmpz(fmpz_t res, const fmpq_t x, const fmpz_t mod) noexcept # Sets the integer ``res`` to the residue `a` of # `x = n/d` = ``(num, den)`` modulo the positive integer `m` = ``mod``, # defined as the `0 \le a < m` satisfying `n \equiv a d \pmod m`. # If such an `a` exists, 1 will be returned, otherwise 0 will # be returned. - int _fmpq_reconstruct_fmpz_2_naive(fmpz_t n, fmpz_t d, const fmpz_t a, const fmpz_t m, const fmpz_t N, const fmpz_t D) - int _fmpq_reconstruct_fmpz_2(fmpz_t n, fmpz_t d, const fmpz_t a, const fmpz_t m, const fmpz_t N, const fmpz_t D) - int fmpq_reconstruct_fmpz_2(fmpq_t res, const fmpz_t a, const fmpz_t m, const fmpz_t N, const fmpz_t D) + int _fmpq_reconstruct_fmpz_2_naive(fmpz_t n, fmpz_t d, const fmpz_t a, const fmpz_t m, const fmpz_t N, const fmpz_t D) noexcept + int _fmpq_reconstruct_fmpz_2(fmpz_t n, fmpz_t d, const fmpz_t a, const fmpz_t m, const fmpz_t N, const fmpz_t D) noexcept + int fmpq_reconstruct_fmpz_2(fmpq_t res, const fmpz_t a, const fmpz_t m, const fmpz_t N, const fmpz_t D) noexcept # Reconstructs a rational number from its residue `a` modulo `m`. # Given a modulus `m > 2`, a residue `0 \le a < m`, and positive `N, D` # satisfying `2ND < m`, this function attempts to find a fraction `n/d` with @@ -389,14 +389,14 @@ cdef extern from "flint_wrap.h": # The function returns 1 if successful, and 0 to indicate that no solution # exists. - int _fmpq_reconstruct_fmpz(fmpz_t n, fmpz_t d, const fmpz_t a, const fmpz_t m) - int fmpq_reconstruct_fmpz(fmpq_t res, const fmpz_t a, const fmpz_t m) + int _fmpq_reconstruct_fmpz(fmpz_t n, fmpz_t d, const fmpz_t a, const fmpz_t m) noexcept + int fmpq_reconstruct_fmpz(fmpq_t res, const fmpz_t a, const fmpz_t m) noexcept # Reconstructs a rational number from its residue `a` modulo `m`, # returning 1 if successful and 0 if no solution exists. # Uses the balanced bounds `N = D = \lfloor\sqrt{\frac{m-1}{2}}\rfloor`. - void _fmpq_next_minimal(fmpz_t rnum, fmpz_t rden, const fmpz_t num, const fmpz_t den) - void fmpq_next_minimal(fmpq_t res, const fmpq_t x) + void _fmpq_next_minimal(fmpz_t rnum, fmpz_t rden, const fmpz_t num, const fmpz_t den) noexcept + void fmpq_next_minimal(fmpq_t res, const fmpq_t x) noexcept # Given `x` which is assumed to be nonnegative and in canonical form, sets # ``res`` to the next rational number in the sequence obtained by # enumerating all positive denominators `q`, for each `q` enumerating @@ -409,8 +409,8 @@ cdef extern from "flint_wrap.h": # minimal height. It has the disadvantage of being somewhat slower to # compute than the Calkin-Wilf enumeration. - void _fmpq_next_signed_minimal(fmpz_t rnum, fmpz_t rden, const fmpz_t num, const fmpz_t den) - void fmpq_next_signed_minimal(fmpq_t res, const fmpq_t x) + void _fmpq_next_signed_minimal(fmpz_t rnum, fmpz_t rden, const fmpz_t num, const fmpz_t den) noexcept + void fmpq_next_signed_minimal(fmpq_t res, const fmpq_t x) noexcept # Given a signed rational number `x` assumed to be in canonical form, sets # ``res`` to the next element in the minimal-height sequence # generated by ``fmpq_next_minimal`` but with negative numbers @@ -419,8 +419,8 @@ cdef extern from "flint_wrap.h": # Starting with zero, this generates every rational number once # and only once, in order of minimal height. - void _fmpq_next_calkin_wilf(fmpz_t rnum, fmpz_t rden, const fmpz_t num, const fmpz_t den) - void fmpq_next_calkin_wilf(fmpq_t res, const fmpq_t x) + void _fmpq_next_calkin_wilf(fmpz_t rnum, fmpz_t rden, const fmpz_t num, const fmpz_t den) noexcept + void fmpq_next_calkin_wilf(fmpq_t res, const fmpq_t x) noexcept # Given `x` which is assumed to be nonnegative and in canonical form, sets # ``res`` to the next number in the breadth-first traversal of the # Calkin-Wilf tree. Starting with zero, this generates every nonnegative @@ -432,8 +432,8 @@ cdef extern from "flint_wrap.h": # has the advantage of being faster to produce than the minimal-height # order. - void _fmpq_next_signed_calkin_wilf(fmpz_t rnum, fmpz_t rden, const fmpz_t num, const fmpz_t den) - void fmpq_next_signed_calkin_wilf(fmpq_t res, const fmpq_t x) + void _fmpq_next_signed_calkin_wilf(fmpz_t rnum, fmpz_t rden, const fmpz_t num, const fmpz_t den) noexcept + void fmpq_next_signed_calkin_wilf(fmpq_t res, const fmpq_t x) noexcept # Given a signed rational number `x` assumed to be in canonical form, sets # ``res`` to the next element in the Calkin-Wilf sequence with # negative numbers interleaved: @@ -441,18 +441,18 @@ cdef extern from "flint_wrap.h": # Starting with zero, this generates every rational number once # and only once, but not in order of minimal height. - void fmpq_farey_neighbors(fmpq_t l, fmpq_t r, const fmpq_t x, const fmpz_t Q) + void fmpq_farey_neighbors(fmpq_t l, fmpq_t r, const fmpq_t x, const fmpz_t Q) noexcept # Set `l` and `r` to the fractions directly below and above `x` in the Farey sequence of order `Q`. # This function will throw if `x` is not canonical or `Q` is less than the denominator of `x`. - void fmpq_simplest_between(fmpq_t x, const fmpq_t l, const fmpq_t r) - void _fmpq_simplest_between(fmpz_t x_num, fmpz_t x_den, const fmpz_t l_num, const fmpz_t l_den, const fmpz_t r_num, const fmpz_t r_den) + void fmpq_simplest_between(fmpq_t x, const fmpq_t l, const fmpq_t r) noexcept + void _fmpq_simplest_between(fmpz_t x_num, fmpz_t x_den, const fmpz_t l_num, const fmpz_t l_den, const fmpz_t r_num, const fmpz_t r_den) noexcept # Set `x` to the simplest fraction in the closed interval `[l, r]`. The underscore version makes the additional assumption that `l \le r`. # The endpoints `l` and `r` do not need to be reduced, but their denominators do need to be positive. # `x` will always be returned in canonical form. A canonical fraction `a_1/b_1` is defined to be simpler than `a_2/b_2` iff `b_1 0`, then ``rem`` will be canonical. # Therefore, applications relying on canonical ``fmpq_t``'s should not call this function with `n \le 0`. - void fmpq_set_cfrac(fmpq_t x, const fmpz * c, slong n) + void fmpq_set_cfrac(fmpq_t x, const fmpz * c, slong n) noexcept # Sets `x` to the value of the continued fraction # .. math :: # x = c_0 + \cfrac{1}{c_1 + \cfrac{1}{c_2 + @@ -489,20 +489,20 @@ cdef extern from "flint_wrap.h": # This product is split in half recursively to balance the size # of the coefficients. - slong fmpq_cfrac_bound(const fmpq_t x) + slong fmpq_cfrac_bound(const fmpq_t x) noexcept # Returns an upper bound for the number of terms in the continued # fraction expansion of `x`. The computed bound is not necessarily sharp. # We use the fact that the smallest denominator # that can give a continued fraction of length `n` is the Fibonacci # number `F_{n+1}`. - void _fmpq_harmonic_ui(fmpz_t num, fmpz_t den, ulong n) - void fmpq_harmonic_ui(fmpq_t x, ulong n) + void _fmpq_harmonic_ui(fmpz_t num, fmpz_t den, ulong n) noexcept + void fmpq_harmonic_ui(fmpq_t x, ulong n) noexcept # Computes the harmonic number `H_n = 1 + 1/2 + 1/3 + \dotsb + 1/n`. # Table lookup is used for `H_n` whose numerator and denominator # fit in single limb. For larger `n`, a divide and conquer strategy is used. - void fmpq_dedekind_sum(fmpq_t s, const fmpz_t h, const fmpz_t k) - void fmpq_dedekind_sum_naive(fmpq_t s, const fmpz_t h, const fmpz_t k) + void fmpq_dedekind_sum(fmpq_t s, const fmpz_t h, const fmpz_t k) noexcept + void fmpq_dedekind_sum_naive(fmpq_t s, const fmpz_t h, const fmpz_t k) noexcept # Computes `s(h,k)` for arbitrary `h` and `k`. The naive version uses a straightforward # implementation of the defining sum using ``fmpz`` arithmetic and is slow for large `k`. diff --git a/src/sage/libs/flint/fmpq_mat.pxd b/src/sage/libs/flint/fmpq_mat.pxd index 1764be93cba..7d00c54b7b7 100644 --- a/src/sage/libs/flint/fmpq_mat.pxd +++ b/src/sage/libs/flint/fmpq_mat.pxd @@ -12,191 +12,191 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void fmpq_mat_init(fmpq_mat_t mat, slong rows, slong cols) + void fmpq_mat_init(fmpq_mat_t mat, slong rows, slong cols) noexcept # Initialises a matrix with the given number of rows and columns for use. - void fmpq_mat_init_set(fmpq_mat_t mat1, const fmpq_mat_t mat2) + void fmpq_mat_init_set(fmpq_mat_t mat1, const fmpq_mat_t mat2) noexcept # Initialises ``mat1`` and sets it equal to ``mat2``. - void fmpq_mat_clear(fmpq_mat_t mat) + void fmpq_mat_clear(fmpq_mat_t mat) noexcept # Frees all memory associated with the matrix. The matrix must be # reinitialised if it is to be used again. - void fmpq_mat_swap(fmpq_mat_t mat1, fmpq_mat_t mat2) + void fmpq_mat_swap(fmpq_mat_t mat1, fmpq_mat_t mat2) noexcept # Swaps two matrices. The dimensions of ``mat1`` and ``mat2`` # are allowed to be different. - void fmpq_mat_swap_entrywise(fmpq_mat_t mat1, fmpq_mat_t mat2) + void fmpq_mat_swap_entrywise(fmpq_mat_t mat1, fmpq_mat_t mat2) noexcept # Swaps two matrices by swapping the individual entries rather than swapping # the contents of the structs. - fmpq * fmpq_mat_entry(const fmpq_mat_t mat, slong i, slong j) + fmpq * fmpq_mat_entry(const fmpq_mat_t mat, slong i, slong j) noexcept # Gives a reference to the entry at row ``i`` and column ``j``. # The reference can be passed as an input or output variable to any # ``fmpq`` function for direct manipulation of the matrix element. # No bounds checking is performed. - fmpz * fmpq_mat_entry_num(const fmpq_mat_t mat, slong i, slong j) + fmpz * fmpq_mat_entry_num(const fmpq_mat_t mat, slong i, slong j) noexcept # Gives a reference to the numerator of the entry at row ``i`` and # column ``j``. The reference can be passed as an input or output # variable to any ``fmpz`` function for direct manipulation of the # matrix element. No bounds checking is performed. - fmpz * fmpq_mat_entry_den(const fmpq_mat_t mat, slong i, slong j) + fmpz * fmpq_mat_entry_den(const fmpq_mat_t mat, slong i, slong j) noexcept # Gives a reference to the denominator of the entry at row ``i`` and # column ``j``. The reference can be passed as an input or output # variable to any ``fmpz`` function for direct manipulation of the # matrix element. No bounds checking is performed. - slong fmpq_mat_nrows(const fmpq_mat_t mat) + slong fmpq_mat_nrows(const fmpq_mat_t mat) noexcept # Return the number of rows of the matrix ``mat``. - slong fmpq_mat_ncols(const fmpq_mat_t mat) + slong fmpq_mat_ncols(const fmpq_mat_t mat) noexcept # Return the number of columns of the matrix ``mat``. - void fmpq_mat_set(fmpq_mat_t dest, const fmpq_mat_t src) + void fmpq_mat_set(fmpq_mat_t dest, const fmpq_mat_t src) noexcept # Sets the entries in ``dest`` to the same values as in ``src``, # assuming the two matrices have the same dimensions. - void fmpq_mat_zero(fmpq_mat_t mat) + void fmpq_mat_zero(fmpq_mat_t mat) noexcept # Sets ``mat`` to the zero matrix. - void fmpq_mat_one(fmpq_mat_t mat) + void fmpq_mat_one(fmpq_mat_t mat) noexcept # Let `m` be the minimum of the number of rows and columns # in the matrix ``mat``. This function sets the first # `m \times m` block to the identity matrix, and the remaining # block to zero. - void fmpq_mat_transpose(fmpq_mat_t rop, const fmpq_mat_t op) + void fmpq_mat_transpose(fmpq_mat_t rop, const fmpq_mat_t op) noexcept # Sets the matrix ``rop`` to the transpose of the matrix ``op``, # assuming that their dimensions are compatible. - void fmpq_mat_swap_rows(fmpq_mat_t mat, slong * perm, slong r, slong s) + void fmpq_mat_swap_rows(fmpq_mat_t mat, slong * perm, slong r, slong s) noexcept # Swaps rows ``r`` and ``s`` of ``mat``. If ``perm`` is non-``NULL``, the # permutation of the rows will also be applied to ``perm``. - void fmpq_mat_swap_cols(fmpq_mat_t mat, slong * perm, slong r, slong s) + void fmpq_mat_swap_cols(fmpq_mat_t mat, slong * perm, slong r, slong s) noexcept # Swaps columns ``r`` and ``s`` of ``mat``. If ``perm`` is non-``NULL``, the # permutation of the columns will also be applied to ``perm``. - void fmpq_mat_invert_rows(fmpq_mat_t mat, slong * perm) + void fmpq_mat_invert_rows(fmpq_mat_t mat, slong * perm) noexcept # Swaps rows ``i`` and ``r - i`` of ``mat`` for ``0 <= i < r/2``, where # ``r`` is the number of rows of ``mat``. If ``perm`` is non-``NULL``, the # permutation of the rows will also be applied to ``perm``. - void fmpq_mat_invert_cols(fmpq_mat_t mat, slong * perm) + void fmpq_mat_invert_cols(fmpq_mat_t mat, slong * perm) noexcept # Swaps columns ``i`` and ``c - i`` of ``mat`` for ``0 <= i < c/2``, where # ``c`` is the number of columns of ``mat``. If ``perm`` is non-``NULL``, the # permutation of the columns will also be applied to ``perm``. - void fmpq_mat_add(fmpq_mat_t mat, const fmpq_mat_t mat1, const fmpq_mat_t mat2) + void fmpq_mat_add(fmpq_mat_t mat, const fmpq_mat_t mat1, const fmpq_mat_t mat2) noexcept # Sets ``mat`` to the sum of ``mat1`` and ``mat2``, # assuming that all three matrices have the same dimensions. - void fmpq_mat_sub(fmpq_mat_t mat, const fmpq_mat_t mat1, const fmpq_mat_t mat2) + void fmpq_mat_sub(fmpq_mat_t mat, const fmpq_mat_t mat1, const fmpq_mat_t mat2) noexcept # Sets ``mat`` to the difference of ``mat1`` and ``mat2``, # assuming that all three matrices have the same dimensions. - void fmpq_mat_neg(fmpq_mat_t rop, const fmpq_mat_t op) + void fmpq_mat_neg(fmpq_mat_t rop, const fmpq_mat_t op) noexcept # Sets ``rop`` to the negative of ``op``, assuming that # the two matrices have the same dimensions. - void fmpq_mat_scalar_mul_fmpq(fmpq_mat_t rop, const fmpq_mat_t op, const fmpq_t x) + void fmpq_mat_scalar_mul_fmpq(fmpq_mat_t rop, const fmpq_mat_t op, const fmpq_t x) noexcept # Sets ``rop`` to ``op`` multiplied by the rational `x`, # assuming that the two matrices have the same dimensions. # Note that the rational ``x`` may not be aliased with any part of the # entries of ``rop``. - void fmpq_mat_scalar_mul_fmpz(fmpq_mat_t rop, const fmpq_mat_t op, const fmpz_t x) + void fmpq_mat_scalar_mul_fmpz(fmpq_mat_t rop, const fmpq_mat_t op, const fmpz_t x) noexcept # Sets ``rop`` to ``op`` multiplied by the integer `x`, # assuming that the two matrices have the same dimensions. # Note that the integer `x` may not be aliased with any part of # the entries of ``rop``. - void fmpq_mat_scalar_div_fmpz(fmpq_mat_t rop, const fmpq_mat_t op, const fmpz_t x) + void fmpq_mat_scalar_div_fmpz(fmpq_mat_t rop, const fmpq_mat_t op, const fmpz_t x) noexcept # Sets ``rop`` to ``op`` divided by the integer `x`, # assuming that the two matrices have the same dimensions # and that `x` is non-zero. # Note that the integer `x` may not be aliased with any part of # the entries of ``rop``. - void fmpq_mat_print(const fmpq_mat_t mat) + void fmpq_mat_print(const fmpq_mat_t mat) noexcept # Prints the matrix ``mat`` to standard output. - void fmpq_mat_randbits(fmpq_mat_t mat, flint_rand_t state, flint_bitcnt_t bits) + void fmpq_mat_randbits(fmpq_mat_t mat, flint_rand_t state, flint_bitcnt_t bits) noexcept # This is equivalent to applying ``fmpq_randbits`` to all entries # in the matrix. - void fmpq_mat_randtest(fmpq_mat_t mat, flint_rand_t state, flint_bitcnt_t bits) + void fmpq_mat_randtest(fmpq_mat_t mat, flint_rand_t state, flint_bitcnt_t bits) noexcept # This is equivalent to applying ``fmpq_randtest`` to all entries # in the matrix. - void fmpq_mat_window_init(fmpq_mat_t window, const fmpq_mat_t mat, slong r1, slong c1, slong r2, slong c2) + void fmpq_mat_window_init(fmpq_mat_t window, const fmpq_mat_t mat, slong r1, slong c1, slong r2, slong c2) noexcept # Initializes the matrix ``window`` to be an ``r2 - r1`` by # ``c2 - c1`` submatrix of ``mat`` whose ``(0,0)`` entry # is the ``(r1, c1)`` entry of ``mat``. The memory for the # elements of ``window`` is shared with ``mat``. - void fmpq_mat_window_clear(fmpq_mat_t window) + void fmpq_mat_window_clear(fmpq_mat_t window) noexcept # Clears the matrix ``window`` and releases any memory that it # uses. Note that the memory to the underlying matrix that # ``window`` points to is not freed. - void fmpq_mat_concat_vertical(fmpq_mat_t res, const fmpq_mat_t mat1, const fmpq_mat_t mat2) + void fmpq_mat_concat_vertical(fmpq_mat_t res, const fmpq_mat_t mat1, const fmpq_mat_t mat2) noexcept # Sets ``res`` to vertical concatenation of (``mat1``, ``mat2``) in that order. Matrix dimensions: ``mat1``: `m \times n`, ``mat2``: `k \times n`, ``res``: `(m + k) \times n`. - void fmpq_mat_concat_horizontal(fmpq_mat_t res, const fmpq_mat_t mat1, const fmpq_mat_t mat2) + void fmpq_mat_concat_horizontal(fmpq_mat_t res, const fmpq_mat_t mat1, const fmpq_mat_t mat2) noexcept # Sets ``res`` to horizontal concatenation of (``mat1``, ``mat2``) in that order. Matrix dimensions: ``mat1``: `m \times n`, ``mat2``: `m \times k`, ``res``: `m \times (n + k)`. - void fmpq_mat_hilbert_matrix(fmpq_mat_t mat) + void fmpq_mat_hilbert_matrix(fmpq_mat_t mat) noexcept # Sets ``mat`` to a Hilbert matrix of the given size. That is, # the entry at row `i` and column `j` is set to `1/(i+j+1)`. - bint fmpq_mat_equal(const fmpq_mat_t mat1, const fmpq_mat_t mat2) + bint fmpq_mat_equal(const fmpq_mat_t mat1, const fmpq_mat_t mat2) noexcept # Returns nonzero if ``mat1`` and ``mat2`` have the same shape and # all their entries agree, and returns zero otherwise. Assumes the # entries in both ``mat1`` and ``mat2`` are in canonical form. - bint fmpq_mat_is_integral(const fmpq_mat_t mat) + bint fmpq_mat_is_integral(const fmpq_mat_t mat) noexcept # Returns nonzero if all entries in ``mat`` are integer-valued, and # returns zero otherwise. Assumes that the entries in ``mat`` # are in canonical form. - bint fmpq_mat_is_zero(const fmpq_mat_t mat) + bint fmpq_mat_is_zero(const fmpq_mat_t mat) noexcept # Returns nonzero if all entries in ``mat`` are zero, and returns # zero otherwise. - bint fmpq_mat_is_one(const fmpq_mat_t mat) + bint fmpq_mat_is_one(const fmpq_mat_t mat) noexcept # Returns nonzero if ``mat`` ones along the diagonal and zeros elsewhere, # and returns zero otherwise. - bint fmpq_mat_is_empty(const fmpq_mat_t mat) + bint fmpq_mat_is_empty(const fmpq_mat_t mat) noexcept # Returns a non-zero value if the number of rows or the number of # columns in ``mat`` is zero, and otherwise returns # zero. - bint fmpq_mat_is_square(const fmpq_mat_t mat) + bint fmpq_mat_is_square(const fmpq_mat_t mat) noexcept # Returns a non-zero value if the number of rows is equal to the # number of columns in ``mat``, and otherwise returns zero. - int fmpq_mat_get_fmpz_mat(fmpz_mat_t dest, const fmpq_mat_t mat) + int fmpq_mat_get_fmpz_mat(fmpz_mat_t dest, const fmpq_mat_t mat) noexcept # Sets ``dest`` to ``mat`` and returns nonzero if all entries # in ``mat`` are integer-valued. If not all entries in ``mat`` # are integer-valued, sets ``dest`` to an undefined matrix # and returns zero. Assumes that the entries in ``mat`` are # in canonical form. - void fmpq_mat_get_fmpz_mat_entrywise(fmpz_mat_t num, fmpz_mat_t den, const fmpq_mat_t mat) + void fmpq_mat_get_fmpz_mat_entrywise(fmpz_mat_t num, fmpz_mat_t den, const fmpq_mat_t mat) noexcept # Sets the integer matrices ``num`` and ``den`` respectively # to the numerators and denominators of the entries in ``mat``. - void fmpq_mat_get_fmpz_mat_matwise(fmpz_mat_t num, fmpz_t den, const fmpq_mat_t mat) + void fmpq_mat_get_fmpz_mat_matwise(fmpz_mat_t num, fmpz_t den, const fmpq_mat_t mat) noexcept # Converts all entries in ``mat`` to a common denominator, # storing the rescaled numerators in ``num`` and the # denominator in ``den``. The denominator will be minimal # if the entries in ``mat`` are in canonical form. - void fmpq_mat_get_fmpz_mat_rowwise(fmpz_mat_t num, fmpz * den, const fmpq_mat_t mat) + void fmpq_mat_get_fmpz_mat_rowwise(fmpz_mat_t num, fmpz * den, const fmpq_mat_t mat) noexcept # Clears denominators in ``mat`` row by row. The rescaled # numerators are written to ``num``, and the denominator # of row ``i`` is written to position ``i`` in ``den`` @@ -204,14 +204,14 @@ cdef extern from "flint_wrap.h": # ``NULL`` can be passed as the ``den`` variable, in which # case the denominators will not be stored. - void fmpq_mat_get_fmpz_mat_rowwise_2(fmpz_mat_t num, fmpz_mat_t num2, fmpz * den, const fmpq_mat_t mat, const fmpq_mat_t mat2) + void fmpq_mat_get_fmpz_mat_rowwise_2(fmpz_mat_t num, fmpz_mat_t num2, fmpz * den, const fmpq_mat_t mat, const fmpq_mat_t mat2) noexcept # Clears denominators row by row of both ``mat`` and ``mat2``, # writing the respective numerators to ``num`` and ``num2``. # This is equivalent to concatenating ``mat`` and ``mat2`` # horizontally, calling ``fmpq_mat_get_fmpz_mat_rowwise``, # and extracting the two submatrices in the result. - void fmpq_mat_get_fmpz_mat_colwise(fmpz_mat_t num, fmpz * den, const fmpq_mat_t mat) + void fmpq_mat_get_fmpz_mat_colwise(fmpz_mat_t num, fmpz * den, const fmpq_mat_t mat) noexcept # Clears denominators in ``mat`` column by column. The rescaled # numerators are written to ``num``, and the denominator # of column ``i`` is written to position ``i`` in ``den`` @@ -219,80 +219,80 @@ cdef extern from "flint_wrap.h": # ``NULL`` can be passed as the ``den`` variable, in which # case the denominators will not be stored. - void fmpq_mat_set_fmpz_mat(fmpq_mat_t dest, const fmpz_mat_t src) + void fmpq_mat_set_fmpz_mat(fmpq_mat_t dest, const fmpz_mat_t src) noexcept # Sets ``dest`` to ``src``. - void fmpq_mat_set_fmpz_mat_div_fmpz(fmpq_mat_t mat, const fmpz_mat_t num, const fmpz_t den) + void fmpq_mat_set_fmpz_mat_div_fmpz(fmpq_mat_t mat, const fmpz_mat_t num, const fmpz_t den) noexcept # Sets ``mat`` to the integer matrix ``num`` divided by the # common denominator ``den``. - void fmpq_mat_get_fmpz_mat_mod_fmpz(fmpz_mat_t dest, const fmpq_mat_t mat, const fmpz_t mod) + void fmpq_mat_get_fmpz_mat_mod_fmpz(fmpz_mat_t dest, const fmpq_mat_t mat, const fmpz_t mod) noexcept # Sets each entry in ``dest`` to the corresponding entry in ``mat``, # reduced modulo ``mod``. - int fmpq_mat_set_fmpz_mat_mod_fmpz(fmpq_mat_t X, const fmpz_mat_t Xmod, const fmpz_t mod) + int fmpq_mat_set_fmpz_mat_mod_fmpz(fmpq_mat_t X, const fmpz_mat_t Xmod, const fmpz_t mod) noexcept # Sets ``X`` to the entrywise rational reconstruction integer matrix # ``Xmod`` modulo ``mod``, and returns nonzero if the reconstruction # is successful. If rational reconstruction fails for any element, # returns zero and sets the entries in ``X`` to undefined values. - void fmpq_mat_mul_direct(fmpq_mat_t C, const fmpq_mat_t A, const fmpq_mat_t B) + void fmpq_mat_mul_direct(fmpq_mat_t C, const fmpq_mat_t A, const fmpq_mat_t B) noexcept # Sets ``C`` to the matrix product ``AB``, computed # naively using rational arithmetic. This is typically very slow and # should only be used in circumstances where clearing denominators # would consume too much memory. - void fmpq_mat_mul_cleared(fmpq_mat_t C, const fmpq_mat_t A, const fmpq_mat_t B) + void fmpq_mat_mul_cleared(fmpq_mat_t C, const fmpq_mat_t A, const fmpq_mat_t B) noexcept # Sets ``C`` to the matrix product ``AB``, computed # by clearing denominators and multiplying over the integers. - void fmpq_mat_mul(fmpq_mat_t C, const fmpq_mat_t A, const fmpq_mat_t B) + void fmpq_mat_mul(fmpq_mat_t C, const fmpq_mat_t A, const fmpq_mat_t B) noexcept # Sets ``C`` to the matrix product ``AB``. This # simply calls ``fmpq_mat_mul_cleared``. - void fmpq_mat_mul_fmpz_mat(fmpq_mat_t C, const fmpq_mat_t A, const fmpz_mat_t B) + void fmpq_mat_mul_fmpz_mat(fmpq_mat_t C, const fmpq_mat_t A, const fmpz_mat_t B) noexcept # Sets ``C`` to the matrix product ``AB``, with ``B`` # an integer matrix. This function works efficiently by clearing # denominators of ``A``. - void fmpq_mat_mul_r_fmpz_mat(fmpq_mat_t C, const fmpz_mat_t A, const fmpq_mat_t B) + void fmpq_mat_mul_r_fmpz_mat(fmpq_mat_t C, const fmpz_mat_t A, const fmpq_mat_t B) noexcept # Sets ``C`` to the matrix product ``AB``, with ``A`` # an integer matrix. This function works efficiently by clearing # denominators of ``B``. - void fmpq_mat_mul_fmpq_vec(fmpq * c, const fmpq_mat_t A, const fmpq * b, slong blen) - void fmpq_mat_mul_fmpz_vec(fmpq * c, const fmpq_mat_t A, const fmpz * b, slong blen) - void fmpq_mat_mul_fmpq_vec_ptr(fmpq * const * c, const fmpq_mat_t A, const fmpq * const * b, slong blen) - void fmpq_mat_mul_fmpz_vec_ptr(fmpq * const * c, const fmpq_mat_t A, const fmpz * const * b, slong blen) + void fmpq_mat_mul_fmpq_vec(fmpq * c, const fmpq_mat_t A, const fmpq * b, slong blen) noexcept + void fmpq_mat_mul_fmpz_vec(fmpq * c, const fmpq_mat_t A, const fmpz * b, slong blen) noexcept + void fmpq_mat_mul_fmpq_vec_ptr(fmpq * const * c, const fmpq_mat_t A, const fmpq * const * b, slong blen) noexcept + void fmpq_mat_mul_fmpz_vec_ptr(fmpq * const * c, const fmpq_mat_t A, const fmpz * const * b, slong blen) noexcept # Compute a matrix-vector product of ``A`` and ``(b, blen)`` and store the result in ``c``. # The vector ``(b, blen)`` is either truncated or zero-extended to the number of columns of ``A``. # The number entries written to ``c`` is always equal to the number of rows of ``A``. - void fmpq_mat_fmpq_vec_mul(fmpq * c, const fmpq * a, slong alen, const fmpq_mat_t B) - void fmpq_mat_fmpz_vec_mul(fmpq * c, const fmpz * a, slong alen, const fmpq_mat_t B) - void fmpq_mat_fmpq_vec_mul_ptr(fmpq * const * c, const fmpq * const * a, slong alen, const fmpq_mat_t B) - void fmpq_mat_fmpz_vec_mul_ptr(fmpq * const * c, const fmpz * const * a, slong alen, const fmpq_mat_t B) + void fmpq_mat_fmpq_vec_mul(fmpq * c, const fmpq * a, slong alen, const fmpq_mat_t B) noexcept + void fmpq_mat_fmpz_vec_mul(fmpq * c, const fmpz * a, slong alen, const fmpq_mat_t B) noexcept + void fmpq_mat_fmpq_vec_mul_ptr(fmpq * const * c, const fmpq * const * a, slong alen, const fmpq_mat_t B) noexcept + void fmpq_mat_fmpz_vec_mul_ptr(fmpq * const * c, const fmpz * const * a, slong alen, const fmpq_mat_t B) noexcept # Compute a vector-matrix product of ``(a, alen)`` and ``B`` and and store the result in ``c``. # The vector ``(a, alen)`` is either truncated or zero-extended to the number of rows of ``B``. # The number entries written to ``c`` is always equal to the number of columns of ``B``. - void fmpq_mat_kronecker_product(fmpq_mat_t C, const fmpq_mat_t A, const fmpq_mat_t B) + void fmpq_mat_kronecker_product(fmpq_mat_t C, const fmpq_mat_t A, const fmpq_mat_t B) noexcept # Sets ``C`` to the Kronecker product of ``A`` and ``B``. - void fmpq_mat_trace(fmpq_t trace, const fmpq_mat_t mat) + void fmpq_mat_trace(fmpq_t trace, const fmpq_mat_t mat) noexcept # Computes the trace of the matrix, i.e. the sum of the entries on # the main diagonal. The matrix is required to be square. - void fmpq_mat_det(fmpq_t det, const fmpq_mat_t mat) + void fmpq_mat_det(fmpq_t det, const fmpq_mat_t mat) noexcept # Sets ``det`` to the determinant of ``mat``. In the general case, # the determinant is computed by clearing denominators and computing a # determinant over the integers. Matrices of size 0, 1 or 2 are handled # directly. - int fmpq_mat_solve_fraction_free(fmpq_mat_t X, const fmpq_mat_t A, const fmpq_mat_t B) - int fmpq_mat_solve_dixon(fmpq_mat_t X, const fmpq_mat_t A, const fmpq_mat_t B) - int fmpq_mat_solve_multi_mod(fmpq_mat_t X, const fmpq_mat_t A, const fmpq_mat_t B) - int fmpq_mat_solve(fmpq_mat_t X, const fmpq_mat_t A, const fmpq_mat_t B) + int fmpq_mat_solve_fraction_free(fmpq_mat_t X, const fmpq_mat_t A, const fmpq_mat_t B) noexcept + int fmpq_mat_solve_dixon(fmpq_mat_t X, const fmpq_mat_t A, const fmpq_mat_t B) noexcept + int fmpq_mat_solve_multi_mod(fmpq_mat_t X, const fmpq_mat_t A, const fmpq_mat_t B) noexcept + int fmpq_mat_solve(fmpq_mat_t X, const fmpq_mat_t A, const fmpq_mat_t B) noexcept # Solves ``AX = B`` for nonsingular ``A``. # Returns nonzero if ``A`` is nonsingular or if the right hand side # is empty, and zero otherwise. @@ -304,34 +304,34 @@ cdef extern from "flint_wrap.h": # are generally the best choice for large systems. # The default method chooses an algorithm automatically. - int fmpq_mat_solve_fmpz_mat_fraction_free(fmpq_mat_t X, const fmpz_mat_t A, const fmpz_mat_t B) - int fmpq_mat_solve_fmpz_mat_dixon(fmpq_mat_t X, const fmpz_mat_t A, const fmpz_mat_t B) - int fmpq_mat_solve_fmpz_mat_multi_mod(fmpq_mat_t X, const fmpz_mat_t A, const fmpz_mat_t B) - int fmpq_mat_solve_fmpz_mat(fmpq_mat_t X, const fmpz_mat_t A, const fmpz_mat_t B) + int fmpq_mat_solve_fmpz_mat_fraction_free(fmpq_mat_t X, const fmpz_mat_t A, const fmpz_mat_t B) noexcept + int fmpq_mat_solve_fmpz_mat_dixon(fmpq_mat_t X, const fmpz_mat_t A, const fmpz_mat_t B) noexcept + int fmpq_mat_solve_fmpz_mat_multi_mod(fmpq_mat_t X, const fmpz_mat_t A, const fmpz_mat_t B) noexcept + int fmpq_mat_solve_fmpz_mat(fmpq_mat_t X, const fmpz_mat_t A, const fmpz_mat_t B) noexcept # Solves ``AX = B`` for nonsingular ``A``, where *A* and *B* are integer # matrices. Returns nonzero if ``A`` is nonsingular or if the right hand side # is empty, and zero otherwise. - int fmpq_mat_can_solve_multi_mod(fmpq_mat_t X, const fmpq_mat_t A, const fmpq_mat_t B) + int fmpq_mat_can_solve_multi_mod(fmpq_mat_t X, const fmpq_mat_t A, const fmpq_mat_t B) noexcept # Returns `1` if ``AX = B`` has a solution and if so, sets ``X`` to one such # solution. The matrices can have any shape but must have the same number of # rows. - int fmpq_mat_can_solve_fraction_free(fmpq_mat_t X, const fmpq_mat_t A, const fmpq_mat_t B) + int fmpq_mat_can_solve_fraction_free(fmpq_mat_t X, const fmpq_mat_t A, const fmpq_mat_t B) noexcept # Returns `1` if ``AX = B`` has a solution and if so, sets ``X`` to one such # solution. The matrices can have any shape but must have the same number of # rows. - int fmpq_mat_can_solve(fmpq_mat_t X, const fmpq_mat_t A, const fmpq_mat_t B) + int fmpq_mat_can_solve(fmpq_mat_t X, const fmpq_mat_t A, const fmpq_mat_t B) noexcept # Returns `1` if ``AX = B`` has a solution and if so, sets ``X`` to one such # solution. The matrices can have any shape but must have the same number of # rows. - int fmpq_mat_inv(fmpq_mat_t B, const fmpq_mat_t A) + int fmpq_mat_inv(fmpq_mat_t B, const fmpq_mat_t A) noexcept # Sets ``B`` to the inverse matrix of ``A`` and returns nonzero. # Returns zero if ``A`` is singular. ``A`` must be a square matrix. - int fmpq_mat_pivot(slong * perm, fmpq_mat_t mat, slong r, slong c) + int fmpq_mat_pivot(slong * perm, fmpq_mat_t mat, slong r, slong c) noexcept # Helper function for row reduction. Returns 1 if the entry of ``mat`` # at row `r` and column `c` is nonzero. Otherwise searches for a nonzero # entry in the same column among rows `r+1, r+2, \ldots`. If a nonzero @@ -339,29 +339,29 @@ cdef extern from "flint_wrap.h": # entries in ``perm`` (unless ``NULL``) and returns -1. If no # nonzero pivot entry is found, leaves the inputs unchanged and returns 0. - slong fmpq_mat_rref_classical(fmpq_mat_t B, const fmpq_mat_t A) + slong fmpq_mat_rref_classical(fmpq_mat_t B, const fmpq_mat_t A) noexcept # Sets ``B`` to the reduced row echelon form of ``A`` and returns # the rank. Performs Gauss-Jordan elimination directly over the rational # numbers. This algorithm is usually inefficient and is mainly intended # to be used for testing purposes. - slong fmpq_mat_rref_fraction_free(fmpq_mat_t B, const fmpq_mat_t A) + slong fmpq_mat_rref_fraction_free(fmpq_mat_t B, const fmpq_mat_t A) noexcept # Sets ``B`` to the reduced row echelon form of ``A`` and returns # the rank. Clears denominators and performs fraction-free Gauss-Jordan # elimination using ``fmpz_mat`` functions. - slong fmpq_mat_rref(fmpq_mat_t B, const fmpq_mat_t A) + slong fmpq_mat_rref(fmpq_mat_t B, const fmpq_mat_t A) noexcept # Sets ``B`` to the reduced row echelon form of ``A`` and returns # the rank. This function automatically chooses between the classical and # fraction-free algorithms depending on the size of the matrix. - void fmpq_mat_gso(fmpq_mat_t B, const fmpq_mat_t A) + void fmpq_mat_gso(fmpq_mat_t B, const fmpq_mat_t A) noexcept # Takes a subset of `\mathbb{Q}^m` `S = \{a_1, a_2, \ldots ,a_n\}` (as the # columns of a `m \times n` matrix ``A``) and generates an orthogonal set # `S' = \{b_1, b_2, \ldots ,b_n\}` (as the columns of the `m \times n` matrix # ``B``) that spans the same subspace of `\mathbb{Q}^m` as `S`. - void fmpq_mat_similarity(fmpq_mat_t A, slong r, fmpq_t d) + void fmpq_mat_similarity(fmpq_mat_t A, slong r, fmpq_t d) noexcept # Applies a similarity transform to the `n\times n` matrix `M` in-place. # If `P` is the `n\times n` identity matrix the zero entries of whose row # `r` (`0`-indexed) have been replaced by `d`, this transform is equivalent @@ -369,19 +369,19 @@ cdef extern from "flint_wrap.h": # Similarity transforms preserve the determinant, characteristic polynomial # and minimal polynomial. - void _fmpq_mat_charpoly(fmpz * coeffs, fmpz_t den, const fmpq_mat_t mat) + void _fmpq_mat_charpoly(fmpz * coeffs, fmpz_t den, const fmpq_mat_t mat) noexcept # Set ``(coeffs, den)`` to the characteristic polynomial of the given # `n\times n` matrix. - void fmpq_mat_charpoly(fmpq_poly_t pol, const fmpq_mat_t mat) + void fmpq_mat_charpoly(fmpq_poly_t pol, const fmpq_mat_t mat) noexcept # Set ``pol`` to the characteristic polynomial of the given `n\times n` # matrix. If ``mat`` is not square, an exception is raised. - slong _fmpq_mat_minpoly(fmpz * coeffs, fmpz_t den, const fmpq_mat_t mat) + slong _fmpq_mat_minpoly(fmpz * coeffs, fmpz_t den, const fmpq_mat_t mat) noexcept # Set ``(coeffs, den)`` to the minimal polynomial of the given # `n\times n` matrix and return the length of the polynomial. - void fmpq_mat_minpoly(fmpq_poly_t pol, const fmpq_mat_t mat) + void fmpq_mat_minpoly(fmpq_poly_t pol, const fmpq_mat_t mat) noexcept # Set ``pol`` to the minimal polynomial of the given `n\times n` # matrix. If ``mat`` is not square, an exception is raised. diff --git a/src/sage/libs/flint/fmpq_mpoly.pxd b/src/sage/libs/flint/fmpq_mpoly.pxd index d40a28e9336..ff9df250dc3 100644 --- a/src/sage/libs/flint/fmpq_mpoly.pxd +++ b/src/sage/libs/flint/fmpq_mpoly.pxd @@ -12,166 +12,166 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void fmpq_mpoly_ctx_init(fmpq_mpoly_ctx_t ctx, slong nvars, const ordering_t ord) + void fmpq_mpoly_ctx_init(fmpq_mpoly_ctx_t ctx, slong nvars, const ordering_t ord) noexcept # Initialise a context object for a polynomial ring with the given number of variables and the given ordering. # The possibilities for the ordering are ``ORD_LEX``, ``ORD_DEGLEX`` and ``ORD_DEGREVLEX``. - slong fmpq_mpoly_ctx_nvars(const fmpq_mpoly_ctx_t ctx) + slong fmpq_mpoly_ctx_nvars(const fmpq_mpoly_ctx_t ctx) noexcept # Return the number of variables used to initialize the context. - ordering_t fmpq_mpoly_ctx_ord(const fmpq_mpoly_ctx_t ctx) + ordering_t fmpq_mpoly_ctx_ord(const fmpq_mpoly_ctx_t ctx) noexcept # Return the ordering used to initialize the context. - void fmpq_mpoly_ctx_clear(fmpq_mpoly_ctx_t ctx) + void fmpq_mpoly_ctx_clear(fmpq_mpoly_ctx_t ctx) noexcept # Release up any space allocated by *ctx*. - void fmpq_mpoly_init(fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx) + void fmpq_mpoly_init(fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx) noexcept # Initialise *A* for use with the given and initialised context object. Its value is set to zero. - void fmpq_mpoly_init2(fmpq_mpoly_t A, slong alloc, const fmpq_mpoly_ctx_t ctx) + void fmpq_mpoly_init2(fmpq_mpoly_t A, slong alloc, const fmpq_mpoly_ctx_t ctx) noexcept # Initialise *A* for use with the given and initialised context object. Its value is set to zero. # It is allocated with space for *alloc* terms and at least ``MPOLY_MIN_BITS`` bits for the exponents. - void fmpq_mpoly_init3(fmpq_mpoly_t A, slong alloc, flint_bitcnt_t bits, const fmpq_mpoly_ctx_t ctx) + void fmpq_mpoly_init3(fmpq_mpoly_t A, slong alloc, flint_bitcnt_t bits, const fmpq_mpoly_ctx_t ctx) noexcept # Initialise *A* for use with the given and initialised context object. Its value is set to zero. # It is allocated with space for *alloc* terms and *bits* bits for the exponents. - void fmpq_mpoly_fit_length(fmpq_mpoly_t A, slong len, const fmpq_mpoly_ctx_t ctx) + void fmpq_mpoly_fit_length(fmpq_mpoly_t A, slong len, const fmpq_mpoly_ctx_t ctx) noexcept # Ensure that *A* has space for at least *len* terms. - void fmpq_mpoly_fit_bits(fmpq_mpoly_t A, flint_bitcnt_t bits, const fmpq_mpoly_ctx_t ctx) + void fmpq_mpoly_fit_bits(fmpq_mpoly_t A, flint_bitcnt_t bits, const fmpq_mpoly_ctx_t ctx) noexcept # Ensure that the exponent fields of *A* have at least *bits* bits. - void fmpq_mpoly_realloc(fmpq_mpoly_t A, slong alloc, const fmpq_mpoly_ctx_t ctx) + void fmpq_mpoly_realloc(fmpq_mpoly_t A, slong alloc, const fmpq_mpoly_ctx_t ctx) noexcept # Reallocate *A* to have space for *alloc* terms. # Assumes the current length of the polynomial is not greater than *alloc*. - void fmpq_mpoly_clear(fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx) + void fmpq_mpoly_clear(fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx) noexcept # Release any space allocated for *A*. - char * fmpq_mpoly_get_str_pretty(const fmpq_mpoly_t A, const char ** x, const fmpq_mpoly_ctx_t ctx) + char * fmpq_mpoly_get_str_pretty(const fmpq_mpoly_t A, const char ** x, const fmpq_mpoly_ctx_t ctx) noexcept # Return a string, which the user is responsible for cleaning up, representing *A*, given an array of variable strings ``x``. - int fmpq_mpoly_fprint_pretty(FILE * file, const fmpq_mpoly_t A, const char ** x, const fmpq_mpoly_ctx_t ctx) + int fmpq_mpoly_fprint_pretty(FILE * file, const fmpq_mpoly_t A, const char ** x, const fmpq_mpoly_ctx_t ctx) noexcept # Print a string representing *A* to *file*. - int fmpq_mpoly_print_pretty(const fmpq_mpoly_t A, const char ** x, const fmpq_mpoly_ctx_t ctx) + int fmpq_mpoly_print_pretty(const fmpq_mpoly_t A, const char ** x, const fmpq_mpoly_ctx_t ctx) noexcept # Print a string representing *A* to ``stdout``. - int fmpq_mpoly_set_str_pretty(fmpq_mpoly_t A, const char * str, const char ** x, const fmpq_mpoly_ctx_t ctx) + int fmpq_mpoly_set_str_pretty(fmpq_mpoly_t A, const char * str, const char ** x, const fmpq_mpoly_ctx_t ctx) noexcept # Set *A* to the polynomial in the null-terminates string ``str`` given an array ``x`` of variable strings. # If parsing ``str`` fails, *A* is set to zero, and `-1` is returned. Otherwise, `0` is returned. # The operations ``+``, ``-``, ``*``, and ``/`` are permitted along with integers and the variables in ``x``. The character ``^`` must be immediately followed by the (integer) exponent. # If any division is not exact, parsing fails. - void fmpq_mpoly_gen(fmpq_mpoly_t A, slong var, const fmpq_mpoly_ctx_t ctx) + void fmpq_mpoly_gen(fmpq_mpoly_t A, slong var, const fmpq_mpoly_ctx_t ctx) noexcept # Set *A* to the variable of index *var*, where ``var = 0`` corresponds to the variable with the most significance with respect to the ordering. - bint fmpq_mpoly_is_gen(const fmpq_mpoly_t A, slong var, const fmpq_mpoly_ctx_t ctx) + bint fmpq_mpoly_is_gen(const fmpq_mpoly_t A, slong var, const fmpq_mpoly_ctx_t ctx) noexcept # If `var \ge 0`, return `1` if *A* is equal to the `var`-th generator, otherwise return `0`. # If `var < 0`, return `1` if the polynomial is equal to any generator, otherwise return `0`. - void fmpq_mpoly_set(fmpq_mpoly_t A, const fmpq_mpoly_t B, const fmpq_mpoly_ctx_t ctx) + void fmpq_mpoly_set(fmpq_mpoly_t A, const fmpq_mpoly_t B, const fmpq_mpoly_ctx_t ctx) noexcept # Set *A* to *B*. - bint fmpq_mpoly_equal(const fmpq_mpoly_t A, const fmpq_mpoly_t B, const fmpq_mpoly_ctx_t ctx) + bint fmpq_mpoly_equal(const fmpq_mpoly_t A, const fmpq_mpoly_t B, const fmpq_mpoly_ctx_t ctx) noexcept # Return `1` if *A* is equal to *B*, else return `0`. - void fmpq_mpoly_swap(fmpq_mpoly_t A, fmpq_mpoly_t B, const fmpq_mpoly_ctx_t ctx) + void fmpq_mpoly_swap(fmpq_mpoly_t A, fmpq_mpoly_t B, const fmpq_mpoly_ctx_t ctx) noexcept # Efficiently swap *A* and *B*. - bint fmpq_mpoly_is_fmpq(const fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx) + bint fmpq_mpoly_is_fmpq(const fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx) noexcept # Return `1` if *A* is a constant, else return `0`. - void fmpq_mpoly_get_fmpq(fmpq_t c, const fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx) + void fmpq_mpoly_get_fmpq(fmpq_t c, const fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx) noexcept # Assuming that *A* is a constant, set *c* to this constant. # This function throws if *A* is not a constant. - void fmpq_mpoly_set_fmpq(fmpq_mpoly_t A, const fmpq_t c, const fmpq_mpoly_ctx_t ctx) - void fmpq_mpoly_set_fmpz(fmpq_mpoly_t A, const fmpz_t c, const fmpq_mpoly_ctx_t ctx) - void fmpq_mpoly_set_ui(fmpq_mpoly_t A, ulong c, const fmpq_mpoly_ctx_t ctx) - void fmpq_mpoly_set_si(fmpq_mpoly_t A, slong c, const fmpq_mpoly_ctx_t ctx) + void fmpq_mpoly_set_fmpq(fmpq_mpoly_t A, const fmpq_t c, const fmpq_mpoly_ctx_t ctx) noexcept + void fmpq_mpoly_set_fmpz(fmpq_mpoly_t A, const fmpz_t c, const fmpq_mpoly_ctx_t ctx) noexcept + void fmpq_mpoly_set_ui(fmpq_mpoly_t A, ulong c, const fmpq_mpoly_ctx_t ctx) noexcept + void fmpq_mpoly_set_si(fmpq_mpoly_t A, slong c, const fmpq_mpoly_ctx_t ctx) noexcept # Set *A* to the constant *c*. - void fmpq_mpoly_zero(fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx) + void fmpq_mpoly_zero(fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx) noexcept # Set *A* to the constant `0`. - void fmpq_mpoly_one(fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx) + void fmpq_mpoly_one(fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx) noexcept # Set *A* to the constant `1`. - bint fmpq_mpoly_equal_fmpq(const fmpq_mpoly_t A, const fmpq_t c, const fmpq_mpoly_ctx_t ctx) - bint fmpq_mpoly_equal_fmpz(const fmpq_mpoly_t A, const fmpz_t c, const fmpq_mpoly_ctx_t ctx) - bint fmpq_mpoly_equal_ui(const fmpq_mpoly_t A, ulong c, const fmpq_mpoly_ctx_t ctx) - bint fmpq_mpoly_equal_si(const fmpq_mpoly_t A, slong c, const fmpq_mpoly_ctx_t ctx) + bint fmpq_mpoly_equal_fmpq(const fmpq_mpoly_t A, const fmpq_t c, const fmpq_mpoly_ctx_t ctx) noexcept + bint fmpq_mpoly_equal_fmpz(const fmpq_mpoly_t A, const fmpz_t c, const fmpq_mpoly_ctx_t ctx) noexcept + bint fmpq_mpoly_equal_ui(const fmpq_mpoly_t A, ulong c, const fmpq_mpoly_ctx_t ctx) noexcept + bint fmpq_mpoly_equal_si(const fmpq_mpoly_t A, slong c, const fmpq_mpoly_ctx_t ctx) noexcept # Return `1` if *A* is equal to the constant *c*, else return `0`. - bint fmpq_mpoly_is_zero(const fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx) + bint fmpq_mpoly_is_zero(const fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx) noexcept # Return `1` if *A* is equal to the constant `0`, else return `0`. - bint fmpq_mpoly_is_one(const fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx) + bint fmpq_mpoly_is_one(const fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx) noexcept # Return `1` if *A* is equal to the constant `1`, else return `0`. - int fmpq_mpoly_degrees_fit_si(const fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx) + int fmpq_mpoly_degrees_fit_si(const fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx) noexcept # Return `1` if the degrees of *A* with respect to each variable fit into an ``slong``, otherwise return `0`. - void fmpq_mpoly_degrees_fmpz(fmpz ** degs, const fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx) - void fmpq_mpoly_degrees_si(slong * degs, const fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx) + void fmpq_mpoly_degrees_fmpz(fmpz ** degs, const fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx) noexcept + void fmpq_mpoly_degrees_si(slong * degs, const fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx) noexcept # Set *degs* to the degrees of *A* with respect to each variable. # If *A* is zero, all degrees are set to `-1`. - void fmpq_mpoly_degree_fmpz(fmpz_t deg, const fmpq_mpoly_t A, slong var, const fmpq_mpoly_ctx_t ctx) - slong fmpq_mpoly_degree_si(const fmpq_mpoly_t A, slong var, const fmpq_mpoly_ctx_t ctx) + void fmpq_mpoly_degree_fmpz(fmpz_t deg, const fmpq_mpoly_t A, slong var, const fmpq_mpoly_ctx_t ctx) noexcept + slong fmpq_mpoly_degree_si(const fmpq_mpoly_t A, slong var, const fmpq_mpoly_ctx_t ctx) noexcept # Either return or set *deg* to the degree of *A* with respect to the variable of index *var*. # If *A* is zero, the degree is defined to be `-1`. - int fmpq_mpoly_total_degree_fits_si(const fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx) + int fmpq_mpoly_total_degree_fits_si(const fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx) noexcept # Return `1` if the total degree of *A* fits into an ``slong``, otherwise return `0`. - void fmpq_mpoly_total_degree_fmpz(fmpz_t tdeg, const fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx) - slong fmpq_mpoly_total_degree_si(const fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx) + void fmpq_mpoly_total_degree_fmpz(fmpz_t tdeg, const fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx) noexcept + slong fmpq_mpoly_total_degree_si(const fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx) noexcept # Either return or set *tdeg* to the total degree of *A*. # If *A* is zero, the total degree is defined to be `-1`. - void fmpq_mpoly_used_vars(int * used, const fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx) + void fmpq_mpoly_used_vars(int * used, const fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx) noexcept # For each variable index *i*, set ``used[i]`` to nonzero if the variable of index *i* appears in *A* and to zero otherwise. - void fmpq_mpoly_get_denominator(fmpz_t d, const fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx) + void fmpq_mpoly_get_denominator(fmpz_t d, const fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx) noexcept # Set *d* to the denominator of *A*, the smallest positive integer `d` such that `d \times A` has integer coefficients. - void fmpq_mpoly_get_coeff_fmpq_monomial(fmpq_t c, const fmpq_mpoly_t A, const fmpq_mpoly_t M, const fmpq_mpoly_ctx_t ctx) + void fmpq_mpoly_get_coeff_fmpq_monomial(fmpq_t c, const fmpq_mpoly_t A, const fmpq_mpoly_t M, const fmpq_mpoly_ctx_t ctx) noexcept # Assuming that *M* is a monomial, set *c* to the coefficient of the corresponding monomial in *A*. # This function throws if *M* is not a monomial. - void fmpq_mpoly_set_coeff_fmpq_monomial(fmpq_mpoly_t A, const fmpq_t c, const fmpq_mpoly_t M, const fmpq_mpoly_ctx_t ctx) + void fmpq_mpoly_set_coeff_fmpq_monomial(fmpq_mpoly_t A, const fmpq_t c, const fmpq_mpoly_t M, const fmpq_mpoly_ctx_t ctx) noexcept # Assuming that *M* is a monomial, set the coefficient of the corresponding monomial in *A* to *c*. # This function throws if *M* is not a monomial. - void fmpq_mpoly_get_coeff_fmpq_fmpz(fmpq_t c, const fmpq_mpoly_t A, fmpz * const * exp, const fmpq_mpoly_ctx_t ctx) - void fmpq_mpoly_get_coeff_fmpq_ui(fmpq_t c, const fmpq_mpoly_t A, const ulong * exp, const fmpq_mpoly_ctx_t ctx) + void fmpq_mpoly_get_coeff_fmpq_fmpz(fmpq_t c, const fmpq_mpoly_t A, fmpz * const * exp, const fmpq_mpoly_ctx_t ctx) noexcept + void fmpq_mpoly_get_coeff_fmpq_ui(fmpq_t c, const fmpq_mpoly_t A, const ulong * exp, const fmpq_mpoly_ctx_t ctx) noexcept # Set *c* to the coefficient of the monomial with exponent *exp*. - void fmpq_mpoly_set_coeff_fmpq_fmpz(fmpq_mpoly_t A, const fmpq_t c, fmpz * const * exp, const fmpq_mpoly_ctx_t ctx) - void fmpq_mpoly_set_coeff_fmpq_ui(fmpq_mpoly_t A, const fmpq_t c, const ulong * exp, const fmpq_mpoly_ctx_t ctx) + void fmpq_mpoly_set_coeff_fmpq_fmpz(fmpq_mpoly_t A, const fmpq_t c, fmpz * const * exp, const fmpq_mpoly_ctx_t ctx) noexcept + void fmpq_mpoly_set_coeff_fmpq_ui(fmpq_mpoly_t A, const fmpq_t c, const ulong * exp, const fmpq_mpoly_ctx_t ctx) noexcept # Set the coefficient of the monomial with exponent *exp* to *c*. - void fmpq_mpoly_get_coeff_vars_ui(fmpq_mpoly_t C, const fmpq_mpoly_t A, const slong * vars, const ulong * exps, slong length, const fmpq_mpoly_ctx_t ctx) + void fmpq_mpoly_get_coeff_vars_ui(fmpq_mpoly_t C, const fmpq_mpoly_t A, const slong * vars, const ulong * exps, slong length, const fmpq_mpoly_ctx_t ctx) noexcept # Set *C* to the coefficient of *A* with respect to the variables in *vars* with powers in the corresponding array *exps*. # Both *vars* and *exps* point to array of length *length*. It is assumed that `0 < length \le nvars(A)` and that the variables in *vars* are distinct. - int fmpq_mpoly_cmp(const fmpq_mpoly_t A, const fmpq_mpoly_t B, const fmpq_mpoly_ctx_t ctx) + int fmpq_mpoly_cmp(const fmpq_mpoly_t A, const fmpq_mpoly_t B, const fmpq_mpoly_ctx_t ctx) noexcept # Return `1` (resp. `-1`, or `0`) if *A* is after (resp. before, same as) *B* in some arbitrary but fixed total ordering of the polynomials. # This ordering agrees with the usual ordering of monomials when *A* and *B* are both monomials. - fmpq * fmpq_mpoly_content_ref(fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx) + fmpq * fmpq_mpoly_content_ref(fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx) noexcept # Return a reference to the content of *A*. - fmpz_mpoly_struct * fmpq_mpoly_zpoly_ref(fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx) + fmpz_mpoly_struct * fmpq_mpoly_zpoly_ref(fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx) noexcept # Return a reference to the integer polynomial of *A*. - fmpz * fmpq_mpoly_zpoly_term_coeff_ref(fmpq_mpoly_t A, slong i, const fmpq_mpoly_ctx_t ctx) + fmpz * fmpq_mpoly_zpoly_term_coeff_ref(fmpq_mpoly_t A, slong i, const fmpq_mpoly_ctx_t ctx) noexcept # Return a reference to the coefficient of index *i* of the integer polynomial of *A*. - bint fmpq_mpoly_is_canonical(const fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx) + bint fmpq_mpoly_is_canonical(const fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx) noexcept # Return `1` if *A* is in canonical form. Otherwise, return `0`. # An ``fmpq_mpoly_t`` is represented as the product of an ``fmpq_t content`` and an ``fmpz_mpoly_t zpoly``. # The representation is considered canonical when either @@ -179,244 +179,244 @@ cdef extern from "flint_wrap.h": # (2) both ``content`` and ``zpoly`` are nonzero and canonical and ``zpoly`` is reduced. # A nonzero ``zpoly`` is considered reduced when the coefficients have GCD one and the leading coefficient is positive. - slong fmpq_mpoly_length(const fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx) + slong fmpq_mpoly_length(const fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx) noexcept # Return the number of terms stored in *A*. # If the polynomial is in canonical form, this will be the number of nonzero coefficients. - void fmpq_mpoly_resize(fmpq_mpoly_t A, slong new_length, const fmpq_mpoly_ctx_t ctx) + void fmpq_mpoly_resize(fmpq_mpoly_t A, slong new_length, const fmpq_mpoly_ctx_t ctx) noexcept # Set the length of *A* to ``new_length``. # Terms are either deleted from the end, or new zero terms are appended. - void fmpq_mpoly_get_term_coeff_fmpq(fmpq_t c, const fmpq_mpoly_t A, slong i, const fmpq_mpoly_ctx_t ctx) + void fmpq_mpoly_get_term_coeff_fmpq(fmpq_t c, const fmpq_mpoly_t A, slong i, const fmpq_mpoly_ctx_t ctx) noexcept # Set *c* to coefficient of index *i* - void fmpq_mpoly_set_term_coeff_fmpq(fmpq_mpoly_t A, slong i, const fmpq_t c, const fmpq_mpoly_ctx_t ctx) + void fmpq_mpoly_set_term_coeff_fmpq(fmpq_mpoly_t A, slong i, const fmpq_t c, const fmpq_mpoly_ctx_t ctx) noexcept # Set the coefficient of index *i* to *c*. - int fmpq_mpoly_term_exp_fits_si(const fmpq_mpoly_t A, slong i, const fmpq_mpoly_ctx_t ctx) - int fmpq_mpoly_term_exp_fits_ui(const fmpq_mpoly_t A, slong i, const fmpq_mpoly_ctx_t ctx) + int fmpq_mpoly_term_exp_fits_si(const fmpq_mpoly_t A, slong i, const fmpq_mpoly_ctx_t ctx) noexcept + int fmpq_mpoly_term_exp_fits_ui(const fmpq_mpoly_t A, slong i, const fmpq_mpoly_ctx_t ctx) noexcept # Return `1` if all entries of the exponent vector of the term of index *i* fit into an ``slong`` (resp. a ``ulong``). Otherwise, return `0`. - void fmpq_mpoly_get_term_exp_fmpz(fmpz ** exps, const fmpq_mpoly_t A, slong i, const fmpq_mpoly_ctx_t ctx) - void fmpq_mpoly_get_term_exp_ui(ulong * exps, const fmpq_mpoly_t A, slong i, const fmpq_mpoly_ctx_t ctx) - void fmpq_mpoly_get_term_exp_si(slong * exps, const fmpq_mpoly_t A, slong i, const fmpq_mpoly_ctx_t ctx) + void fmpq_mpoly_get_term_exp_fmpz(fmpz ** exps, const fmpq_mpoly_t A, slong i, const fmpq_mpoly_ctx_t ctx) noexcept + void fmpq_mpoly_get_term_exp_ui(ulong * exps, const fmpq_mpoly_t A, slong i, const fmpq_mpoly_ctx_t ctx) noexcept + void fmpq_mpoly_get_term_exp_si(slong * exps, const fmpq_mpoly_t A, slong i, const fmpq_mpoly_ctx_t ctx) noexcept # Set *exp* to the exponent vector of the term of index *i*. # The ``_ui`` (resp. ``_si``) version throws if any entry does not fit into a ``ulong`` (resp. ``slong``). - ulong fmpq_mpoly_get_term_var_exp_ui(const fmpq_mpoly_t A, slong i, slong var, const fmpq_mpoly_ctx_t ctx) - slong fmpq_mpoly_get_term_var_exp_si(const fmpq_mpoly_t A, slong i, slong var, const fmpq_mpoly_ctx_t ctx) + ulong fmpq_mpoly_get_term_var_exp_ui(const fmpq_mpoly_t A, slong i, slong var, const fmpq_mpoly_ctx_t ctx) noexcept + slong fmpq_mpoly_get_term_var_exp_si(const fmpq_mpoly_t A, slong i, slong var, const fmpq_mpoly_ctx_t ctx) noexcept # Return the exponent of the variable *var* of the term of index *i*. # This function throws if the exponent does not fit into a ``ulong`` (resp. ``slong``). - void fmpq_mpoly_set_term_exp_fmpz(fmpq_mpoly_t A, slong i, fmpz * const * exps, const fmpq_mpoly_ctx_t ctx) - void fmpq_mpoly_set_term_exp_ui(fmpq_mpoly_t A, slong i, const ulong * exps, const fmpq_mpoly_ctx_t ctx) + void fmpq_mpoly_set_term_exp_fmpz(fmpq_mpoly_t A, slong i, fmpz * const * exps, const fmpq_mpoly_ctx_t ctx) noexcept + void fmpq_mpoly_set_term_exp_ui(fmpq_mpoly_t A, slong i, const ulong * exps, const fmpq_mpoly_ctx_t ctx) noexcept # Set the exponent vector of the term of index *i* to *exp*. - void fmpq_mpoly_get_term(fmpq_mpoly_t M, const fmpq_mpoly_t A, slong i, const fmpq_mpoly_ctx_t ctx) + void fmpq_mpoly_get_term(fmpq_mpoly_t M, const fmpq_mpoly_t A, slong i, const fmpq_mpoly_ctx_t ctx) noexcept # Set *M* to the term of index *i* in *A*. - void fmpq_mpoly_get_term_monomial(fmpq_mpoly_t M, const fmpq_mpoly_t A, slong i, const fmpq_mpoly_ctx_t ctx) + void fmpq_mpoly_get_term_monomial(fmpq_mpoly_t M, const fmpq_mpoly_t A, slong i, const fmpq_mpoly_ctx_t ctx) noexcept # Set *M* to the monomial of the term of index *i* in *A*. The coefficient of *M* will be one. - void fmpq_mpoly_push_term_fmpq_fmpz(fmpq_mpoly_t A, const fmpq_t c, fmpz * const * exp, const fmpq_mpoly_ctx_t ctx) - void fmpq_mpoly_push_term_fmpq_ffmpz(fmpq_mpoly_t A, const fmpq_t c, const fmpz * exp, const fmpq_mpoly_ctx_t ctx) - void fmpq_mpoly_push_term_fmpz_fmpz(fmpq_mpoly_t A, const fmpz_t c, fmpz * const * exp, const fmpq_mpoly_ctx_t ctx) - void fmpq_mpoly_push_term_fmpz_ffmpz(fmpq_mpoly_t A, const fmpz_t c, const fmpz * exp, const fmpq_mpoly_ctx_t ctx) - void fmpq_mpoly_push_term_ui_fmpz(fmpq_mpoly_t A, ulong c, fmpz * const * exp, const fmpq_mpoly_ctx_t ctx) - void fmpq_mpoly_push_term_ui_ffmpz(fmpq_mpoly_t A, ulong c, const fmpz * exp, const fmpq_mpoly_ctx_t ctx) - void fmpq_mpoly_push_term_si_fmpz(fmpq_mpoly_t A, slong c, fmpz * const * exp, const fmpq_mpoly_ctx_t ctx) - void fmpq_mpoly_push_term_si_ffmpz(fmpq_mpoly_t A, slong c, const fmpz * exp, const fmpq_mpoly_ctx_t ctx) - void fmpq_mpoly_push_term_fmpq_ui(fmpq_mpoly_t A, const fmpq_t c, const ulong * exp, const fmpq_mpoly_ctx_t ctx) - void fmpq_mpoly_push_term_fmpz_ui(fmpq_mpoly_t A, const fmpz_t c, const ulong * exp, const fmpq_mpoly_ctx_t ctx) - void fmpq_mpoly_push_term_ui_ui(fmpq_mpoly_t A, ulong c, const ulong * exp, const fmpq_mpoly_ctx_t ctx) - void fmpq_mpoly_push_term_si_ui(fmpq_mpoly_t A, slong c, const ulong * exp, const fmpq_mpoly_ctx_t ctx) + void fmpq_mpoly_push_term_fmpq_fmpz(fmpq_mpoly_t A, const fmpq_t c, fmpz * const * exp, const fmpq_mpoly_ctx_t ctx) noexcept + void fmpq_mpoly_push_term_fmpq_ffmpz(fmpq_mpoly_t A, const fmpq_t c, const fmpz * exp, const fmpq_mpoly_ctx_t ctx) noexcept + void fmpq_mpoly_push_term_fmpz_fmpz(fmpq_mpoly_t A, const fmpz_t c, fmpz * const * exp, const fmpq_mpoly_ctx_t ctx) noexcept + void fmpq_mpoly_push_term_fmpz_ffmpz(fmpq_mpoly_t A, const fmpz_t c, const fmpz * exp, const fmpq_mpoly_ctx_t ctx) noexcept + void fmpq_mpoly_push_term_ui_fmpz(fmpq_mpoly_t A, ulong c, fmpz * const * exp, const fmpq_mpoly_ctx_t ctx) noexcept + void fmpq_mpoly_push_term_ui_ffmpz(fmpq_mpoly_t A, ulong c, const fmpz * exp, const fmpq_mpoly_ctx_t ctx) noexcept + void fmpq_mpoly_push_term_si_fmpz(fmpq_mpoly_t A, slong c, fmpz * const * exp, const fmpq_mpoly_ctx_t ctx) noexcept + void fmpq_mpoly_push_term_si_ffmpz(fmpq_mpoly_t A, slong c, const fmpz * exp, const fmpq_mpoly_ctx_t ctx) noexcept + void fmpq_mpoly_push_term_fmpq_ui(fmpq_mpoly_t A, const fmpq_t c, const ulong * exp, const fmpq_mpoly_ctx_t ctx) noexcept + void fmpq_mpoly_push_term_fmpz_ui(fmpq_mpoly_t A, const fmpz_t c, const ulong * exp, const fmpq_mpoly_ctx_t ctx) noexcept + void fmpq_mpoly_push_term_ui_ui(fmpq_mpoly_t A, ulong c, const ulong * exp, const fmpq_mpoly_ctx_t ctx) noexcept + void fmpq_mpoly_push_term_si_ui(fmpq_mpoly_t A, slong c, const ulong * exp, const fmpq_mpoly_ctx_t ctx) noexcept # Append a term to *A* with coefficient *c* and exponent vector *exp*. # This function should run in constant average time if the terms pushed have bounded denominator. - void fmpq_mpoly_reduce(fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx) + void fmpq_mpoly_reduce(fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx) noexcept # Factor out necessary content from ``A->zpoly`` so that it is reduced. # If the terms of *A* were nonzero and sorted with distinct exponents to begin with, the result will be in canonical form. - void fmpq_mpoly_sort_terms(fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx) + void fmpq_mpoly_sort_terms(fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx) noexcept # Sort the internal ``A->zpoly`` into the canonical ordering dictated by the ordering in *ctx*. # This function does not combine like terms, nor does it delete terms with coefficient zero, nor does it reduce. - void fmpq_mpoly_combine_like_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) noexcept # Combine adjacent like terms in the internal ``A->zpoly`` and then factor out content via a call to :func:`fmpq_mpoly_reduce`. # If the terms of *A* were sorted to begin with, the result will be in canonical form. - void fmpq_mpoly_reverse(fmpq_mpoly_t A, const fmpq_mpoly_t B, 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) noexcept # Set *A* to the reversal of *B*. - 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_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) noexcept # Generate a random polynomial with length up to *length* and exponents in the range ``[0, exp_bound - 1]``. # The exponents of each variable are generated by calls to ``n_randint(state, exp_bound)``. - 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_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) noexcept # Generate a random polynomial with length up to *length* and exponents in the range ``[0, exp_bounds[i] - 1]``. # The exponents of the variable of index *i* are generated by calls to ``n_randint(state, exp_bounds[i])``. - 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_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) noexcept # Generate a random polynomial with length up to *length* and exponents whose packed form does not exceed the given bit count. # The parameter ``coeff_bits`` to the three functions ``fmpq_mpoly_randtest_{bound|bounds|bits}`` is merely a suggestion for the approximate bit count of the resulting coefficients. - 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) - void fmpq_mpoly_add_si(fmpq_mpoly_t A, const fmpq_mpoly_t B, slong c, 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) noexcept + void fmpq_mpoly_add_fmpz(fmpq_mpoly_t A, const fmpq_mpoly_t B, const fmpz_t c, const fmpq_mpoly_ctx_t ctx) noexcept + void fmpq_mpoly_add_ui(fmpq_mpoly_t A, const fmpq_mpoly_t B, ulong c, const fmpq_mpoly_ctx_t ctx) noexcept + void fmpq_mpoly_add_si(fmpq_mpoly_t A, const fmpq_mpoly_t B, slong c, const fmpq_mpoly_ctx_t ctx) noexcept # Set *A* to `B + c`. - void fmpq_mpoly_sub_fmpq(fmpq_mpoly_t A, const fmpq_mpoly_t B, const fmpq_t c, const fmpq_mpoly_ctx_t ctx) - void fmpq_mpoly_sub_fmpz(fmpq_mpoly_t A, const fmpq_mpoly_t B, const fmpz_t c, const fmpq_mpoly_ctx_t ctx) - void fmpq_mpoly_sub_ui(fmpq_mpoly_t A, const fmpq_mpoly_t B, ulong c, const fmpq_mpoly_ctx_t ctx) - void fmpq_mpoly_sub_si(fmpq_mpoly_t A, const fmpq_mpoly_t B, slong c, const fmpq_mpoly_ctx_t ctx) + void fmpq_mpoly_sub_fmpq(fmpq_mpoly_t A, const fmpq_mpoly_t B, const fmpq_t c, const fmpq_mpoly_ctx_t ctx) noexcept + void fmpq_mpoly_sub_fmpz(fmpq_mpoly_t A, const fmpq_mpoly_t B, const fmpz_t c, const fmpq_mpoly_ctx_t ctx) noexcept + void fmpq_mpoly_sub_ui(fmpq_mpoly_t A, const fmpq_mpoly_t B, ulong c, const fmpq_mpoly_ctx_t ctx) noexcept + void fmpq_mpoly_sub_si(fmpq_mpoly_t A, const fmpq_mpoly_t B, slong c, const fmpq_mpoly_ctx_t ctx) noexcept # Set *A* to `B - c`. - void fmpq_mpoly_add(fmpq_mpoly_t A, const fmpq_mpoly_t B, const fmpq_mpoly_t C, const fmpq_mpoly_ctx_t ctx) + void fmpq_mpoly_add(fmpq_mpoly_t A, const fmpq_mpoly_t B, const fmpq_mpoly_t C, const fmpq_mpoly_ctx_t ctx) noexcept # Set *A* to `B + C`. - void fmpq_mpoly_sub(fmpq_mpoly_t A, const fmpq_mpoly_t B, const fmpq_mpoly_t C, const fmpq_mpoly_ctx_t ctx) + void fmpq_mpoly_sub(fmpq_mpoly_t A, const fmpq_mpoly_t B, const fmpq_mpoly_t C, const fmpq_mpoly_ctx_t ctx) noexcept # Set *A* to `B - C`. - void fmpq_mpoly_neg(fmpq_mpoly_t A, const fmpq_mpoly_t B, const fmpq_mpoly_ctx_t ctx) + void fmpq_mpoly_neg(fmpq_mpoly_t A, const fmpq_mpoly_t B, const fmpq_mpoly_ctx_t ctx) noexcept # Set *A* to `-B`. - void fmpq_mpoly_scalar_mul_fmpq(fmpq_mpoly_t A, const fmpq_mpoly_t B, const fmpq_t c, const fmpq_mpoly_ctx_t ctx) - void fmpq_mpoly_scalar_mul_fmpz(fmpq_mpoly_t A, const fmpq_mpoly_t B, const fmpz_t c, const fmpq_mpoly_ctx_t ctx) - void fmpq_mpoly_scalar_mul_ui(fmpq_mpoly_t A, const fmpq_mpoly_t B, ulong c, const fmpq_mpoly_ctx_t ctx) - void fmpq_mpoly_scalar_mul_si(fmpq_mpoly_t A, const fmpq_mpoly_t B, slong c, const fmpq_mpoly_ctx_t ctx) + void fmpq_mpoly_scalar_mul_fmpq(fmpq_mpoly_t A, const fmpq_mpoly_t B, const fmpq_t c, const fmpq_mpoly_ctx_t ctx) noexcept + void fmpq_mpoly_scalar_mul_fmpz(fmpq_mpoly_t A, const fmpq_mpoly_t B, const fmpz_t c, const fmpq_mpoly_ctx_t ctx) noexcept + void fmpq_mpoly_scalar_mul_ui(fmpq_mpoly_t A, const fmpq_mpoly_t B, ulong c, const fmpq_mpoly_ctx_t ctx) noexcept + void fmpq_mpoly_scalar_mul_si(fmpq_mpoly_t A, const fmpq_mpoly_t B, slong c, const fmpq_mpoly_ctx_t ctx) noexcept # Set *A* to `B \times c`. - void fmpq_mpoly_scalar_div_fmpq(fmpq_mpoly_t A, const fmpq_mpoly_t B, const fmpq_t c, const fmpq_mpoly_ctx_t ctx) - void fmpq_mpoly_scalar_div_fmpz(fmpq_mpoly_t A, const fmpq_mpoly_t B, const fmpz_t c, const fmpq_mpoly_ctx_t ctx) - void fmpq_mpoly_scalar_div_ui(fmpq_mpoly_t A, const fmpq_mpoly_t B, ulong c, const fmpq_mpoly_ctx_t ctx) - void fmpq_mpoly_scalar_div_si(fmpq_mpoly_t A, const fmpq_mpoly_t B, slong c, const fmpq_mpoly_ctx_t ctx) + void fmpq_mpoly_scalar_div_fmpq(fmpq_mpoly_t A, const fmpq_mpoly_t B, const fmpq_t c, const fmpq_mpoly_ctx_t ctx) noexcept + void fmpq_mpoly_scalar_div_fmpz(fmpq_mpoly_t A, const fmpq_mpoly_t B, const fmpz_t c, const fmpq_mpoly_ctx_t ctx) noexcept + void fmpq_mpoly_scalar_div_ui(fmpq_mpoly_t A, const fmpq_mpoly_t B, ulong c, const fmpq_mpoly_ctx_t ctx) noexcept + void fmpq_mpoly_scalar_div_si(fmpq_mpoly_t A, const fmpq_mpoly_t B, slong c, const fmpq_mpoly_ctx_t ctx) noexcept # Set *A* to `B/c`. - void fmpq_mpoly_make_monic(fmpq_mpoly_t A, const fmpq_mpoly_t B, const fmpq_mpoly_ctx_t ctx) + void fmpq_mpoly_make_monic(fmpq_mpoly_t A, const fmpq_mpoly_t B, const fmpq_mpoly_ctx_t ctx) noexcept # Set *A* to *B* divided by the leading coefficient of *B*. # This throws if *B* is zero. # All of these functions run quickly if *A* and *B* are aliased. - void fmpq_mpoly_derivative(fmpq_mpoly_t A, const fmpq_mpoly_t B, slong var, const fmpq_mpoly_ctx_t ctx) + void fmpq_mpoly_derivative(fmpq_mpoly_t A, const fmpq_mpoly_t B, slong var, const fmpq_mpoly_ctx_t ctx) noexcept # Set *A* to the derivative of *B* with respect to the variable of index *var*. - void fmpq_mpoly_integral(fmpq_mpoly_t A, const fmpq_mpoly_t B, slong var, const fmpq_mpoly_ctx_t ctx) + void fmpq_mpoly_integral(fmpq_mpoly_t A, const fmpq_mpoly_t B, slong var, const fmpq_mpoly_ctx_t ctx) noexcept # Set *A* to the integral with the fewest number of terms of *B* with respect to the variable of index *var*. - int fmpq_mpoly_evaluate_all_fmpq(fmpq_t ev, const fmpq_mpoly_t A, fmpq * const * vals, const fmpq_mpoly_ctx_t ctx) + int fmpq_mpoly_evaluate_all_fmpq(fmpq_t ev, const fmpq_mpoly_t A, fmpq * const * vals, const fmpq_mpoly_ctx_t ctx) noexcept # Set ``ev`` to the evaluation of *A* where the variables are replaced by the corresponding elements of the array ``vals``. # Return `1` for success and `0` for failure. - int fmpq_mpoly_evaluate_one_fmpq(fmpq_mpoly_t A, const fmpq_mpoly_t B, slong var, const fmpq_t val, const fmpq_mpoly_ctx_t ctx) + int fmpq_mpoly_evaluate_one_fmpq(fmpq_mpoly_t A, const fmpq_mpoly_t B, slong var, const fmpq_t val, const fmpq_mpoly_ctx_t ctx) noexcept # Set *A* to the evaluation of *B* where the variable of index *var* is replaced by ``val``. # Return `1` for success and `0` for failure. - int fmpq_mpoly_compose_fmpq_poly(fmpq_poly_t A, const fmpq_mpoly_t B, fmpq_poly_struct * const * C, const fmpq_mpoly_ctx_t ctxB) + int fmpq_mpoly_compose_fmpq_poly(fmpq_poly_t A, const fmpq_mpoly_t B, fmpq_poly_struct * const * C, const fmpq_mpoly_ctx_t ctxB) noexcept # Set *A* to the evaluation of *B* where the variables are replaced by the corresponding elements of the array *C*. # The context object of *B* is *ctxB*. # Return `1` for success and `0` for failure. - int fmpq_mpoly_compose_fmpq_mpoly(fmpq_mpoly_t A, const fmpq_mpoly_t B, fmpq_mpoly_struct * const * C, const fmpq_mpoly_ctx_t ctxB, const fmpq_mpoly_ctx_t ctxAC) + int fmpq_mpoly_compose_fmpq_mpoly(fmpq_mpoly_t A, const fmpq_mpoly_t B, fmpq_mpoly_struct * const * C, const fmpq_mpoly_ctx_t ctxB, const fmpq_mpoly_ctx_t ctxAC) noexcept # Set *A* to the evaluation of *B* where the variables are replaced by the corresponding elements of the array *C*. # Both *A* and the elements of *C* have context object *ctxAC*, while *B* has context object *ctxB*. # Neither *A* nor *B* is allowed to alias any other polynomial. # Return `1` for success and `0` for failure. - void fmpq_mpoly_compose_fmpq_mpoly_gen(fmpq_mpoly_t A, const fmpq_mpoly_t B, const slong * c, const fmpq_mpoly_ctx_t ctxB, const fmpq_mpoly_ctx_t ctxAC) + void fmpq_mpoly_compose_fmpq_mpoly_gen(fmpq_mpoly_t A, const fmpq_mpoly_t B, const slong * c, const fmpq_mpoly_ctx_t ctxB, const fmpq_mpoly_ctx_t ctxAC) noexcept # Set *A* to the evaluation of *B* where the variable of index *i* in *ctxB* is replaced by the variable of index ``c[i]`` in *ctxAC*. # The length of the array *C* is the number of variables in *ctxB*. # If any ``c[i]`` is negative, the corresponding variable of *B* is replaced by zero. Otherwise, it is expected that ``c[i]`` is less than the number of variables in *ctxAC*. - void fmpq_mpoly_mul(fmpq_mpoly_t A, const fmpq_mpoly_t B, const fmpq_mpoly_t C, const fmpq_mpoly_ctx_t ctx) + void fmpq_mpoly_mul(fmpq_mpoly_t A, const fmpq_mpoly_t B, const fmpq_mpoly_t C, const fmpq_mpoly_ctx_t ctx) noexcept # Set *A* to `B \times C`. - int fmpq_mpoly_pow_fmpz(fmpq_mpoly_t A, const fmpq_mpoly_t B, const fmpz_t k, const fmpq_mpoly_ctx_t ctx) + int fmpq_mpoly_pow_fmpz(fmpq_mpoly_t A, const fmpq_mpoly_t B, const fmpz_t k, const fmpq_mpoly_ctx_t ctx) noexcept # Set *A* to *B* raised to the *k*-th power. # Return `1` for success and `0` for failure. - int fmpq_mpoly_pow_ui(fmpq_mpoly_t A, const fmpq_mpoly_t B, ulong k, const fmpq_mpoly_ctx_t ctx) + int fmpq_mpoly_pow_ui(fmpq_mpoly_t A, const fmpq_mpoly_t B, ulong k, const fmpq_mpoly_ctx_t ctx) noexcept # Set *A* to *B* raised to the *k*-th power. # Return `1` for success and `0` for failure. - int fmpq_mpoly_divides(fmpq_mpoly_t Q, const fmpq_mpoly_t A, const fmpq_mpoly_t B, const fmpq_mpoly_ctx_t ctx) + int fmpq_mpoly_divides(fmpq_mpoly_t Q, const fmpq_mpoly_t A, const fmpq_mpoly_t B, const fmpq_mpoly_ctx_t ctx) noexcept # If *A* is divisible by *B*, set *Q* to the exact quotient and return `1`. Otherwise, set *Q* to zero and return `0`. # Note that the function :func:`fmpq_mpoly_div` may be faster if the quotient is known to be exact. - void fmpq_mpoly_div(fmpq_mpoly_t Q, const fmpq_mpoly_t A, const fmpq_mpoly_t B, const fmpq_mpoly_ctx_t ctx) + void fmpq_mpoly_div(fmpq_mpoly_t Q, const fmpq_mpoly_t A, const fmpq_mpoly_t B, const fmpq_mpoly_ctx_t ctx) noexcept # Set *Q* to the quotient of *A* by *B*, discarding the remainder. - void fmpq_mpoly_divrem(fmpq_mpoly_t Q, fmpq_mpoly_t R, const fmpq_mpoly_t A, const fmpq_mpoly_t B, const fmpq_mpoly_ctx_t ctx) + void fmpq_mpoly_divrem(fmpq_mpoly_t Q, fmpq_mpoly_t R, const fmpq_mpoly_t A, const fmpq_mpoly_t B, const fmpq_mpoly_ctx_t ctx) noexcept # Set *Q* and *R* to the quotient and remainder of *A* divided by *B*. - void fmpq_mpoly_divrem_ideal(fmpq_mpoly_struct ** Q, fmpq_mpoly_t R, const fmpq_mpoly_t A, fmpq_mpoly_struct * const * B, slong len, const fmpq_mpoly_ctx_t ctx) + void fmpq_mpoly_divrem_ideal(fmpq_mpoly_struct ** Q, fmpq_mpoly_t R, const fmpq_mpoly_t A, fmpq_mpoly_struct * const * B, slong len, const fmpq_mpoly_ctx_t ctx) noexcept # This function is as per :func:`fmpq_mpoly_divrem` except that it takes an array of divisor polynomials *B* and it returns an array of quotient polynomials *Q*. # The number of divisor (and hence quotient) polynomials is given by *len*. - void fmpq_mpoly_content(fmpq_t g, const fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx) + void fmpq_mpoly_content(fmpq_t g, const fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx) noexcept # Set *g* to the (nonnegative) gcd of the coefficients of *A*. - void fmpq_mpoly_term_content(fmpq_mpoly_t M, const fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx) + void fmpq_mpoly_term_content(fmpq_mpoly_t M, const fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx) noexcept # Set *M* to the GCD of the terms of *A*. # If *A* is zero, *M* will be zero. Otherwise, *M* will be a monomial with coefficient one. - int fmpq_mpoly_content_vars(fmpq_mpoly_t g, const fmpq_mpoly_t A, slong * vars, slong vars_length, const fmpq_mpoly_ctx_t ctx) + int fmpq_mpoly_content_vars(fmpq_mpoly_t g, const fmpq_mpoly_t A, slong * vars, slong vars_length, const fmpq_mpoly_ctx_t ctx) noexcept # Set *g* to the GCD of the coefficients of *A* when viewed as a polynomial in the variables *vars*. # Return `1` for success and `0` for failure. Upon success, *g* will be independent of the variables *vars*. - int fmpq_mpoly_gcd(fmpq_mpoly_t G, const fmpq_mpoly_t A, const fmpq_mpoly_t B, const fmpq_mpoly_ctx_t ctx) + int fmpq_mpoly_gcd(fmpq_mpoly_t G, const fmpq_mpoly_t A, const fmpq_mpoly_t B, const fmpq_mpoly_ctx_t ctx) noexcept # Try to set *G* to the monic GCD of *A* and *B*. The GCD of zero and zero is defined to be zero. # If the return is `1` the function was successful. Otherwise the return is `0` and *G* is left untouched. - int fmpq_mpoly_gcd_cofactors(fmpq_mpoly_t G, fmpq_mpoly_t Abar, fmpq_mpoly_t Bbar, const fmpq_mpoly_t A, const fmpq_mpoly_t B, const fmpq_mpoly_ctx_t ctx) + int fmpq_mpoly_gcd_cofactors(fmpq_mpoly_t G, fmpq_mpoly_t Abar, fmpq_mpoly_t Bbar, const fmpq_mpoly_t A, const fmpq_mpoly_t B, const fmpq_mpoly_ctx_t ctx) noexcept # Do the operation of :func:`fmpq_mpoly_gcd` and also compute `Abar = A/G` and `Bbar = B/G` if successful. - int fmpq_mpoly_gcd_brown(fmpq_mpoly_t G, const fmpq_mpoly_t A, const fmpq_mpoly_t B, const fmpq_mpoly_ctx_t ctx) - int fmpq_mpoly_gcd_hensel(fmpq_mpoly_t G, const fmpq_mpoly_t A, const fmpq_mpoly_t B, const fmpq_mpoly_ctx_t ctx) - int fmpq_mpoly_gcd_subresultant(fmpq_mpoly_t G, const fmpq_mpoly_t A, const fmpq_mpoly_t B, const fmpq_mpoly_ctx_t ctx) - int fmpq_mpoly_gcd_zippel(fmpq_mpoly_t G, const fmpq_mpoly_t A, const fmpq_mpoly_t B, const fmpq_mpoly_ctx_t ctx) - int fmpq_mpoly_gcd_zippel2(fmpq_mpoly_t G, const fmpq_mpoly_t A, const fmpq_mpoly_t B, const fmpq_mpoly_ctx_t ctx) + int fmpq_mpoly_gcd_brown(fmpq_mpoly_t G, const fmpq_mpoly_t A, const fmpq_mpoly_t B, const fmpq_mpoly_ctx_t ctx) noexcept + int fmpq_mpoly_gcd_hensel(fmpq_mpoly_t G, const fmpq_mpoly_t A, const fmpq_mpoly_t B, const fmpq_mpoly_ctx_t ctx) noexcept + int fmpq_mpoly_gcd_subresultant(fmpq_mpoly_t G, const fmpq_mpoly_t A, const fmpq_mpoly_t B, const fmpq_mpoly_ctx_t ctx) noexcept + int fmpq_mpoly_gcd_zippel(fmpq_mpoly_t G, const fmpq_mpoly_t A, const fmpq_mpoly_t B, const fmpq_mpoly_ctx_t ctx) noexcept + int fmpq_mpoly_gcd_zippel2(fmpq_mpoly_t G, const fmpq_mpoly_t A, const fmpq_mpoly_t B, const fmpq_mpoly_ctx_t ctx) noexcept # Try to set *G* to the GCD of *A* and *B* using various algorithms. - int fmpq_mpoly_resultant(fmpq_mpoly_t R, const fmpq_mpoly_t A, const fmpq_mpoly_t B, slong var, const fmpq_mpoly_ctx_t ctx) + int fmpq_mpoly_resultant(fmpq_mpoly_t R, const fmpq_mpoly_t A, const fmpq_mpoly_t B, slong var, const fmpq_mpoly_ctx_t ctx) noexcept # Try to set *R* to the resultant of *A* and *B* with respect to the variable of index *var*. - int fmpq_mpoly_discriminant(fmpq_mpoly_t D, const fmpq_mpoly_t A, slong var, const fmpq_mpoly_ctx_t ctx) + int fmpq_mpoly_discriminant(fmpq_mpoly_t D, const fmpq_mpoly_t A, slong var, const fmpq_mpoly_ctx_t ctx) noexcept # Try to set *D* to the discriminant of *A* with respect to the variable of index *var*. - int fmpq_mpoly_sqrt(fmpq_mpoly_t Q, const fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx) + int fmpq_mpoly_sqrt(fmpq_mpoly_t Q, const fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx) noexcept # If *A* is a perfect square return `1` and set *Q* to the square root # with positive leading coefficient. Otherwise return `0` and set *Q* to zero. - bint fmpq_mpoly_is_square(const fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx) + bint fmpq_mpoly_is_square(const fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx) noexcept # Return `1` if *A* is a perfect square, otherwise return `0`. - void fmpq_mpoly_univar_init(fmpq_mpoly_univar_t A, const fmpq_mpoly_ctx_t ctx) + void fmpq_mpoly_univar_init(fmpq_mpoly_univar_t A, const fmpq_mpoly_ctx_t ctx) noexcept # Initialize *A*. - void fmpq_mpoly_univar_clear(fmpq_mpoly_univar_t A, const fmpq_mpoly_ctx_t ctx) + void fmpq_mpoly_univar_clear(fmpq_mpoly_univar_t A, const fmpq_mpoly_ctx_t ctx) noexcept # Clear *A*. - void fmpq_mpoly_univar_swap(fmpq_mpoly_univar_t A, fmpq_mpoly_univar_t B, const fmpq_mpoly_ctx_t ctx) + void fmpq_mpoly_univar_swap(fmpq_mpoly_univar_t A, fmpq_mpoly_univar_t B, const fmpq_mpoly_ctx_t ctx) noexcept # Swap *A* and *B*. - void fmpq_mpoly_to_univar(fmpq_mpoly_univar_t A, const fmpq_mpoly_t B, slong var, const fmpq_mpoly_ctx_t ctx) + void fmpq_mpoly_to_univar(fmpq_mpoly_univar_t A, const fmpq_mpoly_t B, slong var, const fmpq_mpoly_ctx_t ctx) noexcept # Set *A* to a univariate form of *B* by pulling out the variable of index *var*. # The coefficients of *A* will still belong to the content *ctx* but will not depend on the variable of index *var*. - void fmpq_mpoly_from_univar(fmpq_mpoly_t A, const fmpq_mpoly_univar_t B, slong var, const fmpq_mpoly_ctx_t ctx) + void fmpq_mpoly_from_univar(fmpq_mpoly_t A, const fmpq_mpoly_univar_t B, slong var, const fmpq_mpoly_ctx_t ctx) noexcept # Set *A* to the normal form of *B* by putting in the variable of index *var*. # This function is undefined if the coefficients of *B* depend on the variable of index *var*. - int fmpq_mpoly_univar_degree_fits_si(const fmpq_mpoly_univar_t A, const fmpq_mpoly_ctx_t ctx) + int fmpq_mpoly_univar_degree_fits_si(const fmpq_mpoly_univar_t A, const fmpq_mpoly_ctx_t ctx) noexcept # Return `1` if the degree of *A* with respect to the main variable fits an ``slong``. Otherwise, return `0`. - slong fmpq_mpoly_univar_length(const fmpq_mpoly_univar_t A, const fmpq_mpoly_ctx_t ctx) + slong fmpq_mpoly_univar_length(const fmpq_mpoly_univar_t A, const fmpq_mpoly_ctx_t ctx) noexcept # Return the number of terms in *A* with respect to the main variable. - slong fmpq_mpoly_univar_get_term_exp_si(fmpq_mpoly_univar_t A, slong i, const fmpq_mpoly_ctx_t ctx) + slong fmpq_mpoly_univar_get_term_exp_si(fmpq_mpoly_univar_t A, slong i, const fmpq_mpoly_ctx_t ctx) noexcept # Return the exponent of the term of index *i* of *A*. - void fmpq_mpoly_univar_get_term_coeff(fmpq_mpoly_t c, const fmpq_mpoly_univar_t A, slong i, const fmpq_mpoly_ctx_t ctx) - void fmpq_mpoly_univar_swap_term_coeff(fmpq_mpoly_t c, fmpq_mpoly_univar_t A, slong i, const fmpq_mpoly_ctx_t ctx) + void fmpq_mpoly_univar_get_term_coeff(fmpq_mpoly_t c, const fmpq_mpoly_univar_t A, slong i, const fmpq_mpoly_ctx_t ctx) noexcept + void fmpq_mpoly_univar_swap_term_coeff(fmpq_mpoly_t c, fmpq_mpoly_univar_t A, slong i, const fmpq_mpoly_ctx_t ctx) noexcept # Set (resp. swap) *c* to (resp. with) the coefficient of the term of index *i* of *A*. diff --git a/src/sage/libs/flint/fmpq_mpoly_factor.pxd b/src/sage/libs/flint/fmpq_mpoly_factor.pxd index aba63e6f731..b27bd701d81 100644 --- a/src/sage/libs/flint/fmpq_mpoly_factor.pxd +++ b/src/sage/libs/flint/fmpq_mpoly_factor.pxd @@ -12,41 +12,41 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void fmpq_mpoly_factor_init(fmpq_mpoly_factor_t f, const fmpq_mpoly_ctx_t ctx) + void fmpq_mpoly_factor_init(fmpq_mpoly_factor_t f, const fmpq_mpoly_ctx_t ctx) noexcept # Initialise *f*. - void fmpq_mpoly_factor_clear(fmpq_mpoly_factor_t f, const fmpq_mpoly_ctx_t ctx) + void fmpq_mpoly_factor_clear(fmpq_mpoly_factor_t f, const fmpq_mpoly_ctx_t ctx) noexcept # Clear *f*. - void fmpq_mpoly_factor_swap(fmpq_mpoly_factor_t f, fmpq_mpoly_factor_t g, const fmpq_mpoly_ctx_t ctx) + void fmpq_mpoly_factor_swap(fmpq_mpoly_factor_t f, fmpq_mpoly_factor_t g, const fmpq_mpoly_ctx_t ctx) noexcept # Efficiently swap *f* and *g*. - slong fmpq_mpoly_factor_length(const fmpq_mpoly_factor_t f, const fmpq_mpoly_ctx_t ctx) + slong fmpq_mpoly_factor_length(const fmpq_mpoly_factor_t f, const fmpq_mpoly_ctx_t ctx) noexcept # Return the length of the product in *f*. - void fmpq_mpoly_factor_get_constant_fmpq(fmpq_t c, const fmpq_mpoly_factor_t f, const fmpq_mpoly_ctx_t ctx) + void fmpq_mpoly_factor_get_constant_fmpq(fmpq_t c, const fmpq_mpoly_factor_t f, const fmpq_mpoly_ctx_t ctx) noexcept # Set *c* to the constant of *f*. - void fmpq_mpoly_factor_get_base(fmpq_mpoly_t B, const fmpq_mpoly_factor_t f, slong i, const fmpq_mpoly_ctx_t ctx) - void fmpq_mpoly_factor_swap_base(fmpq_mpoly_t B, fmpq_mpoly_factor_t f, slong i, const fmpq_mpoly_ctx_t ctx) + void fmpq_mpoly_factor_get_base(fmpq_mpoly_t B, const fmpq_mpoly_factor_t f, slong i, const fmpq_mpoly_ctx_t ctx) noexcept + void fmpq_mpoly_factor_swap_base(fmpq_mpoly_t B, fmpq_mpoly_factor_t f, slong i, const fmpq_mpoly_ctx_t ctx) noexcept # Set (resp. swap) *B* to (resp. with) the base of the term of index *i* in *A*. - slong fmpq_mpoly_factor_get_exp_si(fmpq_mpoly_factor_t f, slong i, const fmpq_mpoly_ctx_t ctx) + slong fmpq_mpoly_factor_get_exp_si(fmpq_mpoly_factor_t f, slong i, const fmpq_mpoly_ctx_t ctx) noexcept # Return the exponent of the term of index *i* in *A*. It is assumed to fit an ``slong``. - void fmpq_mpoly_factor_sort(fmpq_mpoly_factor_t f, const fmpq_mpoly_ctx_t ctx) + void fmpq_mpoly_factor_sort(fmpq_mpoly_factor_t f, const fmpq_mpoly_ctx_t ctx) noexcept # Sort the product of *f* first by exponent and then by base. - int fmpq_mpoly_factor_make_monic(fmpq_mpoly_factor_t f, const fmpq_mpoly_ctx_t ctx) - int fmpq_mpoly_factor_make_integral(fmpq_mpoly_factor_t f, const fmpq_mpoly_ctx_t ctx) + int fmpq_mpoly_factor_make_monic(fmpq_mpoly_factor_t f, const fmpq_mpoly_ctx_t ctx) noexcept + int fmpq_mpoly_factor_make_integral(fmpq_mpoly_factor_t f, const fmpq_mpoly_ctx_t ctx) noexcept # Make the bases in *f* monic (resp. integral and primitive with positive leading coefficient). # Return `1` for success, `0` for failure. - int fmpq_mpoly_factor_squarefree(fmpq_mpoly_factor_t f, const fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx) + int fmpq_mpoly_factor_squarefree(fmpq_mpoly_factor_t f, const fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx) noexcept # Set *f* to a factorization of *A* where the bases are primitive and # pairwise relatively prime. If the product of all irreducible factors with # a given exponent is desired, it is recommended to call :func:`fmpq_mpoly_factor_sort` # and then multiply the bases with the desired exponent. - int fmpq_mpoly_factor(fmpq_mpoly_factor_t f, const fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx) + int fmpq_mpoly_factor(fmpq_mpoly_factor_t f, const fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx) noexcept # Set *f* to a factorization of *A* where the bases are irreducible. diff --git a/src/sage/libs/flint/fmpq_poly.pxd b/src/sage/libs/flint/fmpq_poly.pxd index 7e570d11a2a..c1795aac611 100644 --- a/src/sage/libs/flint/fmpq_poly.pxd +++ b/src/sage/libs/flint/fmpq_poly.pxd @@ -12,15 +12,15 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void fmpq_poly_init(fmpq_poly_t poly) + void fmpq_poly_init(fmpq_poly_t poly) noexcept # Initialises the polynomial for use. The length is set to zero. - void fmpq_poly_init2(fmpq_poly_t poly, slong alloc) + void fmpq_poly_init2(fmpq_poly_t poly, slong alloc) noexcept # Initialises the polynomial with space for at least ``alloc`` # coefficients and sets the length to zero. The ``alloc`` coefficients # are all set to zero. - void fmpq_poly_realloc(fmpq_poly_t poly, slong alloc) + void fmpq_poly_realloc(fmpq_poly_t poly, slong alloc) noexcept # Reallocates the given polynomial to have space for ``alloc`` # coefficients. If ``alloc`` is zero then the polynomial is cleared # and then reinitialised. If the current length is greater than @@ -28,7 +28,7 @@ cdef extern from "flint_wrap.h": # ``alloc``. Note that this might leave the rational polynomial in # non-canonical form. - void fmpq_poly_fit_length(fmpq_poly_t poly, slong len) + void fmpq_poly_fit_length(fmpq_poly_t poly, slong len) noexcept # If ``len`` is greater than the number of coefficients currently # allocated, then the polynomial is reallocated to have space for at # least ``len`` coefficients. No data is lost when calling this @@ -37,48 +37,48 @@ cdef extern from "flint_wrap.h": # least doubling the number of allocated coefficients when ``len`` # is larger than the number of coefficients currently allocated. - void _fmpq_poly_set_length(fmpq_poly_t poly, slong len) + void _fmpq_poly_set_length(fmpq_poly_t poly, slong len) noexcept # Sets the length of the numerator polynomial to ``len``, demoting # coefficients beyond the new length. Note that this method does # not guarantee that the rational polynomial is in canonical form. - void fmpq_poly_clear(fmpq_poly_t poly) + void fmpq_poly_clear(fmpq_poly_t poly) noexcept # Clears the given polynomial, releasing any memory used. The polynomial # must be reinitialised in order to be used again. - void _fmpq_poly_normalise(fmpq_poly_t poly) + void _fmpq_poly_normalise(fmpq_poly_t poly) noexcept # Sets the length of ``poly`` so that the top coefficient is # non-zero. If all coefficients are zero, the length is set to zero. # Note that this function does not guarantee the coprimality of the # numerator polynomial and the integer denominator. - void _fmpq_poly_canonicalise(fmpz * poly, fmpz_t den, slong len) + void _fmpq_poly_canonicalise(fmpz * poly, fmpz_t den, slong len) noexcept # Puts ``(poly, den)`` of length ``len`` into canonical form. # It is assumed that the array ``poly`` contains a non-zero entry in # position ``len - 1`` whenever ``len > 0``. Assumes that ``den`` # is non-zero. - void fmpq_poly_canonicalise(fmpq_poly_t poly) + void fmpq_poly_canonicalise(fmpq_poly_t poly) noexcept # Puts the polynomial ``poly`` into canonical form. Firstly, the length # is set to the actual length of the numerator polynomial. For non-zero # polynomials, it is then ensured that the numerator and denominator are # coprime and that the denominator is positive. The canonical form of the # zero polynomial is a zero numerator polynomial and a one denominator. - bint _fmpq_poly_is_canonical(const fmpz * poly, const fmpz_t den, slong len) + bint _fmpq_poly_is_canonical(const fmpz * poly, const fmpz_t den, slong len) noexcept # Returns whether the polynomial is in canonical form. - bint fmpq_poly_is_canonical(const fmpq_poly_t poly) + bint fmpq_poly_is_canonical(const fmpq_poly_t poly) noexcept # Returns whether the polynomial is in canonical form. - slong fmpq_poly_degree(const fmpq_poly_t poly) + slong fmpq_poly_degree(const fmpq_poly_t poly) noexcept # Returns the degree of ``poly``, which is one less than its length, as # a ``slong``. - slong fmpq_poly_length(const fmpq_poly_t poly) + slong fmpq_poly_length(const fmpq_poly_t poly) noexcept # Returns the length of ``poly``. - fmpz * fmpq_poly_numref(fmpq_poly_t poly) + fmpz * fmpq_poly_numref(fmpq_poly_t poly) noexcept # Returns a reference to the numerator polynomial as an array. # Note that, because of a delayed initialisation approach, this might # be ``NULL`` for zero polynomials. This situation can be salvaged @@ -86,72 +86,72 @@ cdef extern from "flint_wrap.h": # :func:`fmpq_poly_realloc`. # This function is implemented as a macro returning ``(poly)->coeffs``. - fmpz_t fmpq_poly_denref(fmpq_poly_t poly) + fmpz_t fmpq_poly_denref(fmpq_poly_t poly) noexcept # Returns a reference to the denominator as a ``fmpz_t``. The integer # is guaranteed to be properly initialised. # This function is implemented as a macro returning ``(poly)->den``. - void fmpq_poly_get_numerator(fmpz_poly_t res, const fmpq_poly_t poly) + void fmpq_poly_get_numerator(fmpz_poly_t res, const fmpq_poly_t poly) noexcept # Sets ``res`` to the numerator of ``poly``, e.g. the primitive part # as an ``fmpz_poly_t`` if it is in canonical form. - void fmpq_poly_get_denominator(fmpz_t den, const fmpq_poly_t poly) + void fmpq_poly_get_denominator(fmpz_t den, const fmpq_poly_t poly) noexcept # Sets ``res`` to the denominator of ``poly``. - void fmpq_poly_randtest(fmpq_poly_t f, flint_rand_t state, slong len, flint_bitcnt_t bits) + void fmpq_poly_randtest(fmpq_poly_t f, flint_rand_t state, slong len, flint_bitcnt_t bits) noexcept # Sets `f` to a random polynomial with coefficients up to the given # length and where each coefficient has up to the given number of bits. # The coefficients are signed randomly. One must call # :func:`flint_randinit` before calling this function. - void fmpq_poly_randtest_unsigned(fmpq_poly_t f, flint_rand_t state, slong len, flint_bitcnt_t bits) + void fmpq_poly_randtest_unsigned(fmpq_poly_t f, flint_rand_t state, slong len, flint_bitcnt_t bits) noexcept # Sets `f` to a random polynomial with coefficients up to the given length # and where each coefficient has up to the given number of bits. One must # call :func:`flint_randinit` before calling this function. - void fmpq_poly_randtest_not_zero(fmpq_poly_t f, flint_rand_t state, slong len, flint_bitcnt_t bits) + void fmpq_poly_randtest_not_zero(fmpq_poly_t f, flint_rand_t state, slong len, flint_bitcnt_t bits) noexcept # As for :func:`fmpq_poly_randtest` except that ``len`` and ``bits`` # may not be zero and the polynomial generated is guaranteed not to be the # zero polynomial. One must call :func:`flint_randinit` before calling # this function. - void fmpq_poly_set(fmpq_poly_t poly1, const fmpq_poly_t poly2) + void fmpq_poly_set(fmpq_poly_t poly1, const fmpq_poly_t poly2) noexcept # Sets ``poly1`` to equal ``poly2``. - void fmpq_poly_set_si(fmpq_poly_t poly, slong x) + void fmpq_poly_set_si(fmpq_poly_t poly, slong x) noexcept # Sets ``poly`` to the integer `x`. - void fmpq_poly_set_ui(fmpq_poly_t poly, ulong x) + void fmpq_poly_set_ui(fmpq_poly_t poly, ulong x) noexcept # Sets ``poly`` to the integer `x`. - void fmpq_poly_set_fmpz(fmpq_poly_t poly, const fmpz_t x) + void fmpq_poly_set_fmpz(fmpq_poly_t poly, const fmpz_t x) noexcept # Sets ``poly`` to the integer `x`. - void fmpq_poly_set_fmpq(fmpq_poly_t poly, const fmpq_t x) + void fmpq_poly_set_fmpq(fmpq_poly_t poly, const fmpq_t x) noexcept # Sets ``poly`` to the rational `x`, which is assumed to be # given in lowest terms. - void fmpq_poly_set_fmpz_poly(fmpq_poly_t rop, const fmpz_poly_t op) + void fmpq_poly_set_fmpz_poly(fmpq_poly_t rop, const fmpz_poly_t op) noexcept # Sets the rational polynomial ``rop`` to the same value # as the integer polynomial ``op``. - void fmpq_poly_set_nmod_poly(fmpq_poly_t rop, const nmod_poly_t op) + void fmpq_poly_set_nmod_poly(fmpq_poly_t rop, const nmod_poly_t op) noexcept # Sets the coefficients of ``rop`` to the residues in ``op``, # normalised to the interval `-m/2 \le r < m/2` where `m` is the modulus. - void fmpq_poly_get_nmod_poly(nmod_poly_t rop, const fmpq_poly_t op) + void fmpq_poly_get_nmod_poly(nmod_poly_t rop, const fmpq_poly_t op) noexcept # Sets the coefficients of ``rop`` to the coefficients in the denominator of ``op``, # reduced by the modulus of ``rop``. The result is multiplied by the inverse of the # denominator of ``op``. It is assumed that the reduction of the denominator of ``op`` # is invertible. - void fmpq_poly_get_nmod_poly_den(nmod_poly_t rop, const fmpq_poly_t op, int den) + void fmpq_poly_get_nmod_poly_den(nmod_poly_t rop, const fmpq_poly_t op, int den) noexcept # Sets the coefficients of ``rop`` to the coefficients in the denominator # of ``op``, reduced by the modulus of ``rop``. If ``den == 1``, the result is # multiplied by the inverse of the denominator of ``op``. In this case it is # assumed that the reduction of the denominator of ``op`` is invertible. - int _fmpq_poly_set_str(fmpz * poly, fmpz_t den, const char * str, slong len) + int _fmpq_poly_set_str(fmpz * poly, fmpz_t den, const char * str, slong len) noexcept # Sets ``(poly, den)`` to the polynomial specified by the # null-terminated string ``str`` of ``len`` coefficients. The input # format is a sequence of coefficients separated by one space. @@ -162,7 +162,7 @@ cdef extern from "flint_wrap.h": # If ``str`` is not null-terminated, calling this method might result # in a segmentation fault. - int fmpq_poly_set_str(fmpq_poly_t poly, const char * str) + int fmpq_poly_set_str(fmpq_poly_t poly, const char * str) noexcept # Sets ``poly`` to the polynomial specified by the null-terminated # string ``str``. The input format is the same as the output format # of ``fmpq_poly_get_str``: the length given as a decimal integer, @@ -173,85 +173,85 @@ cdef extern from "flint_wrap.h": # the resulting value of ``poly`` is set to zero. If ``str`` is not # null-terminated, calling this method might result in a segmentation fault. - char * fmpq_poly_get_str(const fmpq_poly_t poly) + char * fmpq_poly_get_str(const fmpq_poly_t poly) noexcept # Returns the string representation of ``poly``. - char * fmpq_poly_get_str_pretty(const fmpq_poly_t poly, const char * var) + char * fmpq_poly_get_str_pretty(const fmpq_poly_t poly, const char * var) noexcept # Returns the pretty representation of ``poly``, using the # null-terminated string ``var`` not equal to ``"\0"`` as # the variable name. - void fmpq_poly_zero(fmpq_poly_t poly) + void fmpq_poly_zero(fmpq_poly_t poly) noexcept # Sets ``poly`` to zero. - void fmpq_poly_one(fmpq_poly_t poly) + void fmpq_poly_one(fmpq_poly_t poly) noexcept # Sets ``poly`` to the constant polynomial `1`. - void fmpq_poly_neg(fmpq_poly_t poly1, const fmpq_poly_t poly2) + void fmpq_poly_neg(fmpq_poly_t poly1, const fmpq_poly_t poly2) noexcept # Sets ``poly1`` to the additive inverse of ``poly2``. - void fmpq_poly_inv(fmpq_poly_t poly1, const fmpq_poly_t poly2) + void fmpq_poly_inv(fmpq_poly_t poly1, const fmpq_poly_t poly2) noexcept # Sets ``poly1`` to the multiplicative inverse of ``poly2`` # if possible. Otherwise, if ``poly2`` is not a unit, leaves # ``poly1`` unmodified and calls :func:`abort`. - void fmpq_poly_swap(fmpq_poly_t poly1, fmpq_poly_t poly2) + void fmpq_poly_swap(fmpq_poly_t poly1, fmpq_poly_t poly2) noexcept # Efficiently swaps the polynomials ``poly1`` and ``poly2``. - void fmpq_poly_truncate(fmpq_poly_t poly, slong n) + void fmpq_poly_truncate(fmpq_poly_t poly, slong n) noexcept # If the current length of ``poly`` is greater than `n`, it is # truncated to the given length. Discarded coefficients are demoted, # but they are not necessarily set to zero. - void fmpq_poly_set_trunc(fmpq_poly_t res, const fmpq_poly_t poly, slong n) + void fmpq_poly_set_trunc(fmpq_poly_t res, const fmpq_poly_t poly, slong n) noexcept # Sets ``res`` to a copy of ``poly``, truncated to length ``n``. - void fmpq_poly_get_slice(fmpq_poly_t rop, const fmpq_poly_t op, slong i, slong j) + void fmpq_poly_get_slice(fmpq_poly_t rop, const fmpq_poly_t op, slong i, slong j) noexcept # Returns the slice with coefficients from `x^i` (including) to # `x^j` (excluding). - void fmpq_poly_reverse(fmpq_poly_t res, const fmpq_poly_t poly, slong n) + void fmpq_poly_reverse(fmpq_poly_t res, const fmpq_poly_t poly, slong n) noexcept # This function considers the polynomial ``poly`` to be of length `n`, # notionally truncating and zero padding if required, and reverses # the result. Since the function normalises its result ``res`` may be # of length less than `n`. - void fmpq_poly_get_coeff_fmpz(fmpz_t x, const fmpq_poly_t poly, slong n) + void fmpq_poly_get_coeff_fmpz(fmpz_t x, const fmpq_poly_t poly, slong n) noexcept # Retrieves the `n`\th coefficient of the numerator of ``poly``. - void fmpq_poly_get_coeff_fmpq(fmpq_t x, const fmpq_poly_t poly, slong n) + void fmpq_poly_get_coeff_fmpq(fmpq_t x, const fmpq_poly_t poly, slong n) noexcept # Retrieves the `n`\th coefficient of ``poly``, in lowest terms. - void fmpq_poly_set_coeff_si(fmpq_poly_t poly, slong n, slong x) + void fmpq_poly_set_coeff_si(fmpq_poly_t poly, slong n, slong x) noexcept # Sets the `n`\th coefficient in ``poly`` to the integer `x`. - void fmpq_poly_set_coeff_ui(fmpq_poly_t poly, slong n, ulong x) + void fmpq_poly_set_coeff_ui(fmpq_poly_t poly, slong n, ulong x) noexcept # Sets the `n`\th coefficient in ``poly`` to the integer `x`. - void fmpq_poly_set_coeff_fmpz(fmpq_poly_t poly, slong n, const fmpz_t x) + void fmpq_poly_set_coeff_fmpz(fmpq_poly_t poly, slong n, const fmpz_t x) noexcept # Sets the `n`\th coefficient in ``poly`` to the integer `x`. - void fmpq_poly_set_coeff_fmpq(fmpq_poly_t poly, slong n, const fmpq_t x) + void fmpq_poly_set_coeff_fmpq(fmpq_poly_t poly, slong n, const fmpq_t x) noexcept # Sets the `n`\th coefficient in ``poly`` to the rational `x`. - bint fmpq_poly_equal(const fmpq_poly_t poly1, const fmpq_poly_t poly2) + bint fmpq_poly_equal(const fmpq_poly_t poly1, const fmpq_poly_t poly2) noexcept # Returns `1` if ``poly1`` is equal to ``poly2``, # otherwise returns `0`. - bint _fmpq_poly_equal_trunc(const fmpz * poly1, const fmpz_t den1, slong len1, const fmpz * poly2, const fmpz_t den2, slong len2, slong n) + bint _fmpq_poly_equal_trunc(const fmpz * poly1, const fmpz_t den1, slong len1, const fmpz * poly2, const fmpz_t den2, slong len2, slong n) noexcept # Returns `1` if ``poly1`` and ``poly2`` notionally truncated to length # `n` are equal, otherwise returns `0`. - bint fmpq_poly_equal_trunc(const fmpq_poly_t poly1, const fmpq_poly_t poly2, slong n) + bint fmpq_poly_equal_trunc(const fmpq_poly_t poly1, const fmpq_poly_t poly2, slong n) noexcept # Returns `1` if ``poly1`` and ``poly2`` notionally truncated to length # `n` are equal, otherwise returns `0`. - int _fmpq_poly_cmp(const fmpz * lpoly, const fmpz_t lden, const fmpz * rpoly, const fmpz_t rden, slong len) + int _fmpq_poly_cmp(const fmpz * lpoly, const fmpz_t lden, const fmpz * rpoly, const fmpz_t rden, slong len) noexcept # Compares two non-zero polynomials, assuming they have the same length # ``len > 0``. # The polynomials are expected to be provided in canonical form. - int fmpq_poly_cmp(const fmpq_poly_t left, const fmpq_poly_t right) + int fmpq_poly_cmp(const fmpq_poly_t left, const fmpq_poly_t right) noexcept # Compares the two polynomials ``left`` and ``right``. # Compares the two polynomials ``left`` and ``right``, returning # `-1`, `0`, or `1` as ``left`` is less than, equal to, or greater @@ -259,18 +259,18 @@ cdef extern from "flint_wrap.h": # then, in case of a tie, by the individual coefficients from highest # to lowest. - bint fmpq_poly_is_one(const fmpq_poly_t poly) + bint fmpq_poly_is_one(const fmpq_poly_t poly) noexcept # Returns `1` if ``poly`` is the constant polynomial `1`, otherwise # returns `0`. - bint fmpq_poly_is_zero(const fmpq_poly_t poly) + bint fmpq_poly_is_zero(const fmpq_poly_t poly) noexcept # Returns `1` if ``poly`` is the zero polynomial, otherwise returns `0`. - bint fmpq_poly_is_gen(const fmpq_poly_t poly) + bint fmpq_poly_is_gen(const fmpq_poly_t poly) noexcept # Returns `1` if ``poly`` is the degree `1` polynomial `x`, otherwise returns # `0`. - void _fmpq_poly_add(fmpz * rpoly, fmpz_t rden, const fmpz * poly1, const fmpz_t den1, slong len1, const fmpz * poly2, const fmpz_t den2, slong len2) + void _fmpq_poly_add(fmpz * rpoly, fmpz_t rden, const fmpz * poly1, const fmpz_t den1, slong len1, const fmpz * poly2, const fmpz_t den2, slong len2) noexcept # Forms the sum ``(rpoly, rden)`` of ``(poly1, den1, len1)`` and # ``(poly2, den2, len2)``, placing the result into canonical form. # Assumes that ``rpoly`` is an array of length the maximum of @@ -280,42 +280,42 @@ cdef extern from "flint_wrap.h": # but ``(rpoly, rden)`` and ``(poly2, den2)`` may *not* # be aliased. - void _fmpq_poly_add_can(fmpz * rpoly, fmpz_t rden, const fmpz * poly1, const fmpz_t den1, slong len1, const fmpz * poly2, const fmpz_t den2, slong len2, int can) + void _fmpq_poly_add_can(fmpz * rpoly, fmpz_t rden, const fmpz * poly1, const fmpz_t den1, slong len1, const fmpz * poly2, const fmpz_t den2, slong len2, int can) noexcept # As per ``_fmpq_poly_add`` except that one can specify whether to # canonicalise the output or not. This function is intended to be used with # weak canonicalisation to prevent explosion in memory usage. It exists for # performance reasons. - void fmpq_poly_add(fmpq_poly_t res, const fmpq_poly_t poly1, const fmpq_poly_t poly2) + void fmpq_poly_add(fmpq_poly_t res, const fmpq_poly_t poly1, const fmpq_poly_t poly2) noexcept # Sets ``res`` to the sum of ``poly1`` and ``poly2``, using # Henrici's algorithm. - void fmpq_poly_add_can(fmpq_poly_t res, const fmpq_poly_t poly1, const fmpq_poly_t poly2, int can) + void fmpq_poly_add_can(fmpq_poly_t res, const fmpq_poly_t poly1, const fmpq_poly_t poly2, int can) noexcept # As per ``mpq_poly_add`` except that one can specify whether to # canonicalise the output or not. This function is intended to be used with # weak canonicalisation to prevent explosion in memory usage. It exists for # performance reasons. - void _fmpq_poly_add_series(fmpz * rpoly, fmpz_t rden, const fmpz * poly1, const fmpz_t den1, slong len1, const fmpz * poly2, const fmpz_t den2, slong len2, slong n) + void _fmpq_poly_add_series(fmpz * rpoly, fmpz_t rden, const fmpz * poly1, const fmpz_t den1, slong len1, const fmpz * poly2, const fmpz_t den2, slong len2, slong n) noexcept # As per ``_fmpq_poly_add`` but the inputs are first notionally truncated # to length `n`. If `n` is less than ``len1`` or ``len2`` then the # output only needs space for `n` coefficients. We require `n \geq 0`. - void _fmpq_poly_add_series_can(fmpz * rpoly, fmpz_t rden, const fmpz * poly1, const fmpz_t den1, slong len1, const fmpz * poly2, const fmpz_t den2, slong len2, slong n, int can) + void _fmpq_poly_add_series_can(fmpz * rpoly, fmpz_t rden, const fmpz * poly1, const fmpz_t den1, slong len1, const fmpz * poly2, const fmpz_t den2, slong len2, slong n, int can) noexcept # As per ``_fmpq_poly_add_can`` but the inputs are first notionally # truncated to length `n`. If `n` is less than ``len1`` or ``len2`` # then the output only needs space for `n` coefficients. We require # `n \geq 0`. - void fmpq_poly_add_series(fmpq_poly_t res, const fmpq_poly_t poly1, const fmpq_poly_t poly2, slong n) + void fmpq_poly_add_series(fmpq_poly_t res, const fmpq_poly_t poly1, const fmpq_poly_t poly2, slong n) noexcept # As per ``fmpq_poly_add`` but the inputs are first notionally # truncated to length `n`. - void fmpq_poly_add_series_can(fmpq_poly_t res, const fmpq_poly_t poly1, const fmpq_poly_t poly2, slong n, int can) + void fmpq_poly_add_series_can(fmpq_poly_t res, const fmpq_poly_t poly1, const fmpq_poly_t poly2, slong n, int can) noexcept # As per ``fmpq_poly_add_can`` but the inputs are first notionally # truncated to length `n`. - void _fmpq_poly_sub(fmpz * rpoly, fmpz_t rden, const fmpz * poly1, const fmpz_t den1, slong len1, const fmpz * poly2, const fmpz_t den2, slong len2) + void _fmpq_poly_sub(fmpz * rpoly, fmpz_t rden, const fmpz * poly1, const fmpz_t den1, slong len1, const fmpz * poly2, const fmpz_t den2, slong len2) noexcept # Forms the difference ``(rpoly, rden)`` of ``(poly1, den1, len1)`` # and ``(poly2, den2, len2)``, placing the result into canonical form. # Assumes that ``rpoly`` is an array of length the maximum of @@ -325,42 +325,42 @@ cdef extern from "flint_wrap.h": # but ``(rpoly, rden)`` and ``(poly2, den2, len2)`` may *not* be # aliased. - void _fmpq_poly_sub_can(fmpz * rpoly, fmpz_t rden, const fmpz * poly1, const fmpz_t den1, slong len1, const fmpz * poly2, const fmpz_t den2, slong len2, int can) + void _fmpq_poly_sub_can(fmpz * rpoly, fmpz_t rden, const fmpz * poly1, const fmpz_t den1, slong len1, const fmpz * poly2, const fmpz_t den2, slong len2, int can) noexcept # As per ``_fmpq_poly_sub`` except that one can specify whether to # canonicalise the output or not. This function is intended to be used with # weak canonicalisation to prevent explosion in memory usage. It exists for # performance reasons. - void fmpq_poly_sub(fmpq_poly_t res, const fmpq_poly_t poly1, const fmpq_poly_t poly2) + void fmpq_poly_sub(fmpq_poly_t res, const fmpq_poly_t poly1, const fmpq_poly_t poly2) noexcept # Sets ``res`` to the difference of ``poly1`` and ``poly2``, # using Henrici's algorithm. - void fmpq_poly_sub_can(fmpq_poly_t res, const fmpq_poly_t poly1, const fmpq_poly_t poly2, int can) + void fmpq_poly_sub_can(fmpq_poly_t res, const fmpq_poly_t poly1, const fmpq_poly_t poly2, int can) noexcept # As per ``_fmpq_poly_sub`` except that one can specify whether to # canonicalise the output or not. This function is intended to be used with # weak canonicalisation to prevent explosion in memory usage. It exists for # performance reasons. - void _fmpq_poly_sub_series(fmpz * rpoly, fmpz_t rden, const fmpz * poly1, const fmpz_t den1, slong len1, const fmpz * poly2, const fmpz_t den2, slong len2, slong n) + void _fmpq_poly_sub_series(fmpz * rpoly, fmpz_t rden, const fmpz * poly1, const fmpz_t den1, slong len1, const fmpz * poly2, const fmpz_t den2, slong len2, slong n) noexcept # As per ``_fmpq_poly_sub`` but the inputs are first notionally truncated # to length `n`. If `n` is less than ``len1`` or ``len2`` then the # output only needs space for `n` coefficients. We require `n \geq 0`. - void _fmpq_poly_sub_series_can(fmpz * rpoly, fmpz_t rden, const fmpz * poly1, const fmpz_t den1, slong len1, const fmpz * poly2, const fmpz_t den2, slong len2, slong n, int can) + void _fmpq_poly_sub_series_can(fmpz * rpoly, fmpz_t rden, const fmpz * poly1, const fmpz_t den1, slong len1, const fmpz * poly2, const fmpz_t den2, slong len2, slong n, int can) noexcept # As per ``_fmpq_poly_sub_can`` but the inputs are first notionally # truncated to length `n`. If `n` is less than ``len1`` or ``len2`` # then the output only needs space for `n` coefficients. We require # `n \geq 0`. - void fmpq_poly_sub_series(fmpq_poly_t res, const fmpq_poly_t poly1, const fmpq_poly_t poly2, slong n) + void fmpq_poly_sub_series(fmpq_poly_t res, const fmpq_poly_t poly1, const fmpq_poly_t poly2, slong n) noexcept # As per ``fmpq_poly_sub`` but the inputs are first notionally # truncated to length `n`. - void fmpq_poly_sub_series_can(fmpq_poly_t res, const fmpq_poly_t poly1, const fmpq_poly_t poly2, slong n, int can) + void fmpq_poly_sub_series_can(fmpq_poly_t res, const fmpq_poly_t poly1, const fmpq_poly_t poly2, slong n, int can) noexcept # As per ``fmpq_poly_sub_can`` but the inputs are first notionally # truncated to length `n`. - void _fmpq_poly_scalar_mul_si(fmpz * rpoly, fmpz_t rden, const fmpz * poly, const fmpz_t den, slong len, slong c) + void _fmpq_poly_scalar_mul_si(fmpz * rpoly, fmpz_t rden, const fmpz * poly, const fmpz_t den, slong len, slong c) noexcept # Sets ``(rpoly, rden, len)`` to the product of `c` of # ``(poly, den, len)``. # If the input is normalised, then so is the output, provided it is @@ -370,7 +370,7 @@ cdef extern from "flint_wrap.h": # Supports exact aliasing between ``(rpoly, den)`` # and ``(poly, den)``. - void _fmpq_poly_scalar_mul_ui(fmpz * rpoly, fmpz_t rden, const fmpz * poly, const fmpz_t den, slong len, ulong c) + void _fmpq_poly_scalar_mul_ui(fmpz * rpoly, fmpz_t rden, const fmpz * poly, const fmpz_t den, slong len, ulong c) noexcept # Sets ``(rpoly, rden, len)`` to the product of `c` of # ``(poly, den, len)``. # If the input is normalised, then so is the output, provided it is @@ -380,7 +380,7 @@ cdef extern from "flint_wrap.h": # Supports exact aliasing between ``(rpoly, den)`` # and ``(poly, den)``. - void _fmpq_poly_scalar_mul_fmpz(fmpz * rpoly, fmpz_t rden, const fmpz * poly, const fmpz_t den, slong len, const fmpz_t c) + void _fmpq_poly_scalar_mul_fmpz(fmpz * rpoly, fmpz_t rden, const fmpz * poly, const fmpz_t den, slong len, const fmpz_t c) noexcept # Sets ``(rpoly, rden, len)`` to the product of `c` of # ``(poly, den, len)``. # If the input is normalised, then so is the output, provided it is @@ -390,7 +390,7 @@ cdef extern from "flint_wrap.h": # Supports exact aliasing between ``(rpoly, den)`` # and ``(poly, den)``. - void _fmpq_poly_scalar_mul_fmpq(fmpz * rpoly, fmpz_t rden, const fmpz * poly, const fmpz_t den, slong len, const fmpz_t r, const fmpz_t s) + void _fmpq_poly_scalar_mul_fmpq(fmpz * rpoly, fmpz_t rden, const fmpz * poly, const fmpz_t den, slong len, const fmpz_t r, const fmpz_t s) noexcept # Sets ``(rpoly, rden)`` to the product of `r/s` and # ``(poly, den, len)``, in lowest terms. # Assumes that ``(poly, den, len)`` and `r/s` are provided in lowest @@ -398,39 +398,35 @@ cdef extern from "flint_wrap.h": # Supports aliasing of ``(rpoly, den)`` and ``(poly, den)``. # The ``fmpz_t``'s `r` and `s` may not be part of ``(rpoly, rden)``. - void fmpq_poly_scalar_mul_si(fmpq_poly_t rop, const fmpq_poly_t op, slong c) + void fmpq_poly_scalar_mul_fmpq(fmpq_poly_t rop, const fmpq_poly_t op, const fmpq_t c) noexcept + void fmpq_poly_scalar_mul_si(fmpq_poly_t rop, const fmpq_poly_t op, slong c) noexcept + void fmpq_poly_scalar_mul_ui(fmpq_poly_t rop, const fmpq_poly_t op, ulong c) noexcept # Sets ``rop`` to `c` times ``op``. - void fmpq_poly_scalar_mul_ui(fmpq_poly_t rop, const fmpq_poly_t op, ulong c) - # Sets ``rop`` to `c` times ``op``. - - void fmpq_poly_scalar_mul_fmpz(fmpq_poly_t rop, const fmpq_poly_t op, const fmpz_t c) + void fmpq_poly_scalar_mul_fmpz(fmpq_poly_t rop, const fmpq_poly_t op, const fmpz_t c) noexcept # Sets ``rop`` to `c` times ``op``. Assumes that the ``fmpz_t c`` # is not part of ``rop``. - void fmpq_poly_scalar_mul_mpq(fmpq_poly_t rop, const fmpq_poly_t op, const fmpq_t c) - # Sets ``rop`` to `c` times ``op``. - - void _fmpq_poly_scalar_div_fmpz(fmpz * rpoly, fmpz_t rden, const fmpz * poly, const fmpz_t den, slong len, const fmpz_t c) + void _fmpq_poly_scalar_div_fmpz(fmpz * rpoly, fmpz_t rden, const fmpz * poly, const fmpz_t den, slong len, const fmpz_t c) noexcept # Sets ``(rpoly, rden, len)`` to ``(poly, den, len)`` divided by `c`, # in lowest terms. # Assumes that ``len`` is positive. Assumes that `c` is non-zero. # Supports aliasing between ``(rpoly, rden)`` and ``(poly, den)``. # Assumes that `c` is not part of ``(rpoly, rden)``. - void _fmpq_poly_scalar_div_si(fmpz * rpoly, fmpz_t rden, const fmpz * poly, const fmpz_t den, slong len, slong c) + void _fmpq_poly_scalar_div_si(fmpz * rpoly, fmpz_t rden, const fmpz * poly, const fmpz_t den, slong len, slong c) noexcept # Sets ``(rpoly, rden, len)`` to ``(poly, den, len)`` divided by `c`, # in lowest terms. # Assumes that ``len`` is positive. Assumes that `c` is non-zero. # Supports aliasing between ``(rpoly, rden)`` and ``(poly, den)``. - void _fmpq_poly_scalar_div_ui(fmpz * rpoly, fmpz_t rden, const fmpz * poly, const fmpz_t den, slong len, ulong c) + void _fmpq_poly_scalar_div_ui(fmpz * rpoly, fmpz_t rden, const fmpz * poly, const fmpz_t den, slong len, ulong c) noexcept # Sets ``(rpoly, rden, len)`` to ``(poly, den, len)`` divided by `c`, # in lowest terms. # Assumes that ``len`` is positive. Assumes that `c` is non-zero. # Supports aliasing between ``(rpoly, rden)`` and ``(poly, den)``. - void _fmpq_poly_scalar_div_fmpq(fmpz * rpoly, fmpz_t rden, const fmpz * poly, const fmpz_t den, slong len, const fmpz_t r, const fmpz_t s) + void _fmpq_poly_scalar_div_fmpq(fmpz * rpoly, fmpz_t rden, const fmpz * poly, const fmpz_t den, slong len, const fmpz_t r, const fmpz_t s) noexcept # Sets ``(rpoly, rden, len)`` to ``(poly, den, len)`` divided by `r/s`, # in lowest terms. # Assumes that ``len`` is positive. Assumes that `r/s` is non-zero and @@ -438,23 +434,23 @@ cdef extern from "flint_wrap.h": # ``(poly, den)``. The ``fmpz_t``'s `r` and `s` may not be part of # ``(rpoly, poly)``. - void fmpq_poly_scalar_div_si(fmpq_poly_t rop, const fmpq_poly_t op, slong c) - void fmpq_poly_scalar_div_ui(fmpq_poly_t rop, const fmpq_poly_t op, ulong c) - void fmpq_poly_scalar_div_fmpz(fmpq_poly_t rop, const fmpq_poly_t op, const fmpz_t c) - void fmpq_poly_scalar_div_fmpq(fmpq_poly_t rop, const fmpq_poly_t op, const fmpq_t c) + void fmpq_poly_scalar_div_si(fmpq_poly_t rop, const fmpq_poly_t op, slong c) noexcept + void fmpq_poly_scalar_div_ui(fmpq_poly_t rop, const fmpq_poly_t op, ulong c) noexcept + void fmpq_poly_scalar_div_fmpz(fmpq_poly_t rop, const fmpq_poly_t op, const fmpz_t c) noexcept + void fmpq_poly_scalar_div_fmpq(fmpq_poly_t rop, const fmpq_poly_t op, const fmpq_t c) noexcept # Sets ``rop`` to ``op`` divided by the scalar ``c``. - void _fmpq_poly_mul(fmpz * rpoly, fmpz_t rden, const fmpz * poly1, const fmpz_t den1, slong len1, const fmpz * poly2, const fmpz_t den2, slong len2) + void _fmpq_poly_mul(fmpz * rpoly, fmpz_t rden, const fmpz * poly1, const fmpz_t den1, slong len1, const fmpz * poly2, const fmpz_t den2, slong len2) noexcept # Sets ``(rpoly, rden, len1 + len2 - 1)`` to the product of # ``(poly1, den1, len1)`` and ``(poly2, den2, len2)``. If the # input is provided in canonical form, then so is the output. # Assumes ``len1 >= len2 > 0``. Allows zero-padding in the input. # Does not allow aliasing between the inputs and outputs. - void fmpq_poly_mul(fmpq_poly_t res, const fmpq_poly_t poly1, const fmpq_poly_t poly2) + void fmpq_poly_mul(fmpq_poly_t res, const fmpq_poly_t poly1, const fmpq_poly_t poly2) noexcept # Sets ``res`` to the product of ``poly1`` and ``poly2``. - void _fmpq_poly_mullow(fmpz * rpoly, fmpz_t rden, const fmpz * poly1, const fmpz_t den1, slong len1, const fmpz * poly2, const fmpz_t den2, slong len2, slong n) + void _fmpq_poly_mullow(fmpz * rpoly, fmpz_t rden, const fmpz * poly1, const fmpz_t den1, slong len1, const fmpz * poly2, const fmpz_t den2, slong len2, slong n) noexcept # Sets ``(rpoly, rden, n)`` to the low `n` coefficients of # ``(poly1, den1)`` and ``(poly2, den2)``. The output is # not guaranteed to be in canonical form. @@ -462,43 +458,43 @@ cdef extern from "flint_wrap.h": # Allows for zero-padding in the inputs. Does not allow aliasing between # the inputs and outputs. - void fmpq_poly_mullow(fmpq_poly_t res, const fmpq_poly_t poly1, const fmpq_poly_t poly2, slong n) + void fmpq_poly_mullow(fmpq_poly_t res, const fmpq_poly_t poly1, const fmpq_poly_t poly2, slong n) noexcept # Sets ``res`` to the product of ``poly1`` and ``poly2``, # truncated to length `n`. - void fmpq_poly_addmul(fmpq_poly_t rop, const fmpq_poly_t op1, const fmpq_poly_t op2) + void fmpq_poly_addmul(fmpq_poly_t rop, const fmpq_poly_t op1, const fmpq_poly_t op2) noexcept # Adds the product of ``op1`` and ``op2`` to ``rop``. - void fmpq_poly_submul(fmpq_poly_t rop, const fmpq_poly_t op1, const fmpq_poly_t op2) + void fmpq_poly_submul(fmpq_poly_t rop, const fmpq_poly_t op1, const fmpq_poly_t op2) noexcept # Subtracts the product of ``op1`` and ``op2`` from ``rop``. - void _fmpq_poly_pow(fmpz * rpoly, fmpz_t rden, const fmpz * poly, const fmpz_t den, slong len, ulong e) + void _fmpq_poly_pow(fmpz * rpoly, fmpz_t rden, const fmpz * poly, const fmpz_t den, slong len, ulong e) noexcept # Sets ``(rpoly, rden)`` to ``(poly, den)^e``, assuming # ``e, len > 0``. Assumes that ``rpoly`` is an array of # length at least ``e * (len - 1) + 1``. Supports aliasing # of ``(rpoly, den)`` and ``(poly, den)``. - void fmpq_poly_pow(fmpq_poly_t res, const fmpq_poly_t poly, ulong e) + void fmpq_poly_pow(fmpq_poly_t res, const fmpq_poly_t poly, ulong e) noexcept # Sets ``res`` to ``poly^e``, where the only special case `0^0` is # defined as `1`. - void _fmpq_poly_pow_trunc(fmpz * res, fmpz_t rden, const fmpz * f, const fmpz_t fden, slong flen, ulong exp, slong len) + void _fmpq_poly_pow_trunc(fmpz * res, fmpz_t rden, const fmpz * f, const fmpz_t fden, slong flen, ulong exp, slong len) noexcept # Sets ``(rpoly, rden, len)`` to ``(poly, den)^e`` truncated to length ``len``, # where ``len`` is at most ``e * (flen - 1) + 1``. - void fmpq_poly_pow_trunc(fmpq_poly_t res, const fmpq_poly_t poly, ulong e, slong n) + void fmpq_poly_pow_trunc(fmpq_poly_t res, const fmpq_poly_t poly, ulong e, slong n) noexcept # Sets ``res`` to ``poly^e`` truncated to length ``n``. - void fmpq_poly_shift_left(fmpq_poly_t res, const fmpq_poly_t poly, slong n) + void fmpq_poly_shift_left(fmpq_poly_t res, const fmpq_poly_t poly, slong n) noexcept # Set ``res`` to ``poly`` shifted left by `n` coefficients. Zero # coefficients are inserted. - void fmpq_poly_shift_right(fmpq_poly_t res, const fmpq_poly_t poly, slong n) + void fmpq_poly_shift_right(fmpq_poly_t res, const fmpq_poly_t poly, slong n) noexcept # Set ``res`` to ``poly`` shifted right by `n` coefficients. # If `n` is equal to or greater than the current length of ``poly``, # ``res`` is set to the zero polynomial. - void _fmpq_poly_divrem(fmpz * Q, fmpz_t q, fmpz * R, fmpz_t r, const fmpz * A, const fmpz_t a, slong lenA, const fmpz * B, const fmpz_t b, slong lenB, const fmpz_preinvn_t inv) + void _fmpq_poly_divrem(fmpz * Q, fmpz_t q, fmpz * R, fmpz_t r, const fmpz * A, const fmpz_t a, slong lenA, const fmpz * B, const fmpz_t b, slong lenB, const fmpz_preinvn_t inv) noexcept # Finds the quotient ``(Q, q)`` and remainder ``(R, r)`` of the # Euclidean division of ``(A, a)`` by ``(B, b)``. # Assumes that ``lenA >= lenB > 0``. Assumes that `R` has space for @@ -511,11 +507,11 @@ cdef extern from "flint_wrap.h": # Note: ``fmpz.h`` has to be included before ``fmpq_poly.h`` in order for the # latter to declare this function. - void fmpq_poly_divrem(fmpq_poly_t Q, fmpq_poly_t R, const fmpq_poly_t poly1, const fmpq_poly_t poly2) + void fmpq_poly_divrem(fmpq_poly_t Q, fmpq_poly_t R, const fmpq_poly_t poly1, const fmpq_poly_t poly2) noexcept # Finds the quotient `Q` and remainder `R` of the Euclidean division of # ``poly1`` by ``poly2``. - void _fmpq_poly_div(fmpz * Q, fmpz_t q, const fmpz * A, const fmpz_t a, slong lenA, const fmpz * B, const fmpz_t b, slong lenB, const fmpz_preinvn_t inv) + void _fmpq_poly_div(fmpz * Q, fmpz_t q, const fmpz * A, const fmpz_t a, slong lenA, const fmpz * B, const fmpz_t b, slong lenB, const fmpz_preinvn_t inv) noexcept # Finds the quotient ``(Q, q)`` of the Euclidean division # of ``(A, a)`` by ``(B, b)``. # Assumes that ``lenA >= lenB > 0``. Supports no aliasing @@ -526,11 +522,11 @@ cdef extern from "flint_wrap.h": # Note: ``fmpz.h`` has to be included before ``fmpq_poly.h`` in order for the # latter to declare this function. - void fmpq_poly_div(fmpq_poly_t Q, const fmpq_poly_t poly1, const fmpq_poly_t poly2) + void fmpq_poly_div(fmpq_poly_t Q, const fmpq_poly_t poly1, const fmpq_poly_t poly2) noexcept # Finds the quotient `Q` and remainder `R` of the Euclidean division # of ``poly1`` by ``poly2``. - void _fmpq_poly_rem(fmpz * R, fmpz_t r, const fmpz * A, const fmpz_t a, slong lenA, const fmpz * B, const fmpz_t b, slong lenB, const fmpz_preinvn_t inv) + void _fmpq_poly_rem(fmpz * R, fmpz_t r, const fmpz * A, const fmpz_t a, slong lenA, const fmpz * B, const fmpz_t b, slong lenB, const fmpz_preinvn_t inv) noexcept # Finds the remainder ``(R, r)`` of the Euclidean division # of ``(A, a)`` by ``(B, b)``. # Assumes that ``lenA >= lenB > 0``. Supports no aliasing between @@ -541,77 +537,77 @@ cdef extern from "flint_wrap.h": # Note: ``fmpz.h`` has to be included before ``fmpq_poly.h`` in order for the # latter to declare this function. - void fmpq_poly_rem(fmpq_poly_t R, const fmpq_poly_t poly1, const fmpq_poly_t poly2) + void fmpq_poly_rem(fmpq_poly_t R, const fmpq_poly_t poly1, const fmpq_poly_t poly2) noexcept # Finds the remainder `R` of the Euclidean division # of ``poly1`` by ``poly2``. - fmpq_poly_struct * _fmpq_poly_powers_precompute(const fmpz * B, const fmpz_t denB, slong len) + fmpq_poly_struct * _fmpq_poly_powers_precompute(const fmpz * B, const fmpz_t denB, slong len) noexcept # Computes ``2*len - 1`` powers of `x` modulo the polynomial `B` of # the given length. This is used as a kind of precomputed inverse in # the remainder routine below. - void fmpq_poly_powers_precompute(fmpq_poly_powers_precomp_t pinv, fmpq_poly_t poly) + void fmpq_poly_powers_precompute(fmpq_poly_powers_precomp_t pinv, fmpq_poly_t poly) noexcept # Computes ``2*len - 1`` powers of `x` modulo the polynomial `B` of the given length. This is used as a kind of precomputed inverse in the remainder routine below. - void _fmpq_poly_powers_clear(fmpq_poly_struct * powers, slong len) + void _fmpq_poly_powers_clear(fmpq_poly_struct * powers, slong len) noexcept # Clean up resources used by precomputed powers which have been computed # by ``_fmpq_poly_powers_precompute``. - void fmpq_poly_powers_clear(fmpq_poly_powers_precomp_t pinv) + void fmpq_poly_powers_clear(fmpq_poly_powers_precomp_t pinv) noexcept # Clean up resources used by precomputed powers which have been computed # by ``fmpq_poly_powers_precompute``. - void _fmpq_poly_rem_powers_precomp(fmpz * A, fmpz_t denA, slong m, const fmpz * B, const fmpz_t denB, slong n, fmpq_poly_struct * const powers) + void _fmpq_poly_rem_powers_precomp(fmpz * A, fmpz_t denA, slong m, const fmpz * B, const fmpz_t denB, slong n, fmpq_poly_struct * const powers) noexcept # Set `A` to the remainder of `A` divide `B` given precomputed powers mod `B` # provided by ``_fmpq_poly_powers_precompute``. No aliasing is allowed. # This function is only faster if `m \leq 2\cdot n - 1`. # The output of this function is *not* canonicalised. - void fmpq_poly_rem_powers_precomp(fmpq_poly_t R, const fmpq_poly_t A, const fmpq_poly_t B, const fmpq_poly_powers_precomp_t B_inv) + void fmpq_poly_rem_powers_precomp(fmpq_poly_t R, const fmpq_poly_t A, const fmpq_poly_t B, const fmpq_poly_powers_precomp_t B_inv) noexcept # Set `R` to the remainder of `A` divide `B` given precomputed powers mod `B` # provided by ``fmpq_poly_powers_precompute``. # This function is only faster if ``A->length <= 2*B->length - 1``. # The output of this function is *not* canonicalised. - int _fmpq_poly_divides(fmpz * qpoly, fmpz_t qden, const fmpz * poly1, const fmpz_t den1, slong len1, const fmpz * poly2, const fmpz_t den2, slong len2) + int _fmpq_poly_divides(fmpz * qpoly, fmpz_t qden, const fmpz * poly1, const fmpz_t den1, slong len1, const fmpz * poly2, const fmpz_t den2, slong len2) noexcept # Return `1` if ``(poly2, den2, len2)`` divides ``(poly1, den1, len1)`` and # set ``(qpoly, qden, len1 - len2 + 1)`` to the quotient. Otherwise return # `0`. Requires that ``qpoly`` has space for ``len1 - len2 + 1`` # coefficients and that ``len1 >= len2 > 0``. - int fmpq_poly_divides(fmpq_poly_t q, const fmpq_poly_t poly1, const fmpq_poly_t poly2) + int fmpq_poly_divides(fmpq_poly_t q, const fmpq_poly_t poly1, const fmpq_poly_t poly2) noexcept # Return `1` if ``poly2`` divides ``poly1`` and set ``q`` to the quotient. # Otherwise return `0`. - slong fmpq_poly_remove(fmpq_poly_t q, const fmpq_poly_t poly1, const fmpq_poly_t poly2) + slong fmpq_poly_remove(fmpq_poly_t q, const fmpq_poly_t poly1, const fmpq_poly_t poly2) noexcept # Sets ``q`` to the quotient of ``poly1`` by the highest power of ``poly2`` # which divides it, and returns the power. The divisor ``poly2`` must not be # constant or an exception is raised. - void _fmpq_poly_inv_series_newton(fmpz * rpoly, fmpz_t rden, const fmpz * poly, const fmpz_t den, slong len, slong n) + void _fmpq_poly_inv_series_newton(fmpz * rpoly, fmpz_t rden, const fmpz * poly, const fmpz_t den, slong len, slong n) noexcept # Computes the first `n` terms of the inverse power series of # ``(poly, den, len)`` using Newton iteration. # The result is produced in canonical form. # Assumes that `n \geq 1` and that ``poly`` has non-zero constant term. # Does not support aliasing. - void fmpq_poly_inv_series_newton(fmpq_poly_t res, const fmpq_poly_t poly, slong n) + void fmpq_poly_inv_series_newton(fmpq_poly_t res, const fmpq_poly_t poly, slong n) noexcept # Computes the first `n` terms of the inverse power series # of ``poly`` using Newton iteration, assuming that ``poly`` # has non-zero constant term and `n \geq 1`. - void _fmpq_poly_inv_series(fmpz * rpoly, fmpz_t rden, const fmpz * poly, const fmpz_t den, slong den_len, slong n) + void _fmpq_poly_inv_series(fmpz * rpoly, fmpz_t rden, const fmpz * poly, const fmpz_t den, slong den_len, slong n) noexcept # Computes the first `n` terms of the inverse power series of # ``(poly, den, len)``. # The result is produced in canonical form. # Assumes that `n \geq 1` and that ``poly`` has non-zero constant term. # Does not support aliasing. - void fmpq_poly_inv_series(fmpq_poly_t res, const fmpq_poly_t poly, slong n) + void fmpq_poly_inv_series(fmpq_poly_t res, const fmpq_poly_t poly, slong n) noexcept # Computes the first `n` terms of the inverse power series of ``poly``, # assuming that ``poly`` has non-zero constant term and `n \geq 1`. - void _fmpq_poly_div_series(fmpz * Q, fmpz_t denQ, const fmpz * A, const fmpz_t denA, slong lenA, const fmpz * B, const fmpz_t denB, slong lenB, slong n) + void _fmpq_poly_div_series(fmpz * Q, fmpz_t denQ, const fmpz * A, const fmpz_t denA, slong lenA, const fmpz * B, const fmpz_t denB, slong lenB, slong n) noexcept # Divides ``(A, denA, lenA)`` by ``(B, denB, lenB)`` as power series # over `\mathbb{Q}`, assuming `B` has non-zero constant term and that # all lengths are positive. @@ -619,24 +615,24 @@ cdef extern from "flint_wrap.h": # This function ensures that the numerator and denominator # are coprime on exit. - void fmpq_poly_div_series(fmpq_poly_t Q, const fmpq_poly_t A, const fmpq_poly_t B, slong n) + void fmpq_poly_div_series(fmpq_poly_t Q, const fmpq_poly_t A, const fmpq_poly_t B, slong n) noexcept # Performs power series division in `\mathbb{Q}[[x]] / (x^n)`. The function # considers the polynomials `A` and `B` as power series of length `n` # starting with the constant terms. The function assumes that `B` has # non-zero constant term and `n \geq 1`. - void _fmpq_poly_gcd(fmpz *G, fmpz_t denG, const fmpz *A, slong lenA, const fmpz *B, slong lenB) + void _fmpq_poly_gcd(fmpz *G, fmpz_t denG, const fmpz *A, slong lenA, const fmpz *B, slong lenB) noexcept # Computes the monic greatest common divisor `G` of `A` and `B`. # Assumes that `G` has space for `\operatorname{len}(B)` coefficients, # where `\operatorname{len}(A) \geq \operatorname{len}(B) > 0`. # Aliasing between the output and input arguments is not supported. # Does not support zero-padding. - void fmpq_poly_gcd(fmpq_poly_t G, const fmpq_poly_t A, const fmpq_poly_t B) + void fmpq_poly_gcd(fmpq_poly_t G, const fmpq_poly_t A, const fmpq_poly_t B) noexcept # Computes the monic greatest common divisor `G` of `A` and `B`. # In the special case when `A = B = 0`, sets `G = 0`. - void _fmpq_poly_xgcd(fmpz *G, fmpz_t denG, fmpz *S, fmpz_t denS, fmpz *T, fmpz_t denT, const fmpz *A, const fmpz_t denA, slong lenA, const fmpz *B, const fmpz_t denB, slong lenB) + void _fmpq_poly_xgcd(fmpz *G, fmpz_t denG, fmpz *S, fmpz_t denS, fmpz *T, fmpz_t denT, const fmpz *A, const fmpz_t denA, slong lenA, const fmpz *B, const fmpz_t denB, slong lenB) noexcept # Computes polynomials `G`, `S`, and `T` such that # `G = \gcd(A, B) = S A + T B`, where `G` is the monic # greatest common divisor of `A` and `B`. @@ -645,7 +641,7 @@ cdef extern from "flint_wrap.h": # where it is also assumed that `\operatorname{len}(A) \geq \operatorname{len}(B) > 0`. # Does not support zero padding of the input arguments. - void fmpq_poly_xgcd(fmpq_poly_t G, fmpq_poly_t S, fmpq_poly_t T, const fmpq_poly_t A, const fmpq_poly_t B) + void fmpq_poly_xgcd(fmpq_poly_t G, fmpq_poly_t S, fmpq_poly_t T, const fmpq_poly_t A, const fmpq_poly_t B) noexcept # Computes polynomials `G`, `S`, and `T` such that # `G = \gcd(A, B) = S A + T B`, where `G` is the monic # greatest common divisor of `A` and `B`. @@ -654,25 +650,25 @@ cdef extern from "flint_wrap.h": # scalar multiple of `G = A`, `S = 1`, and `T = 0`. The case # when `A = 0`, `B \neq 0` is handled similarly. - void _fmpq_poly_lcm(fmpz *L, fmpz_t denL, const fmpz *A, slong lenA, const fmpz *B, slong lenB) + void _fmpq_poly_lcm(fmpz *L, fmpz_t denL, const fmpz *A, slong lenA, const fmpz *B, slong lenB) noexcept # Computes the monic least common multiple `L` of `A` and `B`. # Assumes that `L` has space for `\operatorname{len}(A) + \operatorname{len}(B) - 1` coefficients, # where `\operatorname{len}(A) \geq \operatorname{len}(B) > 0`. # Aliasing between the output and input arguments is not supported. # Does not support zero-padding. - void fmpq_poly_lcm(fmpq_poly_t L, const fmpq_poly_t A, const fmpq_poly_t B) + void fmpq_poly_lcm(fmpq_poly_t L, const fmpq_poly_t A, const fmpq_poly_t B) noexcept # Computes the monic least common multiple `L` of `A` and `B`. # In the special case when `A = B = 0`, sets `L = 0`. - void _fmpq_poly_resultant(fmpz_t rnum, fmpz_t rden, const fmpz *poly1, const fmpz_t den1, slong len1, const fmpz *poly2, const fmpz_t den2, slong len2) + void _fmpq_poly_resultant(fmpz_t rnum, fmpz_t rden, const fmpz *poly1, const fmpz_t den1, slong len1, const fmpz *poly2, const fmpz_t den2, slong len2) noexcept # Sets ``(rnum, rden)`` to the resultant of the two input # polynomials. # Assumes that ``len1 >= len2 > 0``. Does not support zero-padding # of the input polynomials. Does not support aliasing of the input and # output arguments. - void fmpq_poly_resultant(fmpq_t r, const fmpq_poly_t f, const fmpq_poly_t g) + void fmpq_poly_resultant(fmpq_t r, const fmpq_poly_t f, const fmpq_poly_t g) noexcept # Returns the resultant of `f` and `g`. # Enumerating the roots of `f` and `g` over `\bar{\mathbf{Q}}` as # `r_1, \dotsc, r_m` and `s_1, \dotsc, s_n`, respectively, and @@ -684,240 +680,240 @@ cdef extern from "flint_wrap.h": # the resultant is zero. Note that otherwise if one of the polynomials is # constant, the last term in the above expression is the empty product. - void fmpq_poly_resultant_div(fmpq_t r, const fmpq_poly_t f, const fmpq_poly_t g, const fmpz_t div, slong nbits) + void fmpq_poly_resultant_div(fmpq_t r, const fmpq_poly_t f, const fmpq_poly_t g, const fmpz_t div, slong nbits) noexcept # Returns the resultant of `f` and `g` divided by ``div`` under the # assumption that the result has at most ``nbits`` bits. The result must # be an integer. - void _fmpq_poly_derivative(fmpz * rpoly, fmpz_t rden, const fmpz * poly, const fmpz_t den, slong len) + void _fmpq_poly_derivative(fmpz * rpoly, fmpz_t rden, const fmpz * poly, const fmpz_t den, slong len) noexcept # Sets ``(rpoly, rden, len - 1)`` to the derivative of # ``(poly, den, len)``. Does nothing if ``len <= 1``. # Supports aliasing between the two polynomials. - void fmpq_poly_derivative(fmpq_poly_t res, const fmpq_poly_t poly) + void fmpq_poly_derivative(fmpq_poly_t res, const fmpq_poly_t poly) noexcept # Sets ``res`` to the derivative of ``poly``. - void _fmpq_poly_nth_derivative(fmpz * rpoly, fmpz_t rden, const fmpz * poly, const fmpz_t den, ulong n, slong len) + void _fmpq_poly_nth_derivative(fmpz * rpoly, fmpz_t rden, const fmpz * poly, const fmpz_t den, ulong n, slong len) noexcept # Sets ``(rpoly, rden, len - n)`` to the nth derivative of # ``(poly, den, len)``. Does nothing if ``len <= n``. # Supports aliasing between the two polynomials. - void fmpq_poly_nth_derivative(fmpq_poly_t res, const fmpq_poly_t poly, ulong n) + void fmpq_poly_nth_derivative(fmpq_poly_t res, const fmpq_poly_t poly, ulong n) noexcept # Sets ``res`` to the nth derivative of ``poly``. - void _fmpq_poly_integral(fmpz * rpoly, fmpz_t rden, const fmpz * poly, const fmpz_t den, slong len) + void _fmpq_poly_integral(fmpz * rpoly, fmpz_t rden, const fmpz * poly, const fmpz_t den, slong len) noexcept # Sets ``(rpoly, rden, len)`` to the integral of # ``(poly, den, len - 1)``. Assumes ``len >= 0``. # Supports aliasing between the two polynomials. # The output will be in canonical form if the input is # in canonical form. - void fmpq_poly_integral(fmpq_poly_t res, const fmpq_poly_t poly) + void fmpq_poly_integral(fmpq_poly_t res, const fmpq_poly_t poly) noexcept # Sets ``res`` to the integral of ``poly``. The constant # term is set to zero. In particular, the integral of the zero # polynomial is the zero polynomial. - void _fmpq_poly_sqrt_series(fmpz * g, fmpz_t gden, const fmpz * f, const fmpz_t fden, slong flen, slong n) + void _fmpq_poly_sqrt_series(fmpz * g, fmpz_t gden, const fmpz * f, const fmpz_t fden, slong flen, slong n) noexcept # Sets ``(g, gden, n)`` to the series expansion of the # square root of ``(f, fden, flen)``. Assumes ``n > 0`` and # that ``(f, fden, flen)`` has constant term 1. # Does not support aliasing between the input and output polynomials. - void fmpq_poly_sqrt_series(fmpq_poly_t res, const fmpq_poly_t f, slong n) + void fmpq_poly_sqrt_series(fmpq_poly_t res, const fmpq_poly_t f, slong n) noexcept # Sets ``res`` to the series expansion of the square root of ``f`` # to order ``n > 1``. Requires ``f`` to have constant term 1. - void _fmpq_poly_invsqrt_series(fmpz * g, fmpz_t gden, const fmpz * f, const fmpz_t fden, slong flen, slong n) + void _fmpq_poly_invsqrt_series(fmpz * g, fmpz_t gden, const fmpz * f, const fmpz_t fden, slong flen, slong n) noexcept # Sets ``(g, gden, n)`` to the series expansion of the inverse # square root of ``(f, fden, flen)``. Assumes ``n > 0`` and # that ``(f, fden, flen)`` has constant term 1. # Does not support aliasing between the input and output polynomials. - void fmpq_poly_invsqrt_series(fmpq_poly_t res, const fmpq_poly_t f, slong n) + void fmpq_poly_invsqrt_series(fmpq_poly_t res, const fmpq_poly_t f, slong n) noexcept # Sets ``res`` to the series expansion of the inverse square root of # ``f`` to order ``n > 0``. Requires ``f`` to have constant term 1. - void _fmpq_poly_power_sums(fmpz * res, fmpz_t rden, const fmpz * poly, slong len, slong n) + void _fmpq_poly_power_sums(fmpz * res, fmpz_t rden, const fmpz * poly, slong len, slong n) noexcept # Compute the (truncated) power sums series of the polynomial # ``(poly,len)`` up to length `n` using Newton identities. - void fmpq_poly_power_sums(fmpq_poly_t res, const fmpq_poly_t poly, slong n) + void fmpq_poly_power_sums(fmpq_poly_t res, const fmpq_poly_t poly, slong n) noexcept # Compute the (truncated) power sum series of the monic polynomial # ``poly`` up to length `n` using Newton identities. That is the power # series whose coefficient of degree `i` is the sum of the `i`-th power of # all (complex) roots of the polynomial ``poly``. - void _fmpq_poly_power_sums_to_poly(fmpz * res, const fmpz * poly, const fmpz_t den, slong len) + void _fmpq_poly_power_sums_to_poly(fmpz * res, const fmpz * poly, const fmpz_t den, slong len) noexcept # Compute an integer polynomial given by its power sums series ``(poly,den,len)``. - void fmpq_poly_power_sums_to_fmpz_poly(fmpz_poly_t res, const fmpq_poly_t Q) + void fmpq_poly_power_sums_to_fmpz_poly(fmpz_poly_t res, const fmpq_poly_t Q) noexcept # Compute the integer polynomial with content one and positive leading # coefficient given by its power sums series ``Q``. - void fmpq_poly_power_sums_to_poly(fmpq_poly_t res, const fmpq_poly_t Q) + void fmpq_poly_power_sums_to_poly(fmpq_poly_t res, const fmpq_poly_t Q) noexcept # Compute the monic polynomial from its power sums series ``Q``. - void _fmpq_poly_log_series(fmpz * g, fmpz_t gden, const fmpz * f, const fmpz_t fden, slong flen, slong n) + void _fmpq_poly_log_series(fmpz * g, fmpz_t gden, const fmpz * f, const fmpz_t fden, slong flen, slong n) noexcept # Sets ``(g, gden, n)`` to the series expansion of the # logarithm of ``(f, fden, flen)``. Assumes ``n > 0`` and # that ``(f, fden, flen)`` has constant term 1. # Supports aliasing between the input and output polynomials. - void fmpq_poly_log_series(fmpq_poly_t res, const fmpq_poly_t f, slong n) + void fmpq_poly_log_series(fmpq_poly_t res, const fmpq_poly_t f, slong n) noexcept # Sets ``res`` to the series expansion of the logarithm of ``f`` # to order ``n > 0``. Requires ``f`` to have constant term 1. - void _fmpq_poly_exp_series(fmpz * g, fmpz_t gden, const fmpz * h, const fmpz_t hden, slong hlen, slong n) + void _fmpq_poly_exp_series(fmpz * g, fmpz_t gden, const fmpz * h, const fmpz_t hden, slong hlen, slong n) noexcept # Sets ``(g, gden, n)`` to the series expansion of the # exponential function of ``(h, hden, hlen)``. Assumes # ``n > 0, hlen > 0`` and # that ``(h, hden, hlen)`` has constant term 0. # Supports aliasing between the input and output polynomials. - void fmpq_poly_exp_series(fmpq_poly_t res, const fmpq_poly_t h, slong n) + void fmpq_poly_exp_series(fmpq_poly_t res, const fmpq_poly_t h, slong n) noexcept # Sets ``res`` to the series expansion of the exponential function # of ``h`` to order ``n > 0``. Requires ``f`` to have # constant term 0. - void _fmpq_poly_exp_expinv_series(fmpz * res1, fmpz_t res1den, fmpz * res2, fmpz_t res2den, const fmpz * h, const fmpz_t hden, slong hlen, slong n) + void _fmpq_poly_exp_expinv_series(fmpz * res1, fmpz_t res1den, fmpz * res2, fmpz_t res2den, const fmpz * h, const fmpz_t hden, slong hlen, slong n) noexcept # The same as ``fmpq_poly_exp_series``, but simultaneously computes # the exponential (in ``res1``, ``res1den``) and its multiplicative inverse # (in ``res2``, ``res2den``). # Supports aliasing between the input and output polynomials. - void fmpq_poly_exp_expinv_series(fmpq_poly_t res1, fmpq_poly_t res2, const fmpq_poly_t h, slong n) + void fmpq_poly_exp_expinv_series(fmpq_poly_t res1, fmpq_poly_t res2, const fmpq_poly_t h, slong n) noexcept # The same as ``fmpq_poly_exp_series``, but simultaneously computes # the exponential (in ``res1``) and its multiplicative inverse # (in ``res2``). - void _fmpq_poly_atan_series(fmpz * g, fmpz_t gden, const fmpz * f, const fmpz_t fden, slong flen, slong n) + void _fmpq_poly_atan_series(fmpz * g, fmpz_t gden, const fmpz * f, const fmpz_t fden, slong flen, slong n) noexcept # Sets ``(g, gden, n)`` to the series expansion of the # inverse tangent of ``(f, fden, flen)``. Assumes ``n > 0`` and # that ``(f, fden, flen)`` has constant term 0. # Supports aliasing between the input and output polynomials. - void fmpq_poly_atan_series(fmpq_poly_t res, const fmpq_poly_t f, slong n) + void fmpq_poly_atan_series(fmpq_poly_t res, const fmpq_poly_t f, slong n) noexcept # Sets ``res`` to the series expansion of the inverse tangent of ``f`` # to order ``n > 0``. Requires ``f`` to have constant term 0. - void _fmpq_poly_atanh_series(fmpz * g, fmpz_t gden, const fmpz * f, const fmpz_t fden, slong flen, slong n) + void _fmpq_poly_atanh_series(fmpz * g, fmpz_t gden, const fmpz * f, const fmpz_t fden, slong flen, slong n) noexcept # Sets ``(g, gden, n)`` to the series expansion of the inverse # hyperbolic tangent of ``(f, fden, flen)``. Assumes ``n > 0`` and # that ``(f, fden, flen)`` has constant term 0. # Supports aliasing between the input and output polynomials. - void fmpq_poly_atanh_series(fmpq_poly_t res, const fmpq_poly_t f, slong n) + void fmpq_poly_atanh_series(fmpq_poly_t res, const fmpq_poly_t f, slong n) noexcept # Sets ``res`` to the series expansion of the inverse hyperbolic # tangent of ``f`` to order ``n > 0``. Requires ``f`` to have # constant term 0. - void _fmpq_poly_asin_series(fmpz * g, fmpz_t gden, const fmpz * f, const fmpz_t fden, slong flen, slong n) + void _fmpq_poly_asin_series(fmpz * g, fmpz_t gden, const fmpz * f, const fmpz_t fden, slong flen, slong n) noexcept # Sets ``(g, gden, n)`` to the series expansion of the # inverse sine of ``(f, fden, flen)``. Assumes ``n > 0`` and # that ``(f, fden, flen)`` has constant term 0. # Supports aliasing between the input and output polynomials. - void fmpq_poly_asin_series(fmpq_poly_t res, const fmpq_poly_t f, slong n) + void fmpq_poly_asin_series(fmpq_poly_t res, const fmpq_poly_t f, slong n) noexcept # Sets ``res`` to the series expansion of the inverse sine of ``f`` # to order ``n > 0``. Requires ``f`` to have constant term 0. - void _fmpq_poly_asinh_series(fmpz * g, fmpz_t gden, const fmpz * f, const fmpz_t fden, slong flen, slong n) + void _fmpq_poly_asinh_series(fmpz * g, fmpz_t gden, const fmpz * f, const fmpz_t fden, slong flen, slong n) noexcept # Sets ``(g, gden, n)`` to the series expansion of the inverse # hyperbolic sine of ``(f, fden, flen)``. Assumes ``n > 0`` and # that ``(f, fden, flen)`` has constant term 0. # Supports aliasing between the input and output polynomials. - void fmpq_poly_asinh_series(fmpq_poly_t res, const fmpq_poly_t f, slong n) + void fmpq_poly_asinh_series(fmpq_poly_t res, const fmpq_poly_t f, slong n) noexcept # Sets ``res`` to the series expansion of the inverse hyperbolic # sine of ``f`` to order ``n > 0``. Requires ``f`` to have # constant term 0. - void _fmpq_poly_tan_series(fmpz * g, fmpz_t gden, const fmpz * f, const fmpz_t fden, slong flen, slong n) + void _fmpq_poly_tan_series(fmpz * g, fmpz_t gden, const fmpz * f, const fmpz_t fden, slong flen, slong n) noexcept # Sets ``(g, gden, n)`` to the series expansion of the # tangent function of ``(f, fden, flen)``. Assumes ``n > 0`` and # that ``(f, fden, flen)`` has constant term 0. # Does not support aliasing between the input and output polynomials. - void fmpq_poly_tan_series(fmpq_poly_t res, const fmpq_poly_t f, slong n) + void fmpq_poly_tan_series(fmpq_poly_t res, const fmpq_poly_t f, slong n) noexcept # Sets ``res`` to the series expansion of the tangent function # of ``f`` to order ``n > 0``. Requires ``f`` to have # constant term 0. - void _fmpq_poly_sin_series(fmpz * g, fmpz_t gden, const fmpz * f, const fmpz_t fden, slong flen, slong n) + void _fmpq_poly_sin_series(fmpz * g, fmpz_t gden, const fmpz * f, const fmpz_t fden, slong flen, slong n) noexcept # Sets ``(g, gden, n)`` to the series expansion of the # sine of ``(f, fden, flen)``. Assumes ``n > 0`` and # that ``(f, fden, flen)`` has constant term 0. # Supports aliasing between the input and output polynomials. - void fmpq_poly_sin_series(fmpq_poly_t res, const fmpq_poly_t f, slong n) + void fmpq_poly_sin_series(fmpq_poly_t res, const fmpq_poly_t f, slong n) noexcept # Sets ``res`` to the series expansion of the sine of ``f`` # to order ``n > 0``. Requires ``f`` to have constant term 0. - void _fmpq_poly_cos_series(fmpz * g, fmpz_t gden, const fmpz * f, const fmpz_t fden, slong flen, slong n) + void _fmpq_poly_cos_series(fmpz * g, fmpz_t gden, const fmpz * f, const fmpz_t fden, slong flen, slong n) noexcept # Sets ``(g, gden, n)`` to the series expansion of the # cosine of ``(f, fden, flen)``. Assumes ``n > 0`` and # that ``(f, fden, flen)`` has constant term 0. # Supports aliasing between the input and output polynomials. - void fmpq_poly_cos_series(fmpq_poly_t res, const fmpq_poly_t f, slong n) + void fmpq_poly_cos_series(fmpq_poly_t res, const fmpq_poly_t f, slong n) noexcept # Sets ``res`` to the series expansion of the cosine of ``f`` # to order ``n > 0``. Requires ``f`` to have constant term 0. - void _fmpq_poly_sin_cos_series(fmpz * s, fmpz_t sden, fmpz * c, fmpz_t cden, const fmpz * f, const fmpz_t fden, slong flen, slong n) + void _fmpq_poly_sin_cos_series(fmpz * s, fmpz_t sden, fmpz * c, fmpz_t cden, const fmpz * f, const fmpz_t fden, slong flen, slong n) noexcept # Sets ``(s, sden, n)`` to the series expansion of the # sine of ``(f, fden, flen)``, and ``(c, cden, n)`` to the series # expansion of the cosine. Assumes ``n > 0`` and # that ``(f, fden, flen)`` has constant term 0. # Supports aliasing between the input and output polynomials. - void fmpq_poly_sin_cos_series(fmpq_poly_t res1, fmpq_poly_t res2, const fmpq_poly_t f, slong n) + void fmpq_poly_sin_cos_series(fmpq_poly_t res1, fmpq_poly_t res2, const fmpq_poly_t f, slong n) noexcept # Sets ``res1`` to the series expansion of the sine of ``f`` # to order ``n > 0``, and ``res2`` to the series expansion # of the cosine. Requires ``f`` to have constant term 0. - void _fmpq_poly_sinh_series(fmpz * g, fmpz_t gden, const fmpz * f, const fmpz_t fden, slong flen, slong n) + void _fmpq_poly_sinh_series(fmpz * g, fmpz_t gden, const fmpz * f, const fmpz_t fden, slong flen, slong n) noexcept # Sets ``(g, gden, n)`` to the series expansion of the # hyperbolic sine of ``(f, fden, flen)``. Assumes ``n > 0`` and # that ``(f, fden, flen)`` has constant term 0. # Does not support aliasing between the input and output polynomials. - void fmpq_poly_sinh_series(fmpq_poly_t res, const fmpq_poly_t f, slong n) + void fmpq_poly_sinh_series(fmpq_poly_t res, const fmpq_poly_t f, slong n) noexcept # Sets ``res`` to the series expansion of the hyperbolic sine of ``f`` # to order ``n > 0``. Requires ``f`` to have constant term 0. - void _fmpq_poly_cosh_series(fmpz * g, fmpz_t gden, const fmpz * f, const fmpz_t fden, slong flen, slong n) + void _fmpq_poly_cosh_series(fmpz * g, fmpz_t gden, const fmpz * f, const fmpz_t fden, slong flen, slong n) noexcept # Sets ``(g, gden, n)`` to the series expansion of the hyperbolic # cosine of ``(f, fden, flen)``. Assumes ``n > 0`` and # that ``(f, fden, flen)`` has constant term 0. # Does not support aliasing between the input and output polynomials. - void fmpq_poly_cosh_series(fmpq_poly_t res, const fmpq_poly_t f, slong n) + void fmpq_poly_cosh_series(fmpq_poly_t res, const fmpq_poly_t f, slong n) noexcept # Sets ``res`` to the series expansion of the hyperbolic cosine of # ``f`` to order ``n > 0``. Requires ``f`` to have constant term 0. - void _fmpq_poly_sinh_cosh_series(fmpz * s, fmpz_t sden, fmpz * c, fmpz_t cden, const fmpz * f, const fmpz_t fden, slong flen, slong n) + void _fmpq_poly_sinh_cosh_series(fmpz * s, fmpz_t sden, fmpz * c, fmpz_t cden, const fmpz * f, const fmpz_t fden, slong flen, slong n) noexcept # Sets ``(s, sden, n)`` to the series expansion of the hyperbolic # sine of ``(f, fden, flen)``, and ``(c, cden, n)`` to the series # expansion of the hyperbolic cosine. Assumes ``n > 0`` and # that ``(f, fden, flen)`` has constant term 0. # Supports aliasing between the input and output polynomials. - void fmpq_poly_sinh_cosh_series(fmpq_poly_t res1, fmpq_poly_t res2, const fmpq_poly_t f, slong n) + void fmpq_poly_sinh_cosh_series(fmpq_poly_t res1, fmpq_poly_t res2, const fmpq_poly_t f, slong n) noexcept # Sets ``res1`` to the series expansion of the hyperbolic sine of ``f`` # to order ``n > 0``, and ``res2`` to the series expansion # of the hyperbolic cosine. Requires ``f`` to have constant term 0. - void _fmpq_poly_tanh_series(fmpz * g, fmpz_t gden, const fmpz * f, const fmpz_t fden, slong flen, slong n) + void _fmpq_poly_tanh_series(fmpz * g, fmpz_t gden, const fmpz * f, const fmpz_t fden, slong flen, slong n) noexcept # Sets ``(g, gden, n)`` to the series expansion of the # hyperbolic tangent of ``(f, fden, flen)``. Assumes ``n > 0`` and # that ``(f, fden, flen)`` has constant term 0. # Does not support aliasing between the input and output polynomials. - void fmpq_poly_tanh_series(fmpq_poly_t res, const fmpq_poly_t f, slong n) + void fmpq_poly_tanh_series(fmpq_poly_t res, const fmpq_poly_t f, slong n) noexcept # Sets ``res`` to the series expansion of the hyperbolic tangent of # ``f`` to order ``n > 0``. Requires ``f`` to have constant term 0. - void _fmpq_poly_legendre_p(fmpz * coeffs, fmpz_t den, ulong n) + void _fmpq_poly_legendre_p(fmpz * coeffs, fmpz_t den, ulong n) noexcept # Sets ``coeffs`` to the coefficient array of the Legendre polynomial # `P_n(x)`, defined by `(n+1) P_{n+1}(x) = (2n+1) x P_n(x) - n P_{n-1}(x)`, # for `n\ge0`. Sets ``den`` to the overall denominator. @@ -929,7 +925,7 @@ cdef extern from "flint_wrap.h": # `\gcd(n!,2^n) = 2^{\lfloor n/2 \rfloor + \lfloor n/4 \rfloor + \ldots}.` # See ``fmpz_poly`` for the shifted Legendre polynomials. - void fmpq_poly_legendre_p(fmpq_poly_t poly, ulong n) + void fmpq_poly_legendre_p(fmpq_poly_t poly, ulong n) noexcept # Sets ``poly`` to the Legendre polynomial `P_n(x)`, defined # by `(n+1) P_{n+1}(x) = (2n+1) x P_n(x) - n P_{n-1}(x)`, for `n\ge0`. # The coefficients are calculated using a hypergeometric recurrence. @@ -939,19 +935,19 @@ cdef extern from "flint_wrap.h": # `\gcd(n!,2^n) = 2^{\lfloor n/2 \rfloor + \lfloor n/4 \rfloor + \ldots}.` # See ``fmpz_poly`` for the shifted Legendre polynomials. - void _fmpq_poly_laguerre_l(fmpz * coeffs, fmpz_t den, ulong n) + void _fmpq_poly_laguerre_l(fmpz * coeffs, fmpz_t den, ulong n) noexcept # Sets ``coeffs`` to the coefficient array of the Laguerre polynomial # `L_n(x)`, defined by `(n+1) L_{n+1}(x) = (2n+1-x) L_n(x) - n L_{n-1}(x)`, # for `n\ge0`. Sets ``den`` to the overall denominator. # The coefficients are calculated using a hypergeometric recurrence. # The length of the array will be ``n+1``. - void fmpq_poly_laguerre_l(fmpq_poly_t poly, ulong n) + void fmpq_poly_laguerre_l(fmpq_poly_t poly, ulong n) noexcept # Sets ``poly`` to the Laguerre polynomial `L_n(x)`, defined by # `(n+1) L_{n+1}(x) = (2n+1-x) L_n(x) - n L_{n-1}(x)`, for `n\ge0`. # The coefficients are calculated using a hypergeometric recurrence. - void _fmpq_poly_gegenbauer_c(fmpz * coeffs, fmpz_t den, ulong n, const fmpq_t a) + void _fmpq_poly_gegenbauer_c(fmpz * coeffs, fmpz_t den, ulong n, const fmpq_t a) noexcept # Sets ``coeffs`` to the coefficient array of the Gegenbauer # (ultraspherical) polynomial # `C^{(\alpha)}_n(x) = \frac{(2\alpha)_n}{n!}{}_2F_1\left(-n,2\alpha+n; @@ -959,32 +955,32 @@ cdef extern from "flint_wrap.h": # `\alpha>0`. Sets ``den`` to the overall denominator. # The coefficients are calculated using a hypergeometric recurrence. - void fmpq_poly_gegenbauer_c(fmpq_poly_t poly, ulong n, const fmpq_t a) + void fmpq_poly_gegenbauer_c(fmpq_poly_t poly, ulong n, const fmpq_t a) noexcept # Sets ``poly`` to the Gegenbauer (ultraspherical) polynomial # `C^{(\alpha)}_n(x) = \frac{(2\alpha)_n}{n!}{}_2F_1\left(-n,2\alpha+n; # \alpha+\frac12;\frac{1-x}{2}\right)`, for integer `n\ge0` and rational # `\alpha>0`. # The coefficients are calculated using a hypergeometric recurrence. - void _fmpq_poly_evaluate_fmpz(fmpz_t rnum, fmpz_t rden, const fmpz * poly, const fmpz_t den, slong len, const fmpz_t a) + void _fmpq_poly_evaluate_fmpz(fmpz_t rnum, fmpz_t rden, const fmpz * poly, const fmpz_t den, slong len, const fmpz_t a) noexcept # Evaluates the polynomial ``(poly, den, len)`` at the integer `a` and # sets ``(rnum, rden)`` to the result in lowest terms. - void fmpq_poly_evaluate_fmpz(fmpq_t res, const fmpq_poly_t poly, const fmpz_t a) + void fmpq_poly_evaluate_fmpz(fmpq_t res, const fmpq_poly_t poly, const fmpz_t a) noexcept # Evaluates the polynomial ``poly`` at the integer `a` and sets # ``res`` to the result. - void _fmpq_poly_evaluate_fmpq(fmpz_t rnum, fmpz_t rden, const fmpz * poly, const fmpz_t den, slong len, const fmpz_t anum, const fmpz_t aden) + void _fmpq_poly_evaluate_fmpq(fmpz_t rnum, fmpz_t rden, const fmpz * poly, const fmpz_t den, slong len, const fmpz_t anum, const fmpz_t aden) noexcept # Evaluates the polynomial ``(poly, den, len)`` at the rational # ``(anum, aden)`` and sets ``(rnum, rden)`` to the result in # lowest terms. Aliasing between ``(rnum, rden)`` and # ``(anum, aden)`` is not supported. - void fmpq_poly_evaluate_fmpq(fmpq_t res, const fmpq_poly_t poly, const fmpq_t a) + void fmpq_poly_evaluate_fmpq(fmpq_t res, const fmpq_poly_t poly, const fmpq_t a) noexcept # Evaluates the polynomial ``poly`` at the rational `a` and # sets ``res`` to the result. - void _fmpq_poly_interpolate_fmpz_vec(fmpz * poly, fmpz_t den, const fmpz * xs, const fmpz * ys, slong n) + void _fmpq_poly_interpolate_fmpz_vec(fmpz * poly, fmpz_t den, const fmpz * xs, const fmpz * ys, slong n) noexcept # Sets ``poly`` / ``den`` to the unique interpolating polynomial of # degree at most `n - 1` satisfying `f(x_i) = y_i` for every pair `x_i, y_i` # in ``xs`` and ``ys``. @@ -997,31 +993,31 @@ cdef extern from "flint_wrap.h": # interpolation, clearing denominators to avoid working with fractions. # It is currently not designed to be efficient for large `n`. - void fmpq_poly_interpolate_fmpz_vec(fmpq_poly_t poly, const fmpz * xs, const fmpz * ys, slong n) + void fmpq_poly_interpolate_fmpz_vec(fmpq_poly_t poly, const fmpz * xs, const fmpz * ys, slong n) noexcept # Sets ``poly`` to the unique interpolating polynomial of degree # at most `n - 1` satisfying `f(x_i) = y_i` for every pair `x_i, y_i` # in ``xs`` and ``ys``. It is assumed that the `x` values are distinct. - void _fmpq_poly_compose(fmpz * res, fmpz_t den, const fmpz * poly1, const fmpz_t den1, slong len1, const fmpz * poly2, const fmpz_t den2, slong len2) + void _fmpq_poly_compose(fmpz * res, fmpz_t den, const fmpz * poly1, const fmpz_t den1, slong len1, const fmpz * poly2, const fmpz_t den2, slong len2) noexcept # Sets ``(res, den)`` to the composition of ``(poly1, den1, len1)`` # and ``(poly2, den2, len2)``, assuming ``len1, len2 > 0``. # Assumes that ``res`` has space for ``(len1 - 1) * (len2 - 1) + 1`` # coefficients. Does not support aliasing. - void fmpq_poly_compose(fmpq_poly_t res, const fmpq_poly_t poly1, const fmpq_poly_t poly2) + void fmpq_poly_compose(fmpq_poly_t res, const fmpq_poly_t poly1, const fmpq_poly_t poly2) noexcept # Sets ``res`` to the composition of ``poly1`` and ``poly2``. - void _fmpq_poly_rescale(fmpz * res, fmpz_t denr, const fmpz * poly, const fmpz_t den, slong len, const fmpz_t anum, const fmpz_t aden) + void _fmpq_poly_rescale(fmpz * res, fmpz_t denr, const fmpz * poly, const fmpz_t den, slong len, const fmpz_t anum, const fmpz_t aden) noexcept # Sets ``(res, denr, len)`` to ``(poly, den, len)`` with the # indeterminate rescaled by ``(anum, aden)``. # Assumes that ``len > 0`` and that ``(anum, aden)`` is non-zero and # in lowest terms. Supports aliasing between ``(res, denr, len)`` and # ``(poly, den, len)``. - void fmpq_poly_rescale(fmpq_poly_t res, const fmpq_poly_t poly, const fmpq_t a) + void fmpq_poly_rescale(fmpq_poly_t res, const fmpq_poly_t poly, const fmpq_t a) noexcept # Sets ``res`` to ``poly`` with the indeterminate rescaled by `a`. - void _fmpq_poly_compose_series_horner(fmpz * res, fmpz_t den, const fmpz * poly1, const fmpz_t den1, slong len1, const fmpz * poly2, const fmpz_t den2, slong len2, slong n) + void _fmpq_poly_compose_series_horner(fmpz * res, fmpz_t den, const fmpz * poly1, const fmpz_t den1, slong len1, const fmpz * poly2, const fmpz_t den2, slong len2, slong n) noexcept # Sets ``(res, den, n)`` to the composition of # ``(poly1, den1, len1)`` and ``(poly2, den2, len2)`` modulo `x^n`, # where the constant term of ``poly2`` is required to be zero. @@ -1033,7 +1029,7 @@ cdef extern from "flint_wrap.h": # The default ``fmpz_poly`` composition algorithm is automatically # used when the composition can be performed over the integers. - void fmpq_poly_compose_series_horner(fmpq_poly_t res, const fmpq_poly_t poly1, const fmpq_poly_t poly2, slong n) + void fmpq_poly_compose_series_horner(fmpq_poly_t res, const fmpq_poly_t poly1, const fmpq_poly_t poly2, slong n) noexcept # Sets ``res`` to the composition of ``poly1`` and ``poly2`` # modulo `x^n`, where the constant term of ``poly2`` is required # to be zero. @@ -1041,7 +1037,7 @@ cdef extern from "flint_wrap.h": # The default ``fmpz_poly`` composition algorithm is automatically # used when the composition can be performed over the integers. - void _fmpq_poly_compose_series_brent_kung(fmpz * res, fmpz_t den, const fmpz * poly1, const fmpz_t den1, slong len1, const fmpz * poly2, const fmpz_t den2, slong len2, slong n) + void _fmpq_poly_compose_series_brent_kung(fmpz * res, fmpz_t den, const fmpz * poly1, const fmpz_t den1, slong len1, const fmpz * poly2, const fmpz_t den2, slong len2, slong n) noexcept # Sets ``(res, den, n)`` to the composition of # ``(poly1, den1, len1)`` and ``(poly2, den2, len2)`` modulo `x^n`, # where the constant term of ``poly2`` is required to be zero. @@ -1053,7 +1049,7 @@ cdef extern from "flint_wrap.h": # The default ``fmpz_poly`` composition algorithm is automatically # used when the composition can be performed over the integers. - void fmpq_poly_compose_series_brent_kung(fmpq_poly_t res, const fmpq_poly_t poly1, const fmpq_poly_t poly2, slong n) + void fmpq_poly_compose_series_brent_kung(fmpq_poly_t res, const fmpq_poly_t poly1, const fmpq_poly_t poly2, slong n) noexcept # Sets ``res`` to the composition of ``poly1`` and ``poly2`` # modulo `x^n`, where the constant term of ``poly2`` is required # to be zero. @@ -1061,7 +1057,7 @@ cdef extern from "flint_wrap.h": # The default ``fmpz_poly`` composition algorithm is automatically # used when the composition can be performed over the integers. - void _fmpq_poly_compose_series(fmpz * res, fmpz_t den, const fmpz * poly1, const fmpz_t den1, slong len1, const fmpz * poly2, const fmpz_t den2, slong len2, slong n) + void _fmpq_poly_compose_series(fmpz * res, fmpz_t den, const fmpz * poly1, const fmpz_t den1, slong len1, const fmpz * poly2, const fmpz_t den2, slong len2, slong n) noexcept # Sets ``(res, den, n)`` to the composition of # ``(poly1, den1, len1)`` and ``(poly2, den2, len2)`` modulo `x^n`, # where the constant term of ``poly2`` is required to be zero. @@ -1074,7 +1070,7 @@ cdef extern from "flint_wrap.h": # The default ``fmpz_poly`` composition algorithm is automatically # used when the composition can be performed over the integers. - void fmpq_poly_compose_series(fmpq_poly_t res, const fmpq_poly_t poly1, const fmpq_poly_t poly2, slong n) + void fmpq_poly_compose_series(fmpq_poly_t res, const fmpq_poly_t poly1, const fmpq_poly_t poly2, slong n) noexcept # Sets ``res`` to the composition of ``poly1`` and ``poly2`` # modulo `x^n`, where the constant term of ``poly2`` is required # to be zero. @@ -1083,7 +1079,7 @@ cdef extern from "flint_wrap.h": # The default ``fmpz_poly`` composition algorithm is automatically # used when the composition can be performed over the integers. - void _fmpq_poly_revert_series_lagrange(fmpz * res, fmpz_t den, const fmpz * poly1, const fmpz_t den1, slong len1, slong n) + void _fmpq_poly_revert_series_lagrange(fmpz * res, fmpz_t den, const fmpz * poly1, const fmpz_t den1, slong len1, slong n) noexcept # Sets ``(res, den)`` to the power series reversion of # ``(poly1, den1, len1)`` modulo `x^n`. # The constant term of ``poly2`` is required to be zero and @@ -1093,7 +1089,7 @@ cdef extern from "flint_wrap.h": # The default ``fmpz_poly`` reversion algorithm is automatically # used when the reversion can be performed over the integers. - void fmpq_poly_revert_series_lagrange(fmpq_poly_t res, const fmpq_poly_t poly, slong n) + void fmpq_poly_revert_series_lagrange(fmpq_poly_t res, const fmpq_poly_t poly, slong n) noexcept # Sets ``res`` to the power series reversion of ``poly1`` modulo `x^n`. # The constant term of ``poly2`` is required to be zero and # the linear term is required to be nonzero. @@ -1101,7 +1097,7 @@ cdef extern from "flint_wrap.h": # The default ``fmpz_poly`` reversion algorithm is automatically # used when the reversion can be performed over the integers. - void _fmpq_poly_revert_series_lagrange_fast(fmpz * res, fmpz_t den, const fmpz * poly1, const fmpz_t den1, slong len1, slong n) + void _fmpq_poly_revert_series_lagrange_fast(fmpz * res, fmpz_t den, const fmpz * poly1, const fmpz_t den1, slong len1, slong n) noexcept # Sets ``(res, den)`` to the power series reversion of # ``(poly1, den1, len1)`` modulo `x^n`. # The constant term of ``poly2`` is required to be zero and @@ -1112,7 +1108,7 @@ cdef extern from "flint_wrap.h": # The default ``fmpz_poly`` reversion algorithm is automatically # used when the reversion can be performed over the integers. - void fmpq_poly_revert_series_lagrange_fast(fmpq_poly_t res, const fmpq_poly_t poly, slong n) + void fmpq_poly_revert_series_lagrange_fast(fmpq_poly_t res, const fmpq_poly_t poly, slong n) noexcept # Sets ``res`` to the power series reversion of ``poly1`` modulo `x^n`. # The constant term of ``poly2`` is required to be zero and # the linear term is required to be nonzero. @@ -1121,7 +1117,7 @@ cdef extern from "flint_wrap.h": # The default ``fmpz_poly`` reversion algorithm is automatically # used when the reversion can be performed over the integers. - void _fmpq_poly_revert_series_newton(fmpz * res, fmpz_t den, const fmpz * poly1, const fmpz_t den1, slong len1, slong n) + void _fmpq_poly_revert_series_newton(fmpz * res, fmpz_t den, const fmpz * poly1, const fmpz_t den1, slong len1, slong n) noexcept # Sets ``(res, den)`` to the power series reversion of # ``(poly1, den1, len1)`` modulo `x^n`. # The constant term of ``poly2`` is required to be zero and @@ -1131,7 +1127,7 @@ cdef extern from "flint_wrap.h": # The default ``fmpz_poly`` reversion algorithm is automatically # used when the reversion can be performed over the integers. - void fmpq_poly_revert_series_newton(fmpq_poly_t res, const fmpq_poly_t poly, slong n) + void fmpq_poly_revert_series_newton(fmpq_poly_t res, const fmpq_poly_t poly, slong n) noexcept # Sets ``res`` to the power series reversion of ``poly1`` modulo `x^n`. # The constant term of ``poly2`` is required to be zero and # the linear term is required to be nonzero. @@ -1139,7 +1135,7 @@ cdef extern from "flint_wrap.h": # The default ``fmpz_poly`` reversion algorithm is automatically # used when the reversion can be performed over the integers. - void _fmpq_poly_revert_series(fmpz * res, fmpz_t den, const fmpz * poly1, const fmpz_t den1, slong len1, slong n) + void _fmpq_poly_revert_series(fmpz * res, fmpz_t den, const fmpz * poly1, const fmpz_t den1, slong len1, slong n) noexcept # Sets ``(res, den)`` to the power series reversion of # ``(poly1, den1, len1)`` modulo `x^n`. # The constant term of ``poly2`` is required to be zero and @@ -1149,7 +1145,7 @@ cdef extern from "flint_wrap.h": # The default ``fmpz_poly`` reversion algorithm is automatically # used when the reversion can be performed over the integers. - void fmpq_poly_revert_series(fmpq_poly_t res, const fmpq_poly_t poly, slong n) + void fmpq_poly_revert_series(fmpq_poly_t res, const fmpq_poly_t poly, slong n) noexcept # Sets ``res`` to the power series reversion of ``poly1`` modulo `x^n`. # The constant term of ``poly2`` is required to be zero and # the linear term is required to be nonzero. @@ -1157,89 +1153,89 @@ cdef extern from "flint_wrap.h": # The default ``fmpz_poly`` reversion algorithm is automatically # used when the reversion can be performed over the integers. - void _fmpq_poly_content(fmpq_t res, const fmpz * poly, const fmpz_t den, slong len) + void _fmpq_poly_content(fmpq_t res, const fmpz * poly, const fmpz_t den, slong len) noexcept # Sets ``res`` to the content of ``(poly, den, len)``. # If ``len == 0``, sets ``res`` to zero. - void fmpq_poly_content(fmpq_t res, const fmpq_poly_t poly) + void fmpq_poly_content(fmpq_t res, const fmpq_poly_t poly) noexcept # Sets ``res`` to the content of ``poly``. The content of the zero # polynomial is defined to be zero. - void _fmpq_poly_primitive_part(fmpz * rpoly, fmpz_t rden, const fmpz * poly, const fmpz_t den, slong len) + void _fmpq_poly_primitive_part(fmpz * rpoly, fmpz_t rden, const fmpz * poly, const fmpz_t den, slong len) noexcept # Sets ``(rpoly, rden, len)`` to the primitive part, with non-negative # leading coefficient, of ``(poly, den, len)``. Assumes that # ``len > 0``. Supports aliasing between the two polynomials. - void fmpq_poly_primitive_part(fmpq_poly_t res, const fmpq_poly_t poly) + void fmpq_poly_primitive_part(fmpq_poly_t res, const fmpq_poly_t poly) noexcept # Sets ``res`` to the primitive part, with non-negative leading # coefficient, of ``poly``. - bint _fmpq_poly_is_monic(const fmpz * poly, const fmpz_t den, slong len) + bint _fmpq_poly_is_monic(const fmpz * poly, const fmpz_t den, slong len) noexcept # Returns whether the polynomial ``(poly, den, len)`` is monic. # The zero polynomial is not monic by definition. - bint fmpq_poly_is_monic(const fmpq_poly_t poly) + bint fmpq_poly_is_monic(const fmpq_poly_t poly) noexcept # Returns whether the polynomial ``poly`` is monic. The zero # polynomial is not monic by definition. - void _fmpq_poly_make_monic(fmpz * rpoly, fmpz_t rden, const fmpz * poly, const fmpz_t den, slong len) + void _fmpq_poly_make_monic(fmpz * rpoly, fmpz_t rden, const fmpz * poly, const fmpz_t den, slong len) noexcept # Sets ``(rpoly, rden, len)`` to the monic scalar multiple of # ``(poly, den, len)``. Assumes that ``len > 0``. Supports # aliasing between the two polynomials. - void fmpq_poly_make_monic(fmpq_poly_t res, const fmpq_poly_t poly) + void fmpq_poly_make_monic(fmpq_poly_t res, const fmpq_poly_t poly) noexcept # Sets ``res`` to the monic scalar multiple of ``poly`` whenever # ``poly`` is non-zero. If ``poly`` is the zero polynomial, sets # ``res`` to zero. - bint fmpq_poly_is_squarefree(const fmpq_poly_t poly) + bint fmpq_poly_is_squarefree(const fmpq_poly_t poly) noexcept # Returns whether the polynomial ``poly`` is square-free. A non-zero # polynomial is defined to be square-free if it has no non-unit square # factors. We also define the zero polynomial to be square-free. - int _fmpq_poly_print(const fmpz * poly, const fmpz_t den, slong len) + int _fmpq_poly_print(const fmpz * poly, const fmpz_t den, slong len) noexcept # Prints the polynomial ``(poly, den, len)`` to ``stdout``. # In case of success, returns a positive value. In case of failure, # returns a non-positive value. - int fmpq_poly_print(const fmpq_poly_t poly) + int fmpq_poly_print(const fmpq_poly_t poly) noexcept # Prints the polynomial to ``stdout``. # In case of success, returns a positive value. In case of failure, # returns a non-positive value. - int _fmpq_poly_print_pretty(const fmpz *poly, const fmpz_t den, slong len, const char * x) + int _fmpq_poly_print_pretty(const fmpz *poly, const fmpz_t den, slong len, const char * x) noexcept - int fmpq_poly_print_pretty(const fmpq_poly_t poly, const char * var) + int fmpq_poly_print_pretty(const fmpq_poly_t poly, const char * var) noexcept # Prints the pretty representation of ``poly`` to ``stdout``, using # the null-terminated string ``var`` not equal to ``"\0"`` as the # variable name. # In the current implementation always returns `1`. - int _fmpq_poly_fprint(FILE * file, const fmpz * poly, const fmpz_t den, slong len) + int _fmpq_poly_fprint(FILE * file, const fmpz * poly, const fmpz_t den, slong len) noexcept # Prints the polynomial ``(poly, den, len)`` to the stream ``file``. # In case of success, returns a positive value. In case of failure, # returns a non-positive value. - int fmpq_poly_fprint(FILE * file, const fmpq_poly_t poly) + int fmpq_poly_fprint(FILE * file, const fmpq_poly_t poly) noexcept # Prints the polynomial to the stream ``file``. # In case of success, returns a positive value. In case of failure, # returns a non-positive value. - int _fmpq_poly_fprint_pretty(FILE * file, const fmpz *poly, const fmpz_t den, slong len, const char * x) + int _fmpq_poly_fprint_pretty(FILE * file, const fmpz *poly, const fmpz_t den, slong len, const char * x) noexcept - int fmpq_poly_fprint_pretty(FILE * file, const fmpq_poly_t poly, const char * var) + int fmpq_poly_fprint_pretty(FILE * file, const fmpq_poly_t poly, const char * var) noexcept # Prints the pretty representation of ``poly`` to ``stdout``, using # the null-terminated string ``var`` not equal to ``"\0"`` as the # variable name. # In the current implementation, always returns `1`. - int fmpq_poly_read(fmpq_poly_t poly) + int fmpq_poly_read(fmpq_poly_t poly) noexcept # Reads a polynomial from ``stdin``, storing the result # in ``poly``. # In case of success, returns a positive number. In case of failure, # returns a non-positive value. - int fmpq_poly_fread(FILE * file, fmpq_poly_t poly) + int fmpq_poly_fread(FILE * file, fmpq_poly_t poly) noexcept # Reads a polynomial from the stream ``file``, storing the result # in ``poly``. # In case of success, returns a positive number. In case of failure, diff --git a/src/sage/libs/flint/fmpq_poly_sage.pxd b/src/sage/libs/flint/fmpq_poly_sage.pxd index afa16e5bbdd..b12a5dd046d 100644 --- a/src/sage/libs/flint/fmpq_poly_sage.pxd +++ b/src/sage/libs/flint/fmpq_poly_sage.pxd @@ -182,9 +182,9 @@ cdef inline sage_fmpq_poly_max_limbs(const fmpq_poly_t poly) noexcept: return _fmpz_vec_max_limbs(fmpq_poly_numref(poly), fmpq_poly_length(poly)) # functions removed from flint but still needed in sage -cdef void fmpq_poly_scalar_mul_mpz(fmpq_poly_t, const fmpq_poly_t, const mpz_t) -cdef void fmpq_poly_scalar_mul_mpq(fmpq_poly_t, const fmpq_poly_t, const mpq_t) -cdef void fmpq_poly_set_coeff_mpq(fmpq_poly_t, slong, const mpq_t) -cdef void fmpq_poly_get_coeff_mpq(mpq_t, const fmpq_poly_t, slong) -cdef void fmpq_poly_set_mpz(fmpq_poly_t, const mpz_t) -cdef void fmpq_poly_set_mpq(fmpq_poly_t, const mpq_t) +cdef void fmpq_poly_scalar_mul_mpz(fmpq_poly_t, const fmpq_poly_t, const mpz_t) noexcept +cdef void fmpq_poly_scalar_mul_mpq(fmpq_poly_t, const fmpq_poly_t, const mpq_t) noexcept +cdef void fmpq_poly_set_coeff_mpq(fmpq_poly_t, slong, const mpq_t) noexcept +cdef void fmpq_poly_get_coeff_mpq(mpq_t, const fmpq_poly_t, slong) noexcept +cdef void fmpq_poly_set_mpz(fmpq_poly_t, const mpz_t) noexcept +cdef void fmpq_poly_set_mpq(fmpq_poly_t, const mpq_t) noexcept diff --git a/src/sage/libs/flint/fmpq_poly_sage.pyx b/src/sage/libs/flint/fmpq_poly_sage.pyx index 3b8a0cf0c51..0c0c680e6b1 100644 --- a/src/sage/libs/flint/fmpq_poly_sage.pyx +++ b/src/sage/libs/flint/fmpq_poly_sage.pyx @@ -5,39 +5,40 @@ from sage.libs.gmp.mpq cimport * from sage.libs.flint.fmpz cimport * from sage.libs.flint.fmpq cimport * -cdef void fmpq_poly_scalar_mul_mpz(fmpq_poly_t rop, const fmpq_poly_t op, const mpz_t c): + +cdef void fmpq_poly_scalar_mul_mpz(fmpq_poly_t rop, const fmpq_poly_t op, const mpz_t c) noexcept: cdef fmpz_t f fmpz_init_set_readonly(f, c) fmpq_poly_scalar_mul_fmpz(rop, op, f) fmpz_clear_readonly(f) -cdef void fmpq_poly_scalar_mul_mpq(fmpq_poly_t rop, const fmpq_poly_t op, const mpq_t c): +cdef void fmpq_poly_scalar_mul_mpq(fmpq_poly_t rop, const fmpq_poly_t op, const mpq_t c) noexcept: cdef fmpq_t f fmpq_init_set_readonly(f, c) fmpq_poly_scalar_mul_fmpq(rop, op, f) fmpq_clear_readonly(f) -cdef void fmpq_poly_set_coeff_mpq(fmpq_poly_t poly, slong n, const mpq_t x): +cdef void fmpq_poly_set_coeff_mpq(fmpq_poly_t poly, slong n, const mpq_t x) noexcept: cdef fmpq_t t fmpq_init_set_readonly(t, x) fmpq_poly_set_coeff_fmpq(poly, n, t) fmpq_clear_readonly(t) -cdef void fmpq_poly_get_coeff_mpq(mpq_t x, const fmpq_poly_t poly, slong n): +cdef void fmpq_poly_get_coeff_mpq(mpq_t x, const fmpq_poly_t poly, slong n) noexcept: cdef fmpq_t t fmpq_init(t) fmpq_poly_get_coeff_fmpq(t, poly, n) fmpq_get_mpq(x, t) fmpq_clear(t) -cdef void fmpq_poly_set_mpq(fmpq_poly_t poly, const mpq_t x): +cdef void fmpq_poly_set_mpq(fmpq_poly_t poly, const mpq_t x) noexcept: fmpq_poly_fit_length(poly, 1) fmpz_set_mpz(fmpq_poly_numref(poly), mpq_numref(x)) fmpz_set_mpz(fmpq_poly_denref(poly), mpq_denref(x)) _fmpq_poly_set_length(poly, 1) _fmpq_poly_normalise(poly) -cdef void fmpq_poly_set_mpz(fmpq_poly_t poly, const mpz_t x): +cdef void fmpq_poly_set_mpz(fmpq_poly_t poly, const mpz_t x) noexcept: fmpq_poly_fit_length(poly, 1) fmpz_set_mpz(fmpq_poly_numref(poly), x) fmpz_one(fmpq_poly_denref(poly)) diff --git a/src/sage/libs/flint/fmpq_vec.pxd b/src/sage/libs/flint/fmpq_vec.pxd index 037d98e9156..f3d7e367f1c 100644 --- a/src/sage/libs/flint/fmpq_vec.pxd +++ b/src/sage/libs/flint/fmpq_vec.pxd @@ -12,44 +12,44 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - fmpq * _fmpq_vec_init(slong n) + fmpq * _fmpq_vec_init(slong n) noexcept # Initialises a vector of ``fmpq`` values of length `n` and sets # all values to 0. This is equivalent to generating a ``fmpz`` vector # of length `2n` with ``_fmpz_vec_init`` and setting all denominators # to 1. - void _fmpq_vec_clear(fmpq * vec, slong n) + void _fmpq_vec_clear(fmpq * vec, slong n) noexcept # Frees an ``fmpq`` vector. - void _fmpq_vec_randtest(fmpq * f, flint_rand_t state, slong len, flint_bitcnt_t bits) + void _fmpq_vec_randtest(fmpq * f, flint_rand_t state, slong len, flint_bitcnt_t bits) noexcept # Sets the entries of a vector of the given length to random rationals with # numerator and denominator having up to the given number of bits per entry. - void _fmpq_vec_randtest_uniq_sorted(fmpq * vec, flint_rand_t state, slong len, flint_bitcnt_t bits) + void _fmpq_vec_randtest_uniq_sorted(fmpq * vec, flint_rand_t state, slong len, flint_bitcnt_t bits) noexcept # Sets the entries of a vector of the given length to random distinct # rationals with numerator and denominator having up to the given number # of bits per entry. The entries in the vector are sorted. - void _fmpq_vec_sort(fmpq * vec, slong len) + void _fmpq_vec_sort(fmpq * vec, slong len) noexcept # Sorts the entries of ``(vec, len)``. - void _fmpq_vec_set_fmpz_vec(fmpq * res, const fmpz * vec, slong len) + void _fmpq_vec_set_fmpz_vec(fmpq * res, const fmpz * vec, slong len) noexcept # Sets ``(res, len)`` to ``(vec, len)``. - void _fmpq_vec_get_fmpz_vec_fmpz(fmpz* num, fmpz_t den, const fmpq * a, slong len) + void _fmpq_vec_get_fmpz_vec_fmpz(fmpz* num, fmpz_t den, const fmpq * a, slong len) noexcept # Find a common denominator ``den`` of the entries of ``a`` and set ``(num, len)`` to the corresponding numerators. - void _fmpq_vec_dot(fmpq_t res, const fmpq * vec1, const fmpq * vec2, slong len) + void _fmpq_vec_dot(fmpq_t res, const fmpq * vec1, const fmpq * vec2, slong len) noexcept # Sets ``res`` to the dot product of the vectors ``(vec1, len)`` and # ``(vec2, len)``. - int _fmpq_vec_fprint(FILE * file, const fmpq * vec, slong len) + int _fmpq_vec_fprint(FILE * file, const fmpq * vec, slong len) noexcept # Prints the vector of given length to the stream ``file``. The # format is the length followed by two spaces, then a space separated # list of coefficients. If the length is zero, only `0` is printed. # In case of success, returns a positive value. In case of failure, # returns a non-positive value. - int _fmpq_vec_print(const fmpq * vec, slong len) + int _fmpq_vec_print(const fmpq * vec, slong len) noexcept # Prints the vector of given length to ``stdout``. # For further details, see :func:`_fmpq_vec_fprint()`. diff --git a/src/sage/libs/flint/fmpz.pxd b/src/sage/libs/flint/fmpz.pxd index adcb826706a..38c973e8f5c 100644 --- a/src/sage/libs/flint/fmpz.pxd +++ b/src/sage/libs/flint/fmpz.pxd @@ -12,33 +12,33 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - fmpz PTR_TO_COEFF(__mpz_struct * ptr) + fmpz PTR_TO_COEFF(__mpz_struct * ptr) noexcept - __mpz_struct * COEFF_TO_PTR(fmpz f) + __mpz_struct * COEFF_TO_PTR(fmpz f) noexcept - int COEFF_IS_MPZ(fmpz f) + int COEFF_IS_MPZ(fmpz f) noexcept - __mpz_struct * _fmpz_new_mpz() + __mpz_struct * _fmpz_new_mpz() noexcept - void _fmpz_clear_mpz(fmpz f) + void _fmpz_clear_mpz(fmpz f) noexcept - void _fmpz_cleanup_mpz_content() + void _fmpz_cleanup_mpz_content() noexcept - void _fmpz_cleanup() + void _fmpz_cleanup() noexcept - __mpz_struct * _fmpz_promote(fmpz_t f) + __mpz_struct * _fmpz_promote(fmpz_t f) noexcept - __mpz_struct * _fmpz_promote_val(fmpz_t f) + __mpz_struct * _fmpz_promote_val(fmpz_t f) noexcept - void _fmpz_demote(fmpz_t f) + void _fmpz_demote(fmpz_t f) noexcept - void _fmpz_demote_val(fmpz_t f) + void _fmpz_demote_val(fmpz_t f) noexcept - void fmpz_init(fmpz_t f) + void fmpz_init(fmpz_t f) noexcept # A small ``fmpz_t`` is initialised, i.e. just a ``slong``. # The value is set to zero. - void fmpz_init2(fmpz_t f, ulong limbs) + void fmpz_init2(fmpz_t f, ulong limbs) noexcept # Initialises the given ``fmpz_t`` to have space for the given # number of limbs. # If ``limbs`` is zero then a small ``fmpz_t`` is allocated, @@ -46,48 +46,48 @@ cdef extern from "flint_wrap.h": # not necessary to call this function except to save time. A call # to ``fmpz_init`` will do just fine. - void fmpz_clear(fmpz_t f) + void fmpz_clear(fmpz_t f) noexcept # Clears the given ``fmpz_t``, releasing any memory associated # with it, either back to the stack or the OS, depending on # whether the reentrant or non-reentrant version of FLINT is built. - void fmpz_init_set(fmpz_t f, const fmpz_t g) + void fmpz_init_set(fmpz_t f, const fmpz_t g) noexcept - void fmpz_init_set_ui(fmpz_t f, ulong g) + void fmpz_init_set_ui(fmpz_t f, ulong g) noexcept - void fmpz_init_set_si(fmpz_t f, slong g) + void fmpz_init_set_si(fmpz_t f, slong g) noexcept # Initialises `f` and sets it to the value of `g`. - void fmpz_randbits(fmpz_t f, flint_rand_t state, flint_bitcnt_t bits) + void fmpz_randbits(fmpz_t f, flint_rand_t state, flint_bitcnt_t bits) noexcept # Generates a random signed integer whose absolute value has precisely # the given number of bits. - void fmpz_randtest(fmpz_t f, flint_rand_t state, flint_bitcnt_t bits) + void fmpz_randtest(fmpz_t f, flint_rand_t state, flint_bitcnt_t bits) noexcept # Generates a random signed integer whose absolute value has a number # of bits which is random from `0` up to ``bits`` inclusive. - void fmpz_randtest_unsigned(fmpz_t f, flint_rand_t state, flint_bitcnt_t bits) + void fmpz_randtest_unsigned(fmpz_t f, flint_rand_t state, flint_bitcnt_t bits) noexcept # Generates a random unsigned integer whose value has a number # of bits which is random from `0` up to ``bits`` inclusive. - void fmpz_randtest_not_zero(fmpz_t f, flint_rand_t state, flint_bitcnt_t bits) + void fmpz_randtest_not_zero(fmpz_t f, flint_rand_t state, flint_bitcnt_t bits) noexcept # As per ``fmpz_randtest``, but the result will not be `0`. # If ``bits`` is set to `0`, an exception will result. - void fmpz_randm(fmpz_t f, flint_rand_t state, const fmpz_t m) + void fmpz_randm(fmpz_t f, flint_rand_t state, const fmpz_t m) noexcept # Generates a random integer in the range `0` to `m - 1` inclusive. - void fmpz_randtest_mod(fmpz_t f, flint_rand_t state, const fmpz_t m) + void fmpz_randtest_mod(fmpz_t f, flint_rand_t state, const fmpz_t m) noexcept # Generates a random integer in the range `0` to `m - 1` inclusive, # with an increased probability of generating values close to # the endpoints. - void fmpz_randtest_mod_signed(fmpz_t f, flint_rand_t state, const fmpz_t m) + void fmpz_randtest_mod_signed(fmpz_t f, flint_rand_t state, const fmpz_t m) noexcept # Generates a random integer in the range `(-m/2, m/2]`, with an # increased probability of generating values close to the # endpoints or close to zero. - void fmpz_randprime(fmpz_t f, flint_rand_t state, flint_bitcnt_t bits, int proved) + void fmpz_randprime(fmpz_t f, flint_rand_t state, flint_bitcnt_t bits, int proved) noexcept # Generates a random prime number with the given number of bits. # The generation is performed by choosing a random number and then # finding the next largest prime, and therefore does not quite @@ -98,137 +98,137 @@ cdef extern from "flint_wrap.h": # If ``proved`` is nonzero, then the integer returned is # guaranteed to actually be prime. - slong fmpz_get_si(const fmpz_t f) + slong fmpz_get_si(const fmpz_t f) noexcept # Returns `f` as a ``slong``. The result is undefined # if `f` does not fit into a ``slong``. - ulong fmpz_get_ui(const fmpz_t f) + ulong fmpz_get_ui(const fmpz_t f) noexcept # Returns `f` as an ``ulong``. The result is undefined # if `f` does not fit into an ``ulong`` or is negative. - void fmpz_get_uiui(mp_limb_t * hi, mp_limb_t * low, const fmpz_t f) + void fmpz_get_uiui(mp_limb_t * hi, mp_limb_t * low, const fmpz_t f) noexcept # If `f` consists of two limbs, then ``*hi`` and ``*low`` are set to the high # and low limbs, otherwise ``*low`` is set to the low limb and ``*hi`` is set # to `0`. - mp_limb_t fmpz_get_nmod(const fmpz_t f, nmod_t mod) + mp_limb_t fmpz_get_nmod(const fmpz_t f, nmod_t mod) noexcept # Returns `f \mod n`. - double fmpz_get_d(const fmpz_t f) + double fmpz_get_d(const fmpz_t f) noexcept # Returns `f` as a ``double``, rounding down towards zero if # `f` cannot be represented exactly. The outcome is undefined # if `f` is too large to fit in the normal range of a double. - void fmpz_set_mpf(fmpz_t f, const mpf_t x) + void fmpz_set_mpf(fmpz_t f, const mpf_t x) noexcept # Sets `f` to the ``mpf_t`` `x`, rounding down towards zero if # the value of `x` is fractional. - void fmpz_get_mpf(mpf_t x, const fmpz_t f) + void fmpz_get_mpf(mpf_t x, const fmpz_t f) noexcept # Sets the value of the ``mpf_t`` `x` to the value of `f`. - void fmpz_get_mpfr(mpfr_t x, const fmpz_t f, mpfr_rnd_t rnd) + void fmpz_get_mpfr(mpfr_t x, const fmpz_t f, mpfr_rnd_t rnd) noexcept # Sets the value of `x` from `f`, rounded toward the given # direction ``rnd``. # **Note:** Requires that ``mpfr.h`` has been included before any FLINT # header is included. - double fmpz_get_d_2exp(slong * exp, const fmpz_t f) + double fmpz_get_d_2exp(slong * exp, const fmpz_t f) noexcept # Returns `f` as a normalized ``double`` along with a `2`-exponent # ``exp``, i.e. if `r` is the return value then `f = r 2^{exp}`, # to within 1 ULP. - void fmpz_get_mpz(mpz_t x, const fmpz_t f) + void fmpz_get_mpz(mpz_t x, const fmpz_t f) noexcept # Sets the ``mpz_t`` `x` to the same value as `f`. - int fmpz_get_mpn(mp_ptr *n, fmpz_t n_in) + int fmpz_get_mpn(mp_ptr *n, fmpz_t n_in) noexcept # Sets the ``mp_ptr`` `n` to the same value as `n_{in}`. Returned # integer is number of limbs allocated to `n`, minimum number of limbs # required to hold the value stored in `n_{in}`. - char * fmpz_get_str(char * str, int b, const fmpz_t f) + char * fmpz_get_str(char * str, int b, const fmpz_t f) noexcept # Returns the representation of `f` in base `b`, which can vary # between `2` and `62`, inclusive. # If ``str`` is ``NULL``, the result string is allocated by # the function. Otherwise, it is up to the caller to ensure that # the allocated block of memory is sufficiently large. - void fmpz_set_si(fmpz_t f, slong val) + void fmpz_set_si(fmpz_t f, slong val) noexcept # Sets `f` to the given ``slong`` value. - void fmpz_set_ui(fmpz_t f, ulong val) + void fmpz_set_ui(fmpz_t f, ulong val) noexcept # Sets `f` to the given ``ulong`` value. - void fmpz_set_d(fmpz_t f, double c) + void fmpz_set_d(fmpz_t f, double c) noexcept # Sets `f` to the ``double`` `c`, rounding down towards zero if # the value of `c` is fractional. The outcome is undefined if `c` is # infinite, not-a-number, or subnormal. - void fmpz_set_d_2exp(fmpz_t f, double d, slong exp) + void fmpz_set_d_2exp(fmpz_t f, double d, slong exp) noexcept # Sets `f` to the nearest integer to `d 2^{exp}`. - void fmpz_neg_ui(fmpz_t f, ulong val) + void fmpz_neg_ui(fmpz_t f, ulong val) noexcept # Sets `f` to the given ``ulong`` value, and then negates `f`. - void fmpz_set_uiui(fmpz_t f, mp_limb_t hi, mp_limb_t lo) + void fmpz_set_uiui(fmpz_t f, mp_limb_t hi, mp_limb_t lo) noexcept # Sets `f` to ``lo``, plus ``hi`` shifted to the left by # ``FLINT_BITS``. - void fmpz_neg_uiui(fmpz_t f, mp_limb_t hi, mp_limb_t lo) + void fmpz_neg_uiui(fmpz_t f, mp_limb_t hi, mp_limb_t lo) noexcept # Sets `f` to ``lo``, plus ``hi`` shifted to the left by # ``FLINT_BITS``, and then negates `f`. - void fmpz_set_signed_uiui(fmpz_t f, ulong hi, ulong lo) + void fmpz_set_signed_uiui(fmpz_t f, ulong hi, ulong lo) noexcept # Sets `f` to ``lo``, plus ``hi`` shifted to the left by # ``FLINT_BITS``, interpreted as a signed two's complement # integer with ``2 * FLINT_BITS`` bits. - void fmpz_set_signed_uiuiui(fmpz_t f, ulong hi, ulong mid, ulong lo) + void fmpz_set_signed_uiuiui(fmpz_t f, ulong hi, ulong mid, ulong lo) noexcept # Sets `f` to ``lo``, plus ``mid`` shifted to the left by # ``FLINT_BITS``, plus ``hi`` shifted to the left by # ``2*FLINT_BITS`` bits, interpreted as a signed two's complement # integer with ``3 * FLINT_BITS`` bits. - void fmpz_set_ui_array(fmpz_t out, const ulong * input, slong n) + void fmpz_set_ui_array(fmpz_t out, const ulong * input, slong n) noexcept # Sets ``out`` to the nonnegative integer # ``in[0] + in[1]*X + ... + in[n - 1]*X^(n - 1)`` # where ``X = 2^FLINT_BITS``. It is assumed that ``n > 0``. - void fmpz_set_signed_ui_array(fmpz_t out, const ulong * input, slong n) + void fmpz_set_signed_ui_array(fmpz_t out, const ulong * input, slong n) noexcept # Sets ``out`` to the integer represented in ``in[0], ..., in[n - 1]`` # as a signed two's complement integer with ``n * FLINT_BITS`` bits. # It is assumed that ``n > 0``. The function operates as a call to # :func:`fmpz_set_ui_array` followed by a symmetric remainder modulo # `2^{n\cdot FLINT\_BITS}`. - void fmpz_get_ui_array(ulong * out, slong n, const fmpz_t input) + void fmpz_get_ui_array(ulong * out, slong n, const fmpz_t input) noexcept # Assuming that the nonnegative integer ``in`` can be represented in the # form ``out[0] + out[1]*X + ... + out[n - 1]*X^(n - 1)``, # where `X = 2^{FLINT\_BITS}`, sets the corresponding elements of ``out`` # so that this is true. It is assumed that ``n > 0``. - void fmpz_get_signed_ui_array(ulong * out, slong n, const fmpz_t input) + void fmpz_get_signed_ui_array(ulong * out, slong n, const fmpz_t input) noexcept # Retrieves the value of `in` modulo `2^{n * FLINT\_BITS}` and puts the `n` # words of the result in ``out[0], ..., out[n-1]``. This will give a signed # two's complement representation of `in` (assuming `in` doesn't overflow the array). - void fmpz_get_signed_uiui(ulong * hi, ulong * lo, const fmpz_t input) + void fmpz_get_signed_uiui(ulong * hi, ulong * lo, const fmpz_t input) noexcept # Retrieves the value of `in` modulo `2^{2 * FLINT\_BITS}` and puts the high # and low words into ``*hi`` and ``*lo`` respectively. - void fmpz_set_mpz(fmpz_t f, const mpz_t x) + void fmpz_set_mpz(fmpz_t f, const mpz_t x) noexcept # Sets `f` to the given ``mpz_t`` value. - int fmpz_set_str(fmpz_t f, const char * str, int b) + int fmpz_set_str(fmpz_t f, const char * str, int b) noexcept # Sets `f` to the value given in the null-terminated string ``str``, # in base `b`. The base `b` can vary between `2` and `62`, inclusive. # Returns `0` if the string contains a valid input and `-1` otherwise. - void fmpz_set_ui_smod(fmpz_t f, mp_limb_t x, mp_limb_t m) + void fmpz_set_ui_smod(fmpz_t f, mp_limb_t x, mp_limb_t m) noexcept # Sets `f` to the signed remainder `y \equiv x \bmod m` satisfying # `-m/2 < y \leq m/2`, given `x` which is assumed to satisfy # `0 \leq x < m`. - void flint_mpz_init_set_readonly(mpz_t z, const fmpz_t f) + void flint_mpz_init_set_readonly(mpz_t z, const fmpz_t f) noexcept # Sets the uninitialised ``mpz_t`` `z` to the value of the # readonly ``fmpz_t`` `f`. # Note that it is assumed that `f` does not change during @@ -256,10 +256,10 @@ cdef extern from "flint_wrap.h": # _fmpz_demote_val(f); # } - void flint_mpz_clear_readonly(mpz_t z) + void flint_mpz_clear_readonly(mpz_t z) noexcept # Clears the readonly ``mpz_t`` `z`. - void fmpz_init_set_readonly(fmpz_t f, const mpz_t z) + void fmpz_init_set_readonly(fmpz_t f, const mpz_t z) noexcept # Sets the uninitialised ``fmpz_t`` `f` to a readonly # version of the integer `z`. # Note that the value of `z` is assumed to remain constant @@ -276,10 +276,10 @@ cdef extern from "flint_wrap.h": # fmpz_clear_readonly(f); # } - void fmpz_clear_readonly(fmpz_t f) + void fmpz_clear_readonly(fmpz_t f) noexcept # Clears the readonly ``fmpz_t`` `f`. - int fmpz_read(fmpz_t f) + int fmpz_read(fmpz_t f) noexcept # Reads a multiprecision integer from ``stdin``. The format is # an optional minus sign, followed by one or more digits. The # first digit should be non-zero unless it is the only digit. @@ -289,7 +289,7 @@ cdef extern from "flint_wrap.h": # ``scanf`` from the standard library and ``mpz_inp_str`` # from MPIR. - int fmpz_fread(FILE * file, fmpz_t f) + int fmpz_fread(FILE * file, fmpz_t f) noexcept # Reads a multiprecision integer from the stream ``file``. The # format is an optional minus sign, followed by one or more digits. # The first digit should be non-zero unless it is the only digit. @@ -299,7 +299,7 @@ cdef extern from "flint_wrap.h": # ``scanf`` from the standard library and ``mpz_inp_str`` # from MPIR. - size_t fmpz_inp_raw(fmpz_t x, FILE *fin ) + size_t fmpz_inp_raw(fmpz_t x, FILE *fin ) noexcept # Reads a multiprecision integer from the stream ``file``. The # format is raw binary format write by :func:`fmpz_out_raw`. # In case of success, return a positive number, indicating number of bytes read. @@ -307,7 +307,7 @@ cdef extern from "flint_wrap.h": # This function calls the ``mpz_inp_raw`` function in library gmp. So that it # can read the raw data written by ``mpz_inp_raw`` directly. - int fmpz_print(const fmpz_t x) + int fmpz_print(const fmpz_t x) noexcept # Prints the value `x` to ``stdout``, without a carriage return (CR). # The value is printed as either `0`, the decimal digits of a # positive integer, or a minus sign followed by the digits of @@ -318,7 +318,7 @@ cdef extern from "flint_wrap.h": # ``flint_printf`` from the standard library and ``mpz_out_str`` # from MPIR. - int fmpz_fprint(FILE * file, const fmpz_t x) + int fmpz_fprint(FILE * file, const fmpz_t x) noexcept # Prints the value `x` to ``file``, without a carriage return (CR). # The value is printed as either `0`, the decimal digits of a # positive integer, or a minus sign followed by the digits of @@ -329,7 +329,7 @@ cdef extern from "flint_wrap.h": # ``flint_printf`` from the standard library and ``mpz_out_str`` # from MPIR. - size_t fmpz_out_raw(FILE *fout, const fmpz_t x ) + size_t fmpz_out_raw(FILE *fout, const fmpz_t x ) noexcept # Writes the value `x` to ``file``. # The value is written in raw binary format. The integer is written in # portable format, with 4 bytes of size information, and that many bytes @@ -341,59 +341,59 @@ cdef extern from "flint_wrap.h": # The output of this can also be read by ``mpz_inp_raw`` from GMP >= 2, # since this function calls the ``mpz_inp_raw`` function in library gmp. - size_t fmpz_sizeinbase(const fmpz_t f, int b) + size_t fmpz_sizeinbase(const fmpz_t f, int b) noexcept # Returns the size of the absolute value of `f` in base `b`, measured in # numbers of digits. The base `b` can be between `2` and `62`, inclusive. - flint_bitcnt_t fmpz_bits(const fmpz_t f) + flint_bitcnt_t fmpz_bits(const fmpz_t f) noexcept # Returns the number of bits required to store the absolute # value of `f`. If `f` is `0` then `0` is returned. - mp_size_t fmpz_size(const fmpz_t f) + mp_size_t fmpz_size(const fmpz_t f) noexcept # Returns the number of limbs required to store the absolute # value of `f`. If `f` is zero then `0` is returned. - int fmpz_sgn(const fmpz_t f) + int fmpz_sgn(const fmpz_t f) noexcept # Returns `-1` if the sign of `f` is negative, `+1` if it is positive, # otherwise returns `0`. - flint_bitcnt_t fmpz_val2(const fmpz_t f) + flint_bitcnt_t fmpz_val2(const fmpz_t f) noexcept # Returns the exponent of the largest power of two dividing `f`, or # equivalently the number of trailing zeros in the binary expansion of `f`. # If `f` is zero then `0` is returned. - void fmpz_swap(fmpz_t f, fmpz_t g) + void fmpz_swap(fmpz_t f, fmpz_t g) noexcept # Efficiently swaps `f` and `g`. No data is copied. - void fmpz_set(fmpz_t f, const fmpz_t g) + void fmpz_set(fmpz_t f, const fmpz_t g) noexcept # Sets `f` to the same value as `g`. - void fmpz_zero(fmpz_t f) + void fmpz_zero(fmpz_t f) noexcept # Sets `f` to zero. - void fmpz_one(fmpz_t f) + void fmpz_one(fmpz_t f) noexcept # Sets `f` to one. - int fmpz_abs_fits_ui(const fmpz_t f) + int fmpz_abs_fits_ui(const fmpz_t f) noexcept # Returns whether the absolute value of `f` # fits into an ``ulong``. - int fmpz_fits_si(const fmpz_t f) + int fmpz_fits_si(const fmpz_t f) noexcept # Returns whether the value of `f` fits into a ``slong``. - void fmpz_setbit(fmpz_t f, ulong i) + void fmpz_setbit(fmpz_t f, ulong i) noexcept # Sets bit index `i` of `f`. - int fmpz_tstbit(const fmpz_t f, ulong i) + int fmpz_tstbit(const fmpz_t f, ulong i) noexcept # Test bit index `i` of `f` and return `0` or `1`, accordingly. - mp_limb_t fmpz_abs_lbound_ui_2exp(slong * exp, const fmpz_t x, int bits) + mp_limb_t fmpz_abs_lbound_ui_2exp(slong * exp, const fmpz_t x, int bits) noexcept # For nonzero `x`, returns a mantissa `m` with exactly ``bits`` bits and # sets ``exp`` to an exponent `e`, such that `|x| \ge m 2^e`. The number # of bits must be between 1 and ``FLINT_BITS`` inclusive. # The mantissa is guaranteed to be correctly rounded. - mp_limb_t fmpz_abs_ubound_ui_2exp(slong * exp, const fmpz_t x, int bits) + mp_limb_t fmpz_abs_ubound_ui_2exp(slong * exp, const fmpz_t x, int bits) noexcept # For nonzero `x`, returns a mantissa `m` with exactly ``bits`` bits # and sets ``exp`` to an exponent `e`, such that `|x| \le m 2^e`. # The number of bits must be between 1 and ``FLINT_BITS`` inclusive. @@ -401,130 +401,130 @@ cdef extern from "flint_wrap.h": # (possibly meaning that the exponent is one too large, # if the mantissa is a power of two). - int fmpz_cmp(const fmpz_t f, const fmpz_t g) + int fmpz_cmp(const fmpz_t f, const fmpz_t g) noexcept - int fmpz_cmp_ui(const fmpz_t f, ulong g) + int fmpz_cmp_ui(const fmpz_t f, ulong g) noexcept - int fmpz_cmp_si(const fmpz_t f, slong g) + int fmpz_cmp_si(const fmpz_t f, slong g) noexcept # Returns a negative value if `f < g`, positive value if `g < f`, # otherwise returns `0`. - int fmpz_cmpabs(const fmpz_t f, const fmpz_t g) + int fmpz_cmpabs(const fmpz_t f, const fmpz_t g) noexcept # Returns a negative value if `\lvert f\rvert < \lvert g\rvert`, positive value if # `\lvert g\rvert < \lvert f \rvert`, otherwise returns `0`. - int fmpz_cmp2abs(const fmpz_t f, const fmpz_t g) + int fmpz_cmp2abs(const fmpz_t f, const fmpz_t g) noexcept # Returns a negative value if `\lvert f\rvert < \lvert 2g\rvert`, positive value if # `\lvert 2g\rvert < \lvert f \rvert`, otherwise returns `0`. - bint fmpz_equal(const fmpz_t f, const fmpz_t g) + bint fmpz_equal(const fmpz_t f, const fmpz_t g) noexcept - bint fmpz_equal_ui(const fmpz_t f, ulong g) + bint fmpz_equal_ui(const fmpz_t f, ulong g) noexcept - bint fmpz_equal_si(const fmpz_t f, slong g) + bint fmpz_equal_si(const fmpz_t f, slong g) noexcept # Returns `1` if `f` is equal to `g`, otherwise returns `0`. - bint fmpz_is_zero(const fmpz_t f) + bint fmpz_is_zero(const fmpz_t f) noexcept # Returns `1` if `f` is `0`, otherwise returns `0`. - bint fmpz_is_one(const fmpz_t f) + bint fmpz_is_one(const fmpz_t f) noexcept # Returns `1` if `f` is equal to one, otherwise returns `0`. - bint fmpz_is_pm1(const fmpz_t f) + bint fmpz_is_pm1(const fmpz_t f) noexcept # Returns `1` if `f` is equal to one or minus one, otherwise returns `0`. - bint fmpz_is_even(const fmpz_t f) + bint fmpz_is_even(const fmpz_t f) noexcept # Returns whether the integer `f` is even. - bint fmpz_is_odd(const fmpz_t f) + bint fmpz_is_odd(const fmpz_t f) noexcept # Returns whether the integer `f` is odd. - void fmpz_neg(fmpz_t f1, const fmpz_t f2) + void fmpz_neg(fmpz_t f1, const fmpz_t f2) noexcept # Sets `f_1` to `-f_2`. - void fmpz_abs(fmpz_t f1, const fmpz_t f2) + void fmpz_abs(fmpz_t f1, const fmpz_t f2) noexcept # Sets `f_1` to the absolute value of `f_2`. - void fmpz_add(fmpz_t f, const fmpz_t g, const fmpz_t h) - void fmpz_add_ui(fmpz_t f, const fmpz_t g, ulong h) - void fmpz_add_si(fmpz_t f, const fmpz_t g, slong h) + void fmpz_add(fmpz_t f, const fmpz_t g, const fmpz_t h) noexcept + void fmpz_add_ui(fmpz_t f, const fmpz_t g, ulong h) noexcept + void fmpz_add_si(fmpz_t f, const fmpz_t g, slong h) noexcept # Sets `f` to `g + h`. - void fmpz_sub(fmpz_t f, const fmpz_t g, const fmpz_t h) - void fmpz_sub_ui(fmpz_t f, const fmpz_t g, ulong h) - void fmpz_sub_si(fmpz_t f, const fmpz_t g, slong h) + void fmpz_sub(fmpz_t f, const fmpz_t g, const fmpz_t h) noexcept + void fmpz_sub_ui(fmpz_t f, const fmpz_t g, ulong h) noexcept + void fmpz_sub_si(fmpz_t f, const fmpz_t g, slong h) noexcept # Sets `f` to `g - h`. - void fmpz_mul(fmpz_t f, const fmpz_t g, const fmpz_t h) - void fmpz_mul_ui(fmpz_t f, const fmpz_t g, ulong h) - void fmpz_mul_si(fmpz_t f, const fmpz_t g, slong h) + void fmpz_mul(fmpz_t f, const fmpz_t g, const fmpz_t h) noexcept + void fmpz_mul_ui(fmpz_t f, const fmpz_t g, ulong h) noexcept + void fmpz_mul_si(fmpz_t f, const fmpz_t g, slong h) noexcept # Sets `f` to `g \times h`. - void fmpz_mul2_uiui(fmpz_t f, const fmpz_t g, ulong x, ulong y) + void fmpz_mul2_uiui(fmpz_t f, const fmpz_t g, ulong x, ulong y) noexcept # Sets `f` to `g \times x \times y` where `x` and `y` are of type ``ulong``. - void fmpz_mul_2exp(fmpz_t f, const fmpz_t g, ulong e) + void fmpz_mul_2exp(fmpz_t f, const fmpz_t g, ulong e) noexcept # Sets `f` to `g \times 2^e`. # Note: Assumes that ``e + FLINT_BITS`` does not overflow. - void fmpz_one_2exp(fmpz_t f, ulong e) + void fmpz_one_2exp(fmpz_t f, ulong e) noexcept # Sets `f` to `2^e`. - void fmpz_addmul(fmpz_t f, const fmpz_t g, const fmpz_t h) - void fmpz_addmul_ui(fmpz_t f, const fmpz_t g, ulong h) - void fmpz_addmul_si(fmpz_t f, const fmpz_t g, slong h) + void fmpz_addmul(fmpz_t f, const fmpz_t g, const fmpz_t h) noexcept + void fmpz_addmul_ui(fmpz_t f, const fmpz_t g, ulong h) noexcept + void fmpz_addmul_si(fmpz_t f, const fmpz_t g, slong h) noexcept # Sets `f` to `f + g \times h`. - void fmpz_submul(fmpz_t f, const fmpz_t g, const fmpz_t h) - void fmpz_submul_ui(fmpz_t f, const fmpz_t g, ulong h) - void fmpz_submul_si(fmpz_t f, const fmpz_t g, slong h) + void fmpz_submul(fmpz_t f, const fmpz_t g, const fmpz_t h) noexcept + void fmpz_submul_ui(fmpz_t f, const fmpz_t g, ulong h) noexcept + void fmpz_submul_si(fmpz_t f, const fmpz_t g, slong h) noexcept # Sets `f` to `f - g \times h`. - void fmpz_fmma(fmpz_t f, const fmpz_t a, const fmpz_t b, const fmpz_t c, const fmpz_t d) + void fmpz_fmma(fmpz_t f, const fmpz_t a, const fmpz_t b, const fmpz_t c, const fmpz_t d) noexcept # Sets `f` to `a \times b + c \times d`. - void fmpz_fmms(fmpz_t f, const fmpz_t a, const fmpz_t b, const fmpz_t c, const fmpz_t d) + void fmpz_fmms(fmpz_t f, const fmpz_t a, const fmpz_t b, const fmpz_t c, const fmpz_t d) noexcept # Sets `f` to `a \times b - c \times d`. - void fmpz_cdiv_qr(fmpz_t f, fmpz_t s, const fmpz_t g, const fmpz_t h) + void fmpz_cdiv_qr(fmpz_t f, fmpz_t s, const fmpz_t g, const fmpz_t h) noexcept - void fmpz_fdiv_qr(fmpz_t f, fmpz_t s, const fmpz_t g, const fmpz_t h) + void fmpz_fdiv_qr(fmpz_t f, fmpz_t s, const fmpz_t g, const fmpz_t h) noexcept - void fmpz_tdiv_qr(fmpz_t f, fmpz_t s, const fmpz_t g, const fmpz_t h) + void fmpz_tdiv_qr(fmpz_t f, fmpz_t s, const fmpz_t g, const fmpz_t h) noexcept - void fmpz_ndiv_qr(fmpz_t f, fmpz_t s, const fmpz_t g, const fmpz_t h) + void fmpz_ndiv_qr(fmpz_t f, fmpz_t s, const fmpz_t g, const fmpz_t h) noexcept - void fmpz_cdiv_q(fmpz_t f, const fmpz_t g, const fmpz_t h) + void fmpz_cdiv_q(fmpz_t f, const fmpz_t g, const fmpz_t h) noexcept - void fmpz_fdiv_q(fmpz_t f, const fmpz_t g, const fmpz_t h) + void fmpz_fdiv_q(fmpz_t f, const fmpz_t g, const fmpz_t h) noexcept - void fmpz_tdiv_q(fmpz_t f, const fmpz_t g, const fmpz_t h) + void fmpz_tdiv_q(fmpz_t f, const fmpz_t g, const fmpz_t h) noexcept - void fmpz_cdiv_q_si(fmpz_t f, const fmpz_t g, slong h) + void fmpz_cdiv_q_si(fmpz_t f, const fmpz_t g, slong h) noexcept - void fmpz_fdiv_q_si(fmpz_t f, const fmpz_t g, slong h) + void fmpz_fdiv_q_si(fmpz_t f, const fmpz_t g, slong h) noexcept - void fmpz_tdiv_q_si(fmpz_t f, const fmpz_t g, slong h) + void fmpz_tdiv_q_si(fmpz_t f, const fmpz_t g, slong h) noexcept - void fmpz_cdiv_q_ui(fmpz_t f, const fmpz_t g, ulong h) + void fmpz_cdiv_q_ui(fmpz_t f, const fmpz_t g, ulong h) noexcept - void fmpz_fdiv_q_ui(fmpz_t f, const fmpz_t g, ulong h) + void fmpz_fdiv_q_ui(fmpz_t f, const fmpz_t g, ulong h) noexcept - void fmpz_tdiv_q_ui(fmpz_t f, const fmpz_t g, ulong h) + void fmpz_tdiv_q_ui(fmpz_t f, const fmpz_t g, ulong h) noexcept - void fmpz_cdiv_q_2exp(fmpz_t f, const fmpz_t g, ulong exp) + void fmpz_cdiv_q_2exp(fmpz_t f, const fmpz_t g, ulong exp) noexcept - void fmpz_fdiv_q_2exp(fmpz_t f, const fmpz_t g, ulong exp) + void fmpz_fdiv_q_2exp(fmpz_t f, const fmpz_t g, ulong exp) noexcept - void fmpz_tdiv_q_2exp(fmpz_t f, const fmpz_t g, ulong exp) + void fmpz_tdiv_q_2exp(fmpz_t f, const fmpz_t g, ulong exp) noexcept - void fmpz_fdiv_r(fmpz_t s, const fmpz_t g, const fmpz_t h) + void fmpz_fdiv_r(fmpz_t s, const fmpz_t g, const fmpz_t h) noexcept - void fmpz_cdiv_r_2exp(fmpz_t s, const fmpz_t g, ulong exp) + void fmpz_cdiv_r_2exp(fmpz_t s, const fmpz_t g, ulong exp) noexcept - void fmpz_fdiv_r_2exp(fmpz_t s, const fmpz_t g, ulong exp) + void fmpz_fdiv_r_2exp(fmpz_t s, const fmpz_t g, ulong exp) noexcept - void fmpz_tdiv_r_2exp(fmpz_t s, const fmpz_t g, ulong exp) + void fmpz_tdiv_r_2exp(fmpz_t s, const fmpz_t g, ulong exp) noexcept # Sets `f` to the quotient of `g` by `h` and/or `s` to the remainder. For the # ``2exp`` functions, ``g = 2^exp``. `If `h` is `0` an exception is raised. # Rounding is made in the following way: @@ -534,96 +534,96 @@ cdef extern from "flint_wrap.h": # * ``ndiv`` rounds the quotient such that the remainder has the smallest # absolute value. In case of ties, it rounds the quotient towards zero. - ulong fmpz_cdiv_ui(const fmpz_t g, ulong h) + ulong fmpz_cdiv_ui(const fmpz_t g, ulong h) noexcept - ulong fmpz_fdiv_ui(const fmpz_t g, ulong h) + ulong fmpz_fdiv_ui(const fmpz_t g, ulong h) noexcept - ulong fmpz_tdiv_ui(const fmpz_t g, ulong h) + ulong fmpz_tdiv_ui(const fmpz_t g, ulong h) noexcept - void fmpz_divexact(fmpz_t f, const fmpz_t g, const fmpz_t h) + void fmpz_divexact(fmpz_t f, const fmpz_t g, const fmpz_t h) noexcept - void fmpz_divexact_si(fmpz_t f, const fmpz_t g, slong h) + void fmpz_divexact_si(fmpz_t f, const fmpz_t g, slong h) noexcept - void fmpz_divexact_ui(fmpz_t f, const fmpz_t g, ulong h) + void fmpz_divexact_ui(fmpz_t f, const fmpz_t g, ulong h) noexcept # Sets `f` to the quotient of `g` and `h`, assuming that the # division is exact, i.e. `g` is a multiple of `h`. If `h` # is `0` an exception is raised. - void fmpz_divexact2_uiui(fmpz_t f, const fmpz_t g, ulong x, ulong y) + void fmpz_divexact2_uiui(fmpz_t f, const fmpz_t g, ulong x, ulong y) noexcept # Sets `f` to the quotient of `g` and `h = x \times y`, assuming that # the division is exact, i.e. `g` is a multiple of `h`. # If `x` or `y` is `0` an exception is raised. - int fmpz_divisible(const fmpz_t f, const fmpz_t g) + int fmpz_divisible(const fmpz_t f, const fmpz_t g) noexcept - int fmpz_divisible_si(const fmpz_t f, slong g) + int fmpz_divisible_si(const fmpz_t f, slong g) noexcept # Returns `1` if there is an integer `q` with `f = q g` and `0` if there is # none. - int fmpz_divides(fmpz_t q, const fmpz_t g, const fmpz_t h) + int fmpz_divides(fmpz_t q, const fmpz_t g, const fmpz_t h) noexcept # Returns `1` if there is an integer `q` with `f = q g` and sets `q` to the # quotient. Otherwise returns `0` and sets `q` to `0`. - void fmpz_mod(fmpz_t f, const fmpz_t g, const fmpz_t h) + void fmpz_mod(fmpz_t f, const fmpz_t g, const fmpz_t h) noexcept # Sets `f` to the remainder of `g` divided by `h` such that the remainder is # positive. Assumes that `h` is not zero. - ulong fmpz_mod_ui(fmpz_t f, const fmpz_t g, ulong h) + ulong fmpz_mod_ui(fmpz_t f, const fmpz_t g, ulong h) noexcept # Sets `f` to the remainder of `g` divided by `h` such that the remainder is # positive and also returns this value. Raises an exception if `h` is zero. - void fmpz_smod(fmpz_t f, const fmpz_t g, const fmpz_t h) + void fmpz_smod(fmpz_t f, const fmpz_t g, const fmpz_t h) noexcept # Sets `f` to the signed remainder `y \equiv g \bmod h` satisfying # `-\lvert h \rvert/2 < y \leq \lvert h\rvert/2`. - void fmpz_preinvn_init(fmpz_preinvn_t inv, const fmpz_t f) + void fmpz_preinvn_init(fmpz_preinvn_t inv, const fmpz_t f) noexcept # Compute a precomputed inverse ``inv`` of ``f`` for use in the # ``preinvn`` functions listed below. - void fmpz_preinvn_clear(fmpz_preinvn_t inv) + void fmpz_preinvn_clear(fmpz_preinvn_t inv) noexcept # Clean up the resources used by a precomputed inverse created with the # :func:`fmpz_preinvn_init` function. - void fmpz_fdiv_qr_preinvn(fmpz_t f, fmpz_t s, const fmpz_t g, const fmpz_t h, const fmpz_preinvn_t hinv) + void fmpz_fdiv_qr_preinvn(fmpz_t f, fmpz_t s, const fmpz_t g, const fmpz_t h, const fmpz_preinvn_t hinv) noexcept # As per :func:`fmpz_fdiv_qr`, but takes a precomputed inverse ``hinv`` # of `h` constructed using :func:`fmpz_preinvn`. # This function will be faster than :func:`fmpz_fdiv_qr_preinvn` when the # number of limbs of `h` is at least ``PREINVN_CUTOFF``. - void fmpz_pow_ui(fmpz_t f, const fmpz_t g, ulong x) - void fmpz_ui_pow_ui(fmpz_t f, ulong g, ulong x) + void fmpz_pow_ui(fmpz_t f, const fmpz_t g, ulong x) noexcept + void fmpz_ui_pow_ui(fmpz_t f, ulong g, ulong x) noexcept # Sets `f` to `g^x`. Defines `0^0 = 1`. - int fmpz_pow_fmpz(fmpz_t f, const fmpz_t g, const fmpz_t x) + int fmpz_pow_fmpz(fmpz_t f, const fmpz_t g, const fmpz_t x) noexcept # Sets `f` to `g^x`. Defines `0^0 = 1`. Return `1` for success and `0` for # failure. The function throws only if `x` is negative. - void fmpz_powm_ui(fmpz_t f, const fmpz_t g, ulong e, const fmpz_t m) + void fmpz_powm_ui(fmpz_t f, const fmpz_t g, ulong e, const fmpz_t m) noexcept - void fmpz_powm(fmpz_t f, const fmpz_t g, const fmpz_t e, const fmpz_t m) + void fmpz_powm(fmpz_t f, const fmpz_t g, const fmpz_t e, const fmpz_t m) noexcept # Sets `f` to `g^e \bmod{m}`. If `e = 0`, sets `f` to `1`. # Assumes that `m \neq 0`, raises an ``abort`` signal otherwise. - slong fmpz_clog(const fmpz_t x, const fmpz_t b) - slong fmpz_clog_ui(const fmpz_t x, ulong b) + slong fmpz_clog(const fmpz_t x, const fmpz_t b) noexcept + slong fmpz_clog_ui(const fmpz_t x, ulong b) noexcept # Returns `\lceil\log_b x\rceil`. # Assumes that `x \geq 1` and `b \geq 2` and that # the return value fits into a signed ``slong``. - slong fmpz_flog(const fmpz_t x, const fmpz_t b) - slong fmpz_flog_ui(const fmpz_t x, ulong b) + slong fmpz_flog(const fmpz_t x, const fmpz_t b) noexcept + slong fmpz_flog_ui(const fmpz_t x, ulong b) noexcept # Returns `\lfloor\log_b x\rfloor`. # Assumes that `x \geq 1` and `b \geq 2` and that # the return value fits into a signed ``slong``. - double fmpz_dlog(const fmpz_t x) + double fmpz_dlog(const fmpz_t x) noexcept # Returns a double precision approximation of the # natural logarithm of `x`. # The accuracy depends on the implementation of the floating-point # logarithm provided by the C standard library. The result can # typically be expected to have a relative error no greater than 1-2 bits. - int fmpz_sqrtmod(fmpz_t b, const fmpz_t a, const fmpz_t p) + int fmpz_sqrtmod(fmpz_t b, const fmpz_t a, const fmpz_t p) noexcept # If `p` is prime, set `b` to a square root of `a` modulo `p` if `a` is a # quadratic residue modulo `p` and return `1`, otherwise return `0`. # If `p` is not prime the return value is with high probability `0`, @@ -631,83 +631,83 @@ cdef extern from "flint_wrap.h": # If `p` is not prime and the return value is `1`, the value of `b` is # meaningless. - void fmpz_sqrt(fmpz_t f, const fmpz_t g) + void fmpz_sqrt(fmpz_t f, const fmpz_t g) noexcept # Sets `f` to the integer part of the square root of `g`, where # `g` is assumed to be non-negative. If `g` is negative, an exception # is raised. - void fmpz_sqrtrem(fmpz_t f, fmpz_t r, const fmpz_t g) + void fmpz_sqrtrem(fmpz_t f, fmpz_t r, const fmpz_t g) noexcept # Sets `f` to the integer part of the square root of `g`, where `g` is # assumed to be non-negative, and sets `r` to the remainder, that is, # the difference `g - f^2`. If `g` is negative, an exception is raised. # The behaviour is undefined if `f` and `r` are aliases. - bint fmpz_is_square(const fmpz_t f) + bint fmpz_is_square(const fmpz_t f) noexcept # Returns nonzero if `f` is a perfect square and zero otherwise. - int fmpz_root(fmpz_t r, const fmpz_t f, slong n) + int fmpz_root(fmpz_t r, const fmpz_t f, slong n) noexcept # Set `r` to the integer part of the `n`-th root of `f`. Requires that # `n > 0` and that if `n` is even then `f` be non-negative, otherwise an # exception is raised. The function returns `1` if the root was exact, # otherwise `0`. - bint fmpz_is_perfect_power(fmpz_t root, const fmpz_t f) + bint fmpz_is_perfect_power(fmpz_t root, const fmpz_t f) noexcept # If `f` is a perfect power `r^k` set ``root`` to `r` and return `k`, # otherwise return `0`. Note that `-1, 0, 1` are all considered perfect # powers. No guarantee is made about `r` or `k` being the smallest # possible value. Negative values of `f` are permitted. - void fmpz_fac_ui(fmpz_t f, ulong n) + void fmpz_fac_ui(fmpz_t f, ulong n) noexcept # Sets `f` to the factorial `n!` where `n` is an ``ulong``. - void fmpz_fib_ui(fmpz_t f, ulong n) + void fmpz_fib_ui(fmpz_t f, ulong n) noexcept # Sets `f` to the Fibonacci number `F_n` where `n` is an # ``ulong``. - void fmpz_bin_uiui(fmpz_t f, ulong n, ulong k) + void fmpz_bin_uiui(fmpz_t f, ulong n, ulong k) noexcept # Sets `f` to the binomial coefficient `{n choose k}`. - void _fmpz_rfac_ui(fmpz_t r, const fmpz_t x, ulong a, ulong b) + void _fmpz_rfac_ui(fmpz_t r, const fmpz_t x, ulong a, ulong b) noexcept # Sets `r` to the rising factorial `(x+a) (x+a+1) (x+a+2) \cdots (x+b-1)`. # Assumes `b > a`. - void fmpz_rfac_ui(fmpz_t r, const fmpz_t x, ulong k) + void fmpz_rfac_ui(fmpz_t r, const fmpz_t x, ulong k) noexcept # Sets `r` to the rising factorial `x (x+1) (x+2) \cdots (x+k-1)`. - void fmpz_rfac_uiui(fmpz_t r, ulong x, ulong k) + void fmpz_rfac_uiui(fmpz_t r, ulong x, ulong k) noexcept # Sets `r` to the rising factorial `x (x+1) (x+2) \cdots (x+k-1)`. - void fmpz_mul_tdiv_q_2exp(fmpz_t f, const fmpz_t g, const fmpz_t h, ulong exp) + void fmpz_mul_tdiv_q_2exp(fmpz_t f, const fmpz_t g, const fmpz_t h, ulong exp) noexcept # Sets `f` to the product of `g` and `h` divided by ``2^exp``, rounding # down towards zero. - void fmpz_mul_si_tdiv_q_2exp(fmpz_t f, const fmpz_t g, slong x, ulong exp) + void fmpz_mul_si_tdiv_q_2exp(fmpz_t f, const fmpz_t g, slong x, ulong exp) noexcept # Sets `f` to the product of `g` and `x` divided by ``2^exp``, rounding # down towards zero. - void fmpz_gcd_ui(fmpz_t f, const fmpz_t g, ulong h) + void fmpz_gcd_ui(fmpz_t f, const fmpz_t g, ulong h) noexcept - void fmpz_gcd(fmpz_t f, const fmpz_t g, const fmpz_t h) + void fmpz_gcd(fmpz_t f, const fmpz_t g, const fmpz_t h) noexcept # Sets `f` to the greatest common divisor of `g` and `h`. The # result is always positive, even if one of `g` and `h` is # negative. - void fmpz_gcd3(fmpz_t f, const fmpz_t a, const fmpz_t b, const fmpz_t c) + void fmpz_gcd3(fmpz_t f, const fmpz_t a, const fmpz_t b, const fmpz_t c) noexcept # Sets `f` to the greatest common divisor of `a`, `b` and `c`. # This is equivalent to calling ``fmpz_gcd`` twice, but may be faster. - void fmpz_lcm(fmpz_t f, const fmpz_t g, const fmpz_t h) + void fmpz_lcm(fmpz_t f, const fmpz_t g, const fmpz_t h) noexcept # Sets `f` to the least common multiple of `g` and `h`. The # result is always nonnegative, even if one of `g` and `h` is # negative. - void fmpz_gcdinv(fmpz_t d, fmpz_t a, const fmpz_t f, const fmpz_t g) + void fmpz_gcdinv(fmpz_t d, fmpz_t a, const fmpz_t f, const fmpz_t g) noexcept # Given integers `f, g` with `0 \leq f < g`, computes the # greatest common divisor `d = \gcd(f, g)` and the modular # inverse `a = f^{-1} \pmod{g}`, whenever `f \neq 0`. # Assumes that `d` and `a` are not aliased. - void fmpz_xgcd(fmpz_t d, fmpz_t a, fmpz_t b, const fmpz_t f, const fmpz_t g) + void fmpz_xgcd(fmpz_t d, fmpz_t a, fmpz_t b, const fmpz_t f, const fmpz_t g) noexcept # Computes the extended GCD of `f` and `g`, i.e. the values `a` and `b` such # that `af + bg = d`, where `d = \gcd(f, g)`. Here `a` will be the same as # calling ``fmpz_gcdinv`` when `f < g` (or vice versa for `b` when `g < f`). @@ -715,7 +715,7 @@ cdef extern from "flint_wrap.h": # ``fmpz_xgcd_canonical_bezout`` instead. This is also faster. # Assumes that there is no aliasing among the outputs. - void fmpz_xgcd_canonical_bezout(fmpz_t d, fmpz_t a, fmpz_t b, const fmpz_t f, const fmpz_t g) + void fmpz_xgcd_canonical_bezout(fmpz_t d, fmpz_t a, fmpz_t b, const fmpz_t f, const fmpz_t g) noexcept # Computes the extended GCD `\operatorname{xgcd}(f, g) = (d, a, b)` such that # the solution is the canonical solution to Bézout's identity. We define the # canonical solution to satisfy one of the following if one of the given @@ -737,7 +737,7 @@ cdef extern from "flint_wrap.h": # \qquad |b| < \Bigl| \frac{f}{2 d} \Bigr|. # Assumes that there is no aliasing among the outputs. - void fmpz_xgcd_partial(fmpz_t co2, fmpz_t co1, fmpz_t r2, fmpz_t r1, const fmpz_t L) + void fmpz_xgcd_partial(fmpz_t co2, fmpz_t co1, fmpz_t r2, fmpz_t r1, const fmpz_t L) noexcept # This function is an implementation of Lehmer extended GCD with early # termination, as used in the ``qfb`` module. It terminates early when # remainders fall below the specified bound. The initial values ``r1`` @@ -750,14 +750,14 @@ cdef extern from "flint_wrap.h": # Aliasing of inputs is not allowed. Similarly aliasing of inputs and outputs # is not allowed. - slong _fmpz_remove(fmpz_t x, const fmpz_t f, double finv) + slong _fmpz_remove(fmpz_t x, const fmpz_t f, double finv) noexcept # Removes all factors `f` from `x` and returns the number of such. # Assumes that `x` is non-zero, that `f > 1` and that ``finv`` # is the precomputed ``double`` inverse of `f` whenever `f` is # a small integer and `0` otherwise. # Does not support aliasing. - slong fmpz_remove(fmpz_t rop, const fmpz_t op, const fmpz_t f) + slong fmpz_remove(fmpz_t rop, const fmpz_t op, const fmpz_t f) noexcept # Remove all occurrences of the factor `f > 1` from the # integer ``op`` and sets ``rop`` to the resulting # integer. @@ -766,28 +766,28 @@ cdef extern from "flint_wrap.h": # Returns an ``abort`` signal if any of the assumptions # are violated. - int fmpz_invmod(fmpz_t f, const fmpz_t g, const fmpz_t h) + int fmpz_invmod(fmpz_t f, const fmpz_t g, const fmpz_t h) noexcept # Sets `f` to the inverse of `g` modulo `h`. The value of `h` may # not be `0` otherwise an exception results. If the inverse exists # the return value will be non-zero, otherwise the return value will # be `0` and the value of `f` undefined. As a special case, we # consider any number invertible modulo `h = \pm 1`, with inverse 0. - void fmpz_negmod(fmpz_t f, const fmpz_t g, const fmpz_t h) + void fmpz_negmod(fmpz_t f, const fmpz_t g, const fmpz_t h) noexcept # Sets `f` to `-g \pmod{h}`, assuming `g` is reduced modulo `h`. - int fmpz_jacobi(const fmpz_t a, const fmpz_t n) + int fmpz_jacobi(const fmpz_t a, const fmpz_t n) noexcept # Computes the Jacobi symbol `\left(\frac{a}{n}\right)` for any `a` and odd positive `n`. - int fmpz_kronecker(const fmpz_t a, const fmpz_t n) + int fmpz_kronecker(const fmpz_t a, const fmpz_t n) noexcept # Computes the Kronecker symbol `\left(\frac{a}{n}\right)` for any `a` and any `n`. - void fmpz_divides_mod_list(fmpz_t xstart, fmpz_t xstride, fmpz_t xlength, const fmpz_t a, const fmpz_t b, const fmpz_t n) + void fmpz_divides_mod_list(fmpz_t xstart, fmpz_t xstride, fmpz_t xlength, const fmpz_t a, const fmpz_t b, const fmpz_t n) noexcept # Set `xstart`, `xstride`, and `xlength` so that the solution set for `x` modulo `n` in `a x = b \bmod n` is exactly `\{xstart + xstride\,i \mid 0 \le i < xlength\}`. # This function essentially gives a list of possibilities for the fraction `a/b` modulo `n`. # The outputs may not be aliased, and `n` should be positive. - int fmpz_bit_pack(mp_limb_t * arr, flint_bitcnt_t shift, flint_bitcnt_t bits, const fmpz_t coeff, int negate, int borrow) + int fmpz_bit_pack(mp_limb_t * arr, flint_bitcnt_t shift, flint_bitcnt_t bits, const fmpz_t coeff, int negate, int borrow) noexcept # Shifts the given coefficient to the left by ``shift`` bits and adds # it to the integer in ``arr`` in a field of the given number of bits:: # shift bits -------------- @@ -801,7 +801,7 @@ cdef extern from "flint_wrap.h": # The value of ``coeff`` may also be optionally (and notionally) negated # before it is used, by setting the ``negate`` parameter to `-1`. - int fmpz_bit_unpack(fmpz_t coeff, mp_limb_t * arr, flint_bitcnt_t shift, flint_bitcnt_t bits, int negate, int borrow) + int fmpz_bit_unpack(fmpz_t coeff, mp_limb_t * arr, flint_bitcnt_t shift, flint_bitcnt_t bits, int negate, int borrow) noexcept # A bit field of the given number of bits is extracted from ``arr``, # starting after ``shift`` bits, and placed into ``coeff``. An # optional borrow of `1` may be added to the coefficient. If the result @@ -809,37 +809,37 @@ cdef extern from "flint_wrap.h": # ``coeff`` may be negated by setting the ``negate`` parameter to `-1`. # The value of ``shift`` is expected to be less than ``FLINT_BITS``. - void fmpz_bit_unpack_unsigned(fmpz_t coeff, const mp_limb_t * arr, flint_bitcnt_t shift, flint_bitcnt_t bits) + void fmpz_bit_unpack_unsigned(fmpz_t coeff, const mp_limb_t * arr, flint_bitcnt_t shift, flint_bitcnt_t bits) noexcept # A bit field of the given number of bits is extracted from ``arr``, # starting after ``shift`` bits, and placed into ``coeff``. # The value of ``shift`` is expected to be less than ``FLINT_BITS``. - void fmpz_complement(fmpz_t r, const fmpz_t f) + void fmpz_complement(fmpz_t r, const fmpz_t f) noexcept # The variable ``r`` is set to the ones-complement of ``f``. - void fmpz_clrbit(fmpz_t f, ulong i) + void fmpz_clrbit(fmpz_t f, ulong i) noexcept # Sets the ``i``\th bit in ``f`` to zero. - void fmpz_combit(fmpz_t f, ulong i) + void fmpz_combit(fmpz_t f, ulong i) noexcept # Complements the ``i``\th bit in ``f``. - void fmpz_and(fmpz_t r, const fmpz_t a, const fmpz_t b) + void fmpz_and(fmpz_t r, const fmpz_t a, const fmpz_t b) noexcept # Sets ``r`` to the bit-wise logical ``and`` of ``a`` and ``b``. - void fmpz_or(fmpz_t r, const fmpz_t a, const fmpz_t b) + void fmpz_or(fmpz_t r, const fmpz_t a, const fmpz_t b) noexcept # Sets ``r`` to the bit-wise logical (inclusive) ``or`` of # ``a`` and ``b``. - void fmpz_xor(fmpz_t r, const fmpz_t a, const fmpz_t b) + void fmpz_xor(fmpz_t r, const fmpz_t a, const fmpz_t b) noexcept # Sets ``r`` to the bit-wise logical exclusive ``or`` of # ``a`` and ``b``. - ulong fmpz_popcnt(const fmpz_t a) + ulong fmpz_popcnt(const fmpz_t a) noexcept # Returns the number of '1' bits in the given Z (aka Hamming weight or # population count). # The return value is undefined if the input is negative. - void fmpz_CRT_ui(fmpz_t out, const fmpz_t r1, const fmpz_t m1, ulong r2, ulong m2, int sign) + void fmpz_CRT_ui(fmpz_t out, const fmpz_t r1, const fmpz_t m1, ulong r2, ulong m2, int sign) noexcept # Uses the Chinese Remainder Theorem to compute the unique integer # `0 \le x < M` (if sign = 0) or `-M/2 < x \le M/2` (if sign = 1) # congruent to `r_1` modulo `m_1` and `r_2` modulo `m_2`, @@ -849,7 +849,7 @@ cdef extern from "flint_wrap.h": # If sign = 0, it is assumed that `0 \le r_1 < m_1` and `0 \le r_2 < m_2`. # Otherwise, it is assumed that `-m_1 \le r_1 < m_1` and `0 \le r_2 < m_2`. - void fmpz_CRT(fmpz_t out, const fmpz_t r1, const fmpz_t m1, fmpz_t r2, fmpz_t m2, int sign) + void fmpz_CRT(fmpz_t out, const fmpz_t r1, const fmpz_t m1, fmpz_t r2, fmpz_t m2, int sign) noexcept # Use the Chinese Remainder Theorem to set ``out`` to the unique value # `0 \le x < M` (if sign = 0) or `-M/2 < x \le M/2` (if sign = 1) # congruent to `r_1` modulo `m_1` and `r_2` modulo `m_2`, @@ -859,14 +859,14 @@ cdef extern from "flint_wrap.h": # If sign = 0, it is assumed that `0 \le r_1 < m_1` and `0 \le r_2 < m_2`. # Otherwise, it is assumed that `-m_1 \le r_1 < m_1` and `0 \le r_2 < m_2`. - void fmpz_multi_mod_ui(mp_limb_t * out, const fmpz_t input, const fmpz_comb_t comb, fmpz_comb_temp_t temp) + void fmpz_multi_mod_ui(mp_limb_t * out, const fmpz_t input, const fmpz_comb_t comb, fmpz_comb_temp_t temp) noexcept # Reduces the multiprecision integer ``in`` modulo each of the primes # stored in the ``comb`` structure. The array ``out`` will be filled # with the residues modulo these primes. The structure ``temp`` is # temporary space which must be provided by :func:`fmpz_comb_temp_init` and # cleared by :func:`fmpz_comb_temp_clear`. - void fmpz_multi_CRT_ui(fmpz_t output, mp_srcptr residues, const fmpz_comb_t comb, fmpz_comb_temp_t ctemp, int sign) + void fmpz_multi_CRT_ui(fmpz_t output, mp_srcptr residues, const fmpz_comb_t comb, fmpz_comb_temp_t ctemp, int sign) noexcept # This function takes a set of residues modulo the list of primes # contained in the ``comb`` structure and reconstructs a multiprecision # integer modulo the product of the primes which has @@ -877,7 +877,7 @@ cdef extern from "flint_wrap.h": # space which must be provided by :func:`fmpz_comb_temp_init` and # cleared by :func:`fmpz_comb_temp_clear`. - void fmpz_comb_init(fmpz_comb_t comb, mp_srcptr primes, slong num_primes) + void fmpz_comb_init(fmpz_comb_t comb, mp_srcptr primes, slong num_primes) noexcept # Initialises a ``comb`` structure for multimodular reduction and # recombination. The array ``primes`` is assumed to contain # ``num_primes`` primes each of ``FLINT_BITS - 1`` bits. Modular @@ -885,49 +885,49 @@ cdef extern from "flint_wrap.h": # The ``primes`` array must not be ``free``'d until the ``comb`` # structure is no longer required and must be cleared by the user. - void fmpz_comb_temp_init(fmpz_comb_temp_t temp, const fmpz_comb_t comb) + void fmpz_comb_temp_init(fmpz_comb_temp_t temp, const fmpz_comb_t comb) noexcept # Creates temporary space to be used by multimodular and CRT functions # based on an initialised ``comb`` structure. - void fmpz_comb_clear(fmpz_comb_t comb) + void fmpz_comb_clear(fmpz_comb_t comb) noexcept # Clears the given ``comb`` structure, releasing any memory it uses. - void fmpz_comb_temp_clear(fmpz_comb_temp_t temp) + void fmpz_comb_temp_clear(fmpz_comb_temp_t temp) noexcept # Clears temporary space ``temp`` used by multimodular and CRT functions # using the given ``comb`` structure. - void fmpz_multi_CRT_init(fmpz_multi_CRT_t CRT) + void fmpz_multi_CRT_init(fmpz_multi_CRT_t CRT) noexcept # Initialize ``CRT`` for Chinese remaindering. - int fmpz_multi_CRT_precompute(fmpz_multi_CRT_t CRT, const fmpz * moduli, slong len) + int fmpz_multi_CRT_precompute(fmpz_multi_CRT_t CRT, const fmpz * moduli, slong len) noexcept # Configure ``CRT`` for repeated Chinese remaindering of ``moduli``. The number of moduli, ``len``, should be positive. # A return of ``0`` indicates that the compilation failed and future # calls to :func:`fmpz_multi_CRT_precomp` will leave the output undefined. # A return of ``1`` indicates that the compilation was successful, which occurs if and only # if either (1) ``len == 1`` and ``modulus + 0`` is nonzero, or (2) no modulus is `0,1,-1` and all moduli are pairwise relatively prime. - void fmpz_multi_CRT_precomp(fmpz_t output, const fmpz_multi_CRT_t P, const fmpz * inputs, int sign) + void fmpz_multi_CRT_precomp(fmpz_t output, const fmpz_multi_CRT_t P, const fmpz * inputs, int sign) noexcept # Set ``output`` to an integer of smallest absolute value that is congruent to ``values + i`` modulo the ``moduli + i`` # in ``P``. - int fmpz_multi_CRT(fmpz_t output, const fmpz * moduli, const fmpz * values, slong len, int sign) + int fmpz_multi_CRT(fmpz_t output, const fmpz * moduli, const fmpz * values, slong len, int sign) noexcept # Perform the same operation as :func:`fmpz_multi_CRT_precomp` while internally constructing and destroying the precomputed data. # All of the remarks in :func:`fmpz_multi_CRT_precompute` apply. - void fmpz_multi_CRT_clear(fmpz_multi_CRT_t P) + void fmpz_multi_CRT_clear(fmpz_multi_CRT_t P) noexcept # Free all space used by ``CRT``. - bint fmpz_is_strong_probabprime(const fmpz_t n, const fmpz_t a) + bint fmpz_is_strong_probabprime(const fmpz_t n, const fmpz_t a) noexcept # Returns `1` if `n` is a strong probable prime to base `a`, otherwise it # returns `0`. - bint fmpz_is_probabprime_lucas(const fmpz_t n) + bint fmpz_is_probabprime_lucas(const fmpz_t n) noexcept # Performs a Lucas probable prime test with parameters chosen by Selfridge's # method `A` as per [BaiWag1980]_. # Return `1` if `n` is a Lucas probable prime, otherwise return `0`. This # function declares some composites probably prime, but no primes composite. - bint fmpz_is_probabprime_BPSW(const fmpz_t n) + bint fmpz_is_probabprime_BPSW(const fmpz_t n) noexcept # Perform a Baillie-PSW probable prime test with parameters chosen by # Selfridge's method `A` as per [BaiWag1980]_. # Return `1` if `n` is a Lucas probable prime, otherwise return `0`. @@ -935,7 +935,7 @@ cdef extern from "flint_wrap.h": # infinitely many probably exist. The test will declare no primes # composite. - bint fmpz_is_probabprime(const fmpz_t p) + bint fmpz_is_probabprime(const fmpz_t p) noexcept # Performs some trial division and then some probabilistic primality tests. # If `p` is definitely composite, the function returns `0`, otherwise it # is declared probably prime, i.e. prime for most practical purposes, and @@ -944,7 +944,7 @@ cdef extern from "flint_wrap.h": # Subsequent calls to the same function do not increase the probability of # the number being prime. - bint fmpz_is_prime_pseudosquare(const fmpz_t n) + bint fmpz_is_prime_pseudosquare(const fmpz_t n) noexcept # Return `0` is `n` is composite. If `n` is too large (greater than about # `94` bits) the function fails silently and returns `-1`, otherwise, if # `n` is proven prime by the pseudosquares method, return `1`. @@ -973,7 +973,7 @@ cdef extern from "flint_wrap.h": # composite prime. However in that case an error is printed, as # that would be of independent interest. - bint fmpz_is_prime_pocklington(fmpz_t F, fmpz_t R, const fmpz_t n, mp_ptr pm1, slong num_pm1) + bint fmpz_is_prime_pocklington(fmpz_t F, fmpz_t R, const fmpz_t n, mp_ptr pm1, slong num_pm1) noexcept # Applies the Pocklington primality test. The test computes a product # `F` of prime powers which divide `n - 1`. # The function then returns either `0` if `n` is definitely composite @@ -993,7 +993,7 @@ cdef extern from "flint_wrap.h": # limit. (See ``_fmpz_nm1_trial_factors``.) # Requires `n` to be odd. - void _fmpz_nm1_trial_factors(const fmpz_t n, mp_ptr pm1, slong * num_pm1, ulong limit) + void _fmpz_nm1_trial_factors(const fmpz_t n, mp_ptr pm1, slong * num_pm1, ulong limit) noexcept # Trial factors `n - 1` up to the given limit (approximately) and stores # the factors in an array ``pm1`` whose length is written out to # ``num_pm1``. @@ -1001,7 +1001,7 @@ cdef extern from "flint_wrap.h": # be produced (and hence on the length of the array that needs to be # supplied). - bint fmpz_is_prime_morrison(fmpz_t F, fmpz_t R, const fmpz_t n, mp_ptr pp1, slong num_pp1) + bint fmpz_is_prime_morrison(fmpz_t F, fmpz_t R, const fmpz_t n, mp_ptr pp1, slong num_pp1) noexcept # Applies the Morrison `p + 1` primality test. The test computes a # product `F` of primes which divide `n + 1`. # The function then returns either `0` if `n` is definitely composite @@ -1022,7 +1022,7 @@ cdef extern from "flint_wrap.h": # limit. (See ``_fmpz_np1_trial_factors``.) # Requires `n` to be odd and non-square. - void _fmpz_np1_trial_factors(const fmpz_t n, mp_ptr pp1, slong * num_pp1, ulong limit) + void _fmpz_np1_trial_factors(const fmpz_t n, mp_ptr pp1, slong * num_pp1, ulong limit) noexcept # Trial factors `n + 1` up to the given limit (approximately) and stores # the factors in an array ``pp1`` whose length is written out to # ``num_pp1``. @@ -1030,7 +1030,7 @@ cdef extern from "flint_wrap.h": # be produced (and hence on the length of the array that needs to be # supplied). - bint fmpz_is_prime(const fmpz_t n) + bint fmpz_is_prime(const fmpz_t n) noexcept # Attempts to prove `n` prime. If `n` is proven prime, the function # returns `1`. If `n` is definitely composite, the function returns `0`. # This function calls :func:`n_is_prime` for `n` that fits in a single word. @@ -1048,41 +1048,41 @@ cdef extern from "flint_wrap.h": # or composite. In that case, the program aborts. This is not expected to # occur in practice. - void fmpz_lucas_chain(fmpz_t Vm, fmpz_t Vm1, const fmpz_t A, const fmpz_t m, const fmpz_t n) + void fmpz_lucas_chain(fmpz_t Vm, fmpz_t Vm1, const fmpz_t A, const fmpz_t m, const fmpz_t n) noexcept # Given `V_0 = 2`, `V_1 = A` compute `V_m, V_{m + 1} \pmod{n}` from the # recurrences `V_j = AV_{j - 1} - V_{j - 2} \pmod{n}`. # This is computed efficiently using `V_{2j} = V_j^2 - 2 \pmod{n}` and # `V_{2j + 1} = V_jV_{j + 1} - A \pmod{n}`. # No aliasing is permitted. - void fmpz_lucas_chain_full(fmpz_t Vm, fmpz_t Vm1, const fmpz_t A, const fmpz_t B, const fmpz_t m, const fmpz_t n) + void fmpz_lucas_chain_full(fmpz_t Vm, fmpz_t Vm1, const fmpz_t A, const fmpz_t B, const fmpz_t m, const fmpz_t n) noexcept # Given `V_0 = 2`, `V_1 = A` compute `V_m, V_{m + 1} \pmod{n}` from the # recurrences `V_j = AV_{j - 1} - BV_{j - 2} \pmod{n}`. # This is computed efficiently using double and add formulas. # No aliasing is permitted. - void fmpz_lucas_chain_double(fmpz_t U2m, fmpz_t U2m1, const fmpz_t Um, const fmpz_t Um1, const fmpz_t A, const fmpz_t B, const fmpz_t n) + void fmpz_lucas_chain_double(fmpz_t U2m, fmpz_t U2m1, const fmpz_t Um, const fmpz_t Um1, const fmpz_t A, const fmpz_t B, const fmpz_t n) noexcept # Given `U_m, U_{m + 1} \pmod{n}` compute `U_{2m}, U_{2m + 1} \pmod{n}`. # Aliasing of `U_{2m}` and `U_m` and aliasing of `U_{2m + 1}` and `U_{m + 1}` # is permitted. No other aliasing is allowed. - void fmpz_lucas_chain_add(fmpz_t Umn, fmpz_t Umn1, const fmpz_t Um, const fmpz_t Um1, const fmpz_t Un, const fmpz_t Un1, const fmpz_t A, const fmpz_t B, const fmpz_t n) + void fmpz_lucas_chain_add(fmpz_t Umn, fmpz_t Umn1, const fmpz_t Um, const fmpz_t Um1, const fmpz_t Un, const fmpz_t Un1, const fmpz_t A, const fmpz_t B, const fmpz_t n) noexcept # Given `U_m, U_{m + 1} \pmod{n}` and `U_n, U_{n + 1} \pmod{n}` compute # `U_{m + n}, U_{m + n + 1} \pmod{n}`. # Aliasing of `U_{m + n}` with `U_m` or `U_n` and aliasing of `U_{m + n + 1}` # with `U_{m + 1}` or `U_{n + 1}` is permitted. No other aliasing is allowed. - void fmpz_lucas_chain_mul(fmpz_t Ukm, fmpz_t Ukm1, const fmpz_t Um, const fmpz_t Um1, const fmpz_t A, const fmpz_t B, const fmpz_t k, const fmpz_t n) + void fmpz_lucas_chain_mul(fmpz_t Ukm, fmpz_t Ukm1, const fmpz_t Um, const fmpz_t Um1, const fmpz_t A, const fmpz_t B, const fmpz_t k, const fmpz_t n) noexcept # Given `U_m, U_{m + 1} \pmod{n}` compute `U_{km}, U_{km + 1} \pmod{n}`. # Aliasing of `U_{km}` and `U_m` and aliasing of `U_{km + 1}` and `U_{m + 1}` # is permitted. No other aliasing is allowed. - void fmpz_lucas_chain_VtoU(fmpz_t Um, fmpz_t Um1, const fmpz_t Vm, const fmpz_t Vm1, const fmpz_t A, const fmpz_t B, const fmpz_t Dinv, const fmpz_t n) + void fmpz_lucas_chain_VtoU(fmpz_t Um, fmpz_t Um1, const fmpz_t Vm, const fmpz_t Vm1, const fmpz_t A, const fmpz_t B, const fmpz_t Dinv, const fmpz_t n) noexcept # Given `V_m, V_{m + 1} \pmod{n}` compute `U_m, U_{m + 1} \pmod{n}`. # Aliasing of `V_m` and `U_m` and aliasing of `V_{m + 1}` and `U_{m + 1}` # is permitted. No other aliasing is allowed. - int fmpz_divisor_in_residue_class_lenstra(fmpz_t fac, const fmpz_t n, const fmpz_t r, const fmpz_t s) + int fmpz_divisor_in_residue_class_lenstra(fmpz_t fac, const fmpz_t n, const fmpz_t r, const fmpz_t s) noexcept # If there exists a proper divisor of `n` which is `r \pmod{s}` for # `0 < r < s < n`, this function returns `1` and sets ``fac`` to such a # divisor. Otherwise the function returns `0` and the value of ``fac`` is @@ -1090,7 +1090,7 @@ cdef extern from "flint_wrap.h": # We require `\gcd(r, s) = 1`. # This is efficient if `s^3 > n`. - void fmpz_nextprime(fmpz_t res, const fmpz_t n, int proved) + void fmpz_nextprime(fmpz_t res, const fmpz_t n, int proved) noexcept # Finds the next prime number larger than `n`. # If ``proved`` is nonzero, then the integer returned is # guaranteed to actually be prime. Otherwise if `n` fits in @@ -1099,19 +1099,19 @@ cdef extern from "flint_wrap.h": # GMP 6.1.2 this used Miller-Rabin iterations, and thereafter uses # a BPSW test. - void fmpz_primorial(fmpz_t res, ulong n) + void fmpz_primorial(fmpz_t res, ulong n) noexcept # Sets ``res`` to ``n`` primorial or `n \#`, the product of all prime # numbers less than or equal to `n`. - void fmpz_factor_euler_phi(fmpz_t res, const fmpz_factor_t fac) - void fmpz_euler_phi(fmpz_t res, const fmpz_t n) + void fmpz_factor_euler_phi(fmpz_t res, const fmpz_factor_t fac) noexcept + void fmpz_euler_phi(fmpz_t res, const fmpz_t n) noexcept # Sets ``res`` to the Euler totient function `\phi(n)`, counting the # number of positive integers less than or equal to `n` that are coprime # to `n`. The factor version takes a precomputed # factorisation of `n`. - int fmpz_factor_moebius_mu(const fmpz_factor_t fac) - int fmpz_moebius_mu(const fmpz_t n) + int fmpz_factor_moebius_mu(const fmpz_factor_t fac) noexcept + int fmpz_moebius_mu(const fmpz_t n) noexcept # Computes the Moebius function `\mu(n)`, which is defined as `\mu(n) = 0` # if `n` has a prime factor of multiplicity greater than `1`, `\mu(n) = -1` # if `n` has an odd number of distinct prime factors, and `\mu(n) = 1` if @@ -1119,8 +1119,8 @@ cdef extern from "flint_wrap.h": # `\mu(0) = 0`. The factor version takes a precomputed # factorisation of `n`. - void fmpz_factor_divisor_sigma(fmpz_t res, ulong k, const fmpz_factor_t fac) - void fmpz_divisor_sigma(fmpz_t res, ulong k, const fmpz_t n) + void fmpz_factor_divisor_sigma(fmpz_t res, ulong k, const fmpz_factor_t fac) noexcept + void fmpz_divisor_sigma(fmpz_t res, ulong k, const fmpz_t n) noexcept # Sets ``res`` to `\sigma_k(n)`, the sum of `k`\th powers of all # divisors of `n`. The factor version takes a precomputed # factorisation of `n`. diff --git a/src/sage/libs/flint/fmpz_extras.pxd b/src/sage/libs/flint/fmpz_extras.pxd index 4f41831cb9c..248fd0a04e1 100644 --- a/src/sage/libs/flint/fmpz_extras.pxd +++ b/src/sage/libs/flint/fmpz_extras.pxd @@ -12,55 +12,55 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - slong fmpz_allocated_bytes(const fmpz_t x) + slong fmpz_allocated_bytes(const fmpz_t x) noexcept # Returns the total number of bytes heap-allocated internally by this object. # The count excludes the size of the structure itself. Add # ``sizeof(fmpz)`` to get the size of the object as a whole. - void fmpz_adiv_q_2exp(fmpz_t z, const fmpz_t x, flint_bitcnt_t exp) + void fmpz_adiv_q_2exp(fmpz_t z, const fmpz_t x, flint_bitcnt_t exp) noexcept # Sets *z* to `x / 2^{exp}`, rounded away from zero. - void fmpz_ui_mul_ui(fmpz_t x, ulong a, ulong b) + void fmpz_ui_mul_ui(fmpz_t x, ulong a, ulong b) noexcept # Sets *x* to *a* times *b*. - void fmpz_max(fmpz_t z, const fmpz_t x, const fmpz_t y) + void fmpz_max(fmpz_t z, const fmpz_t x, const fmpz_t y) noexcept - void fmpz_min(fmpz_t z, const fmpz_t x, const fmpz_t y) + void fmpz_min(fmpz_t z, const fmpz_t x, const fmpz_t y) noexcept # Sets *z* to the maximum (respectively minimum) of *x* and *y*. - void fmpz_add_inline(fmpz_t z, const fmpz_t x, const fmpz_t y) + void fmpz_add_inline(fmpz_t z, const fmpz_t x, const fmpz_t y) noexcept - void fmpz_add_si_inline(fmpz_t z, const fmpz_t x, slong y) + void fmpz_add_si_inline(fmpz_t z, const fmpz_t x, slong y) noexcept - void fmpz_add_ui_inline(fmpz_t z, const fmpz_t x, ulong y) + void fmpz_add_ui_inline(fmpz_t z, const fmpz_t x, ulong y) noexcept # Sets *z* to the sum of *x* and *y*. - void fmpz_sub_si_inline(fmpz_t z, const fmpz_t x, slong y) + void fmpz_sub_si_inline(fmpz_t z, const fmpz_t x, slong y) noexcept # Sets *z* to the difference of *x* and *y*. - void fmpz_add2_fmpz_si_inline(fmpz_t z, const fmpz_t x, const fmpz_t y, slong c) + void fmpz_add2_fmpz_si_inline(fmpz_t z, const fmpz_t x, const fmpz_t y, slong c) noexcept # Sets *z* to the sum of *x*, *y*, and *c*. - mp_size_t _fmpz_size(const fmpz_t x) + mp_size_t _fmpz_size(const fmpz_t x) noexcept # Returns the number of limbs required to represent *x*. - slong _fmpz_sub_small(const fmpz_t x, const fmpz_t y) + slong _fmpz_sub_small(const fmpz_t x, const fmpz_t y) noexcept # Computes the difference of *x* and *y* and returns the result as # an *slong*. The result is clamped between -*WORD_MAX* and *WORD_MAX*, # i.e. between `\pm (2^{63}-1)` inclusive on a 64-bit machine. - void _fmpz_set_si_small(fmpz_t x, slong v) + void _fmpz_set_si_small(fmpz_t x, slong v) noexcept # Sets *x* to the integer *v* which is required to be a value # between *COEFF_MIN* and *COEFF_MAX* so that promotion to # a bignum cannot occur. - void fmpz_set_mpn_large(fmpz_t z, mp_srcptr src, mp_size_t n, int negative) + void fmpz_set_mpn_large(fmpz_t z, mp_srcptr src, mp_size_t n, int negative) noexcept # Sets *z* to the integer represented by the *n* limbs in the array *src*, # or minus this value if *negative* is 1. # Requires `n \ge 2` and that the top limb of *src* is nonzero. # Note that *fmpz_set_ui*, *fmpz_neg_ui* can be used for single-limb integers. - void fmpz_lshift_mpn(fmpz_t z, mp_srcptr src, mp_size_t n, int negative, flint_bitcnt_t shift) + void fmpz_lshift_mpn(fmpz_t z, mp_srcptr src, mp_size_t n, int negative, flint_bitcnt_t shift) noexcept # Sets *z* to the integer represented by the *n* limbs in the array *src*, # or minus this value if *negative* is 1, shifted left by *shift* bits. # Requires `n \ge 1` and that the top limb of *src* is nonzero. diff --git a/src/sage/libs/flint/fmpz_factor.pxd b/src/sage/libs/flint/fmpz_factor.pxd index a9b8b6421aa..75d29a50de1 100644 --- a/src/sage/libs/flint/fmpz_factor.pxd +++ b/src/sage/libs/flint/fmpz_factor.pxd @@ -12,25 +12,25 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void fmpz_factor_init(fmpz_factor_t factor) + void fmpz_factor_init(fmpz_factor_t factor) noexcept # Initialises an ``fmpz_factor_t`` structure. - void fmpz_factor_clear(fmpz_factor_t factor) + void fmpz_factor_clear(fmpz_factor_t factor) noexcept # Clears an ``fmpz_factor_t`` structure. - void _fmpz_factor_append_ui(fmpz_factor_t factor, mp_limb_t p, ulong exp) + void _fmpz_factor_append_ui(fmpz_factor_t factor, mp_limb_t p, ulong exp) noexcept # Append a factor `p` to the given exponent to the # ``fmpz_factor_t`` structure ``factor``. - void _fmpz_factor_append(fmpz_factor_t factor, const fmpz_t p, ulong exp) + void _fmpz_factor_append(fmpz_factor_t factor, const fmpz_t p, ulong exp) noexcept # Append a factor `p` to the given exponent to the # ``fmpz_factor_t`` structure ``factor``. - void fmpz_factor(fmpz_factor_t factor, const fmpz_t n) + void fmpz_factor(fmpz_factor_t factor, const fmpz_t n) noexcept # Factors `n` into prime numbers. If `n` is zero or negative, the # sign field of the ``factor`` object will be set accordingly. - int fmpz_factor_smooth(fmpz_factor_t factor, const fmpz_t n, slong bits, int proved) + int fmpz_factor_smooth(fmpz_factor_t factor, const fmpz_t n, slong bits, int proved) noexcept # Factors `n` into prime numbers up to approximately the given number of # bits and possibly one additional cofactor, which may or may not be prime. # If the number is definitely factored fully, the return value is `1`, @@ -58,10 +58,10 @@ cdef extern from "flint_wrap.h": # ``n_factor`` internally if `n` or the remainder after trial division # is smaller than one word, guaranteeing a complete factorisation. - void fmpz_factor_si(fmpz_factor_t factor, slong n) + void fmpz_factor_si(fmpz_factor_t factor, slong n) noexcept # Like ``fmpz_factor``, but takes a machine integer `n` as input. - int fmpz_factor_trial_range(fmpz_factor_t factor, const fmpz_t n, ulong start, ulong num_primes) + int fmpz_factor_trial_range(fmpz_factor_t factor, const fmpz_t n, ulong start, ulong num_primes) noexcept # Factors `n` into prime factors using trial division. If `n` is # zero or negative, the sign field of the ``factor`` object will be # set accordingly. @@ -70,7 +70,7 @@ cdef extern from "flint_wrap.h": # The function returns 1 if `n` is completely factored, otherwise it returns # `0`. - int fmpz_factor_trial(fmpz_factor_t factor, const fmpz_t n, slong num_primes) + int fmpz_factor_trial(fmpz_factor_t factor, const fmpz_t n, slong num_primes) noexcept # Factors `n` into prime factors using trial division. If `n` is # zero or negative, the sign field of the ``factor`` object will be # set accordingly. @@ -82,20 +82,20 @@ cdef extern from "flint_wrap.h": # The final entry in the factor struct is set to the cofactor after removing # prime factors, if this is not `1`. - void fmpz_factor_refine(fmpz_factor_t res, const fmpz_factor_t f) + void fmpz_factor_refine(fmpz_factor_t res, const fmpz_factor_t f) noexcept # Attempts to improve a partial factorization of an integer by "refining" # the factorization ``f`` to a more complete factorization ``res`` # whose bases are pairwise relatively prime. # This function does not require its input to be in canonical form, # nor does it guarantee that the resulting factorization will be canonical. - void fmpz_factor_expand_iterative(fmpz_t n, const fmpz_factor_t factor) + void fmpz_factor_expand_iterative(fmpz_t n, const fmpz_factor_t factor) noexcept # Evaluates an integer in factored form back to an ``fmpz_t``. # This currently exponentiates the bases separately and multiplies # them together one by one, although much more efficient algorithms # exist. - int fmpz_factor_pp1(fmpz_t factor, const fmpz_t n, ulong B1, ulong B2_sqrt, ulong c) + int fmpz_factor_pp1(fmpz_t factor, const fmpz_t n, ulong B1, ulong B2_sqrt, ulong c) noexcept # Use Williams' `p + 1` method to factor `n`, using a prime bound in # stage 1 of ``B1`` and a prime limit in stage 2 of at least the square # of ``B2_sqrt``. If a factor is found, the function returns `1` and @@ -108,7 +108,7 @@ cdef extern from "flint_wrap.h": # smooth for any prime factors `p` of `n` then the function will # not ever succeed). - int fmpz_factor_pollard_brent_single(fmpz_t p_factor, fmpz_t n_in, fmpz_t yi, fmpz_t ai, mp_limb_t max_iters) + int fmpz_factor_pollard_brent_single(fmpz_t p_factor, fmpz_t n_in, fmpz_t yi, fmpz_t ai, mp_limb_t max_iters) noexcept # Pollard Rho algorithm for integer factorization. Assumes that the `n` is # not prime. ``factor`` is set as the factor if found. Takes as input the initial # value `y`, to start polynomial evaluation, and `a`, the constant of the polynomial @@ -119,7 +119,7 @@ cdef extern from "flint_wrap.h": # If the algorithm fails to find a non trivial factor in one call, it tries again # (this time with a different set of random values). - int fmpz_factor_pollard_brent(fmpz_t factor, flint_rand_t state, fmpz_t n, mp_limb_t max_tries, mp_limb_t max_iters) + int fmpz_factor_pollard_brent(fmpz_t factor, flint_rand_t state, fmpz_t n, mp_limb_t max_tries, mp_limb_t max_iters) noexcept # Pollard Rho algorithm for integer factorization. Assumes that the `n` is # not prime. ``factor`` is set as the factor if found. It is not assured that the # factor found will be prime. Does not compute the complete factorization, @@ -133,26 +133,26 @@ cdef extern from "flint_wrap.h": # suggested by Richard Brent. It can be found in the paper available at # https://maths-people.anu.edu.au/~brent/pd/rpb051i.pdf - void fmpz_factor_ecm_init(ecm_t ecm_inf, mp_limb_t sz) + void fmpz_factor_ecm_init(ecm_t ecm_inf, mp_limb_t sz) noexcept # Initializes the ``ecm_t`` struct. This is needed in some functions # and carries data between subsequent calls. - void fmpz_factor_ecm_clear(ecm_t ecm_inf) + void fmpz_factor_ecm_clear(ecm_t ecm_inf) noexcept # Clears the ``ecm_t`` struct. - void fmpz_factor_ecm_addmod(mp_ptr a, mp_ptr b, mp_ptr c, mp_ptr n, mp_limb_t n_size) + void fmpz_factor_ecm_addmod(mp_ptr a, mp_ptr b, mp_ptr c, mp_ptr n, mp_limb_t n_size) noexcept # Sets `a` to `(b + c)` ``%`` `n`. This is not a normal add mod function, # it assumes `n` is normalized (highest bit set) and `b` and `c` are reduced # modulo `n`. # Used for arithmetic operations in ``fmpz_factor_ecm``. - void fmpz_factor_ecm_submod(mp_ptr x, mp_ptr a, mp_ptr b, mp_ptr n, mp_limb_t n_size) + void fmpz_factor_ecm_submod(mp_ptr x, mp_ptr a, mp_ptr b, mp_ptr n, mp_limb_t n_size) noexcept # Sets `x` to `(a - b)` ``%`` `n`. This is not a normal subtract mod # function, it assumes `n` is normalized (highest bit set) # and `b` and `c` are reduced modulo `n`. # Used for arithmetic operations in ``fmpz_factor_ecm``. - void fmpz_factor_ecm_double(mp_ptr x, mp_ptr z, mp_ptr x0, mp_ptr z0, mp_ptr n, ecm_t ecm_inf) + void fmpz_factor_ecm_double(mp_ptr x, mp_ptr z, mp_ptr x0, mp_ptr z0, mp_ptr n, ecm_t ecm_inf) noexcept # Sets the point `(x : z)` to two times `(x_0 : z_0)` modulo `n` according # to the formula # .. math :: @@ -163,7 +163,7 @@ cdef extern from "flint_wrap.h": # structure. This group doubling is valid only for points expressed in # Montgomery projective coordinates. - void fmpz_factor_ecm_add(mp_ptr x, mp_ptr z, mp_ptr x1, mp_ptr z1, mp_ptr x2, mp_ptr z2, mp_ptr x0, mp_ptr z0, mp_ptr n, ecm_t ecm_inf) + void fmpz_factor_ecm_add(mp_ptr x, mp_ptr z, mp_ptr x1, mp_ptr z1, mp_ptr x2, mp_ptr z2, mp_ptr x0, mp_ptr z0, mp_ptr n, ecm_t ecm_inf) noexcept # Sets the point `(x : z)` to the sum of `(x_1 : z_1)` and `(x_2 : z_2)` # modulo `n`, given the difference `(x_0 : z_0)` according to the formula # .. math :: @@ -172,14 +172,14 @@ cdef extern from "flint_wrap.h": # structure. This group addition is valid only for points expressed in # Montgomery projective coordinates. - void fmpz_factor_ecm_mul_montgomery_ladder(mp_ptr x, mp_ptr z, mp_ptr x0, mp_ptr z0, mp_limb_t k, mp_ptr n, ecm_t ecm_inf) + void fmpz_factor_ecm_mul_montgomery_ladder(mp_ptr x, mp_ptr z, mp_ptr x0, mp_ptr z0, mp_limb_t k, mp_ptr n, ecm_t ecm_inf) noexcept # Montgomery ladder algorithm for scalar multiplication of elliptic points. # Sets the point `(x : z)` to `k(x_0 : z_0)` modulo `n`. # ``ecm_inf`` is used just to use temporary ``mp_ptr``'s in the # structure. Valid only for points expressed in Montgomery projective # coordinates. - int fmpz_factor_ecm_select_curve(mp_ptr f, mp_ptr sigma, mp_ptr n, ecm_t ecm_inf) + int fmpz_factor_ecm_select_curve(mp_ptr f, mp_ptr sigma, mp_ptr n, ecm_t ecm_inf) noexcept # Selects a random elliptic curve given a random integer ``sigma``, # according to Suyama's parameterization. If the factor is found while # selecting the curve, the number of limbs required to store the factor @@ -192,7 +192,7 @@ cdef extern from "flint_wrap.h": # The curve selected is of Montgomery form, the points selected satisfy the # curve and are projective coordinates. - int fmpz_factor_ecm_stage_I(mp_ptr f, const mp_limb_t *prime_array, mp_limb_t num, mp_limb_t B1, mp_ptr n, ecm_t ecm_inf) + int fmpz_factor_ecm_stage_I(mp_ptr f, const mp_limb_t *prime_array, mp_limb_t num, mp_limb_t B1, mp_ptr n, ecm_t ecm_inf) noexcept # Stage I implementation of the ECM algorithm. # ``f`` is set as the factor if found. ``num`` is number of prime numbers # `\le` the bound ``B1``. ``prime_array`` is an array of first ``B1`` @@ -200,7 +200,7 @@ cdef extern from "flint_wrap.h": # If the factor is found, number of words required to store the factor is # returned, otherwise `0`. - int fmpz_factor_ecm_stage_II(mp_ptr f, mp_limb_t B1, mp_limb_t B2, mp_limb_t P, mp_ptr n, ecm_t ecm_inf) + int fmpz_factor_ecm_stage_II(mp_ptr f, mp_limb_t B1, mp_limb_t B2, mp_limb_t P, mp_ptr n, ecm_t ecm_inf) noexcept # Stage II implementation of the ECM algorithm. # ``f`` is set as the factor if found. ``B1``, ``B2`` are the two # bounds. ``P`` is the primorial (approximately equal to `\sqrt{B2}`). @@ -208,7 +208,7 @@ cdef extern from "flint_wrap.h": # If the factor is found, number of words required to store the factor is # returned, otherwise `0`. - int fmpz_factor_ecm(fmpz_t f, mp_limb_t curves, mp_limb_t B1, mp_limb_t B2, flint_rand_t state, const fmpz_t n_in) + int fmpz_factor_ecm(fmpz_t f, mp_limb_t curves, mp_limb_t B1, mp_limb_t B2, flint_rand_t state, const fmpz_t n_in) noexcept # Outer wrapper function for the ECM algorithm. In case ``f`` can fit # in a single unsigned word, a call to ``n_factor_ecm`` is made. # The function calls stage I and II, and diff --git a/src/sage/libs/flint/fmpz_lll.pxd b/src/sage/libs/flint/fmpz_lll.pxd index 6e46a35a9cd..71b55a38ed8 100644 --- a/src/sage/libs/flint/fmpz_lll.pxd +++ b/src/sage/libs/flint/fmpz_lll.pxd @@ -12,11 +12,11 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void fmpz_lll_context_init_default(fmpz_lll_t fl) + void fmpz_lll_context_init_default(fmpz_lll_t fl) noexcept # Sets ``fl->delta``, ``fl->eta``, ``fl->rt`` and ``fl->gt`` to # their default values, 0.99, 0.51, `Z\_BASIS` and `APPROX` respectively. - void fmpz_lll_context_init(fmpz_lll_t fl, double delta, double eta, rep_type rt, gram_type gt) + void fmpz_lll_context_init(fmpz_lll_t fl, double delta, double eta, rep_type rt, gram_type gt) noexcept # Sets ``fl->delta``, ``fl->eta``, ``fl->rt`` and ``fl->gt`` to # ``delta``, ``eta``, ``rt`` and ``gt`` (given as input) # respectively. ``delta`` and ``eta`` are the L^2 parameters. @@ -27,13 +27,13 @@ cdef extern from "flint_wrap.h": # be specified using ``gt`` which can assume the values `APPROX` and # `EXACT`. Note that ``gt`` has meaning only when ``rt`` is `Z\_BASIS`. - void fmpz_lll_randtest(fmpz_lll_t fl, flint_rand_t state) + void fmpz_lll_randtest(fmpz_lll_t fl, flint_rand_t state) noexcept # Sets ``fl->delta`` and ``fl->eta`` to random values in the interval # `(0.25, 1)` and `(0.5, \sqrt{\mathtt{delta}})` respectively. ``fl->rt`` is # set to `GRAM` or `Z\_BASIS` and ``fl->gt`` is set to `APPROX` or `EXACT` # in a pseudo random way. - double fmpz_lll_heuristic_dot(const double * vec1, const double * vec2, slong len2, const fmpz_mat_t B, slong k, slong j, slong exp_adj) + double fmpz_lll_heuristic_dot(const double * vec1, const double * vec2, slong len2, const fmpz_mat_t B, slong k, slong j, slong exp_adj) noexcept # Computes the dot product of two vectors of doubles ``vec1`` and # ``vec2``, which are respectively ``double`` approximations (up to # scaling by a power of 2) to rows ``k`` and ``j`` in the exact integer @@ -46,7 +46,7 @@ cdef extern from "flint_wrap.h": # The final dot product computed by this function is then notionally the # return value times `2^{\mathtt{exp_adj}}`. - int fmpz_lll_check_babai(int kappa, fmpz_mat_t B, fmpz_mat_t U, d_mat_t mu, d_mat_t r, double *s, d_mat_t appB, int *expo, fmpz_gram_t A, int a, int zeros, int kappamax, int n, const fmpz_lll_t fl) + int fmpz_lll_check_babai(int kappa, fmpz_mat_t B, fmpz_mat_t U, d_mat_t mu, d_mat_t r, double *s, d_mat_t appB, int *expo, fmpz_gram_t A, int a, int zeros, int kappamax, int n, const fmpz_lll_t fl) noexcept # Performs floating point size reductions of the ``kappa``-th row of # ``B`` by all of the previous rows, uses d_mats ``mu`` and ``r`` # for storing the GSO data. ``U`` is used to capture the unimodular @@ -66,33 +66,33 @@ cdef extern from "flint_wrap.h": # (usually due to insufficient precision) or 0 if everything was successful. # These descriptions will be true for the future Babai procedures as well. - int fmpz_lll_check_babai_heuristic_d(int kappa, fmpz_mat_t B, fmpz_mat_t U, d_mat_t mu, d_mat_t r, double *s, d_mat_t appB, int *expo, fmpz_gram_t A, int a, int zeros, int kappamax, int n, const fmpz_lll_t fl) + int fmpz_lll_check_babai_heuristic_d(int kappa, fmpz_mat_t B, fmpz_mat_t U, d_mat_t mu, d_mat_t r, double *s, d_mat_t appB, int *expo, fmpz_gram_t A, int a, int zeros, int kappamax, int n, const fmpz_lll_t fl) noexcept # Same as :func:`fmpz_lll_check_babai` but using the heuristic inner product # rather than a purely floating point inner product. The heuristic will # compute at full precision when there is cancellation. - int fmpz_lll_check_babai_heuristic(int kappa, fmpz_mat_t B, fmpz_mat_t U, mpf_mat_t mu, mpf_mat_t r, mpf *s, mpf_mat_t appB, fmpz_gram_t A, int a, int zeros, int kappamax, int n, mpf_t tmp, mpf_t rtmp, flint_bitcnt_t prec, const fmpz_lll_t fl) + int fmpz_lll_check_babai_heuristic(int kappa, fmpz_mat_t B, fmpz_mat_t U, mpf_mat_t mu, mpf_mat_t r, mpf *s, mpf_mat_t appB, fmpz_gram_t A, int a, int zeros, int kappamax, int n, mpf_t tmp, mpf_t rtmp, flint_bitcnt_t prec, const fmpz_lll_t fl) noexcept # This function is like the ``mpf`` version of # :func:`fmpz_lll_check_babai_heuristic_d`. However, it also inherits some # temporary ``mpf_t`` variables ``tmp`` and ``rtmp``. - int fmpz_lll_advance_check_babai(int cur_kappa, int kappa, fmpz_mat_t B, fmpz_mat_t U, d_mat_t mu, d_mat_t r, double *s, d_mat_t appB, int *expo, fmpz_gram_t A, int a, int zeros, int kappamax, int n, const fmpz_lll_t fl) + int fmpz_lll_advance_check_babai(int cur_kappa, int kappa, fmpz_mat_t B, fmpz_mat_t U, d_mat_t mu, d_mat_t r, double *s, d_mat_t appB, int *expo, fmpz_gram_t A, int a, int zeros, int kappamax, int n, const fmpz_lll_t fl) noexcept # This is a Babai procedure which is used when size reducing a vector beyond # an index which LLL has reached. ``cur_kappa`` is the index behind which # we can assume ``B`` is LLL reduced, while ``kappa`` is the vector to # be reduced. This procedure only size reduces the ``kappa``-th row by # vectors up to ``cur_kappa``, **not** ``kappa - 1``. - int fmpz_lll_advance_check_babai_heuristic_d(int cur_kappa, int kappa, fmpz_mat_t B, fmpz_mat_t U, d_mat_t mu, d_mat_t r, double *s, d_mat_t appB, int *expo, fmpz_gram_t A, int a, int zeros, int kappamax, int n, const fmpz_lll_t fl) + int fmpz_lll_advance_check_babai_heuristic_d(int cur_kappa, int kappa, fmpz_mat_t B, fmpz_mat_t U, d_mat_t mu, d_mat_t r, double *s, d_mat_t appB, int *expo, fmpz_gram_t A, int a, int zeros, int kappamax, int n, const fmpz_lll_t fl) noexcept # Same as :func:`fmpz_lll_advance_check_babai` but using the heuristic inner # product rather than a purely floating point inner product. The heuristic # will compute at full precision when there is cancellation. - int fmpz_lll_shift(const fmpz_mat_t B) + int fmpz_lll_shift(const fmpz_mat_t B) noexcept # Computes the largest number of non-zero entries after the diagonal in # ``B``. - int fmpz_lll_d(fmpz_mat_t B, fmpz_mat_t U, const fmpz_lll_t fl) + int fmpz_lll_d(fmpz_mat_t B, fmpz_mat_t U, const fmpz_lll_t fl) noexcept # This is a mildly greedy version of floating point LLL using doubles only. # It tries the fast version of the Babai algorithm # (:func:`fmpz_lll_check_babai`). If that fails, then it switches to the @@ -108,18 +108,18 @@ cdef extern from "flint_wrap.h": # used in computation (approximate or exact) can also be specified through # the variable ``fl->gt`` (applies only if ``fl->rt`` == `Z\_BASIS`). - int fmpz_lll_d_heuristic(fmpz_mat_t B, fmpz_mat_t U, const fmpz_lll_t fl) + int fmpz_lll_d_heuristic(fmpz_mat_t B, fmpz_mat_t U, const fmpz_lll_t fl) noexcept # This LLL reduces ``B`` in place using doubles only. It is similar to # :func:`fmpz_lll_d` but only uses the heuristic inner products which # attempt to detect cancellations. - int fmpz_lll_mpf2(fmpz_mat_t B, fmpz_mat_t U, flint_bitcnt_t prec, const fmpz_lll_t fl) + int fmpz_lll_mpf2(fmpz_mat_t B, fmpz_mat_t U, flint_bitcnt_t prec, const fmpz_lll_t fl) noexcept # This is LLL using ``mpf`` with the given precision, ``prec`` for the # underlying GSO. It reduces ``B`` in place like the other LLL functions. # The `mpf2` in the function name refers to the way the ``mpf_t``'s are # initialised. - int fmpz_lll_mpf(fmpz_mat_t B, fmpz_mat_t U, const fmpz_lll_t fl) + int fmpz_lll_mpf(fmpz_mat_t B, fmpz_mat_t U, const fmpz_lll_t fl) noexcept # A wrapper of :func:`fmpz_lll_mpf2`. This currently begins with # `prec == D\_BITS`, then for the first 20 loops, increases the precision one # limb at a time. After 20 loops, it doubles the precision each time. There @@ -127,7 +127,7 @@ cdef extern from "flint_wrap.h": # function is 0 if the LLL is successful or -1 if the precision maxes out # before ``B`` is LLL-reduced. - int fmpz_lll_wrapper(fmpz_mat_t B, fmpz_mat_t U, const fmpz_lll_t fl) + int fmpz_lll_wrapper(fmpz_mat_t B, fmpz_mat_t U, const fmpz_lll_t fl) noexcept # A wrapper of the above procedures. It begins with the greediest version # (:func:`fmpz_lll_d`), then adapts to the version using heuristic inner # products only (:func:`fmpz_lll_d_heuristic`) if ``fl->rt`` == `Z\_BASIS` and @@ -143,20 +143,20 @@ cdef extern from "flint_wrap.h": # used in computation (approximate or exact) can also be specified through # the variable ``fl->gt`` (applies only if ``fl->rt`` == `Z\_BASIS`). - int fmpz_lll_d_with_removal(fmpz_mat_t B, fmpz_mat_t U, const fmpz_t gs_B, const fmpz_lll_t fl) + int fmpz_lll_d_with_removal(fmpz_mat_t B, fmpz_mat_t U, const fmpz_t gs_B, const fmpz_lll_t fl) noexcept # Same as :func:`fmpz_lll_d` but with a removal bound, ``gs_B``. The # return value is the new dimension of ``B`` if removals are desired. - int fmpz_lll_d_heuristic_with_removal(fmpz_mat_t B, fmpz_mat_t U, const fmpz_t gs_B, const fmpz_lll_t fl) + int fmpz_lll_d_heuristic_with_removal(fmpz_mat_t B, fmpz_mat_t U, const fmpz_t gs_B, const fmpz_lll_t fl) noexcept # Same as :func:`fmpz_lll_d_heuristic` but with a removal bound, # ``gs_B``. The return value is the new dimension of ``B`` if removals # are desired. - int fmpz_lll_mpf2_with_removal(fmpz_mat_t B, fmpz_mat_t U, flint_bitcnt_t prec, const fmpz_t gs_B, const fmpz_lll_t fl) + int fmpz_lll_mpf2_with_removal(fmpz_mat_t B, fmpz_mat_t U, flint_bitcnt_t prec, const fmpz_t gs_B, const fmpz_lll_t fl) noexcept # Same as :func:`fmpz_lll_mpf2` but with a removal bound, ``gs_B``. The # return value is the new dimension of ``B`` if removals are desired. - int fmpz_lll_mpf_with_removal(fmpz_mat_t B, fmpz_mat_t U, const fmpz_t gs_B, const fmpz_lll_t fl) + int fmpz_lll_mpf_with_removal(fmpz_mat_t B, fmpz_mat_t U, const fmpz_t gs_B, const fmpz_lll_t fl) noexcept # A wrapper of :func:`fmpz_lll_mpf2_with_removal`. This currently begins # with `prec == D\_BITS`, then for the first 20 loops, increases the precision # one limb at a time. After 20 loops, it doubles the precision each time. @@ -164,7 +164,7 @@ cdef extern from "flint_wrap.h": # function is the new dimension of ``B`` if removals are desired or -1 if # the precision maxes out before ``B`` is LLL-reduced. - int fmpz_lll_wrapper_with_removal(fmpz_mat_t B, fmpz_mat_t U, const fmpz_t gs_B, const fmpz_lll_t fl) + int fmpz_lll_wrapper_with_removal(fmpz_mat_t B, fmpz_mat_t U, const fmpz_t gs_B, const fmpz_lll_t fl) noexcept # A wrapper of the procedures implementing the base case LLL with the # addition of the removal boundary. It begins with the greediest version # (:func:`fmpz_lll_d_with_removal`), then adapts to the version using @@ -172,13 +172,13 @@ cdef extern from "flint_wrap.h": # if ``fl->rt`` == `Z\_BASIS` and ``fl->gt`` == `APPROX`, and finally to the mpf # version (:func:`fmpz_lll_mpf_with_removal`) if needed. - int fmpz_lll_d_with_removal_knapsack(fmpz_mat_t B, fmpz_mat_t U, const fmpz_t gs_B, const fmpz_lll_t fl) + int fmpz_lll_d_with_removal_knapsack(fmpz_mat_t B, fmpz_mat_t U, const fmpz_t gs_B, const fmpz_lll_t fl) noexcept # This is floating point LLL specialized to knapsack-type lattices. It # performs early size reductions occasionally which makes things faster in # the knapsack case. Otherwise, it is similar to # ``fmpz_lll_d_with_removal``. - int fmpz_lll_wrapper_with_removal_knapsack(fmpz_mat_t B, fmpz_mat_t U, const fmpz_t gs_B, const fmpz_lll_t fl) + int fmpz_lll_wrapper_with_removal_knapsack(fmpz_mat_t B, fmpz_mat_t U, const fmpz_t gs_B, const fmpz_lll_t fl) noexcept # A wrapper of the procedures implementing the LLL specialized to # knapsack-type lattices. It begins with the greediest version and the engine # of this version, (:func:`fmpz_lll_d_with_removal_knapsack`), then adapts @@ -187,7 +187,7 @@ cdef extern from "flint_wrap.h": # ``fl->gt`` == `APPROX`, and finally to the mpf version # (:func:`fmpz_lll_mpf_with_removal`) if needed. - int fmpz_lll_with_removal_ulll(fmpz_mat_t FM, fmpz_mat_t UM, slong new_size, const fmpz_t gs_B, const fmpz_lll_t fl) + int fmpz_lll_with_removal_ulll(fmpz_mat_t FM, fmpz_mat_t UM, slong new_size, const fmpz_t gs_B, const fmpz_lll_t fl) noexcept # ULLL is a new style of LLL which adjoins an identity matrix to the # input lattice ``FM``, then scales the lattice down to ``new_size`` # bits and reduces this augmented lattice. This tends to be more stable @@ -197,27 +197,27 @@ cdef extern from "flint_wrap.h": # transformations, while ``gs_B`` and ``fl`` have the same role as in # the previous routines. The function is optimised for factoring polynomials. - bint fmpz_lll_is_reduced_d(const fmpz_mat_t B, const fmpz_lll_t fl) - bint fmpz_lll_is_reduced_mpfr(const fmpz_mat_t B, const fmpz_lll_t fl, flint_bitcnt_t prec) - bint fmpz_lll_is_reduced_d_with_removal(const fmpz_mat_t B, const fmpz_lll_t fl, const fmpz_t gs_B, int newd) - bint fmpz_lll_is_reduced_mpfr_with_removal(const fmpz_mat_t B, const fmpz_lll_t fl, const fmpz_t gs_B, int newd, flint_bitcnt_t prec) + bint fmpz_lll_is_reduced_d(const fmpz_mat_t B, const fmpz_lll_t fl) noexcept + bint fmpz_lll_is_reduced_mpfr(const fmpz_mat_t B, const fmpz_lll_t fl, flint_bitcnt_t prec) noexcept + bint fmpz_lll_is_reduced_d_with_removal(const fmpz_mat_t B, const fmpz_lll_t fl, const fmpz_t gs_B, int newd) noexcept + bint fmpz_lll_is_reduced_mpfr_with_removal(const fmpz_mat_t B, const fmpz_lll_t fl, const fmpz_t gs_B, int newd, flint_bitcnt_t prec) noexcept # A non-zero return indicates the matrix is definitely reduced, that is, that # * :func:`fmpz_mat_is_reduced` or :func:`fmpz_mat_is_reduced_gram` (for the first two) # * :func:`fmpz_mat_is_reduced_with_removal` or :func:`fmpz_mat_is_reduced_gram_with_removal` (for the last two) # return non-zero. A zero return value is inconclusive. # The `_d` variants are performed in machine precision, while the `_mpfr` uses a precision of `prec` bits. - bint fmpz_lll_is_reduced(const fmpz_mat_t B, const fmpz_lll_t fl, flint_bitcnt_t prec) - bint fmpz_lll_is_reduced_with_removal(const fmpz_mat_t B, const fmpz_lll_t fl, const fmpz_t gs_B, int newd, flint_bitcnt_t prec) + bint fmpz_lll_is_reduced(const fmpz_mat_t B, const fmpz_lll_t fl, flint_bitcnt_t prec) noexcept + bint fmpz_lll_is_reduced_with_removal(const fmpz_mat_t B, const fmpz_lll_t fl, const fmpz_t gs_B, int newd, flint_bitcnt_t prec) noexcept # The return from these functions is always conclusive: the functions # * :func:`fmpz_mat_is_reduced` or :func:`fmpz_mat_is_reduced_gram` # * :func:`fmpz_mat_is_reduced_with_removal` or :func:`fmpz_mat_is_reduced_gram_with_removal` # are optimzied by calling the above heuristics first and returning right away if they give a conclusive answer. - void fmpz_lll_storjohann_ulll(fmpz_mat_t FM, slong new_size, const fmpz_lll_t fl) + void fmpz_lll_storjohann_ulll(fmpz_mat_t FM, slong new_size, const fmpz_lll_t fl) noexcept # Performs ULLL using :func:`fmpz_mat_lll_storjohann` as the LLL function. - void fmpz_lll(fmpz_mat_t B, fmpz_mat_t U, const fmpz_lll_t fl) + void fmpz_lll(fmpz_mat_t B, fmpz_mat_t U, const fmpz_lll_t fl) noexcept # Reduces ``B`` in place according to the parameters specified by the # LLL context object ``fl``. # This is the main LLL function which should be called by the user. It @@ -236,7 +236,7 @@ cdef extern from "flint_wrap.h": # used in computation (approximate or exact) can also be specified through # the variable ``fl->gt`` (applies only if ``fl->rt`` == `Z\_BASIS`). - int fmpz_lll_with_removal(fmpz_mat_t B, fmpz_mat_t U, const fmpz_t gs_B, const fmpz_lll_t fl) + int fmpz_lll_with_removal(fmpz_mat_t B, fmpz_mat_t U, const fmpz_t gs_B, const fmpz_lll_t fl) noexcept # Reduces ``B`` in place according to the parameters specified by the # LLL context object ``fl`` and removes vectors whose squared Gram-Schmidt # length is greater than the bound ``gs_B``. The return value is the new diff --git a/src/sage/libs/flint/fmpz_mat.pxd b/src/sage/libs/flint/fmpz_mat.pxd index 5641d01e5f3..7ac2e3ae909 100644 --- a/src/sage/libs/flint/fmpz_mat.pxd +++ b/src/sage/libs/flint/fmpz_mat.pxd @@ -12,86 +12,86 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void fmpz_mat_init(fmpz_mat_t mat, slong rows, slong cols) + void fmpz_mat_init(fmpz_mat_t mat, slong rows, slong cols) noexcept # Initialises a matrix with the given number of rows and columns for use. - void fmpz_mat_clear(fmpz_mat_t mat) + void fmpz_mat_clear(fmpz_mat_t mat) noexcept # Clears the given matrix. - void fmpz_mat_set(fmpz_mat_t mat1, const fmpz_mat_t mat2) + void fmpz_mat_set(fmpz_mat_t mat1, const fmpz_mat_t mat2) noexcept # Sets ``mat1`` to a copy of ``mat2``. The dimensions of # ``mat1`` and ``mat2`` must be the same. - void fmpz_mat_init_set(fmpz_mat_t mat, const fmpz_mat_t src) + void fmpz_mat_init_set(fmpz_mat_t mat, const fmpz_mat_t src) noexcept # Initialises the matrix ``mat`` to the same size as ``src`` and # sets it to a copy of ``src``. - slong fmpz_mat_nrows(const fmpz_mat_t mat) - slong fmpz_mat_ncols(const fmpz_mat_t mat) + slong fmpz_mat_nrows(const fmpz_mat_t mat) noexcept + slong fmpz_mat_ncols(const fmpz_mat_t mat) noexcept # Returns respectively the number of rows and columns of the matrix. - void fmpz_mat_swap(fmpz_mat_t mat1, fmpz_mat_t mat2) + void fmpz_mat_swap(fmpz_mat_t mat1, fmpz_mat_t mat2) noexcept # Swaps two matrices. The dimensions of ``mat1`` and ``mat2`` # are allowed to be different. - void fmpz_mat_swap_entrywise(fmpz_mat_t mat1, fmpz_mat_t mat2) + void fmpz_mat_swap_entrywise(fmpz_mat_t mat1, fmpz_mat_t mat2) noexcept # Swaps two matrices by swapping the individual entries rather than swapping # the contents of the structs. - fmpz * fmpz_mat_entry(const fmpz_mat_t mat, slong i, slong j) + fmpz * fmpz_mat_entry(const fmpz_mat_t mat, slong i, slong j) noexcept # Returns a reference to the entry of ``mat`` at row `i` and column `j`. # This reference can be passed as an input or output variable to any # function in the ``fmpz`` module for direct manipulation. # Both `i` and `j` must not exceed the dimensions of the matrix. # This function is implemented as a macro. - void fmpz_mat_zero(fmpz_mat_t mat) + void fmpz_mat_zero(fmpz_mat_t mat) noexcept # Sets all entries of ``mat`` to 0. - void fmpz_mat_one(fmpz_mat_t mat) + void fmpz_mat_one(fmpz_mat_t mat) noexcept # Sets ``mat`` to the unit matrix, having ones on the main diagonal # and zeroes elsewhere. If ``mat`` is nonsquare, it is set to the # truncation of a unit matrix. - void fmpz_mat_swap_rows(fmpz_mat_t mat, slong * perm, slong r, slong s) + void fmpz_mat_swap_rows(fmpz_mat_t mat, slong * perm, slong r, slong s) noexcept # Swaps rows ``r`` and ``s`` of ``mat``. If ``perm`` is non-``NULL``, the # permutation of the rows will also be applied to ``perm``. - void fmpz_mat_swap_cols(fmpz_mat_t mat, slong * perm, slong r, slong s) + void fmpz_mat_swap_cols(fmpz_mat_t mat, slong * perm, slong r, slong s) noexcept # Swaps columns ``r`` and ``s`` of ``mat``. If ``perm`` is non-``NULL``, the # permutation of the columns will also be applied to ``perm``. - void fmpz_mat_invert_rows(fmpz_mat_t mat, slong * perm) + void fmpz_mat_invert_rows(fmpz_mat_t mat, slong * perm) noexcept # Swaps rows ``i`` and ``r - i`` of ``mat`` for ``0 <= i < r/2``, where # ``r`` is the number of rows of ``mat``. If ``perm`` is non-``NULL``, the # permutation of the rows will also be applied to ``perm``. - void fmpz_mat_invert_cols(fmpz_mat_t mat, slong * perm) + void fmpz_mat_invert_cols(fmpz_mat_t mat, slong * perm) noexcept # Swaps columns ``i`` and ``c - i`` of ``mat`` for ``0 <= i < c/2``, where # ``c`` is the number of columns of ``mat``. If ``perm`` is non-``NULL``, the # permutation of the columns will also be applied to ``perm``. - void fmpz_mat_window_init(fmpz_mat_t window, const fmpz_mat_t mat, slong r1, slong c1, slong r2, slong c2) + void fmpz_mat_window_init(fmpz_mat_t window, const fmpz_mat_t mat, slong r1, slong c1, slong r2, slong c2) noexcept # Initializes the matrix ``window`` to be an ``r2 - r1`` by # ``c2 - c1`` submatrix of ``mat`` whose ``(0,0)`` entry # is the ``(r1, c1)`` entry of ``mat``. The memory for the # elements of ``window`` is shared with ``mat``. - void fmpz_mat_window_clear(fmpz_mat_t window) + void fmpz_mat_window_clear(fmpz_mat_t window) noexcept # Clears the matrix ``window`` and releases any memory that it # uses. Note that the memory to the underlying matrix that # ``window`` points to is not freed. - void fmpz_mat_randbits(fmpz_mat_t mat, flint_rand_t state, flint_bitcnt_t bits) + void fmpz_mat_randbits(fmpz_mat_t mat, flint_rand_t state, flint_bitcnt_t bits) noexcept # Sets the entries of ``mat`` to random signed integers whose absolute # values have the given number of binary bits. - void fmpz_mat_randtest(fmpz_mat_t mat, flint_rand_t state, flint_bitcnt_t bits) + void fmpz_mat_randtest(fmpz_mat_t mat, flint_rand_t state, flint_bitcnt_t bits) noexcept # Sets the entries of ``mat`` to random signed integers whose # absolute values have a random number of bits up to the given number # of bits inclusive. - void fmpz_mat_randintrel(fmpz_mat_t mat, flint_rand_t state, flint_bitcnt_t bits) + void fmpz_mat_randintrel(fmpz_mat_t mat, flint_rand_t state, flint_bitcnt_t bits) noexcept # Sets ``mat`` to be a random *integer relations* matrix, with # signed entries up to the given number of bits. # The number of columns of ``mat`` must be equal to one more than @@ -99,7 +99,7 @@ cdef extern from "flint_wrap.h": # in the left hand column and an identity matrix in the remaining square # submatrix. - void fmpz_mat_randsimdioph(fmpz_mat_t mat, flint_rand_t state, flint_bitcnt_t bits, flint_bitcnt_t bits2) + void fmpz_mat_randsimdioph(fmpz_mat_t mat, flint_rand_t state, flint_bitcnt_t bits, flint_bitcnt_t bits2) noexcept # Sets ``mat`` to a random *simultaneous diophantine* matrix. # The matrix must be square. The top left entry is set to ``2^bits2``. # The remainder of that row is then set to signed random integers of the @@ -107,7 +107,7 @@ cdef extern from "flint_wrap.h": # Running down the rest of the diagonal are the values ``2^bits`` with # all remaining entries zero. - void fmpz_mat_randntrulike(fmpz_mat_t mat, flint_rand_t state, flint_bitcnt_t bits, ulong q) + void fmpz_mat_randntrulike(fmpz_mat_t mat, flint_rand_t state, flint_bitcnt_t bits, ulong q) noexcept # Sets a square matrix ``mat`` of even dimension to a random # *NTRU like* matrix. # The matrix is broken into four square submatrices. The top left submatrix @@ -118,7 +118,7 @@ cdef extern from "flint_wrap.h": # number of bits. Then entry `(i, j)` of the submatrix is set to # `h[i + j \bmod{r/2}]`. - void fmpz_mat_randntrulike2(fmpz_mat_t mat, flint_rand_t state, flint_bitcnt_t bits, ulong q) + void fmpz_mat_randntrulike2(fmpz_mat_t mat, flint_rand_t state, flint_bitcnt_t bits, ulong q) noexcept # Sets a square matrix ``mat`` of even dimension to a random # *NTRU like* matrix. # The matrix is broken into four square submatrices. The top left submatrix @@ -129,7 +129,7 @@ cdef extern from "flint_wrap.h": # number of bits. Then entry `(i, j)` of the submatrix is set to # `h[i + j \bmod{r/2}]`. - void fmpz_mat_randajtai(fmpz_mat_t mat, flint_rand_t state, double alpha) + void fmpz_mat_randajtai(fmpz_mat_t mat, flint_rand_t state, double alpha) noexcept # Sets a square matrix ``mat`` to a random *ajtai* matrix. # The diagonal entries `(i, i)` are set to a random entry in the range # `[1, 2^{b-1}]` inclusive where `b = \lfloor(2 r - i)^\alpha\rfloor` for some @@ -137,21 +137,21 @@ cdef extern from "flint_wrap.h": # are set to a random entry in the range `(-2^b + 1, 2^b - 1)` whilst the # entries to the right of the diagonal in row `i` are set to zero. - int fmpz_mat_randpermdiag(fmpz_mat_t mat, flint_rand_t state, const fmpz * diag, slong n) + int fmpz_mat_randpermdiag(fmpz_mat_t mat, flint_rand_t state, const fmpz * diag, slong n) noexcept # Sets ``mat`` to a random permutation of the rows and columns of a # given diagonal matrix. The diagonal matrix is specified in the form of # an array of the `n` initial entries on the main diagonal. # The return value is `0` or `1` depending on whether the permutation is # even or odd. - void fmpz_mat_randrank(fmpz_mat_t mat, flint_rand_t state, slong rank, flint_bitcnt_t bits) + void fmpz_mat_randrank(fmpz_mat_t mat, flint_rand_t state, slong rank, flint_bitcnt_t bits) noexcept # Sets ``mat`` to a random sparse matrix with the given rank, # having exactly as many non-zero elements as the rank, with the # nonzero elements being random integers of the given bit size. # The matrix can be transformed into a dense matrix with unchanged # rank by subsequently calling :func:`fmpz_mat_randops`. - void fmpz_mat_randdet(fmpz_mat_t mat, flint_rand_t state, const fmpz_t det) + void fmpz_mat_randdet(fmpz_mat_t mat, flint_rand_t state, const fmpz_t det) noexcept # Sets ``mat`` to a random sparse matrix with minimal number of # nonzero entries such that its determinant has the given value. # Note that the matrix will be zero if ``det`` is zero. @@ -160,20 +160,20 @@ cdef extern from "flint_wrap.h": # The matrix can be transformed into a dense matrix with unchanged # determinant by subsequently calling :func:`fmpz_mat_randops`. - void fmpz_mat_randops(fmpz_mat_t mat, flint_rand_t state, slong count) + void fmpz_mat_randops(fmpz_mat_t mat, flint_rand_t state, slong count) noexcept # Randomises ``mat`` by performing elementary row or column operations. # More precisely, at most ``count`` random additions or subtractions of # distinct rows and columns will be performed. This leaves the rank # (and for square matrices, the determinant) unchanged. - int fmpz_mat_fprint(FILE * file, const fmpz_mat_t mat) + int fmpz_mat_fprint(FILE * file, const fmpz_mat_t mat) noexcept # Prints the given matrix to the stream ``file``. The format is # the number of rows, a space, the number of columns, two spaces, then # a space separated list of coefficients, one row after the other. # In case of success, returns a positive value; otherwise, returns # a non-positive value. - int fmpz_mat_fprint_pretty(FILE * file, const fmpz_mat_t mat) + int fmpz_mat_fprint_pretty(FILE * file, const fmpz_mat_t mat) noexcept # Prints the given matrix to the stream ``file``. The format is an # opening square bracket, then on each line a row of the matrix, followed # by a closing square bracket. Each row is written as an opening square @@ -182,15 +182,15 @@ cdef extern from "flint_wrap.h": # In case of success, returns a positive value; otherwise, returns # a non-positive value. - int fmpz_mat_print(const fmpz_mat_t mat) + int fmpz_mat_print(const fmpz_mat_t mat) noexcept # Prints the given matrix to the stream ``stdout``. For further # details, see :func:`fmpz_mat_fprint`. - int fmpz_mat_print_pretty(const fmpz_mat_t mat) + int fmpz_mat_print_pretty(const fmpz_mat_t mat) noexcept # Prints the given matrix to ``stdout``. For further details, # see :func:`fmpz_mat_fprint_pretty`. - int fmpz_mat_fread(FILE* file, fmpz_mat_t mat) + int fmpz_mat_fread(FILE* file, fmpz_mat_t mat) noexcept # Reads a matrix from the stream ``file``, storing the result # in ``mat``. The expected format is the number of rows, a # space, the number of columns, two spaces, then a space separated @@ -198,167 +198,167 @@ cdef extern from "flint_wrap.h": # In case of success, returns a positive number. In case of failure, # returns a non-positive value. - int fmpz_mat_read(fmpz_mat_t mat) + int fmpz_mat_read(fmpz_mat_t mat) noexcept # Reads a matrix from ``stdin``, storing the result # in ``mat``. # In case of success, returns a positive number. In case of failure, # returns a non-positive value. - bint fmpz_mat_equal(const fmpz_mat_t mat1, const fmpz_mat_t mat2) + bint fmpz_mat_equal(const fmpz_mat_t mat1, const fmpz_mat_t mat2) noexcept # Returns a non-zero value if ``mat1`` and ``mat2`` have # the same dimensions and entries, and zero otherwise. - bint fmpz_mat_is_zero(const fmpz_mat_t mat) + bint fmpz_mat_is_zero(const fmpz_mat_t mat) noexcept # Returns a non-zero value if all entries ``mat`` are zero, and # otherwise returns zero. - bint fmpz_mat_is_one(const fmpz_mat_t mat) + bint fmpz_mat_is_one(const fmpz_mat_t mat) noexcept # Returns a non-zero value if ``mat`` is the unit matrix or the truncation # of a unit matrix, and otherwise returns zero. - bint fmpz_mat_is_empty(const fmpz_mat_t mat) + bint fmpz_mat_is_empty(const fmpz_mat_t mat) noexcept # Returns a non-zero value if the number of rows or the number of # columns in ``mat`` is zero, and otherwise returns # zero. - bint fmpz_mat_is_square(const fmpz_mat_t mat) + bint fmpz_mat_is_square(const fmpz_mat_t mat) noexcept # Returns a non-zero value if the number of rows is equal to the # number of columns in ``mat``, and otherwise returns zero. - bint fmpz_mat_is_zero_row(const fmpz_mat_t mat, slong i) + bint fmpz_mat_is_zero_row(const fmpz_mat_t mat, slong i) noexcept # Returns a non-zero value if row `i` of ``mat`` is zero. - bint fmpz_mat_equal_col(fmpz_mat_t M, slong m, slong n) + bint fmpz_mat_equal_col(fmpz_mat_t M, slong m, slong n) noexcept # Returns `1` if columns `m` and `n` of the matrix `M` are equal, otherwise # returns `0`. - bint fmpz_mat_equal_row(fmpz_mat_t M, slong m, slong n) + bint fmpz_mat_equal_row(fmpz_mat_t M, slong m, slong n) noexcept # Returns `1` if rows `m` and `n` of the matrix `M` are equal, otherwise # returns `0`. - void fmpz_mat_transpose(fmpz_mat_t B, const fmpz_mat_t A) + void fmpz_mat_transpose(fmpz_mat_t B, const fmpz_mat_t A) noexcept # Sets `B` to `A^T`, the transpose of `A`. Dimensions must be compatible. # `A` and `B` are allowed to be the same object if `A` is a square matrix. - void fmpz_mat_concat_vertical(fmpz_mat_t res, const fmpz_mat_t mat1, const fmpz_mat_t mat2) + void fmpz_mat_concat_vertical(fmpz_mat_t res, const fmpz_mat_t mat1, const fmpz_mat_t mat2) noexcept # Sets ``res`` to vertical concatenation of (``mat1``, ``mat2``) # in that order. Matrix dimensions: ``mat1``: `m \times n`, # ``mat2``: `k \times n`, ``res``: `(m + k) \times n`. - void fmpz_mat_concat_horizontal(fmpz_mat_t res, const fmpz_mat_t mat1, const fmpz_mat_t mat2) + void fmpz_mat_concat_horizontal(fmpz_mat_t res, const fmpz_mat_t mat1, const fmpz_mat_t mat2) noexcept # Sets ``res`` to horizontal concatenation of (``mat1``, ``mat2``) # in that order. Matrix dimensions: ``mat1``: `m \times n`, # ``mat2``: `m \times k`, ``res``: `m \times (n + k)`. - void fmpz_mat_get_nmod_mat(nmod_mat_t Amod, const fmpz_mat_t A) + void fmpz_mat_get_nmod_mat(nmod_mat_t Amod, const fmpz_mat_t A) noexcept # Sets the entries of ``Amod`` to the entries of ``A`` reduced # by the modulus of ``Amod``. - void fmpz_mat_set_nmod_mat(fmpz_mat_t A, const nmod_mat_t Amod) + void fmpz_mat_set_nmod_mat(fmpz_mat_t A, const nmod_mat_t Amod) noexcept # Sets the entries of ``Amod`` to the residues in ``Amod``, # normalised to the interval `-m/2 <= r < m/2` where `m` is the modulus. - void fmpz_mat_set_nmod_mat_unsigned(fmpz_mat_t A, const nmod_mat_t Amod) + void fmpz_mat_set_nmod_mat_unsigned(fmpz_mat_t A, const nmod_mat_t Amod) noexcept # Sets the entries of ``Amod`` to the residues in ``Amod``, # normalised to the interval `0 <= r < m` where `m` is the modulus. - void fmpz_mat_CRT_ui(fmpz_mat_t res, const fmpz_mat_t mat1, const fmpz_t m1, const nmod_mat_t mat2, int sign) + void fmpz_mat_CRT_ui(fmpz_mat_t res, const fmpz_mat_t mat1, const fmpz_t m1, const nmod_mat_t mat2, int sign) noexcept # Given ``mat1`` with entries modulo ``m`` and ``mat2`` # with modulus `n`, sets ``res`` to the CRT reconstruction modulo `mn` # with entries satisfying `-mn/2 <= c < mn/2` (if sign = 1) # or `0 <= c < mn` (if sign = 0). - void fmpz_mat_multi_mod_ui_precomp(nmod_mat_t * residues, slong nres, const fmpz_mat_t mat, const fmpz_comb_t comb, fmpz_comb_temp_t temp) + void fmpz_mat_multi_mod_ui_precomp(nmod_mat_t * residues, slong nres, const fmpz_mat_t mat, const fmpz_comb_t comb, fmpz_comb_temp_t temp) noexcept # Sets each of the ``nres`` matrices in ``residues`` to ``mat`` reduced modulo # the modulus of the respective matrix, given precomputed ``comb`` and # ``comb_temp`` structures. # Note: ``fmpz.h`` must be included **before** ``fmpz_mat.h`` in order for # this function to be declared. - void fmpz_mat_multi_mod_ui(nmod_mat_t * residues, slong nres, const fmpz_mat_t mat) + void fmpz_mat_multi_mod_ui(nmod_mat_t * residues, slong nres, const fmpz_mat_t mat) noexcept # Sets each of the ``nres`` matrices in ``residues`` to ``mat`` # reduced modulo the modulus of the respective matrix. # This function is provided for convenience purposes. # For reducing or reconstructing multiple integer matrices over the same # set of moduli, it is faster to use ``fmpz_mat_multi_mod_precomp``. - void fmpz_mat_multi_CRT_ui_precomp(fmpz_mat_t mat, nmod_mat_t * const residues, slong nres, const fmpz_comb_t comb, fmpz_comb_temp_t temp, int sign) + void fmpz_mat_multi_CRT_ui_precomp(fmpz_mat_t mat, nmod_mat_t * const residues, slong nres, const fmpz_comb_t comb, fmpz_comb_temp_t temp, int sign) noexcept # Reconstructs ``mat`` from its images modulo the ``nres`` matrices in # ``residues``, given precomputed ``comb`` and ``comb_temp`` structures. # Note: ``fmpz.h`` must be included **before** ``fmpz_mat.h`` in order for # this function to be declared. - void fmpz_mat_multi_CRT_ui(fmpz_mat_t mat, nmod_mat_t * const residues, slong nres, int sign) + void fmpz_mat_multi_CRT_ui(fmpz_mat_t mat, nmod_mat_t * const residues, slong nres, int sign) noexcept # Reconstructs ``mat`` from its images modulo the ``nres`` matrices # in ``residues``. # This function is provided for convenience purposes. # For reducing or reconstructing multiple integer matrices over the same # set of moduli, it is faster to use :func:`fmpz_mat_multi_CRT_ui_precomp`. - void fmpz_mat_add(fmpz_mat_t C, const fmpz_mat_t A, const fmpz_mat_t B) + void fmpz_mat_add(fmpz_mat_t C, const fmpz_mat_t A, const fmpz_mat_t B) noexcept # Sets ``C`` to the elementwise sum `A + B`. All inputs must # be of the same size. Aliasing is allowed. - void fmpz_mat_sub(fmpz_mat_t C, const fmpz_mat_t A, const fmpz_mat_t B) + void fmpz_mat_sub(fmpz_mat_t C, const fmpz_mat_t A, const fmpz_mat_t B) noexcept # Sets ``C`` to the elementwise difference `A - B`. All inputs must # be of the same size. Aliasing is allowed. - void fmpz_mat_neg(fmpz_mat_t B, const fmpz_mat_t A) + void fmpz_mat_neg(fmpz_mat_t B, const fmpz_mat_t A) noexcept # Sets ``B`` to the elementwise negation of ``A``. Both inputs # must be of the same size. Aliasing is allowed. - void fmpz_mat_scalar_mul_si(fmpz_mat_t B, const fmpz_mat_t A, slong c) - void fmpz_mat_scalar_mul_ui(fmpz_mat_t B, const fmpz_mat_t A, ulong c) - void fmpz_mat_scalar_mul_fmpz(fmpz_mat_t B, const fmpz_mat_t A, const fmpz_t c) + void fmpz_mat_scalar_mul_si(fmpz_mat_t B, const fmpz_mat_t A, slong c) noexcept + void fmpz_mat_scalar_mul_ui(fmpz_mat_t B, const fmpz_mat_t A, ulong c) noexcept + void fmpz_mat_scalar_mul_fmpz(fmpz_mat_t B, const fmpz_mat_t A, const fmpz_t c) noexcept # Set ``B = A*c`` where ``A`` is an ``fmpz_mat_t`` and ``c`` # is a scalar respectively of type ``slong``, ``ulong``, # or ``fmpz_t``. The dimensions of ``A`` and ``B`` must # be compatible. - void fmpz_mat_scalar_addmul_si(fmpz_mat_t B, const fmpz_mat_t A, slong c) - void fmpz_mat_scalar_addmul_ui(fmpz_mat_t B, const fmpz_mat_t A, ulong c) - void fmpz_mat_scalar_addmul_fmpz(fmpz_mat_t B, const fmpz_mat_t A, const fmpz_t c) + void fmpz_mat_scalar_addmul_si(fmpz_mat_t B, const fmpz_mat_t A, slong c) noexcept + void fmpz_mat_scalar_addmul_ui(fmpz_mat_t B, const fmpz_mat_t A, ulong c) noexcept + void fmpz_mat_scalar_addmul_fmpz(fmpz_mat_t B, const fmpz_mat_t A, const fmpz_t c) noexcept # Set ``B = B + A*c`` where ``A`` is an ``fmpz_mat_t`` and ``c`` # is a scalar respectively of type ``slong``, ``ulong``, # or ``fmpz_t``. The dimensions of ``A`` and ``B`` must # be compatible. - void fmpz_mat_scalar_submul_si(fmpz_mat_t B, const fmpz_mat_t A, slong c) - void fmpz_mat_scalar_submul_ui(fmpz_mat_t B, const fmpz_mat_t A, ulong c) - void fmpz_mat_scalar_submul_fmpz(fmpz_mat_t B, const fmpz_mat_t A, const fmpz_t c) + void fmpz_mat_scalar_submul_si(fmpz_mat_t B, const fmpz_mat_t A, slong c) noexcept + void fmpz_mat_scalar_submul_ui(fmpz_mat_t B, const fmpz_mat_t A, ulong c) noexcept + void fmpz_mat_scalar_submul_fmpz(fmpz_mat_t B, const fmpz_mat_t A, const fmpz_t c) noexcept # Set ``B = B - A*c`` where ``A`` is an ``fmpz_mat_t`` and ``c`` # is a scalar respectively of type ``slong``, ``ulong``, # or ``fmpz_t``. The dimensions of ``A`` and ``B`` must # be compatible. - void fmpz_mat_scalar_addmul_nmod_mat_ui(fmpz_mat_t B, const nmod_mat_t A, ulong c) - void fmpz_mat_scalar_addmul_nmod_mat_fmpz(fmpz_mat_t B, const nmod_mat_t A, const fmpz_t c) + void fmpz_mat_scalar_addmul_nmod_mat_ui(fmpz_mat_t B, const nmod_mat_t A, ulong c) noexcept + void fmpz_mat_scalar_addmul_nmod_mat_fmpz(fmpz_mat_t B, const nmod_mat_t A, const fmpz_t c) noexcept # Set ``B = B + A*c`` where ``A`` is an ``nmod_mat_t`` and ``c`` # is a scalar respectively of type ``ulong`` or ``fmpz_t``. # The dimensions of ``A`` and ``B`` must be compatible. - void fmpz_mat_scalar_divexact_si(fmpz_mat_t B, const fmpz_mat_t A, slong c) - void fmpz_mat_scalar_divexact_ui(fmpz_mat_t B, const fmpz_mat_t A, ulong c) - void fmpz_mat_scalar_divexact_fmpz(fmpz_mat_t B, const fmpz_mat_t A, const fmpz_t c) + void fmpz_mat_scalar_divexact_si(fmpz_mat_t B, const fmpz_mat_t A, slong c) noexcept + void fmpz_mat_scalar_divexact_ui(fmpz_mat_t B, const fmpz_mat_t A, ulong c) noexcept + void fmpz_mat_scalar_divexact_fmpz(fmpz_mat_t B, const fmpz_mat_t A, const fmpz_t c) noexcept # Set ``A = B / c``, where ``B`` is an ``fmpz_mat_t`` and ``c`` # is a scalar respectively of type ``slong``, ``ulong``, # or ``fmpz_t``, which is assumed to divide all elements of # ``B`` exactly. - void fmpz_mat_scalar_mul_2exp(fmpz_mat_t B, const fmpz_mat_t A, ulong exp) + void fmpz_mat_scalar_mul_2exp(fmpz_mat_t B, const fmpz_mat_t A, ulong exp) noexcept # Set the matrix ``B`` to the matrix ``A``, of the same dimensions, # multiplied by `2^{exp}`. - void fmpz_mat_scalar_tdiv_q_2exp(fmpz_mat_t B, const fmpz_mat_t A, ulong exp) + void fmpz_mat_scalar_tdiv_q_2exp(fmpz_mat_t B, const fmpz_mat_t A, ulong exp) noexcept # Set the matrix ``B`` to the matrix ``A``, of the same dimensions, # divided by `2^{exp}`, rounding down towards zero. - void fmpz_mat_scalar_smod(fmpz_mat_t B, const fmpz_mat_t A, const fmpz_t P) + void fmpz_mat_scalar_smod(fmpz_mat_t B, const fmpz_mat_t A, const fmpz_t P) noexcept # Set the matrix ``B`` to the matrix ``A``, of the same dimensions, # with each entry reduced modulo `P` in the symmetric moduli system. We # require `P > 0`. - void fmpz_mat_mul(fmpz_mat_t C, const fmpz_mat_t A, const fmpz_mat_t B) + void fmpz_mat_mul(fmpz_mat_t C, const fmpz_mat_t A, const fmpz_mat_t B) noexcept # Sets ``C`` to the matrix product `C = A B`. The matrices must have # compatible dimensions for matrix multiplication. Aliasing # is allowed. @@ -366,19 +366,19 @@ cdef extern from "flint_wrap.h": # multimodular multiplication, based on a heuristic comparison of # the dimensions and entry sizes. - void fmpz_mat_mul_classical(fmpz_mat_t C, const fmpz_mat_t A, const fmpz_mat_t B) + void fmpz_mat_mul_classical(fmpz_mat_t C, const fmpz_mat_t A, const fmpz_mat_t B) noexcept # Sets ``C`` to the matrix product `C = A B` computed using # classical matrix algorithm. # The matrices must have compatible dimensions for matrix multiplication. # No aliasing is allowed. - void fmpz_mat_mul_strassen(fmpz_mat_t C, const fmpz_mat_t A, const fmpz_mat_t B) + void fmpz_mat_mul_strassen(fmpz_mat_t C, const fmpz_mat_t A, const fmpz_mat_t B) noexcept # Sets `C = AB`. Dimensions must be compatible for matrix multiplication. # `C` is not allowed to be aliased with `A` or `B`. Uses Strassen # multiplication (the Strassen-Winograd variant). - void _fmpz_mat_mul_multi_mod(fmpz_mat_t C, const fmpz_mat_t A, const fmpz_mat_t B, int sign, flint_bitcnt_t bits) - void fmpz_mat_mul_multi_mod(fmpz_mat_t C, const fmpz_mat_t A, const fmpz_mat_t B) + void _fmpz_mat_mul_multi_mod(fmpz_mat_t C, const fmpz_mat_t A, const fmpz_mat_t B, int sign, flint_bitcnt_t bits) noexcept + void fmpz_mat_mul_multi_mod(fmpz_mat_t C, const fmpz_mat_t A, const fmpz_mat_t B) noexcept # Sets ``C`` to the matrix product `C = AB` computed using a multimodular # algorithm. `C` is computed modulo several small prime numbers # and reconstructed using the Chinese Remainder Theorem. This generally @@ -392,54 +392,54 @@ cdef extern from "flint_wrap.h": # The matrices must have compatible dimensions for matrix multiplication. # No aliasing is allowed. - int fmpz_mat_mul_blas(fmpz_mat_t C, const fmpz_mat_t A, const fmpz_mat_t B) + int fmpz_mat_mul_blas(fmpz_mat_t C, const fmpz_mat_t A, const fmpz_mat_t B) noexcept # Tries to set `C = AB` using BLAS and returns `1` for success and `0` for failure. # Dimensions must be compatible for matrix multiplication. No aliasing is allowed. # This function currently will fail if the matrices are empty, their dimensions are too large, or their max bits size is over one million bits. - void fmpz_mat_mul_fft(fmpz_mat_t C, const fmpz_mat_t A, const fmpz_mat_t B) + void fmpz_mat_mul_fft(fmpz_mat_t C, const fmpz_mat_t A, const fmpz_mat_t B) noexcept # Aliasing is allowed. - void fmpz_mat_sqr(fmpz_mat_t B, const fmpz_mat_t A) + void fmpz_mat_sqr(fmpz_mat_t B, const fmpz_mat_t A) noexcept # Sets ``B`` to the square of the matrix ``A``, which must be # a square matrix. Aliasing is allowed. # The function calls :func:`fmpz_mat_mul` for dimensions less than 12 and # calls :func:`fmpz_mat_sqr_bodrato` for cases in which the latter is faster. - void fmpz_mat_sqr_bodrato(fmpz_mat_t B, const fmpz_mat_t A) + void fmpz_mat_sqr_bodrato(fmpz_mat_t B, const fmpz_mat_t A) noexcept # Sets ``B`` to the square of the matrix ``A``, which must be # a square matrix. Aliasing is allowed. # The Bodrato algorithm is described in [Bodrato2010]_. # It is highly efficient for squaring matrices which satisfy both the # following conditions: (a) large elements, (b) dimensions less than 150. - void fmpz_mat_pow(fmpz_mat_t B, const fmpz_mat_t A, ulong e) + void fmpz_mat_pow(fmpz_mat_t B, const fmpz_mat_t A, ulong e) noexcept # Sets ``B`` to the matrix ``A`` raised to the power ``e``, # where ``A`` must be a square matrix. Aliasing is allowed. - void _fmpz_mat_mul_small(fmpz_mat_t C, const fmpz_mat_t A, const fmpz_mat_t B) + void _fmpz_mat_mul_small(fmpz_mat_t C, const fmpz_mat_t A, const fmpz_mat_t B) noexcept # This internal function sets `C` to the matrix product `C = A B` computed # using classical matrix algorithm assuming that all entries of `A` and `B` # are small, that is, have bits `\le FLINT\_BITS - 2`. No aliasing is allowed. - void _fmpz_mat_mul_double_word(fmpz_mat_t C, const fmpz_mat_t A, const fmpz_mat_t B) + void _fmpz_mat_mul_double_word(fmpz_mat_t C, const fmpz_mat_t A, const fmpz_mat_t B) noexcept # This function is only for internal use and assumes that either: # - the entries of `A` and `B` are all nonnegative and strictly less than `2^{2*FLINT\_BITS}`, or # - the entries of `A` and `B` are all strictly less than `2^{2*FLINT\_BITS - 1}` in absolute value. - void fmpz_mat_mul_fmpz_vec(fmpz * c, const fmpz_mat_t A, const fmpz * b, slong blen) - void fmpz_mat_mul_fmpz_vec_ptr(fmpz * const * c, const fmpz_mat_t A, const fmpz * const * b, slong blen) + void fmpz_mat_mul_fmpz_vec(fmpz * c, const fmpz_mat_t A, const fmpz * b, slong blen) noexcept + void fmpz_mat_mul_fmpz_vec_ptr(fmpz * const * c, const fmpz_mat_t A, const fmpz * const * b, slong blen) noexcept # Compute a matrix-vector product of ``A`` and ``(b, blen)`` and store the result in ``c``. # The vector ``(b, blen)`` is either truncated or zero-extended to the number of columns of ``A``. # The number of entries written to ``c`` is always equal to the number of rows of ``A``. - void fmpz_mat_fmpz_vec_mul(fmpz * c, const fmpz * a, slong alen, const fmpz_mat_t B) - void fmpz_mat_fmpz_vec_mul_ptr(fmpz * const * c, const fmpz * const * a, slong alen, const fmpz_mat_t B) + void fmpz_mat_fmpz_vec_mul(fmpz * c, const fmpz * a, slong alen, const fmpz_mat_t B) noexcept + void fmpz_mat_fmpz_vec_mul_ptr(fmpz * const * c, const fmpz * const * a, slong alen, const fmpz_mat_t B) noexcept # Compute a vector-matrix product of ``(a, alen)`` and ``B`` and store the result in ``c``. # The vector ``(a, alen)`` is either truncated or zero-extended to the number of rows of ``B``. # The number of entries written to ``c`` is always equal to the number of columns of ``B``. - int fmpz_mat_inv(fmpz_mat_t Ainv, fmpz_t den, const fmpz_mat_t A) + int fmpz_mat_inv(fmpz_mat_t Ainv, fmpz_t den, const fmpz_mat_t A) noexcept # Sets (``Ainv``, ``den``) to the inverse matrix of ``A``. # Returns 1 if ``A`` is nonsingular and 0 if ``A`` is singular. # Aliasing of ``Ainv`` and ``A`` is allowed. @@ -449,18 +449,18 @@ cdef extern from "flint_wrap.h": # and otherwise solves for the identity matrix using # fraction-free LU decomposition. - void fmpz_mat_kronecker_product(fmpz_mat_t C, const fmpz_mat_t A, const fmpz_mat_t B) + void fmpz_mat_kronecker_product(fmpz_mat_t C, const fmpz_mat_t A, const fmpz_mat_t B) noexcept # Sets ``C`` to the Kronecker product of ``A`` and ``B``. - void fmpz_mat_content(fmpz_t mat_gcd, const fmpz_mat_t A) + void fmpz_mat_content(fmpz_t mat_gcd, const fmpz_mat_t A) noexcept # Sets ``mat_gcd`` as the gcd of all the elements of the matrix ``A``. # Returns 0 if the matrix is empty. - void fmpz_mat_trace(fmpz_t trace, const fmpz_mat_t mat) + void fmpz_mat_trace(fmpz_t trace, const fmpz_mat_t mat) noexcept # Computes the trace of the matrix, i.e. the sum of the entries on # the main diagonal. The matrix is required to be square. - void fmpz_mat_det(fmpz_t det, const fmpz_mat_t A) + void fmpz_mat_det(fmpz_t det, const fmpz_mat_t A) noexcept # Sets ``det`` to the determinant of the square matrix `A`. # The matrix of dimension `0 \times 0` is defined to have determinant 1. # This function automatically chooses between :func:`fmpz_mat_det_cofactor`, @@ -469,19 +469,19 @@ cdef extern from "flint_wrap.h": # (with ``proved`` = 1), depending on the size of the matrix # and its entries. - void fmpz_mat_det_cofactor(fmpz_t det, const fmpz_mat_t A) + void fmpz_mat_det_cofactor(fmpz_t det, const fmpz_mat_t A) noexcept # Sets ``det`` to the determinant of the square matrix `A` # computed using direct cofactor expansion. This function only # supports matrices up to size `4 \times 4`. - void fmpz_mat_det_bareiss(fmpz_t det, const fmpz_mat_t A) + void fmpz_mat_det_bareiss(fmpz_t det, const fmpz_mat_t A) noexcept # Sets ``det`` to the determinant of the square matrix `A` # computed using the Bareiss algorithm. A copy of the input matrix is # row reduced using fraction-free Gaussian elimination, and the # determinant is read off from the last element on the main # diagonal. - void fmpz_mat_det_modular(fmpz_t det, const fmpz_mat_t A, int proved) + void fmpz_mat_det_modular(fmpz_t det, const fmpz_mat_t A, int proved) noexcept # Sets ``det`` to the determinant of the square matrix `A` # (if ``proved`` = 1), or a probabilistic value for the # determinant (``proved`` = 0), computed using a multimodular @@ -494,7 +494,7 @@ cdef extern from "flint_wrap.h": # if it remains unchanged modulo several consecutive primes # (currently if their product exceeds `2^{100}`). - void fmpz_mat_det_modular_accelerated(fmpz_t det, const fmpz_mat_t A, int proved) + void fmpz_mat_det_modular_accelerated(fmpz_t det, const fmpz_mat_t A, int proved) noexcept # Sets ``det`` to the determinant of the square matrix `A` # (if ``proved`` = 1), or a probabilistic value for the # determinant (``proved`` = 0), computed using a multimodular @@ -507,24 +507,24 @@ cdef extern from "flint_wrap.h": # with high probability will be nearly as large as the determinant. # This trick is described in [AbbottBronsteinMulders1999]_. - void fmpz_mat_det_modular_given_divisor(fmpz_t det, const fmpz_mat_t A, const fmpz_t d, int proved) + void fmpz_mat_det_modular_given_divisor(fmpz_t det, const fmpz_mat_t A, const fmpz_t d, int proved) noexcept # Given a positive divisor `d` of `\det(A)`, sets ``det`` to the # determinant of the square matrix `A` (if ``proved`` = 1), or a # probabilistic value for the determinant (``proved`` = 0), computed # using a multimodular algorithm. - void fmpz_mat_det_bound(fmpz_t bound, const fmpz_mat_t A) + void fmpz_mat_det_bound(fmpz_t bound, const fmpz_mat_t A) noexcept # Sets ``bound`` to a nonnegative integer `B` such that # `|\det(A)| \le B`. Assumes `A` to be a square matrix. # The bound is computed from the Hadamard inequality # `|\det(A)| \le \prod \|a_i\|_2` where the product is taken # over the rows `a_i` of `A`. - void fmpz_mat_det_bound_nonzero(fmpz_t bound, const fmpz_mat_t A) + void fmpz_mat_det_bound_nonzero(fmpz_t bound, const fmpz_mat_t A) noexcept # As per ``fmpz_mat_det_bound()`` but excludes zero columns. For use with # non-square matrices. - void fmpz_mat_det_divisor(fmpz_t d, const fmpz_mat_t A) + void fmpz_mat_det_divisor(fmpz_t d, const fmpz_mat_t A) noexcept # Sets `d` to some positive divisor of the determinant of the given # square matrix `A`, if the determinant is nonzero. If `|\det(A)| = 0`, # `d` will always be set to zero. @@ -533,7 +533,7 @@ cdef extern from "flint_wrap.h": # common multiple of the denominators in `x`. This yields a divisor `d` # such that `|\det(A)| / d` is tiny with very high probability. - void fmpz_mat_similarity(fmpz_mat_t A, slong r, fmpz_t d) + void fmpz_mat_similarity(fmpz_mat_t A, slong r, fmpz_t d) noexcept # Applies a similarity transform to the `n\times n` matrix `M` in-place. # If `P` is the `n\times n` identity matrix the zero entries of whose row # `r` (`0`-indexed) have been replaced by `d`, this transform is equivalent @@ -541,54 +541,54 @@ cdef extern from "flint_wrap.h": # Similarity transforms preserve the determinant, characteristic polynomial # and minimal polynomial. - void _fmpz_mat_charpoly_berkowitz(fmpz * cp, const fmpz_mat_t mat) + void _fmpz_mat_charpoly_berkowitz(fmpz * cp, const fmpz_mat_t mat) noexcept # Sets ``(cp, n+1)`` to the characteristic polynomial of # an `n \times n` square matrix. - void fmpz_mat_charpoly_berkowitz(fmpz_poly_t cp, const fmpz_mat_t mat) + void fmpz_mat_charpoly_berkowitz(fmpz_poly_t cp, const fmpz_mat_t mat) noexcept # Computes the characteristic polynomial of length `n + 1` of # an `n \times n` square matrix. Uses an `O(n^4)` algorithm based on the # method of Berkowitz. - void _fmpz_mat_charpoly_modular(fmpz * cp, const fmpz_mat_t mat) + void _fmpz_mat_charpoly_modular(fmpz * cp, const fmpz_mat_t mat) noexcept # Sets ``(cp, n+1)`` to the characteristic polynomial of # an `n \times n` square matrix. - void fmpz_mat_charpoly_modular(fmpz_poly_t cp, const fmpz_mat_t mat) + void fmpz_mat_charpoly_modular(fmpz_poly_t cp, const fmpz_mat_t mat) noexcept # Computes the characteristic polynomial of length `n + 1` of # an `n \times n` square matrix. Uses a modular method based on an `O(n^3)` # method over `\mathbb{Z}/n\mathbb{Z}`. - void _fmpz_mat_charpoly(fmpz * cp, const fmpz_mat_t mat) + void _fmpz_mat_charpoly(fmpz * cp, const fmpz_mat_t mat) noexcept # Sets ``(cp, n+1)`` to the characteristic polynomial of # an `n \times n` square matrix. - void fmpz_mat_charpoly(fmpz_poly_t cp, const fmpz_mat_t mat) + void fmpz_mat_charpoly(fmpz_poly_t cp, const fmpz_mat_t mat) noexcept # Computes the characteristic polynomial of length `n + 1` of # an `n \times n` square matrix. - slong _fmpz_mat_minpoly_modular(fmpz * cp, const fmpz_mat_t mat) + slong _fmpz_mat_minpoly_modular(fmpz * cp, const fmpz_mat_t mat) noexcept # Sets ``(cp, n+1)`` to the modular polynomial of # an `n \times n` square matrix and returns its length. - void fmpz_mat_minpoly_modular(fmpz_poly_t cp, const fmpz_mat_t mat) + void fmpz_mat_minpoly_modular(fmpz_poly_t cp, const fmpz_mat_t mat) noexcept # Computes the minimal polynomial of an `n \times n` square matrix. # Uses a modular method based on an average time `O(n^3)`, worst case # `O(n^4)` method over `\mathbb{Z}/n\mathbb{Z}`. - slong _fmpz_mat_minpoly(fmpz * cp, const fmpz_mat_t mat) + slong _fmpz_mat_minpoly(fmpz * cp, const fmpz_mat_t mat) noexcept # Sets ``cp`` to the minimal polynomial of an `n \times n` square # matrix and returns its length. - void fmpz_mat_minpoly(fmpz_poly_t cp, const fmpz_mat_t mat) + void fmpz_mat_minpoly(fmpz_poly_t cp, const fmpz_mat_t mat) noexcept # Computes the minimal polynomial of an `n \times n` square matrix. - slong fmpz_mat_rank(const fmpz_mat_t A) + slong fmpz_mat_rank(const fmpz_mat_t A) noexcept # Returns the rank, that is, the number of linearly independent columns # (equivalently, rows), of `A`. The rank is computed by row reducing # a copy of `A`. - int fmpz_mat_col_partition(slong * part, fmpz_mat_t M, int short_circuit) + int fmpz_mat_col_partition(slong * part, fmpz_mat_t M, int short_circuit) noexcept # Returns the number `p` of distinct columns of `M` (or `0` if the flag # ``short_circuit`` is set and this number is greater than the number # of rows of `M`). The entries of array ``part`` are set to values in @@ -596,7 +596,7 @@ cdef extern from "flint_wrap.h": # columns of `M` are equal. This function is used in van Hoeij polynomial # factoring. - int fmpz_mat_solve(fmpz_mat_t X, fmpz_t den, const fmpz_mat_t A, const fmpz_mat_t B) + int fmpz_mat_solve(fmpz_mat_t X, fmpz_t den, const fmpz_mat_t A, const fmpz_mat_t B) noexcept # Solves the equation `AX = B` for nonsingular `A`. More precisely, computes # (``X``, ``den``) such that `AX = B \times \operatorname{den}`. # Returns 1 if `A` is nonsingular and 0 if `A` is singular. @@ -607,7 +607,7 @@ cdef extern from "flint_wrap.h": # Note that for very large systems, it is faster to compute a modular # solution using ``fmpz_mat_solve_dixon``. - int fmpz_mat_solve_fflu(fmpz_mat_t X, fmpz_t den, const fmpz_mat_t A, const fmpz_mat_t B) + int fmpz_mat_solve_fflu(fmpz_mat_t X, fmpz_t den, const fmpz_mat_t A, const fmpz_mat_t B) noexcept # Solves the equation `AX = B` for nonsingular `A`. More precisely, computes # (``X``, ``den``) such that `AX = B \times \operatorname{den}`. # Returns 1 if `A` is nonsingular and 0 if `A` is singular. @@ -615,7 +615,7 @@ cdef extern from "flint_wrap.h": # Uses fraction-free LU decomposition followed by fraction-free # forward and back substitution. - int fmpz_mat_solve_fflu_precomp(fmpz_mat_t X, const slong * perm, const fmpz_mat_t FFLU, const fmpz_mat_t B) + int fmpz_mat_solve_fflu_precomp(fmpz_mat_t X, const slong * perm, const fmpz_mat_t FFLU, const fmpz_mat_t B) noexcept # Performs fraction-free forward and back substitution given a precomputed # fraction-free LU decomposition and corresponding permutation. If no # impossible division is encountered, the function returns `1`. This does not @@ -625,18 +625,18 @@ cdef extern from "flint_wrap.h": # we have, then the first `r` rows of `p(A)y = p(b)d` hold, where `d` is the # denominator of the FFLU. The remaining rows must be checked by the caller. - int fmpz_mat_solve_cramer(fmpz_mat_t X, fmpz_t den, const fmpz_mat_t A, const fmpz_mat_t B) + int fmpz_mat_solve_cramer(fmpz_mat_t X, fmpz_t den, const fmpz_mat_t A, const fmpz_mat_t B) noexcept # Solves the equation `AX = B` for nonsingular `A`. More precisely, computes # (``X``, ``den``) such that `AX = B \times \operatorname{den}`. # Returns 1 if `A` is nonsingular and 0 if `A` is singular. # Uses Cramer's rule. Only systems of size up to `3 \times 3` are allowed. - void fmpz_mat_solve_bound(fmpz_t N, fmpz_t D, const fmpz_mat_t A, const fmpz_mat_t B) + void fmpz_mat_solve_bound(fmpz_t N, fmpz_t D, const fmpz_mat_t A, const fmpz_mat_t B) noexcept # Assuming that `A` is nonsingular, computes integers `N` and `D` # such that the reduced numerators and denominators `n/d` in # `A^{-1} B` satisfy the bounds `0 \le |n| \le N` and `0 \le d \le D`. - int fmpz_mat_solve_dixon(fmpz_mat_t X, fmpz_t M, const fmpz_mat_t A, const fmpz_mat_t B) + int fmpz_mat_solve_dixon(fmpz_mat_t X, fmpz_t M, const fmpz_mat_t A, const fmpz_mat_t B) noexcept # Solves `AX = B` given a nonsingular square matrix `A` and a matrix `B` of # compatible dimensions, using a modular algorithm. In particular, # Dixon's p-adic lifting algorithm is used (currently a non-adaptive version). @@ -652,7 +652,7 @@ cdef extern from "flint_wrap.h": # undefined. # Aliasing between input and output matrices is allowed. - void _fmpz_mat_solve_dixon_den(fmpz_mat_t X, fmpz_t den, const fmpz_mat_t A, const fmpz_mat_t B, const nmod_mat_t Ainv, mp_limb_t p, const fmpz_t N, const fmpz_t D) + void _fmpz_mat_solve_dixon_den(fmpz_mat_t X, fmpz_t den, const fmpz_mat_t A, const fmpz_mat_t B, const nmod_mat_t Ainv, mp_limb_t p, const fmpz_t N, const fmpz_t D) noexcept # Solves the equation `AX = B` for nonsingular `A`. More precisely, computes # (``X``, ``den``) such that `AX = B \times \operatorname{den}` using a # ``p``-adic algorithm for the supplied prime ``p``. The values ``N`` and @@ -661,7 +661,7 @@ cdef extern from "flint_wrap.h": # Uses the Dixon lifting algorithm with early termination once the lifting # stabilises. - int fmpz_mat_solve_dixon_den(fmpz_mat_t X, fmpz_t den, const fmpz_mat_t A, const fmpz_mat_t B) + int fmpz_mat_solve_dixon_den(fmpz_mat_t X, fmpz_t den, const fmpz_mat_t A, const fmpz_mat_t B) noexcept # Solves the equation `AX = B` for nonsingular `A`. More precisely, computes # (``X``, ``den``) such that `AX = B \times \operatorname{den}`. # Returns 1 if `A` is nonsingular and 0 if `A` is singular. @@ -669,7 +669,7 @@ cdef extern from "flint_wrap.h": # Uses the Dixon lifting algorithm with early termination once the lifting # stabilises. - int fmpz_mat_solve_multi_mod_den(fmpz_mat_t X, fmpz_t den, const fmpz_mat_t A, const fmpz_mat_t B) + int fmpz_mat_solve_multi_mod_den(fmpz_mat_t X, fmpz_t den, const fmpz_mat_t A, const fmpz_mat_t B) noexcept # Solves the equation `AX = B` for nonsingular `A`. More precisely, computes # (``X``, ``den``) such that `AX = B \times \operatorname{den}`. # Returns 1 if `A` is nonsingular and 0 if `A` is singular. @@ -677,7 +677,7 @@ cdef extern from "flint_wrap.h": # Uses a Chinese remainder algorithm with early termination once the lifting # stabilises. - int fmpz_mat_can_solve_multi_mod_den(fmpz_mat_t X, fmpz_t den, const fmpz_mat_t A, const fmpz_mat_t B) + int fmpz_mat_can_solve_multi_mod_den(fmpz_mat_t X, fmpz_t den, const fmpz_mat_t A, const fmpz_mat_t B) noexcept # Returns `1` if the system `AX = B` can be solved. If so it computes # (``X``, ``den``) such that `AX = B \times \operatorname{den}`. The # computed denominator will not generally be minimal. @@ -685,7 +685,7 @@ cdef extern from "flint_wrap.h": # Note that the matrices `A` and `B` may have any shape as long as they have # the same number of rows. - int fmpz_mat_can_solve_fflu(fmpz_mat_t X, fmpz_t den, const fmpz_mat_t A, const fmpz_mat_t B) + int fmpz_mat_can_solve_fflu(fmpz_mat_t X, fmpz_t den, const fmpz_mat_t A, const fmpz_mat_t B) noexcept # Returns `1` if the system `AX = B` can be solved. If so it computes # (``X``, ``den``) such that `AX = B \times \operatorname{den}`. The # computed denominator will not generally be minimal. @@ -693,14 +693,14 @@ cdef extern from "flint_wrap.h": # Note that the matrices `A` and `B` may have any shape as long as they have # the same number of rows. - int fmpz_mat_can_solve(fmpz_mat_t X, fmpz_t den, const fmpz_mat_t A, const fmpz_mat_t B) + int fmpz_mat_can_solve(fmpz_mat_t X, fmpz_t den, const fmpz_mat_t A, const fmpz_mat_t B) noexcept # Returns `1` if the system `AX = B` can be solved. If so it computes # (``X``, ``den``) such that `AX = B \times \operatorname{den}`. The # computed denominator will not generally be minimal. # Note that the matrices `A` and `B` may have any shape as long as they have # the same number of rows. - slong fmpz_mat_find_pivot_any(const fmpz_mat_t mat, slong start_row, slong end_row, slong c) + slong fmpz_mat_find_pivot_any(const fmpz_mat_t mat, slong start_row, slong end_row, slong c) noexcept # Attempts to find a pivot entry for row reduction. # Returns a row index `r` between ``start_row`` (inclusive) and # ``stop_row`` (exclusive) such that column `c` in ``mat`` has @@ -710,7 +710,7 @@ cdef extern from "flint_wrap.h": # entries in the matrix have roughly the same size, but can lead to # unnecessary coefficient growth if the entries vary in size. - slong fmpz_mat_fflu(fmpz_mat_t B, fmpz_t den, slong * perm, const fmpz_mat_t A, int rank_check) + slong fmpz_mat_fflu(fmpz_mat_t B, fmpz_t den, slong * perm, const fmpz_mat_t A, int rank_check) noexcept # Uses fraction-free Gaussian elimination to set (``B``, ``den``) to a # fraction-free LU decomposition of ``A`` and returns the # rank of ``A``. Aliasing of ``A`` and ``B`` is allowed. @@ -726,14 +726,14 @@ cdef extern from "flint_wrap.h": # determinant is not generally the minimal denominator. # The fraction-free LU decomposition is defined in [NakTurWil1997]_. - slong fmpz_mat_rref(fmpz_mat_t B, fmpz_t den, const fmpz_mat_t A) + slong fmpz_mat_rref(fmpz_mat_t B, fmpz_t den, const fmpz_mat_t A) noexcept # Sets (``B``, ``den``) to the reduced row echelon form of ``A`` # and returns the rank of ``A``. Aliasing of ``A`` and ``B`` # is allowed. # The algorithm used chooses between ``fmpz_mat_rref_fflu`` and # ``fmpz_mat_rref_mul`` based on the dimensions of the input matrix. - slong fmpz_mat_rref_fflu(fmpz_mat_t B, fmpz_t den, const fmpz_mat_t A) + slong fmpz_mat_rref_fflu(fmpz_mat_t B, fmpz_t den, const fmpz_mat_t A) noexcept # Sets (``B``, ``den``) to the reduced row echelon form of ``A`` # and returns the rank of ``A``. Aliasing of ``A`` and ``B`` # is allowed. @@ -750,7 +750,7 @@ cdef extern from "flint_wrap.h": # `S` is an appropriate submatrix of `A` (`S = A` if `A` is square). # Note that the determinant is not generally the minimal denominator. - slong fmpz_mat_rref_mul(fmpz_mat_t B, fmpz_t den, const fmpz_mat_t A) + slong fmpz_mat_rref_mul(fmpz_mat_t B, fmpz_t den, const fmpz_mat_t A) noexcept # Sets (``B``, ``den``) to the reduced row echelon form of ``A`` # and returns the rank of ``A``. Aliasing of ``A`` and ``B`` # is allowed. @@ -761,11 +761,11 @@ cdef extern from "flint_wrap.h": # the reduced row echelon form of the whole of ``A``. This procedure is # described in [Stein2007]_. - bint fmpz_mat_is_in_rref_with_rank(const fmpz_mat_t A, const fmpz_t den, slong rank) + bint fmpz_mat_is_in_rref_with_rank(const fmpz_mat_t A, const fmpz_t den, slong rank) noexcept # Checks that the matrix `A/den` is in reduced row echelon form of rank # ``rank``, returns 1 if so and 0 otherwise. - slong fmpz_mat_rref_mod(slong * perm, fmpz_mat_t A, const fmpz_t p) + slong fmpz_mat_rref_mod(slong * perm, fmpz_mat_t A, const fmpz_t p) noexcept # Uses fraction-free Gauss-Jordan elimination to set ``A`` # to its reduced row echelon form and returns the rank of ``A``. # All computations are done modulo p. @@ -773,14 +773,14 @@ cdef extern from "flint_wrap.h": # If ``perm`` is non-``NULL``, the permutation of # rows in the matrix will also be applied to ``perm``. - void fmpz_mat_strong_echelon_form_mod(fmpz_mat_t A, const fmpz_t mod) + void fmpz_mat_strong_echelon_form_mod(fmpz_mat_t A, const fmpz_t mod) noexcept # Transforms `A` such that `A` modulo ``mod`` is the strong echelon form # of the input matrix modulo ``mod``. The Howell form and the strong # echelon form are equal up to permutation of the rows, see [FieHof2014]_ # for a definition of the strong echelon form and the algorithm used here. # `A` must have at least as many rows as columns. - slong fmpz_mat_howell_form_mod(fmpz_mat_t A, const fmpz_t mod) + slong fmpz_mat_howell_form_mod(fmpz_mat_t A, const fmpz_t mod) noexcept # Transforms `A` such that `A` modulo ``mod`` is the Howell form of the # input matrix modulo ``mod``. # For a definition of the Howell form see [StoMul1998]_. The Howell form @@ -788,7 +788,7 @@ cdef extern from "flint_wrap.h": # the rows. # `A` must have at least as many rows as columns. - slong fmpz_mat_nullspace(fmpz_mat_t B, const fmpz_mat_t A) + slong fmpz_mat_nullspace(fmpz_mat_t B, const fmpz_mat_t A) noexcept # Computes a basis for the right rational nullspace of `A` and returns # the dimension of the nullspace (or nullity). `B` is set to a matrix with # linearly independent columns and maximal rank such that `AB = 0` @@ -799,7 +799,7 @@ cdef extern from "flint_wrap.h": # `B` must be allocated with sufficient space to represent the result # (at most `n \times n` where `n` is the number of columns of `A`). - slong fmpz_mat_rref_fraction_free(slong * perm, fmpz_mat_t B, fmpz_t den, const fmpz_mat_t A) + slong fmpz_mat_rref_fraction_free(slong * perm, fmpz_mat_t B, fmpz_t den, const fmpz_mat_t A) noexcept # Computes an integer matrix ``B`` and an integer ``den`` such that # ``B / den`` is the unique row reduced echelon form (RREF) of ``A`` # and returns the rank, i.e. the number of nonzero rows in ``B``. @@ -813,7 +813,7 @@ cdef extern from "flint_wrap.h": # submatrix of) `A`, but is not guaranteed to be minimal or canonical in # any other sense. - void fmpz_mat_hnf(fmpz_mat_t H, const fmpz_mat_t A) + void fmpz_mat_hnf(fmpz_mat_t H, const fmpz_mat_t A) noexcept # Computes an integer matrix ``H`` such that ``H`` is the unique (row) # Hermite normal form of ``A``. The algorithm used is selected from the # implementations in FLINT to be the one most likely to be optimal, based on @@ -821,7 +821,7 @@ cdef extern from "flint_wrap.h": # Aliasing of ``H`` and ``A`` is allowed. The size of ``H`` must be # the same as that of ``A``. - void fmpz_mat_hnf_transform(fmpz_mat_t H, fmpz_mat_t U, const fmpz_mat_t A) + void fmpz_mat_hnf_transform(fmpz_mat_t H, fmpz_mat_t U, const fmpz_mat_t A) noexcept # Computes an integer matrix ``H`` such that ``H`` is the unique (row) # Hermite normal form of ``A`` along with the transformation matrix # ``U`` such that `UA = H`. The algorithm used is selected from the @@ -830,14 +830,14 @@ cdef extern from "flint_wrap.h": # the same as that of ``A`` and ``U`` must be square of \compatible # dimension (having the same number of rows as ``A``). - void fmpz_mat_hnf_classical(fmpz_mat_t H, const fmpz_mat_t A) + void fmpz_mat_hnf_classical(fmpz_mat_t H, const fmpz_mat_t A) noexcept # Computes an integer matrix ``H`` such that ``H`` is the unique (row) # Hermite normal form of ``A``. The algorithm used is straightforward and # is described, for example, in [Algorithm 2.4.4] [Coh1996]_. # Aliasing of ``H`` and ``A`` is allowed. The size of ``H`` must be # the same as that of ``A``. - void fmpz_mat_hnf_xgcd(fmpz_mat_t H, const fmpz_mat_t A) + void fmpz_mat_hnf_xgcd(fmpz_mat_t H, const fmpz_mat_t A) noexcept # Computes an integer matrix ``H`` such that ``H`` is the unique (row) # Hermite normal form of ``A``. The algorithm used is an improvement on the # basic algorithm and uses extended gcds to speed up computation, this method @@ -845,7 +845,7 @@ cdef extern from "flint_wrap.h": # Aliasing of ``H`` and ``A`` is allowed. The size of ``H`` must be # the same as that of ``A``. - void fmpz_mat_hnf_modular(fmpz_mat_t H, const fmpz_mat_t A, const fmpz_t D) + void fmpz_mat_hnf_modular(fmpz_mat_t H, const fmpz_mat_t A, const fmpz_t D) noexcept # Computes an integer matrix ``H`` such that ``H`` is the unique (row) # Hermite normal form of the `m\times n` matrix ``A``, where ``A`` is # assumed to be of rank `n` and ``D`` is known to be a positive multiple of @@ -855,13 +855,13 @@ cdef extern from "flint_wrap.h": # Aliasing of ``H`` and ``A`` is allowed. The size of ``H`` must be # the same as that of ``A``. - void fmpz_mat_hnf_modular_eldiv(fmpz_mat_t A, const fmpz_t D) + void fmpz_mat_hnf_modular_eldiv(fmpz_mat_t A, const fmpz_t D) noexcept # Transforms the `m\times n` matrix ``A`` into Hermite normal form, # where ``A`` is assumed to be of rank `n` and ``D`` is known to be a # positive multiple of the largest elementary divisor of ``A``. # The algorithm used here is described in [FieHof2014]_. - void fmpz_mat_hnf_minors(fmpz_mat_t H, const fmpz_mat_t A) + void fmpz_mat_hnf_minors(fmpz_mat_t H, const fmpz_mat_t A) noexcept # Computes an integer matrix ``H`` such that ``H`` is the unique (row) # Hermite normal form of the `m\times n` matrix ``A``, where ``A`` is # assumed to be of rank `n`. The algorithm used here is due to Kannan and @@ -870,18 +870,18 @@ cdef extern from "flint_wrap.h": # Aliasing of ``H`` and ``A`` is allowed. The size of ``H`` must be # the same as that of ``A``. - void fmpz_mat_hnf_pernet_stein(fmpz_mat_t H, const fmpz_mat_t A, flint_rand_t state) + void fmpz_mat_hnf_pernet_stein(fmpz_mat_t H, const fmpz_mat_t A, flint_rand_t state) noexcept # Computes an integer matrix ``H`` such that ``H`` is the unique (row) # Hermite normal form of the `m\times n` matrix ``A``. The algorithm used # here is due to Pernet and Stein [PernetStein2010]_. # Aliasing of ``H`` and ``A`` is allowed. The size of ``H`` must be # the same as that of ``A``. - bint fmpz_mat_is_in_hnf(const fmpz_mat_t A) + bint fmpz_mat_is_in_hnf(const fmpz_mat_t A) noexcept # Checks that the given matrix is in Hermite normal form, returns 1 if so and # 0 otherwise. - void fmpz_mat_snf(fmpz_mat_t S, const fmpz_mat_t A) + void fmpz_mat_snf(fmpz_mat_t S, const fmpz_mat_t A) noexcept # Computes an integer matrix ``S`` such that ``S`` is the unique Smith # normal form of ``A``. The algorithm used is selected from the # implementations in FLINT to be the one most likely to be optimal, based on @@ -889,44 +889,44 @@ cdef extern from "flint_wrap.h": # Aliasing of ``S`` and ``A`` is allowed. The size of ``S`` must be # the same as that of ``A``. - void fmpz_mat_snf_diagonal(fmpz_mat_t S, const fmpz_mat_t A) + void fmpz_mat_snf_diagonal(fmpz_mat_t S, const fmpz_mat_t A) noexcept # Computes an integer matrix ``S`` such that ``S`` is the unique Smith # normal form of the diagonal matrix ``A``. The algorithm used simply takes # gcds of pairs on the diagonal in turn until the Smith form is obtained. # Aliasing of ``S`` and ``A`` is allowed. The size of ``S`` must be # the same as that of ``A``. - void fmpz_mat_snf_kannan_bachem(fmpz_mat_t S, const fmpz_mat_t A) + void fmpz_mat_snf_kannan_bachem(fmpz_mat_t S, const fmpz_mat_t A) noexcept # Computes an integer matrix ``S`` such that ``S`` is the unique Smith # normal form of the diagonal matrix ``A``. The algorithm used here is due # to Kannan and Bachem [KanBac1979]_ # Aliasing of ``S`` and ``A`` is allowed. The size of ``S`` must be # the same as that of ``A``. - void fmpz_mat_snf_iliopoulos(fmpz_mat_t S, const fmpz_mat_t A, const fmpz_t mod) + void fmpz_mat_snf_iliopoulos(fmpz_mat_t S, const fmpz_mat_t A, const fmpz_t mod) noexcept # Computes an integer matrix ``S`` such that ``S`` is the unique Smith # normal form of the nonsingular `n\times n` matrix ``A``. The algorithm # used is due to Iliopoulos [Iliopoulos1989]_. # Aliasing of ``S`` and ``A`` is allowed. The size of ``S`` must be # the same as that of ``A``. - bint fmpz_mat_is_in_snf(const fmpz_mat_t A) + bint fmpz_mat_is_in_snf(const fmpz_mat_t A) noexcept # Checks that the given matrix is in Smith normal form, returns 1 if so and 0 # otherwise. - void fmpz_mat_gram(fmpz_mat_t B, const fmpz_mat_t A) + void fmpz_mat_gram(fmpz_mat_t B, const fmpz_mat_t A) noexcept # Sets ``B`` to the Gram matrix of the `m`-dimensional lattice ``L`` in # `n`-dimensional Euclidean space `R^n` spanned by the rows of # the `m \times n` matrix ``A``. Dimensions must be compatible. # ``A`` and ``B`` are allowed to be the same object if ``A`` is a # square matrix. - bint fmpz_mat_is_hadamard(const fmpz_mat_t H) + bint fmpz_mat_is_hadamard(const fmpz_mat_t H) noexcept # Returns nonzero iff `H` is a Hadamard matrix, meaning # that it is a square matrix, only has entries that are `\pm 1`, # and satisfies `H^T = n H^{-1}` where `n` is the matrix size. - int fmpz_mat_hadamard(fmpz_mat_t H) + int fmpz_mat_hadamard(fmpz_mat_t H) noexcept # Attempts to set the matrix `H` to a Hadamard matrix, returning 1 if # successful and 0 if unsuccessful. # A Hadamard matrix of size `n` can only exist if `n` is 1, 2, @@ -938,44 +938,44 @@ cdef extern from "flint_wrap.h": # known to exist but for which this construction fails are # 92, 116, 156, ... (OEIS A046116). - int fmpz_mat_get_d_mat(d_mat_t B, const fmpz_mat_t A) + int fmpz_mat_get_d_mat(d_mat_t B, const fmpz_mat_t A) noexcept # Sets the entries of ``B`` as doubles corresponding to the entries of # ``A``, rounding down towards zero if the latter cannot be represented # exactly. The return value is -1 if any entry of ``A`` is too large to # fit in the normal range of a double, and 0 otherwise. - int fmpz_mat_get_d_mat_transpose(d_mat_t B, const fmpz_mat_t A) + int fmpz_mat_get_d_mat_transpose(d_mat_t B, const fmpz_mat_t A) noexcept # Sets the entries of ``B`` as doubles corresponding to the entries of # the transpose of ``A``, rounding down towards zero if the latter cannot # be represented exactly. The return value is -1 if any entry of ``A`` is # too large to fit in the normal range of a double, and 0 otherwise. - void fmpz_mat_chol_d(d_mat_t R, const fmpz_mat_t A) + void fmpz_mat_chol_d(d_mat_t R, const fmpz_mat_t A) noexcept # Computes ``R``, the Cholesky factor of a symmetric, positive definite # matrix ``A`` using the Cholesky decomposition process. (Sets ``R`` # such that `A = RR^{T}` where ``R`` is a lower triangular matrix.) - bint fmpz_mat_is_reduced(const fmpz_mat_t A, double delta, double eta) - bint fmpz_mat_is_reduced_gram(const fmpz_mat_t A, double delta, double eta) + bint fmpz_mat_is_reduced(const fmpz_mat_t A, double delta, double eta) noexcept + bint fmpz_mat_is_reduced_gram(const fmpz_mat_t A, double delta, double eta) noexcept # Returns a non-zero value if the basis ``A`` is LLL-reduced with factor # (``delta``, ``eta``), and otherwise returns zero. # The second version assumes ``A`` is the Gram matrix of the basis. - bint fmpz_mat_is_reduced_with_removal(const fmpz_mat_t A, double delta, double eta, const fmpz_t gs_B, int newd) - bint fmpz_mat_is_reduced_gram_with_removal(const fmpz_mat_t A, double delta, double eta, const fmpz_t gs_B, int newd) + bint fmpz_mat_is_reduced_with_removal(const fmpz_mat_t A, double delta, double eta, const fmpz_t gs_B, int newd) noexcept + bint fmpz_mat_is_reduced_gram_with_removal(const fmpz_mat_t A, double delta, double eta, const fmpz_t gs_B, int newd) noexcept # Returns a non-zero value if the basis ``A`` is LLL-reduced with factor # (``delta``, ``eta``) for each of the first ``newd`` vectors and the squared # Gram-Schmidt length of each of the remaining `i`-th vectors # (where `i \ge` ``newd``) is greater than ``gs_B``, and otherwise returns zero. # The second version assumes ``A`` is the Gram matrix of the basis. - void fmpz_mat_lll_original(fmpz_mat_t A, const fmpq_t delta, const fmpq_t eta) + void fmpz_mat_lll_original(fmpz_mat_t A, const fmpq_t delta, const fmpq_t eta) noexcept # Takes a basis `x_1, x_2, \ldots, x_m` of the lattice `L \subset R^n` (as # the rows of a `m \times n` matrix ``A``). The output is a (``delta``, # ``eta``)-reduced basis `y_1, y_2, \ldots, y_m` of the lattice `L` (as # the rows of the same `m \times n` matrix ``A``). - void fmpz_mat_lll_storjohann(fmpz_mat_t A, const fmpq_t delta, const fmpq_t eta) + void fmpz_mat_lll_storjohann(fmpz_mat_t A, const fmpq_t delta, const fmpq_t eta) noexcept # Takes a basis `x_1, x_2, \ldots, x_m` of the lattice `L \subset R^n` (as # the rows of a `m \times n` matrix ``A``). The output is an (``delta``, # ``eta``)-reduced basis `y_1, y_2, \ldots, y_m` of the lattice `L` (as diff --git a/src/sage/libs/flint/fmpz_mod.pxd b/src/sage/libs/flint/fmpz_mod.pxd index 4fe576901d8..ac0eb02e303 100644 --- a/src/sage/libs/flint/fmpz_mod.pxd +++ b/src/sage/libs/flint/fmpz_mod.pxd @@ -12,83 +12,83 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void fmpz_mod_ctx_init(fmpz_mod_ctx_t ctx, const fmpz_t n) + void fmpz_mod_ctx_init(fmpz_mod_ctx_t ctx, const fmpz_t n) noexcept # Initialise ``ctx`` for arithmetic modulo ``n``, which is expected to be positive. - void fmpz_mod_ctx_clear(fmpz_mod_ctx_t ctx) + void fmpz_mod_ctx_clear(fmpz_mod_ctx_t ctx) noexcept # Free any memory used by ``ctx``. - void fmpz_mod_ctx_set_modulus(fmpz_mod_ctx_t ctx, const fmpz_t n) + void fmpz_mod_ctx_set_modulus(fmpz_mod_ctx_t ctx, const fmpz_t n) noexcept # Reconfigure ``ctx`` for arithmetic modulo ``n``. - void fmpz_mod_set_fmpz(fmpz_t a, const fmpz_t b, const fmpz_mod_ctx_t ctx) + void fmpz_mod_set_fmpz(fmpz_t a, const fmpz_t b, const fmpz_mod_ctx_t ctx) noexcept # Set ``a`` to ``b`` after reduction modulo the modulus. - bint fmpz_mod_is_canonical(const fmpz_t a, const fmpz_mod_ctx_t ctx) + bint fmpz_mod_is_canonical(const fmpz_t a, const fmpz_mod_ctx_t ctx) noexcept # Return ``1`` if `a` is in the canonical range `[0,n)` and ``0`` otherwise. - bint fmpz_mod_is_one(const fmpz_t a, const fmpz_mod_ctx_t ctx) + bint fmpz_mod_is_one(const fmpz_t a, const fmpz_mod_ctx_t ctx) noexcept # Return ``1`` if `a` is `1` modulo `n` and return ``0`` otherwise. - void fmpz_mod_add(fmpz_t a, const fmpz_t b, const fmpz_t c, const fmpz_mod_ctx_t ctx) + void fmpz_mod_add(fmpz_t a, const fmpz_t b, const fmpz_t c, const fmpz_mod_ctx_t ctx) noexcept # Set `a` to `b+c` modulo `n`. - void fmpz_mod_add_fmpz(fmpz_t a, const fmpz_t b, const fmpz_t c, const fmpz_mod_ctx_t ctx) - void fmpz_mod_add_ui(fmpz_t a, const fmpz_t b, ulong c, const fmpz_mod_ctx_t ctx) - void fmpz_mod_add_si(fmpz_t a, const fmpz_t b, slong c, const fmpz_mod_ctx_t ctx) + void fmpz_mod_add_fmpz(fmpz_t a, const fmpz_t b, const fmpz_t c, const fmpz_mod_ctx_t ctx) noexcept + void fmpz_mod_add_ui(fmpz_t a, const fmpz_t b, ulong c, const fmpz_mod_ctx_t ctx) noexcept + void fmpz_mod_add_si(fmpz_t a, const fmpz_t b, slong c, const fmpz_mod_ctx_t ctx) noexcept # Set `a` to `b+c` modulo `n` where only `b` is assumed to be canonical. - void fmpz_mod_sub(fmpz_t a, const fmpz_t b, const fmpz_t c, const fmpz_mod_ctx_t ctx) + void fmpz_mod_sub(fmpz_t a, const fmpz_t b, const fmpz_t c, const fmpz_mod_ctx_t ctx) noexcept # Set `a` to `b-c` modulo `n`. - void fmpz_mod_sub_fmpz(fmpz_t a, const fmpz_t b, const fmpz_t c, const fmpz_mod_ctx_t ctx) - void fmpz_mod_sub_ui(fmpz_t a, const fmpz_t b, ulong c, const fmpz_mod_ctx_t ctx) - void fmpz_mod_sub_si(fmpz_t a, const fmpz_t b, slong c, const fmpz_mod_ctx_t ctx) + void fmpz_mod_sub_fmpz(fmpz_t a, const fmpz_t b, const fmpz_t c, const fmpz_mod_ctx_t ctx) noexcept + void fmpz_mod_sub_ui(fmpz_t a, const fmpz_t b, ulong c, const fmpz_mod_ctx_t ctx) noexcept + void fmpz_mod_sub_si(fmpz_t a, const fmpz_t b, slong c, const fmpz_mod_ctx_t ctx) noexcept # Set `a` to `b-c` modulo `n` where only `b` is assumed to be canonical. - void fmpz_mod_fmpz_sub(fmpz_t a, const fmpz_t b, const fmpz_t c, const fmpz_mod_ctx_t ctx) - void fmpz_mod_ui_sub(fmpz_t a, ulong b, const fmpz_t c, const fmpz_mod_ctx_t ctx) - void fmpz_mod_si_sub(fmpz_t a, slong b, const fmpz_t c, const fmpz_mod_ctx_t ctx) + void fmpz_mod_fmpz_sub(fmpz_t a, const fmpz_t b, const fmpz_t c, const fmpz_mod_ctx_t ctx) noexcept + void fmpz_mod_ui_sub(fmpz_t a, ulong b, const fmpz_t c, const fmpz_mod_ctx_t ctx) noexcept + void fmpz_mod_si_sub(fmpz_t a, slong b, const fmpz_t c, const fmpz_mod_ctx_t ctx) noexcept # Set `a` to `b-c` modulo `n` where only `c` is assumed to be canonical. - void fmpz_mod_neg(fmpz_t a, const fmpz_t b, const fmpz_mod_ctx_t ctx) + void fmpz_mod_neg(fmpz_t a, const fmpz_t b, const fmpz_mod_ctx_t ctx) noexcept # Set `a` to `-b` modulo `n`. - void fmpz_mod_mul(fmpz_t a, const fmpz_t b, const fmpz_t c, const fmpz_mod_ctx_t ctx) + void fmpz_mod_mul(fmpz_t a, const fmpz_t b, const fmpz_t c, const fmpz_mod_ctx_t ctx) noexcept # Set `a` to `b\cdot c` modulo `n`. - void fmpz_mod_inv(fmpz_t a, const fmpz_t b, const fmpz_mod_ctx_t ctx) + void fmpz_mod_inv(fmpz_t a, const fmpz_t b, const fmpz_mod_ctx_t ctx) noexcept # Set `a` to `b^{-1}` modulo `n`. # This function expects that `b` is invertible modulo `n` and throws if this not the case. # Invertibility may be tested with :func:`fmpz_mod_pow_fmpz` or :func:`fmpz_mod_divides`. - int fmpz_mod_divides(fmpz_t a, const fmpz_t b, const fmpz_t c, const fmpz_mod_ctx_t ctx) + int fmpz_mod_divides(fmpz_t a, const fmpz_t b, const fmpz_t c, const fmpz_mod_ctx_t ctx) noexcept # If `a\cdot c = b \mod n` has a solution for `a` return `1` and set `a` to such a solution. Otherwise return `0` and leave `a` undefined. - void fmpz_mod_pow_ui(fmpz_t a, const fmpz_t b, ulong e, const fmpz_mod_ctx_t ctx) + void fmpz_mod_pow_ui(fmpz_t a, const fmpz_t b, ulong e, const fmpz_mod_ctx_t ctx) noexcept # Set `a` to `b^e` modulo `n`. - int fmpz_mod_pow_fmpz(fmpz_t a, const fmpz_t b, const fmpz_t e, const fmpz_mod_ctx_t ctx) + int fmpz_mod_pow_fmpz(fmpz_t a, const fmpz_t b, const fmpz_t e, const fmpz_mod_ctx_t ctx) noexcept # Try to set `a` to `b^e` modulo `n`. # If `e < 0` and `b` is not invertible modulo `n`, the return is `0`. Otherwise, the return is `1`. - void fmpz_mod_discrete_log_pohlig_hellman_init(fmpz_mod_discrete_log_pohlig_hellman_t L) + void fmpz_mod_discrete_log_pohlig_hellman_init(fmpz_mod_discrete_log_pohlig_hellman_t L) noexcept # Initialize ``L``. Upon initialization ``L`` is not ready for computation. - void fmpz_mod_discrete_log_pohlig_hellman_clear(fmpz_mod_discrete_log_pohlig_hellman_t L) + void fmpz_mod_discrete_log_pohlig_hellman_clear(fmpz_mod_discrete_log_pohlig_hellman_t L) noexcept # Free any space used by ``L``. - double fmpz_mod_discrete_log_pohlig_hellman_precompute_prime(fmpz_mod_discrete_log_pohlig_hellman_t L, const fmpz_t p) + double fmpz_mod_discrete_log_pohlig_hellman_precompute_prime(fmpz_mod_discrete_log_pohlig_hellman_t L, const fmpz_t p) noexcept # Configure ``L`` for discrete logarithms modulo ``p`` to an internally chosen base. It is assumed that ``p`` is prime. # The return is an estimate on the number of multiplications needed for one run. - const fmpz * fmpz_mod_discrete_log_pohlig_hellman_primitive_root(fmpz_mod_discrete_log_pohlig_hellman_t L) + const fmpz * fmpz_mod_discrete_log_pohlig_hellman_primitive_root(fmpz_mod_discrete_log_pohlig_hellman_t L) noexcept # Return the internally stored base. - void fmpz_mod_discrete_log_pohlig_hellman_run(fmpz_t x, const fmpz_mod_discrete_log_pohlig_hellman_t L, const fmpz_t y) + void fmpz_mod_discrete_log_pohlig_hellman_run(fmpz_t x, const fmpz_mod_discrete_log_pohlig_hellman_t L, const fmpz_t y) noexcept # Set ``x`` to the logarithm of ``y`` with respect to the internally stored base. ``y`` is expected to be reduced modulo the ``p``. # The function is undefined if the logarithm does not exist. - int fmpz_next_smooth_prime(fmpz_t a, const fmpz_t b) + int fmpz_next_smooth_prime(fmpz_t a, const fmpz_t b) noexcept # Either return `1` and set `a` to a smooth prime strictly greater than `b`, or return `0` and set `a` to `0`. # The smooth primes returned by this function currently have no prime factor of `a-1` greater than `23`, but this should not be relied upon. diff --git a/src/sage/libs/flint/fmpz_mod_mat.pxd b/src/sage/libs/flint/fmpz_mod_mat.pxd index 1ef5933f129..cf12ddc1d22 100644 --- a/src/sage/libs/flint/fmpz_mod_mat.pxd +++ b/src/sage/libs/flint/fmpz_mod_mat.pxd @@ -12,176 +12,176 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - fmpz * fmpz_mod_mat_entry(const fmpz_mod_mat_t mat, slong i, slong j) + fmpz * fmpz_mod_mat_entry(const fmpz_mod_mat_t mat, slong i, slong j) noexcept # Return a reference to the element at row ``i`` and column ``j`` of ``mat``. - void fmpz_mod_mat_set_entry(fmpz_mod_mat_t mat, slong i, slong j, const fmpz_t val) + void fmpz_mod_mat_set_entry(fmpz_mod_mat_t mat, slong i, slong j, const fmpz_t val) noexcept # Set the entry at row ``i`` and column ``j`` of ``mat`` to ``val``. - void fmpz_mod_mat_init(fmpz_mod_mat_t mat, slong rows, slong cols, const fmpz_t n) + void fmpz_mod_mat_init(fmpz_mod_mat_t mat, slong rows, slong cols, const fmpz_t n) noexcept # Initialise ``mat`` as a matrix with the given number of ``rows`` and # ``cols`` and modulus ``n``. - void fmpz_mod_mat_init_set(fmpz_mod_mat_t mat, const fmpz_mod_mat_t src) + void fmpz_mod_mat_init_set(fmpz_mod_mat_t mat, const fmpz_mod_mat_t src) noexcept # Initialise ``mat`` and set it equal to the matrix ``src``, including the # number of rows and columns and the modulus. - void fmpz_mod_mat_clear(fmpz_mod_mat_t mat) + void fmpz_mod_mat_clear(fmpz_mod_mat_t mat) noexcept # Clear ``mat`` and release any memory it used. - slong fmpz_mod_mat_nrows(const fmpz_mod_mat_t mat) + slong fmpz_mod_mat_nrows(const fmpz_mod_mat_t mat) noexcept - slong fmpz_mod_mat_ncols(const fmpz_mod_mat_t mat) + slong fmpz_mod_mat_ncols(const fmpz_mod_mat_t mat) noexcept # Return the number of columns of ``mat``. - void _fmpz_mod_mat_set_mod(fmpz_mod_mat_t mat, const fmpz_t n) + void _fmpz_mod_mat_set_mod(fmpz_mod_mat_t mat, const fmpz_t n) noexcept # Set the modulus of the matrix ``mat`` to ``n``. - void fmpz_mod_mat_one(fmpz_mod_mat_t mat) + void fmpz_mod_mat_one(fmpz_mod_mat_t mat) noexcept # Set ``mat`` to the identity matrix (ones down the diagonal). - void fmpz_mod_mat_zero(fmpz_mod_mat_t mat) + void fmpz_mod_mat_zero(fmpz_mod_mat_t mat) noexcept # Set ``mat`` to the zero matrix. - void fmpz_mod_mat_swap(fmpz_mod_mat_t mat1, fmpz_mod_mat_t mat2) + void fmpz_mod_mat_swap(fmpz_mod_mat_t mat1, fmpz_mod_mat_t mat2) noexcept # Efficiently swap the matrices ``mat1`` and ``mat2``. - void fmpz_mod_mat_swap_entrywise(fmpz_mod_mat_t mat1, fmpz_mod_mat_t mat2) + void fmpz_mod_mat_swap_entrywise(fmpz_mod_mat_t mat1, fmpz_mod_mat_t mat2) noexcept # Swaps two matrices by swapping the individual entries rather than swapping # the contents of the structs. - bint fmpz_mod_mat_is_empty(const fmpz_mod_mat_t mat) + bint fmpz_mod_mat_is_empty(const fmpz_mod_mat_t mat) noexcept # Return `1` if ``mat`` has either zero rows or columns. - bint fmpz_mod_mat_is_square(const fmpz_mod_mat_t mat) + bint fmpz_mod_mat_is_square(const fmpz_mod_mat_t mat) noexcept # Return `1` if ``mat`` has the same number of rows and columns. - void _fmpz_mod_mat_reduce(fmpz_mod_mat_t mat) + void _fmpz_mod_mat_reduce(fmpz_mod_mat_t mat) noexcept # Reduce all the entries of ``mat`` by the modulus ``n``. This function is # only needed internally. - void fmpz_mod_mat_randtest(fmpz_mod_mat_t mat, flint_rand_t state) + void fmpz_mod_mat_randtest(fmpz_mod_mat_t mat, flint_rand_t state) noexcept # Generate a random matrix with the existing dimensions and entries in # `[0, n)` where ``n`` is the modulus. - void fmpz_mod_mat_window_init(fmpz_mod_mat_t window, const fmpz_mod_mat_t mat, slong r1, slong c1, slong r2, slong c2) + void fmpz_mod_mat_window_init(fmpz_mod_mat_t window, const fmpz_mod_mat_t mat, slong r1, slong c1, slong r2, slong c2) noexcept # Initializes the matrix ``window`` to be an ``r2 - r1`` by # ``c2 - c1`` submatrix of ``mat`` whose ``(0, 0)`` entry # is the ``(r1, c1)`` entry of ``mat``. The memory for the # elements of ``window`` is shared with ``mat``. - void fmpz_mod_mat_window_clear(fmpz_mod_mat_t window) + void fmpz_mod_mat_window_clear(fmpz_mod_mat_t window) noexcept # Clears the matrix ``window`` and releases any memory that it # uses. Note that the memory to the underlying matrix that # ``window`` points to is not freed. - void fmpz_mod_mat_concat_horizontal(fmpz_mod_mat_t res, const fmpz_mod_mat_t mat1, const fmpz_mod_mat_t mat2) + void fmpz_mod_mat_concat_horizontal(fmpz_mod_mat_t res, const fmpz_mod_mat_t mat1, const fmpz_mod_mat_t mat2) noexcept # Sets ``res`` to vertical concatenation of (``mat1``, ``mat2``) in that order. Matrix dimensions : ``mat1`` : `m \times n`, ``mat2`` : `k \times n`, ``res`` : `(m + k) \times n`. - void fmpz_mod_mat_concat_vertical(fmpz_mod_mat_t res, const fmpz_mod_mat_t mat1, const fmpz_mod_mat_t mat2) + void fmpz_mod_mat_concat_vertical(fmpz_mod_mat_t res, const fmpz_mod_mat_t mat1, const fmpz_mod_mat_t mat2) noexcept # Sets ``res`` to horizontal concatenation of (``mat1``, ``mat2``) # in that order. Matrix dimensions : ``mat1`` : `m \times n`, # ``mat2`` : `m \times k`, ``res`` : `m \times (n + k)`. - void fmpz_mod_mat_print_pretty(const fmpz_mod_mat_t mat) + void fmpz_mod_mat_print_pretty(const fmpz_mod_mat_t mat) noexcept # Prints the given matrix to ``stdout``. The format is an # opening square bracket then on each line a row of the matrix, followed # by a closing square bracket. Each row is written as an opening square # bracket followed by a space separated list of coefficients followed # by a closing square bracket. - bint fmpz_mod_mat_is_zero(const fmpz_mod_mat_t mat) + bint fmpz_mod_mat_is_zero(const fmpz_mod_mat_t mat) noexcept # Return `1` if ``mat`` is the zero matrix. - void fmpz_mod_mat_set(fmpz_mod_mat_t B, const fmpz_mod_mat_t A) + void fmpz_mod_mat_set(fmpz_mod_mat_t B, const fmpz_mod_mat_t A) noexcept # Set ``B`` to equal ``A``. - void fmpz_mod_mat_transpose(fmpz_mod_mat_t B, const fmpz_mod_mat_t A) + void fmpz_mod_mat_transpose(fmpz_mod_mat_t B, const fmpz_mod_mat_t A) noexcept # Set ``B`` to the transpose of ``A``. - void fmpz_mod_mat_set_fmpz_mat(fmpz_mod_mat_t A, const fmpz_mat_t B) + void fmpz_mod_mat_set_fmpz_mat(fmpz_mod_mat_t A, const fmpz_mat_t B) noexcept # Set ``A`` to the matrix ``B`` reducing modulo the modulus of ``A``. - void fmpz_mod_mat_get_fmpz_mat(fmpz_mat_t A, const fmpz_mod_mat_t B) + void fmpz_mod_mat_get_fmpz_mat(fmpz_mat_t A, const fmpz_mod_mat_t B) noexcept # Set ``A`` to a lift of ``B``. - void fmpz_mod_mat_add(fmpz_mod_mat_t C, const fmpz_mod_mat_t A, const fmpz_mod_mat_t B) + void fmpz_mod_mat_add(fmpz_mod_mat_t C, const fmpz_mod_mat_t A, const fmpz_mod_mat_t B) noexcept # Set ``C`` to `A + B`. - void fmpz_mod_mat_sub(fmpz_mod_mat_t C, const fmpz_mod_mat_t A, const fmpz_mod_mat_t B) + void fmpz_mod_mat_sub(fmpz_mod_mat_t C, const fmpz_mod_mat_t A, const fmpz_mod_mat_t B) noexcept # Set ``C`` to `A - B`. - void fmpz_mod_mat_neg(fmpz_mod_mat_t B, const fmpz_mod_mat_t A) + void fmpz_mod_mat_neg(fmpz_mod_mat_t B, const fmpz_mod_mat_t A) noexcept # Set ``B`` to `-A`. - void fmpz_mod_mat_scalar_mul_si(fmpz_mod_mat_t B, const fmpz_mod_mat_t A, slong c) + void fmpz_mod_mat_scalar_mul_si(fmpz_mod_mat_t B, const fmpz_mod_mat_t A, slong c) noexcept # Set ``B`` to `cA` where ``c`` is a constant. - void fmpz_mod_mat_scalar_mul_ui(fmpz_mod_mat_t B, const fmpz_mod_mat_t A, ulong c) + void fmpz_mod_mat_scalar_mul_ui(fmpz_mod_mat_t B, const fmpz_mod_mat_t A, ulong c) noexcept # Set ``B`` to `cA` where ``c`` is a constant. - void fmpz_mod_mat_scalar_mul_fmpz(fmpz_mod_mat_t B, const fmpz_mod_mat_t A, fmpz_t c) + void fmpz_mod_mat_scalar_mul_fmpz(fmpz_mod_mat_t B, const fmpz_mod_mat_t A, fmpz_t c) noexcept # Set ``B`` to `cA` where ``c`` is a constant. - void fmpz_mod_mat_mul(fmpz_mod_mat_t C, const fmpz_mod_mat_t A, const fmpz_mod_mat_t B) + void fmpz_mod_mat_mul(fmpz_mod_mat_t C, const fmpz_mod_mat_t A, const fmpz_mod_mat_t B) noexcept # Set ``C`` to ``A\times B``. The number of rows of ``B`` must match the # number of columns of ``A``. - void _fmpz_mod_mat_mul_classical_threaded_pool_op(fmpz_mod_mat_t D, const fmpz_mod_mat_t C, const fmpz_mod_mat_t A, const fmpz_mod_mat_t B, int op, thread_pool_handle * threads, slong num_threads) + void _fmpz_mod_mat_mul_classical_threaded_pool_op(fmpz_mod_mat_t D, const fmpz_mod_mat_t C, const fmpz_mod_mat_t A, const fmpz_mod_mat_t B, int op, thread_pool_handle * threads, slong num_threads) noexcept # Set ``D`` to ``A\times B + op*C`` where ``op`` is ``+1``, ``-1`` or ``0``. - void _fmpz_mod_mat_mul_classical_threaded_op(fmpz_mod_mat_t D, const fmpz_mod_mat_t C, const fmpz_mod_mat_t A, const fmpz_mod_mat_t B, int op) + void _fmpz_mod_mat_mul_classical_threaded_op(fmpz_mod_mat_t D, const fmpz_mod_mat_t C, const fmpz_mod_mat_t A, const fmpz_mod_mat_t B, int op) noexcept # Set ``D`` to ``A\times B + op*C`` where ``op`` is ``+1``, ``-1`` or ``0``. - void fmpz_mod_mat_mul_classical_threaded(fmpz_mod_mat_t C, const fmpz_mod_mat_t A, const fmpz_mod_mat_t B) + void fmpz_mod_mat_mul_classical_threaded(fmpz_mod_mat_t C, const fmpz_mod_mat_t A, const fmpz_mod_mat_t B) noexcept # Set ``C`` to ``A\times B``. The number of rows of ``B`` must match the # number of columns of ``A``. - void fmpz_mod_mat_sqr(fmpz_mod_mat_t B, const fmpz_mod_mat_t A) + void fmpz_mod_mat_sqr(fmpz_mod_mat_t B, const fmpz_mod_mat_t A) noexcept # Set ``B`` to ``A^2``. The matrix ``A`` must be square. - void fmpz_mod_mat_mul_fmpz_vec(fmpz * c, const fmpz_mod_mat_t A, const fmpz * b, slong blen) - void fmpz_mod_mat_mul_fmpz_vec_ptr(fmpz * const * c, const fmpz_mod_mat_t A, const fmpz * const * b, slong blen) + void fmpz_mod_mat_mul_fmpz_vec(fmpz * c, const fmpz_mod_mat_t A, const fmpz * b, slong blen) noexcept + void fmpz_mod_mat_mul_fmpz_vec_ptr(fmpz * const * c, const fmpz_mod_mat_t A, const fmpz * const * b, slong blen) noexcept # Compute a matrix-vector product of ``A`` and ``(b, blen)`` and store the result in ``c``. # The vector ``(b, blen)`` is either truncated or zero-extended to the number of columns of ``A``. # The number entries written to ``c`` is always equal to the number of rows of ``A``. - void fmpz_mod_mat_fmpz_vec_mul(fmpz * c, const fmpz * a, slong alen, const fmpz_mod_mat_t B) - void fmpz_mod_mat_fmpz_vec_mul_ptr(fmpz * const * c, const fmpz * const * a, slong alen, const fmpz_mod_mat_t B) + void fmpz_mod_mat_fmpz_vec_mul(fmpz * c, const fmpz * a, slong alen, const fmpz_mod_mat_t B) noexcept + void fmpz_mod_mat_fmpz_vec_mul_ptr(fmpz * const * c, const fmpz * const * a, slong alen, const fmpz_mod_mat_t B) noexcept # Compute a vector-matrix product of ``(a, alen)`` and ``B`` and and store the result in ``c``. # The vector ``(a, alen)`` is either truncated or zero-extended to the number of rows of ``B``. # The number entries written to ``c`` is always equal to the number of columns of ``B``. - void fmpz_mod_mat_trace(fmpz_t trace, const fmpz_mod_mat_t mat) + void fmpz_mod_mat_trace(fmpz_t trace, const fmpz_mod_mat_t mat) noexcept # Set ``trace`` to the trace of the matrix ``mat``. - slong fmpz_mod_mat_rref(slong * perm, fmpz_mod_mat_t mat) + slong fmpz_mod_mat_rref(slong * perm, fmpz_mod_mat_t mat) noexcept # Uses Gauss-Jordan elimination to set ``mat`` to its reduced row echelon # form and returns the rank of ``mat``. # If ``perm`` is non-``NULL``, the permutation of # rows in the matrix will also be applied to ``perm``. # The modulus is assumed to be prime. - void fmpz_mod_mat_strong_echelon_form(fmpz_mod_mat_t mat) + void fmpz_mod_mat_strong_echelon_form(fmpz_mod_mat_t mat) noexcept # Transforms `mat` into the strong echelon form of `mat`. The Howell form and the # strong echelon form are equal up to permutation of the rows, see # [FieHof2014]_ for a definition of the strong echelon form and the # algorithm used here. # `mat` must have at least as many rows as columns. - slong fmpz_mod_mat_howell_form(fmpz_mod_mat_t mat) + slong fmpz_mod_mat_howell_form(fmpz_mod_mat_t mat) noexcept # Transforms `mat` into the Howell form of `mat`. For a definition of the # Howell form see [StoMul1998]_. The Howell form is computed by first # putting `mat` into strong echelon form and then ordering the rows. # `mat` must have at least as many rows as columns. - int fmpz_mod_mat_inv(fmpz_mod_mat_t B, fmpz_mod_mat_t A) + int fmpz_mod_mat_inv(fmpz_mod_mat_t B, fmpz_mod_mat_t A) noexcept # Sets `B = A^{-1}` and returns `1` if `A` is invertible. If `A` is singular, # returns `0` and sets the elements of `B` to undefined values. # `A` and `B` must be square matrices with the same dimensions. # The modulus is assumed to be prime. - slong fmpz_mod_mat_lu(slong * P, fmpz_mod_mat_t A, int rank_check) + slong fmpz_mod_mat_lu(slong * P, fmpz_mod_mat_t A, int rank_check) noexcept # Computes a generalised LU decomposition `LU = PA` of a given # matrix `A`, returning the rank of `A`. # If `A` is a nonsingular square matrix, it will be overwritten with @@ -198,7 +198,7 @@ cdef extern from "flint_wrap.h": # if `A` is detected to be rank-deficient. # The modulus is assumed to be prime. - void fmpz_mod_mat_solve_tril(fmpz_mod_mat_t X, const fmpz_mod_mat_t L, const fmpz_mod_mat_t B, int unit) + void fmpz_mod_mat_solve_tril(fmpz_mod_mat_t X, const fmpz_mod_mat_t L, const fmpz_mod_mat_t B, int unit) noexcept # Sets `X = L^{-1} B` where `L` is a full rank lower triangular # square matrix. If ``unit`` = 1, `L` is assumed to have ones on # its main diagonal, and the main diagonal will not be read. `X` @@ -207,7 +207,7 @@ cdef extern from "flint_wrap.h": # recursive algorithms. # The modulus is assumed to be prime. - void fmpz_mod_mat_solve_triu(fmpz_mod_mat_t X, const fmpz_mod_mat_t U, const fmpz_mod_mat_t B, int unit) + void fmpz_mod_mat_solve_triu(fmpz_mod_mat_t X, const fmpz_mod_mat_t U, const fmpz_mod_mat_t B, int unit) noexcept # Sets `X = U^{-1} B` where `U` is a full rank upper triangular # square matrix. If ``unit`` = 1, `U` is assumed to have ones on # its main diagonal, and the main diagonal will not be read. `X` @@ -216,14 +216,14 @@ cdef extern from "flint_wrap.h": # recursive algorithms. # The modulus is assumed to be prime. - int fmpz_mod_mat_solve(fmpz_mod_mat_t X, const fmpz_mod_mat_t A, const fmpz_mod_mat_t B) + int fmpz_mod_mat_solve(fmpz_mod_mat_t X, const fmpz_mod_mat_t A, const fmpz_mod_mat_t B) noexcept # Solves the matrix-matrix equation `AX = B`. # Returns `1` if `A` has full rank; otherwise returns `0` and sets the # elements of `X` to undefined values. # The matrix `A` must be square. # The modulus is assumed to be prime. - int fmpz_mod_mat_can_solve(fmpz_mod_mat_t X, const fmpz_mod_mat_t A, const fmpz_mod_mat_t B) + int fmpz_mod_mat_can_solve(fmpz_mod_mat_t X, const fmpz_mod_mat_t A, const fmpz_mod_mat_t B) noexcept # Solves the matrix-matrix equation `AX = B` over `Fp`. # Returns `1` if a solution exists; otherwise returns `0` and sets the # elements of `X` to zero. If more than one solution exists, one of the @@ -231,7 +231,7 @@ cdef extern from "flint_wrap.h": # There are no restrictions on the shape of `A` and it may be singular. # The modulus is assumed to be prime. - void fmpz_mod_mat_similarity(fmpz_mod_mat_t M, slong r, fmpz_t d) + void fmpz_mod_mat_similarity(fmpz_mod_mat_t M, slong r, fmpz_t d) noexcept # Applies a similarity transform to the `n\times n` matrix `M` in-place. # If `P` is the `n\times n` identity matrix the zero entries of whose row # `r` (`0`-indexed) have been replaced by `d`, this transform is equivalent @@ -242,11 +242,11 @@ cdef extern from "flint_wrap.h": # in the matrix. # The modulus is assumed to be prime. - void fmpz_mod_mat_charpoly(fmpz_mod_poly_t p, const fmpz_mod_mat_t M, const fmpz_mod_ctx_t ctx) + void fmpz_mod_mat_charpoly(fmpz_mod_poly_t p, const fmpz_mod_mat_t M, const fmpz_mod_ctx_t ctx) noexcept # Compute the characteristic polynomial `p` of the matrix `M`. The matrix # is required to be square, otherwise an exception is raised. - void fmpz_mod_mat_minpoly(fmpz_mod_poly_t p, const fmpz_mod_mat_t M, const fmpz_mod_ctx_t ctx) + void fmpz_mod_mat_minpoly(fmpz_mod_poly_t p, const fmpz_mod_mat_t M, const fmpz_mod_ctx_t ctx) noexcept # Compute the minimal polynomial `p` of the matrix `M`. The matrix # is required to be square, otherwise an exception is raised. # The modulus is assumed to be prime. diff --git a/src/sage/libs/flint/fmpz_mod_mpoly.pxd b/src/sage/libs/flint/fmpz_mod_mpoly.pxd index 83053a0e356..087392d781a 100644 --- a/src/sage/libs/flint/fmpz_mod_mpoly.pxd +++ b/src/sage/libs/flint/fmpz_mod_mpoly.pxd @@ -12,276 +12,276 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void fmpz_mod_mpoly_ctx_init(fmpz_mod_mpoly_ctx_t ctx, slong nvars, const ordering_t ord, const fmpz_t p) + void fmpz_mod_mpoly_ctx_init(fmpz_mod_mpoly_ctx_t ctx, slong nvars, const ordering_t ord, const fmpz_t p) noexcept # Initialise a context object for a polynomial ring modulo *n* with *nvars* variables and ordering *ord*. # The possibilities for the ordering are ``ORD_LEX``, ``ORD_DEGLEX`` and ``ORD_DEGREVLEX``. - slong fmpz_mod_mpoly_ctx_nvars(const fmpz_mod_mpoly_ctx_t ctx) + slong fmpz_mod_mpoly_ctx_nvars(const fmpz_mod_mpoly_ctx_t ctx) noexcept # Return the number of variables used to initialize the context. - ordering_t fmpz_mod_mpoly_ctx_ord(const fmpz_mod_mpoly_ctx_t ctx) + ordering_t fmpz_mod_mpoly_ctx_ord(const fmpz_mod_mpoly_ctx_t ctx) noexcept # Return the ordering used to initialize the context. - void fmpz_mod_mpoly_ctx_get_modulus(fmpz_t n, const fmpz_mod_mpoly_ctx_t ctx) + void fmpz_mod_mpoly_ctx_get_modulus(fmpz_t n, const fmpz_mod_mpoly_ctx_t ctx) noexcept # Set *n* to the modulus used to initialize the context. - void fmpz_mod_mpoly_ctx_clear(fmpz_mod_mpoly_ctx_t ctx) + void fmpz_mod_mpoly_ctx_clear(fmpz_mod_mpoly_ctx_t ctx) noexcept # Release up any space allocated by an *ctx*. - void fmpz_mod_mpoly_init(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_ctx_t ctx) + void fmpz_mod_mpoly_init(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_ctx_t ctx) noexcept # Initialise *A* for use with the given an initialised context object. Its value is set to zero. - void fmpz_mod_mpoly_init2(fmpz_mod_mpoly_t A, slong alloc, const fmpz_mod_mpoly_ctx_t ctx) + void fmpz_mod_mpoly_init2(fmpz_mod_mpoly_t A, slong alloc, const fmpz_mod_mpoly_ctx_t ctx) noexcept # Initialise *A* for use with the given an initialised context object. Its value is set to zero. # It is allocated with space for *alloc* terms and at least ``MPOLY_MIN_BITS`` bits for the exponents. - void fmpz_mod_mpoly_init3(fmpz_mod_mpoly_t A, slong alloc, flint_bitcnt_t bits, const fmpz_mod_mpoly_ctx_t ctx) + void fmpz_mod_mpoly_init3(fmpz_mod_mpoly_t A, slong alloc, flint_bitcnt_t bits, const fmpz_mod_mpoly_ctx_t ctx) noexcept # Initialise *A* for use with the given an initialised context object. Its value is set to zero. # It is allocated with space for *alloc* terms and *bits* bits for the exponents. - void fmpz_mod_mpoly_clear(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_ctx_t ctx) + void fmpz_mod_mpoly_clear(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_ctx_t ctx) noexcept # Release any space allocated for *A*. - char * fmpz_mod_mpoly_get_str_pretty(const fmpz_mod_mpoly_t A, const char ** x, const fmpz_mod_mpoly_ctx_t ctx) + char * fmpz_mod_mpoly_get_str_pretty(const fmpz_mod_mpoly_t A, const char ** x, const fmpz_mod_mpoly_ctx_t ctx) noexcept # Return a string, which the user is responsible for cleaning up, representing *A*, given an array of variable strings *x*. - int fmpz_mod_mpoly_fprint_pretty(FILE * file, const fmpz_mod_mpoly_t A, const char ** x, const fmpz_mod_mpoly_ctx_t ctx) + int fmpz_mod_mpoly_fprint_pretty(FILE * file, const fmpz_mod_mpoly_t A, const char ** x, const fmpz_mod_mpoly_ctx_t ctx) noexcept # Print a string representing *A* to *file*. - int fmpz_mod_mpoly_print_pretty(const fmpz_mod_mpoly_t A, const char ** x, const fmpz_mod_mpoly_ctx_t ctx) + int fmpz_mod_mpoly_print_pretty(const fmpz_mod_mpoly_t A, const char ** x, const fmpz_mod_mpoly_ctx_t ctx) noexcept # Print a string representing *A* to ``stdout``. - int fmpz_mod_mpoly_set_str_pretty(fmpz_mod_mpoly_t A, const char * str, const char ** x, const fmpz_mod_mpoly_ctx_t ctx) + int fmpz_mod_mpoly_set_str_pretty(fmpz_mod_mpoly_t A, const char * str, const char ** x, const fmpz_mod_mpoly_ctx_t ctx) noexcept # Set *A* to the polynomial in the null-terminates string *str* given an array *x* of variable strings. # If parsing *str* fails, *A* is set to zero, and `-1` is returned. Otherwise, `0` is returned. # The operations ``+``, ``-``, ``*``, and ``/`` are permitted along with integers and the variables in *x*. The character ``^`` must be immediately followed by the (integer) exponent. # If any division is not exact, parsing fails. - void fmpz_mod_mpoly_gen(fmpz_mod_mpoly_t A, slong var, const fmpz_mod_mpoly_ctx_t ctx) + void fmpz_mod_mpoly_gen(fmpz_mod_mpoly_t A, slong var, const fmpz_mod_mpoly_ctx_t ctx) noexcept # Set *A* to the variable of index *var*, where `var = 0` corresponds to the variable with the most significance with respect to the ordering. - bint fmpz_mod_mpoly_is_gen(const fmpz_mod_mpoly_t A, slong var, const fmpz_mod_mpoly_ctx_t ctx) + bint fmpz_mod_mpoly_is_gen(const fmpz_mod_mpoly_t A, slong var, const fmpz_mod_mpoly_ctx_t ctx) noexcept # If `var \ge 0`, return `1` if *A* is equal to the `var`-th generator, otherwise return `0`. # If `var < 0`, return `1` if the polynomial is equal to any generator, otherwise return `0`. - void fmpz_mod_mpoly_set(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, const fmpz_mod_mpoly_ctx_t ctx) + void fmpz_mod_mpoly_set(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, const fmpz_mod_mpoly_ctx_t ctx) noexcept # Set *A* to *B*. - bint fmpz_mod_mpoly_equal(const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, const fmpz_mod_mpoly_ctx_t ctx) + bint fmpz_mod_mpoly_equal(const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, const fmpz_mod_mpoly_ctx_t ctx) noexcept # Return `1` if *A* is equal to *B*, else return `0`. - void fmpz_mod_mpoly_swap(fmpz_mod_mpoly_t poly1, fmpz_mod_mpoly_t poly2, const fmpz_mod_mpoly_ctx_t ctx) + void fmpz_mod_mpoly_swap(fmpz_mod_mpoly_t poly1, fmpz_mod_mpoly_t poly2, const fmpz_mod_mpoly_ctx_t ctx) noexcept # Efficiently swap *A* and *B*. - bint fmpz_mod_mpoly_is_fmpz(const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_ctx_t ctx) + bint fmpz_mod_mpoly_is_fmpz(const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_ctx_t ctx) noexcept # Return `1` if *A* is a constant, else return `0`. - void fmpz_mod_mpoly_get_fmpz(fmpz_t c, const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_ctx_t ctx) + void fmpz_mod_mpoly_get_fmpz(fmpz_t c, const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_ctx_t ctx) noexcept # Assuming that *A* is a constant, set *c* to this constant. # This function throws if *A* is not a constant. - void fmpz_mod_mpoly_set_fmpz(fmpz_mod_mpoly_t A, const fmpz_t c, const fmpz_mod_mpoly_ctx_t ctx) - void fmpz_mod_mpoly_set_ui(fmpz_mod_mpoly_t A, ulong c, const fmpz_mod_mpoly_ctx_t ctx) - void fmpz_mod_mpoly_set_si(fmpz_mod_mpoly_t A, slong c, const fmpz_mod_mpoly_ctx_t ctx) + void fmpz_mod_mpoly_set_fmpz(fmpz_mod_mpoly_t A, const fmpz_t c, const fmpz_mod_mpoly_ctx_t ctx) noexcept + void fmpz_mod_mpoly_set_ui(fmpz_mod_mpoly_t A, ulong c, const fmpz_mod_mpoly_ctx_t ctx) noexcept + void fmpz_mod_mpoly_set_si(fmpz_mod_mpoly_t A, slong c, const fmpz_mod_mpoly_ctx_t ctx) noexcept # Set *A* to the constant *c*. - void fmpz_mod_mpoly_zero(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_ctx_t ctx) + void fmpz_mod_mpoly_zero(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_ctx_t ctx) noexcept # Set *A* to the constant `0`. - void fmpz_mod_mpoly_one(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_ctx_t ctx) + void fmpz_mod_mpoly_one(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_ctx_t ctx) noexcept # Set *A* to the constant `1`. - bint fmpz_mod_mpoly_equal_fmpz(const fmpz_mod_mpoly_t A, const fmpz_t c, const fmpz_mod_mpoly_ctx_t ctx) - bint fmpz_mod_mpoly_equal_ui(const fmpz_mod_mpoly_t A, ulong c, const fmpz_mod_mpoly_ctx_t ctx) - bint fmpz_mod_mpoly_equal_si(const fmpz_mod_mpoly_t A, slong c, const fmpz_mod_mpoly_ctx_t ctx) + bint fmpz_mod_mpoly_equal_fmpz(const fmpz_mod_mpoly_t A, const fmpz_t c, const fmpz_mod_mpoly_ctx_t ctx) noexcept + bint fmpz_mod_mpoly_equal_ui(const fmpz_mod_mpoly_t A, ulong c, const fmpz_mod_mpoly_ctx_t ctx) noexcept + bint fmpz_mod_mpoly_equal_si(const fmpz_mod_mpoly_t A, slong c, const fmpz_mod_mpoly_ctx_t ctx) noexcept # Return `1` if *A* is equal to the constant *c*, else return `0`. - bint fmpz_mod_mpoly_is_zero(const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_ctx_t ctx) + bint fmpz_mod_mpoly_is_zero(const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_ctx_t ctx) noexcept # Return `1` if *A* is the constant `0`, else return `0`. - bint fmpz_mod_mpoly_is_one(const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_ctx_t ctx) + bint fmpz_mod_mpoly_is_one(const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_ctx_t ctx) noexcept # Return `1` if *A* is the constant `1`, else return `0`. - int fmpz_mod_mpoly_degrees_fit_si(const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_ctx_t ctx) + int fmpz_mod_mpoly_degrees_fit_si(const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_ctx_t ctx) noexcept # Return `1` if the degrees of *A* with respect to each variable fit into an ``slong``, otherwise return `0`. - void fmpz_mod_mpoly_degrees_fmpz(fmpz ** degs, const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_ctx_t ctx) - void fmpz_mod_mpoly_degrees_si(slong * degs, const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_ctx_t ctx) + void fmpz_mod_mpoly_degrees_fmpz(fmpz ** degs, const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_ctx_t ctx) noexcept + void fmpz_mod_mpoly_degrees_si(slong * degs, const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_ctx_t ctx) noexcept # Set *degs* to the degrees of *A* with respect to each variable. # If *A* is zero, all degrees are set to `-1`. - void fmpz_mod_mpoly_degree_fmpz(fmpz_t deg, const fmpz_mod_mpoly_t A, slong var, const fmpz_mod_mpoly_ctx_t ctx) - slong fmpz_mod_mpoly_degree_si(const fmpz_mod_mpoly_t A, slong var, const fmpz_mod_mpoly_ctx_t ctx) + void fmpz_mod_mpoly_degree_fmpz(fmpz_t deg, const fmpz_mod_mpoly_t A, slong var, const fmpz_mod_mpoly_ctx_t ctx) noexcept + slong fmpz_mod_mpoly_degree_si(const fmpz_mod_mpoly_t A, slong var, const fmpz_mod_mpoly_ctx_t ctx) noexcept # Either return or set *deg* to the degree of *A* with respect to the variable of index *var*. # If *A* is zero, the degree is defined to be `-1`. - int fmpz_mod_mpoly_total_degree_fits_si(const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_ctx_t ctx) + int fmpz_mod_mpoly_total_degree_fits_si(const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_ctx_t ctx) noexcept # Return `1` if the total degree of *A* fits into an ``slong``, otherwise return `0`. - void fmpz_mod_mpoly_total_degree_fmpz(fmpz_t tdeg, const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_ctx_t ctx) - slong fmpz_mod_mpoly_total_degree_si(const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_ctx_t ctx) + void fmpz_mod_mpoly_total_degree_fmpz(fmpz_t tdeg, const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_ctx_t ctx) noexcept + slong fmpz_mod_mpoly_total_degree_si(const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_ctx_t ctx) noexcept # Either return or set *tdeg* to the total degree of *A*. # If *A* is zero, the total degree is defined to be `-1`. - void fmpz_mod_mpoly_used_vars(int * used, const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_ctx_t ctx) + void fmpz_mod_mpoly_used_vars(int * used, const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_ctx_t ctx) noexcept # For each variable index *i*, set ``used[i]`` to nonzero if the variable of index *i* appears in *A* and to zero otherwise. - void fmpz_mod_mpoly_get_coeff_fmpz_monomial(fmpz_t c, const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t M, const fmpz_mod_mpoly_ctx_t ctx) + void fmpz_mod_mpoly_get_coeff_fmpz_monomial(fmpz_t c, const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t M, const fmpz_mod_mpoly_ctx_t ctx) noexcept # Assuming that *M* is a monomial, set *c* to the coefficient of the corresponding monomial in *A*. # This function throws if *M* is not a monomial. - void fmpz_mod_mpoly_set_coeff_fmpz_monomial(fmpz_mod_mpoly_t A, const fmpz_t c, const fmpz_mod_mpoly_t M, const fmpz_mod_mpoly_ctx_t ctx) + void fmpz_mod_mpoly_set_coeff_fmpz_monomial(fmpz_mod_mpoly_t A, const fmpz_t c, const fmpz_mod_mpoly_t M, const fmpz_mod_mpoly_ctx_t ctx) noexcept # Assuming that *M* is a monomial, set the coefficient of the corresponding monomial in *A* to *c*. # This function throws if *M* is not a monomial. - void fmpz_mod_mpoly_get_coeff_fmpz_fmpz(fmpz_t c, const fmpz_mod_mpoly_t A, fmpz * const * exp, const fmpz_mod_mpoly_ctx_t ctx) - void fmpz_mod_mpoly_get_coeff_fmpz_ui(fmpz_t c, const fmpz_mod_mpoly_t A, const ulong * exp, const fmpz_mod_mpoly_ctx_t ctx) + void fmpz_mod_mpoly_get_coeff_fmpz_fmpz(fmpz_t c, const fmpz_mod_mpoly_t A, fmpz * const * exp, const fmpz_mod_mpoly_ctx_t ctx) noexcept + void fmpz_mod_mpoly_get_coeff_fmpz_ui(fmpz_t c, const fmpz_mod_mpoly_t A, const ulong * exp, const fmpz_mod_mpoly_ctx_t ctx) noexcept # Set *c* to the coefficient of the monomial with exponent vector *exp*. - void fmpz_mod_mpoly_set_coeff_fmpz_fmpz(fmpz_mod_mpoly_t A, const fmpz_t c, fmpz * const * exp, const fmpz_mod_mpoly_ctx_t ctx) - void fmpz_mod_mpoly_set_coeff_ui_fmpz(fmpz_mod_mpoly_t A, ulong c, fmpz * const * exp, const fmpz_mod_mpoly_ctx_t ctx) - void fmpz_mod_mpoly_set_coeff_si_fmpz(fmpz_mod_mpoly_t A, slong c, fmpz * const * exp, const fmpz_mod_mpoly_ctx_t ctx) - void fmpz_mod_mpoly_set_coeff_fmpz_ui(fmpz_mod_mpoly_t A, const fmpz_t c, const ulong * exp, const fmpz_mod_mpoly_ctx_t ctx) - void fmpz_mod_mpoly_set_coeff_ui_ui(fmpz_mod_mpoly_t A, ulong c, const ulong * exp, const fmpz_mod_mpoly_ctx_t ctx) - void fmpz_mod_mpoly_set_coeff_si_ui(fmpz_mod_mpoly_t A, slong c, const ulong * exp, const fmpz_mod_mpoly_ctx_t ctx) + void fmpz_mod_mpoly_set_coeff_fmpz_fmpz(fmpz_mod_mpoly_t A, const fmpz_t c, fmpz * const * exp, const fmpz_mod_mpoly_ctx_t ctx) noexcept + void fmpz_mod_mpoly_set_coeff_ui_fmpz(fmpz_mod_mpoly_t A, ulong c, fmpz * const * exp, const fmpz_mod_mpoly_ctx_t ctx) noexcept + void fmpz_mod_mpoly_set_coeff_si_fmpz(fmpz_mod_mpoly_t A, slong c, fmpz * const * exp, const fmpz_mod_mpoly_ctx_t ctx) noexcept + void fmpz_mod_mpoly_set_coeff_fmpz_ui(fmpz_mod_mpoly_t A, const fmpz_t c, const ulong * exp, const fmpz_mod_mpoly_ctx_t ctx) noexcept + void fmpz_mod_mpoly_set_coeff_ui_ui(fmpz_mod_mpoly_t A, ulong c, const ulong * exp, const fmpz_mod_mpoly_ctx_t ctx) noexcept + void fmpz_mod_mpoly_set_coeff_si_ui(fmpz_mod_mpoly_t A, slong c, const ulong * exp, const fmpz_mod_mpoly_ctx_t ctx) noexcept # Set the coefficient of the monomial with exponent vector *exp* to *c*. - void fmpz_mod_mpoly_get_coeff_vars_ui(fmpz_mod_mpoly_t C, const fmpz_mod_mpoly_t A, const slong * vars, const ulong * exps, slong length, const fmpz_mod_mpoly_ctx_t ctx) + void fmpz_mod_mpoly_get_coeff_vars_ui(fmpz_mod_mpoly_t C, const fmpz_mod_mpoly_t A, const slong * vars, const ulong * exps, slong length, const fmpz_mod_mpoly_ctx_t ctx) noexcept # Set *C* to the coefficient of *A* with respect to the variables in *vars* with powers in the corresponding array *exps*. # Both *vars* and *exps* point to array of length *length*. It is assumed that `0 < length \le nvars(A)` and that the variables in *vars* are distinct. - int fmpz_mod_mpoly_cmp(const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, const fmpz_mod_mpoly_ctx_t ctx) + int fmpz_mod_mpoly_cmp(const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, const fmpz_mod_mpoly_ctx_t ctx) noexcept # Return `1` (resp. `-1`, or `0`) if *A* is after (resp. before, same as) *B* in some arbitrary but fixed total ordering of the polynomials. # This ordering agrees with the usual ordering of monomials when *A* and *B* are both monomials. - bint fmpz_mod_mpoly_is_canonical(const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_ctx_t ctx) + bint fmpz_mod_mpoly_is_canonical(const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_ctx_t ctx) noexcept # Return `1` if *A* is in canonical form. Otherwise, return `0`. # To be in canonical form, all of the terms must have nonzero coefficient, and the terms must be sorted from greatest to least. - slong fmpz_mod_mpoly_length(const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_ctx_t ctx) + slong fmpz_mod_mpoly_length(const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_ctx_t ctx) noexcept # Return the number of terms in *A*. # If the polynomial is in canonical form, this will be the number of nonzero coefficients. - void fmpz_mod_mpoly_resize(fmpz_mod_mpoly_t A, slong new_length, const fmpz_mod_mpoly_ctx_t ctx) + void fmpz_mod_mpoly_resize(fmpz_mod_mpoly_t A, slong new_length, const fmpz_mod_mpoly_ctx_t ctx) noexcept # Set the length of *A* to ``new_length``. # Terms are either deleted from the end, or new zero terms are appended. - void fmpz_mod_mpoly_get_term_coeff_fmpz(fmpz_t c, const fmpz_mod_mpoly_t A, slong i, const fmpz_mod_mpoly_ctx_t ctx) + void fmpz_mod_mpoly_get_term_coeff_fmpz(fmpz_t c, const fmpz_mod_mpoly_t A, slong i, const fmpz_mod_mpoly_ctx_t ctx) noexcept # Set *c* to the coefficient of the term of index *i*. - void fmpz_mod_mpoly_set_term_coeff_fmpz(fmpz_mod_mpoly_t A, slong i, const fmpz_t c, const fmpz_mod_mpoly_ctx_t ctx) - void fmpz_mod_mpoly_set_term_coeff_ui(fmpz_mod_mpoly_t A, slong i, ulong c, const fmpz_mod_mpoly_ctx_t ctx) - void fmpz_mod_mpoly_set_term_coeff_si(fmpz_mod_mpoly_t A, slong i, slong c, const fmpz_mod_mpoly_ctx_t ctx) + void fmpz_mod_mpoly_set_term_coeff_fmpz(fmpz_mod_mpoly_t A, slong i, const fmpz_t c, const fmpz_mod_mpoly_ctx_t ctx) noexcept + void fmpz_mod_mpoly_set_term_coeff_ui(fmpz_mod_mpoly_t A, slong i, ulong c, const fmpz_mod_mpoly_ctx_t ctx) noexcept + void fmpz_mod_mpoly_set_term_coeff_si(fmpz_mod_mpoly_t A, slong i, slong c, const fmpz_mod_mpoly_ctx_t ctx) noexcept # Set the coefficient of the term of index *i* to *c*. - int fmpz_mod_mpoly_term_exp_fits_si(const fmpz_mod_mpoly_t poly, slong i, const fmpz_mod_mpoly_ctx_t ctx) - int fmpz_mod_mpoly_term_exp_fits_ui(const fmpz_mod_mpoly_t poly, slong i, const fmpz_mod_mpoly_ctx_t ctx) + int fmpz_mod_mpoly_term_exp_fits_si(const fmpz_mod_mpoly_t poly, slong i, const fmpz_mod_mpoly_ctx_t ctx) noexcept + int fmpz_mod_mpoly_term_exp_fits_ui(const fmpz_mod_mpoly_t poly, slong i, const fmpz_mod_mpoly_ctx_t ctx) noexcept # Return `1` if all entries of the exponent vector of the term of index *i* fit into an ``slong`` (resp. a ``ulong``). Otherwise, return `0`. - void fmpz_mod_mpoly_get_term_exp_fmpz(fmpz ** exp, const fmpz_mod_mpoly_t A, slong i, const fmpz_mod_mpoly_ctx_t ctx) - void fmpz_mod_mpoly_get_term_exp_ui(ulong * exp, const fmpz_mod_mpoly_t A, slong i, const fmpz_mod_mpoly_ctx_t ctx) - void fmpz_mod_mpoly_get_term_exp_si(slong * exp, const fmpz_mod_mpoly_t A, slong i, const fmpz_mod_mpoly_ctx_t ctx) + void fmpz_mod_mpoly_get_term_exp_fmpz(fmpz ** exp, const fmpz_mod_mpoly_t A, slong i, const fmpz_mod_mpoly_ctx_t ctx) noexcept + void fmpz_mod_mpoly_get_term_exp_ui(ulong * exp, const fmpz_mod_mpoly_t A, slong i, const fmpz_mod_mpoly_ctx_t ctx) noexcept + void fmpz_mod_mpoly_get_term_exp_si(slong * exp, const fmpz_mod_mpoly_t A, slong i, const fmpz_mod_mpoly_ctx_t ctx) noexcept # Set *exp* to the exponent vector of the term of index *i*. # The ``_ui`` (resp. ``_si``) version throws if any entry does not fit into a ``ulong`` (resp. ``slong``). - ulong fmpz_mod_mpoly_get_term_var_exp_ui(const fmpz_mod_mpoly_t A, slong i, slong var, const fmpz_mod_mpoly_ctx_t ctx) - slong fmpz_mod_mpoly_get_term_var_exp_si(const fmpz_mod_mpoly_t A, slong i, slong var, const fmpz_mod_mpoly_ctx_t ctx) + ulong fmpz_mod_mpoly_get_term_var_exp_ui(const fmpz_mod_mpoly_t A, slong i, slong var, const fmpz_mod_mpoly_ctx_t ctx) noexcept + slong fmpz_mod_mpoly_get_term_var_exp_si(const fmpz_mod_mpoly_t A, slong i, slong var, const fmpz_mod_mpoly_ctx_t ctx) noexcept # Return the exponent of the variable *var* of the term of index *i*. # This function throws if the exponent does not fit into a ``ulong`` (resp. ``slong``). - void fmpz_mod_mpoly_set_term_exp_fmpz(fmpz_mod_mpoly_t A, slong i, fmpz * const * exp, const fmpz_mod_mpoly_ctx_t ctx) - void fmpz_mod_mpoly_set_term_exp_ui(fmpz_mod_mpoly_t A, slong i, const ulong * exp, const fmpz_mod_mpoly_ctx_t ctx) + void fmpz_mod_mpoly_set_term_exp_fmpz(fmpz_mod_mpoly_t A, slong i, fmpz * const * exp, const fmpz_mod_mpoly_ctx_t ctx) noexcept + void fmpz_mod_mpoly_set_term_exp_ui(fmpz_mod_mpoly_t A, slong i, const ulong * exp, const fmpz_mod_mpoly_ctx_t ctx) noexcept # Set the exponent vector of the term of index *i* to *exp*. - void fmpz_mod_mpoly_get_term(fmpz_mod_mpoly_t M, const fmpz_mod_mpoly_t A, slong i, const fmpz_mod_mpoly_ctx_t ctx) + void fmpz_mod_mpoly_get_term(fmpz_mod_mpoly_t M, const fmpz_mod_mpoly_t A, slong i, const fmpz_mod_mpoly_ctx_t ctx) noexcept # Set *M* to the term of index *i* in *A*. - void fmpz_mod_mpoly_get_term_monomial(fmpz_mod_mpoly_t M, const fmpz_mod_mpoly_t A, slong i, const fmpz_mod_mpoly_ctx_t ctx) + void fmpz_mod_mpoly_get_term_monomial(fmpz_mod_mpoly_t M, const fmpz_mod_mpoly_t A, slong i, const fmpz_mod_mpoly_ctx_t ctx) noexcept # Set *M* to the monomial of the term of index *i* in *A*. The coefficient of *M* will be one. - void fmpz_mod_mpoly_push_term_fmpz_fmpz(fmpz_mod_mpoly_t A, const fmpz_t c, fmpz * const * exp, const fmpz_mod_mpoly_ctx_t ctx) - void fmpz_mod_mpoly_push_term_fmpz_ffmpz(fmpz_mod_mpoly_t A, const fmpz_t c, const fmpz * exp, const fmpz_mod_mpoly_ctx_t ctx) - void fmpz_mod_mpoly_push_term_ui_fmpz(fmpz_mod_mpoly_t A, ulong c, fmpz * const * exp, const fmpz_mod_mpoly_ctx_t ctx) - void fmpz_mod_mpoly_push_term_ui_ffmpz(fmpz_mod_mpoly_t A, ulong c, const fmpz * exp, const fmpz_mod_mpoly_ctx_t ctx) - void fmpz_mod_mpoly_push_term_si_fmpz(fmpz_mod_mpoly_t A, slong c, fmpz * const * exp, const fmpz_mod_mpoly_ctx_t ctx) - void fmpz_mod_mpoly_push_term_si_ffmpz(fmpz_mod_mpoly_t A, slong c, const fmpz * exp, const fmpz_mod_mpoly_ctx_t ctx) - void fmpz_mod_mpoly_push_term_fmpz_ui(fmpz_mod_mpoly_t A, const fmpz_t c, const ulong * exp, const fmpz_mod_mpoly_ctx_t ctx) - void fmpz_mod_mpoly_push_term_ui_ui(fmpz_mod_mpoly_t A, ulong c, const ulong * exp, const fmpz_mod_mpoly_ctx_t ctx) - void fmpz_mod_mpoly_push_term_si_ui(fmpz_mod_mpoly_t A, slong c, const ulong * exp, const fmpz_mod_mpoly_ctx_t ctx) + void fmpz_mod_mpoly_push_term_fmpz_fmpz(fmpz_mod_mpoly_t A, const fmpz_t c, fmpz * const * exp, const fmpz_mod_mpoly_ctx_t ctx) noexcept + void fmpz_mod_mpoly_push_term_fmpz_ffmpz(fmpz_mod_mpoly_t A, const fmpz_t c, const fmpz * exp, const fmpz_mod_mpoly_ctx_t ctx) noexcept + void fmpz_mod_mpoly_push_term_ui_fmpz(fmpz_mod_mpoly_t A, ulong c, fmpz * const * exp, const fmpz_mod_mpoly_ctx_t ctx) noexcept + void fmpz_mod_mpoly_push_term_ui_ffmpz(fmpz_mod_mpoly_t A, ulong c, const fmpz * exp, const fmpz_mod_mpoly_ctx_t ctx) noexcept + void fmpz_mod_mpoly_push_term_si_fmpz(fmpz_mod_mpoly_t A, slong c, fmpz * const * exp, const fmpz_mod_mpoly_ctx_t ctx) noexcept + void fmpz_mod_mpoly_push_term_si_ffmpz(fmpz_mod_mpoly_t A, slong c, const fmpz * exp, const fmpz_mod_mpoly_ctx_t ctx) noexcept + void fmpz_mod_mpoly_push_term_fmpz_ui(fmpz_mod_mpoly_t A, const fmpz_t c, const ulong * exp, const fmpz_mod_mpoly_ctx_t ctx) noexcept + void fmpz_mod_mpoly_push_term_ui_ui(fmpz_mod_mpoly_t A, ulong c, const ulong * exp, const fmpz_mod_mpoly_ctx_t ctx) noexcept + void fmpz_mod_mpoly_push_term_si_ui(fmpz_mod_mpoly_t A, slong c, const ulong * exp, const fmpz_mod_mpoly_ctx_t ctx) noexcept # Append a term to *A* with coefficient *c* and exponent vector *exp*. # This function runs in constant average time. - void fmpz_mod_mpoly_sort_terms(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_ctx_t ctx) + void fmpz_mod_mpoly_sort_terms(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_ctx_t ctx) noexcept # Sort the terms of *A* into the canonical ordering dictated by the ordering in *ctx*. # This function simply reorders the terms: It does not combine like terms, nor does it delete terms with coefficient zero. # This function runs in linear time in the size of *A*. - void fmpz_mod_mpoly_combine_like_terms(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_ctx_t ctx) + void fmpz_mod_mpoly_combine_like_terms(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_ctx_t ctx) noexcept # Combine adjacent like terms in *A* and delete terms with coefficient zero. # If the terms of *A* were sorted to begin with, the result will be in canonical form. # This function runs in linear time in the size of *A*. - void fmpz_mod_mpoly_reverse(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, const fmpz_mod_mpoly_ctx_t ctx) + void fmpz_mod_mpoly_reverse(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, const fmpz_mod_mpoly_ctx_t ctx) noexcept # Set *A* to the reversal of *B*. - void fmpz_mod_mpoly_randtest_bound(fmpz_mod_mpoly_t A, flint_rand_t state, slong length, ulong exp_bound, const fmpz_mod_mpoly_ctx_t ctx) + void fmpz_mod_mpoly_randtest_bound(fmpz_mod_mpoly_t A, flint_rand_t state, slong length, ulong exp_bound, const fmpz_mod_mpoly_ctx_t ctx) noexcept # Generate a random polynomial with length up to *length* and exponents in the range ``[0, exp_bound - 1]``. # The exponents of each variable are generated by calls to ``n_randint(state, exp_bound)``. - void fmpz_mod_mpoly_randtest_bounds(fmpz_mod_mpoly_t A, flint_rand_t state, slong length, ulong * exp_bounds, const fmpz_mod_mpoly_ctx_t ctx) + void fmpz_mod_mpoly_randtest_bounds(fmpz_mod_mpoly_t A, flint_rand_t state, slong length, ulong * exp_bounds, const fmpz_mod_mpoly_ctx_t ctx) noexcept # Generate a random polynomial with length up to *length* and exponents in the range ``[0, exp_bounds[i] - 1]``. # The exponents of the variable of index *i* are generated by calls to ``n_randint(state, exp_bounds[i])``. - void fmpz_mod_mpoly_randtest_bits(fmpz_mod_mpoly_t A, flint_rand_t state, slong length, mp_limb_t exp_bits, const fmpz_mod_mpoly_ctx_t ctx) + void fmpz_mod_mpoly_randtest_bits(fmpz_mod_mpoly_t A, flint_rand_t state, slong length, mp_limb_t exp_bits, const fmpz_mod_mpoly_ctx_t ctx) noexcept # Generate a random polynomial with length up to *length* and exponents whose packed form does not exceed the given bit count. - void fmpz_mod_mpoly_add_fmpz(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, const fmpz_t c, const fmpz_mod_mpoly_ctx_t ctx) - void fmpz_mod_mpoly_add_ui(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, ulong c, const fmpz_mod_mpoly_ctx_t ctx) - void fmpz_mod_mpoly_add_si(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, slong c, const fmpz_mod_mpoly_ctx_t ctx) + void fmpz_mod_mpoly_add_fmpz(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, const fmpz_t c, const fmpz_mod_mpoly_ctx_t ctx) noexcept + void fmpz_mod_mpoly_add_ui(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, ulong c, const fmpz_mod_mpoly_ctx_t ctx) noexcept + void fmpz_mod_mpoly_add_si(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, slong c, const fmpz_mod_mpoly_ctx_t ctx) noexcept # Set *A* to `B + c`. - void fmpz_mod_mpoly_sub_fmpz(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, const fmpz_t c, const fmpz_mod_mpoly_ctx_t ctx) - void fmpz_mod_mpoly_sub_ui(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, ulong c, const fmpz_mod_mpoly_ctx_t ctx) - void fmpz_mod_mpoly_sub_si(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, slong c, const fmpz_mod_mpoly_ctx_t ctx) + void fmpz_mod_mpoly_sub_fmpz(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, const fmpz_t c, const fmpz_mod_mpoly_ctx_t ctx) noexcept + void fmpz_mod_mpoly_sub_ui(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, ulong c, const fmpz_mod_mpoly_ctx_t ctx) noexcept + void fmpz_mod_mpoly_sub_si(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, slong c, const fmpz_mod_mpoly_ctx_t ctx) noexcept # Set *A* to `B - c`. - void fmpz_mod_mpoly_add(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, const fmpz_mod_mpoly_t C, const fmpz_mod_mpoly_ctx_t ctx) + void fmpz_mod_mpoly_add(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, const fmpz_mod_mpoly_t C, const fmpz_mod_mpoly_ctx_t ctx) noexcept # Set *A* to `B + C`. - void fmpz_mod_mpoly_sub(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, const fmpz_mod_mpoly_t C, const fmpz_mod_mpoly_ctx_t ctx) + void fmpz_mod_mpoly_sub(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, const fmpz_mod_mpoly_t C, const fmpz_mod_mpoly_ctx_t ctx) noexcept # Set *A* to `B - C`. - void fmpz_mod_mpoly_neg(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, const fmpz_mod_mpoly_ctx_t ctx) + void fmpz_mod_mpoly_neg(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, const fmpz_mod_mpoly_ctx_t ctx) noexcept # Set *A* to `-B`. - void fmpz_mod_mpoly_scalar_mul_fmpz(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, const fmpz_t c, const fmpz_mod_mpoly_ctx_t ctx) - void fmpz_mod_mpoly_scalar_mul_ui(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, ulong c, const fmpz_mod_mpoly_ctx_t ctx) - void fmpz_mod_mpoly_scalar_mul_si(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, slong c, const fmpz_mod_mpoly_ctx_t ctx) + void fmpz_mod_mpoly_scalar_mul_fmpz(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, const fmpz_t c, const fmpz_mod_mpoly_ctx_t ctx) noexcept + void fmpz_mod_mpoly_scalar_mul_ui(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, ulong c, const fmpz_mod_mpoly_ctx_t ctx) noexcept + void fmpz_mod_mpoly_scalar_mul_si(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, slong c, const fmpz_mod_mpoly_ctx_t ctx) noexcept # Set *A* to `B \times c`. - void fmpz_mod_mpoly_scalar_addmul_fmpz(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, const fmpz_mod_mpoly_t C, const fmpz_t d, const fmpz_mod_mpoly_ctx_t ctx) + void fmpz_mod_mpoly_scalar_addmul_fmpz(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, const fmpz_mod_mpoly_t C, const fmpz_t d, const fmpz_mod_mpoly_ctx_t ctx) noexcept # Sets *A* to `B + C \times d`. - void fmpz_mod_mpoly_make_monic(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, const fmpz_mod_mpoly_ctx_t ctx) + void fmpz_mod_mpoly_make_monic(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, const fmpz_mod_mpoly_ctx_t ctx) noexcept # Set *A* to *B* divided by the leading coefficient of *B*. This throws if *B* is zero or the leading coefficient is not invertible. - void fmpz_mod_mpoly_derivative(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, slong var, const fmpz_mod_mpoly_ctx_t ctx) + void fmpz_mod_mpoly_derivative(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, slong var, const fmpz_mod_mpoly_ctx_t ctx) noexcept # Set *A* to the derivative of *B* with respect to the variable of index *var*. - void fmpz_mod_mpoly_evaluate_all_fmpz(fmpz_t eval, const fmpz_mod_mpoly_t A, fmpz * const * vals, const fmpz_mod_mpoly_ctx_t ctx) + void fmpz_mod_mpoly_evaluate_all_fmpz(fmpz_t eval, const fmpz_mod_mpoly_t A, fmpz * const * vals, const fmpz_mod_mpoly_ctx_t ctx) noexcept # Set *ev* to the evaluation of *A* where the variables are replaced by the corresponding elements of the array *vals*. - void fmpz_mod_mpoly_evaluate_one_fmpz(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, slong var, const fmpz_t val, const fmpz_mod_mpoly_ctx_t ctx) + void fmpz_mod_mpoly_evaluate_one_fmpz(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, slong var, const fmpz_t val, const fmpz_mod_mpoly_ctx_t ctx) noexcept # Set *A* to the evaluation of *B* where the variable of index *var* is replaced by *val*. # Return `1` for success and `0` for failure. - int fmpz_mod_mpoly_compose_fmpz_poly(fmpz_poly_t A, const fmpz_mod_mpoly_t B, fmpz_poly_struct * const * C, const fmpz_mod_mpoly_ctx_t ctxB) + int fmpz_mod_mpoly_compose_fmpz_poly(fmpz_poly_t A, const fmpz_mod_mpoly_t B, fmpz_poly_struct * const * C, const fmpz_mod_mpoly_ctx_t ctxB) noexcept # Set *A* to the evaluation of *B* where the variables are replaced by the corresponding elements of the array *C*. # The context object of *B* is *ctxB*. # Return `1` for success and `0` for failure. - int fmpz_mod_mpoly_compose_fmpz_mod_mpoly_geobucket(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, fmpz_mod_mpoly_struct * const * C, const fmpz_mod_mpoly_ctx_t ctxB, const fmpz_mod_mpoly_ctx_t ctxAC) - int fmpz_mod_mpoly_compose_fmpz_mod_mpoly(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, fmpz_mod_mpoly_struct * const * C, const fmpz_mod_mpoly_ctx_t ctxB, const fmpz_mod_mpoly_ctx_t ctxAC) + int fmpz_mod_mpoly_compose_fmpz_mod_mpoly_geobucket(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, fmpz_mod_mpoly_struct * const * C, const fmpz_mod_mpoly_ctx_t ctxB, const fmpz_mod_mpoly_ctx_t ctxAC) noexcept + int fmpz_mod_mpoly_compose_fmpz_mod_mpoly(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, fmpz_mod_mpoly_struct * const * C, const fmpz_mod_mpoly_ctx_t ctxB, const fmpz_mod_mpoly_ctx_t ctxAC) noexcept # Set *A* to the evaluation of *B* where the variables are replaced by the corresponding elements of the array *C*. # Both *A* and the elements of *C* have context object *ctxAC*, while *B* has context object *ctxB*. # The length of the array *C* is the number of variables in *ctxB*. @@ -289,128 +289,128 @@ cdef extern from "flint_wrap.h": # Return `1` for success and `0` for failure. # The main method attempts to perform the calculation using matrices and chooses heuristically between the ``geobucket`` and ``horner`` methods if needed. - void fmpz_mod_mpoly_compose_fmpz_mod_mpoly_gen(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, const slong * c, const fmpz_mod_mpoly_ctx_t ctxB, const fmpz_mod_mpoly_ctx_t ctxAC) + void fmpz_mod_mpoly_compose_fmpz_mod_mpoly_gen(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, const slong * c, const fmpz_mod_mpoly_ctx_t ctxB, const fmpz_mod_mpoly_ctx_t ctxAC) noexcept # Set *A* to the evaluation of *B* where the variable of index *i* in *ctxB* is replaced by the variable of index ``c[i]`` in *ctxAC*. # The length of the array *C* is the number of variables in *ctxB*. # If any ``c[i]`` is negative, the corresponding variable of *B* is replaced by zero. Otherwise, it is expected that ``c[i]`` is less than the number of variables in *ctxAC*. - void fmpz_mod_mpoly_mul(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, const fmpz_mod_mpoly_t C, const fmpz_mod_mpoly_ctx_t ctx) + void fmpz_mod_mpoly_mul(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, const fmpz_mod_mpoly_t C, const fmpz_mod_mpoly_ctx_t ctx) noexcept # Set *A* to `B \times C`. - void fmpz_mod_mpoly_mul_johnson(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, const fmpz_mod_mpoly_t C, const fmpz_mod_mpoly_ctx_t ctx) + void fmpz_mod_mpoly_mul_johnson(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, const fmpz_mod_mpoly_t C, const fmpz_mod_mpoly_ctx_t ctx) noexcept # Set *A* to `B \times C` using Johnson's heap-based method. - int fmpz_mod_mpoly_mul_dense(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, const fmpz_mod_mpoly_t C, const fmpz_mod_mpoly_ctx_t ctx) + int fmpz_mod_mpoly_mul_dense(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, const fmpz_mod_mpoly_t C, const fmpz_mod_mpoly_ctx_t ctx) noexcept # Try to set *A* to `B \times C` using dense arithmetic. # If the return is `0`, the operation was unsuccessful. Otherwise, it was successful and the return is `1`. - int fmpz_mod_mpoly_pow_fmpz(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, const fmpz_t k, const fmpz_mod_mpoly_ctx_t ctx) + int fmpz_mod_mpoly_pow_fmpz(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, const fmpz_t k, const fmpz_mod_mpoly_ctx_t ctx) noexcept # Set *A* to *B* raised to the `k`-th power. # Return `1` for success and `0` for failure. - int fmpz_mod_mpoly_pow_ui(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, ulong k, const fmpz_mod_mpoly_ctx_t ctx) + int fmpz_mod_mpoly_pow_ui(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, ulong k, const fmpz_mod_mpoly_ctx_t ctx) noexcept # Set *A* to *B* raised to the `k`-th power. # Return `1` for success and `0` for failure. - int fmpz_mod_mpoly_divides(fmpz_mod_mpoly_t Q, const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, const fmpz_mod_mpoly_ctx_t ctx) + int fmpz_mod_mpoly_divides(fmpz_mod_mpoly_t Q, const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, const fmpz_mod_mpoly_ctx_t ctx) noexcept # If *A* is divisible by *B*, set *Q* to the exact quotient and return `1`. Otherwise, set *Q* to zero and return `0`. - void fmpz_mod_mpoly_div(fmpz_mod_mpoly_t Q, const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, const fmpz_mod_mpoly_ctx_t ctx) + void fmpz_mod_mpoly_div(fmpz_mod_mpoly_t Q, const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, const fmpz_mod_mpoly_ctx_t ctx) noexcept # Set *Q* to the quotient of *A* by *B*, discarding the remainder. - void fmpz_mod_mpoly_divrem(fmpz_mod_mpoly_t Q, fmpz_mod_mpoly_t R, const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, const fmpz_mod_mpoly_ctx_t ctx) + void fmpz_mod_mpoly_divrem(fmpz_mod_mpoly_t Q, fmpz_mod_mpoly_t R, const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, const fmpz_mod_mpoly_ctx_t ctx) noexcept # Set *Q* and *R* to the quotient and remainder of *A* divided by *B*. - void fmpz_mod_mpoly_divrem_ideal(fmpz_mod_mpoly_struct ** Q, fmpz_mod_mpoly_t R, const fmpz_mod_mpoly_t A, fmpz_mod_mpoly_struct * const * B, slong len, const fmpz_mod_mpoly_ctx_t ctx) + void fmpz_mod_mpoly_divrem_ideal(fmpz_mod_mpoly_struct ** Q, fmpz_mod_mpoly_t R, const fmpz_mod_mpoly_t A, fmpz_mod_mpoly_struct * const * B, slong len, const fmpz_mod_mpoly_ctx_t ctx) noexcept # This function is as per :func:`fmpz_mod_mpoly_divrem` except that it takes an array of divisor polynomials *B* and it returns an array of quotient polynomials *Q*. # The number of divisor (and hence quotient) polynomials, is given by *len*. - void fmpz_mod_mpoly_term_content(fmpz_mod_mpoly_t M, const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_ctx_t ctx) + void fmpz_mod_mpoly_term_content(fmpz_mod_mpoly_t M, const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_ctx_t ctx) noexcept # Set *M* to the GCD of the terms of *A*. # If *A* is zero, *M* will be zero. Otherwise, *M* will be a monomial with coefficient one. - int fmpz_mod_mpoly_content_vars(fmpz_mod_mpoly_t g, const fmpz_mod_mpoly_t A, slong * vars, slong vars_length, const fmpz_mod_mpoly_ctx_t ctx) + int fmpz_mod_mpoly_content_vars(fmpz_mod_mpoly_t g, const fmpz_mod_mpoly_t A, slong * vars, slong vars_length, const fmpz_mod_mpoly_ctx_t ctx) noexcept # Set *g* to the GCD of the coefficients of *A* when viewed as a polynomial in the variables *vars*. # Return `1` for success and `0` for failure. Upon success, *g* will be independent of the variables *vars*. - int fmpz_mod_mpoly_gcd(fmpz_mod_mpoly_t G, const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, const fmpz_mod_mpoly_ctx_t ctx) + int fmpz_mod_mpoly_gcd(fmpz_mod_mpoly_t G, const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, const fmpz_mod_mpoly_ctx_t ctx) noexcept # Try to set *G* to the monic GCD of *A* and *B*. The GCD of zero and zero is defined to be zero. # If the return is `1` the function was successful. Otherwise the return is `0` and *G* is left untouched. - int fmpz_mod_mpoly_gcd_cofactors(fmpz_mod_mpoly_t G, fmpz_mod_mpoly_t Abar, fmpz_mod_mpoly_t Bbar, const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, const fmpz_mod_mpoly_ctx_t ctx) + int fmpz_mod_mpoly_gcd_cofactors(fmpz_mod_mpoly_t G, fmpz_mod_mpoly_t Abar, fmpz_mod_mpoly_t Bbar, const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, const fmpz_mod_mpoly_ctx_t ctx) noexcept # Do the operation of :func:`fmpz_mod_mpoly_gcd` and also compute `Abar = A/G` and `Bbar = B/G` if successful. - int fmpz_mod_mpoly_gcd_brown(fmpz_mod_mpoly_t G, const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, const fmpz_mod_mpoly_ctx_t ctx) - int fmpz_mod_mpoly_gcd_hensel(fmpz_mod_mpoly_t G, const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, const fmpz_mod_mpoly_ctx_t ctx) - int fmpz_mod_mpoly_gcd_subresultant(fmpz_mod_mpoly_t G, const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, const fmpz_mod_mpoly_ctx_t ctx) - int fmpz_mod_mpoly_gcd_zippel(fmpz_mod_mpoly_t G, const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, const fmpz_mod_mpoly_ctx_t ctx) - int fmpz_mod_mpoly_gcd_zippel2(fmpz_mod_mpoly_t G, const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, const fmpz_mod_mpoly_ctx_t ctx) + int fmpz_mod_mpoly_gcd_brown(fmpz_mod_mpoly_t G, const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, const fmpz_mod_mpoly_ctx_t ctx) noexcept + int fmpz_mod_mpoly_gcd_hensel(fmpz_mod_mpoly_t G, const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, const fmpz_mod_mpoly_ctx_t ctx) noexcept + int fmpz_mod_mpoly_gcd_subresultant(fmpz_mod_mpoly_t G, const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, const fmpz_mod_mpoly_ctx_t ctx) noexcept + int fmpz_mod_mpoly_gcd_zippel(fmpz_mod_mpoly_t G, const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, const fmpz_mod_mpoly_ctx_t ctx) noexcept + int fmpz_mod_mpoly_gcd_zippel2(fmpz_mod_mpoly_t G, const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, const fmpz_mod_mpoly_ctx_t ctx) noexcept # Try to set *G* to the GCD of *A* and *B* using various algorithms. - int fmpz_mod_mpoly_resultant(fmpz_mod_mpoly_t R, const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, slong var, const fmpz_mod_mpoly_ctx_t ctx) + int fmpz_mod_mpoly_resultant(fmpz_mod_mpoly_t R, const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, slong var, const fmpz_mod_mpoly_ctx_t ctx) noexcept # Try to set *R* to the resultant of *A* and *B* with respect to the variable of index *var*. - int fmpz_mod_mpoly_discriminant(fmpz_mod_mpoly_t D, const fmpz_mod_mpoly_t A, slong var, const fmpz_mod_mpoly_ctx_t ctx) + int fmpz_mod_mpoly_discriminant(fmpz_mod_mpoly_t D, const fmpz_mod_mpoly_t A, slong var, const fmpz_mod_mpoly_ctx_t ctx) noexcept # Try to set *D* to the discriminant of *A* with respect to the variable of index *var*. - int fmpz_mod_mpoly_sqrt(fmpz_mod_mpoly_t Q, const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_ctx_t ctx) + int fmpz_mod_mpoly_sqrt(fmpz_mod_mpoly_t Q, const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_ctx_t ctx) noexcept # If `Q^2=A` has a solution, set *Q* to a solution and return `1`, otherwise return `0` and set *Q* to zero. - bint fmpz_mod_mpoly_is_square(const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_ctx_t ctx) + bint fmpz_mod_mpoly_is_square(const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_ctx_t ctx) noexcept # Return `1` if *A* is a perfect square, otherwise return `0`. - int fmpz_mod_mpoly_quadratic_root(fmpz_mod_mpoly_t Q, const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, const fmpz_mod_mpoly_ctx_t ctx) + int fmpz_mod_mpoly_quadratic_root(fmpz_mod_mpoly_t Q, const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, const fmpz_mod_mpoly_ctx_t ctx) noexcept # If `Q^2+AQ=B` has a solution, set *Q* to a solution and return `1`, otherwise return `0`. - void fmpz_mod_mpoly_univar_init(fmpz_mod_mpoly_univar_t A, const fmpz_mod_mpoly_ctx_t ctx) + void fmpz_mod_mpoly_univar_init(fmpz_mod_mpoly_univar_t A, const fmpz_mod_mpoly_ctx_t ctx) noexcept # Initialize *A*. - void fmpz_mod_mpoly_univar_clear(fmpz_mod_mpoly_univar_t A, const fmpz_mod_mpoly_ctx_t ctx) + void fmpz_mod_mpoly_univar_clear(fmpz_mod_mpoly_univar_t A, const fmpz_mod_mpoly_ctx_t ctx) noexcept # Clear *A*. - void fmpz_mod_mpoly_univar_swap(fmpz_mod_mpoly_univar_t A, fmpz_mod_mpoly_univar_t B, const fmpz_mod_mpoly_ctx_t ctx) + void fmpz_mod_mpoly_univar_swap(fmpz_mod_mpoly_univar_t A, fmpz_mod_mpoly_univar_t B, const fmpz_mod_mpoly_ctx_t ctx) noexcept # Swap *A* and *B*. - void fmpz_mod_mpoly_to_univar(fmpz_mod_mpoly_univar_t A, const fmpz_mod_mpoly_t B, slong var, const fmpz_mod_mpoly_ctx_t ctx) + void fmpz_mod_mpoly_to_univar(fmpz_mod_mpoly_univar_t A, const fmpz_mod_mpoly_t B, slong var, const fmpz_mod_mpoly_ctx_t ctx) noexcept # Set *A* to a univariate form of *B* by pulling out the variable of index *var*. # The coefficients of *A* will still belong to the content *ctx* but will not depend on the variable of index *var*. - void fmpz_mod_mpoly_from_univar(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_univar_t B, slong var, const fmpz_mod_mpoly_ctx_t ctx) + void fmpz_mod_mpoly_from_univar(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_univar_t B, slong var, const fmpz_mod_mpoly_ctx_t ctx) noexcept # Set *A* to the normal form of *B* by putting in the variable of index *var*. # This function is undefined if the coefficients of *B* depend on the variable of index *var*. - int fmpz_mod_mpoly_univar_degree_fits_si(const fmpz_mod_mpoly_univar_t A, const fmpz_mod_mpoly_ctx_t ctx) + int fmpz_mod_mpoly_univar_degree_fits_si(const fmpz_mod_mpoly_univar_t A, const fmpz_mod_mpoly_ctx_t ctx) noexcept # Return `1` if the degree of *A* with respect to the main variable fits an ``slong``. Otherwise, return `0`. - slong fmpz_mod_mpoly_univar_length(const fmpz_mod_mpoly_univar_t A, const fmpz_mod_mpoly_ctx_t ctx) + slong fmpz_mod_mpoly_univar_length(const fmpz_mod_mpoly_univar_t A, const fmpz_mod_mpoly_ctx_t ctx) noexcept # Return the number of terms in *A* with respect to the main variable. - slong fmpz_mod_mpoly_univar_get_term_exp_si(fmpz_mod_mpoly_univar_t A, slong i, const fmpz_mod_mpoly_ctx_t ctx) + slong fmpz_mod_mpoly_univar_get_term_exp_si(fmpz_mod_mpoly_univar_t A, slong i, const fmpz_mod_mpoly_ctx_t ctx) noexcept # Return the exponent of the term of index *i* of *A*. - void fmpz_mod_mpoly_univar_get_term_coeff(fmpz_mod_mpoly_t c, const fmpz_mod_mpoly_univar_t A, slong i, const fmpz_mod_mpoly_ctx_t ctx) - void fmpz_mod_mpoly_univar_swap_term_coeff(fmpz_mod_mpoly_t c, fmpz_mod_mpoly_univar_t A, slong i, const fmpz_mod_mpoly_ctx_t ctx) + void fmpz_mod_mpoly_univar_get_term_coeff(fmpz_mod_mpoly_t c, const fmpz_mod_mpoly_univar_t A, slong i, const fmpz_mod_mpoly_ctx_t ctx) noexcept + void fmpz_mod_mpoly_univar_swap_term_coeff(fmpz_mod_mpoly_t c, fmpz_mod_mpoly_univar_t A, slong i, const fmpz_mod_mpoly_ctx_t ctx) noexcept # Set (resp. swap) *c* to (resp. with) the coefficient of the term of index *i* of *A*. - void fmpz_mod_mpoly_univar_set_coeff_ui(fmpz_mod_mpoly_univar_t Ax, ulong e, const fmpz_mod_mpoly_t c, const fmpz_mod_mpoly_ctx_t ctx) + void fmpz_mod_mpoly_univar_set_coeff_ui(fmpz_mod_mpoly_univar_t Ax, ulong e, const fmpz_mod_mpoly_t c, const fmpz_mod_mpoly_ctx_t ctx) noexcept # Set the coefficient of `X^e` in *Ax* to *c*. - int fmpz_mod_mpoly_univar_resultant(fmpz_mod_mpoly_t R, const fmpz_mod_mpoly_univar_t Ax, const fmpz_mod_mpoly_univar_t Bx, const fmpz_mod_mpoly_ctx_t ctx) + int fmpz_mod_mpoly_univar_resultant(fmpz_mod_mpoly_t R, const fmpz_mod_mpoly_univar_t Ax, const fmpz_mod_mpoly_univar_t Bx, const fmpz_mod_mpoly_ctx_t ctx) noexcept # Try to set *R* to the resultant of *Ax* and *Bx*. - int fmpz_mod_mpoly_univar_discriminant(fmpz_mod_mpoly_t D, const fmpz_mod_mpoly_univar_t Ax, const fmpz_mod_mpoly_ctx_t ctx) + int fmpz_mod_mpoly_univar_discriminant(fmpz_mod_mpoly_t D, const fmpz_mod_mpoly_univar_t Ax, const fmpz_mod_mpoly_ctx_t ctx) noexcept # Try to set *D* to the discriminant of *Ax*. - void fmpz_mod_mpoly_inflate(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, const fmpz * shift, const fmpz * stride, const fmpz_mod_mpoly_ctx_t ctx) + void fmpz_mod_mpoly_inflate(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, const fmpz * shift, const fmpz * stride, const fmpz_mod_mpoly_ctx_t ctx) noexcept # Apply the function ``e -> shift[v] + stride[v]*e`` to each exponent ``e`` corresponding to the variable ``v``. # It is assumed that each shift and stride is not negative. - void fmpz_mod_mpoly_deflate(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, const fmpz * shift, const fmpz * stride, const fmpz_mod_mpoly_ctx_t ctx) + void fmpz_mod_mpoly_deflate(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, const fmpz * shift, const fmpz * stride, const fmpz_mod_mpoly_ctx_t ctx) noexcept # Apply the function ``e -> (e - shift[v])/stride[v]`` to each exponent ``e`` corresponding to the variable ``v``. # If any ``stride[v]`` is zero, the corresponding numerator ``e - shift[v]`` is assumed to be zero, and the quotient is defined as zero. # This allows the function to undo the operation performed by :func:`fmpz_mod_mpoly_inflate` when possible. - void fmpz_mod_mpoly_deflation(fmpz * shift, fmpz * stride, const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_ctx_t ctx) + void fmpz_mod_mpoly_deflation(fmpz * shift, fmpz * stride, const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_ctx_t ctx) noexcept # For each variable `v` let `S_v` be the set of exponents appearing on `v`. # Set ``shift[v]`` to `\operatorname{min}(S_v)` and set ``stride[v]`` to `\operatorname{gcd}(S-\operatorname{min}(S_v))`. # If *A* is zero, all shifts and strides are set to zero. diff --git a/src/sage/libs/flint/fmpz_mod_mpoly_factor.pxd b/src/sage/libs/flint/fmpz_mod_mpoly_factor.pxd index dd97d23afd4..3e66286235b 100644 --- a/src/sage/libs/flint/fmpz_mod_mpoly_factor.pxd +++ b/src/sage/libs/flint/fmpz_mod_mpoly_factor.pxd @@ -12,36 +12,36 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void fmpz_mod_mpoly_factor_init(fmpz_mod_mpoly_factor_t f, const fmpz_mod_mpoly_ctx_t ctx) + void fmpz_mod_mpoly_factor_init(fmpz_mod_mpoly_factor_t f, const fmpz_mod_mpoly_ctx_t ctx) noexcept # Initialise *f*. - void fmpz_mod_mpoly_factor_clear(fmpz_mod_mpoly_factor_t f, const fmpz_mod_mpoly_ctx_t ctx) + void fmpz_mod_mpoly_factor_clear(fmpz_mod_mpoly_factor_t f, const fmpz_mod_mpoly_ctx_t ctx) noexcept # Clear *f*. - void fmpz_mod_mpoly_factor_swap(fmpz_mod_mpoly_factor_t f, fmpz_mod_mpoly_factor_t g, const fmpz_mod_mpoly_ctx_t ctx) + void fmpz_mod_mpoly_factor_swap(fmpz_mod_mpoly_factor_t f, fmpz_mod_mpoly_factor_t g, const fmpz_mod_mpoly_ctx_t ctx) noexcept # Efficiently swap *f* and *g*. - slong fmpz_mod_mpoly_factor_length(const fmpz_mod_mpoly_factor_t f, const fmpz_mod_mpoly_ctx_t ctx) + slong fmpz_mod_mpoly_factor_length(const fmpz_mod_mpoly_factor_t f, const fmpz_mod_mpoly_ctx_t ctx) noexcept # Return the length of the product in *f*. - void fmpz_mod_mpoly_factor_get_constant_fmpz(fmpz_t c, const fmpz_mod_mpoly_factor_t f, const fmpz_mod_mpoly_ctx_t ctx) + void fmpz_mod_mpoly_factor_get_constant_fmpz(fmpz_t c, const fmpz_mod_mpoly_factor_t f, const fmpz_mod_mpoly_ctx_t ctx) noexcept # Set *c* to the constant of *f*. - void fmpz_mod_mpoly_factor_get_base(fmpz_mod_mpoly_t B, const fmpz_mod_mpoly_factor_t f, slong i, const fmpz_mod_mpoly_ctx_t ctx) - void fmpz_mod_mpoly_factor_swap_base(fmpz_mod_mpoly_t B, fmpz_mod_mpoly_factor_t f, slong i, const fmpz_mod_mpoly_ctx_t ctx) + void fmpz_mod_mpoly_factor_get_base(fmpz_mod_mpoly_t B, const fmpz_mod_mpoly_factor_t f, slong i, const fmpz_mod_mpoly_ctx_t ctx) noexcept + void fmpz_mod_mpoly_factor_swap_base(fmpz_mod_mpoly_t B, fmpz_mod_mpoly_factor_t f, slong i, const fmpz_mod_mpoly_ctx_t ctx) noexcept # Set (resp. swap) *B* to (resp. with) the base of the term of index *i* in *f*. - slong fmpz_mod_mpoly_factor_get_exp_si(fmpz_mod_mpoly_factor_t f, slong i, const fmpz_mod_mpoly_ctx_t ctx) + slong fmpz_mod_mpoly_factor_get_exp_si(fmpz_mod_mpoly_factor_t f, slong i, const fmpz_mod_mpoly_ctx_t ctx) noexcept # Return the exponent of the term of index *i* in *f*. It is assumed to fit an ``slong``. - void fmpz_mod_mpoly_factor_sort(fmpz_mod_mpoly_factor_t f, const fmpz_mod_mpoly_ctx_t ctx) + void fmpz_mod_mpoly_factor_sort(fmpz_mod_mpoly_factor_t f, const fmpz_mod_mpoly_ctx_t ctx) noexcept # Sort the product of *f* first by exponent and then by base. - int fmpz_mod_mpoly_factor_squarefree(fmpz_mod_mpoly_factor_t f, const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_ctx_t ctx) + int fmpz_mod_mpoly_factor_squarefree(fmpz_mod_mpoly_factor_t f, const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_ctx_t ctx) noexcept # Set *f* to a factorization of *A* where the bases are primitive and # pairwise relatively prime. If the product of all irreducible factors with # a given exponent is desired, it is recommended to call :func:`fmpz_mod_mpoly_factor_sort` # and then multiply the bases with the desired exponent. - int fmpz_mod_mpoly_factor(fmpz_mod_mpoly_factor_t f, const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_ctx_t ctx) + int fmpz_mod_mpoly_factor(fmpz_mod_mpoly_factor_t f, const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_ctx_t ctx) noexcept # Set *f* to a factorization of *A* where the bases are irreducible. diff --git a/src/sage/libs/flint/fmpz_mod_poly.pxd b/src/sage/libs/flint/fmpz_mod_poly.pxd index da85a2583fc..17fe637a632 100644 --- a/src/sage/libs/flint/fmpz_mod_poly.pxd +++ b/src/sage/libs/flint/fmpz_mod_poly.pxd @@ -12,26 +12,26 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void fmpz_mod_poly_init(fmpz_mod_poly_t poly, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_init(fmpz_mod_poly_t poly, const fmpz_mod_ctx_t ctx) noexcept # Initialises ``poly`` for use with context ``ctx`` and set it to zero. # A corresponding call to :func:`fmpz_mod_poly_clear` must be made to free the memory used by the polynomial. - void fmpz_mod_poly_init2(fmpz_mod_poly_t poly, slong alloc, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_init2(fmpz_mod_poly_t poly, slong alloc, const fmpz_mod_ctx_t ctx) noexcept # Initialises ``poly`` with space for at least ``alloc`` coefficients # and sets the length to zero. The allocated coefficients are all set to # zero. - void fmpz_mod_poly_clear(fmpz_mod_poly_t poly, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_clear(fmpz_mod_poly_t poly, const fmpz_mod_ctx_t ctx) noexcept # Clears the given polynomial, releasing any memory used. It must # be reinitialised in order to be used again. - void fmpz_mod_poly_realloc(fmpz_mod_poly_t poly, slong alloc, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_realloc(fmpz_mod_poly_t poly, slong alloc, const fmpz_mod_ctx_t ctx) noexcept # Reallocates the given polynomial to have space for ``alloc`` # coefficients. If ``alloc`` is zero the polynomial is cleared # and then reinitialised. If the current length is greater than # ``alloc`` the polynomial is first truncated to length ``alloc``. - void fmpz_mod_poly_fit_length(fmpz_mod_poly_t poly, slong len, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_fit_length(fmpz_mod_poly_t poly, slong len, const fmpz_mod_ctx_t ctx) noexcept # If ``len`` is greater than the number of coefficients currently # allocated, then the polynomial is reallocated to have space for at # least ``len`` coefficients. No data is lost when calling this @@ -41,49 +41,49 @@ cdef extern from "flint_wrap.h": # allocated coefficients when length is larger than the number of # coefficients currently allocated. - void _fmpz_mod_poly_normalise(fmpz_mod_poly_t poly) + void _fmpz_mod_poly_normalise(fmpz_mod_poly_t poly) noexcept # Sets the length of ``poly`` so that the top coefficient is non-zero. # If all coefficients are zero, the length is set to zero. This function # is mainly used internally, as all functions guarantee normalisation. - void _fmpz_mod_poly_set_length(fmpz_mod_poly_t poly, slong len) + void _fmpz_mod_poly_set_length(fmpz_mod_poly_t poly, slong len) noexcept # Demotes the coefficients of ``poly`` beyond ``len`` and sets # the length of ``poly`` to ``len``. - void fmpz_mod_poly_truncate(fmpz_mod_poly_t poly, slong len, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_truncate(fmpz_mod_poly_t poly, slong len, const fmpz_mod_ctx_t ctx) noexcept # If the current length of ``poly`` is greater than ``len``, it # is truncated to have the given length. Discarded coefficients are # not necessarily set to zero. - void fmpz_mod_poly_set_trunc(fmpz_mod_poly_t res, const fmpz_mod_poly_t poly, slong n, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_set_trunc(fmpz_mod_poly_t res, const fmpz_mod_poly_t poly, slong n, const fmpz_mod_ctx_t ctx) noexcept # Notionally truncate ``poly`` to length `n` and set ``res`` to the # result. The result is normalised. - void fmpz_mod_poly_randtest(fmpz_mod_poly_t f, flint_rand_t state, slong len, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_randtest(fmpz_mod_poly_t f, flint_rand_t state, slong len, const fmpz_mod_ctx_t ctx) noexcept # Sets the polynomial~`f` to a random polynomial of length up~``len``. - void fmpz_mod_poly_randtest_irreducible(fmpz_mod_poly_t f, flint_rand_t state, slong len, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_randtest_irreducible(fmpz_mod_poly_t f, flint_rand_t state, slong len, const fmpz_mod_ctx_t ctx) noexcept # Sets the polynomial~`f` to a random irreducible polynomial of length # up~``len``, assuming ``len`` is positive. - void fmpz_mod_poly_randtest_not_zero(fmpz_mod_poly_t f, flint_rand_t state, slong len, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_randtest_not_zero(fmpz_mod_poly_t f, flint_rand_t state, slong len, const fmpz_mod_ctx_t ctx) noexcept # Sets the polynomial~`f` to a random polynomial of length up~``len``, # assuming ``len`` is positive. - void fmpz_mod_poly_randtest_monic(fmpz_mod_poly_t poly, flint_rand_t state, slong len, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_randtest_monic(fmpz_mod_poly_t poly, flint_rand_t state, slong len, const fmpz_mod_ctx_t ctx) noexcept # Generates a random monic polynomial with length ``len``. - void fmpz_mod_poly_randtest_monic_irreducible(fmpz_mod_poly_t poly, flint_rand_t state, slong len, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_randtest_monic_irreducible(fmpz_mod_poly_t poly, flint_rand_t state, slong len, const fmpz_mod_ctx_t ctx) noexcept # Generates a random monic irreducible polynomial with length ``len``. - void fmpz_mod_poly_randtest_monic_primitive(fmpz_mod_poly_t poly, flint_rand_t state, slong len, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_randtest_monic_primitive(fmpz_mod_poly_t poly, flint_rand_t state, slong len, const fmpz_mod_ctx_t ctx) noexcept # Generates a random monic irreducible primitive polynomial with # length ``len``. - void fmpz_mod_poly_randtest_trinomial(fmpz_mod_poly_t poly, flint_rand_t state, slong len, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_randtest_trinomial(fmpz_mod_poly_t poly, flint_rand_t state, slong len, const fmpz_mod_ctx_t ctx) noexcept # Generates a random monic trinomial of length ``len``. - int fmpz_mod_poly_randtest_trinomial_irreducible(fmpz_mod_poly_t poly, flint_rand_t state, slong len, slong max_attempts, const fmpz_mod_ctx_t ctx) + int fmpz_mod_poly_randtest_trinomial_irreducible(fmpz_mod_poly_t poly, flint_rand_t state, slong len, slong max_attempts, const fmpz_mod_ctx_t ctx) noexcept # Attempts to set ``poly`` to a monic irreducible trinomial of # length ``len``. It will generate up to ``max_attempts`` # trinomials in attempt to find an irreducible one. If @@ -91,10 +91,10 @@ cdef extern from "flint_wrap.h": # trinomials until an irreducible one is found. Returns `1` if one # is found and `0` otherwise. - void fmpz_mod_poly_randtest_pentomial(fmpz_mod_poly_t poly, flint_rand_t state, slong len, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_randtest_pentomial(fmpz_mod_poly_t poly, flint_rand_t state, slong len, const fmpz_mod_ctx_t ctx) noexcept # Generates a random monic pentomial of length ``len``. - int fmpz_mod_poly_randtest_pentomial_irreducible(fmpz_mod_poly_t poly, flint_rand_t state, slong len, slong max_attempts, const fmpz_mod_ctx_t ctx) + int fmpz_mod_poly_randtest_pentomial_irreducible(fmpz_mod_poly_t poly, flint_rand_t state, slong len, slong max_attempts, const fmpz_mod_ctx_t ctx) noexcept # Attempts to set ``poly`` to a monic irreducible pentomial of # length ``len``. It will generate up to ``max_attempts`` # pentomials in attempt to find an irreducible one. If @@ -102,114 +102,114 @@ cdef extern from "flint_wrap.h": # pentomials until an irreducible one is found. Returns `1` if one # is found and `0` otherwise. - void fmpz_mod_poly_randtest_sparse_irreducible(fmpz_mod_poly_t poly, flint_rand_t state, slong len, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_randtest_sparse_irreducible(fmpz_mod_poly_t poly, flint_rand_t state, slong len, const fmpz_mod_ctx_t ctx) noexcept # Attempts to set ``poly`` to a sparse, monic irreducible polynomial # with length ``len``. It attempts to find an irreducible # trinomial. If that does not succeed, it attempts to find a # irreducible pentomial. If that fails, then ``poly`` is just # set to a random monic irreducible polynomial. - slong fmpz_mod_poly_degree(const fmpz_mod_poly_t poly, const fmpz_mod_ctx_t ctx) + slong fmpz_mod_poly_degree(const fmpz_mod_poly_t poly, const fmpz_mod_ctx_t ctx) noexcept # Returns the degree of the polynomial. The degree of the zero # polynomial is defined to be `-1`. - slong fmpz_mod_poly_length(const fmpz_mod_poly_t poly, const fmpz_mod_ctx_t ctx) + slong fmpz_mod_poly_length(const fmpz_mod_poly_t poly, const fmpz_mod_ctx_t ctx) noexcept # Returns the length of the polynomial, which is one more than # its degree. - fmpz * fmpz_mod_poly_lead(const fmpz_mod_poly_t poly, const fmpz_mod_ctx_t ctx) + fmpz * fmpz_mod_poly_lead(const fmpz_mod_poly_t poly, const fmpz_mod_ctx_t ctx) noexcept # Returns a pointer to the first leading coefficient of ``poly`` # if this is non-zero, otherwise returns ``NULL``. - void fmpz_mod_poly_set(fmpz_mod_poly_t poly1, const fmpz_mod_poly_t poly2, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_set(fmpz_mod_poly_t poly1, const fmpz_mod_poly_t poly2, const fmpz_mod_ctx_t ctx) noexcept # Sets the polynomial ``poly1`` to the value of ``poly2``. - void fmpz_mod_poly_swap(fmpz_mod_poly_t poly1, fmpz_mod_poly_t poly2, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_swap(fmpz_mod_poly_t poly1, fmpz_mod_poly_t poly2, const fmpz_mod_ctx_t ctx) noexcept # Swaps the two polynomials. This is done efficiently by swapping # pointers rather than individual coefficients. - void fmpz_mod_poly_zero(fmpz_mod_poly_t poly, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_zero(fmpz_mod_poly_t poly, const fmpz_mod_ctx_t ctx) noexcept # Sets ``poly`` to the zero polynomial. - void fmpz_mod_poly_one(fmpz_mod_poly_t poly, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_one(fmpz_mod_poly_t poly, const fmpz_mod_ctx_t ctx) noexcept # Sets ``poly`` to the constant polynomial `1`. - void fmpz_mod_poly_zero_coeffs(fmpz_mod_poly_t poly, slong i, slong j, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_zero_coeffs(fmpz_mod_poly_t poly, slong i, slong j, const fmpz_mod_ctx_t ctx) noexcept # Sets the coefficients of `X^k` for `k \in [i, j)` in the polynomial # to zero. - void fmpz_mod_poly_reverse(fmpz_mod_poly_t res, const fmpz_mod_poly_t poly, slong n, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_reverse(fmpz_mod_poly_t res, const fmpz_mod_poly_t poly, slong n, const fmpz_mod_ctx_t ctx) noexcept # This function considers the polynomial ``poly`` to be of length `n`, # notionally truncating and zero padding if required, and reverses # the result. Since the function normalises its result ``res`` may be # of length less than `n`. - void fmpz_mod_poly_set_ui(fmpz_mod_poly_t f, ulong c, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_set_ui(fmpz_mod_poly_t f, ulong c, const fmpz_mod_ctx_t ctx) noexcept # Sets the polynomial `f` to the constant `c` reduced modulo `p`. - void fmpz_mod_poly_set_fmpz(fmpz_mod_poly_t f, const fmpz_t c, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_set_fmpz(fmpz_mod_poly_t f, const fmpz_t c, const fmpz_mod_ctx_t ctx) noexcept # Sets the polynomial `f` to the constant `c` reduced modulo `p`. - void fmpz_mod_poly_set_fmpz_poly(fmpz_mod_poly_t f, const fmpz_poly_t g, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_set_fmpz_poly(fmpz_mod_poly_t f, const fmpz_poly_t g, const fmpz_mod_ctx_t ctx) noexcept # Sets `f` to `g` reduced modulo `p`, where `p` is the modulus that # is part of the data structure of `f`. - void fmpz_mod_poly_get_fmpz_poly(fmpz_poly_t f, const fmpz_mod_poly_t g, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_get_fmpz_poly(fmpz_poly_t f, const fmpz_mod_poly_t g, const fmpz_mod_ctx_t ctx) noexcept # Sets `f` to `g`. This is done simply by lifting the coefficients # of `g` taking representatives `[0, p) \subset \mathbf{Z}`. - void fmpz_mod_poly_get_nmod_poly(nmod_poly_t f, const fmpz_mod_poly_t g) + void fmpz_mod_poly_get_nmod_poly(nmod_poly_t f, const fmpz_mod_poly_t g) noexcept - void fmpz_mod_poly_set_nmod_poly(fmpz_mod_poly_t f, const nmod_poly_t g) + void fmpz_mod_poly_set_nmod_poly(fmpz_mod_poly_t f, const nmod_poly_t g) noexcept - bint fmpz_mod_poly_equal(const fmpz_mod_poly_t poly1, const fmpz_mod_poly_t poly2, const fmpz_mod_ctx_t ctx) + bint fmpz_mod_poly_equal(const fmpz_mod_poly_t poly1, const fmpz_mod_poly_t poly2, const fmpz_mod_ctx_t ctx) noexcept # Returns non-zero if the two polynomials are equal, otherwise returns zero. - bint fmpz_mod_poly_equal_trunc(const fmpz_mod_poly_t poly1, const fmpz_mod_poly_t poly2, slong n, const fmpz_mod_ctx_t ctx) + bint fmpz_mod_poly_equal_trunc(const fmpz_mod_poly_t poly1, const fmpz_mod_poly_t poly2, slong n, const fmpz_mod_ctx_t ctx) noexcept # Notionally truncates the two polynomials to length `n` and returns non-zero # if the two polynomials are equal, otherwise returns zero. - bint fmpz_mod_poly_is_zero(const fmpz_mod_poly_t poly, const fmpz_mod_ctx_t ctx) + bint fmpz_mod_poly_is_zero(const fmpz_mod_poly_t poly, const fmpz_mod_ctx_t ctx) noexcept # Returns non-zero if the polynomial is zero. - bint fmpz_mod_poly_is_one(const fmpz_mod_poly_t poly, const fmpz_mod_ctx_t ctx) + bint fmpz_mod_poly_is_one(const fmpz_mod_poly_t poly, const fmpz_mod_ctx_t ctx) noexcept # Returns non-zero if the polynomial is the constant `1`. - bint fmpz_mod_poly_is_gen(const fmpz_mod_poly_t poly, const fmpz_mod_ctx_t ctx) + bint fmpz_mod_poly_is_gen(const fmpz_mod_poly_t poly, const fmpz_mod_ctx_t ctx) noexcept # Returns non-zero if the polynomial is the degree `1` polynomial `x`. - void fmpz_mod_poly_set_coeff_fmpz(fmpz_mod_poly_t poly, slong n, const fmpz_t x, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_set_coeff_fmpz(fmpz_mod_poly_t poly, slong n, const fmpz_t x, const fmpz_mod_ctx_t ctx) noexcept # Sets the coefficient of `X^n` in the polynomial to `x`, # assuming `n \geq 0`. - void fmpz_mod_poly_set_coeff_ui(fmpz_mod_poly_t poly, slong n, ulong x, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_set_coeff_ui(fmpz_mod_poly_t poly, slong n, ulong x, const fmpz_mod_ctx_t ctx) noexcept # Sets the coefficient of `X^n` in the polynomial to `x`, # assuming `n \geq 0`. - void fmpz_mod_poly_get_coeff_fmpz(fmpz_t x, const fmpz_mod_poly_t poly, slong n, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_get_coeff_fmpz(fmpz_t x, const fmpz_mod_poly_t poly, slong n, const fmpz_mod_ctx_t ctx) noexcept # Sets `x` to the coefficient of `X^n` in the polynomial, # assuming `n \geq 0`. - void fmpz_mod_poly_set_coeff_mpz(fmpz_mod_poly_t poly, slong n, const mpz_t x, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_set_coeff_mpz(fmpz_mod_poly_t poly, slong n, const mpz_t x, const fmpz_mod_ctx_t ctx) noexcept # Sets the coefficient of `X^n` in the polynomial to `x`, # assuming `n \geq 0`. - void fmpz_mod_poly_get_coeff_mpz(mpz_t x, const fmpz_mod_poly_t poly, slong n, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_get_coeff_mpz(mpz_t x, const fmpz_mod_poly_t poly, slong n, const fmpz_mod_ctx_t ctx) noexcept # Sets `x` to the coefficient of `X^n` in the polynomial, # assuming `n \geq 0`. - void _fmpz_mod_poly_shift_left(fmpz * res, const fmpz * poly, slong len, slong n) + void _fmpz_mod_poly_shift_left(fmpz * res, const fmpz * poly, slong len, slong n) noexcept # Sets ``(res, len + n)`` to ``(poly, len)`` shifted left by # `n` coefficients. # Inserts zero coefficients at the lower end. Assumes that ``len`` # and `n` are positive, and that ``res`` fits ``len + n`` elements. # Supports aliasing between ``res`` and ``poly``. - void fmpz_mod_poly_shift_left(fmpz_mod_poly_t f, const fmpz_mod_poly_t g, slong n, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_shift_left(fmpz_mod_poly_t f, const fmpz_mod_poly_t g, slong n, const fmpz_mod_ctx_t ctx) noexcept # Sets ``res`` to ``poly`` shifted left by `n` coeffs. Zero # coefficients are inserted. - void _fmpz_mod_poly_shift_right(fmpz * res, const fmpz * poly, slong len, slong n) + void _fmpz_mod_poly_shift_right(fmpz * res, const fmpz * poly, slong len, slong n) noexcept # Sets ``(res, len - n)`` to ``(poly, len)`` shifted right by # `n` coefficients. # Assumes that ``len`` and `n` are positive, that ``len > n``, @@ -217,92 +217,92 @@ cdef extern from "flint_wrap.h": # between ``res`` and ``poly``, although in this case the top # coefficients of ``poly`` are not set to zero. - void fmpz_mod_poly_shift_right(fmpz_mod_poly_t f, const fmpz_mod_poly_t g, slong n, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_shift_right(fmpz_mod_poly_t f, const fmpz_mod_poly_t g, slong n, const fmpz_mod_ctx_t ctx) noexcept # Sets ``res`` to ``poly`` shifted right by `n` coefficients. If `n` # is equal to or greater than the current length of ``poly``, ``res`` # is set to the zero polynomial. - void _fmpz_mod_poly_add(fmpz *res, const fmpz *poly1, slong len1, const fmpz *poly2, slong len2, const fmpz_mod_ctx_t ctx) + void _fmpz_mod_poly_add(fmpz *res, const fmpz *poly1, slong len1, const fmpz *poly2, slong len2, const fmpz_mod_ctx_t ctx) noexcept # Sets ``res`` to the sum of ``(poly1, len1)`` and # ``(poly2, len2)``. It is assumed that ``res`` has # sufficient space for the longer of the two polynomials. - void fmpz_mod_poly_add(fmpz_mod_poly_t res, const fmpz_mod_poly_t poly1, const fmpz_mod_poly_t poly2, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_add(fmpz_mod_poly_t res, const fmpz_mod_poly_t poly1, const fmpz_mod_poly_t poly2, const fmpz_mod_ctx_t ctx) noexcept # Sets ``res`` to the sum of ``poly1`` and ``poly2``. - void fmpz_mod_poly_add_series(fmpz_mod_poly_t res, const fmpz_mod_poly_t poly1, const fmpz_mod_poly_t poly2, slong n, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_add_series(fmpz_mod_poly_t res, const fmpz_mod_poly_t poly1, const fmpz_mod_poly_t poly2, slong n, const fmpz_mod_ctx_t ctx) noexcept # Notionally truncate ``poly1`` and ``poly2`` to length `n` and set # ``res`` to the sum. - void _fmpz_mod_poly_sub(fmpz *res, const fmpz *poly1, slong len1, const fmpz *poly2, slong len2, const fmpz_mod_ctx_t ctx) + void _fmpz_mod_poly_sub(fmpz *res, const fmpz *poly1, slong len1, const fmpz *poly2, slong len2, const fmpz_mod_ctx_t ctx) noexcept # Sets ``res`` to ``(poly1, len1)`` minus ``(poly2, len2)``. It # is assumed that ``res`` has sufficient space for the longer of the # two polynomials. - void fmpz_mod_poly_sub(fmpz_mod_poly_t res, const fmpz_mod_poly_t poly1, const fmpz_mod_poly_t poly2, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_sub(fmpz_mod_poly_t res, const fmpz_mod_poly_t poly1, const fmpz_mod_poly_t poly2, const fmpz_mod_ctx_t ctx) noexcept # Sets ``res`` to ``poly1`` minus ``poly2``. - void fmpz_mod_poly_sub_series(fmpz_mod_poly_t res, const fmpz_mod_poly_t poly1, const fmpz_mod_poly_t poly2, slong n, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_sub_series(fmpz_mod_poly_t res, const fmpz_mod_poly_t poly1, const fmpz_mod_poly_t poly2, slong n, const fmpz_mod_ctx_t ctx) noexcept # Notionally truncate ``poly1`` and ``poly2`` to length `n` and set # ``res`` to the difference. - void _fmpz_mod_poly_neg(fmpz *res, const fmpz *poly, slong len, const fmpz_mod_ctx_t ctx) + void _fmpz_mod_poly_neg(fmpz *res, const fmpz *poly, slong len, const fmpz_mod_ctx_t ctx) noexcept # Sets ``(res, len)`` to the negative of ``(poly, len)`` # modulo `p`. - void fmpz_mod_poly_neg(fmpz_mod_poly_t res, const fmpz_mod_poly_t poly, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_neg(fmpz_mod_poly_t res, const fmpz_mod_poly_t poly, const fmpz_mod_ctx_t ctx) noexcept # Sets ``res`` to the negative of ``poly`` modulo `p`. - void _fmpz_mod_poly_scalar_mul_fmpz(fmpz *res, const fmpz *poly, slong len, const fmpz_t x, const fmpz_mod_ctx_t ctx) + void _fmpz_mod_poly_scalar_mul_fmpz(fmpz *res, const fmpz *poly, slong len, const fmpz_t x, const fmpz_mod_ctx_t ctx) noexcept # Sets ``(res, len``) to ``(poly, len)`` multiplied by `x`, # reduced modulo `p`. - void fmpz_mod_poly_scalar_mul_fmpz(fmpz_mod_poly_t res, const fmpz_mod_poly_t poly, const fmpz_t x, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_scalar_mul_fmpz(fmpz_mod_poly_t res, const fmpz_mod_poly_t poly, const fmpz_t x, const fmpz_mod_ctx_t ctx) noexcept # Sets ``res`` to ``poly`` multiplied by `x`. - void fmpz_mod_poly_scalar_addmul_fmpz(fmpz_mod_poly_t rop, const fmpz_mod_poly_t op, const fmpz_t x, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_scalar_addmul_fmpz(fmpz_mod_poly_t rop, const fmpz_mod_poly_t op, const fmpz_t x, const fmpz_mod_ctx_t ctx) noexcept # Adds to ``rop`` the product of ``op`` by the scalar ``x``. - void _fmpz_mod_poly_scalar_div_fmpz(fmpz *res, const fmpz *poly, slong len, const fmpz_t x, const fmpz_mod_ctx_t ctx) + void _fmpz_mod_poly_scalar_div_fmpz(fmpz *res, const fmpz *poly, slong len, const fmpz_t x, const fmpz_mod_ctx_t ctx) noexcept # Sets ``(res, len``) to ``(poly, len)`` divided by `x` (i.e. # multiplied by the inverse of `x \pmod{p}`). The result is reduced modulo # `p`. - void fmpz_mod_poly_scalar_div_fmpz(fmpz_mod_poly_t res, const fmpz_mod_poly_t poly, const fmpz_t x, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_scalar_div_fmpz(fmpz_mod_poly_t res, const fmpz_mod_poly_t poly, const fmpz_t x, const fmpz_mod_ctx_t ctx) noexcept # Sets ``res`` to ``poly`` divided by `x`, (i.e. multiplied by the # inverse of `x \pmod{p}`). The result is reduced modulo `p`. - void _fmpz_mod_poly_mul(fmpz *res, const fmpz *poly1, slong len1, const fmpz *poly2, slong len2, const fmpz_mod_ctx_t ctx) + void _fmpz_mod_poly_mul(fmpz *res, const fmpz *poly1, slong len1, const fmpz *poly2, slong len2, const fmpz_mod_ctx_t ctx) noexcept # Sets ``(res, len1 + len2 - 1)`` to the product of ``(poly1, len1)`` # and ``(poly2, len2)``. Assumes ``len1 >= len2 > 0``. Allows # zero-padding of the two input polynomials. - void fmpz_mod_poly_mul(fmpz_mod_poly_t res, const fmpz_mod_poly_t poly1, const fmpz_mod_poly_t poly2, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_mul(fmpz_mod_poly_t res, const fmpz_mod_poly_t poly1, const fmpz_mod_poly_t poly2, const fmpz_mod_ctx_t ctx) noexcept # Sets ``res`` to the product of ``poly1`` and ``poly2``. - void _fmpz_mod_poly_mullow(fmpz *res, const fmpz *poly1, slong len1, const fmpz *poly2, slong len2, slong n, const fmpz_mod_ctx_t ctx) + void _fmpz_mod_poly_mullow(fmpz *res, const fmpz *poly1, slong len1, const fmpz *poly2, slong len2, slong n, const fmpz_mod_ctx_t ctx) noexcept # Sets ``(res, n)`` to the lowest `n` coefficients of the product of # ``(poly1, len1)`` and ``(poly2, len2)``. # Assumes ``len1 >= len2 > 0`` and ``0 < n <= len1 + len2 - 1``. # Allows for zero-padding in the inputs. Does not support aliasing between # the inputs and the output. - void fmpz_mod_poly_mullow(fmpz_mod_poly_t res, const fmpz_mod_poly_t poly1, const fmpz_mod_poly_t poly2, slong n, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_mullow(fmpz_mod_poly_t res, const fmpz_mod_poly_t poly1, const fmpz_mod_poly_t poly2, slong n, const fmpz_mod_ctx_t ctx) noexcept # Sets ``res`` to the lowest `n` coefficients of the product of # ``poly1`` and ``poly2``. - void _fmpz_mod_poly_sqr(fmpz *res, const fmpz *poly, slong len, const fmpz_mod_ctx_t ctx) + void _fmpz_mod_poly_sqr(fmpz *res, const fmpz *poly, slong len, const fmpz_mod_ctx_t ctx) noexcept # Sets ``res`` to the square of ``poly``. - void fmpz_mod_poly_sqr(fmpz_mod_poly_t res, const fmpz_mod_poly_t poly, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_sqr(fmpz_mod_poly_t res, const fmpz_mod_poly_t poly, const fmpz_mod_ctx_t ctx) noexcept # Computes ``res`` as the square of ``poly``. - void fmpz_mod_poly_mulhigh(fmpz_mod_poly_t res, const fmpz_mod_poly_t poly1, const fmpz_mod_poly_t poly2, slong start, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_mulhigh(fmpz_mod_poly_t res, const fmpz_mod_poly_t poly1, const fmpz_mod_poly_t poly2, slong start, const fmpz_mod_ctx_t ctx) noexcept # Computes the product of ``poly1`` and ``poly2`` and writes the # coefficients from ``start`` onwards into the high coefficients of # ``res``, the remaining coefficients being arbitrary. - void _fmpz_mod_poly_mulmod(fmpz * res, const fmpz * poly1, slong len1, const fmpz * poly2, slong len2, const fmpz * f, slong lenf, const fmpz_mod_ctx_t ctx) + void _fmpz_mod_poly_mulmod(fmpz * res, const fmpz * poly1, slong len1, const fmpz * poly2, slong len2, const fmpz * f, slong lenf, const fmpz_mod_ctx_t ctx) noexcept # Sets ``res, len1 + len2 - 1`` to the remainder of the product of # ``poly1`` and ``poly2`` upon polynomial division by ``f``. # It is required that ``len1 + len2 - lenf > 0``, which is equivalent @@ -310,11 +310,11 @@ cdef extern from "flint_wrap.h": # use ``_fmpz_mod_poly_mul`` instead. # Aliasing of ``f`` and ``res`` is not permitted. - void fmpz_mod_poly_mulmod(fmpz_mod_poly_t res, const fmpz_mod_poly_t poly1, const fmpz_mod_poly_t poly2, const fmpz_mod_poly_t f, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_mulmod(fmpz_mod_poly_t res, const fmpz_mod_poly_t poly1, const fmpz_mod_poly_t poly2, const fmpz_mod_poly_t f, const fmpz_mod_ctx_t ctx) noexcept # Sets ``res`` to the remainder of the product of ``poly1`` and # ``poly2`` upon polynomial division by ``f``. - void _fmpz_mod_poly_mulmod_preinv(fmpz * res, const fmpz * poly1, slong len1, const fmpz * poly2, slong len2, const fmpz * f, slong lenf, const fmpz* finv, slong lenfinv, const fmpz_mod_ctx_t ctx) + void _fmpz_mod_poly_mulmod_preinv(fmpz * res, const fmpz * poly1, slong len1, const fmpz * poly2, slong len2, const fmpz * f, slong lenf, const fmpz* finv, slong lenfinv, const fmpz_mod_ctx_t ctx) noexcept # Sets ``res, len1 + len2 - 1`` to the remainder of the product of # ``poly1`` and ``poly2`` upon polynomial division by ``f``. # It is required that ``finv`` is the inverse of the reverse of ``f`` @@ -324,38 +324,38 @@ cdef extern from "flint_wrap.h": # Otherwise, simply use ``_fmpz_mod_poly_mul`` instead. # Aliasing of ``f`` or ``finv`` and ``res`` is not permitted. - void fmpz_mod_poly_mulmod_preinv(fmpz_mod_poly_t res, const fmpz_mod_poly_t poly1, const fmpz_mod_poly_t poly2, const fmpz_mod_poly_t f, const fmpz_mod_poly_t finv, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_mulmod_preinv(fmpz_mod_poly_t res, const fmpz_mod_poly_t poly1, const fmpz_mod_poly_t poly2, const fmpz_mod_poly_t f, const fmpz_mod_poly_t finv, const fmpz_mod_ctx_t ctx) noexcept # Sets ``res`` to the remainder of the product of ``poly1`` and # ``poly2`` upon polynomial division by ``f``. ``finv`` is the # inverse of the reverse of ``f``. It is required that ``poly1`` and # ``poly2`` are reduced modulo ``f``. - void _fmpz_mod_poly_product_roots_fmpz_vec(fmpz * poly, const fmpz * xs, slong n, const fmpz_mod_ctx_t ctx) + void _fmpz_mod_poly_product_roots_fmpz_vec(fmpz * poly, const fmpz * xs, slong n, const fmpz_mod_ctx_t ctx) noexcept # Sets ``(poly, n + 1)`` to the monic polynomial which is the product # of `(x - x_0)(x - x_1) \cdots (x - x_{n-1})`, the roots `x_i` being # given by ``xs``. It is required that the roots are canonical. # Aliasing of the input and output is not allowed. - void fmpz_mod_poly_product_roots_fmpz_vec(fmpz_mod_poly_t poly, const fmpz * xs, slong n, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_product_roots_fmpz_vec(fmpz_mod_poly_t poly, const fmpz * xs, slong n, const fmpz_mod_ctx_t ctx) noexcept # Sets ``poly`` to the monic polynomial which is the product # of `(x - x_0)(x - x_1) \cdots (x - x_{n-1})`, the roots `x_i` being # given by ``xs``. It is required that the roots are canonical. - int fmpz_mod_poly_find_distinct_nonzero_roots(fmpz * roots, const fmpz_mod_poly_t A, const fmpz_mod_ctx_t ctx) + int fmpz_mod_poly_find_distinct_nonzero_roots(fmpz * roots, const fmpz_mod_poly_t A, const fmpz_mod_ctx_t ctx) noexcept # If ``A`` has `\deg(A)` distinct nonzero roots in `\mathbb{F}_p`, write these roots out to ``roots[0]`` to ``roots[deg(A) - 1]`` and return ``1``. # Otherwise, return ``0``. It is assumed that ``A`` is nonzero and that the modulus of ``A`` is prime. # This function uses Rabin's probabilistic method via gcd's with `(x + \delta)^{\frac{p-1}{2}} - 1`. - void _fmpz_mod_poly_pow(fmpz *rop, const fmpz *op, slong len, ulong e, const fmpz_mod_ctx_t ctx) + void _fmpz_mod_poly_pow(fmpz *rop, const fmpz *op, slong len, ulong e, const fmpz_mod_ctx_t ctx) noexcept # Sets ``rop = poly^e``, assuming that `e > 1` and ``elen > 0``, # and that ``res`` has space for ``e*(len - 1) + 1`` coefficients. # Does not support aliasing. - void fmpz_mod_poly_pow(fmpz_mod_poly_t rop, const fmpz_mod_poly_t op, ulong e, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_pow(fmpz_mod_poly_t rop, const fmpz_mod_poly_t op, ulong e, const fmpz_mod_ctx_t ctx) noexcept # Computes ``rop = poly^e``. If `e` is zero, returns one, # so that in particular ``0^0 = 1``. - void _fmpz_mod_poly_pow_trunc(fmpz * res, const fmpz * poly, ulong e, slong trunc, const fmpz_mod_ctx_t ctx) + void _fmpz_mod_poly_pow_trunc(fmpz * res, const fmpz * poly, ulong e, slong trunc, const fmpz_mod_ctx_t ctx) noexcept # Sets ``res`` to the low ``trunc`` coefficients of ``poly`` # (assumed to be zero padded if necessary to length ``trunc``) to # the power ``e``. This is equivalent to doing a powering followed @@ -363,12 +363,12 @@ cdef extern from "flint_wrap.h": # ``trunc`` coefficients, that ``trunc > 0`` and that # ``e > 1``. Aliasing is not permitted. - void fmpz_mod_poly_pow_trunc(fmpz_mod_poly_t res, const fmpz_mod_poly_t poly, ulong e, slong trunc, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_pow_trunc(fmpz_mod_poly_t res, const fmpz_mod_poly_t poly, ulong e, slong trunc, const fmpz_mod_ctx_t ctx) noexcept # Sets ``res`` to the low ``trunc`` coefficients of ``poly`` # to the power ``e``. This is equivalent to doing a powering # followed by a truncation. - void _fmpz_mod_poly_pow_trunc_binexp(fmpz * res, const fmpz * poly, ulong e, slong trunc, const fmpz_mod_ctx_t ctx) + void _fmpz_mod_poly_pow_trunc_binexp(fmpz * res, const fmpz * poly, ulong e, slong trunc, const fmpz_mod_ctx_t ctx) noexcept # Sets ``res`` to the low ``trunc`` coefficients of ``poly`` # (assumed to be zero padded if necessary to length ``trunc``) to # the power ``e``. This is equivalent to doing a powering followed @@ -377,12 +377,12 @@ cdef extern from "flint_wrap.h": # ``e > 1``. Aliasing is not permitted. Uses the binary # exponentiation method. - void fmpz_mod_poly_pow_trunc_binexp(fmpz_mod_poly_t res, const fmpz_mod_poly_t poly, ulong e, slong trunc, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_pow_trunc_binexp(fmpz_mod_poly_t res, const fmpz_mod_poly_t poly, ulong e, slong trunc, const fmpz_mod_ctx_t ctx) noexcept # Sets ``res`` to the low ``trunc`` coefficients of ``poly`` # to the power ``e``. This is equivalent to doing a powering # followed by a truncation. Uses the binary exponentiation method. - void _fmpz_mod_poly_powmod_ui_binexp(fmpz * res, const fmpz * poly, ulong e, const fmpz * f, slong lenf, const fmpz_mod_ctx_t ctx) + void _fmpz_mod_poly_powmod_ui_binexp(fmpz * res, const fmpz * poly, ulong e, const fmpz * f, slong lenf, const fmpz_mod_ctx_t ctx) noexcept # Sets ``res`` to ``poly`` raised to the power ``e`` # modulo ``f``, using binary exponentiation. We require ``e > 0``. # We require ``lenf > 1``. It is assumed that ``poly`` is already @@ -390,11 +390,11 @@ cdef extern from "flint_wrap.h": # exactly ``lenf - 1``. The output ``res`` must have room for # ``lenf - 1`` coefficients. - void fmpz_mod_poly_powmod_ui_binexp(fmpz_mod_poly_t res, const fmpz_mod_poly_t poly, ulong e, const fmpz_mod_poly_t f, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_powmod_ui_binexp(fmpz_mod_poly_t res, const fmpz_mod_poly_t poly, ulong e, const fmpz_mod_poly_t f, const fmpz_mod_ctx_t ctx) noexcept # Sets ``res`` to ``poly`` raised to the power ``e`` # modulo ``f``, using binary exponentiation. We require ``e >= 0``. - void _fmpz_mod_poly_powmod_ui_binexp_preinv(fmpz * res, const fmpz * poly, ulong e, const fmpz * f, slong lenf, const fmpz * finv, slong lenfinv, const fmpz_mod_ctx_t ctx) + void _fmpz_mod_poly_powmod_ui_binexp_preinv(fmpz * res, const fmpz * poly, ulong e, const fmpz * f, slong lenf, const fmpz * finv, slong lenfinv, const fmpz_mod_ctx_t ctx) noexcept # Sets ``res`` to ``poly`` raised to the power ``e`` # modulo ``f``, using binary exponentiation. We require ``e > 0``. # We require ``finv`` to be the inverse of the reverse of ``f``. @@ -403,12 +403,12 @@ cdef extern from "flint_wrap.h": # exactly ``lenf - 1``. The output ``res`` must have room for # ``lenf - 1`` coefficients. - void fmpz_mod_poly_powmod_ui_binexp_preinv(fmpz_mod_poly_t res, const fmpz_mod_poly_t poly, ulong e, const fmpz_mod_poly_t f, const fmpz_mod_poly_t finv, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_powmod_ui_binexp_preinv(fmpz_mod_poly_t res, const fmpz_mod_poly_t poly, ulong e, const fmpz_mod_poly_t f, const fmpz_mod_poly_t finv, const fmpz_mod_ctx_t ctx) noexcept # Sets ``res`` to ``poly`` raised to the power ``e`` # modulo ``f``, using binary exponentiation. We require ``e >= 0``. # We require ``finv`` to be the inverse of the reverse of ``f``. - void _fmpz_mod_poly_powmod_fmpz_binexp(fmpz * res, const fmpz * poly, const fmpz_t e, const fmpz * f, slong lenf, const fmpz_mod_ctx_t ctx) + void _fmpz_mod_poly_powmod_fmpz_binexp(fmpz * res, const fmpz * poly, const fmpz_t e, const fmpz * f, slong lenf, const fmpz_mod_ctx_t ctx) noexcept # Sets ``res`` to ``poly`` raised to the power ``e`` # modulo ``f``, using binary exponentiation. We require ``e > 0``. # We require ``lenf > 1``. It is assumed that ``poly`` is already @@ -416,11 +416,11 @@ cdef extern from "flint_wrap.h": # exactly ``lenf - 1``. The output ``res`` must have room for # ``lenf - 1`` coefficients. - void fmpz_mod_poly_powmod_fmpz_binexp(fmpz_mod_poly_t res, const fmpz_mod_poly_t poly, const fmpz_t e, const fmpz_mod_poly_t f, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_powmod_fmpz_binexp(fmpz_mod_poly_t res, const fmpz_mod_poly_t poly, const fmpz_t e, const fmpz_mod_poly_t f, const fmpz_mod_ctx_t ctx) noexcept # Sets ``res`` to ``poly`` raised to the power ``e`` # modulo ``f``, using binary exponentiation. We require ``e >= 0``. - void _fmpz_mod_poly_powmod_fmpz_binexp_preinv(fmpz * res, const fmpz * poly, const fmpz_t e, const fmpz * f, slong lenf, const fmpz* finv, slong lenfinv, const fmpz_mod_ctx_t ctx) + void _fmpz_mod_poly_powmod_fmpz_binexp_preinv(fmpz * res, const fmpz * poly, const fmpz_t e, const fmpz * f, slong lenf, const fmpz* finv, slong lenfinv, const fmpz_mod_ctx_t ctx) noexcept # Sets ``res`` to ``poly`` raised to the power ``e`` # modulo ``f``, using binary exponentiation. We require ``e > 0``. # We require ``finv`` to be the inverse of the reverse of ``f``. @@ -429,25 +429,25 @@ cdef extern from "flint_wrap.h": # exactly ``lenf - 1``. The output ``res`` must have room for # ``lenf - 1`` coefficients. - void fmpz_mod_poly_powmod_fmpz_binexp_preinv(fmpz_mod_poly_t res, const fmpz_mod_poly_t poly, const fmpz_t e, const fmpz_mod_poly_t f, const fmpz_mod_poly_t finv, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_powmod_fmpz_binexp_preinv(fmpz_mod_poly_t res, const fmpz_mod_poly_t poly, const fmpz_t e, const fmpz_mod_poly_t f, const fmpz_mod_poly_t finv, const fmpz_mod_ctx_t ctx) noexcept # Sets ``res`` to ``poly`` raised to the power ``e`` # modulo ``f``, using binary exponentiation. We require ``e >= 0``. # We require ``finv`` to be the inverse of the reverse of ``f``. - void _fmpz_mod_poly_powmod_x_fmpz_preinv(fmpz * res, const fmpz_t e, const fmpz * f, slong lenf, const fmpz* finv, slong lenfinv, const fmpz_mod_ctx_t ctx) + void _fmpz_mod_poly_powmod_x_fmpz_preinv(fmpz * res, const fmpz_t e, const fmpz * f, slong lenf, const fmpz* finv, slong lenfinv, const fmpz_mod_ctx_t ctx) noexcept # Sets ``res`` to ``x`` raised to the power ``e`` modulo ``f``, # using sliding window exponentiation. We require ``e > 0``. # We require ``finv`` to be the inverse of the reverse of ``f``. # We require ``lenf > 2``. The output ``res`` must have room for # ``lenf - 1`` coefficients. - void fmpz_mod_poly_powmod_x_fmpz_preinv(fmpz_mod_poly_t res, const fmpz_t e, const fmpz_mod_poly_t f, const fmpz_mod_poly_t finv, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_powmod_x_fmpz_preinv(fmpz_mod_poly_t res, const fmpz_t e, const fmpz_mod_poly_t f, const fmpz_mod_poly_t finv, const fmpz_mod_ctx_t ctx) noexcept # Sets ``res`` to ``x`` raised to the power ``e`` # modulo ``f``, using sliding window exponentiation. We require # ``e >= 0``. We require ``finv`` to be the inverse of the reverse of # `` - void _fmpz_mod_poly_powers_mod_preinv_naive(fmpz ** res, const fmpz * f, slong flen, slong n, const fmpz * g, slong glen, const fmpz * ginv, slong ginvlen, const fmpz_mod_ctx_t ctx) + void _fmpz_mod_poly_powers_mod_preinv_naive(fmpz ** res, const fmpz * f, slong flen, slong n, const fmpz * g, slong glen, const fmpz * ginv, slong ginvlen, const fmpz_mod_ctx_t ctx) noexcept # Compute ``f^0, f^1, ..., f^(n-1) mod g``, where ``g`` has length ``glen`` # and ``f`` is reduced mod ``g`` and has length ``flen`` (possibly zero # spaced). Assumes ``res`` is an array of ``n`` arrays each with space for @@ -455,12 +455,12 @@ cdef extern from "flint_wrap.h": # ``ginv`` of length ``ginvlen`` is set to the power series inverse of the # reverse of ``g``. - void fmpz_mod_poly_powers_mod_naive(fmpz_mod_poly_struct * res, const fmpz_mod_poly_t f, slong n, const fmpz_mod_poly_t g, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_powers_mod_naive(fmpz_mod_poly_struct * res, const fmpz_mod_poly_t f, slong n, const fmpz_mod_poly_t g, const fmpz_mod_ctx_t ctx) noexcept # Set the entries of the array ``res`` to ``f^0, f^1, ..., f^(n-1) mod g``. # No aliasing is permitted between the entries of ``res`` and either of the # inputs. - void _fmpz_mod_poly_powers_mod_preinv_threaded_pool(fmpz ** res, const fmpz * f, slong flen, slong n, const fmpz * g, slong glen, const fmpz * ginv, slong ginvlen, const fmpz_mod_ctx_t p, thread_pool_handle * threads, slong num_threads) + void _fmpz_mod_poly_powers_mod_preinv_threaded_pool(fmpz ** res, const fmpz * f, slong flen, slong n, const fmpz * g, slong glen, const fmpz * ginv, slong ginvlen, const fmpz_mod_ctx_t p, thread_pool_handle * threads, slong num_threads) noexcept # Compute ``f^0, f^1, ..., f^(n-1) mod g``, where ``g`` has length ``glen`` # and ``f`` is reduced mod ``g`` and has length ``flen`` (possibly zero # spaced). Assumes ``res`` is an array of ``n`` arrays each with space for @@ -468,12 +468,12 @@ cdef extern from "flint_wrap.h": # ``ginv`` of length ``ginvlen`` is set to the power series inverse of the # reverse of ``g``. - void fmpz_mod_poly_powers_mod_bsgs(fmpz_mod_poly_struct * res, const fmpz_mod_poly_t f, slong n, const fmpz_mod_poly_t g, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_powers_mod_bsgs(fmpz_mod_poly_struct * res, const fmpz_mod_poly_t f, slong n, const fmpz_mod_poly_t g, const fmpz_mod_ctx_t ctx) noexcept # Set the entries of the array ``res`` to ``f^0, f^1, ..., f^(n-1) mod g``. # No aliasing is permitted between the entries of ``res`` and either of the # inputs. - void fmpz_mod_poly_frobenius_powers_2exp_precomp(fmpz_mod_poly_frobenius_powers_2exp_t pow, const fmpz_mod_poly_t f, const fmpz_mod_poly_t finv, ulong m, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_frobenius_powers_2exp_precomp(fmpz_mod_poly_frobenius_powers_2exp_t pow, const fmpz_mod_poly_t f, const fmpz_mod_poly_t finv, ulong m, const fmpz_mod_ctx_t ctx) noexcept # If ``p = f->p``, compute `x^{(p^1)}`, `x^{(p^2)}`, `x^{(p^4)}`, ..., # `x^{(p^{(2^l)})} \pmod{f}` where `2^l` is the greatest power of `2` less than # or equal to `m`. @@ -481,11 +481,11 @@ cdef extern from "flint_wrap.h": # using :func:`fmpz_mod_poly_frobenius_power`. # Requires precomputed inverse of `f`, i.e. newton inverse. - void fmpz_mod_poly_frobenius_powers_2exp_clear(fmpz_mod_poly_frobenius_powers_2exp_t pow, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_frobenius_powers_2exp_clear(fmpz_mod_poly_frobenius_powers_2exp_t pow, const fmpz_mod_ctx_t ctx) noexcept # Clear resources used by the ``fmpz_mod_poly_frobenius_powers_2exp_t`` # struct. - void fmpz_mod_poly_frobenius_power(fmpz_mod_poly_t res, fmpz_mod_poly_frobenius_powers_2exp_t pow, const fmpz_mod_poly_t f, ulong m, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_frobenius_power(fmpz_mod_poly_t res, fmpz_mod_poly_frobenius_powers_2exp_t pow, const fmpz_mod_poly_t f, ulong m, const fmpz_mod_ctx_t ctx) noexcept # If ``p = f->p``, compute `x^{(p^m)} \pmod{f}`. # Requires precomputed frobenius powers supplied by # ``fmpz_mod_poly_frobenius_powers_2exp_precomp``. @@ -493,16 +493,16 @@ cdef extern from "flint_wrap.h": # However an impossible inverse by the leading coefficient of `f` will have # been caught by ``fmpz_mod_poly_frobenius_powers_2exp_precomp``. - void fmpz_mod_poly_frobenius_powers_precomp(fmpz_mod_poly_frobenius_powers_t pow, const fmpz_mod_poly_t f, const fmpz_mod_poly_t finv, ulong m, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_frobenius_powers_precomp(fmpz_mod_poly_frobenius_powers_t pow, const fmpz_mod_poly_t f, const fmpz_mod_poly_t finv, ulong m, const fmpz_mod_ctx_t ctx) noexcept # If ``p = f->p``, compute `x^{(p^0)}`, `x^{(p^1)}`, `x^{(p^2)}`, `x^{(p^3)}`, # ..., `x^{(p^m)} \pmod{f}`. # Requires precomputed inverse of `f`, i.e. newton inverse. - void fmpz_mod_poly_frobenius_powers_clear(fmpz_mod_poly_frobenius_powers_t pow, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_frobenius_powers_clear(fmpz_mod_poly_frobenius_powers_t pow, const fmpz_mod_ctx_t ctx) noexcept # Clear resources used by the ``fmpz_mod_poly_frobenius_powers_t`` # struct. - void _fmpz_mod_poly_divrem_basecase(fmpz * Q, fmpz * R, const fmpz * A, slong lenA, const fmpz * B, slong lenB, const fmpz_t invB, const fmpz_mod_ctx_t ctx) + void _fmpz_mod_poly_divrem_basecase(fmpz * Q, fmpz * R, const fmpz * A, slong lenA, const fmpz * B, slong lenB, const fmpz_t invB, const fmpz_mod_ctx_t ctx) noexcept # Computes ``(Q, lenA - lenB + 1)``, ``(R, lenA)`` such that # `A = B Q + R` with `0 \leq \operatorname{len}(R) < \operatorname{len}(B)`. # Assumes that the leading coefficient of `B` is invertible @@ -511,13 +511,13 @@ cdef extern from "flint_wrap.h": # ``(A, lenA)``. `R` and `A` may be aliased, but apart from this no # aliasing of input and output operands is allowed. - void fmpz_mod_poly_divrem_basecase(fmpz_mod_poly_t Q, fmpz_mod_poly_t R, const fmpz_mod_poly_t A, const fmpz_mod_poly_t B, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_divrem_basecase(fmpz_mod_poly_t Q, fmpz_mod_poly_t R, const fmpz_mod_poly_t A, const fmpz_mod_poly_t B, const fmpz_mod_ctx_t ctx) noexcept # Computes `Q`, `R` such that `A = B Q + R` with # `0 \leq \operatorname{len}(R) < \operatorname{len}(B)`. # Assumes that the leading coefficient of `B` is invertible # modulo `p`. - void _fmpz_mod_poly_divrem_newton_n_preinv (fmpz* Q, fmpz* R, const fmpz* A, slong lenA, const fmpz* B, slong lenB, const fmpz* Binv, slong lenBinv, const fmpz_mod_ctx_t ctx) + void _fmpz_mod_poly_divrem_newton_n_preinv (fmpz* Q, fmpz* R, const fmpz* A, slong lenA, const fmpz* B, slong lenB, const fmpz* Binv, slong lenBinv, const fmpz_mod_ctx_t ctx) noexcept # Computes `Q` and `R` such that `A = BQ + R` with `\operatorname{len}(R)` less than # ``lenB``, where `A` is of length ``lenA`` and `B` is of length # ``lenB``. We require that `Q` have space for ``lenA - lenB + 1`` @@ -526,7 +526,7 @@ cdef extern from "flint_wrap.h": # :func:`div_newton_n_preinv` and then multiply out and compute # the remainder. - void fmpz_mod_poly_divrem_newton_n_preinv(fmpz_mod_poly_t Q, fmpz_mod_poly_t R, const fmpz_mod_poly_t A, const fmpz_mod_poly_t B, const fmpz_mod_poly_t Binv, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_divrem_newton_n_preinv(fmpz_mod_poly_t Q, fmpz_mod_poly_t R, const fmpz_mod_poly_t A, const fmpz_mod_poly_t B, const fmpz_mod_poly_t Binv, const fmpz_mod_ctx_t ctx) noexcept # Computes `Q` and `R` such that `A = BQ + R` with `\operatorname{len}(R) < \operatorname{len}(B)`. # We assume `Binv` is the inverse of the reverse of `B` mod `x^{\operatorname{len}(B)}`. # It is required that the length of `A` is less than or equal to @@ -534,7 +534,7 @@ cdef extern from "flint_wrap.h": # The algorithm used is to call :func:`div_newton_n` and then multiply out # and compute the remainder. - void _fmpz_mod_poly_div_newton_n_preinv (fmpz* Q, const fmpz* A, slong lenA, const fmpz* B, slong lenB, const fmpz* Binv, slong lenBinv, const fmpz_mod_ctx_t ctx) + void _fmpz_mod_poly_div_newton_n_preinv (fmpz* Q, const fmpz* A, slong lenA, const fmpz* B, slong lenB, const fmpz* Binv, slong lenBinv, const fmpz_mod_ctx_t ctx) noexcept # Notionally computes polynomials `Q` and `R` such that `A = BQ + R` with # `\operatorname{len}(R)` less than ``lenB``, where ``A`` is of length ``lenA`` # and ``B`` is of length ``lenB``, but return only `Q`. @@ -544,7 +544,7 @@ cdef extern from "flint_wrap.h": # The algorithm used is to reverse the polynomials and divide the # resulting power series, then reverse the result. - void fmpz_mod_poly_div_newton_n_preinv(fmpz_mod_poly_t Q, const fmpz_mod_poly_t A, const fmpz_mod_poly_t B, const fmpz_mod_poly_t Binv, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_div_newton_n_preinv(fmpz_mod_poly_t Q, const fmpz_mod_poly_t A, const fmpz_mod_poly_t B, const fmpz_mod_poly_t Binv, const fmpz_mod_ctx_t ctx) noexcept # Notionally computes `Q` and `R` such that `A = BQ + R` with # `\operatorname{len}(R) < \operatorname{len}(B)`, but returns only `Q`. # We assume that the leading coefficient of `B` is a unit and that `Binv` is @@ -554,33 +554,33 @@ cdef extern from "flint_wrap.h": # The algorithm used is to reverse the polynomials and divide the # resulting power series, then reverse the result. - ulong fmpz_mod_poly_remove(fmpz_mod_poly_t f, const fmpz_mod_poly_t g, const fmpz_mod_ctx_t ctx) + ulong fmpz_mod_poly_remove(fmpz_mod_poly_t f, const fmpz_mod_poly_t g, const fmpz_mod_ctx_t ctx) noexcept # Removes the highest possible power of ``g`` from ``f`` and # returns the exponent. - void _fmpz_mod_poly_rem_basecase(fmpz * R, const fmpz * A, slong lenA, const fmpz * B, slong lenB, const fmpz_t invB, const fmpz_mod_ctx_t ctx) + void _fmpz_mod_poly_rem_basecase(fmpz * R, const fmpz * A, slong lenA, const fmpz * B, slong lenB, const fmpz_t invB, const fmpz_mod_ctx_t ctx) noexcept # Notationally, computes `Q`, `R` such that `A = B Q + R` with # `0 \leq \operatorname{len}(R) < \operatorname{len}(B)` but only sets ``(R, lenB - 1)``. # Allows aliasing only between `A` and `R`. Allows zero-padding # in `A` but not in `B`. Assumes that the leading coefficient # of `B` is a unit modulo `p`. - void fmpz_mod_poly_rem_basecase(fmpz_mod_poly_t R, const fmpz_mod_poly_t A, const fmpz_mod_poly_t B, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_rem_basecase(fmpz_mod_poly_t R, const fmpz_mod_poly_t A, const fmpz_mod_poly_t B, const fmpz_mod_ctx_t ctx) noexcept # Notationally, computes `Q`, `R` such that `A = B Q + R` with # `0 \leq \operatorname{len}(R) < \operatorname{len}(B)` assuming that the leading term # of `B` is a unit. - void _fmpz_mod_poly_div(fmpz * Q, const fmpz * A, slong lenA, const fmpz * B, slong lenB, const fmpz_t invB, const fmpz_mod_ctx_t ctx) + void _fmpz_mod_poly_div(fmpz * Q, const fmpz * A, slong lenA, const fmpz * B, slong lenB, const fmpz_t invB, const fmpz_mod_ctx_t ctx) noexcept # Notationally, computes `Q`, `R` such that `A = B Q + R` with # `0 \leq \operatorname{len}(R) < \operatorname{len}(B)` but only sets ``(Q, lenA - lenB + 1)``. # Assumes that the leading coefficient of `B` is a unit modulo `p`. - void fmpz_mod_poly_div(fmpz_mod_poly_t Q, const fmpz_mod_poly_t A, const fmpz_mod_poly_t B, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_div(fmpz_mod_poly_t Q, const fmpz_mod_poly_t A, const fmpz_mod_poly_t B, const fmpz_mod_ctx_t ctx) noexcept # Notationally, computes `Q`, `R` such that `A = B Q + R` with # `0 \leq \operatorname{len}(R) < \operatorname{len}(B)` assuming that the leading term # of `B` is a unit. - void _fmpz_mod_poly_divrem(fmpz * Q, fmpz * R, const fmpz * A, slong lenA, const fmpz * B, slong lenB, const fmpz_t invB, const fmpz_mod_ctx_t ctx) + void _fmpz_mod_poly_divrem(fmpz * Q, fmpz * R, const fmpz * A, slong lenA, const fmpz * B, slong lenB, const fmpz_t invB, const fmpz_mod_ctx_t ctx) noexcept # Computes ``(Q, lenA - lenB + 1)``, ``(R, lenB - 1)`` such that # `A = B Q + R` and `0 \leq \operatorname{len}(R) < \operatorname{len}(B)`. # Assumes that `B` is non-zero, that the leading coefficient @@ -590,13 +590,13 @@ cdef extern from "flint_wrap.h": # ``(A, lenA)``. No aliasing of input and output operands is # allowed. - void fmpz_mod_poly_divrem(fmpz_mod_poly_t Q, fmpz_mod_poly_t R, const fmpz_mod_poly_t A, const fmpz_mod_poly_t B, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_divrem(fmpz_mod_poly_t Q, fmpz_mod_poly_t R, const fmpz_mod_poly_t A, const fmpz_mod_poly_t B, const fmpz_mod_ctx_t ctx) noexcept # Computes `Q`, `R` such that `A = B Q + R` and # `0 \leq \operatorname{len}(R) < \operatorname{len}(B)`. # Assumes that `B` is non-zero and that the leading coefficient # of `B` is invertible modulo `p`. - void fmpz_mod_poly_divrem_f(fmpz_t f, fmpz_mod_poly_t Q, fmpz_mod_poly_t R, const fmpz_mod_poly_t A, const fmpz_mod_poly_t B, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_divrem_f(fmpz_t f, fmpz_mod_poly_t Q, fmpz_mod_poly_t R, const fmpz_mod_poly_t A, const fmpz_mod_poly_t B, const fmpz_mod_ctx_t ctx) noexcept # Either finds a non-trivial factor~`f` of the modulus~`p`, or computes # `Q`, `R` such that `A = B Q + R` and `0 \leq \operatorname{len}(R) < \operatorname{len}(B)`. # If the leading coefficient of `B` is invertible in `\mathbf{Z}/(p)`, @@ -605,7 +605,7 @@ cdef extern from "flint_wrap.h": # a non-trivial factor of `p` and `Q` and `R` are not touched. # Assumes that `B` is non-zero. - void _fmpz_mod_poly_rem(fmpz *R, const fmpz *A, slong lenA, const fmpz *B, slong lenB, const fmpz_t invB, const fmpz_mod_ctx_t ctx) + void _fmpz_mod_poly_rem(fmpz *R, const fmpz *A, slong lenA, const fmpz *B, slong lenB, const fmpz_t invB, const fmpz_mod_ctx_t ctx) noexcept # Notationally, computes ``(Q, lenA - lenB + 1)``, ``(R, lenB - 1)`` # such that `A = B Q + R` and `0 \leq \operatorname{len}(R) < \operatorname{len}(B)`, returning # only the remainder part. @@ -616,73 +616,73 @@ cdef extern from "flint_wrap.h": # ``(A, lenA)``. No aliasing of input and output operands is # allowed. - void fmpz_mod_poly_rem_f(fmpz_t f, fmpz_mod_poly_t R, const fmpz_mod_poly_t A, const fmpz_mod_poly_t B, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_rem_f(fmpz_t f, fmpz_mod_poly_t R, const fmpz_mod_poly_t A, const fmpz_mod_poly_t B, const fmpz_mod_ctx_t ctx) noexcept # If `f` returns with the value `1` then the function operates as # ``_fmpz_mod_poly_rem``, otherwise `f` will be set to a nontrivial # factor of `p`. - void fmpz_mod_poly_rem(fmpz_mod_poly_t R, const fmpz_mod_poly_t A, const fmpz_mod_poly_t B, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_rem(fmpz_mod_poly_t R, const fmpz_mod_poly_t A, const fmpz_mod_poly_t B, const fmpz_mod_ctx_t ctx) noexcept # Notationally, computes `Q`, `R` such that `A = B Q + R` # and `0 \leq \operatorname{len}(R) < \operatorname{len}(B)`, returning only the remainder # part. # Assumes that `B` is non-zero and that the leading coefficient # of `B` is invertible modulo `p`. - int _fmpz_mod_poly_divides_classical(fmpz * Q, const fmpz * A, slong lenA, const fmpz * B, slong lenB, const fmpz_mod_ctx_t ctx) + int _fmpz_mod_poly_divides_classical(fmpz * Q, const fmpz * A, slong lenA, const fmpz * B, slong lenB, const fmpz_mod_ctx_t ctx) noexcept # Returns `1` if `(B, lenB)` divides `(A, lenA)` and sets # `(Q, lenA - lenB + 1)` to the quotient. Otherwise, returns `0` and sets # `(Q, lenA - lenB + 1)` to zero. We require that `lenA >= lenB > 0`. - int fmpz_mod_poly_divides_classical(fmpz_mod_poly_t Q, const fmpz_mod_poly_t A, const fmpz_mod_poly_t B, const fmpz_mod_ctx_t ctx) + int fmpz_mod_poly_divides_classical(fmpz_mod_poly_t Q, const fmpz_mod_poly_t A, const fmpz_mod_poly_t B, const fmpz_mod_ctx_t ctx) noexcept # Returns `1` if `B` divides `A` and sets `Q` to the quotient. Otherwise # returns `0` and sets `Q` to zero. - int _fmpz_mod_poly_divides(fmpz * Q, const fmpz * A, slong lenA, const fmpz * B, slong lenB, const fmpz_mod_ctx_t ctx) + int _fmpz_mod_poly_divides(fmpz * Q, const fmpz * A, slong lenA, const fmpz * B, slong lenB, const fmpz_mod_ctx_t ctx) noexcept # Returns `1` if `(B, lenB)` divides `(A, lenA)` and sets # `(Q, lenA - lenB + 1)` to the quotient. Otherwise, returns `0` and sets # `(Q, lenA - lenB + 1)` to zero. We require that `lenA >= lenB > 0`. - int fmpz_mod_poly_divides(fmpz_mod_poly_t Q, const fmpz_mod_poly_t A, const fmpz_mod_poly_t B, const fmpz_mod_ctx_t ctx) + int fmpz_mod_poly_divides(fmpz_mod_poly_t Q, const fmpz_mod_poly_t A, const fmpz_mod_poly_t B, const fmpz_mod_ctx_t ctx) noexcept # Returns `1` if `B` divides `A` and sets `Q` to the quotient. Otherwise # returns `0` and sets `Q` to zero. - void _fmpz_mod_poly_inv_series(fmpz * Qinv, const fmpz * Q, slong Qlen, slong n, const fmpz_mod_ctx_t ctx) + void _fmpz_mod_poly_inv_series(fmpz * Qinv, const fmpz * Q, slong Qlen, slong n, const fmpz_mod_ctx_t ctx) noexcept # Sets ``(Qinv, n)`` to the inverse of ``(Q, n)`` modulo `x^n`, # where `n \geq 1`, assuming that the bottom coefficient of `Q` is # invertible modulo `p` and that its inverse is ``cinv``. - void fmpz_mod_poly_inv_series(fmpz_mod_poly_t Qinv, const fmpz_mod_poly_t Q, slong n, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_inv_series(fmpz_mod_poly_t Qinv, const fmpz_mod_poly_t Q, slong n, const fmpz_mod_ctx_t ctx) noexcept # Sets ``Qinv`` to the inverse of ``Q`` modulo `x^n`, # where `n \geq 1`, assuming that the bottom coefficient of # `Q` is a unit. - void fmpz_mod_poly_inv_series_f(fmpz_t f, fmpz_mod_poly_t Qinv, const fmpz_mod_poly_t Q, slong n, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_inv_series_f(fmpz_t f, fmpz_mod_poly_t Qinv, const fmpz_mod_poly_t Q, slong n, const fmpz_mod_ctx_t ctx) noexcept # Either sets `f` to a nontrivial factor of `p` with the value of # ``Qinv`` undefined, or sets ``Qinv`` to the inverse of ``Q`` # modulo `x^n`, where `n \geq 1`. - void _fmpz_mod_poly_div_series(fmpz * Q, const fmpz * A, slong Alen, const fmpz * B, slong Blen, slong n, const fmpz_mod_ctx_t ctx) + void _fmpz_mod_poly_div_series(fmpz * Q, const fmpz * A, slong Alen, const fmpz * B, slong Blen, slong n, const fmpz_mod_ctx_t ctx) noexcept # Set ``(Q, n)`` to the quotient of the series ``(A, Alen``) and # ``(B, Blen)`` assuming ``Alen, Blen <= n``. We assume the bottom # coefficient of ``B`` is invertible modulo `p`. - void fmpz_mod_poly_div_series(fmpz_mod_poly_t Q, const fmpz_mod_poly_t A, const fmpz_mod_poly_t B, slong n, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_div_series(fmpz_mod_poly_t Q, const fmpz_mod_poly_t A, const fmpz_mod_poly_t B, slong n, const fmpz_mod_ctx_t ctx) noexcept # Set `Q` to the quotient of the series `A` by `B`, thinking of the series as # though they were of length `n`. We assume that the bottom coefficient of # `B` is a unit. - void fmpz_mod_poly_make_monic(fmpz_mod_poly_t res, const fmpz_mod_poly_t poly, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_make_monic(fmpz_mod_poly_t res, const fmpz_mod_poly_t poly, const fmpz_mod_ctx_t ctx) noexcept # If ``poly`` is non-zero, sets ``res`` to ``poly`` divided # by its leading coefficient. This assumes that the leading coefficient # of ``poly`` is invertible modulo `p`. # Otherwise, if ``poly`` is zero, sets ``res`` to zero. - void fmpz_mod_poly_make_monic_f(fmpz_t f, fmpz_mod_poly_t res, const fmpz_mod_poly_t poly, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_make_monic_f(fmpz_t f, fmpz_mod_poly_t res, const fmpz_mod_poly_t poly, const fmpz_mod_ctx_t ctx) noexcept # Either set `f` to `1` and ``res`` to ``poly`` divided by its leading # coefficient or set `f` to a nontrivial factor of `p` and leave ``res`` # undefined. - slong _fmpz_mod_poly_gcd(fmpz *G, const fmpz *A, slong lenA, const fmpz *B, slong lenB, const fmpz_mod_ctx_t ctx) + slong _fmpz_mod_poly_gcd(fmpz *G, const fmpz *A, slong lenA, const fmpz *B, slong lenB, const fmpz_mod_ctx_t ctx) noexcept # Sets `G` to the greatest common divisor of `(A, \operatorname{len}(A))` # and `(B, \operatorname{len}(B))` and returns its length. # Assumes that `\operatorname{len}(A) \geq \operatorname{len}(B) > 0` and that the vector `G` has @@ -690,13 +690,13 @@ cdef extern from "flint_wrap.h": # Assumes that ``invB`` is the inverse of the leading coefficients # of `B` modulo the prime number `p`. - void fmpz_mod_poly_gcd(fmpz_mod_poly_t G, const fmpz_mod_poly_t A, const fmpz_mod_poly_t B, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_gcd(fmpz_mod_poly_t G, const fmpz_mod_poly_t A, const fmpz_mod_poly_t B, const fmpz_mod_ctx_t ctx) noexcept # Sets `G` to the greatest common divisor of `A` and `B`. # In general, the greatest common divisor is defined in the polynomial # ring `(\mathbf{Z}/(p \mathbf{Z}))[X]` if and only if `p` is a prime # number. Thus, this function assumes that `p` is prime. - slong _fmpz_mod_poly_gcd_euclidean_f(fmpz_t f, fmpz *G, const fmpz *A, slong lenA, const fmpz *B, slong lenB, const fmpz_mod_ctx_t ctx) + slong _fmpz_mod_poly_gcd_euclidean_f(fmpz_t f, fmpz *G, const fmpz *A, slong lenA, const fmpz *B, slong lenB, const fmpz_mod_ctx_t ctx) noexcept # Either sets `f = 1` and `G` to the greatest common divisor # of `(A, \operatorname{len}(A))` and `(B, \operatorname{len}(B))` and returns its length, # or sets `f \in (1,p)` to a non-trivial factor of `p` and @@ -706,14 +706,14 @@ cdef extern from "flint_wrap.h": # Does not support aliasing of any of the input arguments # with any of the output argument. - void fmpz_mod_poly_gcd_euclidean_f(fmpz_t f, fmpz_mod_poly_t G, const fmpz_mod_poly_t A, const fmpz_mod_poly_t B, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_gcd_euclidean_f(fmpz_t f, fmpz_mod_poly_t G, const fmpz_mod_poly_t A, const fmpz_mod_poly_t B, const fmpz_mod_ctx_t ctx) noexcept # Either sets `f = 1` and `G` to the greatest common divisor # of `A` and `B`, or ` \in (1,p)` to a non-trivial factor of `p`. # In general, the greatest common divisor is defined in the polynomial # ring `(\mathbf{Z}/(p \mathbf{Z}))[X]` if and only if `p` is a prime # number. - slong _fmpz_mod_poly_gcd_f(fmpz_t f, fmpz *G, const fmpz *A, slong lenA, const fmpz *B, slong lenB, const fmpz_mod_ctx_t ctx) + slong _fmpz_mod_poly_gcd_f(fmpz_t f, fmpz *G, const fmpz *A, slong lenA, const fmpz *B, slong lenB, const fmpz_mod_ctx_t ctx) noexcept # Either sets `f = 1` and `G` to the greatest common divisor # of `(A, \operatorname{len}(A))` and `(B, \operatorname{len}(B))` and returns its length, # or sets `f \in (1,p)` to a non-trivial factor of `p` and @@ -723,14 +723,14 @@ cdef extern from "flint_wrap.h": # Does not support aliasing of any of the input arguments # with any of the output arguments. - void fmpz_mod_poly_gcd_f(fmpz_t f, fmpz_mod_poly_t G, const fmpz_mod_poly_t A, const fmpz_mod_poly_t B, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_gcd_f(fmpz_t f, fmpz_mod_poly_t G, const fmpz_mod_poly_t A, const fmpz_mod_poly_t B, const fmpz_mod_ctx_t ctx) noexcept # Either sets `f = 1` and `G` to the greatest common divisor # of `A` and `B`, or `f \in (1,p)` to a non-trivial factor of `p`. # In general, the greatest common divisor is defined in the polynomial # ring `(\mathbf{Z}/(p \mathbf{Z}))[X]` if and only if `p` is a prime # number. - slong _fmpz_mod_poly_hgcd(fmpz **M, slong *lenM, fmpz *A, slong *lenA, fmpz *B, slong *lenB, const fmpz *a, slong lena, const fmpz *b, slong lenb, const fmpz_mod_ctx_t ctx) + slong _fmpz_mod_poly_hgcd(fmpz **M, slong *lenM, fmpz *A, slong *lenA, fmpz *B, slong *lenB, const fmpz *a, slong lena, const fmpz *b, slong lenb, const fmpz_mod_ctx_t ctx) noexcept # Computes the HGCD of `a` and `b`, that is, a matrix~`M`, a sign~`\sigma` # and two polynomials `A` and `B` such that # .. math :: @@ -742,17 +742,17 @@ cdef extern from "flint_wrap.h": # Assumes that ``M[0]``, ``M[1]``, ``M[2]``, and ``M[3]`` # each point to a vector of size at least `\operatorname{len}(a)`. - slong _fmpz_mod_poly_xgcd_euclidean_f(fmpz_t f, fmpz *G, fmpz *S, fmpz *T, const fmpz *A, slong lenA, const fmpz *B, slong lenB, const fmpz_t invB, const fmpz_mod_ctx_t ctx) + slong _fmpz_mod_poly_xgcd_euclidean_f(fmpz_t f, fmpz *G, fmpz *S, fmpz *T, const fmpz *A, slong lenA, const fmpz *B, slong lenB, const fmpz_t invB, const fmpz_mod_ctx_t ctx) noexcept # If `f` returns with the value `1` then the function operates as per # ``_fmpz_mod_poly_xgcd_euclidean``, otherwise `f` is set to a nontrivial # factor of `p`. - void fmpz_mod_poly_xgcd_euclidean_f(fmpz_t f, fmpz_mod_poly_t G, fmpz_mod_poly_t S, fmpz_mod_poly_t T, const fmpz_mod_poly_t A, const fmpz_mod_poly_t B, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_xgcd_euclidean_f(fmpz_t f, fmpz_mod_poly_t G, fmpz_mod_poly_t S, fmpz_mod_poly_t T, const fmpz_mod_poly_t A, const fmpz_mod_poly_t B, const fmpz_mod_ctx_t ctx) noexcept # If `f` returns with the value `1` then the function operates as per # ``fmpz_mod_poly_xgcd_euclidean``, otherwise `f` is set to a nontrivial # factor of `p`. - slong _fmpz_mod_poly_xgcd(fmpz *G, fmpz *S, fmpz *T, const fmpz *A, slong lenA, const fmpz *B, slong lenB, const fmpz_t invB, const fmpz_mod_ctx_t ctx) + slong _fmpz_mod_poly_xgcd(fmpz *G, fmpz *S, fmpz *T, const fmpz *A, slong lenA, const fmpz *B, slong lenB, const fmpz_t invB, const fmpz_mod_ctx_t ctx) noexcept # Computes the GCD of `A` and `B` together with cofactors `S` and `T` # such that `S A + T B = G`. Returns the length of `G`. # Assumes that `\operatorname{len}(A) \geq \operatorname{len}(B) \geq 1` and @@ -764,7 +764,7 @@ cdef extern from "flint_wrap.h": # `\operatorname{len}(T) \leq \max(\operatorname{len}(A) - \operatorname{len}(G), 1)`. # No aliasing of input and output operands is permitted. - void fmpz_mod_poly_xgcd(fmpz_mod_poly_t G, fmpz_mod_poly_t S, fmpz_mod_poly_t T, const fmpz_mod_poly_t A, const fmpz_mod_poly_t B, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_xgcd(fmpz_mod_poly_t G, fmpz_mod_poly_t S, fmpz_mod_poly_t T, const fmpz_mod_poly_t A, const fmpz_mod_poly_t B, const fmpz_mod_ctx_t ctx) noexcept # Computes the GCD of `A` and `B`. The GCD of zero polynomials is # defined to be zero, whereas the GCD of the zero polynomial and some other # polynomial `P` is defined to be `P`. Except in the case where @@ -773,54 +773,54 @@ cdef extern from "flint_wrap.h": # ``S*A + T*B = G``. The length of ``S`` will be at most # ``lenB`` and the length of ``T`` will be at most ``lenA``. - void fmpz_mod_poly_xgcd_f(fmpz_t f, fmpz_mod_poly_t G, fmpz_mod_poly_t S, fmpz_mod_poly_t T, const fmpz_mod_poly_t A, const fmpz_mod_poly_t B, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_xgcd_f(fmpz_t f, fmpz_mod_poly_t G, fmpz_mod_poly_t S, fmpz_mod_poly_t T, const fmpz_mod_poly_t A, const fmpz_mod_poly_t B, const fmpz_mod_ctx_t ctx) noexcept # If `f` returns with the value `1` then the function operates as per # ``fmpz_mod_poly_xgcd``, otherwise `f` is set to a nontrivial # factor of `p`. - slong _fmpz_mod_poly_gcdinv_euclidean(fmpz *G, fmpz *S, const fmpz *A, slong lenA, const fmpz *B, slong lenB, const fmpz_t invA, const fmpz_mod_ctx_t ctx) + slong _fmpz_mod_poly_gcdinv_euclidean(fmpz *G, fmpz *S, const fmpz *A, slong lenA, const fmpz *B, slong lenB, const fmpz_t invA, const fmpz_mod_ctx_t ctx) noexcept # Computes ``(G, lenA)``, ``(S, lenB-1)`` such that # `G \cong S A \pmod{B}`, returning the actual length of `G`. # Assumes that `0 < \operatorname{len}(A) < \operatorname{len}(B)`. - void fmpz_mod_poly_gcdinv_euclidean(fmpz_mod_poly_t G, fmpz_mod_poly_t S, const fmpz_mod_poly_t A, const fmpz_mod_poly_t B, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_gcdinv_euclidean(fmpz_mod_poly_t G, fmpz_mod_poly_t S, const fmpz_mod_poly_t A, const fmpz_mod_poly_t B, const fmpz_mod_ctx_t ctx) noexcept # Computes polynomials `G` and `S`, both reduced modulo~`B`, # such that `G \cong S A \pmod{B}`, where `B` is assumed to # have `\operatorname{len}(B) \geq 2`. # In the case that `A = 0 \pmod{B}`, returns `G = S = 0`. - slong _fmpz_mod_poly_gcdinv_euclidean_f(fmpz_t f, fmpz *G, fmpz *S, const fmpz *A, slong lenA, const fmpz *B, slong lenB, const fmpz_t invA, const fmpz_mod_ctx_t ctx) + slong _fmpz_mod_poly_gcdinv_euclidean_f(fmpz_t f, fmpz *G, fmpz *S, const fmpz *A, slong lenA, const fmpz *B, slong lenB, const fmpz_t invA, const fmpz_mod_ctx_t ctx) noexcept # If `f` returns with value `1` then the function operates as per # :func:`_fmpz_mod_poly_gcdinv_euclidean`, otherwise `f` is set to a # nontrivial factor of `p`. - void fmpz_mod_poly_gcdinv_euclidean_f(fmpz_t f, fmpz_mod_poly_t G, fmpz_mod_poly_t S, const fmpz_mod_poly_t A, const fmpz_mod_poly_t B, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_gcdinv_euclidean_f(fmpz_t f, fmpz_mod_poly_t G, fmpz_mod_poly_t S, const fmpz_mod_poly_t A, const fmpz_mod_poly_t B, const fmpz_mod_ctx_t ctx) noexcept # If `f` returns with value `1` then the function operates as per # :func:`fmpz_mod_poly_gcdinv_euclidean`, otherwise `f` is set to a # nontrivial factor of the modulus of `A`. - slong _fmpz_mod_poly_gcdinv(fmpz *G, fmpz *S, const fmpz *A, slong lenA, const fmpz *B, slong lenB, const fmpz_mod_ctx_t ctx) + slong _fmpz_mod_poly_gcdinv(fmpz *G, fmpz *S, const fmpz *A, slong lenA, const fmpz *B, slong lenB, const fmpz_mod_ctx_t ctx) noexcept # Computes ``(G, lenA)``, ``(S, lenB-1)`` such that # `G \cong S A \pmod{B}`, returning the actual length of `G`. # Assumes that `0 < \operatorname{len}(A) < \operatorname{len}(B)`. - slong _fmpz_mod_poly_gcdinv_f(fmpz_t f, fmpz *G, fmpz *S, const fmpz *A, slong lenA, const fmpz *B, slong lenB, const fmpz_mod_ctx_t ctx) + slong _fmpz_mod_poly_gcdinv_f(fmpz_t f, fmpz *G, fmpz *S, const fmpz *A, slong lenA, const fmpz *B, slong lenB, const fmpz_mod_ctx_t ctx) noexcept # If `f` returns with value `1` then the function operates as per # :func:`_fmpz_mod_poly_gcdinv`, otherwise `f` will be set to a nontrivial # factor of `p`. - void fmpz_mod_poly_gcdinv(fmpz_mod_poly_t G, fmpz_mod_poly_t S, const fmpz_mod_poly_t A, const fmpz_mod_poly_t B, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_gcdinv(fmpz_mod_poly_t G, fmpz_mod_poly_t S, const fmpz_mod_poly_t A, const fmpz_mod_poly_t B, const fmpz_mod_ctx_t ctx) noexcept # Computes polynomials `G` and `S`, both reduced modulo~`B`, # such that `G \cong S A \pmod{B}`, where `B` is assumed to # have `\operatorname{len}(B) \geq 2`. # In the case that `A = 0 \pmod{B}`, returns `G = S = 0`. - void fmpz_mod_poly_gcdinv_f(fmpz_t f, fmpz_mod_poly_t G, fmpz_mod_poly_t S, const fmpz_mod_poly_t A, const fmpz_mod_poly_t B, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_gcdinv_f(fmpz_t f, fmpz_mod_poly_t G, fmpz_mod_poly_t S, const fmpz_mod_poly_t A, const fmpz_mod_poly_t B, const fmpz_mod_ctx_t ctx) noexcept # If `f` returns with value `1` then the function operates as per # :func:`fmpz_mod_poly_gcdinv`, otherwise `f` will be set to a nontrivial # factor of `p`. - int _fmpz_mod_poly_invmod(fmpz *A, const fmpz *B, slong lenB, const fmpz *P, slong lenP, const fmpz_mod_ctx_t ctx) + int _fmpz_mod_poly_invmod(fmpz *A, const fmpz *B, slong lenB, const fmpz *P, slong lenP, const fmpz_mod_ctx_t ctx) noexcept # Attempts to set ``(A, lenP-1)`` to the inverse of ``(B, lenB)`` # modulo the polynomial ``(P, lenP)``. Returns `1` if ``(B, lenB)`` # is invertible and `0` otherwise. @@ -829,12 +829,12 @@ cdef extern from "flint_wrap.h": # Does not support aliasing. # Assumes that `p` is a prime number. - int _fmpz_mod_poly_invmod_f(fmpz_t f, fmpz *A, const fmpz *B, slong lenB, const fmpz *P, slong lenP, const fmpz_mod_ctx_t ctx) + int _fmpz_mod_poly_invmod_f(fmpz_t f, fmpz *A, const fmpz *B, slong lenB, const fmpz *P, slong lenP, const fmpz_mod_ctx_t ctx) noexcept # If `f` returns with the value `1`, then the function operates as per # :func:`_fmpz_mod_poly_invmod`. Otherwise `f` is set to a nontrivial # factor of `p`. - int fmpz_mod_poly_invmod(fmpz_mod_poly_t A, const fmpz_mod_poly_t B, const fmpz_mod_poly_t P, const fmpz_mod_ctx_t ctx) + int fmpz_mod_poly_invmod(fmpz_mod_poly_t A, const fmpz_mod_poly_t B, const fmpz_mod_poly_t P, const fmpz_mod_ctx_t ctx) noexcept # Attempts to set `A` to the inverse of `B` modulo `P` in the polynomial # ring `(\mathbf{Z}/p\mathbf{Z})[X]`, where we assume that `p` is a prime # number. @@ -843,12 +843,12 @@ cdef extern from "flint_wrap.h": # sets `A` to the inverse of `B`. Otherwise, returns~`0` and the value # of `A` on exit is undefined. - int fmpz_mod_poly_invmod_f(fmpz_t f, fmpz_mod_poly_t A, const fmpz_mod_poly_t B, const fmpz_mod_poly_t P, const fmpz_mod_ctx_t ctx) + int fmpz_mod_poly_invmod_f(fmpz_t f, fmpz_mod_poly_t A, const fmpz_mod_poly_t B, const fmpz_mod_poly_t P, const fmpz_mod_ctx_t ctx) noexcept # If `f` returns with the value `1`, then the function operates as per # :func:`fmpz_mod_poly_invmod`. Otherwise `f` is set to a nontrivial # factor of `p`. - slong _fmpz_mod_poly_minpoly_bm(fmpz* poly, const fmpz* seq, slong len, const fmpz_mod_ctx_t ctx) + slong _fmpz_mod_poly_minpoly_bm(fmpz* poly, const fmpz* seq, slong len, const fmpz_mod_ctx_t ctx) noexcept # Sets ``poly`` to the coefficients of a minimal generating # polynomial for sequence ``(seq, len)`` modulo `p`. # The return value equals the length of ``poly``. @@ -856,14 +856,14 @@ cdef extern from "flint_wrap.h": # `len+1` coefficients. No aliasing between inputs and outputs is # allowed. - void fmpz_mod_poly_minpoly_bm(fmpz_mod_poly_t poly, const fmpz* seq, slong len, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_minpoly_bm(fmpz_mod_poly_t poly, const fmpz* seq, slong len, const fmpz_mod_ctx_t ctx) noexcept # Sets ``poly`` to a minimal generating polynomial for sequence # ``seq`` of length ``len``. # Assumes that the modulus is prime. # This version uses the Berlekamp-Massey algorithm, whose running time # is proportional to ``len`` times the size of the minimal generator. - slong _fmpz_mod_poly_minpoly_hgcd(fmpz* poly, const fmpz* seq, slong len, const fmpz_mod_ctx_t ctx) + slong _fmpz_mod_poly_minpoly_hgcd(fmpz* poly, const fmpz* seq, slong len, const fmpz_mod_ctx_t ctx) noexcept # Sets ``poly`` to the coefficients of a minimal generating # polynomial for sequence ``(seq, len)`` modulo `p`. # The return value equals the length of ``poly``. @@ -871,7 +871,7 @@ cdef extern from "flint_wrap.h": # `len+1` coefficients. No aliasing between inputs and outputs is # allowed. - void fmpz_mod_poly_minpoly_hgcd(fmpz_mod_poly_t poly, const fmpz* seq, slong len, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_minpoly_hgcd(fmpz_mod_poly_t poly, const fmpz* seq, slong len, const fmpz_mod_ctx_t ctx) noexcept # Sets ``poly`` to a minimal generating polynomial for sequence # ``seq`` of length ``len``. # Assumes that the modulus is prime. @@ -879,7 +879,7 @@ cdef extern from "flint_wrap.h": # `O(n \log^2 n)` field operations, regardless of the actual size of # the minimal generator. - slong _fmpz_mod_poly_minpoly(fmpz* poly, const fmpz* seq, slong len, const fmpz_mod_ctx_t ctx) + slong _fmpz_mod_poly_minpoly(fmpz* poly, const fmpz* seq, slong len, const fmpz_mod_ctx_t ctx) noexcept # Sets ``poly`` to the coefficients of a minimal generating # polynomial for sequence ``(seq, len)`` modulo `p`. # The return value equals the length of ``poly``. @@ -887,7 +887,7 @@ cdef extern from "flint_wrap.h": # `len+1` coefficients. No aliasing between inputs and outputs is # allowed. - void fmpz_mod_poly_minpoly(fmpz_mod_poly_t poly, const fmpz* seq, slong len, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_minpoly(fmpz_mod_poly_t poly, const fmpz* seq, slong len, const fmpz_mod_ctx_t ctx) noexcept # Sets ``poly`` to a minimal generating polynomial for sequence # ``seq`` of length ``len``. # A minimal generating polynomial is a monic polynomial @@ -899,13 +899,13 @@ cdef extern from "flint_wrap.h": # This version automatically chooses the fastest underlying # implementation based on ``len`` and the size of the modulus. - void _fmpz_mod_poly_resultant_euclidean(fmpz_t res, const fmpz *poly1, slong len1, const fmpz *poly2, slong len2, const fmpz_mod_ctx_t ctx) + void _fmpz_mod_poly_resultant_euclidean(fmpz_t res, const fmpz *poly1, slong len1, const fmpz *poly2, slong len2, const fmpz_mod_ctx_t ctx) noexcept # Sets `r` to the resultant of ``(poly1, len1)`` and # ``(poly2, len2)`` using the Euclidean algorithm. # Assumes that ``len1 >= len2 > 0``. # Assumes that the modulus is prime. - void fmpz_mod_poly_resultant_euclidean(fmpz_t r, const fmpz_mod_poly_t f, const fmpz_mod_poly_t g, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_resultant_euclidean(fmpz_t r, const fmpz_mod_poly_t f, const fmpz_mod_poly_t g, const fmpz_mod_ctx_t ctx) noexcept # Computes the resultant of `f` and `g` using the Euclidean algorithm. # For two non-zero polynomials `f(x) = a_m x^m + \dotsb + a_0` and # `g(x) = b_n x^n + \dotsb + b_0` of degrees `m` and `n`, the resultant @@ -915,7 +915,7 @@ cdef extern from "flint_wrap.h": # For convenience, we define the resultant to be equal to zero if either # of the two polynomials is zero. - void _fmpz_mod_poly_resultant_hgcd(fmpz_t res, const fmpz *A, slong lenA, const fmpz *B, slong lenB, const fmpz_mod_ctx_t ctx) + void _fmpz_mod_poly_resultant_hgcd(fmpz_t res, const fmpz *A, slong lenA, const fmpz *B, slong lenB, const fmpz_mod_ctx_t ctx) noexcept # Sets ``res`` to the resultant of ``(A, lenA)`` and # ``(B, lenB)`` using the half-gcd algorithm. # This algorithm computes the half-gcd as per @@ -946,7 +946,7 @@ cdef extern from "flint_wrap.h": # Assumes that ``lenA >= lenB > 0``. # Assumes that the modulus is prime. - void fmpz_mod_poly_resultant_hgcd(fmpz_t res, const fmpz_mod_poly_t f, const fmpz_mod_poly_t g, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_resultant_hgcd(fmpz_t res, const fmpz_mod_poly_t f, const fmpz_mod_poly_t g, const fmpz_mod_ctx_t ctx) noexcept # Computes the resultant of `f` and `g` using the half-gcd algorithm. # For two non-zero polynomials `f(x) = a_m x^m + \dotsb + a_0` and # `g(x) = b_n x^n + \dotsb + b_0` of degrees `m` and `n`, the resultant @@ -956,13 +956,13 @@ cdef extern from "flint_wrap.h": # For convenience, we define the resultant to be equal to zero if either # of the two polynomials is zero. - void _fmpz_mod_poly_resultant(fmpz_t res, const fmpz *poly1, slong len1, const fmpz *poly2, slong len2, const fmpz_mod_ctx_t ctx) + void _fmpz_mod_poly_resultant(fmpz_t res, const fmpz *poly1, slong len1, const fmpz *poly2, slong len2, const fmpz_mod_ctx_t ctx) noexcept # Returns the resultant of ``(poly1, len1)`` and # ``(poly2, len2)``. # Assumes that ``len1 >= len2 > 0``. # Assumes that the modulus is prime. - void fmpz_mod_poly_resultant(fmpz_t res, const fmpz_mod_poly_t f, const fmpz_mod_poly_t g, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_resultant(fmpz_t res, const fmpz_mod_poly_t f, const fmpz_mod_poly_t g, const fmpz_mod_ctx_t ctx) noexcept # Computes the resultant of $f$ and $g$. # For two non-zero polynomials `f(x) = a_m x^m + \dotsb + a_0` and # `g(x) = b_n x^n + \dotsb + b_0` of degrees `m` and `n`, the resultant @@ -972,10 +972,10 @@ cdef extern from "flint_wrap.h": # For convenience, we define the resultant to be equal to zero if either # of the two polynomials is zero. - void _fmpz_mod_poly_discriminant(fmpz_t d, const fmpz *poly, slong len, const fmpz_mod_ctx_t ctx) + void _fmpz_mod_poly_discriminant(fmpz_t d, const fmpz *poly, slong len, const fmpz_mod_ctx_t ctx) noexcept # Set `d` to the discriminant of ``(poly, len)``. Assumes ``len > 1``. - void fmpz_mod_poly_discriminant(fmpz_t d, const fmpz_mod_poly_t f, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_discriminant(fmpz_t d, const fmpz_mod_poly_t f, const fmpz_mod_ctx_t ctx) noexcept # Set `d` to the discriminant of `f`. # We normalise the discriminant so that # `\operatorname{disc}(f) = (-1)^(n(n-1)/2) \operatorname{res}(f, f') / @@ -985,66 +985,66 @@ cdef extern from "flint_wrap.h": # `\operatorname{lc}(f)` is the leading coefficient of `f` and `r_i` are the # roots of `f`. - void _fmpz_mod_poly_derivative(fmpz *res, const fmpz *poly, slong len, const fmpz_mod_ctx_t ctx) + void _fmpz_mod_poly_derivative(fmpz *res, const fmpz *poly, slong len, const fmpz_mod_ctx_t ctx) noexcept # Sets ``(res, len - 1)`` to the derivative of ``(poly, len)``. # Also handles the cases where ``len`` is `0` or `1` correctly. # Supports aliasing of ``res`` and ``poly``. - void fmpz_mod_poly_derivative(fmpz_mod_poly_t res, const fmpz_mod_poly_t poly, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_derivative(fmpz_mod_poly_t res, const fmpz_mod_poly_t poly, const fmpz_mod_ctx_t ctx) noexcept # Sets ``res`` to the derivative of ``poly``. - void _fmpz_mod_poly_evaluate_fmpz(fmpz_t res, const fmpz *poly, slong len, const fmpz_t a, const fmpz_mod_ctx_t ctx) + void _fmpz_mod_poly_evaluate_fmpz(fmpz_t res, const fmpz *poly, slong len, const fmpz_t a, const fmpz_mod_ctx_t ctx) noexcept # Evaluates the polynomial ``(poly, len)`` at the integer `a` and sets # ``res`` to the result. Aliasing between ``res`` and `a` or any # of the coefficients of ``poly`` is not supported. - void fmpz_mod_poly_evaluate_fmpz(fmpz_t res, const fmpz_mod_poly_t poly, const fmpz_t a, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_evaluate_fmpz(fmpz_t res, const fmpz_mod_poly_t poly, const fmpz_t a, const fmpz_mod_ctx_t ctx) noexcept # Evaluates the polynomial ``poly`` at the integer `a` and sets # ``res`` to the result. # As expected, aliasing between ``res`` and `a` is supported. However, # ``res`` may not be aliased with a coefficient of ``poly``. - void _fmpz_mod_poly_evaluate_fmpz_vec_iter(fmpz * ys, const fmpz * coeffs, slong len, const fmpz * xs, slong n, const fmpz_mod_ctx_t ctx) + void _fmpz_mod_poly_evaluate_fmpz_vec_iter(fmpz * ys, const fmpz * coeffs, slong len, const fmpz * xs, slong n, const fmpz_mod_ctx_t ctx) noexcept # Evaluates (``coeffs``, ``len``) at the ``n`` values # given in the vector ``xs``, writing the output values # to ``ys``. The values in ``xs`` should be reduced # modulo the modulus. # Uses Horner's method iteratively. - void fmpz_mod_poly_evaluate_fmpz_vec_iter(fmpz * ys, const fmpz_mod_poly_t poly, const fmpz * xs, slong n, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_evaluate_fmpz_vec_iter(fmpz * ys, const fmpz_mod_poly_t poly, const fmpz * xs, slong n, const fmpz_mod_ctx_t ctx) noexcept # Evaluates ``poly`` at the ``n`` values given in the vector # ``xs``, writing the output values to ``ys``. The values in # ``xs`` should be reduced modulo the modulus. # Uses Horner's method iteratively. - void _fmpz_mod_poly_evaluate_fmpz_vec_fast_precomp(fmpz * vs, const fmpz * poly, slong plen, fmpz_poly_struct * const * tree, slong len, const fmpz_mod_ctx_t ctx) + void _fmpz_mod_poly_evaluate_fmpz_vec_fast_precomp(fmpz * vs, const fmpz * poly, slong plen, fmpz_poly_struct * const * tree, slong len, const fmpz_mod_ctx_t ctx) noexcept # Evaluates (``poly``, ``plen``) at the ``len`` values given by the precomputed subproduct tree ``tree``. - void _fmpz_mod_poly_evaluate_fmpz_vec_fast(fmpz * ys, const fmpz * poly, slong plen, const fmpz * xs, slong n, const fmpz_mod_ctx_t ctx) + void _fmpz_mod_poly_evaluate_fmpz_vec_fast(fmpz * ys, const fmpz * poly, slong plen, const fmpz * xs, slong n, const fmpz_mod_ctx_t ctx) noexcept # Evaluates (``coeffs``, ``len``) at the ``n`` values # given in the vector ``xs``, writing the output values # to ``ys``. The values in ``xs`` should be reduced # modulo the modulus. # Uses fast multipoint evaluation, building a temporary subproduct tree. - void fmpz_mod_poly_evaluate_fmpz_vec_fast(fmpz * ys, const fmpz_mod_poly_t poly, const fmpz * xs, slong n, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_evaluate_fmpz_vec_fast(fmpz * ys, const fmpz_mod_poly_t poly, const fmpz * xs, slong n, const fmpz_mod_ctx_t ctx) noexcept # Evaluates ``poly`` at the ``n`` values given in the vector # ``xs``, writing the output values to ``ys``. The values in # ``xs`` should be reduced modulo the modulus. # Uses fast multipoint evaluation, building a temporary subproduct tree. - void _fmpz_mod_poly_evaluate_fmpz_vec(fmpz * ys, const fmpz * coeffs, slong len, const fmpz * xs, slong n, const fmpz_mod_ctx_t ctx) + void _fmpz_mod_poly_evaluate_fmpz_vec(fmpz * ys, const fmpz * coeffs, slong len, const fmpz * xs, slong n, const fmpz_mod_ctx_t ctx) noexcept # Evaluates (``coeffs``, ``len``) at the ``n`` values # given in the vector ``xs``, writing the output values # to ``ys``. The values in ``xs`` should be reduced # modulo the modulus. - void fmpz_mod_poly_evaluate_fmpz_vec(fmpz * ys, const fmpz_mod_poly_t poly, const fmpz * xs, slong n, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_evaluate_fmpz_vec(fmpz * ys, const fmpz_mod_poly_t poly, const fmpz * xs, slong n, const fmpz_mod_ctx_t ctx) noexcept # Evaluates ``poly`` at the ``n`` values given in the vector # ``xs``, writing the output values to ``ys``. The values in # ``xs`` should be reduced modulo the modulus. - void _fmpz_mod_poly_compose(fmpz *res, const fmpz *poly1, slong len1, const fmpz *poly2, slong len2, const fmpz_mod_ctx_t ctx) + void _fmpz_mod_poly_compose(fmpz *res, const fmpz *poly1, slong len1, const fmpz *poly2, slong len2, const fmpz_mod_ctx_t ctx) noexcept # Sets ``res`` to the composition of ``(poly1, len1)`` and # ``(poly2, len2)``. # Assumes that ``res`` has space for ``(len1-1)*(len2-1) + 1`` @@ -1053,58 +1053,58 @@ cdef extern from "flint_wrap.h": # Assumes that ``poly1`` and ``poly2`` are non-zero polynomials. # Does not support aliasing between any of the inputs and the output. - void fmpz_mod_poly_compose(fmpz_mod_poly_t res, const fmpz_mod_poly_t poly1, const fmpz_mod_poly_t poly2, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_compose(fmpz_mod_poly_t res, const fmpz_mod_poly_t poly1, const fmpz_mod_poly_t poly2, const fmpz_mod_ctx_t ctx) noexcept # Sets ``res`` to the composition of ``poly1`` and ``poly2``. # To be precise about the order of composition, denoting ``res``, # ``poly1``, and ``poly2`` by `f`, `g`, and `h`, respectively, # sets `f(t) = g(h(t))`. - void _fmpz_mod_poly_invsqrt_series(fmpz * g, const fmpz * h, slong hlen, slong n, const fmpz_mod_ctx_t ctx) + void _fmpz_mod_poly_invsqrt_series(fmpz * g, const fmpz * h, slong hlen, slong n, const fmpz_mod_ctx_t ctx) noexcept # Set the first `n` terms of `g` to the series expansion of `1/\sqrt{h}`. # It is assumed that `n > 0` and `h > 0`. Aliasing is not permitted. - void fmpz_mod_poly_invsqrt_series(fmpz_mod_poly_t g, const fmpz_mod_poly_t h, slong n, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_invsqrt_series(fmpz_mod_poly_t g, const fmpz_mod_poly_t h, slong n, const fmpz_mod_ctx_t ctx) noexcept # Set `g` to the series expansion of `1/\sqrt{h}` to order `O(x^n)`. # It is assumed that `h` has constant term 1. - void _fmpz_mod_poly_sqrt_series(fmpz * g, const fmpz * h, slong hlen, slong n, const fmpz_mod_ctx_t ctx) + void _fmpz_mod_poly_sqrt_series(fmpz * g, const fmpz * h, slong hlen, slong n, const fmpz_mod_ctx_t ctx) noexcept # Set the first `n` terms of `g` to the series expansion of `\sqrt{h}`. # It is assumed that `n > 0` and `h > 0`. Aliasing is not permitted. - void fmpz_mod_poly_sqrt_series(fmpz_mod_poly_t g, const fmpz_mod_poly_t h, slong n, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_sqrt_series(fmpz_mod_poly_t g, const fmpz_mod_poly_t h, slong n, const fmpz_mod_ctx_t ctx) noexcept # Set `g` to the series expansion of `\sqrt{h}` to order `O(x^n)`. # It is assumed that `h` has constant term 1. - int _fmpz_mod_poly_sqrt(fmpz * s, const fmpz * p, slong n, const fmpz_mod_ctx_t ctx) + int _fmpz_mod_poly_sqrt(fmpz * s, const fmpz * p, slong n, const fmpz_mod_ctx_t ctx) noexcept # If ``(p, n)`` is a perfect square, sets ``(s, n / 2 + 1)`` # to a square root of `p` and returns 1. Otherwise returns 0. - int fmpz_mod_poly_sqrt(fmpz_mod_poly_t s, const fmpz_mod_poly_t p, const fmpz_mod_ctx_t ctx) + int fmpz_mod_poly_sqrt(fmpz_mod_poly_t s, const fmpz_mod_poly_t p, const fmpz_mod_ctx_t ctx) noexcept # If `p` is a perfect square, sets `s` to a square root of `p` # and returns 1. Otherwise returns 0. - void _fmpz_mod_poly_compose_mod(fmpz * res, const fmpz * f, slong lenf, const fmpz * g, const fmpz * h, slong lenh, const fmpz_mod_ctx_t ctx) + void _fmpz_mod_poly_compose_mod(fmpz * res, const fmpz * f, slong lenf, const fmpz * g, const fmpz * h, slong lenh, const fmpz_mod_ctx_t ctx) noexcept # Sets ``res`` to the composition `f(g)` modulo `h`. We require that # `h` is nonzero and that the length of `g` is one less than the # length of `h` (possibly with zero padding). The output is not allowed # to be aliased with any of the inputs. - void fmpz_mod_poly_compose_mod(fmpz_mod_poly_t res, const fmpz_mod_poly_t f, const fmpz_mod_poly_t g, const fmpz_mod_poly_t h, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_compose_mod(fmpz_mod_poly_t res, const fmpz_mod_poly_t f, const fmpz_mod_poly_t g, const fmpz_mod_poly_t h, const fmpz_mod_ctx_t ctx) noexcept # Sets ``res`` to the composition `f(g)` modulo `h`. We require that # `h` is nonzero. - void _fmpz_mod_poly_compose_mod_horner(fmpz * res, const fmpz * f, slong lenf, const fmpz * g, const fmpz * h, slong lenh, const fmpz_mod_ctx_t ctx) + void _fmpz_mod_poly_compose_mod_horner(fmpz * res, const fmpz * f, slong lenf, const fmpz * g, const fmpz * h, slong lenh, const fmpz_mod_ctx_t ctx) noexcept # Sets ``res`` to the composition `f(g)` modulo `h`. We require that # `h` is nonzero and that the length of `g` is one less than the # length of `h` (possibly with zero padding). The output is not allowed # to be aliased with any of the inputs. # The algorithm used is Horner's rule. - void fmpz_mod_poly_compose_mod_horner(fmpz_mod_poly_t res, const fmpz_mod_poly_t f, const fmpz_mod_poly_t g, const fmpz_mod_poly_t h, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_compose_mod_horner(fmpz_mod_poly_t res, const fmpz_mod_poly_t f, const fmpz_mod_poly_t g, const fmpz_mod_poly_t h, const fmpz_mod_ctx_t ctx) noexcept # Sets ``res`` to the composition `f(g)` modulo `h`. We require that # `h` is nonzero. The algorithm used is Horner's rule. - void _fmpz_mod_poly_compose_mod_brent_kung(fmpz * res, const fmpz * f, slong len1, const fmpz * g, const fmpz * h, slong len3, const fmpz_mod_ctx_t ctx) + void _fmpz_mod_poly_compose_mod_brent_kung(fmpz * res, const fmpz * f, slong len1, const fmpz * g, const fmpz * h, slong len3, const fmpz_mod_ctx_t ctx) noexcept # Sets ``res`` to the composition `f(g)` modulo `h`. We require that # `h` is nonzero and that the length of `g` is one less than the # length of `h` (possibly with zero padding). We also require that @@ -1112,21 +1112,21 @@ cdef extern from "flint_wrap.h": # allowed to be aliased with any of the inputs. # The algorithm used is the Brent-Kung matrix algorithm. - void fmpz_mod_poly_compose_mod_brent_kung(fmpz_mod_poly_t res, const fmpz_mod_poly_t f, const fmpz_mod_poly_t g, const fmpz_mod_poly_t h, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_compose_mod_brent_kung(fmpz_mod_poly_t res, const fmpz_mod_poly_t f, const fmpz_mod_poly_t g, const fmpz_mod_poly_t h, const fmpz_mod_ctx_t ctx) noexcept # Sets ``res`` to the composition `f(g)` modulo `h`. We require that # `h` is nonzero and that `f` has smaller degree than `h`. # The algorithm used is the Brent-Kung matrix algorithm. - void _fmpz_mod_poly_reduce_matrix_mod_poly (fmpz_mat_t A, const fmpz_mat_t B, const fmpz_mod_poly_t f, const fmpz_mod_ctx_t ctx) + void _fmpz_mod_poly_reduce_matrix_mod_poly (fmpz_mat_t A, const fmpz_mat_t B, const fmpz_mod_poly_t f, const fmpz_mod_ctx_t ctx) noexcept # Sets the ith row of ``A`` to the reduction of the ith row of `B` modulo # `f` for `i=1,\ldots,\sqrt{\deg(f)}`. We require `B` to be at least # a `\sqrt{\deg(f)}\times \deg(f)` matrix and `f` to be nonzero. - void _fmpz_mod_poly_precompute_matrix_worker(void * arg_ptr) + void _fmpz_mod_poly_precompute_matrix_worker(void * arg_ptr) noexcept # Worker function version of ``_fmpz_mod_poly_precompute_matrix``. # Input/output is stored in ``fmpz_mod_poly_matrix_precompute_arg_t``. - void _fmpz_mod_poly_precompute_matrix (fmpz_mat_t A, const fmpz * f, const fmpz * g, slong leng, const fmpz * ginv, slong lenginv, const fmpz_mod_ctx_t ctx) + void _fmpz_mod_poly_precompute_matrix (fmpz_mat_t A, const fmpz * f, const fmpz * g, slong leng, const fmpz * ginv, slong lenginv, const fmpz_mod_ctx_t ctx) noexcept # Sets the ith row of ``A`` to `f^i` modulo `g` for # `i=1,\ldots,\sqrt{\deg(g)}`. We require `A` to be # a `\sqrt{\deg(g)}\times \deg(g)` matrix. We require @@ -1134,19 +1134,19 @@ cdef extern from "flint_wrap.h": # nonzero. ``f`` has to be reduced modulo ``g`` and of length one less # than ``leng`` (possibly with zero padding). - void fmpz_mod_poly_precompute_matrix(fmpz_mat_t A, const fmpz_mod_poly_t f, const fmpz_mod_poly_t g, const fmpz_mod_poly_t ginv, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_precompute_matrix(fmpz_mat_t A, const fmpz_mod_poly_t f, const fmpz_mod_poly_t g, const fmpz_mod_poly_t ginv, const fmpz_mod_ctx_t ctx) noexcept # Sets the ith row of ``A`` to `f^i` modulo `g` for # `i=1,\ldots,\sqrt{\deg(g)}`. We require `A` to be # a `\sqrt{\deg(g)}\times \deg(g)` matrix. We require # ``ginv`` to be the inverse of the reverse of ``g``. - void _fmpz_mod_poly_compose_mod_brent_kung_precomp_preinv_worker(void * arg_ptr) + void _fmpz_mod_poly_compose_mod_brent_kung_precomp_preinv_worker(void * arg_ptr) noexcept # Worker function version of # :func:`_fmpz_mod_poly_compose_mod_brent_kung_precomp_preinv`. # Input/output is stored in # ``fmpz_mod_poly_compose_mod_precomp_preinv_arg_t``. - void _fmpz_mod_poly_compose_mod_brent_kung_precomp_preinv(fmpz * res, const fmpz * f, slong lenf, const fmpz_mat_t A, const fmpz * h, slong lenh, const fmpz * hinv, slong lenhinv, const fmpz_mod_ctx_t ctx) + void _fmpz_mod_poly_compose_mod_brent_kung_precomp_preinv(fmpz * res, const fmpz * f, slong lenf, const fmpz_mat_t A, const fmpz * h, slong lenh, const fmpz * hinv, slong lenhinv, const fmpz_mod_ctx_t ctx) noexcept # Sets ``res`` to the composition `f(g)` modulo `h`. We require that # `h` is nonzero. We require that the ith row of `A` contains `g^i` for # `i=1,\ldots,\sqrt{\deg(h)}`, i.e. `A` is a @@ -1156,7 +1156,7 @@ cdef extern from "flint_wrap.h": # The output is not allowed to be aliased with any of the inputs. # The algorithm used is the Brent-Kung matrix algorithm. - void fmpz_mod_poly_compose_mod_brent_kung_precomp_preinv(fmpz_mod_poly_t res, const fmpz_mod_poly_t f, const fmpz_mat_t A, const fmpz_mod_poly_t h, const fmpz_mod_poly_t hinv, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_compose_mod_brent_kung_precomp_preinv(fmpz_mod_poly_t res, const fmpz_mod_poly_t f, const fmpz_mat_t A, const fmpz_mod_poly_t h, const fmpz_mod_poly_t hinv, const fmpz_mod_ctx_t ctx) noexcept # Sets ``res`` to the composition `f(g)` modulo `h`. We require that the # ith row of `A` contains `g^i` for `i=1,\ldots,\sqrt{\deg(h)}`, i.e. `A` is # a `\sqrt{\deg(h)}\times \deg(h)` matrix. We require that `h` is nonzero and @@ -1165,7 +1165,7 @@ cdef extern from "flint_wrap.h": # modular composition is particularly useful if one has to perform several # modular composition of the form `f(g)` modulo `h` for fixed `g` and `h`. - void _fmpz_mod_poly_compose_mod_brent_kung_preinv(fmpz * res, const fmpz * f, slong lenf, const fmpz * g, const fmpz * h, slong lenh, const fmpz * hinv, slong lenhinv, const fmpz_mod_ctx_t ctx) + void _fmpz_mod_poly_compose_mod_brent_kung_preinv(fmpz * res, const fmpz * f, slong lenf, const fmpz * g, const fmpz * h, slong lenh, const fmpz * hinv, slong lenhinv, const fmpz_mod_ctx_t ctx) noexcept # Sets ``res`` to the composition `f(g)` modulo `h`. We require that # `h` is nonzero and that the length of `g` is one less than the # length of `h` (possibly with zero padding). We also require that @@ -1174,13 +1174,13 @@ cdef extern from "flint_wrap.h": # The output is not allowed to be aliased with any of the inputs. # The algorithm used is the Brent-Kung matrix algorithm. - void fmpz_mod_poly_compose_mod_brent_kung_preinv(fmpz_mod_poly_t res, const fmpz_mod_poly_t f, const fmpz_mod_poly_t g, const fmpz_mod_poly_t h, const fmpz_mod_poly_t hinv, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_compose_mod_brent_kung_preinv(fmpz_mod_poly_t res, const fmpz_mod_poly_t f, const fmpz_mod_poly_t g, const fmpz_mod_poly_t h, const fmpz_mod_poly_t hinv, const fmpz_mod_ctx_t ctx) noexcept # Sets ``res`` to the composition `f(g)` modulo `h`. We require that # `h` is nonzero and that `f` has smaller degree than `h`. Furthermore, # we require ``hinv`` to be the inverse of the reverse of ``h``. # The algorithm used is the Brent-Kung matrix algorithm. - void _fmpz_mod_poly_compose_mod_brent_kung_vec_preinv(fmpz_mod_poly_struct * res, const fmpz_mod_poly_struct * polys, slong len1, slong l, const fmpz * g, slong glen, const fmpz * h, slong lenh, const fmpz * hinv, slong lenhinv, const fmpz_mod_ctx_t ctx) + void _fmpz_mod_poly_compose_mod_brent_kung_vec_preinv(fmpz_mod_poly_struct * res, const fmpz_mod_poly_struct * polys, slong len1, slong l, const fmpz * g, slong glen, const fmpz * h, slong lenh, const fmpz * hinv, slong lenhinv, const fmpz_mod_ctx_t ctx) noexcept # Sets ``res`` to the composition `f_i(g)` modulo `h` for `1\leq i \leq l`, # where `f_i` are the ``l`` elements of ``polys``. We require that `h` is # nonzero and that the length of `g` is less than the length of `h`. We @@ -1192,7 +1192,7 @@ cdef extern from "flint_wrap.h": # aliased with any of the inputs. # The algorithm used is the Brent-Kung matrix algorithm. - void fmpz_mod_poly_compose_mod_brent_kung_vec_preinv(fmpz_mod_poly_struct * res, const fmpz_mod_poly_struct * polys, slong len1, slong n, const fmpz_mod_poly_t g, const fmpz_mod_poly_t h, const fmpz_mod_poly_t hinv, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_compose_mod_brent_kung_vec_preinv(fmpz_mod_poly_struct * res, const fmpz_mod_poly_struct * polys, slong len1, slong n, const fmpz_mod_poly_t g, const fmpz_mod_poly_t h, const fmpz_mod_poly_t hinv, const fmpz_mod_ctx_t ctx) noexcept # Sets ``res`` to the composition `f_i(g)` modulo `h` for `1\leq i \leq n` # where `f_i` are the ``n`` elements of ``polys``. We require ``res`` to # have enough memory allocated to hold ``n`` ``fmpz_mod_poly_struct``'s. @@ -1203,34 +1203,34 @@ cdef extern from "flint_wrap.h": # ``polys`` is allowed. # The algorithm used is the Brent-Kung matrix algorithm. - void _fmpz_mod_poly_compose_mod_brent_kung_vec_preinv_threaded_pool(fmpz_mod_poly_struct * res, const fmpz_mod_poly_struct * polys, slong lenpolys, slong l, const fmpz * g, slong glen, const fmpz * poly, slong len, const fmpz * polyinv, slong leninv, const fmpz_mod_ctx_t ctx, thread_pool_handle * threads, slong num_threads) + void _fmpz_mod_poly_compose_mod_brent_kung_vec_preinv_threaded_pool(fmpz_mod_poly_struct * res, const fmpz_mod_poly_struct * polys, slong lenpolys, slong l, const fmpz * g, slong glen, const fmpz * poly, slong len, const fmpz * polyinv, slong leninv, const fmpz_mod_ctx_t ctx, thread_pool_handle * threads, slong num_threads) noexcept # Multithreaded version of # :func:`_fmpz_mod_poly_compose_mod_brent_kung_vec_preinv`. Distributing the # Horner evaluations across :func:`flint_get_num_threads` threads. - void fmpz_mod_poly_compose_mod_brent_kung_vec_preinv_threaded_pool(fmpz_mod_poly_struct * res, const fmpz_mod_poly_struct * polys, slong len1, slong n, const fmpz_mod_poly_t g, const fmpz_mod_poly_t poly, const fmpz_mod_poly_t polyinv, const fmpz_mod_ctx_t ctx, thread_pool_handle * threads, slong num_threads) + void fmpz_mod_poly_compose_mod_brent_kung_vec_preinv_threaded_pool(fmpz_mod_poly_struct * res, const fmpz_mod_poly_struct * polys, slong len1, slong n, const fmpz_mod_poly_t g, const fmpz_mod_poly_t poly, const fmpz_mod_poly_t polyinv, const fmpz_mod_ctx_t ctx, thread_pool_handle * threads, slong num_threads) noexcept # Multithreaded version of # :func:`fmpz_mod_poly_compose_mod_brent_kung_vec_preinv`. Distributing the # Horner evaluations across :func:`flint_get_num_threads` threads. - void fmpz_mod_poly_compose_mod_brent_kung_vec_preinv_threaded(fmpz_mod_poly_struct * res, const fmpz_mod_poly_struct * polys, slong len1, slong n, const fmpz_mod_poly_t g, const fmpz_mod_poly_t poly, const fmpz_mod_poly_t polyinv, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_compose_mod_brent_kung_vec_preinv_threaded(fmpz_mod_poly_struct * res, const fmpz_mod_poly_struct * polys, slong len1, slong n, const fmpz_mod_poly_t g, const fmpz_mod_poly_t poly, const fmpz_mod_poly_t polyinv, const fmpz_mod_ctx_t ctx) noexcept # Multithreaded version of # :func:`fmpz_mod_poly_compose_mod_brent_kung_vec_preinv`. Distributing the # Horner evaluations across :func:`flint_get_num_threads` threads. - fmpz_poly_struct ** _fmpz_mod_poly_tree_alloc(slong len) + fmpz_poly_struct ** _fmpz_mod_poly_tree_alloc(slong len) noexcept # Allocates space for a subproduct tree of the given length, having # linear factors at the lowest level. - void _fmpz_mod_poly_tree_free(fmpz_poly_struct ** tree, slong len) + void _fmpz_mod_poly_tree_free(fmpz_poly_struct ** tree, slong len) noexcept # Free the allocated space for the subproduct. - void _fmpz_mod_poly_tree_build(fmpz_poly_struct ** tree, const fmpz * roots, slong len, const fmpz_mod_ctx_t ctx) + void _fmpz_mod_poly_tree_build(fmpz_poly_struct ** tree, const fmpz * roots, slong len, const fmpz_mod_ctx_t ctx) noexcept # Builds a subproduct tree in the preallocated space from # the ``len`` monic linear factors `(x-r_i)` where `r_i` are given by # ``roots``. The top level product is not computed. - void _fmpz_mod_poly_radix_init(fmpz **Rpow, fmpz **Rinv, const fmpz *R, slong lenR, slong k, const fmpz_t invL, const fmpz_mod_ctx_t ctx) + void _fmpz_mod_poly_radix_init(fmpz **Rpow, fmpz **Rinv, const fmpz *R, slong lenR, slong k, const fmpz_t invL, const fmpz_mod_ctx_t ctx) noexcept # Computes powers of `R` of the form `R^{2^i}` and their Newton inverses # modulo `x^{2^{i} \deg(R)}` for `i = 0, \dotsc, k-1`. # Assumes that the vectors ``Rpow[i]`` and ``Rinv[i]`` have space @@ -1244,13 +1244,13 @@ cdef extern from "flint_wrap.h": # Note that this precomputed data can be used for any `F` such that # `\operatorname{len}(F) \leq 2^k \deg(R)`. - void fmpz_mod_poly_radix_init(fmpz_mod_poly_radix_t D, const fmpz_mod_poly_t R, slong degF, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_radix_init(fmpz_mod_poly_radix_t D, const fmpz_mod_poly_t R, slong degF, const fmpz_mod_ctx_t ctx) noexcept # Carries out the precomputation necessary to perform radix conversion # to radix~`R` for polynomials~`F` of degree at most ``degF``. # Assumes that `R` is non-constant, i.e. `\deg(R) \geq 1`, # and that the leading coefficient is a unit. - void _fmpz_mod_poly_radix(fmpz **B, const fmpz *F, fmpz **Rpow, fmpz **Rinv, slong degR, slong k, slong i, fmpz *W, const fmpz_mod_ctx_t ctx) + void _fmpz_mod_poly_radix(fmpz **B, const fmpz *F, fmpz **Rpow, fmpz **Rinv, slong degR, slong k, slong i, fmpz *W, const fmpz_mod_ctx_t ctx) noexcept # This is the main recursive function used by the # function :func:`fmpz_mod_poly_radix`. # Assumes that, for all `i = 0, \dotsc, N`, the vector @@ -1266,7 +1266,7 @@ cdef extern from "flint_wrap.h": # Thus, the top level call will have `F` as in the original # problem, and `k = 0`. - void fmpz_mod_poly_radix(fmpz_mod_poly_struct **B, const fmpz_mod_poly_t F, const fmpz_mod_poly_radix_t D, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_radix(fmpz_mod_poly_struct **B, const fmpz_mod_poly_t F, const fmpz_mod_poly_radix_t D, const fmpz_mod_ctx_t ctx) noexcept # Given a polynomial `F` and the precomputed data `D` for the radix `R`, # computes polynomials `B_0, \dotsc, B_N` of degree less than `\deg(R)` # such that @@ -1276,74 +1276,74 @@ cdef extern from "flint_wrap.h": # Assumes that `R` is non-constant, i.e.\ `\deg(R) \geq 1`, # and that the leading coefficient is a unit. - int _fmpz_mod_poly_fprint(FILE * file, const fmpz *poly, slong len, const fmpz_t p) + int _fmpz_mod_poly_fprint(FILE * file, const fmpz *poly, slong len, const fmpz_t p) noexcept # Prints the polynomial ``(poly, len)`` to the stream ``file``. # In case of success, returns a positive value. In case of failure, # returns a non-positive value. - int fmpz_mod_poly_fprint(FILE * file, const fmpz_mod_poly_t poly, const fmpz_mod_ctx_t ctx) + int fmpz_mod_poly_fprint(FILE * file, const fmpz_mod_poly_t poly, const fmpz_mod_ctx_t ctx) noexcept # Prints the polynomial to the stream ``file``. # In case of success, returns a positive value. In case of failure, # returns a non-positive value. - int fmpz_mod_poly_fprint_pretty(FILE * file, const fmpz_mod_poly_t poly, const char * x, const fmpz_mod_ctx_t ctx) + int fmpz_mod_poly_fprint_pretty(FILE * file, const fmpz_mod_poly_t poly, const char * x, const fmpz_mod_ctx_t ctx) noexcept # Prints the pretty representation of ``(poly, len)`` to the stream # ``file``, using the string ``x`` to represent the indeterminate. # In case of success, returns a positive value. In case of failure, # returns a non-positive value. - int fmpz_mod_poly_print(const fmpz_mod_poly_t poly, const fmpz_mod_ctx_t ctx) + int fmpz_mod_poly_print(const fmpz_mod_poly_t poly, const fmpz_mod_ctx_t ctx) noexcept # Prints the polynomial to ``stdout``. # In case of success, returns a positive value. In case of failure, # returns a non-positive value. - int fmpz_mod_poly_print_pretty(const fmpz_mod_poly_t poly, const char * x, const fmpz_mod_ctx_t ctx) + int fmpz_mod_poly_print_pretty(const fmpz_mod_poly_t poly, const char * x, const fmpz_mod_ctx_t ctx) noexcept # Prints the pretty representation of ``poly`` to ``stdout``, # using the string ``x`` to represent the indeterminate. # In case of success, returns a positive value. In case of failure, # returns a non-positive value. - void fmpz_mod_poly_inflate(fmpz_mod_poly_t result, const fmpz_mod_poly_t input, ulong inflation, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_inflate(fmpz_mod_poly_t result, const fmpz_mod_poly_t input, ulong inflation, const fmpz_mod_ctx_t ctx) noexcept # Sets ``result`` to the inflated polynomial `p(x^n)` where # `p` is given by ``input`` and `n` is given by ``inflation``. - void fmpz_mod_poly_deflate(fmpz_mod_poly_t result, const fmpz_mod_poly_t input, ulong deflation, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_deflate(fmpz_mod_poly_t result, const fmpz_mod_poly_t input, ulong deflation, const fmpz_mod_ctx_t ctx) noexcept # Sets ``result`` to the deflated polynomial `p(x^{1/n})` where # `p` is given by ``input`` and `n` is given by ``deflation``. # Requires `n > 0`. - ulong fmpz_mod_poly_deflation(const fmpz_mod_poly_t input, const fmpz_mod_ctx_t ctx) + ulong fmpz_mod_poly_deflation(const fmpz_mod_poly_t input, const fmpz_mod_ctx_t ctx) noexcept # Returns the largest integer by which ``input`` can be deflated. # As special cases, returns 0 if ``input`` is the zero polynomial # and 1 of ``input`` is a constant polynomial. - void fmpz_mod_berlekamp_massey_init(fmpz_mod_berlekamp_massey_t B, const fmpz_mod_ctx_t ctx) + void fmpz_mod_berlekamp_massey_init(fmpz_mod_berlekamp_massey_t B, const fmpz_mod_ctx_t ctx) noexcept # Initialize ``B`` with an empty stream. - void fmpz_mod_berlekamp_massey_clear(fmpz_mod_berlekamp_massey_t B, const fmpz_mod_ctx_t ctx) + void fmpz_mod_berlekamp_massey_clear(fmpz_mod_berlekamp_massey_t B, const fmpz_mod_ctx_t ctx) noexcept # Free any space used by ``B``. - void fmpz_mod_berlekamp_massey_start_over(fmpz_mod_berlekamp_massey_t B, const fmpz_mod_ctx_t ctx) + void fmpz_mod_berlekamp_massey_start_over(fmpz_mod_berlekamp_massey_t B, const fmpz_mod_ctx_t ctx) noexcept # Empty the stream of points in ``B``. - void fmpz_mod_berlekamp_massey_add_points(fmpz_mod_berlekamp_massey_t B, const fmpz * a, slong count, const fmpz_mod_ctx_t ctx) - void fmpz_mod_berlekamp_massey_add_zeros(fmpz_mod_berlekamp_massey_t B, slong count, const fmpz_mod_ctx_t ctx) - void fmpz_mod_berlekamp_massey_add_point(fmpz_mod_berlekamp_massey_t B, const fmpz_t a, const fmpz_mod_ctx_t ctx) + void fmpz_mod_berlekamp_massey_add_points(fmpz_mod_berlekamp_massey_t B, const fmpz * a, slong count, const fmpz_mod_ctx_t ctx) noexcept + void fmpz_mod_berlekamp_massey_add_zeros(fmpz_mod_berlekamp_massey_t B, slong count, const fmpz_mod_ctx_t ctx) noexcept + void fmpz_mod_berlekamp_massey_add_point(fmpz_mod_berlekamp_massey_t B, const fmpz_t a, const fmpz_mod_ctx_t ctx) noexcept # Add point(s) to the stream processed by ``B``. The addition of any number of points will not update the `V` and `R` polynomial. - int fmpz_mod_berlekamp_massey_reduce(fmpz_mod_berlekamp_massey_t B, const fmpz_mod_ctx_t ctx) + int fmpz_mod_berlekamp_massey_reduce(fmpz_mod_berlekamp_massey_t B, const fmpz_mod_ctx_t ctx) noexcept # Ensure that the polynomials `V` and `R` are up to date. The return value is ``1`` if this function changed `V` and ``0`` otherwise. # For example, if this function is called twice in a row without adding any points in between, the return of the second call should be ``0``. # As another example, suppose the object is emptied, the points `1, 1, 2, 3` are added, then reduce is called. This reduce should return ``1`` with `\deg(R) < \deg(V) = 2` because the Fibonacci sequence has been recognized. The further addition of the two points `5, 8` and a reduce will result in a return value of ``0``. - slong fmpz_mod_berlekamp_massey_point_count(const fmpz_mod_berlekamp_massey_t B) + slong fmpz_mod_berlekamp_massey_point_count(const fmpz_mod_berlekamp_massey_t B) noexcept # Return the number of points stored in ``B``. - const fmpz * fmpz_mod_berlekamp_massey_points(const fmpz_mod_berlekamp_massey_t B) + const fmpz * fmpz_mod_berlekamp_massey_points(const fmpz_mod_berlekamp_massey_t B) noexcept # Return a pointer the array of points stored in ``B``. This may be ``NULL`` if func::fmpz_mod_berlekamp_massey_point_count returns ``0``. - const fmpz_mod_poly_struct * fmpz_mod_berlekamp_massey_V_poly(const fmpz_mod_berlekamp_massey_t B) + const fmpz_mod_poly_struct * fmpz_mod_berlekamp_massey_V_poly(const fmpz_mod_berlekamp_massey_t B) noexcept # Return the polynomial ``V`` in ``B``. - const fmpz_mod_poly_struct * fmpz_mod_berlekamp_massey_R_poly(const fmpz_mod_berlekamp_massey_t B) + const fmpz_mod_poly_struct * fmpz_mod_berlekamp_massey_R_poly(const fmpz_mod_berlekamp_massey_t B) noexcept # Return the polynomial ``R`` in ``B``. diff --git a/src/sage/libs/flint/fmpz_mod_poly_factor.pxd b/src/sage/libs/flint/fmpz_mod_poly_factor.pxd index f790ec3fe26..ea31fd0424f 100644 --- a/src/sage/libs/flint/fmpz_mod_poly_factor.pxd +++ b/src/sage/libs/flint/fmpz_mod_poly_factor.pxd @@ -12,55 +12,55 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void fmpz_mod_poly_factor_init(fmpz_mod_poly_factor_t fac, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_factor_init(fmpz_mod_poly_factor_t fac, const fmpz_mod_ctx_t ctx) noexcept # Initialises ``fac`` for use. - void fmpz_mod_poly_factor_clear(fmpz_mod_poly_factor_t fac, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_factor_clear(fmpz_mod_poly_factor_t fac, const fmpz_mod_ctx_t ctx) noexcept # Frees all memory associated with ``fac``. - void fmpz_mod_poly_factor_realloc(fmpz_mod_poly_factor_t fac, slong alloc, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_factor_realloc(fmpz_mod_poly_factor_t fac, slong alloc, const fmpz_mod_ctx_t ctx) noexcept # Reallocates the factor structure to provide space for # precisely ``alloc`` factors. - void fmpz_mod_poly_factor_fit_length(fmpz_mod_poly_factor_t fac, slong len, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_factor_fit_length(fmpz_mod_poly_factor_t fac, slong len, const fmpz_mod_ctx_t ctx) noexcept # Ensures that the factor structure has space for at # least ``len`` factors. This function takes care # of the case of repeated calls by always at least # doubling the number of factors the structure can hold. - void fmpz_mod_poly_factor_set(fmpz_mod_poly_factor_t res, const fmpz_mod_poly_factor_t fac, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_factor_set(fmpz_mod_poly_factor_t res, const fmpz_mod_poly_factor_t fac, const fmpz_mod_ctx_t ctx) noexcept # Sets ``res`` to the same factorisation as ``fac``. - void fmpz_mod_poly_factor_print(const fmpz_mod_poly_factor_t fac, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_factor_print(const fmpz_mod_poly_factor_t fac, const fmpz_mod_ctx_t ctx) noexcept # Prints the entries of ``fac`` to standard output. - void fmpz_mod_poly_factor_insert(fmpz_mod_poly_factor_t fac, const fmpz_mod_poly_t poly, slong exp, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_factor_insert(fmpz_mod_poly_factor_t fac, const fmpz_mod_poly_t poly, slong exp, const fmpz_mod_ctx_t ctx) noexcept # Inserts the factor ``poly`` with multiplicity ``exp`` into # the factorisation ``fac``. # If ``fac`` already contains ``poly``, then ``exp`` simply # gets added to the exponent of the existing entry. - void fmpz_mod_poly_factor_concat(fmpz_mod_poly_factor_t res, const fmpz_mod_poly_factor_t fac, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_factor_concat(fmpz_mod_poly_factor_t res, const fmpz_mod_poly_factor_t fac, const fmpz_mod_ctx_t ctx) noexcept # Concatenates two factorisations. # This is equivalent to calling :func:`fmpz_mod_poly_factor_insert` # repeatedly with the individual factors of ``fac``. # Does not support aliasing between ``res`` and ``fac``. - void fmpz_mod_poly_factor_pow(fmpz_mod_poly_factor_t fac, slong exp, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_factor_pow(fmpz_mod_poly_factor_t fac, slong exp, const fmpz_mod_ctx_t ctx) noexcept # Raises ``fac`` to the power ``exp``. - bint fmpz_mod_poly_is_irreducible(const fmpz_mod_poly_t f, const fmpz_mod_ctx_t ctx) + bint fmpz_mod_poly_is_irreducible(const fmpz_mod_poly_t f, const fmpz_mod_ctx_t ctx) noexcept # Returns 1 if the polynomial ``f`` is irreducible, otherwise returns 0. - bint fmpz_mod_poly_is_irreducible_ddf(const fmpz_mod_poly_t f, const fmpz_mod_ctx_t ctx) + bint fmpz_mod_poly_is_irreducible_ddf(const fmpz_mod_poly_t f, const fmpz_mod_ctx_t ctx) noexcept # Returns 1 if the polynomial ``f`` is irreducible, otherwise returns 0. # Uses fast distinct-degree factorisation. - bint fmpz_mod_poly_is_irreducible_rabin(const fmpz_mod_poly_t f, const fmpz_mod_ctx_t ctx) + bint fmpz_mod_poly_is_irreducible_rabin(const fmpz_mod_poly_t f, const fmpz_mod_ctx_t ctx) noexcept # Returns 1 if the polynomial ``f`` is irreducible, otherwise returns 0. # Uses Rabin irreducibility test. - bint fmpz_mod_poly_is_irreducible_rabin_f(fmpz_t r, const fmpz_mod_poly_t f, const fmpz_mod_ctx_t ctx) + bint fmpz_mod_poly_is_irreducible_rabin_f(fmpz_t r, const fmpz_mod_poly_t f, const fmpz_mod_ctx_t ctx) noexcept # Either sets `r` to `1` and returns 1 if the polynomial ``f`` is # irreducible or `0` otherwise, or sets `r` to a nontrivial factor of # `p`. @@ -68,38 +68,38 @@ cdef extern from "flint_wrap.h": # `\mathbb{Z}/p\mathbb{Z}`, even for composite `f`, or it finds a factor # of `p`. - bint _fmpz_mod_poly_is_squarefree(const fmpz * f, slong len, const fmpz_mod_ctx_t ctx) + bint _fmpz_mod_poly_is_squarefree(const fmpz * f, slong len, const fmpz_mod_ctx_t ctx) noexcept # Returns 1 if ``(f, len)`` is squarefree, and 0 otherwise. As a # special case, the zero polynomial is not considered squarefree. # There are no restrictions on the length. - bint _fmpz_mod_poly_is_squarefree_f(fmpz_t fac, const fmpz * f, slong len, const fmpz_mod_ctx_t ctx) + bint _fmpz_mod_poly_is_squarefree_f(fmpz_t fac, const fmpz * f, slong len, const fmpz_mod_ctx_t ctx) noexcept # If `fac` returns with the value `1` then the function operates as per # :func:`_fmpz_mod_poly_is_squarefree`, otherwise `f` is set to a nontrivial # factor of `p`. - bint fmpz_mod_poly_is_squarefree(const fmpz_mod_poly_t f, const fmpz_mod_ctx_t ctx) + bint fmpz_mod_poly_is_squarefree(const fmpz_mod_poly_t f, const fmpz_mod_ctx_t ctx) noexcept # Returns 1 if ``f`` is squarefree, and 0 otherwise. As a special # case, the zero polynomial is not considered squarefree. - bint fmpz_mod_poly_is_squarefree_f(fmpz_t fac, const fmpz_mod_poly_t f, const fmpz_mod_ctx_t ctx) + bint fmpz_mod_poly_is_squarefree_f(fmpz_t fac, const fmpz_mod_poly_t f, const fmpz_mod_ctx_t ctx) noexcept # If `fac` returns with the value `1` then the function operates as per # :func:`fmpz_mod_poly_is_squarefree`, otherwise `f` is set to a nontrivial # factor of `p`. - bint fmpz_mod_poly_factor_equal_deg_prob(fmpz_mod_poly_t factor, flint_rand_t state, const fmpz_mod_poly_t pol, slong d, const fmpz_mod_ctx_t ctx) + bint fmpz_mod_poly_factor_equal_deg_prob(fmpz_mod_poly_t factor, flint_rand_t state, const fmpz_mod_poly_t pol, slong d, const fmpz_mod_ctx_t ctx) noexcept # Probabilistic equal degree factorisation of ``pol`` into # irreducible factors of degree ``d``. If it passes, a factor is # placed in ``factor`` and 1 is returned, otherwise 0 is returned and # the value of factor is undetermined. # Requires that ``pol`` be monic, non-constant and squarefree. - void fmpz_mod_poly_factor_equal_deg(fmpz_mod_poly_factor_t factors, const fmpz_mod_poly_t pol, slong d, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_factor_equal_deg(fmpz_mod_poly_factor_t factors, const fmpz_mod_poly_t pol, slong d, const fmpz_mod_ctx_t ctx) noexcept # Assuming ``pol`` is a product of irreducible factors all of # degree ``d``, finds all those factors and places them in factors. # Requires that ``pol`` be monic, non-constant and squarefree. - void fmpz_mod_poly_factor_distinct_deg(fmpz_mod_poly_factor_t res, const fmpz_mod_poly_t poly, slong * const *degs, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_factor_distinct_deg(fmpz_mod_poly_factor_t res, const fmpz_mod_poly_t poly, slong * const *degs, const fmpz_mod_ctx_t ctx) noexcept # Factorises a monic non-constant squarefree polynomial ``poly`` # of degree `n` into factors `f[d]` such that for `1 \leq d \leq n` # `f[d]` is the product of the monic irreducible factors of ``poly`` @@ -108,22 +108,22 @@ cdef extern from "flint_wrap.h": # as the factors. # Requires that ``degs`` has enough space for `(n/2)+1 * sizeof(slong)`. - void fmpz_mod_poly_factor_distinct_deg_threaded(fmpz_mod_poly_factor_t res, const fmpz_mod_poly_t poly, slong * const *degs, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_factor_distinct_deg_threaded(fmpz_mod_poly_factor_t res, const fmpz_mod_poly_t poly, slong * const *degs, const fmpz_mod_ctx_t ctx) noexcept # Multithreaded version of :func:`fmpz_mod_poly_factor_distinct_deg`. - void fmpz_mod_poly_factor_squarefree(fmpz_mod_poly_factor_t res, const fmpz_mod_poly_t f, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_factor_squarefree(fmpz_mod_poly_factor_t res, const fmpz_mod_poly_t f, const fmpz_mod_ctx_t ctx) noexcept # Sets ``res`` to a squarefree factorization of ``f``. - void fmpz_mod_poly_factor(fmpz_mod_poly_factor_t res, const fmpz_mod_poly_t f, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_factor(fmpz_mod_poly_factor_t res, const fmpz_mod_poly_t f, const fmpz_mod_ctx_t ctx) noexcept # Factorises a non-constant polynomial ``f`` into monic irreducible # factors choosing the best algorithm for given modulo and degree. # Choice is based on heuristic measurements. - void fmpz_mod_poly_factor_cantor_zassenhaus(fmpz_mod_poly_factor_t res, const fmpz_mod_poly_t f, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_factor_cantor_zassenhaus(fmpz_mod_poly_factor_t res, const fmpz_mod_poly_t f, const fmpz_mod_ctx_t ctx) noexcept # Factorises a non-constant polynomial ``f`` into monic irreducible # factors using the Cantor-Zassenhaus algorithm. - void fmpz_mod_poly_factor_kaltofen_shoup(fmpz_mod_poly_factor_t res, const fmpz_mod_poly_t poly, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_factor_kaltofen_shoup(fmpz_mod_poly_factor_t res, const fmpz_mod_poly_t poly, const fmpz_mod_ctx_t ctx) noexcept # Factorises a non-constant polynomial ``poly`` into monic irreducible # factors using the fast version of Cantor-Zassenhaus algorithm proposed by # Kaltofen and Shoup (1998). More precisely this algorithm uses a @@ -131,22 +131,22 @@ cdef extern from "flint_wrap.h": # step. If :func:`flint_get_num_threads` is greater than one # :func:`fmpz_mod_poly_factor_distinct_deg_threaded` is used. - void fmpz_mod_poly_factor_berlekamp(fmpz_mod_poly_factor_t factors, const fmpz_mod_poly_t f, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_factor_berlekamp(fmpz_mod_poly_factor_t factors, const fmpz_mod_poly_t f, const fmpz_mod_ctx_t ctx) noexcept # Factorises a non-constant polynomial ``f`` into monic irreducible # factors using the Berlekamp algorithm. - void _fmpz_mod_poly_interval_poly_worker(void* arg_ptr) + void _fmpz_mod_poly_interval_poly_worker(void* arg_ptr) noexcept # Worker function to compute interval polynomials in distinct degree # factorisation. Input/output is stored in # :type:`fmpz_mod_poly_interval_poly_arg_t`. - void fmpz_mod_poly_roots(fmpz_mod_poly_factor_t r, const fmpz_mod_poly_t f, int with_multiplicity, const fmpz_mod_ctx_t ctx) + void fmpz_mod_poly_roots(fmpz_mod_poly_factor_t r, const fmpz_mod_poly_t f, int with_multiplicity, const fmpz_mod_ctx_t ctx) noexcept # Fill `r` with factors of the form `x - r_i` where the `r_i` are the distinct roots of a nonzero `f` in `Z/pZ`. # It is expected and not checked that the modulus of `ctx` is prime. # If `with\_multiplicity` is zero, the exponent `e_i` of the factor `x - r_i` is `1`. Otherwise, it is the largest `e_i` such that `(x-r_i)^e_i` divides `f`. # This function throws if `f` is zero, but is otherwise always successful. - int fmpz_mod_poly_roots_factored(fmpz_mod_poly_factor_t r, const fmpz_mod_poly_t f, int with_multiplicity, const fmpz_factor_t n, const fmpz_mod_ctx_t ctx) + int fmpz_mod_poly_roots_factored(fmpz_mod_poly_factor_t r, const fmpz_mod_poly_t f, int with_multiplicity, const fmpz_factor_t n, const fmpz_mod_ctx_t ctx) noexcept # Fill `r` with factors of the form `x - r_i` where the `r_i` are the distinct roots of a nonzero `f` in `Z/nZ`. # It is expected and not checked that `n` is a prime factorization of the modulus of `ctx`. # If `with\_multiplicity` is zero, the exponent `e_i` of the factor `x - r_i` is `1`. Otherwise, it is the largest `e_i` such that `(x-r_i)^e_i` divides `f`. diff --git a/src/sage/libs/flint/fmpz_mod_vec.pxd b/src/sage/libs/flint/fmpz_mod_vec.pxd index 09cd74004e2..17c41e9d642 100644 --- a/src/sage/libs/flint/fmpz_mod_vec.pxd +++ b/src/sage/libs/flint/fmpz_mod_vec.pxd @@ -12,33 +12,33 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void _fmpz_mod_vec_set_fmpz_vec(fmpz * A, const fmpz * B, slong len, const fmpz_mod_ctx_t ctx) + void _fmpz_mod_vec_set_fmpz_vec(fmpz * A, const fmpz * B, slong len, const fmpz_mod_ctx_t ctx) noexcept # Set the `fmpz_mod_vec` `(A, len)` to the `fmpz_vec` `(B, len)` after # reduction of each entry modulo the modulus.. - void _fmpz_mod_vec_neg(fmpz * A, const fmpz * B, slong len, const fmpz_mod_ctx_t ctx) + void _fmpz_mod_vec_neg(fmpz * A, const fmpz * B, slong len, const fmpz_mod_ctx_t ctx) noexcept # Set `(A, len)` to `-(B, len)`. - void _fmpz_mod_vec_add(fmpz * a, const fmpz * b, const fmpz * c, slong n, const fmpz_mod_ctx_t ctx) + void _fmpz_mod_vec_add(fmpz * a, const fmpz * b, const fmpz * c, slong n, const fmpz_mod_ctx_t ctx) noexcept # Set (A, len)` to `(B, len) + (C, len)`. - void _fmpz_mod_vec_sub(fmpz * a, const fmpz * b, const fmpz * c, slong n, const fmpz_mod_ctx_t ctx) + void _fmpz_mod_vec_sub(fmpz * a, const fmpz * b, const fmpz * c, slong n, const fmpz_mod_ctx_t ctx) noexcept # Set (A, len)` to `(B, len) - (C, len)`. - void _fmpz_mod_vec_scalar_mul_fmpz_mod(fmpz * A, const fmpz * B, slong len, const fmpz_t c, const fmpz_mod_ctx_t ctx) + void _fmpz_mod_vec_scalar_mul_fmpz_mod(fmpz * A, const fmpz * B, slong len, const fmpz_t c, const fmpz_mod_ctx_t ctx) noexcept # Set `(A, len)` to `(B, len)*c`. - void _fmpz_mod_vec_scalar_addmul_fmpz_mod(fmpz * A, const fmpz * B, slong len, const fmpz_t c, const fmpz_mod_ctx_t ctx) + void _fmpz_mod_vec_scalar_addmul_fmpz_mod(fmpz * A, const fmpz * B, slong len, const fmpz_t c, const fmpz_mod_ctx_t ctx) noexcept # Set `(A, len)` to `(A, len) + (B, len)*c`. - void _fmpz_mod_vec_scalar_div_fmpz_mod(fmpz * A, const fmpz * B, slong len, const fmpz_t c, const fmpz_mod_ctx_t ctx) + void _fmpz_mod_vec_scalar_div_fmpz_mod(fmpz * A, const fmpz * B, slong len, const fmpz_t c, const fmpz_mod_ctx_t ctx) noexcept # Set `(A, len)` to `(B, len)/c` assuming `c` is nonzero. - void _fmpz_mod_vec_dot(fmpz_t d, const fmpz * A, const fmpz * B, slong len, const fmpz_mod_ctx_t ctx) + void _fmpz_mod_vec_dot(fmpz_t d, const fmpz * A, const fmpz * B, slong len, const fmpz_mod_ctx_t ctx) noexcept # Set `d` to the dot product of `(A, len)` with `(B, len)`. - void _fmpz_mod_vec_dot_rev(fmpz_t d, const fmpz * A, const fmpz * B, slong len, const fmpz_mod_ctx_t ctx) + void _fmpz_mod_vec_dot_rev(fmpz_t d, const fmpz * A, const fmpz * B, slong len, const fmpz_mod_ctx_t ctx) noexcept # Set `d` to the dot product of `(A, len)` with the reverse of the vector `(B, len)`. - void _fmpz_mod_vec_mul(fmpz * A, const fmpz * B, const fmpz * C, slong len, const fmpz_mod_ctx_t ctx) + void _fmpz_mod_vec_mul(fmpz * A, const fmpz * B, const fmpz * C, slong len, const fmpz_mod_ctx_t ctx) noexcept # Set `(A, len)` the pointwise multiplication of `(B, len)` and `(C, len)`. diff --git a/src/sage/libs/flint/fmpz_mpoly.pxd b/src/sage/libs/flint/fmpz_mpoly.pxd index dbbd02143cb..6d69d64ab5f 100644 --- a/src/sage/libs/flint/fmpz_mpoly.pxd +++ b/src/sage/libs/flint/fmpz_mpoly.pxd @@ -12,331 +12,331 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void fmpz_mpoly_ctx_init(fmpz_mpoly_ctx_t ctx, slong nvars, const ordering_t ord) + void fmpz_mpoly_ctx_init(fmpz_mpoly_ctx_t ctx, slong nvars, const ordering_t ord) noexcept # Initialise a context object for a polynomial ring with the given number of variables and the given ordering. # The possibilities for the ordering are ``ORD_LEX``, ``ORD_DEGLEX`` and ``ORD_DEGREVLEX``. - slong fmpz_mpoly_ctx_nvars(const fmpz_mpoly_ctx_t ctx) + slong fmpz_mpoly_ctx_nvars(const fmpz_mpoly_ctx_t ctx) noexcept # Return the number of variables used to initialize the context. - ordering_t fmpz_mpoly_ctx_ord(const fmpz_mpoly_ctx_t ctx) + ordering_t fmpz_mpoly_ctx_ord(const fmpz_mpoly_ctx_t ctx) noexcept # Return the ordering used to initialize the context. - void fmpz_mpoly_ctx_clear(fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_ctx_clear(fmpz_mpoly_ctx_t ctx) noexcept # Release up any space allocated by *ctx*. - void fmpz_mpoly_init(fmpz_mpoly_t A, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_init(fmpz_mpoly_t A, const fmpz_mpoly_ctx_t ctx) noexcept # Initialise *A* for use with the given and initialised context object. Its value is set to zero. - void fmpz_mpoly_init2(fmpz_mpoly_t A, slong alloc, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_init2(fmpz_mpoly_t A, slong alloc, const fmpz_mpoly_ctx_t ctx) noexcept # Initialise *A* for use with the given and initialised context object. Its value is set to zero. # It is allocated with space for *alloc* terms and at least ``MPOLY_MIN_BITS`` bits for the exponents. - void fmpz_mpoly_init3(fmpz_mpoly_t A, slong alloc, flint_bitcnt_t bits, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_init3(fmpz_mpoly_t A, slong alloc, flint_bitcnt_t bits, const fmpz_mpoly_ctx_t ctx) noexcept # Initialise *A* for use with the given and initialised context object. Its value is set to zero. # It is allocated with space for *alloc* terms and *bits* bits for the exponents. - void fmpz_mpoly_fit_length(fmpz_mpoly_t A, slong len, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_fit_length(fmpz_mpoly_t A, slong len, const fmpz_mpoly_ctx_t ctx) noexcept # Ensure that *A* has space for at least *len* terms. - void fmpz_mpoly_fit_bits(fmpz_mpoly_t A, flint_bitcnt_t bits, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_fit_bits(fmpz_mpoly_t A, flint_bitcnt_t bits, const fmpz_mpoly_ctx_t ctx) noexcept # Ensure that the exponent fields of *A* have at least *bits* bits. - void fmpz_mpoly_realloc(fmpz_mpoly_t A, slong alloc, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_realloc(fmpz_mpoly_t A, slong alloc, const fmpz_mpoly_ctx_t ctx) noexcept # Reallocate *A* to have space for *alloc* terms. # Assumes the current length of the polynomial is not greater than *alloc*. - void fmpz_mpoly_clear(fmpz_mpoly_t A, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_clear(fmpz_mpoly_t A, const fmpz_mpoly_ctx_t ctx) noexcept # Release any space allocated for *A*. - char * fmpz_mpoly_get_str_pretty(const fmpz_mpoly_t A, const char ** x, const fmpz_mpoly_ctx_t ctx) + char * fmpz_mpoly_get_str_pretty(const fmpz_mpoly_t A, const char ** x, const fmpz_mpoly_ctx_t ctx) noexcept # Return a string, which the user is responsible for cleaning up, representing *A*, given an array of variable strings *x*. - int fmpz_mpoly_fprint_pretty(FILE * file, const fmpz_mpoly_t A, const char ** x, const fmpz_mpoly_ctx_t ctx) + int fmpz_mpoly_fprint_pretty(FILE * file, const fmpz_mpoly_t A, const char ** x, const fmpz_mpoly_ctx_t ctx) noexcept # Print a string representing *A* to *file*. - int fmpz_mpoly_print_pretty(const fmpz_mpoly_t A, const char ** x, const fmpz_mpoly_ctx_t ctx) + int fmpz_mpoly_print_pretty(const fmpz_mpoly_t A, const char ** x, const fmpz_mpoly_ctx_t ctx) noexcept # Print a string representing *A* to ``stdout``. - int fmpz_mpoly_set_str_pretty(fmpz_mpoly_t A, const char * str, const char ** x, const fmpz_mpoly_ctx_t ctx) + int fmpz_mpoly_set_str_pretty(fmpz_mpoly_t A, const char * str, const char ** x, const fmpz_mpoly_ctx_t ctx) noexcept # Set *A* to the polynomial in the null-terminates string *str* given an array *x* of variable strings. # If parsing *str* fails, *A* is set to zero, and `-1` is returned. Otherwise, `0` is returned. # The operations ``+``, ``-``, ``*``, and ``/`` are permitted along with integers and the variables in *x*. The character ``^`` must be immediately followed by the (integer) exponent. # If any division is not exact, parsing fails. - void fmpz_mpoly_gen(fmpz_mpoly_t A, slong var, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_gen(fmpz_mpoly_t A, slong var, const fmpz_mpoly_ctx_t ctx) noexcept # Set *A* to the variable of index *var*, where `var = 0` corresponds to the variable with the most significance with respect to the ordering. - bint fmpz_mpoly_is_gen(const fmpz_mpoly_t A, slong var, const fmpz_mpoly_ctx_t ctx) + bint fmpz_mpoly_is_gen(const fmpz_mpoly_t A, slong var, const fmpz_mpoly_ctx_t ctx) noexcept # If `var \ge 0`, return `1` if *A* is equal to the `var`-th generator, otherwise return `0`. # If `var < 0`, return `1` if the polynomial is equal to any generator, otherwise return `0`. - void fmpz_mpoly_set(fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_set(fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_mpoly_ctx_t ctx) noexcept # Set *A* to *B*. - bint fmpz_mpoly_equal(const fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_mpoly_ctx_t ctx) + bint fmpz_mpoly_equal(const fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_mpoly_ctx_t ctx) noexcept # Return `1` if *A* is equal to *B*, else return `0`. - void fmpz_mpoly_swap(fmpz_mpoly_t poly1, fmpz_mpoly_t poly2, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_swap(fmpz_mpoly_t poly1, fmpz_mpoly_t poly2, const fmpz_mpoly_ctx_t ctx) noexcept # Efficiently swap *A* and *B*. - int _fmpz_mpoly_fits_small(const fmpz * poly, slong len) + int _fmpz_mpoly_fits_small(const fmpz * poly, slong len) noexcept # Return 1 if the array of coefficients of length *len* consists # entirely of values that are small ``fmpz`` values, i.e. of at most # ``FLINT_BITS - 2`` bits plus a sign bit. - slong fmpz_mpoly_max_bits(const fmpz_mpoly_t A) + slong fmpz_mpoly_max_bits(const fmpz_mpoly_t A) noexcept # Computes the maximum number of bits `b` required to represent the absolute # values of the coefficients of *A*. If all of the coefficients are # positive, `b` is returned, otherwise `-b` is returned. - bint fmpz_mpoly_is_fmpz(const fmpz_mpoly_t A, const fmpz_mpoly_ctx_t ctx) + bint fmpz_mpoly_is_fmpz(const fmpz_mpoly_t A, const fmpz_mpoly_ctx_t ctx) noexcept # Return `1` if *A* is a constant, else return `0`. - void fmpz_mpoly_get_fmpz(fmpz_t c, const fmpz_mpoly_t A, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_get_fmpz(fmpz_t c, const fmpz_mpoly_t A, const fmpz_mpoly_ctx_t ctx) noexcept # Assuming that *A* is a constant, set *c* to this constant. # This function throws if *A* is not a constant. - void fmpz_mpoly_set_fmpz(fmpz_mpoly_t A, const fmpz_t c, const fmpz_mpoly_ctx_t ctx) - void fmpz_mpoly_set_ui(fmpz_mpoly_t A, ulong c, const fmpz_mpoly_ctx_t ctx) - void fmpz_mpoly_set_si(fmpz_mpoly_t A, slong c, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_set_fmpz(fmpz_mpoly_t A, const fmpz_t c, const fmpz_mpoly_ctx_t ctx) noexcept + void fmpz_mpoly_set_ui(fmpz_mpoly_t A, ulong c, const fmpz_mpoly_ctx_t ctx) noexcept + void fmpz_mpoly_set_si(fmpz_mpoly_t A, slong c, const fmpz_mpoly_ctx_t ctx) noexcept # Set *A* to the constant *c*. - void fmpz_mpoly_zero(fmpz_mpoly_t A, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_zero(fmpz_mpoly_t A, const fmpz_mpoly_ctx_t ctx) noexcept # Set *A* to the constant `0`. - void fmpz_mpoly_one(fmpz_mpoly_t A, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_one(fmpz_mpoly_t A, const fmpz_mpoly_ctx_t ctx) noexcept # Set *A* to the constant `1`. - bint fmpz_mpoly_equal_fmpz(const fmpz_mpoly_t A, const fmpz_t c, const fmpz_mpoly_ctx_t ctx) - bint fmpz_mpoly_equal_ui(const fmpz_mpoly_t A, ulong c, const fmpz_mpoly_ctx_t ctx) - bint fmpz_mpoly_equal_si(const fmpz_mpoly_t A, slong c, const fmpz_mpoly_ctx_t ctx) + bint fmpz_mpoly_equal_fmpz(const fmpz_mpoly_t A, const fmpz_t c, const fmpz_mpoly_ctx_t ctx) noexcept + bint fmpz_mpoly_equal_ui(const fmpz_mpoly_t A, ulong c, const fmpz_mpoly_ctx_t ctx) noexcept + bint fmpz_mpoly_equal_si(const fmpz_mpoly_t A, slong c, const fmpz_mpoly_ctx_t ctx) noexcept # Return `1` if *A* is equal to the constant *c*, else return `0`. - bint fmpz_mpoly_is_zero(const fmpz_mpoly_t A, const fmpz_mpoly_ctx_t ctx) + bint fmpz_mpoly_is_zero(const fmpz_mpoly_t A, const fmpz_mpoly_ctx_t ctx) noexcept # Return `1` if *A* is the constant `0`, else return `0`. - bint fmpz_mpoly_is_one(const fmpz_mpoly_t A, const fmpz_mpoly_ctx_t ctx) + bint fmpz_mpoly_is_one(const fmpz_mpoly_t A, const fmpz_mpoly_ctx_t ctx) noexcept # Return `1` if *A* is the constant `1`, else return `0`. - int fmpz_mpoly_degrees_fit_si(const fmpz_mpoly_t A, const fmpz_mpoly_ctx_t ctx) + int fmpz_mpoly_degrees_fit_si(const fmpz_mpoly_t A, const fmpz_mpoly_ctx_t ctx) noexcept # Return `1` if the degrees of *A* with respect to each variable fit into an ``slong``, otherwise return `0`. - void fmpz_mpoly_degrees_fmpz(fmpz ** degs, const fmpz_mpoly_t A, const fmpz_mpoly_ctx_t ctx) - void fmpz_mpoly_degrees_si(slong * degs, const fmpz_mpoly_t A, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_degrees_fmpz(fmpz ** degs, const fmpz_mpoly_t A, const fmpz_mpoly_ctx_t ctx) noexcept + void fmpz_mpoly_degrees_si(slong * degs, const fmpz_mpoly_t A, const fmpz_mpoly_ctx_t ctx) noexcept # Set *degs* to the degrees of *A* with respect to each variable. # If *A* is zero, all degrees are set to `-1`. - void fmpz_mpoly_degree_fmpz(fmpz_t deg, const fmpz_mpoly_t A, slong var, const fmpz_mpoly_ctx_t ctx) - slong fmpz_mpoly_degree_si(const fmpz_mpoly_t A, slong var, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_degree_fmpz(fmpz_t deg, const fmpz_mpoly_t A, slong var, const fmpz_mpoly_ctx_t ctx) noexcept + slong fmpz_mpoly_degree_si(const fmpz_mpoly_t A, slong var, const fmpz_mpoly_ctx_t ctx) noexcept # Either return or set *deg* to the degree of *A* with respect to the variable of index *var*. # If *A* is zero, the degree is defined to be `-1`. - int fmpz_mpoly_total_degree_fits_si(const fmpz_mpoly_t A, const fmpz_mpoly_ctx_t ctx) + int fmpz_mpoly_total_degree_fits_si(const fmpz_mpoly_t A, const fmpz_mpoly_ctx_t ctx) noexcept # Return `1` if the total degree of *A* fits into an ``slong``, otherwise return `0`. - void fmpz_mpoly_total_degree_fmpz(fmpz_t tdeg, const fmpz_mpoly_t A, const fmpz_mpoly_ctx_t ctx) - slong fmpz_mpoly_total_degree_si(const fmpz_mpoly_t A, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_total_degree_fmpz(fmpz_t tdeg, const fmpz_mpoly_t A, const fmpz_mpoly_ctx_t ctx) noexcept + slong fmpz_mpoly_total_degree_si(const fmpz_mpoly_t A, const fmpz_mpoly_ctx_t ctx) noexcept # Either return or set *tdeg* to the total degree of *A*. # If *A* is zero, the total degree is defined to be `-1`. - void fmpz_mpoly_used_vars(int * used, const fmpz_mpoly_t A, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_used_vars(int * used, const fmpz_mpoly_t A, const fmpz_mpoly_ctx_t ctx) noexcept # For each variable index *i*, set ``used[i]`` to nonzero if the variable of index *i* appears in *A* and to zero otherwise. - void fmpz_mpoly_get_coeff_fmpz_monomial(fmpz_t c, const fmpz_mpoly_t A, const fmpz_mpoly_t M, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_get_coeff_fmpz_monomial(fmpz_t c, const fmpz_mpoly_t A, const fmpz_mpoly_t M, const fmpz_mpoly_ctx_t ctx) noexcept # Assuming that *M* is a monomial, set *c* to the coefficient of the corresponding monomial in *A*. # This function throws if *M* is not a monomial. - void fmpz_mpoly_set_coeff_fmpz_monomial(fmpz_mpoly_t poly, const fmpz_t c, const fmpz_mpoly_t poly2, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_set_coeff_fmpz_monomial(fmpz_mpoly_t poly, const fmpz_t c, const fmpz_mpoly_t poly2, const fmpz_mpoly_ctx_t ctx) noexcept # Assuming that *M* is a monomial, set the coefficient of the corresponding monomial in *A* to *c*. # This function throws if *M* is not a monomial. - void fmpz_mpoly_get_coeff_fmpz_fmpz(fmpz_t c, const fmpz_mpoly_t A, fmpz * const * exp, const fmpz_mpoly_ctx_t ctx) - ulong fmpz_mpoly_get_coeff_ui_fmpz(const fmpz_mpoly_t A, fmpz * const * exp, const fmpz_mpoly_ctx_t ctx) - slong fmpz_mpoly_get_coeff_si_fmpz(const fmpz_mpoly_t A, fmpz * const * exp, const fmpz_mpoly_ctx_t ctx) - void fmpz_mpoly_get_coeff_fmpz_ui(fmpz_t c, const fmpz_mpoly_t A, const ulong * exp, const fmpz_mpoly_ctx_t ctx) - ulong fmpz_mpoly_get_coeff_ui_ui(const fmpz_mpoly_t A, const ulong * exp, const fmpz_mpoly_ctx_t ctx) - slong fmpz_mpoly_get_coeff_si_ui(const fmpz_mpoly_t A, const ulong * exp, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_get_coeff_fmpz_fmpz(fmpz_t c, const fmpz_mpoly_t A, fmpz * const * exp, const fmpz_mpoly_ctx_t ctx) noexcept + ulong fmpz_mpoly_get_coeff_ui_fmpz(const fmpz_mpoly_t A, fmpz * const * exp, const fmpz_mpoly_ctx_t ctx) noexcept + slong fmpz_mpoly_get_coeff_si_fmpz(const fmpz_mpoly_t A, fmpz * const * exp, const fmpz_mpoly_ctx_t ctx) noexcept + void fmpz_mpoly_get_coeff_fmpz_ui(fmpz_t c, const fmpz_mpoly_t A, const ulong * exp, const fmpz_mpoly_ctx_t ctx) noexcept + ulong fmpz_mpoly_get_coeff_ui_ui(const fmpz_mpoly_t A, const ulong * exp, const fmpz_mpoly_ctx_t ctx) noexcept + slong fmpz_mpoly_get_coeff_si_ui(const fmpz_mpoly_t A, const ulong * exp, const fmpz_mpoly_ctx_t ctx) noexcept # Either return or set *c* to the coefficient of the monomial with exponent vector *exp*. - void fmpz_mpoly_set_coeff_fmpz_fmpz(fmpz_mpoly_t A, const fmpz_t c, fmpz * const * exp, const fmpz_mpoly_ctx_t ctx) - void fmpz_mpoly_set_coeff_ui_fmpz(fmpz_mpoly_t A, ulong c, fmpz * const * exp, const fmpz_mpoly_ctx_t ctx) - void fmpz_mpoly_set_coeff_si_fmpz(fmpz_mpoly_t A, slong c, fmpz * const * exp, const fmpz_mpoly_ctx_t ctx) - void fmpz_mpoly_set_coeff_fmpz_ui(fmpz_mpoly_t A, const fmpz_t c, const ulong * exp, const fmpz_mpoly_ctx_t ctx) - void fmpz_mpoly_set_coeff_ui_ui(fmpz_mpoly_t A, ulong c, const ulong * exp, const fmpz_mpoly_ctx_t ctx) - void fmpz_mpoly_set_coeff_si_ui(fmpz_mpoly_t A, slong c, const ulong * exp, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_set_coeff_fmpz_fmpz(fmpz_mpoly_t A, const fmpz_t c, fmpz * const * exp, const fmpz_mpoly_ctx_t ctx) noexcept + void fmpz_mpoly_set_coeff_ui_fmpz(fmpz_mpoly_t A, ulong c, fmpz * const * exp, const fmpz_mpoly_ctx_t ctx) noexcept + void fmpz_mpoly_set_coeff_si_fmpz(fmpz_mpoly_t A, slong c, fmpz * const * exp, const fmpz_mpoly_ctx_t ctx) noexcept + void fmpz_mpoly_set_coeff_fmpz_ui(fmpz_mpoly_t A, const fmpz_t c, const ulong * exp, const fmpz_mpoly_ctx_t ctx) noexcept + void fmpz_mpoly_set_coeff_ui_ui(fmpz_mpoly_t A, ulong c, const ulong * exp, const fmpz_mpoly_ctx_t ctx) noexcept + void fmpz_mpoly_set_coeff_si_ui(fmpz_mpoly_t A, slong c, const ulong * exp, const fmpz_mpoly_ctx_t ctx) noexcept # Set the coefficient of the monomial with exponent vector *exp* to *c*. - void fmpz_mpoly_get_coeff_vars_ui(fmpz_mpoly_t C, const fmpz_mpoly_t A, const slong * vars, const ulong * exps, slong length, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_get_coeff_vars_ui(fmpz_mpoly_t C, const fmpz_mpoly_t A, const slong * vars, const ulong * exps, slong length, const fmpz_mpoly_ctx_t ctx) noexcept # Set *C* to the coefficient of *A* with respect to the variables in *vars* with powers in the corresponding array *exps*. # Both *vars* and *exps* point to array of length *length*. It is assumed that `0 < length \le nvars(A)` and that the variables in *vars* are distinct. - int fmpz_mpoly_cmp(const fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_mpoly_ctx_t ctx) + int fmpz_mpoly_cmp(const fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_mpoly_ctx_t ctx) noexcept # Return `1` (resp. `-1`, or `0`) if *A* is after (resp. before, same as) *B* in some arbitrary but fixed total ordering of the polynomials. # This ordering agrees with the usual ordering of monomials when *A* and *B* are both monomials. - bint fmpz_mpoly_is_fmpz_poly(const fmpz_mpoly_t A, slong var, const fmpz_mpoly_ctx_t ctx) + bint fmpz_mpoly_is_fmpz_poly(const fmpz_mpoly_t A, slong var, const fmpz_mpoly_ctx_t ctx) noexcept # Return whether *A* is a univariate polynomial in the variable with index *var*. - int fmpz_mpoly_get_fmpz_poly(fmpz_poly_t A, const fmpz_mpoly_t B, slong var, const fmpz_mpoly_ctx_t ctx) + int fmpz_mpoly_get_fmpz_poly(fmpz_poly_t A, const fmpz_mpoly_t B, slong var, const fmpz_mpoly_ctx_t ctx) noexcept # If *B* is a univariate polynomial in the variable with index *var*, # set *A* to this polynomial and return 1; otherwise return 0. - void fmpz_mpoly_set_fmpz_poly(fmpz_mpoly_t A, const fmpz_poly_t B, slong var, const fmpz_mpoly_ctx_t ctx) - void fmpz_mpoly_set_gen_fmpz_poly(fmpz_mpoly_t A, slong var, const fmpz_poly_t B, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_set_fmpz_poly(fmpz_mpoly_t A, const fmpz_poly_t B, slong var, const fmpz_mpoly_ctx_t ctx) noexcept + void fmpz_mpoly_set_gen_fmpz_poly(fmpz_mpoly_t A, slong var, const fmpz_poly_t B, const fmpz_mpoly_ctx_t ctx) noexcept # Set *A* to the univariate polynomial *B* in the variable with index *var*. - fmpz * fmpz_mpoly_term_coeff_ref(fmpz_mpoly_t A, slong i, const fmpz_mpoly_ctx_t ctx) + fmpz * fmpz_mpoly_term_coeff_ref(fmpz_mpoly_t A, slong i, const fmpz_mpoly_ctx_t ctx) noexcept # Return a reference to the coefficient of index *i* of *A*. - bint fmpz_mpoly_is_canonical(const fmpz_mpoly_t A, const fmpz_mpoly_ctx_t ctx) + bint fmpz_mpoly_is_canonical(const fmpz_mpoly_t A, const fmpz_mpoly_ctx_t ctx) noexcept # Return `1` if *A* is in canonical form. Otherwise, return `0`. # To be in canonical form, all of the terms must have nonzero coefficient, and the terms must be sorted from greatest to least. - slong fmpz_mpoly_length(const fmpz_mpoly_t A, const fmpz_mpoly_ctx_t ctx) + slong fmpz_mpoly_length(const fmpz_mpoly_t A, const fmpz_mpoly_ctx_t ctx) noexcept # Return the number of terms in *A*. # If the polynomial is in canonical form, this will be the number of nonzero coefficients. - void fmpz_mpoly_resize(fmpz_mpoly_t A, slong new_length, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_resize(fmpz_mpoly_t A, slong new_length, const fmpz_mpoly_ctx_t ctx) noexcept # Set the length of *A* to `new\_length`. # Terms are either deleted from the end, or new zero terms are appended. - void fmpz_mpoly_get_term_coeff_fmpz(fmpz_t c, const fmpz_mpoly_t A, slong i, const fmpz_mpoly_ctx_t ctx) - ulong fmpz_mpoly_get_term_coeff_ui(const fmpz_mpoly_t A, slong i, const fmpz_mpoly_ctx_t ctx) - slong fmpz_mpoly_get_term_coeff_si(const fmpz_mpoly_t poly, slong i, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_get_term_coeff_fmpz(fmpz_t c, const fmpz_mpoly_t A, slong i, const fmpz_mpoly_ctx_t ctx) noexcept + ulong fmpz_mpoly_get_term_coeff_ui(const fmpz_mpoly_t A, slong i, const fmpz_mpoly_ctx_t ctx) noexcept + slong fmpz_mpoly_get_term_coeff_si(const fmpz_mpoly_t poly, slong i, const fmpz_mpoly_ctx_t ctx) noexcept # Either return or set *c* to the coefficient of the term of index *i*. - void fmpz_mpoly_set_term_coeff_fmpz(fmpz_mpoly_t A, slong i, const fmpz_t c, const fmpz_mpoly_ctx_t ctx) - void fmpz_mpoly_set_term_coeff_ui(fmpz_mpoly_t A, slong i, ulong c, const fmpz_mpoly_ctx_t ctx) - void fmpz_mpoly_set_term_coeff_si(fmpz_mpoly_t A, slong i, slong c, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_set_term_coeff_fmpz(fmpz_mpoly_t A, slong i, const fmpz_t c, const fmpz_mpoly_ctx_t ctx) noexcept + void fmpz_mpoly_set_term_coeff_ui(fmpz_mpoly_t A, slong i, ulong c, const fmpz_mpoly_ctx_t ctx) noexcept + void fmpz_mpoly_set_term_coeff_si(fmpz_mpoly_t A, slong i, slong c, const fmpz_mpoly_ctx_t ctx) noexcept # Set the coefficient of the term of index *i* to *c*. - int fmpz_mpoly_term_exp_fits_si(const fmpz_mpoly_t poly, slong i, const fmpz_mpoly_ctx_t ctx) - int fmpz_mpoly_term_exp_fits_ui(const fmpz_mpoly_t poly, slong i, const fmpz_mpoly_ctx_t ctx) + int fmpz_mpoly_term_exp_fits_si(const fmpz_mpoly_t poly, slong i, const fmpz_mpoly_ctx_t ctx) noexcept + int fmpz_mpoly_term_exp_fits_ui(const fmpz_mpoly_t poly, slong i, const fmpz_mpoly_ctx_t ctx) noexcept # Return `1` if all entries of the exponent vector of the term of index *i* fit into an ``slong`` (resp. a ``ulong``). Otherwise, return `0`. - void fmpz_mpoly_get_term_exp_fmpz(fmpz ** exp, const fmpz_mpoly_t A, slong i, const fmpz_mpoly_ctx_t ctx) - void fmpz_mpoly_get_term_exp_ui(ulong * exp, const fmpz_mpoly_t A, slong i, const fmpz_mpoly_ctx_t ctx) - void fmpz_mpoly_get_term_exp_si(slong * exp, const fmpz_mpoly_t A, slong i, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_get_term_exp_fmpz(fmpz ** exp, const fmpz_mpoly_t A, slong i, const fmpz_mpoly_ctx_t ctx) noexcept + void fmpz_mpoly_get_term_exp_ui(ulong * exp, const fmpz_mpoly_t A, slong i, const fmpz_mpoly_ctx_t ctx) noexcept + void fmpz_mpoly_get_term_exp_si(slong * exp, const fmpz_mpoly_t A, slong i, const fmpz_mpoly_ctx_t ctx) noexcept # Set *exp* to the exponent vector of the term of index *i*. # The ``_ui`` (resp. ``_si``) version throws if any entry does not fit into a ``ulong`` (resp. ``slong``). - ulong fmpz_mpoly_get_term_var_exp_ui(const fmpz_mpoly_t A, slong i, slong var, const fmpz_mpoly_ctx_t ctx) - slong fmpz_mpoly_get_term_var_exp_si(const fmpz_mpoly_t A, slong i, slong var, const fmpz_mpoly_ctx_t ctx) + ulong fmpz_mpoly_get_term_var_exp_ui(const fmpz_mpoly_t A, slong i, slong var, const fmpz_mpoly_ctx_t ctx) noexcept + slong fmpz_mpoly_get_term_var_exp_si(const fmpz_mpoly_t A, slong i, slong var, const fmpz_mpoly_ctx_t ctx) noexcept # Return the exponent of the variable `var` of the term of index *i*. # This function throws if the exponent does not fit into a ``ulong`` (resp. ``slong``). - void fmpz_mpoly_set_term_exp_fmpz(fmpz_mpoly_t A, slong i, fmpz * const * exp, const fmpz_mpoly_ctx_t ctx) - void fmpz_mpoly_set_term_exp_ui(fmpz_mpoly_t A, slong i, const ulong * exp, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_set_term_exp_fmpz(fmpz_mpoly_t A, slong i, fmpz * const * exp, const fmpz_mpoly_ctx_t ctx) noexcept + void fmpz_mpoly_set_term_exp_ui(fmpz_mpoly_t A, slong i, const ulong * exp, const fmpz_mpoly_ctx_t ctx) noexcept # Set the exponent vector of the term of index *i* to *exp*. - void fmpz_mpoly_get_term(fmpz_mpoly_t M, const fmpz_mpoly_t A, slong i, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_get_term(fmpz_mpoly_t M, const fmpz_mpoly_t A, slong i, const fmpz_mpoly_ctx_t ctx) noexcept # Set `M` to the term of index *i* in *A*. - void fmpz_mpoly_get_term_monomial(fmpz_mpoly_t M, const fmpz_mpoly_t A, slong i, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_get_term_monomial(fmpz_mpoly_t M, const fmpz_mpoly_t A, slong i, const fmpz_mpoly_ctx_t ctx) noexcept # Set `M` to the monomial of the term of index *i* in *A*. The coefficient of `M` will be one. - void fmpz_mpoly_push_term_fmpz_fmpz(fmpz_mpoly_t A, const fmpz_t c, fmpz * const * exp, const fmpz_mpoly_ctx_t ctx) - void fmpz_mpoly_push_term_fmpz_ffmpz(fmpz_mpoly_t A, const fmpz_t c, const fmpz * exp, const fmpz_mpoly_ctx_t ctx) - void fmpz_mpoly_push_term_ui_fmpz(fmpz_mpoly_t A, ulong c, fmpz * const * exp, const fmpz_mpoly_ctx_t ctx) - void fmpz_mpoly_push_term_ui_ffmpz(fmpz_mpoly_t A, ulong c, const fmpz * exp, const fmpz_mpoly_ctx_t ctx) - void fmpz_mpoly_push_term_si_fmpz(fmpz_mpoly_t A, slong c, fmpz * const * exp, const fmpz_mpoly_ctx_t ctx) - void fmpz_mpoly_push_term_si_ffmpz(fmpz_mpoly_t A, slong c, const fmpz * exp, const fmpz_mpoly_ctx_t ctx) - void fmpz_mpoly_push_term_fmpz_ui(fmpz_mpoly_t A, const fmpz_t c, const ulong * exp, const fmpz_mpoly_ctx_t ctx) - void fmpz_mpoly_push_term_ui_ui(fmpz_mpoly_t A, ulong c, const ulong * exp, const fmpz_mpoly_ctx_t ctx) - void fmpz_mpoly_push_term_si_ui(fmpz_mpoly_t A, slong c, const ulong * exp, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_push_term_fmpz_fmpz(fmpz_mpoly_t A, const fmpz_t c, fmpz * const * exp, const fmpz_mpoly_ctx_t ctx) noexcept + void fmpz_mpoly_push_term_fmpz_ffmpz(fmpz_mpoly_t A, const fmpz_t c, const fmpz * exp, const fmpz_mpoly_ctx_t ctx) noexcept + void fmpz_mpoly_push_term_ui_fmpz(fmpz_mpoly_t A, ulong c, fmpz * const * exp, const fmpz_mpoly_ctx_t ctx) noexcept + void fmpz_mpoly_push_term_ui_ffmpz(fmpz_mpoly_t A, ulong c, const fmpz * exp, const fmpz_mpoly_ctx_t ctx) noexcept + void fmpz_mpoly_push_term_si_fmpz(fmpz_mpoly_t A, slong c, fmpz * const * exp, const fmpz_mpoly_ctx_t ctx) noexcept + void fmpz_mpoly_push_term_si_ffmpz(fmpz_mpoly_t A, slong c, const fmpz * exp, const fmpz_mpoly_ctx_t ctx) noexcept + void fmpz_mpoly_push_term_fmpz_ui(fmpz_mpoly_t A, const fmpz_t c, const ulong * exp, const fmpz_mpoly_ctx_t ctx) noexcept + void fmpz_mpoly_push_term_ui_ui(fmpz_mpoly_t A, ulong c, const ulong * exp, const fmpz_mpoly_ctx_t ctx) noexcept + void fmpz_mpoly_push_term_si_ui(fmpz_mpoly_t A, slong c, const ulong * exp, const fmpz_mpoly_ctx_t ctx) noexcept # Append a term to *A* with coefficient *c* and exponent vector *exp*. # This function runs in constant average time. - void fmpz_mpoly_sort_terms(fmpz_mpoly_t A, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_sort_terms(fmpz_mpoly_t A, const fmpz_mpoly_ctx_t ctx) noexcept # Sort the terms of *A* into the canonical ordering dictated by the ordering in *ctx*. # This function simply reorders the terms: It does not combine like terms, nor does it delete terms with coefficient zero. # This function runs in linear time in the size of *A*. - void fmpz_mpoly_combine_like_terms(fmpz_mpoly_t A, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_combine_like_terms(fmpz_mpoly_t A, const fmpz_mpoly_ctx_t ctx) noexcept # Combine adjacent like terms in *A* and delete terms with coefficient zero. # If the terms of *A* were sorted to begin with, the result will be in canonical form. # This function runs in linear time in the size of *A*. - void fmpz_mpoly_reverse(fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_reverse(fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_mpoly_ctx_t ctx) noexcept # Set *A* to the reversal of *B*. - void fmpz_mpoly_randtest_bound(fmpz_mpoly_t A, flint_rand_t state, slong length, mp_limb_t coeff_bits, ulong exp_bound, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_randtest_bound(fmpz_mpoly_t A, flint_rand_t state, slong length, mp_limb_t coeff_bits, ulong exp_bound, const fmpz_mpoly_ctx_t ctx) noexcept # Generate a random polynomial with length up to *length* and exponents in the range ``[0, exp_bound - 1]``. # The exponents of each variable are generated by calls to ``n_randint(state, exp_bound)``. - void fmpz_mpoly_randtest_bounds(fmpz_mpoly_t A, flint_rand_t state, slong length, mp_limb_t coeff_bits, ulong * exp_bounds, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_randtest_bounds(fmpz_mpoly_t A, flint_rand_t state, slong length, mp_limb_t coeff_bits, ulong * exp_bounds, const fmpz_mpoly_ctx_t ctx) noexcept # Generate a random polynomial with length up to *length* and exponents in the range ``[0, exp_bounds[i] - 1]``. # The exponents of the variable of index *i* are generated by calls to ``n_randint(state, exp_bounds[i])``. - void fmpz_mpoly_randtest_bits(fmpz_mpoly_t A, flint_rand_t state, slong length, mp_limb_t coeff_bits, mp_limb_t exp_bits, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_randtest_bits(fmpz_mpoly_t A, flint_rand_t state, slong length, mp_limb_t coeff_bits, mp_limb_t exp_bits, const fmpz_mpoly_ctx_t ctx) noexcept # Generate a random polynomial with length up to the given length and exponents whose packed form does not exceed the given bit count. # The parameter ``coeff_bits`` to the three functions ``fmpz_mpoly_randtest_{bound|bounds|bits}`` is merely a suggestion for the approximate bit count of the resulting signed coefficients. # The function :func:`fmpz_mpoly_max_bits` will give the exact bit count of the result. - void fmpz_mpoly_add_fmpz(fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_t c, const fmpz_mpoly_ctx_t ctx) - void fmpz_mpoly_add_ui(fmpz_mpoly_t A, const fmpz_mpoly_t B, ulong c, const fmpz_mpoly_ctx_t ctx) - void fmpz_mpoly_add_si(fmpz_mpoly_t A, const fmpz_mpoly_t B, slong c, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_add_fmpz(fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_t c, const fmpz_mpoly_ctx_t ctx) noexcept + void fmpz_mpoly_add_ui(fmpz_mpoly_t A, const fmpz_mpoly_t B, ulong c, const fmpz_mpoly_ctx_t ctx) noexcept + void fmpz_mpoly_add_si(fmpz_mpoly_t A, const fmpz_mpoly_t B, slong c, const fmpz_mpoly_ctx_t ctx) noexcept # Set *A* to `B + c`. # If *A* and *B* are aliased, this function will probably run quickly. - void fmpz_mpoly_sub_fmpz(fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_t c, const fmpz_mpoly_ctx_t ctx) - void fmpz_mpoly_sub_ui(fmpz_mpoly_t A, const fmpz_mpoly_t B, ulong c, const fmpz_mpoly_ctx_t ctx) - void fmpz_mpoly_sub_si(fmpz_mpoly_t A, const fmpz_mpoly_t B, slong c, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_sub_fmpz(fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_t c, const fmpz_mpoly_ctx_t ctx) noexcept + void fmpz_mpoly_sub_ui(fmpz_mpoly_t A, const fmpz_mpoly_t B, ulong c, const fmpz_mpoly_ctx_t ctx) noexcept + void fmpz_mpoly_sub_si(fmpz_mpoly_t A, const fmpz_mpoly_t B, slong c, const fmpz_mpoly_ctx_t ctx) noexcept # Set *A* to `B - c`. # If *A* and *B* are aliased, this function will probably run quickly. - void fmpz_mpoly_add(fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_mpoly_t C, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_add(fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_mpoly_t C, const fmpz_mpoly_ctx_t ctx) noexcept # Set *A* to `B + C`. # If *A* and *B* are aliased, this function might run in time proportional to the size of `C`. - void fmpz_mpoly_sub(fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_mpoly_t C, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_sub(fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_mpoly_t C, const fmpz_mpoly_ctx_t ctx) noexcept # Set *A* to `B - C`. # If *A* and *B* are aliased, this function might run in time proportional to the size of `C`. - void fmpz_mpoly_neg(fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_neg(fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_mpoly_ctx_t ctx) noexcept # Set *A* to `-B`. - void fmpz_mpoly_scalar_mul_fmpz(fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_t c, const fmpz_mpoly_ctx_t ctx) - void fmpz_mpoly_scalar_mul_ui(fmpz_mpoly_t A, const fmpz_mpoly_t B, ulong c, const fmpz_mpoly_ctx_t ctx) - void fmpz_mpoly_scalar_mul_si(fmpz_mpoly_t A, const fmpz_mpoly_t B, slong c, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_scalar_mul_fmpz(fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_t c, const fmpz_mpoly_ctx_t ctx) noexcept + void fmpz_mpoly_scalar_mul_ui(fmpz_mpoly_t A, const fmpz_mpoly_t B, ulong c, const fmpz_mpoly_ctx_t ctx) noexcept + void fmpz_mpoly_scalar_mul_si(fmpz_mpoly_t A, const fmpz_mpoly_t B, slong c, const fmpz_mpoly_ctx_t ctx) noexcept # Set *A* to `B \times c`. - void fmpz_mpoly_scalar_fmma(fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_t c, const fmpz_mpoly_t D, const fmpz_t e, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_scalar_fmma(fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_t c, const fmpz_mpoly_t D, const fmpz_t e, const fmpz_mpoly_ctx_t ctx) noexcept # Sets *A* to `B \times c + D \times e`. - void fmpz_mpoly_scalar_divexact_fmpz(fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_t c, const fmpz_mpoly_ctx_t ctx) - void fmpz_mpoly_scalar_divexact_ui(fmpz_mpoly_t A, const fmpz_mpoly_t B, ulong c, const fmpz_mpoly_ctx_t ctx) - void fmpz_mpoly_scalar_divexact_si(fmpz_mpoly_t A, const fmpz_mpoly_t B, slong c, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_scalar_divexact_fmpz(fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_t c, const fmpz_mpoly_ctx_t ctx) noexcept + void fmpz_mpoly_scalar_divexact_ui(fmpz_mpoly_t A, const fmpz_mpoly_t B, ulong c, const fmpz_mpoly_ctx_t ctx) noexcept + void fmpz_mpoly_scalar_divexact_si(fmpz_mpoly_t A, const fmpz_mpoly_t B, slong c, const fmpz_mpoly_ctx_t ctx) noexcept # Set *A* to *B* divided by *c*. The division is assumed to be exact. - int fmpz_mpoly_scalar_divides_fmpz(fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_t c, const fmpz_mpoly_ctx_t ctx) - int fmpz_mpoly_scalar_divides_ui(fmpz_mpoly_t A, const fmpz_mpoly_t B, ulong c, const fmpz_mpoly_ctx_t ctx) - int fmpz_mpoly_scalar_divides_si(fmpz_mpoly_t A, const fmpz_mpoly_t B, slong c, const fmpz_mpoly_ctx_t ctx) + int fmpz_mpoly_scalar_divides_fmpz(fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_t c, const fmpz_mpoly_ctx_t ctx) noexcept + int fmpz_mpoly_scalar_divides_ui(fmpz_mpoly_t A, const fmpz_mpoly_t B, ulong c, const fmpz_mpoly_ctx_t ctx) noexcept + int fmpz_mpoly_scalar_divides_si(fmpz_mpoly_t A, const fmpz_mpoly_t B, slong c, const fmpz_mpoly_ctx_t ctx) noexcept # If *B* is divisible by *c*, set *A* to the exact quotient and return `1`, otherwise set *A* to zero and return `0`. - void fmpz_mpoly_derivative(fmpz_mpoly_t A, const fmpz_mpoly_t B, slong var, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_derivative(fmpz_mpoly_t A, const fmpz_mpoly_t B, slong var, const fmpz_mpoly_ctx_t ctx) noexcept # Set *A* to the derivative of *B* with respect to the variable of index `var`. - void fmpz_mpoly_integral(fmpz_mpoly_t A, fmpz_t scale, const fmpz_mpoly_t B, slong var, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_integral(fmpz_mpoly_t A, fmpz_t scale, const fmpz_mpoly_t B, slong var, const fmpz_mpoly_ctx_t ctx) noexcept # Set *A* and *scale* so that *A* is an integral of `scale \times B` with respect to the variable of index *var*, where *scale* is positive and as small as possible. - int fmpz_mpoly_evaluate_all_fmpz(fmpz_t ev, const fmpz_mpoly_t A, fmpz * const * vals, const fmpz_mpoly_ctx_t ctx) + int fmpz_mpoly_evaluate_all_fmpz(fmpz_t ev, const fmpz_mpoly_t A, fmpz * const * vals, const fmpz_mpoly_ctx_t ctx) noexcept # Set *ev* to the evaluation of *A* where the variables are replaced by the corresponding elements of the array *vals*. # Return `1` for success and `0` for failure. - int fmpz_mpoly_evaluate_one_fmpz(fmpz_mpoly_t A, const fmpz_mpoly_t B, slong var, const fmpz_t val, const fmpz_mpoly_ctx_t ctx) + int fmpz_mpoly_evaluate_one_fmpz(fmpz_mpoly_t A, const fmpz_mpoly_t B, slong var, const fmpz_t val, const fmpz_mpoly_ctx_t ctx) noexcept # Set *A* to the evaluation of *B* where the variable of index *var* is replaced by ``val``. # Return `1` for success and `0` for failure. - int fmpz_mpoly_compose_fmpz_poly(fmpz_poly_t A, const fmpz_mpoly_t B, fmpz_poly_struct * const * C, const fmpz_mpoly_ctx_t ctxB) + int fmpz_mpoly_compose_fmpz_poly(fmpz_poly_t A, const fmpz_mpoly_t B, fmpz_poly_struct * const * C, const fmpz_mpoly_ctx_t ctxB) noexcept # Set *A* to the evaluation of *B* where the variables are replaced by the corresponding elements of the array *C*. # The context object of *B* is *ctxB*. # Return `1` for success and `0` for failure. - int fmpz_mpoly_compose_fmpz_mpoly_geobucket(fmpz_mpoly_t A, const fmpz_mpoly_t B, fmpz_mpoly_struct * const * C, const fmpz_mpoly_ctx_t ctxB, const fmpz_mpoly_ctx_t ctxAC) - int fmpz_mpoly_compose_fmpz_mpoly_horner(fmpz_mpoly_t A, const fmpz_mpoly_t B, fmpz_mpoly_struct * const * C, const fmpz_mpoly_ctx_t ctxB, const fmpz_mpoly_ctx_t ctxAC) - int fmpz_mpoly_compose_fmpz_mpoly(fmpz_mpoly_t A, const fmpz_mpoly_t B, fmpz_mpoly_struct * const * C, const fmpz_mpoly_ctx_t ctxB, const fmpz_mpoly_ctx_t ctxAC) + int fmpz_mpoly_compose_fmpz_mpoly_geobucket(fmpz_mpoly_t A, const fmpz_mpoly_t B, fmpz_mpoly_struct * const * C, const fmpz_mpoly_ctx_t ctxB, const fmpz_mpoly_ctx_t ctxAC) noexcept + int fmpz_mpoly_compose_fmpz_mpoly_horner(fmpz_mpoly_t A, const fmpz_mpoly_t B, fmpz_mpoly_struct * const * C, const fmpz_mpoly_ctx_t ctxB, const fmpz_mpoly_ctx_t ctxAC) noexcept + int fmpz_mpoly_compose_fmpz_mpoly(fmpz_mpoly_t A, const fmpz_mpoly_t B, fmpz_mpoly_struct * const * C, const fmpz_mpoly_ctx_t ctxB, const fmpz_mpoly_ctx_t ctxAC) noexcept # Set *A* to the evaluation of *B* where the variables are replaced by the corresponding elements of the array *C*. # Both *A* and the elements of *C* have context object *ctxAC*, while *B* has context object *ctxB*. # The length of the array *C* is the number of variables in *ctxB*. @@ -344,98 +344,98 @@ cdef extern from "flint_wrap.h": # Return `1` for success and `0` for failure. # The main method attempts to perform the calculation using matrices and chooses heuristically between the ``geobucket`` and ``horner`` methods if needed. - void fmpz_mpoly_compose_fmpz_mpoly_gen(fmpz_mpoly_t A, const fmpz_mpoly_t B, const slong * c, const fmpz_mpoly_ctx_t ctxB, const fmpz_mpoly_ctx_t ctxAC) + void fmpz_mpoly_compose_fmpz_mpoly_gen(fmpz_mpoly_t A, const fmpz_mpoly_t B, const slong * c, const fmpz_mpoly_ctx_t ctxB, const fmpz_mpoly_ctx_t ctxAC) noexcept # Set *A* to the evaluation of *B* where the variable of index *i* in *ctxB* is replaced by the variable of index ``c[i]`` in *ctxAC*. # The length of the array *C* is the number of variables in *ctxB*. # If any ``c[i]`` is negative, the corresponding variable of *B* is replaced by zero. Otherwise, it is expected that ``c[i]`` is less than the number of variables in *ctxAC*. - void fmpz_mpoly_mul(fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_mpoly_t C, const fmpz_mpoly_ctx_t ctx) - void fmpz_mpoly_mul_threaded(fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_mpoly_t C, const fmpz_mpoly_ctx_t ctx, slong thread_limit) + void fmpz_mpoly_mul(fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_mpoly_t C, const fmpz_mpoly_ctx_t ctx) noexcept + void fmpz_mpoly_mul_threaded(fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_mpoly_t C, const fmpz_mpoly_ctx_t ctx, slong thread_limit) noexcept # Set *A* to `B \times C`. - void fmpz_mpoly_mul_johnson(fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_mpoly_t C, const fmpz_mpoly_ctx_t ctx) - void fmpz_mpoly_mul_heap_threaded(fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_mpoly_t C, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_mul_johnson(fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_mpoly_t C, const fmpz_mpoly_ctx_t ctx) noexcept + void fmpz_mpoly_mul_heap_threaded(fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_mpoly_t C, const fmpz_mpoly_ctx_t ctx) noexcept # Set *A* to `B \times C` using Johnson's heap-based method. # The first version always uses one thread. - int fmpz_mpoly_mul_array(fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_mpoly_t C, const fmpz_mpoly_ctx_t ctx) - int fmpz_mpoly_mul_array_threaded(fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_mpoly_t C, const fmpz_mpoly_ctx_t ctx) + int fmpz_mpoly_mul_array(fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_mpoly_t C, const fmpz_mpoly_ctx_t ctx) noexcept + int fmpz_mpoly_mul_array_threaded(fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_mpoly_t C, const fmpz_mpoly_ctx_t ctx) noexcept # Try to set *A* to `B \times C` using arrays. # If the return is `0`, the operation was unsuccessful. Otherwise, it was successful and the return is `1`. # The first version always uses one thread. - int fmpz_mpoly_mul_dense(fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_mpoly_t C, const fmpz_mpoly_ctx_t ctx) + int fmpz_mpoly_mul_dense(fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_mpoly_t C, const fmpz_mpoly_ctx_t ctx) noexcept # Try to set *A* to `B \times C` using dense arithmetic. # If the return is `0`, the operation was unsuccessful. Otherwise, it was successful and the return is `1`. - int fmpz_mpoly_pow_fmpz(fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_t k, const fmpz_mpoly_ctx_t ctx) + int fmpz_mpoly_pow_fmpz(fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_t k, const fmpz_mpoly_ctx_t ctx) noexcept # Set *A* to *B* raised to the *k*-th power. # Return `1` for success and `0` for failure. - int fmpz_mpoly_pow_ui(fmpz_mpoly_t A, const fmpz_mpoly_t B, ulong k, const fmpz_mpoly_ctx_t ctx) + int fmpz_mpoly_pow_ui(fmpz_mpoly_t A, const fmpz_mpoly_t B, ulong k, const fmpz_mpoly_ctx_t ctx) noexcept # Set *A* to *B* raised to the *k*-th power. # Return `1` for success and `0` for failure. - int fmpz_mpoly_divides(fmpz_mpoly_t Q, const fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_mpoly_ctx_t ctx) + int fmpz_mpoly_divides(fmpz_mpoly_t Q, const fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_mpoly_ctx_t ctx) noexcept # If *A* is divisible by *B*, set *Q* to the exact quotient and return `1`. Otherwise, set `Q` to zero and return `0`. - void fmpz_mpoly_divrem(fmpz_mpoly_t Q, fmpz_mpoly_t R, const fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_divrem(fmpz_mpoly_t Q, fmpz_mpoly_t R, const fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_mpoly_ctx_t ctx) noexcept # Set `Q` and `R` to the quotient and remainder of *A* divided by *B*. The monomials in *R* divisible by the leading monomial of *B* will have coefficients reduced modulo the absolute value of the leading coefficient of *B*. # Note that this function is not very useful if the leading coefficient *B* is not a unit. - void fmpz_mpoly_quasidivrem(fmpz_t scale, fmpz_mpoly_t Q, fmpz_mpoly_t R, const fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_quasidivrem(fmpz_t scale, fmpz_mpoly_t Q, fmpz_mpoly_t R, const fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_mpoly_ctx_t ctx) noexcept # Set *scale*, *Q* and *R* so that *Q* and *R* are the quotient and remainder of `scale \times A` divided by *B*. No monomials in *R* will be divisible by the leading monomial of *B*. - void fmpz_mpoly_div(fmpz_mpoly_t Q, const fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_div(fmpz_mpoly_t Q, const fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_mpoly_ctx_t ctx) noexcept # Perform the operation of :func:`fmpz_mpoly_divrem` and discard *R*. # Note that this function is not very useful if the division is not exact and the leading coefficient *B* is not a unit. - void fmpz_mpoly_quasidiv(fmpz_t scale, fmpz_mpoly_t Q, const fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_quasidiv(fmpz_t scale, fmpz_mpoly_t Q, const fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_mpoly_ctx_t ctx) noexcept # Perform the operation of :func:`fmpz_mpoly_quasidivrem` and discard *R*. - void fmpz_mpoly_divrem_ideal(fmpz_mpoly_struct ** Q, fmpz_mpoly_t R, const fmpz_mpoly_t A, fmpz_mpoly_struct * const * B, slong len, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_divrem_ideal(fmpz_mpoly_struct ** Q, fmpz_mpoly_t R, const fmpz_mpoly_t A, fmpz_mpoly_struct * const * B, slong len, const fmpz_mpoly_ctx_t ctx) noexcept # This function is as per :func:`fmpz_mpoly_divrem` except that it takes an array of divisor polynomials *B* and it returns an array of quotient polynomials *Q*. # The number of divisor (and hence quotient) polynomials is given by *len*. # Note that this function is not very useful if there is no unit among the leading coefficients in the array *B*. - void fmpz_mpoly_quasidivrem_ideal(fmpz_t scale, fmpz_mpoly_struct ** Q, fmpz_mpoly_t R, const fmpz_mpoly_t A, fmpz_mpoly_struct * const * B, slong len, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_quasidivrem_ideal(fmpz_t scale, fmpz_mpoly_struct ** Q, fmpz_mpoly_t R, const fmpz_mpoly_t A, fmpz_mpoly_struct * const * B, slong len, const fmpz_mpoly_ctx_t ctx) noexcept # This function is as per :func:`fmpz_mpoly_quasidivrem` except that it takes an array of divisor polynomials *B* and it returns an array of quotient polynomials *Q*. # The number of divisor (and hence quotient) polynomials is given by *len*. - void fmpz_mpoly_term_content(fmpz_mpoly_t M, const fmpz_mpoly_t A, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_term_content(fmpz_mpoly_t M, const fmpz_mpoly_t A, const fmpz_mpoly_ctx_t ctx) noexcept # Set *M* to the GCD of the terms of *A*. # If *A* is zero, *M* will be zero. Otherwise, *M* will be a monomial with positive coefficient. - int fmpz_mpoly_content_vars(fmpz_mpoly_t g, const fmpz_mpoly_t A, slong * vars, slong vars_length, const fmpz_mpoly_ctx_t ctx) + int fmpz_mpoly_content_vars(fmpz_mpoly_t g, const fmpz_mpoly_t A, slong * vars, slong vars_length, const fmpz_mpoly_ctx_t ctx) noexcept # Set *g* to the GCD of the coefficients of *A* when viewed as a polynomial in the variables *vars*. # Return `1` for success and `0` for failure. Upon success, *g* will be independent of the variables *vars*. - int fmpz_mpoly_gcd(fmpz_mpoly_t G, const fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_mpoly_ctx_t ctx) + int fmpz_mpoly_gcd(fmpz_mpoly_t G, const fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_mpoly_ctx_t ctx) noexcept # Try to set *G* to the GCD of *A* and *B* with positive leading coefficient. The GCD of zero and zero is defined to be zero. # If the return is `1` the function was successful. Otherwise the return is `0` and *G* is left untouched. - int fmpz_mpoly_gcd_cofactors(fmpz_mpoly_t G, fmpz_mpoly_t Abar, fmpz_mpoly_t Bbar, const fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_mpoly_ctx_t ctx) + int fmpz_mpoly_gcd_cofactors(fmpz_mpoly_t G, fmpz_mpoly_t Abar, fmpz_mpoly_t Bbar, const fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_mpoly_ctx_t ctx) noexcept # Do the operation of :func:`fmpz_mpoly_gcd` and also compute `Abar = A/G` and `Bbar = B/G` if successful. - int fmpz_mpoly_gcd_brown(fmpz_mpoly_t G, const fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_mpoly_ctx_t ctx) - int fmpz_mpoly_gcd_hensel(fmpz_mpoly_t G, const fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_mpoly_ctx_t ctx) - int fmpz_mpoly_gcd_subresultant(fmpz_mpoly_t G, const fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_mpoly_ctx_t ctx) - int fmpz_mpoly_gcd_zippel(fmpz_mpoly_t G, const fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_mpoly_ctx_t ctx) - int fmpz_mpoly_gcd_zippel2(fmpz_mpoly_t G, const fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_mpoly_ctx_t ctx) + int fmpz_mpoly_gcd_brown(fmpz_mpoly_t G, const fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_mpoly_ctx_t ctx) noexcept + int fmpz_mpoly_gcd_hensel(fmpz_mpoly_t G, const fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_mpoly_ctx_t ctx) noexcept + int fmpz_mpoly_gcd_subresultant(fmpz_mpoly_t G, const fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_mpoly_ctx_t ctx) noexcept + int fmpz_mpoly_gcd_zippel(fmpz_mpoly_t G, const fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_mpoly_ctx_t ctx) noexcept + int fmpz_mpoly_gcd_zippel2(fmpz_mpoly_t G, const fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_mpoly_ctx_t ctx) noexcept # Try to set *G* to the GCD of *A* and *B* using various algorithms. - int fmpz_mpoly_resultant(fmpz_mpoly_t R, const fmpz_mpoly_t A, const fmpz_mpoly_t B, slong var, const fmpz_mpoly_ctx_t ctx) + int fmpz_mpoly_resultant(fmpz_mpoly_t R, const fmpz_mpoly_t A, const fmpz_mpoly_t B, slong var, const fmpz_mpoly_ctx_t ctx) noexcept # Try to set *R* to the resultant of *A* and *B* with respect to the variable of index *var*. - int fmpz_mpoly_discriminant(fmpz_mpoly_t D, const fmpz_mpoly_t A, slong var, const fmpz_mpoly_ctx_t ctx) + int fmpz_mpoly_discriminant(fmpz_mpoly_t D, const fmpz_mpoly_t A, slong var, const fmpz_mpoly_ctx_t ctx) noexcept # Try to set *D* to the discriminant of *A* with respect to the variable of index *var*. - void fmpz_mpoly_primitive_part(fmpz_mpoly_t res, const fmpz_mpoly_t f, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_primitive_part(fmpz_mpoly_t res, const fmpz_mpoly_t f, const fmpz_mpoly_ctx_t ctx) noexcept # Sets *res* to the primitive part of *f*, obtained by dividing # out the content of all coefficients and normalizing the leading # coefficient to be positive. The zero polynomial is unchanged. - int fmpz_mpoly_sqrt_heap(fmpz_mpoly_t Q, const fmpz_mpoly_t A, const fmpz_mpoly_ctx_t ctx, int check) + int fmpz_mpoly_sqrt_heap(fmpz_mpoly_t Q, const fmpz_mpoly_t A, const fmpz_mpoly_ctx_t ctx, int check) noexcept # If *A* is a perfect square return `1` and set *Q* to the square root # with positive leading coefficient. Otherwise return `0` and set *Q* to the # zero polynomial. If `check = 0` the polynomial is assumed to be a perfect @@ -443,62 +443,62 @@ cdef extern from "flint_wrap.h": # non-squares with any reliability, and in the event of being passed a # non-square the result is meaningless. - int fmpz_mpoly_sqrt(fmpz_mpoly_t q, const fmpz_mpoly_t A, const fmpz_mpoly_ctx_t ctx) + int fmpz_mpoly_sqrt(fmpz_mpoly_t q, const fmpz_mpoly_t A, const fmpz_mpoly_ctx_t ctx) noexcept # If *A* is a perfect square return `1` and set *Q* to the square root # with positive leading coefficient. Otherwise return `0` and set *Q* to zero. - bint fmpz_mpoly_is_square(const fmpz_mpoly_t A, const fmpz_mpoly_ctx_t ctx) + bint fmpz_mpoly_is_square(const fmpz_mpoly_t A, const fmpz_mpoly_ctx_t ctx) noexcept # Return `1` if *A* is a perfect square, otherwise return `0`. - void fmpz_mpoly_univar_init(fmpz_mpoly_univar_t A, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_univar_init(fmpz_mpoly_univar_t A, const fmpz_mpoly_ctx_t ctx) noexcept # Initialize *A*. - void fmpz_mpoly_univar_clear(fmpz_mpoly_univar_t A, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_univar_clear(fmpz_mpoly_univar_t A, const fmpz_mpoly_ctx_t ctx) noexcept # Clear *A*. - void fmpz_mpoly_univar_swap(fmpz_mpoly_univar_t A, fmpz_mpoly_univar_t B, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_univar_swap(fmpz_mpoly_univar_t A, fmpz_mpoly_univar_t B, const fmpz_mpoly_ctx_t ctx) noexcept # Swap *A* and *B*. - void fmpz_mpoly_to_univar(fmpz_mpoly_univar_t A, const fmpz_mpoly_t B, slong var, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_to_univar(fmpz_mpoly_univar_t A, const fmpz_mpoly_t B, slong var, const fmpz_mpoly_ctx_t ctx) noexcept # Set *A* to a univariate form of *B* by pulling out the variable of index *var*. # The coefficients of *A* will still belong to the content *ctx* but will not depend on the variable of index *var*. - void fmpz_mpoly_from_univar(fmpz_mpoly_t A, const fmpz_mpoly_univar_t B, slong var, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_from_univar(fmpz_mpoly_t A, const fmpz_mpoly_univar_t B, slong var, const fmpz_mpoly_ctx_t ctx) noexcept # Set *A* to the normal form of *B* by putting in the variable of index *var*. # This function is undefined if the coefficients of *B* depend on the variable of index *var*. - int fmpz_mpoly_univar_degree_fits_si(const fmpz_mpoly_univar_t A, const fmpz_mpoly_ctx_t ctx) + int fmpz_mpoly_univar_degree_fits_si(const fmpz_mpoly_univar_t A, const fmpz_mpoly_ctx_t ctx) noexcept # Return `1` if the degree of *A* with respect to the main variable fits an ``slong``. Otherwise, return `0`. - slong fmpz_mpoly_univar_length(const fmpz_mpoly_univar_t A, const fmpz_mpoly_ctx_t ctx) + slong fmpz_mpoly_univar_length(const fmpz_mpoly_univar_t A, const fmpz_mpoly_ctx_t ctx) noexcept # Return the number of terms in *A* with respect to the main variable. - slong fmpz_mpoly_univar_get_term_exp_si(fmpz_mpoly_univar_t A, slong i, const fmpz_mpoly_ctx_t ctx) + slong fmpz_mpoly_univar_get_term_exp_si(fmpz_mpoly_univar_t A, slong i, const fmpz_mpoly_ctx_t ctx) noexcept # Return the exponent of the term of index *i* of *A*. - void fmpz_mpoly_univar_get_term_coeff(fmpz_mpoly_t c, const fmpz_mpoly_univar_t A, slong i, const fmpz_mpoly_ctx_t ctx) - void fmpz_mpoly_univar_swap_term_coeff(fmpz_mpoly_t c, fmpz_mpoly_univar_t A, slong i, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_univar_get_term_coeff(fmpz_mpoly_t c, const fmpz_mpoly_univar_t A, slong i, const fmpz_mpoly_ctx_t ctx) noexcept + void fmpz_mpoly_univar_swap_term_coeff(fmpz_mpoly_t c, fmpz_mpoly_univar_t A, slong i, const fmpz_mpoly_ctx_t ctx) noexcept # Set (resp. swap) *c* to (resp. with) the coefficient of the term of index *i* of *A*. - void fmpz_mpoly_inflate(fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz * shift, const fmpz * stride, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_inflate(fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz * shift, const fmpz * stride, const fmpz_mpoly_ctx_t ctx) noexcept # Apply the function ``e -> shift[v] + stride[v]*e`` to each exponent ``e`` corresponding to the variable ``v``. # It is assumed that each shift and stride is not negative. - void fmpz_mpoly_deflate(fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz * shift, const fmpz * stride, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_deflate(fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz * shift, const fmpz * stride, const fmpz_mpoly_ctx_t ctx) noexcept # Apply the function ``e -> (e - shift[v])/stride[v]`` to each exponent ``e`` corresponding to the variable ``v``. # If any ``stride[v]`` is zero, the corresponding numerator ``e - shift[v]`` is assumed to be zero, and the quotient is defined as zero. # This allows the function to undo the operation performed by :func:`fmpz_mpoly_inflate` when possible. - void fmpz_mpoly_deflation(fmpz * shift, fmpz * stride, const fmpz_mpoly_t A, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_deflation(fmpz * shift, fmpz * stride, const fmpz_mpoly_t A, const fmpz_mpoly_ctx_t ctx) noexcept # For each variable `v` let `S_v` be the set of exponents appearing on `v`. # Set ``shift[v]`` to `\operatorname{min}(S_v)` and set ``stride[v]`` to `\operatorname{gcd}(S-\operatorname{min}(S_v))`. # If *A* is zero, all shifts and strides are set to zero. - void fmpz_mpoly_pow_fps(fmpz_mpoly_t A, const fmpz_mpoly_t B, ulong k, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_pow_fps(fmpz_mpoly_t A, const fmpz_mpoly_t B, ulong k, const fmpz_mpoly_ctx_t ctx) noexcept # Set *A* to *B* raised to the *k*-th power, using the Monagan and Pearce FPS algorithm. # It is assumed that *B* is not zero and `k \geq 2`. - slong _fmpz_mpoly_divides_array(fmpz ** poly1, ulong ** exp1, slong * alloc, const fmpz * poly2, const ulong * exp2, slong len2, const fmpz * poly3, const ulong * exp3, slong len3, slong * mults, slong num, slong bits) + slong _fmpz_mpoly_divides_array(fmpz ** poly1, ulong ** exp1, slong * alloc, const fmpz * poly2, const ulong * exp2, slong len2, const fmpz * poly3, const ulong * exp3, slong len3, slong * mults, slong num, slong bits) noexcept # Use dense array exact division to set ``(poly1, exp1, alloc)`` to # ``(poly2, exp3, len2)`` divided by ``(poly3, exp3, len3)`` in # ``num`` variables, given a list of multipliers to tightly pack exponents @@ -509,7 +509,7 @@ cdef extern from "flint_wrap.h": # or zero if not. It is assumed that ``poly2`` is not zero. No aliasing is # allowed. - int fmpz_mpoly_divides_array(fmpz_mpoly_t poly1, const fmpz_mpoly_t poly2, const fmpz_mpoly_t poly3, const fmpz_mpoly_ctx_t ctx) + int fmpz_mpoly_divides_array(fmpz_mpoly_t poly1, const fmpz_mpoly_t poly2, const fmpz_mpoly_t poly3, const fmpz_mpoly_ctx_t ctx) noexcept # Set ``poly1`` to ``poly2`` divided by ``poly3``, using a big dense # array to accumulate coefficients, and return 1 if the quotient is exact. # Otherwise, return 0 if the quotient is not exact. If the array will be @@ -519,7 +519,7 @@ cdef extern from "flint_wrap.h": # ``fmpz_mpoly_div_monagan_pearce`` below may be much faster if the # quotient is known to be exact. - slong _fmpz_mpoly_divides_monagan_pearce(fmpz ** poly1, ulong ** exp1, slong * alloc, const fmpz * poly2, const ulong * exp2, slong len2, const fmpz * poly3, const ulong * exp3, slong len3, ulong bits, slong N, const mp_limb_t *cmpmask) + slong _fmpz_mpoly_divides_monagan_pearce(fmpz ** poly1, ulong ** exp1, slong * alloc, const fmpz * poly2, const ulong * exp2, slong len2, const fmpz * poly3, const ulong * exp3, slong len3, ulong bits, slong N, const mp_limb_t *cmpmask) noexcept # Set ``(poly1, exp1, alloc)`` to ``(poly2, exp3, len2)`` divided by # ``(poly3, exp3, len3)`` and return 1 if the quotient is exact. Otherwise # return 0. The function assumes exponent vectors that each fit in `N` words, @@ -528,9 +528,9 @@ cdef extern from "flint_wrap.h": # and packed exponents" by Michael Monagan and Roman Pearce. No aliasing is # allowed. - int fmpz_mpoly_divides_monagan_pearce(fmpz_mpoly_t poly1, const fmpz_mpoly_t poly2, const fmpz_mpoly_t poly3, const fmpz_mpoly_ctx_t ctx) + int fmpz_mpoly_divides_monagan_pearce(fmpz_mpoly_t poly1, const fmpz_mpoly_t poly2, const fmpz_mpoly_t poly3, const fmpz_mpoly_ctx_t ctx) noexcept - int fmpz_mpoly_divides_heap_threaded(fmpz_mpoly_t Q, const fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_mpoly_ctx_t ctx) + int fmpz_mpoly_divides_heap_threaded(fmpz_mpoly_t Q, const fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_mpoly_ctx_t ctx) noexcept # Set ``poly1`` to ``poly2`` divided by ``poly3`` and return 1 if # the quotient is exact. Otherwise return 0. The function uses the algorithm # of Michael Monagan and Roman Pearce. Note that the function @@ -538,7 +538,7 @@ cdef extern from "flint_wrap.h": # quotient is known to be exact. # The threaded version takes an upper limit on the number of threads to use, while the first version always uses one thread. - slong _fmpz_mpoly_div_monagan_pearce(fmpz ** polyq, ulong ** expq, slong * allocq, const fmpz * poly2, const ulong * exp2, slong len2, const fmpz * poly3, const ulong * exp3, slong len3, slong bits, slong N, const mp_limb_t *cmpmask) + slong _fmpz_mpoly_div_monagan_pearce(fmpz ** polyq, ulong ** expq, slong * allocq, const fmpz * poly2, const ulong * exp2, slong len2, const fmpz * poly3, const ulong * exp3, slong len3, slong bits, slong N, const mp_limb_t *cmpmask) noexcept # Set ``(polyq, expq, allocq)`` to the quotient of # ``(poly2, exp2, len2)`` by ``(poly3, exp3, len3)`` discarding # remainder (with notional remainder coefficients reduced modulo the leading @@ -550,7 +550,7 @@ cdef extern from "flint_wrap.h": # "Polynomial division using dynamic arrays, heaps and packed exponents" by # Michael Monagan and Roman Pearce. No aliasing is allowed. - void fmpz_mpoly_div_monagan_pearce(fmpz_mpoly_t polyq, const fmpz_mpoly_t poly2, const fmpz_mpoly_t poly3, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_div_monagan_pearce(fmpz_mpoly_t polyq, const fmpz_mpoly_t poly2, const fmpz_mpoly_t poly3, const fmpz_mpoly_ctx_t ctx) noexcept # Set ``polyq`` to the quotient of ``poly2`` by ``poly3``, # discarding the remainder (with notional remainder coefficients reduced # modulo the leading coefficient of ``poly3``). Implements "Polynomial @@ -558,7 +558,7 @@ cdef extern from "flint_wrap.h": # Monagan and Roman Pearce. This function is exceptionally efficient if the # division is known to be exact. - slong _fmpz_mpoly_divrem_monagan_pearce(slong * lenr, fmpz ** polyq, ulong ** expq, slong * allocq, fmpz ** polyr, ulong ** expr, slong * allocr, const fmpz * poly2, const ulong * exp2, slong len2, const fmpz * poly3, const ulong * exp3, slong len3, slong bits, slong N, const mp_limb_t *cmpmask) + slong _fmpz_mpoly_divrem_monagan_pearce(slong * lenr, fmpz ** polyq, ulong ** expq, slong * allocq, fmpz ** polyr, ulong ** expr, slong * allocr, const fmpz * poly2, const ulong * exp2, slong len2, const fmpz * poly3, const ulong * exp3, slong len3, slong bits, slong N, const mp_limb_t *cmpmask) noexcept # Set ``(polyq, expq, allocq)`` and ``(polyr, expr, allocr)`` to the # quotient and remainder of ``(poly2, exp2, len2)`` by # ``(poly3, exp3, len3)`` (with remainder coefficients reduced modulo the @@ -570,14 +570,14 @@ cdef extern from "flint_wrap.h": # "Polynomial division using dynamic arrays, heaps and packed exponents" by # Michael Monagan and Roman Pearce. No aliasing is allowed. - void fmpz_mpoly_divrem_monagan_pearce(fmpz_mpoly_t q, fmpz_mpoly_t r, const fmpz_mpoly_t poly2, const fmpz_mpoly_t poly3, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_divrem_monagan_pearce(fmpz_mpoly_t q, fmpz_mpoly_t r, const fmpz_mpoly_t poly2, const fmpz_mpoly_t poly3, const fmpz_mpoly_ctx_t ctx) noexcept # Set ``polyq`` and ``polyr`` to the quotient and remainder of # ``poly2`` divided by ``poly3`` (with remainder coefficients reduced # modulo the leading coefficient of ``poly3``). Implements "Polynomial # division using dynamic arrays, heaps and packed exponents" by Michael # Monagan and Roman Pearce. - slong _fmpz_mpoly_divrem_array(slong * lenr, fmpz ** polyq, ulong ** expq, slong * allocq, fmpz ** polyr, ulong ** expr, slong * allocr, const fmpz * poly2, const ulong * exp2, slong len2, const fmpz * poly3, const ulong * exp3, slong len3, slong * mults, slong num, slong bits) + slong _fmpz_mpoly_divrem_array(slong * lenr, fmpz ** polyq, ulong ** expq, slong * allocq, fmpz ** polyr, ulong ** expr, slong * allocr, const fmpz * poly2, const ulong * exp2, slong len2, const fmpz * poly3, const ulong * exp3, slong len3, slong * mults, slong num, slong bits) noexcept # Use dense array division to set ``(polyq, expq, allocq)`` and # ``(polyr, expr, allocr)`` to the quotient and remainder of # ``(poly2, exp2, len2)`` divided by ``(poly3, exp3, len3)`` in @@ -589,7 +589,7 @@ cdef extern from "flint_wrap.h": # quotient. It is assumed that the input polynomials are not zero. No # aliasing is allowed. - int fmpz_mpoly_divrem_array(fmpz_mpoly_t q, fmpz_mpoly_t r, const fmpz_mpoly_t poly2, const fmpz_mpoly_t poly3, const fmpz_mpoly_ctx_t ctx) + int fmpz_mpoly_divrem_array(fmpz_mpoly_t q, fmpz_mpoly_t r, const fmpz_mpoly_t poly2, const fmpz_mpoly_t poly3, const fmpz_mpoly_ctx_t ctx) noexcept # Set ``polyq`` and ``polyr`` to the quotient and remainder of # ``poly2`` divided by ``poly3`` (with remainder coefficients reduced # modulo the leading coefficient of ``poly3``). The function is @@ -598,14 +598,14 @@ cdef extern from "flint_wrap.h": # function silently returns 0 so that another function can be called, # otherwise it returns 1. - void fmpz_mpoly_quasidivrem_heap(fmpz_t scale, fmpz_mpoly_t q, fmpz_mpoly_t r, const fmpz_mpoly_t poly2, const fmpz_mpoly_t poly3, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_quasidivrem_heap(fmpz_t scale, fmpz_mpoly_t q, fmpz_mpoly_t r, const fmpz_mpoly_t poly2, const fmpz_mpoly_t poly3, const fmpz_mpoly_ctx_t ctx) noexcept # Set ``scale``, ``q`` and ``r`` so that # ``scale*poly2 = q*poly3 + r`` and no monomial in ``r`` is divisible # by the leading monomial of ``poly3``, where ``scale`` is positive # and as small as possible. This function throws an exception if # ``poly3`` is zero or if an exponent overflow occurs. - slong _fmpz_mpoly_divrem_ideal_monagan_pearce(fmpz_mpoly_struct ** polyq, fmpz ** polyr, ulong ** expr, slong * allocr, const fmpz * poly2, const ulong * exp2, slong len2, fmpz_mpoly_struct * const * poly3, ulong * const * exp3, slong len, slong N, slong bits, const fmpz_mpoly_ctx_t ctx, const mp_limb_t *cmpmask) + slong _fmpz_mpoly_divrem_ideal_monagan_pearce(fmpz_mpoly_struct ** polyq, fmpz ** polyr, ulong ** expr, slong * allocr, const fmpz * poly2, const ulong * exp2, slong len2, fmpz_mpoly_struct * const * poly3, ulong * const * exp3, slong len, slong N, slong bits, const fmpz_mpoly_ctx_t ctx, const mp_limb_t *cmpmask) noexcept # This function is as per ``_fmpz_mpoly_divrem_monagan_pearce`` except # that it takes an array of divisor polynomials ``poly3`` and an array of # repacked exponent arrays ``exp3``, which may alias the exponent arrays @@ -615,7 +615,7 @@ cdef extern from "flint_wrap.h": # `r = a - \sum_{i=0}^{\mbox{len - 1}} q_ib_i`, where the `q_i` are the # quotient polynomials and the `b_i` are the divisor polynomials. - void fmpz_mpoly_divrem_ideal_monagan_pearce(fmpz_mpoly_struct ** q, fmpz_mpoly_t r, const fmpz_mpoly_t poly2, fmpz_mpoly_struct * const * poly3, slong len, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_divrem_ideal_monagan_pearce(fmpz_mpoly_struct ** q, fmpz_mpoly_t r, const fmpz_mpoly_t poly2, fmpz_mpoly_struct * const * poly3, slong len, const fmpz_mpoly_ctx_t ctx) noexcept # This function is as per ``fmpz_mpoly_divrem_monagan_pearce`` except # that it takes an array of divisor polynomials ``poly3``, and it returns # an array of quotient polynomials ``q``. The number of divisor (and hence @@ -623,74 +623,74 @@ cdef extern from "flint_wrap.h": # polynomials `q_i = q[i]` such that ``poly2`` is # `r + \sum_{i=0}^{\mbox{len - 1}} q_ib_i`, where `b_i =` ``poly3[i]``. - void fmpz_mpoly_vec_init(fmpz_mpoly_vec_t vec, slong len, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_vec_init(fmpz_mpoly_vec_t vec, slong len, const fmpz_mpoly_ctx_t ctx) noexcept # Initializes *vec* to a vector of length *len*, setting all entries to the zero polynomial. - void fmpz_mpoly_vec_clear(fmpz_mpoly_vec_t vec, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_vec_clear(fmpz_mpoly_vec_t vec, const fmpz_mpoly_ctx_t ctx) noexcept # Clears *vec*, freeing its allocated memory. - void fmpz_mpoly_vec_print(const fmpz_mpoly_vec_t vec, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_vec_print(const fmpz_mpoly_vec_t vec, const fmpz_mpoly_ctx_t ctx) noexcept # Prints *vec* to standard output. - void fmpz_mpoly_vec_swap(fmpz_mpoly_vec_t x, fmpz_mpoly_vec_t y, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_vec_swap(fmpz_mpoly_vec_t x, fmpz_mpoly_vec_t y, const fmpz_mpoly_ctx_t ctx) noexcept # Swaps *x* and *y* efficiently. - void fmpz_mpoly_vec_fit_length(fmpz_mpoly_vec_t vec, slong len, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_vec_fit_length(fmpz_mpoly_vec_t vec, slong len, const fmpz_mpoly_ctx_t ctx) noexcept # Allocates room for *len* entries in *vec*. - void fmpz_mpoly_vec_set(fmpz_mpoly_vec_t dest, const fmpz_mpoly_vec_t src, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_vec_set(fmpz_mpoly_vec_t dest, const fmpz_mpoly_vec_t src, const fmpz_mpoly_ctx_t ctx) noexcept # Sets *dest* to a copy of *src*. - void fmpz_mpoly_vec_append(fmpz_mpoly_vec_t vec, const fmpz_mpoly_t f, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_vec_append(fmpz_mpoly_vec_t vec, const fmpz_mpoly_t f, const fmpz_mpoly_ctx_t ctx) noexcept # Appends *f* to the end of *vec*. - slong fmpz_mpoly_vec_insert_unique(fmpz_mpoly_vec_t vec, const fmpz_mpoly_t f, const fmpz_mpoly_ctx_t ctx) + slong fmpz_mpoly_vec_insert_unique(fmpz_mpoly_vec_t vec, const fmpz_mpoly_t f, const fmpz_mpoly_ctx_t ctx) noexcept # Inserts *f* without duplication into *vec* and returns its index. # If this polynomial already exists, *vec* is unchanged. If this # polynomial does not exist in *vec*, it is appended. - void fmpz_mpoly_vec_set_length(fmpz_mpoly_vec_t vec, slong len, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_vec_set_length(fmpz_mpoly_vec_t vec, slong len, const fmpz_mpoly_ctx_t ctx) noexcept # Sets the length of *vec* to *len*, truncating or zero-extending # as needed. - void fmpz_mpoly_vec_randtest_not_zero(fmpz_mpoly_vec_t vec, flint_rand_t state, slong len, slong poly_len, slong bits, ulong exp_bound, fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_vec_randtest_not_zero(fmpz_mpoly_vec_t vec, flint_rand_t state, slong len, slong poly_len, slong bits, ulong exp_bound, fmpz_mpoly_ctx_t ctx) noexcept # Sets *vec* to a random vector with exactly *len* entries, all nonzero, # with random parameters defined by *poly_len*, *bits* and *exp_bound*. - void fmpz_mpoly_vec_set_primitive_unique(fmpz_mpoly_vec_t res, const fmpz_mpoly_vec_t src, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_vec_set_primitive_unique(fmpz_mpoly_vec_t res, const fmpz_mpoly_vec_t src, const fmpz_mpoly_ctx_t ctx) noexcept # Sets *res* to a vector containing all polynomials in *src* reduced # to their primitive parts, without duplication. The zero polynomial # is skipped if present. The output order is arbitrary. - void fmpz_mpoly_spoly(fmpz_mpoly_t res, const fmpz_mpoly_t f, const fmpz_mpoly_t g, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_spoly(fmpz_mpoly_t res, const fmpz_mpoly_t f, const fmpz_mpoly_t g, const fmpz_mpoly_ctx_t ctx) noexcept # Sets *res* to the *S*-polynomial of *f* and *g*, scaled to # an integer polynomial by computing the LCM of the leading coefficients. - void fmpz_mpoly_reduction_primitive_part(fmpz_mpoly_t res, const fmpz_mpoly_t f, const fmpz_mpoly_vec_t vec, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_reduction_primitive_part(fmpz_mpoly_t res, const fmpz_mpoly_t f, const fmpz_mpoly_vec_t vec, const fmpz_mpoly_ctx_t ctx) noexcept # Sets *res* to the primitive part of the reduction (remainder of multivariate # quasidivision with remainder) with respect to the polynomials *vec*. - bint fmpz_mpoly_vec_is_groebner(const fmpz_mpoly_vec_t G, const fmpz_mpoly_vec_t F, const fmpz_mpoly_ctx_t ctx) + bint fmpz_mpoly_vec_is_groebner(const fmpz_mpoly_vec_t G, const fmpz_mpoly_vec_t F, const fmpz_mpoly_ctx_t ctx) noexcept # If *F* is *NULL*, checks if *G* is a Gröbner basis. If *F* is not *NULL*, # checks if *G* is a Gröbner basis for *F*. - bint fmpz_mpoly_vec_is_autoreduced(const fmpz_mpoly_vec_t F, const fmpz_mpoly_ctx_t ctx) + bint fmpz_mpoly_vec_is_autoreduced(const fmpz_mpoly_vec_t F, const fmpz_mpoly_ctx_t ctx) noexcept # Checks whether the vector *F* is autoreduced (or inter-reduced). - void fmpz_mpoly_vec_autoreduction(fmpz_mpoly_vec_t H, const fmpz_mpoly_vec_t F, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_vec_autoreduction(fmpz_mpoly_vec_t H, const fmpz_mpoly_vec_t F, const fmpz_mpoly_ctx_t ctx) noexcept # Sets *H* to the autoreduction (inter-reduction) of *F*. - void fmpz_mpoly_vec_autoreduction_groebner(fmpz_mpoly_vec_t H, const fmpz_mpoly_vec_t G, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_vec_autoreduction_groebner(fmpz_mpoly_vec_t H, const fmpz_mpoly_vec_t G, const fmpz_mpoly_ctx_t ctx) noexcept # Sets *H* to the autoreduction (inter-reduction) of *G*. # Assumes that *G* is a Gröbner basis. # This produces a reduced Gröbner basis, which is unique # (up to the sort order of the entries in the vector). - void fmpz_mpoly_buchberger_naive(fmpz_mpoly_vec_t G, const fmpz_mpoly_vec_t F, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_buchberger_naive(fmpz_mpoly_vec_t G, const fmpz_mpoly_vec_t F, const fmpz_mpoly_ctx_t ctx) noexcept # Sets *G* to a Gröbner basis for *F*, computed using # a naive implementation of Buchberger's algorithm. - int fmpz_mpoly_buchberger_naive_with_limits(fmpz_mpoly_vec_t G, const fmpz_mpoly_vec_t F, slong ideal_len_limit, slong poly_len_limit, slong poly_bits_limit, const fmpz_mpoly_ctx_t ctx) + int fmpz_mpoly_buchberger_naive_with_limits(fmpz_mpoly_vec_t G, const fmpz_mpoly_vec_t F, slong ideal_len_limit, slong poly_len_limit, slong poly_bits_limit, const fmpz_mpoly_ctx_t ctx) noexcept # As :func:`fmpz_mpoly_buchberger_naive`, but halts if during the # execution of Buchberger's algorithm the length of the # ideal basis set exceeds *ideal_len_limit*, the length of any @@ -699,9 +699,9 @@ cdef extern from "flint_wrap.h": # Returns 1 for success and 0 for failure. On failure, *G* is # a valid basis for *F* but it might not be a Gröbner basis. - void fmpz_mpoly_symmetric_gens(fmpz_mpoly_t res, ulong k, slong * vars, slong n, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_symmetric_gens(fmpz_mpoly_t res, ulong k, slong * vars, slong n, const fmpz_mpoly_ctx_t ctx) noexcept - void fmpz_mpoly_symmetric(fmpz_mpoly_t res, ulong k, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_symmetric(fmpz_mpoly_t res, ulong k, const fmpz_mpoly_ctx_t ctx) noexcept # Sets *res* to the elementary symmetric polynomial # `e_k(X_1,\ldots,X_n)`. # The *gens* version takes `X_1,\ldots,X_n` to be the subset of diff --git a/src/sage/libs/flint/fmpz_mpoly_factor.pxd b/src/sage/libs/flint/fmpz_mpoly_factor.pxd index 3544dff614a..8bdc2862453 100644 --- a/src/sage/libs/flint/fmpz_mpoly_factor.pxd +++ b/src/sage/libs/flint/fmpz_mpoly_factor.pxd @@ -12,37 +12,37 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void fmpz_mpoly_factor_init(fmpz_mpoly_factor_t f, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_factor_init(fmpz_mpoly_factor_t f, const fmpz_mpoly_ctx_t ctx) noexcept # Initialise *f*. - void fmpz_mpoly_factor_clear(fmpz_mpoly_factor_t f, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_factor_clear(fmpz_mpoly_factor_t f, const fmpz_mpoly_ctx_t ctx) noexcept # Clear *f*. - void fmpz_mpoly_factor_swap(fmpz_mpoly_factor_t f, fmpz_mpoly_factor_t g, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_factor_swap(fmpz_mpoly_factor_t f, fmpz_mpoly_factor_t g, const fmpz_mpoly_ctx_t ctx) noexcept # Efficiently swap *f* and *g*. - slong fmpz_mpoly_factor_length(const fmpz_mpoly_factor_t f, const fmpz_mpoly_ctx_t ctx) + slong fmpz_mpoly_factor_length(const fmpz_mpoly_factor_t f, const fmpz_mpoly_ctx_t ctx) noexcept # Return the length of the product in *f*. - void fmpz_mpoly_factor_get_constant_fmpz(fmpz_t c, const fmpz_mpoly_factor_t f, const fmpz_mpoly_ctx_t ctx) - void fmpz_mpoly_factor_get_constant_fmpq(fmpq_t c, const fmpz_mpoly_factor_t f, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_factor_get_constant_fmpz(fmpz_t c, const fmpz_mpoly_factor_t f, const fmpz_mpoly_ctx_t ctx) noexcept + void fmpz_mpoly_factor_get_constant_fmpq(fmpq_t c, const fmpz_mpoly_factor_t f, const fmpz_mpoly_ctx_t ctx) noexcept # Set `c` to the constant of *f*. - void fmpz_mpoly_factor_get_base(fmpz_mpoly_t B, const fmpz_mpoly_factor_t f, slong i, const fmpz_mpoly_ctx_t ctx) - void fmpz_mpoly_factor_swap_base(fmpz_mpoly_t B, fmpz_mpoly_factor_t f, slong i, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_factor_get_base(fmpz_mpoly_t B, const fmpz_mpoly_factor_t f, slong i, const fmpz_mpoly_ctx_t ctx) noexcept + void fmpz_mpoly_factor_swap_base(fmpz_mpoly_t B, fmpz_mpoly_factor_t f, slong i, const fmpz_mpoly_ctx_t ctx) noexcept # Set (resp. swap) *B* to (resp. with) the base of the term of index `i` in *A*. - slong fmpz_mpoly_factor_get_exp_si(fmpz_mpoly_factor_t f, slong i, const fmpz_mpoly_ctx_t ctx) + slong fmpz_mpoly_factor_get_exp_si(fmpz_mpoly_factor_t f, slong i, const fmpz_mpoly_ctx_t ctx) noexcept # Return the exponent of the term of index `i` in *A*. It is assumed to fit an ``slong``. - void fmpz_mpoly_factor_sort(fmpz_mpoly_factor_t f, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_factor_sort(fmpz_mpoly_factor_t f, const fmpz_mpoly_ctx_t ctx) noexcept # Sort the product of *f* first by exponent and then by base. - int fmpz_mpoly_factor_squarefree(fmpz_mpoly_factor_t f, const fmpz_mpoly_t A, const fmpz_mpoly_ctx_t ctx) + int fmpz_mpoly_factor_squarefree(fmpz_mpoly_factor_t f, const fmpz_mpoly_t A, const fmpz_mpoly_ctx_t ctx) noexcept # Set *f* to a factorization of *A* where the bases are primitive and # pairwise relatively prime. If the product of all irreducible factors with # a given exponent is desired, it is recommended to call :func:`fmpz_mpoly_factor_sort` # and then multiply the bases with the desired exponent. - int fmpz_mpoly_factor(fmpz_mpoly_factor_t f, const fmpz_mpoly_t A, const fmpz_mpoly_ctx_t ctx) + int fmpz_mpoly_factor(fmpz_mpoly_factor_t f, const fmpz_mpoly_t A, const fmpz_mpoly_ctx_t ctx) noexcept # Set *f* to a factorization of *A* where the bases are irreducible. diff --git a/src/sage/libs/flint/fmpz_mpoly_q.pxd b/src/sage/libs/flint/fmpz_mpoly_q.pxd index 02c696865aa..3f2ff4a5773 100644 --- a/src/sage/libs/flint/fmpz_mpoly_q.pxd +++ b/src/sage/libs/flint/fmpz_mpoly_q.pxd @@ -12,26 +12,26 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void fmpz_mpoly_q_init(fmpz_mpoly_q_t res, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_q_init(fmpz_mpoly_q_t res, const fmpz_mpoly_ctx_t ctx) noexcept # Initializes *res* for use, and sets its value to zero. - void fmpz_mpoly_q_clear(fmpz_mpoly_q_t res, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_q_clear(fmpz_mpoly_q_t res, const fmpz_mpoly_ctx_t ctx) noexcept # Clears *res*, freeing or recycling its allocated memory. - void fmpz_mpoly_q_swap(fmpz_mpoly_q_t x, fmpz_mpoly_q_t y, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_q_swap(fmpz_mpoly_q_t x, fmpz_mpoly_q_t y, const fmpz_mpoly_ctx_t ctx) noexcept # Swaps the values of *x* and *y* efficiently. - void fmpz_mpoly_q_set(fmpz_mpoly_q_t res, const fmpz_mpoly_q_t x, const fmpz_mpoly_ctx_t ctx) - void fmpz_mpoly_q_set_fmpq(fmpz_mpoly_q_t res, const fmpq_t x, const fmpz_mpoly_ctx_t ctx) - void fmpz_mpoly_q_set_fmpz(fmpz_mpoly_q_t res, const fmpz_t x, const fmpz_mpoly_ctx_t ctx) - void fmpz_mpoly_q_set_si(fmpz_mpoly_q_t res, slong x, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_q_set(fmpz_mpoly_q_t res, const fmpz_mpoly_q_t x, const fmpz_mpoly_ctx_t ctx) noexcept + void fmpz_mpoly_q_set_fmpq(fmpz_mpoly_q_t res, const fmpq_t x, const fmpz_mpoly_ctx_t ctx) noexcept + void fmpz_mpoly_q_set_fmpz(fmpz_mpoly_q_t res, const fmpz_t x, const fmpz_mpoly_ctx_t ctx) noexcept + void fmpz_mpoly_q_set_si(fmpz_mpoly_q_t res, slong x, const fmpz_mpoly_ctx_t ctx) noexcept # Sets *res* to the value *x*. - void fmpz_mpoly_q_canonicalise(fmpz_mpoly_q_t x, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_q_canonicalise(fmpz_mpoly_q_t x, const fmpz_mpoly_ctx_t ctx) noexcept # Puts the numerator and denominator of *x* in canonical form by removing # common content and making the leading term of the denominator positive. - bint fmpz_mpoly_q_is_canonical(const fmpz_mpoly_q_t x, const fmpz_mpoly_ctx_t ctx) + bint fmpz_mpoly_q_is_canonical(const fmpz_mpoly_q_t x, const fmpz_mpoly_ctx_t ctx) noexcept # Returns whether *x* is in canonical form. # In addition to verifying that the numerator and denominator # have no common content and that the leading term of the denominator @@ -40,73 +40,73 @@ cdef extern from "flint_wrap.h": # (these properties should normally hold; verifying them # provides an extra consistency check for test code). - bint fmpz_mpoly_q_is_zero(const fmpz_mpoly_q_t x, const fmpz_mpoly_ctx_t ctx) + bint fmpz_mpoly_q_is_zero(const fmpz_mpoly_q_t x, const fmpz_mpoly_ctx_t ctx) noexcept # Returns whether *x* is the constant 0. - bint fmpz_mpoly_q_is_one(const fmpz_mpoly_q_t x, const fmpz_mpoly_ctx_t ctx) + bint fmpz_mpoly_q_is_one(const fmpz_mpoly_q_t x, const fmpz_mpoly_ctx_t ctx) noexcept # Returns whether *x* is the constant 1. - void fmpz_mpoly_q_used_vars(int * used, const fmpz_mpoly_q_t f, const fmpz_mpoly_ctx_t ctx) - void fmpz_mpoly_q_used_vars_num(int * used, const fmpz_mpoly_q_t f, const fmpz_mpoly_ctx_t ctx) - void fmpz_mpoly_q_used_vars_den(int * used, const fmpz_mpoly_q_t f, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_q_used_vars(int * used, const fmpz_mpoly_q_t f, const fmpz_mpoly_ctx_t ctx) noexcept + void fmpz_mpoly_q_used_vars_num(int * used, const fmpz_mpoly_q_t f, const fmpz_mpoly_ctx_t ctx) noexcept + void fmpz_mpoly_q_used_vars_den(int * used, const fmpz_mpoly_q_t f, const fmpz_mpoly_ctx_t ctx) noexcept # For each variable, sets the corresponding entry in *used* to the # boolean flag indicating whether that variable appears in the # rational function (respectively its numerator or denominator). - void fmpz_mpoly_q_zero(fmpz_mpoly_q_t res, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_q_zero(fmpz_mpoly_q_t res, const fmpz_mpoly_ctx_t ctx) noexcept # Sets *res* to the constant 0. - void fmpz_mpoly_q_one(fmpz_mpoly_q_t res, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_q_one(fmpz_mpoly_q_t res, const fmpz_mpoly_ctx_t ctx) noexcept # Sets *res* to the constant 1. - void fmpz_mpoly_q_gen(fmpz_mpoly_q_t res, slong i, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_q_gen(fmpz_mpoly_q_t res, slong i, const fmpz_mpoly_ctx_t ctx) noexcept # Sets *res* to the generator `x_{i+1}`. # Requires `0 \le i < n` where *n* is the number of variables of *ctx*. - void fmpz_mpoly_q_print_pretty(const fmpz_mpoly_q_t f, const char ** x, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_q_print_pretty(const fmpz_mpoly_q_t f, const char ** x, const fmpz_mpoly_ctx_t ctx) noexcept # Prints *res* to standard output. If *x* is not *NULL*, the strings in # *x* are used as the symbols for the variables. - void fmpz_mpoly_q_randtest(fmpz_mpoly_q_t res, flint_rand_t state, slong length, mp_limb_t coeff_bits, slong exp_bound, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_q_randtest(fmpz_mpoly_q_t res, flint_rand_t state, slong length, mp_limb_t coeff_bits, slong exp_bound, const fmpz_mpoly_ctx_t ctx) noexcept # Sets *res* to a random rational function where both numerator and denominator # have up to *length* terms, coefficients up to size *coeff_bits*, and # exponents strictly smaller than *exp_bound*. - bint fmpz_mpoly_q_equal(const fmpz_mpoly_q_t x, const fmpz_mpoly_q_t y, const fmpz_mpoly_ctx_t ctx) + bint fmpz_mpoly_q_equal(const fmpz_mpoly_q_t x, const fmpz_mpoly_q_t y, const fmpz_mpoly_ctx_t ctx) noexcept # Returns whether *x* and *y* are equal. - void fmpz_mpoly_q_neg(fmpz_mpoly_q_t res, const fmpz_mpoly_q_t x, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_q_neg(fmpz_mpoly_q_t res, const fmpz_mpoly_q_t x, const fmpz_mpoly_ctx_t ctx) noexcept # Sets *res* to the negation of *x*. - void fmpz_mpoly_q_add(fmpz_mpoly_q_t res, const fmpz_mpoly_q_t x, const fmpz_mpoly_q_t y, const fmpz_mpoly_ctx_t ctx) - void fmpz_mpoly_q_add_fmpq(fmpz_mpoly_q_t res, const fmpz_mpoly_q_t x, const fmpq_t y, const fmpz_mpoly_ctx_t ctx) - void fmpz_mpoly_q_add_fmpz(fmpz_mpoly_q_t res, const fmpz_mpoly_q_t x, const fmpz_t y, const fmpz_mpoly_ctx_t ctx) - void fmpz_mpoly_q_add_si(fmpz_mpoly_q_t res, const fmpz_mpoly_q_t x, slong y, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_q_add(fmpz_mpoly_q_t res, const fmpz_mpoly_q_t x, const fmpz_mpoly_q_t y, const fmpz_mpoly_ctx_t ctx) noexcept + void fmpz_mpoly_q_add_fmpq(fmpz_mpoly_q_t res, const fmpz_mpoly_q_t x, const fmpq_t y, const fmpz_mpoly_ctx_t ctx) noexcept + void fmpz_mpoly_q_add_fmpz(fmpz_mpoly_q_t res, const fmpz_mpoly_q_t x, const fmpz_t y, const fmpz_mpoly_ctx_t ctx) noexcept + void fmpz_mpoly_q_add_si(fmpz_mpoly_q_t res, const fmpz_mpoly_q_t x, slong y, const fmpz_mpoly_ctx_t ctx) noexcept # Sets *res* to the sum of *x* and *y*. - void fmpz_mpoly_q_sub(fmpz_mpoly_q_t res, const fmpz_mpoly_q_t x, const fmpz_mpoly_q_t y, const fmpz_mpoly_ctx_t ctx) - void fmpz_mpoly_q_sub_fmpq(fmpz_mpoly_q_t res, const fmpz_mpoly_q_t x, const fmpq_t y, const fmpz_mpoly_ctx_t ctx) - void fmpz_mpoly_q_sub_fmpz(fmpz_mpoly_q_t res, const fmpz_mpoly_q_t x, const fmpz_t y, const fmpz_mpoly_ctx_t ctx) - void fmpz_mpoly_q_sub_si(fmpz_mpoly_q_t res, const fmpz_mpoly_q_t x, slong y, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_q_sub(fmpz_mpoly_q_t res, const fmpz_mpoly_q_t x, const fmpz_mpoly_q_t y, const fmpz_mpoly_ctx_t ctx) noexcept + void fmpz_mpoly_q_sub_fmpq(fmpz_mpoly_q_t res, const fmpz_mpoly_q_t x, const fmpq_t y, const fmpz_mpoly_ctx_t ctx) noexcept + void fmpz_mpoly_q_sub_fmpz(fmpz_mpoly_q_t res, const fmpz_mpoly_q_t x, const fmpz_t y, const fmpz_mpoly_ctx_t ctx) noexcept + void fmpz_mpoly_q_sub_si(fmpz_mpoly_q_t res, const fmpz_mpoly_q_t x, slong y, const fmpz_mpoly_ctx_t ctx) noexcept # Sets *res* to the difference of *x* and *y*. - void fmpz_mpoly_q_mul(fmpz_mpoly_q_t res, const fmpz_mpoly_q_t x, const fmpz_mpoly_q_t y, const fmpz_mpoly_ctx_t ctx) - void fmpz_mpoly_q_mul_fmpq(fmpz_mpoly_q_t res, const fmpz_mpoly_q_t x, const fmpq_t y, const fmpz_mpoly_ctx_t ctx) - void fmpz_mpoly_q_mul_fmpz(fmpz_mpoly_q_t res, const fmpz_mpoly_q_t x, const fmpz_t y, const fmpz_mpoly_ctx_t ctx) - void fmpz_mpoly_q_mul_si(fmpz_mpoly_q_t res, const fmpz_mpoly_q_t x, slong y, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_q_mul(fmpz_mpoly_q_t res, const fmpz_mpoly_q_t x, const fmpz_mpoly_q_t y, const fmpz_mpoly_ctx_t ctx) noexcept + void fmpz_mpoly_q_mul_fmpq(fmpz_mpoly_q_t res, const fmpz_mpoly_q_t x, const fmpq_t y, const fmpz_mpoly_ctx_t ctx) noexcept + void fmpz_mpoly_q_mul_fmpz(fmpz_mpoly_q_t res, const fmpz_mpoly_q_t x, const fmpz_t y, const fmpz_mpoly_ctx_t ctx) noexcept + void fmpz_mpoly_q_mul_si(fmpz_mpoly_q_t res, const fmpz_mpoly_q_t x, slong y, const fmpz_mpoly_ctx_t ctx) noexcept # Sets *res* to the product of *x* and *y*. - void fmpz_mpoly_q_div(fmpz_mpoly_q_t res, const fmpz_mpoly_q_t x, const fmpz_mpoly_q_t y, const fmpz_mpoly_ctx_t ctx) - void fmpz_mpoly_q_div_fmpq(fmpz_mpoly_q_t res, const fmpz_mpoly_q_t x, const fmpq_t y, const fmpz_mpoly_ctx_t ctx) - void fmpz_mpoly_q_div_fmpz(fmpz_mpoly_q_t res, const fmpz_mpoly_q_t x, const fmpz_t y, const fmpz_mpoly_ctx_t ctx) - void fmpz_mpoly_q_div_si(fmpz_mpoly_q_t res, const fmpz_mpoly_q_t x, slong y, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_q_div(fmpz_mpoly_q_t res, const fmpz_mpoly_q_t x, const fmpz_mpoly_q_t y, const fmpz_mpoly_ctx_t ctx) noexcept + void fmpz_mpoly_q_div_fmpq(fmpz_mpoly_q_t res, const fmpz_mpoly_q_t x, const fmpq_t y, const fmpz_mpoly_ctx_t ctx) noexcept + void fmpz_mpoly_q_div_fmpz(fmpz_mpoly_q_t res, const fmpz_mpoly_q_t x, const fmpz_t y, const fmpz_mpoly_ctx_t ctx) noexcept + void fmpz_mpoly_q_div_si(fmpz_mpoly_q_t res, const fmpz_mpoly_q_t x, slong y, const fmpz_mpoly_ctx_t ctx) noexcept # Sets *res* to the quotient of *x* and *y*. # Division by zero calls *flint_abort*. - void fmpz_mpoly_q_inv(fmpz_mpoly_q_t res, const fmpz_mpoly_q_t x, const fmpz_mpoly_ctx_t ctx) + void fmpz_mpoly_q_inv(fmpz_mpoly_q_t res, const fmpz_mpoly_q_t x, const fmpz_mpoly_ctx_t ctx) noexcept # Sets *res* to the inverse of *x*. Division by zero # calls *flint_abort*. - void _fmpz_mpoly_q_content(fmpz_t num, fmpz_t den, const fmpz_mpoly_t xnum, const fmpz_mpoly_t xden, const fmpz_mpoly_ctx_t ctx) - void fmpz_mpoly_q_content(fmpq_t res, const fmpz_mpoly_q_t x, const fmpz_mpoly_ctx_t ctx) + void _fmpz_mpoly_q_content(fmpz_t num, fmpz_t den, const fmpz_mpoly_t xnum, const fmpz_mpoly_t xden, const fmpz_mpoly_ctx_t ctx) noexcept + void fmpz_mpoly_q_content(fmpq_t res, const fmpz_mpoly_q_t x, const fmpz_mpoly_ctx_t ctx) noexcept # Sets *res* to the content of the coefficients of *x*. diff --git a/src/sage/libs/flint/fmpz_poly.pxd b/src/sage/libs/flint/fmpz_poly.pxd index 941e24c886f..2f865d837e0 100644 --- a/src/sage/libs/flint/fmpz_poly.pxd +++ b/src/sage/libs/flint/fmpz_poly.pxd @@ -12,24 +12,24 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void fmpz_poly_init(fmpz_poly_t poly) + void fmpz_poly_init(fmpz_poly_t poly) noexcept # Initialises ``poly`` for use, setting its length to zero. # A corresponding call to :func:`fmpz_poly_clear` must be made after # finishing with the ``fmpz_poly_t`` to free the memory used by # the polynomial. - void fmpz_poly_init2(fmpz_poly_t poly, slong alloc) + void fmpz_poly_init2(fmpz_poly_t poly, slong alloc) noexcept # Initialises ``poly`` with space for at least ``alloc`` coefficients # and sets the length to zero. The allocated coefficients are all set to # zero. - void fmpz_poly_realloc(fmpz_poly_t poly, slong alloc) + void fmpz_poly_realloc(fmpz_poly_t poly, slong alloc) noexcept # Reallocates the given polynomial to have space for ``alloc`` # coefficients. If ``alloc`` is zero the polynomial is cleared # and then reinitialised. If the current length is greater than # ``alloc`` the polynomial is first truncated to length ``alloc``. - void fmpz_poly_fit_length(fmpz_poly_t poly, slong len) + void fmpz_poly_fit_length(fmpz_poly_t poly, slong len) noexcept # If ``len`` is greater than the number of coefficients currently # allocated, then the polynomial is reallocated to have space for at # least ``len`` coefficients. No data is lost when calling this @@ -39,51 +39,51 @@ cdef extern from "flint_wrap.h": # of allocated coefficients when length is larger than the number of # coefficients currently allocated. - void fmpz_poly_clear(fmpz_poly_t poly) + void fmpz_poly_clear(fmpz_poly_t poly) noexcept # Clears the given polynomial, releasing any memory used. It must # be reinitialised in order to be used again. - void _fmpz_poly_normalise(fmpz_poly_t poly) + void _fmpz_poly_normalise(fmpz_poly_t poly) noexcept # Sets the length of ``poly`` so that the top coefficient is non-zero. # If all coefficients are zero, the length is set to zero. This function # is mainly used internally, as all functions guarantee normalisation. - void _fmpz_poly_set_length(fmpz_poly_t poly, slong newlen) + void _fmpz_poly_set_length(fmpz_poly_t poly, slong newlen) noexcept # Demotes the coefficients of ``poly`` beyond ``newlen`` and sets # the length of ``poly`` to ``newlen``. - void fmpz_poly_attach_truncate(fmpz_poly_t trunc, const fmpz_poly_t poly, slong n) + void fmpz_poly_attach_truncate(fmpz_poly_t trunc, const fmpz_poly_t poly, slong n) noexcept # This function sets the uninitialised polynomial ``trunc`` to the low # `n` coefficients of ``poly``, or to ``poly`` if the latter doesn't # have `n` coefficients. The polynomial ``trunc`` not be cleared or used # as the output of any Flint functions. - void fmpz_poly_attach_shift(fmpz_poly_t trunc, const fmpz_poly_t poly, slong n) + void fmpz_poly_attach_shift(fmpz_poly_t trunc, const fmpz_poly_t poly, slong n) noexcept # This function sets the uninitialised polynomial ``trunc`` to the # high coefficients of ``poly``, i.e. the coefficients not among the low # `n` coefficients of ``poly``. If the latter doesn't have `n` # coefficients ``trunc`` is set to the zero polynomial. The polynomial # ``trunc`` not be cleared or used as the output of any Flint functions. - slong fmpz_poly_length(const fmpz_poly_t poly) + slong fmpz_poly_length(const fmpz_poly_t poly) noexcept # Returns the length of ``poly``. The zero polynomial has length zero. - slong fmpz_poly_degree(const fmpz_poly_t poly) + slong fmpz_poly_degree(const fmpz_poly_t poly) noexcept # Returns the degree of ``poly``, which is one less than its length. - void fmpz_poly_set(fmpz_poly_t poly1, const fmpz_poly_t poly2) + void fmpz_poly_set(fmpz_poly_t poly1, const fmpz_poly_t poly2) noexcept # Sets ``poly1`` to equal ``poly2``. - void fmpz_poly_set_si(fmpz_poly_t poly, slong c) + void fmpz_poly_set_si(fmpz_poly_t poly, slong c) noexcept # Sets ``poly`` to the signed integer ``c``. - void fmpz_poly_set_ui(fmpz_poly_t poly, ulong c) + void fmpz_poly_set_ui(fmpz_poly_t poly, ulong c) noexcept # Sets ``poly`` to the unsigned integer ``c``. - void fmpz_poly_set_fmpz(fmpz_poly_t poly, const fmpz_t c) + void fmpz_poly_set_fmpz(fmpz_poly_t poly, const fmpz_t c) noexcept # Sets ``poly`` to the integer ``c``. - int _fmpz_poly_set_str(fmpz * poly, const char * str) + int _fmpz_poly_set_str(fmpz * poly, const char * str) noexcept # Sets ``poly`` to the polynomial encoded in the null-terminated # string ``str``. Assumes that ``poly`` is allocated as a # sufficiently large array suitable for the number of coefficients @@ -93,7 +93,7 @@ cdef extern from "flint_wrap.h": # If ``str`` is not null-terminated, calling this method might result # in a segmentation fault. - int fmpz_poly_set_str(fmpz_poly_t poly, const char * str) + int fmpz_poly_set_str(fmpz_poly_t poly, const char * str) noexcept # Imports a polynomial from a null-terminated string. If the string # ``str`` represents a valid polynomial returns `0`, otherwise # returns `1`. @@ -102,78 +102,78 @@ cdef extern from "flint_wrap.h": # ``str`` is not null-terminated, calling this method might result in # a segmentation fault. - char * _fmpz_poly_get_str(const fmpz * poly, slong len) + char * _fmpz_poly_get_str(const fmpz * poly, slong len) noexcept # Returns the plain FLINT string representation of the polynomial # ``(poly, len)``. - char * fmpz_poly_get_str(const fmpz_poly_t poly) + char * fmpz_poly_get_str(const fmpz_poly_t poly) noexcept # Returns the plain FLINT string representation of the polynomial # ``poly``. - char * _fmpz_poly_get_str_pretty(const fmpz * poly, slong len, const char * x) + char * _fmpz_poly_get_str_pretty(const fmpz * poly, slong len, const char * x) noexcept # Returns a pretty representation of the polynomial # ``(poly, len)`` using the null-terminated string ``x`` as the # variable name. - char * fmpz_poly_get_str_pretty(const fmpz_poly_t poly, const char * x) + char * fmpz_poly_get_str_pretty(const fmpz_poly_t poly, const char * x) noexcept # Returns a pretty representation of the polynomial ``poly`` using the # null-terminated string ``x`` as the variable name. - void fmpz_poly_zero(fmpz_poly_t poly) + void fmpz_poly_zero(fmpz_poly_t poly) noexcept # Sets ``poly`` to the zero polynomial. - void fmpz_poly_one(fmpz_poly_t poly) + void fmpz_poly_one(fmpz_poly_t poly) noexcept # Sets ``poly`` to the constant polynomial one. - void fmpz_poly_zero_coeffs(fmpz_poly_t poly, slong i, slong j) + void fmpz_poly_zero_coeffs(fmpz_poly_t poly, slong i, slong j) noexcept # Sets the coefficients of `x^i, \dotsc, x^{j-1}` to zero. - void fmpz_poly_swap(fmpz_poly_t poly1, fmpz_poly_t poly2) + void fmpz_poly_swap(fmpz_poly_t poly1, fmpz_poly_t poly2) noexcept # Swaps ``poly1`` and ``poly2``. This is done efficiently without # copying data by swapping pointers, etc. - void _fmpz_poly_reverse(fmpz * res, const fmpz * poly, slong len, slong n) + void _fmpz_poly_reverse(fmpz * res, const fmpz * poly, slong len, slong n) noexcept # Sets ``(res, n)`` to the reverse of ``(poly, n)``, where # ``poly`` is in fact an array of length ``len``. Assumes that # ``0 < len <= n``. Supports aliasing of ``res`` and ``poly``, # but the behaviour is undefined in case of partial overlap. - void fmpz_poly_reverse(fmpz_poly_t res, const fmpz_poly_t poly, slong n) + void fmpz_poly_reverse(fmpz_poly_t res, const fmpz_poly_t poly, slong n) noexcept # This function considers the polynomial ``poly`` to be of length `n`, # notionally truncating and zero padding if required, and reverses # the result. Since the function normalises its result ``res`` may be # of length less than `n`. - void fmpz_poly_truncate(fmpz_poly_t poly, slong newlen) + void fmpz_poly_truncate(fmpz_poly_t poly, slong newlen) noexcept # If the current length of ``poly`` is greater than ``newlen``, it # is truncated to have the given length. Discarded coefficients are not # necessarily set to zero. - void fmpz_poly_set_trunc(fmpz_poly_t res, const fmpz_poly_t poly, slong n) + void fmpz_poly_set_trunc(fmpz_poly_t res, const fmpz_poly_t poly, slong n) noexcept # Sets ``res`` to a copy of ``poly``, truncated to length ``n``. - void fmpz_poly_randtest(fmpz_poly_t f, flint_rand_t state, slong len, flint_bitcnt_t bits) + void fmpz_poly_randtest(fmpz_poly_t f, flint_rand_t state, slong len, flint_bitcnt_t bits) noexcept # Sets `f` to a random polynomial with up to the given length and where # each coefficient has up to the given number of bits. The coefficients # are signed randomly. - void fmpz_poly_randtest_unsigned(fmpz_poly_t f, flint_rand_t state, slong len, flint_bitcnt_t bits) + void fmpz_poly_randtest_unsigned(fmpz_poly_t f, flint_rand_t state, slong len, flint_bitcnt_t bits) noexcept # Sets `f` to a random polynomial with up to the given length and where # each coefficient has up to the given number of bits. - void fmpz_poly_randtest_not_zero(fmpz_poly_t f, flint_rand_t state, slong len, flint_bitcnt_t bits) + void fmpz_poly_randtest_not_zero(fmpz_poly_t f, flint_rand_t state, slong len, flint_bitcnt_t bits) noexcept # As for :func:`fmpz_poly_randtest` except that ``len`` and bits may # not be zero and the polynomial generated is guaranteed not to be the # zero polynomial. - void fmpz_poly_randtest_no_real_root(fmpz_poly_t p, flint_rand_t state, slong len, flint_bitcnt_t bits) + void fmpz_poly_randtest_no_real_root(fmpz_poly_t p, flint_rand_t state, slong len, flint_bitcnt_t bits) noexcept # Sets ``p`` to a random polynomial without any real root, whose # length is up to ``len`` and where each coefficient has up to the # given number of bits. - void fmpz_poly_randtest_irreducible1(fmpz_poly_t pol, flint_rand_t state, slong len, mp_bitcnt_t bits) - void fmpz_poly_randtest_irreducible2(fmpz_poly_t pol, flint_rand_t state, slong len, mp_bitcnt_t bits) - void fmpz_poly_randtest_irreducible(fmpz_poly_t pol, flint_rand_t state, slong len, mp_bitcnt_t bits) + void fmpz_poly_randtest_irreducible1(fmpz_poly_t pol, flint_rand_t state, slong len, mp_bitcnt_t bits) noexcept + void fmpz_poly_randtest_irreducible2(fmpz_poly_t pol, flint_rand_t state, slong len, mp_bitcnt_t bits) noexcept + void fmpz_poly_randtest_irreducible(fmpz_poly_t pol, flint_rand_t state, slong len, mp_bitcnt_t bits) noexcept # Sets ``p`` to a random irreducible polynomial, whose # length is up to ``len`` and where each coefficient has up to the # given number of bits. There are two algorithms: *irreducible1* @@ -182,24 +182,24 @@ cdef extern from "flint_wrap.h": # integer polynomial, factors it, and returns a random factor. # The default function chooses randomly between these methods. - void fmpz_poly_get_coeff_fmpz(fmpz_t x, const fmpz_poly_t poly, slong n) + void fmpz_poly_get_coeff_fmpz(fmpz_t x, const fmpz_poly_t poly, slong n) noexcept # Sets `x` to the `n`-th coefficient of ``poly``. Coefficient # numbering is from zero and if `n` is set to a value beyond the end of # the polynomial, zero is returned. - slong fmpz_poly_get_coeff_si(const fmpz_poly_t poly, slong n) + slong fmpz_poly_get_coeff_si(const fmpz_poly_t poly, slong n) noexcept # Returns coefficient `n` of ``poly`` as a ``slong``. The result is # undefined if the value does not fit into a ``slong``. Coefficient # numbering is from zero and if `n` is set to a value beyond the end of # the polynomial, zero is returned. - ulong fmpz_poly_get_coeff_ui(const fmpz_poly_t poly, slong n) + ulong fmpz_poly_get_coeff_ui(const fmpz_poly_t poly, slong n) noexcept # Returns coefficient `n` of ``poly`` as a ``ulong``. The result is # undefined if the value does not fit into a ``ulong``. Coefficient # numbering is from zero and if `n` is set to a value beyond the end of the # polynomial, zero is returned. - fmpz * fmpz_poly_get_coeff_ptr(const fmpz_poly_t poly, slong n) + fmpz * fmpz_poly_get_coeff_ptr(const fmpz_poly_t poly, slong n) noexcept # Returns a reference to the coefficient of `x^n` in the polynomial, # as an ``fmpz *``. This function is provided so that individual # coefficients can be accessed and operated on by functions in the @@ -208,7 +208,7 @@ cdef extern from "flint_wrap.h": # Returns ``NULL`` when `n` exceeds the degree of the polynomial. # This function is implemented as a macro. - fmpz * fmpz_poly_lead(const fmpz_poly_t poly) + fmpz * fmpz_poly_lead(const fmpz_poly_t poly) noexcept # Returns a reference to the leading coefficient of the polynomial, # as an ``fmpz *``. This function is provided so that the leading # coefficient can be easily accessed and operated on by functions in @@ -217,281 +217,281 @@ cdef extern from "flint_wrap.h": # Returns ``NULL`` when the polynomial is zero. # This function is implemented as a macro. - void fmpz_poly_set_coeff_fmpz(fmpz_poly_t poly, slong n, const fmpz_t x) + void fmpz_poly_set_coeff_fmpz(fmpz_poly_t poly, slong n, const fmpz_t x) noexcept # Sets coefficient `n` of ``poly`` to the ``fmpz`` value ``x``. # Coefficient numbering starts from zero and if `n` is beyond the current # length of ``poly`` then the polynomial is extended and zero # coefficients inserted if necessary. - void fmpz_poly_set_coeff_si(fmpz_poly_t poly, slong n, slong x) + void fmpz_poly_set_coeff_si(fmpz_poly_t poly, slong n, slong x) noexcept # Sets coefficient `n` of ``poly`` to the ``slong`` value ``x``. # Coefficient numbering starts from zero and if `n` is beyond the current # length of ``poly`` then the polynomial is extended and zero # coefficients inserted if necessary. - void fmpz_poly_set_coeff_ui(fmpz_poly_t poly, slong n, ulong x) + void fmpz_poly_set_coeff_ui(fmpz_poly_t poly, slong n, ulong x) noexcept # Sets coefficient `n` of ``poly`` to the ``ulong`` value # ``x``. Coefficient numbering starts from zero and if `n` is beyond # the current length of ``poly`` then the polynomial is extended and # zero coefficients inserted if necessary. - bint fmpz_poly_equal(const fmpz_poly_t poly1, const fmpz_poly_t poly2) + bint fmpz_poly_equal(const fmpz_poly_t poly1, const fmpz_poly_t poly2) noexcept # Returns `1` if ``poly1`` is equal to ``poly2``, otherwise # returns `0`. The polynomials are assumed to be normalised. - bint fmpz_poly_equal_trunc(const fmpz_poly_t poly1, const fmpz_poly_t poly2, slong n) + bint fmpz_poly_equal_trunc(const fmpz_poly_t poly1, const fmpz_poly_t poly2, slong n) noexcept # Return `1` if ``poly1`` and ``poly2``, notionally truncated to # length `n` are equal, otherwise return `0`. - bint fmpz_poly_is_zero(const fmpz_poly_t poly) + bint fmpz_poly_is_zero(const fmpz_poly_t poly) noexcept # Returns `1` if the polynomial is zero and `0` otherwise. # This function is implemented as a macro. - bint fmpz_poly_is_one(const fmpz_poly_t poly) + bint fmpz_poly_is_one(const fmpz_poly_t poly) noexcept # Returns `1` if the polynomial is one and `0` otherwise. - bint fmpz_poly_is_unit(const fmpz_poly_t poly) + bint fmpz_poly_is_unit(const fmpz_poly_t poly) noexcept # Returns `1` if the polynomial is the constant polynomial `\pm 1`, # and `0` otherwise. - bint fmpz_poly_is_gen(const fmpz_poly_t poly) + bint fmpz_poly_is_gen(const fmpz_poly_t poly) noexcept # Returns `1` if the polynomial is the degree `1` polynomial `x`, and `0` # otherwise. - void _fmpz_poly_add(fmpz * res, const fmpz * poly1, slong len1, const fmpz * poly2, slong len2) + void _fmpz_poly_add(fmpz * res, const fmpz * poly1, slong len1, const fmpz * poly2, slong len2) noexcept # Sets ``res`` to the sum of ``(poly1, len1)`` and # ``(poly2, len2)``. It is assumed that ``res`` has # sufficient space for the longer of the two polynomials. - void fmpz_poly_add(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2) + void fmpz_poly_add(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2) noexcept # Sets ``res`` to the sum of ``poly1`` and ``poly2``. - void fmpz_poly_add_series(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2, slong n) + void fmpz_poly_add_series(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2, slong n) noexcept # Notionally truncate ``poly1`` and ``poly2`` to length `n` and then # set ``res`` to the sum. - void _fmpz_poly_sub(fmpz * res, const fmpz * poly1, slong len1, const fmpz * poly2, slong len2) + void _fmpz_poly_sub(fmpz * res, const fmpz * poly1, slong len1, const fmpz * poly2, slong len2) noexcept # Sets ``res`` to ``(poly1, len1)`` minus ``(poly2, len2)``. It # is assumed that ``res`` has sufficient space for the longer of the # two polynomials. - void fmpz_poly_sub(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2) + void fmpz_poly_sub(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2) noexcept # Sets ``res`` to ``poly1`` minus ``poly2``. - void fmpz_poly_sub_series(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2, slong n) + void fmpz_poly_sub_series(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2, slong n) noexcept # Notionally truncate ``poly1`` and ``poly2`` to length `n` and then # set ``res`` to the sum. - void fmpz_poly_neg(fmpz_poly_t res, const fmpz_poly_t poly) + void fmpz_poly_neg(fmpz_poly_t res, const fmpz_poly_t poly) noexcept # Sets ``res`` to ``-poly``. - void fmpz_poly_scalar_abs(fmpz_poly_t res, const fmpz_poly_t poly) + void fmpz_poly_scalar_abs(fmpz_poly_t res, const fmpz_poly_t poly) noexcept # Sets ``poly1`` to the polynomial whose coefficients are the absolute # value of those of ``poly2``. - void fmpz_poly_scalar_mul_fmpz(fmpz_poly_t poly1, const fmpz_poly_t poly2, const fmpz_t x) + void fmpz_poly_scalar_mul_fmpz(fmpz_poly_t poly1, const fmpz_poly_t poly2, const fmpz_t x) noexcept # Sets ``poly1`` to ``poly2`` times `x`. - void fmpz_poly_scalar_mul_si(fmpz_poly_t poly1, const fmpz_poly_t poly2, slong x) + void fmpz_poly_scalar_mul_si(fmpz_poly_t poly1, const fmpz_poly_t poly2, slong x) noexcept # Sets ``poly1`` to ``poly2`` times the signed ``slong x``. - void fmpz_poly_scalar_mul_ui(fmpz_poly_t poly1, const fmpz_poly_t poly2, ulong x) + void fmpz_poly_scalar_mul_ui(fmpz_poly_t poly1, const fmpz_poly_t poly2, ulong x) noexcept # Sets ``poly1`` to ``poly2`` times the ``ulong x``. - void fmpz_poly_scalar_mul_2exp(fmpz_poly_t poly1, const fmpz_poly_t poly2, ulong exp) + void fmpz_poly_scalar_mul_2exp(fmpz_poly_t poly1, const fmpz_poly_t poly2, ulong exp) noexcept # Sets ``poly1`` to ``poly2`` times ``2^exp``. - void fmpz_poly_scalar_addmul_si(fmpz_poly_t poly1, const fmpz_poly_t poly2, slong x) + void fmpz_poly_scalar_addmul_si(fmpz_poly_t poly1, const fmpz_poly_t poly2, slong x) noexcept - void fmpz_poly_scalar_addmul_ui(fmpz_poly_t poly1, const fmpz_poly_t poly2, ulong x) + void fmpz_poly_scalar_addmul_ui(fmpz_poly_t poly1, const fmpz_poly_t poly2, ulong x) noexcept - void fmpz_poly_scalar_addmul_fmpz(fmpz_poly_t poly1, const fmpz_poly_t poly2, const fmpz_t x) + void fmpz_poly_scalar_addmul_fmpz(fmpz_poly_t poly1, const fmpz_poly_t poly2, const fmpz_t x) noexcept # Sets ``poly1`` to ``poly1 + x * poly2``. - void fmpz_poly_scalar_submul_fmpz(fmpz_poly_t poly1, const fmpz_poly_t poly2, const fmpz_t x) + void fmpz_poly_scalar_submul_fmpz(fmpz_poly_t poly1, const fmpz_poly_t poly2, const fmpz_t x) noexcept # Sets ``poly1`` to ``poly1 - x * poly2``. - void fmpz_poly_scalar_fdiv_fmpz(fmpz_poly_t poly1, const fmpz_poly_t poly2, const fmpz_t x) + void fmpz_poly_scalar_fdiv_fmpz(fmpz_poly_t poly1, const fmpz_poly_t poly2, const fmpz_t x) noexcept # Sets ``poly1`` to ``poly2`` divided by the ``fmpz_t x``, # rounding coefficients down toward `- \infty`. - void fmpz_poly_scalar_fdiv_si(fmpz_poly_t poly1, const fmpz_poly_t poly2, slong x) + void fmpz_poly_scalar_fdiv_si(fmpz_poly_t poly1, const fmpz_poly_t poly2, slong x) noexcept # Sets ``poly1`` to ``poly2`` divided by the ``slong x``, # rounding coefficients down toward `- \infty`. - void fmpz_poly_scalar_fdiv_ui(fmpz_poly_t poly1, const fmpz_poly_t poly2, ulong x) + void fmpz_poly_scalar_fdiv_ui(fmpz_poly_t poly1, const fmpz_poly_t poly2, ulong x) noexcept # Sets ``poly1`` to ``poly2`` divided by the ``ulong x``, # rounding coefficients down toward `- \infty`. - void fmpz_poly_scalar_fdiv_2exp(fmpz_poly_t poly1, const fmpz_poly_t poly2, ulong x) + void fmpz_poly_scalar_fdiv_2exp(fmpz_poly_t poly1, const fmpz_poly_t poly2, ulong x) noexcept # Sets ``poly1`` to ``poly2`` divided by ``2^x``, # rounding coefficients down toward `- \infty`. - void fmpz_poly_scalar_tdiv_fmpz(fmpz_poly_t poly1, const fmpz_poly_t poly2, const fmpz_t x) + void fmpz_poly_scalar_tdiv_fmpz(fmpz_poly_t poly1, const fmpz_poly_t poly2, const fmpz_t x) noexcept # Sets ``poly1`` to ``poly2`` divided by the ``fmpz_t x``, # rounding coefficients toward `0`. - void fmpz_poly_scalar_tdiv_si(fmpz_poly_t poly1, const fmpz_poly_t poly2, slong x) + void fmpz_poly_scalar_tdiv_si(fmpz_poly_t poly1, const fmpz_poly_t poly2, slong x) noexcept # Sets ``poly1`` to ``poly2`` divided by the ``slong x``, # rounding coefficients toward `0`. - void fmpz_poly_scalar_tdiv_ui(fmpz_poly_t poly1, const fmpz_poly_t poly2, ulong x) + void fmpz_poly_scalar_tdiv_ui(fmpz_poly_t poly1, const fmpz_poly_t poly2, ulong x) noexcept # Sets ``poly1`` to ``poly2`` divided by the ``ulong x``, # rounding coefficients toward `0`. - void fmpz_poly_scalar_tdiv_2exp(fmpz_poly_t poly1, const fmpz_poly_t poly2, ulong x) + void fmpz_poly_scalar_tdiv_2exp(fmpz_poly_t poly1, const fmpz_poly_t poly2, ulong x) noexcept # Sets ``poly1`` to ``poly2`` divided by ``2^x``, # rounding coefficients toward `0`. - void fmpz_poly_scalar_divexact_fmpz(fmpz_poly_t poly1, const fmpz_poly_t poly2, const fmpz_t x) + void fmpz_poly_scalar_divexact_fmpz(fmpz_poly_t poly1, const fmpz_poly_t poly2, const fmpz_t x) noexcept # Sets ``poly1`` to ``poly2`` divided by the ``fmpz_t x``, # assuming the division is exact for every coefficient. - void fmpz_poly_scalar_divexact_si(fmpz_poly_t poly1, const fmpz_poly_t poly2, slong x) + void fmpz_poly_scalar_divexact_si(fmpz_poly_t poly1, const fmpz_poly_t poly2, slong x) noexcept # Sets ``poly1`` to ``poly2`` divided by the ``slong x``, # assuming the coefficient is exact for every coefficient. - void fmpz_poly_scalar_divexact_ui(fmpz_poly_t poly1, const fmpz_poly_t poly2, ulong x) + void fmpz_poly_scalar_divexact_ui(fmpz_poly_t poly1, const fmpz_poly_t poly2, ulong x) noexcept # Sets ``poly1`` to ``poly2`` divided by the ``ulong x``, # assuming the coefficient is exact for every coefficient. - void fmpz_poly_scalar_mod_fmpz(fmpz_poly_t poly1, const fmpz_poly_t poly2, const fmpz_t p) + void fmpz_poly_scalar_mod_fmpz(fmpz_poly_t poly1, const fmpz_poly_t poly2, const fmpz_t p) noexcept # Sets ``poly1`` to ``poly2``, reducing each coefficient # modulo `p > 0`. - void fmpz_poly_scalar_smod_fmpz(fmpz_poly_t poly1, const fmpz_poly_t poly2, const fmpz_t p) + void fmpz_poly_scalar_smod_fmpz(fmpz_poly_t poly1, const fmpz_poly_t poly2, const fmpz_t p) noexcept # Sets ``poly1`` to ``poly2``, symmetrically reducing # each coefficient modulo `p > 0`, that is, choosing the unique # representative in the interval `(-p/2, p/2]`. - slong _fmpz_poly_remove_content_2exp(fmpz * pol, slong len) + slong _fmpz_poly_remove_content_2exp(fmpz * pol, slong len) noexcept # Remove the 2-content of ``pol`` and return the number `k` # that is the maximal non-negative integer so that `2^k` divides # all coefficients of the polynomial. For the zero polynomial, # `0` is returned. - void _fmpz_poly_scale_2exp(fmpz * pol, slong len, slong k) + void _fmpz_poly_scale_2exp(fmpz * pol, slong len, slong k) noexcept # Scale ``(pol, len)`` to `p(2^k X)` in-place and divide by the # 2-content (so that the gcd of coefficients is odd). If ``k`` # is negative the polynomial is multiplied by `2^{kd}`. - void _fmpz_poly_bit_pack(mp_ptr arr, const fmpz * poly, slong len, flint_bitcnt_t bit_size, int negate) + void _fmpz_poly_bit_pack(mp_ptr arr, const fmpz * poly, slong len, flint_bitcnt_t bit_size, int negate) noexcept # Packs the coefficients of ``poly`` into bitfields of the given # ``bit_size``, negating the coefficients before packing # if ``negate`` is set to `-1`. - int _fmpz_poly_bit_unpack(fmpz * poly, slong len, mp_srcptr arr, flint_bitcnt_t bit_size, int negate) + int _fmpz_poly_bit_unpack(fmpz * poly, slong len, mp_srcptr arr, flint_bitcnt_t bit_size, int negate) noexcept # Unpacks the polynomial of given length from the array as packed into # fields of the given ``bit_size``, finally negating the coefficients # if ``negate`` is set to `-1`. Returns borrow, which is nonzero if a # leading term with coefficient `\pm1` should be added at # position ``len`` of ``poly``. - void _fmpz_poly_bit_unpack_unsigned(fmpz * poly, slong len, mp_srcptr arr, flint_bitcnt_t bit_size) + void _fmpz_poly_bit_unpack_unsigned(fmpz * poly, slong len, mp_srcptr arr, flint_bitcnt_t bit_size) noexcept # Unpacks the polynomial of given length from the array as packed into # fields of the given ``bit_size``. The coefficients are assumed to # be unsigned. - void fmpz_poly_bit_pack(fmpz_t f, const fmpz_poly_t poly, flint_bitcnt_t bit_size) + void fmpz_poly_bit_pack(fmpz_t f, const fmpz_poly_t poly, flint_bitcnt_t bit_size) noexcept # Packs ``poly`` into bitfields of size ``bit_size``, writing the # result to ``f``. The sign of ``f`` will be the same as that of # the leading coefficient of ``poly``. - void fmpz_poly_bit_unpack(fmpz_poly_t poly, const fmpz_t f, flint_bitcnt_t bit_size) + void fmpz_poly_bit_unpack(fmpz_poly_t poly, const fmpz_t f, flint_bitcnt_t bit_size) noexcept # Unpacks the polynomial with signed coefficients packed into # fields of size ``bit_size`` as represented by the integer ``f``. - void fmpz_poly_bit_unpack_unsigned(fmpz_poly_t poly, const fmpz_t f, flint_bitcnt_t bit_size) + void fmpz_poly_bit_unpack_unsigned(fmpz_poly_t poly, const fmpz_t f, flint_bitcnt_t bit_size) noexcept # Unpacks the polynomial with unsigned coefficients packed into # fields of size ``bit_size`` as represented by the integer ``f``. # It is required that ``f`` is nonnegative. - void _fmpz_poly_mul_classical(fmpz * res, const fmpz * poly1, slong len1, const fmpz * poly2, slong len2) + void _fmpz_poly_mul_classical(fmpz * res, const fmpz * poly1, slong len1, const fmpz * poly2, slong len2) noexcept # Sets ``(res, len1 + len2 - 1)`` to the product of ``(poly1, len1)`` # and ``(poly2, len2)``. # Assumes ``len1`` and ``len2`` are positive. Allows zero-padding # of the two input polynomials. No aliasing of inputs with outputs is # allowed. - void fmpz_poly_mul_classical(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2) + void fmpz_poly_mul_classical(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2) noexcept # Sets ``res`` to the product of ``poly1`` and ``poly2``, computed # using the classical or schoolbook method. - void _fmpz_poly_mullow_classical(fmpz * res, const fmpz * poly1, slong len1, const fmpz * poly2, slong len2, slong n) + void _fmpz_poly_mullow_classical(fmpz * res, const fmpz * poly1, slong len1, const fmpz * poly2, slong len2, slong n) noexcept # Sets ``(res, n)`` to the first `n` coefficients of ``(poly1, len1)`` # multiplied by ``(poly2, len2)``. # Assumes ``0 < n <= len1 + len2 - 1``. Assumes neither ``len1`` nor # ``len2`` is zero. - void fmpz_poly_mullow_classical(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2, slong n) + void fmpz_poly_mullow_classical(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2, slong n) noexcept # Sets ``res`` to the first `n` coefficients of ``poly1 * poly2``. - void _fmpz_poly_mulhigh_classical(fmpz * res, const fmpz * poly1, slong len1, const fmpz * poly2, slong len2, slong start) + void _fmpz_poly_mulhigh_classical(fmpz * res, const fmpz * poly1, slong len1, const fmpz * poly2, slong len2, slong start) noexcept # Sets the first ``start`` coefficients of ``res`` to zero and the # remainder to the corresponding coefficients of # ``(poly1, len1) * (poly2, len2)``. # Assumes ``start <= len1 + len2 - 1``. Assumes neither ``len1`` nor # ``len2`` is zero. - void fmpz_poly_mulhigh_classical(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2, slong start) + void fmpz_poly_mulhigh_classical(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2, slong start) noexcept # Sets the first ``start`` coefficients of ``res`` to zero and the # remainder to the corresponding coefficients of the product of ``poly1`` # and ``poly2``. - void _fmpz_poly_mulmid_classical(fmpz * res, const fmpz * poly1, slong len1, const fmpz * poly2, slong len2) + void _fmpz_poly_mulmid_classical(fmpz * res, const fmpz * poly1, slong len1, const fmpz * poly2, slong len2) noexcept # Sets ``res`` to the middle ``len1 - len2 + 1`` coefficients of # the product of ``(poly1, len1)`` and ``(poly2, len2)``, i.e. the # coefficients from degree ``len2 - 1`` to ``len1 - 1`` inclusive. # Assumes that ``len1 >= len2 > 0``. - void fmpz_poly_mulmid_classical(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2) + void fmpz_poly_mulmid_classical(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2) noexcept # Sets ``res`` to the middle ``len(poly1) - len(poly2) + 1`` # coefficients of ``poly1 * poly2``, i.e. the coefficient from degree # ``len2 - 1`` to ``len1 - 1`` inclusive. Assumes that # ``len1 >= len2``. - void _fmpz_poly_mul_karatsuba(fmpz * res, const fmpz * poly1, slong len1, const fmpz * poly2, slong len2) + void _fmpz_poly_mul_karatsuba(fmpz * res, const fmpz * poly1, slong len1, const fmpz * poly2, slong len2) noexcept # Sets ``(res, len1 + len2 - 1)`` to the product of ``(poly1, len1)`` # and ``(poly2, len2)``. Assumes ``len1 >= len2 > 0``. Allows # zero-padding of the two input polynomials. No aliasing of inputs with # outputs is allowed. - void fmpz_poly_mul_karatsuba(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2) + void fmpz_poly_mul_karatsuba(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2) noexcept # Sets ``res`` to the product of ``poly1`` and ``poly2``. - void _fmpz_poly_mullow_karatsuba_n(fmpz * res, const fmpz * poly1, const fmpz * poly2, slong n) + void _fmpz_poly_mullow_karatsuba_n(fmpz * res, const fmpz * poly1, const fmpz * poly2, slong n) noexcept # Sets ``res`` to the product of ``poly1`` and ``poly2`` and # truncates to the given length. It is assumed that ``poly1`` and # ``poly2`` are precisely the given length, possibly zero padded. # Assumes `n` is not zero. - void fmpz_poly_mullow_karatsuba_n(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2, slong n) + void fmpz_poly_mullow_karatsuba_n(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2, slong n) noexcept # Sets ``res`` to the product of ``poly1`` and ``poly2`` and # truncates to the given length. - void _fmpz_poly_mulhigh_karatsuba_n(fmpz * res, const fmpz * poly1, const fmpz * poly2, slong len) + void _fmpz_poly_mulhigh_karatsuba_n(fmpz * res, const fmpz * poly1, const fmpz * poly2, slong len) noexcept # Sets ``res`` to the product of ``poly1`` and ``poly2`` and # truncates at the top to the given length. The first ``len - 1`` # coefficients are set to zero. It is assumed that ``poly1`` and # ``poly2`` are precisely the given length, possibly zero padded. # Assumes ``len`` is not zero. - void fmpz_poly_mulhigh_karatsuba_n(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2, slong len) + void fmpz_poly_mulhigh_karatsuba_n(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2, slong len) noexcept # Sets the first ``len - 1`` coefficients of the result to zero and the # remaining coefficients to the corresponding coefficients of the product of # ``poly1`` and ``poly2``. Assumes ``poly1`` and ``poly2`` are # at most of the given length. - void _fmpz_poly_mul_KS(fmpz * res, const fmpz * poly1, slong len1, const fmpz * poly2, slong len2) + void _fmpz_poly_mul_KS(fmpz * res, const fmpz * poly1, slong len1, const fmpz * poly2, slong len2) noexcept # Sets ``(res, len1 + len2 - 1)`` to the product of ``(poly1, len1)`` # and ``(poly2, len2)``. # Places no assumptions on ``len1`` and ``len2``. Allows zero-padding # of the two input polynomials. Supports aliasing of inputs and outputs. - void fmpz_poly_mul_KS(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2) + void fmpz_poly_mul_KS(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2) noexcept # Sets ``res`` to the product of ``poly1`` and ``poly2``. - void _fmpz_poly_mullow_KS(fmpz * res, const fmpz * poly1, slong len1, const fmpz * poly2, slong len2, slong n) + void _fmpz_poly_mullow_KS(fmpz * res, const fmpz * poly1, slong len1, const fmpz * poly2, slong len2, slong n) noexcept # Sets ``(res, n)`` to the lowest `n` coefficients of the product of # ``(poly1, len1)`` and ``(poly2, len2)``. # Assumes that ``len1`` and ``len2`` are positive, but does allow @@ -499,21 +499,21 @@ cdef extern from "flint_wrap.h": # too. Assumes `n` is positive. Supports aliasing between ``res``, # ``poly1`` and ``poly2``. - void fmpz_poly_mullow_KS(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2, slong n) + void fmpz_poly_mullow_KS(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2, slong n) noexcept # Sets ``res`` to the lowest `n` coefficients of the product of # ``poly1`` and ``poly2``. - void _fmpz_poly_mul_SS(fmpz * output, const fmpz * input1, slong length1, const fmpz * input2, slong length2) + void _fmpz_poly_mul_SS(fmpz * output, const fmpz * input1, slong length1, const fmpz * input2, slong length2) noexcept # Sets ``(output, length1 + length2 - 1)`` to the product of # ``(input1, length1)`` and ``(input2, length2)``. # We must have ``len1 > 1`` and ``len2 > 1``. Allows zero-padding # of the two input polynomials. Supports aliasing of inputs and outputs. - void fmpz_poly_mul_SS(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2) + void fmpz_poly_mul_SS(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2) noexcept # Sets ``res`` to the product of ``poly1`` and ``poly2``. Uses the # Schönhage-Strassen algorithm. - void _fmpz_poly_mullow_SS(fmpz * output, const fmpz * input1, slong length1, const fmpz * input2, slong length2, slong n) + void _fmpz_poly_mullow_SS(fmpz * output, const fmpz * input1, slong length1, const fmpz * input2, slong length2, slong n) noexcept # Sets ``(res, n)`` to the lowest `n` coefficients of the product of # ``(poly1, len1)`` and ``(poly2, len2)``. # Assumes that ``len1`` and ``len2`` are positive, but does allow @@ -521,45 +521,45 @@ cdef extern from "flint_wrap.h": # and ``len2 > 1``. Assumes `n` is positive. Supports aliasing between # ``res``, ``poly1`` and ``poly2``. - void fmpz_poly_mullow_SS(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2, slong n) + void fmpz_poly_mullow_SS(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2, slong n) noexcept # Sets ``res`` to the lowest `n` coefficients of the product of # ``poly1`` and ``poly2``. - void _fmpz_poly_mul(fmpz * res, const fmpz * poly1, slong len1, const fmpz * poly2, slong len2) + void _fmpz_poly_mul(fmpz * res, const fmpz * poly1, slong len1, const fmpz * poly2, slong len2) noexcept # Sets ``(res, len1 + len2 - 1)`` to the product of ``(poly1, len1)`` # and ``(poly2, len2)``. Assumes ``len1 >= len2 > 0``. Allows # zero-padding of the two input polynomials. Does not support aliasing # between the inputs and the output. - void fmpz_poly_mul(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2) + void fmpz_poly_mul(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2) noexcept # Sets ``res`` to the product of ``poly1`` and ``poly2``. Chooses # an optimal algorithm from the choices above. - void _fmpz_poly_mullow(fmpz * res, const fmpz * poly1, slong len1, const fmpz * poly2, slong len2, slong n) + void _fmpz_poly_mullow(fmpz * res, const fmpz * poly1, slong len1, const fmpz * poly2, slong len2, slong n) noexcept # Sets ``(res, n)`` to the lowest `n` coefficients of the product of # ``(poly1, len1)`` and ``(poly2, len2)``. # Assumes ``len1 >= len2 > 0`` and ``0 < n <= len1 + len2 - 1``. # Allows for zero-padding in the inputs. Does not support aliasing between # the inputs and the output. - void fmpz_poly_mullow(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2, slong n) + void fmpz_poly_mullow(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2, slong n) noexcept # Sets ``res`` to the lowest `n` coefficients of the product of # ``poly1`` and ``poly2``. - void fmpz_poly_mulhigh_n(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2, slong n) + void fmpz_poly_mulhigh_n(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2, slong n) noexcept # Sets the high `n` coefficients of ``res`` to the high `n` coefficients # of the product of ``poly1`` and ``poly2``, assuming the latter are # precisely `n` coefficients in length, zero padded if necessary. The # remaining `n - 1` coefficients may be arbitrary. - void _fmpz_poly_mulhigh(fmpz * res, const fmpz * poly1, slong len1, const fmpz * poly2, slong len2, slong start) + void _fmpz_poly_mulhigh(fmpz * res, const fmpz * poly1, slong len1, const fmpz * poly2, slong len2, slong start) noexcept # Sets all but the low `n` coefficients of `res` to the corresponding # coefficients of the product of `poly1` of length `len1` and `poly2` of # length `len2`, the remaining coefficients being arbitrary. It is assumed # that `len1 >= len2 > 0` and that `0 < n < len1 + len2 - 1`. Aliasing of # inputs is not permitted. - void fmpz_poly_mul_SS_precache_init(fmpz_poly_mul_precache_t pre, slong len1, slong bits1, const fmpz_poly_t poly2) + void fmpz_poly_mul_SS_precache_init(fmpz_poly_mul_precache_t pre, slong len1, slong bits1, const fmpz_poly_t poly2) noexcept # Precompute the FFT of ``poly2`` to enable repeated multiplication of # ``poly2`` by polynomials whose length does not exceed ``len1`` and # whose number of bits per coefficient does not exceed ``bits1``. @@ -581,105 +581,105 @@ cdef extern from "flint_wrap.h": # the polynomial whose FFT is being precached does not have to be either # longer or shorter than the polynomials it is to be multiplied by. - void fmpz_poly_mul_precache_clear(fmpz_poly_mul_precache_t pre) + void fmpz_poly_mul_precache_clear(fmpz_poly_mul_precache_t pre) noexcept # Clear the space allocated by ``fmpz_poly_mul_SS_precache_init``. - void _fmpz_poly_mullow_SS_precache(fmpz * output, const fmpz * input1, slong len1, fmpz_poly_mul_precache_t pre, slong trunc) + void _fmpz_poly_mullow_SS_precache(fmpz * output, const fmpz * input1, slong len1, fmpz_poly_mul_precache_t pre, slong trunc) noexcept # Write into ``output`` the first ``trunc`` coefficients of # the polynomial ``(input1, len1)`` by the polynomial whose FFT was precached # by ``fmpz_poly_mul_SS_precache_init`` and stored in ``pre``. # For performance reasons it is recommended that all polynomials be truncated # to at most ``trunc`` coefficients if possible. - void fmpz_poly_mullow_SS_precache(fmpz_poly_t res, const fmpz_poly_t poly1, fmpz_poly_mul_precache_t pre, slong n) + void fmpz_poly_mullow_SS_precache(fmpz_poly_t res, const fmpz_poly_t poly1, fmpz_poly_mul_precache_t pre, slong n) noexcept # Set ``res`` to the product of ``poly1`` by the polynomial whose FFT was # precached by ``fmpz_poly_mul_SS_precache_init`` (and stored in pre). The # result is truncated to `n` coefficients (and normalised). # There are no restrictions on the length of ``poly1`` other than those given # in the call to ``fmpz_poly_mul_SS_precache_init``. - void fmpz_poly_mul_SS_precache(fmpz_poly_t res, const fmpz_poly_t poly1, fmpz_poly_mul_precache_t pre) + void fmpz_poly_mul_SS_precache(fmpz_poly_t res, const fmpz_poly_t poly1, fmpz_poly_mul_precache_t pre) noexcept # Set ``res`` to the product of ``poly1`` by the polynomial whose FFT was # precached by ``fmpz_poly_mul_SS_precache_init`` (and stored in pre). # There are no restrictions on the length of ``poly1`` other than those given # in the call to ``fmpz_poly_mul_SS_precache_init``. - void _fmpz_poly_sqr_KS(fmpz * rop, const fmpz * op, slong len) + void _fmpz_poly_sqr_KS(fmpz * rop, const fmpz * op, slong len) noexcept # Sets ``(rop, 2*len - 1)`` to the square of ``(op, len)``, # assuming that ``len > 0``. # Supports zero-padding in ``(op, len)``. Does not support aliasing. - void fmpz_poly_sqr_KS(fmpz_poly_t rop, const fmpz_poly_t op) + void fmpz_poly_sqr_KS(fmpz_poly_t rop, const fmpz_poly_t op) noexcept # Sets ``rop`` to the square of the polynomial ``op`` using # Kronecker segmentation. - void _fmpz_poly_sqr_karatsuba(fmpz * rop, const fmpz * op, slong len) + void _fmpz_poly_sqr_karatsuba(fmpz * rop, const fmpz * op, slong len) noexcept # Sets ``(rop, 2*len - 1)`` to the square of ``(op, len)``, # assuming that ``len > 0``. # Supports zero-padding in ``(op, len)``. Does not support aliasing. - void fmpz_poly_sqr_karatsuba(fmpz_poly_t rop, const fmpz_poly_t op) + void fmpz_poly_sqr_karatsuba(fmpz_poly_t rop, const fmpz_poly_t op) noexcept # Sets ``rop`` to the square of the polynomial ``op`` using # the Karatsuba multiplication algorithm. - void _fmpz_poly_sqr_classical(fmpz * rop, const fmpz * op, slong len) + void _fmpz_poly_sqr_classical(fmpz * rop, const fmpz * op, slong len) noexcept # Sets ``(rop, 2*len - 1)`` to the square of ``(op, len)``, # assuming that ``len > 0``. # Supports zero-padding in ``(op, len)``. Does not support aliasing. - void fmpz_poly_sqr_classical(fmpz_poly_t rop, const fmpz_poly_t op) + void fmpz_poly_sqr_classical(fmpz_poly_t rop, const fmpz_poly_t op) noexcept # Sets ``rop`` to the square of the polynomial ``op`` using # the classical or schoolbook method. - void _fmpz_poly_sqr(fmpz * rop, const fmpz * op, slong len) + void _fmpz_poly_sqr(fmpz * rop, const fmpz * op, slong len) noexcept # Sets ``(rop, 2*len - 1)`` to the square of ``(op, len)``, # assuming that ``len > 0``. # Supports zero-padding in ``(op, len)``. Does not support aliasing. - void fmpz_poly_sqr(fmpz_poly_t rop, const fmpz_poly_t op) + void fmpz_poly_sqr(fmpz_poly_t rop, const fmpz_poly_t op) noexcept # Sets ``rop`` to the square of the polynomial ``op``. - void _fmpz_poly_sqrlow_KS(fmpz * res, const fmpz * poly, slong len, slong n) + void _fmpz_poly_sqrlow_KS(fmpz * res, const fmpz * poly, slong len, slong n) noexcept # Sets ``(res, n)`` to the lowest `n` coefficients # of the square of ``(poly, len)``. # Assumes that ``len`` is positive, but does allow for the polynomial # to be zero-padded. The polynomial may be zero, too. Assumes `n` is # positive. Supports aliasing between ``res`` and ``poly``. - void fmpz_poly_sqrlow_KS(fmpz_poly_t res, const fmpz_poly_t poly, slong n) + void fmpz_poly_sqrlow_KS(fmpz_poly_t res, const fmpz_poly_t poly, slong n) noexcept # Sets ``res`` to the lowest `n` coefficients # of the square of ``poly``. - void _fmpz_poly_sqrlow_karatsuba_n(fmpz * res, const fmpz * poly, slong n) + void _fmpz_poly_sqrlow_karatsuba_n(fmpz * res, const fmpz * poly, slong n) noexcept # Sets ``(res, n)`` to the square of ``(poly, n)`` truncated # to length `n`, which is assumed to be positive. Allows for ``poly`` # to be zero-padded. - void fmpz_poly_sqrlow_karatsuba_n(fmpz_poly_t res, const fmpz_poly_t poly, slong n) + void fmpz_poly_sqrlow_karatsuba_n(fmpz_poly_t res, const fmpz_poly_t poly, slong n) noexcept # Sets ``res`` to the square of ``poly`` and # truncates to the given length. - void _fmpz_poly_sqrlow_classical(fmpz * res, const fmpz * poly, slong len, slong n) + void _fmpz_poly_sqrlow_classical(fmpz * res, const fmpz * poly, slong len, slong n) noexcept # Sets ``(res, n)`` to the first `n` coefficients of the square # of ``(poly, len)``. # Assumes that ``0 < n <= 2 * len - 1``. - void fmpz_poly_sqrlow_classical(fmpz_poly_t res, const fmpz_poly_t poly, slong n) + void fmpz_poly_sqrlow_classical(fmpz_poly_t res, const fmpz_poly_t poly, slong n) noexcept # Sets ``res`` to the first `n` coefficients of # the square of ``poly``. - void _fmpz_poly_sqrlow(fmpz * res, const fmpz * poly, slong len, slong n) + void _fmpz_poly_sqrlow(fmpz * res, const fmpz * poly, slong len, slong n) noexcept # Sets ``(res, n)`` to the lowest `n` coefficients # of the square of ``(poly, len)``. # Assumes ``len1 >= len2 > 0`` and ``0 < n <= 2 * len - 1``. # Allows for zero-padding in the input. Does not support aliasing # between the input and the output. - void fmpz_poly_sqrlow(fmpz_poly_t res, const fmpz_poly_t poly, slong n) + void fmpz_poly_sqrlow(fmpz_poly_t res, const fmpz_poly_t poly, slong n) noexcept # Sets ``res`` to the lowest `n` coefficients # of the square of ``poly``. - void _fmpz_poly_pow_multinomial(fmpz * res, const fmpz * poly, slong len, ulong e) + void _fmpz_poly_pow_multinomial(fmpz * res, const fmpz * poly, slong len, ulong e) noexcept # Computes ``res = poly^e``. This uses the J.C.P. Miller pure # recurrence as follows: # If `\ell` is the index of the lowest non-zero coefficient in ``poly``, @@ -688,7 +688,7 @@ cdef extern from "flint_wrap.h": # coefficients. # Assumes ``len > 0``, ``e > 0``. Does not support aliasing. - void fmpz_poly_pow_multinomial(fmpz_poly_t res, const fmpz_poly_t poly, ulong e) + void fmpz_poly_pow_multinomial(fmpz_poly_t res, const fmpz_poly_t poly, ulong e) noexcept # Computes ``res = poly^e`` using a generalisation of binomial expansion # called the J.C.P. Miller pure recurrence [1], [2]. # If `e` is zero, returns one, so that in particular ``0^0 = 1``. @@ -707,17 +707,17 @@ cdef extern from "flint_wrap.h": # Polynomial, and its q-Analog, Journal of Difference Equations and # Applications, 1995, Vol. 1, pp. 57--60 - void _fmpz_poly_pow_binomial(fmpz * res, const fmpz * poly, ulong e) + void _fmpz_poly_pow_binomial(fmpz * res, const fmpz * poly, ulong e) noexcept # Computes ``res = poly^e`` when poly is of length 2, using binomial # expansion. # Assumes `e > 0`. Does not support aliasing. - void fmpz_poly_pow_binomial(fmpz_poly_t res, const fmpz_poly_t poly, ulong e) + void fmpz_poly_pow_binomial(fmpz_poly_t res, const fmpz_poly_t poly, ulong e) noexcept # Computes ``res = poly^e`` when ``poly`` is of length `2`, using # binomial expansion. # If the length of ``poly`` is not `2`, raises an exception and aborts. - void _fmpz_poly_pow_addchains(fmpz * res, const fmpz * poly, slong len, const int * a, int n) + void _fmpz_poly_pow_addchains(fmpz * res, const fmpz * poly, slong len, const int * a, int n) noexcept # Given a star chain `1 = a_0 < a_1 < \dotsb < a_n = e` computes # ``res = poly^e``. # A star chain is an addition chain `1 = a_0 < a_1 < \dotsb < a_n` such @@ -725,43 +725,43 @@ cdef extern from "flint_wrap.h": # Assumes that `e > 2`, or equivalently `n > 1`, and ``len > 0``. Does # not support aliasing. - void fmpz_poly_pow_addchains(fmpz_poly_t res, const fmpz_poly_t poly, ulong e) + void fmpz_poly_pow_addchains(fmpz_poly_t res, const fmpz_poly_t poly, ulong e) noexcept # Computes ``res = poly^e`` using addition chains whenever # `0 \leq e \leq 148`. # If `e > 148`, raises an exception and aborts. - void _fmpz_poly_pow_binexp(fmpz * res, const fmpz * poly, slong len, ulong e) + void _fmpz_poly_pow_binexp(fmpz * res, const fmpz * poly, slong len, ulong e) noexcept # Sets ``res = poly^e`` using left-to-right binary exponentiation as # described on p. 461 of [Knu1997]_. # Assumes that ``len > 0``, ``e > 1``. Assumes that ``res`` is # an array of length at least ``e*(len - 1) + 1``. Does not support # aliasing. - void fmpz_poly_pow_binexp(fmpz_poly_t res, const fmpz_poly_t poly, ulong e) + void fmpz_poly_pow_binexp(fmpz_poly_t res, const fmpz_poly_t poly, ulong e) noexcept # Computes ``res = poly^e`` using the binary exponentiation algorithm. # If `e` is zero, returns one, so that in particular ``0^0 = 1``. - void _fmpz_poly_pow_small(fmpz * res, const fmpz * poly, slong len, ulong e) + void _fmpz_poly_pow_small(fmpz * res, const fmpz * poly, slong len, ulong e) noexcept # Sets ``res = poly^e`` whenever `0 \leq e \leq 4`. # Assumes that ``len > 0`` and that ``res`` is an array of length # at least ``e*(len - 1) + 1``. Does not support aliasing. - void _fmpz_poly_pow(fmpz * res, const fmpz * poly, slong len, ulong e) + void _fmpz_poly_pow(fmpz * res, const fmpz * poly, slong len, ulong e) noexcept # Sets ``res = poly^e``, assuming that ``e, len > 0`` and that # ``res`` has space for ``e*(len - 1) + 1`` coefficients. Does # not support aliasing. - void fmpz_poly_pow(fmpz_poly_t res, const fmpz_poly_t poly, ulong e) + void fmpz_poly_pow(fmpz_poly_t res, const fmpz_poly_t poly, ulong e) noexcept # Computes ``res = poly^e``. If `e` is zero, returns one, # so that in particular ``0^0 = 1``. - void _fmpz_poly_pow_trunc(fmpz * res, const fmpz * poly, ulong e, slong n) + void _fmpz_poly_pow_trunc(fmpz * res, const fmpz * poly, ulong e, slong n) noexcept # Sets ``(res, n)`` to ``(poly, n)`` raised to the power `e` and # truncated to length `n`. # Assumes that `e, n > 0`. Allows zero-padding of ``(poly, n)``. # Does not support aliasing of any inputs and outputs. - void fmpz_poly_pow_trunc(fmpz_poly_t res, const fmpz_poly_t poly, ulong e, slong n) + void fmpz_poly_pow_trunc(fmpz_poly_t res, const fmpz_poly_t poly, ulong e, slong n) noexcept # Notationally raises ``poly`` to the power `e`, truncates the result # to length `n` and writes the result in ``res``. This is computed # much more efficiently than simply powering the polynomial and truncating. @@ -770,18 +770,18 @@ cdef extern from "flint_wrap.h": # This function can be used to raise power series to a power in an # efficient way. - void _fmpz_poly_shift_left(fmpz * res, const fmpz * poly, slong len, slong n) + void _fmpz_poly_shift_left(fmpz * res, const fmpz * poly, slong len, slong n) noexcept # Sets ``(res, len + n)`` to ``(poly, len)`` shifted left by # `n` coefficients. # Inserts zero coefficients at the lower end. Assumes that ``len`` # and `n` are positive, and that ``res`` fits ``len + n`` elements. # Supports aliasing between ``res`` and ``poly``. - void fmpz_poly_shift_left(fmpz_poly_t res, const fmpz_poly_t poly, slong n) + void fmpz_poly_shift_left(fmpz_poly_t res, const fmpz_poly_t poly, slong n) noexcept # Sets ``res`` to ``poly`` shifted left by `n` coeffs. Zero # coefficients are inserted. - void _fmpz_poly_shift_right(fmpz * res, const fmpz * poly, slong len, slong n) + void _fmpz_poly_shift_right(fmpz * res, const fmpz * poly, slong len, slong n) noexcept # Sets ``(res, len - n)`` to ``(poly, len)`` shifted right by # `n` coefficients. # Assumes that ``len`` and `n` are positive, that ``len > n``, @@ -789,37 +789,37 @@ cdef extern from "flint_wrap.h": # between ``res`` and ``poly``, although in this case the top # coefficients of ``poly`` are not set to zero. - void fmpz_poly_shift_right(fmpz_poly_t res, const fmpz_poly_t poly, slong n) + void fmpz_poly_shift_right(fmpz_poly_t res, const fmpz_poly_t poly, slong n) noexcept # Sets ``res`` to ``poly`` shifted right by `n` coefficients. If `n` # is equal to or greater than the current length of ``poly``, ``res`` # is set to the zero polynomial. - ulong fmpz_poly_max_limbs(const fmpz_poly_t poly) + ulong fmpz_poly_max_limbs(const fmpz_poly_t poly) noexcept # Returns the maximum number of limbs required to store the absolute value # of coefficients of ``poly``. If ``poly`` is zero, returns `0`. - slong fmpz_poly_max_bits(const fmpz_poly_t poly) + slong fmpz_poly_max_bits(const fmpz_poly_t poly) noexcept # Computes the maximum number of bits `b` required to store the absolute # value of coefficients of ``poly``. If all the coefficients of # ``poly`` are non-negative, `b` is returned, otherwise `-b` is returned. - void fmpz_poly_height(fmpz_t height, const fmpz_poly_t poly) + void fmpz_poly_height(fmpz_t height, const fmpz_poly_t poly) noexcept # Computes the height of ``poly``, defined as the largest of the # absolute values of the coefficients of ``poly``. Equivalently, this # gives the infinity norm of the coefficients. If ``poly`` is zero, # the height is `0`. - void _fmpz_poly_2norm(fmpz_t res, const fmpz * poly, slong len) + void _fmpz_poly_2norm(fmpz_t res, const fmpz * poly, slong len) noexcept # Sets ``res`` to the Euclidean norm of ``(poly, len)``, that is, # the integer square root of the sum of the squares of the coefficients # of ``poly``. - void fmpz_poly_2norm(fmpz_t res, const fmpz_poly_t poly) + void fmpz_poly_2norm(fmpz_t res, const fmpz_poly_t poly) noexcept # Sets ``res`` to the Euclidean norm of ``poly``, that is, the # integer square root of the sum of the squares of the coefficients of # ``poly``. - mp_limb_t _fmpz_poly_2norm_normalised_bits(const fmpz * poly, slong len) + mp_limb_t _fmpz_poly_2norm_normalised_bits(const fmpz * poly, slong len) noexcept # Returns an upper bound on the number of bits of the normalised # Euclidean norm of ``(poly, len)``, i.e. the number of bits of # the Euclidean norm divided by the absolute value of the leading @@ -829,20 +829,20 @@ cdef extern from "flint_wrap.h": # It is assumed that ``len > 0``. The result only makes sense # if the leading coefficient is nonzero. - void _fmpz_poly_gcd_subresultant(fmpz * res, const fmpz * poly1, slong len1, const fmpz * poly2, slong len2) + void _fmpz_poly_gcd_subresultant(fmpz * res, const fmpz * poly1, slong len1, const fmpz * poly2, slong len2) noexcept # Computes the greatest common divisor ``(res, len2)`` of # ``(poly1, len1)`` and ``(poly2, len2)``, assuming # ``len1 >= len2 > 0``. The result is normalised to have # positive leading coefficient. Aliasing between ``res``, # ``poly1`` and ``poly2`` is supported. - void fmpz_poly_gcd_subresultant(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2) + void fmpz_poly_gcd_subresultant(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2) noexcept # Computes the greatest common divisor ``res`` of ``poly1`` and # ``poly2``, normalised to have non-negative leading coefficient. # This function uses the subresultant algorithm as described # in Algorithm 3.3.1 of [Coh1996]_. - int _fmpz_poly_gcd_heuristic(fmpz * res, const fmpz * poly1, slong len1, const fmpz * poly2, slong len2) + int _fmpz_poly_gcd_heuristic(fmpz * res, const fmpz * poly1, slong len1, const fmpz * poly2, slong len2) noexcept # Computes the greatest common divisor ``(res, len2)`` of # ``(poly1, len1)`` and ``(poly2, len2)``, assuming # ``len1 >= len2 > 0``. The result is normalised to have @@ -851,7 +851,7 @@ cdef extern from "flint_wrap.h": # may not always succeed in finding the GCD. If it fails, the # function returns 0, otherwise it returns 1. - int fmpz_poly_gcd_heuristic(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2) + int fmpz_poly_gcd_heuristic(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2) noexcept # Computes the greatest common divisor ``res`` of ``poly1`` and # ``poly2``, normalised to have non-negative leading coefficient. # The function may not always succeed in finding the GCD. If it fails, @@ -862,14 +862,14 @@ cdef extern from "flint_wrap.h": # coefficients of the GCD) and take the integer GCD. Unpack the # result and test divisibility. - void _fmpz_poly_gcd_modular(fmpz * res, const fmpz * poly1, slong len1, const fmpz * poly2, slong len2) + void _fmpz_poly_gcd_modular(fmpz * res, const fmpz * poly1, slong len1, const fmpz * poly2, slong len2) noexcept # Computes the greatest common divisor ``(res, len2)`` of # ``(poly1, len1)`` and ``(poly2, len2)``, assuming # ``len1 >= len2 > 0``. The result is normalised to have # positive leading coefficient. Aliasing between ``res``, # ``poly1`` and ``poly2`` is not supported. - void fmpz_poly_gcd_modular(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2) + void fmpz_poly_gcd_modular(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2) noexcept # Computes the greatest common divisor ``res`` of ``poly1`` and # ``poly2``, normalised to have non-negative leading coefficient. # This function uses the modular GCD algorithm. The basic @@ -878,7 +878,7 @@ cdef extern from "flint_wrap.h": # some bound is reached (or we can prove with trial division that # we have the GCD). - void _fmpz_poly_gcd(fmpz * res, const fmpz * poly1, slong len1, const fmpz * poly2, slong len2) + void _fmpz_poly_gcd(fmpz * res, const fmpz * poly1, slong len1, const fmpz * poly2, slong len2) noexcept # Computes the greatest common divisor ``res`` of ``(poly1, len1)`` # and ``(poly2, len2)``, assuming ``len1 >= len2 > 0``. The result # is normalised to have positive leading coefficient. @@ -886,11 +886,11 @@ cdef extern from "flint_wrap.h": # Aliasing between ``res``, ``poly1`` and ``poly2`` is not # supported. - void fmpz_poly_gcd(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2) + void fmpz_poly_gcd(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2) noexcept # Computes the greatest common divisor ``res`` of ``poly1`` and # ``poly2``, normalised to have non-negative leading coefficient. - void _fmpz_poly_xgcd_modular(fmpz_t r, fmpz * s, fmpz * t, const fmpz * f, slong len1, const fmpz * g, slong len2) + void _fmpz_poly_xgcd_modular(fmpz_t r, fmpz * s, fmpz * t, const fmpz * f, slong len1, const fmpz * g, slong len2) noexcept # Set `r` to the resultant of ``(f, len1)`` and ``(g, len2)``. # If the resultant is zero, the function returns immediately. Otherwise it # finds polynomials `s` and `t` such that ``s*f + t*g = r``. The length @@ -905,7 +905,7 @@ cdef extern from "flint_wrap.h": # CRT. When the CRT stabilises the resulting polynomials are simply reduced # modulo further primes until a proven bound is reached. - void fmpz_poly_xgcd_modular(fmpz_t r, fmpz_poly_t s, fmpz_poly_t t, const fmpz_poly_t f, const fmpz_poly_t g) + void fmpz_poly_xgcd_modular(fmpz_t r, fmpz_poly_t s, fmpz_poly_t t, const fmpz_poly_t f, const fmpz_poly_t g) noexcept # Set `r` to the resultant of `f` and `g`. If the resultant is zero, the # function then returns immediately, otherwise `s` and `t` are found such # that ``s*f + t*g = r``. @@ -913,7 +913,7 @@ cdef extern from "flint_wrap.h": # equal to 1). The result is undefined otherwise. # Uses the multimodular algorithm. - void _fmpz_poly_xgcd(fmpz_t r, fmpz * s, fmpz * t, const fmpz * f, slong len1, const fmpz * g, slong len2) + void _fmpz_poly_xgcd(fmpz_t r, fmpz * s, fmpz * t, const fmpz * f, slong len1, const fmpz * g, slong len2) noexcept # Set `r` to the resultant of ``(f, len1)`` and ``(g, len2)``. # If the resultant is zero, the function returns immediately. Otherwise it # finds polynomials `s` and `t` such that ``s*f + t*g = r``. The length @@ -924,21 +924,21 @@ cdef extern from "flint_wrap.h": # It is assumed that ``len1 >= len2 > 0``. No aliasing of inputs and # outputs is permitted. - void fmpz_poly_xgcd(fmpz_t r, fmpz_poly_t s, fmpz_poly_t t, const fmpz_poly_t f, const fmpz_poly_t g) + void fmpz_poly_xgcd(fmpz_t r, fmpz_poly_t s, fmpz_poly_t t, const fmpz_poly_t f, const fmpz_poly_t g) noexcept # Set `r` to the resultant of `f` and `g`. If the resultant is zero, the # function then returns immediately, otherwise `s` and `t` are found such # that ``s*f + t*g = r``. # The function assumes that `f` and `g` are primitive (have Gaussian content # equal to 1). The result is undefined otherwise. - void _fmpz_poly_lcm(fmpz * res, const fmpz * poly1, slong len1, const fmpz * poly2, slong len2) + void _fmpz_poly_lcm(fmpz * res, const fmpz * poly1, slong len1, const fmpz * poly2, slong len2) noexcept # Sets ``(res, len1 + len2 - 1)`` to the least common multiple # of the two polynomials ``(poly1, len1)`` and ``(poly2, len2)``, # normalised to have non-negative leading coefficient. # Assumes that ``len1 >= len2 > 0``. # Does not support aliasing. - void fmpz_poly_lcm(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2) + void fmpz_poly_lcm(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2) noexcept # Sets ``res`` to the least common multiple of the two # polynomials ``poly1`` and ``poly2``, normalised to # have non-negative leading coefficient. @@ -949,11 +949,11 @@ cdef extern from "flint_wrap.h": # f g = \gcd(f, g) \operatorname{lcm}(f, g) # holds up to sign. - void _fmpz_poly_resultant_modular(fmpz_t res, const fmpz * poly1, slong len1, const fmpz * poly2, slong len2) + void _fmpz_poly_resultant_modular(fmpz_t res, const fmpz * poly1, slong len1, const fmpz * poly2, slong len2) noexcept # Sets ``res`` to the resultant of ``(poly1, len1)`` and # ``(poly2, len2)``, assuming that ``len1 >= len2 > 0``. - void fmpz_poly_resultant_modular(fmpz_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2) + void fmpz_poly_resultant_modular(fmpz_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2) noexcept # Computes the resultant of ``poly1`` and ``poly2``. # For two non-zero polynomials `f(x) = a_m x^m + \dotsb + a_0` and # `g(x) = b_n x^n + \dotsb + b_0` of degrees `m` and `n`, the resultant @@ -965,18 +965,18 @@ cdef extern from "flint_wrap.h": # This function uses the modular algorithm described # in [Col1971]_. - void fmpz_poly_resultant_modular_div(fmpz_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2, const fmpz_t div, slong nbits) + void fmpz_poly_resultant_modular_div(fmpz_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2, const fmpz_t div, slong nbits) noexcept # Computes the resultant of ``poly1`` and ``poly2`` divided by # ``div`` using a slight modification of the above function. It is assumed that # the resultant is exactly divisible by ``div`` and the result ``res`` # has at most ``nbits`` bits. # This bypasses the computation of general bounds. - void _fmpz_poly_resultant_euclidean(fmpz_t res, const fmpz * poly1, slong len1, const fmpz * poly2, slong len2) + void _fmpz_poly_resultant_euclidean(fmpz_t res, const fmpz * poly1, slong len1, const fmpz * poly2, slong len2) noexcept # Sets ``res`` to the resultant of ``(poly1, len1)`` and # ``(poly2, len2)``, assuming that ``len1 >= len2 > 0``. - void fmpz_poly_resultant_euclidean(fmpz_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2) + void fmpz_poly_resultant_euclidean(fmpz_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2) noexcept # Computes the resultant of ``poly1`` and ``poly2``. # For two non-zero polynomials `f(x) = a_m x^m + \dotsb + a_0` and # `g(x) = b_n x^n + \dotsb + b_0` of degrees `m` and `n`, the resultant @@ -988,11 +988,11 @@ cdef extern from "flint_wrap.h": # This function uses the algorithm described # in Algorithm 3.3.7 of [Coh1996]_. - void _fmpz_poly_resultant(fmpz_t res, const fmpz * poly1, slong len1, const fmpz * poly2, slong len2) + void _fmpz_poly_resultant(fmpz_t res, const fmpz * poly1, slong len1, const fmpz * poly2, slong len2) noexcept # Sets ``res`` to the resultant of ``(poly1, len1)`` and # ``(poly2, len2)``, assuming that ``len1 >= len2 > 0``. - void fmpz_poly_resultant(fmpz_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2) + void fmpz_poly_resultant(fmpz_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2) noexcept # Computes the resultant of ``poly1`` and ``poly2``. # For two non-zero polynomials `f(x) = a_m x^m + \dotsb + a_0` and # `g(x) = b_n x^n + \dotsb + b_0` of degrees `m` and `n`, the resultant @@ -1002,11 +1002,11 @@ cdef extern from "flint_wrap.h": # For convenience, we define the resultant to be equal to zero if either # of the two polynomials is zero. - void _fmpz_poly_discriminant(fmpz_t res, const fmpz * poly, slong len) + void _fmpz_poly_discriminant(fmpz_t res, const fmpz * poly, slong len) noexcept # Set ``res`` to the discriminant of ``(poly, len)``. Assumes # ``len > 1``. - void fmpz_poly_discriminant(fmpz_t res, const fmpz_poly_t poly) + void fmpz_poly_discriminant(fmpz_t res, const fmpz_poly_t poly) noexcept # Set ``res`` to the discriminant of ``poly``. We normalise the # discriminant so that `\operatorname{disc}(f) = (-1)^{(n(n-1)/2)} # \operatorname{res}(f, f')/\operatorname{lc}(f)`, thus @@ -1014,32 +1014,32 @@ cdef extern from "flint_wrap.h": # - r_j)^2`, where `\operatorname{lc}(f)` is the leading coefficient of `f`, # `n` is the degree of `f` and `r_i` are the roots of `f`. - void _fmpz_poly_content(fmpz_t res, const fmpz * poly, slong len) + void _fmpz_poly_content(fmpz_t res, const fmpz * poly, slong len) noexcept # Sets ``res`` to the non-negative content of ``(poly, len)``. # Aliasing between ``res`` and the coefficients of ``poly`` is # not supported. - void fmpz_poly_content(fmpz_t res, const fmpz_poly_t poly) + void fmpz_poly_content(fmpz_t res, const fmpz_poly_t poly) noexcept # Sets ``res`` to the non-negative content of ``poly``. The content # of the zero polynomial is defined to be zero. Supports aliasing, that is, # ``res`` is allowed to be one of the coefficients of ``poly``. - void _fmpz_poly_primitive_part(fmpz * res, const fmpz * poly, slong len) + void _fmpz_poly_primitive_part(fmpz * res, const fmpz * poly, slong len) noexcept # Sets ``(res, len)`` to ``(poly, len)`` divided by the content # of ``(poly, len)``, and normalises the result to have non-negative # leading coefficient. # Assumes that ``(poly, len)`` is non-zero. Supports aliasing of # ``res`` and ``poly``. - void fmpz_poly_primitive_part(fmpz_poly_t res, const fmpz_poly_t poly) + void fmpz_poly_primitive_part(fmpz_poly_t res, const fmpz_poly_t poly) noexcept # Sets ``res`` to ``poly`` divided by the content of ``poly``, # and normalises the result to have non-negative leading coefficient. # If ``poly`` is zero, sets ``res`` to zero. - bint _fmpz_poly_is_squarefree(const fmpz * poly, slong len) + bint _fmpz_poly_is_squarefree(const fmpz * poly, slong len) noexcept # Returns whether the polynomial ``(poly, len)`` is square-free. - bint fmpz_poly_is_squarefree(const fmpz_poly_t poly) + bint fmpz_poly_is_squarefree(const fmpz_poly_t poly) noexcept # Returns whether the polynomial ``poly`` is square-free. A non-zero # polynomial is defined to be square-free if it has no non-unit square # factors. We also define the zero polynomial to be square-free. @@ -1048,7 +1048,7 @@ cdef extern from "flint_wrap.h": # whether the greatest common divisor of ``poly`` and its derivative has # length `1`. - int _fmpz_poly_divrem_basecase(fmpz * Q, fmpz * R, const fmpz * A, slong lenA, const fmpz * B, slong lenB, int exact) + int _fmpz_poly_divrem_basecase(fmpz * Q, fmpz * R, const fmpz * A, slong lenA, const fmpz * B, slong lenB, int exact) noexcept # Computes ``(Q, lenA - lenB + 1)``, ``(R, lenA)`` such that # `A = B Q + R` and each coefficient of `R` beyond ``lenB`` is reduced # modulo the leading coefficient of `B`. @@ -1066,14 +1066,14 @@ cdef extern from "flint_wrap.h": # For ordinary use set the flag ``exact`` to `0`. In this case, no checks # or early aborts occur and the function always returns `1`. - void fmpz_poly_divrem_basecase(fmpz_poly_t Q, fmpz_poly_t R, const fmpz_poly_t A, const fmpz_poly_t B) + void fmpz_poly_divrem_basecase(fmpz_poly_t Q, fmpz_poly_t R, const fmpz_poly_t A, const fmpz_poly_t B) noexcept # Computes `Q`, `R` such that `A = B Q + R` and each coefficient of `R` # beyond `\operatorname{len}(B) - 1` is reduced modulo the leading coefficient of `B`. # If the leading coefficient of `B` is `\pm 1` or the division is exact, # this is the same thing as division over `\mathbb{Q}`. An exception is raised # if `B` is zero. - int _fmpz_poly_divrem_divconquer_recursive(fmpz * Q, fmpz * BQ, fmpz * W, const fmpz * A, const fmpz * B, slong lenB, int exact) + int _fmpz_poly_divrem_divconquer_recursive(fmpz * Q, fmpz * BQ, fmpz * W, const fmpz * A, const fmpz * B, slong lenB, int exact) noexcept # Computes ``(Q, lenB)``, ``(BQ, 2 lenB - 1)`` such that # `BQ = B \times Q` and `A = B Q + R` where each coefficient of `R` beyond # `\operatorname{len}(B) - 1` is reduced modulo the leading coefficient of `B`. We @@ -1095,7 +1095,7 @@ cdef extern from "flint_wrap.h": # For ordinary use set the flag ``exact`` to `0`. In this case, no checks # or early aborts occur and the function always returns `1`. - int _fmpz_poly_divrem_divconquer(fmpz * Q, fmpz * R, const fmpz * A, slong lenA, const fmpz * B, slong lenB, int exact) + int _fmpz_poly_divrem_divconquer(fmpz * Q, fmpz * R, const fmpz * A, slong lenA, const fmpz * B, slong lenB, int exact) noexcept # Computes ``(Q, lenA - lenB + 1)``, ``(R, lenA)`` such that # `A = B Q + R` and each coefficient of `R` beyond `\operatorname{len}(B) - 1` is # reduced modulo the leading coefficient of `B`. If the leading @@ -1113,14 +1113,14 @@ cdef extern from "flint_wrap.h": # For ordinary use set the flag ``exact`` to `0`. In this case, no checks # or early aborts occur and the function always returns `1`. - void fmpz_poly_divrem_divconquer(fmpz_poly_t Q, fmpz_poly_t R, const fmpz_poly_t A, const fmpz_poly_t B) + void fmpz_poly_divrem_divconquer(fmpz_poly_t Q, fmpz_poly_t R, const fmpz_poly_t A, const fmpz_poly_t B) noexcept # Computes `Q`, `R` such that `A = B Q + R` and each coefficient of `R` # beyond `\operatorname{len}(B) - 1` is reduced modulo the leading coefficient of `B`. # If the leading coefficient of `B` is `\pm 1` or the division is exact, # this is the same as division over `\mathbb{Q}`. An exception is raised if `B` # is zero. - int _fmpz_poly_divrem(fmpz * Q, fmpz * R, const fmpz * A, slong lenA, const fmpz * B, slong lenB, int exact) + int _fmpz_poly_divrem(fmpz * Q, fmpz * R, const fmpz * A, slong lenA, const fmpz * B, slong lenB, int exact) noexcept # Computes ``(Q, lenA - lenB + 1)``, ``(R, lenA)`` such that # `A = B Q + R` and each coefficient of `R` beyond `\operatorname{len}(B) - 1` is # reduced modulo the leading coefficient of `B`. If the leading @@ -1138,14 +1138,14 @@ cdef extern from "flint_wrap.h": # For ordinary use set the flag ``exact`` to `0`. In this case, no checks # or early aborts occur and the function always returns `1`. - void fmpz_poly_divrem(fmpz_poly_t Q, fmpz_poly_t R, const fmpz_poly_t A, const fmpz_poly_t B) + void fmpz_poly_divrem(fmpz_poly_t Q, fmpz_poly_t R, const fmpz_poly_t A, const fmpz_poly_t B) noexcept # Computes `Q`, `R` such that `A = B Q + R` and each coefficient of `R` # beyond `\operatorname{len}(B) - 1` is reduced modulo the leading coefficient of `B`. # If the leading coefficient of `B` is `\pm 1` or the division is exact, # this is the same as division over `\mathbb{Q}`. An exception is raised if `B` # is zero. - int _fmpz_poly_div_basecase(fmpz * Q, fmpz * R, const fmpz * A, slong lenA, const fmpz * B, slong lenB, int exact) + int _fmpz_poly_div_basecase(fmpz * Q, fmpz * R, const fmpz * A, slong lenA, const fmpz * B, slong lenB, int exact) noexcept # Computes the quotient ``(Q, lenA - lenB + 1)`` of ``(A, lenA)`` # divided by ``(B, lenB)``. # Notationally, computes `Q`, `R` such that `A = B Q + R` and each @@ -1167,7 +1167,7 @@ cdef extern from "flint_wrap.h": # For ordinary use set the flag ``exact`` to `0`. In this case, no checks # or early aborts occur and the function always returns `1`. - void fmpz_poly_div_basecase(fmpz_poly_t Q, const fmpz_poly_t A, const fmpz_poly_t B) + void fmpz_poly_div_basecase(fmpz_poly_t Q, const fmpz_poly_t A, const fmpz_poly_t B) noexcept # Computes the quotient `Q` of `A` divided by `Q`. # Notationally, computes `Q`, `R` such that `A = B Q + R` and each # coefficient of `R` beyond `\operatorname{len}(B) - 1` is reduced modulo the leading @@ -1176,7 +1176,7 @@ cdef extern from "flint_wrap.h": # this is the same as division over `\mathbb{Q}`. An exception is raised if `B` # is zero. - int _fmpz_poly_divremlow_divconquer_recursive(fmpz * Q, fmpz * BQ, const fmpz * A, const fmpz * B, slong lenB, int exact) + int _fmpz_poly_divremlow_divconquer_recursive(fmpz * Q, fmpz * BQ, const fmpz * A, const fmpz * B, slong lenB, int exact) noexcept # Divide and conquer division of ``(A, 2 lenB - 1)`` by ``(B, lenB)``, # computing only the bottom `\operatorname{len}(B) - 1` coefficients of `B Q`. # Assumes `\operatorname{len}(B) > 0`. Requires `B Q` to have length at least @@ -1192,7 +1192,7 @@ cdef extern from "flint_wrap.h": # For ordinary use set the flag ``exact`` to `0`. In this case, no checks # or early aborts occur and the function always returns `1`. - int _fmpz_poly_div_divconquer_recursive(fmpz * Q, fmpz * temp, const fmpz * A, const fmpz * B, slong lenB, int exact) + int _fmpz_poly_div_divconquer_recursive(fmpz * Q, fmpz * temp, const fmpz * A, const fmpz * B, slong lenB, int exact) noexcept # Recursive short division in the balanced case. # Computes the quotient ``(Q, lenB)`` of ``(A, 2 lenB - 1)`` upon # division by ``(B, lenB)``. Requires `\operatorname{len}(B) > 0`. Needs a @@ -1208,7 +1208,7 @@ cdef extern from "flint_wrap.h": # For ordinary use set the flag ``exact`` to `0`. In this case, no checks # or early aborts occur and the function always returns `1`. - int _fmpz_poly_div_divconquer(fmpz * Q, const fmpz * A, slong lenA, const fmpz * B, slong lenB, int exact) + int _fmpz_poly_div_divconquer(fmpz * Q, const fmpz * A, slong lenA, const fmpz * B, slong lenB, int exact) noexcept # Computes the quotient ``(Q, lenA - lenB + 1)`` of ``(A, lenA)`` # upon division by ``(B, lenB)``. Assumes that # `\operatorname{len}(A) \geq \operatorname{len}(B) > 0`. Does not support aliasing. @@ -1221,7 +1221,7 @@ cdef extern from "flint_wrap.h": # For ordinary use set the flag ``exact`` to `0`. In this case, no checks # or early aborts occur and the function always returns `1`. - void fmpz_poly_div_divconquer(fmpz_poly_t Q, const fmpz_poly_t A, const fmpz_poly_t B) + void fmpz_poly_div_divconquer(fmpz_poly_t Q, const fmpz_poly_t A, const fmpz_poly_t B) noexcept # Computes the quotient `Q` of `A` divided by `B`. # Notationally, computes `Q`, `R` such that `A = B Q + R` and each # coefficient of `R` beyond `\operatorname{len}(B) - 1` is reduced modulo the leading @@ -1230,7 +1230,7 @@ cdef extern from "flint_wrap.h": # this is the same as division over `\mathbb{Q}`. An exception is raised if `B` # is zero. - int _fmpz_poly_div(fmpz * Q, const fmpz * A, slong lenA, const fmpz * B, slong lenB, int exact) + int _fmpz_poly_div(fmpz * Q, const fmpz * A, slong lenA, const fmpz * B, slong lenB, int exact) noexcept # Computes the quotient ``(Q, lenA - lenB + 1)`` of ``(A, lenA)`` # divided by ``(B, lenB)``. # Notationally, computes `Q`, `R` such that `A = B Q + R` and each @@ -1249,7 +1249,7 @@ cdef extern from "flint_wrap.h": # For ordinary use set the flag ``exact`` to `0`. In this case, no checks # or early aborts occur and the function always returns `1`. - void fmpz_poly_div(fmpz_poly_t Q, const fmpz_poly_t A, const fmpz_poly_t B) + void fmpz_poly_div(fmpz_poly_t Q, const fmpz_poly_t A, const fmpz_poly_t B) noexcept # Computes the quotient `Q` of `A` divided by `B`. # Notationally, computes `Q`, `R` such that `A = B Q + R` and each # coefficient of `R` beyond `\operatorname{len}(B) - 1` is reduced modulo the leading @@ -1257,7 +1257,7 @@ cdef extern from "flint_wrap.h": # the division is exact, this is the same as division over `Q`. An # exception is raised if `B` is zero. - void _fmpz_poly_rem_basecase(fmpz * R, const fmpz * A, slong lenA, const fmpz * B, slong lenB) + void _fmpz_poly_rem_basecase(fmpz * R, const fmpz * A, slong lenA, const fmpz * B, slong lenB) noexcept # Computes the remainder ``(R, lenA)`` of ``(A, lenA)`` upon # division by ``(B, lenB)``. # Notationally, computes `Q`, `R` such that `A = B Q + R` and each @@ -1268,7 +1268,7 @@ cdef extern from "flint_wrap.h": # ``(A, lenA)``. `R` and `A` may be aliased, but apart from this no # aliasing of input and output operands is allowed. - void fmpz_poly_rem_basecase(fmpz_poly_t R, const fmpz_poly_t A, const fmpz_poly_t B) + void fmpz_poly_rem_basecase(fmpz_poly_t R, const fmpz_poly_t A, const fmpz_poly_t B) noexcept # Computes the remainder `R` of `A` upon division by `B`. # Notationally, computes `Q`, `R` such that `A = B Q + R` and each # coefficient of `R` beyond `\operatorname{len}(B) - 1` is reduced modulo the leading @@ -1276,7 +1276,7 @@ cdef extern from "flint_wrap.h": # the division is exact, this is the same as division over `\mathbb{Q}`. An # exception is raised if `B` is zero. - void _fmpz_poly_rem(fmpz * R, const fmpz * A, slong lenA, const fmpz * B, slong lenB) + void _fmpz_poly_rem(fmpz * R, const fmpz * A, slong lenA, const fmpz * B, slong lenB) noexcept # Computes the remainder ``(R, lenA)`` of ``(A, lenA)`` upon division # by ``(B, lenB)``. # Notationally, computes `Q`, `R` such that `A = B Q + R` and each @@ -1286,7 +1286,7 @@ cdef extern from "flint_wrap.h": # Assumes that `\operatorname{len}(A) \geq \operatorname{len}(B) > 0`. Allows zero-padding in # ``(A, lenA)``. Aliasing of input and output operands is not allowed. - void fmpz_poly_rem(fmpz_poly_t R, const fmpz_poly_t A, const fmpz_poly_t B) + void fmpz_poly_rem(fmpz_poly_t R, const fmpz_poly_t A, const fmpz_poly_t B) noexcept # Computes the remainder `R` of `A` upon division by `B`. # Notationally, computes `Q`, `R` such that `A = B Q + R` and each # coefficient of `R` beyond `\operatorname{len}(B) - 1` is reduced modulo the leading @@ -1294,39 +1294,39 @@ cdef extern from "flint_wrap.h": # the division is exact, this is the same as division over `\mathbb{Q}`. An # exception is raised if `B` is zero. - void _fmpz_poly_div_root(fmpz * Q, const fmpz * A, slong len, const fmpz_t c) + void _fmpz_poly_div_root(fmpz * Q, const fmpz * A, slong len, const fmpz_t c) noexcept # Computes the quotient ``(Q, len-1)`` of ``(A, len)`` upon # division by `x - c`. # Supports aliasing of ``Q`` and ``A``, but the result is # undefined in case of partial overlap. - void fmpz_poly_div_root(fmpz_poly_t Q, const fmpz_poly_t A, const fmpz_t c) + void fmpz_poly_div_root(fmpz_poly_t Q, const fmpz_poly_t A, const fmpz_t c) noexcept # Computes the quotient ``(Q, len-1)`` of ``(A, len)`` upon # division by `x - c`. - void _fmpz_poly_preinvert(fmpz * B_inv, const fmpz * B, slong n) + void _fmpz_poly_preinvert(fmpz * B_inv, const fmpz * B, slong n) noexcept # Given a monic polynomial ``B`` of length ``n``, compute a precomputed # inverse ``B_inv`` of length ``n`` for use in the functions below. No # aliasing of ``B`` and ``B_inv`` is permitted. We assume ``n`` is not zero. - void fmpz_poly_preinvert(fmpz_poly_t B_inv, const fmpz_poly_t B) + void fmpz_poly_preinvert(fmpz_poly_t B_inv, const fmpz_poly_t B) noexcept # Given a monic polynomial ``B``, compute a precomputed inverse # ``B_inv`` for use in the functions below. An exception is raised if # ``B`` is zero. - void _fmpz_poly_div_preinv(fmpz * Q, const fmpz * A, slong len1, const fmpz * B, const fmpz * B_inv, slong len2) + void _fmpz_poly_div_preinv(fmpz * Q, const fmpz * A, slong len1, const fmpz * B, const fmpz * B_inv, slong len2) noexcept # Given a precomputed inverse ``B_inv`` of the polynomial ``B`` of # length ``len2``, compute the quotient ``Q`` of ``A`` by ``B``. # We assume the length ``len1`` of ``A`` is at least ``len2``. The # polynomial ``Q`` must have space for ``len1 - len2 + 1`` # coefficients. No aliasing of operands is permitted. - void fmpz_poly_div_preinv(fmpz_poly_t Q, const fmpz_poly_t A, const fmpz_poly_t B, const fmpz_poly_t B_inv) + void fmpz_poly_div_preinv(fmpz_poly_t Q, const fmpz_poly_t A, const fmpz_poly_t B, const fmpz_poly_t B_inv) noexcept # Given a precomputed inverse ``B_inv`` of the polynomial ``B``, # compute the quotient ``Q`` of ``A`` by ``B``. Aliasing of ``B`` # and ``B_inv`` is not permitted. - void _fmpz_poly_divrem_preinv(fmpz * Q, fmpz * A, slong len1, const fmpz * B, const fmpz * B_inv, slong len2) + void _fmpz_poly_divrem_preinv(fmpz * Q, fmpz * A, slong len1, const fmpz * B, const fmpz * B_inv, slong len2) noexcept # Given a precomputed inverse ``B_inv`` of the polynomial ``B`` of # length ``len2``, compute the quotient ``Q`` of ``A`` by ``B``. # The remainder is then placed in ``A``. We assume the length ``len1`` @@ -1334,38 +1334,38 @@ cdef extern from "flint_wrap.h": # space for ``len1 - len2 + 1`` coefficients. No aliasing of operands is # permitted. - void fmpz_poly_divrem_preinv(fmpz_poly_t Q, fmpz_poly_t R, const fmpz_poly_t A, const fmpz_poly_t B, const fmpz_poly_t B_inv) + void fmpz_poly_divrem_preinv(fmpz_poly_t Q, fmpz_poly_t R, const fmpz_poly_t A, const fmpz_poly_t B, const fmpz_poly_t B_inv) noexcept # Given a precomputed inverse ``B_inv`` of the polynomial ``B``, # compute the quotient ``Q`` of ``A`` by ``B`` and the remainder # ``R``. Aliasing of ``B`` and ``B_inv`` is not permitted. - fmpz ** _fmpz_poly_powers_precompute(const fmpz * B, slong len) + fmpz ** _fmpz_poly_powers_precompute(const fmpz * B, slong len) noexcept # Computes ``2*len - 1`` powers of `x` modulo the polynomial `B` of # the given length. This is used as a kind of precomputed inverse in # the remainder routine below. - void fmpz_poly_powers_precompute(fmpz_poly_powers_precomp_t pinv, fmpz_poly_t poly) + void fmpz_poly_powers_precompute(fmpz_poly_powers_precomp_t pinv, fmpz_poly_t poly) noexcept # Computes ``2*len - 1`` powers of `x` modulo the polynomial `B` of # the given length. This is used as a kind of precomputed inverse in # the remainder routine below. - void _fmpz_poly_powers_clear(fmpz ** powers, slong len) + void _fmpz_poly_powers_clear(fmpz ** powers, slong len) noexcept # Clean up resources used by precomputed powers which have been computed # by ``_fmpz_poly_powers_precompute``. - void fmpz_poly_powers_clear(fmpz_poly_powers_precomp_t pinv) + void fmpz_poly_powers_clear(fmpz_poly_powers_precomp_t pinv) noexcept # Clean up resources used by precomputed powers which have been computed # by ``fmpz_poly_powers_precompute``. - void _fmpz_poly_rem_powers_precomp(fmpz * A, slong m, const fmpz * B, slong n, fmpz ** const powers) + void _fmpz_poly_rem_powers_precomp(fmpz * A, slong m, const fmpz * B, slong n, fmpz ** const powers) noexcept # Set `A` to the remainder of `A` divide `B` given precomputed powers mod `B` # provided by ``_fmpz_poly_powers_precompute``. No aliasing is allowed. - void fmpz_poly_rem_powers_precomp(fmpz_poly_t R, const fmpz_poly_t A, const fmpz_poly_t B, const fmpz_poly_powers_precomp_t B_inv) + void fmpz_poly_rem_powers_precomp(fmpz_poly_t R, const fmpz_poly_t A, const fmpz_poly_t B, const fmpz_poly_powers_precomp_t B_inv) noexcept # Set `R` to the remainder of `A` divide `B` given precomputed powers mod `B` # provided by ``fmpz_poly_powers_precompute``. - int _fmpz_poly_divides(fmpz * Q, const fmpz * A, slong lenA, const fmpz * B, slong lenB) + int _fmpz_poly_divides(fmpz * Q, const fmpz * A, slong lenA, const fmpz * B, slong lenB) noexcept # Returns 1 if ``(B, lenB)`` divides ``(A, lenA)`` exactly and # sets `Q` to the quotient, otherwise returns 0. # It is assumed that `\operatorname{len}(A) \geq \operatorname{len}(B) > 0` and that `Q` has space @@ -1374,18 +1374,18 @@ cdef extern from "flint_wrap.h": # This function is currently unoptimised and provided for convenience # only. - int fmpz_poly_divides(fmpz_poly_t Q, const fmpz_poly_t A, const fmpz_poly_t B) + int fmpz_poly_divides(fmpz_poly_t Q, const fmpz_poly_t A, const fmpz_poly_t B) noexcept # Returns 1 if `B` divides `A` exactly and sets `Q` to the quotient, # otherwise returns 0. # This function is currently unoptimised and provided for convenience # only. - slong fmpz_poly_remove(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2) + slong fmpz_poly_remove(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2) noexcept # Set ``res`` to ``poly1`` divided by the highest power of ``poly2`` that # divides it and return the power. The divisor ``poly2`` must not be zero or # `\pm 1`, otherwise an exception is raised. - void fmpz_poly_divlow_smodp(fmpz * res, const fmpz_poly_t f, const fmpz_poly_t g, const fmpz_t p, slong n) + void fmpz_poly_divlow_smodp(fmpz * res, const fmpz_poly_t f, const fmpz_poly_t g, const fmpz_t p, slong n) noexcept # Compute the `n` lowest coefficients of `f` divided by `g`, assuming the # division is exact modulo `p`. The computed coefficients are reduced modulo # `p` using the symmetric remainder system. We require `f` to be at least `n` @@ -1393,7 +1393,7 @@ cdef extern from "flint_wrap.h": # coefficient of `g` must be coprime to `p`. This is a bespoke function used # by factoring. - void fmpz_poly_divhigh_smodp(fmpz * res, const fmpz_poly_t f, const fmpz_poly_t g, const fmpz_t p, slong n) + void fmpz_poly_divhigh_smodp(fmpz * res, const fmpz_poly_t f, const fmpz_poly_t g, const fmpz_t p, slong n) noexcept # Compute the `n` highest coefficients of `f` divided by `g`, assuming the # division is exact modulo `p`. The computed coefficients are reduced modulo # `p` using the symmetric remainder system. We require `f` to be as output @@ -1401,57 +1401,57 @@ cdef extern from "flint_wrap.h": # length `n` as inputs. The leading coefficient of `g` must be coprime to # `p`. This is a bespoke function used by factoring. - void _fmpz_poly_inv_series_basecase(fmpz * Qinv, const fmpz * Q, slong Qlen, slong n) + void _fmpz_poly_inv_series_basecase(fmpz * Qinv, const fmpz * Q, slong Qlen, slong n) noexcept # Computes the first `n` terms of the inverse power series of # ``(Q, lenQ)`` using a recurrence. # Assumes that `n \geq 1` and that `Q` has constant term `\pm 1`. # Does not support aliasing. - void fmpz_poly_inv_series_basecase(fmpz_poly_t Qinv, const fmpz_poly_t Q, slong n) + void fmpz_poly_inv_series_basecase(fmpz_poly_t Qinv, const fmpz_poly_t Q, slong n) noexcept # Computes the first `n` terms of the inverse power series of `Q` # using a recurrence, assuming that `Q` has constant term `\pm 1` # and `n \geq 1`. - void _fmpz_poly_inv_series_newton(fmpz * Qinv, const fmpz * Q, slong Qlen, slong n) + void _fmpz_poly_inv_series_newton(fmpz * Qinv, const fmpz * Q, slong Qlen, slong n) noexcept # Computes the first `n` terms of the inverse power series of # ``(Q, lenQ)`` using Newton iteration. # Assumes that `n \geq 1` and that `Q` has constant term `\pm 1`. # Does not support aliasing. - void fmpz_poly_inv_series_newton(fmpz_poly_t Qinv, const fmpz_poly_t Q, slong n) + void fmpz_poly_inv_series_newton(fmpz_poly_t Qinv, const fmpz_poly_t Q, slong n) noexcept # Computes the first `n` terms of the inverse power series of `Q` using # Newton iteration, assuming `Q` has constant term `\pm 1` and `n \geq 1`. - void _fmpz_poly_inv_series(fmpz * Qinv, const fmpz * Q, slong Qlen, slong n) + void _fmpz_poly_inv_series(fmpz * Qinv, const fmpz * Q, slong Qlen, slong n) noexcept # Computes the first `n` terms of the inverse power series of # ``(Q, lenQ)``. # Assumes that `n \geq 1` and that `Q` has constant term `\pm 1`. # Does not support aliasing. - void fmpz_poly_inv_series(fmpz_poly_t Qinv, const fmpz_poly_t Q, slong n) + void fmpz_poly_inv_series(fmpz_poly_t Qinv, const fmpz_poly_t Q, slong n) noexcept # Computes the first `n` terms of the inverse power series of `Q`, # assuming `Q` has constant term `\pm 1` and `n \geq 1`. - void _fmpz_poly_div_series_basecase(fmpz * Q, const fmpz * A, slong Alen, const fmpz * B, slong Blen, slong n) + void _fmpz_poly_div_series_basecase(fmpz * Q, const fmpz * A, slong Alen, const fmpz * B, slong Blen, slong n) noexcept - void _fmpz_poly_div_series_divconquer(fmpz * Q, const fmpz * A, slong Alen, const fmpz * B, slong Blen, slong n) + void _fmpz_poly_div_series_divconquer(fmpz * Q, const fmpz * A, slong Alen, const fmpz * B, slong Blen, slong n) noexcept - void _fmpz_poly_div_series(fmpz * Q, const fmpz * A, slong Alen, const fmpz * B, slong Blen, slong n) + void _fmpz_poly_div_series(fmpz * Q, const fmpz * A, slong Alen, const fmpz * B, slong Blen, slong n) noexcept # Divides ``(A, Alen)`` by ``(B, Blen)`` as power series over `\mathbb{Z}`, # assuming `B` has constant term `\pm 1` and `n \geq 1`. # Aliasing is not supported. - void fmpz_poly_div_series_basecase(fmpz_poly_t Q, const fmpz_poly_t A, const fmpz_poly_t B, slong n) + void fmpz_poly_div_series_basecase(fmpz_poly_t Q, const fmpz_poly_t A, const fmpz_poly_t B, slong n) noexcept - void fmpz_poly_div_series_divconquer(fmpz_poly_t Q, const fmpz_poly_t A, const fmpz_poly_t B, slong n) + void fmpz_poly_div_series_divconquer(fmpz_poly_t Q, const fmpz_poly_t A, const fmpz_poly_t B, slong n) noexcept - void fmpz_poly_div_series(fmpz_poly_t Q, const fmpz_poly_t A, const fmpz_poly_t B, slong n) + void fmpz_poly_div_series(fmpz_poly_t Q, const fmpz_poly_t A, const fmpz_poly_t B, slong n) noexcept # Performs power series division in `\mathbb{Z}[[x]] / (x^n)`. The function # considers the polynomials `A` and `B` as power series of length `n` # starting with the constant terms. The function assumes that `B` has # constant term `\pm 1` and `n \geq 1`. - void _fmpz_poly_pseudo_divrem_basecase(fmpz * Q, fmpz * R, ulong * d, const fmpz * A, slong lenA, const fmpz * B, slong lenB, const fmpz_preinvn_t inv) + void _fmpz_poly_pseudo_divrem_basecase(fmpz * Q, fmpz * R, ulong * d, const fmpz * A, slong lenA, const fmpz * B, slong lenB, const fmpz_preinvn_t inv) noexcept # If `\ell` is the leading coefficient of `B`, then computes `Q`, `R` such # that `\ell^d A = Q B + R`. This function is used for simulating division # over `\mathbb{Q}`. @@ -1465,12 +1465,12 @@ cdef extern from "flint_wrap.h": # Note: ``fmpz.h`` has to be included before ``fmpz_poly.h`` in order for # ``fmpz_poly.h`` to declare this function. - void fmpz_poly_pseudo_divrem_basecase(fmpz_poly_t Q, fmpz_poly_t R, ulong * d, const fmpz_poly_t A, const fmpz_poly_t B) + void fmpz_poly_pseudo_divrem_basecase(fmpz_poly_t Q, fmpz_poly_t R, ulong * d, const fmpz_poly_t A, const fmpz_poly_t B) noexcept # If `\ell` is the leading coefficient of `B`, then computes `Q`, `R` such # that `\ell^d A = Q B + R`. This function is used for simulating division # over `\mathbb{Q}`. - void _fmpz_poly_pseudo_divrem_divconquer(fmpz * Q, fmpz * R, ulong * d, const fmpz * A, slong lenA, const fmpz * B, slong lenB, const fmpz_preinvn_t inv) + void _fmpz_poly_pseudo_divrem_divconquer(fmpz * Q, fmpz * R, ulong * d, const fmpz * A, slong lenA, const fmpz * B, slong lenB, const fmpz_preinvn_t inv) noexcept # Computes ``(Q, lenA - lenB + 1)``, ``(R, lenA)`` such that # `\ell^d A = B Q + R`, only setting the bottom `\operatorname{len}(B) - 1` coefficients # of `R` to their correct values. The remaining top coefficients of @@ -1483,18 +1483,18 @@ cdef extern from "flint_wrap.h": # Note: ``fmpz.h`` has to be included before ``fmpz_poly.h`` in order for # ``fmpz_poly.h`` to declare this function. - void fmpz_poly_pseudo_divrem_divconquer(fmpz_poly_t Q, fmpz_poly_t R, ulong * d, const fmpz_poly_t A, const fmpz_poly_t B) + void fmpz_poly_pseudo_divrem_divconquer(fmpz_poly_t Q, fmpz_poly_t R, ulong * d, const fmpz_poly_t A, const fmpz_poly_t B) noexcept # Computes `Q`, `R`, and `d` such that `\ell^d A = B Q + R`, where `R` has # length less than the length of `B` and `\ell` is the leading coefficient # of `B`. An exception is raised if `B` is zero. - void _fmpz_poly_pseudo_divrem_cohen(fmpz * Q, fmpz * R, const fmpz * A, slong lenA, const fmpz * B, slong lenB) + void _fmpz_poly_pseudo_divrem_cohen(fmpz * Q, fmpz * R, const fmpz * A, slong lenA, const fmpz * B, slong lenB) noexcept # Assumes that `\operatorname{len}(A) \geq \operatorname{len}(B) > 0`. Assumes that `Q` can fit # `\operatorname{len}(A) - \operatorname{len}(B) + 1` coefficients, and that `R` can fit `\operatorname{len}(A)` # coefficients. Supports aliasing of ``(R, lenA)`` and ``(A, lenA)``. # But other than this, no aliasing of the inputs and outputs is supported. - void fmpz_poly_pseudo_divrem_cohen(fmpz_poly_t Q, fmpz_poly_t R, const fmpz_poly_t A, const fmpz_poly_t B) + void fmpz_poly_pseudo_divrem_cohen(fmpz_poly_t Q, fmpz_poly_t R, const fmpz_poly_t A, const fmpz_poly_t B) noexcept # This is a variant of ``fmpz_poly_pseudo_divrem`` which computes # polynomials `Q` and `R` such that `\ell^d A = B Q + R`. However, the # value of `d` is fixed at `\max{\{0, \operatorname{len}(A) - \operatorname{len}(B) + 1\}}`. @@ -1503,13 +1503,13 @@ cdef extern from "flint_wrap.h": # is not asymptotically fast. It is efficient only for short polynomials, # e.g. when `\operatorname{len}(B) < 32`. - void _fmpz_poly_pseudo_rem_cohen(fmpz * R, const fmpz * A, slong lenA, const fmpz * B, slong lenB) + void _fmpz_poly_pseudo_rem_cohen(fmpz * R, const fmpz * A, slong lenA, const fmpz * B, slong lenB) noexcept # Assumes that `\operatorname{len}(A) \geq \operatorname{len}(B) > 0`. Assumes that `R` can fit # `\operatorname{len}(A)` coefficients. Supports aliasing of ``(R, lenA)`` and # ``(A, lenA)``. But other than this, no aliasing of the inputs and # outputs is supported. - void fmpz_poly_pseudo_rem_cohen(fmpz_poly_t R, const fmpz_poly_t A, const fmpz_poly_t B) + void fmpz_poly_pseudo_rem_cohen(fmpz_poly_t R, const fmpz_poly_t A, const fmpz_poly_t B) noexcept # This is a variant of :func:`fmpz_poly_pseudo_rem` which computes # polynomials `Q` and `R` such that `\ell^d A = B Q + R`, but only # returns `R`. However, the value of `d` is fixed at @@ -1521,7 +1521,7 @@ cdef extern from "flint_wrap.h": # This function uses the algorithm described # in Algorithm 3.1.2 of [Coh1996]_. - void _fmpz_poly_pseudo_divrem(fmpz * Q, fmpz * R, ulong * d, const fmpz * A, slong lenA, const fmpz * B, slong lenB, const fmpz_preinvn_t inv) + void _fmpz_poly_pseudo_divrem(fmpz * Q, fmpz * R, ulong * d, const fmpz * A, slong lenA, const fmpz * B, slong lenB, const fmpz_preinvn_t inv) noexcept # If `\ell` is the leading coefficient of `B`, then computes # ``(Q, lenA - lenB + 1)``, ``(R, lenB - 1)`` and `d` such that # `\ell^d A = B Q + R`. This function is used for simulating division @@ -1538,76 +1538,76 @@ cdef extern from "flint_wrap.h": # Note: ``fmpz.h`` has to be included before ``fmpz_poly.h`` in order for # ``fmpz_poly.h`` to declare this function. - void fmpz_poly_pseudo_divrem(fmpz_poly_t Q, fmpz_poly_t R, ulong * d, const fmpz_poly_t A, const fmpz_poly_t B) + void fmpz_poly_pseudo_divrem(fmpz_poly_t Q, fmpz_poly_t R, ulong * d, const fmpz_poly_t A, const fmpz_poly_t B) noexcept # Computes `Q`, `R`, and `d` such that `\ell^d A = B Q + R`. - void _fmpz_poly_pseudo_div(fmpz * Q, ulong * d, const fmpz * A, slong lenA, const fmpz * B, slong lenB, const fmpz_preinvn_t inv) + void _fmpz_poly_pseudo_div(fmpz * Q, ulong * d, const fmpz * A, slong lenA, const fmpz * B, slong lenB, const fmpz_preinvn_t inv) noexcept # Pseudo-division, only returning the quotient. # Note: ``fmpz.h`` has to be included before ``fmpz_poly.h`` in order for # ``fmpz_poly.h`` to declare this function. - void fmpz_poly_pseudo_div(fmpz_poly_t Q, ulong * d, const fmpz_poly_t A, const fmpz_poly_t B) + void fmpz_poly_pseudo_div(fmpz_poly_t Q, ulong * d, const fmpz_poly_t A, const fmpz_poly_t B) noexcept # Pseudo-division, only returning the quotient. - void _fmpz_poly_pseudo_rem(fmpz * R, ulong * d, const fmpz * A, slong lenA, const fmpz * B, slong lenB, const fmpz_preinvn_t inv) + void _fmpz_poly_pseudo_rem(fmpz * R, ulong * d, const fmpz * A, slong lenA, const fmpz * B, slong lenB, const fmpz_preinvn_t inv) noexcept # Pseudo-division, only returning the remainder. # Note: ``fmpz.h`` has to be included before ``fmpz_poly.h`` in order for # ``fmpz_poly.h`` to declare this function. - void fmpz_poly_pseudo_rem(fmpz_poly_t R, ulong * d, const fmpz_poly_t A, const fmpz_poly_t B) + void fmpz_poly_pseudo_rem(fmpz_poly_t R, ulong * d, const fmpz_poly_t A, const fmpz_poly_t B) noexcept # Pseudo-division, only returning the remainder. - void _fmpz_poly_derivative(fmpz * rpoly, const fmpz * poly, slong len) + void _fmpz_poly_derivative(fmpz * rpoly, const fmpz * poly, slong len) noexcept # Sets ``(rpoly, len - 1)`` to the derivative of ``(poly, len)``. # Also handles the cases where ``len`` is `0` or `1` correctly. # Supports aliasing of ``rpoly`` and ``poly``. - void fmpz_poly_derivative(fmpz_poly_t res, const fmpz_poly_t poly) + void fmpz_poly_derivative(fmpz_poly_t res, const fmpz_poly_t poly) noexcept # Sets ``res`` to the derivative of ``poly``. - void _fmpz_poly_nth_derivative(fmpz * rpoly, const fmpz * poly, ulong n, slong len) + void _fmpz_poly_nth_derivative(fmpz * rpoly, const fmpz * poly, ulong n, slong len) noexcept # Sets ``(rpoly, len - n)`` to the nth derivative of ``(poly, len)``. # Also handles the cases where ``len <= n`` correctly. # Supports aliasing of ``rpoly`` and ``poly``. - void fmpz_poly_nth_derivative(fmpz_poly_t res, const fmpz_poly_t poly, ulong n) + void fmpz_poly_nth_derivative(fmpz_poly_t res, const fmpz_poly_t poly, ulong n) noexcept # Sets ``res`` to the nth derivative of ``poly``. - void _fmpz_poly_evaluate_divconquer_fmpz(fmpz_t res, const fmpz * poly, slong len, const fmpz_t a) + void _fmpz_poly_evaluate_divconquer_fmpz(fmpz_t res, const fmpz * poly, slong len, const fmpz_t a) noexcept # Evaluates the polynomial ``(poly, len)`` at the integer `a` using # a divide and conquer approach. Assumes that the length of the polynomial # is at least one. Allows zero padding. Does not allow aliasing between # ``res`` and ``x``. - void fmpz_poly_evaluate_divconquer_fmpz(fmpz_t res, const fmpz_poly_t poly, const fmpz_t a) + void fmpz_poly_evaluate_divconquer_fmpz(fmpz_t res, const fmpz_poly_t poly, const fmpz_t a) noexcept # Evaluates the polynomial ``poly`` at the integer `a` using a divide # and conquer approach. # Aliasing between ``res`` and ``a`` is supported, however, # ``res`` may not be part of ``poly``. - void _fmpz_poly_evaluate_horner_fmpz(fmpz_t res, const fmpz * f, slong len, const fmpz_t a) + void _fmpz_poly_evaluate_horner_fmpz(fmpz_t res, const fmpz * f, slong len, const fmpz_t a) noexcept # Evaluates the polynomial ``(f, len)`` at the integer `a` using # Horner's rule, and sets ``res`` to the result. Aliasing between # ``res`` and `a` or any of the coefficients of `f` is not supported. - void fmpz_poly_evaluate_horner_fmpz(fmpz_t res, const fmpz_poly_t f, const fmpz_t a) + void fmpz_poly_evaluate_horner_fmpz(fmpz_t res, const fmpz_poly_t f, const fmpz_t a) noexcept # Evaluates the polynomial `f` at the integer `a` using Horner's rule, and # sets ``res`` to the result. # As expected, aliasing between ``res`` and ``a`` is supported. # However, ``res`` may not be aliased with a coefficient of `f`. - void _fmpz_poly_evaluate_fmpz(fmpz_t res, const fmpz * f, slong len, const fmpz_t a) + void _fmpz_poly_evaluate_fmpz(fmpz_t res, const fmpz * f, slong len, const fmpz_t a) noexcept # Evaluates the polynomial ``(f, len)`` at the integer `a` and sets # ``res`` to the result. Aliasing between ``res`` and `a` or any # of the coefficients of `f` is not supported. - void fmpz_poly_evaluate_fmpz(fmpz_t res, const fmpz_poly_t f, const fmpz_t a) + void fmpz_poly_evaluate_fmpz(fmpz_t res, const fmpz_poly_t f, const fmpz_t a) noexcept # Evaluates the polynomial `f` at the integer `a` and sets ``res`` # to the result. # As expected, aliasing between ``res`` and `a` is supported. However, # ``res`` may not be aliased with a coefficient of `f`. - void _fmpz_poly_evaluate_divconquer_fmpq(fmpz_t rnum, fmpz_t rden, const fmpz * f, slong len, const fmpz_t anum, const fmpz_t aden) + void _fmpz_poly_evaluate_divconquer_fmpq(fmpz_t rnum, fmpz_t rden, const fmpz * f, slong len, const fmpz_t anum, const fmpz_t aden) noexcept # Evaluates the polynomial ``(f, len)`` at the rational # ``(anum, aden)`` using a divide and conquer approach, and sets # ``(rnum, rden)`` to the result in lowest terms. Assumes that @@ -1615,79 +1615,79 @@ cdef extern from "flint_wrap.h": # Aliasing between ``(rnum, rden)`` and ``(anum, aden)`` or any of # the coefficients of `f` is not supported. - void fmpz_poly_evaluate_divconquer_fmpq(fmpq_t res, const fmpz_poly_t f, const fmpq_t a) + void fmpz_poly_evaluate_divconquer_fmpq(fmpq_t res, const fmpz_poly_t f, const fmpq_t a) noexcept # Evaluates the polynomial `f` at the rational `a` using a divide # and conquer approach, and sets ``res`` to the result. - void _fmpz_poly_evaluate_horner_fmpq(fmpz_t rnum, fmpz_t rden, const fmpz * f, slong len, const fmpz_t anum, const fmpz_t aden) + void _fmpz_poly_evaluate_horner_fmpq(fmpz_t rnum, fmpz_t rden, const fmpz * f, slong len, const fmpz_t anum, const fmpz_t aden) noexcept # Evaluates the polynomial ``(f, len)`` at the rational # ``(anum, aden)`` using Horner's rule, and sets ``(rnum, rden)`` to # the result in lowest terms. # Aliasing between ``(rnum, rden)`` and ``(anum, aden)`` or any of # the coefficients of `f` is not supported. - void fmpz_poly_evaluate_horner_fmpq(fmpq_t res, const fmpz_poly_t f, const fmpq_t a) + void fmpz_poly_evaluate_horner_fmpq(fmpq_t res, const fmpz_poly_t f, const fmpq_t a) noexcept # Evaluates the polynomial `f` at the rational `a` using Horner's rule, and # sets ``res`` to the result. - void _fmpz_poly_evaluate_fmpq(fmpz_t rnum, fmpz_t rden, const fmpz * f, slong len, const fmpz_t anum, const fmpz_t aden) + void _fmpz_poly_evaluate_fmpq(fmpz_t rnum, fmpz_t rden, const fmpz * f, slong len, const fmpz_t anum, const fmpz_t aden) noexcept # Evaluates the polynomial ``(f, len)`` at the rational # ``(anum, aden)`` and sets ``(rnum, rden)`` to the result in lowest # terms. # Aliasing between ``(rnum, rden)`` and ``(anum, aden)`` or any of # the coefficients of `f` is not supported. - void fmpz_poly_evaluate_fmpq(fmpq_t res, const fmpz_poly_t f, const fmpq_t a) + void fmpz_poly_evaluate_fmpq(fmpq_t res, const fmpz_poly_t f, const fmpq_t a) noexcept # Evaluates the polynomial `f` at the rational `a`, and # sets ``res`` to the result. - mp_limb_t _fmpz_poly_evaluate_mod(const fmpz * poly, slong len, mp_limb_t a, mp_limb_t n, mp_limb_t ninv) + mp_limb_t _fmpz_poly_evaluate_mod(const fmpz * poly, slong len, mp_limb_t a, mp_limb_t n, mp_limb_t ninv) noexcept # Evaluates ``(poly, len)`` at the value `a` modulo `n` and # returns the result. The last argument ``ninv`` must be set # to the precomputed inverse of `n`, which can be obtained using # the function :func:`n_preinvert_limb`. - mp_limb_t fmpz_poly_evaluate_mod(const fmpz_poly_t poly, mp_limb_t a, mp_limb_t n) + mp_limb_t fmpz_poly_evaluate_mod(const fmpz_poly_t poly, mp_limb_t a, mp_limb_t n) noexcept # Evaluates ``poly`` at the value `a` modulo `n` and returns the result. - void fmpz_poly_evaluate_fmpz_vec(fmpz * res, const fmpz_poly_t f, const fmpz * a, slong n) + void fmpz_poly_evaluate_fmpz_vec(fmpz * res, const fmpz_poly_t f, const fmpz * a, slong n) noexcept # Evaluates ``f`` at the `n` values given in the vector ``f``, # writing the results to ``res``. - double _fmpz_poly_evaluate_horner_d(const fmpz * poly, slong n, double d) + double _fmpz_poly_evaluate_horner_d(const fmpz * poly, slong n, double d) noexcept # Evaluate ``(poly, n)`` at the double `d`. No attempt is made to do this # efficiently or in a numerically stable way. It is currently only used in # Flint for quick and dirty evaluations of polynomials with all coefficients # positive. - double fmpz_poly_evaluate_horner_d(const fmpz_poly_t poly, double d) + double fmpz_poly_evaluate_horner_d(const fmpz_poly_t poly, double d) noexcept # Evaluate ``poly`` at the double `d`. No attempt is made to do this # efficiently or in a numerically stable way. It is currently only used in # Flint for quick and dirty evaluations of polynomials with all coefficients # positive. - double _fmpz_poly_evaluate_horner_d_2exp(slong * exp, const fmpz * poly, slong n, double d) + double _fmpz_poly_evaluate_horner_d_2exp(slong * exp, const fmpz * poly, slong n, double d) noexcept # Evaluate ``(poly, n)`` at the double `d`. Return the result as a double # and an exponent ``exp`` combination. No attempt is made to do this # efficiently or in a numerically stable way. It is currently only used in # Flint for quick and dirty evaluations of polynomials with all coefficients # positive. - double fmpz_poly_evaluate_horner_d_2exp(slong * exp, const fmpz_poly_t poly, double d) + double fmpz_poly_evaluate_horner_d_2exp(slong * exp, const fmpz_poly_t poly, double d) noexcept # Evaluate ``poly`` at the double `d`. Return the result as a double # and an exponent ``exp`` combination. No attempt is made to do this # efficiently or in a numerically stable way. It is currently only used in # Flint for quick and dirty evaluations of polynomials with all coefficients # positive. - double _fmpz_poly_evaluate_horner_d_2exp2(slong * exp, const fmpz * poly, slong n, double d, slong dexp) + double _fmpz_poly_evaluate_horner_d_2exp2(slong * exp, const fmpz * poly, slong n, double d, slong dexp) noexcept # Evaluate ``poly`` at ``d*2^dexp``. Return the result as a double # and an exponent ``exp`` combination. No attempt is made to do this # efficiently or in a numerically stable way. It is currently only used in # Flint for quick and dirty evaluations of polynomials with all coefficients # positive. - void _fmpz_poly_monomial_to_newton(fmpz * poly, const fmpz * roots, slong n) + void _fmpz_poly_monomial_to_newton(fmpz * poly, const fmpz * roots, slong n) noexcept # Converts ``(poly, n)`` in-place from its coefficients given # in the standard monomial basis to the Newton basis # for the roots `r_0, r_1, \ldots, r_{n-2}`. @@ -1696,7 +1696,7 @@ cdef extern from "flint_wrap.h": # is equal to the input polynomial. # Uses repeated polynomial division. - void _fmpz_poly_newton_to_monomial(fmpz * poly, const fmpz * roots, slong n) + void _fmpz_poly_newton_to_monomial(fmpz * poly, const fmpz * roots, slong n) noexcept # Converts ``(poly, n)`` in-place from its coefficients given # in the Newton basis for the roots `r_0, r_1, \ldots, r_{n-2}` # to the standard monomial basis. In other words, this evaluates @@ -1704,7 +1704,7 @@ cdef extern from "flint_wrap.h": # where `c_i` are the input coefficients for ``poly``. # Uses Horner's rule. - void fmpz_poly_interpolate_fmpz_vec(fmpz_poly_t poly, const fmpz * xs, const fmpz * ys, slong n) + void fmpz_poly_interpolate_fmpz_vec(fmpz_poly_t poly, const fmpz * xs, const fmpz * ys, slong n) noexcept # Sets ``poly`` to the unique interpolating polynomial of degree at # most `n - 1` satisfying `f(x_i) = y_i` for every pair `x_i, y_u` in # ``xs`` and ``ys``, assuming that this polynomial has integer @@ -1713,7 +1713,7 @@ cdef extern from "flint_wrap.h": # exist, a ``FLINT_INEXACT`` exception is thrown. # It is assumed that the `x` values are distinct. - void _fmpz_poly_compose_horner(fmpz * res, const fmpz * poly1, slong len1, const fmpz * poly2, slong len2) + void _fmpz_poly_compose_horner(fmpz * res, const fmpz * poly1, slong len1, const fmpz * poly2, slong len2) noexcept # Sets ``res`` to the composition of ``(poly1, len1)`` and # ``(poly2, len2)``. # Assumes that ``res`` has space for ``(len1-1)*(len2-1) + 1`` @@ -1721,13 +1721,13 @@ cdef extern from "flint_wrap.h": # polynomials. Does not support aliasing between any of the inputs and # the output. - void fmpz_poly_compose_horner(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2) + void fmpz_poly_compose_horner(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2) noexcept # Sets ``res`` to the composition of ``poly1`` and ``poly2``. # To be more precise, denoting ``res``, ``poly1``, and ``poly2`` # by `f`, `g`, and `h`, sets `f(t) = g(h(t))`. # This implementation uses Horner's method. - void _fmpz_poly_compose_divconquer(fmpz * res, const fmpz * poly1, slong len1, const fmpz * poly2, slong len2) + void _fmpz_poly_compose_divconquer(fmpz * res, const fmpz * poly1, slong len1, const fmpz * poly2, slong len2) noexcept # Computes the composition of ``(poly1, len1)`` and ``(poly2, len2)`` # using a divide and conquer approach and places the result into ``res``, # assuming ``res`` can hold the output of length @@ -1735,13 +1735,13 @@ cdef extern from "flint_wrap.h": # Assumes ``len1, len2 > 0``. Does not support aliasing between # ``res`` and any of ``(poly1, len1)`` and ``(poly2, len2)``. - void fmpz_poly_compose_divconquer(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2) + void fmpz_poly_compose_divconquer(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2) noexcept # Sets ``res`` to the composition of ``poly1`` and ``poly2``. # To be precise about the order of composition, denoting ``res``, # ``poly1``, and ``poly2`` by `f`, `g`, and `h`, respectively, # sets `f(t) = g(h(t))`. - void _fmpz_poly_compose(fmpz * res, const fmpz * poly1, slong len1, const fmpz * poly2, slong len2) + void _fmpz_poly_compose(fmpz * res, const fmpz * poly1, slong len1, const fmpz * poly2, slong len2) noexcept # Sets ``res`` to the composition of ``(poly1, len1)`` and # ``(poly2, len2)``. # Assumes that ``res`` has space for ``(len1-1)*(len2-1) + 1`` @@ -1749,58 +1749,58 @@ cdef extern from "flint_wrap.h": # polynomials. Does not support aliasing between any of the inputs and # the output. - void fmpz_poly_compose(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2) + void fmpz_poly_compose(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2) noexcept # Sets ``res`` to the composition of ``poly1`` and ``poly2``. # To be precise about the order of composition, denoting ``res``, # ``poly1``, and ``poly2`` by `f`, `g`, and `h`, respectively, # sets `f(t) = g(h(t))`. - void fmpz_poly_inflate(fmpz_poly_t result, const fmpz_poly_t input, ulong inflation) + void fmpz_poly_inflate(fmpz_poly_t result, const fmpz_poly_t input, ulong inflation) noexcept # Sets ``result`` to the inflated polynomial `p(x^n)` where # `p` is given by ``input`` and `n` is given by ``inflation``. - void fmpz_poly_deflate(fmpz_poly_t result, const fmpz_poly_t input, ulong deflation) + void fmpz_poly_deflate(fmpz_poly_t result, const fmpz_poly_t input, ulong deflation) noexcept # Sets ``result`` to the deflated polynomial `p(x^{1/n})` where # `p` is given by ``input`` and `n` is given by ``deflation``. # Requires `n > 0`. - ulong fmpz_poly_deflation(const fmpz_poly_t input) + ulong fmpz_poly_deflation(const fmpz_poly_t input) noexcept # Returns the largest integer by which ``input`` can be deflated. # As special cases, returns 0 if ``input`` is the zero polynomial # and 1 if ``input`` is a constant polynomial. - void _fmpz_poly_taylor_shift_horner(fmpz * poly, const fmpz_t c, slong n) + void _fmpz_poly_taylor_shift_horner(fmpz * poly, const fmpz_t c, slong n) noexcept # Performs the Taylor shift composing ``poly`` by `x+c` in-place. # Uses an efficient version Horner's rule. - void fmpz_poly_taylor_shift_horner(fmpz_poly_t g, const fmpz_poly_t f, const fmpz_t c) + void fmpz_poly_taylor_shift_horner(fmpz_poly_t g, const fmpz_poly_t f, const fmpz_t c) noexcept # Performs the Taylor shift composing ``f`` by `x+c`. - void _fmpz_poly_taylor_shift_divconquer(fmpz * poly, const fmpz_t c, slong n) + void _fmpz_poly_taylor_shift_divconquer(fmpz * poly, const fmpz_t c, slong n) noexcept # Performs the Taylor shift composing ``poly`` by `x+c` in-place. # Uses the divide-and-conquer polynomial composition algorithm. - void fmpz_poly_taylor_shift_divconquer(fmpz_poly_t g, const fmpz_poly_t f, const fmpz_t c) + void fmpz_poly_taylor_shift_divconquer(fmpz_poly_t g, const fmpz_poly_t f, const fmpz_t c) noexcept # Performs the Taylor shift composing ``f`` by `x+c`. # Uses the divide-and-conquer polynomial composition algorithm. - void _fmpz_poly_taylor_shift_multi_mod(fmpz * poly, const fmpz_t c, slong n) + void _fmpz_poly_taylor_shift_multi_mod(fmpz * poly, const fmpz_t c, slong n) noexcept # Performs the Taylor shift composing ``poly`` by `x+c` in-place. # Uses a multimodular algorithm, distributing the computation # across :func:`flint_get_num_threads` threads. - void fmpz_poly_taylor_shift_multi_mod(fmpz_poly_t g, const fmpz_poly_t f, const fmpz_t c) + void fmpz_poly_taylor_shift_multi_mod(fmpz_poly_t g, const fmpz_poly_t f, const fmpz_t c) noexcept # Performs the Taylor shift composing ``f`` by `x+c`. # Uses a multimodular algorithm, distributing the computation # across :func:`flint_get_num_threads` threads. - void _fmpz_poly_taylor_shift(fmpz * poly, const fmpz_t c, slong n) + void _fmpz_poly_taylor_shift(fmpz * poly, const fmpz_t c, slong n) noexcept # Performs the Taylor shift composing ``poly`` by `x+c` in-place. - void fmpz_poly_taylor_shift(fmpz_poly_t g, const fmpz_poly_t f, const fmpz_t c) + void fmpz_poly_taylor_shift(fmpz_poly_t g, const fmpz_poly_t f, const fmpz_t c) noexcept # Performs the Taylor shift composing ``f`` by `x+c`. - void _fmpz_poly_compose_series_horner(fmpz * res, const fmpz * poly1, slong len1, const fmpz * poly2, slong len2, slong n) + void _fmpz_poly_compose_series_horner(fmpz * res, const fmpz * poly1, slong len1, const fmpz * poly2, slong len2, slong n) noexcept # Sets ``res`` to the composition of ``poly1`` and ``poly2`` # modulo `x^n`, where the constant term of ``poly2`` is required # to be zero. @@ -1810,13 +1810,13 @@ cdef extern from "flint_wrap.h": # of the inputs and the output. # This implementation uses the Horner scheme. - void fmpz_poly_compose_series_horner(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2, slong n) + void fmpz_poly_compose_series_horner(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2, slong n) noexcept # Sets ``res`` to the composition of ``poly1`` and ``poly2`` # modulo `x^n`, where the constant term of ``poly2`` is required # to be zero. # This implementation uses the Horner scheme. - void _fmpz_poly_compose_series_brent_kung(fmpz * res, const fmpz * poly1, slong len1, const fmpz * poly2, slong len2, slong n) + void _fmpz_poly_compose_series_brent_kung(fmpz * res, const fmpz * poly1, slong len1, const fmpz * poly2, slong len2, slong n) noexcept # Sets ``res`` to the composition of ``poly1`` and ``poly2`` # modulo `x^n`, where the constant term of ``poly2`` is required # to be zero. @@ -1826,13 +1826,13 @@ cdef extern from "flint_wrap.h": # of the inputs and the output. # This implementation uses Brent-Kung algorithm 2.1 [BrentKung1978]_. - void fmpz_poly_compose_series_brent_kung(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2, slong n) + void fmpz_poly_compose_series_brent_kung(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2, slong n) noexcept # Sets ``res`` to the composition of ``poly1`` and ``poly2`` # modulo `x^n`, where the constant term of ``poly2`` is required # to be zero. # This implementation uses Brent-Kung algorithm 2.1 [BrentKung1978]_. - void _fmpz_poly_compose_series(fmpz * res, const fmpz * poly1, slong len1, const fmpz * poly2, slong len2, slong n) + void _fmpz_poly_compose_series(fmpz * res, const fmpz * poly1, slong len1, const fmpz * poly2, slong len2, slong n) noexcept # Sets ``res`` to the composition of ``poly1`` and ``poly2`` # modulo `x^n`, where the constant term of ``poly2`` is required # to be zero. @@ -1843,14 +1843,14 @@ cdef extern from "flint_wrap.h": # This implementation automatically switches between the Horner scheme # and Brent-Kung algorithm 2.1 depending on the size of the inputs. - void fmpz_poly_compose_series(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2, slong n) + void fmpz_poly_compose_series(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2, slong n) noexcept # Sets ``res`` to the composition of ``poly1`` and ``poly2`` # modulo `x^n`, where the constant term of ``poly2`` is required # to be zero. # This implementation automatically switches between the Horner scheme # and Brent-Kung algorithm 2.1 depending on the size of the inputs. - void _fmpz_poly_revert_series_lagrange(fmpz * Qinv, const fmpz * Q, slong Qlen, slong n) + void _fmpz_poly_revert_series_lagrange(fmpz * Qinv, const fmpz * Q, slong Qlen, slong n) noexcept # Sets ``Qinv`` to the compositional inverse or reversion of # ``(Q, Qlen)`` as a power series, i.e. computes `Q^{-1}` such that # `Q(Q^{-1}(x)) = Q^{-1}(Q(x)) = x \bmod x^n`. The arguments may not be @@ -1858,14 +1858,14 @@ cdef extern from "flint_wrap.h": # It is required that `Q_0 = 0` and `Q_1 = \pm 1`. # This implementation uses the Lagrange inversion formula. - void fmpz_poly_revert_series_lagrange(fmpz_poly_t Qinv, const fmpz_poly_t Q, slong n) + void fmpz_poly_revert_series_lagrange(fmpz_poly_t Qinv, const fmpz_poly_t Q, slong n) noexcept # Sets ``Qinv`` to the compositional inverse or reversion of ``Q`` # as a power series, i.e. computes `Q^{-1}` such that # `Q(Q^{-1}(x)) = Q^{-1}(Q(x)) = x \bmod x^n`. # It is required that `Q_0 = 0` and `Q_1 = \pm 1`. # This implementation uses the Lagrange inversion formula. - void _fmpz_poly_revert_series_lagrange_fast(fmpz * Qinv, const fmpz * Q, slong Qlen, slong n) + void _fmpz_poly_revert_series_lagrange_fast(fmpz * Qinv, const fmpz * Q, slong Qlen, slong n) noexcept # Sets ``Qinv`` to the compositional inverse or reversion of # ``(Q, Qlen)`` # as a power series, i.e. computes `Q^{-1}` such that @@ -1875,7 +1875,7 @@ cdef extern from "flint_wrap.h": # This implementation uses a reduced-complexity implementation # of the Lagrange inversion formula. - void fmpz_poly_revert_series_lagrange_fast(fmpz_poly_t Qinv, const fmpz_poly_t Q, slong n) + void fmpz_poly_revert_series_lagrange_fast(fmpz_poly_t Qinv, const fmpz_poly_t Q, slong n) noexcept # Sets ``Qinv`` to the compositional inverse or reversion of ``Q`` # as a power series, i.e. computes `Q^{-1}` such that # `Q(Q^{-1}(x)) = Q^{-1}(Q(x)) = x \bmod x^n`. @@ -1883,7 +1883,7 @@ cdef extern from "flint_wrap.h": # This implementation uses a reduced-complexity implementation # of the Lagrange inversion formula. - void _fmpz_poly_revert_series_newton(fmpz * Qinv, const fmpz * Q, slong Qlen, slong n) + void _fmpz_poly_revert_series_newton(fmpz * Qinv, const fmpz * Q, slong Qlen, slong n) noexcept # Sets ``Qinv`` to the compositional inverse or reversion of ``Q`` # as a power series, i.e. computes `Q^{-1}` such that # `Q(Q^{-1}(x)) = Q^{-1}(Q(x)) = x \bmod x^n`. The arguments may not be @@ -1891,14 +1891,14 @@ cdef extern from "flint_wrap.h": # It is required that `Q_0 = 0` and `Q_1 = \pm 1`. # This implementation uses Newton iteration [BrentKung1978]_. - void fmpz_poly_revert_series_newton(fmpz_poly_t Qinv, const fmpz_poly_t Q, slong n) + void fmpz_poly_revert_series_newton(fmpz_poly_t Qinv, const fmpz_poly_t Q, slong n) noexcept # Sets ``Qinv`` to the compositional inverse or reversion of ``Q`` # as a power series, i.e. computes `Q^{-1}` such that # `Q(Q^{-1}(x)) = Q^{-1}(Q(x)) = x \bmod x^n`. # It is required that `Q_0 = 0` and `Q_1 = \pm 1`. # This implementation uses Newton iteration [BrentKung1978]_. - void _fmpz_poly_revert_series(fmpz * Qinv, const fmpz * Q, slong Qlen, slong n) + void _fmpz_poly_revert_series(fmpz * Qinv, const fmpz * Q, slong Qlen, slong n) noexcept # Sets ``Qinv`` to the compositional inverse or reversion of ``Q`` # as a power series, i.e. computes `Q^{-1}` such that # `Q(Q^{-1}(x)) = Q^{-1}(Q(x)) = x \bmod x^n`. The arguments may not be @@ -1907,7 +1907,7 @@ cdef extern from "flint_wrap.h": # This implementation defaults to the fast version of # Lagrange interpolation. - void fmpz_poly_revert_series(fmpz_poly_t Qinv, const fmpz_poly_t Q, slong n) + void fmpz_poly_revert_series(fmpz_poly_t Qinv, const fmpz_poly_t Q, slong n) noexcept # Sets ``Qinv`` to the compositional inverse or reversion of ``Q`` # as a power series, i.e. computes `Q^{-1}` such that # `Q(Q^{-1}(x)) = Q^{-1}(Q(x)) = x \bmod x^n`. @@ -1915,7 +1915,7 @@ cdef extern from "flint_wrap.h": # This implementation defaults to the fast version of # Lagrange interpolation. - int _fmpz_poly_sqrtrem_classical(fmpz * res, fmpz * r, const fmpz * poly, slong len) + int _fmpz_poly_sqrtrem_classical(fmpz * res, fmpz * r, const fmpz * poly, slong len) noexcept # Returns 1 if ``(poly, len)`` can be written in the form `A^2 + R` where # deg(`R`) < deg(``poly``), otherwise returns `0`. If it can be so # written, ``(res, m - 1)`` is set to `A` and ``(res, m)`` is set to @@ -1923,11 +1923,11 @@ cdef extern from "flint_wrap.h": # For efficiency reasons, ``r`` must have room for ``len`` # coefficients, and may alias ``poly``. - int fmpz_poly_sqrtrem_classical(fmpz_poly_t b, fmpz_poly_t r, const fmpz_poly_t a) + int fmpz_poly_sqrtrem_classical(fmpz_poly_t b, fmpz_poly_t r, const fmpz_poly_t a) noexcept # If `a` can be written as `b^2 + r` with `\deg(r) < \deg(a)/2`, return # `1` and set `b` and `r` appropriately. Otherwise return `0`. - int _fmpz_poly_sqrtrem_divconquer(fmpz * res, fmpz * r, const fmpz * poly, slong len, fmpz * temp) + int _fmpz_poly_sqrtrem_divconquer(fmpz * res, fmpz * r, const fmpz * poly, slong len, fmpz * temp) noexcept # Returns 1 if ``(poly, len)`` can be written in the form `A^2 + R` where # deg(`R`) < deg(``poly``), otherwise returns `0`. If it can be so # written, ``(res, m - 1)`` is set to `A` and ``(res, m)`` is set to @@ -1936,11 +1936,11 @@ cdef extern from "flint_wrap.h": # coefficients, and may alias ``poly``. Temporary space of ``len`` # coefficients is required. - int fmpz_poly_sqrtrem_divconquer(fmpz_poly_t b, fmpz_poly_t r, const fmpz_poly_t a) + int fmpz_poly_sqrtrem_divconquer(fmpz_poly_t b, fmpz_poly_t r, const fmpz_poly_t a) noexcept # If `a` can be written as `b^2 + r` with `\deg(r) < \deg(a)/2`, return # `1` and set `b` and `r` appropriately. Otherwise return `0`. - int _fmpz_poly_sqrt_classical(fmpz * res, const fmpz * poly, slong len, int exact) + int _fmpz_poly_sqrt_classical(fmpz * res, const fmpz * poly, slong len, int exact) noexcept # If ``exact`` is `1` and ``(poly, len)`` is a perfect square, sets # ``(res, len / 2 + 1)`` to the square root of ``poly`` with positive # leading coefficient and returns 1. Otherwise returns 0. @@ -1950,12 +1950,12 @@ cdef extern from "flint_wrap.h": # Then, it computes the square root iteratively from top to bottom, # requiring `O(n^2)` coefficient operations. - int fmpz_poly_sqrt_classical(fmpz_poly_t b, const fmpz_poly_t a) + int fmpz_poly_sqrt_classical(fmpz_poly_t b, const fmpz_poly_t a) noexcept # If ``a`` is a perfect square, sets ``b`` to the square root of # ``a`` with positive leading coefficient and returns 1. # Otherwise returns 0. - int _fmpz_poly_sqrt_KS(fmpz * res, const fmpz * poly, slong len) + int _fmpz_poly_sqrt_KS(fmpz * res, const fmpz * poly, slong len) noexcept # Heuristic square root. If the return value is `-1`, the function failed, # otherwise it succeeded and the following applies. # If ``(poly, len)`` is a perfect square, sets @@ -1964,14 +1964,14 @@ cdef extern from "flint_wrap.h": # This function first uses various tests to detect nonsquares quickly. # Then, it computes the square root iteratively from top to bottom. - int fmpz_poly_sqrt_KS(fmpz_poly_t b, const fmpz_poly_t a) + int fmpz_poly_sqrt_KS(fmpz_poly_t b, const fmpz_poly_t a) noexcept # Heuristic square root. If the return value is `-1`, the function failed, # otherwise it succeeded and the following applies. # If ``a`` is a perfect square, sets ``b`` to the square root of # ``a`` with positive leading coefficient and returns 1. # Otherwise returns 0. - int _fmpz_poly_sqrt_divconquer(fmpz * res, const fmpz * poly, slong len, int exact) + int _fmpz_poly_sqrt_divconquer(fmpz * res, const fmpz * poly, slong len, int exact) noexcept # If ``exact`` is `1` and ``(poly, len)`` is a perfect square, sets # ``(res, len / 2 + 1)`` to the square root of ``poly`` with positive # leading coefficient and returns 1. Otherwise returns 0. @@ -1980,29 +1980,29 @@ cdef extern from "flint_wrap.h": # This function first uses various tests to detect nonsquares quickly. # Then, it computes the square root iteratively from top to bottom. - int fmpz_poly_sqrt_divconquer(fmpz_poly_t b, const fmpz_poly_t a) + int fmpz_poly_sqrt_divconquer(fmpz_poly_t b, const fmpz_poly_t a) noexcept # If ``a`` is a perfect square, sets ``b`` to the square root of # ``a`` with positive leading coefficient and returns 1. # Otherwise returns 0. - int _fmpz_poly_sqrt(fmpz * res, const fmpz * poly, slong len) + int _fmpz_poly_sqrt(fmpz * res, const fmpz * poly, slong len) noexcept # If ``(poly, len)`` is a perfect square, sets ``(res, len / 2 + 1)`` # to the square root of ``poly`` with positive leading coefficient # and returns 1. Otherwise returns 0. - int fmpz_poly_sqrt(fmpz_poly_t b, const fmpz_poly_t a) + int fmpz_poly_sqrt(fmpz_poly_t b, const fmpz_poly_t a) noexcept # If ``a`` is a perfect square, sets ``b`` to the square root of # ``a`` with positive leading coefficient and returns 1. # Otherwise returns 0. - int _fmpz_poly_sqrt_series(fmpz * res, const fmpz * poly, slong len, slong n) + int _fmpz_poly_sqrt_series(fmpz * res, const fmpz * poly, slong len, slong n) noexcept # Set ``(res, n)`` to the square root of the series ``(poly, n)``, if it # exists, and return `1`, otherwise, return `0`. # If the valuation of ``poly`` is not zero, ``res`` is zero padded # to make up for the fact that the square root may not be known to precision # `n`. - int fmpz_poly_sqrt_series(fmpz_poly_t b, const fmpz_poly_t a, slong n) + int fmpz_poly_sqrt_series(fmpz_poly_t b, const fmpz_poly_t a, slong n) noexcept # Set ``b`` to the square root of the series ``a``, where the latter # is taken to be a series of precision `n`. If such a square root exists, # return `1`, otherwise, return `0`. @@ -2010,31 +2010,31 @@ cdef extern from "flint_wrap.h": # not have precision ``n``. It is given only to the precision to which # the square root can be computed. - void _fmpz_poly_power_sums_naive(fmpz * res, const fmpz * poly, slong len, slong n) + void _fmpz_poly_power_sums_naive(fmpz * res, const fmpz * poly, slong len, slong n) noexcept # Compute the (truncated) power sums series of the monic polynomial # ``(poly,len)`` up to length `n` using Newton identities. - void fmpz_poly_power_sums_naive(fmpz_poly_t res, const fmpz_poly_t poly, slong n) + void fmpz_poly_power_sums_naive(fmpz_poly_t res, const fmpz_poly_t poly, slong n) noexcept # Compute the (truncated) power sum series of the monic polynomial # ``poly`` up to length `n` using Newton identities. - void fmpz_poly_power_sums(fmpz_poly_t res, const fmpz_poly_t poly, slong n) + void fmpz_poly_power_sums(fmpz_poly_t res, const fmpz_poly_t poly, slong n) noexcept # Compute the (truncated) power sums series of the monic polynomial ``poly`` # up to length `n`. That is the power series whose coefficient of degree `i` is # the sum of the `i`-th power of all (complex) roots of the polynomial # ``poly``. - void _fmpz_poly_power_sums_to_poly(fmpz * res, const fmpz * poly, slong len) + void _fmpz_poly_power_sums_to_poly(fmpz * res, const fmpz * poly, slong len) noexcept # Compute the (monic) polynomial given by its power sums series ``(poly,len)``. - void fmpz_poly_power_sums_to_poly(fmpz_poly_t res, const fmpz_poly_t Q) + void fmpz_poly_power_sums_to_poly(fmpz_poly_t res, const fmpz_poly_t Q) noexcept # Compute the (monic) polynomial given its power sums series ``(Q)``. - void _fmpz_poly_signature(slong * r1, slong * r2, const fmpz * poly, slong len) + void _fmpz_poly_signature(slong * r1, slong * r2, const fmpz * poly, slong len) noexcept # Computes the signature `(r_1, r_2)` of the polynomial # ``(poly, len)``. Assumes that the polynomial is squarefree over `\mathbb{Q}`. - void fmpz_poly_signature(slong * r1, slong * r2, const fmpz_poly_t poly) + void fmpz_poly_signature(slong * r1, slong * r2, const fmpz_poly_t poly) noexcept # Computes the signature `(r_1, r_2)` of the polynomial ``poly``, # which is assumed to be square-free over `\mathbb{Q}`. The values of `r_1` and # `2 r_2` are the number of real and complex roots of the polynomial, @@ -2045,7 +2045,7 @@ cdef extern from "flint_wrap.h": # This function uses the algorithm described # in Algorithm 4.1.11 of [Coh1996]_. - void fmpz_poly_hensel_build_tree(slong * link, fmpz_poly_t *v, fmpz_poly_t *w, const nmod_poly_factor_t fac) + void fmpz_poly_hensel_build_tree(slong * link, fmpz_poly_t *v, fmpz_poly_t *w, const nmod_poly_factor_t fac) noexcept # Initialises and builds a Hensel tree consisting of two arrays `v`, `w` # of polynomials and an array of links, called ``link``. # The caller supplies a set of `r` local factors (in the factor structure @@ -2075,7 +2075,7 @@ cdef extern from "flint_wrap.h": # lift each factor, we have to lift the entire tree and the tree of # XGCD cofactors. - void fmpz_poly_hensel_lift(fmpz_poly_t G, fmpz_poly_t H, fmpz_poly_t A, fmpz_poly_t B, const fmpz_poly_t f, const fmpz_poly_t g, const fmpz_poly_t h, const fmpz_poly_t a, const fmpz_poly_t b, const fmpz_t p, const fmpz_t p1) + void fmpz_poly_hensel_lift(fmpz_poly_t G, fmpz_poly_t H, fmpz_poly_t A, fmpz_poly_t B, const fmpz_poly_t f, const fmpz_poly_t g, const fmpz_poly_t h, const fmpz_poly_t a, const fmpz_poly_t b, const fmpz_t p, const fmpz_t p1) noexcept # This is the main Hensel lifting routine, which performs a Hensel step # from polynomials mod `p` to polynomials mod `P = p p_1`. One starts with # polynomials `f`, `g`, `h` such that `f = gh \pmod p`. The polynomials @@ -2094,17 +2094,17 @@ cdef extern from "flint_wrap.h": # The output arguments `G, H, A, B` may only be aliased with # the input arguments `g, h, a, b`, respectively. - void fmpz_poly_hensel_lift_without_inverse(fmpz_poly_t Gout, fmpz_poly_t Hout, const fmpz_poly_t f, const fmpz_poly_t g, const fmpz_poly_t h, const fmpz_poly_t a, const fmpz_poly_t b, const fmpz_t p, const fmpz_t p1) + void fmpz_poly_hensel_lift_without_inverse(fmpz_poly_t Gout, fmpz_poly_t Hout, const fmpz_poly_t f, const fmpz_poly_t g, const fmpz_poly_t h, const fmpz_poly_t a, const fmpz_poly_t b, const fmpz_t p, const fmpz_t p1) noexcept # Given polynomials such that `f = gh \pmod p` and `ag + bh = 1 \pmod p`, # lifts only the factors `g` and `h` modulo `P = p p_1`. # See :func:`fmpz_poly_hensel_lift`. - void fmpz_poly_hensel_lift_only_inverse(fmpz_poly_t Aout, fmpz_poly_t Bout, const fmpz_poly_t G, const fmpz_poly_t H, const fmpz_poly_t a, const fmpz_poly_t b, const fmpz_t p, const fmpz_t p1) + void fmpz_poly_hensel_lift_only_inverse(fmpz_poly_t Aout, fmpz_poly_t Bout, const fmpz_poly_t G, const fmpz_poly_t H, const fmpz_poly_t a, const fmpz_poly_t b, const fmpz_t p, const fmpz_t p1) noexcept # Given polynomials such that `f = gh \pmod p` and `ag + bh = 1 \pmod p`, # lifts only the cofactors `a` and `b` modulo `P = p p_1`. # See :func:`fmpz_poly_hensel_lift`. - void fmpz_poly_hensel_lift_tree_recursive(slong *link, fmpz_poly_t *v, fmpz_poly_t *w, fmpz_poly_t f, slong j, slong inv, const fmpz_t p0, const fmpz_t p1) + void fmpz_poly_hensel_lift_tree_recursive(slong *link, fmpz_poly_t *v, fmpz_poly_t *w, fmpz_poly_t f, slong j, slong inv, const fmpz_t p0, const fmpz_t p1) noexcept # Takes a current Hensel tree ``(link, v, w)`` and a pair `(j,j+1)` # of entries in the tree and lifts the tree from mod `p_0` to # mod `P = p_0 p_1`, where `1 < p_1 \leq p_0`. @@ -2117,7 +2117,7 @@ cdef extern from "flint_wrap.h": # the lists `v` and `w`. But the polynomials in these two lists # are not allowed to be aliases of each other. - void fmpz_poly_hensel_lift_tree(slong *link, fmpz_poly_t *v, fmpz_poly_t *w, fmpz_poly_t f, slong r, const fmpz_t p, slong e0, slong e1, slong inv) + void fmpz_poly_hensel_lift_tree(slong *link, fmpz_poly_t *v, fmpz_poly_t *w, fmpz_poly_t f, slong r, const fmpz_t p, slong e0, slong e1, slong inv) noexcept # Computes `p_0 = p^{e_0}` and `p_1 = p^{e_1 - e_0}` for a small prime `p` # and `P = p^{e_1}`. # If we aim to lift to `p^b` then `f` is the polynomial whose factors we @@ -2132,7 +2132,7 @@ cdef extern from "flint_wrap.h": # Assumes that `f` is monic. # Assumes that `1 < p_1 \leq p_0`, that is, `0 < e_1 \leq e_0`. - slong _fmpz_poly_hensel_start_lift(fmpz_poly_factor_t lifted_fac, slong *link, fmpz_poly_t *v, fmpz_poly_t *w, const fmpz_poly_t f, const nmod_poly_factor_t local_fac, slong N) + slong _fmpz_poly_hensel_start_lift(fmpz_poly_factor_t lifted_fac, slong *link, fmpz_poly_t *v, fmpz_poly_t *w, const fmpz_poly_t f, const nmod_poly_factor_t local_fac, slong N) noexcept # This function takes the local factors in ``local_fac`` # and Hensel lifts them until they are known mod `p^N`, where # `N \geq 1`. @@ -2150,7 +2150,7 @@ cdef extern from "flint_wrap.h": # over the local factors and convert them to polynomials over # `\mathbf{Z}`. - slong _fmpz_poly_hensel_continue_lift(fmpz_poly_factor_t lifted_fac, slong *link, fmpz_poly_t *v, fmpz_poly_t *w, const fmpz_poly_t f, slong prev, slong curr, slong N, const fmpz_t p) + slong _fmpz_poly_hensel_continue_lift(fmpz_poly_factor_t lifted_fac, slong *link, fmpz_poly_t *v, fmpz_poly_t *w, const fmpz_poly_t f, slong prev, slong curr, slong N, const fmpz_t p) noexcept # This function restarts a stopped Hensel lift. # It lifts from ``curr`` to `N`. It also requires ``prev`` # (to lift the cofactors) given as the return value of the function @@ -2164,74 +2164,74 @@ cdef extern from "flint_wrap.h": # Currently, supports the case when ``prev`` and ``curr`` # are equal. - void fmpz_poly_hensel_lift_once(fmpz_poly_factor_t lifted_fac, const fmpz_poly_t f, const nmod_poly_factor_t local_fac, slong N) + void fmpz_poly_hensel_lift_once(fmpz_poly_factor_t lifted_fac, const fmpz_poly_t f, const nmod_poly_factor_t local_fac, slong N) noexcept # This function does a Hensel lift. # It lifts local factors stored in ``local_fac`` of `f` to `p^N`, # where `N \geq 2`. The lifted factors will be stored in ``lifted_fac``. # This lift cannot be restarted. This function is a convenience function # intended for end users. The product of local factors must be squarefree. - int _fmpz_poly_print(const fmpz * poly, slong len) + int _fmpz_poly_print(const fmpz * poly, slong len) noexcept # Prints the polynomial ``(poly, len)`` to ``stdout``. # In case of success, returns a positive value. In case of failure, # returns a non-positive value. - int fmpz_poly_print(const fmpz_poly_t poly) + int fmpz_poly_print(const fmpz_poly_t poly) noexcept # Prints the polynomial to ``stdout``. # In case of success, returns a positive value. In case of failure, # returns a non-positive value. - int _fmpz_poly_print_pretty(const fmpz * poly, slong len, const char * x) + int _fmpz_poly_print_pretty(const fmpz * poly, slong len, const char * x) noexcept # Prints the pretty representation of ``(poly, len)`` to ``stdout``, # using the string ``x`` to represent the indeterminate. # In case of success, returns a positive value. In case of failure, # returns a non-positive value. - int fmpz_poly_print_pretty(const fmpz_poly_t poly, const char * x) + int fmpz_poly_print_pretty(const fmpz_poly_t poly, const char * x) noexcept # Prints the pretty representation of ``poly`` to ``stdout``, # using the string ``x`` to represent the indeterminate. # In case of success, returns a positive value. In case of failure, # returns a non-positive value. - int _fmpz_poly_fprint(FILE * file, const fmpz * poly, slong len) + int _fmpz_poly_fprint(FILE * file, const fmpz * poly, slong len) noexcept # Prints the polynomial ``(poly, len)`` to the stream ``file``. # In case of success, returns a positive value. In case of failure, # returns a non-positive value. - int fmpz_poly_fprint(FILE * file, const fmpz_poly_t poly) + int fmpz_poly_fprint(FILE * file, const fmpz_poly_t poly) noexcept # Prints the polynomial to the stream ``file``. # In case of success, returns a positive value. In case of failure, # returns a non-positive value. - int _fmpz_poly_fprint_pretty(FILE * file, const fmpz * poly, slong len, const char * x) + int _fmpz_poly_fprint_pretty(FILE * file, const fmpz * poly, slong len, const char * x) noexcept # Prints the pretty representation of ``(poly, len)`` to the stream # ``file``, using the string ``x`` to represent the indeterminate. # In case of success, returns a positive value. In case of failure, # returns a non-positive value. - int fmpz_poly_fprint_pretty(FILE * file, const fmpz_poly_t poly, const char * x) + int fmpz_poly_fprint_pretty(FILE * file, const fmpz_poly_t poly, const char * x) noexcept # Prints the pretty representation of ``poly`` to the stream ``file``, # using the string ``x`` to represent the indeterminate. # In case of success, returns a positive value. In case of failure, # returns a non-positive value. - int fmpz_poly_read(fmpz_poly_t poly) + int fmpz_poly_read(fmpz_poly_t poly) noexcept # Reads a polynomial from ``stdin``, storing the result in ``poly``. # In case of success, returns a positive number. In case of failure, # returns a non-positive value. - int fmpz_poly_read_pretty(fmpz_poly_t poly, char **x) + int fmpz_poly_read_pretty(fmpz_poly_t poly, char **x) noexcept # Reads a polynomial in pretty format from ``stdin``. # For further details, see the documentation for the function # :func:`fmpz_poly_fread_pretty`. - int fmpz_poly_fread(FILE * file, fmpz_poly_t poly) + int fmpz_poly_fread(FILE * file, fmpz_poly_t poly) noexcept # Reads a polynomial from the stream ``file``, storing the result # in ``poly``. # In case of success, returns a positive number. In case of failure, # returns a non-positive value. - int fmpz_poly_fread_pretty(FILE *file, fmpz_poly_t poly, char **x) + int fmpz_poly_fread_pretty(FILE *file, fmpz_poly_t poly, char **x) noexcept # Reads a polynomial from the file ``file`` and sets ``poly`` # to this polynomial. The string ``*x`` is set to the variable # name that is used in the input. @@ -2240,19 +2240,19 @@ cdef extern from "flint_wrap.h": # failure, which could either be a read error or the indicator of a # malformed input. - void fmpz_poly_get_nmod_poly(nmod_poly_t Amod, const fmpz_poly_t A) + void fmpz_poly_get_nmod_poly(nmod_poly_t Amod, const fmpz_poly_t A) noexcept # Sets the coefficients of ``Amod`` to the coefficients in ``A``, # reduced by the modulus of ``Amod``. - void fmpz_poly_set_nmod_poly(fmpz_poly_t A, const nmod_poly_t Amod) + void fmpz_poly_set_nmod_poly(fmpz_poly_t A, const nmod_poly_t Amod) noexcept # Sets the coefficients of ``A`` to the residues in ``Amod``, # normalised to the interval `-m/2 \le r < m/2` where `m` is the modulus. - void fmpz_poly_set_nmod_poly_unsigned(fmpz_poly_t A, const nmod_poly_t Amod) + void fmpz_poly_set_nmod_poly_unsigned(fmpz_poly_t A, const nmod_poly_t Amod) noexcept # Sets the coefficients of ``A`` to the residues in ``Amod``, # normalised to the interval `0 \le r < m` where `m` is the modulus. - void _fmpz_poly_CRT_ui_precomp(fmpz * res, const fmpz * poly1, slong len1, const fmpz_t m1, mp_srcptr poly2, slong len2, mp_limb_t m2, mp_limb_t m2inv, fmpz_t m1m2, mp_limb_t c, int sign) + void _fmpz_poly_CRT_ui_precomp(fmpz * res, const fmpz * poly1, slong len1, const fmpz_t m1, mp_srcptr poly2, slong len2, mp_limb_t m2, mp_limb_t m2inv, fmpz_t m1m2, mp_limb_t c, int sign) noexcept # Sets the coefficients in ``res`` to the CRT reconstruction modulo # `m_1m_2` of the residues ``(poly1, len1)`` and ``(poly2, len2)`` # which are images modulo `m_1` and `m_2` respectively. @@ -2265,40 +2265,40 @@ cdef extern from "flint_wrap.h": # Coefficients of ``res`` are written up to the maximum of # ``len1`` and ``len2``. - void _fmpz_poly_CRT_ui(fmpz * res, const fmpz * poly1, slong len1, const fmpz_t m1, mp_srcptr poly2, slong len2, mp_limb_t m2, mp_limb_t m2inv, int sign) + void _fmpz_poly_CRT_ui(fmpz * res, const fmpz * poly1, slong len1, const fmpz_t m1, mp_srcptr poly2, slong len2, mp_limb_t m2, mp_limb_t m2inv, int sign) noexcept # This function is identical to ``_fmpz_poly_CRT_ui_precomp``, # apart from automatically computing `m_1m_2` and `c`. It also # aborts if `c` cannot be computed. - void fmpz_poly_CRT_ui(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_t m, const nmod_poly_t poly2, int sign) + void fmpz_poly_CRT_ui(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_t m, const nmod_poly_t poly2, int sign) noexcept # Given ``poly1`` with coefficients modulo ``m`` and ``poly2`` # with modulus `n`, sets ``res`` to the CRT reconstruction modulo `mn` # with coefficients satisfying `-mn/2 \le c < mn/2` (if sign = 1) # or `0 \le c < mn` (if sign = 0). - void _fmpz_poly_product_roots_fmpz_vec(fmpz * poly, const fmpz * xs, slong n) + void _fmpz_poly_product_roots_fmpz_vec(fmpz * poly, const fmpz * xs, slong n) noexcept # Sets ``(poly, n + 1)`` to the monic polynomial which is the product # of `(x - x_0)(x - x_1) \cdots (x - x_{n-1})`, the roots `x_i` being # given by ``xs``. # Aliasing of the input and output is not allowed. - void fmpz_poly_product_roots_fmpz_vec(fmpz_poly_t poly, const fmpz * xs, slong n) + void fmpz_poly_product_roots_fmpz_vec(fmpz_poly_t poly, const fmpz * xs, slong n) noexcept # Sets ``poly`` to the monic polynomial which is the product # of `(x - x_0)(x - x_1) \cdots (x - x_{n-1})`, the roots `x_i` being # given by ``xs``. - void _fmpz_poly_product_roots_fmpq_vec(fmpz * poly, const fmpq * xs, slong n) + void _fmpz_poly_product_roots_fmpq_vec(fmpz * poly, const fmpq * xs, slong n) noexcept # Sets ``(poly, n + 1)`` to the product of # `(q_0 x - p_0)(q_1 x - p_1) \cdots (q_{n-1} x - p_{n-1})`, the roots # `p_i/q_i` being given by ``xs``. - void fmpz_poly_product_roots_fmpq_vec(fmpz_poly_t poly, const fmpq * xs, slong n) + void fmpz_poly_product_roots_fmpq_vec(fmpz_poly_t poly, const fmpq * xs, slong n) noexcept # Sets ``poly`` to the polynomial which is the product # of `(q_0 x - p_0)(q_1 x - p_1) \cdots (q_{n-1} x - p_{n-1})`, the roots # `p_i/q_i` being given by ``xs``. - void _fmpz_poly_bound_roots(fmpz_t bound, const fmpz * poly, slong len) - void fmpz_poly_bound_roots(fmpz_t bound, const fmpz_poly_t poly) + void _fmpz_poly_bound_roots(fmpz_t bound, const fmpz * poly, slong len) noexcept + void fmpz_poly_bound_roots(fmpz_t bound, const fmpz_poly_t poly) noexcept # Computes a nonnegative integer ``bound`` that bounds the absolute # value of all complex roots of ``poly``. Uses Fujiwara's bound # .. math :: @@ -2310,7 +2310,7 @@ cdef extern from "flint_wrap.h": # \right) # where the coefficients of the polynomial are `a_0, \ldots, a_n`. - void _fmpz_poly_num_real_roots_sturm(slong * n_neg, slong * n_pos, const fmpz * pol, slong len) + void _fmpz_poly_num_real_roots_sturm(slong * n_neg, slong * n_pos, const fmpz * pol, slong len) noexcept # Sets ``n_neg`` and ``n_pos`` to the number of negative and # positive roots of the polynomial ``(pol, len)`` using Sturm # sequence. The Sturm sequence is computed via subresultant @@ -2319,21 +2319,21 @@ cdef extern from "flint_wrap.h": # The polynomial is assumed to be squarefree, of degree larger than 1 # and with non-zero constant coefficient. - slong fmpz_poly_num_real_roots_sturm(const fmpz_poly_t pol) + slong fmpz_poly_num_real_roots_sturm(const fmpz_poly_t pol) noexcept # Returns the number of real roots of the squarefree polynomial ``pol`` # using Sturm sequence. # The polynomial is assumed to be squarefree. - slong _fmpz_poly_num_real_roots(const fmpz * pol, slong len) + slong _fmpz_poly_num_real_roots(const fmpz * pol, slong len) noexcept # Returns the number of real roots of the squarefree polynomial # ``(pol, len)``. # The polynomial is assumed to be squarefree. - slong fmpz_poly_num_real_roots(const fmpz_poly_t pol) + slong fmpz_poly_num_real_roots(const fmpz_poly_t pol) noexcept # Returns the number of real roots of the squarefree polynomial ``pol``. # The polynomial is assumed to be squarefree. - void _fmpz_poly_cyclotomic(fmpz * a, ulong n, mp_ptr factors, slong num_factors, ulong phi) + void _fmpz_poly_cyclotomic(fmpz * a, ulong n, mp_ptr factors, slong num_factors, ulong phi) noexcept # Sets ``a`` to the lower half of the cyclotomic polynomial `\Phi_n(x)`, # given `n \ge 3` which must be squarefree. # A precomputed array containing the prime factors of `n` must be provided, @@ -2366,21 +2366,21 @@ cdef extern from "flint_wrap.h": # and if `n = 2m`, we use `\Phi_n(x) = \Phi_m(-x)` to fall back # to the case when `n` is odd. - void fmpz_poly_cyclotomic(fmpz_poly_t poly, ulong n) + void fmpz_poly_cyclotomic(fmpz_poly_t poly, ulong n) noexcept # Sets ``poly`` to the `n`-th cyclotomic polynomial, defined as # `\Phi_n(x) = \prod_{\omega} (x-\omega)` # where `\omega` runs over all the `n`-th primitive roots of unity. # We factor `n` into `n = qs` where `q` is squarefree, # and compute `\Phi_q(x)`. Then `\Phi_n(x) = \Phi_q(x^s)`. - ulong _fmpz_poly_is_cyclotomic(const fmpz * poly, slong len) - ulong fmpz_poly_is_cyclotomic(const fmpz_poly_t poly) + ulong _fmpz_poly_is_cyclotomic(const fmpz * poly, slong len) noexcept + ulong fmpz_poly_is_cyclotomic(const fmpz_poly_t poly) noexcept # If ``poly`` is a cyclotomic polynomial, returns the index `n` of this # cyclotomic polynomial. If ``poly`` is not a cyclotomic polynomial, # returns 0. - void _fmpz_poly_cos_minpoly(fmpz * coeffs, ulong n) - void fmpz_poly_cos_minpoly(fmpz_poly_t poly, ulong n) + void _fmpz_poly_cos_minpoly(fmpz * coeffs, ulong n) noexcept + void fmpz_poly_cos_minpoly(fmpz_poly_t poly, ulong n) noexcept # Sets ``poly`` to the minimal polynomial of `2 \cos(2 \pi / n)`. # For suitable choice of `n`, this gives the minimal polynomial # of `2 \cos(a \pi)` or `2 \sin(a \pi)` for any rational `a`. @@ -2393,8 +2393,8 @@ cdef extern from "flint_wrap.h": # the output to be the constant polynomial 1. # See [WaktinsZeitlin1993]_. - void _fmpz_poly_swinnerton_dyer(fmpz * coeffs, ulong n) - void fmpz_poly_swinnerton_dyer(fmpz_poly_t poly, ulong n) + void _fmpz_poly_swinnerton_dyer(fmpz * coeffs, ulong n) noexcept + void fmpz_poly_swinnerton_dyer(fmpz_poly_t poly, ulong n) noexcept # Sets ``poly`` to the Swinnerton-Dyer polynomial `S_n`, defined as # the integer polynomial # `S_n = \prod (x \pm \sqrt{2} \pm \sqrt{3} \pm \sqrt{5} \pm \ldots \pm \sqrt{p_n})` @@ -2403,68 +2403,68 @@ cdef extern from "flint_wrap.h": # irreducible over the integers (it is the minimal polynomial # of `\sqrt{2} + \ldots + \sqrt{p_n}`). - void _fmpz_poly_chebyshev_t(fmpz * coeffs, ulong n) - void fmpz_poly_chebyshev_t(fmpz_poly_t poly, ulong n) + void _fmpz_poly_chebyshev_t(fmpz * coeffs, ulong n) noexcept + void fmpz_poly_chebyshev_t(fmpz_poly_t poly, ulong n) noexcept # Sets ``poly`` to the Chebyshev polynomial of the first kind `T_n(x)`, # defined by `T_n(x) = \cos(n \cos^{-1}(x))`, for `n\ge0`. The coefficients are # calculated using a hypergeometric recurrence. - void _fmpz_poly_chebyshev_u(fmpz * coeffs, ulong n) - void fmpz_poly_chebyshev_u(fmpz_poly_t poly, ulong n) + void _fmpz_poly_chebyshev_u(fmpz * coeffs, ulong n) noexcept + void fmpz_poly_chebyshev_u(fmpz_poly_t poly, ulong n) noexcept # Sets ``poly`` to the Chebyshev polynomial of the first kind `U_n(x)`, # defined by `(n+1) U_n(x) = T'_{n+1}(x)`, for `n\ge0`. # The coefficients are calculated using a hypergeometric recurrence. - void _fmpz_poly_legendre_pt(fmpz * coeffs, ulong n) + void _fmpz_poly_legendre_pt(fmpz * coeffs, ulong n) noexcept # Sets ``coeffs`` to the coefficient array of the shifted Legendre # polynomial `\tilde{P_n}(x)`, defined by `\tilde{P_n}(x) = P_n(2x-1)`, for `n\ge0`. # The coefficients are calculated using a hypergeometric recurrence. # The length of the array will be ``n+1``. # See ``fmpq_poly`` for the Legendre polynomials. - void fmpz_poly_legendre_pt(fmpz_poly_t poly, ulong n) + void fmpz_poly_legendre_pt(fmpz_poly_t poly, ulong n) noexcept # Sets ``poly`` to the shifted Legendre polynomial `\tilde{P_n}(x)`, # defined by `\tilde{P_n}(x) = P_n(2x-1)`, for `n\ge0`. The coefficients are # calculated using a hypergeometric recurrence. See ``fmpq_poly`` # for the Legendre polynomials. - void _fmpz_poly_hermite_h(fmpz * coeffs, ulong n) + void _fmpz_poly_hermite_h(fmpz * coeffs, ulong n) noexcept # Sets ``coeffs`` to the coefficient array of the Hermite # polynomial `H_n(x)`, defined by `H'_n(x) = 2nH_{n-1}(x)`, for `n\ge0`. # The coefficients are calculated using a hypergeometric recurrence. # The length of the array will be ``n+1``. - void fmpz_poly_hermite_h(fmpz_poly_t poly, ulong n) + void fmpz_poly_hermite_h(fmpz_poly_t poly, ulong n) noexcept # Sets ``poly`` to the Hermite polynomial `H_n(x)`, # defined by `H'_n(x) = 2nH_{n-1}(x)`, for `n\ge0`. The coefficients are # calculated using a hypergeometric recurrence. - void _fmpz_poly_hermite_he(fmpz * coeffs, ulong n) + void _fmpz_poly_hermite_he(fmpz * coeffs, ulong n) noexcept # Sets ``coeffs`` to the coefficient array of the Hermite # polynomial `He_n(x)`, defined by # `He_n(x) = 2^{-\tfrac{n}{2}}H_n\left(\frac{x}{\sqrt2}\right)`, for `n\ge0`. # The coefficients are calculated using a hypergeometric recurrence. # The length of the array will be ``n+1``. - void fmpz_poly_hermite_he(fmpz_poly_t poly, ulong n) + void fmpz_poly_hermite_he(fmpz_poly_t poly, ulong n) noexcept # Sets ``poly`` to the Hermite polynomial `He_n(x)`, # defined by `He_n(x) = 2^{-\tfrac{n}{2}}H_n\left(\frac{x}{\sqrt2}\right)`, for `n\ge0`. # The coefficients are calculated using a hypergeometric recurrence. - void _fmpz_poly_fibonacci(fmpz * coeffs, ulong n) + void _fmpz_poly_fibonacci(fmpz * coeffs, ulong n) noexcept # Sets ``coeffs`` to the coefficient array of the `n`-th Fibonacci polynomial. # The coefficients are calculated using a hypergeometric recurrence. - void fmpz_poly_fibonacci(fmpz_poly_t poly, ulong n) + void fmpz_poly_fibonacci(fmpz_poly_t poly, ulong n) noexcept # Sets ``poly`` to the `n`-th Fibonacci polynomial. # The coefficients are calculated using a hypergeometric recurrence. - void arith_eulerian_polynomial(fmpz_poly_t res, ulong n) + void arith_eulerian_polynomial(fmpz_poly_t res, ulong n) noexcept # Sets ``res`` to the Eulerian polynomial `A_n(x)`, where we define # `A_0(x) = 1`. The polynomial is calculated via a recursive relation. - void _fmpz_poly_eta_qexp(fmpz * f, slong r, slong len) - void fmpz_poly_eta_qexp(fmpz_poly_t f, slong r, slong n) + void _fmpz_poly_eta_qexp(fmpz * f, slong r, slong len) noexcept + void fmpz_poly_eta_qexp(fmpz_poly_t f, slong r, slong n) noexcept # Sets `f` to the `q`-expansion to length `n` of the # Dedekind eta function (without the leading factor # `q^{1/24}`) raised to the power `r`, i.e. @@ -2477,15 +2477,15 @@ cdef extern from "flint_wrap.h": # This function uses sparse formulas for `r = 1, 2, 3, 4, 6` # and otherwise reduces to one of those cases using power series arithmetic. - void _fmpz_poly_theta_qexp(fmpz * f, slong r, slong len) - void fmpz_poly_theta_qexp(fmpz_poly_t f, slong r, slong n) + void _fmpz_poly_theta_qexp(fmpz * f, slong r, slong len) noexcept + void fmpz_poly_theta_qexp(fmpz_poly_t f, slong r, slong n) noexcept # Sets `f` to the `q`-expansion to length `n` of the # Jacobi theta function raised to the power `r`, i.e. `\vartheta(q)^r` # where `\vartheta(q) = 1 + 2 \sum_{k=1}^{\infty} q^{k^2}`. # This function uses sparse formulas for `r = 1, 2` # and otherwise reduces to those cases using power series arithmetic. - void fmpz_poly_CLD_bound(fmpz_t res, const fmpz_poly_t f, slong n) + void fmpz_poly_CLD_bound(fmpz_t res, const fmpz_poly_t f, slong n) noexcept # Compute a bound on the `n` coefficient of `fg'/g` where `g` is any # factor of `f`. diff --git a/src/sage/libs/flint/fmpz_poly_factor.pxd b/src/sage/libs/flint/fmpz_poly_factor.pxd index f5c2e97e5b5..1bed31a327a 100644 --- a/src/sage/libs/flint/fmpz_poly_factor.pxd +++ b/src/sage/libs/flint/fmpz_poly_factor.pxd @@ -12,43 +12,43 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void fmpz_poly_factor_init(fmpz_poly_factor_t fac) + void fmpz_poly_factor_init(fmpz_poly_factor_t fac) noexcept # Initialises a new factor structure. - void fmpz_poly_factor_init2(fmpz_poly_factor_t fac, slong alloc) + void fmpz_poly_factor_init2(fmpz_poly_factor_t fac, slong alloc) noexcept # Initialises a new factor structure, providing space for # at least ``alloc`` factors. - void fmpz_poly_factor_realloc(fmpz_poly_factor_t fac, slong alloc) + void fmpz_poly_factor_realloc(fmpz_poly_factor_t fac, slong alloc) noexcept # Reallocates the factor structure to provide space for # precisely ``alloc`` factors. - void fmpz_poly_factor_fit_length(fmpz_poly_factor_t fac, slong len) + void fmpz_poly_factor_fit_length(fmpz_poly_factor_t fac, slong len) noexcept # Ensures that the factor structure has space for at # least ``len`` factors. This functions takes care # of the case of repeated calls by always at least # doubling the number of factors the structure can hold. - void fmpz_poly_factor_clear(fmpz_poly_factor_t fac) + void fmpz_poly_factor_clear(fmpz_poly_factor_t fac) noexcept # Releases all memory occupied by the factor structure. - void fmpz_poly_factor_set(fmpz_poly_factor_t res, const fmpz_poly_factor_t fac) + void fmpz_poly_factor_set(fmpz_poly_factor_t res, const fmpz_poly_factor_t fac) noexcept # Sets ``res`` to the same factorisation as ``fac``. - void fmpz_poly_factor_insert(fmpz_poly_factor_t fac, const fmpz_poly_t p, slong e) + void fmpz_poly_factor_insert(fmpz_poly_factor_t fac, const fmpz_poly_t p, slong e) noexcept # Adds the primitive polynomial `p^e` to the factorisation ``fac``. # Assumes that `\deg(p) \geq 2` and `e \neq 0`. - void fmpz_poly_factor_concat(fmpz_poly_factor_t res, const fmpz_poly_factor_t fac) + void fmpz_poly_factor_concat(fmpz_poly_factor_t res, const fmpz_poly_factor_t fac) noexcept # Concatenates two factorisations. # This is equivalent to calling :func:`fmpz_poly_factor_insert` # repeatedly with the individual factors of ``fac``. # Does not support aliasing between ``res`` and ``fac``. - void fmpz_poly_factor_print(const fmpz_poly_factor_t fac) + void fmpz_poly_factor_print(const fmpz_poly_factor_t fac) noexcept # Prints the entries of ``fac`` to standard output. - void fmpz_poly_factor_squarefree(fmpz_poly_factor_t fac, const fmpz_poly_t F) + void fmpz_poly_factor_squarefree(fmpz_poly_factor_t fac, const fmpz_poly_t F) noexcept # Takes as input a polynomial `F` and a freshly initialized factor # structure ``fac``. Updates ``fac`` to contain a factorization # of `F` into (not necessarily irreducible) factors that themselves @@ -58,7 +58,7 @@ cdef extern from "flint_wrap.h": # F = c \prod_{i} g_i^{e_i} # where `c` is the signed content of `F` and `\gcd(g_i, g_i') = 1`. - void fmpz_poly_factor_zassenhaus_recombination(fmpz_poly_factor_t final_fac, const fmpz_poly_factor_t lifted_fac, const fmpz_poly_t F, const fmpz_t P, slong exp) + void fmpz_poly_factor_zassenhaus_recombination(fmpz_poly_factor_t final_fac, const fmpz_poly_factor_t lifted_fac, const fmpz_poly_t F, const fmpz_t P, slong exp) noexcept # Takes as input a factor structure ``lifted_fac`` containing a # squarefree factorization of the polynomial `F \bmod p`. The algorithm # does a brute force search for irreducible factors of `F` over the @@ -66,7 +66,7 @@ cdef extern from "flint_wrap.h": # The impact of the algorithm is to augment a factorization of # ``F^exp`` to the factor structure ``final_fac``. - void _fmpz_poly_factor_zassenhaus(fmpz_poly_factor_t final_fac, slong exp, const fmpz_poly_t f, slong cutoff, int use_van_hoeij) + void _fmpz_poly_factor_zassenhaus(fmpz_poly_factor_t final_fac, slong exp, const fmpz_poly_t f, slong cutoff, int use_van_hoeij) noexcept # This is the internal wrapper of Zassenhaus. # It will attempt to find a small prime such that `f` modulo `p` has # a minimal number of factors. If it cannot find a prime giving less @@ -82,20 +82,20 @@ cdef extern from "flint_wrap.h": # algorithm with gradual feeding and mod `2^k` data truncation to find # factors when the number of local factors is large. - void fmpz_poly_factor_zassenhaus(fmpz_poly_factor_t final_fac, const fmpz_poly_t F) + void fmpz_poly_factor_zassenhaus(fmpz_poly_factor_t final_fac, const fmpz_poly_t F) noexcept # A wrapper of the Zassenhaus factoring algorithm, which takes as input # any polynomial `F`, and stores a factorization in ``final_fac``. # The complexity will be exponential in the number of local factors # we find for the components of a squarefree factorization of `F`. - void _fmpz_poly_factor_quadratic(fmpz_poly_factor_t fac, const fmpz_poly_t f, slong exp) - void _fmpz_poly_factor_cubic(fmpz_poly_factor_t fac, const fmpz_poly_t f, slong exp) + void _fmpz_poly_factor_quadratic(fmpz_poly_factor_t fac, const fmpz_poly_t f, slong exp) noexcept + void _fmpz_poly_factor_cubic(fmpz_poly_factor_t fac, const fmpz_poly_t f, slong exp) noexcept # Inserts the factorisation of the quadratic (resp. cubic) polynomial *f* into *fac* with # multiplicity *exp*. This function requires that the content of *f* has # been removed, and does not update the content of *fac*. # The factorization is calculated over `\mathbb{R}` or `\mathbb{Q}_2` and then tested over `\mathbb{Z}`. - void fmpz_poly_factor(fmpz_poly_factor_t final_fac, const fmpz_poly_t F) + void fmpz_poly_factor(fmpz_poly_factor_t final_fac, const fmpz_poly_t F) noexcept # A wrapper of the Zassenhaus and van Hoeij factoring algorithms, which takes # as input any polynomial `F`, and stores a factorization in # ``final_fac``. diff --git a/src/sage/libs/flint/fmpz_poly_mat.pxd b/src/sage/libs/flint/fmpz_poly_mat.pxd index a1972258fc1..92d5ae38a0d 100644 --- a/src/sage/libs/flint/fmpz_poly_mat.pxd +++ b/src/sage/libs/flint/fmpz_poly_mat.pxd @@ -12,177 +12,177 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void fmpz_poly_mat_init(fmpz_poly_mat_t mat, slong rows, slong cols) + void fmpz_poly_mat_init(fmpz_poly_mat_t mat, slong rows, slong cols) noexcept # Initialises a matrix with the given number of rows and columns for use. - void fmpz_poly_mat_init_set(fmpz_poly_mat_t mat, const fmpz_poly_mat_t src) + void fmpz_poly_mat_init_set(fmpz_poly_mat_t mat, const fmpz_poly_mat_t src) noexcept # Initialises a matrix ``mat`` of the same dimensions as ``src``, # and sets it to a copy of ``src``. - void fmpz_poly_mat_clear(fmpz_poly_mat_t mat) + void fmpz_poly_mat_clear(fmpz_poly_mat_t mat) noexcept # Frees all memory associated with the matrix. The matrix must be # reinitialised if it is to be used again. - slong fmpz_poly_mat_nrows(const fmpz_poly_mat_t mat) + slong fmpz_poly_mat_nrows(const fmpz_poly_mat_t mat) noexcept # Returns the number of rows in ``mat``. - slong fmpz_poly_mat_ncols(const fmpz_poly_mat_t mat) + slong fmpz_poly_mat_ncols(const fmpz_poly_mat_t mat) noexcept # Returns the number of columns in ``mat``. - fmpz_poly_struct * fmpz_poly_mat_entry(const fmpz_poly_mat_t mat, slong i, slong j) + fmpz_poly_struct * fmpz_poly_mat_entry(const fmpz_poly_mat_t mat, slong i, slong j) noexcept # Gives a reference to the entry at row ``i`` and column ``j``. # The reference can be passed as an input or output variable to any # ``fmpz_poly`` function for direct manipulation of the matrix element. # No bounds checking is performed. - void fmpz_poly_mat_set(fmpz_poly_mat_t mat1, const fmpz_poly_mat_t mat2) + void fmpz_poly_mat_set(fmpz_poly_mat_t mat1, const fmpz_poly_mat_t mat2) noexcept # Sets ``mat1`` to a copy of ``mat2``. - void fmpz_poly_mat_swap(fmpz_poly_mat_t mat1, fmpz_poly_mat_t mat2) + void fmpz_poly_mat_swap(fmpz_poly_mat_t mat1, fmpz_poly_mat_t mat2) noexcept # Swaps ``mat1`` and ``mat2`` efficiently. - void fmpz_poly_mat_swap_entrywise(fmpz_poly_mat_t mat1, fmpz_poly_mat_t mat2) + void fmpz_poly_mat_swap_entrywise(fmpz_poly_mat_t mat1, fmpz_poly_mat_t mat2) noexcept # Swaps two matrices by swapping the individual entries rather than swapping # the contents of the structs. - void fmpz_poly_mat_print(const fmpz_poly_mat_t mat, const char * x) + void fmpz_poly_mat_print(const fmpz_poly_mat_t mat, const char * x) noexcept # Prints the matrix ``mat`` to standard output, using the # variable ``x``. - void fmpz_poly_mat_randtest(fmpz_poly_mat_t mat, flint_rand_t state, slong len, flint_bitcnt_t bits) + void fmpz_poly_mat_randtest(fmpz_poly_mat_t mat, flint_rand_t state, slong len, flint_bitcnt_t bits) noexcept # This is equivalent to applying ``fmpz_poly_randtest`` to all entries # in the matrix. - void fmpz_poly_mat_randtest_unsigned(fmpz_poly_mat_t mat, flint_rand_t state, slong len, flint_bitcnt_t bits) + void fmpz_poly_mat_randtest_unsigned(fmpz_poly_mat_t mat, flint_rand_t state, slong len, flint_bitcnt_t bits) noexcept # This is equivalent to applying ``fmpz_poly_randtest_unsigned`` to # all entries in the matrix. - void fmpz_poly_mat_randtest_sparse(fmpz_poly_mat_t A, flint_rand_t state, slong len, flint_bitcnt_t bits, float density) + void fmpz_poly_mat_randtest_sparse(fmpz_poly_mat_t A, flint_rand_t state, slong len, flint_bitcnt_t bits, float density) noexcept # Creates a random matrix with the amount of nonzero entries given # approximately by the ``density`` variable, which should be a fraction # between 0 (most sparse) and 1 (most dense). # The nonzero entries will have random lengths between 1 and ``len``. - void fmpz_poly_mat_zero(fmpz_poly_mat_t mat) + void fmpz_poly_mat_zero(fmpz_poly_mat_t mat) noexcept # Sets ``mat`` to the zero matrix. - void fmpz_poly_mat_one(fmpz_poly_mat_t mat) + void fmpz_poly_mat_one(fmpz_poly_mat_t mat) noexcept # Sets ``mat`` to the unit or identity matrix of given shape, # having the element 1 on the main diagonal and zeros elsewhere. # If ``mat`` is nonsquare, it is set to the truncation of a unit matrix. - bint fmpz_poly_mat_equal(const fmpz_poly_mat_t mat1, const fmpz_poly_mat_t mat2) + bint fmpz_poly_mat_equal(const fmpz_poly_mat_t mat1, const fmpz_poly_mat_t mat2) noexcept # Returns nonzero if ``mat1`` and ``mat2`` have the same shape and # all their entries agree, and returns zero otherwise. - bint fmpz_poly_mat_is_zero(const fmpz_poly_mat_t mat) + bint fmpz_poly_mat_is_zero(const fmpz_poly_mat_t mat) noexcept # Returns nonzero if all entries in ``mat`` are zero, and returns # zero otherwise. - bint fmpz_poly_mat_is_one(const fmpz_poly_mat_t mat) + bint fmpz_poly_mat_is_one(const fmpz_poly_mat_t mat) noexcept # Returns nonzero if all entries of ``mat`` on the main diagonal # are the constant polynomial 1 and all remaining entries are zero, # and returns zero otherwise. The matrix need not be square. - bint fmpz_poly_mat_is_empty(const fmpz_poly_mat_t mat) + bint fmpz_poly_mat_is_empty(const fmpz_poly_mat_t mat) noexcept # Returns a non-zero value if the number of rows or the number of # columns in ``mat`` is zero, and otherwise returns # zero. - bint fmpz_poly_mat_is_square(const fmpz_poly_mat_t mat) + bint fmpz_poly_mat_is_square(const fmpz_poly_mat_t mat) noexcept # Returns a non-zero value if the number of rows is equal to the # number of columns in ``mat``, and otherwise returns zero. - slong fmpz_poly_mat_max_bits(const fmpz_poly_mat_t A) + slong fmpz_poly_mat_max_bits(const fmpz_poly_mat_t A) noexcept # Returns the maximum number of bits among the coefficients of the # entries in ``A``, or the negative of that value if any # coefficient is negative. - slong fmpz_poly_mat_max_length(const fmpz_poly_mat_t A) + slong fmpz_poly_mat_max_length(const fmpz_poly_mat_t A) noexcept # Returns the maximum polynomial length among all the entries in ``A``. - void fmpz_poly_mat_transpose(fmpz_poly_mat_t B, const fmpz_poly_mat_t A) + void fmpz_poly_mat_transpose(fmpz_poly_mat_t B, const fmpz_poly_mat_t A) noexcept # Sets `B` to `A^t`. - void fmpz_poly_mat_evaluate_fmpz(fmpz_mat_t B, const fmpz_poly_mat_t A, const fmpz_t x) + void fmpz_poly_mat_evaluate_fmpz(fmpz_mat_t B, const fmpz_poly_mat_t A, const fmpz_t x) noexcept # Sets the ``fmpz_mat_t`` ``B`` to ``A`` evaluated entrywise # at the point ``x``. - void fmpz_poly_mat_scalar_mul_fmpz_poly(fmpz_poly_mat_t B, const fmpz_poly_mat_t A, const fmpz_poly_t c) + void fmpz_poly_mat_scalar_mul_fmpz_poly(fmpz_poly_mat_t B, const fmpz_poly_mat_t A, const fmpz_poly_t c) noexcept # Sets ``B`` to ``A`` multiplied entrywise by the polynomial ``c``. - void fmpz_poly_mat_scalar_mul_fmpz(fmpz_poly_mat_t B, const fmpz_poly_mat_t A, const fmpz_t c) + void fmpz_poly_mat_scalar_mul_fmpz(fmpz_poly_mat_t B, const fmpz_poly_mat_t A, const fmpz_t c) noexcept # Sets ``B`` to ``A`` multiplied entrywise by the integer ``c``. - void fmpz_poly_mat_add(fmpz_poly_mat_t C, const fmpz_poly_mat_t A, const fmpz_poly_mat_t B) + void fmpz_poly_mat_add(fmpz_poly_mat_t C, const fmpz_poly_mat_t A, const fmpz_poly_mat_t B) noexcept # Sets ``C`` to the sum of ``A`` and ``B``. # All matrices must have the same shape. Aliasing is allowed. - void fmpz_poly_mat_sub(fmpz_poly_mat_t C, const fmpz_poly_mat_t A, const fmpz_poly_mat_t B) + void fmpz_poly_mat_sub(fmpz_poly_mat_t C, const fmpz_poly_mat_t A, const fmpz_poly_mat_t B) noexcept # Sets ``C`` to the sum of ``A`` and ``B``. # All matrices must have the same shape. Aliasing is allowed. - void fmpz_poly_mat_neg(fmpz_poly_mat_t B, const fmpz_poly_mat_t A) + void fmpz_poly_mat_neg(fmpz_poly_mat_t B, const fmpz_poly_mat_t A) noexcept # Sets ``B`` to the negation of ``A``. # The matrices must have the same shape. Aliasing is allowed. - void fmpz_poly_mat_mul(fmpz_poly_mat_t C, const fmpz_poly_mat_t A, const fmpz_poly_mat_t B) + void fmpz_poly_mat_mul(fmpz_poly_mat_t C, const fmpz_poly_mat_t A, const fmpz_poly_mat_t B) noexcept # Sets ``C`` to the matrix product of ``A`` and ``B``. # The matrices must have compatible dimensions for matrix multiplication. # Aliasing is allowed. This function automatically chooses between # classical and KS multiplication. - void fmpz_poly_mat_mul_classical(fmpz_poly_mat_t C, const fmpz_poly_mat_t A, const fmpz_poly_mat_t B) + void fmpz_poly_mat_mul_classical(fmpz_poly_mat_t C, const fmpz_poly_mat_t A, const fmpz_poly_mat_t B) noexcept # Sets ``C`` to the matrix product of ``A`` and ``B``, # computed using the classical algorithm. The matrices must have # compatible dimensions for matrix multiplication. Aliasing is allowed. - void fmpz_poly_mat_mul_KS(fmpz_poly_mat_t C, const fmpz_poly_mat_t A, const fmpz_poly_mat_t B) + void fmpz_poly_mat_mul_KS(fmpz_poly_mat_t C, const fmpz_poly_mat_t A, const fmpz_poly_mat_t B) noexcept # Sets ``C`` to the matrix product of ``A`` and ``B``, # computed using Kronecker segmentation. The matrices must have # compatible dimensions for matrix multiplication. Aliasing is allowed. - void fmpz_poly_mat_mullow(fmpz_poly_mat_t C, const fmpz_poly_mat_t A, const fmpz_poly_mat_t B, slong len) + void fmpz_poly_mat_mullow(fmpz_poly_mat_t C, const fmpz_poly_mat_t A, const fmpz_poly_mat_t B, slong len) noexcept # Sets ``C`` to the matrix product of ``A`` and ``B``, # truncating each entry in the result to length ``len``. # Uses classical matrix multiplication. The matrices must have # compatible dimensions for matrix multiplication. Aliasing is allowed. - void fmpz_poly_mat_sqr(fmpz_poly_mat_t B, const fmpz_poly_mat_t A) + void fmpz_poly_mat_sqr(fmpz_poly_mat_t B, const fmpz_poly_mat_t A) noexcept # Sets ``B`` to the square of ``A``, which must be a square matrix. # Aliasing is allowed. This function automatically chooses between # classical and KS squaring. - void fmpz_poly_mat_sqr_classical(fmpz_poly_mat_t B, const fmpz_poly_mat_t A) + void fmpz_poly_mat_sqr_classical(fmpz_poly_mat_t B, const fmpz_poly_mat_t A) noexcept # Sets ``B`` to the square of ``A``, which must be a square matrix. # Aliasing is allowed. This function uses direct formulas for very small # matrices, and otherwise classical matrix multiplication. - void fmpz_poly_mat_sqr_KS(fmpz_poly_mat_t B, const fmpz_poly_mat_t A) + void fmpz_poly_mat_sqr_KS(fmpz_poly_mat_t B, const fmpz_poly_mat_t A) noexcept # Sets ``B`` to the square of ``A``, which must be a square matrix. # Aliasing is allowed. This function uses Kronecker segmentation. - void fmpz_poly_mat_sqrlow(fmpz_poly_mat_t B, const fmpz_poly_mat_t A, slong len) + void fmpz_poly_mat_sqrlow(fmpz_poly_mat_t B, const fmpz_poly_mat_t A, slong len) noexcept # Sets ``B`` to the square of ``A``, which must be a square matrix, # truncating all entries to length ``len``. # Aliasing is allowed. This function uses direct formulas for very small # matrices, and otherwise classical matrix multiplication. - void fmpz_poly_mat_pow(fmpz_poly_mat_t B, const fmpz_poly_mat_t A, ulong exp) + void fmpz_poly_mat_pow(fmpz_poly_mat_t B, const fmpz_poly_mat_t A, ulong exp) noexcept # Sets ``B`` to ``A`` raised to the power ``exp``, where ``A`` # is a square matrix. Uses exponentiation by squaring. Aliasing is allowed. - void fmpz_poly_mat_pow_trunc(fmpz_poly_mat_t B, const fmpz_poly_mat_t A, ulong exp, slong len) + void fmpz_poly_mat_pow_trunc(fmpz_poly_mat_t B, const fmpz_poly_mat_t A, ulong exp, slong len) noexcept # Sets ``B`` to ``A`` raised to the power ``exp``, truncating # all entries to length ``len``, where ``A`` is a square matrix. # Uses exponentiation by squaring. Aliasing is allowed. - void fmpz_poly_mat_prod(fmpz_poly_mat_t res, fmpz_poly_mat_t * const factors, slong n) + void fmpz_poly_mat_prod(fmpz_poly_mat_t res, fmpz_poly_mat_t * const factors, slong n) noexcept # Sets ``res`` to the product of the ``n`` matrices given in # the vector ``factors``, all of which must be square and of the # same size. Uses binary splitting. - slong fmpz_poly_mat_find_pivot_any(const fmpz_poly_mat_t mat, slong start_row, slong end_row, slong c) + slong fmpz_poly_mat_find_pivot_any(const fmpz_poly_mat_t mat, slong start_row, slong end_row, slong c) noexcept # Attempts to find a pivot entry for row reduction. # Returns a row index `r` between ``start_row`` (inclusive) and # ``stop_row`` (exclusive) such that column `c` in ``mat`` has @@ -192,7 +192,7 @@ cdef extern from "flint_wrap.h": # entries in the matrix have roughly the same size, but can lead to # unnecessary coefficient growth if the entries vary in size. - slong fmpz_poly_mat_find_pivot_partial(const fmpz_poly_mat_t mat, slong start_row, slong end_row, slong c) + slong fmpz_poly_mat_find_pivot_partial(const fmpz_poly_mat_t mat, slong start_row, slong end_row, slong c) noexcept # Attempts to find a pivot entry for row reduction. # Returns a row index `r` between ``start_row`` (inclusive) and # ``stop_row`` (exclusive) such that column `c` in ``mat`` has @@ -203,7 +203,7 @@ cdef extern from "flint_wrap.h": # the smallest coefficient bit bound. This heuristic typically reduces # coefficient growth when the matrix entries vary in size. - slong fmpz_poly_mat_fflu(fmpz_poly_mat_t B, fmpz_poly_t den, slong * perm, const fmpz_poly_mat_t A, int rank_check) + slong fmpz_poly_mat_fflu(fmpz_poly_mat_t B, fmpz_poly_t den, slong * perm, const fmpz_poly_mat_t A, int rank_check) noexcept # Uses fraction-free Gaussian elimination to set (``B``, ``den``) to a # fraction-free LU decomposition of ``A`` and returns the # rank of ``A``. Aliasing of ``A`` and ``B`` is allowed. @@ -217,38 +217,38 @@ cdef extern from "flint_wrap.h": # the sign is decided by the parity of the permutation. Note that the # determinant is not generally the minimal denominator. - slong fmpz_poly_mat_rref(fmpz_poly_mat_t B, fmpz_poly_t den, const fmpz_poly_mat_t A) + slong fmpz_poly_mat_rref(fmpz_poly_mat_t B, fmpz_poly_t den, const fmpz_poly_mat_t A) noexcept # Sets (``B``, ``den``) to the reduced row echelon form of # ``A`` and returns the rank of ``A``. Aliasing of ``A`` and # ``B`` is allowed. # The denominator ``den`` is set to `\pm \operatorname{det}(A)`. # Note that the determinant is not generally the minimal denominator. - void fmpz_poly_mat_trace(fmpz_poly_t trace, const fmpz_poly_mat_t mat) + void fmpz_poly_mat_trace(fmpz_poly_t trace, const fmpz_poly_mat_t mat) noexcept # Computes the trace of the matrix, i.e. the sum of the entries on # the main diagonal. The matrix is required to be square. - void fmpz_poly_mat_det(fmpz_poly_t det, const fmpz_poly_mat_t A) + void fmpz_poly_mat_det(fmpz_poly_t det, const fmpz_poly_mat_t A) noexcept # Sets ``det`` to the determinant of the square matrix ``A``. Uses # a direct formula, fraction-free LU decomposition, or interpolation, # depending on the size of the matrix. - void fmpz_poly_mat_det_fflu(fmpz_poly_t det, const fmpz_poly_mat_t A) + void fmpz_poly_mat_det_fflu(fmpz_poly_t det, const fmpz_poly_mat_t A) noexcept # Sets ``det`` to the determinant of the square matrix ``A``. # The determinant is computed by performing a fraction-free LU # decomposition on a copy of ``A``. - void fmpz_poly_mat_det_interpolate(fmpz_poly_t det, const fmpz_poly_mat_t A) + void fmpz_poly_mat_det_interpolate(fmpz_poly_t det, const fmpz_poly_mat_t A) noexcept # Sets ``det`` to the determinant of the square matrix ``A``. # The determinant is computed by determining a bound `n` for its length, # evaluating the matrix at `n` distinct points, computing the determinant # of each integer matrix, and forming the interpolating polynomial. - slong fmpz_poly_mat_rank(const fmpz_poly_mat_t A) + slong fmpz_poly_mat_rank(const fmpz_poly_mat_t A) noexcept # Returns the rank of ``A``. Performs fraction-free LU decomposition # on a copy of ``A``. - int fmpz_poly_mat_inv(fmpz_poly_mat_t Ainv, fmpz_poly_t den, const fmpz_poly_mat_t A) + int fmpz_poly_mat_inv(fmpz_poly_mat_t Ainv, fmpz_poly_t den, const fmpz_poly_mat_t A) noexcept # Sets (``Ainv``, ``den``) to the inverse matrix of ``A``. # Returns 1 if ``A`` is nonsingular and 0 if ``A`` is singular. # Aliasing of ``Ainv`` and ``A`` is allowed. @@ -258,7 +258,7 @@ cdef extern from "flint_wrap.h": # Uses fraction-free LU decomposition, followed by solving for # the identity matrix. - slong fmpz_poly_mat_nullspace(fmpz_poly_mat_t res, const fmpz_poly_mat_t mat) + slong fmpz_poly_mat_nullspace(fmpz_poly_mat_t res, const fmpz_poly_mat_t mat) noexcept # Computes the right rational nullspace of the matrix ``mat`` and # returns the nullity. # More precisely, assume that ``mat`` has rank `r` and nullity `n`. @@ -270,7 +270,7 @@ cdef extern from "flint_wrap.h": # In general, the polynomials in each column vector in the result # will have a nontrivial common GCD. - int fmpz_poly_mat_solve(fmpz_poly_mat_t X, fmpz_poly_t den, const fmpz_poly_mat_t A, const fmpz_poly_mat_t B) + int fmpz_poly_mat_solve(fmpz_poly_mat_t X, fmpz_poly_t den, const fmpz_poly_mat_t A, const fmpz_poly_mat_t B) noexcept # Solves the equation `AX = B` for nonsingular `A`. More precisely, computes # (``X``, ``den``) such that `AX = B \times \operatorname{den}`. # Returns 1 if `A` is nonsingular and 0 if `A` is singular. @@ -278,7 +278,7 @@ cdef extern from "flint_wrap.h": # Uses fraction-free LU decomposition followed by fraction-free # forward and back substitution. - int fmpz_poly_mat_solve_fflu(fmpz_poly_mat_t X, fmpz_poly_t den, const fmpz_poly_mat_t A, const fmpz_poly_mat_t B) + int fmpz_poly_mat_solve_fflu(fmpz_poly_mat_t X, fmpz_poly_t den, const fmpz_poly_mat_t A, const fmpz_poly_mat_t B) noexcept # Solves the equation `AX = B` for nonsingular `A`. More precisely, computes # (``X``, ``den``) such that `AX = B \times \operatorname{den}`. # Returns 1 if `A` is nonsingular and 0 if `A` is singular. @@ -286,6 +286,6 @@ cdef extern from "flint_wrap.h": # Uses fraction-free LU decomposition followed by fraction-free # forward and back substitution. - void fmpz_poly_mat_solve_fflu_precomp(fmpz_poly_mat_t X, const slong * perm, const fmpz_poly_mat_t FFLU, const fmpz_poly_mat_t B) + void fmpz_poly_mat_solve_fflu_precomp(fmpz_poly_mat_t X, const slong * perm, const fmpz_poly_mat_t FFLU, const fmpz_poly_mat_t B) noexcept # Performs fraction-free forward and back substitution given a precomputed # fraction-free LU decomposition and corresponding permutation. diff --git a/src/sage/libs/flint/fmpz_poly_q.pxd b/src/sage/libs/flint/fmpz_poly_q.pxd index 396dec3a2f6..ee1a23bf5d5 100644 --- a/src/sage/libs/flint/fmpz_poly_q.pxd +++ b/src/sage/libs/flint/fmpz_poly_q.pxd @@ -12,138 +12,138 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void fmpz_poly_q_init(fmpz_poly_q_t rop) + void fmpz_poly_q_init(fmpz_poly_q_t rop) noexcept # Initialises ``rop``. - void fmpz_poly_q_clear(fmpz_poly_q_t rop) + void fmpz_poly_q_clear(fmpz_poly_q_t rop) noexcept # Clears the object ``rop``. - fmpz_poly_struct * fmpz_poly_q_numref(const fmpz_poly_q_t op) + fmpz_poly_struct * fmpz_poly_q_numref(const fmpz_poly_q_t op) noexcept # Returns a reference to the numerator of ``op``. - fmpz_poly_struct * fmpz_poly_q_denref(const fmpz_poly_q_t op) + fmpz_poly_struct * fmpz_poly_q_denref(const fmpz_poly_q_t op) noexcept # Returns a reference to the denominator of ``op``. - void fmpz_poly_q_canonicalise(fmpz_poly_q_t rop) + void fmpz_poly_q_canonicalise(fmpz_poly_q_t rop) noexcept # Brings ``rop`` into canonical form, only assuming that # the denominator is non-zero. - bint fmpz_poly_q_is_canonical(const fmpz_poly_q_t op) + bint fmpz_poly_q_is_canonical(const fmpz_poly_q_t op) noexcept # Checks whether the rational function ``op`` is in # canonical form. - void fmpz_poly_q_randtest(fmpz_poly_q_t poly, flint_rand_t state, slong len1, flint_bitcnt_t bits1, slong len2, flint_bitcnt_t bits2) + void fmpz_poly_q_randtest(fmpz_poly_q_t poly, flint_rand_t state, slong len1, flint_bitcnt_t bits1, slong len2, flint_bitcnt_t bits2) noexcept # Sets ``poly`` to a random rational function. - void fmpz_poly_q_randtest_not_zero(fmpz_poly_q_t poly, flint_rand_t state, slong len1, flint_bitcnt_t bits1, slong len2, flint_bitcnt_t bits2) + void fmpz_poly_q_randtest_not_zero(fmpz_poly_q_t poly, flint_rand_t state, slong len1, flint_bitcnt_t bits1, slong len2, flint_bitcnt_t bits2) noexcept # Sets ``poly`` to a random non-zero rational function. - void fmpz_poly_q_set(fmpz_poly_q_t rop, const fmpz_poly_q_t op) + void fmpz_poly_q_set(fmpz_poly_q_t rop, const fmpz_poly_q_t op) noexcept # Sets the element ``rop`` to the same value as the element ``op``. - void fmpz_poly_q_set_si(fmpz_poly_q_t rop, slong op) + void fmpz_poly_q_set_si(fmpz_poly_q_t rop, slong op) noexcept # Sets the element ``rop`` to the value given by the ``slong`` # ``op``. - void fmpz_poly_q_swap(fmpz_poly_q_t op1, fmpz_poly_q_t op2) + void fmpz_poly_q_swap(fmpz_poly_q_t op1, fmpz_poly_q_t op2) noexcept # Swaps the elements ``op1`` and ``op2``. # This is done efficiently by swapping pointers. - void fmpz_poly_q_zero(fmpz_poly_q_t rop) + void fmpz_poly_q_zero(fmpz_poly_q_t rop) noexcept # Sets ``rop`` to zero. - void fmpz_poly_q_one(fmpz_poly_q_t rop) + void fmpz_poly_q_one(fmpz_poly_q_t rop) noexcept # Sets ``rop`` to one. - void fmpz_poly_q_neg(fmpz_poly_q_t rop, const fmpz_poly_q_t op) + void fmpz_poly_q_neg(fmpz_poly_q_t rop, const fmpz_poly_q_t op) noexcept # Sets the element ``rop`` to the additive inverse of ``op``. - void fmpz_poly_q_inv(fmpz_poly_q_t rop, const fmpz_poly_q_t op) + void fmpz_poly_q_inv(fmpz_poly_q_t rop, const fmpz_poly_q_t op) noexcept # Sets the element ``rop`` to the multiplicative inverse of ``op``. # Assumes that the element ``op`` is non-zero. - bint fmpz_poly_q_is_zero(const fmpz_poly_q_t op) + bint fmpz_poly_q_is_zero(const fmpz_poly_q_t op) noexcept # Returns whether the element ``op`` is zero. - bint fmpz_poly_q_is_one(const fmpz_poly_q_t op) + bint fmpz_poly_q_is_one(const fmpz_poly_q_t op) noexcept # Returns whether the element ``rop`` is equal to the constant # polynomial `1`. - bint fmpz_poly_q_equal(const fmpz_poly_q_t op1, const fmpz_poly_q_t op2) + bint fmpz_poly_q_equal(const fmpz_poly_q_t op1, const fmpz_poly_q_t op2) noexcept # Returns whether the two elements ``op1`` and ``op2`` are equal. - void fmpz_poly_q_add(fmpz_poly_q_t rop, const fmpz_poly_q_t op1, const fmpz_poly_q_t op2) + void fmpz_poly_q_add(fmpz_poly_q_t rop, const fmpz_poly_q_t op1, const fmpz_poly_q_t op2) noexcept # Sets ``rop`` to the sum of ``op1`` and ``op2``. - void fmpz_poly_q_sub(fmpz_poly_q_t rop, const fmpz_poly_q_t op1, const fmpz_poly_q_t op2) + void fmpz_poly_q_sub(fmpz_poly_q_t rop, const fmpz_poly_q_t op1, const fmpz_poly_q_t op2) noexcept # Sets ``rop`` to the difference of ``op1`` and ``op2``. - void fmpz_poly_q_addmul(fmpz_poly_q_t rop, const fmpz_poly_q_t op1, const fmpz_poly_q_t op2) + void fmpz_poly_q_addmul(fmpz_poly_q_t rop, const fmpz_poly_q_t op1, const fmpz_poly_q_t op2) noexcept # Adds the product of ``op1`` and ``op2`` to ``rop``. - void fmpz_poly_q_submul(fmpz_poly_q_t rop, const fmpz_poly_q_t op1, const fmpz_poly_q_t op2) + void fmpz_poly_q_submul(fmpz_poly_q_t rop, const fmpz_poly_q_t op1, const fmpz_poly_q_t op2) noexcept # Subtracts the product of ``op1`` and ``op2`` from ``rop``. - void fmpz_poly_q_scalar_mul_si(fmpz_poly_q_t rop, const fmpz_poly_q_t op, slong x) + void fmpz_poly_q_scalar_mul_si(fmpz_poly_q_t rop, const fmpz_poly_q_t op, slong x) noexcept # Sets ``rop`` to the product of the rational function ``op`` # and the ``slong`` integer `x`. - void fmpz_poly_q_scalar_mul_fmpz(fmpz_poly_q_t rop, const fmpz_poly_q_t op, const fmpz_t x) + void fmpz_poly_q_scalar_mul_fmpz(fmpz_poly_q_t rop, const fmpz_poly_q_t op, const fmpz_t x) noexcept # Sets ``rop`` to the product of the rational function ``op`` # and the ``fmpz_t`` integer `x`. - void fmpz_poly_q_scalar_mul_fmpq(fmpz_poly_q_t rop, const fmpz_poly_q_t op, const fmpq_t x) + void fmpz_poly_q_scalar_mul_fmpq(fmpz_poly_q_t rop, const fmpz_poly_q_t op, const fmpq_t x) noexcept # Sets ``rop`` to the product of the rational function ``op`` # and the ``fmpq_t`` rational `x`. - void fmpz_poly_q_scalar_div_si(fmpz_poly_q_t rop, const fmpz_poly_q_t op, slong x) + void fmpz_poly_q_scalar_div_si(fmpz_poly_q_t rop, const fmpz_poly_q_t op, slong x) noexcept # Sets ``rop`` to the quotient of the rational function ``op`` # and the ``slong`` integer `x`. - void fmpz_poly_q_scalar_div_fmpz(fmpz_poly_q_t rop, const fmpz_poly_q_t op, const fmpz_t x) + void fmpz_poly_q_scalar_div_fmpz(fmpz_poly_q_t rop, const fmpz_poly_q_t op, const fmpz_t x) noexcept # Sets ``rop`` to the quotient of the rational function ``op`` # and the ``fmpz_t`` integer `x`. - void fmpz_poly_q_scalar_div_fmpq(fmpz_poly_q_t rop, const fmpz_poly_q_t op, const fmpq_t x) + void fmpz_poly_q_scalar_div_fmpq(fmpz_poly_q_t rop, const fmpz_poly_q_t op, const fmpq_t x) noexcept # Sets ``rop`` to the quotient of the rational function ``op`` # and the ``fmpq_t`` rational `x`. - void fmpz_poly_q_mul(fmpz_poly_q_t rop, const fmpz_poly_q_t op1, const fmpz_poly_q_t op2) + void fmpz_poly_q_mul(fmpz_poly_q_t rop, const fmpz_poly_q_t op1, const fmpz_poly_q_t op2) noexcept # Sets ``rop`` to the product of ``op1`` and ``op2``. - void fmpz_poly_q_div(fmpz_poly_q_t rop, const fmpz_poly_q_t op1, const fmpz_poly_q_t op2) + void fmpz_poly_q_div(fmpz_poly_q_t rop, const fmpz_poly_q_t op1, const fmpz_poly_q_t op2) noexcept # Sets ``rop`` to the quotient of ``op1`` and ``op2``. - void fmpz_poly_q_pow(fmpz_poly_q_t rop, const fmpz_poly_q_t op, ulong exp) + void fmpz_poly_q_pow(fmpz_poly_q_t rop, const fmpz_poly_q_t op, ulong exp) noexcept # Sets ``rop`` to the ``exp``-th power of ``op``. # The corner case of ``exp == 0`` is handled by setting ``rop`` to # the constant function `1`. Note that this includes the case `0^0 = 1`. - void fmpz_poly_q_derivative(fmpz_poly_q_t rop, const fmpz_poly_q_t op) + void fmpz_poly_q_derivative(fmpz_poly_q_t rop, const fmpz_poly_q_t op) noexcept # Sets ``rop`` to the derivative of ``op``. - int fmpz_poly_q_evaluate_fmpq(fmpq_t rop, const fmpz_poly_q_t f, const fmpq_t a) + int fmpz_poly_q_evaluate_fmpq(fmpq_t rop, const fmpz_poly_q_t f, const fmpq_t a) noexcept # Sets ``rop`` to `f` evaluated at the rational `a`. # If the denominator evaluates to zero at `a`, returns non-zero and # does not modify any of the variables. Otherwise, returns `0` and # sets ``rop`` to the rational `f(a)`. - int fmpz_poly_q_set_str(fmpz_poly_q_t rop, const char *s) + int fmpz_poly_q_set_str(fmpz_poly_q_t rop, const char *s) noexcept # Sets ``rop`` to the rational function given # by the string ``s``. - char * fmpz_poly_q_get_str(const fmpz_poly_q_t op) + char * fmpz_poly_q_get_str(const fmpz_poly_q_t op) noexcept # Returns the string representation of # the rational function ``op``. - char * fmpz_poly_q_get_str_pretty(const fmpz_poly_q_t op, const char *x) + char * fmpz_poly_q_get_str_pretty(const fmpz_poly_q_t op, const char *x) noexcept # Returns the pretty string representation of # the rational function ``op``. - int fmpz_poly_q_print(const fmpz_poly_q_t op) + int fmpz_poly_q_print(const fmpz_poly_q_t op) noexcept # Prints the representation of the rational # function ``op`` to ``stdout``. - int fmpz_poly_q_print_pretty(const fmpz_poly_q_t op, const char *x) + int fmpz_poly_q_print_pretty(const fmpz_poly_q_t op, const char *x) noexcept # Prints the pretty representation of the rational # function ``op`` to ``stdout``. diff --git a/src/sage/libs/flint/fmpz_poly_sage.pxd b/src/sage/libs/flint/fmpz_poly_sage.pxd index 1d86947143a..add6ad1fbb6 100644 --- a/src/sage/libs/flint/fmpz_poly_sage.pxd +++ b/src/sage/libs/flint/fmpz_poly_sage.pxd @@ -5,12 +5,12 @@ from sage.libs.gmp.types cimport mpz_t from .types cimport * # functions removed from flint but still needed in sage -cdef void fmpz_poly_scalar_mul_mpz(fmpz_poly_t, const fmpz_poly_t, const mpz_t) -cdef void fmpz_poly_scalar_divexact_mpz(fmpz_poly_t, const fmpz_poly_t, const mpz_t) -cdef void fmpz_poly_scalar_fdiv_mpz(fmpz_poly_t, const fmpz_poly_t, const mpz_t) -cdef void fmpz_poly_set_coeff_mpz(fmpz_poly_t, slong, const mpz_t) -cdef void fmpz_poly_get_coeff_mpz(mpz_t, const fmpz_poly_t, slong) -cdef void fmpz_poly_set_mpz(fmpz_poly_t, const mpz_t) +cdef void fmpz_poly_scalar_mul_mpz(fmpz_poly_t, const fmpz_poly_t, const mpz_t) noexcept +cdef void fmpz_poly_scalar_divexact_mpz(fmpz_poly_t, const fmpz_poly_t, const mpz_t) noexcept +cdef void fmpz_poly_scalar_fdiv_mpz(fmpz_poly_t, const fmpz_poly_t, const mpz_t) noexcept +cdef void fmpz_poly_set_coeff_mpz(fmpz_poly_t, slong, const mpz_t) noexcept +cdef void fmpz_poly_get_coeff_mpz(mpz_t, const fmpz_poly_t, slong) noexcept +cdef void fmpz_poly_set_mpz(fmpz_poly_t, const mpz_t) noexcept # Wrapper Cython class diff --git a/src/sage/libs/flint/fmpz_poly_sage.pyx b/src/sage/libs/flint/fmpz_poly_sage.pyx index 1c422ce8100..d86d025a3e0 100644 --- a/src/sage/libs/flint/fmpz_poly_sage.pyx +++ b/src/sage/libs/flint/fmpz_poly_sage.pyx @@ -461,38 +461,38 @@ cdef class Fmpz_poly(SageObject): # Functions removed from flint but still needed in Sage. Code adapted from # earlier versions of flint. -cdef void fmpz_poly_scalar_mul_mpz(fmpz_poly_t rop, const fmpz_poly_t op, const mpz_t c): +cdef void fmpz_poly_scalar_mul_mpz(fmpz_poly_t rop, const fmpz_poly_t op, const mpz_t c) noexcept: cdef fmpz_t f fmpz_init_set_readonly(f, c) fmpz_poly_scalar_mul_fmpz(rop, op, f) fmpz_clear_readonly(f) -cdef void fmpz_poly_scalar_divexact_mpz(fmpz_poly_t rop, const fmpz_poly_t op, const mpz_t c): +cdef void fmpz_poly_scalar_divexact_mpz(fmpz_poly_t rop, const fmpz_poly_t op, const mpz_t c) noexcept: cdef fmpz_t f fmpz_init_set_readonly(f, c) fmpz_poly_scalar_divexact_fmpz(rop, op, f) fmpz_clear_readonly(f) -cdef void fmpz_poly_scalar_fdiv_mpz(fmpz_poly_t rop, const fmpz_poly_t op, const mpz_t c): +cdef void fmpz_poly_scalar_fdiv_mpz(fmpz_poly_t rop, const fmpz_poly_t op, const mpz_t c) noexcept: cdef fmpz_t f fmpz_init_set_readonly(f, c) fmpz_poly_scalar_fdiv_fmpz(rop, op, f) fmpz_clear_readonly(f) -cdef void fmpz_poly_set_coeff_mpz(fmpz_poly_t poly, slong n, const mpz_t x): +cdef void fmpz_poly_set_coeff_mpz(fmpz_poly_t poly, slong n, const mpz_t x) noexcept: cdef fmpz_t t fmpz_init_set_readonly(t, x) fmpz_poly_set_coeff_fmpz(poly, n, t) fmpz_clear_readonly(t) -cdef void fmpz_poly_get_coeff_mpz(mpz_t x, const fmpz_poly_t poly, slong n): +cdef void fmpz_poly_get_coeff_mpz(mpz_t x, const fmpz_poly_t poly, slong n) noexcept: cdef fmpz_t t fmpz_init(t) fmpz_poly_get_coeff_fmpz(t, poly, n) fmpz_get_mpz(x, t) fmpz_clear(t) -cdef void fmpz_poly_set_mpz(fmpz_poly_t poly, const mpz_t x): +cdef void fmpz_poly_set_mpz(fmpz_poly_t poly, const mpz_t x) noexcept: fmpz_poly_fit_length(poly, 1) fmpz_set_mpz(poly.coeffs, x) _fmpz_poly_set_length(poly, 1) diff --git a/src/sage/libs/flint/fmpz_vec.pxd b/src/sage/libs/flint/fmpz_vec.pxd index 40486fe2ce2..fb75eb2bf27 100644 --- a/src/sage/libs/flint/fmpz_vec.pxd +++ b/src/sage/libs/flint/fmpz_vec.pxd @@ -12,52 +12,52 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - fmpz * _fmpz_vec_init(slong len) + fmpz * _fmpz_vec_init(slong len) noexcept # Returns an initialised vector of ``fmpz``'s of given length. - void _fmpz_vec_clear(fmpz * vec, slong len) + void _fmpz_vec_clear(fmpz * vec, slong len) noexcept # Clears the entries of ``(vec, len)`` and frees the space allocated # for ``vec``. - void _fmpz_vec_randtest(fmpz * f, flint_rand_t state, slong len, flint_bitcnt_t bits) + void _fmpz_vec_randtest(fmpz * f, flint_rand_t state, slong len, flint_bitcnt_t bits) noexcept # Sets the entries of a vector of the given length to random integers with # up to the given number of bits per entry. - void _fmpz_vec_randtest_unsigned(fmpz * f, flint_rand_t state, slong len, flint_bitcnt_t bits) + void _fmpz_vec_randtest_unsigned(fmpz * f, flint_rand_t state, slong len, flint_bitcnt_t bits) noexcept # Sets the entries of a vector of the given length to random unsigned # integers with up to the given number of bits per entry. - slong _fmpz_vec_max_bits(const fmpz * vec, slong len) + slong _fmpz_vec_max_bits(const fmpz * vec, slong len) noexcept # If `b` is the maximum number of bits of the absolute value of any # coefficient of ``vec``, then if any coefficient of ``vec`` is # negative, `-b` is returned, else `b` is returned. - slong _fmpz_vec_max_bits_ref(const fmpz * vec, slong len) + slong _fmpz_vec_max_bits_ref(const fmpz * vec, slong len) noexcept # If `b` is the maximum number of bits of the absolute value of any # coefficient of ``vec``, then if any coefficient of ``vec`` is # negative, `-b` is returned, else `b` is returned. # This is a slower reference implementation of ``_fmpz_vec_max_bits``. - void _fmpz_vec_sum_max_bits(slong * sumabs, slong * maxabs, const fmpz * vec, slong len) + void _fmpz_vec_sum_max_bits(slong * sumabs, slong * maxabs, const fmpz * vec, slong len) noexcept # Sets ``sumabs`` to the bit count of the sum of the absolute values of # the elements of ``vec``. Sets ``maxabs`` to the bit count of the # maximum of the absolute values of the elements of ``vec``. - mp_size_t _fmpz_vec_max_limbs(const fmpz * vec, slong len) + mp_size_t _fmpz_vec_max_limbs(const fmpz * vec, slong len) noexcept # Returns the maximum number of limbs needed to store the absolute value # of any entry in ``(vec, len)``. If all entries are zero, returns # zero. - void _fmpz_vec_height(fmpz_t height, const fmpz * vec, slong len) + void _fmpz_vec_height(fmpz_t height, const fmpz * vec, slong len) noexcept # Computes the height of ``(vec, len)``, defined as the largest of the # absolute values the coefficients. Equivalently, this gives the infinity # norm of the vector. If ``len`` is zero, the height is `0`. - slong _fmpz_vec_height_index(const fmpz * vec, slong len) + slong _fmpz_vec_height_index(const fmpz * vec, slong len) noexcept # Returns the index of an entry of maximum absolute value in the vector. # The length must be at least 1. - int _fmpz_vec_fread(FILE * file, fmpz ** vec, slong * len) + int _fmpz_vec_fread(FILE * file, fmpz ** vec, slong * len) noexcept # Reads a vector from the stream ``file`` and stores it at # ``*vec``. The format is the same as the output format of # ``_fmpz_vec_fprint()``, followed by either any character @@ -79,37 +79,37 @@ cdef extern from "flint_wrap.h": # In case of success, returns a positive value. In case of failure, # returns a non-positive value. - int _fmpz_vec_read(fmpz ** vec, slong * len) + int _fmpz_vec_read(fmpz ** vec, slong * len) noexcept # Reads a vector from ``stdin`` and stores it at ``*vec``. # For further details, see ``_fmpz_vec_fread()``. - int _fmpz_vec_fprint(FILE * file, const fmpz * vec, slong len) + int _fmpz_vec_fprint(FILE * file, const fmpz * vec, slong len) noexcept # Prints the vector of given length to the stream ``file``. The # format is the length followed by two spaces, then a space separated # list of coefficients. If the length is zero, only `0` is printed. # In case of success, returns a positive value. In case of failure, # returns a non-positive value. - int _fmpz_vec_print(const fmpz * vec, slong len) + int _fmpz_vec_print(const fmpz * vec, slong len) noexcept # Prints the vector of given length to ``stdout``. # For further details, see ``_fmpz_vec_fprint()``. - void _fmpz_vec_get_nmod_vec(mp_ptr res, const fmpz * poly, slong len, nmod_t mod) + void _fmpz_vec_get_nmod_vec(mp_ptr res, const fmpz * poly, slong len, nmod_t mod) noexcept # Reduce the coefficients of ``(poly, len)`` modulo the given # modulus and set ``(res, len)`` to the result. - void _fmpz_vec_set_nmod_vec(fmpz * res, mp_srcptr poly, slong len, nmod_t mod) + void _fmpz_vec_set_nmod_vec(fmpz * res, mp_srcptr poly, slong len, nmod_t mod) noexcept # Set the coefficients of ``(res, len)`` to the symmetric modulus # of the coefficients of ``(poly, len)``, i.e. convert the given # coefficients modulo the given modulus `n` to their signed integer # representatives in the range `[-n/2, n/2)`. - void _fmpz_vec_get_fft(mp_limb_t ** coeffs_f, const fmpz * coeffs_m, slong l, slong length) + void _fmpz_vec_get_fft(mp_limb_t ** coeffs_f, const fmpz * coeffs_m, slong l, slong length) noexcept # Convert the vector of coeffs ``coeffs_m`` to an fft vector # ``coeffs_f`` of the given ``length`` with ``l`` limbs per # coefficient with an additional limb for overflow. - void _fmpz_vec_set_fft(fmpz * coeffs_m, slong length, const mp_ptr * coeffs_f, slong limbs, slong sign) + void _fmpz_vec_set_fft(fmpz * coeffs_m, slong length, const mp_ptr * coeffs_f, slong limbs, slong sign) noexcept # Convert an fft vector ``coeffs_f`` of fully reduced Fermat numbers of the # given ``length`` to a vector of ``fmpz``'s. Each is assumed to be the given # number of limbs in length with an additional limb for overflow. If the @@ -118,7 +118,7 @@ cdef extern from "flint_wrap.h": # and in the range `[0,2n]` in the unsigned case where # ``n = 2^(FLINT_BITS*limbs - 1)``. - slong _fmpz_vec_get_d_vec_2exp(double * appv, const fmpz * vec, slong len) + slong _fmpz_vec_get_d_vec_2exp(double * appv, const fmpz * vec, slong len) noexcept # Export the array of ``len`` entries starting at the pointer ``vec`` # to an array of doubles ``appv``, each entry of which is notionally # multiplied by a single returned exponent to give the original entry. The @@ -126,167 +126,167 @@ cdef extern from "flint_wrap.h": # entries so that all the doubles in ``appv`` have a maximum absolute # value of 1.0. - void _fmpz_vec_set(fmpz * vec1, const fmpz * vec2, slong len2) + void _fmpz_vec_set(fmpz * vec1, const fmpz * vec2, slong len2) noexcept # Makes a copy of ``(vec2, len2)`` into ``vec1``. - void _fmpz_vec_swap(fmpz * vec1, fmpz * vec2, slong len2) + void _fmpz_vec_swap(fmpz * vec1, fmpz * vec2, slong len2) noexcept # Swaps the integers in ``(vec1, len2)`` and ``(vec2, len2)``. - void _fmpz_vec_zero(fmpz * vec, slong len) + void _fmpz_vec_zero(fmpz * vec, slong len) noexcept # Zeros the entries of ``(vec, len)``. - void _fmpz_vec_neg(fmpz * vec1, const fmpz * vec2, slong len2) + void _fmpz_vec_neg(fmpz * vec1, const fmpz * vec2, slong len2) noexcept # Negates ``(vec2, len2)`` and places it into ``vec1``. - void _fmpz_vec_scalar_abs(fmpz * vec1, const fmpz * vec2, slong len2) + void _fmpz_vec_scalar_abs(fmpz * vec1, const fmpz * vec2, slong len2) noexcept # Takes the absolute value of entries in ``(vec2, len2)`` and places the # result into ``vec1``. - bint _fmpz_vec_equal(const fmpz * vec1, const fmpz * vec2, slong len) + bint _fmpz_vec_equal(const fmpz * vec1, const fmpz * vec2, slong len) noexcept # Compares two vectors of the given length and returns `1` if they are # equal, otherwise returns `0`. - bint _fmpz_vec_is_zero(const fmpz * vec, slong len) + bint _fmpz_vec_is_zero(const fmpz * vec, slong len) noexcept # Returns `1` if ``(vec, len)`` is zero, and `0` otherwise. - void _fmpz_vec_max(fmpz * vec1, const fmpz * vec2, const fmpz * vec3, slong len) + void _fmpz_vec_max(fmpz * vec1, const fmpz * vec2, const fmpz * vec3, slong len) noexcept # Sets ``vec1`` to the pointwise maximum of ``vec2`` and ``vec3``. - void _fmpz_vec_max_inplace(fmpz * vec1, const fmpz * vec2, slong len) + void _fmpz_vec_max_inplace(fmpz * vec1, const fmpz * vec2, slong len) noexcept # Sets ``vec1`` to the pointwise maximum of ``vec1`` and ``vec2``. - void _fmpz_vec_sort(fmpz * vec, slong len) + void _fmpz_vec_sort(fmpz * vec, slong len) noexcept # Sorts the coefficients of ``vec`` in ascending order. - void _fmpz_vec_add(fmpz * res, const fmpz * vec1, const fmpz * vec2, slong len2) + void _fmpz_vec_add(fmpz * res, const fmpz * vec1, const fmpz * vec2, slong len2) noexcept # Sets ``(res, len2)`` to the sum of ``(vec1, len2)`` # and ``(vec2, len2)``. - void _fmpz_vec_sub(fmpz * res, const fmpz * vec1, const fmpz * vec2, slong len2) + void _fmpz_vec_sub(fmpz * res, const fmpz * vec1, const fmpz * vec2, slong len2) noexcept # Sets ``(res, len2)`` to ``(vec1, len2)`` minus ``(vec2, len2)``. - void _fmpz_vec_scalar_mul_fmpz(fmpz * vec1, const fmpz * vec2, slong len2, const fmpz_t x) + void _fmpz_vec_scalar_mul_fmpz(fmpz * vec1, const fmpz * vec2, slong len2, const fmpz_t x) noexcept # Sets ``(vec1, len2)`` to ``(vec2, len2)`` multiplied by `c`, # where `c` is an ``fmpz_t``. - void _fmpz_vec_scalar_mul_si(fmpz * vec1, const fmpz * vec2, slong len2, slong c) + void _fmpz_vec_scalar_mul_si(fmpz * vec1, const fmpz * vec2, slong len2, slong c) noexcept # Sets ``(vec1, len2)`` to ``(vec2, len2)`` multiplied by `c`, # where `c` is a ``slong``. - void _fmpz_vec_scalar_mul_ui(fmpz * vec1, const fmpz * vec2, slong len2, ulong c) + void _fmpz_vec_scalar_mul_ui(fmpz * vec1, const fmpz * vec2, slong len2, ulong c) noexcept # Sets ``(vec1, len2)`` to ``(vec2, len2)`` multiplied by `c`, # where `c` is an ``ulong``. - void _fmpz_vec_scalar_mul_2exp(fmpz * vec1, const fmpz * vec2, slong len2, ulong exp) + void _fmpz_vec_scalar_mul_2exp(fmpz * vec1, const fmpz * vec2, slong len2, ulong exp) noexcept # Sets ``(vec1, len2)`` to ``(vec2, len2)`` multiplied by ``2^exp``. - void _fmpz_vec_scalar_divexact_fmpz(fmpz * vec1, const fmpz * vec2, slong len2, const fmpz_t x) + void _fmpz_vec_scalar_divexact_fmpz(fmpz * vec1, const fmpz * vec2, slong len2, const fmpz_t x) noexcept # Sets ``(vec1, len2)`` to ``(vec2, len2)`` divided by `x`, where the # division is assumed to be exact for every entry in ``vec2``. - void _fmpz_vec_scalar_divexact_si(fmpz * vec1, const fmpz * vec2, slong len2, slong c) + void _fmpz_vec_scalar_divexact_si(fmpz * vec1, const fmpz * vec2, slong len2, slong c) noexcept # Sets ``(vec1, len2)`` to ``(vec2, len2)`` divided by `x`, where the # division is assumed to be exact for every entry in ``vec2``. - void _fmpz_vec_scalar_divexact_ui(fmpz * vec1, const fmpz * vec2, slong len2, ulong c) + void _fmpz_vec_scalar_divexact_ui(fmpz * vec1, const fmpz * vec2, slong len2, ulong c) noexcept # Sets ``(vec1, len2)`` to ``(vec2, len2)`` divided by `x`, where the # division is assumed to be exact for every entry in ``vec2``. - void _fmpz_vec_scalar_fdiv_q_fmpz(fmpz * vec1, const fmpz * vec2, slong len2, const fmpz_t c) + void _fmpz_vec_scalar_fdiv_q_fmpz(fmpz * vec1, const fmpz * vec2, slong len2, const fmpz_t c) noexcept # Sets ``(vec1, len2)`` to ``(vec2, len2)`` divided by `c`, rounding # down towards minus infinity whenever the division is not exact. - void _fmpz_vec_scalar_fdiv_q_si(fmpz * vec1, const fmpz * vec2, slong len2, slong c) + void _fmpz_vec_scalar_fdiv_q_si(fmpz * vec1, const fmpz * vec2, slong len2, slong c) noexcept # Sets ``(vec1, len2)`` to ``(vec2, len2)`` divided by `c`, rounding # down towards minus infinity whenever the division is not exact. - void _fmpz_vec_scalar_fdiv_q_ui(fmpz * vec1, const fmpz * vec2, slong len2, ulong c) + void _fmpz_vec_scalar_fdiv_q_ui(fmpz * vec1, const fmpz * vec2, slong len2, ulong c) noexcept # Sets ``(vec1, len2)`` to ``(vec2, len2)`` divided by `c`, rounding # down towards minus infinity whenever the division is not exact. - void _fmpz_vec_scalar_fdiv_q_2exp(fmpz * vec1, const fmpz * vec2, slong len2, ulong exp) + void _fmpz_vec_scalar_fdiv_q_2exp(fmpz * vec1, const fmpz * vec2, slong len2, ulong exp) noexcept # Sets ``(vec1, len2)`` to ``(vec2, len2)`` divided by ``2^exp``, # rounding down towards minus infinity whenever the division is not exact. - void _fmpz_vec_scalar_fdiv_r_2exp(fmpz * vec1, const fmpz * vec2, slong len2, ulong exp) + void _fmpz_vec_scalar_fdiv_r_2exp(fmpz * vec1, const fmpz * vec2, slong len2, ulong exp) noexcept # Sets ``(vec1, len2)`` to the remainder of ``(vec2, len2)`` # divided by ``2^exp``, rounding down the quotient towards minus # infinity whenever the division is not exact. - void _fmpz_vec_scalar_tdiv_q_fmpz(fmpz * vec1, const fmpz * vec2, slong len2, const fmpz_t c) + void _fmpz_vec_scalar_tdiv_q_fmpz(fmpz * vec1, const fmpz * vec2, slong len2, const fmpz_t c) noexcept # Sets ``(vec1, len2)`` to ``(vec2, len2)`` divided by `c`, rounding # towards zero whenever the division is not exact. - void _fmpz_vec_scalar_tdiv_q_si(fmpz * vec1, const fmpz * vec2, slong len2, slong c) + void _fmpz_vec_scalar_tdiv_q_si(fmpz * vec1, const fmpz * vec2, slong len2, slong c) noexcept # Sets ``(vec1, len2)`` to ``(vec2, len2)`` divided by `c`, rounding # towards zero whenever the division is not exact. - void _fmpz_vec_scalar_tdiv_q_ui(fmpz * vec1, const fmpz * vec2, slong len2, ulong c) + void _fmpz_vec_scalar_tdiv_q_ui(fmpz * vec1, const fmpz * vec2, slong len2, ulong c) noexcept # Sets ``(vec1, len2)`` to ``(vec2, len2)`` divided by `c`, rounding # towards zero whenever the division is not exact. - void _fmpz_vec_scalar_tdiv_q_2exp(fmpz * vec1, const fmpz * vec2, slong len2, ulong exp) + void _fmpz_vec_scalar_tdiv_q_2exp(fmpz * vec1, const fmpz * vec2, slong len2, ulong exp) noexcept # Sets ``(vec1, len2)`` to ``(vec2, len2)`` divided by ``2^exp``, # rounding down towards zero whenever the division is not exact. - void _fmpz_vec_scalar_addmul_si(fmpz * vec1, const fmpz * vec2, slong len2, slong c) + void _fmpz_vec_scalar_addmul_si(fmpz * vec1, const fmpz * vec2, slong len2, slong c) noexcept - void _fmpz_vec_scalar_addmul_ui(fmpz * vec1, const fmpz * vec2, slong len2, ulong c) + void _fmpz_vec_scalar_addmul_ui(fmpz * vec1, const fmpz * vec2, slong len2, ulong c) noexcept - void _fmpz_vec_scalar_addmul_fmpz(fmpz * vec1, const fmpz * vec2, slong len2, const fmpz_t c) + void _fmpz_vec_scalar_addmul_fmpz(fmpz * vec1, const fmpz * vec2, slong len2, const fmpz_t c) noexcept # Adds ``(vec2, len2)`` times `c` to ``(vec1, len2)``. - void _fmpz_vec_scalar_addmul_si_2exp(fmpz * vec1, const fmpz * vec2, slong len2, slong c, ulong exp) + void _fmpz_vec_scalar_addmul_si_2exp(fmpz * vec1, const fmpz * vec2, slong len2, slong c, ulong exp) noexcept # Adds ``(vec2, len2)`` times ``c * 2^exp`` to ``(vec1, len2)``, # where `c` is a ``slong``. - void _fmpz_vec_scalar_submul_fmpz(fmpz * vec1, const fmpz * vec2, slong len2, const fmpz_t x) + void _fmpz_vec_scalar_submul_fmpz(fmpz * vec1, const fmpz * vec2, slong len2, const fmpz_t x) noexcept # Subtracts ``(vec2, len2)`` times `c` from ``(vec1, len2)``, # where `c` is a ``fmpz_t``. - void _fmpz_vec_scalar_submul_si(fmpz * vec1, const fmpz * vec2, slong len2, slong c) + void _fmpz_vec_scalar_submul_si(fmpz * vec1, const fmpz * vec2, slong len2, slong c) noexcept # Subtracts ``(vec2, len2)`` times `c` from ``(vec1, len2)``, # where `c` is a ``slong``. - void _fmpz_vec_scalar_submul_si_2exp(fmpz * vec1, const fmpz * vec2, slong len2, slong c, ulong e) + void _fmpz_vec_scalar_submul_si_2exp(fmpz * vec1, const fmpz * vec2, slong len2, slong c, ulong e) noexcept # Subtracts ``(vec2, len2)`` times `c \times 2^e` # from ``(vec1, len2)``, where `c` is a ``slong``. - void _fmpz_vec_sum(fmpz_t res, const fmpz * vec, slong len) + void _fmpz_vec_sum(fmpz_t res, const fmpz * vec, slong len) noexcept # Sets ``res`` to the sum of the entries in ``(vec, len)``. # Aliasing of ``res`` with the entries in ``vec`` is not permitted. - void _fmpz_vec_prod(fmpz_t res, const fmpz * vec, slong len) + void _fmpz_vec_prod(fmpz_t res, const fmpz * vec, slong len) noexcept # Sets ``res`` to the product of the entries in ``(vec, len)``. # Aliasing of ``res`` with the entries in ``vec`` is not permitted. # Uses binary splitting. - void _fmpz_vec_scalar_mod_fmpz(fmpz *res, const fmpz *vec, slong len, const fmpz_t p) + void _fmpz_vec_scalar_mod_fmpz(fmpz *res, const fmpz *vec, slong len, const fmpz_t p) noexcept # Reduces all entries in ``(vec, len)`` modulo `p > 0`. - void _fmpz_vec_scalar_smod_fmpz(fmpz *res, const fmpz *vec, slong len, const fmpz_t p) + void _fmpz_vec_scalar_smod_fmpz(fmpz *res, const fmpz *vec, slong len, const fmpz_t p) noexcept # Reduces all entries in ``(vec, len)`` modulo `p > 0`, choosing # the unique representative in `(-p/2, p/2]`. - void _fmpz_vec_content(fmpz_t res, const fmpz * vec, slong len) + void _fmpz_vec_content(fmpz_t res, const fmpz * vec, slong len) noexcept # Sets ``res`` to the non-negative content of the entries in ``vec``. # The content of a zero vector, including the case when the length is zero, # is defined to be zero. - void _fmpz_vec_content_chained(fmpz_t res, const fmpz * vec, slong len, const fmpz_t input) + void _fmpz_vec_content_chained(fmpz_t res, const fmpz * vec, slong len, const fmpz_t input) noexcept # Sets ``res`` to the non-negative content of ``input`` and the entries in ``vec``. # This is useful for calculating the common content of several vectors. - void _fmpz_vec_lcm(fmpz_t res, const fmpz * vec, slong len) + void _fmpz_vec_lcm(fmpz_t res, const fmpz * vec, slong len) noexcept # Sets ``res`` to the nonnegative least common multiple of the entries # in ``vec``. The least common multiple is zero if any entry in # the vector is zero. The least common multiple of a length zero vector is # defined to be one. - void _fmpz_vec_dot(fmpz_t res, const fmpz * vec1, const fmpz * vec2, slong len2) + void _fmpz_vec_dot(fmpz_t res, const fmpz * vec1, const fmpz * vec2, slong len2) noexcept # Sets ``res`` to the dot product of ``(vec1, len2)`` and # ``(vec2, len2)``. - void _fmpz_vec_dot_ptr(fmpz_t res, const fmpz * vec1, fmpz ** const vec2, slong offset, slong len) + void _fmpz_vec_dot_ptr(fmpz_t res, const fmpz * vec1, fmpz ** const vec2, slong offset, slong len) noexcept # Sets ``res`` to the dot product of ``len`` values at ``vec1`` and the # ``len`` values ``vec2[i] + offset`` for `0 \leq i < len`. diff --git a/src/sage/libs/flint/fmpzi.pxd b/src/sage/libs/flint/fmpzi.pxd index 90c103bf7dd..8020b2408a3 100644 --- a/src/sage/libs/flint/fmpzi.pxd +++ b/src/sage/libs/flint/fmpzi.pxd @@ -12,77 +12,77 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void fmpzi_init(fmpzi_t x) + void fmpzi_init(fmpzi_t x) noexcept - void fmpzi_clear(fmpzi_t x) + void fmpzi_clear(fmpzi_t x) noexcept - void fmpzi_swap(fmpzi_t x, fmpzi_t y) + void fmpzi_swap(fmpzi_t x, fmpzi_t y) noexcept - void fmpzi_zero(fmpzi_t x) + void fmpzi_zero(fmpzi_t x) noexcept - void fmpzi_one(fmpzi_t x) + void fmpzi_one(fmpzi_t x) noexcept - void fmpzi_set(fmpzi_t res, const fmpzi_t x) + void fmpzi_set(fmpzi_t res, const fmpzi_t x) noexcept - void fmpzi_set_si_si(fmpzi_t res, slong a, slong b) + void fmpzi_set_si_si(fmpzi_t res, slong a, slong b) noexcept - void fmpzi_print(const fmpzi_t x) + void fmpzi_print(const fmpzi_t x) noexcept - void fmpzi_randtest(fmpzi_t res, flint_rand_t state, mp_bitcnt_t bits) + void fmpzi_randtest(fmpzi_t res, flint_rand_t state, mp_bitcnt_t bits) noexcept - bint fmpzi_equal(const fmpzi_t x, const fmpzi_t y) + bint fmpzi_equal(const fmpzi_t x, const fmpzi_t y) noexcept - bint fmpzi_is_zero(const fmpzi_t x) + bint fmpzi_is_zero(const fmpzi_t x) noexcept - bint fmpzi_is_one(const fmpzi_t x) + bint fmpzi_is_one(const fmpzi_t x) noexcept - bint fmpzi_is_unit(const fmpzi_t x) + bint fmpzi_is_unit(const fmpzi_t x) noexcept - slong fmpzi_canonical_unit_i_pow(const fmpzi_t x) + slong fmpzi_canonical_unit_i_pow(const fmpzi_t x) noexcept - void fmpzi_canonicalise_unit(fmpzi_t res, const fmpzi_t x) + void fmpzi_canonicalise_unit(fmpzi_t res, const fmpzi_t x) noexcept - slong fmpzi_bits(const fmpzi_t x) + slong fmpzi_bits(const fmpzi_t x) noexcept - void fmpzi_norm(fmpz_t res, const fmpzi_t x) + void fmpzi_norm(fmpz_t res, const fmpzi_t x) noexcept - void fmpzi_conj(fmpzi_t res, const fmpzi_t x) + void fmpzi_conj(fmpzi_t res, const fmpzi_t x) noexcept - void fmpzi_neg(fmpzi_t res, const fmpzi_t x) + void fmpzi_neg(fmpzi_t res, const fmpzi_t x) noexcept - void fmpzi_add(fmpzi_t res, const fmpzi_t x, const fmpzi_t y) + void fmpzi_add(fmpzi_t res, const fmpzi_t x, const fmpzi_t y) noexcept - void fmpzi_sub(fmpzi_t res, const fmpzi_t x, const fmpzi_t y) + void fmpzi_sub(fmpzi_t res, const fmpzi_t x, const fmpzi_t y) noexcept - void fmpzi_sqr(fmpzi_t res, const fmpzi_t x) + void fmpzi_sqr(fmpzi_t res, const fmpzi_t x) noexcept - void fmpzi_mul(fmpzi_t res, const fmpzi_t x, const fmpzi_t y) + void fmpzi_mul(fmpzi_t res, const fmpzi_t x, const fmpzi_t y) noexcept - void fmpzi_pow_ui(fmpzi_t res, const fmpzi_t x, ulong exp) + void fmpzi_pow_ui(fmpzi_t res, const fmpzi_t x, ulong exp) noexcept - void fmpzi_divexact(fmpzi_t q, const fmpzi_t x, const fmpzi_t y) + void fmpzi_divexact(fmpzi_t q, const fmpzi_t x, const fmpzi_t y) noexcept # Sets *q* to the quotient of *x* and *y*, assuming that the # division is exact. - void fmpzi_divrem(fmpzi_t q, fmpzi_t r, const fmpzi_t x, const fmpzi_t y) + void fmpzi_divrem(fmpzi_t q, fmpzi_t r, const fmpzi_t x, const fmpzi_t y) noexcept # Computes a quotient and remainder satisfying # `x = q y + r` with `N(r) \le N(y)/2`, with a canonical # choice of remainder when breaking ties. - void fmpzi_divrem_approx(fmpzi_t q, fmpzi_t r, const fmpzi_t x, const fmpzi_t y) + void fmpzi_divrem_approx(fmpzi_t q, fmpzi_t r, const fmpzi_t x, const fmpzi_t y) noexcept # Computes a quotient and remainder satisfying # `x = q y + r` with `N(r) < N(y)`, with an implementation-defined, # non-canonical choice of remainder. - slong fmpzi_remove_one_plus_i(fmpzi_t res, const fmpzi_t x) + slong fmpzi_remove_one_plus_i(fmpzi_t res, const fmpzi_t x) noexcept # Divide *x* exactly by the largest possible power `(1+i)^k` # and return the exponent *k*. - void fmpzi_gcd_euclidean(fmpzi_t res, const fmpzi_t x, const fmpzi_t y) - void fmpzi_gcd_euclidean_improved(fmpzi_t res, const fmpzi_t x, const fmpzi_t y) - void fmpzi_gcd_binary(fmpzi_t res, const fmpzi_t x, const fmpzi_t y) - void fmpzi_gcd_shortest(fmpzi_t res, const fmpzi_t x, const fmpzi_t y) - void fmpzi_gcd(fmpzi_t res, const fmpzi_t x, const fmpzi_t y) + void fmpzi_gcd_euclidean(fmpzi_t res, const fmpzi_t x, const fmpzi_t y) noexcept + void fmpzi_gcd_euclidean_improved(fmpzi_t res, const fmpzi_t x, const fmpzi_t y) noexcept + void fmpzi_gcd_binary(fmpzi_t res, const fmpzi_t x, const fmpzi_t y) noexcept + void fmpzi_gcd_shortest(fmpzi_t res, const fmpzi_t x, const fmpzi_t y) noexcept + void fmpzi_gcd(fmpzi_t res, const fmpzi_t x, const fmpzi_t y) noexcept # Computes the GCD of *x* and *y*. The result is in canonical # unit form. # The *euclidean* version is a straightforward implementation diff --git a/src/sage/libs/flint/fq.pxd b/src/sage/libs/flint/fq.pxd index f94f23043f9..0d893d4565b 100644 --- a/src/sage/libs/flint/fq.pxd +++ b/src/sage/libs/flint/fq.pxd @@ -12,7 +12,7 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void fq_ctx_init(fq_ctx_t ctx, const fmpz_t p, slong d, const char *var) + void fq_ctx_init(fq_ctx_t ctx, const fmpz_t p, slong d, const char *var) noexcept # Initialises the context for prime `p` and extension degree `d`, # with name ``var`` for the generator. By default, it will try # use a Conway polynomial; if one is not available, a random @@ -21,7 +21,7 @@ cdef extern from "flint_wrap.h": # Assumes that the string ``var`` is a null-terminated string # of length at least one. - int _fq_ctx_init_conway(fq_ctx_t ctx, const fmpz_t p, slong d, const char *var) + int _fq_ctx_init_conway(fq_ctx_t ctx, const fmpz_t p, slong d, const char *var) noexcept # Attempts to initialise the context for prime `p` and extension # degree `d`, with name ``var`` for the generator using a Conway # polynomial for the modulus. @@ -32,7 +32,7 @@ cdef extern from "flint_wrap.h": # Assumes that the string ``var`` is a null-terminated string # of length at least one. - void fq_ctx_init_conway(fq_ctx_t ctx, const fmpz_t p, slong d, const char *var) + void fq_ctx_init_conway(fq_ctx_t ctx, const fmpz_t p, slong d, const char *var) noexcept # Initialises the context for prime `p` and extension degree `d`, # with name ``var`` for the generator using a Conway polynomial # for the modulus. @@ -40,122 +40,122 @@ cdef extern from "flint_wrap.h": # Assumes that the string ``var`` is a null-terminated string # of length at least one. - void fq_ctx_init_modulus(fq_ctx_t ctx, const fmpz_mod_poly_t modulus, const fmpz_mod_ctx_t ctxp, const char *var) + void fq_ctx_init_modulus(fq_ctx_t ctx, const fmpz_mod_poly_t modulus, const fmpz_mod_ctx_t ctxp, const char *var) noexcept # Initialises the context for given ``modulus`` with name # ``var`` for the generator. # Assumes that ``modulus`` is an irreducible polynomial over the finite field `\mathbf{F}_{p}` in ``ctxp``. # Assumes that the string ``var`` is a null-terminated string # of length at least one. - void fq_ctx_clear(fq_ctx_t ctx) + void fq_ctx_clear(fq_ctx_t ctx) noexcept # Clears all memory that has been allocated as part of the context. - const fmpz_mod_poly_struct* fq_ctx_modulus(const fq_ctx_t ctx) + const fmpz_mod_poly_struct* fq_ctx_modulus(const fq_ctx_t ctx) noexcept # Returns a pointer to the modulus in the context. - slong fq_ctx_degree(const fq_ctx_t ctx) + slong fq_ctx_degree(const fq_ctx_t ctx) noexcept # Returns the degree of the field extension # `[\mathbf{F}_{q} : \mathbf{F}_{p}]`, which # is equal to `\log_{p} q`. - const fmpz * fq_ctx_prime(const fq_ctx_t ctx) + const fmpz * fq_ctx_prime(const fq_ctx_t ctx) noexcept # Returns a pointer to the prime `p` in the context. - void fq_ctx_order(fmpz_t f, const fq_ctx_t ctx) + void fq_ctx_order(fmpz_t f, const fq_ctx_t ctx) noexcept # Sets `f` to be the size of the finite field. - int fq_ctx_fprint(FILE * file, const fq_ctx_t ctx) + int fq_ctx_fprint(FILE * file, const fq_ctx_t ctx) noexcept # Prints the context information to ``file``. Returns 1 for a # success and a negative number for an error. - void fq_ctx_print(const fq_ctx_t ctx) + void fq_ctx_print(const fq_ctx_t ctx) noexcept # Prints the context information to ``stdout``. - void fq_ctx_randtest(fq_ctx_t ctx, flint_rand_t state) + void fq_ctx_randtest(fq_ctx_t ctx, flint_rand_t state) noexcept # Initializes ``ctx`` to a random finite field. Assumes that # ``fq_ctx_init`` has not been called on ``ctx`` already. - void fq_ctx_randtest_reducible(fq_ctx_t ctx, flint_rand_t state) + void fq_ctx_randtest_reducible(fq_ctx_t ctx, flint_rand_t state) noexcept # Initializes ``ctx`` to a random extension of a prime field. # The modulus may or may not be irreducible. Assumes that # ``fq_ctx_init`` has not been called on ``ctx`` already. - void fq_init(fq_t rop, const fq_ctx_t ctx) + void fq_init(fq_t rop, const fq_ctx_t ctx) noexcept # Initialises the element ``rop``, setting its value to `0`. - void fq_init2(fq_t rop, const fq_ctx_t ctx) + void fq_init2(fq_t rop, const fq_ctx_t ctx) noexcept # Initialises ``poly`` with at least enough space for it to be an element # of ``ctx`` and sets it to `0`. - void fq_clear(fq_t rop, const fq_ctx_t ctx) + void fq_clear(fq_t rop, const fq_ctx_t ctx) noexcept # Clears the element ``rop``. - void _fq_sparse_reduce(fmpz *R, slong lenR, const fq_ctx_t ctx) + void _fq_sparse_reduce(fmpz *R, slong lenR, const fq_ctx_t ctx) noexcept # Reduces ``(R, lenR)`` modulo the polynomial `f` given by the # modulus of ``ctx``. - void _fq_dense_reduce(fmpz *R, slong lenR, const fq_ctx_t ctx) + void _fq_dense_reduce(fmpz *R, slong lenR, const fq_ctx_t ctx) noexcept # Reduces ``(R, lenR)`` modulo the polynomial `f` given by the # modulus of ``ctx`` using Newton division. - void _fq_reduce(fmpz *r, slong lenR, const fq_ctx_t ctx) + void _fq_reduce(fmpz *r, slong lenR, const fq_ctx_t ctx) noexcept # Reduces ``(R, lenR)`` modulo the polynomial `f` given by the # modulus of ``ctx``. Does either sparse or dense reduction # based on ``ctx->sparse_modulus``. - void fq_reduce(fq_t rop, const fq_ctx_t ctx) + void fq_reduce(fq_t rop, const fq_ctx_t ctx) noexcept # Reduces the polynomial ``rop`` as an element of # `\mathbf{F}_p[X] / (f(X))`. - void fq_add(fq_t rop, const fq_t op1, const fq_t op2, const fq_ctx_t ctx) + void fq_add(fq_t rop, const fq_t op1, const fq_t op2, const fq_ctx_t ctx) noexcept # Sets ``rop`` to the sum of ``op1`` and ``op2``. - void fq_sub(fq_t rop, const fq_t op1, const fq_t op2, const fq_ctx_t ctx) + void fq_sub(fq_t rop, const fq_t op1, const fq_t op2, const fq_ctx_t ctx) noexcept # Sets ``rop`` to the difference of ``op1`` and ``op2``. - void fq_sub_one(fq_t rop, const fq_t op1, const fq_ctx_t ctx) + void fq_sub_one(fq_t rop, const fq_t op1, const fq_ctx_t ctx) noexcept # Sets ``rop`` to the difference of ``op1`` and `1`. - void fq_neg(fq_t rop, const fq_t op, const fq_ctx_t ctx) + void fq_neg(fq_t rop, const fq_t op, const fq_ctx_t ctx) noexcept # Sets ``rop`` to the negative of ``op``. - void fq_mul(fq_t rop, const fq_t op1, const fq_t op2, const fq_ctx_t ctx) + void fq_mul(fq_t rop, const fq_t op1, const fq_t op2, const fq_ctx_t ctx) noexcept # Sets ``rop`` to the product of ``op1`` and ``op2``, # reducing the output in the given context. - void fq_mul_fmpz(fq_t rop, const fq_t op, const fmpz_t x, const fq_ctx_t ctx) + void fq_mul_fmpz(fq_t rop, const fq_t op, const fmpz_t x, const fq_ctx_t ctx) noexcept # Sets ``rop`` to the product of ``op`` and `x`, # reducing the output in the given context. - void fq_mul_si(fq_t rop, const fq_t op, slong x, const fq_ctx_t ctx) + void fq_mul_si(fq_t rop, const fq_t op, slong x, const fq_ctx_t ctx) noexcept # Sets ``rop`` to the product of ``op`` and `x`, # reducing the output in the given context. - void fq_mul_ui(fq_t rop, const fq_t op, ulong x, const fq_ctx_t ctx) + void fq_mul_ui(fq_t rop, const fq_t op, ulong x, const fq_ctx_t ctx) noexcept # Sets ``rop`` to the product of ``op`` and `x`, # reducing the output in the given context. - void fq_sqr(fq_t rop, const fq_t op, const fq_ctx_t ctx) + void fq_sqr(fq_t rop, const fq_t op, const fq_ctx_t ctx) noexcept # Sets ``rop`` to the square of ``op``, # reducing the output in the given context. - void fq_div(fq_t rop, const fq_t op1, const fq_t op2, const fq_ctx_t ctx) + void fq_div(fq_t rop, const fq_t op1, const fq_t op2, const fq_ctx_t ctx) noexcept # Sets ``rop`` to the quotient of ``op1`` and ``op2``, # reducing the output in the given context. - void _fq_inv(fmpz *rop, const fmpz *op, slong len, const fq_ctx_t ctx) + void _fq_inv(fmpz *rop, const fmpz *op, slong len, const fq_ctx_t ctx) noexcept # Sets ``(rop, d)`` to the inverse of the non-zero element # ``(op, len)``. - void fq_inv(fq_t rop, const fq_t op, const fq_ctx_t ctx) + void fq_inv(fq_t rop, const fq_t op, const fq_ctx_t ctx) noexcept # Sets ``rop`` to the inverse of the non-zero element ``op``. - void fq_gcdinv(fq_t f, fq_t inv, const fq_t op, const fq_ctx_t ctx) + void fq_gcdinv(fq_t f, fq_t inv, const fq_t op, const fq_ctx_t ctx) noexcept # Sets ``inv`` to be the inverse of ``op`` modulo the modulus # of ``ctx``. If ``op`` is not invertible, then ``f`` is # set to a factor of the modulus; otherwise, it is set to one. - void _fq_pow(fmpz *rop, const fmpz *op, slong len, const fmpz_t e, const fq_ctx_t ctx) + void _fq_pow(fmpz *rop, const fmpz *op, slong len, const fmpz_t e, const fq_ctx_t ctx) noexcept # Sets ``(rop, 2*d-1)`` to ``(op,len)`` raised to the power `e`, # reduced modulo `f(X)`, the modulus of ``ctx``. # Assumes that `e \geq 0` and that ``len`` is positive and at most `d`. @@ -164,148 +164,148 @@ cdef extern from "flint_wrap.h": # `f(X)`, which is a polynomial of degree `d`. # Does not support aliasing. - void fq_pow(fq_t rop, const fq_t op, const fmpz_t e, const fq_ctx_t ctx) + void fq_pow(fq_t rop, const fq_t op, const fmpz_t e, const fq_ctx_t ctx) noexcept # Sets ``rop`` the ``op`` raised to the power `e`. # Currently assumes that `e \geq 0`. # Note that for any input ``op``, ``rop`` is set to `1` # whenever `e = 0`. - void fq_pow_ui(fq_t rop, const fq_t op, const ulong e, const fq_ctx_t ctx) + void fq_pow_ui(fq_t rop, const fq_t op, const ulong e, const fq_ctx_t ctx) noexcept # Sets ``rop`` the ``op`` raised to the power `e`. # Currently assumes that `e \geq 0`. # Note that for any input ``op``, ``rop`` is set to `1` # whenever `e = 0`. - int fq_sqrt(fq_t rop, const fq_t op1, const fq_ctx_t ctx) + int fq_sqrt(fq_t rop, const fq_t op1, const fq_ctx_t ctx) noexcept # Sets ``rop`` to the square root of ``op1`` if it is a square, and return # `1`, otherwise return `0`. - void fq_pth_root(fq_t rop, const fq_t op1, const fq_ctx_t ctx) + void fq_pth_root(fq_t rop, const fq_t op1, const fq_ctx_t ctx) noexcept # Sets ``rop`` to a `p^{th}` root root of ``op1``. Currently, # this computes the root by raising ``op1`` to `p^{d-1}` where # `d` is the degree of the extension. - bint fq_is_square(const fq_t op, const fq_ctx_t ctx) + bint fq_is_square(const fq_t op, const fq_ctx_t ctx) noexcept # Return ``1`` if ``op`` is a square. - int fq_fprint_pretty(FILE *file, const fq_t op, const fq_ctx_t ctx) + int fq_fprint_pretty(FILE *file, const fq_t op, const fq_ctx_t ctx) noexcept # Prints a pretty representation of ``op`` to ``file``. # In the current implementation, always returns `1`. The return code is # part of the function's signature to allow for a later implementation to # return the number of characters printed or a non-positive error code. - int fq_print_pretty(const fq_t op, const fq_ctx_t ctx) + int fq_print_pretty(const fq_t op, const fq_ctx_t ctx) noexcept # Prints a pretty representation of ``op`` to ``stdout``. # In the current implementation, always returns `1`. The return code is # part of the function's signature to allow for a later implementation to # return the number of characters printed or a non-positive error code. - int fq_fprint(FILE * file, const fq_t op, const fq_ctx_t ctx) + int fq_fprint(FILE * file, const fq_t op, const fq_ctx_t ctx) noexcept # Prints a representation of ``op`` to ``file``. # For further details on the representation used, see # :func:`fmpz_mod_poly_fprint`. - void fq_print(const fq_t op, const fq_ctx_t ctx) + void fq_print(const fq_t op, const fq_ctx_t ctx) noexcept # Prints a representation of ``op`` to ``stdout``. # For further details on the representation used, see # :func:`fmpz_mod_poly_print`. - char * fq_get_str(const fq_t op, const fq_ctx_t ctx) + char * fq_get_str(const fq_t op, const fq_ctx_t ctx) noexcept # Returns the plain FLINT string representation of the element # ``op``. - char * fq_get_str_pretty(const fq_t op, const fq_ctx_t ctx) + char * fq_get_str_pretty(const fq_t op, const fq_ctx_t ctx) noexcept # Returns a pretty representation of the element ``op`` using the # null-terminated string ``x`` as the variable name. - void fq_randtest(fq_t rop, flint_rand_t state, const fq_ctx_t ctx) + void fq_randtest(fq_t rop, flint_rand_t state, const fq_ctx_t ctx) noexcept # Generates a random element of `\mathbf{F}_q`. - void fq_randtest_not_zero(fq_t rop, flint_rand_t state, const fq_ctx_t ctx) + void fq_randtest_not_zero(fq_t rop, flint_rand_t state, const fq_ctx_t ctx) noexcept # Generates a random non-zero element of `\mathbf{F}_q`. - void fq_randtest_dense(fq_t rop, flint_rand_t state, const fq_ctx_t ctx) + void fq_randtest_dense(fq_t rop, flint_rand_t state, const fq_ctx_t ctx) noexcept # Generates a random element of `\mathbf{F}_q` which has an # underlying polynomial with dense coefficients. - void fq_rand(fq_t rop, flint_rand_t state, const fq_ctx_t ctx) + void fq_rand(fq_t rop, flint_rand_t state, const fq_ctx_t ctx) noexcept # Generates a high quality random element of `\mathbf{F}_q`. - void fq_rand_not_zero(fq_t rop, flint_rand_t state, const fq_ctx_t ctx) + void fq_rand_not_zero(fq_t rop, flint_rand_t state, const fq_ctx_t ctx) noexcept # Generates a high quality non-zero random element of `\mathbf{F}_q`. - void fq_set(fq_t rop, const fq_t op, const fq_ctx_t ctx) + void fq_set(fq_t rop, const fq_t op, const fq_ctx_t ctx) noexcept # Sets ``rop`` to ``op``. - void fq_set_si(fq_t rop, const slong x, const fq_ctx_t ctx) + void fq_set_si(fq_t rop, const slong x, const fq_ctx_t ctx) noexcept # Sets ``rop`` to ``x``, considered as an element of # `\mathbf{F}_p`. - void fq_set_ui(fq_t rop, const ulong x, const fq_ctx_t ctx) + void fq_set_ui(fq_t rop, const ulong x, const fq_ctx_t ctx) noexcept # Sets ``rop`` to ``x``, considered as an element of # `\mathbf{F}_p`. - void fq_set_fmpz(fq_t rop, const fmpz_t x, const fq_ctx_t ctx) + void fq_set_fmpz(fq_t rop, const fmpz_t x, const fq_ctx_t ctx) noexcept # Sets ``rop`` to ``x``, considered as an element of # `\mathbf{F}_p`. - void fq_swap(fq_t op1, fq_t op2, const fq_ctx_t ctx) + void fq_swap(fq_t op1, fq_t op2, const fq_ctx_t ctx) noexcept # Swaps the two elements ``op1`` and ``op2``. - void fq_zero(fq_t rop, const fq_ctx_t ctx) + void fq_zero(fq_t rop, const fq_ctx_t ctx) noexcept # Sets ``rop`` to zero. - void fq_one(fq_t rop, const fq_ctx_t ctx) + void fq_one(fq_t rop, const fq_ctx_t ctx) noexcept # Sets ``rop`` to one, reduced in the given context. - void fq_gen(fq_t rop, const fq_ctx_t ctx) + void fq_gen(fq_t rop, const fq_ctx_t ctx) noexcept # Sets ``rop`` to a generator for the finite field. # There is no guarantee this is a multiplicative generator of # the finite field. - int fq_get_fmpz(fmpz_t rop, const fq_t op, const fq_ctx_t ctx) + int fq_get_fmpz(fmpz_t rop, const fq_t op, const fq_ctx_t ctx) noexcept # If ``op`` has a lift to the integers, return `1` and set ``rop`` to the lift in `[0,p)`. # Otherwise, return `0` and leave `rop` undefined. - void fq_get_fmpz_poly(fmpz_poly_t a, const fq_t b, const fq_ctx_t ctx) + void fq_get_fmpz_poly(fmpz_poly_t a, const fq_t b, const fq_ctx_t ctx) noexcept - void fq_get_fmpz_mod_poly(fmpz_mod_poly_t a, const fq_t b, const fq_ctx_t ctx) + void fq_get_fmpz_mod_poly(fmpz_mod_poly_t a, const fq_t b, const fq_ctx_t ctx) noexcept # Set ``a`` to a representative of ``b`` in ``ctx``. # The representatives are taken in `(\mathbb{Z}/p\mathbb{Z})[x]/h(x)` where `h(x)` is the defining polynomial in ``ctx``. - void fq_set_fmpz_poly(fq_t a, const fmpz_poly_t b, const fq_ctx_t ctx) + void fq_set_fmpz_poly(fq_t a, const fmpz_poly_t b, const fq_ctx_t ctx) noexcept - void fq_set_fmpz_mod_poly(fq_t a, const fmpz_mod_poly_t b, const fq_ctx_t ctx) + void fq_set_fmpz_mod_poly(fq_t a, const fmpz_mod_poly_t b, const fq_ctx_t ctx) noexcept # Set ``a`` to the element in ``ctx`` with representative ``b``. # The representatives are taken in `(\mathbb{Z}/p\mathbb{Z})[x]/h(x)` where `h(x)` is the defining polynomial in ``ctx``. - void fq_get_fmpz_mod_mat(fmpz_mod_mat_t col, const fq_t a, const fq_ctx_t ctx) + void fq_get_fmpz_mod_mat(fmpz_mod_mat_t col, const fq_t a, const fq_ctx_t ctx) noexcept # Convert ``a`` to a column vector of length ``degree(ctx)``. - void fq_set_fmpz_mod_mat(fq_t a, const fmpz_mod_mat_t col, const fq_ctx_t ctx) + void fq_set_fmpz_mod_mat(fq_t a, const fmpz_mod_mat_t col, const fq_ctx_t ctx) noexcept # Convert a column vector ``col`` of length ``degree(ctx)`` to an element of ``ctx``. - bint fq_is_zero(const fq_t op, const fq_ctx_t ctx) + bint fq_is_zero(const fq_t op, const fq_ctx_t ctx) noexcept # Returns whether ``op`` is equal to zero. - bint fq_is_one(const fq_t op, const fq_ctx_t ctx) + bint fq_is_one(const fq_t op, const fq_ctx_t ctx) noexcept # Returns whether ``op`` is equal to one. - bint fq_equal(const fq_t op1, const fq_t op2, const fq_ctx_t ctx) + bint fq_equal(const fq_t op1, const fq_t op2, const fq_ctx_t ctx) noexcept # Returns whether ``op1`` and ``op2`` are equal. - bint fq_is_invertible(const fq_t op, const fq_ctx_t ctx) + bint fq_is_invertible(const fq_t op, const fq_ctx_t ctx) noexcept # Returns whether ``op`` is an invertible element. - bint fq_is_invertible_f(fq_t f, const fq_t op, const fq_ctx_t ctx) + bint fq_is_invertible_f(fq_t f, const fq_t op, const fq_ctx_t ctx) noexcept # Returns whether ``op`` is an invertible element. If it is not, # then ``f`` is set of a factor of the modulus. - void _fq_trace(fmpz_t rop, const fmpz *op, slong len, const fq_ctx_t ctx) + void _fq_trace(fmpz_t rop, const fmpz *op, slong len, const fq_ctx_t ctx) noexcept # Sets ``rop`` to the trace of the non-zero element ``(op, len)`` # in `\mathbf{F}_{q}`. - void fq_trace(fmpz_t rop, const fq_t op, const fq_ctx_t ctx) + void fq_trace(fmpz_t rop, const fq_t op, const fq_ctx_t ctx) noexcept # Sets ``rop`` to the trace of ``op``. # For an element `a \in \mathbf{F}_q`, multiplication by `a` defines # a `\mathbf{F}_p`-linear map on `\mathbf{F}_q`. We define the @@ -314,11 +314,11 @@ cdef extern from "flint_wrap.h": # `a` is equal to `\sum_{i=0}^{d-1} \Sigma^i (a)`, where `d = # \log_{p} q`. - void _fq_norm(fmpz_t rop, const fmpz *op, slong len, const fq_ctx_t ctx) + void _fq_norm(fmpz_t rop, const fmpz *op, slong len, const fq_ctx_t ctx) noexcept # Sets ``rop`` to the norm of the non-zero element ``(op, len)`` # in `\mathbf{F}_{q}`. - void fq_norm(fmpz_t rop, const fq_t op, const fq_ctx_t ctx) + void fq_norm(fmpz_t rop, const fq_t op, const fq_ctx_t ctx) noexcept # Computes the norm of ``op``. # For an element `a \in \mathbf{F}_q`, multiplication by `a` defines # a `\mathbf{F}_p`-linear map on `\mathbf{F}_q`. We define the norm @@ -328,12 +328,12 @@ cdef extern from "flint_wrap.h": # `d = \text{dim}_{\mathbf{F}_p}(\mathbf{F}_q)`. # Algorithm selection is automatic depending on the input. - void _fq_frobenius(fmpz *rop, const fmpz *op, slong len, slong e, const fq_ctx_t ctx) + void _fq_frobenius(fmpz *rop, const fmpz *op, slong len, slong e, const fq_ctx_t ctx) noexcept # Sets ``(rop, 2d-1)`` to the image of ``(op, len)`` under the # Frobenius operator raised to the e-th power, assuming that neither # ``op`` nor ``e`` are zero. - void fq_frobenius(fq_t rop, const fq_t op, slong e, const fq_ctx_t ctx) + void fq_frobenius(fq_t rop, const fq_t op, slong e, const fq_ctx_t ctx) noexcept # Evaluates the homomorphism `\Sigma^e` at ``op``. # Recall that `\mathbf{F}_q / \mathbf{F}_p` is Galois with Galois group # `\langle \sigma \rangle`, which is also isomorphic to @@ -341,7 +341,7 @@ cdef extern from "flint_wrap.h": # `\sigma \in \operatorname{Gal}(\mathbf{F}_q/\mathbf{F}_p)` is the Frobenius element # `\sigma \colon x \mapsto x^p`. - int fq_multiplicative_order(fmpz * ord, const fq_t op, const fq_ctx_t ctx) + int fq_multiplicative_order(fmpz * ord, const fq_t op, const fq_ctx_t ctx) noexcept # Computes the order of ``op`` as an element of the # multiplicative group of ``ctx``. # Returns 0 if ``op`` is 0, otherwise it returns 1 if ``op`` @@ -349,15 +349,15 @@ cdef extern from "flint_wrap.h": # This function can also be used to check primitivity of a generator of # a finite field whose defining polynomial is not primitive. - bint fq_is_primitive(const fq_t op, const fq_ctx_t ctx) + bint fq_is_primitive(const fq_t op, const fq_ctx_t ctx) noexcept # Returns whether ``op`` is primitive, i.e., whether it is a # generator of the multiplicative group of ``ctx``. - void fq_bit_pack(fmpz_t f, const fq_t op, flint_bitcnt_t bit_size, const fq_ctx_t ctx) + void fq_bit_pack(fmpz_t f, const fq_t op, flint_bitcnt_t bit_size, const fq_ctx_t ctx) noexcept # Packs ``op`` into bitfields of size ``bit_size``, writing the # result to ``f``. - void fq_bit_unpack(fq_t rop, const fmpz_t f, flint_bitcnt_t bit_size, const fq_ctx_t ctx) + void fq_bit_unpack(fq_t rop, const fmpz_t f, flint_bitcnt_t bit_size, const fq_ctx_t ctx) noexcept # Unpacks into ``rop`` the element with coefficients packed into # fields of size ``bit_size`` as represented by the integer # ``f``. diff --git a/src/sage/libs/flint/fq_default.pxd b/src/sage/libs/flint/fq_default.pxd index c85ec98d7dc..f24158f21d3 100644 --- a/src/sage/libs/flint/fq_default.pxd +++ b/src/sage/libs/flint/fq_default.pxd @@ -12,7 +12,7 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void fq_default_ctx_init(fq_default_ctx_t ctx, const fmpz_t p, slong d, const char * var) + void fq_default_ctx_init(fq_default_ctx_t ctx, const fmpz_t p, slong d, const char * var) noexcept # Initialises the context for prime `p` and extension degree `d`, # with name ``var`` for the generator. By default, it will try # use a Conway polynomial; if one is not available, a random @@ -21,13 +21,13 @@ cdef extern from "flint_wrap.h": # Assumes that the string ``var`` is a null-terminated string # of length at least one. - void fq_default_ctx_init_type(fq_default_ctx_t ctx, const fmpz_t p, slong d, const char * var, int type) + void fq_default_ctx_init_type(fq_default_ctx_t ctx, const fmpz_t p, slong d, const char * var, int type) noexcept # As per the previous function except that if ``type == 1`` an ``fq_zech`` # context is created, if ``type == 2`` an ``fq_nmod`` and if ``type == 3`` # an ``fq``. If ``type == 0`` the functionality is as per the previous # function. - void fq_default_ctx_init_modulus(fq_default_ctx_t ctx, const fmpz_mod_poly_t modulus, fmpz_mod_ctx_t mod_ctx, const char * var) + void fq_default_ctx_init_modulus(fq_default_ctx_t ctx, const fmpz_mod_poly_t modulus, fmpz_mod_ctx_t mod_ctx, const char * var) noexcept # Initialises the context for the finite field defined by the given # polynomial ``modulus``. The characteristic will be the modulus of # the polynomial and the degree equal to its degree. @@ -35,13 +35,13 @@ cdef extern from "flint_wrap.h": # Assumes that the string ``var`` is a null-terminated string # of length at least one. - void fq_default_ctx_init_modulus_type(fq_default_ctx_t ctx, const fmpz_mod_poly_t modulus, fmpz_mod_ctx_t mod_ctx, const char * var, int type) + void fq_default_ctx_init_modulus_type(fq_default_ctx_t ctx, const fmpz_mod_poly_t modulus, fmpz_mod_ctx_t mod_ctx, const char * var, int type) noexcept # As per the previous function except that if ``type == 1`` an ``fq_zech`` # context is created, if ``type == 2`` an ``fq_nmod`` and if ``type == 3`` # an ``fq``. If ``type == 0`` the functionality is as per the previous # function. - void fq_default_ctx_init_modulus_nmod(fq_default_ctx_t ctx, const nmod_poly_t modulus, const char * var) + void fq_default_ctx_init_modulus_nmod(fq_default_ctx_t ctx, const nmod_poly_t modulus, const char * var) noexcept # Initialises the context for the finite field defined by the given # polynomial ``modulus``. The characteristic will be the modulus of # the polynomial and the degree equal to its degree. @@ -49,235 +49,235 @@ cdef extern from "flint_wrap.h": # Assumes that the string ``var`` is a null-terminated string # of length at least one. - void fq_default_ctx_init_modulus_nmod_type(fq_default_ctx_t ctx, const nmod_poly_t modulus, const char * var, int type) + void fq_default_ctx_init_modulus_nmod_type(fq_default_ctx_t ctx, const nmod_poly_t modulus, const char * var, int type) noexcept # As per the previous function except that if ``type == 1`` an ``fq_zech`` # context is created, if ``type == 2`` an ``fq_nmod`` and if ``type == 3`` # an ``fq``. If ``type == 0`` the functionality is as per the previous # function. - void fq_default_ctx_clear(fq_default_ctx_t ctx) + void fq_default_ctx_clear(fq_default_ctx_t ctx) noexcept # Clears all memory that has been allocated as part of the context. - int fq_default_ctx_type(const fq_default_ctx_t ctx) + int fq_default_ctx_type(const fq_default_ctx_t ctx) noexcept # Returns `1` if the context contains an ``fq_zech`` context, `2` if it # contains an ``fq_mod`` context and `3` if it contains an ``fq`` context. - slong fq_default_ctx_degree(const fq_default_ctx_t ctx) + slong fq_default_ctx_degree(const fq_default_ctx_t ctx) noexcept # Returns the degree of the field extension # `[\mathbf{F}_{q} : \mathbf{F}_{p}]`, which # is equal to `\log_{p} q`. - void fq_default_ctx_prime(fmpz_t prime, const fq_default_ctx_t ctx) + void fq_default_ctx_prime(fmpz_t prime, const fq_default_ctx_t ctx) noexcept # Sets `prime` to the prime `p` in the context. - void fq_default_ctx_order(fmpz_t f, const fq_default_ctx_t ctx) + void fq_default_ctx_order(fmpz_t f, const fq_default_ctx_t ctx) noexcept # Sets `f` to be the size of the finite field. - void fq_default_ctx_modulus(fmpz_mod_poly_t p, const fq_default_ctx_t ctx) + void fq_default_ctx_modulus(fmpz_mod_poly_t p, const fq_default_ctx_t ctx) noexcept # Sets `p` to the defining polynomial of the finite field.. - int fq_default_ctx_fprint(FILE * file, const fq_default_ctx_t ctx) + int fq_default_ctx_fprint(FILE * file, const fq_default_ctx_t ctx) noexcept # Prints the context information to ``file``. Returns 1 for a # success and a negative number for an error. - void fq_default_ctx_print(const fq_default_ctx_t ctx) + void fq_default_ctx_print(const fq_default_ctx_t ctx) noexcept # Prints the context information to ``stdout``. - void fq_default_ctx_randtest(fq_default_ctx_t ctx) + void fq_default_ctx_randtest(fq_default_ctx_t ctx) noexcept # Initializes ``ctx`` to a random finite field. Assumes that # ``fq_default_ctx_init`` has not been called on ``ctx`` already. - void fq_default_get_coeff_fmpz(fmpz_t c, fq_default_t op, slong n, const fq_default_ctx_t ctx) + void fq_default_get_coeff_fmpz(fmpz_t c, fq_default_t op, slong n, const fq_default_ctx_t ctx) noexcept # Set `c` to the degree `n` coefficient of the polynomial representation of # the finite field element ``op``. - void fq_default_init(fq_default_t rop, const fq_default_ctx_t ctx) + void fq_default_init(fq_default_t rop, const fq_default_ctx_t ctx) noexcept # Initialises the element ``rop``, setting its value to `0`. - void fq_default_init2(fq_default_t rop, const fq_default_ctx_t ctx) + void fq_default_init2(fq_default_t rop, const fq_default_ctx_t ctx) noexcept # Initialises ``poly`` with at least enough space for it to be an element # of ``ctx`` and sets it to `0`. - void fq_default_clear(fq_default_t rop, const fq_default_ctx_t ctx) + void fq_default_clear(fq_default_t rop, const fq_default_ctx_t ctx) noexcept # Clears the element ``rop``. - bint fq_default_is_invertible(const fq_default_t op, const fq_default_ctx_t ctx) + bint fq_default_is_invertible(const fq_default_t op, const fq_default_ctx_t ctx) noexcept # Return ``1`` if ``op`` is an invertible element. - void fq_default_add(fq_default_t rop, const fq_default_t op1, const fq_default_t op2, const fq_default_ctx_t ctx) + void fq_default_add(fq_default_t rop, const fq_default_t op1, const fq_default_t op2, const fq_default_ctx_t ctx) noexcept # Sets ``rop`` to the sum of ``op1`` and ``op2``. - void fq_default_sub(fq_default_t rop, const fq_default_t op1, const fq_default_t op2, const fq_default_ctx_t ctx) + void fq_default_sub(fq_default_t rop, const fq_default_t op1, const fq_default_t op2, const fq_default_ctx_t ctx) noexcept # Sets ``rop`` to the difference of ``op1`` and ``op2``. - void fq_default_sub_one(fq_default_t rop, const fq_default_t op1, const fq_default_ctx_t ctx) + void fq_default_sub_one(fq_default_t rop, const fq_default_t op1, const fq_default_ctx_t ctx) noexcept # Sets ``rop`` to the difference of ``op1`` and `1`. - void fq_default_neg(fq_default_t rop, const fq_default_t op, const fq_default_ctx_t ctx) + void fq_default_neg(fq_default_t rop, const fq_default_t op, const fq_default_ctx_t ctx) noexcept # Sets ``rop`` to the negative of ``op``. - void fq_default_mul(fq_default_t rop, const fq_default_t op1, const fq_default_t op2, const fq_default_ctx_t ctx) + void fq_default_mul(fq_default_t rop, const fq_default_t op1, const fq_default_t op2, const fq_default_ctx_t ctx) noexcept # Sets ``rop`` to the product of ``op1`` and ``op2``, # reducing the output in the given context. - void fq_default_mul_fmpz(fq_default_t rop, const fq_default_t op, const fmpz_t x, const fq_default_ctx_t ctx) + void fq_default_mul_fmpz(fq_default_t rop, const fq_default_t op, const fmpz_t x, const fq_default_ctx_t ctx) noexcept # Sets ``rop`` to the product of ``op`` and `x`, # reducing the output in the given context. - void fq_default_mul_si(fq_default_t rop, const fq_default_t op, slong x, const fq_default_ctx_t ctx) + void fq_default_mul_si(fq_default_t rop, const fq_default_t op, slong x, const fq_default_ctx_t ctx) noexcept # Sets ``rop`` to the product of ``op`` and `x`, # reducing the output in the given context. - void fq_default_mul_ui(fq_default_t rop, const fq_default_t op, ulong x, const fq_default_ctx_t ctx) + void fq_default_mul_ui(fq_default_t rop, const fq_default_t op, ulong x, const fq_default_ctx_t ctx) noexcept # Sets ``rop`` to the product of ``op`` and `x`, # reducing the output in the given context. - void fq_default_sqr(fq_default_t rop, const fq_default_t op, const fq_default_ctx_t ctx) + void fq_default_sqr(fq_default_t rop, const fq_default_t op, const fq_default_ctx_t ctx) noexcept # Sets ``rop`` to the square of ``op``, # reducing the output in the given context. - void fq_default_div(fq_default_t rop, fq_default_t op1, fq_default_t op2, const fq_default_ctx_t ctx) + void fq_default_div(fq_default_t rop, fq_default_t op1, fq_default_t op2, const fq_default_ctx_t ctx) noexcept # Sets ``rop`` to the quotient of ``op1`` and ``op2``, # reducing the output in the given context. - void fq_default_inv(fq_default_t rop, const fq_default_t op, const fq_default_ctx_t ctx) + void fq_default_inv(fq_default_t rop, const fq_default_t op, const fq_default_ctx_t ctx) noexcept # Sets ``rop`` to the inverse of the non-zero element ``op``. - void fq_default_pow(fq_default_t rop, const fq_default_t op, const fmpz_t e, const fq_default_ctx_t ctx) + void fq_default_pow(fq_default_t rop, const fq_default_t op, const fmpz_t e, const fq_default_ctx_t ctx) noexcept # Sets ``rop`` the ``op`` raised to the power `e`. # Currently assumes that `e \geq 0`. # Note that for any input ``op``, ``rop`` is set to `1` # whenever `e = 0`. - void fq_default_pow_ui(fq_default_t rop, const fq_default_t op, const ulong e, const fq_default_ctx_t ctx) + void fq_default_pow_ui(fq_default_t rop, const fq_default_t op, const ulong e, const fq_default_ctx_t ctx) noexcept # Sets ``rop`` the ``op`` raised to the power `e`. # Currently assumes that `e \geq 0`. # Note that for any input ``op``, ``rop`` is set to `1` # whenever `e = 0`. - int fq_default_sqrt(fq_default_t rop, const fq_default_t op1, const fq_default_ctx_t ctx) + int fq_default_sqrt(fq_default_t rop, const fq_default_t op1, const fq_default_ctx_t ctx) noexcept # Sets ``rop`` to the square root of ``op1`` if it is a square, and return # `1`, otherwise return `0`. - void fq_default_pth_root(fq_default_t rop, const fq_default_t op1, const fq_default_ctx_t ctx) + void fq_default_pth_root(fq_default_t rop, const fq_default_t op1, const fq_default_ctx_t ctx) noexcept # Sets ``rop`` to a `p^{th}` root root of ``op1``. Currently, # this computes the root by raising ``op1`` to `p^{d-1}` where # `d` is the degree of the extension. - bint fq_default_is_square(const fq_default_t op, const fq_default_ctx_t ctx) + bint fq_default_is_square(const fq_default_t op, const fq_default_ctx_t ctx) noexcept # Return ``1`` if ``op`` is a square. - int fq_default_fprint_pretty(FILE *file, const fq_default_t op, const fq_default_ctx_t ctx) + int fq_default_fprint_pretty(FILE *file, const fq_default_t op, const fq_default_ctx_t ctx) noexcept # Prints a pretty representation of ``op`` to ``file``. # In the current implementation, always returns `1`. The return code is # part of the function's signature to allow for a later implementation to # return the number of characters printed or a non-positive error code. - void fq_default_print_pretty(const fq_default_t op, const fq_default_ctx_t ctx) + void fq_default_print_pretty(const fq_default_t op, const fq_default_ctx_t ctx) noexcept # Prints a pretty representation of ``op`` to ``stdout``. # In the current implementation, always returns `1`. The return code is # part of the function's signature to allow for a later implementation to # return the number of characters printed or a non-positive error code. - int fq_default_fprint(FILE * file, const fq_default_t op, const fq_default_ctx_t ctx) + int fq_default_fprint(FILE * file, const fq_default_t op, const fq_default_ctx_t ctx) noexcept # Prints a representation of ``op`` to ``file``. - void fq_default_print(const fq_default_t op, const fq_default_ctx_t ctx) + void fq_default_print(const fq_default_t op, const fq_default_ctx_t ctx) noexcept # Prints a representation of ``op`` to ``stdout``. - char * fq_default_get_str(const fq_default_t op, const fq_default_ctx_t ctx) + char * fq_default_get_str(const fq_default_t op, const fq_default_ctx_t ctx) noexcept # Returns the plain FLINT string representation of the element # ``op``. - char * fq_default_get_str_pretty(const fq_default_t op, const fq_default_ctx_t ctx) + char * fq_default_get_str_pretty(const fq_default_t op, const fq_default_ctx_t ctx) noexcept # Returns a pretty representation of the element ``op`` using the # null-terminated string ``x`` as the variable name. - void fq_default_randtest(fq_default_t rop, flint_rand_t state, const fq_default_ctx_t ctx) + void fq_default_randtest(fq_default_t rop, flint_rand_t state, const fq_default_ctx_t ctx) noexcept # Generates a random element of `\mathbf{F}_q`. - void fq_default_randtest_not_zero(fq_default_t rop, flint_rand_t state, const fq_default_ctx_t ctx) + void fq_default_randtest_not_zero(fq_default_t rop, flint_rand_t state, const fq_default_ctx_t ctx) noexcept # Generates a random non-zero element of `\mathbf{F}_q`. - void fq_default_rand(fq_default_t rop, flint_rand_t state, const fq_default_ctx_t ctx) + void fq_default_rand(fq_default_t rop, flint_rand_t state, const fq_default_ctx_t ctx) noexcept # Generates a high quality random element of `\mathbf{F}_q`. - void fq_default_rand_not_zero(fq_default_t rop, flint_rand_t state, const fq_default_ctx_t ctx) + void fq_default_rand_not_zero(fq_default_t rop, flint_rand_t state, const fq_default_ctx_t ctx) noexcept # Generates a high quality non-zero random element of `\mathbf{F}_q`. - void fq_default_set(fq_default_t rop, const fq_default_t op, const fq_default_ctx_t ctx) + void fq_default_set(fq_default_t rop, const fq_default_t op, const fq_default_ctx_t ctx) noexcept # Sets ``rop`` to ``op``. - void fq_default_set_si(fq_default_t rop, const slong x, const fq_default_ctx_t ctx) + void fq_default_set_si(fq_default_t rop, const slong x, const fq_default_ctx_t ctx) noexcept # Sets ``rop`` to ``x``, considered as an element of # `\mathbf{F}_p`. - void fq_default_set_ui(fq_default_t rop, const ulong x, const fq_default_ctx_t ctx) + void fq_default_set_ui(fq_default_t rop, const ulong x, const fq_default_ctx_t ctx) noexcept # Sets ``rop`` to ``x``, considered as an element of # `\mathbf{F}_p`. - void fq_default_set_fmpz(fq_default_t rop, const fmpz_t x, const fq_default_ctx_t ctx) + void fq_default_set_fmpz(fq_default_t rop, const fmpz_t x, const fq_default_ctx_t ctx) noexcept # Sets ``rop`` to ``x``, considered as an element of # `\mathbf{F}_p`. - void fq_default_swap(fq_default_t op1, fq_default_t op2, const fq_default_ctx_t ctx) + void fq_default_swap(fq_default_t op1, fq_default_t op2, const fq_default_ctx_t ctx) noexcept # Swaps the two elements ``op1`` and ``op2``. - void fq_default_zero(fq_default_t rop, const fq_default_ctx_t ctx) + void fq_default_zero(fq_default_t rop, const fq_default_ctx_t ctx) noexcept # Sets ``rop`` to zero. - void fq_default_one(fq_default_t rop, const fq_default_ctx_t ctx) + void fq_default_one(fq_default_t rop, const fq_default_ctx_t ctx) noexcept # Sets ``rop`` to one, reduced in the given context. - void fq_default_gen(fq_default_t rop, const fq_default_ctx_t ctx) + void fq_default_gen(fq_default_t rop, const fq_default_ctx_t ctx) noexcept # Sets ``rop`` to a generator for the finite field. # There is no guarantee this is a multiplicative generator of # the finite field. - int fq_default_get_fmpz(fmpz_t rop, const fq_default_t op, const fq_default_ctx_t ctx) + int fq_default_get_fmpz(fmpz_t rop, const fq_default_t op, const fq_default_ctx_t ctx) noexcept # If ``op`` has a lift to the integers, return `1` and set ``rop`` to the lift in `[0,p)`. # Otherwise, return `0` and leave `rop` undefined. - void fq_default_get_nmod_poly(nmod_poly_t poly, const fq_default_t op, const fq_default_ctx_t ctx) + void fq_default_get_nmod_poly(nmod_poly_t poly, const fq_default_t op, const fq_default_ctx_t ctx) noexcept # Sets ``poly`` to the polynomial representation of ``op``. Assumes the # characteristic of the field and the modulus of the polynomial are the same. # No checking of this occurs. - void fq_default_set_nmod_poly(fq_default_t op, const nmod_poly_t poly, const fq_default_ctx_t ctx) + void fq_default_set_nmod_poly(fq_default_t op, const nmod_poly_t poly, const fq_default_ctx_t ctx) noexcept # Sets ``op`` to the finite field element represented by the polynomial # ``poly``. Assumes the characteristic of the field and the modulus of the # polynomial are the same. No checking of this occurs. - void fq_default_get_fmpz_mod_poly(fmpz_mod_poly_t poly, const fq_default_t op, const fq_default_ctx_t ctx) + void fq_default_get_fmpz_mod_poly(fmpz_mod_poly_t poly, const fq_default_t op, const fq_default_ctx_t ctx) noexcept # Sets ``poly`` to the polynomial representation of ``op``. Assumes the # characteristic of the field and the modulus of the polynomial are the same. # No checking of this occurs. - void fq_default_set_fmpz_mod_poly(fq_default_t op, const fmpz_mod_poly_t poly, const fq_default_ctx_t ctx) + void fq_default_set_fmpz_mod_poly(fq_default_t op, const fmpz_mod_poly_t poly, const fq_default_ctx_t ctx) noexcept # Sets ``op`` to the finite field element represented by the polynomial # ``poly``. Assumes the characteristic of the field and the modulus of the # polynomial are the same. No checking of this occurs. - void fq_default_get_fmpz_poly(fmpz_poly_t a, const fq_default_t b, const fq_default_ctx_t ctx) + void fq_default_get_fmpz_poly(fmpz_poly_t a, const fq_default_t b, const fq_default_ctx_t ctx) noexcept # Set ``a`` to a representative of ``b`` in ``ctx``. # The representatives are taken in `(\mathbb{Z}/p\mathbb{Z})[x]/h(x)` where # `h(x)` is the defining polynomial in ``ctx``. - void fq_default_set_fmpz_poly(fq_default_t a, const fmpz_poly_t b, const fq_default_ctx_t ctx) + void fq_default_set_fmpz_poly(fq_default_t a, const fmpz_poly_t b, const fq_default_ctx_t ctx) noexcept # Set ``a`` to the element in ``ctx`` with representative ``b``. # The representatives are taken in `(\mathbb{Z}/p\mathbb{Z})[x]/h(x)` where # `h(x)` is the defining polynomial in ``ctx``. - bint fq_default_is_zero(const fq_default_t op, const fq_default_ctx_t ctx) + bint fq_default_is_zero(const fq_default_t op, const fq_default_ctx_t ctx) noexcept # Returns whether ``op`` is equal to zero. - bint fq_default_is_one(const fq_default_t op, const fq_default_ctx_t ctx) + bint fq_default_is_one(const fq_default_t op, const fq_default_ctx_t ctx) noexcept # Returns whether ``op`` is equal to one. - bint fq_default_equal(const fq_default_t op1, const fq_default_t op2, const fq_default_ctx_t ctx) + bint fq_default_equal(const fq_default_t op1, const fq_default_t op2, const fq_default_ctx_t ctx) noexcept # Returns whether ``op1`` and ``op2`` are equal. - void fq_default_trace(fmpz_t rop, const fq_default_t op, const fq_default_ctx_t ctx) + void fq_default_trace(fmpz_t rop, const fq_default_t op, const fq_default_ctx_t ctx) noexcept # Sets ``rop`` to the trace of ``op``. # For an element `a \in \mathbf{F}_q`, multiplication by `a` defines # a `\mathbf{F}_p`-linear map on `\mathbf{F}_q`. We define the @@ -286,7 +286,7 @@ cdef extern from "flint_wrap.h": # `a` is equal to `\sum_{i=0}^{d-1} \Sigma^i (a)`, where `d = # \log_{p} q`. - void fq_default_norm(fmpz_t rop, const fq_default_t op, const fq_default_ctx_t ctx) + void fq_default_norm(fmpz_t rop, const fq_default_t op, const fq_default_ctx_t ctx) noexcept # Computes the norm of ``op``. # For an element `a \in \mathbf{F}_q`, multiplication by `a` defines # a `\mathbf{F}_p`-linear map on `\mathbf{F}_q`. We define the norm @@ -296,7 +296,7 @@ cdef extern from "flint_wrap.h": # `d = \text{dim}_{\mathbf{F}_p}(\mathbf{F}_q)`. # Algorithm selection is automatic depending on the input. - void fq_default_frobenius(fq_default_t rop, const fq_default_t op, slong e, const fq_default_ctx_t ctx) + void fq_default_frobenius(fq_default_t rop, const fq_default_t op, slong e, const fq_default_ctx_t ctx) noexcept # Evaluates the homomorphism `\Sigma^e` at ``op``. # Recall that `\mathbf{F}_q / \mathbf{F}_p` is Galois with Galois group # `\langle \sigma \rangle`, which is also isomorphic to diff --git a/src/sage/libs/flint/fq_default_mat.pxd b/src/sage/libs/flint/fq_default_mat.pxd index b8bf8cdd5c1..9b0e60f1cc5 100644 --- a/src/sage/libs/flint/fq_default_mat.pxd +++ b/src/sage/libs/flint/fq_default_mat.pxd @@ -12,121 +12,121 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void fq_default_mat_init(fq_default_mat_t mat, slong rows, slong cols, const fq_default_ctx_t ctx) + void fq_default_mat_init(fq_default_mat_t mat, slong rows, slong cols, const fq_default_ctx_t ctx) noexcept # Initialises ``mat`` to a ``rows``-by-``cols`` matrix with # coefficients in `\mathbf{F}_{q}` given by ``ctx``. All elements # are set to zero. - void fq_default_mat_init_set(fq_default_mat_t mat, const fq_default_mat_t src, const fq_default_ctx_t ctx) + void fq_default_mat_init_set(fq_default_mat_t mat, const fq_default_mat_t src, const fq_default_ctx_t ctx) noexcept # Initialises ``mat`` and sets its dimensions and elements to # those of ``src``. - void fq_default_mat_clear(fq_default_mat_t mat, const fq_default_ctx_t ctx) + void fq_default_mat_clear(fq_default_mat_t mat, const fq_default_ctx_t ctx) noexcept # Clears the matrix and releases any memory it used. The matrix # cannot be used again until it is initialised. This function must be # called exactly once when finished using an ``fq_default_mat_t`` object. - void fq_default_mat_set(fq_default_mat_t mat, const fq_default_mat_t src, const fq_default_ctx_t ctx) + void fq_default_mat_set(fq_default_mat_t mat, const fq_default_mat_t src, const fq_default_ctx_t ctx) noexcept # Sets ``mat`` to a copy of ``src``. It is assumed # that ``mat`` and ``src`` have identical dimensions. - void fq_default_mat_entry(fq_default_t val, const fq_default_mat_t mat, slong i, slong j, const fq_default_ctx_t ctx) + void fq_default_mat_entry(fq_default_t val, const fq_default_mat_t mat, slong i, slong j, const fq_default_ctx_t ctx) noexcept # Directly accesses the entry in ``mat`` in row `i` and column `j`, # indexed from zero by setting ``val`` to the value of that entry. No bounds # checking is performed. - void fq_default_mat_entry_set(fq_default_mat_t mat, slong i, slong j, const fq_default_t x, const fq_default_ctx_t ctx) + void fq_default_mat_entry_set(fq_default_mat_t mat, slong i, slong j, const fq_default_t x, const fq_default_ctx_t ctx) noexcept # Sets the entry in ``mat`` in row `i` and column `j` to ``x``. - void fq_default_mat_entry_set_fmpz(fq_default_mat_t mat, slong i, slong j, const fmpz_t x, const fq_default_ctx_t ctx) + void fq_default_mat_entry_set_fmpz(fq_default_mat_t mat, slong i, slong j, const fmpz_t x, const fq_default_ctx_t ctx) noexcept # Sets the entry in ``mat`` in row `i` and column `j` to ``x``. - slong fq_default_mat_nrows(const fq_default_mat_t mat, const fq_default_ctx_t ctx) + slong fq_default_mat_nrows(const fq_default_mat_t mat, const fq_default_ctx_t ctx) noexcept # Returns the number of rows in ``mat``. - slong fq_default_mat_ncols(const fq_default_mat_t mat, const fq_default_ctx_t ctx) + slong fq_default_mat_ncols(const fq_default_mat_t mat, const fq_default_ctx_t ctx) noexcept # Returns the number of columns in ``mat``. - void fq_default_mat_swap(fq_default_mat_t mat1, fq_default_mat_t mat2, const fq_default_ctx_t ctx) + void fq_default_mat_swap(fq_default_mat_t mat1, fq_default_mat_t mat2, const fq_default_ctx_t ctx) noexcept # Swaps two matrices. The dimensions of ``mat1`` and ``mat2`` # are allowed to be different. - void fq_default_mat_zero(fq_default_mat_t mat, const fq_default_ctx_t ctx) + void fq_default_mat_zero(fq_default_mat_t mat, const fq_default_ctx_t ctx) noexcept # Sets all entries of ``mat`` to 0. - void fq_default_mat_one(fq_default_mat_t mat, const fq_default_ctx_t ctx) + void fq_default_mat_one(fq_default_mat_t mat, const fq_default_ctx_t ctx) noexcept # Sets the diagonal entries of ``mat`` to 1 and all other entries to 0. - void fq_default_mat_swap_rows(fq_default_mat_t mat, slong * perm, slong r, slong s, const fq_default_ctx_t ctx) + void fq_default_mat_swap_rows(fq_default_mat_t mat, slong * perm, slong r, slong s, const fq_default_ctx_t ctx) noexcept # Swaps rows ``r`` and ``s`` of ``mat``. If ``perm`` is non-``NULL``, the # permutation of the rows will also be applied to ``perm``. - void fq_default_mat_swap_cols(fq_default_mat_t mat, slong * perm, slong r, slong s, const fq_default_ctx_t ctx) + void fq_default_mat_swap_cols(fq_default_mat_t mat, slong * perm, slong r, slong s, const fq_default_ctx_t ctx) noexcept # Swaps columns ``r`` and ``s`` of ``mat``. If ``perm`` is non-``NULL``, the # permutation of the columns will also be applied to ``perm``. - void fq_default_mat_invert_rows(fq_default_mat_t mat, slong * perm, const fq_default_ctx_t ctx) + void fq_default_mat_invert_rows(fq_default_mat_t mat, slong * perm, const fq_default_ctx_t ctx) noexcept # Swaps rows ``i`` and ``r - i`` of ``mat`` for ``0 <= i < r/2``, where # ``r`` is the number of rows of ``mat``. If ``perm`` is non-``NULL``, the # permutation of the rows will also be applied to ``perm``. - void fq_default_mat_invert_cols(fq_default_mat_t mat, slong * perm, const fq_default_ctx_t ctx) + void fq_default_mat_invert_cols(fq_default_mat_t mat, slong * perm, const fq_default_ctx_t ctx) noexcept # Swaps columns ``i`` and ``c - i`` of ``mat`` for ``0 <= i < c/2``, where # ``c`` is the number of columns of ``mat``. If ``perm`` is non-``NULL``, the # permutation of the columns will also be applied to ``perm``. - void fq_default_mat_set_nmod_mat(fq_default_mat_t mat1, const nmod_mat_t mat2, const fq_default_ctx_t ctx) + void fq_default_mat_set_nmod_mat(fq_default_mat_t mat1, const nmod_mat_t mat2, const fq_default_ctx_t ctx) noexcept # Sets the matrix ``mat1`` to the matrix ``mat2``. - void fq_default_mat_set_fmpz_mod_mat(fq_default_mat_t mat1, const fmpz_mod_mat_t mat2, const fq_default_ctx_t ctx) + void fq_default_mat_set_fmpz_mod_mat(fq_default_mat_t mat1, const fmpz_mod_mat_t mat2, const fq_default_ctx_t ctx) noexcept # Sets the matrix ``mat1`` to the matrix ``mat2``. - void fq_default_mat_set_fmpz_mat(fq_default_mat_t mat1, const fmpz_mat_t mat2, const fq_default_ctx_t ctx) + void fq_default_mat_set_fmpz_mat(fq_default_mat_t mat1, const fmpz_mat_t mat2, const fq_default_ctx_t ctx) noexcept # Sets the matrix ``mat1`` to the matrix ``mat2``, reducing the entries # modulo the characteristic of the finite field. - void fq_default_mat_concat_vertical(fq_default_mat_t res, const fq_default_mat_t mat1, const fq_default_mat_t mat2, const fq_default_ctx_t ctx) + void fq_default_mat_concat_vertical(fq_default_mat_t res, const fq_default_mat_t mat1, const fq_default_mat_t mat2, const fq_default_ctx_t ctx) noexcept # Sets ``res`` to vertical concatenation of (``mat1``, ``mat2``) in that order. Matrix dimensions : ``mat1`` : `m \times n`, ``mat2`` : `k \times n`, ``res`` : `(m + k) \times n`. - void fq_default_mat_concat_horizontal(fq_default_mat_t res, const fq_default_mat_t mat1, const fq_default_mat_t mat2, const fq_default_ctx_t ctx) + void fq_default_mat_concat_horizontal(fq_default_mat_t res, const fq_default_mat_t mat1, const fq_default_mat_t mat2, const fq_default_ctx_t ctx) noexcept # Sets ``res`` to horizontal concatenation of (``mat1``, ``mat2``) in that order. Matrix dimensions : ``mat1`` : `m \times n`, ``mat2`` : `m \times k`, ``res`` : `m \times (n + k)`. - int fq_default_mat_print_pretty(const fq_default_mat_t mat, const fq_default_ctx_t ctx) + int fq_default_mat_print_pretty(const fq_default_mat_t mat, const fq_default_ctx_t ctx) noexcept # Pretty-prints ``mat`` to ``stdout``. A header is printed # followed by the rows enclosed in brackets. - int fq_default_mat_fprint_pretty(FILE * file, const fq_default_mat_t mat, const fq_default_ctx_t ctx) + int fq_default_mat_fprint_pretty(FILE * file, const fq_default_mat_t mat, const fq_default_ctx_t ctx) noexcept # Pretty-prints ``mat`` to ``file``. A header is printed # followed by the rows enclosed in brackets. # In case of success, returns a positive value. In case of failure, # returns a non-positive value. - int fq_default_mat_print(const fq_default_mat_t mat, const fq_default_ctx_t ctx) + int fq_default_mat_print(const fq_default_mat_t mat, const fq_default_ctx_t ctx) noexcept # Prints ``mat`` to ``stdout``. A header is printed followed # by the rows enclosed in brackets. - int fq_default_mat_fprint(FILE * file, const fq_default_mat_t mat, const fq_default_ctx_t ctx) + int fq_default_mat_fprint(FILE * file, const fq_default_mat_t mat, const fq_default_ctx_t ctx) noexcept # Prints ``mat`` to ``file``. A header is printed followed by # the rows enclosed in brackets. # In case of success, returns a positive value. In case of failure, # returns a non-positive value. - void fq_default_mat_window_init(fq_default_mat_t window, const fq_default_mat_t mat, slong r1, slong c1, slong r2, slong c2, const fq_default_ctx_t ctx) + void fq_default_mat_window_init(fq_default_mat_t window, const fq_default_mat_t mat, slong r1, slong c1, slong r2, slong c2, const fq_default_ctx_t ctx) noexcept # Initializes the matrix ``window`` to be an ``r2 - r1`` by # ``c2 - c1`` submatrix of ``mat`` whose ``(0,0)`` entry # is the ``(r1, c1)`` entry of ``mat``. The memory for the # elements of ``window`` is shared with ``mat``. - void fq_default_mat_window_clear(fq_default_mat_t window, const fq_default_ctx_t ctx) + void fq_default_mat_window_clear(fq_default_mat_t window, const fq_default_ctx_t ctx) noexcept # Clears the matrix ``window`` and releases any memory that it # uses. Note that the memory to the underlying matrix that # ``window`` points to is not freed. - void fq_default_mat_randtest(fq_default_mat_t mat, flint_rand_t state, const fq_default_ctx_t ctx) + void fq_default_mat_randtest(fq_default_mat_t mat, flint_rand_t state, const fq_default_ctx_t ctx) noexcept # Sets the elements of ``mat`` to random elements of # `\mathbf{F}_{q}`, given by ``ctx``. - int fq_default_mat_randpermdiag(fq_mat_t mat, flint_rand_t state, fq_struct * diag, slong n, const fq_ctx_t ctx) + int fq_default_mat_randpermdiag(fq_mat_t mat, flint_rand_t state, fq_struct * diag, slong n, const fq_ctx_t ctx) noexcept # Sets ``mat`` to a random permutation of the diagonal matrix # with `n` leading entries given by the vector ``diag``. It is # assumed that the main diagonal of ``mat`` has room for at @@ -134,7 +134,7 @@ cdef extern from "flint_wrap.h": # Returns `0` or `1`, depending on whether the permutation is even # or odd respectively. - void fq_default_mat_randrank(fq_default_mat_t mat, flint_rand_t state, slong rank, const fq_default_ctx_t ctx) + void fq_default_mat_randrank(fq_default_mat_t mat, flint_rand_t state, slong rank, const fq_default_ctx_t ctx) noexcept # Sets ``mat`` to a random sparse matrix with the given rank, # having exactly as many non-zero elements as the rank, with the # non-zero elements being uniformly random elements of @@ -142,69 +142,69 @@ cdef extern from "flint_wrap.h": # The matrix can be transformed into a dense matrix with unchanged # rank by subsequently calling :func:`fq_default_mat_randops`. - void fq_default_mat_randops(fq_default_mat_t mat, slong count, flint_rand_t state, const fq_default_ctx_t ctx) + void fq_default_mat_randops(fq_default_mat_t mat, slong count, flint_rand_t state, const fq_default_ctx_t ctx) noexcept # Randomises ``mat`` by performing elementary row or column # operations. More precisely, at most ``count`` random additions # or subtractions of distinct rows and columns will be performed. # This leaves the rank (and for square matrices, determinant) # unchanged. - void fq_default_mat_randtril(fq_default_mat_t mat, flint_rand_t state, int unit, const fq_default_ctx_t ctx) + void fq_default_mat_randtril(fq_default_mat_t mat, flint_rand_t state, int unit, const fq_default_ctx_t ctx) noexcept # Sets ``mat`` to a random lower triangular matrix. If # ``unit`` is 1, it will have ones on the main diagonal, # otherwise it will have random nonzero entries on the main # diagonal. - void fq_default_mat_randtriu(fq_default_mat_t mat, flint_rand_t state, int unit, const fq_default_ctx_t ctx) + void fq_default_mat_randtriu(fq_default_mat_t mat, flint_rand_t state, int unit, const fq_default_ctx_t ctx) noexcept # Sets ``mat`` to a random upper triangular matrix. If # ``unit`` is 1, it will have ones on the main diagonal, # otherwise it will have random nonzero entries on the main # diagonal. - bint fq_default_mat_equal(const fq_default_mat_t mat1, const fq_default_mat_t mat2, const fq_default_ctx_t ctx) + bint fq_default_mat_equal(const fq_default_mat_t mat1, const fq_default_mat_t mat2, const fq_default_ctx_t ctx) noexcept # Returns nonzero if mat1 and mat2 have the same dimensions and elements, # and zero otherwise. - bint fq_default_mat_is_zero(const fq_default_mat_t mat, const fq_default_ctx_t ctx) + bint fq_default_mat_is_zero(const fq_default_mat_t mat, const fq_default_ctx_t ctx) noexcept # Returns a non-zero value if all entries of ``mat`` are zero, and # otherwise returns zero. - bint fq_default_mat_is_one(const fq_default_mat_t mat, const fq_default_ctx_t ctx) + bint fq_default_mat_is_one(const fq_default_mat_t mat, const fq_default_ctx_t ctx) noexcept # Returns a non-zero value if all diagonal entries of ``mat`` are one and # all other entries are zero, and otherwise returns zero. - bint fq_default_mat_is_empty(const fq_default_mat_t mat, const fq_default_ctx_t ctx) + bint fq_default_mat_is_empty(const fq_default_mat_t mat, const fq_default_ctx_t ctx) noexcept # Returns a non-zero value if the number of rows or the number of # columns in ``mat`` is zero, and otherwise returns zero. - bint fq_default_mat_is_square(const fq_default_mat_t mat, const fq_default_ctx_t ctx) + bint fq_default_mat_is_square(const fq_default_mat_t mat, const fq_default_ctx_t ctx) noexcept # Returns a non-zero value if the number of rows is equal to the # number of columns in ``mat``, and otherwise returns zero. - void fq_default_mat_add(fq_default_mat_t C, const fq_default_mat_t A, const fq_default_mat_t B, const fq_default_ctx_t ctx) + void fq_default_mat_add(fq_default_mat_t C, const fq_default_mat_t A, const fq_default_mat_t B, const fq_default_ctx_t ctx) noexcept # Computes `C = A + B`. Dimensions must be identical. - void fq_default_mat_sub(fq_default_mat_t C, const fq_default_mat_t A, const fq_default_mat_t B, const fq_default_ctx_t ctx) + void fq_default_mat_sub(fq_default_mat_t C, const fq_default_mat_t A, const fq_default_mat_t B, const fq_default_ctx_t ctx) noexcept # Computes `C = A - B`. Dimensions must be identical. - void fq_default_mat_neg(fq_default_mat_t A, const fq_default_mat_t B, const fq_default_ctx_t ctx) + void fq_default_mat_neg(fq_default_mat_t A, const fq_default_mat_t B, const fq_default_ctx_t ctx) noexcept # Sets `B = -A`. Dimensions must be identical. - void fq_default_mat_mul(fq_default_mat_t C, const fq_default_mat_t A, const fq_default_mat_t B, const fq_default_ctx_t ctx) + void fq_default_mat_mul(fq_default_mat_t C, const fq_default_mat_t A, const fq_default_mat_t B, const fq_default_ctx_t ctx) noexcept # Sets `C = AB`. Dimensions must be compatible for matrix # multiplication. Aliasing is allowed. This function automatically chooses # between classical and KS multiplication. - void fq_default_mat_submul(fq_default_mat_t D, const fq_default_mat_t C, const fq_default_mat_t A, const fq_default_mat_t B, const fq_default_ctx_t ctx) + void fq_default_mat_submul(fq_default_mat_t D, const fq_default_mat_t C, const fq_default_mat_t A, const fq_default_mat_t B, const fq_default_ctx_t ctx) noexcept # Sets `D = C + AB`. `C` and `D` may be aliased with each other but # not with `A` or `B`. - int fq_default_mat_inv(fq_default_mat_t B, fq_default_mat_t A, const fq_default_ctx_t ctx) + int fq_default_mat_inv(fq_default_mat_t B, fq_default_mat_t A, const fq_default_ctx_t ctx) noexcept # Sets `B = A^{-1}` and returns `1` if `A` is invertible. If `A` is singular, # returns `0` and sets the elements of `B` to undefined values. # `A` and `B` must be square matrices with the same dimensions. - slong fq_default_mat_lu(slong * P, fq_default_mat_t A, int rank_check, const fq_default_ctx_t ctx) + slong fq_default_mat_lu(slong * P, fq_default_mat_t A, int rank_check, const fq_default_ctx_t ctx) noexcept # Computes a generalised LU decomposition `LU = PA` of a given # matrix `A`, returning the rank of `A`. # If `A` is a nonsingular square matrix, it will be overwritten with @@ -221,13 +221,13 @@ cdef extern from "flint_wrap.h": # if `A` is detected to be rank-deficient. # This function calls ``fq_default_mat_lu_recursive``. - slong fq_default_mat_rref(fq_default_mat_t A, const fq_default_ctx_t ctx) + slong fq_default_mat_rref(fq_default_mat_t A, const fq_default_ctx_t ctx) noexcept # Puts `A` in reduced row echelon form and returns the rank of `A`. # The rref is computed by first obtaining an unreduced row echelon # form via LU decomposition and then solving an additional # triangular system. - void fq_default_mat_solve_tril(fq_default_mat_t X, const fq_default_mat_t L, const fq_default_mat_t B, int unit, const fq_default_ctx_t ctx) + void fq_default_mat_solve_tril(fq_default_mat_t X, const fq_default_mat_t L, const fq_default_mat_t B, int unit, const fq_default_ctx_t ctx) noexcept # Sets `X = L^{-1} B` where `L` is a full rank lower triangular # square matrix. If ``unit`` = 1, `L` is assumed to have ones on # its main diagonal, and the main diagonal will not be read. `X` @@ -235,7 +235,7 @@ cdef extern from "flint_wrap.h": # is allowed. Automatically chooses between the classical and # recursive algorithms. - void fq_default_mat_solve_triu(fq_default_mat_t X, const fq_default_mat_t U, const fq_default_mat_t B, int unit, const fq_default_ctx_t ctx) + void fq_default_mat_solve_triu(fq_default_mat_t X, const fq_default_mat_t U, const fq_default_mat_t B, int unit, const fq_default_ctx_t ctx) noexcept # Sets `X = U^{-1} B` where `U` is a full rank upper triangular # square matrix. If ``unit`` = 1, `U` is assumed to have ones on # its main diagonal, and the main diagonal will not be read. `X` @@ -243,20 +243,20 @@ cdef extern from "flint_wrap.h": # is allowed. Automatically chooses between the classical and # recursive algorithms. - int fq_default_mat_solve(fq_default_mat_t X, const fq_default_mat_t A, const fq_default_mat_t B, const fq_default_ctx_t ctx) + int fq_default_mat_solve(fq_default_mat_t X, const fq_default_mat_t A, const fq_default_mat_t B, const fq_default_ctx_t ctx) noexcept # Solves the matrix-matrix equation `AX = B`. # Returns `1` if `A` has full rank; otherwise returns `0` and sets the # elements of `X` to undefined values. # The matrix `A` must be square. - int fq_default_mat_can_solve(fq_default_mat_t X, const fq_default_mat_t A, const fq_default_mat_t B, const fq_default_ctx_t ctx) + int fq_default_mat_can_solve(fq_default_mat_t X, const fq_default_mat_t A, const fq_default_mat_t B, const fq_default_ctx_t ctx) noexcept # Solves the matrix-matrix equation `AX = B` over `Fq`. # Returns `1` if a solution exists; otherwise returns `0` and sets the # elements of `X` to zero. If more than one solution exists, one of the # valid solutions is given. # There are no restrictions on the shape of `A` and it may be singular. - void fq_default_mat_similarity(fq_default_mat_t M, slong r, fq_default_t d, const fq_default_ctx_t ctx) + void fq_default_mat_similarity(fq_default_mat_t M, slong r, fq_default_t d, const fq_default_ctx_t ctx) noexcept # Applies a similarity transform to the `n\times n` matrix `M` in-place. # If `P` is the `n\times n` identity matrix the zero entries of whose row # `r` (`0`-indexed) have been replaced by `d`, this transform is equivalent @@ -266,10 +266,10 @@ cdef extern from "flint_wrap.h": # The value `d` is required to be reduced modulo the modulus of the entries # in the matrix. - void fq_default_mat_charpoly(fq_default_poly_t p, const fq_default_mat_t M, const fq_default_ctx_t ctx) + void fq_default_mat_charpoly(fq_default_poly_t p, const fq_default_mat_t M, const fq_default_ctx_t ctx) noexcept # Compute the characteristic polynomial `p` of the matrix `M`. The matrix # is required to be square, otherwise an exception is raised. - void fq_default_mat_minpoly(fq_default_poly_t p, const fq_default_mat_t M, const fq_default_ctx_t ctx) + void fq_default_mat_minpoly(fq_default_poly_t p, const fq_default_mat_t M, const fq_default_ctx_t ctx) noexcept # Compute the minimal polynomial `p` of the matrix `M`. The matrix # is required to be square, otherwise an exception is raised. diff --git a/src/sage/libs/flint/fq_default_poly.pxd b/src/sage/libs/flint/fq_default_poly.pxd index 69d18c6c7a4..21d20fbfd83 100644 --- a/src/sage/libs/flint/fq_default_poly.pxd +++ b/src/sage/libs/flint/fq_default_poly.pxd @@ -12,27 +12,27 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void fq_default_poly_init(fq_default_poly_t poly, const fq_default_ctx_t ctx) + void fq_default_poly_init(fq_default_poly_t poly, const fq_default_ctx_t ctx) noexcept # Initialises ``poly`` for use, with context ctx, and setting its # length to zero. A corresponding call to :func:`fq_default_poly_clear` # must be made after finishing with the ``fq_default_poly_t`` to free the # memory used by the polynomial. - void fq_default_poly_init2(fq_default_poly_t poly, slong alloc, const fq_default_ctx_t ctx) + void fq_default_poly_init2(fq_default_poly_t poly, slong alloc, const fq_default_ctx_t ctx) noexcept # Initialises ``poly`` with space for at least ``alloc`` # coefficients and sets the length to zero. The allocated # coefficients are all set to zero. A corresponding call to # :func:`fq_default_poly_clear` must be made after finishing with the # ``fq_default_poly_t`` to free the memory used by the polynomial. - void fq_default_poly_realloc(fq_default_poly_t poly, slong alloc, const fq_default_ctx_t ctx) + void fq_default_poly_realloc(fq_default_poly_t poly, slong alloc, const fq_default_ctx_t ctx) noexcept # Reallocates the given polynomial to have space for ``alloc`` # coefficients. If ``alloc`` is zero the polynomial is cleared # and then reinitialised. If the current length is greater than # ``alloc`` the polynomial is first truncated to length # ``alloc``. - void fq_default_poly_fit_length(fq_default_poly_t poly, slong len, const fq_default_ctx_t ctx) + void fq_default_poly_fit_length(fq_default_poly_t poly, slong len, const fq_default_ctx_t ctx) noexcept # If ``len`` is greater than the number of coefficients currently # allocated, then the polynomial is reallocated to have space for at # least ``len`` coefficients. No data is lost when calling this @@ -42,224 +42,224 @@ cdef extern from "flint_wrap.h": # least doubling the number of allocated coefficients when length is # larger than the number of coefficients currently allocated. - void fq_default_poly_clear(fq_default_poly_t poly, const fq_default_ctx_t ctx) + void fq_default_poly_clear(fq_default_poly_t poly, const fq_default_ctx_t ctx) noexcept # Clears the given polynomial, releasing any memory used. It must # be reinitialised in order to be used again. - void _fq_default_poly_set_length(fq_default_poly_t poly, slong len, const fq_default_ctx_t ctx) + void _fq_default_poly_set_length(fq_default_poly_t poly, slong len, const fq_default_ctx_t ctx) noexcept # Set the length of ``poly`` to ``len``. - void fq_default_poly_truncate(fq_default_poly_t poly, slong newlen, const fq_default_ctx_t ctx) + void fq_default_poly_truncate(fq_default_poly_t poly, slong newlen, const fq_default_ctx_t ctx) noexcept # Truncates the polynomial to length at most `n`. - void fq_default_poly_set_trunc(fq_default_poly_t poly1, fq_default_poly_t poly2, slong newlen, const fq_default_ctx_t ctx) + void fq_default_poly_set_trunc(fq_default_poly_t poly1, fq_default_poly_t poly2, slong newlen, const fq_default_ctx_t ctx) noexcept # Sets ``poly1`` to ``poly2`` truncated to length `n`. - void fq_default_poly_reverse(fq_default_poly_t output, const fq_default_poly_t input, slong m, const fq_default_ctx_t ctx) + void fq_default_poly_reverse(fq_default_poly_t output, const fq_default_poly_t input, slong m, const fq_default_ctx_t ctx) noexcept # Sets ``output`` to the reverse of ``input``, thinking of it # as a polynomial of length ``m``, notionally zero-padded if # necessary). The length ``m`` must be non-negative, but there # are no other restrictions. The output polynomial will be set to # length ``m`` and then normalised. - slong fq_default_poly_degree(const fq_default_poly_t poly, const fq_default_ctx_t ctx) + slong fq_default_poly_degree(const fq_default_poly_t poly, const fq_default_ctx_t ctx) noexcept # Returns the degree of the polynomial ``poly``. - slong fq_default_poly_length(const fq_default_poly_t poly, const fq_default_ctx_t ctx) + slong fq_default_poly_length(const fq_default_poly_t poly, const fq_default_ctx_t ctx) noexcept # Returns the length of the polynomial ``poly``. - void fq_default_poly_randtest(fq_default_poly_t f, flint_rand_t state, slong len, const fq_default_ctx_t ctx) + void fq_default_poly_randtest(fq_default_poly_t f, flint_rand_t state, slong len, const fq_default_ctx_t ctx) noexcept # Sets `f` to a random polynomial of length at most ``len`` # with entries in the field described by ``ctx``. - void fq_default_poly_randtest_not_zero(fq_default_poly_t f, flint_rand_t state, slong len, const fq_default_ctx_t ctx) + void fq_default_poly_randtest_not_zero(fq_default_poly_t f, flint_rand_t state, slong len, const fq_default_ctx_t ctx) noexcept # Same as ``fq_default_poly_randtest`` but guarantees that the polynomial # is not zero. - void fq_default_poly_randtest_monic(fq_default_poly_t f, flint_rand_t state, slong len, const fq_default_ctx_t ctx) + void fq_default_poly_randtest_monic(fq_default_poly_t f, flint_rand_t state, slong len, const fq_default_ctx_t ctx) noexcept # Sets `f` to a random monic polynomial of length ``len`` with # entries in the field described by ``ctx``. - void fq_default_poly_randtest_irreducible(fq_default_poly_t f, flint_rand_t state, slong len, const fq_default_ctx_t ctx) + void fq_default_poly_randtest_irreducible(fq_default_poly_t f, flint_rand_t state, slong len, const fq_default_ctx_t ctx) noexcept # Sets `f` to a random monic, irreducible polynomial of length # ``len`` with entries in the field described by ``ctx``. - void fq_default_poly_set(fq_default_poly_t poly1, const fq_default_poly_t poly2, const fq_default_ctx_t ctx) + void fq_default_poly_set(fq_default_poly_t poly1, const fq_default_poly_t poly2, const fq_default_ctx_t ctx) noexcept # Sets the polynomial ``poly1`` to the polynomial ``poly2``. - void fq_default_poly_set_fq_default(fq_default_poly_t poly, const fq_default_t c, const fq_default_ctx_t ctx) + void fq_default_poly_set_fq_default(fq_default_poly_t poly, const fq_default_t c, const fq_default_ctx_t ctx) noexcept # Sets the polynomial ``poly`` to ``c``. - void fq_default_poly_swap(fq_default_poly_t op1, fq_default_poly_t op2, const fq_default_ctx_t ctx) + void fq_default_poly_swap(fq_default_poly_t op1, fq_default_poly_t op2, const fq_default_ctx_t ctx) noexcept # Swaps the two polynomials ``op1`` and ``op2``. - void fq_default_poly_zero(fq_default_poly_t poly, const fq_default_ctx_t ctx) + void fq_default_poly_zero(fq_default_poly_t poly, const fq_default_ctx_t ctx) noexcept # Sets ``poly`` to the zero polynomial. - void fq_default_poly_one(fq_default_poly_t poly, const fq_default_ctx_t ctx) + void fq_default_poly_one(fq_default_poly_t poly, const fq_default_ctx_t ctx) noexcept # Sets ``poly`` to the constant polynomial `1`. - void fq_default_poly_gen(fq_default_poly_t poly, const fq_default_ctx_t ctx) + void fq_default_poly_gen(fq_default_poly_t poly, const fq_default_ctx_t ctx) noexcept # Sets ``poly`` to the polynomial `x`. - void fq_default_poly_make_monic(fq_default_poly_t rop, const fq_default_poly_t op, const fq_default_ctx_t ctx) + void fq_default_poly_make_monic(fq_default_poly_t rop, const fq_default_poly_t op, const fq_default_ctx_t ctx) noexcept # Sets ``rop`` to ``op``, normed to have leading coefficient 1. - void fq_default_poly_set_nmod_poly(fq_default_poly_t rop, const nmod_poly_t op, const fq_default_ctx_t ctx) + void fq_default_poly_set_nmod_poly(fq_default_poly_t rop, const nmod_poly_t op, const fq_default_ctx_t ctx) noexcept # Sets the polynomial ``rop`` to the polynomial ``op``. - void fq_default_poly_set_fmpz_mod_poly(fq_default_poly_t rop, const fmpz_mod_poly_t op, const fq_default_ctx_t ctx) + void fq_default_poly_set_fmpz_mod_poly(fq_default_poly_t rop, const fmpz_mod_poly_t op, const fq_default_ctx_t ctx) noexcept # Sets the polynomial ``rop`` to the polynomial ``op``. - void fq_default_poly_set_fmpz_poly(fq_default_poly_t rop, const fmpz_poly_t op, const fq_default_ctx_t ctx) + void fq_default_poly_set_fmpz_poly(fq_default_poly_t rop, const fmpz_poly_t op, const fq_default_ctx_t ctx) noexcept # Sets the polynomial ``rop`` to the polynomial ``op``. - void fq_default_poly_get_coeff(fq_default_t x, const fq_default_poly_t poly, slong n, const fq_default_ctx_t ctx) + void fq_default_poly_get_coeff(fq_default_t x, const fq_default_poly_t poly, slong n, const fq_default_ctx_t ctx) noexcept # Sets `x` to the coefficient of `X^n` in ``poly``. - void fq_default_poly_set_coeff(fq_default_poly_t poly, slong n, const fq_default_t x, const fq_default_ctx_t ctx) + void fq_default_poly_set_coeff(fq_default_poly_t poly, slong n, const fq_default_t x, const fq_default_ctx_t ctx) noexcept # Sets the coefficient of `X^n` in ``poly`` to `x`. - void fq_default_poly_set_coeff_fmpz(fq_default_poly_t poly, slong n, const fmpz_t x, const fq_default_ctx_t ctx) + void fq_default_poly_set_coeff_fmpz(fq_default_poly_t poly, slong n, const fmpz_t x, const fq_default_ctx_t ctx) noexcept # Sets the coefficient of `X^n` in the polynomial to `x`, # assuming `n \geq 0`. - bint fq_default_poly_equal(const fq_default_poly_t poly1, const fq_default_poly_t poly2, const fq_default_ctx_t ctx) + bint fq_default_poly_equal(const fq_default_poly_t poly1, const fq_default_poly_t poly2, const fq_default_ctx_t ctx) noexcept # Returns nonzero if the two polynomials ``poly1`` and ``poly2`` # are equal, otherwise returns zero. - bint fq_default_poly_equal_trunc(const fq_default_poly_t poly1, const fq_default_poly_t poly2, slong n, const fq_default_ctx_t ctx) + bint fq_default_poly_equal_trunc(const fq_default_poly_t poly1, const fq_default_poly_t poly2, slong n, const fq_default_ctx_t ctx) noexcept # Notionally truncate ``poly1`` and ``poly2`` to length `n` and # return nonzero if they are equal, otherwise return zero. - bint fq_default_poly_is_zero(const fq_default_poly_t poly, const fq_default_ctx_t ctx) + bint fq_default_poly_is_zero(const fq_default_poly_t poly, const fq_default_ctx_t ctx) noexcept # Returns whether the polynomial ``poly`` is the zero polynomial. - bint fq_default_poly_is_one(const fq_default_poly_t op, const fq_default_ctx_t ctx) + bint fq_default_poly_is_one(const fq_default_poly_t op, const fq_default_ctx_t ctx) noexcept # Returns whether the polynomial ``poly`` is equal # to the constant polynomial `1`. - bint fq_default_poly_is_gen(const fq_default_poly_t op, const fq_default_ctx_t ctx) + bint fq_default_poly_is_gen(const fq_default_poly_t op, const fq_default_ctx_t ctx) noexcept # Returns whether the polynomial ``poly`` is equal # to the polynomial `x`. - bint fq_default_poly_is_unit(const fq_default_poly_t op, const fq_default_ctx_t ctx) + bint fq_default_poly_is_unit(const fq_default_poly_t op, const fq_default_ctx_t ctx) noexcept # Returns whether the polynomial ``poly`` is a unit in the polynomial # ring `\mathbf{F}_q[X]`, i.e. if it has degree `0` and is non-zero. - bint fq_default_poly_equal_fq_default(const fq_default_poly_t poly, const fq_default_t c, const fq_default_ctx_t ctx) + bint fq_default_poly_equal_fq_default(const fq_default_poly_t poly, const fq_default_t c, const fq_default_ctx_t ctx) noexcept # Returns whether the polynomial ``poly`` is equal the (constant) # `\mathbf{F}_q` element ``c`` - void fq_default_poly_add(fq_default_poly_t res, const fq_default_poly_t poly1, const fq_default_poly_t poly2, const fq_default_ctx_t ctx) + void fq_default_poly_add(fq_default_poly_t res, const fq_default_poly_t poly1, const fq_default_poly_t poly2, const fq_default_ctx_t ctx) noexcept # Sets ``res`` to the sum of ``poly1`` and ``poly2``. - void fq_default_poly_add_si(fq_default_poly_t res, const fq_default_poly_t poly1, slong c, const fq_default_ctx_t ctx) + void fq_default_poly_add_si(fq_default_poly_t res, const fq_default_poly_t poly1, slong c, const fq_default_ctx_t ctx) noexcept # Sets ``res`` to the sum of ``poly1`` and ``c``. - void fq_default_poly_add_series(fq_default_poly_t res, const fq_default_poly_t poly1, const fq_default_poly_t poly2, slong n, const fq_default_ctx_t ctx) + void fq_default_poly_add_series(fq_default_poly_t res, const fq_default_poly_t poly1, const fq_default_poly_t poly2, slong n, const fq_default_ctx_t ctx) noexcept # Notionally truncate ``poly1`` and ``poly2`` to length ``n`` and set # ``res`` to the sum. - void fq_default_poly_sub(fq_default_poly_t res, const fq_default_poly_t poly1, const fq_default_poly_t poly2, const fq_default_ctx_t ctx) + void fq_default_poly_sub(fq_default_poly_t res, const fq_default_poly_t poly1, const fq_default_poly_t poly2, const fq_default_ctx_t ctx) noexcept # Sets ``res`` to the difference of ``poly1`` and ``poly2``. - void fq_default_poly_sub_series(fq_default_poly_t res, const fq_default_poly_t poly1, const fq_default_poly_t poly2, slong n, const fq_default_ctx_t ctx) + void fq_default_poly_sub_series(fq_default_poly_t res, const fq_default_poly_t poly1, const fq_default_poly_t poly2, slong n, const fq_default_ctx_t ctx) noexcept # Notionally truncate ``poly1`` and ``poly2`` to length ``n`` and set # ``res`` to the difference. - void fq_default_poly_neg(fq_default_poly_t res, const fq_default_poly_t poly, const fq_default_ctx_t ctx) + void fq_default_poly_neg(fq_default_poly_t res, const fq_default_poly_t poly, const fq_default_ctx_t ctx) noexcept # Sets ``res`` to the additive inverse of ``poly``. - void fq_default_poly_scalar_mul_fq_default(fq_default_poly_t rop, const fq_default_poly_t op, const fq_default_t x, const fq_default_ctx_t ctx) + void fq_default_poly_scalar_mul_fq_default(fq_default_poly_t rop, const fq_default_poly_t op, const fq_default_t x, const fq_default_ctx_t ctx) noexcept # Sets ``rop`` to the product of ``op`` by the scalar ``x``, in the context # defined by ``ctx``. - void fq_default_poly_scalar_addmul_fq_default(fq_default_poly_t rop, const fq_default_poly_t op, const fq_default_t x, const fq_default_ctx_t ctx) + void fq_default_poly_scalar_addmul_fq_default(fq_default_poly_t rop, const fq_default_poly_t op, const fq_default_t x, const fq_default_ctx_t ctx) noexcept # Adds to ``rop`` the product of ``op`` by the # scalar ``x``, in the context defined by ``ctx``. - void fq_default_poly_scalar_submul_fq_default(fq_default_poly_t rop, const fq_default_poly_t op, const fq_default_t x, const fq_default_ctx_t ctx) + void fq_default_poly_scalar_submul_fq_default(fq_default_poly_t rop, const fq_default_poly_t op, const fq_default_t x, const fq_default_ctx_t ctx) noexcept # Subtracts from ``rop`` the product of ``op`` by the # scalar ``x``, in the context defined by ``ctx``. - void fq_default_poly_scalar_div_fq_default(fq_default_poly_t rop, const fq_default_poly_t op, const fq_default_t x, const fq_default_ctx_t ctx) + void fq_default_poly_scalar_div_fq_default(fq_default_poly_t rop, const fq_default_poly_t op, const fq_default_t x, const fq_default_ctx_t ctx) noexcept # Sets ``rop`` to the quotient of ``op`` by the scalar ``x``, in the context # defined by ``ctx``. An exception is raised if ``x`` is zero. - void fq_default_poly_mul(fq_default_poly_t rop, const fq_default_poly_t op1, const fq_default_poly_t op2, const fq_default_ctx_t ctx) + void fq_default_poly_mul(fq_default_poly_t rop, const fq_default_poly_t op1, const fq_default_poly_t op2, const fq_default_ctx_t ctx) noexcept # Sets ``rop`` to the product of ``op1`` and ``op2``, # choosing an appropriate algorithm. - void fq_default_poly_mullow(fq_default_poly_t rop, const fq_default_poly_t op1, const fq_default_poly_t op2, slong n, const fq_default_ctx_t ctx) + void fq_default_poly_mullow(fq_default_poly_t rop, const fq_default_poly_t op1, const fq_default_poly_t op2, slong n, const fq_default_ctx_t ctx) noexcept # Sets ``rop`` to the lowest `n` coefficients of the product of # ``op1`` and ``op2``. - void fq_default_poly_mulhigh(fq_default_poly_t res, const fq_default_poly_t poly1, const fq_default_poly_t poly2, slong start, const fq_default_ctx_t ctx) + void fq_default_poly_mulhigh(fq_default_poly_t res, const fq_default_poly_t poly1, const fq_default_poly_t poly2, slong start, const fq_default_ctx_t ctx) noexcept # Computes the product of ``poly1`` and ``poly2`` and writes the # coefficients from ``start`` onwards into the high coefficients of # ``res``, the remaining coefficients being arbitrary but reduced. - void fq_default_poly_mulmod(fq_default_poly_t res, const fq_default_poly_t poly1, const fq_default_poly_t poly2, const fq_default_poly_t f, const fq_default_ctx_t ctx) + void fq_default_poly_mulmod(fq_default_poly_t res, const fq_default_poly_t poly1, const fq_default_poly_t poly2, const fq_default_poly_t f, const fq_default_ctx_t ctx) noexcept # Sets ``res`` to the remainder of the product of ``poly1`` # and ``poly2`` upon polynomial division by ``f``. - void fq_default_poly_sqr(fq_default_poly_t rop, const fq_default_poly_t op, const fq_default_ctx_t ctx) + void fq_default_poly_sqr(fq_default_poly_t rop, const fq_default_poly_t op, const fq_default_ctx_t ctx) noexcept # Sets ``rop`` to the square of ``op``, # choosing an appropriate algorithm. - void fq_default_poly_pow(fq_default_poly_t rop, const fq_default_poly_t op, ulong e, const fq_default_ctx_t ctx) + void fq_default_poly_pow(fq_default_poly_t rop, const fq_default_poly_t op, ulong e, const fq_default_ctx_t ctx) noexcept # Computes ``rop = op^e``. If `e` is zero, returns one, # so that in particular ``0^0 = 1``. - void fq_default_poly_powmod_ui_binexp(fq_default_poly_t res, const fq_default_poly_t poly, ulong e, const fq_default_poly_t f, const fq_default_ctx_t ctx) + void fq_default_poly_powmod_ui_binexp(fq_default_poly_t res, const fq_default_poly_t poly, ulong e, const fq_default_poly_t f, const fq_default_ctx_t ctx) noexcept # Sets ``res`` to ``poly`` raised to the power ``e`` modulo # ``f``, using binary exponentiation. We require ``e >= 0``. - void fq_default_poly_powmod_fmpz_binexp(fq_default_poly_t res, const fq_default_poly_t poly, const fmpz_t e, const fq_default_poly_t f, const fq_default_ctx_t ctx) + void fq_default_poly_powmod_fmpz_binexp(fq_default_poly_t res, const fq_default_poly_t poly, const fmpz_t e, const fq_default_poly_t f, const fq_default_ctx_t ctx) noexcept # Sets ``res`` to ``poly`` raised to the power ``e`` modulo # ``f``, using binary exponentiation. We require ``e >= 0``. - void fq_default_poly_pow_trunc(fq_default_poly_t res, const fq_default_poly_t poly, ulong e, slong trunc, const fq_default_ctx_t ctx) + void fq_default_poly_pow_trunc(fq_default_poly_t res, const fq_default_poly_t poly, ulong e, slong trunc, const fq_default_ctx_t ctx) noexcept # Sets ``res`` to the low ``trunc`` coefficients of ``poly`` # to the power ``e``. This is equivalent to doing a powering # followed by a truncation. - void fq_default_poly_shift_left(fq_default_poly_t rop, const fq_default_poly_t op, slong n, const fq_default_ctx_t ctx) + void fq_default_poly_shift_left(fq_default_poly_t rop, const fq_default_poly_t op, slong n, const fq_default_ctx_t ctx) noexcept # Sets ``rop`` to ``op`` shifted left by `n` coeffs. Zero # coefficients are inserted. - void fq_default_poly_shift_right(fq_default_poly_t rop, const fq_default_poly_t op, slong n, const fq_default_ctx_t ctx) + void fq_default_poly_shift_right(fq_default_poly_t rop, const fq_default_poly_t op, slong n, const fq_default_ctx_t ctx) noexcept # Sets ``rop`` to ``op`` shifted right by `n` coefficients. # If `n` is equal to or greater than the current length of # ``op``, ``rop`` is set to the zero polynomial. - slong fq_default_poly_hamming_weight(const fq_default_poly_t op, const fq_default_ctx_t ctx) + slong fq_default_poly_hamming_weight(const fq_default_poly_t op, const fq_default_ctx_t ctx) noexcept # Returns the number of non-zero entries in the polynomial ``op``. - void fq_default_poly_divrem(fq_default_poly_t Q, fq_default_poly_t R, const fq_default_poly_t A, const fq_default_poly_t B, const fq_default_ctx_t ctx) + void fq_default_poly_divrem(fq_default_poly_t Q, fq_default_poly_t R, const fq_default_poly_t A, const fq_default_poly_t B, const fq_default_ctx_t ctx) noexcept # Computes `Q`, `R` such that `A = B Q + R` with # `0 \leq \operatorname{len}(R) < \operatorname{len}(B)`. # Assumes that the leading coefficient of `B` is invertible. This can # be taken for granted the context is for a finite field, that is, when # `p` is prime and `f(X)` is irreducible. - void fq_default_poly_rem(fq_default_poly_t R, const fq_default_poly_t A, const fq_default_poly_t B, const fq_default_ctx_t ctx) + void fq_default_poly_rem(fq_default_poly_t R, const fq_default_poly_t A, const fq_default_poly_t B, const fq_default_ctx_t ctx) noexcept # Sets ``R`` to the remainder of the division of ``A`` by # ``B`` in the context described by ``ctx``. - void fq_default_poly_inv_series(fq_default_poly_t Qinv, const fq_default_poly_t Q, slong n, const fq_default_ctx_t ctx) + void fq_default_poly_inv_series(fq_default_poly_t Qinv, const fq_default_poly_t Q, slong n, const fq_default_ctx_t ctx) noexcept # Given ``Q`` find ``Qinv`` such that ``Q * Qinv`` is # ``1`` modulo `x^n`. The constant coefficient of ``Q`` must # be invertible modulo the modulus of ``Q``. An exception is # raised if this is not the case or if ``n = 0``. - void fq_default_poly_div_series(fq_default_poly_t Q, const fq_default_poly_t A, const fq_default_poly_t B, slong n, const fq_default_ctx_t ctx) + void fq_default_poly_div_series(fq_default_poly_t Q, const fq_default_poly_t A, const fq_default_poly_t B, slong n, const fq_default_ctx_t ctx) noexcept # Set `Q` to the quotient of the series `A` by `B`, thinking of the series as # though they were of length `n`. We assume that the bottom coefficient of # `B` is invertible. - void fq_default_poly_gcd(fq_default_poly_t rop, const fq_default_poly_t op1, const fq_default_poly_t op2, const fq_default_ctx_t ctx) + void fq_default_poly_gcd(fq_default_poly_t rop, const fq_default_poly_t op1, const fq_default_poly_t op2, const fq_default_ctx_t ctx) noexcept # Sets ``rop`` to the greatest common divisor of ``op1`` and # ``op2``, using the either the Euclidean or HGCD algorithm. The # GCD of zero polynomials is defined to be zero, whereas the GCD of @@ -267,7 +267,7 @@ cdef extern from "flint_wrap.h": # `P`. Except in the case where the GCD is zero, the GCD `G` is made # monic. - void fq_default_poly_xgcd(fq_default_poly_t G, fq_default_poly_t S, fq_default_poly_t T, const fq_default_poly_t A, const fq_default_poly_t B, const fq_default_ctx_t ctx) + void fq_default_poly_xgcd(fq_default_poly_t G, fq_default_poly_t S, fq_default_poly_t T, const fq_default_poly_t A, const fq_default_poly_t B, const fq_default_ctx_t ctx) noexcept # Computes the GCD of `A` and `B`. The GCD of zero polynomials is # defined to be zero, whereas the GCD of the zero polynomial and some other # polynomial `P` is defined to be `P`. Except in the case where @@ -276,83 +276,83 @@ cdef extern from "flint_wrap.h": # ``S*A + T*B = G``. The length of ``S`` will be at most # ``lenB`` and the length of ``T`` will be at most ``lenA``. - int fq_default_poly_divides(fq_default_poly_t Q, const fq_default_poly_t A, const fq_default_poly_t B, const fq_default_ctx_t ctx) + int fq_default_poly_divides(fq_default_poly_t Q, const fq_default_poly_t A, const fq_default_poly_t B, const fq_default_ctx_t ctx) noexcept # Returns `1` if `B` divides `A` exactly and sets `Q` to the quotient, # otherwise returns `0`. # This function is currently unoptimised and provided for convenience # only. - void fq_default_poly_derivative(fq_default_poly_t rop, const fq_default_poly_t op, const fq_default_ctx_t ctx) + void fq_default_poly_derivative(fq_default_poly_t rop, const fq_default_poly_t op, const fq_default_ctx_t ctx) noexcept # Sets ``rop`` to the derivative of ``op``. - void fq_default_poly_invsqrt_series(fq_default_poly_t g, const fq_default_poly_t h, slong n, fq_default_ctx_t ctx) + void fq_default_poly_invsqrt_series(fq_default_poly_t g, const fq_default_poly_t h, slong n, fq_default_ctx_t ctx) noexcept # Set `g` to the series expansion of `1/\sqrt{h}` to order `O(x^n)`. # It is assumed that `h` has constant term 1. - void fq_default_poly_sqrt_series(fq_default_poly_t g, const fq_default_poly_t h, slong n, fq_default_ctx_t ctx) + void fq_default_poly_sqrt_series(fq_default_poly_t g, const fq_default_poly_t h, slong n, fq_default_ctx_t ctx) noexcept # Set `g` to the series expansion of `\sqrt{h}` to order `O(x^n)`. # It is assumed that `h` has constant term 1. - int fq_default_poly_sqrt(fq_default_poly_t s, const fq_default_poly_t p, fq_default_ctx_t mod) + int fq_default_poly_sqrt(fq_default_poly_t s, const fq_default_poly_t p, fq_default_ctx_t mod) noexcept # If `p` is a perfect square, sets `s` to a square root of `p` # and returns 1. Otherwise returns 0. - void fq_default_poly_evaluate_fq_default(fq_default_t rop, const fq_default_poly_t f, const fq_default_t a, const fq_default_ctx_t ctx) + void fq_default_poly_evaluate_fq_default(fq_default_t rop, const fq_default_poly_t f, const fq_default_t a, const fq_default_ctx_t ctx) noexcept # Sets ``rop`` to the value of `f(a)`. # As the coefficient ring `\mathbf{F}_q` is finite, Horner's method # is sufficient. - void fq_default_poly_compose(fq_default_poly_t rop, const fq_default_poly_t op1, const fq_default_poly_t op2, const fq_default_ctx_t ctx) + void fq_default_poly_compose(fq_default_poly_t rop, const fq_default_poly_t op1, const fq_default_poly_t op2, const fq_default_ctx_t ctx) noexcept # Sets ``rop`` to the composition of ``op1`` and ``op2``. # To be precise about the order of composition, denoting ``rop``, # ``op1``, and ``op2`` by `f`, `g`, and `h`, respectively, # sets `f(t) = g(h(t))`. - void fq_default_poly_compose_mod(fq_default_poly_t res, const fq_default_poly_t f, const fq_default_poly_t g, const fq_default_poly_t h, const fq_default_ctx_t ctx) + void fq_default_poly_compose_mod(fq_default_poly_t res, const fq_default_poly_t f, const fq_default_poly_t g, const fq_default_poly_t h, const fq_default_ctx_t ctx) noexcept # Sets ``res`` to the composition `f(g)` modulo `h`. We require # that `h` is nonzero. - int fq_default_poly_fprint_pretty(FILE * file, const fq_default_poly_t poly, const char *x, const fq_default_ctx_t ctx) + int fq_default_poly_fprint_pretty(FILE * file, const fq_default_poly_t poly, const char *x, const fq_default_ctx_t ctx) noexcept # Prints the pretty representation of ``poly`` to the stream # ``file``, using the string ``x`` to represent the indeterminate. # In case of success, returns a positive value. In case of failure, # returns a non-positive value. - int fq_default_poly_print_pretty(const fq_default_poly_t poly, const char *x, const fq_default_ctx_t ctx) + int fq_default_poly_print_pretty(const fq_default_poly_t poly, const char *x, const fq_default_ctx_t ctx) noexcept # Prints the pretty representation of ``poly`` to ``stdout``, # using the string ``x`` to represent the indeterminate. # In case of success, returns a positive value. In case of failure, # returns a non-positive value. - int fq_default_poly_fprint(FILE * file, const fq_default_poly_t poly, const fq_default_ctx_t ctx) + int fq_default_poly_fprint(FILE * file, const fq_default_poly_t poly, const fq_default_ctx_t ctx) noexcept # Prints the pretty representation of ``poly`` to the stream # ``file``. # In case of success, returns a positive value. In case of failure, # returns a non-positive value. - int fq_default_poly_print(const fq_default_poly_t poly, const fq_default_ctx_t ctx) + int fq_default_poly_print(const fq_default_poly_t poly, const fq_default_ctx_t ctx) noexcept # Prints the representation of ``poly`` to ``stdout``. # In case of success, returns a positive value. In case of failure, # returns a non-positive value. - char * fq_default_poly_get_str(const fq_default_poly_t poly, const fq_default_ctx_t ctx) + char * fq_default_poly_get_str(const fq_default_poly_t poly, const fq_default_ctx_t ctx) noexcept # Returns the plain FLINT string representation of the polynomial # ``poly``. - char * fq_default_poly_get_str_pretty(const fq_default_poly_t poly, const char * x, const fq_default_ctx_t ctx) + char * fq_default_poly_get_str_pretty(const fq_default_poly_t poly, const char * x, const fq_default_ctx_t ctx) noexcept # Returns a pretty representation of the polynomial ``poly`` using the # null-terminated string ``x`` as the variable name - void fq_default_poly_inflate(fq_default_poly_t result, const fq_default_poly_t input, ulong inflation, const fq_default_ctx_t ctx) + void fq_default_poly_inflate(fq_default_poly_t result, const fq_default_poly_t input, ulong inflation, const fq_default_ctx_t ctx) noexcept # Sets ``result`` to the inflated polynomial `p(x^n)` where # `p` is given by ``input`` and `n` is given by ``inflation``. - void fq_default_poly_deflate(fq_default_poly_t result, const fq_default_poly_t input, ulong deflation, const fq_default_ctx_t ctx) + void fq_default_poly_deflate(fq_default_poly_t result, const fq_default_poly_t input, ulong deflation, const fq_default_ctx_t ctx) noexcept # Sets ``result`` to the deflated polynomial `p(x^{1/n})` where # `p` is given by ``input`` and `n` is given by ``deflation``. # Requires `n > 0`. - ulong fq_default_poly_deflation(const fq_default_poly_t input, const fq_default_ctx_t ctx) + ulong fq_default_poly_deflation(const fq_default_poly_t input, const fq_default_ctx_t ctx) noexcept # Returns the largest integer by which ``input`` can be deflated. # As special cases, returns 0 if ``input`` is the zero polynomial # and 1 of ``input`` is a constant polynomial. diff --git a/src/sage/libs/flint/fq_default_poly_factor.pxd b/src/sage/libs/flint/fq_default_poly_factor.pxd index f707e03cd2a..cc69e8a168c 100644 --- a/src/sage/libs/flint/fq_default_poly_factor.pxd +++ b/src/sage/libs/flint/fq_default_poly_factor.pxd @@ -12,80 +12,80 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void fq_default_poly_factor_init(fq_default_poly_factor_t fac, const fq_default_ctx_t ctx) + void fq_default_poly_factor_init(fq_default_poly_factor_t fac, const fq_default_ctx_t ctx) noexcept # Initialises ``fac`` for use. An :type:`fq_default_poly_factor_t` # represents a polynomial in factorised form as a product of # polynomials with associated exponents. - void fq_default_poly_factor_clear(fq_default_poly_factor_t fac, const fq_default_ctx_t ctx) + void fq_default_poly_factor_clear(fq_default_poly_factor_t fac, const fq_default_ctx_t ctx) noexcept # Frees all memory associated with ``fac``. - void fq_default_poly_factor_realloc(fq_default_poly_factor_t fac, slong alloc, const fq_default_ctx_t ctx) + void fq_default_poly_factor_realloc(fq_default_poly_factor_t fac, slong alloc, const fq_default_ctx_t ctx) noexcept # Reallocates the factor structure to provide space for # precisely ``alloc`` factors. - void fq_default_poly_factor_fit_length(fq_default_poly_factor_t fac, slong len, const fq_default_ctx_t ctx) + void fq_default_poly_factor_fit_length(fq_default_poly_factor_t fac, slong len, const fq_default_ctx_t ctx) noexcept # Ensures that the factor structure has space for at least # ``len`` factors. This function takes care of the case of # repeated calls by always at least doubling the number of factors # the structure can hold. - void fq_default_poly_factor_set(fq_default_poly_factor_t res, const fq_default_poly_factor_t fac, const fq_default_ctx_t ctx) + void fq_default_poly_factor_set(fq_default_poly_factor_t res, const fq_default_poly_factor_t fac, const fq_default_ctx_t ctx) noexcept # Sets ``res`` to the same factorisation as ``fac``. - void fq_default_poly_factor_print_pretty(const fq_default_poly_factor_t fac, const char * var, const fq_default_ctx_t ctx) + void fq_default_poly_factor_print_pretty(const fq_default_poly_factor_t fac, const char * var, const fq_default_ctx_t ctx) noexcept # Pretty-prints the entries of ``fac`` to standard output. - void fq_default_poly_factor_print(const fq_default_poly_factor_t fac, const fq_default_ctx_t ctx) + void fq_default_poly_factor_print(const fq_default_poly_factor_t fac, const fq_default_ctx_t ctx) noexcept # Prints the entries of ``fac`` to standard output. - void fq_default_poly_factor_insert(fq_default_poly_factor_t fac, const fq_default_poly_t poly, slong exp, const fq_default_ctx_t ctx) + void fq_default_poly_factor_insert(fq_default_poly_factor_t fac, const fq_default_poly_t poly, slong exp, const fq_default_ctx_t ctx) noexcept # Inserts the factor ``poly`` with multiplicity ``exp`` into # the factorisation ``fac``. # If ``fac`` already contains ``poly``, then ``exp`` simply # gets added to the exponent of the existing entry. - void fq_default_poly_factor_concat(fq_default_poly_factor_t res, const fq_default_poly_factor_t fac, const fq_default_ctx_t ctx) + void fq_default_poly_factor_concat(fq_default_poly_factor_t res, const fq_default_poly_factor_t fac, const fq_default_ctx_t ctx) noexcept # Concatenates two factorisations. # This is equivalent to calling :func:`fq_default_poly_factor_insert` # repeatedly with the individual factors of ``fac``. # Does not support aliasing between ``res`` and ``fac``. - void fq_default_poly_factor_pow(fq_default_poly_factor_t fac, slong exp, const fq_default_ctx_t ctx) + void fq_default_poly_factor_pow(fq_default_poly_factor_t fac, slong exp, const fq_default_ctx_t ctx) noexcept # Raises ``fac`` to the power ``exp``. - ulong fq_default_poly_remove(fq_default_poly_t f, const fq_default_poly_t p, const fq_default_ctx_t ctx) + ulong fq_default_poly_remove(fq_default_poly_t f, const fq_default_poly_t p, const fq_default_ctx_t ctx) noexcept # Removes the highest possible power of ``p`` from ``f`` and # returns the exponent. - slong fq_default_poly_factor_length(fq_default_poly_factor_t fac, const fq_default_ctx_t ctx) + slong fq_default_poly_factor_length(fq_default_poly_factor_t fac, const fq_default_ctx_t ctx) noexcept # Return the number of factors, not including the unit. - void fq_default_poly_factor_get_poly(fq_default_poly_t poly, const fq_default_poly_factor_t fac, slong i, const fq_default_ctx_t ctx) + void fq_default_poly_factor_get_poly(fq_default_poly_t poly, const fq_default_poly_factor_t fac, slong i, const fq_default_ctx_t ctx) noexcept # Set ``poly`` to factor ``i`` of ``fac`` (numbering starts at zero). - slong fq_default_poly_factor_exp(fq_default_poly_factor_t fac, slong i, const fq_default_ctx_t ctx) + slong fq_default_poly_factor_exp(fq_default_poly_factor_t fac, slong i, const fq_default_ctx_t ctx) noexcept # Return the exponent of factor ``i`` of ``fac``. - bint fq_default_poly_is_irreducible(const fq_default_poly_t f, const fq_default_ctx_t ctx) + bint fq_default_poly_is_irreducible(const fq_default_poly_t f, const fq_default_ctx_t ctx) noexcept # Returns 1 if the polynomial ``f`` is irreducible, otherwise returns 0. - bint fq_default_poly_is_squarefree(const fq_default_poly_t f, const fq_default_ctx_t ctx) + bint fq_default_poly_is_squarefree(const fq_default_poly_t f, const fq_default_ctx_t ctx) noexcept # Returns 1 if ``f`` is squarefree, and 0 otherwise. As a special # case, the zero polynomial is not considered squarefree. - void fq_default_poly_factor_equal_deg(fq_default_poly_factor_t factors, const fq_default_poly_t pol, slong d, const fq_default_ctx_t ctx) + void fq_default_poly_factor_equal_deg(fq_default_poly_factor_t factors, const fq_default_poly_t pol, slong d, const fq_default_ctx_t ctx) noexcept # Assuming ``pol`` is a product of irreducible factors all of # degree ``d``, finds all those factors and places them in # factors. Requires that ``pol`` be monic, non-constant and # squarefree. - void fq_default_poly_factor_split_single(fq_default_poly_t linfactor, const fq_default_poly_t input, const fq_default_ctx_t ctx) + void fq_default_poly_factor_split_single(fq_default_poly_t linfactor, const fq_default_poly_t input, const fq_default_ctx_t ctx) noexcept # Assuming ``input`` is a product of factors all of degree 1, finds a single # linear factor of ``input`` and places it in ``linfactor``. # Requires that ``input`` be monic and non-constant. - void fq_default_poly_factor_distinct_deg(fq_default_poly_factor_t res, const fq_default_poly_t poly, slong * const * degs, const fq_default_ctx_t ctx) + void fq_default_poly_factor_distinct_deg(fq_default_poly_factor_t res, const fq_default_poly_t poly, slong * const * degs, const fq_default_ctx_t ctx) noexcept # Factorises a monic non-constant squarefree polynomial ``poly`` # of degree `n` into factors `f[d]` such that for `1 \leq d \leq n` # `f[d]` is the product of the monic irreducible factors of @@ -95,16 +95,16 @@ cdef extern from "flint_wrap.h": # Requires that ``degs`` have enough space for irreducible polynomials' # powers (maximum space required is ``n * sizeof(slong)``). - void fq_default_poly_factor_squarefree(fq_default_poly_factor_t res, const fq_default_poly_t f, const fq_default_ctx_t ctx) + void fq_default_poly_factor_squarefree(fq_default_poly_factor_t res, const fq_default_poly_t f, const fq_default_ctx_t ctx) noexcept # Sets ``res`` to a squarefree factorization of ``f``. - void fq_default_poly_factor(fq_default_poly_factor_t res, fq_default_t lead, const fq_default_poly_t f, const fq_default_ctx_t ctx) + void fq_default_poly_factor(fq_default_poly_factor_t res, fq_default_t lead, const fq_default_poly_t f, const fq_default_ctx_t ctx) noexcept # Factorises a non-constant polynomial ``f`` into monic # irreducible factors choosing the best algorithm for given modulo # and degree. The output ``lead`` is set to the leading coefficient of `f` # upon return. Choice of algorithm is based on heuristic measurements. - void fq_default_poly_roots(fq_default_poly_factor_t r, const fq_default_poly_t f, int with_multiplicity, const fq_default_ctx_t ctx) + void fq_default_poly_roots(fq_default_poly_factor_t r, const fq_default_poly_t f, int with_multiplicity, const fq_default_ctx_t ctx) noexcept # Fill `r` with factors of the form `x - r_i` where the `r_i` are the distinct roots of a nonzero `f` in `F_q`. # If `with\_multiplicity` is zero, the exponent `e_i` of the factor `x - r_i` is `1`. Otherwise, it is the largest `e_i` such that `(x-r_i)^e_i` divides `f`. # This function throws if `f` is zero, but is otherwise always successful. diff --git a/src/sage/libs/flint/fq_embed.pxd b/src/sage/libs/flint/fq_embed.pxd index c440b3515fd..aa8a5b33015 100644 --- a/src/sage/libs/flint/fq_embed.pxd +++ b/src/sage/libs/flint/fq_embed.pxd @@ -12,7 +12,7 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void fq_embed_gens(fq_t gen_sub, fq_t gen_sup, fmpz_mod_poly_t minpoly, const fq_ctx_t sub_ctx, const fq_ctx_t sup_ctx) + void fq_embed_gens(fq_t gen_sub, fq_t gen_sup, fmpz_mod_poly_t minpoly, const fq_ctx_t sub_ctx, const fq_ctx_t sup_ctx) noexcept # Given two contexts ``sub_ctx`` and ``sup_ctx``, such that # ``degree(sub_ctx)`` divides ``degree(sup_ctx)``, compute: # * an element ``gen_sub`` in ``sub_ctx`` such that @@ -24,7 +24,7 @@ cdef extern from "flint_wrap.h": # These data uniquely define an embedding of ``sub_ctx`` into # ``sup_ctx``. - void _fq_embed_gens_naive(fq_t gen_sub, fq_t gen_sup, fmpz_mod_poly_t minpoly, const fq_ctx_t sub_ctx, const fq_ctx_t sup_ctx) + void _fq_embed_gens_naive(fq_t gen_sub, fq_t gen_sup, fmpz_mod_poly_t minpoly, const fq_ctx_t sub_ctx, const fq_ctx_t sup_ctx) noexcept # Given two contexts ``sub_ctx`` and ``sup_ctx``, such that # ``degree(sub_ctx)`` divides ``degree(sup_ctx)``, compute an # embedding of ``sub_ctx`` into ``sup_ctx`` defined as follows: @@ -34,7 +34,7 @@ cdef extern from "flint_wrap.h": # * ``gen_sup`` is a root of ``minpoly`` inside the field # defined by ``sup_ctx``. - void fq_embed_matrices(fmpz_mod_mat_t embed, fmpz_mod_mat_t project, const fq_t gen_sub, const fq_ctx_t sub_ctx, const fq_t gen_sup, const fq_ctx_t sup_ctx, const fmpz_mod_poly_t gen_minpoly) + void fq_embed_matrices(fmpz_mod_mat_t embed, fmpz_mod_mat_t project, const fq_t gen_sub, const fq_ctx_t sub_ctx, const fq_t gen_sup, const fq_ctx_t sup_ctx, const fmpz_mod_poly_t gen_minpoly) noexcept # Given: # * two contexts ``sub_ctx`` and ``sup_ctx``, of # respective degrees `m` and `n`, such that `m` divides `n`; @@ -49,7 +49,7 @@ cdef extern from "flint_wrap.h": # ``project`` `\times` ``embed`` is the `m\times m` identity # matrix. - void fq_embed_trace_matrix(fmpz_mod_mat_t res, const fmpz_mod_mat_t basis, const fq_ctx_t sub_ctx, const fq_ctx_t sup_ctx) + void fq_embed_trace_matrix(fmpz_mod_mat_t res, const fmpz_mod_mat_t basis, const fq_ctx_t sub_ctx, const fq_ctx_t sup_ctx) noexcept # Given: # * two contexts ``sub_ctx`` and ``sup_ctx``, of degrees # `m` and `n`, such that `m` divides `n`; @@ -65,33 +65,33 @@ cdef extern from "flint_wrap.h": # `m=n`, ``basis`` represents a Frobenius, and the result is its # inverse matrix. - void fq_embed_composition_matrix(fmpz_mod_mat_t matrix, const fq_t gen, const fq_ctx_t ctx) + void fq_embed_composition_matrix(fmpz_mod_mat_t matrix, const fq_t gen, const fq_ctx_t ctx) noexcept # Compute the *composition matrix* of ``gen``. # For an element `a\in\mathbf{F}_{p^n}`, its composition matrix is the # matrix whose columns are `a^0, a^1, \ldots, a^{n-1}`. - void fq_embed_composition_matrix_sub(fmpz_mod_mat_t matrix, const fq_t gen, const fq_ctx_t ctx, slong trunc) + void fq_embed_composition_matrix_sub(fmpz_mod_mat_t matrix, const fq_t gen, const fq_ctx_t ctx, slong trunc) noexcept # Compute the *composition matrix* of ``gen``, truncated to # ``trunc`` columns. - void fq_embed_mul_matrix(fmpz_mod_mat_t matrix, const fq_t gen, const fq_ctx_t ctx) + void fq_embed_mul_matrix(fmpz_mod_mat_t matrix, const fq_t gen, const fq_ctx_t ctx) noexcept # Compute the *multiplication matrix* of ``gen``. # For an element `a` in `\mathbf{F}_{p^n}=\mathbf{F}_p[x]`, its # multiplication matrix is the matrix whose columns are `a, ax, # \dots, ax^{n-1}`. - void fq_embed_mono_to_dual_matrix(fmpz_mod_mat_t res, const fq_ctx_t ctx) + void fq_embed_mono_to_dual_matrix(fmpz_mod_mat_t res, const fq_ctx_t ctx) noexcept # Compute the change of basis matrix from the monomial basis of # ``ctx`` to its dual basis. - void fq_embed_dual_to_mono_matrix(fmpz_mod_mat_t res, const fq_ctx_t ctx) + void fq_embed_dual_to_mono_matrix(fmpz_mod_mat_t res, const fq_ctx_t ctx) noexcept # Compute the change of basis matrix from the dual basis of # ``ctx`` to its monomial basis. - void fq_modulus_pow_series_inv(fmpz_mod_poly_t res, const fq_ctx_t ctx, slong trunc) + void fq_modulus_pow_series_inv(fmpz_mod_poly_t res, const fq_ctx_t ctx, slong trunc) noexcept # Compute the power series inverse of the reverse of the modulus of # ``ctx`` up to `O(x^\texttt{trunc})`. - void fq_modulus_derivative_inv(fq_t m_prime, fq_t m_prime_inv, const fq_ctx_t ctx) + void fq_modulus_derivative_inv(fq_t m_prime, fq_t m_prime_inv, const fq_ctx_t ctx) noexcept # Compute the derivative ``m_prime`` of the modulus of ``ctx`` # as an element of ``ctx``, and its inverse ``m_prime_inv``. diff --git a/src/sage/libs/flint/fq_mat.pxd b/src/sage/libs/flint/fq_mat.pxd index 6bdba3d3bbd..a0aba3868ff 100644 --- a/src/sage/libs/flint/fq_mat.pxd +++ b/src/sage/libs/flint/fq_mat.pxd @@ -12,117 +12,117 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void fq_mat_init(fq_mat_t mat, slong rows, slong cols, const fq_ctx_t ctx) + void fq_mat_init(fq_mat_t mat, slong rows, slong cols, const fq_ctx_t ctx) noexcept # Initialises ``mat`` to a ``rows``-by-``cols`` matrix with # coefficients in `\mathbf{F}_{q}` given by ``ctx``. All elements # are set to zero. - void fq_mat_init_set(fq_mat_t mat, const fq_mat_t src, const fq_ctx_t ctx) + void fq_mat_init_set(fq_mat_t mat, const fq_mat_t src, const fq_ctx_t ctx) noexcept # Initialises ``mat`` and sets its dimensions and elements to # those of ``src``. - void fq_mat_clear(fq_mat_t mat, const fq_ctx_t ctx) + void fq_mat_clear(fq_mat_t mat, const fq_ctx_t ctx) noexcept # Clears the matrix and releases any memory it used. The matrix # cannot be used again until it is initialised. This function must be # called exactly once when finished using an ``fq_mat_t`` object. - void fq_mat_set(fq_mat_t mat, const fq_mat_t src, const fq_ctx_t ctx) + void fq_mat_set(fq_mat_t mat, const fq_mat_t src, const fq_ctx_t ctx) noexcept # Sets ``mat`` to a copy of ``src``. It is assumed # that ``mat`` and ``src`` have identical dimensions. - fq_struct * fq_mat_entry(const fq_mat_t mat, slong i, slong j) + fq_struct * fq_mat_entry(const fq_mat_t mat, slong i, slong j) noexcept # Directly accesses the entry in ``mat`` in row `i` and column `j`, # indexed from zero. No bounds checking is performed. - void fq_mat_entry_set(fq_mat_t mat, slong i, slong j, const fq_t x, const fq_ctx_t ctx) + void fq_mat_entry_set(fq_mat_t mat, slong i, slong j, const fq_t x, const fq_ctx_t ctx) noexcept # Sets the entry in ``mat`` in row `i` and column `j` to ``x``. - slong fq_mat_nrows(const fq_mat_t mat, const fq_ctx_t ctx) + slong fq_mat_nrows(const fq_mat_t mat, const fq_ctx_t ctx) noexcept # Returns the number of rows in ``mat``. - slong fq_mat_ncols(const fq_mat_t mat, const fq_ctx_t ctx) + slong fq_mat_ncols(const fq_mat_t mat, const fq_ctx_t ctx) noexcept # Returns the number of columns in ``mat``. - void fq_mat_swap(fq_mat_t mat1, fq_mat_t mat2, const fq_ctx_t ctx) + void fq_mat_swap(fq_mat_t mat1, fq_mat_t mat2, const fq_ctx_t ctx) noexcept # Swaps two matrices. The dimensions of ``mat1`` and ``mat2`` # are allowed to be different. - void fq_mat_swap_entrywise(fq_mat_t mat1, fq_mat_t mat2, const fq_ctx_t ctx) + void fq_mat_swap_entrywise(fq_mat_t mat1, fq_mat_t mat2, const fq_ctx_t ctx) noexcept # Swaps two matrices by swapping the individual entries rather than swapping # the contents of the structs. - void fq_mat_zero(fq_mat_t mat, const fq_ctx_t ctx) + void fq_mat_zero(fq_mat_t mat, const fq_ctx_t ctx) noexcept # Sets all entries of ``mat`` to 0. - void fq_mat_one(fq_mat_t mat, const fq_ctx_t ctx) + void fq_mat_one(fq_mat_t mat, const fq_ctx_t ctx) noexcept # Sets all the diagonal entries of ``mat`` to 1 and all other entries to 0. - void fq_mat_swap_rows(fq_mat_t mat, slong * perm, slong r, slong s, const fq_ctx_t ctx) + void fq_mat_swap_rows(fq_mat_t mat, slong * perm, slong r, slong s, const fq_ctx_t ctx) noexcept # Swaps rows ``r`` and ``s`` of ``mat``. If ``perm`` is non-``NULL``, the # permutation of the rows will also be applied to ``perm``. - void fq_mat_swap_cols(fq_mat_t mat, slong * perm, slong r, slong s, const fq_ctx_t ctx) + void fq_mat_swap_cols(fq_mat_t mat, slong * perm, slong r, slong s, const fq_ctx_t ctx) noexcept # Swaps columns ``r`` and ``s`` of ``mat``. If ``perm`` is non-``NULL``, the # permutation of the columns will also be applied to ``perm``. - void fq_mat_invert_rows(fq_mat_t mat, slong * perm, const fq_ctx_t ctx) + void fq_mat_invert_rows(fq_mat_t mat, slong * perm, const fq_ctx_t ctx) noexcept # Swaps rows ``i`` and ``r - i`` of ``mat`` for ``0 <= i < r/2``, where # ``r`` is the number of rows of ``mat``. If ``perm`` is non-``NULL``, the # permutation of the rows will also be applied to ``perm``. - void fq_mat_invert_cols(fq_mat_t mat, slong * perm, const fq_ctx_t ctx) + void fq_mat_invert_cols(fq_mat_t mat, slong * perm, const fq_ctx_t ctx) noexcept # Swaps columns ``i`` and ``c - i`` of ``mat`` for ``0 <= i < c/2``, where # ``c`` is the number of columns of ``mat``. If ``perm`` is non-``NULL``, the # permutation of the columns will also be applied to ``perm``. - void fq_mat_set_nmod_mat(fq_mat_t mat1, const nmod_mat_t mat2, const fq_ctx_t ctx) + void fq_mat_set_nmod_mat(fq_mat_t mat1, const nmod_mat_t mat2, const fq_ctx_t ctx) noexcept # Sets the matrix ``mat1`` to the matrix ``mat2``. - void fq_mat_set_fmpz_mod_mat(fq_mat_t mat1, const fmpz_mod_mat_t mat2, const fq_ctx_t ctx) + void fq_mat_set_fmpz_mod_mat(fq_mat_t mat1, const fmpz_mod_mat_t mat2, const fq_ctx_t ctx) noexcept # Sets the matrix ``mat1`` to the matrix ``mat2``. - void fq_mat_concat_vertical(fq_mat_t res, const fq_mat_t mat1, const fq_mat_t mat2, const fq_ctx_t ctx) + void fq_mat_concat_vertical(fq_mat_t res, const fq_mat_t mat1, const fq_mat_t mat2, const fq_ctx_t ctx) noexcept # Sets ``res`` to vertical concatenation of (``mat1``, ``mat2``) in that order. Matrix dimensions : ``mat1`` : `m \times n`, ``mat2`` : `k \times n`, ``res`` : `(m + k) \times n`. - void fq_mat_concat_horizontal(fq_mat_t res, const fq_mat_t mat1, const fq_mat_t mat2, const fq_ctx_t ctx) + void fq_mat_concat_horizontal(fq_mat_t res, const fq_mat_t mat1, const fq_mat_t mat2, const fq_ctx_t ctx) noexcept # Sets ``res`` to horizontal concatenation of (``mat1``, ``mat2``) in that order. Matrix dimensions : ``mat1`` : `m \times n`, ``mat2`` : `m \times k`, ``res`` : `m \times (n + k)`. - int fq_mat_print_pretty(const fq_mat_t mat, const fq_ctx_t ctx) + int fq_mat_print_pretty(const fq_mat_t mat, const fq_ctx_t ctx) noexcept # Pretty-prints ``mat`` to ``stdout``. A header is printed # followed by the rows enclosed in brackets. - int fq_mat_fprint_pretty(FILE * file, const fq_mat_t mat, const fq_ctx_t ctx) + int fq_mat_fprint_pretty(FILE * file, const fq_mat_t mat, const fq_ctx_t ctx) noexcept # Pretty-prints ``mat`` to ``file``. A header is printed # followed by the rows enclosed in brackets. # In case of success, returns a positive value. In case of failure, # returns a non-positive value. - int fq_mat_print(const fq_mat_t mat, const fq_ctx_t ctx) + int fq_mat_print(const fq_mat_t mat, const fq_ctx_t ctx) noexcept # Prints ``mat`` to ``stdout``. A header is printed followed # by the rows enclosed in brackets. - int fq_mat_fprint(FILE * file, const fq_mat_t mat, const fq_ctx_t ctx) + int fq_mat_fprint(FILE * file, const fq_mat_t mat, const fq_ctx_t ctx) noexcept # Prints ``mat`` to ``file``. A header is printed followed by # the rows enclosed in brackets. # In case of success, returns a positive value. In case of failure, # returns a non-positive value. - void fq_mat_window_init(fq_mat_t window, const fq_mat_t mat, slong r1, slong c1, slong r2, slong c2, const fq_ctx_t ctx) + void fq_mat_window_init(fq_mat_t window, const fq_mat_t mat, slong r1, slong c1, slong r2, slong c2, const fq_ctx_t ctx) noexcept # Initializes the matrix ``window`` to be an ``r2 - r1`` by # ``c2 - c1`` submatrix of ``mat`` whose ``(0,0)`` entry # is the ``(r1, c1)`` entry of ``mat``. The memory for the # elements of ``window`` is shared with ``mat``. - void fq_mat_window_clear(fq_mat_t window, const fq_ctx_t ctx) + void fq_mat_window_clear(fq_mat_t window, const fq_ctx_t ctx) noexcept # Clears the matrix ``window`` and releases any memory that it # uses. Note that the memory to the underlying matrix that # ``window`` points to is not freed. - void fq_mat_randtest(fq_mat_t mat, flint_rand_t state, const fq_ctx_t ctx) + void fq_mat_randtest(fq_mat_t mat, flint_rand_t state, const fq_ctx_t ctx) noexcept # Sets the elements of ``mat`` to random elements of # `\mathbf{F}_{q}`, given by ``ctx``. - int fq_mat_randpermdiag(fq_mat_t mat, flint_rand_t state, fq_struct * diag, slong n, const fq_ctx_t ctx) + int fq_mat_randpermdiag(fq_mat_t mat, flint_rand_t state, fq_struct * diag, slong n, const fq_ctx_t ctx) noexcept # Sets ``mat`` to a random permutation of the diagonal matrix # with `n` leading entries given by the vector ``diag``. It is # assumed that the main diagonal of ``mat`` has room for at @@ -130,7 +130,7 @@ cdef extern from "flint_wrap.h": # Returns `0` or `1`, depending on whether the permutation is even # or odd respectively. - void fq_mat_randrank(fq_mat_t mat, flint_rand_t state, slong rank, const fq_ctx_t ctx) + void fq_mat_randrank(fq_mat_t mat, flint_rand_t state, slong rank, const fq_ctx_t ctx) noexcept # Sets ``mat`` to a random sparse matrix with the given rank, # having exactly as many non-zero elements as the rank, with the # non-zero elements being uniformly random elements of @@ -138,92 +138,92 @@ cdef extern from "flint_wrap.h": # The matrix can be transformed into a dense matrix with unchanged # rank by subsequently calling :func:`fq_mat_randops`. - void fq_mat_randops(fq_mat_t mat, slong count, flint_rand_t state, const fq_ctx_t ctx) + void fq_mat_randops(fq_mat_t mat, slong count, flint_rand_t state, const fq_ctx_t ctx) noexcept # Randomises ``mat`` by performing elementary row or column # operations. More precisely, at most ``count`` random additions # or subtractions of distinct rows and columns will be performed. # This leaves the rank (and for square matrices, determinant) # unchanged. - void fq_mat_randtril(fq_mat_t mat, flint_rand_t state, int unit, const fq_ctx_t ctx) + void fq_mat_randtril(fq_mat_t mat, flint_rand_t state, int unit, const fq_ctx_t ctx) noexcept # Sets ``mat`` to a random lower triangular matrix. If # ``unit`` is 1, it will have ones on the main diagonal, # otherwise it will have random nonzero entries on the main # diagonal. - void fq_mat_randtriu(fq_mat_t mat, flint_rand_t state, int unit, const fq_ctx_t ctx) + void fq_mat_randtriu(fq_mat_t mat, flint_rand_t state, int unit, const fq_ctx_t ctx) noexcept # Sets ``mat`` to a random upper triangular matrix. If # ``unit`` is 1, it will have ones on the main diagonal, # otherwise it will have random nonzero entries on the main # diagonal. - bint fq_mat_equal(const fq_mat_t mat1, const fq_mat_t mat2, const fq_ctx_t ctx) + bint fq_mat_equal(const fq_mat_t mat1, const fq_mat_t mat2, const fq_ctx_t ctx) noexcept # Returns nonzero if mat1 and mat2 have the same dimensions and elements, # and zero otherwise. - bint fq_mat_is_zero(const fq_mat_t mat, const fq_ctx_t ctx) + bint fq_mat_is_zero(const fq_mat_t mat, const fq_ctx_t ctx) noexcept # Returns a non-zero value if all entries of ``mat`` are zero, and # otherwise returns zero. - bint fq_mat_is_one(const fq_mat_t mat, const fq_ctx_t ctx) + bint fq_mat_is_one(const fq_mat_t mat, const fq_ctx_t ctx) noexcept # Returns a non-zero value if all entries ``mat`` are zero except the # diagonal entries which must be one, otherwise returns zero.. - bint fq_mat_is_empty(const fq_mat_t mat, const fq_ctx_t ctx) + bint fq_mat_is_empty(const fq_mat_t mat, const fq_ctx_t ctx) noexcept # Returns a non-zero value if the number of rows or the number of # columns in ``mat`` is zero, and otherwise returns zero. - bint fq_mat_is_square(const fq_mat_t mat, const fq_ctx_t ctx) + bint fq_mat_is_square(const fq_mat_t mat, const fq_ctx_t ctx) noexcept # Returns a non-zero value if the number of rows is equal to the # number of columns in ``mat``, and otherwise returns zero. - void fq_mat_add(fq_mat_t C, const fq_mat_t A, const fq_mat_t B, const fq_ctx_t ctx) + void fq_mat_add(fq_mat_t C, const fq_mat_t A, const fq_mat_t B, const fq_ctx_t ctx) noexcept # Computes `C = A + B`. Dimensions must be identical. - void fq_mat_sub(fq_mat_t C, const fq_mat_t A, const fq_mat_t B, const fq_ctx_t ctx) + void fq_mat_sub(fq_mat_t C, const fq_mat_t A, const fq_mat_t B, const fq_ctx_t ctx) noexcept # Computes `C = A - B`. Dimensions must be identical. - void fq_mat_neg(fq_mat_t A, const fq_mat_t B, const fq_ctx_t ctx) + void fq_mat_neg(fq_mat_t A, const fq_mat_t B, const fq_ctx_t ctx) noexcept # Sets `B = -A`. Dimensions must be identical. - void fq_mat_mul(fq_mat_t C, const fq_mat_t A, const fq_mat_t B, const fq_ctx_t ctx) + void fq_mat_mul(fq_mat_t C, const fq_mat_t A, const fq_mat_t B, const fq_ctx_t ctx) noexcept # Sets `C = AB`. Dimensions must be compatible for matrix # multiplication. Aliasing is allowed. This function automatically chooses # between classical and KS multiplication. - void fq_mat_mul_classical(fq_mat_t C, const fq_mat_t A, const fq_mat_t B, const fq_ctx_t ctx) + void fq_mat_mul_classical(fq_mat_t C, const fq_mat_t A, const fq_mat_t B, const fq_ctx_t ctx) noexcept # Sets `C = AB`. Dimensions must be compatible for matrix multiplication. # `C` is not allowed to be aliased with `A` or `B`. Uses classical # matrix multiplication. - void fq_mat_mul_KS(fq_mat_t C, const fq_mat_t A, const fq_mat_t B, const fq_ctx_t ctx) + void fq_mat_mul_KS(fq_mat_t C, const fq_mat_t A, const fq_mat_t B, const fq_ctx_t ctx) noexcept # Sets `C = AB`. Dimensions must be compatible for matrix # multiplication. `C` is not allowed to be aliased with `A` or # `B`. Uses Kronecker substitution to perform the multiplication # over the integers. - void fq_mat_submul(fq_mat_t D, const fq_mat_t C, const fq_mat_t A, const fq_mat_t B, const fq_ctx_t ctx) + void fq_mat_submul(fq_mat_t D, const fq_mat_t C, const fq_mat_t A, const fq_mat_t B, const fq_ctx_t ctx) noexcept # Sets `D = C + AB`. `C` and `D` may be aliased with each other but # not with `A` or `B`. - void fq_mat_mul_vec(fq_struct * c, const fq_mat_t A, const fq_struct * b, slong blen, const fq_ctx_t ctx) - void fq_mat_mul_vec_ptr(fq_struct * const * c, const fq_mat_t A, const fq_struct * const * b, slong blen, const fq_ctx_t ctx) + void fq_mat_mul_vec(fq_struct * c, const fq_mat_t A, const fq_struct * b, slong blen, const fq_ctx_t ctx) noexcept + void fq_mat_mul_vec_ptr(fq_struct * const * c, const fq_mat_t A, const fq_struct * const * b, slong blen, const fq_ctx_t ctx) noexcept # Compute a matrix-vector product of ``A`` and ``(b, blen)`` and store the result in ``c``. # The vector ``(b, blen)`` is either truncated or zero-extended to the number of columns of ``A``. # The number entries written to ``c`` is always equal to the number of rows of ``A``. - void fq_mat_vec_mul(fq_struct * c, const fq_struct * a, slong alen, const fq_mat_t B, const fq_ctx_t ctx) - void fq_mat_vec_mul_ptr(fq_struct * const * c, const fq_struct * const * a, slong alen, const fq_mat_t B, const fq_ctx_t ctx) + void fq_mat_vec_mul(fq_struct * c, const fq_struct * a, slong alen, const fq_mat_t B, const fq_ctx_t ctx) noexcept + void fq_mat_vec_mul_ptr(fq_struct * const * c, const fq_struct * const * a, slong alen, const fq_mat_t B, const fq_ctx_t ctx) noexcept # Compute a vector-matrix product of ``(a, alen)`` and ``B`` and and store the result in ``c``. # The vector ``(a, alen)`` is either truncated or zero-extended to the number of rows of ``B``. # The number entries written to ``c`` is always equal to the number of columns of ``B``. - int fq_mat_inv(fq_mat_t B, fq_mat_t A, const fq_ctx_t ctx) + int fq_mat_inv(fq_mat_t B, fq_mat_t A, const fq_ctx_t ctx) noexcept # Sets `B = A^{-1}` and returns `1` if `A` is invertible. If `A` is singular, # returns `0` and sets the elements of `B` to undefined values. # `A` and `B` must be square matrices with the same dimensions. - slong fq_mat_lu(slong * P, fq_mat_t A, int rank_check, const fq_ctx_t ctx) + slong fq_mat_lu(slong * P, fq_mat_t A, int rank_check, const fq_ctx_t ctx) noexcept # Computes a generalised LU decomposition `LU = PA` of a given # matrix `A`, returning the rank of `A`. # If `A` is a nonsingular square matrix, it will be overwritten with @@ -240,26 +240,26 @@ cdef extern from "flint_wrap.h": # if `A` is detected to be rank-deficient. # This function calls ``fq_mat_lu_recursive``. - slong fq_mat_lu_classical(slong * P, fq_mat_t A, int rank_check, const fq_ctx_t ctx) + slong fq_mat_lu_classical(slong * P, fq_mat_t A, int rank_check, const fq_ctx_t ctx) noexcept # Computes a generalised LU decomposition `LU = PA` of a given # matrix `A`, returning the rank of `A`. The behavior of this # function is identical to that of ``fq_mat_lu``. Uses Gaussian # elimination. - slong fq_mat_lu_recursive(slong * P, fq_mat_t A, int rank_check, const fq_ctx_t ctx) + slong fq_mat_lu_recursive(slong * P, fq_mat_t A, int rank_check, const fq_ctx_t ctx) noexcept # Computes a generalised LU decomposition `LU = PA` of a given # matrix `A`, returning the rank of `A`. The behavior of this # function is identical to that of ``fq_mat_lu``. Uses recursive # block decomposition, switching to classical Gaussian elimination # for sufficiently small blocks. - slong fq_mat_rref(fq_mat_t A, const fq_ctx_t ctx) + slong fq_mat_rref(fq_mat_t A, const fq_ctx_t ctx) noexcept # Puts `A` in reduced row echelon form and returns the rank of `A`. # The rref is computed by first obtaining an unreduced row echelon # form via LU decomposition and then solving an additional # triangular system. - slong fq_mat_reduce_row(fq_mat_t A, slong * P, slong * L, slong n, const fq_ctx_t ctx) + slong fq_mat_reduce_row(fq_mat_t A, slong * P, slong * L, slong n, const fq_ctx_t ctx) noexcept # Reduce row n of the matrix `A`, assuming the prior rows are in Gauss # form. However those rows may not be in order. The entry `i` of the array # `P` is the row of `A` which has a pivot in the `i`-th column. If no such @@ -272,7 +272,7 @@ cdef extern from "flint_wrap.h": # `L` can all be set to the number of columns of `A`. We require the entries # of `L` to be monotonic increasing. - void fq_mat_solve_tril(fq_mat_t X, const fq_mat_t L, const fq_mat_t B, int unit, const fq_ctx_t ctx) + void fq_mat_solve_tril(fq_mat_t X, const fq_mat_t L, const fq_mat_t B, int unit, const fq_ctx_t ctx) noexcept # Sets `X = L^{-1} B` where `L` is a full rank lower triangular # square matrix. If ``unit`` = 1, `L` is assumed to have ones on # its main diagonal, and the main diagonal will not be read. `X` @@ -280,14 +280,14 @@ cdef extern from "flint_wrap.h": # is allowed. Automatically chooses between the classical and # recursive algorithms. - void fq_mat_solve_tril_classical(fq_mat_t X, const fq_mat_t L, const fq_mat_t B, int unit, const fq_ctx_t ctx) + void fq_mat_solve_tril_classical(fq_mat_t X, const fq_mat_t L, const fq_mat_t B, int unit, const fq_ctx_t ctx) noexcept # Sets `X = L^{-1} B` where `L` is a full rank lower triangular # square matrix. If ``unit`` = 1, `L` is assumed to have ones on # its main diagonal, and the main diagonal will not be read. `X` # and `B` are allowed to be the same matrix, but no other aliasing # is allowed. Uses forward substitution. - void fq_mat_solve_tril_recursive(fq_mat_t X, const fq_mat_t L, const fq_mat_t B, int unit, const fq_ctx_t ctx) + void fq_mat_solve_tril_recursive(fq_mat_t X, const fq_mat_t L, const fq_mat_t B, int unit, const fq_ctx_t ctx) noexcept # Sets `X = L^{-1} B` where `L` is a full rank lower triangular # square matrix. If ``unit`` = 1, `L` is assumed to have ones on # its main diagonal, and the main diagonal will not be read. `X` @@ -301,7 +301,7 @@ cdef extern from "flint_wrap.h": # to reduce the problem to matrix multiplication and triangular # solving of smaller systems. - void fq_mat_solve_triu(fq_mat_t X, const fq_mat_t U, const fq_mat_t B, int unit, const fq_ctx_t ctx) + void fq_mat_solve_triu(fq_mat_t X, const fq_mat_t U, const fq_mat_t B, int unit, const fq_ctx_t ctx) noexcept # Sets `X = U^{-1} B` where `U` is a full rank upper triangular # square matrix. If ``unit`` = 1, `U` is assumed to have ones on # its main diagonal, and the main diagonal will not be read. `X` @@ -309,14 +309,14 @@ cdef extern from "flint_wrap.h": # is allowed. Automatically chooses between the classical and # recursive algorithms. - void fq_mat_solve_triu_classical(fq_mat_t X, const fq_mat_t U, const fq_mat_t B, int unit, const fq_ctx_t ctx) + void fq_mat_solve_triu_classical(fq_mat_t X, const fq_mat_t U, const fq_mat_t B, int unit, const fq_ctx_t ctx) noexcept # Sets `X = U^{-1} B` where `U` is a full rank upper triangular # square matrix. If ``unit`` = 1, `U` is assumed to have ones on # its main diagonal, and the main diagonal will not be read. `X` # and `B` are allowed to be the same matrix, but no other aliasing # is allowed. Uses forward substitution. - void fq_mat_solve_triu_recursive(fq_mat_t X, const fq_mat_t U, const fq_mat_t B, int unit, const fq_ctx_t ctx) + void fq_mat_solve_triu_recursive(fq_mat_t X, const fq_mat_t U, const fq_mat_t B, int unit, const fq_ctx_t ctx) noexcept # Sets `X = U^{-1} B` where `U` is a full rank upper triangular # square matrix. If ``unit`` = 1, `U` is assumed to have ones on # its main diagonal, and the main diagonal will not be read. `X` @@ -330,20 +330,20 @@ cdef extern from "flint_wrap.h": # to reduce the problem to matrix multiplication and triangular # solving of smaller systems. - int fq_mat_solve(fq_mat_t X, const fq_mat_t A, const fq_mat_t B, const fq_ctx_t ctx) + int fq_mat_solve(fq_mat_t X, const fq_mat_t A, const fq_mat_t B, const fq_ctx_t ctx) noexcept # Solves the matrix-matrix equation `AX = B`. # Returns `1` if `A` has full rank; otherwise returns `0` and sets the # elements of `X` to undefined values. # The matrix `A` must be square. - int fq_mat_can_solve(fq_mat_t X, const fq_mat_t A, const fq_mat_t B, const fq_ctx_t ctx) + int fq_mat_can_solve(fq_mat_t X, const fq_mat_t A, const fq_mat_t B, const fq_ctx_t ctx) noexcept # Solves the matrix-matrix equation `AX = B` over `Fq`. # Returns `1` if a solution exists; otherwise returns `0` and sets the # elements of `X` to zero. If more than one solution exists, one of the # valid solutions is given. # There are no restrictions on the shape of `A` and it may be singular. - void fq_mat_similarity(fq_mat_t M, slong r, fq_t d, const fq_ctx_t ctx) + void fq_mat_similarity(fq_mat_t M, slong r, fq_t d, const fq_ctx_t ctx) noexcept # Applies a similarity transform to the `n\times n` matrix `M` in-place. # If `P` is the `n\times n` identity matrix the zero entries of whose row # `r` (`0`-indexed) have been replaced by `d`, this transform is equivalent @@ -353,14 +353,14 @@ cdef extern from "flint_wrap.h": # The value `d` is required to be reduced modulo the modulus of the entries # in the matrix. - void fq_mat_charpoly_danilevsky(fq_poly_t p, const fq_mat_t M, const fq_ctx_t ctx) + void fq_mat_charpoly_danilevsky(fq_poly_t p, const fq_mat_t M, const fq_ctx_t ctx) noexcept # Compute the characteristic polynomial `p` of the matrix `M`. The matrix # is assumed to be square. - void fq_mat_charpoly(fq_poly_t p, const fq_mat_t M, const fq_ctx_t ctx) + void fq_mat_charpoly(fq_poly_t p, const fq_mat_t M, const fq_ctx_t ctx) noexcept # Compute the characteristic polynomial `p` of the matrix `M`. The matrix # is required to be square, otherwise an exception is raised. - void fq_mat_minpoly(fq_poly_t p, const fq_mat_t M, const fq_ctx_t ctx) + void fq_mat_minpoly(fq_poly_t p, const fq_mat_t M, const fq_ctx_t ctx) noexcept # Compute the minimal polynomial `p` of the matrix `M`. The matrix # is required to be square, otherwise an exception is raised. diff --git a/src/sage/libs/flint/fq_nmod.pxd b/src/sage/libs/flint/fq_nmod.pxd index 5c661eeaf96..f87d0cb2b50 100644 --- a/src/sage/libs/flint/fq_nmod.pxd +++ b/src/sage/libs/flint/fq_nmod.pxd @@ -12,7 +12,7 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void fq_nmod_ctx_init(fq_nmod_ctx_t ctx, const fmpz_t p, slong d, const char *var) + void fq_nmod_ctx_init(fq_nmod_ctx_t ctx, const fmpz_t p, slong d, const char *var) noexcept # Initialises the context for prime `p` and extension degree `d`, # with name ``var`` for the generator. By default, it will try # use a Conway polynomial; if one is not available, a random @@ -21,7 +21,7 @@ cdef extern from "flint_wrap.h": # Assumes that the string ``var`` is a null-terminated string # of length at least one. - int _fq_nmod_ctx_init_conway(fq_nmod_ctx_t ctx, const fmpz_t p, slong d, const char *var) + int _fq_nmod_ctx_init_conway(fq_nmod_ctx_t ctx, const fmpz_t p, slong d, const char *var) noexcept # Attempts to initialise the context for prime `p` and extension # degree `d`, with name ``var`` for the generator using a Conway # polynomial for the modulus. @@ -32,7 +32,7 @@ cdef extern from "flint_wrap.h": # Assumes that the string ``var`` is a null-terminated string # of length at least one. - void fq_nmod_ctx_init_conway(fq_nmod_ctx_t ctx, const fmpz_t p, slong d, const char *var) + void fq_nmod_ctx_init_conway(fq_nmod_ctx_t ctx, const fmpz_t p, slong d, const char *var) noexcept # Initialises the context for prime `p` and extension degree `d`, # with name ``var`` for the generator using a Conway polynomial # for the modulus. @@ -40,7 +40,7 @@ cdef extern from "flint_wrap.h": # Assumes that the string ``var`` is a null-terminated string # of length at least one. - void fq_nmod_ctx_init_modulus(fq_nmod_ctx_t ctx, const nmod_poly_t modulus, const char *var) + void fq_nmod_ctx_init_modulus(fq_nmod_ctx_t ctx, const nmod_poly_t modulus, const char *var) noexcept # Initialises the context for given ``modulus`` with name # ``var`` for the generator. # Assumes that ``modulus`` is an irreducible polynomial over @@ -48,111 +48,111 @@ cdef extern from "flint_wrap.h": # Assumes that the string ``var`` is a null-terminated string # of length at least one. - void fq_nmod_ctx_clear(fq_nmod_ctx_t ctx) + void fq_nmod_ctx_clear(fq_nmod_ctx_t ctx) noexcept # Clears all memory that has been allocated as part of the context. - const nmod_poly_struct* fq_nmod_ctx_modulus(const fq_nmod_ctx_t ctx) + const nmod_poly_struct* fq_nmod_ctx_modulus(const fq_nmod_ctx_t ctx) noexcept # Returns a pointer to the modulus in the context. - slong fq_nmod_ctx_degree(const fq_nmod_ctx_t ctx) + slong fq_nmod_ctx_degree(const fq_nmod_ctx_t ctx) noexcept # Returns the degree of the field extension # `[\mathbf{F}_{q} : \mathbf{F}_{p}]`, which # is equal to `\log_{p} q`. - fmpz * fq_nmod_ctx_prime(const fq_nmod_ctx_t ctx) + fmpz * fq_nmod_ctx_prime(const fq_nmod_ctx_t ctx) noexcept # Returns a pointer to the prime `p` in the context. - void fq_nmod_ctx_order(fmpz_t f, const fq_nmod_ctx_t ctx) + void fq_nmod_ctx_order(fmpz_t f, const fq_nmod_ctx_t ctx) noexcept # Sets `f` to be the size of the finite field. - int fq_nmod_ctx_fprint(FILE * file, const fq_nmod_ctx_t ctx) + int fq_nmod_ctx_fprint(FILE * file, const fq_nmod_ctx_t ctx) noexcept # Prints the context information to ``file``. Returns 1 for a # success and a negative number for an error. - void fq_nmod_ctx_print(const fq_nmod_ctx_t ctx) + void fq_nmod_ctx_print(const fq_nmod_ctx_t ctx) noexcept # Prints the context information to ``stdout``. - void fq_nmod_ctx_randtest(fq_nmod_ctx_t ctx, flint_rand_t state) + void fq_nmod_ctx_randtest(fq_nmod_ctx_t ctx, flint_rand_t state) noexcept # Initializes ``ctx`` to a random finite field. Assumes that # ``fq_nmod_ctx_init`` has not been called on ``ctx`` already. - void fq_nmod_ctx_randtest_reducible(fq_nmod_ctx_t ctx, flint_rand_t state) + void fq_nmod_ctx_randtest_reducible(fq_nmod_ctx_t ctx, flint_rand_t state) noexcept # Initializes ``ctx`` to a random extension of a word-sized prime # field. The modulus may or may not be irreducible. Assumes that # ``fq_nmod_ctx_init`` has not been called on ``ctx`` already. - void fq_nmod_init(fq_nmod_t rop, const fq_nmod_ctx_t ctx) + void fq_nmod_init(fq_nmod_t rop, const fq_nmod_ctx_t ctx) noexcept # Initialises the element ``rop``, setting its value to `0`. Currently, the behaviour is identical to ``fq_nmod_init2``, as it also ensures ``rop`` has enough space for it to be an element of ``ctx``, this may change in the future. - void fq_nmod_init2(fq_nmod_t rop, const fq_nmod_ctx_t ctx) + void fq_nmod_init2(fq_nmod_t rop, const fq_nmod_ctx_t ctx) noexcept # Initialises ``rop`` with at least enough space for it to be an element # of ``ctx`` and sets it to `0`. - void fq_nmod_clear(fq_nmod_t rop, const fq_nmod_ctx_t ctx) + void fq_nmod_clear(fq_nmod_t rop, const fq_nmod_ctx_t ctx) noexcept # Clears the element ``rop``. - void _fq_nmod_sparse_reduce(mp_limb_t * R, slong lenR, const fq_nmod_ctx_t ctx) + void _fq_nmod_sparse_reduce(mp_limb_t * R, slong lenR, const fq_nmod_ctx_t ctx) noexcept # Reduces ``(R, lenR)`` modulo the polynomial `f` given by the # modulus of ``ctx``. - void _fq_nmod_dense_reduce(mp_limb_t * R, slong lenR, const fq_nmod_ctx_t ctx) + void _fq_nmod_dense_reduce(mp_limb_t * R, slong lenR, const fq_nmod_ctx_t ctx) noexcept # Reduces ``(R, lenR)`` modulo the polynomial `f` given by the # modulus of ``ctx`` using Newton division. - void _fq_nmod_reduce(mp_limb_t * r, slong lenR, const fq_nmod_ctx_t ctx) + void _fq_nmod_reduce(mp_limb_t * r, slong lenR, const fq_nmod_ctx_t ctx) noexcept # Reduces ``(R, lenR)`` modulo the polynomial `f` given by the # modulus of ``ctx``. Does either sparse or dense reduction # based on ``ctx->sparse_modulus``. - void fq_nmod_reduce(fq_nmod_t rop, const fq_nmod_ctx_t ctx) + void fq_nmod_reduce(fq_nmod_t rop, const fq_nmod_ctx_t ctx) noexcept # Reduces the polynomial ``rop`` as an element of # `\mathbf{F}_p[X] / (f(X))`. - void fq_nmod_add(fq_nmod_t rop, const fq_nmod_t op1, const fq_nmod_t op2, const fq_nmod_ctx_t ctx) + void fq_nmod_add(fq_nmod_t rop, const fq_nmod_t op1, const fq_nmod_t op2, const fq_nmod_ctx_t ctx) noexcept # Sets ``rop`` to the sum of ``op1`` and ``op2``. - void fq_nmod_sub(fq_nmod_t rop, const fq_nmod_t op1, const fq_nmod_t op2, const fq_nmod_ctx_t ctx) + void fq_nmod_sub(fq_nmod_t rop, const fq_nmod_t op1, const fq_nmod_t op2, const fq_nmod_ctx_t ctx) noexcept # Sets ``rop`` to the difference of ``op1`` and ``op2``. - void fq_nmod_sub_one(fq_nmod_t rop, const fq_nmod_t op1, const fq_nmod_ctx_t ctx) + void fq_nmod_sub_one(fq_nmod_t rop, const fq_nmod_t op1, const fq_nmod_ctx_t ctx) noexcept # Sets ``rop`` to the difference of ``op1`` and `1`. - void fq_nmod_neg(fq_nmod_t rop, const fq_nmod_t op, const fq_nmod_ctx_t ctx) + void fq_nmod_neg(fq_nmod_t rop, const fq_nmod_t op, const fq_nmod_ctx_t ctx) noexcept # Sets ``rop`` to the negative of ``op``. - void fq_nmod_mul(fq_nmod_t rop, const fq_nmod_t op1, const fq_nmod_t op2, const fq_nmod_ctx_t ctx) + void fq_nmod_mul(fq_nmod_t rop, const fq_nmod_t op1, const fq_nmod_t op2, const fq_nmod_ctx_t ctx) noexcept # Sets ``rop`` to the product of ``op1`` and ``op2``, # reducing the output in the given context. - void fq_nmod_mul_fmpz(fq_nmod_t rop, const fq_nmod_t op, const fmpz_t x, const fq_nmod_ctx_t ctx) + void fq_nmod_mul_fmpz(fq_nmod_t rop, const fq_nmod_t op, const fmpz_t x, const fq_nmod_ctx_t ctx) noexcept # Sets ``rop`` to the product of ``op`` and `x`, # reducing the output in the given context. - void fq_nmod_mul_si(fq_nmod_t rop, const fq_nmod_t op, slong x, const fq_nmod_ctx_t ctx) + void fq_nmod_mul_si(fq_nmod_t rop, const fq_nmod_t op, slong x, const fq_nmod_ctx_t ctx) noexcept # Sets ``rop`` to the product of ``op`` and `x`, # reducing the output in the given context. - void fq_nmod_mul_ui(fq_nmod_t rop, const fq_nmod_t op, ulong x, const fq_nmod_ctx_t ctx) + void fq_nmod_mul_ui(fq_nmod_t rop, const fq_nmod_t op, ulong x, const fq_nmod_ctx_t ctx) noexcept # Sets ``rop`` to the product of ``op`` and `x`, # reducing the output in the given context. - void fq_nmod_sqr(fq_nmod_t rop, const fq_nmod_t op, const fq_nmod_ctx_t ctx) + void fq_nmod_sqr(fq_nmod_t rop, const fq_nmod_t op, const fq_nmod_ctx_t ctx) noexcept # Sets ``rop`` to the square of ``op``, # reducing the output in the given context. - void _fq_nmod_inv(mp_ptr * rop, mp_srcptr * op, slong len, const fq_nmod_ctx_t ctx) + void _fq_nmod_inv(mp_ptr * rop, mp_srcptr * op, slong len, const fq_nmod_ctx_t ctx) noexcept # Sets ``(rop, d)`` to the inverse of the non-zero element # ``(op, len)``. - void fq_nmod_inv(fq_nmod_t rop, const fq_nmod_t op, const fq_nmod_ctx_t ctx) + void fq_nmod_inv(fq_nmod_t rop, const fq_nmod_t op, const fq_nmod_ctx_t ctx) noexcept # Sets ``rop`` to the inverse of the non-zero element ``op``. - void fq_nmod_gcdinv(fq_nmod_t f, fq_nmod_t inv, const fq_nmod_t op, const fq_nmod_ctx_t ctx) + void fq_nmod_gcdinv(fq_nmod_t f, fq_nmod_t inv, const fq_nmod_t op, const fq_nmod_ctx_t ctx) noexcept # Sets ``inv`` to be the inverse of ``op`` modulo the modulus # of ``ctx``. If ``op`` is not invertible, then ``f`` is # set to a factor of the modulus; otherwise, it is set to one. - void _fq_nmod_pow(mp_limb_t * rop, const mp_limb_t * op, slong len, const fmpz_t e, const fq_nmod_ctx_t ctx) + void _fq_nmod_pow(mp_limb_t * rop, const mp_limb_t * op, slong len, const fmpz_t e, const fq_nmod_ctx_t ctx) noexcept # Sets ``(rop, 2*d-1)`` to ``(op,len)`` raised to the power `e`, # reduced modulo `f(X)`, the modulus of ``ctx``. # Assumes that `e \geq 0` and that ``len`` is positive and at most `d`. @@ -161,145 +161,145 @@ cdef extern from "flint_wrap.h": # `f(X)`, which is a polynomial of degree `d`. # Does not support aliasing. - void fq_nmod_pow(fq_nmod_t rop, const fq_nmod_t op, const fmpz_t e, const fq_nmod_ctx_t ctx) + void fq_nmod_pow(fq_nmod_t rop, const fq_nmod_t op, const fmpz_t e, const fq_nmod_ctx_t ctx) noexcept # Sets ``rop`` to ``op`` raised to the power `e`. # Currently assumes that `e \geq 0`. # Note that for any input ``op``, ``rop`` is set to `1` # whenever `e = 0`. - void fq_nmod_pow_ui(fq_nmod_t rop, const fq_nmod_t op, const ulong e, const fq_nmod_ctx_t ctx) + void fq_nmod_pow_ui(fq_nmod_t rop, const fq_nmod_t op, const ulong e, const fq_nmod_ctx_t ctx) noexcept # Sets ``rop`` to ``op`` raised to the power `e`. # Currently assumes that `e \geq 0`. # Note that for any input ``op``, ``rop`` is set to `1` # whenever `e = 0`. - int fq_nmod_sqrt(fq_nmod_t rop, const fq_nmod_t op1, const fq_nmod_ctx_t ctx) + int fq_nmod_sqrt(fq_nmod_t rop, const fq_nmod_t op1, const fq_nmod_ctx_t ctx) noexcept # Sets ``rop`` to the square root of ``op1`` if it is a square, and return # `1`, otherwise return `0`. - void fq_nmod_pth_root(fq_nmod_t rop, const fq_nmod_t op1, const fq_nmod_ctx_t ctx) + void fq_nmod_pth_root(fq_nmod_t rop, const fq_nmod_t op1, const fq_nmod_ctx_t ctx) noexcept # Sets ``rop`` to a `p^{\textrm{th}}` root of ``op1``. Currently, # this computes the root by raising ``op1`` to `p^{d-1}` where # `d` is the degree of the extension. - bint fq_nmod_is_square(const fq_nmod_t op, const fq_nmod_ctx_t ctx) + bint fq_nmod_is_square(const fq_nmod_t op, const fq_nmod_ctx_t ctx) noexcept # Return ``1`` if ``op`` is a square. - int fq_nmod_fprint_pretty(FILE * file, const fq_nmod_t op, const fq_nmod_ctx_t ctx) + int fq_nmod_fprint_pretty(FILE * file, const fq_nmod_t op, const fq_nmod_ctx_t ctx) noexcept # Prints a pretty representation of ``op`` to ``file``. # In case of success, returns a positive value. In case of failure, # returns a non-positive value. - void fq_nmod_print_pretty(const fq_nmod_t op, const fq_nmod_ctx_t ctx) + void fq_nmod_print_pretty(const fq_nmod_t op, const fq_nmod_ctx_t ctx) noexcept # Prints a pretty representation of ``op`` to ``stdout``. # In case of success, returns a positive value. In case of failure, # returns a non-positive value. - int fq_nmod_fprint(FILE * file, const fq_nmod_t op, const fq_nmod_ctx_t ctx) + int fq_nmod_fprint(FILE * file, const fq_nmod_t op, const fq_nmod_ctx_t ctx) noexcept # Prints a representation of ``op`` to ``file``. # For further details on the representation used, see # ``nmod_poly_fprint()``. - void fq_nmod_print(const fq_nmod_t op, const fq_nmod_ctx_t ctx) + void fq_nmod_print(const fq_nmod_t op, const fq_nmod_ctx_t ctx) noexcept # Prints a representation of ``op`` to ``stdout``. # For further details on the representation used, see # ``nmod_poly_print()``. - char * fq_nmod_get_str(const fq_nmod_t op, const fq_nmod_ctx_t ctx) + char * fq_nmod_get_str(const fq_nmod_t op, const fq_nmod_ctx_t ctx) noexcept # Returns the plain FLINT string representation of the element # ``op``. - char * fq_nmod_get_str_pretty(const fq_nmod_t op, const fq_nmod_ctx_t ctx) + char * fq_nmod_get_str_pretty(const fq_nmod_t op, const fq_nmod_ctx_t ctx) noexcept # Returns a pretty representation of the element ``op`` using the # null-terminated string ``x`` as the variable name. - void fq_nmod_randtest(fq_nmod_t rop, flint_rand_t state, const fq_nmod_ctx_t ctx) + void fq_nmod_randtest(fq_nmod_t rop, flint_rand_t state, const fq_nmod_ctx_t ctx) noexcept # Generates a random element of `\mathbf{F}_q`. - void fq_nmod_randtest_not_zero(fq_nmod_t rop, flint_rand_t state, const fq_nmod_ctx_t ctx) + void fq_nmod_randtest_not_zero(fq_nmod_t rop, flint_rand_t state, const fq_nmod_ctx_t ctx) noexcept # Generates a random non-zero element of `\mathbf{F}_q`. - void fq_nmod_randtest_dense(fq_nmod_t rop, flint_rand_t state, const fq_nmod_ctx_t ctx) + void fq_nmod_randtest_dense(fq_nmod_t rop, flint_rand_t state, const fq_nmod_ctx_t ctx) noexcept # Generates a random element of `\mathbf{F}_q` which has an # underlying polynomial with dense coefficients. - void fq_nmod_rand(fq_nmod_t rop, flint_rand_t state, const fq_nmod_ctx_t ctx) + void fq_nmod_rand(fq_nmod_t rop, flint_rand_t state, const fq_nmod_ctx_t ctx) noexcept # Generates a high quality random element of `\mathbf{F}_q`. - void fq_nmod_rand_not_zero(fq_nmod_t rop, flint_rand_t state, const fq_nmod_ctx_t ctx) + void fq_nmod_rand_not_zero(fq_nmod_t rop, flint_rand_t state, const fq_nmod_ctx_t ctx) noexcept # Generates a high quality non-zero random element of `\mathbf{F}_q`. - void fq_nmod_set(fq_nmod_t rop, const fq_nmod_t op, const fq_nmod_ctx_t ctx) + void fq_nmod_set(fq_nmod_t rop, const fq_nmod_t op, const fq_nmod_ctx_t ctx) noexcept # Sets ``rop`` to ``op``. - void fq_nmod_set_si(fq_nmod_t rop, const slong x, const fq_nmod_ctx_t ctx) + void fq_nmod_set_si(fq_nmod_t rop, const slong x, const fq_nmod_ctx_t ctx) noexcept # Sets ``rop`` to ``x``, considered as an element of # `\mathbf{F}_p`. - void fq_nmod_set_ui(fq_nmod_t rop, const ulong x, const fq_nmod_ctx_t ctx) + void fq_nmod_set_ui(fq_nmod_t rop, const ulong x, const fq_nmod_ctx_t ctx) noexcept # Sets ``rop`` to ``x``, considered as an element of # `\mathbf{F}_p`. - void fq_nmod_set_fmpz(fq_nmod_t rop, const fmpz_t x, const fq_nmod_ctx_t ctx) + void fq_nmod_set_fmpz(fq_nmod_t rop, const fmpz_t x, const fq_nmod_ctx_t ctx) noexcept # Sets ``rop`` to ``x``, considered as an element of # `\mathbf{F}_p`. - void fq_nmod_swap(fq_nmod_t op1, fq_nmod_t op2, const fq_nmod_ctx_t ctx) + void fq_nmod_swap(fq_nmod_t op1, fq_nmod_t op2, const fq_nmod_ctx_t ctx) noexcept # Swaps the two elements ``op1`` and ``op2``. - void fq_nmod_zero(fq_nmod_t rop, const fq_nmod_ctx_t ctx) + void fq_nmod_zero(fq_nmod_t rop, const fq_nmod_ctx_t ctx) noexcept # Sets ``rop`` to zero. - void fq_nmod_one(fq_nmod_t rop, const fq_nmod_ctx_t ctx) + void fq_nmod_one(fq_nmod_t rop, const fq_nmod_ctx_t ctx) noexcept # Sets ``rop`` to one, reduced in the given context. - void fq_nmod_gen(fq_nmod_t rop, const fq_nmod_ctx_t ctx) + void fq_nmod_gen(fq_nmod_t rop, const fq_nmod_ctx_t ctx) noexcept # Sets ``rop`` to a generator for the finite field. # There is no guarantee this is a multiplicative generator of # the finite field. - int fq_nmod_get_fmpz(fmpz_t rop, const fq_nmod_t op, const fq_nmod_ctx_t ctx) + int fq_nmod_get_fmpz(fmpz_t rop, const fq_nmod_t op, const fq_nmod_ctx_t ctx) noexcept # If ``op`` has a lift to the integers, return `1` and set ``rop`` to the lift in `[0,p)`. # Otherwise, return `0` and leave `rop` undefined. - void fq_nmod_get_nmod_poly(nmod_poly_t a, const fq_nmod_t b, const fq_nmod_ctx_t ctx) + void fq_nmod_get_nmod_poly(nmod_poly_t a, const fq_nmod_t b, const fq_nmod_ctx_t ctx) noexcept # Set ``a`` to a representative of ``b`` in ``ctx``. # The representatives are taken in `(\mathbb{Z}/p\mathbb{Z})[x]/h(x)` where `h(x)` is the defining polynomial in ``ctx``. - void fq_nmod_set_nmod_poly(fq_nmod_t a, const nmod_poly_t b, const fq_nmod_ctx_t ctx) + void fq_nmod_set_nmod_poly(fq_nmod_t a, const nmod_poly_t b, const fq_nmod_ctx_t ctx) noexcept # Set ``a`` to the element in ``ctx`` with representative ``b``. # The representatives are taken in `(\mathbb{Z}/p\mathbb{Z})[x]/h(x)` where `h(x)` is the defining polynomial in ``ctx``. - void fq_nmod_get_nmod_mat(nmod_mat_t col, const fq_nmod_t a, const fq_nmod_ctx_t ctx) + void fq_nmod_get_nmod_mat(nmod_mat_t col, const fq_nmod_t a, const fq_nmod_ctx_t ctx) noexcept # Convert ``a`` to a column vector of length ``degree(ctx)``. - void fq_nmod_set_nmod_mat(fq_nmod_t a, const nmod_mat_t col, const fq_nmod_ctx_t ctx) + void fq_nmod_set_nmod_mat(fq_nmod_t a, const nmod_mat_t col, const fq_nmod_ctx_t ctx) noexcept # Convert a column vector ``col`` of length ``degree(ctx)`` to an element of ``ctx``. - bint fq_nmod_is_zero(const fq_nmod_t op, const fq_nmod_ctx_t ctx) + bint fq_nmod_is_zero(const fq_nmod_t op, const fq_nmod_ctx_t ctx) noexcept # Returns whether ``op`` is equal to zero. - bint fq_nmod_is_one(const fq_nmod_t op, const fq_nmod_ctx_t ctx) + bint fq_nmod_is_one(const fq_nmod_t op, const fq_nmod_ctx_t ctx) noexcept # Returns whether ``op`` is equal to one. - bint fq_nmod_equal(const fq_nmod_t op1, const fq_nmod_t op2, const fq_nmod_ctx_t ctx) + bint fq_nmod_equal(const fq_nmod_t op1, const fq_nmod_t op2, const fq_nmod_ctx_t ctx) noexcept # Returns whether ``op1`` and ``op2`` are equal. - bint fq_nmod_is_invertible(const fq_nmod_t op, const fq_nmod_ctx_t ctx) + bint fq_nmod_is_invertible(const fq_nmod_t op, const fq_nmod_ctx_t ctx) noexcept # Returns whether ``op`` is an invertible element. - bint fq_nmod_is_invertible_f(fq_nmod_t f, const fq_nmod_t op, const fq_nmod_ctx_t ctx) + bint fq_nmod_is_invertible_f(fq_nmod_t f, const fq_nmod_t op, const fq_nmod_ctx_t ctx) noexcept # Returns whether ``op`` is an invertible element. If it is not, # then ``f`` is set to a factor of the modulus. - int fq_nmod_cmp(const fq_nmod_t a, const fq_nmod_t b, const fq_nmod_ctx_t ctx) + int fq_nmod_cmp(const fq_nmod_t a, const fq_nmod_t b, const fq_nmod_ctx_t ctx) noexcept # Return ``1`` (resp. ``-1``, or ``0``) if ``a`` is after (resp. before, same as) ``b`` in some arbitrary but fixed total ordering of the elements. - void _fq_nmod_trace(fmpz_t rop, const mp_limb_t * op, slong len, const fq_nmod_ctx_t ctx) + void _fq_nmod_trace(fmpz_t rop, const mp_limb_t * op, slong len, const fq_nmod_ctx_t ctx) noexcept # Sets ``rop`` to the trace of the non-zero element ``(op, len)`` # in `\mathbf{F}_{q}`. - void fq_nmod_trace(fmpz_t rop, const fq_nmod_t op, const fq_nmod_ctx_t ctx) + void fq_nmod_trace(fmpz_t rop, const fq_nmod_t op, const fq_nmod_ctx_t ctx) noexcept # Sets ``rop`` to the trace of ``op``. # For an element `a \in \mathbf{F}_q`, multiplication by `a` defines # a `\mathbf{F}_p`-linear map on `\mathbf{F}_q`. We define the @@ -308,11 +308,11 @@ cdef extern from "flint_wrap.h": # `a` is equal to `\sum_{i=0}^{d-1} \Sigma^i (a)`, where `d = # \log_{p} q`. - void _fq_nmod_norm(fmpz_t rop, const mp_limb_t * op, slong len, const fq_nmod_ctx_t ctx) + void _fq_nmod_norm(fmpz_t rop, const mp_limb_t * op, slong len, const fq_nmod_ctx_t ctx) noexcept # Sets ``rop`` to the norm of the non-zero element ``(op, len)`` # in `\mathbf{F}_{q}`. - void fq_nmod_norm(fmpz_t rop, const fq_nmod_t op, const fq_nmod_ctx_t ctx) + void fq_nmod_norm(fmpz_t rop, const fq_nmod_t op, const fq_nmod_ctx_t ctx) noexcept # Computes the norm of ``op``. # For an element `a \in \mathbf{F}_q`, multiplication by `a` defines # a `\mathbf{F}_p`-linear map on `\mathbf{F}_q`. We define the norm @@ -322,12 +322,12 @@ cdef extern from "flint_wrap.h": # `d = \text{dim}_{\mathbf{F}_p}(\mathbf{F}_q)`. # Algorithm selection is automatic depending on the input. - void _fq_nmod_frobenius(mp_limb_t * rop, const mp_limb_t * op, slong len, slong e, const fq_nmod_ctx_t ctx) + void _fq_nmod_frobenius(mp_limb_t * rop, const mp_limb_t * op, slong len, slong e, const fq_nmod_ctx_t ctx) noexcept # Sets ``(rop, 2d-1)`` to the image of ``(op, len)`` under the # Frobenius operator raised to the e-th power, assuming that neither # ``op`` nor ``e`` are zero. - void fq_nmod_frobenius(fq_nmod_t rop, const fq_nmod_t op, slong e, const fq_nmod_ctx_t ctx) + void fq_nmod_frobenius(fq_nmod_t rop, const fq_nmod_t op, slong e, const fq_nmod_ctx_t ctx) noexcept # Evaluates the homomorphism `\Sigma^e` at ``op``. # Recall that `\mathbf{F}_q / \mathbf{F}_p` is Galois with Galois group # `\langle \sigma \rangle`, which is also isomorphic to @@ -335,7 +335,7 @@ cdef extern from "flint_wrap.h": # `\sigma \in \operatorname{Gal}(\mathbf{F}_q/\mathbf{F}_p)` is the Frobenius element # `\sigma \colon x \mapsto x^p`. - int fq_nmod_multiplicative_order(fmpz * ord, const fq_nmod_t op, const fq_nmod_ctx_t ctx) + int fq_nmod_multiplicative_order(fmpz * ord, const fq_nmod_t op, const fq_nmod_ctx_t ctx) noexcept # Computes the order of ``op`` as an element of the # multiplicative group of ``ctx``. # Returns 0 if ``op`` is 0, otherwise it returns 1 if ``op`` @@ -343,15 +343,15 @@ cdef extern from "flint_wrap.h": # This function can also be used to check primitivity of a generator of # a finite field whose defining polynomial is not primitive. - bint fq_nmod_is_primitive(const fq_nmod_t op, const fq_nmod_ctx_t ctx) + bint fq_nmod_is_primitive(const fq_nmod_t op, const fq_nmod_ctx_t ctx) noexcept # Returns whether ``op`` is primitive, i.e., whether it is a # generator of the multiplicative group of ``ctx``. - void fq_nmod_bit_pack(fmpz_t f, const fq_nmod_t op, flint_bitcnt_t bit_size, const fq_nmod_ctx_t ctx) + void fq_nmod_bit_pack(fmpz_t f, const fq_nmod_t op, flint_bitcnt_t bit_size, const fq_nmod_ctx_t ctx) noexcept # Packs ``op`` into bitfields of size ``bit_size``, writing the # result to ``f``. - void fq_nmod_bit_unpack(fq_nmod_t rop, const fmpz_t f, flint_bitcnt_t bit_size, const fq_nmod_ctx_t ctx) + void fq_nmod_bit_unpack(fq_nmod_t rop, const fmpz_t f, flint_bitcnt_t bit_size, const fq_nmod_ctx_t ctx) noexcept # Unpacks into ``rop`` the element with coefficients packed into # fields of size ``bit_size`` as represented by the integer # ``f``. diff --git a/src/sage/libs/flint/fq_nmod_embed.pxd b/src/sage/libs/flint/fq_nmod_embed.pxd index 03accc2a3d7..51c2e020343 100644 --- a/src/sage/libs/flint/fq_nmod_embed.pxd +++ b/src/sage/libs/flint/fq_nmod_embed.pxd @@ -12,7 +12,7 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void fq_nmod_embed_gens(fq_nmod_t gen_sub, fq_nmod_t gen_sup, nmod_poly_t minpoly, const fq_nmod_ctx_t sub_ctx, const fq_nmod_ctx_t sup_ctx) + void fq_nmod_embed_gens(fq_nmod_t gen_sub, fq_nmod_t gen_sup, nmod_poly_t minpoly, const fq_nmod_ctx_t sub_ctx, const fq_nmod_ctx_t sup_ctx) noexcept # Given two contexts ``sub_ctx`` and ``sup_ctx``, such that # ``degree(sub_ctx)`` divides ``degree(sup_ctx)``, compute: # * an element ``gen_sub`` in ``sub_ctx`` such that @@ -24,7 +24,7 @@ cdef extern from "flint_wrap.h": # These data uniquely define an embedding of ``sub_ctx`` into # ``sup_ctx``. - void _fq_nmod_embed_gens_naive(fq_nmod_t gen_sub, fq_nmod_t gen_sup, nmod_poly_t minpoly, const fq_nmod_ctx_t sub_ctx, const fq_nmod_ctx_t sup_ctx) + void _fq_nmod_embed_gens_naive(fq_nmod_t gen_sub, fq_nmod_t gen_sup, nmod_poly_t minpoly, const fq_nmod_ctx_t sub_ctx, const fq_nmod_ctx_t sup_ctx) noexcept # Given two contexts ``sub_ctx`` and ``sup_ctx``, such that # ``degree(sub_ctx)`` divides ``degree(sup_ctx)``, compute an # embedding of ``sub_ctx`` into ``sup_ctx`` defined as follows: @@ -34,7 +34,7 @@ cdef extern from "flint_wrap.h": # * ``gen_sup`` is a root of ``minpoly`` inside the field # defined by ``sup_ctx``. - void fq_nmod_embed_matrices(nmod_mat_t embed, nmod_mat_t project, const fq_nmod_t gen_sub, const fq_nmod_ctx_t sub_ctx, const fq_nmod_t gen_sup, const fq_nmod_ctx_t sup_ctx, const nmod_poly_t gen_minpoly) + void fq_nmod_embed_matrices(nmod_mat_t embed, nmod_mat_t project, const fq_nmod_t gen_sub, const fq_nmod_ctx_t sub_ctx, const fq_nmod_t gen_sup, const fq_nmod_ctx_t sup_ctx, const nmod_poly_t gen_minpoly) noexcept # Given: # * two contexts ``sub_ctx`` and ``sup_ctx``, of # respective degrees `m` and `n`, such that `m` divides `n`; @@ -49,7 +49,7 @@ cdef extern from "flint_wrap.h": # ``project`` `\times` ``embed`` is the `m\times m` identity # matrix. - void fq_nmod_embed_trace_matrix(nmod_mat_t res, const nmod_mat_t basis, const fq_nmod_ctx_t sub_ctx, const fq_nmod_ctx_t sup_ctx) + void fq_nmod_embed_trace_matrix(nmod_mat_t res, const nmod_mat_t basis, const fq_nmod_ctx_t sub_ctx, const fq_nmod_ctx_t sup_ctx) noexcept # Given: # * two contexts ``sub_ctx`` and ``sup_ctx``, of degrees # `m` and `n`, such that `m` divides `n`; @@ -65,33 +65,33 @@ cdef extern from "flint_wrap.h": # `m=n`, ``basis`` represents a Frobenius, and the result is its # inverse matrix. - void fq_nmod_embed_composition_matrix(nmod_mat_t matrix, const fq_nmod_t gen, const fq_nmod_ctx_t ctx) + void fq_nmod_embed_composition_matrix(nmod_mat_t matrix, const fq_nmod_t gen, const fq_nmod_ctx_t ctx) noexcept # Compute the *composition matrix* of ``gen``. # For an element `a\in\mathbf{F}_{p^n}`, its composition matrix is the # matrix whose columns are `a^0, a^1, \ldots, a^{n-1}`. - void fq_nmod_embed_composition_matrix_sub(nmod_mat_t matrix, const fq_nmod_t gen, const fq_nmod_ctx_t ctx, slong trunc) + void fq_nmod_embed_composition_matrix_sub(nmod_mat_t matrix, const fq_nmod_t gen, const fq_nmod_ctx_t ctx, slong trunc) noexcept # Compute the *composition matrix* of ``gen``, truncated to # ``trunc`` columns. - void fq_nmod_embed_mul_matrix(nmod_mat_t matrix, const fq_nmod_t gen, const fq_nmod_ctx_t ctx) + void fq_nmod_embed_mul_matrix(nmod_mat_t matrix, const fq_nmod_t gen, const fq_nmod_ctx_t ctx) noexcept # Compute the *multiplication matrix* of ``gen``. # For an element `a` in `\mathbf{F}_{p^n}=\mathbf{F}_p[x]`, its # multiplication matrix is the matrix whose columns are `a, ax, # \dots, ax^{n-1}`. - void fq_nmod_embed_mono_to_dual_matrix(nmod_mat_t res, const fq_nmod_ctx_t ctx) + void fq_nmod_embed_mono_to_dual_matrix(nmod_mat_t res, const fq_nmod_ctx_t ctx) noexcept # Compute the change of basis matrix from the monomial basis of # ``ctx`` to its dual basis. - void fq_nmod_embed_dual_to_mono_matrix(nmod_mat_t res, const fq_nmod_ctx_t ctx) + void fq_nmod_embed_dual_to_mono_matrix(nmod_mat_t res, const fq_nmod_ctx_t ctx) noexcept # Compute the change of basis matrix from the dual basis of # ``ctx`` to its monomial basis. - void fq_nmod_modulus_pow_series_inv(nmod_poly_t res, const fq_nmod_ctx_t ctx, slong trunc) + void fq_nmod_modulus_pow_series_inv(nmod_poly_t res, const fq_nmod_ctx_t ctx, slong trunc) noexcept # Compute the power series inverse of the reverse of the modulus of # ``ctx`` up to `O(x^\texttt{trunc})`. - void fq_nmod_modulus_derivative_inv(fq_nmod_t m_prime, fq_nmod_t m_prime_inv, const fq_nmod_ctx_t ctx) + void fq_nmod_modulus_derivative_inv(fq_nmod_t m_prime, fq_nmod_t m_prime_inv, const fq_nmod_ctx_t ctx) noexcept # Compute the derivative ``m_prime`` of the modulus of ``ctx`` # as an element of ``ctx``, and its inverse ``m_prime_inv``. diff --git a/src/sage/libs/flint/fq_nmod_mat.pxd b/src/sage/libs/flint/fq_nmod_mat.pxd index ecb12cf7b4f..41106b90431 100644 --- a/src/sage/libs/flint/fq_nmod_mat.pxd +++ b/src/sage/libs/flint/fq_nmod_mat.pxd @@ -12,117 +12,117 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void fq_nmod_mat_init(fq_nmod_mat_t mat, slong rows, slong cols, const fq_nmod_ctx_t ctx) + void fq_nmod_mat_init(fq_nmod_mat_t mat, slong rows, slong cols, const fq_nmod_ctx_t ctx) noexcept # Initialises ``mat`` to a ``rows``-by-``cols`` matrix with # coefficients in `\mathbf{F}_{q}` given by ``ctx``. All elements # are set to zero. - void fq_nmod_mat_init_set(fq_nmod_mat_t mat, const fq_nmod_mat_t src, const fq_nmod_ctx_t ctx) + void fq_nmod_mat_init_set(fq_nmod_mat_t mat, const fq_nmod_mat_t src, const fq_nmod_ctx_t ctx) noexcept # Initialises ``mat`` and sets its dimensions and elements to # those of ``src``. - void fq_nmod_mat_clear(fq_nmod_mat_t mat, const fq_nmod_ctx_t ctx) + void fq_nmod_mat_clear(fq_nmod_mat_t mat, const fq_nmod_ctx_t ctx) noexcept # Clears the matrix and releases any memory it used. The matrix # cannot be used again until it is initialised. This function must be # called exactly once when finished using an :type:`fq_nmod_mat_t` object. - void fq_nmod_mat_set(fq_nmod_mat_t mat, const fq_nmod_mat_t src, const fq_nmod_ctx_t ctx) + void fq_nmod_mat_set(fq_nmod_mat_t mat, const fq_nmod_mat_t src, const fq_nmod_ctx_t ctx) noexcept # Sets ``mat`` to a copy of ``src``. It is assumed # that ``mat`` and ``src`` have identical dimensions. - fq_nmod_struct * fq_nmod_mat_entry(const fq_nmod_mat_t mat, slong i, slong j) + fq_nmod_struct * fq_nmod_mat_entry(const fq_nmod_mat_t mat, slong i, slong j) noexcept # Directly accesses the entry in ``mat`` in row `i` and column `j`, # indexed from zero. No bounds checking is performed. - void fq_nmod_mat_entry_set(fq_nmod_mat_t mat, slong i, slong j, const fq_nmod_t x, const fq_nmod_ctx_t ctx) + void fq_nmod_mat_entry_set(fq_nmod_mat_t mat, slong i, slong j, const fq_nmod_t x, const fq_nmod_ctx_t ctx) noexcept # Sets the entry in ``mat`` in row `i` and column `j` to ``x``. - slong fq_nmod_mat_nrows(const fq_nmod_mat_t mat, const fq_nmod_ctx_t ctx) + slong fq_nmod_mat_nrows(const fq_nmod_mat_t mat, const fq_nmod_ctx_t ctx) noexcept # Returns the number of rows in ``mat``. - slong fq_nmod_mat_ncols(const fq_nmod_mat_t mat, const fq_nmod_ctx_t ctx) + slong fq_nmod_mat_ncols(const fq_nmod_mat_t mat, const fq_nmod_ctx_t ctx) noexcept # Returns the number of columns in ``mat``. - void fq_nmod_mat_swap(fq_nmod_mat_t mat1, fq_nmod_mat_t mat2, const fq_nmod_ctx_t ctx) + void fq_nmod_mat_swap(fq_nmod_mat_t mat1, fq_nmod_mat_t mat2, const fq_nmod_ctx_t ctx) noexcept # Swaps two matrices. The dimensions of ``mat1`` and ``mat2`` # are allowed to be different. - void fq_nmod_mat_swap_entrywise(fq_nmod_mat_t mat1, fq_nmod_mat_t mat2, const fq_nmod_ctx_t ctx) + void fq_nmod_mat_swap_entrywise(fq_nmod_mat_t mat1, fq_nmod_mat_t mat2, const fq_nmod_ctx_t ctx) noexcept # Swaps two matrices by swapping the individual entries rather than swapping # the contents of the structs. - void fq_nmod_mat_zero(fq_nmod_mat_t mat, const fq_nmod_ctx_t ctx) + void fq_nmod_mat_zero(fq_nmod_mat_t mat, const fq_nmod_ctx_t ctx) noexcept # Sets all entries of ``mat`` to 0. - void fq_nmod_mat_one(fq_nmod_mat_t mat, const fq_nmod_ctx_t ctx) + void fq_nmod_mat_one(fq_nmod_mat_t mat, const fq_nmod_ctx_t ctx) noexcept # Sets all diagonal entries of ``mat`` to 1 and all other entries to 0. - void fq_nmod_mat_swap_rows(fq_nmod_mat_t mat, slong * perm, slong r, slong s, const fq_nmod_ctx_t ctx) + void fq_nmod_mat_swap_rows(fq_nmod_mat_t mat, slong * perm, slong r, slong s, const fq_nmod_ctx_t ctx) noexcept # Swaps rows ``r`` and ``s`` of ``mat``. If ``perm`` is non-``NULL``, the # permutation of the rows will also be applied to ``perm``. - void fq_nmod_mat_swap_cols(fq_nmod_mat_t mat, slong * perm, slong r, slong s, const fq_nmod_ctx_t ctx) + void fq_nmod_mat_swap_cols(fq_nmod_mat_t mat, slong * perm, slong r, slong s, const fq_nmod_ctx_t ctx) noexcept # Swaps columns ``r`` and ``s`` of ``mat``. If ``perm`` is non-``NULL``, the # permutation of the columns will also be applied to ``perm``. - void fq_nmod_mat_invert_rows(fq_nmod_mat_t mat, slong * perm, const fq_nmod_ctx_t ctx) + void fq_nmod_mat_invert_rows(fq_nmod_mat_t mat, slong * perm, const fq_nmod_ctx_t ctx) noexcept # Swaps rows ``i`` and ``r - i`` of ``mat`` for ``0 <= i < r/2``, where # ``r`` is the number of rows of ``mat``. If ``perm`` is non-``NULL``, the # permutation of the rows will also be applied to ``perm``. - void fq_nmod_mat_invert_cols(fq_nmod_mat_t mat, slong * perm, const fq_nmod_ctx_t ctx) + void fq_nmod_mat_invert_cols(fq_nmod_mat_t mat, slong * perm, const fq_nmod_ctx_t ctx) noexcept # Swaps columns ``i`` and ``c - i`` of ``mat`` for ``0 <= i < c/2``, where # ``c`` is the number of columns of ``mat``. If ``perm`` is non-``NULL``, the # permutation of the columns will also be applied to ``perm``. - void fq_nmod_mat_set_nmod_mat(fq_nmod_mat_t mat1, const nmod_mat_t mat2, const fq_nmod_ctx_t ctx) + void fq_nmod_mat_set_nmod_mat(fq_nmod_mat_t mat1, const nmod_mat_t mat2, const fq_nmod_ctx_t ctx) noexcept # Sets the matrix ``mat1`` to the matrix ``mat2``. - void fq_nmod_mat_set_fmpz_mod_mat(fq_nmod_mat_t mat1, const fmpz_mod_mat_t mat2, const fq_nmod_ctx_t ctx) + void fq_nmod_mat_set_fmpz_mod_mat(fq_nmod_mat_t mat1, const fmpz_mod_mat_t mat2, const fq_nmod_ctx_t ctx) noexcept # Sets the matrix ``mat1`` to the matrix ``mat2``. - void fq_nmod_mat_concat_vertical(fq_nmod_mat_t res, const fq_nmod_mat_t mat1, const fq_nmod_mat_t mat2, const fq_nmod_ctx_t ctx) + void fq_nmod_mat_concat_vertical(fq_nmod_mat_t res, const fq_nmod_mat_t mat1, const fq_nmod_mat_t mat2, const fq_nmod_ctx_t ctx) noexcept # Sets ``res`` to vertical concatenation of (``mat1``, ``mat2``) in that order. Matrix dimensions : ``mat1`` : `m \times n`, ``mat2`` : `k \times n`, ``res`` : `(m + k) \times n`. - void fq_nmod_mat_concat_horizontal(fq_nmod_mat_t res, const fq_nmod_mat_t mat1, const fq_nmod_mat_t mat2, const fq_nmod_ctx_t ctx) + void fq_nmod_mat_concat_horizontal(fq_nmod_mat_t res, const fq_nmod_mat_t mat1, const fq_nmod_mat_t mat2, const fq_nmod_ctx_t ctx) noexcept # Sets ``res`` to horizontal concatenation of (``mat1``, ``mat2``) in that order. Matrix dimensions : ``mat1`` : `m \times n`, ``mat2`` : `m \times k`, ``res`` : `m \times (n + k)`. - int fq_nmod_mat_print_pretty(const fq_nmod_mat_t mat, const fq_nmod_ctx_t ctx) + int fq_nmod_mat_print_pretty(const fq_nmod_mat_t mat, const fq_nmod_ctx_t ctx) noexcept # Pretty-prints ``mat`` to ``stdout``. A header is printed # followed by the rows enclosed in brackets. - int fq_nmod_mat_fprint_pretty(FILE * file, const fq_nmod_mat_t mat, const fq_nmod_ctx_t ctx) + int fq_nmod_mat_fprint_pretty(FILE * file, const fq_nmod_mat_t mat, const fq_nmod_ctx_t ctx) noexcept # Pretty-prints ``mat`` to ``file``. A header is printed # followed by the rows enclosed in brackets. # In case of success, returns a positive value. In case of failure, # returns a non-positive value. - int fq_nmod_mat_print(const fq_nmod_mat_t mat, const fq_nmod_ctx_t ctx) + int fq_nmod_mat_print(const fq_nmod_mat_t mat, const fq_nmod_ctx_t ctx) noexcept # Prints ``mat`` to ``stdout``. A header is printed followed # by the rows enclosed in brackets. - int fq_nmod_mat_fprint(FILE * file, const fq_nmod_mat_t mat, const fq_nmod_ctx_t ctx) + int fq_nmod_mat_fprint(FILE * file, const fq_nmod_mat_t mat, const fq_nmod_ctx_t ctx) noexcept # Prints ``mat`` to ``file``. A header is printed followed by # the rows enclosed in brackets. # In case of success, returns a positive value. In case of failure, # returns a non-positive value. - void fq_nmod_mat_window_init(fq_nmod_mat_t window, const fq_nmod_mat_t mat, slong r1, slong c1, slong r2, slong c2, const fq_nmod_ctx_t ctx) + void fq_nmod_mat_window_init(fq_nmod_mat_t window, const fq_nmod_mat_t mat, slong r1, slong c1, slong r2, slong c2, const fq_nmod_ctx_t ctx) noexcept # Initializes the matrix ``window`` to be an ``r2 - r1`` by # ``c2 - c1`` submatrix of ``mat`` whose ``(0,0)`` entry # is the ``(r1, c1)`` entry of ``mat``. The memory for the # elements of ``window`` is shared with ``mat``. - void fq_nmod_mat_window_clear(fq_nmod_mat_t window, const fq_nmod_ctx_t ctx) + void fq_nmod_mat_window_clear(fq_nmod_mat_t window, const fq_nmod_ctx_t ctx) noexcept # Clears the matrix ``window`` and releases any memory that it # uses. Note that the memory to the underlying matrix that # ``window`` points to is not freed. - void fq_nmod_mat_randtest(fq_nmod_mat_t mat, flint_rand_t state, const fq_nmod_ctx_t ctx) + void fq_nmod_mat_randtest(fq_nmod_mat_t mat, flint_rand_t state, const fq_nmod_ctx_t ctx) noexcept # Sets the elements of ``mat`` to random elements of # `\mathbf{F}_{q}`, given by ``ctx``. - int fq_nmod_mat_randpermdiag(fq_nmod_mat_t mat, flint_rand_t state, fq_nmod_struct * diag, slong n, const fq_nmod_ctx_t ctx) + int fq_nmod_mat_randpermdiag(fq_nmod_mat_t mat, flint_rand_t state, fq_nmod_struct * diag, slong n, const fq_nmod_ctx_t ctx) noexcept # Sets ``mat`` to a random permutation of the diagonal matrix # with `n` leading entries given by the vector ``diag``. It is # assumed that the main diagonal of ``mat`` has room for at @@ -130,7 +130,7 @@ cdef extern from "flint_wrap.h": # Returns `0` or `1`, depending on whether the permutation is even # or odd respectively. - void fq_nmod_mat_randrank(fq_nmod_mat_t mat, flint_rand_t state, slong rank, const fq_nmod_ctx_t ctx) + void fq_nmod_mat_randrank(fq_nmod_mat_t mat, flint_rand_t state, slong rank, const fq_nmod_ctx_t ctx) noexcept # Sets ``mat`` to a random sparse matrix with the given rank, # having exactly as many non-zero elements as the rank, with the # non-zero elements being uniformly random elements of @@ -138,92 +138,92 @@ cdef extern from "flint_wrap.h": # The matrix can be transformed into a dense matrix with unchanged # rank by subsequently calling :func:`fq_nmod_mat_randops`. - void fq_nmod_mat_randops(fq_nmod_mat_t mat, slong count, flint_rand_t state, const fq_nmod_ctx_t ctx) + void fq_nmod_mat_randops(fq_nmod_mat_t mat, slong count, flint_rand_t state, const fq_nmod_ctx_t ctx) noexcept # Randomises ``mat`` by performing elementary row or column # operations. More precisely, at most ``count`` random additions # or subtractions of distinct rows and columns will be performed. # This leaves the rank (and for square matrices, determinant) # unchanged. - void fq_nmod_mat_randtril(fq_nmod_mat_t mat, flint_rand_t state, int unit, const fq_nmod_ctx_t ctx) + void fq_nmod_mat_randtril(fq_nmod_mat_t mat, flint_rand_t state, int unit, const fq_nmod_ctx_t ctx) noexcept # Sets ``mat`` to a random lower triangular matrix. If # ``unit`` is 1, it will have ones on the main diagonal, # otherwise it will have random nonzero entries on the main # diagonal. - void fq_nmod_mat_randtriu(fq_nmod_mat_t mat, flint_rand_t state, int unit, const fq_nmod_ctx_t ctx) + void fq_nmod_mat_randtriu(fq_nmod_mat_t mat, flint_rand_t state, int unit, const fq_nmod_ctx_t ctx) noexcept # Sets ``mat`` to a random upper triangular matrix. If # ``unit`` is 1, it will have ones on the main diagonal, # otherwise it will have random nonzero entries on the main # diagonal. - bint fq_nmod_mat_equal(const fq_nmod_mat_t mat1, const fq_nmod_mat_t mat2, const fq_nmod_ctx_t ctx) + bint fq_nmod_mat_equal(const fq_nmod_mat_t mat1, const fq_nmod_mat_t mat2, const fq_nmod_ctx_t ctx) noexcept # Returns nonzero if mat1 and mat2 have the same dimensions and elements, # and zero otherwise. - bint fq_nmod_mat_is_zero(const fq_nmod_mat_t mat, const fq_nmod_ctx_t ctx) + bint fq_nmod_mat_is_zero(const fq_nmod_mat_t mat, const fq_nmod_ctx_t ctx) noexcept # Returns a non-zero value if all entries ``mat`` are zero, and # otherwise returns zero. - bint fq_nmod_mat_is_one(const fq_nmod_mat_t mat, const fq_nmod_ctx_t ctx) + bint fq_nmod_mat_is_one(const fq_nmod_mat_t mat, const fq_nmod_ctx_t ctx) noexcept # Returns a non-zero value if all entries ``mat`` are zero except the # diagonal entries which must be one, otherwise returns zero. - bint fq_nmod_mat_is_empty(const fq_nmod_mat_t mat, const fq_nmod_ctx_t ctx) + bint fq_nmod_mat_is_empty(const fq_nmod_mat_t mat, const fq_nmod_ctx_t ctx) noexcept # Returns a non-zero value if the number of rows or the number of # columns in ``mat`` is zero, and otherwise returns zero. - bint fq_nmod_mat_is_square(const fq_nmod_mat_t mat, const fq_nmod_ctx_t ctx) + bint fq_nmod_mat_is_square(const fq_nmod_mat_t mat, const fq_nmod_ctx_t ctx) noexcept # Returns a non-zero value if the number of rows is equal to the # number of columns in ``mat``, and otherwise returns zero. - void fq_nmod_mat_add(fq_nmod_mat_t C, const fq_nmod_mat_t A, const fq_nmod_mat_t B, const fq_nmod_ctx_t ctx) + void fq_nmod_mat_add(fq_nmod_mat_t C, const fq_nmod_mat_t A, const fq_nmod_mat_t B, const fq_nmod_ctx_t ctx) noexcept # Computes `C = A + B`. Dimensions must be identical. - void fq_nmod_mat_sub(fq_nmod_mat_t C, const fq_nmod_mat_t A, const fq_nmod_mat_t B, const fq_nmod_ctx_t ctx) + void fq_nmod_mat_sub(fq_nmod_mat_t C, const fq_nmod_mat_t A, const fq_nmod_mat_t B, const fq_nmod_ctx_t ctx) noexcept # Computes `C = A - B`. Dimensions must be identical. - void fq_nmod_mat_neg(fq_nmod_mat_t A, const fq_nmod_mat_t B, const fq_nmod_ctx_t ctx) + void fq_nmod_mat_neg(fq_nmod_mat_t A, const fq_nmod_mat_t B, const fq_nmod_ctx_t ctx) noexcept # Sets `B = -A`. Dimensions must be identical. - void fq_nmod_mat_mul(fq_nmod_mat_t C, const fq_nmod_mat_t A, const fq_nmod_mat_t B, const fq_nmod_ctx_t ctx) + void fq_nmod_mat_mul(fq_nmod_mat_t C, const fq_nmod_mat_t A, const fq_nmod_mat_t B, const fq_nmod_ctx_t ctx) noexcept # Sets `C = AB`. Dimensions must be compatible for matrix # multiplication. Aliasing is allowed. This function automatically chooses # between classical and KS multiplication. - void fq_nmod_mat_mul_classical(fq_nmod_mat_t C, const fq_nmod_mat_t A, const fq_nmod_mat_t B, const fq_nmod_ctx_t ctx) + void fq_nmod_mat_mul_classical(fq_nmod_mat_t C, const fq_nmod_mat_t A, const fq_nmod_mat_t B, const fq_nmod_ctx_t ctx) noexcept # Sets `C = AB`. Dimensions must be compatible for matrix multiplication. # `C` is not allowed to be aliased with `A` or `B`. Uses classical # matrix multiplication. - void fq_nmod_mat_mul_KS(fq_nmod_mat_t C, const fq_nmod_mat_t A, const fq_nmod_mat_t B, const fq_nmod_ctx_t ctx) + void fq_nmod_mat_mul_KS(fq_nmod_mat_t C, const fq_nmod_mat_t A, const fq_nmod_mat_t B, const fq_nmod_ctx_t ctx) noexcept # Sets `C = AB`. Dimensions must be compatible for matrix # multiplication. `C` is not allowed to be aliased with `A` or # `B`. Uses Kronecker substitution to perform the multiplication # over the integers. - void fq_nmod_mat_submul(fq_nmod_mat_t D, const fq_nmod_mat_t C, const fq_nmod_mat_t A, const fq_nmod_mat_t B, const fq_nmod_ctx_t ctx) + void fq_nmod_mat_submul(fq_nmod_mat_t D, const fq_nmod_mat_t C, const fq_nmod_mat_t A, const fq_nmod_mat_t B, const fq_nmod_ctx_t ctx) noexcept # Sets `D = C + AB`. `C` and `D` may be aliased with each other but # not with `A` or `B`. - void fq_nmod_mat_mul_vec(fq_nmod_struct * c, const fq_nmod_mat_t A, const fq_nmod_struct * b, slong blen, const fq_nmod_ctx_t ctx) - void fq_nmod_mat_mul_vec_ptr(fq_nmod_struct * const * c, const fq_nmod_mat_t A, const fq_nmod_struct * const * b, slong blen, const fq_nmod_ctx_t ctx) + void fq_nmod_mat_mul_vec(fq_nmod_struct * c, const fq_nmod_mat_t A, const fq_nmod_struct * b, slong blen, const fq_nmod_ctx_t ctx) noexcept + void fq_nmod_mat_mul_vec_ptr(fq_nmod_struct * const * c, const fq_nmod_mat_t A, const fq_nmod_struct * const * b, slong blen, const fq_nmod_ctx_t ctx) noexcept # Compute a matrix-vector product of ``A`` and ``(b, blen)`` and store the result in ``c``. # The vector ``(b, blen)`` is either truncated or zero-extended to the number of columns of ``A``. # The number entries written to ``c`` is always equal to the number of rows of ``A``. - void fq_nmod_mat_vec_mul(fq_nmod_struct * c, const fq_nmod_struct * a, slong alen, const fq_nmod_mat_t B, const fq_nmod_ctx_t ctx) - void fq_nmod_mat_vec_mul_ptr(fq_nmod_struct * const * c, const fq_nmod_struct * const * a, slong alen, const fq_nmod_mat_t B, const fq_nmod_ctx_t ctx) + void fq_nmod_mat_vec_mul(fq_nmod_struct * c, const fq_nmod_struct * a, slong alen, const fq_nmod_mat_t B, const fq_nmod_ctx_t ctx) noexcept + void fq_nmod_mat_vec_mul_ptr(fq_nmod_struct * const * c, const fq_nmod_struct * const * a, slong alen, const fq_nmod_mat_t B, const fq_nmod_ctx_t ctx) noexcept # Compute a vector-matrix product of ``(a, alen)`` and ``B`` and and store the result in ``c``. # The vector ``(a, alen)`` is either truncated or zero-extended to the number of rows of ``B``. # The number entries written to ``c`` is always equal to the number of columns of ``B``. - int fq_nmod_mat_inv(fq_nmod_mat_t B, fq_nmod_mat_t A, const fq_nmod_ctx_t ctx) + int fq_nmod_mat_inv(fq_nmod_mat_t B, fq_nmod_mat_t A, const fq_nmod_ctx_t ctx) noexcept # Sets `B = A^{-1}` and returns `1` if `A` is invertible. If `A` is singular, # returns `0` and sets the elements of `B` to undefined values. # `A` and `B` must be square matrices with the same dimensions. - slong fq_nmod_mat_lu(slong * P, fq_nmod_mat_t A, int rank_check, const fq_nmod_ctx_t ctx) + slong fq_nmod_mat_lu(slong * P, fq_nmod_mat_t A, int rank_check, const fq_nmod_ctx_t ctx) noexcept # Computes a generalised LU decomposition `LU = PA` of a given # matrix `A`, returning the rank of `A`. # If `A` is a nonsingular square matrix, it will be overwritten with @@ -240,26 +240,26 @@ cdef extern from "flint_wrap.h": # if `A` is detected to be rank-deficient. # This function calls ``fq_nmod_mat_lu_recursive``. - slong fq_nmod_mat_lu_classical(slong * P, fq_nmod_mat_t A, int rank_check, const fq_nmod_ctx_t ctx) + slong fq_nmod_mat_lu_classical(slong * P, fq_nmod_mat_t A, int rank_check, const fq_nmod_ctx_t ctx) noexcept # Computes a generalised LU decomposition `LU = PA` of a given # matrix `A`, returning the rank of `A`. The behavior of this # function is identical to that of ``fq_nmod_mat_lu``. Uses Gaussian # elimination. - slong fq_nmod_mat_lu_recursive(slong * P, fq_nmod_mat_t A, int rank_check, const fq_nmod_ctx_t ctx) + slong fq_nmod_mat_lu_recursive(slong * P, fq_nmod_mat_t A, int rank_check, const fq_nmod_ctx_t ctx) noexcept # Computes a generalised LU decomposition `LU = PA` of a given # matrix `A`, returning the rank of `A`. The behavior of this # function is identical to that of ``fq_nmod_mat_lu``. Uses recursive # block decomposition, switching to classical Gaussian elimination # for sufficiently small blocks. - slong fq_nmod_mat_rref(fq_nmod_mat_t A, const fq_nmod_ctx_t ctx) + slong fq_nmod_mat_rref(fq_nmod_mat_t A, const fq_nmod_ctx_t ctx) noexcept # Puts `A` in reduced row echelon form and returns the rank of `A`. # The rref is computed by first obtaining an unreduced row echelon # form via LU decomposition and then solving an additional # triangular system. - slong fq_nmod_mat_reduce_row(fq_nmod_mat_t A, slong * P, slong * L, slong n, const fq_nmod_ctx_t ctx) + slong fq_nmod_mat_reduce_row(fq_nmod_mat_t A, slong * P, slong * L, slong n, const fq_nmod_ctx_t ctx) noexcept # Reduce row n of the matrix `A`, assuming the prior rows are in Gauss # form. However those rows may not be in order. The entry `i` of the array # `P` is the row of `A` which has a pivot in the `i`-th column. If no such @@ -272,7 +272,7 @@ cdef extern from "flint_wrap.h": # `L` can all be set to the number of columns of `A`. We require the entries # of `L` to be monotonic increasing. - void fq_nmod_mat_solve_tril(fq_nmod_mat_t X, const fq_nmod_mat_t L, const fq_nmod_mat_t B, int unit, const fq_nmod_ctx_t ctx) + void fq_nmod_mat_solve_tril(fq_nmod_mat_t X, const fq_nmod_mat_t L, const fq_nmod_mat_t B, int unit, const fq_nmod_ctx_t ctx) noexcept # Sets `X = L^{-1} B` where `L` is a full rank lower triangular # square matrix. If ``unit`` = 1, `L` is assumed to have ones on # its main diagonal, and the main diagonal will not be read. `X` @@ -280,14 +280,14 @@ cdef extern from "flint_wrap.h": # is allowed. Automatically chooses between the classical and # recursive algorithms. - void fq_nmod_mat_solve_tril_classical(fq_nmod_mat_t X, const fq_nmod_mat_t L, const fq_nmod_mat_t B, int unit, const fq_nmod_ctx_t ctx) + void fq_nmod_mat_solve_tril_classical(fq_nmod_mat_t X, const fq_nmod_mat_t L, const fq_nmod_mat_t B, int unit, const fq_nmod_ctx_t ctx) noexcept # Sets `X = L^{-1} B` where `L` is a full rank lower triangular # square matrix. If ``unit`` = 1, `L` is assumed to have ones on # its main diagonal, and the main diagonal will not be read. `X` # and `B` are allowed to be the same matrix, but no other aliasing # is allowed. Uses forward substitution. - void fq_nmod_mat_solve_tril_recursive(fq_nmod_mat_t X, const fq_nmod_mat_t L, const fq_nmod_mat_t B, int unit, const fq_nmod_ctx_t ctx) + void fq_nmod_mat_solve_tril_recursive(fq_nmod_mat_t X, const fq_nmod_mat_t L, const fq_nmod_mat_t B, int unit, const fq_nmod_ctx_t ctx) noexcept # Sets `X = L^{-1} B` where `L` is a full rank lower triangular # square matrix. If ``unit`` = 1, `L` is assumed to have ones on # its main diagonal, and the main diagonal will not be read. `X` @@ -301,7 +301,7 @@ cdef extern from "flint_wrap.h": # to reduce the problem to matrix multiplication and triangular # solving of smaller systems. - void fq_nmod_mat_solve_triu(fq_nmod_mat_t X, const fq_nmod_mat_t U, const fq_nmod_mat_t B, int unit, const fq_nmod_ctx_t ctx) + void fq_nmod_mat_solve_triu(fq_nmod_mat_t X, const fq_nmod_mat_t U, const fq_nmod_mat_t B, int unit, const fq_nmod_ctx_t ctx) noexcept # Sets `X = U^{-1} B` where `U` is a full rank upper triangular # square matrix. If ``unit`` = 1, `U` is assumed to have ones on # its main diagonal, and the main diagonal will not be read. `X` @@ -309,14 +309,14 @@ cdef extern from "flint_wrap.h": # is allowed. Automatically chooses between the classical and # recursive algorithms. - void fq_nmod_mat_solve_triu_classical(fq_nmod_mat_t X, const fq_nmod_mat_t U, const fq_nmod_mat_t B, int unit, const fq_nmod_ctx_t ctx) + void fq_nmod_mat_solve_triu_classical(fq_nmod_mat_t X, const fq_nmod_mat_t U, const fq_nmod_mat_t B, int unit, const fq_nmod_ctx_t ctx) noexcept # Sets `X = U^{-1} B` where `U` is a full rank upper triangular # square matrix. If ``unit`` = 1, `U` is assumed to have ones on # its main diagonal, and the main diagonal will not be read. `X` # and `B` are allowed to be the same matrix, but no other aliasing # is allowed. Uses forward substitution. - void fq_nmod_mat_solve_triu_recursive(fq_nmod_mat_t X, const fq_nmod_mat_t U, const fq_nmod_mat_t B, int unit, const fq_nmod_ctx_t ctx) + void fq_nmod_mat_solve_triu_recursive(fq_nmod_mat_t X, const fq_nmod_mat_t U, const fq_nmod_mat_t B, int unit, const fq_nmod_ctx_t ctx) noexcept # Sets `X = U^{-1} B` where `U` is a full rank upper triangular # square matrix. If ``unit`` = 1, `U` is assumed to have ones on # its main diagonal, and the main diagonal will not be read. `X` @@ -330,20 +330,20 @@ cdef extern from "flint_wrap.h": # to reduce the problem to matrix multiplication and triangular # solving of smaller systems. - int fq_nmod_mat_solve(fq_nmod_mat_t X, const fq_nmod_mat_t A, const fq_nmod_mat_t B, const fq_nmod_ctx_t ctx) + int fq_nmod_mat_solve(fq_nmod_mat_t X, const fq_nmod_mat_t A, const fq_nmod_mat_t B, const fq_nmod_ctx_t ctx) noexcept # Solves the matrix-matrix equation `AX = B`. # Returns `1` if `A` has full rank; otherwise returns `0` and sets the # elements of `X` to undefined values. # The matrix `A` must be square. - int fq_nmod_mat_can_solve(fq_nmod_mat_t X, const fq_nmod_mat_t A, const fq_nmod_mat_t B, const fq_nmod_ctx_t ctx) + int fq_nmod_mat_can_solve(fq_nmod_mat_t X, const fq_nmod_mat_t A, const fq_nmod_mat_t B, const fq_nmod_ctx_t ctx) noexcept # Solves the matrix-matrix equation `AX = B` over `Fq`. # Returns `1` if a solution exists; otherwise returns `0` and sets the # elements of `X` to zero. If more than one solution exists, one of the # valid solutions is given. # There are no restrictions on the shape of `A` and it may be singular. - void fq_nmod_mat_similarity(fq_nmod_mat_t M, slong r, fq_nmod_t d, const fq_nmod_ctx_t ctx) + void fq_nmod_mat_similarity(fq_nmod_mat_t M, slong r, fq_nmod_t d, const fq_nmod_ctx_t ctx) noexcept # Applies a similarity transform to the `n\times n` matrix `M` in-place. # If `P` is the `n\times n` identity matrix the zero entries of whose row # `r` (`0`-indexed) have been replaced by `d`, this transform is equivalent @@ -353,14 +353,14 @@ cdef extern from "flint_wrap.h": # The value `d` is required to be reduced modulo the modulus of the entries # in the matrix. - void fq_nmod_mat_charpoly_danilevsky(fq_nmod_poly_t p, const fq_nmod_mat_t M, const fq_nmod_ctx_t ctx) + void fq_nmod_mat_charpoly_danilevsky(fq_nmod_poly_t p, const fq_nmod_mat_t M, const fq_nmod_ctx_t ctx) noexcept # Compute the characteristic polynomial `p` of the matrix `M`. The matrix # is assumed to be square. - void fq_nmod_mat_charpoly(fq_nmod_poly_t p, const fq_nmod_mat_t M, const fq_nmod_ctx_t ctx) + void fq_nmod_mat_charpoly(fq_nmod_poly_t p, const fq_nmod_mat_t M, const fq_nmod_ctx_t ctx) noexcept # Compute the characteristic polynomial `p` of the matrix `M`. The matrix # is required to be square, otherwise an exception is raised. - void fq_nmod_mat_minpoly(fq_nmod_poly_t p, const fq_nmod_mat_t M, const fq_nmod_ctx_t ctx) + void fq_nmod_mat_minpoly(fq_nmod_poly_t p, const fq_nmod_mat_t M, const fq_nmod_ctx_t ctx) noexcept # Compute the minimal polynomial `p` of the matrix `M`. The matrix # is required to be square, otherwise an exception is raised. diff --git a/src/sage/libs/flint/fq_nmod_mpoly.pxd b/src/sage/libs/flint/fq_nmod_mpoly.pxd index bbab91a5de6..4b90208edc6 100644 --- a/src/sage/libs/flint/fq_nmod_mpoly.pxd +++ b/src/sage/libs/flint/fq_nmod_mpoly.pxd @@ -12,354 +12,354 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void fq_nmod_mpoly_ctx_init(fq_nmod_mpoly_ctx_t ctx, slong nvars, const ordering_t ord, const fq_nmod_ctx_t fqctx) + void fq_nmod_mpoly_ctx_init(fq_nmod_mpoly_ctx_t ctx, slong nvars, const ordering_t ord, const fq_nmod_ctx_t fqctx) noexcept # Initialise a context object for a polynomial ring with the given number of variables and the given ordering. # It will have coefficients in the finite field *fqctx*. # The possibilities for the ordering are ``ORD_LEX``, ``ORD_DEGLEX`` and ``ORD_DEGREVLEX``. - slong fq_nmod_mpoly_ctx_nvars(const fq_nmod_mpoly_ctx_t ctx) + slong fq_nmod_mpoly_ctx_nvars(const fq_nmod_mpoly_ctx_t ctx) noexcept # Return the number of variables used to initialize the context. - ordering_t fq_nmod_mpoly_ctx_ord(const fq_nmod_mpoly_ctx_t ctx) + ordering_t fq_nmod_mpoly_ctx_ord(const fq_nmod_mpoly_ctx_t ctx) noexcept # Return the ordering used to initialize the context. - void fq_nmod_mpoly_ctx_clear(fq_nmod_mpoly_ctx_t ctx) + void fq_nmod_mpoly_ctx_clear(fq_nmod_mpoly_ctx_t ctx) noexcept # Release any space allocated by an *ctx*. - void fq_nmod_mpoly_init(fq_nmod_mpoly_t A, const fq_nmod_mpoly_ctx_t ctx) + void fq_nmod_mpoly_init(fq_nmod_mpoly_t A, const fq_nmod_mpoly_ctx_t ctx) noexcept # Initialise *A* for use with the given an initialised context object. Its value is set to zero. - void fq_nmod_mpoly_init2(fq_nmod_mpoly_t A, slong alloc, const fq_nmod_mpoly_ctx_t ctx) + void fq_nmod_mpoly_init2(fq_nmod_mpoly_t A, slong alloc, const fq_nmod_mpoly_ctx_t ctx) noexcept # Initialise *A* for use with the given an initialised context object. Its value is set to zero. # It is allocated with space for *alloc* terms and at least ``MPOLY_MIN_BITS`` bits for the exponents. - void fq_nmod_mpoly_init3(fq_nmod_mpoly_t A, slong alloc, flint_bitcnt_t bits, const fq_nmod_mpoly_ctx_t ctx) + void fq_nmod_mpoly_init3(fq_nmod_mpoly_t A, slong alloc, flint_bitcnt_t bits, const fq_nmod_mpoly_ctx_t ctx) noexcept # Initialise *A* for use with the given an initialised context object. Its value is set to zero. # It is allocated with space for *alloc* terms and *bits* bits for the exponents. - void fq_nmod_mpoly_fit_length(fq_nmod_mpoly_t A, slong len, const fq_nmod_mpoly_ctx_t ctx) + void fq_nmod_mpoly_fit_length(fq_nmod_mpoly_t A, slong len, const fq_nmod_mpoly_ctx_t ctx) noexcept # Ensure that *A* has space for at least *len* terms. - void fq_nmod_mpoly_realloc(fq_nmod_mpoly_t A, slong alloc, const fq_nmod_mpoly_ctx_t ctx) + void fq_nmod_mpoly_realloc(fq_nmod_mpoly_t A, slong alloc, const fq_nmod_mpoly_ctx_t ctx) noexcept # Reallocate *A* to have space for *alloc* terms. # Assumes the current length of the polynomial is not greater than *alloc*. - void fq_nmod_mpoly_clear(fq_nmod_mpoly_t A, const fq_nmod_mpoly_ctx_t ctx) + void fq_nmod_mpoly_clear(fq_nmod_mpoly_t A, const fq_nmod_mpoly_ctx_t ctx) noexcept # Release any space allocated for *A*. - char * fq_nmod_mpoly_get_str_pretty(const fq_nmod_mpoly_t A, const char ** x, const fq_nmod_mpoly_ctx_t ctx) + char * fq_nmod_mpoly_get_str_pretty(const fq_nmod_mpoly_t A, const char ** x, const fq_nmod_mpoly_ctx_t ctx) noexcept # Return a string, which the user is responsible for cleaning up, representing *A*, given an array of variable strings *x*. - int fq_nmod_mpoly_fprint_pretty(FILE * file, const fq_nmod_mpoly_t A, const char ** x, const fq_nmod_mpoly_ctx_t ctx) + int fq_nmod_mpoly_fprint_pretty(FILE * file, const fq_nmod_mpoly_t A, const char ** x, const fq_nmod_mpoly_ctx_t ctx) noexcept # Print a string representing *A* to *file*. - int fq_nmod_mpoly_print_pretty(const fq_nmod_mpoly_t A, const char ** x, const fq_nmod_mpoly_ctx_t ctx) + int fq_nmod_mpoly_print_pretty(const fq_nmod_mpoly_t A, const char ** x, const fq_nmod_mpoly_ctx_t ctx) noexcept # Print a string representing *A* to ``stdout``. - int fq_nmod_mpoly_set_str_pretty(fq_nmod_mpoly_t A, const char * str, const char ** x, const fq_nmod_mpoly_ctx_t ctx) + int fq_nmod_mpoly_set_str_pretty(fq_nmod_mpoly_t A, const char * str, const char ** x, const fq_nmod_mpoly_ctx_t ctx) noexcept # Set *A* to the polynomial in the null-terminates string *str* given an array *x* of variable strings. # If parsing *str* fails, *A* is set to zero, and `-1` is returned. Otherwise, `0` is returned. # The operations ``+``, ``-``, ``*``, and ``/`` are permitted along with integers and the variables in *x*. The character ``^`` must be immediately followed by the (integer) exponent. # If any division is not exact, parsing fails. - void fq_nmod_mpoly_gen(fq_nmod_mpoly_t A, slong var, const fq_nmod_mpoly_ctx_t ctx) + void fq_nmod_mpoly_gen(fq_nmod_mpoly_t A, slong var, const fq_nmod_mpoly_ctx_t ctx) noexcept # Set *A* to the variable of index *var*, where `var = 0` corresponds to the variable with the most significance with respect to the ordering. - bint fq_nmod_mpoly_is_gen(const fq_nmod_mpoly_t A, slong var, const fq_nmod_mpoly_ctx_t ctx) + bint fq_nmod_mpoly_is_gen(const fq_nmod_mpoly_t A, slong var, const fq_nmod_mpoly_ctx_t ctx) noexcept # If `var \ge 0`, return `1` if *A* is equal to the `var`-th generator, otherwise return `0`. # If `var < 0`, return `1` if the polynomial is equal to any generator, otherwise return `0`. - void fq_nmod_mpoly_set(fq_nmod_mpoly_t A, const fq_nmod_mpoly_t B, const fq_nmod_mpoly_ctx_t ctx) + void fq_nmod_mpoly_set(fq_nmod_mpoly_t A, const fq_nmod_mpoly_t B, const fq_nmod_mpoly_ctx_t ctx) noexcept # Set *A* to *B*. - bint fq_nmod_mpoly_equal(const fq_nmod_mpoly_t A, const fq_nmod_mpoly_t B, const fq_nmod_mpoly_ctx_t ctx) + bint fq_nmod_mpoly_equal(const fq_nmod_mpoly_t A, const fq_nmod_mpoly_t B, const fq_nmod_mpoly_ctx_t ctx) noexcept # Return `1` if *A* is equal to *B*, else return `0`. - void fq_nmod_mpoly_swap(fq_nmod_mpoly_t A, fq_nmod_mpoly_t B, const fq_nmod_mpoly_ctx_t ctx) + void fq_nmod_mpoly_swap(fq_nmod_mpoly_t A, fq_nmod_mpoly_t B, const fq_nmod_mpoly_ctx_t ctx) noexcept # Efficiently swap *A* and *B*. - bint fq_nmod_mpoly_is_fq_nmod(const fq_nmod_mpoly_t A, const fq_nmod_mpoly_ctx_t ctx) + bint fq_nmod_mpoly_is_fq_nmod(const fq_nmod_mpoly_t A, const fq_nmod_mpoly_ctx_t ctx) noexcept # Return `1` if *A* is a constant, else return `0`. - void fq_nmod_mpoly_get_fq_nmod(fq_nmod_t c, const fq_nmod_mpoly_t A, const fq_nmod_mpoly_ctx_t ctx) + void fq_nmod_mpoly_get_fq_nmod(fq_nmod_t c, const fq_nmod_mpoly_t A, const fq_nmod_mpoly_ctx_t ctx) noexcept # Assuming that *A* is a constant, set *c* to this constant. # This function throws if *A* is not a constant. - void fq_nmod_mpoly_set_fq_nmod(fq_nmod_mpoly_t A, const fq_nmod_t c, const fq_nmod_mpoly_ctx_t ctx) - void fq_nmod_mpoly_set_ui(fq_nmod_mpoly_t A, ulong c, const fq_nmod_mpoly_ctx_t ctx) + void fq_nmod_mpoly_set_fq_nmod(fq_nmod_mpoly_t A, const fq_nmod_t c, const fq_nmod_mpoly_ctx_t ctx) noexcept + void fq_nmod_mpoly_set_ui(fq_nmod_mpoly_t A, ulong c, const fq_nmod_mpoly_ctx_t ctx) noexcept # Set *A* to the constant *c*. - void fq_nmod_mpoly_set_fq_nmod_gen(fq_nmod_mpoly_t A, const fq_nmod_mpoly_ctx_t ctx) + void fq_nmod_mpoly_set_fq_nmod_gen(fq_nmod_mpoly_t A, const fq_nmod_mpoly_ctx_t ctx) noexcept # Set *A* to the constant given by :func:`fq_nmod_gen`. - void fq_nmod_mpoly_zero(fq_nmod_mpoly_t A, const fq_nmod_mpoly_ctx_t ctx) + void fq_nmod_mpoly_zero(fq_nmod_mpoly_t A, const fq_nmod_mpoly_ctx_t ctx) noexcept # Set *A* to the constant `0`. - void fq_nmod_mpoly_one(fq_nmod_mpoly_t A, const fq_nmod_mpoly_ctx_t ctx) + void fq_nmod_mpoly_one(fq_nmod_mpoly_t A, const fq_nmod_mpoly_ctx_t ctx) noexcept # Set *A* to the constant `1`. - bint fq_nmod_mpoly_equal_fq_nmod(const fq_nmod_mpoly_t A, const fq_nmod_t c, const fq_nmod_mpoly_ctx_t ctx) + bint fq_nmod_mpoly_equal_fq_nmod(const fq_nmod_mpoly_t A, const fq_nmod_t c, const fq_nmod_mpoly_ctx_t ctx) noexcept # Return `1` if *A* is equal to the constant *c*, else return `0`. - bint fq_nmod_mpoly_is_zero(const fq_nmod_mpoly_t A, const fq_nmod_mpoly_ctx_t ctx) + bint fq_nmod_mpoly_is_zero(const fq_nmod_mpoly_t A, const fq_nmod_mpoly_ctx_t ctx) noexcept # Return `1` if *A* is the constant `0`, else return `0`. - bint fq_nmod_mpoly_is_one(const fq_nmod_mpoly_t A, const fq_nmod_mpoly_ctx_t ctx) + bint fq_nmod_mpoly_is_one(const fq_nmod_mpoly_t A, const fq_nmod_mpoly_ctx_t ctx) noexcept # Return `1` if *A* is the constant `1`, else return `0`. - int fq_nmod_mpoly_degrees_fit_si(const fq_nmod_mpoly_t A, const fq_nmod_mpoly_ctx_t ctx) + int fq_nmod_mpoly_degrees_fit_si(const fq_nmod_mpoly_t A, const fq_nmod_mpoly_ctx_t ctx) noexcept # Return `1` if the degrees of *A* with respect to each variable fit into an ``slong``, otherwise return `0`. - void fq_nmod_mpoly_degrees_fmpz(fmpz ** degs, const fq_nmod_mpoly_t A, const fq_nmod_mpoly_ctx_t ctx) - void fq_nmod_mpoly_degrees_si(slong * degs, const fq_nmod_mpoly_t A, const fq_nmod_mpoly_ctx_t ctx) + void fq_nmod_mpoly_degrees_fmpz(fmpz ** degs, const fq_nmod_mpoly_t A, const fq_nmod_mpoly_ctx_t ctx) noexcept + void fq_nmod_mpoly_degrees_si(slong * degs, const fq_nmod_mpoly_t A, const fq_nmod_mpoly_ctx_t ctx) noexcept # Set *degs* to the degrees of *A* with respect to each variable. # If *A* is zero, all degrees are set to `-1`. - void fq_nmod_mpoly_degree_fmpz(fmpz_t deg, const fq_nmod_mpoly_t A, slong var, const fq_nmod_mpoly_ctx_t ctx) - slong fq_nmod_mpoly_degree_si(const fq_nmod_mpoly_t A, slong var, const fq_nmod_mpoly_ctx_t ctx) + void fq_nmod_mpoly_degree_fmpz(fmpz_t deg, const fq_nmod_mpoly_t A, slong var, const fq_nmod_mpoly_ctx_t ctx) noexcept + slong fq_nmod_mpoly_degree_si(const fq_nmod_mpoly_t A, slong var, const fq_nmod_mpoly_ctx_t ctx) noexcept # Either return or set *deg* to the degree of *A* with respect to the variable of index *var*. # If *A* is zero, the degree is defined to be `-1`. - int fq_nmod_mpoly_total_degree_fits_si(const fq_nmod_mpoly_t A, const fq_nmod_mpoly_ctx_t ctx) + int fq_nmod_mpoly_total_degree_fits_si(const fq_nmod_mpoly_t A, const fq_nmod_mpoly_ctx_t ctx) noexcept # Return `1` if the total degree of *A* fits into an ``slong``, otherwise return `0`. - void fq_nmod_mpoly_total_degree_fmpz(fmpz_t tdeg, const fq_nmod_mpoly_t A, const fq_nmod_mpoly_ctx_t ctx) - slong fq_nmod_mpoly_total_degree_si(const fq_nmod_mpoly_t A, const fq_nmod_mpoly_ctx_t ctx) + void fq_nmod_mpoly_total_degree_fmpz(fmpz_t tdeg, const fq_nmod_mpoly_t A, const fq_nmod_mpoly_ctx_t ctx) noexcept + slong fq_nmod_mpoly_total_degree_si(const fq_nmod_mpoly_t A, const fq_nmod_mpoly_ctx_t ctx) noexcept # Either return or set *tdeg* to the total degree of *A*. # If *A* is zero, the total degree is defined to be `-1`. - void fq_nmod_mpoly_used_vars(int * used, const fq_nmod_mpoly_t A, const fq_nmod_mpoly_ctx_t ctx) + void fq_nmod_mpoly_used_vars(int * used, const fq_nmod_mpoly_t A, const fq_nmod_mpoly_ctx_t ctx) noexcept # For each variable index `i`, set ``used[i]`` to nonzero if the variable of index `i` appears in *A* and to zero otherwise. - void fq_nmod_mpoly_get_coeff_fq_nmod_monomial(fq_nmod_t c, const fq_nmod_mpoly_t A, const fq_nmod_mpoly_t M, const fq_nmod_mpoly_ctx_t ctx) + void fq_nmod_mpoly_get_coeff_fq_nmod_monomial(fq_nmod_t c, const fq_nmod_mpoly_t A, const fq_nmod_mpoly_t M, const fq_nmod_mpoly_ctx_t ctx) noexcept # Assuming that *M* is a monomial, set *c* to the coefficient of the corresponding monomial in *A*. # This function throws if *M* is not a monomial. - void fq_nmod_mpoly_set_coeff_fq_nmod_monomial(fq_nmod_mpoly_t A, const fq_nmod_t c, const fq_nmod_mpoly_t M, const fq_nmod_mpoly_ctx_t ctx) + void fq_nmod_mpoly_set_coeff_fq_nmod_monomial(fq_nmod_mpoly_t A, const fq_nmod_t c, const fq_nmod_mpoly_t M, const fq_nmod_mpoly_ctx_t ctx) noexcept # Assuming that *M* is a monomial, set the coefficient of the corresponding monomial in *A* to *c*. # This function throws if *M* is not a monomial. - void fq_nmod_mpoly_get_coeff_fq_nmod_fmpz(fq_nmod_t c, const fq_nmod_mpoly_t A, fmpz * const * exp, const fq_nmod_mpoly_ctx_t ctx) - void fq_nmod_mpoly_get_coeff_fq_nmod_ui(fq_nmod_t c, const fq_nmod_mpoly_t A, const ulong * exp, const fq_nmod_mpoly_ctx_t ctx) + void fq_nmod_mpoly_get_coeff_fq_nmod_fmpz(fq_nmod_t c, const fq_nmod_mpoly_t A, fmpz * const * exp, const fq_nmod_mpoly_ctx_t ctx) noexcept + void fq_nmod_mpoly_get_coeff_fq_nmod_ui(fq_nmod_t c, const fq_nmod_mpoly_t A, const ulong * exp, const fq_nmod_mpoly_ctx_t ctx) noexcept # Set *c* to the coefficient of the monomial with exponent vector *exp*. - void fq_nmod_mpoly_set_coeff_fq_nmod_fmpz(fq_nmod_mpoly_t A, const fq_nmod_t c, fmpz * const * exp, const fq_nmod_mpoly_ctx_t ctx) - void fq_nmod_mpoly_set_coeff_fq_nmod_ui(fq_nmod_mpoly_t A, const fq_nmod_t c, const ulong * exp, const fq_nmod_mpoly_ctx_t ctx) + void fq_nmod_mpoly_set_coeff_fq_nmod_fmpz(fq_nmod_mpoly_t A, const fq_nmod_t c, fmpz * const * exp, const fq_nmod_mpoly_ctx_t ctx) noexcept + void fq_nmod_mpoly_set_coeff_fq_nmod_ui(fq_nmod_mpoly_t A, const fq_nmod_t c, const ulong * exp, const fq_nmod_mpoly_ctx_t ctx) noexcept # Set the coefficient of the monomial with exponent *exp* to *c*. - void fq_nmod_mpoly_get_coeff_vars_ui(fq_nmod_mpoly_t C, const fq_nmod_mpoly_t A, const slong * vars, const ulong * exps, slong length, const fq_nmod_mpoly_ctx_t ctx) + void fq_nmod_mpoly_get_coeff_vars_ui(fq_nmod_mpoly_t C, const fq_nmod_mpoly_t A, const slong * vars, const ulong * exps, slong length, const fq_nmod_mpoly_ctx_t ctx) noexcept # Set *C* to the coefficient of *A* with respect to the variables in *vars* with powers in the corresponding array *exps*. # Both *vars* and *exps* point to array of length *length*. It is assumed that `0 < length \le nvars(A)` and that the variables in *vars* are distinct. - int fq_nmod_mpoly_cmp(const fq_nmod_mpoly_t A, const fq_nmod_mpoly_t B, const fq_nmod_mpoly_ctx_t ctx) + int fq_nmod_mpoly_cmp(const fq_nmod_mpoly_t A, const fq_nmod_mpoly_t B, const fq_nmod_mpoly_ctx_t ctx) noexcept # Return `1` (resp. `-1`, or `0`) if *A* is after (resp. before, same as) *B* in some arbitrary but fixed total ordering of the polynomials. # This ordering agrees with the usual ordering of monomials when *A* and *B* are both monomials. - bint fq_nmod_mpoly_is_canonical(const fq_nmod_mpoly_t A, const fq_nmod_mpoly_ctx_t ctx) + bint fq_nmod_mpoly_is_canonical(const fq_nmod_mpoly_t A, const fq_nmod_mpoly_ctx_t ctx) noexcept # Return `1` if *A* is in canonical form. Otherwise, return `0`. # To be in canonical form, all of the terms must have nonzero coefficients, and the terms must be sorted from greatest to least. - slong fq_nmod_mpoly_length(const fq_nmod_mpoly_t A, const fq_nmod_mpoly_ctx_t ctx) + slong fq_nmod_mpoly_length(const fq_nmod_mpoly_t A, const fq_nmod_mpoly_ctx_t ctx) noexcept # Return the number of terms in *A*. # If the polynomial is in canonical form, this will be the number of nonzero coefficients. - void fq_nmod_mpoly_resize(fq_nmod_mpoly_t A, slong new_length, const fq_nmod_mpoly_ctx_t ctx) + void fq_nmod_mpoly_resize(fq_nmod_mpoly_t A, slong new_length, const fq_nmod_mpoly_ctx_t ctx) noexcept # Set the length of *A* to ``new_length``. # Terms are either deleted from the end, or new zero terms are appended. - void fq_nmod_mpoly_get_term_coeff_fq_nmod(fq_nmod_t c, const fq_nmod_mpoly_t A, slong i, const fq_nmod_mpoly_ctx_t ctx) + void fq_nmod_mpoly_get_term_coeff_fq_nmod(fq_nmod_t c, const fq_nmod_mpoly_t A, slong i, const fq_nmod_mpoly_ctx_t ctx) noexcept # Set *c* to the coefficient of the term of index *i*. - void fq_nmod_mpoly_set_term_coeff_ui(fq_nmod_mpoly_t A, slong i, ulong c, const fq_nmod_mpoly_ctx_t ctx) + void fq_nmod_mpoly_set_term_coeff_ui(fq_nmod_mpoly_t A, slong i, ulong c, const fq_nmod_mpoly_ctx_t ctx) noexcept # Set the coefficient of the term of index *i* to *c*. - int fq_nmod_mpoly_term_exp_fits_si(const fq_nmod_mpoly_t A, slong i, const fq_nmod_mpoly_ctx_t ctx) - int fq_nmod_mpoly_term_exp_fits_ui(const fq_nmod_mpoly_t A, slong i, const fq_nmod_mpoly_ctx_t ctx) + int fq_nmod_mpoly_term_exp_fits_si(const fq_nmod_mpoly_t A, slong i, const fq_nmod_mpoly_ctx_t ctx) noexcept + int fq_nmod_mpoly_term_exp_fits_ui(const fq_nmod_mpoly_t A, slong i, const fq_nmod_mpoly_ctx_t ctx) noexcept # Return `1` if all entries of the exponent vector of the term of index `i` fit into an ``slong`` (resp. a ``ulong``). Otherwise, return `0`. - void fq_nmod_mpoly_get_term_exp_fmpz(fmpz ** exp, const fq_nmod_mpoly_t A, slong i, const fq_nmod_mpoly_ctx_t ctx) - void fq_nmod_mpoly_get_term_exp_ui(ulong * exp, const fq_nmod_mpoly_t A, slong i, const fq_nmod_mpoly_ctx_t ctx) - void fq_nmod_mpoly_get_term_exp_si(slong * exp, const fq_nmod_mpoly_t A, slong i, const fq_nmod_mpoly_ctx_t ctx) + void fq_nmod_mpoly_get_term_exp_fmpz(fmpz ** exp, const fq_nmod_mpoly_t A, slong i, const fq_nmod_mpoly_ctx_t ctx) noexcept + void fq_nmod_mpoly_get_term_exp_ui(ulong * exp, const fq_nmod_mpoly_t A, slong i, const fq_nmod_mpoly_ctx_t ctx) noexcept + void fq_nmod_mpoly_get_term_exp_si(slong * exp, const fq_nmod_mpoly_t A, slong i, const fq_nmod_mpoly_ctx_t ctx) noexcept # Set *exp* to the exponent vector of the term of index *i*. # The ``_ui`` (resp. ``_si``) version throws if any entry does not fit into a ``ulong`` (resp. ``slong``). - ulong fq_nmod_mpoly_get_term_var_exp_ui(const fq_nmod_mpoly_t A, slong i, slong var, const fq_nmod_mpoly_ctx_t ctx) - slong fq_nmod_mpoly_get_term_var_exp_si(const fq_nmod_mpoly_t A, slong i, slong var, const fq_nmod_mpoly_ctx_t ctx) + ulong fq_nmod_mpoly_get_term_var_exp_ui(const fq_nmod_mpoly_t A, slong i, slong var, const fq_nmod_mpoly_ctx_t ctx) noexcept + slong fq_nmod_mpoly_get_term_var_exp_si(const fq_nmod_mpoly_t A, slong i, slong var, const fq_nmod_mpoly_ctx_t ctx) noexcept # Return the exponent of the variable *var* of the term of index *i*. # This function throws if the exponent does not fit into a ``ulong`` (resp. ``slong``). - void fq_nmod_mpoly_set_term_exp_fmpz(fq_nmod_mpoly_t A, slong i, fmpz * const * exp, const fq_nmod_mpoly_ctx_t ctx) - void fq_nmod_mpoly_set_term_exp_ui(fq_nmod_mpoly_t A, slong i, const ulong * exp, const fq_nmod_mpoly_ctx_t ctx) + void fq_nmod_mpoly_set_term_exp_fmpz(fq_nmod_mpoly_t A, slong i, fmpz * const * exp, const fq_nmod_mpoly_ctx_t ctx) noexcept + void fq_nmod_mpoly_set_term_exp_ui(fq_nmod_mpoly_t A, slong i, const ulong * exp, const fq_nmod_mpoly_ctx_t ctx) noexcept # Set the exponent of the term of index *i* to *exp*. - void fq_nmod_mpoly_get_term(fq_nmod_mpoly_t M, const fq_nmod_mpoly_t A, slong i, const fq_nmod_mpoly_ctx_t ctx) + void fq_nmod_mpoly_get_term(fq_nmod_mpoly_t M, const fq_nmod_mpoly_t A, slong i, const fq_nmod_mpoly_ctx_t ctx) noexcept # Set *M* to the term of index *i* in *A*. - void fq_nmod_mpoly_get_term_monomial(fq_nmod_mpoly_t M, const fq_nmod_mpoly_t A, slong i, const fq_nmod_mpoly_ctx_t ctx) + void fq_nmod_mpoly_get_term_monomial(fq_nmod_mpoly_t M, const fq_nmod_mpoly_t A, slong i, const fq_nmod_mpoly_ctx_t ctx) noexcept # Set *M* to the monomial of the term of index *i* in *A*. The coefficient of *M* will be one. - void fq_nmod_mpoly_push_term_fq_nmod_fmpz(fq_nmod_mpoly_t A, const fq_nmod_t c, fmpz * const * exp, const fq_nmod_mpoly_ctx_t ctx) - void fq_nmod_mpoly_push_term_fq_nmod_ffmpz(fq_nmod_mpoly_t A, const fq_nmod_t c, const fmpz * exp, const fq_nmod_mpoly_ctx_t ctx) - void fq_nmod_mpoly_push_term_fq_nmod_ui(fq_nmod_mpoly_t A, const fq_nmod_t c, const ulong * exp, const fq_nmod_mpoly_ctx_t ctx) + void fq_nmod_mpoly_push_term_fq_nmod_fmpz(fq_nmod_mpoly_t A, const fq_nmod_t c, fmpz * const * exp, const fq_nmod_mpoly_ctx_t ctx) noexcept + void fq_nmod_mpoly_push_term_fq_nmod_ffmpz(fq_nmod_mpoly_t A, const fq_nmod_t c, const fmpz * exp, const fq_nmod_mpoly_ctx_t ctx) noexcept + void fq_nmod_mpoly_push_term_fq_nmod_ui(fq_nmod_mpoly_t A, const fq_nmod_t c, const ulong * exp, const fq_nmod_mpoly_ctx_t ctx) noexcept # Append a term to *A* with coefficient *c* and exponent vector *exp*. # This function runs in constant average time. - void fq_nmod_mpoly_sort_terms(fq_nmod_mpoly_t A, const fq_nmod_mpoly_ctx_t ctx) + void fq_nmod_mpoly_sort_terms(fq_nmod_mpoly_t A, const fq_nmod_mpoly_ctx_t ctx) noexcept # Sort the terms of *A* into the canonical ordering dictated by the ordering in *ctx*. # This function simply reorders the terms: It does not combine like terms, nor does it delete terms with coefficient zero. # This function runs in linear time in the bit size of *A*. - void fq_nmod_mpoly_combine_like_terms(fq_nmod_mpoly_t A, const fq_nmod_mpoly_ctx_t ctx) + void fq_nmod_mpoly_combine_like_terms(fq_nmod_mpoly_t A, const fq_nmod_mpoly_ctx_t ctx) noexcept # Combine adjacent like terms in *A* and delete terms with coefficient zero. # If the terms of *A* were sorted to begin with, the result will be in canonical form. # This function runs in linear time in the bit size of *A*. - void fq_nmod_mpoly_reverse(fq_nmod_mpoly_t A, const fq_nmod_mpoly_t B, const fq_nmod_mpoly_ctx_t ctx) + void fq_nmod_mpoly_reverse(fq_nmod_mpoly_t A, const fq_nmod_mpoly_t B, const fq_nmod_mpoly_ctx_t ctx) noexcept # Set *A* to the reversal of *B*. - void fq_nmod_mpoly_randtest_bound(fq_nmod_mpoly_t A, flint_rand_t state, slong length, ulong exp_bound, const fq_nmod_mpoly_ctx_t ctx) + void fq_nmod_mpoly_randtest_bound(fq_nmod_mpoly_t A, flint_rand_t state, slong length, ulong exp_bound, const fq_nmod_mpoly_ctx_t ctx) noexcept # Generate a random polynomial with length up to *length* and exponents in the range ``[0, exp_bound - 1]``. # The exponents of each variable are generated by calls to ``n_randint(state, exp_bound)``. - void fq_nmod_mpoly_randtest_bounds(fq_nmod_mpoly_t A, flint_rand_t state, slong length, ulong *exp_bounds, const fq_nmod_mpoly_ctx_t ctx) + void fq_nmod_mpoly_randtest_bounds(fq_nmod_mpoly_t A, flint_rand_t state, slong length, ulong *exp_bounds, const fq_nmod_mpoly_ctx_t ctx) noexcept # Generate a random polynomial with length up to *length* and exponents in the range ``[0, exp_bounds[i] - 1]``. # The exponents of the variable of index *i* are generated by calls to ``n_randint(state, exp_bounds[i])``. - void fq_nmod_mpoly_randtest_bits(fq_nmod_mpoly_t A, flint_rand_t state, slong length, mp_limb_t exp_bits, const fq_nmod_mpoly_ctx_t ctx) + void fq_nmod_mpoly_randtest_bits(fq_nmod_mpoly_t A, flint_rand_t state, slong length, mp_limb_t exp_bits, const fq_nmod_mpoly_ctx_t ctx) noexcept # Generate a random polynomial with length up to *length* and exponents whose packed form does not exceed the given bit count. - void fq_nmod_mpoly_add_fq_nmod(fq_nmod_mpoly_t A, const fq_nmod_mpoly_t B, const fq_nmod_t C, const fq_nmod_mpoly_ctx_t ctx) + void fq_nmod_mpoly_add_fq_nmod(fq_nmod_mpoly_t A, const fq_nmod_mpoly_t B, const fq_nmod_t C, const fq_nmod_mpoly_ctx_t ctx) noexcept # Set *A* to `B + c`. - void fq_nmod_mpoly_sub_fq_nmod(fq_nmod_mpoly_t A, const fq_nmod_mpoly_t B, const fq_nmod_t C, const fq_nmod_mpoly_ctx_t ctx) + void fq_nmod_mpoly_sub_fq_nmod(fq_nmod_mpoly_t A, const fq_nmod_mpoly_t B, const fq_nmod_t C, const fq_nmod_mpoly_ctx_t ctx) noexcept # Set *A* to `B - c`. - void fq_nmod_mpoly_add(fq_nmod_mpoly_t A, const fq_nmod_mpoly_t B, const fq_nmod_mpoly_t C, const fq_nmod_mpoly_ctx_t ctx) + void fq_nmod_mpoly_add(fq_nmod_mpoly_t A, const fq_nmod_mpoly_t B, const fq_nmod_mpoly_t C, const fq_nmod_mpoly_ctx_t ctx) noexcept # Set *A* to `B + C`. - void fq_nmod_mpoly_sub(fq_nmod_mpoly_t A, const fq_nmod_mpoly_t B, const fq_nmod_mpoly_t C, const fq_nmod_mpoly_ctx_t ctx) + void fq_nmod_mpoly_sub(fq_nmod_mpoly_t A, const fq_nmod_mpoly_t B, const fq_nmod_mpoly_t C, const fq_nmod_mpoly_ctx_t ctx) noexcept # Set *A* to `B - C`. - void fq_nmod_mpoly_neg(fq_nmod_mpoly_t A, const fq_nmod_mpoly_t B, const fq_nmod_mpoly_ctx_t ctx) + void fq_nmod_mpoly_neg(fq_nmod_mpoly_t A, const fq_nmod_mpoly_t B, const fq_nmod_mpoly_ctx_t ctx) noexcept # Set *A* to `-B`. - void fq_nmod_mpoly_scalar_mul_fq_nmod(fq_nmod_mpoly_t A, const fq_nmod_mpoly_t B, const fq_nmod_t c, const fq_nmod_mpoly_ctx_t ctx) + void fq_nmod_mpoly_scalar_mul_fq_nmod(fq_nmod_mpoly_t A, const fq_nmod_mpoly_t B, const fq_nmod_t c, const fq_nmod_mpoly_ctx_t ctx) noexcept # Set *A* to `B \times c`. - void fq_nmod_mpoly_make_monic(fq_nmod_mpoly_t A, const fq_nmod_mpoly_t B, const fq_nmod_mpoly_ctx_t ctx) + void fq_nmod_mpoly_make_monic(fq_nmod_mpoly_t A, const fq_nmod_mpoly_t B, const fq_nmod_mpoly_ctx_t ctx) noexcept # Set *A* to *B* divided by the leading coefficient of *B*. # This throws if *B* is zero. - void fq_nmod_mpoly_derivative(fq_nmod_mpoly_t A, const fq_nmod_mpoly_t B, slong var, const fq_nmod_mpoly_ctx_t ctx) + void fq_nmod_mpoly_derivative(fq_nmod_mpoly_t A, const fq_nmod_mpoly_t B, slong var, const fq_nmod_mpoly_ctx_t ctx) noexcept # Set *A* to the derivative of *B* with respect to the variable of index *var*. - void fq_nmod_mpoly_evaluate_all_fq_nmod(fq_nmod_t ev, const fq_nmod_mpoly_t A, fq_nmod_struct * const * vals, const fq_nmod_mpoly_ctx_t ctx) + void fq_nmod_mpoly_evaluate_all_fq_nmod(fq_nmod_t ev, const fq_nmod_mpoly_t A, fq_nmod_struct * const * vals, const fq_nmod_mpoly_ctx_t ctx) noexcept # Set *ev* the evaluation of *A* where the variables are replaced by the corresponding elements of the array *vals*. - void fq_nmod_mpoly_evaluate_one_fq_nmod(fq_nmod_mpoly_t A, const fq_nmod_mpoly_t B, slong var, const fq_nmod_t val, const fq_nmod_mpoly_ctx_t ctx) + void fq_nmod_mpoly_evaluate_one_fq_nmod(fq_nmod_mpoly_t A, const fq_nmod_mpoly_t B, slong var, const fq_nmod_t val, const fq_nmod_mpoly_ctx_t ctx) noexcept # Set *A* to the evaluation of *B* where the variable of index *var* is replaced by *val*. - int fq_nmod_mpoly_compose_fq_nmod_poly(fq_nmod_poly_t A, const fq_nmod_mpoly_t B, fq_nmod_poly_struct * const * C, const fq_nmod_mpoly_ctx_t ctx) + int fq_nmod_mpoly_compose_fq_nmod_poly(fq_nmod_poly_t A, const fq_nmod_mpoly_t B, fq_nmod_poly_struct * const * C, const fq_nmod_mpoly_ctx_t ctx) noexcept # Set *A* to the evaluation of *B* where the variables are replaced by the corresponding elements of the array *C*. # The context object of *B* is *ctxB*. # Return `1` for success and `0` for failure. - int fq_nmod_mpoly_compose_fq_nmod_mpoly(fq_nmod_mpoly_t A, const fq_nmod_mpoly_t B, fq_nmod_mpoly_struct * const * C, const fq_nmod_mpoly_ctx_t ctxB, const fq_nmod_mpoly_ctx_t ctxAC) + int fq_nmod_mpoly_compose_fq_nmod_mpoly(fq_nmod_mpoly_t A, const fq_nmod_mpoly_t B, fq_nmod_mpoly_struct * const * C, const fq_nmod_mpoly_ctx_t ctxB, const fq_nmod_mpoly_ctx_t ctxAC) noexcept # Set *A* to the evaluation of *B* where the variables are replaced by the corresponding elements of the array *C*. # Both *A* and the elements of *C* have context object *ctxAC*, while *B* has context object *ctxB*. # Neither *A* nor *B* is allowed to alias any other polynomial. # Return `1` for success and `0` for failure. - void fq_nmod_mpoly_compose_fq_nmod_mpoly_gen(fq_nmod_mpoly_t A, const fq_nmod_mpoly_t B, const slong * c, const fq_nmod_mpoly_ctx_t ctxB, const fq_nmod_mpoly_ctx_t ctxAC) + void fq_nmod_mpoly_compose_fq_nmod_mpoly_gen(fq_nmod_mpoly_t A, const fq_nmod_mpoly_t B, const slong * c, const fq_nmod_mpoly_ctx_t ctxB, const fq_nmod_mpoly_ctx_t ctxAC) noexcept # Set *A* to the evaluation of *B* where the variable of index *i* in *ctxB* is replaced by the variable of index ``c[i]`` in *ctxAC*. # The length of the array *C* is the number of variables in *ctxB*. # If any ``c[i]`` is negative, the corresponding variable of *B* is replaced by zero. Otherwise, it is expected that ``c[i]`` is less than the number of variables in *ctxAC*. - void fq_nmod_mpoly_mul(fq_nmod_mpoly_t A, const fq_nmod_mpoly_t B, const fq_nmod_mpoly_t C, const fq_nmod_mpoly_ctx_t ctx) + void fq_nmod_mpoly_mul(fq_nmod_mpoly_t A, const fq_nmod_mpoly_t B, const fq_nmod_mpoly_t C, const fq_nmod_mpoly_ctx_t ctx) noexcept # Set *A* to *B* times *C*. - int fq_nmod_mpoly_pow_fmpz(fq_nmod_mpoly_t A, const fq_nmod_mpoly_t B, const fmpz_t k, const fq_nmod_mpoly_ctx_t ctx) + int fq_nmod_mpoly_pow_fmpz(fq_nmod_mpoly_t A, const fq_nmod_mpoly_t B, const fmpz_t k, const fq_nmod_mpoly_ctx_t ctx) noexcept # Set *A* to `B` raised to the *k*-th power. # Return `1` for success and `0` for failure. - int fq_nmod_mpoly_pow_ui(fq_nmod_mpoly_t A, const fq_nmod_mpoly_t B, ulong k, const fq_nmod_mpoly_ctx_t ctx) + int fq_nmod_mpoly_pow_ui(fq_nmod_mpoly_t A, const fq_nmod_mpoly_t B, ulong k, const fq_nmod_mpoly_ctx_t ctx) noexcept # Set *A* to `B` raised to the *k*-th power. # Return `1` for success and `0` for failure. - int fq_nmod_mpoly_divides(fq_nmod_mpoly_t Q, const fq_nmod_mpoly_t A, const fq_nmod_mpoly_t B, const fq_nmod_mpoly_ctx_t ctx) + int fq_nmod_mpoly_divides(fq_nmod_mpoly_t Q, const fq_nmod_mpoly_t A, const fq_nmod_mpoly_t B, const fq_nmod_mpoly_ctx_t ctx) noexcept # If *A* is divisible by *B*, set *Q* to the exact quotient and return `1`. Otherwise, set *Q* to zero and return `0`. - void fq_nmod_mpoly_div(fq_nmod_mpoly_t Q, const fq_nmod_mpoly_t A, const fq_nmod_mpoly_t B, const fq_nmod_mpoly_ctx_t ctx) + void fq_nmod_mpoly_div(fq_nmod_mpoly_t Q, const fq_nmod_mpoly_t A, const fq_nmod_mpoly_t B, const fq_nmod_mpoly_ctx_t ctx) noexcept # Set *Q* to the quotient of *A* by *B*, discarding the remainder. - void fq_nmod_mpoly_divrem(fq_nmod_mpoly_t Q, fq_nmod_mpoly_t R, const fq_nmod_mpoly_t A, const fq_nmod_mpoly_t B, const fq_nmod_mpoly_ctx_t ctx) + void fq_nmod_mpoly_divrem(fq_nmod_mpoly_t Q, fq_nmod_mpoly_t R, const fq_nmod_mpoly_t A, const fq_nmod_mpoly_t B, const fq_nmod_mpoly_ctx_t ctx) noexcept # Set *Q* and *R* to the quotient and remainder of *A* divided by *B*. - void fq_nmod_mpoly_divrem_ideal(fq_nmod_mpoly_struct ** Q, fq_nmod_mpoly_t R, const fq_nmod_mpoly_t A, fq_nmod_mpoly_struct * const * B, slong len, const fq_nmod_mpoly_ctx_t ctx) + void fq_nmod_mpoly_divrem_ideal(fq_nmod_mpoly_struct ** Q, fq_nmod_mpoly_t R, const fq_nmod_mpoly_t A, fq_nmod_mpoly_struct * const * B, slong len, const fq_nmod_mpoly_ctx_t ctx) noexcept # This function is as per :func:`fq_nmod_mpoly_divrem` except that it takes an array of divisor polynomials *B* and it returns an array of quotient polynomials *Q*. # The number of divisor (and hence quotient) polynomials, is given by *len*. - void fq_nmod_mpoly_term_content(fq_nmod_mpoly_t M, const fq_nmod_mpoly_t A, const fq_nmod_mpoly_ctx_t ctx) + void fq_nmod_mpoly_term_content(fq_nmod_mpoly_t M, const fq_nmod_mpoly_t A, const fq_nmod_mpoly_ctx_t ctx) noexcept # Set *M* to the GCD of the terms of *A*. # If *A* is zero, *M* will be zero. Otherwise, *M* will be a monomial with coefficient one. - int fq_nmod_mpoly_content_vars(fq_nmod_mpoly_t g, const fq_nmod_mpoly_t A, slong * vars, slong vars_length, const fq_nmod_mpoly_ctx_t ctx) + int fq_nmod_mpoly_content_vars(fq_nmod_mpoly_t g, const fq_nmod_mpoly_t A, slong * vars, slong vars_length, const fq_nmod_mpoly_ctx_t ctx) noexcept # Set *g* to the GCD of the coefficients of *A* when viewed as a polynomial in the variables *vars*. # Return `1` for success and `0` for failure. Upon success, *g* will be independent of the variables *vars*. - int fq_nmod_mpoly_gcd(fq_nmod_mpoly_t G, const fq_nmod_mpoly_t A, const fq_nmod_mpoly_t B, const fq_nmod_mpoly_ctx_t ctx) + int fq_nmod_mpoly_gcd(fq_nmod_mpoly_t G, const fq_nmod_mpoly_t A, const fq_nmod_mpoly_t B, const fq_nmod_mpoly_ctx_t ctx) noexcept # Try to set *G* to the monic GCD of *A* and *B*. The GCD of zero and zero is defined to be zero. # If the return is `1` the function was successful. Otherwise the return is `0` and *G* is left untouched. - int fq_nmod_mpoly_gcd_cofactors(fq_nmod_mpoly_t G, fq_nmod_mpoly_t Abar, fq_nmod_mpoly_t Bbar, const fq_nmod_mpoly_t A, const fq_nmod_mpoly_t B, const fq_nmod_mpoly_ctx_t ctx) + int fq_nmod_mpoly_gcd_cofactors(fq_nmod_mpoly_t G, fq_nmod_mpoly_t Abar, fq_nmod_mpoly_t Bbar, const fq_nmod_mpoly_t A, const fq_nmod_mpoly_t B, const fq_nmod_mpoly_ctx_t ctx) noexcept # Do the operation of :func:`fq_nmod_mpoly_gcd` and also compute `Abar = A/G` and `Bbar = B/G` if successful. - int fq_nmod_mpoly_gcd_brown(fq_nmod_mpoly_t G, const fq_nmod_mpoly_t A, const fq_nmod_mpoly_t B, const fq_nmod_mpoly_ctx_t ctx) - int fq_nmod_mpoly_gcd_hensel(fq_nmod_mpoly_t G, const fq_nmod_mpoly_t A, const fq_nmod_mpoly_t B, const fq_nmod_mpoly_ctx_t ctx) - int fq_nmod_mpoly_gcd_zippel(fq_nmod_mpoly_t G, const fq_nmod_mpoly_t A, const fq_nmod_mpoly_t B, const fq_nmod_mpoly_ctx_t ctx) + int fq_nmod_mpoly_gcd_brown(fq_nmod_mpoly_t G, const fq_nmod_mpoly_t A, const fq_nmod_mpoly_t B, const fq_nmod_mpoly_ctx_t ctx) noexcept + int fq_nmod_mpoly_gcd_hensel(fq_nmod_mpoly_t G, const fq_nmod_mpoly_t A, const fq_nmod_mpoly_t B, const fq_nmod_mpoly_ctx_t ctx) noexcept + int fq_nmod_mpoly_gcd_zippel(fq_nmod_mpoly_t G, const fq_nmod_mpoly_t A, const fq_nmod_mpoly_t B, const fq_nmod_mpoly_ctx_t ctx) noexcept # Try to set *G* to the GCD of *A* and *B* using various algorithms. - int fq_nmod_mpoly_resultant(fq_nmod_mpoly_t R, const fq_nmod_mpoly_t A, const fq_nmod_mpoly_t B, slong var, const fq_nmod_mpoly_ctx_t ctx) + int fq_nmod_mpoly_resultant(fq_nmod_mpoly_t R, const fq_nmod_mpoly_t A, const fq_nmod_mpoly_t B, slong var, const fq_nmod_mpoly_ctx_t ctx) noexcept # Try to set *R* to the resultant of *A* and *B* with respect to the variable of index *var*. - int fq_nmod_mpoly_discriminant(fq_nmod_mpoly_t D, const fq_nmod_mpoly_t A, slong var, const fq_nmod_mpoly_ctx_t ctx) + int fq_nmod_mpoly_discriminant(fq_nmod_mpoly_t D, const fq_nmod_mpoly_t A, slong var, const fq_nmod_mpoly_ctx_t ctx) noexcept # Try to set *D* to the discriminant of *A* with respect to the variable of index *var*. - int fq_nmod_mpoly_sqrt(fq_nmod_mpoly_t Q, const fq_nmod_mpoly_t A, const fq_nmod_mpoly_ctx_t ctx) + int fq_nmod_mpoly_sqrt(fq_nmod_mpoly_t Q, const fq_nmod_mpoly_t A, const fq_nmod_mpoly_ctx_t ctx) noexcept # If `Q^2=A` has a solution, set `Q` to a solution and return `1`, otherwise return `0` and set `Q` to zero. - bint fq_nmod_mpoly_is_square(const fq_nmod_mpoly_t A, const fq_nmod_mpoly_ctx_t ctx) + bint fq_nmod_mpoly_is_square(const fq_nmod_mpoly_t A, const fq_nmod_mpoly_ctx_t ctx) noexcept # Return `1` if *A* is a perfect square, otherwise return `0`. - int fq_nmod_mpoly_quadratic_root(fq_nmod_mpoly_t Q, const fq_nmod_mpoly_t A, const fq_nmod_mpoly_t B, const fq_nmod_mpoly_ctx_t ctx) + int fq_nmod_mpoly_quadratic_root(fq_nmod_mpoly_t Q, const fq_nmod_mpoly_t A, const fq_nmod_mpoly_t B, const fq_nmod_mpoly_ctx_t ctx) noexcept # If `Q^2+AQ=B` has a solution, set `Q` to a solution and return `1`, otherwise return `0`. - void fq_nmod_mpoly_univar_init(fq_nmod_mpoly_univar_t A, const fq_nmod_mpoly_ctx_t ctx) + void fq_nmod_mpoly_univar_init(fq_nmod_mpoly_univar_t A, const fq_nmod_mpoly_ctx_t ctx) noexcept # Initialize *A*. - void fq_nmod_mpoly_univar_clear(fq_nmod_mpoly_univar_t A, const fq_nmod_mpoly_ctx_t ctx) + void fq_nmod_mpoly_univar_clear(fq_nmod_mpoly_univar_t A, const fq_nmod_mpoly_ctx_t ctx) noexcept # Clear *A*. - void fq_nmod_mpoly_univar_swap(fq_nmod_mpoly_univar_t A, fq_nmod_mpoly_univar_t B, const fq_nmod_mpoly_ctx_t ctx) + void fq_nmod_mpoly_univar_swap(fq_nmod_mpoly_univar_t A, fq_nmod_mpoly_univar_t B, const fq_nmod_mpoly_ctx_t ctx) noexcept # Swap *A* and `B`. - void fq_nmod_mpoly_to_univar(fq_nmod_mpoly_univar_t A, const fq_nmod_mpoly_t B, slong var, const fq_nmod_mpoly_ctx_t ctx) + void fq_nmod_mpoly_to_univar(fq_nmod_mpoly_univar_t A, const fq_nmod_mpoly_t B, slong var, const fq_nmod_mpoly_ctx_t ctx) noexcept # Set *A* to a univariate form of *B* by pulling out the variable of index *var*. # The coefficients of *A* will still belong to the content *ctx* but will not depend on the variable of index *var*. - void fq_nmod_mpoly_from_univar(fq_nmod_mpoly_t A, const fq_nmod_mpoly_univar_t B, slong var, const fq_nmod_mpoly_ctx_t ctx) + void fq_nmod_mpoly_from_univar(fq_nmod_mpoly_t A, const fq_nmod_mpoly_univar_t B, slong var, const fq_nmod_mpoly_ctx_t ctx) noexcept # Set *A* to the normal form of *B* by putting in the variable of index *var*. # This function is undefined if the coefficients of *B* depend on the variable of index *var*. - int fq_nmod_mpoly_univar_degree_fits_si(const fq_nmod_mpoly_univar_t A, const fq_nmod_mpoly_ctx_t ctx) + int fq_nmod_mpoly_univar_degree_fits_si(const fq_nmod_mpoly_univar_t A, const fq_nmod_mpoly_ctx_t ctx) noexcept # Return `1` if the degree of *A* with respect to the main variable fits an ``slong``. Otherwise, return `0`. - slong fq_nmod_mpoly_univar_length(const fq_nmod_mpoly_univar_t A, const fq_nmod_mpoly_ctx_t ctx) + slong fq_nmod_mpoly_univar_length(const fq_nmod_mpoly_univar_t A, const fq_nmod_mpoly_ctx_t ctx) noexcept # Return the number of terms in *A* with respect to the main variable. - slong fq_nmod_mpoly_univar_get_term_exp_si(fq_nmod_mpoly_univar_t A, slong i, const fq_nmod_mpoly_ctx_t ctx) + slong fq_nmod_mpoly_univar_get_term_exp_si(fq_nmod_mpoly_univar_t A, slong i, const fq_nmod_mpoly_ctx_t ctx) noexcept # Return the exponent of the term of index *i* of *A*. - void fq_nmod_mpoly_univar_get_term_coeff(fq_nmod_mpoly_t c, const fq_nmod_mpoly_univar_t A, slong i, const fq_nmod_mpoly_ctx_t ctx) - void fq_nmod_mpoly_univar_swap_term_coeff(fq_nmod_mpoly_t c, fq_nmod_mpoly_univar_t A, slong i, const fq_nmod_mpoly_ctx_t ctx) + void fq_nmod_mpoly_univar_get_term_coeff(fq_nmod_mpoly_t c, const fq_nmod_mpoly_univar_t A, slong i, const fq_nmod_mpoly_ctx_t ctx) noexcept + void fq_nmod_mpoly_univar_swap_term_coeff(fq_nmod_mpoly_t c, fq_nmod_mpoly_univar_t A, slong i, const fq_nmod_mpoly_ctx_t ctx) noexcept # Set (resp. swap) *c* to (resp. with) the coefficient of the term of index *i* of *A*. diff --git a/src/sage/libs/flint/fq_nmod_mpoly_factor.pxd b/src/sage/libs/flint/fq_nmod_mpoly_factor.pxd index f6564bc10ed..624350934d2 100644 --- a/src/sage/libs/flint/fq_nmod_mpoly_factor.pxd +++ b/src/sage/libs/flint/fq_nmod_mpoly_factor.pxd @@ -12,36 +12,36 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void fq_nmod_mpoly_factor_init(fq_nmod_mpoly_factor_t f, const fq_nmod_mpoly_ctx_t ctx) + void fq_nmod_mpoly_factor_init(fq_nmod_mpoly_factor_t f, const fq_nmod_mpoly_ctx_t ctx) noexcept # Initialise *f*. - void fq_nmod_mpoly_factor_clear(fq_nmod_mpoly_factor_t f, const fq_nmod_mpoly_ctx_t ctx) + void fq_nmod_mpoly_factor_clear(fq_nmod_mpoly_factor_t f, const fq_nmod_mpoly_ctx_t ctx) noexcept # Clear *f*. - void fq_nmod_mpoly_factor_swap(fq_nmod_mpoly_factor_t f, fq_nmod_mpoly_factor_t g, const fq_nmod_mpoly_ctx_t ctx) + void fq_nmod_mpoly_factor_swap(fq_nmod_mpoly_factor_t f, fq_nmod_mpoly_factor_t g, const fq_nmod_mpoly_ctx_t ctx) noexcept # Efficiently swap *f* and *g*. - slong fq_nmod_mpoly_factor_length(const fq_nmod_mpoly_factor_t f, const fq_nmod_mpoly_ctx_t ctx) + slong fq_nmod_mpoly_factor_length(const fq_nmod_mpoly_factor_t f, const fq_nmod_mpoly_ctx_t ctx) noexcept # Return the length of the product in *f*. - void fq_nmod_mpoly_factor_get_constant_fq_nmod(fq_nmod_t c, const fq_nmod_mpoly_factor_t f, const fq_nmod_mpoly_ctx_t ctx) + void fq_nmod_mpoly_factor_get_constant_fq_nmod(fq_nmod_t c, const fq_nmod_mpoly_factor_t f, const fq_nmod_mpoly_ctx_t ctx) noexcept # Set `c` to the constant of *f*. - void fq_nmod_mpoly_factor_get_base(fq_nmod_mpoly_t p, const fq_nmod_mpoly_factor_t f, slong i, const fq_nmod_mpoly_ctx_t ctx) - void fq_nmod_mpoly_factor_swap_base(fq_nmod_mpoly_t p, const fq_nmod_mpoly_factor_t f, slong i, const fq_nmod_mpoly_ctx_t ctx) + void fq_nmod_mpoly_factor_get_base(fq_nmod_mpoly_t p, const fq_nmod_mpoly_factor_t f, slong i, const fq_nmod_mpoly_ctx_t ctx) noexcept + void fq_nmod_mpoly_factor_swap_base(fq_nmod_mpoly_t p, const fq_nmod_mpoly_factor_t f, slong i, const fq_nmod_mpoly_ctx_t ctx) noexcept # Set (resp. swap) *B* to (resp. with) the base of the term of index *i* in *A*. - slong fq_nmod_mpoly_factor_get_exp_si(fq_nmod_mpoly_factor_t f, slong i, const fq_nmod_mpoly_ctx_t ctx) + slong fq_nmod_mpoly_factor_get_exp_si(fq_nmod_mpoly_factor_t f, slong i, const fq_nmod_mpoly_ctx_t ctx) noexcept # Return the exponent of the term of index *i* in *A*. It is assumed to fit an ``slong``. - void fq_nmod_mpoly_factor_sort(fq_nmod_mpoly_factor_t f, const fq_nmod_mpoly_ctx_t ctx) + void fq_nmod_mpoly_factor_sort(fq_nmod_mpoly_factor_t f, const fq_nmod_mpoly_ctx_t ctx) noexcept # Sort the product of *f* first by exponent and then by base. - int fq_nmod_mpoly_factor_squarefree(fq_nmod_mpoly_factor_t f, const fq_nmod_mpoly_t A, const fq_nmod_mpoly_ctx_t ctx) + int fq_nmod_mpoly_factor_squarefree(fq_nmod_mpoly_factor_t f, const fq_nmod_mpoly_t A, const fq_nmod_mpoly_ctx_t ctx) noexcept # Set *f* to a factorization of *A* where the bases are primitive and # pairwise relatively prime. If the product of all irreducible factors with # a given exponent is desired, it is recommended to call :func:`fq_nmod_mpoly_factor_sort` # and then multiply the bases with the desired exponent. - int fq_nmod_mpoly_factor(fq_nmod_mpoly_factor_t f, const fq_nmod_mpoly_t A, const fq_nmod_mpoly_ctx_t ctx) + int fq_nmod_mpoly_factor(fq_nmod_mpoly_factor_t f, const fq_nmod_mpoly_t A, const fq_nmod_mpoly_ctx_t ctx) noexcept # Set *f* to a factorization of *A* where the bases are irreducible. diff --git a/src/sage/libs/flint/fq_nmod_poly.pxd b/src/sage/libs/flint/fq_nmod_poly.pxd index 8f079a6f324..995dcbed9a2 100644 --- a/src/sage/libs/flint/fq_nmod_poly.pxd +++ b/src/sage/libs/flint/fq_nmod_poly.pxd @@ -12,27 +12,27 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void fq_nmod_poly_init(fq_nmod_poly_t poly, const fq_nmod_ctx_t ctx) + void fq_nmod_poly_init(fq_nmod_poly_t poly, const fq_nmod_ctx_t ctx) noexcept # Initialises ``poly`` for use, with context ctx, and setting its # length to zero. A corresponding call to :func:`fq_nmod_poly_clear` # must be made after finishing with the ``fq_nmod_poly_t`` to free the # memory used by the polynomial. - void fq_nmod_poly_init2(fq_nmod_poly_t poly, slong alloc, const fq_nmod_ctx_t ctx) + void fq_nmod_poly_init2(fq_nmod_poly_t poly, slong alloc, const fq_nmod_ctx_t ctx) noexcept # Initialises ``poly`` with space for at least ``alloc`` # coefficients and sets the length to zero. The allocated # coefficients are all set to zero. A corresponding call to # :func:`fq_nmod_poly_clear` must be made after finishing with the # ``fq_nmod_poly_t`` to free the memory used by the polynomial. - void fq_nmod_poly_realloc(fq_nmod_poly_t poly, slong alloc, const fq_nmod_ctx_t ctx) + void fq_nmod_poly_realloc(fq_nmod_poly_t poly, slong alloc, const fq_nmod_ctx_t ctx) noexcept # Reallocates the given polynomial to have space for ``alloc`` # coefficients. If ``alloc`` is zero the polynomial is cleared # and then reinitialised. If the current length is greater than # ``alloc`` the polynomial is first truncated to length # ``alloc``. - void fq_nmod_poly_fit_length(fq_nmod_poly_t poly, slong len, const fq_nmod_ctx_t ctx) + void fq_nmod_poly_fit_length(fq_nmod_poly_t poly, slong len, const fq_nmod_ctx_t ctx) noexcept # If ``len`` is greater than the number of coefficients currently # allocated, then the polynomial is reallocated to have space for at # least ``len`` coefficients. No data is lost when calling this @@ -42,33 +42,33 @@ cdef extern from "flint_wrap.h": # least doubling the number of allocated coefficients when length is # larger than the number of coefficients currently allocated. - void _fq_nmod_poly_set_length(fq_nmod_poly_t poly, slong newlen, const fq_nmod_ctx_t ctx) + void _fq_nmod_poly_set_length(fq_nmod_poly_t poly, slong newlen, const fq_nmod_ctx_t ctx) noexcept # Sets the coefficients of ``poly`` beyond ``len`` to zero and # sets the length of ``poly`` to ``len``. - void fq_nmod_poly_clear(fq_nmod_poly_t poly, const fq_nmod_ctx_t ctx) + void fq_nmod_poly_clear(fq_nmod_poly_t poly, const fq_nmod_ctx_t ctx) noexcept # Clears the given polynomial, releasing any memory used. It must # be reinitialised in order to be used again. - void _fq_nmod_poly_normalise(fq_nmod_poly_t poly, const fq_nmod_ctx_t ctx) + void _fq_nmod_poly_normalise(fq_nmod_poly_t poly, const fq_nmod_ctx_t ctx) noexcept # Sets the length of ``poly`` so that the top coefficient is # non-zero. If all coefficients are zero, the length is set to # zero. This function is mainly used internally, as all functions # guarantee normalisation. - void _fq_nmod_poly_normalise2(const fq_nmod_struct *poly, slong *length, const fq_nmod_ctx_t ctx) + void _fq_nmod_poly_normalise2(const fq_nmod_struct *poly, slong *length, const fq_nmod_ctx_t ctx) noexcept # Sets the length ``length`` of ``(poly,length)`` so that the # top coefficient is non-zero. If all coefficients are zero, the # length is set to zero. This function is mainly used internally, as # all functions guarantee normalisation. - void fq_nmod_poly_truncate(fq_nmod_poly_t poly, slong newlen, const fq_nmod_ctx_t ctx) + void fq_nmod_poly_truncate(fq_nmod_poly_t poly, slong newlen, const fq_nmod_ctx_t ctx) noexcept # Truncates the polynomial to length at most ``n``. - void fq_nmod_poly_set_trunc(fq_nmod_poly_t poly1, fq_nmod_poly_t poly2, slong newlen, const fq_nmod_ctx_t ctx) + void fq_nmod_poly_set_trunc(fq_nmod_poly_t poly1, fq_nmod_poly_t poly2, slong newlen, const fq_nmod_ctx_t ctx) noexcept # Sets ``poly1`` to ``poly2`` truncated to length `n`. - void _fq_nmod_poly_reverse(fq_nmod_struct* output, const fq_nmod_struct* input, slong len, slong m, const fq_nmod_ctx_t ctx) + void _fq_nmod_poly_reverse(fq_nmod_struct* output, const fq_nmod_struct* input, slong len, slong m, const fq_nmod_ctx_t ctx) noexcept # Sets ``output`` to the reverse of ``input``, which is of # length ``len``, but thinking of it as a polynomial of # length ``m``, notionally zero-padded if necessary. The @@ -76,199 +76,199 @@ cdef extern from "flint_wrap.h": # restrictions. The polynomial ``output`` must have space for # ``m`` coefficients. - void fq_nmod_poly_reverse(fq_nmod_poly_t output, const fq_nmod_poly_t input, slong m, const fq_nmod_ctx_t ctx) + void fq_nmod_poly_reverse(fq_nmod_poly_t output, const fq_nmod_poly_t input, slong m, const fq_nmod_ctx_t ctx) noexcept # Sets ``output`` to the reverse of ``input``, thinking of it # as a polynomial of length ``m``, notionally zero-padded if # necessary). The length ``m`` must be non-negative, but there # are no other restrictions. The output polynomial will be set to # length ``m`` and then normalised. - slong fq_nmod_poly_degree(const fq_nmod_poly_t poly, const fq_nmod_ctx_t ctx) + slong fq_nmod_poly_degree(const fq_nmod_poly_t poly, const fq_nmod_ctx_t ctx) noexcept # Returns the degree of the polynomial ``poly``. - slong fq_nmod_poly_length(const fq_nmod_poly_t poly, const fq_nmod_ctx_t ctx) + slong fq_nmod_poly_length(const fq_nmod_poly_t poly, const fq_nmod_ctx_t ctx) noexcept # Returns the length of the polynomial ``poly``. - fq_nmod_struct * fq_nmod_poly_lead(const fq_nmod_poly_t poly, const fq_nmod_ctx_t ctx) + fq_nmod_struct * fq_nmod_poly_lead(const fq_nmod_poly_t poly, const fq_nmod_ctx_t ctx) noexcept # Returns a pointer to the leading coefficient of ``poly``, or # ``NULL`` if ``poly`` is the zero polynomial. - void fq_nmod_poly_randtest(fq_nmod_poly_t f, flint_rand_t state, slong len, const fq_nmod_ctx_t ctx) + void fq_nmod_poly_randtest(fq_nmod_poly_t f, flint_rand_t state, slong len, const fq_nmod_ctx_t ctx) noexcept # Sets `f` to a random polynomial of length at most ``len`` # with entries in the field described by ``ctx``. - void fq_nmod_poly_randtest_not_zero(fq_nmod_poly_t f, flint_rand_t state, slong len, const fq_nmod_ctx_t ctx) + void fq_nmod_poly_randtest_not_zero(fq_nmod_poly_t f, flint_rand_t state, slong len, const fq_nmod_ctx_t ctx) noexcept # Same as ``fq_nmod_poly_randtest`` but guarantees that the polynomial # is not zero. - void fq_nmod_poly_randtest_monic(fq_nmod_poly_t f, flint_rand_t state, slong len, const fq_nmod_ctx_t ctx) + void fq_nmod_poly_randtest_monic(fq_nmod_poly_t f, flint_rand_t state, slong len, const fq_nmod_ctx_t ctx) noexcept # Sets `f` to a random monic polynomial of length ``len`` with # entries in the field described by ``ctx``. - void fq_nmod_poly_randtest_irreducible(fq_nmod_poly_t f, flint_rand_t state, slong len, const fq_nmod_ctx_t ctx) + void fq_nmod_poly_randtest_irreducible(fq_nmod_poly_t f, flint_rand_t state, slong len, const fq_nmod_ctx_t ctx) noexcept # Sets `f` to a random monic, irreducible polynomial of length # ``len`` with entries in the field described by ``ctx``. - void _fq_nmod_poly_set(fq_nmod_struct *rop, const fq_nmod_struct *op, slong len, const fq_nmod_ctx_t ctx) + void _fq_nmod_poly_set(fq_nmod_struct *rop, const fq_nmod_struct *op, slong len, const fq_nmod_ctx_t ctx) noexcept # Sets ``(rop, len``) to ``(op, len)``. - void fq_nmod_poly_set(fq_nmod_poly_t poly1, const fq_nmod_poly_t poly2, const fq_nmod_ctx_t ctx) + void fq_nmod_poly_set(fq_nmod_poly_t poly1, const fq_nmod_poly_t poly2, const fq_nmod_ctx_t ctx) noexcept # Sets the polynomial ``poly1`` to the polynomial ``poly2``. - void fq_nmod_poly_set_fq_nmod(fq_nmod_poly_t poly, const fq_nmod_t c, const fq_nmod_ctx_t ctx) + void fq_nmod_poly_set_fq_nmod(fq_nmod_poly_t poly, const fq_nmod_t c, const fq_nmod_ctx_t ctx) noexcept # Sets the polynomial ``poly`` to ``c``. - void fq_nmod_poly_set_fmpz_mod_poly(fq_nmod_poly_t rop, const fmpz_mod_poly_t op, const fq_nmod_ctx_t ctx) + void fq_nmod_poly_set_fmpz_mod_poly(fq_nmod_poly_t rop, const fmpz_mod_poly_t op, const fq_nmod_ctx_t ctx) noexcept # Sets the polynomial ``rop`` to the polynomial ``op`` - void fq_nmod_poly_set_nmod_poly(fq_nmod_poly_t rop, const nmod_poly_t op, const fq_nmod_ctx_t ctx) + void fq_nmod_poly_set_nmod_poly(fq_nmod_poly_t rop, const nmod_poly_t op, const fq_nmod_ctx_t ctx) noexcept # Sets the polynomial ``rop`` to the polynomial ``op`` - void fq_nmod_poly_swap(fq_nmod_poly_t op1, fq_nmod_poly_t op2, const fq_nmod_ctx_t ctx) + void fq_nmod_poly_swap(fq_nmod_poly_t op1, fq_nmod_poly_t op2, const fq_nmod_ctx_t ctx) noexcept # Swaps the two polynomials ``op1`` and ``op2``. - void _fq_nmod_poly_zero(fq_nmod_struct *rop, slong len, const fq_nmod_ctx_t ctx) + void _fq_nmod_poly_zero(fq_nmod_struct *rop, slong len, const fq_nmod_ctx_t ctx) noexcept # Sets ``(rop, len)`` to the zero polynomial. - void fq_nmod_poly_zero(fq_nmod_poly_t poly, const fq_nmod_ctx_t ctx) + void fq_nmod_poly_zero(fq_nmod_poly_t poly, const fq_nmod_ctx_t ctx) noexcept # Sets ``poly`` to the zero polynomial. - void fq_nmod_poly_one(fq_nmod_poly_t poly, const fq_nmod_ctx_t ctx) + void fq_nmod_poly_one(fq_nmod_poly_t poly, const fq_nmod_ctx_t ctx) noexcept # Sets ``poly`` to the constant polynomial `1`. - void fq_nmod_poly_gen(fq_nmod_poly_t poly, const fq_nmod_ctx_t ctx) + void fq_nmod_poly_gen(fq_nmod_poly_t poly, const fq_nmod_ctx_t ctx) noexcept # Sets ``poly`` to the polynomial `x`. - void fq_nmod_poly_make_monic(fq_nmod_poly_t rop, const fq_nmod_poly_t op, const fq_nmod_ctx_t ctx) + void fq_nmod_poly_make_monic(fq_nmod_poly_t rop, const fq_nmod_poly_t op, const fq_nmod_ctx_t ctx) noexcept # Sets ``rop`` to ``op``, normed to have leading coefficient 1. - void _fq_nmod_poly_make_monic(fq_nmod_struct *rop, const fq_nmod_struct *op, slong length, const fq_nmod_ctx_t ctx) + void _fq_nmod_poly_make_monic(fq_nmod_struct *rop, const fq_nmod_struct *op, slong length, const fq_nmod_ctx_t ctx) noexcept # Sets ``rop`` to ``(op,length)``, normed to have leading coefficient 1. # Assumes that ``rop`` has enough space for the polynomial, assumes that # ``op`` is not zero (and thus has an invertible leading coefficient). - void fq_nmod_poly_get_coeff(fq_nmod_t x, const fq_nmod_poly_t poly, slong n, const fq_nmod_ctx_t ctx) + void fq_nmod_poly_get_coeff(fq_nmod_t x, const fq_nmod_poly_t poly, slong n, const fq_nmod_ctx_t ctx) noexcept # Sets `x` to the coefficient of `X^n` in ``poly``. - void fq_nmod_poly_set_coeff(fq_nmod_poly_t poly, slong n, const fq_nmod_t x, const fq_nmod_ctx_t ctx) + void fq_nmod_poly_set_coeff(fq_nmod_poly_t poly, slong n, const fq_nmod_t x, const fq_nmod_ctx_t ctx) noexcept # Sets the coefficient of `X^n` in ``poly`` to `x`. - void fq_nmod_poly_set_coeff_fmpz(fq_nmod_poly_t poly, slong n, const fmpz_t x, const fq_nmod_ctx_t ctx) + void fq_nmod_poly_set_coeff_fmpz(fq_nmod_poly_t poly, slong n, const fmpz_t x, const fq_nmod_ctx_t ctx) noexcept # Sets the coefficient of `X^n` in the polynomial to `x`, # assuming `n \geq 0`. - bint fq_nmod_poly_equal(const fq_nmod_poly_t poly1, const fq_nmod_poly_t poly2, const fq_nmod_ctx_t ctx) + bint fq_nmod_poly_equal(const fq_nmod_poly_t poly1, const fq_nmod_poly_t poly2, const fq_nmod_ctx_t ctx) noexcept # Returns nonzero if the two polynomials ``poly1`` and ``poly2`` # are equal, otherwise return zero. - bint fq_nmod_poly_equal_trunc(const fq_nmod_poly_t poly1, const fq_nmod_poly_t poly2, slong n, const fq_nmod_ctx_t ctx) + bint fq_nmod_poly_equal_trunc(const fq_nmod_poly_t poly1, const fq_nmod_poly_t poly2, slong n, const fq_nmod_ctx_t ctx) noexcept # Notionally truncate ``poly1`` and ``poly2`` to length `n` and # return nonzero if they are equal, otherwise return zero. - bint fq_nmod_poly_is_zero(const fq_nmod_poly_t poly, const fq_nmod_ctx_t ctx) + bint fq_nmod_poly_is_zero(const fq_nmod_poly_t poly, const fq_nmod_ctx_t ctx) noexcept # Returns whether the polynomial ``poly`` is the zero polynomial. - bint fq_nmod_poly_is_one(const fq_nmod_poly_t op, const fq_nmod_ctx_t ctx) + bint fq_nmod_poly_is_one(const fq_nmod_poly_t op, const fq_nmod_ctx_t ctx) noexcept # Returns whether the polynomial ``poly`` is equal # to the constant polynomial `1`. - bint fq_nmod_poly_is_gen(const fq_nmod_poly_t op, const fq_nmod_ctx_t ctx) + bint fq_nmod_poly_is_gen(const fq_nmod_poly_t op, const fq_nmod_ctx_t ctx) noexcept # Returns whether the polynomial ``poly`` is equal # to the polynomial `x`. - bint fq_nmod_poly_is_unit(const fq_nmod_poly_t op, const fq_nmod_ctx_t ctx) + bint fq_nmod_poly_is_unit(const fq_nmod_poly_t op, const fq_nmod_ctx_t ctx) noexcept # Returns whether the polynomial ``poly`` is a unit in the polynomial # ring `\mathbf{F}_q[X]`, i.e. if it has degree `0` and is non-zero. - bint fq_nmod_poly_equal_fq_nmod(const fq_nmod_poly_t poly, const fq_nmod_t c, const fq_nmod_ctx_t ctx) + bint fq_nmod_poly_equal_fq_nmod(const fq_nmod_poly_t poly, const fq_nmod_t c, const fq_nmod_ctx_t ctx) noexcept # Returns whether the polynomial ``poly`` is equal the (constant) # `\mathbf{F}_q` element ``c`` - void _fq_nmod_poly_add(fq_nmod_struct *res, const fq_nmod_struct *poly1, slong len1, const fq_nmod_struct *poly2, slong len2, const fq_nmod_ctx_t ctx) + void _fq_nmod_poly_add(fq_nmod_struct *res, const fq_nmod_struct *poly1, slong len1, const fq_nmod_struct *poly2, slong len2, const fq_nmod_ctx_t ctx) noexcept # Sets ``res`` to the sum of ``(poly1,len1)`` and ``(poly2,len2)``. - void fq_nmod_poly_add(fq_nmod_poly_t res, const fq_nmod_poly_t poly1, const fq_nmod_poly_t poly2, const fq_nmod_ctx_t ctx) + void fq_nmod_poly_add(fq_nmod_poly_t res, const fq_nmod_poly_t poly1, const fq_nmod_poly_t poly2, const fq_nmod_ctx_t ctx) noexcept # Sets ``res`` to the sum of ``poly1`` and ``poly2``. - void fq_nmod_poly_add_si(fq_nmod_poly_t res, const fq_nmod_poly_t poly1, slong c, const fq_nmod_ctx_t ctx) + void fq_nmod_poly_add_si(fq_nmod_poly_t res, const fq_nmod_poly_t poly1, slong c, const fq_nmod_ctx_t ctx) noexcept # Sets ``res`` to the sum of ``poly1`` and ``c``. - void fq_nmod_poly_add_series(fq_nmod_poly_t res, const fq_nmod_poly_t poly1, const fq_nmod_poly_t poly2, slong n, const fq_nmod_ctx_t ctx) + void fq_nmod_poly_add_series(fq_nmod_poly_t res, const fq_nmod_poly_t poly1, const fq_nmod_poly_t poly2, slong n, const fq_nmod_ctx_t ctx) noexcept # Notionally truncate ``poly1`` and ``poly2`` to length ``n`` and set # ``res`` to the sum. - void _fq_nmod_poly_sub(fq_nmod_struct *res, const fq_nmod_struct *poly1, slong len1, const fq_nmod_struct *poly2, slong len2, const fq_nmod_ctx_t ctx) + void _fq_nmod_poly_sub(fq_nmod_struct *res, const fq_nmod_struct *poly1, slong len1, const fq_nmod_struct *poly2, slong len2, const fq_nmod_ctx_t ctx) noexcept # Sets ``res`` to the difference of ``(poly1,len1)`` and # ``(poly2,len2)``. - void fq_nmod_poly_sub(fq_nmod_poly_t res, const fq_nmod_poly_t poly1, const fq_nmod_poly_t poly2, const fq_nmod_ctx_t ctx) + void fq_nmod_poly_sub(fq_nmod_poly_t res, const fq_nmod_poly_t poly1, const fq_nmod_poly_t poly2, const fq_nmod_ctx_t ctx) noexcept # Sets ``res`` to the difference of ``poly1`` and ``poly2``. - void fq_nmod_poly_sub_series(fq_nmod_poly_t res, const fq_nmod_poly_t poly1, const fq_nmod_poly_t poly2, slong n, const fq_nmod_ctx_t ctx) + void fq_nmod_poly_sub_series(fq_nmod_poly_t res, const fq_nmod_poly_t poly1, const fq_nmod_poly_t poly2, slong n, const fq_nmod_ctx_t ctx) noexcept # Notionally truncate ``poly1`` and ``poly2`` to length ``n`` and set # ``res`` to the difference. - void _fq_nmod_poly_neg(fq_nmod_struct *rop, const fq_nmod_struct *op, slong len, const fq_nmod_ctx_t ctx) + void _fq_nmod_poly_neg(fq_nmod_struct *rop, const fq_nmod_struct *op, slong len, const fq_nmod_ctx_t ctx) noexcept # Sets ``rop`` to the additive inverse of ``(poly,len)``. - void fq_nmod_poly_neg(fq_nmod_poly_t res, const fq_nmod_poly_t poly, const fq_nmod_ctx_t ctx) + void fq_nmod_poly_neg(fq_nmod_poly_t res, const fq_nmod_poly_t poly, const fq_nmod_ctx_t ctx) noexcept # Sets ``res`` to the additive inverse of ``poly``. - void _fq_nmod_poly_scalar_mul_fq_nmod(fq_nmod_struct *rop, const fq_nmod_struct *op, slong len, const fq_nmod_t x, const fq_nmod_ctx_t ctx) + void _fq_nmod_poly_scalar_mul_fq_nmod(fq_nmod_struct *rop, const fq_nmod_struct *op, slong len, const fq_nmod_t x, const fq_nmod_ctx_t ctx) noexcept # Sets ``(rop,len)`` to the product of ``(op,len)`` by the # scalar ``x``, in the context defined by ``ctx``. - void fq_nmod_poly_scalar_mul_fq_nmod(fq_nmod_poly_t rop, const fq_nmod_poly_t op, const fq_nmod_t x, const fq_nmod_ctx_t ctx) + void fq_nmod_poly_scalar_mul_fq_nmod(fq_nmod_poly_t rop, const fq_nmod_poly_t op, const fq_nmod_t x, const fq_nmod_ctx_t ctx) noexcept # Sets ``rop`` to the product of ``op`` by the scalar ``x``, in the context # defined by ``ctx``. - void _fq_nmod_poly_scalar_addmul_fq_nmod(fq_nmod_struct *rop, const fq_nmod_struct *op, slong len, const fq_nmod_t x, const fq_nmod_ctx_t ctx) + void _fq_nmod_poly_scalar_addmul_fq_nmod(fq_nmod_struct *rop, const fq_nmod_struct *op, slong len, const fq_nmod_t x, const fq_nmod_ctx_t ctx) noexcept # Adds to ``(rop,len)`` the product of ``(op,len)`` by the # scalar ``x``, in the context defined by ``ctx``. # In particular, assumes the same length for ``op`` and # ``rop``. - void fq_nmod_poly_scalar_addmul_fq_nmod(fq_nmod_poly_t rop, const fq_nmod_poly_t op, const fq_nmod_t x, const fq_nmod_ctx_t ctx) + void fq_nmod_poly_scalar_addmul_fq_nmod(fq_nmod_poly_t rop, const fq_nmod_poly_t op, const fq_nmod_t x, const fq_nmod_ctx_t ctx) noexcept # Adds to ``rop`` the product of ``op`` by the # scalar ``x``, in the context defined by ``ctx``. - void _fq_nmod_poly_scalar_submul_fq_nmod(fq_nmod_struct *rop, const fq_nmod_struct *op, slong len, const fq_nmod_t x, const fq_nmod_ctx_t ctx) + void _fq_nmod_poly_scalar_submul_fq_nmod(fq_nmod_struct *rop, const fq_nmod_struct *op, slong len, const fq_nmod_t x, const fq_nmod_ctx_t ctx) noexcept # Subtracts from ``(rop,len)`` the product of ``(op,len)`` by the # scalar ``x``, in the context defined by ``ctx``. # In particular, assumes the same length for ``op`` and # ``rop``. - void fq_nmod_poly_scalar_submul_fq_nmod(fq_nmod_poly_t rop, const fq_nmod_poly_t op, const fq_nmod_t x, const fq_nmod_ctx_t ctx) + void fq_nmod_poly_scalar_submul_fq_nmod(fq_nmod_poly_t rop, const fq_nmod_poly_t op, const fq_nmod_t x, const fq_nmod_ctx_t ctx) noexcept # Subtracts from ``rop`` the product of ``op`` by the # scalar ``x``, in the context defined by ``ctx``. - void _fq_nmod_poly_scalar_div_fq(fq_nmod_struct *rop, const fq_nmod_struct *op, slong len, const fq_nmod_t x, const fq_nmod_ctx_t ctx) + void _fq_nmod_poly_scalar_div_fq(fq_nmod_struct *rop, const fq_nmod_struct *op, slong len, const fq_nmod_t x, const fq_nmod_ctx_t ctx) noexcept # Sets ``(rop,len)`` to the quotient of ``(op,len)`` by the # scalar ``x``, in the context defined by ``ctx``. An exception is raised # if ``x`` is zero. - void fq_nmod_poly_scalar_div_fq(fq_nmod_poly_t rop, const fq_nmod_poly_t op, const fq_nmod_t x, const fq_nmod_ctx_t ctx) + void fq_nmod_poly_scalar_div_fq(fq_nmod_poly_t rop, const fq_nmod_poly_t op, const fq_nmod_t x, const fq_nmod_ctx_t ctx) noexcept # Sets ``rop`` to the quotient of ``op`` by the scalar ``x``, in the context # defined by ``ctx``. An exception is raised if ``x`` is zero. - void _fq_nmod_poly_mul_classical(fq_nmod_struct *rop, const fq_nmod_struct *op1, slong len1, const fq_nmod_struct *op2, slong len2, const fq_nmod_ctx_t ctx) + void _fq_nmod_poly_mul_classical(fq_nmod_struct *rop, const fq_nmod_struct *op1, slong len1, const fq_nmod_struct *op2, slong len2, const fq_nmod_ctx_t ctx) noexcept # Sets ``(rop, len1 + len2 - 1)`` to the product of ``(op1, len1)`` # and ``(op2, len2)``, assuming that ``len1`` is at least ``len2`` # and neither is zero. # Permits zero padding. Does not support aliasing of ``rop`` # with either ``op1`` or ``op2``. - void fq_nmod_poly_mul_classical(fq_nmod_poly_t rop, const fq_nmod_poly_t op1, const fq_nmod_poly_t op2, const fq_nmod_ctx_t ctx) + void fq_nmod_poly_mul_classical(fq_nmod_poly_t rop, const fq_nmod_poly_t op1, const fq_nmod_poly_t op2, const fq_nmod_ctx_t ctx) noexcept # Sets ``rop`` to the product of ``op1`` and ``op2`` # using classical polynomial multiplication. - void _fq_nmod_poly_mul_reorder(fq_nmod_struct *rop, const fq_nmod_struct *op1, slong len1, const fq_nmod_struct *op2, slong len2, const fq_nmod_ctx_t ctx) + void _fq_nmod_poly_mul_reorder(fq_nmod_struct *rop, const fq_nmod_struct *op1, slong len1, const fq_nmod_struct *op2, slong len2, const fq_nmod_ctx_t ctx) noexcept # Sets ``(rop, len1 + len2 - 1)`` to the product of ``(op1, len1)`` # and ``(op2, len2)``, assuming that ``len1`` and ``len2`` are # non-zero. # Permits zero padding. Supports aliasing. - void fq_nmod_poly_mul_reorder(fq_nmod_poly_t rop, const fq_nmod_poly_t op1, const fq_nmod_poly_t op2, const fq_nmod_ctx_t ctx) + void fq_nmod_poly_mul_reorder(fq_nmod_poly_t rop, const fq_nmod_poly_t op1, const fq_nmod_poly_t op2, const fq_nmod_ctx_t ctx) noexcept # Sets ``rop`` to the product of ``op1`` and ``op2``, # reordering the two indeterminates `X` and `Y` when viewing # the polynomials as elements of `\mathbf{F}_p[X,Y]`. @@ -287,49 +287,49 @@ cdef extern from "flint_wrap.h": # multiplication routines in the `Y`-direction where the polynomial # degree `n` is large. - void _fq_nmod_poly_mul_univariate(fq_nmod_struct *rop, const fq_nmod_struct *op1, slong len1, const fq_nmod_struct *op2, slong len2, const fq_nmod_ctx_t ctx) + void _fq_nmod_poly_mul_univariate(fq_nmod_struct *rop, const fq_nmod_struct *op1, slong len1, const fq_nmod_struct *op2, slong len2, const fq_nmod_ctx_t ctx) noexcept # Sets ``(rop, len1 + len2 - 1)`` to the product of ``(op1, len1)`` # and ``(op2, len2)``. # Permits zero padding and makes no assumptions on ``len1`` and ``len2``. # Supports aliasing. - void fq_nmod_poly_mul_univariate(fq_nmod_poly_t rop, const fq_nmod_poly_t op1, const fq_nmod_poly_t op2, const fq_nmod_ctx_t ctx) + void fq_nmod_poly_mul_univariate(fq_nmod_poly_t rop, const fq_nmod_poly_t op1, const fq_nmod_poly_t op2, const fq_nmod_ctx_t ctx) noexcept # Sets ``rop`` to the product of ``op1`` and ``op2`` # using a bivariate to univariate transformation and reducing # this problem to multiplying two univariate polynomials. - void _fq_nmod_poly_mul_KS(fq_nmod_struct *rop, const fq_nmod_struct *op1, slong len1, const fq_nmod_struct *op2, slong len2, const fq_nmod_ctx_t ctx) + void _fq_nmod_poly_mul_KS(fq_nmod_struct *rop, const fq_nmod_struct *op1, slong len1, const fq_nmod_struct *op2, slong len2, const fq_nmod_ctx_t ctx) noexcept # Sets ``(rop, len1 + len2 - 1)`` to the product of ``(op1, len1)`` # and ``(op2, len2)``. # Permits zero padding and places no assumptions on the # lengths ``len1`` and ``len2``. Supports aliasing. - void fq_nmod_poly_mul_KS(fq_nmod_poly_t rop, const fq_nmod_poly_t op1, const fq_nmod_poly_t op2, const fq_nmod_ctx_t ctx) + void fq_nmod_poly_mul_KS(fq_nmod_poly_t rop, const fq_nmod_poly_t op1, const fq_nmod_poly_t op2, const fq_nmod_ctx_t ctx) noexcept # Sets ``rop`` to the product of ``op1`` and ``op2`` # using Kronecker substitution, that is, by encoding each # coefficient in `\mathbf{F}_{q}` as an integer and reducing # this problem to multiplying two polynomials over the integers. - void _fq_nmod_poly_mul(fq_nmod_struct *rop, const fq_nmod_struct *op1, slong len1, const fq_nmod_struct *op2, slong len2, const fq_nmod_ctx_t ctx) + void _fq_nmod_poly_mul(fq_nmod_struct *rop, const fq_nmod_struct *op1, slong len1, const fq_nmod_struct *op2, slong len2, const fq_nmod_ctx_t ctx) noexcept # Sets ``(rop, len1 + len2 - 1)`` to the product of ``(op1, len1)`` # and ``(op2, len2)``, choosing an appropriate algorithm. # Permits zero padding. Does not support aliasing. - void fq_nmod_poly_mul(fq_nmod_poly_t rop, const fq_nmod_poly_t op1, const fq_nmod_poly_t op2, const fq_nmod_ctx_t ctx) + void fq_nmod_poly_mul(fq_nmod_poly_t rop, const fq_nmod_poly_t op1, const fq_nmod_poly_t op2, const fq_nmod_ctx_t ctx) noexcept # Sets ``rop`` to the product of ``op1`` and ``op2``, # choosing an appropriate algorithm. - void _fq_nmod_poly_mullow_classical(fq_nmod_struct *rop, const fq_nmod_struct *op1, slong len1, const fq_nmod_struct *op2, slong len2, slong n, const fq_nmod_ctx_t ctx) + void _fq_nmod_poly_mullow_classical(fq_nmod_struct *rop, const fq_nmod_struct *op1, slong len1, const fq_nmod_struct *op2, slong len2, slong n, const fq_nmod_ctx_t ctx) noexcept # Sets ``(rop, n)`` to the first `n` coefficients of # ``(op1, len1)`` multiplied by ``(op2, len2)``. # Assumes ``0 < n <= len1 + len2 - 1``. Assumes neither # ``len1`` nor ``len2`` is zero. - void fq_nmod_poly_mullow_classical(fq_nmod_poly_t rop, const fq_nmod_poly_t op1, const fq_nmod_poly_t op2, slong n, const fq_nmod_ctx_t ctx) + void fq_nmod_poly_mullow_classical(fq_nmod_poly_t rop, const fq_nmod_poly_t op1, const fq_nmod_poly_t op2, slong n, const fq_nmod_ctx_t ctx) noexcept # Sets ``rop`` to the product of ``op1`` and ``op2``, # computed using the classical or schoolbook method. - void _fq_nmod_poly_mullow_univariate(fq_nmod_struct *rop, const fq_nmod_struct *op1, slong len1, const fq_nmod_struct *op2, slong len2, slong n, const fq_nmod_ctx_t ctx) + void _fq_nmod_poly_mullow_univariate(fq_nmod_struct *rop, const fq_nmod_struct *op1, slong len1, const fq_nmod_struct *op2, slong len2, slong n, const fq_nmod_ctx_t ctx) noexcept # Sets ``(rop, n)`` to the lowest `n` coefficients of the product of # ``(op1, len1)`` and ``(op2, len2)``, computed using a # bivariate to univariate transformation. @@ -338,12 +338,12 @@ cdef extern from "flint_wrap.h": # too. Assumes `n` is positive. Supports aliasing between ``rop``, # ``op1`` and ``op2``. - void fq_nmod_poly_mullow_univariate(fq_nmod_poly_t rop, const fq_nmod_poly_t op1, const fq_nmod_poly_t op2, slong n, const fq_nmod_ctx_t ctx) + void fq_nmod_poly_mullow_univariate(fq_nmod_poly_t rop, const fq_nmod_poly_t op1, const fq_nmod_poly_t op2, slong n, const fq_nmod_ctx_t ctx) noexcept # Sets ``rop`` to the lowest `n` coefficients of the product of # ``poly1`` and ``poly2``, computed using a bivariate to # univariate transformation. - void _fq_nmod_poly_mullow_KS(fq_nmod_struct *rop, const fq_nmod_struct *op1, slong len1, const fq_nmod_struct *op2, slong len2, slong n, const fq_nmod_ctx_t ctx) + void _fq_nmod_poly_mullow_KS(fq_nmod_struct *rop, const fq_nmod_struct *op1, slong len1, const fq_nmod_struct *op2, slong len2, slong n, const fq_nmod_ctx_t ctx) noexcept # Sets ``(rop, n)`` to the lowest `n` coefficients of the product of # ``(op1, len1)`` and ``(op2, len2)``. # Assumes that ``len1`` and ``len2`` are positive, but does allow @@ -351,45 +351,45 @@ cdef extern from "flint_wrap.h": # too. Assumes `n` is positive. Supports aliasing between ``rop``, # ``op1`` and ``op2``. - void fq_nmod_poly_mullow_KS(fq_nmod_poly_t rop, const fq_nmod_poly_t op1, const fq_nmod_poly_t op2, slong n, const fq_nmod_ctx_t ctx) + void fq_nmod_poly_mullow_KS(fq_nmod_poly_t rop, const fq_nmod_poly_t op1, const fq_nmod_poly_t op2, slong n, const fq_nmod_ctx_t ctx) noexcept # Sets ``rop`` to the product of ``op1`` and ``op2``. - void _fq_nmod_poly_mullow(fq_nmod_struct *rop, const fq_nmod_struct *op1, slong len1, const fq_nmod_struct *op2, slong len2, slong n, const fq_nmod_ctx_t ctx) + void _fq_nmod_poly_mullow(fq_nmod_struct *rop, const fq_nmod_struct *op1, slong len1, const fq_nmod_struct *op2, slong len2, slong n, const fq_nmod_ctx_t ctx) noexcept # Sets ``(rop, n)`` to the lowest `n` coefficients of the product of # ``(op1, len1)`` and ``(op2, len2)``. # Assumes ``0 < n <= len1 + len2 - 1``. Allows for zero-padding in # the inputs. Does not support aliasing between the inputs and the output. - void fq_nmod_poly_mullow(fq_nmod_poly_t rop, const fq_nmod_poly_t op1, const fq_nmod_poly_t op2, slong n, const fq_nmod_ctx_t ctx) + void fq_nmod_poly_mullow(fq_nmod_poly_t rop, const fq_nmod_poly_t op1, const fq_nmod_poly_t op2, slong n, const fq_nmod_ctx_t ctx) noexcept # Sets ``rop`` to the lowest `n` coefficients of the product of # ``op1`` and ``op2``. - void _fq_nmod_poly_mulhigh_classical(fq_nmod_struct *res, const fq_nmod_struct *poly1, slong len1, const fq_nmod_struct *poly2, slong len2, slong start, const fq_nmod_ctx_t ctx) + void _fq_nmod_poly_mulhigh_classical(fq_nmod_struct *res, const fq_nmod_struct *poly1, slong len1, const fq_nmod_struct *poly2, slong len2, slong start, const fq_nmod_ctx_t ctx) noexcept # Computes the product of ``(poly1, len1)`` and ``(poly2, len2)`` # and writes the coefficients from ``start`` onwards into the high # coefficients of ``res``, the remaining coefficients being arbitrary # but reduced. Assumes that ``len1 >= len2 > 0``. Aliasing of inputs # and output is not permitted. Algorithm is classical multiplication. - void fq_nmod_poly_mulhigh_classical(fq_nmod_poly_t res, const fq_nmod_poly_t poly1, const fq_nmod_poly_t poly2, slong start, const fq_nmod_ctx_t ctx) + void fq_nmod_poly_mulhigh_classical(fq_nmod_poly_t res, const fq_nmod_poly_t poly1, const fq_nmod_poly_t poly2, slong start, const fq_nmod_ctx_t ctx) noexcept # Computes the product of ``poly1`` and ``poly2`` and writes the # coefficients from ``start`` onwards into the high coefficients of # ``res``, the remaining coefficients being arbitrary but reduced. # Algorithm is classical multiplication. - void _fq_nmod_poly_mulhigh(fq_nmod_struct *res, const fq_nmod_struct *poly1, slong len1, const fq_nmod_struct *poly2, slong len2, slong start, fq_nmod_ctx_t ctx) + void _fq_nmod_poly_mulhigh(fq_nmod_struct *res, const fq_nmod_struct *poly1, slong len1, const fq_nmod_struct *poly2, slong len2, slong start, fq_nmod_ctx_t ctx) noexcept # Computes the product of ``(poly1, len1)`` and ``(poly2, len2)`` # and writes the coefficients from ``start`` onwards into the high # coefficients of ``res``, the remaining coefficients being arbitrary # but reduced. Assumes that ``len1 >= len2 > 0``. Aliasing of inputs # and output is not permitted. - void fq_nmod_poly_mulhigh(fq_nmod_poly_t res, const fq_nmod_poly_t poly1, const fq_nmod_poly_t poly2, slong start, const fq_nmod_ctx_t ctx) + void fq_nmod_poly_mulhigh(fq_nmod_poly_t res, const fq_nmod_poly_t poly1, const fq_nmod_poly_t poly2, slong start, const fq_nmod_ctx_t ctx) noexcept # Computes the product of ``poly1`` and ``poly2`` and writes the # coefficients from ``start`` onwards into the high coefficients of # ``res``, the remaining coefficients being arbitrary but reduced. - void _fq_nmod_poly_mulmod(fq_nmod_struct* res, const fq_nmod_struct* poly1, slong len1, const fq_nmod_struct* poly2, slong len2, const fq_nmod_struct* f, slong lenf, const fq_nmod_ctx_t ctx) + void _fq_nmod_poly_mulmod(fq_nmod_struct* res, const fq_nmod_struct* poly1, slong len1, const fq_nmod_struct* poly2, slong len2, const fq_nmod_struct* f, slong lenf, const fq_nmod_ctx_t ctx) noexcept # Sets ``res`` to the remainder of the product of ``poly1`` # and ``poly2`` upon polynomial division by ``f``. # It is required that ``len1 + len2 - lenf > 0``, which is @@ -397,62 +397,62 @@ cdef extern from "flint_wrap.h": # reduced. Otherwise, simply use ``_fq_nmod_poly_mul`` instead. # Aliasing of ``f`` and ``res`` is not permitted. - void fq_nmod_poly_mulmod(fq_nmod_poly_t res, const fq_nmod_poly_t poly1, const fq_nmod_poly_t poly2, const fq_nmod_poly_t f, const fq_nmod_ctx_t ctx) + void fq_nmod_poly_mulmod(fq_nmod_poly_t res, const fq_nmod_poly_t poly1, const fq_nmod_poly_t poly2, const fq_nmod_poly_t f, const fq_nmod_ctx_t ctx) noexcept # Sets ``res`` to the remainder of the product of ``poly1`` # and ``poly2`` upon polynomial division by ``f``. - void _fq_nmod_poly_mulmod_preinv(fq_nmod_struct* res, const fq_nmod_struct* poly1, slong len1, const fq_nmod_struct* poly2, slong len2, const fq_nmod_struct* f, slong lenf, const fq_nmod_struct* finv, slong lenfinv, const fq_nmod_ctx_t ctx) + void _fq_nmod_poly_mulmod_preinv(fq_nmod_struct* res, const fq_nmod_struct* poly1, slong len1, const fq_nmod_struct* poly2, slong len2, const fq_nmod_struct* f, slong lenf, const fq_nmod_struct* finv, slong lenfinv, const fq_nmod_ctx_t ctx) noexcept # Sets ``res`` to the remainder of the product of ``poly1`` # and ``poly2`` upon polynomial division by ``f``. # It is required that ``finv`` is the inverse of the reverse of # ``f`` mod ``x^lenf``. # Aliasing of ``res`` with any of the inputs is not permitted. - void fq_nmod_poly_mulmod_preinv(fq_nmod_poly_t res, const fq_nmod_poly_t poly1, const fq_nmod_poly_t poly2, const fq_nmod_poly_t f, const fq_nmod_poly_t finv, const fq_nmod_ctx_t ctx) + void fq_nmod_poly_mulmod_preinv(fq_nmod_poly_t res, const fq_nmod_poly_t poly1, const fq_nmod_poly_t poly2, const fq_nmod_poly_t f, const fq_nmod_poly_t finv, const fq_nmod_ctx_t ctx) noexcept # Sets ``res`` to the remainder of the product of ``poly1`` # and ``poly2`` upon polynomial division by ``f``. ``finv`` # is the inverse of the reverse of ``f``. - void _fq_nmod_poly_sqr_classical(fq_nmod_struct *rop, const fq_nmod_struct *op, slong len, const fq_nmod_ctx_t ctx) + void _fq_nmod_poly_sqr_classical(fq_nmod_struct *rop, const fq_nmod_struct *op, slong len, const fq_nmod_ctx_t ctx) noexcept # Sets ``(rop, 2*len - 1)`` to the square of ``(op, len)``, # assuming that ``(op,len)`` is not zero and using classical # polynomial multiplication. # Permits zero padding. Does not support aliasing of ``rop`` # with either ``op1`` or ``op2``. - void fq_nmod_poly_sqr_classical(fq_nmod_poly_t rop, const fq_nmod_poly_t op, const fq_nmod_ctx_t ctx) + void fq_nmod_poly_sqr_classical(fq_nmod_poly_t rop, const fq_nmod_poly_t op, const fq_nmod_ctx_t ctx) noexcept # Sets ``rop`` to the square of ``op`` using classical # polynomial multiplication. - void _fq_nmod_poly_sqr_KS(fq_nmod_struct *rop, const fq_nmod_struct *op, slong len, const fq_nmod_ctx_t ctx) + void _fq_nmod_poly_sqr_KS(fq_nmod_struct *rop, const fq_nmod_struct *op, slong len, const fq_nmod_ctx_t ctx) noexcept # Sets ``(rop, 2*len - 1)`` to the square of ``(op, len)``. # Permits zero padding and places no assumptions on the # lengths ``len1`` and ``len2``. Supports aliasing. - void fq_nmod_poly_sqr_KS(fq_nmod_poly_t rop, const fq_nmod_poly_t op, const fq_nmod_ctx_t ctx) + void fq_nmod_poly_sqr_KS(fq_nmod_poly_t rop, const fq_nmod_poly_t op, const fq_nmod_ctx_t ctx) noexcept # Sets ``rop`` to the square ``op`` using Kronecker substitution, # that is, by encoding each coefficient in `\mathbf{F}_{q}` as an integer # and reducing this problem to multiplying two polynomials over the integers. - void _fq_nmod_poly_sqr(fq_nmod_struct *rop, const fq_nmod_struct *op, slong len, const fq_nmod_ctx_t ctx) + void _fq_nmod_poly_sqr(fq_nmod_struct *rop, const fq_nmod_struct *op, slong len, const fq_nmod_ctx_t ctx) noexcept # Sets ``(rop, 2* len - 1)`` to the square of ``(op, len)``, # choosing an appropriate algorithm. # Permits zero padding. Does not support aliasing. - void fq_nmod_poly_sqr(fq_nmod_poly_t rop, const fq_nmod_poly_t op, const fq_nmod_ctx_t ctx) + void fq_nmod_poly_sqr(fq_nmod_poly_t rop, const fq_nmod_poly_t op, const fq_nmod_ctx_t ctx) noexcept # Sets ``rop`` to the square of ``op``, # choosing an appropriate algorithm. - void _fq_nmod_poly_pow(fq_nmod_struct *rop, const fq_nmod_struct *op, slong len, ulong e, const fq_nmod_ctx_t ctx) + void _fq_nmod_poly_pow(fq_nmod_struct *rop, const fq_nmod_struct *op, slong len, ulong e, const fq_nmod_ctx_t ctx) noexcept # Sets ``rop = op^e``, assuming that ``e, len > 0`` and that # ``rop`` has space for ``e*(len - 1) + 1`` coefficients. Does # not support aliasing. - void fq_nmod_poly_pow(fq_nmod_poly_t rop, const fq_nmod_poly_t op, ulong e, const fq_nmod_ctx_t ctx) + void fq_nmod_poly_pow(fq_nmod_poly_t rop, const fq_nmod_poly_t op, ulong e, const fq_nmod_ctx_t ctx) noexcept # Computes ``rop = op^e``. If `e` is zero, returns one, # so that in particular ``0^0 = 1``. - void _fq_nmod_poly_powmod_ui_binexp(fq_nmod_struct* res, const fq_nmod_struct* poly, ulong e, const fq_nmod_struct* f, slong lenf, const fq_nmod_ctx_t ctx) + void _fq_nmod_poly_powmod_ui_binexp(fq_nmod_struct* res, const fq_nmod_struct* poly, ulong e, const fq_nmod_struct* f, slong lenf, const fq_nmod_ctx_t ctx) noexcept # Sets ``res`` to ``poly`` raised to the power ``e`` modulo # ``f``, using binary exponentiation. We require ``e > 0``. # We require ``lenf > 1``. It is assumed that ``poly`` is @@ -460,11 +460,11 @@ cdef extern from "flint_wrap.h": # have length exactly ``lenf - 1``. The output ``res`` must # have room for ``lenf - 1`` coefficients. - void fq_nmod_poly_powmod_ui_binexp(fq_nmod_poly_t res, const fq_nmod_poly_t poly, ulong e, const fq_nmod_poly_t f, const fq_nmod_ctx_t ctx) + void fq_nmod_poly_powmod_ui_binexp(fq_nmod_poly_t res, const fq_nmod_poly_t poly, ulong e, const fq_nmod_poly_t f, const fq_nmod_ctx_t ctx) noexcept # Sets ``res`` to ``poly`` raised to the power ``e`` modulo # ``f``, using binary exponentiation. We require ``e >= 0``. - void _fq_nmod_poly_powmod_ui_binexp_preinv(fq_nmod_struct* res, const fq_nmod_struct* poly, ulong e, const fq_nmod_struct* f, slong lenf, const fq_nmod_struct* finv, slong lenfinv, const fq_nmod_ctx_t ctx) + void _fq_nmod_poly_powmod_ui_binexp_preinv(fq_nmod_struct* res, const fq_nmod_struct* poly, ulong e, const fq_nmod_struct* f, slong lenf, const fq_nmod_struct* finv, slong lenfinv, const fq_nmod_ctx_t ctx) noexcept # Sets ``res`` to ``poly`` raised to the power ``e`` modulo # ``f``, using binary exponentiation. We require ``e > 0``. # We require ``finv`` to be the inverse of the reverse of @@ -474,13 +474,13 @@ cdef extern from "flint_wrap.h": # have length exactly ``lenf - 1``. The output ``res`` must # have room for ``lenf - 1`` coefficients. - void fq_nmod_poly_powmod_ui_binexp_preinv(fq_nmod_poly_t res, const fq_nmod_poly_t poly, ulong e, const fq_nmod_poly_t f, const fq_nmod_poly_t finv, const fq_nmod_ctx_t ctx) + void fq_nmod_poly_powmod_ui_binexp_preinv(fq_nmod_poly_t res, const fq_nmod_poly_t poly, ulong e, const fq_nmod_poly_t f, const fq_nmod_poly_t finv, const fq_nmod_ctx_t ctx) noexcept # Sets ``res`` to ``poly`` raised to the power ``e`` modulo # ``f``, using binary exponentiation. We require ``e >= 0``. # We require ``finv`` to be the inverse of the reverse of # ``f``. - void _fq_nmod_poly_powmod_fmpz_binexp(fq_nmod_struct* res, const fq_nmod_struct* poly, const fmpz_t e, const fq_nmod_struct* f, slong lenf, const fq_nmod_ctx_t ctx) + void _fq_nmod_poly_powmod_fmpz_binexp(fq_nmod_struct* res, const fq_nmod_struct* poly, const fmpz_t e, const fq_nmod_struct* f, slong lenf, const fq_nmod_ctx_t ctx) noexcept # Sets ``res`` to ``poly`` raised to the power ``e`` modulo # ``f``, using binary exponentiation. We require ``e > 0``. # We require ``lenf > 1``. It is assumed that ``poly`` is @@ -488,11 +488,11 @@ cdef extern from "flint_wrap.h": # have length exactly ``lenf - 1``. The output ``res`` must # have room for ``lenf - 1`` coefficients. - void fq_nmod_poly_powmod_fmpz_binexp(fq_nmod_poly_t res, const fq_nmod_poly_t poly, const fmpz_t e, const fq_nmod_poly_t f, const fq_nmod_ctx_t ctx) + void fq_nmod_poly_powmod_fmpz_binexp(fq_nmod_poly_t res, const fq_nmod_poly_t poly, const fmpz_t e, const fq_nmod_poly_t f, const fq_nmod_ctx_t ctx) noexcept # Sets ``res`` to ``poly`` raised to the power ``e`` modulo # ``f``, using binary exponentiation. We require ``e >= 0``. - void _fq_nmod_poly_powmod_fmpz_binexp_preinv(fq_nmod_struct* res, const fq_nmod_struct* poly, const fmpz_t e, const fq_nmod_struct* f, slong lenf, const fq_nmod_struct* finv, slong lenfinv, const fq_nmod_ctx_t ctx) + void _fq_nmod_poly_powmod_fmpz_binexp_preinv(fq_nmod_struct* res, const fq_nmod_struct* poly, const fmpz_t e, const fq_nmod_struct* f, slong lenf, const fq_nmod_struct* finv, slong lenfinv, const fq_nmod_ctx_t ctx) noexcept # Sets ``res`` to ``poly`` raised to the power ``e`` modulo # ``f``, using binary exponentiation. We require ``e > 0``. # We require ``finv`` to be the inverse of the reverse of @@ -502,13 +502,13 @@ cdef extern from "flint_wrap.h": # have length exactly ``lenf - 1``. The output ``res`` must # have room for ``lenf - 1`` coefficients. - void fq_nmod_poly_powmod_fmpz_binexp_preinv(fq_nmod_poly_t res, const fq_nmod_poly_t poly, const fmpz_t e, const fq_nmod_poly_t f, const fq_nmod_poly_t finv, const fq_nmod_ctx_t ctx) + void fq_nmod_poly_powmod_fmpz_binexp_preinv(fq_nmod_poly_t res, const fq_nmod_poly_t poly, const fmpz_t e, const fq_nmod_poly_t f, const fq_nmod_poly_t finv, const fq_nmod_ctx_t ctx) noexcept # Sets ``res`` to ``poly`` raised to the power ``e`` modulo # ``f``, using binary exponentiation. We require ``e >= 0``. # We require ``finv`` to be the inverse of the reverse of # ``f``. - void _fq_nmod_poly_powmod_fmpz_sliding_preinv(fq_nmod_struct* res, const fq_nmod_struct* poly, const fmpz_t e, ulong k, const fq_nmod_struct* f, slong lenf, const fq_nmod_struct* finv, slong lenfinv, const fq_nmod_ctx_t ctx) + void _fq_nmod_poly_powmod_fmpz_sliding_preinv(fq_nmod_struct* res, const fq_nmod_struct* poly, const fmpz_t e, ulong k, const fq_nmod_struct* f, slong lenf, const fq_nmod_struct* finv, slong lenfinv, const fq_nmod_ctx_t ctx) noexcept # Sets ``res`` to ``poly`` raised to the power ``e`` modulo # ``f``, using sliding-window exponentiation with window size # ``k``. We require ``e > 0``. We require ``finv`` to be @@ -520,7 +520,7 @@ cdef extern from "flint_wrap.h": # have length exactly ``lenf - 1``. The output ``res`` must # have room for ``lenf - 1`` coefficients. - void fq_nmod_poly_powmod_fmpz_sliding_preinv(fq_nmod_poly_t res, const fq_nmod_poly_t poly, const fmpz_t e, ulong k, const fq_nmod_poly_t f, const fq_nmod_poly_t finv, const fq_nmod_ctx_t ctx) + void fq_nmod_poly_powmod_fmpz_sliding_preinv(fq_nmod_poly_t res, const fq_nmod_poly_t poly, const fmpz_t e, ulong k, const fq_nmod_poly_t f, const fq_nmod_poly_t finv, const fq_nmod_ctx_t ctx) noexcept # Sets ``res`` to ``poly`` raised to the power ``e`` modulo # ``f``, using sliding-window exponentiation with window size # ``k``. We require ``e >= 0``. We require ``finv`` to be @@ -528,20 +528,20 @@ cdef extern from "flint_wrap.h": # zero, then an "optimum" size will be selected automatically base # on ``e``. - void _fq_nmod_poly_powmod_x_fmpz_preinv(fq_nmod_struct * res, const fmpz_t e, const fq_nmod_struct * f, slong lenf, const fq_nmod_struct * finv, slong lenfinv, const fq_nmod_ctx_t ctx) + void _fq_nmod_poly_powmod_x_fmpz_preinv(fq_nmod_struct * res, const fmpz_t e, const fq_nmod_struct * f, slong lenf, const fq_nmod_struct * finv, slong lenfinv, const fq_nmod_ctx_t ctx) noexcept # Sets ``res`` to ``x`` raised to the power ``e`` modulo ``f``, # using sliding window exponentiation. We require ``e > 0``. # We require ``finv`` to be the inverse of the reverse of ``f``. # We require ``lenf > 2``. The output ``res`` must have room for # ``lenf - 1`` coefficients. - void fq_nmod_poly_powmod_x_fmpz_preinv(fq_nmod_poly_t res, const fmpz_t e, const fq_nmod_poly_t f, const fq_nmod_poly_t finv, const fq_nmod_ctx_t ctx) + void fq_nmod_poly_powmod_x_fmpz_preinv(fq_nmod_poly_t res, const fmpz_t e, const fq_nmod_poly_t f, const fq_nmod_poly_t finv, const fq_nmod_ctx_t ctx) noexcept # Sets ``res`` to ``x`` raised to the power ``e`` # modulo ``f``, using sliding window exponentiation. We require # ``e >= 0``. We require ``finv`` to be the inverse of the reverse of # ``f``. - void _fq_nmod_poly_pow_trunc_binexp(fq_nmod_struct * res, const fq_nmod_struct * poly, ulong e, slong trunc, const fq_nmod_ctx_t ctx) + void _fq_nmod_poly_pow_trunc_binexp(fq_nmod_struct * res, const fq_nmod_struct * poly, ulong e, slong trunc, const fq_nmod_ctx_t ctx) noexcept # Sets ``res`` to the low ``trunc`` coefficients of ``poly`` # (assumed to be zero padded if necessary to length ``trunc``) to # the power ``e``. This is equivalent to doing a powering followed @@ -550,12 +550,12 @@ cdef extern from "flint_wrap.h": # ``e > 1``. Aliasing is not permitted. Uses the binary # exponentiation method. - void fq_nmod_poly_pow_trunc_binexp(fq_nmod_poly_t res, const fq_nmod_poly_t poly, ulong e, slong trunc, const fq_nmod_ctx_t ctx) + void fq_nmod_poly_pow_trunc_binexp(fq_nmod_poly_t res, const fq_nmod_poly_t poly, ulong e, slong trunc, const fq_nmod_ctx_t ctx) noexcept # Sets ``res`` to the low ``trunc`` coefficients of ``poly`` # to the power ``e``. This is equivalent to doing a powering # followed by a truncation. Uses the binary exponentiation method. - void _fq_nmod_poly_pow_trunc(fq_nmod_struct * res, const fq_nmod_struct * poly, ulong e, slong trunc, const fq_nmod_ctx_t mod) + void _fq_nmod_poly_pow_trunc(fq_nmod_struct * res, const fq_nmod_struct * poly, ulong e, slong trunc, const fq_nmod_ctx_t mod) noexcept # Sets ``res`` to the low ``trunc`` coefficients of ``poly`` # (assumed to be zero padded if necessary to length ``trunc``) to # the power ``e``. This is equivalent to doing a powering followed @@ -563,12 +563,12 @@ cdef extern from "flint_wrap.h": # ``trunc`` coefficients, that ``trunc > 0`` and that # ``e > 1``. Aliasing is not permitted. - void fq_nmod_poly_pow_trunc(fq_nmod_poly_t res, const fq_nmod_poly_t poly, ulong e, slong trunc, const fq_nmod_ctx_t ctx) + void fq_nmod_poly_pow_trunc(fq_nmod_poly_t res, const fq_nmod_poly_t poly, ulong e, slong trunc, const fq_nmod_ctx_t ctx) noexcept # Sets ``res`` to the low ``trunc`` coefficients of ``poly`` # to the power ``e``. This is equivalent to doing a powering # followed by a truncation. - void _fq_nmod_poly_shift_left(fq_nmod_struct *rop, const fq_nmod_struct *op, slong len, slong n, const fq_nmod_ctx_t ctx) + void _fq_nmod_poly_shift_left(fq_nmod_struct *rop, const fq_nmod_struct *op, slong len, slong n, const fq_nmod_ctx_t ctx) noexcept # Sets ``(rop, len + n)`` to ``(op, len)`` shifted left by # `n` coefficients. # Inserts zero coefficients at the lower end. Assumes that @@ -576,11 +576,11 @@ cdef extern from "flint_wrap.h": # ``len + n`` elements. Supports aliasing between ``rop`` and # ``op``. - void fq_nmod_poly_shift_left(fq_nmod_poly_t rop, const fq_nmod_poly_t op, slong n, const fq_nmod_ctx_t ctx) + void fq_nmod_poly_shift_left(fq_nmod_poly_t rop, const fq_nmod_poly_t op, slong n, const fq_nmod_ctx_t ctx) noexcept # Sets ``rop`` to ``op`` shifted left by `n` coeffs. Zero # coefficients are inserted. - void _fq_nmod_poly_shift_right(fq_nmod_struct *rop, const fq_nmod_struct *op, slong len, slong n, const fq_nmod_ctx_t ctx) + void _fq_nmod_poly_shift_right(fq_nmod_struct *rop, const fq_nmod_struct *op, slong len, slong n, const fq_nmod_ctx_t ctx) noexcept # Sets ``(rop, len - n)`` to ``(op, len)`` shifted right by # `n` coefficients. # Assumes that ``len`` and `n` are positive, that ``len > n``, @@ -588,18 +588,18 @@ cdef extern from "flint_wrap.h": # aliasing between ``rop`` and ``op``, although in this case # the top coefficients of ``op`` are not set to zero. - void fq_nmod_poly_shift_right(fq_nmod_poly_t rop, const fq_nmod_poly_t op, slong n, const fq_nmod_ctx_t ctx) + void fq_nmod_poly_shift_right(fq_nmod_poly_t rop, const fq_nmod_poly_t op, slong n, const fq_nmod_ctx_t ctx) noexcept # Sets ``rop`` to ``op`` shifted right by `n` coefficients. # If `n` is equal to or greater than the current length of # ``op``, ``rop`` is set to the zero polynomial. - slong _fq_nmod_poly_hamming_weight(const fq_nmod_struct *op, slong len, const fq_nmod_ctx_t ctx) + slong _fq_nmod_poly_hamming_weight(const fq_nmod_struct *op, slong len, const fq_nmod_ctx_t ctx) noexcept # Returns the number of non-zero entries in ``(op, len)``. - slong fq_nmod_poly_hamming_weight(const fq_nmod_poly_t op, const fq_nmod_ctx_t ctx) + slong fq_nmod_poly_hamming_weight(const fq_nmod_poly_t op, const fq_nmod_ctx_t ctx) noexcept # Returns the number of non-zero entries in the polynomial ``op``. - void _fq_nmod_poly_divrem(fq_nmod_struct *Q, fq_nmod_struct *R, const fq_nmod_struct *A, slong lenA, const fq_nmod_struct *B, slong lenB, const fq_nmod_t invB, const fq_nmod_ctx_t ctx) + void _fq_nmod_poly_divrem(fq_nmod_struct *Q, fq_nmod_struct *R, const fq_nmod_struct *A, slong lenA, const fq_nmod_struct *B, slong lenB, const fq_nmod_t invB, const fq_nmod_ctx_t ctx) noexcept # Computes ``(Q, lenA - lenB + 1)``, ``(R, lenA)`` such that # `A = B Q + R` with `0 \leq \operatorname{len}(R) < \operatorname{len}(B)`. # Assumes that the leading coefficient of `B` is invertible @@ -608,14 +608,14 @@ cdef extern from "flint_wrap.h": # ``(A, lenA)``. `R` and `A` may be aliased, but apart from # this no aliasing of input and output operands is allowed. - void fq_nmod_poly_divrem(fq_nmod_poly_t Q, fq_nmod_poly_t R, const fq_nmod_poly_t A, const fq_nmod_poly_t B, const fq_nmod_ctx_t ctx) + void fq_nmod_poly_divrem(fq_nmod_poly_t Q, fq_nmod_poly_t R, const fq_nmod_poly_t A, const fq_nmod_poly_t B, const fq_nmod_ctx_t ctx) noexcept # Computes `Q`, `R` such that `A = B Q + R` with # `0 \leq \operatorname{len}(R) < \operatorname{len}(B)`. # Assumes that the leading coefficient of `B` is invertible. This can # be taken for granted the context is for a finite field, that is, when # `p` is prime and `f(X)` is irreducible. - void fq_nmod_poly_divrem_f(fq_nmod_t f, fq_nmod_poly_t Q, fq_nmod_poly_t R, const fq_nmod_poly_t A, const fq_nmod_poly_t B, const fq_nmod_ctx_t ctx) + void fq_nmod_poly_divrem_f(fq_nmod_t f, fq_nmod_poly_t Q, fq_nmod_poly_t R, const fq_nmod_poly_t A, const fq_nmod_poly_t B, const fq_nmod_ctx_t ctx) noexcept # Either finds a non-trivial factor `f` of the modulus of # ``ctx``, or computes `Q`, `R` such that `A = B Q + R` and # `0 \leq \operatorname{len}(R) < \operatorname{len}(B)`. @@ -625,27 +625,27 @@ cdef extern from "flint_wrap.h": # non-trivial factor of the modulus and `Q` and `R` are not touched. # Assumes that `B` is non-zero. - void _fq_nmod_poly_rem(fq_nmod_struct *R, const fq_nmod_struct *A, slong lenA, const fq_nmod_struct *B, slong lenB, const fq_nmod_t invB, const fq_nmod_ctx_t ctx) + void _fq_nmod_poly_rem(fq_nmod_struct *R, const fq_nmod_struct *A, slong lenA, const fq_nmod_struct *B, slong lenB, const fq_nmod_t invB, const fq_nmod_ctx_t ctx) noexcept # Sets ``R`` to the remainder of the division of ``(A,lenA)`` by # ``(B,lenB)``. Assumes that the leading coefficient of ``(B,lenB)`` # is invertible and that ``invB`` is its inverse. - void fq_nmod_poly_rem(fq_nmod_poly_t R, const fq_nmod_poly_t A, const fq_nmod_poly_t B, const fq_nmod_ctx_t ctx) + void fq_nmod_poly_rem(fq_nmod_poly_t R, const fq_nmod_poly_t A, const fq_nmod_poly_t B, const fq_nmod_ctx_t ctx) noexcept # Sets ``R`` to the remainder of the division of ``A`` by # ``B`` in the context described by ``ctx``. - void _fq_nmod_poly_div(fq_nmod_struct *Q, const fq_nmod_struct *A, slong lenA, const fq_nmod_struct *B, slong lenB, const fq_nmod_t invB, const fq_nmod_ctx_t ctx) + void _fq_nmod_poly_div(fq_nmod_struct *Q, const fq_nmod_struct *A, slong lenA, const fq_nmod_struct *B, slong lenB, const fq_nmod_t invB, const fq_nmod_ctx_t ctx) noexcept # Notationally, computes `Q`, `R` such that `A = B Q + R` with `0 # \leq \operatorname{len}(R) < \operatorname{len}(B)` but only sets ``(Q, lenA - lenB + 1)``. # Allows zero-padding in `A` but not in `B`. Assumes that the leading coefficient of `B` is a # unit. - void fq_nmod_poly_div(fq_nmod_poly_t Q, const fq_nmod_poly_t A, const fq_nmod_poly_t B, const fq_nmod_ctx_t ctx) + void fq_nmod_poly_div(fq_nmod_poly_t Q, const fq_nmod_poly_t A, const fq_nmod_poly_t B, const fq_nmod_ctx_t ctx) noexcept # Notionally finds polynomials `Q` and `R` such that `A = B Q + R` with # `\operatorname{len}(R) < \operatorname{len}(B)`, but returns only ``Q``. If `\operatorname{len}(B) = 0` an # exception is raised. - void _fq_nmod_poly_div_newton_n_preinv(fq_nmod_struct* Q, const fq_nmod_struct* A, slong lenA, const fq_nmod_struct* B, slong lenB, const fq_nmod_struct* Binv, slong lenBinv, const fq_nmod_ctx_t ctx) + void _fq_nmod_poly_div_newton_n_preinv(fq_nmod_struct* Q, const fq_nmod_struct* A, slong lenA, const fq_nmod_struct* B, slong lenB, const fq_nmod_struct* Binv, slong lenBinv, const fq_nmod_ctx_t ctx) noexcept # Notionally computes polynomials `Q` and `R` such that `A = BQ + R` with # `\operatorname{len}(R)` less than ``lenB``, where ``A`` is of length ``lenA`` # and ``B`` is of length ``lenB``, but return only `Q`. @@ -655,7 +655,7 @@ cdef extern from "flint_wrap.h": # The algorithm used is to reverse the polynomials and divide the # resulting power series, then reverse the result. - void fq_nmod_poly_div_newton_n_preinv(fq_nmod_poly_t Q, const fq_nmod_poly_t A, const fq_nmod_poly_t B, const fq_nmod_poly_t Binv, const fq_nmod_ctx_t ctx) + void fq_nmod_poly_div_newton_n_preinv(fq_nmod_poly_t Q, const fq_nmod_poly_t A, const fq_nmod_poly_t B, const fq_nmod_poly_t Binv, const fq_nmod_ctx_t ctx) noexcept # Notionally computes `Q` and `R` such that `A = BQ + R` with # `\operatorname{len}(R) < \operatorname{len}(B)`, but returns only `Q`. # We assume that the leading coefficient of `B` is a unit and that `Binv` is @@ -665,7 +665,7 @@ cdef extern from "flint_wrap.h": # The algorithm used is to reverse the polynomials and divide the # resulting power series, then reverse the result. - void _fq_nmod_poly_divrem_newton_n_preinv(fq_nmod_struct* Q, fq_nmod_struct* R, const fq_nmod_struct* A, slong lenA, const fq_nmod_struct* B, slong lenB, const fq_nmod_struct* Binv, slong lenBinv, const fq_nmod_ctx_t ctx) + void _fq_nmod_poly_divrem_newton_n_preinv(fq_nmod_struct* Q, fq_nmod_struct* R, const fq_nmod_struct* A, slong lenA, const fq_nmod_struct* B, slong lenB, const fq_nmod_struct* Binv, slong lenBinv, const fq_nmod_ctx_t ctx) noexcept # Computes `Q` and `R` such that `A = BQ + R` with `\operatorname{len}(R)` less # than ``lenB``, where `A` is of length ``lenA`` and `B` is of # length ``lenB``. We require that `Q` have space for @@ -674,7 +674,7 @@ cdef extern from "flint_wrap.h": # used is to call :func:`div_newton_preinv` and then multiply out # and compute the remainder. - void fq_nmod_poly_divrem_newton_n_preinv(fq_nmod_poly_t Q, fq_nmod_poly_t R, const fq_nmod_poly_t A, const fq_nmod_poly_t B, const fq_nmod_poly_t Binv, const fq_nmod_ctx_t ctx) + void fq_nmod_poly_divrem_newton_n_preinv(fq_nmod_poly_t Q, fq_nmod_poly_t R, const fq_nmod_poly_t A, const fq_nmod_poly_t B, const fq_nmod_poly_t Binv, const fq_nmod_ctx_t ctx) noexcept # Computes `Q` and `R` such that `A = BQ + R` with `\operatorname{len}(R) < # \operatorname{len}(B)`. We assume `Binv` is the inverse of the reverse of `B` # mod `x^{\operatorname{len}(B)}`. @@ -683,43 +683,43 @@ cdef extern from "flint_wrap.h": # The algorithm used is to call :func:`div_newton` and then # multiply out and compute the remainder. - void _fq_nmod_poly_inv_series_newton(fq_nmod_struct* Qinv, const fq_nmod_struct* Q, slong n, const fq_nmod_t cinv, const fq_nmod_ctx_t ctx) + void _fq_nmod_poly_inv_series_newton(fq_nmod_struct* Qinv, const fq_nmod_struct* Q, slong n, const fq_nmod_t cinv, const fq_nmod_ctx_t ctx) noexcept # Given ``Q`` of length ``n`` whose constant coefficient is # invertible modulo the given modulus, find a polynomial ``Qinv`` # of length ``n`` such that ``Q * Qinv`` is ``1`` modulo # `x^n`. Requires ``n > 0``. This function can be viewed as # inverting a power series via Newton iteration. - void fq_nmod_poly_inv_series_newton(fq_nmod_poly_t Qinv, const fq_nmod_poly_t Q, slong n, const fq_nmod_ctx_t ctx) + void fq_nmod_poly_inv_series_newton(fq_nmod_poly_t Qinv, const fq_nmod_poly_t Q, slong n, const fq_nmod_ctx_t ctx) noexcept # Given ``Q`` find ``Qinv`` such that ``Q * Qinv`` is # ``1`` modulo `x^n`. The constant coefficient of ``Q`` must # be invertible modulo the modulus of ``Q``. An exception is # raised if this is not the case or if ``n = 0``. This function # can be viewed as inverting a power series via Newton iteration. - void _fq_nmod_poly_inv_series(fq_nmod_struct* Qinv, const fq_nmod_struct* Q, slong n, const fq_nmod_t cinv, const fq_nmod_ctx_t ctx) + void _fq_nmod_poly_inv_series(fq_nmod_struct* Qinv, const fq_nmod_struct* Q, slong n, const fq_nmod_t cinv, const fq_nmod_ctx_t ctx) noexcept # Given ``Q`` of length ``n`` whose constant coefficient is # invertible modulo the given modulus, find a polynomial ``Qinv`` # of length ``n`` such that ``Q * Qinv`` is ``1`` modulo # `x^n`. Requires ``n > 0``. - void fq_nmod_poly_inv_series(fq_nmod_poly_t Qinv, const fq_nmod_poly_t Q, slong n, const fq_nmod_ctx_t ctx) + void fq_nmod_poly_inv_series(fq_nmod_poly_t Qinv, const fq_nmod_poly_t Q, slong n, const fq_nmod_ctx_t ctx) noexcept # Given ``Q`` find ``Qinv`` such that ``Q * Qinv`` is # ``1`` modulo `x^n`. The constant coefficient of ``Q`` must # be invertible modulo the modulus of ``Q``. An exception is # raised if this is not the case or if ``n = 0``. - void _fq_nmod_poly_div_series(fq_nmod_struct *Q, const fq_nmod_struct *A, mp_limb_signed_t Alen, const fq_nmod_struct *B, mp_limb_signed_t Blen, mp_limb_signed_t n, const fq_nmod_ctx_t ctx) + void _fq_nmod_poly_div_series(fq_nmod_struct *Q, const fq_nmod_struct *A, mp_limb_signed_t Alen, const fq_nmod_struct *B, mp_limb_signed_t Blen, mp_limb_signed_t n, const fq_nmod_ctx_t ctx) noexcept # Set ``(Q, n)`` to the quotient of the series ``(A, Alen``) and # ``(B, Blen)`` assuming ``Alen, Blen <= n``. We assume the bottom # coefficient of ``B`` is invertible. - void fq_nmod_poly_div_series(fq_nmod_poly_t Q, const fq_nmod_poly_t A, const fq_nmod_poly_t B, slong n, fq_nmod_ctx_t ctx) + void fq_nmod_poly_div_series(fq_nmod_poly_t Q, const fq_nmod_poly_t A, const fq_nmod_poly_t B, slong n, fq_nmod_ctx_t ctx) noexcept # Set `Q` to the quotient of the series `A` by `B`, thinking of the series as # though they were of length `n`. We assume that the bottom coefficient of # `B` is invertible. - void fq_nmod_poly_gcd(fq_nmod_poly_t rop, const fq_nmod_poly_t op1, const fq_nmod_poly_t op2, const fq_nmod_ctx_t ctx) + void fq_nmod_poly_gcd(fq_nmod_poly_t rop, const fq_nmod_poly_t op1, const fq_nmod_poly_t op2, const fq_nmod_ctx_t ctx) noexcept # Sets ``rop`` to the greatest common divisor of ``op1`` and # ``op2``, using the either the Euclidean or HGCD algorithm. The # GCD of zero polynomials is defined to be zero, whereas the GCD of @@ -727,14 +727,14 @@ cdef extern from "flint_wrap.h": # `P`. Except in the case where the GCD is zero, the GCD `G` is made # monic. - slong _fq_nmod_poly_gcd(fq_nmod_struct* G, const fq_nmod_struct* A, slong lenA, const fq_nmod_struct* B, slong lenB, const fq_nmod_ctx_t ctx) + slong _fq_nmod_poly_gcd(fq_nmod_struct* G, const fq_nmod_struct* A, slong lenA, const fq_nmod_struct* B, slong lenB, const fq_nmod_ctx_t ctx) noexcept # Computes the GCD of `A` of length ``lenA`` and `B` of length # ``lenB``, where ``lenA >= lenB > 0`` and sets `G` to it. The # length of the GCD `G` is returned by the function. No attempt is # made to make the GCD monic. It is required that `G` have space for # ``lenB`` coefficients. - slong _fq_nmod_poly_gcd_euclidean_f(fq_nmod_t f, fq_nmod_struct *G, const fq_nmod_struct *A, slong lenA, const fq_nmod_struct *B, slong lenB, const fq_nmod_ctx_t ctx) + slong _fq_nmod_poly_gcd_euclidean_f(fq_nmod_t f, fq_nmod_struct *G, const fq_nmod_struct *A, slong lenA, const fq_nmod_struct *B, slong lenB, const fq_nmod_ctx_t ctx) noexcept # Either sets `f = 1` and `G` to the greatest common divisor of # `(A,\operatorname{len}(A))` and `(B, \operatorname{len}(B))` and returns its length, or sets # `f` to a non-trivial factor of the modulus of ``ctx`` and leaves @@ -742,11 +742,11 @@ cdef extern from "flint_wrap.h": # Assumes that `\operatorname{len}(A) \geq \operatorname{len}(B) > 0` and that the vector `G` # has space for sufficiently many coefficients. - void fq_nmod_poly_gcd_euclidean_f(fq_nmod_t f, fq_nmod_poly_t G, const fq_nmod_poly_t A, const fq_nmod_poly_t B, const fq_nmod_ctx_t ctx) + void fq_nmod_poly_gcd_euclidean_f(fq_nmod_t f, fq_nmod_poly_t G, const fq_nmod_poly_t A, const fq_nmod_poly_t B, const fq_nmod_ctx_t ctx) noexcept # Either sets `f = 1` and `G` to the greatest common divisor of `A` # and `B` or sets `f` to a factor of the modulus of ``ctx``. - slong _fq_nmod_poly_xgcd(fq_nmod_struct *G, fq_nmod_struct *S, fq_nmod_struct *T, const fq_nmod_struct *A, slong lenA, const fq_nmod_struct *B, slong lenB, const fq_nmod_ctx_t ctx) + slong _fq_nmod_poly_xgcd(fq_nmod_struct *G, fq_nmod_struct *S, fq_nmod_struct *T, const fq_nmod_struct *A, slong lenA, const fq_nmod_struct *B, slong lenB, const fq_nmod_ctx_t ctx) noexcept # Computes the GCD of `A` and `B` together with cofactors `S` and `T` # such that `S A + T B = G`. Returns the length of `G`. # Assumes that `\operatorname{len}(A) \geq \operatorname{len}(B) \geq 1` and @@ -758,7 +758,7 @@ cdef extern from "flint_wrap.h": # `\operatorname{len}(T) \leq \max(\operatorname{len}(A) - \operatorname{len}(G), 1)`. # No aliasing of input and output operands is permitted. - void fq_nmod_poly_xgcd(fq_nmod_poly_t G, fq_nmod_poly_t S, fq_nmod_poly_t T, const fq_nmod_poly_t A, const fq_nmod_poly_t B, const fq_nmod_ctx_t ctx) + void fq_nmod_poly_xgcd(fq_nmod_poly_t G, fq_nmod_poly_t S, fq_nmod_poly_t T, const fq_nmod_poly_t A, const fq_nmod_poly_t B, const fq_nmod_ctx_t ctx) noexcept # Computes the GCD of `A` and `B`. The GCD of zero polynomials is # defined to be zero, whereas the GCD of the zero polynomial and some other # polynomial `P` is defined to be `P`. Except in the case where @@ -767,7 +767,7 @@ cdef extern from "flint_wrap.h": # ``S*A + T*B = G``. The length of ``S`` will be at most # ``lenB`` and the length of ``T`` will be at most ``lenA``. - slong _fq_nmod_poly_xgcd_euclidean_f(fq_nmod_t f, fq_nmod_struct *G, fq_nmod_struct *S, fq_nmod_struct *T, const fq_nmod_struct *A, slong lenA, const fq_nmod_struct *B, slong lenB, const fq_nmod_ctx_t ctx) + slong _fq_nmod_poly_xgcd_euclidean_f(fq_nmod_t f, fq_nmod_struct *G, fq_nmod_struct *S, fq_nmod_struct *T, const fq_nmod_struct *A, slong lenA, const fq_nmod_struct *B, slong lenB, const fq_nmod_ctx_t ctx) noexcept # Either sets `f = 1` and computes the GCD of `A` and `B` together # with cofactors `S` and `T` such that `S A + T B = G`; otherwise, # sets `f` to a non-trivial factor of the modulus of ``ctx`` and @@ -781,7 +781,7 @@ cdef extern from "flint_wrap.h": # `\operatorname{len}(T) \leq \max(\operatorname{len}(A) - \operatorname{len}(G), 1)`. # No aliasing of input and output operands is permitted. - void fq_nmod_poly_xgcd_euclidean_f(fq_nmod_t f, fq_nmod_poly_t G, fq_nmod_poly_t S, fq_nmod_poly_t T, const fq_nmod_poly_t A, const fq_nmod_poly_t B, const fq_nmod_ctx_t ctx) + void fq_nmod_poly_xgcd_euclidean_f(fq_nmod_t f, fq_nmod_poly_t G, fq_nmod_poly_t S, fq_nmod_poly_t T, const fq_nmod_poly_t A, const fq_nmod_poly_t B, const fq_nmod_ctx_t ctx) noexcept # Either sets `f = 1` and computes the GCD of `A` and `B` or sets # `f` to a non-trivial factor of the modulus of ``ctx``. # If the GCD is computed, polynomials ``S`` and ``T`` are @@ -793,7 +793,7 @@ cdef extern from "flint_wrap.h": # be `P`. Except in the case where the GCD is zero, the GCD `G` is # made monic. - int _fq_nmod_poly_divides(fq_nmod_struct *Q, const fq_nmod_struct *A, slong lenA, const fq_nmod_struct *B, slong lenB, const fq_nmod_t invB, const fq_nmod_ctx_t ctx) + int _fq_nmod_poly_divides(fq_nmod_struct *Q, const fq_nmod_struct *A, slong lenA, const fq_nmod_struct *B, slong lenB, const fq_nmod_t invB, const fq_nmod_ctx_t ctx) noexcept # Returns `1` if ``(B, lenB)`` divides ``(A, lenA)`` exactly and # sets `Q` to the quotient, otherwise returns `0`. # It is assumed that `\operatorname{len}(A) \geq \operatorname{len}(B) > 0` and that `Q` has space @@ -802,57 +802,57 @@ cdef extern from "flint_wrap.h": # This function is currently unoptimised and provided for convenience # only. - int fq_nmod_poly_divides(fq_nmod_poly_t Q, const fq_nmod_poly_t A, const fq_nmod_poly_t B, const fq_nmod_ctx_t ctx) + int fq_nmod_poly_divides(fq_nmod_poly_t Q, const fq_nmod_poly_t A, const fq_nmod_poly_t B, const fq_nmod_ctx_t ctx) noexcept # Returns `1` if `B` divides `A` exactly and sets `Q` to the quotient, # otherwise returns `0`. # This function is currently unoptimised and provided for convenience # only. - void _fq_nmod_poly_derivative(fq_nmod_struct *rop, const fq_nmod_struct *op, slong len, const fq_nmod_ctx_t ctx) + void _fq_nmod_poly_derivative(fq_nmod_struct *rop, const fq_nmod_struct *op, slong len, const fq_nmod_ctx_t ctx) noexcept # Sets ``(rop, len - 1)`` to the derivative of ``(op, len)``. # Also handles the cases where ``len`` is `0` or `1` correctly. # Supports aliasing of ``rop`` and ``op``. - void fq_nmod_poly_derivative(fq_nmod_poly_t rop, const fq_nmod_poly_t op, const fq_nmod_ctx_t ctx) + void fq_nmod_poly_derivative(fq_nmod_poly_t rop, const fq_nmod_poly_t op, const fq_nmod_ctx_t ctx) noexcept # Sets ``rop`` to the derivative of ``op``. - void _fq_nmod_poly_invsqrt_series(fq_nmod_struct * g, const fq_nmod_struct * h, slong n, fq_nmod_ctx_t mod) + void _fq_nmod_poly_invsqrt_series(fq_nmod_struct * g, const fq_nmod_struct * h, slong n, fq_nmod_ctx_t mod) noexcept # Set the first `n` terms of `g` to the series expansion of `1/\sqrt{h}`. # It is assumed that `n > 0`, that `h` has constant term 1 and that `h` # is zero-padded as necessary to length `n`. Aliasing is not permitted. - void fq_nmod_poly_invsqrt_series(fq_nmod_poly_t g, const fq_nmod_poly_t h, slong n, fq_nmod_ctx_t ctx) + void fq_nmod_poly_invsqrt_series(fq_nmod_poly_t g, const fq_nmod_poly_t h, slong n, fq_nmod_ctx_t ctx) noexcept # Set `g` to the series expansion of `1/\sqrt{h}` to order `O(x^n)`. # It is assumed that `h` has constant term 1. - void _fq_nmod_poly_sqrt_series(fq_nmod_struct * g, const fq_nmod_struct * h, slong n, fq_nmod_ctx_t ctx) + void _fq_nmod_poly_sqrt_series(fq_nmod_struct * g, const fq_nmod_struct * h, slong n, fq_nmod_ctx_t ctx) noexcept # Set the first `n` terms of `g` to the series expansion of `\sqrt{h}`. # It is assumed that `n > 0`, that `h` has constant term 1 and that `h` # is zero-padded as necessary to length `n`. Aliasing is not permitted. - void fq_nmod_poly_sqrt_series(fq_nmod_poly_t g, const fq_nmod_poly_t h, slong n, fq_nmod_ctx_t ctx) + void fq_nmod_poly_sqrt_series(fq_nmod_poly_t g, const fq_nmod_poly_t h, slong n, fq_nmod_ctx_t ctx) noexcept # Set `g` to the series expansion of `\sqrt{h}` to order `O(x^n)`. # It is assumed that `h` has constant term 1. - int _fq_nmod_poly_sqrt(fq_nmod_struct * s, const fq_nmod_struct * p, slong n, fq_nmod_ctx_t mod) + int _fq_nmod_poly_sqrt(fq_nmod_struct * s, const fq_nmod_struct * p, slong n, fq_nmod_ctx_t mod) noexcept # If ``(p, n)`` is a perfect square, sets ``(s, n / 2 + 1)`` # to a square root of `p` and returns 1. Otherwise returns 0. - int fq_nmod_poly_sqrt(fq_nmod_poly_t s, const fq_nmod_poly_t p, fq_nmod_ctx_t mod) + int fq_nmod_poly_sqrt(fq_nmod_poly_t s, const fq_nmod_poly_t p, fq_nmod_ctx_t mod) noexcept # If `p` is a perfect square, sets `s` to a square root of `p` # and returns 1. Otherwise returns 0. - void _fq_nmod_poly_evaluate_fq_nmod(fq_nmod_t rop, const fq_nmod_struct *op, slong len, const fq_nmod_t a, const fq_nmod_ctx_t ctx) + void _fq_nmod_poly_evaluate_fq_nmod(fq_nmod_t rop, const fq_nmod_struct *op, slong len, const fq_nmod_t a, const fq_nmod_ctx_t ctx) noexcept # Sets ``rop`` to ``(op, len)`` evaluated at `a`. # Supports zero padding. There are no restrictions on ``len``, that # is, ``len`` is allowed to be zero, too. - void fq_nmod_poly_evaluate_fq_nmod(fq_nmod_t rop, const fq_nmod_poly_t f, const fq_nmod_t a, const fq_nmod_ctx_t ctx) + void fq_nmod_poly_evaluate_fq_nmod(fq_nmod_t rop, const fq_nmod_poly_t f, const fq_nmod_t a, const fq_nmod_ctx_t ctx) noexcept # Sets ``rop`` to the value of `f(a)`. # As the coefficient ring `\mathbf{F}_q` is finite, Horner's method # is sufficient. - void _fq_nmod_poly_compose(fq_nmod_struct *rop, const fq_nmod_struct *op1, slong len1, const fq_nmod_struct *op2, slong len2, const fq_nmod_ctx_t ctx) + void _fq_nmod_poly_compose(fq_nmod_struct *rop, const fq_nmod_struct *op1, slong len1, const fq_nmod_struct *op2, slong len2, const fq_nmod_ctx_t ctx) noexcept # Sets ``rop`` to the composition of ``(op1, len1)`` and # ``(op2, len2)``. # Assumes that ``rop`` has space for ``(len1-1)*(len2-1) + 1`` @@ -860,24 +860,24 @@ cdef extern from "flint_wrap.h": # polynomials. Does not support aliasing between any of the inputs and # the output. - void fq_nmod_poly_compose(fq_nmod_poly_t rop, const fq_nmod_poly_t op1, const fq_nmod_poly_t op2, const fq_nmod_ctx_t ctx) + void fq_nmod_poly_compose(fq_nmod_poly_t rop, const fq_nmod_poly_t op1, const fq_nmod_poly_t op2, const fq_nmod_ctx_t ctx) noexcept # Sets ``rop`` to the composition of ``op1`` and ``op2``. # To be precise about the order of composition, denoting ``rop``, # ``op1``, and ``op2`` by `f`, `g`, and `h`, respectively, # sets `f(t) = g(h(t))`. - void _fq_nmod_poly_compose_mod_horner(fq_nmod_struct * res, const fq_nmod_struct * f, slong lenf, const fq_nmod_struct * g, const fq_nmod_struct * h, slong lenh, const fq_nmod_ctx_t ctx) + void _fq_nmod_poly_compose_mod_horner(fq_nmod_struct * res, const fq_nmod_struct * f, slong lenf, const fq_nmod_struct * g, const fq_nmod_struct * h, slong lenh, const fq_nmod_ctx_t ctx) noexcept # Sets ``res`` to the composition `f(g)` modulo `h`. We require that # `h` is nonzero and that the length of `g` is one less than the # length of `h` (possibly with zero padding). The output is not allowed # to be aliased with any of the inputs. # The algorithm used is Horner's rule. - void fq_nmod_poly_compose_mod_horner(fq_nmod_poly_t res, const fq_nmod_poly_t f, const fq_nmod_poly_t g, const fq_nmod_poly_t h, const fq_nmod_ctx_t ctx) + void fq_nmod_poly_compose_mod_horner(fq_nmod_poly_t res, const fq_nmod_poly_t f, const fq_nmod_poly_t g, const fq_nmod_poly_t h, const fq_nmod_ctx_t ctx) noexcept # Sets ``res`` to the composition `f(g)` modulo `h`. We require that # `h` is nonzero. The algorithm used is Horner's rule. - void _fq_nmod_poly_compose_mod_horner_preinv(fq_nmod_struct * res, const fq_nmod_struct * f, slong lenf, const fq_nmod_struct * g, const fq_nmod_struct * h, slong lenh, const fq_nmod_struct * hinv, slong lenhiv, const fq_nmod_ctx_t ctx) + void _fq_nmod_poly_compose_mod_horner_preinv(fq_nmod_struct * res, const fq_nmod_struct * f, slong lenf, const fq_nmod_struct * g, const fq_nmod_struct * h, slong lenh, const fq_nmod_struct * hinv, slong lenhiv, const fq_nmod_ctx_t ctx) noexcept # Sets ``res`` to the composition `f(g)` modulo `h`. We require # that `h` is nonzero and that the length of `g` is one less than # the length of `h` (possibly with zero padding). We also require @@ -887,13 +887,13 @@ cdef extern from "flint_wrap.h": # any of the inputs. # The algorithm used is Horner's rule. - void fq_nmod_poly_compose_mod_horner_preinv(fq_nmod_poly_t res, const fq_nmod_poly_t f, const fq_nmod_poly_t g, const fq_nmod_poly_t h, const fq_nmod_poly_t hinv, const fq_nmod_ctx_t ctx) + void fq_nmod_poly_compose_mod_horner_preinv(fq_nmod_poly_t res, const fq_nmod_poly_t f, const fq_nmod_poly_t g, const fq_nmod_poly_t h, const fq_nmod_poly_t hinv, const fq_nmod_ctx_t ctx) noexcept # Sets ``res`` to the composition `f(g)` modulo `h`. We require # that `h` is nonzero and that `f` has smaller degree than # `h`. Furthermore, we require ``hinv`` to be the inverse of the # reverse of ``h``. The algorithm used is Horner's rule. - void _fq_nmod_poly_compose_mod_brent_kung(fq_nmod_struct * res, const fq_nmod_struct * f, slong lenf, const fq_nmod_struct * g, const fq_nmod_struct * h, slong lenh, const fq_nmod_ctx_t ctx) + void _fq_nmod_poly_compose_mod_brent_kung(fq_nmod_struct * res, const fq_nmod_struct * f, slong lenf, const fq_nmod_struct * g, const fq_nmod_struct * h, slong lenh, const fq_nmod_ctx_t ctx) noexcept # Sets ``res`` to the composition `f(g)` modulo `h`. We require # that `h` is nonzero and that the length of `g` is one less than # the length of `h` (possibly with zero padding). We also require @@ -901,12 +901,12 @@ cdef extern from "flint_wrap.h": # is not allowed to be aliased with any of the inputs. # The algorithm used is the Brent-Kung matrix algorithm. - void fq_nmod_poly_compose_mod_brent_kung(fq_nmod_poly_t res, const fq_nmod_poly_t f, const fq_nmod_poly_t g, const fq_nmod_poly_t h, const fq_nmod_ctx_t ctx) + void fq_nmod_poly_compose_mod_brent_kung(fq_nmod_poly_t res, const fq_nmod_poly_t f, const fq_nmod_poly_t g, const fq_nmod_poly_t h, const fq_nmod_ctx_t ctx) noexcept # Sets ``res`` to the composition `f(g)` modulo `h`. We require # that `h` is nonzero and that `f` has smaller degree than `h`. The # algorithm used is the Brent-Kung matrix algorithm. - void _fq_nmod_poly_compose_mod_brent_kung_preinv(fq_nmod_struct * res, const fq_nmod_struct * f, slong lenf, const fq_nmod_struct * g, const fq_nmod_struct * h, slong lenh, const fq_nmod_struct * hinv, slong lenhiv, const fq_nmod_ctx_t ctx) + void _fq_nmod_poly_compose_mod_brent_kung_preinv(fq_nmod_struct * res, const fq_nmod_struct * f, slong lenf, const fq_nmod_struct * g, const fq_nmod_struct * h, slong lenh, const fq_nmod_struct * hinv, slong lenhiv, const fq_nmod_ctx_t ctx) noexcept # Sets ``res`` to the composition `f(g)` modulo `h`. We require # that `h` is nonzero and that the length of `g` is one less than # the length of `h` (possibly with zero padding). We also require @@ -916,24 +916,24 @@ cdef extern from "flint_wrap.h": # any of the inputs. # The algorithm used is the Brent-Kung matrix algorithm. - void fq_nmod_poly_compose_mod_brent_kung_preinv(fq_nmod_poly_t res, const fq_nmod_poly_t f, const fq_nmod_poly_t g, const fq_nmod_poly_t h, const fq_nmod_poly_t hinv, const fq_nmod_ctx_t ctx) + void fq_nmod_poly_compose_mod_brent_kung_preinv(fq_nmod_poly_t res, const fq_nmod_poly_t f, const fq_nmod_poly_t g, const fq_nmod_poly_t h, const fq_nmod_poly_t hinv, const fq_nmod_ctx_t ctx) noexcept # Sets ``res`` to the composition `f(g)` modulo `h`. We require # that `h` is nonzero and that `f` has smaller degree than # `h`. Furthermore, we require ``hinv`` to be the inverse of the # reverse of ``h``. The algorithm used is the Brent-Kung matrix # algorithm. - void _fq_nmod_poly_compose_mod(fq_nmod_struct * res, const fq_nmod_struct * f, slong lenf, const fq_nmod_struct * g, const fq_nmod_struct * h, slong lenh, const fq_nmod_ctx_t ctx) + void _fq_nmod_poly_compose_mod(fq_nmod_struct * res, const fq_nmod_struct * f, slong lenf, const fq_nmod_struct * g, const fq_nmod_struct * h, slong lenh, const fq_nmod_ctx_t ctx) noexcept # Sets ``res`` to the composition `f(g)` modulo `h`. We require # that `h` is nonzero and that the length of `g` is one less than # the length of `h` (possibly with zero padding). The output is not # allowed to be aliased with any of the inputs. - void fq_nmod_poly_compose_mod(fq_nmod_poly_t res, const fq_nmod_poly_t f, const fq_nmod_poly_t g, const fq_nmod_poly_t h, const fq_nmod_ctx_t ctx) + void fq_nmod_poly_compose_mod(fq_nmod_poly_t res, const fq_nmod_poly_t f, const fq_nmod_poly_t g, const fq_nmod_poly_t h, const fq_nmod_ctx_t ctx) noexcept # Sets ``res`` to the composition `f(g)` modulo `h`. We require # that `h` is nonzero. - void _fq_nmod_poly_compose_mod_preinv(fq_nmod_struct * res, const fq_nmod_struct * f, slong lenf, const fq_nmod_struct * g, const fq_nmod_struct * h, slong lenh, const fq_nmod_struct * hinv, slong lenhiv, const fq_nmod_ctx_t ctx) + void _fq_nmod_poly_compose_mod_preinv(fq_nmod_struct * res, const fq_nmod_struct * f, slong lenf, const fq_nmod_struct * g, const fq_nmod_struct * h, slong lenh, const fq_nmod_struct * hinv, slong lenhiv, const fq_nmod_ctx_t ctx) noexcept # Sets ``res`` to the composition `f(g)` modulo `h`. We require # that `h` is nonzero and that the length of `g` is one less than # the length of `h` (possibly with zero padding). We also require @@ -942,30 +942,30 @@ cdef extern from "flint_wrap.h": # reverse of ``h``. The output is not allowed to be aliased with # any of the inputs. - void fq_nmod_poly_compose_mod_preinv(fq_nmod_poly_t res, const fq_nmod_poly_t f, const fq_nmod_poly_t g, const fq_nmod_poly_t h, const fq_nmod_poly_t hinv, const fq_nmod_ctx_t ctx) + void fq_nmod_poly_compose_mod_preinv(fq_nmod_poly_t res, const fq_nmod_poly_t f, const fq_nmod_poly_t g, const fq_nmod_poly_t h, const fq_nmod_poly_t hinv, const fq_nmod_ctx_t ctx) noexcept # Sets ``res`` to the composition `f(g)` modulo `h`. We require # that `h` is nonzero and that `f` has smaller degree than # `h`. Furthermore, we require ``hinv`` to be the inverse of the # reverse of ``h``. - void _fq_nmod_poly_reduce_matrix_mod_poly (fq_nmod_mat_t A, const fq_nmod_mat_t B, const fq_nmod_poly_t f, const fq_nmod_ctx_t ctx) + void _fq_nmod_poly_reduce_matrix_mod_poly (fq_nmod_mat_t A, const fq_nmod_mat_t B, const fq_nmod_poly_t f, const fq_nmod_ctx_t ctx) noexcept # Sets the ith row of ``A`` to the reduction of the ith row of `B` modulo # `f` for `i=1,\ldots,\sqrt{\deg(f)}`. We require `B` to be at least # a `\sqrt{\deg(f)}\times \deg(f)` matrix and `f` to be nonzero. - void _fq_nmod_poly_precompute_matrix (fq_nmod_mat_t A, const fq_nmod_struct* f, const fq_nmod_struct* g, slong leng, const fq_nmod_struct* ginv, slong lenginv, const fq_nmod_ctx_t ctx) + void _fq_nmod_poly_precompute_matrix (fq_nmod_mat_t A, const fq_nmod_struct* f, const fq_nmod_struct* g, slong leng, const fq_nmod_struct* ginv, slong lenginv, const fq_nmod_ctx_t ctx) noexcept # Sets the ith row of ``A`` to `f^i` modulo `g` for # `i=1,\ldots,\sqrt{\deg(g)}`. We require `A` to be a # `\sqrt{\deg(g)}\times \deg(g)` matrix. We require ``ginv`` to # be the inverse of the reverse of ``g`` and `g` to be nonzero. - void fq_nmod_poly_precompute_matrix (fq_nmod_mat_t A, const fq_nmod_poly_t f, const fq_nmod_poly_t g, const fq_nmod_poly_t ginv, const fq_nmod_ctx_t ctx) + void fq_nmod_poly_precompute_matrix (fq_nmod_mat_t A, const fq_nmod_poly_t f, const fq_nmod_poly_t g, const fq_nmod_poly_t ginv, const fq_nmod_ctx_t ctx) noexcept # Sets the ith row of ``A`` to `f^i` modulo `g` for # `i=1,\ldots,\sqrt{\deg(g)}`. We require `A` to be a # `\sqrt{\deg(g)}\times \deg(g)` matrix. We require ``ginv`` to # be the inverse of the reverse of ``g``. - void _fq_nmod_poly_compose_mod_brent_kung_precomp_preinv(fq_nmod_struct* res, const fq_nmod_struct* f, slong lenf, const fq_nmod_mat_t A, const fq_nmod_struct* h, slong lenh, const fq_nmod_struct* hinv, slong lenhinv, const fq_nmod_ctx_t ctx) + void _fq_nmod_poly_compose_mod_brent_kung_precomp_preinv(fq_nmod_struct* res, const fq_nmod_struct* f, slong lenf, const fq_nmod_mat_t A, const fq_nmod_struct* h, slong lenh, const fq_nmod_struct* hinv, slong lenhinv, const fq_nmod_ctx_t ctx) noexcept # Sets ``res`` to the composition `f(g)` modulo `h`. We require # that `h` is nonzero. We require that the ith row of `A` contains # `g^i` for `i=1,\ldots,\sqrt{\deg(h)}`, i.e. `A` is a @@ -975,7 +975,7 @@ cdef extern from "flint_wrap.h": # The output is not allowed to be aliased with any of the inputs. # The algorithm used is the Brent-Kung matrix algorithm. - void fq_nmod_poly_compose_mod_brent_kung_precomp_preinv(fq_nmod_poly_t res, const fq_nmod_poly_t f, const fq_nmod_mat_t A, const fq_nmod_poly_t h, const fq_nmod_poly_t hinv, const fq_nmod_ctx_t ctx) + void fq_nmod_poly_compose_mod_brent_kung_precomp_preinv(fq_nmod_poly_t res, const fq_nmod_poly_t f, const fq_nmod_mat_t A, const fq_nmod_poly_t h, const fq_nmod_poly_t hinv, const fq_nmod_ctx_t ctx) noexcept # Sets ``res`` to the composition `f(g)` modulo `h`. We require # that the ith row of `A` contains `g^i` for # `i=1,\ldots,\sqrt{\deg(h)}`, i.e. `A` is a `\sqrt{\deg(h)}\times @@ -986,79 +986,79 @@ cdef extern from "flint_wrap.h": # several modular composition of the form `f(g)` modulo `h` for # fixed `g` and `h`. - int _fq_nmod_poly_fprint_pretty(FILE *file, const fq_nmod_struct *poly, slong len, const char *x, const fq_nmod_ctx_t ctx) + int _fq_nmod_poly_fprint_pretty(FILE *file, const fq_nmod_struct *poly, slong len, const char *x, const fq_nmod_ctx_t ctx) noexcept # Prints the pretty representation of ``(poly, len)`` to the stream # ``file``, using the string ``x`` to represent the indeterminate. # In case of success, returns a positive value. In case of failure, # returns a non-positive value. - int fq_nmod_poly_fprint_pretty(FILE * file, const fq_nmod_poly_t poly, const char *x, const fq_nmod_ctx_t ctx) + int fq_nmod_poly_fprint_pretty(FILE * file, const fq_nmod_poly_t poly, const char *x, const fq_nmod_ctx_t ctx) noexcept # Prints the pretty representation of ``poly`` to the stream # ``file``, using the string ``x`` to represent the indeterminate. # In case of success, returns a positive value. In case of failure, # returns a non-positive value. - int _fq_nmod_poly_print_pretty(const fq_nmod_struct *poly, slong len, const char *x, const fq_nmod_ctx_t ctx) + int _fq_nmod_poly_print_pretty(const fq_nmod_struct *poly, slong len, const char *x, const fq_nmod_ctx_t ctx) noexcept # Prints the pretty representation of ``(poly, len)`` to ``stdout``, # using the string ``x`` to represent the indeterminate. # In case of success, returns a positive value. In case of failure, # returns a non-positive value. - int fq_nmod_poly_print_pretty(const fq_nmod_poly_t poly, const char *x, const fq_nmod_ctx_t ctx) + int fq_nmod_poly_print_pretty(const fq_nmod_poly_t poly, const char *x, const fq_nmod_ctx_t ctx) noexcept # Prints the pretty representation of ``poly`` to ``stdout``, # using the string ``x`` to represent the indeterminate. # In case of success, returns a positive value. In case of failure, # returns a non-positive value. - int _fq_nmod_poly_fprint(FILE *file, const fq_nmod_struct *poly, slong len, const fq_nmod_ctx_t ctx) + int _fq_nmod_poly_fprint(FILE *file, const fq_nmod_struct *poly, slong len, const fq_nmod_ctx_t ctx) noexcept # Prints the pretty representation of ``(poly, len)`` to the stream # ``file``. # In case of success, returns a positive value. In case of failure, # returns a non-positive value. - int fq_nmod_poly_fprint(FILE * file, const fq_nmod_poly_t poly, const fq_nmod_ctx_t ctx) + int fq_nmod_poly_fprint(FILE * file, const fq_nmod_poly_t poly, const fq_nmod_ctx_t ctx) noexcept # Prints the pretty representation of ``poly`` to the stream # ``file``. # In case of success, returns a positive value. In case of failure, # returns a non-positive value. - int _fq_nmod_poly_print(const fq_nmod_struct *poly, slong len, const fq_nmod_ctx_t ctx) + int _fq_nmod_poly_print(const fq_nmod_struct *poly, slong len, const fq_nmod_ctx_t ctx) noexcept # Prints the pretty representation of ``(poly, len)`` to ``stdout``. # In case of success, returns a positive value. In case of failure, # returns a non-positive value. - int fq_nmod_poly_print(const fq_nmod_poly_t poly, const fq_nmod_ctx_t ctx) + int fq_nmod_poly_print(const fq_nmod_poly_t poly, const fq_nmod_ctx_t ctx) noexcept # Prints the representation of ``poly`` to ``stdout``. # In case of success, returns a positive value. In case of failure, # returns a non-positive value. - char * _fq_nmod_poly_get_str(const fq_nmod_struct * poly, slong len, const fq_nmod_ctx_t ctx) + char * _fq_nmod_poly_get_str(const fq_nmod_struct * poly, slong len, const fq_nmod_ctx_t ctx) noexcept # Returns the plain FLINT string representation of the polynomial # ``(poly, len)``. - char * fq_nmod_poly_get_str(const fq_nmod_poly_t poly, const fq_nmod_ctx_t ctx) + char * fq_nmod_poly_get_str(const fq_nmod_poly_t poly, const fq_nmod_ctx_t ctx) noexcept # Returns the plain FLINT string representation of the polynomial # ``poly``. - char * _fq_nmod_poly_get_str_pretty(const fq_nmod_struct * poly, slong len, const char * x, const fq_nmod_ctx_t ctx) + char * _fq_nmod_poly_get_str_pretty(const fq_nmod_struct * poly, slong len, const char * x, const fq_nmod_ctx_t ctx) noexcept # Returns a pretty representation of the polynomial # ``(poly, len)`` using the null-terminated string ``x`` as the # variable name. - char * fq_nmod_poly_get_str_pretty(const fq_nmod_poly_t poly, const char * x, const fq_nmod_ctx_t ctx) + char * fq_nmod_poly_get_str_pretty(const fq_nmod_poly_t poly, const char * x, const fq_nmod_ctx_t ctx) noexcept # Returns a pretty representation of the polynomial ``poly`` using the # null-terminated string ``x`` as the variable name - void fq_nmod_poly_inflate(fq_nmod_poly_t result, const fq_nmod_poly_t input, ulong inflation, const fq_nmod_ctx_t ctx) + void fq_nmod_poly_inflate(fq_nmod_poly_t result, const fq_nmod_poly_t input, ulong inflation, const fq_nmod_ctx_t ctx) noexcept # Sets ``result`` to the inflated polynomial `p(x^n)` where # `p` is given by ``input`` and `n` is given by ``inflation``. - void fq_nmod_poly_deflate(fq_nmod_poly_t result, const fq_nmod_poly_t input, ulong deflation, const fq_nmod_ctx_t ctx) + void fq_nmod_poly_deflate(fq_nmod_poly_t result, const fq_nmod_poly_t input, ulong deflation, const fq_nmod_ctx_t ctx) noexcept # Sets ``result`` to the deflated polynomial `p(x^{1/n})` where # `p` is given by ``input`` and `n` is given by ``deflation``. # Requires `n > 0`. - ulong fq_nmod_poly_deflation(const fq_nmod_poly_t input, const fq_nmod_ctx_t ctx) + ulong fq_nmod_poly_deflation(const fq_nmod_poly_t input, const fq_nmod_ctx_t ctx) noexcept # Returns the largest integer by which ``input`` can be deflated. # As special cases, returns 0 if ``input`` is the zero polynomial # and 1 of ``input`` is a constant polynomial. diff --git a/src/sage/libs/flint/fq_nmod_poly_factor.pxd b/src/sage/libs/flint/fq_nmod_poly_factor.pxd index 84684bad90b..304d1a4f1a9 100644 --- a/src/sage/libs/flint/fq_nmod_poly_factor.pxd +++ b/src/sage/libs/flint/fq_nmod_poly_factor.pxd @@ -12,91 +12,91 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void fq_nmod_poly_factor_init(fq_nmod_poly_factor_t fac, const fq_nmod_ctx_t ctx) + void fq_nmod_poly_factor_init(fq_nmod_poly_factor_t fac, const fq_nmod_ctx_t ctx) noexcept # Initialises ``fac`` for use. An :type:`fq_nmod_poly_factor_t` # represents a polynomial in factorised form as a product of # polynomials with associated exponents. - void fq_nmod_poly_factor_clear(fq_nmod_poly_factor_t fac, const fq_nmod_ctx_t ctx) + void fq_nmod_poly_factor_clear(fq_nmod_poly_factor_t fac, const fq_nmod_ctx_t ctx) noexcept # Frees all memory associated with ``fac``. - void fq_nmod_poly_factor_realloc(fq_nmod_poly_factor_t fac, slong alloc, const fq_nmod_ctx_t ctx) + void fq_nmod_poly_factor_realloc(fq_nmod_poly_factor_t fac, slong alloc, const fq_nmod_ctx_t ctx) noexcept # Reallocates the factor structure to provide space for # precisely ``alloc`` factors. - void fq_nmod_poly_factor_fit_length(fq_nmod_poly_factor_t fac, slong len, const fq_nmod_ctx_t ctx) + void fq_nmod_poly_factor_fit_length(fq_nmod_poly_factor_t fac, slong len, const fq_nmod_ctx_t ctx) noexcept # Ensures that the factor structure has space for at least # ``len`` factors. This function takes care of the case of # repeated calls by always at least doubling the number of factors # the structure can hold. - void fq_nmod_poly_factor_set(fq_nmod_poly_factor_t res, const fq_nmod_poly_factor_t fac, const fq_nmod_ctx_t ctx) + void fq_nmod_poly_factor_set(fq_nmod_poly_factor_t res, const fq_nmod_poly_factor_t fac, const fq_nmod_ctx_t ctx) noexcept # Sets ``res`` to the same factorisation as ``fac``. - void fq_nmod_poly_factor_print_pretty(const fq_nmod_poly_factor_t fac, const char * var, const fq_nmod_ctx_t ctx) + void fq_nmod_poly_factor_print_pretty(const fq_nmod_poly_factor_t fac, const char * var, const fq_nmod_ctx_t ctx) noexcept # Pretty-prints the entries of ``fac`` to standard output. - void fq_nmod_poly_factor_print(const fq_nmod_poly_factor_t fac, const fq_nmod_ctx_t ctx) + void fq_nmod_poly_factor_print(const fq_nmod_poly_factor_t fac, const fq_nmod_ctx_t ctx) noexcept # Prints the entries of ``fac`` to standard output. - void fq_nmod_poly_factor_insert(fq_nmod_poly_factor_t fac, const fq_nmod_poly_t poly, slong exp, const fq_nmod_ctx_t ctx) + void fq_nmod_poly_factor_insert(fq_nmod_poly_factor_t fac, const fq_nmod_poly_t poly, slong exp, const fq_nmod_ctx_t ctx) noexcept # Inserts the factor ``poly`` with multiplicity ``exp`` into # the factorisation ``fac``. # If ``fac`` already contains ``poly``, then ``exp`` simply # gets added to the exponent of the existing entry. - void fq_nmod_poly_factor_concat(fq_nmod_poly_factor_t res, const fq_nmod_poly_factor_t fac, const fq_nmod_ctx_t ctx) + void fq_nmod_poly_factor_concat(fq_nmod_poly_factor_t res, const fq_nmod_poly_factor_t fac, const fq_nmod_ctx_t ctx) noexcept # Concatenates two factorisations. # This is equivalent to calling :func:`fq_nmod_poly_factor_insert` # repeatedly with the individual factors of ``fac``. # Does not support aliasing between ``res`` and ``fac``. - void fq_nmod_poly_factor_pow(fq_nmod_poly_factor_t fac, slong exp, const fq_nmod_ctx_t ctx) + void fq_nmod_poly_factor_pow(fq_nmod_poly_factor_t fac, slong exp, const fq_nmod_ctx_t ctx) noexcept # Raises ``fac`` to the power ``exp``. - ulong fq_nmod_poly_remove(fq_nmod_poly_t f, const fq_nmod_poly_t p, const fq_nmod_ctx_t ctx) + ulong fq_nmod_poly_remove(fq_nmod_poly_t f, const fq_nmod_poly_t p, const fq_nmod_ctx_t ctx) noexcept # Removes the highest possible power of ``p`` from ``f`` and # returns the exponent. - bint fq_nmod_poly_is_irreducible(const fq_nmod_poly_t f, const fq_nmod_ctx_t ctx) + bint fq_nmod_poly_is_irreducible(const fq_nmod_poly_t f, const fq_nmod_ctx_t ctx) noexcept # Returns 1 if the polynomial ``f`` is irreducible, otherwise returns 0. - bint fq_nmod_poly_is_irreducible_ddf(const fq_nmod_poly_t f, const fq_nmod_ctx_t ctx) + bint fq_nmod_poly_is_irreducible_ddf(const fq_nmod_poly_t f, const fq_nmod_ctx_t ctx) noexcept # Returns 1 if the polynomial ``f`` is irreducible, otherwise returns 0. # Uses fast distinct-degree factorisation. - bint fq_nmod_poly_is_irreducible_ben_or(const fq_nmod_poly_t f, const fq_nmod_ctx_t ctx) + bint fq_nmod_poly_is_irreducible_ben_or(const fq_nmod_poly_t f, const fq_nmod_ctx_t ctx) noexcept # Returns 1 if the polynomial ``f`` is irreducible, otherwise returns 0. # Uses Ben-Or's irreducibility test. - bint _fq_nmod_poly_is_squarefree(const fq_nmod_struct * f, slong len, const fq_nmod_ctx_t ctx) + bint _fq_nmod_poly_is_squarefree(const fq_nmod_struct * f, slong len, const fq_nmod_ctx_t ctx) noexcept # Returns 1 if ``(f, len)`` is squarefree, and 0 otherwise. As a # special case, the zero polynomial is not considered squarefree. # There are no restrictions on the length. - bint fq_nmod_poly_is_squarefree(const fq_nmod_poly_t f, const fq_nmod_ctx_t ctx) + bint fq_nmod_poly_is_squarefree(const fq_nmod_poly_t f, const fq_nmod_ctx_t ctx) noexcept # Returns 1 if ``f`` is squarefree, and 0 otherwise. As a special # case, the zero polynomial is not considered squarefree. - bint fq_nmod_poly_factor_equal_deg_prob(fq_nmod_poly_t factor, flint_rand_t state, const fq_nmod_poly_t pol, slong d, const fq_nmod_ctx_t ctx) + bint fq_nmod_poly_factor_equal_deg_prob(fq_nmod_poly_t factor, flint_rand_t state, const fq_nmod_poly_t pol, slong d, const fq_nmod_ctx_t ctx) noexcept # Probabilistic equal degree factorisation of ``pol`` into # irreducible factors of degree ``d``. If it passes, a factor is # placed in factor and 1 is returned, otherwise 0 is returned and # the value of factor is undetermined. # Requires that ``pol`` be monic, non-constant and squarefree. - void fq_nmod_poly_factor_equal_deg(fq_nmod_poly_factor_t factors, const fq_nmod_poly_t pol, slong d, const fq_nmod_ctx_t ctx) + void fq_nmod_poly_factor_equal_deg(fq_nmod_poly_factor_t factors, const fq_nmod_poly_t pol, slong d, const fq_nmod_ctx_t ctx) noexcept # Assuming ``pol`` is a product of irreducible factors all of # degree ``d``, finds all those factors and places them in # factors. Requires that ``pol`` be monic, non-constant and # squarefree. - void fq_nmod_poly_factor_split_single(fq_nmod_poly_t linfactor, const fq_nmod_poly_t input, const fq_nmod_ctx_t ctx) + void fq_nmod_poly_factor_split_single(fq_nmod_poly_t linfactor, const fq_nmod_poly_t input, const fq_nmod_ctx_t ctx) noexcept # Assuming ``input`` is a product of factors all of degree 1, finds a single # linear factor of ``input`` and places it in ``linfactor``. # Requires that ``input`` be monic and non-constant. - void fq_nmod_poly_factor_distinct_deg(fq_nmod_poly_factor_t res, const fq_nmod_poly_t poly, slong * const *degs, const fq_nmod_ctx_t ctx) + void fq_nmod_poly_factor_distinct_deg(fq_nmod_poly_factor_t res, const fq_nmod_poly_t poly, slong * const *degs, const fq_nmod_ctx_t ctx) noexcept # Factorises a monic non-constant squarefree polynomial ``poly`` # of degree `n` into factors `f[d]` such that for `1 \leq d \leq n` # `f[d]` is the product of the monic irreducible factors of @@ -106,31 +106,31 @@ cdef extern from "flint_wrap.h": # Requires that ``degs`` have enough space for irreducible polynomials' # powers (maximum space required is `n * sizeof(slong)`). - void fq_nmod_poly_factor_squarefree(fq_nmod_poly_factor_t res, const fq_nmod_poly_t f, const fq_nmod_ctx_t ctx) + void fq_nmod_poly_factor_squarefree(fq_nmod_poly_factor_t res, const fq_nmod_poly_t f, const fq_nmod_ctx_t ctx) noexcept # Sets ``res`` to a squarefree factorization of ``f``. - void fq_nmod_poly_factor(fq_nmod_poly_factor_t res, fq_nmod_t lead, const fq_nmod_poly_t f, const fq_nmod_ctx_t ctx) + void fq_nmod_poly_factor(fq_nmod_poly_factor_t res, fq_nmod_t lead, const fq_nmod_poly_t f, const fq_nmod_ctx_t ctx) noexcept # Factorises a non-constant polynomial ``f`` into monic # irreducible factors choosing the best algorithm for given modulo # and degree. The output ``lead`` is set to the leading coefficient of `f` # upon return. Choice of algorithm is based on heuristic measurements. - void fq_nmod_poly_factor_cantor_zassenhaus(fq_nmod_poly_factor_t res, const fq_nmod_poly_t f, const fq_nmod_ctx_t ctx) + void fq_nmod_poly_factor_cantor_zassenhaus(fq_nmod_poly_factor_t res, const fq_nmod_poly_t f, const fq_nmod_ctx_t ctx) noexcept # Factorises a non-constant polynomial ``f`` into monic # irreducible factors using the Cantor-Zassenhaus algorithm. - void fq_nmod_poly_factor_kaltofen_shoup(fq_nmod_poly_factor_t res, const fq_nmod_poly_t poly, const fq_nmod_ctx_t ctx) + void fq_nmod_poly_factor_kaltofen_shoup(fq_nmod_poly_factor_t res, const fq_nmod_poly_t poly, const fq_nmod_ctx_t ctx) noexcept # Factorises a non-constant polynomial ``f`` into monic # irreducible factors using the fast version of Cantor-Zassenhaus # algorithm proposed by Kaltofen and Shoup (1998). More precisely # this algorithm uses a “baby step/giant step” strategy for the # distinct-degree factorization step. - void fq_nmod_poly_factor_berlekamp(fq_nmod_poly_factor_t factors, const fq_nmod_poly_t f, const fq_nmod_ctx_t ctx) + void fq_nmod_poly_factor_berlekamp(fq_nmod_poly_factor_t factors, const fq_nmod_poly_t f, const fq_nmod_ctx_t ctx) noexcept # Factorises a non-constant polynomial ``f`` into monic # irreducible factors using the Berlekamp algorithm. - void fq_nmod_poly_factor_with_berlekamp(fq_nmod_poly_factor_t res, fq_nmod_t leading_coeff, const fq_nmod_poly_t f, const fq_nmod_ctx_t ctx) + void fq_nmod_poly_factor_with_berlekamp(fq_nmod_poly_factor_t res, fq_nmod_t leading_coeff, const fq_nmod_poly_t f, const fq_nmod_ctx_t ctx) noexcept # Factorises a general polynomial ``f`` into monic irreducible # factors and sets ``leading_coeff`` to the leading coefficient # of ``f``, or 0 if ``f`` is the zero polynomial. @@ -139,7 +139,7 @@ cdef extern from "flint_wrap.h": # performs a square-free factorisation, and finally runs Berlekamp # on all the individual square-free factors. - void fq_nmod_poly_factor_with_cantor_zassenhaus(fq_nmod_poly_factor_t res, fq_nmod_t leading_coeff, const fq_nmod_poly_t f, const fq_nmod_ctx_t ctx) + void fq_nmod_poly_factor_with_cantor_zassenhaus(fq_nmod_poly_factor_t res, fq_nmod_t leading_coeff, const fq_nmod_poly_t f, const fq_nmod_ctx_t ctx) noexcept # Factorises a general polynomial ``f`` into monic irreducible # factors and sets ``leading_coeff`` to the leading coefficient # of ``f``, or 0 if ``f`` is the zero polynomial. @@ -148,7 +148,7 @@ cdef extern from "flint_wrap.h": # performs a square-free factorisation, and finally runs # Cantor-Zassenhaus on all the individual square-free factors. - void fq_nmod_poly_factor_with_kaltofen_shoup(fq_nmod_poly_factor_t res, fq_nmod_t leading_coeff, const fq_nmod_poly_t f, const fq_nmod_ctx_t ctx) + void fq_nmod_poly_factor_with_kaltofen_shoup(fq_nmod_poly_factor_t res, fq_nmod_t leading_coeff, const fq_nmod_poly_t f, const fq_nmod_ctx_t ctx) noexcept # Factorises a general polynomial ``f`` into monic irreducible # factors and sets ``leading_coeff`` to the leading coefficient # of ``f``, or 0 if ``f`` is the zero polynomial. @@ -157,12 +157,12 @@ cdef extern from "flint_wrap.h": # performs a square-free factorisation, and finally runs # Kaltofen-Shoup on all the individual square-free factors. - void fq_nmod_poly_iterated_frobenius_preinv(fq_nmod_poly_t *rop, slong n, const fq_nmod_poly_t v, const fq_nmod_poly_t vinv, const fq_nmod_ctx_t ctx) + void fq_nmod_poly_iterated_frobenius_preinv(fq_nmod_poly_t *rop, slong n, const fq_nmod_poly_t v, const fq_nmod_poly_t vinv, const fq_nmod_ctx_t ctx) noexcept # Sets ``rop[i]`` to be `x^{q^i} \bmod v` for `0 \le i < n`. # It is required that ``vinv`` is the inverse of the reverse of # ``v`` mod ``x^lenv``. - void fq_nmod_poly_roots(fq_nmod_poly_factor_t r, const fq_nmod_poly_t f, int with_multiplicity, const fq_nmod_ctx_t ctx) + void fq_nmod_poly_roots(fq_nmod_poly_factor_t r, const fq_nmod_poly_t f, int with_multiplicity, const fq_nmod_ctx_t ctx) noexcept # Fill `r` with factors of the form `x - r_i` where the `r_i` are the distinct roots of a nonzero `f` in `F_q`. # If `with\_multiplicity` is zero, the exponent `e_i` of the factor `x - r_i` is `1`. Otherwise, it is the largest `e_i` such that `(x-r_i)^e_i` divides `f`. # This function throws if `f` is zero, but is otherwise always successful. diff --git a/src/sage/libs/flint/fq_nmod_vec.pxd b/src/sage/libs/flint/fq_nmod_vec.pxd index 6bbf21fe295..3901d06488e 100644 --- a/src/sage/libs/flint/fq_nmod_vec.pxd +++ b/src/sage/libs/flint/fq_nmod_vec.pxd @@ -12,62 +12,62 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - fq_nmod_struct * _fq_nmod_vec_init(slong len, const fq_nmod_ctx_t ctx) + fq_nmod_struct * _fq_nmod_vec_init(slong len, const fq_nmod_ctx_t ctx) noexcept # Returns an initialised vector of ``fq_nmod``'s of given length. - void _fq_nmod_vec_clear(fq_nmod_struct * vec, slong len, const fq_nmod_ctx_t ctx) + void _fq_nmod_vec_clear(fq_nmod_struct * vec, slong len, const fq_nmod_ctx_t ctx) noexcept # Clears the entries of ``(vec, len)`` and frees the space allocated # for ``vec``. - void _fq_nmod_vec_randtest(fq_nmod_struct * f, flint_rand_t state, slong len, const fq_nmod_ctx_t ctx) + void _fq_nmod_vec_randtest(fq_nmod_struct * f, flint_rand_t state, slong len, const fq_nmod_ctx_t ctx) noexcept # Sets the entries of a vector of the given length to elements of # the finite field. - int _fq_nmod_vec_fprint(FILE * file, const fq_nmod_struct * vec, slong len, const fq_nmod_ctx_t ctx) + int _fq_nmod_vec_fprint(FILE * file, const fq_nmod_struct * vec, slong len, const fq_nmod_ctx_t ctx) noexcept # Prints the vector of given length to the stream ``file``. The # format is the length followed by two spaces, then a space separated # list of coefficients. If the length is zero, only `0` is printed. # In case of success, returns a positive value. In case of failure, # returns a non-positive value. - int _fq_nmod_vec_print(const fq_nmod_struct * vec, slong len, const fq_nmod_ctx_t ctx) + int _fq_nmod_vec_print(const fq_nmod_struct * vec, slong len, const fq_nmod_ctx_t ctx) noexcept # Prints the vector of given length to ``stdout``. # For further details, see ``_fq_nmod_vec_fprint()``. - void _fq_nmod_vec_set(fq_nmod_struct * vec1, const fq_nmod_struct * vec2, slong len2, const fq_nmod_ctx_t ctx) + void _fq_nmod_vec_set(fq_nmod_struct * vec1, const fq_nmod_struct * vec2, slong len2, const fq_nmod_ctx_t ctx) noexcept # Makes a copy of ``(vec2, len2)`` into ``vec1``. - void _fq_nmod_vec_swap(fq_nmod_struct * vec1, fq_nmod_struct * vec2, slong len2, const fq_nmod_ctx_t ctx) + void _fq_nmod_vec_swap(fq_nmod_struct * vec1, fq_nmod_struct * vec2, slong len2, const fq_nmod_ctx_t ctx) noexcept # Swaps the elements in ``(vec1, len2)`` and ``(vec2, len2)``. - void _fq_nmod_vec_zero(fq_nmod_struct * vec, slong len, const fq_nmod_ctx_t ctx) + void _fq_nmod_vec_zero(fq_nmod_struct * vec, slong len, const fq_nmod_ctx_t ctx) noexcept # Zeros the entries of ``(vec, len)``. - void _fq_nmod_vec_neg(fq_nmod_struct * vec1, const fq_nmod_struct * vec2, slong len2, const fq_nmod_ctx_t ctx) + void _fq_nmod_vec_neg(fq_nmod_struct * vec1, const fq_nmod_struct * vec2, slong len2, const fq_nmod_ctx_t ctx) noexcept # Negates ``(vec2, len2)`` and places it into ``vec1``. - bint _fq_nmod_vec_equal(const fq_nmod_struct * vec1, const fq_nmod_struct * vec2, slong len, const fq_nmod_ctx_t ctx) + bint _fq_nmod_vec_equal(const fq_nmod_struct * vec1, const fq_nmod_struct * vec2, slong len, const fq_nmod_ctx_t ctx) noexcept # Compares two vectors of the given length and returns `1` if they are # equal, otherwise returns `0`. - bint _fq_nmod_vec_is_zero(const fq_nmod_struct * vec, slong len, const fq_nmod_ctx_t ctx) + bint _fq_nmod_vec_is_zero(const fq_nmod_struct * vec, slong len, const fq_nmod_ctx_t ctx) noexcept # Returns `1` if ``(vec, len)`` is zero, and `0` otherwise. - void _fq_nmod_vec_add(fq_nmod_struct * res, const fq_nmod_struct * vec1, const fq_nmod_struct * vec2, slong len2, const fq_nmod_ctx_t ctx) + void _fq_nmod_vec_add(fq_nmod_struct * res, const fq_nmod_struct * vec1, const fq_nmod_struct * vec2, slong len2, const fq_nmod_ctx_t ctx) noexcept # Sets ``(res, len2)`` to the sum of ``(vec1, len2)`` # and ``(vec2, len2)``. - void _fq_nmod_vec_sub(fq_nmod_struct * res, const fq_nmod_struct * vec1, const fq_nmod_struct * vec2, slong len2, const fq_nmod_ctx_t ctx) + void _fq_nmod_vec_sub(fq_nmod_struct * res, const fq_nmod_struct * vec1, const fq_nmod_struct * vec2, slong len2, const fq_nmod_ctx_t ctx) noexcept # Sets ``(res, len2)`` to ``(vec1, len2)`` minus ``(vec2, len2)``. - void _fq_nmod_vec_scalar_addmul_fq_nmod(fq_nmod_struct * vec1, const fq_nmod_struct * vec2, slong len2, const fq_nmod_t c, const fq_nmod_ctx_t ctx) + void _fq_nmod_vec_scalar_addmul_fq_nmod(fq_nmod_struct * vec1, const fq_nmod_struct * vec2, slong len2, const fq_nmod_t c, const fq_nmod_ctx_t ctx) noexcept # Adds ``(vec2, len2)`` times `c` to ``(vec1, len2)``, where # `c` is a ``fq_nmod_t``. - void _fq_nmod_vec_scalar_submul_fq_nmod(fq_nmod_struct * vec1, const fq_nmod_struct * vec2, slong len2, const fq_nmod_t c, const fq_nmod_ctx_t ctx) + void _fq_nmod_vec_scalar_submul_fq_nmod(fq_nmod_struct * vec1, const fq_nmod_struct * vec2, slong len2, const fq_nmod_t c, const fq_nmod_ctx_t ctx) noexcept # Subtracts ``(vec2, len2)`` times `c` from ``(vec1, len2)``, # where `c` is a ``fq_nmod_t``. - void _fq_nmod_vec_dot(fq_nmod_t res, const fq_nmod_struct * vec1, const fq_nmod_struct * vec2, slong len2, const fq_nmod_ctx_t ctx) + void _fq_nmod_vec_dot(fq_nmod_t res, const fq_nmod_struct * vec1, const fq_nmod_struct * vec2, slong len2, const fq_nmod_ctx_t ctx) noexcept # Sets ``res`` to the dot product of (``vec1``, ``len``) # and (``vec2``, ``len``). diff --git a/src/sage/libs/flint/fq_poly.pxd b/src/sage/libs/flint/fq_poly.pxd index dcea06d428a..8b9efb8b8c8 100644 --- a/src/sage/libs/flint/fq_poly.pxd +++ b/src/sage/libs/flint/fq_poly.pxd @@ -12,27 +12,27 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void fq_poly_init(fq_poly_t poly, const fq_ctx_t ctx) + void fq_poly_init(fq_poly_t poly, const fq_ctx_t ctx) noexcept # Initialises ``poly`` for use, with context ctx, and setting its # length to zero. A corresponding call to :func:`fq_poly_clear` # must be made after finishing with the ``fq_poly_t`` to free the # memory used by the polynomial. - void fq_poly_init2(fq_poly_t poly, slong alloc, const fq_ctx_t ctx) + void fq_poly_init2(fq_poly_t poly, slong alloc, const fq_ctx_t ctx) noexcept # Initialises ``poly`` with space for at least ``alloc`` # coefficients and sets the length to zero. The allocated # coefficients are all set to zero. A corresponding call to # :func:`fq_poly_clear` must be made after finishing with the # ``fq_poly_t`` to free the memory used by the polynomial. - void fq_poly_realloc(fq_poly_t poly, slong alloc, const fq_ctx_t ctx) + void fq_poly_realloc(fq_poly_t poly, slong alloc, const fq_ctx_t ctx) noexcept # Reallocates the given polynomial to have space for ``alloc`` # coefficients. If ``alloc`` is zero the polynomial is cleared # and then reinitialised. If the current length is greater than # ``alloc`` the polynomial is first truncated to length # ``alloc``. - void fq_poly_fit_length(fq_poly_t poly, slong len, const fq_ctx_t ctx) + void fq_poly_fit_length(fq_poly_t poly, slong len, const fq_ctx_t ctx) noexcept # If ``len`` is greater than the number of coefficients currently # allocated, then the polynomial is reallocated to have space for at # least ``len`` coefficients. No data is lost when calling this @@ -42,33 +42,33 @@ cdef extern from "flint_wrap.h": # least doubling the number of allocated coefficients when length is # larger than the number of coefficients currently allocated. - void _fq_poly_set_length(fq_poly_t poly, slong newlen, const fq_ctx_t ctx) + void _fq_poly_set_length(fq_poly_t poly, slong newlen, const fq_ctx_t ctx) noexcept # Sets the coefficients of ``poly`` beyond ``len`` to zero and # sets the length of ``poly`` to ``len``. - void fq_poly_clear(fq_poly_t poly, const fq_ctx_t ctx) + void fq_poly_clear(fq_poly_t poly, const fq_ctx_t ctx) noexcept # Clears the given polynomial, releasing any memory used. It must # be reinitialised in order to be used again. - void _fq_poly_normalise(fq_poly_t poly, const fq_ctx_t ctx) + void _fq_poly_normalise(fq_poly_t poly, const fq_ctx_t ctx) noexcept # Sets the length of ``poly`` so that the top coefficient is # non-zero. If all coefficients are zero, the length is set to # zero. This function is mainly used internally, as all functions # guarantee normalisation. - void _fq_poly_normalise2(const fq_struct *poly, slong *length, const fq_ctx_t ctx) + void _fq_poly_normalise2(const fq_struct *poly, slong *length, const fq_ctx_t ctx) noexcept # Sets the length ``length`` of ``(poly,length)`` so that the # top coefficient is non-zero. If all coefficients are zero, the # length is set to zero. This function is mainly used internally, as # all functions guarantee normalisation. - void fq_poly_truncate(fq_poly_t poly, slong newlen, const fq_ctx_t ctx) + void fq_poly_truncate(fq_poly_t poly, slong newlen, const fq_ctx_t ctx) noexcept # Truncates the polynomial to length at most `n`. - void fq_poly_set_trunc(fq_poly_t poly1, fq_poly_t poly2, slong newlen, const fq_ctx_t ctx) + void fq_poly_set_trunc(fq_poly_t poly1, fq_poly_t poly2, slong newlen, const fq_ctx_t ctx) noexcept # Sets ``poly1`` to ``poly2`` truncated to length `n`. - void _fq_poly_reverse(fq_struct* output, const fq_struct* input, slong len, slong m, const fq_ctx_t ctx) + void _fq_poly_reverse(fq_struct* output, const fq_struct* input, slong len, slong m, const fq_ctx_t ctx) noexcept # Sets ``output`` to the reverse of ``input``, which is of # length ``len``, but thinking of it as a polynomial of # length ``m``, notionally zero-padded if necessary. The @@ -76,198 +76,198 @@ cdef extern from "flint_wrap.h": # restrictions. The polynomial ``output`` must have space for # ``m`` coefficients. - void fq_poly_reverse(fq_poly_t output, const fq_poly_t input, slong m, const fq_ctx_t ctx) + void fq_poly_reverse(fq_poly_t output, const fq_poly_t input, slong m, const fq_ctx_t ctx) noexcept # Sets ``output`` to the reverse of ``input``, thinking of it # as a polynomial of length ``m``, notionally zero-padded if # necessary). The length ``m`` must be non-negative, but there # are no other restrictions. The output polynomial will be set to # length ``m`` and then normalised. - slong fq_poly_degree(const fq_poly_t poly, const fq_ctx_t ctx) + slong fq_poly_degree(const fq_poly_t poly, const fq_ctx_t ctx) noexcept # Returns the degree of the polynomial ``poly``. - slong fq_poly_length(const fq_poly_t poly, const fq_ctx_t ctx) + slong fq_poly_length(const fq_poly_t poly, const fq_ctx_t ctx) noexcept # Returns the length of the polynomial ``poly``. - fq_struct * fq_poly_lead(const fq_poly_t poly, const fq_ctx_t ctx) + fq_struct * fq_poly_lead(const fq_poly_t poly, const fq_ctx_t ctx) noexcept # Returns a pointer to the leading coefficient of ``poly``, or # ``NULL`` if ``poly`` is the zero polynomial. - void fq_poly_randtest(fq_poly_t f, flint_rand_t state, slong len, const fq_ctx_t ctx) + void fq_poly_randtest(fq_poly_t f, flint_rand_t state, slong len, const fq_ctx_t ctx) noexcept # Sets `f` to a random polynomial of length at most ``len`` # with entries in the field described by ``ctx``. - void fq_poly_randtest_not_zero(fq_poly_t f, flint_rand_t state, slong len, const fq_ctx_t ctx) + void fq_poly_randtest_not_zero(fq_poly_t f, flint_rand_t state, slong len, const fq_ctx_t ctx) noexcept # Same as ``fq_poly_randtest`` but guarantees that the polynomial # is not zero. - void fq_poly_randtest_monic(fq_poly_t f, flint_rand_t state, slong len, const fq_ctx_t ctx) + void fq_poly_randtest_monic(fq_poly_t f, flint_rand_t state, slong len, const fq_ctx_t ctx) noexcept # Sets `f` to a random monic polynomial of length ``len`` with # entries in the field described by ``ctx``. - void fq_poly_randtest_irreducible(fq_poly_t f, flint_rand_t state, slong len, const fq_ctx_t ctx) + void fq_poly_randtest_irreducible(fq_poly_t f, flint_rand_t state, slong len, const fq_ctx_t ctx) noexcept # Sets `f` to a random monic, irreducible polynomial of length # ``len`` with entries in the field described by ``ctx``. - void _fq_poly_set(fq_struct *rop, const fq_struct *op, slong len, const fq_ctx_t ctx) + void _fq_poly_set(fq_struct *rop, const fq_struct *op, slong len, const fq_ctx_t ctx) noexcept # Sets ``(rop, len``) to ``(op, len)``. - void fq_poly_set(fq_poly_t poly1, const fq_poly_t poly2, const fq_ctx_t ctx) + void fq_poly_set(fq_poly_t poly1, const fq_poly_t poly2, const fq_ctx_t ctx) noexcept # Sets the polynomial ``poly1`` to the polynomial ``poly2``. - void fq_poly_set_fq(fq_poly_t poly, const fq_t c, const fq_ctx_t ctx) + void fq_poly_set_fq(fq_poly_t poly, const fq_t c, const fq_ctx_t ctx) noexcept # Sets the polynomial ``poly`` to ``c``. - void fq_poly_set_fmpz_mod_poly(fq_poly_t rop, const fmpz_mod_poly_t op, const fq_ctx_t ctx) + void fq_poly_set_fmpz_mod_poly(fq_poly_t rop, const fmpz_mod_poly_t op, const fq_ctx_t ctx) noexcept # Sets the polynomial ``rop`` to the polynomial ``op`` - void fq_poly_set_nmod_poly(fq_poly_t rop, const nmod_poly_t op, const fq_ctx_t ctx) + void fq_poly_set_nmod_poly(fq_poly_t rop, const nmod_poly_t op, const fq_ctx_t ctx) noexcept # Sets the polynomial ``rop`` to the polynomial ``op`` - void fq_poly_swap(fq_poly_t op1, fq_poly_t op2, const fq_ctx_t ctx) + void fq_poly_swap(fq_poly_t op1, fq_poly_t op2, const fq_ctx_t ctx) noexcept # Swaps the two polynomials ``op1`` and ``op2``. - void _fq_poly_zero(fq_struct *rop, slong len, const fq_ctx_t ctx) + void _fq_poly_zero(fq_struct *rop, slong len, const fq_ctx_t ctx) noexcept # Sets ``(rop, len)`` to the zero polynomial. - void fq_poly_zero(fq_poly_t poly, const fq_ctx_t ctx) + void fq_poly_zero(fq_poly_t poly, const fq_ctx_t ctx) noexcept # Sets ``poly`` to the zero polynomial. - void fq_poly_one(fq_poly_t poly, const fq_ctx_t ctx) + void fq_poly_one(fq_poly_t poly, const fq_ctx_t ctx) noexcept # Sets ``poly`` to the constant polynomial `1`. - void fq_poly_gen(fq_poly_t poly, const fq_ctx_t ctx) + void fq_poly_gen(fq_poly_t poly, const fq_ctx_t ctx) noexcept # Sets ``poly`` to the polynomial `x`. - void fq_poly_make_monic(fq_poly_t rop, const fq_poly_t op, const fq_ctx_t ctx) + void fq_poly_make_monic(fq_poly_t rop, const fq_poly_t op, const fq_ctx_t ctx) noexcept # Sets ``rop`` to ``op``, normed to have leading coefficient 1. - void _fq_poly_make_monic(fq_struct *rop, const fq_struct *op, slong length, const fq_ctx_t ctx) + void _fq_poly_make_monic(fq_struct *rop, const fq_struct *op, slong length, const fq_ctx_t ctx) noexcept # Sets ``rop`` to ``(op,length)``, normed to have leading coefficient 1. # Assumes that ``rop`` has enough space for the polynomial, assumes that # ``op`` is not zero (and thus has an invertible leading coefficient). - void fq_poly_get_coeff(fq_t x, const fq_poly_t poly, slong n, const fq_ctx_t ctx) + void fq_poly_get_coeff(fq_t x, const fq_poly_t poly, slong n, const fq_ctx_t ctx) noexcept # Sets `x` to the coefficient of `X^n` in ``poly``. - void fq_poly_set_coeff(fq_poly_t poly, slong n, const fq_t x, const fq_ctx_t ctx) + void fq_poly_set_coeff(fq_poly_t poly, slong n, const fq_t x, const fq_ctx_t ctx) noexcept # Sets the coefficient of `X^n` in ``poly`` to `x`. - void fq_poly_set_coeff_fmpz(fq_poly_t poly, slong n, const fmpz_t x, const fq_ctx_t ctx) + void fq_poly_set_coeff_fmpz(fq_poly_t poly, slong n, const fmpz_t x, const fq_ctx_t ctx) noexcept # Sets the coefficient of `X^n` in the polynomial to `x`, # assuming `n \geq 0`. - bint fq_poly_equal(const fq_poly_t poly1, const fq_poly_t poly2, const fq_ctx_t ctx) + bint fq_poly_equal(const fq_poly_t poly1, const fq_poly_t poly2, const fq_ctx_t ctx) noexcept # Returns nonzero if the two polynomials ``poly1`` and ``poly2`` # are equal, otherwise returns zero. - bint fq_poly_equal_trunc(const fq_poly_t poly1, const fq_poly_t poly2, slong n, const fq_ctx_t ctx) + bint fq_poly_equal_trunc(const fq_poly_t poly1, const fq_poly_t poly2, slong n, const fq_ctx_t ctx) noexcept # Notionally truncate ``poly1`` and ``poly2`` to length `n` and # return nonzero if they are equal, otherwise return zero. - bint fq_poly_is_zero(const fq_poly_t poly, const fq_ctx_t ctx) + bint fq_poly_is_zero(const fq_poly_t poly, const fq_ctx_t ctx) noexcept # Returns whether the polynomial ``poly`` is the zero polynomial. - bint fq_poly_is_one(const fq_poly_t op, const fq_ctx_t ctx) + bint fq_poly_is_one(const fq_poly_t op, const fq_ctx_t ctx) noexcept # Returns whether the polynomial ``poly`` is equal # to the constant polynomial `1`. - bint fq_poly_is_gen(const fq_poly_t op, const fq_ctx_t ctx) + bint fq_poly_is_gen(const fq_poly_t op, const fq_ctx_t ctx) noexcept # Returns whether the polynomial ``poly`` is equal # to the polynomial `x`. - bint fq_poly_is_unit(const fq_poly_t op, const fq_ctx_t ctx) + bint fq_poly_is_unit(const fq_poly_t op, const fq_ctx_t ctx) noexcept # Returns whether the polynomial ``poly`` is a unit in the polynomial # ring `\mathbf{F}_q[X]`, i.e. if it has degree `0` and is non-zero. - bint fq_poly_equal_fq(const fq_poly_t poly, const fq_t c, const fq_ctx_t ctx) + bint fq_poly_equal_fq(const fq_poly_t poly, const fq_t c, const fq_ctx_t ctx) noexcept # Returns whether the polynomial ``poly`` is equal the (constant) # `\mathbf{F}_q` element ``c`` - void _fq_poly_add(fq_struct *res, const fq_struct *poly1, slong len1, const fq_struct *poly2, slong len2, const fq_ctx_t ctx) + void _fq_poly_add(fq_struct *res, const fq_struct *poly1, slong len1, const fq_struct *poly2, slong len2, const fq_ctx_t ctx) noexcept # Sets ``res`` to the sum of ``(poly1,len1)`` and ``(poly2,len2)``. - void fq_poly_add(fq_poly_t res, const fq_poly_t poly1, const fq_poly_t poly2, const fq_ctx_t ctx) + void fq_poly_add(fq_poly_t res, const fq_poly_t poly1, const fq_poly_t poly2, const fq_ctx_t ctx) noexcept # Sets ``res`` to the sum of ``poly1`` and ``poly2``. - void fq_poly_add_si(fq_poly_t res, const fq_poly_t poly1, slong c, const fq_ctx_t ctx) + void fq_poly_add_si(fq_poly_t res, const fq_poly_t poly1, slong c, const fq_ctx_t ctx) noexcept # Sets ``res`` to the sum of ``poly1`` and ``c``. - void fq_poly_add_series(fq_poly_t res, const fq_poly_t poly1, const fq_poly_t poly2, slong n, const fq_ctx_t ctx) + void fq_poly_add_series(fq_poly_t res, const fq_poly_t poly1, const fq_poly_t poly2, slong n, const fq_ctx_t ctx) noexcept # Notionally truncate ``poly1`` and ``poly2`` to length ``n`` and set # ``res`` to the sum. - void _fq_poly_sub(fq_struct *res, const fq_struct *poly1, slong len1, const fq_struct *poly2, slong len2, const fq_ctx_t ctx) + void _fq_poly_sub(fq_struct *res, const fq_struct *poly1, slong len1, const fq_struct *poly2, slong len2, const fq_ctx_t ctx) noexcept # Sets ``res`` to the difference of ``(poly1,len1)`` and ``(poly2,len2)``. - void fq_poly_sub(fq_poly_t res, const fq_poly_t poly1, const fq_poly_t poly2, const fq_ctx_t ctx) + void fq_poly_sub(fq_poly_t res, const fq_poly_t poly1, const fq_poly_t poly2, const fq_ctx_t ctx) noexcept # Sets ``res`` to the difference of ``poly1`` and ``poly2``. - void fq_poly_sub_series(fq_poly_t res, const fq_poly_t poly1, const fq_poly_t poly2, slong n, const fq_ctx_t ctx) + void fq_poly_sub_series(fq_poly_t res, const fq_poly_t poly1, const fq_poly_t poly2, slong n, const fq_ctx_t ctx) noexcept # Notionally truncate ``poly1`` and ``poly2`` to length ``n`` and set # ``res`` to the difference. - void _fq_poly_neg(fq_struct *rop, const fq_struct *op, slong len, const fq_ctx_t ctx) + void _fq_poly_neg(fq_struct *rop, const fq_struct *op, slong len, const fq_ctx_t ctx) noexcept # Sets ``rop`` to the additive inverse of ``(poly,len)``. - void fq_poly_neg(fq_poly_t res, const fq_poly_t poly, const fq_ctx_t ctx) + void fq_poly_neg(fq_poly_t res, const fq_poly_t poly, const fq_ctx_t ctx) noexcept # Sets ``res`` to the additive inverse of ``poly``. - void _fq_poly_scalar_mul_fq(fq_struct *rop, const fq_struct *op, slong len, const fq_t x, const fq_ctx_t ctx) + void _fq_poly_scalar_mul_fq(fq_struct *rop, const fq_struct *op, slong len, const fq_t x, const fq_ctx_t ctx) noexcept # Sets ``(rop,len)`` to the product of ``(op,len)`` by the # scalar ``x``, in the context defined by ``ctx``. - void fq_poly_scalar_mul_fq(fq_poly_t rop, const fq_poly_t op, const fq_t x, const fq_ctx_t ctx) + void fq_poly_scalar_mul_fq(fq_poly_t rop, const fq_poly_t op, const fq_t x, const fq_ctx_t ctx) noexcept # Sets ``rop`` to the product of ``op`` by the scalar ``x``, in the context # defined by ``ctx``. - void _fq_poly_scalar_addmul_fq(fq_struct *rop, const fq_struct *op, slong len, const fq_t x, const fq_ctx_t ctx) + void _fq_poly_scalar_addmul_fq(fq_struct *rop, const fq_struct *op, slong len, const fq_t x, const fq_ctx_t ctx) noexcept # Adds to ``(rop,len)`` the product of ``(op,len)`` by the # scalar ``x``, in the context defined by ``ctx``. # In particular, assumes the same length for ``op`` and # ``rop``. - void fq_poly_scalar_addmul_fq(fq_poly_t rop, const fq_poly_t op, const fq_t x, const fq_ctx_t ctx) + void fq_poly_scalar_addmul_fq(fq_poly_t rop, const fq_poly_t op, const fq_t x, const fq_ctx_t ctx) noexcept # Adds to ``rop`` the product of ``op`` by the # scalar ``x``, in the context defined by ``ctx``. - void _fq_poly_scalar_submul_fq(fq_struct *rop, const fq_struct *op, slong len, const fq_t x, const fq_ctx_t ctx) + void _fq_poly_scalar_submul_fq(fq_struct *rop, const fq_struct *op, slong len, const fq_t x, const fq_ctx_t ctx) noexcept # Subtracts from ``(rop,len)`` the product of ``(op,len)`` by the # scalar ``x``, in the context defined by ``ctx``. # In particular, assumes the same length for ``op`` and # ``rop``. - void fq_poly_scalar_submul_fq(fq_poly_t rop, const fq_poly_t op, const fq_t x, const fq_ctx_t ctx) + void fq_poly_scalar_submul_fq(fq_poly_t rop, const fq_poly_t op, const fq_t x, const fq_ctx_t ctx) noexcept # Subtracts from ``rop`` the product of ``op`` by the # scalar ``x``, in the context defined by ``ctx``. - void _fq_poly_scalar_div_fq(fq_struct *rop, const fq_struct *op, slong len, const fq_t x, const fq_ctx_t ctx) + void _fq_poly_scalar_div_fq(fq_struct *rop, const fq_struct *op, slong len, const fq_t x, const fq_ctx_t ctx) noexcept # Sets ``(rop,len)`` to the quotient of ``(op,len)`` by the # scalar ``x``, in the context defined by ``ctx``. An exception is raised # if ``x`` is zero. - void fq_poly_scalar_div_fq(fq_poly_t rop, const fq_poly_t op, const fq_t x, const fq_ctx_t ctx) + void fq_poly_scalar_div_fq(fq_poly_t rop, const fq_poly_t op, const fq_t x, const fq_ctx_t ctx) noexcept # Sets ``rop`` to the quotient of ``op`` by the scalar ``x``, in the context # defined by ``ctx``. An exception is raised if ``x`` is zero. - void _fq_poly_mul_classical(fq_struct *rop, const fq_struct *op1, slong len1, const fq_struct *op2, slong len2, const fq_ctx_t ctx) + void _fq_poly_mul_classical(fq_struct *rop, const fq_struct *op1, slong len1, const fq_struct *op2, slong len2, const fq_ctx_t ctx) noexcept # Sets ``(rop, len1 + len2 - 1)`` to the product of ``(op1, len1)`` # and ``(op2, len2)``, assuming that ``len1`` is at least ``len2`` # and neither is zero. # Permits zero padding. Does not support aliasing of ``rop`` # with either ``op1`` or ``op2``. - void fq_poly_mul_classical(fq_poly_t rop, const fq_poly_t op1, const fq_poly_t op2, const fq_ctx_t ctx) + void fq_poly_mul_classical(fq_poly_t rop, const fq_poly_t op1, const fq_poly_t op2, const fq_ctx_t ctx) noexcept # Sets ``rop`` to the product of ``op1`` and ``op2`` # using classical polynomial multiplication. - void _fq_poly_mul_reorder(fq_struct *rop, const fq_struct *op1, slong len1, const fq_struct *op2, slong len2, const fq_ctx_t ctx) + void _fq_poly_mul_reorder(fq_struct *rop, const fq_struct *op1, slong len1, const fq_struct *op2, slong len2, const fq_ctx_t ctx) noexcept # Sets ``(rop, len1 + len2 - 1)`` to the product of ``(op1, len1)`` # and ``(op2, len2)``, assuming that ``len1`` and ``len2`` are # non-zero. # Permits zero padding. Supports aliasing. - void fq_poly_mul_reorder(fq_poly_t rop, const fq_poly_t op1, const fq_poly_t op2, const fq_ctx_t ctx) + void fq_poly_mul_reorder(fq_poly_t rop, const fq_poly_t op1, const fq_poly_t op2, const fq_ctx_t ctx) noexcept # Sets ``rop`` to the product of ``op1`` and ``op2``, # reordering the two indeterminates `X` and `Y` when viewing # the polynomials as elements of `\mathbf{F}_p[X,Y]`. @@ -286,49 +286,49 @@ cdef extern from "flint_wrap.h": # multiplication routines in the `Y`-direction where the polynomial # degree `n` is large. - void _fq_poly_mul_univariate(fq_struct *rop, const fq_struct *op1, slong len1, const fq_struct *op2, slong len2, const fq_ctx_t ctx) + void _fq_poly_mul_univariate(fq_struct *rop, const fq_struct *op1, slong len1, const fq_struct *op2, slong len2, const fq_ctx_t ctx) noexcept # Sets ``(rop, len1 + len2 - 1)`` to the product of ``(op1, len1)`` # and ``(op2, len2)``. # Permits zero padding and places no assumptions on the # lengths ``len1`` and ``len2``. Supports aliasing. - void fq_poly_mul_univariate(fq_poly_t rop, const fq_poly_t op1, const fq_poly_t op2, const fq_ctx_t ctx) + void fq_poly_mul_univariate(fq_poly_t rop, const fq_poly_t op1, const fq_poly_t op2, const fq_ctx_t ctx) noexcept # Sets ``rop`` to the product of ``op1`` and ``op2`` # using a bivariate to univariate transformation and reducing # this problem to multiplying two univariate polynomials. - void _fq_poly_mul_KS(fq_struct *rop, const fq_struct *op1, slong len1, const fq_struct *op2, slong len2, const fq_ctx_t ctx) + void _fq_poly_mul_KS(fq_struct *rop, const fq_struct *op1, slong len1, const fq_struct *op2, slong len2, const fq_ctx_t ctx) noexcept # Sets ``(rop, len1 + len2 - 1)`` to the product of ``(op1, len1)`` # and ``(op2, len2)``. # Permits zero padding and places no assumptions on the # lengths ``len1`` and ``len2``. Supports aliasing. - void fq_poly_mul_KS(fq_poly_t rop, const fq_poly_t op1, const fq_poly_t op2, const fq_ctx_t ctx) + void fq_poly_mul_KS(fq_poly_t rop, const fq_poly_t op1, const fq_poly_t op2, const fq_ctx_t ctx) noexcept # Sets ``rop`` to the product of ``op1`` and ``op2`` # using Kronecker substitution, that is, by encoding each # coefficient in `\mathbf{F}_{q}` as an integer and reducing # this problem to multiplying two polynomials over the integers. - void _fq_poly_mul(fq_struct *rop, const fq_struct *op1, slong len1, const fq_struct *op2, slong len2, const fq_ctx_t ctx) + void _fq_poly_mul(fq_struct *rop, const fq_struct *op1, slong len1, const fq_struct *op2, slong len2, const fq_ctx_t ctx) noexcept # Sets ``(rop, len1 + len2 - 1)`` to the product of ``(op1, len1)`` # and ``(op2, len2)``, choosing an appropriate algorithm. # Permits zero padding. Does not support aliasing. - void fq_poly_mul(fq_poly_t rop, const fq_poly_t op1, const fq_poly_t op2, const fq_ctx_t ctx) + void fq_poly_mul(fq_poly_t rop, const fq_poly_t op1, const fq_poly_t op2, const fq_ctx_t ctx) noexcept # Sets ``rop`` to the product of ``op1`` and ``op2``, # choosing an appropriate algorithm. - void _fq_poly_mullow_classical(fq_struct *rop, const fq_struct *op1, slong len1, const fq_struct *op2, slong len2, slong n, const fq_ctx_t ctx) + void _fq_poly_mullow_classical(fq_struct *rop, const fq_struct *op1, slong len1, const fq_struct *op2, slong len2, slong n, const fq_ctx_t ctx) noexcept # Sets ``(rop, n)`` to the first `n` coefficients of ``(op1, len1)`` # multiplied by ``(op2, len2)``. # Assumes ``0 < n <= len1 + len2 - 1``. Assumes neither ``len1`` nor # ``len2`` is zero. - void fq_poly_mullow_classical(fq_poly_t rop, const fq_poly_t op1, const fq_poly_t op2, slong n, const fq_ctx_t ctx) + void fq_poly_mullow_classical(fq_poly_t rop, const fq_poly_t op1, const fq_poly_t op2, slong n, const fq_ctx_t ctx) noexcept # Sets ``rop`` to the product of ``poly1`` and ``poly2``, computed # using the classical or schoolbook method. - void _fq_poly_mullow_univariate(fq_struct *rop, const fq_struct *op1, slong len1, const fq_struct *op2, slong len2, slong n, const fq_ctx_t ctx) + void _fq_poly_mullow_univariate(fq_struct *rop, const fq_struct *op1, slong len1, const fq_struct *op2, slong len2, slong n, const fq_ctx_t ctx) noexcept # Sets ``(rop, n)`` to the lowest `n` coefficients of the product of # ``(op1, len1)`` and ``(op2, len2)``, computed using a # bivariate to univariate transformation. @@ -337,12 +337,12 @@ cdef extern from "flint_wrap.h": # too. Assumes `n` is positive. Supports aliasing between ``res``, # ``poly1`` and ``poly2``. - void fq_poly_mullow_univariate(fq_poly_t rop, const fq_poly_t op1, const fq_poly_t op2, slong n, const fq_ctx_t ctx) + void fq_poly_mullow_univariate(fq_poly_t rop, const fq_poly_t op1, const fq_poly_t op2, slong n, const fq_ctx_t ctx) noexcept # Sets ``rop`` to the lowest `n` coefficients of the product of # ``op1`` and ``op2``, computed using a bivariate to univariate # transformation. - void _fq_poly_mullow_KS(fq_struct *rop, const fq_struct *op1, slong len1, const fq_struct *op2, slong len2, slong n, const fq_ctx_t ctx) + void _fq_poly_mullow_KS(fq_struct *rop, const fq_struct *op1, slong len1, const fq_struct *op2, slong len2, slong n, const fq_ctx_t ctx) noexcept # Sets ``(rop, n)`` to the lowest `n` coefficients of the product of # ``(op1, len1)`` and ``(op2, len2)``. # Assumes that ``len1`` and ``len2`` are positive, but does allow @@ -350,46 +350,46 @@ cdef extern from "flint_wrap.h": # too. Assumes `n` is positive. Supports aliasing between ``rop``, # ``op1`` and ``op2``. - void fq_poly_mullow_KS(fq_poly_t rop, const fq_poly_t op1, const fq_poly_t op2, slong n, const fq_ctx_t ctx) + void fq_poly_mullow_KS(fq_poly_t rop, const fq_poly_t op1, const fq_poly_t op2, slong n, const fq_ctx_t ctx) noexcept # Sets ``rop`` to the lowest `n` coefficients of the product of # ``op1`` and ``op2``. - void _fq_poly_mullow(fq_struct *rop, const fq_struct *op1, slong len1, const fq_struct *op2, slong len2, slong n, const fq_ctx_t ctx) + void _fq_poly_mullow(fq_struct *rop, const fq_struct *op1, slong len1, const fq_struct *op2, slong len2, slong n, const fq_ctx_t ctx) noexcept # Sets ``(rop, n)`` to the lowest `n` coefficients of the product of # ``(op1, len1)`` and ``(op2, len2)``. # Assumes ``0 < n <= len1 + len2 - 1``. Allows for zero-padding in # the inputs. Does not support aliasing between the inputs and the output. - void fq_poly_mullow(fq_poly_t rop, const fq_poly_t op1, const fq_poly_t op2, slong n, const fq_ctx_t ctx) + void fq_poly_mullow(fq_poly_t rop, const fq_poly_t op1, const fq_poly_t op2, slong n, const fq_ctx_t ctx) noexcept # Sets ``rop`` to the lowest `n` coefficients of the product of # ``op1`` and ``op2``. - void _fq_poly_mulhigh_classical(fq_struct *res, const fq_struct *poly1, slong len1, const fq_struct *poly2, slong len2, slong start, const fq_ctx_t ctx) + void _fq_poly_mulhigh_classical(fq_struct *res, const fq_struct *poly1, slong len1, const fq_struct *poly2, slong len2, slong start, const fq_ctx_t ctx) noexcept # Computes the product of ``(poly1, len1)`` and ``(poly2, len2)`` # and writes the coefficients from ``start`` onwards into the high # coefficients of ``res``, the remaining coefficients being arbitrary # but reduced. Assumes that ``len1 >= len2 > 0``. Aliasing of inputs # and output is not permitted. Algorithm is classical multiplication. - void fq_poly_mulhigh_classical(fq_poly_t res, const fq_poly_t poly1, const fq_poly_t poly2, slong start, const fq_ctx_t ctx) + void fq_poly_mulhigh_classical(fq_poly_t res, const fq_poly_t poly1, const fq_poly_t poly2, slong start, const fq_ctx_t ctx) noexcept # Computes the product of ``poly1`` and ``poly2`` and writes the # coefficients from ``start`` onwards into the high coefficients of # ``res``, the remaining coefficients being arbitrary but reduced. # Algorithm is classical multiplication. - void _fq_poly_mulhigh(fq_struct *res, const fq_struct *poly1, slong len1, const fq_struct *poly2, slong len2, slong start, fq_ctx_t ctx) + void _fq_poly_mulhigh(fq_struct *res, const fq_struct *poly1, slong len1, const fq_struct *poly2, slong len2, slong start, fq_ctx_t ctx) noexcept # Computes the product of ``(poly1, len1)`` and ``(poly2, len2)`` # and writes the coefficients from ``start`` onwards into the high # coefficients of ``res``, the remaining coefficients being arbitrary # but reduced. Assumes that ``len1 >= len2 > 0``. Aliasing of inputs # and output is not permitted. - void fq_poly_mulhigh(fq_poly_t res, const fq_poly_t poly1, const fq_poly_t poly2, slong start, const fq_ctx_t ctx) + void fq_poly_mulhigh(fq_poly_t res, const fq_poly_t poly1, const fq_poly_t poly2, slong start, const fq_ctx_t ctx) noexcept # Computes the product of ``poly1`` and ``poly2`` and writes the # coefficients from ``start`` onwards into the high coefficients of # ``res``, the remaining coefficients being arbitrary but reduced. - void _fq_poly_mulmod(fq_struct* res, const fq_struct* poly1, slong len1, const fq_struct* poly2, slong len2, const fq_struct* f, slong lenf, const fq_ctx_t ctx) + void _fq_poly_mulmod(fq_struct* res, const fq_struct* poly1, slong len1, const fq_struct* poly2, slong len2, const fq_struct* f, slong lenf, const fq_ctx_t ctx) noexcept # Sets ``res`` to the remainder of the product of ``poly1`` # and ``poly2`` upon polynomial division by ``f``. # It is required that ``len1 + len2 - lenf > 0``, which is @@ -397,74 +397,74 @@ cdef extern from "flint_wrap.h": # reduced. Otherwise, simply use ``_fq_poly_mul`` instead. # Aliasing of ``f`` and ``res`` is not permitted. - void fq_poly_mulmod(fq_poly_t res, const fq_poly_t poly1, const fq_poly_t poly2, const fq_poly_t f, const fq_ctx_t ctx) + void fq_poly_mulmod(fq_poly_t res, const fq_poly_t poly1, const fq_poly_t poly2, const fq_poly_t f, const fq_ctx_t ctx) noexcept # Sets ``res`` to the remainder of the product of ``poly1`` # and ``poly2`` upon polynomial division by ``f``. - void _fq_poly_mulmod_preinv(fq_struct* res, const fq_struct* poly1, slong len1, const fq_struct* poly2, slong len2, const fq_struct* f, slong lenf, const fq_struct* finv, slong lenfinv, const fq_ctx_t ctx) + void _fq_poly_mulmod_preinv(fq_struct* res, const fq_struct* poly1, slong len1, const fq_struct* poly2, slong len2, const fq_struct* f, slong lenf, const fq_struct* finv, slong lenfinv, const fq_ctx_t ctx) noexcept # Sets ``res`` to the remainder of the product of ``poly1`` # and ``poly2`` upon polynomial division by ``f``. # It is required that ``finv`` is the inverse of the reverse of # ``f`` mod ``x^lenf``. # Aliasing of ``res`` with any of the inputs is not permitted. - void fq_poly_mulmod_preinv(fq_poly_t res, const fq_poly_t poly1, const fq_poly_t poly2, const fq_poly_t f, const fq_poly_t finv, const fq_ctx_t ctx) + void fq_poly_mulmod_preinv(fq_poly_t res, const fq_poly_t poly1, const fq_poly_t poly2, const fq_poly_t f, const fq_poly_t finv, const fq_ctx_t ctx) noexcept # Sets ``res`` to the remainder of the product of ``poly1`` # and ``poly2`` upon polynomial division by ``f``. ``finv`` # is the inverse of the reverse of ``f``. - void _fq_poly_sqr_classical(fq_struct *rop, const fq_struct *op, slong len, const fq_ctx_t ctx) + void _fq_poly_sqr_classical(fq_struct *rop, const fq_struct *op, slong len, const fq_ctx_t ctx) noexcept # Sets ``(rop, 2*len - 1)`` to the square of ``(op, len)``, # assuming that ``(op,len)`` is not zero and using classical # polynomial multiplication. # Permits zero padding. Does not support aliasing of ``rop`` # with either ``op1`` or ``op2``. - void fq_poly_sqr_classical(fq_poly_t rop, const fq_poly_t op, const fq_ctx_t ctx) + void fq_poly_sqr_classical(fq_poly_t rop, const fq_poly_t op, const fq_ctx_t ctx) noexcept # Sets ``rop`` to the square of ``op`` using classical # polynomial multiplication. - void _fq_poly_sqr_reorder(fq_struct *rop, const fq_struct *op, slong len, const fq_ctx_t ctx) + void _fq_poly_sqr_reorder(fq_struct *rop, const fq_struct *op, slong len, const fq_ctx_t ctx) noexcept # Sets ``(rop, 2*len- 1)`` to the square of ``(op, len)``, # assuming that ``len`` is not zero reordering the two indeterminates # `X` and `Y` when viewing the polynomials as elements of `\mathbf{F}_p[X,Y]`. # Permits zero padding. Supports aliasing. - void fq_poly_sqr_reorder(fq_poly_t rop, const fq_poly_t op, const fq_ctx_t ctx) + void fq_poly_sqr_reorder(fq_poly_t rop, const fq_poly_t op, const fq_ctx_t ctx) noexcept # Sets ``rop`` to the square of ``op``, # assuming that ``len`` is not zero reordering the two indeterminates # `X` and `Y` when viewing the polynomials as elements of `\mathbf{F}_p[X,Y]`. # See ``fq_poly_mul_reorder``. - void _fq_poly_sqr_KS(fq_struct *rop, const fq_struct *op, slong len, const fq_ctx_t ctx) + void _fq_poly_sqr_KS(fq_struct *rop, const fq_struct *op, slong len, const fq_ctx_t ctx) noexcept # Sets ``(rop, 2*len - 1)`` to the square of ``(op, len)``. # Permits zero padding and places no assumptions on the # lengths ``len1`` and ``len2``. Supports aliasing. - void fq_poly_sqr_KS(fq_poly_t rop, const fq_poly_t op, const fq_ctx_t ctx) + void fq_poly_sqr_KS(fq_poly_t rop, const fq_poly_t op, const fq_ctx_t ctx) noexcept # Sets ``rop`` to the square ``op`` using Kronecker substitution, # that is, by encoding each coefficient in `\mathbf{F}_{q}` as an integer # and reducing this problem to multiplying two polynomials over the integers. - void _fq_poly_sqr(fq_struct *rop, const fq_struct *op, slong len, const fq_ctx_t ctx) + void _fq_poly_sqr(fq_struct *rop, const fq_struct *op, slong len, const fq_ctx_t ctx) noexcept # Sets ``(rop, 2* len - 1)`` to the square of ``(op, len)``, # choosing an appropriate algorithm. # Permits zero padding. Does not support aliasing. - void fq_poly_sqr(fq_poly_t rop, const fq_poly_t op, const fq_ctx_t ctx) + void fq_poly_sqr(fq_poly_t rop, const fq_poly_t op, const fq_ctx_t ctx) noexcept # Sets ``rop`` to the square of ``op``, # choosing an appropriate algorithm. - void _fq_poly_pow(fq_struct *rop, const fq_struct *op, slong len, ulong e, const fq_ctx_t ctx) + void _fq_poly_pow(fq_struct *rop, const fq_struct *op, slong len, ulong e, const fq_ctx_t ctx) noexcept # Sets ``rop = op^e``, assuming that ``e, len > 0`` and that # ``rop`` has space for ``e*(len - 1) + 1`` coefficients. Does # not support aliasing. - void fq_poly_pow(fq_poly_t rop, const fq_poly_t op, ulong e, const fq_ctx_t ctx) + void fq_poly_pow(fq_poly_t rop, const fq_poly_t op, ulong e, const fq_ctx_t ctx) noexcept # Computes ``rop = op^e``. If `e` is zero, returns one, # so that in particular ``0^0 = 1``. - void _fq_poly_powmod_ui_binexp(fq_struct* res, const fq_struct* poly, ulong e, const fq_struct* f, slong lenf, const fq_ctx_t ctx) + void _fq_poly_powmod_ui_binexp(fq_struct* res, const fq_struct* poly, ulong e, const fq_struct* f, slong lenf, const fq_ctx_t ctx) noexcept # Sets ``res`` to ``poly`` raised to the power ``e`` modulo # ``f``, using binary exponentiation. We require ``e > 0``. # We require ``lenf > 1``. It is assumed that ``poly`` is @@ -472,11 +472,11 @@ cdef extern from "flint_wrap.h": # have length exactly ``lenf - 1``. The output ``res`` must # have room for ``lenf - 1`` coefficients. - void fq_poly_powmod_ui_binexp(fq_poly_t res, const fq_poly_t poly, ulong e, const fq_poly_t f, const fq_ctx_t ctx) + void fq_poly_powmod_ui_binexp(fq_poly_t res, const fq_poly_t poly, ulong e, const fq_poly_t f, const fq_ctx_t ctx) noexcept # Sets ``res`` to ``poly`` raised to the power ``e`` modulo # ``f``, using binary exponentiation. We require ``e >= 0``. - void _fq_poly_powmod_ui_binexp_preinv(fq_struct* res, const fq_struct* poly, ulong e, const fq_struct* f, slong lenf, const fq_struct* finv, slong lenfinv, const fq_ctx_t ctx) + void _fq_poly_powmod_ui_binexp_preinv(fq_struct* res, const fq_struct* poly, ulong e, const fq_struct* f, slong lenf, const fq_struct* finv, slong lenfinv, const fq_ctx_t ctx) noexcept # Sets ``res`` to ``poly`` raised to the power ``e`` modulo # ``f``, using binary exponentiation. We require ``e > 0``. # We require ``finv`` to be the inverse of the reverse of @@ -486,13 +486,13 @@ cdef extern from "flint_wrap.h": # have length exactly ``lenf - 1``. The output ``res`` must # have room for ``lenf - 1`` coefficients. - void fq_poly_powmod_ui_binexp_preinv(fq_poly_t res, const fq_poly_t poly, ulong e, const fq_poly_t f, const fq_poly_t finv, const fq_ctx_t ctx) + void fq_poly_powmod_ui_binexp_preinv(fq_poly_t res, const fq_poly_t poly, ulong e, const fq_poly_t f, const fq_poly_t finv, const fq_ctx_t ctx) noexcept # Sets ``res`` to ``poly`` raised to the power ``e`` modulo # ``f``, using binary exponentiation. We require ``e >= 0``. # We require ``finv`` to be the inverse of the reverse of # ``f``. - void _fq_poly_powmod_fmpz_binexp(fq_struct* res, const fq_struct* poly, const fmpz_t e, const fq_struct* f, slong lenf, const fq_ctx_t ctx) + void _fq_poly_powmod_fmpz_binexp(fq_struct* res, const fq_struct* poly, const fmpz_t e, const fq_struct* f, slong lenf, const fq_ctx_t ctx) noexcept # Sets ``res`` to ``poly`` raised to the power ``e`` modulo # ``f``, using binary exponentiation. We require ``e > 0``. # We require ``lenf > 1``. It is assumed that ``poly`` is @@ -500,11 +500,11 @@ cdef extern from "flint_wrap.h": # have length exactly ``lenf - 1``. The output ``res`` must # have room for ``lenf - 1`` coefficients. - void fq_poly_powmod_fmpz_binexp(fq_poly_t res, const fq_poly_t poly, const fmpz_t e, const fq_poly_t f, const fq_ctx_t ctx) + void fq_poly_powmod_fmpz_binexp(fq_poly_t res, const fq_poly_t poly, const fmpz_t e, const fq_poly_t f, const fq_ctx_t ctx) noexcept # Sets ``res`` to ``poly`` raised to the power ``e`` modulo # ``f``, using binary exponentiation. We require ``e >= 0``. - void _fq_poly_powmod_fmpz_binexp_preinv(fq_struct* res, const fq_struct* poly, const fmpz_t e, const fq_struct* f, slong lenf, const fq_struct* finv, slong lenfinv, const fq_ctx_t ctx) + void _fq_poly_powmod_fmpz_binexp_preinv(fq_struct* res, const fq_struct* poly, const fmpz_t e, const fq_struct* f, slong lenf, const fq_struct* finv, slong lenfinv, const fq_ctx_t ctx) noexcept # Sets ``res`` to ``poly`` raised to the power ``e`` modulo # ``f``, using binary exponentiation. We require ``e > 0``. # We require ``finv`` to be the inverse of the reverse of @@ -514,13 +514,13 @@ cdef extern from "flint_wrap.h": # have length exactly ``lenf - 1``. The output ``res`` must # have room for ``lenf - 1`` coefficients. - void fq_poly_powmod_fmpz_binexp_preinv(fq_poly_t res, const fq_poly_t poly, const fmpz_t e, const fq_poly_t f, const fq_poly_t finv, const fq_ctx_t ctx) + void fq_poly_powmod_fmpz_binexp_preinv(fq_poly_t res, const fq_poly_t poly, const fmpz_t e, const fq_poly_t f, const fq_poly_t finv, const fq_ctx_t ctx) noexcept # Sets ``res`` to ``poly`` raised to the power ``e`` modulo # ``f``, using binary exponentiation. We require ``e >= 0``. # We require ``finv`` to be the inverse of the reverse of # ``f``. - void _fq_poly_powmod_fmpz_sliding_preinv(fq_struct* res, const fq_struct* poly, const fmpz_t e, ulong k, const fq_struct* f, slong lenf, const fq_struct* finv, slong lenfinv, const fq_ctx_t ctx) + void _fq_poly_powmod_fmpz_sliding_preinv(fq_struct* res, const fq_struct* poly, const fmpz_t e, ulong k, const fq_struct* f, slong lenf, const fq_struct* finv, slong lenfinv, const fq_ctx_t ctx) noexcept # Sets ``res`` to ``poly`` raised to the power ``e`` modulo # ``f``, using sliding-window exponentiation with window size # ``k``. We require ``e > 0``. We require ``finv`` to be @@ -532,7 +532,7 @@ cdef extern from "flint_wrap.h": # have length exactly ``lenf - 1``. The output ``res`` must # have room for ``lenf - 1`` coefficients. - void fq_poly_powmod_fmpz_sliding_preinv(fq_poly_t res, const fq_poly_t poly, const fmpz_t e, ulong k, const fq_poly_t f, const fq_poly_t finv, const fq_ctx_t ctx) + void fq_poly_powmod_fmpz_sliding_preinv(fq_poly_t res, const fq_poly_t poly, const fmpz_t e, ulong k, const fq_poly_t f, const fq_poly_t finv, const fq_ctx_t ctx) noexcept # Sets ``res`` to ``poly`` raised to the power ``e`` modulo # ``f``, using sliding-window exponentiation with window size # ``k``. We require ``e >= 0``. We require ``finv`` to be @@ -540,20 +540,20 @@ cdef extern from "flint_wrap.h": # zero, then an "optimum" size will be selected automatically base # on ``e``. - void _fq_poly_powmod_x_fmpz_preinv(fq_struct * res, const fmpz_t e, const fq_struct * f, slong lenf, const fq_struct * finv, slong lenfinv, const fq_ctx_t ctx) + void _fq_poly_powmod_x_fmpz_preinv(fq_struct * res, const fmpz_t e, const fq_struct * f, slong lenf, const fq_struct * finv, slong lenfinv, const fq_ctx_t ctx) noexcept # Sets ``res`` to ``x`` raised to the power ``e`` modulo ``f``, # using sliding window exponentiation. We require ``e > 0``. # We require ``finv`` to be the inverse of the reverse of ``f``. # We require ``lenf > 2``. The output ``res`` must have room for # ``lenf - 1`` coefficients. - void fq_poly_powmod_x_fmpz_preinv(fq_poly_t res, const fmpz_t e, const fq_poly_t f, const fq_poly_t finv, const fq_ctx_t ctx) + void fq_poly_powmod_x_fmpz_preinv(fq_poly_t res, const fmpz_t e, const fq_poly_t f, const fq_poly_t finv, const fq_ctx_t ctx) noexcept # Sets ``res`` to ``x`` raised to the power ``e`` # modulo ``f``, using sliding window exponentiation. We require # ``e >= 0``. We require ``finv`` to be the inverse of the reverse of # ``f``. - void _fq_poly_pow_trunc_binexp(fq_struct * res, const fq_struct * poly, ulong e, slong trunc, const fq_ctx_t ctx) + void _fq_poly_pow_trunc_binexp(fq_struct * res, const fq_struct * poly, ulong e, slong trunc, const fq_ctx_t ctx) noexcept # Sets ``res`` to the low ``trunc`` coefficients of ``poly`` # (assumed to be zero padded if necessary to length ``trunc``) to # the power ``e``. This is equivalent to doing a powering followed @@ -562,12 +562,12 @@ cdef extern from "flint_wrap.h": # ``e > 1``. Aliasing is not permitted. Uses the binary # exponentiation method. - void fq_poly_pow_trunc_binexp(fq_poly_t res, const fq_poly_t poly, ulong e, slong trunc, const fq_ctx_t ctx) + void fq_poly_pow_trunc_binexp(fq_poly_t res, const fq_poly_t poly, ulong e, slong trunc, const fq_ctx_t ctx) noexcept # Sets ``res`` to the low ``trunc`` coefficients of ``poly`` # to the power ``e``. This is equivalent to doing a powering # followed by a truncation. Uses the binary exponentiation method. - void _fq_poly_pow_trunc(fq_struct * res, const fq_struct * poly, ulong e, slong trunc, const fq_ctx_t mod) + void _fq_poly_pow_trunc(fq_struct * res, const fq_struct * poly, ulong e, slong trunc, const fq_ctx_t mod) noexcept # Sets ``res`` to the low ``trunc`` coefficients of ``poly`` # (assumed to be zero padded if necessary to length ``trunc``) to # the power ``e``. This is equivalent to doing a powering followed @@ -575,12 +575,12 @@ cdef extern from "flint_wrap.h": # ``trunc`` coefficients, that ``trunc > 0`` and that # ``e > 1``. Aliasing is not permitted. - void fq_poly_pow_trunc(fq_poly_t res, const fq_poly_t poly, ulong e, slong trunc, const fq_ctx_t ctx) + void fq_poly_pow_trunc(fq_poly_t res, const fq_poly_t poly, ulong e, slong trunc, const fq_ctx_t ctx) noexcept # Sets ``res`` to the low ``trunc`` coefficients of ``poly`` # to the power ``e``. This is equivalent to doing a powering # followed by a truncation. - void _fq_poly_shift_left(fq_struct *rop, const fq_struct *op, slong len, slong n, const fq_ctx_t ctx) + void _fq_poly_shift_left(fq_struct *rop, const fq_struct *op, slong len, slong n, const fq_ctx_t ctx) noexcept # Sets ``(rop, len + n)`` to ``(op, len)`` shifted left by # `n` coefficients. # Inserts zero coefficients at the lower end. Assumes that @@ -588,11 +588,11 @@ cdef extern from "flint_wrap.h": # ``len + n`` elements. Supports aliasing between ``rop`` and # ``op``. - void fq_poly_shift_left(fq_poly_t rop, const fq_poly_t op, slong n, const fq_ctx_t ctx) + void fq_poly_shift_left(fq_poly_t rop, const fq_poly_t op, slong n, const fq_ctx_t ctx) noexcept # Sets ``rop`` to ``op`` shifted left by `n` coeffs. Zero # coefficients are inserted. - void _fq_poly_shift_right(fq_struct *rop, const fq_struct *op, slong len, slong n, const fq_ctx_t ctx) + void _fq_poly_shift_right(fq_struct *rop, const fq_struct *op, slong len, slong n, const fq_ctx_t ctx) noexcept # Sets ``(rop, len - n)`` to ``(op, len)`` shifted right by # `n` coefficients. # Assumes that ``len`` and `n` are positive, that ``len > n``, @@ -600,18 +600,18 @@ cdef extern from "flint_wrap.h": # aliasing between ``rop`` and ``op``, although in this case # the top coefficients of ``op`` are not set to zero. - void fq_poly_shift_right(fq_poly_t rop, const fq_poly_t op, slong n, const fq_ctx_t ctx) + void fq_poly_shift_right(fq_poly_t rop, const fq_poly_t op, slong n, const fq_ctx_t ctx) noexcept # Sets ``rop`` to ``op`` shifted right by `n` coefficients. # If `n` is equal to or greater than the current length of # ``op``, ``rop`` is set to the zero polynomial. - slong _fq_poly_hamming_weight(const fq_struct *op, slong len, const fq_ctx_t ctx) + slong _fq_poly_hamming_weight(const fq_struct *op, slong len, const fq_ctx_t ctx) noexcept # Returns the number of non-zero entries in ``(op, len)``. - slong fq_poly_hamming_weight(const fq_poly_t op, const fq_ctx_t ctx) + slong fq_poly_hamming_weight(const fq_poly_t op, const fq_ctx_t ctx) noexcept # Returns the number of non-zero entries in the polynomial ``op``. - void _fq_poly_divrem(fq_struct *Q, fq_struct *R, const fq_struct *A, slong lenA, const fq_struct *B, slong lenB, const fq_t invB, const fq_ctx_t ctx) + void _fq_poly_divrem(fq_struct *Q, fq_struct *R, const fq_struct *A, slong lenA, const fq_struct *B, slong lenB, const fq_t invB, const fq_ctx_t ctx) noexcept # Computes ``(Q, lenA - lenB + 1)``, ``(R, lenA)`` such that # `A = B Q + R` with `0 \leq \operatorname{len}(R) < \operatorname{len}(B)`. # Assumes that the leading coefficient of `B` is invertible @@ -620,14 +620,14 @@ cdef extern from "flint_wrap.h": # ``(A, lenA)``. `R` and `A` may be aliased, but apart from # this no aliasing of input and output operands is allowed. - void fq_poly_divrem(fq_poly_t Q, fq_poly_t R, const fq_poly_t A, const fq_poly_t B, const fq_ctx_t ctx) + void fq_poly_divrem(fq_poly_t Q, fq_poly_t R, const fq_poly_t A, const fq_poly_t B, const fq_ctx_t ctx) noexcept # Computes `Q`, `R` such that `A = B Q + R` with # `0 \leq \operatorname{len}(R) < \operatorname{len}(B)`. # Assumes that the leading coefficient of `B` is invertible. This can # be taken for granted the context is for a finite field, that is, when # `p` is prime and `f(X)` is irreducible. - void fq_poly_divrem_f(fq_t f, fq_poly_t Q, fq_poly_t R, const fq_poly_t A, const fq_poly_t B, const fq_ctx_t ctx) + void fq_poly_divrem_f(fq_t f, fq_poly_t Q, fq_poly_t R, const fq_poly_t A, const fq_poly_t B, const fq_ctx_t ctx) noexcept # Either finds a non-trivial factor `f` of the modulus of # ``ctx``, or computes `Q`, `R` such that `A = B Q + R` and # `0 \leq \operatorname{len}(R) < \operatorname{len}(B)`. @@ -637,26 +637,26 @@ cdef extern from "flint_wrap.h": # non-trivial factor of the modulus and `Q` and `R` are not touched. # Assumes that `B` is non-zero. - void _fq_poly_rem(fq_struct *R, const fq_struct *A, slong lenA, const fq_struct *B, slong lenB, const fq_t invB, const fq_ctx_t ctx) + void _fq_poly_rem(fq_struct *R, const fq_struct *A, slong lenA, const fq_struct *B, slong lenB, const fq_t invB, const fq_ctx_t ctx) noexcept # Sets ``R`` to the remainder of the division of ``(A,lenA)`` by # ``(B,lenB)``. Assumes that the leading coefficient of ``(B,lenB)`` # is invertible and that ``invB`` is its inverse. - void fq_poly_rem(fq_poly_t R, const fq_poly_t A, const fq_poly_t B, const fq_ctx_t ctx) + void fq_poly_rem(fq_poly_t R, const fq_poly_t A, const fq_poly_t B, const fq_ctx_t ctx) noexcept # Sets ``R`` to the remainder of the division of ``A`` by # ``B`` in the context described by ``ctx``. - void _fq_poly_div(fq_struct *Q, const fq_struct *A, slong lenA, const fq_struct *B, slong lenB, const fq_t invB, const fq_ctx_t ctx) + void _fq_poly_div(fq_struct *Q, const fq_struct *A, slong lenA, const fq_struct *B, slong lenB, const fq_t invB, const fq_ctx_t ctx) noexcept # Notationally, computes `Q`, `R` such that `A = B Q + R` with `0 # \leq \operatorname{len}(R) < \operatorname{len}(B)` but only sets ``(Q, lenA - lenB + 1)``. # Allows zero-padding in `A` but not in `B`. Assumes that the leading coefficient of `B` is a unit. - void fq_poly_div(fq_poly_t Q, const fq_poly_t A, const fq_poly_t B, const fq_ctx_t ctx) + void fq_poly_div(fq_poly_t Q, const fq_poly_t A, const fq_poly_t B, const fq_ctx_t ctx) noexcept # Notionally finds polynomials `Q` and `R` such that `A = B Q + R` with # `\operatorname{len}(R) < \operatorname{len}(B)`, but returns only ``Q``. If `\operatorname{len}(B) = 0` an # exception is raised. - void _fq_poly_div_newton_n_preinv(fq_struct* Q, const fq_struct* A, slong lenA, const fq_struct* B, slong lenB, const fq_struct* Binv, slong lenBinv, const fq_ctx_t ctx) + void _fq_poly_div_newton_n_preinv(fq_struct* Q, const fq_struct* A, slong lenA, const fq_struct* B, slong lenB, const fq_struct* Binv, slong lenBinv, const fq_ctx_t ctx) noexcept # Notionally computes polynomials `Q` and `R` such that `A = BQ + R` with # `\operatorname{len}(R)` less than ``lenB``, where ``A`` is of length ``lenA`` # and ``B`` is of length ``lenB``, but return only `Q`. @@ -666,7 +666,7 @@ cdef extern from "flint_wrap.h": # The algorithm used is to reverse the polynomials and divide the # resulting power series, then reverse the result. - void fq_poly_div_newton_n_preinv(fq_poly_t Q, const fq_poly_t A, const fq_poly_t B, const fq_poly_t Binv, const fq_ctx_t ctx) + void fq_poly_div_newton_n_preinv(fq_poly_t Q, const fq_poly_t A, const fq_poly_t B, const fq_poly_t Binv, const fq_ctx_t ctx) noexcept # Notionally computes `Q` and `R` such that `A = BQ + R` with # `\operatorname{len}(R) < \operatorname{len}(B)`, but returns only `Q`. # We assume that the leading coefficient of `B` is a unit and that `Binv` is @@ -676,7 +676,7 @@ cdef extern from "flint_wrap.h": # The algorithm used is to reverse the polynomials and divide the # resulting power series, then reverse the result. - void _fq_poly_divrem_newton_n_preinv(fq_struct* Q, fq_struct* R, const fq_struct* A, slong lenA, const fq_struct* B, slong lenB, const fq_struct* Binv, slong lenBinv, const fq_ctx_t ctx) + void _fq_poly_divrem_newton_n_preinv(fq_struct* Q, fq_struct* R, const fq_struct* A, slong lenA, const fq_struct* B, slong lenB, const fq_struct* Binv, slong lenBinv, const fq_ctx_t ctx) noexcept # Computes `Q` and `R` such that `A = BQ + R` with `\operatorname{len}(R)` less # than ``lenB``, where `A` is of length ``lenA`` and `B` is of # length ``lenB``. We require that `Q` have space for @@ -685,7 +685,7 @@ cdef extern from "flint_wrap.h": # used is to call :func:`div_newton_n_preinv` and then multiply out # and compute the remainder. - void fq_poly_divrem_newton_n_preinv(fq_poly_t Q, fq_poly_t R, const fq_poly_t A, const fq_poly_t B, const fq_poly_t Binv, const fq_ctx_t ctx) + void fq_poly_divrem_newton_n_preinv(fq_poly_t Q, fq_poly_t R, const fq_poly_t A, const fq_poly_t B, const fq_poly_t Binv, const fq_ctx_t ctx) noexcept # Computes `Q` and `R` such that `A = BQ + R` with `\operatorname{len}(R) < # \operatorname{len}(B)`. We assume `Binv` is the inverse of the reverse of `B` # mod `x^{\operatorname{len}(B)}`. @@ -694,43 +694,43 @@ cdef extern from "flint_wrap.h": # The algorithm used is to call :func:`div_newton_n` and then # multiply out and compute the remainder. - void _fq_poly_inv_series_newton(fq_struct* Qinv, const fq_struct* Q, slong n, const fq_t cinv, const fq_ctx_t ctx) + void _fq_poly_inv_series_newton(fq_struct* Qinv, const fq_struct* Q, slong n, const fq_t cinv, const fq_ctx_t ctx) noexcept # Given ``Q`` of length ``n`` whose constant coefficient is # invertible modulo the given modulus, find a polynomial ``Qinv`` # of length ``n`` such that ``Q * Qinv`` is ``1`` modulo # `x^n`. Requires ``n > 0``. This function can be viewed as # inverting a power series via Newton iteration. - void fq_poly_inv_series_newton(fq_poly_t Qinv, const fq_poly_t Q, slong n, const fq_ctx_t ctx) + void fq_poly_inv_series_newton(fq_poly_t Qinv, const fq_poly_t Q, slong n, const fq_ctx_t ctx) noexcept # Given ``Q`` find ``Qinv`` such that ``Q * Qinv`` is # ``1`` modulo `x^n`. The constant coefficient of ``Q`` must # be invertible modulo the modulus of ``Q``. An exception is # raised if this is not the case or if ``n = 0``. This function # can be viewed as inverting a power series via Newton iteration. - void _fq_poly_inv_series(fq_struct* Qinv, const fq_struct* Q, slong n, const fq_t cinv, const fq_ctx_t ctx) + void _fq_poly_inv_series(fq_struct* Qinv, const fq_struct* Q, slong n, const fq_t cinv, const fq_ctx_t ctx) noexcept # Given ``Q`` of length ``n`` whose constant coefficient is # invertible modulo the given modulus, find a polynomial ``Qinv`` # of length ``n`` such that ``Q * Qinv`` is ``1`` modulo # `x^n`. Requires ``n > 0``. - void fq_poly_inv_series(fq_poly_t Qinv, const fq_poly_t Q, slong n, const fq_ctx_t ctx) + void fq_poly_inv_series(fq_poly_t Qinv, const fq_poly_t Q, slong n, const fq_ctx_t ctx) noexcept # Given ``Q`` find ``Qinv`` such that ``Q * Qinv`` is # ``1`` modulo `x^n`. The constant coefficient of ``Q`` must # be invertible modulo the modulus of ``Q``. An exception is # raised if this is not the case or if ``n = 0``. - void _fq_poly_div_series(fq_struct * Q, const fq_struct * A, slong Alen, const fq_struct * B, slong Blen, slong n, const fq_ctx_t ctx) + void _fq_poly_div_series(fq_struct * Q, const fq_struct * A, slong Alen, const fq_struct * B, slong Blen, slong n, const fq_ctx_t ctx) noexcept # Set ``(Q, n)`` to the quotient of the series ``(A, Alen``) and # ``(B, Blen)`` assuming ``Alen, Blen <= n``. We assume the bottom # coefficient of ``B`` is invertible. - void fq_poly_div_series(fq_poly_t Q, const fq_poly_t A, const fq_poly_t B, slong n, const fq_ctx_t ctx) + void fq_poly_div_series(fq_poly_t Q, const fq_poly_t A, const fq_poly_t B, slong n, const fq_ctx_t ctx) noexcept # Set `Q` to the quotient of the series `A` by `B`, thinking of the series as # though they were of length `n`. We assume that the bottom coefficient of # `B` is invertible. - void fq_poly_gcd(fq_poly_t rop, const fq_poly_t op1, const fq_poly_t op2, const fq_ctx_t ctx) + void fq_poly_gcd(fq_poly_t rop, const fq_poly_t op1, const fq_poly_t op2, const fq_ctx_t ctx) noexcept # Sets ``rop`` to the greatest common divisor of ``op1`` and # ``op2``, using the either the Euclidean or HGCD algorithm. The # GCD of zero polynomials is defined to be zero, whereas the GCD of @@ -738,14 +738,14 @@ cdef extern from "flint_wrap.h": # `P`. Except in the case where the GCD is zero, the GCD `G` is made # monic. - slong _fq_poly_gcd(fq_struct* G, const fq_struct* A, slong lenA, const fq_struct* B, slong lenB, const fq_ctx_t ctx) + slong _fq_poly_gcd(fq_struct* G, const fq_struct* A, slong lenA, const fq_struct* B, slong lenB, const fq_ctx_t ctx) noexcept # Computes the GCD of `A` of length ``lenA`` and `B` of length # ``lenB``, where ``lenA >= lenB > 0`` and sets `G` to it. The # length of the GCD `G` is returned by the function. No attempt is # made to make the GCD monic. It is required that `G` have space for # ``lenB`` coefficients. - slong _fq_poly_gcd_euclidean_f(fq_t f, fq_struct *G, const fq_struct *A, slong lenA, const fq_struct *B, slong lenB, const fq_ctx_t ctx) + slong _fq_poly_gcd_euclidean_f(fq_t f, fq_struct *G, const fq_struct *A, slong lenA, const fq_struct *B, slong lenB, const fq_ctx_t ctx) noexcept # Either sets `f = 1` and `G` to the greatest common divisor of # `(A,\operatorname{len}(A))` and `(B, \operatorname{len}(B))` and returns its length, or sets # `f` to a non-trivial factor of the modulus of ``ctx`` and leaves @@ -753,11 +753,11 @@ cdef extern from "flint_wrap.h": # Assumes that `\operatorname{len}(A) \geq \operatorname{len}(B) > 0` and that the vector `G` # has space for sufficiently many coefficients. - void fq_poly_gcd_euclidean_f(fq_t f, fq_poly_t G, const fq_poly_t A, const fq_poly_t B, const fq_ctx_t ctx) + void fq_poly_gcd_euclidean_f(fq_t f, fq_poly_t G, const fq_poly_t A, const fq_poly_t B, const fq_ctx_t ctx) noexcept # Either sets `f = 1` and `G` to the greatest common divisor of `A` # and `B` or sets `f` to a factor of the modulus of ``ctx``. - slong _fq_poly_xgcd(fq_struct *G, fq_struct *S, fq_struct *T, const fq_struct *A, slong lenA, const fq_struct *B, slong lenB, const fq_ctx_t ctx) + slong _fq_poly_xgcd(fq_struct *G, fq_struct *S, fq_struct *T, const fq_struct *A, slong lenA, const fq_struct *B, slong lenB, const fq_ctx_t ctx) noexcept # Computes the GCD of `A` and `B` together with cofactors `S` and `T` # such that `S A + T B = G`. Returns the length of `G`. # Assumes that `\operatorname{len}(A) \geq \operatorname{len}(B) \geq 1` and @@ -769,7 +769,7 @@ cdef extern from "flint_wrap.h": # `\operatorname{len}(T) \leq \max(\operatorname{len}(A) - \operatorname{len}(G), 1)`. # No aliasing of input and output operands is permitted. - void fq_poly_xgcd(fq_poly_t G, fq_poly_t S, fq_poly_t T, const fq_poly_t A, const fq_poly_t B, const fq_ctx_t ctx) + void fq_poly_xgcd(fq_poly_t G, fq_poly_t S, fq_poly_t T, const fq_poly_t A, const fq_poly_t B, const fq_ctx_t ctx) noexcept # Computes the GCD of `A` and `B`. The GCD of zero polynomials is # defined to be zero, whereas the GCD of the zero polynomial and some other # polynomial `P` is defined to be `P`. Except in the case where @@ -778,7 +778,7 @@ cdef extern from "flint_wrap.h": # ``S*A + T*B = G``. The length of ``S`` will be at most # ``lenB`` and the length of ``T`` will be at most ``lenA``. - slong _fq_poly_xgcd_euclidean_f(fq_t f, fq_struct *G, fq_struct *S, fq_struct *T, const fq_struct *A, slong lenA, const fq_struct *B, slong lenB, const fq_ctx_t ctx) + slong _fq_poly_xgcd_euclidean_f(fq_t f, fq_struct *G, fq_struct *S, fq_struct *T, const fq_struct *A, slong lenA, const fq_struct *B, slong lenB, const fq_ctx_t ctx) noexcept # Either sets `f = 1` and computes the GCD of `A` and `B` together # with cofactors `S` and `T` such that `S A + T B = G`; otherwise, # sets `f` to a non-trivial factor of the modulus of ``ctx`` and @@ -792,7 +792,7 @@ cdef extern from "flint_wrap.h": # `\operatorname{len}(T) \leq \max(\operatorname{len}(A) - \operatorname{len}(G), 1)`. # No aliasing of input and output operands is permitted. - void fq_poly_xgcd_euclidean_f(fq_t f, fq_poly_t G, fq_poly_t S, fq_poly_t T, const fq_poly_t A, const fq_poly_t B, const fq_ctx_t ctx) + void fq_poly_xgcd_euclidean_f(fq_t f, fq_poly_t G, fq_poly_t S, fq_poly_t T, const fq_poly_t A, const fq_poly_t B, const fq_ctx_t ctx) noexcept # Either sets `f = 1` and computes the GCD of `A` and `B` or sets # `f` to a non-trivial factor of the modulus of ``ctx``. # If the GCD is computed, polynomials ``S`` and ``T`` are @@ -804,7 +804,7 @@ cdef extern from "flint_wrap.h": # be `P`. Except in the case where the GCD is zero, the GCD `G` is # made monic. - int _fq_poly_divides(fq_struct *Q, const fq_struct *A, slong lenA, const fq_struct *B, slong lenB, const fq_t invB, const fq_ctx_t ctx) + int _fq_poly_divides(fq_struct *Q, const fq_struct *A, slong lenA, const fq_struct *B, slong lenB, const fq_t invB, const fq_ctx_t ctx) noexcept # Returns `1` if ``(B, lenB)`` divides ``(A, lenA)`` exactly and # sets `Q` to the quotient, otherwise returns `0`. # It is assumed that `\operatorname{len}(A) \geq \operatorname{len}(B) > 0` and that `Q` has space @@ -813,57 +813,57 @@ cdef extern from "flint_wrap.h": # This function is currently unoptimised and provided for convenience # only. - int fq_poly_divides(fq_poly_t Q, const fq_poly_t A, const fq_poly_t B, const fq_ctx_t ctx) + int fq_poly_divides(fq_poly_t Q, const fq_poly_t A, const fq_poly_t B, const fq_ctx_t ctx) noexcept # Returns `1` if `B` divides `A` exactly and sets `Q` to the quotient, # otherwise returns `0`. # This function is currently unoptimised and provided for convenience # only. - void _fq_poly_derivative(fq_struct *rop, const fq_struct *op, slong len, const fq_ctx_t ctx) + void _fq_poly_derivative(fq_struct *rop, const fq_struct *op, slong len, const fq_ctx_t ctx) noexcept # Sets ``(rop, len - 1)`` to the derivative of ``(op, len)``. # Also handles the cases where ``len`` is `0` or `1` correctly. # Supports aliasing of ``rop`` and ``op``. - void fq_poly_derivative(fq_poly_t rop, const fq_poly_t op, const fq_ctx_t ctx) + void fq_poly_derivative(fq_poly_t rop, const fq_poly_t op, const fq_ctx_t ctx) noexcept # Sets ``rop`` to the derivative of ``op``. - void _fq_poly_invsqrt_series(fq_struct * g, const fq_struct * h, slong n, fq_ctx_t mod) + void _fq_poly_invsqrt_series(fq_struct * g, const fq_struct * h, slong n, fq_ctx_t mod) noexcept # Set the first `n` terms of `g` to the series expansion of `1/\sqrt{h}`. # It is assumed that `n > 0`, that `h` has constant term 1 and that `h` # is zero-padded as necessary to length `n`. Aliasing is not permitted. - void fq_poly_invsqrt_series(fq_poly_t g, const fq_poly_t h, slong n, fq_ctx_t ctx) + void fq_poly_invsqrt_series(fq_poly_t g, const fq_poly_t h, slong n, fq_ctx_t ctx) noexcept # Set `g` to the series expansion of `1/\sqrt{h}` to order `O(x^n)`. # It is assumed that `h` has constant term 1. - void _fq_poly_sqrt_series(fq_struct * g, const fq_struct * h, slong n, fq_ctx_t ctx) + void _fq_poly_sqrt_series(fq_struct * g, const fq_struct * h, slong n, fq_ctx_t ctx) noexcept # Set the first `n` terms of `g` to the series expansion of `\sqrt{h}`. # It is assumed that `n > 0`, that `h` has constant term 1 and that `h` # is zero-padded as necessary to length `n`. Aliasing is not permitted. - void fq_poly_sqrt_series(fq_poly_t g, const fq_poly_t h, slong n, fq_ctx_t ctx) + void fq_poly_sqrt_series(fq_poly_t g, const fq_poly_t h, slong n, fq_ctx_t ctx) noexcept # Set `g` to the series expansion of `\sqrt{h}` to order `O(x^n)`. # It is assumed that `h` has constant term 1. - int _fq_poly_sqrt(fq_struct * s, const fq_struct * p, slong n, fq_ctx_t mod) + int _fq_poly_sqrt(fq_struct * s, const fq_struct * p, slong n, fq_ctx_t mod) noexcept # If ``(p, n)`` is a perfect square, sets ``(s, n / 2 + 1)`` # to a square root of `p` and returns 1. Otherwise returns 0. - int fq_poly_sqrt(fq_poly_t s, const fq_poly_t p, fq_ctx_t mod) + int fq_poly_sqrt(fq_poly_t s, const fq_poly_t p, fq_ctx_t mod) noexcept # If `p` is a perfect square, sets `s` to a square root of `p` # and returns 1. Otherwise returns 0. - void _fq_poly_evaluate_fq(fq_t rop, const fq_struct *op, slong len, const fq_t a, const fq_ctx_t ctx) + void _fq_poly_evaluate_fq(fq_t rop, const fq_struct *op, slong len, const fq_t a, const fq_ctx_t ctx) noexcept # Sets ``rop`` to ``(op, len)`` evaluated at `a`. # Supports zero padding. There are no restrictions on ``len``, that # is, ``len`` is allowed to be zero, too. - void fq_poly_evaluate_fq(fq_t rop, const fq_poly_t f, const fq_t a, const fq_ctx_t ctx) + void fq_poly_evaluate_fq(fq_t rop, const fq_poly_t f, const fq_t a, const fq_ctx_t ctx) noexcept # Sets ``rop`` to the value of `f(a)`. # As the coefficient ring `\mathbf{F}_q` is finite, Horner's method # is sufficient. - void _fq_poly_compose(fq_struct *rop, const fq_struct *op1, slong len1, const fq_struct *op2, slong len2, const fq_ctx_t ctx) + void _fq_poly_compose(fq_struct *rop, const fq_struct *op1, slong len1, const fq_struct *op2, slong len2, const fq_ctx_t ctx) noexcept # Sets ``rop`` to the composition of ``(op1, len1)`` and # ``(op2, len2)``. # Assumes that ``rop`` has space for ``(len1-1)*(len2-1) + 1`` @@ -871,24 +871,24 @@ cdef extern from "flint_wrap.h": # polynomials. Does not support aliasing between any of the inputs and # the output. - void fq_poly_compose(fq_poly_t rop, const fq_poly_t op1, const fq_poly_t op2, const fq_ctx_t ctx) + void fq_poly_compose(fq_poly_t rop, const fq_poly_t op1, const fq_poly_t op2, const fq_ctx_t ctx) noexcept # Sets ``rop`` to the composition of ``op1`` and ``op2``. # To be precise about the order of composition, denoting ``rop``, # ``op1``, and ``op2`` by `f`, `g`, and `h`, respectively, # sets `f(t) = g(h(t))`. - void _fq_poly_compose_mod_horner(fq_struct * res, const fq_struct * f, slong lenf, const fq_struct * g, const fq_struct * h, slong lenh, const fq_ctx_t ctx) + void _fq_poly_compose_mod_horner(fq_struct * res, const fq_struct * f, slong lenf, const fq_struct * g, const fq_struct * h, slong lenh, const fq_ctx_t ctx) noexcept # Sets ``res`` to the composition `f(g)` modulo `h`. We require that # `h` is nonzero and that the length of `g` is one less than the # length of `h` (possibly with zero padding). The output is not allowed # to be aliased with any of the inputs. # The algorithm used is Horner's rule. - void fq_poly_compose_mod_horner(fq_poly_t res, const fq_poly_t f, const fq_poly_t g, const fq_poly_t h, const fq_ctx_t ctx) + void fq_poly_compose_mod_horner(fq_poly_t res, const fq_poly_t f, const fq_poly_t g, const fq_poly_t h, const fq_ctx_t ctx) noexcept # Sets ``res`` to the composition `f(g)` modulo `h`. We require that # `h` is nonzero. The algorithm used is Horner's rule. - void _fq_poly_compose_mod_horner_preinv(fq_struct * res, const fq_struct * f, slong lenf, const fq_struct * g, const fq_struct * h, slong lenh, const fq_struct * hinv, slong lenhiv, const fq_ctx_t ctx) + void _fq_poly_compose_mod_horner_preinv(fq_struct * res, const fq_struct * f, slong lenf, const fq_struct * g, const fq_struct * h, slong lenh, const fq_struct * hinv, slong lenhiv, const fq_ctx_t ctx) noexcept # Sets ``res`` to the composition `f(g)` modulo `h`. We require # that `h` is nonzero and that the length of `g` is one less than # the length of `h` (possibly with zero padding). We also require @@ -898,13 +898,13 @@ cdef extern from "flint_wrap.h": # any of the inputs. # The algorithm used is Horner's rule. - void fq_poly_compose_mod_horner_preinv(fq_poly_t res, const fq_poly_t f, const fq_poly_t g, const fq_poly_t h, const fq_poly_t hinv, const fq_ctx_t ctx) + void fq_poly_compose_mod_horner_preinv(fq_poly_t res, const fq_poly_t f, const fq_poly_t g, const fq_poly_t h, const fq_poly_t hinv, const fq_ctx_t ctx) noexcept # Sets ``res`` to the composition `f(g)` modulo `h`. We require # that `h` is nonzero and that `f` has smaller degree than # `h`. Furthermore, we require ``hinv`` to be the inverse of the # reverse of ``h``. The algorithm used is Horner's rule. - void _fq_poly_compose_mod_brent_kung(fq_struct * res, const fq_struct * f, slong lenf, const fq_struct * g, const fq_struct * h, slong lenh, const fq_ctx_t ctx) + void _fq_poly_compose_mod_brent_kung(fq_struct * res, const fq_struct * f, slong lenf, const fq_struct * g, const fq_struct * h, slong lenh, const fq_ctx_t ctx) noexcept # Sets ``res`` to the composition `f(g)` modulo `h`. We require # that `h` is nonzero and that the length of `g` is one less than # the length of `h` (possibly with zero padding). We also require @@ -912,12 +912,12 @@ cdef extern from "flint_wrap.h": # is not allowed to be aliased with any of the inputs. # The algorithm used is the Brent-Kung matrix algorithm. - void fq_poly_compose_mod_brent_kung(fq_poly_t res, const fq_poly_t f, const fq_poly_t g, const fq_poly_t h, const fq_ctx_t ctx) + void fq_poly_compose_mod_brent_kung(fq_poly_t res, const fq_poly_t f, const fq_poly_t g, const fq_poly_t h, const fq_ctx_t ctx) noexcept # Sets ``res`` to the composition `f(g)` modulo `h`. We require # that `h` is nonzero and that `f` has smaller degree than `h`. The # algorithm used is the Brent-Kung matrix algorithm. - void _fq_poly_compose_mod_brent_kung_preinv(fq_struct * res, const fq_struct * f, slong lenf, const fq_struct * g, const fq_struct * h, slong lenh, const fq_struct * hinv, slong lenhiv, const fq_ctx_t ctx) + void _fq_poly_compose_mod_brent_kung_preinv(fq_struct * res, const fq_struct * f, slong lenf, const fq_struct * g, const fq_struct * h, slong lenh, const fq_struct * hinv, slong lenhiv, const fq_ctx_t ctx) noexcept # Sets ``res`` to the composition `f(g)` modulo `h`. We require # that `h` is nonzero and that the length of `g` is one less than # the length of `h` (possibly with zero padding). We also require @@ -927,24 +927,24 @@ cdef extern from "flint_wrap.h": # any of the inputs. # The algorithm used is the Brent-Kung matrix algorithm. - void fq_poly_compose_mod_brent_kung_preinv(fq_poly_t res, const fq_poly_t f, const fq_poly_t g, const fq_poly_t h, const fq_poly_t hinv, const fq_ctx_t ctx) + void fq_poly_compose_mod_brent_kung_preinv(fq_poly_t res, const fq_poly_t f, const fq_poly_t g, const fq_poly_t h, const fq_poly_t hinv, const fq_ctx_t ctx) noexcept # Sets ``res`` to the composition `f(g)` modulo `h`. We require # that `h` is nonzero and that `f` has smaller degree than # `h`. Furthermore, we require ``hinv`` to be the inverse of the # reverse of ``h``. The algorithm used is the Brent-Kung matrix # algorithm. - void _fq_poly_compose_mod(fq_struct * res, const fq_struct * f, slong lenf, const fq_struct * g, const fq_struct * h, slong lenh, const fq_ctx_t ctx) + void _fq_poly_compose_mod(fq_struct * res, const fq_struct * f, slong lenf, const fq_struct * g, const fq_struct * h, slong lenh, const fq_ctx_t ctx) noexcept # Sets ``res`` to the composition `f(g)` modulo `h`. We require # that `h` is nonzero and that the length of `g` is one less than # the length of `h` (possibly with zero padding). The output is not # allowed to be aliased with any of the inputs. - void fq_poly_compose_mod(fq_poly_t res, const fq_poly_t f, const fq_poly_t g, const fq_poly_t h, const fq_ctx_t ctx) + void fq_poly_compose_mod(fq_poly_t res, const fq_poly_t f, const fq_poly_t g, const fq_poly_t h, const fq_ctx_t ctx) noexcept # Sets ``res`` to the composition `f(g)` modulo `h`. We require # that `h` is nonzero. - void _fq_poly_compose_mod_preinv(fq_struct * res, const fq_struct * f, slong lenf, const fq_struct * g, const fq_struct * h, slong lenh, const fq_struct * hinv, slong lenhiv, const fq_ctx_t ctx) + void _fq_poly_compose_mod_preinv(fq_struct * res, const fq_struct * f, slong lenf, const fq_struct * g, const fq_struct * h, slong lenh, const fq_struct * hinv, slong lenhiv, const fq_ctx_t ctx) noexcept # Sets ``res`` to the composition `f(g)` modulo `h`. We require # that `h` is nonzero and that the length of `g` is one less than # the length of `h` (possibly with zero padding). We also require @@ -953,30 +953,30 @@ cdef extern from "flint_wrap.h": # reverse of ``h``. The output is not allowed to be aliased with # any of the inputs. - void fq_poly_compose_mod_preinv(fq_poly_t res, const fq_poly_t f, const fq_poly_t g, const fq_poly_t h, const fq_poly_t hinv, const fq_ctx_t ctx) + void fq_poly_compose_mod_preinv(fq_poly_t res, const fq_poly_t f, const fq_poly_t g, const fq_poly_t h, const fq_poly_t hinv, const fq_ctx_t ctx) noexcept # Sets ``res`` to the composition `f(g)` modulo `h`. We require # that `h` is nonzero and that `f` has smaller degree than # `h`. Furthermore, we require ``hinv`` to be the inverse of the # reverse of ``h``. - void _fq_poly_reduce_matrix_mod_poly (fq_mat_t A, const fq_mat_t B, const fq_poly_t f, const fq_ctx_t ctx) + void _fq_poly_reduce_matrix_mod_poly (fq_mat_t A, const fq_mat_t B, const fq_poly_t f, const fq_ctx_t ctx) noexcept # Sets the ith row of ``A`` to the reduction of the ith row of `B` modulo # `f` for `i=1,\ldots,\sqrt{\deg(f)}`. We require `B` to be at least # a `\sqrt{\deg(f)}\times \deg(f)` matrix and `f` to be nonzero. - void _fq_poly_precompute_matrix (fq_mat_t A, const fq_struct* f, const fq_struct* g, slong leng, const fq_struct* ginv, slong lenginv, const fq_ctx_t ctx) + void _fq_poly_precompute_matrix (fq_mat_t A, const fq_struct* f, const fq_struct* g, slong leng, const fq_struct* ginv, slong lenginv, const fq_ctx_t ctx) noexcept # Sets the ith row of ``A`` to `f^i` modulo `g` for # `i=1,\ldots,\sqrt{\deg(g)}`. We require `A` to be a # `\sqrt{\deg(g)}\times \deg(g)` matrix. We require ``ginv`` to # be the inverse of the reverse of ``g`` and `g` to be nonzero. - void fq_poly_precompute_matrix (fq_mat_t A, const fq_poly_t f, const fq_poly_t g, const fq_poly_t ginv, const fq_ctx_t ctx) + void fq_poly_precompute_matrix (fq_mat_t A, const fq_poly_t f, const fq_poly_t g, const fq_poly_t ginv, const fq_ctx_t ctx) noexcept # Sets the ith row of ``A`` to `f^i` modulo `g` for # `i=1,\ldots,\sqrt{\deg(g)}`. We require `A` to be a # `\sqrt{\deg(g)}\times \deg(g)` matrix. We require ``ginv`` to # be the inverse of the reverse of ``g``. - void _fq_poly_compose_mod_brent_kung_precomp_preinv(fq_struct* res, const fq_struct* f, slong lenf, const fq_mat_t A, const fq_struct* h, slong lenh, const fq_struct* hinv, slong lenhinv, const fq_ctx_t ctx) + void _fq_poly_compose_mod_brent_kung_precomp_preinv(fq_struct* res, const fq_struct* f, slong lenf, const fq_mat_t A, const fq_struct* h, slong lenh, const fq_struct* hinv, slong lenhinv, const fq_ctx_t ctx) noexcept # Sets ``res`` to the composition `f(g)` modulo `h`. We require # that `h` is nonzero. We require that the ith row of `A` contains # `g^i` for `i=1,\ldots,\sqrt{\deg(h)}`, i.e. `A` is a @@ -986,7 +986,7 @@ cdef extern from "flint_wrap.h": # The output is not allowed to be aliased with any of the inputs. # The algorithm used is the Brent-Kung matrix algorithm. - void fq_poly_compose_mod_brent_kung_precomp_preinv(fq_poly_t res, const fq_poly_t f, const fq_mat_t A, const fq_poly_t h, const fq_poly_t hinv, const fq_ctx_t ctx) + void fq_poly_compose_mod_brent_kung_precomp_preinv(fq_poly_t res, const fq_poly_t f, const fq_mat_t A, const fq_poly_t h, const fq_poly_t hinv, const fq_ctx_t ctx) noexcept # Sets ``res`` to the composition `f(g)` modulo `h`. We require # that the ith row of `A` contains `g^i` for # `i=1,\ldots,\sqrt{\deg(h)}`, i.e. `A` is a `\sqrt{\deg(h)}\times @@ -997,79 +997,79 @@ cdef extern from "flint_wrap.h": # several modular composition of the form `f(g)` modulo `h` for # fixed `g` and `h`. - int _fq_poly_fprint_pretty(FILE *file, const fq_struct *poly, slong len, const char *x, const fq_ctx_t ctx) + int _fq_poly_fprint_pretty(FILE *file, const fq_struct *poly, slong len, const char *x, const fq_ctx_t ctx) noexcept # Prints the pretty representation of ``(poly, len)`` to the stream # ``file``, using the string ``x`` to represent the indeterminate. # In case of success, returns a positive value. In case of failure, # returns a non-positive value. - int fq_poly_fprint_pretty(FILE * file, const fq_poly_t poly, const char *x, const fq_ctx_t ctx) + int fq_poly_fprint_pretty(FILE * file, const fq_poly_t poly, const char *x, const fq_ctx_t ctx) noexcept # Prints the pretty representation of ``poly`` to the stream # ``file``, using the string ``x`` to represent the indeterminate. # In case of success, returns a positive value. In case of failure, # returns a non-positive value. - int _fq_poly_print_pretty(const fq_struct *poly, slong len, const char *x, const fq_ctx_t ctx) + int _fq_poly_print_pretty(const fq_struct *poly, slong len, const char *x, const fq_ctx_t ctx) noexcept # Prints the pretty representation of ``(poly, len)`` to ``stdout``, # using the string ``x`` to represent the indeterminate. # In case of success, returns a positive value. In case of failure, # returns a non-positive value. - int fq_poly_print_pretty(const fq_poly_t poly, const char *x, const fq_ctx_t ctx) + int fq_poly_print_pretty(const fq_poly_t poly, const char *x, const fq_ctx_t ctx) noexcept # Prints the pretty representation of ``poly`` to ``stdout``, # using the string ``x`` to represent the indeterminate. # In case of success, returns a positive value. In case of failure, # returns a non-positive value. - int _fq_poly_fprint(FILE *file, const fq_struct *poly, slong len, const fq_ctx_t ctx) + int _fq_poly_fprint(FILE *file, const fq_struct *poly, slong len, const fq_ctx_t ctx) noexcept # Prints the pretty representation of ``(poly, len)`` to the stream # ``file``. # In case of success, returns a positive value. In case of failure, # returns a non-positive value. - int fq_poly_fprint(FILE * file, const fq_poly_t poly, const fq_ctx_t ctx) + int fq_poly_fprint(FILE * file, const fq_poly_t poly, const fq_ctx_t ctx) noexcept # Prints the pretty representation of ``poly`` to the stream # ``file``. # In case of success, returns a positive value. In case of failure, # returns a non-positive value. - int _fq_poly_print(const fq_struct *poly, slong len, const fq_ctx_t ctx) + int _fq_poly_print(const fq_struct *poly, slong len, const fq_ctx_t ctx) noexcept # Prints the pretty representation of ``(poly, len)`` to ``stdout``. # In case of success, returns a positive value. In case of failure, # returns a non-positive value. - int fq_poly_print(const fq_poly_t poly, const fq_ctx_t ctx) + int fq_poly_print(const fq_poly_t poly, const fq_ctx_t ctx) noexcept # Prints the representation of ``poly`` to ``stdout``. # In case of success, returns a positive value. In case of failure, # returns a non-positive value. - char * _fq_poly_get_str(const fq_struct * poly, slong len, const fq_ctx_t ctx) + char * _fq_poly_get_str(const fq_struct * poly, slong len, const fq_ctx_t ctx) noexcept # Returns the plain FLINT string representation of the polynomial # ``(poly, len)``. - char * fq_poly_get_str(const fq_poly_t poly, const fq_ctx_t ctx) + char * fq_poly_get_str(const fq_poly_t poly, const fq_ctx_t ctx) noexcept # Returns the plain FLINT string representation of the polynomial # ``poly``. - char * _fq_poly_get_str_pretty(const fq_struct * poly, slong len, const char * x, const fq_ctx_t ctx) + char * _fq_poly_get_str_pretty(const fq_struct * poly, slong len, const char * x, const fq_ctx_t ctx) noexcept # Returns a pretty representation of the polynomial # ``(poly, len)`` using the null-terminated string ``x`` as the # variable name. - char * fq_poly_get_str_pretty(const fq_poly_t poly, const char * x, const fq_ctx_t ctx) + char * fq_poly_get_str_pretty(const fq_poly_t poly, const char * x, const fq_ctx_t ctx) noexcept # Returns a pretty representation of the polynomial ``poly`` using the # null-terminated string ``x`` as the variable name - void fq_poly_inflate(fq_poly_t result, const fq_poly_t input, ulong inflation, const fq_ctx_t ctx) + void fq_poly_inflate(fq_poly_t result, const fq_poly_t input, ulong inflation, const fq_ctx_t ctx) noexcept # Sets ``result`` to the inflated polynomial `p(x^n)` where # `p` is given by ``input`` and `n` is given by ``inflation``. - void fq_poly_deflate(fq_poly_t result, const fq_poly_t input, ulong deflation, const fq_ctx_t ctx) + void fq_poly_deflate(fq_poly_t result, const fq_poly_t input, ulong deflation, const fq_ctx_t ctx) noexcept # Sets ``result`` to the deflated polynomial `p(x^{1/n})` where # `p` is given by ``input`` and `n` is given by ``deflation``. # Requires `n > 0`. - ulong fq_poly_deflation(const fq_poly_t input, const fq_ctx_t ctx) + ulong fq_poly_deflation(const fq_poly_t input, const fq_ctx_t ctx) noexcept # Returns the largest integer by which ``input`` can be deflated. # As special cases, returns 0 if ``input`` is the zero polynomial # and 1 of ``input`` is a constant polynomial. diff --git a/src/sage/libs/flint/fq_poly_factor.pxd b/src/sage/libs/flint/fq_poly_factor.pxd index a914d98b427..4a5dedcc73c 100644 --- a/src/sage/libs/flint/fq_poly_factor.pxd +++ b/src/sage/libs/flint/fq_poly_factor.pxd @@ -12,91 +12,91 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void fq_poly_factor_init(fq_poly_factor_t fac, const fq_ctx_t ctx) + void fq_poly_factor_init(fq_poly_factor_t fac, const fq_ctx_t ctx) noexcept # Initialises ``fac`` for use. An :type:`fq_poly_factor_t` # represents a polynomial in factorised form as a product of # polynomials with associated exponents. - void fq_poly_factor_clear(fq_poly_factor_t fac, const fq_ctx_t ctx) + void fq_poly_factor_clear(fq_poly_factor_t fac, const fq_ctx_t ctx) noexcept # Frees all memory associated with ``fac``. - void fq_poly_factor_realloc(fq_poly_factor_t fac, slong alloc, const fq_ctx_t ctx) + void fq_poly_factor_realloc(fq_poly_factor_t fac, slong alloc, const fq_ctx_t ctx) noexcept # Reallocates the factor structure to provide space for # precisely ``alloc`` factors. - void fq_poly_factor_fit_length(fq_poly_factor_t fac, slong len, const fq_ctx_t ctx) + void fq_poly_factor_fit_length(fq_poly_factor_t fac, slong len, const fq_ctx_t ctx) noexcept # Ensures that the factor structure has space for at least # ``len`` factors. This function takes care of the case of # repeated calls by always at least doubling the number of factors # the structure can hold. - void fq_poly_factor_set(fq_poly_factor_t res, const fq_poly_factor_t fac, const fq_ctx_t ctx) + void fq_poly_factor_set(fq_poly_factor_t res, const fq_poly_factor_t fac, const fq_ctx_t ctx) noexcept # Sets ``res`` to the same factorisation as ``fac``. - void fq_poly_factor_print_pretty(const fq_poly_factor_t fac, const char * var, const fq_ctx_t ctx) + void fq_poly_factor_print_pretty(const fq_poly_factor_t fac, const char * var, const fq_ctx_t ctx) noexcept # Pretty-prints the entries of ``fac`` to standard output. - void fq_poly_factor_print(const fq_poly_factor_t fac, const fq_ctx_t ctx) + void fq_poly_factor_print(const fq_poly_factor_t fac, const fq_ctx_t ctx) noexcept # Prints the entries of ``fac`` to standard output. - void fq_poly_factor_insert(fq_poly_factor_t fac, const fq_poly_t poly, slong exp, const fq_ctx_t ctx) + void fq_poly_factor_insert(fq_poly_factor_t fac, const fq_poly_t poly, slong exp, const fq_ctx_t ctx) noexcept # Inserts the factor ``poly`` with multiplicity ``exp`` into # the factorisation ``fac``. # If ``fac`` already contains ``poly``, then ``exp`` simply # gets added to the exponent of the existing entry. - void fq_poly_factor_concat(fq_poly_factor_t res, const fq_poly_factor_t fac, const fq_ctx_t ctx) + void fq_poly_factor_concat(fq_poly_factor_t res, const fq_poly_factor_t fac, const fq_ctx_t ctx) noexcept # Concatenates two factorisations. # This is equivalent to calling :func:`fq_poly_factor_insert` # repeatedly with the individual factors of ``fac``. # Does not support aliasing between ``res`` and ``fac``. - void fq_poly_factor_pow(fq_poly_factor_t fac, slong exp, const fq_ctx_t ctx) + void fq_poly_factor_pow(fq_poly_factor_t fac, slong exp, const fq_ctx_t ctx) noexcept # Raises ``fac`` to the power ``exp``. - ulong fq_poly_remove(fq_poly_t f, const fq_poly_t p, const fq_ctx_t ctx) + ulong fq_poly_remove(fq_poly_t f, const fq_poly_t p, const fq_ctx_t ctx) noexcept # Removes the highest possible power of ``p`` from ``f`` and # returns the exponent. - bint fq_poly_is_irreducible(const fq_poly_t f, const fq_ctx_t ctx) + bint fq_poly_is_irreducible(const fq_poly_t f, const fq_ctx_t ctx) noexcept # Returns 1 if the polynomial ``f`` is irreducible, otherwise returns 0. - bint fq_poly_is_irreducible_ddf(const fq_poly_t f, const fq_ctx_t ctx) + bint fq_poly_is_irreducible_ddf(const fq_poly_t f, const fq_ctx_t ctx) noexcept # Returns 1 if the polynomial ``f`` is irreducible, otherwise returns 0. # Uses fast distinct-degree factorisation. - bint fq_poly_is_irreducible_ben_or(const fq_poly_t f, const fq_ctx_t ctx) + bint fq_poly_is_irreducible_ben_or(const fq_poly_t f, const fq_ctx_t ctx) noexcept # Returns 1 if the polynomial ``f`` is irreducible, otherwise returns 0. # Uses Ben-Or's irreducibility test. - bint _fq_poly_is_squarefree(const fq_struct * f, slong len, const fq_ctx_t ctx) + bint _fq_poly_is_squarefree(const fq_struct * f, slong len, const fq_ctx_t ctx) noexcept # Returns 1 if ``(f, len)`` is squarefree, and 0 otherwise. As a # special case, the zero polynomial is not considered squarefree. # There are no restrictions on the length. - bint fq_poly_is_squarefree(const fq_poly_t f, const fq_ctx_t ctx) + bint fq_poly_is_squarefree(const fq_poly_t f, const fq_ctx_t ctx) noexcept # Returns 1 if ``f`` is squarefree, and 0 otherwise. As a special # case, the zero polynomial is not considered squarefree. - bint fq_poly_factor_equal_deg_prob(fq_poly_t factor, flint_rand_t state, const fq_poly_t pol, slong d, const fq_ctx_t ctx) + bint fq_poly_factor_equal_deg_prob(fq_poly_t factor, flint_rand_t state, const fq_poly_t pol, slong d, const fq_ctx_t ctx) noexcept # Probabilistic equal degree factorisation of ``pol`` into # irreducible factors of degree ``d``. If it passes, a factor is # placed in factor and 1 is returned, otherwise 0 is returned and # the value of factor is undetermined. # Requires that ``pol`` be monic, non-constant and squarefree. - void fq_poly_factor_equal_deg(fq_poly_factor_t factors, const fq_poly_t pol, slong d, const fq_ctx_t ctx) + void fq_poly_factor_equal_deg(fq_poly_factor_t factors, const fq_poly_t pol, slong d, const fq_ctx_t ctx) noexcept # Assuming ``pol`` is a product of irreducible factors all of # degree ``d``, finds all those factors and places them in # factors. Requires that ``pol`` be monic, non-constant and # squarefree. - void fq_poly_factor_split_single(fq_poly_t linfactor, const fq_poly_t input, const fq_ctx_t ctx) + void fq_poly_factor_split_single(fq_poly_t linfactor, const fq_poly_t input, const fq_ctx_t ctx) noexcept # Assuming ``input`` is a product of factors all of degree 1, finds a single # linear factor of ``input`` and places it in ``linfactor``. # Requires that ``input`` be monic and non-constant. - void fq_poly_factor_distinct_deg(fq_poly_factor_t res, const fq_poly_t poly, slong * const *degs, const fq_ctx_t ctx) + void fq_poly_factor_distinct_deg(fq_poly_factor_t res, const fq_poly_t poly, slong * const *degs, const fq_ctx_t ctx) noexcept # Factorises a monic non-constant squarefree polynomial ``poly`` # of degree `n` into factors `f[d]` such that for `1 \leq d \leq n` # `f[d]` is the product of the monic irreducible factors of @@ -106,31 +106,31 @@ cdef extern from "flint_wrap.h": # Requires that ``degs`` have enough space for irreducible polynomials' # powers (maximum space required is ``n * sizeof(slong)``). - void fq_poly_factor_squarefree(fq_poly_factor_t res, const fq_poly_t f, const fq_ctx_t ctx) + void fq_poly_factor_squarefree(fq_poly_factor_t res, const fq_poly_t f, const fq_ctx_t ctx) noexcept # Sets ``res`` to a squarefree factorization of ``f``. - void fq_poly_factor(fq_poly_factor_t res, fq_t lead, const fq_poly_t f, const fq_ctx_t ctx) + void fq_poly_factor(fq_poly_factor_t res, fq_t lead, const fq_poly_t f, const fq_ctx_t ctx) noexcept # Factorises a non-constant polynomial ``f`` into monic # irreducible factors choosing the best algorithm for given modulo # and degree. The output ``lead`` is set to the leading coefficient of `f` # upon return. Choice of algorithm is based on heuristic measurements. - void fq_poly_factor_cantor_zassenhaus(fq_poly_factor_t res, const fq_poly_t f, const fq_ctx_t ctx) + void fq_poly_factor_cantor_zassenhaus(fq_poly_factor_t res, const fq_poly_t f, const fq_ctx_t ctx) noexcept # Factorises a non-constant polynomial ``f`` into monic # irreducible factors using the Cantor-Zassenhaus algorithm. - void fq_poly_factor_kaltofen_shoup(fq_poly_factor_t res, const fq_poly_t poly, const fq_ctx_t ctx) + void fq_poly_factor_kaltofen_shoup(fq_poly_factor_t res, const fq_poly_t poly, const fq_ctx_t ctx) noexcept # Factorises a non-constant polynomial ``f`` into monic # irreducible factors using the fast version of Cantor-Zassenhaus # algorithm proposed by Kaltofen and Shoup (1998). More precisely # this algorithm uses a “baby step/giant step” strategy for the # distinct-degree factorization step. - void fq_poly_factor_berlekamp(fq_poly_factor_t factors, const fq_poly_t f, const fq_ctx_t ctx) + void fq_poly_factor_berlekamp(fq_poly_factor_t factors, const fq_poly_t f, const fq_ctx_t ctx) noexcept # Factorises a non-constant polynomial ``f`` into monic # irreducible factors using the Berlekamp algorithm. - void fq_poly_factor_with_berlekamp(fq_poly_factor_t res, fq_t leading_coeff, const fq_poly_t f, const fq_ctx_t ctx) + void fq_poly_factor_with_berlekamp(fq_poly_factor_t res, fq_t leading_coeff, const fq_poly_t f, const fq_ctx_t ctx) noexcept # Factorises a general polynomial ``f`` into monic irreducible # factors and sets ``leading_coeff`` to the leading coefficient # of ``f``, or 0 if ``f`` is the zero polynomial. @@ -139,7 +139,7 @@ cdef extern from "flint_wrap.h": # performs a square-free factorisation, and finally runs Berlekamp # factorisation on all the individual square-free factors. - void fq_poly_factor_with_cantor_zassenhaus(fq_poly_factor_t res, fq_t leading_coeff, const fq_poly_t f, const fq_ctx_t ctx) + void fq_poly_factor_with_cantor_zassenhaus(fq_poly_factor_t res, fq_t leading_coeff, const fq_poly_t f, const fq_ctx_t ctx) noexcept # Factorises a general polynomial ``f`` into monic irreducible # factors and sets ``leading_coeff`` to the leading coefficient # of ``f``, or 0 if ``f`` is the zero polynomial. @@ -148,7 +148,7 @@ cdef extern from "flint_wrap.h": # performs a square-free factorisation, and finally runs # Cantor-Zassenhaus on all the individual square-free factors. - void fq_poly_factor_with_kaltofen_shoup(fq_poly_factor_t res, fq_t leading_coeff, const fq_poly_t f, const fq_ctx_t ctx) + void fq_poly_factor_with_kaltofen_shoup(fq_poly_factor_t res, fq_t leading_coeff, const fq_poly_t f, const fq_ctx_t ctx) noexcept # Factorises a general polynomial ``f`` into monic irreducible # factors and sets ``leading_coeff`` to the leading coefficient # of ``f``, or 0 if ``f`` is the zero polynomial. @@ -157,12 +157,12 @@ cdef extern from "flint_wrap.h": # performs a square-free factorisation, and finally runs # Kaltofen-Shoup on all the individual square-free factors. - void fq_poly_iterated_frobenius_preinv(fq_poly_t *rop, slong n, const fq_poly_t v, const fq_poly_t vinv, const fq_ctx_t ctx) + void fq_poly_iterated_frobenius_preinv(fq_poly_t *rop, slong n, const fq_poly_t v, const fq_poly_t vinv, const fq_ctx_t ctx) noexcept # Sets ``rop[i]`` to be `x^{q^i}\bmod v` for `0 \le i < n`. # It is required that ``vinv`` is the inverse of the reverse of # ``v`` mod ``x^lenv``. - void fq_poly_roots(fq_poly_factor_t r, const fq_poly_t f, int with_multiplicity, const fq_ctx_t ctx) + void fq_poly_roots(fq_poly_factor_t r, const fq_poly_t f, int with_multiplicity, const fq_ctx_t ctx) noexcept # Fill `r` with factors of the form `x - r_i` where the `r_i` are the distinct roots of a nonzero `f` in `F_q`. # If `with\_multiplicity` is zero, the exponent `e_i` of the factor `x - r_i` is `1`. Otherwise, it is the largest `e_i` such that `(x-r_i)^e_i` divides `f`. # This function throws if `f` is zero, but is otherwise always successful. diff --git a/src/sage/libs/flint/fq_vec.pxd b/src/sage/libs/flint/fq_vec.pxd index 7475e0dc8f7..506f4133404 100644 --- a/src/sage/libs/flint/fq_vec.pxd +++ b/src/sage/libs/flint/fq_vec.pxd @@ -12,62 +12,62 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - fq_struct * _fq_vec_init(slong len, const fq_ctx_t ctx) + fq_struct * _fq_vec_init(slong len, const fq_ctx_t ctx) noexcept # Returns an initialised vector of ``fq``'s of given length. - void _fq_vec_clear(fq_struct * vec, slong len, const fq_ctx_t ctx) + void _fq_vec_clear(fq_struct * vec, slong len, const fq_ctx_t ctx) noexcept # Clears the entries of ``(vec, len)`` and frees the space allocated # for ``vec``. - void _fq_vec_randtest(fq_struct * f, flint_rand_t state, slong len, const fq_ctx_t ctx) + void _fq_vec_randtest(fq_struct * f, flint_rand_t state, slong len, const fq_ctx_t ctx) noexcept # Sets the entries of a vector of the given length to elements of # the finite field. - int _fq_vec_fprint(FILE * file, const fq_struct * vec, slong len, const fq_ctx_t ctx) + int _fq_vec_fprint(FILE * file, const fq_struct * vec, slong len, const fq_ctx_t ctx) noexcept # Prints the vector of given length to the stream ``file``. The # format is the length followed by two spaces, then a space separated # list of coefficients. If the length is zero, only `0` is printed. # In case of success, returns a positive value. In case of failure, # returns a non-positive value. - int _fq_vec_print(const fq_struct * vec, slong len, const fq_ctx_t ctx) + int _fq_vec_print(const fq_struct * vec, slong len, const fq_ctx_t ctx) noexcept # Prints the vector of given length to ``stdout``. # For further details, see ``_fq_vec_fprint()``. - void _fq_vec_set(fq_struct * vec1, const fq_struct * vec2, slong len2, const fq_ctx_t ctx) + void _fq_vec_set(fq_struct * vec1, const fq_struct * vec2, slong len2, const fq_ctx_t ctx) noexcept # Makes a copy of ``(vec2, len2)`` into ``vec1``. - void _fq_vec_swap(fq_struct * vec1, fq_struct * vec2, slong len2, const fq_ctx_t ctx) + void _fq_vec_swap(fq_struct * vec1, fq_struct * vec2, slong len2, const fq_ctx_t ctx) noexcept # Swaps the elements in ``(vec1, len2)`` and ``(vec2, len2)``. - void _fq_vec_zero(fq_struct * vec, slong len, const fq_ctx_t ctx) + void _fq_vec_zero(fq_struct * vec, slong len, const fq_ctx_t ctx) noexcept # Zeros the entries of ``(vec, len)``. - void _fq_vec_neg(fq_struct * vec1, const fq_struct * vec2, slong len2, const fq_ctx_t ctx) + void _fq_vec_neg(fq_struct * vec1, const fq_struct * vec2, slong len2, const fq_ctx_t ctx) noexcept # Negates ``(vec2, len2)`` and places it into ``vec1``. - bint _fq_vec_equal(const fq_struct * vec1, const fq_struct * vec2, slong len, const fq_ctx_t ctx) + bint _fq_vec_equal(const fq_struct * vec1, const fq_struct * vec2, slong len, const fq_ctx_t ctx) noexcept # Compares two vectors of the given length and returns `1` if they are # equal, otherwise returns `0`. - bint _fq_vec_is_zero(const fq_struct * vec, slong len, const fq_ctx_t ctx) + bint _fq_vec_is_zero(const fq_struct * vec, slong len, const fq_ctx_t ctx) noexcept # Returns `1` if ``(vec, len)`` is zero, and `0` otherwise. - void _fq_vec_add(fq_struct * res, const fq_struct * vec1, const fq_struct * vec2, slong len2, const fq_ctx_t ctx) + void _fq_vec_add(fq_struct * res, const fq_struct * vec1, const fq_struct * vec2, slong len2, const fq_ctx_t ctx) noexcept # Sets ``(res, len2)`` to the sum of ``(vec1, len2)`` # and ``(vec2, len2)``. - void _fq_vec_sub(fq_struct * res, const fq_struct * vec1, const fq_struct * vec2, slong len2, const fq_ctx_t ctx) + void _fq_vec_sub(fq_struct * res, const fq_struct * vec1, const fq_struct * vec2, slong len2, const fq_ctx_t ctx) noexcept # Sets ``(res, len2)`` to ``(vec1, len2)`` minus ``(vec2, len2)``. - void _fq_vec_scalar_addmul_fq(fq_struct * vec1, const fq_struct * vec2, slong len2, const fq_t c, const fq_ctx_t ctx) + void _fq_vec_scalar_addmul_fq(fq_struct * vec1, const fq_struct * vec2, slong len2, const fq_t c, const fq_ctx_t ctx) noexcept # Adds ``(vec2, len2)`` times `c` to ``(vec1, len2)``, where # `c` is a ``fq_t``. - void _fq_vec_scalar_submul_fq(fq_struct * vec1, const fq_struct * vec2, slong len2, const fq_t c, const fq_ctx_t ctx) + void _fq_vec_scalar_submul_fq(fq_struct * vec1, const fq_struct * vec2, slong len2, const fq_t c, const fq_ctx_t ctx) noexcept # Subtracts ``(vec2, len2)`` times `c` from ``(vec1, len2)``, # where `c` is a ``fq_t``. - void _fq_vec_dot(fq_t res, const fq_struct * vec1, const fq_struct * vec2, slong len2, const fq_ctx_t ctx) + void _fq_vec_dot(fq_t res, const fq_struct * vec1, const fq_struct * vec2, slong len2, const fq_ctx_t ctx) noexcept # Sets ``res`` to the dot product of (``vec1``, ``len``) # and (``vec2``, ``len``). diff --git a/src/sage/libs/flint/fq_zech.pxd b/src/sage/libs/flint/fq_zech.pxd index a6b22cd4589..b0cf8c2f0c6 100644 --- a/src/sage/libs/flint/fq_zech.pxd +++ b/src/sage/libs/flint/fq_zech.pxd @@ -12,7 +12,7 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void fq_zech_ctx_init(fq_zech_ctx_t ctx, const fmpz_t p, slong d, const char *var) + void fq_zech_ctx_init(fq_zech_ctx_t ctx, const fmpz_t p, slong d, const char *var) noexcept # Initialises the context for prime `p` and extension degree `d`, # with name ``var`` for the generator. By default, it will try # use a Conway polynomial; if one is not available, a random @@ -21,7 +21,7 @@ cdef extern from "flint_wrap.h": # Assumes that the string ``var`` is a null-terminated string # of length at least one. - int _fq_zech_ctx_init_conway(fq_zech_ctx_t ctx, const fmpz_t p, slong d, const char *var) + int _fq_zech_ctx_init_conway(fq_zech_ctx_t ctx, const fmpz_t p, slong d, const char *var) noexcept # Attempts to initialise the context for prime `p` and extension # degree `d`, with name ``var`` for the generator using a Conway # polynomial for the modulus. @@ -32,7 +32,7 @@ cdef extern from "flint_wrap.h": # Assumes that the string ``var`` is a null-terminated string # of length at least one. - void fq_zech_ctx_init_conway(fq_zech_ctx_t ctx, const fmpz_t p, slong d, const char *var) + void fq_zech_ctx_init_conway(fq_zech_ctx_t ctx, const fmpz_t p, slong d, const char *var) noexcept # Initialises the context for prime `p` and extension degree `d`, # with name ``var`` for the generator using a Conway polynomial # for the modulus. @@ -40,7 +40,7 @@ cdef extern from "flint_wrap.h": # Assumes that the string ``var`` is a null-terminated string # of length at least one. - void fq_zech_ctx_init_random(fq_zech_ctx_t ctx, const fmpz_t p, slong d, const char *var) + void fq_zech_ctx_init_random(fq_zech_ctx_t ctx, const fmpz_t p, slong d, const char *var) noexcept # Initialises the context for prime `p` and extension degree `d`, # with name ``var`` for the generator using a random primitive # polynomial. @@ -48,7 +48,7 @@ cdef extern from "flint_wrap.h": # Assumes that the string ``var`` is a null-terminated string # of length at least one. - void fq_zech_ctx_init_modulus(fq_zech_ctx_t ctx, const nmod_poly_t modulus, const char *var) + void fq_zech_ctx_init_modulus(fq_zech_ctx_t ctx, const nmod_poly_t modulus, const char *var) noexcept # Initialises the context for given ``modulus`` with name # ``var`` for the generator. # Assumes that ``modulus`` is an primitive polynomial over @@ -57,132 +57,132 @@ cdef extern from "flint_wrap.h": # Assumes that the string ``var`` is a null-terminated string # of length at least one. - int fq_zech_ctx_init_modulus_check(fq_zech_ctx_t ctx, const nmod_poly_t modulus, const char *var) + int fq_zech_ctx_init_modulus_check(fq_zech_ctx_t ctx, const nmod_poly_t modulus, const char *var) noexcept # As per the previous function, but returns `0` if the modulus was not # primitive and `1` if the context was successfully initialised with the # given modulus. No exception is raised. - void fq_zech_ctx_init_fq_nmod_ctx(fq_zech_ctx_t ctx, fq_nmod_ctx_t ctxn) + void fq_zech_ctx_init_fq_nmod_ctx(fq_zech_ctx_t ctx, fq_nmod_ctx_t ctxn) noexcept # Initializes the context ``ctx`` to be the Zech representation # for the finite field given by ``ctxn``. - int fq_zech_ctx_init_fq_nmod_ctx_check(fq_zech_ctx_t ctx, fq_nmod_ctx_t ctxn) + int fq_zech_ctx_init_fq_nmod_ctx_check(fq_zech_ctx_t ctx, fq_nmod_ctx_t ctxn) noexcept # As per the previous function but returns `0` if a non-primitive modulus is # detected. Returns `0` if the Zech representation was successfully # initialised. - void fq_zech_ctx_clear(fq_zech_ctx_t ctx) + void fq_zech_ctx_clear(fq_zech_ctx_t ctx) noexcept # Clears all memory that has been allocated as part of the context. - const nmod_poly_struct* fq_zech_ctx_modulus(const fq_zech_ctx_t ctx) + const nmod_poly_struct* fq_zech_ctx_modulus(const fq_zech_ctx_t ctx) noexcept # Returns a pointer to the modulus in the context. - slong fq_zech_ctx_degree(const fq_zech_ctx_t ctx) + slong fq_zech_ctx_degree(const fq_zech_ctx_t ctx) noexcept # Returns the degree of the field extension # `[\mathbf{F}_{q} : \mathbf{F}_{p}]`, which # is equal to `\log_{p} q`. - fmpz * fq_zech_ctx_prime(const fq_zech_ctx_t ctx) + fmpz * fq_zech_ctx_prime(const fq_zech_ctx_t ctx) noexcept # Returns a pointer to the prime `p` in the context. - void fq_zech_ctx_order(fmpz_t f, const fq_zech_ctx_t ctx) + void fq_zech_ctx_order(fmpz_t f, const fq_zech_ctx_t ctx) noexcept # Sets `f` to be the size of the finite field. - mp_limb_t fq_zech_ctx_order_ui(const fq_zech_ctx_t ctx) + mp_limb_t fq_zech_ctx_order_ui(const fq_zech_ctx_t ctx) noexcept # Returns the size of the finite field. - int fq_zech_ctx_fprint(FILE * file, const fq_zech_ctx_t ctx) + int fq_zech_ctx_fprint(FILE * file, const fq_zech_ctx_t ctx) noexcept # Prints the context information to {\tt{file}}. Returns 1 for a # success and a negative number for an error. - void fq_zech_ctx_print(const fq_zech_ctx_t ctx) + void fq_zech_ctx_print(const fq_zech_ctx_t ctx) noexcept # Prints the context information to {\tt{stdout}}. - void fq_zech_ctx_randtest(fq_zech_ctx_t ctx, flint_rand_t state) + void fq_zech_ctx_randtest(fq_zech_ctx_t ctx, flint_rand_t state) noexcept # Initializes ``ctx`` to a random finite field. Assumes that # ``fq_zech_ctx_init`` has not been called on ``ctx`` already. - void fq_zech_ctx_randtest_reducible(fq_zech_ctx_t ctx, flint_rand_t state) + void fq_zech_ctx_randtest_reducible(fq_zech_ctx_t ctx, flint_rand_t state) noexcept # Since the Zech logarithm representation does not work with a # non-irreducible modulus, does the same as # ``fq_zech_ctx_randtest``. - void fq_zech_init(fq_zech_t rop, const fq_zech_ctx_t ctx) + void fq_zech_init(fq_zech_t rop, const fq_zech_ctx_t ctx) noexcept # Initialises the element ``rop``, setting its value to `0`. - void fq_zech_init2(fq_zech_t rop, const fq_zech_ctx_t ctx) + void fq_zech_init2(fq_zech_t rop, const fq_zech_ctx_t ctx) noexcept # Initialises ``poly`` with at least enough space for it to be an element # of ``ctx`` and sets it to `0`. - void fq_zech_clear(fq_zech_t rop, const fq_zech_ctx_t ctx) + void fq_zech_clear(fq_zech_t rop, const fq_zech_ctx_t ctx) noexcept # Clears the element ``rop``. - void _fq_zech_sparse_reduce(mp_ptr R, slong lenR, const fq_zech_ctx_t ctx) + void _fq_zech_sparse_reduce(mp_ptr R, slong lenR, const fq_zech_ctx_t ctx) noexcept # Reduces ``(R, lenR)`` modulo the polynomial `f` given by the # modulus of ``ctx``. - void _fq_zech_dense_reduce(mp_ptr R, slong lenR, const fq_zech_ctx_t ctx) + void _fq_zech_dense_reduce(mp_ptr R, slong lenR, const fq_zech_ctx_t ctx) noexcept # Reduces ``(R, lenR)`` modulo the polynomial `f` given by the # modulus of ``ctx`` using Newton division. - void _fq_zech_reduce(mp_ptr r, slong lenR, const fq_zech_ctx_t ctx) + void _fq_zech_reduce(mp_ptr r, slong lenR, const fq_zech_ctx_t ctx) noexcept # Reduces ``(R, lenR)`` modulo the polynomial `f` given by the # modulus of ``ctx``. Does either sparse or dense reduction # based on ``ctx->sparse_modulus``. - void fq_zech_reduce(fq_zech_t rop, const fq_zech_ctx_t ctx) + void fq_zech_reduce(fq_zech_t rop, const fq_zech_ctx_t ctx) noexcept # Reduces the polynomial ``rop`` as an element of # `\mathbf{F}_p[X] / (f(X))`. - void fq_zech_add(fq_zech_t rop, const fq_zech_t op1, const fq_zech_t op2, const fq_zech_ctx_t ctx) + void fq_zech_add(fq_zech_t rop, const fq_zech_t op1, const fq_zech_t op2, const fq_zech_ctx_t ctx) noexcept # Sets ``rop`` to the sum of ``op1`` and ``op2``. - void fq_zech_sub(fq_zech_t rop, const fq_zech_t op1, const fq_zech_t op2, const fq_zech_ctx_t ctx) + void fq_zech_sub(fq_zech_t rop, const fq_zech_t op1, const fq_zech_t op2, const fq_zech_ctx_t ctx) noexcept # Sets ``rop`` to the difference of ``op1`` and ``op2``. - void fq_zech_sub_one(fq_zech_t rop, const fq_zech_t op1, const fq_zech_ctx_t ctx) + void fq_zech_sub_one(fq_zech_t rop, const fq_zech_t op1, const fq_zech_ctx_t ctx) noexcept # Sets ``rop`` to the difference of ``op1`` and `1`. - void fq_zech_neg(fq_zech_t rop, const fq_zech_t op, const fq_zech_ctx_t ctx) + void fq_zech_neg(fq_zech_t rop, const fq_zech_t op, const fq_zech_ctx_t ctx) noexcept # Sets ``rop`` to the negative of ``op``. - void fq_zech_mul(fq_zech_t rop, const fq_zech_t op1, const fq_zech_t op2, const fq_zech_ctx_t ctx) + void fq_zech_mul(fq_zech_t rop, const fq_zech_t op1, const fq_zech_t op2, const fq_zech_ctx_t ctx) noexcept # Sets ``rop`` to the product of ``op1`` and ``op2``, # reducing the output in the given context. - void fq_zech_mul_fmpz(fq_zech_t rop, const fq_zech_t op, const fmpz_t x, const fq_zech_ctx_t ctx) + void fq_zech_mul_fmpz(fq_zech_t rop, const fq_zech_t op, const fmpz_t x, const fq_zech_ctx_t ctx) noexcept # Sets ``rop`` to the product of ``op`` and `x`, # reducing the output in the given context. - void fq_zech_mul_si(fq_zech_t rop, const fq_zech_t op, slong x, const fq_zech_ctx_t ctx) + void fq_zech_mul_si(fq_zech_t rop, const fq_zech_t op, slong x, const fq_zech_ctx_t ctx) noexcept # Sets ``rop`` to the product of ``op`` and `x`, # reducing the output in the given context. - void fq_zech_mul_ui(fq_zech_t rop, const fq_zech_t op, ulong x, const fq_zech_ctx_t ctx) + void fq_zech_mul_ui(fq_zech_t rop, const fq_zech_t op, ulong x, const fq_zech_ctx_t ctx) noexcept # Sets ``rop`` to the product of ``op`` and `x`, # reducing the output in the given context. - void fq_zech_sqr(fq_zech_t rop, const fq_zech_t op, const fq_zech_ctx_t ctx) + void fq_zech_sqr(fq_zech_t rop, const fq_zech_t op, const fq_zech_ctx_t ctx) noexcept # Sets ``rop`` to the square of ``op``, # reducing the output in the given context. - void fq_zech_div(fq_zech_t rop, const fq_zech_t op1, const fq_zech_t op2, const fq_zech_ctx_t ctx) + void fq_zech_div(fq_zech_t rop, const fq_zech_t op1, const fq_zech_t op2, const fq_zech_ctx_t ctx) noexcept # Sets ``rop`` to the quotient of ``op1`` and ``op2``, # reducing the output in the given context. - void _fq_zech_inv(mp_ptr *rop, mp_srcptr *op, slong len, const fq_zech_ctx_t ctx) + void _fq_zech_inv(mp_ptr *rop, mp_srcptr *op, slong len, const fq_zech_ctx_t ctx) noexcept # Sets ``(rop, d)`` to the inverse of the non-zero element # ``(op, len)``. - void fq_zech_inv(fq_zech_t rop, const fq_zech_t op, const fq_zech_ctx_t ctx) + void fq_zech_inv(fq_zech_t rop, const fq_zech_t op, const fq_zech_ctx_t ctx) noexcept # Sets ``rop`` to the inverse of the non-zero element ``op``. - void fq_zech_gcdinv(fq_zech_t f, fq_zech_t inv, const fq_zech_t op, const fq_zech_ctx_t ctx) + void fq_zech_gcdinv(fq_zech_t f, fq_zech_t inv, const fq_zech_t op, const fq_zech_ctx_t ctx) noexcept # Sets ``inv`` to be the inverse of ``op`` modulo the modulus # of ``ctx`` and sets ``f`` to one. Since the modulus for # ``ctx`` is always irreducible, ``op`` is always invertible. - void _fq_zech_pow(fmpz *rop, const fmpz *op, slong len, const fmpz_t e, const fmpz * a, const slong *j, slong lena, const fmpz_t p) + void _fq_zech_pow(fmpz *rop, const fmpz *op, slong len, const fmpz_t e, const fmpz * a, const slong *j, slong lena, const fmpz_t p) noexcept # Sets ``(rop, 2*d-1)`` to ``(op,len)`` raised to the power `e`, # reduced modulo `f(X)`, the modulus of ``ctx``. # Assumes that `e \geq 0` and that ``len`` is positive and at most `d`. @@ -191,145 +191,145 @@ cdef extern from "flint_wrap.h": # `f(X)`, which is a polynomial of degree `d`. # Does not support aliasing. - void fq_zech_pow(fq_zech_t rop, const fq_zech_t op, const fmpz_t e, const fq_zech_ctx_t ctx) + void fq_zech_pow(fq_zech_t rop, const fq_zech_t op, const fmpz_t e, const fq_zech_ctx_t ctx) noexcept # Sets ``rop`` the ``op`` raised to the power `e`. # Currently assumes that `e \geq 0`. # Note that for any input ``op``, ``rop`` is set to `1` # whenever `e = 0`. - void fq_zech_pow_ui(fq_zech_t rop, const fq_zech_t op, const ulong e, const fq_zech_ctx_t ctx) + void fq_zech_pow_ui(fq_zech_t rop, const fq_zech_t op, const ulong e, const fq_zech_ctx_t ctx) noexcept # Sets ``rop`` the ``op`` raised to the power `e`. # Currently assumes that `e \geq 0`. # Note that for any input ``op``, ``rop`` is set to `1` # whenever `e = 0`. - int fq_zech_sqrt(fq_zech_t rop, const fq_zech_t op1, const fq_zech_ctx_t ctx) + int fq_zech_sqrt(fq_zech_t rop, const fq_zech_t op1, const fq_zech_ctx_t ctx) noexcept # Sets ``rop`` to the square root of ``op1`` if it is a square, and return # `1`, otherwise return `0`. - void fq_zech_pth_root(fq_zech_t rop, const fq_zech_t op1, const fq_zech_ctx_t ctx) + void fq_zech_pth_root(fq_zech_t rop, const fq_zech_t op1, const fq_zech_ctx_t ctx) noexcept # Sets ``rop`` to a `p^{th}` root root of ``op1``. Currently, # this computes the root by raising ``op1`` to `p^{d-1}` where # `d` is the degree of the extension. - bint fq_zech_is_square(const fq_zech_t op, const fq_zech_ctx_t ctx) + bint fq_zech_is_square(const fq_zech_t op, const fq_zech_ctx_t ctx) noexcept # Return ``1`` if ``op`` is a square. - int fq_zech_fprint_pretty(FILE *file, const fq_zech_t op, const fq_zech_ctx_t ctx) + int fq_zech_fprint_pretty(FILE *file, const fq_zech_t op, const fq_zech_ctx_t ctx) noexcept # Prints a pretty representation of ``op`` to ``file``. # In the current implementation, always returns `1`. The return code is # part of the function's signature to allow for a later implementation to # return the number of characters printed or a non-positive error code. - void fq_zech_print_pretty(const fq_zech_t op, const fq_zech_ctx_t ctx) + void fq_zech_print_pretty(const fq_zech_t op, const fq_zech_ctx_t ctx) noexcept # Prints a pretty representation of ``op`` to ``stdout``. # In the current implementation, always returns `1`. The return code is # part of the function's signature to allow for a later implementation to # return the number of characters printed or a non-positive error code. - int fq_zech_fprint(FILE * file, const fq_zech_t op, const fq_zech_ctx_t ctx) + int fq_zech_fprint(FILE * file, const fq_zech_t op, const fq_zech_ctx_t ctx) noexcept # Prints a representation of ``op`` to ``file``. - void fq_zech_print(const fq_zech_t op, const fq_zech_ctx_t ctx) + void fq_zech_print(const fq_zech_t op, const fq_zech_ctx_t ctx) noexcept # Prints a representation of ``op`` to ``stdout``. - char * fq_zech_get_str(const fq_zech_t op, const fq_zech_ctx_t ctx) + char * fq_zech_get_str(const fq_zech_t op, const fq_zech_ctx_t ctx) noexcept # Returns the plain FLINT string representation of the element # ``op``. - char * fq_zech_get_str_pretty(const fq_zech_t op, const fq_zech_ctx_t ctx) + char * fq_zech_get_str_pretty(const fq_zech_t op, const fq_zech_ctx_t ctx) noexcept # Returns a pretty representation of the element ``op`` using the # null-terminated string ``x`` as the variable name. - void fq_zech_randtest(fq_zech_t rop, flint_rand_t state, const fq_zech_ctx_t ctx) + void fq_zech_randtest(fq_zech_t rop, flint_rand_t state, const fq_zech_ctx_t ctx) noexcept # Generates a random element of `\mathbf{F}_q`. - void fq_zech_randtest_not_zero(fq_zech_t rop, flint_rand_t state, const fq_zech_ctx_t ctx) + void fq_zech_randtest_not_zero(fq_zech_t rop, flint_rand_t state, const fq_zech_ctx_t ctx) noexcept # Generates a random non-zero element of `\mathbf{F}_q`. - void fq_zech_randtest_dense(fq_zech_t rop, flint_rand_t state, const fq_zech_ctx_t ctx) + void fq_zech_randtest_dense(fq_zech_t rop, flint_rand_t state, const fq_zech_ctx_t ctx) noexcept # Generates a random element of `\mathbf{F}_q` which has an # underlying polynomial with dense coefficients. - void fq_zech_rand(fq_zech_t rop, flint_rand_t state, const fq_zech_ctx_t ctx) + void fq_zech_rand(fq_zech_t rop, flint_rand_t state, const fq_zech_ctx_t ctx) noexcept # Generates a high quality random element of `\mathbf{F}_q`. - void fq_zech_rand_not_zero(fq_zech_t rop, flint_rand_t state, const fq_zech_ctx_t ctx) + void fq_zech_rand_not_zero(fq_zech_t rop, flint_rand_t state, const fq_zech_ctx_t ctx) noexcept # Generates a high quality non-zero random element of `\mathbf{F}_q`. - void fq_zech_set(fq_zech_t rop, const fq_zech_t op, const fq_zech_ctx_t ctx) + void fq_zech_set(fq_zech_t rop, const fq_zech_t op, const fq_zech_ctx_t ctx) noexcept # Sets ``rop`` to ``op``. - void fq_zech_set_si(fq_zech_t rop, const slong x, const fq_zech_ctx_t ctx) + void fq_zech_set_si(fq_zech_t rop, const slong x, const fq_zech_ctx_t ctx) noexcept # Sets ``rop`` to ``x``, considered as an element of # `\mathbf{F}_p`. - void fq_zech_set_ui(fq_zech_t rop, const ulong x, const fq_zech_ctx_t ctx) + void fq_zech_set_ui(fq_zech_t rop, const ulong x, const fq_zech_ctx_t ctx) noexcept # Sets ``rop`` to ``x``, considered as an element of # `\mathbf{F}_p`. - void fq_zech_set_fmpz(fq_zech_t rop, const fmpz_t x, const fq_zech_ctx_t ctx) + void fq_zech_set_fmpz(fq_zech_t rop, const fmpz_t x, const fq_zech_ctx_t ctx) noexcept # Sets ``rop`` to ``x``, considered as an element of # `\mathbf{F}_p`. - void fq_zech_swap(fq_zech_t op1, fq_zech_t op2, const fq_zech_ctx_t ctx) + void fq_zech_swap(fq_zech_t op1, fq_zech_t op2, const fq_zech_ctx_t ctx) noexcept # Swaps the two elements ``op1`` and ``op2``. - void fq_zech_zero(fq_zech_t rop, const fq_zech_ctx_t ctx) + void fq_zech_zero(fq_zech_t rop, const fq_zech_ctx_t ctx) noexcept # Sets ``rop`` to zero. - void fq_zech_one(fq_zech_t rop, const fq_zech_ctx_t ctx) + void fq_zech_one(fq_zech_t rop, const fq_zech_ctx_t ctx) noexcept # Sets ``rop`` to one, reduced in the given context. - void fq_zech_gen(fq_zech_t rop, const fq_zech_ctx_t ctx) + void fq_zech_gen(fq_zech_t rop, const fq_zech_ctx_t ctx) noexcept # Sets ``rop`` to a generator for the finite field. # There is no guarantee this is a multiplicative generator of # the finite field. - int fq_zech_get_fmpz(fmpz_t rop, const fq_zech_t op, const fq_zech_ctx_t ctx) + int fq_zech_get_fmpz(fmpz_t rop, const fq_zech_t op, const fq_zech_ctx_t ctx) noexcept # If ``op`` has a lift to the integers, return `1` and set ``rop`` to the lift in `[0,p)`. # Otherwise, return `0` and leave `rop` undefined. - void fq_zech_get_fq_nmod(fq_nmod_t rop, const fq_zech_t op, const fq_zech_ctx_t ctx) + void fq_zech_get_fq_nmod(fq_nmod_t rop, const fq_zech_t op, const fq_zech_ctx_t ctx) noexcept # Sets ``rop`` to the ``fq_nmod_t`` element corresponding to ``op``. - void fq_zech_set_fq_nmod(fq_zech_t rop, const fq_nmod_t op, const fq_zech_ctx_t ctx) + void fq_zech_set_fq_nmod(fq_zech_t rop, const fq_nmod_t op, const fq_zech_ctx_t ctx) noexcept # Sets ``rop`` to the ``fq_zech_t`` element corresponding to ``op``. - void fq_zech_get_nmod_poly(nmod_poly_t a, const fq_zech_t b, const fq_zech_ctx_t ctx) + void fq_zech_get_nmod_poly(nmod_poly_t a, const fq_zech_t b, const fq_zech_ctx_t ctx) noexcept # Set ``a`` to a representative of ``b`` in ``ctx``. # The representatives are taken in `(\mathbb{Z}/p\mathbb{Z})[x]/h(x)` where `h(x)` is the defining polynomial in ``ctx``. - void fq_zech_set_nmod_poly(fq_zech_t a, const nmod_poly_t b, const fq_zech_ctx_t ctx) + void fq_zech_set_nmod_poly(fq_zech_t a, const nmod_poly_t b, const fq_zech_ctx_t ctx) noexcept # Set ``a`` to the element in ``ctx`` with representative ``b``. # The representatives are taken in `(\mathbb{Z}/p\mathbb{Z})[x]/h(x)` where `h(x)` is the defining polynomial in ``ctx``. - void fq_zech_get_nmod_mat(nmod_mat_t col, const fq_zech_t a, const fq_zech_ctx_t ctx) + void fq_zech_get_nmod_mat(nmod_mat_t col, const fq_zech_t a, const fq_zech_ctx_t ctx) noexcept # Convert ``a`` to a column vector of length ``degree(ctx)``. - void fq_zech_set_nmod_mat(fq_zech_t a, const nmod_mat_t col, const fq_zech_ctx_t ctx) + void fq_zech_set_nmod_mat(fq_zech_t a, const nmod_mat_t col, const fq_zech_ctx_t ctx) noexcept # Convert a column vector ``col`` of length ``degree(ctx)`` to # an element of ``ctx``. - bint fq_zech_is_zero(const fq_zech_t op, const fq_zech_ctx_t ctx) + bint fq_zech_is_zero(const fq_zech_t op, const fq_zech_ctx_t ctx) noexcept # Returns whether ``op`` is equal to zero. - bint fq_zech_is_one(const fq_zech_t op, const fq_zech_ctx_t ctx) + bint fq_zech_is_one(const fq_zech_t op, const fq_zech_ctx_t ctx) noexcept # Returns whether ``op`` is equal to one. - bint fq_zech_equal(const fq_zech_t op1, const fq_zech_t op2, const fq_zech_ctx_t ctx) + bint fq_zech_equal(const fq_zech_t op1, const fq_zech_t op2, const fq_zech_ctx_t ctx) noexcept # Returns whether ``op1`` and ``op2`` are equal. - bint fq_zech_is_invertible(const fq_zech_t op, const fq_zech_ctx_t ctx) + bint fq_zech_is_invertible(const fq_zech_t op, const fq_zech_ctx_t ctx) noexcept # Returns whether ``op`` is an invertible element. - bint fq_zech_is_invertible_f(fq_zech_t f, const fq_zech_t op, const fq_zech_ctx_t ctx) + bint fq_zech_is_invertible_f(fq_zech_t f, const fq_zech_t op, const fq_zech_ctx_t ctx) noexcept # Returns whether ``op`` is an invertible element. If it is not, # then ``f`` is set of a factor of the modulus. Since the # modulus for an ``fq_zech_ctx_t`` is always irreducible, then # any non-zero ``op`` will be invertible. - void fq_zech_trace(fmpz_t rop, const fq_zech_t op, const fq_zech_ctx_t ctx) + void fq_zech_trace(fmpz_t rop, const fq_zech_t op, const fq_zech_ctx_t ctx) noexcept # Sets ``rop`` to the trace of ``op``. # For an element `a \in \mathbf{F}_q`, multiplication by `a` defines # a `\mathbf{F}_p`-linear map on `\mathbf{F}_q`. We define the @@ -338,7 +338,7 @@ cdef extern from "flint_wrap.h": # `a` is equal to `\sum_{i=0}^{d-1} \Sigma^i (a)`, where `d = # \log_{p} q`. - void fq_zech_norm(fmpz_t rop, const fq_zech_t op, const fq_zech_ctx_t ctx) + void fq_zech_norm(fmpz_t rop, const fq_zech_t op, const fq_zech_ctx_t ctx) noexcept # Computes the norm of ``op``. # For an element `a \in \mathbf{F}_q`, multiplication by `a` defines # a `\mathbf{F}_p`-linear map on `\mathbf{F}_q`. We define the norm @@ -348,7 +348,7 @@ cdef extern from "flint_wrap.h": # `d = \text{dim}_{\mathbf{F}_p}(\mathbf{F}_q)`. # Algorithm selection is automatic depending on the input. - void fq_zech_frobenius(fq_zech_t rop, const fq_zech_t op, slong e, const fq_zech_ctx_t ctx) + void fq_zech_frobenius(fq_zech_t rop, const fq_zech_t op, slong e, const fq_zech_ctx_t ctx) noexcept # Evaluates the homomorphism `\Sigma^e` at ``op``. # Recall that `\mathbf{F}_q / \mathbf{F}_p` is Galois with Galois group # `\langle \sigma \rangle`, which is also isomorphic to @@ -356,7 +356,7 @@ cdef extern from "flint_wrap.h": # `\sigma \in \operatorname{Gal}(\mathbf{F}_q/\mathbf{F}_p)` is the Frobenius element # `\sigma \colon x \mapsto x^p`. - int fq_zech_multiplicative_order(fmpz * ord, const fq_zech_t op, const fq_zech_ctx_t ctx) + int fq_zech_multiplicative_order(fmpz * ord, const fq_zech_t op, const fq_zech_ctx_t ctx) noexcept # Computes the order of ``op`` as an element of the # multiplicative group of ``ctx``. # Returns 0 if ``op`` is 0, otherwise it returns 1 if ``op`` @@ -366,15 +366,15 @@ cdef extern from "flint_wrap.h": # primitivity of the generator, but can be used to check that other elements # are primitive. - bint fq_zech_is_primitive(const fq_zech_t op, const fq_zech_ctx_t ctx) + bint fq_zech_is_primitive(const fq_zech_t op, const fq_zech_ctx_t ctx) noexcept # Returns whether ``op`` is primitive, i.e., whether it is a # generator of the multiplicative group of ``ctx``. - void fq_zech_bit_pack(fmpz_t f, const fq_zech_t op, flint_bitcnt_t bit_size, const fq_zech_ctx_t ctx) + void fq_zech_bit_pack(fmpz_t f, const fq_zech_t op, flint_bitcnt_t bit_size, const fq_zech_ctx_t ctx) noexcept # Packs ``op`` into bitfields of size ``bit_size``, writing the # result to ``f``. - void fq_zech_bit_unpack(fq_zech_t rop, const fmpz_t f, flint_bitcnt_t bit_size, const fq_zech_ctx_t ctx) + void fq_zech_bit_unpack(fq_zech_t rop, const fmpz_t f, flint_bitcnt_t bit_size, const fq_zech_ctx_t ctx) noexcept # Unpacks into ``rop`` the element with coefficients packed into # fields of size ``bit_size`` as represented by the integer # ``f``. diff --git a/src/sage/libs/flint/fq_zech_embed.pxd b/src/sage/libs/flint/fq_zech_embed.pxd index b008efebd5d..3b80717a548 100644 --- a/src/sage/libs/flint/fq_zech_embed.pxd +++ b/src/sage/libs/flint/fq_zech_embed.pxd @@ -12,7 +12,7 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void fq_zech_embed_gens(fq_zech_t gen_sub, fq_zech_t gen_sup, nmod_poly_t minpoly, const fq_zech_ctx_t sub_ctx, const fq_zech_ctx_t sup_ctx) + void fq_zech_embed_gens(fq_zech_t gen_sub, fq_zech_t gen_sup, nmod_poly_t minpoly, const fq_zech_ctx_t sub_ctx, const fq_zech_ctx_t sup_ctx) noexcept # Given two contexts ``sub_ctx`` and ``sup_ctx``, such that # ``degree(sub_ctx)`` divides ``degree(sup_ctx)``, compute: # * an element ``gen_sub`` in ``sub_ctx`` such that @@ -24,7 +24,7 @@ cdef extern from "flint_wrap.h": # These data uniquely define an embedding of ``sub_ctx`` into # ``sup_ctx``. - void _fq_zech_embed_gens_naive(fq_zech_t gen_sub, fq_zech_t gen_sup, nmod_poly_t minpoly, const fq_zech_ctx_t sub_ctx, const fq_zech_ctx_t sup_ctx) + void _fq_zech_embed_gens_naive(fq_zech_t gen_sub, fq_zech_t gen_sup, nmod_poly_t minpoly, const fq_zech_ctx_t sub_ctx, const fq_zech_ctx_t sup_ctx) noexcept # Given two contexts ``sub_ctx`` and ``sup_ctx``, such that # ``degree(sub_ctx)`` divides ``degree(sup_ctx)``, compute an # embedding of ``sub_ctx`` into ``sup_ctx`` defined as follows: @@ -34,7 +34,7 @@ cdef extern from "flint_wrap.h": # * ``gen_sup`` is a root of ``minpoly`` inside the field # defined by ``sup_ctx``. - void fq_zech_embed_matrices(nmod_mat_t embed, nmod_mat_t project, const fq_zech_t gen_sub, const fq_zech_ctx_t sub_ctx, const fq_zech_t gen_sup, const fq_zech_ctx_t sup_ctx, const nmod_poly_t gen_minpoly) + void fq_zech_embed_matrices(nmod_mat_t embed, nmod_mat_t project, const fq_zech_t gen_sub, const fq_zech_ctx_t sub_ctx, const fq_zech_t gen_sup, const fq_zech_ctx_t sup_ctx, const nmod_poly_t gen_minpoly) noexcept # Given: # * two contexts ``sub_ctx`` and ``sup_ctx``, of # respective degrees `m` and `n`, such that `m` divides `n`; @@ -49,7 +49,7 @@ cdef extern from "flint_wrap.h": # ``project`` `\times` ``embed`` is the `m\times m` identity # matrix. - void fq_zech_embed_trace_matrix(nmod_mat_t res, const nmod_mat_t basis, const fq_zech_ctx_t sub_ctx, const fq_zech_ctx_t sup_ctx) + void fq_zech_embed_trace_matrix(nmod_mat_t res, const nmod_mat_t basis, const fq_zech_ctx_t sub_ctx, const fq_zech_ctx_t sup_ctx) noexcept # Given: # * two contexts ``sub_ctx`` and ``sup_ctx``, of degrees # `m` and `n`, such that `m` divides `n`; @@ -65,33 +65,33 @@ cdef extern from "flint_wrap.h": # `m=n`, ``basis`` represents a Frobenius, and the result is its # inverse matrix. - void fq_zech_embed_composition_matrix(nmod_mat_t matrix, const fq_zech_t gen, const fq_zech_ctx_t ctx) + void fq_zech_embed_composition_matrix(nmod_mat_t matrix, const fq_zech_t gen, const fq_zech_ctx_t ctx) noexcept # Compute the *composition matrix* of ``gen``. # For an element `a\in\mathbf{F}_{p^n}`, its composition matrix is the # matrix whose columns are `a^0, a^1, \ldots, a^{n-1}`. - void fq_zech_embed_composition_matrix_sub(nmod_mat_t matrix, const fq_zech_t gen, const fq_zech_ctx_t ctx, slong trunc) + void fq_zech_embed_composition_matrix_sub(nmod_mat_t matrix, const fq_zech_t gen, const fq_zech_ctx_t ctx, slong trunc) noexcept # Compute the *composition matrix* of ``gen``, truncated to # ``trunc`` columns. - void fq_zech_embed_mul_matrix(nmod_mat_t matrix, const fq_zech_t gen, const fq_zech_ctx_t ctx) + void fq_zech_embed_mul_matrix(nmod_mat_t matrix, const fq_zech_t gen, const fq_zech_ctx_t ctx) noexcept # Compute the *multiplication matrix* of ``gen``. # For an element `a` in `\mathbf{F}_{p^n}=\mathbf{F}_p[x]`, its # multiplication matrix is the matrix whose columns are `a, ax, # \dots, ax^{n-1}`. - void fq_zech_embed_mono_to_dual_matrix(nmod_mat_t res, const fq_zech_ctx_t ctx) + void fq_zech_embed_mono_to_dual_matrix(nmod_mat_t res, const fq_zech_ctx_t ctx) noexcept # Compute the change of basis matrix from the monomial basis of # ``ctx`` to its dual basis. - void fq_zech_embed_dual_to_mono_matrix(nmod_mat_t res, const fq_zech_ctx_t ctx) + void fq_zech_embed_dual_to_mono_matrix(nmod_mat_t res, const fq_zech_ctx_t ctx) noexcept # Compute the change of basis matrix from the dual basis of # ``ctx`` to its monomial basis. - void fq_zech_modulus_pow_series_inv(nmod_poly_t res, const fq_zech_ctx_t ctx, slong trunc) + void fq_zech_modulus_pow_series_inv(nmod_poly_t res, const fq_zech_ctx_t ctx, slong trunc) noexcept # Compute the power series inverse of the reverse of the modulus of # ``ctx`` up to `O(x^\texttt{trunc})`. - void fq_zech_modulus_derivative_inv(fq_zech_t m_prime, fq_zech_t m_prime_inv, const fq_zech_ctx_t ctx) + void fq_zech_modulus_derivative_inv(fq_zech_t m_prime, fq_zech_t m_prime_inv, const fq_zech_ctx_t ctx) noexcept # Compute the derivative ``m_prime`` of the modulus of ``ctx`` # as an element of ``ctx``, and its inverse ``m_prime_inv``. diff --git a/src/sage/libs/flint/fq_zech_mat.pxd b/src/sage/libs/flint/fq_zech_mat.pxd index 72ea94dfdb6..174f6968daa 100644 --- a/src/sage/libs/flint/fq_zech_mat.pxd +++ b/src/sage/libs/flint/fq_zech_mat.pxd @@ -12,99 +12,99 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void fq_zech_mat_init(fq_zech_mat_t mat, slong rows, slong cols, const fq_zech_ctx_t ctx) + void fq_zech_mat_init(fq_zech_mat_t mat, slong rows, slong cols, const fq_zech_ctx_t ctx) noexcept # Initialises ``mat`` to a ``rows``-by-``cols`` matrix with # coefficients in `\mathbf{F}_{q}` given by ``ctx``. All elements # are set to zero. - void fq_zech_mat_init_set(fq_zech_mat_t mat, const fq_zech_mat_t src, const fq_zech_ctx_t ctx) + void fq_zech_mat_init_set(fq_zech_mat_t mat, const fq_zech_mat_t src, const fq_zech_ctx_t ctx) noexcept # Initialises ``mat`` and sets its dimensions and elements to # those of ``src``. - void fq_zech_mat_clear(fq_zech_mat_t mat, const fq_zech_ctx_t ctx) + void fq_zech_mat_clear(fq_zech_mat_t mat, const fq_zech_ctx_t ctx) noexcept # Clears the matrix and releases any memory it used. The matrix # cannot be used again until it is initialised. This function must be # called exactly once when finished using an ``fq_zech_mat_t`` object. - void fq_zech_mat_set(fq_zech_mat_t mat, const fq_zech_mat_t src, const fq_zech_ctx_t ctx) + void fq_zech_mat_set(fq_zech_mat_t mat, const fq_zech_mat_t src, const fq_zech_ctx_t ctx) noexcept # Sets ``mat`` to a copy of ``src``. It is assumed # that ``mat`` and ``src`` have identical dimensions. - fq_zech_struct * fq_zech_mat_entry(const fq_zech_mat_t mat, slong i, slong j) + fq_zech_struct * fq_zech_mat_entry(const fq_zech_mat_t mat, slong i, slong j) noexcept # Directly accesses the entry in ``mat`` in row `i` and column `j`, # indexed from zero. No bounds checking is performed. - void fq_zech_mat_entry_set(fq_zech_mat_t mat, slong i, slong j, const fq_zech_t x, const fq_zech_ctx_t ctx) + void fq_zech_mat_entry_set(fq_zech_mat_t mat, slong i, slong j, const fq_zech_t x, const fq_zech_ctx_t ctx) noexcept # Sets the entry in ``mat`` in row `i` and column `j` to ``x``. - slong fq_zech_mat_nrows(const fq_zech_mat_t mat, const fq_zech_ctx_t ctx) + slong fq_zech_mat_nrows(const fq_zech_mat_t mat, const fq_zech_ctx_t ctx) noexcept # Returns the number of rows in ``mat``. - slong fq_zech_mat_ncols(const fq_zech_mat_t mat, const fq_zech_ctx_t ctx) + slong fq_zech_mat_ncols(const fq_zech_mat_t mat, const fq_zech_ctx_t ctx) noexcept # Returns the number of columns in ``mat``. - void fq_zech_mat_swap(fq_zech_mat_t mat1, fq_zech_mat_t mat2, const fq_zech_ctx_t ctx) + void fq_zech_mat_swap(fq_zech_mat_t mat1, fq_zech_mat_t mat2, const fq_zech_ctx_t ctx) noexcept # Swaps two matrices. The dimensions of ``mat1`` and ``mat2`` # are allowed to be different. - void fq_zech_mat_swap_entrywise(fq_zech_mat_t mat1, fq_zech_mat_t mat2, const fq_zech_ctx_t ctx) + void fq_zech_mat_swap_entrywise(fq_zech_mat_t mat1, fq_zech_mat_t mat2, const fq_zech_ctx_t ctx) noexcept # Swaps two matrices by swapping the individual entries rather than swapping # the contents of the structs. - void fq_zech_mat_zero(fq_zech_mat_t mat, const fq_zech_ctx_t ctx) + void fq_zech_mat_zero(fq_zech_mat_t mat, const fq_zech_ctx_t ctx) noexcept # Sets all entries of ``mat`` to 0. - void fq_zech_mat_one(fq_zech_mat_t mat, const fq_zech_ctx_t ctx) + void fq_zech_mat_one(fq_zech_mat_t mat, const fq_zech_ctx_t ctx) noexcept # Sets all diagonal entries of ``mat`` to 1 and all other entries to 0. - void fq_zech_mat_set_nmod_mat(fq_zech_mat_t mat1, const nmod_mat_t mat2, const fq_zech_ctx_t ctx) + void fq_zech_mat_set_nmod_mat(fq_zech_mat_t mat1, const nmod_mat_t mat2, const fq_zech_ctx_t ctx) noexcept # Sets the matrix ``mat1`` to the matrix ``mat2``. - void fq_zech_mat_set_fmpz_mod_mat(fq_zech_mat_t mat1, const fmpz_mod_mat_t mat2, const fq_zech_ctx_t ctx) + void fq_zech_mat_set_fmpz_mod_mat(fq_zech_mat_t mat1, const fmpz_mod_mat_t mat2, const fq_zech_ctx_t ctx) noexcept # Sets the matrix ``mat1`` to the matrix ``mat2``. - void fq_zech_mat_concat_vertical(fq_zech_mat_t res, const fq_zech_mat_t mat1, const fq_zech_mat_t mat2, const fq_zech_ctx_t ctx) + void fq_zech_mat_concat_vertical(fq_zech_mat_t res, const fq_zech_mat_t mat1, const fq_zech_mat_t mat2, const fq_zech_ctx_t ctx) noexcept # Sets ``res`` to vertical concatenation of (``mat1``, ``mat2``) in that order. Matrix dimensions : ``mat1`` : `m \times n`, ``mat2`` : `k \times n`, ``res`` : `(m + k) \times n`. - void fq_zech_mat_concat_horizontal(fq_zech_mat_t res, const fq_zech_mat_t mat1, const fq_zech_mat_t mat2, const fq_zech_ctx_t ctx) + void fq_zech_mat_concat_horizontal(fq_zech_mat_t res, const fq_zech_mat_t mat1, const fq_zech_mat_t mat2, const fq_zech_ctx_t ctx) noexcept # Sets ``res`` to horizontal concatenation of (``mat1``, ``mat2``) in that order. Matrix dimensions : ``mat1`` : `m \times n`, ``mat2`` : `m \times k`, ``res`` : `m \times (n + k)`. - int fq_zech_mat_print_pretty(const fq_zech_mat_t mat, const fq_zech_ctx_t ctx) + int fq_zech_mat_print_pretty(const fq_zech_mat_t mat, const fq_zech_ctx_t ctx) noexcept # Pretty-prints ``mat`` to ``stdout``. A header is printed # followed by the rows enclosed in brackets. - int fq_zech_mat_fprint_pretty(FILE * file, const fq_zech_mat_t mat, const fq_zech_ctx_t ctx) + int fq_zech_mat_fprint_pretty(FILE * file, const fq_zech_mat_t mat, const fq_zech_ctx_t ctx) noexcept # Pretty-prints ``mat`` to ``file``. A header is printed # followed by the rows enclosed in brackets. # In case of success, returns a positive value. In case of failure, # returns a non-positive value. - int fq_zech_mat_print(const fq_zech_mat_t mat, const fq_zech_ctx_t ctx) + int fq_zech_mat_print(const fq_zech_mat_t mat, const fq_zech_ctx_t ctx) noexcept # Prints ``mat`` to ``stdout``. A header is printed followed # by the rows enclosed in brackets. - int fq_zech_mat_fprint(FILE * file, const fq_zech_mat_t mat, const fq_zech_ctx_t ctx) + int fq_zech_mat_fprint(FILE * file, const fq_zech_mat_t mat, const fq_zech_ctx_t ctx) noexcept # Prints ``mat`` to ``file``. A header is printed followed by # the rows enclosed in brackets. # In case of success, returns a positive value. In case of failure, # returns a non-positive value. - void fq_zech_mat_window_init(fq_zech_mat_t window, const fq_zech_mat_t mat, slong r1, slong c1, slong r2, slong c2, const fq_zech_ctx_t ctx) + void fq_zech_mat_window_init(fq_zech_mat_t window, const fq_zech_mat_t mat, slong r1, slong c1, slong r2, slong c2, const fq_zech_ctx_t ctx) noexcept # Initializes the matrix ``window`` to be an ``r2 - r1`` by # ``c2 - c1`` submatrix of ``mat`` whose ``(0,0)`` entry # is the ``(r1, c1)`` entry of ``mat``. The memory for the # elements of ``window`` is shared with ``mat``. - void fq_zech_mat_window_clear(fq_zech_mat_t window, const fq_zech_ctx_t ctx) + void fq_zech_mat_window_clear(fq_zech_mat_t window, const fq_zech_ctx_t ctx) noexcept # Clears the matrix ``window`` and releases any memory that it # uses. Note that the memory to the underlying matrix that # ``window`` points to is not freed. - void fq_zech_mat_randtest(fq_zech_mat_t mat, flint_rand_t state, const fq_zech_ctx_t ctx) + void fq_zech_mat_randtest(fq_zech_mat_t mat, flint_rand_t state, const fq_zech_ctx_t ctx) noexcept # Sets the elements of ``mat`` to random elements of # `\mathbf{F}_{q}`, given by ``ctx``. - int fq_zech_mat_randpermdiag(fq_zech_mat_t mat, flint_rand_t state, fq_zech_struct * diag, slong n, const fq_zech_ctx_t ctx) + int fq_zech_mat_randpermdiag(fq_zech_mat_t mat, flint_rand_t state, fq_zech_struct * diag, slong n, const fq_zech_ctx_t ctx) noexcept # Sets ``mat`` to a random permutation of the diagonal matrix # with `n` leading entries given by the vector ``diag``. It is # assumed that the main diagonal of ``mat`` has room for at @@ -112,7 +112,7 @@ cdef extern from "flint_wrap.h": # Returns `0` or `1`, depending on whether the permutation is even # or odd respectively. - void fq_zech_mat_randrank(fq_zech_mat_t mat, flint_rand_t state, slong rank, const fq_zech_ctx_t ctx) + void fq_zech_mat_randrank(fq_zech_mat_t mat, flint_rand_t state, slong rank, const fq_zech_ctx_t ctx) noexcept # Sets ``mat`` to a random sparse matrix with the given rank, # having exactly as many non-zero elements as the rank, with the # non-zero elements being uniformly random elements of @@ -120,88 +120,88 @@ cdef extern from "flint_wrap.h": # The matrix can be transformed into a dense matrix with unchanged # rank by subsequently calling :func:`fq_zech_mat_randops`. - void fq_zech_mat_randops(fq_zech_mat_t mat, slong count, flint_rand_t state, const fq_zech_ctx_t ctx) + void fq_zech_mat_randops(fq_zech_mat_t mat, slong count, flint_rand_t state, const fq_zech_ctx_t ctx) noexcept # Randomises ``mat`` by performing elementary row or column # operations. More precisely, at most ``count`` random additions # or subtractions of distinct rows and columns will be performed. # This leaves the rank (and for square matrices, determinant) # unchanged. - void fq_zech_mat_randtril(fq_zech_mat_t mat, flint_rand_t state, int unit, const fq_zech_ctx_t ctx) + void fq_zech_mat_randtril(fq_zech_mat_t mat, flint_rand_t state, int unit, const fq_zech_ctx_t ctx) noexcept # Sets ``mat`` to a random lower triangular matrix. If # ``unit`` is 1, it will have ones on the main diagonal, # otherwise it will have random nonzero entries on the main # diagonal. - void fq_zech_mat_randtriu(fq_zech_mat_t mat, flint_rand_t state, int unit, const fq_zech_ctx_t ctx) + void fq_zech_mat_randtriu(fq_zech_mat_t mat, flint_rand_t state, int unit, const fq_zech_ctx_t ctx) noexcept # Sets ``mat`` to a random upper triangular matrix. If # ``unit`` is 1, it will have ones on the main diagonal, # otherwise it will have random nonzero entries on the main # diagonal. - bint fq_zech_mat_equal(const fq_zech_mat_t mat1, const fq_zech_mat_t mat2, const fq_zech_ctx_t ctx) + bint fq_zech_mat_equal(const fq_zech_mat_t mat1, const fq_zech_mat_t mat2, const fq_zech_ctx_t ctx) noexcept # Returns nonzero if mat1 and mat2 have the same dimensions and elements, # and zero otherwise. - bint fq_zech_mat_is_zero(const fq_zech_mat_t mat, const fq_zech_ctx_t ctx) + bint fq_zech_mat_is_zero(const fq_zech_mat_t mat, const fq_zech_ctx_t ctx) noexcept # Returns a non-zero value if all entries ``mat`` are zero, and # otherwise returns zero. - bint fq_zech_mat_is_one(const fq_zech_mat_t mat, const fq_zech_ctx_t ctx) + bint fq_zech_mat_is_one(const fq_zech_mat_t mat, const fq_zech_ctx_t ctx) noexcept # Returns a non-zero value if all entries ``mat`` are zero except the # diagonal entries which must be one, otherwise returns zero. - bint fq_zech_mat_is_empty(const fq_zech_mat_t mat, const fq_zech_ctx_t ctx) + bint fq_zech_mat_is_empty(const fq_zech_mat_t mat, const fq_zech_ctx_t ctx) noexcept # Returns a non-zero value if the number of rows or the number of # columns in ``mat`` is zero, and otherwise returns zero. - bint fq_zech_mat_is_square(const fq_zech_mat_t mat, const fq_zech_ctx_t ctx) + bint fq_zech_mat_is_square(const fq_zech_mat_t mat, const fq_zech_ctx_t ctx) noexcept # Returns a non-zero value if the number of rows is equal to the # number of columns in ``mat``, and otherwise returns zero. - void fq_zech_mat_add(fq_zech_mat_t C, const fq_zech_mat_t A, const fq_zech_mat_t B, const fq_zech_ctx_t ctx) + void fq_zech_mat_add(fq_zech_mat_t C, const fq_zech_mat_t A, const fq_zech_mat_t B, const fq_zech_ctx_t ctx) noexcept # Computes `C = A + B`. Dimensions must be identical. - void fq_zech_mat_sub(fq_zech_mat_t C, const fq_zech_mat_t A, const fq_zech_mat_t B, const fq_zech_ctx_t ctx) + void fq_zech_mat_sub(fq_zech_mat_t C, const fq_zech_mat_t A, const fq_zech_mat_t B, const fq_zech_ctx_t ctx) noexcept # Computes `C = A - B`. Dimensions must be identical. - void fq_zech_mat_neg(fq_zech_mat_t A, const fq_zech_mat_t B, const fq_zech_ctx_t ctx) + void fq_zech_mat_neg(fq_zech_mat_t A, const fq_zech_mat_t B, const fq_zech_ctx_t ctx) noexcept # Sets `B = -A`. Dimensions must be identical. - void fq_zech_mat_mul(fq_zech_mat_t C, const fq_zech_mat_t A, const fq_zech_mat_t B, const fq_zech_ctx_t ctx) + void fq_zech_mat_mul(fq_zech_mat_t C, const fq_zech_mat_t A, const fq_zech_mat_t B, const fq_zech_ctx_t ctx) noexcept # Sets `C = AB`. Dimensions must be compatible for matrix # multiplication. `C` is not allowed to be aliased with `A` or # `B`. This function automatically chooses between classical and # KS multiplication. - void fq_zech_mat_mul_classical(fq_zech_mat_t C, const fq_zech_mat_t A, const fq_zech_mat_t B, const fq_zech_ctx_t ctx) + void fq_zech_mat_mul_classical(fq_zech_mat_t C, const fq_zech_mat_t A, const fq_zech_mat_t B, const fq_zech_ctx_t ctx) noexcept # Sets `C = AB`. Dimensions must be compatible for matrix multiplication. # `C` is not allowed to be aliased with `A` or `B`. Uses classical # matrix multiplication. - void fq_zech_mat_mul_KS(fq_zech_mat_t C, const fq_zech_mat_t A, const fq_zech_mat_t B, const fq_zech_ctx_t ctx) + void fq_zech_mat_mul_KS(fq_zech_mat_t C, const fq_zech_mat_t A, const fq_zech_mat_t B, const fq_zech_ctx_t ctx) noexcept # Sets `C = AB`. Dimensions must be compatible for matrix # multiplication. `C` is not allowed to be aliased with `A` or # `B`. Uses Kronecker substitution to perform the multiplication # over the integers. - void fq_zech_mat_submul(fq_zech_mat_t D, const fq_zech_mat_t C, const fq_zech_mat_t A, const fq_zech_mat_t B, const fq_zech_ctx_t ctx) + void fq_zech_mat_submul(fq_zech_mat_t D, const fq_zech_mat_t C, const fq_zech_mat_t A, const fq_zech_mat_t B, const fq_zech_ctx_t ctx) noexcept # Sets `D = C + AB`. `C` and `D` may be aliased with each other but # not with `A` or `B`. - void fq_zech_mat_mul_vec(fq_zech_struct * c, const fq_zech_mat_t A, const fq_zech_struct * b, slong blen, const fq_zech_ctx_t ctx) - void fq_zech_mat_mul_vec_ptr(fq_zech_struct * const * c, const fq_zech_mat_t A, const fq_zech_struct * const * b, slong blen, const fq_zech_ctx_t ctx) + void fq_zech_mat_mul_vec(fq_zech_struct * c, const fq_zech_mat_t A, const fq_zech_struct * b, slong blen, const fq_zech_ctx_t ctx) noexcept + void fq_zech_mat_mul_vec_ptr(fq_zech_struct * const * c, const fq_zech_mat_t A, const fq_zech_struct * const * b, slong blen, const fq_zech_ctx_t ctx) noexcept # Compute a matrix-vector product of ``A`` and ``(b, blen)`` and store the result in ``c``. # The vector ``(b, blen)`` is either truncated or zero-extended to the number of columns of ``A``. # The number entries written to ``c`` is always equal to the number of rows of ``A``. - void fq_zech_mat_vec_mul(fq_zech_struct * c, const fq_zech_struct * a, slong alen, const fq_zech_mat_t B, const fq_zech_ctx_t ctx) - void fq_zech_mat_vec_mul_ptr(fq_zech_struct * const * c, const fq_zech_struct * const * a, slong alen, const fq_zech_mat_t B, const fq_zech_ctx_t ctx) + void fq_zech_mat_vec_mul(fq_zech_struct * c, const fq_zech_struct * a, slong alen, const fq_zech_mat_t B, const fq_zech_ctx_t ctx) noexcept + void fq_zech_mat_vec_mul_ptr(fq_zech_struct * const * c, const fq_zech_struct * const * a, slong alen, const fq_zech_mat_t B, const fq_zech_ctx_t ctx) noexcept # Compute a vector-matrix product of ``(a, alen)`` and ``B`` and and store the result in ``c``. # The vector ``(a, alen)`` is either truncated or zero-extended to the number of rows of ``B``. # The number entries written to ``c`` is always equal to the number of columns of ``B``. - slong fq_zech_mat_lu(slong * P, fq_zech_mat_t A, int rank_check, const fq_zech_ctx_t ctx) + slong fq_zech_mat_lu(slong * P, fq_zech_mat_t A, int rank_check, const fq_zech_ctx_t ctx) noexcept # Computes a generalised LU decomposition `LU = PA` of a given # matrix `A`, returning the rank of `A`. # If `A` is a nonsingular square matrix, it will be overwritten with @@ -218,26 +218,26 @@ cdef extern from "flint_wrap.h": # if `A` is detected to be rank-deficient. # This function calls ``fq_zech_mat_lu_recursive``. - slong fq_zech_mat_lu_classical(slong * P, fq_zech_mat_t A, int rank_check, const fq_zech_ctx_t ctx) + slong fq_zech_mat_lu_classical(slong * P, fq_zech_mat_t A, int rank_check, const fq_zech_ctx_t ctx) noexcept # Computes a generalised LU decomposition `LU = PA` of a given # matrix `A`, returning the rank of `A`. The behavior of this # function is identical to that of ``fq_zech_mat_lu``. Uses Gaussian # elimination. - slong fq_zech_mat_lu_recursive(slong * P, fq_zech_mat_t A, int rank_check, const fq_zech_ctx_t ctx) + slong fq_zech_mat_lu_recursive(slong * P, fq_zech_mat_t A, int rank_check, const fq_zech_ctx_t ctx) noexcept # Computes a generalised LU decomposition `LU = PA` of a given # matrix `A`, returning the rank of `A`. The behavior of this # function is identical to that of ``fq_zech_mat_lu``. Uses recursive # block decomposition, switching to classical Gaussian elimination # for sufficiently small blocks. - slong fq_zech_mat_rref(fq_zech_mat_t A, const fq_zech_ctx_t ctx) + slong fq_zech_mat_rref(fq_zech_mat_t A, const fq_zech_ctx_t ctx) noexcept # Puts `A` in reduced row echelon form and returns the rank of `A`. # The rref is computed by first obtaining an unreduced row echelon # form via LU decomposition and then solving an additional # triangular system. - slong fq_zech_mat_reduce_row(fq_zech_mat_t A, slong * P, slong * L, slong n, const fq_zech_ctx_t ctx) + slong fq_zech_mat_reduce_row(fq_zech_mat_t A, slong * P, slong * L, slong n, const fq_zech_ctx_t ctx) noexcept # Reduce row n of the matrix `A`, assuming the prior rows are in Gauss # form. However those rows may not be in order. The entry `i` of the array # `P` is the row of `A` which has a pivot in the `i`-th column. If no such @@ -250,7 +250,7 @@ cdef extern from "flint_wrap.h": # `L` can all be set to the number of columns of `A`. We require the entries # of `L` to be monotonic increasing. - void fq_zech_mat_solve_tril(fq_zech_mat_t X, const fq_zech_mat_t L, const fq_zech_mat_t B, int unit, const fq_zech_ctx_t ctx) + void fq_zech_mat_solve_tril(fq_zech_mat_t X, const fq_zech_mat_t L, const fq_zech_mat_t B, int unit, const fq_zech_ctx_t ctx) noexcept # Sets `X = L^{-1} B` where `L` is a full rank lower triangular # square matrix. If ``unit`` = 1, `L` is assumed to have ones on # its main diagonal, and the main diagonal will not be read. `X` @@ -258,14 +258,14 @@ cdef extern from "flint_wrap.h": # is allowed. Automatically chooses between the classical and # recursive algorithms. - void fq_zech_mat_solve_tril_classical(fq_zech_mat_t X, const fq_zech_mat_t L, const fq_zech_mat_t B, int unit, const fq_zech_ctx_t ctx) + void fq_zech_mat_solve_tril_classical(fq_zech_mat_t X, const fq_zech_mat_t L, const fq_zech_mat_t B, int unit, const fq_zech_ctx_t ctx) noexcept # Sets `X = L^{-1} B` where `L` is a full rank lower triangular # square matrix. If ``unit`` = 1, `L` is assumed to have ones on # its main diagonal, and the main diagonal will not be read. `X` # and `B` are allowed to be the same matrix, but no other aliasing # is allowed. Uses forward substitution. - void fq_zech_mat_solve_tril_recursive(fq_zech_mat_t X, const fq_zech_mat_t L, const fq_zech_mat_t B, int unit, const fq_zech_ctx_t ctx) + void fq_zech_mat_solve_tril_recursive(fq_zech_mat_t X, const fq_zech_mat_t L, const fq_zech_mat_t B, int unit, const fq_zech_ctx_t ctx) noexcept # Sets `X = L^{-1} B` where `L` is a full rank lower triangular # square matrix. If ``unit`` = 1, `L` is assumed to have ones on # its main diagonal, and the main diagonal will not be read. `X` @@ -279,7 +279,7 @@ cdef extern from "flint_wrap.h": # to reduce the problem to matrix multiplication and triangular # solving of smaller systems. - void fq_zech_mat_solve_triu(fq_zech_mat_t X, const fq_zech_mat_t U, const fq_zech_mat_t B, int unit, const fq_zech_ctx_t ctx) + void fq_zech_mat_solve_triu(fq_zech_mat_t X, const fq_zech_mat_t U, const fq_zech_mat_t B, int unit, const fq_zech_ctx_t ctx) noexcept # Sets `X = U^{-1} B` where `U` is a full rank upper triangular # square matrix. If ``unit`` = 1, `U` is assumed to have ones on # its main diagonal, and the main diagonal will not be read. `X` @@ -287,14 +287,14 @@ cdef extern from "flint_wrap.h": # is allowed. Automatically chooses between the classical and # recursive algorithms. - void fq_zech_mat_solve_triu_classical(fq_zech_mat_t X, const fq_zech_mat_t U, const fq_zech_mat_t B, int unit, const fq_zech_ctx_t ctx) + void fq_zech_mat_solve_triu_classical(fq_zech_mat_t X, const fq_zech_mat_t U, const fq_zech_mat_t B, int unit, const fq_zech_ctx_t ctx) noexcept # Sets `X = U^{-1} B` where `U` is a full rank upper triangular # square matrix. If ``unit`` = 1, `U` is assumed to have ones on # its main diagonal, and the main diagonal will not be read. `X` # and `B` are allowed to be the same matrix, but no other aliasing # is allowed. Uses forward substitution. - void fq_zech_mat_solve_triu_recursive(fq_zech_mat_t X, const fq_zech_mat_t U, const fq_zech_mat_t B, int unit, const fq_zech_ctx_t ctx) + void fq_zech_mat_solve_triu_recursive(fq_zech_mat_t X, const fq_zech_mat_t U, const fq_zech_mat_t B, int unit, const fq_zech_ctx_t ctx) noexcept # Sets `X = U^{-1} B` where `U` is a full rank upper triangular # square matrix. If ``unit`` = 1, `U` is assumed to have ones on # its main diagonal, and the main diagonal will not be read. `X` @@ -308,20 +308,20 @@ cdef extern from "flint_wrap.h": # to reduce the problem to matrix multiplication and triangular # solving of smaller systems. - int fq_zech_mat_solve(fq_zech_mat_t X, const fq_zech_mat_t A, const fq_zech_mat_t B, const fq_zech_ctx_t ctx) + int fq_zech_mat_solve(fq_zech_mat_t X, const fq_zech_mat_t A, const fq_zech_mat_t B, const fq_zech_ctx_t ctx) noexcept # Solves the matrix-matrix equation `AX = B`. # Returns `1` if `A` has full rank; otherwise returns `0` and sets the # elements of `X` to undefined values. # The matrix `A` must be square. - int fq_zech_mat_can_solve(fq_zech_mat_t X, const fq_zech_mat_t A, const fq_zech_mat_t B, const fq_zech_ctx_t ctx) + int fq_zech_mat_can_solve(fq_zech_mat_t X, const fq_zech_mat_t A, const fq_zech_mat_t B, const fq_zech_ctx_t ctx) noexcept # Solves the matrix-matrix equation `AX = B` over `Fq`. # Returns `1` if a solution exists; otherwise returns `0` and sets the # elements of `X` to zero. If more than one solution exists, one of the # valid solutions is given. # There are no restrictions on the shape of `A` and it may be singular. - void fq_zech_mat_similarity(fq_zech_mat_t M, slong r, fq_zech_t d, const fq_zech_ctx_t ctx) + void fq_zech_mat_similarity(fq_zech_mat_t M, slong r, fq_zech_t d, const fq_zech_ctx_t ctx) noexcept # Applies a similarity transform to the `n\times n` matrix `M` in-place. # If `P` is the `n\times n` identity matrix the zero entries of whose row # `r` (`0`-indexed) have been replaced by `d`, this transform is equivalent @@ -331,14 +331,14 @@ cdef extern from "flint_wrap.h": # The value `d` is required to be reduced modulo the modulus of the entries # in the matrix. - void fq_zech_mat_charpoly_danilevsky(fq_zech_poly_t p, const fq_zech_mat_t M, const fq_zech_ctx_t ctx) + void fq_zech_mat_charpoly_danilevsky(fq_zech_poly_t p, const fq_zech_mat_t M, const fq_zech_ctx_t ctx) noexcept # Compute the characteristic polynomial `p` of the matrix `M`. The matrix # is assumed to be square. - void fq_zech_mat_charpoly(fq_zech_poly_t p, const fq_zech_mat_t M, const fq_zech_ctx_t ctx) + void fq_zech_mat_charpoly(fq_zech_poly_t p, const fq_zech_mat_t M, const fq_zech_ctx_t ctx) noexcept # Compute the characteristic polynomial `p` of the matrix `M`. The matrix # is required to be square, otherwise an exception is raised. - void fq_zech_mat_minpoly(fq_zech_poly_t p, const fq_zech_mat_t M, const fq_zech_ctx_t ctx) + void fq_zech_mat_minpoly(fq_zech_poly_t p, const fq_zech_mat_t M, const fq_zech_ctx_t ctx) noexcept # Compute the minimal polynomial `p` of the matrix `M`. The matrix # is required to be square, otherwise an exception is raised. diff --git a/src/sage/libs/flint/fq_zech_poly.pxd b/src/sage/libs/flint/fq_zech_poly.pxd index 7ec51dd3005..05d4ed18768 100644 --- a/src/sage/libs/flint/fq_zech_poly.pxd +++ b/src/sage/libs/flint/fq_zech_poly.pxd @@ -12,27 +12,27 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void fq_zech_poly_init(fq_zech_poly_t poly, const fq_zech_ctx_t ctx) + void fq_zech_poly_init(fq_zech_poly_t poly, const fq_zech_ctx_t ctx) noexcept # Initialises ``poly`` for use, with context ctx, and setting its # length to zero. A corresponding call to :func:`fq_zech_poly_clear` # must be made after finishing with the ``fq_zech_poly_t`` to free the # memory used by the polynomial. - void fq_zech_poly_init2(fq_zech_poly_t poly, slong alloc, const fq_zech_ctx_t ctx) + void fq_zech_poly_init2(fq_zech_poly_t poly, slong alloc, const fq_zech_ctx_t ctx) noexcept # Initialises ``poly`` with space for at least ``alloc`` # coefficients and sets the length to zero. The allocated # coefficients are all set to zero. A corresponding call to # :func:`fq_zech_poly_clear` must be made after finishing with the # ``fq_zech_poly_t`` to free the memory used by the polynomial. - void fq_zech_poly_realloc(fq_zech_poly_t poly, slong alloc, const fq_zech_ctx_t ctx) + void fq_zech_poly_realloc(fq_zech_poly_t poly, slong alloc, const fq_zech_ctx_t ctx) noexcept # Reallocates the given polynomial to have space for ``alloc`` # coefficients. If ``alloc`` is zero the polynomial is cleared # and then reinitialised. If the current length is greater than # ``alloc`` the polynomial is first truncated to length # ``alloc``. - void fq_zech_poly_fit_length(fq_zech_poly_t poly, slong len, const fq_zech_ctx_t ctx) + void fq_zech_poly_fit_length(fq_zech_poly_t poly, slong len, const fq_zech_ctx_t ctx) noexcept # If ``len`` is greater than the number of coefficients currently # allocated, then the polynomial is reallocated to have space for at # least ``len`` coefficients. No data is lost when calling this @@ -42,33 +42,33 @@ cdef extern from "flint_wrap.h": # least doubling the number of allocated coefficients when length is # larger than the number of coefficients currently allocated. - void _fq_zech_poly_set_length(fq_zech_poly_t poly, slong newlen, const fq_zech_ctx_t ctx) + void _fq_zech_poly_set_length(fq_zech_poly_t poly, slong newlen, const fq_zech_ctx_t ctx) noexcept # Sets the coefficients of ``poly`` beyond ``len`` to zero and # sets the length of ``poly`` to ``len``. - void fq_zech_poly_clear(fq_zech_poly_t poly, const fq_zech_ctx_t ctx) + void fq_zech_poly_clear(fq_zech_poly_t poly, const fq_zech_ctx_t ctx) noexcept # Clears the given polynomial, releasing any memory used. It must # be reinitialised in order to be used again. - void _fq_zech_poly_normalise(fq_zech_poly_t poly, const fq_zech_ctx_t ctx) + void _fq_zech_poly_normalise(fq_zech_poly_t poly, const fq_zech_ctx_t ctx) noexcept # Sets the length of ``poly`` so that the top coefficient is # non-zero. If all coefficients are zero, the length is set to # zero. This function is mainly used internally, as all functions # guarantee normalisation. - void _fq_zech_poly_normalise2(const fq_zech_struct *poly, slong *length, const fq_zech_ctx_t ctx) + void _fq_zech_poly_normalise2(const fq_zech_struct *poly, slong *length, const fq_zech_ctx_t ctx) noexcept # Sets the length ``length`` of ``(poly,length)`` so that the # top coefficient is non-zero. If all coefficients are zero, the # length is set to zero. This function is mainly used internally, as # all functions guarantee normalisation. - void fq_zech_poly_truncate(fq_zech_poly_t poly, slong newlen, const fq_zech_ctx_t ctx) + void fq_zech_poly_truncate(fq_zech_poly_t poly, slong newlen, const fq_zech_ctx_t ctx) noexcept # Truncates the polynomial to length at most `n`. - void fq_zech_poly_set_trunc(fq_zech_poly_t poly1, fq_zech_poly_t poly2, slong newlen, const fq_zech_ctx_t ctx) + void fq_zech_poly_set_trunc(fq_zech_poly_t poly1, fq_zech_poly_t poly2, slong newlen, const fq_zech_ctx_t ctx) noexcept # Sets ``poly1`` to ``poly2`` truncated to length `n`. - void _fq_zech_poly_reverse(fq_zech_struct* output, const fq_zech_struct* input, slong len, slong m, const fq_zech_ctx_t ctx) + void _fq_zech_poly_reverse(fq_zech_struct* output, const fq_zech_struct* input, slong len, slong m, const fq_zech_ctx_t ctx) noexcept # Sets ``output`` to the reverse of ``input``, which is of # length ``len``, but thinking of it as a polynomial of # length ``m``, notionally zero-padded if necessary. The @@ -76,199 +76,199 @@ cdef extern from "flint_wrap.h": # restrictions. The polynomial ``output`` must have space for # ``m`` coefficients. - void fq_zech_poly_reverse(fq_zech_poly_t output, const fq_zech_poly_t input, slong m, const fq_zech_ctx_t ctx) + void fq_zech_poly_reverse(fq_zech_poly_t output, const fq_zech_poly_t input, slong m, const fq_zech_ctx_t ctx) noexcept # Sets ``output`` to the reverse of ``input``, thinking of it # as a polynomial of length ``m``, notionally zero-padded if # necessary). The length ``m`` must be non-negative, but there # are no other restrictions. The output polynomial will be set to # length ``m`` and then normalised. - slong fq_zech_poly_degree(const fq_zech_poly_t poly, const fq_zech_ctx_t ctx) + slong fq_zech_poly_degree(const fq_zech_poly_t poly, const fq_zech_ctx_t ctx) noexcept # Returns the degree of the polynomial ``poly``. - slong fq_zech_poly_length(const fq_zech_poly_t poly, const fq_zech_ctx_t ctx) + slong fq_zech_poly_length(const fq_zech_poly_t poly, const fq_zech_ctx_t ctx) noexcept # Returns the length of the polynomial ``poly``. - fq_zech_struct * fq_zech_poly_lead(const fq_zech_poly_t poly, const fq_zech_ctx_t ctx) + fq_zech_struct * fq_zech_poly_lead(const fq_zech_poly_t poly, const fq_zech_ctx_t ctx) noexcept # Returns a pointer to the leading coefficient of ``poly``, or # ``NULL`` if ``poly`` is the zero polynomial. - void fq_zech_poly_randtest(fq_zech_poly_t f, flint_rand_t state, slong len, const fq_zech_ctx_t ctx) + void fq_zech_poly_randtest(fq_zech_poly_t f, flint_rand_t state, slong len, const fq_zech_ctx_t ctx) noexcept # Sets `f` to a random polynomial of length at most ``len`` # with entries in the field described by ``ctx``. - void fq_zech_poly_randtest_not_zero(fq_zech_poly_t f, flint_rand_t state, slong len, const fq_zech_ctx_t ctx) + void fq_zech_poly_randtest_not_zero(fq_zech_poly_t f, flint_rand_t state, slong len, const fq_zech_ctx_t ctx) noexcept # Same as ``fq_zech_poly_randtest`` but guarantees that the polynomial # is not zero. - void fq_zech_poly_randtest_monic(fq_zech_poly_t f, flint_rand_t state, slong len, const fq_zech_ctx_t ctx) + void fq_zech_poly_randtest_monic(fq_zech_poly_t f, flint_rand_t state, slong len, const fq_zech_ctx_t ctx) noexcept # Sets `f` to a random monic polynomial of length ``len`` with # entries in the field described by ``ctx``. - void fq_zech_poly_randtest_irreducible(fq_zech_poly_t f, flint_rand_t state, slong len, const fq_zech_ctx_t ctx) + void fq_zech_poly_randtest_irreducible(fq_zech_poly_t f, flint_rand_t state, slong len, const fq_zech_ctx_t ctx) noexcept # Sets `f` to a random monic, irreducible polynomial of length # ``len`` with entries in the field described by ``ctx``. - void _fq_zech_poly_set(fq_zech_struct *rop, const fq_zech_struct *op, slong len, const fq_zech_ctx_t ctx) + void _fq_zech_poly_set(fq_zech_struct *rop, const fq_zech_struct *op, slong len, const fq_zech_ctx_t ctx) noexcept # Sets ``(rop, len``) to ``(op, len)``. - void fq_zech_poly_set(fq_zech_poly_t poly1, const fq_zech_poly_t poly2, const fq_zech_ctx_t ctx) + void fq_zech_poly_set(fq_zech_poly_t poly1, const fq_zech_poly_t poly2, const fq_zech_ctx_t ctx) noexcept # Sets the polynomial ``poly1`` to the polynomial ``poly2``. - void fq_zech_poly_set_fq_zech(fq_zech_poly_t poly, const fq_zech_t c, const fq_zech_ctx_t ctx) + void fq_zech_poly_set_fq_zech(fq_zech_poly_t poly, const fq_zech_t c, const fq_zech_ctx_t ctx) noexcept # Sets the polynomial ``poly`` to ``c``. - void fq_zech_poly_set_fmpz_mod_poly(fq_zech_poly_t rop, const fmpz_mod_poly_t op, const fq_zech_ctx_t ctx) + void fq_zech_poly_set_fmpz_mod_poly(fq_zech_poly_t rop, const fmpz_mod_poly_t op, const fq_zech_ctx_t ctx) noexcept # Sets the polynomial ``rop`` to the polynomial ``op`` - void fq_zech_poly_set_nmod_poly(fq_zech_poly_t rop, const nmod_poly_t op, const fq_zech_ctx_t ctx) + void fq_zech_poly_set_nmod_poly(fq_zech_poly_t rop, const nmod_poly_t op, const fq_zech_ctx_t ctx) noexcept # Sets the polynomial ``rop`` to the polynomial ``op`` - void fq_zech_poly_swap(fq_zech_poly_t op1, fq_zech_poly_t op2, const fq_zech_ctx_t ctx) + void fq_zech_poly_swap(fq_zech_poly_t op1, fq_zech_poly_t op2, const fq_zech_ctx_t ctx) noexcept # Swaps the two polynomials ``op1`` and ``op2``. - void _fq_zech_poly_zero(fq_zech_struct *rop, slong len, const fq_zech_ctx_t ctx) + void _fq_zech_poly_zero(fq_zech_struct *rop, slong len, const fq_zech_ctx_t ctx) noexcept # Sets ``(rop, len)`` to the zero polynomial. - void fq_zech_poly_zero(fq_zech_poly_t poly, const fq_zech_ctx_t ctx) + void fq_zech_poly_zero(fq_zech_poly_t poly, const fq_zech_ctx_t ctx) noexcept # Sets ``poly`` to the zero polynomial. - void fq_zech_poly_one(fq_zech_poly_t poly, const fq_zech_ctx_t ctx) + void fq_zech_poly_one(fq_zech_poly_t poly, const fq_zech_ctx_t ctx) noexcept # Sets ``poly`` to the constant polynomial `1`. - void fq_zech_poly_gen(fq_zech_poly_t poly, const fq_zech_ctx_t ctx) + void fq_zech_poly_gen(fq_zech_poly_t poly, const fq_zech_ctx_t ctx) noexcept # Sets ``poly`` to the polynomial `x`. - void fq_zech_poly_make_monic(fq_zech_poly_t rop, const fq_zech_poly_t op, const fq_zech_ctx_t ctx) + void fq_zech_poly_make_monic(fq_zech_poly_t rop, const fq_zech_poly_t op, const fq_zech_ctx_t ctx) noexcept # Sets ``rop`` to ``op``, normed to have leading coefficient 1. - void _fq_zech_poly_make_monic(fq_zech_struct *rop, const fq_zech_struct *op, slong length, const fq_zech_ctx_t ctx) + void _fq_zech_poly_make_monic(fq_zech_struct *rop, const fq_zech_struct *op, slong length, const fq_zech_ctx_t ctx) noexcept # Sets ``rop`` to ``(op,length)``, normed to have leading coefficient 1. # Assumes that ``rop`` has enough space for the polynomial, assumes that # ``op`` is not zero (and thus has an invertible leading coefficient). - void fq_zech_poly_get_coeff(fq_zech_t x, const fq_zech_poly_t poly, slong n, const fq_zech_ctx_t ctx) + void fq_zech_poly_get_coeff(fq_zech_t x, const fq_zech_poly_t poly, slong n, const fq_zech_ctx_t ctx) noexcept # Sets `x` to the coefficient of `X^n` in ``poly``. - void fq_zech_poly_set_coeff(fq_zech_poly_t poly, slong n, const fq_zech_t x, const fq_zech_ctx_t ctx) + void fq_zech_poly_set_coeff(fq_zech_poly_t poly, slong n, const fq_zech_t x, const fq_zech_ctx_t ctx) noexcept # Sets the coefficient of `X^n` in ``poly`` to `x`. - void fq_zech_poly_set_coeff_fmpz(fq_zech_poly_t poly, slong n, const fmpz_t x, const fq_zech_ctx_t ctx) + void fq_zech_poly_set_coeff_fmpz(fq_zech_poly_t poly, slong n, const fmpz_t x, const fq_zech_ctx_t ctx) noexcept # Sets the coefficient of `X^n` in the polynomial to `x`, # assuming `n \geq 0`. - bint fq_zech_poly_equal(const fq_zech_poly_t poly1, const fq_zech_poly_t poly2, const fq_zech_ctx_t ctx) + bint fq_zech_poly_equal(const fq_zech_poly_t poly1, const fq_zech_poly_t poly2, const fq_zech_ctx_t ctx) noexcept # Returns nonzero if the two polynomials ``poly1`` and ``poly2`` # are equal, otherwise return zero. - bint fq_zech_poly_equal_trunc(const fq_zech_poly_t poly1, const fq_zech_poly_t poly2, slong n, const fq_zech_ctx_t ctx) + bint fq_zech_poly_equal_trunc(const fq_zech_poly_t poly1, const fq_zech_poly_t poly2, slong n, const fq_zech_ctx_t ctx) noexcept # Notionally truncate ``poly1`` and ``poly2`` to length `n` and # return nonzero if they are equal, otherwise return zero. - bint fq_zech_poly_is_zero(const fq_zech_poly_t poly, const fq_zech_ctx_t ctx) + bint fq_zech_poly_is_zero(const fq_zech_poly_t poly, const fq_zech_ctx_t ctx) noexcept # Returns whether the polynomial ``poly`` is the zero polynomial. - bint fq_zech_poly_is_one(const fq_zech_poly_t op, const fq_zech_ctx_t ctx) + bint fq_zech_poly_is_one(const fq_zech_poly_t op, const fq_zech_ctx_t ctx) noexcept # Returns whether the polynomial ``poly`` is equal # to the constant polynomial `1`. - bint fq_zech_poly_is_gen(const fq_zech_poly_t op, const fq_zech_ctx_t ctx) + bint fq_zech_poly_is_gen(const fq_zech_poly_t op, const fq_zech_ctx_t ctx) noexcept # Returns whether the polynomial ``poly`` is equal # to the polynomial `x`. - bint fq_zech_poly_is_unit(const fq_zech_poly_t op, const fq_zech_ctx_t ctx) + bint fq_zech_poly_is_unit(const fq_zech_poly_t op, const fq_zech_ctx_t ctx) noexcept # Returns whether the polynomial ``poly`` is a unit in the polynomial # ring `\mathbf{F}_q[X]`, i.e. if it has degree `0` and is non-zero. - bint fq_zech_poly_equal_fq_zech(const fq_zech_poly_t poly, const fq_zech_t c, const fq_zech_ctx_t ctx) + bint fq_zech_poly_equal_fq_zech(const fq_zech_poly_t poly, const fq_zech_t c, const fq_zech_ctx_t ctx) noexcept # Returns whether the polynomial ``poly`` is equal the (constant) # `\mathbf{F}_q` element ``c`` - void _fq_zech_poly_add(fq_zech_struct *res, const fq_zech_struct *poly1, slong len1, const fq_zech_struct *poly2, slong len2, const fq_zech_ctx_t ctx) + void _fq_zech_poly_add(fq_zech_struct *res, const fq_zech_struct *poly1, slong len1, const fq_zech_struct *poly2, slong len2, const fq_zech_ctx_t ctx) noexcept # Sets ``res`` to the sum of ``(poly1,len1)`` and ``(poly2,len2)``. - void fq_zech_poly_add(fq_zech_poly_t res, const fq_zech_poly_t poly1, const fq_zech_poly_t poly2, const fq_zech_ctx_t ctx) + void fq_zech_poly_add(fq_zech_poly_t res, const fq_zech_poly_t poly1, const fq_zech_poly_t poly2, const fq_zech_ctx_t ctx) noexcept # Sets ``res`` to the sum of ``poly1`` and ``poly2``. - void fq_zech_poly_add_si(fq_zech_poly_t res, const fq_zech_poly_t poly1, slong c, const fq_zech_ctx_t ctx) + void fq_zech_poly_add_si(fq_zech_poly_t res, const fq_zech_poly_t poly1, slong c, const fq_zech_ctx_t ctx) noexcept # Sets ``res`` to the sum of ``poly1`` and ``c``. - void fq_zech_poly_add_series(fq_zech_poly_t res, const fq_zech_poly_t poly1, const fq_zech_poly_t poly2, slong n, const fq_zech_ctx_t ctx) + void fq_zech_poly_add_series(fq_zech_poly_t res, const fq_zech_poly_t poly1, const fq_zech_poly_t poly2, slong n, const fq_zech_ctx_t ctx) noexcept # Notionally truncate ``poly1`` and ``poly2`` to length ``n`` and set # ``res`` to the sum. - void _fq_zech_poly_sub(fq_zech_struct *res, const fq_zech_struct *poly1, slong len1, const fq_zech_struct *poly2, slong len2, const fq_zech_ctx_t ctx) + void _fq_zech_poly_sub(fq_zech_struct *res, const fq_zech_struct *poly1, slong len1, const fq_zech_struct *poly2, slong len2, const fq_zech_ctx_t ctx) noexcept # Sets ``res`` to the difference of ``(poly1,len1)`` and # ``(poly2,len2)``. - void fq_zech_poly_sub(fq_zech_poly_t res, const fq_zech_poly_t poly1, const fq_zech_poly_t poly2, const fq_zech_ctx_t ctx) + void fq_zech_poly_sub(fq_zech_poly_t res, const fq_zech_poly_t poly1, const fq_zech_poly_t poly2, const fq_zech_ctx_t ctx) noexcept # Sets ``res`` to the difference of ``poly1`` and ``poly2``. - void fq_zech_poly_sub_series(fq_zech_poly_t res, const fq_zech_poly_t poly1, const fq_zech_poly_t poly2, slong n, const fq_zech_ctx_t ctx) + void fq_zech_poly_sub_series(fq_zech_poly_t res, const fq_zech_poly_t poly1, const fq_zech_poly_t poly2, slong n, const fq_zech_ctx_t ctx) noexcept # Notionally truncate ``poly1`` and ``poly2`` to length ``n`` and set # ``res`` to the difference. - void _fq_zech_poly_neg(fq_zech_struct *rop, const fq_zech_struct *op, slong len, const fq_zech_ctx_t ctx) + void _fq_zech_poly_neg(fq_zech_struct *rop, const fq_zech_struct *op, slong len, const fq_zech_ctx_t ctx) noexcept # Sets ``rop`` to the additive inverse of ``(op,len)``. - void fq_zech_poly_neg(fq_zech_poly_t res, const fq_zech_poly_t poly, const fq_zech_ctx_t ctx) + void fq_zech_poly_neg(fq_zech_poly_t res, const fq_zech_poly_t poly, const fq_zech_ctx_t ctx) noexcept # Sets ``res`` to the additive inverse of ``poly``. - void _fq_zech_poly_scalar_mul_fq_zech(fq_zech_struct *rop, const fq_zech_struct *op, slong len, const fq_zech_t x, const fq_zech_ctx_t ctx) + void _fq_zech_poly_scalar_mul_fq_zech(fq_zech_struct *rop, const fq_zech_struct *op, slong len, const fq_zech_t x, const fq_zech_ctx_t ctx) noexcept # Sets ``(rop,len)`` to the product of ``(op,len)`` by the # scalar ``x``, in the context defined by ``ctx``. - void fq_zech_poly_scalar_mul_fq_zech(fq_zech_poly_t rop, const fq_zech_poly_t op, const fq_zech_t x, const fq_zech_ctx_t ctx) + void fq_zech_poly_scalar_mul_fq_zech(fq_zech_poly_t rop, const fq_zech_poly_t op, const fq_zech_t x, const fq_zech_ctx_t ctx) noexcept # Sets ``rop`` to the product of ``op`` by the scalar ``x``, in the context # defined by ``ctx``. - void _fq_zech_poly_scalar_addmul_fq_zech(fq_zech_struct *rop, const fq_zech_struct *op, slong len, const fq_zech_t x, const fq_zech_ctx_t ctx) + void _fq_zech_poly_scalar_addmul_fq_zech(fq_zech_struct *rop, const fq_zech_struct *op, slong len, const fq_zech_t x, const fq_zech_ctx_t ctx) noexcept # Adds to ``(rop,len)`` the product of ``(op,len)`` by the # scalar ``x``, in the context defined by ``ctx``. # In particular, assumes the same length for ``op`` and # ``rop``. - void fq_zech_poly_scalar_addmul_fq_zech(fq_zech_poly_t rop, const fq_zech_poly_t op, const fq_zech_t x, const fq_zech_ctx_t ctx) + void fq_zech_poly_scalar_addmul_fq_zech(fq_zech_poly_t rop, const fq_zech_poly_t op, const fq_zech_t x, const fq_zech_ctx_t ctx) noexcept # Adds to ``rop`` the product of ``op`` by the # scalar ``x``, in the context defined by ``ctx``. - void _fq_zech_poly_scalar_submul_fq_zech(fq_zech_struct *rop, const fq_zech_struct *op, slong len, const fq_zech_t x, const fq_zech_ctx_t ctx) + void _fq_zech_poly_scalar_submul_fq_zech(fq_zech_struct *rop, const fq_zech_struct *op, slong len, const fq_zech_t x, const fq_zech_ctx_t ctx) noexcept # Subtracts from ``(rop,len)`` the product of ``(op,len)`` by the # scalar ``x``, in the context defined by ``ctx``. # In particular, assumes the same length for ``op`` and # ``rop``. - void fq_zech_poly_scalar_submul_fq_zech(fq_zech_poly_t rop, const fq_zech_poly_t op, const fq_zech_t x, const fq_zech_ctx_t ctx) + void fq_zech_poly_scalar_submul_fq_zech(fq_zech_poly_t rop, const fq_zech_poly_t op, const fq_zech_t x, const fq_zech_ctx_t ctx) noexcept # Subtracts from ``rop`` the product of ``op`` by the # scalar ``x``, in the context defined by ``ctx``. - void _fq_zech_poly_scalar_div_fq_zech(fq_zech_struct *rop, const fq_zech_struct *op, slong len, const fq_zech_t x, const fq_zech_ctx_t ctx) + void _fq_zech_poly_scalar_div_fq_zech(fq_zech_struct *rop, const fq_zech_struct *op, slong len, const fq_zech_t x, const fq_zech_ctx_t ctx) noexcept # Sets ``(rop,len)`` to the quotient of ``(op,len)`` by the # scalar ``x``, in the context defined by ``ctx``. An exception is raised # if ``x`` is zero. - void fq_zech_poly_scalar_div_fq_zech(fq_zech_poly_t rop, const fq_zech_poly_t op, const fq_zech_t x, const fq_zech_ctx_t ctx) + void fq_zech_poly_scalar_div_fq_zech(fq_zech_poly_t rop, const fq_zech_poly_t op, const fq_zech_t x, const fq_zech_ctx_t ctx) noexcept # Sets ``rop`` to the quotient of ``op`` by the scalar ``x``, in the context # defined by ``ctx``. An exception is raised if ``x`` is zero. - void _fq_zech_poly_mul_classical(fq_zech_struct *rop, const fq_zech_struct *op1, slong len1, const fq_zech_struct *op2, slong len2, const fq_zech_ctx_t ctx) + void _fq_zech_poly_mul_classical(fq_zech_struct *rop, const fq_zech_struct *op1, slong len1, const fq_zech_struct *op2, slong len2, const fq_zech_ctx_t ctx) noexcept # Sets ``(rop, len1 + len2 - 1)`` to the product of ``(op1, len1)`` # and ``(op2, len2)``, assuming that ``len1`` is at least ``len2`` # and neither is zero. # Permits zero padding. Does not support aliasing of ``rop`` # with either ``op1`` or ``op2``. - void fq_zech_poly_mul_classical(fq_zech_poly_t rop, const fq_zech_poly_t op1, const fq_zech_poly_t op2, const fq_zech_ctx_t ctx) + void fq_zech_poly_mul_classical(fq_zech_poly_t rop, const fq_zech_poly_t op1, const fq_zech_poly_t op2, const fq_zech_ctx_t ctx) noexcept # Sets ``rop`` to the product of ``op1`` and ``op2`` # using classical polynomial multiplication. - void _fq_zech_poly_mul_reorder(fq_zech_struct *rop, const fq_zech_struct *op1, slong len1, const fq_zech_struct *op2, slong len2, const fq_zech_ctx_t ctx) + void _fq_zech_poly_mul_reorder(fq_zech_struct *rop, const fq_zech_struct *op1, slong len1, const fq_zech_struct *op2, slong len2, const fq_zech_ctx_t ctx) noexcept # Sets ``(rop, len1 + len2 - 1)`` to the product of ``(op1, len1)`` # and ``(op2, len2)``, assuming that ``len1`` and ``len2`` are # non-zero. # Permits zero padding. Supports aliasing. - void fq_zech_poly_mul_reorder(fq_zech_poly_t rop, const fq_zech_poly_t op1, const fq_zech_poly_t op2, const fq_zech_ctx_t ctx) + void fq_zech_poly_mul_reorder(fq_zech_poly_t rop, const fq_zech_poly_t op1, const fq_zech_poly_t op2, const fq_zech_ctx_t ctx) noexcept # Sets ``rop`` to the product of ``op1`` and ``op2``, # reordering the two indeterminates `X` and `Y` when viewing # the polynomials as elements of `\mathbf{F}_p[X,Y]`. @@ -287,38 +287,38 @@ cdef extern from "flint_wrap.h": # multiplication routines in the `Y`-direction where the polynomial # degree `n` is large. - void _fq_zech_poly_mul_KS(fq_zech_struct *rop, const fq_zech_struct *op1, slong len1, const fq_zech_struct *op2, slong len2, const fq_zech_ctx_t ctx) + void _fq_zech_poly_mul_KS(fq_zech_struct *rop, const fq_zech_struct *op1, slong len1, const fq_zech_struct *op2, slong len2, const fq_zech_ctx_t ctx) noexcept # Sets ``(rop, len1 + len2 - 1)`` to the product of ``(op1, len1)`` # and ``(op2, len2)``. # Permits zero padding and places no assumptions on the # lengths ``len1`` and ``len2``. Supports aliasing. - void fq_zech_poly_mul_KS(fq_zech_poly_t rop, const fq_zech_poly_t op1, const fq_zech_poly_t op2, const fq_zech_ctx_t ctx) + void fq_zech_poly_mul_KS(fq_zech_poly_t rop, const fq_zech_poly_t op1, const fq_zech_poly_t op2, const fq_zech_ctx_t ctx) noexcept # Sets ``rop`` to the product of ``op1`` and ``op2`` # using Kronecker substitution, that is, by encoding each # coefficient in `\mathbf{F}_{q}` as an integer and reducing # this problem to multiplying two polynomials over the integers. - void _fq_zech_poly_mul(fq_zech_struct *rop, const fq_zech_struct *op1, slong len1, const fq_zech_struct *op2, slong len2, const fq_zech_ctx_t ctx) + void _fq_zech_poly_mul(fq_zech_struct *rop, const fq_zech_struct *op1, slong len1, const fq_zech_struct *op2, slong len2, const fq_zech_ctx_t ctx) noexcept # Sets ``(rop, len1 + len2 - 1)`` to the product of ``(op1, len1)`` # and ``(op2, len2)``, choosing an appropriate algorithm. # Permits zero padding. Does not support aliasing. - void fq_zech_poly_mul(fq_zech_poly_t rop, const fq_zech_poly_t op1, const fq_zech_poly_t op2, const fq_zech_ctx_t ctx) + void fq_zech_poly_mul(fq_zech_poly_t rop, const fq_zech_poly_t op1, const fq_zech_poly_t op2, const fq_zech_ctx_t ctx) noexcept # Sets ``rop`` to the product of ``op1`` and ``op2``, # choosing an appropriate algorithm. - void _fq_zech_poly_mullow_classical(fq_zech_struct *rop, const fq_zech_struct *op1, slong len1, const fq_zech_struct *op2, slong len2, slong n, const fq_zech_ctx_t ctx) + void _fq_zech_poly_mullow_classical(fq_zech_struct *rop, const fq_zech_struct *op1, slong len1, const fq_zech_struct *op2, slong len2, slong n, const fq_zech_ctx_t ctx) noexcept # Sets ``(rop, n)`` to the first `n` coefficients of # ``(op1, len1)`` multiplied by ``(op2, len2)``. # Assumes ``0 < n <= len1 + len2 - 1``. Assumes neither # ``len1`` nor ``len2`` is zero. - void fq_zech_poly_mullow_classical(fq_zech_poly_t rop, const fq_zech_poly_t op1, const fq_zech_poly_t op2, slong n, const fq_zech_ctx_t ctx) + void fq_zech_poly_mullow_classical(fq_zech_poly_t rop, const fq_zech_poly_t op1, const fq_zech_poly_t op2, slong n, const fq_zech_ctx_t ctx) noexcept # Sets ``rop`` to the product of ``op1`` and ``op2``, # computed using the classical or schoolbook method. - void _fq_zech_poly_mullow_KS(fq_zech_struct *rop, const fq_zech_struct *op1, slong len1, const fq_zech_struct *op2, slong len2, slong n, const fq_zech_ctx_t ctx) + void _fq_zech_poly_mullow_KS(fq_zech_struct *rop, const fq_zech_struct *op1, slong len1, const fq_zech_struct *op2, slong len2, slong n, const fq_zech_ctx_t ctx) noexcept # Sets ``(rop, n)`` to the lowest `n` coefficients of the product of # ``(op1, len1)`` and ``(op2, len2)``. # Assumes that ``len1`` and ``len2`` are positive, but does allow @@ -326,45 +326,45 @@ cdef extern from "flint_wrap.h": # too. Assumes `n` is positive. Supports aliasing between ``rop``, # ``op1`` and ``op2``. - void fq_zech_poly_mullow_KS(fq_zech_poly_t rop, const fq_zech_poly_t op1, const fq_zech_poly_t op2, slong n, const fq_zech_ctx_t ctx) + void fq_zech_poly_mullow_KS(fq_zech_poly_t rop, const fq_zech_poly_t op1, const fq_zech_poly_t op2, slong n, const fq_zech_ctx_t ctx) noexcept # Sets ``rop`` to the product of ``op1`` and ``op2``. - void _fq_zech_poly_mullow(fq_zech_struct *rop, const fq_zech_struct *op1, slong len1, const fq_zech_struct *op2, slong len2, slong n, const fq_zech_ctx_t ctx) + void _fq_zech_poly_mullow(fq_zech_struct *rop, const fq_zech_struct *op1, slong len1, const fq_zech_struct *op2, slong len2, slong n, const fq_zech_ctx_t ctx) noexcept # Sets ``(rop, n)`` to the lowest `n` coefficients of the product of # ``(op1, len1)`` and ``(op2, len2)``. # Assumes ``0 < n <= len1 + len2 - 1``. Allows for zero-padding in # the inputs. Does not support aliasing between the inputs and the output. - void fq_zech_poly_mullow(fq_zech_poly_t rop, const fq_zech_poly_t op1, const fq_zech_poly_t op2, slong n, const fq_zech_ctx_t ctx) + void fq_zech_poly_mullow(fq_zech_poly_t rop, const fq_zech_poly_t op1, const fq_zech_poly_t op2, slong n, const fq_zech_ctx_t ctx) noexcept # Sets ``rop`` to the lowest `n` coefficients of the product of # ``op1`` and ``op2``. - void _fq_zech_poly_mulhigh_classical(fq_zech_struct *res, const fq_zech_struct *poly1, slong len1, const fq_zech_struct *poly2, slong len2, slong start, const fq_zech_ctx_t ctx) + void _fq_zech_poly_mulhigh_classical(fq_zech_struct *res, const fq_zech_struct *poly1, slong len1, const fq_zech_struct *poly2, slong len2, slong start, const fq_zech_ctx_t ctx) noexcept # Computes the product of ``(poly1, len1)`` and ``(poly2, len2)`` # and writes the coefficients from ``start`` onwards into the high # coefficients of ``res``, the remaining coefficients being arbitrary # but reduced. Assumes that ``len1 >= len2 > 0``. Aliasing of inputs # and output is not permitted. Algorithm is classical multiplication. - void fq_zech_poly_mulhigh_classical(fq_zech_poly_t res, const fq_zech_poly_t poly1, const fq_zech_poly_t poly2, slong start, const fq_zech_ctx_t ctx) + void fq_zech_poly_mulhigh_classical(fq_zech_poly_t res, const fq_zech_poly_t poly1, const fq_zech_poly_t poly2, slong start, const fq_zech_ctx_t ctx) noexcept # Computes the product of ``poly1`` and ``poly2`` and writes the # coefficients from ``start`` onwards into the high coefficients of # ``res``, the remaining coefficients being arbitrary but reduced. # Algorithm is classical multiplication. - void _fq_zech_poly_mulhigh(fq_zech_struct *res, const fq_zech_struct *poly1, slong len1, const fq_zech_struct *poly2, slong len2, slong start, fq_zech_ctx_t ctx) + void _fq_zech_poly_mulhigh(fq_zech_struct *res, const fq_zech_struct *poly1, slong len1, const fq_zech_struct *poly2, slong len2, slong start, fq_zech_ctx_t ctx) noexcept # Computes the product of ``(poly1, len1)`` and ``(poly2, len2)`` # and writes the coefficients from ``start`` onwards into the high # coefficients of ``res``, the remaining coefficients being arbitrary # but reduced. Assumes that ``len1 >= len2 > 0``. Aliasing of inputs # and output is not permitted. - void fq_zech_poly_mulhigh(fq_zech_poly_t res, const fq_zech_poly_t poly1, const fq_zech_poly_t poly2, slong start, const fq_zech_ctx_t ctx) + void fq_zech_poly_mulhigh(fq_zech_poly_t res, const fq_zech_poly_t poly1, const fq_zech_poly_t poly2, slong start, const fq_zech_ctx_t ctx) noexcept # Computes the product of ``poly1`` and ``poly2`` and writes the # coefficients from ``start`` onwards into the high coefficients of # ``res``, the remaining coefficients being arbitrary but reduced. - void _fq_zech_poly_mulmod(fq_zech_struct* res, const fq_zech_struct* poly1, slong len1, const fq_zech_struct* poly2, slong len2, const fq_zech_struct* f, slong lenf, const fq_zech_ctx_t ctx) + void _fq_zech_poly_mulmod(fq_zech_struct* res, const fq_zech_struct* poly1, slong len1, const fq_zech_struct* poly2, slong len2, const fq_zech_struct* f, slong lenf, const fq_zech_ctx_t ctx) noexcept # Sets ``res`` to the remainder of the product of ``poly1`` # and ``poly2`` upon polynomial division by ``f``. # It is required that ``len1 + len2 - lenf > 0``, which is @@ -372,62 +372,62 @@ cdef extern from "flint_wrap.h": # reduced. Otherwise, simply use ``_fq_zech_poly_mul`` instead. # Aliasing of ``f`` and ``res`` is not permitted. - void fq_zech_poly_mulmod(fq_zech_poly_t res, const fq_zech_poly_t poly1, const fq_zech_poly_t poly2, const fq_zech_poly_t f, const fq_zech_ctx_t ctx) + void fq_zech_poly_mulmod(fq_zech_poly_t res, const fq_zech_poly_t poly1, const fq_zech_poly_t poly2, const fq_zech_poly_t f, const fq_zech_ctx_t ctx) noexcept # Sets ``res`` to the remainder of the product of ``poly1`` # and ``poly2`` upon polynomial division by ``f``. - void _fq_zech_poly_mulmod_preinv(fq_zech_struct* res, const fq_zech_struct* poly1, slong len1, const fq_zech_struct* poly2, slong len2, const fq_zech_struct* f, slong lenf, const fq_zech_struct* finv, slong lenfinv, const fq_zech_ctx_t ctx) + void _fq_zech_poly_mulmod_preinv(fq_zech_struct* res, const fq_zech_struct* poly1, slong len1, const fq_zech_struct* poly2, slong len2, const fq_zech_struct* f, slong lenf, const fq_zech_struct* finv, slong lenfinv, const fq_zech_ctx_t ctx) noexcept # Sets ``res`` to the remainder of the product of ``poly1`` # and ``poly2`` upon polynomial division by ``f``. # It is required that ``finv`` is the inverse of the reverse of # ``f`` mod ``x^lenf``. # Aliasing of ``res`` with any of the inputs is not permitted. - void fq_zech_poly_mulmod_preinv(fq_zech_poly_t res, const fq_zech_poly_t poly1, const fq_zech_poly_t poly2, const fq_zech_poly_t f, const fq_zech_poly_t finv, const fq_zech_ctx_t ctx) + void fq_zech_poly_mulmod_preinv(fq_zech_poly_t res, const fq_zech_poly_t poly1, const fq_zech_poly_t poly2, const fq_zech_poly_t f, const fq_zech_poly_t finv, const fq_zech_ctx_t ctx) noexcept # Sets ``res`` to the remainder of the product of ``poly1`` # and ``poly2`` upon polynomial division by ``f``. ``finv`` # is the inverse of the reverse of ``f``. - void _fq_zech_poly_sqr_classical(fq_zech_struct *rop, const fq_zech_struct *op, slong len, const fq_zech_ctx_t ctx) + void _fq_zech_poly_sqr_classical(fq_zech_struct *rop, const fq_zech_struct *op, slong len, const fq_zech_ctx_t ctx) noexcept # Sets ``(rop, 2*len - 1)`` to the square of ``(op, len)``, # assuming that ``(op,len)`` is not zero and using classical # polynomial multiplication. # Permits zero padding. Does not support aliasing of ``rop`` # with either ``op1`` or ``op2``. - void fq_zech_poly_sqr_classical(fq_zech_poly_t rop, const fq_zech_poly_t op, const fq_zech_ctx_t ctx) + void fq_zech_poly_sqr_classical(fq_zech_poly_t rop, const fq_zech_poly_t op, const fq_zech_ctx_t ctx) noexcept # Sets ``rop`` to the square of ``op`` using classical # polynomial multiplication. - void _fq_zech_poly_sqr_KS(fq_zech_struct *rop, const fq_zech_struct *op, slong len, const fq_zech_ctx_t ctx) + void _fq_zech_poly_sqr_KS(fq_zech_struct *rop, const fq_zech_struct *op, slong len, const fq_zech_ctx_t ctx) noexcept # Sets ``(rop, 2*len - 1)`` to the square of ``(op, len)``. # Permits zero padding and places no assumptions on the # lengths ``len1`` and ``len2``. Supports aliasing. - void fq_zech_poly_sqr_KS(fq_zech_poly_t rop, const fq_zech_poly_t op, const fq_zech_ctx_t ctx) + void fq_zech_poly_sqr_KS(fq_zech_poly_t rop, const fq_zech_poly_t op, const fq_zech_ctx_t ctx) noexcept # Sets ``rop`` to the square ``op`` using Kronecker substitution, # that is, by encoding each coefficient in `\mathbf{F}_{q}` as an integer # and reducing this problem to multiplying two polynomials over the integers. - void _fq_zech_poly_sqr(fq_zech_struct *rop, const fq_zech_struct *op, slong len, const fq_zech_ctx_t ctx) + void _fq_zech_poly_sqr(fq_zech_struct *rop, const fq_zech_struct *op, slong len, const fq_zech_ctx_t ctx) noexcept # Sets ``(rop, 2* len - 1)`` to the square of ``(op, len)``, # choosing an appropriate algorithm. # Permits zero padding. Does not support aliasing. - void fq_zech_poly_sqr(fq_zech_poly_t rop, const fq_zech_poly_t op, const fq_zech_ctx_t ctx) + void fq_zech_poly_sqr(fq_zech_poly_t rop, const fq_zech_poly_t op, const fq_zech_ctx_t ctx) noexcept # Sets ``rop`` to the square of ``op``, # choosing an appropriate algorithm. - void _fq_zech_poly_pow(fq_zech_struct *rop, const fq_zech_struct *op, slong len, ulong e, const fq_zech_ctx_t ctx) + void _fq_zech_poly_pow(fq_zech_struct *rop, const fq_zech_struct *op, slong len, ulong e, const fq_zech_ctx_t ctx) noexcept # Sets ``rop = op^e``, assuming that ``e, len > 0`` and that # ``res`` has space for ``e*(len - 1) + 1`` coefficients. Does # not support aliasing. - void fq_zech_poly_pow(fq_zech_poly_t rop, const fq_zech_poly_t op, ulong e, const fq_zech_ctx_t ctx) + void fq_zech_poly_pow(fq_zech_poly_t rop, const fq_zech_poly_t op, ulong e, const fq_zech_ctx_t ctx) noexcept # Computes ``rop = op^e``. If `e` is zero, returns one, # so that in particular ``0^0 = 1``. - void _fq_zech_poly_powmod_ui_binexp(fq_zech_struct* res, const fq_zech_struct* poly, ulong e, const fq_zech_struct* f, slong lenf, const fq_zech_ctx_t ctx) + void _fq_zech_poly_powmod_ui_binexp(fq_zech_struct* res, const fq_zech_struct* poly, ulong e, const fq_zech_struct* f, slong lenf, const fq_zech_ctx_t ctx) noexcept # Sets ``res`` to ``poly`` raised to the power ``e`` modulo # ``f``, using binary exponentiation. We require ``e > 0``. # We require ``lenf > 1``. It is assumed that ``poly`` is @@ -435,11 +435,11 @@ cdef extern from "flint_wrap.h": # have length exactly ``lenf - 1``. The output ``res`` must # have room for ``lenf - 1`` coefficients. - void fq_zech_poly_powmod_ui_binexp(fq_zech_poly_t res, const fq_zech_poly_t poly, ulong e, const fq_zech_poly_t f, const fq_zech_ctx_t ctx) + void fq_zech_poly_powmod_ui_binexp(fq_zech_poly_t res, const fq_zech_poly_t poly, ulong e, const fq_zech_poly_t f, const fq_zech_ctx_t ctx) noexcept # Sets ``res`` to ``poly`` raised to the power ``e`` modulo # ``f``, using binary exponentiation. We require ``e >= 0``. - void _fq_zech_poly_powmod_ui_binexp_preinv(fq_zech_struct* res, const fq_zech_struct* poly, ulong e, const fq_zech_struct* f, slong lenf, const fq_zech_struct* finv, slong lenfinv, const fq_zech_ctx_t ctx) + void _fq_zech_poly_powmod_ui_binexp_preinv(fq_zech_struct* res, const fq_zech_struct* poly, ulong e, const fq_zech_struct* f, slong lenf, const fq_zech_struct* finv, slong lenfinv, const fq_zech_ctx_t ctx) noexcept # Sets ``res`` to ``poly`` raised to the power ``e`` modulo # ``f``, using binary exponentiation. We require ``e > 0``. # We require ``finv`` to be the inverse of the reverse of @@ -449,13 +449,13 @@ cdef extern from "flint_wrap.h": # have length exactly ``lenf - 1``. The output ``res`` must # have room for ``lenf - 1`` coefficients. - void fq_zech_poly_powmod_ui_binexp_preinv(fq_zech_poly_t res, const fq_zech_poly_t poly, ulong e, const fq_zech_poly_t f, const fq_zech_poly_t finv, const fq_zech_ctx_t ctx) + void fq_zech_poly_powmod_ui_binexp_preinv(fq_zech_poly_t res, const fq_zech_poly_t poly, ulong e, const fq_zech_poly_t f, const fq_zech_poly_t finv, const fq_zech_ctx_t ctx) noexcept # Sets ``res`` to ``poly`` raised to the power ``e`` modulo # ``f``, using binary exponentiation. We require ``e >= 0``. # We require ``finv`` to be the inverse of the reverse of # ``f``. - void _fq_zech_poly_powmod_fmpz_binexp(fq_zech_struct* res, const fq_zech_struct* poly, const fmpz_t e, const fq_zech_struct* f, slong lenf, const fq_zech_ctx_t ctx) + void _fq_zech_poly_powmod_fmpz_binexp(fq_zech_struct* res, const fq_zech_struct* poly, const fmpz_t e, const fq_zech_struct* f, slong lenf, const fq_zech_ctx_t ctx) noexcept # Sets ``res`` to ``poly`` raised to the power ``e`` modulo # ``f``, using binary exponentiation. We require ``e > 0``. # We require ``lenf > 1``. It is assumed that ``poly`` is @@ -463,11 +463,11 @@ cdef extern from "flint_wrap.h": # have length exactly ``lenf - 1``. The output ``res`` must # have room for ``lenf - 1`` coefficients. - void fq_zech_poly_powmod_fmpz_binexp(fq_zech_poly_t res, const fq_zech_poly_t poly, const fmpz_t e, const fq_zech_poly_t f, const fq_zech_ctx_t ctx) + void fq_zech_poly_powmod_fmpz_binexp(fq_zech_poly_t res, const fq_zech_poly_t poly, const fmpz_t e, const fq_zech_poly_t f, const fq_zech_ctx_t ctx) noexcept # Sets ``res`` to ``poly`` raised to the power ``e`` modulo # ``f``, using binary exponentiation. We require ``e >= 0``. - void _fq_zech_poly_powmod_fmpz_binexp_preinv(fq_zech_struct* res, const fq_zech_struct* poly, const fmpz_t e, const fq_zech_struct* f, slong lenf, const fq_zech_struct* finv, slong lenfinv, const fq_zech_ctx_t ctx) + void _fq_zech_poly_powmod_fmpz_binexp_preinv(fq_zech_struct* res, const fq_zech_struct* poly, const fmpz_t e, const fq_zech_struct* f, slong lenf, const fq_zech_struct* finv, slong lenfinv, const fq_zech_ctx_t ctx) noexcept # Sets ``res`` to ``poly`` raised to the power ``e`` modulo # ``f``, using binary exponentiation. We require ``e > 0``. # We require ``finv`` to be the inverse of the reverse of @@ -477,13 +477,13 @@ cdef extern from "flint_wrap.h": # have length exactly ``lenf - 1``. The output ``res`` must # have room for ``lenf - 1`` coefficients. - void fq_zech_poly_powmod_fmpz_binexp_preinv(fq_zech_poly_t res, const fq_zech_poly_t poly, const fmpz_t e, const fq_zech_poly_t f, const fq_zech_poly_t finv, const fq_zech_ctx_t ctx) + void fq_zech_poly_powmod_fmpz_binexp_preinv(fq_zech_poly_t res, const fq_zech_poly_t poly, const fmpz_t e, const fq_zech_poly_t f, const fq_zech_poly_t finv, const fq_zech_ctx_t ctx) noexcept # Sets ``res`` to ``poly`` raised to the power ``e`` modulo # ``f``, using binary exponentiation. We require ``e >= 0``. # We require ``finv`` to be the inverse of the reverse of # ``f``. - void _fq_zech_poly_powmod_fmpz_sliding_preinv(fq_zech_struct* res, const fq_zech_struct* poly, const fmpz_t e, ulong k, const fq_zech_struct* f, slong lenf, const fq_zech_struct* finv, slong lenfinv, const fq_zech_ctx_t ctx) + void _fq_zech_poly_powmod_fmpz_sliding_preinv(fq_zech_struct* res, const fq_zech_struct* poly, const fmpz_t e, ulong k, const fq_zech_struct* f, slong lenf, const fq_zech_struct* finv, slong lenfinv, const fq_zech_ctx_t ctx) noexcept # Sets ``res`` to ``poly`` raised to the power ``e`` modulo # ``f``, using sliding-window exponentiation with window size # ``k``. We require ``e > 0``. We require ``finv`` to be @@ -495,7 +495,7 @@ cdef extern from "flint_wrap.h": # have length exactly ``lenf - 1``. The output ``res`` must # have room for ``lenf - 1`` coefficients. - void fq_zech_poly_powmod_fmpz_sliding_preinv(fq_zech_poly_t res, const fq_zech_poly_t poly, const fmpz_t e, ulong k, const fq_zech_poly_t f, const fq_zech_poly_t finv, const fq_zech_ctx_t ctx) + void fq_zech_poly_powmod_fmpz_sliding_preinv(fq_zech_poly_t res, const fq_zech_poly_t poly, const fmpz_t e, ulong k, const fq_zech_poly_t f, const fq_zech_poly_t finv, const fq_zech_ctx_t ctx) noexcept # Sets ``res`` to ``poly`` raised to the power ``e`` modulo # ``f``, using sliding-window exponentiation with window size # ``k``. We require ``e >= 0``. We require ``finv`` to be @@ -503,31 +503,31 @@ cdef extern from "flint_wrap.h": # zero, then an "optimum" size will be selected automatically base # on ``e``. - void _fq_zech_poly_powmod_x_fmpz_preinv(fq_zech_struct * res, const fmpz_t e, const fq_zech_struct * f, slong lenf, const fq_zech_struct * finv, slong lenfinv, const fq_zech_ctx_t ctx) + void _fq_zech_poly_powmod_x_fmpz_preinv(fq_zech_struct * res, const fmpz_t e, const fq_zech_struct * f, slong lenf, const fq_zech_struct * finv, slong lenfinv, const fq_zech_ctx_t ctx) noexcept # Sets ``res`` to ``x`` raised to the power ``e`` modulo ``f``, # using sliding window exponentiation. We require ``e > 0``. # We require ``finv`` to be the inverse of the reverse of ``f``. # We require ``lenf > 2``. The output ``res`` must have room for # ``lenf - 1`` coefficients. - void fq_zech_poly_powmod_x_fmpz_preinv(fq_zech_poly_t res, const fmpz_t e, const fq_zech_poly_t f, const fq_zech_poly_t finv, const fq_zech_ctx_t ctx) + void fq_zech_poly_powmod_x_fmpz_preinv(fq_zech_poly_t res, const fmpz_t e, const fq_zech_poly_t f, const fq_zech_poly_t finv, const fq_zech_ctx_t ctx) noexcept # Sets ``res`` to ``x`` raised to the power ``e`` # modulo ``f``, using sliding window exponentiation. We require # ``e >= 0``. We require ``finv`` to be the inverse of the reverse of # ``f``. - void _fq_zech_poly_pow_trunc_binexp(fq_zech_struct * res, const fq_zech_struct * poly, ulong e, slong trunc, const fq_zech_ctx_t ctx) + void _fq_zech_poly_pow_trunc_binexp(fq_zech_struct * res, const fq_zech_struct * poly, ulong e, slong trunc, const fq_zech_ctx_t ctx) noexcept # Sets ``res`` to the low ``trunc`` coefficients of ``poly`` # (assumed to be zero padded if necessary to length ``trunc``) to the power ``e``. This is equivalent to doing a powering followed # by a truncation. We require that ``res`` has enough space for # ``trunc`` coefficients, that ``trunc > 0`` and that ``e > 1``. Aliasing is not permitted. Uses the binary exponentiation method. - void fq_zech_poly_pow_trunc_binexp(fq_zech_poly_t res, const fq_zech_poly_t poly, ulong e, slong trunc, const fq_zech_ctx_t ctx) + void fq_zech_poly_pow_trunc_binexp(fq_zech_poly_t res, const fq_zech_poly_t poly, ulong e, slong trunc, const fq_zech_ctx_t ctx) noexcept # Sets ``res`` to the low ``trunc`` coefficients of ``poly`` # to the power ``e``. This is equivalent to doing a powering # followed by a truncation. Uses the binary exponentiation method. - void _fq_zech_poly_pow_trunc(fq_zech_struct * res, const fq_zech_struct * poly, ulong e, slong trunc, const fq_zech_ctx_t mod) + void _fq_zech_poly_pow_trunc(fq_zech_struct * res, const fq_zech_struct * poly, ulong e, slong trunc, const fq_zech_ctx_t mod) noexcept # Sets ``res`` to the low ``trunc`` coefficients of ``poly`` # (assumed to be zero padded if necessary to length ``trunc``) to # the power ``e``. This is equivalent to doing a powering followed @@ -535,12 +535,12 @@ cdef extern from "flint_wrap.h": # ``trunc`` coefficients, that ``trunc > 0`` and that # ``e > 1``. Aliasing is not permitted. - void fq_zech_poly_pow_trunc(fq_zech_poly_t res, const fq_zech_poly_t poly, ulong e, slong trunc, const fq_zech_ctx_t ctx) + void fq_zech_poly_pow_trunc(fq_zech_poly_t res, const fq_zech_poly_t poly, ulong e, slong trunc, const fq_zech_ctx_t ctx) noexcept # Sets ``res`` to the low ``trunc`` coefficients of ``poly`` # to the power ``e``. This is equivalent to doing a powering # followed by a truncation. - void _fq_zech_poly_shift_left(fq_zech_struct *rop, const fq_zech_struct *op, slong len, slong n, const fq_zech_ctx_t ctx) + void _fq_zech_poly_shift_left(fq_zech_struct *rop, const fq_zech_struct *op, slong len, slong n, const fq_zech_ctx_t ctx) noexcept # Sets ``(rop, len + n)`` to ``(op, len)`` shifted left by # `n` coefficients. # Inserts zero coefficients at the lower end. Assumes that @@ -548,11 +548,11 @@ cdef extern from "flint_wrap.h": # ``len + n`` elements. Supports aliasing between ``rop`` and # ``op``. - void fq_zech_poly_shift_left(fq_zech_poly_t rop, const fq_zech_poly_t op, slong n, const fq_zech_ctx_t ctx) + void fq_zech_poly_shift_left(fq_zech_poly_t rop, const fq_zech_poly_t op, slong n, const fq_zech_ctx_t ctx) noexcept # Sets ``rop`` to ``op`` shifted left by `n` coeffs. Zero # coefficients are inserted. - void _fq_zech_poly_shift_right(fq_zech_struct *rop, const fq_zech_struct *op, slong len, slong n, const fq_zech_ctx_t ctx) + void _fq_zech_poly_shift_right(fq_zech_struct *rop, const fq_zech_struct *op, slong len, slong n, const fq_zech_ctx_t ctx) noexcept # Sets ``(rop, len - n)`` to ``(op, len)`` shifted right by # `n` coefficients. # Assumes that ``len`` and `n` are positive, that ``len > n``, @@ -560,18 +560,18 @@ cdef extern from "flint_wrap.h": # aliasing between ``rop`` and ``op``, although in this case # the top coefficients of ``op`` are not set to zero. - void fq_zech_poly_shift_right(fq_zech_poly_t rop, const fq_zech_poly_t op, slong n, const fq_zech_ctx_t ctx) + void fq_zech_poly_shift_right(fq_zech_poly_t rop, const fq_zech_poly_t op, slong n, const fq_zech_ctx_t ctx) noexcept # Sets ``rop`` to ``op`` shifted right by `n` coefficients. # If `n` is equal to or greater than the current length of # ``op``, ``rop`` is set to the zero polynomial. - slong _fq_zech_poly_hamming_weight(const fq_zech_struct *op, slong len, const fq_zech_ctx_t ctx) + slong _fq_zech_poly_hamming_weight(const fq_zech_struct *op, slong len, const fq_zech_ctx_t ctx) noexcept # Returns the number of non-zero entries in ``(op, len)``. - slong fq_zech_poly_hamming_weight(const fq_zech_poly_t op, const fq_zech_ctx_t ctx) + slong fq_zech_poly_hamming_weight(const fq_zech_poly_t op, const fq_zech_ctx_t ctx) noexcept # Returns the number of non-zero entries in the polynomial ``op``. - void _fq_zech_poly_divrem(fq_zech_struct *Q, fq_zech_struct *R, const fq_zech_struct *A, slong lenA, const fq_zech_struct *B, slong lenB, const fq_zech_t invB, const fq_zech_ctx_t ctx) + void _fq_zech_poly_divrem(fq_zech_struct *Q, fq_zech_struct *R, const fq_zech_struct *A, slong lenA, const fq_zech_struct *B, slong lenB, const fq_zech_t invB, const fq_zech_ctx_t ctx) noexcept # Computes ``(Q, lenA - lenB + 1)``, ``(R, lenA)`` such that # `A = B Q + R` with `0 \leq \operatorname{len}(R) < \operatorname{len}(B)`. # Assumes that the leading coefficient of `B` is invertible @@ -580,14 +580,14 @@ cdef extern from "flint_wrap.h": # ``(A, lenA)``. `R` and `A` may be aliased, but apart from # this no aliasing of input and output operands is allowed. - void fq_zech_poly_divrem(fq_zech_poly_t Q, fq_zech_poly_t R, const fq_zech_poly_t A, const fq_zech_poly_t B, const fq_zech_ctx_t ctx) + void fq_zech_poly_divrem(fq_zech_poly_t Q, fq_zech_poly_t R, const fq_zech_poly_t A, const fq_zech_poly_t B, const fq_zech_ctx_t ctx) noexcept # Computes `Q`, `R` such that `A = B Q + R` with # `0 \leq \operatorname{len}(R) < \operatorname{len}(B)`. # Assumes that the leading coefficient of `B` is invertible. This can # be taken for granted the context is for a finite field, that is, when # `p` is prime and `f(X)` is irreducible. - void fq_zech_poly_divrem_f(fq_zech_t f, fq_zech_poly_t Q, fq_zech_poly_t R, const fq_zech_poly_t A, const fq_zech_poly_t B, const fq_zech_ctx_t ctx) + void fq_zech_poly_divrem_f(fq_zech_t f, fq_zech_poly_t Q, fq_zech_poly_t R, const fq_zech_poly_t A, const fq_zech_poly_t B, const fq_zech_ctx_t ctx) noexcept # Either finds a non-trivial factor `f` of the modulus of # ``ctx``, or computes `Q`, `R` such that `A = B Q + R` and # `0 \leq \operatorname{len}(R) < \operatorname{len}(B)`. @@ -597,27 +597,27 @@ cdef extern from "flint_wrap.h": # non-trivial factor of the modulus and `Q` and `R` are not touched. # Assumes that `B` is non-zero. - void _fq_zech_poly_rem(fq_zech_struct *R, const fq_zech_struct *A, slong lenA, const fq_zech_struct *B, slong lenB, const fq_zech_t invB, const fq_zech_ctx_t ctx) + void _fq_zech_poly_rem(fq_zech_struct *R, const fq_zech_struct *A, slong lenA, const fq_zech_struct *B, slong lenB, const fq_zech_t invB, const fq_zech_ctx_t ctx) noexcept # Sets ``R`` to the remainder of the division of ``(A,lenA)`` by # ``(B,lenB)``. Assumes that the leading coefficient of ``(B,lenB)`` # is invertible and that ``invB`` is its inverse. - void fq_zech_poly_rem(fq_zech_poly_t R, const fq_zech_poly_t A, const fq_zech_poly_t B, const fq_zech_ctx_t ctx) + void fq_zech_poly_rem(fq_zech_poly_t R, const fq_zech_poly_t A, const fq_zech_poly_t B, const fq_zech_ctx_t ctx) noexcept # Sets ``R`` to the remainder of the division of ``A`` by # ``B`` in the context described by ``ctx``. - void _fq_zech_poly_div(fq_zech_struct *Q, const fq_zech_struct *A, slong lenA, const fq_zech_struct *B, slong lenB, const fq_zech_t invB, const fq_zech_ctx_t ctx) + void _fq_zech_poly_div(fq_zech_struct *Q, const fq_zech_struct *A, slong lenA, const fq_zech_struct *B, slong lenB, const fq_zech_t invB, const fq_zech_ctx_t ctx) noexcept # Notationally, computes `Q`, `R` such that `A = B Q + R` with `0 # \leq \operatorname{len}(R) < \operatorname{len}(B)` but only sets ``(Q, lenA - lenB + 1)``. # Allows zero-padding in `A` but not in `B`. Assumes that the leading coefficient of `B` is a # unit. - void fq_zech_poly_div(fq_zech_poly_t Q, const fq_zech_poly_t A, const fq_zech_poly_t B, const fq_zech_ctx_t ctx) + void fq_zech_poly_div(fq_zech_poly_t Q, const fq_zech_poly_t A, const fq_zech_poly_t B, const fq_zech_ctx_t ctx) noexcept # Notionally finds polynomials `Q` and `R` such that `A = B Q + R` with # `\operatorname{len}(R) < \operatorname{len}(B)`, but returns only ``Q``. If `\operatorname{len}(B) = 0` an # exception is raised. - void _fq_zech_poly_div_newton_n_preinv(fq_zech_struct* Q, const fq_zech_struct* A, slong lenA, const fq_zech_struct* B, slong lenB, const fq_zech_struct* Binv, slong lenBinv, const fq_zech_ctx_t ctx) + void _fq_zech_poly_div_newton_n_preinv(fq_zech_struct* Q, const fq_zech_struct* A, slong lenA, const fq_zech_struct* B, slong lenB, const fq_zech_struct* Binv, slong lenBinv, const fq_zech_ctx_t ctx) noexcept # Notionally computes polynomials `Q` and `R` such that `A = BQ + R` with # `\operatorname{len}(R)` less than ``lenB``, where ``A`` is of length ``lenA`` # and ``B`` is of length ``lenB``, but return only `Q`. @@ -627,7 +627,7 @@ cdef extern from "flint_wrap.h": # The algorithm used is to reverse the polynomials and divide the # resulting power series, then reverse the result. - void fq_zech_poly_div_newton_n_preinv(fq_zech_poly_t Q, const fq_zech_poly_t A, const fq_zech_poly_t B, const fq_zech_poly_t Binv, const fq_zech_ctx_t ctx) + void fq_zech_poly_div_newton_n_preinv(fq_zech_poly_t Q, const fq_zech_poly_t A, const fq_zech_poly_t B, const fq_zech_poly_t Binv, const fq_zech_ctx_t ctx) noexcept # Notionally computes `Q` and `R` such that `A = BQ + R` with # `\operatorname{len}(R) < \operatorname{len}(B)`, but returns only `Q`. # We assume that the leading coefficient of `B` is a unit and that `Binv` is @@ -637,7 +637,7 @@ cdef extern from "flint_wrap.h": # The algorithm used is to reverse the polynomials and divide the # resulting power series, then reverse the result. - void _fq_zech_poly_divrem_newton_n_preinv(fq_zech_struct* Q, fq_zech_struct* R, const fq_zech_struct* A, slong lenA, const fq_zech_struct* B, slong lenB, const fq_zech_struct* Binv, slong lenBinv, const fq_zech_ctx_t ctx) + void _fq_zech_poly_divrem_newton_n_preinv(fq_zech_struct* Q, fq_zech_struct* R, const fq_zech_struct* A, slong lenA, const fq_zech_struct* B, slong lenB, const fq_zech_struct* Binv, slong lenBinv, const fq_zech_ctx_t ctx) noexcept # Computes `Q` and `R` such that `A = BQ + R` with `\operatorname{len}(R)` less # than ``lenB``, where `A` is of length ``lenA`` and `B` is of # length ``lenB``. We require that `Q` have space for @@ -646,7 +646,7 @@ cdef extern from "flint_wrap.h": # used is to call :func:`div_newton_preinv` and then multiply out # and compute the remainder. - void fq_zech_poly_divrem_newton_n_preinv(fq_zech_poly_t Q, fq_zech_poly_t R, const fq_zech_poly_t A, const fq_zech_poly_t B, const fq_zech_poly_t Binv, const fq_zech_ctx_t ctx) + void fq_zech_poly_divrem_newton_n_preinv(fq_zech_poly_t Q, fq_zech_poly_t R, const fq_zech_poly_t A, const fq_zech_poly_t B, const fq_zech_poly_t Binv, const fq_zech_ctx_t ctx) noexcept # Computes `Q` and `R` such that `A = BQ + R` with `\operatorname{len}(R) < # \operatorname{len}(B)`. We assume `Binv` is the inverse of the reverse of `B` # mod `x^{\operatorname{len}(B)}`. @@ -655,43 +655,43 @@ cdef extern from "flint_wrap.h": # The algorithm used is to call :func:`div_newton` and then # multiply out and compute the remainder. - void _fq_zech_poly_inv_series_newton(fq_zech_struct* Qinv, const fq_zech_struct* Q, slong n, const fq_zech_t cinv, const fq_zech_ctx_t ctx) + void _fq_zech_poly_inv_series_newton(fq_zech_struct* Qinv, const fq_zech_struct* Q, slong n, const fq_zech_t cinv, const fq_zech_ctx_t ctx) noexcept # Given ``Q`` of length ``n`` whose constant coefficient is # invertible modulo the given modulus, find a polynomial ``Qinv`` # of length ``n`` such that ``Q * Qinv`` is ``1`` modulo # `x^n`. Requires ``n > 0``. This function can be viewed as # inverting a power series via Newton iteration. - void fq_zech_poly_inv_series_newton(fq_zech_poly_t Qinv, const fq_zech_poly_t Q, slong n, const fq_zech_ctx_t ctx) + void fq_zech_poly_inv_series_newton(fq_zech_poly_t Qinv, const fq_zech_poly_t Q, slong n, const fq_zech_ctx_t ctx) noexcept # Given ``Q`` find ``Qinv`` such that ``Q * Qinv`` is # ``1`` modulo `x^n`. The constant coefficient of ``Q`` must # be invertible modulo the modulus of ``Q``. An exception is # raised if this is not the case or if ``n = 0``. This function # can be viewed as inverting a power series via Newton iteration. - void _fq_zech_poly_inv_series(fq_zech_struct* Qinv, const fq_zech_struct* Q, slong n, const fq_zech_t cinv, const fq_zech_ctx_t ctx) + void _fq_zech_poly_inv_series(fq_zech_struct* Qinv, const fq_zech_struct* Q, slong n, const fq_zech_t cinv, const fq_zech_ctx_t ctx) noexcept # Given ``Q`` of length ``n`` whose constant coefficient is # invertible modulo the given modulus, find a polynomial ``Qinv`` # of length ``n`` such that ``Q * Qinv`` is ``1`` modulo # `x^n`. Requires ``n > 0``. - void fq_zech_poly_inv_series(fq_zech_poly_t Qinv, const fq_zech_poly_t Q, slong n, const fq_zech_ctx_t ctx) + void fq_zech_poly_inv_series(fq_zech_poly_t Qinv, const fq_zech_poly_t Q, slong n, const fq_zech_ctx_t ctx) noexcept # Given ``Q`` find ``Qinv`` such that ``Q * Qinv`` is # ``1`` modulo `x^n`. The constant coefficient of ``Q`` must # be invertible modulo the modulus of ``Q``. An exception is # raised if this is not the case or if ``n = 0``. - void _fq_zech_poly_div_series(fq_zech_struct * Q, const fq_zech_struct * A, slong Alen, const fq_zech_struct * B, slong Blen, slong n, const fq_zech_ctx_t ctx) + void _fq_zech_poly_div_series(fq_zech_struct * Q, const fq_zech_struct * A, slong Alen, const fq_zech_struct * B, slong Blen, slong n, const fq_zech_ctx_t ctx) noexcept # Set ``(Q, n)`` to the quotient of the series ``(A, Alen``) and # ``(B, Blen)`` assuming ``Alen, Blen <= n``. We assume the bottom # coefficient of ``B`` is invertible. - void fq_zech_poly_div_series(fq_zech_poly_t Q, const fq_zech_poly_t A, const fq_zech_poly_t B, slong n, const fq_zech_ctx_t ctx) + void fq_zech_poly_div_series(fq_zech_poly_t Q, const fq_zech_poly_t A, const fq_zech_poly_t B, slong n, const fq_zech_ctx_t ctx) noexcept # Set `Q` to the quotient of the series `A` by `B`, thinking of the series as # though they were of length `n`. We assume that the bottom coefficient of # `B` is invertible. - void fq_zech_poly_gcd(fq_zech_poly_t rop, const fq_zech_poly_t op1, const fq_zech_poly_t op2, const fq_zech_ctx_t ctx) + void fq_zech_poly_gcd(fq_zech_poly_t rop, const fq_zech_poly_t op1, const fq_zech_poly_t op2, const fq_zech_ctx_t ctx) noexcept # Sets ``rop`` to the greatest common divisor of ``op1`` and # ``op2``, using the either the Euclidean or HGCD algorithm. The # GCD of zero polynomials is defined to be zero, whereas the GCD of @@ -699,14 +699,14 @@ cdef extern from "flint_wrap.h": # `P`. Except in the case where the GCD is zero, the GCD `G` is made # monic. - slong _fq_zech_poly_gcd(fq_zech_struct* G, const fq_zech_struct* A, slong lenA, const fq_zech_struct* B, slong lenB, const fq_zech_ctx_t ctx) + slong _fq_zech_poly_gcd(fq_zech_struct* G, const fq_zech_struct* A, slong lenA, const fq_zech_struct* B, slong lenB, const fq_zech_ctx_t ctx) noexcept # Computes the GCD of `A` of length ``lenA`` and `B` of length # ``lenB``, where ``lenA >= lenB > 0`` and sets `G` to it. The # length of the GCD `G` is returned by the function. No attempt is # made to make the GCD monic. It is required that `G` have space for # ``lenB`` coefficients. - slong _fq_zech_poly_gcd_euclidean_f(fq_zech_t f, fq_zech_struct *G, const fq_zech_struct *A, slong lenA, const fq_zech_struct *B, slong lenB, const fq_zech_ctx_t ctx) + slong _fq_zech_poly_gcd_euclidean_f(fq_zech_t f, fq_zech_struct *G, const fq_zech_struct *A, slong lenA, const fq_zech_struct *B, slong lenB, const fq_zech_ctx_t ctx) noexcept # Either sets `f = 1` and `G` to the greatest common divisor of # `(A,\operatorname{len}(A))` and `(B, \operatorname{len}(B))` and returns its length, or sets # `f` to a non-trivial factor of the modulus of ``ctx`` and leaves @@ -714,11 +714,11 @@ cdef extern from "flint_wrap.h": # Assumes that `\operatorname{len}(A) \geq \operatorname{len}(B) > 0` and that the vector `G` # has space for sufficiently many coefficients. - void fq_zech_poly_gcd_euclidean_f(fq_zech_t f, fq_zech_poly_t G, const fq_zech_poly_t A, const fq_zech_poly_t B, const fq_zech_ctx_t ctx) + void fq_zech_poly_gcd_euclidean_f(fq_zech_t f, fq_zech_poly_t G, const fq_zech_poly_t A, const fq_zech_poly_t B, const fq_zech_ctx_t ctx) noexcept # Either sets `f = 1` and `G` to the greatest common divisor of `A` # and `B` or sets `f` to a factor of the modulus of ``ctx``. - slong _fq_zech_poly_xgcd(fq_zech_struct *G, fq_zech_struct *S, fq_zech_struct *T, const fq_zech_struct *A, slong lenA, const fq_zech_struct *B, slong lenB, const fq_zech_ctx_t ctx) + slong _fq_zech_poly_xgcd(fq_zech_struct *G, fq_zech_struct *S, fq_zech_struct *T, const fq_zech_struct *A, slong lenA, const fq_zech_struct *B, slong lenB, const fq_zech_ctx_t ctx) noexcept # Computes the GCD of `A` and `B` together with cofactors `S` and `T` # such that `S A + T B = G`. Returns the length of `G`. # Assumes that `\operatorname{len}(A) \geq \operatorname{len}(B) \geq 1` and @@ -730,7 +730,7 @@ cdef extern from "flint_wrap.h": # `\operatorname{len}(T) \leq \max(\operatorname{len}(A) - \operatorname{len}(G), 1)`. # No aliasing of input and output operands is permitted. - void fq_zech_poly_xgcd(fq_zech_poly_t G, fq_zech_poly_t S, fq_zech_poly_t T, const fq_zech_poly_t A, const fq_zech_poly_t B, const fq_zech_ctx_t ctx) + void fq_zech_poly_xgcd(fq_zech_poly_t G, fq_zech_poly_t S, fq_zech_poly_t T, const fq_zech_poly_t A, const fq_zech_poly_t B, const fq_zech_ctx_t ctx) noexcept # Computes the GCD of `A` and `B`. The GCD of zero polynomials is # defined to be zero, whereas the GCD of the zero polynomial and some other # polynomial `P` is defined to be `P`. Except in the case where @@ -739,7 +739,7 @@ cdef extern from "flint_wrap.h": # ``S*A + T*B = G``. The length of ``S`` will be at most # ``lenB`` and the length of ``T`` will be at most ``lenA``. - slong _fq_zech_poly_xgcd_euclidean_f(fq_zech_t f, fq_zech_struct *G, fq_zech_struct *S, fq_zech_struct *T, const fq_zech_struct *A, slong lenA, const fq_zech_struct *B, slong lenB, const fq_zech_ctx_t ctx) + slong _fq_zech_poly_xgcd_euclidean_f(fq_zech_t f, fq_zech_struct *G, fq_zech_struct *S, fq_zech_struct *T, const fq_zech_struct *A, slong lenA, const fq_zech_struct *B, slong lenB, const fq_zech_ctx_t ctx) noexcept # Either sets `f = 1` and computes the GCD of `A` and `B` together # with cofactors `S` and `T` such that `S A + T B = G`; otherwise, # sets `f` to a non-trivial factor of the modulus of ``ctx`` and @@ -753,7 +753,7 @@ cdef extern from "flint_wrap.h": # `\operatorname{len}(T) \leq \max(\operatorname{len}(A) - \operatorname{len}(G), 1)`. # No aliasing of input and output operands is permitted. - void fq_zech_poly_xgcd_euclidean_f(fq_zech_t f, fq_zech_poly_t G, fq_zech_poly_t S, fq_zech_poly_t T, const fq_zech_poly_t A, const fq_zech_poly_t B, const fq_zech_ctx_t ctx) + void fq_zech_poly_xgcd_euclidean_f(fq_zech_t f, fq_zech_poly_t G, fq_zech_poly_t S, fq_zech_poly_t T, const fq_zech_poly_t A, const fq_zech_poly_t B, const fq_zech_ctx_t ctx) noexcept # Either sets `f = 1` and computes the GCD of `A` and `B` or sets # `f` to a non-trivial factor of the modulus of ``ctx``. # If the GCD is computed, polynomials ``S`` and ``T`` are @@ -765,7 +765,7 @@ cdef extern from "flint_wrap.h": # be `P`. Except in the case where the GCD is zero, the GCD `G` is # made monic. - int _fq_zech_poly_divides(fq_zech_struct *Q, const fq_zech_struct *A, slong lenA, const fq_zech_struct *B, slong lenB, const fq_zech_t invB, const fq_zech_ctx_t ctx) + int _fq_zech_poly_divides(fq_zech_struct *Q, const fq_zech_struct *A, slong lenA, const fq_zech_struct *B, slong lenB, const fq_zech_t invB, const fq_zech_ctx_t ctx) noexcept # Returns `1` if ``(B, lenB)`` divides ``(A, lenA)`` exactly and # sets `Q` to the quotient, otherwise returns `0`. # It is assumed that `\operatorname{len}(A) \geq \operatorname{len}(B) > 0` and that `Q` has space @@ -774,57 +774,57 @@ cdef extern from "flint_wrap.h": # This function is currently unoptimised and provided for convenience # only. - int fq_zech_poly_divides(fq_zech_poly_t Q, const fq_zech_poly_t A, const fq_zech_poly_t B, const fq_zech_ctx_t ctx) + int fq_zech_poly_divides(fq_zech_poly_t Q, const fq_zech_poly_t A, const fq_zech_poly_t B, const fq_zech_ctx_t ctx) noexcept # Returns `1` if `B` divides `A` exactly and sets `Q` to the quotient, # otherwise returns `0`. # This function is currently unoptimised and provided for convenience # only. - void _fq_zech_poly_derivative(fq_zech_struct *rop, const fq_zech_struct *op, slong len, const fq_zech_ctx_t ctx) + void _fq_zech_poly_derivative(fq_zech_struct *rop, const fq_zech_struct *op, slong len, const fq_zech_ctx_t ctx) noexcept # Sets ``(rop, len - 1)`` to the derivative of ``(op, len)``. # Also handles the cases where ``len`` is `0` or `1` correctly. # Supports aliasing of ``rop`` and ``op``. - void fq_zech_poly_derivative(fq_zech_poly_t rop, const fq_zech_poly_t op, const fq_zech_ctx_t ctx) + void fq_zech_poly_derivative(fq_zech_poly_t rop, const fq_zech_poly_t op, const fq_zech_ctx_t ctx) noexcept # Sets ``rop`` to the derivative of ``op``. - void _fq_zech_poly_invsqrt_series(fq_zech_struct * g, const fq_zech_struct * h, slong n, fq_zech_ctx_t mod) + void _fq_zech_poly_invsqrt_series(fq_zech_struct * g, const fq_zech_struct * h, slong n, fq_zech_ctx_t mod) noexcept # Set the first `n` terms of `g` to the series expansion of `1/\sqrt{h}`. # It is assumed that `n > 0`, that `h` has constant term 1 and that `h` # is zero-padded as necessary to length `n`. Aliasing is not permitted. - void fq_zech_poly_invsqrt_series(fq_zech_poly_t g, const fq_zech_poly_t h, slong n, fq_zech_ctx_t ctx) + void fq_zech_poly_invsqrt_series(fq_zech_poly_t g, const fq_zech_poly_t h, slong n, fq_zech_ctx_t ctx) noexcept # Set `g` to the series expansion of `1/\sqrt{h}` to order `O(x^n)`. # It is assumed that `h` has constant term 1. - void _fq_zech_poly_sqrt_series(fq_zech_struct * g, const fq_zech_struct * h, slong n, fq_zech_ctx_t ctx) + void _fq_zech_poly_sqrt_series(fq_zech_struct * g, const fq_zech_struct * h, slong n, fq_zech_ctx_t ctx) noexcept # Set the first `n` terms of `g` to the series expansion of `\sqrt{h}`. # It is assumed that `n > 0`, that `h` has constant term 1 and that `h` # is zero-padded as necessary to length `n`. Aliasing is not permitted. - void fq_zech_poly_sqrt_series(fq_zech_poly_t g, const fq_zech_poly_t h, slong n, fq_zech_ctx_t ctx) + void fq_zech_poly_sqrt_series(fq_zech_poly_t g, const fq_zech_poly_t h, slong n, fq_zech_ctx_t ctx) noexcept # Set `g` to the series expansion of `\sqrt{h}` to order `O(x^n)`. # It is assumed that `h` has constant term 1. - int _fq_zech_poly_sqrt(fq_zech_struct * s, const fq_zech_struct * p, slong n, fq_zech_ctx_t mod) + int _fq_zech_poly_sqrt(fq_zech_struct * s, const fq_zech_struct * p, slong n, fq_zech_ctx_t mod) noexcept # If ``(p, n)`` is a perfect square, sets ``(s, n / 2 + 1)`` # to a square root of `p` and returns 1. Otherwise returns 0. - int fq_zech_poly_sqrt(fq_zech_poly_t s, const fq_zech_poly_t p, fq_zech_ctx_t mod) + int fq_zech_poly_sqrt(fq_zech_poly_t s, const fq_zech_poly_t p, fq_zech_ctx_t mod) noexcept # If `p` is a perfect square, sets `s` to a square root of `p` # and returns 1. Otherwise returns 0. - void _fq_zech_poly_evaluate_fq_zech(fq_zech_t rop, const fq_zech_struct *op, slong len, const fq_zech_t a, const fq_zech_ctx_t ctx) + void _fq_zech_poly_evaluate_fq_zech(fq_zech_t rop, const fq_zech_struct *op, slong len, const fq_zech_t a, const fq_zech_ctx_t ctx) noexcept # Sets ``rop`` to ``(op, len)`` evaluated at `a`. # Supports zero padding. There are no restrictions on ``len``, that # is, ``len`` is allowed to be zero, too. - void fq_zech_poly_evaluate_fq_zech(fq_zech_t rop, const fq_zech_poly_t f, const fq_zech_t a, const fq_zech_ctx_t ctx) + void fq_zech_poly_evaluate_fq_zech(fq_zech_t rop, const fq_zech_poly_t f, const fq_zech_t a, const fq_zech_ctx_t ctx) noexcept # Sets ``rop`` to the value of `f(a)`. # As the coefficient ring `\mathbf{F}_q` is finite, Horner's method # is sufficient. - void _fq_zech_poly_compose(fq_zech_struct *rop, const fq_zech_struct *op1, slong len1, const fq_zech_struct *op2, slong len2, const fq_zech_ctx_t ctx) + void _fq_zech_poly_compose(fq_zech_struct *rop, const fq_zech_struct *op1, slong len1, const fq_zech_struct *op2, slong len2, const fq_zech_ctx_t ctx) noexcept # Sets ``rop`` to the composition of ``(op1, len1)`` and # ``(op2, len2)``. # Assumes that ``rop`` has space for ``(len1-1)*(len2-1) + 1`` @@ -832,24 +832,24 @@ cdef extern from "flint_wrap.h": # polynomials. Does not support aliasing between any of the inputs and # the output. - void fq_zech_poly_compose(fq_zech_poly_t rop, const fq_zech_poly_t op1, const fq_zech_poly_t op2, const fq_zech_ctx_t ctx) + void fq_zech_poly_compose(fq_zech_poly_t rop, const fq_zech_poly_t op1, const fq_zech_poly_t op2, const fq_zech_ctx_t ctx) noexcept # Sets ``rop`` to the composition of ``op1`` and ``op2``. # To be precise about the order of composition, denoting ``rop``, # ``op1``, and ``op2`` by `f`, `g`, and `h`, respectively, # sets `f(t) = g(h(t))`. - void _fq_zech_poly_compose_mod_horner(fq_zech_struct * res, const fq_zech_struct * f, slong lenf, const fq_zech_struct * g, const fq_zech_struct * h, slong lenh, const fq_zech_ctx_t ctx) + void _fq_zech_poly_compose_mod_horner(fq_zech_struct * res, const fq_zech_struct * f, slong lenf, const fq_zech_struct * g, const fq_zech_struct * h, slong lenh, const fq_zech_ctx_t ctx) noexcept # Sets ``res`` to the composition `f(g)` modulo `h`. We require that # `h` is nonzero and that the length of `g` is one less than the # length of `h` (possibly with zero padding). The output is not allowed # to be aliased with any of the inputs. # The algorithm used is Horner's rule. - void fq_zech_poly_compose_mod_horner(fq_zech_poly_t res, const fq_zech_poly_t f, const fq_zech_poly_t g, const fq_zech_poly_t h, const fq_zech_ctx_t ctx) + void fq_zech_poly_compose_mod_horner(fq_zech_poly_t res, const fq_zech_poly_t f, const fq_zech_poly_t g, const fq_zech_poly_t h, const fq_zech_ctx_t ctx) noexcept # Sets ``res`` to the composition `f(g)` modulo `h`. We require that # `h` is nonzero. The algorithm used is Horner's rule. - void _fq_zech_poly_compose_mod_horner_preinv(fq_zech_struct * res, const fq_zech_struct * f, slong lenf, const fq_zech_struct * g, const fq_zech_struct * h, slong lenh, const fq_zech_struct * hinv, slong lenhiv, const fq_zech_ctx_t ctx) + void _fq_zech_poly_compose_mod_horner_preinv(fq_zech_struct * res, const fq_zech_struct * f, slong lenf, const fq_zech_struct * g, const fq_zech_struct * h, slong lenh, const fq_zech_struct * hinv, slong lenhiv, const fq_zech_ctx_t ctx) noexcept # Sets ``res`` to the composition `f(g)` modulo `h`. We require # that `h` is nonzero and that the length of `g` is one less than # the length of `h` (possibly with zero padding). We also require @@ -859,13 +859,13 @@ cdef extern from "flint_wrap.h": # any of the inputs. # The algorithm used is Horner's rule. - void fq_zech_poly_compose_mod_horner_preinv(fq_zech_poly_t res, const fq_zech_poly_t f, const fq_zech_poly_t g, const fq_zech_poly_t h, const fq_zech_poly_t hinv, const fq_zech_ctx_t ctx) + void fq_zech_poly_compose_mod_horner_preinv(fq_zech_poly_t res, const fq_zech_poly_t f, const fq_zech_poly_t g, const fq_zech_poly_t h, const fq_zech_poly_t hinv, const fq_zech_ctx_t ctx) noexcept # Sets ``res`` to the composition `f(g)` modulo `h`. We require # that `h` is nonzero and that `f` has smaller degree than # `h`. Furthermore, we require ``hinv`` to be the inverse of the # reverse of ``h``. The algorithm used is Horner's rule. - void _fq_zech_poly_compose_mod_brent_kung(fq_zech_struct * res, const fq_zech_struct * f, slong lenf, const fq_zech_struct * g, const fq_zech_struct * h, slong lenh, const fq_zech_ctx_t ctx) + void _fq_zech_poly_compose_mod_brent_kung(fq_zech_struct * res, const fq_zech_struct * f, slong lenf, const fq_zech_struct * g, const fq_zech_struct * h, slong lenh, const fq_zech_ctx_t ctx) noexcept # Sets ``res`` to the composition `f(g)` modulo `h`. We require # that `h` is nonzero and that the length of `g` is one less than # the length of `h` (possibly with zero padding). We also require @@ -873,12 +873,12 @@ cdef extern from "flint_wrap.h": # is not allowed to be aliased with any of the inputs. # The algorithm used is the Brent-Kung matrix algorithm. - void fq_zech_poly_compose_mod_brent_kung(fq_zech_poly_t res, const fq_zech_poly_t f, const fq_zech_poly_t g, const fq_zech_poly_t h, const fq_zech_ctx_t ctx) + void fq_zech_poly_compose_mod_brent_kung(fq_zech_poly_t res, const fq_zech_poly_t f, const fq_zech_poly_t g, const fq_zech_poly_t h, const fq_zech_ctx_t ctx) noexcept # Sets ``res`` to the composition `f(g)` modulo `h`. We require # that `h` is nonzero and that `f` has smaller degree than `h`. The # algorithm used is the Brent-Kung matrix algorithm. - void _fq_zech_poly_compose_mod_brent_kung_preinv(fq_zech_struct * res, const fq_zech_struct * f, slong lenf, const fq_zech_struct * g, const fq_zech_struct * h, slong lenh, const fq_zech_struct * hinv, slong lenhiv, const fq_zech_ctx_t ctx) + void _fq_zech_poly_compose_mod_brent_kung_preinv(fq_zech_struct * res, const fq_zech_struct * f, slong lenf, const fq_zech_struct * g, const fq_zech_struct * h, slong lenh, const fq_zech_struct * hinv, slong lenhiv, const fq_zech_ctx_t ctx) noexcept # Sets ``res`` to the composition `f(g)` modulo `h`. We require # that `h` is nonzero and that the length of `g` is one less than # the length of `h` (possibly with zero padding). We also require @@ -888,24 +888,24 @@ cdef extern from "flint_wrap.h": # any of the inputs. # The algorithm used is the Brent-Kung matrix algorithm. - void fq_zech_poly_compose_mod_brent_kung_preinv(fq_zech_poly_t res, const fq_zech_poly_t f, const fq_zech_poly_t g, const fq_zech_poly_t h, const fq_zech_poly_t hinv, const fq_zech_ctx_t ctx) + void fq_zech_poly_compose_mod_brent_kung_preinv(fq_zech_poly_t res, const fq_zech_poly_t f, const fq_zech_poly_t g, const fq_zech_poly_t h, const fq_zech_poly_t hinv, const fq_zech_ctx_t ctx) noexcept # Sets ``res`` to the composition `f(g)` modulo `h`. We require # that `h` is nonzero and that `f` has smaller degree than # `h`. Furthermore, we require ``hinv`` to be the inverse of the # reverse of ``h``. The algorithm used is the Brent-Kung matrix # algorithm. - void _fq_zech_poly_compose_mod(fq_zech_struct * res, const fq_zech_struct * f, slong lenf, const fq_zech_struct * g, const fq_zech_struct * h, slong lenh, const fq_zech_ctx_t ctx) + void _fq_zech_poly_compose_mod(fq_zech_struct * res, const fq_zech_struct * f, slong lenf, const fq_zech_struct * g, const fq_zech_struct * h, slong lenh, const fq_zech_ctx_t ctx) noexcept # Sets ``res`` to the composition `f(g)` modulo `h`. We require # that `h` is nonzero and that the length of `g` is one less than # the length of `h` (possibly with zero padding). The output is not # allowed to be aliased with any of the inputs. - void fq_zech_poly_compose_mod(fq_zech_poly_t res, const fq_zech_poly_t f, const fq_zech_poly_t g, const fq_zech_poly_t h, const fq_zech_ctx_t ctx) + void fq_zech_poly_compose_mod(fq_zech_poly_t res, const fq_zech_poly_t f, const fq_zech_poly_t g, const fq_zech_poly_t h, const fq_zech_ctx_t ctx) noexcept # Sets ``res`` to the composition `f(g)` modulo `h`. We require # that `h` is nonzero. - void _fq_zech_poly_compose_mod_preinv(fq_zech_struct * res, const fq_zech_struct * f, slong lenf, const fq_zech_struct * g, const fq_zech_struct * h, slong lenh, const fq_zech_struct * hinv, slong lenhiv, const fq_zech_ctx_t ctx) + void _fq_zech_poly_compose_mod_preinv(fq_zech_struct * res, const fq_zech_struct * f, slong lenf, const fq_zech_struct * g, const fq_zech_struct * h, slong lenh, const fq_zech_struct * hinv, slong lenhiv, const fq_zech_ctx_t ctx) noexcept # Sets ``res`` to the composition `f(g)` modulo `h`. We require # that `h` is nonzero and that the length of `g` is one less than # the length of `h` (possibly with zero padding). We also require @@ -914,30 +914,30 @@ cdef extern from "flint_wrap.h": # reverse of ``h``. The output is not allowed to be aliased with # any of the inputs. - void fq_zech_poly_compose_mod_preinv(fq_zech_poly_t res, const fq_zech_poly_t f, const fq_zech_poly_t g, const fq_zech_poly_t h, const fq_zech_poly_t hinv, const fq_zech_ctx_t ctx) + void fq_zech_poly_compose_mod_preinv(fq_zech_poly_t res, const fq_zech_poly_t f, const fq_zech_poly_t g, const fq_zech_poly_t h, const fq_zech_poly_t hinv, const fq_zech_ctx_t ctx) noexcept # Sets ``res`` to the composition `f(g)` modulo `h`. We require # that `h` is nonzero and that `f` has smaller degree than # `h`. Furthermore, we require ``hinv`` to be the inverse of the # reverse of ``h``. - void _fq_zech_poly_reduce_matrix_mod_poly (fq_zech_mat_t A, const fq_zech_mat_t B, const fq_zech_poly_t f, const fq_zech_ctx_t ctx) + void _fq_zech_poly_reduce_matrix_mod_poly (fq_zech_mat_t A, const fq_zech_mat_t B, const fq_zech_poly_t f, const fq_zech_ctx_t ctx) noexcept # Sets the ith row of ``A`` to the reduction of the ith row of `B` modulo # `f` for `i=1,\ldots,\sqrt{\deg(f)}`. We require `B` to be at least # a `\sqrt{\deg(f)}\times \deg(f)` matrix and `f` to be nonzero. - void _fq_zech_poly_precompute_matrix (fq_zech_mat_t A, const fq_zech_struct* f, const fq_zech_struct* g, slong leng, const fq_zech_struct* ginv, slong lenginv, const fq_zech_ctx_t ctx) + void _fq_zech_poly_precompute_matrix (fq_zech_mat_t A, const fq_zech_struct* f, const fq_zech_struct* g, slong leng, const fq_zech_struct* ginv, slong lenginv, const fq_zech_ctx_t ctx) noexcept # Sets the ith row of ``A`` to `f^i` modulo `g` for # `i=1,\ldots,\sqrt{\deg(g)}`. We require `A` to be a # `\sqrt{\deg(g)}\times \deg(g)` matrix. We require ``ginv`` to # be the inverse of the reverse of ``g`` and `g` to be nonzero. - void fq_zech_poly_precompute_matrix (fq_zech_mat_t A, const fq_zech_poly_t f, const fq_zech_poly_t g, const fq_zech_poly_t ginv, const fq_zech_ctx_t ctx) + void fq_zech_poly_precompute_matrix (fq_zech_mat_t A, const fq_zech_poly_t f, const fq_zech_poly_t g, const fq_zech_poly_t ginv, const fq_zech_ctx_t ctx) noexcept # Sets the ith row of ``A`` to `f^i` modulo `g` for # `i=1,\ldots,\sqrt{\deg(g)}`. We require `A` to be a # `\sqrt{\deg(g)}\times \deg(g)` matrix. We require ``ginv`` to # be the inverse of the reverse of ``g``. - void _fq_zech_poly_compose_mod_brent_kung_precomp_preinv(fq_zech_struct* res, const fq_zech_struct* f, slong lenf, const fq_zech_mat_t A, const fq_zech_struct* h, slong lenh, const fq_zech_struct* hinv, slong lenhinv, const fq_zech_ctx_t ctx) + void _fq_zech_poly_compose_mod_brent_kung_precomp_preinv(fq_zech_struct* res, const fq_zech_struct* f, slong lenf, const fq_zech_mat_t A, const fq_zech_struct* h, slong lenh, const fq_zech_struct* hinv, slong lenhinv, const fq_zech_ctx_t ctx) noexcept # Sets ``res`` to the composition `f(g)` modulo `h`. We require # that `h` is nonzero. We require that the ith row of `A` contains # `g^i` for `i=1,\ldots,\sqrt{\deg(h)}`, i.e. `A` is a @@ -947,7 +947,7 @@ cdef extern from "flint_wrap.h": # The output is not allowed to be aliased with any of the inputs. # The algorithm used is the Brent-Kung matrix algorithm. - void fq_zech_poly_compose_mod_brent_kung_precomp_preinv(fq_zech_poly_t res, const fq_zech_poly_t f, const fq_zech_mat_t A, const fq_zech_poly_t h, const fq_zech_poly_t hinv, const fq_zech_ctx_t ctx) + void fq_zech_poly_compose_mod_brent_kung_precomp_preinv(fq_zech_poly_t res, const fq_zech_poly_t f, const fq_zech_mat_t A, const fq_zech_poly_t h, const fq_zech_poly_t hinv, const fq_zech_ctx_t ctx) noexcept # Sets ``res`` to the composition `f(g)` modulo `h`. We require # that the ith row of `A` contains `g^i` for # `i=1,\ldots,\sqrt{\deg(h)}`, i.e. `A` is a `\sqrt{\deg(h)}\times @@ -958,79 +958,79 @@ cdef extern from "flint_wrap.h": # several modular composition of the form `f(g)` modulo `h` for # fixed `g` and `h`. - int _fq_zech_poly_fprint_pretty(FILE *file, const fq_zech_struct *poly, slong len, const char *x, const fq_zech_ctx_t ctx) + int _fq_zech_poly_fprint_pretty(FILE *file, const fq_zech_struct *poly, slong len, const char *x, const fq_zech_ctx_t ctx) noexcept # Prints the pretty representation of ``(poly, len)`` to the stream # ``file``, using the string ``x`` to represent the indeterminate. # In case of success, returns a positive value. In case of failure, # returns a non-positive value. - int fq_zech_poly_fprint_pretty(FILE * file, const fq_zech_poly_t poly, const char *x, const fq_zech_ctx_t ctx) + int fq_zech_poly_fprint_pretty(FILE * file, const fq_zech_poly_t poly, const char *x, const fq_zech_ctx_t ctx) noexcept # Prints the pretty representation of ``poly`` to the stream # ``file``, using the string ``x`` to represent the indeterminate. # In case of success, returns a positive value. In case of failure, # returns a non-positive value. - int _fq_zech_poly_print_pretty(const fq_zech_struct *poly, slong len, const char *x, const fq_zech_ctx_t ctx) + int _fq_zech_poly_print_pretty(const fq_zech_struct *poly, slong len, const char *x, const fq_zech_ctx_t ctx) noexcept # Prints the pretty representation of ``(poly, len)`` to ``stdout``, # using the string ``x`` to represent the indeterminate. # In case of success, returns a positive value. In case of failure, # returns a non-positive value. - int fq_zech_poly_print_pretty(const fq_zech_poly_t poly, const char *x, const fq_zech_ctx_t ctx) + int fq_zech_poly_print_pretty(const fq_zech_poly_t poly, const char *x, const fq_zech_ctx_t ctx) noexcept # Prints the pretty representation of ``poly`` to ``stdout``, # using the string ``x`` to represent the indeterminate. # In case of success, returns a positive value. In case of failure, # returns a non-positive value. - int _fq_zech_poly_fprint(FILE *file, const fq_zech_struct *poly, slong len, const fq_zech_ctx_t ctx) + int _fq_zech_poly_fprint(FILE *file, const fq_zech_struct *poly, slong len, const fq_zech_ctx_t ctx) noexcept # Prints the pretty representation of ``(poly, len)`` to the stream # ``file``. # In case of success, returns a positive value. In case of failure, # returns a non-positive value. - int fq_zech_poly_fprint(FILE * file, const fq_zech_poly_t poly, const fq_zech_ctx_t ctx) + int fq_zech_poly_fprint(FILE * file, const fq_zech_poly_t poly, const fq_zech_ctx_t ctx) noexcept # Prints the pretty representation of ``poly`` to the stream # ``file``. # In case of success, returns a positive value. In case of failure, # returns a non-positive value. - int _fq_zech_poly_print(const fq_zech_struct *poly, slong len, const fq_zech_ctx_t ctx) + int _fq_zech_poly_print(const fq_zech_struct *poly, slong len, const fq_zech_ctx_t ctx) noexcept # Prints the pretty representation of ``(poly, len)`` to ``stdout``. # In case of success, returns a positive value. In case of failure, # returns a non-positive value. - int fq_zech_poly_print(const fq_zech_poly_t poly, const fq_zech_ctx_t ctx) + int fq_zech_poly_print(const fq_zech_poly_t poly, const fq_zech_ctx_t ctx) noexcept # Prints the representation of ``poly`` to ``stdout``. # In case of success, returns a positive value. In case of failure, # returns a non-positive value. - char * _fq_zech_poly_get_str(const fq_zech_struct * poly, slong len, const fq_zech_ctx_t ctx) + char * _fq_zech_poly_get_str(const fq_zech_struct * poly, slong len, const fq_zech_ctx_t ctx) noexcept # Returns the plain FLINT string representation of the polynomial # ``(poly, len)``. - char * fq_zech_poly_get_str(const fq_zech_poly_t poly, const fq_zech_ctx_t ctx) + char * fq_zech_poly_get_str(const fq_zech_poly_t poly, const fq_zech_ctx_t ctx) noexcept # Returns the plain FLINT string representation of the polynomial # ``poly``. - char * _fq_zech_poly_get_str_pretty(const fq_zech_struct * poly, slong len, const char * x, const fq_zech_ctx_t ctx) + char * _fq_zech_poly_get_str_pretty(const fq_zech_struct * poly, slong len, const char * x, const fq_zech_ctx_t ctx) noexcept # Returns a pretty representation of the polynomial # ``(poly, len)`` using the null-terminated string ``x`` as the # variable name. - char * fq_zech_poly_get_str_pretty(const fq_zech_poly_t poly, const char * x, const fq_zech_ctx_t ctx) + char * fq_zech_poly_get_str_pretty(const fq_zech_poly_t poly, const char * x, const fq_zech_ctx_t ctx) noexcept # Returns a pretty representation of the polynomial ``poly`` using the # null-terminated string ``x`` as the variable name - void fq_zech_poly_inflate(fq_zech_poly_t result, const fq_zech_poly_t input, ulong inflation, const fq_zech_ctx_t ctx) + void fq_zech_poly_inflate(fq_zech_poly_t result, const fq_zech_poly_t input, ulong inflation, const fq_zech_ctx_t ctx) noexcept # Sets ``result`` to the inflated polynomial `p(x^n)` where # `p` is given by ``input`` and `n` is given by ``inflation``. - void fq_zech_poly_deflate(fq_zech_poly_t result, const fq_zech_poly_t input, ulong deflation, const fq_zech_ctx_t ctx) + void fq_zech_poly_deflate(fq_zech_poly_t result, const fq_zech_poly_t input, ulong deflation, const fq_zech_ctx_t ctx) noexcept # Sets ``result`` to the deflated polynomial `p(x^{1/n})` where # `p` is given by ``input`` and `n` is given by ``deflation``. # Requires `n > 0`. - ulong fq_zech_poly_deflation(const fq_zech_poly_t input, const fq_zech_ctx_t ctx) + ulong fq_zech_poly_deflation(const fq_zech_poly_t input, const fq_zech_ctx_t ctx) noexcept # Returns the largest integer by which ``input`` can be deflated. # As special cases, returns 0 if ``input`` is the zero polynomial # and 1 of ``input`` is a constant polynomial. diff --git a/src/sage/libs/flint/fq_zech_poly_factor.pxd b/src/sage/libs/flint/fq_zech_poly_factor.pxd index 362f7556338..8258c7ad359 100644 --- a/src/sage/libs/flint/fq_zech_poly_factor.pxd +++ b/src/sage/libs/flint/fq_zech_poly_factor.pxd @@ -12,91 +12,91 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void fq_zech_poly_factor_init(fq_zech_poly_factor_t fac, const fq_zech_ctx_t ctx) + void fq_zech_poly_factor_init(fq_zech_poly_factor_t fac, const fq_zech_ctx_t ctx) noexcept # Initialises ``fac`` for use. An ``fq_zech_poly_factor_t`` # represents a polynomial in factorised form as a product of # polynomials with associated exponents. - void fq_zech_poly_factor_clear(fq_zech_poly_factor_t fac, const fq_zech_ctx_t ctx) + void fq_zech_poly_factor_clear(fq_zech_poly_factor_t fac, const fq_zech_ctx_t ctx) noexcept # Frees all memory associated with ``fac``. - void fq_zech_poly_factor_realloc(fq_zech_poly_factor_t fac, slong alloc, const fq_zech_ctx_t ctx) + void fq_zech_poly_factor_realloc(fq_zech_poly_factor_t fac, slong alloc, const fq_zech_ctx_t ctx) noexcept # Reallocates the factor structure to provide space for # precisely ``alloc`` factors. - void fq_zech_poly_factor_fit_length(fq_zech_poly_factor_t fac, slong len, const fq_zech_ctx_t ctx) + void fq_zech_poly_factor_fit_length(fq_zech_poly_factor_t fac, slong len, const fq_zech_ctx_t ctx) noexcept # Ensures that the factor structure has space for at least # ``len`` factors. This function takes care of the case of # repeated calls by always at least doubling the number of factors # the structure can hold. - void fq_zech_poly_factor_set(fq_zech_poly_factor_t res, const fq_zech_poly_factor_t fac, const fq_zech_ctx_t ctx) + void fq_zech_poly_factor_set(fq_zech_poly_factor_t res, const fq_zech_poly_factor_t fac, const fq_zech_ctx_t ctx) noexcept # Sets ``res`` to the same factorisation as ``fac``. - void fq_zech_poly_factor_print_pretty(const fq_zech_poly_factor_t fac, const char *var, const fq_zech_ctx_t ctx) + void fq_zech_poly_factor_print_pretty(const fq_zech_poly_factor_t fac, const char *var, const fq_zech_ctx_t ctx) noexcept # Pretty-prints the entries of ``fac`` to standard output. - void fq_zech_poly_factor_print(const fq_zech_poly_factor_t fac, const fq_zech_ctx_t ctx) + void fq_zech_poly_factor_print(const fq_zech_poly_factor_t fac, const fq_zech_ctx_t ctx) noexcept # Prints the entries of ``fac`` to standard output. - void fq_zech_poly_factor_insert(fq_zech_poly_factor_t fac, const fq_zech_poly_t poly, slong exp, const fq_zech_ctx_t ctx) + void fq_zech_poly_factor_insert(fq_zech_poly_factor_t fac, const fq_zech_poly_t poly, slong exp, const fq_zech_ctx_t ctx) noexcept # Inserts the factor ``poly`` with multiplicity ``exp`` into # the factorisation ``fac``. # If ``fac`` already contains ``poly``, then ``exp`` simply # gets added to the exponent of the existing entry. - void fq_zech_poly_factor_concat(fq_zech_poly_factor_t res, const fq_zech_poly_factor_t fac, const fq_zech_ctx_t ctx) + void fq_zech_poly_factor_concat(fq_zech_poly_factor_t res, const fq_zech_poly_factor_t fac, const fq_zech_ctx_t ctx) noexcept # Concatenates two factorisations. # This is equivalent to calling ``fq_zech_poly_factor_insert()`` # repeatedly with the individual factors of ``fac``. # Does not support aliasing between ``res`` and ``fac``. - void fq_zech_poly_factor_pow(fq_zech_poly_factor_t fac, slong exp, const fq_zech_ctx_t ctx) + void fq_zech_poly_factor_pow(fq_zech_poly_factor_t fac, slong exp, const fq_zech_ctx_t ctx) noexcept # Raises ``fac`` to the power ``exp``. - ulong fq_zech_poly_remove(fq_zech_poly_t f, const fq_zech_poly_t p, const fq_zech_ctx_t ctx) + ulong fq_zech_poly_remove(fq_zech_poly_t f, const fq_zech_poly_t p, const fq_zech_ctx_t ctx) noexcept # Removes the highest possible power of ``p`` from ``f`` and # returns the exponent. - bint fq_zech_poly_is_irreducible(const fq_zech_poly_t f, const fq_zech_ctx_t ctx) + bint fq_zech_poly_is_irreducible(const fq_zech_poly_t f, const fq_zech_ctx_t ctx) noexcept # Returns 1 if the polynomial ``f`` is irreducible, otherwise returns 0. - bint fq_zech_poly_is_irreducible_ddf(const fq_zech_poly_t f, const fq_zech_ctx_t ctx) + bint fq_zech_poly_is_irreducible_ddf(const fq_zech_poly_t f, const fq_zech_ctx_t ctx) noexcept # Returns 1 if the polynomial ``f`` is irreducible, otherwise returns 0. # Uses fast distinct-degree factorisation. - bint fq_zech_poly_is_irreducible_ben_or(const fq_zech_poly_t f, const fq_zech_ctx_t ctx) + bint fq_zech_poly_is_irreducible_ben_or(const fq_zech_poly_t f, const fq_zech_ctx_t ctx) noexcept # Returns 1 if the polynomial ``f`` is irreducible, otherwise returns 0. # Uses Ben-Or's irreducibility test. - bint _fq_zech_poly_is_squarefree(const fq_zech_struct * f, slong len, const fq_zech_ctx_t ctx) + bint _fq_zech_poly_is_squarefree(const fq_zech_struct * f, slong len, const fq_zech_ctx_t ctx) noexcept # Returns 1 if ``(f, len)`` is squarefree, and 0 otherwise. As a # special case, the zero polynomial is not considered squarefree. # There are no restrictions on the length. - bint fq_zech_poly_is_squarefree(const fq_zech_poly_t f, const fq_zech_ctx_t ctx) + bint fq_zech_poly_is_squarefree(const fq_zech_poly_t f, const fq_zech_ctx_t ctx) noexcept # Returns 1 if ``f`` is squarefree, and 0 otherwise. As a special # case, the zero polynomial is not considered squarefree. - bint fq_zech_poly_factor_equal_deg_prob(fq_zech_poly_t factor, flint_rand_t state, const fq_zech_poly_t pol, slong d, const fq_zech_ctx_t ctx) + bint fq_zech_poly_factor_equal_deg_prob(fq_zech_poly_t factor, flint_rand_t state, const fq_zech_poly_t pol, slong d, const fq_zech_ctx_t ctx) noexcept # Probabilistic equal degree factorisation of ``pol`` into # irreducible factors of degree ``d``. If it passes, a factor is # placed in factor and 1 is returned, otherwise 0 is returned and # the value of factor is undetermined. # Requires that ``pol`` be monic, non-constant and squarefree. - void fq_zech_poly_factor_equal_deg(fq_zech_poly_factor_t factors, const fq_zech_poly_t pol, slong d, const fq_zech_ctx_t ctx) + void fq_zech_poly_factor_equal_deg(fq_zech_poly_factor_t factors, const fq_zech_poly_t pol, slong d, const fq_zech_ctx_t ctx) noexcept # Assuming ``pol`` is a product of irreducible factors all of # degree ``d``, finds all those factors and places them in # factors. Requires that ``pol`` be monic, non-constant and # squarefree. - void fq_zech_poly_factor_split_single(fq_zech_poly_t linfactor, const fq_zech_poly_t input, const fq_zech_ctx_t ctx) + void fq_zech_poly_factor_split_single(fq_zech_poly_t linfactor, const fq_zech_poly_t input, const fq_zech_ctx_t ctx) noexcept # Assuming ``input`` is a product of factors all of degree 1, finds a single # linear factor of ``input`` and places it in ``linfactor``. # Requires that ``input`` be monic and non-constant. - void fq_zech_poly_factor_distinct_deg(fq_zech_poly_factor_t res, const fq_zech_poly_t poly, slong * const *degs, const fq_zech_ctx_t ctx) + void fq_zech_poly_factor_distinct_deg(fq_zech_poly_factor_t res, const fq_zech_poly_t poly, slong * const *degs, const fq_zech_ctx_t ctx) noexcept # Factorises a monic non-constant squarefree polynomial ``poly`` # of degree `n` into factors `f[d]` such that for `1 \leq d \leq n` # `f[d]` is the product of the monic irreducible factors of @@ -106,31 +106,31 @@ cdef extern from "flint_wrap.h": # Requires that ``degs`` have enough space for irreducible polynomials' # powers (maximum space required is `n * sizeof(slong)`). - void fq_zech_poly_factor_squarefree(fq_zech_poly_factor_t res, const fq_zech_poly_t f, const fq_zech_ctx_t ctx) + void fq_zech_poly_factor_squarefree(fq_zech_poly_factor_t res, const fq_zech_poly_t f, const fq_zech_ctx_t ctx) noexcept # Sets ``res`` to a squarefree factorization of ``f``. - void fq_zech_poly_factor(fq_zech_poly_factor_t res, fq_zech_t lead, const fq_zech_poly_t f, const fq_zech_ctx_t ctx) + void fq_zech_poly_factor(fq_zech_poly_factor_t res, fq_zech_t lead, const fq_zech_poly_t f, const fq_zech_ctx_t ctx) noexcept # Factorises a non-constant polynomial ``f`` into monic # irreducible factors choosing the best algorithm for given modulo # and degree. The output ``lead`` is set to the leading coefficient of `f` # upon return. Choice of algorithm is based on heuristic measurements. - void fq_zech_poly_factor_cantor_zassenhaus(fq_zech_poly_factor_t res, const fq_zech_poly_t f, const fq_zech_ctx_t ctx) + void fq_zech_poly_factor_cantor_zassenhaus(fq_zech_poly_factor_t res, const fq_zech_poly_t f, const fq_zech_ctx_t ctx) noexcept # Factorises a non-constant polynomial ``f`` into monic # irreducible factors using the Cantor-Zassenhaus algorithm. - void fq_zech_poly_factor_kaltofen_shoup(fq_zech_poly_factor_t res, const fq_zech_poly_t poly, const fq_zech_ctx_t ctx) + void fq_zech_poly_factor_kaltofen_shoup(fq_zech_poly_factor_t res, const fq_zech_poly_t poly, const fq_zech_ctx_t ctx) noexcept # Factorises a non-constant polynomial ``f`` into monic # irreducible factors using the fast version of Cantor-Zassenhaus # algorithm proposed by Kaltofen and Shoup (1998). More precisely # this algorithm uses a “baby step/giant step” strategy for the # distinct-degree factorization step. - void fq_zech_poly_factor_berlekamp(fq_zech_poly_factor_t factors, const fq_zech_poly_t f, const fq_zech_ctx_t ctx) + void fq_zech_poly_factor_berlekamp(fq_zech_poly_factor_t factors, const fq_zech_poly_t f, const fq_zech_ctx_t ctx) noexcept # Factorises a non-constant polynomial ``f`` into monic # irreducible factors using the Berlekamp algorithm. - void fq_zech_poly_factor_with_berlekamp(fq_zech_poly_factor_t res, fq_zech_t leading_coeff, const fq_zech_poly_t f, const fq_zech_ctx_t ctx) + void fq_zech_poly_factor_with_berlekamp(fq_zech_poly_factor_t res, fq_zech_t leading_coeff, const fq_zech_poly_t f, const fq_zech_ctx_t ctx) noexcept # Factorises a general polynomial ``f`` into monic irreducible # factors and sets ``leading_coeff`` to the leading coefficient # of ``f``, or 0 if ``f`` is the zero polynomial. @@ -139,7 +139,7 @@ cdef extern from "flint_wrap.h": # performs a square-free factorisation, and finally runs Berlekamp # on all the individual square-free factors. - void fq_zech_poly_factor_with_cantor_zassenhaus(fq_zech_poly_factor_t res, fq_zech_t leading_coeff, const fq_zech_poly_t f, const fq_zech_ctx_t ctx) + void fq_zech_poly_factor_with_cantor_zassenhaus(fq_zech_poly_factor_t res, fq_zech_t leading_coeff, const fq_zech_poly_t f, const fq_zech_ctx_t ctx) noexcept # Factorises a general polynomial ``f`` into monic irreducible # factors and sets ``leading_coeff`` to the leading coefficient # of ``f``, or 0 if ``f`` is the zero polynomial. @@ -148,7 +148,7 @@ cdef extern from "flint_wrap.h": # performs a square-free factorisation, and finally runs # Cantor-Zassenhaus on all the individual square-free factors. - void fq_zech_poly_factor_with_kaltofen_shoup(fq_zech_poly_factor_t res, fq_zech_t leading_coeff, const fq_zech_poly_t f, const fq_zech_ctx_t ctx) + void fq_zech_poly_factor_with_kaltofen_shoup(fq_zech_poly_factor_t res, fq_zech_t leading_coeff, const fq_zech_poly_t f, const fq_zech_ctx_t ctx) noexcept # Factorises a general polynomial ``f`` into monic irreducible # factors and sets ``leading_coeff`` to the leading coefficient # of ``f``, or 0 if ``f`` is the zero polynomial. @@ -157,12 +157,12 @@ cdef extern from "flint_wrap.h": # performs a square-free factorisation, and finally runs # Kaltofen-Shoup on all the individual square-free factors. - void fq_zech_poly_iterated_frobenius_preinv(fq_zech_poly_t *rop, slong n, const fq_zech_poly_t v, const fq_zech_poly_t vinv, const fq_zech_ctx_t ctx) + void fq_zech_poly_iterated_frobenius_preinv(fq_zech_poly_t *rop, slong n, const fq_zech_poly_t v, const fq_zech_poly_t vinv, const fq_zech_ctx_t ctx) noexcept # Sets ``rop[i]`` to be `x^{q^i} \bmod v` for `0 \le i < n`. # It is required that ``vinv`` is the inverse of the reverse of # ``v`` mod ``x^lenv``. - void fq_zech_poly_roots(fq_zech_poly_factor_t r, const fq_zech_poly_t f, int with_multiplicity, const fq_zech_ctx_t ctx) + void fq_zech_poly_roots(fq_zech_poly_factor_t r, const fq_zech_poly_t f, int with_multiplicity, const fq_zech_ctx_t ctx) noexcept # Fill `r` with factors of the form `x - r_i` where the `r_i` are the distinct roots of a nonzero `f` in `F_q`. # If `with\_multiplicity` is zero, the exponent `e_i` of the factor `x - r_i` is `1`. Otherwise, it is the largest `e_i` such that `(x-r_i)^e_i` divides `f`. # This function throws if `f` is zero, but is otherwise always successful. diff --git a/src/sage/libs/flint/fq_zech_vec.pxd b/src/sage/libs/flint/fq_zech_vec.pxd index cfe0f2c5770..447a626e6ec 100644 --- a/src/sage/libs/flint/fq_zech_vec.pxd +++ b/src/sage/libs/flint/fq_zech_vec.pxd @@ -12,62 +12,62 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - fq_zech_struct * _fq_zech_vec_init(slong len, const fq_zech_ctx_t ctx) + fq_zech_struct * _fq_zech_vec_init(slong len, const fq_zech_ctx_t ctx) noexcept # Returns an initialised vector of ``fq_zech``'s of given length. - void _fq_zech_vec_clear(fq_zech_struct * vec, slong len, const fq_zech_ctx_t ctx) + void _fq_zech_vec_clear(fq_zech_struct * vec, slong len, const fq_zech_ctx_t ctx) noexcept # Clears the entries of ``(vec, len)`` and frees the space allocated # for ``vec``. - void _fq_zech_vec_randtest(fq_zech_struct * f, flint_rand_t state, slong len, const fq_zech_ctx_t ctx) + void _fq_zech_vec_randtest(fq_zech_struct * f, flint_rand_t state, slong len, const fq_zech_ctx_t ctx) noexcept # Sets the entries of a vector of the given length to elements of # the finite field. - int _fq_zech_vec_fprint(FILE * file, const fq_zech_struct * vec, slong len, const fq_zech_ctx_t ctx) + int _fq_zech_vec_fprint(FILE * file, const fq_zech_struct * vec, slong len, const fq_zech_ctx_t ctx) noexcept # Prints the vector of given length to the stream ``file``. The # format is the length followed by two spaces, then a space separated # list of coefficients. If the length is zero, only `0` is printed. # In case of success, returns a positive value. In case of failure, # returns a non-positive value. - int _fq_zech_vec_print(const fq_zech_struct * vec, slong len, const fq_zech_ctx_t ctx) + int _fq_zech_vec_print(const fq_zech_struct * vec, slong len, const fq_zech_ctx_t ctx) noexcept # Prints the vector of given length to ``stdout``. # For further details, see ``_fq_zech_vec_fprint()``. - void _fq_zech_vec_set(fq_zech_struct * vec1, const fq_zech_struct * vec2, slong len2, const fq_zech_ctx_t ctx) + void _fq_zech_vec_set(fq_zech_struct * vec1, const fq_zech_struct * vec2, slong len2, const fq_zech_ctx_t ctx) noexcept # Makes a copy of ``(vec2, len2)`` into ``vec1``. - void _fq_zech_vec_swap(fq_zech_struct * vec1, fq_zech_struct * vec2, slong len2, const fq_zech_ctx_t ctx) + void _fq_zech_vec_swap(fq_zech_struct * vec1, fq_zech_struct * vec2, slong len2, const fq_zech_ctx_t ctx) noexcept # Swaps the elements in ``(vec1, len2)`` and ``(vec2, len2)``. - void _fq_zech_vec_zero(fq_zech_struct * vec, slong len, const fq_zech_ctx_t ctx) + void _fq_zech_vec_zero(fq_zech_struct * vec, slong len, const fq_zech_ctx_t ctx) noexcept # Zeros the entries of ``(vec, len)``. - void _fq_zech_vec_neg(fq_zech_struct * vec1, const fq_zech_struct * vec2, slong len2, const fq_zech_ctx_t ctx) + void _fq_zech_vec_neg(fq_zech_struct * vec1, const fq_zech_struct * vec2, slong len2, const fq_zech_ctx_t ctx) noexcept # Negates ``(vec2, len2)`` and places it into ``vec1``. - bint _fq_zech_vec_equal(const fq_zech_struct * vec1, const fq_zech_struct * vec2, slong len, const fq_zech_ctx_t ctx) + bint _fq_zech_vec_equal(const fq_zech_struct * vec1, const fq_zech_struct * vec2, slong len, const fq_zech_ctx_t ctx) noexcept # Compares two vectors of the given length and returns `1` if they are # equal, otherwise returns `0`. - bint _fq_zech_vec_is_zero(const fq_zech_struct * vec, slong len, const fq_zech_ctx_t ctx) + bint _fq_zech_vec_is_zero(const fq_zech_struct * vec, slong len, const fq_zech_ctx_t ctx) noexcept # Returns `1` if ``(vec, len)`` is zero, and `0` otherwise. - void _fq_zech_vec_add(fq_zech_struct * res, const fq_zech_struct * vec1, const fq_zech_struct * vec2, slong len2, const fq_zech_ctx_t ctx) + void _fq_zech_vec_add(fq_zech_struct * res, const fq_zech_struct * vec1, const fq_zech_struct * vec2, slong len2, const fq_zech_ctx_t ctx) noexcept # Sets ``(res, len2)`` to the sum of ``(vec1, len2)`` # and ``(vec2, len2)``. - void _fq_zech_vec_sub(fq_zech_struct * res, const fq_zech_struct * vec1, const fq_zech_struct * vec2, slong len2, const fq_zech_ctx_t ctx) + void _fq_zech_vec_sub(fq_zech_struct * res, const fq_zech_struct * vec1, const fq_zech_struct * vec2, slong len2, const fq_zech_ctx_t ctx) noexcept # Sets ``(res, len2)`` to ``(vec1, len2)`` minus ``(vec2, len2)``. - void _fq_zech_vec_scalar_addmul_fq_zech(fq_zech_struct * vec1, const fq_zech_struct * vec2, slong len2, const fq_zech_t c, const fq_zech_ctx_t ctx) + void _fq_zech_vec_scalar_addmul_fq_zech(fq_zech_struct * vec1, const fq_zech_struct * vec2, slong len2, const fq_zech_t c, const fq_zech_ctx_t ctx) noexcept # Adds ``(vec2, len2)`` times `c` to ``(vec1, len2)``, where # `c` is a ``fq_zech_t``. - void _fq_zech_vec_scalar_submul_fq_zech(fq_zech_struct * vec1, const fq_zech_struct * vec2, slong len2, const fq_zech_t c, const fq_zech_ctx_t ctx) + void _fq_zech_vec_scalar_submul_fq_zech(fq_zech_struct * vec1, const fq_zech_struct * vec2, slong len2, const fq_zech_t c, const fq_zech_ctx_t ctx) noexcept # Subtracts ``(vec2, len2)`` times `c` from ``(vec1, len2)``, # where `c` is a ``fq_zech_t``. - void _fq_zech_vec_dot(fq_zech_t res, const fq_zech_struct * vec1, const fq_zech_struct * vec2, slong len2, const fq_zech_ctx_t ctx) + void _fq_zech_vec_dot(fq_zech_t res, const fq_zech_struct * vec1, const fq_zech_struct * vec2, slong len2, const fq_zech_ctx_t ctx) noexcept # Sets ``res`` to the dot product of (``vec1``, ``len``) # and (``vec2``, ``len``). diff --git a/src/sage/libs/flint/gr.pxd b/src/sage/libs/flint/gr.pxd index 7f72ee3a2ba..894f0d121c1 100644 --- a/src/sage/libs/flint/gr.pxd +++ b/src/sage/libs/flint/gr.pxd @@ -12,11 +12,11 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - slong gr_ctx_sizeof_elem(gr_ctx_t ctx) + slong gr_ctx_sizeof_elem(gr_ctx_t ctx) noexcept # Return ``sizeof(type)`` where ``type`` is the underlying C # type for elements of *ctx*. - int gr_ctx_clear(gr_ctx_t ctx) + int gr_ctx_clear(gr_ctx_t ctx) noexcept # Clears the context object *ctx*, freeing any memory # allocated by this object. # Some context objects may require that no elements are cleared after calling @@ -26,123 +26,123 @@ cdef extern from "flint_wrap.h": # may also be required to stay alive until after this # method is called. - int gr_ctx_write(gr_stream_t out, gr_ctx_t ctx) - int gr_ctx_print(gr_ctx_t ctx) - int gr_ctx_println(gr_ctx_t ctx) - int gr_ctx_get_str(char ** s, gr_ctx_t ctx) + int gr_ctx_write(gr_stream_t out, gr_ctx_t ctx) noexcept + int gr_ctx_print(gr_ctx_t ctx) noexcept + int gr_ctx_println(gr_ctx_t ctx) noexcept + int gr_ctx_get_str(char ** s, gr_ctx_t ctx) noexcept # Writes a description of the structure *ctx* to the stream *out*, # prints it to *stdout*, or sets *s* to a pointer to # a heap-allocated string of the description (the user must free # the string with ``flint_free``). # The *println* version prints a trailing newline. - int gr_ctx_set_gen_name(gr_ctx_t ctx, const char * s) - int gr_ctx_set_gen_names(gr_ctx_t ctx, const char ** s) + int gr_ctx_set_gen_name(gr_ctx_t ctx, const char * s) noexcept + int gr_ctx_set_gen_names(gr_ctx_t ctx, const char ** s) noexcept # Set the name of the generator (univariate polynomial ring, # finite field, etc.) or generators (multivariate). # The name is used when printing and may be used to choose # coercions. - void gr_init(gr_ptr res, gr_ctx_t ctx) + void gr_init(gr_ptr res, gr_ctx_t ctx) noexcept # Initializes *res* to a valid variable and sets it to the # zero element of the ring *ctx*. - void gr_clear(gr_ptr res, gr_ctx_t ctx) + void gr_clear(gr_ptr res, gr_ctx_t ctx) noexcept # Clears *res*, freeing any memory allocated by this object. - void gr_swap(gr_ptr x, gr_ptr y, gr_ctx_t ctx) + void gr_swap(gr_ptr x, gr_ptr y, gr_ctx_t ctx) noexcept # Swaps *x* and *y* efficiently. - void gr_set_shallow(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) + void gr_set_shallow(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept # Sets *res* to a shallow copy of *x*, copying the struct data. - gr_ptr gr_heap_init(gr_ctx_t ctx) + gr_ptr gr_heap_init(gr_ctx_t ctx) noexcept # Return a pointer to a single new heap-allocated element of *ctx* # set to 0. - void gr_heap_clear(gr_ptr x, gr_ctx_t ctx) + void gr_heap_clear(gr_ptr x, gr_ctx_t ctx) noexcept # Free the single heap-allocated element *x* of *ctx* which should # have been created with :func:`gr_heap_init`. - gr_ptr gr_heap_init_vec(slong len, gr_ctx_t ctx) + gr_ptr gr_heap_init_vec(slong len, gr_ctx_t ctx) noexcept # Return a pointer to a new heap-allocated vector of *len* # initialized elements. - void gr_heap_clear_vec(gr_ptr x, slong len, gr_ctx_t ctx) + void gr_heap_clear_vec(gr_ptr x, slong len, gr_ctx_t ctx) noexcept # Clear the *len* elements in the heap-allocated vector *len* and # free the vector itself. - int gr_randtest(gr_ptr res, flint_rand_t state, gr_ctx_t ctx) + int gr_randtest(gr_ptr res, flint_rand_t state, gr_ctx_t ctx) noexcept # Sets *res* to a random element of the domain *ctx*. # The distribution is determined by the implementation. # Typically the distribution is non-uniform in order to # find corner cases more easily in test code. - int gr_randtest_not_zero(gr_ptr res, flint_rand_t state, gr_ctx_t ctx) + int gr_randtest_not_zero(gr_ptr res, flint_rand_t state, gr_ctx_t ctx) noexcept # Sets *res* to a random nonzero element of the domain *ctx*. # This operation will fail and return ``GR_DOMAIN`` in the zero ring. - int gr_randtest_small(gr_ptr res, flint_rand_t state, gr_ctx_t ctx) + int gr_randtest_small(gr_ptr res, flint_rand_t state, gr_ctx_t ctx) noexcept # Sets *res* to a "small" element of the domain *ctx*. # This is suitable for randomized testing where a "large" argument # could result in excessive computation time. - int gr_write(gr_stream_t out, gr_srcptr x, gr_ctx_t ctx) - int gr_print(gr_srcptr x, gr_ctx_t ctx) - int gr_println(gr_srcptr x, gr_ctx_t ctx) - int gr_get_str(char ** s, gr_srcptr x, gr_ctx_t ctx) + int gr_write(gr_stream_t out, gr_srcptr x, gr_ctx_t ctx) noexcept + int gr_print(gr_srcptr x, gr_ctx_t ctx) noexcept + int gr_println(gr_srcptr x, gr_ctx_t ctx) noexcept + int gr_get_str(char ** s, gr_srcptr x, gr_ctx_t ctx) noexcept # Writes a description of the element *x* to the stream *out*, # or prints it to *stdout*, or sets *s* to a pointer to # a heap-allocated string of the description (the user must free # the string with ``flint_free``). The *println* version prints a # trailing newline. - int gr_set_str(gr_ptr res, const char * x, gr_ctx_t ctx) + int gr_set_str(gr_ptr res, const char * x, gr_ctx_t ctx) noexcept # Sets *res* to the string description in *x*. - int gr_write_n(gr_stream_t out, gr_srcptr x, slong n, gr_ctx_t ctx) - int gr_get_str_n(char ** s, gr_srcptr x, slong n, gr_ctx_t ctx) + int gr_write_n(gr_stream_t out, gr_srcptr x, slong n, gr_ctx_t ctx) noexcept + int gr_get_str_n(char ** s, gr_srcptr x, slong n, gr_ctx_t ctx) noexcept # String conversion where real and complex numbers may be rounded # to *n* digits. - int gr_set(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) + int gr_set(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept # Sets *res* to a copy of the element *x*. - int gr_set_other(gr_ptr res, gr_srcptr x, gr_ctx_t x_ctx, gr_ctx_t ctx) + int gr_set_other(gr_ptr res, gr_srcptr x, gr_ctx_t x_ctx, gr_ctx_t ctx) noexcept # Sets *res* to the element *x* of the structure *x_ctx* which # may be different from *ctx*. This returns the ``GR_DOMAIN`` flag # if *x* is not an element of *ctx* or cannot be converted # unambiguously to *ctx*. The ``GR_UNABLE`` flag is returned # if the conversion is not implemented. - int gr_set_ui(gr_ptr res, ulong x, gr_ctx_t ctx) - int gr_set_si(gr_ptr res, slong x, gr_ctx_t ctx) - int gr_set_fmpz(gr_ptr res, const fmpz_t x, gr_ctx_t ctx) - int gr_set_fmpq(gr_ptr res, const fmpq_t x, gr_ctx_t ctx) - int gr_set_d(gr_ptr res, double x, gr_ctx_t ctx) + int gr_set_ui(gr_ptr res, ulong x, gr_ctx_t ctx) noexcept + int gr_set_si(gr_ptr res, slong x, gr_ctx_t ctx) noexcept + int gr_set_fmpz(gr_ptr res, const fmpz_t x, gr_ctx_t ctx) noexcept + int gr_set_fmpq(gr_ptr res, const fmpq_t x, gr_ctx_t ctx) noexcept + int gr_set_d(gr_ptr res, double x, gr_ctx_t ctx) noexcept # Sets *res* to the value *x*. If no reasonable conversion to the # domain *ctx* is possible, returns ``GR_DOMAIN``. - int gr_get_si(slong * res, gr_srcptr x, gr_ctx_t ctx) - int gr_get_ui(ulong * res, gr_srcptr x, gr_ctx_t ctx) - int gr_get_fmpz(fmpz_t res, gr_srcptr x, gr_ctx_t ctx) - int gr_get_fmpq(fmpq_t res, gr_srcptr x, gr_ctx_t ctx) - int gr_get_d(double * res, gr_srcptr x, gr_ctx_t ctx) + int gr_get_si(slong * res, gr_srcptr x, gr_ctx_t ctx) noexcept + int gr_get_ui(ulong * res, gr_srcptr x, gr_ctx_t ctx) noexcept + int gr_get_fmpz(fmpz_t res, gr_srcptr x, gr_ctx_t ctx) noexcept + int gr_get_fmpq(fmpq_t res, gr_srcptr x, gr_ctx_t ctx) noexcept + int gr_get_d(double * res, gr_srcptr x, gr_ctx_t ctx) noexcept # Sets *res* to the value *x*. This returns the ``GR_DOMAIN`` flag # if *x* cannot be converted to the target type. # For floating-point output types, the output may be rounded. - int gr_set_fmpz_2exp_fmpz(gr_ptr res, const fmpz_t x, const fmpz_t y, gr_ctx_t ctx) - int gr_get_fmpz_2exp_fmpz(fmpz_t res1, fmpz_t res2, gr_srcptr x, gr_ctx_t ctx) + int gr_set_fmpz_2exp_fmpz(gr_ptr res, const fmpz_t x, const fmpz_t y, gr_ctx_t ctx) noexcept + int gr_get_fmpz_2exp_fmpz(fmpz_t res1, fmpz_t res2, gr_srcptr x, gr_ctx_t ctx) noexcept # Set or retrieve a dyadic number. - int gr_get_fexpr(fexpr_t res, gr_srcptr x, gr_ctx_t ctx) - int gr_get_fexpr_serialize(fexpr_t res, gr_srcptr x, gr_ctx_t ctx) + int gr_get_fexpr(fexpr_t res, gr_srcptr x, gr_ctx_t ctx) noexcept + int gr_get_fexpr_serialize(fexpr_t res, gr_srcptr x, gr_ctx_t ctx) noexcept # Sets *res* to a symbolic expression representing *x*. # The *serialize* version may generate a representation of the # internal representation which is not intended to be human-readable. - int gr_set_fexpr(gr_ptr res, fexpr_vec_t inputs, gr_vec_t outputs, const fexpr_t x, gr_ctx_t ctx) + int gr_set_fexpr(gr_ptr res, fexpr_vec_t inputs, gr_vec_t outputs, const fexpr_t x, gr_ctx_t ctx) noexcept # Sets *res* to the evaluation of the expression *x* in the # given ring or structure. # The user must provide vectors *inputs* and *outputs* which @@ -150,108 +150,108 @@ cdef extern from "flint_wrap.h": # during evaluation. Non-empty vectors may be given to map symbols # to predefined values. - int gr_zero(gr_ptr res, gr_ctx_t ctx) - int gr_one(gr_ptr res, gr_ctx_t ctx) - int gr_neg_one(gr_ptr res, gr_ctx_t ctx) + int gr_zero(gr_ptr res, gr_ctx_t ctx) noexcept + int gr_one(gr_ptr res, gr_ctx_t ctx) noexcept + int gr_neg_one(gr_ptr res, gr_ctx_t ctx) noexcept # Sets *res* to the ring element 0, 1 or -1. - int gr_gen(gr_ptr res, gr_ctx_t ctx) + int gr_gen(gr_ptr res, gr_ctx_t ctx) noexcept # Sets *res* to a generator of this domain. The meaning of # "generator" depends on the domain. - int gr_gens(gr_vec_t res, gr_ctx_t ctx) + int gr_gens(gr_vec_t res, gr_ctx_t ctx) noexcept # Sets *res* to a vector containing the generators of this domain # where this makes sense, for example in a multivariate polynomial # ring. - truth_t gr_is_zero(gr_srcptr x, gr_ctx_t ctx) - truth_t gr_is_one(gr_srcptr x, gr_ctx_t ctx) - truth_t gr_is_neg_one(gr_srcptr x, gr_ctx_t ctx) + truth_t gr_is_zero(gr_srcptr x, gr_ctx_t ctx) noexcept + truth_t gr_is_one(gr_srcptr x, gr_ctx_t ctx) noexcept + truth_t gr_is_neg_one(gr_srcptr x, gr_ctx_t ctx) noexcept # Returns whether *x* is equal to the ring element 0, 1 or -1, # respectively. - truth_t gr_equal(gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) + truth_t gr_equal(gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) noexcept # Returns whether the elements *x* and *y* are equal. - truth_t gr_is_integer(gr_srcptr x, gr_ctx_t ctx) + truth_t gr_is_integer(gr_srcptr x, gr_ctx_t ctx) noexcept # Returns whether *x* represents an integer. - truth_t gr_is_rational(gr_srcptr x, gr_ctx_t ctx) + truth_t gr_is_rational(gr_srcptr x, gr_ctx_t ctx) noexcept # Returns whether *x* represents a rational number. - int gr_neg(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) + int gr_neg(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept # Sets *res* to `-x`. - int gr_add(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) - int gr_add_ui(gr_ptr res, gr_srcptr x, ulong y, gr_ctx_t ctx) - int gr_add_si(gr_ptr res, gr_srcptr x, slong y, gr_ctx_t ctx) - int gr_add_fmpz(gr_ptr res, gr_srcptr x, const fmpz_t y, gr_ctx_t ctx) - int gr_add_fmpq(gr_ptr res, gr_srcptr x, const fmpq_t y, gr_ctx_t ctx) - int gr_add_other(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t y_ctx, gr_ctx_t ctx) - int gr_other_add(gr_ptr res, gr_srcptr x, gr_ctx_t x_ctx, gr_srcptr y, gr_ctx_t ctx) + int gr_add(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) noexcept + int gr_add_ui(gr_ptr res, gr_srcptr x, ulong y, gr_ctx_t ctx) noexcept + int gr_add_si(gr_ptr res, gr_srcptr x, slong y, gr_ctx_t ctx) noexcept + int gr_add_fmpz(gr_ptr res, gr_srcptr x, const fmpz_t y, gr_ctx_t ctx) noexcept + int gr_add_fmpq(gr_ptr res, gr_srcptr x, const fmpq_t y, gr_ctx_t ctx) noexcept + int gr_add_other(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t y_ctx, gr_ctx_t ctx) noexcept + int gr_other_add(gr_ptr res, gr_srcptr x, gr_ctx_t x_ctx, gr_srcptr y, gr_ctx_t ctx) noexcept # Sets *res* to `x + y`. - int gr_sub(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) - int gr_sub_ui(gr_ptr res, gr_srcptr x, ulong y, gr_ctx_t ctx) - int gr_sub_si(gr_ptr res, gr_srcptr x, slong y, gr_ctx_t ctx) - int gr_sub_fmpz(gr_ptr res, gr_srcptr x, const fmpz_t y, gr_ctx_t ctx) - int gr_sub_fmpq(gr_ptr res, gr_srcptr x, const fmpq_t y, gr_ctx_t ctx) - int gr_sub_other(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t y_ctx, gr_ctx_t ctx) - int gr_other_sub(gr_ptr res, gr_srcptr x, gr_ctx_t x_ctx, gr_srcptr y, gr_ctx_t ctx) + int gr_sub(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) noexcept + int gr_sub_ui(gr_ptr res, gr_srcptr x, ulong y, gr_ctx_t ctx) noexcept + int gr_sub_si(gr_ptr res, gr_srcptr x, slong y, gr_ctx_t ctx) noexcept + int gr_sub_fmpz(gr_ptr res, gr_srcptr x, const fmpz_t y, gr_ctx_t ctx) noexcept + int gr_sub_fmpq(gr_ptr res, gr_srcptr x, const fmpq_t y, gr_ctx_t ctx) noexcept + int gr_sub_other(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t y_ctx, gr_ctx_t ctx) noexcept + int gr_other_sub(gr_ptr res, gr_srcptr x, gr_ctx_t x_ctx, gr_srcptr y, gr_ctx_t ctx) noexcept # Sets *res* to `x - y`. - int gr_mul(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) - int gr_mul_ui(gr_ptr res, gr_srcptr x, ulong y, gr_ctx_t ctx) - int gr_mul_si(gr_ptr res, gr_srcptr x, slong y, gr_ctx_t ctx) - int gr_mul_fmpz(gr_ptr res, gr_srcptr x, const fmpz_t y, gr_ctx_t ctx) - int gr_mul_fmpq(gr_ptr res, gr_srcptr x, const fmpq_t y, gr_ctx_t ctx) - int gr_mul_other(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t y_ctx, gr_ctx_t ctx) - int gr_other_mul(gr_ptr res, gr_srcptr x, gr_ctx_t x_ctx, gr_srcptr y, gr_ctx_t ctx) + int gr_mul(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) noexcept + int gr_mul_ui(gr_ptr res, gr_srcptr x, ulong y, gr_ctx_t ctx) noexcept + int gr_mul_si(gr_ptr res, gr_srcptr x, slong y, gr_ctx_t ctx) noexcept + int gr_mul_fmpz(gr_ptr res, gr_srcptr x, const fmpz_t y, gr_ctx_t ctx) noexcept + int gr_mul_fmpq(gr_ptr res, gr_srcptr x, const fmpq_t y, gr_ctx_t ctx) noexcept + int gr_mul_other(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t y_ctx, gr_ctx_t ctx) noexcept + int gr_other_mul(gr_ptr res, gr_srcptr x, gr_ctx_t x_ctx, gr_srcptr y, gr_ctx_t ctx) noexcept # Sets *res* to `x \cdot y`. - int gr_addmul(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) - int gr_addmul_ui(gr_ptr res, gr_srcptr x, ulong y, gr_ctx_t ctx) - int gr_addmul_si(gr_ptr res, gr_srcptr x, slong y, gr_ctx_t ctx) - int gr_addmul_fmpz(gr_ptr res, gr_srcptr x, const fmpz_t y, gr_ctx_t ctx) - int gr_addmul_fmpq(gr_ptr res, gr_srcptr x, const fmpq_t y, gr_ctx_t ctx) - int gr_addmul_other(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t y_ctx, gr_ctx_t ctx) + int gr_addmul(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) noexcept + int gr_addmul_ui(gr_ptr res, gr_srcptr x, ulong y, gr_ctx_t ctx) noexcept + int gr_addmul_si(gr_ptr res, gr_srcptr x, slong y, gr_ctx_t ctx) noexcept + int gr_addmul_fmpz(gr_ptr res, gr_srcptr x, const fmpz_t y, gr_ctx_t ctx) noexcept + int gr_addmul_fmpq(gr_ptr res, gr_srcptr x, const fmpq_t y, gr_ctx_t ctx) noexcept + int gr_addmul_other(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t y_ctx, gr_ctx_t ctx) noexcept # Sets *res* to `\mathrm{res } + x \cdot y`. # Rings may override the default # implementation to perform this operation in one step without # allocating a temporary variable, without intermediate rounding, etc. - int gr_submul(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) - int gr_submul_ui(gr_ptr res, gr_srcptr x, ulong y, gr_ctx_t ctx) - int gr_submul_si(gr_ptr res, gr_srcptr x, slong y, gr_ctx_t ctx) - int gr_submul_fmpz(gr_ptr res, gr_srcptr x, const fmpz_t y, gr_ctx_t ctx) - int gr_submul_fmpq(gr_ptr res, gr_srcptr x, const fmpq_t y, gr_ctx_t ctx) - int gr_submul_other(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t y_ctx, gr_ctx_t ctx) + int gr_submul(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) noexcept + int gr_submul_ui(gr_ptr res, gr_srcptr x, ulong y, gr_ctx_t ctx) noexcept + int gr_submul_si(gr_ptr res, gr_srcptr x, slong y, gr_ctx_t ctx) noexcept + int gr_submul_fmpz(gr_ptr res, gr_srcptr x, const fmpz_t y, gr_ctx_t ctx) noexcept + int gr_submul_fmpq(gr_ptr res, gr_srcptr x, const fmpq_t y, gr_ctx_t ctx) noexcept + int gr_submul_other(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t y_ctx, gr_ctx_t ctx) noexcept # Sets *res* to `\mathrm{res } - x \cdot y`. # Rings may override the default # implementation to perform this operation in one step without # allocating a temporary variable, without intermediate rounding, etc. - int gr_mul_two(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) + int gr_mul_two(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept # Sets *res* to `2x`. The default implementation adds *x* # to itself. - int gr_sqr(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) + int gr_sqr(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept # Sets *res* to `x ^ 2`. The default implementation multiplies *x* # with itself. - int gr_mul_2exp_si(gr_ptr res, gr_srcptr x, slong y, gr_ctx_t ctx) - int gr_mul_2exp_fmpz(gr_ptr res, gr_srcptr x, const fmpz_t y, gr_ctx_t ctx) + int gr_mul_2exp_si(gr_ptr res, gr_srcptr x, slong y, gr_ctx_t ctx) noexcept + int gr_mul_2exp_fmpz(gr_ptr res, gr_srcptr x, const fmpz_t y, gr_ctx_t ctx) noexcept # Sets *res* to `x \cdot 2^y`. This may perform `x \cdot 2^{-y}` # when *y* is negative, allowing exact division by powers of two # even if `2^{y}` is not representable. - int gr_div(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) - int gr_div_ui(gr_ptr res, gr_srcptr x, ulong y, gr_ctx_t ctx) - int gr_div_si(gr_ptr res, gr_srcptr x, slong y, gr_ctx_t ctx) - int gr_div_fmpz(gr_ptr res, gr_srcptr x, const fmpz_t y, gr_ctx_t ctx) - int gr_div_fmpq(gr_ptr res, gr_srcptr x, const fmpq_t y, gr_ctx_t ctx) - int gr_div_other(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t y_ctx, gr_ctx_t ctx) - int gr_other_div(gr_ptr res, gr_srcptr x, gr_ctx_t x_ctx, gr_srcptr y, gr_ctx_t ctx) + int gr_div(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) noexcept + int gr_div_ui(gr_ptr res, gr_srcptr x, ulong y, gr_ctx_t ctx) noexcept + int gr_div_si(gr_ptr res, gr_srcptr x, slong y, gr_ctx_t ctx) noexcept + int gr_div_fmpz(gr_ptr res, gr_srcptr x, const fmpz_t y, gr_ctx_t ctx) noexcept + int gr_div_fmpq(gr_ptr res, gr_srcptr x, const fmpq_t y, gr_ctx_t ctx) noexcept + int gr_div_other(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t y_ctx, gr_ctx_t ctx) noexcept + int gr_other_div(gr_ptr res, gr_srcptr x, gr_ctx_t x_ctx, gr_srcptr y, gr_ctx_t ctx) noexcept # Sets *res* to the quotient `x / y` if such an element exists # in the present ring. Returns the flag ``GR_DOMAIN`` if no such # quotient exists. @@ -264,26 +264,26 @@ cdef extern from "flint_wrap.h": # `q y = x` (which, for example, gives the usual exact # division in `\mathbb{Z}`). - truth_t gr_is_invertible(gr_srcptr x, gr_ctx_t ctx) + truth_t gr_is_invertible(gr_srcptr x, gr_ctx_t ctx) noexcept # Returns whether *x* has a multiplicative inverse in the present ring, # i.e. whether *x* is a unit. - int gr_inv(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) + int gr_inv(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept # Sets *res* to the multiplicative inverse of *x* in the present ring, # if such an element exists. # Returns the flag ``GR_DOMAIN`` if *x* is not invertible, or # ``GR_UNABLE`` if the implementation is unable to perform # the computation. - truth_t gr_divides(gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) + truth_t gr_divides(gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) noexcept # Returns whether *x* divides *y*. - int gr_divexact(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) - int gr_divexact_ui(gr_ptr res, gr_srcptr x, ulong y, gr_ctx_t ctx) - int gr_divexact_si(gr_ptr res, gr_srcptr x, slong y, gr_ctx_t ctx) - int gr_divexact_fmpz(gr_ptr res, gr_srcptr x, const fmpz_t y, gr_ctx_t ctx) - int gr_divexact_other(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t y_ctx, gr_ctx_t ctx) - int gr_other_divexact(gr_ptr res, gr_srcptr x, gr_ctx_t x_ctx, gr_srcptr y, gr_ctx_t ctx) + int gr_divexact(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) noexcept + int gr_divexact_ui(gr_ptr res, gr_srcptr x, ulong y, gr_ctx_t ctx) noexcept + int gr_divexact_si(gr_ptr res, gr_srcptr x, slong y, gr_ctx_t ctx) noexcept + int gr_divexact_fmpz(gr_ptr res, gr_srcptr x, const fmpz_t y, gr_ctx_t ctx) noexcept + int gr_divexact_other(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t y_ctx, gr_ctx_t ctx) noexcept + int gr_other_divexact(gr_ptr res, gr_srcptr x, gr_ctx_t x_ctx, gr_srcptr y, gr_ctx_t ctx) noexcept # Sets *res* to the quotient `x / y`, assuming that this quotient # is exact in the present ring. # Rings may optimize this operation by not verifying that the @@ -291,9 +291,9 @@ cdef extern from "flint_wrap.h": # implementation may set *res* to a nonsense value and still # return the ``GR_SUCCESS`` flag. - int gr_euclidean_div(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) - int gr_euclidean_rem(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) - int gr_euclidean_divrem(gr_ptr res1, gr_ptr res2, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) + int gr_euclidean_div(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) noexcept + int gr_euclidean_rem(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) noexcept + int gr_euclidean_divrem(gr_ptr res1, gr_ptr res2, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) noexcept # In a Euclidean ring, these functions perform some version of Euclidean # division with remainder, where the choice of quotient is # implementation-defined. For example, it is standard to use @@ -301,13 +301,13 @@ cdef extern from "flint_wrap.h": # In non-Euclidean rings, these functions may implement some generalization of # Euclidean division with remainder. - int gr_pow(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) - int gr_pow_ui(gr_ptr res, gr_srcptr x, ulong y, gr_ctx_t ctx) - int gr_pow_si(gr_ptr res, gr_srcptr x, slong y, gr_ctx_t ctx) - int gr_pow_fmpz(gr_ptr res, gr_srcptr x, const fmpz_t y, gr_ctx_t ctx) - int gr_pow_fmpq(gr_ptr res, gr_srcptr x, const fmpq_t y, gr_ctx_t ctx) - int gr_pow_other(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t y_ctx, gr_ctx_t ctx) - int gr_other_pow(gr_ptr res, gr_srcptr x, gr_ctx_t x_ctx, gr_srcptr y, gr_ctx_t ctx) + int gr_pow(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) noexcept + int gr_pow_ui(gr_ptr res, gr_srcptr x, ulong y, gr_ctx_t ctx) noexcept + int gr_pow_si(gr_ptr res, gr_srcptr x, slong y, gr_ctx_t ctx) noexcept + int gr_pow_fmpz(gr_ptr res, gr_srcptr x, const fmpz_t y, gr_ctx_t ctx) noexcept + int gr_pow_fmpq(gr_ptr res, gr_srcptr x, const fmpq_t y, gr_ctx_t ctx) noexcept + int gr_pow_other(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t y_ctx, gr_ctx_t ctx) noexcept + int gr_other_pow(gr_ptr res, gr_srcptr x, gr_ctx_t x_ctx, gr_srcptr y, gr_ctx_t ctx) noexcept # Sets *res* to the power `x ^ y`, the interpretation of which # depends on the ring when `y \not \in \mathbb{Z}`. # Returns the flag ``GR_DOMAIN`` if this power cannot be assigned @@ -321,11 +321,11 @@ cdef extern from "flint_wrap.h": # should override these methods with faster versions or # to support more general notions of exponentiation when possible. - truth_t gr_is_square(gr_srcptr x, gr_ctx_t ctx) + truth_t gr_is_square(gr_srcptr x, gr_ctx_t ctx) noexcept # Returns whether *x* is a perfect square in the present ring. - int gr_sqrt(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) - int gr_rsqrt(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) + int gr_sqrt(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept + int gr_rsqrt(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept # Sets *res* to a square root of *x* (respectively reciprocal # square root) in the present ring, if such an element exists. # Returns the flag ``GR_DOMAIN`` if *x* is not a perfect square @@ -333,17 +333,17 @@ cdef extern from "flint_wrap.h": # ``GR_UNABLE`` if the implementation is unable to perform # the computation. - int gr_gcd(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) + int gr_gcd(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) noexcept # Sets *res* to a greatest common divisor (GCD) of *x* and *y*. # Since the GCD is unique only up to multiplication by a unit, # an implementation-defined representative is chosen. - int gr_lcm(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) + int gr_lcm(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) noexcept # Sets *res* to a least common multiple (LCM) of *x* and *y*. # Since the LCM is unique only up to multiplication by a unit, # an implementation-defined representative is chosen. - int gr_factor(gr_ptr c, gr_vec_t factors, gr_vec_t exponents, gr_srcptr x, int flags, gr_ctx_t ctx) + int gr_factor(gr_ptr c, gr_vec_t factors, gr_vec_t exponents, gr_srcptr x, int flags, gr_ctx_t ctx) noexcept # Given `x \in R`, computes a factorization # `x = c {f_1}^{e_1} \ldots {f_n}^{e_n}` # where `f_k` will be irreducible or prime (depending on `R`). @@ -359,8 +359,8 @@ cdef extern from "flint_wrap.h": # but they are not guaranteed to be sorted in any particular # order. - int gr_numerator(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) - int gr_denominator(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) + int gr_numerator(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept + int gr_denominator(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept # Return a numerator `p` and denominator `q` such that `x = p/q`. # For typical fraction fields, the denominator will be minimal # and canonical. @@ -368,62 +368,62 @@ cdef extern from "flint_wrap.h": # as the numerator matches. # The default implementations simply return `p = x` and `q = 1`. - int gr_floor(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) - int gr_ceil(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) - int gr_trunc(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) - int gr_nint(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) + int gr_floor(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept + int gr_ceil(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept + int gr_trunc(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept + int gr_nint(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept # In the real and complex numbers, sets *res* to the integer closest # to *x*, respectively rounding towards minus infinity, plus infinity, # zero, or the nearest integer (with tie-to-even). - int gr_abs(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) + int gr_abs(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept # Sets *res* to the absolute value of *x*, which maybe defined # both in complex rings and in any ordered ring. - int gr_i(gr_ptr res, gr_ctx_t ctx) + int gr_i(gr_ptr res, gr_ctx_t ctx) noexcept # Sets *res* to the imaginary unit. - int gr_conj(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) - int gr_re(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) - int gr_im(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) - int gr_sgn(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) - int gr_csgn(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) - int gr_arg(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) + int gr_conj(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept + int gr_re(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept + int gr_im(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept + int gr_sgn(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept + int gr_csgn(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept + int gr_arg(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept # These methods may return the flag ``GR_DOMAIN`` (or ``GR_UNABLE``) # when the ring is not a subring of the real or complex numbers. - int gr_pos_inf(gr_ptr res, gr_ctx_t ctx) - int gr_neg_inf(gr_ptr res, gr_ctx_t ctx) - int gr_uinf(gr_ptr res, gr_ctx_t ctx) - int gr_undefined(gr_ptr res, gr_ctx_t ctx) - int gr_unknown(gr_ptr res, gr_ctx_t ctx) + int gr_pos_inf(gr_ptr res, gr_ctx_t ctx) noexcept + int gr_neg_inf(gr_ptr res, gr_ctx_t ctx) noexcept + int gr_uinf(gr_ptr res, gr_ctx_t ctx) noexcept + int gr_undefined(gr_ptr res, gr_ctx_t ctx) noexcept + int gr_unknown(gr_ptr res, gr_ctx_t ctx) noexcept - int gr_cmp(int * res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) - int gr_cmp_other(int * res, gr_srcptr x, gr_srcptr y, gr_ctx_t y_ctx, gr_ctx_t ctx) + int gr_cmp(int * res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) noexcept + int gr_cmp_other(int * res, gr_srcptr x, gr_srcptr y, gr_ctx_t y_ctx, gr_ctx_t ctx) noexcept # Sets *res* to -1, 0 or 1 according to whether *x* is less than, # equal or greater than the absolute value of *y*. # This may return ``GR_DOMAIN`` if the ring is not an ordered ring. - int gr_cmpabs(int * res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) - int gr_cmpabs_other(int * res, gr_srcptr x, gr_srcptr y, gr_ctx_t y_ctx, gr_ctx_t ctx) + int gr_cmpabs(int * res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) noexcept + int gr_cmpabs_other(int * res, gr_srcptr x, gr_srcptr y, gr_ctx_t y_ctx, gr_ctx_t ctx) noexcept # Sets *res* to -1, 0 or 1 according to whether the absolute value # of *x* is less than, equal or greater than the absolute value of *y*. # This may return ``GR_DOMAIN`` if the ring is not an ordered ring. - int gr_ctx_fq_prime(fmpz_t p, gr_ctx_t ctx) + int gr_ctx_fq_prime(fmpz_t p, gr_ctx_t ctx) noexcept - int gr_ctx_fq_degree(slong * deg, gr_ctx_t ctx) + int gr_ctx_fq_degree(slong * deg, gr_ctx_t ctx) noexcept - int gr_ctx_fq_order(fmpz_t q, gr_ctx_t ctx) + int gr_ctx_fq_order(fmpz_t q, gr_ctx_t ctx) noexcept - int gr_fq_frobenius(gr_ptr res, gr_srcptr x, slong e, gr_ctx_t ctx) + int gr_fq_frobenius(gr_ptr res, gr_srcptr x, slong e, gr_ctx_t ctx) noexcept - int gr_fq_multiplicative_order(fmpz_t res, gr_srcptr x, gr_ctx_t ctx) + int gr_fq_multiplicative_order(fmpz_t res, gr_srcptr x, gr_ctx_t ctx) noexcept - int gr_fq_norm(fmpz_t res, gr_srcptr x, gr_ctx_t ctx) + int gr_fq_norm(fmpz_t res, gr_srcptr x, gr_ctx_t ctx) noexcept - int gr_fq_trace(fmpz_t res, gr_srcptr x, gr_ctx_t ctx) + int gr_fq_trace(fmpz_t res, gr_srcptr x, gr_ctx_t ctx) noexcept - truth_t gr_fq_is_primitive(gr_srcptr x, gr_ctx_t ctx) + truth_t gr_fq_is_primitive(gr_srcptr x, gr_ctx_t ctx) noexcept - int gr_fq_pth_root(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) + int gr_fq_pth_root(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept diff --git a/src/sage/libs/flint/gr_generic.pxd b/src/sage/libs/flint/gr_generic.pxd index 95dbf3336ab..1065194c445 100644 --- a/src/sage/libs/flint/gr_generic.pxd +++ b/src/sage/libs/flint/gr_generic.pxd @@ -12,260 +12,260 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void gr_generic_init() - void gr_generic_clear() - void gr_generic_swap() - void gr_generic_randtest() - void gr_generic_write() - void gr_generic_zero() - void gr_generic_one() - void gr_generic_equal() - void gr_generic_set() - void gr_generic_set_si() - void gr_generic_set_ui() - void gr_generic_set_fmpz() - void gr_generic_neg() - void gr_generic_add() - void gr_generic_sub() - void gr_generic_mul() - - int gr_generic_ctx_clear(gr_ctx_t ctx) - - void gr_generic_set_shallow(gr_ptr res, gr_srcptr x, const gr_ctx_t ctx) - - int gr_generic_write_n(gr_stream_t out, gr_srcptr x, slong n, gr_ctx_t ctx) - - int gr_generic_randtest_not_zero(gr_ptr x, flint_rand_t state, gr_ctx_t ctx) - - int gr_generic_randtest_small(gr_ptr x, flint_rand_t state, gr_ctx_t ctx) - - truth_t gr_generic_is_zero(gr_srcptr x, gr_ctx_t ctx) - truth_t gr_generic_is_one(gr_srcptr x, gr_ctx_t ctx) - truth_t gr_generic_is_neg_one(gr_srcptr x, gr_ctx_t ctx) - - int gr_generic_neg_one(gr_ptr res, gr_ctx_t ctx) - - int gr_generic_set_other(gr_ptr res, gr_srcptr x, gr_ctx_t xctx, gr_ctx_t ctx) - int gr_generic_set_fmpq(gr_ptr res, const fmpq_t y, gr_ctx_t ctx) - - int gr_generic_add_fmpz(gr_ptr res, gr_srcptr x, const fmpz_t y, gr_ctx_t ctx) - int gr_generic_add_ui(gr_ptr res, gr_srcptr x, ulong y, gr_ctx_t ctx) - int gr_generic_add_si(gr_ptr res, gr_srcptr x, slong y, gr_ctx_t ctx) - int gr_generic_add_fmpq(gr_ptr res, gr_srcptr x, const fmpq_t y, gr_ctx_t ctx) - int gr_generic_add_other(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t y_ctx, gr_ctx_t ctx) - int gr_generic_other_add(gr_ptr res, gr_srcptr x, gr_ctx_t x_ctx, gr_srcptr y, gr_ctx_t ctx) - - int gr_generic_sub_ui(gr_ptr res, gr_srcptr x, ulong y, gr_ctx_t ctx) - int gr_generic_sub_si(gr_ptr res, gr_srcptr x, slong y, gr_ctx_t ctx) - int gr_generic_sub_fmpz(gr_ptr res, gr_srcptr x, const fmpz_t y, gr_ctx_t ctx) - int gr_generic_sub_fmpq(gr_ptr res, gr_srcptr x, const fmpq_t y, gr_ctx_t ctx) - int gr_generic_sub_other(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t y_ctx, gr_ctx_t ctx) - int gr_generic_other_sub(gr_ptr res, gr_srcptr x, gr_ctx_t x_ctx, gr_srcptr y, gr_ctx_t ctx) - - int gr_generic_mul_fmpz(gr_ptr res, gr_srcptr x, const fmpz_t y, gr_ctx_t ctx) - int gr_generic_mul_ui(gr_ptr res, gr_srcptr x, ulong y, gr_ctx_t ctx) - int gr_generic_mul_si(gr_ptr res, gr_srcptr x, slong y, gr_ctx_t ctx) - int gr_generic_mul_fmpq(gr_ptr res, gr_srcptr x, const fmpq_t y, gr_ctx_t ctx) - int gr_generic_mul_other(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t y_ctx, gr_ctx_t ctx) - int gr_generic_other_mul(gr_ptr res, gr_srcptr x, gr_ctx_t x_ctx, gr_srcptr y, gr_ctx_t ctx) - - int gr_generic_addmul(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) - int gr_generic_addmul_ui(gr_ptr res, gr_srcptr x, ulong y, gr_ctx_t ctx) - int gr_generic_addmul_si(gr_ptr res, gr_srcptr x, slong y, gr_ctx_t ctx) - int gr_generic_addmul_fmpz(gr_ptr res, gr_srcptr x, const fmpz_t y, gr_ctx_t ctx) - int gr_generic_addmul_fmpq(gr_ptr res, gr_srcptr x, const fmpq_t y, gr_ctx_t ctx) - int gr_generic_addmul_other(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t y_ctx, gr_ctx_t ctx) - - int gr_generic_submul(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) - int gr_generic_submul_ui(gr_ptr res, gr_srcptr x, ulong y, gr_ctx_t ctx) - int gr_generic_submul_si(gr_ptr res, gr_srcptr x, slong y, gr_ctx_t ctx) - int gr_generic_submul_fmpz(gr_ptr res, gr_srcptr x, const fmpz_t y, gr_ctx_t ctx) - int gr_generic_submul_fmpq(gr_ptr res, gr_srcptr x, const fmpq_t y, gr_ctx_t ctx) - int gr_generic_submul_other(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t y_ctx, gr_ctx_t ctx) - - int gr_generic_mul_two(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) - - int gr_generic_sqr(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) - - int gr_generic_mul_2exp_si(gr_ptr res, gr_srcptr x, slong y, gr_ctx_t ctx) - int gr_generic_mul_2exp_fmpz(gr_ptr res, gr_srcptr x, const fmpz_t y, gr_ctx_t ctx) - - int gr_generic_set_fmpz_2exp_fmpz(gr_ptr res, const fmpz_t x, const fmpz_t y, gr_ctx_t ctx) - - int gr_generic_get_fmpz_2exp_fmpz(fmpz_t res1, fmpz_t res2, gr_ptr x, gr_ctx_t ctx) - - int gr_generic_inv(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) - - truth_t gr_generic_is_invertible(gr_srcptr x, gr_ctx_t ctx) - - int gr_generic_div_fmpz(gr_ptr res, gr_srcptr x, const fmpz_t y, gr_ctx_t ctx) - int gr_generic_div_ui(gr_ptr res, gr_srcptr x, ulong y, gr_ctx_t ctx) - int gr_generic_div_si(gr_ptr res, gr_srcptr x, slong y, gr_ctx_t ctx) - int gr_generic_div_fmpq(gr_ptr res, gr_srcptr x, const fmpq_t y, gr_ctx_t ctx) - int gr_generic_div_other(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t y_ctx, gr_ctx_t ctx) - int gr_generic_other_div(gr_ptr res, gr_srcptr x, gr_ctx_t x_ctx, gr_srcptr y, gr_ctx_t ctx) - - int gr_generic_divexact(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) - - int gr_generic_pow_fmpz_sliding(gr_ptr f, gr_srcptr g, const fmpz_t pow, gr_ctx_t ctx) - int gr_generic_pow_ui_sliding(gr_ptr f, gr_srcptr g, ulong pow, gr_ctx_t ctx) - int gr_generic_pow_fmpz_binexp(gr_ptr res, gr_srcptr x, const fmpz_t exp, gr_ctx_t ctx) - int gr_generic_pow_ui_binexp(gr_ptr res, gr_srcptr x, ulong e, gr_ctx_t ctx) - - int gr_generic_pow_fmpz(gr_ptr res, gr_srcptr x, const fmpz_t e, gr_ctx_t ctx) - int gr_generic_pow_si(gr_ptr res, gr_srcptr x, slong e, gr_ctx_t ctx) - int gr_generic_pow_ui(gr_ptr res, gr_srcptr x, ulong e, gr_ctx_t ctx) - int gr_generic_pow_fmpq(gr_ptr res, gr_srcptr x, const fmpq_t y, gr_ctx_t ctx) - int gr_generic_pow_other(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t y_ctx, gr_ctx_t ctx) - int gr_generic_other_pow(gr_ptr res, gr_srcptr x, gr_ctx_t x_ctx, gr_srcptr y, gr_ctx_t ctx) - - int _gr_fmpz_poly_evaluate_horner(gr_ptr res, const fmpz * f, slong len, gr_srcptr x, gr_ctx_t ctx) - int gr_fmpz_poly_evaluate_horner(gr_ptr res, const fmpz_poly_t f, gr_srcptr x, gr_ctx_t ctx) - int _gr_fmpz_poly_evaluate_rectangular(gr_ptr res, const fmpz * f, slong len, gr_srcptr x, gr_ctx_t ctx) - int gr_fmpz_poly_evaluate_rectangular(gr_ptr res, const fmpz_poly_t f, gr_srcptr x, gr_ctx_t ctx) - int _gr_fmpz_poly_evaluate(gr_ptr res, const fmpz * f, slong len, gr_srcptr x, gr_ctx_t ctx) - int gr_fmpz_poly_evaluate(gr_ptr res, const fmpz_poly_t f, gr_srcptr x, gr_ctx_t ctx) + void gr_generic_init() noexcept + void gr_generic_clear() noexcept + void gr_generic_swap() noexcept + void gr_generic_randtest() noexcept + void gr_generic_write() noexcept + void gr_generic_zero() noexcept + void gr_generic_one() noexcept + void gr_generic_equal() noexcept + void gr_generic_set() noexcept + void gr_generic_set_si() noexcept + void gr_generic_set_ui() noexcept + void gr_generic_set_fmpz() noexcept + void gr_generic_neg() noexcept + void gr_generic_add() noexcept + void gr_generic_sub() noexcept + void gr_generic_mul() noexcept + + int gr_generic_ctx_clear(gr_ctx_t ctx) noexcept + + void gr_generic_set_shallow(gr_ptr res, gr_srcptr x, const gr_ctx_t ctx) noexcept + + int gr_generic_write_n(gr_stream_t out, gr_srcptr x, slong n, gr_ctx_t ctx) noexcept + + int gr_generic_randtest_not_zero(gr_ptr x, flint_rand_t state, gr_ctx_t ctx) noexcept + + int gr_generic_randtest_small(gr_ptr x, flint_rand_t state, gr_ctx_t ctx) noexcept + + truth_t gr_generic_is_zero(gr_srcptr x, gr_ctx_t ctx) noexcept + truth_t gr_generic_is_one(gr_srcptr x, gr_ctx_t ctx) noexcept + truth_t gr_generic_is_neg_one(gr_srcptr x, gr_ctx_t ctx) noexcept + + int gr_generic_neg_one(gr_ptr res, gr_ctx_t ctx) noexcept + + int gr_generic_set_other(gr_ptr res, gr_srcptr x, gr_ctx_t xctx, gr_ctx_t ctx) noexcept + int gr_generic_set_fmpq(gr_ptr res, const fmpq_t y, gr_ctx_t ctx) noexcept + + int gr_generic_add_fmpz(gr_ptr res, gr_srcptr x, const fmpz_t y, gr_ctx_t ctx) noexcept + int gr_generic_add_ui(gr_ptr res, gr_srcptr x, ulong y, gr_ctx_t ctx) noexcept + int gr_generic_add_si(gr_ptr res, gr_srcptr x, slong y, gr_ctx_t ctx) noexcept + int gr_generic_add_fmpq(gr_ptr res, gr_srcptr x, const fmpq_t y, gr_ctx_t ctx) noexcept + int gr_generic_add_other(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t y_ctx, gr_ctx_t ctx) noexcept + int gr_generic_other_add(gr_ptr res, gr_srcptr x, gr_ctx_t x_ctx, gr_srcptr y, gr_ctx_t ctx) noexcept + + int gr_generic_sub_ui(gr_ptr res, gr_srcptr x, ulong y, gr_ctx_t ctx) noexcept + int gr_generic_sub_si(gr_ptr res, gr_srcptr x, slong y, gr_ctx_t ctx) noexcept + int gr_generic_sub_fmpz(gr_ptr res, gr_srcptr x, const fmpz_t y, gr_ctx_t ctx) noexcept + int gr_generic_sub_fmpq(gr_ptr res, gr_srcptr x, const fmpq_t y, gr_ctx_t ctx) noexcept + int gr_generic_sub_other(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t y_ctx, gr_ctx_t ctx) noexcept + int gr_generic_other_sub(gr_ptr res, gr_srcptr x, gr_ctx_t x_ctx, gr_srcptr y, gr_ctx_t ctx) noexcept + + int gr_generic_mul_fmpz(gr_ptr res, gr_srcptr x, const fmpz_t y, gr_ctx_t ctx) noexcept + int gr_generic_mul_ui(gr_ptr res, gr_srcptr x, ulong y, gr_ctx_t ctx) noexcept + int gr_generic_mul_si(gr_ptr res, gr_srcptr x, slong y, gr_ctx_t ctx) noexcept + int gr_generic_mul_fmpq(gr_ptr res, gr_srcptr x, const fmpq_t y, gr_ctx_t ctx) noexcept + int gr_generic_mul_other(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t y_ctx, gr_ctx_t ctx) noexcept + int gr_generic_other_mul(gr_ptr res, gr_srcptr x, gr_ctx_t x_ctx, gr_srcptr y, gr_ctx_t ctx) noexcept + + int gr_generic_addmul(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) noexcept + int gr_generic_addmul_ui(gr_ptr res, gr_srcptr x, ulong y, gr_ctx_t ctx) noexcept + int gr_generic_addmul_si(gr_ptr res, gr_srcptr x, slong y, gr_ctx_t ctx) noexcept + int gr_generic_addmul_fmpz(gr_ptr res, gr_srcptr x, const fmpz_t y, gr_ctx_t ctx) noexcept + int gr_generic_addmul_fmpq(gr_ptr res, gr_srcptr x, const fmpq_t y, gr_ctx_t ctx) noexcept + int gr_generic_addmul_other(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t y_ctx, gr_ctx_t ctx) noexcept + + int gr_generic_submul(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) noexcept + int gr_generic_submul_ui(gr_ptr res, gr_srcptr x, ulong y, gr_ctx_t ctx) noexcept + int gr_generic_submul_si(gr_ptr res, gr_srcptr x, slong y, gr_ctx_t ctx) noexcept + int gr_generic_submul_fmpz(gr_ptr res, gr_srcptr x, const fmpz_t y, gr_ctx_t ctx) noexcept + int gr_generic_submul_fmpq(gr_ptr res, gr_srcptr x, const fmpq_t y, gr_ctx_t ctx) noexcept + int gr_generic_submul_other(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t y_ctx, gr_ctx_t ctx) noexcept + + int gr_generic_mul_two(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept + + int gr_generic_sqr(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept + + int gr_generic_mul_2exp_si(gr_ptr res, gr_srcptr x, slong y, gr_ctx_t ctx) noexcept + int gr_generic_mul_2exp_fmpz(gr_ptr res, gr_srcptr x, const fmpz_t y, gr_ctx_t ctx) noexcept + + int gr_generic_set_fmpz_2exp_fmpz(gr_ptr res, const fmpz_t x, const fmpz_t y, gr_ctx_t ctx) noexcept + + int gr_generic_get_fmpz_2exp_fmpz(fmpz_t res1, fmpz_t res2, gr_ptr x, gr_ctx_t ctx) noexcept + + int gr_generic_inv(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept + + truth_t gr_generic_is_invertible(gr_srcptr x, gr_ctx_t ctx) noexcept + + int gr_generic_div_fmpz(gr_ptr res, gr_srcptr x, const fmpz_t y, gr_ctx_t ctx) noexcept + int gr_generic_div_ui(gr_ptr res, gr_srcptr x, ulong y, gr_ctx_t ctx) noexcept + int gr_generic_div_si(gr_ptr res, gr_srcptr x, slong y, gr_ctx_t ctx) noexcept + int gr_generic_div_fmpq(gr_ptr res, gr_srcptr x, const fmpq_t y, gr_ctx_t ctx) noexcept + int gr_generic_div_other(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t y_ctx, gr_ctx_t ctx) noexcept + int gr_generic_other_div(gr_ptr res, gr_srcptr x, gr_ctx_t x_ctx, gr_srcptr y, gr_ctx_t ctx) noexcept + + int gr_generic_divexact(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) noexcept + + int gr_generic_pow_fmpz_sliding(gr_ptr f, gr_srcptr g, const fmpz_t pow, gr_ctx_t ctx) noexcept + int gr_generic_pow_ui_sliding(gr_ptr f, gr_srcptr g, ulong pow, gr_ctx_t ctx) noexcept + int gr_generic_pow_fmpz_binexp(gr_ptr res, gr_srcptr x, const fmpz_t exp, gr_ctx_t ctx) noexcept + int gr_generic_pow_ui_binexp(gr_ptr res, gr_srcptr x, ulong e, gr_ctx_t ctx) noexcept + + int gr_generic_pow_fmpz(gr_ptr res, gr_srcptr x, const fmpz_t e, gr_ctx_t ctx) noexcept + int gr_generic_pow_si(gr_ptr res, gr_srcptr x, slong e, gr_ctx_t ctx) noexcept + int gr_generic_pow_ui(gr_ptr res, gr_srcptr x, ulong e, gr_ctx_t ctx) noexcept + int gr_generic_pow_fmpq(gr_ptr res, gr_srcptr x, const fmpq_t y, gr_ctx_t ctx) noexcept + int gr_generic_pow_other(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t y_ctx, gr_ctx_t ctx) noexcept + int gr_generic_other_pow(gr_ptr res, gr_srcptr x, gr_ctx_t x_ctx, gr_srcptr y, gr_ctx_t ctx) noexcept + + int _gr_fmpz_poly_evaluate_horner(gr_ptr res, const fmpz * f, slong len, gr_srcptr x, gr_ctx_t ctx) noexcept + int gr_fmpz_poly_evaluate_horner(gr_ptr res, const fmpz_poly_t f, gr_srcptr x, gr_ctx_t ctx) noexcept + int _gr_fmpz_poly_evaluate_rectangular(gr_ptr res, const fmpz * f, slong len, gr_srcptr x, gr_ctx_t ctx) noexcept + int gr_fmpz_poly_evaluate_rectangular(gr_ptr res, const fmpz_poly_t f, gr_srcptr x, gr_ctx_t ctx) noexcept + int _gr_fmpz_poly_evaluate(gr_ptr res, const fmpz * f, slong len, gr_srcptr x, gr_ctx_t ctx) noexcept + int gr_fmpz_poly_evaluate(gr_ptr res, const fmpz_poly_t f, gr_srcptr x, gr_ctx_t ctx) noexcept # Sets *res* to the value of the integer polynomial *f* evaluated # at the argument *x*. - int gr_fmpz_mpoly_evaluate(gr_ptr res, const fmpz_mpoly_t f, gr_srcptr x, const fmpz_mpoly_ctx_t mctx, gr_ctx_t ctx) + int gr_fmpz_mpoly_evaluate(gr_ptr res, const fmpz_mpoly_t f, gr_srcptr x, const fmpz_mpoly_ctx_t mctx, gr_ctx_t ctx) noexcept # Sets *res* to value of the multivariate polynomial *f* (with # corresponding context object *mctx*) evaluated at the vector # of arguments in *x*. - truth_t gr_generic_is_square(gr_srcptr x, gr_ctx_t ctx) - int gr_generic_sqrt(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) - int gr_generic_rsqrt(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) + truth_t gr_generic_is_square(gr_srcptr x, gr_ctx_t ctx) noexcept + int gr_generic_sqrt(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept + int gr_generic_rsqrt(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept # Currently these methods check for the special values 0 and 1. - int gr_generic_numerator(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) - int gr_generic_denominator(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) + int gr_generic_numerator(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept + int gr_generic_denominator(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept - int gr_generic_cmp(int * res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) - int gr_generic_cmpabs(int * res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) - int gr_generic_cmp_other(int * res, gr_srcptr x, gr_srcptr y, gr_ctx_t y_ctx, gr_ctx_t ctx) - int gr_generic_cmpabs_other(int * res, gr_srcptr x, gr_srcptr y, gr_ctx_t y_ctx, gr_ctx_t ctx) - - int gr_generic_bernoulli_ui(gr_ptr res, ulong n, gr_ctx_t ctx) - int gr_generic_bernoulli_fmpz(gr_ptr res, const fmpz_t n, gr_ctx_t ctx) - int gr_generic_bernoulli_vec(gr_ptr res, slong len, gr_ctx_t ctx) - int gr_generic_eulernum_ui(gr_ptr res, ulong n, gr_ctx_t ctx) - int gr_generic_eulernum_fmpz(gr_ptr res, const fmpz_t n, gr_ctx_t ctx) - int gr_generic_eulernum_vec(gr_ptr res, slong len, gr_ctx_t ctx) - int gr_generic_stirling_s1u_uiui(gr_ptr res, ulong x, ulong y, gr_ctx_t ctx) - int gr_generic_stirling_s1_uiui(gr_ptr res, ulong x, ulong y, gr_ctx_t ctx) - int gr_generic_stirling_s2_uiui(gr_ptr res, ulong x, ulong y, gr_ctx_t ctx) - int gr_generic_stirling_s1u_ui_vec(gr_ptr res, ulong x, slong len, gr_ctx_t ctx) - int gr_generic_stirling_s1_ui_vec(gr_ptr res, ulong x, slong len, gr_ctx_t ctx) - int gr_generic_stirling_s2_ui_vec(gr_ptr res, ulong x, slong len, gr_ctx_t ctx) - - void gr_generic_vec_init(gr_ptr vec, slong len, gr_ctx_t ctx) - - void gr_generic_vec_clear(gr_ptr vec, slong len, gr_ctx_t ctx) - - void gr_generic_vec_swap(gr_ptr vec1, gr_ptr vec2, slong len, gr_ctx_t ctx) - - int gr_generic_vec_zero(gr_ptr vec, slong len, gr_ctx_t ctx) - - int gr_generic_vec_set(gr_ptr res, gr_srcptr src, slong len, gr_ctx_t ctx) - - int gr_generic_vec_neg(gr_ptr res, gr_srcptr src, slong len, gr_ctx_t ctx) - - int gr_generic_vec_normalise(slong * res, gr_srcptr vec, slong len, gr_ctx_t ctx) - - slong gr_generic_vec_normalise_weak(gr_srcptr vec, slong len, gr_ctx_t ctx) - - int gr_generic_vec_mul_scalar_2exp_si(gr_ptr vec1, gr_srcptr vec2, slong len, slong c, gr_ctx_t ctx) - - int gr_generic_vec_scalar_addmul(gr_ptr vec1, gr_srcptr vec2, slong len, gr_srcptr c, gr_ctx_t ctx) - - int gr_generic_vec_scalar_submul(gr_ptr vec1, gr_srcptr vec2, slong len, gr_srcptr c, gr_ctx_t ctx) - - int gr_generic_vec_scalar_addmul_si(gr_ptr vec1, gr_srcptr vec2, slong len, slong c, gr_ctx_t ctx) - - int gr_generic_vec_scalar_submul_si(gr_ptr vec1, gr_srcptr vec2, slong len, slong c, gr_ctx_t ctx) - - truth_t gr_generic_vec_equal(gr_srcptr vec1, gr_srcptr vec2, slong len, gr_ctx_t ctx) - - bint gr_generic_vec_is_zero(gr_srcptr vec, slong len, gr_ctx_t ctx) - - int gr_generic_vec_dot(gr_ptr res, gr_srcptr initial, int subtract, gr_srcptr vec1, gr_srcptr vec2, slong len, gr_ctx_t ctx) - - int gr_generic_vec_dot_rev(gr_ptr res, gr_srcptr initial, int subtract, gr_srcptr vec1, gr_srcptr vec2, slong len, gr_ctx_t ctx) - - int gr_generic_vec_dot_ui(gr_ptr res, gr_srcptr initial, int subtract, gr_srcptr vec1, const ulong * vec2, slong len, gr_ctx_t ctx) - - int gr_generic_vec_dot_si(gr_ptr res, gr_srcptr initial, int subtract, gr_srcptr vec1, const slong * vec2, slong len, gr_ctx_t ctx) - - int gr_generic_vec_dot_fmpz(gr_ptr res, gr_srcptr initial, int subtract, gr_srcptr vec1, const fmpz * vec2, slong len, gr_ctx_t ctx) - - int gr_generic_vec_set_powers(gr_ptr res, gr_srcptr x, slong len, gr_ctx_t ctx) - - int gr_generic_vec_reciprocals(gr_ptr res, slong len, gr_ctx_t ctx) - - int gr_generic_vec_add(gr_ptr res, gr_srcptr src1, gr_srcptr src2, slong len, gr_ctx_t ctx) - int gr_generic_vec_sub(gr_ptr res, gr_srcptr src1, gr_srcptr src2, slong len, gr_ctx_t ctx) - int gr_generic_vec_mul(gr_ptr res, gr_srcptr src1, gr_srcptr src2, slong len, gr_ctx_t ctx) - int gr_generic_vec_div(gr_ptr res, gr_srcptr src1, gr_srcptr src2, slong len, gr_ctx_t ctx) - int gr_generic_vec_divexact(gr_ptr res, gr_srcptr src1, gr_srcptr src2, slong len, gr_ctx_t ctx) - int gr_generic_vec_pow(gr_ptr res, gr_srcptr src1, gr_srcptr src2, slong len, gr_ctx_t ctx) - int gr_generic_vec_add_scalar(gr_ptr vec1, gr_srcptr vec2, slong len, gr_srcptr c, gr_ctx_t ctx) - int gr_generic_vec_sub_scalar(gr_ptr vec1, gr_srcptr vec2, slong len, gr_srcptr c, gr_ctx_t ctx) - int gr_generic_vec_mul_scalar(gr_ptr vec1, gr_srcptr vec2, slong len, gr_srcptr c, gr_ctx_t ctx) - int gr_generic_vec_div_scalar(gr_ptr vec1, gr_srcptr vec2, slong len, gr_srcptr c, gr_ctx_t ctx) - int gr_generic_vec_divexact_scalar(gr_ptr vec1, gr_srcptr vec2, slong len, gr_srcptr c, gr_ctx_t ctx) - int gr_generic_vec_pow_scalar(gr_ptr vec1, gr_srcptr vec2, slong len, gr_srcptr c, gr_ctx_t ctx) - int gr_generic_vec_add_scalar_si(gr_ptr vec1, gr_srcptr vec2, slong len, slong c, gr_ctx_t ctx) - int gr_generic_vec_sub_scalar_si(gr_ptr vec1, gr_srcptr vec2, slong len, slong c, gr_ctx_t ctx) - int gr_generic_vec_mul_scalar_si(gr_ptr vec1, gr_srcptr vec2, slong len, slong c, gr_ctx_t ctx) - int gr_generic_vec_div_scalar_si(gr_ptr vec1, gr_srcptr vec2, slong len, slong c, gr_ctx_t ctx) - int gr_generic_vec_divexact_scalar_si(gr_ptr vec1, gr_srcptr vec2, slong len, slong c, gr_ctx_t ctx) - int gr_generic_vec_pow_scalar_si(gr_ptr vec1, gr_srcptr vec2, slong len, slong c, gr_ctx_t ctx) - int gr_generic_vec_add_scalar_ui(gr_ptr vec1, gr_srcptr vec2, slong len, ulong c, gr_ctx_t ctx) - int gr_generic_vec_sub_scalar_ui(gr_ptr vec1, gr_srcptr vec2, slong len, ulong c, gr_ctx_t ctx) - int gr_generic_vec_mul_scalar_ui(gr_ptr vec1, gr_srcptr vec2, slong len, ulong c, gr_ctx_t ctx) - int gr_generic_vec_div_scalar_ui(gr_ptr vec1, gr_srcptr vec2, slong len, ulong c, gr_ctx_t ctx) - int gr_generic_vec_divexact_scalar_ui(gr_ptr vec1, gr_srcptr vec2, slong len, ulong c, gr_ctx_t ctx) - int gr_generic_vec_pow_scalar_ui(gr_ptr vec1, gr_srcptr vec2, slong len, ulong c, gr_ctx_t ctx) - int gr_generic_vec_add_scalar_fmpz(gr_ptr vec1, gr_srcptr vec2, slong len, const fmpz_t c, gr_ctx_t ctx) - int gr_generic_vec_sub_scalar_fmpz(gr_ptr vec1, gr_srcptr vec2, slong len, const fmpz_t c, gr_ctx_t ctx) - int gr_generic_vec_mul_scalar_fmpz(gr_ptr vec1, gr_srcptr vec2, slong len, const fmpz_t c, gr_ctx_t ctx) - int gr_generic_vec_div_scalar_fmpz(gr_ptr vec1, gr_srcptr vec2, slong len, const fmpz_t c, gr_ctx_t ctx) - int gr_generic_vec_divexact_scalar_fmpz(gr_ptr vec1, gr_srcptr vec2, slong len, const fmpz_t c, gr_ctx_t ctx) - int gr_generic_vec_pow_scalar_fmpz(gr_ptr vec1, gr_srcptr vec2, slong len, const fmpz_t c, gr_ctx_t ctx) - int gr_generic_vec_add_scalar_fmpq(gr_ptr vec1, gr_srcptr vec2, slong len, const fmpq_t c, gr_ctx_t ctx) - int gr_generic_vec_sub_scalar_fmpq(gr_ptr vec1, gr_srcptr vec2, slong len, const fmpq_t c, gr_ctx_t ctx) - int gr_generic_vec_mul_scalar_fmpq(gr_ptr vec1, gr_srcptr vec2, slong len, const fmpq_t c, gr_ctx_t ctx) - int gr_generic_vec_div_scalar_fmpq(gr_ptr vec1, gr_srcptr vec2, slong len, const fmpq_t c, gr_ctx_t ctx) - int gr_generic_vec_divexact_scalar_fmpq(gr_ptr vec1, gr_srcptr vec2, slong len, const fmpq_t c, gr_ctx_t ctx) - int gr_generic_vec_pow_scalar_fmpq(gr_ptr vec1, gr_srcptr vec2, slong len, const fmpq_t c, gr_ctx_t ctx) - int gr_generic_scalar_add_vec(gr_ptr vec1, gr_srcptr c, gr_srcptr vec2, slong len, gr_ctx_t ctx) - int gr_generic_scalar_sub_vec(gr_ptr vec1, gr_srcptr c, gr_srcptr vec2, slong len, gr_ctx_t ctx) - int gr_generic_scalar_mul_vec(gr_ptr vec1, gr_srcptr c, gr_srcptr vec2, slong len, gr_ctx_t ctx) - int gr_generic_scalar_div_vec(gr_ptr vec1, gr_srcptr c, gr_srcptr vec2, slong len, gr_ctx_t ctx) - int gr_generic_scalar_divexact_vec(gr_ptr vec1, gr_srcptr c, gr_srcptr vec2, slong len, gr_ctx_t ctx) - int gr_generic_scalar_pow_vec(gr_ptr vec1, gr_srcptr c, gr_srcptr vec2, slong len, gr_ctx_t ctx) - int gr_generic_vec_add_other(gr_ptr vec1, gr_srcptr vec2, gr_srcptr vec3, gr_ctx_t ctx3, slong len, gr_ctx_t ctx) - int gr_generic_vec_sub_other(gr_ptr vec1, gr_srcptr vec2, gr_srcptr vec3, gr_ctx_t ctx3, slong len, gr_ctx_t ctx) - int gr_generic_vec_mul_other(gr_ptr vec1, gr_srcptr vec2, gr_srcptr vec3, gr_ctx_t ctx3, slong len, gr_ctx_t ctx) - int gr_generic_vec_div_other(gr_ptr vec1, gr_srcptr vec2, gr_srcptr vec3, gr_ctx_t ctx3, slong len, gr_ctx_t ctx) - int gr_generic_vec_divexact_other(gr_ptr vec1, gr_srcptr vec2, gr_srcptr vec3, gr_ctx_t ctx3, slong len, gr_ctx_t ctx) - int gr_generic_vec_pow_other(gr_ptr vec1, gr_srcptr vec2, gr_srcptr vec3, gr_ctx_t ctx3, slong len, gr_ctx_t ctx) - int gr_generic_other_add_vec(gr_ptr vec1, gr_srcptr vec2, gr_ctx_t ctx2, gr_srcptr vec3, slong len, gr_ctx_t ctx) - int gr_generic_other_sub_vec(gr_ptr vec1, gr_srcptr vec2, gr_ctx_t ctx2, gr_srcptr vec3, slong len, gr_ctx_t ctx) - int gr_generic_other_mul_vec(gr_ptr vec1, gr_srcptr vec2, gr_ctx_t ctx2, gr_srcptr vec3, slong len, gr_ctx_t ctx) - int gr_generic_other_div_vec(gr_ptr vec1, gr_srcptr vec2, gr_ctx_t ctx2, gr_srcptr vec3, slong len, gr_ctx_t ctx) - int gr_generic_other_divexact_vec(gr_ptr vec1, gr_srcptr vec2, gr_ctx_t ctx2, gr_srcptr vec3, slong len, gr_ctx_t ctx) - int gr_generic_other_pow_vec(gr_ptr vec1, gr_srcptr vec2, gr_ctx_t ctx2, gr_srcptr vec3, slong len, gr_ctx_t ctx) - int gr_generic_vec_add_scalar_other(gr_ptr vec1, gr_srcptr vec2, slong len, gr_srcptr c, gr_ctx_t cctx, gr_ctx_t ctx) - int gr_generic_vec_sub_scalar_other(gr_ptr vec1, gr_srcptr vec2, slong len, gr_srcptr c, gr_ctx_t cctx, gr_ctx_t ctx) - int gr_generic_vec_mul_scalar_other(gr_ptr vec1, gr_srcptr vec2, slong len, gr_srcptr c, gr_ctx_t cctx, gr_ctx_t ctx) - int gr_generic_vec_div_scalar_other(gr_ptr vec1, gr_srcptr vec2, slong len, gr_srcptr c, gr_ctx_t cctx, gr_ctx_t ctx) - int gr_generic_vec_divexact_scalar_other(gr_ptr vec1, gr_srcptr vec2, slong len, gr_srcptr c, gr_ctx_t cctx, gr_ctx_t ctx) - int gr_generic_vec_pow_scalar_other(gr_ptr vec1, gr_srcptr vec2, slong len, gr_srcptr c, gr_ctx_t cctx, gr_ctx_t ctx) - int gr_generic_scalar_other_add_vec(gr_ptr vec1, gr_srcptr c, gr_ctx_t cctx, gr_srcptr vec2, slong len, gr_ctx_t ctx) - int gr_generic_scalar_other_sub_vec(gr_ptr vec1, gr_srcptr c, gr_ctx_t cctx, gr_srcptr vec2, slong len, gr_ctx_t ctx) - int gr_generic_scalar_other_mul_vec(gr_ptr vec1, gr_srcptr c, gr_ctx_t cctx, gr_srcptr vec2, slong len, gr_ctx_t ctx) - int gr_generic_scalar_other_div_vec(gr_ptr vec1, gr_srcptr c, gr_ctx_t cctx, gr_srcptr vec2, slong len, gr_ctx_t ctx) - int gr_generic_scalar_other_divexact_vec(gr_ptr vec1, gr_srcptr c, gr_ctx_t cctx, gr_srcptr vec2, slong len, gr_ctx_t ctx) - int gr_generic_scalar_other_pow_vec(gr_ptr vec1, gr_srcptr c, gr_ctx_t cctx, gr_srcptr vec2, slong len, gr_ctx_t ctx) + int gr_generic_cmp(int * res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) noexcept + int gr_generic_cmpabs(int * res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) noexcept + int gr_generic_cmp_other(int * res, gr_srcptr x, gr_srcptr y, gr_ctx_t y_ctx, gr_ctx_t ctx) noexcept + int gr_generic_cmpabs_other(int * res, gr_srcptr x, gr_srcptr y, gr_ctx_t y_ctx, gr_ctx_t ctx) noexcept + + int gr_generic_bernoulli_ui(gr_ptr res, ulong n, gr_ctx_t ctx) noexcept + int gr_generic_bernoulli_fmpz(gr_ptr res, const fmpz_t n, gr_ctx_t ctx) noexcept + int gr_generic_bernoulli_vec(gr_ptr res, slong len, gr_ctx_t ctx) noexcept + int gr_generic_eulernum_ui(gr_ptr res, ulong n, gr_ctx_t ctx) noexcept + int gr_generic_eulernum_fmpz(gr_ptr res, const fmpz_t n, gr_ctx_t ctx) noexcept + int gr_generic_eulernum_vec(gr_ptr res, slong len, gr_ctx_t ctx) noexcept + int gr_generic_stirling_s1u_uiui(gr_ptr res, ulong x, ulong y, gr_ctx_t ctx) noexcept + int gr_generic_stirling_s1_uiui(gr_ptr res, ulong x, ulong y, gr_ctx_t ctx) noexcept + int gr_generic_stirling_s2_uiui(gr_ptr res, ulong x, ulong y, gr_ctx_t ctx) noexcept + int gr_generic_stirling_s1u_ui_vec(gr_ptr res, ulong x, slong len, gr_ctx_t ctx) noexcept + int gr_generic_stirling_s1_ui_vec(gr_ptr res, ulong x, slong len, gr_ctx_t ctx) noexcept + int gr_generic_stirling_s2_ui_vec(gr_ptr res, ulong x, slong len, gr_ctx_t ctx) noexcept + + void gr_generic_vec_init(gr_ptr vec, slong len, gr_ctx_t ctx) noexcept + + void gr_generic_vec_clear(gr_ptr vec, slong len, gr_ctx_t ctx) noexcept + + void gr_generic_vec_swap(gr_ptr vec1, gr_ptr vec2, slong len, gr_ctx_t ctx) noexcept + + int gr_generic_vec_zero(gr_ptr vec, slong len, gr_ctx_t ctx) noexcept + + int gr_generic_vec_set(gr_ptr res, gr_srcptr src, slong len, gr_ctx_t ctx) noexcept + + int gr_generic_vec_neg(gr_ptr res, gr_srcptr src, slong len, gr_ctx_t ctx) noexcept + + int gr_generic_vec_normalise(slong * res, gr_srcptr vec, slong len, gr_ctx_t ctx) noexcept + + slong gr_generic_vec_normalise_weak(gr_srcptr vec, slong len, gr_ctx_t ctx) noexcept + + int gr_generic_vec_mul_scalar_2exp_si(gr_ptr vec1, gr_srcptr vec2, slong len, slong c, gr_ctx_t ctx) noexcept + + int gr_generic_vec_scalar_addmul(gr_ptr vec1, gr_srcptr vec2, slong len, gr_srcptr c, gr_ctx_t ctx) noexcept + + int gr_generic_vec_scalar_submul(gr_ptr vec1, gr_srcptr vec2, slong len, gr_srcptr c, gr_ctx_t ctx) noexcept + + int gr_generic_vec_scalar_addmul_si(gr_ptr vec1, gr_srcptr vec2, slong len, slong c, gr_ctx_t ctx) noexcept + + int gr_generic_vec_scalar_submul_si(gr_ptr vec1, gr_srcptr vec2, slong len, slong c, gr_ctx_t ctx) noexcept + + truth_t gr_generic_vec_equal(gr_srcptr vec1, gr_srcptr vec2, slong len, gr_ctx_t ctx) noexcept + + bint gr_generic_vec_is_zero(gr_srcptr vec, slong len, gr_ctx_t ctx) noexcept + + int gr_generic_vec_dot(gr_ptr res, gr_srcptr initial, int subtract, gr_srcptr vec1, gr_srcptr vec2, slong len, gr_ctx_t ctx) noexcept + + int gr_generic_vec_dot_rev(gr_ptr res, gr_srcptr initial, int subtract, gr_srcptr vec1, gr_srcptr vec2, slong len, gr_ctx_t ctx) noexcept + + int gr_generic_vec_dot_ui(gr_ptr res, gr_srcptr initial, int subtract, gr_srcptr vec1, const ulong * vec2, slong len, gr_ctx_t ctx) noexcept + + int gr_generic_vec_dot_si(gr_ptr res, gr_srcptr initial, int subtract, gr_srcptr vec1, const slong * vec2, slong len, gr_ctx_t ctx) noexcept + + int gr_generic_vec_dot_fmpz(gr_ptr res, gr_srcptr initial, int subtract, gr_srcptr vec1, const fmpz * vec2, slong len, gr_ctx_t ctx) noexcept + + int gr_generic_vec_set_powers(gr_ptr res, gr_srcptr x, slong len, gr_ctx_t ctx) noexcept + + int gr_generic_vec_reciprocals(gr_ptr res, slong len, gr_ctx_t ctx) noexcept + + int gr_generic_vec_add(gr_ptr res, gr_srcptr src1, gr_srcptr src2, slong len, gr_ctx_t ctx) noexcept + int gr_generic_vec_sub(gr_ptr res, gr_srcptr src1, gr_srcptr src2, slong len, gr_ctx_t ctx) noexcept + int gr_generic_vec_mul(gr_ptr res, gr_srcptr src1, gr_srcptr src2, slong len, gr_ctx_t ctx) noexcept + int gr_generic_vec_div(gr_ptr res, gr_srcptr src1, gr_srcptr src2, slong len, gr_ctx_t ctx) noexcept + int gr_generic_vec_divexact(gr_ptr res, gr_srcptr src1, gr_srcptr src2, slong len, gr_ctx_t ctx) noexcept + int gr_generic_vec_pow(gr_ptr res, gr_srcptr src1, gr_srcptr src2, slong len, gr_ctx_t ctx) noexcept + int gr_generic_vec_add_scalar(gr_ptr vec1, gr_srcptr vec2, slong len, gr_srcptr c, gr_ctx_t ctx) noexcept + int gr_generic_vec_sub_scalar(gr_ptr vec1, gr_srcptr vec2, slong len, gr_srcptr c, gr_ctx_t ctx) noexcept + int gr_generic_vec_mul_scalar(gr_ptr vec1, gr_srcptr vec2, slong len, gr_srcptr c, gr_ctx_t ctx) noexcept + int gr_generic_vec_div_scalar(gr_ptr vec1, gr_srcptr vec2, slong len, gr_srcptr c, gr_ctx_t ctx) noexcept + int gr_generic_vec_divexact_scalar(gr_ptr vec1, gr_srcptr vec2, slong len, gr_srcptr c, gr_ctx_t ctx) noexcept + int gr_generic_vec_pow_scalar(gr_ptr vec1, gr_srcptr vec2, slong len, gr_srcptr c, gr_ctx_t ctx) noexcept + int gr_generic_vec_add_scalar_si(gr_ptr vec1, gr_srcptr vec2, slong len, slong c, gr_ctx_t ctx) noexcept + int gr_generic_vec_sub_scalar_si(gr_ptr vec1, gr_srcptr vec2, slong len, slong c, gr_ctx_t ctx) noexcept + int gr_generic_vec_mul_scalar_si(gr_ptr vec1, gr_srcptr vec2, slong len, slong c, gr_ctx_t ctx) noexcept + int gr_generic_vec_div_scalar_si(gr_ptr vec1, gr_srcptr vec2, slong len, slong c, gr_ctx_t ctx) noexcept + int gr_generic_vec_divexact_scalar_si(gr_ptr vec1, gr_srcptr vec2, slong len, slong c, gr_ctx_t ctx) noexcept + int gr_generic_vec_pow_scalar_si(gr_ptr vec1, gr_srcptr vec2, slong len, slong c, gr_ctx_t ctx) noexcept + int gr_generic_vec_add_scalar_ui(gr_ptr vec1, gr_srcptr vec2, slong len, ulong c, gr_ctx_t ctx) noexcept + int gr_generic_vec_sub_scalar_ui(gr_ptr vec1, gr_srcptr vec2, slong len, ulong c, gr_ctx_t ctx) noexcept + int gr_generic_vec_mul_scalar_ui(gr_ptr vec1, gr_srcptr vec2, slong len, ulong c, gr_ctx_t ctx) noexcept + int gr_generic_vec_div_scalar_ui(gr_ptr vec1, gr_srcptr vec2, slong len, ulong c, gr_ctx_t ctx) noexcept + int gr_generic_vec_divexact_scalar_ui(gr_ptr vec1, gr_srcptr vec2, slong len, ulong c, gr_ctx_t ctx) noexcept + int gr_generic_vec_pow_scalar_ui(gr_ptr vec1, gr_srcptr vec2, slong len, ulong c, gr_ctx_t ctx) noexcept + int gr_generic_vec_add_scalar_fmpz(gr_ptr vec1, gr_srcptr vec2, slong len, const fmpz_t c, gr_ctx_t ctx) noexcept + int gr_generic_vec_sub_scalar_fmpz(gr_ptr vec1, gr_srcptr vec2, slong len, const fmpz_t c, gr_ctx_t ctx) noexcept + int gr_generic_vec_mul_scalar_fmpz(gr_ptr vec1, gr_srcptr vec2, slong len, const fmpz_t c, gr_ctx_t ctx) noexcept + int gr_generic_vec_div_scalar_fmpz(gr_ptr vec1, gr_srcptr vec2, slong len, const fmpz_t c, gr_ctx_t ctx) noexcept + int gr_generic_vec_divexact_scalar_fmpz(gr_ptr vec1, gr_srcptr vec2, slong len, const fmpz_t c, gr_ctx_t ctx) noexcept + int gr_generic_vec_pow_scalar_fmpz(gr_ptr vec1, gr_srcptr vec2, slong len, const fmpz_t c, gr_ctx_t ctx) noexcept + int gr_generic_vec_add_scalar_fmpq(gr_ptr vec1, gr_srcptr vec2, slong len, const fmpq_t c, gr_ctx_t ctx) noexcept + int gr_generic_vec_sub_scalar_fmpq(gr_ptr vec1, gr_srcptr vec2, slong len, const fmpq_t c, gr_ctx_t ctx) noexcept + int gr_generic_vec_mul_scalar_fmpq(gr_ptr vec1, gr_srcptr vec2, slong len, const fmpq_t c, gr_ctx_t ctx) noexcept + int gr_generic_vec_div_scalar_fmpq(gr_ptr vec1, gr_srcptr vec2, slong len, const fmpq_t c, gr_ctx_t ctx) noexcept + int gr_generic_vec_divexact_scalar_fmpq(gr_ptr vec1, gr_srcptr vec2, slong len, const fmpq_t c, gr_ctx_t ctx) noexcept + int gr_generic_vec_pow_scalar_fmpq(gr_ptr vec1, gr_srcptr vec2, slong len, const fmpq_t c, gr_ctx_t ctx) noexcept + int gr_generic_scalar_add_vec(gr_ptr vec1, gr_srcptr c, gr_srcptr vec2, slong len, gr_ctx_t ctx) noexcept + int gr_generic_scalar_sub_vec(gr_ptr vec1, gr_srcptr c, gr_srcptr vec2, slong len, gr_ctx_t ctx) noexcept + int gr_generic_scalar_mul_vec(gr_ptr vec1, gr_srcptr c, gr_srcptr vec2, slong len, gr_ctx_t ctx) noexcept + int gr_generic_scalar_div_vec(gr_ptr vec1, gr_srcptr c, gr_srcptr vec2, slong len, gr_ctx_t ctx) noexcept + int gr_generic_scalar_divexact_vec(gr_ptr vec1, gr_srcptr c, gr_srcptr vec2, slong len, gr_ctx_t ctx) noexcept + int gr_generic_scalar_pow_vec(gr_ptr vec1, gr_srcptr c, gr_srcptr vec2, slong len, gr_ctx_t ctx) noexcept + int gr_generic_vec_add_other(gr_ptr vec1, gr_srcptr vec2, gr_srcptr vec3, gr_ctx_t ctx3, slong len, gr_ctx_t ctx) noexcept + int gr_generic_vec_sub_other(gr_ptr vec1, gr_srcptr vec2, gr_srcptr vec3, gr_ctx_t ctx3, slong len, gr_ctx_t ctx) noexcept + int gr_generic_vec_mul_other(gr_ptr vec1, gr_srcptr vec2, gr_srcptr vec3, gr_ctx_t ctx3, slong len, gr_ctx_t ctx) noexcept + int gr_generic_vec_div_other(gr_ptr vec1, gr_srcptr vec2, gr_srcptr vec3, gr_ctx_t ctx3, slong len, gr_ctx_t ctx) noexcept + int gr_generic_vec_divexact_other(gr_ptr vec1, gr_srcptr vec2, gr_srcptr vec3, gr_ctx_t ctx3, slong len, gr_ctx_t ctx) noexcept + int gr_generic_vec_pow_other(gr_ptr vec1, gr_srcptr vec2, gr_srcptr vec3, gr_ctx_t ctx3, slong len, gr_ctx_t ctx) noexcept + int gr_generic_other_add_vec(gr_ptr vec1, gr_srcptr vec2, gr_ctx_t ctx2, gr_srcptr vec3, slong len, gr_ctx_t ctx) noexcept + int gr_generic_other_sub_vec(gr_ptr vec1, gr_srcptr vec2, gr_ctx_t ctx2, gr_srcptr vec3, slong len, gr_ctx_t ctx) noexcept + int gr_generic_other_mul_vec(gr_ptr vec1, gr_srcptr vec2, gr_ctx_t ctx2, gr_srcptr vec3, slong len, gr_ctx_t ctx) noexcept + int gr_generic_other_div_vec(gr_ptr vec1, gr_srcptr vec2, gr_ctx_t ctx2, gr_srcptr vec3, slong len, gr_ctx_t ctx) noexcept + int gr_generic_other_divexact_vec(gr_ptr vec1, gr_srcptr vec2, gr_ctx_t ctx2, gr_srcptr vec3, slong len, gr_ctx_t ctx) noexcept + int gr_generic_other_pow_vec(gr_ptr vec1, gr_srcptr vec2, gr_ctx_t ctx2, gr_srcptr vec3, slong len, gr_ctx_t ctx) noexcept + int gr_generic_vec_add_scalar_other(gr_ptr vec1, gr_srcptr vec2, slong len, gr_srcptr c, gr_ctx_t cctx, gr_ctx_t ctx) noexcept + int gr_generic_vec_sub_scalar_other(gr_ptr vec1, gr_srcptr vec2, slong len, gr_srcptr c, gr_ctx_t cctx, gr_ctx_t ctx) noexcept + int gr_generic_vec_mul_scalar_other(gr_ptr vec1, gr_srcptr vec2, slong len, gr_srcptr c, gr_ctx_t cctx, gr_ctx_t ctx) noexcept + int gr_generic_vec_div_scalar_other(gr_ptr vec1, gr_srcptr vec2, slong len, gr_srcptr c, gr_ctx_t cctx, gr_ctx_t ctx) noexcept + int gr_generic_vec_divexact_scalar_other(gr_ptr vec1, gr_srcptr vec2, slong len, gr_srcptr c, gr_ctx_t cctx, gr_ctx_t ctx) noexcept + int gr_generic_vec_pow_scalar_other(gr_ptr vec1, gr_srcptr vec2, slong len, gr_srcptr c, gr_ctx_t cctx, gr_ctx_t ctx) noexcept + int gr_generic_scalar_other_add_vec(gr_ptr vec1, gr_srcptr c, gr_ctx_t cctx, gr_srcptr vec2, slong len, gr_ctx_t ctx) noexcept + int gr_generic_scalar_other_sub_vec(gr_ptr vec1, gr_srcptr c, gr_ctx_t cctx, gr_srcptr vec2, slong len, gr_ctx_t ctx) noexcept + int gr_generic_scalar_other_mul_vec(gr_ptr vec1, gr_srcptr c, gr_ctx_t cctx, gr_srcptr vec2, slong len, gr_ctx_t ctx) noexcept + int gr_generic_scalar_other_div_vec(gr_ptr vec1, gr_srcptr c, gr_ctx_t cctx, gr_srcptr vec2, slong len, gr_ctx_t ctx) noexcept + int gr_generic_scalar_other_divexact_vec(gr_ptr vec1, gr_srcptr c, gr_ctx_t cctx, gr_srcptr vec2, slong len, gr_ctx_t ctx) noexcept + int gr_generic_scalar_other_pow_vec(gr_ptr vec1, gr_srcptr c, gr_ctx_t cctx, gr_srcptr vec2, slong len, gr_ctx_t ctx) noexcept diff --git a/src/sage/libs/flint/gr_mat.pxd b/src/sage/libs/flint/gr_mat.pxd index 5d42e52d699..02b2570fabd 100644 --- a/src/sage/libs/flint/gr_mat.pxd +++ b/src/sage/libs/flint/gr_mat.pxd @@ -12,159 +12,159 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - gr_ptr gr_mat_entry_ptr(gr_mat_t mat, slong i, slong j, gr_ctx_t ctx) + gr_ptr gr_mat_entry_ptr(gr_mat_t mat, slong i, slong j, gr_ctx_t ctx) noexcept # Function returning a pointer to the entry at row *i* and column # *j* of the matrix *mat*. The indices must be in bounds. - void gr_mat_init(gr_mat_t mat, slong rows, slong cols, gr_ctx_t ctx) + void gr_mat_init(gr_mat_t mat, slong rows, slong cols, gr_ctx_t ctx) noexcept # Initializes *mat* to a matrix with the given number of rows and # columns. - int gr_mat_init_set(gr_mat_t res, const gr_mat_t mat, gr_ctx_t ctx) + int gr_mat_init_set(gr_mat_t res, const gr_mat_t mat, gr_ctx_t ctx) noexcept # Initializes *res* to a copy of the matrix *mat*. - void gr_mat_clear(gr_mat_t mat, gr_ctx_t ctx) + void gr_mat_clear(gr_mat_t mat, gr_ctx_t ctx) noexcept # Clears the matrix. - void gr_mat_swap(gr_mat_t mat1, gr_mat_t mat2, gr_ctx_t ctx) + void gr_mat_swap(gr_mat_t mat1, gr_mat_t mat2, gr_ctx_t ctx) noexcept # Swaps *mat1* and *mat12* efficiently. - int gr_mat_swap_entrywise(gr_mat_t mat1, const gr_mat_t mat2, gr_ctx_t ctx) + int gr_mat_swap_entrywise(gr_mat_t mat1, const gr_mat_t mat2, gr_ctx_t ctx) noexcept # Performs a deep swap of *mat1* and *mat2*, swapping the individual # entries rather than the top-level structures. - void gr_mat_window_init(gr_mat_t window, const gr_mat_t mat, slong r1, slong c1, slong r2, slong c2, gr_ctx_t ctx) + void gr_mat_window_init(gr_mat_t window, const gr_mat_t mat, slong r1, slong c1, slong r2, slong c2, gr_ctx_t ctx) noexcept # Initializes *window* to a window matrix into the submatrix of *mat* # starting at the corner at row *r1* and column *c1* (inclusive) and ending # at row *r2* and column *c2* (exclusive). # The indices must be within bounds. - void gr_mat_window_clear(gr_mat_t window, gr_ctx_t ctx) + void gr_mat_window_clear(gr_mat_t window, gr_ctx_t ctx) noexcept # Frees the window matrix. - int gr_mat_write(gr_stream_t out, const gr_mat_t mat, gr_ctx_t ctx) + int gr_mat_write(gr_stream_t out, const gr_mat_t mat, gr_ctx_t ctx) noexcept # Write *mat* to the stream *out*. - int gr_mat_print(const gr_mat_t mat, gr_ctx_t ctx) + int gr_mat_print(const gr_mat_t mat, gr_ctx_t ctx) noexcept # Prints *mat* to standard output. - truth_t gr_mat_equal(const gr_mat_t mat1, const gr_mat_t mat2, gr_ctx_t ctx) + truth_t gr_mat_equal(const gr_mat_t mat1, const gr_mat_t mat2, gr_ctx_t ctx) noexcept # Returns whether *mat1* and *mat2* are equal. - truth_t gr_mat_is_zero(const gr_mat_t mat, gr_ctx_t ctx) - truth_t gr_mat_is_one(const gr_mat_t mat, gr_ctx_t ctx) - truth_t gr_mat_is_neg_one(const gr_mat_t mat, gr_ctx_t ctx) + truth_t gr_mat_is_zero(const gr_mat_t mat, gr_ctx_t ctx) noexcept + truth_t gr_mat_is_one(const gr_mat_t mat, gr_ctx_t ctx) noexcept + truth_t gr_mat_is_neg_one(const gr_mat_t mat, gr_ctx_t ctx) noexcept # Returns whether *mat* respectively is the zero matrix or # the scalar matrix with 1 or -1 on the main diagonal. - truth_t gr_mat_is_scalar(const gr_mat_t mat, gr_ctx_t ctx) + truth_t gr_mat_is_scalar(const gr_mat_t mat, gr_ctx_t ctx) noexcept # Returns whether *mat* is a scalar matrix, being a diagonal matrix # with identical elements on the main diagonal. - int gr_mat_zero(gr_mat_t res, gr_ctx_t ctx) + int gr_mat_zero(gr_mat_t res, gr_ctx_t ctx) noexcept # Sets *res* to the zero matrix. - int gr_mat_one(gr_mat_t res, gr_ctx_t ctx) + int gr_mat_one(gr_mat_t res, gr_ctx_t ctx) noexcept # Sets *res* to the scalar matrix with 1 on the main diagonal # and zero elsewhere. - int gr_mat_set(gr_mat_t res, const gr_mat_t mat, gr_ctx_t ctx) - int gr_mat_set_fmpz_mat(gr_mat_t res, const fmpz_mat_t mat, gr_ctx_t ctx) - int gr_mat_set_fmpq_mat(gr_mat_t res, const fmpq_mat_t mat, gr_ctx_t ctx) + int gr_mat_set(gr_mat_t res, const gr_mat_t mat, gr_ctx_t ctx) noexcept + int gr_mat_set_fmpz_mat(gr_mat_t res, const fmpz_mat_t mat, gr_ctx_t ctx) noexcept + int gr_mat_set_fmpq_mat(gr_mat_t res, const fmpq_mat_t mat, gr_ctx_t ctx) noexcept # Sets *res* to the value of *mat*. - int gr_mat_set_scalar(gr_mat_t res, gr_srcptr c, gr_ctx_t ctx) - int gr_mat_set_ui(gr_mat_t res, ulong c, gr_ctx_t ctx) - int gr_mat_set_si(gr_mat_t res, slong c, gr_ctx_t ctx) - int gr_mat_set_fmpz(gr_mat_t res, const fmpz_t c, gr_ctx_t ctx) - int gr_mat_set_fmpq(gr_mat_t res, const fmpq_t c, gr_ctx_t ctx) + int gr_mat_set_scalar(gr_mat_t res, gr_srcptr c, gr_ctx_t ctx) noexcept + int gr_mat_set_ui(gr_mat_t res, ulong c, gr_ctx_t ctx) noexcept + int gr_mat_set_si(gr_mat_t res, slong c, gr_ctx_t ctx) noexcept + int gr_mat_set_fmpz(gr_mat_t res, const fmpz_t c, gr_ctx_t ctx) noexcept + int gr_mat_set_fmpq(gr_mat_t res, const fmpq_t c, gr_ctx_t ctx) noexcept # Set *res* to the scalar matrix with *c* on the main diagonal # and zero elsewhere. - int gr_mat_concat_horizontal(gr_mat_t res, const gr_mat_t mat1, const gr_mat_t mat2, gr_ctx_t ctx) + int gr_mat_concat_horizontal(gr_mat_t res, const gr_mat_t mat1, const gr_mat_t mat2, gr_ctx_t ctx) noexcept - int gr_mat_concat_vertical(gr_mat_t res, const gr_mat_t mat1, const gr_mat_t mat2, gr_ctx_t ctx) + int gr_mat_concat_vertical(gr_mat_t res, const gr_mat_t mat1, const gr_mat_t mat2, gr_ctx_t ctx) noexcept - int gr_mat_transpose(gr_mat_t B, const gr_mat_t A, gr_ctx_t ctx) + int gr_mat_transpose(gr_mat_t B, const gr_mat_t A, gr_ctx_t ctx) noexcept # Sets *B* to the transpose of *A*. - int gr_mat_swap_rows(gr_mat_t mat, slong * perm, slong r, slong s, gr_ctx_t ctx) + int gr_mat_swap_rows(gr_mat_t mat, slong * perm, slong r, slong s, gr_ctx_t ctx) noexcept # Swaps rows ``r`` and ``s`` of ``mat``. If ``perm`` is non-``NULL``, the # permutation of the rows will also be applied to ``perm``. - int gr_mat_swap_cols(gr_mat_t mat, slong * perm, slong r, slong s, gr_ctx_t ctx) + int gr_mat_swap_cols(gr_mat_t mat, slong * perm, slong r, slong s, gr_ctx_t ctx) noexcept # Swaps columns ``r`` and ``s`` of ``mat``. If ``perm`` is non-``NULL``, the # permutation of the columns will also be applied to ``perm``. - int gr_mat_invert_rows(gr_mat_t mat, slong * perm, gr_ctx_t ctx) + int gr_mat_invert_rows(gr_mat_t mat, slong * perm, gr_ctx_t ctx) noexcept # Swaps rows ``i`` and ``r - i`` of ``mat`` for ``0 <= i < r/2``, where # ``r`` is the number of rows of ``mat``. If ``perm`` is non-``NULL``, the # permutation of the rows will also be applied to ``perm``. - int gr_mat_invert_cols(gr_mat_t mat, slong * perm, gr_ctx_t ctx) + int gr_mat_invert_cols(gr_mat_t mat, slong * perm, gr_ctx_t ctx) noexcept # Swaps columns ``i`` and ``c - i`` of ``mat`` for ``0 <= i < c/2``, where # ``c`` is the number of columns of ``mat``. If ``perm`` is non-``NULL``, the # permutation of the columns will also be applied to ``perm``. - truth_t gr_mat_is_empty(const gr_mat_t mat, gr_ctx_t ctx) + truth_t gr_mat_is_empty(const gr_mat_t mat, gr_ctx_t ctx) noexcept # Returns whether *mat* is an empty matrix, having either zero # rows or zero column. This predicate is always decidable (even if # the underlying ring is not computable), returning # ``T_TRUE`` or ``T_FALSE``. - truth_t gr_mat_is_square(const gr_mat_t mat, gr_ctx_t ctx) + truth_t gr_mat_is_square(const gr_mat_t mat, gr_ctx_t ctx) noexcept # Returns whether *mat* is a square matrix, having the same number # of rows as columns (not the same thing as being a perfect square!). # This predicate is always decidable (even if the underlying ring # is not computable), returning ``T_TRUE`` or ``T_FALSE``. - int gr_mat_neg(gr_mat_t res, const gr_mat_t mat, gr_ctx_t ctx) + int gr_mat_neg(gr_mat_t res, const gr_mat_t mat, gr_ctx_t ctx) noexcept - int gr_mat_add(gr_mat_t res, const gr_mat_t mat1, const gr_mat_t mat2, gr_ctx_t ctx) + int gr_mat_add(gr_mat_t res, const gr_mat_t mat1, const gr_mat_t mat2, gr_ctx_t ctx) noexcept - int gr_mat_sub(gr_mat_t res, const gr_mat_t mat1, const gr_mat_t mat2, gr_ctx_t ctx) + int gr_mat_sub(gr_mat_t res, const gr_mat_t mat1, const gr_mat_t mat2, gr_ctx_t ctx) noexcept - int gr_mat_mul_classical(gr_mat_t res, const gr_mat_t mat1, const gr_mat_t mat2, gr_ctx_t ctx) - int gr_mat_mul_strassen(gr_mat_t C, const gr_mat_t A, const gr_mat_t B, gr_ctx_t ctx); - int gr_mat_mul_generic(gr_mat_t C, const gr_mat_t A, const gr_mat_t B, gr_ctx_t ctx) - int gr_mat_mul(gr_mat_t res, const gr_mat_t mat1, const gr_mat_t mat2, gr_ctx_t ctx) + int gr_mat_mul_classical(gr_mat_t res, const gr_mat_t mat1, const gr_mat_t mat2, gr_ctx_t ctx) noexcept + int gr_mat_mul_strassen(gr_mat_t C, const gr_mat_t A, const gr_mat_t B, gr_ctx_t ctx) noexcept + int gr_mat_mul_generic(gr_mat_t C, const gr_mat_t A, const gr_mat_t B, gr_ctx_t ctx) noexcept + int gr_mat_mul(gr_mat_t res, const gr_mat_t mat1, const gr_mat_t mat2, gr_ctx_t ctx) noexcept # Matrix multiplication. The default function can be overloaded by specific rings; # otherwise, it falls back to :func:`gr_mat_mul_generic` which currently # only performs classical multiplication. - int gr_mat_sqr(gr_mat_t res, const gr_mat_t mat, gr_ctx_t ctx) + int gr_mat_sqr(gr_mat_t res, const gr_mat_t mat, gr_ctx_t ctx) noexcept - int gr_mat_add_scalar(gr_mat_t res, const gr_mat_t mat, gr_srcptr c, gr_ctx_t ctx) - int gr_mat_sub_scalar(gr_mat_t res, const gr_mat_t mat, gr_srcptr c, gr_ctx_t ctx) - int gr_mat_mul_scalar(gr_mat_t res, const gr_mat_t mat, gr_srcptr c, gr_ctx_t ctx) - int gr_mat_addmul_scalar(gr_mat_t res, const gr_mat_t mat, gr_srcptr c, gr_ctx_t ctx) - int gr_mat_submul_scalar(gr_mat_t res, const gr_mat_t mat, gr_srcptr c, gr_ctx_t ctx) - int gr_mat_div_scalar(gr_mat_t res, const gr_mat_t mat, gr_srcptr c, gr_ctx_t ctx) + int gr_mat_add_scalar(gr_mat_t res, const gr_mat_t mat, gr_srcptr c, gr_ctx_t ctx) noexcept + int gr_mat_sub_scalar(gr_mat_t res, const gr_mat_t mat, gr_srcptr c, gr_ctx_t ctx) noexcept + int gr_mat_mul_scalar(gr_mat_t res, const gr_mat_t mat, gr_srcptr c, gr_ctx_t ctx) noexcept + int gr_mat_addmul_scalar(gr_mat_t res, const gr_mat_t mat, gr_srcptr c, gr_ctx_t ctx) noexcept + int gr_mat_submul_scalar(gr_mat_t res, const gr_mat_t mat, gr_srcptr c, gr_ctx_t ctx) noexcept + int gr_mat_div_scalar(gr_mat_t res, const gr_mat_t mat, gr_srcptr c, gr_ctx_t ctx) noexcept - int _gr_mat_gr_poly_evaluate(gr_mat_t res, gr_srcptr poly, slong len, const gr_mat_t mat, gr_ctx_t ctx) - int gr_mat_gr_poly_evaluate(gr_mat_t res, const gr_poly_t poly, const gr_mat_t mat, gr_ctx_t ctx) + int _gr_mat_gr_poly_evaluate(gr_mat_t res, gr_srcptr poly, slong len, const gr_mat_t mat, gr_ctx_t ctx) noexcept + int gr_mat_gr_poly_evaluate(gr_mat_t res, const gr_poly_t poly, const gr_mat_t mat, gr_ctx_t ctx) noexcept # Sets *res* to the matrix obtained by evaluating the # scalar polynomial *poly* with matrix argument *mat*. - truth_t gr_mat_is_upper_triangular(const gr_mat_t mat, gr_ctx_t ctx) - truth_t gr_mat_is_lower_triangular(const gr_mat_t mat, gr_ctx_t ctx) + truth_t gr_mat_is_upper_triangular(const gr_mat_t mat, gr_ctx_t ctx) noexcept + truth_t gr_mat_is_lower_triangular(const gr_mat_t mat, gr_ctx_t ctx) noexcept # Returns whether *mat* is upper (respectively lower) triangular, having # zeros everywhere below (respectively above) the main diagonal. # The matrix need not be square. - truth_t gr_mat_is_diagonal(const gr_mat_t mat, gr_ctx_t ctx) + truth_t gr_mat_is_diagonal(const gr_mat_t mat, gr_ctx_t ctx) noexcept # Returns whether *mat* is a diagonal matrix, having zeros everywhere # except on the main diagonal. # The matrix need not be square. - int gr_mat_mul_diag(gr_mat_t res, const gr_mat_t A, const gr_vec_t D, gr_ctx_t ctx) - int gr_mat_diag_mul(gr_mat_t res, const gr_vec_t D, const gr_mat_t A, gr_ctx_t ctx) + int gr_mat_mul_diag(gr_mat_t res, const gr_mat_t A, const gr_vec_t D, gr_ctx_t ctx) noexcept + int gr_mat_diag_mul(gr_mat_t res, const gr_vec_t D, const gr_mat_t A, gr_ctx_t ctx) noexcept # Set *res* to the product `AD` or `DA` respectively, where `D` is # a diagonal matrix represented as a vector of entries. - int gr_mat_find_nonzero_pivot_large_abs(slong * pivot_row, gr_mat_t mat, slong start_row, slong end_row, slong column, gr_ctx_t ctx) - int gr_mat_find_nonzero_pivot_generic(slong * pivot_row, gr_mat_t mat, slong start_row, slong end_row, slong column, gr_ctx_t ctx) - int gr_mat_find_nonzero_pivot(slong * pivot_row, gr_mat_t mat, slong start_row, slong end_row, slong column, gr_ctx_t ctx) + int gr_mat_find_nonzero_pivot_large_abs(slong * pivot_row, gr_mat_t mat, slong start_row, slong end_row, slong column, gr_ctx_t ctx) noexcept + int gr_mat_find_nonzero_pivot_generic(slong * pivot_row, gr_mat_t mat, slong start_row, slong end_row, slong column, gr_ctx_t ctx) noexcept + int gr_mat_find_nonzero_pivot(slong * pivot_row, gr_mat_t mat, slong start_row, slong end_row, slong column, gr_ctx_t ctx) noexcept # Attempts to find a nonzero element in column number *column* # of the matrix *mat* in a row between *start_row* (inclusive) # and *end_row* (exclusive). @@ -175,9 +175,9 @@ cdef extern from "flint_wrap.h": # This function may be destructive: any elements that are nontrivially # zero but can be certified zero may be overwritten by exact zeros. - int gr_mat_lu_classical(slong * rank, slong * P, gr_mat_t LU, const gr_mat_t A, int rank_check, gr_ctx_t ctx) - int gr_mat_lu_recursive(slong * rank, slong * P, gr_mat_t LU, const gr_mat_t A, int rank_check, gr_ctx_t ctx) - int gr_mat_lu(slong * rank, slong * P, gr_mat_t LU, const gr_mat_t A, int rank_check, gr_ctx_t ctx) + int gr_mat_lu_classical(slong * rank, slong * P, gr_mat_t LU, const gr_mat_t A, int rank_check, gr_ctx_t ctx) noexcept + int gr_mat_lu_recursive(slong * rank, slong * P, gr_mat_t LU, const gr_mat_t A, int rank_check, gr_ctx_t ctx) noexcept + int gr_mat_lu(slong * rank, slong * P, gr_mat_t LU, const gr_mat_t A, int rank_check, gr_ctx_t ctx) noexcept # Computes a generalized LU decomposition `A = PLU` of a given # matrix *A*, writing the rank of *A* to *rank*. # If *A* is a nonsingular square matrix, *LU* will be set to @@ -204,17 +204,17 @@ cdef extern from "flint_wrap.h": # The *recursive* version uses a block recursive algorithm # to take advantage of fast matrix multiplication. - int gr_mat_fflu(slong * rank, slong * P, gr_mat_t LU, gr_ptr den, const gr_mat_t A, int rank_check, gr_ctx_t ctx) + int gr_mat_fflu(slong * rank, slong * P, gr_mat_t LU, gr_ptr den, const gr_mat_t A, int rank_check, gr_ctx_t ctx) noexcept # Similar to :func:`gr_mat_lu`, but computes a fraction-free # LU decomposition using the Bareiss algorithm. # The denominator is written to *den*. - int gr_mat_nonsingular_solve_tril_classical(gr_mat_t X, const gr_mat_t L, const gr_mat_t B, int unit, gr_ctx_t ctx) - int gr_mat_nonsingular_solve_tril_recursive(gr_mat_t X, const gr_mat_t L, const gr_mat_t B, int unit, gr_ctx_t ctx) - int gr_mat_nonsingular_solve_tril(gr_mat_t X, const gr_mat_t L, const gr_mat_t B, int unit, gr_ctx_t ctx) - int gr_mat_nonsingular_solve_triu_classical(gr_mat_t X, const gr_mat_t U, const gr_mat_t B, int unit, gr_ctx_t ctx) - int gr_mat_nonsingular_solve_triu_recursive(gr_mat_t X, const gr_mat_t U, const gr_mat_t B, int unit, gr_ctx_t ctx) - int gr_mat_nonsingular_solve_triu(gr_mat_t X, const gr_mat_t U, const gr_mat_t B, int unit, gr_ctx_t ctx) + int gr_mat_nonsingular_solve_tril_classical(gr_mat_t X, const gr_mat_t L, const gr_mat_t B, int unit, gr_ctx_t ctx) noexcept + int gr_mat_nonsingular_solve_tril_recursive(gr_mat_t X, const gr_mat_t L, const gr_mat_t B, int unit, gr_ctx_t ctx) noexcept + int gr_mat_nonsingular_solve_tril(gr_mat_t X, const gr_mat_t L, const gr_mat_t B, int unit, gr_ctx_t ctx) noexcept + int gr_mat_nonsingular_solve_triu_classical(gr_mat_t X, const gr_mat_t U, const gr_mat_t B, int unit, gr_ctx_t ctx) noexcept + int gr_mat_nonsingular_solve_triu_recursive(gr_mat_t X, const gr_mat_t U, const gr_mat_t B, int unit, gr_ctx_t ctx) noexcept + int gr_mat_nonsingular_solve_triu(gr_mat_t X, const gr_mat_t U, const gr_mat_t B, int unit, gr_ctx_t ctx) noexcept # Solves the lower triangular system `LX = B` or the upper triangular system # `UX = B`, respectively. Division by the the diagonal entries must # be possible; if not a division fails, ``GR_DOMAIN`` is returned @@ -227,38 +227,38 @@ cdef extern from "flint_wrap.h": # way to benefit from fast matrix multiplication. The default versions # choose an algorithm automatically. - int gr_mat_nonsingular_solve_fflu(gr_mat_t X, const gr_mat_t A, const gr_mat_t B, gr_ctx_t ctx) - int gr_mat_nonsingular_solve_lu(gr_mat_t X, const gr_mat_t A, const gr_mat_t B, gr_ctx_t ctx) - int gr_mat_nonsingular_solve(gr_mat_t X, const gr_mat_t A, const gr_mat_t B, gr_ctx_t ctx) + int gr_mat_nonsingular_solve_fflu(gr_mat_t X, const gr_mat_t A, const gr_mat_t B, gr_ctx_t ctx) noexcept + int gr_mat_nonsingular_solve_lu(gr_mat_t X, const gr_mat_t A, const gr_mat_t B, gr_ctx_t ctx) noexcept + int gr_mat_nonsingular_solve(gr_mat_t X, const gr_mat_t A, const gr_mat_t B, gr_ctx_t ctx) noexcept # Solves `AX = B`. If *A* is not invertible, # returns ``GR_DOMAIN`` even if the system has a solution. - int gr_mat_nonsingular_solve_fflu_precomp(gr_mat_t X, const slong * perm, const gr_mat_t LU, const gr_mat_t B, gr_ctx_t ctx) - int gr_mat_nonsingular_solve_lu_precomp(gr_mat_t X, const slong * perm, const gr_mat_t LU, const gr_mat_t B, gr_ctx_t ctx) + int gr_mat_nonsingular_solve_fflu_precomp(gr_mat_t X, const slong * perm, const gr_mat_t LU, const gr_mat_t B, gr_ctx_t ctx) noexcept + int gr_mat_nonsingular_solve_lu_precomp(gr_mat_t X, const slong * perm, const gr_mat_t LU, const gr_mat_t B, gr_ctx_t ctx) noexcept # Solves `AX = B` given a precomputed FFLU or LU factorization of *A*. - int gr_mat_nonsingular_solve_den_fflu(gr_mat_t X, gr_ptr den, const gr_mat_t A, const gr_mat_t B, gr_ctx_t ctx) - int gr_mat_nonsingular_solve_den(gr_mat_t X, gr_ptr den, const gr_mat_t A, const gr_mat_t B, gr_ctx_t ctx) + int gr_mat_nonsingular_solve_den_fflu(gr_mat_t X, gr_ptr den, const gr_mat_t A, const gr_mat_t B, gr_ctx_t ctx) noexcept + int gr_mat_nonsingular_solve_den(gr_mat_t X, gr_ptr den, const gr_mat_t A, const gr_mat_t B, gr_ctx_t ctx) noexcept # Solves `AX = B` over the fraction field of the present ring # (assumed to be an integral domain), returning `X` with # an implied denominator *den*. # If *A* is not invertible over the fraction field, returns # ``GR_DOMAIN`` even if the system has a solution. - int gr_mat_solve_field(gr_mat_t X, const gr_mat_t A, const gr_mat_t B, gr_ctx_t ctx) + int gr_mat_solve_field(gr_mat_t X, const gr_mat_t A, const gr_mat_t B, gr_ctx_t ctx) noexcept # Solves `AX = B` where *A* is not necessarily square and not necessarily # invertible. Assuming that the ring is a field, a return value of # ``GR_DOMAIN`` indicates that the system has no solution. # If there are multiple solutions, an arbitrary solution is returned. - int gr_mat_det_fflu(gr_ptr res, const gr_mat_t mat, gr_ctx_t ctx) - int gr_mat_det_berkowitz(gr_ptr res, const gr_mat_t mat, gr_ctx_t ctx) - int gr_mat_det_lu(gr_ptr res, const gr_mat_t mat, gr_ctx_t ctx) - int gr_mat_det_cofactor(gr_ptr res, const gr_mat_t mat, gr_ctx_t ctx) - int gr_mat_det_generic_field(gr_ptr res, const gr_mat_t A, gr_ctx_t ctx) - int gr_mat_det_generic_integral_domain(gr_ptr res, const gr_mat_t A, gr_ctx_t ctx) - int gr_mat_det_generic(gr_ptr res, const gr_mat_t A, gr_ctx_t ctx) - int gr_mat_det(gr_ptr res, const gr_mat_t mat, gr_ctx_t ctx) + int gr_mat_det_fflu(gr_ptr res, const gr_mat_t mat, gr_ctx_t ctx) noexcept + int gr_mat_det_berkowitz(gr_ptr res, const gr_mat_t mat, gr_ctx_t ctx) noexcept + int gr_mat_det_lu(gr_ptr res, const gr_mat_t mat, gr_ctx_t ctx) noexcept + int gr_mat_det_cofactor(gr_ptr res, const gr_mat_t mat, gr_ctx_t ctx) noexcept + int gr_mat_det_generic_field(gr_ptr res, const gr_mat_t A, gr_ctx_t ctx) noexcept + int gr_mat_det_generic_integral_domain(gr_ptr res, const gr_mat_t A, gr_ctx_t ctx) noexcept + int gr_mat_det_generic(gr_ptr res, const gr_mat_t A, gr_ctx_t ctx) noexcept + int gr_mat_det(gr_ptr res, const gr_mat_t mat, gr_ctx_t ctx) noexcept # Sets *res* to the determinant of the square matrix *mat*. # Various algorithms are available: # * The *berkowitz* version uses the division-free Berkowitz algorithm @@ -278,14 +278,14 @@ cdef extern from "flint_wrap.h": # * The *default* method can be overloaded. # If the matrix is not square, ``GR_DOMAIN`` is returned. - int gr_mat_trace(gr_ptr res, const gr_mat_t mat, gr_ctx_t ctx) + int gr_mat_trace(gr_ptr res, const gr_mat_t mat, gr_ctx_t ctx) noexcept # Sets *res* to the trace (sum of entries on the main diagonal) of # the square matrix *mat*. # If the matrix is not square, ``GR_DOMAIN`` is returned. - int gr_mat_rank_fflu(slong * rank, const gr_mat_t mat, gr_ctx_t ctx) - int gr_mat_rank_lu(slong * rank, const gr_mat_t mat, gr_ctx_t ctx) - int gr_mat_rank(slong * rank, const gr_mat_t mat, gr_ctx_t ctx) + int gr_mat_rank_fflu(slong * rank, const gr_mat_t mat, gr_ctx_t ctx) noexcept + int gr_mat_rank_lu(slong * rank, const gr_mat_t mat, gr_ctx_t ctx) noexcept + int gr_mat_rank(slong * rank, const gr_mat_t mat, gr_ctx_t ctx) noexcept # Sets *res* to the rank of *mat*. # The default method returns ``GR_DOMAIN`` if the element ring # is not an integral domain, in which case the usual rank is @@ -294,20 +294,20 @@ cdef extern from "flint_wrap.h": # encounter an impossible inverse in the execution of the # respective algorithms. - int gr_mat_rref_lu(slong * rank, gr_mat_t R, const gr_mat_t A, gr_ctx_t ctx) - int gr_mat_rref_fflu(slong * rank, gr_mat_t R, const gr_mat_t A, gr_ctx_t ctx) - int gr_mat_rref(slong * rank, gr_mat_t R, const gr_mat_t A, gr_ctx_t ctx) + int gr_mat_rref_lu(slong * rank, gr_mat_t R, const gr_mat_t A, gr_ctx_t ctx) noexcept + int gr_mat_rref_fflu(slong * rank, gr_mat_t R, const gr_mat_t A, gr_ctx_t ctx) noexcept + int gr_mat_rref(slong * rank, gr_mat_t R, const gr_mat_t A, gr_ctx_t ctx) noexcept # Sets *R* to the reduced row echelon form of *A*, also setting # *rank* to its rank. - int gr_mat_rref_den_fflu(slong * rank, gr_mat_t R, gr_ptr den, const gr_mat_t A, gr_ctx_t ctx) - int gr_mat_rref_den(slong * rank, gr_mat_t R, gr_ptr den, const gr_mat_t A, gr_ctx_t ctx) + int gr_mat_rref_den_fflu(slong * rank, gr_mat_t R, gr_ptr den, const gr_mat_t A, gr_ctx_t ctx) noexcept + int gr_mat_rref_den(slong * rank, gr_mat_t R, gr_ptr den, const gr_mat_t A, gr_ctx_t ctx) noexcept # Like *rref*, but computes the reduced row echelon multiplied # by a common (not necessarily minimal) denominator which is written # to *den*. This can be used to compute the rref over an integral # domain which is not a field. - int gr_mat_nullspace(gr_mat_t X, const gr_mat_t A, gr_ctx_t ctx) + int gr_mat_nullspace(gr_mat_t X, const gr_mat_t A, gr_ctx_t ctx) noexcept # Sets *X* to a basis for the (right) nullspace of *A*. # On success, the output matrix will be resized to the correct # number of columns. @@ -317,7 +317,7 @@ cdef extern from "flint_wrap.h": # basis over the fraction field. The result may be meaningless # if the ring is not an integral domain. - int gr_mat_inv(gr_mat_t res, const gr_mat_t mat, gr_ctx_t ctx) + int gr_mat_inv(gr_mat_t res, const gr_mat_t mat, gr_ctx_t ctx) noexcept # Sets *res* to the inverse of *mat*, computed by solving # `A A^{-1} = I`. # Returns ``GR_DOMAIN`` if it can be determined that *mat* is not @@ -327,9 +327,9 @@ cdef extern from "flint_wrap.h": # To compute the inverse over the fraction field, one may use # :func:`gr_mat_nonsingular_solve_den` or :func:`gr_mat_adjugate`. - int gr_mat_adjugate_charpoly(gr_mat_t adj, gr_ptr det, const gr_mat_t mat, gr_ctx_t ctx) - int gr_mat_adjugate_cofactor(gr_mat_t adj, gr_ptr det, const gr_mat_t mat, gr_ctx_t ctx) - int gr_mat_adjugate(gr_mat_t adj, gr_ptr det, const gr_mat_t mat, gr_ctx_t ctx) + int gr_mat_adjugate_charpoly(gr_mat_t adj, gr_ptr det, const gr_mat_t mat, gr_ctx_t ctx) noexcept + int gr_mat_adjugate_cofactor(gr_mat_t adj, gr_ptr det, const gr_mat_t mat, gr_ctx_t ctx) noexcept + int gr_mat_adjugate(gr_mat_t adj, gr_ptr det, const gr_mat_t mat, gr_ctx_t ctx) noexcept # Sets *adj* to the adjugate matrix of *mat*, simultaneously # setting *det* to the determinant of *mat*. We have # `\operatorname{adj}(A) A = A \operatorname{adj}(A) = \det(A) I`, @@ -343,27 +343,27 @@ cdef extern from "flint_wrap.h": # for the characteristic polynomial itself depending on the # algorithm used. - int _gr_mat_charpoly(gr_ptr res, const gr_mat_t mat, gr_ctx_t ctx) - int gr_mat_charpoly(gr_poly_t res, const gr_mat_t mat, gr_ctx_t ctx) + int _gr_mat_charpoly(gr_ptr res, const gr_mat_t mat, gr_ctx_t ctx) noexcept + int gr_mat_charpoly(gr_poly_t res, const gr_mat_t mat, gr_ctx_t ctx) noexcept # Computes the characteristic polynomial using a default # algorithm choice. The # underscore method assumes that *res* is a preallocated # array of `n + 1` coefficients. - int _gr_mat_charpoly_berkowitz(gr_ptr res, const gr_mat_t mat, gr_ctx_t ctx) - int gr_mat_charpoly_berkowitz(gr_poly_t res, const gr_mat_t mat, gr_ctx_t ctx) + int _gr_mat_charpoly_berkowitz(gr_ptr res, const gr_mat_t mat, gr_ctx_t ctx) noexcept + int gr_mat_charpoly_berkowitz(gr_poly_t res, const gr_mat_t mat, gr_ctx_t ctx) noexcept # Sets *res* to the characteristic polynomial of the square matrix # *mat*, computed using the division-free Berkowitz algorithm. # The number of operations is `O(n^4)` where *n* is the # size of the matrix. - int _gr_mat_charpoly_danilevsky_inplace(gr_ptr res, gr_mat_t mat, gr_ctx_t ctx) - int _gr_mat_charpoly_danilevsky(gr_ptr res, const gr_mat_t mat, gr_ctx_t ctx) - int gr_mat_charpoly_danilevsky(gr_poly_t res, const gr_mat_t mat, gr_ctx_t ctx) - int _gr_mat_charpoly_gauss(gr_ptr res, const gr_mat_t mat, gr_ctx_t ctx) - int gr_mat_charpoly_gauss(gr_poly_t res, const gr_mat_t mat, gr_ctx_t ctx) - int _gr_mat_charpoly_householder(gr_ptr res, const gr_mat_t mat, gr_ctx_t ctx) - int gr_mat_charpoly_householder(gr_poly_t res, const gr_mat_t mat, gr_ctx_t ctx) + int _gr_mat_charpoly_danilevsky_inplace(gr_ptr res, gr_mat_t mat, gr_ctx_t ctx) noexcept + int _gr_mat_charpoly_danilevsky(gr_ptr res, const gr_mat_t mat, gr_ctx_t ctx) noexcept + int gr_mat_charpoly_danilevsky(gr_poly_t res, const gr_mat_t mat, gr_ctx_t ctx) noexcept + int _gr_mat_charpoly_gauss(gr_ptr res, const gr_mat_t mat, gr_ctx_t ctx) noexcept + int gr_mat_charpoly_gauss(gr_poly_t res, const gr_mat_t mat, gr_ctx_t ctx) noexcept + int _gr_mat_charpoly_householder(gr_ptr res, const gr_mat_t mat, gr_ctx_t ctx) noexcept + int gr_mat_charpoly_householder(gr_poly_t res, const gr_mat_t mat, gr_ctx_t ctx) noexcept # Sets *res* to the characteristic polynomial of the square matrix # *mat*, computed using the Danilevsky algorithm, # Hessenberg reduction using Gaussian elimination, @@ -377,10 +377,10 @@ cdef extern from "flint_wrap.h": # an impossible division or square root # is encountered or when a comparison cannot be performed. - int _gr_mat_charpoly_faddeev(gr_ptr res, gr_mat_t adj, const gr_mat_t mat, gr_ctx_t ctx) - int gr_mat_charpoly_faddeev(gr_poly_t res, gr_mat_t adj, const gr_mat_t mat, gr_ctx_t ctx) - int _gr_mat_charpoly_faddeev_bsgs(gr_ptr res, gr_mat_t adj, const gr_mat_t mat, gr_ctx_t ctx) - int gr_mat_charpoly_faddeev_bsgs(gr_poly_t res, gr_mat_t adj, const gr_mat_t mat, gr_ctx_t ctx) + int _gr_mat_charpoly_faddeev(gr_ptr res, gr_mat_t adj, const gr_mat_t mat, gr_ctx_t ctx) noexcept + int gr_mat_charpoly_faddeev(gr_poly_t res, gr_mat_t adj, const gr_mat_t mat, gr_ctx_t ctx) noexcept + int _gr_mat_charpoly_faddeev_bsgs(gr_ptr res, gr_mat_t adj, const gr_mat_t mat, gr_ctx_t ctx) noexcept + int gr_mat_charpoly_faddeev_bsgs(gr_poly_t res, gr_mat_t adj, const gr_mat_t mat, gr_ctx_t ctx) noexcept # Sets *res* to the characteristic polynomial of the square matrix # *mat*, computed using the Faddeev-LeVerrier algorithm. # If the optional output argument *adj* is not *NULL*, it is @@ -395,17 +395,17 @@ cdef extern from "flint_wrap.h": # in finite characteristic or when the underlying ring does # not implement a division algorithm. - int _gr_mat_charpoly_from_hessenberg(gr_ptr res, const gr_mat_t mat, gr_ctx_t ctx) - int gr_mat_charpoly_from_hessenberg(gr_poly_t res, const gr_mat_t mat, gr_ctx_t ctx) + int _gr_mat_charpoly_from_hessenberg(gr_ptr res, const gr_mat_t mat, gr_ctx_t ctx) noexcept + int gr_mat_charpoly_from_hessenberg(gr_poly_t res, const gr_mat_t mat, gr_ctx_t ctx) noexcept # Sets *res* to the characteristic polynomial of the square matrix # *mat*, which is assumed to be in Hessenberg form (this is # currently not checked). - int gr_mat_minpoly_field(gr_poly_t res, const gr_mat_t mat, gr_ctx_t ctx) + int gr_mat_minpoly_field(gr_poly_t res, const gr_mat_t mat, gr_ctx_t ctx) noexcept # Compute the minimal polynomial of the matrix *mat*. # The algorithm assumes that the coefficient ring is a field. - int gr_mat_apply_row_similarity(gr_mat_t M, slong r, gr_ptr d, gr_ctx_t ctx) + int gr_mat_apply_row_similarity(gr_mat_t M, slong r, gr_ptr d, gr_ctx_t ctx) noexcept # Applies an elementary similarity transform to the `n\times n` matrix `M` # in-place. # If `P` is the `n\times n` identity matrix the zero entries of whose row @@ -414,8 +414,8 @@ cdef extern from "flint_wrap.h": # Similarity transforms preserve the determinant, characteristic polynomial # and minimal polynomial. - int gr_mat_eigenvalues(gr_vec_t lmbda, gr_vec_t mult, const gr_mat_t mat, int flags, gr_ctx_t ctx) - int gr_mat_eigenvalues_other(gr_vec_t lmbda, gr_vec_t mult, const gr_mat_t mat, gr_ctx_t mat_ctx, int flags, gr_ctx_t ctx) + int gr_mat_eigenvalues(gr_vec_t lmbda, gr_vec_t mult, const gr_mat_t mat, int flags, gr_ctx_t ctx) noexcept + int gr_mat_eigenvalues_other(gr_vec_t lmbda, gr_vec_t mult, const gr_mat_t mat, gr_ctx_t mat_ctx, int flags, gr_ctx_t ctx) noexcept # Finds all eigenvalues of the given matrix in the ring defined by *ctx*, # storing the eigenvalues without duplication in *lambda* (a vector with # elements of type ``ctx``) and the corresponding multiplicities in @@ -423,9 +423,9 @@ cdef extern from "flint_wrap.h": # The interface is essentially the same as that of # :func:`gr_poly_roots`; see its documentation for details. - int gr_mat_diagonalization_precomp(gr_vec_t D, gr_mat_t L, gr_mat_t R, const gr_mat_t A, const gr_vec_t eigenvalues, const gr_vec_t mult, gr_ctx_t ctx) - int gr_mat_diagonalization_generic(gr_vec_t D, gr_mat_t L, gr_mat_t R, const gr_mat_t A, int flags, gr_ctx_t ctx) - int gr_mat_diagonalization(gr_vec_t D, gr_mat_t L, gr_mat_t R, const gr_mat_t A, int flags, gr_ctx_t ctx) + int gr_mat_diagonalization_precomp(gr_vec_t D, gr_mat_t L, gr_mat_t R, const gr_mat_t A, const gr_vec_t eigenvalues, const gr_vec_t mult, gr_ctx_t ctx) noexcept + int gr_mat_diagonalization_generic(gr_vec_t D, gr_mat_t L, gr_mat_t R, const gr_mat_t A, int flags, gr_ctx_t ctx) noexcept + int gr_mat_diagonalization(gr_vec_t D, gr_mat_t L, gr_mat_t R, const gr_mat_t A, int flags, gr_ctx_t ctx) noexcept # Computes a diagonalization `LAR = D` given a square matrix `A`, # where `D` is a diagonal matrix (returned as a vector) of the eigenvalues # repeated according to their multiplicities, @@ -442,23 +442,23 @@ cdef extern from "flint_wrap.h": # with corresponding multiplicities, which can be computed # with :func:`gr_mat_eigenvalues`. - int gr_mat_set_jordan_blocks(gr_mat_t mat, const gr_vec_t lmbda, slong num_blocks, slong * block_lambda, slong * block_size, gr_ctx_t ctx) - int gr_mat_jordan_blocks(gr_vec_t lmbda, slong * num_blocks, slong * block_lambda, slong * block_size, const gr_mat_t A, gr_ctx_t ctx) - int gr_mat_jordan_transformation(gr_mat_t mat, const gr_vec_t lmbda, slong num_blocks, slong * block_lambda, slong * block_size, const gr_mat_t A, gr_ctx_t ctx) - int gr_mat_jordan_form(gr_mat_t J, gr_mat_t P, const gr_mat_t A, gr_ctx_t ctx) + int gr_mat_set_jordan_blocks(gr_mat_t mat, const gr_vec_t lmbda, slong num_blocks, slong * block_lambda, slong * block_size, gr_ctx_t ctx) noexcept + int gr_mat_jordan_blocks(gr_vec_t lmbda, slong * num_blocks, slong * block_lambda, slong * block_size, const gr_mat_t A, gr_ctx_t ctx) noexcept + int gr_mat_jordan_transformation(gr_mat_t mat, const gr_vec_t lmbda, slong num_blocks, slong * block_lambda, slong * block_size, const gr_mat_t A, gr_ctx_t ctx) noexcept + int gr_mat_jordan_form(gr_mat_t J, gr_mat_t P, const gr_mat_t A, gr_ctx_t ctx) noexcept - int gr_mat_exp_jordan(gr_mat_t res, const gr_mat_t A, gr_ctx_t ctx) - int gr_mat_exp(gr_mat_t res, const gr_mat_t A, gr_ctx_t ctx) + int gr_mat_exp_jordan(gr_mat_t res, const gr_mat_t A, gr_ctx_t ctx) noexcept + int gr_mat_exp(gr_mat_t res, const gr_mat_t A, gr_ctx_t ctx) noexcept - int gr_mat_log_jordan(gr_mat_t res, const gr_mat_t A, gr_ctx_t ctx) - int gr_mat_log(gr_mat_t res, const gr_mat_t A, gr_ctx_t ctx) + int gr_mat_log_jordan(gr_mat_t res, const gr_mat_t A, gr_ctx_t ctx) noexcept + int gr_mat_log(gr_mat_t res, const gr_mat_t A, gr_ctx_t ctx) noexcept - truth_t gr_mat_is_hessenberg(const gr_mat_t mat, gr_ctx_t ctx) + truth_t gr_mat_is_hessenberg(const gr_mat_t mat, gr_ctx_t ctx) noexcept # Returns whether *mat* is in upper Hessenberg form. - int gr_mat_hessenberg_gauss(gr_mat_t res, const gr_mat_t mat, gr_ctx_t ctx) - int gr_mat_hessenberg_householder(gr_mat_t res, const gr_mat_t mat, gr_ctx_t ctx) - int gr_mat_hessenberg(gr_mat_t res, const gr_mat_t mat, gr_ctx_t ctx) + int gr_mat_hessenberg_gauss(gr_mat_t res, const gr_mat_t mat, gr_ctx_t ctx) noexcept + int gr_mat_hessenberg_householder(gr_mat_t res, const gr_mat_t mat, gr_ctx_t ctx) noexcept + int gr_mat_hessenberg(gr_mat_t res, const gr_mat_t mat, gr_ctx_t ctx) noexcept # Sets *res* to an upper Hessenberg form of *mat*. # The *gauss* version uses Gaussian elimination. # The *householder* version uses Householder reflections. @@ -468,30 +468,30 @@ cdef extern from "flint_wrap.h": # The *householder* version additionally requires complex # conjugation and the ability to compute square roots. - int gr_mat_randtest(gr_mat_t res, flint_rand_t state, gr_ctx_t ctx) + int gr_mat_randtest(gr_mat_t res, flint_rand_t state, gr_ctx_t ctx) noexcept # Sets *res* to a random matrix. The distribution is nonuniform. - int gr_mat_randops(gr_mat_t mat, flint_rand_t state, slong count, gr_ctx_t ctx) + int gr_mat_randops(gr_mat_t mat, flint_rand_t state, slong count, gr_ctx_t ctx) noexcept # Randomises *mat* in-place by performing elementary row or column # operations. More precisely, at most *count* random additions or # subtractions of distinct rows and columns will be performed. - int gr_mat_randpermdiag(int * parity, gr_mat_t mat, flint_rand_t state, gr_ptr diag, slong n, gr_ctx_t ctx) + int gr_mat_randpermdiag(int * parity, gr_mat_t mat, flint_rand_t state, gr_ptr diag, slong n, gr_ctx_t ctx) noexcept # Sets mat to a random permutation of the diagonal matrix with *n* leading entries given by # the vector ``diag``. Returns ``GR_DOMAIN`` if the main diagonal of ``mat`` # does not have room for at least *n* entries. # The parity (0 or 1) of the permutation is written to ``parity``. - int gr_mat_randrank(gr_mat_t mat, flint_rand_t state, slong rank, gr_ctx_t ctx) + int gr_mat_randrank(gr_mat_t mat, flint_rand_t state, slong rank, gr_ctx_t ctx) noexcept # Sets ``mat`` to a random sparse matrix with the given rank, having exactly as many # non-zero elements as the rank. The matrix can be transformed into a dense matrix # with unchanged rank by subsequently calling :func:`gr_mat_randops`. # This operation only makes sense over integral domains (currently not checked). - int gr_mat_ones(gr_mat_t res, gr_ctx_t ctx) + int gr_mat_ones(gr_mat_t res, gr_ctx_t ctx) noexcept # Sets all entries in *res* to one. - int gr_mat_pascal(gr_mat_t res, int triangular, gr_ctx_t ctx) + int gr_mat_pascal(gr_mat_t res, int triangular, gr_ctx_t ctx) noexcept # Sets *res* to a Pascal matrix, whose entries are binomial coefficients. # If *triangular* is 0, constructs a full symmetric matrix # with the rows of Pascal's triangle as successive antidiagonals. @@ -500,18 +500,18 @@ cdef extern from "flint_wrap.h": # constructs the lower triangular matrix with the rows of Pascal's # triangle as rows. - int gr_mat_stirling(gr_mat_t res, int kind, gr_ctx_t ctx) + int gr_mat_stirling(gr_mat_t res, int kind, gr_ctx_t ctx) noexcept # Sets *res* to a Stirling matrix, whose entries are Stirling numbers. # If *kind* is 0, the entries are set to the unsigned Stirling numbers # of the first kind. If *kind* is 1, the entries are set to the signed # Stirling numbers of the first kind. If *kind* is 2, the entries are # set to the Stirling numbers of the second kind. - int gr_mat_hilbert(gr_mat_t res, gr_ctx_t ctx) + int gr_mat_hilbert(gr_mat_t res, gr_ctx_t ctx) noexcept # Sets *res* to the Hilbert matrix, which has entries `1/(i+j+1)` # for `i, j \ge 0`. - int gr_mat_hadamard(gr_mat_t res, gr_ctx_t ctx) + int gr_mat_hadamard(gr_mat_t res, gr_ctx_t ctx) noexcept # If possible, sets *res* to a Hadamard matrix of the provided size # and returns ``GR_SUCCESS``. Returns ``GR_DOMAIN`` # if no Hadamard matrix of the given size exists, @@ -527,7 +527,7 @@ cdef extern from "flint_wrap.h": # known to exist but for which this construction fails are # 92, 116, 156, ... (OEIS A046116). - int gr_mat_reduce_row(slong * column, gr_mat_t A, slong * P, slong * L, slong m, gr_ctx_t ctx) + int gr_mat_reduce_row(slong * column, gr_mat_t A, slong * P, slong * L, slong m, gr_ctx_t ctx) noexcept # Reduce row n of the matrix `A`, assuming the prior rows are in Gauss # form. However those rows may not be in order. The entry `i` of the array # `P` is the row of `A` which has a pivot in the `i`-th column. If no such diff --git a/src/sage/libs/flint/gr_mpoly.pxd b/src/sage/libs/flint/gr_mpoly.pxd index dcdc9a02273..8d482d403e0 100644 --- a/src/sage/libs/flint/gr_mpoly.pxd +++ b/src/sage/libs/flint/gr_mpoly.pxd @@ -12,113 +12,113 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void gr_mpoly_init(gr_mpoly_t A, const mpoly_ctx_t mctx, gr_ctx_t cctx) + void gr_mpoly_init(gr_mpoly_t A, const mpoly_ctx_t mctx, gr_ctx_t cctx) noexcept # Initializes and sets *A* to the zero polynomial. - void gr_mpoly_init3(gr_mpoly_t A, slong alloc, flint_bitcnt_t bits, const mpoly_ctx_t mctx, gr_ctx_t cctx) - void gr_mpoly_init2(gr_mpoly_t A, slong alloc, const mpoly_ctx_t mctx, gr_ctx_t cctx) + void gr_mpoly_init3(gr_mpoly_t A, slong alloc, flint_bitcnt_t bits, const mpoly_ctx_t mctx, gr_ctx_t cctx) noexcept + void gr_mpoly_init2(gr_mpoly_t A, slong alloc, const mpoly_ctx_t mctx, gr_ctx_t cctx) noexcept # Initializes *A* with space allocated for the given number # of coefficients and exponents with the given number of bits. - void gr_mpoly_clear(gr_mpoly_t A, const mpoly_ctx_t mctx, gr_ctx_t cctx) + void gr_mpoly_clear(gr_mpoly_t A, const mpoly_ctx_t mctx, gr_ctx_t cctx) noexcept # Clears *A*, freeing all allocated data. - void gr_mpoly_swap(gr_mpoly_t A, gr_mpoly_t B, const mpoly_ctx_t mctx, gr_ctx_t cctx) + void gr_mpoly_swap(gr_mpoly_t A, gr_mpoly_t B, const mpoly_ctx_t mctx, gr_ctx_t cctx) noexcept # Swaps *A* and *B* efficiently. - int gr_mpoly_set(gr_mpoly_t A, const gr_mpoly_t B, const mpoly_ctx_t mctx, gr_ctx_t cctx) + int gr_mpoly_set(gr_mpoly_t A, const gr_mpoly_t B, const mpoly_ctx_t mctx, gr_ctx_t cctx) noexcept # Sets *A* to *B*. - int gr_mpoly_zero(gr_mpoly_t A, const mpoly_ctx_t mctx, gr_ctx_t cctx) + int gr_mpoly_zero(gr_mpoly_t A, const mpoly_ctx_t mctx, gr_ctx_t cctx) noexcept # Sets *A* to the zero polynomial. - truth_t gr_mpoly_is_zero(const gr_mpoly_t A, const mpoly_ctx_t mctx, gr_ctx_t cctx) + truth_t gr_mpoly_is_zero(const gr_mpoly_t A, const mpoly_ctx_t mctx, gr_ctx_t cctx) noexcept # Returns whether *A* is the zero polynomial. - int gr_mpoly_gen(gr_mpoly_t A, slong var, const mpoly_ctx_t mctx, gr_ctx_t cctx) + int gr_mpoly_gen(gr_mpoly_t A, slong var, const mpoly_ctx_t mctx, gr_ctx_t cctx) noexcept # Sets *A* to the generator with index *var* (indexed from zero). - truth_t gr_mpoly_is_gen(const gr_mpoly_t A, slong var, const mpoly_ctx_t mctx, gr_ctx_t cctx) + truth_t gr_mpoly_is_gen(const gr_mpoly_t A, slong var, const mpoly_ctx_t mctx, gr_ctx_t cctx) noexcept # Returns whether *A* is the generator with index *var* (indexed from zero). - truth_t gr_mpoly_equal(const gr_mpoly_t A, const gr_mpoly_t B, const mpoly_ctx_t mctx, gr_ctx_t cctx) + truth_t gr_mpoly_equal(const gr_mpoly_t A, const gr_mpoly_t B, const mpoly_ctx_t mctx, gr_ctx_t cctx) noexcept # Returns whether *A* and *B* are equal. - int gr_mpoly_randtest_bits(gr_mpoly_t A, flint_rand_t state, slong length, flint_bitcnt_t exp_bits, const mpoly_ctx_t mctx, gr_ctx_t cctx) + int gr_mpoly_randtest_bits(gr_mpoly_t A, flint_rand_t state, slong length, flint_bitcnt_t exp_bits, const mpoly_ctx_t mctx, gr_ctx_t cctx) noexcept # Sets *A* to a random polynomial with up to *length* terms # and up to *exp_bits* bits in the exponents. - int gr_mpoly_write_pretty(gr_stream_t out, const gr_mpoly_t A, const char ** x, const mpoly_ctx_t mctx, gr_ctx_t cctx) - int gr_mpoly_print_pretty(const gr_mpoly_t A, const char ** x, const mpoly_ctx_t mctx, gr_ctx_t cctx) + int gr_mpoly_write_pretty(gr_stream_t out, const gr_mpoly_t A, const char ** x, const mpoly_ctx_t mctx, gr_ctx_t cctx) noexcept + int gr_mpoly_print_pretty(const gr_mpoly_t A, const char ** x, const mpoly_ctx_t mctx, gr_ctx_t cctx) noexcept # Prints *A* using the strings in *x* for the variables. # If *x* is *NULL*, defaults are used. - int gr_mpoly_get_coeff_scalar_fmpz(gr_ptr c, const gr_mpoly_t A, const fmpz * exp, const mpoly_ctx_t mctx, gr_ctx_t cctx) - int gr_mpoly_get_coeff_scalar_ui(gr_ptr c, const gr_mpoly_t A, const ulong * exp, const mpoly_ctx_t mctx, gr_ctx_t cctx) + int gr_mpoly_get_coeff_scalar_fmpz(gr_ptr c, const gr_mpoly_t A, const fmpz * exp, const mpoly_ctx_t mctx, gr_ctx_t cctx) noexcept + int gr_mpoly_get_coeff_scalar_ui(gr_ptr c, const gr_mpoly_t A, const ulong * exp, const mpoly_ctx_t mctx, gr_ctx_t cctx) noexcept # Sets *c* to the coefficient in *A* with exponents *exp*. - int gr_mpoly_set_coeff_scalar_fmpz(gr_mpoly_t A, gr_srcptr c, const fmpz * exp, const mpoly_ctx_t mctx, gr_ctx_t cctx) - int gr_mpoly_set_coeff_ui_fmpz(gr_mpoly_t A, ulong c, const fmpz * exp, const mpoly_ctx_t mctx, gr_ctx_t cctx) - int gr_mpoly_set_coeff_si_fmpz(gr_mpoly_t A, slong c, const fmpz * exp, const mpoly_ctx_t mctx, gr_ctx_t cctx) - int gr_mpoly_set_coeff_fmpz_fmpz(gr_mpoly_t A, const fmpz_t c, const fmpz * exp, const mpoly_ctx_t mctx, gr_ctx_t cctx) - int gr_mpoly_set_coeff_fmpq_fmpz(gr_mpoly_t A, const fmpq_t c, const fmpz * exp, const mpoly_ctx_t mctx, gr_ctx_t cctx) - - int gr_mpoly_set_coeff_scalar_ui(gr_mpoly_t poly, gr_srcptr c, const ulong * exp, const mpoly_ctx_t mctx, gr_ctx_t cctx) - int gr_mpoly_set_coeff_ui_ui(gr_mpoly_t A, ulong c, const ulong * exp, const mpoly_ctx_t mctx, gr_ctx_t cctx) - int gr_mpoly_set_coeff_si_ui(gr_mpoly_t A, slong c, const ulong * exp, const mpoly_ctx_t mctx, gr_ctx_t cctx) - int gr_mpoly_set_coeff_fmpz_ui(gr_mpoly_t A, const fmpz_t c, const ulong * exp, const mpoly_ctx_t mctx, gr_ctx_t cctx) - int gr_mpoly_set_coeff_fmpq_ui(gr_mpoly_t A, const fmpq_t c, const ulong * exp, const mpoly_ctx_t mctx, gr_ctx_t cctx) + int gr_mpoly_set_coeff_scalar_fmpz(gr_mpoly_t A, gr_srcptr c, const fmpz * exp, const mpoly_ctx_t mctx, gr_ctx_t cctx) noexcept + int gr_mpoly_set_coeff_ui_fmpz(gr_mpoly_t A, ulong c, const fmpz * exp, const mpoly_ctx_t mctx, gr_ctx_t cctx) noexcept + int gr_mpoly_set_coeff_si_fmpz(gr_mpoly_t A, slong c, const fmpz * exp, const mpoly_ctx_t mctx, gr_ctx_t cctx) noexcept + int gr_mpoly_set_coeff_fmpz_fmpz(gr_mpoly_t A, const fmpz_t c, const fmpz * exp, const mpoly_ctx_t mctx, gr_ctx_t cctx) noexcept + int gr_mpoly_set_coeff_fmpq_fmpz(gr_mpoly_t A, const fmpq_t c, const fmpz * exp, const mpoly_ctx_t mctx, gr_ctx_t cctx) noexcept + + int gr_mpoly_set_coeff_scalar_ui(gr_mpoly_t poly, gr_srcptr c, const ulong * exp, const mpoly_ctx_t mctx, gr_ctx_t cctx) noexcept + int gr_mpoly_set_coeff_ui_ui(gr_mpoly_t A, ulong c, const ulong * exp, const mpoly_ctx_t mctx, gr_ctx_t cctx) noexcept + int gr_mpoly_set_coeff_si_ui(gr_mpoly_t A, slong c, const ulong * exp, const mpoly_ctx_t mctx, gr_ctx_t cctx) noexcept + int gr_mpoly_set_coeff_fmpz_ui(gr_mpoly_t A, const fmpz_t c, const ulong * exp, const mpoly_ctx_t mctx, gr_ctx_t cctx) noexcept + int gr_mpoly_set_coeff_fmpq_ui(gr_mpoly_t A, const fmpq_t c, const ulong * exp, const mpoly_ctx_t mctx, gr_ctx_t cctx) noexcept # Sets the coefficient with exponents *exp* in *A* to the scalar *c* # which must be an element of or coercible to the coefficient ring. - int gr_mpoly_neg(gr_mpoly_t A, const gr_mpoly_t B, const mpoly_ctx_t mctx, gr_ctx_t cctx) + int gr_mpoly_neg(gr_mpoly_t A, const gr_mpoly_t B, const mpoly_ctx_t mctx, gr_ctx_t cctx) noexcept # Sets *A* to the negation of *B*. - int gr_mpoly_add(gr_mpoly_t A, const gr_mpoly_t B, const gr_mpoly_t C, const mpoly_ctx_t mctx, gr_ctx_t cctx) + int gr_mpoly_add(gr_mpoly_t A, const gr_mpoly_t B, const gr_mpoly_t C, const mpoly_ctx_t mctx, gr_ctx_t cctx) noexcept # Sets *A* to the difference of *B* and *C*. - int gr_mpoly_sub(gr_mpoly_t A, const gr_mpoly_t B, const gr_mpoly_t C, const mpoly_ctx_t mctx, gr_ctx_t cctx) + int gr_mpoly_sub(gr_mpoly_t A, const gr_mpoly_t B, const gr_mpoly_t C, const mpoly_ctx_t mctx, gr_ctx_t cctx) noexcept # Sets *A* to the difference of *B* and *C*. - int gr_mpoly_mul(gr_mpoly_t A, const gr_mpoly_t B, const gr_mpoly_t C, const mpoly_ctx_t mctx, gr_ctx_t cctx) - int gr_mpoly_mul_johnson(gr_mpoly_t A, const gr_mpoly_t B, const gr_mpoly_t C, const mpoly_ctx_t mctx, gr_ctx_t cctx) - int gr_mpoly_mul_monomial(gr_mpoly_t A, const gr_mpoly_t B, const gr_mpoly_t C, const mpoly_ctx_t mctx, gr_ctx_t cctx) + int gr_mpoly_mul(gr_mpoly_t A, const gr_mpoly_t B, const gr_mpoly_t C, const mpoly_ctx_t mctx, gr_ctx_t cctx) noexcept + int gr_mpoly_mul_johnson(gr_mpoly_t A, const gr_mpoly_t B, const gr_mpoly_t C, const mpoly_ctx_t mctx, gr_ctx_t cctx) noexcept + int gr_mpoly_mul_monomial(gr_mpoly_t A, const gr_mpoly_t B, const gr_mpoly_t C, const mpoly_ctx_t mctx, gr_ctx_t cctx) noexcept # Sets *A* to the product of *B* and *C*. # The *monomial* version assumes that *C* is a monomial. - int gr_mpoly_mul_scalar(gr_mpoly_t A, const gr_mpoly_t B, gr_srcptr c, const mpoly_ctx_t mctx, gr_ctx_t cctx) - int gr_mpoly_mul_si(gr_mpoly_t A, const gr_mpoly_t B, slong c, const mpoly_ctx_t mctx, gr_ctx_t cctx) - int gr_mpoly_mul_ui(gr_mpoly_t A, const gr_mpoly_t B, ulong c, const mpoly_ctx_t mctx, gr_ctx_t cctx) - int gr_mpoly_mul_fmpz(gr_mpoly_t A, const gr_mpoly_t B, const fmpz_t c, const mpoly_ctx_t mctx, gr_ctx_t cctx) - int gr_mpoly_mul_fmpq(gr_mpoly_t A, const gr_mpoly_t B, const fmpq_t c, const mpoly_ctx_t mctx, gr_ctx_t cctx) + int gr_mpoly_mul_scalar(gr_mpoly_t A, const gr_mpoly_t B, gr_srcptr c, const mpoly_ctx_t mctx, gr_ctx_t cctx) noexcept + int gr_mpoly_mul_si(gr_mpoly_t A, const gr_mpoly_t B, slong c, const mpoly_ctx_t mctx, gr_ctx_t cctx) noexcept + int gr_mpoly_mul_ui(gr_mpoly_t A, const gr_mpoly_t B, ulong c, const mpoly_ctx_t mctx, gr_ctx_t cctx) noexcept + int gr_mpoly_mul_fmpz(gr_mpoly_t A, const gr_mpoly_t B, const fmpz_t c, const mpoly_ctx_t mctx, gr_ctx_t cctx) noexcept + int gr_mpoly_mul_fmpq(gr_mpoly_t A, const gr_mpoly_t B, const fmpq_t c, const mpoly_ctx_t mctx, gr_ctx_t cctx) noexcept # Sets *A* to *B* multiplied by the scalar *c* which must be # an element of or coercible to the coefficient ring. - void _gr_mpoly_fit_length(gr_ptr * coeffs, slong * coeffs_alloc, ulong ** exps, slong * exps_alloc, slong N, slong length, gr_ctx_t cctx) + void _gr_mpoly_fit_length(gr_ptr * coeffs, slong * coeffs_alloc, ulong ** exps, slong * exps_alloc, slong N, slong length, gr_ctx_t cctx) noexcept - void gr_mpoly_fit_length(gr_mpoly_t A, slong len, const mpoly_ctx_t mctx, gr_ctx_t cctx) + void gr_mpoly_fit_length(gr_mpoly_t A, slong len, const mpoly_ctx_t mctx, gr_ctx_t cctx) noexcept # Ensures that *A* has space for *len* coefficients and exponents. - void gr_mpoly_fit_bits(gr_mpoly_t A, flint_bitcnt_t bits, const mpoly_ctx_t mctx, gr_ctx_t cctx) + void gr_mpoly_fit_bits(gr_mpoly_t A, flint_bitcnt_t bits, const mpoly_ctx_t mctx, gr_ctx_t cctx) noexcept - void gr_mpoly_fit_length_fit_bits(gr_mpoly_t A, slong len, flint_bitcnt_t bits, const mpoly_ctx_t mctx, gr_ctx_t cctx) + void gr_mpoly_fit_length_fit_bits(gr_mpoly_t A, slong len, flint_bitcnt_t bits, const mpoly_ctx_t mctx, gr_ctx_t cctx) noexcept - void gr_mpoly_fit_length_reset_bits(gr_mpoly_t A, slong len, flint_bitcnt_t bits, const mpoly_ctx_t mctx, gr_ctx_t cctx) + void gr_mpoly_fit_length_reset_bits(gr_mpoly_t A, slong len, flint_bitcnt_t bits, const mpoly_ctx_t mctx, gr_ctx_t cctx) noexcept - void _gr_mpoly_set_length(gr_mpoly_t A, slong newlen, const mpoly_ctx_t mctx, gr_ctx_t cctx) + void _gr_mpoly_set_length(gr_mpoly_t A, slong newlen, const mpoly_ctx_t mctx, gr_ctx_t cctx) noexcept - void _gr_mpoly_push_exp_ui(gr_mpoly_t A, const ulong * exp, const mpoly_ctx_t mctx, gr_ctx_t cctx) + void _gr_mpoly_push_exp_ui(gr_mpoly_t A, const ulong * exp, const mpoly_ctx_t mctx, gr_ctx_t cctx) noexcept - int gr_mpoly_push_term_scalar_ui(gr_mpoly_t A, gr_srcptr c, const ulong * exp, const mpoly_ctx_t mctx, gr_ctx_t cctx) + int gr_mpoly_push_term_scalar_ui(gr_mpoly_t A, gr_srcptr c, const ulong * exp, const mpoly_ctx_t mctx, gr_ctx_t cctx) noexcept - void _gr_mpoly_push_exp_fmpz(gr_mpoly_t A, const fmpz * exp, const mpoly_ctx_t mctx, gr_ctx_t cctx) + void _gr_mpoly_push_exp_fmpz(gr_mpoly_t A, const fmpz * exp, const mpoly_ctx_t mctx, gr_ctx_t cctx) noexcept - int gr_mpoly_push_term_scalar_fmpz(gr_mpoly_t A, gr_srcptr c, const fmpz * exp, const mpoly_ctx_t mctx, gr_ctx_t cctx) + int gr_mpoly_push_term_scalar_fmpz(gr_mpoly_t A, gr_srcptr c, const fmpz * exp, const mpoly_ctx_t mctx, gr_ctx_t cctx) noexcept - void gr_mpoly_sort_terms(gr_mpoly_t A, const mpoly_ctx_t mctx, gr_ctx_t cctx) + void gr_mpoly_sort_terms(gr_mpoly_t A, const mpoly_ctx_t mctx, gr_ctx_t cctx) noexcept - int gr_mpoly_combine_like_terms(gr_mpoly_t A, const mpoly_ctx_t mctx, gr_ctx_t cctx) + int gr_mpoly_combine_like_terms(gr_mpoly_t A, const mpoly_ctx_t mctx, gr_ctx_t cctx) noexcept - truth_t gr_mpoly_is_canonical(const gr_mpoly_t A, const mpoly_ctx_t mctx, gr_ctx_t cctx) + truth_t gr_mpoly_is_canonical(const gr_mpoly_t A, const mpoly_ctx_t mctx, gr_ctx_t cctx) noexcept - void gr_mpoly_assert_canonical(const gr_mpoly_t A, const mpoly_ctx_t mctx, gr_ctx_t cctx) + void gr_mpoly_assert_canonical(const gr_mpoly_t A, const mpoly_ctx_t mctx, gr_ctx_t cctx) noexcept diff --git a/src/sage/libs/flint/gr_poly.pxd b/src/sage/libs/flint/gr_poly.pxd index 436f7f25623..2fb3da86b14 100644 --- a/src/sage/libs/flint/gr_poly.pxd +++ b/src/sage/libs/flint/gr_poly.pxd @@ -12,118 +12,118 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void gr_poly_init(gr_poly_t poly, gr_ctx_t ctx) + void gr_poly_init(gr_poly_t poly, gr_ctx_t ctx) noexcept - void gr_poly_init2(gr_poly_t poly, slong len, gr_ctx_t ctx) + void gr_poly_init2(gr_poly_t poly, slong len, gr_ctx_t ctx) noexcept - void gr_poly_clear(gr_poly_t poly, gr_ctx_t ctx) + void gr_poly_clear(gr_poly_t poly, gr_ctx_t ctx) noexcept - gr_ptr gr_poly_entry_ptr(gr_poly_t poly, slong i, gr_ctx_t ctx) + gr_ptr gr_poly_entry_ptr(gr_poly_t poly, slong i, gr_ctx_t ctx) noexcept - slong gr_poly_length(const gr_poly_t poly, gr_ctx_t ctx) + slong gr_poly_length(const gr_poly_t poly, gr_ctx_t ctx) noexcept - void gr_poly_swap(gr_poly_t poly1, gr_poly_t poly2, gr_ctx_t ctx) + void gr_poly_swap(gr_poly_t poly1, gr_poly_t poly2, gr_ctx_t ctx) noexcept - void gr_poly_fit_length(gr_poly_t poly, slong len, gr_ctx_t ctx) + void gr_poly_fit_length(gr_poly_t poly, slong len, gr_ctx_t ctx) noexcept - void _gr_poly_set_length(gr_poly_t poly, slong len, gr_ctx_t ctx) + void _gr_poly_set_length(gr_poly_t poly, slong len, gr_ctx_t ctx) noexcept - void _gr_poly_normalise(gr_poly_t poly, gr_ctx_t ctx) + void _gr_poly_normalise(gr_poly_t poly, gr_ctx_t ctx) noexcept - int gr_poly_set(gr_poly_t res, const gr_poly_t src, gr_ctx_t ctx) - int gr_poly_get_fmpz_poly(gr_poly_t res, const fmpz_poly_t src, gr_ctx_t ctx) - int gr_poly_set_fmpq_poly(gr_poly_t res, const fmpq_poly_t src, gr_ctx_t ctx) - int gr_poly_set_gr_poly_other(gr_poly_t res, const gr_poly_t x, gr_ctx_t x_ctx, gr_ctx_t ctx) + int gr_poly_set(gr_poly_t res, const gr_poly_t src, gr_ctx_t ctx) noexcept + int gr_poly_get_fmpz_poly(gr_poly_t res, const fmpz_poly_t src, gr_ctx_t ctx) noexcept + int gr_poly_set_fmpq_poly(gr_poly_t res, const fmpq_poly_t src, gr_ctx_t ctx) noexcept + int gr_poly_set_gr_poly_other(gr_poly_t res, const gr_poly_t x, gr_ctx_t x_ctx, gr_ctx_t ctx) noexcept - int _gr_poly_reverse(gr_ptr res, gr_srcptr poly, slong len, slong n, gr_ctx_t ctx) - int gr_poly_reverse(gr_poly_t res, const gr_poly_t poly, slong n, gr_ctx_t ctx) + int _gr_poly_reverse(gr_ptr res, gr_srcptr poly, slong len, slong n, gr_ctx_t ctx) noexcept + int gr_poly_reverse(gr_poly_t res, const gr_poly_t poly, slong n, gr_ctx_t ctx) noexcept - int gr_poly_truncate(gr_poly_t res, const gr_poly_t poly, slong newlen, gr_ctx_t ctx) + int gr_poly_truncate(gr_poly_t res, const gr_poly_t poly, slong newlen, gr_ctx_t ctx) noexcept - int gr_poly_zero(gr_poly_t poly, gr_ctx_t ctx) - int gr_poly_one(gr_poly_t poly, gr_ctx_t ctx) - int gr_poly_neg_one(gr_poly_t poly, gr_ctx_t ctx) - int gr_poly_gen(gr_poly_t poly, gr_ctx_t ctx) + int gr_poly_zero(gr_poly_t poly, gr_ctx_t ctx) noexcept + int gr_poly_one(gr_poly_t poly, gr_ctx_t ctx) noexcept + int gr_poly_neg_one(gr_poly_t poly, gr_ctx_t ctx) noexcept + int gr_poly_gen(gr_poly_t poly, gr_ctx_t ctx) noexcept - int gr_poly_write(gr_stream_t out, const gr_poly_t poly, const char * x, gr_ctx_t ctx) - int gr_poly_print(const gr_poly_t poly, gr_ctx_t ctx) + int gr_poly_write(gr_stream_t out, const gr_poly_t poly, const char * x, gr_ctx_t ctx) noexcept + int gr_poly_print(const gr_poly_t poly, gr_ctx_t ctx) noexcept - int gr_poly_randtest(gr_poly_t poly, flint_rand_t state, slong len, gr_ctx_t ctx) + int gr_poly_randtest(gr_poly_t poly, flint_rand_t state, slong len, gr_ctx_t ctx) noexcept - truth_t _gr_poly_equal(gr_srcptr poly1, slong len1, gr_srcptr poly2, slong len2, gr_ctx_t ctx) - truth_t gr_poly_equal(const gr_poly_t poly1, const gr_poly_t poly2, gr_ctx_t ctx) + truth_t _gr_poly_equal(gr_srcptr poly1, slong len1, gr_srcptr poly2, slong len2, gr_ctx_t ctx) noexcept + truth_t gr_poly_equal(const gr_poly_t poly1, const gr_poly_t poly2, gr_ctx_t ctx) noexcept - truth_t gr_poly_is_zero(const gr_poly_t poly, gr_ctx_t ctx) - truth_t gr_poly_is_one(const gr_poly_t poly, gr_ctx_t ctx) - truth_t gr_poly_is_gen(const gr_poly_t poly, gr_ctx_t ctx) - truth_t gr_poly_is_scalar(const gr_poly_t poly, gr_ctx_t ctx) + truth_t gr_poly_is_zero(const gr_poly_t poly, gr_ctx_t ctx) noexcept + truth_t gr_poly_is_one(const gr_poly_t poly, gr_ctx_t ctx) noexcept + truth_t gr_poly_is_gen(const gr_poly_t poly, gr_ctx_t ctx) noexcept + truth_t gr_poly_is_scalar(const gr_poly_t poly, gr_ctx_t ctx) noexcept - int gr_poly_set_scalar(gr_poly_t poly, gr_srcptr c, gr_ctx_t ctx) - int gr_poly_set_si(gr_poly_t poly, slong c, gr_ctx_t ctx) - int gr_poly_set_ui(gr_poly_t poly, ulong c, gr_ctx_t ctx) - int gr_poly_set_fmpz(gr_poly_t poly, const fmpz_t c, gr_ctx_t ctx) - int gr_poly_set_fmpq(gr_poly_t poly, const fmpq_t c, gr_ctx_t ctx) + int gr_poly_set_scalar(gr_poly_t poly, gr_srcptr c, gr_ctx_t ctx) noexcept + int gr_poly_set_si(gr_poly_t poly, slong c, gr_ctx_t ctx) noexcept + int gr_poly_set_ui(gr_poly_t poly, ulong c, gr_ctx_t ctx) noexcept + int gr_poly_set_fmpz(gr_poly_t poly, const fmpz_t c, gr_ctx_t ctx) noexcept + int gr_poly_set_fmpq(gr_poly_t poly, const fmpq_t c, gr_ctx_t ctx) noexcept - int gr_poly_set_coeff_scalar(gr_poly_t poly, slong n, gr_srcptr c, gr_ctx_t ctx) - int gr_poly_set_coeff_si(gr_poly_t poly, slong n, slong c, gr_ctx_t ctx) - int gr_poly_set_coeff_ui(gr_poly_t poly, slong n, ulong c, gr_ctx_t ctx) - int gr_poly_set_coeff_fmpz(gr_poly_t poly, slong n, const fmpz_t c, gr_ctx_t ctx) - int gr_poly_set_coeff_fmpq(gr_poly_t poly, slong n, const fmpq_t c, gr_ctx_t ctx) + int gr_poly_set_coeff_scalar(gr_poly_t poly, slong n, gr_srcptr c, gr_ctx_t ctx) noexcept + int gr_poly_set_coeff_si(gr_poly_t poly, slong n, slong c, gr_ctx_t ctx) noexcept + int gr_poly_set_coeff_ui(gr_poly_t poly, slong n, ulong c, gr_ctx_t ctx) noexcept + int gr_poly_set_coeff_fmpz(gr_poly_t poly, slong n, const fmpz_t c, gr_ctx_t ctx) noexcept + int gr_poly_set_coeff_fmpq(gr_poly_t poly, slong n, const fmpq_t c, gr_ctx_t ctx) noexcept - int gr_poly_get_coeff_scalar(gr_ptr res, const gr_poly_t poly, slong n, gr_ctx_t ctx) + int gr_poly_get_coeff_scalar(gr_ptr res, const gr_poly_t poly, slong n, gr_ctx_t ctx) noexcept - int gr_poly_neg(gr_poly_t res, const gr_poly_t src, gr_ctx_t ctx) + int gr_poly_neg(gr_poly_t res, const gr_poly_t src, gr_ctx_t ctx) noexcept - int _gr_poly_add(gr_ptr res, gr_srcptr poly1, slong len1, gr_srcptr poly2, slong len2, gr_ctx_t ctx) - int gr_poly_add(gr_poly_t res, const gr_poly_t poly1, const gr_poly_t poly2, gr_ctx_t ctx) + int _gr_poly_add(gr_ptr res, gr_srcptr poly1, slong len1, gr_srcptr poly2, slong len2, gr_ctx_t ctx) noexcept + int gr_poly_add(gr_poly_t res, const gr_poly_t poly1, const gr_poly_t poly2, gr_ctx_t ctx) noexcept - int _gr_poly_sub(gr_ptr res, gr_srcptr poly1, slong len1, gr_srcptr poly2, slong len2, gr_ctx_t ctx) - int gr_poly_sub(gr_poly_t res, const gr_poly_t poly1, const gr_poly_t poly2, gr_ctx_t ctx) + int _gr_poly_sub(gr_ptr res, gr_srcptr poly1, slong len1, gr_srcptr poly2, slong len2, gr_ctx_t ctx) noexcept + int gr_poly_sub(gr_poly_t res, const gr_poly_t poly1, const gr_poly_t poly2, gr_ctx_t ctx) noexcept - int _gr_poly_mul(gr_ptr res, gr_srcptr poly1, slong len1, gr_srcptr poly2, slong len2, gr_ctx_t ctx) - int gr_poly_mul(gr_poly_t res, const gr_poly_t poly1, const gr_poly_t poly2, gr_ctx_t ctx) + int _gr_poly_mul(gr_ptr res, gr_srcptr poly1, slong len1, gr_srcptr poly2, slong len2, gr_ctx_t ctx) noexcept + int gr_poly_mul(gr_poly_t res, const gr_poly_t poly1, const gr_poly_t poly2, gr_ctx_t ctx) noexcept - int _gr_poly_mullow_generic(gr_ptr res, gr_srcptr poly1, slong len1, gr_srcptr poly2, slong len2, slong len, gr_ctx_t ctx) - int _gr_poly_mullow(gr_ptr res, gr_srcptr poly1, slong len1, gr_srcptr poly2, slong len2, slong len, gr_ctx_t ctx) - int gr_poly_mullow(gr_poly_t res, const gr_poly_t poly1, const gr_poly_t poly2, slong len, gr_ctx_t ctx) + int _gr_poly_mullow_generic(gr_ptr res, gr_srcptr poly1, slong len1, gr_srcptr poly2, slong len2, slong len, gr_ctx_t ctx) noexcept + int _gr_poly_mullow(gr_ptr res, gr_srcptr poly1, slong len1, gr_srcptr poly2, slong len2, slong len, gr_ctx_t ctx) noexcept + int gr_poly_mullow(gr_poly_t res, const gr_poly_t poly1, const gr_poly_t poly2, slong len, gr_ctx_t ctx) noexcept - int gr_poly_mul_scalar(gr_poly_t res, const gr_poly_t poly, gr_srcptr c, gr_ctx_t ctx) + int gr_poly_mul_scalar(gr_poly_t res, const gr_poly_t poly, gr_srcptr c, gr_ctx_t ctx) noexcept - int _gr_poly_pow_series_ui_binexp(gr_ptr res, gr_srcptr f, slong flen, ulong exp, slong len, gr_ctx_t ctx) - int gr_poly_pow_series_ui_binexp(gr_poly_t res, const gr_poly_t poly, ulong exp, slong len, gr_ctx_t ctx) + int _gr_poly_pow_series_ui_binexp(gr_ptr res, gr_srcptr f, slong flen, ulong exp, slong len, gr_ctx_t ctx) noexcept + int gr_poly_pow_series_ui_binexp(gr_poly_t res, const gr_poly_t poly, ulong exp, slong len, gr_ctx_t ctx) noexcept - int _gr_poly_pow_series_ui(gr_ptr res, gr_srcptr f, slong flen, ulong exp, slong len, gr_ctx_t ctx) - int gr_poly_pow_series_ui(gr_poly_t res, const gr_poly_t poly, ulong exp, slong len, gr_ctx_t ctx) + int _gr_poly_pow_series_ui(gr_ptr res, gr_srcptr f, slong flen, ulong exp, slong len, gr_ctx_t ctx) noexcept + int gr_poly_pow_series_ui(gr_poly_t res, const gr_poly_t poly, ulong exp, slong len, gr_ctx_t ctx) noexcept - int _gr_poly_pow_ui_binexp(gr_ptr res, gr_srcptr f, slong flen, ulong exp, gr_ctx_t ctx) - int gr_poly_pow_ui_binexp(gr_poly_t res, const gr_poly_t poly, ulong exp, gr_ctx_t ctx) + int _gr_poly_pow_ui_binexp(gr_ptr res, gr_srcptr f, slong flen, ulong exp, gr_ctx_t ctx) noexcept + int gr_poly_pow_ui_binexp(gr_poly_t res, const gr_poly_t poly, ulong exp, gr_ctx_t ctx) noexcept - int _gr_poly_pow_ui(gr_ptr res, gr_srcptr f, slong flen, ulong exp, gr_ctx_t ctx) - int gr_poly_pow_ui(gr_poly_t res, const gr_poly_t poly, ulong exp, gr_ctx_t ctx) + int _gr_poly_pow_ui(gr_ptr res, gr_srcptr f, slong flen, ulong exp, gr_ctx_t ctx) noexcept + int gr_poly_pow_ui(gr_poly_t res, const gr_poly_t poly, ulong exp, gr_ctx_t ctx) noexcept - int gr_poly_pow_fmpz(gr_poly_t res, const gr_poly_t poly, const fmpz_t exp, gr_ctx_t ctx) + int gr_poly_pow_fmpz(gr_poly_t res, const gr_poly_t poly, const fmpz_t exp, gr_ctx_t ctx) noexcept - int _gr_poly_pow_series_fmpq_recurrence(gr_ptr h, gr_srcptr f, slong flen, const fmpq_t exp, slong len, int precomp, gr_ctx_t ctx) - int gr_poly_pow_series_fmpq_recurrence(gr_poly_t res, const gr_poly_t poly, const fmpq_t exp, slong len, gr_ctx_t ctx) + int _gr_poly_pow_series_fmpq_recurrence(gr_ptr h, gr_srcptr f, slong flen, const fmpq_t exp, slong len, int precomp, gr_ctx_t ctx) noexcept + int gr_poly_pow_series_fmpq_recurrence(gr_poly_t res, const gr_poly_t poly, const fmpq_t exp, slong len, gr_ctx_t ctx) noexcept - int _gr_poly_shift_left(gr_ptr res, gr_srcptr poly, slong len, slong n, gr_ctx_t ctx) - int gr_poly_shift_left(gr_poly_t res, const gr_poly_t poly, slong n, gr_ctx_t ctx) + int _gr_poly_shift_left(gr_ptr res, gr_srcptr poly, slong len, slong n, gr_ctx_t ctx) noexcept + int gr_poly_shift_left(gr_poly_t res, const gr_poly_t poly, slong n, gr_ctx_t ctx) noexcept - int _gr_poly_shift_right(gr_ptr res, gr_srcptr poly, slong len, slong n, gr_ctx_t ctx) - int gr_poly_shift_right(gr_poly_t res, const gr_poly_t poly, slong n, gr_ctx_t ctx) + int _gr_poly_shift_right(gr_ptr res, gr_srcptr poly, slong len, slong n, gr_ctx_t ctx) noexcept + int gr_poly_shift_right(gr_poly_t res, const gr_poly_t poly, slong n, gr_ctx_t ctx) noexcept - int _gr_poly_divrem_divconquer_preinv1(gr_ptr Q, gr_ptr R, gr_srcptr A, slong lenA, gr_srcptr B, slong lenB, gr_srcptr invB, slong cutoff, gr_ctx_t ctx) - int _gr_poly_divrem_divconquer_noinv(gr_ptr Q, gr_ptr R, gr_srcptr A, slong lenA, gr_srcptr B, slong lenB, slong cutoff, gr_ctx_t ctx) - int _gr_poly_divrem_divconquer(gr_ptr Q, gr_ptr R, gr_srcptr A, slong lenA, gr_srcptr B, slong lenB, slong cutoff, gr_ctx_t ctx) - int gr_poly_divrem_divconquer(gr_poly_t Q, gr_poly_t R, const gr_poly_t A, const gr_poly_t B, slong cutoff, gr_ctx_t ctx) - int _gr_poly_divrem_basecase_preinv1(gr_ptr Q, gr_ptr R, gr_srcptr A, slong lenA, gr_srcptr B, slong lenB, gr_srcptr invB, gr_ctx_t ctx) - int _gr_poly_divrem_basecase_noinv(gr_ptr Q, gr_ptr R, gr_srcptr A, slong lenA, gr_srcptr B, slong lenB, gr_ctx_t ctx) - int _gr_poly_divrem_basecase(gr_ptr Q, gr_ptr R, gr_srcptr A, slong lenA, gr_srcptr B, slong lenB, gr_ctx_t ctx) - int gr_poly_divrem_basecase(gr_poly_t Q, gr_poly_t R, const gr_poly_t A, const gr_poly_t B, gr_ctx_t ctx) - int _gr_poly_divrem_newton(gr_ptr Q, gr_ptr R, gr_srcptr A, slong lenA, gr_srcptr B, slong lenB, gr_ctx_t ctx) - int gr_poly_divrem_newton(gr_poly_t Q, gr_poly_t R, const gr_poly_t A, const gr_poly_t B, gr_ctx_t ctx) - int _gr_poly_divrem(gr_ptr Q, gr_ptr R, gr_srcptr A, slong lenA, gr_srcptr B, slong lenB, gr_ctx_t ctx) - int gr_poly_divrem(gr_poly_t Q, gr_poly_t R, const gr_poly_t A, const gr_poly_t B, gr_ctx_t ctx) + int _gr_poly_divrem_divconquer_preinv1(gr_ptr Q, gr_ptr R, gr_srcptr A, slong lenA, gr_srcptr B, slong lenB, gr_srcptr invB, slong cutoff, gr_ctx_t ctx) noexcept + int _gr_poly_divrem_divconquer_noinv(gr_ptr Q, gr_ptr R, gr_srcptr A, slong lenA, gr_srcptr B, slong lenB, slong cutoff, gr_ctx_t ctx) noexcept + int _gr_poly_divrem_divconquer(gr_ptr Q, gr_ptr R, gr_srcptr A, slong lenA, gr_srcptr B, slong lenB, slong cutoff, gr_ctx_t ctx) noexcept + int gr_poly_divrem_divconquer(gr_poly_t Q, gr_poly_t R, const gr_poly_t A, const gr_poly_t B, slong cutoff, gr_ctx_t ctx) noexcept + int _gr_poly_divrem_basecase_preinv1(gr_ptr Q, gr_ptr R, gr_srcptr A, slong lenA, gr_srcptr B, slong lenB, gr_srcptr invB, gr_ctx_t ctx) noexcept + int _gr_poly_divrem_basecase_noinv(gr_ptr Q, gr_ptr R, gr_srcptr A, slong lenA, gr_srcptr B, slong lenB, gr_ctx_t ctx) noexcept + int _gr_poly_divrem_basecase(gr_ptr Q, gr_ptr R, gr_srcptr A, slong lenA, gr_srcptr B, slong lenB, gr_ctx_t ctx) noexcept + int gr_poly_divrem_basecase(gr_poly_t Q, gr_poly_t R, const gr_poly_t A, const gr_poly_t B, gr_ctx_t ctx) noexcept + int _gr_poly_divrem_newton(gr_ptr Q, gr_ptr R, gr_srcptr A, slong lenA, gr_srcptr B, slong lenB, gr_ctx_t ctx) noexcept + int gr_poly_divrem_newton(gr_poly_t Q, gr_poly_t R, const gr_poly_t A, const gr_poly_t B, gr_ctx_t ctx) noexcept + int _gr_poly_divrem(gr_ptr Q, gr_ptr R, gr_srcptr A, slong lenA, gr_srcptr B, slong lenB, gr_ctx_t ctx) noexcept + int gr_poly_divrem(gr_poly_t Q, gr_poly_t R, const gr_poly_t A, const gr_poly_t B, gr_ctx_t ctx) noexcept # These functions implement Euclidean division with remainder: # given polynomials `A, B \in K[x]` where `K` is a field, with `B \ne 0`, # there is a unique quotient `Q` and remainder `R` such that `A = BQ + R` @@ -158,131 +158,131 @@ cdef extern from "flint_wrap.h": # The *noinv* versions perform repeated checked divisions # by the leading coefficient. - int _gr_poly_div_divconquer_preinv1(gr_ptr Q, gr_srcptr A, slong lenA, gr_srcptr B, slong lenB, gr_srcptr invB, slong cutoff, gr_ctx_t ctx) - int _gr_poly_div_divconquer_noinv(gr_ptr Q, gr_srcptr A, slong lenA, gr_srcptr B, slong lenB, slong cutoff, gr_ctx_t ctx) - int _gr_poly_div_divconquer(gr_ptr Q, gr_srcptr A, slong lenA, gr_srcptr B, slong lenB, slong cutoff, gr_ctx_t ctx) - int gr_poly_div_divconquer(gr_poly_t Q, const gr_poly_t A, const gr_poly_t B, slong cutoff, gr_ctx_t ctx) - int _gr_poly_div_basecase_preinv1(gr_ptr Q, gr_srcptr A, slong lenA, gr_srcptr B, slong lenB, gr_srcptr invB, gr_ctx_t ctx) - int _gr_poly_div_basecase_noinv(gr_ptr Q, gr_srcptr A, slong lenA, gr_srcptr B, slong lenB, gr_ctx_t ctx) - int _gr_poly_div_basecase(gr_ptr Q, gr_srcptr A, slong lenA, gr_srcptr B, slong lenB, gr_ctx_t ctx) - int gr_poly_div_basecase(gr_poly_t Q, const gr_poly_t A, const gr_poly_t B, gr_ctx_t ctx) - int _gr_poly_div_newton(gr_ptr Q, gr_srcptr A, slong lenA, gr_srcptr B, slong lenB, gr_ctx_t ctx) - int gr_poly_div_newton(gr_poly_t Q, const gr_poly_t A, const gr_poly_t B, gr_ctx_t ctx) - int _gr_poly_div(gr_ptr Q, gr_srcptr A, slong lenA, gr_srcptr B, slong lenB, gr_ctx_t ctx) - int gr_poly_div(gr_poly_t Q, const gr_poly_t A, const gr_poly_t B, gr_ctx_t ctx) + int _gr_poly_div_divconquer_preinv1(gr_ptr Q, gr_srcptr A, slong lenA, gr_srcptr B, slong lenB, gr_srcptr invB, slong cutoff, gr_ctx_t ctx) noexcept + int _gr_poly_div_divconquer_noinv(gr_ptr Q, gr_srcptr A, slong lenA, gr_srcptr B, slong lenB, slong cutoff, gr_ctx_t ctx) noexcept + int _gr_poly_div_divconquer(gr_ptr Q, gr_srcptr A, slong lenA, gr_srcptr B, slong lenB, slong cutoff, gr_ctx_t ctx) noexcept + int gr_poly_div_divconquer(gr_poly_t Q, const gr_poly_t A, const gr_poly_t B, slong cutoff, gr_ctx_t ctx) noexcept + int _gr_poly_div_basecase_preinv1(gr_ptr Q, gr_srcptr A, slong lenA, gr_srcptr B, slong lenB, gr_srcptr invB, gr_ctx_t ctx) noexcept + int _gr_poly_div_basecase_noinv(gr_ptr Q, gr_srcptr A, slong lenA, gr_srcptr B, slong lenB, gr_ctx_t ctx) noexcept + int _gr_poly_div_basecase(gr_ptr Q, gr_srcptr A, slong lenA, gr_srcptr B, slong lenB, gr_ctx_t ctx) noexcept + int gr_poly_div_basecase(gr_poly_t Q, const gr_poly_t A, const gr_poly_t B, gr_ctx_t ctx) noexcept + int _gr_poly_div_newton(gr_ptr Q, gr_srcptr A, slong lenA, gr_srcptr B, slong lenB, gr_ctx_t ctx) noexcept + int gr_poly_div_newton(gr_poly_t Q, const gr_poly_t A, const gr_poly_t B, gr_ctx_t ctx) noexcept + int _gr_poly_div(gr_ptr Q, gr_srcptr A, slong lenA, gr_srcptr B, slong lenB, gr_ctx_t ctx) noexcept + int gr_poly_div(gr_poly_t Q, const gr_poly_t A, const gr_poly_t B, gr_ctx_t ctx) noexcept # Versions of the *divrem* functions which output only the quotient. # These are generally faster. - int _gr_poly_rem(gr_ptr R, gr_srcptr A, slong lenA, gr_srcptr B, slong lenB, gr_ctx_t ctx) - int gr_poly_rem(gr_poly_t R, const gr_poly_t A, const gr_poly_t B, gr_ctx_t ctx) + int _gr_poly_rem(gr_ptr R, gr_srcptr A, slong lenA, gr_srcptr B, slong lenB, gr_ctx_t ctx) noexcept + int gr_poly_rem(gr_poly_t R, const gr_poly_t A, const gr_poly_t B, gr_ctx_t ctx) noexcept # Versions of the *divrem* functions which output only the remainder. - int _gr_poly_inv_series_newton(gr_ptr res, gr_srcptr A, slong Alen, slong len, slong cutoff, gr_ctx_t ctx) - int gr_poly_inv_series_newton(gr_poly_t res, const gr_poly_t A, slong len, slong cutoff, gr_ctx_t ctx) - int _gr_poly_inv_series_basecase_preinv1(gr_ptr res, gr_srcptr A, slong Alen, gr_srcptr Ainv, slong len, gr_ctx_t ctx) - int _gr_poly_inv_series_basecase(gr_ptr res, gr_srcptr A, slong Alen, slong len, gr_ctx_t ctx) - int gr_poly_inv_series_basecase(gr_poly_t res, const gr_poly_t A, slong len, gr_ctx_t ctx) - int _gr_poly_inv_series(gr_ptr res, gr_srcptr A, slong Alen, slong len, gr_ctx_t ctx) - int gr_poly_inv_series(gr_poly_t res, const gr_poly_t A, slong len, gr_ctx_t ctx) - - int _gr_poly_div_series_newton(gr_ptr res, gr_srcptr A, slong Alen, gr_srcptr B, slong Blen, slong len, slong cutoff, gr_ctx_t ctx) - int gr_poly_div_series_newton(gr_poly_t res, const gr_poly_t A, const gr_poly_t B, slong len, slong cutoff, gr_ctx_t ctx) - int _gr_poly_div_series_divconquer(gr_ptr res, gr_srcptr B, slong Blen, gr_srcptr A, slong Alen, slong len, slong cutoff, gr_ctx_t ctx) - int gr_poly_div_series_divconquer(gr_poly_t Q, const gr_poly_t A, const gr_poly_t B, slong len, slong cutoff, gr_ctx_t ctx) - int _gr_poly_div_series_invmul(gr_ptr res, gr_srcptr B, slong Blen, gr_srcptr A, slong Alen, slong len, gr_ctx_t ctx) - int gr_poly_div_series_invmul(gr_poly_t res, const gr_poly_t A, const gr_poly_t B, slong len, gr_ctx_t ctx) - int _gr_poly_div_series_basecase_preinv1(gr_ptr Q, gr_srcptr A, slong Alen, gr_srcptr B, slong Blen, gr_srcptr Binv, slong len, gr_ctx_t ctx) - int _gr_poly_div_series_basecase_noinv(gr_ptr Q, gr_srcptr A, slong Alen, gr_srcptr B, slong Blen, slong len, gr_ctx_t ctx) - int _gr_poly_div_series_basecase(gr_ptr res, gr_srcptr A, slong Alen, gr_srcptr B, slong Blen, slong len, gr_ctx_t ctx) - int gr_poly_div_series_basecase(gr_poly_t res, const gr_poly_t A, const gr_poly_t B, slong len, gr_ctx_t ctx) - int _gr_poly_div_series(gr_ptr res, gr_srcptr A, slong Alen, gr_srcptr B, slong Blen, slong len, gr_ctx_t ctx) - int gr_poly_div_series(gr_poly_t res, const gr_poly_t A, const gr_poly_t B, slong len, gr_ctx_t ctx) - - int _gr_poly_divexact_basecase_bidirectional(gr_ptr Q, gr_srcptr A, slong Alen, gr_srcptr B, slong Blen, gr_ctx_t ctx) - int gr_poly_divexact_basecase_bidirectional(gr_poly_t Q, const gr_poly_t A, const gr_poly_t B, gr_ctx_t ctx) - int _gr_poly_divexact_bidirectional(gr_ptr Q, gr_srcptr A, slong Alen, gr_srcptr B, slong Blen, gr_ctx_t ctx) - int gr_poly_divexact_bidirectional(gr_poly_t Q, const gr_poly_t A, const gr_poly_t B, gr_ctx_t ctx) - int _gr_poly_divexact_basecase_noinv(gr_ptr Q, gr_srcptr A, slong Alen, gr_srcptr B, slong Blen, gr_ctx_t ctx) - int _gr_poly_divexact_basecase(gr_ptr Q, gr_srcptr A, slong Alen, gr_srcptr B, slong Blen, gr_ctx_t ctx) - int gr_poly_divexact_basecase(gr_poly_t Q, const gr_poly_t A, const gr_poly_t B, gr_ctx_t ctx) - - int _gr_poly_divexact_series_basecase_noinv(gr_ptr Q, gr_srcptr A, slong Alen, gr_srcptr B, slong Blen, slong len, gr_ctx_t ctx) - int _gr_poly_divexact_series_basecase(gr_ptr Q, gr_srcptr A, slong Alen, gr_srcptr B, slong Blen, slong len, gr_ctx_t ctx) - int gr_poly_divexact_series_basecase(gr_poly_t Q, const gr_poly_t A, const gr_poly_t B, slong len, gr_ctx_t ctx) - - int _gr_poly_sqrt_series_newton(gr_ptr res, gr_srcptr f, slong flen, slong len, slong cutoff, gr_ctx_t ctx) - int gr_poly_sqrt_series_newton(gr_poly_t res, const gr_poly_t f, slong len, slong cutoff, gr_ctx_t ctx) - int _gr_poly_sqrt_series_basecase(gr_ptr res, gr_srcptr f, slong flen, slong len, gr_ctx_t ctx) - int gr_poly_sqrt_series_basecase(gr_poly_t res, const gr_poly_t f, slong len, gr_ctx_t ctx) - int _gr_poly_sqrt_series_miller(gr_ptr res, gr_srcptr f, slong flen, slong len, gr_ctx_t ctx) - int gr_poly_sqrt_series_miller(gr_poly_t res, const gr_poly_t f, slong len, gr_ctx_t ctx) - int _gr_poly_sqrt_series(gr_ptr res, gr_srcptr f, slong flen, slong len, gr_ctx_t ctx) - int gr_poly_sqrt_series(gr_poly_t res, const gr_poly_t f, slong len, gr_ctx_t ctx) - - int _gr_poly_rsqrt_series_newton(gr_ptr res, gr_srcptr f, slong flen, slong len, slong cutoff, gr_ctx_t ctx) - int gr_poly_rsqrt_series_newton(gr_poly_t res, const gr_poly_t f, slong len, slong cutoff, gr_ctx_t ctx) - int _gr_poly_rsqrt_series_basecase(gr_ptr res, gr_srcptr f, slong flen, slong len, gr_ctx_t ctx) - int gr_poly_rsqrt_series_basecase(gr_poly_t res, const gr_poly_t f, slong len, gr_ctx_t ctx) - int _gr_poly_rsqrt_series_miller(gr_ptr res, gr_srcptr f, slong flen, slong len, gr_ctx_t ctx) - int gr_poly_rsqrt_series_miller(gr_poly_t res, const gr_poly_t f, slong len, gr_ctx_t ctx) - int _gr_poly_rsqrt_series(gr_ptr res, gr_srcptr f, slong flen, slong len, gr_ctx_t ctx) - int gr_poly_rsqrt_series(gr_poly_t res, const gr_poly_t f, slong len, gr_ctx_t ctx) - - int _gr_poly_evaluate_rectangular(gr_ptr res, gr_srcptr poly, slong len, gr_srcptr x, gr_ctx_t ctx) - int gr_poly_evaluate_rectangular(gr_ptr res, const gr_poly_t poly, gr_srcptr x, gr_ctx_t ctx) - - int _gr_poly_evaluate_horner(gr_ptr res, gr_srcptr poly, slong len, gr_srcptr x, gr_ctx_t ctx) - int gr_poly_evaluate_horner(gr_ptr res, const gr_poly_t poly, gr_srcptr x, gr_ctx_t ctx) - - int _gr_poly_evaluate(gr_ptr res, gr_srcptr poly, slong len, gr_srcptr x, gr_ctx_t ctx) - int gr_poly_evaluate(gr_ptr res, const gr_poly_t poly, gr_srcptr x, gr_ctx_t ctx) + int _gr_poly_inv_series_newton(gr_ptr res, gr_srcptr A, slong Alen, slong len, slong cutoff, gr_ctx_t ctx) noexcept + int gr_poly_inv_series_newton(gr_poly_t res, const gr_poly_t A, slong len, slong cutoff, gr_ctx_t ctx) noexcept + int _gr_poly_inv_series_basecase_preinv1(gr_ptr res, gr_srcptr A, slong Alen, gr_srcptr Ainv, slong len, gr_ctx_t ctx) noexcept + int _gr_poly_inv_series_basecase(gr_ptr res, gr_srcptr A, slong Alen, slong len, gr_ctx_t ctx) noexcept + int gr_poly_inv_series_basecase(gr_poly_t res, const gr_poly_t A, slong len, gr_ctx_t ctx) noexcept + int _gr_poly_inv_series(gr_ptr res, gr_srcptr A, slong Alen, slong len, gr_ctx_t ctx) noexcept + int gr_poly_inv_series(gr_poly_t res, const gr_poly_t A, slong len, gr_ctx_t ctx) noexcept + + int _gr_poly_div_series_newton(gr_ptr res, gr_srcptr A, slong Alen, gr_srcptr B, slong Blen, slong len, slong cutoff, gr_ctx_t ctx) noexcept + int gr_poly_div_series_newton(gr_poly_t res, const gr_poly_t A, const gr_poly_t B, slong len, slong cutoff, gr_ctx_t ctx) noexcept + int _gr_poly_div_series_divconquer(gr_ptr res, gr_srcptr B, slong Blen, gr_srcptr A, slong Alen, slong len, slong cutoff, gr_ctx_t ctx) noexcept + int gr_poly_div_series_divconquer(gr_poly_t Q, const gr_poly_t A, const gr_poly_t B, slong len, slong cutoff, gr_ctx_t ctx) noexcept + int _gr_poly_div_series_invmul(gr_ptr res, gr_srcptr B, slong Blen, gr_srcptr A, slong Alen, slong len, gr_ctx_t ctx) noexcept + int gr_poly_div_series_invmul(gr_poly_t res, const gr_poly_t A, const gr_poly_t B, slong len, gr_ctx_t ctx) noexcept + int _gr_poly_div_series_basecase_preinv1(gr_ptr Q, gr_srcptr A, slong Alen, gr_srcptr B, slong Blen, gr_srcptr Binv, slong len, gr_ctx_t ctx) noexcept + int _gr_poly_div_series_basecase_noinv(gr_ptr Q, gr_srcptr A, slong Alen, gr_srcptr B, slong Blen, slong len, gr_ctx_t ctx) noexcept + int _gr_poly_div_series_basecase(gr_ptr res, gr_srcptr A, slong Alen, gr_srcptr B, slong Blen, slong len, gr_ctx_t ctx) noexcept + int gr_poly_div_series_basecase(gr_poly_t res, const gr_poly_t A, const gr_poly_t B, slong len, gr_ctx_t ctx) noexcept + int _gr_poly_div_series(gr_ptr res, gr_srcptr A, slong Alen, gr_srcptr B, slong Blen, slong len, gr_ctx_t ctx) noexcept + int gr_poly_div_series(gr_poly_t res, const gr_poly_t A, const gr_poly_t B, slong len, gr_ctx_t ctx) noexcept + + int _gr_poly_divexact_basecase_bidirectional(gr_ptr Q, gr_srcptr A, slong Alen, gr_srcptr B, slong Blen, gr_ctx_t ctx) noexcept + int gr_poly_divexact_basecase_bidirectional(gr_poly_t Q, const gr_poly_t A, const gr_poly_t B, gr_ctx_t ctx) noexcept + int _gr_poly_divexact_bidirectional(gr_ptr Q, gr_srcptr A, slong Alen, gr_srcptr B, slong Blen, gr_ctx_t ctx) noexcept + int gr_poly_divexact_bidirectional(gr_poly_t Q, const gr_poly_t A, const gr_poly_t B, gr_ctx_t ctx) noexcept + int _gr_poly_divexact_basecase_noinv(gr_ptr Q, gr_srcptr A, slong Alen, gr_srcptr B, slong Blen, gr_ctx_t ctx) noexcept + int _gr_poly_divexact_basecase(gr_ptr Q, gr_srcptr A, slong Alen, gr_srcptr B, slong Blen, gr_ctx_t ctx) noexcept + int gr_poly_divexact_basecase(gr_poly_t Q, const gr_poly_t A, const gr_poly_t B, gr_ctx_t ctx) noexcept + + int _gr_poly_divexact_series_basecase_noinv(gr_ptr Q, gr_srcptr A, slong Alen, gr_srcptr B, slong Blen, slong len, gr_ctx_t ctx) noexcept + int _gr_poly_divexact_series_basecase(gr_ptr Q, gr_srcptr A, slong Alen, gr_srcptr B, slong Blen, slong len, gr_ctx_t ctx) noexcept + int gr_poly_divexact_series_basecase(gr_poly_t Q, const gr_poly_t A, const gr_poly_t B, slong len, gr_ctx_t ctx) noexcept + + int _gr_poly_sqrt_series_newton(gr_ptr res, gr_srcptr f, slong flen, slong len, slong cutoff, gr_ctx_t ctx) noexcept + int gr_poly_sqrt_series_newton(gr_poly_t res, const gr_poly_t f, slong len, slong cutoff, gr_ctx_t ctx) noexcept + int _gr_poly_sqrt_series_basecase(gr_ptr res, gr_srcptr f, slong flen, slong len, gr_ctx_t ctx) noexcept + int gr_poly_sqrt_series_basecase(gr_poly_t res, const gr_poly_t f, slong len, gr_ctx_t ctx) noexcept + int _gr_poly_sqrt_series_miller(gr_ptr res, gr_srcptr f, slong flen, slong len, gr_ctx_t ctx) noexcept + int gr_poly_sqrt_series_miller(gr_poly_t res, const gr_poly_t f, slong len, gr_ctx_t ctx) noexcept + int _gr_poly_sqrt_series(gr_ptr res, gr_srcptr f, slong flen, slong len, gr_ctx_t ctx) noexcept + int gr_poly_sqrt_series(gr_poly_t res, const gr_poly_t f, slong len, gr_ctx_t ctx) noexcept + + int _gr_poly_rsqrt_series_newton(gr_ptr res, gr_srcptr f, slong flen, slong len, slong cutoff, gr_ctx_t ctx) noexcept + int gr_poly_rsqrt_series_newton(gr_poly_t res, const gr_poly_t f, slong len, slong cutoff, gr_ctx_t ctx) noexcept + int _gr_poly_rsqrt_series_basecase(gr_ptr res, gr_srcptr f, slong flen, slong len, gr_ctx_t ctx) noexcept + int gr_poly_rsqrt_series_basecase(gr_poly_t res, const gr_poly_t f, slong len, gr_ctx_t ctx) noexcept + int _gr_poly_rsqrt_series_miller(gr_ptr res, gr_srcptr f, slong flen, slong len, gr_ctx_t ctx) noexcept + int gr_poly_rsqrt_series_miller(gr_poly_t res, const gr_poly_t f, slong len, gr_ctx_t ctx) noexcept + int _gr_poly_rsqrt_series(gr_ptr res, gr_srcptr f, slong flen, slong len, gr_ctx_t ctx) noexcept + int gr_poly_rsqrt_series(gr_poly_t res, const gr_poly_t f, slong len, gr_ctx_t ctx) noexcept + + int _gr_poly_evaluate_rectangular(gr_ptr res, gr_srcptr poly, slong len, gr_srcptr x, gr_ctx_t ctx) noexcept + int gr_poly_evaluate_rectangular(gr_ptr res, const gr_poly_t poly, gr_srcptr x, gr_ctx_t ctx) noexcept + + int _gr_poly_evaluate_horner(gr_ptr res, gr_srcptr poly, slong len, gr_srcptr x, gr_ctx_t ctx) noexcept + int gr_poly_evaluate_horner(gr_ptr res, const gr_poly_t poly, gr_srcptr x, gr_ctx_t ctx) noexcept + + int _gr_poly_evaluate(gr_ptr res, gr_srcptr poly, slong len, gr_srcptr x, gr_ctx_t ctx) noexcept + int gr_poly_evaluate(gr_ptr res, const gr_poly_t poly, gr_srcptr x, gr_ctx_t ctx) noexcept # Set *res* to *poly* evaluated at *x*. - int _gr_poly_evaluate_other_horner(gr_ptr res, gr_srcptr f, slong len, const gr_srcptr x, gr_ctx_t x_ctx, gr_ctx_t ctx) - int gr_poly_evaluate_other_horner(gr_ptr res, const gr_poly_t f, gr_srcptr x, gr_ctx_t x_ctx, gr_ctx_t ctx) - int _gr_poly_evaluate_other_rectangular(gr_ptr res, gr_srcptr f, slong len, const gr_srcptr x, gr_ctx_t x_ctx, gr_ctx_t ctx) - int gr_poly_evaluate_other_rectangular(gr_ptr res, const gr_poly_t f, gr_srcptr x, gr_ctx_t x_ctx, gr_ctx_t ctx) - int _gr_poly_evaluate_other(gr_ptr res, gr_srcptr f, slong len, const gr_srcptr x, gr_ctx_t x_ctx, gr_ctx_t ctx) - int gr_poly_evaluate_other(gr_ptr res, const gr_poly_t f, gr_srcptr x, gr_ctx_t x_ctx, gr_ctx_t ctx) + int _gr_poly_evaluate_other_horner(gr_ptr res, gr_srcptr f, slong len, const gr_srcptr x, gr_ctx_t x_ctx, gr_ctx_t ctx) noexcept + int gr_poly_evaluate_other_horner(gr_ptr res, const gr_poly_t f, gr_srcptr x, gr_ctx_t x_ctx, gr_ctx_t ctx) noexcept + int _gr_poly_evaluate_other_rectangular(gr_ptr res, gr_srcptr f, slong len, const gr_srcptr x, gr_ctx_t x_ctx, gr_ctx_t ctx) noexcept + int gr_poly_evaluate_other_rectangular(gr_ptr res, const gr_poly_t f, gr_srcptr x, gr_ctx_t x_ctx, gr_ctx_t ctx) noexcept + int _gr_poly_evaluate_other(gr_ptr res, gr_srcptr f, slong len, const gr_srcptr x, gr_ctx_t x_ctx, gr_ctx_t ctx) noexcept + int gr_poly_evaluate_other(gr_ptr res, const gr_poly_t f, gr_srcptr x, gr_ctx_t x_ctx, gr_ctx_t ctx) noexcept # Set *res* to *poly* evaluated at *x*, where the coefficients of *f* # belong to *ctx* while both *x* and *res* belong to *x_ctx*. - gr_ptr * _gr_poly_tree_alloc(slong len, gr_ctx_t ctx) + gr_ptr * _gr_poly_tree_alloc(slong len, gr_ctx_t ctx) noexcept - void _gr_poly_tree_free(gr_ptr * tree, slong len, gr_ctx_t ctx) + void _gr_poly_tree_free(gr_ptr * tree, slong len, gr_ctx_t ctx) noexcept - int _gr_poly_tree_build(gr_ptr * tree, gr_srcptr roots, slong len, gr_ctx_t ctx) + int _gr_poly_tree_build(gr_ptr * tree, gr_srcptr roots, slong len, gr_ctx_t ctx) noexcept - int _gr_poly_evaluate_vec_fast_precomp(gr_ptr vs, gr_srcptr poly, slong plen, gr_ptr * tree, slong len, gr_ctx_t ctx) + int _gr_poly_evaluate_vec_fast_precomp(gr_ptr vs, gr_srcptr poly, slong plen, gr_ptr * tree, slong len, gr_ctx_t ctx) noexcept - int _gr_poly_evaluate_vec_fast(gr_ptr ys, gr_srcptr poly, slong plen, gr_srcptr xs, slong n, gr_ctx_t ctx) + int _gr_poly_evaluate_vec_fast(gr_ptr ys, gr_srcptr poly, slong plen, gr_srcptr xs, slong n, gr_ctx_t ctx) noexcept - int gr_poly_evaluate_vec_fast(gr_vec_t ys, const gr_poly_t poly, const gr_vec_t xs, gr_ctx_t ctx) + int gr_poly_evaluate_vec_fast(gr_vec_t ys, const gr_poly_t poly, const gr_vec_t xs, gr_ctx_t ctx) noexcept - int _gr_poly_evaluate_vec_iter(gr_ptr ys, gr_srcptr poly, slong plen, gr_srcptr xs, slong n, gr_ctx_t ctx) + int _gr_poly_evaluate_vec_iter(gr_ptr ys, gr_srcptr poly, slong plen, gr_srcptr xs, slong n, gr_ctx_t ctx) noexcept - int gr_poly_evaluate_vec_iter(gr_vec_t ys, const gr_poly_t poly, const gr_vec_t xs, gr_ctx_t ctx) + int gr_poly_evaluate_vec_iter(gr_vec_t ys, const gr_poly_t poly, const gr_vec_t xs, gr_ctx_t ctx) noexcept - int _gr_poly_taylor_shift_horner(gr_ptr res, gr_srcptr poly, slong len, gr_srcptr c, gr_ctx_t ctx) - int gr_poly_taylor_shift_horner(gr_poly_t res, const gr_poly_t poly, gr_srcptr c, gr_ctx_t ctx) - int _gr_poly_taylor_shift_divconquer(gr_ptr res, gr_srcptr poly, slong len, gr_srcptr c, gr_ctx_t ctx) - int gr_poly_taylor_shift_divconquer(gr_poly_t res, const gr_poly_t poly, gr_srcptr c, gr_ctx_t ctx) - int _gr_poly_taylor_shift_convolution(gr_ptr res, gr_srcptr poly, slong len, gr_srcptr c, gr_ctx_t ctx) - int gr_poly_taylor_shift_convolution(gr_poly_t res, const gr_poly_t poly, gr_srcptr c, gr_ctx_t ctx) - int _gr_poly_taylor_shift(gr_ptr res, gr_srcptr poly, slong len, gr_srcptr c, gr_ctx_t ctx) - int gr_poly_taylor_shift(gr_poly_t res, const gr_poly_t poly, gr_srcptr c, gr_ctx_t ctx) + int _gr_poly_taylor_shift_horner(gr_ptr res, gr_srcptr poly, slong len, gr_srcptr c, gr_ctx_t ctx) noexcept + int gr_poly_taylor_shift_horner(gr_poly_t res, const gr_poly_t poly, gr_srcptr c, gr_ctx_t ctx) noexcept + int _gr_poly_taylor_shift_divconquer(gr_ptr res, gr_srcptr poly, slong len, gr_srcptr c, gr_ctx_t ctx) noexcept + int gr_poly_taylor_shift_divconquer(gr_poly_t res, const gr_poly_t poly, gr_srcptr c, gr_ctx_t ctx) noexcept + int _gr_poly_taylor_shift_convolution(gr_ptr res, gr_srcptr poly, slong len, gr_srcptr c, gr_ctx_t ctx) noexcept + int gr_poly_taylor_shift_convolution(gr_poly_t res, const gr_poly_t poly, gr_srcptr c, gr_ctx_t ctx) noexcept + int _gr_poly_taylor_shift(gr_ptr res, gr_srcptr poly, slong len, gr_srcptr c, gr_ctx_t ctx) noexcept + int gr_poly_taylor_shift(gr_poly_t res, const gr_poly_t poly, gr_srcptr c, gr_ctx_t ctx) noexcept # Sets *res* to the Taylor shift `f(x+c)`, where *f* is given by # *poly*, computed respectively using # an optimized form of Horner's rule, divide-and-conquer, a single # convolution, and an automatic choice between the three algorithms. # The underscore methods support aliasing. - int _gr_poly_compose_horner(gr_ptr res, gr_srcptr poly1, slong len1, gr_srcptr poly2, slong len2, gr_ctx_t ctx) - int gr_poly_compose_horner(gr_poly_t res, const gr_poly_t poly1, const gr_poly_t poly2, gr_ctx_t ctx) - int _gr_poly_compose_divconquer(gr_ptr res, gr_srcptr poly1, slong len1, gr_srcptr poly2, slong len2, gr_ctx_t ctx) - int gr_poly_compose_divconquer(gr_poly_t res, const gr_poly_t poly1, const gr_poly_t poly2, gr_ctx_t ctx) - int _gr_poly_compose(gr_ptr res, gr_srcptr poly1, slong len1, gr_srcptr poly2, slong len2, gr_ctx_t ctx) - int gr_poly_compose(gr_poly_t res, const gr_poly_t poly1, const gr_poly_t poly2, gr_ctx_t ctx) + int _gr_poly_compose_horner(gr_ptr res, gr_srcptr poly1, slong len1, gr_srcptr poly2, slong len2, gr_ctx_t ctx) noexcept + int gr_poly_compose_horner(gr_poly_t res, const gr_poly_t poly1, const gr_poly_t poly2, gr_ctx_t ctx) noexcept + int _gr_poly_compose_divconquer(gr_ptr res, gr_srcptr poly1, slong len1, gr_srcptr poly2, slong len2, gr_ctx_t ctx) noexcept + int gr_poly_compose_divconquer(gr_poly_t res, const gr_poly_t poly1, const gr_poly_t poly2, gr_ctx_t ctx) noexcept + int _gr_poly_compose(gr_ptr res, gr_srcptr poly1, slong len1, gr_srcptr poly2, slong len2, gr_ctx_t ctx) noexcept + int gr_poly_compose(gr_poly_t res, const gr_poly_t poly1, const gr_poly_t poly2, gr_ctx_t ctx) noexcept # Sets *res* to the composition `f(g(x))` where *f* is given by *poly1* # and *g* is given by *poly2*, respectively using Horner's rule, # divide-and-conquer, and an automatic choice between the two algorithms. @@ -291,14 +291,14 @@ cdef extern from "flint_wrap.h": # The underscore methods do not support aliasing of the output # with either input polynomial. - int _gr_poly_compose_series_horner(gr_ptr res, gr_srcptr poly1, slong len1, gr_srcptr poly2, slong len2, slong n, gr_ctx_t ctx) - int gr_poly_compose_series_horner(gr_poly_t res, const gr_poly_t poly1, const gr_poly_t poly2, slong n, gr_ctx_t ctx) - int _gr_poly_compose_series_brent_kung(gr_ptr res, gr_srcptr poly1, slong len1, gr_srcptr poly2, slong len2, slong n, gr_ctx_t ctx) - int gr_poly_compose_series_brent_kung(gr_poly_t res, const gr_poly_t poly1, const gr_poly_t poly2, slong n, gr_ctx_t ctx) - int _gr_poly_compose_series_divconquer(gr_ptr res, gr_srcptr poly1, slong len1, gr_srcptr poly2, slong len2, slong n, gr_ctx_t ctx) - int gr_poly_compose_series_divconquer(gr_poly_t res, const gr_poly_t poly1, const gr_poly_t poly2, slong n, gr_ctx_t ctx) - int _gr_poly_compose_series(gr_ptr res, gr_srcptr poly1, slong len1, gr_srcptr poly2, slong len2, slong n, gr_ctx_t ctx) - int gr_poly_compose_series(gr_poly_t res, const gr_poly_t poly1, const gr_poly_t poly2, slong n, gr_ctx_t ctx) + int _gr_poly_compose_series_horner(gr_ptr res, gr_srcptr poly1, slong len1, gr_srcptr poly2, slong len2, slong n, gr_ctx_t ctx) noexcept + int gr_poly_compose_series_horner(gr_poly_t res, const gr_poly_t poly1, const gr_poly_t poly2, slong n, gr_ctx_t ctx) noexcept + int _gr_poly_compose_series_brent_kung(gr_ptr res, gr_srcptr poly1, slong len1, gr_srcptr poly2, slong len2, slong n, gr_ctx_t ctx) noexcept + int gr_poly_compose_series_brent_kung(gr_poly_t res, const gr_poly_t poly1, const gr_poly_t poly2, slong n, gr_ctx_t ctx) noexcept + int _gr_poly_compose_series_divconquer(gr_ptr res, gr_srcptr poly1, slong len1, gr_srcptr poly2, slong len2, slong n, gr_ctx_t ctx) noexcept + int gr_poly_compose_series_divconquer(gr_poly_t res, const gr_poly_t poly1, const gr_poly_t poly2, slong n, gr_ctx_t ctx) noexcept + int _gr_poly_compose_series(gr_ptr res, gr_srcptr poly1, slong len1, gr_srcptr poly2, slong len2, slong n, gr_ctx_t ctx) noexcept + int gr_poly_compose_series(gr_poly_t res, const gr_poly_t poly1, const gr_poly_t poly2, slong n, gr_ctx_t ctx) noexcept # Sets *res* to the power series composition `h(x) = f(g(x))` truncated # to order `O(x^n)` where `f` is given by *poly1* and `g` is given by *poly2*, # respectively using Horner's rule, the Brent-Kung baby step-giant step @@ -309,22 +309,22 @@ cdef extern from "flint_wrap.h": # The underscore methods do not support aliasing of the output # with either input polynomial, and do not zero-pad the result. - int _gr_poly_derivative(gr_ptr res, gr_srcptr poly, slong len, gr_ctx_t ctx) - int gr_poly_derivative(gr_poly_t res, const gr_poly_t poly, gr_ctx_t ctx) + int _gr_poly_derivative(gr_ptr res, gr_srcptr poly, slong len, gr_ctx_t ctx) noexcept + int gr_poly_derivative(gr_poly_t res, const gr_poly_t poly, gr_ctx_t ctx) noexcept - int _gr_poly_nth_derivative(gr_ptr res, gr_srcptr poly, ulong n, slong len, gr_ctx_t ctx) - int gr_poly_nth_derivative(gr_poly_t res, const gr_poly_t poly, ulong n, gr_ctx_t ctx) + int _gr_poly_nth_derivative(gr_ptr res, gr_srcptr poly, ulong n, slong len, gr_ctx_t ctx) noexcept + int gr_poly_nth_derivative(gr_poly_t res, const gr_poly_t poly, ulong n, gr_ctx_t ctx) noexcept - int _gr_poly_integral(gr_ptr res, gr_srcptr poly, slong len, gr_ctx_t ctx) - int gr_poly_integral(gr_poly_t res, const gr_poly_t poly, gr_ctx_t ctx) + int _gr_poly_integral(gr_ptr res, gr_srcptr poly, slong len, gr_ctx_t ctx) noexcept + int gr_poly_integral(gr_poly_t res, const gr_poly_t poly, gr_ctx_t ctx) noexcept - int _gr_poly_make_monic(gr_ptr res, gr_srcptr poly, slong len, gr_ctx_t ctx) - int gr_poly_make_monic(gr_poly_t res, const gr_poly_t src, gr_ctx_t ctx) + int _gr_poly_make_monic(gr_ptr res, gr_srcptr poly, slong len, gr_ctx_t ctx) noexcept + int gr_poly_make_monic(gr_poly_t res, const gr_poly_t src, gr_ctx_t ctx) noexcept - truth_t _gr_poly_is_monic(gr_srcptr poly, slong len, gr_ctx_t ctx) - truth_t gr_poly_is_monic(const gr_poly_t res, gr_ctx_t ctx) + truth_t _gr_poly_is_monic(gr_srcptr poly, slong len, gr_ctx_t ctx) noexcept + truth_t gr_poly_is_monic(const gr_poly_t res, gr_ctx_t ctx) noexcept - int _gr_poly_hgcd(gr_ptr r, slong * sgn, gr_ptr * M, slong * lenM, gr_ptr A, slong * lenA, gr_ptr B, slong * lenB, gr_srcptr a, slong lena, gr_srcptr b, slong lenb, slong cutoff, gr_ctx_t ctx) + int _gr_poly_hgcd(gr_ptr r, slong * sgn, gr_ptr * M, slong * lenM, gr_ptr A, slong * lenA, gr_ptr B, slong * lenB, gr_srcptr a, slong lena, gr_srcptr b, slong lenb, slong cutoff, gr_ctx_t ctx) noexcept # Computes the HGCD of `a` and `b`, that is, a matrix `M`, a sign `\sigma` # and two polynomials `A` and `B` such that # .. math :: @@ -338,12 +338,12 @@ cdef extern from "flint_wrap.h": # If `r` is not ``NULL``, writes to that variable the corresponding value # for computing resultants using the HGCD algorithm. - int _gr_poly_gcd_hgcd(gr_ptr G, slong * _lenG, gr_srcptr A, slong lenA, gr_srcptr B, slong lenB, slong inner_cutoff, slong cutoff, gr_ctx_t ctx) - int gr_poly_gcd_hgcd(gr_poly_t G, const gr_poly_t A, const gr_poly_t B, slong inner_cutoff, slong cutoff, gr_ctx_t ctx) - int _gr_poly_gcd_euclidean(gr_ptr G, slong * lenG, gr_srcptr A, slong lenA, gr_srcptr B, slong lenB, gr_ctx_t ctx) - int gr_poly_gcd_euclidean(gr_poly_t G, const gr_poly_t A, const gr_poly_t B, gr_ctx_t ctx) - int _gr_poly_gcd(gr_ptr G, slong * lenG, gr_srcptr A, slong lenA, gr_srcptr B, slong lenB, gr_ctx_t ctx) - int gr_poly_gcd(gr_poly_t G, const gr_poly_t A, const gr_poly_t B, gr_ctx_t ctx) + int _gr_poly_gcd_hgcd(gr_ptr G, slong * _lenG, gr_srcptr A, slong lenA, gr_srcptr B, slong lenB, slong inner_cutoff, slong cutoff, gr_ctx_t ctx) noexcept + int gr_poly_gcd_hgcd(gr_poly_t G, const gr_poly_t A, const gr_poly_t B, slong inner_cutoff, slong cutoff, gr_ctx_t ctx) noexcept + int _gr_poly_gcd_euclidean(gr_ptr G, slong * lenG, gr_srcptr A, slong lenA, gr_srcptr B, slong lenB, gr_ctx_t ctx) noexcept + int gr_poly_gcd_euclidean(gr_poly_t G, const gr_poly_t A, const gr_poly_t B, gr_ctx_t ctx) noexcept + int _gr_poly_gcd(gr_ptr G, slong * lenG, gr_srcptr A, slong lenA, gr_srcptr B, slong lenB, gr_ctx_t ctx) noexcept + int gr_poly_gcd(gr_poly_t G, const gr_poly_t A, const gr_poly_t B, gr_ctx_t ctx) noexcept # Polynomial GCD. Currently only useful over fields. # The underscore methods assume ``lenA >= lenB >= 1`` and that both # *A* and *B* have nonzero leading coefficient. @@ -351,22 +351,22 @@ cdef extern from "flint_wrap.h": # The time complexity of the half-GCD algorithm is `\mathcal{O}(n \log^2 n)` # ring operations. For further details, see [ThullYap1990]_. - int _gr_poly_xgcd_euclidean(slong * lenG, gr_ptr G, gr_ptr S, gr_ptr T, gr_srcptr A, slong lenA, gr_srcptr B, slong lenB, gr_ctx_t ctx) - int gr_poly_xgcd_euclidean(gr_poly_t G, gr_poly_t S, gr_poly_t T, const gr_poly_t A, const gr_poly_t B, gr_ctx_t ctx) - - int _gr_poly_xgcd_hgcd(slong * Glen, gr_ptr G, gr_ptr S, gr_ptr T, gr_srcptr A, slong lenA, gr_srcptr B, slong lenB, slong hgcd_cutoff, slong cutoff, gr_ctx_t ctx) - int gr_poly_xgcd_hgcd(gr_poly_t G, gr_poly_t S, gr_poly_t T, const gr_poly_t A, const gr_poly_t B, slong hgcd_cutoff, slong cutoff, gr_ctx_t ctx) - - int _gr_poly_resultant_euclidean(gr_ptr res, gr_srcptr poly1, slong len1, gr_srcptr poly2, slong len2, gr_ctx_t ctx) - int gr_poly_resultant_euclidean(gr_ptr res, const gr_poly_t f, const gr_poly_t g, gr_ctx_t ctx) - int _gr_poly_resultant_hgcd(gr_ptr res, gr_srcptr A, slong lenA, gr_srcptr B, slong lenB, slong inner_cutoff, slong cutoff, gr_ctx_t ctx) - int gr_poly_resultant_hgcd(gr_ptr res, const gr_poly_t f, const gr_poly_t g, slong inner_cutoff, slong cutoff, gr_ctx_t ctx) - int _gr_poly_resultant_sylvester(gr_ptr res, gr_srcptr poly1, slong len1, gr_srcptr poly2, slong len2, gr_ctx_t ctx) - int gr_poly_resultant_sylvester(gr_ptr res, const gr_poly_t f, const gr_poly_t g, gr_ctx_t ctx) - int _gr_poly_resultant_small(gr_ptr res, gr_srcptr poly1, slong len1, gr_srcptr poly2, slong len2, gr_ctx_t ctx) - int gr_poly_resultant_small(gr_ptr res, const gr_poly_t f, const gr_poly_t g, gr_ctx_t ctx) - int _gr_poly_resultant(gr_ptr res, gr_srcptr poly1, slong len1, gr_srcptr poly2, slong len2, gr_ctx_t ctx) - int gr_poly_resultant(gr_ptr res, const gr_poly_t f, const gr_poly_t g, gr_ctx_t ctx) + int _gr_poly_xgcd_euclidean(slong * lenG, gr_ptr G, gr_ptr S, gr_ptr T, gr_srcptr A, slong lenA, gr_srcptr B, slong lenB, gr_ctx_t ctx) noexcept + int gr_poly_xgcd_euclidean(gr_poly_t G, gr_poly_t S, gr_poly_t T, const gr_poly_t A, const gr_poly_t B, gr_ctx_t ctx) noexcept + + int _gr_poly_xgcd_hgcd(slong * Glen, gr_ptr G, gr_ptr S, gr_ptr T, gr_srcptr A, slong lenA, gr_srcptr B, slong lenB, slong hgcd_cutoff, slong cutoff, gr_ctx_t ctx) noexcept + int gr_poly_xgcd_hgcd(gr_poly_t G, gr_poly_t S, gr_poly_t T, const gr_poly_t A, const gr_poly_t B, slong hgcd_cutoff, slong cutoff, gr_ctx_t ctx) noexcept + + int _gr_poly_resultant_euclidean(gr_ptr res, gr_srcptr poly1, slong len1, gr_srcptr poly2, slong len2, gr_ctx_t ctx) noexcept + int gr_poly_resultant_euclidean(gr_ptr res, const gr_poly_t f, const gr_poly_t g, gr_ctx_t ctx) noexcept + int _gr_poly_resultant_hgcd(gr_ptr res, gr_srcptr A, slong lenA, gr_srcptr B, slong lenB, slong inner_cutoff, slong cutoff, gr_ctx_t ctx) noexcept + int gr_poly_resultant_hgcd(gr_ptr res, const gr_poly_t f, const gr_poly_t g, slong inner_cutoff, slong cutoff, gr_ctx_t ctx) noexcept + int _gr_poly_resultant_sylvester(gr_ptr res, gr_srcptr poly1, slong len1, gr_srcptr poly2, slong len2, gr_ctx_t ctx) noexcept + int gr_poly_resultant_sylvester(gr_ptr res, const gr_poly_t f, const gr_poly_t g, gr_ctx_t ctx) noexcept + int _gr_poly_resultant_small(gr_ptr res, gr_srcptr poly1, slong len1, gr_srcptr poly2, slong len2, gr_ctx_t ctx) noexcept + int gr_poly_resultant_small(gr_ptr res, const gr_poly_t f, const gr_poly_t g, gr_ctx_t ctx) noexcept + int _gr_poly_resultant(gr_ptr res, gr_srcptr poly1, slong len1, gr_srcptr poly2, slong len2, gr_ctx_t ctx) noexcept + int gr_poly_resultant(gr_ptr res, const gr_poly_t f, const gr_poly_t g, gr_ctx_t ctx) noexcept # Sets *res* to the resultant of *poly1* and *poly2*. # The underscore methods assume that `len1 \ge len2 \ge 1` # and that the leading coefficients are nonzero. @@ -390,7 +390,7 @@ cdef extern from "flint_wrap.h": # Currently no algorithm has been implemented that is appropriate for # integral domains. - int gr_poly_factor_squarefree(gr_ptr c, gr_vec_t fac, gr_vec_t exp, const gr_poly_t poly, gr_ctx_t ctx) + int gr_poly_factor_squarefree(gr_ptr c, gr_vec_t fac, gr_vec_t exp, const gr_poly_t poly, gr_ctx_t ctx) noexcept # Computes a squarefree factorization of *poly*. # The constant *c* is set to an element of the scalar ring. # The factors in *fac* are set to polynomials; the user must thus @@ -398,11 +398,11 @@ cdef extern from "flint_wrap.h": # *poly* (and *not* to the parent *ctx*). # The exponent vector *exp* must be initialized to the *fmpz* type. - int gr_poly_squarefree_part(gr_poly_t res, const gr_poly_t poly, gr_ctx_t ctx) + int gr_poly_squarefree_part(gr_poly_t res, const gr_poly_t poly, gr_ctx_t ctx) noexcept # Sets *res* to the squarefreepart of *poly*. - int gr_poly_roots(gr_vec_t roots, gr_vec_t mult, const gr_poly_t poly, int flags, gr_ctx_t ctx) - int gr_poly_roots_other(gr_vec_t roots, gr_vec_t mult, const gr_poly_t poly, gr_ctx_t poly_ctx, int flags, gr_ctx_t ctx) + int gr_poly_roots(gr_vec_t roots, gr_vec_t mult, const gr_poly_t poly, int flags, gr_ctx_t ctx) noexcept + int gr_poly_roots_other(gr_vec_t roots, gr_vec_t mult, const gr_poly_t poly, gr_ctx_t poly_ctx, int flags, gr_ctx_t ctx) noexcept # Finds all roots of the given polynomial in the ring defined by *ctx*, # storing the roots without duplication in *roots* (a vector with # elements of type ``ctx``) and the corresponding multiplicities in @@ -420,38 +420,38 @@ cdef extern from "flint_wrap.h": # We consider roots of the zero polynomial to be ill-defined and return # ``GR_DOMAIN`` in that case. - int _gr_poly_asin_series(gr_ptr res, gr_srcptr f, slong flen, slong len, gr_ctx_t ctx) - int gr_poly_asin_series(gr_poly_t res, const gr_poly_t f, slong len, gr_ctx_t ctx) - int _gr_poly_asinh_series(gr_ptr res, gr_srcptr f, slong flen, slong len, gr_ctx_t ctx) - int gr_poly_asinh_series(gr_poly_t res, const gr_poly_t f, slong len, gr_ctx_t ctx) - int _gr_poly_acos_series(gr_ptr res, gr_srcptr f, slong flen, slong len, gr_ctx_t ctx) - int gr_poly_acos_series(gr_poly_t res, const gr_poly_t f, slong len, gr_ctx_t ctx) - int _gr_poly_acosh_series(gr_ptr res, gr_srcptr f, slong flen, slong len, gr_ctx_t ctx) - int gr_poly_acosh_series(gr_poly_t res, const gr_poly_t f, slong len, gr_ctx_t ctx) - int _gr_poly_atan_series(gr_ptr res, gr_srcptr f, slong flen, slong len, gr_ctx_t ctx) - int gr_poly_atan_series(gr_poly_t res, const gr_poly_t f, slong len, gr_ctx_t ctx) - int _gr_poly_atanh_series(gr_ptr res, gr_srcptr f, slong flen, slong len, gr_ctx_t ctx) - int gr_poly_atanh_series(gr_poly_t res, const gr_poly_t f, slong len, gr_ctx_t ctx) - - int _gr_poly_log_series(gr_ptr res, gr_srcptr f, slong flen, slong len, gr_ctx_t ctx) - int gr_poly_log_series(gr_poly_t res, const gr_poly_t f, slong len, gr_ctx_t ctx) - int _gr_poly_log1p_series(gr_ptr res, gr_srcptr f, slong flen, slong len, gr_ctx_t ctx) - int gr_poly_log1p_series(gr_poly_t res, const gr_poly_t f, slong len, gr_ctx_t ctx) - - int _gr_poly_exp_series_basecase(gr_ptr f, gr_srcptr h, slong hlen, slong n, gr_ctx_t ctx) - int gr_poly_exp_series_basecase(gr_poly_t f, const gr_poly_t h, slong n, gr_ctx_t ctx) - int _gr_poly_exp_series_basecase_mul(gr_ptr f, gr_srcptr h, slong hlen, slong n, gr_ctx_t ctx) - int gr_poly_exp_series_basecase_mul(gr_poly_t f, const gr_poly_t h, slong n, gr_ctx_t ctx) - int _gr_poly_exp_series_newton(gr_ptr f, gr_ptr g, gr_srcptr h, slong hlen, slong n, slong cutoff, gr_ctx_t ctx) - int gr_poly_exp_series_newton(gr_poly_t f, const gr_poly_t h, slong n, slong cutoff, gr_ctx_t ctx) - int _gr_poly_exp_series_generic(gr_ptr f, gr_srcptr h, slong hlen, slong n, gr_ctx_t ctx) - int _gr_poly_exp_series(gr_ptr res, gr_srcptr f, slong flen, slong len, gr_ctx_t ctx) - int gr_poly_exp_series(gr_poly_t f, const gr_poly_t h, slong n, gr_ctx_t ctx) - - int _gr_poly_sin_cos_series_basecase(gr_ptr s, gr_ptr c, gr_srcptr h, slong hlen, slong n, int times_pi, gr_ctx_t ctx) - int gr_poly_sin_cos_series_basecase(gr_poly_t s, gr_poly_t c, const gr_poly_t h, slong n, int times_pi, gr_ctx_t ctx) - int _gr_poly_sin_cos_series_tangent(gr_ptr s, gr_ptr c, gr_srcptr h, slong hlen, slong n, int times_pi, gr_ctx_t ctx) - int gr_poly_sin_cos_series_tangent(gr_poly_t s, gr_poly_t c, const gr_poly_t h, slong n, int times_pi, gr_ctx_t ctx) + int _gr_poly_asin_series(gr_ptr res, gr_srcptr f, slong flen, slong len, gr_ctx_t ctx) noexcept + int gr_poly_asin_series(gr_poly_t res, const gr_poly_t f, slong len, gr_ctx_t ctx) noexcept + int _gr_poly_asinh_series(gr_ptr res, gr_srcptr f, slong flen, slong len, gr_ctx_t ctx) noexcept + int gr_poly_asinh_series(gr_poly_t res, const gr_poly_t f, slong len, gr_ctx_t ctx) noexcept + int _gr_poly_acos_series(gr_ptr res, gr_srcptr f, slong flen, slong len, gr_ctx_t ctx) noexcept + int gr_poly_acos_series(gr_poly_t res, const gr_poly_t f, slong len, gr_ctx_t ctx) noexcept + int _gr_poly_acosh_series(gr_ptr res, gr_srcptr f, slong flen, slong len, gr_ctx_t ctx) noexcept + int gr_poly_acosh_series(gr_poly_t res, const gr_poly_t f, slong len, gr_ctx_t ctx) noexcept + int _gr_poly_atan_series(gr_ptr res, gr_srcptr f, slong flen, slong len, gr_ctx_t ctx) noexcept + int gr_poly_atan_series(gr_poly_t res, const gr_poly_t f, slong len, gr_ctx_t ctx) noexcept + int _gr_poly_atanh_series(gr_ptr res, gr_srcptr f, slong flen, slong len, gr_ctx_t ctx) noexcept + int gr_poly_atanh_series(gr_poly_t res, const gr_poly_t f, slong len, gr_ctx_t ctx) noexcept + + int _gr_poly_log_series(gr_ptr res, gr_srcptr f, slong flen, slong len, gr_ctx_t ctx) noexcept + int gr_poly_log_series(gr_poly_t res, const gr_poly_t f, slong len, gr_ctx_t ctx) noexcept + int _gr_poly_log1p_series(gr_ptr res, gr_srcptr f, slong flen, slong len, gr_ctx_t ctx) noexcept + int gr_poly_log1p_series(gr_poly_t res, const gr_poly_t f, slong len, gr_ctx_t ctx) noexcept + + int _gr_poly_exp_series_basecase(gr_ptr f, gr_srcptr h, slong hlen, slong n, gr_ctx_t ctx) noexcept + int gr_poly_exp_series_basecase(gr_poly_t f, const gr_poly_t h, slong n, gr_ctx_t ctx) noexcept + int _gr_poly_exp_series_basecase_mul(gr_ptr f, gr_srcptr h, slong hlen, slong n, gr_ctx_t ctx) noexcept + int gr_poly_exp_series_basecase_mul(gr_poly_t f, const gr_poly_t h, slong n, gr_ctx_t ctx) noexcept + int _gr_poly_exp_series_newton(gr_ptr f, gr_ptr g, gr_srcptr h, slong hlen, slong n, slong cutoff, gr_ctx_t ctx) noexcept + int gr_poly_exp_series_newton(gr_poly_t f, const gr_poly_t h, slong n, slong cutoff, gr_ctx_t ctx) noexcept + int _gr_poly_exp_series_generic(gr_ptr f, gr_srcptr h, slong hlen, slong n, gr_ctx_t ctx) noexcept + int _gr_poly_exp_series(gr_ptr res, gr_srcptr f, slong flen, slong len, gr_ctx_t ctx) noexcept + int gr_poly_exp_series(gr_poly_t f, const gr_poly_t h, slong n, gr_ctx_t ctx) noexcept + + int _gr_poly_sin_cos_series_basecase(gr_ptr s, gr_ptr c, gr_srcptr h, slong hlen, slong n, int times_pi, gr_ctx_t ctx) noexcept + int gr_poly_sin_cos_series_basecase(gr_poly_t s, gr_poly_t c, const gr_poly_t h, slong n, int times_pi, gr_ctx_t ctx) noexcept + int _gr_poly_sin_cos_series_tangent(gr_ptr s, gr_ptr c, gr_srcptr h, slong hlen, slong n, int times_pi, gr_ctx_t ctx) noexcept + int gr_poly_sin_cos_series_tangent(gr_poly_t s, gr_poly_t c, const gr_poly_t h, slong n, int times_pi, gr_ctx_t ctx) noexcept # The *basecase* version uses a simple recurrence for the coefficients, # requiring `O(nm)` operations where `m` is the length of `h`. # The *tangent* version uses the tangent half-angle formulas to compute @@ -464,9 +464,9 @@ cdef extern from "flint_wrap.h": # The *basecase* and *tangent* versions take a flag *times_pi* # specifying that the input is to be multiplied by `\pi`. - int _gr_poly_tan_series_basecase(gr_ptr f, gr_srcptr h, slong hlen, slong n, gr_ctx_t ctx) - int gr_poly_tan_series_basecase(gr_poly_t f, const gr_poly_t h, slong n, gr_ctx_t ctx) - int _gr_poly_tan_series_newton(gr_ptr f, gr_srcptr h, slong hlen, slong n, slong cutoff, gr_ctx_t ctx) - int gr_poly_tan_series_newton(gr_poly_t f, const gr_poly_t h, slong n, slong cutoff, gr_ctx_t ctx) - int _gr_poly_tan_series(gr_ptr f, gr_srcptr h, slong hlen, slong n, gr_ctx_t ctx) - int gr_poly_tan_series(gr_poly_t f, const gr_poly_t h, slong n, gr_ctx_t ctx) + int _gr_poly_tan_series_basecase(gr_ptr f, gr_srcptr h, slong hlen, slong n, gr_ctx_t ctx) noexcept + int gr_poly_tan_series_basecase(gr_poly_t f, const gr_poly_t h, slong n, gr_ctx_t ctx) noexcept + int _gr_poly_tan_series_newton(gr_ptr f, gr_srcptr h, slong hlen, slong n, slong cutoff, gr_ctx_t ctx) noexcept + int gr_poly_tan_series_newton(gr_poly_t f, const gr_poly_t h, slong n, slong cutoff, gr_ctx_t ctx) noexcept + int _gr_poly_tan_series(gr_ptr f, gr_srcptr h, slong hlen, slong n, gr_ctx_t ctx) noexcept + int gr_poly_tan_series(gr_poly_t f, const gr_poly_t h, slong n, gr_ctx_t ctx) noexcept diff --git a/src/sage/libs/flint/gr_special.pxd b/src/sage/libs/flint/gr_special.pxd index 4438c818246..568fbd98581 100644 --- a/src/sage/libs/flint/gr_special.pxd +++ b/src/sage/libs/flint/gr_special.pxd @@ -12,98 +12,98 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - int gr_pi(gr_ptr res, gr_ctx_t ctx) - int gr_euler(gr_ptr res, gr_ctx_t ctx) - int gr_catalan(gr_ptr res, gr_ctx_t ctx) - int gr_khinchin(gr_ptr res, gr_ctx_t ctx) - int gr_glaisher(gr_ptr res, gr_ctx_t ctx) + int gr_pi(gr_ptr res, gr_ctx_t ctx) noexcept + int gr_euler(gr_ptr res, gr_ctx_t ctx) noexcept + int gr_catalan(gr_ptr res, gr_ctx_t ctx) noexcept + int gr_khinchin(gr_ptr res, gr_ctx_t ctx) noexcept + int gr_glaisher(gr_ptr res, gr_ctx_t ctx) noexcept # Standard real constants: `\pi`, Euler's constant `\gamma`, # Catalan's constant, Khinchin's constant, Glaisher's constant. - int gr_exp(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) - int gr_expm1(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) - int gr_exp2(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) - int gr_exp10(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) - int gr_exp_pi_i(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) - int gr_log(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) - int gr_log1p(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) - int gr_log2(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) - int gr_log10(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) - int gr_log_pi_i(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) - - int gr_sin(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) - int gr_cos(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) - int gr_sin_cos(gr_ptr res1, gr_ptr res2, gr_srcptr x, gr_ctx_t ctx) - int gr_tan(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) - int gr_cot(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) - int gr_sec(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) - int gr_csc(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) - - int gr_sin_pi(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) - int gr_cos_pi(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) - int gr_sin_cos_pi(gr_ptr res1, gr_ptr res2, gr_srcptr x, gr_ctx_t ctx) - int gr_tan_pi(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) - int gr_cot_pi(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) - int gr_sec_pi(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) - int gr_csc_pi(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) - - int gr_sinc(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) - int gr_sinc_pi(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) - - int gr_sinh(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) - int gr_cosh(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) - int gr_sinh_cosh(gr_ptr res1, gr_ptr res2, gr_srcptr x, gr_ctx_t ctx) - int gr_tanh(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) - int gr_coth(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) - int gr_sech(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) - int gr_csch(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) - - int gr_asin(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) - int gr_acos(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) - int gr_atan(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) - int gr_atan2(gr_ptr res, gr_srcptr y, gr_srcptr x, gr_ctx_t ctx) - int gr_acot(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) - int gr_asec(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) - int gr_acsc(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) - - int gr_asin_pi(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) - int gr_acos_pi(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) - int gr_atan_pi(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) - int gr_acot_pi(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) - int gr_asec_pi(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) - int gr_acsc_pi(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) - - int gr_asinh(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) - int gr_acosh(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) - int gr_atanh(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) - int gr_acoth(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) - int gr_asech(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) - int gr_acsch(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) - - int gr_lambertw(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) - int gr_lambertw_fmpz(gr_ptr res, gr_srcptr x, const fmpz_t k, gr_ctx_t ctx) - - int gr_fac(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) - int gr_fac_ui(gr_ptr res, ulong x, gr_ctx_t ctx) - int gr_fac_fmpz(gr_ptr res, const fmpz_t x, gr_ctx_t ctx) - int gr_fac_vec(gr_ptr res, slong len, gr_ctx_t ctx) + int gr_exp(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept + int gr_expm1(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept + int gr_exp2(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept + int gr_exp10(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept + int gr_exp_pi_i(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept + int gr_log(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept + int gr_log1p(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept + int gr_log2(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept + int gr_log10(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept + int gr_log_pi_i(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept + + int gr_sin(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept + int gr_cos(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept + int gr_sin_cos(gr_ptr res1, gr_ptr res2, gr_srcptr x, gr_ctx_t ctx) noexcept + int gr_tan(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept + int gr_cot(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept + int gr_sec(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept + int gr_csc(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept + + int gr_sin_pi(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept + int gr_cos_pi(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept + int gr_sin_cos_pi(gr_ptr res1, gr_ptr res2, gr_srcptr x, gr_ctx_t ctx) noexcept + int gr_tan_pi(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept + int gr_cot_pi(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept + int gr_sec_pi(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept + int gr_csc_pi(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept + + int gr_sinc(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept + int gr_sinc_pi(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept + + int gr_sinh(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept + int gr_cosh(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept + int gr_sinh_cosh(gr_ptr res1, gr_ptr res2, gr_srcptr x, gr_ctx_t ctx) noexcept + int gr_tanh(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept + int gr_coth(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept + int gr_sech(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept + int gr_csch(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept + + int gr_asin(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept + int gr_acos(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept + int gr_atan(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept + int gr_atan2(gr_ptr res, gr_srcptr y, gr_srcptr x, gr_ctx_t ctx) noexcept + int gr_acot(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept + int gr_asec(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept + int gr_acsc(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept + + int gr_asin_pi(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept + int gr_acos_pi(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept + int gr_atan_pi(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept + int gr_acot_pi(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept + int gr_asec_pi(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept + int gr_acsc_pi(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept + + int gr_asinh(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept + int gr_acosh(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept + int gr_atanh(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept + int gr_acoth(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept + int gr_asech(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept + int gr_acsch(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept + + int gr_lambertw(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept + int gr_lambertw_fmpz(gr_ptr res, gr_srcptr x, const fmpz_t k, gr_ctx_t ctx) noexcept + + int gr_fac(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept + int gr_fac_ui(gr_ptr res, ulong x, gr_ctx_t ctx) noexcept + int gr_fac_fmpz(gr_ptr res, const fmpz_t x, gr_ctx_t ctx) noexcept + int gr_fac_vec(gr_ptr res, slong len, gr_ctx_t ctx) noexcept # Factorial `x!`. The *vec* version writes the first *len* # consecutive values `1, 1, 2, 6, \ldots, (len-1)!` # to the preallocated vector *res*. - int gr_rfac(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) - int gr_rfac_ui(gr_ptr res, ulong x, gr_ctx_t ctx) - int gr_rfac_fmpz(gr_ptr res, const fmpz_t x, gr_ctx_t ctx) - int gr_rfac_vec(gr_ptr res, slong len, gr_ctx_t ctx) + int gr_rfac(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept + int gr_rfac_ui(gr_ptr res, ulong x, gr_ctx_t ctx) noexcept + int gr_rfac_fmpz(gr_ptr res, const fmpz_t x, gr_ctx_t ctx) noexcept + int gr_rfac_vec(gr_ptr res, slong len, gr_ctx_t ctx) noexcept # Reciprocal factorial. The *vec* version writes the first *len* # consecutive values `1, 1, 1/2, 1/6, \ldots, 1/(len-1)!` # to the preallocated vector *res*. - int gr_bin(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) - int gr_bin_ui(gr_ptr res, gr_srcptr x, ulong y, gr_ctx_t ctx) - int gr_bin_uiui(gr_ptr res, ulong x, ulong y, gr_ctx_t ctx) - int gr_bin_vec(gr_ptr res, gr_srcptr x, slong len, gr_ctx_t ctx) - int gr_bin_ui_vec(gr_ptr res, ulong x, slong len, gr_ctx_t ctx) + int gr_bin(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) noexcept + int gr_bin_ui(gr_ptr res, gr_srcptr x, ulong y, gr_ctx_t ctx) noexcept + int gr_bin_uiui(gr_ptr res, ulong x, ulong y, gr_ctx_t ctx) noexcept + int gr_bin_vec(gr_ptr res, gr_srcptr x, slong len, gr_ctx_t ctx) noexcept + int gr_bin_ui_vec(gr_ptr res, ulong x, slong len, gr_ctx_t ctx) noexcept # Binomial coefficient `{x choose y}`. The *vec* versions write the # first *len* consecutive values `{x choose 0}, {x choose 1}, \ldots, {x choose len-1}` # to the preallocated vector *res*. @@ -111,60 +111,60 @@ cdef extern from "flint_wrap.h": # coefficients (Pascal's triangle), it is more efficient to # call :func:`gr_mat_pascal` than to call these functions repeatedly. - int gr_rising(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) - int gr_rising_ui(gr_ptr res, gr_srcptr x, ulong y, gr_ctx_t ctx) - int gr_falling(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) - int gr_falling_ui(gr_ptr res, gr_srcptr x, ulong y, gr_ctx_t ctx) + int gr_rising(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) noexcept + int gr_rising_ui(gr_ptr res, gr_srcptr x, ulong y, gr_ctx_t ctx) noexcept + int gr_falling(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) noexcept + int gr_falling_ui(gr_ptr res, gr_srcptr x, ulong y, gr_ctx_t ctx) noexcept # Rising and falling factorials `x (x+1) \cdots (x+y-1)` # and `x (x-1) \cdots (x-y+1)`, or their generalizations # to non-integer `y` via the gamma function. - int gr_gamma(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) - int gr_gamma_fmpz(gr_ptr res, const fmpz_t x, gr_ctx_t ctx) - int gr_gamma_fmpq(gr_ptr res, const fmpq_t x, gr_ctx_t ctx) - int gr_rgamma(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) - int gr_lgamma(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) - int gr_digamma(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) + int gr_gamma(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept + int gr_gamma_fmpz(gr_ptr res, const fmpz_t x, gr_ctx_t ctx) noexcept + int gr_gamma_fmpq(gr_ptr res, const fmpq_t x, gr_ctx_t ctx) noexcept + int gr_rgamma(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept + int gr_lgamma(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept + int gr_digamma(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept # Gamma function `\Gamma(x)`, its reciprocal `1 / \Gamma(x)`, # the log-gamma function `\log \Gamma(x)`, and the digamma function # `\psi(x)`. - int gr_barnes_g(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) - int gr_log_barnes_g(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) + int gr_barnes_g(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept + int gr_log_barnes_g(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept # Barnes G-function. - int gr_beta(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) + int gr_beta(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) noexcept # Beta function `B(x,y)`. - int gr_doublefac(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) - int gr_doublefac_ui(gr_ptr res, ulong x, gr_ctx_t ctx) + int gr_doublefac(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept + int gr_doublefac_ui(gr_ptr res, ulong x, gr_ctx_t ctx) noexcept # Double factorial `x!!`. - int gr_harmonic(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) - int gr_harmonic_ui(gr_ptr res, ulong x, gr_ctx_t ctx) + int gr_harmonic(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept + int gr_harmonic_ui(gr_ptr res, ulong x, gr_ctx_t ctx) noexcept # Harmonic number `H_x`. - int gr_bernoulli_ui(gr_ptr res, ulong n, gr_ctx_t ctx) - int gr_bernoulli_fmpz(gr_ptr res, const fmpz_t n, gr_ctx_t ctx) - int gr_bernoulli_vec(gr_ptr res, slong len, gr_ctx_t ctx) + int gr_bernoulli_ui(gr_ptr res, ulong n, gr_ctx_t ctx) noexcept + int gr_bernoulli_fmpz(gr_ptr res, const fmpz_t n, gr_ctx_t ctx) noexcept + int gr_bernoulli_vec(gr_ptr res, slong len, gr_ctx_t ctx) noexcept # Bernoulli numbers `B_n`. - int gr_eulernum_ui(gr_ptr res, ulong x, gr_ctx_t ctx) - int gr_eulernum_fmpz(gr_ptr res, const fmpz_t x, gr_ctx_t ctx) - int gr_eulernum_vec(gr_ptr res, slong len, gr_ctx_t ctx) + int gr_eulernum_ui(gr_ptr res, ulong x, gr_ctx_t ctx) noexcept + int gr_eulernum_fmpz(gr_ptr res, const fmpz_t x, gr_ctx_t ctx) noexcept + int gr_eulernum_vec(gr_ptr res, slong len, gr_ctx_t ctx) noexcept # Euler numbers `E_n`. - int gr_fib_ui(gr_ptr res, ulong n, gr_ctx_t ctx) - int gr_fib_fmpz(gr_ptr res, const fmpz_t n, gr_ctx_t ctx) - int gr_fib_vec(gr_ptr res, slong len, gr_ctx_t ctx) + int gr_fib_ui(gr_ptr res, ulong n, gr_ctx_t ctx) noexcept + int gr_fib_fmpz(gr_ptr res, const fmpz_t n, gr_ctx_t ctx) noexcept + int gr_fib_vec(gr_ptr res, slong len, gr_ctx_t ctx) noexcept # Fibonacci numbers `F_n`. - int gr_stirling_s1u_uiui(gr_ptr res, ulong x, ulong y, gr_ctx_t ctx) - int gr_stirling_s1_uiui(gr_ptr res, ulong x, ulong y, gr_ctx_t ctx) - int gr_stirling_s2_uiui(gr_ptr res, ulong x, ulong y, gr_ctx_t ctx) - int gr_stirling_s1u_ui_vec(gr_ptr res, ulong x, slong len, gr_ctx_t ctx) - int gr_stirling_s1_ui_vec(gr_ptr res, ulong x, slong len, gr_ctx_t ctx) - int gr_stirling_s2_ui_vec(gr_ptr res, ulong x, slong len, gr_ctx_t ctx) + int gr_stirling_s1u_uiui(gr_ptr res, ulong x, ulong y, gr_ctx_t ctx) noexcept + int gr_stirling_s1_uiui(gr_ptr res, ulong x, ulong y, gr_ctx_t ctx) noexcept + int gr_stirling_s2_uiui(gr_ptr res, ulong x, ulong y, gr_ctx_t ctx) noexcept + int gr_stirling_s1u_ui_vec(gr_ptr res, ulong x, slong len, gr_ctx_t ctx) noexcept + int gr_stirling_s1_ui_vec(gr_ptr res, ulong x, slong len, gr_ctx_t ctx) noexcept + int gr_stirling_s2_ui_vec(gr_ptr res, ulong x, slong len, gr_ctx_t ctx) noexcept # Stirling numbers `S(x,y)`: unsigned of the first kind, # signed of the first kind, and second kind. The *vec* versions # write the *len* consecutive values `S(x,0), S(x,1), \ldots, S(x, len-1)` @@ -173,146 +173,146 @@ cdef extern from "flint_wrap.h": # it is more efficient to # call :func:`gr_mat_stirling` than to call these functions repeatedly. - int gr_bellnum_ui(gr_ptr res, ulong x, gr_ctx_t ctx) - int gr_bellnum_fmpz(gr_ptr res, const fmpz_t x, gr_ctx_t ctx) - int gr_bellnum_vec(gr_ptr res, slong len, gr_ctx_t ctx) + int gr_bellnum_ui(gr_ptr res, ulong x, gr_ctx_t ctx) noexcept + int gr_bellnum_fmpz(gr_ptr res, const fmpz_t x, gr_ctx_t ctx) noexcept + int gr_bellnum_vec(gr_ptr res, slong len, gr_ctx_t ctx) noexcept # Bell numbers `B_n`. - int gr_partitions_ui(gr_ptr res, ulong x, gr_ctx_t ctx) - int gr_partitions_fmpz(gr_ptr res, const fmpz_t x, gr_ctx_t ctx) - int gr_partitions_vec(gr_ptr res, slong len, gr_ctx_t ctx) + int gr_partitions_ui(gr_ptr res, ulong x, gr_ctx_t ctx) noexcept + int gr_partitions_fmpz(gr_ptr res, const fmpz_t x, gr_ctx_t ctx) noexcept + int gr_partitions_vec(gr_ptr res, slong len, gr_ctx_t ctx) noexcept # Partition numbers `p(n)`. - int gr_erf(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) - int gr_erfc(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) - int gr_erfcx(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) - int gr_erfi(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) - int gr_erfinv(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) - int gr_erfcinv(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) - - int gr_fresnel_s(gr_ptr res, gr_srcptr x, int normalized, gr_ctx_t ctx) - int gr_fresnel_c(gr_ptr res, gr_srcptr x, int normalized, gr_ctx_t ctx) - int gr_fresnel(gr_ptr res1, gr_ptr res2, gr_srcptr x, int normalized, gr_ctx_t ctx) - - int gr_gamma_upper(gr_ptr res, gr_srcptr x, gr_srcptr y, int regularized, gr_ctx_t ctx) - int gr_gamma_lower(gr_ptr res, gr_srcptr x, gr_srcptr y, int regularized, gr_ctx_t ctx) - int gr_beta_lower(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_srcptr z, int regularized, gr_ctx_t ctx) - - int gr_exp_integral(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) - int gr_exp_integral_ei(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) - int gr_sin_integral(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) - int gr_cos_integral(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) - int gr_sinh_integral(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) - int gr_cosh_integral(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) - int gr_log_integral(gr_ptr res, gr_srcptr x, int offset, gr_ctx_t ctx) - int gr_dilog(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) - - int gr_chebyshev_t_fmpz(gr_ptr res, const fmpz_t n, gr_srcptr x, gr_ctx_t ctx) - int gr_chebyshev_t(gr_ptr res, gr_srcptr n, gr_srcptr x, gr_ctx_t ctx) - int gr_chebyshev_u_fmpz(gr_ptr res, const fmpz_t n, gr_srcptr x, gr_ctx_t ctx) - int gr_chebyshev_u(gr_ptr res, gr_srcptr n, gr_srcptr x, gr_ctx_t ctx) - - int gr_jacobi_p(gr_ptr res, gr_srcptr n, gr_srcptr a, gr_srcptr b, gr_srcptr z, gr_ctx_t ctx) - int gr_gegenbauer_c(gr_ptr res, gr_srcptr n, gr_srcptr m, gr_srcptr z, gr_ctx_t ctx) - int gr_laguerre_l(gr_ptr res, gr_srcptr n, gr_srcptr m, gr_srcptr z, gr_ctx_t ctx) - int gr_hermite_h(gr_ptr res, gr_srcptr n, gr_srcptr z, gr_ctx_t ctx) - int gr_legendre_p(gr_ptr res, gr_srcptr n, gr_srcptr m, gr_srcptr z, int type, gr_ctx_t ctx) - int gr_legendre_q(gr_ptr res, gr_srcptr n, gr_srcptr m, gr_srcptr z, int type, gr_ctx_t ctx) - int gr_spherical_y_si(gr_ptr res, slong n, slong m, gr_srcptr theta, gr_srcptr phi, gr_ctx_t ctx) - int gr_legendre_p_root_ui(gr_ptr root, gr_ptr weight, ulong n, ulong k, gr_ctx_t ctx) - - int gr_bessel_j(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) - int gr_bessel_y(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) - int gr_bessel_i(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) - int gr_bessel_k(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) - int gr_bessel_j_y(gr_ptr res1, gr_ptr res2, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) - int gr_bessel_i_scaled(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) - int gr_bessel_k_scaled(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) - - int gr_airy(gr_ptr res1, gr_ptr res2, gr_ptr res3, gr_ptr res4, gr_srcptr x, gr_ctx_t ctx) - int gr_airy_ai(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) - int gr_airy_bi(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) - int gr_airy_ai_prime(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) - int gr_airy_bi_prime(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) - - int gr_airy_ai_zero(gr_ptr res, const fmpz_t n, gr_ctx_t ctx) - int gr_airy_bi_zero(gr_ptr res, const fmpz_t n, gr_ctx_t ctx) - int gr_airy_ai_prime_zero(gr_ptr res, const fmpz_t n, gr_ctx_t ctx) - int gr_airy_bi_prime_zero(gr_ptr res, const fmpz_t n, gr_ctx_t ctx) - - int gr_coulomb(gr_ptr res1, gr_ptr res2, gr_ptr res3, gr_ptr res4, gr_srcptr x, gr_srcptr y, gr_srcptr z, gr_ctx_t ctx) - int gr_coulomb_f(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_srcptr z, gr_ctx_t ctx) - int gr_coulomb_g(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_srcptr z, gr_ctx_t ctx) - int gr_coulomb_hpos(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_srcptr z, gr_ctx_t ctx) - int gr_coulomb_hneg(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_srcptr z, gr_ctx_t ctx) - - int gr_hypgeom_0f1(gr_ptr res, gr_srcptr a, gr_srcptr z, int flags, gr_ctx_t ctx) - int gr_hypgeom_1f1(gr_ptr res, gr_srcptr a, gr_srcptr b, gr_srcptr z, int flags, gr_ctx_t ctx) - int gr_hypgeom_u(gr_ptr res, gr_srcptr a, gr_srcptr b, gr_srcptr z, int flags, gr_ctx_t ctx) - int gr_hypgeom_2f1(gr_ptr res, gr_srcptr a, gr_srcptr b, gr_srcptr c, gr_srcptr z, int flags, gr_ctx_t ctx) - int gr_hypgeom_pfq(gr_ptr res, const gr_vec_t a, const gr_vec_t b, gr_srcptr z, int flags, gr_ctx_t ctx) - - int gr_zeta(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) - int gr_zeta_ui(gr_ptr res, ulong x, gr_ctx_t ctx) - int gr_hurwitz_zeta(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) - int gr_polygamma(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) - int gr_polylog(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) - int gr_lerch_phi(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_srcptr z, gr_ctx_t ctx) - int gr_stieltjes(gr_ptr res, const fmpz_t x, gr_srcptr y, gr_ctx_t ctx) - - int gr_dirichlet_eta(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) - int gr_riemann_xi(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) - int gr_zeta_zero(gr_ptr res, const fmpz_t n, gr_ctx_t ctx) - int gr_zeta_zero_vec(gr_ptr res, const fmpz_t n, slong len, gr_ctx_t ctx) - int gr_zeta_nzeros(gr_ptr res, gr_srcptr t, gr_ctx_t ctx) - - int gr_dirichlet_chi_fmpz(gr_ptr res, const dirichlet_group_t G, const dirichlet_char_t chi, const fmpz_t n, gr_ctx_t ctx) - int gr_dirichlet_chi_vec(gr_ptr res, const dirichlet_group_t G, const dirichlet_char_t chi, slong len, gr_ctx_t ctx) - int gr_dirichlet_l(gr_ptr res, const dirichlet_group_t G, const dirichlet_char_t chi, gr_srcptr s, gr_ctx_t ctx) - int gr_dirichlet_l_all(gr_vec_t res, const dirichlet_group_t G, gr_srcptr s, gr_ctx_t ctx) - int gr_dirichlet_hardy_theta(gr_ptr res, const dirichlet_group_t G, const dirichlet_char_t chi, gr_srcptr t, gr_ctx_t ctx) - int gr_dirichlet_hardy_z(gr_ptr res, const dirichlet_group_t G, const dirichlet_char_t chi, gr_srcptr t, gr_ctx_t ctx) - - int gr_agm1(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) - int gr_agm(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) - - int gr_elliptic_k(gr_ptr res, gr_srcptr m, gr_ctx_t ctx) - int gr_elliptic_e(gr_ptr res, gr_srcptr m, gr_ctx_t ctx) - int gr_elliptic_pi(gr_ptr res, gr_srcptr n, gr_srcptr m, gr_ctx_t ctx) - int gr_elliptic_f(gr_ptr res, gr_srcptr phi, gr_srcptr m, int pi, gr_ctx_t ctx) - int gr_elliptic_e_inc(gr_ptr res, gr_srcptr phi, gr_srcptr m, int pi, gr_ctx_t ctx) - int gr_elliptic_pi_inc(gr_ptr res, gr_srcptr n, gr_srcptr phi, gr_srcptr m, int pi, gr_ctx_t ctx) - - int gr_carlson_rc(gr_ptr res, gr_srcptr x, gr_srcptr y, int flags, gr_ctx_t ctx) - int gr_carlson_rf(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_srcptr z, int flags, gr_ctx_t ctx) - int gr_carlson_rd(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_srcptr z, int flags, gr_ctx_t ctx) - int gr_carlson_rg(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_srcptr z, int flags, gr_ctx_t ctx) - int gr_carlson_rj(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_srcptr z, gr_srcptr w, int flags, gr_ctx_t ctx) - - int gr_jacobi_theta(gr_ptr res1, gr_ptr res2, gr_ptr res3, gr_ptr res4, gr_srcptr z, gr_srcptr tau, gr_ctx_t ctx) - int gr_jacobi_theta_1(gr_ptr res, gr_srcptr z, gr_srcptr tau, gr_ctx_t ctx) - int gr_jacobi_theta_2(gr_ptr res, gr_srcptr z, gr_srcptr tau, gr_ctx_t ctx) - int gr_jacobi_theta_3(gr_ptr res, gr_srcptr z, gr_srcptr tau, gr_ctx_t ctx) - int gr_jacobi_theta_4(gr_ptr res, gr_srcptr z, gr_srcptr tau, gr_ctx_t ctx) - - int gr_dedekind_eta(gr_ptr res, gr_srcptr tau, gr_ctx_t ctx) - int gr_dedekind_eta_q(gr_ptr res, gr_srcptr tau, gr_ctx_t ctx) - - int gr_modular_j(gr_ptr res, gr_srcptr tau, gr_ctx_t ctx) - int gr_modular_lambda(gr_ptr res, gr_srcptr tau, gr_ctx_t ctx) - int gr_modular_delta(gr_ptr res, gr_srcptr tau, gr_ctx_t ctx) - - int gr_hilbert_class_poly(gr_ptr res, slong D, gr_srcptr x, gr_ctx_t ctx) - - int gr_eisenstein_e(gr_ptr res, ulong n, gr_srcptr tau, gr_ctx_t ctx) - int gr_eisenstein_g(gr_ptr res, ulong n, gr_srcptr tau, gr_ctx_t ctx) - int gr_eisenstein_g_vec(gr_ptr res, gr_srcptr tau, slong len, gr_ctx_t ctx) - - int gr_elliptic_invariants(gr_ptr res1, gr_ptr res2, gr_srcptr tau, gr_ctx_t ctx) - int gr_elliptic_roots(gr_ptr res1, gr_ptr res2, gr_ptr res3, gr_srcptr tau, gr_ctx_t ctx) - - int gr_weierstrass_p(gr_ptr res, gr_srcptr z, gr_srcptr tau, gr_ctx_t ctx) - int gr_weierstrass_p_prime(gr_ptr res, gr_srcptr z, gr_srcptr tau, gr_ctx_t ctx) - int gr_weierstrass_p_inv(gr_ptr res, gr_srcptr z, gr_srcptr tau, gr_ctx_t ctx) - int gr_weierstrass_zeta(gr_ptr res, gr_srcptr z, gr_srcptr tau, gr_ctx_t ctx) - int gr_weierstrass_sigma(gr_ptr res, gr_srcptr z, gr_srcptr tau, gr_ctx_t ctx) + int gr_erf(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept + int gr_erfc(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept + int gr_erfcx(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept + int gr_erfi(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept + int gr_erfinv(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept + int gr_erfcinv(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept + + int gr_fresnel_s(gr_ptr res, gr_srcptr x, int normalized, gr_ctx_t ctx) noexcept + int gr_fresnel_c(gr_ptr res, gr_srcptr x, int normalized, gr_ctx_t ctx) noexcept + int gr_fresnel(gr_ptr res1, gr_ptr res2, gr_srcptr x, int normalized, gr_ctx_t ctx) noexcept + + int gr_gamma_upper(gr_ptr res, gr_srcptr x, gr_srcptr y, int regularized, gr_ctx_t ctx) noexcept + int gr_gamma_lower(gr_ptr res, gr_srcptr x, gr_srcptr y, int regularized, gr_ctx_t ctx) noexcept + int gr_beta_lower(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_srcptr z, int regularized, gr_ctx_t ctx) noexcept + + int gr_exp_integral(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) noexcept + int gr_exp_integral_ei(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept + int gr_sin_integral(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept + int gr_cos_integral(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept + int gr_sinh_integral(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept + int gr_cosh_integral(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept + int gr_log_integral(gr_ptr res, gr_srcptr x, int offset, gr_ctx_t ctx) noexcept + int gr_dilog(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept + + int gr_chebyshev_t_fmpz(gr_ptr res, const fmpz_t n, gr_srcptr x, gr_ctx_t ctx) noexcept + int gr_chebyshev_t(gr_ptr res, gr_srcptr n, gr_srcptr x, gr_ctx_t ctx) noexcept + int gr_chebyshev_u_fmpz(gr_ptr res, const fmpz_t n, gr_srcptr x, gr_ctx_t ctx) noexcept + int gr_chebyshev_u(gr_ptr res, gr_srcptr n, gr_srcptr x, gr_ctx_t ctx) noexcept + + int gr_jacobi_p(gr_ptr res, gr_srcptr n, gr_srcptr a, gr_srcptr b, gr_srcptr z, gr_ctx_t ctx) noexcept + int gr_gegenbauer_c(gr_ptr res, gr_srcptr n, gr_srcptr m, gr_srcptr z, gr_ctx_t ctx) noexcept + int gr_laguerre_l(gr_ptr res, gr_srcptr n, gr_srcptr m, gr_srcptr z, gr_ctx_t ctx) noexcept + int gr_hermite_h(gr_ptr res, gr_srcptr n, gr_srcptr z, gr_ctx_t ctx) noexcept + int gr_legendre_p(gr_ptr res, gr_srcptr n, gr_srcptr m, gr_srcptr z, int type, gr_ctx_t ctx) noexcept + int gr_legendre_q(gr_ptr res, gr_srcptr n, gr_srcptr m, gr_srcptr z, int type, gr_ctx_t ctx) noexcept + int gr_spherical_y_si(gr_ptr res, slong n, slong m, gr_srcptr theta, gr_srcptr phi, gr_ctx_t ctx) noexcept + int gr_legendre_p_root_ui(gr_ptr root, gr_ptr weight, ulong n, ulong k, gr_ctx_t ctx) noexcept + + int gr_bessel_j(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) noexcept + int gr_bessel_y(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) noexcept + int gr_bessel_i(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) noexcept + int gr_bessel_k(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) noexcept + int gr_bessel_j_y(gr_ptr res1, gr_ptr res2, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) noexcept + int gr_bessel_i_scaled(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) noexcept + int gr_bessel_k_scaled(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) noexcept + + int gr_airy(gr_ptr res1, gr_ptr res2, gr_ptr res3, gr_ptr res4, gr_srcptr x, gr_ctx_t ctx) noexcept + int gr_airy_ai(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept + int gr_airy_bi(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept + int gr_airy_ai_prime(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept + int gr_airy_bi_prime(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept + + int gr_airy_ai_zero(gr_ptr res, const fmpz_t n, gr_ctx_t ctx) noexcept + int gr_airy_bi_zero(gr_ptr res, const fmpz_t n, gr_ctx_t ctx) noexcept + int gr_airy_ai_prime_zero(gr_ptr res, const fmpz_t n, gr_ctx_t ctx) noexcept + int gr_airy_bi_prime_zero(gr_ptr res, const fmpz_t n, gr_ctx_t ctx) noexcept + + int gr_coulomb(gr_ptr res1, gr_ptr res2, gr_ptr res3, gr_ptr res4, gr_srcptr x, gr_srcptr y, gr_srcptr z, gr_ctx_t ctx) noexcept + int gr_coulomb_f(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_srcptr z, gr_ctx_t ctx) noexcept + int gr_coulomb_g(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_srcptr z, gr_ctx_t ctx) noexcept + int gr_coulomb_hpos(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_srcptr z, gr_ctx_t ctx) noexcept + int gr_coulomb_hneg(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_srcptr z, gr_ctx_t ctx) noexcept + + int gr_hypgeom_0f1(gr_ptr res, gr_srcptr a, gr_srcptr z, int flags, gr_ctx_t ctx) noexcept + int gr_hypgeom_1f1(gr_ptr res, gr_srcptr a, gr_srcptr b, gr_srcptr z, int flags, gr_ctx_t ctx) noexcept + int gr_hypgeom_u(gr_ptr res, gr_srcptr a, gr_srcptr b, gr_srcptr z, int flags, gr_ctx_t ctx) noexcept + int gr_hypgeom_2f1(gr_ptr res, gr_srcptr a, gr_srcptr b, gr_srcptr c, gr_srcptr z, int flags, gr_ctx_t ctx) noexcept + int gr_hypgeom_pfq(gr_ptr res, const gr_vec_t a, const gr_vec_t b, gr_srcptr z, int flags, gr_ctx_t ctx) noexcept + + int gr_zeta(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept + int gr_zeta_ui(gr_ptr res, ulong x, gr_ctx_t ctx) noexcept + int gr_hurwitz_zeta(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) noexcept + int gr_polygamma(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) noexcept + int gr_polylog(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) noexcept + int gr_lerch_phi(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_srcptr z, gr_ctx_t ctx) noexcept + int gr_stieltjes(gr_ptr res, const fmpz_t x, gr_srcptr y, gr_ctx_t ctx) noexcept + + int gr_dirichlet_eta(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept + int gr_riemann_xi(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept + int gr_zeta_zero(gr_ptr res, const fmpz_t n, gr_ctx_t ctx) noexcept + int gr_zeta_zero_vec(gr_ptr res, const fmpz_t n, slong len, gr_ctx_t ctx) noexcept + int gr_zeta_nzeros(gr_ptr res, gr_srcptr t, gr_ctx_t ctx) noexcept + + int gr_dirichlet_chi_fmpz(gr_ptr res, const dirichlet_group_t G, const dirichlet_char_t chi, const fmpz_t n, gr_ctx_t ctx) noexcept + int gr_dirichlet_chi_vec(gr_ptr res, const dirichlet_group_t G, const dirichlet_char_t chi, slong len, gr_ctx_t ctx) noexcept + int gr_dirichlet_l(gr_ptr res, const dirichlet_group_t G, const dirichlet_char_t chi, gr_srcptr s, gr_ctx_t ctx) noexcept + int gr_dirichlet_l_all(gr_vec_t res, const dirichlet_group_t G, gr_srcptr s, gr_ctx_t ctx) noexcept + int gr_dirichlet_hardy_theta(gr_ptr res, const dirichlet_group_t G, const dirichlet_char_t chi, gr_srcptr t, gr_ctx_t ctx) noexcept + int gr_dirichlet_hardy_z(gr_ptr res, const dirichlet_group_t G, const dirichlet_char_t chi, gr_srcptr t, gr_ctx_t ctx) noexcept + + int gr_agm1(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept + int gr_agm(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) noexcept + + int gr_elliptic_k(gr_ptr res, gr_srcptr m, gr_ctx_t ctx) noexcept + int gr_elliptic_e(gr_ptr res, gr_srcptr m, gr_ctx_t ctx) noexcept + int gr_elliptic_pi(gr_ptr res, gr_srcptr n, gr_srcptr m, gr_ctx_t ctx) noexcept + int gr_elliptic_f(gr_ptr res, gr_srcptr phi, gr_srcptr m, int pi, gr_ctx_t ctx) noexcept + int gr_elliptic_e_inc(gr_ptr res, gr_srcptr phi, gr_srcptr m, int pi, gr_ctx_t ctx) noexcept + int gr_elliptic_pi_inc(gr_ptr res, gr_srcptr n, gr_srcptr phi, gr_srcptr m, int pi, gr_ctx_t ctx) noexcept + + int gr_carlson_rc(gr_ptr res, gr_srcptr x, gr_srcptr y, int flags, gr_ctx_t ctx) noexcept + int gr_carlson_rf(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_srcptr z, int flags, gr_ctx_t ctx) noexcept + int gr_carlson_rd(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_srcptr z, int flags, gr_ctx_t ctx) noexcept + int gr_carlson_rg(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_srcptr z, int flags, gr_ctx_t ctx) noexcept + int gr_carlson_rj(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_srcptr z, gr_srcptr w, int flags, gr_ctx_t ctx) noexcept + + int gr_jacobi_theta(gr_ptr res1, gr_ptr res2, gr_ptr res3, gr_ptr res4, gr_srcptr z, gr_srcptr tau, gr_ctx_t ctx) noexcept + int gr_jacobi_theta_1(gr_ptr res, gr_srcptr z, gr_srcptr tau, gr_ctx_t ctx) noexcept + int gr_jacobi_theta_2(gr_ptr res, gr_srcptr z, gr_srcptr tau, gr_ctx_t ctx) noexcept + int gr_jacobi_theta_3(gr_ptr res, gr_srcptr z, gr_srcptr tau, gr_ctx_t ctx) noexcept + int gr_jacobi_theta_4(gr_ptr res, gr_srcptr z, gr_srcptr tau, gr_ctx_t ctx) noexcept + + int gr_dedekind_eta(gr_ptr res, gr_srcptr tau, gr_ctx_t ctx) noexcept + int gr_dedekind_eta_q(gr_ptr res, gr_srcptr tau, gr_ctx_t ctx) noexcept + + int gr_modular_j(gr_ptr res, gr_srcptr tau, gr_ctx_t ctx) noexcept + int gr_modular_lambda(gr_ptr res, gr_srcptr tau, gr_ctx_t ctx) noexcept + int gr_modular_delta(gr_ptr res, gr_srcptr tau, gr_ctx_t ctx) noexcept + + int gr_hilbert_class_poly(gr_ptr res, slong D, gr_srcptr x, gr_ctx_t ctx) noexcept + + int gr_eisenstein_e(gr_ptr res, ulong n, gr_srcptr tau, gr_ctx_t ctx) noexcept + int gr_eisenstein_g(gr_ptr res, ulong n, gr_srcptr tau, gr_ctx_t ctx) noexcept + int gr_eisenstein_g_vec(gr_ptr res, gr_srcptr tau, slong len, gr_ctx_t ctx) noexcept + + int gr_elliptic_invariants(gr_ptr res1, gr_ptr res2, gr_srcptr tau, gr_ctx_t ctx) noexcept + int gr_elliptic_roots(gr_ptr res1, gr_ptr res2, gr_ptr res3, gr_srcptr tau, gr_ctx_t ctx) noexcept + + int gr_weierstrass_p(gr_ptr res, gr_srcptr z, gr_srcptr tau, gr_ctx_t ctx) noexcept + int gr_weierstrass_p_prime(gr_ptr res, gr_srcptr z, gr_srcptr tau, gr_ctx_t ctx) noexcept + int gr_weierstrass_p_inv(gr_ptr res, gr_srcptr z, gr_srcptr tau, gr_ctx_t ctx) noexcept + int gr_weierstrass_zeta(gr_ptr res, gr_srcptr z, gr_srcptr tau, gr_ctx_t ctx) noexcept + int gr_weierstrass_sigma(gr_ptr res, gr_srcptr z, gr_srcptr tau, gr_ctx_t ctx) noexcept diff --git a/src/sage/libs/flint/gr_vec.pxd b/src/sage/libs/flint/gr_vec.pxd index 3abe7600f21..a5dbd3ba96f 100644 --- a/src/sage/libs/flint/gr_vec.pxd +++ b/src/sage/libs/flint/gr_vec.pxd @@ -12,165 +12,165 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void gr_vec_init(gr_vec_t vec, slong len, gr_ctx_t ctx) + void gr_vec_init(gr_vec_t vec, slong len, gr_ctx_t ctx) noexcept # Initializes *vec* to a vector of length *len* with elements # in the ring *ctx*. The length must be nonnegative. # All entries are set to zero. - void gr_vec_clear(gr_vec_t vec, gr_ctx_t ctx) + void gr_vec_clear(gr_vec_t vec, gr_ctx_t ctx) noexcept # Clears the vector *vec*. - gr_ptr gr_vec_entry_ptr(gr_vec_t vec, slong i, gr_ctx_t ctx) + gr_ptr gr_vec_entry_ptr(gr_vec_t vec, slong i, gr_ctx_t ctx) noexcept # Returns a pointer to the *i*-th element in the vector *vec*, # indexed from zero. The index must be in bounds. - slong gr_vec_length(const gr_vec_t vec, gr_ctx_t ctx) + slong gr_vec_length(const gr_vec_t vec, gr_ctx_t ctx) noexcept # Returns the length of the vector *vec*. - void gr_vec_fit_length(gr_vec_t vec, slong len, gr_ctx_t ctx) + void gr_vec_fit_length(gr_vec_t vec, slong len, gr_ctx_t ctx) noexcept # Allocates space for at least *len* elements in the vector *vec*. # This does not change the size of the vector. - void gr_vec_set_length(gr_vec_t vec, slong len, gr_ctx_t ctx) + void gr_vec_set_length(gr_vec_t vec, slong len, gr_ctx_t ctx) noexcept # Resizes the vector to length *len*, which must be nonnegative. # The vector will be extended with zeros. - int gr_vec_set(gr_vec_t res, const gr_vec_t src, gr_ctx_t ctx) + int gr_vec_set(gr_vec_t res, const gr_vec_t src, gr_ctx_t ctx) noexcept # Sets *res* to a copy of the vector *src*. - int gr_vec_append(gr_vec_t vec, gr_srcptr x, gr_ctx_t ctx) + int gr_vec_append(gr_vec_t vec, gr_srcptr x, gr_ctx_t ctx) noexcept # Appends the element *x* to the end of vector *vec*. - int _gr_vec_write(gr_stream_t out, gr_srcptr vec, slong len, gr_ctx_t ctx) - int gr_vec_write(gr_stream_t out, const gr_vec_t vec, gr_ctx_t ctx) - int gr_vec_print(const gr_vec_t vec, gr_ctx_t ctx) + int _gr_vec_write(gr_stream_t out, gr_srcptr vec, slong len, gr_ctx_t ctx) noexcept + int gr_vec_write(gr_stream_t out, const gr_vec_t vec, gr_ctx_t ctx) noexcept + int gr_vec_print(const gr_vec_t vec, gr_ctx_t ctx) noexcept - void _gr_vec_init(gr_ptr vec, slong len, gr_ctx_t ctx) + void _gr_vec_init(gr_ptr vec, slong len, gr_ctx_t ctx) noexcept # Initialize *len* elements of *vec* to the value 0. # The pointer *vec* must already refer to allocated memory. - void _gr_vec_clear(gr_ptr vec, slong len, gr_ctx_t ctx) + void _gr_vec_clear(gr_ptr vec, slong len, gr_ctx_t ctx) noexcept # Clears *len* elements of *vec*. # This frees memory allocated by individual elements, but # does not free the memory allocated by *vec* itself. - void _gr_vec_swap(gr_ptr vec1, gr_ptr vec2, slong len, gr_ctx_t ctx) + void _gr_vec_swap(gr_ptr vec1, gr_ptr vec2, slong len, gr_ctx_t ctx) noexcept # Swap the entries of *vec1* and *vec2*. - int _gr_vec_randtest(gr_ptr res, flint_rand_t state, slong len, gr_ctx_t ctx) + int _gr_vec_randtest(gr_ptr res, flint_rand_t state, slong len, gr_ctx_t ctx) noexcept - int _gr_vec_set(gr_ptr res, gr_srcptr src, slong len, gr_ctx_t ctx) + int _gr_vec_set(gr_ptr res, gr_srcptr src, slong len, gr_ctx_t ctx) noexcept - truth_t _gr_vec_equal(gr_srcptr vec1, gr_srcptr vec2, slong len, gr_ctx_t ctx) + truth_t _gr_vec_equal(gr_srcptr vec1, gr_srcptr vec2, slong len, gr_ctx_t ctx) noexcept - int _gr_vec_zero(gr_ptr vec, slong len, gr_ctx_t ctx) + int _gr_vec_zero(gr_ptr vec, slong len, gr_ctx_t ctx) noexcept - truth_t _gr_vec_is_zero(gr_srcptr vec, slong len, gr_ctx_t ctx) + truth_t _gr_vec_is_zero(gr_srcptr vec, slong len, gr_ctx_t ctx) noexcept - int _gr_vec_normalise(slong * res, gr_srcptr vec, slong len, gr_ctx_t ctx) + int _gr_vec_normalise(slong * res, gr_srcptr vec, slong len, gr_ctx_t ctx) noexcept - slong _gr_vec_normalise_weak(gr_srcptr vec, slong len, gr_ctx_t ctx) + slong _gr_vec_normalise_weak(gr_srcptr vec, slong len, gr_ctx_t ctx) noexcept - int _gr_vec_neg(gr_ptr res, gr_srcptr src, slong len, gr_ctx_t ctx) + int _gr_vec_neg(gr_ptr res, gr_srcptr src, slong len, gr_ctx_t ctx) noexcept - int _gr_vec_add(gr_ptr res, gr_srcptr src1, gr_srcptr src2, slong len, gr_ctx_t ctx) - int _gr_vec_sub(gr_ptr res, gr_srcptr src1, gr_srcptr src2, slong len, gr_ctx_t ctx) - int _gr_vec_mul(gr_ptr res, gr_srcptr src1, gr_srcptr src2, slong len, gr_ctx_t ctx) - int _gr_vec_div(gr_ptr res, gr_srcptr src1, gr_srcptr src2, slong len, gr_ctx_t ctx) - int _gr_vec_divexact(gr_ptr res, gr_srcptr src1, gr_srcptr src2, slong len, gr_ctx_t ctx) - int _gr_vec_pow(gr_ptr res, gr_srcptr src1, gr_srcptr src2, slong len, gr_ctx_t ctx) + int _gr_vec_add(gr_ptr res, gr_srcptr src1, gr_srcptr src2, slong len, gr_ctx_t ctx) noexcept + int _gr_vec_sub(gr_ptr res, gr_srcptr src1, gr_srcptr src2, slong len, gr_ctx_t ctx) noexcept + int _gr_vec_mul(gr_ptr res, gr_srcptr src1, gr_srcptr src2, slong len, gr_ctx_t ctx) noexcept + int _gr_vec_div(gr_ptr res, gr_srcptr src1, gr_srcptr src2, slong len, gr_ctx_t ctx) noexcept + int _gr_vec_divexact(gr_ptr res, gr_srcptr src1, gr_srcptr src2, slong len, gr_ctx_t ctx) noexcept + int _gr_vec_pow(gr_ptr res, gr_srcptr src1, gr_srcptr src2, slong len, gr_ctx_t ctx) noexcept # Binary operations applied elementwise. - int _gr_vec_add_scalar(gr_ptr vec1, gr_srcptr vec2, slong len, gr_srcptr c, gr_ctx_t ctx) - int _gr_vec_sub_scalar(gr_ptr vec1, gr_srcptr vec2, slong len, gr_srcptr c, gr_ctx_t ctx) - int _gr_vec_mul_scalar(gr_ptr vec1, gr_srcptr vec2, slong len, gr_srcptr c, gr_ctx_t ctx) - int _gr_vec_div_scalar(gr_ptr vec1, gr_srcptr vec2, slong len, gr_srcptr c, gr_ctx_t ctx) - int _gr_vec_divexact_scalar(gr_ptr vec1, gr_srcptr vec2, slong len, gr_srcptr c, gr_ctx_t ctx) - int _gr_vec_pow_scalar(gr_ptr vec1, gr_srcptr vec2, slong len, gr_srcptr c, gr_ctx_t ctx) - int _gr_scalar_add_vec(gr_ptr vec1, gr_srcptr c, gr_srcptr vec2, slong len, gr_ctx_t ctx) - int _gr_scalar_sub_vec(gr_ptr vec1, gr_srcptr c, gr_srcptr vec2, slong len, gr_ctx_t ctx) - int _gr_scalar_mul_vec(gr_ptr vec1, gr_srcptr c, gr_srcptr vec2, slong len, gr_ctx_t ctx) - int _gr_scalar_div_vec(gr_ptr vec1, gr_srcptr c, gr_srcptr vec2, slong len, gr_ctx_t ctx) - int _gr_scalar_divexact_vec(gr_ptr vec1, gr_srcptr c, gr_srcptr vec2, slong len, gr_ctx_t ctx) - int _gr_scalar_pow_vec(gr_ptr vec1, gr_srcptr c, gr_srcptr vec2, slong len, gr_ctx_t ctx) + int _gr_vec_add_scalar(gr_ptr vec1, gr_srcptr vec2, slong len, gr_srcptr c, gr_ctx_t ctx) noexcept + int _gr_vec_sub_scalar(gr_ptr vec1, gr_srcptr vec2, slong len, gr_srcptr c, gr_ctx_t ctx) noexcept + int _gr_vec_mul_scalar(gr_ptr vec1, gr_srcptr vec2, slong len, gr_srcptr c, gr_ctx_t ctx) noexcept + int _gr_vec_div_scalar(gr_ptr vec1, gr_srcptr vec2, slong len, gr_srcptr c, gr_ctx_t ctx) noexcept + int _gr_vec_divexact_scalar(gr_ptr vec1, gr_srcptr vec2, slong len, gr_srcptr c, gr_ctx_t ctx) noexcept + int _gr_vec_pow_scalar(gr_ptr vec1, gr_srcptr vec2, slong len, gr_srcptr c, gr_ctx_t ctx) noexcept + int _gr_scalar_add_vec(gr_ptr vec1, gr_srcptr c, gr_srcptr vec2, slong len, gr_ctx_t ctx) noexcept + int _gr_scalar_sub_vec(gr_ptr vec1, gr_srcptr c, gr_srcptr vec2, slong len, gr_ctx_t ctx) noexcept + int _gr_scalar_mul_vec(gr_ptr vec1, gr_srcptr c, gr_srcptr vec2, slong len, gr_ctx_t ctx) noexcept + int _gr_scalar_div_vec(gr_ptr vec1, gr_srcptr c, gr_srcptr vec2, slong len, gr_ctx_t ctx) noexcept + int _gr_scalar_divexact_vec(gr_ptr vec1, gr_srcptr c, gr_srcptr vec2, slong len, gr_ctx_t ctx) noexcept + int _gr_scalar_pow_vec(gr_ptr vec1, gr_srcptr c, gr_srcptr vec2, slong len, gr_ctx_t ctx) noexcept # Binary operations applied elementwise with a fixed scalar operand. - int _gr_vec_add_other(gr_ptr vec1, gr_srcptr vec2, gr_srcptr vec3, gr_ctx_t ctx3, slong len, gr_ctx_t ctx) - int _gr_vec_sub_other(gr_ptr vec1, gr_srcptr vec2, gr_srcptr vec3, gr_ctx_t ctx3, slong len, gr_ctx_t ctx) - int _gr_vec_mul_other(gr_ptr vec1, gr_srcptr vec2, gr_srcptr vec3, gr_ctx_t ctx3, slong len, gr_ctx_t ctx) - int _gr_vec_div_other(gr_ptr vec1, gr_srcptr vec2, gr_srcptr vec3, gr_ctx_t ctx3, slong len, gr_ctx_t ctx) - int _gr_vec_divexact_other(gr_ptr vec1, gr_srcptr vec2, gr_srcptr vec3, gr_ctx_t ctx3, slong len, gr_ctx_t ctx) - int _gr_vec_pow_other(gr_ptr vec1, gr_srcptr vec2, gr_srcptr vec3, gr_ctx_t ctx3, slong len, gr_ctx_t ctx) - int _gr_other_add_vec(gr_ptr vec1, gr_srcptr vec2, gr_ctx_t ctx2, gr_srcptr vec3, slong len, gr_ctx_t ctx) - int _gr_other_sub_vec(gr_ptr vec1, gr_srcptr vec2, gr_ctx_t ctx2, gr_srcptr vec3, slong len, gr_ctx_t ctx) - int _gr_other_mul_vec(gr_ptr vec1, gr_srcptr vec2, gr_ctx_t ctx2, gr_srcptr vec3, slong len, gr_ctx_t ctx) - int _gr_other_div_vec(gr_ptr vec1, gr_srcptr vec2, gr_ctx_t ctx2, gr_srcptr vec3, slong len, gr_ctx_t ctx) - int _gr_other_divexact_vec(gr_ptr vec1, gr_srcptr vec2, gr_ctx_t ctx2, gr_srcptr vec3, slong len, gr_ctx_t ctx) - int _gr_other_pow_vec(gr_ptr vec1, gr_srcptr vec2, gr_ctx_t ctx2, gr_srcptr vec3, slong len, gr_ctx_t ctx) + int _gr_vec_add_other(gr_ptr vec1, gr_srcptr vec2, gr_srcptr vec3, gr_ctx_t ctx3, slong len, gr_ctx_t ctx) noexcept + int _gr_vec_sub_other(gr_ptr vec1, gr_srcptr vec2, gr_srcptr vec3, gr_ctx_t ctx3, slong len, gr_ctx_t ctx) noexcept + int _gr_vec_mul_other(gr_ptr vec1, gr_srcptr vec2, gr_srcptr vec3, gr_ctx_t ctx3, slong len, gr_ctx_t ctx) noexcept + int _gr_vec_div_other(gr_ptr vec1, gr_srcptr vec2, gr_srcptr vec3, gr_ctx_t ctx3, slong len, gr_ctx_t ctx) noexcept + int _gr_vec_divexact_other(gr_ptr vec1, gr_srcptr vec2, gr_srcptr vec3, gr_ctx_t ctx3, slong len, gr_ctx_t ctx) noexcept + int _gr_vec_pow_other(gr_ptr vec1, gr_srcptr vec2, gr_srcptr vec3, gr_ctx_t ctx3, slong len, gr_ctx_t ctx) noexcept + int _gr_other_add_vec(gr_ptr vec1, gr_srcptr vec2, gr_ctx_t ctx2, gr_srcptr vec3, slong len, gr_ctx_t ctx) noexcept + int _gr_other_sub_vec(gr_ptr vec1, gr_srcptr vec2, gr_ctx_t ctx2, gr_srcptr vec3, slong len, gr_ctx_t ctx) noexcept + int _gr_other_mul_vec(gr_ptr vec1, gr_srcptr vec2, gr_ctx_t ctx2, gr_srcptr vec3, slong len, gr_ctx_t ctx) noexcept + int _gr_other_div_vec(gr_ptr vec1, gr_srcptr vec2, gr_ctx_t ctx2, gr_srcptr vec3, slong len, gr_ctx_t ctx) noexcept + int _gr_other_divexact_vec(gr_ptr vec1, gr_srcptr vec2, gr_ctx_t ctx2, gr_srcptr vec3, slong len, gr_ctx_t ctx) noexcept + int _gr_other_pow_vec(gr_ptr vec1, gr_srcptr vec2, gr_ctx_t ctx2, gr_srcptr vec3, slong len, gr_ctx_t ctx) noexcept # Binary operations applied elementwise, allowing a different type for one of the vectors. - int _gr_vec_add_scalar_other(gr_ptr vec1, gr_srcptr vec2, slong len, gr_srcptr c, gr_ctx_t cctx, gr_ctx_t ctx) - int _gr_vec_sub_scalar_other(gr_ptr vec1, gr_srcptr vec2, slong len, gr_srcptr c, gr_ctx_t cctx, gr_ctx_t ctx) - int _gr_vec_mul_scalar_other(gr_ptr vec1, gr_srcptr vec2, slong len, gr_srcptr c, gr_ctx_t cctx, gr_ctx_t ctx) - int _gr_vec_div_scalar_other(gr_ptr vec1, gr_srcptr vec2, slong len, gr_srcptr c, gr_ctx_t cctx, gr_ctx_t ctx) - int _gr_vec_divexact_scalar_other(gr_ptr vec1, gr_srcptr vec2, slong len, gr_srcptr c, gr_ctx_t cctx, gr_ctx_t ctx) - int _gr_vec_pow_scalar_other(gr_ptr vec1, gr_srcptr vec2, slong len, gr_srcptr c, gr_ctx_t cctx, gr_ctx_t ctx) - int _gr_scalar_other_add_vec(gr_ptr vec1, gr_srcptr c, gr_ctx_t cctx, gr_srcptr vec2, slong len, gr_ctx_t ctx) - int _gr_scalar_other_sub_vec(gr_ptr vec1, gr_srcptr c, gr_ctx_t cctx, gr_srcptr vec2, slong len, gr_ctx_t ctx) - int _gr_scalar_other_mul_vec(gr_ptr vec1, gr_srcptr c, gr_ctx_t cctx, gr_srcptr vec2, slong len, gr_ctx_t ctx) - int _gr_scalar_other_div_vec(gr_ptr vec1, gr_srcptr c, gr_ctx_t cctx, gr_srcptr vec2, slong len, gr_ctx_t ctx) - int _gr_scalar_other_divexact_vec(gr_ptr vec1, gr_srcptr c, gr_ctx_t cctx, gr_srcptr vec2, slong len, gr_ctx_t ctx) - int _gr_scalar_other_pow_vec(gr_ptr vec1, gr_srcptr c, gr_ctx_t cctx, gr_srcptr vec2, slong len, gr_ctx_t ctx) - int _gr_vec_add_scalar_si(gr_ptr vec1, gr_srcptr vec2, slong len, slong c, gr_ctx_t ctx) - int _gr_vec_sub_scalar_si(gr_ptr vec1, gr_srcptr vec2, slong len, slong c, gr_ctx_t ctx) - int _gr_vec_mul_scalar_si(gr_ptr vec1, gr_srcptr vec2, slong len, slong c, gr_ctx_t ctx) - int _gr_vec_div_scalar_si(gr_ptr vec1, gr_srcptr vec2, slong len, slong c, gr_ctx_t ctx) - int _gr_vec_divexact_scalar_si(gr_ptr vec1, gr_srcptr vec2, slong len, slong c, gr_ctx_t ctx) - int _gr_vec_pow_scalar_si(gr_ptr vec1, gr_srcptr vec2, slong len, slong c, gr_ctx_t ctx) - int _gr_vec_add_scalar_ui(gr_ptr vec1, gr_srcptr vec2, slong len, ulong c, gr_ctx_t ctx) - int _gr_vec_sub_scalar_ui(gr_ptr vec1, gr_srcptr vec2, slong len, ulong c, gr_ctx_t ctx) - int _gr_vec_mul_scalar_ui(gr_ptr vec1, gr_srcptr vec2, slong len, ulong c, gr_ctx_t ctx) - int _gr_vec_div_scalar_ui(gr_ptr vec1, gr_srcptr vec2, slong len, ulong c, gr_ctx_t ctx) - int _gr_vec_divexact_scalar_ui(gr_ptr vec1, gr_srcptr vec2, slong len, ulong c, gr_ctx_t ctx) - int _gr_vec_pow_scalar_ui(gr_ptr vec1, gr_srcptr vec2, slong len, ulong c, gr_ctx_t ctx) - int _gr_vec_add_scalar_fmpz(gr_ptr vec1, gr_srcptr vec2, slong len, const fmpz_t c, gr_ctx_t ctx) - int _gr_vec_sub_scalar_fmpz(gr_ptr vec1, gr_srcptr vec2, slong len, const fmpz_t c, gr_ctx_t ctx) - int _gr_vec_mul_scalar_fmpz(gr_ptr vec1, gr_srcptr vec2, slong len, const fmpz_t c, gr_ctx_t ctx) - int _gr_vec_div_scalar_fmpz(gr_ptr vec1, gr_srcptr vec2, slong len, const fmpz_t c, gr_ctx_t ctx) - int _gr_vec_divexact_scalar_fmpz(gr_ptr vec1, gr_srcptr vec2, slong len, const fmpz_t c, gr_ctx_t ctx) - int _gr_vec_pow_scalar_fmpz(gr_ptr vec1, gr_srcptr vec2, slong len, const fmpz_t c, gr_ctx_t ctx) - int _gr_vec_add_scalar_fmpq(gr_ptr vec1, gr_srcptr vec2, slong len, const fmpq_t c, gr_ctx_t ctx) - int _gr_vec_sub_scalar_fmpq(gr_ptr vec1, gr_srcptr vec2, slong len, const fmpq_t c, gr_ctx_t ctx) - int _gr_vec_mul_scalar_fmpq(gr_ptr vec1, gr_srcptr vec2, slong len, const fmpq_t c, gr_ctx_t ctx) - int _gr_vec_div_scalar_fmpq(gr_ptr vec1, gr_srcptr vec2, slong len, const fmpq_t c, gr_ctx_t ctx) - int _gr_vec_divexact_scalar_fmpq(gr_ptr vec1, gr_srcptr vec2, slong len, const fmpq_t c, gr_ctx_t ctx) - int _gr_vec_pow_scalar_fmpq(gr_ptr vec1, gr_srcptr vec2, slong len, const fmpq_t c, gr_ctx_t ctx) + int _gr_vec_add_scalar_other(gr_ptr vec1, gr_srcptr vec2, slong len, gr_srcptr c, gr_ctx_t cctx, gr_ctx_t ctx) noexcept + int _gr_vec_sub_scalar_other(gr_ptr vec1, gr_srcptr vec2, slong len, gr_srcptr c, gr_ctx_t cctx, gr_ctx_t ctx) noexcept + int _gr_vec_mul_scalar_other(gr_ptr vec1, gr_srcptr vec2, slong len, gr_srcptr c, gr_ctx_t cctx, gr_ctx_t ctx) noexcept + int _gr_vec_div_scalar_other(gr_ptr vec1, gr_srcptr vec2, slong len, gr_srcptr c, gr_ctx_t cctx, gr_ctx_t ctx) noexcept + int _gr_vec_divexact_scalar_other(gr_ptr vec1, gr_srcptr vec2, slong len, gr_srcptr c, gr_ctx_t cctx, gr_ctx_t ctx) noexcept + int _gr_vec_pow_scalar_other(gr_ptr vec1, gr_srcptr vec2, slong len, gr_srcptr c, gr_ctx_t cctx, gr_ctx_t ctx) noexcept + int _gr_scalar_other_add_vec(gr_ptr vec1, gr_srcptr c, gr_ctx_t cctx, gr_srcptr vec2, slong len, gr_ctx_t ctx) noexcept + int _gr_scalar_other_sub_vec(gr_ptr vec1, gr_srcptr c, gr_ctx_t cctx, gr_srcptr vec2, slong len, gr_ctx_t ctx) noexcept + int _gr_scalar_other_mul_vec(gr_ptr vec1, gr_srcptr c, gr_ctx_t cctx, gr_srcptr vec2, slong len, gr_ctx_t ctx) noexcept + int _gr_scalar_other_div_vec(gr_ptr vec1, gr_srcptr c, gr_ctx_t cctx, gr_srcptr vec2, slong len, gr_ctx_t ctx) noexcept + int _gr_scalar_other_divexact_vec(gr_ptr vec1, gr_srcptr c, gr_ctx_t cctx, gr_srcptr vec2, slong len, gr_ctx_t ctx) noexcept + int _gr_scalar_other_pow_vec(gr_ptr vec1, gr_srcptr c, gr_ctx_t cctx, gr_srcptr vec2, slong len, gr_ctx_t ctx) noexcept + int _gr_vec_add_scalar_si(gr_ptr vec1, gr_srcptr vec2, slong len, slong c, gr_ctx_t ctx) noexcept + int _gr_vec_sub_scalar_si(gr_ptr vec1, gr_srcptr vec2, slong len, slong c, gr_ctx_t ctx) noexcept + int _gr_vec_mul_scalar_si(gr_ptr vec1, gr_srcptr vec2, slong len, slong c, gr_ctx_t ctx) noexcept + int _gr_vec_div_scalar_si(gr_ptr vec1, gr_srcptr vec2, slong len, slong c, gr_ctx_t ctx) noexcept + int _gr_vec_divexact_scalar_si(gr_ptr vec1, gr_srcptr vec2, slong len, slong c, gr_ctx_t ctx) noexcept + int _gr_vec_pow_scalar_si(gr_ptr vec1, gr_srcptr vec2, slong len, slong c, gr_ctx_t ctx) noexcept + int _gr_vec_add_scalar_ui(gr_ptr vec1, gr_srcptr vec2, slong len, ulong c, gr_ctx_t ctx) noexcept + int _gr_vec_sub_scalar_ui(gr_ptr vec1, gr_srcptr vec2, slong len, ulong c, gr_ctx_t ctx) noexcept + int _gr_vec_mul_scalar_ui(gr_ptr vec1, gr_srcptr vec2, slong len, ulong c, gr_ctx_t ctx) noexcept + int _gr_vec_div_scalar_ui(gr_ptr vec1, gr_srcptr vec2, slong len, ulong c, gr_ctx_t ctx) noexcept + int _gr_vec_divexact_scalar_ui(gr_ptr vec1, gr_srcptr vec2, slong len, ulong c, gr_ctx_t ctx) noexcept + int _gr_vec_pow_scalar_ui(gr_ptr vec1, gr_srcptr vec2, slong len, ulong c, gr_ctx_t ctx) noexcept + int _gr_vec_add_scalar_fmpz(gr_ptr vec1, gr_srcptr vec2, slong len, const fmpz_t c, gr_ctx_t ctx) noexcept + int _gr_vec_sub_scalar_fmpz(gr_ptr vec1, gr_srcptr vec2, slong len, const fmpz_t c, gr_ctx_t ctx) noexcept + int _gr_vec_mul_scalar_fmpz(gr_ptr vec1, gr_srcptr vec2, slong len, const fmpz_t c, gr_ctx_t ctx) noexcept + int _gr_vec_div_scalar_fmpz(gr_ptr vec1, gr_srcptr vec2, slong len, const fmpz_t c, gr_ctx_t ctx) noexcept + int _gr_vec_divexact_scalar_fmpz(gr_ptr vec1, gr_srcptr vec2, slong len, const fmpz_t c, gr_ctx_t ctx) noexcept + int _gr_vec_pow_scalar_fmpz(gr_ptr vec1, gr_srcptr vec2, slong len, const fmpz_t c, gr_ctx_t ctx) noexcept + int _gr_vec_add_scalar_fmpq(gr_ptr vec1, gr_srcptr vec2, slong len, const fmpq_t c, gr_ctx_t ctx) noexcept + int _gr_vec_sub_scalar_fmpq(gr_ptr vec1, gr_srcptr vec2, slong len, const fmpq_t c, gr_ctx_t ctx) noexcept + int _gr_vec_mul_scalar_fmpq(gr_ptr vec1, gr_srcptr vec2, slong len, const fmpq_t c, gr_ctx_t ctx) noexcept + int _gr_vec_div_scalar_fmpq(gr_ptr vec1, gr_srcptr vec2, slong len, const fmpq_t c, gr_ctx_t ctx) noexcept + int _gr_vec_divexact_scalar_fmpq(gr_ptr vec1, gr_srcptr vec2, slong len, const fmpq_t c, gr_ctx_t ctx) noexcept + int _gr_vec_pow_scalar_fmpq(gr_ptr vec1, gr_srcptr vec2, slong len, const fmpq_t c, gr_ctx_t ctx) noexcept # Binary operations applied elementwise with a fixed scalar operand, allowing a different type # for the scalar. - int _gr_vec_addmul_scalar(gr_ptr vec1, gr_srcptr vec2, slong len, gr_srcptr c, gr_ctx_t ctx) - int _gr_vec_submul_scalar(gr_ptr vec1, gr_srcptr vec2, slong len, gr_srcptr c, gr_ctx_t ctx) - int _gr_vec_addmul_scalar_si(gr_ptr vec1, gr_srcptr vec2, slong len, slong c, gr_ctx_t ctx) - int _gr_vec_submul_scalar_si(gr_ptr vec1, gr_srcptr vec2, slong len, slong c, gr_ctx_t ctx) + int _gr_vec_addmul_scalar(gr_ptr vec1, gr_srcptr vec2, slong len, gr_srcptr c, gr_ctx_t ctx) noexcept + int _gr_vec_submul_scalar(gr_ptr vec1, gr_srcptr vec2, slong len, gr_srcptr c, gr_ctx_t ctx) noexcept + int _gr_vec_addmul_scalar_si(gr_ptr vec1, gr_srcptr vec2, slong len, slong c, gr_ctx_t ctx) noexcept + int _gr_vec_submul_scalar_si(gr_ptr vec1, gr_srcptr vec2, slong len, slong c, gr_ctx_t ctx) noexcept - int _gr_vec_mul_scalar_2exp_si(gr_ptr res, gr_srcptr vec, slong len, slong c, gr_ctx_t ctx) + int _gr_vec_mul_scalar_2exp_si(gr_ptr res, gr_srcptr vec, slong len, slong c, gr_ctx_t ctx) noexcept - int _gr_vec_sum(gr_ptr res, gr_srcptr vec, slong len, gr_ctx_t ctx) + int _gr_vec_sum(gr_ptr res, gr_srcptr vec, slong len, gr_ctx_t ctx) noexcept - int _gr_vec_product(gr_ptr res, gr_srcptr vec, slong len, gr_ctx_t ctx) + int _gr_vec_product(gr_ptr res, gr_srcptr vec, slong len, gr_ctx_t ctx) noexcept - int _gr_vec_dot(gr_ptr res, gr_srcptr initial, int subtract, gr_srcptr vec1, gr_srcptr vec2, slong len, gr_ctx_t ctx) - int _gr_vec_dot_si(gr_ptr res, gr_srcptr initial, int subtract, gr_srcptr vec1, const slong * vec2, slong len, gr_ctx_t ctx) - int _gr_vec_dot_ui(gr_ptr res, gr_srcptr initial, int subtract, gr_srcptr vec1, const ulong * vec2, slong len, gr_ctx_t ctx) - int _gr_vec_dot_fmpz(gr_ptr res, gr_srcptr initial, int subtract, gr_srcptr vec1, const fmpz * vec2, slong len, gr_ctx_t ctx) + int _gr_vec_dot(gr_ptr res, gr_srcptr initial, int subtract, gr_srcptr vec1, gr_srcptr vec2, slong len, gr_ctx_t ctx) noexcept + int _gr_vec_dot_si(gr_ptr res, gr_srcptr initial, int subtract, gr_srcptr vec1, const slong * vec2, slong len, gr_ctx_t ctx) noexcept + int _gr_vec_dot_ui(gr_ptr res, gr_srcptr initial, int subtract, gr_srcptr vec1, const ulong * vec2, slong len, gr_ctx_t ctx) noexcept + int _gr_vec_dot_fmpz(gr_ptr res, gr_srcptr initial, int subtract, gr_srcptr vec1, const fmpz * vec2, slong len, gr_ctx_t ctx) noexcept # Sets *res* to `c \pm \sum_{i=0}^{n-1} a_i b_i`. - int _gr_vec_dot_rev(gr_ptr res, gr_srcptr initial, int subtract, gr_srcptr vec1, gr_srcptr vec2, slong len, gr_ctx_t ctx) + int _gr_vec_dot_rev(gr_ptr res, gr_srcptr initial, int subtract, gr_srcptr vec1, gr_srcptr vec2, slong len, gr_ctx_t ctx) noexcept # Sets *res* to `c \pm \sum_{i=0}^{n-1} a_i b_{n-1-i}`. - int _gr_vec_step(gr_ptr vec, gr_srcptr start, gr_srcptr step, slong len, gr_ctx_t ctx) + int _gr_vec_step(gr_ptr vec, gr_srcptr start, gr_srcptr step, slong len, gr_ctx_t ctx) noexcept - int _gr_vec_reciprocals(gr_ptr res, slong len, gr_ctx_t ctx) + int _gr_vec_reciprocals(gr_ptr res, slong len, gr_ctx_t ctx) noexcept # Sets *res* to the vector of reciprocals of the positive integers 1, 2, ... up to *len* inclusive. - int _gr_vec_set_powers(gr_ptr res, gr_srcptr x, slong len, gr_ctx_t ctx) + int _gr_vec_set_powers(gr_ptr res, gr_srcptr x, slong len, gr_ctx_t ctx) noexcept diff --git a/src/sage/libs/flint/hypgeom.pxd b/src/sage/libs/flint/hypgeom.pxd index 6d5cfe4113b..e1dc128deda 100644 --- a/src/sage/libs/flint/hypgeom.pxd +++ b/src/sage/libs/flint/hypgeom.pxd @@ -12,11 +12,11 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void hypgeom_init(hypgeom_t hyp) + void hypgeom_init(hypgeom_t hyp) noexcept - void hypgeom_clear(hypgeom_t hyp) + void hypgeom_clear(hypgeom_t hyp) noexcept - slong hypgeom_estimate_terms(const mag_t z, int r, slong d) + slong hypgeom_estimate_terms(const mag_t z, int r, slong d) noexcept # Computes an approximation of the largest `n` such # that `|z|^n/(n!)^r = 2^{-d}`, giving a first-order estimate of the # number of terms needed to approximate the sum of a hypergeometric @@ -31,7 +31,7 @@ cdef extern from "flint_wrap.h": # The function aborts if the computed value of `n` is greater # than or equal to LONG_MAX / 2. - slong hypgeom_bound(mag_t error, int r, slong C, slong D, slong K, const mag_t TK, const mag_t z, slong prec) + slong hypgeom_bound(mag_t error, int r, slong C, slong D, slong K, const mag_t TK, const mag_t z, slong prec) noexcept # Computes a truncation parameter sufficient to achieve *prec* bits # of absolute accuracy, according to the strategy described above. # The input consists of `r`, `C`, `D`, `K`, precomputed bound for `T(K)`, @@ -45,15 +45,15 @@ cdef extern from "flint_wrap.h": # The output variable *error* is set to the value of `\varepsilon`, # and `n` is returned. - void hypgeom_precompute(hypgeom_t hyp) + void hypgeom_precompute(hypgeom_t hyp) noexcept # Precomputes the bounds data `C`, `D`, `K` and an upper bound for `T(K)`. - void arb_hypgeom_sum(arb_t P, arb_t Q, const hypgeom_t hyp, slong n, slong prec) + void arb_hypgeom_sum(arb_t P, arb_t Q, const hypgeom_t hyp, slong n, slong prec) noexcept # Computes `P, Q` such that `P / Q = \sum_{k=0}^{n-1} T(k)` where `T(k)` # is defined by *hyp*, # using binary splitting and a working precision of *prec* bits. - void arb_hypgeom_infsum(arb_t P, arb_t Q, hypgeom_t hyp, slong tol, slong prec) + void arb_hypgeom_infsum(arb_t P, arb_t Q, hypgeom_t hyp, slong tol, slong prec) noexcept # Computes `P, Q` such that `P / Q = \sum_{k=0}^{\infty} T(k)` where `T(k)` # is defined by *hyp*, using binary splitting and # working precision of *prec* bits. diff --git a/src/sage/libs/flint/long_extras.pxd b/src/sage/libs/flint/long_extras.pxd index 3efb8c50d2e..258aaabf3eb 100644 --- a/src/sage/libs/flint/long_extras.pxd +++ b/src/sage/libs/flint/long_extras.pxd @@ -12,28 +12,28 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - size_t z_sizeinbase(slong n, int b) + size_t z_sizeinbase(slong n, int b) noexcept # Returns the number of digits in the base `b` representation # of the absolute value of the integer `n`. # Assumes that `b \geq 2`. - int z_mul_checked(slong * a, slong b, slong c) + int z_mul_checked(slong * a, slong b, slong c) noexcept # Set `*a` to `b` times `c` and return `1` if the product overflowed. Otherwise, return `0`. - mp_limb_signed_t z_randtest(flint_rand_t state) + mp_limb_signed_t z_randtest(flint_rand_t state) noexcept # Returns a pseudo random number with a random number of bits, from # `0` to ``FLINT_BITS``. The probability of the special values `0`, # `\pm 1`, ``COEFF_MAX``, ``COEFF_MIN``, ``WORD_MAX`` and # ``WORD_MIN`` is increased. # This random function is mainly used for testing purposes. - mp_limb_signed_t z_randtest_not_zero(flint_rand_t state) + mp_limb_signed_t z_randtest_not_zero(flint_rand_t state) noexcept # As for ``z_randtest(state)``, but does not return `0`. - mp_limb_signed_t z_randint(flint_rand_t state, mp_limb_t limit) + mp_limb_signed_t z_randint(flint_rand_t state, mp_limb_t limit) noexcept # Returns a pseudo random number of absolute value less than # ``limit``. If ``limit`` is zero or exceeds ``WORD_MAX``, # it is interpreted as ``WORD_MAX``. - int z_kronecker(slong a, slong n) + int z_kronecker(slong a, slong n) noexcept # Return the Kronecker symbol `\left(\frac{a}{n}\right)` for any `a` and any `n`. diff --git a/src/sage/libs/flint/mag.pxd b/src/sage/libs/flint/mag.pxd index 5ab2c7a5139..0a1a16736e4 100644 --- a/src/sage/libs/flint/mag.pxd +++ b/src/sage/libs/flint/mag.pxd @@ -12,95 +12,95 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void mag_init(mag_t x) + void mag_init(mag_t x) noexcept # Initializes the variable *x* for use. Its value is set to zero. - void mag_clear(mag_t x) + void mag_clear(mag_t x) noexcept # Clears the variable *x*, freeing or recycling its allocated memory. - void mag_swap(mag_t x, mag_t y) + void mag_swap(mag_t x, mag_t y) noexcept # Swaps *x* and *y* efficiently. - mag_ptr _mag_vec_init(slong n) + mag_ptr _mag_vec_init(slong n) noexcept # Allocates a vector of length *n*. All entries are set to zero. - void _mag_vec_clear(mag_ptr v, slong n) + void _mag_vec_clear(mag_ptr v, slong n) noexcept # Clears a vector of length *n*. - slong mag_allocated_bytes(const mag_t x) + slong mag_allocated_bytes(const mag_t x) noexcept # Returns the total number of bytes heap-allocated internally by this object. # The count excludes the size of the structure itself. Add # ``sizeof(mag_struct)`` to get the size of the object as a whole. - void mag_zero(mag_t res) + void mag_zero(mag_t res) noexcept # Sets *res* to zero. - void mag_one(mag_t res) + void mag_one(mag_t res) noexcept # Sets *res* to one. - void mag_inf(mag_t res) + void mag_inf(mag_t res) noexcept # Sets *res* to positive infinity. - bint mag_is_special(const mag_t x) + bint mag_is_special(const mag_t x) noexcept # Returns nonzero iff *x* is zero or positive infinity. - bint mag_is_zero(const mag_t x) + bint mag_is_zero(const mag_t x) noexcept # Returns nonzero iff *x* is zero. - bint mag_is_inf(const mag_t x) + bint mag_is_inf(const mag_t x) noexcept # Returns nonzero iff *x* is positive infinity. - bint mag_is_finite(const mag_t x) + bint mag_is_finite(const mag_t x) noexcept # Returns nonzero iff *x* is not positive infinity (since there is no # NaN value, this function is exactly the logical negation of :func:`mag_is_inf`). - void mag_init_set(mag_t res, const mag_t x) + void mag_init_set(mag_t res, const mag_t x) noexcept # Initializes *res* and sets it to the value of *x*. This operation is always exact. - void mag_set(mag_t res, const mag_t x) + void mag_set(mag_t res, const mag_t x) noexcept # Sets *res* to the value of *x*. This operation is always exact. - void mag_set_d(mag_t res, double x) + void mag_set_d(mag_t res, double x) noexcept - void mag_set_ui(mag_t res, ulong x) + void mag_set_ui(mag_t res, ulong x) noexcept - void mag_set_fmpz(mag_t res, const fmpz_t x) + void mag_set_fmpz(mag_t res, const fmpz_t x) noexcept # Sets *res* to an upper bound for `|x|`. The operation may be inexact # even if *x* is exactly representable. - void mag_set_d_lower(mag_t res, double x) + void mag_set_d_lower(mag_t res, double x) noexcept - void mag_set_ui_lower(mag_t res, ulong x) + void mag_set_ui_lower(mag_t res, ulong x) noexcept - void mag_set_fmpz_lower(mag_t res, const fmpz_t x) + void mag_set_fmpz_lower(mag_t res, const fmpz_t x) noexcept # Sets *res* to a lower bound for `|x|`. # The operation may be inexact even if *x* is exactly representable. - void mag_set_d_2exp_fmpz(mag_t res, double x, const fmpz_t y) + void mag_set_d_2exp_fmpz(mag_t res, double x, const fmpz_t y) noexcept - void mag_set_fmpz_2exp_fmpz(mag_t res, const fmpz_t x, const fmpz_t y) + void mag_set_fmpz_2exp_fmpz(mag_t res, const fmpz_t x, const fmpz_t y) noexcept - void mag_set_ui_2exp_si(mag_t res, ulong x, slong y) + void mag_set_ui_2exp_si(mag_t res, ulong x, slong y) noexcept # Sets *res* to an upper bound for `|x| \cdot 2^y`. - void mag_set_d_2exp_fmpz_lower(mag_t res, double x, const fmpz_t y) + void mag_set_d_2exp_fmpz_lower(mag_t res, double x, const fmpz_t y) noexcept - void mag_set_fmpz_2exp_fmpz_lower(mag_t res, const fmpz_t x, const fmpz_t y) + void mag_set_fmpz_2exp_fmpz_lower(mag_t res, const fmpz_t x, const fmpz_t y) noexcept # Sets *res* to a lower bound for `|x| \cdot 2^y`. - double mag_get_d(const mag_t x) + double mag_get_d(const mag_t x) noexcept # Returns a *double* giving an upper bound for *x*. - double mag_get_d_log2_approx(const mag_t x) + double mag_get_d_log2_approx(const mag_t x) noexcept # Returns a *double* approximating `\log_2(x)`, suitable for estimating # magnitudes (warning: not a rigorous bound). # The value is clamped between *COEFF_MIN* and *COEFF_MAX*. - void mag_get_fmpq(fmpq_t res, const mag_t x) + void mag_get_fmpq(fmpq_t res, const mag_t x) noexcept - void mag_get_fmpz(fmpz_t res, const mag_t x) + void mag_get_fmpz(fmpz_t res, const mag_t x) noexcept - void mag_get_fmpz_lower(fmpz_t res, const mag_t x) + void mag_get_fmpz_lower(fmpz_t res, const mag_t x) noexcept # Sets *res*, respectively, to the exact rational number represented by *x*, # the integer exactly representing the ceiling function of *x*, or the # integer exactly representing the floor function of *x*. @@ -109,243 +109,243 @@ cdef extern from "flint_wrap.h": # abort will be raised. If the exponent otherwise is too large or too small, # the available memory could be exhausted resulting in undefined behavior. - bint mag_equal(const mag_t x, const mag_t y) + bint mag_equal(const mag_t x, const mag_t y) noexcept # Returns nonzero iff *x* and *y* have the same value. - int mag_cmp(const mag_t x, const mag_t y) + int mag_cmp(const mag_t x, const mag_t y) noexcept # Returns negative, zero, or positive, depending on whether *x* # is smaller, equal, or larger than *y*. - int mag_cmp_2exp_si(const mag_t x, slong y) + int mag_cmp_2exp_si(const mag_t x, slong y) noexcept # Returns negative, zero, or positive, depending on whether *x* # is smaller, equal, or larger than `2^y`. - void mag_min(mag_t res, const mag_t x, const mag_t y) + void mag_min(mag_t res, const mag_t x, const mag_t y) noexcept - void mag_max(mag_t res, const mag_t x, const mag_t y) + void mag_max(mag_t res, const mag_t x, const mag_t y) noexcept # Sets *res* respectively to the smaller or the larger of *x* and *y*. - void mag_print(const mag_t x) + void mag_print(const mag_t x) noexcept # Prints *x* to standard output. - void mag_fprint(FILE * file, const mag_t x) + void mag_fprint(FILE * file, const mag_t x) noexcept # Prints *x* to the stream *file*. - char * mag_dump_str(const mag_t x) + char * mag_dump_str(const mag_t x) noexcept # Allocates a string and writes a binary representation of *x* to it that can # be read by :func:`mag_load_str`. The returned string needs to be # deallocated with *flint_free*. - int mag_load_str(mag_t x, const char * str) + int mag_load_str(mag_t x, const char * str) noexcept # Parses *str* into *x*. Returns a nonzero value if *str* is not formatted # correctly. - int mag_dump_file(FILE * stream, const mag_t x) + int mag_dump_file(FILE * stream, const mag_t x) noexcept # Writes a binary representation of *x* to *stream* that can be read by # :func:`mag_load_file`. Returns a nonzero value if the data could not be # written. - int mag_load_file(mag_t x, FILE * stream) + int mag_load_file(mag_t x, FILE * stream) noexcept # Reads *x* from *stream*. Returns a nonzero value if the data is not # formatted correctly or the read failed. Note that the data is assumed to be # delimited by a whitespace or end-of-file, i.e., when writing multiple # values with :func:`mag_dump_file` make sure to insert a whitespace to # separate consecutive values. - void mag_randtest(mag_t res, flint_rand_t state, slong expbits) + void mag_randtest(mag_t res, flint_rand_t state, slong expbits) noexcept # Sets *res* to a random finite value, with an exponent up to *expbits* bits large. - void mag_randtest_special(mag_t res, flint_rand_t state, slong expbits) + void mag_randtest_special(mag_t res, flint_rand_t state, slong expbits) noexcept # Like :func:`mag_randtest`, but also sometimes sets *res* to infinity. - void mag_add(mag_t res, const mag_t x, const mag_t y) + void mag_add(mag_t res, const mag_t x, const mag_t y) noexcept - void mag_add_ui(mag_t res, const mag_t x, ulong y) + void mag_add_ui(mag_t res, const mag_t x, ulong y) noexcept # Sets *res* to an upper bound for `x + y`. - void mag_add_lower(mag_t res, const mag_t x, const mag_t y) + void mag_add_lower(mag_t res, const mag_t x, const mag_t y) noexcept - void mag_add_ui_lower(mag_t res, const mag_t x, ulong y) + void mag_add_ui_lower(mag_t res, const mag_t x, ulong y) noexcept # Sets *res* to a lower bound for `x + y`. - void mag_add_2exp_fmpz(mag_t res, const mag_t x, const fmpz_t e) + void mag_add_2exp_fmpz(mag_t res, const mag_t x, const fmpz_t e) noexcept # Sets *res* to an upper bound for `x + 2^e`. - void mag_add_ui_2exp_si(mag_t res, const mag_t x, ulong y, slong e) + void mag_add_ui_2exp_si(mag_t res, const mag_t x, ulong y, slong e) noexcept # Sets *res* to an upper bound for `x + y 2^e`. - void mag_sub(mag_t res, const mag_t x, const mag_t y) + void mag_sub(mag_t res, const mag_t x, const mag_t y) noexcept # Sets *res* to an upper bound for `\max(x-y, 0)`. - void mag_sub_lower(mag_t res, const mag_t x, const mag_t y) + void mag_sub_lower(mag_t res, const mag_t x, const mag_t y) noexcept # Sets *res* to a lower bound for `\max(x-y, 0)`. - void mag_mul_2exp_si(mag_t res, const mag_t x, slong y) + void mag_mul_2exp_si(mag_t res, const mag_t x, slong y) noexcept - void mag_mul_2exp_fmpz(mag_t res, const mag_t x, const fmpz_t y) + void mag_mul_2exp_fmpz(mag_t res, const mag_t x, const fmpz_t y) noexcept # Sets *res* to `x \cdot 2^y`. This operation is exact. - void mag_mul(mag_t res, const mag_t x, const mag_t y) + void mag_mul(mag_t res, const mag_t x, const mag_t y) noexcept - void mag_mul_ui(mag_t res, const mag_t x, ulong y) + void mag_mul_ui(mag_t res, const mag_t x, ulong y) noexcept - void mag_mul_fmpz(mag_t res, const mag_t x, const fmpz_t y) + void mag_mul_fmpz(mag_t res, const mag_t x, const fmpz_t y) noexcept # Sets *res* to an upper bound for `xy`. - void mag_mul_lower(mag_t res, const mag_t x, const mag_t y) + void mag_mul_lower(mag_t res, const mag_t x, const mag_t y) noexcept - void mag_mul_ui_lower(mag_t res, const mag_t x, ulong y) + void mag_mul_ui_lower(mag_t res, const mag_t x, ulong y) noexcept - void mag_mul_fmpz_lower(mag_t res, const mag_t x, const fmpz_t y) + void mag_mul_fmpz_lower(mag_t res, const mag_t x, const fmpz_t y) noexcept # Sets *res* to a lower bound for `xy`. - void mag_addmul(mag_t z, const mag_t x, const mag_t y) + void mag_addmul(mag_t z, const mag_t x, const mag_t y) noexcept # Sets *z* to an upper bound for `z + xy`. - void mag_div(mag_t res, const mag_t x, const mag_t y) + void mag_div(mag_t res, const mag_t x, const mag_t y) noexcept - void mag_div_ui(mag_t res, const mag_t x, ulong y) + void mag_div_ui(mag_t res, const mag_t x, ulong y) noexcept - void mag_div_fmpz(mag_t res, const mag_t x, const fmpz_t y) + void mag_div_fmpz(mag_t res, const mag_t x, const fmpz_t y) noexcept # Sets *res* to an upper bound for `x / y`. - void mag_div_lower(mag_t res, const mag_t x, const mag_t y) + void mag_div_lower(mag_t res, const mag_t x, const mag_t y) noexcept # Sets *res* to a lower bound for `x / y`. - void mag_inv(mag_t res, const mag_t x) + void mag_inv(mag_t res, const mag_t x) noexcept # Sets *res* to an upper bound for `1 / x`. - void mag_inv_lower(mag_t res, const mag_t x) + void mag_inv_lower(mag_t res, const mag_t x) noexcept # Sets *res* to a lower bound for `1 / x`. - void mag_fast_init_set(mag_t x, const mag_t y) + void mag_fast_init_set(mag_t x, const mag_t y) noexcept # Initialises *x* and sets it to the value of *y*. - void mag_fast_zero(mag_t res) + void mag_fast_zero(mag_t res) noexcept # Sets *res* to zero. - bint mag_fast_is_zero(const mag_t x) + bint mag_fast_is_zero(const mag_t x) noexcept # Returns nonzero iff *x* to zero. - void mag_fast_mul(mag_t res, const mag_t x, const mag_t y) + void mag_fast_mul(mag_t res, const mag_t x, const mag_t y) noexcept # Sets *res* to an upper bound for `xy`. - void mag_fast_addmul(mag_t z, const mag_t x, const mag_t y) + void mag_fast_addmul(mag_t z, const mag_t x, const mag_t y) noexcept # Sets *z* to an upper bound for `z + xy`. - void mag_fast_add_2exp_si(mag_t res, const mag_t x, slong e) + void mag_fast_add_2exp_si(mag_t res, const mag_t x, slong e) noexcept # Sets *res* to an upper bound for `x + 2^e`. - void mag_fast_mul_2exp_si(mag_t res, const mag_t x, slong e) + void mag_fast_mul_2exp_si(mag_t res, const mag_t x, slong e) noexcept # Sets *res* to an upper bound for `x 2^e`. - void mag_pow_ui(mag_t res, const mag_t x, ulong e) + void mag_pow_ui(mag_t res, const mag_t x, ulong e) noexcept - void mag_pow_fmpz(mag_t res, const mag_t x, const fmpz_t e) + void mag_pow_fmpz(mag_t res, const mag_t x, const fmpz_t e) noexcept # Sets *res* to an upper bound for `x^e`. - void mag_pow_ui_lower(mag_t res, const mag_t x, ulong e) + void mag_pow_ui_lower(mag_t res, const mag_t x, ulong e) noexcept - void mag_pow_fmpz_lower(mag_t res, const mag_t x, const fmpz_t e) + void mag_pow_fmpz_lower(mag_t res, const mag_t x, const fmpz_t e) noexcept # Sets *res* to a lower bound for `x^e`. - void mag_sqrt(mag_t res, const mag_t x) + void mag_sqrt(mag_t res, const mag_t x) noexcept # Sets *res* to an upper bound for `\sqrt{x}`. - void mag_sqrt_lower(mag_t res, const mag_t x) + void mag_sqrt_lower(mag_t res, const mag_t x) noexcept # Sets *res* to a lower bound for `\sqrt{x}`. - void mag_rsqrt(mag_t res, const mag_t x) + void mag_rsqrt(mag_t res, const mag_t x) noexcept # Sets *res* to an upper bound for `1/\sqrt{x}`. - void mag_rsqrt_lower(mag_t res, const mag_t x) + void mag_rsqrt_lower(mag_t res, const mag_t x) noexcept # Sets *res* to an lower bound for `1/\sqrt{x}`. - void mag_hypot(mag_t res, const mag_t x, const mag_t y) + void mag_hypot(mag_t res, const mag_t x, const mag_t y) noexcept # Sets *res* to an upper bound for `\sqrt{x^2 + y^2}`. - void mag_root(mag_t res, const mag_t x, ulong n) + void mag_root(mag_t res, const mag_t x, ulong n) noexcept # Sets *res* to an upper bound for `x^{1/n}`. - void mag_log(mag_t res, const mag_t x) + void mag_log(mag_t res, const mag_t x) noexcept # Sets *res* to an upper bound for `\log(\max(1,x))`. - void mag_log_lower(mag_t res, const mag_t x) + void mag_log_lower(mag_t res, const mag_t x) noexcept # Sets *res* to a lower bound for `\log(\max(1,x))`. - void mag_neg_log(mag_t res, const mag_t x) + void mag_neg_log(mag_t res, const mag_t x) noexcept # Sets *res* to an upper bound for `-\log(\min(1,x))`, i.e. an upper # bound for `|\log(x)|` for `x \le 1`. - void mag_neg_log_lower(mag_t res, const mag_t x) + void mag_neg_log_lower(mag_t res, const mag_t x) noexcept # Sets *res* to a lower bound for `-\log(\min(1,x))`, i.e. a lower # bound for `|\log(x)|` for `x \le 1`. - void mag_log_ui(mag_t res, ulong n) + void mag_log_ui(mag_t res, ulong n) noexcept # Sets *res* to an upper bound for `\log(n)`. - void mag_log1p(mag_t res, const mag_t x) + void mag_log1p(mag_t res, const mag_t x) noexcept # Sets *res* to an upper bound for `\log(1+x)`. The bound is computed # accurately for small *x*. - void mag_exp(mag_t res, const mag_t x) + void mag_exp(mag_t res, const mag_t x) noexcept # Sets *res* to an upper bound for `\exp(x)`. - void mag_exp_lower(mag_t res, const mag_t x) + void mag_exp_lower(mag_t res, const mag_t x) noexcept # Sets *res* to a lower bound for `\exp(x)`. - void mag_expinv(mag_t res, const mag_t x) + void mag_expinv(mag_t res, const mag_t x) noexcept # Sets *res* to an upper bound for `\exp(-x)`. - void mag_expinv_lower(mag_t res, const mag_t x) + void mag_expinv_lower(mag_t res, const mag_t x) noexcept # Sets *res* to a lower bound for `\exp(-x)`. - void mag_expm1(mag_t res, const mag_t x) + void mag_expm1(mag_t res, const mag_t x) noexcept # Sets *res* to an upper bound for `\exp(x) - 1`. The bound is computed # accurately for small *x*. - void mag_exp_tail(mag_t res, const mag_t x, ulong N) + void mag_exp_tail(mag_t res, const mag_t x, ulong N) noexcept # Sets *res* to an upper bound for `\sum_{k=N}^{\infty} x^k / k!`. - void mag_binpow_uiui(mag_t res, ulong m, ulong n) + void mag_binpow_uiui(mag_t res, ulong m, ulong n) noexcept # Sets *res* to an upper bound for `(1 + 1/m)^n`. - void mag_geom_series(mag_t res, const mag_t x, ulong N) + void mag_geom_series(mag_t res, const mag_t x, ulong N) noexcept # Sets *res* to an upper bound for `\sum_{k=N}^{\infty} x^k`. - void mag_const_pi(mag_t res) + void mag_const_pi(mag_t res) noexcept - void mag_const_pi_lower(mag_t res) + void mag_const_pi_lower(mag_t res) noexcept # Sets *res* to an upper (respectively lower) bound for `\pi`. - void mag_atan(mag_t res, const mag_t x) + void mag_atan(mag_t res, const mag_t x) noexcept - void mag_atan_lower(mag_t res, const mag_t x) + void mag_atan_lower(mag_t res, const mag_t x) noexcept # Sets *res* to an upper (respectively lower) bound for `\operatorname{atan}(x)`. - void mag_cosh(mag_t res, const mag_t x) + void mag_cosh(mag_t res, const mag_t x) noexcept - void mag_cosh_lower(mag_t res, const mag_t x) + void mag_cosh_lower(mag_t res, const mag_t x) noexcept - void mag_sinh(mag_t res, const mag_t x) + void mag_sinh(mag_t res, const mag_t x) noexcept - void mag_sinh_lower(mag_t res, const mag_t x) + void mag_sinh_lower(mag_t res, const mag_t x) noexcept # Sets *res* to an upper or lower bound for `\cosh(x)` or `\sinh(x)`. - void mag_fac_ui(mag_t res, ulong n) + void mag_fac_ui(mag_t res, ulong n) noexcept # Sets *res* to an upper bound for `n!`. - void mag_rfac_ui(mag_t res, ulong n) + void mag_rfac_ui(mag_t res, ulong n) noexcept # Sets *res* to an upper bound for `1/n!`. - void mag_bin_uiui(mag_t res, ulong n, ulong k) + void mag_bin_uiui(mag_t res, ulong n, ulong k) noexcept # Sets *res* to an upper bound for the binomial coefficient `{n choose k}`. - void mag_bernoulli_div_fac_ui(mag_t res, ulong n) + void mag_bernoulli_div_fac_ui(mag_t res, ulong n) noexcept # Sets *res* to an upper bound for `|B_n| / n!` where `B_n` denotes # a Bernoulli number. - void mag_polylog_tail(mag_t res, const mag_t z, slong s, ulong d, ulong N) + void mag_polylog_tail(mag_t res, const mag_t z, slong s, ulong d, ulong N) noexcept # Sets *res* to an upper bound for # .. math :: # \sum_{k=N}^{\infty} \frac{z^k \log^d(k)}{k^s}. @@ -354,7 +354,7 @@ cdef extern from "flint_wrap.h": # real or complex, the user can simply # substitute any convenient integer `s'` such that `s' \le \operatorname{Re}(s)`. - void mag_hurwitz_zeta_uiui(mag_t res, ulong s, ulong a) + void mag_hurwitz_zeta_uiui(mag_t res, ulong s, ulong a) noexcept # Sets *res* to an upper bound for `\zeta(s,a) = \sum_{k=0}^{\infty} (k+a)^{-s}`. # We use the formula # .. math :: diff --git a/src/sage/libs/flint/mpf_mat.pxd b/src/sage/libs/flint/mpf_mat.pxd index 529cb9996c9..27013710381 100644 --- a/src/sage/libs/flint/mpf_mat.pxd +++ b/src/sage/libs/flint/mpf_mat.pxd @@ -12,79 +12,79 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void mpf_mat_init(mpf_mat_t mat, slong rows, slong cols, flint_bitcnt_t prec) + void mpf_mat_init(mpf_mat_t mat, slong rows, slong cols, flint_bitcnt_t prec) noexcept # Initialises a matrix with the given number of rows and columns and the # given precision for use. The precision is at least the precision of the # entries. - void mpf_mat_clear(mpf_mat_t mat) + void mpf_mat_clear(mpf_mat_t mat) noexcept # Clears the given matrix. - void mpf_mat_set(mpf_mat_t mat1, const mpf_mat_t mat2) + void mpf_mat_set(mpf_mat_t mat1, const mpf_mat_t mat2) noexcept # Sets ``mat1`` to a copy of ``mat2``. The dimensions of # ``mat1`` and ``mat2`` must be the same. - void mpf_mat_swap(mpf_mat_t mat1, mpf_mat_t mat2) + void mpf_mat_swap(mpf_mat_t mat1, mpf_mat_t mat2) noexcept # Swaps two matrices. The dimensions of ``mat1`` and ``mat2`` # are allowed to be different. - void mpf_mat_swap_entrywise(mpf_mat_t mat1, mpf_mat_t mat2) + void mpf_mat_swap_entrywise(mpf_mat_t mat1, mpf_mat_t mat2) noexcept # Swaps two matrices by swapping the individual entries rather than swapping # the contents of the structs. - mpf * mpf_mat_entry(const mpf_mat_t mat, slong i, slong j) + mpf * mpf_mat_entry(const mpf_mat_t mat, slong i, slong j) noexcept # Returns a reference to the entry of ``mat`` at row `i` and column `j`. # Both `i` and `j` must not exceed the dimensions of the matrix. # The return value can be used to either retrieve or set the given entry. - void mpf_mat_zero(mpf_mat_t mat) + void mpf_mat_zero(mpf_mat_t mat) noexcept # Sets all entries of ``mat`` to 0. - void mpf_mat_one(mpf_mat_t mat) + void mpf_mat_one(mpf_mat_t mat) noexcept # Sets ``mat`` to the unit matrix, having ones on the main diagonal # and zeroes elsewhere. If ``mat`` is nonsquare, it is set to the # truncation of a unit matrix. - void mpf_mat_set_fmpz_mat(mpf_mat_t B, const fmpz_mat_t A) + void mpf_mat_set_fmpz_mat(mpf_mat_t B, const fmpz_mat_t A) noexcept # Sets the entries of ``B`` as mpfs corresponding to the entries of # ``A``. - void mpf_mat_randtest(mpf_mat_t mat, flint_rand_t state, flint_bitcnt_t bits) + void mpf_mat_randtest(mpf_mat_t mat, flint_rand_t state, flint_bitcnt_t bits) noexcept # Sets the entries of ``mat`` to random numbers in the # interval `[0, 1)` with ``bits`` significant bits in the mantissa or less if # their precision is smaller. - void mpf_mat_print(const mpf_mat_t mat) + void mpf_mat_print(const mpf_mat_t mat) noexcept # Prints the given matrix to the stream ``stdout``. - bint mpf_mat_equal(const mpf_mat_t mat1, const mpf_mat_t mat2) + bint mpf_mat_equal(const mpf_mat_t mat1, const mpf_mat_t mat2) noexcept # Returns a non-zero value if ``mat1`` and ``mat2`` have # the same dimensions and entries, and zero otherwise. - bint mpf_mat_approx_equal(const mpf_mat_t mat1, const mpf_mat_t mat2, flint_bitcnt_t bits) + bint mpf_mat_approx_equal(const mpf_mat_t mat1, const mpf_mat_t mat2, flint_bitcnt_t bits) noexcept # Returns a non-zero value if ``mat1`` and ``mat2`` have # the same dimensions and the first ``bits`` bits of their entries # are equal, and zero otherwise. - bint mpf_mat_is_zero(const mpf_mat_t mat) + bint mpf_mat_is_zero(const mpf_mat_t mat) noexcept # Returns a non-zero value if all entries ``mat`` are zero, and # otherwise returns zero. - bint mpf_mat_is_empty(const mpf_mat_t mat) + bint mpf_mat_is_empty(const mpf_mat_t mat) noexcept # Returns a non-zero value if the number of rows or the number of # columns in ``mat`` is zero, and otherwise returns # zero. - bint mpf_mat_is_square(const mpf_mat_t mat) + bint mpf_mat_is_square(const mpf_mat_t mat) noexcept # Returns a non-zero value if the number of rows is equal to the # number of columns in ``mat``, and otherwise returns zero. - void mpf_mat_mul(mpf_mat_t C, const mpf_mat_t A, const mpf_mat_t B) + void mpf_mat_mul(mpf_mat_t C, const mpf_mat_t A, const mpf_mat_t B) noexcept # Sets ``C`` to the matrix product `C = A B`. The matrices must have # compatible dimensions for matrix multiplication (an exception is raised # otherwise). Aliasing is allowed. - void mpf_mat_gso(mpf_mat_t B, const mpf_mat_t A) + void mpf_mat_gso(mpf_mat_t B, const mpf_mat_t A) noexcept # Takes a subset of `R^m` `S = {a_1, a_2, \ldots ,a_n}` (as the columns of # a `m \times n` matrix ``A``) and generates an orthonormal set # `S' = {b_1, b_2, \ldots ,b_n}` (as the columns of the `m \times n` matrix @@ -92,7 +92,7 @@ cdef extern from "flint_wrap.h": # This uses an algorithm of Schwarz-Rutishauser. See pp. 9 of # https://people.inf.ethz.ch/gander/papers/qrneu.pdf - void mpf_mat_qr(mpf_mat_t Q, mpf_mat_t R, const mpf_mat_t A) + void mpf_mat_qr(mpf_mat_t Q, mpf_mat_t R, const mpf_mat_t A) noexcept # Computes the `QR` decomposition of a matrix ``A`` using the Gram-Schmidt # process. (Sets ``Q`` and ``R`` such that `A = QR` where ``R`` is # an upper triangular matrix and ``Q`` is an orthogonal matrix.) diff --git a/src/sage/libs/flint/mpf_vec.pxd b/src/sage/libs/flint/mpf_vec.pxd index 05005c8b2b6..782de46c450 100644 --- a/src/sage/libs/flint/mpf_vec.pxd +++ b/src/sage/libs/flint/mpf_vec.pxd @@ -12,69 +12,69 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - mpf * _mpf_vec_init(slong len, mp_limb_t prec) + mpf * _mpf_vec_init(slong len, mp_limb_t prec) noexcept # Returns a vector of the given length of initialised ``mpf``'s # with at least the given precision. - void _mpf_vec_clear(mpf * vec, slong len) + void _mpf_vec_clear(mpf * vec, slong len) noexcept # Clears the given vector. - void _mpf_vec_randtest(mpf * f, flint_rand_t state, slong len, flint_bitcnt_t bits) + void _mpf_vec_randtest(mpf * f, flint_rand_t state, slong len, flint_bitcnt_t bits) noexcept # Sets the entries of a vector of the given length to random numbers in the # interval `[0, 1)` with ``bits`` significant bits in the mantissa or less if # their precision is smaller. - void _mpf_vec_zero(mpf * vec, slong len) + void _mpf_vec_zero(mpf * vec, slong len) noexcept # Zeros the vector ``(vec, len)``. - void _mpf_vec_set(mpf * vec1, const mpf * vec2, slong len2) + void _mpf_vec_set(mpf * vec1, const mpf * vec2, slong len2) noexcept # Copies the vector ``vec2`` of the given length into ``vec1``. # A check is made to ensure ``vec1`` and ``vec2`` are different. - void _mpf_vec_set_fmpz_vec(mpf * appv, const fmpz * vec, slong len) + void _mpf_vec_set_fmpz_vec(mpf * appv, const fmpz * vec, slong len) noexcept # Export the array of ``len`` entries starting at the pointer ``vec`` # to an array of mpfs ``appv``. - bint _mpf_vec_equal(const mpf * vec1, const mpf * vec2, slong len) + bint _mpf_vec_equal(const mpf * vec1, const mpf * vec2, slong len) noexcept # Compares two vectors of the given length and returns `1` if they are # equal, otherwise returns `0`. - bint _mpf_vec_is_zero(const mpf * vec, slong len) + bint _mpf_vec_is_zero(const mpf * vec, slong len) noexcept # Returns `1` if ``(vec, len)`` is zero, and `0` otherwise. - bint _mpf_vec_approx_equal(const mpf * vec1, const mpf * vec2, slong len, flint_bitcnt_t bits) + bint _mpf_vec_approx_equal(const mpf * vec1, const mpf * vec2, slong len, flint_bitcnt_t bits) noexcept # Compares two vectors of the given length and returns `1` if the first # ``bits`` bits of their entries are equal, otherwise returns `0`. - void _mpf_vec_add(mpf * res, const mpf * vec1, const mpf * vec2, slong len2) + void _mpf_vec_add(mpf * res, const mpf * vec1, const mpf * vec2, slong len2) noexcept # Adds the given vectors of the given length together and stores the # result in ``res``. - void _mpf_vec_sub(mpf * res, const mpf * vec1, const mpf * vec2, slong len2) + void _mpf_vec_sub(mpf * res, const mpf * vec1, const mpf * vec2, slong len2) noexcept # Sets ``(res, len2)`` to ``(vec1, len2)`` minus ``(vec2, len2)``. - void _mpf_vec_scalar_mul_mpf(mpf * res, const mpf * vec, slong len, mpf_t c) + void _mpf_vec_scalar_mul_mpf(mpf * res, const mpf * vec, slong len, mpf_t c) noexcept # Multiplies the vector with given length by the scalar `c` and # sets ``res`` to the result. - void _mpf_vec_scalar_mul_2exp(mpf * res, const mpf * vec, slong len, flint_bitcnt_t exp) + void _mpf_vec_scalar_mul_2exp(mpf * res, const mpf * vec, slong len, flint_bitcnt_t exp) noexcept # Multiplies the given vector of the given length by ``2^exp``. - void _mpf_vec_dot(mpf_t res, const mpf * vec1, const mpf * vec2, slong len2) + void _mpf_vec_dot(mpf_t res, const mpf * vec1, const mpf * vec2, slong len2) noexcept # Sets ``res`` to the dot product of ``(vec1, len2)`` with # ``(vec2, len2)``. - void _mpf_vec_norm(mpf_t res, const mpf * vec, slong len) + void _mpf_vec_norm(mpf_t res, const mpf * vec, slong len) noexcept # Sets ``res`` to the square of the Euclidean norm of # ``(vec, len)``. - int _mpf_vec_dot2(mpf_t res, const mpf * vec1, const mpf * vec2, slong len2, flint_bitcnt_t prec) + int _mpf_vec_dot2(mpf_t res, const mpf * vec1, const mpf * vec2, slong len2, flint_bitcnt_t prec) noexcept # Sets ``res`` to the dot product of ``(vec1, len2)`` with # ``(vec2, len2)``. The temporary variable used has its precision # set to be at least ``prec`` bits. Returns 0 if a probable # cancellation is detected, and otherwise returns a non-zero value. - void _mpf_vec_norm2(mpf_t res, const mpf * vec, slong len, flint_bitcnt_t prec) + void _mpf_vec_norm2(mpf_t res, const mpf * vec, slong len, flint_bitcnt_t prec) noexcept # Sets ``res`` to the square of the Euclidean norm of # ``(vec, len)``. The temporary variable used has its precision # set to be at least ``prec`` bits. diff --git a/src/sage/libs/flint/mpfr_mat.pxd b/src/sage/libs/flint/mpfr_mat.pxd index 7a821764a55..170a3be851e 100644 --- a/src/sage/libs/flint/mpfr_mat.pxd +++ b/src/sage/libs/flint/mpfr_mat.pxd @@ -12,39 +12,39 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void mpfr_mat_init(mpfr_mat_t mat, slong rows, slong cols, mpfr_prec_t prec) + void mpfr_mat_init(mpfr_mat_t mat, slong rows, slong cols, mpfr_prec_t prec) noexcept # Initialises a matrix with the given number of rows and columns and the # given precision for use. The precision is the exact precision of the # entries. - void mpfr_mat_clear(mpfr_mat_t mat) + void mpfr_mat_clear(mpfr_mat_t mat) noexcept # Clears the given matrix. - __mpfr_struct * mpfr_mat_entry(const mpfr_mat_t mat, slong i, slong j) + __mpfr_struct * mpfr_mat_entry(const mpfr_mat_t mat, slong i, slong j) noexcept # Return a reference to the entry at row `i` and column `j` of the given # matrix. The values `i` and `j` must be within the bounds for the matrix. # The reference can be used to either return or set the given entry. - void mpfr_mat_swap(mpfr_mat_t mat1, mpfr_mat_t mat2) + void mpfr_mat_swap(mpfr_mat_t mat1, mpfr_mat_t mat2) noexcept # Efficiently swap matrices ``mat1`` and ``mat2``. - void mpfr_mat_swap_entrywise(mpfr_mat_t mat1, mpfr_mat_t mat2) + void mpfr_mat_swap_entrywise(mpfr_mat_t mat1, mpfr_mat_t mat2) noexcept # Swaps two matrices by swapping the individual entries rather than swapping # the contents of the structs. - void mpfr_mat_set(mpfr_mat_t mat1, const mpfr_mat_t mat2) + void mpfr_mat_set(mpfr_mat_t mat1, const mpfr_mat_t mat2) noexcept # Set ``mat1`` to the value of ``mat2``. - void mpfr_mat_zero(mpfr_mat_t mat) + void mpfr_mat_zero(mpfr_mat_t mat) noexcept # Set ``mat`` to the zero matrix. - bint mpfr_mat_equal(const mpfr_mat_t mat1, const mpfr_mat_t mat2) + bint mpfr_mat_equal(const mpfr_mat_t mat1, const mpfr_mat_t mat2) noexcept # Return `1` if the two given matrices are equal, otherwise return `0`. - void mpfr_mat_randtest(mpfr_mat_t mat, flint_rand_t state) + void mpfr_mat_randtest(mpfr_mat_t mat, flint_rand_t state) noexcept # Generate a random matrix with random number of rows and columns and random # entries for use in test code. - void mpfr_mat_mul_classical(mpfr_mat_t C, const mpfr_mat_t A, const mpfr_mat_t B, mpfr_rnd_t rnd) + void mpfr_mat_mul_classical(mpfr_mat_t C, const mpfr_mat_t A, const mpfr_mat_t B, mpfr_rnd_t rnd) noexcept # Set `C` to the product of `A` and `B` with the given rounding mode, using # the classical algorithm. diff --git a/src/sage/libs/flint/mpfr_vec.pxd b/src/sage/libs/flint/mpfr_vec.pxd index bd6811b547f..cc6e8f2499a 100644 --- a/src/sage/libs/flint/mpfr_vec.pxd +++ b/src/sage/libs/flint/mpfr_vec.pxd @@ -12,29 +12,29 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - mpfr_ptr _mpfr_vec_init(slong len, flint_bitcnt_t prec) + mpfr_ptr _mpfr_vec_init(slong len, flint_bitcnt_t prec) noexcept # Returns a vector of the given length of initialised ``mpfr``'s # with the given exact precision. - void _mpfr_vec_clear(mpfr_ptr vec, slong len) + void _mpfr_vec_clear(mpfr_ptr vec, slong len) noexcept # Clears the given vector. - void _mpfr_vec_zero(mpfr_ptr vec, slong len) + void _mpfr_vec_zero(mpfr_ptr vec, slong len) noexcept # Zeros the vector ``(vec, len)``. - void _mpfr_vec_set(mpfr_ptr vec1, mpfr_srcptr vec2, slong len) + void _mpfr_vec_set(mpfr_ptr vec1, mpfr_srcptr vec2, slong len) noexcept # Copies the vector ``vec2`` of the given length into ``vec1``. # No check is made to ensure ``vec1`` and ``vec2`` are different. - void _mpfr_vec_add(mpfr_ptr res, mpfr_srcptr vec1, mpfr_srcptr vec2, slong len) + void _mpfr_vec_add(mpfr_ptr res, mpfr_srcptr vec1, mpfr_srcptr vec2, slong len) noexcept # Adds the given vectors of the given length together and stores the # result in ``res``. - void _mpfr_vec_scalar_mul_mpfr(mpfr_ptr res, mpfr_srcptr vec, slong len, mpfr_t c) + void _mpfr_vec_scalar_mul_mpfr(mpfr_ptr res, mpfr_srcptr vec, slong len, mpfr_t c) noexcept # Multiplies the vector with given length by the scalar `c` and # sets ``res`` to the result. - void _mpfr_vec_scalar_mul_2exp(mpfr_ptr res, mpfr_srcptr vec, slong len, flint_bitcnt_t exp) + void _mpfr_vec_scalar_mul_2exp(mpfr_ptr res, mpfr_srcptr vec, slong len, flint_bitcnt_t exp) noexcept # Multiplies the given vector of the given length by ``2^exp``. - void _mpfr_vec_scalar_product(mpfr_t res, mpfr_srcptr vec1, mpfr_srcptr vec2, slong len) + void _mpfr_vec_scalar_product(mpfr_t res, mpfr_srcptr vec1, mpfr_srcptr vec2, slong len) noexcept diff --git a/src/sage/libs/flint/mpn_extras.pxd b/src/sage/libs/flint/mpn_extras.pxd index 5f5b3bbf99d..3cf2facfb78 100644 --- a/src/sage/libs/flint/mpn_extras.pxd +++ b/src/sage/libs/flint/mpn_extras.pxd @@ -12,14 +12,14 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void flint_mpn_debug(mp_srcptr x, mp_size_t xsize) + void flint_mpn_debug(mp_srcptr x, mp_size_t xsize) noexcept # Prints debug information about ``(x, xsize)`` to ``stdout``. # In particular, this will print binary representations of all the limbs. - int flint_mpn_zero_p(mp_srcptr x, mp_size_t xsize) + int flint_mpn_zero_p(mp_srcptr x, mp_size_t xsize) noexcept # Returns `1` if all limbs of ``(x, xsize)`` are zero, otherwise `0`. - mp_limb_t flint_mpn_mul(mp_ptr z, mp_srcptr x, mp_size_t xn, mp_srcptr y, mp_size_t yn) + mp_limb_t flint_mpn_mul(mp_ptr z, mp_srcptr x, mp_size_t xn, mp_srcptr y, mp_size_t yn) noexcept # Sets ``(z, xn+yn)`` to the product of ``(x, xn)`` and ``(y, yn)`` # and returns the top limb of the result. # We require `xn \ge yn \ge 1` @@ -27,39 +27,39 @@ cdef extern from "flint_wrap.h": # This function uses FFT multiplication if the operands are large enough # and otherwise calls ``mpn_mul``. - void flint_mpn_mul_n(mp_ptr z, mp_srcptr x, mp_srcptr y, mp_size_t n) + void flint_mpn_mul_n(mp_ptr z, mp_srcptr x, mp_srcptr y, mp_size_t n) noexcept # Sets ``z`` to the product of ``(x, n)`` and ``(y, n)``. # We require `n \ge 1` # and that ``z`` is not aliased with either input operand. # This function uses FFT multiplication if the operands are large enough # and otherwise calls ``mpn_mul_n``. - void flint_mpn_sqr(mp_ptr z, mp_srcptr x, mp_size_t n) + void flint_mpn_sqr(mp_ptr z, mp_srcptr x, mp_size_t n) noexcept # Sets ``z`` to the square of ``(x, n)``. # We require `n \ge 1` # and that ``z`` is not aliased with either input operand. # This function uses FFT multiplication if the operands are large enough # and otherwise calls ``mpn_sqr``. - mp_size_t flint_mpn_fmms1(mp_ptr y, mp_limb_t a1, mp_srcptr x1, mp_limb_t a2, mp_srcptr x2, mp_size_t n) + mp_size_t flint_mpn_fmms1(mp_ptr y, mp_limb_t a1, mp_srcptr x1, mp_limb_t a2, mp_srcptr x2, mp_size_t n) noexcept # Given not-necessarily-normalized `x_1` and `x_2` of length `n > 0` and output `y` of length `n`, try to compute `y = a_1\cdot x_1 - a_2\cdot x_2`. # Return the normalized length of `y` if `y \ge 0` and `y` fits into `n` limbs. Otherwise, return `-1`. # `y` may alias `x_1` but is not allowed to alias `x_2`. - int flint_mpn_divisible_1_odd(mp_srcptr x, mp_size_t xsize, mp_limb_t d) + int flint_mpn_divisible_1_odd(mp_srcptr x, mp_size_t xsize, mp_limb_t d) noexcept # Expression determining whether ``(x, xsize)`` is divisible by the # ``mp_limb_t d`` which is assumed to be odd-valued and at least `3`. # This function is implemented as a macro. - mp_size_t flint_mpn_divexact_1(mp_ptr x, mp_size_t xsize, mp_limb_t d) + mp_size_t flint_mpn_divexact_1(mp_ptr x, mp_size_t xsize, mp_limb_t d) noexcept # Divides `x` once by a known single-limb divisor, returns the new size. - mp_size_t flint_mpn_remove_2exp(mp_ptr x, mp_size_t xsize, flint_bitcnt_t *bits) + mp_size_t flint_mpn_remove_2exp(mp_ptr x, mp_size_t xsize, flint_bitcnt_t *bits) noexcept # Divides ``(x, xsize)`` by `2^n` where `n` is the number of trailing # zero bits in `x`. The new size of `x` is returned, and `n` is stored in # the bits argument. `x` may not be zero. - mp_size_t flint_mpn_remove_power_ascending(mp_ptr x, mp_size_t xsize, mp_ptr p, mp_size_t psize, ulong *exp) + mp_size_t flint_mpn_remove_power_ascending(mp_ptr x, mp_size_t xsize, mp_ptr p, mp_size_t psize, ulong *exp) noexcept # Divides ``(x, xsize)`` by the largest power `n` of ``(p, psize)`` # that is an exact divisor of `x`. The new size of `x` is returned, and # `n` is stored in the ``exp`` argument. `x` may not be zero, and `p` @@ -69,13 +69,13 @@ cdef extern from "flint_wrap.h": # large powers. Because of its high overhead, it should not be used as # the first stage of trial division. - int flint_mpn_factor_trial(mp_srcptr x, mp_size_t xsize, slong start, slong stop) + int flint_mpn_factor_trial(mp_srcptr x, mp_size_t xsize, slong start, slong stop) noexcept # Searches for a factor of ``(x, xsize)`` among the primes in positions # ``start, ..., stop-1`` of ``flint_primes``. Returns `i` if # ``flint_primes[i]`` is a factor, otherwise returns `0` if no factor # is found. It is assumed that ``start >= 1``. - int flint_mpn_factor_trial_tree(slong * factors, mp_srcptr x, mp_size_t xsize, slong num_primes) + int flint_mpn_factor_trial_tree(slong * factors, mp_srcptr x, mp_size_t xsize, slong num_primes) noexcept # Searches for a factor of ``(x, xsize)`` among the primes in positions # approximately in the range ``0, ..., num_primes - 1`` of ``flint_primes``. # Returns the number of prime factors found and fills ``factors`` with their @@ -85,19 +85,19 @@ cdef extern from "flint_wrap.h": # The algorithm used is a tree based gcd with a product of primes, the tree # for which is cached globally (it is threadsafe). - int flint_mpn_divides(mp_ptr q, mp_srcptr array1, mp_size_t limbs1, mp_srcptr arrayg, mp_size_t limbsg, mp_ptr temp) + int flint_mpn_divides(mp_ptr q, mp_srcptr array1, mp_size_t limbs1, mp_srcptr arrayg, mp_size_t limbsg, mp_ptr temp) noexcept # If ``(arrayg, limbsg)`` divides ``(array1, limbs1)`` then # ``(q, limbs1 - limbsg + 1)`` is set to the quotient and 1 is # returned, otherwise 0 is returned. The temporary space ``temp`` # must have space for ``limbsg`` limbs. # Assumes ``limbs1 >= limbsg > 0``. - mp_limb_t flint_mpn_preinv1(mp_limb_t d, mp_limb_t d2) + mp_limb_t flint_mpn_preinv1(mp_limb_t d, mp_limb_t d2) noexcept # Computes a precomputed inverse from the leading two limbs of the # divisor ``b, n`` to be used with the ``preinv1`` functions. # We require the most significant bit of ``b, n`` to be 1. - mp_limb_t flint_mpn_divrem_preinv1(mp_ptr q, mp_ptr a, mp_size_t m, mp_srcptr b, mp_size_t n, mp_limb_t dinv) + mp_limb_t flint_mpn_divrem_preinv1(mp_ptr q, mp_ptr a, mp_size_t m, mp_srcptr b, mp_size_t n, mp_limb_t dinv) noexcept # Divide ``a, m`` by ``b, n``, returning the high limb of the # quotient (which will either be 0 or 1), storing the remainder in-place # in ``a, n`` and the rest of the quotient in ``q, m - n``. @@ -105,7 +105,7 @@ cdef extern from "flint_wrap.h": # ``dinv`` must be computed from ``b[n - 1]``, ``b[n - 2]`` by # ``flint_mpn_preinv1``. We also require ``m >= n >= 2``. - void flint_mpn_mulmod_preinv1(mp_ptr r, mp_srcptr a, mp_srcptr b, mp_size_t n, mp_srcptr d, mp_limb_t dinv, ulong norm) + void flint_mpn_mulmod_preinv1(mp_ptr r, mp_srcptr a, mp_srcptr b, mp_size_t n, mp_srcptr d, mp_limb_t dinv, ulong norm) noexcept # Given a normalised integer `d` with precomputed inverse ``dinv`` # provided by ``flint_mpn_preinv1``, computes `ab \pmod{d}` and # stores the result in `r`. Each of `a`, `b` and `r` is expected to @@ -117,13 +117,13 @@ cdef extern from "flint_wrap.h": # We require `a` and `b` to be reduced modulo `n` before calling the # function. - void flint_mpn_preinvn(mp_ptr dinv, mp_srcptr d, mp_size_t n) + void flint_mpn_preinvn(mp_ptr dinv, mp_srcptr d, mp_size_t n) noexcept # Compute an `n` limb precomputed inverse ``dinv`` of the `n` limb # integer `d`. # We require that `d` is normalised, i.e. with the most significant # bit of the most significant limb set. - void flint_mpn_mod_preinvn(mp_ptr r, mp_srcptr a, mp_size_t m, mp_srcptr d, mp_size_t n, mp_srcptr dinv) + void flint_mpn_mod_preinvn(mp_ptr r, mp_srcptr a, mp_size_t m, mp_srcptr d, mp_size_t n, mp_srcptr dinv) noexcept # Given a normalised integer `d` of `n` limbs, with precomputed inverse # ``dinv`` provided by ``flint_mpn_preinvn`` and integer `a` of `m` # limbs, computes `a \pmod{d}` and stores the result in-place in the lower @@ -132,7 +132,7 @@ cdef extern from "flint_wrap.h": # is permitted. # Note that this function is not always as fast as ordinary division. - mp_limb_t flint_mpn_divrem_preinvn(mp_ptr q, mp_ptr r, mp_srcptr a, mp_size_t m, mp_srcptr d, mp_size_t n, mp_srcptr dinv) + mp_limb_t flint_mpn_divrem_preinvn(mp_ptr q, mp_ptr r, mp_srcptr a, mp_size_t m, mp_srcptr d, mp_size_t n, mp_srcptr dinv) noexcept # Given a normalised integer `d` with precomputed inverse ``dinv`` # provided by ``flint_mpn_preinvn``, computes the quotient of `a` by `d` # and stores the result in `q` and the remainder in the lower `n` limbs of @@ -142,7 +142,7 @@ cdef extern from "flint_wrap.h": # and any of the other operands. # Note that this function is not always as fast as ordinary division. - void flint_mpn_mulmod_preinvn(mp_ptr r, mp_srcptr a, mp_srcptr b, mp_size_t n, mp_srcptr d, mp_srcptr dinv, ulong norm) + void flint_mpn_mulmod_preinvn(mp_ptr r, mp_srcptr a, mp_srcptr b, mp_size_t n, mp_srcptr d, mp_srcptr dinv, ulong norm) noexcept # Given a normalised integer `d` with precomputed inverse ``dinv`` # provided by ``flint_mpn_preinvn``, computes `ab \pmod{d}` and # stores the result in `r`. Each of `a`, `b` and `r` is expected to @@ -155,7 +155,7 @@ cdef extern from "flint_wrap.h": # function. # Note that this function is not always as fast as ordinary division. - mp_size_t flint_mpn_gcd_full2(mp_ptr arrayg, mp_srcptr array1, mp_size_t limbs1, mp_srcptr array2, mp_size_t limbs2, mp_ptr temp) + mp_size_t flint_mpn_gcd_full2(mp_ptr arrayg, mp_srcptr array1, mp_size_t limbs1, mp_srcptr array2, mp_size_t limbs2, mp_ptr temp) noexcept # Sets ``(arrayg, retvalue)`` to the gcd of ``(array1, limbs1)`` and # ``(array2, limbs2)``. # The only assumption is that neither ``limbs1`` nor ``limbs2`` is @@ -164,19 +164,19 @@ cdef extern from "flint_wrap.h": # space, or ``NULL`` must be passed to ``temp`` if the function should # allocate its own space. - mp_size_t flint_mpn_gcd_full(mp_ptr arrayg, mp_srcptr array1, mp_size_t limbs1, mp_srcptr array2, mp_size_t limbs2) + mp_size_t flint_mpn_gcd_full(mp_ptr arrayg, mp_srcptr array1, mp_size_t limbs1, mp_srcptr array2, mp_size_t limbs2) noexcept # Sets ``(arrayg, retvalue)`` to the gcd of ``(array1, limbs1)`` and # ``(array2, limbs2)``. # The only assumption is that neither ``limbs1`` nor ``limbs2`` is # zero. - void flint_mpn_rrandom(mp_limb_t *rp, gmp_randstate_t state, mp_size_t n) + void flint_mpn_rrandom(mp_limb_t *rp, gmp_randstate_t state, mp_size_t n) noexcept # Generates a random number with ``n`` limbs and stores # it on ``rp``. The number it generates will tend to have # long strings of zeros and ones in the binary representation. # Useful for testing functions and algorithms, since this kind of random # numbers have proven to be more likely to trigger corner-case bugs. - void flint_mpn_urandomb(mp_limb_t *rp, gmp_randstate_t state, flint_bitcnt_t n) + void flint_mpn_urandomb(mp_limb_t *rp, gmp_randstate_t state, flint_bitcnt_t n) noexcept # Generates a uniform random number of ``n`` bits and stores # it on ``rp``. diff --git a/src/sage/libs/flint/mpoly.pxd b/src/sage/libs/flint/mpoly.pxd index 83905ccef53..9204bbaa0c4 100644 --- a/src/sage/libs/flint/mpoly.pxd +++ b/src/sage/libs/flint/mpoly.pxd @@ -12,132 +12,132 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void mpoly_ctx_init(mpoly_ctx_t ctx, slong nvars, const ordering_t ord) + void mpoly_ctx_init(mpoly_ctx_t ctx, slong nvars, const ordering_t ord) noexcept # Initialize a context for specified number of variables and ordering. - void mpoly_ctx_clear(mpoly_ctx_t mctx) + void mpoly_ctx_clear(mpoly_ctx_t mctx) noexcept # Clean up any space used by a context object. - ordering_t mpoly_ordering_randtest(flint_rand_t state) + ordering_t mpoly_ordering_randtest(flint_rand_t state) noexcept # Return a random ordering. The possibilities are ``ORD_LEX``, # ``ORD_DEGLEX`` and ``ORD_DEGREVLEX``. - void mpoly_ctx_init_rand(mpoly_ctx_t mctx, flint_rand_t state, slong max_nvars) + void mpoly_ctx_init_rand(mpoly_ctx_t mctx, flint_rand_t state, slong max_nvars) noexcept # Initialize a context with a random choice for the ordering. - int mpoly_ordering_isdeg(const mpoly_ctx_t ctx) + int mpoly_ordering_isdeg(const mpoly_ctx_t ctx) noexcept # Return 1 if the ordering of the given context is a degree ordering (deglex or degrevlex). - int mpoly_ordering_isrev(const mpoly_ctx_t cth) + int mpoly_ordering_isrev(const mpoly_ctx_t cth) noexcept # Return 1 if the ordering of the given context is a reverse ordering (currently only # degrevlex). - void mpoly_ordering_print(ordering_t ord) + void mpoly_ordering_print(ordering_t ord) noexcept # Print a string (either "lex", "deglex" or "degrevlex") to standard # output, corresponding to the given ordering. - void mpoly_monomial_add(ulong * exp_ptr, const ulong * exp2, const ulong * exp3, slong N) + void mpoly_monomial_add(ulong * exp_ptr, const ulong * exp2, const ulong * exp3, slong N) noexcept # Set ``(exp_ptr, N)`` to the sum of the monomials ``(exp2, N)`` and # ``(exp3, N)``, assuming ``bits <= FLINT_BITS`` - void mpoly_monomial_add_mp(ulong * exp_ptr, const ulong * exp2, const ulong * exp3, slong N) + void mpoly_monomial_add_mp(ulong * exp_ptr, const ulong * exp2, const ulong * exp3, slong N) noexcept # Set ``(exp_ptr, N)`` to the sum of the monomials ``(exp2, N)`` and # ``(exp3, N)``. - void mpoly_monomial_sub(ulong * exp_ptr, const ulong * exp2, const ulong * exp3, slong N) + void mpoly_monomial_sub(ulong * exp_ptr, const ulong * exp2, const ulong * exp3, slong N) noexcept # Set ``(exp_ptr, N)`` to the difference of the monomials ``(exp2, N)`` and ``(exp3, N)``, assuming ``bits <= FLINT_BITS`` - void mpoly_monomial_sub_mp(ulong * exp_ptr, const ulong * exp2, const ulong * exp3, slong N) + void mpoly_monomial_sub_mp(ulong * exp_ptr, const ulong * exp2, const ulong * exp3, slong N) noexcept # Set ``(exp_ptr, N)`` to the difference of the monomials ``(exp2, N)`` and ``(exp3, N)``. - int mpoly_monomial_overflows(ulong * exp2, slong N, ulong mask) + int mpoly_monomial_overflows(ulong * exp2, slong N, ulong mask) noexcept # Return true if any of the fields of the given monomial ``(exp2, N)`` has # overflowed (or is negative). The ``mask`` is a word with the high bit of # each field set to 1. In other words, the function returns 1 if any word of # ``exp2`` has any of the nonzero bits in ``mask`` set. Assumes that # ``bits <= FLINT_BITS``. - int mpoly_monomial_overflows_mp(ulong * exp_ptr, slong N, flint_bitcnt_t bits) + int mpoly_monomial_overflows_mp(ulong * exp_ptr, slong N, flint_bitcnt_t bits) noexcept # Return true if any of the fields of the given monomial ``(exp_ptr, N)`` # has overflowed. Assumes that ``bits >= FLINT_BITS``. - int mpoly_monomial_overflows1(ulong exp, ulong mask) + int mpoly_monomial_overflows1(ulong exp, ulong mask) noexcept # As per ``mpoly_monomial_overflows`` with ``N = 1``. - void mpoly_monomial_set(ulong * exp2, const ulong * exp3, slong N) + void mpoly_monomial_set(ulong * exp2, const ulong * exp3, slong N) noexcept # Set the monomial ``(exp2, N)`` to ``(exp3, N)``. - void mpoly_monomial_swap(ulong * exp2, ulong * exp3, slong N) + void mpoly_monomial_swap(ulong * exp2, ulong * exp3, slong N) noexcept # Swap the words in ``(exp2, N)`` and ``(exp3, N)``. - void mpoly_monomial_mul_ui(ulong * exp2, const ulong * exp3, slong N, ulong c) + void mpoly_monomial_mul_ui(ulong * exp2, const ulong * exp3, slong N, ulong c) noexcept # Set the words of ``(exp2, N)`` to the words of ``(exp3, N)`` # multiplied by ``c``. - bint mpoly_monomial_is_zero(const ulong * exp, slong N) + bint mpoly_monomial_is_zero(const ulong * exp, slong N) noexcept # Return 1 if ``(exp, N)`` is zero. - bint mpoly_monomial_equal(const ulong * exp2, const ulong * exp3, slong N) + bint mpoly_monomial_equal(const ulong * exp2, const ulong * exp3, slong N) noexcept # Return 1 if the monomials ``(exp2, N)`` and ``(exp3, N)`` are equal. - void mpoly_get_cmpmask(ulong * cmpmask, slong N, ulong bits, const mpoly_ctx_t mctx) + void mpoly_get_cmpmask(ulong * cmpmask, slong N, ulong bits, const mpoly_ctx_t mctx) noexcept # Get the mask ``(cmpmask, N)`` for comparisons. # ``bits`` should be set to the number of bits in the exponents # to be compared. Any function that compares monomials should use this # comparison mask. - bint mpoly_monomial_lt(const ulong * exp2, const ulong * exp3, slong N, const ulong * cmpmask) + bint mpoly_monomial_lt(const ulong * exp2, const ulong * exp3, slong N, const ulong * cmpmask) noexcept # Return 1 if ``(exp2, N)`` is less than ``(exp3, N)``. - bint mpoly_monomial_gt(const ulong * exp2, const ulong * exp3, slong N, const ulong * cmpmask) + bint mpoly_monomial_gt(const ulong * exp2, const ulong * exp3, slong N, const ulong * cmpmask) noexcept # Return 1 if ``(exp2, N)`` is greater than ``(exp3, N)``. - int mpoly_monomial_cmp(const ulong * exp2, const ulong * exp3, slong N, const ulong * cmpmask) + int mpoly_monomial_cmp(const ulong * exp2, const ulong * exp3, slong N, const ulong * cmpmask) noexcept # Return `1` if ``(exp2, N)`` is greater than, `0` if it is equal to and # `-1` if it is less than ``(exp3, N)``. - int mpoly_monomial_divides(ulong * exp_ptr, const ulong * exp2, const ulong * exp3, slong N, ulong mask) + int mpoly_monomial_divides(ulong * exp_ptr, const ulong * exp2, const ulong * exp3, slong N, ulong mask) noexcept # Return 1 if the monomial ``(exp3, N)`` divides ``(exp2, N)``. If so # set ``(exp_ptr, N)`` to the quotient monomial. The ``mask`` is a word # with the high bit of each bit field set to 1. Assumes that # ``bits <= FLINT_BITS``. - int mpoly_monomial_divides_mp(ulong * exp_ptr, const ulong * exp2, const ulong * exp3, slong N, flint_bitcnt_t bits) + int mpoly_monomial_divides_mp(ulong * exp_ptr, const ulong * exp2, const ulong * exp3, slong N, flint_bitcnt_t bits) noexcept # Return 1 if the monomial ``(exp3, N)`` divides ``(exp2, N)``. If so # set ``(exp_ptr, N)`` to the quotient monomial. Assumes that # ``bits >= FLINT_BITS``. - int mpoly_monomial_divides1(ulong * exp_ptr, const ulong exp2, const ulong exp3, ulong mask) + int mpoly_monomial_divides1(ulong * exp_ptr, const ulong exp2, const ulong exp3, ulong mask) noexcept # As per ``mpoly_monomial_divides`` with ``N = 1``. - int mpoly_monomial_divides_tight(slong e1, slong e2, slong * prods, slong num) + int mpoly_monomial_divides_tight(slong e1, slong e2, slong * prods, slong num) noexcept # Return 1 if the monomial ``e2`` divides the monomial ``e1``, where # the monomials are stored using factorial representation. The array # ``(prods, num)`` should consist of `1`, `b_1, b_1\times b_2, \ldots`, # where the `b_i` are the bases of the factorial number representation. - flint_bitcnt_t mpoly_exp_bits_required_ui(const ulong * user_exp, const mpoly_ctx_t mctx) + flint_bitcnt_t mpoly_exp_bits_required_ui(const ulong * user_exp, const mpoly_ctx_t mctx) noexcept # Returns the number of bits required to store ``user_exp`` in packed # format. The returned number of bits includes space for a zeroed signed bit. - flint_bitcnt_t mpoly_exp_bits_required_ffmpz(const fmpz * user_exp, const mpoly_ctx_t mctx) + flint_bitcnt_t mpoly_exp_bits_required_ffmpz(const fmpz * user_exp, const mpoly_ctx_t mctx) noexcept # Returns the number of bits required to store ``user_exp`` in packed # format. The returned number of bits includes space for a zeroed signed bit. - flint_bitcnt_t mpoly_exp_bits_required_pfmpz(fmpz * const * user_exp, const mpoly_ctx_t mctx) + flint_bitcnt_t mpoly_exp_bits_required_pfmpz(fmpz * const * user_exp, const mpoly_ctx_t mctx) noexcept # Returns the number of bits required to store ``user_exp`` in packed # format. The returned number of bits includes space for a zeroed signed bit. - void mpoly_max_fields_ui_sp(ulong * max_fields, const ulong * poly_exps, slong len, ulong bits, const mpoly_ctx_t mctx) + void mpoly_max_fields_ui_sp(ulong * max_fields, const ulong * poly_exps, slong len, ulong bits, const mpoly_ctx_t mctx) noexcept # Compute the field-wise maximum of packed exponents from ``poly_exps`` # of length ``len`` and unpack the result into ``max_fields``. # The maximums are assumed to fit a ulong. - void mpoly_max_fields_fmpz(fmpz * max_fields, const ulong * poly_exps, slong len, ulong bits, const mpoly_ctx_t mctx) + void mpoly_max_fields_fmpz(fmpz * max_fields, const ulong * poly_exps, slong len, ulong bits, const mpoly_ctx_t mctx) noexcept # Compute the field-wise maximum of packed exponents from ``poly_exps`` # of length ``len`` and unpack the result into ``max_fields``. - void mpoly_max_degrees_tight(slong * max_exp, ulong * exps, slong len, slong * prods, slong num) + void mpoly_max_degrees_tight(slong * max_exp, ulong * exps, slong len, slong * prods, slong num) noexcept # Return an array of ``num`` integers corresponding to the maximum degrees # of the exponents in the array of exponent vectors ``(exps, len)``, # assuming that the exponent are packed in a factorial representation. The @@ -147,7 +147,7 @@ cdef extern from "flint_wrap.h": # with the entry corresponding to the most significant base of the factorial # representation first in the array. - int mpoly_monomial_exists(slong * index, const ulong * poly_exps, const ulong * exp, slong len, slong N, const ulong * cmpmask) + int mpoly_monomial_exists(slong * index, const ulong * poly_exps, const ulong * exp, slong len, slong N, const ulong * cmpmask) noexcept # Returns true if the given exponent vector ``exp`` exists in the array of # exponent vectors ``(poly_exps, len)``, otherwise, returns false. If the # exponent vector is found, its index into the array of exponent vectors is @@ -155,7 +155,7 @@ cdef extern from "flint_wrap.h": # could be inserted to preserve the ordering. The index can be in the range # ``[0, len]``. - void mpoly_search_monomials(slong ** e_ind, ulong * e, slong * e_score, slong * t1, slong * t2, slong *t3, slong lower, slong upper, const ulong * a, slong a_len, const ulong * b, slong b_len, slong N, const ulong * cmpmask) + void mpoly_search_monomials(slong ** e_ind, ulong * e, slong * e_score, slong * t1, slong * t2, slong *t3, slong lower, slong upper, const ulong * a, slong a_len, const ulong * b, slong b_len, slong N, const ulong * cmpmask) noexcept # Given packed exponent vectors ``a`` and ``b``, compute a packed # exponent ``e`` such that the number of monomials in the cross product # ``a`` X ``b`` that are less than or equal to ``e`` is between @@ -167,64 +167,64 @@ cdef extern from "flint_wrap.h": # of ``t1``, ``t2``, and ``t3`` and gives the locations of the # monomials in ``a`` X ``b``. - int mpoly_term_exp_fits_ui(ulong * exps, ulong bits, slong n, const mpoly_ctx_t mctx) + int mpoly_term_exp_fits_ui(ulong * exps, ulong bits, slong n, const mpoly_ctx_t mctx) noexcept # Return whether every entry of the exponent vector of index `n` in # ``exps`` fits into a ``ulong``. - int mpoly_term_exp_fits_si(ulong * exps, ulong bits, slong n, const mpoly_ctx_t mctx) + int mpoly_term_exp_fits_si(ulong * exps, ulong bits, slong n, const mpoly_ctx_t mctx) noexcept # Return whether every entry of the exponent vector of index `n` in # ``exps`` fits into a ``slong``. - void mpoly_get_monomial_ui(ulong * exps, const ulong * poly_exps, ulong bits, const mpoly_ctx_t mctx) + void mpoly_get_monomial_ui(ulong * exps, const ulong * poly_exps, ulong bits, const mpoly_ctx_t mctx) noexcept # Convert the packed exponent ``poly_exps`` of bit count ``bits`` to a # monomial from the user's perspective. The exponents are assumed to fit # a ulong. - void mpoly_get_monomial_ffmpz(fmpz * exps, const ulong * poly_exps, flint_bitcnt_t bits, const mpoly_ctx_t mctx) + void mpoly_get_monomial_ffmpz(fmpz * exps, const ulong * poly_exps, flint_bitcnt_t bits, const mpoly_ctx_t mctx) noexcept # Convert the packed exponent ``poly_exps`` of bit count ``bits`` to a # monomial from the user's perspective. - void mpoly_get_monomial_pfmpz(fmpz ** exps, const ulong * poly_exps, flint_bitcnt_t bits, const mpoly_ctx_t mctx) + void mpoly_get_monomial_pfmpz(fmpz ** exps, const ulong * poly_exps, flint_bitcnt_t bits, const mpoly_ctx_t mctx) noexcept # Convert the packed exponent ``poly_exps`` of bit count ``bits`` to a # monomial from the user's perspective. - void mpoly_set_monomial_ui(ulong * exp1, const ulong * exp2, ulong bits, const mpoly_ctx_t mctx) + void mpoly_set_monomial_ui(ulong * exp1, const ulong * exp2, ulong bits, const mpoly_ctx_t mctx) noexcept # Convert the user monomial ``exp2`` to packed format using ``bits``. - void mpoly_set_monomial_ffmpz(ulong * exp1, const fmpz * exp2, flint_bitcnt_t bits, const mpoly_ctx_t mctx) + void mpoly_set_monomial_ffmpz(ulong * exp1, const fmpz * exp2, flint_bitcnt_t bits, const mpoly_ctx_t mctx) noexcept # Convert the user monomial ``exp2`` to packed format using ``bits``. - void mpoly_set_monomial_pfmpz(ulong * exp1, fmpz * const * exp2, flint_bitcnt_t bits, const mpoly_ctx_t mctx) + void mpoly_set_monomial_pfmpz(ulong * exp1, fmpz * const * exp2, flint_bitcnt_t bits, const mpoly_ctx_t mctx) noexcept # Convert the user monomial ``exp2`` to packed format using ``bits``. - void mpoly_pack_vec_ui(ulong * exp1, const ulong * exp2, ulong bits, slong nfields, slong len) + void mpoly_pack_vec_ui(ulong * exp1, const ulong * exp2, ulong bits, slong nfields, slong len) noexcept # Packs a vector ``exp2`` into \{exp1} using a bit count of ``bits``. # No checking is done to ensure that the vector actually fits # into ``bits`` bits. The number of fields in each vector is # ``nfields`` and the total number of vectors to unpack is ``len``. - void mpoly_pack_vec_fmpz(ulong * exp1, const fmpz * exp2, flint_bitcnt_t bits, slong nfields, slong len) + void mpoly_pack_vec_fmpz(ulong * exp1, const fmpz * exp2, flint_bitcnt_t bits, slong nfields, slong len) noexcept # Packs a vector ``exp2`` into \{exp1} using a bit count of ``bits``. # No checking is done to ensure that the vector actually fits # into ``bits`` bits. The number of fields in each vector is # ``nfields`` and the total number of vectors to unpack is ``len``. - void mpoly_unpack_vec_ui(ulong * exp1, const ulong * exp2, ulong bits, slong nfields, slong len) + void mpoly_unpack_vec_ui(ulong * exp1, const ulong * exp2, ulong bits, slong nfields, slong len) noexcept # Unpacks vector ``exp2`` of bit count ``bits`` into ``exp1``. # The number of fields in each vector is # ``nfields`` and the total number of vectors to unpack is ``len``. - void mpoly_unpack_vec_fmpz(fmpz * exp1, const ulong * exp2, flint_bitcnt_t bits, slong nfields, slong len) + void mpoly_unpack_vec_fmpz(fmpz * exp1, const ulong * exp2, flint_bitcnt_t bits, slong nfields, slong len) noexcept # Unpacks vector ``exp2`` of bit count ``bits`` into ``exp1``. # The number of fields in each vector is # ``nfields`` and the total number of vectors to unpack is ``len``. - int mpoly_repack_monomials(ulong * exps1, ulong bits1, const ulong * exps2, ulong bits2, slong len, const mpoly_ctx_t mctx) + int mpoly_repack_monomials(ulong * exps1, ulong bits1, const ulong * exps2, ulong bits2, slong len, const mpoly_ctx_t mctx) noexcept # Convert an array of length ``len`` of exponents ``exps2`` packed # using bits ``bits2`` into an array ``exps1`` using bits ``bits1``. # No checking is done to ensure that the result fits into bits ``bits1``. - void mpoly_pack_monomials_tight(ulong * exp1, const ulong * exp2, slong len, const slong * mults, slong num, slong bits) + void mpoly_pack_monomials_tight(ulong * exp1, const ulong * exp2, slong len, const slong * mults, slong num, slong bits) noexcept # Given an array of possibly packed exponent vectors ``exp2`` of length # ``len``, where each field of each exponent vector is packed into the # given number of bits, return the corresponding array of monomial vectors @@ -237,7 +237,7 @@ cdef extern from "flint_wrap.h": # least significant ``num`` fields of each exponent vectors and ignores # the rest. The number of ignored fields should be passed in ``extras``. - void mpoly_unpack_monomials_tight(ulong * e1, ulong * e2, slong len, slong * mults, slong num, slong bits) + void mpoly_unpack_monomials_tight(ulong * e1, ulong * e2, slong len, slong * mults, slong num, slong bits) noexcept # Given an array of exponent vectors ``e2`` of length ``len`` packed # using a factorial numbering scheme, unpack the monomials into an array # ``e1`` of exponent vectors in standard packed format, where each field @@ -246,7 +246,7 @@ cdef extern from "flint_wrap.h": # entry of which corresponds to the field of least significance in each # exponent vector. - void mpoly_main_variable_terms1(slong * i1, slong * n1, const ulong * exp1, slong l1, slong len1, slong k, slong num, slong bits) + void mpoly_main_variable_terms1(slong * i1, slong * n1, const ulong * exp1, slong l1, slong len1, slong k, slong num, slong bits) noexcept # Given an array of exponent vectors ``(exp1, len1)``, each exponent # vector taking one word of space, with each exponent being packed into the # given number of bits, compute ``l1`` starting offsets ``i1`` and @@ -256,7 +256,7 @@ cdef extern from "flint_wrap.h": # from the variable of least significance, starting from `0`. The value # ``l1`` should be the degree in the main variable, plus one. - int _mpoly_heap_insert(mpoly_heap_s * heap, ulong * exp, void * x, slong * next_loc, slong * heap_len, slong N, const ulong * cmpmask) + int _mpoly_heap_insert(mpoly_heap_s * heap, ulong * exp, void * x, slong * next_loc, slong * heap_len, slong N, const ulong * cmpmask) noexcept # Given a heap, insert a new node `x` corresponding to the given exponent # into the heap. Heap elements are ordered by the exponent ``(exp, N)``, # with the largest element at the head of the heap. A pointer to the current @@ -264,11 +264,11 @@ cdef extern from "flint_wrap.h": # the function. Note that the index 0 position in the heap is not used, so # the length is always one greater than the number of elements. - void _mpoly_heap_insert1(mpoly_heap1_s * heap, ulong exp, void * x, slong * next_loc, slong * heap_len, ulong maskhi) + void _mpoly_heap_insert1(mpoly_heap1_s * heap, ulong exp, void * x, slong * next_loc, slong * heap_len, ulong maskhi) noexcept # As per ``_mpoly_heap_insert`` except that ``N = 1``, and # ``maskhi = cmpmask[0]``. - void * _mpoly_heap_pop(mpoly_heap_s * heap, slong * heap_len, slong N, const ulong * cmpmask) + void * _mpoly_heap_pop(mpoly_heap_s * heap, slong * heap_len, slong N, const ulong * cmpmask) noexcept # Pop the head of the heap. It is cast to a ``void *``. A pointer to the # current heap length must be passed in via ``heap_len``. This will be # updated by the function. Note that the index 0 position in the heap is not @@ -276,6 +276,6 @@ cdef extern from "flint_wrap.h": # ``maskhi`` and ``masklo`` values are zero except for degrevlex # ordering, where they are as per the monomial comparison operations above. - void * _mpoly_heap_pop1(mpoly_heap1_s * heap, slong * heap_len, ulong maskhi) + void * _mpoly_heap_pop1(mpoly_heap1_s * heap, slong * heap_len, ulong maskhi) noexcept # As per ``_mpoly_heap_pop1`` except that ``N = 1``, and # ``maskhi = cmpmask[0]``. diff --git a/src/sage/libs/flint/nf.pxd b/src/sage/libs/flint/nf.pxd index 3df152c7c74..c9200ea1056 100644 --- a/src/sage/libs/flint/nf.pxd +++ b/src/sage/libs/flint/nf.pxd @@ -12,10 +12,10 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void nf_init(nf_t nf, const fmpq_poly_t pol) + void nf_init(nf_t nf, const fmpq_poly_t pol) noexcept # Perform basic initialisation of a number field (for element arithmetic) # given a defining polynomial over `\mathbb{Q}`. - void nf_clear(nf_t nf) + void nf_clear(nf_t nf) noexcept # Release resources used by a number field object. The object will need # initialisation again before it can be used. diff --git a/src/sage/libs/flint/nf_elem.pxd b/src/sage/libs/flint/nf_elem.pxd index a0034c21fef..a78a48946c7 100644 --- a/src/sage/libs/flint/nf_elem.pxd +++ b/src/sage/libs/flint/nf_elem.pxd @@ -12,33 +12,33 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void nf_elem_init(nf_elem_t a, const nf_t nf) + void nf_elem_init(nf_elem_t a, const nf_t nf) noexcept # Initialise a number field element to belong to the given number field # ``nf``. The element is set to zero. - void nf_elem_clear(nf_elem_t a, const nf_t nf) + void nf_elem_clear(nf_elem_t a, const nf_t nf) noexcept # Clear resources allocated by the given number field element in the given # number field. - void nf_elem_randtest(nf_elem_t a, flint_rand_t state, mp_bitcnt_t bits, const nf_t nf) + void nf_elem_randtest(nf_elem_t a, flint_rand_t state, mp_bitcnt_t bits, const nf_t nf) noexcept # Generate a random number field element `a` in the number field ``nf`` # whose coefficients have up to the given number of bits. - void nf_elem_canonicalise(nf_elem_t a, const nf_t nf) + void nf_elem_canonicalise(nf_elem_t a, const nf_t nf) noexcept # Canonicalise a number field element, i.e. reduce numerator and denominator # to lowest terms. If the numerator is `0`, set the denominator to `1`. - void _nf_elem_reduce(nf_elem_t a, const nf_t nf) + void _nf_elem_reduce(nf_elem_t a, const nf_t nf) noexcept # Reduce a number field element modulo the defining polynomial. This is used # with functions such as ``nf_elem_mul_red`` which allow reduction to be # delayed. Does not canonicalise. - void nf_elem_reduce(nf_elem_t a, const nf_t nf) + void nf_elem_reduce(nf_elem_t a, const nf_t nf) noexcept # Reduce a number field element modulo the defining polynomial. This is used # with functions such as ``nf_elem_mul_red`` which allow reduction to be # delayed. - int _nf_elem_invertible_check(nf_elem_t a, const nf_t nf) + int _nf_elem_invertible_check(nf_elem_t a, const nf_t nf) noexcept # Whilst the defining polynomial for a number field should by definition be # irreducible, it is not enforced. Thus in test code, it is convenient to be # able to check that a given number field element is invertible modulo the @@ -47,191 +47,191 @@ cdef extern from "flint_wrap.h": # `1` is returned, otherwise `0` is returned. # The function is only intended to be used in test code. - void nf_elem_set_fmpz_mat_row(nf_elem_t b, const fmpz_mat_t M, const slong i, fmpz_t den, const nf_t nf) + void nf_elem_set_fmpz_mat_row(nf_elem_t b, const fmpz_mat_t M, const slong i, fmpz_t den, const nf_t nf) noexcept # Set `b` to the element specified by row `i` of the matrix `M` and with the # given denominator `d`. Column `0` of the matrix corresponds to the constant # coefficient of the number field element. - void nf_elem_get_fmpz_mat_row(fmpz_mat_t M, const slong i, fmpz_t den, const nf_elem_t b, const nf_t nf) + void nf_elem_get_fmpz_mat_row(fmpz_mat_t M, const slong i, fmpz_t den, const nf_elem_t b, const nf_t nf) noexcept # Set the row `i` of the matrix `M` to the coefficients of the numerator of # the element `b` and `d` to the denominator of `b`. Column `0` of the matrix # corresponds to the constant coefficient of the number field element. - void nf_elem_set_fmpq_poly(nf_elem_t a, const fmpq_poly_t pol, const nf_t nf) + void nf_elem_set_fmpq_poly(nf_elem_t a, const fmpq_poly_t pol, const nf_t nf) noexcept # Set `a` to the element corresponding to the polynomial ``pol``. - void nf_elem_get_fmpq_poly(fmpq_poly_t pol, const nf_elem_t a, const nf_t nf) + void nf_elem_get_fmpq_poly(fmpq_poly_t pol, const nf_elem_t a, const nf_t nf) noexcept # Set ``pol`` to a polynomial corresponding to `a`, reduced modulo the # defining polynomial of ``nf``. - void nf_elem_get_nmod_poly_den(nmod_poly_t pol, const nf_elem_t a, const nf_t nf, int den) + void nf_elem_get_nmod_poly_den(nmod_poly_t pol, const nf_elem_t a, const nf_t nf, int den) noexcept # Set ``pol`` to the reduction of the polynomial corresponding to the # numerator of `a`. If ``den == 1``, the result is multiplied by the # inverse of the denominator of `a`. In this case it is assumed that the # reduction of the denominator of `a` is invertible. - void nf_elem_get_nmod_poly(nmod_poly_t pol, const nf_elem_t a, const nf_t nf) + void nf_elem_get_nmod_poly(nmod_poly_t pol, const nf_elem_t a, const nf_t nf) noexcept # Set ``pol`` to the reduction of the polynomial corresponding to the # numerator of `a`. The result is multiplied by the inverse of the # denominator of `a`. It is assumed that the reduction of the denominator of # `a` is invertible. - void nf_elem_get_fmpz_mod_poly_den(fmpz_mod_poly_t pol, const nf_elem_t a, const nf_t nf, int den, const fmpz_mod_ctx_t ctx) + void nf_elem_get_fmpz_mod_poly_den(fmpz_mod_poly_t pol, const nf_elem_t a, const nf_t nf, int den, const fmpz_mod_ctx_t ctx) noexcept # Set ``pol`` to the reduction of the polynomial corresponding to the # numerator of `a`. If ``den == 1``, the result is multiplied by the # inverse of the denominator of `a`. In this case it is assumed that the # reduction of the denominator of `a` is invertible. - void nf_elem_get_fmpz_mod_poly(fmpz_mod_poly_t pol, const nf_elem_t a, const nf_t nf, const fmpz_mod_ctx_t ctx) + void nf_elem_get_fmpz_mod_poly(fmpz_mod_poly_t pol, const nf_elem_t a, const nf_t nf, const fmpz_mod_ctx_t ctx) noexcept # Set ``pol`` to the reduction of the polynomial corresponding to the # numerator of `a`. The result is multiplied by the inverse of the # denominator of `a`. It is assumed that the reduction of the denominator of # `a` is invertible. - void nf_elem_set_den(nf_elem_t b, fmpz_t d, const nf_t nf) + void nf_elem_set_den(nf_elem_t b, fmpz_t d, const nf_t nf) noexcept # Set the denominator of the ``nf_elem_t b`` to the given integer `d`. # Assumes `d > 0`. - void nf_elem_get_den(fmpz_t d, const nf_elem_t b, const nf_t nf) + void nf_elem_get_den(fmpz_t d, const nf_elem_t b, const nf_t nf) noexcept # Set `d` to the denominator of the ``nf_elem_t b``. - void _nf_elem_set_coeff_num_fmpz(nf_elem_t a, slong i, const fmpz_t d, const nf_t nf) + void _nf_elem_set_coeff_num_fmpz(nf_elem_t a, slong i, const fmpz_t d, const nf_t nf) noexcept # Set the `i`-th coefficient of the denominator of `a` to the given integer # `d`. - bint _nf_elem_equal(const nf_elem_t a, const nf_elem_t b, const nf_t nf) + bint _nf_elem_equal(const nf_elem_t a, const nf_elem_t b, const nf_t nf) noexcept # Return `1` if the given number field elements are equal in the given # number field ``nf``. This function does \emph{not} assume `a` and `b` # are canonicalised. - bint nf_elem_equal(const nf_elem_t a, const nf_elem_t b, const nf_t nf) + bint nf_elem_equal(const nf_elem_t a, const nf_elem_t b, const nf_t nf) noexcept # Return `1` if the given number field elements are equal in the given # number field ``nf``. This function assumes `a` and `b` \emph{are} # canonicalised. - bint nf_elem_is_zero(const nf_elem_t a, const nf_t nf) + bint nf_elem_is_zero(const nf_elem_t a, const nf_t nf) noexcept # Return `1` if the given number field element is equal to zero, # otherwise return `0`. - bint nf_elem_is_one(const nf_elem_t a, const nf_t nf) + bint nf_elem_is_one(const nf_elem_t a, const nf_t nf) noexcept # Return `1` if the given number field element is equal to one, # otherwise return `0`. - void nf_elem_print_pretty(const nf_elem_t a, const nf_t nf, const char * var) + void nf_elem_print_pretty(const nf_elem_t a, const nf_t nf, const char * var) noexcept # Print the given number field element to ``stdout`` using the # null-terminated string ``var`` not equal to ``"\0"`` as the # name of the primitive element. - void nf_elem_zero(nf_elem_t a, const nf_t nf) + void nf_elem_zero(nf_elem_t a, const nf_t nf) noexcept - void nf_elem_one(nf_elem_t a, const nf_t nf) + void nf_elem_one(nf_elem_t a, const nf_t nf) noexcept - void nf_elem_set(nf_elem_t a, const nf_elem_t b, const nf_t nf) + void nf_elem_set(nf_elem_t a, const nf_elem_t b, const nf_t nf) noexcept # Set the number field element `a` to equal the number field element `b`, # i.e. set `a = b`. - void nf_elem_neg(nf_elem_t a, const nf_elem_t b, const nf_t nf) + void nf_elem_neg(nf_elem_t a, const nf_elem_t b, const nf_t nf) noexcept # Set the number field element `a` to minus the number field element `b`, # i.e. set `a = -b`. - void nf_elem_swap(nf_elem_t a, nf_elem_t b, const nf_t nf) + void nf_elem_swap(nf_elem_t a, nf_elem_t b, const nf_t nf) noexcept # Efficiently swap the two number field elements `a` and `b`. - void nf_elem_mul_gen(nf_elem_t a, const nf_elem_t b, const nf_t nf) + void nf_elem_mul_gen(nf_elem_t a, const nf_elem_t b, const nf_t nf) noexcept # Multiply the element `b` with the generator of the number field. - void _nf_elem_add(nf_elem_t r, const nf_elem_t a, const nf_elem_t b, const nf_t nf) + void _nf_elem_add(nf_elem_t r, const nf_elem_t a, const nf_elem_t b, const nf_t nf) noexcept # Add two elements of a number field ``nf``, i.e. set `r = a + b`. # Canonicalisation is not performed. - void nf_elem_add(nf_elem_t r, const nf_elem_t a, const nf_elem_t b, const nf_t nf) + void nf_elem_add(nf_elem_t r, const nf_elem_t a, const nf_elem_t b, const nf_t nf) noexcept # Add two elements of a number field ``nf``, i.e. set `r = a + b`. - void _nf_elem_sub(nf_elem_t r, const nf_elem_t a, const nf_elem_t b, const nf_t nf) + void _nf_elem_sub(nf_elem_t r, const nf_elem_t a, const nf_elem_t b, const nf_t nf) noexcept # Subtract two elements of a number field ``nf``, i.e. set `r = a - b`. # Canonicalisation is not performed. - void nf_elem_sub(nf_elem_t r, const nf_elem_t a, const nf_elem_t b, const nf_t nf) + void nf_elem_sub(nf_elem_t r, const nf_elem_t a, const nf_elem_t b, const nf_t nf) noexcept # Subtract two elements of a number field ``nf``, i.e. set `r = a - b`. - void _nf_elem_mul(nf_elem_t a, const nf_elem_t b, const nf_elem_t c, const nf_t nf) + void _nf_elem_mul(nf_elem_t a, const nf_elem_t b, const nf_elem_t c, const nf_t nf) noexcept # Multiply two elements of a number field ``nf``, i.e. set `r = a * b`. # Does not canonicalise. Aliasing of inputs with output is not supported. - void _nf_elem_mul_red(nf_elem_t a, const nf_elem_t b, const nf_elem_t c, const nf_t nf, int red) + void _nf_elem_mul_red(nf_elem_t a, const nf_elem_t b, const nf_elem_t c, const nf_t nf, int red) noexcept # As per ``_nf_elem_mul``, but reduction modulo the defining polynomial # of the number field is only carried out if ``red == 1``. Assumes both # inputs are reduced. - void nf_elem_mul(nf_elem_t a, const nf_elem_t b, const nf_elem_t c, const nf_t nf) + void nf_elem_mul(nf_elem_t a, const nf_elem_t b, const nf_elem_t c, const nf_t nf) noexcept # Multiply two elements of a number field ``nf``, i.e. set `r = a * b`. - void nf_elem_mul_red(nf_elem_t a, const nf_elem_t b, const nf_elem_t c, const nf_t nf, int red) + void nf_elem_mul_red(nf_elem_t a, const nf_elem_t b, const nf_elem_t c, const nf_t nf, int red) noexcept # As per ``nf_elem_mul``, but reduction modulo the defining polynomial # of the number field is only carried out if ``red == 1``. Assumes both # inputs are reduced. - void _nf_elem_inv(nf_elem_t r, const nf_elem_t a, const nf_t nf) + void _nf_elem_inv(nf_elem_t r, const nf_elem_t a, const nf_t nf) noexcept # Invert an element of a number field ``nf``, i.e. set `r = a^{-1}`. # Aliasing of the input with the output is not supported. - void nf_elem_inv(nf_elem_t r, const nf_elem_t a, const nf_t nf) + void nf_elem_inv(nf_elem_t r, const nf_elem_t a, const nf_t nf) noexcept # Invert an element of a number field ``nf``, i.e. set `r = a^{-1}`. - void _nf_elem_div(nf_elem_t a, const nf_elem_t b, const nf_elem_t c, const nf_t nf) + void _nf_elem_div(nf_elem_t a, const nf_elem_t b, const nf_elem_t c, const nf_t nf) noexcept # Set `a` to `b/c` in the given number field. Aliasing of `a` and `b` is not # permitted. - void nf_elem_div(nf_elem_t a, const nf_elem_t b, const nf_elem_t c, const nf_t nf) + void nf_elem_div(nf_elem_t a, const nf_elem_t b, const nf_elem_t c, const nf_t nf) noexcept # Set `a` to `b/c` in the given number field. - void _nf_elem_pow(nf_elem_t res, const nf_elem_t a, ulong e, const nf_t nf) + void _nf_elem_pow(nf_elem_t res, const nf_elem_t a, ulong e, const nf_t nf) noexcept # Set ``res`` to `a^e` using left-to-right binary exponentiation as # described on p. 461 of [Knu1997]_. # Assumes that `a \neq 0` and `e > 1`. Does not support aliasing. - void nf_elem_pow(nf_elem_t res, const nf_elem_t a, ulong e, const nf_t nf) + void nf_elem_pow(nf_elem_t res, const nf_elem_t a, ulong e, const nf_t nf) noexcept # Set ``res`` = ``a^e`` using the binary exponentiation algorithm. # If `e` is zero, returns one, so that in particular ``0^0 = 1``. - void _nf_elem_norm(fmpz_t rnum, fmpz_t rden, const nf_elem_t a, const nf_t nf) + void _nf_elem_norm(fmpz_t rnum, fmpz_t rden, const nf_elem_t a, const nf_t nf) noexcept # Set ``rnum, rden`` to the absolute norm of the given number field # element `a`. - void nf_elem_norm(fmpq_t res, const nf_elem_t a, const nf_t nf) + void nf_elem_norm(fmpq_t res, const nf_elem_t a, const nf_t nf) noexcept # Set ``res`` to the absolute norm of the given number field # element `a`. - void nf_elem_norm_div(fmpq_t res, const nf_elem_t a, const nf_t nf, const fmpz_t div, slong nbits) + void nf_elem_norm_div(fmpq_t res, const nf_elem_t a, const nf_t nf, const fmpz_t div, slong nbits) noexcept # Set ``res`` to the absolute norm of the given number field element `a`, # divided by ``div`` . Assumes the result to be an integer and having # at most ``nbits`` bits. - void _nf_elem_norm_div(fmpz_t rnum, fmpz_t rden, const nf_elem_t a, const nf_t nf, const fmpz_t divisor, slong nbits) + void _nf_elem_norm_div(fmpz_t rnum, fmpz_t rden, const nf_elem_t a, const nf_t nf, const fmpz_t divisor, slong nbits) noexcept # Set ``rnum, rden`` to the absolute norm of the given number field element `a`, # divided by ``div`` . Assumes the result to be an integer and having # at most ``nbits`` bits. - void _nf_elem_trace(fmpz_t rnum, fmpz_t rden, const nf_elem_t a, const nf_t nf) + void _nf_elem_trace(fmpz_t rnum, fmpz_t rden, const nf_elem_t a, const nf_t nf) noexcept # Set ``rnum, rden`` to the absolute trace of the given number field # element `a`. - void nf_elem_trace(fmpq_t res, const nf_elem_t a, const nf_t nf) + void nf_elem_trace(fmpq_t res, const nf_elem_t a, const nf_t nf) noexcept # Set ``res`` to the absolute trace of the given number field # element `a`. - void nf_elem_rep_mat(fmpq_mat_t res, const nf_elem_t a, const nf_t nf) + void nf_elem_rep_mat(fmpq_mat_t res, const nf_elem_t a, const nf_t nf) noexcept # Set ``res`` to the matrix representing the multiplication with `a` with # respect to the basis `1, a, \dotsc, a^{d - 1}`, where `a` is the generator # of the number field of `d` is its degree. - void nf_elem_rep_mat_fmpz_mat_den(fmpz_mat_t res, fmpz_t den, const nf_elem_t a, const nf_t nf) + void nf_elem_rep_mat_fmpz_mat_den(fmpz_mat_t res, fmpz_t den, const nf_elem_t a, const nf_t nf) noexcept # Return a tuple `M, d` such that `M/d` is the matrix representing the # multiplication with `a` with respect to the basis `1, a, \dotsc, a^{d - 1}`, # where `a` is the generator of the number field of `d` is its degree. # The integral matrix `M` is primitive. - void nf_elem_mod_fmpz_den(nf_elem_t z, const nf_elem_t a, const fmpz_t mod, const nf_t nf, int den) + void nf_elem_mod_fmpz_den(nf_elem_t z, const nf_elem_t a, const fmpz_t mod, const nf_t nf, int den) noexcept # If ``den == 0``, return an element `z` with denominator `1`, such that # the coefficients of `z - da` are divisble by ``mod``, where `d` is the # denominator of `a`. The coefficients of `z` are reduced modulo ``mod``. @@ -241,7 +241,7 @@ cdef extern from "flint_wrap.h": # denominator of `a`. # Reduction takes place with respect to the positive residue system. - void nf_elem_smod_fmpz_den(nf_elem_t z, const nf_elem_t a, const fmpz_t mod, const nf_t nf, int den) + void nf_elem_smod_fmpz_den(nf_elem_t z, const nf_elem_t a, const fmpz_t mod, const nf_t nf, int den) noexcept # If ``den == 0``, return an element `z` with denominator `1`, such that # the coefficients of `z - da` are divisble by ``mod``, where `d` is the # denominator of `a`. The coefficients of `z` are reduced modulo ``mod``. @@ -251,24 +251,24 @@ cdef extern from "flint_wrap.h": # denominator of `a`. # Reduction takes place with respect to the symmetric residue system. - void nf_elem_mod_fmpz(nf_elem_t res, const nf_elem_t a, const fmpz_t mod, const nf_t nf) + void nf_elem_mod_fmpz(nf_elem_t res, const nf_elem_t a, const fmpz_t mod, const nf_t nf) noexcept # Return an element `z` such that `z - a` has denominator `1` and the # coefficients of `z - a` are divisible by ``mod``. The coefficients of # `z` are reduced modulo `\mathtt{mod} \cdot d`, where `d` is the denominator of `b`. # Reduction takes place with respect to the positive residue system. - void nf_elem_smod_fmpz(nf_elem_t res, const nf_elem_t a, const fmpz_t mod, const nf_t nf) + void nf_elem_smod_fmpz(nf_elem_t res, const nf_elem_t a, const fmpz_t mod, const nf_t nf) noexcept # Return an element `z` such that `z - a` has denominator `1` and the # coefficients of `z - a` are divisible by ``mod``. The coefficients of # `z` are reduced modulo `\mathtt{mod} \cdot d`, where `d` is the denominator of `b`. # Reduction takes place with respect to the symmetric residue system. - void nf_elem_coprime_den(nf_elem_t res, const nf_elem_t a, const fmpz_t mod, const nf_t nf) + void nf_elem_coprime_den(nf_elem_t res, const nf_elem_t a, const fmpz_t mod, const nf_t nf) noexcept # Return an element `z` such that the denominator of `z - a` is coprime to # ``mod``. # Reduction takes place with respect to the positive residue system. - void nf_elem_coprime_den_signed(nf_elem_t res, const nf_elem_t a, const fmpz_t mod, const nf_t nf) + void nf_elem_coprime_den_signed(nf_elem_t res, const nf_elem_t a, const fmpz_t mod, const nf_t nf) noexcept # Return an element `z` such that the denominator of `z - a` is coprime to # ``mod``. # Reduction takes place with respect to the symmetric residue system. diff --git a/src/sage/libs/flint/nmod.pxd b/src/sage/libs/flint/nmod.pxd index a4d8cf20e03..8fdfe4a5096 100644 --- a/src/sage/libs/flint/nmod.pxd +++ b/src/sage/libs/flint/nmod.pxd @@ -12,75 +12,75 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void nmod_init(nmod_t * mod, mp_limb_t n) + void nmod_init(nmod_t * mod, mp_limb_t n) noexcept # Initialises the given ``nmod_t`` structure for reduction modulo `n` # with a precomputed inverse. - mp_limb_t _nmod_add(mp_limb_t a, mp_limb_t b, nmod_t mod) + mp_limb_t _nmod_add(mp_limb_t a, mp_limb_t b, nmod_t mod) noexcept # Returns `a + b` modulo ``mod.n``. It is assumed that ``mod`` is # no more than ``FLINT_BITS - 1`` bits. It is assumed that `a` and `b` # are already reduced modulo ``mod.n``. - mp_limb_t nmod_add(mp_limb_t a, mp_limb_t b, nmod_t mod) + mp_limb_t nmod_add(mp_limb_t a, mp_limb_t b, nmod_t mod) noexcept # Returns `a + b` modulo ``mod.n``. No assumptions are made about # ``mod.n``. It is assumed that `a` and `b` are already reduced # modulo ``mod.n``. - mp_limb_t _nmod_sub(mp_limb_t a, mp_limb_t b, nmod_t mod) + mp_limb_t _nmod_sub(mp_limb_t a, mp_limb_t b, nmod_t mod) noexcept # Returns `a - b` modulo ``mod.n``. It is assumed that ``mod`` # is no more than ``FLINT_BITS - 1`` bits. It is assumed that # `a` and `b` are already reduced modulo ``mod.n``. - mp_limb_t nmod_sub(mp_limb_t a, mp_limb_t b, nmod_t mod) + mp_limb_t nmod_sub(mp_limb_t a, mp_limb_t b, nmod_t mod) noexcept # Returns `a - b` modulo ``mod.n``. No assumptions are made about # ``mod.n``. It is assumed that `a` and `b` are already reduced # modulo ``mod.n``. - mp_limb_t nmod_neg(mp_limb_t a, nmod_t mod) + mp_limb_t nmod_neg(mp_limb_t a, nmod_t mod) noexcept # Returns `-a` modulo ``mod.n``. It is assumed that `a` is already # reduced modulo ``mod.n``, but no assumptions are made about the # latter. - mp_limb_t nmod_mul(mp_limb_t a, mp_limb_t b, nmod_t mod) + mp_limb_t nmod_mul(mp_limb_t a, mp_limb_t b, nmod_t mod) noexcept # Returns `ab` modulo ``mod.n``. No assumptions are made about # ``mod.n``. It is assumed that `a` and `b` are already reduced # modulo ``mod.n``. - mp_limb_t _nmod_mul_fullword(mp_limb_t a, mp_limb_t b, nmod_t mod) + mp_limb_t _nmod_mul_fullword(mp_limb_t a, mp_limb_t b, nmod_t mod) noexcept # Returns `ab` modulo ``mod.n``. Requires that ``mod.n`` is exactly # ``FLINT_BITS`` large. It is assumed that `a` and `b` are already # reduced modulo ``mod.n``. - mp_limb_t nmod_inv(mp_limb_t a, nmod_t mod) + mp_limb_t nmod_inv(mp_limb_t a, nmod_t mod) noexcept # Returns `a^{-1}` modulo ``mod.n``. The inverse is assumed to exist. - mp_limb_t nmod_div(mp_limb_t a, mp_limb_t b, nmod_t mod) + mp_limb_t nmod_div(mp_limb_t a, mp_limb_t b, nmod_t mod) noexcept # Returns `ab^{-1}` modulo ``mod.n``. The inverse of `b` is assumed to # exist. It is assumed that `a` is already reduced modulo ``mod.n``. - mp_limb_t nmod_pow_ui(mp_limb_t a, ulong e, nmod_t mod) + mp_limb_t nmod_pow_ui(mp_limb_t a, ulong e, nmod_t mod) noexcept # Returns `a^e` modulo ``mod.n``. No assumptions are made about # ``mod.n``. It is assumed that `a` is already reduced # modulo ``mod.n``. - mp_limb_t nmod_pow_fmpz(mp_limb_t a, const fmpz_t e, nmod_t mod) + mp_limb_t nmod_pow_fmpz(mp_limb_t a, const fmpz_t e, nmod_t mod) noexcept # Returns `a^e` modulo ``mod.n``. No assumptions are made about # ``mod.n``. It is assumed that `a` is already reduced # modulo ``mod.n`` and that `e` is not negative. - void nmod_discrete_log_pohlig_hellman_init(nmod_discrete_log_pohlig_hellman_t L) + void nmod_discrete_log_pohlig_hellman_init(nmod_discrete_log_pohlig_hellman_t L) noexcept # Initialize ``L``. Upon initialization ``L`` is not ready for computation. - void nmod_discrete_log_pohlig_hellman_clear(nmod_discrete_log_pohlig_hellman_t L) + void nmod_discrete_log_pohlig_hellman_clear(nmod_discrete_log_pohlig_hellman_t L) noexcept # Free any space used by ``L``. - double nmod_discrete_log_pohlig_hellman_precompute_prime(nmod_discrete_log_pohlig_hellman_t L, mp_limb_t p) + double nmod_discrete_log_pohlig_hellman_precompute_prime(nmod_discrete_log_pohlig_hellman_t L, mp_limb_t p) noexcept # Configure ``L`` for discrete logarithms modulo ``p`` to an internally chosen base. It is assumed that ``p`` is prime. # The return is an estimate on the number of multiplications needed for one run. - mp_limb_t nmod_discrete_log_pohlig_hellman_primitive_root(const nmod_discrete_log_pohlig_hellman_t L) + mp_limb_t nmod_discrete_log_pohlig_hellman_primitive_root(const nmod_discrete_log_pohlig_hellman_t L) noexcept # Return the internally stored base. - ulong nmod_discrete_log_pohlig_hellman_run(const nmod_discrete_log_pohlig_hellman_t L, mp_limb_t y) + ulong nmod_discrete_log_pohlig_hellman_run(const nmod_discrete_log_pohlig_hellman_t L, mp_limb_t y) noexcept # Return the logarithm of ``y`` with respect to the internally stored base. ``y`` is expected to be reduced modulo the ``p``. # The function is undefined if the logarithm does not exist. diff --git a/src/sage/libs/flint/nmod_mat.pxd b/src/sage/libs/flint/nmod_mat.pxd index c2f0b32bd41..85981e1ed05 100644 --- a/src/sage/libs/flint/nmod_mat.pxd +++ b/src/sage/libs/flint/nmod_mat.pxd @@ -12,72 +12,72 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void nmod_mat_init(nmod_mat_t mat, slong rows, slong cols, mp_limb_t n) + void nmod_mat_init(nmod_mat_t mat, slong rows, slong cols, mp_limb_t n) noexcept # Initialises ``mat`` to a ``rows``-by-``cols`` matrix with # coefficients modulo `n`, where `n` can be any nonzero integer that # fits in a limb. All elements are set to zero. - void nmod_mat_init_set(nmod_mat_t mat, const nmod_mat_t src) + void nmod_mat_init_set(nmod_mat_t mat, const nmod_mat_t src) noexcept # Initialises ``mat`` and sets its dimensions, modulus and elements # to those of ``src``. - void nmod_mat_clear(nmod_mat_t mat) + void nmod_mat_clear(nmod_mat_t mat) noexcept # Clears the matrix and releases any memory it used. The matrix # cannot be used again until it is initialised. This function must be # called exactly once when finished using an ``nmod_mat_t`` object. - void nmod_mat_set(nmod_mat_t mat, const nmod_mat_t src) + void nmod_mat_set(nmod_mat_t mat, const nmod_mat_t src) noexcept # Sets ``mat`` to a copy of ``src``. It is assumed # that ``mat`` and ``src`` have identical dimensions. - void nmod_mat_swap(nmod_mat_t mat1, nmod_mat_t mat2) + void nmod_mat_swap(nmod_mat_t mat1, nmod_mat_t mat2) noexcept # Exchanges ``mat1`` and ``mat2``. - void nmod_mat_swap_entrywise(nmod_mat_t mat1, nmod_mat_t mat2) + void nmod_mat_swap_entrywise(nmod_mat_t mat1, nmod_mat_t mat2) noexcept # Swaps two matrices by swapping the individual entries rather than swapping # the contents of the structs. - mp_limb_t nmod_mat_get_entry(const nmod_mat_t mat, slong i, slong j) + mp_limb_t nmod_mat_get_entry(const nmod_mat_t mat, slong i, slong j) noexcept # Get the entry at row `i` and column `j` of the matrix ``mat``. - mp_limb_t * nmod_mat_entry_ptr(const nmod_mat_t mat, slong i, slong j) + mp_limb_t * nmod_mat_entry_ptr(const nmod_mat_t mat, slong i, slong j) noexcept # Return a pointer to the entry at row `i` and column `j` of the matrix # ``mat``. - void nmod_mat_set_entry(nmod_mat_t mat, slong i, slong j, mp_limb_t x) + void nmod_mat_set_entry(nmod_mat_t mat, slong i, slong j, mp_limb_t x) noexcept # Set the entry at row `i` and column `j` of the matrix ``mat`` to # ``x``. - slong nmod_mat_nrows(const nmod_mat_t mat) + slong nmod_mat_nrows(const nmod_mat_t mat) noexcept # Returns the number of rows in ``mat``. - slong nmod_mat_ncols(const nmod_mat_t mat) + slong nmod_mat_ncols(const nmod_mat_t mat) noexcept # Returns the number of columns in ``mat``. - void nmod_mat_zero(nmod_mat_t mat) + void nmod_mat_zero(nmod_mat_t mat) noexcept # Sets all entries of the matrix ``mat`` to zero. - bint nmod_mat_is_zero(const nmod_mat_t mat) + bint nmod_mat_is_zero(const nmod_mat_t mat) noexcept # Returns `1` if all entries of the matrix ``mat`` are zero. - void nmod_mat_window_init(nmod_mat_t window, const nmod_mat_t mat, slong r1, slong c1, slong r2, slong c2) + void nmod_mat_window_init(nmod_mat_t window, const nmod_mat_t mat, slong r1, slong c1, slong r2, slong c2) noexcept # Initializes the matrix ``window`` to be an ``r2 - r1`` by # ``c2 - c1`` submatrix of ``mat`` whose ``(0,0)`` entry # is the ``(r1, c1)`` entry of ``mat``. The memory for the # elements of ``window`` is shared with ``mat``. - void nmod_mat_window_clear(nmod_mat_t window) + void nmod_mat_window_clear(nmod_mat_t window) noexcept # Clears the matrix ``window`` and releases any memory that it # uses. Note that the memory to the underlying matrix that # ``window`` points to is not freed. - void nmod_mat_concat_vertical(nmod_mat_t res, const nmod_mat_t mat1, const nmod_mat_t mat2) + void nmod_mat_concat_vertical(nmod_mat_t res, const nmod_mat_t mat1, const nmod_mat_t mat2) noexcept # Sets ``res`` to vertical concatenation of (`mat1`, ``mat2``) in that order. Matrix dimensions : ``mat1`` : `m \times n`, ``mat2`` : `k \times n`, ``res`` : `(m + k) \times n`. - void nmod_mat_concat_horizontal(nmod_mat_t res, const nmod_mat_t mat1, const nmod_mat_t mat2) + void nmod_mat_concat_horizontal(nmod_mat_t res, const nmod_mat_t mat1, const nmod_mat_t mat2) noexcept # Sets ``res`` to horizontal concatenation of (``mat1``, ``mat2``) in that order. Matrix dimensions : ``mat1`` : `m \times n`, ``mat2`` : `m \times k`, ``res`` : `m \times (n + k)`. - void nmod_mat_print_pretty(const nmod_mat_t mat) + void nmod_mat_print_pretty(const nmod_mat_t mat) noexcept # Pretty-prints ``mat`` to ``stdout``. A header is printed followed # by the rows enclosed in brackets. Each column is right-aligned to the # width of the modulus written in decimal, and the columns are separated by @@ -87,25 +87,25 @@ cdef extern from "flint_wrap.h": # [ 0 0 2607] # [ 622 0 0] - int nmod_mat_fprint_pretty(FILE * file, const nmod_mat_t mat) + int nmod_mat_fprint_pretty(FILE * file, const nmod_mat_t mat) noexcept # Same as ``nmod_mat_print_pretty`` but printing to ``file``. - int nmod_mat_print(const nmod_mat_t mat) + int nmod_mat_print(const nmod_mat_t mat) noexcept # Currently, same as ``nmod_mat_print_pretty``. - int nmod_mat_fprint(FILE * f, const nmod_mat_t mat) + int nmod_mat_fprint(FILE * f, const nmod_mat_t mat) noexcept # Currently, same as ``nmod_mat_fprint_pretty``. - void nmod_mat_randtest(nmod_mat_t mat, flint_rand_t state) + void nmod_mat_randtest(nmod_mat_t mat, flint_rand_t state) noexcept # Sets the elements to a random matrix with entries between `0` and `m-1` # inclusive, where `m` is the modulus of ``mat``. A sparse matrix is # generated with increased probability. - void nmod_mat_randfull(nmod_mat_t mat, flint_rand_t state) + void nmod_mat_randfull(nmod_mat_t mat, flint_rand_t state) noexcept # Sets the element to random numbers likely to be close to the modulus # of the matrix. This is used to test potential overflow-related bugs. - int nmod_mat_randpermdiag(nmod_mat_t mat, flint_rand_t state, mp_srcptr diag, slong n) + int nmod_mat_randpermdiag(nmod_mat_t mat, flint_rand_t state, mp_srcptr diag, slong n) noexcept # Sets ``mat`` to a random permutation of the diagonal matrix # with `n` leading entries given by the vector ``diag``. It is # assumed that the main diagonal of ``mat`` has room for at @@ -113,7 +113,7 @@ cdef extern from "flint_wrap.h": # Returns `0` or `1`, depending on whether the permutation is even # or odd respectively. - void nmod_mat_randrank(nmod_mat_t mat, flint_rand_t state, slong rank) + void nmod_mat_randrank(nmod_mat_t mat, flint_rand_t state, slong rank) noexcept # Sets ``mat`` to a random sparse matrix with the given rank, # having exactly as many non-zero elements as the rank, with the # non-zero elements being uniformly random integers between `0` @@ -121,86 +121,86 @@ cdef extern from "flint_wrap.h": # The matrix can be transformed into a dense matrix with unchanged # rank by subsequently calling :func:`nmod_mat_randops`. - void nmod_mat_randops(nmod_mat_t mat, slong count, flint_rand_t state) + void nmod_mat_randops(nmod_mat_t mat, slong count, flint_rand_t state) noexcept # Randomises ``mat`` by performing elementary row or column # operations. More precisely, at most ``count`` random additions # or subtractions of distinct rows and columns will be performed. # This leaves the rank (and for square matrices, determinant) # unchanged. - void nmod_mat_randtril(nmod_mat_t mat, flint_rand_t state, int unit) + void nmod_mat_randtril(nmod_mat_t mat, flint_rand_t state, int unit) noexcept # Sets ``mat`` to a random lower triangular matrix. If ``unit`` is 1, # it will have ones on the main diagonal, otherwise it will have random # nonzero entries on the main diagonal. - void nmod_mat_randtriu(nmod_mat_t mat, flint_rand_t state, int unit) + void nmod_mat_randtriu(nmod_mat_t mat, flint_rand_t state, int unit) noexcept # Sets ``mat`` to a random upper triangular matrix. If ``unit`` is 1, # it will have ones on the main diagonal, otherwise it will have random # nonzero entries on the main diagonal. - bint nmod_mat_equal(const nmod_mat_t mat1, const nmod_mat_t mat2) + bint nmod_mat_equal(const nmod_mat_t mat1, const nmod_mat_t mat2) noexcept # Returns nonzero if ``mat1`` and ``mat2`` have the same dimensions and elements, # and zero otherwise. The moduli are ignored. - bint nmod_mat_is_zero_row(const nmod_mat_t mat, slong i) + bint nmod_mat_is_zero_row(const nmod_mat_t mat, slong i) noexcept # Returns a non-zero value if row `i` of ``mat`` is zero. - void nmod_mat_transpose(nmod_mat_t B, const nmod_mat_t A) + void nmod_mat_transpose(nmod_mat_t B, const nmod_mat_t A) noexcept # Sets `B` to the transpose of `A`. Dimensions must be compatible. # `B` and `A` may be the same object if and only if the matrix is square. - void nmod_mat_swap_rows(nmod_mat_t mat, slong * perm, slong r, slong s) + void nmod_mat_swap_rows(nmod_mat_t mat, slong * perm, slong r, slong s) noexcept # Swaps rows ``r`` and ``s`` of ``mat``. If ``perm`` is non-``NULL``, the # permutation of the rows will also be applied to ``perm``. - void nmod_mat_swap_cols(nmod_mat_t mat, slong * perm, slong r, slong s) + void nmod_mat_swap_cols(nmod_mat_t mat, slong * perm, slong r, slong s) noexcept # Swaps columns ``r`` and ``s`` of ``mat``. If ``perm`` is non-``NULL``, the # permutation of the columns will also be applied to ``perm``. - void nmod_mat_invert_rows(nmod_mat_t mat, slong * perm) + void nmod_mat_invert_rows(nmod_mat_t mat, slong * perm) noexcept # Swaps rows ``i`` and ``r - i`` of ``mat`` for ``0 <= i < r/2``, where # ``r`` is the number of rows of ``mat``. If ``perm`` is non-``NULL``, the # permutation of the rows will also be applied to ``perm``. - void nmod_mat_invert_cols(nmod_mat_t mat, slong * perm) + void nmod_mat_invert_cols(nmod_mat_t mat, slong * perm) noexcept # Swaps columns ``i`` and ``c - i`` of ``mat`` for ``0 <= i < c/2``, where # ``c`` is the number of columns of ``mat``. If ``perm`` is non-``NULL``, the # permutation of the columns will also be applied to ``perm``. - void nmod_mat_permute_rows(nmod_mat_t mat, const slong * perm_act, slong * perm_store) + void nmod_mat_permute_rows(nmod_mat_t mat, const slong * perm_act, slong * perm_store) noexcept # Permutes rows of the matrix ``mat`` according to permutation ``perm_act`` # and, if ``perm_store`` is not ``NULL``, apply the same permutation to it. - void nmod_mat_add(nmod_mat_t C, const nmod_mat_t A, const nmod_mat_t B) + void nmod_mat_add(nmod_mat_t C, const nmod_mat_t A, const nmod_mat_t B) noexcept # Computes `C = A + B`. Dimensions must be identical. - void nmod_mat_sub(nmod_mat_t C, const nmod_mat_t A, const nmod_mat_t B) + void nmod_mat_sub(nmod_mat_t C, const nmod_mat_t A, const nmod_mat_t B) noexcept # Computes `C = A - B`. Dimensions must be identical. - void nmod_mat_neg(nmod_mat_t A, const nmod_mat_t B) + void nmod_mat_neg(nmod_mat_t A, const nmod_mat_t B) noexcept # Sets `B = -A`. Dimensions must be identical. - void nmod_mat_scalar_mul(nmod_mat_t B, const nmod_mat_t A, mp_limb_t c) + void nmod_mat_scalar_mul(nmod_mat_t B, const nmod_mat_t A, mp_limb_t c) noexcept # Sets `B = cA`, where the scalar `c` is assumed to be reduced # modulo the modulus. Dimensions of `A` and `B` must be identical. - void nmod_mat_scalar_addmul_ui(nmod_mat_t dest, const nmod_mat_t X, const nmod_mat_t Y, const mp_limb_t b) + void nmod_mat_scalar_addmul_ui(nmod_mat_t dest, const nmod_mat_t X, const nmod_mat_t Y, const mp_limb_t b) noexcept # Sets `dest = X + bY`, where the scalar `b` is assumed to be reduced # modulo the modulus. Dimensions of dest, X and Y must be identical. # dest can be aliased with X or Y. - void nmod_mat_scalar_mul_fmpz(nmod_mat_t res, const nmod_mat_t M, const fmpz_t c) + void nmod_mat_scalar_mul_fmpz(nmod_mat_t res, const nmod_mat_t M, const fmpz_t c) noexcept # Sets `B = cA`, where the scalar `c` is of type ``fmpz_t``. Dimensions of `A` # and `B` must be identical. - void nmod_mat_mul(nmod_mat_t C, const nmod_mat_t A, const nmod_mat_t B) + void nmod_mat_mul(nmod_mat_t C, const nmod_mat_t A, const nmod_mat_t B) noexcept # Sets `C = AB`. Dimensions must be compatible for matrix multiplication. # Aliasing is allowed. This function automatically chooses between classical # and Strassen multiplication. - void _nmod_mat_mul_classical_op(nmod_mat_t D, const nmod_mat_t C, const nmod_mat_t A, const nmod_mat_t B, int op) + void _nmod_mat_mul_classical_op(nmod_mat_t D, const nmod_mat_t C, const nmod_mat_t A, const nmod_mat_t B, int op) noexcept - void nmod_mat_mul_classical(nmod_mat_t C, const nmod_mat_t A, const nmod_mat_t B) + void nmod_mat_mul_classical(nmod_mat_t C, const nmod_mat_t A, const nmod_mat_t B) noexcept # Sets `C = AB`. Dimensions must be compatible for matrix multiplication. # `C` is not allowed to be aliased with `A` or `B`. Uses classical # matrix multiplication, creating a temporary transposed copy of `B` @@ -208,70 +208,70 @@ cdef extern from "flint_wrap.h": # and packing several entries of `B` into each word if the modulus # is very small. - void _nmod_mat_mul_classical_threaded_pool_op(nmod_mat_t D, const nmod_mat_t C, const nmod_mat_t A, const nmod_mat_t B, int op, thread_pool_handle * threads, slong num_threads) + void _nmod_mat_mul_classical_threaded_pool_op(nmod_mat_t D, const nmod_mat_t C, const nmod_mat_t A, const nmod_mat_t B, int op, thread_pool_handle * threads, slong num_threads) noexcept # Multithreaded version of ``_nmod_mat_mul_classical``. - void _nmod_mat_mul_classical_threaded_op(nmod_mat_t D, const nmod_mat_t C, const nmod_mat_t A, const nmod_mat_t B, int op) + void _nmod_mat_mul_classical_threaded_op(nmod_mat_t D, const nmod_mat_t C, const nmod_mat_t A, const nmod_mat_t B, int op) noexcept # Multithreaded version of ``_nmod_mat_mul_classical``. - void nmod_mat_mul_classical_threaded(nmod_mat_t C, const nmod_mat_t A, const nmod_mat_t B) + void nmod_mat_mul_classical_threaded(nmod_mat_t C, const nmod_mat_t A, const nmod_mat_t B) noexcept # Multithreaded version of ``nmod_mat_mul_classical``. - void nmod_mat_mul_strassen(nmod_mat_t C, const nmod_mat_t A, const nmod_mat_t B) + void nmod_mat_mul_strassen(nmod_mat_t C, const nmod_mat_t A, const nmod_mat_t B) noexcept # Sets `C = AB`. Dimensions must be compatible for matrix multiplication. # `C` is not allowed to be aliased with `A` or `B`. Uses Strassen # multiplication (the Strassen-Winograd variant). - int nmod_mat_mul_blas(nmod_mat_t C, const nmod_mat_t A, const nmod_mat_t B) + int nmod_mat_mul_blas(nmod_mat_t C, const nmod_mat_t A, const nmod_mat_t B) noexcept # Tries to set `C = AB` using BLAS and returns `1` for success and `0` for failure. Dimensions must be compatible for matrix multiplication. - void nmod_mat_addmul(nmod_mat_t D, const nmod_mat_t C, const nmod_mat_t A, const nmod_mat_t B) + void nmod_mat_addmul(nmod_mat_t D, const nmod_mat_t C, const nmod_mat_t A, const nmod_mat_t B) noexcept # Sets `D = C + AB`. `C` and `D` may be aliased with each other but # not with `A` or `B`. Automatically selects between classical # and Strassen multiplication. - void nmod_mat_submul(nmod_mat_t D, const nmod_mat_t C, const nmod_mat_t A, const nmod_mat_t B) + void nmod_mat_submul(nmod_mat_t D, const nmod_mat_t C, const nmod_mat_t A, const nmod_mat_t B) noexcept # Sets `D = C + AB`. `C` and `D` may be aliased with each other but # not with `A` or `B`. - void nmod_mat_mul_nmod_vec(mp_limb_t * c, const nmod_mat_t A, const mp_limb_t * b, slong blen) - void nmod_mat_mul_nmod_vec_ptr(mp_limb_t * const * c, const nmod_mat_t A, const mp_limb_t * const * b, slong blen) + void nmod_mat_mul_nmod_vec(mp_limb_t * c, const nmod_mat_t A, const mp_limb_t * b, slong blen) noexcept + void nmod_mat_mul_nmod_vec_ptr(mp_limb_t * const * c, const nmod_mat_t A, const mp_limb_t * const * b, slong blen) noexcept # Compute a matrix-vector product of ``A`` and ``(b, blen)`` and store the result in ``c``. # The vector ``(b, blen)`` is either truncated or zero-extended to the number of columns of ``A``. # The number entries written to ``c`` is always equal to the number of rows of ``A``. - void nmod_mat_nmod_vec_mul(mp_limb_t * c, const mp_limb_t * a, slong alen, const nmod_mat_t B) - void nmod_mat_nmod_vec_mul_ptr(mp_limb_t * const * c, const mp_limb_t * const * a, slong alen, const nmod_mat_t B) + void nmod_mat_nmod_vec_mul(mp_limb_t * c, const mp_limb_t * a, slong alen, const nmod_mat_t B) noexcept + void nmod_mat_nmod_vec_mul_ptr(mp_limb_t * const * c, const mp_limb_t * const * a, slong alen, const nmod_mat_t B) noexcept # Compute a vector-matrix product of ``(a, alen)`` and ``B`` and and store the result in ``c``. # The vector ``(a, alen)`` is either truncated or zero-extended to the number of rows of ``B``. # The number entries written to ``c`` is always equal to the number of columns of ``B``. - void _nmod_mat_pow(nmod_mat_t dest, const nmod_mat_t mat, ulong pow) + void _nmod_mat_pow(nmod_mat_t dest, const nmod_mat_t mat, ulong pow) noexcept - void nmod_mat_pow(nmod_mat_t dest, const nmod_mat_t mat, ulong pow) + void nmod_mat_pow(nmod_mat_t dest, const nmod_mat_t mat, ulong pow) noexcept # Sets `dest = mat^{pow}`. ``dest`` and ``mat`` may be aliased. Implements - mp_limb_t nmod_mat_trace(const nmod_mat_t mat) + mp_limb_t nmod_mat_trace(const nmod_mat_t mat) noexcept # Computes the trace of the matrix, i.e. the sum of the entries on # the main diagonal. The matrix is required to be square. - mp_limb_t nmod_mat_det_howell(const nmod_mat_t A) + mp_limb_t nmod_mat_det_howell(const nmod_mat_t A) noexcept # Returns the determinant of `A`. - mp_limb_t nmod_mat_det(const nmod_mat_t A) + mp_limb_t nmod_mat_det(const nmod_mat_t A) noexcept # Returns the determinant of `A`. - slong nmod_mat_rank(const nmod_mat_t A) + slong nmod_mat_rank(const nmod_mat_t A) noexcept # Returns the rank of `A`. The modulus of `A` must be a prime number. - int nmod_mat_inv(nmod_mat_t B, const nmod_mat_t A) + int nmod_mat_inv(nmod_mat_t B, const nmod_mat_t A) noexcept # Sets `B = A^{-1}` and returns `1` if `A` is invertible. # If `A` is singular, returns `0` and sets the elements of # `B` to undefined values. # `A` and `B` must be square matrices with the same dimensions # and modulus. The modulus must be prime. - void nmod_mat_solve_tril(nmod_mat_t X, const nmod_mat_t L, const nmod_mat_t B, int unit) + void nmod_mat_solve_tril(nmod_mat_t X, const nmod_mat_t L, const nmod_mat_t B, int unit) noexcept # Sets `X = L^{-1} B` where `L` is a full rank lower triangular square # matrix. If ``unit`` = 1, `L` is assumed to have ones on its # main diagonal, and the main diagonal will not be read. @@ -279,14 +279,14 @@ cdef extern from "flint_wrap.h": # aliasing is allowed. Automatically chooses between the classical and # recursive algorithms. - void nmod_mat_solve_tril_classical(nmod_mat_t X, const nmod_mat_t L, const nmod_mat_t B, int unit) + void nmod_mat_solve_tril_classical(nmod_mat_t X, const nmod_mat_t L, const nmod_mat_t B, int unit) noexcept # Sets `X = L^{-1} B` where `L` is a full rank lower triangular square # matrix. If ``unit`` = 1, `L` is assumed to have ones on its # main diagonal, and the main diagonal will not be read. # `X` and `B` are allowed to be the same matrix, but no other # aliasing is allowed. Uses forward substitution. - void nmod_mat_solve_tril_recursive(nmod_mat_t X, const nmod_mat_t L, const nmod_mat_t B, int unit) + void nmod_mat_solve_tril_recursive(nmod_mat_t X, const nmod_mat_t L, const nmod_mat_t B, int unit) noexcept # Sets `X = L^{-1} B` where `L` is a full rank lower triangular square # matrix. If ``unit`` = 1, `L` is assumed to have ones on its # main diagonal, and the main diagonal will not be read. @@ -300,7 +300,7 @@ cdef extern from "flint_wrap.h": # to reduce the problem to matrix multiplication and triangular solving # of smaller systems. - void nmod_mat_solve_triu(nmod_mat_t X, const nmod_mat_t U, const nmod_mat_t B, int unit) + void nmod_mat_solve_triu(nmod_mat_t X, const nmod_mat_t U, const nmod_mat_t B, int unit) noexcept # Sets `X = U^{-1} B` where `U` is a full rank upper triangular square # matrix. If ``unit`` = 1, `U` is assumed to have ones on its # main diagonal, and the main diagonal will not be read. @@ -308,14 +308,14 @@ cdef extern from "flint_wrap.h": # aliasing is allowed. Automatically chooses between the classical and # recursive algorithms. - void nmod_mat_solve_triu_classical(nmod_mat_t X, const nmod_mat_t U, const nmod_mat_t B, int unit) + void nmod_mat_solve_triu_classical(nmod_mat_t X, const nmod_mat_t U, const nmod_mat_t B, int unit) noexcept # Sets `X = U^{-1} B` where `U` is a full rank upper triangular square # matrix. If ``unit`` = 1, `U` is assumed to have ones on its # main diagonal, and the main diagonal will not be read. # `X` and `B` are allowed to be the same matrix, but no other # aliasing is allowed. Uses forward substitution. - void nmod_mat_solve_triu_recursive(nmod_mat_t X, const nmod_mat_t U, const nmod_mat_t B, int unit) + void nmod_mat_solve_triu_recursive(nmod_mat_t X, const nmod_mat_t U, const nmod_mat_t B, int unit) noexcept # Sets `X = U^{-1} B` where `U` is a full rank upper triangular square # matrix. If ``unit`` = 1, `U` is assumed to have ones on its # main diagonal, and the main diagonal will not be read. @@ -329,7 +329,7 @@ cdef extern from "flint_wrap.h": # to reduce the problem to matrix multiplication and triangular solving # of smaller systems. - int nmod_mat_solve(nmod_mat_t X, const nmod_mat_t A, const nmod_mat_t B) + int nmod_mat_solve(nmod_mat_t X, const nmod_mat_t A, const nmod_mat_t B) noexcept # Solves the matrix-matrix equation `AX = B` over `\mathbb{Z} / p \mathbb{Z}` where `p` # is the modulus of `X` which must be a prime number. `X`, `A`, and `B` # should have the same moduli. @@ -337,7 +337,7 @@ cdef extern from "flint_wrap.h": # elements of `X` to undefined values. # The matrix `A` must be square. - int nmod_mat_can_solve_inner(slong * rank, slong * perm, slong * pivots, nmod_mat_t X, const nmod_mat_t A, const nmod_mat_t B) + int nmod_mat_can_solve_inner(slong * rank, slong * perm, slong * pivots, nmod_mat_t X, const nmod_mat_t A, const nmod_mat_t B) noexcept # As for :func:`nmod_mat_can_solve` except that if `rank` is not `NULL` the # value it points to will be set to the rank of `A`. If `perm` is not `NULL` # then it must be a valid initialised permutation whose length is the number @@ -347,7 +347,7 @@ cdef extern from "flint_wrap.h": # set by the function call. They are set to the columns of the pivots chosen # by the LU decomposition of `A`. - int nmod_mat_can_solve(nmod_mat_t X, const nmod_mat_t A, const nmod_mat_t B) + int nmod_mat_can_solve(nmod_mat_t X, const nmod_mat_t A, const nmod_mat_t B) noexcept # Solves the matrix-matrix equation `AX = B` over `\mathbb{Z} / p \mathbb{Z}` where `p` # is the modulus of `X` which must be a prime number. `X`, `A`, and `B` # should have the same moduli. @@ -356,16 +356,16 @@ cdef extern from "flint_wrap.h": # valid solutions is given. # There are no restrictions on the shape of `A` and it may be singular. - int nmod_mat_solve_vec(mp_ptr x, const nmod_mat_t A, mp_srcptr b) + int nmod_mat_solve_vec(mp_ptr x, const nmod_mat_t A, mp_srcptr b) noexcept # Solves the matrix-vector equation `Ax = b` over `\mathbb{Z} / p \mathbb{Z}` where `p` # is the modulus of `A` which must be a prime number. # Returns `1` if `A` has full rank; otherwise returns `0` and sets the # elements of `x` to undefined values. - slong nmod_mat_lu(slong * P, nmod_mat_t A, int rank_check) - slong nmod_mat_lu_classical(slong * P, nmod_mat_t A, int rank_check) - slong nmod_mat_lu_classical_delayed(slong * P, nmod_mat_t A, int rank_check) - slong nmod_mat_lu_recursive(slong * P, nmod_mat_t A, int rank_check) + slong nmod_mat_lu(slong * P, nmod_mat_t A, int rank_check) noexcept + slong nmod_mat_lu_classical(slong * P, nmod_mat_t A, int rank_check) noexcept + slong nmod_mat_lu_classical_delayed(slong * P, nmod_mat_t A, int rank_check) noexcept + slong nmod_mat_lu_recursive(slong * P, nmod_mat_t A, int rank_check) noexcept # Computes a generalised LU decomposition `LU = PA` of a given # matrix `A`, returning the rank of `A`. # If `A` is a nonsingular square matrix, it will be overwritten with @@ -384,13 +384,13 @@ cdef extern from "flint_wrap.h": # The *recursive* version uses block recursive decomposition. # The default function chooses an algorithm automatically. - slong nmod_mat_rref(nmod_mat_t A) + slong nmod_mat_rref(nmod_mat_t A) noexcept # Puts `A` in reduced row echelon form and returns the rank of `A`. # The rref is computed by first obtaining an unreduced row echelon # form via LU decomposition and then solving an additional # triangular system. - slong nmod_mat_reduce_row(nmod_mat_t A, slong * P, slong * L, slong n) + slong nmod_mat_reduce_row(nmod_mat_t A, slong * P, slong * L, slong n) noexcept # Reduce row n of the matrix `A`, assuming the prior rows are in Gauss # form. However those rows may not be in order. The entry `i` of the array # `P` is the row of `A` which has a pivot in the `i`-th column. If no such @@ -403,7 +403,7 @@ cdef extern from "flint_wrap.h": # can all be set to the number of columns of `A`. We require the entries of # `L` to be monotonic increasing. - slong nmod_mat_nullspace(nmod_mat_t X, const nmod_mat_t A) + slong nmod_mat_nullspace(nmod_mat_t X, const nmod_mat_t A) noexcept # Computes the nullspace of `A` and returns the nullity. # More precisely, this function sets `X` to a maximum rank matrix # such that `AX = 0` and returns the rank of `X`. The columns of @@ -413,7 +413,7 @@ cdef extern from "flint_wrap.h": # This function computes the reduced row echelon form and then reads # off the basis vectors. - void nmod_mat_similarity(nmod_mat_t M, slong r, ulong d) + void nmod_mat_similarity(nmod_mat_t M, slong r, ulong d) noexcept # Applies a similarity transform to the `n\times n` matrix `M` in-place. # If `P` is the `n\times n` identity matrix the zero entries of whose row # `r` (`0`-indexed) have been replaced by `d`, this transform is equivalent @@ -423,18 +423,18 @@ cdef extern from "flint_wrap.h": # The value `d` is required to be reduced modulo the modulus of the entries # in the matrix. - void nmod_mat_charpoly_berkowitz(nmod_poly_t p, const nmod_mat_t M) - void nmod_mat_charpoly_danilevsky(nmod_poly_t p, const nmod_mat_t M) - void nmod_mat_charpoly(nmod_poly_t p, const nmod_mat_t M) + void nmod_mat_charpoly_berkowitz(nmod_poly_t p, const nmod_mat_t M) noexcept + void nmod_mat_charpoly_danilevsky(nmod_poly_t p, const nmod_mat_t M) noexcept + void nmod_mat_charpoly(nmod_poly_t p, const nmod_mat_t M) noexcept # Compute the characteristic polynomial `p` of the matrix `M`. The matrix # is required to be square, otherwise an exception is raised. # The *danilevsky* algorithm assumes that the modulus is prime. - void nmod_mat_minpoly(nmod_poly_t p, const nmod_mat_t M) + void nmod_mat_minpoly(nmod_poly_t p, const nmod_mat_t M) noexcept # Compute the minimal polynomial `p` of the matrix `M`. The matrix # is required to be square, otherwise an exception is raised. - void nmod_mat_strong_echelon_form(nmod_mat_t A) + void nmod_mat_strong_echelon_form(nmod_mat_t A) noexcept # Puts `A` into strong echelon form. The Howell form and the strong echelon # form are equal up to permutation of the rows, see [FieHof2014]_ for a # definition of the strong echelon form and the algorithm used here. @@ -443,7 +443,7 @@ cdef extern from "flint_wrap.h": # agreeing with the definition of Howell form in [StoMul1998]_. # `A` must have at least as many rows as columns. - slong nmod_mat_howell_form(nmod_mat_t A) + slong nmod_mat_howell_form(nmod_mat_t A) noexcept # Puts `A` into Howell form and returns the number of non-zero rows. # For a definition of the Howell form see [StoMul1998]_. The Howell form # is computed by first putting `A` into strong echelon form and then ordering diff --git a/src/sage/libs/flint/nmod_mpoly.pxd b/src/sage/libs/flint/nmod_mpoly.pxd index c6902fa6a5d..3083e39d480 100644 --- a/src/sage/libs/flint/nmod_mpoly.pxd +++ b/src/sage/libs/flint/nmod_mpoly.pxd @@ -12,395 +12,395 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void nmod_mpoly_ctx_init(nmod_mpoly_ctx_t ctx, slong nvars, const ordering_t ord, mp_limb_t n) + void nmod_mpoly_ctx_init(nmod_mpoly_ctx_t ctx, slong nvars, const ordering_t ord, mp_limb_t n) noexcept # Initialise a context object for a polynomial ring with the given number of variables and the given ordering. # It will have coefficients modulo *n*. Setting `n = 0` will give undefined behavior. # The possibilities for the ordering are ``ORD_LEX``, ``ORD_DEGLEX`` and ``ORD_DEGREVLEX``. - slong nmod_mpoly_ctx_nvars(const nmod_mpoly_ctx_t ctx) + slong nmod_mpoly_ctx_nvars(const nmod_mpoly_ctx_t ctx) noexcept # Return the number of variables used to initialize the context. - ordering_t nmod_mpoly_ctx_ord(const nmod_mpoly_ctx_t ctx) + ordering_t nmod_mpoly_ctx_ord(const nmod_mpoly_ctx_t ctx) noexcept # Return the ordering used to initialize the context. - mp_limb_t nmod_mpoly_ctx_modulus(const nmod_mpoly_ctx_t ctx) + mp_limb_t nmod_mpoly_ctx_modulus(const nmod_mpoly_ctx_t ctx) noexcept # Return the modulus used to initialize the context. - void nmod_mpoly_ctx_clear(nmod_mpoly_ctx_t ctx) + void nmod_mpoly_ctx_clear(nmod_mpoly_ctx_t ctx) noexcept # Release any space allocated by *ctx*. - void nmod_mpoly_init(nmod_mpoly_t A, const nmod_mpoly_ctx_t ctx) + void nmod_mpoly_init(nmod_mpoly_t A, const nmod_mpoly_ctx_t ctx) noexcept # Initialise *A* for use with the given an initialised context object. Its value is set to zero. - void nmod_mpoly_init2(nmod_mpoly_t A, slong alloc, const nmod_mpoly_ctx_t ctx) + void nmod_mpoly_init2(nmod_mpoly_t A, slong alloc, const nmod_mpoly_ctx_t ctx) noexcept # Initialise *A* for use with the given an initialised context object. Its value is set to zero. # It is allocated with space for *alloc* terms and at least ``MPOLY_MIN_BITS`` bits for the exponent widths. - void nmod_mpoly_init3(nmod_mpoly_t A, slong alloc, flint_bitcnt_t bits, const nmod_mpoly_ctx_t ctx) + void nmod_mpoly_init3(nmod_mpoly_t A, slong alloc, flint_bitcnt_t bits, const nmod_mpoly_ctx_t ctx) noexcept # Initialise *A* for use with the given an initialised context object. Its value is set to zero. # It is allocated with space for *alloc* terms and *bits* bits for the exponents. - void nmod_mpoly_fit_length(nmod_mpoly_t A, slong len, const nmod_mpoly_ctx_t ctx) + void nmod_mpoly_fit_length(nmod_mpoly_t A, slong len, const nmod_mpoly_ctx_t ctx) noexcept # Ensure that *A* has space for at least *len* terms. - void nmod_mpoly_realloc(nmod_mpoly_t A, slong alloc, const nmod_mpoly_ctx_t ctx) + void nmod_mpoly_realloc(nmod_mpoly_t A, slong alloc, const nmod_mpoly_ctx_t ctx) noexcept # Reallocate *A* to have space for *alloc* terms. # Assumes the current length of the polynomial is not greater than *alloc*. - void nmod_mpoly_clear(nmod_mpoly_t A, const nmod_mpoly_ctx_t ctx) + void nmod_mpoly_clear(nmod_mpoly_t A, const nmod_mpoly_ctx_t ctx) noexcept # Release any space allocated for *A*. - char * nmod_mpoly_get_str_pretty(const nmod_mpoly_t A, const char ** x, const nmod_mpoly_ctx_t ctx) + char * nmod_mpoly_get_str_pretty(const nmod_mpoly_t A, const char ** x, const nmod_mpoly_ctx_t ctx) noexcept # Return a string, which the user is responsible for cleaning up, representing *A*, given an array of variable strings *x*. - int nmod_mpoly_fprint_pretty(FILE * file, const nmod_mpoly_t A, const char ** x, const nmod_mpoly_ctx_t ctx) + int nmod_mpoly_fprint_pretty(FILE * file, const nmod_mpoly_t A, const char ** x, const nmod_mpoly_ctx_t ctx) noexcept # Print a string representing *A* to *file*. - int nmod_mpoly_print_pretty(const nmod_mpoly_t A, const char ** x, const nmod_mpoly_ctx_t ctx) + int nmod_mpoly_print_pretty(const nmod_mpoly_t A, const char ** x, const nmod_mpoly_ctx_t ctx) noexcept # Print a string representing *A* to ``stdout``. - int nmod_mpoly_set_str_pretty(nmod_mpoly_t A, const char * str, const char ** x, const nmod_mpoly_ctx_t ctx) + int nmod_mpoly_set_str_pretty(nmod_mpoly_t A, const char * str, const char ** x, const nmod_mpoly_ctx_t ctx) noexcept # Set *A* to the polynomial in the null-terminates string *str* given an array *x* of variable strings. # If parsing *str* fails, *A* is set to zero, and `-1` is returned. Otherwise, `0` is returned. # The operations ``+``, ``-``, ``*``, and ``/`` are permitted along with integers and the variables in *x*. The character ``^`` must be immediately followed by the (integer) exponent. # If any division is not exact, parsing fails. - void nmod_mpoly_gen(nmod_mpoly_t A, slong var, const nmod_mpoly_ctx_t ctx) + void nmod_mpoly_gen(nmod_mpoly_t A, slong var, const nmod_mpoly_ctx_t ctx) noexcept # Set *A* to the variable of index *var*, where `var = 0` corresponds to the variable with the most significance with respect to the ordering. - bint nmod_mpoly_is_gen(const nmod_mpoly_t A, slong var, const nmod_mpoly_ctx_t ctx) + bint nmod_mpoly_is_gen(const nmod_mpoly_t A, slong var, const nmod_mpoly_ctx_t ctx) noexcept # If `var \ge 0`, return `1` if *A* is equal to the `var`-th generator, otherwise return `0`. # If `var < 0`, return `1` if the polynomial is equal to any generator, otherwise return `0`. - void nmod_mpoly_set(nmod_mpoly_t A, const nmod_mpoly_t B, const nmod_mpoly_ctx_t ctx) + void nmod_mpoly_set(nmod_mpoly_t A, const nmod_mpoly_t B, const nmod_mpoly_ctx_t ctx) noexcept # Set *A* to *B*. - bint nmod_mpoly_equal(const nmod_mpoly_t A, const nmod_mpoly_t B, const nmod_mpoly_ctx_t ctx) + bint nmod_mpoly_equal(const nmod_mpoly_t A, const nmod_mpoly_t B, const nmod_mpoly_ctx_t ctx) noexcept # Return `1` if *A* is equal to *B*, else return `0`. - void nmod_mpoly_swap(nmod_mpoly_t A, nmod_mpoly_t B, const nmod_mpoly_ctx_t ctx) + void nmod_mpoly_swap(nmod_mpoly_t A, nmod_mpoly_t B, const nmod_mpoly_ctx_t ctx) noexcept # Efficiently swap *A* and *B*. - bint nmod_mpoly_is_ui(const nmod_mpoly_t A, const nmod_mpoly_ctx_t ctx) + bint nmod_mpoly_is_ui(const nmod_mpoly_t A, const nmod_mpoly_ctx_t ctx) noexcept # Return `1` if *A* is a constant, else return `0`. - ulong nmod_mpoly_get_ui(const nmod_mpoly_t A, const nmod_mpoly_ctx_t ctx) + ulong nmod_mpoly_get_ui(const nmod_mpoly_t A, const nmod_mpoly_ctx_t ctx) noexcept # Assuming that *A* is a constant, return this constant. # This function throws if *A* is not a constant. - void nmod_mpoly_set_ui(nmod_mpoly_t A, ulong c, const nmod_mpoly_ctx_t ctx) + void nmod_mpoly_set_ui(nmod_mpoly_t A, ulong c, const nmod_mpoly_ctx_t ctx) noexcept # Set *A* to the constant *c*. - void nmod_mpoly_zero(nmod_mpoly_t A, const nmod_mpoly_ctx_t ctx) + void nmod_mpoly_zero(nmod_mpoly_t A, const nmod_mpoly_ctx_t ctx) noexcept # Set *A* to the constant `0`. - void nmod_mpoly_one(nmod_mpoly_t A, const nmod_mpoly_ctx_t ctx) + void nmod_mpoly_one(nmod_mpoly_t A, const nmod_mpoly_ctx_t ctx) noexcept # Set *A* to the constant `1`. - bint nmod_mpoly_equal_ui(const nmod_mpoly_t A, ulong c, const nmod_mpoly_ctx_t ctx) + bint nmod_mpoly_equal_ui(const nmod_mpoly_t A, ulong c, const nmod_mpoly_ctx_t ctx) noexcept # Return `1` if *A* is equal to the constant *c*, else return `0`. - bint nmod_mpoly_is_zero(const nmod_mpoly_t A, const nmod_mpoly_ctx_t ctx) + bint nmod_mpoly_is_zero(const nmod_mpoly_t A, const nmod_mpoly_ctx_t ctx) noexcept # Return `1` if *A* is the constant `0`, else return `0`. - bint nmod_mpoly_is_one(const nmod_mpoly_t A, const nmod_mpoly_ctx_t ctx) + bint nmod_mpoly_is_one(const nmod_mpoly_t A, const nmod_mpoly_ctx_t ctx) noexcept # Return `1` if *A* is the constant `1`, else return `0`. - int nmod_mpoly_degrees_fit_si(const nmod_mpoly_t A, const nmod_mpoly_ctx_t ctx) + int nmod_mpoly_degrees_fit_si(const nmod_mpoly_t A, const nmod_mpoly_ctx_t ctx) noexcept # Return `1` if the degrees of *A* with respect to each variable fit into an ``slong``, otherwise return `0`. - void nmod_mpoly_degrees_fmpz(fmpz ** degs, const nmod_mpoly_t A, const nmod_mpoly_ctx_t ctx) - void nmod_mpoly_degrees_si(slong * degs, const nmod_mpoly_t A, const nmod_mpoly_ctx_t ctx) + void nmod_mpoly_degrees_fmpz(fmpz ** degs, const nmod_mpoly_t A, const nmod_mpoly_ctx_t ctx) noexcept + void nmod_mpoly_degrees_si(slong * degs, const nmod_mpoly_t A, const nmod_mpoly_ctx_t ctx) noexcept # Set *degs* to the degrees of *A* with respect to each variable. # If *A* is zero, all degrees are set to `-1`. - void nmod_mpoly_degree_fmpz(fmpz_t deg, const nmod_mpoly_t A, slong var, const nmod_mpoly_ctx_t ctx) - slong nmod_mpoly_degree_si(const nmod_mpoly_t A, slong var, const nmod_mpoly_ctx_t ctx) + void nmod_mpoly_degree_fmpz(fmpz_t deg, const nmod_mpoly_t A, slong var, const nmod_mpoly_ctx_t ctx) noexcept + slong nmod_mpoly_degree_si(const nmod_mpoly_t A, slong var, const nmod_mpoly_ctx_t ctx) noexcept # Either return or set *deg* to the degree of *A* with respect to the variable of index *var*. # If *A* is zero, the degree is defined to be `-1`. - int nmod_mpoly_total_degree_fits_si(const nmod_mpoly_t A, const nmod_mpoly_ctx_t ctx) + int nmod_mpoly_total_degree_fits_si(const nmod_mpoly_t A, const nmod_mpoly_ctx_t ctx) noexcept # Return `1` if the total degree of *A* fits into an ``slong``, otherwise return `0`. - void nmod_mpoly_total_degree_fmpz(fmpz_t tdeg, const nmod_mpoly_t A, const nmod_mpoly_ctx_t ctx) - slong nmod_mpoly_total_degree_si(const nmod_mpoly_t A, const nmod_mpoly_ctx_t ctx) + void nmod_mpoly_total_degree_fmpz(fmpz_t tdeg, const nmod_mpoly_t A, const nmod_mpoly_ctx_t ctx) noexcept + slong nmod_mpoly_total_degree_si(const nmod_mpoly_t A, const nmod_mpoly_ctx_t ctx) noexcept # Either return or set *tdeg* to the total degree of *A*. # If *A* is zero, the total degree is defined to be `-1`. - void nmod_mpoly_used_vars(int * used, const nmod_mpoly_t A, const nmod_mpoly_ctx_t ctx) + void nmod_mpoly_used_vars(int * used, const nmod_mpoly_t A, const nmod_mpoly_ctx_t ctx) noexcept # For each variable index *i*, set ``used[i]`` to nonzero if the variable of index *i* appears in *A* and to zero otherwise. - ulong nmod_mpoly_get_coeff_ui_monomial(const nmod_mpoly_t A, const nmod_mpoly_t M, const nmod_mpoly_ctx_t ctx) + ulong nmod_mpoly_get_coeff_ui_monomial(const nmod_mpoly_t A, const nmod_mpoly_t M, const nmod_mpoly_ctx_t ctx) noexcept # Assuming that *M* is a monomial, return the coefficient of the corresponding monomial in *A*. # This function throws if *M* is not a monomial. - void nmod_mpoly_set_coeff_ui_monomial(nmod_mpoly_t A, ulong c, const nmod_mpoly_t M, const nmod_mpoly_ctx_t ctx) + void nmod_mpoly_set_coeff_ui_monomial(nmod_mpoly_t A, ulong c, const nmod_mpoly_t M, const nmod_mpoly_ctx_t ctx) noexcept # Assuming that *M* is a monomial, set the coefficient of the corresponding monomial in *A* to *c*. # This function throws if *M* is not a monomial. - ulong nmod_mpoly_get_coeff_ui_fmpz(const nmod_mpoly_t A, fmpz * const * exp, const nmod_mpoly_ctx_t ctx) - ulong nmod_mpoly_get_coeff_ui_ui(const nmod_mpoly_t A, const ulong * exp, const nmod_mpoly_ctx_t ctx) + ulong nmod_mpoly_get_coeff_ui_fmpz(const nmod_mpoly_t A, fmpz * const * exp, const nmod_mpoly_ctx_t ctx) noexcept + ulong nmod_mpoly_get_coeff_ui_ui(const nmod_mpoly_t A, const ulong * exp, const nmod_mpoly_ctx_t ctx) noexcept # Return the coefficient of the monomial with exponent *exp*. - void nmod_mpoly_set_coeff_ui_fmpz(nmod_mpoly_t A, ulong c, fmpz * const * exp, const nmod_mpoly_ctx_t ctx) - void nmod_mpoly_set_coeff_ui_ui(nmod_mpoly_t A, ulong c, const ulong * exp, const nmod_mpoly_ctx_t ctx) + void nmod_mpoly_set_coeff_ui_fmpz(nmod_mpoly_t A, ulong c, fmpz * const * exp, const nmod_mpoly_ctx_t ctx) noexcept + void nmod_mpoly_set_coeff_ui_ui(nmod_mpoly_t A, ulong c, const ulong * exp, const nmod_mpoly_ctx_t ctx) noexcept # Set the coefficient of the monomial with exponent *exp* to `c`. - void nmod_mpoly_get_coeff_vars_ui(nmod_mpoly_t C, const nmod_mpoly_t A, const slong * vars, const ulong * exps, slong length, const nmod_mpoly_ctx_t ctx) + void nmod_mpoly_get_coeff_vars_ui(nmod_mpoly_t C, const nmod_mpoly_t A, const slong * vars, const ulong * exps, slong length, const nmod_mpoly_ctx_t ctx) noexcept # Set *C* to the coefficient of *A* with respect to the variables in *vars* with powers in the corresponding array *exps*. # Both *vars* and *exps* point to array of length *length*. It is assumed that ``0 < length \le nvars(A)`` and that the variables in *vars* are distinct. - int nmod_mpoly_cmp(const nmod_mpoly_t A, const nmod_mpoly_t B, const nmod_mpoly_ctx_t ctx) + int nmod_mpoly_cmp(const nmod_mpoly_t A, const nmod_mpoly_t B, const nmod_mpoly_ctx_t ctx) noexcept # Return `1` (resp. `-1`, or `0`) if *A* is after (resp. before, same as) *B* in some arbitrary but fixed total ordering of the polynomials. # This ordering agrees with the usual ordering of monomials when *A* and *B* are both monomials. - mp_limb_t * nmod_mpoly_term_coeff_ref(nmod_mpoly_t A, slong i, const nmod_mpoly_ctx_t ctx) + mp_limb_t * nmod_mpoly_term_coeff_ref(nmod_mpoly_t A, slong i, const nmod_mpoly_ctx_t ctx) noexcept # Return a reference to the coefficient of index *i* of *A*. - bint nmod_mpoly_is_canonical(const nmod_mpoly_t A, const nmod_mpoly_ctx_t ctx) + bint nmod_mpoly_is_canonical(const nmod_mpoly_t A, const nmod_mpoly_ctx_t ctx) noexcept # Return `1` if *A* is in canonical form. Otherwise, return `0`. # To be in canonical form, all of the terms must have nonzero coefficients, and the terms must be sorted from greatest to least. - slong nmod_mpoly_length(const nmod_mpoly_t A, const nmod_mpoly_ctx_t ctx) + slong nmod_mpoly_length(const nmod_mpoly_t A, const nmod_mpoly_ctx_t ctx) noexcept # Return the number of terms in *A*. # If the polynomial is in canonical form, this will be the number of nonzero coefficients. - void nmod_mpoly_resize(nmod_mpoly_t A, slong new_length, const nmod_mpoly_ctx_t ctx) + void nmod_mpoly_resize(nmod_mpoly_t A, slong new_length, const nmod_mpoly_ctx_t ctx) noexcept # Set the length of *A* to ``new_length``. # Terms are either deleted from the end, or new zero terms are appended. - ulong nmod_mpoly_get_term_coeff_ui(const nmod_mpoly_t A, slong i, const nmod_mpoly_ctx_t ctx) + ulong nmod_mpoly_get_term_coeff_ui(const nmod_mpoly_t A, slong i, const nmod_mpoly_ctx_t ctx) noexcept # Return the coefficient of the term of index *i*. - void nmod_mpoly_set_term_coeff_ui(nmod_mpoly_t A, slong i, ulong c, const nmod_mpoly_ctx_t ctx) + void nmod_mpoly_set_term_coeff_ui(nmod_mpoly_t A, slong i, ulong c, const nmod_mpoly_ctx_t ctx) noexcept # Set the coefficient of the term of index *i* to *c*. - int nmod_mpoly_term_exp_fits_si(const nmod_mpoly_t A, slong i, const nmod_mpoly_ctx_t ctx) - int nmod_mpoly_term_exp_fits_ui(const nmod_mpoly_t A, slong i, const nmod_mpoly_ctx_t ctx) + int nmod_mpoly_term_exp_fits_si(const nmod_mpoly_t A, slong i, const nmod_mpoly_ctx_t ctx) noexcept + int nmod_mpoly_term_exp_fits_ui(const nmod_mpoly_t A, slong i, const nmod_mpoly_ctx_t ctx) noexcept # Return `1` if all entries of the exponent vector of the term of index *i* fit into an ``slong`` (resp. a ``ulong``). Otherwise, return `0`. - void nmod_mpoly_get_term_exp_fmpz(fmpz ** exp, const nmod_mpoly_t A, slong i, const nmod_mpoly_ctx_t ctx) - void nmod_mpoly_get_term_exp_ui(ulong * exp, const nmod_mpoly_t A, slong i, const nmod_mpoly_ctx_t ctx) + void nmod_mpoly_get_term_exp_fmpz(fmpz ** exp, const nmod_mpoly_t A, slong i, const nmod_mpoly_ctx_t ctx) noexcept + void nmod_mpoly_get_term_exp_ui(ulong * exp, const nmod_mpoly_t A, slong i, const nmod_mpoly_ctx_t ctx) noexcept - void nmod_mpoly_get_term_exp_si(slong * exp, const nmod_mpoly_t A, slong i, const nmod_mpoly_ctx_t ctx) + void nmod_mpoly_get_term_exp_si(slong * exp, const nmod_mpoly_t A, slong i, const nmod_mpoly_ctx_t ctx) noexcept # Set *exp* to the exponent vector of the term of index *i*. # The ``_ui`` (resp. ``_si``) version throws if any entry does not fit into a ``ulong`` (resp. ``slong``). - ulong nmod_mpoly_get_term_var_exp_ui(const nmod_mpoly_t A, slong i, slong var, const nmod_mpoly_ctx_t ctx) - slong nmod_mpoly_get_term_var_exp_si(const nmod_mpoly_t A, slong i, slong var, const nmod_mpoly_ctx_t ctx) + ulong nmod_mpoly_get_term_var_exp_ui(const nmod_mpoly_t A, slong i, slong var, const nmod_mpoly_ctx_t ctx) noexcept + slong nmod_mpoly_get_term_var_exp_si(const nmod_mpoly_t A, slong i, slong var, const nmod_mpoly_ctx_t ctx) noexcept # Return the exponent of the variable *var* of the term of index *i*. # This function throws if the exponent does not fit into a ``ulong`` (resp. ``slong``). - void nmod_mpoly_set_term_exp_fmpz(nmod_mpoly_t A, slong i, fmpz * const * exp, const nmod_mpoly_ctx_t ctx) - void nmod_mpoly_set_term_exp_ui(nmod_mpoly_t A, slong i, const ulong * exp, const nmod_mpoly_ctx_t ctx) + void nmod_mpoly_set_term_exp_fmpz(nmod_mpoly_t A, slong i, fmpz * const * exp, const nmod_mpoly_ctx_t ctx) noexcept + void nmod_mpoly_set_term_exp_ui(nmod_mpoly_t A, slong i, const ulong * exp, const nmod_mpoly_ctx_t ctx) noexcept # Set the exponent of the term of index *i* to *exp*. - void nmod_mpoly_get_term(nmod_mpoly_t M, const nmod_mpoly_t A, slong i, const nmod_mpoly_ctx_t ctx) + void nmod_mpoly_get_term(nmod_mpoly_t M, const nmod_mpoly_t A, slong i, const nmod_mpoly_ctx_t ctx) noexcept # Set *M* to the term of index *i* in *A*. - void nmod_mpoly_get_term_monomial(nmod_mpoly_t M, const nmod_mpoly_t A, slong i, const nmod_mpoly_ctx_t ctx) + void nmod_mpoly_get_term_monomial(nmod_mpoly_t M, const nmod_mpoly_t A, slong i, const nmod_mpoly_ctx_t ctx) noexcept # Set *M* to the monomial of the term of index *i* in *A*. The coefficient of *M* will be one. - void nmod_mpoly_push_term_ui_fmpz(nmod_mpoly_t A, ulong c, fmpz * const * exp, const nmod_mpoly_ctx_t ctx) - void nmod_mpoly_push_term_ui_ffmpz(nmod_mpoly_t A, ulong c, const fmpz * exp, const nmod_mpoly_ctx_t ctx) - void nmod_mpoly_push_term_ui_ui(nmod_mpoly_t A, ulong c, const ulong * exp, const nmod_mpoly_ctx_t ctx) + void nmod_mpoly_push_term_ui_fmpz(nmod_mpoly_t A, ulong c, fmpz * const * exp, const nmod_mpoly_ctx_t ctx) noexcept + void nmod_mpoly_push_term_ui_ffmpz(nmod_mpoly_t A, ulong c, const fmpz * exp, const nmod_mpoly_ctx_t ctx) noexcept + void nmod_mpoly_push_term_ui_ui(nmod_mpoly_t A, ulong c, const ulong * exp, const nmod_mpoly_ctx_t ctx) noexcept # Append a term to *A* with coefficient *c* and exponent vector *exp*. # This function runs in constant average time. - void nmod_mpoly_sort_terms(nmod_mpoly_t A, const nmod_mpoly_ctx_t ctx) + void nmod_mpoly_sort_terms(nmod_mpoly_t A, const nmod_mpoly_ctx_t ctx) noexcept # Sort the terms of *A* into the canonical ordering dictated by the ordering in *ctx*. # This function simply reorders the terms: It does not combine like terms, nor does it delete terms with coefficient zero. # This function runs in linear time in the bit size of *A*. - void nmod_mpoly_combine_like_terms(nmod_mpoly_t A, const nmod_mpoly_ctx_t ctx) + void nmod_mpoly_combine_like_terms(nmod_mpoly_t A, const nmod_mpoly_ctx_t ctx) noexcept # Combine adjacent like terms in *A* and delete terms with coefficient zero. # If the terms of *A* were sorted to begin with, the result will be in canonical form. # This function runs in linear time in the bit size of *A*. - void nmod_mpoly_reverse(nmod_mpoly_t A, const nmod_mpoly_t B, const nmod_mpoly_ctx_t ctx) + void nmod_mpoly_reverse(nmod_mpoly_t A, const nmod_mpoly_t B, const nmod_mpoly_ctx_t ctx) noexcept # Set *A* to the reversal of *B*. - void nmod_mpoly_randtest_bound(nmod_mpoly_t A, flint_rand_t state, slong length, ulong exp_bound, const nmod_mpoly_ctx_t ctx) + void nmod_mpoly_randtest_bound(nmod_mpoly_t A, flint_rand_t state, slong length, ulong exp_bound, const nmod_mpoly_ctx_t ctx) noexcept # Generate a random polynomial with length up to *length* and exponents in the range ``[0, exp_bound - 1]``. # The exponents of each variable are generated by calls to ``n_randint(state, exp_bound)``. - void nmod_mpoly_randtest_bounds(nmod_mpoly_t A, flint_rand_t state, slong length, ulong * exp_bounds, const nmod_mpoly_ctx_t ctx) + void nmod_mpoly_randtest_bounds(nmod_mpoly_t A, flint_rand_t state, slong length, ulong * exp_bounds, const nmod_mpoly_ctx_t ctx) noexcept # Generate a random polynomial with length up to *length* and exponents in the range ``[0, exp_bounds[i] - 1]``. # The exponents of the variable of index *i* are generated by calls to ``n_randint(state, exp_bounds[i])``. - void nmod_mpoly_randtest_bits(nmod_mpoly_t A, flint_rand_t state, slong length, mp_limb_t exp_bits, const nmod_mpoly_ctx_t ctx) + void nmod_mpoly_randtest_bits(nmod_mpoly_t A, flint_rand_t state, slong length, mp_limb_t exp_bits, const nmod_mpoly_ctx_t ctx) noexcept # Generate a random polynomial with length up to *length* and exponents whose packed form does not exceed the given bit count. - void nmod_mpoly_add_ui(nmod_mpoly_t A, const nmod_mpoly_t B, ulong c, const nmod_mpoly_ctx_t ctx) + void nmod_mpoly_add_ui(nmod_mpoly_t A, const nmod_mpoly_t B, ulong c, const nmod_mpoly_ctx_t ctx) noexcept # Set *A* to `B + c`. - void nmod_mpoly_sub_ui(nmod_mpoly_t A, const nmod_mpoly_t B, ulong c, const nmod_mpoly_ctx_t ctx) + void nmod_mpoly_sub_ui(nmod_mpoly_t A, const nmod_mpoly_t B, ulong c, const nmod_mpoly_ctx_t ctx) noexcept # Set *A* to `B - c`. - void nmod_mpoly_add(nmod_mpoly_t A, const nmod_mpoly_t B, const nmod_mpoly_t C, const nmod_mpoly_ctx_t ctx) + void nmod_mpoly_add(nmod_mpoly_t A, const nmod_mpoly_t B, const nmod_mpoly_t C, const nmod_mpoly_ctx_t ctx) noexcept # Set *A* to `B + C`. - void nmod_mpoly_sub(nmod_mpoly_t A, const nmod_mpoly_t B, const nmod_mpoly_t C, const nmod_mpoly_ctx_t ctx) + void nmod_mpoly_sub(nmod_mpoly_t A, const nmod_mpoly_t B, const nmod_mpoly_t C, const nmod_mpoly_ctx_t ctx) noexcept # Set *A* to `B - C`. - void nmod_mpoly_neg(nmod_mpoly_t A, const nmod_mpoly_t B, const nmod_mpoly_ctx_t ctx) + void nmod_mpoly_neg(nmod_mpoly_t A, const nmod_mpoly_t B, const nmod_mpoly_ctx_t ctx) noexcept # Set *A* to `-B`. - void nmod_mpoly_scalar_mul_ui(nmod_mpoly_t A, const nmod_mpoly_t B, ulong c, const nmod_mpoly_ctx_t ctx) + void nmod_mpoly_scalar_mul_ui(nmod_mpoly_t A, const nmod_mpoly_t B, ulong c, const nmod_mpoly_ctx_t ctx) noexcept # Set *A* to `B \times c`. - void nmod_mpoly_make_monic(nmod_mpoly_t A, const nmod_mpoly_t B, const nmod_mpoly_ctx_t ctx) + void nmod_mpoly_make_monic(nmod_mpoly_t A, const nmod_mpoly_t B, const nmod_mpoly_ctx_t ctx) noexcept # Set *A* to *B* divided by the leading coefficient of *B*. # This throws if *B* is zero or the leading coefficient is not invertible. - void nmod_mpoly_derivative(nmod_mpoly_t A, const nmod_mpoly_t B, slong var, const nmod_mpoly_ctx_t ctx) + void nmod_mpoly_derivative(nmod_mpoly_t A, const nmod_mpoly_t B, slong var, const nmod_mpoly_ctx_t ctx) noexcept # Set *A* to the derivative of *B* with respect to the variable of index *var*. - ulong nmod_mpoly_evaluate_all_ui(const nmod_mpoly_t A, const ulong * vals, const nmod_mpoly_ctx_t ctx) + ulong nmod_mpoly_evaluate_all_ui(const nmod_mpoly_t A, const ulong * vals, const nmod_mpoly_ctx_t ctx) noexcept # Return the evaluation of *A* where the variables are replaced by the corresponding elements of the array *vals*. - void nmod_mpoly_evaluate_one_ui(nmod_mpoly_t A, const nmod_mpoly_t B, slong var, ulong val, const nmod_mpoly_ctx_t ctx) + void nmod_mpoly_evaluate_one_ui(nmod_mpoly_t A, const nmod_mpoly_t B, slong var, ulong val, const nmod_mpoly_ctx_t ctx) noexcept # Set *A* to the evaluation of *B* where the variable of index *var* is replaced by *val*. - int nmod_mpoly_compose_nmod_poly(nmod_poly_t A, const nmod_mpoly_t B, nmod_poly_struct * const * C, const nmod_mpoly_ctx_t ctx) + int nmod_mpoly_compose_nmod_poly(nmod_poly_t A, const nmod_mpoly_t B, nmod_poly_struct * const * C, const nmod_mpoly_ctx_t ctx) noexcept # Set *A* to the evaluation of *B* where the variables are replaced by the corresponding elements of the array *C*. # The context object of *B* is *ctxB*. # Return `1` for success and `0` for failure. - int nmod_mpoly_compose_nmod_mpoly_geobucket(nmod_mpoly_t A, const nmod_mpoly_t B, nmod_mpoly_struct * const * C, const nmod_mpoly_ctx_t ctxB, const nmod_mpoly_ctx_t ctxAC) - int nmod_mpoly_compose_nmod_mpoly_horner(nmod_mpoly_t A, const nmod_mpoly_t B, nmod_mpoly_struct * const * C, const nmod_mpoly_ctx_t ctxB, const nmod_mpoly_ctx_t ctxAC) - int nmod_mpoly_compose_nmod_mpoly(nmod_mpoly_t A, const nmod_mpoly_t B, nmod_mpoly_struct * const * C, const nmod_mpoly_ctx_t ctxB, const nmod_mpoly_ctx_t ctxAC) + int nmod_mpoly_compose_nmod_mpoly_geobucket(nmod_mpoly_t A, const nmod_mpoly_t B, nmod_mpoly_struct * const * C, const nmod_mpoly_ctx_t ctxB, const nmod_mpoly_ctx_t ctxAC) noexcept + int nmod_mpoly_compose_nmod_mpoly_horner(nmod_mpoly_t A, const nmod_mpoly_t B, nmod_mpoly_struct * const * C, const nmod_mpoly_ctx_t ctxB, const nmod_mpoly_ctx_t ctxAC) noexcept + int nmod_mpoly_compose_nmod_mpoly(nmod_mpoly_t A, const nmod_mpoly_t B, nmod_mpoly_struct * const * C, const nmod_mpoly_ctx_t ctxB, const nmod_mpoly_ctx_t ctxAC) noexcept # Set *A* to the evaluation of *B* where the variables are replaced by the corresponding elements of the array *C*. # Both *A* and the elements of *C* have context object *ctxAC*, while *B* has context object *ctxB*. # Neither of *A* and *B* is allowed to alias any other polynomial. # Return `1` for success and `0` for failure. # The main method attempts to perform the calculation using matrices and chooses heuristically between the ``geobucket`` and ``horner`` methods if needed. - void nmod_mpoly_compose_nmod_mpoly_gen(nmod_mpoly_t A, const nmod_mpoly_t B, const slong * c, const nmod_mpoly_ctx_t ctxB, const nmod_mpoly_ctx_t ctxAC) + void nmod_mpoly_compose_nmod_mpoly_gen(nmod_mpoly_t A, const nmod_mpoly_t B, const slong * c, const nmod_mpoly_ctx_t ctxB, const nmod_mpoly_ctx_t ctxAC) noexcept # Set *A* to the evaluation of *B* where the variable of index *i* in *ctxB* is replaced by the variable of index ``c[i]`` in *ctxAC*. # The length of the array *C* is the number of variables in *ctxB*. # If any ``c[i]`` is negative, the corresponding variable of *B* is replaced by zero. Otherwise, it is expected that ``c[i]`` is less than the number of variables in *ctxAC*. - void nmod_mpoly_mul(nmod_mpoly_t A, const nmod_mpoly_t B, const nmod_mpoly_t C, const nmod_mpoly_ctx_t ctx) + void nmod_mpoly_mul(nmod_mpoly_t A, const nmod_mpoly_t B, const nmod_mpoly_t C, const nmod_mpoly_ctx_t ctx) noexcept # Set *A* to `B \times C`. - void nmod_mpoly_mul_johnson(nmod_mpoly_t A, const nmod_mpoly_t B, const nmod_mpoly_t C, const nmod_mpoly_ctx_t ctx) - void nmod_mpoly_mul_heap_threaded(nmod_mpoly_t A, const nmod_mpoly_t B, const nmod_mpoly_t C, const nmod_mpoly_ctx_t ctx) + void nmod_mpoly_mul_johnson(nmod_mpoly_t A, const nmod_mpoly_t B, const nmod_mpoly_t C, const nmod_mpoly_ctx_t ctx) noexcept + void nmod_mpoly_mul_heap_threaded(nmod_mpoly_t A, const nmod_mpoly_t B, const nmod_mpoly_t C, const nmod_mpoly_ctx_t ctx) noexcept # Set *A* to `B \times C` using Johnson's heap-based method. # The first version always uses one thread. - int nmod_mpoly_mul_array(nmod_mpoly_t A, const nmod_mpoly_t B, const nmod_mpoly_t C, const nmod_mpoly_ctx_t ctx) - int nmod_mpoly_mul_array_threaded(nmod_mpoly_t A, const nmod_mpoly_t B, const nmod_mpoly_t C, const nmod_mpoly_ctx_t ctx) + int nmod_mpoly_mul_array(nmod_mpoly_t A, const nmod_mpoly_t B, const nmod_mpoly_t C, const nmod_mpoly_ctx_t ctx) noexcept + int nmod_mpoly_mul_array_threaded(nmod_mpoly_t A, const nmod_mpoly_t B, const nmod_mpoly_t C, const nmod_mpoly_ctx_t ctx) noexcept # Try to set *A* to `B \times C` using arrays. # If the return is `0`, the operation was unsuccessful. Otherwise, it was successful, and the return is `1`. # The first version always uses one thread. - int nmod_mpoly_mul_dense(nmod_mpoly_t A, const nmod_mpoly_t B, const nmod_mpoly_t C, const nmod_mpoly_ctx_t ctx) + int nmod_mpoly_mul_dense(nmod_mpoly_t A, const nmod_mpoly_t B, const nmod_mpoly_t C, const nmod_mpoly_ctx_t ctx) noexcept # Try to set *A* to `B \times C` using univariate arithmetic. # If the return is `0`, the operation was unsuccessful. Otherwise, it was successful and the return is `1`. - int nmod_mpoly_pow_fmpz(nmod_mpoly_t A, const nmod_mpoly_t B, const fmpz_t k, const nmod_mpoly_ctx_t ctx) + int nmod_mpoly_pow_fmpz(nmod_mpoly_t A, const nmod_mpoly_t B, const fmpz_t k, const nmod_mpoly_ctx_t ctx) noexcept # Set *A* to *B* raised to the *k*-th power. # Return `1` for success and `0` for failure. - int nmod_mpoly_pow_ui(nmod_mpoly_t A, const nmod_mpoly_t B, ulong k, const nmod_mpoly_ctx_t ctx) + int nmod_mpoly_pow_ui(nmod_mpoly_t A, const nmod_mpoly_t B, ulong k, const nmod_mpoly_ctx_t ctx) noexcept # Set *A* to *B* raised to the *k*-th power. # Return `1` for success and `0` for failure. - int nmod_mpoly_divides(nmod_mpoly_t Q, const nmod_mpoly_t A, const nmod_mpoly_t B, const nmod_mpoly_ctx_t ctx) + int nmod_mpoly_divides(nmod_mpoly_t Q, const nmod_mpoly_t A, const nmod_mpoly_t B, const nmod_mpoly_ctx_t ctx) noexcept # If *A* is divisible by *B*, set *Q* to the exact quotient and return `1`. Otherwise, set *Q* to zero and return `0`. # Note that the function ``nmod_mpoly_div`` below may be faster if the quotient is known to be exact. - void nmod_mpoly_div(nmod_mpoly_t Q, const nmod_mpoly_t A, const nmod_mpoly_t B, const nmod_mpoly_ctx_t ctx) + void nmod_mpoly_div(nmod_mpoly_t Q, const nmod_mpoly_t A, const nmod_mpoly_t B, const nmod_mpoly_ctx_t ctx) noexcept # Set *Q* to the quotient of *A* by *B*, discarding the remainder. - void nmod_mpoly_divrem(nmod_mpoly_t Q, nmod_mpoly_t R, const nmod_mpoly_t A, const nmod_mpoly_t B, const nmod_mpoly_ctx_t ctx) + void nmod_mpoly_divrem(nmod_mpoly_t Q, nmod_mpoly_t R, const nmod_mpoly_t A, const nmod_mpoly_t B, const nmod_mpoly_ctx_t ctx) noexcept # Set *Q* and *R* to the quotient and remainder of *A* divided by *B*. - void nmod_mpoly_divrem_ideal(nmod_mpoly_struct ** Q, nmod_mpoly_t R, const nmod_mpoly_t A, nmod_mpoly_struct * const * B, slong len, const nmod_mpoly_ctx_t ctx) + void nmod_mpoly_divrem_ideal(nmod_mpoly_struct ** Q, nmod_mpoly_t R, const nmod_mpoly_t A, nmod_mpoly_struct * const * B, slong len, const nmod_mpoly_ctx_t ctx) noexcept # This function is as per :func:`nmod_mpoly_divrem` except that it takes an array of divisor polynomials *B* and it returns an array of quotient polynomials *Q*. # The number of divisor (and hence quotient) polynomials, is given by *len*. - int nmod_mpoly_divides_dense(nmod_mpoly_t Q, const nmod_mpoly_t A, const nmod_mpoly_t B, const nmod_mpoly_ctx_t ctx) + int nmod_mpoly_divides_dense(nmod_mpoly_t Q, const nmod_mpoly_t A, const nmod_mpoly_t B, const nmod_mpoly_ctx_t ctx) noexcept # Try to do the operation of ``nmod_mpoly_divides`` using univariate arithmetic. # If the return is `-1`, the operation was unsuccessful. Otherwise, it was successful and the return is `0` or `1`. - int nmod_mpoly_divides_monagan_pearce(nmod_mpoly_t Q, const nmod_mpoly_t A, const nmod_mpoly_t B, const nmod_mpoly_ctx_t ctx) + int nmod_mpoly_divides_monagan_pearce(nmod_mpoly_t Q, const nmod_mpoly_t A, const nmod_mpoly_t B, const nmod_mpoly_ctx_t ctx) noexcept # Do the operation of ``nmod_mpoly_divides`` using the algorithm of Michael Monagan and Roman Pearce. - int nmod_mpoly_divides_heap_threaded(nmod_mpoly_t Q, const nmod_mpoly_t A, const nmod_mpoly_t B, const nmod_mpoly_ctx_t ctx) + int nmod_mpoly_divides_heap_threaded(nmod_mpoly_t Q, const nmod_mpoly_t A, const nmod_mpoly_t B, const nmod_mpoly_ctx_t ctx) noexcept # Do the operation of ``nmod_mpoly_divides`` using a heap and multiple threads. # This function should only be called once ``global_thread_pool`` has been initialized. - void nmod_mpoly_term_content(nmod_mpoly_t M, const nmod_mpoly_t A, const nmod_mpoly_ctx_t ctx) + void nmod_mpoly_term_content(nmod_mpoly_t M, const nmod_mpoly_t A, const nmod_mpoly_ctx_t ctx) noexcept # Set *M* to the GCD of the terms of *A*. # If *A* is zero, *M* will be zero. Otherwise, *M* will be a monomial with coefficient one. - int nmod_mpoly_content_vars(nmod_mpoly_t g, const nmod_mpoly_t A, slong * vars, slong vars_length, const nmod_mpoly_ctx_t ctx) + int nmod_mpoly_content_vars(nmod_mpoly_t g, const nmod_mpoly_t A, slong * vars, slong vars_length, const nmod_mpoly_ctx_t ctx) noexcept # Set *g* to the GCD of the coefficients of *A* when viewed as a polynomial in the variables *vars*. # Return `1` for success and `0` for failure. Upon success, *g* will be independent of the variables *vars*. - int nmod_mpoly_gcd(nmod_mpoly_t G, const nmod_mpoly_t A, const nmod_mpoly_t B, const nmod_mpoly_ctx_t ctx) + int nmod_mpoly_gcd(nmod_mpoly_t G, const nmod_mpoly_t A, const nmod_mpoly_t B, const nmod_mpoly_ctx_t ctx) noexcept # Try to set *G* to the monic GCD of *A* and *B*. The GCD of zero and zero is defined to be zero. # If the return is `1` the function was successful. Otherwise the return is `0` and *G* is left untouched. - int nmod_mpoly_gcd_cofactors(nmod_mpoly_t G, nmod_mpoly_t Abar, nmod_mpoly_t Bbar, const nmod_mpoly_t A, const nmod_mpoly_t B, const nmod_mpoly_ctx_t ctx) + int nmod_mpoly_gcd_cofactors(nmod_mpoly_t G, nmod_mpoly_t Abar, nmod_mpoly_t Bbar, const nmod_mpoly_t A, const nmod_mpoly_t B, const nmod_mpoly_ctx_t ctx) noexcept # Do the operation of :func:`nmod_mpoly_gcd` and also compute `Abar = A/G` and `Bbar = B/G` if successful. - int nmod_mpoly_gcd_brown(nmod_mpoly_t G, const nmod_mpoly_t A, const nmod_mpoly_t B, const nmod_mpoly_ctx_t ctx) - int nmod_mpoly_gcd_hensel(nmod_mpoly_t G, const nmod_mpoly_t A, const nmod_mpoly_t B, const nmod_mpoly_ctx_t ctx) - int nmod_mpoly_gcd_zippel(nmod_mpoly_t G, const nmod_mpoly_t A, const nmod_mpoly_t B, const nmod_mpoly_ctx_t ctx) + int nmod_mpoly_gcd_brown(nmod_mpoly_t G, const nmod_mpoly_t A, const nmod_mpoly_t B, const nmod_mpoly_ctx_t ctx) noexcept + int nmod_mpoly_gcd_hensel(nmod_mpoly_t G, const nmod_mpoly_t A, const nmod_mpoly_t B, const nmod_mpoly_ctx_t ctx) noexcept + int nmod_mpoly_gcd_zippel(nmod_mpoly_t G, const nmod_mpoly_t A, const nmod_mpoly_t B, const nmod_mpoly_ctx_t ctx) noexcept # Try to set *G* to the GCD of *A* and *B* using various algorithms. - int nmod_mpoly_resultant(nmod_mpoly_t R, const nmod_mpoly_t A, const nmod_mpoly_t B, slong var, const nmod_mpoly_ctx_t ctx) + int nmod_mpoly_resultant(nmod_mpoly_t R, const nmod_mpoly_t A, const nmod_mpoly_t B, slong var, const nmod_mpoly_ctx_t ctx) noexcept # Try to set *R* to the resultant of *A* and *B* with respect to the variable of index *var*. - int nmod_mpoly_discriminant(nmod_mpoly_t D, const nmod_mpoly_t A, slong var, const nmod_mpoly_ctx_t ctx) + int nmod_mpoly_discriminant(nmod_mpoly_t D, const nmod_mpoly_t A, slong var, const nmod_mpoly_ctx_t ctx) noexcept # Try to set *D* to the discriminant of *A* with respect to the variable of index *var*. - int nmod_mpoly_sqrt(nmod_mpoly_t Q, const nmod_mpoly_t A, const nmod_mpoly_ctx_t ctx) + int nmod_mpoly_sqrt(nmod_mpoly_t Q, const nmod_mpoly_t A, const nmod_mpoly_ctx_t ctx) noexcept # If `Q^2=A` has a solution, set *Q* to a solution and return `1`, otherwise return `0` and set *Q* to zero. - bint nmod_mpoly_is_square(const nmod_mpoly_t A, const nmod_mpoly_ctx_t ctx) + bint nmod_mpoly_is_square(const nmod_mpoly_t A, const nmod_mpoly_ctx_t ctx) noexcept # Return `1` if *A* is a perfect square, otherwise return `0`. - int nmod_mpoly_quadratic_root(nmod_mpoly_t Q, const nmod_mpoly_t A, const nmod_mpoly_t B, const nmod_mpoly_ctx_t ctx) + int nmod_mpoly_quadratic_root(nmod_mpoly_t Q, const nmod_mpoly_t A, const nmod_mpoly_t B, const nmod_mpoly_ctx_t ctx) noexcept # If `Q^2+AQ=B` has a solution, set *Q* to a solution and return `1`, otherwise return `0`. - void nmod_mpoly_univar_init(nmod_mpoly_univar_t A, const nmod_mpoly_ctx_t ctx) + void nmod_mpoly_univar_init(nmod_mpoly_univar_t A, const nmod_mpoly_ctx_t ctx) noexcept # Initialize *A*. - void nmod_mpoly_univar_clear(nmod_mpoly_univar_t A, const nmod_mpoly_ctx_t ctx) + void nmod_mpoly_univar_clear(nmod_mpoly_univar_t A, const nmod_mpoly_ctx_t ctx) noexcept # Clear *A*. - void nmod_mpoly_univar_swap(nmod_mpoly_univar_t A, nmod_mpoly_univar_t B, const nmod_mpoly_ctx_t ctx) + void nmod_mpoly_univar_swap(nmod_mpoly_univar_t A, nmod_mpoly_univar_t B, const nmod_mpoly_ctx_t ctx) noexcept # Swap *A* and *B*. - void nmod_mpoly_to_univar(nmod_mpoly_univar_t A, const nmod_mpoly_t B, slong var, const nmod_mpoly_ctx_t ctx) + void nmod_mpoly_to_univar(nmod_mpoly_univar_t A, const nmod_mpoly_t B, slong var, const nmod_mpoly_ctx_t ctx) noexcept # Set *A* to a univariate form of *B* by pulling out the variable of index *var*. # The coefficients of *A* will still belong to the content *ctx* but will not depend on the variable of index *var*. - void nmod_mpoly_from_univar(nmod_mpoly_t A, const nmod_mpoly_univar_t B, slong var, const nmod_mpoly_ctx_t ctx) + void nmod_mpoly_from_univar(nmod_mpoly_t A, const nmod_mpoly_univar_t B, slong var, const nmod_mpoly_ctx_t ctx) noexcept # Set *A* to the normal form of *B* by putting in the variable of index *var*. # This function is undefined if the coefficients of *B* depend on the variable of index *var*. - int nmod_mpoly_univar_degree_fits_si(const nmod_mpoly_univar_t A, const nmod_mpoly_ctx_t ctx) + int nmod_mpoly_univar_degree_fits_si(const nmod_mpoly_univar_t A, const nmod_mpoly_ctx_t ctx) noexcept # Return `1` if the degree of *A* with respect to the main variable fits an ``slong``. Otherwise, return `0`. - slong nmod_mpoly_univar_length(const nmod_mpoly_univar_t A, const nmod_mpoly_ctx_t ctx) + slong nmod_mpoly_univar_length(const nmod_mpoly_univar_t A, const nmod_mpoly_ctx_t ctx) noexcept # Return the number of terms in *A* with respect to the main variable. - slong nmod_mpoly_univar_get_term_exp_si(nmod_mpoly_univar_t A, slong i, const nmod_mpoly_ctx_t ctx) + slong nmod_mpoly_univar_get_term_exp_si(nmod_mpoly_univar_t A, slong i, const nmod_mpoly_ctx_t ctx) noexcept # Return the exponent of the term of index *i* of *A*. - void nmod_mpoly_univar_get_term_coeff(nmod_mpoly_t c, const nmod_mpoly_univar_t A, slong i, const nmod_mpoly_ctx_t ctx) - void nmod_mpoly_univar_swap_term_coeff(nmod_mpoly_t c, nmod_mpoly_univar_t A, slong i, const nmod_mpoly_ctx_t ctx) + void nmod_mpoly_univar_get_term_coeff(nmod_mpoly_t c, const nmod_mpoly_univar_t A, slong i, const nmod_mpoly_ctx_t ctx) noexcept + void nmod_mpoly_univar_swap_term_coeff(nmod_mpoly_t c, nmod_mpoly_univar_t A, slong i, const nmod_mpoly_ctx_t ctx) noexcept # Set (resp. swap) *c* to (resp. with) the coefficient of the term of index *i* of *A*. - void nmod_mpoly_pow_rmul(nmod_mpoly_t A, const nmod_mpoly_t B, ulong k, const nmod_mpoly_ctx_t ctx) + void nmod_mpoly_pow_rmul(nmod_mpoly_t A, const nmod_mpoly_t B, ulong k, const nmod_mpoly_ctx_t ctx) noexcept # Set *A* to *B* raised to the *k*-th power using repeated multiplications. - void nmod_mpoly_div_monagan_pearce(nmod_mpoly_t polyq, const nmod_mpoly_t poly2, const nmod_mpoly_t poly3, const nmod_mpoly_ctx_t ctx) + void nmod_mpoly_div_monagan_pearce(nmod_mpoly_t polyq, const nmod_mpoly_t poly2, const nmod_mpoly_t poly3, const nmod_mpoly_ctx_t ctx) noexcept # Set ``polyq`` to the quotient of ``poly2`` by ``poly3``, # discarding the remainder (with notional remainder coefficients reduced # modulo the leading coefficient of ``poly3``). Implements "Polynomial @@ -408,14 +408,14 @@ cdef extern from "flint_wrap.h": # Monagan and Roman Pearce. This function is exceptionally efficient if the # division is known to be exact. - void nmod_mpoly_divrem_monagan_pearce(nmod_mpoly_t q, nmod_mpoly_t r, const nmod_mpoly_t poly2, const nmod_mpoly_t poly3, const nmod_mpoly_ctx_t ctx) + void nmod_mpoly_divrem_monagan_pearce(nmod_mpoly_t q, nmod_mpoly_t r, const nmod_mpoly_t poly2, const nmod_mpoly_t poly3, const nmod_mpoly_ctx_t ctx) noexcept # Set ``polyq`` and ``polyr`` to the quotient and remainder of # ``poly2`` divided by ``poly3``, (with remainder coefficients reduced # modulo the leading coefficient of ``poly3``). Implements "Polynomial # division using dynamic arrays, heaps and packed exponents" by Michael # Monagan and Roman Pearce. - void nmod_mpoly_divrem_ideal_monagan_pearce(nmod_mpoly_struct ** q, nmod_mpoly_t r, const nmod_mpoly_t poly2, nmod_mpoly_struct * const * poly3, slong len, const nmod_mpoly_ctx_t ctx) + void nmod_mpoly_divrem_ideal_monagan_pearce(nmod_mpoly_struct ** q, nmod_mpoly_t r, const nmod_mpoly_t poly2, nmod_mpoly_struct * const * poly3, slong len, const nmod_mpoly_ctx_t ctx) noexcept # This function is as per ``nmod_mpoly_divrem_monagan_pearce`` except # that it takes an array of divisor polynomials ``poly3``, and it returns # an array of quotient polynomials ``q``. The number of divisor (and hence diff --git a/src/sage/libs/flint/nmod_mpoly_factor.pxd b/src/sage/libs/flint/nmod_mpoly_factor.pxd index 50f70e80748..e30e6f70c1e 100644 --- a/src/sage/libs/flint/nmod_mpoly_factor.pxd +++ b/src/sage/libs/flint/nmod_mpoly_factor.pxd @@ -12,36 +12,36 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void nmod_mpoly_factor_init(nmod_mpoly_factor_t f, const nmod_mpoly_ctx_t ctx) + void nmod_mpoly_factor_init(nmod_mpoly_factor_t f, const nmod_mpoly_ctx_t ctx) noexcept # Initialise *f*. - void nmod_mpoly_factor_clear(nmod_mpoly_factor_t f, const nmod_mpoly_ctx_t ctx) + void nmod_mpoly_factor_clear(nmod_mpoly_factor_t f, const nmod_mpoly_ctx_t ctx) noexcept # Clear *f*. - void nmod_mpoly_factor_swap(nmod_mpoly_factor_t f, nmod_mpoly_factor_t g, const nmod_mpoly_ctx_t ctx) + void nmod_mpoly_factor_swap(nmod_mpoly_factor_t f, nmod_mpoly_factor_t g, const nmod_mpoly_ctx_t ctx) noexcept # Efficiently swap *f* and *g*. - slong nmod_mpoly_factor_length(const nmod_mpoly_factor_t f, const nmod_mpoly_ctx_t ctx) + slong nmod_mpoly_factor_length(const nmod_mpoly_factor_t f, const nmod_mpoly_ctx_t ctx) noexcept # Return the length of the product in *f*. - ulong nmod_mpoly_factor_get_constant_ui(const nmod_mpoly_factor_t f, const nmod_mpoly_ctx_t ctx) + ulong nmod_mpoly_factor_get_constant_ui(const nmod_mpoly_factor_t f, const nmod_mpoly_ctx_t ctx) noexcept # Return the constant of *f*. - void nmod_mpoly_factor_get_base(nmod_mpoly_t p, const nmod_mpoly_factor_t f, slong i, const nmod_mpoly_ctx_t ctx) - void nmod_mpoly_factor_swap_base(nmod_mpoly_t p, nmod_mpoly_factor_t f, slong i, const nmod_mpoly_ctx_t ctx) + void nmod_mpoly_factor_get_base(nmod_mpoly_t p, const nmod_mpoly_factor_t f, slong i, const nmod_mpoly_ctx_t ctx) noexcept + void nmod_mpoly_factor_swap_base(nmod_mpoly_t p, nmod_mpoly_factor_t f, slong i, const nmod_mpoly_ctx_t ctx) noexcept # Set (resp. swap) *B* to (resp. with) the base of the term of index `i` in *A*. - slong nmod_mpoly_factor_get_exp_si(nmod_mpoly_factor_t f, slong i, const nmod_mpoly_ctx_t ctx) + slong nmod_mpoly_factor_get_exp_si(nmod_mpoly_factor_t f, slong i, const nmod_mpoly_ctx_t ctx) noexcept # Return the exponent of the term of index `i` in *A*. It is assumed to fit an ``slong``. - void nmod_mpoly_factor_sort(nmod_mpoly_factor_t f, const nmod_mpoly_ctx_t ctx) + void nmod_mpoly_factor_sort(nmod_mpoly_factor_t f, const nmod_mpoly_ctx_t ctx) noexcept # Sort the product of *f* first by exponent and then by base. - int nmod_mpoly_factor_squarefree(nmod_mpoly_factor_t f, const nmod_mpoly_t A, const nmod_mpoly_ctx_t ctx) + int nmod_mpoly_factor_squarefree(nmod_mpoly_factor_t f, const nmod_mpoly_t A, const nmod_mpoly_ctx_t ctx) noexcept # Set *f* to a factorization of *A* where the bases are primitive and # pairwise relatively prime. If the product of all irreducible factors with # a given exponent is desired, it is recommended to call :func:`nmod_mpoly_factor_sort` # and then multiply the bases with the desired exponent. - int nmod_mpoly_factor(nmod_mpoly_factor_t f, const nmod_mpoly_t A, const nmod_mpoly_ctx_t ctx) + int nmod_mpoly_factor(nmod_mpoly_factor_t f, const nmod_mpoly_t A, const nmod_mpoly_ctx_t ctx) noexcept # Set *f* to a factorization of *A* where the bases are irreducible. diff --git a/src/sage/libs/flint/nmod_poly.pxd b/src/sage/libs/flint/nmod_poly.pxd index 422f5b365d0..9c24f3bf831 100644 --- a/src/sage/libs/flint/nmod_poly.pxd +++ b/src/sage/libs/flint/nmod_poly.pxd @@ -12,89 +12,89 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - int signed_mpn_sub_n(mp_ptr res, mp_srcptr op1, mp_srcptr op2, slong n) + int signed_mpn_sub_n(mp_ptr res, mp_srcptr op1, mp_srcptr op2, slong n) noexcept # If ``op1 >= op2`` return 0 and set ``res`` to ``op1 - op2`` # else return 1 and set ``res`` to ``op2 - op1``. - void nmod_poly_init(nmod_poly_t poly, mp_limb_t n) + void nmod_poly_init(nmod_poly_t poly, mp_limb_t n) noexcept # Initialises ``poly``. It will have coefficients modulo `n`. - void nmod_poly_init_preinv(nmod_poly_t poly, mp_limb_t n, mp_limb_t ninv) + void nmod_poly_init_preinv(nmod_poly_t poly, mp_limb_t n, mp_limb_t ninv) noexcept # Initialises ``poly``. It will have coefficients modulo `n`. # The caller supplies a precomputed inverse limb generated by # :func:`n_preinvert_limb`. - void nmod_poly_init_mod(nmod_poly_t poly, const nmod_t mod) + void nmod_poly_init_mod(nmod_poly_t poly, const nmod_t mod) noexcept # Initialises ``poly`` using an already initialised modulus ``mod``. - void nmod_poly_init2(nmod_poly_t poly, mp_limb_t n, slong alloc) + void nmod_poly_init2(nmod_poly_t poly, mp_limb_t n, slong alloc) noexcept # Initialises ``poly``. It will have coefficients modulo `n`. # Up to ``alloc`` coefficients may be stored in ``poly``. - void nmod_poly_init2_preinv(nmod_poly_t poly, mp_limb_t n, mp_limb_t ninv, slong alloc) + void nmod_poly_init2_preinv(nmod_poly_t poly, mp_limb_t n, mp_limb_t ninv, slong alloc) noexcept # Initialises ``poly``. It will have coefficients modulo `n`. # The caller supplies a precomputed inverse limb generated by # :func:`n_preinvert_limb`. Up to ``alloc`` coefficients may # be stored in ``poly``. - void nmod_poly_realloc(nmod_poly_t poly, slong alloc) + void nmod_poly_realloc(nmod_poly_t poly, slong alloc) noexcept # Reallocates ``poly`` to the given length. If the current # length is less than ``alloc``, the polynomial is truncated # and normalised. If ``alloc`` is zero, the polynomial is # cleared. - void nmod_poly_clear(nmod_poly_t poly) + void nmod_poly_clear(nmod_poly_t poly) noexcept # Clears the polynomial and releases any memory it used. The polynomial # cannot be used again until it is initialised. - void nmod_poly_fit_length(nmod_poly_t poly, slong alloc) + void nmod_poly_fit_length(nmod_poly_t poly, slong alloc) noexcept # Ensures ``poly`` has space for at least ``alloc`` coefficients. # This function only ever grows the allocated space, so no data loss can # occur. - void _nmod_poly_normalise(nmod_poly_t poly) + void _nmod_poly_normalise(nmod_poly_t poly) noexcept # Internal function for normalising a polynomial so that the top # coefficient, if there is one at all, is not zero. - slong nmod_poly_length(const nmod_poly_t poly) + slong nmod_poly_length(const nmod_poly_t poly) noexcept # Returns the length of the polynomial ``poly``. The zero polynomial # has length zero. - slong nmod_poly_degree(const nmod_poly_t poly) + slong nmod_poly_degree(const nmod_poly_t poly) noexcept # Returns the degree of the polynomial ``poly``. The zero polynomial # is deemed to have degree `-1`. - mp_limb_t nmod_poly_modulus(const nmod_poly_t poly) + mp_limb_t nmod_poly_modulus(const nmod_poly_t poly) noexcept # Returns the modulus of the polynomial ``poly``. This will be a # positive integer. - flint_bitcnt_t nmod_poly_max_bits(const nmod_poly_t poly) + flint_bitcnt_t nmod_poly_max_bits(const nmod_poly_t poly) noexcept # Returns the maximum number of bits of any coefficient of ``poly``. - bint nmod_poly_is_unit(const nmod_poly_t poly) + bint nmod_poly_is_unit(const nmod_poly_t poly) noexcept - bint nmod_poly_is_monic(const nmod_poly_t poly) + bint nmod_poly_is_monic(const nmod_poly_t poly) noexcept - void nmod_poly_set(nmod_poly_t a, const nmod_poly_t b) + void nmod_poly_set(nmod_poly_t a, const nmod_poly_t b) noexcept # Sets ``a`` to a copy of ``b``. - void nmod_poly_swap(nmod_poly_t poly1, nmod_poly_t poly2) + void nmod_poly_swap(nmod_poly_t poly1, nmod_poly_t poly2) noexcept # Efficiently swaps ``poly1`` and ``poly2`` by swapping pointers # internally. - void nmod_poly_zero(nmod_poly_t res) + void nmod_poly_zero(nmod_poly_t res) noexcept # Sets ``res`` to the zero polynomial. - void nmod_poly_truncate(nmod_poly_t poly, slong len) + void nmod_poly_truncate(nmod_poly_t poly, slong len) noexcept # Truncates ``poly`` to the given length and normalises it. # If ``len`` is greater than the current length of ``poly``, # then nothing happens. - void nmod_poly_set_trunc(nmod_poly_t res, const nmod_poly_t poly, slong len) + void nmod_poly_set_trunc(nmod_poly_t res, const nmod_poly_t poly, slong len) noexcept # Notionally truncate ``poly`` to length ``len`` and set ``res`` to the # result. The result is normalised. - void _nmod_poly_reverse(mp_ptr output, mp_srcptr input, slong len, slong m) + void _nmod_poly_reverse(mp_ptr output, mp_srcptr input, slong len, slong m) noexcept # Sets ``output`` to the reverse of ``input``, which is of length # ``len``, but thinking of it as a polynomial of length ``m``, # notionally zero-padded if necessary. The length ``m`` must be @@ -103,33 +103,33 @@ cdef extern from "flint_wrap.h": # aliasing of ``output`` and ``input``, but the behaviour is # undefined in case of partial overlap. - void nmod_poly_reverse(nmod_poly_t output, const nmod_poly_t input, slong m) + void nmod_poly_reverse(nmod_poly_t output, const nmod_poly_t input, slong m) noexcept # Sets ``output`` to the reverse of ``input``, thinking of it as # a polynomial of length ``m``, notionally zero-padded if necessary). # The length ``m`` must be non-negative, but there are no other # restrictions. The output polynomial will be set to length ``m`` # and then normalised. - void nmod_poly_randtest(nmod_poly_t poly, flint_rand_t state, slong len) + void nmod_poly_randtest(nmod_poly_t poly, flint_rand_t state, slong len) noexcept # Generates a random polynomial with length up to ``len``. - void nmod_poly_randtest_irreducible(nmod_poly_t poly, flint_rand_t state, slong len) + void nmod_poly_randtest_irreducible(nmod_poly_t poly, flint_rand_t state, slong len) noexcept # Generates a random irreducible polynomial with length up to ``len``. - void nmod_poly_randtest_monic(nmod_poly_t poly, flint_rand_t state, slong len) + void nmod_poly_randtest_monic(nmod_poly_t poly, flint_rand_t state, slong len) noexcept # Generates a random monic polynomial with length ``len``. - void nmod_poly_randtest_monic_irreducible(nmod_poly_t poly, flint_rand_t state, slong len) + void nmod_poly_randtest_monic_irreducible(nmod_poly_t poly, flint_rand_t state, slong len) noexcept # Generates a random monic irreducible polynomial with length ``len``. - void nmod_poly_randtest_monic_primitive(nmod_poly_t poly, flint_rand_t state, slong len) + void nmod_poly_randtest_monic_primitive(nmod_poly_t poly, flint_rand_t state, slong len) noexcept # Generates a random monic irreducible primitive polynomial with # length ``len``. - void nmod_poly_randtest_trinomial(nmod_poly_t poly, flint_rand_t state, slong len) + void nmod_poly_randtest_trinomial(nmod_poly_t poly, flint_rand_t state, slong len) noexcept # Generates a random monic trinomial of length ``len``. - int nmod_poly_randtest_trinomial_irreducible(nmod_poly_t poly, flint_rand_t state, slong len, slong max_attempts) + int nmod_poly_randtest_trinomial_irreducible(nmod_poly_t poly, flint_rand_t state, slong len, slong max_attempts) noexcept # Attempts to set ``poly`` to a monic irreducible trinomial of # length ``len``. It will generate up to ``max_attempts`` # trinomials in attempt to find an irreducible one. If @@ -137,10 +137,10 @@ cdef extern from "flint_wrap.h": # trinomials until an irreducible one is found. Returns `1` if one # is found and `0` otherwise. - void nmod_poly_randtest_pentomial(nmod_poly_t poly, flint_rand_t state, slong len) + void nmod_poly_randtest_pentomial(nmod_poly_t poly, flint_rand_t state, slong len) noexcept # Generates a random monic pentomial of length ``len``. - int nmod_poly_randtest_pentomial_irreducible(nmod_poly_t poly, flint_rand_t state, slong len, slong max_attempts) + int nmod_poly_randtest_pentomial_irreducible(nmod_poly_t poly, flint_rand_t state, slong len, slong max_attempts) noexcept # Attempts to set ``poly`` to a monic irreducible pentomial of # length ``len``. It will generate up to ``max_attempts`` # pentomials in attempt to find an irreducible one. If @@ -148,20 +148,20 @@ cdef extern from "flint_wrap.h": # pentomials until an irreducible one is found. Returns `1` if one # is found and `0` otherwise. - void nmod_poly_randtest_sparse_irreducible(nmod_poly_t poly, flint_rand_t state, slong len) + void nmod_poly_randtest_sparse_irreducible(nmod_poly_t poly, flint_rand_t state, slong len) noexcept # Attempts to set ``poly`` to a sparse, monic irreducible polynomial # with length ``len``. It attempts to find an irreducible # trinomial. If that does not succeed, it attempts to find a # irreducible pentomial. If that fails, then ``poly`` is just # set to a random monic irreducible polynomial. - ulong nmod_poly_get_coeff_ui(const nmod_poly_t poly, slong j) + ulong nmod_poly_get_coeff_ui(const nmod_poly_t poly, slong j) noexcept # Returns the coefficient of ``poly`` at index ``j``, where # coefficients are numbered with zero being the constant coefficient, # and returns it as an ``ulong``. If ``j`` refers to a # coefficient beyond the end of ``poly``, zero is returned. - void nmod_poly_set_coeff_ui(nmod_poly_t poly, slong j, ulong c) + void nmod_poly_set_coeff_ui(nmod_poly_t poly, slong j, ulong c) noexcept # Sets the coefficient of ``poly`` at index ``j``, where # coefficients are numbered with zero being the constant coefficient, # to the value ``c`` reduced modulo the modulus of ``poly``. @@ -169,25 +169,25 @@ cdef extern from "flint_wrap.h": # the polynomial is first resized, with intervening coefficients being # set to zero. - char * nmod_poly_get_str(const nmod_poly_t poly) + char * nmod_poly_get_str(const nmod_poly_t poly) noexcept # Writes ``poly`` to a string representation. The format is as # described for :func:`nmod_poly_print`. The string must be freed by the # user when finished. For this it is sufficient to call :func:`flint_free`. - char * nmod_poly_get_str_pretty(const nmod_poly_t poly, const char * x) + char * nmod_poly_get_str_pretty(const nmod_poly_t poly, const char * x) noexcept # Writes ``poly`` to a pretty string representation. The format is as # described for :func:`nmod_poly_print_pretty`. The string must be freed # by the user when finished. For this it is sufficient to call # :func:`flint_free`. # It is assumed that the top coefficient is non-zero. - int nmod_poly_set_str(nmod_poly_t poly, const char * s) + int nmod_poly_set_str(nmod_poly_t poly, const char * s) noexcept # Reads ``poly`` from a string ``s``. The format is as described # for :func:`nmod_poly_print`. If a polynomial in the correct format # is read, a positive value is returned, otherwise a non-positive value # is returned. - int nmod_poly_print(const nmod_poly_t a) + int nmod_poly_print(const nmod_poly_t a) noexcept # Prints the polynomial to ``stdout``. The length is printed, # followed by a space, then the modulus. If the length is zero this is # all that is printed, otherwise two spaces followed by a space @@ -196,21 +196,21 @@ cdef extern from "flint_wrap.h": # In case of success, returns a positive value. In case of failure, # returns a non-positive value. - int nmod_poly_print_pretty(const nmod_poly_t a, const char * x) + int nmod_poly_print_pretty(const nmod_poly_t a, const char * x) noexcept # Prints the polynomial to ``stdout`` using the string ``x`` to # represent the indeterminate. # It is assumed that the top coefficient is non-zero. # In case of success, returns a positive value. In case of failure, # returns a non-positive value. - int nmod_poly_fread(FILE * f, nmod_poly_t poly) + int nmod_poly_fread(FILE * f, nmod_poly_t poly) noexcept # Reads ``poly`` from the file stream ``f``. If this is a file # that has just been written, the file should be closed then opened # again. The format is as described for :func:`nmod_poly_print`. If a # polynomial in the correct format is read, a positive value is returned, # otherwise a non-positive value is returned. - int nmod_poly_fprint(FILE * f, const nmod_poly_t poly) + int nmod_poly_fprint(FILE * f, const nmod_poly_t poly) noexcept # Writes a polynomial to the file stream ``f``. If this is a file # then the file should be closed and reopened before being read. # The format is as described for :func:`nmod_poly_print`. If the @@ -219,7 +219,7 @@ cdef extern from "flint_wrap.h": # In case of success, returns a positive value. In case of failure, # returns a non-positive value. - int nmod_poly_fprint_pretty(FILE * f, const nmod_poly_t poly, const char * x) + int nmod_poly_fprint_pretty(FILE * f, const nmod_poly_t poly, const char * x) noexcept # Writes a polynomial to the file stream ``f``. If this is a file # then the file should be closed and reopened before being read. # The format is as described for :func:`nmod_poly_print_pretty`. If the @@ -229,88 +229,88 @@ cdef extern from "flint_wrap.h": # In case of success, returns a positive value. In case of failure, # returns a non-positive value. - int nmod_poly_read(nmod_poly_t poly) + int nmod_poly_read(nmod_poly_t poly) noexcept # Read ``poly`` from ``stdin``. The format is as described for # :func:`nmod_poly_print`. If a polynomial in the correct format is read, a # positive value is returned, otherwise a non-positive value is returned. - bint nmod_poly_equal(const nmod_poly_t a, const nmod_poly_t b) + bint nmod_poly_equal(const nmod_poly_t a, const nmod_poly_t b) noexcept # Returns `1` if the polynomials are equal, otherwise `0`. - bint nmod_poly_equal_nmod(const nmod_poly_t poly, ulong cst) + bint nmod_poly_equal_nmod(const nmod_poly_t poly, ulong cst) noexcept # Returns `1` if the polynomial ``poly`` is constant, equal to ``cst``, # otherwise `0`. # ``cst`` is assumed to be already reduced, i.e. less than the modulus of # ``poly``. - bint nmod_poly_equal_ui(const nmod_poly_t poly, ulong cst) + bint nmod_poly_equal_ui(const nmod_poly_t poly, ulong cst) noexcept # Returns `1` if the polynomial ``poly`` is constant and equal to ``cst`` up to # reduction modulo the modulus of ``poly``, otherwise returns `0`. - bint nmod_poly_equal_trunc(const nmod_poly_t poly1, const nmod_poly_t poly2, slong n) + bint nmod_poly_equal_trunc(const nmod_poly_t poly1, const nmod_poly_t poly2, slong n) noexcept # Notionally truncate ``poly1`` and ``poly2`` to length `n` and return # `1` if the truncations are equal, otherwise return `0`. - bint nmod_poly_is_zero(const nmod_poly_t poly) + bint nmod_poly_is_zero(const nmod_poly_t poly) noexcept # Returns `1` if the polynomial ``poly`` is the zero polynomial, # otherwise returns `0`. - bint nmod_poly_is_one(const nmod_poly_t poly) + bint nmod_poly_is_one(const nmod_poly_t poly) noexcept # Returns `1` if the polynomial ``poly`` is the constant polynomial 1, # otherwise returns `0`. - bint nmod_poly_is_gen(const nmod_poly_t poly) + bint nmod_poly_is_gen(const nmod_poly_t poly) noexcept - void _nmod_poly_shift_left(mp_ptr res, mp_srcptr poly, slong len, slong k) + void _nmod_poly_shift_left(mp_ptr res, mp_srcptr poly, slong len, slong k) noexcept # Sets ``(res, len + k)`` to ``(poly, len)`` shifted left by # ``k`` coefficients. Assumes that ``res`` has space for # ``len + k`` coefficients. - void nmod_poly_shift_left(nmod_poly_t res, const nmod_poly_t poly, slong k) + void nmod_poly_shift_left(nmod_poly_t res, const nmod_poly_t poly, slong k) noexcept # Sets ``res`` to ``poly`` shifted left by ``k`` coefficients, # i.e. multiplied by `x^k`. - void _nmod_poly_shift_right(mp_ptr res, mp_srcptr poly, slong len, slong k) + void _nmod_poly_shift_right(mp_ptr res, mp_srcptr poly, slong len, slong k) noexcept # Sets ``(res, len - k)`` to ``(poly, len)`` shifted left by # ``k`` coefficients. It is assumed that ``k <= len`` and that # ``res`` has space for at least ``len - k`` coefficients. - void nmod_poly_shift_right(nmod_poly_t res, const nmod_poly_t poly, slong k) + void nmod_poly_shift_right(nmod_poly_t res, const nmod_poly_t poly, slong k) noexcept # Sets ``res`` to ``poly`` shifted right by ``k`` coefficients, # i.e. divide by `x^k` and throw away the remainder. If ``k`` is # greater than or equal to the length of ``poly``, the result is the # zero polynomial. - void _nmod_poly_add(mp_ptr res, mp_srcptr poly1, slong len1, mp_srcptr poly2, slong len2, nmod_t mod) + void _nmod_poly_add(mp_ptr res, mp_srcptr poly1, slong len1, mp_srcptr poly2, slong len2, nmod_t mod) noexcept # Sets ``res`` to the sum of ``(poly1, len1)`` and # ``(poly2, len2)``. There are no restrictions on the lengths. - void nmod_poly_add(nmod_poly_t res, const nmod_poly_t poly1, const nmod_poly_t poly2) + void nmod_poly_add(nmod_poly_t res, const nmod_poly_t poly1, const nmod_poly_t poly2) noexcept # Sets ``res`` to the sum of ``poly1`` and ``poly2``. - void nmod_poly_add_series(nmod_poly_t res, const nmod_poly_t poly1, const nmod_poly_t poly2, slong n) + void nmod_poly_add_series(nmod_poly_t res, const nmod_poly_t poly1, const nmod_poly_t poly2, slong n) noexcept # Notionally truncate ``poly1`` and ``poly2`` to length `n` and set # ``res`` to the sum. - void _nmod_poly_sub(mp_ptr res, mp_srcptr poly1, slong len1, mp_srcptr poly2, slong len2, nmod_t mod) + void _nmod_poly_sub(mp_ptr res, mp_srcptr poly1, slong len1, mp_srcptr poly2, slong len2, nmod_t mod) noexcept # Sets ``res`` to the difference of ``(poly1, len1)`` and # ``(poly2, len2)``. There are no restrictions on the lengths. - void nmod_poly_sub(nmod_poly_t res, const nmod_poly_t poly1, const nmod_poly_t poly2) + void nmod_poly_sub(nmod_poly_t res, const nmod_poly_t poly1, const nmod_poly_t poly2) noexcept # Sets ``res`` to the difference of ``poly1`` and ``poly2``. - void nmod_poly_sub_series(nmod_poly_t res, const nmod_poly_t poly1, const nmod_poly_t poly2, slong n) + void nmod_poly_sub_series(nmod_poly_t res, const nmod_poly_t poly1, const nmod_poly_t poly2, slong n) noexcept # Notionally truncate ``poly1`` and ``poly2`` to length `n` and set # ``res`` to the difference. - void nmod_poly_neg(nmod_poly_t res, const nmod_poly_t poly) + void nmod_poly_neg(nmod_poly_t res, const nmod_poly_t poly) noexcept # Sets ``res`` to the negation of ``poly``. - void nmod_poly_scalar_mul_nmod(nmod_poly_t res, const nmod_poly_t poly, ulong c) + void nmod_poly_scalar_mul_nmod(nmod_poly_t res, const nmod_poly_t poly, ulong c) noexcept # Sets ``res`` to ``(poly, len)`` multiplied by `c`, # where `c` is reduced modulo the modulus of ``poly``. - void _nmod_poly_make_monic(mp_ptr output, mp_srcptr input, slong len, nmod_t mod) + void _nmod_poly_make_monic(mp_ptr output, mp_srcptr input, slong len, nmod_t mod) noexcept # Sets ``output`` to be the scalar multiple of ``input`` of # length ``len > 0`` that has leading coefficient one, if such a # polynomial exists. If the leading coefficient of ``input`` is not @@ -318,7 +318,7 @@ cdef extern from "flint_wrap.h": # leading coefficient is the greatest common divisor of the leading # coefficient and the modulus of ``input``. - void nmod_poly_make_monic(nmod_poly_t output, const nmod_poly_t input) + void nmod_poly_make_monic(nmod_poly_t output, const nmod_poly_t input) noexcept # Sets ``output`` to be the scalar multiple of ``input`` with leading # coefficient one, if such a polynomial exists. If ``input`` is zero # an exception is raised. If the leading coefficient of ``input`` is not @@ -326,7 +326,7 @@ cdef extern from "flint_wrap.h": # leading coefficient is the greatest common divisor of the leading # coefficient and the modulus of ``input``. - void _nmod_poly_bit_pack(mp_ptr res, mp_srcptr poly, slong len, flint_bitcnt_t bits) + void _nmod_poly_bit_pack(mp_ptr res, mp_srcptr poly, slong len, flint_bitcnt_t bits) noexcept # Packs ``len`` coefficients of ``poly`` into fields of the given # number of bits in the large integer ``res``, i.e. evaluates # ``poly`` at ``2^bits`` and store the result in ``res``. @@ -334,7 +334,7 @@ cdef extern from "flint_wrap.h": # coefficient of ``poly`` is bigger than ``bits/2`` bits. We # also assume ``bits < 3 * FLINT_BITS``. - void _nmod_poly_bit_unpack(mp_ptr res, slong len, mp_srcptr mpn, ulong bits, nmod_t mod) + void _nmod_poly_bit_unpack(mp_ptr res, slong len, mp_srcptr mpn, ulong bits, nmod_t mod) noexcept # Unpacks ``len`` coefficients stored in the big integer ``mpn`` # in bit fields of the given number of bits, reduces them modulo the # given modulus, then stores them in the polynomial ``res``. @@ -342,145 +342,145 @@ cdef extern from "flint_wrap.h": # There are no restrictions on the size of the actual coefficients as # stored within the bitfields. - void nmod_poly_bit_pack(fmpz_t f, const nmod_poly_t poly, flint_bitcnt_t bit_size) + void nmod_poly_bit_pack(fmpz_t f, const nmod_poly_t poly, flint_bitcnt_t bit_size) noexcept # Packs ``poly`` into bitfields of size ``bit_size``, writing the # result to ``f``. - void nmod_poly_bit_unpack(nmod_poly_t poly, const fmpz_t f, flint_bitcnt_t bit_size) + void nmod_poly_bit_unpack(nmod_poly_t poly, const fmpz_t f, flint_bitcnt_t bit_size) noexcept # Unpacks the polynomial from fields of size ``bit_size`` as # represented by the integer ``f``. - void _nmod_poly_KS2_pack1(mp_ptr res, mp_srcptr op, slong n, slong s, ulong b, ulong k, slong r) + void _nmod_poly_KS2_pack1(mp_ptr res, mp_srcptr op, slong n, slong s, ulong b, ulong k, slong r) noexcept # Same as ``_nmod_poly_KS2_pack``, but requires ``b <= FLINT_BITS``. - void _nmod_poly_KS2_pack(mp_ptr res, mp_srcptr op, slong n, slong s, ulong b, ulong k, slong r) + void _nmod_poly_KS2_pack(mp_ptr res, mp_srcptr op, slong n, slong s, ulong b, ulong k, slong r) noexcept # Bit packing routine used by KS2 and KS4 multiplication. - void _nmod_poly_KS2_unpack1(mp_ptr res, mp_srcptr op, slong n, ulong b, ulong k) + void _nmod_poly_KS2_unpack1(mp_ptr res, mp_srcptr op, slong n, ulong b, ulong k) noexcept # Same as ``_nmod_poly_KS2_unpack``, but requires ``b <= FLINT_BITS`` # (i.e. writes one word per coefficient). - void _nmod_poly_KS2_unpack2(mp_ptr res, mp_srcptr op, slong n, ulong b, ulong k) + void _nmod_poly_KS2_unpack2(mp_ptr res, mp_srcptr op, slong n, ulong b, ulong k) noexcept # Same as ``_nmod_poly_KS2_unpack``, but requires # ``FLINT_BITS < b <= 2 * FLINT_BITS`` (i.e. writes two words per # coefficient). - void _nmod_poly_KS2_unpack3(mp_ptr res, mp_srcptr op, slong n, ulong b, ulong k) + void _nmod_poly_KS2_unpack3(mp_ptr res, mp_srcptr op, slong n, ulong b, ulong k) noexcept # Same as ``_nmod_poly_KS2_unpack``, but requires # ``2 * FLINT_BITS < b < 3 * FLINT_BITS`` (i.e. writes three words per # coefficient). - void _nmod_poly_KS2_unpack(mp_ptr res, mp_srcptr op, slong n, ulong b, ulong k) + void _nmod_poly_KS2_unpack(mp_ptr res, mp_srcptr op, slong n, ulong b, ulong k) noexcept # Bit unpacking code used by KS2 and KS4 multiplication. - void _nmod_poly_KS2_reduce(mp_ptr res, slong s, mp_srcptr op, slong n, ulong w, nmod_t mod) + void _nmod_poly_KS2_reduce(mp_ptr res, slong s, mp_srcptr op, slong n, ulong w, nmod_t mod) noexcept # Reduction code used by KS2 and KS4 multiplication. - void _nmod_poly_KS2_recover_reduce1(mp_ptr res, slong s, mp_srcptr op1, mp_srcptr op2, slong n, ulong b, nmod_t mod) + void _nmod_poly_KS2_recover_reduce1(mp_ptr res, slong s, mp_srcptr op1, mp_srcptr op2, slong n, ulong b, nmod_t mod) noexcept # Same as ``_nmod_poly_KS2_recover_reduce``, but requires # ``0 < 2 * b <= FLINT_BITS``. - void _nmod_poly_KS2_recover_reduce2(mp_ptr res, slong s, mp_srcptr op1, mp_srcptr op2, slong n, ulong b, nmod_t mod) + void _nmod_poly_KS2_recover_reduce2(mp_ptr res, slong s, mp_srcptr op1, mp_srcptr op2, slong n, ulong b, nmod_t mod) noexcept # Same as ``_nmod_poly_KS2_recover_reduce``, but requires # ``FLINT_BITS < 2 * b < 2*FLINT_BITS``. - void _nmod_poly_KS2_recover_reduce2b(mp_ptr res, slong s, mp_srcptr op1, mp_srcptr op2, slong n, ulong b, nmod_t mod) + void _nmod_poly_KS2_recover_reduce2b(mp_ptr res, slong s, mp_srcptr op1, mp_srcptr op2, slong n, ulong b, nmod_t mod) noexcept # Same as ``_nmod_poly_KS2_recover_reduce``, but requires # ``b == FLINT_BITS``. - void _nmod_poly_KS2_recover_reduce3(mp_ptr res, slong s, mp_srcptr op1, mp_srcptr op2, slong n, ulong b, nmod_t mod) + void _nmod_poly_KS2_recover_reduce3(mp_ptr res, slong s, mp_srcptr op1, mp_srcptr op2, slong n, ulong b, nmod_t mod) noexcept # Same as ``_nmod_poly_KS2_recover_reduce``, but requires # ``2 * FLINT_BITS < 2 * b <= 3 * FLINT_BITS``. - void _nmod_poly_KS2_recover_reduce(mp_ptr res, slong s, mp_srcptr op1, mp_srcptr op2, slong n, ulong b, nmod_t mod) + void _nmod_poly_KS2_recover_reduce(mp_ptr res, slong s, mp_srcptr op1, mp_srcptr op2, slong n, ulong b, nmod_t mod) noexcept # Reduction code used by KS4 multiplication. - void _nmod_poly_mul_classical(mp_ptr res, mp_srcptr poly1, slong len1, mp_srcptr poly2, slong len2, nmod_t mod) + void _nmod_poly_mul_classical(mp_ptr res, mp_srcptr poly1, slong len1, mp_srcptr poly2, slong len2, nmod_t mod) noexcept # Sets ``(res, len1 + len2 - 1)`` to the product of ``(poly1, len1)`` # and ``(poly2, len2)``. Assumes ``len1 >= len2 > 0``. Aliasing of # inputs and output is not permitted. - void nmod_poly_mul_classical(nmod_poly_t res, const nmod_poly_t poly1, const nmod_poly_t poly2) + void nmod_poly_mul_classical(nmod_poly_t res, const nmod_poly_t poly1, const nmod_poly_t poly2) noexcept # Sets ``res`` to the product of ``poly1`` and ``poly2``. - void _nmod_poly_mullow_classical(mp_ptr res, mp_srcptr poly1, slong len1, mp_srcptr poly2, slong len2, slong trunc, nmod_t mod) + void _nmod_poly_mullow_classical(mp_ptr res, mp_srcptr poly1, slong len1, mp_srcptr poly2, slong len2, slong trunc, nmod_t mod) noexcept # Sets ``res`` to the lower ``trunc`` coefficients of the product of # ``(poly1, len1)`` and ``(poly2, len2)``. Assumes that # ``len1 >= len2 > 0`` and ``trunc > 0``. Aliasing of inputs and # output is not permitted. - void nmod_poly_mullow_classical(nmod_poly_t res, const nmod_poly_t poly1, const nmod_poly_t poly2, slong trunc) + void nmod_poly_mullow_classical(nmod_poly_t res, const nmod_poly_t poly1, const nmod_poly_t poly2, slong trunc) noexcept # Sets ``res`` to the lower ``trunc`` coefficients of the product # of ``poly1`` and ``poly2``. - void _nmod_poly_mulhigh_classical(mp_ptr res, mp_srcptr poly1, slong len1, mp_srcptr poly2, slong len2, slong start, nmod_t mod) + void _nmod_poly_mulhigh_classical(mp_ptr res, mp_srcptr poly1, slong len1, mp_srcptr poly2, slong len2, slong start, nmod_t mod) noexcept # Computes the product of ``(poly1, len1)`` and ``(poly2, len2)`` # and writes the coefficients from ``start`` onwards into the high # coefficients of ``res``, the remaining coefficients being arbitrary # but reduced. Assumes that ``len1 >= len2 > 0``. Aliasing of inputs # and output is not permitted. - void nmod_poly_mulhigh_classical(nmod_poly_t res, const nmod_poly_t poly1, const nmod_poly_t poly2, slong start) + void nmod_poly_mulhigh_classical(nmod_poly_t res, const nmod_poly_t poly1, const nmod_poly_t poly2, slong start) noexcept # Computes the product of ``poly1`` and ``poly2`` and writes the # coefficients from ``start`` onwards into the high coefficients of # ``res``, the remaining coefficients being arbitrary but reduced. - void _nmod_poly_mul_KS(mp_ptr out, mp_srcptr in1, slong len1, mp_srcptr in2, slong len2, flint_bitcnt_t bits, nmod_t mod) + void _nmod_poly_mul_KS(mp_ptr out, mp_srcptr in1, slong len1, mp_srcptr in2, slong len2, flint_bitcnt_t bits, nmod_t mod) noexcept # Sets ``res`` to the product of ``in1`` and ``in2`` # assuming the output coefficients are at most the given number of # bits wide. If ``bits`` is set to `0` an appropriate value is # computed automatically. Assumes that ``len1 >= len2 > 0``. - void nmod_poly_mul_KS(nmod_poly_t res, const nmod_poly_t poly1, const nmod_poly_t poly2, flint_bitcnt_t bits) + void nmod_poly_mul_KS(nmod_poly_t res, const nmod_poly_t poly1, const nmod_poly_t poly2, flint_bitcnt_t bits) noexcept # Sets ``res`` to the product of ``poly1`` and ``poly2`` # assuming the output coefficients are at most the given number of # bits wide. If ``bits`` is set to `0` an appropriate value # is computed automatically. - void _nmod_poly_mul_KS2(mp_ptr res, mp_srcptr op1, slong n1, mp_srcptr op2, slong n2, nmod_t mod) + void _nmod_poly_mul_KS2(mp_ptr res, mp_srcptr op1, slong n1, mp_srcptr op2, slong n2, nmod_t mod) noexcept # Sets ``res`` to the product of ``op1`` and ``op2``. # Assumes that ``len1 >= len2 > 0``. - void nmod_poly_mul_KS2(nmod_poly_t res, const nmod_poly_t poly1, const nmod_poly_t poly2) + void nmod_poly_mul_KS2(nmod_poly_t res, const nmod_poly_t poly1, const nmod_poly_t poly2) noexcept # Sets ``res`` to the product of ``poly1`` and ``poly2``. - void _nmod_poly_mul_KS4(mp_ptr res, mp_srcptr op1, slong n1, mp_srcptr op2, slong n2, nmod_t mod) + void _nmod_poly_mul_KS4(mp_ptr res, mp_srcptr op1, slong n1, mp_srcptr op2, slong n2, nmod_t mod) noexcept # Sets ``res`` to the product of ``op1`` and ``op2``. # Assumes that ``len1 >= len2 > 0``. - void nmod_poly_mul_KS4(nmod_poly_t res, const nmod_poly_t poly1, const nmod_poly_t poly2) + void nmod_poly_mul_KS4(nmod_poly_t res, const nmod_poly_t poly1, const nmod_poly_t poly2) noexcept # Sets ``res`` to the product of ``poly1`` and ``poly2``. - void _nmod_poly_mullow_KS(mp_ptr out, mp_srcptr in1, slong len1, mp_srcptr in2, slong len2, flint_bitcnt_t bits, slong n, nmod_t mod) + void _nmod_poly_mullow_KS(mp_ptr out, mp_srcptr in1, slong len1, mp_srcptr in2, slong len2, flint_bitcnt_t bits, slong n, nmod_t mod) noexcept # Sets ``out`` to the low `n` coefficients of ``in1`` of length # ``len1`` times ``in2`` of length ``len2``. The output must have # space for ``n`` coefficients. We assume that ``len1 >= len2 > 0`` # and that ``0 < n <= len1 + len2 - 1``. - void nmod_poly_mullow_KS(nmod_poly_t res, const nmod_poly_t poly1, const nmod_poly_t poly2, flint_bitcnt_t bits, slong n) + void nmod_poly_mullow_KS(nmod_poly_t res, const nmod_poly_t poly1, const nmod_poly_t poly2, flint_bitcnt_t bits, slong n) noexcept # Set ``res`` to the low `n` coefficients of ``in1`` of length # ``len1`` times ``in2`` of length ``len2``. - void _nmod_poly_mul(mp_ptr res, mp_srcptr poly1, slong len1, mp_srcptr poly2, slong len2, nmod_t mod) + void _nmod_poly_mul(mp_ptr res, mp_srcptr poly1, slong len1, mp_srcptr poly2, slong len2, nmod_t mod) noexcept # Sets ``res`` to the product of ``poly1`` of length ``len1`` # and ``poly2`` of length ``len2``. Assumes ``len1 >= len2 > 0``. # No aliasing is permitted between the inputs and the output. - void nmod_poly_mul(nmod_poly_t res, const nmod_poly_t poly, const nmod_poly_t poly2) + void nmod_poly_mul(nmod_poly_t res, const nmod_poly_t poly, const nmod_poly_t poly2) noexcept # Sets ``res`` to the product of ``poly1`` and ``poly2``. - void _nmod_poly_mullow(mp_ptr res, mp_srcptr poly1, slong len1, mp_srcptr poly2, slong len2, slong n, nmod_t mod) + void _nmod_poly_mullow(mp_ptr res, mp_srcptr poly1, slong len1, mp_srcptr poly2, slong len2, slong n, nmod_t mod) noexcept # Sets ``res`` to the first ``n`` coefficients of the # product of ``poly1`` of length ``len1`` and ``poly2`` of # length ``len2``. It is assumed that ``0 < n <= len1 + len2 - 1`` # and that ``len1 >= len2 > 0``. No aliasing of inputs and output # is permitted. - void nmod_poly_mullow(nmod_poly_t res, const nmod_poly_t poly1, const nmod_poly_t poly2, slong trunc) + void nmod_poly_mullow(nmod_poly_t res, const nmod_poly_t poly1, const nmod_poly_t poly2, slong trunc) noexcept # Sets ``res`` to the first ``trunc`` coefficients of the # product of ``poly1`` and ``poly2``. - void _nmod_poly_mulhigh(mp_ptr res, mp_srcptr poly1, slong len1, mp_srcptr poly2, slong len2, slong n, nmod_t mod) + void _nmod_poly_mulhigh(mp_ptr res, mp_srcptr poly1, slong len1, mp_srcptr poly2, slong len2, slong n, nmod_t mod) noexcept # Sets all but the low `n` coefficients of ``res`` to the # corresponding coefficients of the product of ``poly1`` of length # ``len1`` and ``poly2`` of length ``len2``, the other @@ -488,12 +488,12 @@ cdef extern from "flint_wrap.h": # ``len1 >= len2 > 0`` and that ``0 < n <= len1 + len2 - 1``. # Aliasing of inputs and output is not permitted. - void nmod_poly_mulhigh(nmod_poly_t res, const nmod_poly_t poly1, const nmod_poly_t poly2, slong n) + void nmod_poly_mulhigh(nmod_poly_t res, const nmod_poly_t poly1, const nmod_poly_t poly2, slong n) noexcept # Sets all but the low `n` coefficients of ``res`` to the # corresponding coefficients of the product of ``poly1`` and # ``poly2``, the remaining coefficients being arbitrary. - void _nmod_poly_mulmod(mp_ptr res, mp_srcptr poly1, slong len1, mp_srcptr poly2, slong len2, mp_srcptr f, slong lenf, nmod_t mod) + void _nmod_poly_mulmod(mp_ptr res, mp_srcptr poly1, slong len1, mp_srcptr poly2, slong len2, mp_srcptr f, slong lenf, nmod_t mod) noexcept # Sets ``res`` to the remainder of the product of ``poly1`` and # ``poly2`` upon polynomial division by ``f``. # It is required that ``len1 + len2 - lenf > 0``, which is equivalent @@ -501,11 +501,11 @@ cdef extern from "flint_wrap.h": # use ``_nmod_poly_mul`` instead. # Aliasing of ``f`` and ``res`` is not permitted. - void nmod_poly_mulmod(nmod_poly_t res, const nmod_poly_t poly1, const nmod_poly_t poly2, const nmod_poly_t f) + void nmod_poly_mulmod(nmod_poly_t res, const nmod_poly_t poly1, const nmod_poly_t poly2, const nmod_poly_t f) noexcept # Sets ``res`` to the remainder of the product of ``poly1`` and # ``poly2`` upon polynomial division by ``f``. - void _nmod_poly_mulmod_preinv(mp_ptr res, mp_srcptr poly1, slong len1, mp_srcptr poly2, slong len2, mp_srcptr f, slong lenf, mp_srcptr finv, slong lenfinv, nmod_t mod) + void _nmod_poly_mulmod_preinv(mp_ptr res, mp_srcptr poly1, slong len1, mp_srcptr poly2, slong len2, mp_srcptr f, slong lenf, mp_srcptr finv, slong lenfinv, nmod_t mod) noexcept # Sets ``res`` to the remainder of the product of ``poly1`` and # ``poly2`` upon polynomial division by ``f``. # It is required that ``finv`` is the inverse of the reverse of ``f`` @@ -515,34 +515,34 @@ cdef extern from "flint_wrap.h": # Otherwise, simply use ``_nmod_poly_mul`` instead. # Aliasing of ```res`` with any of the inputs is not permitted. - void nmod_poly_mulmod_preinv(nmod_poly_t res, const nmod_poly_t poly1, const nmod_poly_t poly2, const nmod_poly_t f, const nmod_poly_t finv) + void nmod_poly_mulmod_preinv(nmod_poly_t res, const nmod_poly_t poly1, const nmod_poly_t poly2, const nmod_poly_t f, const nmod_poly_t finv) noexcept # Sets ``res`` to the remainder of the product of ``poly1`` and # ``poly2`` upon polynomial division by ``f``. ``finv`` is the # inverse of the reverse of ``f``. It is required that ``poly1`` and # ``poly2`` are reduced modulo ``f``. - void _nmod_poly_pow_binexp(mp_ptr res, mp_srcptr poly, slong len, ulong e, nmod_t mod) + void _nmod_poly_pow_binexp(mp_ptr res, mp_srcptr poly, slong len, ulong e, nmod_t mod) noexcept # Raises ``poly`` of length ``len`` to the power ``e`` and sets # ``res`` to the result. We require that ``res`` has enough space # for ``(len - 1)*e + 1`` coefficients. Assumes that ``len > 0``, # ``e > 1``. Aliasing is not permitted. Uses the binary exponentiation # method. - void nmod_poly_pow_binexp(nmod_poly_t res, const nmod_poly_t poly, ulong e) + void nmod_poly_pow_binexp(nmod_poly_t res, const nmod_poly_t poly, ulong e) noexcept # Raises ``poly`` to the power ``e`` and sets ``res`` to the # result. Uses the binary exponentiation method. - void _nmod_poly_pow(mp_ptr res, mp_srcptr poly, slong len, ulong e, nmod_t mod) + void _nmod_poly_pow(mp_ptr res, mp_srcptr poly, slong len, ulong e, nmod_t mod) noexcept # Raises ``poly`` of length ``len`` to the power ``e`` and sets # ``res`` to the result. We require that ``res`` has enough space # for ``(len - 1)*e + 1`` coefficients. Assumes that ``len > 0``, # ``e > 1``. Aliasing is not permitted. - void nmod_poly_pow(nmod_poly_t res, const nmod_poly_t poly, ulong e) + void nmod_poly_pow(nmod_poly_t res, const nmod_poly_t poly, ulong e) noexcept # Raises ``poly`` to the power ``e`` and sets ``res`` to the # result. - void _nmod_poly_pow_trunc_binexp(mp_ptr res, mp_srcptr poly, ulong e, slong trunc, nmod_t mod) + void _nmod_poly_pow_trunc_binexp(mp_ptr res, mp_srcptr poly, ulong e, slong trunc, nmod_t mod) noexcept # Sets ``res`` to the low ``trunc`` coefficients of ``poly`` # (assumed to be zero padded if necessary to length ``trunc``) to # the power ``e``. This is equivalent to doing a powering followed @@ -551,12 +551,12 @@ cdef extern from "flint_wrap.h": # ``e > 1``. Aliasing is not permitted. Uses the binary # exponentiation method. - void nmod_poly_pow_trunc_binexp(nmod_poly_t res, const nmod_poly_t poly, ulong e, slong trunc) + void nmod_poly_pow_trunc_binexp(nmod_poly_t res, const nmod_poly_t poly, ulong e, slong trunc) noexcept # Sets ``res`` to the low ``trunc`` coefficients of ``poly`` # to the power ``e``. This is equivalent to doing a powering # followed by a truncation. Uses the binary exponentiation method. - void _nmod_poly_pow_trunc(mp_ptr res, mp_srcptr poly, ulong e, slong trunc, nmod_t mod) + void _nmod_poly_pow_trunc(mp_ptr res, mp_srcptr poly, ulong e, slong trunc, nmod_t mod) noexcept # Sets ``res`` to the low ``trunc`` coefficients of ``poly`` # (assumed to be zero padded if necessary to length ``trunc``) to # the power ``e``. This is equivalent to doing a powering followed @@ -564,12 +564,12 @@ cdef extern from "flint_wrap.h": # ``trunc`` coefficients, that ``trunc > 0`` and that # ``e > 1``. Aliasing is not permitted. - void nmod_poly_pow_trunc(nmod_poly_t res, const nmod_poly_t poly, ulong e, slong trunc) + void nmod_poly_pow_trunc(nmod_poly_t res, const nmod_poly_t poly, ulong e, slong trunc) noexcept # Sets ``res`` to the low ``trunc`` coefficients of ``poly`` # to the power ``e``. This is equivalent to doing a powering # followed by a truncation. - void _nmod_poly_powmod_ui_binexp(mp_ptr res, mp_srcptr poly, ulong e, mp_srcptr f, slong lenf, nmod_t mod) + void _nmod_poly_powmod_ui_binexp(mp_ptr res, mp_srcptr poly, ulong e, mp_srcptr f, slong lenf, nmod_t mod) noexcept # Sets ``res`` to ``poly`` raised to the power ``e`` # modulo ``f``, using binary exponentiation. We require ``e > 0``. # We require ``lenf > 1``. It is assumed that ``poly`` is already @@ -577,22 +577,22 @@ cdef extern from "flint_wrap.h": # exactly ``lenf - 1``. The output ``res`` must have room for # ``lenf - 1`` coefficients. - void nmod_poly_powmod_ui_binexp(nmod_poly_t res, const nmod_poly_t poly, ulong e, const nmod_poly_t f) + void nmod_poly_powmod_ui_binexp(nmod_poly_t res, const nmod_poly_t poly, ulong e, const nmod_poly_t f) noexcept # Sets ``res`` to ``poly`` raised to the power ``e`` # modulo ``f``, using binary exponentiation. We require ``e >= 0``. - void _nmod_poly_powmod_fmpz_binexp(mp_ptr res, mp_srcptr poly, fmpz_t e, mp_srcptr f, slong lenf, nmod_t mod) + void _nmod_poly_powmod_fmpz_binexp(mp_ptr res, mp_srcptr poly, fmpz_t e, mp_srcptr f, slong lenf, nmod_t mod) noexcept # Sets ``res`` to ``poly`` raised to the power ``e`` # modulo ``f``, using binary exponentiation. We require ``e > 0``. # We require ``lenf > 1``. It is assumed that ``poly`` is already # reduced modulo ``f`` and zero-padded as necessary to have length # exactly ``lenf - 1``. The output ``res`` must have room for ``lenf - 1`` coefficients. - void nmod_poly_powmod_fmpz_binexp(nmod_poly_t res, const nmod_poly_t poly, fmpz_t e, const nmod_poly_t f) + void nmod_poly_powmod_fmpz_binexp(nmod_poly_t res, const nmod_poly_t poly, fmpz_t e, const nmod_poly_t f) noexcept # Sets ``res`` to ``poly`` raised to the power ``e`` # modulo ``f``, using binary exponentiation. We require ``e >= 0``. - void _nmod_poly_powmod_ui_binexp_preinv (mp_ptr res, mp_srcptr poly, ulong e, mp_srcptr f, slong lenf, mp_srcptr finv, slong lenfinv, nmod_t mod) + void _nmod_poly_powmod_ui_binexp_preinv (mp_ptr res, mp_srcptr poly, ulong e, mp_srcptr f, slong lenf, mp_srcptr finv, slong lenfinv, nmod_t mod) noexcept # Sets ``res`` to ``poly`` raised to the power ``e`` # modulo ``f``, using binary exponentiation. We require ``e > 0``. # We require ``finv`` to be the inverse of the reverse of ``f``. @@ -601,12 +601,12 @@ cdef extern from "flint_wrap.h": # exactly ``lenf - 1``. The output ``res`` must have room for # ``lenf - 1`` coefficients. - void nmod_poly_powmod_ui_binexp_preinv(nmod_poly_t res, const nmod_poly_t poly, ulong e, const nmod_poly_t f, const nmod_poly_t finv) + void nmod_poly_powmod_ui_binexp_preinv(nmod_poly_t res, const nmod_poly_t poly, ulong e, const nmod_poly_t f, const nmod_poly_t finv) noexcept # Sets ``res`` to ``poly`` raised to the power ``e`` # modulo ``f``, using binary exponentiation. We require ``e >= 0``. # We require ``finv`` to be the inverse of the reverse of ``f``. - void _nmod_poly_powmod_fmpz_binexp_preinv (mp_ptr res, mp_srcptr poly, fmpz_t e, mp_srcptr f, slong lenf, mp_srcptr finv, slong lenfinv, nmod_t mod) + void _nmod_poly_powmod_fmpz_binexp_preinv (mp_ptr res, mp_srcptr poly, fmpz_t e, mp_srcptr f, slong lenf, mp_srcptr finv, slong lenfinv, nmod_t mod) noexcept # Sets ``res`` to ``poly`` raised to the power ``e`` # modulo ``f``, using binary exponentiation. We require ``e > 0``. # We require ``finv`` to be the inverse of the reverse of ``f``. @@ -615,38 +615,38 @@ cdef extern from "flint_wrap.h": # exactly ``lenf - 1``. The output ``res`` must have room for # ``lenf - 1`` coefficients. - void nmod_poly_powmod_fmpz_binexp_preinv(nmod_poly_t res, const nmod_poly_t poly, fmpz_t e, const nmod_poly_t f, const nmod_poly_t finv) + void nmod_poly_powmod_fmpz_binexp_preinv(nmod_poly_t res, const nmod_poly_t poly, fmpz_t e, const nmod_poly_t f, const nmod_poly_t finv) noexcept # Sets ``res`` to ``poly`` raised to the power ``e`` # modulo ``f``, using binary exponentiation. We require ``e >= 0``. # We require ``finv`` to be the inverse of the reverse of ``f``. - void _nmod_poly_powmod_x_ui_preinv (mp_ptr res, ulong e, mp_srcptr f, slong lenf, mp_srcptr finv, slong lenfinv, nmod_t mod) + void _nmod_poly_powmod_x_ui_preinv (mp_ptr res, ulong e, mp_srcptr f, slong lenf, mp_srcptr finv, slong lenfinv, nmod_t mod) noexcept # Sets ``res`` to ``x`` raised to the power ``e`` modulo ``f``, # using sliding window exponentiation. We require ``e > 0``. # We require ``finv`` to be the inverse of the reverse of ``f``. # We require ``lenf > 2``. The output ``res`` must have room for # ``lenf - 1`` coefficients. - void nmod_poly_powmod_x_ui_preinv(nmod_poly_t res, ulong e, const nmod_poly_t f, const nmod_poly_t finv) + void nmod_poly_powmod_x_ui_preinv(nmod_poly_t res, ulong e, const nmod_poly_t f, const nmod_poly_t finv) noexcept # Sets ``res`` to ``x`` raised to the power ``e`` # modulo ``f``, using sliding window exponentiation. We require # ``e >= 0``. We require ``finv`` to be the inverse of the reverse of # ``f``. - void _nmod_poly_powmod_x_fmpz_preinv (mp_ptr res, fmpz_t e, mp_srcptr f, slong lenf, mp_srcptr finv, slong lenfinv, nmod_t mod) + void _nmod_poly_powmod_x_fmpz_preinv (mp_ptr res, fmpz_t e, mp_srcptr f, slong lenf, mp_srcptr finv, slong lenfinv, nmod_t mod) noexcept # Sets ``res`` to ``x`` raised to the power ``e`` modulo ``f``, # using sliding window exponentiation. We require ``e > 0``. # We require ``finv`` to be the inverse of the reverse of ``f``. # We require ``lenf > 2``. The output ``res`` must have room for # ``lenf - 1`` coefficients. - void nmod_poly_powmod_x_fmpz_preinv(nmod_poly_t res, fmpz_t e, const nmod_poly_t f, const nmod_poly_t finv) + void nmod_poly_powmod_x_fmpz_preinv(nmod_poly_t res, fmpz_t e, const nmod_poly_t f, const nmod_poly_t finv) noexcept # Sets ``res`` to ``x`` raised to the power ``e`` # modulo ``f``, using sliding window exponentiation. We require # ``e >= 0``. We require ``finv`` to be the inverse of the reverse of # ``f``. - void _nmod_poly_powers_mod_preinv_naive(mp_ptr * res, mp_srcptr f, slong flen, slong n, mp_srcptr g, slong glen, mp_srcptr ginv, slong ginvlen, const nmod_t mod) + void _nmod_poly_powers_mod_preinv_naive(mp_ptr * res, mp_srcptr f, slong flen, slong n, mp_srcptr g, slong glen, mp_srcptr ginv, slong ginvlen, const nmod_t mod) noexcept # Compute ``f^0, f^1, ..., f^(n-1) mod g``, where ``g`` has length ``glen`` # and ``f`` is reduced mod ``g`` and has length ``flen`` (possibly zero # spaced). Assumes ``res`` is an array of ``n`` arrays each with space for @@ -654,12 +654,12 @@ cdef extern from "flint_wrap.h": # ``ginv`` of length ``ginvlen`` is set to the power series inverse of the # reverse of ``g``. - void nmod_poly_powers_mod_naive(nmod_poly_struct * res, const nmod_poly_t f, slong n, const nmod_poly_t g) + void nmod_poly_powers_mod_naive(nmod_poly_struct * res, const nmod_poly_t f, slong n, const nmod_poly_t g) noexcept # Set the entries of the array ``res`` to ``f^0, f^1, ..., f^(n-1) mod g``. # No aliasing is permitted between the entries of ``res`` and either of the # inputs. - void _nmod_poly_powers_mod_preinv_threaded_pool(mp_ptr * res, mp_srcptr f, slong flen, slong n, mp_srcptr g, slong glen, mp_srcptr ginv, slong ginvlen, const nmod_t mod, thread_pool_handle * threads, slong num_threads) + void _nmod_poly_powers_mod_preinv_threaded_pool(mp_ptr * res, mp_srcptr f, slong flen, slong n, mp_srcptr g, slong glen, mp_srcptr ginv, slong ginvlen, const nmod_t mod, thread_pool_handle * threads, slong num_threads) noexcept # Compute ``f^0, f^1, ..., f^(n-1) mod g``, where ``g`` has length ``glen`` # and ``f`` is reduced mod ``g`` and has length ``flen`` (possibly zero # spaced). Assumes ``res`` is an array of ``n`` arrays each with space for @@ -667,7 +667,7 @@ cdef extern from "flint_wrap.h": # ``ginv`` of length ``ginvlen`` is set to the power series inverse of the # reverse of ``g``. - void _nmod_poly_powers_mod_preinv_threaded(mp_ptr * res, mp_srcptr f, slong flen, slong n, mp_srcptr g, slong glen, mp_srcptr ginv, slong ginvlen, const nmod_t mod) + void _nmod_poly_powers_mod_preinv_threaded(mp_ptr * res, mp_srcptr f, slong flen, slong n, mp_srcptr g, slong glen, mp_srcptr ginv, slong ginvlen, const nmod_t mod) noexcept # Compute ``f^0, f^1, ..., f^(n-1) mod g``, where ``g`` has length ``glen`` # and ``f`` is reduced mod ``g`` and has length ``flen`` (possibly zero # spaced). Assumes ``res`` is an array of ``n`` arrays each with space for @@ -675,55 +675,55 @@ cdef extern from "flint_wrap.h": # ``ginv`` of length ``ginvlen`` is set to the power series inverse of the # reverse of ``g``. - void nmod_poly_powers_mod_bsgs(nmod_poly_struct * res, const nmod_poly_t f, slong n, const nmod_poly_t g) + void nmod_poly_powers_mod_bsgs(nmod_poly_struct * res, const nmod_poly_t f, slong n, const nmod_poly_t g) noexcept # Set the entries of the array ``res`` to ``f^0, f^1, ..., f^(n-1) mod g``. # No aliasing is permitted between the entries of ``res`` and either of the # inputs. - void _nmod_poly_divrem_basecase(mp_ptr Q, mp_ptr R, mp_srcptr A, slong A_len, mp_srcptr B, slong B_len, nmod_t mod) + void _nmod_poly_divrem_basecase(mp_ptr Q, mp_ptr R, mp_srcptr A, slong A_len, mp_srcptr B, slong B_len, nmod_t mod) noexcept # Finds `Q` and `R` such that `A = B Q + R` with `\operatorname{len}(R) < \operatorname{len}(B)`. # If `\operatorname{len}(B) = 0` an exception is raised. We require that ``W`` # is temporary space of ``NMOD_DIVREM_BC_ITCH(A_len, B_len, mod)`` # coefficients. - void nmod_poly_divrem_basecase(nmod_poly_t Q, nmod_poly_t R, const nmod_poly_t A, const nmod_poly_t B) + void nmod_poly_divrem_basecase(nmod_poly_t Q, nmod_poly_t R, const nmod_poly_t A, const nmod_poly_t B) noexcept # Finds `Q` and `R` such that `A = B Q + R` with `\operatorname{len}(R) < \operatorname{len}(B)`. # If `\operatorname{len}(B) = 0` an exception is raised. - void _nmod_poly_divrem(mp_ptr Q, mp_ptr R, mp_srcptr A, slong lenA, mp_srcptr B, slong lenB, nmod_t mod) + void _nmod_poly_divrem(mp_ptr Q, mp_ptr R, mp_srcptr A, slong lenA, mp_srcptr B, slong lenB, nmod_t mod) noexcept # Computes `Q` and `R` such that `A = BQ + R` with `\operatorname{len}(R)` less than # ``lenB``, where ``A`` is of length ``lenA`` and ``B`` is of # length ``lenB``. We require that ``Q`` have space for # ``lenA - lenB + 1`` coefficients. - void nmod_poly_divrem(nmod_poly_t Q, nmod_poly_t R, const nmod_poly_t A, const nmod_poly_t B) + void nmod_poly_divrem(nmod_poly_t Q, nmod_poly_t R, const nmod_poly_t A, const nmod_poly_t B) noexcept # Computes `Q` and `R` such that `A = BQ + R` with `\operatorname{len}(R) < \operatorname{len}(B)`. - void _nmod_poly_div(mp_ptr Q, mp_srcptr A, slong lenA, mp_srcptr B, slong lenB, nmod_t mod) + void _nmod_poly_div(mp_ptr Q, mp_srcptr A, slong lenA, mp_srcptr B, slong lenB, nmod_t mod) noexcept # Notionally computes polynomials `Q` and `R` such that `A = BQ + R` with # `\operatorname{len}(R)` less than ``lenB``, where ``A`` is of length ``lenA`` # and ``B`` is of length ``lenB``, but returns only ``Q``. We # require that ``Q`` have space for ``lenA - lenB + 1`` coefficients. - void nmod_poly_div(nmod_poly_t Q, const nmod_poly_t A, const nmod_poly_t B) + void nmod_poly_div(nmod_poly_t Q, const nmod_poly_t A, const nmod_poly_t B) noexcept # Computes the quotient `Q` on polynomial division of `A` and `B`. - void _nmod_poly_rem_q1(mp_ptr R, mp_srcptr A, slong lenA, mp_srcptr B, slong lenB, nmod_t mod) + void _nmod_poly_rem_q1(mp_ptr R, mp_srcptr A, slong lenA, mp_srcptr B, slong lenB, nmod_t mod) noexcept - void _nmod_poly_rem(mp_ptr R, mp_srcptr A, slong lenA, mp_srcptr B, slong lenB, nmod_t mod) + void _nmod_poly_rem(mp_ptr R, mp_srcptr A, slong lenA, mp_srcptr B, slong lenB, nmod_t mod) noexcept # Computes the remainder `R` on polynomial division of `A` by `B`. - void nmod_poly_rem(nmod_poly_t R, const nmod_poly_t A, const nmod_poly_t B) + void nmod_poly_rem(nmod_poly_t R, const nmod_poly_t A, const nmod_poly_t B) noexcept # Computes the remainder `R` on polynomial division of `A` by `B`. - void _nmod_poly_inv_series_basecase(mp_ptr Qinv, mp_srcptr Q, slong Qlen, slong n, nmod_t mod) + void _nmod_poly_inv_series_basecase(mp_ptr Qinv, mp_srcptr Q, slong Qlen, slong n, nmod_t mod) noexcept # Given ``Q`` of length ``Qlen`` whose leading coefficient is invertible # modulo the given modulus, finds a polynomial ``Qinv`` of length ``n`` # such that the top ``n`` coefficients of the product ``Q * Qinv`` is # `x^{n - 1}`. Requires that ``n > 0``. This function can be viewed as # inverting a power series. - void nmod_poly_inv_series_basecase(nmod_poly_t Qinv, const nmod_poly_t Q, slong n) + void nmod_poly_inv_series_basecase(nmod_poly_t Qinv, const nmod_poly_t Q, slong n) noexcept # Given ``Q`` of length at least ``n`` find ``Qinv`` of length # ``n`` such that the top ``n`` coefficients of the product # ``Q * Qinv`` is `x^{n - 1}`. An exception is raised if ``n = 0`` @@ -731,34 +731,34 @@ cdef extern from "flint_wrap.h": # coefficient of ``Q`` must be invertible modulo the modulus of # ``Q``. This function can be viewed as inverting a power series. - void _nmod_poly_inv_series_newton(mp_ptr Qinv, mp_srcptr Q, slong Qlen, slong n, nmod_t mod) + void _nmod_poly_inv_series_newton(mp_ptr Qinv, mp_srcptr Q, slong Qlen, slong n, nmod_t mod) noexcept # Given ``Q`` of length ``Qlen`` whose constant coefficient is invertible # modulo the given modulus, find a polynomial ``Qinv`` of length ``n`` # such that ``Q * Qinv`` is ``1`` modulo `x^n`. Requires ``n > 0``. # This function can be viewed as inverting a power series via Newton # iteration. - void nmod_poly_inv_series_newton(nmod_poly_t Qinv, const nmod_poly_t Q, slong n) + void nmod_poly_inv_series_newton(nmod_poly_t Qinv, const nmod_poly_t Q, slong n) noexcept # Given ``Q`` find ``Qinv`` such that ``Q * Qinv`` is ``1`` # modulo `x^n`. The constant coefficient of ``Q`` must be invertible # modulo the modulus of ``Q``. An exception is raised if this is not # the case or if ``n = 0``. This function can be viewed as inverting # a power series via Newton iteration. - void _nmod_poly_inv_series(mp_ptr Qinv, mp_srcptr Q, slong Qlen, slong n, nmod_t mod) + void _nmod_poly_inv_series(mp_ptr Qinv, mp_srcptr Q, slong Qlen, slong n, nmod_t mod) noexcept # Given ``Q`` of length ``Qlenn`` whose constant coefficient is invertible # modulo the given modulus, find a polynomial ``Qinv`` of length ``n`` # such that ``Q * Qinv`` is ``1`` modulo `x^n`. Requires ``n > 0``. # This function can be viewed as inverting a power series. - void nmod_poly_inv_series(nmod_poly_t Qinv, const nmod_poly_t Q, slong n) + void nmod_poly_inv_series(nmod_poly_t Qinv, const nmod_poly_t Q, slong n) noexcept # Given ``Q`` find ``Qinv`` such that ``Q * Qinv`` is ``1`` # modulo `x^n`. The constant coefficient of ``Q`` must be invertible # modulo the modulus of ``Q``. An exception is raised if this is not # the case or if ``n = 0``. This function can be viewed as inverting # a power series. - void _nmod_poly_div_series_basecase(mp_ptr Q, mp_srcptr A, slong Alen, mp_srcptr B, slong Blen, slong n, nmod_t mod) + void _nmod_poly_div_series_basecase(mp_ptr Q, mp_srcptr A, slong Alen, mp_srcptr B, slong Blen, slong n, nmod_t mod) noexcept # Given polynomials ``A`` and ``B`` of length ``Alen`` and # ``Blen``, finds the # polynomial ``Q`` of length ``n`` such that ``Q * B = A`` @@ -766,7 +766,7 @@ cdef extern from "flint_wrap.h": # of ``B`` is invertible modulo the given modulus. The polynomial # ``Q`` must have space for ``n`` coefficients. - void nmod_poly_div_series_basecase(nmod_poly_t Q, const nmod_poly_t A, const nmod_poly_t B, slong n) + void nmod_poly_div_series_basecase(nmod_poly_t Q, const nmod_poly_t A, const nmod_poly_t B, slong n) noexcept # Given polynomials ``A`` and ``B`` considered modulo ``n``, # finds the polynomial ``Q`` of length at most ``n`` such that # ``Q * B = A`` modulo `x^n`. We assume ``n > 0`` and that the @@ -774,7 +774,7 @@ cdef extern from "flint_wrap.h": # An exception is raised if ``n == 0`` or the constant coefficient # of ``B`` is zero. - void _nmod_poly_div_series(mp_ptr Q, mp_srcptr A, slong Alen, mp_srcptr B, slong Blen, slong n, nmod_t mod) + void _nmod_poly_div_series(mp_ptr Q, mp_srcptr A, slong Alen, mp_srcptr B, slong Blen, slong n, nmod_t mod) noexcept # Given polynomials ``A`` and ``B`` of length ``Alen`` and # ``Blen``, finds the # polynomial ``Q`` of length ``n`` such that ``Q * B = A`` @@ -782,7 +782,7 @@ cdef extern from "flint_wrap.h": # of ``B`` is invertible modulo the given modulus. The polynomial # ``Q`` must have space for ``n`` coefficients. - void nmod_poly_div_series(nmod_poly_t Q, const nmod_poly_t A, const nmod_poly_t B, slong n) + void nmod_poly_div_series(nmod_poly_t Q, const nmod_poly_t A, const nmod_poly_t B, slong n) noexcept # Given polynomials ``A`` and ``B`` considered modulo ``n``, # finds the polynomial ``Q`` of length at most ``n`` such that # ``Q * B = A`` modulo `x^n`. We assume ``n > 0`` and that the @@ -790,7 +790,7 @@ cdef extern from "flint_wrap.h": # An exception is raised if ``n == 0`` or the constant coefficient # of ``B`` is zero. - void _nmod_poly_div_newton_n_preinv (mp_ptr Q, mp_srcptr A, slong lenA, mp_srcptr B, slong lenB, mp_srcptr Binv, slong lenBinv, nmod_t mod) + void _nmod_poly_div_newton_n_preinv (mp_ptr Q, mp_srcptr A, slong lenA, mp_srcptr B, slong lenB, mp_srcptr Binv, slong lenBinv, nmod_t mod) noexcept # Notionally computes polynomials `Q` and `R` such that `A = BQ + R` with # `\operatorname{len}(R)` less than ``lenB``, where ``A`` is of length ``lenA`` # and ``B`` is of length ``lenB``, but return only `Q`. @@ -800,7 +800,7 @@ cdef extern from "flint_wrap.h": # The algorithm used is to reverse the polynomials and divide the # resulting power series, then reverse the result. - void nmod_poly_div_newton_n_preinv (nmod_poly_t Q, const nmod_poly_t A, const nmod_poly_t B, const nmod_poly_t Binv) + void nmod_poly_div_newton_n_preinv (nmod_poly_t Q, const nmod_poly_t A, const nmod_poly_t B, const nmod_poly_t Binv) noexcept # Notionally computes `Q` and `R` such that `A = BQ + R` with # `\operatorname{len}(R) < \operatorname{len}(B)`, but returns only `Q`. # We assume that the leading coefficient of `B` is a unit and that `Binv` is @@ -810,7 +810,7 @@ cdef extern from "flint_wrap.h": # The algorithm used is to reverse the polynomials and divide the # resulting power series, then reverse the result. - void _nmod_poly_divrem_newton_n_preinv (mp_ptr Q, mp_ptr R, mp_srcptr A, slong lenA, mp_srcptr B, slong lenB, mp_srcptr Binv, slong lenBinv, nmod_t mod) + void _nmod_poly_divrem_newton_n_preinv (mp_ptr Q, mp_ptr R, mp_srcptr A, slong lenA, mp_srcptr B, slong lenB, mp_srcptr Binv, slong lenBinv, nmod_t mod) noexcept # Computes `Q` and `R` such that `A = BQ + R` with `\operatorname{len}(R)` less than # ``lenB``, where `A` is of length ``lenA`` and `B` is of length # ``lenB``. We require that `Q` have space for ``lenA - lenB + 1`` @@ -819,7 +819,7 @@ cdef extern from "flint_wrap.h": # :func:`div_newton_n_preinv` and then multiply out and compute # the remainder. - void nmod_poly_divrem_newton_n_preinv(nmod_poly_t Q, nmod_poly_t R, const nmod_poly_t A, const nmod_poly_t B, const nmod_poly_t Binv) + void nmod_poly_divrem_newton_n_preinv(nmod_poly_t Q, nmod_poly_t R, const nmod_poly_t A, const nmod_poly_t B, const nmod_poly_t Binv) noexcept # Computes `Q` and `R` such that `A = BQ + R` with `\operatorname{len}(R) < \operatorname{len}(B)`. # We assume `Binv` is the inverse of the reverse of `B` mod `x^{\operatorname{len}(B)}`. # It is required that the length of `A` is less than or equal to @@ -827,43 +827,43 @@ cdef extern from "flint_wrap.h": # The algorithm used is to call :func:`div_newton_n` and then multiply out # and compute the remainder. - mp_limb_t _nmod_poly_div_root(mp_ptr Q, mp_srcptr A, slong len, mp_limb_t c, nmod_t mod) + mp_limb_t _nmod_poly_div_root(mp_ptr Q, mp_srcptr A, slong len, mp_limb_t c, nmod_t mod) noexcept # Sets ``(Q, len-1)`` to the quotient of ``(A, len)`` on division # by `(x - c)`, and returns the remainder, equal to the value of `A` # evaluated at `c`. `A` and `Q` are allowed to be the same, but may # not overlap partially in any other way. - mp_limb_t nmod_poly_div_root(nmod_poly_t Q, const nmod_poly_t A, mp_limb_t c) + mp_limb_t nmod_poly_div_root(nmod_poly_t Q, const nmod_poly_t A, mp_limb_t c) noexcept # Sets `Q` to the quotient of `A` on division by `(x - c)`, and returns # the remainder, equal to the value of `A` evaluated at `c`. - int _nmod_poly_divides_classical(mp_ptr Q, mp_srcptr A, slong lenA, mp_srcptr B, slong lenB, nmod_t mod) + int _nmod_poly_divides_classical(mp_ptr Q, mp_srcptr A, slong lenA, mp_srcptr B, slong lenB, nmod_t mod) noexcept # Returns `1` if `(B, lenB)` divides `(A, lenA)` and sets # `(Q, lenA - lenB + 1)` to the quotient. Otherwise, returns `0` and sets # `(Q, lenA - lenB + 1)` to zero. We require that `lenA >= lenB > 0`. - int nmod_poly_divides_classical(nmod_poly_t Q, const nmod_poly_t A, const nmod_poly_t B) + int nmod_poly_divides_classical(nmod_poly_t Q, const nmod_poly_t A, const nmod_poly_t B) noexcept # Returns `1` if `B` divides `A` and sets `Q` to the quotient. Otherwise # returns `0` and sets `Q` to zero. - int _nmod_poly_divides(mp_ptr Q, mp_srcptr A, slong lenA, mp_srcptr B, slong lenB, nmod_t mod) + int _nmod_poly_divides(mp_ptr Q, mp_srcptr A, slong lenA, mp_srcptr B, slong lenB, nmod_t mod) noexcept # Returns `1` if `(B, lenB)` divides `(A, lenA)` and sets # `(Q, lenA - lenB + 1)` to the quotient. Otherwise, returns `0` and sets # `(Q, lenA - lenB + 1)` to zero. We require that `lenA >= lenB > 0`. - int nmod_poly_divides(nmod_poly_t Q, const nmod_poly_t A, const nmod_poly_t B) + int nmod_poly_divides(nmod_poly_t Q, const nmod_poly_t A, const nmod_poly_t B) noexcept # Returns `1` if `B` divides `A` and sets `Q` to the quotient. Otherwise # returns `0` and sets `Q` to zero. - void _nmod_poly_derivative(mp_ptr x_prime, mp_srcptr x, slong len, nmod_t mod) + void _nmod_poly_derivative(mp_ptr x_prime, mp_srcptr x, slong len, nmod_t mod) noexcept # Sets the first ``len - 1`` coefficients of ``x_prime`` to the # derivative of ``x`` which is assumed to be of length ``len``. # It is assumed that ``len > 0``. - void nmod_poly_derivative(nmod_poly_t x_prime, const nmod_poly_t x) + void nmod_poly_derivative(nmod_poly_t x_prime, const nmod_poly_t x) noexcept # Sets ``x_prime`` to the derivative of ``x``. - void _nmod_poly_integral(mp_ptr x_int, mp_srcptr x, slong len, nmod_t mod) + void _nmod_poly_integral(mp_ptr x_int, mp_srcptr x, slong len, nmod_t mod) noexcept # Set the first ``len`` coefficients of ``x_int`` to the # integral of ``x`` which is assumed to be of length ``len - 1``. # The constant term of ``x_int`` is set to zero. @@ -871,83 +871,83 @@ cdef extern from "flint_wrap.h": # if the modulus is a prime number strictly larger than the degree of # ``x``. Supports aliasing between the two polynomials. - void nmod_poly_integral(nmod_poly_t x_int, const nmod_poly_t x) + void nmod_poly_integral(nmod_poly_t x_int, const nmod_poly_t x) noexcept # Set ``x_int`` to the indefinite integral of ``x`` with constant # term zero. The result is only well-defined if the modulus # is a prime number strictly larger than the degree of ``x``. - mp_limb_t _nmod_poly_evaluate_nmod(mp_srcptr poly, slong len, mp_limb_t c, nmod_t mod) + mp_limb_t _nmod_poly_evaluate_nmod(mp_srcptr poly, slong len, mp_limb_t c, nmod_t mod) noexcept # Evaluates ``poly`` at the value ``c`` and reduces modulo the # given modulus of ``poly``. The value ``c`` should be reduced # modulo the modulus. The algorithm used is Horner's method. - mp_limb_t nmod_poly_evaluate_nmod(const nmod_poly_t poly, mp_limb_t c) + mp_limb_t nmod_poly_evaluate_nmod(const nmod_poly_t poly, mp_limb_t c) noexcept # Evaluates ``poly`` at the value ``c`` and reduces modulo the # modulus of ``poly``. The value ``c`` should be reduced modulo # the modulus. The algorithm used is Horner's method. - void nmod_poly_evaluate_mat_horner(nmod_mat_t dest, const nmod_poly_t poly, const nmod_mat_t c) + void nmod_poly_evaluate_mat_horner(nmod_mat_t dest, const nmod_poly_t poly, const nmod_mat_t c) noexcept # Evaluates ``poly`` with matrix as an argument at the value ``c`` # and stores the result in ``dest``. The dimension and modulus of # ``dest`` is assumed to be same as that of ``c``. ``dest`` and # ``c`` may be aliased. Horner's Method is used to compute the result. - void nmod_poly_evaluate_mat_paterson_stockmeyer(nmod_mat_t dest, const nmod_poly_t poly, const nmod_mat_t c) + void nmod_poly_evaluate_mat_paterson_stockmeyer(nmod_mat_t dest, const nmod_poly_t poly, const nmod_mat_t c) noexcept # Evaluates ``poly`` with matrix as an argument at the value ``c`` # and stores the result in ``dest``. The dimension and modulus of # ``dest`` is assumed to be same as that of ``c``. ``dest`` and # ``c`` may be aliased. Paterson-Stockmeyer algorithm is used to compute # the result. The algorithm is described in [Paterson1973]_. - void nmod_poly_evaluate_mat(nmod_mat_t dest, const nmod_poly_t poly, const nmod_mat_t c) + void nmod_poly_evaluate_mat(nmod_mat_t dest, const nmod_poly_t poly, const nmod_mat_t c) noexcept # Evaluates ``poly`` with matrix as an argument at the value ``c`` # and stores the result in ``dest``. The dimension and modulus of # ``dest`` is assumed to be same as that of ``c``. ``dest`` and # ``c`` may be aliased. This function automatically switches between # Horner's method and the Paterson-Stockmeyer algorithm. - void _nmod_poly_evaluate_nmod_vec_iter(mp_ptr ys, mp_srcptr poly, slong len, mp_srcptr xs, slong n, nmod_t mod) + void _nmod_poly_evaluate_nmod_vec_iter(mp_ptr ys, mp_srcptr poly, slong len, mp_srcptr xs, slong n, nmod_t mod) noexcept # Evaluates (``coeffs``, ``len``) at the ``n`` values # given in the vector ``xs``, writing the output values # to ``ys``. The values in ``xs`` should be reduced # modulo the modulus. # Uses Horner's method iteratively. - void nmod_poly_evaluate_nmod_vec_iter(mp_ptr ys, const nmod_poly_t poly, mp_srcptr xs, slong n) + void nmod_poly_evaluate_nmod_vec_iter(mp_ptr ys, const nmod_poly_t poly, mp_srcptr xs, slong n) noexcept # Evaluates ``poly`` at the ``n`` values given in the vector # ``xs``, writing the output values to ``ys``. The values in # ``xs`` should be reduced modulo the modulus. # Uses Horner's method iteratively. - void _nmod_poly_evaluate_nmod_vec_fast_precomp(mp_ptr vs, mp_srcptr poly, slong plen, const mp_ptr * tree, slong len, nmod_t mod) + void _nmod_poly_evaluate_nmod_vec_fast_precomp(mp_ptr vs, mp_srcptr poly, slong plen, const mp_ptr * tree, slong len, nmod_t mod) noexcept # Evaluates (``poly``, ``plen``) at the ``len`` values given # by the precomputed subproduct tree ``tree``. - void _nmod_poly_evaluate_nmod_vec_fast(mp_ptr ys, mp_srcptr poly, slong len, mp_srcptr xs, slong n, nmod_t mod) + void _nmod_poly_evaluate_nmod_vec_fast(mp_ptr ys, mp_srcptr poly, slong len, mp_srcptr xs, slong n, nmod_t mod) noexcept # Evaluates (``coeffs``, ``len``) at the ``n`` values # given in the vector ``xs``, writing the output values # to ``ys``. The values in ``xs`` should be reduced # modulo the modulus. # Uses fast multipoint evaluation, building a temporary subproduct tree. - void nmod_poly_evaluate_nmod_vec_fast(mp_ptr ys, const nmod_poly_t poly, mp_srcptr xs, slong n) + void nmod_poly_evaluate_nmod_vec_fast(mp_ptr ys, const nmod_poly_t poly, mp_srcptr xs, slong n) noexcept # Evaluates ``poly`` at the ``n`` values given in the vector # ``xs``, writing the output values to ``ys``. The values in # ``xs`` should be reduced modulo the modulus. # Uses fast multipoint evaluation, building a temporary subproduct tree. - void _nmod_poly_evaluate_nmod_vec(mp_ptr ys, mp_srcptr poly, slong len, mp_srcptr xs, slong n, nmod_t mod) + void _nmod_poly_evaluate_nmod_vec(mp_ptr ys, mp_srcptr poly, slong len, mp_srcptr xs, slong n, nmod_t mod) noexcept # Evaluates (``poly``, ``len``) at the ``n`` values # given in the vector ``xs``, writing the output values # to ``ys``. The values in ``xs`` should be reduced # modulo the modulus. - void nmod_poly_evaluate_nmod_vec(mp_ptr ys, const nmod_poly_t poly, mp_srcptr xs, slong n) + void nmod_poly_evaluate_nmod_vec(mp_ptr ys, const nmod_poly_t poly, mp_srcptr xs, slong n) noexcept # Evaluates ``poly`` at the ``n`` values given in the vector # ``xs``, writing the output values to ``ys``. The values in # ``xs`` should be reduced modulo the modulus. - void _nmod_poly_interpolate_nmod_vec(mp_ptr poly, mp_srcptr xs, mp_srcptr ys, slong n, nmod_t mod) + void _nmod_poly_interpolate_nmod_vec(mp_ptr poly, mp_srcptr xs, mp_srcptr ys, slong n, nmod_t mod) noexcept # Sets ``poly`` to the unique polynomial of length at most ``n`` # that interpolates the ``n`` given evaluation points ``xs`` and # values ``ys``. If the interpolating polynomial is shorter than @@ -956,17 +956,17 @@ cdef extern from "flint_wrap.h": # modulus, and all ``xs`` must be distinct. Aliasing between # ``poly`` and ``xs`` or ``ys`` is not allowed. - void nmod_poly_interpolate_nmod_vec(nmod_poly_t poly, mp_srcptr xs, mp_srcptr ys, slong n) + void nmod_poly_interpolate_nmod_vec(nmod_poly_t poly, mp_srcptr xs, mp_srcptr ys, slong n) noexcept # Sets ``poly`` to the unique polynomial of length ``n`` that # interpolates the ``n`` given evaluation points ``xs`` and # values ``ys``. The values in ``xs`` and ``ys`` should be # reduced modulo the modulus, and all ``xs`` must be distinct. - void _nmod_poly_interpolation_weights(mp_ptr w, const mp_ptr * tree, slong len, nmod_t mod) + void _nmod_poly_interpolation_weights(mp_ptr w, const mp_ptr * tree, slong len, nmod_t mod) noexcept # Sets ``w`` to the barycentric interpolation weights for fast # Lagrange interpolation with respect to a given subproduct tree. - void _nmod_poly_interpolate_nmod_vec_fast_precomp(mp_ptr poly, mp_srcptr ys, const mp_ptr * tree, mp_srcptr weights, slong len, nmod_t mod) + void _nmod_poly_interpolate_nmod_vec_fast_precomp(mp_ptr poly, mp_srcptr ys, const mp_ptr * tree, mp_srcptr weights, slong len, nmod_t mod) noexcept # Performs interpolation using the fast Lagrange interpolation # algorithm, generating a temporary subproduct tree. # The function values are given as ``ys``. The function takes @@ -974,45 +974,45 @@ cdef extern from "flint_wrap.h": # interpolation weights ``weights`` corresponding to the # roots. - void _nmod_poly_interpolate_nmod_vec_fast(mp_ptr poly, mp_srcptr xs, mp_srcptr ys, slong n, nmod_t mod) + void _nmod_poly_interpolate_nmod_vec_fast(mp_ptr poly, mp_srcptr xs, mp_srcptr ys, slong n, nmod_t mod) noexcept # Performs interpolation using the fast Lagrange interpolation # algorithm, generating a temporary subproduct tree. - void nmod_poly_interpolate_nmod_vec_fast(nmod_poly_t poly, mp_srcptr xs, mp_srcptr ys, slong n) + void nmod_poly_interpolate_nmod_vec_fast(nmod_poly_t poly, mp_srcptr xs, mp_srcptr ys, slong n) noexcept # Performs interpolation using the fast Lagrange interpolation algorithm, # generating a temporary subproduct tree. - void _nmod_poly_interpolate_nmod_vec_newton(mp_ptr poly, mp_srcptr xs, mp_srcptr ys, slong n, nmod_t mod) + void _nmod_poly_interpolate_nmod_vec_newton(mp_ptr poly, mp_srcptr xs, mp_srcptr ys, slong n, nmod_t mod) noexcept # Forms the interpolating polynomial in the Newton basis using # the method of divided differences and then converts it to # monomial form. - void nmod_poly_interpolate_nmod_vec_newton(nmod_poly_t poly, mp_srcptr xs, mp_srcptr ys, slong n) + void nmod_poly_interpolate_nmod_vec_newton(nmod_poly_t poly, mp_srcptr xs, mp_srcptr ys, slong n) noexcept # Forms the interpolating polynomial in the Newton basis using # the method of divided differences and then converts it to # monomial form. - void _nmod_poly_interpolate_nmod_vec_barycentric(mp_ptr poly, mp_srcptr xs, mp_srcptr ys, slong n, nmod_t mod) + void _nmod_poly_interpolate_nmod_vec_barycentric(mp_ptr poly, mp_srcptr xs, mp_srcptr ys, slong n, nmod_t mod) noexcept # Forms the interpolating polynomial using a naive implementation # of the barycentric form of Lagrange interpolation. - void nmod_poly_interpolate_nmod_vec_barycentric(nmod_poly_t poly, mp_srcptr xs, mp_srcptr ys, slong n) + void nmod_poly_interpolate_nmod_vec_barycentric(nmod_poly_t poly, mp_srcptr xs, mp_srcptr ys, slong n) noexcept # Forms the interpolating polynomial using a naive implementation # of the barycentric form of Lagrange interpolation. - void _nmod_poly_compose_horner(mp_ptr res, mp_srcptr poly1, slong len1, mp_srcptr poly2, slong len2, nmod_t mod) + void _nmod_poly_compose_horner(mp_ptr res, mp_srcptr poly1, slong len1, mp_srcptr poly2, slong len2, nmod_t mod) noexcept # Composes ``poly1`` of length ``len1`` with ``poly2`` of length # ``len2`` and sets ``res`` to the result, i.e. evaluates # ``poly1`` at ``poly2``. The algorithm used is Horner's algorithm. # We require that ``res`` have space for ``(len1 - 1)*(len2 - 1) + 1`` # coefficients. It is assumed that ``len1 > 0`` and ``len2 > 0``. - void nmod_poly_compose_horner(nmod_poly_t res, const nmod_poly_t poly1, const nmod_poly_t poly2) + void nmod_poly_compose_horner(nmod_poly_t res, const nmod_poly_t poly1, const nmod_poly_t poly2) noexcept # Composes ``poly1`` with ``poly2`` and sets ``res`` to the result, # i.e. evaluates ``poly1`` at ``poly2``. The algorithm used is # Horner's algorithm. - void _nmod_poly_compose_divconquer(mp_ptr res, mp_srcptr poly1, slong len1, mp_srcptr poly2, slong len2, nmod_t mod) + void _nmod_poly_compose_divconquer(mp_ptr res, mp_srcptr poly1, slong len1, mp_srcptr poly2, slong len2, nmod_t mod) noexcept # Composes ``poly1`` of length ``len1`` with ``poly2`` of length # ``len2`` and sets ``res`` to the result, i.e. evaluates # ``poly1`` at ``poly2``. The algorithm used is the divide and @@ -1020,59 +1020,59 @@ cdef extern from "flint_wrap.h": # ``(len1 - 1)*(len2 - 1) + 1`` coefficients. It is assumed that # ``len1 > 0`` and ``len2 > 0``. - void nmod_poly_compose_divconquer(nmod_poly_t res, const nmod_poly_t poly1, const nmod_poly_t poly2) + void nmod_poly_compose_divconquer(nmod_poly_t res, const nmod_poly_t poly1, const nmod_poly_t poly2) noexcept # Composes ``poly1`` with ``poly2`` and sets ``res`` to the result, # i.e. evaluates ``poly1`` at ``poly2``. The algorithm used is # the divide and conquer algorithm. - void _nmod_poly_compose(mp_ptr res, mp_srcptr poly1, slong len1, mp_srcptr poly2, slong len2, nmod_t mod) + void _nmod_poly_compose(mp_ptr res, mp_srcptr poly1, slong len1, mp_srcptr poly2, slong len2, nmod_t mod) noexcept # Composes ``poly1`` of length ``len1`` with ``poly2`` of length # ``len2`` and sets ``res`` to the result, i.e. evaluates ``poly1`` # at ``poly2``. We require that ``res`` have space for # ``(len1 - 1)*(len2 - 1) + 1`` coefficients. It is assumed that # ``len1 > 0`` and ``len2 > 0``. - void nmod_poly_compose(nmod_poly_t res, const nmod_poly_t poly1, const nmod_poly_t poly2) + void nmod_poly_compose(nmod_poly_t res, const nmod_poly_t poly1, const nmod_poly_t poly2) noexcept # Composes ``poly1`` with ``poly2`` and sets ``res`` to the result, # that is, evaluates ``poly1`` at ``poly2``. - void _nmod_poly_taylor_shift_horner(mp_ptr poly, mp_limb_t c, slong len, nmod_t mod) + void _nmod_poly_taylor_shift_horner(mp_ptr poly, mp_limb_t c, slong len, nmod_t mod) noexcept # Performs the Taylor shift composing ``poly`` by `x+c` in-place. # Uses an efficient version Horner's rule. - void nmod_poly_taylor_shift_horner(nmod_poly_t g, const nmod_poly_t f, mp_limb_t c) + void nmod_poly_taylor_shift_horner(nmod_poly_t g, const nmod_poly_t f, mp_limb_t c) noexcept # Performs the Taylor shift composing ``f`` by `x+c`. - void _nmod_poly_taylor_shift_convolution(mp_ptr poly, mp_limb_t c, slong len, nmod_t mod) + void _nmod_poly_taylor_shift_convolution(mp_ptr poly, mp_limb_t c, slong len, nmod_t mod) noexcept # Performs the Taylor shift composing ``poly`` by `x+c` in-place. # Writes the composition as a single convolution with cost `O(M(n))`. # We require that the modulus is a prime at least as large as the length. - void nmod_poly_taylor_shift_convolution(nmod_poly_t g, const nmod_poly_t f, mp_limb_t c) + void nmod_poly_taylor_shift_convolution(nmod_poly_t g, const nmod_poly_t f, mp_limb_t c) noexcept # Performs the Taylor shift composing ``f`` by `x+c`. # Writes the composition as a single convolution with cost `O(M(n))`. # We require that the modulus is a prime at least as large as the length. - void _nmod_poly_taylor_shift(mp_ptr poly, mp_limb_t c, slong len, nmod_t mod) + void _nmod_poly_taylor_shift(mp_ptr poly, mp_limb_t c, slong len, nmod_t mod) noexcept # Performs the Taylor shift composing ``poly`` by `x+c` in-place. # We require that the modulus is a prime. - void nmod_poly_taylor_shift(nmod_poly_t g, const nmod_poly_t f, mp_limb_t c) + void nmod_poly_taylor_shift(nmod_poly_t g, const nmod_poly_t f, mp_limb_t c) noexcept # Performs the Taylor shift composing ``f`` by `x+c`. # We require that the modulus is a prime. - void _nmod_poly_compose_mod_horner(mp_ptr res, mp_srcptr f, slong lenf, mp_srcptr g, mp_srcptr h, slong lenh, nmod_t mod) + void _nmod_poly_compose_mod_horner(mp_ptr res, mp_srcptr f, slong lenf, mp_srcptr g, mp_srcptr h, slong lenh, nmod_t mod) noexcept # Sets ``res`` to the composition `f(g)` modulo `h`. We require that # `h` is nonzero and that the length of `g` is one less than the # length of `h` (possibly with zero padding). The output is not allowed # to be aliased with any of the inputs. # The algorithm used is Horner's rule. - void nmod_poly_compose_mod_horner(nmod_poly_t res, const nmod_poly_t f, const nmod_poly_t g, const nmod_poly_t h) + void nmod_poly_compose_mod_horner(nmod_poly_t res, const nmod_poly_t f, const nmod_poly_t g, const nmod_poly_t h) noexcept # Sets ``res`` to the composition `f(g)` modulo `h`. We require that # `h` is nonzero. The algorithm used is Horner's rule. - void _nmod_poly_compose_mod_brent_kung(mp_ptr res, mp_srcptr f, slong lenf, mp_srcptr g, mp_srcptr h, slong lenh, nmod_t mod) + void _nmod_poly_compose_mod_brent_kung(mp_ptr res, mp_srcptr f, slong lenf, mp_srcptr g, mp_srcptr h, slong lenh, nmod_t mod) noexcept # Sets ``res`` to the composition `f(g)` modulo `h`. We require that # `h` is nonzero and that the length of `g` is one less than the # length of `h` (possibly with zero padding). We also require that @@ -1080,12 +1080,12 @@ cdef extern from "flint_wrap.h": # to be aliased with any of the inputs. # The algorithm used is the Brent-Kung matrix algorithm. - void nmod_poly_compose_mod_brent_kung(nmod_poly_t res, const nmod_poly_t f, const nmod_poly_t g, const nmod_poly_t h) + void nmod_poly_compose_mod_brent_kung(nmod_poly_t res, const nmod_poly_t f, const nmod_poly_t g, const nmod_poly_t h) noexcept # Sets ``res`` to the composition `f(g)` modulo `h`. We require that # `h` is nonzero and that `f` has smaller degree than `h`. # The algorithm used is the Brent-Kung matrix algorithm. - void _nmod_poly_compose_mod_brent_kung_preinv(mp_ptr res, mp_srcptr f, slong lenf, mp_srcptr g, mp_srcptr h, slong lenh, mp_srcptr hinv, slong lenhinv, nmod_t mod) + void _nmod_poly_compose_mod_brent_kung_preinv(mp_ptr res, mp_srcptr f, slong lenf, mp_srcptr g, mp_srcptr h, slong lenh, mp_srcptr hinv, slong lenhinv, nmod_t mod) noexcept # Sets ``res`` to the composition `f(g)` modulo `h`. We require that # `h` is nonzero and that the length of `g` is one less than the # length of `h` (possibly with zero padding). We also require that @@ -1094,22 +1094,22 @@ cdef extern from "flint_wrap.h": # The output is not allowed to be aliased with any of the inputs. # The algorithm used is the Brent-Kung matrix algorithm. - void nmod_poly_compose_mod_brent_kung_preinv(nmod_poly_t res, const nmod_poly_t f, const nmod_poly_t g, const nmod_poly_t h, const nmod_poly_t hinv) + void nmod_poly_compose_mod_brent_kung_preinv(nmod_poly_t res, const nmod_poly_t f, const nmod_poly_t g, const nmod_poly_t h, const nmod_poly_t hinv) noexcept # Sets ``res`` to the composition `f(g)` modulo `h`. We require that # `h` is nonzero and that `f` has smaller degree than `h`. Furthermore, # we require ``hinv`` to be the inverse of the reverse of ``h``. # The algorithm used is the Brent-Kung matrix algorithm. - void _nmod_poly_reduce_matrix_mod_poly (nmod_mat_t A, const nmod_mat_t B, const nmod_poly_t f) + void _nmod_poly_reduce_matrix_mod_poly (nmod_mat_t A, const nmod_mat_t B, const nmod_poly_t f) noexcept # Sets the ith row of ``A`` to the reduction of the ith row of `B` modulo # `f` for `i=1,\ldots,\sqrt{\deg(f)}`. We require `B` to be at least # a `\sqrt{\deg(f)}\times \deg(f)` matrix and `f` to be nonzero. - void _nmod_poly_precompute_matrix_worker (void * arg_ptr) + void _nmod_poly_precompute_matrix_worker (void * arg_ptr) noexcept # Worker function version of ``_nmod_poly_precompute_matrix``. # Input/output is stored in ``nmod_poly_matrix_precompute_arg_t``. - void _nmod_poly_precompute_matrix (nmod_mat_t A, mp_srcptr f, mp_srcptr g, slong leng, mp_srcptr ginv, slong lenginv, nmod_t mod) + void _nmod_poly_precompute_matrix (nmod_mat_t A, mp_srcptr f, mp_srcptr g, slong leng, mp_srcptr ginv, slong lenginv, nmod_t mod) noexcept # Sets the ith row of ``A`` to `f^i` modulo `g` for # `i=1,\ldots,\sqrt{\deg(g)}`. We require `A` to be # a `\sqrt{\deg(g)}\times \deg(g)` matrix. We require @@ -1117,19 +1117,19 @@ cdef extern from "flint_wrap.h": # nonzero. ``f`` has to be reduced modulo ``g`` and of length one less # than ``leng`` (possibly with zero padding). - void nmod_poly_precompute_matrix (nmod_mat_t A, const nmod_poly_t f, const nmod_poly_t g, const nmod_poly_t ginv) + void nmod_poly_precompute_matrix (nmod_mat_t A, const nmod_poly_t f, const nmod_poly_t g, const nmod_poly_t ginv) noexcept # Sets the ith row of ``A`` to `f^i` modulo `g` for # `i=1,\ldots,\sqrt{\deg(g)}`. We require `A` to be # a `\sqrt{\deg(g)}\times \deg(g)` matrix. We require # ``ginv`` to be the inverse of the reverse of ``g``. - void _nmod_poly_compose_mod_brent_kung_precomp_preinv_worker(void * arg_ptr) + void _nmod_poly_compose_mod_brent_kung_precomp_preinv_worker(void * arg_ptr) noexcept # Worker function version of # ``_nmod_poly_compose_mod_brent_kung_precomp_preinv``. # Input/output is stored in # ``nmod_poly_compose_mod_precomp_preinv_arg_t``. - void _nmod_poly_compose_mod_brent_kung_precomp_preinv(mp_ptr res, mp_srcptr f, slong lenf, const nmod_mat_t A, mp_srcptr h, slong lenh, mp_srcptr hinv, slong lenhinv, nmod_t mod) + void _nmod_poly_compose_mod_brent_kung_precomp_preinv(mp_ptr res, mp_srcptr f, slong lenf, const nmod_mat_t A, mp_srcptr h, slong lenh, mp_srcptr hinv, slong lenhinv, nmod_t mod) noexcept # Sets ``res`` to the composition `f(g)` modulo `h`. We require that # `h` is nonzero. We require that the ith row of `A` contains `g^i` for # `i=1,\ldots,\sqrt{\deg(h)}`, i.e. `A` is a @@ -1139,7 +1139,7 @@ cdef extern from "flint_wrap.h": # The output is not allowed to be aliased with any of the inputs. # The algorithm used is the Brent-Kung matrix algorithm. - void nmod_poly_compose_mod_brent_kung_precomp_preinv(nmod_poly_t res, const nmod_poly_t f, const nmod_mat_t A, const nmod_poly_t h, const nmod_poly_t hinv) + void nmod_poly_compose_mod_brent_kung_precomp_preinv(nmod_poly_t res, const nmod_poly_t f, const nmod_mat_t A, const nmod_poly_t h, const nmod_poly_t hinv) noexcept # Sets ``res`` to the composition `f(g)` modulo `h`. We require that the # ith row of `A` contains `g^i` for `i=1,\ldots,\sqrt{\deg(h)}`, i.e. `A` is a # `\sqrt{\deg(h)}\times \deg(h)` matrix. We require that `h` is nonzero and @@ -1148,7 +1148,7 @@ cdef extern from "flint_wrap.h": # modular composition is particularly useful if one has to perform several # modular composition of the form `f(g)` modulo `h` for fixed `g` and `h`. - void _nmod_poly_compose_mod_brent_kung_vec_preinv(nmod_poly_struct * res, const nmod_poly_struct * polys, slong len1, slong l, mp_srcptr g, slong leng, mp_srcptr h, slong lenh, mp_srcptr hinv, slong lenhinv, nmod_t mod) + void _nmod_poly_compose_mod_brent_kung_vec_preinv(nmod_poly_struct * res, const nmod_poly_struct * polys, slong len1, slong l, mp_srcptr g, slong leng, mp_srcptr h, slong lenh, mp_srcptr hinv, slong lenhinv, nmod_t mod) noexcept # Sets ``res`` to the composition `f_i(g)` modulo `h` for `1\leq i \leq l`, # where `f_i` are the first ``l`` elements of ``polys``. We require that `h` # is nonzero and that the length of `g` is less than the length of `h`. We @@ -1160,7 +1160,7 @@ cdef extern from "flint_wrap.h": # aliased with any of the inputs. # The algorithm used is the Brent-Kung matrix algorithm. - void nmod_poly_compose_mod_brent_kung_vec_preinv(nmod_poly_struct * res, const nmod_poly_struct * polys, slong len1, slong n, const nmod_poly_t g, const nmod_poly_t h, const nmod_poly_t hinv) + void nmod_poly_compose_mod_brent_kung_vec_preinv(nmod_poly_struct * res, const nmod_poly_struct * polys, slong len1, slong n, const nmod_poly_t g, const nmod_poly_t h, const nmod_poly_t hinv) noexcept # Sets ``res`` to the composition `f_i(g)` modulo `h` for `1\leq i \leq n` # where `f_i` are the first ``n`` elements of ``polys``. We require ``res`` # to have enough memory allocated to hold ``n`` ``nmod_poly_struct``. The @@ -1170,44 +1170,44 @@ cdef extern from "flint_wrap.h": # of the reverse of ``h``. No aliasing of ``res`` and ``polys`` is allowed. # The algorithm used is the Brent-Kung matrix algorithm. - void _nmod_poly_compose_mod_brent_kung_vec_preinv_threaded_pool(nmod_poly_struct * res, const nmod_poly_struct * polys, slong lenpolys, slong l, mp_srcptr g, slong glen, mp_srcptr poly, slong len, mp_srcptr polyinv, slong leninv, nmod_t mod, thread_pool_handle * threads, slong num_threads) + void _nmod_poly_compose_mod_brent_kung_vec_preinv_threaded_pool(nmod_poly_struct * res, const nmod_poly_struct * polys, slong lenpolys, slong l, mp_srcptr g, slong glen, mp_srcptr poly, slong len, mp_srcptr polyinv, slong leninv, nmod_t mod, thread_pool_handle * threads, slong num_threads) noexcept # Multithreaded version of # :func:`_nmod_poly_compose_mod_brent_kung_vec_preinv`. Distributing the # Horner evaluations across :func:`flint_get_num_threads` threads. - void nmod_poly_compose_mod_brent_kung_vec_preinv_threaded_pool(nmod_poly_struct * res, const nmod_poly_struct * polys, slong len1, slong n, const nmod_poly_t g, const nmod_poly_t poly, const nmod_poly_t polyinv, thread_pool_handle * threads, slong num_threads) + void nmod_poly_compose_mod_brent_kung_vec_preinv_threaded_pool(nmod_poly_struct * res, const nmod_poly_struct * polys, slong len1, slong n, const nmod_poly_t g, const nmod_poly_t poly, const nmod_poly_t polyinv, thread_pool_handle * threads, slong num_threads) noexcept # Multithreaded version of # :func:`nmod_poly_compose_mod_brent_kung_vec_preinv`. Distributing the # Horner evaluations across :func:`flint_get_num_threads` threads. - void nmod_poly_compose_mod_brent_kung_vec_preinv_threaded(nmod_poly_struct * res, const nmod_poly_struct * polys, slong len1, slong n, const nmod_poly_t g, const nmod_poly_t poly, const nmod_poly_t polyinv) + void nmod_poly_compose_mod_brent_kung_vec_preinv_threaded(nmod_poly_struct * res, const nmod_poly_struct * polys, slong len1, slong n, const nmod_poly_t g, const nmod_poly_t poly, const nmod_poly_t polyinv) noexcept # Multithreaded version of # :func:`nmod_poly_compose_mod_brent_kung_vec_preinv`. Distributing the # Horner evaluations across :func:`flint_get_num_threads` threads. - void _nmod_poly_compose_mod(mp_ptr res, mp_srcptr f, slong lenf, mp_srcptr g, mp_srcptr h, slong lenh, nmod_t mod) + void _nmod_poly_compose_mod(mp_ptr res, mp_srcptr f, slong lenf, mp_srcptr g, mp_srcptr h, slong lenh, nmod_t mod) noexcept # Sets ``res`` to the composition `f(g)` modulo `h`. We require that # `h` is nonzero and that the length of `g` is one less than the # length of `h` (possibly with zero padding). The output is not allowed # to be aliased with any of the inputs. - void nmod_poly_compose_mod(nmod_poly_t res, const nmod_poly_t f, const nmod_poly_t g, const nmod_poly_t h) + void nmod_poly_compose_mod(nmod_poly_t res, const nmod_poly_t f, const nmod_poly_t g, const nmod_poly_t h) noexcept # Sets ``res`` to the composition `f(g)` modulo `h`. We require that # `h` is nonzero. - slong _nmod_poly_gcd_euclidean(mp_ptr G, mp_srcptr A, slong lenA, mp_srcptr B, slong lenB, nmod_t mod) + slong _nmod_poly_gcd_euclidean(mp_ptr G, mp_srcptr A, slong lenA, mp_srcptr B, slong lenB, nmod_t mod) noexcept # Computes the GCD of `A` of length ``lenA`` and `B` of length # ``lenB``, where ``lenA >= lenB > 0``. The length of the GCD `G` # is returned by the function. No attempt is made to make the GCD monic. It # is required that `G` have space for ``lenB`` coefficients. - void nmod_poly_gcd_euclidean(nmod_poly_t G, const nmod_poly_t A, const nmod_poly_t B) + void nmod_poly_gcd_euclidean(nmod_poly_t G, const nmod_poly_t A, const nmod_poly_t B) noexcept # Computes the GCD of `A` and `B`. The GCD of zero polynomials is # defined to be zero, whereas the GCD of the zero polynomial and some other # polynomial `P` is defined to be `P`. Except in the case where # the GCD is zero, the GCD `G` is made monic. - slong _nmod_poly_hgcd(mp_ptr *M, slong *lenM, mp_ptr A, slong *lenA, mp_ptr B, slong *lenB, mp_srcptr a, slong lena, mp_srcptr b, slong lenb, nmod_t mod) + slong _nmod_poly_hgcd(mp_ptr *M, slong *lenM, mp_ptr A, slong *lenA, mp_ptr B, slong *lenB, mp_srcptr a, slong lena, mp_srcptr b, slong lenb, nmod_t mod) noexcept # Computes the HGCD of `a` and `b`, that is, a matrix `M`, a sign `\sigma` # and two polynomials `A` and `B` such that # .. math :: @@ -1222,32 +1222,32 @@ cdef extern from "flint_wrap.h": # Assumes that ``M[0]``, ``M[1]``, ``M[2]``, and ``M[3]`` # each point to a vector of size at least `\operatorname{len}(a)`. - slong _nmod_poly_gcd_hgcd(mp_ptr G, mp_srcptr A, slong lenA, mp_srcptr B, slong lenB, nmod_t mod) + slong _nmod_poly_gcd_hgcd(mp_ptr G, mp_srcptr A, slong lenA, mp_srcptr B, slong lenB, nmod_t mod) noexcept # Computes the monic GCD of `A` and `B`, assuming that # `\operatorname{len}(A) \geq \operatorname{len}(B) > 0`. # Assumes that `G` has space for `\operatorname{len}(B)` coefficients and # returns the length of `G` on output. - void nmod_poly_gcd_hgcd(nmod_poly_t G, const nmod_poly_t A, const nmod_poly_t B) + void nmod_poly_gcd_hgcd(nmod_poly_t G, const nmod_poly_t A, const nmod_poly_t B) noexcept # Computes the monic GCD of `A` and `B` using the HGCD algorithm. # As a special case, the GCD of two zero polynomials is defined to be # the zero polynomial. # The time complexity of the algorithm is `\mathcal{O}(n \log^2 n)`. # For further details, see [ThullYap1990]_. - slong _nmod_poly_gcd(mp_ptr G, mp_srcptr A, slong lenA, mp_srcptr B, slong lenB, nmod_t mod) + slong _nmod_poly_gcd(mp_ptr G, mp_srcptr A, slong lenA, mp_srcptr B, slong lenB, nmod_t mod) noexcept # Computes the GCD of `A` of length ``lenA`` and `B` of length # ``lenB``, where ``lenA >= lenB > 0``. The length of the GCD `G` # is returned by the function. No attempt is made to make the GCD monic. It # is required that `G` have space for ``lenB`` coefficients. - void nmod_poly_gcd(nmod_poly_t G, const nmod_poly_t A, const nmod_poly_t B) + void nmod_poly_gcd(nmod_poly_t G, const nmod_poly_t A, const nmod_poly_t B) noexcept # Computes the GCD of `A` and `B`. The GCD of zero polynomials is # defined to be zero, whereas the GCD of the zero polynomial and some other # polynomial `P` is defined to be `P`. Except in the case where # the GCD is zero, the GCD `G` is made monic. - slong _nmod_poly_xgcd_euclidean(mp_ptr G, mp_ptr S, mp_ptr T, mp_srcptr A, slong A_len, mp_srcptr B, slong B_len, nmod_t mod) + slong _nmod_poly_xgcd_euclidean(mp_ptr G, mp_ptr S, mp_ptr T, mp_srcptr A, slong A_len, mp_srcptr B, slong B_len, nmod_t mod) noexcept # Computes the GCD of `A` and `B` together with cofactors `S` and `T` # such that `S A + T B = G`. Returns the length of `G`. # Assumes that `\operatorname{len}(A) \geq \operatorname{len}(B) \geq 1` and @@ -1259,7 +1259,7 @@ cdef extern from "flint_wrap.h": # `\operatorname{len}(T) \leq \max(\operatorname{len}(A) - \operatorname{len}(G), 1)`. # No aliasing of input and output operands is permitted. - void nmod_poly_xgcd_euclidean(nmod_poly_t G, nmod_poly_t S, nmod_poly_t T, const nmod_poly_t A, const nmod_poly_t B) + void nmod_poly_xgcd_euclidean(nmod_poly_t G, nmod_poly_t S, nmod_poly_t T, const nmod_poly_t A, const nmod_poly_t B) noexcept # Computes the GCD of `A` and `B`. The GCD of zero polynomials is # defined to be zero, whereas the GCD of the zero polynomial and some other # polynomial `P` is defined to be `P`. Except in the case where @@ -1268,7 +1268,7 @@ cdef extern from "flint_wrap.h": # ``S*A + T*B = G``. The length of ``S`` will be at most # ``lenB`` and the length of ``T`` will be at most ``lenA``. - slong _nmod_poly_xgcd_hgcd(mp_ptr G, mp_ptr S, mp_ptr T, mp_srcptr A, slong A_len, mp_srcptr B, slong B_len, nmod_t mod) + slong _nmod_poly_xgcd_hgcd(mp_ptr G, mp_ptr S, mp_ptr T, mp_srcptr A, slong A_len, mp_srcptr B, slong B_len, nmod_t mod) noexcept # Computes the GCD of `A` and `B`, where `\operatorname{len}(A) \geq \operatorname{len}(B) > 0`, # together with cofactors `S` and `T` such that `S A + T B = G`. Returns # the length of `G`. @@ -1280,7 +1280,7 @@ cdef extern from "flint_wrap.h": # Both `S` and `T` must have space for at least `2` coefficients. # No aliasing of input and output operands is permitted. - void nmod_poly_xgcd_hgcd(nmod_poly_t G, nmod_poly_t S, nmod_poly_t T, const nmod_poly_t A, const nmod_poly_t B) + void nmod_poly_xgcd_hgcd(nmod_poly_t G, nmod_poly_t S, nmod_poly_t T, const nmod_poly_t A, const nmod_poly_t B) noexcept # Computes the GCD of `A` and `B`. The GCD of zero polynomials is # defined to be zero, whereas the GCD of the zero polynomial and some other # polynomial `P` is defined to be `P`. Except in the case where @@ -1289,7 +1289,7 @@ cdef extern from "flint_wrap.h": # ``S*A + T*B = G``. The length of ``S`` will be at most # ``lenB`` and the length of ``T`` will be at most ``lenA``. - slong _nmod_poly_xgcd(mp_ptr G, mp_ptr S, mp_ptr T, mp_srcptr A, slong lenA, mp_srcptr B, slong lenB, nmod_t mod) + slong _nmod_poly_xgcd(mp_ptr G, mp_ptr S, mp_ptr T, mp_srcptr A, slong lenA, mp_srcptr B, slong lenB, nmod_t mod) noexcept # Computes the GCD of `A` and `B`, where `\operatorname{len}(A) \geq \operatorname{len}(B) > 0`, # together with cofactors `S` and `T` such that `S A + T B = G`. Returns # the length of `G`. @@ -1300,7 +1300,7 @@ cdef extern from "flint_wrap.h": # and `\operatorname{len}(T) \leq \operatorname{len}(A) - \operatorname{len}(G)`. # No aliasing of input and output operands is permitted. - void nmod_poly_xgcd(nmod_poly_t G, nmod_poly_t S, nmod_poly_t T, const nmod_poly_t A, const nmod_poly_t B) + void nmod_poly_xgcd(nmod_poly_t G, nmod_poly_t S, nmod_poly_t T, const nmod_poly_t A, const nmod_poly_t B) noexcept # Computes the GCD of `A` and `B`. The GCD of zero polynomials is # defined to be zero, whereas the GCD of the zero polynomial and some other # polynomial `P` is defined to be `P`. Except in the case where @@ -1309,13 +1309,13 @@ cdef extern from "flint_wrap.h": # ``S*A + T*B = G``. The length of ``S`` will be at most # ``lenB`` and the length of ``T`` will be at most ``lenA``. - mp_limb_t _nmod_poly_resultant_euclidean(mp_srcptr poly1, slong len1, mp_srcptr poly2, slong len2, nmod_t mod) + mp_limb_t _nmod_poly_resultant_euclidean(mp_srcptr poly1, slong len1, mp_srcptr poly2, slong len2, nmod_t mod) noexcept # Returns the resultant of ``(poly1, len1)`` and # ``(poly2, len2)`` using the Euclidean algorithm. # Assumes that ``len1 >= len2 > 0``. # Assumes that the modulus is prime. - mp_limb_t nmod_poly_resultant_euclidean(const nmod_poly_t f, const nmod_poly_t g) + mp_limb_t nmod_poly_resultant_euclidean(const nmod_poly_t f, const nmod_poly_t g) noexcept # Computes the resultant of `f` and `g` using the Euclidean algorithm. # For two non-zero polynomials `f(x) = a_m x^m + \dotsb + a_0` and # `g(x) = b_n x^n + \dotsb + b_0` of degrees `m` and `n`, the resultant @@ -1325,7 +1325,7 @@ cdef extern from "flint_wrap.h": # For convenience, we define the resultant to be equal to zero if either # of the two polynomials is zero. - mp_limb_t _nmod_poly_resultant_hgcd(mp_srcptr poly1, slong len1, mp_srcptr poly2, slong len2, nmod_t mod) + mp_limb_t _nmod_poly_resultant_hgcd(mp_srcptr poly1, slong len1, mp_srcptr poly2, slong len2, nmod_t mod) noexcept # Returns the resultant of ``(poly1, len1)`` and # ``(poly2, len2)`` using the half-gcd algorithm. # This algorithm computes the half-gcd as per :func:`_nmod_poly_gcd_hgcd` @@ -1355,7 +1355,7 @@ cdef extern from "flint_wrap.h": # Assumes that ``len1 >= len2 > 0``. # Assumes that the modulus is prime. - mp_limb_t nmod_poly_resultant_hgcd(const nmod_poly_t f, const nmod_poly_t g) + mp_limb_t nmod_poly_resultant_hgcd(const nmod_poly_t f, const nmod_poly_t g) noexcept # Computes the resultant of `f` and `g` using the half-gcd algorithm. # For two non-zero polynomials `f(x) = a_m x^m + \dotsb + a_0` and # `g(x) = b_n x^n + \dotsb + b_0` of degrees `m` and `n`, the resultant @@ -1365,13 +1365,13 @@ cdef extern from "flint_wrap.h": # For convenience, we define the resultant to be equal to zero if either # of the two polynomials is zero. - mp_limb_t _nmod_poly_resultant(mp_srcptr poly1, slong len1, mp_srcptr poly2, slong len2, nmod_t mod) + mp_limb_t _nmod_poly_resultant(mp_srcptr poly1, slong len1, mp_srcptr poly2, slong len2, nmod_t mod) noexcept # Returns the resultant of ``(poly1, len1)`` and # ``(poly2, len2)``. # Assumes that ``len1 >= len2 > 0``. # Assumes that the modulus is prime. - mp_limb_t nmod_poly_resultant(const nmod_poly_t f, const nmod_poly_t g) + mp_limb_t nmod_poly_resultant(const nmod_poly_t f, const nmod_poly_t g) noexcept # Computes the resultant of `f` and `g`. # For two non-zero polynomials `f(x) = a_m x^m + \dotsb + a_0` and # `g(x) = b_n x^n + \dotsb + b_0` of degrees `m` and `n`, the resultant @@ -1381,18 +1381,18 @@ cdef extern from "flint_wrap.h": # For convenience, we define the resultant to be equal to zero if either # of the two polynomials is zero. - slong _nmod_poly_gcdinv(mp_limb_t *G, mp_limb_t *S, const mp_limb_t *A, slong lenA, const mp_limb_t *B, slong lenB, const nmod_t mod) + slong _nmod_poly_gcdinv(mp_limb_t *G, mp_limb_t *S, const mp_limb_t *A, slong lenA, const mp_limb_t *B, slong lenB, const nmod_t mod) noexcept # Computes ``(G, lenA)``, ``(S, lenB-1)`` such that # `G \cong S A \pmod{B}`, returning the actual length of `G`. # Assumes that `0 < \operatorname{len}(A) < \operatorname{len}(B)`. - void nmod_poly_gcdinv(nmod_poly_t G, nmod_poly_t S, const nmod_poly_t A, const nmod_poly_t B) + void nmod_poly_gcdinv(nmod_poly_t G, nmod_poly_t S, const nmod_poly_t A, const nmod_poly_t B) noexcept # Computes polynomials `G` and `S`, both reduced modulo `B`, # such that `G \cong S A \pmod{B}`, where `B` is assumed to # have `\operatorname{len}(B) \geq 2`. # In the case that `A = 0 \pmod{B}`, returns `G = S = 0`. - int _nmod_poly_invmod(mp_limb_t *A, const mp_limb_t *B, slong lenB, const mp_limb_t *P, slong lenP, const nmod_t mod) + int _nmod_poly_invmod(mp_limb_t *A, const mp_limb_t *B, slong lenB, const mp_limb_t *P, slong lenP, const nmod_t mod) noexcept # Attempts to set ``(A, lenP-1)`` to the inverse of ``(B, lenB)`` # modulo the polynomial ``(P, lenP)``. Returns `1` if ``(B, lenB)`` # is invertible and `0` otherwise. @@ -1401,7 +1401,7 @@ cdef extern from "flint_wrap.h": # Does not support aliasing. # Assumes that `mod` is a prime number. - int nmod_poly_invmod(nmod_poly_t A, const nmod_poly_t B, const nmod_poly_t P) + int nmod_poly_invmod(nmod_poly_t A, const nmod_poly_t B, const nmod_poly_t P) noexcept # Attempts to set `A` to the inverse of `B` modulo `P` in the polynomial # ring `(\mathbf{Z}/p\mathbf{Z})[X]`, where we assume that `p` is a prime # number. @@ -1410,10 +1410,10 @@ cdef extern from "flint_wrap.h": # sets `A` to the inverse of `B`. Otherwise, returns `0` and the value # of `A` on exit is undefined. - mp_limb_t _nmod_poly_discriminant(mp_srcptr poly, slong len, nmod_t mod) + mp_limb_t _nmod_poly_discriminant(mp_srcptr poly, slong len, nmod_t mod) noexcept # Return the discriminant of ``(poly, len)``. Assumes ``len > 1``. - mp_limb_t nmod_poly_discriminant(const nmod_poly_t f) + mp_limb_t nmod_poly_discriminant(const nmod_poly_t f) noexcept # Return the discriminant of `f`. # We normalise the discriminant so that # `\operatorname{disc}(f) = (-1)^{n(n-1)/2} \operatorname{res}(f, f') / @@ -1423,7 +1423,7 @@ cdef extern from "flint_wrap.h": # `\operatorname{lc}(f)` is the leading coefficient of `f` and `r_i` are the # roots of `f`. - void _nmod_poly_compose_series(mp_ptr res, mp_srcptr poly1, slong len1, mp_srcptr poly2, slong len2, slong n, nmod_t mod) + void _nmod_poly_compose_series(mp_ptr res, mp_srcptr poly1, slong len1, mp_srcptr poly2, slong len2, slong n, nmod_t mod) noexcept # Sets ``res`` to the composition of ``poly1`` and ``poly2`` # modulo `x^n`, where the constant term of ``poly2`` is required # to be zero. @@ -1434,12 +1434,12 @@ cdef extern from "flint_wrap.h": # Wraps :func:`_gr_poly_compose_series` which chooses automatically # between various algorithms. - void nmod_poly_compose_series(nmod_poly_t res, const nmod_poly_t poly1, const nmod_poly_t poly2, slong n) + void nmod_poly_compose_series(nmod_poly_t res, const nmod_poly_t poly1, const nmod_poly_t poly2, slong n) noexcept # Sets ``res`` to the composition of ``poly1`` and ``poly2`` # modulo `x^n`, where the constant term of ``poly2`` is required # to be zero. - void _nmod_poly_revert_series_lagrange(mp_ptr Qinv, mp_srcptr Q, slong n, nmod_t mod) + void _nmod_poly_revert_series_lagrange(mp_ptr Qinv, mp_srcptr Q, slong n, nmod_t mod) noexcept # Sets ``Qinv`` to the compositional inverse or reversion of ``Q`` # as a power series, i.e. computes `Q^{-1}` such that # `Q(Q^{-1}(x)) = Q^{-1}(Q(x)) = x \bmod x^n`. The arguments must @@ -1448,7 +1448,7 @@ cdef extern from "flint_wrap.h": # `1, 2, \ldots, n-1` are invertible modulo the modulus. # This implementation uses the Lagrange inversion formula. - void nmod_poly_revert_series_lagrange(nmod_poly_t Qinv, const nmod_poly_t Q, slong n) + void nmod_poly_revert_series_lagrange(nmod_poly_t Qinv, const nmod_poly_t Q, slong n) noexcept # Sets ``Qinv`` to the compositional inverse or reversion of ``Q`` # as a power series, i.e. computes `Q^{-1}` such that # `Q(Q^{-1}(x)) = Q^{-1}(Q(x)) = x \bmod x^n`. @@ -1456,7 +1456,7 @@ cdef extern from "flint_wrap.h": # `1, 2, \ldots, n-1` are invertible modulo the modulus. # This implementation uses the Lagrange inversion formula. - void _nmod_poly_revert_series_lagrange_fast(mp_ptr Qinv, mp_srcptr Q, slong n, nmod_t mod) + void _nmod_poly_revert_series_lagrange_fast(mp_ptr Qinv, mp_srcptr Q, slong n, nmod_t mod) noexcept # Sets ``Qinv`` to the compositional inverse or reversion of ``Q`` # as a power series, i.e. computes `Q^{-1}` such that # `Q(Q^{-1}(x)) = Q^{-1}(Q(x)) = x \bmod x^n`. The arguments must @@ -1466,7 +1466,7 @@ cdef extern from "flint_wrap.h": # This implementation uses a reduced-complexity implementation # of the Lagrange inversion formula. - void nmod_poly_revert_series_lagrange_fast(nmod_poly_t Qinv, const nmod_poly_t Q, slong n) + void nmod_poly_revert_series_lagrange_fast(nmod_poly_t Qinv, const nmod_poly_t Q, slong n) noexcept # Sets ``Qinv`` to the compositional inverse or reversion of ``Q`` # as a power series, i.e. computes `Q^{-1}` such that # `Q(Q^{-1}(x)) = Q^{-1}(Q(x)) = x \bmod x^n`. @@ -1475,7 +1475,7 @@ cdef extern from "flint_wrap.h": # This implementation uses a reduced-complexity implementation # of the Lagrange inversion formula. - void _nmod_poly_revert_series_newton(mp_ptr Qinv, mp_srcptr Q, slong n, nmod_t mod) + void _nmod_poly_revert_series_newton(mp_ptr Qinv, mp_srcptr Q, slong n, nmod_t mod) noexcept # Sets ``Qinv`` to the compositional inverse or reversion of ``Q`` # as a power series, i.e. computes `Q^{-1}` such that # `Q(Q^{-1}(x)) = Q^{-1}(Q(x)) = x \bmod x^n`. The arguments must @@ -1484,7 +1484,7 @@ cdef extern from "flint_wrap.h": # `1, 2, \ldots, n-1` are invertible modulo the modulus. # This implementation uses Newton iteration [BrentKung1978]_. - void nmod_poly_revert_series_newton(nmod_poly_t Qinv, const nmod_poly_t Q, slong n) + void nmod_poly_revert_series_newton(nmod_poly_t Qinv, const nmod_poly_t Q, slong n) noexcept # Sets ``Qinv`` to the compositional inverse or reversion of ``Q`` # as a power series, i.e. computes `Q^{-1}` such that # `Q(Q^{-1}(x)) = Q^{-1}(Q(x)) = x \bmod x^n`. @@ -1492,7 +1492,7 @@ cdef extern from "flint_wrap.h": # `1, 2, \ldots, n-1` are invertible modulo the modulus. # This implementation uses Newton iteration [BrentKung1978]_. - void _nmod_poly_revert_series(mp_ptr Qinv, mp_srcptr Q, slong n, nmod_t mod) + void _nmod_poly_revert_series(mp_ptr Qinv, mp_srcptr Q, slong n, nmod_t mod) noexcept # Sets ``Qinv`` to the compositional inverse or reversion of ``Q`` # as a power series, i.e. computes `Q^{-1}` such that # `Q(Q^{-1}(x)) = Q^{-1}(Q(x)) = x \bmod x^n`. The arguments must @@ -1503,7 +1503,7 @@ cdef extern from "flint_wrap.h": # inversion formula and Newton iteration based on the size of the # input. - void nmod_poly_revert_series(nmod_poly_t Qinv, const nmod_poly_t Q, slong n) + void nmod_poly_revert_series(nmod_poly_t Qinv, const nmod_poly_t Q, slong n) noexcept # Sets ``Qinv`` to the compositional inverse or reversion of ``Q`` # as a power series, i.e. computes `Q^{-1}` such that # `Q(Q^{-1}(x)) = Q^{-1}(Q(x)) = x \bmod x^n`. @@ -1513,95 +1513,95 @@ cdef extern from "flint_wrap.h": # inversion formula and Newton iteration based on the size of the # input. - void _nmod_poly_invsqrt_series(mp_ptr g, mp_srcptr h, slong hlen, slong n, nmod_t mod) + void _nmod_poly_invsqrt_series(mp_ptr g, mp_srcptr h, slong hlen, slong n, nmod_t mod) noexcept # Set the first `n` terms of `g` to the series expansion of `1/\sqrt{h}`. # It is assumed that `n > 0`, that `h` has constant term 1. Aliasing is not permitted. - void nmod_poly_invsqrt_series(nmod_poly_t g, const nmod_poly_t h, slong n) + void nmod_poly_invsqrt_series(nmod_poly_t g, const nmod_poly_t h, slong n) noexcept # Set `g` to the series expansion of `1/\sqrt{h}` to order `O(x^n)`. # It is assumed that `h` has constant term 1. - void _nmod_poly_sqrt_series(mp_ptr g, mp_srcptr h, slong hlen, slong n, nmod_t mod) + void _nmod_poly_sqrt_series(mp_ptr g, mp_srcptr h, slong hlen, slong n, nmod_t mod) noexcept # Set the first `n` terms of `g` to the series expansion of `\sqrt{h}`. # It is assumed that `n > 0`, that `h` has constant term 1. Aliasing is not permitted. - void nmod_poly_sqrt_series(nmod_poly_t g, const nmod_poly_t h, slong n) + void nmod_poly_sqrt_series(nmod_poly_t g, const nmod_poly_t h, slong n) noexcept # Set `g` to the series expansion of `\sqrt{h}` to order `O(x^n)`. # It is assumed that `h` has constant term 1. - int _nmod_poly_sqrt(mp_ptr s, mp_srcptr p, slong n, nmod_t mod) + int _nmod_poly_sqrt(mp_ptr s, mp_srcptr p, slong n, nmod_t mod) noexcept # If ``(p, n)`` is a perfect square, sets ``(s, n / 2 + 1)`` # to a square root of `p` and returns 1. Otherwise returns 0. - int nmod_poly_sqrt(nmod_poly_t s, const nmod_poly_t p) + int nmod_poly_sqrt(nmod_poly_t s, const nmod_poly_t p) noexcept # If `p` is a perfect square, sets `s` to a square root of `p` # and returns 1. Otherwise returns 0. - void _nmod_poly_power_sums_naive(mp_ptr res, mp_srcptr poly, slong len, slong n, nmod_t mod) + void _nmod_poly_power_sums_naive(mp_ptr res, mp_srcptr poly, slong len, slong n, nmod_t mod) noexcept # Compute the (truncated) power sums series of the polynomial # ``(poly,len)`` up to length `n` using Newton identities. - void nmod_poly_power_sums_naive(nmod_poly_t res, const nmod_poly_t poly, slong n) + void nmod_poly_power_sums_naive(nmod_poly_t res, const nmod_poly_t poly, slong n) noexcept # Compute the (truncated) power sum series of the polynomial # ``poly`` up to length `n` using Newton identities. - void _nmod_poly_power_sums_schoenhage(mp_ptr res, mp_srcptr poly, slong len, slong n, nmod_t mod) + void _nmod_poly_power_sums_schoenhage(mp_ptr res, mp_srcptr poly, slong len, slong n, nmod_t mod) noexcept # Compute the (truncated) power sums series of the polynomial # ``(poly,len)`` up to length `n` using a series expansion # (a formula due to Schoenhage). - void nmod_poly_power_sums_schoenhage(nmod_poly_t res, const nmod_poly_t poly, slong n) + void nmod_poly_power_sums_schoenhage(nmod_poly_t res, const nmod_poly_t poly, slong n) noexcept # Compute the (truncated) power sums series of the polynomial # ``poly`` up to length `n` using a series expansion # (a formula due to Schoenhage). - void _nmod_poly_power_sums(mp_ptr res, mp_srcptr poly, slong len, slong n, nmod_t mod) + void _nmod_poly_power_sums(mp_ptr res, mp_srcptr poly, slong len, slong n, nmod_t mod) noexcept # Compute the (truncated) power sums series of the polynomial # ``(poly,len)`` up to length `n`. - void nmod_poly_power_sums(nmod_poly_t res, const nmod_poly_t poly, slong n) + void nmod_poly_power_sums(nmod_poly_t res, const nmod_poly_t poly, slong n) noexcept # Compute the (truncated) power sums series of the polynomial # ``poly`` up to length `n`. - void _nmod_poly_power_sums_to_poly_naive(mp_ptr res, mp_srcptr poly, slong len, nmod_t mod) + void _nmod_poly_power_sums_to_poly_naive(mp_ptr res, mp_srcptr poly, slong len, nmod_t mod) noexcept # Compute the (monic) polynomial given by its power sums series # ``(poly,len)`` using Newton identities. - void nmod_poly_power_sums_to_poly_naive(nmod_poly_t res, const nmod_poly_t Q) + void nmod_poly_power_sums_to_poly_naive(nmod_poly_t res, const nmod_poly_t Q) noexcept # Compute the (monic) polynomial given by its power sums series # ``Q`` using Newton identities. - void _nmod_poly_power_sums_to_poly_schoenhage(mp_ptr res, mp_srcptr poly, slong len, nmod_t mod) + void _nmod_poly_power_sums_to_poly_schoenhage(mp_ptr res, mp_srcptr poly, slong len, nmod_t mod) noexcept # Compute the (monic) polynomial given by its power sums series # ``(poly,len)`` using series expansion (a formula due to Schoenhage). - void nmod_poly_power_sums_to_poly_schoenhage(nmod_poly_t res, const nmod_poly_t Q) + void nmod_poly_power_sums_to_poly_schoenhage(nmod_poly_t res, const nmod_poly_t Q) noexcept # Compute the (monic) polynomial given by its power sums series # ``Q`` using series expansion (a formula due to Schoenhage). - void _nmod_poly_power_sums_to_poly(mp_ptr res, mp_srcptr poly, slong len, nmod_t mod) + void _nmod_poly_power_sums_to_poly(mp_ptr res, mp_srcptr poly, slong len, nmod_t mod) noexcept # Compute the (monic) polynomial given by its power sums series # ``(poly,len)``. - void nmod_poly_power_sums_to_poly(nmod_poly_t res, const nmod_poly_t Q) + void nmod_poly_power_sums_to_poly(nmod_poly_t res, const nmod_poly_t Q) noexcept # Compute the (monic) polynomial given by its power sums series ``Q``. - void _nmod_poly_log_series(mp_ptr g, mp_srcptr h, slong hlen, slong n, nmod_t mod) + void _nmod_poly_log_series(mp_ptr g, mp_srcptr h, slong hlen, slong n, nmod_t mod) noexcept # Set `g = \log(h) + O(x^n)`. Assumes `n > 0` and ``hlen > 0``. # Aliasing of `g` and `h` is allowed. - void nmod_poly_log_series(nmod_poly_t g, const nmod_poly_t h, slong n) + void nmod_poly_log_series(nmod_poly_t g, const nmod_poly_t h, slong n) noexcept # Set `g = \log(h) + O(x^n)`. The case `h = 1+cx^r` is automatically # detected and handled efficiently. - void _nmod_poly_exp_series(mp_ptr f, mp_srcptr h, slong hlen, slong n, nmod_t mod) + void _nmod_poly_exp_series(mp_ptr f, mp_srcptr h, slong hlen, slong n, nmod_t mod) noexcept # Set `f = \exp(h) + O(x^n)` where ``h`` is a polynomial. Assume # `n > 0`. Aliasing of `g` and `h` is not allowed. # Uses Newton iteration (an improved version of the # algorithm in [HanZim2004]_). # For small `n`, falls back to the basecase algorithm. - void _nmod_poly_exp_expinv_series(mp_ptr f, mp_ptr g, mp_srcptr h, slong hlen, slong n, nmod_t mod) + void _nmod_poly_exp_expinv_series(mp_ptr f, mp_ptr g, mp_srcptr h, slong hlen, slong n, nmod_t mod) noexcept # Set `f = \exp(h) + O(x^n)` and `g = \exp(-h) + O(x^n)`, more efficiently # for large `n` than performing a separate inversion to obtain `g`. # Assumes `n > 0` and that `h` is zero-padded @@ -1609,107 +1609,107 @@ cdef extern from "flint_wrap.h": # Uses Newton iteration (the version given in [HanZim2004]_). # For small `n`, falls back to the basecase algorithm. - void nmod_poly_exp_series(nmod_poly_t g, const nmod_poly_t h, slong n) + void nmod_poly_exp_series(nmod_poly_t g, const nmod_poly_t h, slong n) noexcept # Set `g = \exp(h) + O(x^n)`. The case `h = cx^r` is automatically # detected and handled efficiently. Otherwise this function automatically # uses the basecase algorithm for small `n` and Newton iteration otherwise. - void _nmod_poly_atan_series(mp_ptr g, mp_srcptr h, slong hlen, slong n, nmod_t mod) + void _nmod_poly_atan_series(mp_ptr g, mp_srcptr h, slong hlen, slong n, nmod_t mod) noexcept # Set `g = \operatorname{atan}(h) + O(x^n)`. Assumes `n > 0`. # Aliasing of `g` and `h` is allowed. - void nmod_poly_atan_series(nmod_poly_t g, const nmod_poly_t h, slong n) + void nmod_poly_atan_series(nmod_poly_t g, const nmod_poly_t h, slong n) noexcept # Set `g = \operatorname{atan}(h) + O(x^n)`. - void _nmod_poly_atanh_series(mp_ptr g, mp_srcptr h, slong hlen, slong n, nmod_t mod) + void _nmod_poly_atanh_series(mp_ptr g, mp_srcptr h, slong hlen, slong n, nmod_t mod) noexcept # Set `g = \operatorname{atanh}(h) + O(x^n)`. Assumes `n > 0`. # Aliasing of `g` and `h` is allowed. - void nmod_poly_atanh_series(nmod_poly_t g, const nmod_poly_t h, slong n) + void nmod_poly_atanh_series(nmod_poly_t g, const nmod_poly_t h, slong n) noexcept # Set `g = \operatorname{atanh}(h) + O(x^n)`. - void _nmod_poly_asin_series(mp_ptr g, mp_srcptr h, slong hlen, slong n, nmod_t mod) + void _nmod_poly_asin_series(mp_ptr g, mp_srcptr h, slong hlen, slong n, nmod_t mod) noexcept # Set `g = \operatorname{asin}(h) + O(x^n)`. Assumes `n > 0`. # Aliasing of `g` and `h` is allowed. - void nmod_poly_asin_series(nmod_poly_t g, const nmod_poly_t h, slong n) + void nmod_poly_asin_series(nmod_poly_t g, const nmod_poly_t h, slong n) noexcept # Set `g = \operatorname{asin}(h) + O(x^n)`. - void _nmod_poly_asinh_series(mp_ptr g, mp_srcptr h, slong hlen, slong n, nmod_t mod) + void _nmod_poly_asinh_series(mp_ptr g, mp_srcptr h, slong hlen, slong n, nmod_t mod) noexcept # Set `g = \operatorname{asinh}(h) + O(x^n)`. Assumes `n > 0`. # Aliasing of `g` and `h` is allowed. - void nmod_poly_asinh_series(nmod_poly_t g, const nmod_poly_t h, slong n) + void nmod_poly_asinh_series(nmod_poly_t g, const nmod_poly_t h, slong n) noexcept # Set `g = \operatorname{asinh}(h) + O(x^n)`. - void _nmod_poly_sin_series(mp_ptr g, mp_srcptr h, slong n, nmod_t mod) + void _nmod_poly_sin_series(mp_ptr g, mp_srcptr h, slong n, nmod_t mod) noexcept # Set `g = \operatorname{sin}(h) + O(x^n)`. Assumes `n > 0` and that `h` # is zero-padded as necessary to length `n`. Aliasing of `g` and `h` is # allowed. The value is computed using the identity # `\sin(x) = 2 \tan(x/2)) / (1 + \tan^2(x/2)).` - void nmod_poly_sin_series(nmod_poly_t g, const nmod_poly_t h, slong n) + void nmod_poly_sin_series(nmod_poly_t g, const nmod_poly_t h, slong n) noexcept # Set `g = \operatorname{sin}(h) + O(x^n)`. - void _nmod_poly_cos_series(mp_ptr g, mp_srcptr h, slong n, nmod_t mod) + void _nmod_poly_cos_series(mp_ptr g, mp_srcptr h, slong n, nmod_t mod) noexcept # Set `g = \operatorname{cos}(h) + O(x^n)`. Assumes `n > 0` and that `h` # is zero-padded as necessary to length `n`. Aliasing of `g` and `h` is # allowed. The value is computed using the identity # `\cos(x) = (1-\tan^2(x/2)) / (1 + \tan^2(x/2)).` - void nmod_poly_cos_series(nmod_poly_t g, const nmod_poly_t h, slong n) + void nmod_poly_cos_series(nmod_poly_t g, const nmod_poly_t h, slong n) noexcept # Set `g = \operatorname{cos}(h) + O(x^n)`. - void _nmod_poly_tan_series(mp_ptr g, mp_srcptr h, slong hlen, slong n, nmod_t mod) + void _nmod_poly_tan_series(mp_ptr g, mp_srcptr h, slong hlen, slong n, nmod_t mod) noexcept # Set `g = \operatorname{tan}(h) + O(x^n)`. Assumes `n > 0` and that `h` # is zero-padded as necessary to length `n`. Aliasing of `g` and `h` is # not allowed. Uses Newton iteration to invert the atan function. - void nmod_poly_tan_series(nmod_poly_t g, const nmod_poly_t h, slong n) + void nmod_poly_tan_series(nmod_poly_t g, const nmod_poly_t h, slong n) noexcept # Set `g = \operatorname{tan}(h) + O(x^n)`. - void _nmod_poly_sinh_series(mp_ptr g, mp_srcptr h, slong n, nmod_t mod) + void _nmod_poly_sinh_series(mp_ptr g, mp_srcptr h, slong n, nmod_t mod) noexcept # Set `g = \operatorname{sinh}(h) + O(x^n)`. Assumes `n > 0` and that `h` # is zero-padded as necessary to length `n`. Aliasing of `g` and `h` is # not allowed. Uses the identity `\sinh(x) = (e^x - e^{-x})/2`. - void nmod_poly_sinh_series(nmod_poly_t g, const nmod_poly_t h, slong n) + void nmod_poly_sinh_series(nmod_poly_t g, const nmod_poly_t h, slong n) noexcept # Set `g = \operatorname{sinh}(h) + O(x^n)`. - void _nmod_poly_cosh_series(mp_ptr g, mp_srcptr h, slong n, nmod_t mod) + void _nmod_poly_cosh_series(mp_ptr g, mp_srcptr h, slong n, nmod_t mod) noexcept # Set `g = \operatorname{cos}(h) + O(x^n)`. Assumes `n > 0` and that `h` # is zero-padded as necessary to length `n`. Aliasing of `g` and `h` is # not allowed. # Uses the identity `\cosh(x) = (e^x + e^{-x})/2`. - void nmod_poly_cosh_series(nmod_poly_t g, const nmod_poly_t h, slong n) + void nmod_poly_cosh_series(nmod_poly_t g, const nmod_poly_t h, slong n) noexcept # Set `g = \operatorname{cosh}(h) + O(x^n)`. - void _nmod_poly_tanh_series(mp_ptr g, mp_srcptr h, slong n, nmod_t mod) + void _nmod_poly_tanh_series(mp_ptr g, mp_srcptr h, slong n, nmod_t mod) noexcept # Set `g = \operatorname{tanh}(h) + O(x^n)`. Assumes `n > 0` and that `h` # is zero-padded as necessary to length `n`. Uses the identity # `\tanh(x) = (e^{2x}-1)/(e^{2x}+1)`. - void nmod_poly_tanh_series(nmod_poly_t g, const nmod_poly_t h, slong n) + void nmod_poly_tanh_series(nmod_poly_t g, const nmod_poly_t h, slong n) noexcept # Set `g = \operatorname{tanh}(h) + O(x^n)`. - void _nmod_poly_product_roots_nmod_vec(mp_ptr poly, mp_srcptr xs, slong n, nmod_t mod) + void _nmod_poly_product_roots_nmod_vec(mp_ptr poly, mp_srcptr xs, slong n, nmod_t mod) noexcept # Sets ``(poly, n + 1)`` to the monic polynomial which is the product # of `(x - x_0)(x - x_1) \cdots (x - x_{n-1})`, the roots `x_i` being # given by ``xs``. # Aliasing of the input and output is not allowed. - void nmod_poly_product_roots_nmod_vec(nmod_poly_t poly, mp_srcptr xs, slong n) + void nmod_poly_product_roots_nmod_vec(nmod_poly_t poly, mp_srcptr xs, slong n) noexcept # Sets ``poly`` to the monic polynomial which is the product # of `(x - x_0)(x - x_1) \cdots (x - x_{n-1})`, the roots `x_i` being # given by ``xs``. - int nmod_poly_find_distinct_nonzero_roots(mp_limb_t * roots, const nmod_poly_t A) + int nmod_poly_find_distinct_nonzero_roots(mp_limb_t * roots, const nmod_poly_t A) noexcept # If ``A`` has `\deg(A)` distinct nonzero roots in `\mathbb{F}_p`, write these roots out to ``roots[0]`` to ``roots[deg(A) - 1]`` and return ``1``. # Otherwise, return ``0``. It is assumed that ``A`` is nonzero and that the modulus of ``A`` is prime. # This function uses Rabin's probabilistic method via gcd's with `(x + \delta)^{\frac{p-1}{2}} - 1`. - mp_ptr * _nmod_poly_tree_alloc(slong len) + mp_ptr * _nmod_poly_tree_alloc(slong len) noexcept # Allocates space for a subproduct tree of the given length, having # linear factors at the lowest level. # Entry `i` in the tree is a pointer to a single array of limbs, @@ -1724,88 +1724,88 @@ cdef extern from "flint_wrap.h": # XXXX1 XX1 X1 # XXXXXXX1 - void _nmod_poly_tree_free(mp_ptr * tree, slong len) + void _nmod_poly_tree_free(mp_ptr * tree, slong len) noexcept # Free the allocated space for the subproduct. - void _nmod_poly_tree_build(mp_ptr * tree, mp_srcptr roots, slong len, nmod_t mod) + void _nmod_poly_tree_build(mp_ptr * tree, mp_srcptr roots, slong len, nmod_t mod) noexcept # Builds a subproduct tree in the preallocated space from # the ``len`` monic linear factors `(x-r_i)`. The top level # product is not computed. - void nmod_poly_inflate(nmod_poly_t result, const nmod_poly_t input, ulong inflation) + void nmod_poly_inflate(nmod_poly_t result, const nmod_poly_t input, ulong inflation) noexcept # Sets ``result`` to the inflated polynomial `p(x^n)` where # `p` is given by ``input`` and `n` is given by ``deflation``. - void nmod_poly_deflate(nmod_poly_t result, const nmod_poly_t input, ulong deflation) + void nmod_poly_deflate(nmod_poly_t result, const nmod_poly_t input, ulong deflation) noexcept # Sets ``result`` to the deflated polynomial `p(x^{1/n})` where # `p` is given by ``input`` and `n` is given by ``deflation``. # Requires `n > 0`. - ulong nmod_poly_deflation(const nmod_poly_t input) + ulong nmod_poly_deflation(const nmod_poly_t input) noexcept # Returns the largest integer by which ``input`` can be deflated. # As special cases, returns 0 if ``input`` is the zero polynomial # and 1 of ``input`` is a constant polynomial. - void nmod_poly_multi_crt_init(nmod_poly_multi_crt_t CRT) + void nmod_poly_multi_crt_init(nmod_poly_multi_crt_t CRT) noexcept # Initialize ``CRT`` for Chinese remaindering. - int nmod_poly_multi_crt_precompute(nmod_poly_multi_crt_t CRT, const nmod_poly_struct * moduli, slong len) - int nmod_poly_multi_crt_precompute_p(nmod_poly_multi_crt_t CRT, const nmod_poly_struct * const * moduli, slong len) + int nmod_poly_multi_crt_precompute(nmod_poly_multi_crt_t CRT, const nmod_poly_struct * moduli, slong len) noexcept + int nmod_poly_multi_crt_precompute_p(nmod_poly_multi_crt_t CRT, const nmod_poly_struct * const * moduli, slong len) noexcept # Configure ``CRT`` for repeated Chinese remaindering of ``moduli``. The number of moduli, ``len``, should be positive. # A return of ``0`` indicates that the compilation failed and future calls to :func:`nmod_poly_multi_crt_precomp` will leave the output undefined. # A return of ``1`` indicates that the compilation was successful, which occurs if and only if either (1) ``len == 1`` and ``modulus + 0`` is nonzero, or (2) all of the moduli have positive degree and are pairwise relatively prime. - void nmod_poly_multi_crt_precomp(nmod_poly_t output, const nmod_poly_multi_crt_t CRT, const nmod_poly_struct * values) - void nmod_poly_multi_crt_precomp_p(nmod_poly_t output, const nmod_poly_multi_crt_t CRT, const nmod_poly_struct * const * values) + void nmod_poly_multi_crt_precomp(nmod_poly_t output, const nmod_poly_multi_crt_t CRT, const nmod_poly_struct * values) noexcept + void nmod_poly_multi_crt_precomp_p(nmod_poly_t output, const nmod_poly_multi_crt_t CRT, const nmod_poly_struct * const * values) noexcept # Set ``output`` to the polynomial of lowest possible degree that is congruent to ``values + i`` modulo the ``moduli + i`` in :func:`nmod_poly_multi_crt_precompute`. # The inputs ``values + 0, ..., values + len - 1`` where ``len`` was used in :func:`nmod_poly_multi_crt_precompute` are expected to be valid and have modulus matching the modulus of the moduli used in :func:`nmod_poly_multi_crt_precompute`. - int nmod_poly_multi_crt(nmod_poly_t output, const nmod_poly_struct * moduli, const nmod_poly_struct * values, slong len) + int nmod_poly_multi_crt(nmod_poly_t output, const nmod_poly_struct * moduli, const nmod_poly_struct * values, slong len) noexcept # Perform the same operation as :func:`nmod_poly_multi_crt_precomp` while internally constructing and destroying the precomputed data. # All of the remarks in :func:`nmod_poly_multi_crt_precompute` apply. - void nmod_poly_multi_crt_clear(nmod_poly_multi_crt_t CRT) + void nmod_poly_multi_crt_clear(nmod_poly_multi_crt_t CRT) noexcept # Free all space used by ``CRT``. - slong _nmod_poly_multi_crt_local_size(const nmod_poly_multi_crt_t CRT) + slong _nmod_poly_multi_crt_local_size(const nmod_poly_multi_crt_t CRT) noexcept # Return the required length of the output for :func:`_nmod_poly_multi_crt_run`. - void _nmod_poly_multi_crt_run(nmod_poly_struct * outputs, const nmod_poly_multi_crt_t CRT, const nmod_poly_struct * inputs) - void _nmod_poly_multi_crt_run_p(nmod_poly_struct * outputs, const nmod_poly_multi_crt_t CRT, const nmod_poly_struct * const * inputs) + void _nmod_poly_multi_crt_run(nmod_poly_struct * outputs, const nmod_poly_multi_crt_t CRT, const nmod_poly_struct * inputs) noexcept + void _nmod_poly_multi_crt_run_p(nmod_poly_struct * outputs, const nmod_poly_multi_crt_t CRT, const nmod_poly_struct * const * inputs) noexcept # Perform the same operation as :func:`nmod_poly_multi_crt_precomp` using supplied temporary space. # The actual output is placed in ``outputs + 0``, and ``outputs`` should contain space for all temporaries and should be at least as long as ``_nmod_poly_multi_crt_local_size(CRT)``. # Of course the moduli of these temporaries should match the modulus of the inputs. - void nmod_berlekamp_massey_init(nmod_berlekamp_massey_t B, mp_limb_t p) + void nmod_berlekamp_massey_init(nmod_berlekamp_massey_t B, mp_limb_t p) noexcept # Initialize ``B`` in characteristic ``p`` with an empty stream. - void nmod_berlekamp_massey_clear(nmod_berlekamp_massey_t B) + void nmod_berlekamp_massey_clear(nmod_berlekamp_massey_t B) noexcept # Free any space used by ``B``. - void nmod_berlekamp_massey_start_over(nmod_berlekamp_massey_t B) + void nmod_berlekamp_massey_start_over(nmod_berlekamp_massey_t B) noexcept # Empty the stream of points in ``B``. - void nmod_berlekamp_massey_set_prime(nmod_berlekamp_massey_t B, mp_limb_t p) + void nmod_berlekamp_massey_set_prime(nmod_berlekamp_massey_t B, mp_limb_t p) noexcept # Set the characteristic of the field and empty the stream of points in ``B``. - void nmod_berlekamp_massey_add_points(nmod_berlekamp_massey_t B, const mp_limb_t * a, slong count) - void nmod_berlekamp_massey_add_zeros(nmod_berlekamp_massey_t B, slong count) - void nmod_berlekamp_massey_add_point(nmod_berlekamp_massey_t B, mp_limb_t a) + void nmod_berlekamp_massey_add_points(nmod_berlekamp_massey_t B, const mp_limb_t * a, slong count) noexcept + void nmod_berlekamp_massey_add_zeros(nmod_berlekamp_massey_t B, slong count) noexcept + void nmod_berlekamp_massey_add_point(nmod_berlekamp_massey_t B, mp_limb_t a) noexcept # Add point(s) to the stream processed by ``B``. The addition of any number of points will not update the `V` and `R` polynomial. - int nmod_berlekamp_massey_reduce(nmod_berlekamp_massey_t B) + int nmod_berlekamp_massey_reduce(nmod_berlekamp_massey_t B) noexcept # Ensure that the polynomials `V` and `R` are up to date. The return value is ``1`` if this function changed `V` and ``0`` otherwise. # For example, if this function is called twice in a row without adding any points in between, the return of the second call should be ``0``. # As another example, suppose the object is emptied, the points `1, 1, 2, 3` are added, then reduce is called. This reduce should return ``1`` with `\deg(R) < \deg(V) = 2` because the Fibonacci sequence has been recognized. The further addition of the two points `5, 8` and a reduce will result in a return value of ``0``. - slong nmod_berlekamp_massey_point_count(const nmod_berlekamp_massey_t B) + slong nmod_berlekamp_massey_point_count(const nmod_berlekamp_massey_t B) noexcept # Return the number of points stored in ``B``. - const mp_limb_t * nmod_berlekamp_massey_points(const nmod_berlekamp_massey_t B) + const mp_limb_t * nmod_berlekamp_massey_points(const nmod_berlekamp_massey_t B) noexcept # Return a pointer to the array of points stored in ``B``. This may be ``NULL`` if :func:`nmod_berlekamp_massey_point_count` returns ``0``. - const nmod_poly_struct * nmod_berlekamp_massey_V_poly(const nmod_berlekamp_massey_t B) + const nmod_poly_struct * nmod_berlekamp_massey_V_poly(const nmod_berlekamp_massey_t B) noexcept # Return the polynomial `V` in ``B``. - const nmod_poly_struct * nmod_berlekamp_massey_R_poly(const nmod_berlekamp_massey_t B) + const nmod_poly_struct * nmod_berlekamp_massey_R_poly(const nmod_berlekamp_massey_t B) noexcept # Return the polynomial `R` in ``B``. diff --git a/src/sage/libs/flint/nmod_poly_factor.pxd b/src/sage/libs/flint/nmod_poly_factor.pxd index b4f3d03573e..a0964a4a80e 100644 --- a/src/sage/libs/flint/nmod_poly_factor.pxd +++ b/src/sage/libs/flint/nmod_poly_factor.pxd @@ -12,85 +12,85 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void nmod_poly_factor_init(nmod_poly_factor_t fac) + void nmod_poly_factor_init(nmod_poly_factor_t fac) noexcept # Initialises ``fac`` for use. An ``nmod_poly_factor_t`` # represents a polynomial in factorised form as a product of # polynomials with associated exponents. - void nmod_poly_factor_clear(nmod_poly_factor_t fac) + void nmod_poly_factor_clear(nmod_poly_factor_t fac) noexcept # Frees all memory associated with ``fac``. - void nmod_poly_factor_realloc(nmod_poly_factor_t fac, slong alloc) + void nmod_poly_factor_realloc(nmod_poly_factor_t fac, slong alloc) noexcept # Reallocates the factor structure to provide space for # precisely ``alloc`` factors. - void nmod_poly_factor_fit_length(nmod_poly_factor_t fac, slong len) + void nmod_poly_factor_fit_length(nmod_poly_factor_t fac, slong len) noexcept # Ensures that the factor structure has space for at # least ``len`` factors. This function takes care # of the case of repeated calls by always at least # doubling the number of factors the structure can hold. - void nmod_poly_factor_set(nmod_poly_factor_t res, const nmod_poly_factor_t fac) + void nmod_poly_factor_set(nmod_poly_factor_t res, const nmod_poly_factor_t fac) noexcept # Sets ``res`` to the same factorisation as ``fac``. - void nmod_poly_factor_print(const nmod_poly_factor_t fac) + void nmod_poly_factor_print(const nmod_poly_factor_t fac) noexcept # Prints the entries of ``fac`` to standard output. - void nmod_poly_factor_insert(nmod_poly_factor_t fac, const nmod_poly_t poly, slong exp) + void nmod_poly_factor_insert(nmod_poly_factor_t fac, const nmod_poly_t poly, slong exp) noexcept # Inserts the factor ``poly`` with multiplicity ``exp`` into # the factorisation ``fac``. # If ``fac`` already contains ``poly``, then ``exp`` simply # gets added to the exponent of the existing entry. - void nmod_poly_factor_concat(nmod_poly_factor_t res, const nmod_poly_factor_t fac) + void nmod_poly_factor_concat(nmod_poly_factor_t res, const nmod_poly_factor_t fac) noexcept # Concatenates two factorisations. # This is equivalent to calling :func:`nmod_poly_factor_insert` # repeatedly with the individual factors of ``fac``. # Does not support aliasing between ``res`` and ``fac``. - void nmod_poly_factor_pow(nmod_poly_factor_t fac, slong exp) + void nmod_poly_factor_pow(nmod_poly_factor_t fac, slong exp) noexcept # Raises ``fac`` to the power ``exp``. - ulong nmod_poly_remove(nmod_poly_t f, const nmod_poly_t p) + ulong nmod_poly_remove(nmod_poly_t f, const nmod_poly_t p) noexcept # Removes the highest possible power of ``p`` from ``f`` and # returns the exponent. - bint nmod_poly_is_irreducible(const nmod_poly_t f) + bint nmod_poly_is_irreducible(const nmod_poly_t f) noexcept # Returns 1 if the polynomial ``f`` is irreducible, otherwise returns 0. - bint nmod_poly_is_irreducible_ddf(const nmod_poly_t f) + bint nmod_poly_is_irreducible_ddf(const nmod_poly_t f) noexcept # Returns 1 if the polynomial ``f`` is irreducible, otherwise returns 0. # Uses fast distinct-degree factorisation. - bint nmod_poly_is_irreducible_rabin(const nmod_poly_t f) + bint nmod_poly_is_irreducible_rabin(const nmod_poly_t f) noexcept # Returns 1 if the polynomial ``f`` is irreducible, otherwise returns 0. # Uses Rabin irreducibility test. - bint _nmod_poly_is_squarefree(mp_srcptr f, slong len, nmod_t mod) + bint _nmod_poly_is_squarefree(mp_srcptr f, slong len, nmod_t mod) noexcept # Returns 1 if ``(f, len)`` is squarefree, and 0 otherwise. As a # special case, the zero polynomial is not considered squarefree. # There are no restrictions on the length. - bint nmod_poly_is_squarefree(const nmod_poly_t f) + bint nmod_poly_is_squarefree(const nmod_poly_t f) noexcept # Returns 1 if ``f`` is squarefree, and 0 otherwise. As a special # case, the zero polynomial is not considered squarefree. - void nmod_poly_factor_squarefree(nmod_poly_factor_t res, const nmod_poly_t f) + void nmod_poly_factor_squarefree(nmod_poly_factor_t res, const nmod_poly_t f) noexcept # Sets ``res`` to a square-free factorization of ``f``. - bint nmod_poly_factor_equal_deg_prob(nmod_poly_t factor, flint_rand_t state, const nmod_poly_t pol, slong d) + bint nmod_poly_factor_equal_deg_prob(nmod_poly_t factor, flint_rand_t state, const nmod_poly_t pol, slong d) noexcept # Probabilistic equal degree factorisation of ``pol`` into # irreducible factors of degree ``d``. If it passes, a factor is # placed in factor and 1 is returned, otherwise 0 is returned and # the value of factor is undetermined. # Requires that ``pol`` be monic, non-constant and squarefree. - void nmod_poly_factor_equal_deg(nmod_poly_factor_t factors, const nmod_poly_t pol, slong d) + void nmod_poly_factor_equal_deg(nmod_poly_factor_t factors, const nmod_poly_t pol, slong d) noexcept # Assuming ``pol`` is a product of irreducible factors all of # degree ``d``, finds all those factors and places them in factors. # Requires that ``pol`` be monic, non-constant and squarefree. - void nmod_poly_factor_distinct_deg(nmod_poly_factor_t res, const nmod_poly_t poly, slong * const *degs) + void nmod_poly_factor_distinct_deg(nmod_poly_factor_t res, const nmod_poly_t poly, slong * const *degs) noexcept # Factorises a monic non-constant squarefree polynomial ``poly`` # of degree n into factors `f[d]` such that for `1 \leq d \leq n` # `f[d]` is the product of the monic irreducible factors of ``poly`` @@ -99,18 +99,18 @@ cdef extern from "flint_wrap.h": # as the factors. # Requires that ``degs`` has enough space for ``(n/2)+1 * sizeof(slong)``. - void nmod_poly_factor_distinct_deg_threaded(nmod_poly_factor_t res, const nmod_poly_t poly, slong * const *degs) + void nmod_poly_factor_distinct_deg_threaded(nmod_poly_factor_t res, const nmod_poly_t poly, slong * const *degs) noexcept # Multithreaded version of :func:`nmod_poly_factor_distinct_deg`. - void nmod_poly_factor_cantor_zassenhaus(nmod_poly_factor_t res, const nmod_poly_t f) + void nmod_poly_factor_cantor_zassenhaus(nmod_poly_factor_t res, const nmod_poly_t f) noexcept # Factorises a non-constant polynomial ``f`` into monic irreducible # factors using the Cantor-Zassenhaus algorithm. - void nmod_poly_factor_berlekamp(nmod_poly_factor_t res, const nmod_poly_t f) + void nmod_poly_factor_berlekamp(nmod_poly_factor_t res, const nmod_poly_t f) noexcept # Factorises a non-constant, squarefree polynomial ``f`` into monic # irreducible factors using the Berlekamp algorithm. - void nmod_poly_factor_kaltofen_shoup(nmod_poly_factor_t res, const nmod_poly_t poly) + void nmod_poly_factor_kaltofen_shoup(nmod_poly_factor_t res, const nmod_poly_t poly) noexcept # Factorises a non-constant polynomial ``f`` into monic irreducible # factors using the fast version of Cantor-Zassenhaus algorithm proposed by # Kaltofen and Shoup (1998). More precisely this algorithm uses a @@ -118,7 +118,7 @@ cdef extern from "flint_wrap.h": # step. If :func:`flint_get_num_threads` is greater than one # :func:`nmod_poly_factor_distinct_deg_threaded` is used. - mp_limb_t nmod_poly_factor_with_berlekamp(nmod_poly_factor_t res, const nmod_poly_t f) + mp_limb_t nmod_poly_factor_with_berlekamp(nmod_poly_factor_t res, const nmod_poly_t f) noexcept # Factorises a general polynomial ``f`` into monic irreducible factors # and returns the leading coefficient of ``f``, or 0 if ``f`` # is the zero polynomial. @@ -127,7 +127,7 @@ cdef extern from "flint_wrap.h": # square-free factorisation, and finally runs Berlekamp on all the # individual square-free factors. - mp_limb_t nmod_poly_factor_with_cantor_zassenhaus(nmod_poly_factor_t res, const nmod_poly_t f) + mp_limb_t nmod_poly_factor_with_cantor_zassenhaus(nmod_poly_factor_t res, const nmod_poly_t f) noexcept # Factorises a general polynomial ``f`` into monic irreducible factors # and returns the leading coefficient of ``f``, or 0 if ``f`` # is the zero polynomial. @@ -136,7 +136,7 @@ cdef extern from "flint_wrap.h": # square-free factorisation, and finally runs Cantor-Zassenhaus on all the # individual square-free factors. - mp_limb_t nmod_poly_factor_with_kaltofen_shoup(nmod_poly_factor_t res, const nmod_poly_t f) + mp_limb_t nmod_poly_factor_with_kaltofen_shoup(nmod_poly_factor_t res, const nmod_poly_t f) noexcept # Factorises a general polynomial ``f`` into monic irreducible factors # and returns the leading coefficient of ``f``, or 0 if ``f`` # is the zero polynomial. @@ -145,7 +145,7 @@ cdef extern from "flint_wrap.h": # square-free factorisation, and finally runs Kaltofen-Shoup on all the # individual square-free factors. - mp_limb_t nmod_poly_factor(nmod_poly_factor_t res, const nmod_poly_t f) + mp_limb_t nmod_poly_factor(nmod_poly_factor_t res, const nmod_poly_t f) noexcept # Factorises a general polynomial ``f`` into monic irreducible factors # and returns the leading coefficient of ``f``, or 0 if ``f`` # is the zero polynomial. @@ -156,7 +156,7 @@ cdef extern from "flint_wrap.h": # Currently Cantor-Zassenhaus is used by default unless the modulus is 2, in # which case Berlekamp is used. - void _nmod_poly_interval_poly_worker(void* arg_ptr) + void _nmod_poly_interval_poly_worker(void* arg_ptr) noexcept # Worker function to compute interval polynomials in distinct degree # factorisation. Input/output is stored in # ``nmod_poly_interval_poly_arg_t``. diff --git a/src/sage/libs/flint/nmod_poly_mat.pxd b/src/sage/libs/flint/nmod_poly_mat.pxd index 0fa57b73920..2047bf1761c 100644 --- a/src/sage/libs/flint/nmod_poly_mat.pxd +++ b/src/sage/libs/flint/nmod_poly_mat.pxd @@ -12,175 +12,175 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void nmod_poly_mat_init(nmod_poly_mat_t mat, slong rows, slong cols, mp_limb_t n) + void nmod_poly_mat_init(nmod_poly_mat_t mat, slong rows, slong cols, mp_limb_t n) noexcept # Initialises a matrix with the given number of rows and columns for use. # The modulus is set to `n`. - void nmod_poly_mat_init_set(nmod_poly_mat_t mat, const nmod_poly_mat_t src) + void nmod_poly_mat_init_set(nmod_poly_mat_t mat, const nmod_poly_mat_t src) noexcept # Initialises a matrix ``mat`` of the same dimensions and modulus # as ``src``, and sets it to a copy of ``src``. - void nmod_poly_mat_clear(nmod_poly_mat_t mat) + void nmod_poly_mat_clear(nmod_poly_mat_t mat) noexcept # Frees all memory associated with the matrix. The matrix must be # reinitialised if it is to be used again. - void nmod_poly_mat_set_trunc(nmod_poly_mat_t res, const nmod_poly_mat_t pmat, long len) + void nmod_poly_mat_set_trunc(nmod_poly_mat_t res, const nmod_poly_mat_t pmat, long len) noexcept # Set ``res`` to the truncation of ``pmat`` to length ``len``. Entries of # ``res`` are normalized. - void nmod_poly_mat_truncate(nmod_poly_mat_t pmat, long len) + void nmod_poly_mat_truncate(nmod_poly_mat_t pmat, long len) noexcept # Truncates ``pmat`` to the given length ``len``, and normalize its entries. # If ``len`` is greater than the maximum length of the entries of ``pmat``, # then nothing happens. - void nmod_poly_mat_shift_left(nmod_poly_mat_t res, const nmod_poly_mat_t pmat, slong k) + void nmod_poly_mat_shift_left(nmod_poly_mat_t res, const nmod_poly_mat_t pmat, slong k) noexcept # Sets ``res`` to ``pmat`` shifted left by ``k`` coefficients, that is, # multiplied by `x^k`. - void nmod_poly_mat_shift_right(nmod_poly_mat_t res, const nmod_poly_mat_t pmat, slong k) + void nmod_poly_mat_shift_right(nmod_poly_mat_t res, const nmod_poly_mat_t pmat, slong k) noexcept # Sets ``res`` to ``pmat`` shifted right by ``k`` coefficients, that is, # divide by `x^k` and throw away the remainder. If ``k`` is greater than or # equal to the length of ``pmat``, the result is the zero polynomial matrix. - slong nmod_poly_mat_nrows(const nmod_poly_mat_t mat) + slong nmod_poly_mat_nrows(const nmod_poly_mat_t mat) noexcept # Returns the number of rows in ``mat``. - slong nmod_poly_mat_ncols(const nmod_poly_mat_t mat) + slong nmod_poly_mat_ncols(const nmod_poly_mat_t mat) noexcept # Returns the number of columns in ``mat``. - mp_limb_t nmod_poly_mat_modulus(const nmod_poly_mat_t mat) + mp_limb_t nmod_poly_mat_modulus(const nmod_poly_mat_t mat) noexcept # Returns the modulus of ``mat``. - nmod_poly_struct * nmod_poly_mat_entry(const nmod_poly_mat_t mat, slong i, slong j) + nmod_poly_struct * nmod_poly_mat_entry(const nmod_poly_mat_t mat, slong i, slong j) noexcept # Gives a reference to the entry at row ``i`` and column ``j``. # The reference can be passed as an input or output variable to any # ``nmod_poly`` function for direct manipulation of the matrix element. # No bounds checking is performed. - void nmod_poly_mat_set(nmod_poly_mat_t mat1, const nmod_poly_mat_t mat2) + void nmod_poly_mat_set(nmod_poly_mat_t mat1, const nmod_poly_mat_t mat2) noexcept # Sets ``mat1`` to a copy of ``mat2``. - void nmod_poly_mat_set_nmod_mat(nmod_poly_mat_t pmat, const nmod_mat_t cmat) + void nmod_poly_mat_set_nmod_mat(nmod_poly_mat_t pmat, const nmod_mat_t cmat) noexcept # Sets the already-initialized polynomial matrix ``pmat`` to a constant # matrix with the same entries as ``cmat``. Both input matrices must have the # same dimensions and modulus. - void nmod_poly_mat_swap(nmod_poly_mat_t mat1, nmod_poly_mat_t mat2) + void nmod_poly_mat_swap(nmod_poly_mat_t mat1, nmod_poly_mat_t mat2) noexcept # Swaps ``mat1`` and ``mat2`` efficiently. - void nmod_poly_mat_swap_entrywise(nmod_poly_mat_t mat1, nmod_poly_mat_t mat2) + void nmod_poly_mat_swap_entrywise(nmod_poly_mat_t mat1, nmod_poly_mat_t mat2) noexcept # Swaps two matrices by swapping the individual entries rather than swapping # the contents of the structs. - void nmod_poly_mat_print(const nmod_poly_mat_t mat, const char * x) + void nmod_poly_mat_print(const nmod_poly_mat_t mat, const char * x) noexcept # Prints the matrix ``mat`` to standard output, using the # variable ``x``. - void nmod_poly_mat_randtest(nmod_poly_mat_t mat, flint_rand_t state, slong len) + void nmod_poly_mat_randtest(nmod_poly_mat_t mat, flint_rand_t state, slong len) noexcept # This is equivalent to applying ``nmod_poly_randtest`` to all entries # in the matrix. - void nmod_poly_mat_randtest_sparse(nmod_poly_mat_t A, flint_rand_t state, slong len, float density) + void nmod_poly_mat_randtest_sparse(nmod_poly_mat_t A, flint_rand_t state, slong len, float density) noexcept # Creates a random matrix with the amount of nonzero entries given # approximately by the ``density`` variable, which should be a fraction # between 0 (most sparse) and 1 (most dense). # The nonzero entries will have random lengths between 1 and ``len``. - void nmod_poly_mat_zero(nmod_poly_mat_t mat) + void nmod_poly_mat_zero(nmod_poly_mat_t mat) noexcept # Sets ``mat`` to the zero matrix. - void nmod_poly_mat_one(nmod_poly_mat_t mat) + void nmod_poly_mat_one(nmod_poly_mat_t mat) noexcept # Sets ``mat`` to the unit or identity matrix of given shape, # having the element 1 on the main diagonal and zeros elsewhere. # If ``mat`` is nonsquare, it is set to the truncation of a unit matrix. - bint nmod_poly_mat_equal(const nmod_poly_mat_t mat1, const nmod_poly_mat_t mat2) + bint nmod_poly_mat_equal(const nmod_poly_mat_t mat1, const nmod_poly_mat_t mat2) noexcept # Returns nonzero if ``mat1`` and ``mat2`` have the same shape and # all their entries agree, and returns zero otherwise. - bint nmod_poly_mat_equal_nmod_mat(const nmod_poly_mat_t pmat, const nmod_mat_t cmat) + bint nmod_poly_mat_equal_nmod_mat(const nmod_poly_mat_t pmat, const nmod_mat_t cmat) noexcept # Returns nonzero if ``pmat`` is a constant matrix with the same dimensions # and entries as ``cmat``; returns zero otherwise. - bint nmod_poly_mat_is_zero(const nmod_poly_mat_t mat) + bint nmod_poly_mat_is_zero(const nmod_poly_mat_t mat) noexcept # Returns nonzero if all entries in ``mat`` are zero, and returns # zero otherwise. - bint nmod_poly_mat_is_one(const nmod_poly_mat_t mat) + bint nmod_poly_mat_is_one(const nmod_poly_mat_t mat) noexcept # Returns nonzero if all entry of ``mat`` on the main diagonal # are the constant polynomial 1 and all remaining entries are zero, # and returns zero otherwise. The matrix need not be square. - bint nmod_poly_mat_is_empty(const nmod_poly_mat_t mat) + bint nmod_poly_mat_is_empty(const nmod_poly_mat_t mat) noexcept # Returns a non-zero value if the number of rows or the number of # columns in ``mat`` is zero, and otherwise returns # zero. - bint nmod_poly_mat_is_square(const nmod_poly_mat_t mat) + bint nmod_poly_mat_is_square(const nmod_poly_mat_t mat) noexcept # Returns a non-zero value if the number of rows is equal to the # number of columns in ``mat``, and otherwise returns zero. - void nmod_poly_mat_get_coeff_mat(nmod_mat_t coeff, const nmod_poly_mat_t pmat, slong deg) + void nmod_poly_mat_get_coeff_mat(nmod_mat_t coeff, const nmod_poly_mat_t pmat, slong deg) noexcept # Sets ``coeff`` to be the coefficient of ``pmat`` of degree ``deg``, where # ``pmat`` is seen as a polynomial with matrix coefficients and coefficients # are numbered from zero. ``coeff`` must be already initialized with the # right dimensions and modulus. For entries of ``pmat`` of degree less than # ``deg``, the corresponding entry of ``coeff`` is zero. - void nmod_poly_mat_set_coeff_mat(nmod_poly_mat_t pmat, const nmod_mat_t coeff, slong deg) + void nmod_poly_mat_set_coeff_mat(nmod_poly_mat_t pmat, const nmod_mat_t coeff, slong deg) noexcept # Sets the coefficient of ``pmat`` of degree ``deg`` to ``coeff``, where # ``pmat`` is seen as a polynomial with matrix coefficients and coefficients # are numbered from zero. For each entry of ``pmat``, if ``deg`` is larger # than its degree, this entry is first resized to the appropriate length, # with intervening coefficients being set to zero. - slong nmod_poly_mat_max_length(const nmod_poly_mat_t A) + slong nmod_poly_mat_max_length(const nmod_poly_mat_t A) noexcept # Returns the maximum polynomial length among all the entries in ``A``. - slong nmod_poly_mat_degree(const nmod_poly_mat_t pmat) + slong nmod_poly_mat_degree(const nmod_poly_mat_t pmat) noexcept # Returns the degree of the polynomial matrix ``pmat``. The zero matrix is # deemed to have degree `-1`. - void nmod_poly_mat_evaluate_nmod(nmod_mat_t B, const nmod_poly_mat_t A, mp_limb_t x) + void nmod_poly_mat_evaluate_nmod(nmod_mat_t B, const nmod_poly_mat_t A, mp_limb_t x) noexcept # Sets the ``nmod_mat_t`` ``B`` to ``A`` evaluated entrywise # at the point ``x``. - void nmod_poly_mat_scalar_mul_nmod_poly(nmod_poly_mat_t B, const nmod_poly_mat_t A, const nmod_poly_t c) + void nmod_poly_mat_scalar_mul_nmod_poly(nmod_poly_mat_t B, const nmod_poly_mat_t A, const nmod_poly_t c) noexcept # Sets ``B`` to ``A`` multiplied entrywise by the polynomial ``c``. - void nmod_poly_mat_scalar_mul_nmod(nmod_poly_mat_t B, const nmod_poly_mat_t A, mp_limb_t c) + void nmod_poly_mat_scalar_mul_nmod(nmod_poly_mat_t B, const nmod_poly_mat_t A, mp_limb_t c) noexcept # Sets ``B`` to ``A`` multiplied entrywise by the coefficient # ``c``, which is assumed to be reduced modulo the modulus. - void nmod_poly_mat_add(nmod_poly_mat_t C, const nmod_poly_mat_t A, const nmod_poly_mat_t B) + void nmod_poly_mat_add(nmod_poly_mat_t C, const nmod_poly_mat_t A, const nmod_poly_mat_t B) noexcept # Sets ``C`` to the sum of ``A`` and ``B``. # All matrices must have the same shape. Aliasing is allowed. - void nmod_poly_mat_sub(nmod_poly_mat_t C, const nmod_poly_mat_t A, const nmod_poly_mat_t B) + void nmod_poly_mat_sub(nmod_poly_mat_t C, const nmod_poly_mat_t A, const nmod_poly_mat_t B) noexcept # Sets ``C`` to the sum of ``A`` and ``B``. # All matrices must have the same shape. Aliasing is allowed. - void nmod_poly_mat_neg(nmod_poly_mat_t B, const nmod_poly_mat_t A) + void nmod_poly_mat_neg(nmod_poly_mat_t B, const nmod_poly_mat_t A) noexcept # Sets ``B`` to the negation of ``A``. # The matrices must have the same shape. Aliasing is allowed. - void nmod_poly_mat_mul(nmod_poly_mat_t C, const nmod_poly_mat_t A, const nmod_poly_mat_t B) + void nmod_poly_mat_mul(nmod_poly_mat_t C, const nmod_poly_mat_t A, const nmod_poly_mat_t B) noexcept # Sets ``C`` to the matrix product of ``A`` and ``B``. # The matrices must have compatible dimensions for matrix multiplication. # Aliasing is allowed. This function automatically chooses between # classical, KS and evaluation-interpolation multiplication. - void nmod_poly_mat_mul_classical(nmod_poly_mat_t C, const nmod_poly_mat_t A, const nmod_poly_mat_t B) + void nmod_poly_mat_mul_classical(nmod_poly_mat_t C, const nmod_poly_mat_t A, const nmod_poly_mat_t B) noexcept # Sets ``C`` to the matrix product of ``A`` and ``B``, # computed using the classical algorithm. The matrices must have # compatible dimensions for matrix multiplication. Aliasing is allowed. - void nmod_poly_mat_mul_KS(nmod_poly_mat_t C, const nmod_poly_mat_t A, const nmod_poly_mat_t B) + void nmod_poly_mat_mul_KS(nmod_poly_mat_t C, const nmod_poly_mat_t A, const nmod_poly_mat_t B) noexcept # Sets ``C`` to the matrix product of ``A`` and ``B``, # computed using Kronecker segmentation. The matrices must have # compatible dimensions for matrix multiplication. Aliasing is allowed. - void nmod_poly_mat_mul_interpolate(nmod_poly_mat_t C, const nmod_poly_mat_t A, const nmod_poly_mat_t B) + void nmod_poly_mat_mul_interpolate(nmod_poly_mat_t C, const nmod_poly_mat_t A, const nmod_poly_mat_t B) noexcept # Sets ``C`` to the matrix product of ``A`` and ``B``, # computed through evaluation and interpolation. The matrices must have # compatible dimensions for matrix multiplication. For interpolation @@ -188,32 +188,32 @@ cdef extern from "flint_wrap.h": # large as `m + n - 1` where `m` and `n` are the maximum lengths of # polynomials in the input matrices. Aliasing is allowed. - void nmod_poly_mat_sqr(nmod_poly_mat_t B, const nmod_poly_mat_t A) + void nmod_poly_mat_sqr(nmod_poly_mat_t B, const nmod_poly_mat_t A) noexcept # Sets ``B`` to the square of ``A``, which must be a square matrix. # Aliasing is allowed. This function automatically chooses between # classical and KS squaring. - void nmod_poly_mat_sqr_classical(nmod_poly_mat_t B, const nmod_poly_mat_t A) + void nmod_poly_mat_sqr_classical(nmod_poly_mat_t B, const nmod_poly_mat_t A) noexcept # Sets ``B`` to the square of ``A``, which must be a square matrix. # Aliasing is allowed. This function uses direct formulas for very small # matrices, and otherwise classical matrix multiplication. - void nmod_poly_mat_sqr_KS(nmod_poly_mat_t B, const nmod_poly_mat_t A) + void nmod_poly_mat_sqr_KS(nmod_poly_mat_t B, const nmod_poly_mat_t A) noexcept # Sets ``B`` to the square of ``A``, which must be a square matrix. # Aliasing is allowed. This function uses Kronecker segmentation. - void nmod_poly_mat_sqr_interpolate(nmod_poly_mat_t B, const nmod_poly_mat_t A) + void nmod_poly_mat_sqr_interpolate(nmod_poly_mat_t B, const nmod_poly_mat_t A) noexcept # Sets ``B`` to the square of ``A``, which must be a square matrix, # computed through evaluation and interpolation. For interpolation # to be well-defined, we require that the modulus is a prime at least as # large as `2n - 1` where `n` is the maximum length of # polynomials in the input matrix. Aliasing is allowed. - void nmod_poly_mat_pow(nmod_poly_mat_t B, const nmod_poly_mat_t A, ulong exp) + void nmod_poly_mat_pow(nmod_poly_mat_t B, const nmod_poly_mat_t A, ulong exp) noexcept # Sets ``B`` to ``A`` raised to the power ``exp``, where ``A`` # is a square matrix. Uses exponentiation by squaring. Aliasing is allowed. - slong nmod_poly_mat_find_pivot_any(const nmod_poly_mat_t mat, slong start_row, slong end_row, slong c) + slong nmod_poly_mat_find_pivot_any(const nmod_poly_mat_t mat, slong start_row, slong end_row, slong c) noexcept # Attempts to find a pivot entry for row reduction. # Returns a row index `r` between ``start_row`` (inclusive) and # ``stop_row`` (exclusive) such that column `c` in ``mat`` has @@ -223,7 +223,7 @@ cdef extern from "flint_wrap.h": # entries in the matrix have roughly the same size, but can lead to # unnecessary coefficient growth if the entries vary in size. - slong nmod_poly_mat_find_pivot_partial(const nmod_poly_mat_t mat, slong start_row, slong end_row, slong c) + slong nmod_poly_mat_find_pivot_partial(const nmod_poly_mat_t mat, slong start_row, slong end_row, slong c) noexcept # Attempts to find a pivot entry for row reduction. # Returns a row index `r` between ``start_row`` (inclusive) and # ``stop_row`` (exclusive) such that column `c` in ``mat`` has @@ -233,7 +233,7 @@ cdef extern from "flint_wrap.h": # typically reduces coefficient growth when the matrix entries # vary in size. - slong nmod_poly_mat_fflu(nmod_poly_mat_t B, nmod_poly_t den, slong * perm, const nmod_poly_mat_t A, int rank_check) + slong nmod_poly_mat_fflu(nmod_poly_mat_t B, nmod_poly_t den, slong * perm, const nmod_poly_mat_t A, int rank_check) noexcept # Uses fraction-free Gaussian elimination to set (``B``, ``den``) to a # fraction-free LU decomposition of ``A`` and returns the # rank of ``A``. Aliasing of ``A`` and ``B`` is allowed. @@ -247,28 +247,28 @@ cdef extern from "flint_wrap.h": # the sign is decided by the parity of the permutation. Note that the # determinant is not generally the minimal denominator. - slong nmod_poly_mat_rref(nmod_poly_mat_t B, nmod_poly_t den, const nmod_poly_mat_t A) + slong nmod_poly_mat_rref(nmod_poly_mat_t B, nmod_poly_t den, const nmod_poly_mat_t A) noexcept # Sets (``B``, ``den``) to the reduced row echelon form of ``A`` # and returns the rank of ``A``. # Aliasing of ``A`` and ``B`` is allowed. # The denominator ``den`` is set to `\pm \operatorname{det}(A)`. # Note that the determinant is not generally the minimal denominator. - void nmod_poly_mat_trace(nmod_poly_t trace, const nmod_poly_mat_t mat) + void nmod_poly_mat_trace(nmod_poly_t trace, const nmod_poly_mat_t mat) noexcept # Computes the trace of the matrix, i.e. the sum of the entries on # the main diagonal. The matrix is required to be square. - void nmod_poly_mat_det(nmod_poly_t det, const nmod_poly_mat_t A) + void nmod_poly_mat_det(nmod_poly_t det, const nmod_poly_mat_t A) noexcept # Sets ``det`` to the determinant of the square matrix ``A``. Uses # a direct formula, fraction-free LU decomposition, or interpolation, # depending on the size of the matrix. - void nmod_poly_mat_det_fflu(nmod_poly_t det, const nmod_poly_mat_t A) + void nmod_poly_mat_det_fflu(nmod_poly_t det, const nmod_poly_mat_t A) noexcept # Sets ``det`` to the determinant of the square matrix ``A``. # The determinant is computed by performing a fraction-free LU # decomposition on a copy of ``A``. - void nmod_poly_mat_det_interpolate(nmod_poly_t det, const nmod_poly_mat_t A) + void nmod_poly_mat_det_interpolate(nmod_poly_t det, const nmod_poly_mat_t A) noexcept # Sets ``det`` to the determinant of the square matrix ``A``. # The determinant is computed by determining a bound `n` for its length, # evaluating the matrix at `n` distinct points, computing the determinant @@ -277,11 +277,11 @@ cdef extern from "flint_wrap.h": # if working over `\mathbf{Z}/p\mathbf{Z}` where `p < n`), # this function automatically falls back to ``nmod_poly_mat_det_fflu``. - slong nmod_poly_mat_rank(const nmod_poly_mat_t A) + slong nmod_poly_mat_rank(const nmod_poly_mat_t A) noexcept # Returns the rank of ``A``. Performs fraction-free LU decomposition # on a copy of ``A``. - int nmod_poly_mat_inv(nmod_poly_mat_t Ainv, nmod_poly_t den, const nmod_poly_mat_t A) + int nmod_poly_mat_inv(nmod_poly_mat_t Ainv, nmod_poly_t den, const nmod_poly_mat_t A) noexcept # Sets (``Ainv``, ``den``) to the inverse matrix of ``A``. # Returns 1 if ``A`` is nonsingular and 0 if ``A`` is singular. # Aliasing of ``Ainv`` and ``A`` is allowed. @@ -291,7 +291,7 @@ cdef extern from "flint_wrap.h": # Uses fraction-free LU decomposition, followed by solving for # the identity matrix. - slong nmod_poly_mat_nullspace(nmod_poly_mat_t res, const nmod_poly_mat_t mat) + slong nmod_poly_mat_nullspace(nmod_poly_mat_t res, const nmod_poly_mat_t mat) noexcept # Computes the right rational nullspace of the matrix ``mat`` and # returns the nullity. # More precisely, assume that ``mat`` has rank `r` and nullity `n`. @@ -303,7 +303,7 @@ cdef extern from "flint_wrap.h": # In general, the polynomials in each column vector in the result # will have a nontrivial common GCD. - int nmod_poly_mat_solve(nmod_poly_mat_t X, nmod_poly_t den, const nmod_poly_mat_t A, const nmod_poly_mat_t B) + int nmod_poly_mat_solve(nmod_poly_mat_t X, nmod_poly_t den, const nmod_poly_mat_t A, const nmod_poly_mat_t B) noexcept # Solves the equation `AX = B` for nonsingular `A`. More precisely, computes # (``X``, ``den``) such that `AX = B \times \operatorname{den}`. # Returns 1 if `A` is nonsingular and 0 if `A` is singular. @@ -311,7 +311,7 @@ cdef extern from "flint_wrap.h": # Uses fraction-free LU decomposition followed by fraction-free # forward and back substitution. - int nmod_poly_mat_solve_fflu(nmod_poly_mat_t X, nmod_poly_t den, const nmod_poly_mat_t A, const nmod_poly_mat_t B) + int nmod_poly_mat_solve_fflu(nmod_poly_mat_t X, nmod_poly_t den, const nmod_poly_mat_t A, const nmod_poly_mat_t B) noexcept # Solves the equation `AX = B` for nonsingular `A`. More precisely, computes # (``X``, ``den``) such that `AX = B \times \operatorname{den}`. # Returns 1 if `A` is nonsingular and 0 if `A` is singular. @@ -319,6 +319,6 @@ cdef extern from "flint_wrap.h": # Uses fraction-free LU decomposition followed by fraction-free # forward and back substitution. - void nmod_poly_mat_solve_fflu_precomp(nmod_poly_mat_t X, const slong * perm, const nmod_poly_mat_t FFLU, const nmod_poly_mat_t B) + void nmod_poly_mat_solve_fflu_precomp(nmod_poly_mat_t X, const slong * perm, const nmod_poly_mat_t FFLU, const nmod_poly_mat_t B) noexcept # Performs fraction-free forward and back substitution given a precomputed # fraction-free LU decomposition and corresponding permutation. diff --git a/src/sage/libs/flint/nmod_vec.pxd b/src/sage/libs/flint/nmod_vec.pxd index 8009c859d49..9bb2a6839e3 100644 --- a/src/sage/libs/flint/nmod_vec.pxd +++ b/src/sage/libs/flint/nmod_vec.pxd @@ -12,39 +12,39 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - mp_ptr _nmod_vec_init(slong len) + mp_ptr _nmod_vec_init(slong len) noexcept # Returns a vector of the given length. The entries are not necessarily # zero. - void _nmod_vec_clear(mp_ptr vec) + void _nmod_vec_clear(mp_ptr vec) noexcept # Frees the memory used by the given vector. - void _nmod_vec_randtest(mp_ptr vec, flint_rand_t state, slong len, nmod_t mod) + void _nmod_vec_randtest(mp_ptr vec, flint_rand_t state, slong len, nmod_t mod) noexcept # Sets ``vec`` to a random vector of the given length with entries # reduced modulo ``mod.n``. - void _nmod_vec_set(mp_ptr res, mp_srcptr vec, slong len) + void _nmod_vec_set(mp_ptr res, mp_srcptr vec, slong len) noexcept # Copies ``len`` entries from the vector ``vec`` to ``res``. - void _nmod_vec_zero(mp_ptr vec, slong len) + void _nmod_vec_zero(mp_ptr vec, slong len) noexcept # Zeros the given vector of the given length. - void _nmod_vec_swap(mp_ptr a, mp_ptr b, slong length) + void _nmod_vec_swap(mp_ptr a, mp_ptr b, slong length) noexcept # Swaps the vectors ``a`` and ``b`` of length `n` by actually # swapping the entries. - void _nmod_vec_reduce(mp_ptr res, mp_srcptr vec, slong len, nmod_t mod) + void _nmod_vec_reduce(mp_ptr res, mp_srcptr vec, slong len, nmod_t mod) noexcept # Reduces the entries of ``(vec, len)`` modulo ``mod.n`` and set # ``res`` to the result. - flint_bitcnt_t _nmod_vec_max_bits(mp_srcptr vec, slong len) + flint_bitcnt_t _nmod_vec_max_bits(mp_srcptr vec, slong len) noexcept # Returns the maximum number of bits of any entry in the vector. - bint _nmod_vec_equal(mp_srcptr vec, mp_srcptr vec2, slong len) + bint _nmod_vec_equal(mp_srcptr vec, mp_srcptr vec2, slong len) noexcept # Returns~`1` if ``(vec, len)`` is equal to ``(vec2, len)``, # otherwise returns~`0`. - void _nmod_vec_print_pretty(mp_srcptr vec, slong len, nmod_t mod) + void _nmod_vec_print_pretty(mp_srcptr vec, slong len, nmod_t mod) noexcept # Pretty-prints ``vec`` to ``stdout``. A header is printed followed by the # vector enclosed in brackets. Each entry is right-aligned to the width of # the modulus written in decimal, and the entries are separated by spaces. @@ -52,40 +52,40 @@ cdef extern from "flint_wrap.h": # # [ 33 181 107 61 32 11 80 138 34 171 86 156] - int _nmod_vec_fprint_pretty(FILE * file, mp_srcptr vec, slong len, nmod_t mod) + int _nmod_vec_fprint_pretty(FILE * file, mp_srcptr vec, slong len, nmod_t mod) noexcept # Same as ``_nmod_vec_print_pretty`` but printing to ``file``. - int _nmod_vec_print(mp_srcptr vec, slong len, nmod_t mod) + int _nmod_vec_print(mp_srcptr vec, slong len, nmod_t mod) noexcept # Currently, same as ``_nmod_vec_print_pretty``. - int _nmod_vec_fprint(FILE * f, mp_srcptr vec, slong len, nmod_t mod) + int _nmod_vec_fprint(FILE * f, mp_srcptr vec, slong len, nmod_t mod) noexcept # Currently, same as ``_nmod_vec_fprint_pretty``. - void _nmod_vec_add(mp_ptr res, mp_srcptr vec1, mp_srcptr vec2, slong len, nmod_t mod) + void _nmod_vec_add(mp_ptr res, mp_srcptr vec1, mp_srcptr vec2, slong len, nmod_t mod) noexcept # Sets ``(res, len)`` to the sum of ``(vec1, len)`` # and ``(vec2, len)``. - void _nmod_vec_sub(mp_ptr res, mp_srcptr vec1, mp_srcptr vec2, slong len, nmod_t mod) + void _nmod_vec_sub(mp_ptr res, mp_srcptr vec1, mp_srcptr vec2, slong len, nmod_t mod) noexcept # Sets ``(res, len)`` to the difference of ``(vec1, len)`` # and ``(vec2, len)``. - void _nmod_vec_neg(mp_ptr res, mp_srcptr vec, slong len, nmod_t mod) + void _nmod_vec_neg(mp_ptr res, mp_srcptr vec, slong len, nmod_t mod) noexcept # Sets ``(res, len)`` to the negation of ``(vec, len)``. - void _nmod_vec_scalar_mul_nmod(mp_ptr res, mp_srcptr vec, slong len, mp_limb_t c, nmod_t mod) + void _nmod_vec_scalar_mul_nmod(mp_ptr res, mp_srcptr vec, slong len, mp_limb_t c, nmod_t mod) noexcept # Sets ``(res, len)`` to ``(vec, len)`` multiplied by `c`. The element # `c` and all elements of `vec` are assumed to be less than `mod.n`. - void _nmod_vec_scalar_mul_nmod_shoup(mp_ptr res, mp_srcptr vec, slong len, mp_limb_t c, nmod_t mod) + void _nmod_vec_scalar_mul_nmod_shoup(mp_ptr res, mp_srcptr vec, slong len, mp_limb_t c, nmod_t mod) noexcept # Sets ``(res, len)`` to ``(vec, len)`` multiplied by `c` using # :func:`n_mulmod_shoup`. `mod.n` should be less than `2^{\mathtt{FLINT\_BITS} - 1}`. `c` # and all elements of `vec` should be less than `mod.n`. - void _nmod_vec_scalar_addmul_nmod(mp_ptr res, mp_srcptr vec, slong len, mp_limb_t c, nmod_t mod) + void _nmod_vec_scalar_addmul_nmod(mp_ptr res, mp_srcptr vec, slong len, mp_limb_t c, nmod_t mod) noexcept # Adds ``(vec, len)`` times `c` to the vector ``(res, len)``. The element # `c` and all elements of `vec` are assumed to be less than `mod.n`. - int _nmod_vec_dot_bound_limbs(slong len, nmod_t mod) + int _nmod_vec_dot_bound_limbs(slong len, nmod_t mod) noexcept # Returns the number of limbs (0, 1, 2 or 3) needed to represent the # unreduced dot product of two vectors of length ``len`` having entries # modulo ``mod.n``, assuming that ``len`` is nonnegative and that @@ -93,16 +93,16 @@ cdef extern from "flint_wrap.h": # this function returns the precise limb size of ``len`` times # ``(mod.n - 1) ^ 2``. - mp_limb_t _nmod_vec_dot(mp_srcptr vec1, mp_srcptr vec2, slong len, nmod_t mod, int nlimbs) + mp_limb_t _nmod_vec_dot(mp_srcptr vec1, mp_srcptr vec2, slong len, nmod_t mod, int nlimbs) noexcept # Returns the dot product of (``vec1``, ``len``) and # (``vec2``, ``len``). The ``nlimbs`` parameter should be # 0, 1, 2 or 3, specifying the number of limbs needed to represent the # unreduced result. - mp_limb_t _nmod_vec_dot_rev(mp_srcptr vec1, mp_srcptr vec2, slong len, nmod_t mod, int nlimbs) + mp_limb_t _nmod_vec_dot_rev(mp_srcptr vec1, mp_srcptr vec2, slong len, nmod_t mod, int nlimbs) noexcept # The same as ``_nmod_vec_dot``, but reverses ``vec2``. - mp_limb_t _nmod_vec_dot_ptr(mp_srcptr vec1, const mp_ptr * vec2, slong offset, slong len, nmod_t mod, int nlimbs) + mp_limb_t _nmod_vec_dot_ptr(mp_srcptr vec1, const mp_ptr * vec2, slong offset, slong len, nmod_t mod, int nlimbs) noexcept # Returns the dot product of (``vec1``, ``len``) and the values at # ``vec2[i][offset]``. The ``nlimbs`` parameter should be # 0, 1, 2 or 3, specifying the number of limbs needed to represent the diff --git a/src/sage/libs/flint/padic.pxd b/src/sage/libs/flint/padic.pxd index ab2a2328cb3..c88cf07dc3f 100644 --- a/src/sage/libs/flint/padic.pxd +++ b/src/sage/libs/flint/padic.pxd @@ -12,29 +12,29 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - fmpz * padic_unit(const padic_t op) + fmpz * padic_unit(const padic_t op) noexcept # Returns the unit part of the `p`-adic number as a FLINT integer, which # can be used as an operand for the ``fmpz`` functions. - slong padic_val(const padic_t op) + slong padic_val(const padic_t op) noexcept # Returns the valuation part of the `p`-adic number. # Note that this function is implemented as a macro and that # the expression ``padic_val(op)`` can be used as both an # *lvalue* and an *rvalue*. - slong padic_get_val(const padic_t op) + slong padic_get_val(const padic_t op) noexcept # Returns the valuation part of the `p`-adic number. - slong padic_prec(const padic_t op) + slong padic_prec(const padic_t op) noexcept # Returns the precision of the `p`-adic number. # Note that this function is implemented as a macro and that # the expression ``padic_prec(op)`` can be used as both an # *lvalue* and an *rvalue*. - slong padic_get_prec(const padic_t op) + slong padic_get_prec(const padic_t op) noexcept # Returns the precision of the `p`-adic number. - void padic_ctx_init(padic_ctx_t ctx, const fmpz_t p, slong min, slong max, padic_print_mode mode) + void padic_ctx_init(padic_ctx_t ctx, const fmpz_t p, slong min, slong max, padic_print_mode mode) noexcept # Initialises the context ``ctx`` with the given data. # Assumes that `p` is a prime. This is not verified but the subsequent # behaviour is undefined if `p` is a composite number. @@ -52,151 +52,151 @@ cdef extern from "flint_wrap.h": # printed showing the valuation and unit parts separately, # e.g. ``12*7^-1``. - void padic_ctx_clear(padic_ctx_t ctx) + void padic_ctx_clear(padic_ctx_t ctx) noexcept # Clears all memory that has been allocated as part of the context. - int _padic_ctx_pow_ui(fmpz_t rop, ulong e, const padic_ctx_t ctx) + int _padic_ctx_pow_ui(fmpz_t rop, ulong e, const padic_ctx_t ctx) noexcept # Sets ``rop`` to `p^e` as efficiently as possible, where # ``rop`` is expected to be an uninitialised ``fmpz_t``. # If the return value is non-zero, it is the responsibility of # the caller to clear the returned integer. - void padic_init(padic_t rop) + void padic_init(padic_t rop) noexcept # Initialises the `p`-adic number with the precision set to # ``PADIC_DEFAULT_PREC``, which is defined as `20`. - void padic_init2(padic_t rop, slong N) + void padic_init2(padic_t rop, slong N) noexcept # Initialises the `p`-adic number ``rop`` with precision `N`. - void padic_clear(padic_t rop) + void padic_clear(padic_t rop) noexcept # Clears all memory used by the `p`-adic number ``rop``. - void _padic_canonicalise(padic_t rop, const padic_ctx_t ctx) + void _padic_canonicalise(padic_t rop, const padic_ctx_t ctx) noexcept # Brings the `p`-adic number ``rop`` into canonical form. # That is to say, ensures that either `u = v = 0` or # `p \nmid u`. There is no reduction modulo a power # of `p`. - void _padic_reduce(padic_t rop, const padic_ctx_t ctx) + void _padic_reduce(padic_t rop, const padic_ctx_t ctx) noexcept # Given a `p`-adic number ``rop`` in canonical form, # reduces it modulo `p^N`. - void padic_reduce(padic_t rop, const padic_ctx_t ctx) + void padic_reduce(padic_t rop, const padic_ctx_t ctx) noexcept # Ensures that the `p`-adic number ``rop`` is reduced. - void padic_randtest(padic_t rop, flint_rand_t state, const padic_ctx_t ctx) + void padic_randtest(padic_t rop, flint_rand_t state, const padic_ctx_t ctx) noexcept # Sets ``rop`` to a random `p`-adic number modulo `p^N` with valuation # in the range `[- \lceil N/10\rceil, N)`, `[N - \lceil -N/10\rceil, N)`, or `[-10, 0)` # as `N` is positive, negative or zero, whenever ``rop`` is non-zero. - void padic_randtest_not_zero(padic_t rop, flint_rand_t state, const padic_ctx_t ctx) + void padic_randtest_not_zero(padic_t rop, flint_rand_t state, const padic_ctx_t ctx) noexcept # Sets ``rop`` to a random non-zero `p`-adic number modulo `p^N`, # where the range of the valuation is as for the function # :func:`padic_randtest`. - void padic_randtest_int(padic_t rop, flint_rand_t state, const padic_ctx_t ctx) + void padic_randtest_int(padic_t rop, flint_rand_t state, const padic_ctx_t ctx) noexcept # Sets ``rop`` to a random `p`-adic integer modulo `p^N`. # Note that whenever `N \leq 0`, ``rop`` is set to zero. - void padic_set(padic_t rop, const padic_t op, const padic_ctx_t ctx) + void padic_set(padic_t rop, const padic_t op, const padic_ctx_t ctx) noexcept # Sets ``rop`` to the `p`-adic number ``op``. - void padic_set_si(padic_t rop, slong op, const padic_ctx_t ctx) + void padic_set_si(padic_t rop, slong op, const padic_ctx_t ctx) noexcept # Sets the `p`-adic number ``rop`` to the # ``slong`` integer ``op``. - void padic_set_ui(padic_t rop, ulong op, const padic_ctx_t ctx) + void padic_set_ui(padic_t rop, ulong op, const padic_ctx_t ctx) noexcept # Sets the `p`-adic number ``rop`` to the ``ulong`` # integer ``op``. - void padic_set_fmpz(padic_t rop, const fmpz_t op, const padic_ctx_t ctx) + void padic_set_fmpz(padic_t rop, const fmpz_t op, const padic_ctx_t ctx) noexcept # Sets the `p`-adic number ``rop`` to the integer ``op``. - void padic_set_fmpq(padic_t rop, const fmpq_t op, const padic_ctx_t ctx) + void padic_set_fmpq(padic_t rop, const fmpq_t op, const padic_ctx_t ctx) noexcept # Sets ``rop`` to the rational ``op``. - void padic_set_mpz(padic_t rop, const mpz_t op, const padic_ctx_t ctx) + void padic_set_mpz(padic_t rop, const mpz_t op, const padic_ctx_t ctx) noexcept # Sets the `p`-adic number ``rop`` to the MPIR integer ``op``. - void padic_set_mpq(padic_t rop, const mpq_t op, const padic_ctx_t ctx) + void padic_set_mpq(padic_t rop, const mpq_t op, const padic_ctx_t ctx) noexcept # Sets ``rop`` to the MPIR rational ``op``. - void padic_get_fmpz(fmpz_t rop, const padic_t op, const padic_ctx_t ctx) + void padic_get_fmpz(fmpz_t rop, const padic_t op, const padic_ctx_t ctx) noexcept # Sets the integer ``rop`` to the exact `p`-adic integer ``op``. # If ``op`` is not a `p`-adic integer, raises an ``abort`` signal. - void padic_get_fmpq(fmpq_t rop, const padic_t op, const padic_ctx_t ctx) + void padic_get_fmpq(fmpq_t rop, const padic_t op, const padic_ctx_t ctx) noexcept # Sets the rational ``rop`` to the `p`-adic number ``op``. - void padic_get_mpz(mpz_t rop, const padic_t op, const padic_ctx_t ctx) + void padic_get_mpz(mpz_t rop, const padic_t op, const padic_ctx_t ctx) noexcept # Sets the MPIR integer ``rop`` to the `p`-adic integer ``op``. # If ``op`` is not a `p`-adic integer, raises an ``abort`` signal. - void padic_get_mpq(mpq_t rop, const padic_t op, const padic_ctx_t ctx) + void padic_get_mpq(mpq_t rop, const padic_t op, const padic_ctx_t ctx) noexcept # Sets the MPIR rational ``rop`` to the value of ``op``. - void padic_swap(padic_t op1, padic_t op2) + void padic_swap(padic_t op1, padic_t op2) noexcept # Swaps the two `p`-adic numbers ``op1`` and ``op2``. # Note that this includes swapping the precisions. In particular, this # operation is not equivalent to swapping ``op1`` and ``op2`` # using :func:`padic_set` and an auxiliary variable whenever the # precisions of the two elements are different. - void padic_zero(padic_t rop) + void padic_zero(padic_t rop) noexcept # Sets the `p`-adic number ``rop`` to zero. - void padic_one(padic_t rop) + void padic_one(padic_t rop) noexcept # Sets the `p`-adic number ``rop`` to one, reduced modulo the # precision of ``rop``. - bint padic_is_zero(const padic_t op) + bint padic_is_zero(const padic_t op) noexcept # Returns whether ``op`` is equal to zero. - bint padic_is_one(const padic_t op) + bint padic_is_one(const padic_t op) noexcept # Returns whether ``op`` is equal to one, that is, whether # `u = 1` and `v = 0`. - bint padic_equal(const padic_t op1, const padic_t op2) + bint padic_equal(const padic_t op1, const padic_t op2) noexcept # Returns whether ``op1`` and ``op2`` are equal, that is, # whether `u_1 = u_2` and `v_1 = v_2`. - slong * _padic_lifts_exps(slong *n, slong N) + slong * _padic_lifts_exps(slong *n, slong N) noexcept # Given a positive integer `N` define the sequence # `a_0 = N, a_1 = \lceil a_0/2\rceil, \dotsc, a_{n-1} = \lceil a_{n-2}/2\rceil = 1`. # Then `n = \lceil\log_2 N\rceil + 1`. # This function sets `n` and allocates and returns the array `a`. - void _padic_lifts_pows(fmpz *pow, const slong *a, slong n, const fmpz_t p) + void _padic_lifts_pows(fmpz *pow, const slong *a, slong n, const fmpz_t p) noexcept # Given an array `a` as computed above, this function # computes the corresponding powers of `p`, that is, # ``pow[i]`` is equal to `p^{a_i}`. - void padic_add(padic_t rop, const padic_t op1, const padic_t op2, const padic_ctx_t ctx) + void padic_add(padic_t rop, const padic_t op1, const padic_t op2, const padic_ctx_t ctx) noexcept # Sets ``rop`` to the sum of ``op1`` and ``op2``. - void padic_sub(padic_t rop, const padic_t op1, const padic_t op2, const padic_ctx_t ctx) + void padic_sub(padic_t rop, const padic_t op1, const padic_t op2, const padic_ctx_t ctx) noexcept # Sets ``rop`` to the difference of ``op1`` and ``op2``. - void padic_neg(padic_t rop, const padic_t op, const padic_ctx_t ctx) + void padic_neg(padic_t rop, const padic_t op, const padic_ctx_t ctx) noexcept # Sets ``rop`` to the additive inverse of ``op``. - void padic_mul(padic_t rop, const padic_t op1, const padic_t op2, const padic_ctx_t ctx) + void padic_mul(padic_t rop, const padic_t op1, const padic_t op2, const padic_ctx_t ctx) noexcept # Sets ``rop`` to the product of ``op1`` and ``op2``. - void padic_shift(padic_t rop, const padic_t op, slong v, const padic_ctx_t ctx) + void padic_shift(padic_t rop, const padic_t op, slong v, const padic_ctx_t ctx) noexcept # Sets ``rop`` to the product of ``op`` and `p^v`. - void padic_div(padic_t rop, const padic_t op1, const padic_t op2, const padic_ctx_t ctx) + void padic_div(padic_t rop, const padic_t op1, const padic_t op2, const padic_ctx_t ctx) noexcept # Sets ``rop`` to the quotient of ``op1`` and ``op2``. - void _padic_inv_precompute(padic_inv_t S, const fmpz_t p, slong N) + void _padic_inv_precompute(padic_inv_t S, const fmpz_t p, slong N) noexcept # Pre-computes some data and allocates temporary space for # `p`-adic inversion using Hensel lifting. - void _padic_inv_clear(padic_inv_t S) + void _padic_inv_clear(padic_inv_t S) noexcept # Frees the memory used by `S`. - void _padic_inv_precomp(fmpz_t rop, const fmpz_t op, const padic_inv_t S) + void _padic_inv_precomp(fmpz_t rop, const fmpz_t op, const padic_inv_t S) noexcept # Sets ``rop`` to the inverse of ``op`` modulo `p^N`, # assuming that ``op`` is a unit and `N \geq 1`. # In the current implementation, allows aliasing, but this might @@ -208,20 +208,20 @@ cdef extern from "flint_wrap.h": # this function to avoid repeated memory allocations, as used # e.g. by the function :func:`padic_log`. - void _padic_inv(fmpz_t rop, const fmpz_t op, const fmpz_t p, slong N) + void _padic_inv(fmpz_t rop, const fmpz_t op, const fmpz_t p, slong N) noexcept # Sets ``rop`` to the inverse of ``op`` modulo `p^N`, # assuming that ``op`` is a unit and `N \geq 1`. # In the current implementation, allows aliasing, but this might # change in future versions. - void padic_inv(padic_t rop, const padic_t op, const padic_ctx_t ctx) + void padic_inv(padic_t rop, const padic_t op, const padic_ctx_t ctx) noexcept # Computes the inverse of ``op`` modulo `p^N`. # Suppose that ``op`` is given as `x = u p^v`. # Raises an ``abort`` signal if `v < -N`. Otherwise, # computes the inverse of `u` modulo `p^{N+v}`. # This function employs Hensel lifting of an inverse modulo `p`. - int padic_sqrt(padic_t rop, const padic_t op, const padic_ctx_t ctx) + int padic_sqrt(padic_t rop, const padic_t op, const padic_ctx_t ctx) noexcept # Returns whether ``op`` is a `p`-adic square. If this is # the case, sets ``rop`` to one of the square roots; otherwise, # the value of ``rop`` is undefined. @@ -232,7 +232,7 @@ cdef extern from "flint_wrap.h": # `u \bmod 8` is a square in `\mathbf{Z} / 8 \mathbf{Z}`, # for `p = 2`. - void padic_pow_si(padic_t rop, const padic_t op, slong e, const padic_ctx_t ctx) + void padic_pow_si(padic_t rop, const padic_t op, slong e, const padic_ctx_t ctx) noexcept # Sets ``rop`` to ``op`` raised to the power `e`, # which is defined as one whenever `e = 0`. # Assumes that some computations involving `e` and the @@ -242,7 +242,7 @@ cdef extern from "flint_wrap.h": # then `x^e = p^{ev} u^e` is defined modulo `p^{N + (e - 1) v}`, # which is a precision loss in case `v < 0`. - slong _padic_exp_bound(slong v, slong N, const fmpz_t p) + slong _padic_exp_bound(slong v, slong N, const fmpz_t p) noexcept # Returns an integer `i` such that for all `j \geq i` we have # `\operatorname{ord}_p(x^j / j!) \geq N`, where `\operatorname{ord}_p(x) = v`. # When `p` is a word-sized prime, @@ -251,9 +251,9 @@ cdef extern from "flint_wrap.h": # Assumes that `v < N`. Moreover, `v` has to be at least `2` or `1`, # depending on whether `p` is `2` or odd. - void _padic_exp_rectangular(fmpz_t rop, const fmpz_t u, slong v, const fmpz_t p, slong N) - void _padic_exp_balanced(fmpz_t rop, const fmpz_t u, slong v, const fmpz_t p, slong N) - void _padic_exp(fmpz_t rop, const fmpz_t u, slong v, const fmpz_t p, slong N) + void _padic_exp_rectangular(fmpz_t rop, const fmpz_t u, slong v, const fmpz_t p, slong N) noexcept + void _padic_exp_balanced(fmpz_t rop, const fmpz_t u, slong v, const fmpz_t p, slong N) noexcept + void _padic_exp(fmpz_t rop, const fmpz_t u, slong v, const fmpz_t p, slong N) noexcept # Sets ``rop`` to the `p`-exponential function evaluated at # `x = p^v u`, reduced modulo `p^N`. # Assumes that `x \neq 0`, that `\operatorname{ord}_p(x) < N` and that @@ -261,7 +261,7 @@ cdef extern from "flint_wrap.h": # `2` or `1` depending on whether the prime `p` is `2` or odd. # Supports aliasing between ``rop`` and `u`. - int padic_exp(padic_t y, const padic_t x, const padic_ctx_t ctx) + int padic_exp(padic_t y, const padic_t x, const padic_ctx_t ctx) noexcept # Returns whether the `p`-adic exponential function converges at # the `p`-adic number `x`, and if so sets `y` to its value. # The `p`-adic exponential function is defined by the usual series @@ -271,20 +271,20 @@ cdef extern from "flint_wrap.h": # elements `x \in \mathbf{Q}_p`, this means that `\operatorname{ord}_p(x) \geq 1` # when `p \geq 3` and `\operatorname{ord}_2(x) \geq 2` when `p = 2`. - int padic_exp_rectangular(padic_t y, const padic_t x, const padic_ctx_t ctx) + int padic_exp_rectangular(padic_t y, const padic_t x, const padic_ctx_t ctx) noexcept # Returns whether the `p`-adic exponential function converges at # the `p`-adic number `x`, and if so sets `y` to its value. # Uses a rectangular splitting algorithm to evaluate the series # expression of `\exp(x) \bmod{p^N}`. - int padic_exp_balanced(padic_t y, const padic_t x, const padic_ctx_t ctx) + int padic_exp_balanced(padic_t y, const padic_t x, const padic_ctx_t ctx) noexcept # Returns whether the `p`-adic exponential function converges at # the `p`-adic number `x`, and if so sets `y` to its value. # Uses a balanced approach, balancing the size of chunks of `x` # with the valuation and hence the rate of convergence, which # results in a quasi-linear algorithm in `N`, for fixed `p`. - slong _padic_log_bound(slong v, slong N, const fmpz_t p) + slong _padic_log_bound(slong v, slong N, const fmpz_t p) noexcept # Returns `b` such that for all `i \geq b` we have # .. math :: # i v - \operatorname{ord}_p(i) \geq N @@ -293,10 +293,10 @@ cdef extern from "flint_wrap.h": # odd or `p = 2`, respectively, and also that `N < 2^{f-2}` # where `f` is ``FLINT_BITS``. - void _padic_log(fmpz_t z, const fmpz_t y, slong v, const fmpz_t p, slong N) - void _padic_log_rectangular(fmpz_t z, const fmpz_t y, slong v, const fmpz_t p, slong N) - void _padic_log_satoh(fmpz_t z, const fmpz_t y, slong v, const fmpz_t p, slong N) - void _padic_log_balanced(fmpz_t z, const fmpz_t y, slong v, const fmpz_t p, slong N) + void _padic_log(fmpz_t z, const fmpz_t y, slong v, const fmpz_t p, slong N) noexcept + void _padic_log_rectangular(fmpz_t z, const fmpz_t y, slong v, const fmpz_t p, slong N) noexcept + void _padic_log_satoh(fmpz_t z, const fmpz_t y, slong v, const fmpz_t p, slong N) noexcept + void _padic_log_balanced(fmpz_t z, const fmpz_t y, slong v, const fmpz_t p, slong N) noexcept # Computes # .. math :: # z = - \sum_{i = 1}^{\infty} \frac{y^i}{i} \pmod{p^N}, @@ -312,7 +312,7 @@ cdef extern from "flint_wrap.h": # Assumes that `v < N`, and hence in particular `N \geq 2`. # Does not support aliasing between `y` and `z`. - int padic_log(padic_t rop, const padic_t op, const padic_ctx_t ctx) + int padic_log(padic_t rop, const padic_t op, const padic_ctx_t ctx) noexcept # Returns whether the `p`-adic logarithm function converges at # the `p`-adic number ``op``, and if so sets ``rop`` to its # value. @@ -322,14 +322,14 @@ cdef extern from "flint_wrap.h": # but this only converges when `\operatorname{ord}_p(x - 1)` is at least `2` # or `1` when `p = 2` or `p > 2`, respectively. - int padic_log_rectangular(padic_t rop, const padic_t op, const padic_ctx_t ctx) + int padic_log_rectangular(padic_t rop, const padic_t op, const padic_ctx_t ctx) noexcept # Returns whether the `p`-adic logarithm function converges at # the `p`-adic number ``op``, and if so sets ``rop`` to its # value. # Uses a rectangular splitting algorithm to evaluate the series # expression of `\log(x) \bmod{p^N}`. - int padic_log_satoh(padic_t rop, const padic_t op, const padic_ctx_t ctx) + int padic_log_satoh(padic_t rop, const padic_t op, const padic_ctx_t ctx) noexcept # Returns whether the `p`-adic logarithm function converges at # the `p`-adic number ``op``, and if so sets ``rop`` to its # value. @@ -339,38 +339,38 @@ cdef extern from "flint_wrap.h": # \log(a) \equiv p^{-k} \Bigl( \log\bigl(a^{p^k}\bigr) \pmod{p^{N+k}} # \Bigr) \pmod{p^N}. - int padic_log_balanced(padic_t rop, const padic_t op, const padic_ctx_t ctx) + int padic_log_balanced(padic_t rop, const padic_t op, const padic_ctx_t ctx) noexcept # Returns whether the `p`-adic logarithm function converges at # the `p`-adic number ``op``, and if so sets ``rop`` to its # value. - void _padic_teichmuller(fmpz_t rop, const fmpz_t op, const fmpz_t p, slong N) + void _padic_teichmuller(fmpz_t rop, const fmpz_t op, const fmpz_t p, slong N) noexcept # Computes the Teichm\"uller lift of the `p`-adic unit ``op``, # assuming that `N \geq 1`. # Supports aliasing between ``rop`` and ``op``. - void padic_teichmuller(padic_t rop, const padic_t op, const padic_ctx_t ctx) + void padic_teichmuller(padic_t rop, const padic_t op, const padic_ctx_t ctx) noexcept # Computes the Teichm\"uller lift of the `p`-adic unit ``op``. # If ``op`` is a `p`-adic integer divisible by `p`, sets ``rop`` # to zero, which satisfies `t^p - t = 0`, although it is clearly not # a `(p-1)`-st root of unity. # If ``op`` has negative valuation, raises an ``abort`` signal. - ulong padic_val_fac_ui_2(ulong n) + ulong padic_val_fac_ui_2(ulong n) noexcept # Computes the `2`-adic valuation of `n!`. # Note that since `n` fits into an ``ulong``, so does # `\operatorname{ord}_2(n!)` since `\operatorname{ord}_2(n!) \leq (n - 1) / (p - 1) = n - 1`. - ulong padic_val_fac_ui(ulong n, const fmpz_t p) + ulong padic_val_fac_ui(ulong n, const fmpz_t p) noexcept # Computes the `p`-adic valuation of `n!`. # Note that since `n` fits into an ``ulong``, so does # `\operatorname{ord}_p(n!)` since `\operatorname{ord}_p(n!) \leq (n - 1) / (p - 1)`. - void padic_val_fac(fmpz_t rop, const fmpz_t op, const fmpz_t p) + void padic_val_fac(fmpz_t rop, const fmpz_t op, const fmpz_t p) noexcept # Sets ``rop`` to the `p`-adic valuation of the factorial # of ``op``, assuming that ``op`` is non-negative. - char * padic_get_str(char * str, const padic_t op, const padic_ctx_t ctx) + char * padic_get_str(char * str, const padic_t op, const padic_ctx_t ctx) noexcept # Returns the string representation of the `p`-adic number ``op`` # according to the printing mode set in the context. # If ``str`` is ``NULL`` then a new block of memory is allocated @@ -378,18 +378,18 @@ cdef extern from "flint_wrap.h": # the string ``str`` is large enough to hold the representation and # it is also the return value. - int _padic_fprint(FILE * file, const fmpz_t u, slong v, const padic_ctx_t ctx) - int padic_fprint(FILE * file, const padic_t op, const padic_ctx_t ctx) + int _padic_fprint(FILE * file, const fmpz_t u, slong v, const padic_ctx_t ctx) noexcept + int padic_fprint(FILE * file, const padic_t op, const padic_ctx_t ctx) noexcept # Prints the string representation of the `p`-adic number ``op`` # to the stream ``file``. # In the current implementation, always returns `1`. - int _padic_print(const fmpz_t u, slong v, const padic_ctx_t ctx) - int padic_print(const padic_t op, const padic_ctx_t ctx) + int _padic_print(const fmpz_t u, slong v, const padic_ctx_t ctx) noexcept + int padic_print(const padic_t op, const padic_ctx_t ctx) noexcept # Prints the string representation of the `p`-adic number ``op`` # to the stream ``stdout``. # In the current implementation, always returns `1`. - void padic_debug(const padic_t op) + void padic_debug(const padic_t op) noexcept # Prints debug information about ``op`` to the stream ``stdout``, # in the format ``"(u v N)"``. diff --git a/src/sage/libs/flint/padic_mat.pxd b/src/sage/libs/flint/padic_mat.pxd index d0e0c541f4c..1d5e8ea44ac 100644 --- a/src/sage/libs/flint/padic_mat.pxd +++ b/src/sage/libs/flint/padic_mat.pxd @@ -12,172 +12,172 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - fmpz_mat_struct * padic_mat(const padic_mat_t A) + fmpz_mat_struct * padic_mat(const padic_mat_t A) noexcept # Returns a pointer to the unit part of the matrix, which # is a matrix over `\mathbf{Z}`. # The return value can be used as an argument to # the functions in the ``fmpz_mat`` module. - fmpz * padic_mat_entry(const padic_mat_t A, slong i, slong j) + fmpz * padic_mat_entry(const padic_mat_t A, slong i, slong j) noexcept # Returns a pointer to unit part of the entry in position `(i, j)`. # Note that this is not necessarily a unit. # The return value can be used as an argument to # the functions in the ``fmpz`` module. - slong padic_mat_val(const padic_mat_t A) + slong padic_mat_val(const padic_mat_t A) noexcept # Allow access (as L-value or R-value) to ``val`` field of `A`. # This function is implemented as a macro. - slong padic_mat_prec(const padic_mat_t A) + slong padic_mat_prec(const padic_mat_t A) noexcept # Allow access (as L-value or R-value) to ``prec`` field of `A`. # This function is implemented as a macro. - slong padic_mat_get_val(const padic_mat_t A) + slong padic_mat_get_val(const padic_mat_t A) noexcept # Returns the valuation of the matrix. - slong padic_mat_get_prec(const padic_mat_t A) + slong padic_mat_get_prec(const padic_mat_t A) noexcept # Returns the `p`-adic precision of the matrix. - slong padic_mat_nrows(const padic_mat_t A) + slong padic_mat_nrows(const padic_mat_t A) noexcept # Returns the number of rows of the matrix `A`. - slong padic_mat_ncols(const padic_mat_t A) + slong padic_mat_ncols(const padic_mat_t A) noexcept # Returns the number of columns of the matrix `A`. - void padic_mat_init(padic_mat_t A, slong r, slong c) + void padic_mat_init(padic_mat_t A, slong r, slong c) noexcept # Initialises the matrix `A` as a zero matrix with the specified numbers # of rows and columns and precision ``PADIC_DEFAULT_PREC``. - void padic_mat_init2(padic_mat_t A, slong r, slong c, slong prec) + void padic_mat_init2(padic_mat_t A, slong r, slong c, slong prec) noexcept # Initialises the matrix `A` as a zero matrix with the specified numbers # of rows and columns and the given precision. - void padic_mat_clear(padic_mat_t A) + void padic_mat_clear(padic_mat_t A) noexcept # Clears the matrix `A`. - void _padic_mat_canonicalise(padic_mat_t A, const padic_ctx_t ctx) + void _padic_mat_canonicalise(padic_mat_t A, const padic_ctx_t ctx) noexcept # Ensures that the matrix `A` is in canonical form. - void _padic_mat_reduce(padic_mat_t A, const padic_ctx_t ctx) + void _padic_mat_reduce(padic_mat_t A, const padic_ctx_t ctx) noexcept # Ensures that the matrix `A` is reduced modulo `p^N`, # assuming that it is in canonical form already. - void padic_mat_reduce(padic_mat_t A, const padic_ctx_t ctx) + void padic_mat_reduce(padic_mat_t A, const padic_ctx_t ctx) noexcept # Ensures that the matrix `A` is reduced modulo `p^N`, # without assuming that it is necessarily in canonical form. - bint padic_mat_is_empty(const padic_mat_t A) + bint padic_mat_is_empty(const padic_mat_t A) noexcept # Returns whether the matrix `A` is empty, that is, # whether it has zero rows or zero columns. - bint padic_mat_is_square(const padic_mat_t A) + bint padic_mat_is_square(const padic_mat_t A) noexcept # Returns whether the matrix `A` is square. - bint padic_mat_is_canonical(const padic_mat_t A, const padic_ctx_t p) + bint padic_mat_is_canonical(const padic_mat_t A, const padic_ctx_t p) noexcept # Returns whether the matrix `A` is in canonical form. - void padic_mat_set(padic_mat_t B, const padic_mat_t A, const padic_ctx_t p) + void padic_mat_set(padic_mat_t B, const padic_mat_t A, const padic_ctx_t p) noexcept # Sets `B` to a copy of `A`, respecting the precision of `B`. - void padic_mat_swap(padic_mat_t A, padic_mat_t B) + void padic_mat_swap(padic_mat_t A, padic_mat_t B) noexcept # Swaps the two matrices `A` and `B`. This is done efficiently by # swapping pointers. - void padic_mat_swap_entrywise(padic_mat_t mat1, padic_mat_t mat2) + void padic_mat_swap_entrywise(padic_mat_t mat1, padic_mat_t mat2) noexcept # Swaps two matrices by swapping the individual entries rather than swapping # the contents of the structs. - void padic_mat_zero(padic_mat_t A) + void padic_mat_zero(padic_mat_t A) noexcept # Sets the matrix `A` to zero. - void padic_mat_one(padic_mat_t A) + void padic_mat_one(padic_mat_t A) noexcept # Sets the matrix `A` to the identity matrix. If the precision # is negative then the matrix will be the zero matrix. - void padic_mat_set_fmpq_mat(padic_mat_t B, const fmpq_mat_t A, const padic_ctx_t ctx) + void padic_mat_set_fmpq_mat(padic_mat_t B, const fmpq_mat_t A, const padic_ctx_t ctx) noexcept # Sets the `p`-adic matrix `B` to the rational matrix `A`, reduced # according to the given context. - void padic_mat_get_fmpq_mat(fmpq_mat_t B, const padic_mat_t A, const padic_ctx_t ctx) + void padic_mat_get_fmpq_mat(fmpq_mat_t B, const padic_mat_t A, const padic_ctx_t ctx) noexcept # Sets the rational matrix `B` to the `p`-adic matrices `A`; # no reduction takes place. - void padic_mat_get_entry_padic(padic_t rop, const padic_mat_t op, slong i, slong j, const padic_ctx_t ctx) + void padic_mat_get_entry_padic(padic_t rop, const padic_mat_t op, slong i, slong j, const padic_ctx_t ctx) noexcept # Sets ``rop`` to the entry in position `(i, j)` in the matrix ``op``. - void padic_mat_set_entry_padic(padic_mat_t rop, slong i, slong j, const padic_t op, const padic_ctx_t ctx) + void padic_mat_set_entry_padic(padic_mat_t rop, slong i, slong j, const padic_t op, const padic_ctx_t ctx) noexcept # Sets the entry in position `(i, j)` in the matrix to ``rop``. - bint padic_mat_equal(const padic_mat_t A, const padic_mat_t B) + bint padic_mat_equal(const padic_mat_t A, const padic_mat_t B) noexcept # Returns whether the two matrices `A` and `B` are equal. - bint padic_mat_is_zero(const padic_mat_t A) + bint padic_mat_is_zero(const padic_mat_t A) noexcept # Returns whether the matrix `A` is zero. - int padic_mat_fprint(FILE * file, const padic_mat_t A, const padic_ctx_t ctx) + int padic_mat_fprint(FILE * file, const padic_mat_t A, const padic_ctx_t ctx) noexcept # Prints a simple representation of the matrix `A` to the # output stream ``file``. The format is the number of rows, # a space, the number of columns, two spaces, followed by a list # of all the entries, one row after the other. # In the current implementation, always returns `1`. - int padic_mat_fprint_pretty(FILE * file, const padic_mat_t A, const padic_ctx_t ctx) + int padic_mat_fprint_pretty(FILE * file, const padic_mat_t A, const padic_ctx_t ctx) noexcept # Prints a *pretty* representation of the matrix `A` # to the output stream ``file``. # In the current implementation, always returns `1`. - int padic_mat_print(const padic_mat_t A, const padic_ctx_t ctx) - int padic_mat_print_pretty(const padic_mat_t A, const padic_ctx_t ctx) + int padic_mat_print(const padic_mat_t A, const padic_ctx_t ctx) noexcept + int padic_mat_print_pretty(const padic_mat_t A, const padic_ctx_t ctx) noexcept - void padic_mat_randtest(padic_mat_t A, flint_rand_t state, const padic_ctx_t ctx) + void padic_mat_randtest(padic_mat_t A, flint_rand_t state, const padic_ctx_t ctx) noexcept # Sets `A` to a random matrix. # The valuation will be in the range `[- \lceil N/10\rceil, N)`, # `[N - \lceil -N/10\rceil, N)`, or `[-10, 0)` as `N` is positive, # negative or zero. - void padic_mat_transpose(padic_mat_t B, const padic_mat_t A) + void padic_mat_transpose(padic_mat_t B, const padic_mat_t A) noexcept # Sets `B` to `A^t`. - void _padic_mat_add(padic_mat_t C, const padic_mat_t A, const padic_mat_t B, const padic_ctx_t ctx) + void _padic_mat_add(padic_mat_t C, const padic_mat_t A, const padic_mat_t B, const padic_ctx_t ctx) noexcept # Sets `C` to the exact sum `A + B`, ensuring that the result is in # canonical form. - void padic_mat_add(padic_mat_t C, const padic_mat_t A, const padic_mat_t B, const padic_ctx_t ctx) + void padic_mat_add(padic_mat_t C, const padic_mat_t A, const padic_mat_t B, const padic_ctx_t ctx) noexcept # Sets `C` to the sum `A + B` modulo `p^N`. - void _padic_mat_sub(padic_mat_t C, const padic_mat_t A, const padic_mat_t B, const padic_ctx_t ctx) + void _padic_mat_sub(padic_mat_t C, const padic_mat_t A, const padic_mat_t B, const padic_ctx_t ctx) noexcept # Sets `C` to the exact difference `A - B`, ensuring that the result is in # canonical form. - void padic_mat_sub(padic_mat_t C, const padic_mat_t A, const padic_mat_t B, const padic_ctx_t ctx) + void padic_mat_sub(padic_mat_t C, const padic_mat_t A, const padic_mat_t B, const padic_ctx_t ctx) noexcept # Sets `C` to `A - B`, ensuring that the result is reduced. - void _padic_mat_neg(padic_mat_t B, const padic_mat_t A) + void _padic_mat_neg(padic_mat_t B, const padic_mat_t A) noexcept # Sets `B` to `-A` in canonical form. - void padic_mat_neg(padic_mat_t B, const padic_mat_t A, const padic_ctx_t ctx) + void padic_mat_neg(padic_mat_t B, const padic_mat_t A, const padic_ctx_t ctx) noexcept # Sets `B` to `-A`, ensuring the result is reduced. - void _padic_mat_scalar_mul_padic(padic_mat_t B, const padic_mat_t A, const padic_t c, const padic_ctx_t ctx) + void _padic_mat_scalar_mul_padic(padic_mat_t B, const padic_mat_t A, const padic_t c, const padic_ctx_t ctx) noexcept # Sets `B` to `c A`, ensuring that the result is in canonical form. - void padic_mat_scalar_mul_padic(padic_mat_t B, const padic_mat_t A, const padic_t c, const padic_ctx_t ctx) + void padic_mat_scalar_mul_padic(padic_mat_t B, const padic_mat_t A, const padic_t c, const padic_ctx_t ctx) noexcept # Sets `B` to `c A`, ensuring that the result is reduced. - void _padic_mat_scalar_mul_fmpz(padic_mat_t B, const padic_mat_t A, const fmpz_t c, const padic_ctx_t ctx) + void _padic_mat_scalar_mul_fmpz(padic_mat_t B, const padic_mat_t A, const fmpz_t c, const padic_ctx_t ctx) noexcept # Sets `B` to `c A`, ensuring that the result is in canonical form. - void padic_mat_scalar_mul_fmpz(padic_mat_t B, const padic_mat_t A, const fmpz_t c, const padic_ctx_t ctx) + void padic_mat_scalar_mul_fmpz(padic_mat_t B, const padic_mat_t A, const fmpz_t c, const padic_ctx_t ctx) noexcept # Sets `B` to `c A`, ensuring that the result is reduced. - void padic_mat_scalar_div_fmpz(padic_mat_t B, const padic_mat_t A, const fmpz_t c, const padic_ctx_t ctx) + void padic_mat_scalar_div_fmpz(padic_mat_t B, const padic_mat_t A, const fmpz_t c, const padic_ctx_t ctx) noexcept # Sets `B` to `c^{-1} A`, assuming that `c \neq 0`. # Ensures that the result `B` is reduced. - void _padic_mat_mul(padic_mat_t C, const padic_mat_t A, const padic_mat_t B, const padic_ctx_t ctx) + void _padic_mat_mul(padic_mat_t C, const padic_mat_t A, const padic_mat_t B, const padic_ctx_t ctx) noexcept # Sets `C` to the product `A B` of the two matrices `A` and `B`, # ensuring that `C` is in canonical form. - void padic_mat_mul(padic_mat_t C, const padic_mat_t A, const padic_mat_t B, const padic_ctx_t ctx) + void padic_mat_mul(padic_mat_t C, const padic_mat_t A, const padic_mat_t B, const padic_ctx_t ctx) noexcept # Sets `C` to the product `A B` of the two matrices `A` and `B`, # ensuring that `C` is reduced. diff --git a/src/sage/libs/flint/padic_poly.pxd b/src/sage/libs/flint/padic_poly.pxd index 37cf4d0435e..b50b49c9ddf 100644 --- a/src/sage/libs/flint/padic_poly.pxd +++ b/src/sage/libs/flint/padic_poly.pxd @@ -12,25 +12,25 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void padic_poly_init(padic_poly_t poly) + void padic_poly_init(padic_poly_t poly) noexcept # Initialises ``poly`` for use, setting its length to zero. # The precision of the polynomial is set to ``PADIC_DEFAULT_PREC``. # A corresponding call to :func:`padic_poly_clear` must be made # after finishing with the :type:`padic_poly_t` to free the memory # used by the polynomial. - void padic_poly_init2(padic_poly_t poly, slong alloc, slong prec) + void padic_poly_init2(padic_poly_t poly, slong alloc, slong prec) noexcept # Initialises ``poly`` with space for at least ``alloc`` coefficients # and sets the length to zero. The allocated coefficients are all set to # zero. The precision is set to ``prec``. - void padic_poly_realloc(padic_poly_t poly, slong alloc, const fmpz_t p) + void padic_poly_realloc(padic_poly_t poly, slong alloc, const fmpz_t p) noexcept # Reallocates the given polynomial to have space for ``alloc`` # coefficients. If ``alloc`` is zero the polynomial is cleared # and then reinitialised. If the current length is greater than # ``alloc`` the polynomial is first truncated to length ``alloc``. - void padic_poly_fit_length(padic_poly_t poly, slong len) + void padic_poly_fit_length(padic_poly_t poly, slong len) noexcept # If ``len`` is greater than the number of coefficients currently # allocated, then the polynomial is reallocated to have space for at # least ``len`` coefficients. No data is lost when calling this @@ -40,41 +40,41 @@ cdef extern from "flint_wrap.h": # of allocated coefficients when length is larger than the number of # coefficients currently allocated. - void _padic_poly_set_length(padic_poly_t poly, slong len) + void _padic_poly_set_length(padic_poly_t poly, slong len) noexcept # Demotes the coefficients of ``poly`` beyond ``len`` and sets # the length of ``poly`` to ``len``. # Note that if the current length is greater than ``len`` the # polynomial may no slonger be in canonical form. - void padic_poly_clear(padic_poly_t poly) + void padic_poly_clear(padic_poly_t poly) noexcept # Clears the given polynomial, releasing any memory used. It must # be reinitialised in order to be used again. - void _padic_poly_normalise(padic_poly_t poly) + void _padic_poly_normalise(padic_poly_t poly) noexcept # Sets the length of ``poly`` so that the top coefficient is non-zero. # If all coefficients are zero, the length is set to zero. This function # is mainly used internally, as all functions guarantee normalisation. - void _padic_poly_canonicalise(fmpz *poly, slong *v, slong len, const fmpz_t p) - void padic_poly_canonicalise(padic_poly_t poly, const fmpz_t p) + void _padic_poly_canonicalise(fmpz *poly, slong *v, slong len, const fmpz_t p) noexcept + void padic_poly_canonicalise(padic_poly_t poly, const fmpz_t p) noexcept # Brings the polynomial ``poly`` into canonical form, # assuming that it is normalised already. Does *not* # carry out any reduction. - void padic_poly_reduce(padic_poly_t poly, const padic_ctx_t ctx) + void padic_poly_reduce(padic_poly_t poly, const padic_ctx_t ctx) noexcept # Reduces the polynomial ``poly`` modulo `p^N`, assuming # that it is in canonical form already. - void padic_poly_truncate(padic_poly_t poly, slong n, const fmpz_t p) + void padic_poly_truncate(padic_poly_t poly, slong n, const fmpz_t p) noexcept # Truncates the polynomial to length at most~`n`. - slong padic_poly_degree(const padic_poly_t poly) + slong padic_poly_degree(const padic_poly_t poly) noexcept # Returns the degree of the polynomial ``poly``. - slong padic_poly_length(const padic_poly_t poly) + slong padic_poly_length(const padic_poly_t poly) noexcept # Returns the length of the polynomial ``poly``. - slong padic_poly_val(const padic_poly_t poly) + slong padic_poly_val(const padic_poly_t poly) noexcept # Returns the valuation of the polynomial ``poly``, # which is defined to be the minimum valuation of all # its coefficients. @@ -82,22 +82,22 @@ cdef extern from "flint_wrap.h": # Note that this is implemented as a macro and can be # used as either a ``lvalue`` or a ``rvalue``. - slong padic_poly_prec(padic_poly_t poly) + slong padic_poly_prec(padic_poly_t poly) noexcept # Returns the precision of the polynomial ``poly``. # Note that this is implemented as a macro and can be # used as either a ``lvalue`` or a ``rvalue``. # Note that increasing the precision might require # a call to :func:`padic_poly_reduce`. - void padic_poly_randtest(padic_poly_t f, flint_rand_t state, slong len, const padic_ctx_t ctx) + void padic_poly_randtest(padic_poly_t f, flint_rand_t state, slong len, const padic_ctx_t ctx) noexcept # Sets `f` to a random polynomial of length at most ``len`` # with entries reduced modulo `p^N`. - void padic_poly_randtest_not_zero(padic_poly_t f, flint_rand_t state, slong len, const padic_ctx_t ctx) + void padic_poly_randtest_not_zero(padic_poly_t f, flint_rand_t state, slong len, const padic_ctx_t ctx) noexcept # Sets `f` to a non-zero random polynomial of length at most ``len`` # with entries reduced modulo `p^N`. - void padic_poly_randtest_val(padic_poly_t f, flint_rand_t state, slong val, slong len, const padic_ctx_t ctx) + void padic_poly_randtest_val(padic_poly_t f, flint_rand_t state, slong val, slong len, const padic_ctx_t ctx) noexcept # Sets `f` to a random polynomial of length at most ``len`` # with at most the prescribed valuation ``val`` and entries # reduced modulo `p^N`. @@ -105,82 +105,82 @@ cdef extern from "flint_wrap.h": # to ``val``, but do not check for additional cancellation # when creating the coefficients. - void padic_poly_set_padic(padic_poly_t poly, const padic_t x, const padic_ctx_t ctx) + void padic_poly_set_padic(padic_poly_t poly, const padic_t x, const padic_ctx_t ctx) noexcept # Sets the polynomial ``poly`` to the `p`-adic number `x`, # reduced to the precision of the polynomial. - void padic_poly_set(padic_poly_t poly1, const padic_poly_t poly2, const padic_ctx_t ctx) + void padic_poly_set(padic_poly_t poly1, const padic_poly_t poly2, const padic_ctx_t ctx) noexcept # Sets the polynomial ``poly1`` to the polynomial ``poly2``, # reduced to the precision of ``poly1``. - void padic_poly_set_si(padic_poly_t poly, slong x, const padic_ctx_t ctx) + void padic_poly_set_si(padic_poly_t poly, slong x, const padic_ctx_t ctx) noexcept # Sets the polynomial ``poly`` to the ``signed slong`` # integer `x` reduced to the precision of the polynomial. - void padic_poly_set_ui(padic_poly_t poly, ulong x, const padic_ctx_t ctx) + void padic_poly_set_ui(padic_poly_t poly, ulong x, const padic_ctx_t ctx) noexcept # Sets the polynomial ``poly`` to the ``unsigned slong`` # integer `x` reduced to the precision of the polynomial. - void padic_poly_set_fmpz(padic_poly_t poly, const fmpz_t x, const padic_ctx_t ctx) + void padic_poly_set_fmpz(padic_poly_t poly, const fmpz_t x, const padic_ctx_t ctx) noexcept # Sets the polynomial ``poly`` to the integer `x` # reduced to the precision of the polynomial. - void padic_poly_set_fmpq(padic_poly_t poly, const fmpq_t x, const padic_ctx_t ctx) + void padic_poly_set_fmpq(padic_poly_t poly, const fmpq_t x, const padic_ctx_t ctx) noexcept # Sets the polynomial ``poly`` to the value of the rational `x`, # reduced to the precision of the polynomial. - void padic_poly_set_fmpz_poly(padic_poly_t rop, const fmpz_poly_t op, const padic_ctx_t ctx) + void padic_poly_set_fmpz_poly(padic_poly_t rop, const fmpz_poly_t op, const padic_ctx_t ctx) noexcept # Sets the polynomial ``rop`` to the integer polynomial ``op`` # reduced to the precision of the polynomial. - void padic_poly_set_fmpq_poly(padic_poly_t rop, const fmpq_poly_t op, const padic_ctx_t ctx) + void padic_poly_set_fmpq_poly(padic_poly_t rop, const fmpq_poly_t op, const padic_ctx_t ctx) noexcept # Sets the polynomial ``rop`` to the value of the rational # polynomial ``op``, reduced to the precision of the polynomial. - int padic_poly_get_fmpz_poly(fmpz_poly_t rop, const padic_poly_t op, const padic_ctx_t ctx) + int padic_poly_get_fmpz_poly(fmpz_poly_t rop, const padic_poly_t op, const padic_ctx_t ctx) noexcept # Sets the integer polynomial ``rop`` to the value of the `p`-adic # polynomial ``op`` and returns `1` if the polynomial is `p`-adically # integral. Otherwise, returns `0`. - void padic_poly_get_fmpq_poly(fmpq_poly_t rop, const padic_poly_t op, const padic_ctx_t ctx) + void padic_poly_get_fmpq_poly(fmpq_poly_t rop, const padic_poly_t op, const padic_ctx_t ctx) noexcept # Sets ``rop`` to the rational polynomial corresponding to # the `p`-adic polynomial ``op``. - void padic_poly_zero(padic_poly_t poly) + void padic_poly_zero(padic_poly_t poly) noexcept # Sets ``poly`` to the zero polynomial. - void padic_poly_one(padic_poly_t poly) + void padic_poly_one(padic_poly_t poly) noexcept # Sets ``poly`` to the constant polynomial `1`, # reduced to the precision of the polynomial. - void padic_poly_swap(padic_poly_t poly1, padic_poly_t poly2) + void padic_poly_swap(padic_poly_t poly1, padic_poly_t poly2) noexcept # Swaps the two polynomials ``poly1`` and ``poly2``, # including their precisions. # This is done efficiently by swapping pointers. - void padic_poly_get_coeff_padic(padic_t c, const padic_poly_t poly, slong n, const padic_ctx_t ctx) + void padic_poly_get_coeff_padic(padic_t c, const padic_poly_t poly, slong n, const padic_ctx_t ctx) noexcept # Sets `c` to the coefficient of `x^n` in the polynomial, # reduced modulo the precision of `c`. - void padic_poly_set_coeff_padic(padic_poly_t f, slong n, const padic_t c, const padic_ctx_t ctx) + void padic_poly_set_coeff_padic(padic_poly_t f, slong n, const padic_t c, const padic_ctx_t ctx) noexcept # Sets the coefficient of `x^n` in the polynomial `f` to `c`, # reduced to the precision of the polynomial `f`. # Note that this operation can take linear time in the length # of the polynomial. - bint padic_poly_equal(const padic_poly_t poly1, const padic_poly_t poly2) + bint padic_poly_equal(const padic_poly_t poly1, const padic_poly_t poly2) noexcept # Returns whether the two polynomials ``poly1`` and ``poly2`` # are equal. - bint padic_poly_is_zero(const padic_poly_t poly) + bint padic_poly_is_zero(const padic_poly_t poly) noexcept # Returns whether the polynomial ``poly`` is the zero polynomial. - bint padic_poly_is_one(const padic_poly_t poly) + bint padic_poly_is_one(const padic_poly_t poly) noexcept # Returns whether the polynomial ``poly`` is equal # to the constant polynomial~`1`, taking the precision # of the polynomial into account. - void _padic_poly_add(fmpz *rop, slong *rval, slong N, const fmpz *op1, slong val1, slong len1, slong N1, const fmpz *op2, slong val2, slong len2, slong N2, const padic_ctx_t ctx) + void _padic_poly_add(fmpz *rop, slong *rval, slong N, const fmpz *op1, slong val1, slong len1, slong N1, const fmpz *op2, slong val2, slong len2, slong N2, const padic_ctx_t ctx) noexcept # Sets ``(rop, *val, FLINT_MAX(len1, len2)`` to the sum of # ``(op1, val1, len1)`` and ``(op2, val2, len2)``. # Assumes that the input is reduced and guarantees that this is @@ -188,10 +188,10 @@ cdef extern from "flint_wrap.h": # Assumes that `\min\{v_1, v_2\} < N`. # Supports aliasing between the output and input arguments. - void padic_poly_add(padic_poly_t f, const padic_poly_t g, const padic_poly_t h, const padic_ctx_t ctx) + void padic_poly_add(padic_poly_t f, const padic_poly_t g, const padic_poly_t h, const padic_ctx_t ctx) noexcept # Sets `f` to the sum `g + h`. - void _padic_poly_sub(fmpz *rop, slong *rval, slong N, const fmpz *op1, slong val1, slong len1, slong N1, const fmpz *op2, slong val2, slong len2, slong N2, const padic_ctx_t ctx) + void _padic_poly_sub(fmpz *rop, slong *rval, slong N, const fmpz *op1, slong val1, slong len1, slong N1, const fmpz *op2, slong val2, slong len2, slong N2, const padic_ctx_t ctx) noexcept # Sets ``(rop, *val, FLINT_MAX(len1, len2)`` to the difference of # ``(op1, val1, len1)`` and ``(op2, val2, len2)``. # Assumes that the input is reduced and guarantees that this is @@ -199,25 +199,25 @@ cdef extern from "flint_wrap.h": # Assumes that `\min\{v_1, v_2\} < N`. # Support aliasing between the output and input arguments. - void padic_poly_sub(padic_poly_t f, const padic_poly_t g, const padic_poly_t h, const padic_ctx_t ctx) + void padic_poly_sub(padic_poly_t f, const padic_poly_t g, const padic_poly_t h, const padic_ctx_t ctx) noexcept # Sets `f` to the difference `g - h`. - void padic_poly_neg(padic_poly_t f, const padic_poly_t g, const padic_ctx_t ctx) + void padic_poly_neg(padic_poly_t f, const padic_poly_t g, const padic_ctx_t ctx) noexcept # Sets `f` to `-g`. - void _padic_poly_scalar_mul_padic(fmpz *rop, slong *rval, slong N, const fmpz *op, slong val, slong len, const padic_t c, const padic_ctx_t ctx) + void _padic_poly_scalar_mul_padic(fmpz *rop, slong *rval, slong N, const fmpz *op, slong val, slong len, const padic_t c, const padic_ctx_t ctx) noexcept # Sets ``(rop, *rval, len)`` to ``(op, val, len)`` multiplied # by the scalar `c`. # The result will only be correctly reduced if the polynomial # is non-zero. Otherwise, the array ``(rop, len)`` will be # set to zero but the valuation ``*rval`` might be wrong. - void padic_poly_scalar_mul_padic(padic_poly_t rop, const padic_poly_t op, const padic_t c, const padic_ctx_t ctx) + void padic_poly_scalar_mul_padic(padic_poly_t rop, const padic_poly_t op, const padic_t c, const padic_ctx_t ctx) noexcept # Sets the polynomial ``rop`` to the product of the # polynomial ``op`` and the `p`-adic number `c`, # reducing the result modulo `p^N`. - void _padic_poly_mul(fmpz *rop, slong *rval, slong N, const fmpz *op1, slong val1, slong len1, const fmpz *op2, slong val2, slong len2, const padic_ctx_t ctx) + void _padic_poly_mul(fmpz *rop, slong *rval, slong N, const fmpz *op1, slong val1, slong len1, const fmpz *op2, slong val2, slong len2, const padic_ctx_t ctx) noexcept # Sets ``(rop, *rval, len1 + len2 - 1)`` to the product of # ``(op1, val1, len1)`` and ``(op2, val2, len2)``. # Assumes that the resulting valuation ``*rval``, which is @@ -225,17 +225,17 @@ cdef extern from "flint_wrap.h": # than the precision~`N` of the context. # Assumes that ``len1 >= len2 > 0``. - void padic_poly_mul(padic_poly_t res, const padic_poly_t poly1, const padic_poly_t poly2, const padic_ctx_t ctx) + void padic_poly_mul(padic_poly_t res, const padic_poly_t poly1, const padic_poly_t poly2, const padic_ctx_t ctx) noexcept # Sets the polynomial ``res`` to the product of the two polynomials # ``poly1`` and ``poly2``, reduced modulo `p^N`. - void _padic_poly_pow(fmpz *rop, slong *rval, slong N, const fmpz *op, slong val, slong len, ulong e, const padic_ctx_t ctx) + void _padic_poly_pow(fmpz *rop, slong *rval, slong N, const fmpz *op, slong val, slong len, ulong e, const padic_ctx_t ctx) noexcept # Sets the polynomial ``(rop, *rval, e (len - 1) + 1)`` to the # polynomial ``(op, val, len)`` raised to the power~`e`. # Assumes that `e > 1` and ``len > 0``. # Does not support aliasing between the input and output arguments. - void padic_poly_pow(padic_poly_t rop, const padic_poly_t op, ulong e, const padic_ctx_t ctx) + void padic_poly_pow(padic_poly_t rop, const padic_poly_t op, ulong e, const padic_ctx_t ctx) noexcept # Sets the polynomial ``rop`` to the polynomial ``op`` raised # to the power~`e`, reduced to the precision in ``rop``. # In the special case `e = 0`, sets ``rop`` to the constant @@ -248,7 +248,7 @@ cdef extern from "flint_wrap.h": # has valuation~`v < 0`. The result then has valuation # `e v < 0` but is only correct to precision `N + (e - 1) v`. - void padic_poly_inv_series(padic_poly_t g, const padic_poly_t f, slong n, const padic_ctx_t ctx) + void padic_poly_inv_series(padic_poly_t g, const padic_poly_t f, slong n, const padic_ctx_t ctx) noexcept # Computes the power series inverse `g` of `f` modulo `X^n`, # where `n \geq 1`. # Given the polynomial `f \in \mathbf{Q}[X] \subset \mathbf{Q}_p[X]`, @@ -260,26 +260,26 @@ cdef extern from "flint_wrap.h": # of `f` is minimal among the coefficients of `f`. # Note that the result `g` is zero if and only if `- \operatorname{ord}_p(f) \geq N`. - void _padic_poly_derivative(fmpz *rop, slong *rval, slong N, const fmpz *op, slong val, slong len, const padic_ctx_t ctx) + void _padic_poly_derivative(fmpz *rop, slong *rval, slong N, const fmpz *op, slong val, slong len, const padic_ctx_t ctx) noexcept # Sets ``(rop, rval)`` to the derivative of ``(op, val)`` reduced # modulo `p^N`. # Supports aliasing of the input and the output parameters. - void padic_poly_derivative(padic_poly_t rop, const padic_poly_t op, const padic_ctx_t ctx) + void padic_poly_derivative(padic_poly_t rop, const padic_poly_t op, const padic_ctx_t ctx) noexcept # Sets ``rop`` to the derivative of ``op``, reducing the # result modulo the precision of ``rop``. - void padic_poly_shift_left(padic_poly_t rop, const padic_poly_t op, slong n, const padic_ctx_t ctx) + void padic_poly_shift_left(padic_poly_t rop, const padic_poly_t op, slong n, const padic_ctx_t ctx) noexcept # Notationally, sets the polynomial ``rop`` to the polynomial ``op`` # multiplied by `x^n`, where `n \geq 0`, and reduces the result. - void padic_poly_shift_right(padic_poly_t rop, const padic_poly_t op, slong n, const padic_ctx_t ctx) + void padic_poly_shift_right(padic_poly_t rop, const padic_poly_t op, slong n, const padic_ctx_t ctx) noexcept # Notationally, sets the polynomial ``rop`` to the polynomial # ``op`` after floor division by `x^n`, where `n \geq 0`, ensuring # the result is reduced. - void _padic_poly_evaluate_padic(fmpz_t u, slong *v, slong N, const fmpz *poly, slong val, slong len, const fmpz_t a, slong b, const padic_ctx_t ctx) - void padic_poly_evaluate_padic(padic_t y, const padic_poly_t poly, const padic_t a, const padic_ctx_t ctx) + void _padic_poly_evaluate_padic(fmpz_t u, slong *v, slong N, const fmpz *poly, slong val, slong len, const fmpz_t a, slong b, const padic_ctx_t ctx) noexcept + void padic_poly_evaluate_padic(padic_t y, const padic_poly_t poly, const padic_t a, const padic_ctx_t ctx) noexcept # Sets the `p`-adic number ``y`` to ``poly`` evaluated at `a`, # reduced in the given context. # Suppose that the polynomial can be written as `F(X) = p^w f(X)` @@ -290,37 +290,37 @@ cdef extern from "flint_wrap.h": # `y = F(a)` is defined to precision `N` when `a` is integral and # `N+(n-1)b` when `b < 0`. - void _padic_poly_compose(fmpz *rop, slong *rval, slong N, const fmpz *op1, slong val1, slong len1, const fmpz *op2, slong val2, slong len2, const padic_ctx_t ctx) + void _padic_poly_compose(fmpz *rop, slong *rval, slong N, const fmpz *op1, slong val1, slong len1, const fmpz *op2, slong val2, slong len2, const padic_ctx_t ctx) noexcept # Sets ``(rop, *rval, (len1-1)*(len2-1)+1)`` to the composition # of the two input polynomials, reducing the result modulo `p^N`. # Assumes that ``len1`` is non-zero. # Does not support aliasing. - void padic_poly_compose(padic_poly_t rop, const padic_poly_t op1, const padic_poly_t op2, const padic_ctx_t ctx) + void padic_poly_compose(padic_poly_t rop, const padic_poly_t op1, const padic_poly_t op2, const padic_ctx_t ctx) noexcept # Sets ``rop`` to the composition of ``op1`` and ``op2``, # reducing the result in the given context. # To be clear about the order of composition, let `f(X)` and `g(X)` # denote the polynomials ``op1`` and ``op2``, respectively. # Then ``rop`` is set to `f(g(X))`. - void _padic_poly_compose_pow(fmpz *rop, slong *rval, slong N, const fmpz *op, slong val, slong len, slong k, const padic_ctx_t ctx) + void _padic_poly_compose_pow(fmpz *rop, slong *rval, slong N, const fmpz *op, slong val, slong len, slong k, const padic_ctx_t ctx) noexcept # Sets ``(rop, *rval, (len - 1)*k + 1)`` to the composition of # ``(op, val, len)`` and the monomial `x^k`, where `k \geq 1`. # Assumes that ``len`` is positive. # Supports aliasing between the input and output polynomials. - void padic_poly_compose_pow(padic_poly_t rop, const padic_poly_t op, slong k, const padic_ctx_t ctx) + void padic_poly_compose_pow(padic_poly_t rop, const padic_poly_t op, slong k, const padic_ctx_t ctx) noexcept # Sets ``rop`` to the composition of ``op`` and the monomial `x^k`, # where `k \geq 1`. # Note that no reduction takes place. - int padic_poly_debug(const padic_poly_t poly) + int padic_poly_debug(const padic_poly_t poly) noexcept # Prints the data defining the `p`-adic polynomial ``poly`` # in a simple format useful for debugging purposes. # In the current implementation, always returns `1`. - int _padic_poly_fprint(FILE *file, const fmpz *poly, slong val, slong len, const padic_ctx_t ctx) - int padic_poly_fprint(FILE *file, const padic_poly_t poly, const padic_ctx_t ctx) + int _padic_poly_fprint(FILE *file, const fmpz *poly, slong val, slong len, const padic_ctx_t ctx) noexcept + int padic_poly_fprint(FILE *file, const padic_poly_t poly, const padic_ctx_t ctx) noexcept # Prints a simple representation of the polynomial ``poly`` # to the stream ``file``. # A non-zero polynomial is represented by the number of coefficients, @@ -335,18 +335,18 @@ cdef extern from "flint_wrap.h": # The zero polynomial is represented by ``"0"``. # In the current implementation, always returns `1`. - int _padic_poly_print(const fmpz *poly, slong val, slong len, const padic_ctx_t ctx) - int padic_poly_print(const padic_poly_t poly, const padic_ctx_t ctx) + int _padic_poly_print(const fmpz *poly, slong val, slong len, const padic_ctx_t ctx) noexcept + int padic_poly_print(const padic_poly_t poly, const padic_ctx_t ctx) noexcept # Prints a simple representation of the polynomial ``poly`` # to ``stdout``. # In the current implementation, always returns `1`. - int _padic_poly_fprint_pretty(FILE *file, const fmpz *poly, slong val, slong len, const char *var, const padic_ctx_t ctx) - int padic_poly_fprint_pretty(FILE *file, const padic_poly_t poly, const char *var, const padic_ctx_t ctx) - int _padic_poly_print_pretty(const fmpz *poly, slong val, slong len, const char *var, const padic_ctx_t ctx) - int padic_poly_print_pretty(const padic_poly_t poly, const char *var, const padic_ctx_t ctx) + int _padic_poly_fprint_pretty(FILE *file, const fmpz *poly, slong val, slong len, const char *var, const padic_ctx_t ctx) noexcept + int padic_poly_fprint_pretty(FILE *file, const padic_poly_t poly, const char *var, const padic_ctx_t ctx) noexcept + int _padic_poly_print_pretty(const fmpz *poly, slong val, slong len, const char *var, const padic_ctx_t ctx) noexcept + int padic_poly_print_pretty(const padic_poly_t poly, const char *var, const padic_ctx_t ctx) noexcept - bint _padic_poly_is_canonical(const fmpz *op, slong val, slong len, const padic_ctx_t ctx) - bint padic_poly_is_canonical(const padic_poly_t op, const padic_ctx_t ctx) - bint _padic_poly_is_reduced(const fmpz *op, slong val, slong len, slong N, const padic_ctx_t ctx) - bint padic_poly_is_reduced(const padic_poly_t op, const padic_ctx_t ctx) + bint _padic_poly_is_canonical(const fmpz *op, slong val, slong len, const padic_ctx_t ctx) noexcept + bint padic_poly_is_canonical(const padic_poly_t op, const padic_ctx_t ctx) noexcept + bint _padic_poly_is_reduced(const fmpz *op, slong val, slong len, slong N, const padic_ctx_t ctx) noexcept + bint padic_poly_is_reduced(const padic_poly_t op, const padic_ctx_t ctx) noexcept diff --git a/src/sage/libs/flint/partitions.pxd b/src/sage/libs/flint/partitions.pxd index 044fa3c584b..b930b5da26a 100644 --- a/src/sage/libs/flint/partitions.pxd +++ b/src/sage/libs/flint/partitions.pxd @@ -12,7 +12,7 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void partitions_rademacher_bound(arf_t b, const fmpz_t n, ulong N) + void partitions_rademacher_bound(arf_t b, const fmpz_t n, ulong N) noexcept # Sets `b` to an upper bound for # .. math :: # M(n,N) = \frac{44 \pi^2}{225 \sqrt 3} N^{-1/2} @@ -22,7 +22,7 @@ cdef extern from "flint_wrap.h": # Hardy-Ramanujan-Rademacher formula when the series is taken up # to the term `t(n,N)` inclusive. - void partitions_hrr_sum_arb(arb_t x, const fmpz_t n, slong N0, slong N, int use_doubles) + void partitions_hrr_sum_arb(arb_t x, const fmpz_t n, slong N0, slong N, int use_doubles) noexcept # Evaluates the partial sum `\sum_{k=N_0}^N t(n,k)` of the # Hardy-Ramanujan-Rademacher series. # If *use_doubles* is nonzero, doubles and the system's standard library math @@ -34,7 +34,7 @@ cdef extern from "flint_wrap.h": # safe. Setting *use_doubles* to zero gives a fully guaranteed # bound. - void partitions_fmpz_fmpz(fmpz_t p, const fmpz_t n, int use_doubles) + void partitions_fmpz_fmpz(fmpz_t p, const fmpz_t n, int use_doubles) noexcept # Computes the partition function `p(n)` using the Hardy-Ramanujan-Rademacher # formula. This function computes a numerical ball containing `p(n)` # and verifies that the ball contains a unique integer. @@ -44,18 +44,18 @@ cdef extern from "flint_wrap.h": # See :func:`partitions_hrr_sum_arb` for an explanation of the # *use_doubles* option. - void partitions_fmpz_ui(fmpz_t p, ulong n) + void partitions_fmpz_ui(fmpz_t p, ulong n) noexcept # Computes the partition function `p(n)` using the Hardy-Ramanujan-Rademacher # formula. This function computes a numerical ball containing `p(n)` # and verifies that the ball contains a unique integer. - void partitions_fmpz_ui_using_doubles(fmpz_t p, ulong n) + void partitions_fmpz_ui_using_doubles(fmpz_t p, ulong n) noexcept # Computes the partition function `p(n)`, enabling the use of doubles # internally. This significantly speeds up evaluation for small `n` # (e.g. `n < 10^6`), but the error bounds are not certified # (see remarks for :func:`partitions_hrr_sum_arb`). - void partitions_leading_fmpz(arb_t res, const fmpz_t n, slong prec) + void partitions_leading_fmpz(arb_t res, const fmpz_t n, slong prec) noexcept # Sets *res* to the leading term in the Hardy-Ramanujan series # for `p(n)` (without Rademacher's correction of this term, which is # vanishingly small when `n` is large), that is, diff --git a/src/sage/libs/flint/perm.pxd b/src/sage/libs/flint/perm.pxd index c2216d70f85..a6c8a986a24 100644 --- a/src/sage/libs/flint/perm.pxd +++ b/src/sage/libs/flint/perm.pxd @@ -12,37 +12,37 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - slong * _perm_init(slong n) + slong * _perm_init(slong n) noexcept # Initialises the permutation for use. - void _perm_clear(slong *vec) + void _perm_clear(slong *vec) noexcept # Clears the permutation. - void _perm_set(slong *res, const slong *vec, slong n) + void _perm_set(slong *res, const slong *vec, slong n) noexcept # Sets the permutation ``res`` to the same as the permutation ``vec``. - void _perm_set_one(slong *vec, slong n) + void _perm_set_one(slong *vec, slong n) noexcept # Sets the permutation to the identity permutation. - void _perm_inv(slong *res, const slong *vec, slong n) + void _perm_inv(slong *res, const slong *vec, slong n) noexcept # Sets ``res`` to the inverse permutation of ``vec``. # Allows aliasing of ``res`` and ``vec``. - void _perm_compose(slong *res, const slong *vec1, const slong *vec2, slong n) + void _perm_compose(slong *res, const slong *vec1, const slong *vec2, slong n) noexcept # Forms the composition `\pi_1 \circ \pi_2` of two permutations # `\pi_1` and `\pi_2`. Here, `\pi_2` is applied first, that is, # `(\pi_1 \circ \pi_2)(i) = \pi_1(\pi_2(i))`. # Allows aliasing of ``res``, ``vec1`` and ``vec2``. - int _perm_parity(const slong *vec, slong n) + int _perm_parity(const slong *vec, slong n) noexcept # Returns the parity of ``vec``, 0 if the permutation is even and 1 if # the permutation is odd. - int _perm_randtest(slong *vec, slong n, flint_rand_t state) + int _perm_randtest(slong *vec, slong n, flint_rand_t state) noexcept # Generates a random permutation vector of length `n` and returns # its parity, 0 or 1. # This function uses the Knuth shuffle algorithm to generate a uniformly # random permutation without retries. - int _perm_print(const slong * vec, slong n) + int _perm_print(const slong * vec, slong n) noexcept # Prints the permutation vector of length `n` to ``stdout``. diff --git a/src/sage/libs/flint/profiler.pxd b/src/sage/libs/flint/profiler.pxd index 6738f843a3e..31824150e64 100644 --- a/src/sage/libs/flint/profiler.pxd +++ b/src/sage/libs/flint/profiler.pxd @@ -12,8 +12,8 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void timeit_start(timeit_t t) - void timeit_stop(timeit_t t) + void timeit_start(timeit_t t) noexcept + void timeit_stop(timeit_t t) noexcept # Gives wall and user time - useful for parallel programming. # Example usage:: # timeit_t t0; @@ -23,11 +23,11 @@ cdef extern from "flint_wrap.h": # timeit_stop(t0); # flint_printf("cpu = %wd ms wall = %wd ms\n", t0->cpu, t0->wall); - void start_clock(int n) + void start_clock(int n) noexcept - void stop_clock(int n) + void stop_clock(int n) noexcept - double get_clock(int n) + double get_clock(int n) noexcept # Gives time based on cycle counter. # First one must ensure the processor speed in cycles per second # is set correctly in ``profiler.h``, in the macro definition @@ -44,7 +44,7 @@ cdef extern from "flint_wrap.h": # clocks can be changed by altering ``FLINT_NUM_CLOCKS``. One can also # initialise an individual clock with ``init_clock(n)``. - void prof_repeat(double *min, double *max, profile_target_t target, void *arg) + void prof_repeat(double *min, double *max, profile_target_t target, void *arg) noexcept # Allows one to automatically time a given function. Here is a sample usage: # Suppose one has a function one wishes to profile:: # void myfunc(ulong a, ulong b); @@ -79,7 +79,7 @@ cdef extern from "flint_wrap.h": # adjusting ``DURATION_THRESHOLD`` and one may set a target duration # in microseconds by adjusting ``DURATION_TARGET`` in ``profiler.h``. - void get_memory_usage(meminfo_t meminfo) + void get_memory_usage(meminfo_t meminfo) noexcept # Obtains information about the memory usage of the current process. # The meminfo object contains the slots ``size`` (virtual memory size), # ``peak`` (peak virtual memory size), ``rss`` (resident set size), diff --git a/src/sage/libs/flint/qadic.pxd b/src/sage/libs/flint/qadic.pxd index 6d3cb1b50ad..6f11a693009 100644 --- a/src/sage/libs/flint/qadic.pxd +++ b/src/sage/libs/flint/qadic.pxd @@ -12,7 +12,7 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void qadic_ctx_init(qadic_ctx_t ctx, const fmpz_t p, slong d, slong min, slong max, const char *var, padic_print_mode mode) + void qadic_ctx_init(qadic_ctx_t ctx, const fmpz_t p, slong d, slong min, slong max, const char *var, padic_print_mode mode) noexcept # Initialises the context ``ctx`` with prime `p`, extension degree `d`, # variable name ``var`` and printing mode ``mode``. The defining polynomial # is chosen as a Conway polynomial if possible and otherwise as a random @@ -28,7 +28,7 @@ cdef extern from "flint_wrap.h": # arithmetic in `\mathbf{Q}_p / (p^N)` such as powers of `p` close # to `p^N`. - void qadic_ctx_init_conway(qadic_ctx_t ctx, const fmpz_t p, slong d, slong min, slong max, const char *var, padic_print_mode mode) + void qadic_ctx_init_conway(qadic_ctx_t ctx, const fmpz_t p, slong d, slong min, slong max, const char *var, padic_print_mode mode) noexcept # Initialises the context ``ctx`` with prime `p`, extension degree `d`, # variable name ``var`` and printing mode ``mode``. The defining polynomial # is chosen as a Conway polynomial, hence has restrictions on the @@ -44,26 +44,26 @@ cdef extern from "flint_wrap.h": # arithmetic in `\mathbf{Q}_p / (p^N)` such as powers of `p` close # to `p^N`. - void qadic_ctx_clear(qadic_ctx_t ctx) + void qadic_ctx_clear(qadic_ctx_t ctx) noexcept # Clears all memory that has been allocated as part of the context. - slong qadic_ctx_degree(const qadic_ctx_t ctx) + slong qadic_ctx_degree(const qadic_ctx_t ctx) noexcept # Returns the extension degree. - void qadic_ctx_print(const qadic_ctx_t ctx) + void qadic_ctx_print(const qadic_ctx_t ctx) noexcept # Prints the data from the given context. - void qadic_init(qadic_t rop) + void qadic_init(qadic_t rop) noexcept # Initialises the element ``rop``, setting its value to `0`. - void qadic_init2(qadic_t rop, slong prec) + void qadic_init2(qadic_t rop, slong prec) noexcept # Initialises the element ``rop`` with the given output precision, # setting the value to `0`. - void qadic_clear(qadic_t rop) + void qadic_clear(qadic_t rop) noexcept # Clears the element ``rop``. - void _fmpz_poly_reduce(fmpz *R, slong lenR, const fmpz *a, const slong *j, slong len) + void _fmpz_poly_reduce(fmpz *R, slong lenR, const fmpz *a, const slong *j, slong len) noexcept # Reduces a polynomial ``(R, lenR)`` modulo a sparse monic # polynomial `f(X) = \sum_{i} a_{i} X^{j_{i}}` of degree at # least `2`. @@ -71,7 +71,7 @@ cdef extern from "flint_wrap.h": # sorted in ascending order. # Allows zero-padding in ``(R, lenR)``. - void _fmpz_mod_poly_reduce(fmpz *R, slong lenR, const fmpz *a, const slong *j, slong len, const fmpz_t p) + void _fmpz_mod_poly_reduce(fmpz *R, slong lenR, const fmpz *a, const slong *j, slong len, const fmpz_t p) noexcept # Reduces a polynomial ``(R, lenR)`` modulo a sparse monic # polynomial `f(X) = \sum_{i} a_{i} X^{j_{i}}` of degree at # least `2` in `\mathbf{Z}/(p)`, where `p` is typically a prime @@ -80,83 +80,83 @@ cdef extern from "flint_wrap.h": # sorted in ascending order. # Allows zero-padding in ``(R, lenR)``. - void qadic_reduce(qadic_t rop, const qadic_ctx_t ctx) + void qadic_reduce(qadic_t rop, const qadic_ctx_t ctx) noexcept # Reduces ``rop`` modulo `f(X)` and `p^N`. - slong qadic_val(const qadic_t op) + slong qadic_val(const qadic_t op) noexcept # Returns the valuation of ``op``. - slong qadic_prec(const qadic_t op) + slong qadic_prec(const qadic_t op) noexcept # Returns the precision of ``op``. - void qadic_randtest(qadic_t rop, flint_rand_t state, const qadic_ctx_t ctx) + void qadic_randtest(qadic_t rop, flint_rand_t state, const qadic_ctx_t ctx) noexcept # Generates a random element of `\mathbf{Q}_q`. - void qadic_randtest_not_zero(qadic_t rop, flint_rand_t state, const qadic_ctx_t ctx) + void qadic_randtest_not_zero(qadic_t rop, flint_rand_t state, const qadic_ctx_t ctx) noexcept # Generates a random non-zero element of `\mathbf{Q}_q`. - void qadic_randtest_val(qadic_t rop, flint_rand_t state, slong v, const qadic_ctx_t ctx) + void qadic_randtest_val(qadic_t rop, flint_rand_t state, slong v, const qadic_ctx_t ctx) noexcept # Generates a random element of `\mathbf{Q}_q` with prescribed # valuation ``val``. # Note that if `v \geq N` then the element is necessarily zero. - void qadic_randtest_int(qadic_t rop, flint_rand_t state, const qadic_ctx_t ctx) + void qadic_randtest_int(qadic_t rop, flint_rand_t state, const qadic_ctx_t ctx) noexcept # Generates a random element of `\mathbf{Q}_q` with non-negative valuation. - void qadic_set(qadic_t rop, const qadic_t op, const qadic_ctx_t ctx) + void qadic_set(qadic_t rop, const qadic_t op, const qadic_ctx_t ctx) noexcept # Sets ``rop`` to ``op``. - void qadic_zero(qadic_t rop) + void qadic_zero(qadic_t rop) noexcept # Sets ``rop`` to zero. - void qadic_one(qadic_t rop) + void qadic_one(qadic_t rop) noexcept # Sets ``rop`` to one, reduced in the given context. # Note that if the precision `N` is non-positive then ``rop`` # is actually set to zero. - void qadic_gen(qadic_t rop, const qadic_ctx_t ctx) + void qadic_gen(qadic_t rop, const qadic_ctx_t ctx) noexcept # Sets ``rop`` to the generator `X` for the extension # when `N > 0`, and zero otherwise. If the extension degree # is one, raises an abort signal. - void qadic_set_ui(qadic_t rop, ulong op, const qadic_ctx_t ctx) + void qadic_set_ui(qadic_t rop, ulong op, const qadic_ctx_t ctx) noexcept # Sets ``rop`` to the integer ``op``, reduced in the # context. - int qadic_get_padic(padic_t rop, const qadic_t op, const qadic_ctx_t ctx) + int qadic_get_padic(padic_t rop, const qadic_t op, const qadic_ctx_t ctx) noexcept # If the element ``op`` lies in `\mathbf{Q}_p`, sets ``rop`` # to its value and returns `1`; otherwise, returns `0`. - bint qadic_is_zero(const qadic_t op) + bint qadic_is_zero(const qadic_t op) noexcept # Returns whether ``op`` is equal to zero. - bint qadic_is_one(const qadic_t op) + bint qadic_is_one(const qadic_t op) noexcept # Returns whether ``op`` is equal to one in the given # context. - bint qadic_equal(const qadic_t op1, const qadic_t op2) + bint qadic_equal(const qadic_t op1, const qadic_t op2) noexcept # Returns whether ``op1`` and ``op2`` are equal. - void qadic_add(qadic_t rop, const qadic_t op1, const qadic_t op2, const qadic_ctx_t ctx) + void qadic_add(qadic_t rop, const qadic_t op1, const qadic_t op2, const qadic_ctx_t ctx) noexcept # Sets ``rop`` to the sum of ``op1`` and ``op2``. # Assumes that both ``op1`` and ``op2`` are reduced in the # given context and ensures that ``rop`` is, too. - void qadic_sub(qadic_t rop, const qadic_t op1, const qadic_t op2, const qadic_ctx_t ctx) + void qadic_sub(qadic_t rop, const qadic_t op1, const qadic_t op2, const qadic_ctx_t ctx) noexcept # Sets ``rop`` to the difference of ``op1`` and ``op2``. # Assumes that both ``op1`` and ``op2`` are reduced in the # given context and ensures that ``rop`` is, too. - void qadic_neg(qadic_t rop, const qadic_t op, const qadic_ctx_t ctx) + void qadic_neg(qadic_t rop, const qadic_t op, const qadic_ctx_t ctx) noexcept # Sets ``rop`` to the negative of ``op``. # Assumes that ``op`` is reduced in the given context and # ensures that ``rop`` is, too. - void qadic_mul(qadic_t rop, const qadic_t op1, const qadic_t op2, const qadic_ctx_t ctx) + void qadic_mul(qadic_t rop, const qadic_t op1, const qadic_t op2, const qadic_ctx_t ctx) noexcept # Sets ``rop`` to the product of ``op1`` and ``op2``, # reducing the output in the given context. - void _qadic_inv(fmpz *rop, const fmpz *op, slong len, const fmpz *a, const slong *j, slong lena, const fmpz_t p, slong N) + void _qadic_inv(fmpz *rop, const fmpz *op, slong len, const fmpz *a, const slong *j, slong lena, const fmpz_t p, slong N) noexcept # Sets ``(rop, d)`` to the inverse of ``(op, len)`` # modulo `f(X)` given by ``(a,j,lena)`` and `p^N`. # Assumes that ``(op,len)`` has valuation `0`, that is, @@ -164,10 +164,10 @@ cdef extern from "flint_wrap.h": # Assumes that ``len`` is at most `d`. # Does not support aliasing. - void qadic_inv(qadic_t rop, const qadic_t op, const qadic_ctx_t ctx) + void qadic_inv(qadic_t rop, const qadic_t op, const qadic_ctx_t ctx) noexcept # Sets ``rop`` to the inverse of ``op``, reduced in the given context. - void _qadic_pow(fmpz *rop, const fmpz *op, slong len, const fmpz_t e, const fmpz *a, const slong *j, slong lena, const fmpz_t p) + void _qadic_pow(fmpz *rop, const fmpz *op, slong len, const fmpz_t e, const fmpz *a, const slong *j, slong lena, const fmpz_t p) noexcept # Sets ``(rop, 2*d-1)`` to ``(op,len)`` raised to the power `e`, # reduced modulo `f(X)` given by ``(a, j, lena)`` and `p`, which # is expected to be a prime power. @@ -177,53 +177,53 @@ cdef extern from "flint_wrap.h": # `f(X)`, which is a polynomial of degree `d`. # Does not support aliasing. - void qadic_pow(qadic_t rop, const qadic_t op, const fmpz_t e, const qadic_ctx_t ctx) + void qadic_pow(qadic_t rop, const qadic_t op, const fmpz_t e, const qadic_ctx_t ctx) noexcept # Sets ``rop`` the ``op`` raised to the power `e`. # Currently assumes that `e \geq 0`. # Note that for any input ``op``, ``rop`` is set to one in the # given context whenever `e = 0`. - int qadic_sqrt(qadic_t rop, const qadic_t op, const qadic_ctx_t ctx) + int qadic_sqrt(qadic_t rop, const qadic_t op, const qadic_ctx_t ctx) noexcept # Return ``1`` if the input is a square (to input precision). If so, set # ``rop`` to a square root (truncated to output precision). - void _qadic_exp_rectangular(fmpz *rop, const fmpz *op, slong v, slong len, const fmpz *a, const slong *j, slong lena, const fmpz_t p, slong N, const fmpz_t pN) + void _qadic_exp_rectangular(fmpz *rop, const fmpz *op, slong v, slong len, const fmpz *a, const slong *j, slong lena, const fmpz_t p, slong N, const fmpz_t pN) noexcept # Sets ``(rop, 2*d - 1)`` to the exponential of ``(op, v, len)`` # reduced modulo `p^N`, assuming that the series converges. # Assumes that ``(op, v, len)`` is non-zero. # Does not support aliasing. - int qadic_exp_rectangular(qadic_t rop, const qadic_t op, const qadic_ctx_t ctx) + int qadic_exp_rectangular(qadic_t rop, const qadic_t op, const qadic_ctx_t ctx) noexcept # Returns whether the exponential series converges at ``op`` # and sets ``rop`` to its value reduced modulo in the given # context. - void _qadic_exp_balanced(fmpz *rop, const fmpz *x, slong v, slong len, const fmpz *a, const slong *j, slong lena, const fmpz_t p, slong N, const fmpz_t pN) + void _qadic_exp_balanced(fmpz *rop, const fmpz *x, slong v, slong len, const fmpz *a, const slong *j, slong lena, const fmpz_t p, slong N, const fmpz_t pN) noexcept # Sets ``(rop, d)`` to the exponential of ``(op, v, len)`` # reduced modulo `p^N`, assuming that the series converges. # Assumes that ``len`` is in `[1,d)` but supports zero padding, # including the special case when ``(op, len)`` is zero. # Supports aliasing between ``rop`` and ``op``. - int qadic_exp_balanced(qadic_t rop, const qadic_t op, const qadic_ctx_t ctx) + int qadic_exp_balanced(qadic_t rop, const qadic_t op, const qadic_ctx_t ctx) noexcept # Returns whether the exponential series converges at ``op`` # and sets ``rop`` to its value reduced modulo in the given # context. - void _qadic_exp(fmpz *rop, const fmpz *op, slong v, slong len, const fmpz *a, const slong *j, slong lena, const fmpz_t p, slong N, const fmpz_t pN) + void _qadic_exp(fmpz *rop, const fmpz *op, slong v, slong len, const fmpz *a, const slong *j, slong lena, const fmpz_t p, slong N, const fmpz_t pN) noexcept # Sets ``(rop, 2*d - 1)`` to the exponential of ``(op, v, len)`` # reduced modulo `p^N`, assuming that the series converges. # Assumes that ``(op, v, len)`` is non-zero. # Does not support aliasing. - int qadic_exp(qadic_t rop, const qadic_t op, const qadic_ctx_t ctx) + int qadic_exp(qadic_t rop, const qadic_t op, const qadic_ctx_t ctx) noexcept # Returns whether the exponential series converges at ``op`` # and sets ``rop`` to its value reduced modulo in the given # context. # The exponential series converges if the valuation of ``op`` # is at least `2` or `1` when `p` is even or odd, respectively. - void _qadic_log_rectangular(fmpz *z, const fmpz *y, slong v, slong len, const fmpz *a, const slong *j, slong lena, const fmpz_t p, slong N, const fmpz_t pN) + void _qadic_log_rectangular(fmpz *z, const fmpz *y, slong v, slong len, const fmpz *a, const slong *j, slong lena, const fmpz_t p, slong N, const fmpz_t pN) noexcept # Computes # .. math :: # z = - \sum_{i = 1}^{\infty} \frac{y^i}{i} \pmod{p^N}. @@ -239,11 +239,11 @@ cdef extern from "flint_wrap.h": # Assumes that `v < N`, and in particular `N \geq 2`. # Supports aliasing between `y` and `z`. - int qadic_log_rectangular(qadic_t rop, const qadic_t op, const qadic_ctx_t ctx) + int qadic_log_rectangular(qadic_t rop, const qadic_t op, const qadic_ctx_t ctx) noexcept # Returns whether the `p`-adic logarithm function converges at # ``op``, and if so sets ``rop`` to its value. - void _qadic_log_balanced(fmpz *z, const fmpz *y, slong len, const fmpz *a, const slong *j, slong lena, const fmpz_t p, slong N, const fmpz_t pN) + void _qadic_log_balanced(fmpz *z, const fmpz *y, slong len, const fmpz *a, const slong *j, slong lena, const fmpz_t p, slong N, const fmpz_t pN) noexcept # Computes `(z, d)` as # .. math :: # z = - \sum_{i = 1}^{\infty} \frac{y^i}{i} \pmod{p^N}. @@ -251,11 +251,11 @@ cdef extern from "flint_wrap.h": # at least `2` when `p = 2` so that the series converges. # Supports aliasing between `z` and `y`. - int qadic_log_balanced(qadic_t rop, const qadic_t op, const qadic_ctx_t ctx) + int qadic_log_balanced(qadic_t rop, const qadic_t op, const qadic_ctx_t ctx) noexcept # Returns whether the `p`-adic logarithm function converges at # ``op``, and if so sets ``rop`` to its value. - void _qadic_log(fmpz *z, const fmpz *y, slong v, slong len, const fmpz *a, const slong *j, slong lena, const fmpz_t p, slong N, const fmpz_t pN) + void _qadic_log(fmpz *z, const fmpz *y, slong v, slong len, const fmpz *a, const slong *j, slong lena, const fmpz_t p, slong N, const fmpz_t pN) noexcept # Computes `(z, d)` as # .. math :: # z = - \sum_{i = 1}^{\infty} \frac{y^i}{i} \pmod{p^N}. @@ -271,7 +271,7 @@ cdef extern from "flint_wrap.h": # Assumes that `v < N`, and hence in particular `N \geq 2`. # Supports aliasing between `z` and `y`. - int qadic_log(qadic_t rop, const qadic_t op, const qadic_ctx_t ctx) + int qadic_log(qadic_t rop, const qadic_t op, const qadic_ctx_t ctx) noexcept # Returns whether the `p`-adic logarithm function converges at # ``op``, and if so sets ``rop`` to its value. # The `p`-adic logarithm function is defined by the usual series @@ -280,7 +280,7 @@ cdef extern from "flint_wrap.h": # but this only converges when `\operatorname{ord}_p(x)` is at least `2` or `1` # when `p = 2` or `p > 2`, respectively. - void _qadic_frobenius_a(fmpz *rop, slong e, const fmpz *a, const slong *j, slong lena, const fmpz_t p, slong N) + void _qadic_frobenius_a(fmpz *rop, slong e, const fmpz *a, const slong *j, slong lena, const fmpz_t p, slong N) noexcept # Computes `\sigma^e(X) \bmod{p^N}` where `X` is such that # `\mathbf{Q}_q \cong \mathbf{Q}_p[X]/(f(X))`. # Assumes that the precision `N` is at least `2` and that the @@ -289,13 +289,13 @@ cdef extern from "flint_wrap.h": # Sets ``(rop, 2*d-1)``, although the actual length of the # output will be at most `d`. - void _qadic_frobenius(fmpz *rop, const fmpz *op, slong len, slong e, const fmpz *a, const slong *j, slong lena, const fmpz_t p, slong N) + void _qadic_frobenius(fmpz *rop, const fmpz *op, slong len, slong e, const fmpz *a, const slong *j, slong lena, const fmpz_t p, slong N) noexcept # Sets ``(rop, 2*d-1)`` to `\Sigma` evaluated at ``(op, len)``. # Assumes that ``len`` is positive but at most `d`. # Assumes that `0 < e < d`. # Does not support aliasing. - void qadic_frobenius(qadic_t rop, const qadic_t op, slong e, const qadic_ctx_t ctx) + void qadic_frobenius(qadic_t rop, const qadic_t op, slong e, const qadic_ctx_t ctx) noexcept # Evaluates the homomorphism `\Sigma^e` at ``op``. # Recall that `\mathbf{Q}_q / \mathbf{Q}_p` is Galois with Galois group # `\langle \Sigma \rangle \cong \langle \sigma \rangle`, which is also @@ -305,12 +305,12 @@ cdef extern from "flint_wrap.h": # `\operatorname{Gal}(\mathbf{Q}_q/\mathbf{Q}_p)`. # This functionality is implemented as ``GaloisImage()`` in Magma. - void _qadic_teichmuller(fmpz *rop, const fmpz *op, slong len, const fmpz *a, const slong *j, slong lena, const fmpz_t p, slong N) + void _qadic_teichmuller(fmpz *rop, const fmpz *op, slong len, const fmpz *a, const slong *j, slong lena, const fmpz_t p, slong N) noexcept # Sets ``(rop, d)`` to the Teichmüller lift of ``(op, len)`` # modulo `p^N`. # Does not support aliasing. - void qadic_teichmuller(qadic_t rop, const qadic_t op, const qadic_ctx_t ctx) + void qadic_teichmuller(qadic_t rop, const qadic_t op, const qadic_ctx_t ctx) noexcept # Sets ``rop`` to the Teichmüller lift of ``op`` to the # precision given in the context. # For a unit ``op``, this is the unique `(q-1)`\th root of unity @@ -318,8 +318,8 @@ cdef extern from "flint_wrap.h": # Sets ``rop`` to zero if ``op`` is zero in the given context. # Raises an exception if the valuation of ``op`` is negative. - void _qadic_trace(fmpz_t rop, const fmpz *op, slong len, const fmpz *a, const slong *j, slong lena, const fmpz_t pN) - void qadic_trace(padic_t rop, const qadic_t op, const qadic_ctx_t ctx) + void _qadic_trace(fmpz_t rop, const fmpz *op, slong len, const fmpz *a, const slong *j, slong lena, const fmpz_t pN) noexcept + void qadic_trace(padic_t rop, const qadic_t op, const qadic_ctx_t ctx) noexcept # Sets ``rop`` to the trace of ``op``. # For an element `a \in \mathbf{Q}_q`, multiplication by `a` defines # a `\mathbf{Q}_p`-linear map on `\mathbf{Q}_q`. We define the trace @@ -327,7 +327,7 @@ cdef extern from "flint_wrap.h": # `\operatorname{Gal}(\mathbf{Q}_q / \mathbf{Q}_p)` then the trace of `a` is equal to # `\sum_{i=0}^{d-1} \Sigma^i (a)`. - void _qadic_norm(fmpz_t rop, const fmpz *op, slong len, const fmpz *a, const slong *j, slong lena, const fmpz_t p, slong N) + void _qadic_norm(fmpz_t rop, const fmpz *op, slong len, const fmpz *a, const slong *j, slong lena, const fmpz_t p, slong N) noexcept # Sets ``rop`` to the norm of the element ``(op,len)`` # in `\mathbf{Z}_q` to precision `N`, where ``len`` is at # least one. @@ -336,11 +336,11 @@ cdef extern from "flint_wrap.h": # Thus, the output ``rop`` of this function will typically # not have to be canonicalised or reduced by the caller. - void qadic_norm(padic_t rop, const qadic_t op, const qadic_ctx_t ctx) + void qadic_norm(padic_t rop, const qadic_t op, const qadic_ctx_t ctx) noexcept # Computes the norm of ``op`` to the given precision. # Algorithm selection is automatic depending on the input. - void qadic_norm_analytic(padic_t rop, const qadic_t op, const qadic_ctx_t ctx) + void qadic_norm_analytic(padic_t rop, const qadic_t op, const qadic_ctx_t ctx) noexcept # Whenever ``op`` has valuation greater than `(p-1)^{-1}`, this # routine computes its norm ``rop`` via # .. math :: @@ -351,7 +351,7 @@ cdef extern from "flint_wrap.h": # The complexity of this implementation is quasi-linear in `d` and `N`, # and polynomial in `\log p`. - void qadic_norm_resultant(padic_t rop, const qadic_t op, const qadic_ctx_t ctx) + void qadic_norm_resultant(padic_t rop, const qadic_t op, const qadic_ctx_t ctx) noexcept # Sets ``rop`` to the norm of ``op``, using the formula # .. math :: # \operatorname{Norm}(x) = \ell(f)^{-\deg(a)} \operatorname{Res}(f(X), a(X)), @@ -362,13 +362,13 @@ cdef extern from "flint_wrap.h": # `\mathcal{O}(d^4 M(N \log p))`, where `M(n)` denotes the # complexity of multiplying to `n`-bit integers. - int qadic_fprint_pretty(FILE *file, const qadic_t op, const qadic_ctx_t ctx) + int qadic_fprint_pretty(FILE *file, const qadic_t op, const qadic_ctx_t ctx) noexcept # Prints a pretty representation of ``op`` to ``file``. # In the current implementation, always returns `1`. The return code is # part of the function's signature to allow for a later implementation to # return the number of characters printed or a non-positive error code. - int qadic_print_pretty(const qadic_t op, const qadic_ctx_t ctx) + int qadic_print_pretty(const qadic_t op, const qadic_ctx_t ctx) noexcept # Prints a pretty representation of ``op`` to ``stdout``. # In the current implementation, always returns `1`. The return code is # part of the function's signature to allow for a later implementation to diff --git a/src/sage/libs/flint/qfb.pxd b/src/sage/libs/flint/qfb.pxd index ce978aa0503..1b89c40755d 100644 --- a/src/sage/libs/flint/qfb.pxd +++ b/src/sage/libs/flint/qfb.pxd @@ -12,62 +12,62 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void qfb_init(qfb_t q) + void qfb_init(qfb_t q) noexcept # Initialise a ``qfb_t`` `q` for use. - void qfb_clear(qfb_t q) + void qfb_clear(qfb_t q) noexcept # Clear a ``qfb_t`` after use. This releases any memory allocated for # `q` back to flint. - void qfb_array_clear(qfb ** forms, slong num) + void qfb_array_clear(qfb ** forms, slong num) noexcept # Clean up an array of ``qfb`` structs allocated by a qfb function. # The parameter ``num`` must be set to the length of the array. - qfb_hash_t * qfb_hash_init(slong depth) + qfb_hash_t * qfb_hash_init(slong depth) noexcept # Initialises a hash table of size `2^{depth}`. - void qfb_hash_clear(qfb_hash_t * qhash, slong depth) + void qfb_hash_clear(qfb_hash_t * qhash, slong depth) noexcept # Frees all memory used by a hash table of size `2^{depth}`. - void qfb_hash_insert(qfb_hash_t * qhash, qfb_t q, qfb_t q2, slong it, slong depth) + void qfb_hash_insert(qfb_hash_t * qhash, qfb_t q, qfb_t q2, slong it, slong depth) noexcept # Insert the binary quadratic form ``q`` into the given hash table # of size `2^{depth}` in the field ``q`` of the hash structure. # Also store the second binary quadratic form ``q2`` (if not # ``NULL``) in the similarly named field and ``iter`` in the # similarly named field of the hash structure. - slong qfb_hash_find(qfb_hash_t * qhash, qfb_t q, slong depth) + slong qfb_hash_find(qfb_hash_t * qhash, qfb_t q, slong depth) noexcept # Search for the given binary quadratic form or its inverse in the # given hash table of size `2^{depth}`. If it is found, return # the index in the table (which is an array of ``qfb_hash_t`` # structs), otherwise return ``-1``. - void qfb_set(qfb_t f, qfb_t g) + void qfb_set(qfb_t f, qfb_t g) noexcept # Set the binary quadratic form `f` to be equal to `g`. - bint qfb_equal(qfb_t f, qfb_t g) + bint qfb_equal(qfb_t f, qfb_t g) noexcept # Returns `1` if `f` and `g` are identical binary quadratic forms, # otherwise returns `0`. - void qfb_print(qfb_t q) + void qfb_print(qfb_t q) noexcept # Print a binary quadratic form `q` in the format `(a, b, c)` where # `a`, `b`, `c` are the entries of `q`. - void qfb_discriminant(fmpz_t D, qfb_t f) + void qfb_discriminant(fmpz_t D, qfb_t f) noexcept # Set `D` to the discriminant of the binary quadratic form `f`, i.e. to # `b^2 - 4ac`, where `f = (a, b, c)`. - void qfb_reduce(qfb_t r, qfb_t f, fmpz_t D) + void qfb_reduce(qfb_t r, qfb_t f, fmpz_t D) noexcept # Set `r` to a reduced form equivalent to the binary quadratic form `f` # of discriminant `D`. - bint qfb_is_reduced(qfb_t r) + bint qfb_is_reduced(qfb_t r) noexcept # Returns `1` if `q` is a reduced binary quadratic form, otherwise # returns `0`. Note that this only tests for definite quadratic # forms, so a form `r = (a,b,c)` is reduced if and only if `|b| \le a \le # c` and if either inequality is an equality, then `b \ge 0`. - slong qfb_reduced_forms(qfb ** forms, slong d) + slong qfb_reduced_forms(qfb ** forms, slong d) noexcept # Given a discriminant `d` (negative for negative definite forms), compute # all the reduced binary quadratic forms of that discriminant. The function # allocates space for these and returns it in the variable ``forms`` @@ -77,52 +77,52 @@ cdef extern from "flint_wrap.h": # stored in an array of ``qfb`` structs, which contain fields # ``a, b, c`` corresponding to forms `(a, b, c)`. - slong qfb_reduced_forms_large(qfb ** forms, slong d) + slong qfb_reduced_forms_large(qfb ** forms, slong d) noexcept # As for ``qfb_reduced_forms``. However, for small `|d|` it requires # fewer primes to be computed at a small cost in speed. It is called # automatically by ``qfb_reduced_forms`` for large `|d|` so that # ``flint_primes`` is not exhausted. - void qfb_nucomp(qfb_t r, const qfb_t f, const qfb_t g, fmpz_t D, fmpz_t L) + void qfb_nucomp(qfb_t r, const qfb_t f, const qfb_t g, fmpz_t D, fmpz_t L) noexcept # Shanks' NUCOMP as described in [JvdP2002]_. # Computes the near reduced composition of forms `f` and `g` given # `L = \lfloor |D|^{1/4} \rfloor` where `D` is the common discriminant of # `f` and `g`. The result is returned in `r`. # We require that `f` is a primitive form. - void qfb_nudupl(qfb_t r, const qfb_t f, fmpz_t D, fmpz_t L) + void qfb_nudupl(qfb_t r, const qfb_t f, fmpz_t D, fmpz_t L) noexcept # As for ``nucomp`` except that the form `f` is composed with itself. # We require that `f` is a primitive form. - void qfb_pow_ui(qfb_t r, qfb_t f, fmpz_t D, ulong exp) + void qfb_pow_ui(qfb_t r, qfb_t f, fmpz_t D, ulong exp) noexcept # Compute the near reduced form `r` which is the result of composing the # principal form (identity) with `f` ``exp`` times. # We require `D` to be set to the discriminant of `f` and that `f` is a # primitive form. - void qfb_pow(qfb_t r, qfb_t f, fmpz_t D, fmpz_t exp) + void qfb_pow(qfb_t r, qfb_t f, fmpz_t D, fmpz_t exp) noexcept # As per ``qfb_pow_ui``. - void qfb_inverse(qfb_t r, qfb_t f) + void qfb_inverse(qfb_t r, qfb_t f) noexcept # Set `r` to the inverse of the binary quadratic form `f`. - bint qfb_is_principal_form(qfb_t f, fmpz_t D) + bint qfb_is_principal_form(qfb_t f, fmpz_t D) noexcept # Return `1` if `f` is the reduced principal form of discriminant `D`, # i.e. the identity in the form class group, else `0`. - void qfb_principal_form(qfb_t f, fmpz_t D) + void qfb_principal_form(qfb_t f, fmpz_t D) noexcept # Set `f` to the principal form of discriminant `D`, i.e. the identity in # the form class group. - bint qfb_is_primitive(qfb_t f) + bint qfb_is_primitive(qfb_t f) noexcept # Return `1` if `f` is primitive, i.e. the greatest common divisor of its # three coefficients is `1`. Otherwise the function returns `0`. - void qfb_prime_form(qfb_t r, fmpz_t D, fmpz_t p) + void qfb_prime_form(qfb_t r, fmpz_t D, fmpz_t p) noexcept # Sets `r` to the unique prime `(p, b, c)` of discriminant `D`, i.e. with # `0 < b \leq p`. We require that `p` is a prime. - int qfb_exponent_element(fmpz_t exponent, qfb_t f, fmpz_t n, ulong B1, ulong B2_sqrt) + int qfb_exponent_element(fmpz_t exponent, qfb_t f, fmpz_t n, ulong B1, ulong B2_sqrt) noexcept # Find the exponent of the element `f` in the form class group of forms of # discriminant `n`, doing a stage `1` with primes up to at least ``B1`` # and a stage `2` for a single large prime up to at least the square of @@ -136,7 +136,7 @@ cdef extern from "flint_wrap.h": # additional limbs of data in a hash table, where ``iters`` is the # square root of ``B2``. - int qfb_exponent(fmpz_t exponent, fmpz_t n, ulong B1, ulong B2_sqrt, slong c) + int qfb_exponent(fmpz_t exponent, fmpz_t n, ulong B1, ulong B2_sqrt, slong c) noexcept # Compute the exponent of the class group of discriminant `n`, doing # a stage `1` with primes up to at least ``B1`` and a stage `2` for # a single large prime up to at least the square of ``B2_sqrt``, and @@ -151,7 +151,7 @@ cdef extern from "flint_wrap.h": # square root of ``B2``. # We use algorithm 8.1 of [Sut2007]_. - int qfb_exponent_grh(fmpz_t exponent, fmpz_t n, ulong B1, ulong B2_sqrt) + int qfb_exponent_grh(fmpz_t exponent, fmpz_t n, ulong B1, ulong B2_sqrt) noexcept # Similar to ``qfb_exponent`` except that the bound ``c`` is # automatically generated such that the exponent is guaranteed to be # correct, if found, assuming the GRH, namely that the class group is diff --git a/src/sage/libs/flint/qqbar.pxd b/src/sage/libs/flint/qqbar.pxd index cb220973c5d..b49a764bb0a 100644 --- a/src/sage/libs/flint/qqbar.pxd +++ b/src/sage/libs/flint/qqbar.pxd @@ -12,79 +12,79 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void qqbar_init(qqbar_t res) + void qqbar_init(qqbar_t res) noexcept # Initializes the variable *res* for use, and sets its value to zero. - void qqbar_clear(qqbar_t res) + void qqbar_clear(qqbar_t res) noexcept # Clears the variable *res*, freeing or recycling its allocated memory. - qqbar_ptr _qqbar_vec_init(slong len) + qqbar_ptr _qqbar_vec_init(slong len) noexcept # Returns a pointer to an array of *len* initialized *qqbar_struct*:s. - void _qqbar_vec_clear(qqbar_ptr vec, slong len) + void _qqbar_vec_clear(qqbar_ptr vec, slong len) noexcept # Clears all *len* entries in the vector *vec* and frees the # vector itself. - void qqbar_swap(qqbar_t x, qqbar_t y) + void qqbar_swap(qqbar_t x, qqbar_t y) noexcept # Swaps the values of *x* and *y* efficiently. - void qqbar_set(qqbar_t res, const qqbar_t x) - void qqbar_set_si(qqbar_t res, slong x) - void qqbar_set_ui(qqbar_t res, ulong x) - void qqbar_set_fmpz(qqbar_t res, const fmpz_t x) - void qqbar_set_fmpq(qqbar_t res, const fmpq_t x) + void qqbar_set(qqbar_t res, const qqbar_t x) noexcept + void qqbar_set_si(qqbar_t res, slong x) noexcept + void qqbar_set_ui(qqbar_t res, ulong x) noexcept + void qqbar_set_fmpz(qqbar_t res, const fmpz_t x) noexcept + void qqbar_set_fmpq(qqbar_t res, const fmpq_t x) noexcept # Sets *res* to the value *x*. - void qqbar_set_re_im(qqbar_t res, const qqbar_t x, const qqbar_t y) + void qqbar_set_re_im(qqbar_t res, const qqbar_t x, const qqbar_t y) noexcept # Sets *res* to the value `x + yi`. - int qqbar_set_d(qqbar_t res, double x) - int qqbar_set_re_im_d(qqbar_t res, double x, double y) + int qqbar_set_d(qqbar_t res, double x) noexcept + int qqbar_set_re_im_d(qqbar_t res, double x, double y) noexcept # Sets *res* to the value *x* or `x + yi` respectively. These functions # performs error handling: if *x* and *y* are finite, the conversion succeeds # and the return flag is 1. If *x* or *y* is non-finite (infinity or NaN), # the conversion fails and the return flag is 0. - slong qqbar_degree(const qqbar_t x) + slong qqbar_degree(const qqbar_t x) noexcept # Returns the degree of *x*, i.e. the degree of the minimal polynomial. - bint qqbar_is_rational(const qqbar_t x) + bint qqbar_is_rational(const qqbar_t x) noexcept # Returns whether *x* is a rational number. - bint qqbar_is_integer(const qqbar_t x) + bint qqbar_is_integer(const qqbar_t x) noexcept # Returns whether *x* is an integer (an element of `\mathbb{Z}`). - bint qqbar_is_algebraic_integer(const qqbar_t x) + bint qqbar_is_algebraic_integer(const qqbar_t x) noexcept # Returns whether *x* is an algebraic integer, i.e. whether its minimal # polynomial has leading coefficient 1. - bint qqbar_is_zero(const qqbar_t x) - bint qqbar_is_one(const qqbar_t x) - bint qqbar_is_neg_one(const qqbar_t x) + bint qqbar_is_zero(const qqbar_t x) noexcept + bint qqbar_is_one(const qqbar_t x) noexcept + bint qqbar_is_neg_one(const qqbar_t x) noexcept # Returns whether *x* is the number `0`, `1`, `-1`. - bint qqbar_is_i(const qqbar_t x) - bint qqbar_is_neg_i(const qqbar_t x) + bint qqbar_is_i(const qqbar_t x) noexcept + bint qqbar_is_neg_i(const qqbar_t x) noexcept # Returns whether *x* is the imaginary unit `i` (respectively `-i`). - bint qqbar_is_real(const qqbar_t x) + bint qqbar_is_real(const qqbar_t x) noexcept # Returns whether *x* is a real number. - void qqbar_height(fmpz_t res, const qqbar_t x) + void qqbar_height(fmpz_t res, const qqbar_t x) noexcept # Sets *res* to the height of *x* (the largest absolute value of the # coefficients of the minimal polynomial of *x*). - slong qqbar_height_bits(const qqbar_t x) + slong qqbar_height_bits(const qqbar_t x) noexcept # Returns the height of *x* (the largest absolute value of the # coefficients of the minimal polynomial of *x*) measured in bits. - int qqbar_within_limits(const qqbar_t x, slong deg_limit, slong bits_limit) + int qqbar_within_limits(const qqbar_t x, slong deg_limit, slong bits_limit) noexcept # Checks if *x* has degree bounded by *deg_limit* and height # bounded by *bits_limit* bits, returning 0 (false) or 1 (true). # If *deg_limit* is set to 0, the degree check is skipped, # and similarly for *bits_limit*. - int qqbar_binop_within_limits(const qqbar_t x, const qqbar_t y, slong deg_limit, slong bits_limit) + int qqbar_binop_within_limits(const qqbar_t x, const qqbar_t y, slong deg_limit, slong bits_limit) noexcept # Checks if `x + y`, `x - y`, `x \cdot y` and `x / y` certainly have # degree bounded by *deg_limit* (by multiplying the degrees for *x* and *y* # to obtain a trivial bound). For *bits_limits*, the sum of the bit heights @@ -92,78 +92,78 @@ cdef extern from "flint_wrap.h": # If *deg_limit* is set to 0, the degree check is skipped, # and similarly for *bits_limit*. - void _qqbar_get_fmpq(fmpz_t num, fmpz_t den, const qqbar_t x) + void _qqbar_get_fmpq(fmpz_t num, fmpz_t den, const qqbar_t x) noexcept # Sets *num* and *den* to the numerator and denominator of *x*. # Aborts if *x* is not a rational number. - void qqbar_get_fmpq(fmpq_t res, const qqbar_t x) + void qqbar_get_fmpq(fmpq_t res, const qqbar_t x) noexcept # Sets *res* to *x*. Aborts if *x* is not a rational number. - void qqbar_get_fmpz(fmpz_t res, const qqbar_t x) + void qqbar_get_fmpz(fmpz_t res, const qqbar_t x) noexcept # Sets *res* to *x*. Aborts if *x* is not an integer. - void qqbar_zero(qqbar_t res) + void qqbar_zero(qqbar_t res) noexcept # Sets *res* to the number 0. - void qqbar_one(qqbar_t res) + void qqbar_one(qqbar_t res) noexcept # Sets *res* to the number 1. - void qqbar_i(qqbar_t res) + void qqbar_i(qqbar_t res) noexcept # Sets *res* to the imaginary unit `i`. - void qqbar_phi(qqbar_t res) + void qqbar_phi(qqbar_t res) noexcept # Sets *res* to the golden ratio `\varphi = \tfrac{1}{2}(\sqrt{5} + 1)`. - void qqbar_print(const qqbar_t x) + void qqbar_print(const qqbar_t x) noexcept # Prints *res* to standard output. The output shows the degree # and the list of coefficients # of the minimal polynomial followed by a decimal representation of # the enclosing interval. This function is mainly intended for debugging. - void qqbar_printn(const qqbar_t x, slong n) + void qqbar_printn(const qqbar_t x, slong n) noexcept # Prints *res* to standard output. The output shows a decimal # approximation to *n* digits. - void qqbar_printnd(const qqbar_t x, slong n) + void qqbar_printnd(const qqbar_t x, slong n) noexcept # Prints *res* to standard output. The output shows a decimal # approximation to *n* digits, followed by the degree of the number. - void qqbar_randtest(qqbar_t res, flint_rand_t state, slong deg, slong bits) + void qqbar_randtest(qqbar_t res, flint_rand_t state, slong deg, slong bits) noexcept # Sets *res* to a random algebraic number with degree up to *deg* and # with height (measured in bits) up to *bits*. - void qqbar_randtest_real(qqbar_t res, flint_rand_t state, slong deg, slong bits) + void qqbar_randtest_real(qqbar_t res, flint_rand_t state, slong deg, slong bits) noexcept # Sets *res* to a random real algebraic number with degree up to *deg* and # with height (measured in bits) up to *bits*. - void qqbar_randtest_nonreal(qqbar_t res, flint_rand_t state, slong deg, slong bits) + void qqbar_randtest_nonreal(qqbar_t res, flint_rand_t state, slong deg, slong bits) noexcept # Sets *res* to a random nonreal algebraic number with degree up to *deg* and # with height (measured in bits) up to *bits*. Since all algebraic numbers # of degree 1 are real, *deg* must be at least 2. - bint qqbar_equal(const qqbar_t x, const qqbar_t y) + bint qqbar_equal(const qqbar_t x, const qqbar_t y) noexcept # Returns whether *x* and *y* are equal. - bint qqbar_equal_fmpq_poly_val(const qqbar_t x, const fmpq_poly_t f, const qqbar_t y) + bint qqbar_equal_fmpq_poly_val(const qqbar_t x, const fmpq_poly_t f, const qqbar_t y) noexcept # Returns whether *x* is equal to `f(y)`. This function is more efficient # than evaluating `f(y)` and comparing the results. - int qqbar_cmp_re(const qqbar_t x, const qqbar_t y) + int qqbar_cmp_re(const qqbar_t x, const qqbar_t y) noexcept # Compares the real parts of *x* and *y*, returning -1, 0 or +1. - int qqbar_cmp_im(const qqbar_t x, const qqbar_t y) + int qqbar_cmp_im(const qqbar_t x, const qqbar_t y) noexcept # Compares the imaginary parts of *x* and *y*, returning -1, 0 or +1. - int qqbar_cmpabs_re(const qqbar_t x, const qqbar_t y) + int qqbar_cmpabs_re(const qqbar_t x, const qqbar_t y) noexcept # Compares the absolute values of the real parts of *x* and *y*, returning -1, 0 or +1. - int qqbar_cmpabs_im(const qqbar_t x, const qqbar_t y) + int qqbar_cmpabs_im(const qqbar_t x, const qqbar_t y) noexcept # Compares the absolute values of the imaginary parts of *x* and *y*, returning -1, 0 or +1. - int qqbar_cmpabs(const qqbar_t x, const qqbar_t y) + int qqbar_cmpabs(const qqbar_t x, const qqbar_t y) noexcept # Compares the absolute values of *x* and *y*, returning -1, 0 or +1. - int qqbar_cmp_root_order(const qqbar_t x, const qqbar_t y) + int qqbar_cmp_root_order(const qqbar_t x, const qqbar_t y) noexcept # Compares *x* and *y* using an arbitrary but convenient ordering # defined on the complex numbers. This is useful for sorting the # roots of a polynomial in a canonical order. @@ -174,7 +174,7 @@ cdef extern from "flint_wrap.h": # order of the sign. This implies that complex conjugate roots # are adjacent, with the root in the upper half plane first. - ulong qqbar_hash(const qqbar_t x) + ulong qqbar_hash(const qqbar_t x) noexcept # Returns a hash of *x*. As currently implemented, this function # only hashes the minimal polynomial of *x*. The user should # mix in some bits based on the numerical value if it is critical @@ -185,181 +185,181 @@ cdef extern from "flint_wrap.h": # important that all bits in the output are random, # the user should apply an integer hash function to the output. - void qqbar_conj(qqbar_t res, const qqbar_t x) + void qqbar_conj(qqbar_t res, const qqbar_t x) noexcept # Sets *res* to the complex conjugate of *x*. - void qqbar_re(qqbar_t res, const qqbar_t x) + void qqbar_re(qqbar_t res, const qqbar_t x) noexcept # Sets *res* to the real part of *x*. - void qqbar_im(qqbar_t res, const qqbar_t x) + void qqbar_im(qqbar_t res, const qqbar_t x) noexcept # Sets *res* to the imaginary part of *x*. - void qqbar_re_im(qqbar_t res1, qqbar_t res2, const qqbar_t x) + void qqbar_re_im(qqbar_t res1, qqbar_t res2, const qqbar_t x) noexcept # Sets *res1* to the real part of *x* and *res2* to the imaginary part of *x*. - void qqbar_abs(qqbar_t res, const qqbar_t x) + void qqbar_abs(qqbar_t res, const qqbar_t x) noexcept # Sets *res* to the absolute value of *x*: - void qqbar_abs2(qqbar_t res, const qqbar_t x) + void qqbar_abs2(qqbar_t res, const qqbar_t x) noexcept # Sets *res* to the square of the absolute value of *x*. - void qqbar_sgn(qqbar_t res, const qqbar_t x) + void qqbar_sgn(qqbar_t res, const qqbar_t x) noexcept # Sets *res* to the complex sign of *x*, defined as 0 if *x* is zero # and as `x / |x|` otherwise. - int qqbar_sgn_re(const qqbar_t x) + int qqbar_sgn_re(const qqbar_t x) noexcept # Returns the sign of the real part of *x* (-1, 0 or +1). - int qqbar_sgn_im(const qqbar_t x) + int qqbar_sgn_im(const qqbar_t x) noexcept # Returns the sign of the imaginary part of *x* (-1, 0 or +1). - int qqbar_csgn(const qqbar_t x) + int qqbar_csgn(const qqbar_t x) noexcept # Returns the extension of the real sign function taking the # value 1 for *x* strictly in the right half plane, -1 for *x* strictly # in the left half plane, and the sign of the imaginary part when *x* is on # the imaginary axis. Equivalently, `\operatorname{csgn}(x) = x / \sqrt{x^2}` # except that the value is 0 when *x* is zero. - void qqbar_floor(fmpz_t res, const qqbar_t x) + void qqbar_floor(fmpz_t res, const qqbar_t x) noexcept # Sets *res* to the floor function of *x*. If *x* is not real, the # value is defined as the floor function of the real part of *x*. - void qqbar_ceil(fmpz_t res, const qqbar_t x) + void qqbar_ceil(fmpz_t res, const qqbar_t x) noexcept # Sets *res* to the ceiling function of *x*. If *x* is not real, the # value is defined as the ceiling function of the real part of *x*. - void qqbar_neg(qqbar_t res, const qqbar_t x) + void qqbar_neg(qqbar_t res, const qqbar_t x) noexcept # Sets *res* to the negation of *x*. - void qqbar_add(qqbar_t res, const qqbar_t x, const qqbar_t y) - void qqbar_add_fmpq(qqbar_t res, const qqbar_t x, const fmpq_t y) - void qqbar_add_fmpz(qqbar_t res, const qqbar_t x, const fmpz_t y) - void qqbar_add_ui(qqbar_t res, const qqbar_t x, ulong y) - void qqbar_add_si(qqbar_t res, const qqbar_t x, slong y) + void qqbar_add(qqbar_t res, const qqbar_t x, const qqbar_t y) noexcept + void qqbar_add_fmpq(qqbar_t res, const qqbar_t x, const fmpq_t y) noexcept + void qqbar_add_fmpz(qqbar_t res, const qqbar_t x, const fmpz_t y) noexcept + void qqbar_add_ui(qqbar_t res, const qqbar_t x, ulong y) noexcept + void qqbar_add_si(qqbar_t res, const qqbar_t x, slong y) noexcept # Sets *res* to the sum of *x* and *y*. - void qqbar_sub(qqbar_t res, const qqbar_t x, const qqbar_t y) - void qqbar_sub_fmpq(qqbar_t res, const qqbar_t x, const fmpq_t y) - void qqbar_sub_fmpz(qqbar_t res, const qqbar_t x, const fmpz_t y) - void qqbar_sub_ui(qqbar_t res, const qqbar_t x, ulong y) - void qqbar_sub_si(qqbar_t res, const qqbar_t x, slong y) - void qqbar_fmpq_sub(qqbar_t res, const fmpq_t x, const qqbar_t y) - void qqbar_fmpz_sub(qqbar_t res, const fmpz_t x, const qqbar_t y) - void qqbar_ui_sub(qqbar_t res, ulong x, const qqbar_t y) - void qqbar_si_sub(qqbar_t res, slong x, const qqbar_t y) + void qqbar_sub(qqbar_t res, const qqbar_t x, const qqbar_t y) noexcept + void qqbar_sub_fmpq(qqbar_t res, const qqbar_t x, const fmpq_t y) noexcept + void qqbar_sub_fmpz(qqbar_t res, const qqbar_t x, const fmpz_t y) noexcept + void qqbar_sub_ui(qqbar_t res, const qqbar_t x, ulong y) noexcept + void qqbar_sub_si(qqbar_t res, const qqbar_t x, slong y) noexcept + void qqbar_fmpq_sub(qqbar_t res, const fmpq_t x, const qqbar_t y) noexcept + void qqbar_fmpz_sub(qqbar_t res, const fmpz_t x, const qqbar_t y) noexcept + void qqbar_ui_sub(qqbar_t res, ulong x, const qqbar_t y) noexcept + void qqbar_si_sub(qqbar_t res, slong x, const qqbar_t y) noexcept # Sets *res* to the difference of *x* and *y*. - void qqbar_mul(qqbar_t res, const qqbar_t x, const qqbar_t y) - void qqbar_mul_fmpq(qqbar_t res, const qqbar_t x, const fmpq_t y) - void qqbar_mul_fmpz(qqbar_t res, const qqbar_t x, const fmpz_t y) - void qqbar_mul_ui(qqbar_t res, const qqbar_t x, ulong y) - void qqbar_mul_si(qqbar_t res, const qqbar_t x, slong y) + void qqbar_mul(qqbar_t res, const qqbar_t x, const qqbar_t y) noexcept + void qqbar_mul_fmpq(qqbar_t res, const qqbar_t x, const fmpq_t y) noexcept + void qqbar_mul_fmpz(qqbar_t res, const qqbar_t x, const fmpz_t y) noexcept + void qqbar_mul_ui(qqbar_t res, const qqbar_t x, ulong y) noexcept + void qqbar_mul_si(qqbar_t res, const qqbar_t x, slong y) noexcept # Sets *res* to the product of *x* and *y*. - void qqbar_mul_2exp_si(qqbar_t res, const qqbar_t x, slong e) + void qqbar_mul_2exp_si(qqbar_t res, const qqbar_t x, slong e) noexcept # Sets *res* to *x* multiplied by `2^e`. - void qqbar_sqr(qqbar_t res, const qqbar_t x) + void qqbar_sqr(qqbar_t res, const qqbar_t x) noexcept # Sets *res* to the square of *x*. - void qqbar_inv(qqbar_t res, const qqbar_t x) + void qqbar_inv(qqbar_t res, const qqbar_t x) noexcept # Sets *res* to the multiplicative inverse of *y*. # Division by zero calls *flint_abort*. - void qqbar_div(qqbar_t res, const qqbar_t x, const qqbar_t y) - void qqbar_div_fmpq(qqbar_t res, const qqbar_t x, const fmpq_t y) - void qqbar_div_fmpz(qqbar_t res, const qqbar_t x, const fmpz_t y) - void qqbar_div_ui(qqbar_t res, const qqbar_t x, ulong y) - void qqbar_div_si(qqbar_t res, const qqbar_t x, slong y) - void qqbar_fmpq_div(qqbar_t res, const fmpq_t x, const qqbar_t y) - void qqbar_fmpz_div(qqbar_t res, const fmpz_t x, const qqbar_t y) - void qqbar_ui_div(qqbar_t res, ulong x, const qqbar_t y) - void qqbar_si_div(qqbar_t res, slong x, const qqbar_t y) + void qqbar_div(qqbar_t res, const qqbar_t x, const qqbar_t y) noexcept + void qqbar_div_fmpq(qqbar_t res, const qqbar_t x, const fmpq_t y) noexcept + void qqbar_div_fmpz(qqbar_t res, const qqbar_t x, const fmpz_t y) noexcept + void qqbar_div_ui(qqbar_t res, const qqbar_t x, ulong y) noexcept + void qqbar_div_si(qqbar_t res, const qqbar_t x, slong y) noexcept + void qqbar_fmpq_div(qqbar_t res, const fmpq_t x, const qqbar_t y) noexcept + void qqbar_fmpz_div(qqbar_t res, const fmpz_t x, const qqbar_t y) noexcept + void qqbar_ui_div(qqbar_t res, ulong x, const qqbar_t y) noexcept + void qqbar_si_div(qqbar_t res, slong x, const qqbar_t y) noexcept # Sets *res* to the quotient of *x* and *y*. # Division by zero calls *flint_abort*. - void qqbar_scalar_op(qqbar_t res, const qqbar_t x, const fmpz_t a, const fmpz_t b, const fmpz_t c) + void qqbar_scalar_op(qqbar_t res, const qqbar_t x, const fmpz_t a, const fmpz_t b, const fmpz_t c) noexcept # Sets *res* to the rational affine transformation `(ax+b)/c`, performed as # a single operation. There are no restrictions on *a*, *b* and *c* # except that *c* must be nonzero. Division by zero calls *flint_abort*. - void qqbar_sqrt(qqbar_t res, const qqbar_t x) - void qqbar_sqrt_ui(qqbar_t res, ulong x) + void qqbar_sqrt(qqbar_t res, const qqbar_t x) noexcept + void qqbar_sqrt_ui(qqbar_t res, ulong x) noexcept # Sets *res* to the principal square root of *x*. - void qqbar_rsqrt(qqbar_t res, const qqbar_t x) + void qqbar_rsqrt(qqbar_t res, const qqbar_t x) noexcept # Sets *res* to the reciprocal of the principal square root of *x*. # Division by zero calls *flint_abort*. - void qqbar_pow_ui(qqbar_t res, const qqbar_t x, ulong n) - void qqbar_pow_si(qqbar_t res, const qqbar_t x, slong n) - void qqbar_pow_fmpz(qqbar_t res, const qqbar_t x, const fmpz_t n) - void qqbar_pow_fmpq(qqbar_t res, const qqbar_t x, const fmpq_t n) + void qqbar_pow_ui(qqbar_t res, const qqbar_t x, ulong n) noexcept + void qqbar_pow_si(qqbar_t res, const qqbar_t x, slong n) noexcept + void qqbar_pow_fmpz(qqbar_t res, const qqbar_t x, const fmpz_t n) noexcept + void qqbar_pow_fmpq(qqbar_t res, const qqbar_t x, const fmpq_t n) noexcept # Sets *res* to *x* raised to the *n*-th power. # Raising zero to a negative power aborts. - void qqbar_root_ui(qqbar_t res, const qqbar_t x, ulong n) - void qqbar_fmpq_root_ui(qqbar_t res, const fmpq_t x, ulong n) + void qqbar_root_ui(qqbar_t res, const qqbar_t x, ulong n) noexcept + void qqbar_fmpq_root_ui(qqbar_t res, const fmpq_t x, ulong n) noexcept # Sets *res* to the principal *n*-th root of *x*. The order *n* # must be positive. - void qqbar_fmpq_pow_si_ui(qqbar_t res, const fmpq_t x, slong m, ulong n) + void qqbar_fmpq_pow_si_ui(qqbar_t res, const fmpq_t x, slong m, ulong n) noexcept # Sets *res* to the principal branch of `x^{m/n}`. The order *n* # must be positive. Division by zero calls *flint_abort*. - int qqbar_pow(qqbar_t res, const qqbar_t x, const qqbar_t y) + int qqbar_pow(qqbar_t res, const qqbar_t x, const qqbar_t y) noexcept # General exponentiation: if `x^y` is an algebraic number, sets *res* # to this value and returns 1. If `x^y` is transcendental or # undefined, returns 0. Note that this function returns 0 instead of # aborting on division zero. - void qqbar_get_acb(acb_t res, const qqbar_t x, slong prec) + void qqbar_get_acb(acb_t res, const qqbar_t x, slong prec) noexcept # Sets *res* to an enclosure of *x* rounded to *prec* bits. - void qqbar_get_arb(arb_t res, const qqbar_t x, slong prec) + void qqbar_get_arb(arb_t res, const qqbar_t x, slong prec) noexcept # Sets *res* to an enclosure of *x* rounded to *prec* bits, assuming that # *x* is a real number. If *x* is not real, *res* is set to # `[\operatorname{NaN} \pm \infty]`. - void qqbar_get_arb_re(arb_t res, const qqbar_t x, slong prec) + void qqbar_get_arb_re(arb_t res, const qqbar_t x, slong prec) noexcept # Sets *res* to an enclosure of the real part of *x* rounded to *prec* bits. - void qqbar_get_arb_im(arb_t res, const qqbar_t x, slong prec) + void qqbar_get_arb_im(arb_t res, const qqbar_t x, slong prec) noexcept # Sets *res* to an enclosure of the imaginary part of *x* rounded to *prec* bits. - void qqbar_cache_enclosure(qqbar_t res, slong prec) + void qqbar_cache_enclosure(qqbar_t res, slong prec) noexcept # Polishes the internal enclosure of *res* to at least *prec* bits # of precision in-place. Normally, *qqbar* operations that need # high-precision enclosures compute them on the fly without caching the results; # if *res* will be used as an invariant operand for many operations, # calling this function as a precomputation step can improve performance. - void qqbar_denominator(fmpz_t res, const qqbar_t y) + void qqbar_denominator(fmpz_t res, const qqbar_t y) noexcept # Sets *res* to the denominator of *y*, i.e. the leading coefficient # of the minimal polynomial of *y*. - void qqbar_numerator(qqbar_t res, const qqbar_t y) + void qqbar_numerator(qqbar_t res, const qqbar_t y) noexcept # Sets *res* to the numerator of *y*, i.e. *y* multiplied by # its denominator. - void qqbar_conjugates(qqbar_ptr res, const qqbar_t x) + void qqbar_conjugates(qqbar_ptr res, const qqbar_t x) noexcept # Sets the entries of the vector *res* to the *d* algebraic conjugates of # *x*, including *x* itself, where *d* is the degree of *x*. The output # is sorted in a canonical order (as defined by :func:`qqbar_cmp_root_order`). - void _qqbar_evaluate_fmpq_poly(qqbar_t res, const fmpz * poly, const fmpz_t den, slong len, const qqbar_t x) - void qqbar_evaluate_fmpq_poly(qqbar_t res, const fmpq_poly_t poly, const qqbar_t x) - void _qqbar_evaluate_fmpz_poly(qqbar_t res, const fmpz * poly, slong len, const qqbar_t x) - void qqbar_evaluate_fmpz_poly(qqbar_t res, const fmpz_poly_t poly, const qqbar_t x) + void _qqbar_evaluate_fmpq_poly(qqbar_t res, const fmpz * poly, const fmpz_t den, slong len, const qqbar_t x) noexcept + void qqbar_evaluate_fmpq_poly(qqbar_t res, const fmpq_poly_t poly, const qqbar_t x) noexcept + void _qqbar_evaluate_fmpz_poly(qqbar_t res, const fmpz * poly, slong len, const qqbar_t x) noexcept + void qqbar_evaluate_fmpz_poly(qqbar_t res, const fmpz_poly_t poly, const qqbar_t x) noexcept # Sets *res* to the value of the given polynomial *poly* evaluated at # the algebraic number *x*. These methods detect simple special cases and # automatically reduce *poly* if its degree is greater or equal # to that of the minimal polynomial of *x*. In the generic case, evaluation # is done by computing minimal polynomials of representation matrices. - int qqbar_evaluate_fmpz_mpoly_iter(qqbar_t res, const fmpz_mpoly_t poly, qqbar_srcptr x, slong deg_limit, slong bits_limit, const fmpz_mpoly_ctx_t ctx) - int qqbar_evaluate_fmpz_mpoly_horner(qqbar_t res, const fmpz_mpoly_t poly, qqbar_srcptr x, slong deg_limit, slong bits_limit, const fmpz_mpoly_ctx_t ctx) - int qqbar_evaluate_fmpz_mpoly(qqbar_t res, const fmpz_mpoly_t poly, qqbar_srcptr x, slong deg_limit, slong bits_limit, const fmpz_mpoly_ctx_t ctx) + int qqbar_evaluate_fmpz_mpoly_iter(qqbar_t res, const fmpz_mpoly_t poly, qqbar_srcptr x, slong deg_limit, slong bits_limit, const fmpz_mpoly_ctx_t ctx) noexcept + int qqbar_evaluate_fmpz_mpoly_horner(qqbar_t res, const fmpz_mpoly_t poly, qqbar_srcptr x, slong deg_limit, slong bits_limit, const fmpz_mpoly_ctx_t ctx) noexcept + int qqbar_evaluate_fmpz_mpoly(qqbar_t res, const fmpz_mpoly_t poly, qqbar_srcptr x, slong deg_limit, slong bits_limit, const fmpz_mpoly_ctx_t ctx) noexcept # Sets *res* to the value of *poly* evaluated at the algebraic numbers # given in the vector *x*. The number of variables is defined by # the context object *ctx*. @@ -373,8 +373,8 @@ cdef extern from "flint_wrap.h": # implementation of the Horner scheme. The default algorithm currently # uses the Horner scheme. - void qqbar_roots_fmpz_poly(qqbar_ptr res, const fmpz_poly_t poly, int flags) - void qqbar_roots_fmpq_poly(qqbar_ptr res, const fmpq_poly_t poly, int flags) + void qqbar_roots_fmpz_poly(qqbar_ptr res, const fmpz_poly_t poly, int flags) noexcept + void qqbar_roots_fmpq_poly(qqbar_ptr res, const fmpq_poly_t poly, int flags) noexcept # Sets the entries of the vector *res* to the *d* roots of the polynomial # *poly*. Roots with multiplicity appear with repetition in the # output array. By default, the roots will be sorted in a @@ -388,80 +388,80 @@ cdef extern from "flint_wrap.h": # to be sorted (except for repeated roots being listed # consecutively). - void qqbar_eigenvalues_fmpz_mat(qqbar_ptr res, const fmpz_mat_t mat, int flags) - void qqbar_eigenvalues_fmpq_mat(qqbar_ptr res, const fmpq_mat_t mat, int flags) + void qqbar_eigenvalues_fmpz_mat(qqbar_ptr res, const fmpz_mat_t mat, int flags) noexcept + void qqbar_eigenvalues_fmpq_mat(qqbar_ptr res, const fmpq_mat_t mat, int flags) noexcept # Sets the entries of the vector *res* to the eigenvalues of the # square matrix *mat*. These functions compute the characteristic polynomial # of *mat* and then call :func:`qqbar_roots_fmpz_poly` with the same # flags. - void qqbar_root_of_unity(qqbar_t res, slong p, ulong q) + void qqbar_root_of_unity(qqbar_t res, slong p, ulong q) noexcept # Sets *res* to the root of unity `e^{2 \pi i p / q}`. - bint qqbar_is_root_of_unity(slong * p, ulong * q, const qqbar_t x) + bint qqbar_is_root_of_unity(slong * p, ulong * q, const qqbar_t x) noexcept # If *x* is not a root of unity, returns 0. # If *x* is a root of unity, returns 1. # If *p* and *q* are not *NULL* and *x* is a root of unity, # this also sets *p* and *q* to the minimal integers with `0 \le p < q` # such that `x = e^{2 \pi i p / q}`. - void qqbar_exp_pi_i(qqbar_t res, slong p, ulong q) + void qqbar_exp_pi_i(qqbar_t res, slong p, ulong q) noexcept # Sets *res* to the root of unity `e^{\pi i p / q}`. - void qqbar_cos_pi(qqbar_t res, slong p, ulong q) - void qqbar_sin_pi(qqbar_t res, slong p, ulong q) - int qqbar_tan_pi(qqbar_t res, slong p, ulong q) - int qqbar_cot_pi(qqbar_t res, slong p, ulong q) - int qqbar_sec_pi(qqbar_t res, slong p, ulong q) - int qqbar_csc_pi(qqbar_t res, slong p, ulong q) + void qqbar_cos_pi(qqbar_t res, slong p, ulong q) noexcept + void qqbar_sin_pi(qqbar_t res, slong p, ulong q) noexcept + int qqbar_tan_pi(qqbar_t res, slong p, ulong q) noexcept + int qqbar_cot_pi(qqbar_t res, slong p, ulong q) noexcept + int qqbar_sec_pi(qqbar_t res, slong p, ulong q) noexcept + int qqbar_csc_pi(qqbar_t res, slong p, ulong q) noexcept # Sets *res* to the trigonometric function `\cos(\pi x)`, # `\sin(\pi x)`, etc., with `x = \tfrac{p}{q}`. # The functions tan, cot, sec and csc return the flag 1 if the value exists, # and return 0 if the evaluation point is a pole of the function. - int qqbar_log_pi_i(slong * p, ulong * q, const qqbar_t x) + int qqbar_log_pi_i(slong * p, ulong * q, const qqbar_t x) noexcept # If `y = \operatorname{log}(x) / (\pi i)` is algebraic, and hence # necessarily rational, sets `y = p / q` to the reduced such # fraction with `-1 < y \le 1` and returns 1. # If *y* is not algebraic, returns 0. - int qqbar_atan_pi(slong * p, ulong * q, const qqbar_t x) + int qqbar_atan_pi(slong * p, ulong * q, const qqbar_t x) noexcept # If `y = \operatorname{atan}(x) / \pi` is algebraic, and hence # necessarily rational, sets `y = p / q` to the reduced such # fraction with `|y| < \tfrac{1}{2}` and returns 1. # If *y* is not algebraic, returns 0. - int qqbar_asin_pi(slong * p, ulong * q, const qqbar_t x) + int qqbar_asin_pi(slong * p, ulong * q, const qqbar_t x) noexcept # If `y = \operatorname{asin}(x) / \pi` is algebraic, and hence # necessarily rational, sets `y = p / q` to the reduced such # fraction with `|y| \le \tfrac{1}{2}` and returns 1. # If *y* is not algebraic, returns 0. - int qqbar_acos_pi(slong * p, ulong * q, const qqbar_t x) + int qqbar_acos_pi(slong * p, ulong * q, const qqbar_t x) noexcept # If `y = \operatorname{acos}(x) / \pi` is algebraic, and hence # necessarily rational, sets `y = p / q` to the reduced such # fraction with `0 \le y \le 1` and returns 1. # If *y* is not algebraic, returns 0. - int qqbar_acot_pi(slong * p, ulong * q, const qqbar_t x) + int qqbar_acot_pi(slong * p, ulong * q, const qqbar_t x) noexcept # If `y = \operatorname{acot}(x) / \pi` is algebraic, and hence # necessarily rational, sets `y = p / q` to the reduced such # fraction with `-\tfrac{1}{2} < y \le \tfrac{1}{2}` and returns 1. # If *y* is not algebraic, returns 0. - int qqbar_asec_pi(slong * p, ulong * q, const qqbar_t x) + int qqbar_asec_pi(slong * p, ulong * q, const qqbar_t x) noexcept # If `y = \operatorname{asec}(x) / \pi` is algebraic, and hence # necessarily rational, sets `y = p / q` to the reduced such # fraction with `0 \le y \le 1` and returns 1. # If *y* is not algebraic, returns 0. - int qqbar_acsc_pi(slong * p, ulong * q, const qqbar_t x) + int qqbar_acsc_pi(slong * p, ulong * q, const qqbar_t x) noexcept # If `y = \operatorname{acsc}(x) / \pi` is algebraic, and hence # necessarily rational, sets `y = p / q` to the reduced such # fraction with `-\tfrac{1}{2} \le y \le \tfrac{1}{2}` and returns 1. # If *y* is not algebraic, returns 0. - int qqbar_guess(qqbar_t res, const acb_t z, slong max_deg, slong max_bits, int flags, slong prec) + int qqbar_guess(qqbar_t res, const acb_t z, slong max_deg, slong max_bits, int flags, slong prec) noexcept # Attempts to find an algebraic number *res* of degree at most *max_deg* and # height at most *max_bits* bits matching the numerical enclosure *z*. # The return flag indicates success. @@ -478,7 +478,7 @@ cdef extern from "flint_wrap.h": # repeatedly with successively larger parameters when the size of the # intended solution is unknown or may be much smaller than a worst-case bound. - int qqbar_express_in_field(fmpq_poly_t res, const qqbar_t alpha, const qqbar_t x, slong max_bits, int flags, slong prec) + int qqbar_express_in_field(fmpq_poly_t res, const qqbar_t alpha, const qqbar_t x, slong max_bits, int flags, slong prec) noexcept # Attempts to express *x* in the number field generated by *alpha*, returning # success (0 or 1). On success, *res* is set to a polynomial *f* of degree # less than the degree of *alpha* and with height (counting both the numerator @@ -500,7 +500,7 @@ cdef extern from "flint_wrap.h": # repeatedly with successively larger parameters when the size of the # intended solution is unknown or may be much smaller than a worst-case bound. - void qqbar_get_quadratic(fmpz_t a, fmpz_t b, fmpz_t c, fmpz_t q, const qqbar_t x, int factoring) + void qqbar_get_quadratic(fmpz_t a, fmpz_t b, fmpz_t c, fmpz_t q, const qqbar_t x, int factoring) noexcept # Assuming that *x* has degree 1 or 2, computes integers *a*, *b*, *c* # and *q* such that # .. math :: @@ -530,7 +530,7 @@ cdef extern from "flint_wrap.h": # (up to some trial division limit determined internally by Flint), # but large factors are only found heuristically. - int qqbar_set_fexpr(qqbar_t res, const fexpr_t expr) + int qqbar_set_fexpr(qqbar_t res, const fexpr_t expr) noexcept # Sets *res* to the algebraic number represented by the symbolic # expression *expr*, returning 1 on success and 0 on failure. # This function performs a "static" evaluation using *qqbar* arithmetic, @@ -560,7 +560,7 @@ cdef extern from "flint_wrap.h": # * ``1 / Infinity`` (only numbers are handled) # * ``Sum(n, For(n, 1, 10))`` (only static evaluation is performed) - void qqbar_get_fexpr_repr(fexpr_t res, const qqbar_t x) + void qqbar_get_fexpr_repr(fexpr_t res, const qqbar_t x) noexcept # Sets *res* to a symbolic expression reflecting the exact internal # representation of *x*. The output will have the form # ``AlgebraicNumberSerialized(List(coeffs), enclosure)``. @@ -569,7 +569,7 @@ cdef extern from "flint_wrap.h": # serializing algebraic numbers as it requires minimal computation, # but it has the disadvantage of not being human-readable. - void qqbar_get_fexpr_root_nearest(fexpr_t res, const qqbar_t x) + void qqbar_get_fexpr_root_nearest(fexpr_t res, const qqbar_t x) noexcept # Sets *res* to a symbolic expression unambiguously describing *x* # in the form ``PolynomialRootNearest(List(coeffs), point)`` # where *point* is an approximation of *x* guaranteed to be closer @@ -578,7 +578,7 @@ cdef extern from "flint_wrap.h": # :func:`qqbar_set_fexpr`. This is a useful format for human-readable # presentation, but serialization and deserialization can be expensive. - void qqbar_get_fexpr_root_indexed(fexpr_t res, const qqbar_t x) + void qqbar_get_fexpr_root_indexed(fexpr_t res, const qqbar_t x) noexcept # Sets *res* to a symbolic expression unambiguously describing *x* # in the form ``PolynomialRootIndexed(List(coeffs), index)`` # where *index* is the index of *x* among its conjugate roots @@ -588,7 +588,7 @@ cdef extern from "flint_wrap.h": # presentation when the numerical value is important, but serialization # and deserialization can be expensive. - int qqbar_get_fexpr_formula(fexpr_t res, const qqbar_t x, ulong flags) + int qqbar_get_fexpr_formula(fexpr_t res, const qqbar_t x, ulong flags) noexcept # Attempts to express the algebraic number *x* as a closed-form expression # using arithmetic operations, radicals, and possibly exponentials # or trigonometric functions, but without using ``PolynomialRootNearest`` @@ -638,18 +638,18 @@ cdef extern from "flint_wrap.h": # for nonreal numbers. The other flags (not fully implemented) can be # used to force exponential form, trigonometric form, or radical form. - void qqbar_fmpz_poly_composed_op(fmpz_poly_t res, const fmpz_poly_t A, const fmpz_poly_t B, int op) + void qqbar_fmpz_poly_composed_op(fmpz_poly_t res, const fmpz_poly_t A, const fmpz_poly_t B, int op) noexcept # Given nonconstant polynomials *A* and *B*, sets *res* to a polynomial # whose roots are `a+b`, `a-b`, `ab` or `a/b` for all roots *a* of *A* # and all roots *b* of *B*. The parameter *op* selects the arithmetic # operation: 0 for addition, 1 for subtraction, 2 for multiplication # and 3 for division. If *op* is 3, *B* must not have zero as a root. - void qqbar_binary_op(qqbar_t res, const qqbar_t x, const qqbar_t y, int op) + void qqbar_binary_op(qqbar_t res, const qqbar_t x, const qqbar_t y, int op) noexcept # Performs a binary operation using a generic algorithm. This does not # check for special cases. - int _qqbar_validate_uniqueness(acb_t res, const fmpz_poly_t poly, const acb_t z, slong max_prec) + int _qqbar_validate_uniqueness(acb_t res, const fmpz_poly_t poly, const acb_t z, slong max_prec) noexcept # Given *z* known to be an enclosure of at least one root of *poly*, # certifies that the enclosure contains a unique root, and in that # case sets *res* to a new (possibly improved) enclosure for the same @@ -663,7 +663,7 @@ cdef extern from "flint_wrap.h": # existence; when existence has not been ensured a priori, # :func:`_qqbar_validate_existence_uniqueness` should be used instead. - int _qqbar_validate_existence_uniqueness(acb_t res, const fmpz_poly_t poly, const acb_t z, slong max_prec) + int _qqbar_validate_existence_uniqueness(acb_t res, const fmpz_poly_t poly, const acb_t z, slong max_prec) noexcept # Given any complex interval *z*, certifies that the enclosure contains a # unique root of *poly*, and in that case sets *res* to a new (possibly # improved) enclosure for the same root, returning 1. Returns 0 if @@ -672,8 +672,8 @@ cdef extern from "flint_wrap.h": # interval Newton method. The working precision is determined from the # accuracy of *z*, but limited by *max_prec* bits. - void _qqbar_enclosure_raw(acb_t res, const fmpz_poly_t poly, const acb_t z, slong prec) - void qqbar_enclosure_raw(acb_t res, const qqbar_t x, slong prec) + void _qqbar_enclosure_raw(acb_t res, const fmpz_poly_t poly, const acb_t z, slong prec) noexcept + void qqbar_enclosure_raw(acb_t res, const qqbar_t x, slong prec) noexcept # Sets *res* to an enclosure of *x* accurate to about *prec* bits # (the actual accuracy can be slightly lower, or higher). # This function uses repeated interval Newton steps to polish the initial @@ -683,7 +683,7 @@ cdef extern from "flint_wrap.h": # If the initial enclosure is accurate enough, *res* is set to this value # without rounding and without further computation. - int _qqbar_acb_lindep(fmpz * rel, acb_srcptr vec, slong len, int check, slong prec) + int _qqbar_acb_lindep(fmpz * rel, acb_srcptr vec, slong len, int check, slong prec) noexcept # Attempts to find an integer vector *rel* giving a linear relation between # the elements of the real or complex vector *vec*, using the LLL algorithm. # The working precision is set to the minimum of *prec* and the relative diff --git a/src/sage/libs/flint/qsieve.pxd b/src/sage/libs/flint/qsieve.pxd index 170ffef4339..a8ffecc5e13 100644 --- a/src/sage/libs/flint/qsieve.pxd +++ b/src/sage/libs/flint/qsieve.pxd @@ -12,21 +12,21 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - mp_limb_t qsieve_knuth_schroeppel(qs_t qs_inf) + mp_limb_t qsieve_knuth_schroeppel(qs_t qs_inf) noexcept # Return the Knuth-Schroeppel multiplier for the `n`, integer to be factored # based upon the Knuth-Schroeppel function. - mp_limb_t qsieve_primes_init(qs_t qs_inf) + mp_limb_t qsieve_primes_init(qs_t qs_inf) noexcept # Compute the factor base prime along with there inverse for `kn`, where `k` # is Knuth-Schroeppel multiplier and `n` is the integer to be factored. It # also computes the square root of `kn` modulo factor base primes. - mp_limb_t qsieve_primes_increment(qs_t qs_inf, mp_limb_t delta) + mp_limb_t qsieve_primes_increment(qs_t qs_inf, mp_limb_t delta) noexcept # It increase the number of factor base primes by amount 'delta' and # calculate inverse of those primes along with the square root of `kn` modulo # those primes. - void qsieve_init_A0(qs_t qs_inf) + void qsieve_init_A0(qs_t qs_inf) noexcept # First it chooses the possible range of factor of `A _0`, based on the number # of bits in optimal value of `A _0`. It tries to select range such that we have # plenty of primes to choose from as well as number of factor in `A _0` are @@ -38,93 +38,93 @@ cdef extern from "flint_wrap.h": # factor using binary search from the even indices of possible range of factor # such that value of `A _0` is close to it's optimal value. - void qsieve_next_A0(qs_t qs_inf) + void qsieve_next_A0(qs_t qs_inf) noexcept # Find next candidate for `A _0` as follows: # generate next lexicographic `s - 1`-subset from the odd indices of possible # range of factor base and choose the last factor from even indices using binary # search so that value `A _0` is close to it's optimal value. - void qsieve_compute_pre_data(qs_t qs_inf) + void qsieve_compute_pre_data(qs_t qs_inf) noexcept # Precompute all the data associated with factor's of `A _0`, since `A _0` is going # to be fixed for several `A`. - void qsieve_init_poly_first(qs_t qs_inf) + void qsieve_init_poly_first(qs_t qs_inf) noexcept # Initializes the value of `A = q _0 * A _0`, where `q _0` is non-factor base prime. # precompute the data necessary for generating different `B` value using grey code # formula. Combine the data calculated for the factor of `A _0` along with the # parameter `q _0` to obtain data as for factor of `A`. It also calculates the sieve # offset for all the factor base prime, for first polynomial. - void qsieve_init_poly_next(qs_t qs_inf, slong i) + void qsieve_init_poly_next(qs_t qs_inf, slong i) noexcept # Generate next polynomial or next `B` value for particular `A` and also updates the # sieve offsets for all the factor base prime, for this `B` value. - void qsieve_compute_C(fmpz_t C, qs_t qs_inf, qs_poly_t poly) + void qsieve_compute_C(fmpz_t C, qs_t qs_inf, qs_poly_t poly) noexcept # Given `A` and `B`, calculate `C = (B ^2 - A) / N`. - void qsieve_do_sieving(qs_t qs_inf, unsigned char * sieve, qs_poly_t poly) + void qsieve_do_sieving(qs_t qs_inf, unsigned char * sieve, qs_poly_t poly) noexcept # First initialize the sieve array to zero, then for each `p \in` ``factor base``, add # `\log_2(p)` to the locations `\operatorname{soln1} _p + i * p` and `\operatorname{soln2} _p + i * p` for # `i = 0, 1, 2,\dots`, where `\operatorname{soln1} _p` and `\operatorname{soln2} _p` are the sieve offsets calculated # for `p`. - void qsieve_do_sieving2(qs_t qs_inf, unsigned char * seive, qs_poly_t poly) + void qsieve_do_sieving2(qs_t qs_inf, unsigned char * seive, qs_poly_t poly) noexcept # Perform the same task as above but instead of sieving over whole array at once divide # the array in blocks and then sieve over each block for all the primes in factor base. - slong qsieve_evaluate_candidate(qs_t qs_inf, ulong i, unsigned char * sieve, qs_poly_t poly) + slong qsieve_evaluate_candidate(qs_t qs_inf, ulong i, unsigned char * sieve, qs_poly_t poly) noexcept # For location `i` in sieve array value at which, is greater than sieve threshold, check # the value of `Q(x)` at position `i` for smoothness. If value is found to be smooth then # store it for later processing, else check the residue for the partial if it is found to # be partial then store it for late processing. - slong qsieve_evaluate_sieve(qs_t qs_inf, unsigned char * sieve, qs_poly_t poly) + slong qsieve_evaluate_sieve(qs_t qs_inf, unsigned char * sieve, qs_poly_t poly) noexcept # Scan the sieve array for location at, which accumulated value is greater than sieve # threshold. - slong qsieve_collect_relations(qs_t qs_inf, unsigned char * sieve) + slong qsieve_collect_relations(qs_t qs_inf, unsigned char * sieve) noexcept # Call for initialization of polynomial, sieving, and scanning of sieve # for all the possible polynomials for particular hypercube i.e. `A`. - void qsieve_write_to_file(qs_t qs_inf, mp_limb_t prime, fmpz_t Y, qs_poly_t poly) + void qsieve_write_to_file(qs_t qs_inf, mp_limb_t prime, fmpz_t Y, qs_poly_t poly) noexcept # Write a relation to the file. Format is as follows, # first write large prime, in case of full relation it is 1, then write exponent # of small primes, then write number of factor followed by offset of factor in # factor base and their exponent and at last value of `Q(x)` for particular relation. # each relation is written in new line. - hash_t * qsieve_get_table_entry(qs_t qs_inf, mp_limb_t prime) + hash_t * qsieve_get_table_entry(qs_t qs_inf, mp_limb_t prime) noexcept # Return the pointer to the location of 'prime' is hash table if it exist, else # create and entry for it in hash table and return pointer to that. - void qsieve_add_to_hashtable(qs_t qs_inf, mp_limb_t prime) + void qsieve_add_to_hashtable(qs_t qs_inf, mp_limb_t prime) noexcept # Add 'prime' to the hast table. - relation_t qsieve_parse_relation(qs_t qs_inf, char * str) + relation_t qsieve_parse_relation(qs_t qs_inf, char * str) noexcept # Given a string representation of relation from the file, parse it to obtain # all the parameters of relation. - relation_t qsieve_merge_relation(qs_t qs_inf, relation_t a, relation_t b) + relation_t qsieve_merge_relation(qs_t qs_inf, relation_t a, relation_t b) noexcept # Given two partial relation having same large prime, merge them to obtain a full # relation. - int qsieve_compare_relation(const void * a, const void * b) + int qsieve_compare_relation(const void * a, const void * b) noexcept # Compare two relation based on, first large prime, then number of factor and then # offsets of factor in factor base. - int qsieve_remove_duplicates(relation_t * rel_list, slong num_relations) + int qsieve_remove_duplicates(relation_t * rel_list, slong num_relations) noexcept # Remove duplicate from given list of relations by sorting relations in the list. - void qsieve_insert_relation2(qs_t qs_inf, relation_t * rel_list, slong num_relations) + void qsieve_insert_relation2(qs_t qs_inf, relation_t * rel_list, slong num_relations) noexcept # Given a list of relations, insert each relation from the list into the matrix for # further processing. - int qsieve_process_relation(qs_t qs_inf) + int qsieve_process_relation(qs_t qs_inf) noexcept # After we have accumulated required number of relations, first process the file by # reading all the relations, removes singleton. Then merge all the possible partial # to obtain full relations. - void qsieve_factor(fmpz_factor_t factors, const fmpz_t n) + void qsieve_factor(fmpz_factor_t factors, const fmpz_t n) noexcept # Factor `n` using the quadratic sieve method. It is required that `n` is not a # prime and not a perfect power. There is no guarantee that the factors found will # be prime, or distinct. diff --git a/src/sage/libs/flint/thread_pool.pxd b/src/sage/libs/flint/thread_pool.pxd index 55517e2fee9..05f70383ef5 100644 --- a/src/sage/libs/flint/thread_pool.pxd +++ b/src/sage/libs/flint/thread_pool.pxd @@ -12,38 +12,38 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void thread_pool_init(thread_pool_t T, slong size) + void thread_pool_init(thread_pool_t T, slong size) noexcept # Initialise ``T`` and create ``size`` sleeping # threads that are available to work. # If `size \le 0` no threads are created and future calls to # :func:`thread_pool_request` will return `0` (unless # :func:`thread_pool_set_size` has been called). - slong thread_pool_get_size(thread_pool_t T) + slong thread_pool_get_size(thread_pool_t T) noexcept # Return the number of threads in ``T``. - int thread_pool_set_size(thread_pool_t T, slong new_size) + int thread_pool_set_size(thread_pool_t T, slong new_size) noexcept # If all threads in ``T`` are in the available state, resize ``T`` and return 1. # Otherwise, return ``0``. - slong thread_pool_request(thread_pool_t T, thread_pool_handle * out, slong requested) + slong thread_pool_request(thread_pool_t T, thread_pool_handle * out, slong requested) noexcept # Put at most ``requested`` threads in the unavailable state and return # their handles. The handles are written to ``out`` and the number of # handles written is returned. These threads must be released by a call to # ``thread_pool_give_back``. - void thread_pool_wake(thread_pool_t T, thread_pool_handle i, int max_workers, void (*f)(void*), void * a) + void thread_pool_wake(thread_pool_t T, thread_pool_handle i, int max_workers, void (*f)(void*), void * a) noexcept # Wake up a sleeping thread ``i`` and have it work on ``f(a)``. The thread # being woken will be allowed to start ``max_workers`` additional worker # threads. Usually this value should be set to ``0``. - void thread_pool_wait(thread_pool_t T, thread_pool_handle i) + void thread_pool_wait(thread_pool_t T, thread_pool_handle i) noexcept # Wait for thread ``i`` to finish working and go back to sleep. - void thread_pool_give_back(thread_pool_t T, thread_pool_handle i) + void thread_pool_give_back(thread_pool_t T, thread_pool_handle i) noexcept # Put thread ``i`` back in the available state. This thread should be sleeping # when this function is called. - void thread_pool_clear(thread_pool_t T) + void thread_pool_clear(thread_pool_t T) noexcept # Release any resources used by ``T``. All threads should be given back before # this function is called. diff --git a/src/sage/libs/flint/ulong_extras.pxd b/src/sage/libs/flint/ulong_extras.pxd index 1c3a82f057a..cce0a3bdffc 100644 --- a/src/sage/libs/flint/ulong_extras.pxd +++ b/src/sage/libs/flint/ulong_extras.pxd @@ -12,7 +12,7 @@ from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - ulong n_randlimb(flint_rand_t state) + ulong n_randlimb(flint_rand_t state) noexcept # Returns a uniformly pseudo random limb. # The algorithm generates two random half limbs `s_j`, `j = 0, 1`, # by iterating respectively `v_{i+1} = (v_i a + b) \bmod{p_j}` for @@ -21,31 +21,31 @@ cdef extern from "flint_wrap.h": # and ``p_0 = nextprime(2^16)`` on a 32-bit machine and # ``p_1 = nextprime(p_0)``. - ulong n_randbits(flint_rand_t state, unsigned int bits) + ulong n_randbits(flint_rand_t state, unsigned int bits) noexcept # Returns a uniformly pseudo random number with the given number of # bits. The most significant bit is always set, unless zero is passed, # in which case zero is returned. - ulong n_randtest_bits(flint_rand_t state, int bits) + ulong n_randtest_bits(flint_rand_t state, int bits) noexcept # Returns a uniformly pseudo random number with the given number of # bits. The most significant bit is always set, unless zero is passed, # in which case zero is returned. The probability of a value with a # sparse binary representation being returned is increased. This # function is intended for use in test code. - ulong n_randint(flint_rand_t state, ulong limit) + ulong n_randint(flint_rand_t state, ulong limit) noexcept # Returns a uniformly pseudo random number up to but not including # the given limit. If zero is passed as a parameter, an entire random # limb is returned. - ulong n_urandint(flint_rand_t state, ulong limit) + ulong n_urandint(flint_rand_t state, ulong limit) noexcept # Returns a uniformly pseudo random number up to but not including # the given limit. If zero is passed as a parameter, an entire # random limb is returned. This function provides somewhat better # randomness as compared to :func:`n_randint`, especially for larger # values of limit. - ulong n_randtest(flint_rand_t state) + ulong n_randtest(flint_rand_t state) noexcept # Returns a pseudo random number with a random number of bits, # from `0` to ``FLINT_BITS``. The probability of the special # values `0`, `1`, ``COEFF_MAX`` and ``WORD_MAX`` is increased @@ -53,50 +53,50 @@ cdef extern from "flint_wrap.h": # This random function is mainly used for testing purposes. # This function is intended for use in test code. - ulong n_randtest_not_zero(flint_rand_t state) + ulong n_randtest_not_zero(flint_rand_t state) noexcept # As for :func:`n_randtest`, but does not return `0`. # This function is intended for use in test code. - ulong n_randprime(flint_rand_t state, ulong bits, int proved) + ulong n_randprime(flint_rand_t state, ulong bits, int proved) noexcept # Returns a random prime number ``(proved = 1)`` or probable prime # ``(proved = 0)`` # with ``bits`` bits, where ``bits`` must be at least 2 and # at most ``FLINT_BITS``. - ulong n_randtest_prime(flint_rand_t state, int proved) + ulong n_randtest_prime(flint_rand_t state, int proved) noexcept # Returns a random prime number ``(proved = 1)`` or probable # prime ``(proved = 0)`` # with size randomly chosen between 2 and ``FLINT_BITS`` bits. # This function is intended for use in test code. - ulong n_pow(ulong n, ulong exp) + ulong n_pow(ulong n, ulong exp) noexcept # Returns ``n^exp``. No checking is done for overflow. The exponent # may be zero. We define `0^0 = 1`. # The algorithm simply uses a for loop. Repeated squaring is # unlikely to speed up this algorithm. - ulong n_flog(ulong n, ulong b) + ulong n_flog(ulong n, ulong b) noexcept # Returns `\lfloor\log_b n\rfloor`. # Assumes that `n \geq 1` and `b \geq 2`. - ulong n_clog(ulong n, ulong b) + ulong n_clog(ulong n, ulong b) noexcept # Returns `\lceil\log_b n\rceil`. # Assumes that `n \geq 1` and `b \geq 2`. - ulong n_clog_2exp(ulong n, ulong b) + ulong n_clog_2exp(ulong n, ulong b) noexcept # Returns `\lceil\log_b 2^n\rceil`. # Assumes that `b \geq 2`. - ulong n_revbin(ulong n, ulong b) + ulong n_revbin(ulong n, ulong b) noexcept # Returns the binary reverse of `n`, assuming it is `b` bits in length, # e.g. ``n_revbin(10110, 6)`` will return ``110100``. - int n_sizeinbase(ulong n, int base) + int n_sizeinbase(ulong n, int base) noexcept # Returns the exact number of digits needed to represent `n` as a # string in base ``base`` assumed to be between 2 and 36. # Returns 1 when `n = 0`. - ulong n_preinvert_limb_prenorm(ulong n) + ulong n_preinvert_limb_prenorm(ulong n) noexcept # Computes an approximate inverse ``invxl`` of the limb ``xl``, # with an implicit leading~`1`. More formally it computes:: # invxl = (B^2 - B*x - 1)/x = (B^2 - 1)/x - B @@ -119,19 +119,19 @@ cdef extern from "flint_wrap.h": # then from the theorem, we have `0 \leq n - q_1 d < 3 d`, i.e. the # quotient is out by at most `2` and is always either correct or too small. - ulong n_preinvert_limb(ulong n) + ulong n_preinvert_limb(ulong n) noexcept # Returns a precomputed inverse of `n`, as defined in [GraMol2010]_. # This precomputed inverse can be used with all of the functions that # take a precomputed inverse whose names are suffixed by ``_preinv``. # We require `n > 0`. - double n_precompute_inverse(ulong n) + double n_precompute_inverse(ulong n) noexcept # Returns a precomputed inverse of `n` with double precision value `1/n`. # This precomputed inverse can be used with all of the functions that # take a precomputed inverse whose names are suffixed by ``_precomp``. # We require `n > 0`. - ulong n_mod_precomp(ulong a, ulong n, double ninv) + ulong n_mod_precomp(ulong a, ulong n, double ninv) noexcept # Returns `a \bmod{n}` given a precomputed inverse of `n` computed # by :func:`n_precompute_inverse`. We require ``n < 2^FLINT_D_BITS`` # and ``a < 2^(FLINT_BITS-1)`` and `0 \leq a < n^2`. @@ -159,7 +159,7 @@ cdef extern from "flint_wrap.h": # subtracting 1 from the quotient. Then the quotient we have computed is # either exactly what we are after, or one too small. - ulong n_mod2_precomp(ulong a, ulong n, double ninv) + ulong n_mod2_precomp(ulong a, ulong n, double ninv) noexcept # Returns `a \bmod{n}` given a precomputed inverse of `n` computed by # :func:`n_precompute_inverse`. There are no restrictions on `a` or # on `n`. @@ -173,7 +173,7 @@ cdef extern from "flint_wrap.h": # negative or positive, so the quotient we compute may be one # out in either direction. - ulong n_divrem2_preinv(ulong * q, ulong a, ulong n, ulong ninv) + ulong n_divrem2_preinv(ulong * q, ulong a, ulong n, ulong ninv) noexcept # Returns `a \bmod{n}` and sets `q` to the quotient of `a` by `n`, given a # precomputed inverse of `n` computed by :func:`n_preinvert_limb()`. There are # no restrictions on `a` and the only restriction on `n` is that it be @@ -182,7 +182,7 @@ cdef extern from "flint_wrap.h": # `n` is normalised and `a` is shifted into two limbs to compensate. Then # their algorithm is applied verbatim and the remainder shifted back. - ulong n_div2_preinv(ulong a, ulong n, ulong ninv) + ulong n_div2_preinv(ulong a, ulong n, ulong ninv) noexcept # Returns the Euclidean quotient of `a` by `n` given a precomputed inverse of # `n` computed by :func:`n_preinvert_limb`. There are no restrictions on `a` # and the only restriction on `n` is that it be nonzero. @@ -190,7 +190,7 @@ cdef extern from "flint_wrap.h": # `n` is normalised and `a` is shifted into two limbs to compensate. Then # their algorithm is applied verbatim. - ulong n_mod2_preinv(ulong a, ulong n, ulong ninv) + ulong n_mod2_preinv(ulong a, ulong n, ulong ninv) noexcept # Returns `a \bmod{n}` given a precomputed inverse of `n` computed by # :func:`n_preinvert_limb()`. There are no restrictions on `a` and the only # restriction on `n` is that it be nonzero. @@ -198,7 +198,7 @@ cdef extern from "flint_wrap.h": # `n` is normalised and `a` is shifted into two limbs to compensate. Then # their algorithm is applied verbatim and the result shifted back. - ulong n_divrem2_precomp(ulong * q, ulong a, ulong n, double npre) + ulong n_divrem2_precomp(ulong * q, ulong a, ulong n, double npre) noexcept # Returns `a \bmod{n}` given a precomputed inverse of `n` computed by # :func:`n_precompute_inverse` and sets `q` to the quotient. There # are no restrictions on `a` or on `n`. @@ -207,7 +207,7 @@ cdef extern from "flint_wrap.h": # cases to deal with the case where `a` is already reduced modulo # `n` and where `n` is `64` bits and `a` is not reduced modulo `n`. - ulong n_ll_mod_preinv(ulong a_hi, ulong a_lo, ulong n, ulong ninv) + ulong n_ll_mod_preinv(ulong a_hi, ulong a_lo, ulong n, ulong ninv) noexcept # Returns `a \bmod{n}` given a precomputed inverse of `n` computed by # :func:`n_preinvert_limb`. There are no restrictions on `a`, which # will be two limbs ``(a_hi, a_lo)``, or on `n`. @@ -218,7 +218,7 @@ cdef extern from "flint_wrap.h": # :func:`n_mod2_preinv` and then the algorithm of Granlund and # Möller [GraMol2010]_ is used again to reduce modulo `n`. - ulong n_lll_mod_preinv(ulong a_hi, ulong a_mi, ulong a_lo, ulong n, ulong ninv) + ulong n_lll_mod_preinv(ulong a_hi, ulong a_mi, ulong a_lo, ulong n, ulong ninv) noexcept # Returns `a \bmod{n}`, where `a` has three limbs ``(a_hi, a_mi, a_lo)``, # given a precomputed inverse of `n` computed by :func:`n_preinvert_limb`. # It is assumed that ``a_hi`` is reduced modulo `n`. There are no @@ -227,7 +227,7 @@ cdef extern from "flint_wrap.h": # Möller [GraMol2010]_ to first reduce the top two limbs # modulo `n`, then does the same on the bottom two limbs. - ulong n_mulmod_precomp(ulong a, ulong b, ulong n, double ninv) + ulong n_mulmod_precomp(ulong a, ulong b, ulong n, double ninv) noexcept # Returns `a b \bmod{n}` given a precomputed inverse of `n` # computed by :func:`n_precompute_inverse`. We require # ``n < 2^FLINT_D_BITS`` and `0 \leq a, b < n`. @@ -247,19 +247,19 @@ cdef extern from "flint_wrap.h": # computed integer quotient is at most two above and one below the quotient # we are after. - ulong n_mulmod2_preinv(ulong a, ulong b, ulong n, ulong ninv) + ulong n_mulmod2_preinv(ulong a, ulong b, ulong n, ulong ninv) noexcept # Returns `a b \bmod{n}` given a precomputed inverse of `n` computed by # :func:`n_preinvert_limb`. There are no restrictions on `a`, `b` or # on `n`. This is implemented by multiplying using :func:`umul_ppmm` and # then reducing using :func:`n_ll_mod_preinv`. - ulong n_mulmod2(ulong a, ulong b, ulong n) + ulong n_mulmod2(ulong a, ulong b, ulong n) noexcept # Returns `a b \bmod{n}`. There are no restrictions on `a`, `b` or # on `n`. This is implemented by multiplying using :func:`umul_ppmm` and # then reducing using :func:`n_ll_mod_preinv` after computing a precomputed # inverse. - ulong n_mulmod_preinv(ulong a, ulong b, ulong n, ulong ninv, ulong norm) + ulong n_mulmod_preinv(ulong a, ulong b, ulong n, ulong ninv, ulong norm) noexcept # Returns `a b \pmod{n}` given a precomputed inverse of `n` computed by # :func:`n_preinvert_limb`, assuming `a` and `b` are reduced modulo `n` # and `n` is normalised, i.e. with most significant bit set. There are @@ -272,12 +272,12 @@ cdef extern from "flint_wrap.h": # reducing it. # The algorithm used is that of Granlund and Möller [GraMol2010]_. - ulong n_gcd(ulong x, ulong y) + ulong n_gcd(ulong x, ulong y) noexcept # Returns the greatest common divisor `g` of `x` and `y`. No assumptions # are made about the values `x` and `y`. # This function wraps GMP's ``mpn_gcd_1``. - ulong n_gcdinv(ulong * a, ulong x, ulong y) + ulong n_gcdinv(ulong * a, ulong x, ulong y) noexcept # Returns the greatest common divisor `g` of `x` and `y` and computes # `a` such that `0 \leq a < y` and `a x = \gcd(x, y) \bmod{y}`, when # this is defined. We require `x < y`. @@ -286,7 +286,7 @@ cdef extern from "flint_wrap.h": # This is merely an adaption of the extended Euclidean algorithm # computing just one cofactor and reducing it modulo `y`. - ulong n_xgcd(ulong * a, ulong * b, ulong x, ulong y) + ulong n_xgcd(ulong * a, ulong * b, ulong x, ulong y) noexcept # Returns the greatest common divisor `g` of `x` and `y` and unsigned # values `a` and `b` such that `a x - b y = g`. We require `x \geq y`. # We claim that computing the extended greatest common divisor via the @@ -305,25 +305,25 @@ cdef extern from "flint_wrap.h": # See the documentation of :func:`n_gcd` for a description of the # branching in the algorithm, which is faster than using division. - int n_jacobi(mp_limb_signed_t x, ulong y) + int n_jacobi(mp_limb_signed_t x, ulong y) noexcept # Computes the Jacobi symbol `\left(\frac{x}{y}\right)` for any `x` and odd `y`. - int n_jacobi_unsigned(ulong x, ulong y) + int n_jacobi_unsigned(ulong x, ulong y) noexcept # Computes the Jacobi symbol, allowing `x` to go up to a full limb. - ulong n_addmod(ulong a, ulong b, ulong n) + ulong n_addmod(ulong a, ulong b, ulong n) noexcept # Returns `(a + b) \bmod{n}`. - ulong n_submod(ulong a, ulong b, ulong n) + ulong n_submod(ulong a, ulong b, ulong n) noexcept # Returns `(a - b) \bmod{n}`. - ulong n_invmod(ulong x, ulong y) + ulong n_invmod(ulong x, ulong y) noexcept # Returns the inverse of `x` modulo `y`, if it exists. Otherwise an exception # is thrown. # This is merely an adaption of the extended Euclidean algorithm # with appropriate normalisation. - ulong n_powmod_precomp(ulong a, mp_limb_signed_t exp, ulong n, double npre) + ulong n_powmod_precomp(ulong a, mp_limb_signed_t exp, ulong n, double npre) noexcept # Returns ``a^exp`` modulo `n` given a precomputed inverse of `n` # computed by :func:`n_precompute_inverse`. We require `n < 2^{53}` # and `0 \leq a < n`. There are no restrictions on ``exp``, i.e. @@ -331,7 +331,7 @@ cdef extern from "flint_wrap.h": # This is implemented as a standard binary powering algorithm using # repeated squaring and reducing modulo `n` at each step. - ulong n_powmod_ui_precomp(ulong a, ulong exp, ulong n, double npre) + ulong n_powmod_ui_precomp(ulong a, ulong exp, ulong n, double npre) noexcept # Returns ``a^exp`` modulo `n` given a precomputed inverse of `n` # computed by :func:`n_precompute_inverse`. We require `n < 2^{53}` # and `0 \leq a < n`. The exponent ``exp`` is unsigned and so @@ -339,14 +339,14 @@ cdef extern from "flint_wrap.h": # This is implemented as a standard binary powering algorithm using # repeated squaring and reducing modulo `n` at each step. - ulong n_powmod(ulong a, mp_limb_signed_t exp, ulong n) + ulong n_powmod(ulong a, mp_limb_signed_t exp, ulong n) noexcept # Returns ``a^exp`` modulo `n`. We require ``n < 2^FLINT_D_BITS`` # and `0 \leq a < n`. There are no restrictions on ``exp``, i.e. # it can be negative. # This is implemented by precomputing an inverse and calling the # ``precomp`` version of this function. - ulong n_powmod2_preinv(ulong a, mp_limb_signed_t exp, ulong n, ulong ninv) + ulong n_powmod2_preinv(ulong a, mp_limb_signed_t exp, ulong n, ulong ninv) noexcept # Returns ``(a^exp) % n`` given a precomputed inverse of `n` computed # by :func:`n_preinvert_limb`. We require `0 \leq a < n`, but there are no # restrictions on `n` or on ``exp``, i.e. it can be negative. @@ -355,7 +355,7 @@ cdef extern from "flint_wrap.h": # If ``exp`` is negative but `a` is not invertible modulo `n`, an # exception is raised. - ulong n_powmod2(ulong a, mp_limb_signed_t exp, ulong n) + ulong n_powmod2(ulong a, mp_limb_signed_t exp, ulong n) noexcept # Returns ``(a^exp) % n``. We require `0 \leq a < n`, but there are # no restrictions on `n` or on ``exp``, i.e. it can be negative. # This is implemented by precomputing an inverse limb and calling the @@ -363,7 +363,7 @@ cdef extern from "flint_wrap.h": # If ``exp`` is negative but `a` is not invertible modulo `n`, an # exception is raised. - ulong n_powmod2_ui_preinv(ulong a, ulong exp, ulong n, ulong ninv) + ulong n_powmod2_ui_preinv(ulong a, ulong exp, ulong n, ulong ninv) noexcept # Returns ``(a^exp) % n`` given a precomputed inverse of `n` computed # by :func:`n_preinvert_limb`. We require `0 \leq a < n`, but there are no # restrictions on `n`. The exponent ``exp`` is unsigned and so can be @@ -371,14 +371,14 @@ cdef extern from "flint_wrap.h": # This is implemented as a standard binary powering algorithm using # repeated squaring and reducing modulo `n` at each step. - ulong n_powmod2_fmpz_preinv(ulong a, const fmpz_t exp, ulong n, ulong ninv) + ulong n_powmod2_fmpz_preinv(ulong a, const fmpz_t exp, ulong n, ulong ninv) noexcept # Returns ``(a^exp) % n`` given a precomputed inverse of `n` computed # by :func:`n_preinvert_limb`. We require `0 \leq a < n`, but there are no # restrictions on `n`. The exponent ``exp`` must not be negative. # This is implemented as a standard binary powering algorithm using # repeated squaring and reducing modulo `n` at each step. - ulong n_sqrtmod(ulong a, ulong p) + ulong n_sqrtmod(ulong a, ulong p) noexcept # If `p` is prime, compute a square root of `a` modulo `p` if `a` is a # quadratic residue modulo `p`, otherwise return `0`. # If `p` is not prime the result is with high probability `0`, indicating @@ -386,7 +386,7 @@ cdef extern from "flint_wrap.h": # result is meaningless. # Assumes that `a` is reduced modulo `p`. - slong n_sqrtmod_2pow(ulong ** sqrt, ulong a, slong exp) + slong n_sqrtmod_2pow(ulong ** sqrt, ulong a, slong exp) noexcept # Computes all the square roots of ``a`` modulo ``2^exp``. The roots # are stored in an array which is created and whose address is stored in # the location pointed to by ``sqrt``. The array of roots is allocated @@ -396,7 +396,7 @@ cdef extern from "flint_wrap.h": # returned by the function and the location ``sqrt`` points to is set to # NULL. - slong n_sqrtmod_primepow(ulong ** sqrt, ulong a, ulong p, slong exp) + slong n_sqrtmod_primepow(ulong ** sqrt, ulong a, ulong p, slong exp) noexcept # Computes all the square roots of ``a`` modulo ``p^exp``. The roots # are stored in an array which is created and whose address is stored in # the location pointed to by ``sqrt``. The array of roots is allocated @@ -406,7 +406,7 @@ cdef extern from "flint_wrap.h": # returned by the function and the location ``sqrt`` points to is set to # NULL. - slong n_sqrtmodn(ulong ** sqrt, ulong a, n_factor_t * fac) + slong n_sqrtmodn(ulong ** sqrt, ulong a, n_factor_t * fac) noexcept # Computes all the square roots of ``a`` modulo ``m`` given the # factorisation of ``m`` in ``fac``. The roots are stored in an array # which is created and whose address is stored in the location pointed to by @@ -416,83 +416,83 @@ cdef extern from "flint_wrap.h": # ``m`` then 0 is returned by the function and the location ``sqrt`` # points to is set to NULL. - mp_limb_t n_mulmod_shoup(mp_limb_t w, mp_limb_t t, mp_limb_t w_precomp, mp_limb_t p) + mp_limb_t n_mulmod_shoup(mp_limb_t w, mp_limb_t t, mp_limb_t w_precomp, mp_limb_t p) noexcept # Returns `w t \bmod{p}` given a precomputed scaled approximation of `w / p` # computed by :func:`n_mulmod_precomp_shoup`. The value of `p` should be # less than `2^{\mathtt{FLINT\_BITS} - 1}`. `w` and `t` should be less than `p`. # Works faster than :func:`n_mulmod2_preinv` if `w` fixed and `t` from array # (for example, scalar multiplication of vector). - mp_limb_t n_mulmod_precomp_shoup(mp_limb_t w, mp_limb_t p) + mp_limb_t n_mulmod_precomp_shoup(mp_limb_t w, mp_limb_t p) noexcept # Returns `w'`, scaled approximation of `w / p`. `w'` is equal to the integer # part of `w \cdot 2^{\mathtt{FLINT\_BITS}} / p`. - int n_divides(mp_limb_t * q, mp_limb_t n, mp_limb_t p) + int n_divides(mp_limb_t * q, mp_limb_t n, mp_limb_t p) noexcept - void n_primes_init(n_primes_t it) + void n_primes_init(n_primes_t it) noexcept # Initialises the prime number iterator ``iter`` for use. - void n_primes_clear(n_primes_t it) + void n_primes_clear(n_primes_t it) noexcept # Clears memory allocated by the prime number iterator ``iter``. - ulong n_primes_next(n_primes_t it) + ulong n_primes_next(n_primes_t it) noexcept # Returns the next prime number and advances the state of ``iter``. # The first call returns 2. # Small primes are looked up from ``flint_small_primes``. # When this table is exhausted, primes are generated in blocks # by calling :func:`n_primes_sieve_range`. - void n_primes_jump_after(n_primes_t it, ulong n) + void n_primes_jump_after(n_primes_t it, ulong n) noexcept # Changes the state of ``iter`` to start generating primes # after `n` (excluding `n` itself). - void n_primes_extend_small(n_primes_t it, ulong bound) + void n_primes_extend_small(n_primes_t it, ulong bound) noexcept # Extends the table of small primes in ``iter`` to contain # at least two primes larger than or equal to ``bound``. - void n_primes_sieve_range(n_primes_t it, ulong a, ulong b) + void n_primes_sieve_range(n_primes_t it, ulong a, ulong b) noexcept # Sets the block endpoints of ``iter`` to the smallest and # largest odd numbers between `a` and `b` inclusive, and # sieves to mark all odd primes in this range. # The iterator state is changed to point to the first # number in the sieved range. - void n_compute_primes(ulong num_primes) + void n_compute_primes(ulong num_primes) noexcept # Precomputes at least ``num_primes`` primes and their ``double`` # precomputed inverses and stores them in an internal cache. # Assuming that FLINT has been built with support for thread-local storage, # each thread has its own cache. - const ulong * n_primes_arr_readonly(ulong num_primes) + const ulong * n_primes_arr_readonly(ulong num_primes) noexcept # Returns a pointer to a read-only array of the first ``num_primes`` # prime numbers. The computed primes are cached for repeated calls. # The pointer is valid until the user calls :func:`n_cleanup_primes` # in the same thread. - const double * n_prime_inverses_arr_readonly(ulong n) + const double * n_prime_inverses_arr_readonly(ulong n) noexcept # Returns a pointer to a read-only array of inverses of the first # ``num_primes`` prime numbers. The computed primes are cached for # repeated calls. The pointer is valid until the user calls # :func:`n_cleanup_primes` in the same thread. - void n_cleanup_primes() + void n_cleanup_primes() noexcept # Frees the internal cache of prime numbers used by the current thread. # This will invalidate any pointers returned by # :func:`n_primes_arr_readonly` or :func:`n_prime_inverses_arr_readonly`. - ulong n_nextprime(ulong n, int proved) + ulong n_nextprime(ulong n, int proved) noexcept # Returns the next prime after `n`. Assumes the result will fit in an # ``ulong``. If proved is `0`, i.e. false, the prime is not # proven prime, otherwise it is. - ulong n_prime_pi(ulong n) + ulong n_prime_pi(ulong n) noexcept # Returns the value of the prime counting function `\pi(n)`, i.e. the # number of primes less than or equal to `n`. The invariant # ``n_prime_pi(n_nth_prime(n)) == n``. # Currently, this function simply extends the table of cached primes up to # an upper limit and then performs a binary search. - void n_prime_pi_bounds(ulong *lo, ulong *hi, ulong n) + void n_prime_pi_bounds(ulong *lo, ulong *hi, ulong n) noexcept # Calculates lower and upper bounds for the value of the prime counting # function ``lo <= pi(n) <= hi``. If ``lo`` and ``hi`` point to # the same location, the high value will be stored. @@ -505,13 +505,13 @@ cdef extern from "flint_wrap.h": # approximation to `\ln n`, taking care to use a value too # small or too large to maintain the inequality. - ulong n_nth_prime(ulong n) + ulong n_nth_prime(ulong n) noexcept # Returns the `n`\th prime number `p_n`, using the mathematical indexing # convention `p_1 = 2, p_2 = 3, \dotsc`. # This function simply ensures that the table of cached primes is large # enough and then looks up the entry. - void n_nth_prime_bounds(ulong *lo, ulong *hi, ulong n) + void n_nth_prime_bounds(ulong *lo, ulong *hi, ulong n) noexcept # Calculates lower and upper bounds for the `n`\th prime number `p_n` , # ``lo <= p_n <= hi``. If ``lo`` and ``hi`` point to the same # location, the high value will be stored. Note that this function will @@ -528,14 +528,14 @@ cdef extern from "flint_wrap.h": # ``n_prime_pi_bounds()``, and estimate `\ln \ln n` to the nearest # integer; this function is nearly constant. - bint n_is_oddprime_small(ulong n) + bint n_is_oddprime_small(ulong n) noexcept # Returns `1` if `n` is an odd prime smaller than # ``FLINT_ODDPRIME_SMALL_CUTOFF``. Expects `n` # to be odd and smaller than the cutoff. # This function merely uses a lookup table with one bit allocated for each # odd number up to the cutoff. - bint n_is_oddprime_binary(ulong n) + bint n_is_oddprime_binary(ulong n) noexcept # This function performs a simple binary search through # the table of cached primes for `n`. If it exists in the array it returns # `1`, otherwise `0`. For the algorithm to operate correctly @@ -545,7 +545,7 @@ cdef extern from "flint_wrap.h": # refine our search with a simple binary algorithm, taking # the top or bottom of the current interval as necessary. - bint n_is_prime_pocklington(ulong n, ulong iterations) + bint n_is_prime_pocklington(ulong n, ulong iterations) noexcept # Tests if `n` is a prime using the Pocklington--Lehmer primality # test. If `1` is returned `n` has been proved prime. If `0` is returned # `n` is composite. However `-1` may be returned if nothing was proved @@ -565,7 +565,7 @@ cdef extern from "flint_wrap.h": # https://mathworld.wolfram.com/PocklingtonsTheorem.html # for a description of the algorithm. - bint n_is_prime_pseudosquare(ulong n) + bint n_is_prime_pseudosquare(ulong n) noexcept # Tests if `n` is a prime according to Theorem 2.7 [LukPatWil1996]_. # We first factor `N` using trial division up to some limit `B`. # In fact, the number of primes used in the trial factoring is at @@ -591,7 +591,7 @@ cdef extern from "flint_wrap.h": # composite prime. However in that case an error is printed, as # that would be of independent interest. - bint n_is_prime(ulong n) + bint n_is_prime(ulong n) noexcept # Tests if `n` is a prime. This first sieves for small prime factors, # then simply calls :func:`n_is_probabprime`. This has been checked # against the tables of Feitsma and Galway @@ -602,7 +602,7 @@ cdef extern from "flint_wrap.h": # primality. This is likely to be significantly slower for prime # inputs. - bint n_is_strong_probabprime_precomp(ulong n, double npre, ulong a, ulong d) + bint n_is_strong_probabprime_precomp(ulong n, double npre, ulong a, ulong d) noexcept # Tests if `n` is a strong probable prime to the base `a`. We # require that `d` is set to the largest odd factor of `n - 1` and # ``npre`` is a precomputed inverse of `n` computed with @@ -615,7 +615,7 @@ cdef extern from "flint_wrap.h": # A description of strong probable primes is given here: # https://mathworld.wolfram.com/StrongPseudoprime.html - bint n_is_strong_probabprime2_preinv(ulong n, ulong ninv, ulong a, ulong d) + bint n_is_strong_probabprime2_preinv(ulong n, ulong ninv, ulong a, ulong d) noexcept # Tests if `n` is a strong probable prime to the base `a`. We require # that `d` is set to the largest odd factor of `n - 1` and ``npre`` # is a precomputed inverse of `n` computed with :func:`n_preinvert_limb`. @@ -626,13 +626,13 @@ cdef extern from "flint_wrap.h": # A description of strong probable primes is given here: # https://mathworld.wolfram.com/StrongPseudoprime.html - bint n_is_probabprime_fermat(ulong n, ulong i) + bint n_is_probabprime_fermat(ulong n, ulong i) noexcept # Returns `1` if `n` is a base `i` Fermat probable prime. Requires # `1 < i < n` and that `i` does not divide `n`. # By Fermat's Little Theorem if `i^{n-1}` is not congruent to `1` # then `n` is not prime. - bint n_is_probabprime_fibonacci(ulong n) + bint n_is_probabprime_fibonacci(ulong n) noexcept # Let `F_j` be the `j`\th element of the Fibonacci sequence # `0, 1, 1, 2, 3, 5, \dotsc`, starting at `j = 0`. Then if `n` is prime # we have `F_{n - (n/5)} = 0 \pmod n`, where `(n/5)` is the Jacobi @@ -640,7 +640,7 @@ cdef extern from "flint_wrap.h": # For further details, see pp. 142 [CraPom2005]_. # We require that `n` is not divisible by `2` or `5`. - bint n_is_probabprime_BPSW(ulong n) + bint n_is_probabprime_BPSW(ulong n) noexcept # Implements a Baillie--Pomerance--Selfridge--Wagstaff probable primality # test. This is a variant of the usual BPSW test (which only uses strong # base-2 probable prime and Lucas-Selfridge tests, see Baillie and @@ -653,12 +653,12 @@ cdef extern from "flint_wrap.h": # Up to `2^{64}` the test we use has been checked against tables of # pseudoprimes. Thus it is a primality test up to this limit. - bint n_is_probabprime_lucas(ulong n) + bint n_is_probabprime_lucas(ulong n) noexcept # For details on Lucas pseudoprimes, see [pp. 143] [CraPom2005]_. # We implement a variant of the Lucas pseudoprime test similar to that # described by Baillie and Wagstaff [BaiWag1980]_. - bint n_is_probabprime(ulong n) + bint n_is_probabprime(ulong n) noexcept # Tests if `n` is a probable prime. Up to ``FLINT_ODDPRIME_SMALL_CUTOFF`` # this algorithm uses :func:`n_is_oddprime_small` which uses a lookup table. # Next it calls :func:`n_compute_primes` with the maximum table size and @@ -674,14 +674,14 @@ cdef extern from "flint_wrap.h": # and Galway and up to the accuracy of those tables, this is an exhaustive # check up to `2^{64}`, i.e. there are no counterexamples. - ulong n_CRT(ulong r1, ulong m1, ulong r2, ulong m2) + ulong n_CRT(ulong r1, ulong m1, ulong r2, ulong m2) noexcept # Use the Chinese Remainder Theorem to return the unique value # `0 \le x < M` congruent to `r_1` modulo `m_1` and `r_2` modulo `m_2`, # where `M = m_1 \times m_2` is assumed to fit a ulong. # It is assumed that `m_1` and `m_2` are positive integers greater # than `1` and coprime. It is assumed that `0 \le r_1 < m_1` and `0 \le r_2 < m_2`. - ulong n_sqrt(ulong a) + ulong n_sqrt(ulong a) noexcept # Computes the integer truncation of the square root of `a`. # The implementation uses a call to the IEEE floating point sqrt function. # The integer itself is represented by the nearest double and its square @@ -694,7 +694,7 @@ cdef extern from "flint_wrap.h": # precision float provided the square root itself can be represented # in a single float, i.e. for `a < 281474976710656 = 2^{46}`. - ulong n_sqrtrem(ulong * r, ulong a) + ulong n_sqrtrem(ulong * r, ulong a) noexcept # Computes the integer truncation of the square root of `a`. # The integer itself is represented by the nearest double and its square # root is computed to the nearest place. If `a` is one below a square, the @@ -709,14 +709,14 @@ cdef extern from "flint_wrap.h": # The remainder is computed by subtracting the square of the computed square # root from `a`. - bint n_is_square(ulong x) + bint n_is_square(ulong x) noexcept # Returns `1` if `x` is a square, otherwise `0`. # This code first checks if `x` is a square modulo `64`, # `63 = 3 \times 3 \times 7` and `65 = 5 \times 13`, using lookup tables, # and if so it then takes a square root and checks that the square of this # equals the original value. - bint n_is_perfect_power235(ulong n) + bint n_is_perfect_power235(ulong n) noexcept # Returns `1` if `n` is a perfect square, cube or fifth power. # This function uses a series of modular tests to reject most # non 235-powers. Each modular test returns a value from 0 to 7 @@ -729,12 +729,12 @@ cdef extern from "flint_wrap.h": # root can be taken, if indicated, to determine whether the power # of that root is exactly equal to `n`. - bint n_is_perfect_power(ulong * root, ulong n) + bint n_is_perfect_power(ulong * root, ulong n) noexcept # If `n = r^k`, return `k` and set ``root`` to `r`. Note that `0` and # `1` are considered squares. No guarantees are made about `r` or `k` # being the minimum possible value. - ulong n_rootrem(ulong* remainder, ulong n, ulong root) + ulong n_rootrem(ulong* remainder, ulong n, ulong root) noexcept # This function uses the Newton iteration method to calculate the nth root of # a number. # First approximation is calculated by an algorithm mentioned in this @@ -743,7 +743,7 @@ cdef extern from "flint_wrap.h": # Returns the integer part of ``n ^ 1/root``. Remainder is set as # ``n - base^root``. In case `n < 1` or ``root < 1``, `0` is returned. - ulong n_cbrt(ulong n) + ulong n_cbrt(ulong n) noexcept # This function returns the integer truncation of the cube root of `n`. # First approximation is calculated by an algorithm mentioned in this # article: https://en.wikipedia.org/wiki/Fast_inverse_square_root . @@ -754,16 +754,16 @@ cdef extern from "flint_wrap.h": # `x \leftarrow x - (x\cdot x\cdot x - a)\cdot x/(2\cdot x\cdot x\cdot x + a)` for getting a good estimate, # as mentioned in the paper by W. Kahan [Kahan1991]_ . - ulong n_cbrt_newton_iteration(ulong n) + ulong n_cbrt_newton_iteration(ulong n) noexcept # This function returns the integer truncation of the cube root of `n`. # Makes use of Newton iterations to get a close value, and then adjusts the # estimate so as to get the correct value. - ulong n_cbrt_binary_search(ulong n) + ulong n_cbrt_binary_search(ulong n) noexcept # This function returns the integer truncation of the cube root of `n`. # Uses binary search to get the correct value. - ulong n_cbrt_chebyshev_approx(ulong n) + ulong n_cbrt_chebyshev_approx(ulong n) noexcept # This function returns the integer truncation of the cube root of `n`. # The number is first expressed in the form ``x * 2^exp``. This ensures # `x` is in the range [0.5, 1]. Cube root of x is calculated using @@ -772,14 +772,14 @@ cdef extern from "flint_wrap.h": # https://mpmath.org, using the function chebyfit. x is multiplied # by ``2^exp`` and the cube root of 1, 2 or 4 (according to ``exp%3``). - ulong n_cbrtrem(ulong* remainder, ulong n) + ulong n_cbrtrem(ulong* remainder, ulong n) noexcept # This function returns the integer truncation of the cube root of `n`. # Remainder is set as `n` minus the cube of the value returned. - void n_factor_init(n_factor_t * factors) + void n_factor_init(n_factor_t * factors) noexcept # Initializes factors. - int n_remove(ulong * n, ulong p) + int n_remove(ulong * n, ulong p) noexcept # Removes the highest possible power of `p` from `n`, replacing # `n` with the quotient. The return value is the highest # power of `p` that divided `n`. Assumes `n` is not `0`. @@ -790,7 +790,7 @@ cdef extern from "flint_wrap.h": # proceeds down the power tree again removing powers of `p` # until none remain. - int n_remove2_precomp(ulong * n, ulong p, double ppre) + int n_remove2_precomp(ulong * n, ulong p, double ppre) noexcept # Removes the highest possible power of `p` from `n`, replacing # `n` with the quotient. The return value is the highest # power of `p` that divided `n`. Assumes `n` is not `0`. We require @@ -800,7 +800,7 @@ cdef extern from "flint_wrap.h": # `p` we make repeated use of :func:`n_divrem2_precomp` until division # by `p` is no longer possible. - void n_factor_insert(n_factor_t * factors, ulong p, ulong exp) + void n_factor_insert(n_factor_t * factors, ulong p, ulong exp) noexcept # Inserts the given prime power factor ``p^exp`` into # the ``n_factor_t`` ``factors``. See the documentation for # :func:`n_factor_trial` for a description of the ``n_factor_t`` type. @@ -811,7 +811,7 @@ cdef extern from "flint_wrap.h": # There is no test code for this function other than its use by # the various factoring functions, which have test code. - ulong n_factor_trial_range(n_factor_t * factors, ulong n, ulong start, ulong num_primes) + ulong n_factor_trial_range(n_factor_t * factors, ulong n, ulong start, ulong num_primes) noexcept # Trial factor `n` with the first ``num_primes`` primes, but # starting at the prime with index start (counting from zero). # One requires an initialised ``n_factor_t`` structure, but factors @@ -833,12 +833,12 @@ cdef extern from "flint_wrap.h": # :func:`n_compute_primes` are utilised with the :func:`n_remove2_precomp` # function. - ulong n_factor_trial(n_factor_t * factors, ulong n, ulong num_primes) + ulong n_factor_trial(n_factor_t * factors, ulong n, ulong num_primes) noexcept # This function calls :func:`n_factor_trial_range`, with the value of # `0` for ``start``. By default this adds factors to an already existing # ``n_factor_t`` or to a newly initialised one. - ulong n_factor_power235(ulong *exp, ulong n) + ulong n_factor_power235(ulong *exp, ulong n) noexcept # Returns `0` if `n` is not a perfect square, cube or fifth power. # Otherwise it returns the root and sets ``exp`` to either `2`, # `3` or `5` appropriately. @@ -853,18 +853,18 @@ cdef extern from "flint_wrap.h": # root can be taken, if indicated, to determine whether the power # of that root is exactly equal to `n`. - ulong n_factor_one_line(ulong n, ulong iters) + ulong n_factor_one_line(ulong n, ulong iters) noexcept # This implements Bill Hart's one line factoring algorithm [Har2012]_. # It is a variant of Fermat's algorithm which cycles through a large number # of multipliers instead of incrementing the square root. It is faster than # SQUFOF for `n` less than about `2^{40}`. - ulong n_factor_lehman(ulong n) + ulong n_factor_lehman(ulong n) noexcept # Lehman's factoring algorithm. Currently works up to `10^{16}`, but is # not particularly efficient and so is not used in the general factor # function. Always returns a factor of `n`. - ulong n_factor_SQUFOF(ulong n, ulong iters) + ulong n_factor_SQUFOF(ulong n, ulong iters) noexcept # Attempts to split `n` using the given number of iterations # of SQUFOF. Simply set ``iters`` to ``WORD(0)`` for maximum # persistence. @@ -879,7 +879,7 @@ cdef extern from "flint_wrap.h": # If SQUFOF fails to factor `n` we return `0`, however with # ``iters`` large enough this should never happen. - void n_factor(n_factor_t * factors, ulong n, int proved) + void n_factor(n_factor_t * factors, ulong n, int proved) noexcept # Factors `n` with no restrictions on `n`. If the prime factors are # required to be checked with a primality test, one may set # ``proved`` to `1`, otherwise set it to `0`, and they will only be @@ -906,7 +906,7 @@ cdef extern from "flint_wrap.h": # ``FLINT_FACTOR_SQUFOF_ITERS``. If that fails an error results and # the program aborts. However this should not happen in practice. - ulong n_factor_trial_partial(n_factor_t * factors, ulong n, ulong * prod, ulong num_primes, ulong limit) + ulong n_factor_trial_partial(n_factor_t * factors, ulong n, ulong * prod, ulong num_primes, ulong limit) noexcept # Attempts trial factoring of `n` with the first ``num_primes primes``, # but stops when the product of prime factors so far exceeds ``limit``. # One requires an initialised ``n_factor_t`` structure, but factors @@ -929,7 +929,7 @@ cdef extern from "flint_wrap.h": # :func:`n_compute_primes` are utilised with the :func:`n_remove2_precomp` # function. - ulong n_factor_partial(n_factor_t * factors, ulong n, ulong limit, int proved) + ulong n_factor_partial(n_factor_t * factors, ulong n, ulong limit, int proved) noexcept # Factors `n`, but stops when the product of prime factors so far # exceeds ``limit``. # One requires an initialised ``n_factor_t`` structure, but factors @@ -944,7 +944,7 @@ cdef extern from "flint_wrap.h": # The factors are proved prime if ``proved`` is `1`, otherwise # they are merely probably prime. - ulong n_factor_pp1(ulong n, ulong B1, ulong c) + ulong n_factor_pp1(ulong n, ulong B1, ulong c) noexcept # Factors `n` using Williams' `p + 1` factoring algorithm, with prime # limit set to `B1`. We require `c` to be set to a random value. Each # trial of the algorithm with a different value of `c` gives another @@ -955,14 +955,14 @@ cdef extern from "flint_wrap.h": # If the algorithm succeeds, it returns the factor, otherwise it # returns `0` or `1` (the trivial factors modulo `n`). - ulong n_factor_pp1_wrapper(ulong n) + ulong n_factor_pp1_wrapper(ulong n) noexcept # A simple wrapper around ``n_factor_pp1`` which works in the range # `31`-`64` bits. Below this point, trial factoring will always succeed. # This function mainly exists for ``n_factor`` and is tuned to minimise # the time for ``n_factor`` on numbers that reach the ``n_factor_pp1`` # stage, i.e. after trial factoring and one line factoring. - int n_factor_pollard_brent_single(mp_limb_t *factor, mp_limb_t n, mp_limb_t ninv, mp_limb_t ai, mp_limb_t xi, mp_limb_t normbits, mp_limb_t max_iters) + int n_factor_pollard_brent_single(mp_limb_t *factor, mp_limb_t n, mp_limb_t ninv, mp_limb_t ai, mp_limb_t xi, mp_limb_t normbits, mp_limb_t max_iters) noexcept # Pollard Rho algorithm (with Brent modification) for integer factorization. # Assumes that the `n` is not prime. `factor` is set as the factor if found. # It is not assured that the factor found will be prime. Does not compute the complete @@ -978,7 +978,7 @@ cdef extern from "flint_wrap.h": # suggested by Richard Brent in the paper, available at # https://maths-people.anu.edu.au/~brent/pd/rpb051i.pdf - int n_factor_pollard_brent(mp_limb_t *factor, flint_rand_t state, mp_limb_t n_in, mp_limb_t max_tries, mp_limb_t max_iters) + int n_factor_pollard_brent(mp_limb_t *factor, flint_rand_t state, mp_limb_t n_in, mp_limb_t max_tries, mp_limb_t max_iters) noexcept # Pollard Rho algorithm, modified as suggested by Richard Brent. Makes a call to # :func:`n_factor_pollard_brent_single`. The input parameters ai and xi for # :func:`n_factor_pollard_brent_single` are selected at random. @@ -989,7 +989,7 @@ cdef extern from "flint_wrap.h": # is successful. In such a case, 1 is returned. Otherwise, 0 is returned. Factor # discovered is not necessarily prime. - int n_moebius_mu(ulong n) + int n_moebius_mu(ulong n) noexcept # Computes the Moebius function `\mu(n)`, which is defined as `\mu(n) = 0` # if `n` has a prime factor of multiplicity greater than `1`, `\mu(n) = -1` # if `n` has an odd number of distinct prime factors, and `\mu(n) = 1` if @@ -1001,28 +1001,28 @@ cdef extern from "flint_wrap.h": # For larger `n`, we first check if `n` is divisible by a small odd square # and otherwise call ``n_factor()`` and count the factors. - void n_moebius_mu_vec(int * mu, ulong len) + void n_moebius_mu_vec(int * mu, ulong len) noexcept # Computes `\mu(n)` for ``n = 0, 1, ..., len - 1``. This # is done by sieving over each prime in the range, flipping the sign # of `\mu(n)` for every multiple of a prime `p` and setting `\mu(n) = 0` # for every multiple of `p^2`. - bint n_is_squarefree(ulong n) + bint n_is_squarefree(ulong n) noexcept # Returns `0` if `n` is divisible by some perfect square, and `1` otherwise. # This simply amounts to testing whether `\mu(n) \neq 0`. As special # cases, `1` is considered squarefree and `0` is not considered squarefree. - ulong n_euler_phi(ulong n) + ulong n_euler_phi(ulong n) noexcept # Computes the Euler totient function `\phi(n)`, counting the number of # positive integers less than or equal to `n` that are coprime to `n`. - ulong n_factorial_fast_mod2_preinv(ulong n, ulong p, ulong pinv) + ulong n_factorial_fast_mod2_preinv(ulong n, ulong p, ulong pinv) noexcept # Returns `n! \bmod p` given a precomputed inverse of `p` as computed # by :func:`n_preinvert_limb`. `p` is not required to be a prime, but # no special optimisations are made for composite `p`. # Uses fast multipoint evaluation, running in about `O(n^{1/2})` time. - ulong n_factorial_mod2_preinv(ulong n, ulong p, ulong pinv) + ulong n_factorial_mod2_preinv(ulong n, ulong p, ulong pinv) noexcept # Returns `n! \bmod p` given a precomputed inverse of `p` as computed # by :func:`n_preinvert_limb`. `p` is not required to be a prime, but # no special optimisations are made for composite `p`. @@ -1030,15 +1030,15 @@ cdef extern from "flint_wrap.h": # if `n` is not too large, and calls the fast algorithm for extremely # large `n`. - ulong n_primitive_root_prime_prefactor(ulong p, n_factor_t * factors) + ulong n_primitive_root_prime_prefactor(ulong p, n_factor_t * factors) noexcept # Returns a primitive root for the multiplicative subgroup of `\mathbb{Z}/p\mathbb{Z}` # where `p` is prime given the factorisation (``factors``) of `p - 1`. - ulong n_primitive_root_prime(ulong p) + ulong n_primitive_root_prime(ulong p) noexcept # Returns a primitive root for the multiplicative subgroup of `\mathbb{Z}/p\mathbb{Z}` # where `p` is prime. - ulong n_discrete_log_bsgs(ulong b, ulong a, ulong n) + ulong n_discrete_log_bsgs(ulong b, ulong a, ulong n) noexcept # Returns the discrete logarithm of `b` with respect to `a` in the # multiplicative subgroup of `\mathbb{Z}/n\mathbb{Z}` when `\mathbb{Z}/n\mathbb{Z}` # is cyclic. That is, @@ -1047,7 +1047,7 @@ cdef extern from "flint_wrap.h": # `p^k`, or `2p^k` where `p` is an odd prime and `k` is a positive # integer. - void n_factor_ecm_double(mp_limb_t *x, mp_limb_t *z, mp_limb_t x0, mp_limb_t z0, mp_limb_t n, n_ecm_t n_ecm_inf) + void n_factor_ecm_double(mp_limb_t *x, mp_limb_t *z, mp_limb_t x0, mp_limb_t z0, mp_limb_t n, n_ecm_t n_ecm_inf) noexcept # Sets the point `(x : z)` to two times `(x_0 : z_0)` modulo `n` according # to the formula # `x = (x_0 + z_0)^2 \cdot (x_0 - z_0)^2 \mod n,` @@ -1055,18 +1055,18 @@ cdef extern from "flint_wrap.h": # This group doubling is valid only for points expressed in # Montgomery projective coordinates. - void n_factor_ecm_add(mp_limb_t *x, mp_limb_t *z, mp_limb_t x1, mp_limb_t z1, mp_limb_t x2, mp_limb_t z2, mp_limb_t x0, mp_limb_t z0, mp_limb_t n, n_ecm_t n_ecm_inf) + void n_factor_ecm_add(mp_limb_t *x, mp_limb_t *z, mp_limb_t x1, mp_limb_t z1, mp_limb_t x2, mp_limb_t z2, mp_limb_t x0, mp_limb_t z0, mp_limb_t n, n_ecm_t n_ecm_inf) noexcept # Sets the point `(x : z)` to the sum of `(x_1 : z_1)` and `(x_2 : z_2)` # modulo `n`, given the difference `(x_0 : z_0)` according to the formula # This group doubling is valid only for points expressed in # Montgomery projective coordinates. - void n_factor_ecm_mul_montgomery_ladder(mp_limb_t *x, mp_limb_t *z, mp_limb_t x0, mp_limb_t z0, mp_limb_t k, mp_limb_t n, n_ecm_t n_ecm_inf) + void n_factor_ecm_mul_montgomery_ladder(mp_limb_t *x, mp_limb_t *z, mp_limb_t x0, mp_limb_t z0, mp_limb_t k, mp_limb_t n, n_ecm_t n_ecm_inf) noexcept # Montgomery ladder algorithm for scalar multiplication of elliptic points. # Sets the point `(x : z)` to `k(x_0 : z_0)` modulo `n`. # Valid only for points expressed in Montgomery projective coordinates. - int n_factor_ecm_select_curve(mp_limb_t *f, mp_limb_t sigma, mp_limb_t n, n_ecm_t n_ecm_inf) + int n_factor_ecm_select_curve(mp_limb_t *f, mp_limb_t sigma, mp_limb_t n, n_ecm_t n_ecm_inf) noexcept # Selects a random elliptic curve given a random integer ``sigma``, # according to Suyama's parameterization. If the factor is found while # selecting the curve, `1` is returned. In case the curve found is not @@ -1078,21 +1078,21 @@ cdef extern from "flint_wrap.h": # The curve selected is of Montgomery form, the points selected satisfy the # curve and are projective coordinates. - int n_factor_ecm_stage_I(mp_limb_t *f, const mp_limb_t *prime_array, mp_limb_t num, mp_limb_t B1, mp_limb_t n, n_ecm_t n_ecm_inf) + int n_factor_ecm_stage_I(mp_limb_t *f, const mp_limb_t *prime_array, mp_limb_t num, mp_limb_t B1, mp_limb_t n, n_ecm_t n_ecm_inf) noexcept # Stage I implementation of the ECM algorithm. # ``f`` is set as the factor if found. ``num`` is number of prime numbers # `<=` the bound ``B1``. ``prime_array`` is an array of first ``B1`` # primes. `n` is the number being factored. # If the factor is found, `1` is returned, otherwise `0`. - int n_factor_ecm_stage_II(mp_limb_t *f, mp_limb_t B1, mp_limb_t B2, mp_limb_t P, mp_limb_t n, n_ecm_t n_ecm_inf) + int n_factor_ecm_stage_II(mp_limb_t *f, mp_limb_t B1, mp_limb_t B2, mp_limb_t P, mp_limb_t n, n_ecm_t n_ecm_inf) noexcept # Stage II implementation of the ECM algorithm. # ``f`` is set as the factor if found. ``B1``, ``B2`` are the two # bounds. ``P`` is the primorial (approximately equal to `\sqrt{B2}`). # `n` is the number being factored. # If the factor is found, `1` is returned, otherwise `0`. - int n_factor_ecm(mp_limb_t *f, mp_limb_t curves, mp_limb_t B1, mp_limb_t B2, flint_rand_t state, mp_limb_t n) + int n_factor_ecm(mp_limb_t *f, mp_limb_t curves, mp_limb_t B1, mp_limb_t B2, flint_rand_t state, mp_limb_t n) noexcept # Outer wrapper function for the ECM algorithm. It factors `n` which # must fit into a ``mp_limb_t``. # The function calls stage I and II, and From c8e813406f663929fcf774fa5720923838f69767 Mon Sep 17 00:00:00 2001 From: Vincent Delecroix <20100.delecroix@gmail.com> Date: Mon, 11 Dec 2023 11:11:23 +0100 Subject: [PATCH 22/41] clean fmpq_poly_sage[.pxd,.pyx] --- src/sage/libs/flint/fmpq_poly_sage.pxd | 162 +------------------------ src/sage/libs/flint/fmpq_poly_sage.pyx | 1 + 2 files changed, 2 insertions(+), 161 deletions(-) diff --git a/src/sage/libs/flint/fmpq_poly_sage.pxd b/src/sage/libs/flint/fmpq_poly_sage.pxd index b12a5dd046d..661623745b4 100644 --- a/src/sage/libs/flint/fmpq_poly_sage.pxd +++ b/src/sage/libs/flint/fmpq_poly_sage.pxd @@ -14,168 +14,8 @@ from sage.libs.gmp.types cimport mpz_t, mpq_t from sage.libs.flint.types cimport * from sage.libs.flint.fmpz_vec cimport _fmpz_vec_max_limbs +from sage.libs.flint.fmpq_poly cimport fmpq_poly_numref, fmpq_poly_length -# flint/fmpq_poly.h -cdef extern from "flint_wrap.h": - # Memory management - void fmpq_poly_init(fmpq_poly_t) - - void fmpq_poly_init2(fmpq_poly_t, slong) - void fmpq_poly_realloc(fmpq_poly_t, slong) - - void fmpq_poly_fit_length(fmpq_poly_t, slong) - - void fmpq_poly_clear(fmpq_poly_t) - - void fmpq_poly_canonicalise(fmpq_poly_t) - int fmpq_poly_is_canonical(const fmpq_poly_t) - - void _fmpq_poly_set_length(fmpq_poly_t, slong) - void _fmpq_poly_normalise(fmpq_poly_t) - - # Polynomial parameters - slong fmpq_poly_degree(const fmpq_poly_t) - ulong fmpq_poly_length(const fmpq_poly_t) - - # Accessing the numerator and denominator - fmpz *fmpq_poly_numref(fmpq_poly_t) - fmpz *fmpq_poly_denref(fmpq_poly_t) - - void fmpq_poly_get_numerator(fmpz_poly_t, const fmpq_poly_t) - - # Assignment, swap, negation - void fmpq_poly_set(fmpq_poly_t, const fmpq_poly_t) - void fmpq_poly_set_si(fmpq_poly_t, slong) - void fmpq_poly_set_ui(fmpq_poly_t, ulong) - void fmpq_poly_set_fmpz(fmpq_poly_t, const fmpz_t) - void fmpq_poly_set_fmpq(fmpq_poly_t, const fmpq_t) - void fmpq_poly_set_fmpz_poly(fmpq_poly_t, const fmpz_poly_t) - - void fmpq_poly_set_str(fmpq_poly_t, const char *) - char *fmpq_poly_get_str(const fmpq_poly_t) - char *fmpq_poly_get_str_pretty(const fmpq_poly_t, const char *) - - void fmpq_poly_zero(fmpq_poly_t) - void fmpq_poly_one(fmpq_poly_t) - - void fmpq_poly_neg(fmpq_poly_t, const fmpq_poly_t) - void fmpq_poly_inv(fmpq_poly_t, const fmpq_poly_t) - - void fmpq_poly_swap(fmpq_poly_t, fmpq_poly_t) - void fmpq_poly_truncate(fmpq_poly_t, slong) - void fmpq_poly_get_slice(fmpq_poly_t, const fmpq_poly_t, slong, slong) - void fmpq_poly_reverse(fmpq_poly_t, const fmpq_poly_t, slong) - - void fmpq_poly_get_coeff_fmpq(fmpq_t, const fmpq_poly_t, slong) - void fmpq_poly_get_coeff_si(slong, const fmpq_poly_t, slong) - void fmpq_poly_get_coeff_ui(ulong, const fmpq_poly_t, slong) - - void fmpq_poly_set_coeff_si(fmpq_poly_t, slong, slong) - void fmpq_poly_set_coeff_ui(fmpq_poly_t, slong, ulong) - void fmpq_poly_set_coeff_fmpz(fmpq_poly_t, slong, const fmpz_t) - void fmpq_poly_set_coeff_fmpq(fmpq_poly_t, slong, const fmpq_t) - - # Comparison - int fmpq_poly_equal(const fmpq_poly_t, const fmpq_poly_t) - int fmpq_poly_cmp(const fmpq_poly_t, const fmpq_poly_t) - int fmpq_poly_is_one(const fmpq_poly_t) - int fmpq_poly_is_zero(const fmpq_poly_t) - - # Addition and subtraction - void fmpq_poly_add(fmpq_poly_t, const fmpq_poly_t, const fmpq_poly_t) - void fmpq_poly_sub(fmpq_poly_t, const fmpq_poly_t, const fmpq_poly_t) - - void fmpq_poly_add_can( - fmpq_poly_t, const fmpq_poly_t, const fmpq_poly_t, int) - void fmpq_poly_sub_can( - fmpq_poly_t, const fmpq_poly_t, const fmpq_poly_t, int) - - # Scalar multiplication and division - void fmpq_poly_scalar_mul_si(fmpq_poly_t, const fmpq_poly_t, slong) - void fmpq_poly_scalar_mul_ui(fmpq_poly_t, const fmpq_poly_t, ulong) - void fmpq_poly_scalar_mul_fmpz( - fmpq_poly_t, const fmpq_poly_t, const fmpz_t) - void fmpq_poly_scalar_mul_fmpq( - fmpq_poly_t, const fmpq_poly_t, const fmpq_t) - - void fmpq_poly_scalar_div_si(fmpq_poly_t, const fmpq_poly_t, slong) - void fmpq_poly_scalar_div_ui(fmpq_poly_t, const fmpq_poly_t, ulong) - void fmpq_poly_scalar_div_fmpz( - fmpq_poly_t, const fmpq_poly_t, const fmpz_t) - void fmpq_poly_scalar_div_fmpq( - fmpq_poly_t, const fmpq_poly_t, const fmpq_t) - - # Multiplication - void fmpq_poly_mul(fmpq_poly_t, const fmpq_poly_t, const fmpq_poly_t) - void fmpq_poly_mullow(fmpq_poly_t, const fmpq_poly_t, const fmpq_poly_t, slong) - - void fmpq_poly_addmul(fmpq_poly_t, const fmpq_poly_t, const fmpq_poly_t) - void fmpq_poly_submul(fmpq_poly_t, const fmpq_poly_t, const fmpq_poly_t) - - # Powering - void fmpq_poly_pow(fmpq_poly_t, const fmpq_poly_t, ulong) - - # Shifting - void fmpq_poly_shift_left(fmpq_poly_t, const fmpq_poly_t, slong) - void fmpq_poly_shift_right(fmpq_poly_t, const fmpq_poly_t, slong) - - # Euclidean division - void fmpq_poly_divrem( - fmpq_poly_t, fmpq_poly_t, const fmpq_poly_t, const fmpq_poly_t) - void fmpq_poly_div(fmpq_poly_t, const fmpq_poly_t, const fmpq_poly_t) - void fmpq_poly_rem(fmpq_poly_t, const fmpq_poly_t, const fmpq_poly_t) - - # Greatest common divisor - void fmpq_poly_gcd(fmpq_poly_t, const fmpq_poly_t, const fmpq_poly_t) - void fmpq_poly_xgcd( - fmpq_poly_t, fmpq_poly_t, fmpq_poly_t, - const fmpq_poly_t, const fmpq_poly_t) - - void fmpq_poly_lcm(fmpq_poly_t, const fmpq_poly_t, const fmpq_poly_t) - - void fmpq_poly_resultant(fmpq_t, const fmpq_poly_t, const fmpq_poly_t) - - # Power series division - void fmpq_poly_inv_series_newton(fmpq_poly_t, const fmpq_poly_t, slong) - void fmpq_poly_inv_series(fmpq_poly_t, const fmpq_poly_t, slong) - void fmpq_poly_div_series( - fmpq_poly_t, const fmpq_poly_t, const fmpq_poly_t, slong) - - # Derivative and integral - void fmpq_poly_derivative(fmpq_poly_t, const fmpq_poly_t) - void fmpq_poly_integral(fmpq_poly_t, const fmpq_poly_t) - - # Evaluation - void fmpq_poly_evaluate_fmpz(fmpq_t, const fmpq_poly_t, const fmpz_t) - void fmpq_poly_evaluate_fmpq(fmpq_t, const fmpq_poly_t, const fmpq_t) - - # Composition - void fmpq_poly_compose(fmpq_poly_t, const fmpq_poly_t, const fmpq_poly_t) - void fmpq_poly_rescale(fmpq_poly_t, const fmpq_poly_t, const fmpq_t) - - # Revert - void fmpq_poly_revert_series(fmpq_poly_t, fmpq_poly_t, unsigned long) - - # Gaussian content - void fmpq_poly_content(fmpq_t, const fmpq_poly_t) - void fmpq_poly_primitive_part(fmpq_poly_t, const fmpq_poly_t) - - int fmpq_poly_is_monic(const fmpq_poly_t) - void fmpq_poly_make_monic(fmpq_poly_t, const fmpq_poly_t) - - # Transcendental functions - void fmpq_poly_log_series(fmpq_poly_t, const fmpq_poly_t, slong) - void fmpq_poly_exp_series(fmpq_poly_t, const fmpq_poly_t, slong) - void fmpq_poly_atan_series(fmpq_poly_t, const fmpq_poly_t, slong) - void fmpq_poly_atanh_series(fmpq_poly_t, const fmpq_poly_t, slong) - void fmpq_poly_asin_series(fmpq_poly_t, const fmpq_poly_t, slong) - void fmpq_poly_asinh_series(fmpq_poly_t, const fmpq_poly_t, slong) - void fmpq_poly_tan_series(fmpq_poly_t, const fmpq_poly_t, slong) - void fmpq_poly_sin_series(fmpq_poly_t, const fmpq_poly_t, slong) - void fmpq_poly_cos_series(fmpq_poly_t, const fmpq_poly_t, slong) - void fmpq_poly_sinh_series(fmpq_poly_t, const fmpq_poly_t, slong) - void fmpq_poly_cosh_series(fmpq_poly_t, const fmpq_poly_t, slong) - void fmpq_poly_tanh_series(fmpq_poly_t, const fmpq_poly_t, slong) # since the fmpq_poly header seems to be lacking this inline function cdef inline sage_fmpq_poly_max_limbs(const fmpq_poly_t poly) noexcept: diff --git a/src/sage/libs/flint/fmpq_poly_sage.pyx b/src/sage/libs/flint/fmpq_poly_sage.pyx index 0c0c680e6b1..fcaf6407bfc 100644 --- a/src/sage/libs/flint/fmpq_poly_sage.pyx +++ b/src/sage/libs/flint/fmpq_poly_sage.pyx @@ -4,6 +4,7 @@ from sage.libs.gmp.mpq cimport * from sage.libs.flint.fmpz cimport * from sage.libs.flint.fmpq cimport * +from sage.libs.flint.fmpq_poly cimport * cdef void fmpq_poly_scalar_mul_mpz(fmpq_poly_t rop, const fmpq_poly_t op, const mpz_t c) noexcept: From 95353cde498f4d88176e70c3063d1a04135b5200 Mon Sep 17 00:00:00 2001 From: Vincent Delecroix <20100.delecroix@gmail.com> Date: Mon, 11 Dec 2023 11:14:41 +0100 Subject: [PATCH 23/41] safer flint_wrap.h --- src/sage/libs/flint/flint_wrap.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/sage/libs/flint/flint_wrap.h b/src/sage/libs/flint/flint_wrap.h index e28943f2d90..c3cd2b7760b 100644 --- a/src/sage/libs/flint/flint_wrap.h +++ b/src/sage/libs/flint/flint_wrap.h @@ -31,6 +31,10 @@ #define slong mp_limb_signed_t #endif +/* NOTE: calcium.h must be imported before gr.h as otherwise truth_t gets redefined + See https://github.com/flintlib/flint/issues/1653 */ +#include + #include #include #include From db99de3882e40d58e8e2d1613ae517b7717778f1 Mon Sep 17 00:00:00 2001 From: Vincent Delecroix <20100.delecroix@gmail.com> Date: Mon, 11 Dec 2023 12:30:17 +0100 Subject: [PATCH 24/41] fix import of n_factor_to_list in integer.pyx --- src/sage/rings/integer.pyx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sage/rings/integer.pyx b/src/sage/rings/integer.pyx index c990c200e57..183c8741c04 100644 --- a/src/sage/rings/integer.pyx +++ b/src/sage/rings/integer.pyx @@ -3996,7 +3996,7 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): global n_factor_to_list if n_factor_to_list is None: try: - from sage.libs.flint.ulong_extras import n_factor_to_list + from sage.libs.flint.ulong_extras_sage import n_factor_to_list except ImportError: pass if n_factor_to_list is not None: From 8be2a1f11ee361a00f5e311df2d581531437281f Mon Sep 17 00:00:00 2001 From: Vincent Delecroix <20100.delecroix@gmail.com> Date: Mon, 11 Dec 2023 13:49:09 +0100 Subject: [PATCH 25/41] fix import of qsieve in integer.pyx --- src/sage/rings/integer.pyx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sage/rings/integer.pyx b/src/sage/rings/integer.pyx index 183c8741c04..51bbe5cf2c9 100644 --- a/src/sage/rings/integer.pyx +++ b/src/sage/rings/integer.pyx @@ -4042,7 +4042,7 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): message = "the factorization returned by qsieve may be incomplete (the factors may not be prime) or even wrong; see qsieve? for details" from warnings import warn warn(message, RuntimeWarning, stacklevel=5) - from sage.libs.flint.qsieve import qsieve + from sage.libs.flint.qsieve_sage import qsieve F = qsieve(n) F.sort() return IntegerFactorization(F, unit=unit, unsafe=True, From d9aee90eb847c66ae08cdd0be144b18db5d393d6 Mon Sep 17 00:00:00 2001 From: Vincent Delecroix <20100.delecroix@gmail.com> Date: Tue, 12 Dec 2023 11:42:54 +0100 Subject: [PATCH 26/41] include autogeneration files --- src/sage_setup/autogen/flint/README.md | 18 + src/sage_setup/autogen/flint/__init__.py | 12 + src/sage_setup/autogen/flint/env.py | 20 + .../autogen/flint/macros/acb_macros.pxd | 11 + .../autogen/flint/macros/acb_mat_macros.pxd | 14 + .../autogen/flint/macros/acb_poly_macros.pxd | 8 + .../autogen/flint/macros/arb_macros.pxd | 11 + .../autogen/flint/macros/arb_mat_macros.pxd | 14 + .../autogen/flint/macros/fmpq_mat_macros.pxd | 14 + .../autogen/flint/macros/fmpz_mat_macros.pxd | 14 + .../autogen/flint/macros/fmpz_poly_macros.pxd | 8 + .../autogen/flint/macros/mag_macros.pxd | 8 + src/sage_setup/autogen/flint/reader.py | 257 +++ .../flint/templates/flint_sage.pyx.template | 31 + .../flint/templates/flint_wrap.h.template | 42 + .../flint/templates/types.pxd.template | 2044 +++++++++++++++++ src/sage_setup/autogen/flint/writer.py | 111 + src/sage_setup/autogen/flint_autogen.py | 19 + 18 files changed, 2656 insertions(+) create mode 100644 src/sage_setup/autogen/flint/README.md create mode 100644 src/sage_setup/autogen/flint/__init__.py create mode 100644 src/sage_setup/autogen/flint/env.py create mode 100644 src/sage_setup/autogen/flint/macros/acb_macros.pxd create mode 100644 src/sage_setup/autogen/flint/macros/acb_mat_macros.pxd create mode 100644 src/sage_setup/autogen/flint/macros/acb_poly_macros.pxd create mode 100644 src/sage_setup/autogen/flint/macros/arb_macros.pxd create mode 100644 src/sage_setup/autogen/flint/macros/arb_mat_macros.pxd create mode 100644 src/sage_setup/autogen/flint/macros/fmpq_mat_macros.pxd create mode 100644 src/sage_setup/autogen/flint/macros/fmpz_mat_macros.pxd create mode 100644 src/sage_setup/autogen/flint/macros/fmpz_poly_macros.pxd create mode 100644 src/sage_setup/autogen/flint/macros/mag_macros.pxd create mode 100644 src/sage_setup/autogen/flint/reader.py create mode 100644 src/sage_setup/autogen/flint/templates/flint_sage.pyx.template create mode 100644 src/sage_setup/autogen/flint/templates/flint_wrap.h.template create mode 100644 src/sage_setup/autogen/flint/templates/types.pxd.template create mode 100644 src/sage_setup/autogen/flint/writer.py create mode 100644 src/sage_setup/autogen/flint_autogen.py diff --git a/src/sage_setup/autogen/flint/README.md b/src/sage_setup/autogen/flint/README.md new file mode 100644 index 00000000000..dea2e753f94 --- /dev/null +++ b/src/sage_setup/autogen/flint/README.md @@ -0,0 +1,18 @@ +Autogeneration of flint header files for SageMath +================================================= + +The scripts in this folder are responsible for the automatic generation of the Cython header files +in `sage/libs/flint/`. To make the autogeneration + +1. Obtain a clone of the flint repo, eg `git clone https://github.com/flintlib/flint2` + +2. Checkout to the appropriate commit, eg `git checkout v2.9.0` + +3. Possibly adjust the content of `types.pxd.template` (which will be used to generate + types.pxd) + +4. Set the environment variable `FLINT_GIT_DIR` + +5. Run the `run.py` script, eg `python autogen.py` + +6. Copy all the files generated in `pxd_headers` inside the sage source tree (ie `SAGE_SRC/sage/libs/flint`) diff --git a/src/sage_setup/autogen/flint/__init__.py b/src/sage_setup/autogen/flint/__init__.py new file mode 100644 index 00000000000..c2c0601a864 --- /dev/null +++ b/src/sage_setup/autogen/flint/__init__.py @@ -0,0 +1,12 @@ +#***************************************************************************** +# Copyright (C) 2023 Vincent Delecroix <20100.delecroix@gmail.com> +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 2 of the License, or +# (at your option) any later version. +# http://www.gnu.org/licenses/ +#***************************************************************************** + +from .env import AUTOGEN_DIR +from .writer import write_flint_cython_headers diff --git a/src/sage_setup/autogen/flint/env.py b/src/sage_setup/autogen/flint/env.py new file mode 100644 index 00000000000..ce8ebed4f07 --- /dev/null +++ b/src/sage_setup/autogen/flint/env.py @@ -0,0 +1,20 @@ +#***************************************************************************** +# Copyright (C) 2023 Vincent Delecroix <20100.delecroix@gmail.com> +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 2 of the License, or +# (at your option) any later version. +# http://www.gnu.org/licenses/ +#***************************************************************************** + +import os + + +AUTOGEN_DIR = os.path.dirname(os.path.realpath(__file__)) +FLINT_GIT_DIR = os.environ.get('FLINT_GIT_DIR', '') +FLINT_INCLUDE_DIR = os.path.join(FLINT_GIT_DIR, 'src') +FLINT_DOC_DIR = os.path.join(FLINT_GIT_DIR, 'doc/source') + +if not os.path.isdir(FLINT_GIT_DIR) or not os.path.isdir(FLINT_INCLUDE_DIR) or not os.path.isdir(FLINT_DOC_DIR): + raise ValueError('FLINT_GIT_DIR (={}) environment variable must be set to the location of flint sources'.format(FLINT_GIT_DIR)) diff --git a/src/sage_setup/autogen/flint/macros/acb_macros.pxd b/src/sage_setup/autogen/flint/macros/acb_macros.pxd new file mode 100644 index 00000000000..a3bfc1d468b --- /dev/null +++ b/src/sage_setup/autogen/flint/macros/acb_macros.pxd @@ -0,0 +1,11 @@ +# Macros from acb.h +# See https://github.com/flintlib/flint/issues/1529 + +from .types cimport * + +cdef extern from "flint_wrap.h": + arb_ptr acb_realref(acb_t x) + # Macro giving a pointer to the real part of x + + arb_ptr acb_imagref(acb_t x) + # Macro giving a pointer to the imaginary part of x diff --git a/src/sage_setup/autogen/flint/macros/acb_mat_macros.pxd b/src/sage_setup/autogen/flint/macros/acb_mat_macros.pxd new file mode 100644 index 00000000000..6fc4b5d82fc --- /dev/null +++ b/src/sage_setup/autogen/flint/macros/acb_mat_macros.pxd @@ -0,0 +1,14 @@ +# Macros from acb_mat.h +# See https://github.com/flintlib/flint/issues/1529 + +from .types cimport * + +cdef extern from "flint_wrap.h": + acb_ptr acb_mat_entry(acb_mat_t mat, slong i, slong j) + # Macro giving a pointer to the entry at row *i* and column *j*. + + slong acb_mat_nrows(acb_mat_t) + # Returns the number of rows of the matrix. + + slong acb_mat_ncols(acb_mat_t) + # Returns the number of columns of the matrix. diff --git a/src/sage_setup/autogen/flint/macros/acb_poly_macros.pxd b/src/sage_setup/autogen/flint/macros/acb_poly_macros.pxd new file mode 100644 index 00000000000..f6b26ab0d1a --- /dev/null +++ b/src/sage_setup/autogen/flint/macros/acb_poly_macros.pxd @@ -0,0 +1,8 @@ +# Macros from acb_poly.h +# See https://github.com/flintlib/flint/issues/1529 + +from .types cimport * + +cdef extern from "flint_wrap.h": + acb_ptr acb_poly_get_coeff_ptr(acb_poly_t p, ulong n) + # Macro giving a pointer to the n-th coefficient of p (or NULL) diff --git a/src/sage_setup/autogen/flint/macros/arb_macros.pxd b/src/sage_setup/autogen/flint/macros/arb_macros.pxd new file mode 100644 index 00000000000..2c243ecac1c --- /dev/null +++ b/src/sage_setup/autogen/flint/macros/arb_macros.pxd @@ -0,0 +1,11 @@ +# Macros from arb.h +# See https://github.com/flintlib/flint/issues/1529 + +from .types cimport * + +cdef extern from "flint_wrap.h": + arf_ptr arb_midref(arb_t x) + # Macro giving a pointer to the midpoint of x + + mag_ptr arb_radref(arb_t x) + # Macro giving a pointer to the radius of x diff --git a/src/sage_setup/autogen/flint/macros/arb_mat_macros.pxd b/src/sage_setup/autogen/flint/macros/arb_mat_macros.pxd new file mode 100644 index 00000000000..ebf86d0f785 --- /dev/null +++ b/src/sage_setup/autogen/flint/macros/arb_mat_macros.pxd @@ -0,0 +1,14 @@ +# Macros from arb_mat.h +# See https://github.com/flintlib/flint/issues/1529 + +from .types cimport * + +cdef extern from "flint_wrap.h": + arb_ptr arb_mat_entry(arb_mat_t mat, slong i, slong j) + # Macro giving a pointer to the entry at row *i* and column *j*. + + slong arb_mat_nrows(arb_mat_t) + # Returns the number of rows of the matrix. + + slong arb_mat_ncols(arb_mat_t) + # Returns the number of columns of the matrix. diff --git a/src/sage_setup/autogen/flint/macros/fmpq_mat_macros.pxd b/src/sage_setup/autogen/flint/macros/fmpq_mat_macros.pxd new file mode 100644 index 00000000000..36eb1ef8703 --- /dev/null +++ b/src/sage_setup/autogen/flint/macros/fmpq_mat_macros.pxd @@ -0,0 +1,14 @@ +# Macros from fmpq_mat.h +# See https://github.com/flintlib/flint/issues/1529 + +from .types cimport * + +cdef extern from "flint_wrap.h": + fmpq * fmpq_mat_entry(fmpq_mat_t mat, slong i, slong j) + # Macro giving a pointer to the entry at row *i* and column *j*. + + slong fmpq_mat_nrows(fmpq_mat_t) + # Returns the number of rows of the matrix. + + slong fmpq_mat_ncols(fmpq_mat_t) + # Returns the number of columns of the matrix. diff --git a/src/sage_setup/autogen/flint/macros/fmpz_mat_macros.pxd b/src/sage_setup/autogen/flint/macros/fmpz_mat_macros.pxd new file mode 100644 index 00000000000..52046e309b0 --- /dev/null +++ b/src/sage_setup/autogen/flint/macros/fmpz_mat_macros.pxd @@ -0,0 +1,14 @@ +# Macros from fmpz_mat.h +# See https://github.com/flintlib/flint/issues/1529 + +from .types cimport * + +cdef extern from "flint_wrap.h": + fmpz * fmpz_mat_entry(fmpz_mat_t mat, slong i, slong j) + # Macro giving a pointer to the entry at row *i* and column *j*. + + slong fmpz_mat_nrows(fmpz_mat_t) + # Returns the number of rows of the matrix. + + slong fmpz_mat_ncols(fmpz_mat_t) + # Returns the number of columns of the matrix. diff --git a/src/sage_setup/autogen/flint/macros/fmpz_poly_macros.pxd b/src/sage_setup/autogen/flint/macros/fmpz_poly_macros.pxd new file mode 100644 index 00000000000..fd789d7f1c7 --- /dev/null +++ b/src/sage_setup/autogen/flint/macros/fmpz_poly_macros.pxd @@ -0,0 +1,8 @@ +# Macros from fmpz_poly.h +# See https://github.com/flintlib/flint/issues/1529 + +from .types cimport * + +cdef extern from "flint_wrap.h": + fmpz * fmpz_poly_get_coeff_ptr(fmpz_poly_t p, ulong n) + # Macro giving a pointer to the n-th coefficient of p (or NULL) diff --git a/src/sage_setup/autogen/flint/macros/mag_macros.pxd b/src/sage_setup/autogen/flint/macros/mag_macros.pxd new file mode 100644 index 00000000000..8ca2d202fc6 --- /dev/null +++ b/src/sage_setup/autogen/flint/macros/mag_macros.pxd @@ -0,0 +1,8 @@ +# Macros from mag.h +# See https://github.com/flintlib/flint/issues/1529 + +from .types cimport * + +cdef extern from "flint_wrap.h": + long MAG_BITS + diff --git a/src/sage_setup/autogen/flint/reader.py b/src/sage_setup/autogen/flint/reader.py new file mode 100644 index 00000000000..c8d44298066 --- /dev/null +++ b/src/sage_setup/autogen/flint/reader.py @@ -0,0 +1,257 @@ +r""" +Extraction of function, macros, types from flint documentation. +""" + +#***************************************************************************** +# Copyright (C) 2023 Vincent Delecroix <20100.delecroix@gmail.com> +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 2 of the License, or +# (at your option) any later version. +# http://www.gnu.org/licenses/ +#***************************************************************************** + +import os +from .env import FLINT_INCLUDE_DIR, FLINT_DOC_DIR + + +class Extractor: + r""" + Tool to extract function declarations from a flint .rst file + """ + NONE = 0 + DOC = 1 + FUNCTION_DECLARATION = 2 + MACRO_DECLARATION = 4 + TYPE_DECLARATION = 8 + + def __init__(self, filename): + self.filename = filename + if not filename.endswith('.rst'): + raise ValueError + + # Attributes that are modified throughout the document parsing + self.state = self.NONE # position in the documentation + self.section = None # current section + self.content = {} # section -> list of pairs (function signatures, func documentation) + self.functions = [] # current list of pairs (function signatures, func documentation) + self.signatures = [] # current list of function/macro/type signatures + self.doc = [] # current function documentation + + with open(filename) as f: + text = f.read() + self.lines = text.splitlines() + self.i = 0 + + def run(self): + while self.process_line(): + pass + if self.state & self.FUNCTION_DECLARATION: + self.add_function() + if self.state & self.MACRO_DECLARATION: + self.add_macro() + if self.functions: + self.update_section() + self.state = self.NONE + + def update_section(self): + if self.section not in self.content: + self.content[self.section] = [] + self.content[self.section] += tuple(self.functions) + self.functions.clear() + + def clean_doc(self): + # Remove empty lines at the end of documentation + while self.doc and not self.doc[-1]: + self.doc.pop() + + for i, line in enumerate(self.doc): + # To make sage linter happier + line = line.replace('\\choose ', 'choose ') + self.doc[i] = line + + @staticmethod + def has_boolean_return_type(func_signature): + r""" + Determine whether the function func_signature has a boolean return type. + + If so, it will be declared in Cython as `bint` rather than `int`. + """ + if func_signature.count('(') != 1 or func_signature.count(')') != 1: + return False + + j = func_signature.index('(') + func_name = func_signature[:j].strip().split() + if len(func_name) != 2: + return False + + return_type = func_name[0] + if return_type != 'int': + return False + + func_name = func_name[1] + + return func_name.startswith('is_') or \ + '_is_' in func_name or \ + func_name.endswith('_eq') or \ + func_name.endswith('_ne') or \ + func_name.endswith('_lt') or \ + func_name.endswith('_le') or \ + func_name.endswith('_gt') or \ + func_name.endswith('_ge') or \ + '_contains_' in func_name or \ + func_name.endswith('_contains') or \ + '_equal_' in func_name or \ + func_name.endswith('_equal') or \ + func_name.endswith('_overlaps') + + def clean_signatures(self): + if (self.state & self.FUNCTION_DECLARATION) or (self.state & self.MACRO_DECLARATION): + for i, func_signature in enumerate(self.signatures): + replacement = [('(void)', '()'), (' enum ', ' ')] + for bad_type, good_type in replacement: + func_signature = func_signature.replace(bad_type, good_type) + + bad_arg_names = [('in', 'input'), ('lambda', 'lmbda'), ('iter', 'it'), ('is', 'iis')] + replacements = [(pattern.format(bad), pattern.format(good)) for pattern in [' {},', ' {})', '*{},', '*{})'] for bad, good in bad_arg_names] + for bad_form, good_form in replacements: + func_signature = func_signature.replace(bad_form, good_form) + + if self.has_boolean_return_type(func_signature): + func_signature = func_signature.strip() + if not func_signature.startswith('int '): + raise RuntimeError + func_signature = 'b' + func_signature + + self.signatures[i] = func_signature + + def add_declaration(self): + if self.state & self.FUNCTION_DECLARATION: + self.add_function() + elif self.state & self.MACRO_DECLARATION: + self.add_macro() + elif self.state & self.TYPE_DECLARATION: + self.add_type() + + self.signatures.clear() + self.doc.clear() + self.state = self.NONE + + def add_function(self): + self.clean_doc() + + # Drop va_list argument + signatures = [] + for func_signature in self.signatures: + if '(' not in func_signature or ')' not in func_signature: + raise RuntimeError(func_signature) + elif 'va_list ' in func_signature: + print('Warning: va_list unsupported {}'.format(func_signature)) + else: + signatures.append(func_signature) + self.signatures = signatures + self.clean_signatures() + + self.functions.append((tuple(self.signatures), tuple(self.doc))) + + def add_macro(self): + # TODO: we might want to support auto-generation of macros + return + + def add_type(self): + # TODO: we might want to support auto-generation of types + return + + def process_line(self): + r""" + Process one line of documentation. + """ + if self.i >= len(self.lines): + return 0 + + if bool(self.state & self.FUNCTION_DECLARATION) + bool(self.state & self.MACRO_DECLARATION) + bool(self.state & self.TYPE_DECLARATION) > 1: + raise RuntimeError('self.state = {} and i = {}'.format(self.state, self.i)) + + line = self.lines[self.i] + if line.startswith('.. function::'): + self.add_declaration() + if line[13] != ' ': + print('Warning: no space {}'.format(line)) + self.signatures.append(line[13:].strip()) + self.state = self.FUNCTION_DECLARATION + self.i += 1 + elif line.startswith('.. macro::'): + self.add_declaration() + if line[10] != ' ': + print('Warning no space{}'.format(line)) + self.signatures.append(line[10:].strip()) + self.state = self.MACRO_DECLARATION + self.i += 1 + elif line.startswith('.. type::'): + # type + # NOTE: we do nothing as the documentation duplicates type declaration + # and lacks the actual list of attributes + self.add_declaration() + self.state = self.TYPE_DECLARATION + self.i += 1 + elif self.state == self.FUNCTION_DECLARATION: + if len(line) > 14 and line.startswith(' ' * 14): + # function with similar declaration + line = line[14:].strip() + if line: + self.signatures.append(line) + self.i += 1 + elif not line.strip(): + # leaving function declaration + self.state |= self.DOC + self.i += 1 + else: + raise ValueError(line) + elif self.state == self.MACRO_DECLARATION: + if len(line) > 10 and line.startswith(' ' * 10): + # macro with similar declaration + line = line[10:].strip() + if line: + self.signatures.append(line) + self.i += 1 + elif not line.strip(): + # leaving macro declaration + self.state |= self.DOC + self.i += 1 + else: + raise ValueError(line) + elif (self.state & self.DOC) and line.startswith(' '): + # function doc + line = line.strip() + if line: + self.doc.append(line) + self.i += 1 + elif self.i + 1 < len(self.lines) and self.lines[self.i + 1].startswith('----'): + # new section + self.add_declaration() + if self.functions: + self.update_section() + section = line + self.i += 2 + elif not line: + self.i += 1 + else: + self.add_declaration() + self.i += 1 + + return 1 + + +def extract_functions(filename): + r""" + OUTPUT: + + dictionary: section -> list of pairs (func_sig, doc) + """ + e = Extractor(filename) + e.run() + return e.content + + + diff --git a/src/sage_setup/autogen/flint/templates/flint_sage.pyx.template b/src/sage_setup/autogen/flint/templates/flint_sage.pyx.template new file mode 100644 index 00000000000..24edaaa5945 --- /dev/null +++ b/src/sage_setup/autogen/flint/templates/flint_sage.pyx.template @@ -0,0 +1,31 @@ +# distutils: extra_compile_args = -D_XPG6 +""" +Flint imports + +TESTS: + +Import this module:: + + sage: import sage.libs.flint.flint_sage + +We verify that :trac:`6919` is correctly fixed:: + + sage: R. = PolynomialRing(ZZ) + sage: A = 2^(2^17+2^15) + sage: a = A * x^31 + sage: b = (A * x) * x^30 + sage: a == b + True +""" + +# cimport all .pxd files to make sure they compile +{CYTHON_IMPORTS} + +# Try to clean up after ourselves before sage terminates. This +# probably doesn't do anything if your copy of flint is re-entrant +# (and most are). Moreover it isn't strictly necessary, because the OS +# will reclaim these resources anyway after sage terminates. However +# this might reveal other bugs, and can help tools like valgrind do +# their jobs. +import atexit +atexit.register(_fmpz_cleanup_mpz_content) diff --git a/src/sage_setup/autogen/flint/templates/flint_wrap.h.template b/src/sage_setup/autogen/flint/templates/flint_wrap.h.template new file mode 100644 index 00000000000..d0922305269 --- /dev/null +++ b/src/sage_setup/autogen/flint/templates/flint_wrap.h.template @@ -0,0 +1,42 @@ +#ifndef SAGE_FLINT_WRAP_H +#define SAGE_FLINT_WRAP_H +/* Using flint headers together in the same module as headers from + * some other libraries (pari, possibly others) as it defines the + * macros ulong and slong all over the place. + * + * What's worse is they are defined to types from GMP (mp_limb_t and + * mp_limb_signed_t respectively) which themselves can have system-dependent + * typedefs, so there is no guarantee that all these 'ulong' definitions from + * different libraries' headers will be compatible. + * + * When including flint headers in Sage it should be done through this wrapper + * to prevent confusion. We rename flint's ulong and slong to fulong and + * fslong. This is consistent with flint's other f-prefixed typedefs. + */ + +#include + +/* Save previous definition of ulong if any, as pari also uses it */ +/* Should work on GCC, clang, MSVC */ +#pragma push_macro("ulong") +#undef ulong + +#include + +/* If flint was already previously included via another header (e.g. + * arb_wrap.h) then it may be necessary to redefine ulong and slong again */ + +#ifndef ulong +#define ulong mp_limb_t +#define slong mp_limb_signed_t +#endif + +{HEADER_LIST} + +#undef ulong +#undef slong +#undef mp_bitcnt_t + +#pragma pop_macro("ulong") + +#endif diff --git a/src/sage_setup/autogen/flint/templates/types.pxd.template b/src/sage_setup/autogen/flint/templates/types.pxd.template new file mode 100644 index 00000000000..e94346ffc8b --- /dev/null +++ b/src/sage_setup/autogen/flint/templates/types.pxd.template @@ -0,0 +1,2044 @@ +# distutils: depends = {HEADER_LIST} + +""" +Declarations for FLINT types +""" + +#***************************************************************************** +# Copyright (C) 2014 Jeroen Demeyer +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 2 of the License, or +# (at your option) any later version. +# http://www.gnu.org/licenses/ +#***************************************************************************** + +from sage.libs.gmp.types cimport * + +# Use these typedefs in lieu of flint's ulong and slong macros +ctypedef mp_limb_t ulong +ctypedef mp_limb_signed_t slong +ctypedef mp_limb_t flint_bitcnt_t + + +cdef extern from "flint_wrap.h": + # flint/fmpz.h + ctypedef slong fmpz + ctypedef fmpz fmpz_t[1] + + bint COEFF_IS_MPZ(fmpz) + mpz_ptr COEFF_TO_PTR(fmpz) + + ctypedef struct fmpz_preinvn_struct: + mp_ptr dinv + long n + mp_bitcnt_t norm + + ctypedef fmpz_preinvn_struct[1] fmpz_preinvn_t + + ctypedef struct fmpz_comb_struct: + pass + + ctypedef fmpz_comb_struct fmpz_comb_t[1] + + ctypedef struct fmpz_comb_temp_struct: + slong Alen, Tlen + fmpz * A + fmpz * T + + ctypedef fmpz_comb_temp_struct fmpz_comb_temp_t[1] + + ctypedef struct fmpz_multi_CRT_struct: + pass + + ctypedef fmpz_multi_CRT_struct fmpz_multi_CRT_t[1] + + + # flint/fmpq.h + ctypedef struct fmpq: + pass + + ctypedef fmpq fmpq_t[1] + + + # flint/arith.h + ctypedef struct trig_prod_struct: + pass + ctypedef trig_prod_struct trig_prod_t[1] + + + # flint/ulong_extras.pxd + ctypedef struct n_ecm_s: + pass + ctypedef n_ecm_s n_ecm_t[1] + + + # flint/arf.h + ctypedef enum arf_rnd_t: + ARF_RND_DOWN + ARF_RND_UP + ARF_RND_FLOOR + ARF_RND_CEIL + ARF_RND_NEAR + long ARF_PREC_EXACT + + + # flint/arf_types.h + ctypedef struct mantissa_noptr_struct: + pass + + ctypedef struct mantissa_ptr_struct: + pass + + ctypedef union mantissa_struct: + mantissa_noptr_struct noptr + mantissa_ptr_struct ptr + + ctypedef struct arf_struct: + pass + ctypedef arf_struct arf_t[1] + ctypedef arf_struct * arf_ptr + ctypedef const arf_struct * arf_srcptr + + ctypedef struct arf_interval_struct: + arf_struct a + arf_struct b + ctypedef arf_interval_struct arf_interval_t[1] + ctypedef arf_interval_struct * arf_interval_ptr + ctypedef const arf_interval_struct * arf_interval_srcptr + + + # flint/arb_types.h + ctypedef struct mag_struct: + pass + ctypedef mag_struct mag_t[1] + ctypedef mag_struct * mag_ptr + ctypedef const mag_struct * mag_srcptr + + ctypedef struct arb_struct: + pass + ctypedef arb_struct arb_t[1] + ctypedef arb_struct * arb_ptr + ctypedef const arb_struct * arb_srcptr + + ctypedef struct arb_mat_struct: + arb_ptr entries + slong r + slong c + arb_ptr * rows + ctypedef arb_mat_struct arb_mat_t[1] + + ctypedef struct arb_poly_struct: + pass + ctypedef arb_poly_struct[1] arb_poly_t + ctypedef arb_poly_struct * arb_poly_ptr + ctypedef const arb_poly_struct * arb_poly_srcptr + + + # flint/arb_calc.h + ctypedef int (*arb_calc_func_t)(arb_ptr out, const arb_t inp, + void * param, slong order, slong prec) + + + # flint/acb.h + ctypedef struct acb_struct: + pass + ctypedef acb_struct[1] acb_t + ctypedef acb_struct * acb_ptr + ctypedef const acb_struct * acb_srcptr + + + + # flint/acb_mat.h + ctypedef struct acb_mat_struct: + pass + ctypedef acb_mat_struct[1] acb_mat_t + + + # flint/acb_modular.h + ctypedef struct psl2z_struct: + fmpz a + fmpz b + fmpz c + fmpz d + ctypedef psl2z_struct psl2z_t[1] + + + # flint/acb_poly.h + ctypedef struct acb_poly_struct: + pass + ctypedef acb_poly_struct[1] acb_poly_t + ctypedef acb_poly_struct * acb_poly_ptr + ctypedef const acb_poly_struct * acb_poly_srcptr + + # flint/acb_calc.h + ctypedef struct acb_calc_integrate_opt_struct: + long deg_limit + long eval_limit + long depth_limit + bint use_heap + int verbose + ctypedef acb_calc_integrate_opt_struct acb_calc_integrate_opt_t[1] + ctypedef int (*acb_calc_func_t)(acb_ptr out, + const acb_t inp, void * param, long order, long prec) + + + # flint/acb_dft.h + ctypedef struct crt_struct: + pass + ctypedef crt_struct crt_t[1] + + ctypedef struct acb_dft_step_struct: + pass + ctypedef acb_dft_step_struct * acb_dft_step_ptr + + ctypedef struct acb_dft_cyc_struct: + pass + ctypedef acb_dft_cyc_struct acb_dft_cyc_t[1] + + ctypedef struct acb_dft_rad2_struct: + pass + ctypedef acb_dft_rad2_struct acb_dft_rad2_t[1] + + ctypedef struct acb_dft_bluestein_struct: + pass + ctypedef acb_dft_bluestein_struct acb_dft_bluestein_t[1] + + ctypedef struct acb_dft_prod_struct: + pass + ctypedef acb_dft_prod_struct acb_dft_prod_t[1] + + ctypedef struct acb_dft_crt_struct: + pass + ctypedef acb_dft_crt_struct acb_dft_crt_t[1] + + ctypedef struct acb_dft_naive_struct: + pass + ctypedef acb_dft_naive_struct acb_dft_naive_t[1] + + ctypedef struct acb_dft_pre_struct: + pass + ctypedef acb_dft_pre_struct acb_dft_pre_t[1] + + + # flint/acb_dirichlet.h + ctypedef struct acb_dirichlet_hurwitz_precomp_struct: + pass + ctypedef acb_dirichlet_hurwitz_precomp_struct acb_dirichlet_hurwitz_precomp_t[1] + + ctypedef struct acb_dirichlet_roots_struct: + pass + ctypedef acb_dirichlet_roots_struct acb_dirichlet_roots_t[1] + + ctypedef struct acb_dirichlet_platt_c_precomp_struct: + pass + ctypedef acb_dirichlet_platt_c_precomp_struct acb_dirichlet_platt_c_precomp_t[1] + + ctypedef struct acb_dirichlet_platt_i_precomp_struct: + pass + ctypedef acb_dirichlet_platt_i_precomp_struct acb_dirichlet_platt_i_precomp_t[1] + + ctypedef struct acb_dirichlet_platt_ws_precomp_struct: + pass + ctypedef acb_dirichlet_platt_ws_precomp_struct acb_dirichlet_platt_ws_precomp_t[1] + + + # flint/d_mat.h + ctypedef struct d_mat_struct: + double * entries + slong r + slong c + double ** rows + + ctypedef d_mat_struct d_mat_t[1] + + + # flint/flint.h + ctypedef struct flint_rand_s: + pass + ctypedef flint_rand_s flint_rand_t[1] + + cdef long FLINT_BITS + cdef long FLINT_D_BITS + + + # flint/limb_types.h + ctypedef struct n_factor_t: + int num + unsigned long exp[15] + unsigned long p[15] + + ctypedef struct n_primes_struct: + pass + + ctypedef n_primes_struct n_primes_t[1] + + long FLINT_MAX_FACTORS_IN_LIMB + + + # flint/fmpz_factor.h + ctypedef struct ecm_s: + pass + + ctypedef ecm_s ecm_t[1] + + + # flint/fmpz_mod.h + ctypedef struct fmpz_mod_discrete_log_pohlig_hellman_entry_struct: + pass + + ctypedef struct fmpz_mod_discrete_log_pohlig_hellman_struct: + pass + + ctypedef fmpz_mod_discrete_log_pohlig_hellman_struct fmpz_mod_discrete_log_pohlig_hellman_t[1] + + + # flint/nmod_poly.h + ctypedef struct nmod_t: + mp_limb_t n + mp_limb_t ninv + mp_bitcnt_t norm + + ctypedef struct nmod_poly_multi_crt_struct: + pass + + ctypedef nmod_poly_multi_crt_struct nmod_poly_multi_crt_t[1] + + ctypedef struct nmod_berlekamp_massey_struct: + pass + + ctypedef nmod_berlekamp_massey_struct nmod_berlekamp_massey_t[1] + + + # flint/fmpz_types.h + ctypedef struct fmpz_factor_struct: + int sign + fmpz* p + ulong* exp + slong alloc + slong num + + ctypedef fmpz_factor_struct fmpz_factor_t[1] + + ctypedef struct fmpz_poly_struct: + fmpz* coeffs + long alloc + long length + + ctypedef fmpz_poly_struct fmpz_poly_t[1] + + ctypedef struct fmpz_poly_factor_struct: + pass + + ctypedef fmpz_poly_factor_struct fmpz_poly_factor_t[1] + + ctypedef struct fmpz_mat_struct: + pass + + ctypedef fmpz_mat_struct fmpz_mat_t[1] + + ctypedef struct fmpz_poly_mat_struct: + pass + + ctypedef fmpz_poly_mat_struct fmpz_poly_mat_t[1] + + ctypedef struct fmpz_mpoly_struct: + pass + + ctypedef fmpz_mpoly_struct fmpz_mpoly_t[1] + + ctypedef struct fmpz_mpoly_factor_struct: + pass + + ctypedef fmpz_mpoly_factor_struct fmpz_mpoly_factor_t[1] + + ctypedef struct fmpz_poly_q_struct: + fmpz_poly_struct *num + fmpz_poly_struct *den + + ctypedef fmpz_poly_q_struct fmpz_poly_q_t[1] + + ctypedef struct fmpz_mpoly_q_struct: + pass + + ctypedef fmpz_mpoly_q_struct fmpz_mpoly_q_t[1] + + ctypedef struct fmpzi_struct: + fmpz a + fmpz b + + ctypedef fmpzi_struct fmpzi_t[1] + + + # flint/fmpq_types.h + ctypedef struct fmpq_mat_struct: + pass + ctypedef fmpq_mat_struct fmpq_mat_t[1] + + ctypedef struct fmpq_poly_struct: + pass + ctypedef fmpq_poly_struct fmpq_poly_t[1] + + ctypedef struct fmpq_mpoly_struct: + pass + ctypedef fmpq_mpoly_struct fmpq_mpoly_t[1] + + ctypedef struct fmpq_mpoly_factor_struct: + pass + ctypedef fmpq_mpoly_factor_struct fmpq_mpoly_factor_t[1] + + + # flint/nmod_types.h + ctypedef struct nmod_mat_struct: + mp_limb_t * entries + slong r + slong c + mp_limb_t ** rows + nmod_t mod + + ctypedef nmod_mat_struct nmod_mat_t[1] + + ctypedef struct nmod_poly_struct: + mp_ptr coeffs + slong alloc + slong length + nmod_t mod + + ctypedef nmod_poly_struct nmod_poly_t[1] + + ctypedef struct nmod_poly_factor_struct: + nmod_poly_struct * p + slong *exp + slong num + slong alloc + + ctypedef nmod_poly_factor_struct nmod_poly_factor_t[1] + + ctypedef struct nmod_poly_mat_struct: + nmod_poly_struct * entries + slong r + slong c + nmod_poly_struct ** rows + mp_limb_t modulus + + ctypedef nmod_poly_mat_struct nmod_poly_mat_t[1] + + ctypedef struct nmod_mpoly_struct: + mp_limb_t * coeffs + ulong * exps + slong length + flint_bitcnt_t bits + slong coeffs_alloc + slong exps_alloc + + ctypedef nmod_mpoly_struct nmod_mpoly_t[1] + + ctypedef struct nmod_mpoly_factor_struct: + mp_limb_t constant + nmod_mpoly_struct * poly + fmpz * exp + slong num + slong alloc + + ctypedef nmod_mpoly_factor_struct nmod_mpoly_factor_t[1] + + + # flint/nmod_mpoly.h + ctypedef struct nmod_mpoly_univar_struct: + pass + ctypedef nmod_mpoly_univar_struct nmod_mpoly_univar_t[1] + + ctypedef struct nmod_mpolyu_struct: + pass + ctypedef nmod_mpolyu_struct nmod_mpolyu_t[1] + + ctypedef struct nmod_mpolyn_struct: + pass + ctypedef nmod_mpolyn_struct nmod_mpolyn_t[1] + + ctypedef struct nmod_mpolyun_struct: + pass + ctypedef nmod_mpolyun_struct nmod_mpolyun_t[1] + + ctypedef struct nmod_mpolyd_struct: + pass + ctypedef nmod_mpolyd_struct nmod_mpolyd_t[1] + + ctypedef struct nmod_poly_stack_struct: + pass + ctypedef nmod_poly_stack_struct nmod_poly_stack_t[1] + + + # flint/fq_nmod_types.h + ctypedef nmod_poly_t fq_nmod_t + ctypedef nmod_poly_struct fq_nmod_struct + + ctypedef struct fq_nmod_ctx_struct: + pass + ctypedef fq_nmod_ctx_struct fq_nmod_ctx_t[1] + + ctypedef struct fq_nmod_mat_struct: + pass + ctypedef fq_nmod_mat_struct fq_nmod_mat_t[1] + + ctypedef struct fq_nmod_poly_struct: + pass + ctypedef fq_nmod_poly_struct fq_nmod_poly_t[1] + + ctypedef struct fq_nmod_poly_factor_struct: + pass + ctypedef fq_nmod_poly_factor_struct fq_nmod_poly_factor_t[1] + + + # flint2/fq_nmod_mpoly.h + ctypedef struct fq_nmod_mpoly_ctx_struct: + pass + ctypedef fq_nmod_mpoly_ctx_struct fq_nmod_mpoly_ctx_t[1] + + ctypedef struct fq_nmod_mpoly_struct: + pass + ctypedef fq_nmod_mpoly_struct fq_nmod_mpoly_t[1] + + ctypedef struct fq_nmod_mpoly_univar_struct: + pass + ctypedef fq_nmod_mpoly_univar_struct fq_nmod_mpoly_univar_t[1] + + ctypedef struct fq_nmod_mpolyu_struct: + pass + ctypedef fq_nmod_mpolyu_struct fq_nmod_mpolyu_t[1] + + ctypedef struct fq_nmod_mpolyn_struct: + pass + ctypedef fq_nmod_mpolyn_struct fq_nmod_mpolyn_t[1] + + ctypedef struct fq_nmod_mpolyun_struct: + pass + ctypedef fq_nmod_mpolyun_struct fq_nmod_mpolyun_t[1] + + ctypedef struct bad_fq_nmod_embed_struct: + pass + ctypedef bad_fq_nmod_embed_struct bad_fq_nmod_embed_t[1] + + + # flint2/fq_nmod_mpoly_factor.h + ctypedef struct fq_nmod_mpoly_factor_struct: + pass + ctypedef fq_nmod_mpoly_factor_struct fq_nmod_mpoly_factor_t[1] + + ctypedef struct fq_nmod_mpolyv_struct: + pass + ctypedef fq_nmod_mpolyv_struct fq_nmod_mpolyv_t[1] + + ctypedef struct fq_nmod_mpoly_pfrac_struct: + pass + ctypedef fq_nmod_mpoly_pfrac_struct fq_nmod_mpoly_pfrac_t[1] + + + # flint/fmpz_poly.h + ctypedef struct fmpz_poly_powers_precomp_struct: + fmpz ** powers + slong len + + ctypedef fmpz_poly_powers_precomp_struct fmpz_poly_powers_precomp_t[1] + + ctypedef struct fmpz_poly_mul_precache_struct: + mp_limb_t ** jj + slong n + slong len2 + slong loglen + slong bits2 + slong limbs + fmpz_poly_t poly2 + + ctypedef fmpz_poly_mul_precache_struct fmpz_poly_mul_precache_t[1] + + + # flint/fmpz_mod_types.h + ctypedef struct fmpz_mod_ctx_struct: + pass + + ctypedef fmpz_mod_ctx_struct fmpz_mod_ctx_t[1] + + ctypedef struct fmpz_mod_mat_struct: + fmpz_mat_t mat + fmpz_t mod + + ctypedef fmpz_mod_mat_struct fmpz_mod_mat_t[1] + + ctypedef struct fmpz_mod_poly_struct: + fmpz * coeffs + slong alloc + slong length + + ctypedef fmpz_mod_poly_struct fmpz_mod_poly_t[1] + + ctypedef struct fmpz_mod_poly_factor_struct: + fmpz_mod_poly_struct * poly + slong *exp + slong num + slong alloc + + ctypedef fmpz_mod_poly_factor_struct fmpz_mod_poly_factor_t[1] + + ctypedef struct fmpz_mod_mpoly_struct: + fmpz * coeffs + ulong * exps + slong length + flint_bitcnt_t bits + slong coeffs_alloc + slong exps_alloc + + ctypedef fmpz_mod_mpoly_struct fmpz_mod_mpoly_t[1] + + ctypedef struct fmpz_mod_mpoly_factor_struct: + fmpz_t constant + fmpz_mod_mpoly_struct * poly + fmpz * exp + slong num + slong alloc + + ctypedef fmpz_mod_mpoly_factor_struct fmpz_mod_mpoly_factor_t[1] + + + # flint/fmpq_poly.h + ctypedef struct fmpq_poly_powers_precomp_struct: + fmpq_poly_struct * powers + slong len + + ctypedef fmpq_poly_powers_precomp_struct fmpq_poly_powers_precomp_t[1] + + + # flint/fmpz_mod_poly.h: + ctypedef struct fmpz_mod_poly_res_struct: + pass + + ctypedef fmpz_mod_poly_res_struct fmpz_mod_poly_res_t[1] + + ctypedef struct fmpz_mod_poly_frobenius_powers_2exp_struct: + pass + + ctypedef fmpz_mod_poly_frobenius_powers_2exp_struct fmpz_mod_poly_frobenius_powers_2exp_t[1] + + ctypedef struct fmpz_mod_poly_frobenius_powers_struct: + pass + + ctypedef fmpz_mod_poly_frobenius_powers_struct fmpz_mod_poly_frobenius_powers_t[1] + + ctypedef struct fmpz_mod_poly_matrix_precompute_arg_t: + pass + + ctypedef struct fmpz_mod_poly_compose_mod_precomp_preinv_arg_t: + pass + + ctypedef struct fmpz_mod_poly_radix_struct: + pass + + ctypedef fmpz_mod_poly_radix_struct fmpz_mod_poly_radix_t[1] + + ctypedef struct fmpz_mod_berlekamp_massey_struct: + pass + + ctypedef fmpz_mod_berlekamp_massey_struct fmpz_mod_berlekamp_massey_t[1] + + + # flint/nmod.h + ctypedef struct nmod_discrete_log_pohlig_hellman_table_entry_struct: + pass + + ctypedef struct nmod_discrete_log_pohlig_hellman_entry_struct: + pass + + ctypedef struct nmod_discrete_log_pohlig_hellman_struct: + pass + ctypedef nmod_discrete_log_pohlig_hellman_struct nmod_discrete_log_pohlig_hellman_t[1] + + + # flint/fq_types.h + ctypedef fmpz_poly_t fq_t + ctypedef fmpz_poly_struct fq_struct + + ctypedef struct fq_ctx_struct: + pass + + ctypedef fq_ctx_struct fq_ctx_t[1] + + ctypedef struct fq_mat_struct: + pass + ctypedef fq_mat_struct fq_mat_t[1] + + ctypedef struct fq_poly_struct: + pass + ctypedef fq_poly_struct fq_poly_t[1] + + ctypedef struct fq_poly_factor_struct: + pass + ctypedef fq_poly_factor_struct fq_poly_factor_t[1] + + + # flint/fq_zech_types.h + ctypedef struct fq_zech_struct: + pass + ctypedef fq_zech_struct fq_zech_t[1] + + ctypedef struct fq_zech_ctx_struct: + pass + ctypedef fq_zech_ctx_struct fq_zech_ctx_t[1] + + ctypedef struct fq_zech_mat_struct: + pass + ctypedef fq_zech_mat_struct fq_zech_mat_t[1] + + ctypedef struct fq_zech_poly_struct: + pass + ctypedef fq_zech_poly_struct fq_zech_poly_t[1] + + ctypedef struct fq_zech_poly_factor_struct: + pass + ctypedef fq_zech_poly_factor_struct fq_zech_poly_factor_t[1] + + + # flint/padic.h + ctypedef struct padic_struct: + fmpz u + long v + + ctypedef padic_struct padic_t[1] + + cdef enum padic_print_mode: + PADIC_TERSE + PADIC_SERIES + PADIC_VAL_UNIT + + ctypedef struct padic_ctx_struct: + fmpz_t p + long N + double pinv + fmpz* pow + long min + long max + + ctypedef padic_ctx_struct padic_ctx_t[1] + + ctypedef struct padic_inv_struct: + long n + fmpz *pow + fmpz *u + + ctypedef padic_inv_struct padic_inv_t[1] + + + # flint/fmpz_mod_mpoly.h + ctypedef struct fmpz_mod_mpoly_univar_struct: + pass + ctypedef fmpz_mod_mpoly_univar_struct fmpz_mod_mpoly_univar_t[1] + + + # flint/padic_poly.h + ctypedef struct padic_poly_struct: + fmpz *coeffs + long alloc + long length + long val + long N + + ctypedef padic_poly_struct padic_poly_t[1] + + + # flint/padic_mat.h + ctypedef struct padic_mat_struct: + pass + ctypedef padic_mat_struct padic_mat_t[1] + + + # flint/qadic.h + ctypedef struct qadic_ctx_struct: + padic_ctx_struct pctx + fmpz *a + long *j + long len + char *var + + ctypedef qadic_ctx_struct qadic_ctx_t[1] + + ctypedef padic_poly_struct qadic_struct + ctypedef padic_poly_t qadic_t + + + # flint/qsieve.h + ctypedef struct prime_t: + pass + + ctypedef struct fac_t: + pass + + ctypedef struct la_col_t: + pass + + ctypedef struct hash_t: + pass + + ctypedef struct relation_t: + pass + + ctypedef struct qs_poly_s: + pass + ctypedef qs_poly_s qs_poly_t[1] + + ctypedef struct qs_s: + pass + ctypedef qs_s qs_t[1] + + + # flint/thread_pool.h + ctypedef struct thread_pool_entry_struct: + pass + + ctypedef thread_pool_entry_struct thread_pool_entry_t[1] + + ctypedef struct thread_pool_struct: + pass + + ctypedef thread_pool_struct thread_pool_t[1] + ctypedef int thread_pool_handle + + + # flint/bernoulli.h + ctypedef struct bernoulli_rev_struct: + pass + ctypedef bernoulli_rev_struct bernoulli_rev_t[1] + + + # flint/mpoly_types.h + ctypedef enum ordering_t: + ORD_LEX + ORD_DEGLEX + ORD_DEGREVLEX + + ctypedef struct mpoly_ctx_struct: + pass + ctypedef mpoly_ctx_struct mpoly_ctx_t[1] + + ctypedef struct nmod_mpoly_ctx_struct: + pass + ctypedef nmod_mpoly_ctx_struct nmod_mpoly_ctx_t[1] + + ctypedef struct fmpz_mpoly_ctx_struct: + pass + ctypedef fmpz_mpoly_ctx_struct fmpz_mpoly_ctx_t[1] + + ctypedef struct fmpq_mpoly_ctx_struct: + pass + + ctypedef fmpq_mpoly_ctx_struct fmpq_mpoly_ctx_t[1] + + ctypedef struct fmpz_mod_mpoly_ctx_struct: + pass + ctypedef fmpz_mod_mpoly_ctx_struct fmpz_mod_mpoly_ctx_t[1] + + + # flint/mpoly.h + ctypedef struct mpoly_heap_t: + pass + + ctypedef struct mpoly_nheap_t: + pass + + ctypedef struct mpoly_heap1_s: + pass + + ctypedef struct mpoly_heap_s: + pass + + ctypedef struct mpoly_rbnode_ui_struct: + pass + + ctypedef struct mpoly_rbtree_ui_struct: + pass + + ctypedef mpoly_rbtree_ui_struct mpoly_rbtree_ui_t[1] + + ctypedef struct mpoly_rbnode_fmpz_struct: + pass + + ctypedef struct mpoly_rbtree_fmpz_struct: + pass + ctypedef mpoly_rbtree_fmpz_struct mpoly_rbtree_fmpz_t[1] + + ctypedef struct mpoly_gcd_info_struct: + pass + ctypedef mpoly_gcd_info_struct mpoly_gcd_info_t[1] + + ctypedef struct mpoly_compression_struct: + pass + ctypedef mpoly_compression_struct mpoly_compression_t[1] + + ctypedef struct mpoly_univar_struct: + pass + ctypedef mpoly_univar_struct mpoly_univar_t[1] + + ctypedef struct mpoly_void_ring_struct: + pass + ctypedef mpoly_void_ring_struct mpoly_void_ring_t[1] + + ctypedef struct string_with_length_struct: + pass + + ctypedef struct mpoly_parse_struct: + pass + ctypedef mpoly_parse_struct mpoly_parse_t[1] + + + # flint/fmpz_mpoly.h + ctypedef struct fmpz_mpoly_univar_struct: + pass + ctypedef fmpz_mpoly_univar_struct fmpz_mpoly_univar_t[1] + + ctypedef struct fmpz_mpolyd_struct: + pass + ctypedef fmpz_mpolyd_struct fmpz_mpolyd_t[1] + + ctypedef struct fmpz_mpoly_vec_struct: + pass + ctypedef fmpz_mpoly_vec_struct fmpz_mpoly_vec_t[1] + + ctypedef struct fmpz_mpolyd_ctx_struct: + pass + ctypedef fmpz_mpolyd_ctx_struct fmpz_mpolyd_ctx_t[1] + + ctypedef struct fmpz_pow_cache_struct: + pass + ctypedef fmpz_pow_cache_struct fmpz_pow_cache_t[1] + + ctypedef struct fmpz_mpoly_geobucket_struct: + pass + ctypedef fmpz_mpoly_geobucket_struct fmpz_mpoly_geobucket_t[1] + + + # flint/fmpq_mpoly.h + ctypedef struct fmpq_mpoly_univar_struct: + pass + ctypedef fmpq_mpoly_univar_struct fmpq_mpoly_univar_t[1] + + + # flint/fft_small.h + ctypedef struct mpn_ctx_struct: + pass + ctypedef mpn_ctx_struct mpn_ctx_t[1] + + ctypedef struct mul_precomp_struct: + pass + + ctypedef struct nmod_poly_divrem_precomp_struct: + pass + + + # flint/nf.h + ctypedef struct nf_struct: + pass + ctypedef nf_struct nf_t[1] + + + # flint/nf_elem.h + ctypedef struct lnf_elem_struct: + pass + ctypedef lnf_elem_struct lnf_elem_t[1] + + ctypedef struct qnf_elem_struct: + pass + ctypedef qnf_elem_struct qnf_elem_t[1] + + ctypedef union nf_elem_struct: + fmpq_poly_t elem + lnf_elem_t lelem + qnf_elem_t qelem + ctypedef nf_elem_struct nf_elem_t[1] + + + # flint/calcium.h + ctypedef struct calcium_stream_struct: + pass + ctypedef calcium_stream_struct calcium_stream_t[1] + + + ctypedef enum truth_t: + T_TRUE + T_FALSE + T_UNKNOWN + + ctypedef enum calcium_func_code: + CA_QQBar + CA_Neg + CA_Add + CA_Sub + CA_Mul + CA_Div + CA_Sqrt + CA_Cbrt + CA_Root + CA_Floor + CA_Ceil + CA_Abs + CA_Sign + CA_Re + CA_Im + CA_Arg + CA_Conjugate + CA_Pi + CA_Sin + CA_Cos + CA_Exp + CA_Log + CA_Pow + CA_Tan + CA_Cot + CA_Cosh + CA_Sinh + CA_Tanh + CA_Coth + CA_Atan + CA_Acos + CA_Asin + CA_Acot + CA_Atanh + CA_Acosh + CA_Asinh + CA_Acoth + CA_Euler + CA_Gamma + CA_LogGamma + CA_Psi + CA_Erf + CA_Erfc + CA_Erfi + CA_RiemannZeta + CA_HurwitzZeta + CA_FUNC_CODE_LENGTH + + + # flint/ca.h + ctypedef union ca_elem_struct: + fmpq q + nf_elem_struct nf + fmpz_mpoly_q_struct * mpoly_q + + ctypedef struct ca_struct: + ulong field + ca_elem_struct elem + + ctypedef ca_struct ca_t[1] + ctypedef ca_struct * ca_ptr + ctypedef const ca_struct * ca_srcptr + + ctypedef struct ca_ext_qqbar: + pass + + ctypedef struct ca_ext_func_data: + pass + + ctypedef struct ca_ext_struct: + pass + + ctypedef ca_ext_struct ca_ext_t[1] + ctypedef ca_ext_struct * ca_ext_ptr + ctypedef const ca_ext_struct * ca_ext_srcptr + + ctypedef struct ca_ext_cache_struct: + pass + + ctypedef ca_ext_cache_struct ca_ext_cache_t[1] + + ctypedef struct ca_field_struct: + pass + + ctypedef ca_field_struct ca_field_t[1] + ctypedef ca_field_struct * ca_field_ptr + ctypedef const ca_field_struct * ca_field_srcptr + + ctypedef struct ca_field_cache_struct: + pass + + ctypedef ca_field_cache_struct ca_field_cache_t[1] + + cdef enum: + CA_OPT_VERBOSE + CA_OPT_PRINT_FLAGS + CA_OPT_MPOLY_ORD + CA_OPT_PREC_LIMIT + CA_OPT_QQBAR_DEG_LIMIT + CA_OPT_LOW_PREC + CA_OPT_SMOOTH_LIMIT + CA_OPT_LLL_PREC + CA_OPT_POW_LIMIT + CA_OPT_USE_GROEBNER + CA_OPT_GROEBNER_LENGTH_LIMIT + CA_OPT_GROEBNER_POLY_LENGTH_LIMIT + CA_OPT_GROEBNER_POLY_BITS_LIMIT + CA_OPT_VIETA_LIMIT + CA_OPT_TRIG_FORM + CA_OPT_NUM_OPTIONS + + ctypedef struct ca_ctx_struct: + pass + + ctypedef ca_ctx_struct ca_ctx_t[1] + + ctypedef struct ca_factor_struct: + pass + ctypedef ca_factor_struct ca_factor_t[1] + + + # flint/ca_poly.h + ctypedef struct ca_poly_struct: + pass + ctypedef ca_poly_struct ca_poly_t[1] + + ctypedef struct ca_poly_vec_struct: + pass + ctypedef ca_poly_vec_struct ca_poly_vec_t[1] + + + # flint/ca_vec.h + ctypedef struct ca_vec_struct: + pass + ctypedef ca_vec_struct ca_vec_t[1] + + + # flint/ca_mat.h + ctypedef struct ca_mat_struct: + pass + ctypedef ca_mat_struct ca_mat_t[1] + + + # flint/mpf_vec.h + ctypedef __mpf_struct mpf + + + # flint/mpf_mat.h + ctypedef struct mpf_mat_struct: + pass + ctypedef mpf_mat_struct mpf_mat_t[1] + + + # flint/mpfr_mat.h + ctypedef struct mpfr_mat_struct: + pass + ctypedef mpfr_mat_struct mpfr_mat_t[1] + + + # flint/gr.h + ctypedef int (*gr_funcptr)() + + ctypedef struct gr_stream_struct: + pass + ctypedef gr_stream_struct gr_stream_t[1] + + ctypedef void * gr_ptr + ctypedef const void * gr_srcptr + ctypedef void * gr_ctx_ptr + + ctypedef struct gr_vec_struct: + pass + ctypedef gr_vec_struct gr_vec_t[1] + + ctypedef enum gr_method: + GR_METHOD_CTX_WRITE + GR_METHOD_CTX_CLEAR + GR_METHOD_CTX_IS_RING + GR_METHOD_CTX_IS_COMMUTATIVE_RING + GR_METHOD_CTX_IS_INTEGRAL_DOMAIN + GR_METHOD_CTX_IS_FIELD + GR_METHOD_CTX_IS_UNIQUE_FACTORIZATION_DOMAIN + GR_METHOD_CTX_IS_FINITE + GR_METHOD_CTX_IS_FINITE_CHARACTERISTIC + GR_METHOD_CTX_IS_ALGEBRAICALLY_CLOSED + GR_METHOD_CTX_IS_ORDERED_RING + GR_METHOD_CTX_IS_MULTIPLICATIVE_GROUP + GR_METHOD_CTX_IS_EXACT + GR_METHOD_CTX_IS_CANONICAL + GR_METHOD_CTX_IS_THREADSAFE + GR_METHOD_CTX_HAS_REAL_PREC + GR_METHOD_CTX_SET_REAL_PREC + GR_METHOD_CTX_GET_REAL_PREC + GR_METHOD_CTX_SET_GEN_NAME + GR_METHOD_CTX_SET_GEN_NAMES + GR_METHOD_INIT + GR_METHOD_CLEAR + GR_METHOD_SWAP + GR_METHOD_SET_SHALLOW + GR_METHOD_WRITE + GR_METHOD_WRITE_N + GR_METHOD_RANDTEST + GR_METHOD_RANDTEST_NOT_ZERO + GR_METHOD_RANDTEST_SMALL + GR_METHOD_ZERO + GR_METHOD_ONE + GR_METHOD_NEG_ONE + GR_METHOD_IS_ZERO + GR_METHOD_IS_ONE + GR_METHOD_IS_NEG_ONE + GR_METHOD_EQUAL + GR_METHOD_SET + GR_METHOD_SET_UI + GR_METHOD_SET_SI + GR_METHOD_SET_FMPZ + GR_METHOD_SET_FMPQ + GR_METHOD_SET_D + GR_METHOD_SET_OTHER + GR_METHOD_SET_STR + GR_METHOD_GET_SI + GR_METHOD_GET_UI + GR_METHOD_GET_FMPZ + GR_METHOD_GET_FMPQ + GR_METHOD_GET_D + GR_METHOD_GET_FEXPR + GR_METHOD_GET_FEXPR_SERIALIZE + GR_METHOD_SET_FEXPR + GR_METHOD_NEG + GR_METHOD_ADD + GR_METHOD_ADD_UI + GR_METHOD_ADD_SI + GR_METHOD_ADD_FMPZ + GR_METHOD_ADD_FMPQ + GR_METHOD_ADD_OTHER + GR_METHOD_OTHER_ADD + GR_METHOD_SUB + GR_METHOD_SUB_UI + GR_METHOD_SUB_SI + GR_METHOD_SUB_FMPZ + GR_METHOD_SUB_FMPQ + GR_METHOD_SUB_OTHER + GR_METHOD_OTHER_SUB + GR_METHOD_MUL + GR_METHOD_MUL_UI + GR_METHOD_MUL_SI + GR_METHOD_MUL_FMPZ + GR_METHOD_MUL_FMPQ + GR_METHOD_MUL_OTHER + GR_METHOD_OTHER_MUL + GR_METHOD_ADDMUL + GR_METHOD_ADDMUL_UI + GR_METHOD_ADDMUL_SI + GR_METHOD_ADDMUL_FMPZ + GR_METHOD_ADDMUL_FMPQ + GR_METHOD_ADDMUL_OTHER + GR_METHOD_SUBMUL + GR_METHOD_SUBMUL_UI + GR_METHOD_SUBMUL_SI + GR_METHOD_SUBMUL_FMPZ + GR_METHOD_SUBMUL_FMPQ + GR_METHOD_SUBMUL_OTHER + GR_METHOD_FMA + GR_METHOD_FMS + GR_METHOD_FMMA + GR_METHOD_FMMS + GR_METHOD_MUL_TWO + GR_METHOD_SQR + GR_METHOD_MUL_2EXP_SI + GR_METHOD_MUL_2EXP_FMPZ + GR_METHOD_SET_FMPZ_2EXP_FMPZ + GR_METHOD_GET_FMPZ_2EXP_FMPZ + GR_METHOD_IS_INVERTIBLE + GR_METHOD_INV + GR_METHOD_DIV + GR_METHOD_DIV_UI + GR_METHOD_DIV_SI + GR_METHOD_DIV_FMPZ + GR_METHOD_DIV_FMPQ + GR_METHOD_DIV_OTHER + GR_METHOD_OTHER_DIV + GR_METHOD_DIVEXACT + GR_METHOD_DIVEXACT_UI + GR_METHOD_DIVEXACT_SI + GR_METHOD_DIVEXACT_FMPZ + GR_METHOD_DIVEXACT_FMPQ + GR_METHOD_DIVEXACT_OTHER + GR_METHOD_OTHER_DIVEXACT + GR_METHOD_POW + GR_METHOD_POW_UI + GR_METHOD_POW_SI + GR_METHOD_POW_FMPZ + GR_METHOD_POW_FMPQ + GR_METHOD_POW_OTHER + GR_METHOD_OTHER_POW + GR_METHOD_IS_SQUARE + GR_METHOD_SQRT + GR_METHOD_RSQRT + GR_METHOD_HYPOT + GR_METHOD_IS_PERFECT_POWER + GR_METHOD_FACTOR_PERFECT_POWER + GR_METHOD_ROOT_UI + GR_METHOD_DIVIDES + GR_METHOD_EUCLIDEAN_DIV + GR_METHOD_EUCLIDEAN_REM + GR_METHOD_EUCLIDEAN_DIVREM + GR_METHOD_GCD + GR_METHOD_LCM + GR_METHOD_FACTOR + GR_METHOD_NUMERATOR + GR_METHOD_DENOMINATOR + GR_METHOD_FLOOR + GR_METHOD_CEIL + GR_METHOD_TRUNC + GR_METHOD_NINT + GR_METHOD_CMP + GR_METHOD_CMPABS + GR_METHOD_CMP_OTHER + GR_METHOD_CMPABS_OTHER + GR_METHOD_MIN + GR_METHOD_MAX + GR_METHOD_ABS + GR_METHOD_ABS2 + GR_METHOD_I + GR_METHOD_CONJ + GR_METHOD_RE + GR_METHOD_IM + GR_METHOD_SGN + GR_METHOD_CSGN + GR_METHOD_ARG + GR_METHOD_POS_INF + GR_METHOD_NEG_INF + GR_METHOD_UINF + GR_METHOD_UNDEFINED + GR_METHOD_UNKNOWN + GR_METHOD_IS_INTEGER + GR_METHOD_IS_RATIONAL + GR_METHOD_IS_REAL + GR_METHOD_IS_POSITIVE_INTEGER + GR_METHOD_IS_NONNEGATIVE_INTEGER + GR_METHOD_IS_NEGATIVE_INTEGER + GR_METHOD_IS_NONPOSITIVE_INTEGER + GR_METHOD_IS_POSITIVE_REAL + GR_METHOD_IS_NONNEGATIVE_REAL + GR_METHOD_IS_NEGATIVE_REAL + GR_METHOD_IS_NONPOSITIVE_REAL + GR_METHOD_IS_ROOT_OF_UNITY + GR_METHOD_ROOT_OF_UNITY_UI + GR_METHOD_ROOT_OF_UNITY_UI_VEC + GR_METHOD_PI + GR_METHOD_EXP + GR_METHOD_EXPM1 + GR_METHOD_EXP_PI_I + GR_METHOD_EXP2 + GR_METHOD_EXP10 + GR_METHOD_LOG + GR_METHOD_LOG1P + GR_METHOD_LOG_PI_I + GR_METHOD_LOG2 + GR_METHOD_LOG10 + GR_METHOD_SIN + GR_METHOD_COS + GR_METHOD_SIN_COS + GR_METHOD_TAN + GR_METHOD_COT + GR_METHOD_SEC + GR_METHOD_CSC + GR_METHOD_SIN_PI + GR_METHOD_COS_PI + GR_METHOD_SIN_COS_PI + GR_METHOD_TAN_PI + GR_METHOD_COT_PI + GR_METHOD_SEC_PI + GR_METHOD_CSC_PI + GR_METHOD_SINC + GR_METHOD_SINC_PI + GR_METHOD_SINH + GR_METHOD_COSH + GR_METHOD_SINH_COSH + GR_METHOD_TANH + GR_METHOD_COTH + GR_METHOD_SECH + GR_METHOD_CSCH + GR_METHOD_ASIN + GR_METHOD_ACOS + GR_METHOD_ATAN + GR_METHOD_ATAN2 + GR_METHOD_ACOT + GR_METHOD_ASEC + GR_METHOD_ACSC + GR_METHOD_ASINH + GR_METHOD_ACOSH + GR_METHOD_ATANH + GR_METHOD_ACOTH + GR_METHOD_ASECH + GR_METHOD_ACSCH + GR_METHOD_ASIN_PI + GR_METHOD_ACOS_PI + GR_METHOD_ATAN_PI + GR_METHOD_ACOT_PI + GR_METHOD_ASEC_PI + GR_METHOD_ACSC_PI + GR_METHOD_FAC + GR_METHOD_FAC_UI + GR_METHOD_FAC_FMPZ + GR_METHOD_FAC_VEC + GR_METHOD_RFAC + GR_METHOD_RFAC_UI + GR_METHOD_RFAC_FMPZ + GR_METHOD_RFAC_VEC + GR_METHOD_BIN + GR_METHOD_BIN_UI + GR_METHOD_BIN_UIUI + GR_METHOD_BIN_VEC + GR_METHOD_BIN_UI_VEC + GR_METHOD_RISING_UI + GR_METHOD_RISING + GR_METHOD_FALLING_UI + GR_METHOD_FALLING + GR_METHOD_GAMMA + GR_METHOD_GAMMA_FMPZ + GR_METHOD_GAMMA_FMPQ + GR_METHOD_RGAMMA + GR_METHOD_LGAMMA + GR_METHOD_DIGAMMA + GR_METHOD_BETA + GR_METHOD_DOUBLEFAC + GR_METHOD_DOUBLEFAC_UI + GR_METHOD_BARNES_G + GR_METHOD_LOG_BARNES_G + GR_METHOD_HARMONIC + GR_METHOD_HARMONIC_UI + GR_METHOD_BERNOULLI_UI + GR_METHOD_BERNOULLI_FMPZ + GR_METHOD_BERNOULLI_VEC + GR_METHOD_FIB_UI + GR_METHOD_FIB_FMPZ + GR_METHOD_FIB_VEC + GR_METHOD_STIRLING_S1U_UIUI + GR_METHOD_STIRLING_S1_UIUI + GR_METHOD_STIRLING_S2_UIUI + GR_METHOD_STIRLING_S1U_UI_VEC + GR_METHOD_STIRLING_S1_UI_VEC + GR_METHOD_STIRLING_S2_UI_VEC + GR_METHOD_EULERNUM_UI + GR_METHOD_EULERNUM_FMPZ + GR_METHOD_EULERNUM_VEC + GR_METHOD_BELLNUM_UI + GR_METHOD_BELLNUM_FMPZ + GR_METHOD_BELLNUM_VEC + GR_METHOD_PARTITIONS_UI + GR_METHOD_PARTITIONS_FMPZ + GR_METHOD_PARTITIONS_VEC + GR_METHOD_CHEBYSHEV_T_FMPZ + GR_METHOD_CHEBYSHEV_U_FMPZ + GR_METHOD_CHEBYSHEV_T + GR_METHOD_CHEBYSHEV_U + GR_METHOD_JACOBI_P + GR_METHOD_GEGENBAUER_C + GR_METHOD_LAGUERRE_L + GR_METHOD_HERMITE_H + GR_METHOD_LEGENDRE_P + GR_METHOD_LEGENDRE_Q + GR_METHOD_LEGENDRE_P_ROOT_UI + GR_METHOD_SPHERICAL_Y_SI + GR_METHOD_EULER + GR_METHOD_CATALAN + GR_METHOD_KHINCHIN + GR_METHOD_GLAISHER + GR_METHOD_LAMBERTW + GR_METHOD_LAMBERTW_FMPZ + GR_METHOD_ERF + GR_METHOD_ERFC + GR_METHOD_ERFCX + GR_METHOD_ERFI + GR_METHOD_ERFINV + GR_METHOD_ERFCINV + GR_METHOD_FRESNEL_S + GR_METHOD_FRESNEL_C + GR_METHOD_FRESNEL + GR_METHOD_GAMMA_UPPER + GR_METHOD_GAMMA_LOWER + GR_METHOD_BETA_LOWER + GR_METHOD_EXP_INTEGRAL + GR_METHOD_EXP_INTEGRAL_EI + GR_METHOD_SIN_INTEGRAL + GR_METHOD_COS_INTEGRAL + GR_METHOD_SINH_INTEGRAL + GR_METHOD_COSH_INTEGRAL + GR_METHOD_LOG_INTEGRAL + GR_METHOD_DILOG + GR_METHOD_BESSEL_J + GR_METHOD_BESSEL_Y + GR_METHOD_BESSEL_J_Y + GR_METHOD_BESSEL_I + GR_METHOD_BESSEL_I_SCALED + GR_METHOD_BESSEL_K + GR_METHOD_BESSEL_K_SCALED + GR_METHOD_AIRY + GR_METHOD_AIRY_AI + GR_METHOD_AIRY_BI + GR_METHOD_AIRY_AI_PRIME + GR_METHOD_AIRY_BI_PRIME + GR_METHOD_AIRY_AI_ZERO + GR_METHOD_AIRY_BI_ZERO + GR_METHOD_AIRY_AI_PRIME_ZERO + GR_METHOD_AIRY_BI_PRIME_ZERO + GR_METHOD_COULOMB + GR_METHOD_COULOMB_F + GR_METHOD_COULOMB_G + GR_METHOD_COULOMB_HPOS + GR_METHOD_COULOMB_HNEG + GR_METHOD_ZETA + GR_METHOD_ZETA_UI + GR_METHOD_HURWITZ_ZETA + GR_METHOD_LERCH_PHI + GR_METHOD_STIELTJES + GR_METHOD_DIRICHLET_ETA + GR_METHOD_DIRICHLET_BETA + GR_METHOD_RIEMANN_XI + GR_METHOD_ZETA_ZERO + GR_METHOD_ZETA_ZERO_VEC + GR_METHOD_ZETA_NZEROS + GR_METHOD_DIRICHLET_CHI_UI + GR_METHOD_DIRICHLET_CHI_FMPZ + GR_METHOD_DIRICHLET_L + GR_METHOD_DIRICHLET_HARDY_THETA + GR_METHOD_DIRICHLET_HARDY_Z + GR_METHOD_BERNPOLY_UI + GR_METHOD_EULERPOLY_UI + GR_METHOD_POLYLOG + GR_METHOD_POLYGAMMA + GR_METHOD_HYPGEOM_0F1 + GR_METHOD_HYPGEOM_1F1 + GR_METHOD_HYPGEOM_2F0 + GR_METHOD_HYPGEOM_2F1 + GR_METHOD_HYPGEOM_U + GR_METHOD_HYPGEOM_PFQ + GR_METHOD_JACOBI_THETA + GR_METHOD_JACOBI_THETA_1 + GR_METHOD_JACOBI_THETA_2 + GR_METHOD_JACOBI_THETA_3 + GR_METHOD_JACOBI_THETA_4 + GR_METHOD_JACOBI_THETA_Q + GR_METHOD_JACOBI_THETA_Q_1 + GR_METHOD_JACOBI_THETA_Q_2 + GR_METHOD_JACOBI_THETA_Q_3 + GR_METHOD_JACOBI_THETA_Q_4 + GR_METHOD_MODULAR_J + GR_METHOD_MODULAR_LAMBDA + GR_METHOD_MODULAR_DELTA + GR_METHOD_HILBERT_CLASS_POLY + GR_METHOD_DEDEKIND_ETA + GR_METHOD_DEDEKIND_ETA_Q + GR_METHOD_EISENSTEIN_E + GR_METHOD_EISENSTEIN_G + GR_METHOD_EISENSTEIN_G_VEC + GR_METHOD_AGM + GR_METHOD_AGM1 + GR_METHOD_ELLIPTIC_K + GR_METHOD_ELLIPTIC_E + GR_METHOD_ELLIPTIC_PI + GR_METHOD_ELLIPTIC_F + GR_METHOD_ELLIPTIC_E_INC + GR_METHOD_ELLIPTIC_PI_INC + GR_METHOD_CARLSON_RF + GR_METHOD_CARLSON_RC + GR_METHOD_CARLSON_RJ + GR_METHOD_CARLSON_RG + GR_METHOD_CARLSON_RD + GR_METHOD_ELLIPTIC_ROOTS + GR_METHOD_ELLIPTIC_INVARIANTS + GR_METHOD_WEIERSTRASS_P + GR_METHOD_WEIERSTRASS_P_PRIME + GR_METHOD_WEIERSTRASS_P_INV + GR_METHOD_WEIERSTRASS_ZETA + GR_METHOD_WEIERSTRASS_SIGMA + GR_METHOD_GEN + GR_METHOD_GENS + GR_METHOD_CTX_FQ_PRIME + GR_METHOD_CTX_FQ_DEGREE + GR_METHOD_CTX_FQ_ORDER + GR_METHOD_FQ_FROBENIUS + GR_METHOD_FQ_MULTIPLICATIVE_ORDER + GR_METHOD_FQ_NORM + GR_METHOD_FQ_TRACE + GR_METHOD_FQ_IS_PRIMITIVE + GR_METHOD_FQ_PTH_ROOT + GR_METHOD_VEC_INIT + GR_METHOD_VEC_CLEAR + GR_METHOD_VEC_SWAP + GR_METHOD_VEC_SET + GR_METHOD_VEC_ZERO + GR_METHOD_VEC_EQUAL + GR_METHOD_VEC_IS_ZERO + GR_METHOD_VEC_NEG + GR_METHOD_VEC_NORMALISE + GR_METHOD_VEC_NORMALISE_WEAK + GR_METHOD_VEC_ADD + GR_METHOD_VEC_SUB + GR_METHOD_VEC_MUL + GR_METHOD_VEC_DIV + GR_METHOD_VEC_DIVEXACT + GR_METHOD_VEC_POW + GR_METHOD_VEC_ADD_SCALAR + GR_METHOD_VEC_SUB_SCALAR + GR_METHOD_VEC_MUL_SCALAR + GR_METHOD_VEC_DIV_SCALAR + GR_METHOD_VEC_DIVEXACT_SCALAR + GR_METHOD_VEC_POW_SCALAR + GR_METHOD_SCALAR_ADD_VEC + GR_METHOD_SCALAR_SUB_VEC + GR_METHOD_SCALAR_MUL_VEC + GR_METHOD_SCALAR_DIV_VEC + GR_METHOD_SCALAR_DIVEXACT_VEC + GR_METHOD_SCALAR_POW_VEC + GR_METHOD_VEC_ADD_OTHER + GR_METHOD_VEC_SUB_OTHER + GR_METHOD_VEC_MUL_OTHER + GR_METHOD_VEC_DIV_OTHER + GR_METHOD_VEC_DIVEXACT_OTHER + GR_METHOD_VEC_POW_OTHER + GR_METHOD_OTHER_ADD_VEC + GR_METHOD_OTHER_SUB_VEC + GR_METHOD_OTHER_MUL_VEC + GR_METHOD_OTHER_DIV_VEC + GR_METHOD_OTHER_DIVEXACT_VEC + GR_METHOD_OTHER_POW_VEC + GR_METHOD_VEC_ADD_SCALAR_OTHER + GR_METHOD_VEC_SUB_SCALAR_OTHER + GR_METHOD_VEC_MUL_SCALAR_OTHER + GR_METHOD_VEC_DIV_SCALAR_OTHER + GR_METHOD_VEC_DIVEXACT_SCALAR_OTHER + GR_METHOD_VEC_POW_SCALAR_OTHER + GR_METHOD_SCALAR_OTHER_ADD_VEC + GR_METHOD_SCALAR_OTHER_SUB_VEC + GR_METHOD_SCALAR_OTHER_MUL_VEC + GR_METHOD_SCALAR_OTHER_DIV_VEC + GR_METHOD_SCALAR_OTHER_DIVEXACT_VEC + GR_METHOD_SCALAR_OTHER_POW_VEC + GR_METHOD_VEC_ADD_SCALAR_SI + GR_METHOD_VEC_ADD_SCALAR_UI + GR_METHOD_VEC_ADD_SCALAR_FMPZ + GR_METHOD_VEC_ADD_SCALAR_FMPQ + GR_METHOD_VEC_SUB_SCALAR_SI + GR_METHOD_VEC_SUB_SCALAR_UI + GR_METHOD_VEC_SUB_SCALAR_FMPZ + GR_METHOD_VEC_SUB_SCALAR_FMPQ + GR_METHOD_VEC_MUL_SCALAR_SI + GR_METHOD_VEC_MUL_SCALAR_UI + GR_METHOD_VEC_MUL_SCALAR_FMPZ + GR_METHOD_VEC_MUL_SCALAR_FMPQ + GR_METHOD_VEC_DIV_SCALAR_SI + GR_METHOD_VEC_DIV_SCALAR_UI + GR_METHOD_VEC_DIV_SCALAR_FMPZ + GR_METHOD_VEC_DIV_SCALAR_FMPQ + GR_METHOD_VEC_DIVEXACT_SCALAR_SI + GR_METHOD_VEC_DIVEXACT_SCALAR_UI + GR_METHOD_VEC_DIVEXACT_SCALAR_FMPZ + GR_METHOD_VEC_DIVEXACT_SCALAR_FMPQ + GR_METHOD_VEC_POW_SCALAR_SI + GR_METHOD_VEC_POW_SCALAR_UI + GR_METHOD_VEC_POW_SCALAR_FMPZ + GR_METHOD_VEC_POW_SCALAR_FMPQ + GR_METHOD_VEC_MUL_SCALAR_2EXP_SI + GR_METHOD_VEC_MUL_SCALAR_2EXP_FMPZ + GR_METHOD_VEC_ADDMUL_SCALAR + GR_METHOD_VEC_SUBMUL_SCALAR + GR_METHOD_VEC_ADDMUL_SCALAR_SI + GR_METHOD_VEC_SUBMUL_SCALAR_SI + GR_METHOD_VEC_SUM + GR_METHOD_VEC_PRODUCT + GR_METHOD_VEC_DOT + GR_METHOD_VEC_DOT_REV + GR_METHOD_VEC_DOT_UI + GR_METHOD_VEC_DOT_SI + GR_METHOD_VEC_DOT_FMPZ + GR_METHOD_VEC_SET_POWERS + GR_METHOD_VEC_RECIPROCALS + GR_METHOD_POLY_MULLOW + GR_METHOD_POLY_DIV + GR_METHOD_POLY_DIVREM + GR_METHOD_POLY_DIVEXACT + GR_METHOD_POLY_TAYLOR_SHIFT + GR_METHOD_POLY_INV_SERIES + GR_METHOD_POLY_INV_SERIES_BASECASE + GR_METHOD_POLY_DIV_SERIES + GR_METHOD_POLY_DIV_SERIES_BASECASE + GR_METHOD_POLY_RSQRT_SERIES + GR_METHOD_POLY_SQRT_SERIES + GR_METHOD_POLY_EXP_SERIES + GR_METHOD_POLY_FACTOR + GR_METHOD_POLY_ROOTS + GR_METHOD_POLY_ROOTS_OTHER + GR_METHOD_MAT_MUL + GR_METHOD_MAT_DET + GR_METHOD_MAT_EXP + GR_METHOD_MAT_LOG + GR_METHOD_MAT_FIND_NONZERO_PIVOT + GR_METHOD_MAT_DIAGONALIZATION + GR_METHOD_TAB_SIZE + + ctypedef struct gr_method_tab_input: + pass + + ctypedef enum gr_which_structure: + GR_CTX_FMPZ + GR_CTX_FMPQ + GR_CTX_FMPZI + GR_CTX_FMPZ_MOD + GR_CTX_NMOD + GR_CTX_NMOD8 + GR_CTX_NMOD32 + GR_CTX_FQ + GR_CTX_FQ_NMOD + GR_CTX_FQ_ZECH + GR_CTX_NF + GR_CTX_REAL_ALGEBRAIC_QQBAR + GR_CTX_COMPLEX_ALGEBRAIC_QQBAR + GR_CTX_REAL_ALGEBRAIC_CA + GR_CTX_COMPLEX_ALGEBRAIC_CA + GR_CTX_RR_CA + GR_CTX_CC_CA + GR_CTX_COMPLEX_EXTENDED_CA + GR_CTX_RR_ARB + GR_CTX_CC_ACB + GR_CTX_REAL_FLOAT_ARF + GR_CTX_COMPLEX_FLOAT_ACF + GR_CTX_FMPZ_POLY + GR_CTX_FMPQ_POLY + GR_CTX_GR_POLY + GR_CTX_FMPZ_MPOLY + GR_CTX_GR_MPOLY + GR_CTX_FMPZ_MPOLY_Q + GR_CTX_GR_SERIES + GR_CTX_GR_SERIES_MOD + GR_CTX_GR_MAT + GR_CTX_GR_VEC + GR_CTX_PSL2Z + GR_CTX_DIRICHLET_GROUP + GR_CTX_PERM + GR_CTX_FEXPR + GR_CTX_UNKNOWN_DOMAIN + GR_CTX_WHICH_STRUCTURE_TAB_SIZE + + ctypedef struct gr_ctx_struct: + pass + ctypedef gr_ctx_struct gr_ctx_t[1] + + ctypedef void ((*gr_method_init_clear_op)(gr_ptr, gr_ctx_ptr)) + ctypedef void ((*gr_method_swap_op)(gr_ptr, gr_ptr, gr_ctx_ptr)) + ctypedef int ((*gr_method_ctx)(gr_ctx_ptr)) + # NOTE: we removed an extra parenthesis so that Cython is less confused + # see https://github.com/cython/cython/issues/5779 + ctypedef truth_t (*gr_method_ctx_predicate)(gr_ctx_ptr) + ctypedef int ((*gr_method_ctx_set_si)(gr_ctx_ptr, slong)) + ctypedef int ((*gr_method_ctx_get_si)(slong *, gr_ctx_ptr)) + ctypedef int ((*gr_method_ctx_stream)(gr_stream_t, gr_ctx_ptr)) + ctypedef int ((*gr_method_ctx_set_str)(gr_ctx_ptr, const char *)) + ctypedef int ((*gr_method_ctx_set_strs)(gr_ctx_ptr, const char **)) + ctypedef int ((*gr_method_stream_in)(gr_stream_t, gr_srcptr, gr_ctx_ptr)) + ctypedef int ((*gr_method_stream_in_si)(gr_stream_t, gr_srcptr, slong, gr_ctx_ptr)) + ctypedef int ((*gr_method_randtest)(gr_ptr, flint_rand_t state, gr_ctx_ptr)) + ctypedef int ((*gr_method_constant_op)(gr_ptr, gr_ctx_ptr)) + ctypedef int ((*gr_method_constant_op_get_si)(slong *, gr_ctx_ptr)) + ctypedef int ((*gr_method_constant_op_get_fmpz)(fmpz_t, gr_ctx_ptr)) + ctypedef void ((*gr_method_void_unary_op)(gr_ptr, gr_srcptr, gr_ctx_ptr)) + ctypedef int ((*gr_method_unary_op)(gr_ptr, gr_srcptr, gr_ctx_ptr)) + ctypedef int ((*gr_method_unary_op_si)(gr_ptr, slong, gr_ctx_ptr)) + ctypedef int ((*gr_method_unary_op_ui)(gr_ptr, ulong, gr_ctx_ptr)) + ctypedef int ((*gr_method_unary_op_fmpz)(gr_ptr, const fmpz_t, gr_ctx_ptr)) + ctypedef int ((*gr_method_unary_op_fmpq)(gr_ptr, const fmpq_t, gr_ctx_ptr)) + ctypedef int ((*gr_method_unary_op_d)(gr_ptr, double, gr_ctx_ptr)) + ctypedef int ((*gr_method_unary_op_other)(gr_ptr, gr_srcptr, gr_ctx_ptr, gr_ctx_ptr)) + ctypedef int ((*gr_method_unary_op_str)(gr_ptr, const char *, gr_ctx_ptr)) + ctypedef int ((*gr_method_unary_op_get_ui)(ulong *, gr_srcptr, gr_ctx_ptr)) + ctypedef int ((*gr_method_unary_op_get_si)(slong *, gr_srcptr, gr_ctx_ptr)) + ctypedef int ((*gr_method_unary_op_get_fmpz)(fmpz_t, gr_srcptr, gr_ctx_ptr)) + ctypedef int ((*gr_method_unary_op_get_fmpq)(fmpq_t, gr_srcptr, gr_ctx_ptr)) + ctypedef int ((*gr_method_unary_op_get_d)(double *, gr_srcptr, gr_ctx_ptr)) + ctypedef int ((*gr_method_unary_op_get_fmpz_fmpz)(fmpz_t, fmpz_t, gr_srcptr, gr_ctx_ptr)) + ctypedef int ((*gr_method_unary_op_with_flag)(gr_ptr, gr_srcptr, int, gr_ctx_ptr)) + ctypedef int ((*gr_method_binary_unary_op)(gr_ptr, gr_ptr, gr_srcptr, gr_ctx_ptr)) + ctypedef int ((*gr_method_binary_unary_op_with_flag)(gr_ptr, gr_ptr, gr_srcptr, int, gr_ctx_ptr)) + ctypedef int ((*gr_method_quaternary_unary_op)(gr_ptr, gr_ptr, gr_ptr, gr_ptr, gr_srcptr, gr_ctx_ptr)) + ctypedef int ((*gr_method_binary_op)(gr_ptr, gr_srcptr, gr_srcptr, gr_ctx_ptr)) + ctypedef int ((*gr_method_binary_op_si)(gr_ptr, gr_srcptr, slong, gr_ctx_ptr)) + ctypedef int ((*gr_method_binary_op_ui)(gr_ptr, gr_srcptr, ulong, gr_ctx_ptr)) + ctypedef int ((*gr_method_binary_op_fmpz)(gr_ptr, gr_srcptr, const fmpz_t, gr_ctx_ptr)) + ctypedef int ((*gr_method_binary_op_fmpz_fmpz)(gr_ptr, const fmpz_t, const fmpz_t, gr_ctx_ptr)) + ctypedef int ((*gr_method_binary_op_fmpz_si)(gr_ptr, const fmpz_t, slong, gr_ctx_ptr)) + ctypedef int ((*gr_method_binary_op_fmpq)(gr_ptr, gr_srcptr, const fmpq_t, gr_ctx_ptr)) + ctypedef int ((*gr_method_binary_op_other)(gr_ptr, gr_srcptr, gr_srcptr, gr_ctx_ptr, gr_ctx_ptr)) + ctypedef int ((*gr_method_other_binary_op)(gr_ptr, gr_srcptr, gr_ctx_ptr, gr_srcptr, gr_ctx_ptr)) + ctypedef int ((*gr_method_si_binary_op)(gr_ptr, slong, gr_srcptr, gr_ctx_ptr)) + ctypedef int ((*gr_method_ui_binary_op)(gr_ptr, ulong, gr_srcptr, gr_ctx_ptr)) + ctypedef int ((*gr_method_fmpz_binary_op)(gr_ptr, const fmpz_t, gr_srcptr, gr_ctx_ptr)) + ctypedef int ((*gr_method_fmpq_binary_op)(gr_ptr, const fmpq_t, gr_srcptr, gr_ctx_ptr)) + ctypedef int ((*gr_method_binary_op_ui_ui)(gr_ptr, ulong, ulong, gr_ctx_ptr)) + ctypedef int ((*gr_method_binary_op_ui_si)(gr_ptr, ulong, slong, gr_ctx_ptr)) + ctypedef int ((*gr_method_binary_op_get_int)(int *, gr_srcptr, gr_srcptr, gr_ctx_ptr)) + ctypedef int ((*gr_method_binary_op_other_get_int)(int *, gr_srcptr, gr_srcptr, gr_ctx_ptr, gr_ctx_ptr)) + ctypedef int ((*gr_method_binary_binary_op)(gr_ptr, gr_ptr, gr_srcptr, gr_srcptr, gr_ctx_ptr)) + ctypedef int ((*gr_method_binary_op_with_flag)(gr_ptr, gr_srcptr, gr_srcptr, int, gr_ctx_ptr)) + ctypedef int ((*gr_method_binary_binary_op_ui_ui)(gr_ptr, gr_ptr, ulong, ulong, gr_ctx_ptr)) + ctypedef int ((*gr_method_ternary_op)(gr_ptr, gr_srcptr, gr_srcptr, gr_srcptr, gr_ctx_ptr)) + ctypedef int ((*gr_method_ternary_op_with_flag)(gr_ptr, gr_srcptr, gr_srcptr, gr_srcptr, int, gr_ctx_ptr)) + ctypedef int ((*gr_method_ternary_unary_op)(gr_ptr, gr_ptr, gr_ptr, gr_srcptr, gr_ctx_ptr)) + ctypedef int ((*gr_method_quaternary_op)(gr_ptr, gr_srcptr, gr_srcptr, gr_srcptr, gr_srcptr, gr_ctx_ptr)) + ctypedef int ((*gr_method_quaternary_op_with_flag)(gr_ptr, gr_srcptr, gr_srcptr, gr_srcptr, gr_srcptr, int, gr_ctx_ptr)) + ctypedef int ((*gr_method_quaternary_binary_op)(gr_ptr, gr_ptr, gr_ptr, gr_ptr, gr_srcptr, gr_srcptr, gr_ctx_ptr)) + ctypedef int ((*gr_method_quaternary_ternary_op)(gr_ptr, gr_ptr, gr_ptr, gr_ptr, gr_srcptr, gr_srcptr, gr_srcptr, gr_ctx_ptr)) + ctypedef int ((*gr_method_si_si_quaternary_op)(gr_ptr, slong, slong, gr_srcptr, gr_srcptr, gr_ctx_ptr)) + # NOTE: we removed an extra parenthesis so that Cython is less confused + # see https://github.com/cython/cython/issues/5779 + ctypedef truth_t (*gr_method_unary_predicate)(gr_srcptr, gr_ctx_ptr) + ctypedef truth_t (*gr_method_binary_predicate)(gr_srcptr, gr_srcptr, gr_ctx_ptr) + ctypedef void ((*gr_method_vec_init_clear_op)(gr_ptr, slong, gr_ctx_ptr)) + ctypedef void ((*gr_method_vec_swap_op)(gr_ptr, gr_ptr, slong, gr_ctx_ptr)) + ctypedef int ((*gr_method_vec_constant_op)(gr_ptr, slong, gr_ctx_ptr)) + ctypedef int ((*gr_method_vec_op)(gr_ptr, gr_srcptr, slong, gr_ctx_ptr)) + ctypedef int ((*gr_method_vec_vec_op)(gr_ptr, gr_srcptr, gr_srcptr, slong, gr_ctx_ptr)) + ctypedef int ((*gr_method_vec_scalar_op)(gr_ptr, gr_srcptr, slong, gr_srcptr, gr_ctx_ptr)) + ctypedef int ((*gr_method_scalar_vec_op)(gr_ptr, gr_srcptr, gr_srcptr, slong, gr_ctx_ptr)) + ctypedef int ((*gr_method_vec_op_other)(gr_ptr, gr_srcptr, gr_srcptr, gr_ctx_ptr, slong, gr_ctx_ptr)) + ctypedef int ((*gr_method_other_op_vec)(gr_ptr, gr_srcptr, gr_ctx_ptr, gr_srcptr, slong, gr_ctx_ptr)) + ctypedef int ((*gr_method_vec_op_scalar_other)(gr_ptr, gr_srcptr, slong, gr_srcptr, gr_ctx_ptr, gr_ctx_ptr)) + ctypedef int ((*gr_method_scalar_other_op_vec)(gr_ptr, gr_srcptr, gr_ctx_ptr, gr_srcptr, slong, gr_ctx_ptr)) + ctypedef int ((*gr_method_vec_scalar_op_si)(gr_ptr, gr_srcptr, slong, slong, gr_ctx_ptr)) + ctypedef int ((*gr_method_vec_scalar_op_ui)(gr_ptr, gr_srcptr, slong, ulong, gr_ctx_ptr)) + ctypedef int ((*gr_method_vec_scalar_op_fmpz)(gr_ptr, gr_srcptr, slong, const fmpz_t, gr_ctx_ptr)) + ctypedef int ((*gr_method_vec_scalar_op_fmpq)(gr_ptr, gr_srcptr, slong, const fmpq_t, gr_ctx_ptr)) + # NOTE: we removed an extra parenthesis so that Cython is less confused + # see https://github.com/cython/cython/issues/5779 + ctypedef truth_t (*gr_method_vec_predicate)(gr_srcptr, slong, gr_ctx_ptr) + ctypedef truth_t (*gr_method_vec_vec_predicate)(gr_srcptr, gr_srcptr, slong, gr_ctx_ptr) + ctypedef int ((*gr_method_factor_op)(gr_ptr, gr_vec_t, gr_vec_t, gr_srcptr, int, gr_ctx_ptr)) + ctypedef int ((*gr_method_poly_unary_trunc_op)(gr_ptr, gr_srcptr, slong, slong, gr_ctx_ptr)) + ctypedef int ((*gr_method_poly_binary_op)(gr_ptr, gr_srcptr, slong, gr_srcptr, slong, gr_ctx_ptr)) + ctypedef int ((*gr_method_poly_binary_binary_op)(gr_ptr, gr_ptr, gr_srcptr, slong, gr_srcptr, slong, gr_ctx_ptr)) + ctypedef int ((*gr_method_poly_binary_trunc_op)(gr_ptr, gr_srcptr, slong, gr_srcptr, slong, slong, gr_ctx_ptr)) + ctypedef int ((*gr_method_vec_ctx_op)(gr_vec_t, gr_ctx_ptr)) + + ctypedef struct polynomial_ctx_t: + pass + + ctypedef struct vector_ctx_t: + pass + + ctypedef struct matrix_ctx_t: + pass + + + # flint/gr_poly.h + ctypedef struct gr_poly_struct: + pass + ctypedef gr_poly_struct gr_poly_t[1] + + + # flint/gr_mat.h + ctypedef struct gr_mat_struct: + pass + ctypedef gr_mat_struct gr_mat_t[1] + + + # flint/gr_mpoly.h + ctypedef struct gr_mpoly_struct: + pass + ctypedef gr_mpoly_struct gr_mpoly_t[1] + + + # flint/double_interval.h + ctypedef struct di_t: + double a + double b + + + # flint/fq_default.h + ctypedef union fq_default_struct: + fq_t fq + fq_nmod_t fq_nmod + fq_zech_t fq_zech + ulong nmod + fmpz_t fmpz_mod + ctypedef fq_default_struct fq_default_t[1] + + ctypedef struct fq_default_ctx_struct: + pass + ctypedef fq_default_ctx_struct fq_default_ctx_t[1] + + + # flint/fq_default_poly.h + ctypedef union fq_default_poly_struct: + fq_poly_t fq + fq_nmod_poly_t fq_nmod + fq_zech_poly_t fq_zech + nmod_poly_t nmod + fmpz_mod_poly_t fmpz_mod + ctypedef fq_default_poly_struct fq_default_poly_t[1] + + + # flint/fq_poly_factor.h + ctypedef union fq_default_poly_factor_struct: + fq_poly_factor_t fq + fq_nmod_poly_factor_t fq_nmod + fq_zech_poly_factor_t fq_zech + nmod_poly_factor_t nmod + fmpz_mod_poly_factor_t fmpz_mod + ctypedef fq_default_poly_factor_struct fq_default_poly_factor_t[1] + + + # flint/fq_default_mat.h + ctypedef union fq_default_mat_struct: + pass + ctypedef fq_default_mat_struct fq_default_mat_t[1] + + + # flint/qfb.h + ctypedef struct qfb: + pass + ctypedef qfb qfb_t[1] + + ctypedef struct qfb_hash_t: + pass + + + # flint/qqbar.h + ctypedef struct qqbar_struct: + pass + ctypedef qqbar_struct qqbar_t[1] + ctypedef qqbar_struct * qqbar_ptr + ctypedef const qqbar_struct * qqbar_srcptr + + + # flint/profiler.h + ctypedef struct struct_meminfo: + pass + ctypedef struct_meminfo meminfo_t[1] + + ctypedef struct struct_timeit: + pass + ctypedef struct_timeit timeit_t[1] + + ctypedef void (*profile_target_t)(void* arg, ulong count) + + + # flint/fexpr.h + ctypedef struct fexpr_struct: + pass + ctypedef fexpr_struct fexpr_t[1] + ctypedef fexpr_struct * fexpr_ptr + ctypedef const fexpr_struct * fexpr_srcptr + + ctypedef struct fexpr_vec_struct: + pass + ctypedef fexpr_vec_struct fexpr_vec_t[1] + + + # flint/hypgeom.h + ctypedef struct hypgeom_struct: + pass + ctypedef hypgeom_struct hypgeom_t[1] + + + # flint/dlog.h + ctypedef struct dlog_precomp_struct: + pass + ctypedef dlog_precomp_struct * dlog_precomp_ptr + ctypedef dlog_precomp_struct dlog_precomp_t[1] + + ctypedef struct dlog_1modpe_struct: + pass + ctypedef dlog_1modpe_struct dlog_1modpe_t[1] + + ctypedef struct dlog_modpe_struct: + pass + ctypedef dlog_modpe_struct dlog_modpe_t[1] + + ctypedef struct dlog_table_struct: + pass + ctypedef dlog_table_struct dlog_table_t[1] + + ctypedef struct apow_t: + pass + + ctypedef struct dlog_bsgs_struct: + pass + ctypedef dlog_bsgs_struct dlog_bsgs_t[1] + + ctypedef struct dlog_rho_struct: + pass + ctypedef dlog_rho_struct dlog_rho_t[1] + + ctypedef struct dlog_crt_struct: + pass + ctypedef dlog_crt_struct dlog_crt_t[1] + + ctypedef struct dlog_power_struct: + pass + ctypedef dlog_power_struct dlog_power_t[1] + + ctypedef ulong dlog_order23_t[1] + + + # flint/bool_mat.h + ctypedef struct bool_mat_struct: + pass + ctypedef bool_mat_struct bool_mat_t[1] + + + # flint/dirichlet.h + ctypedef struct dirichlet_prime_group_struct: + pass + + ctypedef struct dirichlet_group_struct: + pass + ctypedef dirichlet_group_struct dirichlet_group_t[1] + + ctypedef struct dirichlet_char_struct: + pass + ctypedef dirichlet_char_struct dirichlet_char_t[1] + + + # flint/arb_fpwrap.h + ctypedef struct complex_double: + double real + double imag + + + # flint/aprcl.h + ctypedef struct _aprcl_config: + pass + ctypedef _aprcl_config aprcl_config[1]; + + ctypedef struct _unity_zpq: + pass + ctypedef _unity_zpq unity_zpq[1] + + ctypedef struct _unity_zp: + pass + ctypedef _unity_zp unity_zp[1] + + ctypedef enum primality_test_status: + UNKNOWN + PRIME + COMPOSITE + PROBABPRIME + + + # flint/acf.h + ctypedef struct acf_struct: + pass + + ctypedef acf_struct acf_t[1] + ctypedef acf_struct * acf_ptr + ctypedef const acf_struct * acf_srcptr + + + # flint/fmpz_lll.h + ctypedef enum rep_type: + GRAM + Z_BASIS + + ctypedef enum gram_type: + APPROX + EXACT + + ctypedef struct fmpz_lll_struct: + pass + ctypedef fmpz_lll_struct fmpz_lll_t[1] + + ctypedef union fmpz_gram_union: + d_mat_t appSP + mpf_mat_t appSP2 + fmpz_mat_t exactSP + ctypedef fmpz_gram_union fmpz_gram_t[1] diff --git a/src/sage_setup/autogen/flint/writer.py b/src/sage_setup/autogen/flint/writer.py new file mode 100644 index 00000000000..4a842d4395d --- /dev/null +++ b/src/sage_setup/autogen/flint/writer.py @@ -0,0 +1,111 @@ +r""" +Write flint header files. +""" +#***************************************************************************** +# Copyright (C) 2023 Vincent Delecroix <20100.delecroix@gmail.com> +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 2 of the License, or +# (at your option) any later version. +# http://www.gnu.org/licenses/ +#***************************************************************************** + +import os, shutil +from .env import AUTOGEN_DIR, FLINT_DOC_DIR, FLINT_INCLUDE_DIR +from .reader import extract_functions + + +def write_flint_cython_headers(output_dir, documentation=False): + r""" + Write cython header files. + + Arguments + output_dir -- (string) path where to write the .pxd files + """ + header_list = [] + pxd_list = [] + for filename in os.listdir(FLINT_DOC_DIR): + if not filename.endswith('.rst'): + continue + prefix = filename[:-4] + + absolute_filename = os.path.join(FLINT_DOC_DIR, filename) + content = extract_functions(absolute_filename) + if not content: + # NOTE: skip files with no function declaration + continue + + # try to match header + header = prefix + '.h' + absolute_header = os.path.join(FLINT_INCLUDE_DIR, header) + if not os.path.isfile(absolute_header): + print('Warning: skipping {} because no associated .h found'.format(filename)) + continue + if prefix == "machine_vectors" or prefix == "fft_small": + print('Warning: skipping fft_small.h and machine_vectors.h because depend on special CPU instructions') + continue + header_list.append(header) + pxd_list.append(prefix + '.pxd') + + output = open(os.path.join(output_dir, prefix + '.pxd'), 'w') + + print('# distutils: libraries = flint', file=output) + print('# distutils: depends = flint/{}'.format(prefix + '.h'), file=output) + print(file=output) + print('#' * 80, file=output) + print('# This file is auto-generated by the script', file=output) + print('# SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py.', file=output) + print('# Do not modify by hand! Fix and rerun the script instead.', file=output) + print('#' * 80, file=output) + print(file=output) + + print('from libc.stdio cimport FILE', file=output) + print('from sage.libs.gmp.types cimport *', file=output) + print('from sage.libs.mpfr.types cimport *', file=output) + print('from sage.libs.flint.types cimport *', file=output) + print(file=output) + + print('cdef extern from "flint_wrap.h":', file=output) + + for section in content: + if section is not None: + print(' ## {}'.format(section), file=output) + for func_signatures, doc in content[section]: + if documentation: + print('', file=output) + for line in doc: + print(' # {}'.format(line), file=output) + for line in func_signatures: + print(' {} noexcept'.format(line), file=output) + + if os.path.isfile(os.path.join(AUTOGEN_DIR, 'macros', prefix + '_macros.pxd')): + print('\nfrom .{} cimport *'.format(prefix + '_macros'), file=output) + + output.close() + + for extra_header in ['nmod_types.h']: + if extra_header in header_list: + print('Warning: {} already in HEADER_LIST'.format(extra_header)) + header_list.append(extra_header) + + header_list.sort() + + with open(os.path.join(AUTOGEN_DIR, 'templates', 'flint_wrap.h.template')) as f: + text = f.read() + with open(os.path.join(output_dir, 'flint_wrap.h'), 'w') as output: + output.write(text.format(HEADER_LIST='\n'.join('#include '.format(header) for header in header_list))) + + with open(os.path.join(AUTOGEN_DIR, 'templates', 'types.pxd.template')) as f: + text = f.read() + with open(os.path.join(output_dir, 'types.pxd'), 'w') as output: + output.write(text.format(HEADER_LIST=' '.join('flint/{}'.format(header) for header in header_list))) + + for filename in os.listdir(os.path.join(AUTOGEN_DIR, 'macros')): + prefix = filename[:-4] + shutil.copy(os.path.join(AUTOGEN_DIR, 'macros', filename), os.path.join(output_dir, filename)) + + with open(os.path.join(AUTOGEN_DIR, 'templates', 'flint_sage.pyx.template')) as f: + text = f.read() + with open(os.path.join(output_dir, 'flint_sage.pyx'), 'w') as output: + output.write(text.format(CYTHON_IMPORTS='\n'.join('from .{} cimport *'.format(header[:-4]) for header in pxd_list))) diff --git a/src/sage_setup/autogen/flint_autogen.py b/src/sage_setup/autogen/flint_autogen.py new file mode 100644 index 00000000000..6a21ede1ccc --- /dev/null +++ b/src/sage_setup/autogen/flint_autogen.py @@ -0,0 +1,19 @@ +r""" +Autogeneration of flint headers. +""" +#***************************************************************************** +# Copyright (C) 2023 Vincent Delecroix <20100.delecroix@gmail.com> +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 2 of the License, or +# (at your option) any later version. +# http://www.gnu.org/licenses/ +#***************************************************************************** + +import os +from flint import AUTOGEN_DIR, write_flint_cython_headers + + +OUTPUT_DIR = os.path.realpath(os.path.join(AUTOGEN_DIR, os.path.pardir, os.path.pardir, os.path.pardir, 'sage', 'libs', 'flint')) +write_flint_cython_headers(OUTPUT_DIR, documentation=False) From 11a92aaac6a5f6ffd4b0731ce683ee42f5b17eaa Mon Sep 17 00:00:00 2001 From: Vincent Delecroix <20100.delecroix@gmail.com> Date: Tue, 12 Dec 2023 13:57:57 +0100 Subject: [PATCH 27/41] more types --- .../flint/templates/types.pxd.template | 31 ++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/src/sage_setup/autogen/flint/templates/types.pxd.template b/src/sage_setup/autogen/flint/templates/types.pxd.template index e94346ffc8b..32b9c23cae7 100644 --- a/src/sage_setup/autogen/flint/templates/types.pxd.template +++ b/src/sage_setup/autogen/flint/templates/types.pxd.template @@ -149,7 +149,6 @@ cdef extern from "flint_wrap.h": ctypedef const acb_struct * acb_srcptr - # flint/acb_mat.h ctypedef struct acb_mat_struct: pass @@ -244,6 +243,16 @@ cdef extern from "flint_wrap.h": ctypedef acb_dirichlet_platt_ws_precomp_struct acb_dirichlet_platt_ws_precomp_t[1] + # flint/acb_theta.h + cdef struct acb_theta_eld_struct: + pass + ctypedef acb_theta_eld_struct acb_theta_eld_t[1] + + ctypedef void (*acb_theta_naive_worker_t)(acb_ptr, acb_srcptr, acb_srcptr, const slong *, + slong, const acb_t, const slong *, slong, slong, slong, slong) + ctypedef int (*acb_theta_ql_worker_t)(acb_ptr, acb_srcptr, acb_srcptr, + arb_srcptr, arb_srcptr, const acb_mat_t, slong, slong) + # flint/d_mat.h ctypedef struct d_mat_struct: double * entries @@ -955,6 +964,26 @@ cdef extern from "flint_wrap.h": ctypedef nf_elem_struct nf_elem_t[1] + # flint/machine_vectors.h + ctypedef struct vec1n: + pass + ctypedef struct vec2n: + pass + ctypedef struct vec4n: + pass + ctypedef struct vec8n: + pass + + ctypedef struct vec1d: + pass + ctypedef struct vec2d: + pass + ctypedef struct vec4d: + pass + ctypedef struct vec8d: + pass + + # flint/calcium.h ctypedef struct calcium_stream_struct: pass From f5505bfac8e82320500f40c01afc0dbeae43d181 Mon Sep 17 00:00:00 2001 From: Vincent Delecroix <20100.delecroix@gmail.com> Date: Tue, 12 Dec 2023 13:58:35 +0100 Subject: [PATCH 28/41] sort pxd_list --- src/sage_setup/autogen/flint/writer.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/sage_setup/autogen/flint/writer.py b/src/sage_setup/autogen/flint/writer.py index 4a842d4395d..dbc35c0adac 100644 --- a/src/sage_setup/autogen/flint/writer.py +++ b/src/sage_setup/autogen/flint/writer.py @@ -90,6 +90,7 @@ def write_flint_cython_headers(output_dir, documentation=False): header_list.append(extra_header) header_list.sort() + pxd_list.sort() with open(os.path.join(AUTOGEN_DIR, 'templates', 'flint_wrap.h.template')) as f: text = f.read() From b6c4a0f5e8ceaf94d8dca4f8470f860f88d3d723 Mon Sep 17 00:00:00 2001 From: Vincent Delecroix <20100.delecroix@gmail.com> Date: Tue, 12 Dec 2023 17:47:47 +0100 Subject: [PATCH 29/41] clean macros --- src/sage_setup/autogen/flint/macros/acb_macros.pxd | 3 --- src/sage_setup/autogen/flint/macros/acb_mat_macros.pxd | 5 ----- src/sage_setup/autogen/flint/macros/acb_poly_macros.pxd | 1 - src/sage_setup/autogen/flint/macros/arb_macros.pxd | 3 --- src/sage_setup/autogen/flint/macros/arb_mat_macros.pxd | 5 ----- src/sage_setup/autogen/flint/macros/fmpq_mat_macros.pxd | 5 ----- src/sage_setup/autogen/flint/macros/fmpz_macros.pxd | 7 +++++++ src/sage_setup/autogen/flint/macros/fmpz_mat_macros.pxd | 5 ----- src/sage_setup/autogen/flint/macros/fmpz_poly_macros.pxd | 1 - src/sage_setup/autogen/flint/macros/mag_macros.pxd | 1 - 10 files changed, 7 insertions(+), 29 deletions(-) create mode 100644 src/sage_setup/autogen/flint/macros/fmpz_macros.pxd diff --git a/src/sage_setup/autogen/flint/macros/acb_macros.pxd b/src/sage_setup/autogen/flint/macros/acb_macros.pxd index a3bfc1d468b..26ef61206bc 100644 --- a/src/sage_setup/autogen/flint/macros/acb_macros.pxd +++ b/src/sage_setup/autogen/flint/macros/acb_macros.pxd @@ -5,7 +5,4 @@ from .types cimport * cdef extern from "flint_wrap.h": arb_ptr acb_realref(acb_t x) - # Macro giving a pointer to the real part of x - arb_ptr acb_imagref(acb_t x) - # Macro giving a pointer to the imaginary part of x diff --git a/src/sage_setup/autogen/flint/macros/acb_mat_macros.pxd b/src/sage_setup/autogen/flint/macros/acb_mat_macros.pxd index 6fc4b5d82fc..36b95b8f6df 100644 --- a/src/sage_setup/autogen/flint/macros/acb_mat_macros.pxd +++ b/src/sage_setup/autogen/flint/macros/acb_mat_macros.pxd @@ -5,10 +5,5 @@ from .types cimport * cdef extern from "flint_wrap.h": acb_ptr acb_mat_entry(acb_mat_t mat, slong i, slong j) - # Macro giving a pointer to the entry at row *i* and column *j*. - slong acb_mat_nrows(acb_mat_t) - # Returns the number of rows of the matrix. - slong acb_mat_ncols(acb_mat_t) - # Returns the number of columns of the matrix. diff --git a/src/sage_setup/autogen/flint/macros/acb_poly_macros.pxd b/src/sage_setup/autogen/flint/macros/acb_poly_macros.pxd index f6b26ab0d1a..7fa5b0fe852 100644 --- a/src/sage_setup/autogen/flint/macros/acb_poly_macros.pxd +++ b/src/sage_setup/autogen/flint/macros/acb_poly_macros.pxd @@ -5,4 +5,3 @@ from .types cimport * cdef extern from "flint_wrap.h": acb_ptr acb_poly_get_coeff_ptr(acb_poly_t p, ulong n) - # Macro giving a pointer to the n-th coefficient of p (or NULL) diff --git a/src/sage_setup/autogen/flint/macros/arb_macros.pxd b/src/sage_setup/autogen/flint/macros/arb_macros.pxd index 2c243ecac1c..46f9a516434 100644 --- a/src/sage_setup/autogen/flint/macros/arb_macros.pxd +++ b/src/sage_setup/autogen/flint/macros/arb_macros.pxd @@ -5,7 +5,4 @@ from .types cimport * cdef extern from "flint_wrap.h": arf_ptr arb_midref(arb_t x) - # Macro giving a pointer to the midpoint of x - mag_ptr arb_radref(arb_t x) - # Macro giving a pointer to the radius of x diff --git a/src/sage_setup/autogen/flint/macros/arb_mat_macros.pxd b/src/sage_setup/autogen/flint/macros/arb_mat_macros.pxd index ebf86d0f785..c7bc5dfcad9 100644 --- a/src/sage_setup/autogen/flint/macros/arb_mat_macros.pxd +++ b/src/sage_setup/autogen/flint/macros/arb_mat_macros.pxd @@ -5,10 +5,5 @@ from .types cimport * cdef extern from "flint_wrap.h": arb_ptr arb_mat_entry(arb_mat_t mat, slong i, slong j) - # Macro giving a pointer to the entry at row *i* and column *j*. - slong arb_mat_nrows(arb_mat_t) - # Returns the number of rows of the matrix. - slong arb_mat_ncols(arb_mat_t) - # Returns the number of columns of the matrix. diff --git a/src/sage_setup/autogen/flint/macros/fmpq_mat_macros.pxd b/src/sage_setup/autogen/flint/macros/fmpq_mat_macros.pxd index 36eb1ef8703..45720b0511a 100644 --- a/src/sage_setup/autogen/flint/macros/fmpq_mat_macros.pxd +++ b/src/sage_setup/autogen/flint/macros/fmpq_mat_macros.pxd @@ -5,10 +5,5 @@ from .types cimport * cdef extern from "flint_wrap.h": fmpq * fmpq_mat_entry(fmpq_mat_t mat, slong i, slong j) - # Macro giving a pointer to the entry at row *i* and column *j*. - slong fmpq_mat_nrows(fmpq_mat_t) - # Returns the number of rows of the matrix. - slong fmpq_mat_ncols(fmpq_mat_t) - # Returns the number of columns of the matrix. diff --git a/src/sage_setup/autogen/flint/macros/fmpz_macros.pxd b/src/sage_setup/autogen/flint/macros/fmpz_macros.pxd new file mode 100644 index 00000000000..4256a213c21 --- /dev/null +++ b/src/sage_setup/autogen/flint/macros/fmpz_macros.pxd @@ -0,0 +1,7 @@ +# Macros from fmpz_poly.h +# See https://github.com/flintlib/flint/issues/1529 + +from .types cimport * + +cdef extern from "flint_wrap.h": + bint COEFF_IS_MPZ(fmpz f) diff --git a/src/sage_setup/autogen/flint/macros/fmpz_mat_macros.pxd b/src/sage_setup/autogen/flint/macros/fmpz_mat_macros.pxd index 52046e309b0..3aa4ef5ada0 100644 --- a/src/sage_setup/autogen/flint/macros/fmpz_mat_macros.pxd +++ b/src/sage_setup/autogen/flint/macros/fmpz_mat_macros.pxd @@ -5,10 +5,5 @@ from .types cimport * cdef extern from "flint_wrap.h": fmpz * fmpz_mat_entry(fmpz_mat_t mat, slong i, slong j) - # Macro giving a pointer to the entry at row *i* and column *j*. - slong fmpz_mat_nrows(fmpz_mat_t) - # Returns the number of rows of the matrix. - slong fmpz_mat_ncols(fmpz_mat_t) - # Returns the number of columns of the matrix. diff --git a/src/sage_setup/autogen/flint/macros/fmpz_poly_macros.pxd b/src/sage_setup/autogen/flint/macros/fmpz_poly_macros.pxd index fd789d7f1c7..6690d8bd8bb 100644 --- a/src/sage_setup/autogen/flint/macros/fmpz_poly_macros.pxd +++ b/src/sage_setup/autogen/flint/macros/fmpz_poly_macros.pxd @@ -5,4 +5,3 @@ from .types cimport * cdef extern from "flint_wrap.h": fmpz * fmpz_poly_get_coeff_ptr(fmpz_poly_t p, ulong n) - # Macro giving a pointer to the n-th coefficient of p (or NULL) diff --git a/src/sage_setup/autogen/flint/macros/mag_macros.pxd b/src/sage_setup/autogen/flint/macros/mag_macros.pxd index 8ca2d202fc6..836fc681fd1 100644 --- a/src/sage_setup/autogen/flint/macros/mag_macros.pxd +++ b/src/sage_setup/autogen/flint/macros/mag_macros.pxd @@ -5,4 +5,3 @@ from .types cimport * cdef extern from "flint_wrap.h": long MAG_BITS - From 77253adf82570ffc1473f9d4bfe336e9d621505d Mon Sep 17 00:00:00 2001 From: Vincent Delecroix <20100.delecroix@gmail.com> Date: Tue, 12 Dec 2023 17:50:21 +0100 Subject: [PATCH 30/41] remove COEFF_IS_MPZ from types.pxd --- src/sage_setup/autogen/flint/templates/types.pxd.template | 1 - 1 file changed, 1 deletion(-) diff --git a/src/sage_setup/autogen/flint/templates/types.pxd.template b/src/sage_setup/autogen/flint/templates/types.pxd.template index 32b9c23cae7..a60b10839ab 100644 --- a/src/sage_setup/autogen/flint/templates/types.pxd.template +++ b/src/sage_setup/autogen/flint/templates/types.pxd.template @@ -27,7 +27,6 @@ cdef extern from "flint_wrap.h": ctypedef slong fmpz ctypedef fmpz fmpz_t[1] - bint COEFF_IS_MPZ(fmpz) mpz_ptr COEFF_TO_PTR(fmpz) ctypedef struct fmpz_preinvn_struct: From ed478a0d87385226e9ae23c0fdb6ccd502f6b9df Mon Sep 17 00:00:00 2001 From: Vincent Delecroix <20100.delecroix@gmail.com> Date: Tue, 12 Dec 2023 17:50:57 +0100 Subject: [PATCH 31/41] do generate flint.pxd --- src/sage_setup/autogen/flint/writer.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/sage_setup/autogen/flint/writer.py b/src/sage_setup/autogen/flint/writer.py index dbc35c0adac..18b6802ead7 100644 --- a/src/sage_setup/autogen/flint/writer.py +++ b/src/sage_setup/autogen/flint/writer.py @@ -38,14 +38,23 @@ def write_flint_cython_headers(output_dir, documentation=False): # try to match header header = prefix + '.h' + if prefix == 'flint': + header = header + '.in' absolute_header = os.path.join(FLINT_INCLUDE_DIR, header) + if not os.path.isfile(absolute_header): print('Warning: skipping {} because no associated .h found'.format(filename)) continue - if prefix == "machine_vectors" or prefix == "fft_small": - print('Warning: skipping fft_small.h and machine_vectors.h because depend on special CPU instructions') + + # TODO: below are some exceptions for which we do not create .pxd file + if prefix == 'machine_vectors' or prefix == 'fft_small': + print('Warning: ignoring machine_vectors and fft_small because architecture dependent') + continue + if prefix == 'acb_theta': + print('Warning: ignoring acb_theta because not in stable release') continue - header_list.append(header) + + header_list.append(prefix + '.h') pxd_list.append(prefix + '.pxd') output = open(os.path.join(output_dir, prefix + '.pxd'), 'w') From 6ccf96372a26686d1b18b611a718eb80a0782b6d Mon Sep 17 00:00:00 2001 From: Vincent Delecroix <20100.delecroix@gmail.com> Date: Tue, 12 Dec 2023 17:51:42 +0100 Subject: [PATCH 32/41] some more notes in README --- src/sage_setup/autogen/flint/README.md | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/sage_setup/autogen/flint/README.md b/src/sage_setup/autogen/flint/README.md index dea2e753f94..6fe45febad2 100644 --- a/src/sage_setup/autogen/flint/README.md +++ b/src/sage_setup/autogen/flint/README.md @@ -14,5 +14,12 @@ in `sage/libs/flint/`. To make the autogeneration 4. Set the environment variable `FLINT_GIT_DIR` 5. Run the `run.py` script, eg `python autogen.py` + (that automatically write down the headers in the sage source tree `SAGE_SRC/sage/libs/flint`) -6. Copy all the files generated in `pxd_headers` inside the sage source tree (ie `SAGE_SRC/sage/libs/flint`) + +Additional notes +---------------- + +- macros in flint documentation are not converted into cython declarations (because they lack + a signature). The cython signature of flint macros must be manually written down in the + files contained `SAGE_SRC/sage/src/sage_setup/autogen/flint/macros` From cca101bb34605a8ba90ff4e74ba070122ac3a1a0 Mon Sep 17 00:00:00 2001 From: Vincent Delecroix <20100.delecroix@gmail.com> Date: Tue, 12 Dec 2023 17:53:10 +0100 Subject: [PATCH 33/41] fix fmpz_factor_sage import --- src/sage/rings/factorint_flint.pyx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sage/rings/factorint_flint.pyx b/src/sage/rings/factorint_flint.pyx index e20ae4dd4a8..cc50af04a1c 100644 --- a/src/sage/rings/factorint_flint.pyx +++ b/src/sage/rings/factorint_flint.pyx @@ -20,7 +20,7 @@ from cysignals.signals cimport sig_on, sig_off from sage.libs.flint.fmpz cimport fmpz_t, fmpz_init, fmpz_set_mpz from sage.libs.flint.fmpz_factor cimport * -from sage.libs.flint.fmpz_factor_extra cimport * +from sage.libs.flint.fmpz_factor_sage cimport * from sage.rings.integer cimport Integer From eab2d4edbf902b72bf0e6c7253fb1834cc19b8d5 Mon Sep 17 00:00:00 2001 From: Vincent Delecroix <20100.delecroix@gmail.com> Date: Tue, 12 Dec 2023 17:53:42 +0100 Subject: [PATCH 34/41] remove specialized acb_poly_revert_series that disappeared from flint --- src/sage/libs/arb/acb_poly.pxd | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/sage/libs/arb/acb_poly.pxd b/src/sage/libs/arb/acb_poly.pxd index 50f20af0cf9..42f4eae1ad4 100644 --- a/src/sage/libs/arb/acb_poly.pxd +++ b/src/sage/libs/arb/acb_poly.pxd @@ -83,12 +83,6 @@ from sage.libs.flint.acb_poly cimport ( acb_poly_compose, _acb_poly_compose_series, acb_poly_compose_series, - _acb_poly_revert_series_lagrange, - acb_poly_revert_series_lagrange, - _acb_poly_revert_series_newton, - acb_poly_revert_series_newton, - _acb_poly_revert_series_lagrange_fast, - acb_poly_revert_series_lagrange_fast, _acb_poly_revert_series, acb_poly_revert_series, _acb_poly_evaluate_horner, From a8d4725b986553f4a588d1a33374e1ef0d97a98f Mon Sep 17 00:00:00 2001 From: Vincent Delecroix <20100.delecroix@gmail.com> Date: Tue, 12 Dec 2023 17:18:39 +0100 Subject: [PATCH 35/41] regenerate flint cython headers --- src/sage/libs/flint/acb.pxd | 685 +----- src/sage/libs/flint/acb_calc.pxd | 159 +- src/sage/libs/flint/acb_dft.pxd | 38 +- src/sage/libs/flint/acb_dirichlet.pxd | 417 +--- src/sage/libs/flint/acb_elliptic.pxd | 210 +- src/sage/libs/flint/acb_hypgeom.pxd | 747 +----- src/sage/libs/flint/acb_macros.pxd | 5 +- src/sage/libs/flint/acb_mat.pxd | 460 +--- src/sage/libs/flint/acb_mat_macros.pxd | 7 +- src/sage/libs/flint/acb_modular.pxd | 325 +-- src/sage/libs/flint/acb_poly.pxd | 661 +----- src/sage/libs/flint/acb_poly_macros.pxd | 3 +- src/sage/libs/flint/acb_theta.pxd | 123 + src/sage/libs/flint/acf.pxd | 33 +- src/sage/libs/flint/aprcl.pxd | 203 +- src/sage/libs/flint/arb.pxd | 1132 +-------- src/sage/libs/flint/arb_calc.pxd | 110 +- src/sage/libs/flint/arb_fmpz_poly.pxd | 77 +- src/sage/libs/flint/arb_fpwrap.pxd | 141 +- src/sage/libs/flint/arb_hypgeom.pxd | 382 +-- src/sage/libs/flint/arb_macros.pxd | 5 +- src/sage/libs/flint/arb_mat.pxd | 435 +--- src/sage/libs/flint/arb_mat_macros.pxd | 7 +- src/sage/libs/flint/arb_poly.pxd | 645 +---- src/sage/libs/flint/arf.pxd | 376 +-- src/sage/libs/flint/arith.pxd | 330 +-- src/sage/libs/flint/bernoulli.pxd | 61 +- src/sage/libs/flint/bool_mat.pxd | 118 +- src/sage/libs/flint/ca.pxd | 617 +---- src/sage/libs/flint/ca_ext.pxd | 54 +- src/sage/libs/flint/ca_field.pxd | 64 +- src/sage/libs/flint/ca_mat.pxd | 341 +-- src/sage/libs/flint/ca_poly.pxd | 178 +- src/sage/libs/flint/ca_vec.pxd | 75 +- src/sage/libs/flint/calcium.pxd | 27 +- src/sage/libs/flint/d_mat.pxd | 78 +- src/sage/libs/flint/d_vec.pxd | 51 +- src/sage/libs/flint/dirichlet.pxd | 98 +- src/sage/libs/flint/dlog.pxd | 40 +- src/sage/libs/flint/double_extras.pxd | 35 +- src/sage/libs/flint/double_interval.pxd | 38 +- src/sage/libs/flint/fexpr.pxd | 260 +- src/sage/libs/flint/fexpr_builtin.pxd | 13 +- src/sage/libs/flint/fft.pxd | 384 +-- src/sage/libs/flint/flint.pxd | 67 +- src/sage/libs/flint/flint_sage.pyx | 220 +- src/sage/libs/flint/flint_wrap.h | 224 +- src/sage/libs/flint/fmpq.pxd | 377 +-- src/sage/libs/flint/fmpq_mat.pxd | 291 +-- src/sage/libs/flint/fmpq_mat_macros.pxd | 7 +- src/sage/libs/flint/fmpq_mpoly.pxd | 265 +-- src/sage/libs/flint/fmpq_mpoly_factor.pxd | 30 +- src/sage/libs/flint/fmpq_poly.pxd | 1021 +------- src/sage/libs/flint/fmpq_vec.pxd | 38 +- src/sage/libs/flint/fmpz.pxd | 892 +------ src/sage/libs/flint/fmpz_extras.pxd | 42 +- src/sage/libs/flint/fmpz_factor.pxd | 191 +- ..._factor_extra.pxd => fmpz_factor_sage.pxd} | 0 ..._factor_extra.pyx => fmpz_factor_sage.pyx} | 0 src/sage/libs/flint/fmpz_lll.pxd | 215 +- src/sage/libs/flint/fmpz_macros.pxd | 7 + src/sage/libs/flint/fmpz_mat.pxd | 817 +------ src/sage/libs/flint/fmpz_mat_macros.pxd | 7 +- src/sage/libs/flint/fmpz_mod.pxd | 56 +- src/sage/libs/flint/fmpz_mod_mat.pxd | 189 +- src/sage/libs/flint/fmpz_mod_mpoly.pxd | 263 +- src/sage/libs/flint/fmpz_mod_mpoly_factor.pxd | 27 +- src/sage/libs/flint/fmpz_mod_poly.pxd | 1194 +--------- src/sage/libs/flint/fmpz_mod_poly_factor.pxd | 123 +- src/sage/libs/flint/fmpz_mod_vec.pxd | 25 +- src/sage/libs/flint/fmpz_mpoly.pxd | 502 +--- src/sage/libs/flint/fmpz_mpoly_factor.pxd | 27 +- src/sage/libs/flint/fmpz_mpoly_q.pxd | 63 +- src/sage/libs/flint/fmpz_poly.pxd | 2105 +---------------- src/sage/libs/flint/fmpz_poly_factor.pxd | 76 +- src/sage/libs/flint/fmpz_poly_macros.pxd | 3 +- src/sage/libs/flint/fmpz_poly_mat.pxd | 228 +- src/sage/libs/flint/fmpz_poly_q.pxd | 108 +- src/sage/libs/flint/fmpz_vec.pxd | 224 +- src/sage/libs/flint/fmpzi.pxd | 54 +- src/sage/libs/flint/fq.pxd | 300 +-- src/sage/libs/flint/fq_default.pxd | 231 +- src/sage/libs/flint/fq_default_mat.pxd | 213 +- src/sage/libs/flint/fq_default_poly.pxd | 273 +-- .../libs/flint/fq_default_poly_factor.pxd | 79 +- src/sage/libs/flint/fq_embed.pxd | 77 +- src/sage/libs/flint/fq_mat.pxd | 291 +-- src/sage/libs/flint/fq_nmod.pxd | 278 +-- src/sage/libs/flint/fq_nmod_embed.pxd | 77 +- src/sage/libs/flint/fq_nmod_mat.pxd | 291 +-- src/sage/libs/flint/fq_nmod_mpoly.pxd | 245 +- src/sage/libs/flint/fq_nmod_mpoly_factor.pxd | 27 +- src/sage/libs/flint/fq_nmod_poly.pxd | 992 +------- src/sage/libs/flint/fq_nmod_poly_factor.pxd | 133 +- src/sage/libs/flint/fq_nmod_vec.pxd | 48 +- src/sage/libs/flint/fq_poly.pxd | 1001 +------- src/sage/libs/flint/fq_poly_factor.pxd | 133 +- src/sage/libs/flint/fq_vec.pxd | 48 +- src/sage/libs/flint/fq_zech.pxd | 307 +-- src/sage/libs/flint/fq_zech_embed.pxd | 77 +- src/sage/libs/flint/fq_zech_mat.pxd | 274 +-- src/sage/libs/flint/fq_zech_poly.pxd | 962 +------- src/sage/libs/flint/fq_zech_poly_factor.pxd | 135 +- src/sage/libs/flint/fq_zech_vec.pxd | 48 +- src/sage/libs/flint/gr.pxd | 271 +-- src/sage/libs/flint/gr_generic.pxd | 64 +- src/sage/libs/flint/gr_mat.pxd | 388 +-- src/sage/libs/flint/gr_mpoly.pxd | 64 +- src/sage/libs/flint/gr_poly.pxd | 224 +- src/sage/libs/flint/gr_special.pxd | 89 +- src/sage/libs/flint/gr_vec.pxd | 64 +- src/sage/libs/flint/hypgeom.pxd | 47 +- src/sage/libs/flint/long_extras.pxd | 24 +- src/sage/libs/flint/mag.pxd | 242 +- src/sage/libs/flint/mag_macros.pxd | 3 +- src/sage/libs/flint/mpf_mat.pxd | 72 +- src/sage/libs/flint/mpf_vec.pxd | 54 +- src/sage/libs/flint/mpfr_mat.pxd | 31 +- src/sage/libs/flint/mpfr_vec.pxd | 23 +- src/sage/libs/flint/mpn_extras.pxd | 157 +- src/sage/libs/flint/mpoly.pxd | 219 +- src/sage/libs/flint/nf.pxd | 10 +- src/sage/libs/flint/nf_elem.pxd | 208 +- src/sage/libs/flint/nmod.pxd | 61 +- src/sage/libs/flint/nmod_mat.pxd | 355 +-- src/sage/libs/flint/nmod_mpoly.pxd | 288 +-- src/sage/libs/flint/nmod_mpoly_factor.pxd | 27 +- src/sage/libs/flint/nmod_poly.pxd | 1492 +----------- src/sage/libs/flint/nmod_poly_factor.pxd | 132 +- src/sage/libs/flint/nmod_poly_mat.pxd | 256 +- src/sage/libs/flint/nmod_vec.pxd | 77 +- src/sage/libs/flint/padic.pxd | 314 +-- src/sage/libs/flint/padic_mat.pxd | 127 +- src/sage/libs/flint/padic_poly.pxd | 310 +-- src/sage/libs/flint/partitions.pxd | 47 +- src/sage/libs/flint/perm.pxd | 44 +- src/sage/libs/flint/profiler.pxd | 73 +- src/sage/libs/flint/qadic.pxd | 342 +-- src/sage/libs/flint/qfb.pxd | 122 +- src/sage/libs/flint/qqbar.pxd | 540 +---- src/sage/libs/flint/qsieve.pxd | 99 +- src/sage/libs/flint/qsieve_sage.pyx | 2 +- src/sage/libs/flint/thread_pool.pxd | 32 +- src/sage/libs/flint/types.pxd | 52 +- src/sage/libs/flint/ulong_extras.pxd | 1002 +------- 145 files changed, 1221 insertions(+), 33593 deletions(-) create mode 100644 src/sage/libs/flint/acb_theta.pxd rename src/sage/libs/flint/{fmpz_factor_extra.pxd => fmpz_factor_sage.pxd} (100%) rename src/sage/libs/flint/{fmpz_factor_extra.pyx => fmpz_factor_sage.pyx} (100%) create mode 100644 src/sage/libs/flint/fmpz_macros.pxd diff --git a/src/sage/libs/flint/acb.pxd b/src/sage/libs/flint/acb.pxd index 9ed8853dee8..9017379224b 100644 --- a/src/sage/libs/flint/acb.pxd +++ b/src/sage/libs/flint/acb.pxd @@ -2,7 +2,9 @@ # distutils: depends = flint/acb.h ################################################################################ -# This file is auto-generated. Do not modify by hand +# This file is auto-generated by the script +# SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py. +# Do not modify by hand! Fix and rerun the script instead. ################################################################################ from libc.stdio cimport FILE @@ -11,911 +13,256 @@ from sage.libs.mpfr.types cimport * from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void acb_init(acb_t x) noexcept - # Initializes the variable *x* for use, and sets its value to zero. - void acb_clear(acb_t x) noexcept - # Clears the variable *x*, freeing or recycling its allocated memory. - acb_ptr _acb_vec_init(slong n) noexcept - # Returns a pointer to an array of *n* initialized *acb_struct*:s. - void _acb_vec_clear(acb_ptr v, slong n) noexcept - # Clears an array of *n* initialized *acb_struct*:s. - slong acb_allocated_bytes(const acb_t x) noexcept - # Returns the total number of bytes heap-allocated internally by this object. - # The count excludes the size of the structure itself. Add - # ``sizeof(acb_struct)`` to get the size of the object as a whole. - slong _acb_vec_allocated_bytes(acb_srcptr vec, slong len) noexcept - # Returns the total number of bytes allocated for this vector, i.e. the - # space taken up by the vector itself plus the sum of the internal heap - # allocation sizes for all its member elements. - double _acb_vec_estimate_allocated_bytes(slong len, slong prec) noexcept - # Estimates the number of bytes that need to be allocated for a vector of - # *len* elements with *prec* bits of precision, including the space for - # internal limb data. - # See comments for :func:`_arb_vec_estimate_allocated_bytes`. - void acb_zero(acb_t z) noexcept - void acb_one(acb_t z) noexcept - void acb_onei(acb_t z) noexcept - # Sets *z* respectively to 0, 1, `i = \sqrt{-1}`. - void acb_set(acb_t z, const acb_t x) noexcept - void acb_set_ui(acb_t z, ulong x) noexcept - void acb_set_si(acb_t z, slong x) noexcept - void acb_set_d(acb_t z, double x) noexcept - void acb_set_fmpz(acb_t z, const fmpz_t x) noexcept - void acb_set_arb(acb_t z, const arb_t c) noexcept - # Sets *z* to the value of *x*. - void acb_set_si_si(acb_t z, slong x, slong y) noexcept - void acb_set_d_d(acb_t z, double x, double y) noexcept - void acb_set_fmpz_fmpz(acb_t z, const fmpz_t x, const fmpz_t y) noexcept - void acb_set_arb_arb(acb_t z, const arb_t x, const arb_t y) noexcept - # Sets the real and imaginary part of *z* to the values *x* and *y* respectively - void acb_set_fmpq(acb_t z, const fmpq_t x, slong prec) noexcept - void acb_set_round(acb_t z, const acb_t x, slong prec) noexcept - void acb_set_round_fmpz(acb_t z, const fmpz_t x, slong prec) noexcept - void acb_set_round_arb(acb_t z, const arb_t x, slong prec) noexcept - # Sets *z* to *x*, rounded to *prec* bits. - void acb_swap(acb_t z, acb_t x) noexcept - # Swaps *z* and *x* efficiently. - void acb_add_error_arf(acb_t x, const arf_t err) noexcept - void acb_add_error_mag(acb_t x, const mag_t err) noexcept - void acb_add_error_arb(acb_t x, const arb_t err) noexcept - # Adds *err* to the error bounds of both the real and imaginary - # parts of *x*, modifying *x* in-place. - void acb_get_mid(acb_t m, const acb_t x) noexcept - # Sets *m* to the midpoint of *x*. - void acb_print(const acb_t x) noexcept - void acb_fprint(FILE * file, const acb_t x) noexcept - # Prints the internal representation of *x*. - void acb_printd(const acb_t x, slong digits) noexcept - void acb_fprintd(FILE * file, const acb_t x, slong digits) noexcept - # Prints *x* in decimal. The printed value of the radius is not adjusted - # to compensate for the fact that the binary-to-decimal conversion - # of both the midpoint and the radius introduces additional error. - void acb_printn(const acb_t x, slong digits, ulong flags) noexcept - void acb_fprintn(FILE * file, const acb_t x, slong digits, ulong flags) noexcept - # Prints a nice decimal representation of *x*, using the format of - # :func:`arb_get_str` (or the corresponding :func:`arb_printn`) for the - # real and imaginary parts. - # By default, the output shows the midpoint of both the real and imaginary - # parts with a guaranteed error of at most one unit in the last decimal - # place. In addition, explicit error bounds are printed so that the displayed - # decimal interval is guaranteed to enclose *x*. - # Any flags understood by :func:`arb_get_str` can be passed via *flags* - # to control the format of the real and imaginary parts. - void acb_randtest(acb_t z, flint_rand_t state, slong prec, slong mag_bits) noexcept - # Generates a random complex number by generating separate random - # real and imaginary parts. - void acb_randtest_special(acb_t z, flint_rand_t state, slong prec, slong mag_bits) noexcept - # Generates a random complex number by generating separate random - # real and imaginary parts. Also generates NaNs and infinities. - void acb_randtest_precise(acb_t z, flint_rand_t state, slong prec, slong mag_bits) noexcept - # Generates a random complex number with precise real and imaginary parts. - void acb_randtest_param(acb_t z, flint_rand_t state, slong prec, slong mag_bits) noexcept - # Generates a random complex number, with very high probability of - # generating integers and half-integers. - + void acb_urandom(acb_t z, flint_rand_t state, slong prec) noexcept bint acb_is_zero(const acb_t z) noexcept - # Returns nonzero iff *z* is zero. - bint acb_is_one(const acb_t z) noexcept - # Returns nonzero iff *z* is exactly 1. - bint acb_is_finite(const acb_t z) noexcept - # Returns nonzero iff *z* certainly is finite. - bint acb_is_exact(const acb_t z) noexcept - # Returns nonzero iff *z* is exact. - bint acb_is_int(const acb_t z) noexcept - # Returns nonzero iff *z* is an exact integer. - bint acb_is_int_2exp_si(const acb_t x, slong e) noexcept - # Returns nonzero iff *z* exactly equals `n 2^e` for some integer *n*. - bint acb_equal(const acb_t x, const acb_t y) noexcept - # Returns nonzero iff *x* and *y* are identical as sets, i.e. - # if the real and imaginary parts are equal as balls. - # Note that this is not the same thing as testing whether both - # *x* and *y* certainly represent the same complex number, unless - # either *x* or *y* is exact (and neither contains NaN). - # To test whether both operands *might* represent the same mathematical - # quantity, use :func:`acb_overlaps` or :func:`acb_contains`, - # depending on the circumstance. - bint acb_equal_si(const acb_t x, slong y) noexcept - # Returns nonzero iff *x* is equal to the integer *y*. - bint acb_eq(const acb_t x, const acb_t y) noexcept - # Returns nonzero iff *x* and *y* are certainly equal, as determined - # by testing that :func:`arb_eq` holds for both the real and imaginary - # parts. - bint acb_ne(const acb_t x, const acb_t y) noexcept - # Returns nonzero iff *x* and *y* are certainly not equal, as determined - # by testing that :func:`arb_ne` holds for either the real or imaginary parts. - bint acb_overlaps(const acb_t x, const acb_t y) noexcept - # Returns nonzero iff *x* and *y* have some point in common. - void acb_union(acb_t z, const acb_t x, const acb_t y, slong prec) noexcept - # Sets *z* to a complex interval containing both *x* and *y*. - void acb_get_abs_ubound_arf(arf_t u, const acb_t z, slong prec) noexcept - # Sets *u* to an upper bound for the absolute value of *z*, computed - # using a working precision of *prec* bits. - void acb_get_abs_lbound_arf(arf_t u, const acb_t z, slong prec) noexcept - # Sets *u* to a lower bound for the absolute value of *z*, computed - # using a working precision of *prec* bits. - void acb_get_rad_ubound_arf(arf_t u, const acb_t z, slong prec) noexcept - # Sets *u* to an upper bound for the error radius of *z* (the value - # is currently not computed tightly). - void acb_get_mag(mag_t u, const acb_t x) noexcept - # Sets *u* to an upper bound for the absolute value of *x*. - void acb_get_mag_lower(mag_t u, const acb_t x) noexcept - # Sets *u* to a lower bound for the absolute value of *x*. - bint acb_contains_fmpq(const acb_t x, const fmpq_t y) noexcept - bint acb_contains_fmpz(const acb_t x, const fmpz_t y) noexcept - bint acb_contains(const acb_t x, const acb_t y) noexcept - # Returns nonzero iff *y* is contained in *x*. - bint acb_contains_zero(const acb_t x) noexcept - # Returns nonzero iff zero is contained in *x*. - bint acb_contains_int(const acb_t x) noexcept - # Returns nonzero iff the complex interval represented by *x* contains - # an integer. - bint acb_contains_interior(const acb_t x, const acb_t y) noexcept - # Tests if *y* is contained in the interior of *x*. - # This predicate always evaluates to false if *x* and *y* are both - # real-valued, since an imaginary part of 0 is not considered contained in - # the interior of the point interval 0. More generally, the same - # problem occurs for intervals with an exact real or imaginary part. - # Such intervals must be handled specially by the user where a different - # interpretation is intended. - slong acb_rel_error_bits(const acb_t x) noexcept - # Returns the effective relative error of *x* measured in bits. - # This is computed as if calling :func:`arb_rel_error_bits` on the - # real ball whose midpoint is the larger out of the real and imaginary - # midpoints of *x*, and whose radius is the larger out of the real - # and imaginary radiuses of *x*. - slong acb_rel_accuracy_bits(const acb_t x) noexcept - # Returns the effective relative accuracy of *x* measured in bits, - # equal to the negative of the return value from :func:`acb_rel_error_bits`. - slong acb_rel_one_accuracy_bits(const acb_t x) noexcept - # Given a ball with midpoint *m* and radius *r*, returns an approximation of - # the relative accuracy of `[\max(1,|m|) \pm r]` measured in bits. - slong acb_bits(const acb_t x) noexcept - # Returns the maximum of *arb_bits* applied to the real - # and imaginary parts of *x*, i.e. the minimum precision sufficient - # to represent *x* exactly. - void acb_indeterminate(acb_t x) noexcept - # Sets *x* to - # `[\operatorname{NaN} \pm \infty] + [\operatorname{NaN} \pm \infty]i`, - # representing an indeterminate result. - void acb_trim(acb_t y, const acb_t x) noexcept - # Sets *y* to a a copy of *x* with both the real and imaginary - # parts trimmed (see :func:`arb_trim`). - bint acb_is_real(const acb_t x) noexcept - # Returns nonzero iff the imaginary part of *x* is zero. - # It does not test whether the real part of *x* also is finite. - int acb_get_unique_fmpz(fmpz_t z, const acb_t x) noexcept - # If *x* contains a unique integer, sets *z* to that value and returns - # nonzero. Otherwise (if *x* represents no integers or more than one integer), - # returns zero. - void acb_get_real(arb_t re, const acb_t z) noexcept - # Sets *re* to the real part of *z*. - void acb_get_imag(arb_t im, const acb_t z) noexcept - # Sets *im* to the imaginary part of *z*. - void acb_arg(arb_t r, const acb_t z, slong prec) noexcept - # Sets *r* to a real interval containing the complex argument (phase) of *z*. - # We define the complex argument have a discontinuity on `(-\infty,0]`, with - # the special value `\operatorname{arg}(0) = 0`, and - # `\operatorname{arg}(a+0i) = \pi` for `a < 0`. Equivalently, if - # `z = a+bi`, the argument is given by `\operatorname{atan2}(b,a)` - # (see :func:`arb_atan2`). - void acb_abs(arb_t r, const acb_t z, slong prec) noexcept - # Sets *r* to the absolute value of *z*. - void acb_sgn(acb_t r, const acb_t z, slong prec) noexcept - # Sets *r* to the complex sign of *z*, defined as 0 if *z* is exactly zero - # and the projection onto the unit circle `z / |z| = \exp(i \arg(z))` otherwise. - void acb_csgn(arb_t r, const acb_t z) noexcept - # Sets *r* to the extension of the real sign function taking the - # value 1 for *z* strictly in the right half plane, -1 for *z* strictly - # in the left half plane, and the sign of the imaginary part when *z* is on - # the imaginary axis. Equivalently, `\operatorname{csgn}(z) = z / \sqrt{z^2}` - # except that the value is 0 when *z* is exactly zero. - void acb_neg(acb_t z, const acb_t x) noexcept - void acb_neg_round(acb_t z, const acb_t x, slong prec) noexcept - # Sets *z* to the negation of *x*. - void acb_conj(acb_t z, const acb_t x) noexcept - # Sets *z* to the complex conjugate of *x*. - void acb_add_ui(acb_t z, const acb_t x, ulong y, slong prec) noexcept - void acb_add_si(acb_t z, const acb_t x, slong y, slong prec) noexcept - void acb_add_fmpz(acb_t z, const acb_t x, const fmpz_t y, slong prec) noexcept - void acb_add_arb(acb_t z, const acb_t x, const arb_t y, slong prec) noexcept - void acb_add(acb_t z, const acb_t x, const acb_t y, slong prec) noexcept - # Sets *z* to the sum of *x* and *y*. - void acb_sub_ui(acb_t z, const acb_t x, ulong y, slong prec) noexcept - void acb_sub_si(acb_t z, const acb_t x, slong y, slong prec) noexcept - void acb_sub_fmpz(acb_t z, const acb_t x, const fmpz_t y, slong prec) noexcept - void acb_sub_arb(acb_t z, const acb_t x, const arb_t y, slong prec) noexcept - void acb_sub(acb_t z, const acb_t x, const acb_t y, slong prec) noexcept - # Sets *z* to the difference of *x* and *y*. - void acb_mul_onei(acb_t z, const acb_t x) noexcept - # Sets *z* to *x* multiplied by the imaginary unit. - void acb_div_onei(acb_t z, const acb_t x) noexcept - # Sets *z* to *x* divided by the imaginary unit. - + void acb_mul_i_pow_si(acb_t z, const acb_t x, slong k) noexcept void acb_mul_ui(acb_t z, const acb_t x, ulong y, slong prec) noexcept - void acb_mul_si(acb_t z, const acb_t x, slong y, slong prec) noexcept - void acb_mul_fmpz(acb_t z, const acb_t x, const fmpz_t y, slong prec) noexcept - void acb_mul_arb(acb_t z, const acb_t x, const arb_t y, slong prec) noexcept - # Sets *z* to the product of *x* and *y*. - void acb_mul(acb_t z, const acb_t x, const acb_t y, slong prec) noexcept - # Sets *z* to the product of *x* and *y*. If at least one part of - # *x* or *y* is zero, the operations is reduced to two real multiplications. - # If *x* and *y* are the same pointers, they are assumed to represent - # the same mathematical quantity and the squaring formula is used. - void acb_mul_2exp_si(acb_t z, const acb_t x, slong e) noexcept - void acb_mul_2exp_fmpz(acb_t z, const acb_t x, const fmpz_t e) noexcept - # Sets *z* to *x* multiplied by `2^e`, without rounding. - void acb_sqr(acb_t z, const acb_t x, slong prec) noexcept - # Sets *z* to *x* squared. - void acb_cube(acb_t z, const acb_t x, slong prec) noexcept - # Sets *z* to *x* cubed, computed efficiently using two real squarings, - # two real multiplications, and scalar operations. - void acb_addmul(acb_t z, const acb_t x, const acb_t y, slong prec) noexcept - void acb_addmul_ui(acb_t z, const acb_t x, ulong y, slong prec) noexcept - void acb_addmul_si(acb_t z, const acb_t x, slong y, slong prec) noexcept - void acb_addmul_fmpz(acb_t z, const acb_t x, const fmpz_t y, slong prec) noexcept - void acb_addmul_arb(acb_t z, const acb_t x, const arb_t y, slong prec) noexcept - # Sets *z* to *z* plus the product of *x* and *y*. - void acb_submul(acb_t z, const acb_t x, const acb_t y, slong prec) noexcept - void acb_submul_ui(acb_t z, const acb_t x, ulong y, slong prec) noexcept - void acb_submul_si(acb_t z, const acb_t x, slong y, slong prec) noexcept - void acb_submul_fmpz(acb_t z, const acb_t x, const fmpz_t y, slong prec) noexcept - void acb_submul_arb(acb_t z, const acb_t x, const arb_t y, slong prec) noexcept - # Sets *z* to *z* minus the product of *x* and *y*. - void acb_inv(acb_t z, const acb_t x, slong prec) noexcept - # Sets *z* to the multiplicative inverse of *x*. - void acb_div_ui(acb_t z, const acb_t x, ulong y, slong prec) noexcept - void acb_div_si(acb_t z, const acb_t x, slong y, slong prec) noexcept - void acb_div_fmpz(acb_t z, const acb_t x, const fmpz_t y, slong prec) noexcept - void acb_div_arb(acb_t z, const acb_t x, const arb_t y, slong prec) noexcept - void acb_div(acb_t z, const acb_t x, const acb_t y, slong prec) noexcept - # Sets *z* to the quotient of *x* and *y*. - void acb_dot_precise(acb_t res, const acb_t s, int subtract, acb_srcptr x, slong xstep, acb_srcptr y, slong ystep, slong len, slong prec) noexcept void acb_dot_simple(acb_t res, const acb_t s, int subtract, acb_srcptr x, slong xstep, acb_srcptr y, slong ystep, slong len, slong prec) noexcept void acb_dot(acb_t res, const acb_t s, int subtract, acb_srcptr x, slong xstep, acb_srcptr y, slong ystep, slong len, slong prec) noexcept - # Computes the dot product of the vectors *x* and *y*, setting - # *res* to `s + (-1)^{subtract} \sum_{i=0}^{len-1} x_i y_i`. - # The initial term *s* is optional and can be - # omitted by passing *NULL* (equivalently, `s = 0`). - # The parameter *subtract* must be 0 or 1. - # The length *len* is allowed to be negative, which is equivalent - # to a length of zero. - # The parameters *xstep* or *ystep* specify a step length for - # traversing subsequences of the vectors *x* and *y*; either can be - # negative to step in the reverse direction starting from - # the initial pointer. - # Aliasing is allowed between *res* and *s* but not between - # *res* and the entries of *x* and *y*. - # The default version determines the optimal precision for each term - # and performs all internal calculations using mpn arithmetic - # with minimal overhead. This is the preferred way to compute a - # dot product; it is generally much faster and more precise - # than a simple loop. - # The *simple* version performs fused multiply-add operations in - # a simple loop. This can be used for - # testing purposes and is also used as a fallback by the - # default version when the exponents are out of range - # for the optimized code. - # The *precise* version computes the dot product exactly up to the - # final rounding. This can be extremely slow and is only intended - # for testing. - void acb_approx_dot(acb_t res, const acb_t s, int subtract, acb_srcptr x, slong xstep, acb_srcptr y, slong ystep, slong len, slong prec) noexcept - # Computes an approximate dot product *without error bounds*. - # The radii of the inputs are ignored (only the midpoints are read) - # and only the midpoint of the output is written. - void acb_dot_ui(acb_t res, const acb_t initial, int subtract, acb_srcptr x, slong xstep, const ulong * y, slong ystep, slong len, slong prec) noexcept void acb_dot_si(acb_t res, const acb_t initial, int subtract, acb_srcptr x, slong xstep, const slong * y, slong ystep, slong len, slong prec) noexcept void acb_dot_uiui(acb_t res, const acb_t initial, int subtract, acb_srcptr x, slong xstep, const ulong * y, slong ystep, slong len, slong prec) noexcept void acb_dot_siui(acb_t res, const acb_t initial, int subtract, acb_srcptr x, slong xstep, const ulong * y, slong ystep, slong len, slong prec) noexcept void acb_dot_fmpz(acb_t res, const acb_t initial, int subtract, acb_srcptr x, slong xstep, const fmpz * y, slong ystep, slong len, slong prec) noexcept - # Equivalent to :func:`acb_dot`, but with integers in the array *y*. - # The *uiui* and *siui* versions take an array of double-limb integers - # as input; the *siui* version assumes that these represent signed - # integers in two's complement form. - void acb_const_pi(acb_t y, slong prec) noexcept - # Sets *y* to the constant `\pi`. - void acb_sqrt(acb_t r, const acb_t z, slong prec) noexcept - # Sets *r* to the square root of *z*. - # If either the real or imaginary part is exactly zero, only - # a single real square root is needed. Generally, we use the formula - # `\sqrt{a+bi} = u/2 + ib/u, u = \sqrt{2(|a+bi|+a)}`, - # requiring two real square root extractions. - void acb_sqrt_analytic(acb_t r, const acb_t z, int analytic, slong prec) noexcept - # Computes the square root. If *analytic* is set, gives a NaN-containing - # result if *z* touches the branch cut. - void acb_rsqrt(acb_t r, const acb_t z, slong prec) noexcept - # Sets *r* to the reciprocal square root of *z*. - # If either the real or imaginary part is exactly zero, only - # a single real reciprocal square root is needed. Generally, we use the - # formula `1/\sqrt{a+bi} = ((a+r) - bi)/v, r = |a+bi|, v = \sqrt{r |a+bi+r|^2}`, - # requiring one real square root and one real reciprocal square root. - void acb_rsqrt_analytic(acb_t r, const acb_t z, int analytic, slong prec) noexcept - # Computes the reciprocal square root. If *analytic* is set, gives a - # NaN-containing result if *z* touches the branch cut. - + void acb_sqrts(acb_t y1, acb_t y2, const acb_t x, slong prec) noexcept void acb_quadratic_roots_fmpz(acb_t r1, acb_t r2, const fmpz_t a, const fmpz_t b, const fmpz_t c, slong prec) noexcept - # Sets *r1* and *r2* to the roots of the quadratic polynomial - # `ax^2 + bx + c`. Requires that *a* is nonzero. - # This function is implemented so that both roots are computed accurately - # even when direct use of the quadratic formula would lose accuracy. - void acb_root_ui(acb_t r, const acb_t z, ulong k, slong prec) noexcept - # Sets *r* to the principal *k*-th root of *z*. - void acb_pow_fmpz(acb_t y, const acb_t b, const fmpz_t e, slong prec) noexcept - void acb_pow_ui(acb_t y, const acb_t b, ulong e, slong prec) noexcept - void acb_pow_si(acb_t y, const acb_t b, slong e, slong prec) noexcept - # Sets `y = b^e` using binary exponentiation (with an initial division - # if `e < 0`). Note that these functions can get slow if the exponent is - # extremely large (in such cases :func:`acb_pow` may be superior). - void acb_pow_arb(acb_t z, const acb_t x, const arb_t y, slong prec) noexcept - void acb_pow(acb_t z, const acb_t x, const acb_t y, slong prec) noexcept - # Sets `z = x^y`, computed using binary exponentiation if `y` if - # a small exact integer, as `z = (x^{1/2})^{2y}` if `y` is a small exact - # half-integer, and generally as `z = \exp(y \log x)`. - void acb_pow_analytic(acb_t r, const acb_t x, const acb_t y, int analytic, slong prec) noexcept - # Computes the power `x^y`. If *analytic* is set, gives a - # NaN-containing result if *x* touches the branch cut (unless *y* is - # an integer). - void acb_unit_root(acb_t res, ulong order, slong prec) noexcept - # Sets *res* to `\exp(\frac{2i\pi}{\mathrm{order}})` to precision *prec*. - void acb_exp(acb_t y, const acb_t z, slong prec) noexcept - # Sets *y* to the exponential function of *z*, computed as - # `\exp(a+bi) = \exp(a) \left( \cos(b) + \sin(b) i \right)`. - void acb_exp_pi_i(acb_t y, const acb_t z, slong prec) noexcept - # Sets *y* to `\exp(\pi i z)`. - void acb_exp_invexp(acb_t s, acb_t t, const acb_t z, slong prec) noexcept - # Sets `s = \exp(z)` and `t = \exp(-z)`. - void acb_expm1(acb_t res, const acb_t z, slong prec) noexcept - # Sets *res* to `\exp(z)-1`, using a more accurate method when `z \approx 0`. - void acb_log(acb_t y, const acb_t z, slong prec) noexcept - # Sets *y* to the principal branch of the natural logarithm of *z*, - # computed as - # `\log(a+bi) = \frac{1}{2} \log(a^2 + b^2) + i \operatorname{arg}(a+bi)`. - void acb_log_analytic(acb_t r, const acb_t z, int analytic, slong prec) noexcept - # Computes the natural logarithm. If *analytic* is set, gives a - # NaN-containing result if *z* touches the branch cut. - void acb_log1p(acb_t z, const acb_t x, slong prec) noexcept - # Sets `z = \log(1+x)`, computed accurately when `x \approx 0`. - void acb_sin(acb_t s, const acb_t z, slong prec) noexcept - void acb_cos(acb_t c, const acb_t z, slong prec) noexcept - void acb_sin_cos(acb_t s, acb_t c, const acb_t z, slong prec) noexcept - # Sets `s = \sin(z)`, `c = \cos(z)`, evaluated as - # `\sin(a+bi) = \sin(a)\cosh(b) + i \cos(a)\sinh(b)`, - # `\cos(a+bi) = \cos(a)\cosh(b) - i \sin(a)\sinh(b)`. - void acb_tan(acb_t s, const acb_t z, slong prec) noexcept - # Sets `s = \tan(z) = \sin(z) / \cos(z)`. For large imaginary parts, - # the function is evaluated in a numerically stable way as `\pm i` - # plus a decreasing exponential factor. - void acb_cot(acb_t s, const acb_t z, slong prec) noexcept - # Sets `s = \cot(z) = \cos(z) / \sin(z)`. For large imaginary parts, - # the function is evaluated in a numerically stable way as `\pm i` - # plus a decreasing exponential factor. - void acb_sin_pi(acb_t s, const acb_t z, slong prec) noexcept - void acb_cos_pi(acb_t s, const acb_t z, slong prec) noexcept - void acb_sin_cos_pi(acb_t s, acb_t c, const acb_t z, slong prec) noexcept - # Sets `s = \sin(\pi z)`, `c = \cos(\pi z)`, evaluating the trigonometric - # factors of the real and imaginary part accurately via :func:`arb_sin_cos_pi`. - void acb_tan_pi(acb_t s, const acb_t z, slong prec) noexcept - # Sets `s = \tan(\pi z)`. Uses the same algorithm as :func:`acb_tan`, - # but evaluates the sine and cosine accurately via :func:`arb_sin_cos_pi`. - void acb_cot_pi(acb_t s, const acb_t z, slong prec) noexcept - # Sets `s = \cot(\pi z)`. Uses the same algorithm as :func:`acb_cot`, - # but evaluates the sine and cosine accurately via :func:`arb_sin_cos_pi`. - void acb_sec(acb_t res, const acb_t z, slong prec) noexcept - # Computes `\sec(z) = 1 / \cos(z)`. - void acb_csc(acb_t res, const acb_t z, slong prec) noexcept - # Computes `\csc(x) = 1 / \sin(z)`. - void acb_csc_pi(acb_t res, const acb_t z, slong prec) noexcept - # Computes `\csc(\pi x) = 1 / \sin(\pi z)`. Evaluates the sine accurately - # via :func:`acb_sin_pi`. - void acb_sinc(acb_t s, const acb_t z, slong prec) noexcept - # Sets `s = \operatorname{sinc}(x) = \sin(z) / z`. - void acb_sinc_pi(acb_t s, const acb_t z, slong prec) noexcept - # Sets `s = \operatorname{sinc}(\pi x) = \sin(\pi z) / (\pi z)`. - void acb_asin(acb_t res, const acb_t z, slong prec) noexcept - # Sets *res* to `\operatorname{asin}(z) = -i \log(iz + \sqrt{1-z^2})`. - void acb_acos(acb_t res, const acb_t z, slong prec) noexcept - # Sets *res* to `\operatorname{acos}(z) = \tfrac{1}{2} \pi - \operatorname{asin}(z)`. - void acb_atan(acb_t res, const acb_t z, slong prec) noexcept - # Sets *res* to `\operatorname{atan}(z) = \tfrac{1}{2} i (\log(1-iz)-\log(1+iz))`. - void acb_sinh(acb_t s, const acb_t z, slong prec) noexcept - void acb_cosh(acb_t c, const acb_t z, slong prec) noexcept - void acb_sinh_cosh(acb_t s, acb_t c, const acb_t z, slong prec) noexcept - void acb_tanh(acb_t s, const acb_t z, slong prec) noexcept - void acb_coth(acb_t s, const acb_t z, slong prec) noexcept - # Respectively computes `\sinh(z) = -i\sin(iz)`, `\cosh(z) = \cos(iz)`, - # `\tanh(z) = -i\tan(iz)`, `\coth(z) = i\cot(iz)`. - void acb_sech(acb_t res, const acb_t z, slong prec) noexcept - # Computes `\operatorname{sech}(z) = 1 / \cosh(z)`. - void acb_csch(acb_t res, const acb_t z, slong prec) noexcept - # Computes `\operatorname{csch}(z) = 1 / \sinh(z)`. - void acb_asinh(acb_t res, const acb_t z, slong prec) noexcept - # Sets *res* to `\operatorname{asinh}(z) = -i \operatorname{asin}(iz)`. - void acb_acosh(acb_t res, const acb_t z, slong prec) noexcept - # Sets *res* to `\operatorname{acosh}(z) = \log(z + \sqrt{z+1} \sqrt{z-1})`. - void acb_atanh(acb_t res, const acb_t z, slong prec) noexcept - # Sets *res* to `\operatorname{atanh}(z) = -i \operatorname{atan}(iz)`. - void acb_lambertw_asymp(acb_t res, const acb_t z, const fmpz_t k, slong L, slong M, slong prec) noexcept - # Sets *res* to the Lambert W function `W_k(z)` computed using *L* and *M* - # terms in the bivariate series giving the asymptotic expansion at - # zero or infinity. This algorithm is valid - # everywhere, but the error bound is only finite when `|\log(z)|` is - # sufficiently large. - int acb_lambertw_check_branch(const acb_t w, const fmpz_t k, slong prec) noexcept - # Tests if *w* definitely lies in the image of the branch `W_k(z)`. - # This function is used internally to verify that a computed approximation - # of the Lambert W function lies on the intended branch. Note that this will - # necessarily evaluate to false for points exactly on (or overlapping) the - # branch cuts, where a different algorithm has to be used. - void acb_lambertw_bound_deriv(mag_t res, const acb_t z, const acb_t ez1, const fmpz_t k) noexcept - # Sets *res* to an upper bound for `|W_k'(z)|`. The input *ez1* should - # contain the precomputed value of `ez+1`. - # Along the real line, the directional derivative of `W_k(z)` is understood - # to be taken. As a result, the user must handle the branch cut - # discontinuity separately when using this function to bound perturbations - # in the value of `W_k(z)`. - void acb_lambertw(acb_t res, const acb_t z, const fmpz_t k, int flags, slong prec) noexcept - # Sets *res* to the Lambert W function `W_k(z)` where the index *k* selects - # the branch (with `k = 0` giving the principal branch). - # The placement of branch cuts follows [CGHJK1996]_. - # If *flags* is nonzero, nonstandard branch cuts are used. - # If *flags* is set to *ACB_LAMBERTW_LEFT*, computes `W_{\mathrm{left}|k}(z)` - # which corresponds to `W_k(z)` in the upper - # half plane and `W_{k+1}(z)` in the lower half plane, connected continuously - # to the left of the branch points. - # In other words, the branch cut on `(-\infty,0)` is rotated counterclockwise - # to `(0,+\infty)`. - # (For `k = -1` and `k = 0`, there is also a branch cut on `(-1/e,0)`, - # continuous from below instead of from above to maintain counterclockwise - # continuity.) - # If *flags* is set to *ACB_LAMBERTW_MIDDLE*, computes - # `W_{\mathrm{middle}}(z)` which corresponds to - # `W_{-1}(z)` in the upper half plane and `W_{1}(z)` in the lower half - # plane, connected continuously through `(-1/e,0)` with branch cuts - # on `(-\infty,-1/e)` and `(0,+\infty)`. `W_{\mathrm{middle}}(z)` extends the - # real analytic function `W_{-1}(x)` defined on `(-1/e,0)` to a complex - # analytic function, whereas the standard branch `W_{-1}(z)` has a branch - # cut along the real segment. - # The algorithm used to compute the Lambert W function is described - # in [Joh2017b]_. - void acb_rising_ui(acb_t z, const acb_t x, ulong n, slong prec) noexcept void acb_rising(acb_t z, const acb_t x, const acb_t n, slong prec) noexcept - # Computes the rising factorial `z = x (x+1) (x+2) \cdots (x+n-1)`. - # These functions are aliases for :func:`acb_hypgeom_rising_ui` - # and :func:`acb_hypgeom_rising`. - void acb_gamma(acb_t y, const acb_t x, slong prec) noexcept - # Computes the gamma function `y = \Gamma(x)`. - # This is an alias for :func:`acb_hypgeom_gamma`. - void acb_rgamma(acb_t y, const acb_t x, slong prec) noexcept - # Computes the reciprocal gamma function `y = 1/\Gamma(x)`, - # avoiding division by zero at the poles of the gamma function. - # This is an alias for :func:`acb_hypgeom_rgamma`. - void acb_lgamma(acb_t y, const acb_t x, slong prec) noexcept - # Computes the logarithmic gamma function `y = \log \Gamma(x)`. - # This is an alias for :func:`acb_hypgeom_lgamma`. - # The branch cut of the logarithmic gamma function is placed on the - # negative half-axis, which means that - # `\log \Gamma(z) + \log z = \log \Gamma(z+1)` holds for all `z`, - # whereas `\log \Gamma(z) \ne \log(\Gamma(z))` in general. - # In the left half plane, the reflection formula with correct - # branch structure is evaluated via :func:`acb_log_sin_pi`. - void acb_digamma(acb_t y, const acb_t x, slong prec) noexcept - # Computes the digamma function `y = \psi(x) = (\log \Gamma(x))' = \Gamma'(x) / \Gamma(x)`. - void acb_log_sin_pi(acb_t res, const acb_t z, slong prec) noexcept - # Computes the logarithmic sine function defined by - # .. math :: - # S(z) = \log(\pi) - \log \Gamma(z) + \log \Gamma(1-z) - # which is equal to - # .. math :: - # S(z) = \int_{1/2}^z \pi \cot(\pi t) dt - # where the path of integration goes through the upper half plane - # if `0 < \arg(z) \le \pi` and through the lower half plane - # if `-\pi < \arg(z) \le 0`. Equivalently, - # .. math :: - # S(z) = \log(\sin(\pi(z-n))) \mp n \pi i, \quad n = \lfloor \operatorname{re}(z) \rfloor - # where the negative sign is taken if `0 < \arg(z) \le \pi` - # and the positive sign is taken otherwise (if the interval `\arg(z)` - # does not certainly satisfy either condition, the union of - # both cases is computed). - # After subtracting *n*, we have `0 \le \operatorname{re}(z) < 1`. In - # this strip, we use - # use `S(z) = \log(\sin(\pi(z)))` if the imaginary part of *z* is small. - # Otherwise, we use `S(z) = i \pi (z-1/2) + \log((1+e^{-2i\pi z})/2)` - # in the lower half-plane and the conjugated expression in the upper - # half-plane to avoid exponent overflow. - # The function is evaluated at the midpoint and the propagated error - # is computed from `S'(z)` to get a continuous change - # when `z` is non-real and `n` spans more than one possible integer value. - void acb_polygamma(acb_t res, const acb_t s, const acb_t z, slong prec) noexcept - # Sets *res* to the value of the generalized polygamma function `\psi(s,z)`. - # If *s* is a nonnegative order, this is simply the *s*-order derivative - # of the digamma function. If `s = 0`, this function simply - # calls the digamma function internally. For integers `s \ge 1`, - # it calls the Hurwitz zeta function. Note that for small integers - # `s \ge 1`, it can be faster to use - # :func:`acb_poly_digamma_series` and read off the coefficients. - # The generalization to other values of *s* is due to - # Espinosa and Moll [EM2004]_: - # .. math :: - # \psi(s,z) = \frac{\zeta'(s+1,z) + (\gamma + \psi(-s)) \zeta(s+1,z)}{\Gamma(-s)} - void acb_barnes_g(acb_t res, const acb_t z, slong prec) noexcept - void acb_log_barnes_g(acb_t res, const acb_t z, slong prec) noexcept - # Computes Barnes *G*-function or the logarithmic Barnes *G*-function, - # respectively. The logarithmic version has branch cuts on the negative - # real axis and is continuous elsewhere in the complex plane, - # in analogy with the logarithmic gamma function. The functional - # equation - # .. math :: - # \log G(z+1) = \log \Gamma(z) + \log G(z). - # holds for all *z*. - # For small integers, we directly use the recurrence - # relation `G(z+1) = \Gamma(z) G(z)` together with the initial value - # `G(1) = 1`. For general *z*, we use the formula - # .. math :: - # \log G(z) = (z-1) \log \Gamma(z) - \zeta'(-1,z) + \zeta'(-1). - void acb_zeta(acb_t z, const acb_t s, slong prec) noexcept - # Sets *z* to the value of the Riemann zeta function `\zeta(s)`. - # Note: for computing derivatives with respect to `s`, - # use :func:`acb_poly_zeta_series` or related methods. - # This is a wrapper of :func:`acb_dirichlet_zeta`. - void acb_hurwitz_zeta(acb_t z, const acb_t s, const acb_t a, slong prec) noexcept - # Sets *z* to the value of the Hurwitz zeta function `\zeta(s, a)`. - # Note: for computing derivatives with respect to `s`, - # use :func:`acb_poly_zeta_series` or related methods. - # This is a wrapper of :func:`acb_dirichlet_hurwitz`. - void acb_bernoulli_poly_ui(acb_t res, ulong n, const acb_t x, slong prec) noexcept - # Sets *res* to the value of the Bernoulli polynomial `B_n(x)`. - # Warning: this function is only fast if either *n* or *x* is a small integer. - # This function reads Bernoulli numbers from the global cache if they - # are already cached, but does not automatically extend the cache by itself. - void acb_polylog(acb_t w, const acb_t s, const acb_t z, slong prec) noexcept - void acb_polylog_si(acb_t w, slong s, const acb_t z, slong prec) noexcept - # Sets *w* to the polylogarithm `\operatorname{Li}_s(z)`. - void acb_agm1(acb_t m, const acb_t z, slong prec) noexcept - # Sets *m* to the arithmetic-geometric mean `M(z) = \operatorname{agm}(1,z)`, - # defined such that the function is continuous in the complex plane except for - # a branch cut along the negative half axis (where it is continuous - # from above). This corresponds to always choosing an "optimal" branch for - # the square root in the arithmetic-geometric mean iteration. - void acb_agm1_cpx(acb_ptr m, const acb_t z, slong len, slong prec) noexcept - # Sets the coefficients in the array *m* to the power series expansion of the - # arithmetic-geometric mean at the point *z* truncated to length *len*, i.e. - # `M(z+x) \in \mathbb{C}[[x]]`. - void acb_agm(acb_t m, const acb_t x, const acb_t y, slong prec) noexcept - # Sets *m* to the arithmetic-geometric mean of *x* and *y*. The square - # roots in the AGM iteration are chosen so as to form the "optimal" - # AGM sequence. This gives a well-defined function of *x* and *y* except - # when `x / y` is a negative real number, in which case there are two - # optimal AGM sequences. In that case, an arbitrary but consistent - # choice is made (if a decision cannot be made due to inexact arithmetic, - # the union of both choices is returned). - void acb_chebyshev_t_ui(acb_t a, ulong n, const acb_t x, slong prec) noexcept - void acb_chebyshev_u_ui(acb_t a, ulong n, const acb_t x, slong prec) noexcept - # Evaluates the Chebyshev polynomial of the first kind `a = T_n(x)` - # or the Chebyshev polynomial of the second kind `a = U_n(x)`. - void acb_chebyshev_t2_ui(acb_t a, acb_t b, ulong n, const acb_t x, slong prec) noexcept - void acb_chebyshev_u2_ui(acb_t a, acb_t b, ulong n, const acb_t x, slong prec) noexcept - # Simultaneously evaluates `a = T_n(x), b = T_{n-1}(x)` or - # `a = U_n(x), b = U_{n-1}(x)`. - # Aliasing between *a*, *b* and *x* is not permitted. - void acb_real_abs(acb_t res, const acb_t z, int analytic, slong prec) noexcept - # The absolute value is extended to `+z` in the right half plane and - # `-z` in the left half plane, with a discontinuity on the vertical line - # `\operatorname{Re}(z) = 0`. - void acb_real_sgn(acb_t res, const acb_t z, int analytic, slong prec) noexcept - # The sign function is extended to `+1` in the right half plane and - # `-1` in the left half plane, with a discontinuity on the vertical line - # `\operatorname{Re}(z) = 0`. - # If *analytic* is not set, this is effectively the same function as - # :func:`acb_csgn`. - void acb_real_heaviside(acb_t res, const acb_t z, int analytic, slong prec) noexcept - # The Heaviside step function (or unit step function) is extended to `+1` in - # the right half plane and `0` in the left half plane, with a discontinuity on - # the vertical line `\operatorname{Re}(z) = 0`. - void acb_real_floor(acb_t res, const acb_t z, int analytic, slong prec) noexcept - # The floor function is extended to a piecewise constant function - # equal to `n` in the strips with real part `(n,n+1)`, with discontinuities - # on the vertical lines `\operatorname{Re}(z) = n`. - void acb_real_ceil(acb_t res, const acb_t z, int analytic, slong prec) noexcept - # The ceiling function is extended to a piecewise constant function - # equal to `n+1` in the strips with real part `(n,n+1)`, with discontinuities - # on the vertical lines `\operatorname{Re}(z) = n`. - void acb_real_max(acb_t res, const acb_t x, const acb_t y, int analytic, slong prec) noexcept - # The real function `\max(x,y)` is extended to a piecewise analytic function - # of two variables by returning `x` when - # `\operatorname{Re}(x) \ge \operatorname{Re}(y)` - # and returning `y` when `\operatorname{Re}(x) < \operatorname{Re}(y)`, - # with discontinuities where `\operatorname{Re}(x) = \operatorname{Re}(y)`. - void acb_real_min(acb_t res, const acb_t x, const acb_t y, int analytic, slong prec) noexcept - # The real function `\min(x,y)` is extended to a piecewise analytic function - # of two variables by returning `x` when - # `\operatorname{Re}(x) \le \operatorname{Re}(y)` - # and returning `y` when `\operatorname{Re}(x) > \operatorname{Re}(y)`, - # with discontinuities where `\operatorname{Re}(x) = \operatorname{Re}(y)`. - void acb_real_sqrtpos(acb_t res, const acb_t z, int analytic, slong prec) noexcept - # Extends the real square root function on `[0,+\infty)` to the usual - # complex square root on the cut plane. Like :func:`arb_sqrtpos`, only - # the nonnegative part of *z* is considered if *z* is purely real - # and *analytic* is not set. This is useful for integrating `\sqrt{f(x)}` - # where it is known that `f(x) \ge 0`: unlike :func:`acb_sqrt_analytic`, - # no spurious imaginary terms `[\pm \varepsilon] i` are created when the - # balls computed for `f(x)` straddle zero. - void _acb_vec_zero(acb_ptr A, slong n) noexcept - # Sets all entries in *vec* to zero. - bint _acb_vec_is_zero(acb_srcptr vec, slong len) noexcept - # Returns nonzero iff all entries in *x* are zero. - bint _acb_vec_is_real(acb_srcptr v, slong len) noexcept - # Returns nonzero iff all entries in *x* have zero imaginary part. - + bint _acb_vec_is_finite(acb_srcptr vec, slong len) noexcept + bint _acb_vec_equal(acb_srcptr vec1, acb_srcptr vec2, slong len) noexcept + bint _acb_vec_overlaps(acb_srcptr vec1, acb_srcptr vec2, slong len) noexcept + bint _acb_vec_contains(acb_srcptr vec1, acb_srcptr vec2, slong len) noexcept void _acb_vec_set(acb_ptr res, acb_srcptr vec, slong len) noexcept - # Sets *res* to a copy of *vec*. - void _acb_vec_set_round(acb_ptr res, acb_srcptr vec, slong len, slong prec) noexcept - # Sets *res* to a copy of *vec*, rounding each entry to *prec* bits. - void _acb_vec_swap(acb_ptr vec1, acb_ptr vec2, slong len) noexcept - # Swaps the entries of *vec1* and *vec2*. - + void _acb_vec_get_real(arb_ptr re, acb_srcptr vec, slong len) noexcept + void _acb_vec_get_imag(arb_ptr im, acb_srcptr vec, slong len) noexcept + void _acb_vec_set_real_imag(acb_ptr vec, arb_srcptr re, arb_srcptr im, slong len) noexcept void _acb_vec_neg(acb_ptr res, acb_srcptr vec, slong len) noexcept - void _acb_vec_add(acb_ptr res, acb_srcptr vec1, acb_srcptr vec2, slong len, slong prec) noexcept - void _acb_vec_sub(acb_ptr res, acb_srcptr vec1, acb_srcptr vec2, slong len, slong prec) noexcept - void _acb_vec_scalar_submul(acb_ptr res, acb_srcptr vec, slong len, const acb_t c, slong prec) noexcept - void _acb_vec_scalar_addmul(acb_ptr res, acb_srcptr vec, slong len, const acb_t c, slong prec) noexcept - void _acb_vec_scalar_mul(acb_ptr res, acb_srcptr vec, slong len, const acb_t c, slong prec) noexcept - void _acb_vec_scalar_mul_ui(acb_ptr res, acb_srcptr vec, slong len, ulong c, slong prec) noexcept - void _acb_vec_scalar_mul_2exp_si(acb_ptr res, acb_srcptr vec, slong len, slong c) noexcept - void _acb_vec_scalar_mul_onei(acb_ptr res, acb_srcptr vec, slong len) noexcept - void _acb_vec_scalar_div_ui(acb_ptr res, acb_srcptr vec, slong len, ulong c, slong prec) noexcept - void _acb_vec_scalar_div(acb_ptr res, acb_srcptr vec, slong len, const acb_t c, slong prec) noexcept - void _acb_vec_scalar_mul_arb(acb_ptr res, acb_srcptr vec, slong len, const arb_t c, slong prec) noexcept - void _acb_vec_scalar_div_arb(acb_ptr res, acb_srcptr vec, slong len, const arb_t c, slong prec) noexcept - void _acb_vec_scalar_mul_fmpz(acb_ptr res, acb_srcptr vec, slong len, const fmpz_t c, slong prec) noexcept - void _acb_vec_scalar_div_fmpz(acb_ptr res, acb_srcptr vec, slong len, const fmpz_t c, slong prec) noexcept - + void _acb_vec_sqr(acb_ptr res, acb_srcptr vec, slong len, slong prec) noexcept slong _acb_vec_bits(acb_srcptr vec, slong len) noexcept - # Returns the maximum of :func:`arb_bits` for all entries in *vec*. - void _acb_vec_set_powers(acb_ptr xs, const acb_t x, slong len, slong prec) noexcept - # Sets *xs* to the powers `1, x, x^2, \ldots, x^{len-1}`. - void _acb_vec_unit_roots(acb_ptr z, slong order, slong len, slong prec) noexcept - # Sets *z* to the powers `1,z,z^2,\dots z^{\mathrm{len}-1}` where `z=\exp(\frac{2i\pi}{\mathrm{order}})` to precision *prec*. - # *order* can be taken negative. - # In order to avoid precision loss, this function does not simply compute powers of a primitive root. - void _acb_vec_add_error_arf_vec(acb_ptr res, arf_srcptr err, slong len) noexcept - void _acb_vec_add_error_mag_vec(acb_ptr res, mag_srcptr err, slong len) noexcept - # Adds the magnitude of each entry in *err* to the radius of the - # corresponding entry in *res*. - void _acb_vec_indeterminate(acb_ptr vec, slong len) noexcept - # Applies :func:`acb_indeterminate` elementwise. - void _acb_vec_trim(acb_ptr res, acb_srcptr vec, slong len) noexcept - # Applies :func:`acb_trim` elementwise. - int _acb_vec_get_unique_fmpz_vec(fmpz * res, acb_srcptr vec, slong len) noexcept - # Calls :func:`acb_get_unique_fmpz` elementwise and returns nonzero if - # all entries can be rounded uniquely to integers. If any entry in *vec* - # cannot be rounded uniquely to an integer, returns zero. - void _acb_vec_sort_pretty(acb_ptr vec, slong len) noexcept - # Sorts the vector of complex numbers based on the real and imaginary parts. - # This is intended to reveal structure when printing a set of complex numbers, - # not to apply an order relation in a rigorous way. + void _acb_vec_printd(acb_srcptr vec, slong len, slong digits) noexcept + void _acb_vec_printn(acb_srcptr vec, slong len, slong digits, ulong flags) noexcept from .acb_macros cimport * diff --git a/src/sage/libs/flint/acb_calc.pxd b/src/sage/libs/flint/acb_calc.pxd index c0a78d68dc9..45e6a27db09 100644 --- a/src/sage/libs/flint/acb_calc.pxd +++ b/src/sage/libs/flint/acb_calc.pxd @@ -2,7 +2,9 @@ # distutils: depends = flint/acb_calc.h ################################################################################ -# This file is auto-generated. Do not modify by hand +# This file is auto-generated by the script +# SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py. +# Do not modify by hand! Fix and rerun the script instead. ################################################################################ from libc.stdio cimport FILE @@ -11,163 +13,8 @@ from sage.libs.mpfr.types cimport * from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - int acb_calc_integrate(acb_t res, acb_calc_func_t func, void * param, const acb_t a, const acb_t b, slong rel_goal, const mag_t abs_tol, const acb_calc_integrate_opt_t options, slong prec) noexcept - # Computes a rigorous enclosure of the integral - # .. math :: - # I = \int_a^b f(t) dt - # where *f* is specified by (*func*, *param*), following a straight-line - # path between the complex numbers *a* and *b*. - # For finite results, *a*, *b* must be finite and *f* must be bounded - # on the path of integration. - # To compute improper integrals, the user should therefore truncate the path - # of integration manually (or make a regularizing change of variables, - # if possible). - # Returns *ARB_CALC_SUCCESS* if the integration converged to the - # target accuracy on all subintervals, and returns - # *ARB_CALC_NO_CONVERGENCE* otherwise. - # By default, the integrand *func* will only be called with *order* = 0 - # or *order* = 1; that is, derivatives are not required. - # - The integrand will be called with *order* = 0 to evaluate *f* - # normally on the integration path (either at a single point - # or on a subinterval). In this case, *f* is treated as a pointwise defined - # function and can have arbitrary discontinuities. - # - The integrand will be called with *order* = 1 to evaluate *f* - # on a domain surrounding a segment of the integration path for the purpose - # of bounding the error of a quadrature formula. In this case, *func* must - # verify that *f* is holomorphic on this domain (and output a non-finite - # value if it is not). - # The integration algorithm combines direct interval enclosures, - # Gauss-Legendre quadrature where *f* is holomorphic, - # and adaptive subdivision. This strategy supports integrands with - # discontinuities while providing exponential convergence for typical - # piecewise holomorphic integrands. - # The following parameters control accuracy: - # - *rel_goal* - relative accuracy goal as a number of bits, i.e. - # target a relative error less than `\varepsilon_{rel} = 2^{-r}` - # where *r* = *rel_goal* - # (note the sign: *rel_goal* should be nonnegative). - # - *abs_tol* - absolute accuracy goal as a :type:`mag_t` describing - # the error tolerance, i.e. - # target an absolute error less than `\varepsilon_{abs}` = *abs_tol*. - # - *prec* - working precision. This is the working precision used to - # evaluate the integrand and manipulate interval endpoints. - # As currently implemented, the algorithm does not attempt to adjust the - # working precision by itself, and adaptive - # control of the working precision must be handled by the user. - # For typical usage, set *rel_goal* = *prec* and *abs_tol* = `2^{-prec}`. - # It usually only makes sense to have *rel_goal* between 0 and *prec*. - # The algorithm attempts to achieve an error of - # `\max(\varepsilon_{abs}, M \varepsilon_{rel})` on each subinterval, - # where *M* is the magnitude of the integral. - # These parameters are only guidelines; the cumulative error may be larger - # than both the prescribed - # absolute and relative error goals, depending on the number of - # subdivisions, cancellation between segments of the integral, and numerical - # errors in the evaluation of the integrand. - # To compute tiny integrals with high relative accuracy, one should set - # `\varepsilon_{abs} \approx M \varepsilon_{rel}` where *M* is a known - # estimate of the magnitude. Setting `\varepsilon_{abs}` to 0 is also - # allowed, forcing use of a relative instead of an absolute tolerance goal. - # This can be handy for exponentially small or - # large functions of unknown magnitude. It is recommended to avoid - # setting `\varepsilon_{abs}` very small - # if possible since the algorithm might need many extra - # subdivisions to estimate *M* automatically; if the approximate - # magnitude can be estimated by some external means (for example if - # a midpoint-width or endpoint-width estimate is known to be accurate), - # providing an appropriate `\varepsilon_{abs} \approx M \varepsilon_{rel}` - # will be more efficient. - # If the integral has very large magnitude, setting the absolute - # tolerance to a corresponding large value is recommended for best - # performance, but it is not necessary for convergence since the absolute - # tolerance is increased automatically during the execution of the - # algorithm if the partial integrals are found to have larger error. - # Additional options for the integration can be provided via the *options* - # parameter (documented below). To use all defaults, *NULL* can be passed - # for *options*. - void acb_calc_integrate_opt_init(acb_calc_integrate_opt_t options) noexcept - # Initializes *options* for use, setting all fields to 0 indicating - # default values. - int acb_calc_integrate_gl_auto_deg(acb_t res, slong * num_eval, acb_calc_func_t func, void * param, const acb_t a, const acb_t b, const mag_t tol, slong deg_limit, int flags, slong prec) noexcept - # Attempts to compute `I = \int_a^b f(t) dt` using a single application - # of Gauss-Legendre quadrature with automatic determination of the - # quadrature degree so that the error is smaller than *tol*. - # Returns *ARB_CALC_SUCCESS* if the integral has been evaluated successfully - # or *ARB_CALC_NO_CONVERGENCE* if the tolerance could not be met. - # The total number of function evaluations is written to *num_eval*. - # For the interval `[-1,1]`, the error of the *n*-point Gauss-Legendre - # rule is bounded by - # .. math :: - # \left| I - \sum_{k=0}^{n-1} w_k f(x_k) \right| \le \frac{64 M}{15 (\rho-1) \rho^{2n-1}} - # if `f` is holomorphic with `|f(z)| \le M` inside the ellipse *E* - # with foci `\pm 1` and semiaxes - # `X` and `Y = \sqrt{X^2 - 1}` such that `\rho = X + Y` - # with `\rho > 1` [Tre2008]_. - # For an arbitrary interval, we use `\int_a^b f(t) dt = \int_{-1}^1 g(t) dt` - # where `g(t) = \Delta f(\Delta t + m)`, - # `\Delta = \tfrac{1}{2}(b-a)`, `m = \tfrac{1}{2}(a+b)`. - # With `I = [\pm X] + [\pm Y]i`, this means that we evaluate - # `\Delta f(\Delta I + m)` to get the bound `M`. - # (An improvement would be to reduce the wrapping effect of rotating the - # ellipse when the path is not rectilinear). - # We search for an `X` that makes the error small by trying steps `2^{2^k}`. - # Larger `X` will give smaller `1 / \rho^{2n-1}` but larger `M`. If we try - # successive larger values of `k`, we can abort when `M = \infty` - # since this either means that we have hit a singularity or a branch cut or - # that overestimation in the evaluation of `f` is becoming too severe. - void acb_calc_cauchy_bound(arb_t bound, acb_calc_func_t func, void * param, const acb_t x, const arb_t radius, slong maxdepth, slong prec) noexcept - # Sets *bound* to a ball containing the value of the integral - # .. math :: - # C(x,r) = \frac{1}{2 \pi r} \oint_{|z-x| = r} |f(z)| dz - # = \int_0^1 |f(x+re^{2\pi i t})| dt - # where *f* is specified by (*func*, *param*) and *r* is given by *radius*. - # The integral is computed using a simple step sum. - # The integration range is subdivided until the order of magnitude of *b* - # can be determined (i.e. its error bound is smaller than its midpoint), - # or until the step length has been cut in half *maxdepth* times. - # This function is currently implemented completely naively, and - # repeatedly subdivides the whole integration range instead of - # performing adaptive subdivisions. - int acb_calc_integrate_taylor(acb_t res, acb_calc_func_t func, void * param, const acb_t a, const acb_t b, const arf_t inner_radius, const arf_t outer_radius, slong accuracy_goal, slong prec) noexcept - # Computes the integral - # .. math :: - # I = \int_a^b f(t) dt - # where *f* is specified by (*func*, *param*), following a straight-line - # path between the complex numbers *a* and *b* which both must be finite. - # The integral is approximated by piecewise centered Taylor polynomials. - # Rigorous truncation error bounds are calculated using the Cauchy integral - # formula. More precisely, if the Taylor series of *f* centered at the point - # *m* is `f(m+x) = \sum_{n=0}^{\infty} a_n x^n`, then - # .. math :: - # \int f(m+x) = \left( \sum_{n=0}^{N-1} a_n \frac{x^{n+1}}{n+1} \right) - # + \left( \sum_{n=N}^{\infty} a_n \frac{x^{n+1}}{n+1} \right). - # For sufficiently small *x*, the second series converges and its - # absolute value is bounded by - # .. math :: - # \sum_{n=N}^{\infty} \frac{C(m,R)}{R^n} \frac{|x|^{n+1}}{N+1} - # = \frac{C(m,R) R x}{(R-x)(N+1)} \left( \frac{x}{R} \right)^N. - # It is required that any singularities of *f* are - # isolated from the path of integration by a distance strictly - # greater than the positive value *outer_radius* (which is the integration - # radius used for the Cauchy bound). Taylor series step lengths are - # chosen so as not to - # exceed *inner_radius*, which must be strictly smaller than *outer_radius* - # for convergence. A smaller *inner_radius* gives more rapid convergence - # of each Taylor series but means that more series might have to be used. - # A reasonable choice might be to set *inner_radius* to half the value of - # *outer_radius*, giving roughly one accurate bit per term. - # The truncation point of each Taylor series is chosen so that the absolute - # truncation error is roughly `2^{-p}` where *p* is given by *accuracy_goal* - # (in the future, this might change to a relative accuracy). - # Arithmetic operations and function - # evaluations are performed at a precision of *prec* bits. Note that due - # to accumulation of numerical errors, both values may have to be set - # higher (and the endpoints may have to be computed more accurately) - # to achieve a desired accuracy. - # This function chooses the evaluation points uniformly rather - # than implementing adaptive subdivision. diff --git a/src/sage/libs/flint/acb_dft.pxd b/src/sage/libs/flint/acb_dft.pxd index 7cee8b2291a..08542aabeca 100644 --- a/src/sage/libs/flint/acb_dft.pxd +++ b/src/sage/libs/flint/acb_dft.pxd @@ -2,7 +2,9 @@ # distutils: depends = flint/acb_dft.h ################################################################################ -# This file is auto-generated. Do not modify by hand +# This file is auto-generated by the script +# SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py. +# Do not modify by hand! Fix and rerun the script instead. ################################################################################ from libc.stdio cimport FILE @@ -11,71 +13,37 @@ from sage.libs.mpfr.types cimport * from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void acb_dft(acb_ptr w, acb_srcptr v, slong n, slong prec) noexcept - void acb_dft_inverse(acb_ptr w, acb_srcptr v, slong n, slong prec) noexcept - void acb_dft_precomp_init(acb_dft_pre_t pre, slong len, slong prec) noexcept - void acb_dft_precomp_clear(acb_dft_pre_t pre) noexcept - void acb_dft_precomp(acb_ptr w, acb_srcptr v, const acb_dft_pre_t pre, slong prec) noexcept - void acb_dft_inverse_precomp(acb_ptr w, acb_srcptr v, const acb_dft_pre_t pre, slong prec) noexcept - void acb_dirichlet_dft_prod(acb_ptr w, acb_srcptr v, slong * cyc, slong num, slong prec) noexcept - void acb_dft_prod_init(acb_dft_prod_t t, slong * cyc, slong num, slong prec) noexcept - void acb_dft_prod_clear(acb_dft_prod_t t) noexcept - void acb_dirichlet_dft_prod_precomp(acb_ptr w, acb_srcptr v, const acb_dft_prod_t prod, slong prec) noexcept - void acb_dft_convol_naive(acb_ptr w, acb_srcptr f, acb_srcptr g, slong len, slong prec) noexcept - void acb_dft_convol_rad2(acb_ptr w, acb_srcptr f, acb_srcptr g, slong len, slong prec) noexcept - void acb_dft_convol(acb_ptr w, acb_srcptr f, acb_srcptr g, slong len, slong prec) noexcept - void acb_dft_naive(acb_ptr w, acb_srcptr v, slong n, slong prec) noexcept - void acb_dft_naive_init(acb_dft_naive_t t, slong len, slong prec) noexcept - void acb_dft_naive_clear(acb_dft_naive_t t) noexcept - void acb_dft_naive_precomp(acb_ptr w, acb_srcptr v, const acb_dft_naive_t t, slong prec) noexcept - void acb_dft_crt(acb_ptr w, acb_srcptr v, slong n, slong prec) noexcept - void acb_dft_crt_init(acb_dft_crt_t t, slong len, slong prec) noexcept - void acb_dft_crt_clear(acb_dft_crt_t t) noexcept - void acb_dft_crt_precomp(acb_ptr w, acb_srcptr v, const acb_dft_crt_t t, slong prec) noexcept - void acb_dft_cyc(acb_ptr w, acb_srcptr v, slong n, slong prec) noexcept - void acb_dft_cyc_init(acb_dft_cyc_t t, slong len, slong prec) noexcept - void acb_dft_cyc_clear(acb_dft_cyc_t t) noexcept - void acb_dft_cyc_precomp(acb_ptr w, acb_srcptr v, const acb_dft_cyc_t t, slong prec) noexcept - void acb_dft_rad2(acb_ptr w, acb_srcptr v, int e, slong prec) noexcept - void acb_dft_inverse_rad2(acb_ptr w, acb_srcptr v, int e, slong prec) noexcept - void acb_dft_rad2_init(acb_dft_rad2_t t, int e, slong prec) noexcept - void acb_dft_rad2_clear(acb_dft_rad2_t t) noexcept - void acb_dft_rad2_precomp(acb_ptr w, acb_srcptr v, const acb_dft_rad2_t t, slong prec) noexcept - void acb_dft_bluestein(acb_ptr w, acb_srcptr v, slong n, slong prec) noexcept - void acb_dft_bluestein_init(acb_dft_bluestein_t t, slong len, slong prec) noexcept - void acb_dft_bluestein_clear(acb_dft_bluestein_t t) noexcept - void acb_dft_bluestein_precomp(acb_ptr w, acb_srcptr v, const acb_dft_bluestein_t t, slong prec) noexcept diff --git a/src/sage/libs/flint/acb_dirichlet.pxd b/src/sage/libs/flint/acb_dirichlet.pxd index 1b6f09dd74c..a76a8711c84 100644 --- a/src/sage/libs/flint/acb_dirichlet.pxd +++ b/src/sage/libs/flint/acb_dirichlet.pxd @@ -2,7 +2,9 @@ # distutils: depends = flint/acb_dirichlet.h ################################################################################ -# This file is auto-generated. Do not modify by hand +# This file is auto-generated by the script +# SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py. +# Do not modify by hand! Fix and rerun the script instead. ################################################################################ from libc.stdio cimport FILE @@ -11,511 +13,98 @@ from sage.libs.mpfr.types cimport * from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void acb_dirichlet_roots_init(acb_dirichlet_roots_t roots, ulong n, slong num, slong prec) noexcept - # Initializes *roots* with precomputed data for fast evaluation of roots of - # unity `e^{2\pi i k/n}` of a fixed order *n*. The precomputation is - # optimized for *num* evaluations. - # For very small *num*, only the single root `e^{2\pi i/n}` will be - # precomputed, which can then be raised to a power. For small *prec* - # and large *n*, this method might even skip precomputing this single root - # if it estimates that evaluating roots of unity from scratch will be faster - # than powering. - # If *num* is large enough, the whole set of roots in the first quadrant - # will be precomputed at once. However, this is automatically avoided for - # large *n* if too much memory would be used. For intermediate *num*, - # baby-step giant-step tables are computed. - void acb_dirichlet_roots_clear(acb_dirichlet_roots_t roots) noexcept - # Clears the structure. - void acb_dirichlet_root(acb_t res, const acb_dirichlet_roots_t roots, ulong k, slong prec) noexcept - # Computes `e^{2\pi i k/n}`. - void acb_dirichlet_powsum_term(acb_ptr res, arb_t log_prev, ulong * prev, const acb_t s, ulong k, int integer, int critical_line, slong len, slong prec) noexcept - # Sets *res* to `k^{-(s+x)}` as a power series in *x* truncated to length *len*. - # The flags *integer* and *critical_line* respectively specify optimizing - # for *s* being an integer or having real part 1/2. - # On input *log_prev* should contain the natural logarithm of the integer - # at *prev*. If *prev* is close to *k*, this can be used to speed up - # computations. If `\log(k)` is computed internally by this function, then - # *log_prev* is overwritten by this value, and the integer at *prev* is - # overwritten by *k*, allowing *log_prev* to be recycled for the next - # term when evaluating a power sum. - void acb_dirichlet_powsum_sieved(acb_ptr res, const acb_t s, ulong n, slong len, slong prec) noexcept - # Sets *res* to `\sum_{k=1}^n k^{-(s+x)}` - # as a power series in *x* truncated to length *len*. - # This function stores a table of powers that have already been calculated, - # computing `(ij)^r` as `i^r j^r` whenever `k = ij` is - # composite. As a further optimization, it groups all even `k` and - # evaluates the sum as a polynomial in `2^{-(s+x)}`. - # This scheme requires about `n / \log n` powers, `n / 2` multiplications, - # and temporary storage of `n / 6` power series. Due to the extra - # power series multiplications, it is only faster than the naive - # algorithm when *len* is small. - void acb_dirichlet_powsum_smooth(acb_ptr res, const acb_t s, ulong n, slong len, slong prec) noexcept - # Sets *res* to `\sum_{k=1}^n k^{-(s+x)}` - # as a power series in *x* truncated to length *len*. - # This function performs partial sieving by adding multiples of 5-smooth *k* - # into separate buckets. Asymptotically, this requires computing 4/15 - # of the powers, which is slower than *sieved*, but only requires - # logarithmic extra space. It is also faster for large *len*, since most - # power series multiplications are traded for additions. - # A slightly bigger gain for larger *n* could be achieved by using more - # small prime factors, at the expense of space. - void acb_dirichlet_zeta(acb_t res, const acb_t s, slong prec) noexcept - # Computes `\zeta(s)` using an automatic choice of algorithm. - void acb_dirichlet_zeta_jet(acb_t res, const acb_t s, int deflate, slong len, slong prec) noexcept - # Computes the first *len* terms of the Taylor series of the Riemann zeta - # function at *s*. If *deflate* is nonzero, computes the deflated - # function `\zeta(s) - 1/(s-1)` instead. - void acb_dirichlet_zeta_bound(mag_t res, const acb_t s) noexcept - # Computes an upper bound for `|\zeta(s)|` quickly. On the critical strip (and - # slightly outside of it), formula (43.3) in [Rad1973]_ is used. - # To the right, evaluating at the real part of *s* gives a trivial bound. - # To the left, the functional equation is used. - void acb_dirichlet_zeta_deriv_bound(mag_t der1, mag_t der2, const acb_t s) noexcept - # Sets *der1* to a bound for `|\zeta'(s)|` and *der2* to a bound for - # `|\zeta''(s)|`. These bounds are mainly intended for use in the critical - # strip and will not be tight. - void acb_dirichlet_eta(acb_t res, const acb_t s, slong prec) noexcept - # Sets *res* to the Dirichlet eta function - # `\eta(s) = \sum_{k=1}^{\infty} (-1)^{k+1} / k^s = (1-2^{1-s}) \zeta(s)`, - # also known as the alternating zeta function. - # Note that the alternating character `\{1,-1\}` is not itself - # a Dirichlet character. - void acb_dirichlet_xi(acb_t res, const acb_t s, slong prec) noexcept - # Sets *res* to the Riemann xi function - # `\xi(s) = \frac{1}{2} s (s-1) \pi^{-s/2} \Gamma(\frac{1}{2} s) \zeta(s)`. - # The functional equation for xi is `\xi(1-s) = \xi(s)`. - void acb_dirichlet_zeta_rs_f_coeffs(acb_ptr f, const arb_t p, slong n, slong prec) noexcept - # Computes the coefficients `F^{(j)}(p)` for `0 \le j < n`. - # Uses power series division. This method breaks down when `p = \pm 1/2` - # (which is not problem if *s* is an exact floating-point number). - void acb_dirichlet_zeta_rs_d_coeffs(arb_ptr d, const arb_t sigma, slong k, slong prec) noexcept - # Computes the coefficients `d_j^{(k)}` for `0 \le j \le \lfloor 3k/2 \rfloor + 1`. - # On input, the array *d* must contain the coefficients for `d_j^{(k-1)}` - # unless `k = 0`, and these coefficients will be updated in-place. - void acb_dirichlet_zeta_rs_bound(mag_t err, const acb_t s, slong K) noexcept - # Bounds the error term `RS_K` following Theorem 4.2 in Arias de Reyna. - void acb_dirichlet_zeta_rs_r(acb_t res, const acb_t s, slong K, slong prec) noexcept - # Computes `\mathcal{R}(s)` in the upper half plane. Uses precisely *K* - # asymptotic terms in the RS formula if this input parameter is positive; - # otherwise chooses the number of terms automatically based on *s* and the - # precision. - void acb_dirichlet_zeta_rs(acb_t res, const acb_t s, slong K, slong prec) noexcept - # Computes `\zeta(s)` using the Riemann-Siegel formula. Uses precisely - # *K* asymptotic terms in the RS formula if this input parameter is positive; - # otherwise chooses the number of terms automatically based on *s* and the - # precision. - void acb_dirichlet_zeta_jet_rs(acb_ptr res, const acb_t s, slong len, slong prec) noexcept - # Computes the first *len* terms of the Taylor series of the Riemann zeta - # function at *s* using the Riemann Siegel formula. This function currently - # only supports *len* = 1 or *len* = 2. A finite difference is used - # to compute the first derivative. - void acb_dirichlet_hurwitz(acb_t res, const acb_t s, const acb_t a, slong prec) noexcept - # Computes the Hurwitz zeta function `\zeta(s, a)`. - # This function automatically delegates to the code for the Riemann zeta function - # when `a = 1`. Some other special cases may also be handled by direct - # formulas. In general, Euler-Maclaurin summation is used. - void acb_dirichlet_hurwitz_precomp_init(acb_dirichlet_hurwitz_precomp_t pre, const acb_t s, int deflate, slong A, slong K, slong N, slong prec) noexcept - # Precomputes a grid of Taylor polynomials for fast evaluation of - # `\zeta(s,a)` on `a \in (0,1]` with fixed *s*. - # *A* is the initial shift to apply to *a*, *K* is the number of Taylor terms, - # *N* is the number of grid points. The precomputation requires *NK* - # evaluations of the Hurwitz zeta function, and each subsequent evaluation - # requires *2K* simple arithmetic operations (polynomial evaluation) plus - # *A* powers. As *K* grows, the error is at most `O(1/(2AN)^K)`. - # This function can be called with *A* set to zero, in which case - # no Taylor series precomputation is performed. This means that evaluation - # will be identical to calling :func:`acb_dirichlet_hurwitz` directly. - # Otherwise, we require that *A*, *K* and *N* are all positive. For a finite - # error bound, we require `K+\operatorname{re}(s) > 1`. - # To avoid an initial "bump" that steals precision - # and slows convergence, *AN* should be at least roughly as large as `|s|`, - # e.g. it is a good idea to have at least `AN > 0.5 |s|`. - # If *deflate* is set, the deflated Hurwitz zeta function is used, - # removing the pole at `s = 1`. - void acb_dirichlet_hurwitz_precomp_init_num(acb_dirichlet_hurwitz_precomp_t pre, const acb_t s, int deflate, double num_eval, slong prec) noexcept - # Initializes *pre*, choosing the parameters *A*, *K*, and *N* - # automatically to minimize the cost of *num_eval* evaluations of the - # Hurwitz zeta function at argument *s* to precision *prec*. - void acb_dirichlet_hurwitz_precomp_clear(acb_dirichlet_hurwitz_precomp_t pre) noexcept - # Clears the precomputed data. - void acb_dirichlet_hurwitz_precomp_choose_param(ulong * A, ulong * K, ulong * N, const acb_t s, double num_eval, slong prec) noexcept - # Chooses precomputation parameters *A*, *K* and *N* to minimize - # the cost of *num_eval* evaluations of the Hurwitz zeta function - # at argument *s* to precision *prec*. - # If it is estimated that evaluating each Hurwitz zeta function from - # scratch would be better than performing a precomputation, *A*, *K* and *N* - # are all set to 0. - void acb_dirichlet_hurwitz_precomp_bound(mag_t res, const acb_t s, slong A, slong K, slong N) noexcept - # Computes an upper bound for the truncation error (not accounting for - # roundoff error) when evaluating `\zeta(s,a)` with precomputation parameters - # *A*, *K*, *N*, assuming that `0 < a \le 1`. - # For details, see :ref:`algorithms_hurwitz`. - void acb_dirichlet_hurwitz_precomp_eval(acb_t res, const acb_dirichlet_hurwitz_precomp_t pre, ulong p, ulong q, slong prec) noexcept - # Evaluates `\zeta(s,p/q)` using precomputed data, assuming that `0 < p/q \le 1`. - void acb_dirichlet_lerch_phi_integral(acb_t res, const acb_t z, const acb_t s, const acb_t a, slong prec) noexcept void acb_dirichlet_lerch_phi_direct(acb_t res, const acb_t z, const acb_t s, const acb_t a, slong prec) noexcept void acb_dirichlet_lerch_phi(acb_t res, const acb_t z, const acb_t s, const acb_t a, slong prec) noexcept - # Computes the Lerch transcendent - # .. math :: - # \Phi(z,s,a) = \sum_{k=0}^{\infty} \frac{z^k}{(k+a)^s} - # which is analytically continued for `|z| \ge 1`. - # The *direct* version evaluates a truncation of the defining series. - # The *integral* version uses the Hankel contour integral - # .. math :: - # \Phi(z,s,a) = -\frac{\Gamma(1-s)}{2 \pi i} \int_C \frac{(-t)^{s-1} e^{-a t}}{1 - z e^{-t}} dt - # where the path is deformed as needed to avoid poles and branch - # cuts of the integrand. - # The default method chooses an algorithm automatically and also - # checks for some special cases where the function can be expressed - # in terms of simpler functions (Hurwitz zeta, polylogarithms). - void acb_dirichlet_stieltjes(acb_t res, const fmpz_t n, const acb_t a, slong prec) noexcept - # Given a nonnegative integer *n*, sets *res* to the generalized Stieltjes constant - # `\gamma_n(a)` which is the coefficient in the Laurent series of the - # Hurwitz zeta function at the pole - # .. math :: - # \zeta(s,a) = \frac{1}{s-1} + \sum_{n=0}^\infty \frac{(-1)^n}{n!} \gamma_n(a) (s-1)^n. - # With `a = 1`, this gives the ordinary Stieltjes constants for the - # Riemann zeta function. - # This function uses an integral representation to permit fast computation - # for extremely large *n* [JB2018]_. If *n* is moderate and the precision - # is high enough, it falls back to evaluating the Hurwitz zeta function - # of a power series and reading off the last coefficient. - # Note that for computing a range of values - # `\gamma_0(a), \ldots, \gamma_n(a)`, it is - # generally more efficient to evaluate the Hurwitz zeta function series - # expansion once at `s = 1` than to call this function repeatedly, - # unless *n* is extremely large (at least several hundred). - void acb_dirichlet_chi(acb_t res, const dirichlet_group_t G, const dirichlet_char_t chi, ulong n, slong prec) noexcept - # Sets *res* to `\chi(n)`, the value of the Dirichlet character *chi* - # at the integer *n*. - void acb_dirichlet_chi_vec(acb_ptr v, const dirichlet_group_t G, const dirichlet_char_t chi, slong nv, slong prec) noexcept - # Compute the *nv* first Dirichlet values. - void acb_dirichlet_pairing(acb_t res, const dirichlet_group_t G, ulong m, ulong n, slong prec) noexcept - void acb_dirichlet_pairing_char(acb_t res, const dirichlet_group_t G, const dirichlet_char_t a, const dirichlet_char_t b, slong prec) noexcept - # Sets *res* to the value of the Dirichlet pairing `\chi(m,n)` at numbers `m` and `n`. - # The second form takes two characters as input. - void acb_dirichlet_gauss_sum_naive(acb_t res, const dirichlet_group_t G, const dirichlet_char_t chi, slong prec) noexcept - void acb_dirichlet_gauss_sum_factor(acb_t res, const dirichlet_group_t G, const dirichlet_char_t chi, slong prec) noexcept - void acb_dirichlet_gauss_sum_order2(acb_t res, const dirichlet_group_t G, const dirichlet_char_t chi, slong prec) noexcept - void acb_dirichlet_gauss_sum_theta(acb_t res, const dirichlet_group_t G, const dirichlet_char_t chi, slong prec) noexcept - void acb_dirichlet_gauss_sum(acb_t res, const dirichlet_group_t G, const dirichlet_char_t chi, slong prec) noexcept - void acb_dirichlet_jacobi_sum_naive(acb_t res, const dirichlet_group_t G, const dirichlet_char_t chi1, const dirichlet_char_t chi2, slong prec) noexcept - void acb_dirichlet_jacobi_sum_factor(acb_t res, const dirichlet_group_t G, const dirichlet_char_t chi1, const dirichlet_char_t chi2, slong prec) noexcept - void acb_dirichlet_jacobi_sum_gauss(acb_t res, const dirichlet_group_t G, const dirichlet_char_t chi1, const dirichlet_char_t chi2, slong prec) noexcept - void acb_dirichlet_jacobi_sum(acb_t res, const dirichlet_group_t G, const dirichlet_char_t chi1, const dirichlet_char_t chi2, slong prec) noexcept - void acb_dirichlet_jacobi_sum_ui(acb_t res, const dirichlet_group_t G, ulong a, ulong b, slong prec) noexcept - void acb_dirichlet_chi_theta_arb(acb_t res, const dirichlet_group_t G, const dirichlet_char_t chi, const arb_t t, slong prec) noexcept - void acb_dirichlet_ui_theta_arb(acb_t res, const dirichlet_group_t G, ulong a, const arb_t t, slong prec) noexcept - # Compute the theta series `\Theta_q(a,t)` for real argument `t>0`. - # Beware that if `t<1` the functional equation - # .. math:: - # t \theta(a,t) = \epsilon(\chi) \theta\left(\frac1a, \frac1t\right) - # should be used, which is not done automatically (to avoid recomputing the - # Gauss sum). - # We call *theta series* of a Dirichlet character the quadratic series - # .. math:: - # \Theta_q(a) = \sum_{n\geq 0} \chi_q(a, n) n^p x^{n^2} - # where `p` is the parity of the character `\chi_q(a,\cdot)`. - # For `\Re(t)>0` we write `x(t)=\exp(-\frac{\pi}{N}t^2)` and define - # .. math:: - # \Theta_q(a,t) = \sum_{n\geq 0} \chi_q(a, n) x(t)^{n^2}. - ulong acb_dirichlet_theta_length(ulong q, const arb_t t, slong prec) noexcept - void acb_dirichlet_qseries_arb_powers_naive(acb_t res, const arb_t x, int p, const ulong * a, const acb_dirichlet_roots_t z, slong len, slong prec) noexcept - void acb_dirichlet_qseries_arb_powers_smallorder(acb_t res, const arb_t x, int p, const ulong * a, const acb_dirichlet_roots_t z, slong len, slong prec) noexcept - void acb_dirichlet_dft_conrey(acb_ptr w, acb_srcptr v, const dirichlet_group_t G, slong prec) noexcept - void acb_dirichlet_dft(acb_ptr w, acb_srcptr v, const dirichlet_group_t G, slong prec) noexcept - void acb_dirichlet_root_number_theta(acb_t res, const dirichlet_group_t G, const dirichlet_char_t chi, slong prec) noexcept - void acb_dirichlet_root_number(acb_t res, const dirichlet_group_t G, const dirichlet_char_t chi, slong prec) noexcept - void acb_dirichlet_l_hurwitz(acb_t res, const acb_t s, const acb_dirichlet_hurwitz_precomp_t precomp, const dirichlet_group_t G, const dirichlet_char_t chi, slong prec) noexcept - # Computes `L(s,\chi)` using decomposition in terms of the Hurwitz zeta function - # .. math:: - # L(s,\chi) = q^{-s}\sum_{k=1}^q \chi(k) \,\zeta\!\left(s,\frac kq\right). - # If `s = 1` and `\chi` is non-principal, the deflated Hurwitz zeta function - # is used to avoid poles. - # If *precomp* is *NULL*, each Hurwitz zeta function value is computed - # directly. If a pre-initialized *precomp* object is provided, this will be - # used instead to evaluate the Hurwitz zeta function. - void acb_dirichlet_l_euler_product(acb_t res, const acb_t s, const dirichlet_group_t G, const dirichlet_char_t chi, slong prec) noexcept - void _acb_dirichlet_euler_product_real_ui(arb_t res, ulong s, const signed char * chi, int mod, int reciprocal, slong prec) noexcept - # Computes `L(s,\chi)` directly using the Euler product. This is - # efficient if *s* has large positive real part. As implemented, this - # function only gives a finite result if `\operatorname{re}(s) \ge 2`. - # An error bound is computed via :func:`mag_hurwitz_zeta_uiui`. - # If *s* is complex, replace it with its real part. Since - # .. math :: - # \frac{1}{L(s,\chi)} = \prod_{p} \left(1 - \frac{\chi(p)}{p^s}\right) - # = \sum_{k=1}^{\infty} \frac{\mu(k)\chi(k)}{k^s} - # and the truncated product gives all smooth-index terms in the series, we have - # .. math :: - # \left|\prod_{p < N} \left(1 - \frac{\chi(p)}{p^s}\right) - \frac{1}{L(s,\chi)}\right| - # \le \sum_{k=N}^{\infty} \frac{1}{k^s} = \zeta(s,N). - # The underscore version specialized for integer *s* assumes that `\chi` is - # a real Dirichlet character given by the explicit list *chi* of character - # values at 0, 1, ..., *mod* - 1. If *reciprocal* is set, it computes - # `1 / L(s,\chi)` (this is faster if the reciprocal can be used directly). - void acb_dirichlet_l(acb_t res, const acb_t s, const dirichlet_group_t G, const dirichlet_char_t chi, slong prec) noexcept - # Computes `L(s,\chi)` using a default choice of algorithm. - void acb_dirichlet_l_fmpq(acb_t res, const fmpq_t s, const dirichlet_group_t G, const dirichlet_char_t chi, slong prec) noexcept void acb_dirichlet_l_fmpq_afe(acb_t res, const fmpq_t s, const dirichlet_group_t G, const dirichlet_char_t chi, slong prec) noexcept - # Computes `L(s,\chi)` where *s* is a rational number. - # The *afe* version uses the approximate functional equation; - # the default version chooses an algorithm automatically. - void acb_dirichlet_l_vec_hurwitz(acb_ptr res, const acb_t s, const acb_dirichlet_hurwitz_precomp_t precomp, const dirichlet_group_t G, slong prec) noexcept - # Compute all values `L(s,\chi)` for `\chi` mod `q`, using the - # Hurwitz zeta function and a discrete Fourier transform. - # The output *res* is assumed to have length *G->phi_q* and values - # are stored by lexicographically ordered - # Conrey logs. See :func:`acb_dirichlet_dft_conrey`. - # If *precomp* is *NULL*, each Hurwitz zeta function value is computed - # directly. If a pre-initialized *precomp* object is provided, this will be - # used instead to evaluate the Hurwitz zeta function. - void acb_dirichlet_l_jet(acb_ptr res, const acb_t s, const dirichlet_group_t G, const dirichlet_char_t chi, int deflate, slong len, slong prec) noexcept - # Computes the Taylor expansion of `L(s,\chi)` to length *len*, - # i.e. `L(s), L'(s), \ldots, L^{(len-1)}(s) / (len-1)!`. - # If *deflate* is set, computes the expansion of - # .. math :: - # L(s,\chi) - \frac{\sum_{k=1}^q \chi(k)}{(s-1)q} - # instead. If *chi* is a principal character, then this has the effect of - # subtracting the pole with residue `\sum_{k=1}^q \chi(k) = \phi(q) / q` - # that is located at `s = 1`. In particular, when evaluated at `s = 1`, this - # gives the regular part of the Laurent expansion. - # When *chi* is non-principal, *deflate* has no effect. - void _acb_dirichlet_l_series(acb_ptr res, acb_srcptr s, slong slen, const dirichlet_group_t G, const dirichlet_char_t chi, int deflate, slong len, slong prec) noexcept - void acb_dirichlet_l_series(acb_poly_t res, const acb_poly_t s, const dirichlet_group_t G, const dirichlet_char_t chi, int deflate, slong len, slong prec) noexcept - # Sets *res* to the power series `L(s,\chi)` where *s* is a given power series, truncating the result to length *len*. - # See :func:`acb_dirichlet_l_jet` for the meaning of the *deflate* flag. - void acb_dirichlet_hardy_theta(acb_ptr res, const acb_t t, const dirichlet_group_t G, const dirichlet_char_t chi, slong len, slong prec) noexcept - # Computes the phase function used to construct the Z-function. - # We have - # .. math :: - # \theta(t) = -\frac{t}{2} \log(\pi/q) - \frac{i \log(\epsilon)}{2} - # + \frac{\log \Gamma((s+\delta)/2) - \log \Gamma((1-s+\delta)/2)}{2i} - # where `s = 1/2+it`, `\delta` is the parity of *chi*, and `\epsilon` - # is the root number as computed by :func:`acb_dirichlet_root_number`. - # The first *len* terms in the Taylor expansion are written to the output. - void acb_dirichlet_hardy_z(acb_ptr res, const acb_t t, const dirichlet_group_t G, const dirichlet_char_t chi, slong len, slong prec) noexcept - # Computes the Hardy Z-function, also known as the Riemann-Siegel Z-function - # `Z(t) = e^{i \theta(t)} L(1/2+it)`, which is real-valued for real *t*. - # The first *len* terms in the Taylor expansion are written to the output. - void _acb_dirichlet_hardy_theta_series(acb_ptr res, acb_srcptr t, slong tlen, const dirichlet_group_t G, const dirichlet_char_t chi, slong len, slong prec) noexcept - void acb_dirichlet_hardy_theta_series(acb_poly_t res, const acb_poly_t t, const dirichlet_group_t G, const dirichlet_char_t chi, slong len, slong prec) noexcept - # Sets *res* to the power series `\theta(t)` where *t* is a given power series, truncating the result to length *len*. - void _acb_dirichlet_hardy_z_series(acb_ptr res, acb_srcptr t, slong tlen, const dirichlet_group_t G, const dirichlet_char_t chi, slong len, slong prec) noexcept - void acb_dirichlet_hardy_z_series(acb_poly_t res, const acb_poly_t t, const dirichlet_group_t G, const dirichlet_char_t chi, slong len, slong prec) noexcept - # Sets *res* to the power series `Z(t)` where *t* is a given power series, truncating the result to length *len*. - void acb_dirichlet_gram_point(arb_t res, const fmpz_t n, const dirichlet_group_t G, const dirichlet_char_t chi, slong prec) noexcept - # Sets *res* to the *n*-th Gram point `g_n`, defined as the unique solution - # in `[7, \infty)` of `\theta(g_n) = \pi n`. Currently only the Gram points - # corresponding to the Riemann zeta function are supported and *G* and *chi* - # must both be set to *NULL*. Requires `n \ge -1`. - ulong acb_dirichlet_turing_method_bound(const fmpz_t p) noexcept - # Computes an upper bound *B* for the minimum number of consecutive good - # Gram blocks sufficient to count nontrivial zeros of the Riemann zeta - # function using Turing's method [Tur1953]_ as updated by [Leh1970]_, - # [Bre1979]_, and [Tru2011]_. - # Let `N(T)` denote the number of zeros (counted according to their - # multiplicities) of `\zeta(s)` in the region `0 < \operatorname{Im}(s) \le T`. - # If at least *B* consecutive Gram blocks with union `[g_n, g_p)` - # satisfy Rosser's rule, then `N(g_n) \le n + 1` and `N(g_p) \ge p + 1`. - int _acb_dirichlet_definite_hardy_z(arb_t res, const arf_t t, slong * pprec) noexcept - # Sets *res* to the Hardy Z-function `Z(t)`. - # The initial precision (* *pprec*) is increased as necessary - # to determine the sign of `Z(t)`. The sign is returned. - void _acb_dirichlet_isolate_gram_hardy_z_zero(arf_t a, arf_t b, const fmpz_t n) noexcept - # Uses Gram's law to compute an interval `(a, b)` that - # contains the *n*-th zero of the Hardy Z-function and no other zero. - # Requires `1 \le n \le 126`. - void _acb_dirichlet_isolate_rosser_hardy_z_zero(arf_t a, arf_t b, const fmpz_t n) noexcept - # Uses Rosser's rule to compute an interval `(a, b)` that - # contains the *n*-th zero of the Hardy Z-function and no other zero. - # Requires `1 \le n \le 13999526`. - void _acb_dirichlet_isolate_turing_hardy_z_zero(arf_t a, arf_t b, const fmpz_t n) noexcept - # Computes an interval `(a, b)` that contains the *n*-th zero of the - # Hardy Z-function and no other zero, following Turing's method. - # Requires `n \ge 2`. - void acb_dirichlet_isolate_hardy_z_zero(arf_t a, arf_t b, const fmpz_t n) noexcept - # Computes an interval `(a, b)` that contains the *n*-th zero of the - # Hardy Z-function and contains no other zero, using the most appropriate - # underscore version of this function. Requires `n \ge 1`. - void _acb_dirichlet_refine_hardy_z_zero(arb_t res, const arf_t a, const arf_t b, slong prec) noexcept - # Sets *res* to the unique zero of the Hardy Z-function in the - # interval `(a, b)`. - void acb_dirichlet_hardy_z_zero(arb_t res, const fmpz_t n, slong prec) noexcept - # Sets *res* to the *n*-th zero of the Hardy Z-function, requiring `n \ge 1`. - void acb_dirichlet_hardy_z_zeros(arb_ptr res, const fmpz_t n, slong len, slong prec) noexcept - # Sets the entries of *res* to *len* consecutive zeros of the - # Hardy Z-function, beginning with the *n*-th zero. Requires positive *n*. - void acb_dirichlet_zeta_zero(acb_t res, const fmpz_t n, slong prec) noexcept - # Sets *res* to the *n*-th nontrivial zero of `\zeta(s)`, requiring `n \ge 1`. - void acb_dirichlet_zeta_zeros(acb_ptr res, const fmpz_t n, slong len, slong prec) noexcept - # Sets the entries of *res* to *len* consecutive nontrivial zeros of `\zeta(s)` - # beginning with the *n*-th zero. Requires positive *n*. - void _acb_dirichlet_exact_zeta_nzeros(fmpz_t res, const arf_t t) noexcept - void acb_dirichlet_zeta_nzeros(arb_t res, const arb_t t, slong prec) noexcept - # Compute the number of zeros (counted according to their multiplicities) - # of `\zeta(s)` in the region `0 < \operatorname{Im}(s) \le t`. - void acb_dirichlet_backlund_s(arb_t res, const arb_t t, slong prec) noexcept - # Compute `S(t) = \frac{1}{\pi}\operatorname{arg}\zeta(\frac{1}{2} + it)` - # where the argument is defined by continuous variation of `s` in `\zeta(s)` - # starting at `s = 2`, then vertically to `s = 2 + it`, then horizontally - # to `s = \frac{1}{2} + it`. In particular `\operatorname{arg}` in this - # context is not the principal value of the argument, and it cannot be - # computed directly by :func:`acb_arg`. In practice `S(t)` is computed as - # `S(t) = N(t) - \frac{1}{\pi}\theta(t) - 1` where `N(t)` is - # :func:`acb_dirichlet_zeta_nzeros` and `\theta(t)` is - # :func:`acb_dirichlet_hardy_theta`. - void acb_dirichlet_backlund_s_bound(mag_t res, const arb_t t) noexcept - # Compute an upper bound for `|S(t)|` quickly. Theorem 1 - # and the bounds in (1.2) in [Tru2014]_ are used. - void acb_dirichlet_zeta_nzeros_gram(fmpz_t res, const fmpz_t n) noexcept - # Compute `N(g_n)`. That is, compute the number of zeros (counted according - # to their multiplicities) of `\zeta(s)` in the region - # `0 < \operatorname{Im}(s) \le g_n` where `g_n` is the *n*-th Gram point. - # Requires `n \ge -1`. - slong acb_dirichlet_backlund_s_gram(const fmpz_t n) noexcept - # Compute `S(g_n)` where `g_n` is the *n*-th Gram point. Requires `n \ge -1`. - void acb_dirichlet_platt_scaled_lambda(arb_t res, const arb_t t, slong prec) noexcept - # Compute `\Lambda(t) e^{\pi t/4}` where - # .. math :: - # \Lambda(t) = \pi^{-\frac{it}{2}} - # \Gamma\left(\frac{\frac{1}{2}+it}{2}\right) - # \zeta\left(\frac{1}{2} + it\right) - # is defined in the beginning of section 3 of [Pla2017]_. As explained in - # [Pla2011]_ this function has the same zeros as `\zeta(1/2 + it)` and is - # real-valued by the functional equation, and the exponential factor is - # designed to counteract the decay of the gamma factor as `t` increases. - void acb_dirichlet_platt_scaled_lambda_vec(arb_ptr res, const fmpz_t T, slong A, slong B, slong prec) noexcept - void acb_dirichlet_platt_multieval(arb_ptr res, const fmpz_t T, slong A, slong B, const arb_t h, const fmpz_t J, slong K, slong sigma, slong prec) noexcept - void acb_dirichlet_platt_multieval_threaded(arb_ptr res, const fmpz_t T, slong A, slong B, const arb_t h, const fmpz_t J, slong K, slong sigma, slong prec) noexcept - # Compute :func:`acb_dirichlet_platt_scaled_lambda` at `N=AB` points on a - # grid, following the notation of [Pla2017]_. The first point on the grid - # is `T - B/2` and the distance between grid points is `1/A`. The product - # `N=AB` must be an even integer. The multieval versions evaluate the - # function at all points on the grid simultaneously using discrete Fourier - # transforms, and they require the four additional tuning parameters - # *h*, *J*, *K*, and *sigma*. The *threaded* multieval version splits the - # computation over the number of threads returned by - # *flint_get_num_threads()*, while the default multieval version chooses - # whether to use multithreading automatically. - void acb_dirichlet_platt_ws_interpolation(arb_t res, arf_t deriv, const arb_t t0, arb_srcptr p, const fmpz_t T, slong A, slong B, slong Ns_max, const arb_t H, slong sigma, slong prec) noexcept - # Compute :func:`acb_dirichlet_platt_scaled_lambda` at *t0* by - # Gaussian-windowed Whittaker-Shannon interpolation of points evaluated by - # :func:`acb_dirichlet_platt_scaled_lambda_vec`. The derivative is - # also approximated if the output parameter *deriv* is not *NULL*. - # *Ns_max* defines the maximum number of supporting points to be used in - # the interpolation on either side of *t0*. *H* is the standard deviation - # of the Gaussian window centered on *t0* to be applied before the - # interpolation. *sigma* is an odd positive integer tuning parameter - # `\sigma \in 2\mathbb{Z}_{>0}+1` used in computing error bounds. - slong _acb_dirichlet_platt_local_hardy_z_zeros(arb_ptr res, const fmpz_t n, slong len, const fmpz_t T, slong A, slong B, const arb_t h, const fmpz_t J, slong K, slong sigma_grid, slong Ns_max, const arb_t H, slong sigma_interp, slong prec) noexcept - slong acb_dirichlet_platt_local_hardy_z_zeros(arb_ptr res, const fmpz_t n, slong len, slong prec) noexcept - slong acb_dirichlet_platt_hardy_z_zeros(arb_ptr res, const fmpz_t n, slong len, slong prec) noexcept - # Sets at most the first *len* entries of *res* to consecutive - # zeros of the Hardy Z-function starting with the *n*-th zero. - # The number of obtained consecutive zeros is returned. The first two - # function variants each make a single call to Platt's grid evaluation - # of the scaled Lambda function, whereas the third variant performs as many - # evaluations as necessary to obtain *len* consecutive zeros. - # The final several parameters of the underscored local variant have the same - # meanings as in the functions :func:`acb_dirichlet_platt_multieval` - # and :func:`acb_dirichlet_platt_ws_interpolation`. The non-underscored - # variants currently expect `10^4 \leq n \leq 10^{23}`. The user has the - # option of multi-threading through *flint_set_num_threads(numthreads)*. - slong acb_dirichlet_platt_zeta_zeros(acb_ptr res, const fmpz_t n, slong len, slong prec) noexcept - # Sets at most the first *len* entries of *res* to consecutive - # zeros of the Riemann zeta function starting with the *n*-th zero. - # The number of obtained consecutive zeros is returned. It currently - # expects `10^4 \leq n \leq 10^{23}`. The user has the option of - # multi-threading through *flint_set_num_threads(numthreads)*. diff --git a/src/sage/libs/flint/acb_elliptic.pxd b/src/sage/libs/flint/acb_elliptic.pxd index 8fe3b2b571c..cfeb04feaf3 100644 --- a/src/sage/libs/flint/acb_elliptic.pxd +++ b/src/sage/libs/flint/acb_elliptic.pxd @@ -2,7 +2,9 @@ # distutils: depends = flint/acb_elliptic.h ################################################################################ -# This file is auto-generated. Do not modify by hand +# This file is auto-generated by the script +# SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py. +# Do not modify by hand! Fix and rerun the script instead. ################################################################################ from libc.stdio cimport FILE @@ -11,234 +13,28 @@ from sage.libs.mpfr.types cimport * from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void acb_elliptic_k(acb_t res, const acb_t m, slong prec) noexcept - # Computes the complete elliptic integral of the first kind - # .. math :: - # K(m) = \int_0^{\pi/2} \frac{dt}{\sqrt{1-m \sin^2 t}} - # = \int_0^1 - # \frac{dt}{\left(\sqrt{1-t^2}\right)\left(\sqrt{1-mt^2}\right)} - # using the arithmetic-geometric mean: `K(m) = \pi / (2 M(\sqrt{1-m}))`. - void acb_elliptic_k_jet(acb_ptr res, const acb_t m, slong len, slong prec) noexcept - # Sets the coefficients in the array *res* to the power series expansion of the - # complete elliptic integral of the first kind at the point *m* truncated to - # length *len*, i.e. `K(m+x) \in \mathbb{C}[[x]]`. - void _acb_elliptic_k_series(acb_ptr res, acb_srcptr m, slong mlen, slong len, slong prec) noexcept - void acb_elliptic_k_series(acb_poly_t res, const acb_poly_t m, slong len, slong prec) noexcept - # Sets *res* to the complete elliptic integral of the first kind of the - # power series *m*, truncated to length *len*. - void acb_elliptic_e(acb_t res, const acb_t m, slong prec) noexcept - # Computes the complete elliptic integral of the second kind - # .. math :: - # E(m) = \int_0^{\pi/2} \sqrt{1-m \sin^2 t} \, dt = - # \int_0^1 - # \frac{\sqrt{1-mt^2}}{\sqrt{1-t^2}} \, dt - # using `E(m) = (1-m)(2m K'(m) + K(m))` (where the prime - # denotes a derivative, not a complementary integral). - void acb_elliptic_pi(acb_t res, const acb_t n, const acb_t m, slong prec) noexcept - # Evaluates the complete elliptic integral of the third kind - # .. math :: - # \Pi(n, m) = \int_0^{\pi/2} - # \frac{dt}{(1-n \sin^2 t) \sqrt{1-m \sin^2 t}} = - # \int_0^1 - # \frac{dt}{(1-nt^2) \sqrt{1-t^2} \sqrt{1-mt^2}}. - # This implementation currently uses the same algorithm as the corresponding - # incomplete integral. It is therefore less efficient than the implementations - # of the first two complete elliptic integrals which use the AGM. - void acb_elliptic_f(acb_t res, const acb_t phi, const acb_t m, int pi, slong prec) noexcept - # Evaluates the Legendre incomplete elliptic integral of the first kind, - # given by - # .. math :: - # F(\phi,m) = \int_0^{\phi} \frac{dt}{\sqrt{1-m \sin^2 t}} - # = \int_0^{\sin \phi} - # \frac{dt}{\left(\sqrt{1-t^2}\right)\left(\sqrt{1-mt^2}\right)} - # on the standard strip `-\pi/2 \le \operatorname{Re}(\phi) \le \pi/2`. - # Outside this strip, the function extends quasiperiodically as - # .. math :: - # F(\phi + n \pi, m) = 2 n K(m) + F(\phi,m), n \in \mathbb{Z}. - # Inside the standard strip, the function is computed via - # the symmetric integral `R_F`. - # If the flag *pi* is set to 1, the variable `\phi` is replaced by - # `\pi \phi`, changing the quasiperiod to 1. - # The function reduces to a complete elliptic integral of the first kind - # when `\phi = \frac{\pi}{2}`; that is, - # `F\left(\frac{\pi}{2}, m\right) = K(m)`. - void acb_elliptic_e_inc(acb_t res, const acb_t phi, const acb_t m, int pi, slong prec) noexcept - # Evaluates the Legendre incomplete elliptic integral of the second kind, - # given by - # .. math :: - # E(\phi,m) = \int_0^{\phi} \sqrt{1-m \sin^2 t} \, dt = - # \int_0^{\sin \phi} - # \frac{\sqrt{1-mt^2}}{\sqrt{1-t^2}} \, dt - # on the standard strip `-\pi/2 \le \operatorname{Re}(\phi) \le \pi/2`. - # Outside this strip, the function extends quasiperiodically as - # .. math :: - # E(\phi + n \pi, m) = 2 n E(m) + E(\phi,m), n \in \mathbb{Z}. - # Inside the standard strip, the function is computed via - # the symmetric integrals `R_F` and `R_D`. - # If the flag *pi* is set to 1, the variable `\phi` is replaced by - # `\pi \phi`, changing the quasiperiod to 1. - # The function reduces to a complete elliptic integral of the second kind - # when `\phi = \frac{\pi}{2}`; that is, - # `E\left(\frac{\pi}{2}, m\right) = E(m)`. - void acb_elliptic_pi_inc(acb_t res, const acb_t n, const acb_t phi, const acb_t m, int pi, slong prec) noexcept - # Evaluates the Legendre incomplete elliptic integral of the third kind, - # given by - # .. math :: - # \Pi(n, \phi, m) = \int_0^{\phi} - # \frac{dt}{(1-n \sin^2 t) \sqrt{1-m \sin^2 t}} = - # \int_0^{\sin \phi} - # \frac{dt}{(1-nt^2) \sqrt{1-t^2} \sqrt{1-mt^2}} - # on the standard strip `-\pi/2 \le \operatorname{Re}(\phi) \le \pi/2`. - # Outside this strip, the function extends quasiperiodically as - # .. math :: - # \Pi(n, \phi + k \pi, m) = 2 k \Pi(n,m) + \Pi(n,\phi,m), k \in \mathbb{Z}. - # Inside the standard strip, the function is computed via - # the symmetric integrals `R_F` and `R_J`. - # If the flag *pi* is set to 1, the variable `\phi` is replaced by - # `\pi \phi`, changing the quasiperiod to 1. - # The function reduces to a complete elliptic integral of the third kind - # when `\phi = \frac{\pi}{2}`; that is, - # `\Pi\left(n, \frac{\pi}{2}, m\right) = \Pi(n, m)`. - void acb_elliptic_rf(acb_t res, const acb_t x, const acb_t y, const acb_t z, int flags, slong prec) noexcept - # Evaluates the Carlson symmetric elliptic integral of the first kind - # .. math :: - # R_F(x,y,z) = \frac{1}{2} - # \int_0^{\infty} \frac{dt}{\sqrt{(t+x)(t+y)(t+z)}} - # where the square root extends continuously from positive infinity. - # The integral is well-defined for `x,y,z \notin (-\infty,0)`, and with - # at most one of `x,y,z` being zero. - # When some parameters are negative real numbers, the function is - # still defined by analytic continuation. - # In general, one or more duplication steps are applied until - # `x,y,z` are close enough to use a multivariate Taylor series. - # The special case `R_C(x, y) = R_F(x, y, y) = \frac{1}{2} \int_0^{\infty} (t+x)^{-1/2} (t+y)^{-1} dt` - # may be computed by - # setting *y* and *z* to the same variable. - # (This case is not yet handled specially, but might be optimized in - # the future.) - # The *flags* parameter is reserved for future use and currently - # does nothing. Passing 0 results in default behavior. - void acb_elliptic_rg(acb_t res, const acb_t x, const acb_t y, const acb_t z, int flags, slong prec) noexcept - # Evaluates the Carlson symmetric elliptic integral of the second kind - # .. math :: - # R_G(x,y,z) = \frac{1}{4} \int_0^{\infty} - # \frac{t}{\sqrt{(t+x)(t+y)(t+z)}} - # \left( \frac{x}{t+x} + \frac{y}{t+y} + \frac{z}{t+z}\right) dt - # where the square root is taken continuously as in `R_F`. - # The evaluation is done by expressing `R_G` in terms of `R_F` and `R_D`. - # There are no restrictions on the variables. - void acb_elliptic_rj(acb_t res, const acb_t x, const acb_t y, const acb_t z, const acb_t p, int flags, slong prec) noexcept - void acb_elliptic_rj_carlson(acb_t res, const acb_t x, const acb_t y, const acb_t z, const acb_t p, int flags, slong prec) noexcept - void acb_elliptic_rj_integration(acb_t res, const acb_t x, const acb_t y, const acb_t z, const acb_t p, int flags, slong prec) noexcept - # Evaluates the Carlson symmetric elliptic integral of the third kind - # .. math :: - # R_J(x,y,z,p) = \frac{3}{2} - # \int_0^{\infty} \frac{dt}{(t+p)\sqrt{(t+x)(t+y)(t+z)}} - # where the square root is taken continuously as in `R_F`. - # Three versions of this function are available: the *carlson* version - # applies one or more duplication steps until `x,y,z,p` are close enough - # to use a multivariate Taylor series. - # The duplication algorithm is not correct for all possible - # combinations of complex variables, since the square roots taken - # during the computation can introduce spurious branch cuts. - # According to [Car1995]_, a sufficient (but not necessary) condition - # for correctness is that *x*, *y*, *z* have nonnegative - # real part and that *p* has positive real part. - # In other cases, the algorithm *might* still be correct, but no attempt - # is made to check this; it is up to the user to verify that - # the duplication algorithm is appropriate for the given parameters - # before calling this function. - # The *integration* algorithm uses explicit numerical integration to - # translate the parameters to the right half-plane. This is reliable - # but can be slow. - # The default method uses the *carlson* algorithm when it is certain - # to be correct, and otherwise falls back to the slow *integration* - # algorithm. - # The special case `R_D(x, y, z) = R_J(x, y, z, z)` - # may be computed by setting *z* and *p* to the same variable. - # This case is handled specially to avoid redundant arithmetic operations. - # In this case, the *carlson* algorithm is correct for all *x*, *y* and *z*. - # The *flags* parameter is reserved for future use and currently - # does nothing. Passing 0 results in default behavior. - void acb_elliptic_rc1(acb_t res, const acb_t x, slong prec) noexcept - # This helper function computes the special case - # `R_C(1, 1+x) = \operatorname{atan}(\sqrt{x})/\sqrt{x} = {}_2F_1(1,1/2,3/2,-x)`, - # which is needed in the evaluation of `R_J`. - void acb_elliptic_p(acb_t res, const acb_t z, const acb_t tau, slong prec) noexcept - # Computes Weierstrass's elliptic function - # .. math :: - # \wp(z, \tau) = \frac{1}{z^2} + \sum_{n^2+m^2 \ne 0} - # \left[ \frac{1}{(z+m+n\tau)^2} - \frac{1}{(m+n\tau)^2} \right] - # which satisfies `\wp(z, \tau) = \wp(z + 1, \tau) = \wp(z + \tau, \tau)`. - # To evaluate the function efficiently, we use the formula - # .. math :: - # \wp(z, \tau) = \pi^2 \theta_2^2(0,\tau) \theta_3^2(0,\tau) - # \frac{\theta_4^2(z,\tau)}{\theta_1^2(z,\tau)} - - # \frac{\pi^2}{3} \left[ \theta_2^4(0,\tau) + \theta_3^4(0,\tau)\right]. - void acb_elliptic_p_prime(acb_t res, const acb_t z, const acb_t tau, slong prec) noexcept - # Computes the derivative `\wp'(z, \tau)` of Weierstrass's elliptic function `\wp(z, \tau)`. - void acb_elliptic_p_jet(acb_ptr res, const acb_t z, const acb_t tau, slong len, slong prec) noexcept - # Computes the formal power series `\wp(z + x, \tau) \in \mathbb{C}[[x]]`, - # truncated to length *len*. In particular, with *len* = 2, simultaneously - # computes `\wp(z, \tau), \wp'(z, \tau)` which together generate - # the field of elliptic functions with periods 1 and `\tau`. - void _acb_elliptic_p_series(acb_ptr res, acb_srcptr z, slong zlen, const acb_t tau, slong len, slong prec) noexcept - void acb_elliptic_p_series(acb_poly_t res, const acb_poly_t z, const acb_t tau, slong len, slong prec) noexcept - # Sets *res* to the Weierstrass elliptic function of the power series *z*, - # with periods 1 and *tau*, truncated to length *len*. - void acb_elliptic_invariants(acb_t g2, acb_t g3, const acb_t tau, slong prec) noexcept - # Computes the lattice invariants `g_2, g_3`. The Weierstrass elliptic - # function satisfies the differential equation - # `[\wp'(z, \tau)]^2 = 4 [\wp(z,\tau)]^3 - g_2 \wp(z,\tau) - g_3`. - # Up to constant factors, the lattice invariants are the first two - # Eisenstein series (see :func:`acb_modular_eisenstein`). - void acb_elliptic_roots(acb_t e1, acb_t e2, acb_t e3, const acb_t tau, slong prec) noexcept - # Computes the lattice roots `e_1, e_2, e_3`, which are the roots of - # the polynomial `4z^3 - g_2 z - g_3`. - void acb_elliptic_inv_p(acb_t res, const acb_t z, const acb_t tau, slong prec) noexcept - # Computes the inverse of the Weierstrass elliptic function, which - # satisfies `\wp(\wp^{-1}(z, \tau), \tau) = z`. This function is given - # by the elliptic integral - # .. math :: - # \wp^{-1}(z, \tau) = \frac{1}{2} \int_z^{\infty} \frac{dt}{\sqrt{(t-e_1)(t-e_2)(t-e_3)}} - # = R_F(z-e_1,z-e_2,z-e_3). - void acb_elliptic_zeta(acb_t res, const acb_t z, const acb_t tau, slong prec) noexcept - # Computes the Weierstrass zeta function - # .. math :: - # \zeta(z, \tau) = \frac{1}{z} + \sum_{n^2+m^2 \ne 0} - # \left[ \frac{1}{z-m-n\tau} + \frac{1}{m+n\tau} + \frac{z}{(m+n\tau)^2} \right] - # which is quasiperiodic with `\zeta(z + 1, \tau) = \zeta(z, \tau) + \zeta(1/2, \tau)` - # and `\zeta(z + \tau, \tau) = \zeta(z, \tau) + \zeta(\tau/2, \tau)`. - void acb_elliptic_sigma(acb_t res, const acb_t z, const acb_t tau, slong prec) noexcept - # Computes the Weierstrass sigma function - # .. math :: - # \sigma(z, \tau) = z \prod_{n^2+m^2 \ne 0} - # \left[ \left(1-\frac{z}{m+n\tau}\right) - # \exp\left(\frac{z}{m+n\tau} + \frac{z^2}{2(m+n\tau)^2} \right) \right] - # which is quasiperiodic with `\sigma(z + 1, \tau) = -e^{2 \zeta(1/2, \tau) (z+1/2)} \sigma(z, \tau)` - # and `\sigma(z + \tau, \tau) = -e^{2 \zeta(\tau/2, \tau) (z+\tau/2)} \sigma(z, \tau)`. diff --git a/src/sage/libs/flint/acb_hypgeom.pxd b/src/sage/libs/flint/acb_hypgeom.pxd index b1498db6015..4b8d8664e87 100644 --- a/src/sage/libs/flint/acb_hypgeom.pxd +++ b/src/sage/libs/flint/acb_hypgeom.pxd @@ -2,7 +2,9 @@ # distutils: depends = flint/acb_hypgeom.h ################################################################################ -# This file is auto-generated. Do not modify by hand +# This file is auto-generated by the script +# SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py. +# Do not modify by hand! Fix and rerun the script instead. ################################################################################ from libc.stdio cimport FILE @@ -11,898 +13,155 @@ from sage.libs.mpfr.types cimport * from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void acb_hypgeom_rising_ui_forward(acb_t res, const acb_t x, ulong n, slong prec) noexcept void acb_hypgeom_rising_ui_bs(acb_t res, const acb_t x, ulong n, slong prec) noexcept void acb_hypgeom_rising_ui_rs(acb_t res, const acb_t x, ulong n, ulong m, slong prec) noexcept void acb_hypgeom_rising_ui_rec(acb_t res, const acb_t x, ulong n, slong prec) noexcept void acb_hypgeom_rising_ui(acb_t res, const acb_t x, ulong n, slong prec) noexcept void acb_hypgeom_rising(acb_t res, const acb_t x, const acb_t n, slong prec) noexcept - # Computes the rising factorial `(x)_n`. - # The *forward* version uses the forward recurrence. - # The *bs* version uses binary splitting. - # The *rs* version uses rectangular splitting. It takes an extra tuning - # parameter *m* which can be set to zero to choose automatically. - # The *rec* version chooses an algorithm automatically, avoiding - # use of the gamma function (so that it can be used in the computation - # of the gamma function). - # The default versions (*rising_ui* and *rising_ui*) choose an algorithm - # automatically and may additionally fall back on the gamma function. - void acb_hypgeom_rising_ui_jet_powsum(acb_ptr res, const acb_t x, ulong n, slong len, slong prec) noexcept void acb_hypgeom_rising_ui_jet_bs(acb_ptr res, const acb_t x, ulong n, slong len, slong prec) noexcept void acb_hypgeom_rising_ui_jet_rs(acb_ptr res, const acb_t x, ulong n, ulong m, slong len, slong prec) noexcept void acb_hypgeom_rising_ui_jet(acb_ptr res, const acb_t x, ulong n, slong len, slong prec) noexcept - # Computes the jet of the rising factorial `(x)_n`, truncated to length *len*. - # In other words, constructs the polynomial `(X + x)_n \in \mathbb{R}[X]`, - # truncated if `\operatorname{len} < n + 1` (and zero-extended - # if `\operatorname{len} > n + 1`). - # The *powsum* version computes the sequence of powers of *x* and forms integral - # linear combinations of these. - # The *bs* version uses binary splitting. - # The *rs* version uses rectangular splitting. It takes an extra tuning - # parameter *m* which can be set to zero to choose automatically. - # The default version chooses an algorithm automatically. - void acb_hypgeom_log_rising_ui(acb_ptr res, const acb_t x, ulong n, slong prec) noexcept - # Computes the log-rising factorial `\log \, (x)_n = \sum_{k=0}^{n-1} \log(x+k)`. - # This first computes the ordinary rising factorial and then determines - # the branch correction `2 \pi i m` with respect to the principal - # logarithm. The correction is computed using Hare's algorithm in - # floating-point arithmetic if this is safe; otherwise, - # a direct computation of `\sum_{k=0}^{n-1} \arg(x+k)` is used as a fallback. - void acb_hypgeom_log_rising_ui_jet(acb_ptr res, const acb_t x, ulong n, slong len, slong prec) noexcept - # Computes the jet of the log-rising factorial `\log \, (x)_n`, - # truncated to length *len*. - void acb_hypgeom_gamma_stirling_sum_horner(acb_t s, const acb_t z, slong N, slong prec) noexcept void acb_hypgeom_gamma_stirling_sum_improved(acb_t s, const acb_t z, slong N, slong K, slong prec) noexcept - # Sets *res* to the final sum in the Stirling series for the gamma function - # truncated before the term with index *N*, i.e. computes - # `\sum_{n=1}^{N-1} B_{2n} / (2n(2n-1) z^{2n-1})`. - # The *horner* version uses Horner scheme with gradual precision adjustments. - # The *improved* version uses rectangular splitting for the low-index - # terms and reexpands the high-index terms as hypergeometric polynomials, - # using a splitting parameter *K* (which can be set to 0 to use a default - # value). - void acb_hypgeom_gamma_stirling(acb_t res, const acb_t x, int reciprocal, slong prec) noexcept - # Sets *res* to the gamma function of *x* computed using the Stirling - # series together with argument reduction. If *reciprocal* is set, - # the reciprocal gamma function is computed instead. - int acb_hypgeom_gamma_taylor(acb_t res, const acb_t x, int reciprocal, slong prec) noexcept - # Attempts to compute the gamma function of *x* using Taylor series - # together with argument reduction. This is only supported if *x* and *prec* - # are both small enough. If successful, returns 1; otherwise, does nothing - # and returns 0. If *reciprocal* is set, the reciprocal gamma function is - # computed instead. - void acb_hypgeom_gamma(acb_t res, const acb_t x, slong prec) noexcept - # Sets *res* to the gamma function of *x* computed using a default - # algorithm choice. - void acb_hypgeom_rgamma(acb_t res, const acb_t x, slong prec) noexcept - # Sets *res* to the reciprocal gamma function of *x* computed using a default - # algorithm choice. - void acb_hypgeom_lgamma(acb_t res, const acb_t x, slong prec) noexcept - # Sets *res* to the principal branch of the log-gamma function of *x* - # computed using a default algorithm choice. - void acb_hypgeom_pfq_bound_factor(mag_t C, acb_srcptr a, slong p, acb_srcptr b, slong q, const acb_t z, ulong n) noexcept - # Computes a factor *C* such that - # `\left|\sum_{k=n}^{\infty} T(k)\right| \le C |T(n)|`. - # See :ref:`algorithms_hypergeometric_convergent`. - # As currently implemented, the bound becomes infinite when `n` is - # too small, even if the series converges. - slong acb_hypgeom_pfq_choose_n(acb_srcptr a, slong p, acb_srcptr b, slong q, const acb_t z, slong prec) noexcept - # Heuristically attempts to choose a number of terms *n* to - # sum of a hypergeometric series at a working precision of *prec* bits. - # Uses double precision arithmetic internally. As currently implemented, - # it can fail to produce a good result if the parameters are extremely - # large or extremely close to nonpositive integers. - # Numerical cancellation is assumed to be significant, so truncation - # is done when the current term is *prec* bits - # smaller than the largest encountered term. - # This function will also attempt to pick a reasonable - # truncation point for divergent series. - void acb_hypgeom_pfq_sum_forward(acb_t s, acb_t t, acb_srcptr a, slong p, acb_srcptr b, slong q, const acb_t z, slong n, slong prec) noexcept - void acb_hypgeom_pfq_sum_rs(acb_t s, acb_t t, acb_srcptr a, slong p, acb_srcptr b, slong q, const acb_t z, slong n, slong prec) noexcept - void acb_hypgeom_pfq_sum_bs(acb_t s, acb_t t, acb_srcptr a, slong p, acb_srcptr b, slong q, const acb_t z, slong n, slong prec) noexcept - void acb_hypgeom_pfq_sum_fme(acb_t s, acb_t t, acb_srcptr a, slong p, acb_srcptr b, slong q, const acb_t z, slong n, slong prec) noexcept - void acb_hypgeom_pfq_sum(acb_t s, acb_t t, acb_srcptr a, slong p, acb_srcptr b, slong q, const acb_t z, slong n, slong prec) noexcept - # Computes `s = \sum_{k=0}^{n-1} T(k)` and `t = T(n)`. - # Does not allow aliasing between input and output variables. - # We require `n \ge 0`. - # The *forward* version computes the sum using forward - # recurrence. - # The *bs* version computes the sum using binary splitting. - # The *rs* version computes the sum in reverse order - # using rectangular splitting. It only computes a - # magnitude bound for the value of *t*. - # The *fme* version uses fast multipoint evaluation. - # The default version automatically chooses an algorithm - # depending on the inputs. - void acb_hypgeom_pfq_sum_bs_invz(acb_t s, acb_t t, acb_srcptr a, slong p, acb_srcptr b, slong q, const acb_t w, slong n, slong prec) noexcept - void acb_hypgeom_pfq_sum_invz(acb_t s, acb_t t, acb_srcptr a, slong p, acb_srcptr b, slong q, const acb_t z, const acb_t w, slong n, slong prec) noexcept - # Like :func:`acb_hypgeom_pfq_sum`, but taking advantage of - # `w = 1/z` possibly having few bits. - void acb_hypgeom_pfq_direct(acb_t res, acb_srcptr a, slong p, acb_srcptr b, slong q, const acb_t z, slong n, slong prec) noexcept - # Computes - # .. math :: - # {}_pf_{q}(z) - # = \sum_{k=0}^{\infty} T(k) - # = \sum_{k=0}^{n-1} T(k) + \varepsilon - # directly from the defining series, including a rigorous bound for - # the truncation error `\varepsilon` in the output. - # If `n < 0`, this function chooses a number of terms automatically - # using :func:`acb_hypgeom_pfq_choose_n`. - void acb_hypgeom_pfq_series_sum_forward(acb_poly_t s, acb_poly_t t, const acb_poly_struct * a, slong p, const acb_poly_struct * b, slong q, const acb_poly_t z, int regularized, slong n, slong len, slong prec) noexcept - void acb_hypgeom_pfq_series_sum_bs(acb_poly_t s, acb_poly_t t, const acb_poly_struct * a, slong p, const acb_poly_struct * b, slong q, const acb_poly_t z, int regularized, slong n, slong len, slong prec) noexcept - void acb_hypgeom_pfq_series_sum_rs(acb_poly_t s, acb_poly_t t, const acb_poly_struct * a, slong p, const acb_poly_struct * b, slong q, const acb_poly_t z, int regularized, slong n, slong len, slong prec) noexcept - void acb_hypgeom_pfq_series_sum(acb_poly_t s, acb_poly_t t, const acb_poly_struct * a, slong p, const acb_poly_struct * b, slong q, const acb_poly_t z, int regularized, slong n, slong len, slong prec) noexcept - # Computes `s = \sum_{k=0}^{n-1} T(k)` and `t = T(n)` given parameters - # and argument that are power series. - # Does not allow aliasing between input and output variables. - # We require `n \ge 0` and that *len* is positive. - # If *regularized* is set, the regularized sum is computed, avoiding - # division by zero at the poles of the gamma function. - # The *forward*, *bs*, *rs* and default versions use forward recurrence, - # binary splitting, rectangular splitting, and an automatic algorithm - # choice. - void acb_hypgeom_pfq_series_direct(acb_poly_t res, const acb_poly_struct * a, slong p, const acb_poly_struct * b, slong q, const acb_poly_t z, int regularized, slong n, slong len, slong prec) noexcept - # Computes `{}_pf_{q}(z)` directly using the defining series, given - # parameters and argument that are power series. - # The result is a power series of length *len*. - # We require that *len* is positive. - # An error bound is computed automatically as a function of the number - # of terms *n*. If `n < 0`, the number of terms is chosen - # automatically. - # If *regularized* is set, the regularized hypergeometric function - # is computed instead. - void acb_hypgeom_u_asymp(acb_t res, const acb_t a, const acb_t b, const acb_t z, slong n, slong prec) noexcept - # Sets *res* to `U^{*}(a,b,z)` computed using *n* terms of the asymptotic series, - # with a rigorous bound for the error included in the output. - # We require `n \ge 0`. - int acb_hypgeom_u_use_asymp(const acb_t z, slong prec) noexcept - # Heuristically determines whether the asymptotic series can be used - # to evaluate `U(a,b,z)` to *prec* accurate bits (assuming that *a* and *b* - # are small). - void acb_hypgeom_pfq(acb_t res, acb_srcptr a, slong p, acb_srcptr b, slong q, const acb_t z, int regularized, slong prec) noexcept - # Computes the generalized hypergeometric function `{}_pF_{q}(z)`, - # or the regularized version if *regularized* is set. - # This function automatically delegates to a specialized implementation - # when the order (*p*, *q*) is one of (0,0), (1,0), (0,1), (1,1), (2,1). - # Otherwise, it falls back to direct summation. - # While this is a top-level function meant to take care of special cases - # automatically, it does not generally perform the optimization - # of deleting parameters that appear in both *a* and *b*. This can be - # done ahead of time by the user in applications where duplicate - # parameters are likely to occur. - void acb_hypgeom_u_1f1_series(acb_poly_t res, const acb_poly_t a, const acb_poly_t b, const acb_poly_t z, slong len, slong prec) noexcept - # Computes `U(a,b,z)` as a power series truncated to length *len*, - # given `a, b, z \in \mathbb{C}[[x]]`. - # If `b[0] \in \mathbb{Z}`, it computes one extra derivative and removes - # the singularity (it is then assumed that `b[1] \ne 0`). - # As currently implemented, the output is indeterminate if `b` is nonexact - # and contains an integer. - void acb_hypgeom_u_1f1(acb_t res, const acb_t a, const acb_t b, const acb_t z, slong prec) noexcept - # Computes `U(a,b,z)` as a sum of two convergent hypergeometric series. - # If `b \in \mathbb{Z}`, it computes - # the limit value via :func:`acb_hypgeom_u_1f1_series`. - # As currently implemented, the output is indeterminate if `b` is nonexact - # and contains an integer. - void acb_hypgeom_u(acb_t res, const acb_t a, const acb_t b, const acb_t z, slong prec) noexcept - # Computes `U(a,b,z)` using an automatic algorithm choice. The - # function :func:`acb_hypgeom_u_asymp` is used - # if `a` or `a-b+1` is a nonpositive integer (in which - # case the asymptotic series terminates), or if *z* is sufficiently large. - # Otherwise :func:`acb_hypgeom_u_1f1` is used. - void acb_hypgeom_m_asymp(acb_t res, const acb_t a, const acb_t b, const acb_t z, int regularized, slong prec) noexcept - void acb_hypgeom_m_1f1(acb_t res, const acb_t a, const acb_t b, const acb_t z, int regularized, slong prec) noexcept - void acb_hypgeom_m(acb_t res, const acb_t a, const acb_t b, const acb_t z, int regularized, slong prec) noexcept - # Computes the confluent hypergeometric function - # `M(a,b,z) = {}_1F_1(a,b,z)`, or - # `\mathbf{M}(a,b,z) = \frac{1}{\Gamma(b)} {}_1F_1(a,b,z)` if *regularized* - # is set. - void acb_hypgeom_1f1(acb_t res, const acb_t a, const acb_t b, const acb_t z, int regularized, slong prec) noexcept - # Alias for :func:`acb_hypgeom_m`. - void acb_hypgeom_0f1_asymp(acb_t res, const acb_t a, const acb_t z, int regularized, slong prec) noexcept - void acb_hypgeom_0f1_direct(acb_t res, const acb_t a, const acb_t z, int regularized, slong prec) noexcept - void acb_hypgeom_0f1(acb_t res, const acb_t a, const acb_t z, int regularized, slong prec) noexcept - # Computes the confluent hypergeometric function - # `{}_0F_1(a,z)`, or `\frac{1}{\Gamma(a)} {}_0F_1(a,z)` if *regularized* - # is set, using asymptotic expansions, direct summation, - # or an automatic algorithm choice. - # The *asymp* version uses the asymptotic expansions of Bessel - # functions, together with the connection formulas - # .. math :: - # \frac{{}_0F_1(a,z)}{\Gamma(a)} = (-z)^{(1-a)/2} J_{a-1}(2 \sqrt{-z}) = - # z^{(1-a)/2} I_{a-1}(2 \sqrt{z}). - # The Bessel-*J* function is used in the left half-plane and the - # Bessel-*I* function is used in the right half-plane, to avoid loss - # of accuracy due to evaluating the square root on the branch cut. - void acb_hypgeom_erf_propagated_error(mag_t re, mag_t im, const acb_t z) noexcept - # Sets *re* and *im* to upper bounds for the error in the real and imaginary - # part resulting from approximating the error function of *z* by - # the error function evaluated at the midpoint of *z*. Uses - # the first derivative. - void acb_hypgeom_erf_1f1a(acb_t res, const acb_t z, slong prec) noexcept - void acb_hypgeom_erf_1f1b(acb_t res, const acb_t z, slong prec) noexcept - void acb_hypgeom_erf_asymp(acb_t res, const acb_t z, int complementary, slong prec, slong prec2) noexcept - # Computes the error function respectively using - # .. math :: - # \operatorname{erf}(z) &= \frac{2z}{\sqrt{\pi}} - # {}_1F_1(\tfrac{1}{2}, \tfrac{3}{2}, -z^2) - # \operatorname{erf}(z) &= \frac{2z e^{-z^2}}{\sqrt{\pi}} - # {}_1F_1(1, \tfrac{3}{2}, z^2) - # \operatorname{erf}(z) &= \frac{z}{\sqrt{z^2}} - # \left(1 - \frac{e^{-z^2}}{\sqrt{\pi}} - # U(\tfrac{1}{2}, \tfrac{1}{2}, z^2)\right) = - # \frac{z}{\sqrt{z^2}} - \frac{e^{-z^2}}{z \sqrt{\pi}} - # U^{*}(\tfrac{1}{2}, \tfrac{1}{2}, z^2). - # The *asymp* version takes a second precision to use for the *U* term. - # It also takes an extra flag *complementary*, computing the complementary - # error function if set. - void acb_hypgeom_erf(acb_t res, const acb_t z, slong prec) noexcept - # Computes the error function using an automatic algorithm choice. - # If *z* is too small to use the asymptotic expansion, a working precision - # sufficient to circumvent cancellation in the hypergeometric series is - # determined automatically, and a bound for the propagated error is - # computed with :func:`acb_hypgeom_erf_propagated_error`. - void _acb_hypgeom_erf_series(acb_ptr res, acb_srcptr z, slong zlen, slong len, slong prec) noexcept - void acb_hypgeom_erf_series(acb_poly_t res, const acb_poly_t z, slong len, slong prec) noexcept - # Computes the error function of the power series *z*, - # truncated to length *len*. - void acb_hypgeom_erfc(acb_t res, const acb_t z, slong prec) noexcept - # Computes the complementary error function - # `\operatorname{erfc}(z) = 1 - \operatorname{erf}(z)`. - # This function avoids catastrophic cancellation for large positive *z*. - void _acb_hypgeom_erfc_series(acb_ptr res, acb_srcptr z, slong zlen, slong len, slong prec) noexcept - void acb_hypgeom_erfc_series(acb_poly_t res, const acb_poly_t z, slong len, slong prec) noexcept - # Computes the complementary error function of the power series *z*, - # truncated to length *len*. - void acb_hypgeom_erfi(acb_t res, const acb_t z, slong prec) noexcept - # Computes the imaginary error function - # `\operatorname{erfi}(z) = -i\operatorname{erf}(iz)`. This is a trivial wrapper - # of :func:`acb_hypgeom_erf`. - void _acb_hypgeom_erfi_series(acb_ptr res, acb_srcptr z, slong zlen, slong len, slong prec) noexcept - void acb_hypgeom_erfi_series(acb_poly_t res, const acb_poly_t z, slong len, slong prec) noexcept - # Computes the imaginary error function of the power series *z*, - # truncated to length *len*. - void acb_hypgeom_fresnel(acb_t res1, acb_t res2, const acb_t z, int normalized, slong prec) noexcept - # Sets *res1* to the Fresnel sine integral `S(z)` and *res2* to - # the Fresnel cosine integral `C(z)`. Optionally, just a single function - # can be computed by passing *NULL* as the other output variable. - # The definition `S(z) = \int_0^z \sin(t^2) dt` is used if *normalized* is 0, - # and `S(z) = \int_0^z \sin(\tfrac{1}{2} \pi t^2) dt` is used if - # *normalized* is 1 (the latter is the Abramowitz & Stegun convention). - # `C(z)` is defined analogously. - void _acb_hypgeom_fresnel_series(acb_ptr res1, acb_ptr res2, acb_srcptr z, slong zlen, int normalized, slong len, slong prec) noexcept - void acb_hypgeom_fresnel_series(acb_poly_t res1, acb_poly_t res2, const acb_poly_t z, int normalized, slong len, slong prec) noexcept - # Sets *res1* to the Fresnel sine integral and *res2* to the Fresnel - # cosine integral of the power series *z*, truncated to length *len*. - # Optionally, just a single function can be computed by passing *NULL* - # as the other output variable. - void acb_hypgeom_bessel_j_asymp(acb_t res, const acb_t nu, const acb_t z, slong prec) noexcept - # Computes the Bessel function of the first kind - # via :func:`acb_hypgeom_u_asymp`. - # For all complex `\nu, z`, we have - # .. math :: - # J_{\nu}(z) = \frac{z^{\nu}}{2^{\nu} e^{iz} \Gamma(\nu+1)} - # {}_1F_1(\nu+\tfrac{1}{2}, 2\nu+1, 2iz) = A_{+} B_{+} + A_{-} B_{-} - # where - # .. math :: - # A_{\pm} = z^{\nu} (z^2)^{-\tfrac{1}{2}-\nu} (\mp i z)^{\tfrac{1}{2}+\nu} (2 \pi)^{-1/2} = (\pm iz)^{-1/2-\nu} z^{\nu} (2 \pi)^{-1/2} - # .. math :: - # B_{\pm} = e^{\pm i z} U^{*}(\nu+\tfrac{1}{2}, 2\nu+1, \mp 2iz). - # Nicer representations of the factors `A_{\pm}` can be given depending conditionally - # on the parameters. If `\nu + \tfrac{1}{2} = n \in \mathbb{Z}`, we have - # `A_{\pm} = (\pm i)^{n} (2 \pi z)^{-1/2}`. - # And if `\operatorname{Re}(z) > 0`, we have `A_{\pm} = \exp(\mp i [(2\nu+1)/4] \pi) (2 \pi z)^{-1/2}`. - void acb_hypgeom_bessel_j_0f1(acb_t res, const acb_t nu, const acb_t z, slong prec) noexcept - # Computes the Bessel function of the first kind from - # .. math :: - # J_{\nu}(z) = \frac{1}{\Gamma(\nu+1)} \left(\frac{z}{2}\right)^{\nu} - # {}_0F_1\left(\nu+1, -\frac{z^2}{4}\right). - void acb_hypgeom_bessel_j(acb_t res, const acb_t nu, const acb_t z, slong prec) noexcept - # Computes the Bessel function of the first kind `J_{\nu}(z)` using - # an automatic algorithm choice. - void acb_hypgeom_bessel_y(acb_t res, const acb_t nu, const acb_t z, slong prec) noexcept - # Computes the Bessel function of the second kind `Y_{\nu}(z)` from the - # formula - # .. math :: - # Y_{\nu}(z) = \frac{\cos(\nu \pi) J_{\nu}(z) - J_{-\nu}(z)}{\sin(\nu \pi)} - # unless `\nu = n` is an integer in which case the limit value - # .. math :: - # Y_n(z) = -\frac{2}{\pi} \left( i^n K_n(iz) + - # \left[\log(iz)-\log(z)\right] J_n(z) \right) - # is computed. - # As currently implemented, the output is indeterminate if `\nu` is nonexact - # and contains an integer. - void acb_hypgeom_bessel_jy(acb_t res1, acb_t res2, const acb_t nu, const acb_t z, slong prec) noexcept - # Sets *res1* to `J_{\nu}(z)` and *res2* to `Y_{\nu}(z)`, computed - # simultaneously. From these values, the user can easily - # construct the Bessel functions of the third kind (Hankel functions) - # `H_{\nu}^{(1)}(z), H_{\nu}^{(2)}(z) = J_{\nu}(z) \pm i Y_{\nu}(z)`. - void acb_hypgeom_bessel_i_asymp(acb_t res, const acb_t nu, const acb_t z, int scaled, slong prec) noexcept - void acb_hypgeom_bessel_i_0f1(acb_t res, const acb_t nu, const acb_t z, int scaled, slong prec) noexcept - void acb_hypgeom_bessel_i(acb_t res, const acb_t nu, const acb_t z, slong prec) noexcept - void acb_hypgeom_bessel_i_scaled(acb_t res, const acb_t nu, const acb_t z, slong prec) noexcept - # Computes the modified Bessel function of the first kind - # `I_{\nu}(z) = z^{\nu} (iz)^{-\nu} J_{\nu}(iz)` respectively using - # asymptotic series (see :func:`acb_hypgeom_bessel_j_asymp`), - # the convergent series - # .. math :: - # I_{\nu}(z) = \frac{1}{\Gamma(\nu+1)} \left(\frac{z}{2}\right)^{\nu} - # {}_0F_1\left(\nu+1, \frac{z^2}{4}\right), - # or an automatic algorithm choice. - # The *scaled* version computes the function `e^{-z} I_{\nu}(z)`. The *asymp* - # and *0f1* functions implement both variants and allow choosing with a flag. - void acb_hypgeom_bessel_k_asymp(acb_t res, const acb_t nu, const acb_t z, int scaled, slong prec) noexcept - # Computes the modified Bessel function of the second kind via - # via :func:`acb_hypgeom_u_asymp`. For all `\nu` and all `z \ne 0`, we have - # .. math :: - # K_{\nu}(z) = \left(\frac{2z}{\pi}\right)^{-1/2} e^{-z} - # U^{*}(\nu+\tfrac{1}{2}, 2\nu+1, 2z). - # If *scaled* is set, computes the function `e^{z} K_{\nu}(z)`. - void acb_hypgeom_bessel_k_0f1_series(acb_poly_t res, const acb_poly_t nu, const acb_poly_t z, int scaled, slong len, slong prec) noexcept - # Computes the modified Bessel function of the second kind `K_{\nu}(z)` - # as a power series truncated to length *len*, - # given `\nu, z \in \mathbb{C}[[x]]`. Uses the formula - # .. math :: - # K_{\nu}(z) = \frac{1}{2} \frac{\pi}{\sin(\pi \nu)} \left[ - # \left(\frac{z}{2}\right)^{-\nu} - # {}_0{\widetilde F}_1\left(1-\nu, \frac{z^2}{4}\right) - # - - # \left(\frac{z}{2}\right)^{\nu} - # {}_0{\widetilde F}_1\left(1+\nu, \frac{z^2}{4}\right) - # \right]. - # If `\nu[0] \in \mathbb{Z}`, it computes one extra derivative and removes - # the singularity (it is then assumed that `\nu[1] \ne 0`). - # As currently implemented, the output is indeterminate if `\nu[0]` is nonexact - # and contains an integer. - # If *scaled* is set, computes the function `e^{z} K_{\nu}(z)`. - void acb_hypgeom_bessel_k_0f1(acb_t res, const acb_t nu, const acb_t z, int scaled, slong prec) noexcept - # Computes the modified Bessel function of the second kind from - # .. math :: - # K_{\nu}(z) = \frac{1}{2} \left[ - # \left(\frac{z}{2}\right)^{-\nu} - # \Gamma(\nu) - # {}_0F_1\left(1-\nu, \frac{z^2}{4}\right) - # - - # \left(\frac{z}{2}\right)^{\nu} - # \frac{\pi}{\nu \sin(\pi \nu) \Gamma(\nu)} - # {}_0F_1\left(\nu+1, \frac{z^2}{4}\right) - # \right] - # if `\nu \notin \mathbb{Z}`. If `\nu \in \mathbb{Z}`, it computes - # the limit value via :func:`acb_hypgeom_bessel_k_0f1_series`. - # As currently implemented, the output is indeterminate if `\nu` is nonexact - # and contains an integer. - # If *scaled* is set, computes the function `e^{z} K_{\nu}(z)`. - void acb_hypgeom_bessel_k(acb_t res, const acb_t nu, const acb_t z, slong prec) noexcept - # Computes the modified Bessel function of the second kind `K_{\nu}(z)` using - # an automatic algorithm choice. - void acb_hypgeom_bessel_k_scaled(acb_t res, const acb_t nu, const acb_t z, slong prec) noexcept - # Computes the function `e^{z} K_{\nu}(z)`. - void acb_hypgeom_airy_direct(acb_t ai, acb_t ai_prime, acb_t bi, acb_t bi_prime, const acb_t z, slong n, slong prec) noexcept - # Computes the Airy functions using direct series expansions truncated at *n* terms. - # Error bounds are included in the output. - void acb_hypgeom_airy_asymp(acb_t ai, acb_t ai_prime, acb_t bi, acb_t bi_prime, const acb_t z, slong n, slong prec) noexcept - # Computes the Airy functions using asymptotic expansions truncated at *n* terms. - # Error bounds are included in the output. - # For details about how the error bounds are computed, see - # :ref:`algorithms_hypergeometric_asymptotic_airy`. - void acb_hypgeom_airy_bound(mag_t ai, mag_t ai_prime, mag_t bi, mag_t bi_prime, const acb_t z) noexcept - # Computes bounds for the Airy functions using first-order asymptotic - # expansions together with error bounds. This function uses some - # shortcuts to make it slightly faster than calling - # :func:`acb_hypgeom_airy_asymp` with `n = 1`. - void acb_hypgeom_airy(acb_t ai, acb_t ai_prime, acb_t bi, acb_t bi_prime, const acb_t z, slong prec) noexcept - # Computes Airy functions using an automatic algorithm choice. - # We use :func:`acb_hypgeom_airy_asymp` whenever this gives full accuracy - # and :func:`acb_hypgeom_airy_direct` otherwise. - # In the latter case, we first use hardware double precision arithmetic to - # determine an accurate estimate of the working precision needed - # to compute the Airy functions accurately for given *z*. This estimate is - # obtained by comparing the leading-order asymptotic estimate of the Airy - # functions with the magnitude of the largest term in the power series. - # The estimate is generic in the sense that it does not take into account - # vanishing near the roots of the functions. - # We subsequently evaluate the power series at the midpoint of *z* and - # bound the propagated error using derivatives. Derivatives are - # bounded using :func:`acb_hypgeom_airy_bound`. - void acb_hypgeom_airy_jet(acb_ptr ai, acb_ptr bi, const acb_t z, slong len, slong prec) noexcept - # Writes to *ai* and *bi* the respective Taylor expansions of the Airy functions - # at the point *z*, truncated to length *len*. - # Either of the outputs can be *NULL* to avoid computing that function. - # The variable *z* is not allowed to be aliased with the outputs. - # To simplify the implementation, this method does not compute the - # series expansions of the primed versions directly; these are - # easily obtained by computing one extra coefficient and differentiating - # the output with :func:`_acb_poly_derivative`. - void _acb_hypgeom_airy_series(acb_ptr ai, acb_ptr ai_prime, acb_ptr bi, acb_ptr bi_prime, acb_srcptr z, slong zlen, slong len, slong prec) noexcept - void acb_hypgeom_airy_series(acb_poly_t ai, acb_poly_t ai_prime, acb_poly_t bi, acb_poly_t bi_prime, const acb_poly_t z, slong len, slong prec) noexcept - # Computes the Airy functions evaluated at the power series *z*, - # truncated to length *len*. As with the other Airy methods, any of the - # outputs can be *NULL*. - void acb_hypgeom_coulomb(acb_t F, acb_t G, acb_t Hpos, acb_t Hneg, const acb_t l, const acb_t eta, const acb_t z, slong prec) noexcept - # Writes to *F*, *G*, *Hpos*, *Hneg* the values of the respective - # Coulomb wave functions. Any of the outputs can be *NULL*. - void acb_hypgeom_coulomb_jet(acb_ptr F, acb_ptr G, acb_ptr Hpos, acb_ptr Hneg, const acb_t l, const acb_t eta, const acb_t z, slong len, slong prec) noexcept - # Writes to *F*, *G*, *Hpos*, *Hneg* the respective Taylor expansions of the - # Coulomb wave functions at the point *z*, truncated to length *len*. - # Any of the outputs can be *NULL*. - void _acb_hypgeom_coulomb_series(acb_ptr F, acb_ptr G, acb_ptr Hpos, acb_ptr Hneg, const acb_t l, const acb_t eta, acb_srcptr z, slong zlen, slong len, slong prec) noexcept - void acb_hypgeom_coulomb_series(acb_poly_t F, acb_poly_t G, acb_poly_t Hpos, acb_poly_t Hneg, const acb_t l, const acb_t eta, const acb_poly_t z, slong len, slong prec) noexcept - # Computes the Coulomb wave functions evaluated at the power series *z*, - # truncated to length *len*. Any of the outputs can be *NULL*. - void acb_hypgeom_gamma_upper_asymp(acb_t res, const acb_t s, const acb_t z, int regularized, slong prec) noexcept - void acb_hypgeom_gamma_upper_1f1a(acb_t res, const acb_t s, const acb_t z, int regularized, slong prec) noexcept - void acb_hypgeom_gamma_upper_1f1b(acb_t res, const acb_t s, const acb_t z, int regularized, slong prec) noexcept - void acb_hypgeom_gamma_upper_singular(acb_t res, slong s, const acb_t z, int regularized, slong prec) noexcept - void acb_hypgeom_gamma_upper(acb_t res, const acb_t s, const acb_t z, int regularized, slong prec) noexcept - # If *regularized* is 0, computes the upper incomplete gamma function - # `\Gamma(s,z)`. - # If *regularized* is 1, computes the regularized upper incomplete - # gamma function `Q(s,z) = \Gamma(s,z) / \Gamma(s)`. - # If *regularized* is 2, computes the generalized exponential integral - # `z^{-s} \Gamma(s,z) = E_{1-s}(z)` instead (this option is mainly - # intended for internal use; :func:`acb_hypgeom_expint` is the intended - # interface for computing the exponential integral). - # The different methods respectively implement the formulas - # .. math :: - # \Gamma(s,z) = e^{-z} U(1-s,1-s,z) - # .. math :: - # \Gamma(s,z) = \Gamma(s) - \frac{z^s}{s} {}_1F_1(s, s+1, -z) - # .. math :: - # \Gamma(s,z) = \Gamma(s) - \frac{z^s e^{-z}}{s} {}_1F_1(1, s+1, z) - # .. math :: - # \Gamma(s,z) = \frac{(-1)^n}{n!} (\psi(n+1) - \log(z)) - # + \frac{(-1)^n}{(n+1)!} z \, {}_2F_2(1,1,2,2+n,-z) - # - z^{-n} \sum_{k=0}^{n-1} \frac{(-z)^k}{(k-n) k!}, - # \quad n = -s \in \mathbb{Z}_{\ge 0} - # and an automatic algorithm choice. The automatic version also handles - # other special input such as `z = 0` and `s = 1, 2, 3`. - # The *singular* version evaluates the finite sum directly and therefore - # assumes that *s* is not too large. - void _acb_hypgeom_gamma_upper_series(acb_ptr res, const acb_t s, acb_srcptr z, slong zlen, int regularized, slong n, slong prec) noexcept - void acb_hypgeom_gamma_upper_series(acb_poly_t res, const acb_t s, const acb_poly_t z, int regularized, slong n, slong prec) noexcept - # Sets *res* to an upper incomplete gamma function where *s* is - # a constant and *z* is a power series, truncated to length *n*. - # The *regularized* argument has the same interpretation as in - # :func:`acb_hypgeom_gamma_upper`. - void acb_hypgeom_gamma_lower(acb_t res, const acb_t s, const acb_t z, int regularized, slong prec) noexcept - # If *regularized* is 0, computes the lower incomplete gamma function - # `\gamma(s,z) = \frac{z^s}{s} {}_1F_1(s, s+1, -z)`. - # If *regularized* is 1, computes the regularized lower incomplete - # gamma function `P(s,z) = \gamma(s,z) / \Gamma(s)`. - # If *regularized* is 2, computes a further regularized lower incomplete - # gamma function `\gamma^{*}(s,z) = z^{-s} P(s,z)`. - void _acb_hypgeom_gamma_lower_series(acb_ptr res, const acb_t s, acb_srcptr z, slong zlen, int regularized, slong n, slong prec) noexcept - void acb_hypgeom_gamma_lower_series(acb_poly_t res, const acb_t s, const acb_poly_t z, int regularized, slong n, slong prec) noexcept - # Sets *res* to an lower incomplete gamma function where *s* is - # a constant and *z* is a power series, truncated to length *n*. - # The *regularized* argument has the same interpretation as in - # :func:`acb_hypgeom_gamma_lower`. - void acb_hypgeom_beta_lower(acb_t res, const acb_t a, const acb_t b, const acb_t z, int regularized, slong prec) noexcept - # Computes the (lower) incomplete beta function, defined by - # `B(a,b;z) = \int_0^z t^{a-1} (1-t)^{b-1}`, - # optionally the regularized incomplete beta function - # `I(a,b;z) = B(a,b;z) / B(a,b;1)`. - # In general, the integral must be interpreted using analytic continuation. - # The precise definitions for all parameter values are - # .. math :: - # B(a,b;z) = \frac{z^a}{a} {}_2F_1(a, 1-b, a+1, z) - # .. math :: - # I(a,b;z) = \frac{\Gamma(a+b)}{\Gamma(b)} z^a {}_2{\widetilde F}_1(a, 1-b, a+1, z). - # Note that both functions with this definition are undefined - # for nonpositive integer *a*, and *I* is undefined for nonpositive integer - # `a + b`. - void _acb_hypgeom_beta_lower_series(acb_ptr res, const acb_t a, const acb_t b, acb_srcptr z, slong zlen, int regularized, slong n, slong prec) noexcept - void acb_hypgeom_beta_lower_series(acb_poly_t res, const acb_t a, const acb_t b, const acb_poly_t z, int regularized, slong n, slong prec) noexcept - # Sets *res* to the lower incomplete beta function `B(a,b;z)` (optionally - # the regularized version `I(a,b;z)`) where *a* and *b* are constants - # and *z* is a power series, truncating the result to length *n*. - # The underscore method requires positive lengths and does not support - # aliasing. - void acb_hypgeom_expint(acb_t res, const acb_t s, const acb_t z, slong prec) noexcept - # Computes the generalized exponential integral `E_s(z)`. This is a - # trivial wrapper of :func:`acb_hypgeom_gamma_upper`. - void acb_hypgeom_ei_asymp(acb_t res, const acb_t z, slong prec) noexcept - void acb_hypgeom_ei_2f2(acb_t res, const acb_t z, slong prec) noexcept - void acb_hypgeom_ei(acb_t res, const acb_t z, slong prec) noexcept - # Computes the exponential integral `\operatorname{Ei}(z)`, respectively - # using - # .. math :: - # \operatorname{Ei}(z) = -e^z U(1,1,-z) - \log(-z) - # + \frac{1}{2} \left(\log(z) - \log\left(\frac{1}{z}\right) \right) - # .. math :: - # \operatorname{Ei}(z) = z {}_2F_2(1, 1; 2, 2; z) + \gamma - # + \frac{1}{2} \left(\log(z) - \log\left(\frac{1}{z}\right) \right) - # and an automatic algorithm choice. - void _acb_hypgeom_ei_series(acb_ptr res, acb_srcptr z, slong zlen, slong len, slong prec) noexcept - void acb_hypgeom_ei_series(acb_poly_t res, const acb_poly_t z, slong len, slong prec) noexcept - # Computes the exponential integral of the power series *z*, - # truncated to length *len*. - void acb_hypgeom_si_asymp(acb_t res, const acb_t z, slong prec) noexcept - void acb_hypgeom_si_1f2(acb_t res, const acb_t z, slong prec) noexcept - void acb_hypgeom_si(acb_t res, const acb_t z, slong prec) noexcept - # Computes the sine integral `\operatorname{Si}(z)`, respectively - # using - # .. math :: - # \operatorname{Si}(z) = \frac{i}{2} \left[ - # e^{iz} U(1,1,-iz) - e^{-iz} U(1,1,iz) + - # \log(-iz) - \log(iz) \right] - # .. math :: - # \operatorname{Si}(z) = z {}_1F_2(\tfrac{1}{2}; \tfrac{3}{2}, \tfrac{3}{2}; -\tfrac{z^2}{4}) - # and an automatic algorithm choice. - void _acb_hypgeom_si_series(acb_ptr res, acb_srcptr z, slong zlen, slong len, slong prec) noexcept - void acb_hypgeom_si_series(acb_poly_t res, const acb_poly_t z, slong len, slong prec) noexcept - # Computes the sine integral of the power series *z*, - # truncated to length *len*. - void acb_hypgeom_ci_asymp(acb_t res, const acb_t z, slong prec) noexcept - void acb_hypgeom_ci_2f3(acb_t res, const acb_t z, slong prec) noexcept - void acb_hypgeom_ci(acb_t res, const acb_t z, slong prec) noexcept - # Computes the cosine integral `\operatorname{Ci}(z)`, respectively - # using - # .. math :: - # \operatorname{Ci}(z) = \log(z) - \frac{1}{2} \left[ - # e^{iz} U(1,1,-iz) + e^{-iz} U(1,1,iz) + - # \log(-iz) + \log(iz) \right] - # .. math :: - # \operatorname{Ci}(z) = -\tfrac{z^2}{4} - # {}_2F_3(1, 1; 2, 2, \tfrac{3}{2}; -\tfrac{z^2}{4}) - # + \log(z) + \gamma - # and an automatic algorithm choice. - void _acb_hypgeom_ci_series(acb_ptr res, acb_srcptr z, slong zlen, slong len, slong prec) noexcept - void acb_hypgeom_ci_series(acb_poly_t res, const acb_poly_t z, slong len, slong prec) noexcept - # Computes the cosine integral of the power series *z*, - # truncated to length *len*. - void acb_hypgeom_shi(acb_t res, const acb_t z, slong prec) noexcept - # Computes the hyperbolic sine integral - # `\operatorname{Shi}(z) = -i \operatorname{Si}(iz)`. - # This is a trivial wrapper of :func:`acb_hypgeom_si`. - void _acb_hypgeom_shi_series(acb_ptr res, acb_srcptr z, slong zlen, slong len, slong prec) noexcept - void acb_hypgeom_shi_series(acb_poly_t res, const acb_poly_t z, slong len, slong prec) noexcept - # Computes the hyperbolic sine integral of the power series *z*, - # truncated to length *len*. - void acb_hypgeom_chi_asymp(acb_t res, const acb_t z, slong prec) noexcept - void acb_hypgeom_chi_2f3(acb_t res, const acb_t z, slong prec) noexcept - void acb_hypgeom_chi(acb_t res, const acb_t z, slong prec) noexcept - # Computes the hyperbolic cosine integral `\operatorname{Chi}(z)`, respectively - # using - # .. math :: - # \operatorname{Chi}(z) = -\frac{1}{2} \left[ - # e^{z} U(1,1,-z) + e^{-z} U(1,1,z) + - # \log(-z) - \log(z) \right] - # .. math :: - # \operatorname{Chi}(z) = \tfrac{z^2}{4} - # {}_2F_3(1, 1; 2, 2, \tfrac{3}{2}; \tfrac{z^2}{4}) - # + \log(z) + \gamma - # and an automatic algorithm choice. - void _acb_hypgeom_chi_series(acb_ptr res, acb_srcptr z, slong zlen, slong len, slong prec) noexcept - void acb_hypgeom_chi_series(acb_poly_t res, const acb_poly_t z, slong len, slong prec) noexcept - # Computes the hyperbolic cosine integral of the power series *z*, - # truncated to length *len*. - void acb_hypgeom_li(acb_t res, const acb_t z, int offset, slong prec) noexcept - # If *offset* is zero, computes the logarithmic integral - # `\operatorname{li}(z) = \operatorname{Ei}(\log(z))`. - # If *offset* is nonzero, computes the offset logarithmic integral - # `\operatorname{Li}(z) = \operatorname{li}(z) - \operatorname{li}(2)`. - void _acb_hypgeom_li_series(acb_ptr res, acb_srcptr z, slong zlen, int offset, slong len, slong prec) noexcept - void acb_hypgeom_li_series(acb_poly_t res, const acb_poly_t z, int offset, slong len, slong prec) noexcept - # Computes the logarithmic integral (optionally the offset version) - # of the power series *z*, truncated to length *len*. - void acb_hypgeom_2f1_continuation(acb_t res0, acb_t res1, const acb_t a, const acb_t b, const acb_t c, const acb_t z0, const acb_t z1, const acb_t f0, const acb_t f1, slong prec) noexcept - # Given `F(z_0), F'(z_0)` in *f0*, *f1*, sets *res0* and *res1* to `F(z_1), F'(z_1)` - # by integrating the hypergeometric differential equation along a straight-line path. - # The evaluation points should be well-isolated from the singular points 0 and 1. - void acb_hypgeom_2f1_series_direct(acb_poly_t res, const acb_poly_t a, const acb_poly_t b, const acb_poly_t c, const acb_poly_t z, int regularized, slong len, slong prec) noexcept - # Computes `F(z)` of the given power series truncated to length *len*, using - # direct summation of the hypergeometric series. - void acb_hypgeom_2f1_direct(acb_t res, const acb_t a, const acb_t b, const acb_t c, const acb_t z, int regularized, slong prec) noexcept - # Computes `F(z)` using direct summation of the hypergeometric series. - void acb_hypgeom_2f1_transform(acb_t res, const acb_t a, const acb_t b, const acb_t c, const acb_t z, int flags, int which, slong prec) noexcept - void acb_hypgeom_2f1_transform_limit(acb_t res, const acb_t a, const acb_t b, const acb_t c, const acb_t z, int regularized, int which, slong prec) noexcept - # Computes `F(z)` using an argument transformation determined by the flag *which*. - # Legal values are 1 for `z/(z-1)`, - # 2 for `1/z`, 3 for `1/(1-z)`, 4 for `1-z`, and 5 for `1-1/z`. - # The *transform_limit* version assumes that *which* is not 1. - # If *which* is 2 or 3, it assumes that `b-a` represents an exact integer. - # If *which* is 4 or 5, it assumes that `c-a-b` represents an exact integer. - # In these cases, it computes the correct limit value. - # See :func:`acb_hypgeom_2f1` for the meaning of *flags*. - void acb_hypgeom_2f1_corner(acb_t res, const acb_t a, const acb_t b, const acb_t c, const acb_t z, int regularized, slong prec) noexcept - # Computes `F(z)` near the corner cases `\exp(\pm \pi i \sqrt{3})` - # by analytic continuation. - int acb_hypgeom_2f1_choose(const acb_t z) noexcept - # Chooses a method to compute the function based on the location of *z* - # in the complex plane. If the return value is 0, direct summation should be used. - # If the return value is 1 to 5, the transformation with this index in - # :func:`acb_hypgeom_2f1_transform` should be used. - # If the return value is 6, the corner case algorithm should be used. - void acb_hypgeom_2f1(acb_t res, const acb_t a, const acb_t b, const acb_t c, const acb_t z, int flags, slong prec) noexcept - # Computes `F(z)` or `\operatorname{\mathbf{F}}(z)` - # using an automatic algorithm choice. - # The following bit fields can be set in *flags*: - # - *ACB_HYPGEOM_2F1_REGULARIZED* - computes the regularized - # hypergeometric function `\operatorname{\mathbf{F}}(z)`. - # Setting *flags* to 1 is the same as just toggling this option. - # - *ACB_HYPGEOM_2F1_AB* - `a-b` is an integer. - # - *ACB_HYPGEOM_2F1_ABC* - `a+b-c` is an integer. - # - *ACB_HYPGEOM_2F1_AC* - `a-c` is an integer. - # - *ACB_HYPGEOM_2F1_BC* - `b-c` is an integer. - # The last four flags can be set to indicate that the respective parameter - # differences are known to represent exact integers, even if the input intervals - # are inexact. This allows the correct limits to be evaluated when - # applying transformation formulas. For example, to evaluate - # `{}_2F_1(\sqrt{2}, 1/2, \sqrt{2}+3/2, 9/10)`, the *ABC* flag should be set. - # If not set, the result will be an indeterminate interval due to - # internally dividing by an interval containing zero. - # If the parameters are exact floating-point numbers (including exact - # integers or half-integers), then the limits are computed automatically, and - # setting these flags is unnecessary. - # Currently, only the *AB* and *ABC* flags are used this way; - # the *AC* and *BC* flags might be used in the future. - void acb_hypgeom_chebyshev_t(acb_t res, const acb_t n, const acb_t z, slong prec) noexcept - void acb_hypgeom_chebyshev_u(acb_t res, const acb_t n, const acb_t z, slong prec) noexcept - # Computes the Chebyshev polynomial (or Chebyshev function) of first or second kind - # .. math :: - # T_n(z) = {}_2F_1\left(-n,n,\frac{1}{2},\frac{1-z}{2}\right) - # .. math :: - # U_n(z) = (n+1) {}_2F_1\left(-n,n+2,\frac{3}{2},\frac{1-z}{2}\right). - # The hypergeometric series definitions are only used for computation - # near the point 1. In general, trigonometric representations are used. - # For word-size integer *n*, :func:`acb_chebyshev_t_ui` and - # :func:`acb_chebyshev_u_ui` are called. - void acb_hypgeom_jacobi_p(acb_t res, const acb_t n, const acb_t a, const acb_t b, const acb_t z, slong prec) noexcept - # Computes the Jacobi polynomial (or Jacobi function) - # .. math :: - # P_n^{(a,b)}(z)=\frac{(a+1)_n}{\Gamma(n+1)} {}_2F_1\left(-n,n+a+b+1,a+1,\frac{1-z}{2}\right). - # For nonnegative integer *n*, this is a polynomial in *a*, *b* and *z*, - # even when the parameters are such that the hypergeometric series - # is undefined. In such cases, the polynomial is evaluated using - # direct methods. - void acb_hypgeom_gegenbauer_c(acb_t res, const acb_t n, const acb_t m, const acb_t z, slong prec) noexcept - # Computes the Gegenbauer polynomial (or Gegenbauer function) - # .. math :: - # C_n^{m}(z)=\frac{(2m)_n}{\Gamma(n+1)} {}_2F_1\left(-n,2m+n,m+\frac{1}{2},\frac{1-z}{2}\right). - # For nonnegative integer *n*, this is a polynomial in *m* and *z*, - # even when the parameters are such that the hypergeometric series - # is undefined. In such cases, the polynomial is evaluated using - # direct methods. - void acb_hypgeom_laguerre_l(acb_t res, const acb_t n, const acb_t m, const acb_t z, slong prec) noexcept - # Computes the Laguerre polynomial (or Laguerre function) - # .. math :: - # L_n^{m}(z)=\frac{(m+1)_n}{\Gamma(n+1)} {}_1F_1\left(-n,m+1,z\right). - # For nonnegative integer *n*, this is a polynomial in *m* and *z*, - # even when the parameters are such that the hypergeometric series - # is undefined. In such cases, the polynomial is evaluated using - # direct methods. - # There are at least two incompatible ways to define the Laguerre function when - # *n* is a negative integer. One possibility when `m = 0` is to define - # `L_{-n}^0(z) = e^z L_{n-1}^0(-z)`. Another possibility is to cover this - # case with the recurrence relation `L_{n-1}^m(z) + L_n^{m-1}(z) = L_n^m(z)`. - # Currently, we leave this case undefined (returning indeterminate). - void acb_hypgeom_hermite_h(acb_t res, const acb_t n, const acb_t z, slong prec) noexcept - # Computes the Hermite polynomial (or Hermite function) - # .. math :: - # H_n(z) = 2^n \sqrt{\pi} \left( - # \frac{1}{\Gamma((1-n)/2)} {}_1F_1\left(-\frac{n}{2},\frac{1}{2},z^2\right) - # - - # \frac{2z}{\Gamma(-n/2)} {}_1F_1\left(\frac{1-n}{2},\frac{3}{2},z^2\right)\right). - void acb_hypgeom_legendre_p(acb_t res, const acb_t n, const acb_t m, const acb_t z, int type, slong prec) noexcept - # Sets *res* to the associated Legendre function of the first kind - # evaluated for degree *n*, order *m*, and argument *z*. - # When *m* is zero, this reduces to the Legendre polynomial `P_n(z)`. - # Many different branch cut conventions appear in the literature. - # If *type* is 0, the version - # .. math :: - # P_n^m(z) = \frac{(1+z)^{m/2}}{(1-z)^{m/2}} - # \mathbf{F}\left(-n, n+1, 1-m, \frac{1-z}{2}\right) - # is computed, and if *type* is 1, the alternative version - # .. math :: - # {\mathcal P}_n^m(z) = \frac{(z+1)^{m/2}}{(z-1)^{m/2}} - # \mathbf{F}\left(-n, n+1, 1-m, \frac{1-z}{2}\right). - # is computed. Type 0 and type 1 respectively correspond to - # type 2 and type 3 in *Mathematica* and *mpmath*. - void acb_hypgeom_legendre_q(acb_t res, const acb_t n, const acb_t m, const acb_t z, int type, slong prec) noexcept - # Sets *res* to the associated Legendre function of the second kind - # evaluated for degree *n*, order *m*, and argument *z*. - # When *m* is zero, this reduces to the Legendre function `Q_n(z)`. - # Many different branch cut conventions appear in the literature. - # If *type* is 0, the version - # .. math :: - # Q_n^m(z) = \frac{\pi}{2 \sin(\pi m)} - # \left( \cos(\pi m) P_n^m(z) - - # \frac{\Gamma(1+m+n)}{\Gamma(1-m+n)} P_n^{-m}(z)\right) - # is computed, and if *type* is 1, the alternative version - # .. math :: - # \mathcal{Q}_n^m(z) = \frac{\pi}{2 \sin(\pi m)} e^{\pi i m} - # \left( \mathcal{P}_n^m(z) - - # \frac{\Gamma(1+m+n)}{\Gamma(1-m+n)} \mathcal{P}_n^{-m}(z)\right) - # is computed. Type 0 and type 1 respectively correspond to - # type 2 and type 3 in *Mathematica* and *mpmath*. - # When *m* is an integer, either expression is interpreted as a limit. - # We make use of the connection formulas [WQ3a]_, [WQ3b]_ and [WQ3c]_ - # to allow computing the function even in the limiting case. - # (The formula [WQ3d]_ would be useful, but is incorrect in the lower - # half plane.) - # .. [WQ3a] http://functions.wolfram.com/07.11.26.0033.01 - # .. [WQ3b] http://functions.wolfram.com/07.12.27.0014.01 - # .. [WQ3c] http://functions.wolfram.com/07.12.26.0003.01 - # .. [WQ3d] http://functions.wolfram.com/07.12.26.0088.01 - void acb_hypgeom_legendre_p_uiui_rec(acb_t res, ulong n, ulong m, const acb_t z, slong prec) noexcept - # For nonnegative integer *n* and *m*, uses recurrence relations to evaluate - # `(1-z^2)^{-m/2} P_n^m(z)` which is a polynomial in *z*. - void acb_hypgeom_spherical_y(acb_t res, slong n, slong m, const acb_t theta, const acb_t phi, slong prec) noexcept - # Computes the spherical harmonic of degree *n*, order *m*, - # latitude angle *theta*, and longitude angle *phi*, normalized - # such that - # .. math :: - # Y_n^m(\theta, \phi) = \sqrt{\frac{2n+1}{4\pi} \frac{(n-m)!}{(n+m)!}} e^{im\phi} P_n^m(\cos(\theta)). - # The definition is extended to negative *m* and *n* by symmetry. - # This function is a polynomial in `\cos(\theta)` and `\sin(\theta)`. - # We evaluate it using :func:`acb_hypgeom_legendre_p_uiui_rec`. - void acb_hypgeom_dilog_zero_taylor(acb_t res, const acb_t z, slong prec) noexcept - # Computes the dilogarithm for *z* close to 0 using the hypergeometric series - # (effective only when `|z| \ll 1`). - void acb_hypgeom_dilog_zero(acb_t res, const acb_t z, slong prec) noexcept - # Computes the dilogarithm for *z* close to 0, using the bit-burst algorithm - # instead of the hypergeometric series directly at very high precision. - void acb_hypgeom_dilog_transform(acb_t res, const acb_t z, int algorithm, slong prec) noexcept - # Computes the dilogarithm by applying one of the transformations - # `1/z`, `1-z`, `z/(z-1)`, `1/(1-z)`, indexed by *algorithm* from 1 to 4, - # and calling :func:`acb_hypgeom_dilog_zero` with the reduced variable. - # Alternatively, for *algorithm* between 5 and 7, starts from the - # respective point `\pm i`, `(1\pm i)/2`, `(1\pm i)/2` (with the sign - # chosen according to the midpoint of *z*) - # and computes the dilogarithm by the bit-burst method. - void acb_hypgeom_dilog_continuation(acb_t res, const acb_t a, const acb_t z, slong prec) noexcept - # Computes `\operatorname{Li}_2(z) - \operatorname{Li}_2(a)` using - # Taylor expansion at *a*. Binary splitting is used. Both *a* and *z* - # should be well isolated from the points 0 and 1, except that *a* may - # be exactly 0. If the straight line path from *a* to *b* crosses the branch - # cut, this method provides continuous analytic continuation instead of - # computing the principal branch. - void acb_hypgeom_dilog_bitburst(acb_t res, acb_t z0, const acb_t z, slong prec) noexcept - # Sets *z0* to a point with short bit expansion close to *z* and sets - # *res* to `\operatorname{Li}_2(z) - \operatorname{Li}_2(z_0)`, computed - # using the bit-burst algorithm. - void acb_hypgeom_dilog(acb_t res, const acb_t z, slong prec) noexcept - # Computes the dilogarithm using a default algorithm choice. diff --git a/src/sage/libs/flint/acb_macros.pxd b/src/sage/libs/flint/acb_macros.pxd index ec352a9c264..26ef61206bc 100644 --- a/src/sage/libs/flint/acb_macros.pxd +++ b/src/sage/libs/flint/acb_macros.pxd @@ -1,11 +1,8 @@ # Macros from acb.h -# See https://github.com/flintlib/flint/issues/152 +# See https://github.com/flintlib/flint/issues/1529 from .types cimport * cdef extern from "flint_wrap.h": arb_ptr acb_realref(acb_t x) - # Macro giving a pointer to the real part of x - arb_ptr acb_imagref(acb_t x) - # Macro giving a pointer to the imaginary part of x diff --git a/src/sage/libs/flint/acb_mat.pxd b/src/sage/libs/flint/acb_mat.pxd index 521af44f0c0..031913ab07a 100644 --- a/src/sage/libs/flint/acb_mat.pxd +++ b/src/sage/libs/flint/acb_mat.pxd @@ -2,7 +2,9 @@ # distutils: depends = flint/acb_mat.h ################################################################################ -# This file is auto-generated. Do not modify by hand +# This file is auto-generated by the script +# SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py. +# Do not modify by hand! Fix and rerun the script instead. ################################################################################ from libc.stdio cimport FILE @@ -11,562 +13,122 @@ from sage.libs.mpfr.types cimport * from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void acb_mat_init(acb_mat_t mat, slong r, slong c) noexcept - # Initializes the matrix, setting it to the zero matrix with *r* rows - # and *c* columns. - void acb_mat_clear(acb_mat_t mat) noexcept - # Clears the matrix, deallocating all entries. - slong acb_mat_allocated_bytes(const acb_mat_t x) noexcept - # Returns the total number of bytes heap-allocated internally by this object. - # The count excludes the size of the structure itself. Add - # ``sizeof(acb_mat_struct)`` to get the size of the object as a whole. - void acb_mat_window_init(acb_mat_t window, const acb_mat_t mat, slong r1, slong c1, slong r2, slong c2) noexcept - # Initializes *window* to a window matrix into the submatrix of *mat* - # starting at the corner at row *r1* and column *c1* (inclusive) and ending - # at row *r2* and column *c2* (exclusive). - void acb_mat_window_clear(acb_mat_t window) noexcept - # Frees the window matrix. - void acb_mat_set(acb_mat_t dest, const acb_mat_t src) noexcept - void acb_mat_set_fmpz_mat(acb_mat_t dest, const fmpz_mat_t src) noexcept - void acb_mat_set_round_fmpz_mat(acb_mat_t dest, const fmpz_mat_t src, slong prec) noexcept - void acb_mat_set_fmpq_mat(acb_mat_t dest, const fmpq_mat_t src, slong prec) noexcept - void acb_mat_set_arb_mat(acb_mat_t dest, const arb_mat_t src) noexcept - void acb_mat_set_round_arb_mat(acb_mat_t dest, const arb_mat_t src, slong prec) noexcept - # Sets *dest* to *src*. The operands must have identical dimensions. - + void acb_mat_get_real(arb_mat_t re, const arb_mat_t mat) noexcept + void acb_mat_get_imag(arb_mat_t im, const arb_mat_t mat) noexcept + void acb_mat_set_real_imag(acb_mat_t mat, const arb_mat_t re, const arb_mat_t im) noexcept void acb_mat_randtest(acb_mat_t mat, flint_rand_t state, slong prec, slong mag_bits) noexcept - # Sets *mat* to a random matrix with up to *prec* bits of precision - # and with exponents of width up to *mag_bits*. - void acb_mat_randtest_eig(acb_mat_t mat, flint_rand_t state, acb_srcptr E, slong prec) noexcept - # Sets *mat* to a random matrix with the prescribed eigenvalues - # supplied as the vector *E*. The output matrix is required to be - # square. We generate a random unitary matrix via a matrix - # exponential, and then evaluate an inverse Schur decomposition. - void acb_mat_printd(const acb_mat_t mat, slong digits) noexcept - # Prints each entry in the matrix with the specified number of decimal digits. - void acb_mat_fprintd(FILE * file, const acb_mat_t mat, slong digits) noexcept - # Prints each entry in the matrix with the specified number of decimal - # digits to the stream *file*. - bint acb_mat_equal(const acb_mat_t mat1, const acb_mat_t mat2) noexcept - # Returns whether the matrices have the same dimensions and identical - # intervals as entries. - bint acb_mat_overlaps(const acb_mat_t mat1, const acb_mat_t mat2) noexcept - # Returns whether the matrices have the same dimensions - # and each entry in *mat1* overlaps with the corresponding entry in *mat2*. - bint acb_mat_contains(const acb_mat_t mat1, const acb_mat_t mat2) noexcept - bint acb_mat_contains_fmpz_mat(const acb_mat_t mat1, const fmpz_mat_t mat2) noexcept - bint acb_mat_contains_fmpq_mat(const acb_mat_t mat1, const fmpq_mat_t mat2) noexcept - # Returns whether the matrices have the same dimensions and each entry - # in *mat2* is contained in the corresponding entry in *mat1*. - bint acb_mat_eq(const acb_mat_t mat1, const acb_mat_t mat2) noexcept - # Returns whether *mat1* and *mat2* certainly represent the same matrix. - bint acb_mat_ne(const acb_mat_t mat1, const acb_mat_t mat2) noexcept - # Returns whether *mat1* and *mat2* certainly do not represent the same matrix. - bint acb_mat_is_real(const acb_mat_t mat) noexcept - # Returns whether all entries in *mat* have zero imaginary part. - bint acb_mat_is_empty(const acb_mat_t mat) noexcept - # Returns whether the number of rows or the number of columns in *mat* is zero. - bint acb_mat_is_square(const acb_mat_t mat) noexcept - # Returns whether the number of rows is equal to the number of columns in *mat*. - bint acb_mat_is_exact(const acb_mat_t mat) noexcept - # Returns whether all entries in *mat* have zero radius. - bint acb_mat_is_zero(const acb_mat_t mat) noexcept - # Returns whether all entries in *mat* are exactly zero. - bint acb_mat_is_finite(const acb_mat_t mat) noexcept - # Returns whether all entries in *mat* are finite. - bint acb_mat_is_triu(const acb_mat_t mat) noexcept - # Returns whether *mat* is upper triangular; that is, all entries - # below the main diagonal are exactly zero. - bint acb_mat_is_tril(const acb_mat_t mat) noexcept - # Returns whether *mat* is lower triangular; that is, all entries - # above the main diagonal are exactly zero. - bint acb_mat_is_diag(const acb_mat_t mat) noexcept - # Returns whether *mat* is a diagonal matrix; that is, all entries - # off the main diagonal are exactly zero. - void acb_mat_zero(acb_mat_t mat) noexcept - # Sets all entries in mat to zero. - void acb_mat_one(acb_mat_t mat) noexcept - # Sets the entries on the main diagonal to ones, - # and all other entries to zero. - void acb_mat_ones(acb_mat_t mat) noexcept - # Sets all entries in the matrix to ones. - + void acb_mat_onei(acb_mat_t mat) noexcept void acb_mat_indeterminate(acb_mat_t mat) noexcept - # Sets all entries in the matrix to indeterminate (NaN). - void acb_mat_dft(acb_mat_t mat, int type, slong prec) noexcept - # Sets *mat* to the DFT (discrete Fourier transform) matrix of order *n* - # where *n* is the smallest dimension of *mat* (if *mat* is not square, - # the matrix is extended periodically along the larger dimension). - # Here, we use the normalized DFT matrix - # .. math :: - # A_{j,k} = \frac{\omega^{jk}}{\sqrt{n}}, \quad \omega = e^{-2\pi i/n}. - # The *type* parameter is currently ignored and should be set to 0. - # In the future, it might be used to select a different convention. - void acb_mat_transpose(acb_mat_t dest, const acb_mat_t src) noexcept - # Sets *dest* to the exact transpose *src*. The operands must have - # compatible dimensions. Aliasing is allowed. - void acb_mat_conjugate_transpose(acb_mat_t dest, const acb_mat_t src) noexcept - # Sets *dest* to the conjugate transpose of *src*. The operands must have - # compatible dimensions. Aliasing is allowed. - void acb_mat_conjugate(acb_mat_t dest, const acb_mat_t src) noexcept - # Sets *dest* to the elementwise complex conjugate of *src*. - void acb_mat_bound_inf_norm(mag_t b, const acb_mat_t A) noexcept - # Sets *b* to an upper bound for the infinity norm (i.e. the largest - # absolute value row sum) of *A*. - void acb_mat_frobenius_norm(arb_t res, const acb_mat_t A, slong prec) noexcept - # Sets *res* to the Frobenius norm (i.e. the square root of the sum - # of squares of entries) of *A*. - void acb_mat_bound_frobenius_norm(mag_t res, const acb_mat_t A) noexcept - # Sets *res* to an upper bound for the Frobenius norm of *A*. - void acb_mat_neg(acb_mat_t dest, const acb_mat_t src) noexcept - # Sets *dest* to the exact negation of *src*. The operands must have - # the same dimensions. - void acb_mat_add(acb_mat_t res, const acb_mat_t mat1, const acb_mat_t mat2, slong prec) noexcept - # Sets res to the sum of *mat1* and *mat2*. The operands must have the same dimensions. - void acb_mat_sub(acb_mat_t res, const acb_mat_t mat1, const acb_mat_t mat2, slong prec) noexcept - # Sets *res* to the difference of *mat1* and *mat2*. The operands must have - # the same dimensions. - void acb_mat_mul_classical(acb_mat_t res, const acb_mat_t mat1, const acb_mat_t mat2, slong prec) noexcept - void acb_mat_mul_threaded(acb_mat_t res, const acb_mat_t mat1, const acb_mat_t mat2, slong prec) noexcept - void acb_mat_mul_reorder(acb_mat_t res, const acb_mat_t mat1, const acb_mat_t mat2, slong prec) noexcept - void acb_mat_mul(acb_mat_t res, const acb_mat_t mat1, const acb_mat_t mat2, slong prec) noexcept - # Sets *res* to the matrix product of *mat1* and *mat2*. The operands must have - # compatible dimensions for matrix multiplication. - # The *classical* version performs matrix multiplication in the trivial way. - # The *threaded* version performs classical multiplication but splits the - # computation over the number of threads returned by *flint_get_num_threads()*. - # The *reorder* version reorders the data and performs one to four real - # matrix multiplications via :func:`arb_mat_mul`. - # The default version chooses an algorithm automatically. - void acb_mat_mul_entrywise(acb_mat_t res, const acb_mat_t mat1, const acb_mat_t mat2, slong prec) noexcept - # Sets *res* to the entrywise product of *mat1* and *mat2*. - # The operands must have the same dimensions. - void acb_mat_sqr_classical(acb_mat_t res, const acb_mat_t mat, slong prec) noexcept - void acb_mat_sqr(acb_mat_t res, const acb_mat_t mat, slong prec) noexcept - # Sets *res* to the matrix square of *mat*. The operands must both be square - # with the same dimensions. - void acb_mat_pow_ui(acb_mat_t res, const acb_mat_t mat, ulong exp, slong prec) noexcept - # Sets *res* to *mat* raised to the power *exp*. Requires that *mat* - # is a square matrix. - void acb_mat_approx_mul(acb_mat_t res, const acb_mat_t mat1, const acb_mat_t mat2, slong prec) noexcept - # Approximate matrix multiplication. The input radii are ignored and - # the output matrix is set to an approximate floating-point result. - # For performance reasons, the radii in the output matrix will *not* - # necessarily be written (zeroed), but will remain zero if they - # are already zeroed in *res* before calling this function. - void acb_mat_scalar_mul_2exp_si(acb_mat_t B, const acb_mat_t A, slong c) noexcept - # Sets *B* to *A* multiplied by `2^c`. - void acb_mat_scalar_addmul_si(acb_mat_t B, const acb_mat_t A, slong c, slong prec) noexcept - void acb_mat_scalar_addmul_fmpz(acb_mat_t B, const acb_mat_t A, const fmpz_t c, slong prec) noexcept - void acb_mat_scalar_addmul_arb(acb_mat_t B, const acb_mat_t A, const arb_t c, slong prec) noexcept - void acb_mat_scalar_addmul_acb(acb_mat_t B, const acb_mat_t A, const acb_t c, slong prec) noexcept - # Sets *B* to `B + A \times c`. - void acb_mat_scalar_mul_si(acb_mat_t B, const acb_mat_t A, slong c, slong prec) noexcept - void acb_mat_scalar_mul_fmpz(acb_mat_t B, const acb_mat_t A, const fmpz_t c, slong prec) noexcept - void acb_mat_scalar_mul_arb(acb_mat_t B, const acb_mat_t A, const arb_t c, slong prec) noexcept - void acb_mat_scalar_mul_acb(acb_mat_t B, const acb_mat_t A, const acb_t c, slong prec) noexcept - # Sets *B* to `A \times c`. - void acb_mat_scalar_div_si(acb_mat_t B, const acb_mat_t A, slong c, slong prec) noexcept - void acb_mat_scalar_div_fmpz(acb_mat_t B, const acb_mat_t A, const fmpz_t c, slong prec) noexcept - void acb_mat_scalar_div_arb(acb_mat_t B, const acb_mat_t A, const arb_t c, slong prec) noexcept - void acb_mat_scalar_div_acb(acb_mat_t B, const acb_mat_t A, const acb_t c, slong prec) noexcept - # Sets *B* to `A / c`. - + void _acb_mat_vector_mul_row(acb_ptr res, acb_srcptr v, const acb_mat_t A, slong prec) noexcept + void _acb_mat_vector_mul_col(acb_ptr res, const acb_mat_t A, acb_srcptr v, slong prec) noexcept + void acb_mat_vector_mul_row(acb_ptr res, acb_srcptr v, const acb_mat_t A, slong prec) noexcept + void acb_mat_vector_mul_col(acb_ptr res, const acb_mat_t A, acb_srcptr v, slong prec) noexcept int acb_mat_lu_classical(slong * perm, acb_mat_t LU, const acb_mat_t A, slong prec) noexcept - int acb_mat_lu_recursive(slong * perm, acb_mat_t LU, const acb_mat_t A, slong prec) noexcept - int acb_mat_lu(slong * perm, acb_mat_t LU, const acb_mat_t A, slong prec) noexcept - # Given an `n \times n` matrix `A`, computes an LU decomposition `PLU = A` - # using Gaussian elimination with partial pivoting. - # The input and output matrices can be the same, performing the - # decomposition in-place. - # Entry `i` in the permutation vector perm is set to the row index in - # the input matrix corresponding to row `i` in the output matrix. - # The algorithm succeeds and returns nonzero if it can find `n` invertible - # (i.e. not containing zero) pivot entries. This guarantees that the matrix - # is invertible. - # The algorithm fails and returns zero, leaving the entries in `P` and `LU` - # undefined, if it cannot find `n` invertible pivot elements. - # In this case, either the matrix is singular, the input matrix was - # computed to insufficient precision, or the LU decomposition was - # attempted at insufficient precision. - # The *classical* version uses Gaussian elimination directly while - # the *recursive* version performs the computation in a block recursive - # way to benefit from fast matrix multiplication. The default version - # chooses an algorithm automatically. - void acb_mat_solve_tril_classical(acb_mat_t X, const acb_mat_t L, const acb_mat_t B, int unit, slong prec) noexcept - void acb_mat_solve_tril_recursive(acb_mat_t X, const acb_mat_t L, const acb_mat_t B, int unit, slong prec) noexcept - void acb_mat_solve_tril(acb_mat_t X, const acb_mat_t L, const acb_mat_t B, int unit, slong prec) noexcept - void acb_mat_solve_triu_classical(acb_mat_t X, const acb_mat_t U, const acb_mat_t B, int unit, slong prec) noexcept - void acb_mat_solve_triu_recursive(acb_mat_t X, const acb_mat_t U, const acb_mat_t B, int unit, slong prec) noexcept - void acb_mat_solve_triu(acb_mat_t X, const acb_mat_t U, const acb_mat_t B, int unit, slong prec) noexcept - # Solves the lower triangular system `LX = B` or the upper triangular system - # `UX = B`, respectively. If *unit* is set, the main diagonal of *L* or *U* - # is taken to consist of all ones, and in that case the actual entries on - # the diagonal are not read at all and can contain other data. - # The *classical* versions perform the computations iteratively while the - # *recursive* versions perform the computations in a block recursive - # way to benefit from fast matrix multiplication. The default versions - # choose an algorithm automatically. - void acb_mat_solve_lu_precomp(acb_mat_t X, const slong * perm, const acb_mat_t LU, const acb_mat_t B, slong prec) noexcept - # Solves `AX = B` given the precomputed nonsingular LU decomposition `A = PLU`. - # The matrices `X` and `B` are allowed to be aliased with each other, - # but `X` is not allowed to be aliased with `LU`. - int acb_mat_solve(acb_mat_t X, const acb_mat_t A, const acb_mat_t B, slong prec) noexcept - int acb_mat_solve_lu(acb_mat_t X, const acb_mat_t A, const acb_mat_t B, slong prec) noexcept - int acb_mat_solve_precond(acb_mat_t X, const acb_mat_t A, const acb_mat_t B, slong prec) noexcept - # Solves `AX = B` where `A` is a nonsingular `n \times n` matrix - # and `X` and `B` are `n \times m` matrices. - # If `m > 0` and `A` cannot be inverted numerically (indicating either that - # `A` is singular or that the precision is insufficient), the values in the - # output matrix are left undefined and zero is returned. A nonzero return - # value guarantees that `A` is invertible and that the exact solution - # matrix is contained in the output. - # Three algorithms are provided: - # * The *lu* version performs LU decomposition directly in ball arithmetic. - # This is fast, but the bounds typically blow up exponentially with *n*, - # even if the system is well-conditioned. This algorithm is usually - # the best choice at very high precision. - # * The *precond* version computes an approximate inverse to precondition - # the system. This is usually several times slower than direct LU - # decomposition, but the bounds do not blow up with *n* if the system is - # well-conditioned. This algorithm is usually - # the best choice for large systems at low to moderate precision. - # * The default version selects between *lu* and *precomp* automatically. - # The automatic choice should be reasonable most of the time, but users - # may benefit from trying either *lu* or *precond* in specific applications. - # For example, the *lu* solver often performs better for ill-conditioned - # systems where use of very high precision is unavoidable. - int acb_mat_inv(acb_mat_t X, const acb_mat_t A, slong prec) noexcept - # Sets `X = A^{-1}` where `A` is a square matrix, computed by solving - # the system `AX = I`. - # If `A` cannot be inverted numerically (indicating either that - # `A` is singular or that the precision is insufficient), the values in the - # output matrix are left undefined and zero is returned. - # A nonzero return value guarantees that the matrix is invertible - # and that the exact inverse is contained in the output. - void acb_mat_det_lu(acb_t det, const acb_mat_t A, slong prec) noexcept - void acb_mat_det_precond(acb_t det, const acb_mat_t A, slong prec) noexcept - void acb_mat_det(acb_t det, const acb_mat_t A, slong prec) noexcept - # Sets *det* to the determinant of the matrix *A*. - # The *lu* version uses Gaussian elimination with partial pivoting. If at - # some point an invertible pivot element cannot be found, the elimination is - # stopped and the magnitude of the determinant of the remaining submatrix - # is bounded using Hadamard's inequality. - # The *precond* version computes an approximate LU factorization of *A* - # and multiplies by the inverse *L* and *U* martices as preconditioners - # to obtain a matrix close to the identity matrix [Rum2010]_. An enclosure - # for this determinant is computed using Gershgorin circles. This is about - # four times slower than direct Gaussian elimination, but much more - # numerically stable. - # The default version automatically selects between the *lu* and *precond* - # versions and additionally handles small or triangular matrices - # by direct formulas. - void acb_mat_approx_solve_triu(acb_mat_t X, const acb_mat_t U, const acb_mat_t B, int unit, slong prec) noexcept - void acb_mat_approx_solve_tril(acb_mat_t X, const acb_mat_t L, const acb_mat_t B, int unit, slong prec) noexcept - int acb_mat_approx_lu(slong * P, acb_mat_t LU, const acb_mat_t A, slong prec) noexcept - void acb_mat_approx_solve_lu_precomp(acb_mat_t X, const slong * perm, const acb_mat_t A, const acb_mat_t B, slong prec) noexcept - int acb_mat_approx_solve(acb_mat_t X, const acb_mat_t A, const acb_mat_t B, slong prec) noexcept - int acb_mat_approx_inv(acb_mat_t X, const acb_mat_t A, slong prec) noexcept - # These methods perform approximate solving *without any error control*. - # The radii in the input matrices are ignored, the computations are done - # numerically with floating-point arithmetic (using ordinary - # Gaussian elimination and triangular solving, accelerated through - # the use of block recursive strategies for large matrices), and the - # output matrices are set to the approximate floating-point results with - # zeroed error bounds. - void _acb_mat_charpoly(acb_ptr poly, const acb_mat_t mat, slong prec) noexcept - void acb_mat_charpoly(acb_poly_t poly, const acb_mat_t mat, slong prec) noexcept - # Sets *poly* to the characteristic polynomial of *mat* which must be - # a square matrix. If the matrix has *n* rows, the underscore method - # requires space for `n + 1` output coefficients. - # Employs a division-free algorithm using `O(n^4)` operations. - void _acb_mat_companion(acb_mat_t mat, acb_srcptr poly, slong prec) noexcept - void acb_mat_companion(acb_mat_t mat, const acb_poly_t poly, slong prec) noexcept - # Sets the *n* by *n* matrix *mat* to the companion matrix of the polynomial - # *poly* which must have degree *n*. - # The underscore method reads `n + 1` input coefficients. - void acb_mat_exp_taylor_sum(acb_mat_t S, const acb_mat_t A, slong N, slong prec) noexcept - # Sets *S* to the truncated exponential Taylor series `S = \sum_{k=0}^{N-1} A^k / k!`. - # See :func:`arb_mat_exp_taylor_sum` for implementation notes. - void acb_mat_exp(acb_mat_t B, const acb_mat_t A, slong prec) noexcept - # Sets *B* to the exponential of the matrix *A*, defined by the Taylor series - # .. math :: - # \exp(A) = \sum_{k=0}^{\infty} \frac{A^k}{k!}. - # The function is evaluated as `\exp(A/2^r)^{2^r}`, where `r` is chosen - # to give rapid convergence of the Taylor series. - # Error bounds are computed as for :func:`arb_mat_exp`. - void acb_mat_trace(acb_t trace, const acb_mat_t mat, slong prec) noexcept - # Sets *trace* to the trace of the matrix, i.e. the sum of entries on the - # main diagonal of *mat*. The matrix is required to be square. - void _acb_mat_diag_prod(acb_t res, const acb_mat_t mat, slong a, slong b, slong prec) noexcept - void acb_mat_diag_prod(acb_t res, const acb_mat_t mat, slong prec) noexcept - # Sets *res* to the product of the entries on the main diagonal of *mat*. - # The underscore method computes the product of the entries between - # index *a* inclusive and *b* exclusive (the indices must be in range). - void acb_mat_get_mid(acb_mat_t B, const acb_mat_t A) noexcept - # Sets the entries of *B* to the exact midpoints of the entries of *A*. - void acb_mat_add_error_mag(acb_mat_t mat, const mag_t err) noexcept - # Adds *err* in-place to the radii of the entries of *mat*. - int acb_mat_approx_eig_qr(acb_ptr E, acb_mat_t L, acb_mat_t R, const acb_mat_t A, const mag_t tol, slong maxiter, slong prec) noexcept - # Computes floating-point approximations of all the *n* eigenvalues - # (and optionally eigenvectors) of the - # given *n* by *n* matrix *A*. The approximations of the - # eigenvalues are written to the vector *E*, in no particular order. - # If *L* is not *NULL*, approximations of the corresponding left - # eigenvectors are written to the rows of *L*. If *R* is not *NULL*, - # approximations of the corresponding - # right eigenvectors are written to the columns of *R*. - # The parameters *tol* and *maxiter* can be used to control the - # target numerical error and the maximum number of iterations - # allowed before giving up. Passing *NULL* and 0 respectively results - # in default values being used. - # Uses the implicitly shifted QR algorithm with reduction - # to Hessenberg form. - # No guarantees are made about the accuracy of the output. A nonzero - # return value indicates that the QR iteration converged numerically, - # but this is only a heuristic termination test and does not imply - # any statement whatsoever about error bounds. - # The output may also be accurate even if this function returns zero. - void acb_mat_eig_global_enclosure(mag_t eps, const acb_mat_t A, acb_srcptr E, const acb_mat_t R, slong prec) noexcept - # Given an *n* by *n* matrix *A*, a length-*n* vector *E* - # containing approximations of the eigenvalues of *A*, - # and an *n* by *n* matrix *R* containing approximations of - # the corresponding right eigenvectors, computes a rigorous bound - # `\varepsilon` such that every eigenvalue `\lambda` of *A* satisfies - # `|\lambda - \hat \lambda_k| \le \varepsilon` - # for some `\hat \lambda_k` in *E*. - # In other words, the union of the balls - # `B_k = \{z : |z - \hat \lambda_k| \le \varepsilon\}` is guaranteed to - # be an enclosure of all eigenvalues of *A*. - # Note that there is no guarantee that each ball `B_k` can be - # identified with a single eigenvalue: it is possible that some - # balls contain several eigenvalues while other balls contain - # no eigenvalues. In other words, this method is not powerful enough - # to compute isolating balls for the individual eigenvalues (or even - # for clusters of eigenvalues other than the whole spectrum). - # Nevertheless, in practice the balls `B_k` will represent - # eigenvalues one-to-one with high probability if the - # given approximations are good. - # The output can be used to certify - # that all eigenvalues of *A* lie in some region of the complex - # plane (such as a specific half-plane, strip, disk, or annulus) - # without the need to certify the individual eigenvalues. - # The output is easily converted into lower or upper bounds - # for the absolute values or real or imaginary parts - # of the spectrum, and with high probability these bounds will be tight. - # Using :func:`acb_add_error_mag` and :func:`acb_union`, the output - # can also be converted to a single :type:`acb_t` enclosing - # the whole spectrum of *A* in a rectangle, but note that to - # test whether a condition holds for all eigenvalues of *A*, it - # is typically better to iterate over the individual balls `B_k`. - # This function implements the fast algorithm in Theorem 1 in - # [Miy2010]_ which extends the Bauer-Fike theorem. Approximations - # *E* and *R* can, for instance, be computed using - # :func:`acb_mat_approx_eig_qr`. - # No assumptions are made about the structure of *A* or the - # quality of the given approximations. - void acb_mat_eig_enclosure_rump(acb_t lmbda, acb_mat_t J, acb_mat_t R, const acb_mat_t A, const acb_t lambda_approx, const acb_mat_t R_approx, slong prec) noexcept - # Given an *n* by *n* matrix *A* and an approximate - # eigenvalue-eigenvector pair *lambda_approx* and *R_approx* (where - # *R_approx* is an *n* by 1 matrix), computes an enclosure - # *lambda* guaranteed to contain at least one of the eigenvalues of *A*, - # along with an enclosure *R* for a corresponding right eigenvector. - # More generally, this function can handle clustered (or repeated) - # eigenvalues. If *R_approx* is an *n* by *k* - # matrix containing approximate eigenvectors for a presumed cluster - # of *k* eigenvalues near *lambda_approx*, - # this function computes an enclosure *lambda* - # guaranteed to contain at - # least *k* eigenvalues of *A* along with a matrix *R* guaranteed to - # contain a basis for the *k*-dimensional invariant subspace - # associated with these eigenvalues. - # Note that for multiple eigenvalues, determining the individual eigenvectors is - # an ill-posed problem; describing an enclosure of the invariant subspace - # is the best we can hope for. - # For `k = 1`, it is guaranteed that `AR - R \lambda` contains - # the zero matrix. For `k > 2`, this cannot generally be guaranteed - # (in particular, *A* might not diagonalizable). - # In this case, we can still compute an approximately diagonal - # *k* by *k* interval matrix `J \approx \lambda I` such that `AR - RJ` - # is guaranteed to contain the zero matrix. - # This matrix has the property that the Jordan canonical form of - # (any exact matrix contained in) *A* has a *k* by *k* submatrix - # equal to the Jordan canonical form of - # (some exact matrix contained in) *J*. - # The output *J* is optional (the user can pass *NULL* to omit it). - # The algorithm follows section 13.4 in [Rum2010]_, corresponding - # to the ``verifyeig()`` routine in INTLAB. - # The initial approximations can, for instance, be computed using - # :func:`acb_mat_approx_eig_qr`. - # No assumptions are made about the structure of *A* or the - # quality of the given approximations. - int acb_mat_eig_simple_rump(acb_ptr E, acb_mat_t L, acb_mat_t R, const acb_mat_t A, acb_srcptr E_approx, const acb_mat_t R_approx, slong prec) noexcept - int acb_mat_eig_simple_vdhoeven_mourrain(acb_ptr E, acb_mat_t L, acb_mat_t R, const acb_mat_t A, acb_srcptr E_approx, const acb_mat_t R_approx, slong prec) noexcept - int acb_mat_eig_simple(acb_ptr E, acb_mat_t L, acb_mat_t R, const acb_mat_t A, acb_srcptr E_approx, const acb_mat_t R_approx, slong prec) noexcept - # Computes all the eigenvalues (and optionally corresponding - # eigenvectors) of the given *n* by *n* matrix *A*. - # Attempts to prove that *A* has *n* simple (isolated) - # eigenvalues, returning 1 if successful - # and 0 otherwise. On success, isolating complex intervals for the - # eigenvalues are written to the vector *E*, in no particular order. - # If *L* is not *NULL*, enclosures of the corresponding left - # eigenvectors are written to the rows of *L*. If *R* is not *NULL*, - # enclosures of the corresponding - # right eigenvectors are written to the columns of *R*. - # The left eigenvectors are normalized so that `L = R^{-1}`. - # This produces a diagonalization `LAR = D` where *D* is the - # diagonal matrix with the entries in *E* on the diagonal. - # The user supplies approximations *E_approx* and *R_approx* - # of the eigenvalues and the right eigenvectors. - # The initial approximations can, for instance, be computed using - # :func:`acb_mat_approx_eig_qr`. - # No assumptions are made about the structure of *A* or the - # quality of the given approximations. - # Two algorithms are implemented: - # * The *rump* version calls :func:`acb_mat_eig_enclosure_rump` repeatedly - # to certify eigenvalue-eigenvector pairs one by one. The iteration is - # stopped to return non-success if a new eigenvalue overlaps with - # previously computed one. Finally, *L* is computed by a matrix inversion. - # This has complexity `O(n^4)`. - # * The *vdhoeven_mourrain* version uses the algorithm in [HM2017]_ to - # certify all eigenvalues and eigenvectors in one step. This has - # complexity `O(n^3)`. - # The default version currently uses *vdhoeven_mourrain*. - # By design, these functions terminate instead of attempting to - # compute eigenvalue clusters if some eigenvalues cannot be isolated. - # To compute all eigenvalues of a matrix allowing for overlap, - # :func:`acb_mat_eig_multiple_rump` may be used as a fallback, - # or :func:`acb_mat_eig_multiple` may be used in the first place. - int acb_mat_eig_multiple_rump(acb_ptr E, const acb_mat_t A, acb_srcptr E_approx, const acb_mat_t R_approx, slong prec) noexcept - int acb_mat_eig_multiple(acb_ptr E, const acb_mat_t A, acb_srcptr E_approx, const acb_mat_t R_approx, slong prec) noexcept - # Computes all the eigenvalues of the given *n* by *n* matrix *A*. - # On success, the output vector *E* contains *n* complex intervals, - # each representing one eigenvalue of *A* with the correct - # multiplicities in case of overlap. - # The output intervals are either disjoint or identical, and - # identical intervals are guaranteed to be grouped consecutively. - # Each complete run of *k* identical intervals thus represents a cluster of - # exactly *k* eigenvalues which could not be separated from each - # other at the current precision, but which could be isolated - # from the other `n - k` eigenvalues of the matrix. - # The user supplies approximations *E_approx* and *R_approx* - # of the eigenvalues and the right eigenvectors. - # The initial approximations can, for instance, be computed using - # :func:`acb_mat_approx_eig_qr`. - # No assumptions are made about the structure of *A* or the - # quality of the given approximations. - # The *rump* algorithm groups approximate eigenvalues that are close - # and calls :func:`acb_mat_eig_enclosure_rump` repeatedly to validate - # each cluster. The complexity is `O(m n^3)` for *m* clusters. - # The default version, as currently implemented, first attempts to - # call :func:`acb_mat_eig_simple_vdhoeven_mourrain` hoping that the - # eigenvalues are actually simple. It then uses the *rump* algorithm as - # a fallback. from .acb_mat_macros cimport * diff --git a/src/sage/libs/flint/acb_mat_macros.pxd b/src/sage/libs/flint/acb_mat_macros.pxd index 7803cc4a945..36b95b8f6df 100644 --- a/src/sage/libs/flint/acb_mat_macros.pxd +++ b/src/sage/libs/flint/acb_mat_macros.pxd @@ -1,14 +1,9 @@ # Macros from acb_mat.h -# See https://github.com/flintlib/flint/issues/152 +# See https://github.com/flintlib/flint/issues/1529 from .types cimport * cdef extern from "flint_wrap.h": acb_ptr acb_mat_entry(acb_mat_t mat, slong i, slong j) - # Macro giving a pointer to the entry at row *i* and column *j*. - slong acb_mat_nrows(acb_mat_t) - # Returns the number of rows of the matrix. - slong acb_mat_ncols(acb_mat_t) - # Returns the number of columns of the matrix. diff --git a/src/sage/libs/flint/acb_modular.pxd b/src/sage/libs/flint/acb_modular.pxd index f45c197338e..8a6b824883d 100644 --- a/src/sage/libs/flint/acb_modular.pxd +++ b/src/sage/libs/flint/acb_modular.pxd @@ -2,7 +2,9 @@ # distutils: depends = flint/acb_modular.h ################################################################################ -# This file is auto-generated. Do not modify by hand +# This file is auto-generated by the script +# SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py. +# Do not modify by hand! Fix and rerun the script instead. ################################################################################ from libc.stdio cimport FILE @@ -11,369 +13,48 @@ from sage.libs.mpfr.types cimport * from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void psl2z_init(psl2z_t g) noexcept - # Initializes *g* and set it to the identity element. - void psl2z_clear(psl2z_t g) noexcept - # Clears *g*. - void psl2z_swap(psl2z_t f, psl2z_t g) noexcept - # Swaps *f* and *g* efficiently. - void psl2z_set(psl2z_t f, const psl2z_t g) noexcept - # Sets *f* to a copy of *g*. - void psl2z_one(psl2z_t g) noexcept - # Sets *g* to the identity element. - bint psl2z_is_one(const psl2z_t g) noexcept - # Returns nonzero iff *g* is the identity element. - void psl2z_print(const psl2z_t g) noexcept - # Prints *g* to standard output. - void psl2z_fprint(FILE * file, const psl2z_t g) noexcept - # Prints *g* to the stream *file*. - bint psl2z_equal(const psl2z_t f, const psl2z_t g) noexcept - # Returns nonzero iff *f* and *g* are equal. - void psl2z_mul(psl2z_t h, const psl2z_t f, const psl2z_t g) noexcept - # Sets *h* to the product of *f* and *g*, namely the matrix product - # with the signs canonicalized. - void psl2z_inv(psl2z_t h, const psl2z_t g) noexcept - # Sets *h* to the inverse of *g*. - bint psl2z_is_correct(const psl2z_t g) noexcept - # Returns nonzero iff *g* contains correct data, i.e. - # satisfying `ad-bc = 1`, `c \ge 0`, and `d > 0` if `c = 0`. - void psl2z_randtest(psl2z_t g, flint_rand_t state, slong bits) noexcept - # Sets *g* to a random element of `\text{PSL}(2, \mathbb{Z})` - # with entries of bit length at most *bits* - # (or 1, if *bits* is not positive). We first generate *a* and *d*, compute - # their Bezout coefficients, divide by the GCD, and then correct the signs. - void acb_modular_transform(acb_t w, const psl2z_t g, const acb_t z, slong prec) noexcept - # Applies the modular transformation *g* to the complex number *z*, - # evaluating - # .. math :: - # w = g z = \frac{az+b}{cz+d}. - void acb_modular_fundamental_domain_approx_d(psl2z_t g, double x, double y, double one_minus_eps) noexcept - void acb_modular_fundamental_domain_approx_arf(psl2z_t g, const arf_t x, const arf_t y, const arf_t one_minus_eps, slong prec) noexcept - # Attempts to determine a modular transformation *g* that maps the - # complex number `x+yi` to the fundamental domain or just - # slightly outside the fundamental domain, where the target tolerance - # (not a strict bound) is specified by *one_minus_eps*. - # The inputs are assumed to be finite numbers, with *y* positive. - # Uses floating-point iteration, repeatedly applying either - # the transformation `z \gets z + b` or `z \gets -1/z`. The iteration is - # terminated if `|x| \le 1/2` and `x^2 + y^2 \ge 1 - \varepsilon` where - # `1 - \varepsilon` is passed as *one_minus_eps*. It is also terminated - # if too many steps have been taken without convergence, or if the numbers - # end up too large or too small for the working precision. - # The algorithm can fail to produce a satisfactory transformation. - # The output *g* is always set to *some* correct modular transformation, - # but it is up to the user to verify a posteriori that *g* maps `x+yi` - # close enough to the fundamental domain. - void acb_modular_fundamental_domain_approx(acb_t w, psl2z_t g, const acb_t z, const arf_t one_minus_eps, slong prec) noexcept - # Attempts to determine a modular transformation *g* that maps the - # complex number `z` to the fundamental domain or just - # slightly outside the fundamental domain, where the target tolerance - # (not a strict bound) is specified by *one_minus_eps*. It also computes - # the transformed value `w = gz`. - # This function first tries to use - # :func:`acb_modular_fundamental_domain_approx_d` and checks if the - # result is acceptable. If this fails, it calls - # :func:`acb_modular_fundamental_domain_approx_arf` with higher precision. - # Finally, `w = gz` is evaluated by a single application of *g*. - # The algorithm can fail to produce a satisfactory transformation. - # The output *g* is always set to *some* correct modular transformation, - # but it is up to the user to verify a posteriori that `w` is close enough - # to the fundamental domain. - bint acb_modular_is_in_fundamental_domain(const acb_t z, const arf_t tol, slong prec) noexcept - # Returns nonzero if it is certainly true that `|z| \ge 1 - \varepsilon` and - # `|\operatorname{Re}(z)| \le 1/2 + \varepsilon` where `\varepsilon` is - # specified by *tol*. Returns zero if this is false or cannot be determined. - void acb_modular_fill_addseq(slong * tab, slong len) noexcept - # Builds a near-optimal addition sequence for a sequence of integers - # which is assumed to be reasonably dense. - # As input, the caller should set each entry in *tab* to `-1` if - # that index is to be part of the addition sequence, and to 0 otherwise. - # On output, entry *i* in *tab* will either be zero (if the number is - # not part of the sequence), or a value *j* such that both - # *j* and `i - j` are also marked. - # The first two entries in *tab* are ignored (the number 1 is always - # assumed to be part of the sequence). - void acb_modular_theta_transform(int * R, int * S, int * C, const psl2z_t g) noexcept - # We wish to write a theta function with quasiperiod `\tau` in terms - # of a theta function with quasiperiod `\tau' = g \tau`, given - # some `g = (a, b; c, d) \in \text{PSL}(2, \mathbb{Z})`. - # For `i = 0, 1, 2, 3`, this function computes integers `R_i` and `S_i` - # (*R* and *S* should be arrays of length 4) - # and `C \in \{0, 1\}` such that - # .. math :: - # \theta_{1+i}(z,\tau) = \exp(\pi i R_i / 4) \cdot A \cdot B \cdot \theta_{1+S_i}(z',\tau') - # where `z' = z, A = B = 1` if `C = 0`, and - # .. math :: - # z' = \frac{-z}{c \tau + d}, \quad - # A = \sqrt{\frac{i}{c \tau + d}}, \quad - # B = \exp\left(-\pi i c \frac{z^2}{c \tau + d}\right) - # if `C = 1`. Note that `A` is well-defined with the principal branch - # of the square root since `A^2 = i/(c \tau + d)` lies in the right half-plane. - # Firstly, if `c = 0`, we have - # `\theta_i(z, \tau) = \exp(-\pi i b / 4) \theta_i(z, \tau+b)` - # for `i = 1, 2`, whereas - # `\theta_3` and `\theta_4` remain unchanged when `b` is even - # and swap places with each other when `b` is odd. - # In this case we set `C = 0`. - # For an arbitrary `g` with `c > 0`, we set `C = 1`. The general - # transformations are given by Rademacher [Rad1973]_. - # We need the function `\theta_{m,n}(z,\tau)` defined for `m, n \in \mathbb{Z}` by - # (beware of the typos in [Rad1973]_) - # .. math :: - # \theta_{0,0}(z,\tau) = \theta_3(z,\tau), \quad - # \theta_{0,1}(z,\tau) = \theta_4(z,\tau) - # .. math :: - # \theta_{1,0}(z,\tau) = \theta_2(z,\tau), \quad - # \theta_{1,1}(z,\tau) = i \theta_1(z,\tau) - # .. math :: - # \theta_{m+2,n}(z,\tau) = (-1)^n \theta_{m,n}(z,\tau) - # .. math :: - # \theta_{m,n+2}(z,\tau) = \theta_{m,n}(z,\tau). - # Then we may write - # .. math :: - # \theta_1(z,\tau) &= \varepsilon_1 A B \theta_1(z', \tau') - # \theta_2(z,\tau) &= \varepsilon_2 A B \theta_{1-c,1+a}(z', \tau') - # \theta_3(z,\tau) &= \varepsilon_3 A B \theta_{1+d-c,1-b+a}(z', \tau') - # \theta_4(z,\tau) &= \varepsilon_4 A B \theta_{1+d,1-b}(z', \tau') - # where `\varepsilon_i` is an 8th root of unity. - # Specifically, if we denote the 24th root of unity - # in the transformation formula of the Dedekind eta - # function by `\varepsilon(a,b,c,d) = \exp(\pi i R(a,b,c,d) / 12)` - # (see :func:`acb_modular_epsilon_arg`), then: - # .. math :: - # \varepsilon_1(a,b,c,d) &= \exp(\pi i [R(-d,b,c,-a) + 1] / 4) - # \varepsilon_2(a,b,c,d) &= \exp(\pi i [-R(a,b,c,d) + (5+(2-c)a)] / 4) - # \varepsilon_3(a,b,c,d) &= \exp(\pi i [-R(a,b,c,d) + (4+(c-d-2)(b-a))] / 4) - # \varepsilon_4(a,b,c,d) &= \exp(\pi i [-R(a,b,c,d) + (3-(2+d)b)] / 4) - # These formulas are easily derived from the formulas in [Rad1973]_ - # (Rademacher has the transformed/untransformed variables exchanged, - # and his "`\varepsilon`" differs from ours by a constant - # offset in the phase). - void acb_modular_addseq_theta(slong * exponents, slong * aindex, slong * bindex, slong num) noexcept - # Constructs an addition sequence for the first *num* squares and triangular - # numbers interleaved (excluding zero), i.e. 1, 2, 4, 6, 9, 12, 16, 20, 25, 30 etc. - void acb_modular_theta_sum(acb_ptr theta1, acb_ptr theta2, acb_ptr theta3, acb_ptr theta4, const acb_t w, int w_is_unit, const acb_t q, slong len, slong prec) noexcept - # Simultaneously computes the first *len* coefficients of each of the - # formal power series - # .. math :: - # \theta_1(z+x,\tau) / q_{1/4} \in \mathbb{C}[[x]] - # \theta_2(z+x,\tau) / q_{1/4} \in \mathbb{C}[[x]] - # \theta_3(z+x,\tau) \in \mathbb{C}[[x]] - # \theta_4(z+x,\tau) \in \mathbb{C}[[x]] - # given `w = \exp(\pi i z)` and `q = \exp(\pi i \tau)`, by summing - # a finite truncation of the respective theta function series. - # In particular, with *len* equal to 1, computes the respective - # value of the theta function at the point *z*. - # We require *len* to be positive. - # If *w_is_unit* is nonzero, *w* is assumed to lie on the unit circle, - # i.e. *z* is assumed to be real. - # Note that the factor `q_{1/4}` is removed from `\theta_1` and `\theta_2`. - # To get the true theta function values, the user has to multiply - # this factor back. This convention avoids unnecessary computations, - # since the user can compute `q_{1/4} = \exp(\pi i \tau / 4)` followed by - # `q = (q_{1/4})^4`, and in many cases when computing products or quotients - # of theta functions, the factor `q_{1/4}` can be eliminated entirely. - # This function is intended for `|q| \ll 1`. It can be called with any - # `q`, but will return useless intervals if convergence is not rapid. - # For general evaluation of theta functions, the user should only call - # this function after applying a suitable modular transformation. - # We consider the sums together, alternatingly updating `(\theta_1, \theta_2)` - # or `(\theta_3, \theta_4)`. For `k = 0, 1, 2, \ldots`, the powers of `q` - # are `\lfloor (k+2)^2 / 4 \rfloor = 1, 2, 4, 6, 9` etc. and the powers of `w` are - # `\pm (k+2) = \pm 2, \pm 3, \pm 4, \ldots` etc. The scheme - # is illustrated by the following table: - # .. math :: - # \begin{array}{llll} - # & \theta_1, \theta_2 & q^0 & (w^1 \pm w^{-1}) \\ - # k = 0 & \theta_3, \theta_4 & q^1 & (w^2 \pm w^{-2}) \\ - # k = 1 & \theta_1, \theta_2 & q^2 & (w^3 \pm w^{-3}) \\ - # k = 2 & \theta_3, \theta_4 & q^4 & (w^4 \pm w^{-4}) \\ - # k = 3 & \theta_1, \theta_2 & q^6 & (w^5 \pm w^{-5}) \\ - # k = 4 & \theta_3, \theta_4 & q^9 & (w^6 \pm w^{-6}) \\ - # k = 5 & \theta_1, \theta_2 & q^{12} & (w^7 \pm w^{-7}) \\ - # \end{array} - # For some integer `N \ge 1`, the summation is stopped just before term - # `k = N`. Let `Q = |q|`, `W = \max(|w|,|w^{-1}|)`, - # `E = \lfloor (N+2)^2 / 4 \rfloor` and - # `F = \lfloor (N+1)/2 \rfloor + 1`. The error of the - # zeroth derivative can be bounded as - # .. math :: - # 2 Q^E W^{N+2} \left[ 1 + Q^F W + Q^{2F} W^2 + \ldots \right] - # = \frac{2 Q^E W^{N+2}}{1 - Q^F W} - # provided that the denominator is positive (otherwise we set - # the error bound to infinity). - # When *len* is greater than 1, consider the derivative of order *r*. - # The term of index *k* and order *r* picks up a factor of magnitude - # `(k+2)^r` from differentiation of `w^{k+2}` (it also picks up a factor - # `\pi^r`, but we omit this until we rescale the coefficients - # at the end of the computation). Thus we have the error bound - # .. math :: - # 2 Q^E W^{N+2} (N+2)^r \left[ 1 + Q^F W \frac{(N+3)^r}{(N+2)^r} + Q^{2F} W^2 \frac{(N+4)^r}{(N+2)^r} + \ldots \right] - # which by the inequality `(1 + m/(N+2))^r \le \exp(mr/(N+2))` - # can be bounded as - # .. math :: - # \frac{2 Q^E W^{N+2} (N+2)^r}{1 - Q^F W \exp(r/(N+2))}, - # again valid when the denominator is positive. - # To actually evaluate the series, we write the even - # cosine terms as `w^{2n} + w^{-2n}`, the odd cosine terms as - # `w (w^{2n} + w^{-2n-2})`, and the sine terms as `w (w^{2n} - w^{-2n-2})`. - # This way we only need even powers of `w` and `w^{-1}`. - # The implementation is not yet optimized for real `z`, in which case - # further work can be saved. - # This function does not permit aliasing between input and output - # arguments. - void acb_modular_theta_const_sum_basecase(acb_t theta2, acb_t theta3, acb_t theta4, const acb_t q, slong N, slong prec) noexcept - void acb_modular_theta_const_sum_rs(acb_t theta2, acb_t theta3, acb_t theta4, const acb_t q, slong N, slong prec) noexcept - # Computes the truncated theta constant sums - # `\theta_2 = \sum_{k(k+1) < N} q^{k(k+1)}`, - # `\theta_3 = \sum_{k^2 < N} q^{k^2}`, - # `\theta_4 = \sum_{k^2 < N} (-1)^k q^{k^2}`. - # The *basecase* version uses a short addition sequence. - # The *rs* version uses rectangular splitting. - # The algorithms are described in [EHJ2016]_. - void acb_modular_theta_const_sum(acb_t theta2, acb_t theta3, acb_t theta4, const acb_t q, slong prec) noexcept - # Computes the respective theta constants by direct summation - # (without applying modular transformations). This function - # selects an appropriate *N*, calls either - # :func:`acb_modular_theta_const_sum_basecase` or - # :func:`acb_modular_theta_const_sum_rs` or depending on *N*, - # and adds a bound for the truncation error. - void acb_modular_theta_notransform(acb_t theta1, acb_t theta2, acb_t theta3, acb_t theta4, const acb_t z, const acb_t tau, slong prec) noexcept - # Evaluates the Jacobi theta functions `\theta_i(z,\tau)`, `i = 1, 2, 3, 4` - # simultaneously. This function does not move `\tau` to the fundamental domain. - # This is generally worse than :func:`acb_modular_theta`, but can - # be slightly better for moderate input. - void acb_modular_theta(acb_t theta1, acb_t theta2, acb_t theta3, acb_t theta4, const acb_t z, const acb_t tau, slong prec) noexcept - # Evaluates the Jacobi theta functions `\theta_i(z,\tau)`, `i = 1, 2, 3, 4` - # simultaneously. This function moves `\tau` to the fundamental domain - # and then also reduces `z` modulo `\tau` - # before calling :func:`acb_modular_theta_sum`. - void acb_modular_theta_jet_notransform(acb_ptr theta1, acb_ptr theta2, acb_ptr theta3, acb_ptr theta4, const acb_t z, const acb_t tau, slong len, slong prec) noexcept - void acb_modular_theta_jet(acb_ptr theta1, acb_ptr theta2, acb_ptr theta3, acb_ptr theta4, const acb_t z, const acb_t tau, slong len, slong prec) noexcept - # Evaluates the Jacobi theta functions along with their derivatives - # with respect to *z*, writing the first *len* coefficients in the power - # series `\theta_i(z+x,\tau) \in \mathbb{C}[[x]]` to - # each respective output variable. The *notransform* version does not - # move `\tau` to the fundamental domain or reduce `z` during the computation. - void _acb_modular_theta_series(acb_ptr theta1, acb_ptr theta2, acb_ptr theta3, acb_ptr theta4, acb_srcptr z, slong zlen, const acb_t tau, slong len, slong prec) noexcept - void acb_modular_theta_series(acb_poly_t theta1, acb_poly_t theta2, acb_poly_t theta3, acb_poly_t theta4, const acb_poly_t z, const acb_t tau, slong len, slong prec) noexcept - # Evaluates the respective Jacobi theta functions of the power series *z*, - # truncated to length *len*. Either of the output variables can be *NULL*. - void acb_modular_addseq_eta(slong * exponents, slong * aindex, slong * bindex, slong num) noexcept - # Constructs an addition sequence for the first *num* generalized pentagonal - # numbers (excluding zero), i.e. 1, 2, 5, 7, 12, 15, 22, 26, 35, 40 etc. - void acb_modular_eta_sum(acb_t eta, const acb_t q, slong prec) noexcept - # Evaluates the Dedekind eta function - # without the leading 24th root, i.e. - # .. math :: \exp(-\pi i \tau/12) \eta(\tau) = \sum_{n=-\infty}^{\infty} (-1)^n q^{(3n^2-n)/2} - # given `q = \exp(2 \pi i \tau)`, by summing the defining series. - # This function is intended for `|q| \ll 1`. It can be called with any - # `q`, but will return useless intervals if convergence is not rapid. - # For general evaluation of the eta function, the user should only call - # this function after applying a suitable modular transformation. - # The series is evaluated using either a short addition sequence or - # rectangular splitting, depending on the number of terms. - # The algorithms are described in [EHJ2016]_. - int acb_modular_epsilon_arg(const psl2z_t g) noexcept - # Given `g = (a, b; c, d)`, computes an integer `R` such that - # `\varepsilon(a,b,c,d) = \exp(\pi i R / 12)` is the 24th root of unity in - # the transformation formula for the Dedekind eta function, - # .. math :: - # \eta\left(\frac{a\tau+b}{c\tau+d}\right) = \varepsilon (a,b,c,d) - # \sqrt{c\tau+d} \eta(\tau). - void acb_modular_eta(acb_t r, const acb_t tau, slong prec) noexcept - # Computes the Dedekind eta function `\eta(\tau)` given `\tau` in the upper - # half-plane. This function applies the functional equation to move - # `\tau` to the fundamental domain before calling - # :func:`acb_modular_eta_sum`. - void acb_modular_j(acb_t r, const acb_t tau, slong prec) noexcept - # Computes Klein's j-invariant `j(\tau)` given `\tau` in the upper - # half-plane. The function is normalized so that `j(i) = 1728`. - # We first move `\tau` to the fundamental domain, which does not change - # the value of the function. Then we use the formula - # `j(\tau) = 32 (\theta_2^8+\theta_3^8+\theta_4^8)^3 / (\theta_2 \theta_3 \theta_4)^8` where - # `\theta_i = \theta_i(0,\tau)`. - void acb_modular_lambda(acb_t r, const acb_t tau, slong prec) noexcept - # Computes the lambda function - # `\lambda(\tau) = \theta_2^4(0,\tau) / \theta_3^4(0,\tau)`, which - # is invariant under modular transformations `(a, b; c, d)` - # where `a, d` are odd and `b, c` are even. - void acb_modular_delta(acb_t r, const acb_t tau, slong prec) noexcept - # Computes the modular discriminant `\Delta(\tau) = \eta(\tau)^{24}`, - # which transforms as - # .. math :: - # \Delta\left(\frac{a\tau+b}{c\tau+d}\right) = (c\tau+d)^{12} \Delta(\tau). - # The modular discriminant is sometimes defined with an extra factor - # `(2\pi)^{12}`, which we omit in this implementation. - void acb_modular_eisenstein(acb_ptr r, const acb_t tau, slong len, slong prec) noexcept - # Computes simultaneously the first *len* entries in the sequence - # of Eisenstein series `G_4(\tau), G_6(\tau), G_8(\tau), \ldots`, - # defined by - # .. math :: - # G_{2k}(\tau) = \sum_{m^2 + n^2 \ne 0} \frac{1}{(m+n\tau )^{2k}} - # and satisfying - # .. math :: - # G_{2k} \left(\frac{a\tau+b}{c\tau+d}\right) = (c\tau+d)^{2k} G_{2k}(\tau). - # We first evaluate `G_4(\tau)` and `G_6(\tau)` on the fundamental - # domain using theta functions, and then compute the Eisenstein series - # of higher index using a recurrence relation. - void acb_modular_elliptic_k(acb_t w, const acb_t m, slong prec) noexcept - void acb_modular_elliptic_k_cpx(acb_ptr w, const acb_t m, slong len, slong prec) noexcept - void acb_modular_elliptic_e(acb_t w, const acb_t m, slong prec) noexcept - void acb_modular_elliptic_p(acb_t wp, const acb_t z, const acb_t tau, slong prec) noexcept - void acb_modular_elliptic_p_zpx(acb_ptr wp, const acb_t z, const acb_t tau, slong len, slong prec) noexcept - void acb_modular_hilbert_class_poly(fmpz_poly_t res, slong D) noexcept - # Sets *res* to the Hilbert class polynomial of discriminant *D*, - # defined as - # .. math :: - # H_D(x) = \prod_{(a,b,c)} \left(x - j\left(\frac{-b+\sqrt{D}}{2a}\right)\right) - # where `(a,b,c)` ranges over the primitive reduced positive - # definite binary quadratic forms of discriminant `b^2 - 4ac = D`. - # The Hilbert class polynomial is only defined if `D < 0` and *D* - # is congruent to 0 or 1 mod 4. If some other value of *D* is passed as - # input, *res* is set to the zero polynomial. diff --git a/src/sage/libs/flint/acb_poly.pxd b/src/sage/libs/flint/acb_poly.pxd index 8ca5fab29d4..2e4e900cac0 100644 --- a/src/sage/libs/flint/acb_poly.pxd +++ b/src/sage/libs/flint/acb_poly.pxd @@ -2,7 +2,9 @@ # distutils: depends = flint/acb_poly.h ################################################################################ -# This file is auto-generated. Do not modify by hand +# This file is auto-generated by the script +# SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py. +# Do not modify by hand! Fix and rerun the script instead. ################################################################################ from libc.stdio cimport FILE @@ -11,894 +13,237 @@ from sage.libs.mpfr.types cimport * from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void acb_poly_init(acb_poly_t poly) noexcept - # Initializes the polynomial for use, setting it to the zero polynomial. - void acb_poly_clear(acb_poly_t poly) noexcept - # Clears the polynomial, deallocating all coefficients and the - # coefficient array. - void acb_poly_fit_length(acb_poly_t poly, slong len) noexcept - # Makes sure that the coefficient array of the polynomial contains at - # least *len* initialized coefficients. - void _acb_poly_set_length(acb_poly_t poly, slong len) noexcept - # Directly changes the length of the polynomial, without allocating or - # deallocating coefficients. The value should not exceed the allocation length. - void _acb_poly_normalise(acb_poly_t poly) noexcept - # Strips any trailing coefficients which are identical to zero. - void acb_poly_swap(acb_poly_t poly1, acb_poly_t poly2) noexcept - # Swaps *poly1* and *poly2* efficiently. - slong acb_poly_allocated_bytes(const acb_poly_t x) noexcept - # Returns the total number of bytes heap-allocated internally by this object. - # The count excludes the size of the structure itself. Add - # ``sizeof(acb_poly_struct)`` to get the size of the object as a whole. - slong acb_poly_length(const acb_poly_t poly) noexcept - # Returns the length of *poly*, i.e. zero if *poly* is - # identically zero, and otherwise one more than the index - # of the highest term that is not identically zero. - slong acb_poly_degree(const acb_poly_t poly) noexcept - # Returns the degree of *poly*, defined as one less than its length. - # Note that if one or several leading coefficients are balls - # containing zero, this value can be larger than the true - # degree of the exact polynomial represented by *poly*, - # so the return value of this function is effectively - # an upper bound. - bint acb_poly_is_zero(const acb_poly_t poly) noexcept - bint acb_poly_is_one(const acb_poly_t poly) noexcept - bint acb_poly_is_x(const acb_poly_t poly) noexcept - # Returns 1 if *poly* is exactly the polynomial 0, 1 or *x* - # respectively. Returns 0 otherwise. - void acb_poly_zero(acb_poly_t poly) noexcept - # Sets *poly* to the zero polynomial. - void acb_poly_one(acb_poly_t poly) noexcept - # Sets *poly* to the constant polynomial 1. - void acb_poly_set(acb_poly_t dest, const acb_poly_t src) noexcept - # Sets *dest* to a copy of *src*. - void acb_poly_set_round(acb_poly_t dest, const acb_poly_t src, slong prec) noexcept - # Sets *dest* to a copy of *src*, rounded to *prec* bits. - void acb_poly_set_trunc(acb_poly_t dest, const acb_poly_t src, slong n) noexcept - void acb_poly_set_trunc_round(acb_poly_t dest, const acb_poly_t src, slong n, slong prec) noexcept - # Sets *dest* to a copy of *src*, truncated to length *n* and rounded to *prec* bits. - void acb_poly_set_coeff_si(acb_poly_t poly, slong n, slong c) noexcept - void acb_poly_set_coeff_acb(acb_poly_t poly, slong n, const acb_t c) noexcept - # Sets the coefficient with index *n* in *poly* to the value *c*. - # We require that *n* is nonnegative. - void acb_poly_get_coeff_acb(acb_t v, const acb_poly_t poly, slong n) noexcept - # Sets *v* to the value of the coefficient with index *n* in *poly*. - # We require that *n* is nonnegative. - void _acb_poly_shift_right(acb_ptr res, acb_srcptr poly, slong len, slong n) noexcept - void acb_poly_shift_right(acb_poly_t res, const acb_poly_t poly, slong n) noexcept - # Sets *res* to *poly* divided by `x^n`, throwing away the lower coefficients. - # We require that *n* is nonnegative. - void _acb_poly_shift_left(acb_ptr res, acb_srcptr poly, slong len, slong n) noexcept - void acb_poly_shift_left(acb_poly_t res, const acb_poly_t poly, slong n) noexcept - # Sets *res* to *poly* multiplied by `x^n`. - # We require that *n* is nonnegative. - void acb_poly_truncate(acb_poly_t poly, slong n) noexcept - # Truncates *poly* to have length at most *n*, i.e. degree - # strictly smaller than *n*. We require that *n* is nonnegative. - slong acb_poly_valuation(const acb_poly_t poly) noexcept - # Returns the degree of the lowest term that is not exactly zero in *poly*. - # Returns -1 if *poly* is the zero polynomial. - void acb_poly_printd(const acb_poly_t poly, slong digits) noexcept - # Prints the polynomial as an array of coefficients, printing each - # coefficient using *acb_printd*. - void acb_poly_fprintd(FILE * file, const acb_poly_t poly, slong digits) noexcept - # Prints the polynomial as an array of coefficients to the stream *file*, - # printing each coefficient using *acb_fprintd*. - void acb_poly_randtest(acb_poly_t poly, flint_rand_t state, slong len, slong prec, slong mag_bits) noexcept - # Creates a random polynomial with length at most *len*. - bint acb_poly_equal(const acb_poly_t A, const acb_poly_t B) noexcept - # Returns nonzero iff *A* and *B* are identical as interval polynomials. - bint acb_poly_contains(const acb_poly_t poly1, const acb_poly_t poly2) noexcept - bint acb_poly_contains_fmpz_poly(const acb_poly_t poly1, const fmpz_poly_t poly2) noexcept - bint acb_poly_contains_fmpq_poly(const acb_poly_t poly1, const fmpq_poly_t poly2) noexcept - # Returns nonzero iff *poly2* is contained in *poly1*. - bint _acb_poly_overlaps(acb_srcptr poly1, slong len1, acb_srcptr poly2, slong len2) noexcept - bint acb_poly_overlaps(const acb_poly_t poly1, const acb_poly_t poly2) noexcept - # Returns nonzero iff *poly1* overlaps with *poly2*. The underscore - # function requires that *len1* is at least as large as *len2*. - int acb_poly_get_unique_fmpz_poly(fmpz_poly_t z, const acb_poly_t x) noexcept - # If *x* contains a unique integer polynomial, sets *z* to that value and returns - # nonzero. Otherwise (if *x* represents no integers or more than one integer), - # returns zero, possibly partially modifying *z*. - bint acb_poly_is_real(const acb_poly_t poly) noexcept - # Returns nonzero iff all coefficients in *poly* have zero imaginary part. - void acb_poly_set_fmpz_poly(acb_poly_t poly, const fmpz_poly_t re, slong prec) noexcept - void acb_poly_set2_fmpz_poly(acb_poly_t poly, const fmpz_poly_t re, const fmpz_poly_t im, slong prec) noexcept - void acb_poly_set_arb_poly(acb_poly_t poly, const arb_poly_t re) noexcept - void acb_poly_set2_arb_poly(acb_poly_t poly, const arb_poly_t re, const arb_poly_t im) noexcept - void acb_poly_set_fmpq_poly(acb_poly_t poly, const fmpq_poly_t re, slong prec) noexcept - void acb_poly_set2_fmpq_poly(acb_poly_t poly, const fmpq_poly_t re, const fmpq_poly_t im, slong prec) noexcept - # Sets *poly* to the given real part *re* plus the imaginary part *im*, - # both rounded to *prec* bits. - void acb_poly_set_acb(acb_poly_t poly, const acb_t src) noexcept - void acb_poly_set_si(acb_poly_t poly, slong src) noexcept - # Sets *poly* to *src*. - void _acb_poly_majorant(arb_ptr res, acb_srcptr poly, slong len, slong prec) noexcept - void acb_poly_majorant(arb_poly_t res, const acb_poly_t poly, slong prec) noexcept - # Sets *res* to an exact real polynomial whose coefficients are - # upper bounds for the absolute values of the coefficients in *poly*, - # rounded to *prec* bits. - void _acb_poly_add(acb_ptr C, acb_srcptr A, slong lenA, acb_srcptr B, slong lenB, slong prec) noexcept - # Sets *{C, max(lenA, lenB)}* to the sum of *{A, lenA}* and *{B, lenB}*. - # Allows aliasing of the input and output operands. - void acb_poly_add(acb_poly_t C, const acb_poly_t A, const acb_poly_t B, slong prec) noexcept - void acb_poly_add_si(acb_poly_t C, const acb_poly_t A, slong B, slong prec) noexcept - # Sets *C* to the sum of *A* and *B*. - void _acb_poly_sub(acb_ptr C, acb_srcptr A, slong lenA, acb_srcptr B, slong lenB, slong prec) noexcept - # Sets *{C, max(lenA, lenB)}* to the difference of *{A, lenA}* and *{B, lenB}*. - # Allows aliasing of the input and output operands. - void acb_poly_sub(acb_poly_t C, const acb_poly_t A, const acb_poly_t B, slong prec) noexcept - # Sets *C* to the difference of *A* and *B*. - void acb_poly_add_series(acb_poly_t C, const acb_poly_t A, const acb_poly_t B, slong len, slong prec) noexcept - # Sets *C* to the sum of *A* and *B*, truncated to length *len*. - void acb_poly_sub_series(acb_poly_t C, const acb_poly_t A, const acb_poly_t B, slong len, slong prec) noexcept - # Sets *C* to the difference of *A* and *B*, truncated to length *len*. - void acb_poly_neg(acb_poly_t C, const acb_poly_t A) noexcept - # Sets *C* to the negation of *A*. - void acb_poly_scalar_mul_2exp_si(acb_poly_t C, const acb_poly_t A, slong c) noexcept - # Sets *C* to *A* multiplied by `2^c`. - void acb_poly_scalar_mul(acb_poly_t C, const acb_poly_t A, const acb_t c, slong prec) noexcept - # Sets *C* to *A* multiplied by *c*. - void acb_poly_scalar_div(acb_poly_t C, const acb_poly_t A, const acb_t c, slong prec) noexcept - # Sets *C* to *A* divided by *c*. - void _acb_poly_mullow_classical(acb_ptr C, acb_srcptr A, slong lenA, acb_srcptr B, slong lenB, slong n, slong prec) noexcept - void _acb_poly_mullow_transpose(acb_ptr C, acb_srcptr A, slong lenA, acb_srcptr B, slong lenB, slong n, slong prec) noexcept - void _acb_poly_mullow_transpose_gauss(acb_ptr C, acb_srcptr A, slong lenA, acb_srcptr B, slong lenB, slong n, slong prec) noexcept - void _acb_poly_mullow(acb_ptr C, acb_srcptr A, slong lenA, acb_srcptr B, slong lenB, slong n, slong prec) noexcept - # Sets *{C, n}* to the product of *{A, lenA}* and *{B, lenB}*, truncated to - # length *n*. The output is not allowed to be aliased with either of the - # inputs. We require `\mathrm{lenA} \ge \mathrm{lenB} > 0`, - # `n > 0`, `\mathrm{lenA} + \mathrm{lenB} - 1 \ge n`. - # The *classical* version uses a plain loop. - # The *transpose* version evaluates the product using four real polynomial - # multiplications (via :func:`_arb_poly_mullow`). - # The *transpose_gauss* version evaluates the product using three real - # polynomial multiplications. This is almost always faster than *transpose*, - # but has worse numerical stability when the coefficients vary - # in magnitude. - # The default function :func:`_acb_poly_mullow` automatically switches - # been *classical* and *transpose* multiplication. - # If the input pointers are identical (and the lengths are the same), - # they are assumed to represent the same polynomial, and its - # square is computed. - void acb_poly_mullow_classical(acb_poly_t C, const acb_poly_t A, const acb_poly_t B, slong n, slong prec) noexcept - void acb_poly_mullow_transpose(acb_poly_t C, const acb_poly_t A, const acb_poly_t B, slong n, slong prec) noexcept - void acb_poly_mullow_transpose_gauss(acb_poly_t C, const acb_poly_t A, const acb_poly_t B, slong n, slong prec) noexcept - void acb_poly_mullow(acb_poly_t C, const acb_poly_t A, const acb_poly_t B, slong n, slong prec) noexcept - # Sets *C* to the product of *A* and *B*, truncated to length *n*. - # If the same variable is passed for *A* and *B*, sets *C* to the - # square of *A* truncated to length *n*. - void _acb_poly_mul(acb_ptr C, acb_srcptr A, slong lenA, acb_srcptr B, slong lenB, slong prec) noexcept - # Sets *{C, lenA + lenB - 1}* to the product of *{A, lenA}* and *{B, lenB}*. - # The output is not allowed to be aliased with either of the - # inputs. We require `\mathrm{lenA} \ge \mathrm{lenB} > 0`. - # This function is implemented as a simple wrapper for :func:`_acb_poly_mullow`. - # If the input pointers are identical (and the lengths are the same), - # they are assumed to represent the same polynomial, and its - # square is computed. - void acb_poly_mul(acb_poly_t C, const acb_poly_t A1, const acb_poly_t B2, slong prec) noexcept - # Sets *C* to the product of *A* and *B*. - # If the same variable is passed for *A* and *B*, sets *C* to - # the square of *A*. - void _acb_poly_inv_series(acb_ptr Qinv, acb_srcptr Q, slong Qlen, slong len, slong prec) noexcept - # Sets *{Qinv, len}* to the power series inverse of *{Q, Qlen}*. Uses Newton iteration. - void acb_poly_inv_series(acb_poly_t Qinv, const acb_poly_t Q, slong n, slong prec) noexcept - # Sets *Qinv* to the power series inverse of *Q*. - void _acb_poly_div_series(acb_ptr Q, acb_srcptr A, slong Alen, acb_srcptr B, slong Blen, slong n, slong prec) noexcept - # Sets *{Q, n}* to the power series quotient of *{A, Alen}* by *{B, Blen}*. - # Uses Newton iteration followed by multiplication. - void acb_poly_div_series(acb_poly_t Q, const acb_poly_t A, const acb_poly_t B, slong n, slong prec) noexcept - # Sets *Q* to the power series quotient *A* divided by *B*, truncated to length *n*. - void _acb_poly_div(acb_ptr Q, acb_srcptr A, slong lenA, acb_srcptr B, slong lenB, slong prec) noexcept - void _acb_poly_rem(acb_ptr R, acb_srcptr A, slong lenA, acb_srcptr B, slong lenB, slong prec) noexcept - void _acb_poly_divrem(acb_ptr Q, acb_ptr R, acb_srcptr A, slong lenA, acb_srcptr B, slong lenB, slong prec) noexcept - int acb_poly_divrem(acb_poly_t Q, acb_poly_t R, const acb_poly_t A, const acb_poly_t B, slong prec) noexcept - # Performs polynomial division with remainder, computing a quotient `Q` and - # a remainder `R` such that `A = BQ + R`. The implementation reverses the - # inputs and performs power series division. - # If the leading coefficient of `B` contains zero (or if `B` is identically - # zero), returns 0 indicating failure without modifying the outputs. - # Otherwise returns nonzero. - void _acb_poly_div_root(acb_ptr Q, acb_t R, acb_srcptr A, slong len, const acb_t c, slong prec) noexcept - # Divides `A` by the polynomial `x - c`, computing the quotient `Q` as well - # as the remainder `R = f(c)`. - void _acb_poly_taylor_shift(acb_ptr g, const acb_t c, slong n, slong prec) noexcept void acb_poly_taylor_shift(acb_poly_t g, const acb_poly_t f, const acb_t c, slong prec) noexcept - # Sets *g* to the Taylor shift `f(x+c)`. - # The underscore methods act in-place on *g* = *f* which has length *n*. - void _acb_poly_compose(acb_ptr res, acb_srcptr poly1, slong len1, acb_srcptr poly2, slong len2, slong prec) noexcept void acb_poly_compose(acb_poly_t res, const acb_poly_t poly1, const acb_poly_t poly2, slong prec) noexcept - # Sets *res* to the composition `h(x) = f(g(x))` where `f` is given by - # *poly1* and `g` is given by *poly2*. - # The underscore method does not support aliasing of the output - # with either input polynomial. - void _acb_poly_compose_series(acb_ptr res, acb_srcptr poly1, slong len1, acb_srcptr poly2, slong len2, slong n, slong prec) noexcept void acb_poly_compose_series(acb_poly_t res, const acb_poly_t poly1, const acb_poly_t poly2, slong n, slong prec) noexcept - # Sets *res* to the power series composition `h(x) = f(g(x))` truncated - # to order `O(x^n)` where `f` is given by *poly1* and `g` is given by *poly2*. - # Wraps :func:`_gr_poly_compose_series` which chooses automatically - # between various algorithms. - # We require that the constant term in `g(x)` is exactly zero. - # The underscore method does not support aliasing of the output - # with either input polynomial. - - void _acb_poly_revert_series_lagrange(acb_ptr h, acb_srcptr f, slong flen, slong n, slong prec) noexcept - - void acb_poly_revert_series_lagrange(acb_poly_t h, const acb_poly_t f, slong n, slong prec) noexcept - - void _acb_poly_revert_series_newton(acb_ptr h, acb_srcptr f, slong flen, slong n, slong prec) noexcept - - void acb_poly_revert_series_newton(acb_poly_t h, const acb_poly_t f, slong n, slong prec) noexcept - - void _acb_poly_revert_series_lagrange_fast(acb_ptr h, acb_srcptr f, slong flen, slong n, slong prec) noexcept - - void acb_poly_revert_series_lagrange_fast(acb_poly_t h, const acb_poly_t f, slong n, slong prec) noexcept - void _acb_poly_revert_series(acb_ptr h, acb_srcptr f, slong flen, slong n, slong prec) noexcept - void acb_poly_revert_series(acb_poly_t h, const acb_poly_t f, slong n, slong prec) noexcept - # Sets `h` to the power series reversion of `f`, i.e. the expansion - # of the compositional inverse function `f^{-1}(x)`, - # truncated to order `O(x^n)`, using respectively - # Lagrange inversion, Newton iteration, fast Lagrange inversion, - # and a default algorithm choice. - # We require that the constant term in `f` is exactly zero and that the - # linear term is nonzero. The underscore methods assume that *flen* - # is at least 2, and do not support aliasing. - void _acb_poly_evaluate_horner(acb_t y, acb_srcptr f, slong len, const acb_t x, slong prec) noexcept - void acb_poly_evaluate_horner(acb_t y, const acb_poly_t f, const acb_t x, slong prec) noexcept - void _acb_poly_evaluate_rectangular(acb_t y, acb_srcptr f, slong len, const acb_t x, slong prec) noexcept - void acb_poly_evaluate_rectangular(acb_t y, const acb_poly_t f, const acb_t x, slong prec) noexcept - void _acb_poly_evaluate(acb_t y, acb_srcptr f, slong len, const acb_t x, slong prec) noexcept - void acb_poly_evaluate(acb_t y, const acb_poly_t f, const acb_t x, slong prec) noexcept - # Sets `y = f(x)`, evaluated respectively using Horner's rule, - # rectangular splitting, and an automatic algorithm choice. - void _acb_poly_evaluate2_horner(acb_t y, acb_t z, acb_srcptr f, slong len, const acb_t x, slong prec) noexcept - void acb_poly_evaluate2_horner(acb_t y, acb_t z, const acb_poly_t f, const acb_t x, slong prec) noexcept - void _acb_poly_evaluate2_rectangular(acb_t y, acb_t z, acb_srcptr f, slong len, const acb_t x, slong prec) noexcept - void acb_poly_evaluate2_rectangular(acb_t y, acb_t z, const acb_poly_t f, const acb_t x, slong prec) noexcept - void _acb_poly_evaluate2(acb_t y, acb_t z, acb_srcptr f, slong len, const acb_t x, slong prec) noexcept - void acb_poly_evaluate2(acb_t y, acb_t z, const acb_poly_t f, const acb_t x, slong prec) noexcept - # Sets `y = f(x), z = f'(x)`, evaluated respectively using Horner's rule, - # rectangular splitting, and an automatic algorithm choice. - # When Horner's rule is used, the only advantage of evaluating the - # function and its derivative simultaneously is that one does not have - # to generate the derivative polynomial explicitly. - # With the rectangular splitting algorithm, the powers can be reused, - # making simultaneous evaluation slightly faster. - void _acb_poly_product_roots(acb_ptr poly, acb_srcptr xs, slong n, slong prec) noexcept - void acb_poly_product_roots(acb_poly_t poly, acb_srcptr xs, slong n, slong prec) noexcept - # Generates the polynomial `(x-x_0)(x-x_1)\cdots(x-x_{n-1})`. - acb_ptr * _acb_poly_tree_alloc(slong len) noexcept - # Returns an initialized data structured capable of representing a - # remainder tree (product tree) of *len* roots. - void _acb_poly_tree_free(acb_ptr * tree, slong len) noexcept - # Deallocates a tree structure as allocated using *_acb_poly_tree_alloc*. - void _acb_poly_tree_build(acb_ptr * tree, acb_srcptr roots, slong len, slong prec) noexcept - # Constructs a product tree from a given array of *len* roots. The tree - # structure must be pre-allocated to the specified length using - # :func:`_acb_poly_tree_alloc`. - void _acb_poly_evaluate_vec_iter(acb_ptr ys, acb_srcptr poly, slong plen, acb_srcptr xs, slong n, slong prec) noexcept - void acb_poly_evaluate_vec_iter(acb_ptr ys, const acb_poly_t poly, acb_srcptr xs, slong n, slong prec) noexcept - # Evaluates the polynomial simultaneously at *n* given points, calling - # :func:`_acb_poly_evaluate` repeatedly. - void _acb_poly_evaluate_vec_fast_precomp(acb_ptr vs, acb_srcptr poly, slong plen, acb_ptr * tree, slong len, slong prec) noexcept - void _acb_poly_evaluate_vec_fast(acb_ptr ys, acb_srcptr poly, slong plen, acb_srcptr xs, slong n, slong prec) noexcept - void acb_poly_evaluate_vec_fast(acb_ptr ys, const acb_poly_t poly, acb_srcptr xs, slong n, slong prec) noexcept - # Evaluates the polynomial simultaneously at *n* given points, using - # fast multipoint evaluation. - void _acb_poly_interpolate_newton(acb_ptr poly, acb_srcptr xs, acb_srcptr ys, slong n, slong prec) noexcept - void acb_poly_interpolate_newton(acb_poly_t poly, acb_srcptr xs, acb_srcptr ys, slong n, slong prec) noexcept - # Recovers the unique polynomial of length at most *n* that interpolates - # the given *x* and *y* values. This implementation first interpolates in the - # Newton basis and then converts back to the monomial basis. - void _acb_poly_interpolate_barycentric(acb_ptr poly, acb_srcptr xs, acb_srcptr ys, slong n, slong prec) noexcept - void acb_poly_interpolate_barycentric(acb_poly_t poly, acb_srcptr xs, acb_srcptr ys, slong n, slong prec) noexcept - # Recovers the unique polynomial of length at most *n* that interpolates - # the given *x* and *y* values. This implementation uses the barycentric - # form of Lagrange interpolation. - void _acb_poly_interpolation_weights(acb_ptr w, acb_ptr * tree, slong len, slong prec) noexcept - void _acb_poly_interpolate_fast_precomp(acb_ptr poly, acb_srcptr ys, acb_ptr * tree, acb_srcptr weights, slong len, slong prec) noexcept - void _acb_poly_interpolate_fast(acb_ptr poly, acb_srcptr xs, acb_srcptr ys, slong len, slong prec) noexcept - void acb_poly_interpolate_fast(acb_poly_t poly, acb_srcptr xs, acb_srcptr ys, slong n, slong prec) noexcept - # Recovers the unique polynomial of length at most *n* that interpolates - # the given *x* and *y* values, using fast Lagrange interpolation. - # The precomp function takes a precomputed product tree over the - # *x* values and a vector of interpolation weights as additional inputs. - void _acb_poly_derivative(acb_ptr res, acb_srcptr poly, slong len, slong prec) noexcept - # Sets *{res, len - 1}* to the derivative of *{poly, len}*. - # Allows aliasing of the input and output. - void acb_poly_derivative(acb_poly_t res, const acb_poly_t poly, slong prec) noexcept - # Sets *res* to the derivative of *poly*. - void _acb_poly_nth_derivative(acb_ptr res, acb_srcptr poly, ulong n, slong len, slong prec) noexcept - # Sets *{res, len - n}* to the nth derivative of *{poly, len}*. Does - # nothing if *len <= n*. Allows aliasing of the input and output. - void acb_poly_nth_derivative(acb_poly_t res, const acb_poly_t poly, ulong n, slong prec) noexcept - # Sets *res* to the nth derivative of *poly*. - void _acb_poly_integral(acb_ptr res, acb_srcptr poly, slong len, slong prec) noexcept - # Sets *{res, len}* to the integral of *{poly, len - 1}*. - # Allows aliasing of the input and output. - void acb_poly_integral(acb_poly_t res, const acb_poly_t poly, slong prec) noexcept - # Sets *res* to the integral of *poly*. - void _acb_poly_borel_transform(acb_ptr res, acb_srcptr poly, slong len, slong prec) noexcept - void acb_poly_borel_transform(acb_poly_t res, const acb_poly_t poly, slong prec) noexcept - # Computes the Borel transform of the input polynomial, mapping `\sum_k a_k x^k` - # to `\sum_k (a_k / k!) x^k`. The underscore method allows aliasing. - void _acb_poly_inv_borel_transform(acb_ptr res, acb_srcptr poly, slong len, slong prec) noexcept - void acb_poly_inv_borel_transform(acb_poly_t res, const acb_poly_t poly, slong prec) noexcept - # Computes the inverse Borel transform of the input polynomial, mapping `\sum_k a_k x^k` - # to `\sum_k a_k k! x^k`. The underscore method allows aliasing. - void _acb_poly_binomial_transform_basecase(acb_ptr b, acb_srcptr a, slong alen, slong len, slong prec) noexcept - void acb_poly_binomial_transform_basecase(acb_poly_t b, const acb_poly_t a, slong len, slong prec) noexcept - void _acb_poly_binomial_transform_convolution(acb_ptr b, acb_srcptr a, slong alen, slong len, slong prec) noexcept - void acb_poly_binomial_transform_convolution(acb_poly_t b, const acb_poly_t a, slong len, slong prec) noexcept - void _acb_poly_binomial_transform(acb_ptr b, acb_srcptr a, slong alen, slong len, slong prec) noexcept - void acb_poly_binomial_transform(acb_poly_t b, const acb_poly_t a, slong len, slong prec) noexcept - # Computes the binomial transform of the input polynomial, truncating - # the output to length *len*. See :func:`arb_poly_binomial_transform` for - # details. - # The underscore methods do not support aliasing, and assume that - # the lengths are nonzero. - void _acb_poly_graeffe_transform(acb_ptr b, acb_srcptr a, slong len, slong prec) noexcept - void acb_poly_graeffe_transform(acb_poly_t b, const acb_poly_t a, slong prec) noexcept - # Computes the Graeffe transform of input polynomial, which is of length *len*. - # See :func:`arb_poly_graeffe_transform` for details. - # The underscore method assumes that *a* and *b* are initialized, - # *a* is of length *len*, and *b* is of length at least *len*. - # Both methods allow aliasing. - void _acb_poly_pow_ui_trunc_binexp(acb_ptr res, acb_srcptr f, slong flen, ulong exp, slong len, slong prec) noexcept - # Sets *{res, len}* to *{f, flen}* raised to the power *exp*, truncated - # to length *len*. Requires that *len* is no longer than the length - # of the power as computed without truncation (i.e. no zero-padding is performed). - # Does not support aliasing of the input and output, and requires - # that *flen* and *len* are positive. - # Uses binary exponentiation. - void acb_poly_pow_ui_trunc_binexp(acb_poly_t res, const acb_poly_t poly, ulong exp, slong len, slong prec) noexcept - # Sets *res* to *poly* raised to the power *exp*, truncated to length *len*. - # Uses binary exponentiation. - void _acb_poly_pow_ui(acb_ptr res, acb_srcptr f, slong flen, ulong exp, slong prec) noexcept - # Sets *res* to *{f, flen}* raised to the power *exp*. Does not - # support aliasing of the input and output, and requires that - # *flen* is positive. - void acb_poly_pow_ui(acb_poly_t res, const acb_poly_t poly, ulong exp, slong prec) noexcept - # Sets *res* to *poly* raised to the power *exp*. - void _acb_poly_pow_series(acb_ptr h, acb_srcptr f, slong flen, acb_srcptr g, slong glen, slong len, slong prec) noexcept - # Sets *{h, len}* to the power series `f(x)^{g(x)} = \exp(g(x) \log f(x))` truncated - # to length *len*. This function detects special cases such as *g* being an - # exact small integer or `\pm 1/2`, and computes such powers more - # efficiently. This function does not support aliasing of the output - # with either of the input operands. It requires that all lengths - # are positive, and assumes that *flen* and *glen* do not exceed *len*. - void acb_poly_pow_series(acb_poly_t h, const acb_poly_t f, const acb_poly_t g, slong len, slong prec) noexcept - # Sets *h* to the power series `f(x)^{g(x)} = \exp(g(x) \log f(x))` truncated - # to length *len*. This function detects special cases such as *g* being an - # exact small integer or `\pm 1/2`, and computes such powers more - # efficiently. - void _acb_poly_pow_acb_series(acb_ptr h, acb_srcptr f, slong flen, const acb_t g, slong len, slong prec) noexcept - # Sets *{h, len}* to the power series `f(x)^g = \exp(g \log f(x))` truncated - # to length *len*. This function detects special cases such as *g* being an - # exact small integer or `\pm 1/2`, and computes such powers more - # efficiently. This function does not support aliasing of the output - # with either of the input operands. It requires that all lengths - # are positive, and assumes that *flen* does not exceed *len*. - void acb_poly_pow_acb_series(acb_poly_t h, const acb_poly_t f, const acb_t g, slong len, slong prec) noexcept - # Sets *h* to the power series `f(x)^g = \exp(g \log f(x))` truncated - # to length *len*. - void _acb_poly_sqrt_series(acb_ptr g, acb_srcptr h, slong hlen, slong n, slong prec) noexcept - void acb_poly_sqrt_series(acb_poly_t g, const acb_poly_t h, slong n, slong prec) noexcept - # Sets *g* to the power series square root of *h*, truncated to length *n*. - # Uses division-free Newton iteration for the reciprocal square root, - # followed by a multiplication. - # The underscore method does not support aliasing of the input and output - # arrays. It requires that *hlen* and *n* are greater than zero. - void _acb_poly_rsqrt_series(acb_ptr g, acb_srcptr h, slong hlen, slong n, slong prec) noexcept - void acb_poly_rsqrt_series(acb_poly_t g, const acb_poly_t h, slong n, slong prec) noexcept - # Sets *g* to the reciprocal power series square root of *h*, truncated to length *n*. - # Uses division-free Newton iteration. - # The underscore method does not support aliasing of the input and output - # arrays. It requires that *hlen* and *n* are greater than zero. - void _acb_poly_log_series(acb_ptr res, acb_srcptr f, slong flen, slong n, slong prec) noexcept - void acb_poly_log_series(acb_poly_t res, const acb_poly_t f, slong n, slong prec) noexcept - # Sets *res* to the power series logarithm of *f*, truncated to length *n*. - # Uses the formula `\log(f(x)) = \int f'(x) / f(x) dx`, adding the logarithm of the - # constant term in *f* as the constant of integration. - # The underscore method supports aliasing of the input and output - # arrays. It requires that *flen* and *n* are greater than zero. - void _acb_poly_log1p_series(acb_ptr res, acb_srcptr f, slong flen, slong n, slong prec) noexcept - void acb_poly_log1p_series(acb_poly_t res, const acb_poly_t f, slong n, slong prec) noexcept - # Computes the power series `\log(1+f)`, with better accuracy when the constant term of *f* is small. - void _acb_poly_atan_series(acb_ptr res, acb_srcptr f, slong flen, slong n, slong prec) noexcept - void acb_poly_atan_series(acb_poly_t res, const acb_poly_t f, slong n, slong prec) noexcept - # Sets *res* the power series inverse tangent of *f*, truncated to length *n*. - # Uses the formula - # .. math :: - # \tan^{-1}(f(x)) = \int f'(x) / (1+f(x)^2) dx, - # adding the function of the constant term in *f* as the constant of integration. - # The underscore method supports aliasing of the input and output - # arrays. It requires that *flen* and *n* are greater than zero. - void _acb_poly_exp_series_basecase(acb_ptr f, acb_srcptr h, slong hlen, slong n, slong prec) noexcept - void acb_poly_exp_series_basecase(acb_poly_t f, const acb_poly_t h, slong n, slong prec) noexcept - void _acb_poly_exp_series(acb_ptr f, acb_srcptr h, slong hlen, slong n, slong prec) noexcept - void acb_poly_exp_series(acb_poly_t f, const acb_poly_t h, slong n, slong prec) noexcept - # Sets `f` to the power series exponential of `h`, truncated to length `n`. - # The basecase version uses a simple recurrence for the coefficients, - # requiring `O(nm)` operations where `m` is the length of `h`. - # The main implementation uses Newton iteration, starting from a small - # number of terms given by the basecase algorithm. The complexity - # is `O(M(n))`. Redundant operations in the Newton iteration are - # avoided by using the scheme described in [HZ2004]_. - # The underscore methods support aliasing and allow the input to be - # shorter than the output, but require the lengths to be nonzero. - void _acb_poly_exp_pi_i_series(acb_ptr f, acb_srcptr h, slong hlen, slong n, slong prec) noexcept - void acb_poly_exp_pi_i_series(acb_poly_t f, const acb_poly_t h, slong n, slong prec) noexcept - # Sets *f* to the power series `\exp(\pi i h)` truncated to length *n*. - # The underscore method supports aliasing and allows the input to be - # shorter than the output, but requires the lengths to be nonzero. - void _acb_poly_sin_cos_series(acb_ptr s, acb_ptr c, acb_srcptr h, slong hlen, slong n, slong prec) noexcept void acb_poly_sin_cos_series(acb_poly_t s, acb_poly_t c, const acb_poly_t h, slong n, slong prec) noexcept - # Sets *s* and *c* to the power series sine and cosine of *h*, computed - # simultaneously. - # The underscore method supports aliasing and requires the lengths to be nonzero. - void _acb_poly_sin_series(acb_ptr s, acb_srcptr h, slong hlen, slong n, slong prec) noexcept - void acb_poly_sin_series(acb_poly_t s, const acb_poly_t h, slong n, slong prec) noexcept - void _acb_poly_cos_series(acb_ptr c, acb_srcptr h, slong hlen, slong n, slong prec) noexcept - void acb_poly_cos_series(acb_poly_t c, const acb_poly_t h, slong n, slong prec) noexcept - # Respectively evaluates the power series sine or cosine. These functions - # simply wrap :func:`_acb_poly_sin_cos_series`. The underscore methods - # support aliasing and require the lengths to be nonzero. - void _acb_poly_tan_series(acb_ptr g, acb_srcptr h, slong hlen, slong len, slong prec) noexcept - void acb_poly_tan_series(acb_poly_t g, const acb_poly_t h, slong n, slong prec) noexcept - # Sets *g* to the power series tangent of *h*. - # For small *n* takes the quotient of the sine and cosine as computed - # using the basecase algorithm. For large *n*, uses Newton iteration - # to invert the inverse tangent series. The complexity is `O(M(n))`. - # The underscore version does not support aliasing, and requires - # the lengths to be nonzero. - void _acb_poly_sin_cos_pi_series(acb_ptr s, acb_ptr c, acb_srcptr h, slong hlen, slong n, slong prec) noexcept - void acb_poly_sin_cos_pi_series(acb_poly_t s, acb_poly_t c, const acb_poly_t h, slong n, slong prec) noexcept - void _acb_poly_sin_pi_series(acb_ptr s, acb_srcptr h, slong hlen, slong n, slong prec) noexcept - void acb_poly_sin_pi_series(acb_poly_t s, const acb_poly_t h, slong n, slong prec) noexcept - void _acb_poly_cos_pi_series(acb_ptr c, acb_srcptr h, slong hlen, slong n, slong prec) noexcept - void acb_poly_cos_pi_series(acb_poly_t c, const acb_poly_t h, slong n, slong prec) noexcept - void _acb_poly_cot_pi_series(acb_ptr c, acb_srcptr h, slong hlen, slong n, slong prec) noexcept - void acb_poly_cot_pi_series(acb_poly_t c, const acb_poly_t h, slong n, slong prec) noexcept - # Compute the respective trigonometric functions of the input - # multiplied by `\pi`. - void _acb_poly_sinh_cosh_series_basecase(acb_ptr s, acb_ptr c, acb_srcptr h, slong hlen, slong n, slong prec) noexcept - void acb_poly_sinh_cosh_series_basecase(acb_poly_t s, acb_poly_t c, const acb_poly_t h, slong n, slong prec) noexcept - void _acb_poly_sinh_cosh_series_exponential(acb_ptr s, acb_ptr c, acb_srcptr h, slong hlen, slong n, slong prec) noexcept - void acb_poly_sinh_cosh_series_exponential(acb_poly_t s, acb_poly_t c, const acb_poly_t h, slong n, slong prec) noexcept - void _acb_poly_sinh_cosh_series(acb_ptr s, acb_ptr c, acb_srcptr h, slong hlen, slong n, slong prec) noexcept - void acb_poly_sinh_cosh_series(acb_poly_t s, acb_poly_t c, const acb_poly_t h, slong n, slong prec) noexcept - void _acb_poly_sinh_series(acb_ptr s, acb_srcptr h, slong hlen, slong n, slong prec) noexcept - void acb_poly_sinh_series(acb_poly_t s, const acb_poly_t h, slong n, slong prec) noexcept - void _acb_poly_cosh_series(acb_ptr c, acb_srcptr h, slong hlen, slong n, slong prec) noexcept - void acb_poly_cosh_series(acb_poly_t c, const acb_poly_t h, slong n, slong prec) noexcept - # Sets *s* and *c* respectively to the hyperbolic sine and cosine of the - # power series *h*, truncated to length *n*. - # The implementations mirror those for sine and cosine, except that - # the *exponential* version computes both functions using the exponential - # function instead of the hyperbolic tangent. - void _acb_poly_sinc_series(acb_ptr s, acb_srcptr h, slong hlen, slong n, slong prec) noexcept - void acb_poly_sinc_series(acb_poly_t s, const acb_poly_t h, slong n, slong prec) noexcept - # Sets *s* to the sinc function of the power series *h*, truncated - # to length *n*. - void _acb_poly_lambertw_series(acb_ptr res, acb_srcptr z, slong zlen, const fmpz_t k, int flags, slong len, slong prec) noexcept - void acb_poly_lambertw_series(acb_poly_t res, const acb_poly_t z, const fmpz_t k, int flags, slong len, slong prec) noexcept - # Sets *res* to branch *k* of the Lambert W function of the power series *z*. - # The argument *flags* is reserved for future use. - # The underscore method allows aliasing, but assumes that the lengths are nonzero. - void _acb_poly_gamma_series(acb_ptr res, acb_srcptr h, slong hlen, slong n, slong prec) noexcept - void acb_poly_gamma_series(acb_poly_t res, const acb_poly_t h, slong n, slong prec) noexcept - void _acb_poly_rgamma_series(acb_ptr res, acb_srcptr h, slong hlen, slong n, slong prec) noexcept - void acb_poly_rgamma_series(acb_poly_t res, const acb_poly_t h, slong n, slong prec) noexcept - void _acb_poly_lgamma_series(acb_ptr res, acb_srcptr h, slong hlen, slong n, slong prec) noexcept - void acb_poly_lgamma_series(acb_poly_t res, const acb_poly_t h, slong n, slong prec) noexcept - void _acb_poly_digamma_series(acb_ptr res, acb_srcptr h, slong hlen, slong n, slong prec) noexcept - void acb_poly_digamma_series(acb_poly_t res, const acb_poly_t h, slong n, slong prec) noexcept - # Sets *res* to the series expansion of `\Gamma(h(x))`, `1/\Gamma(h(x))`, - # or `\log \Gamma(h(x))`, `\psi(h(x))`, truncated to length *n*. - # These functions first generate the Taylor series at the constant - # term of *h*, and then call :func:`_acb_poly_compose_series`. - # The Taylor coefficients are generated using Stirling's series. - # The underscore methods support aliasing of the input and output - # arrays, and require that *hlen* and *n* are greater than zero. - void _acb_poly_rising_ui_series(acb_ptr res, acb_srcptr f, slong flen, ulong r, slong trunc, slong prec) noexcept - void acb_poly_rising_ui_series(acb_poly_t res, const acb_poly_t f, ulong r, slong trunc, slong prec) noexcept - # Sets *res* to the rising factorial `(f) (f+1) (f+2) \cdots (f+r-1)`, truncated - # to length *trunc*. The underscore method assumes that *flen*, *r* and *trunc* - # are at least 1, and does not support aliasing. Uses binary splitting. - void _acb_poly_powsum_series_naive(acb_ptr z, const acb_t s, const acb_t a, const acb_t q, slong n, slong len, slong prec) noexcept - void _acb_poly_powsum_series_naive_threaded(acb_ptr z, const acb_t s, const acb_t a, const acb_t q, slong n, slong len, slong prec) noexcept - # Computes - # .. math :: - # z = S(s,a,n) = \sum_{k=0}^{n-1} \frac{q^k}{(k+a)^{s+t}} - # as a power series in `t` truncated to length *len*. This function - # evaluates the sum naively term by term. - # The *threaded* version splits the computation - # over the number of threads returned by *flint_get_num_threads()*. - void _acb_poly_powsum_one_series_sieved(acb_ptr z, const acb_t s, slong n, slong len, slong prec) noexcept - # Computes - # .. math :: - # z = S(s,1,n) \sum_{k=1}^n \frac{1}{k^{s+t}} - # as a power series in `t` truncated to length *len*. - # This function stores a table of powers that have already been calculated, - # computing `(ij)^r` as `i^r j^r` whenever `k = ij` is - # composite. As a further optimization, it groups all even `k` and - # evaluates the sum as a polynomial in `2^{-(s+t)}`. - # This scheme requires about `n / \log n` powers, `n / 2` multiplications, - # and temporary storage of `n / 6` power series. Due to the extra - # power series multiplications, it is only faster than the naive - # algorithm when *len* is small. - void _acb_poly_zeta_em_choose_param(mag_t bound, ulong * N, ulong * M, const acb_t s, const acb_t a, slong d, slong target, slong prec) noexcept - # Chooses *N* and *M* for Euler-Maclaurin summation of the - # Hurwitz zeta function, using a default algorithm. - void _acb_poly_zeta_em_bound1(mag_t bound, const acb_t s, const acb_t a, slong N, slong M, slong d, slong wp) noexcept - void _acb_poly_zeta_em_bound(arb_ptr vec, const acb_t s, const acb_t a, ulong N, ulong M, slong d, slong wp) noexcept - # Compute bounds for Euler-Maclaurin evaluation of the Hurwitz zeta function - # or its power series, using the formulas in [Joh2013]_. - void _acb_poly_zeta_em_tail_naive(acb_ptr z, const acb_t s, const acb_t Na, acb_srcptr Nasx, slong M, slong len, slong prec) noexcept - void _acb_poly_zeta_em_tail_bsplit(acb_ptr z, const acb_t s, const acb_t Na, acb_srcptr Nasx, slong M, slong len, slong prec) noexcept - # Evaluates the tail in the Euler-Maclaurin sum for the Hurwitz zeta - # function, respectively using the naive recurrence and binary splitting. - void _acb_poly_zeta_em_sum(acb_ptr z, const acb_t s, const acb_t a, int deflate, ulong N, ulong M, slong d, slong prec) noexcept - # Evaluates the truncated Euler-Maclaurin sum of order `N, M` for the - # length-*d* truncated Taylor series of the Hurwitz zeta function - # `\zeta(s,a)` at `s`, using a working precision of *prec* bits. - # With `a = 1`, this gives the usual Riemann zeta function. - # If *deflate* is nonzero, `\zeta(s,a) - 1/(s-1)` is evaluated - # (which permits series expansion at `s = 1`). - void _acb_poly_zeta_cpx_series(acb_ptr z, const acb_t s, const acb_t a, int deflate, slong d, slong prec) noexcept - # Computes the series expansion of `\zeta(s+x,a)` (or - # `\zeta(s+x,a) - 1/(s+x-1)` if *deflate* is nonzero) to order *d*. - # This function wraps :func:`_acb_poly_zeta_em_sum`, automatically choosing - # default values for `N, M` using :func:`_acb_poly_zeta_em_choose_param` to - # target an absolute truncation error of `2^{-\operatorname{prec}}`. - void _acb_poly_zeta_series(acb_ptr res, acb_srcptr h, slong hlen, const acb_t a, int deflate, slong len, slong prec) noexcept - void acb_poly_zeta_series(acb_poly_t res, const acb_poly_t f, const acb_t a, int deflate, slong n, slong prec) noexcept - # Sets *res* to the Hurwitz zeta function `\zeta(s,a)` where `s` a power - # series and `a` is a constant, truncated to length *n*. - # To evaluate the usual Riemann zeta function, set `a = 1`. - # If *deflate* is nonzero, evaluates `\zeta(s,a) + 1/(1-s)`, which - # is well-defined as a limit when the constant term of `s` is 1. - # In particular, expanding `\zeta(s,a) + 1/(1-s)` with `s = 1+x` - # gives the Stieltjes constants - # .. math :: - # \sum_{k=0}^{n-1} \frac{(-1)^k}{k!} \gamma_k(a) x^k`. - # If `a = 1`, this implementation uses the reflection formula if the midpoint - # of the constant term of `s` is negative. - void _acb_poly_polylog_cpx_small(acb_ptr w, const acb_t s, const acb_t z, slong len, slong prec) noexcept - void _acb_poly_polylog_cpx_zeta(acb_ptr w, const acb_t s, const acb_t z, slong len, slong prec) noexcept - void _acb_poly_polylog_cpx(acb_ptr w, const acb_t s, const acb_t z, slong len, slong prec) noexcept - # Sets *w* to the Taylor series with respect to *x* of the polylogarithm - # `\operatorname{Li}_{s+x}(z)`, where *s* and *z* are given complex - # constants. The output is computed to length *len* which must be positive. - # Aliasing between *w* and *s* or *z* is not permitted. - # The *small* version uses the standard power series expansion with respect - # to *z*, convergent when `|z| < 1`. The *zeta* version evaluates - # the polylogarithm as a sum of two Hurwitz zeta functions. - # The default version automatically delegates to the *small* version - # when *z* is close to zero, and the *zeta* version otherwise. - # For further details, see :ref:`algorithms_polylogarithms`. - void _acb_poly_polylog_series(acb_ptr w, acb_srcptr s, slong slen, const acb_t z, slong len, slong prec) noexcept - void acb_poly_polylog_series(acb_poly_t w, const acb_poly_t s, const acb_t z, slong len, slong prec) noexcept - # Sets *w* to the polylogarithm `\operatorname{Li}_{s}(z)` where *s* is a given - # power series, truncating the output to length *len*. The underscore method - # requires all lengths to be positive and supports aliasing between - # all inputs and outputs. - void _acb_poly_erf_series(acb_ptr res, acb_srcptr z, slong zlen, slong n, slong prec) noexcept - void acb_poly_erf_series(acb_poly_t res, const acb_poly_t z, slong n, slong prec) noexcept - # Sets *res* to the error function of the power series *z*, truncated to length *n*. - # These methods are provided for backwards compatibility. - # See :func:`acb_hypgeom_erf_series`, :func:`acb_hypgeom_erfc_series`, - # :func:`acb_hypgeom_erfi_series`. - void _acb_poly_agm1_series(acb_ptr res, acb_srcptr z, slong zlen, slong len, slong prec) noexcept - void acb_poly_agm1_series(acb_poly_t res, const acb_poly_t z, slong n, slong prec) noexcept - # Sets *res* to the arithmetic-geometric mean of 1 and the power series *z*, - # truncated to length *n*. - void _acb_poly_elliptic_k_series(acb_ptr res, acb_srcptr z, slong zlen, slong len, slong prec) noexcept - void acb_poly_elliptic_k_series(acb_poly_t res, const acb_poly_t z, slong n, slong prec) noexcept - void _acb_poly_elliptic_p_series(acb_ptr res, acb_srcptr z, slong zlen, const acb_t tau, slong len, slong prec) noexcept - void acb_poly_elliptic_p_series(acb_poly_t res, const acb_poly_t z, const acb_t tau, slong n, slong prec) noexcept - void _acb_poly_root_bound_fujiwara(mag_t bound, acb_srcptr poly, slong len) noexcept - void acb_poly_root_bound_fujiwara(mag_t bound, acb_poly_t poly) noexcept - # Sets *bound* to an upper bound for the magnitude of all the complex - # roots of *poly*. Uses Fujiwara's bound - # .. math :: - # 2 \max \left\{\left|\frac{a_{n-1}}{a_n}\right|, - # \left|\frac{a_{n-2}}{a_n}\right|^{1/2}, - # \cdots, - # \left|\frac{a_1}{a_n}\right|^{1/(n-1)}, - # \left|\frac{a_0}{2a_n}\right|^{1/n} - # \right\} - # where `a_0, \ldots, a_n` are the coefficients of *poly*. - void _acb_poly_root_inclusion(acb_t r, const acb_t m, acb_srcptr poly, acb_srcptr polyder, slong len, slong prec) noexcept - # Given any complex number `m`, and a nonconstant polynomial `f` and its - # derivative `f'`, sets *r* to a complex interval centered on `m` that is - # guaranteed to contain at least one root of `f`. - # Such an interval is obtained by taking a ball of radius `|f(m)/f'(m)| n` - # where `n` is the degree of `f`. Proof: assume that the distance - # to the nearest root exceeds `r = |f(m)/f'(m)| n`. Then - # .. math :: - # \left|\frac{f'(m)}{f(m)}\right| = - # \left|\sum_i \frac{1}{m-\zeta_i}\right| - # \le \sum_i \frac{1}{|m-\zeta_i|} - # < \frac{n}{r} = \left|\frac{f'(m)}{f(m)}\right| - # which is a contradiction (see [Kob2010]_). - slong _acb_poly_validate_roots(acb_ptr roots, acb_srcptr poly, slong len, slong prec) noexcept - # Given a list of approximate roots of the input polynomial, this - # function sets a rigorous bounding interval for each root, and determines - # which roots are isolated from all the other roots. - # It then rearranges the list of roots so that the isolated roots - # are at the front of the list, and returns the count of isolated roots. - # If the return value equals the degree of the polynomial, then all - # roots have been found. If the return value is smaller, all the - # remaining output intervals are guaranteed to contain roots, but - # it is possible that not all of the polynomial's roots are contained - # among them. - void _acb_poly_refine_roots_durand_kerner(acb_ptr roots, acb_srcptr poly, slong len, slong prec) noexcept - # Refines the given roots simultaneously using a single iteration - # of the Durand-Kerner method. The radius of each root is set to an - # approximation of the correction, giving a rough estimate of its error (not - # a rigorous bound). - slong _acb_poly_find_roots(acb_ptr roots, acb_srcptr poly, acb_srcptr initial, slong len, slong maxiter, slong prec) noexcept - slong acb_poly_find_roots(acb_ptr roots, const acb_poly_t poly, acb_srcptr initial, slong maxiter, slong prec) noexcept - # Attempts to compute all the roots of the given nonzero polynomial *poly* - # using a working precision of *prec* bits. If *n* denotes the degree of *poly*, - # the function writes *n* approximate roots with rigorous error bounds to - # the preallocated array *roots*, and returns the number of - # roots that are isolated. - # If the return value equals the degree of the polynomial, then all - # roots have been found. If the return value is smaller, all the output - # intervals are guaranteed to contain roots, but it is possible that - # not all of the polynomial's roots are contained among them. - # The roots are computed numerically by performing several steps with - # the Durand-Kerner method and terminating if the estimated accuracy of - # the roots approaches the working precision or if the number - # of steps exceeds *maxiter*, which can be set to zero in order to use - # a default value. Finally, the approximate roots are validated rigorously. - # Initial values for the iteration can be provided as the array *initial*. - # If *initial* is set to *NULL*, default values `(0.4+0.9i)^k` are used. - # The polynomial is assumed to be squarefree. If there are repeated - # roots, the iteration is likely to find them (with low numerical accuracy), - # but the error bounds will not converge as the precision increases. - int _acb_poly_validate_real_roots(acb_srcptr roots, acb_srcptr poly, slong len, slong prec) noexcept - int acb_poly_validate_real_roots(acb_srcptr roots, const acb_poly_t poly, slong prec) noexcept - # Given a strictly real polynomial *poly* (of length *len*) and isolating - # intervals for all its complex roots, determines if all the real roots - # are separated from the non-real roots. If this function returns nonzero, - # every root enclosure that touches the real axis (as tested by applying - # :func:`arb_contains_zero` to the imaginary part) corresponds to a real root - # (its imaginary part can be set to zero), and every other root enclosure - # corresponds to a non-real root (with known sign for the imaginary part). - # If this function returns zero, then the signs of the imaginary parts - # are not known for certain, based on the accuracy of the inputs - # and the working precision *prec*. from .acb_poly_macros cimport * diff --git a/src/sage/libs/flint/acb_poly_macros.pxd b/src/sage/libs/flint/acb_poly_macros.pxd index 18a51a7e315..7fa5b0fe852 100644 --- a/src/sage/libs/flint/acb_poly_macros.pxd +++ b/src/sage/libs/flint/acb_poly_macros.pxd @@ -1,8 +1,7 @@ # Macros from acb_poly.h -# See https://github.com/flintlib/flint/issues/152 +# See https://github.com/flintlib/flint/issues/1529 from .types cimport * cdef extern from "flint_wrap.h": acb_ptr acb_poly_get_coeff_ptr(acb_poly_t p, ulong n) - # Macro giving a pointer to the n-th coefficient of p (or NULL) diff --git a/src/sage/libs/flint/acb_theta.pxd b/src/sage/libs/flint/acb_theta.pxd new file mode 100644 index 00000000000..9ae702fc37f --- /dev/null +++ b/src/sage/libs/flint/acb_theta.pxd @@ -0,0 +1,123 @@ +# distutils: libraries = flint +# distutils: depends = flint/acb_theta.h + +################################################################################ +# This file is auto-generated by the script +# SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py. +# Do not modify by hand! Fix and rerun the script instead. +################################################################################ + +from libc.stdio cimport FILE +from sage.libs.gmp.types cimport * +from sage.libs.mpfr.types cimport * +from sage.libs.flint.types cimport * + +cdef extern from "flint_wrap.h": + void acb_theta_all(acb_ptr th, acb_srcptr z, const acb_mat_t tau, int sqr, slong prec) noexcept + void acb_theta_naive_fixed_ab(acb_ptr th, ulong ab, acb_srcptr zs, slong nb, const acb_mat_t tau, slong prec) noexcept + void acb_theta_naive_all(acb_ptr th, acb_srcptr zs, slong nb, const acb_mat_t tau, slong prec) noexcept + void acb_theta_jet_all(acb_ptr dth, acb_srcptr z, const acb_mat_t tau, slong ord, slong prec) noexcept + void acb_theta_jet_naive_fixed_ab(acb_ptr dth, ulong ab, acb_srcptr z, const acb_mat_t tau, slong ord, slong prec) noexcept + void acb_theta_jet_naive_all(acb_ptr dth, acb_srcptr z, const acb_mat_t tau, slong ord, slong prec) noexcept + slong sp2gz_dim(const fmpz_mat_t mat) noexcept + void sp2gz_set_blocks(fmpz_mat_t mat, const fmpz_mat_t alpha, const fmpz_mat_t beta, const fmpz_mat_t gamma, const fmpz_mat_t delta) noexcept + void sp2gz_j(fmpz_mat_t mat) noexcept + void sp2gz_block_diag(fmpz_mat_t mat, const fmpz_mat_t U) noexcept + void sp2gz_trig(fmpz_mat_t mat, const fmpz_mat_t S) noexcept + void sp2gz_embed(fmpz_mat_t res, const fmpz_mat_t mat) noexcept + void sp2gz_restrict(fmpz_mat_t res, const fmpz_mat_t mat) noexcept + slong sp2gz_nb_fundamental(slong g) noexcept + void sp2gz_fundamental(fmpz_mat_t mat, slong j) noexcept + bint sp2gz_is_correct(const fmpz_mat_t mat) noexcept + bint sp2gz_is_j(const fmpz_mat_t mat) noexcept + bint sp2gz_is_block_diag(const fmpz_mat_t mat) noexcept + bint sp2gz_is_trig(const fmpz_mat_t mat) noexcept + bint sp2gz_is_embedded(fmpz_mat_t res, const fmpz_mat_t mat) noexcept + void sp2gz_inv(fmpz_mat_t inv, const fmpz_mat_t mat) noexcept + fmpz_mat_struct * sp2gz_decompose(slong * nb, const fmpz_mat_t mat) noexcept + void sp2gz_randtest(fmpz_mat_t mat, flint_rand_t state, slong bits) noexcept + void acb_siegel_cocycle(acb_mat_t c, const fmpz_mat_t mat, const acb_mat_t tau, slong prec) noexcept + void acb_siegel_transform_cocycle_inv(acb_mat_t w, acb_mat_t c, acb_mat_t cinv, const fmpz_mat_t mat, const acb_mat_t tau, slong prec) noexcept + void acb_siegel_transform(acb_mat_t w, const fmpz_mat_t mat, const acb_mat_t tau, slong prec) noexcept + void acb_siegel_transform_z(acb_ptr r, acb_mat_t w, const fmpz_mat_t mat, acb_srcptr z, const acb_mat_t tau, slong prec) noexcept + void acb_siegel_cho(arb_mat_t C, const acb_mat_t tau, slong prec) noexcept + void acb_siegel_yinv(arb_mat_t Yinv, const acb_mat_t tau, slong prec) noexcept + void acb_siegel_reduce(fmpz_mat_t mat, const acb_mat_t tau, slong prec) noexcept + bint acb_siegel_is_reduced(const acb_mat_t tau, slong tol_exp, slong prec) noexcept + void acb_siegel_randtest(acb_mat_t tau, flint_rand_t state, slong prec, slong mag_bits) noexcept + void acb_siegel_randtest_reduced(acb_mat_t tau, flint_rand_t state, slong prec, slong mag_bits) noexcept + void acb_siegel_randtest_vec(acb_ptr z, flint_rand_t state, slong g, slong prec) noexcept + void acb_theta_char_get_slong(slong * n, ulong a, slong g) noexcept + ulong acb_theta_char_get_a(const slong * n, slong g) noexcept + void acb_theta_char_get_arb(arb_ptr v, ulong a, slong g) noexcept + void acb_theta_char_get_acb(acb_ptr v, ulong a, slong g) noexcept + slong acb_theta_char_dot(ulong a, ulong b, slong g) noexcept + slong acb_theta_char_dot_slong(ulong a, const slong * n, slong g) noexcept + void acb_theta_char_dot_acb(acb_t x, ulong a, acb_srcptr z, slong g, slong prec) noexcept + bint acb_theta_char_is_even(ulong ab, slong g) noexcept + bint acb_theta_char_is_goepel(ulong ch1, ulong ch2, ulong ch3, ulong ch4, slong g) noexcept + bint acb_theta_char_is_syzygous(ulong ch1, ulong ch2, ulong ch3, slong g) noexcept + void acb_theta_eld_init(acb_theta_eld_t E, slong d, slong g) noexcept + void acb_theta_eld_clear(acb_theta_eld_t E) noexcept + int acb_theta_eld_set(acb_theta_eld_t E, const arb_mat_t C, const arf_t R2, arb_srcptr v) noexcept + void acb_theta_eld_points(slong * pts, const acb_theta_eld_t E) noexcept + void acb_theta_eld_border(slong * pts, const acb_theta_eld_t E) noexcept + bint acb_theta_eld_contains(const acb_theta_eld_t E, slong * pt) noexcept + void acb_theta_eld_print(const acb_theta_eld_t E) noexcept + void acb_theta_naive_radius(arf_t R2, arf_t eps, const arb_mat_t C, slong ord, slong prec) noexcept + void acb_theta_naive_reduce(arb_ptr v, acb_ptr new_zs, arb_ptr as, acb_ptr cs, arb_ptr us, acb_srcptr zs, slong nb, const acb_mat_t tau, slong prec) noexcept + void acb_theta_naive_term(acb_t res, acb_srcptr z, const acb_mat_t tau, slong * tup, slong * n, slong prec) noexcept + void acb_theta_naive_worker(acb_ptr th, slong len, acb_srcptr zs, slong nb, const acb_mat_t tau, const acb_theta_eld_t E, slong ord, slong prec, acb_theta_naive_worker_t worker) noexcept + void acb_theta_naive_00(acb_ptr th, acb_srcptr zs, slong nb, const acb_mat_t tau, slong prec) noexcept + void acb_theta_naive_0b(acb_ptr th, acb_srcptr zs, slong nb, const acb_mat_t tau, slong prec) noexcept + void acb_theta_naive_fixed_a(acb_ptr th, ulong a, acb_srcptr zs, slong nb, const acb_mat_t tau, slong prec) noexcept + slong acb_theta_jet_nb(slong ord, slong g) noexcept + slong acb_theta_jet_total_order(const slong * tup, slong g) noexcept + void acb_theta_jet_tuples(slong * tups, slong ord, slong g) noexcept + slong acb_theta_jet_index(const slong * tup, slong g) noexcept + void acb_theta_jet_mul(acb_ptr res, acb_srcptr v1, acb_srcptr v2, slong ord, slong g, slong prec) noexcept + void acb_theta_jet_compose(acb_ptr res, acb_srcptr v, const acb_mat_t N, slong ord, slong prec) noexcept + void acb_theta_jet_exp_pi_i(acb_ptr res, arb_srcptr a, slong ord, slong g, slong prec) noexcept + void acb_theta_jet_naive_radius(arf_t R2, arf_t eps, arb_srcptr v, const arb_mat_t C, slong ord, slong prec) noexcept + void acb_theta_jet_naive_00(acb_ptr dth, acb_srcptr z, const acb_mat_t tau, slong ord, slong prec) noexcept + void acb_theta_jet_error_bounds(arb_ptr err, acb_srcptr z, const acb_mat_t tau, acb_srcptr dth, slong ord, slong prec) noexcept + void acb_theta_dist_pt(arb_t d, arb_srcptr v, const arb_mat_t C, slong * n, slong prec) noexcept + void acb_theta_dist_lat(arb_t d, arb_srcptr v, const arb_mat_t C, slong prec) noexcept + void acb_theta_dist_a0(arb_ptr d, acb_srcptr z, const acb_mat_t tau, slong prec) noexcept + slong acb_theta_dist_addprec(const arb_t d) noexcept + void acb_theta_agm_hadamard(acb_ptr res, acb_srcptr a, slong g, slong prec) noexcept + void acb_theta_agm_sqrt(acb_ptr res, acb_srcptr a, acb_srcptr rts, slong nb, slong prec) noexcept + void acb_theta_agm_mul(acb_ptr res, acb_srcptr a1, acb_srcptr a2, slong g, slong prec) noexcept + void acb_theta_agm_mul_tight(acb_ptr res, acb_srcptr a0, acb_srcptr a, arb_srcptr d0, arb_srcptr d, slong g, slong prec) noexcept + int acb_theta_ql_a0_naive(acb_ptr th, acb_srcptr t, acb_srcptr z, arb_srcptr d0, arb_srcptr d, const acb_mat_t tau, slong guard, slong prec) noexcept + int acb_theta_ql_a0_split(acb_ptr th, acb_srcptr t, acb_srcptr z, arb_srcptr d, const acb_mat_t tau, slong s, slong guard, slong prec, acb_theta_ql_worker_t worker) noexcept + int acb_theta_ql_a0_steps(acb_ptr th, acb_srcptr t, acb_srcptr z, arb_srcptr d0, arb_srcptr d, const acb_mat_t tau, slong nb_steps, slong s, slong guard, slong prec, acb_theta_ql_worker_t worker) noexcept + slong acb_theta_ql_a0_nb_steps(const arb_mat_t C, slong s, slong prec) noexcept + int acb_theta_ql_a0(acb_ptr th, acb_srcptr t, acb_srcptr z, arb_srcptr d0, arb_srcptr d, const acb_mat_t tau, slong guard, slong prec) noexcept + slong acb_theta_ql_reduce(acb_ptr new_z, acb_t c, arb_t u, slong * n1, acb_srcptr z, const acb_mat_t tau, slong prec) noexcept + void acb_theta_ql_all(acb_ptr th, acb_srcptr z, const acb_mat_t tau, int sqr, slong prec) noexcept + void acb_theta_jet_ql_bounds(arb_t c, arb_t rho, acb_srcptr z, const acb_mat_t tau, slong ord) noexcept + void acb_theta_jet_ql_radius(arf_t eps, arf_t err, const arb_t c, const arb_t rho, slong ord, slong g, slong prec) noexcept + void acb_theta_jet_ql_finite_diff(acb_ptr dth, const arf_t eps, const arf_t err, acb_srcptr val, slong ord, slong g, slong prec) noexcept + void acb_theta_jet_ql_all(acb_ptr dth, acb_srcptr z, const acb_mat_t tau, slong ord, slong prec) noexcept + ulong acb_theta_transform_char(slong * e, const fmpz_mat_t mat, ulong ab) noexcept + void acb_theta_transform_sqrtdet(acb_t res, const acb_mat_t tau, slong prec) noexcept + slong acb_theta_transform_kappa(acb_t sqrtdet, const fmpz_mat_t mat, const acb_mat_t tau, slong prec) noexcept + slong acb_theta_transform_kappa2(const fmpz_mat_t mat) noexcept + void acb_theta_transform_proj(acb_ptr res, const fmpz_mat_t mat, acb_srcptr th, int sqr, slong prec) noexcept + void acb_theta_g2_jet_naive_1(acb_ptr dth, const acb_mat_t tau, slong prec) noexcept + void acb_theta_g2_detk_symj(acb_poly_t res, const acb_mat_t m, const acb_poly_t f, slong k, slong j, slong prec) noexcept + void acb_theta_g2_transvectant(acb_poly_t res, const acb_poly_t g, const acb_poly_t h, slong m, slong n, slong k, slong prec) noexcept + void acb_theta_g2_transvectant_lead(acb_t res, const acb_poly_t g, const acb_poly_t h, slong m, slong n, slong k, slong prec) noexcept + slong acb_theta_g2_character(const fmpz_mat_t mat) noexcept + void acb_theta_g2_psi4(acb_t res, acb_srcptr th2, slong prec) noexcept + void acb_theta_g2_psi6(acb_t res, acb_srcptr th2, slong prec) noexcept + void acb_theta_g2_chi10(acb_t res, acb_srcptr th2, slong prec) noexcept + void acb_theta_g2_chi12(acb_t res, acb_srcptr th2, slong prec) noexcept + void acb_theta_g2_chi5(acb_t res, acb_srcptr th, slong prec) noexcept + void acb_theta_g2_chi35(acb_t res, acb_srcptr th, slong prec) noexcept + void acb_theta_g2_chi3_6(acb_poly_t res, acb_srcptr dth, slong prec) noexcept + void acb_theta_g2_sextic(acb_poly_t res, const acb_mat_t tau, slong prec) noexcept + void acb_theta_g2_sextic_chi5(acb_poly_t res, acb_t chi5, const acb_mat_t tau, slong prec) noexcept + void acb_theta_g2_covariants(acb_poly_struct * res, const acb_poly_t f, slong prec) noexcept + void acb_theta_g2_covariants_lead(acb_ptr res, const acb_poly_t f, slong prec) noexcept diff --git a/src/sage/libs/flint/acf.pxd b/src/sage/libs/flint/acf.pxd index 1cde16d26ea..0e65a589a7e 100644 --- a/src/sage/libs/flint/acf.pxd +++ b/src/sage/libs/flint/acf.pxd @@ -2,7 +2,9 @@ # distutils: depends = flint/acf.h ################################################################################ -# This file is auto-generated. Do not modify by hand +# This file is auto-generated by the script +# SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py. +# Do not modify by hand! Fix and rerun the script instead. ################################################################################ from libc.stdio cimport FILE @@ -11,47 +13,18 @@ from sage.libs.mpfr.types cimport * from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void acf_init(acf_t x) noexcept - # Initializes the variable *x* for use, and sets its value to zero. - void acf_clear(acf_t x) noexcept - # Clears the variable *x*, freeing or recycling its allocated memory. - void acf_swap(acf_t z, acf_t x) noexcept - # Swaps *z* and *x* efficiently. - slong acf_allocated_bytes(const acf_t x) noexcept - # Returns the total number of bytes heap-allocated internally by this object. - # The count excludes the size of the structure itself. Add - # ``sizeof(acf_struct)`` to get the size of the object as a whole. - arf_ptr acf_real_ptr(acf_t z) noexcept arf_ptr acf_imag_ptr(acf_t z) noexcept - # Returns a pointer to the real or imaginary part of *z*. - void acf_set(acf_t z, const acf_t x) noexcept - # Sets *z* to the value *x*. - bint acf_equal(const acf_t x, const acf_t y) noexcept - # Returns whether *x* and *y* are equal. - int acf_add(acf_t res, const acf_t x, const acf_t y, slong prec, arf_rnd_t rnd) noexcept - int acf_sub(acf_t res, const acf_t x, const acf_t y, slong prec, arf_rnd_t rnd) noexcept - int acf_mul(acf_t res, const acf_t x, const acf_t y, slong prec, arf_rnd_t rnd) noexcept - # Sets *res* to the sum, difference or product of *x* or *y*, correctly - # rounding the real and imaginary parts in direction *rnd*. - # The return flag has the least significant bit set if the real - # part is inexact, and the second least significant bit set if - # the imaginary part is inexact. - void acf_approx_inv(acf_t res, const acf_t x, slong prec, arf_rnd_t rnd) noexcept void acf_approx_div(acf_t res, const acf_t x, const acf_t y, slong prec, arf_rnd_t rnd) noexcept void acf_approx_sqrt(acf_t res, const acf_t x, slong prec, arf_rnd_t rnd) noexcept - # Computes an approximate inverse, quotient or square root. - void acf_approx_dot(acf_t res, const acf_t initial, int subtract, acf_srcptr x, slong xstep, acf_srcptr y, slong ystep, slong len, slong prec, arf_rnd_t rnd) noexcept - # Computes an approximate dot product, with the same meaning of - # the parameters as :func:`arb_dot`. diff --git a/src/sage/libs/flint/aprcl.pxd b/src/sage/libs/flint/aprcl.pxd index 95be5a520dd..4eaa71b85bc 100644 --- a/src/sage/libs/flint/aprcl.pxd +++ b/src/sage/libs/flint/aprcl.pxd @@ -2,7 +2,9 @@ # distutils: depends = flint/aprcl.h ################################################################################ -# This file is auto-generated. Do not modify by hand +# This file is auto-generated by the script +# SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py. +# Do not modify by hand! Fix and rerun the script instead. ################################################################################ from libc.stdio cimport FILE @@ -11,269 +13,70 @@ from sage.libs.mpfr.types cimport * from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - bint aprcl_is_prime(const fmpz_t n) noexcept - # Tests `n` for primality using the APRCL test. - # This is the same as :func:`aprcl_is_prime_jacobi`. - bint aprcl_is_prime_jacobi(const fmpz_t n) noexcept - # If `n` is prime returns 1; otherwise returns 0. The algorithm is well described - # in "Implementation of a New Primality Test" by H. Cohen and A.K. Lenstra and - # "A Course in Computational Algebraic Number Theory" by H. Cohen. - # It is theoretically possible that this function fails to prove that - # `n` is prime. In this event, :func:`flint_abort` is called. - # To handle this condition, the :func:`_aprcl_is_prime_jacobi` function - # can be used. - bint aprcl_is_prime_gauss(const fmpz_t n) noexcept - # If `n` is prime returns 1; otherwise returns 0. - # Uses the cyclotomic primality testing algorithm described in - # "Four primality testing algorithms" by Rene Schoof. - # The minimum required numbers `s` and `R` are computed automatically. - # By default `R \ge 180`. In some cases this function fails to prove - # that `n` is prime. This means that we select a too small `R` value. - # In this event, :func:`flint_abort` is called. - # To handle this condition, the :func:`_aprcl_is_prime_jacobi` function - # can be used. - primality_test_status _aprcl_is_prime_jacobi(const fmpz_t n, const aprcl_config config) noexcept - # Jacobi sum test for `n`. Possible return values: - # ``PRIME``, ``COMPOSITE`` and ``UNKNOWN`` (if we cannot - # prove primality). - primality_test_status _aprcl_is_prime_gauss(const fmpz_t n, const aprcl_config config) noexcept - # Tests `n` for primality with fixed ``config``. Possible return values: - # ``PRIME``, ``COMPOSITE`` and ``PROBABPRIME`` - # (if we cannot prove primality). - bint aprcl_is_prime_gauss_min_R(const fmpz_t n, ulong R) noexcept - # Same as :func:`aprcl_is_prime_gauss` with fixed minimum value of `R`. - bint aprcl_is_prime_final_division(const fmpz_t n, const fmpz_t s, ulong r) noexcept - # Returns 0 if for some `a = n^k \bmod s`, where `k \in [1, r - 1]`, - # we have that `a \mid n`; otherwise returns 1. - void aprcl_config_gauss_init(aprcl_config conf, const fmpz_t n) noexcept - # Computes the `s` and `R` values used in the cyclotomic primality test, - # `s^2 > n` and `s=\prod\limits_{\substack{q-1\mid R \\ q \text{ prime}}}q`. - # Also stores factors of `R` and `s`. - void aprcl_config_gauss_init_min_R(aprcl_config conf, const fmpz_t n, ulong R) noexcept - # Computes the `s` with fixed minimum `R` such that `a^R \equiv 1 \mod{s}` - # for all integers `a` coprime to `s`. - void aprcl_config_gauss_clear(aprcl_config conf) noexcept - # Clears the given ``aprcl_config`` element. It must be reinitialised in - # order to be used again. - ulong aprcl_R_value(const fmpz_t n) noexcept - # Returns a precomputed `R` value for APRCL, such that the - # corresponding `s` value is greater than `\sqrt{n}`. The maximum - # stored value `6983776800` allows to test numbers up to `6000` digits. - void aprcl_config_jacobi_init(aprcl_config conf, const fmpz_t n) noexcept - # Computes the `s` and `R` values used in the cyclotomic primality test, - # `s^2 > n` and `a^R \equiv 1 \mod{s}` for all `a` coprime to `s`. - # Also stores factors of `R` and `s`. - void aprcl_config_jacobi_clear(aprcl_config conf) noexcept - # Clears the given ``aprcl_config`` element. It must be reinitialised in - # order to be used again. - void unity_zp_init(unity_zp f, ulong p, ulong exp, const fmpz_t n) noexcept - # Initializes `f` as an element of `\mathbb{Z}[\zeta_{p^{exp}}]/(n)`. - void unity_zp_clear(unity_zp f) noexcept - # Clears the given element. It must be reinitialised in - # order to be used again. - void unity_zp_copy(unity_zp f, const unity_zp g) noexcept - # Sets `f` to `g`. `f` and `g` must be initialized with same `p` and `n`. - void unity_zp_swap(unity_zp f, unity_zp q) noexcept - # Swaps `f` and `g`. `f` and `g` must be initialized with same `p` and `n`. - void unity_zp_set_zero(unity_zp f) noexcept - # Sets `f` to zero. - slong unity_zp_is_unity(unity_zp f) noexcept - # If `f = \zeta^h` returns h; otherwise returns -1. - bint unity_zp_equal(unity_zp f, unity_zp g) noexcept - # Returns nonzero if `f = g` reduced by the `p^{exp}`-th cyclotomic - # polynomial. - void unity_zp_print(const unity_zp f) noexcept - # Prints the contents of the `f`. - void unity_zp_coeff_set_fmpz(unity_zp f, ulong ind, const fmpz_t x) noexcept void unity_zp_coeff_set_ui(unity_zp f, ulong ind, ulong x) noexcept - # Sets the coefficient of `\zeta^{ind}` to `x`. - # `ind` must be less than `p^{exp}`. - void unity_zp_coeff_add_fmpz(unity_zp f, ulong ind, const fmpz_t x) noexcept void unity_zp_coeff_add_ui(unity_zp f, ulong ind, ulong x) noexcept - # Adds `x` to the coefficient of `\zeta^{ind}`. - # `x` must be less than `n`. - # `ind` must be less than `p^{exp}`. - void unity_zp_coeff_inc(unity_zp f, ulong ind) noexcept - # Increments the coefficient of `\zeta^{ind}`. - # `ind` must be less than `p^{exp}`. - void unity_zp_coeff_dec(unity_zp f, ulong ind) noexcept - # Decrements the coefficient of `\zeta^{ind}`. - # `ind` must be less than `p^{exp}`. - void unity_zp_mul_scalar_fmpz(unity_zp f, const unity_zp g, const fmpz_t s) noexcept - # Sets `f` to `s \cdot g`. `f` and `g` must be initialized with - # same `p`, `exp` and `n`. - void unity_zp_mul_scalar_ui(unity_zp f, const unity_zp g, ulong s) noexcept - # Sets `f` to `s \cdot g`. `f` and `g` must be initialized with - # same `p`, `exp` and `n`. - void unity_zp_add(unity_zp f, const unity_zp g, const unity_zp h) noexcept - # Sets `f` to `g + h`. - # `f`, `g` and `h` must be initialized with same `p`, `exp` and `n`. - void unity_zp_mul(unity_zp f, const unity_zp g, const unity_zp h) noexcept - # Sets `f` to `g \cdot h`. - # `f`, `g` and `h` must be initialized with same `p`, `exp` and `n`. - void unity_zp_sqr(unity_zp f, const unity_zp g) noexcept - # Sets `f` to `g \cdot g`. - # `f`, `g` and `h` must be initialized with same `p`, `exp` and `n`. - void unity_zp_mul_inplace(unity_zp f, const unity_zp g, const unity_zp h, fmpz_t * t) noexcept - # Sets `f` to `g \cdot h`. If `p^{exp} = 3, 4, 5, 7, 8, 9, 11, 16` special - # multiplication functions are used. The preallocated array `t` of ``fmpz_t`` is - # used for all computations in this case. - # `f`, `g` and `h` must be initialized with same `p`, `exp` and `n`. - void unity_zp_sqr_inplace(unity_zp f, const unity_zp g, fmpz_t * t) noexcept - # Sets `f` to `g \cdot g`. If `p^{exp} = 3, 4, 5, 7, 8, 9, 11, 16` special - # multiplication functions are used. The preallocated array `t` of ``fmpz_t`` is - # used for all computations in this case. - # `f` and `g` must be initialized with same `p`, `exp` and `n`. - void unity_zp_pow_fmpz(unity_zp f, const unity_zp g, const fmpz_t pow) noexcept - # Sets `f` to `g^{pow}`. `f` and `g` must be initialized with - # same `p`, `exp` and `n`. - void unity_zp_pow_ui(unity_zp f, const unity_zp g, ulong pow) noexcept - # Sets `f` to `g^{pow}`. `f` and `g` must be initialized with - # same `p`, `exp` and `n`. - ulong _unity_zp_pow_select_k(const fmpz_t n) noexcept - # Returns the smallest integer `k` satisfying - # `\log (n) < (k(k + 1)2^{2k}) / (2^{k + 1} - k - 2) + 1` - void unity_zp_pow_2k_fmpz(unity_zp f, const unity_zp g, const fmpz_t pow) noexcept - # Sets `f` to `g^{pow}` using the `2^k`-ary exponentiation method. - # `f` and `g` must be initialized with same `p`, `exp` and `n`. - void unity_zp_pow_2k_ui(unity_zp f, const unity_zp g, ulong pow) noexcept - # Sets `f` to `g^{pow}` using the `2^k`-ary exponentiation method. - # `f` and `g` must be initialized with same `p`, `exp` and `n`. - void unity_zp_pow_sliding_fmpz(unity_zp f, unity_zp g, const fmpz_t pow) noexcept - # Sets `f` to `g^{pow}` using the sliding window exponentiation method. - # `f` and `g` must be initialized with same `p`, `exp` and `n`. - void _unity_zp_reduce_cyclotomic_divmod(unity_zp f) noexcept void _unity_zp_reduce_cyclotomic(unity_zp f) noexcept - # Sets `f = f \bmod \Phi_{p^{exp}}`. `\Phi_{p^{exp}}` is the `p^{exp}`-th - # cyclotomic polynomial. `g` must be reduced by `x^{p^{exp}}-1` poly. - # `f` and `g` must be initialized with same `p`, `exp` and `n`. - void unity_zp_reduce_cyclotomic(unity_zp f, const unity_zp g) noexcept - # Sets `f = g \bmod \Phi_{p^{exp}}`. `\Phi_{p^{exp}}` is the `p^{exp}`-th - # cyclotomic polynomial. - void unity_zp_aut(unity_zp f, const unity_zp g, ulong x) noexcept - # Sets `f = \sigma_x(g)`, the automorphism `\sigma_x(\zeta)=\zeta^x`. - # `f` and `g` must be initialized with the same `p`, `exp` and `n`. - void unity_zp_aut_inv(unity_zp f, const unity_zp g, ulong x) noexcept - # Sets `f = \sigma_x^{-1}(g)`, so `\sigma_x(f) = g`. - # `g` must be reduced by `\Phi_{p^{exp}}`. - # `f` and `g` must be initialized with the same `p`, `exp` and `n`. - void unity_zp_jacobi_sum_pq(unity_zp f, ulong q, ulong p) noexcept - # Sets `f` to the Jacobi sum `J(p, q) = j(\chi_{p, q}, \chi_{p, q})`. - void unity_zp_jacobi_sum_2q_one(unity_zp f, ulong q) noexcept - # Sets `f` to the Jacobi sum - # `J_2(q) = j(\chi_{2, q}^{2^{k - 3}}, \chi_{2, q}^{3 \cdot 2^{k - 3}}))^2`. - void unity_zp_jacobi_sum_2q_two(unity_zp f, ulong q) noexcept - # Sets `f` to the Jacobi sum - # `J_3(1) = j(\chi_{2, q}, \chi_{2, q}, \chi_{2, q}) = - # J(2, q) \cdot j(\chi_{2, q}^2, \chi_{2, q})`. - void unity_zpq_init(unity_zpq f, ulong q, ulong p, const fmpz_t n) noexcept - # Initializes `f` as an element of `\mathbb{Z}[\zeta_q, \zeta_p]/(n)`. - void unity_zpq_clear(unity_zpq f) noexcept - # Clears the given element. It must be reinitialized in - # order to be used again. - void unity_zpq_copy(unity_zpq f, const unity_zpq g) noexcept - # Sets `f` to `g`. `f` and `g` must be initialized with - # same `p`, `q` and `n`. - void unity_zpq_swap(unity_zpq f, unity_zpq q) noexcept - # Swaps `f` and `g`. `f` and `g` must be initialized with - # same `p`, `q` and `n`. - bint unity_zpq_equal(const unity_zpq f, const unity_zpq g) noexcept - # Returns nonzero if `f = g`. - slong unity_zpq_p_unity(const unity_zpq f) noexcept - # If `f = \zeta_p^x` returns `x \in [0, p - 1]`; otherwise returns `p`. - bint unity_zpq_is_p_unity(const unity_zpq f) noexcept - # Returns nonzero if `f = \zeta_p^x`. - bint unity_zpq_is_p_unity_generator(const unity_zpq f) noexcept - # Returns nonzero if `f` is a generator of the cyclic group `\langle\zeta_p\rangle`. - void unity_zpq_coeff_set_fmpz(unity_zpq f, slong i, slong j, const fmpz_t x) noexcept - # Sets the coefficient of `\zeta_q^i \zeta_p^j` to `x`. - # `i` must be less than `q` and `j` must be less than `p`. - void unity_zpq_coeff_set_ui(unity_zpq f, slong i, slong j, ulong x) noexcept - # Sets the coefficient of `\zeta_q^i \zeta_p^j` to `x`. - # `i` must be less than `q` and `j` must be less then `p`. - void unity_zpq_coeff_add(unity_zpq f, slong i, slong j, const fmpz_t x) noexcept - # Adds `x` to the coefficient of `\zeta_p^i \zeta_q^j`. `x` must be less than `n`. - void unity_zpq_add(unity_zpq f, const unity_zpq g, const unity_zpq h) noexcept - # Sets `f` to `g + h`. - # `f`, `g` and `h` must be initialized with same - # `q`, `p` and `n`. - void unity_zpq_mul(unity_zpq f, const unity_zpq g, const unity_zpq h) noexcept - # Sets the `f` to `g \cdot h`. - # `f`, `g` and `h` must be initialized with same - # `q`, `p` and `n`. - void _unity_zpq_mul_unity_p(unity_zpq f) noexcept - # Sets `f = f \cdot \zeta_p`. - void unity_zpq_mul_unity_p_pow(unity_zpq f, const unity_zpq g, slong k) noexcept - # Sets `f` to `g \cdot \zeta_p^k`. - void unity_zpq_pow(unity_zpq f, const unity_zpq g, const fmpz_t p) noexcept - # Sets `f` to `g^p`. `f` and `g` must be initialized with same `p`, `q` and `n`. - void unity_zpq_pow_ui(unity_zpq f, const unity_zpq g, ulong p) noexcept - # Sets `f` to `g^p`. `f` and `g` must be initialized with same `p`, `q` and `n`. - void unity_zpq_gauss_sum(unity_zpq f, ulong q, ulong p) noexcept - # Sets `f = \tau(\chi_{p, q})`. - void unity_zpq_gauss_sum_sigma_pow(unity_zpq f, ulong q, ulong p) noexcept - # Sets `f = \tau^{\sigma_n}(\chi_{p, q})`. diff --git a/src/sage/libs/flint/arb.pxd b/src/sage/libs/flint/arb.pxd index d7bf72f9409..9da42e43fb8 100644 --- a/src/sage/libs/flint/arb.pxd +++ b/src/sage/libs/flint/arb.pxd @@ -2,7 +2,9 @@ # distutils: depends = flint/arb.h ################################################################################ -# This file is auto-generated. Do not modify by hand +# This file is auto-generated by the script +# SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py. +# Do not modify by hand! Fix and rerun the script instead. ################################################################################ from libc.stdio cimport FILE @@ -11,1482 +13,368 @@ from sage.libs.mpfr.types cimport * from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void arb_init(arb_t x) noexcept - # Initializes the variable *x* for use. Its midpoint and radius are both - # set to zero. - void arb_clear(arb_t x) noexcept - # Clears the variable *x*, freeing or recycling its allocated memory. - arb_ptr _arb_vec_init(slong n) noexcept - # Returns a pointer to an array of *n* initialized :type:`arb_struct` - # entries. - void _arb_vec_clear(arb_ptr v, slong n) noexcept - # Clears an array of *n* initialized :type:`arb_struct` entries. - void arb_swap(arb_t x, arb_t y) noexcept - # Swaps *x* and *y* efficiently. - slong arb_allocated_bytes(const arb_t x) noexcept - # Returns the total number of bytes heap-allocated internally by this object. - # The count excludes the size of the structure itself. Add - # ``sizeof(arb_struct)`` to get the size of the object as a whole. - slong _arb_vec_allocated_bytes(arb_srcptr vec, slong len) noexcept - # Returns the total number of bytes allocated for this vector, i.e. the - # space taken up by the vector itself plus the sum of the internal heap - # allocation sizes for all its member elements. - double _arb_vec_estimate_allocated_bytes(slong len, slong prec) noexcept - # Estimates the number of bytes that need to be allocated for a vector of - # *len* elements with *prec* bits of precision, including the space for - # internal limb data. - # This function returns a *double* to avoid overflow issues when both - # *len* and *prec* are large. - # This is only an approximation of the physical memory that will be used - # by an actual vector. In practice, the space varies with the content - # of the numbers; for example, zeros and small integers require no - # internal heap allocation even if the precision is huge. - # The estimate assumes that exponents will not be bignums. - # The actual amount may also be higher or lower due to overhead in the - # memory allocator or overcommitment by the operating system. - void arb_set(arb_t y, const arb_t x) noexcept - void arb_set_arf(arb_t y, const arf_t x) noexcept - void arb_set_si(arb_t y, slong x) noexcept - void arb_set_ui(arb_t y, ulong x) noexcept - void arb_set_d(arb_t y, double x) noexcept - void arb_set_fmpz(arb_t y, const fmpz_t x) noexcept - # Sets *y* to the value of *x* without rounding. - void arb_set_fmpz_2exp(arb_t y, const fmpz_t x, const fmpz_t e) noexcept - # Sets *y* to `x \cdot 2^e`. - void arb_set_round(arb_t y, const arb_t x, slong prec) noexcept - void arb_set_round_fmpz(arb_t y, const fmpz_t x, slong prec) noexcept - # Sets *y* to the value of *x*, rounded to *prec* bits in the direction - # towards zero. - void arb_set_round_fmpz_2exp(arb_t y, const fmpz_t x, const fmpz_t e, slong prec) noexcept - # Sets *y* to `x \cdot 2^e`, rounded to *prec* bits in the direction - # towards zero. - void arb_set_fmpq(arb_t y, const fmpq_t x, slong prec) noexcept - # Sets *y* to the rational number *x*, rounded to *prec* bits in the direction - # towards zero. - int arb_set_str(arb_t res, const char * inp, slong prec) noexcept - # Sets *res* to the value specified by the human-readable string *inp*. - # The input may be a decimal floating-point literal, - # such as "25", "0.001", "7e+141" or "-31.4159e-1", and may also consist - # of two such literals separated by the symbol "+/-" and optionally - # enclosed in brackets, e.g. "[3.25 +/- 0.0001]", or simply - # "[+/- 10]" with an implicit zero midpoint. - # The output is rounded to *prec* bits, and if the binary-to-decimal - # conversion is inexact, the resulting error is added to the radius. - # The symbols "inf" and "nan" are recognized (a nan midpoint results in an - # indeterminate interval, with infinite radius). - # Returns 0 if successful and nonzero if unsuccessful. If unsuccessful, - # the result is set to an indeterminate interval. - char * arb_get_str(const arb_t x, slong n, ulong flags) noexcept - # Returns a nice human-readable representation of *x*, with at most *n* - # digits of the midpoint printed. - # With default flags, the output can be parsed back with :func:`arb_set_str`, - # and this is guaranteed to produce an interval containing the original - # interval *x*. - # By default, the output is rounded so that the value given for the - # midpoint is correct up to 1 ulp (unit in the last decimal place). - # If *ARB_STR_MORE* is added to *flags*, more (possibly incorrect) - # digits may be printed. - # If *ARB_STR_NO_RADIUS* is added to *flags*, the radius is not - # included in the output. Unless *ARB_STR_MORE* is set, the output is - # rounded so that the midpoint is correct to 1 ulp. As a special case, - # if there are no significant digits after rounding, the result will - # be shown as ``0e+n``, meaning that the result is between - # ``-1e+n`` and ``1e+n`` (following the contract that the output is - # correct to within one unit in the only shown digit). - # By adding a multiple *m* of *ARB_STR_CONDENSE* to *flags*, strings - # of more than three times *m* consecutive digits are condensed, only - # printing the leading and trailing *m* digits along with - # brackets indicating the number of digits omitted - # (useful when computing values to extremely high precision). - void arb_zero(arb_t x) noexcept - # Sets *x* to zero. - void arb_one(arb_t f) noexcept - # Sets *x* to the exact integer 1. - void arb_pos_inf(arb_t x) noexcept - # Sets *x* to positive infinity, with a zero radius. - void arb_neg_inf(arb_t x) noexcept - # Sets *x* to negative infinity, with a zero radius. - void arb_zero_pm_inf(arb_t x) noexcept - # Sets *x* to `[0 \pm \infty]`, representing the whole extended real line. - void arb_indeterminate(arb_t x) noexcept - # Sets *x* to `[\operatorname{NaN} \pm \infty]`, representing - # an indeterminate result. - void arb_zero_pm_one(arb_t x) noexcept - # Sets *x* to the interval `[0 \pm 1]`. - void arb_unit_interval(arb_t x) noexcept - # Sets *x* to the interval `[0, 1]`. - void arb_print(const arb_t x) noexcept - void arb_fprint(FILE * file, const arb_t x) noexcept - # Prints the internal representation of *x*. - void arb_printd(const arb_t x, slong digits) noexcept - void arb_fprintd(FILE * file, const arb_t x, slong digits) noexcept - # Prints *x* in decimal. The printed value of the radius is not adjusted - # to compensate for the fact that the binary-to-decimal conversion - # of both the midpoint and the radius introduces additional error. - void arb_printn(const arb_t x, slong digits, ulong flags) noexcept - void arb_fprintn(FILE * file, const arb_t x, slong digits, ulong flags) noexcept - # Prints a nice decimal representation of *x*. - # By default, the output shows the midpoint with a guaranteed error of at - # most one unit in the last decimal place. In addition, an explicit error - # bound is printed so that the displayed decimal interval is guaranteed to - # enclose *x*. - # See :func:`arb_get_str` for details. - char * arb_dump_str(const arb_t x) noexcept - # Returns a serialized representation of *x* as a null-terminated - # ASCII string that can be read by :func:`arb_load_str`. The format consists - # of four hexadecimal integers representing the midpoint mantissa, - # midpoint exponent, radius mantissa and radius exponent (with special - # values to indicate zero, infinity and NaN values), - # separated by single spaces. The returned string needs to be deallocated - # with *flint_free*. - int arb_load_str(arb_t x, const char * str) noexcept - # Sets *x* to the serialized representation given in *str*. Returns a - # nonzero value if *str* is not formatted correctly (see :func:`arb_dump_str`). - int arb_dump_file(FILE * stream, const arb_t x) noexcept - # Writes a serialized ASCII representation of *x* to *stream* in a form that - # can be read by :func:`arb_load_file`. Returns a nonzero value if the data - # could not be written. - int arb_load_file(arb_t x, FILE * stream) noexcept - # Reads *x* from a serialized ASCII representation in *stream*. Returns a - # nonzero value if the data is not - # formatted correctly or the read failed. Note that the data is assumed to be - # delimited by a whitespace or end-of-file, i.e., when writing multiple - # values with :func:`arb_dump_file` make sure to insert a whitespace to - # separate consecutive values. - # It is possible to serialize and deserialize a vector as follows - # (warning: without error handling): - # .. code-block:: c - # fp = fopen("data.txt", "w"); - # for (i = 0; i < n; i++) - # { - # arb_dump_file(fp, vec + i); - # fprintf(fp, "\n"); // or any whitespace character - # } - # fclose(fp); - # fp = fopen("data.txt", "r"); - # for (i = 0; i < n; i++) - # { - # arb_load_file(vec + i, fp); - # } - # fclose(fp); - void arb_randtest(arb_t x, flint_rand_t state, slong prec, slong mag_bits) noexcept - # Generates a random ball. The midpoint and radius will both be finite. - void arb_randtest_exact(arb_t x, flint_rand_t state, slong prec, slong mag_bits) noexcept - # Generates a random number with zero radius. - void arb_randtest_precise(arb_t x, flint_rand_t state, slong prec, slong mag_bits) noexcept - # Generates a random number with radius around `2^{-\text{prec}}` - # the magnitude of the midpoint. - + void arb_randtest_positive(arb_t x, flint_rand_t state, slong prec, slong mag_bits) noexcept void arb_randtest_wide(arb_t x, flint_rand_t state, slong prec, slong mag_bits) noexcept - # Generates a random number with midpoint and radius chosen independently, - # possibly giving a very large interval. - void arb_randtest_special(arb_t x, flint_rand_t state, slong prec, slong mag_bits) noexcept - # Generates a random interval, possibly having NaN or an infinity - # as the midpoint and possibly having an infinite radius. - void arb_get_rand_fmpq(fmpq_t q, flint_rand_t state, const arb_t x, slong bits) noexcept - # Sets *q* to a random rational number from the interval represented by *x*. - # A denominator is chosen by multiplying the binary denominator of *x* - # by a random integer up to *bits* bits. - # The outcome is undefined if the midpoint or radius of *x* is non-finite, - # or if the exponent of the midpoint or radius is so large or small - # that representing the endpoints as exact rational numbers would - # cause overflows. - void arb_urandom(arb_t x, flint_rand_t state, slong prec) noexcept - # Sets *x* to a uniformly distributed random number in the interval - # `[0, 1]`. The method uses rounding from integers to floats, hence the - # radius might not be `0`. - void arb_get_mid_arb(arb_t m, const arb_t x) noexcept - # Sets *m* to the midpoint of *x*. - void arb_get_rad_arb(arb_t r, const arb_t x) noexcept - # Sets *r* to the radius of *x*. - void arb_add_error_arf(arb_t x, const arf_t err) noexcept - void arb_add_error_mag(arb_t x, const mag_t err) noexcept - void arb_add_error(arb_t x, const arb_t err) noexcept - # Adds the absolute value of *err* to the radius of *x* (the operation - # is done in-place). - void arb_add_error_2exp_si(arb_t x, slong e) noexcept - void arb_add_error_2exp_fmpz(arb_t x, const fmpz_t e) noexcept - # Adds `2^e` to the radius of *x*. - void arb_union(arb_t z, const arb_t x, const arb_t y, slong prec) noexcept - # Sets *z* to a ball containing both *x* and *y*. - int arb_intersection(arb_t z, const arb_t x, const arb_t y, slong prec) noexcept - # If *x* and *y* overlap according to :func:`arb_overlaps`, - # then *z* is set to a ball containing the intersection of *x* and *y* - # and a nonzero value is returned. - # Otherwise zero is returned and the value of *z* is undefined. - # If *x* or *y* contains NaN, the result is NaN. - void arb_nonnegative_part(arb_t res, const arb_t x) noexcept - # Sets *res* to the intersection of *x* with `[0,\infty]`. If *x* is - # nonnegative, an exact copy is made. If *x* is finite and contains negative - # numbers, an interval of the form `[r/2 \pm r/2]` is produced, which - # certainly contains no negative points. - # In the special case when *x* is strictly negative, *res* is set to zero. - void arb_get_abs_ubound_arf(arf_t u, const arb_t x, slong prec) noexcept - # Sets *u* to the upper bound for the absolute value of *x*, - # rounded up to *prec* bits. If *x* contains NaN, the result is NaN. - void arb_get_abs_lbound_arf(arf_t u, const arb_t x, slong prec) noexcept - # Sets *u* to the lower bound for the absolute value of *x*, - # rounded down to *prec* bits. If *x* contains NaN, the result is NaN. - void arb_get_ubound_arf(arf_t u, const arb_t x, slong prec) noexcept - # Sets *u* to the upper bound for the value of *x*, - # rounded up to *prec* bits. If *x* contains NaN, the result is NaN. - void arb_get_lbound_arf(arf_t u, const arb_t x, slong prec) noexcept - # Sets *u* to the lower bound for the value of *x*, - # rounded down to *prec* bits. If *x* contains NaN, the result is NaN. - void arb_get_mag(mag_t z, const arb_t x) noexcept - # Sets *z* to an upper bound for the absolute value of *x*. If *x* contains - # NaN, the result is positive infinity. - void arb_get_mag_lower(mag_t z, const arb_t x) noexcept - # Sets *z* to a lower bound for the absolute value of *x*. If *x* contains - # NaN, the result is zero. - void arb_get_mag_lower_nonnegative(mag_t z, const arb_t x) noexcept - # Sets *z* to a lower bound for the signed value of *x*, or zero - # if *x* overlaps with the negative half-axis. If *x* contains NaN, - # the result is zero. - void arb_get_interval_fmpz_2exp(fmpz_t a, fmpz_t b, fmpz_t exp, const arb_t x) noexcept - # Computes the exact interval represented by *x*, in the form of an integer - # interval multiplied by a power of two, i.e. `x = [a, b] \times 2^{\text{exp}}`. - # The result is normalized by removing common trailing zeros - # from *a* and *b*. - # This method aborts if *x* is infinite or NaN, or if the difference between - # the exponents of the midpoint and the radius is so large that allocating - # memory for the result fails. - # Warning: this method will allocate a huge amount of memory to store - # the result if the exponent difference is huge. Memory allocation could - # succeed even if the required space is far larger than the physical - # memory available on the machine, resulting in swapping. It is recommended - # to check that the midpoint and radius of *x* both are within a - # reasonable range before calling this method. - void arb_set_interval_mag(arb_t x, const mag_t a, const mag_t b, slong prec) noexcept - void arb_set_interval_arf(arb_t x, const arf_t a, const arf_t b, slong prec) noexcept - void arb_set_interval_mpfr(arb_t x, const mpfr_t a, const mpfr_t b, slong prec) noexcept - # Sets *x* to a ball containing the interval `[a, b]`. We - # require that `a \le b`. - void arb_set_interval_neg_pos_mag(arb_t x, const mag_t a, const mag_t b, slong prec) noexcept - # Sets *x* to a ball containing the interval `[-a, b]`. - void arb_get_interval_arf(arf_t a, arf_t b, const arb_t x, slong prec) noexcept - void arb_get_interval_mpfr(mpfr_t a, mpfr_t b, const arb_t x) noexcept - # Constructs an interval `[a, b]` containing the ball *x*. The MPFR version - # uses the precision of the output variables. - slong arb_rel_error_bits(const arb_t x) noexcept - # Returns the effective relative error of *x* measured in bits, defined as - # the difference between the position of the top bit in the radius - # and the top bit in the midpoint, plus one. - # The result is clamped between plus/minus *ARF_PREC_EXACT*. - slong arb_rel_accuracy_bits(const arb_t x) noexcept - # Returns the effective relative accuracy of *x* measured in bits, - # equal to the negative of the return value from :func:`arb_rel_error_bits`. - slong arb_rel_one_accuracy_bits(const arb_t x) noexcept - # Given a ball with midpoint *m* and radius *r*, returns an approximation of - # the relative accuracy of `[\max(1,|m|) \pm r]` measured in bits. - slong arb_bits(const arb_t x) noexcept - # Returns the number of bits needed to represent the absolute value - # of the mantissa of the midpoint of *x*, i.e. the minimum precision - # sufficient to represent *x* exactly. Returns 0 if the midpoint - # of *x* is a special value. - void arb_trim(arb_t y, const arb_t x) noexcept - # Sets *y* to a trimmed copy of *x*: rounds *x* to a number of bits - # equal to the accuracy of *x* (as indicated by its radius), - # plus a few guard bits. The resulting ball is guaranteed to - # contain *x*, but is more economical if *x* has - # less than full accuracy. - int arb_get_unique_fmpz(fmpz_t z, const arb_t x) noexcept - # If *x* contains a unique integer, sets *z* to that value and returns - # nonzero. Otherwise (if *x* represents no integers or more than one integer), - # returns zero. - # This method aborts if there is a unique integer but that integer - # is so large that allocating memory for the result fails. - # Warning: this method will allocate a huge amount of memory to store - # the result if there is a unique integer and that integer is huge. - # Memory allocation could succeed even if the required space is far - # larger than the physical memory available on the machine, resulting - # in swapping. It is recommended to check that the midpoint of *x* is - # within a reasonable range before calling this method. - void arb_floor(arb_t y, const arb_t x, slong prec) noexcept void arb_ceil(arb_t y, const arb_t x, slong prec) noexcept void arb_trunc(arb_t y, const arb_t x, slong prec) noexcept void arb_nint(arb_t y, const arb_t x, slong prec) noexcept - # Sets *y* to a ball containing respectively, `\lfloor x \rfloor` and - # `\lceil x \rceil`, `\operatorname{trunc}(x)`, `\operatorname{nint}(x)`, - # with the midpoint of *y* rounded to at most *prec* bits. - void arb_get_fmpz_mid_rad_10exp(fmpz_t mid, fmpz_t rad, fmpz_t exp, const arb_t x, slong n) noexcept - # Assuming that *x* is finite and not exactly zero, computes integers *mid*, - # *rad*, *exp* such that `x \in [m-r, m+r] \times 10^e` and such that the - # larger out of *mid* and *rad* has at least *n* digits plus a few guard - # digits. If *x* is infinite or exactly zero, the outputs are all set - # to zero. - int arb_can_round_arf(const arb_t x, slong prec, arf_rnd_t rnd) noexcept - int arb_can_round_mpfr(const arb_t x, slong prec, mpfr_rnd_t rnd) noexcept - # Returns nonzero if rounding the midpoint of *x* to *prec* bits in - # the direction *rnd* is guaranteed to give the unique correctly - # rounded floating-point approximation for the real number represented by *x*. - # In other words, if this function returns nonzero, applying - # :func:`arf_set_round`, or :func:`arf_get_mpfr`, or :func:`arf_get_d` - # to the midpoint of *x* is guaranteed to return a correctly rounded *arf_t*, - # *mpfr_t* (provided that *prec* is the precision of the output variable), - # or *double* (provided that *prec* is 53). - # Moreover, :func:`arf_get_mpfr` is guaranteed to return the correct ternary - # value according to MPFR semantics. - # Note that the *mpfr* version of this function takes an MPFR rounding mode - # symbol as input, while the *arf* version takes an *arf* rounding mode - # symbol. Otherwise, the functions are identical. - # This function may perform a fast, inexact test; that is, it may return - # zero in some cases even when correct rounding actually is possible. - # To be conservative, zero is returned when *x* is non-finite, even if it - # is an "exact" infinity. - bint arb_is_zero(const arb_t x) noexcept - # Returns nonzero iff the midpoint and radius of *x* are both zero. - bint arb_is_nonzero(const arb_t x) noexcept - # Returns nonzero iff zero is not contained in the interval represented - # by *x*. - bint arb_is_one(const arb_t f) noexcept - # Returns nonzero iff *x* is exactly 1. - bint arb_is_finite(const arb_t x) noexcept - # Returns nonzero iff the midpoint and radius of *x* are both finite - # floating-point numbers, i.e. not infinities or NaN. - bint arb_is_exact(const arb_t x) noexcept - # Returns nonzero iff the radius of *x* is zero. - bint arb_is_int(const arb_t x) noexcept - # Returns nonzero iff *x* is an exact integer. - bint arb_is_int_2exp_si(const arb_t x, slong e) noexcept - # Returns nonzero iff *x* exactly equals `n 2^e` for some integer *n*. - bint arb_equal(const arb_t x, const arb_t y) noexcept - # Returns nonzero iff *x* and *y* are equal as balls, i.e. have both the - # same midpoint and radius. - # Note that this is not the same thing as testing whether both - # *x* and *y* certainly represent the same real number, unless - # either *x* or *y* is exact (and neither contains NaN). - # To test whether both operands *might* represent the same mathematical - # quantity, use :func:`arb_overlaps` or :func:`arb_contains`, - # depending on the circumstance. - bint arb_equal_si(const arb_t x, slong y) noexcept - # Returns nonzero iff *x* is equal to the integer *y*. - bint arb_is_positive(const arb_t x) noexcept - bint arb_is_nonnegative(const arb_t x) noexcept - bint arb_is_negative(const arb_t x) noexcept - bint arb_is_nonpositive(const arb_t x) noexcept - # Returns nonzero iff all points *p* in the interval represented by *x* - # satisfy, respectively, `p > 0`, `p \ge 0`, `p < 0`, `p \le 0`. - # If *x* contains NaN, returns zero. - bint arb_overlaps(const arb_t x, const arb_t y) noexcept - # Returns nonzero iff *x* and *y* have some point in common. - # If either *x* or *y* contains NaN, this function always returns nonzero - # (as a NaN could be anything, it could in particular contain any - # number that is included in the other operand). - bint arb_contains_arf(const arb_t x, const arf_t y) noexcept - bint arb_contains_fmpq(const arb_t x, const fmpq_t y) noexcept - bint arb_contains_fmpz(const arb_t x, const fmpz_t y) noexcept - bint arb_contains_si(const arb_t x, slong y) noexcept - bint arb_contains_mpfr(const arb_t x, const mpfr_t y) noexcept - bint arb_contains(const arb_t x, const arb_t y) noexcept - # Returns nonzero iff the given number (or ball) *y* is contained in - # the interval represented by *x*. - # If *x* contains NaN, this function always returns nonzero (as it - # could represent anything, and in particular could represent all - # the points included in *y*). - # If *y* contains NaN and *x* does not, it always returns zero. - bint arb_contains_int(const arb_t x) noexcept - # Returns nonzero iff the interval represented by *x* contains an integer. - bint arb_contains_zero(const arb_t x) noexcept - bint arb_contains_negative(const arb_t x) noexcept - bint arb_contains_nonpositive(const arb_t x) noexcept - bint arb_contains_positive(const arb_t x) noexcept - bint arb_contains_nonnegative(const arb_t x) noexcept - # Returns nonzero iff there is any point *p* in the interval represented - # by *x* satisfying, respectively, `p = 0`, `p < 0`, `p \le 0`, `p > 0`, `p \ge 0`. - # If *x* contains NaN, returns nonzero. - bint arb_contains_interior(const arb_t x, const arb_t y) noexcept - # Tests if *y* is contained in the interior of *x*; that is, contained - # in *x* and not touching either endpoint. - bint arb_eq(const arb_t x, const arb_t y) noexcept - bint arb_ne(const arb_t x, const arb_t y) noexcept - bint arb_lt(const arb_t x, const arb_t y) noexcept - bint arb_le(const arb_t x, const arb_t y) noexcept - bint arb_gt(const arb_t x, const arb_t y) noexcept - bint arb_ge(const arb_t x, const arb_t y) noexcept - # Respectively performs the comparison `x = y`, `x \ne y`, - # `x < y`, `x \le y`, `x > y`, `x \ge y` in a mathematically meaningful way. - # If the comparison `t \, (\operatorname{op}) \, u` holds for all - # `t \in x` and all `u \in y`, returns 1. - # Otherwise, returns 0. - # The balls *x* and *y* are viewed as subintervals of the extended real line. - # Note that balls that are formally different can compare as equal - # under this definition: for example, `[-\infty \pm 3] = [-\infty \pm 0]`. - # Also `[-\infty] \le [\infty \pm \infty]`. - # The output is always 0 if either input has NaN as midpoint. - void arb_neg(arb_t y, const arb_t x) noexcept - void arb_neg_round(arb_t y, const arb_t x, slong prec) noexcept - # Sets *y* to the negation of *x*. - void arb_abs(arb_t y, const arb_t x) noexcept - # Sets *y* to the absolute value of *x*. No attempt is made to improve the - # interval represented by *x* if it contains zero. - void arb_nonnegative_abs(arb_t y, const arb_t x) noexcept - # Sets *y* to the absolute value of *x*. If *x* is finite and it contains - # zero, sets *y* to some interval `[r \pm r]` that contains the absolute - # value of *x*. - void arb_sgn(arb_t y, const arb_t x) noexcept - # Sets *y* to the sign function of *x*. The result is `[0 \pm 1]` if - # *x* contains both zero and nonzero numbers. - int arb_sgn_nonzero(const arb_t x) noexcept - # Returns 1 if *x* is strictly positive, -1 if *x* is strictly negative, - # and 0 if *x* is zero or a ball containing zero so that its sign - # is not determined. - void arb_min(arb_t z, const arb_t x, const arb_t y, slong prec) noexcept - void arb_max(arb_t z, const arb_t x, const arb_t y, slong prec) noexcept - # Sets *z* respectively to the minimum and the maximum of *x* and *y*. - void arb_minmax(arb_t z1, arb_t z2, const arb_t x, const arb_t y, slong prec) noexcept - # Sets *z1* and *z2* respectively to the minimum and the maximum of *x* and *y*. - void arb_add(arb_t z, const arb_t x, const arb_t y, slong prec) noexcept - void arb_add_arf(arb_t z, const arb_t x, const arf_t y, slong prec) noexcept - void arb_add_ui(arb_t z, const arb_t x, ulong y, slong prec) noexcept - void arb_add_si(arb_t z, const arb_t x, slong y, slong prec) noexcept - void arb_add_fmpz(arb_t z, const arb_t x, const fmpz_t y, slong prec) noexcept - # Sets `z = x + y`, rounded to *prec* bits. The precision can be - # *ARF_PREC_EXACT* provided that the result fits in memory. - void arb_add_fmpz_2exp(arb_t z, const arb_t x, const fmpz_t m, const fmpz_t e, slong prec) noexcept - # Sets `z = x + m \cdot 2^e`, rounded to *prec* bits. The precision can be - # *ARF_PREC_EXACT* provided that the result fits in memory. - void arb_sub(arb_t z, const arb_t x, const arb_t y, slong prec) noexcept - void arb_sub_arf(arb_t z, const arb_t x, const arf_t y, slong prec) noexcept - void arb_sub_ui(arb_t z, const arb_t x, ulong y, slong prec) noexcept - void arb_sub_si(arb_t z, const arb_t x, slong y, slong prec) noexcept - void arb_sub_fmpz(arb_t z, const arb_t x, const fmpz_t y, slong prec) noexcept - # Sets `z = x - y`, rounded to *prec* bits. The precision can be - # *ARF_PREC_EXACT* provided that the result fits in memory. - void arb_mul(arb_t z, const arb_t x, const arb_t y, slong prec) noexcept - void arb_mul_arf(arb_t z, const arb_t x, const arf_t y, slong prec) noexcept - void arb_mul_si(arb_t z, const arb_t x, slong y, slong prec) noexcept - void arb_mul_ui(arb_t z, const arb_t x, ulong y, slong prec) noexcept - void arb_mul_fmpz(arb_t z, const arb_t x, const fmpz_t y, slong prec) noexcept - # Sets `z = x \cdot y`, rounded to *prec* bits. The precision can be - # *ARF_PREC_EXACT* provided that the result fits in memory. - void arb_mul_2exp_si(arb_t y, const arb_t x, slong e) noexcept - void arb_mul_2exp_fmpz(arb_t y, const arb_t x, const fmpz_t e) noexcept - # Sets *y* to *x* multiplied by `2^e`. - void arb_addmul(arb_t z, const arb_t x, const arb_t y, slong prec) noexcept - void arb_addmul_arf(arb_t z, const arb_t x, const arf_t y, slong prec) noexcept - void arb_addmul_si(arb_t z, const arb_t x, slong y, slong prec) noexcept - void arb_addmul_ui(arb_t z, const arb_t x, ulong y, slong prec) noexcept - void arb_addmul_fmpz(arb_t z, const arb_t x, const fmpz_t y, slong prec) noexcept - # Sets `z = z + x \cdot y`, rounded to prec bits. The precision can be - # *ARF_PREC_EXACT* provided that the result fits in memory. - void arb_submul(arb_t z, const arb_t x, const arb_t y, slong prec) noexcept - void arb_submul_arf(arb_t z, const arb_t x, const arf_t y, slong prec) noexcept - void arb_submul_si(arb_t z, const arb_t x, slong y, slong prec) noexcept - void arb_submul_ui(arb_t z, const arb_t x, ulong y, slong prec) noexcept - void arb_submul_fmpz(arb_t z, const arb_t x, const fmpz_t y, slong prec) noexcept - # Sets `z = z - x \cdot y`, rounded to prec bits. The precision can be - # *ARF_PREC_EXACT* provided that the result fits in memory. - void arb_fma(arb_t res, const arb_t x, const arb_t y, const arb_t z, slong prec) noexcept void arb_fma_arf(arb_t res, const arb_t x, const arf_t y, const arb_t z, slong prec) noexcept void arb_fma_si(arb_t res, const arb_t x, slong y, const arb_t z, slong prec) noexcept void arb_fma_ui(arb_t res, const arb_t x, ulong y, const arb_t z, slong prec) noexcept void arb_fma_fmpz(arb_t res, const arb_t x, const fmpz_t y, const arb_t z, slong prec) noexcept - # Sets *res* to `x \cdot y + z`. This is equivalent to an *addmul* except - # that *res* and *z* can be separate variables. - void arb_inv(arb_t z, const arb_t x, slong prec) noexcept - # Sets *z* to `1 / x`. - void arb_div(arb_t z, const arb_t x, const arb_t y, slong prec) noexcept - void arb_div_arf(arb_t z, const arb_t x, const arf_t y, slong prec) noexcept - void arb_div_si(arb_t z, const arb_t x, slong y, slong prec) noexcept - void arb_div_ui(arb_t z, const arb_t x, ulong y, slong prec) noexcept - void arb_div_fmpz(arb_t z, const arb_t x, const fmpz_t y, slong prec) noexcept - void arb_fmpz_div_fmpz(arb_t z, const fmpz_t x, const fmpz_t y, slong prec) noexcept - void arb_ui_div(arb_t z, ulong x, const arb_t y, slong prec) noexcept - # Sets `z = x / y`, rounded to *prec* bits. If *y* contains zero, *z* is - # set to `0 \pm \infty`. Otherwise, error propagation uses the rule - # .. math :: - # \left| \frac{x}{y} - \frac{x+\xi_1 a}{y+\xi_2 b} \right| = - # \left|\frac{x \xi_2 b - y \xi_1 a}{y (y+\xi_2 b)}\right| \le - # \frac{|xb|+|ya|}{|y| (|y|-b)} - # where `-1 \le \xi_1, \xi_2 \le 1`, and - # where the triangle inequality has been applied to the numerator and - # the reverse triangle inequality has been applied to the denominator. - void arb_div_2expm1_ui(arb_t z, const arb_t x, ulong n, slong prec) noexcept - # Sets `z = x / (2^n - 1)`, rounded to *prec* bits. - void arb_dot_precise(arb_t res, const arb_t s, int subtract, arb_srcptr x, slong xstep, arb_srcptr y, slong ystep, slong len, slong prec) noexcept void arb_dot_simple(arb_t res, const arb_t s, int subtract, arb_srcptr x, slong xstep, arb_srcptr y, slong ystep, slong len, slong prec) noexcept void arb_dot(arb_t res, const arb_t s, int subtract, arb_srcptr x, slong xstep, arb_srcptr y, slong ystep, slong len, slong prec) noexcept - # Computes the dot product of the vectors *x* and *y*, setting - # *res* to `s + (-1)^{subtract} \sum_{i=0}^{len-1} x_i y_i`. - # The initial term *s* is optional and can be - # omitted by passing *NULL* (equivalently, `s = 0`). - # The parameter *subtract* must be 0 or 1. - # The length *len* is allowed to be negative, which is equivalent - # to a length of zero. - # The parameters *xstep* or *ystep* specify a step length for - # traversing subsequences of the vectors *x* and *y*; either can be - # negative to step in the reverse direction starting from - # the initial pointer. - # Aliasing is allowed between *res* and *s* but not between - # *res* and the entries of *x* and *y*. - # The default version determines the optimal precision for each term - # and performs all internal calculations using mpn arithmetic - # with minimal overhead. This is the preferred way to compute a - # dot product; it is generally much faster and more precise - # than a simple loop. - # The *simple* version performs fused multiply-add operations in - # a simple loop. This can be used for - # testing purposes and is also used as a fallback by the - # default version when the exponents are out of range - # for the optimized code. - # The *precise* version computes the dot product exactly up to the - # final rounding. This can be extremely slow and is only intended - # for testing. - void arb_approx_dot(arb_t res, const arb_t s, int subtract, arb_srcptr x, slong xstep, arb_srcptr y, slong ystep, slong len, slong prec) noexcept - # Computes an approximate dot product *without error bounds*. - # The radii of the inputs are ignored (only the midpoints are read) - # and only the midpoint of the output is written. - void arb_dot_ui(arb_t res, const arb_t initial, int subtract, arb_srcptr x, slong xstep, const ulong * y, slong ystep, slong len, slong prec) noexcept void arb_dot_si(arb_t res, const arb_t initial, int subtract, arb_srcptr x, slong xstep, const slong * y, slong ystep, slong len, slong prec) noexcept void arb_dot_uiui(arb_t res, const arb_t initial, int subtract, arb_srcptr x, slong xstep, const ulong * y, slong ystep, slong len, slong prec) noexcept void arb_dot_siui(arb_t res, const arb_t initial, int subtract, arb_srcptr x, slong xstep, const ulong * y, slong ystep, slong len, slong prec) noexcept void arb_dot_fmpz(arb_t res, const arb_t initial, int subtract, arb_srcptr x, slong xstep, const fmpz * y, slong ystep, slong len, slong prec) noexcept - # Equivalent to :func:`arb_dot`, but with integers in the array *y*. - # The *uiui* and *siui* versions take an array of double-limb integers - # as input; the *siui* version assumes that these represent signed - # integers in two's complement form. - void arb_sqrt(arb_t z, const arb_t x, slong prec) noexcept - void arb_sqrt_arf(arb_t z, const arf_t x, slong prec) noexcept - void arb_sqrt_fmpz(arb_t z, const fmpz_t x, slong prec) noexcept - void arb_sqrt_ui(arb_t z, ulong x, slong prec) noexcept - # Sets *z* to the square root of *x*, rounded to *prec* bits. - # If `x = m \pm x` where `m \ge r \ge 0`, the propagated error is bounded by - # `\sqrt{m} - \sqrt{m-r} = \sqrt{m} (1 - \sqrt{1 - r/m}) \le \sqrt{m} (r/m + (r/m)^2)/2`. - void arb_sqrtpos(arb_t z, const arb_t x, slong prec) noexcept - # Sets *z* to the square root of *x*, assuming that *x* represents a - # nonnegative number (i.e. discarding any negative numbers in the input - # interval). - void arb_hypot(arb_t z, const arb_t x, const arb_t y, slong prec) noexcept - # Sets *z* to `\sqrt{x^2 + y^2}`. - void arb_rsqrt(arb_t z, const arb_t x, slong prec) noexcept - void arb_rsqrt_ui(arb_t z, ulong x, slong prec) noexcept - # Sets *z* to the reciprocal square root of *x*, rounded to *prec* bits. - # At high precision, this is faster than computing a square root. - void arb_sqrt1pm1(arb_t z, const arb_t x, slong prec) noexcept - # Sets `z = \sqrt{1+x}-1`, computed accurately when `x \approx 0`. - void arb_root_ui(arb_t z, const arb_t x, ulong k, slong prec) noexcept - # Sets *z* to the *k*-th root of *x*, rounded to *prec* bits. - # This function selects between different algorithms. For large *k*, - # it evaluates `\exp(\log(x)/k)`. For small *k*, it uses :func:`arf_root` - # at the midpoint and computes a propagated error bound as follows: - # if input interval is `[m-r, m+r]` with `r \le m`, the error is largest at - # `m-r` where it satisfies - # .. math :: - # m^{1/k} - (m-r)^{1/k} = m^{1/k} [1 - (1-r/m)^{1/k}] - # = m^{1/k} [1 - \exp(\log(1-r/m)/k)] - # \le m^{1/k} \min(1, -\log(1-r/m)/k) - # = m^{1/k} \min(1, \log(1+r/(m-r))/k). - # This is evaluated using :func:`mag_log1p`. - void arb_root(arb_t z, const arb_t x, ulong k, slong prec) noexcept - # Alias for :func:`arb_root_ui`, provided for backwards compatibility. - void arb_sqr(arb_t y, const arb_t x, slong prec) noexcept - # Sets *y* to be the square of *x*. - void arb_pow_fmpz_binexp(arb_t y, const arb_t b, const fmpz_t e, slong prec) noexcept - void arb_pow_fmpz(arb_t y, const arb_t b, const fmpz_t e, slong prec) noexcept - void arb_pow_ui(arb_t y, const arb_t b, ulong e, slong prec) noexcept - void arb_ui_pow_ui(arb_t y, ulong b, ulong e, slong prec) noexcept - void arb_si_pow_ui(arb_t y, slong b, ulong e, slong prec) noexcept - # Sets `y = b^e` using binary exponentiation (with an initial division - # if `e < 0`). Provided that *b* and *e* - # are small enough and the exponent is positive, the exact power can be - # computed by setting the precision to *ARF_PREC_EXACT*. - # Note that these functions can get slow if the exponent is - # extremely large (in such cases :func:`arb_pow` may be superior). - void arb_pow_fmpq(arb_t y, const arb_t x, const fmpq_t a, slong prec) noexcept - # Sets `y = b^e`, computed as `y = (b^{1/q})^p` if the denominator of - # `e = p/q` is small, and generally as `y = \exp(e \log b)`. - # Note that this function can get slow if the exponent is - # extremely large (in such cases :func:`arb_pow` may be superior). - void arb_pow(arb_t z, const arb_t x, const arb_t y, slong prec) noexcept - # Sets `z = x^y`, computed using binary exponentiation if `y` is - # a small exact integer, as `z = (x^{1/2})^{2y}` if `y` is a small exact - # half-integer, and generally as `z = \exp(y \log x)`, except giving the - # obvious finite result if `x` is `a \pm a` and `y` is positive. - void arb_log_ui(arb_t z, ulong x, slong prec) noexcept - void arb_log_fmpz(arb_t z, const fmpz_t x, slong prec) noexcept - void arb_log_arf(arb_t z, const arf_t x, slong prec) noexcept - void arb_log(arb_t z, const arb_t x, slong prec) noexcept - # Sets `z = \log(x)`. - # At low to medium precision (up to about 4096 bits), :func:`arb_log_arf` - # uses table-based argument reduction and fast Taylor series evaluation - # via :func:`_arb_atan_taylor_rs`. At high precision, it falls back to MPFR. - # The function :func:`arb_log` simply calls :func:`arb_log_arf` with - # the midpoint as input, and separately adds the propagated error. - void arb_log_ui_from_prev(arb_t log_k1, ulong k1, arb_t log_k0, ulong k0, slong prec) noexcept - # Computes `\log(k_1)`, given `\log(k_0)` where `k_0 < k_1`. - # At high precision, this function uses the formula - # `\log(k_1) = \log(k_0) + 2 \operatorname{atanh}((k_1-k_0)/(k_1+k_0))`, - # evaluating the inverse hyperbolic tangent using binary splitting - # (for best efficiency, `k_0` should be large and `k_1 - k_0` should - # be small). Otherwise, it ignores `\log(k_0)` and evaluates the logarithm - # the usual way. - void arb_log1p(arb_t z, const arb_t x, slong prec) noexcept - # Sets `z = \log(1+x)`, computed accurately when `x \approx 0`. - void arb_log_base_ui(arb_t res, const arb_t x, ulong b, slong prec) noexcept - # Sets *res* to `\log_b(x)`. The result is computed exactly when possible. - void arb_log_hypot(arb_t res, const arb_t x, const arb_t y, slong prec) noexcept - # Sets *res* to `\log(\sqrt{x^2+y^2})`. - void arb_exp(arb_t z, const arb_t x, slong prec) noexcept - # Sets `z = \exp(x)`. Error propagation is done using the following rule: - # assuming `x = m \pm r`, the error is largest at `m + r`, and we have - # `\exp(m+r) - \exp(m) = \exp(m) (\exp(r)-1) \le r \exp(m+r)`. - void arb_expm1(arb_t z, const arb_t x, slong prec) noexcept - # Sets `z = \exp(x)-1`, using a more accurate method when `x \approx 0`. - void arb_exp_invexp(arb_t z, arb_t w, const arb_t x, slong prec) noexcept - # Sets `z = \exp(x)` and `w = \exp(-x)`. The second exponential is computed - # from the first using a division, but propagated error bounds are - # computed separately. - void arb_sin(arb_t s, const arb_t x, slong prec) noexcept - void arb_cos(arb_t c, const arb_t x, slong prec) noexcept - void arb_sin_cos(arb_t s, arb_t c, const arb_t x, slong prec) noexcept - # Sets `s = \sin(x)`, `c = \cos(x)`. - void arb_sin_pi(arb_t s, const arb_t x, slong prec) noexcept - void arb_cos_pi(arb_t c, const arb_t x, slong prec) noexcept - void arb_sin_cos_pi(arb_t s, arb_t c, const arb_t x, slong prec) noexcept - # Sets `s = \sin(\pi x)`, `c = \cos(\pi x)`. - void arb_tan(arb_t y, const arb_t x, slong prec) noexcept - # Sets `y = \tan(x) = \sin(x) / \cos(y)`. - void arb_cot(arb_t y, const arb_t x, slong prec) noexcept - # Sets `y = \cot(x) = \cos(x) / \sin(y)`. - void arb_sin_cos_pi_fmpq(arb_t s, arb_t c, const fmpq_t x, slong prec) noexcept - void arb_sin_pi_fmpq(arb_t s, const fmpq_t x, slong prec) noexcept - void arb_cos_pi_fmpq(arb_t c, const fmpq_t x, slong prec) noexcept - # Sets `s = \sin(\pi x)`, `c = \cos(\pi x)` where `x` is a rational - # number (whose numerator and denominator are assumed to be reduced). - # We first use trigonometric symmetries to reduce the argument to the - # octant `[0, 1/4]`. Then we either multiply by a numerical approximation - # of `\pi` and evaluate the trigonometric function the usual way, - # or we use algebraic methods, depending on which is estimated to be faster. - # Since the argument has been reduced to the first octant, the - # first of these two methods gives full accuracy even if the original - # argument is close to some root other the origin. - void arb_tan_pi(arb_t y, const arb_t x, slong prec) noexcept - # Sets `y = \tan(\pi x)`. - void arb_cot_pi(arb_t y, const arb_t x, slong prec) noexcept - # Sets `y = \cot(\pi x)`. - void arb_sec(arb_t res, const arb_t x, slong prec) noexcept - # Computes `\sec(x) = 1 / \cos(x)`. - void arb_csc(arb_t res, const arb_t x, slong prec) noexcept - # Computes `\csc(x) = 1 / \sin(x)`. - void arb_csc_pi(arb_t res, const arb_t x, slong prec) noexcept - # Computes `\csc(\pi x) = 1 / \sin(\pi x)`. - void arb_sinc(arb_t z, const arb_t x, slong prec) noexcept - # Sets `z = \operatorname{sinc}(x) = \sin(x) / x`. - void arb_sinc_pi(arb_t z, const arb_t x, slong prec) noexcept - # Sets `z = \operatorname{sinc}(\pi x) = \sin(\pi x) / (\pi x)`. - void arb_atan_arf(arb_t z, const arf_t x, slong prec) noexcept - void arb_atan(arb_t z, const arb_t x, slong prec) noexcept - # Sets `z = \operatorname{atan}(x)`. - # At low to medium precision (up to about 4096 bits), :func:`arb_atan_arf` - # uses table-based argument reduction and fast Taylor series evaluation - # via :func:`_arb_atan_taylor_rs`. At high precision, it falls back to MPFR. - # The function :func:`arb_atan` simply calls :func:`arb_atan_arf` with - # the midpoint as input, and separately adds the propagated error. - # The function :func:`arb_atan_arf` uses lookup tables if - # possible, and otherwise falls back to :func:`arb_atan_arf_bb`. - void arb_atan2(arb_t z, const arb_t b, const arb_t a, slong prec) noexcept - # Sets *r* to an the argument (phase) of the complex number - # `a + bi`, with the branch cut discontinuity on `(-\infty,0]`. - # We define `\operatorname{atan2}(0,0) = 0`, and for `a < 0`, - # `\operatorname{atan2}(0,a) = \pi`. - void arb_asin(arb_t z, const arb_t x, slong prec) noexcept - # Sets `z = \operatorname{asin}(x) = \operatorname{atan}(x / \sqrt{1-x^2})`. - # If `x` is not contained in the domain `[-1,1]`, the result is an - # indeterminate interval. - void arb_acos(arb_t z, const arb_t x, slong prec) noexcept - # Sets `z = \operatorname{acos}(x) = \pi/2 - \operatorname{asin}(x)`. - # If `x` is not contained in the domain `[-1,1]`, the result is an - # indeterminate interval. - void arb_sinh(arb_t s, const arb_t x, slong prec) noexcept - void arb_cosh(arb_t c, const arb_t x, slong prec) noexcept - void arb_sinh_cosh(arb_t s, arb_t c, const arb_t x, slong prec) noexcept - # Sets `s = \sinh(x)`, `c = \cosh(x)`. If the midpoint of `x` is close - # to zero and the hyperbolic sine is to be computed, - # evaluates `(e^{2x}\pm1) / (2e^x)` via :func:`arb_expm1` - # to avoid loss of accuracy. Otherwise evaluates `(e^x \pm e^{-x}) / 2`. - void arb_tanh(arb_t y, const arb_t x, slong prec) noexcept - # Sets `y = \tanh(x) = \sinh(x) / \cosh(x)`, evaluated - # via :func:`arb_expm1` as `\tanh(x) = (e^{2x} - 1) / (e^{2x} + 1)` - # if `|x|` is small, and as - # `\tanh(\pm x) = 1 - 2 e^{\mp 2x} / (1 + e^{\mp 2x})` - # if `|x|` is large. - void arb_coth(arb_t y, const arb_t x, slong prec) noexcept - # Sets `y = \coth(x) = \cosh(x) / \sinh(x)`, evaluated using - # the same strategy as :func:`arb_tanh`. - void arb_sech(arb_t res, const arb_t x, slong prec) noexcept - # Computes `\operatorname{sech}(x) = 1 / \cosh(x)`. - void arb_csch(arb_t res, const arb_t x, slong prec) noexcept - # Computes `\operatorname{csch}(x) = 1 / \sinh(x)`. - void arb_atanh(arb_t z, const arb_t x, slong prec) noexcept - # Sets `z = \operatorname{atanh}(x)`. - void arb_asinh(arb_t z, const arb_t x, slong prec) noexcept - # Sets `z = \operatorname{asinh}(x)`. - void arb_acosh(arb_t z, const arb_t x, slong prec) noexcept - # Sets `z = \operatorname{acosh}(x)`. - # If `x < 1`, the result is an indeterminate interval. - void arb_const_pi(arb_t z, slong prec) noexcept - # Computes `\pi`. - void arb_const_sqrt_pi(arb_t z, slong prec) noexcept - # Computes `\sqrt{\pi}`. - void arb_const_log_sqrt2pi(arb_t z, slong prec) noexcept - # Computes `\log \sqrt{2 \pi}`. - void arb_const_log2(arb_t z, slong prec) noexcept - # Computes `\log(2)`. - void arb_const_log10(arb_t z, slong prec) noexcept - # Computes `\log(10)`. - void arb_const_euler(arb_t z, slong prec) noexcept - # Computes Euler's constant `\gamma = \lim_{k \rightarrow \infty} (H_k - \log k)` - # where `H_k = 1 + 1/2 + \ldots + 1/k`. - void arb_const_catalan(arb_t z, slong prec) noexcept - # Computes Catalan's constant `C = \sum_{n=0}^{\infty} (-1)^n / (2n+1)^2`. - void arb_const_e(arb_t z, slong prec) noexcept - # Computes `e = \exp(1)`. - void arb_const_khinchin(arb_t z, slong prec) noexcept - # Computes Khinchin's constant `K_0`. - void arb_const_glaisher(arb_t z, slong prec) noexcept - # Computes the Glaisher-Kinkelin constant `A = \exp(1/12 - \zeta'(-1))`. - void arb_const_apery(arb_t z, slong prec) noexcept - # Computes Apery's constant `\zeta(3)`. - + void arb_const_reciprocal_fibonacci(arb_t z, slong prec) noexcept void arb_lambertw(arb_t res, const arb_t x, int flags, slong prec) noexcept - # Computes the Lambert W function, which solves the equation `w e^w = x`. - # The Lambert W function has infinitely many complex branches `W_k(x)`, - # two of which are real on a part of the real line. - # The principal branch `W_0(x)` is selected by setting *flags* to 0, and the - # `W_{-1}` branch is selected by setting *flags* to 1. - # The principal branch is real-valued for `x \ge -1/e` - # (taking values in `[-1,+\infty)`) and the `W_{-1}` branch is real-valued - # for `-1/e \le x < 0` and takes values in `(-\infty,-1]`. - # Elsewhere, the Lambert W function is complex and :func:`acb_lambertw` - # should be used. - # The implementation first computes a floating-point approximation - # heuristically and then computes a rigorously certified enclosure around - # this approximation. Some asymptotic cases are handled specially. - # The algorithm used to compute the Lambert W function is described - # in [Joh2017b]_, which follows the main ideas in [CGHJK1996]_. - void arb_rising_ui(arb_t z, const arb_t x, ulong n, slong prec) noexcept void arb_rising(arb_t z, const arb_t x, const arb_t n, slong prec) noexcept - # Computes the rising factorial `z = x (x+1) (x+2) \cdots (x+n-1)`. - # These functions are aliases for :func:`arb_hypgeom_rising_ui` - # and :func:`arb_hypgeom_rising`. - void arb_rising_fmpq_ui(arb_t z, const fmpq_t x, ulong n, slong prec) noexcept - # Computes the rising factorial `z = x (x+1) (x+2) \cdots (x+n-1)` using - # binary splitting. If the denominator or numerator of *x* is large - # compared to *prec*, it is more efficient to convert *x* to an approximation - # and use :func:`arb_rising_ui`. - void arb_fac_ui(arb_t z, ulong n, slong prec) noexcept - # Computes the factorial `z = n!` via the gamma function. - void arb_doublefac_ui(arb_t z, ulong n, slong prec) noexcept - # Computes the double factorial `z = n!!` via the gamma function. - void arb_bin_ui(arb_t z, const arb_t n, ulong k, slong prec) noexcept - void arb_bin_uiui(arb_t z, ulong n, ulong k, slong prec) noexcept - # Computes the binomial coefficient `z = {n choose k}`, via the - # rising factorial as `{n choose k} = (n-k+1)_k / k!`. - void arb_gamma(arb_t z, const arb_t x, slong prec) noexcept void arb_gamma_fmpq(arb_t z, const fmpq_t x, slong prec) noexcept void arb_gamma_fmpz(arb_t z, const fmpz_t x, slong prec) noexcept - # Computes the gamma function `z = \Gamma(x)`. - # These functions are aliases for :func:`arb_hypgeom_gamma`, - # :func:`arb_hypgeom_gamma_fmpq`, :func:`arb_hypgeom_gamma_fmpz`. - void arb_lgamma(arb_t z, const arb_t x, slong prec) noexcept - # Computes the logarithmic gamma function `z = \log \Gamma(x)`. - # The complex branch structure is assumed, so if `x \le 0`, the - # result is an indeterminate interval. - # This function is an alias for :func:`arb_hypgeom_lgamma`. - void arb_rgamma(arb_t z, const arb_t x, slong prec) noexcept - # Computes the reciprocal gamma function `z = 1/\Gamma(x)`, - # avoiding division by zero at the poles of the gamma function. - # This function is an alias for :func:`arb_hypgeom_rgamma`. - void arb_digamma(arb_t y, const arb_t x, slong prec) noexcept - # Computes the digamma function `z = \psi(x) = (\log \Gamma(x))' = \Gamma'(x) / \Gamma(x)`. - void arb_zeta_ui_vec_borwein(arb_ptr z, ulong start, slong num, ulong step, slong prec) noexcept - # Evaluates `\zeta(s)` at `\mathrm{num}` consecutive integers *s* beginning - # with *start* and proceeding in increments of *step*. - # Uses Borwein's formula ([Bor2000]_, [GS2003]_), - # implemented to support fast multi-evaluation - # (but also works well for a single *s*). - # Requires `\mathrm{start} \ge 2`. For efficiency, the largest *s* - # should be at most about as - # large as *prec*. Arguments approaching *LONG_MAX* will cause - # overflows. - # One should therefore only use this function for *s* up to about *prec*, and - # then switch to the Euler product. - # The algorithm for single *s* is basically identical to the one used in MPFR - # (see [MPFR2012]_ for a detailed description). - # In particular, we evaluate the sum backwards to avoid storing more than one - # `d_k` coefficient, and use integer arithmetic throughout since it - # is convenient and the terms turn out to be slightly larger than - # `2^\mathrm{prec}`. - # The only numerical error in the main loop comes from the division by `k^s`, - # which adds less than 1 unit of error per term. - # For fast multi-evaluation, we repeatedly divide by `k^{\mathrm{step}}`. - # Each division reduces the input error and adds at most 1 unit of - # additional rounding error, so by induction, the error per term - # is always smaller than 2 units. - void arb_zeta_ui_asymp(arb_t x, ulong s, slong prec) noexcept - void arb_zeta_ui_euler_product(arb_t z, ulong s, slong prec) noexcept - # Computes `\zeta(s)` using the Euler product. This is fast only if *s* - # is large compared to the precision. Both methods are trivial wrappers - # for :func:`_acb_dirichlet_euler_product_real_ui`. - void arb_zeta_ui_bernoulli(arb_t x, ulong s, slong prec) noexcept - # Computes `\zeta(s)` for even *s* via the corresponding Bernoulli number. - void arb_zeta_ui_borwein_bsplit(arb_t x, ulong s, slong prec) noexcept - # Computes `\zeta(s)` for arbitrary `s \ge 2` using a binary splitting - # implementation of Borwein's algorithm. This has quasilinear complexity - # with respect to the precision (assuming that `s` is fixed). - void arb_zeta_ui_vec(arb_ptr x, ulong start, slong num, slong prec) noexcept - void arb_zeta_ui_vec_even(arb_ptr x, ulong start, slong num, slong prec) noexcept - void arb_zeta_ui_vec_odd(arb_ptr x, ulong start, slong num, slong prec) noexcept - # Computes `\zeta(s)` at *num* consecutive integers (respectively *num* - # even or *num* odd integers) beginning with `s = \mathrm{start} \ge 2`, - # automatically choosing an appropriate algorithm. - void arb_zeta_ui(arb_t x, ulong s, slong prec) noexcept - # Computes `\zeta(s)` for nonnegative integer `s \ne 1`, automatically - # choosing an appropriate algorithm. This function is - # intended for numerical evaluation of isolated zeta values; for - # multi-evaluation, the vector versions are more efficient. - void arb_zeta(arb_t z, const arb_t s, slong prec) noexcept - # Sets *z* to the value of the Riemann zeta function `\zeta(s)`. - # For computing derivatives with respect to `s`, - # use :func:`arb_poly_zeta_series`. - void arb_hurwitz_zeta(arb_t z, const arb_t s, const arb_t a, slong prec) noexcept - # Sets *z* to the value of the Hurwitz zeta function `\zeta(s,a)`. - # For computing derivatives with respect to `s`, - # use :func:`arb_poly_zeta_series`. - void arb_bernoulli_ui(arb_t b, ulong n, slong prec) noexcept - void arb_bernoulli_fmpz(arb_t b, const fmpz_t n, slong prec) noexcept - # Sets `b` to the numerical value of the Bernoulli number `B_n` - # approximated to *prec* bits. - # The internal precision is increased automatically to give an accurate - # result. Note that, with huge *fmpz* input, the output will have a huge - # exponent and evaluation will accordingly be slower. - # A single division from the exact fraction of `B_n` is used if this value - # is in the global cache or the exact numerator roughly is larger than - # *prec* bits. Otherwise, the Riemann zeta function is used - # (see :func:`arb_bernoulli_ui_zeta`). - # This function reads `B_n` from the global cache - # if the number is already cached, but does not automatically extend - # the cache by itself. - void arb_bernoulli_ui_zeta(arb_t b, ulong n, slong prec) noexcept - # Sets `b` to the numerical value of `B_n` accurate to *prec* bits, - # computed using the formula `B_{2n} = (-1)^{n+1} 2 (2n)! \zeta(2n) / (2 \pi)^n`. - # To avoid potential infinite recursion, we explicitly call the - # Euler product implementation of the zeta function. - # This method will only give high accuracy if the precision is small - # enough compared to `n` for the Euler product to converge rapidly. - void arb_bernoulli_poly_ui(arb_t res, ulong n, const arb_t x, slong prec) noexcept - # Sets *res* to the value of the Bernoulli polynomial `B_n(x)`. - # Warning: this function is only fast if either *n* or *x* is a small integer. - # This function reads Bernoulli numbers from the global cache if they - # are already cached, but does not automatically extend the cache by itself. - void arb_power_sum_vec(arb_ptr res, const arb_t a, const arb_t b, slong len, slong prec) noexcept - # For *n* from 0 to *len* - 1, sets entry *n* in the output vector *res* to - # .. math :: - # S_n(a,b) = \frac{1}{n+1}\left(B_{n+1}(b) - B_{n+1}(a)\right) - # where `B_n(x)` is a Bernoulli polynomial. If *a* and *b* are integers - # and `b \ge a`, this is equivalent to - # .. math :: - # S_n(a,b) = \sum_{k=a}^{b-1} k^n. - # The computation uses the generating function for Bernoulli polynomials. - void arb_polylog(arb_t w, const arb_t s, const arb_t z, slong prec) noexcept - void arb_polylog_si(arb_t w, slong s, const arb_t z, slong prec) noexcept - # Sets *w* to the polylogarithm `\operatorname{Li}_s(z)`. - void arb_fib_fmpz(arb_t z, const fmpz_t n, slong prec) noexcept void arb_fib_ui(arb_t z, ulong n, slong prec) noexcept - # Computes the Fibonacci number `F_n` using binary squaring. - void arb_agm(arb_t z, const arb_t x, const arb_t y, slong prec) noexcept - # Sets *z* to the arithmetic-geometric mean of *x* and *y*. - void arb_chebyshev_t_ui(arb_t a, ulong n, const arb_t x, slong prec) noexcept - void arb_chebyshev_u_ui(arb_t a, ulong n, const arb_t x, slong prec) noexcept - # Evaluates the Chebyshev polynomial of the first kind `a = T_n(x)` - # or the Chebyshev polynomial of the second kind `a = U_n(x)`. - void arb_chebyshev_t2_ui(arb_t a, arb_t b, ulong n, const arb_t x, slong prec) noexcept - void arb_chebyshev_u2_ui(arb_t a, arb_t b, ulong n, const arb_t x, slong prec) noexcept - # Simultaneously evaluates `a = T_n(x), b = T_{n-1}(x)` or - # `a = U_n(x), b = U_{n-1}(x)`. - # Aliasing between *a*, *b* and *x* is not permitted. - void arb_bell_sum_bsplit(arb_t res, const fmpz_t n, const fmpz_t a, const fmpz_t b, const fmpz_t mmag, slong prec) noexcept - void arb_bell_sum_taylor(arb_t res, const fmpz_t n, const fmpz_t a, const fmpz_t b, const fmpz_t mmag, slong prec) noexcept - # Helper functions for Bell numbers, evaluating the sum - # `\sum_{k=a}^{b-1} k^n / k!`. If *mmag* is non-NULL, it may be used - # to indicate that the target error tolerance should be - # `2^{mmag - prec}`. - void arb_bell_fmpz(arb_t res, const fmpz_t n, slong prec) noexcept - void arb_bell_ui(arb_t res, ulong n, slong prec) noexcept - # Sets *res* to the Bell number `B_n`. If the number is too large to - # fit exactly in *prec* bits, a numerical approximation is computed - # efficiently. - # The algorithm to compute Bell numbers, including error analysis, - # is described in detail in [Joh2015]_. - void arb_euler_number_fmpz(arb_t res, const fmpz_t n, slong prec) noexcept void arb_euler_number_ui(arb_t res, ulong n, slong prec) noexcept - # Sets *res* to the Euler number `E_n`, which is defined by - # the exponential generating function `1 / \cosh(x)`. - # The result will be exact if `E_n` is exactly representable - # at the requested precision. - void arb_fmpz_euler_number_ui_multi_mod(fmpz_t res, ulong n, double alpha) noexcept void arb_fmpz_euler_number_ui(fmpz_t res, ulong n) noexcept - # Computes the Euler number `E_n` as an exact integer. The default - # algorithm uses a table lookup, the Dirichlet beta function or a - # hybrid modular algorithm depending on the size of *n*. - # The *multi_mod* algorithm accepts a tuning parameter *alpha* which - # can be set to a negative value to use defaults. - void arb_partitions_fmpz(arb_t res, const fmpz_t n, slong prec) noexcept - void arb_partitions_ui(arb_t res, ulong n, slong prec) noexcept - # Sets *res* to the partition function `p(n)`. - # When *n* is large and `\log_2 p(n)` is more than twice *prec*, - # the leading term in the Hardy-Ramanujan asymptotic series is used - # together with an error bound. Otherwise, the exact value is computed - # and rounded. - void arb_primorial_nth_ui(arb_t res, ulong n, slong prec) noexcept - # Sets *res* to the *nth* primorial, defined as the product of the - # first *n* prime numbers. The running time is quasilinear in *n*. - void arb_primorial_ui(arb_t res, ulong n, slong prec) noexcept - # Sets *res* to the primorial defined as the product of the positive - # integers up to and including *n*. The running time is quasilinear in *n*. - void _arb_atan_taylor_naive(mp_ptr y, mp_limb_t * error, mp_srcptr x, mp_size_t xn, ulong N, int alternating) noexcept - void _arb_atan_taylor_rs(mp_ptr y, mp_limb_t * error, mp_srcptr x, mp_size_t xn, ulong N, int alternating) noexcept - # Computes an approximation of `y = \sum_{k=0}^{N-1} x^{2k+1} / (2k+1)` - # (if *alternating* is 0) or `y = \sum_{k=0}^{N-1} (-1)^k x^{2k+1} / (2k+1)` - # (if *alternating* is 1). Used internally for computing arctangents - # and logarithms. The *naive* version uses the forward recurrence, and the - # *rs* version uses a division-avoiding rectangular splitting scheme. - # Requires `N \le 255`, `0 \le x \le 1/16`, and *xn* positive. - # The input *x* and output *y* are fixed-point numbers with *xn* fractional - # limbs. A bound for the ulp error is written to *error*. - void _arb_exp_taylor_naive(mp_ptr y, mp_limb_t * error, mp_srcptr x, mp_size_t xn, ulong N) noexcept - void _arb_exp_taylor_rs(mp_ptr y, mp_limb_t * error, mp_srcptr x, mp_size_t xn, ulong N) noexcept - # Computes an approximation of `y = \sum_{k=0}^{N-1} x^k / k!`. Used internally - # for computing exponentials. The *naive* version uses the forward recurrence, - # and the *rs* version uses a division-avoiding rectangular splitting scheme. - # Requires `N \le 287`, `0 \le x \le 1/16`, and *xn* positive. - # The input *x* is a fixed-point number with *xn* fractional - # limbs, and the output *y* is a fixed-point number with *xn* fractional - # limbs plus one extra limb for the integer part of the result. - # A bound for the ulp error is written to *error*. - 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) noexcept - 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) noexcept - # Computes approximations of `y_s = \sum_{k=0}^{N-1} (-1)^k x^{2k+1} / (2k+1)!` - # and `y_c = \sum_{k=0}^{N-1} (-1)^k x^{2k} / (2k)!`. - # Used internally for computing sines and cosines. The *naive* version uses - # the forward recurrence, and the *rs* version uses a division-avoiding - # rectangular splitting scheme. - # Requires `N \le 143`, `0 \le x \le 1/16`, and *xn* positive. - # The input *x* and outputs *ysin*, *ycos* are fixed-point numbers with - # *xn* fractional limbs. A bound for the ulp error is written to *error*. - # If *sinonly* is 1, only the sine is computed; if *sinonly* is 0 - # both the sine and cosine are computed. - # To compute sin and cos, *alternating* should be 1. If *alternating* is 0, - # the hyperbolic sine is computed (this is currently only intended to - # be used together with *sinonly*). - 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) noexcept - # Attempts to write `w = x - q \log(2)` with `0 \le w < \log(2)`, where *w* - # is a fixed-point number with *wn* limbs and ulp error *error*. - # Returns success. - 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) noexcept - # Attempts to write `w = |x| - q \pi/4` with `0 \le w < \pi/4`, where *w* - # is a fixed-point number with *wn* limbs and ulp error *error*. - # Returns success. - # The value of *q* mod 8 is written to *octant*. The output variable *q* - # can be NULL, in which case the full value of *q* is not stored. - slong _arb_exp_taylor_bound(slong mag, slong prec) noexcept - # Returns *n* such that - # `\left|\sum_{k=n}^{\infty} x^k / k!\right| \le 2^{-\mathrm{prec}}`, - # assuming `|x| \le 2^{\mathrm{mag}} \le 1/4`. - void arb_exp_arf_bb(arb_t z, const arf_t x, slong prec, int m1) noexcept - # Computes the exponential function using the bit-burst algorithm. - # If *m1* is nonzero, the exponential function minus one is computed - # accurately. - # Aborts if *x* is extremely small or large (where another algorithm - # should be used). - # For large *x*, repeated halving is used. In fact, we always - # do argument reduction until `|x|` is smaller than about `2^{-d}` - # where `d \approx 16` to speed up convergence. If `|x| \approx 2^m`, - # we thus need about `m+d` squarings. - # Computing `\log(2)` costs roughly 100-200 multiplications, so is not - # usually worth the effort at very high precision. However, this function - # could be improved by using `\log(2)` based reduction at precision low - # enough that the value can be assumed to be cached. - 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) noexcept - void _arb_exp_sum_bs_powtab(fmpz_t T, fmpz_t Q, flint_bitcnt_t * Qexp, const fmpz_t x, flint_bitcnt_t r, slong N) noexcept - # Computes *T*, *Q* and *Qexp* such that - # `T / (Q 2^{\text{Qexp}}) = \sum_{k=1}^N (x/2^r)^k/k!` using binary splitting. - # Note that the sum is taken to *N* inclusive and omits the constant term. - # The *powtab* version precomputes a table of powers of *x*, - # resulting in slightly higher memory usage but better speed. For best - # efficiency, *N* should have many trailing zero bits. - void arb_exp_arf_rs_generic(arb_t res, const arf_t x, slong prec, int minus_one) noexcept - # Computes the exponential function using a generic version of the rectangular - # splitting strategy, intended for intermediate precision. - void _arb_atan_sum_bs_simple(fmpz_t T, fmpz_t Q, flint_bitcnt_t * Qexp, const fmpz_t x, flint_bitcnt_t r, slong N) noexcept - void _arb_atan_sum_bs_powtab(fmpz_t T, fmpz_t Q, flint_bitcnt_t * Qexp, const fmpz_t x, flint_bitcnt_t r, slong N) noexcept - # Computes *T*, *Q* and *Qexp* such that - # `T / (Q 2^{\text{Qexp}}) = \sum_{k=1}^N (-1)^k (x/2^r)^{2k} / (2k+1)` - # using binary splitting. - # Note that the sum is taken to *N* inclusive, omits the linear term, - # and requires a final multiplication by `(x/2^r)` to give the - # true series for atan. - # The *powtab* version precomputes a table of powers of *x*, - # resulting in slightly higher memory usage but better speed. For best - # efficiency, *N* should have many trailing zero bits. - void arb_atan_arf_bb(arb_t z, const arf_t x, slong prec) noexcept - # Computes the arctangent of *x*. - # Initially, the argument-halving formula - # .. math :: - # \operatorname{atan}(x) = 2 \operatorname{atan}\left(\frac{x}{1+\sqrt{1+x^2}}\right) - # is applied up to 8 times to get a small argument. - # Then a version of the bit-burst algorithm is used. - # The functional equation - # .. math :: - # \operatorname{atan}(x) = \operatorname{atan}(p/q) + - # \operatorname{atan}(w), - # \quad w = \frac{qx-p}{px+q}, - # \quad p = \lfloor qx \rfloor - # is applied repeatedly instead of integrating a differential - # equation for the arctangent, as this appears to be more efficient. - void arb_atan_frac_bsplit(arb_t s, const fmpz_t p, const fmpz_t q, int hyperbolic, slong prec) noexcept - # Computes the arctangent of `p/q`, optionally the hyperbolic - # arctangent, using direct series summation with binary splitting. - void arb_sin_cos_arf_generic(arb_t s, arb_t c, const arf_t x, slong prec) noexcept - # Computes the sine and cosine of *x* using a generic strategy. - # This function gets called internally by the main sin and cos functions - # when the precision for argument reduction or series evaluation - # based on lookup tables is exhausted. - # This function first performs a cheap test to see if - # `|x| < \pi / 2 - \varepsilon`. If the test fails, it uses - # `\pi` to reduce the argument to the first octant, - # and then evaluates the sin and cos functions recursively (this call cannot - # result in infinite recursion). - # If no argument reduction is needed, this function uses a generic version - # of the rectangular splitting algorithm if the precision is not too high, - # and otherwise invokes the asymptotically fast bit-burst algorithm. - void arb_sin_cos_arf_bb(arb_t s, arb_t c, const arf_t x, slong prec) noexcept - # Computes the sine and cosine of *x* using the bit-burst algorithm. - # It is required that `|x| < \pi / 2` (this is not checked). - void arb_sin_cos_wide(arb_t s, arb_t c, const arb_t x, slong prec) noexcept - # Computes an accurate enclosure (with both endpoints optimal to within - # about `2^{-30}` as afforded by the radius format) of the range of - # sine and cosine on a given wide interval. The computation is done - # by evaluating the sine and cosine at the interval endpoints and - # determining whether peaks of -1 or 1 occur between the endpoints. - # The interval is then converted back to a ball. - # The internal computations are done with doubles, using a simple - # floating-point algorithm to approximate the sine and cosine. It is - # easy to see that the cumulative errors in this algorithm add up to - # less than `2^{-30}`, with the dominant source of error being a single - # approximate reduction by `\pi/2`. This reduction is done safely using - # doubles up to a magnitude of about `2^{20}`. For larger arguments, a - # slower reduction using :type:`arb_t` arithmetic is done as a - # preprocessing step. - void arb_sin_cos_generic(arb_t s, arb_t c, const arb_t x, slong prec) noexcept - # Computes the sine and cosine of *x* by taking care of various special - # cases and computing the propagated error before calling - # :func:`arb_sin_cos_arf_generic`. This is used as a fallback inside - # :func:`arb_sin_cos` to take care of all cases without a fast - # path in that function. - void arb_log_primes_vec_bsplit(arb_ptr res, slong n, slong prec) noexcept - # Sets *res* to a vector containing the natural logarithms of - # the first *n* prime numbers, computed using binary splitting - # applied to simultaneous Machine-type formulas. This function is not - # optimized for large *n* or small *prec*. - void _arb_log_p_ensure_cached(slong prec) noexcept - # Ensure that the internal cache of logarithms of small prime - # numbers has entries to at least *prec* bits. - void arb_exp_arf_log_reduction(arb_t res, const arf_t x, slong prec, int minus_one) noexcept - # Computes the exponential function using log reduction. - void arb_exp_arf_generic(arb_t z, const arf_t x, slong prec, int minus_one) noexcept - # Computes the exponential function using an automatic choice - # between rectangular splitting and the bit-burst algorithm, - # without precomputation. - void arb_exp_arf(arb_t z, const arf_t x, slong prec, int minus_one, slong maglim) noexcept - # Computes the exponential function using an automatic choice - # between all implemented algorithms. - void arb_log_newton(arb_t res, const arb_t x, slong prec) noexcept void arb_log_arf_newton(arb_t res, const arf_t x, slong prec) noexcept - # Computes the logarithm using Newton iteration. - void arb_atan_gauss_primes_vec_bsplit(arb_ptr res, slong n, slong prec) noexcept - # Sets *res* to the primitive angles corresponding to the - # first *n* nonreal Gaussian primes (ignoring symmetries), - # computed using binary splitting - # applied to simultaneous Machine-type formulas. This function is not - # optimized for large *n* or small *prec*. - void _arb_atan_gauss_p_ensure_cached(slong prec) noexcept - void arb_sin_cos_arf_atan_reduction(arb_t res1, arb_t res2, const arf_t x, slong prec) noexcept - # Computes sin and/or cos using reduction by primitive angles. - void arb_atan_newton(arb_t res, const arb_t x, slong prec) noexcept void arb_atan_arf_newton(arb_t res, const arf_t x, slong prec) noexcept - # Computes the arctangent using Newton iteration. - void _arb_vec_zero(arb_ptr vec, slong n) noexcept - # Sets all entries in *vec* to zero. - bint _arb_vec_is_zero(arb_srcptr vec, slong len) noexcept - # Returns nonzero iff all entries in *x* are zero. - bint _arb_vec_is_finite(arb_srcptr x, slong len) noexcept - # Returns nonzero iff all entries in *x* certainly are finite. - + bint _arb_vec_equal(arb_srcptr vec1, arb_srcptr vec2, slong len) noexcept + bint _arb_vec_overlaps(arb_srcptr vec1, arb_srcptr vec2, slong len) noexcept + bint _arb_vec_contains(arb_srcptr vec1, arb_srcptr vec2, slong len) noexcept void _arb_vec_set(arb_ptr res, arb_srcptr vec, slong len) noexcept - # Sets *res* to a copy of *vec*. - void _arb_vec_set_round(arb_ptr res, arb_srcptr vec, slong len, slong prec) noexcept - # Sets *res* to a copy of *vec*, rounding each entry to *prec* bits. - void _arb_vec_swap(arb_ptr vec1, arb_ptr vec2, slong len) noexcept - # Swaps the entries of *vec1* and *vec2*. - void _arb_vec_neg(arb_ptr B, arb_srcptr A, slong n) noexcept - void _arb_vec_sub(arb_ptr C, arb_srcptr A, arb_srcptr B, slong n, slong prec) noexcept - void _arb_vec_add(arb_ptr C, arb_srcptr A, arb_srcptr B, slong n, slong prec) noexcept - void _arb_vec_scalar_mul(arb_ptr res, arb_srcptr vec, slong len, const arb_t c, slong prec) noexcept - void _arb_vec_scalar_div(arb_ptr res, arb_srcptr vec, slong len, const arb_t c, slong prec) noexcept - void _arb_vec_scalar_mul_fmpz(arb_ptr res, arb_srcptr vec, slong len, const fmpz_t c, slong prec) noexcept - void _arb_vec_scalar_mul_2exp_si(arb_ptr res, arb_srcptr src, slong len, slong c) noexcept - void _arb_vec_scalar_addmul(arb_ptr res, arb_srcptr vec, slong len, const arb_t c, slong prec) noexcept - void _arb_vec_get_mag(mag_t bound, arb_srcptr vec, slong len) noexcept - # Sets *bound* to an upper bound for the entries in *vec*. - slong _arb_vec_bits(arb_srcptr x, slong len) noexcept - # Returns the maximum of :func:`arb_bits` for all entries in *vec*. - void _arb_vec_set_powers(arb_ptr xs, const arb_t x, slong len, slong prec) noexcept - # Sets *xs* to the powers `1, x, x^2, \ldots, x^{len-1}`. - void _arb_vec_add_error_arf_vec(arb_ptr res, arf_srcptr err, slong len) noexcept - void _arb_vec_add_error_mag_vec(arb_ptr res, mag_srcptr err, slong len) noexcept - # Adds the magnitude of each entry in *err* to the radius of the - # corresponding entry in *res*. - void _arb_vec_indeterminate(arb_ptr vec, slong len) noexcept - # Applies :func:`arb_indeterminate` elementwise. - void _arb_vec_trim(arb_ptr res, arb_srcptr vec, slong len) noexcept - # Applies :func:`arb_trim` elementwise. - int _arb_vec_get_unique_fmpz_vec(fmpz * res, arb_srcptr vec, slong len) noexcept - # Calls :func:`arb_get_unique_fmpz` elementwise and returns nonzero if - # all entries can be rounded uniquely to integers. If any entry in *vec* - # cannot be rounded uniquely to an integer, returns zero. + void _arb_vec_printn(arb_srcptr vec, slong len, slong digits, ulong flags) noexcept + void _arb_vec_printd(arb_srcptr vec, slong len, slong ndigits) noexcept from .arb_macros cimport * diff --git a/src/sage/libs/flint/arb_calc.pxd b/src/sage/libs/flint/arb_calc.pxd index 2d872e59343..47ff5273d9c 100644 --- a/src/sage/libs/flint/arb_calc.pxd +++ b/src/sage/libs/flint/arb_calc.pxd @@ -2,7 +2,9 @@ # distutils: depends = flint/arb_calc.h ################################################################################ -# This file is auto-generated. Do not modify by hand +# This file is auto-generated by the script +# SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py. +# Do not modify by hand! Fix and rerun the script instead. ################################################################################ from libc.stdio cimport FILE @@ -11,123 +13,17 @@ from sage.libs.mpfr.types cimport * from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void arf_interval_init(arf_interval_t v) noexcept - void arf_interval_clear(arf_interval_t v) noexcept - arf_interval_ptr _arf_interval_vec_init(slong n) noexcept - void _arf_interval_vec_clear(arf_interval_ptr v, slong n) noexcept - void arf_interval_set(arf_interval_t v, const arf_interval_t u) noexcept - void arf_interval_swap(arf_interval_t v, arf_interval_t u) noexcept - void arf_interval_get_arb(arb_t x, const arf_interval_t v, slong prec) noexcept - void arf_interval_printd(const arf_interval_t v, slong n) noexcept - # Helper functions for endpoint-based intervals. - void arf_interval_fprintd(FILE * file, const arf_interval_t v, slong n) noexcept - # Helper functions for endpoint-based intervals. - slong arb_calc_isolate_roots(arf_interval_ptr * found, int ** flags, arb_calc_func_t func, void * param, const arf_interval_t interval, slong maxdepth, slong maxeval, slong maxfound, slong prec) noexcept - # Rigorously isolates single roots of a real analytic function - # on the interior of an interval. - # This routine writes an array of *n* interesting subintervals of - # *interval* to *found* and corresponding flags to *flags*, returning the integer *n*. - # The output has the following properties: - # * The function has no roots on *interval* outside of the output - # subintervals. - # * Subintervals are sorted in increasing order (with no overlap except - # possibly starting and ending with the same point). - # * Subintervals with a flag of 1 contain exactly one (single) root. - # * Subintervals with any other flag may or may not contain roots. - # If no flags other than 1 occur, all roots of the function on *interval* - # have been isolated. If there are output subintervals on which the - # existence or nonexistence of roots could not be determined, - # the user may attempt further searches on those subintervals - # (possibly with increased precision and/or increased - # bounds for the breaking criteria). Note that roots of multiplicity - # higher than one and roots located exactly at endpoints cannot be isolated - # by the algorithm. - # The following breaking criteria are implemented: - # * At most *maxdepth* recursive subdivisions are attempted. The smallest - # details that can be distinguished are therefore about - # `2^{-\text{maxdepth}}` times the width of *interval*. - # A typical, reasonable value might be between 20 and 50. - # * If the total number of tested subintervals exceeds *maxeval*, the - # algorithm is terminated and any untested subintervals are added - # to the output. The total number of calls to *func* is thereby restricted - # to a small multiple of *maxeval* (the actual count can be slightly - # higher depending on implementation details). - # A typical, reasonable value might be between 100 and 100000. - # * The algorithm terminates if *maxfound* roots have been isolated. - # In particular, setting *maxfound* to 1 can be used to locate - # just one root of the function even if there are numerous roots. - # To try to find all roots, *LONG_MAX* may be passed. - # The argument *prec* denotes the precision used to evaluate the - # function. It is possibly also used for some other arithmetic operations - # performed internally by the algorithm. Note that it probably does not - # make sense for *maxdepth* to exceed *prec*. - # Warning: it is assumed that subdivision points of *interval* can be - # represented exactly as floating-point numbers in memory. - # Do not pass `1 \pm 2^{-10^{100}}` as input. - int arb_calc_refine_root_bisect(arf_interval_t r, arb_calc_func_t func, void * param, const arf_interval_t start, slong it, slong prec) noexcept - # Given an interval *start* known to contain a single root of *func*, - # refines it using *iter* bisection steps. The algorithm can - # return a failure code if the sign of the function at an evaluation - # point is ambiguous. The output *r* is set to a valid isolating interval - # (possibly just *start*) even if the algorithm fails. - void arb_calc_newton_conv_factor(arf_t conv_factor, arb_calc_func_t func, void * param, const arb_t conv_region, slong prec) noexcept - # Given an interval `I` specified by *conv_region*, evaluates a bound - # for `C = \sup_{t,u \in I} \frac{1}{2} |f''(t)| / |f'(u)|`, - # where `f` is the function specified by *func* and *param*. - # The bound is obtained by evaluating `f'(I)` and `f''(I)` directly. - # If `f` is ill-conditioned, `I` may need to be extremely precise in - # order to get an effective, finite bound for *C*. - int arb_calc_newton_step(arb_t xnew, arb_calc_func_t func, void * param, const arb_t x, const arb_t conv_region, const arf_t conv_factor, slong prec) noexcept - # Performs a single step with an interval version of Newton's method. - # The input consists of the function `f` specified - # by *func* and *param*, a ball `x = [m-r, m+r]` known - # to contain a single root of `f`, a ball `I` (*conv_region*) - # containing `x` with an associated bound (*conv_factor*) for - # `C = \sup_{t,u \in I} \frac{1}{2} |f''(t)| / |f'(u)|`, - # and a working precision *prec*. - # The Newton update consists of setting - # `x' = [m'-r', m'+r']` where `m' = m - f(m) / f'(m)` - # and `r' = C r^2`. The expression `m - f(m) / f'(m)` is evaluated - # using ball arithmetic at a working precision of *prec* bits, and the - # rounding error during this evaluation is accounted for in the output. - # We now check that `x' \in I` and `r' < r`. If both conditions are - # satisfied, we set *xnew* to `x'` and return *ARB_CALC_SUCCESS*. - # If either condition fails, we set *xnew* to `x` and return - # *ARB_CALC_NO_CONVERGENCE*, indicating that no progress - # is made. - int arb_calc_refine_root_newton(arb_t r, arb_calc_func_t func, void * param, const arb_t start, const arb_t conv_region, const arf_t conv_factor, slong eval_extra_prec, slong prec) noexcept - # Refines a precise estimate of a single root of a function - # to high precision by performing several Newton steps, using - # nearly optimally chosen doubling precision steps. - # The inputs are defined as for *arb_calc_newton_step*, except for - # the precision parameters: *prec* is the target accuracy and - # *eval_extra_prec* is the estimated number of guard bits that need - # to be added to evaluate the function accurately close to the root - # (for example, if the function is a polynomial with large coefficients - # of alternating signs and Horner's rule is used to evaluate it, - # the extra precision should typically be approximately - # the bit size of the coefficients). - # This function returns *ARB_CALC_SUCCESS* if all attempted - # Newton steps are successful (note that this does not guarantee - # that the computed root is accurate to *prec* bits, which has - # to be verified by the user), only that it is more accurate - # than the starting ball. - # On failure, *ARB_CALC_IMPRECISE_INPUT* - # or *ARB_CALC_NO_CONVERGENCE* may be returned. In this case, *r* - # is set to a ball for the root which is valid but likely - # does have full accuracy (it can possibly just be equal - # to the starting ball). diff --git a/src/sage/libs/flint/arb_fmpz_poly.pxd b/src/sage/libs/flint/arb_fmpz_poly.pxd index 6a5b28a0301..cee8a0ef8dc 100644 --- a/src/sage/libs/flint/arb_fmpz_poly.pxd +++ b/src/sage/libs/flint/arb_fmpz_poly.pxd @@ -2,7 +2,9 @@ # distutils: depends = flint/arb_fmpz_poly.h ################################################################################ -# This file is auto-generated. Do not modify by hand +# This file is auto-generated by the script +# SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py. +# Do not modify by hand! Fix and rerun the script instead. ################################################################################ from libc.stdio cimport FILE @@ -11,93 +13,20 @@ from sage.libs.mpfr.types cimport * from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void _arb_fmpz_poly_evaluate_arb_horner(arb_t res, const fmpz * poly, slong len, const arb_t x, slong prec) noexcept - void arb_fmpz_poly_evaluate_arb_horner(arb_t res, const fmpz_poly_t poly, const arb_t x, slong prec) noexcept - void _arb_fmpz_poly_evaluate_arb_rectangular(arb_t res, const fmpz * poly, slong len, const arb_t x, slong prec) noexcept - void arb_fmpz_poly_evaluate_arb_rectangular(arb_t res, const fmpz_poly_t poly, const arb_t x, slong prec) noexcept - void _arb_fmpz_poly_evaluate_arb(arb_t res, const fmpz * poly, slong len, const arb_t x, slong prec) noexcept - void arb_fmpz_poly_evaluate_arb(arb_t res, const fmpz_poly_t poly, const arb_t x, slong prec) noexcept - void _arb_fmpz_poly_evaluate_acb_horner(acb_t res, const fmpz * poly, slong len, const acb_t x, slong prec) noexcept - void arb_fmpz_poly_evaluate_acb_horner(acb_t res, const fmpz_poly_t poly, const acb_t x, slong prec) noexcept - void _arb_fmpz_poly_evaluate_acb_rectangular(acb_t res, const fmpz * poly, slong len, const acb_t x, slong prec) noexcept - void arb_fmpz_poly_evaluate_acb_rectangular(acb_t res, const fmpz_poly_t poly, const acb_t x, slong prec) noexcept - void _arb_fmpz_poly_evaluate_acb(acb_t res, const fmpz * poly, slong len, const acb_t x, slong prec) noexcept - void arb_fmpz_poly_evaluate_acb(acb_t res, const fmpz_poly_t poly, const acb_t x, slong prec) noexcept - # Evaluates *poly* (given by a polynomial object or an array with *len* coefficients) - # at the given real or complex number, respectively using Horner's rule, rectangular - # splitting, or a default algorithm choice. - ulong arb_fmpz_poly_deflation(const fmpz_poly_t poly) noexcept - # Finds the maximal exponent by which *poly* can be deflated. - void arb_fmpz_poly_deflate(fmpz_poly_t res, const fmpz_poly_t poly, ulong deflation) noexcept - # Sets *res* to a copy of *poly* deflated by the exponent *deflation*. - void arb_fmpz_poly_complex_roots(acb_ptr roots, const fmpz_poly_t poly, int flags, slong prec) noexcept - # Writes to *roots* all the real and complex roots of the polynomial *poly*, - # computed to at least *prec* accurate bits. - # The root enclosures are guaranteed to be disjoint, so that - # all roots are isolated. - # The real roots are written first in ascending order (with - # the imaginary parts set exactly to zero). The following - # nonreal roots are written in arbitrary order, but with conjugate pairs - # grouped together (the root in the upper plane leading - # the root in the lower plane). - # The input polynomial *must* be squarefree. For a general polynomial, - # compute the squarefree part `f / \gcd(f,f')` or do a full squarefree - # factorization to obtain the multiplicities of the roots:: - # fmpz_poly_factor_t fac; - # fmpz_poly_factor_init(fac); - # fmpz_poly_factor_squarefree(fac, poly); - # for (i = 0; i < fac->num; i++) - # { - # deg = fmpz_poly_degree(fac->p + i); - # flint_printf("%wd roots of multiplicity %wd\n", deg, fac->exp[i]); - # roots = _acb_vec_init(deg); - # arb_fmpz_poly_complex_roots(roots, fac->p + i, 0, prec); - # _acb_vec_clear(roots, deg); - # } - # fmpz_poly_factor_clear(fac); - # All roots are refined to a relative accuracy of at least *prec* bits. - # The output values will generally have higher actual precision, - # depending on the precision needed for isolation and the - # precision used internally by the algorithm. - # This implementation should be adequate for general use, but it is not - # currently competitive with state-of-the-art isolation - # methods for finding real roots alone. - # The following *flags* are supported: - # * *ARB_FMPZ_POLY_ROOTS_VERBOSE* - void arb_fmpz_poly_cos_minpoly(fmpz_poly_t res, ulong n) noexcept - # Sets *res* to the monic minimal polynomial of `2 \cos(2 \pi / n)`. - # This is a wrapper of FLINT's *fmpz_poly_cos_minpoly*, provided here - # for backward compatibility. - void arb_fmpz_poly_gauss_period_minpoly(fmpz_poly_t res, ulong q, ulong n) noexcept - # Sets *res* to the minimal polynomial of the Gaussian periods - # `\sum_{a \in H} \zeta^a` where `\zeta = \exp(2 \pi i / q)` - # and *H* are the cosets of the subgroups of order `d = (q - 1) / n` of - # `(\mathbb{Z}/q\mathbb{Z})^{\times}`. - # The resulting polynomial has degree *n*. - # When `d = 1`, the result is the cyclotomic polynomial `\Phi_q`. - # The implementation assumes that *q* is prime, and that *n* is a divisor of - # `q - 1` such that *n* is coprime with *d*. If any condition is not met, - # *res* is set to the zero polynomial. - # This method provides a fast (in practice) way to - # construct finite field extensions of prescribed degree. - # If *q* satisfies the conditions stated above and `(q-1)/f` additionally - # is coprime with *n*, where *f* is the multiplicative order of *p* mod *q*, then - # the Gaussian period minimal polynomial is irreducible over - # `\operatorname{GF}(p)` [CP2005]_. diff --git a/src/sage/libs/flint/arb_fpwrap.pxd b/src/sage/libs/flint/arb_fpwrap.pxd index 2c5095c9f85..7a5aada626f 100644 --- a/src/sage/libs/flint/arb_fpwrap.pxd +++ b/src/sage/libs/flint/arb_fpwrap.pxd @@ -2,7 +2,9 @@ # distutils: depends = flint/arb_fpwrap.h ################################################################################ -# This file is auto-generated. Do not modify by hand +# This file is auto-generated by the script +# SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py. +# Do not modify by hand! Fix and rerun the script instead. ################################################################################ from libc.stdio cimport FILE @@ -11,338 +13,201 @@ from sage.libs.mpfr.types cimport * from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - int arb_fpwrap_double_exp(double * res, double x, int flags) noexcept int arb_fpwrap_cdouble_exp(complex_double * res, complex_double x, int flags) noexcept - int arb_fpwrap_double_expm1(double * res, double x, int flags) noexcept int arb_fpwrap_cdouble_expm1(complex_double * res, complex_double x, int flags) noexcept - int arb_fpwrap_double_log(double * res, double x, int flags) noexcept int arb_fpwrap_cdouble_log(complex_double * res, complex_double x, int flags) noexcept - int arb_fpwrap_double_log1p(double * res, double x, int flags) noexcept int arb_fpwrap_cdouble_log1p(complex_double * res, complex_double x, int flags) noexcept - int arb_fpwrap_double_pow(double * res, double x, double y, int flags) noexcept int arb_fpwrap_cdouble_pow(complex_double * res, complex_double x, complex_double y, int flags) noexcept - int arb_fpwrap_double_sqrt(double * res, double x, int flags) noexcept int arb_fpwrap_cdouble_sqrt(complex_double * res, complex_double x, int flags) noexcept - int arb_fpwrap_double_rsqrt(double * res, double x, int flags) noexcept int arb_fpwrap_cdouble_rsqrt(complex_double * res, complex_double x, int flags) noexcept - int arb_fpwrap_double_cbrt(double * res, double x, int flags) noexcept int arb_fpwrap_cdouble_cbrt(complex_double * res, complex_double x, int flags) noexcept - int arb_fpwrap_double_sin(double * res, double x, int flags) noexcept int arb_fpwrap_cdouble_sin(complex_double * res, complex_double x, int flags) noexcept - int arb_fpwrap_double_cos(double * res, double x, int flags) noexcept int arb_fpwrap_cdouble_cos(complex_double * res, complex_double x, int flags) noexcept - int arb_fpwrap_double_tan(double * res, double x, int flags) noexcept int arb_fpwrap_cdouble_tan(complex_double * res, complex_double x, int flags) noexcept - int arb_fpwrap_double_cot(double * res, double x, int flags) noexcept int arb_fpwrap_cdouble_cot(complex_double * res, complex_double x, int flags) noexcept - int arb_fpwrap_double_sec(double * res, double x, int flags) noexcept int arb_fpwrap_cdouble_sec(complex_double * res, complex_double x, int flags) noexcept - int arb_fpwrap_double_csc(double * res, double x, int flags) noexcept int arb_fpwrap_cdouble_csc(complex_double * res, complex_double x, int flags) noexcept - int arb_fpwrap_double_sinc(double * res, double x, int flags) noexcept int arb_fpwrap_cdouble_sinc(complex_double * res, complex_double x, int flags) noexcept - int arb_fpwrap_double_sin_pi(double * res, double x, int flags) noexcept int arb_fpwrap_cdouble_sin_pi(complex_double * res, complex_double x, int flags) noexcept - int arb_fpwrap_double_cos_pi(double * res, double x, int flags) noexcept int arb_fpwrap_cdouble_cos_pi(complex_double * res, complex_double x, int flags) noexcept - int arb_fpwrap_double_tan_pi(double * res, double x, int flags) noexcept int arb_fpwrap_cdouble_tan_pi(complex_double * res, complex_double x, int flags) noexcept - int arb_fpwrap_double_cot_pi(double * res, double x, int flags) noexcept int arb_fpwrap_cdouble_cot_pi(complex_double * res, complex_double x, int flags) noexcept - int arb_fpwrap_double_sinc_pi(double * res, double x, int flags) noexcept int arb_fpwrap_cdouble_sinc_pi(complex_double * res, complex_double x, int flags) noexcept - int arb_fpwrap_double_asin(double * res, double x, int flags) noexcept int arb_fpwrap_cdouble_asin(complex_double * res, complex_double x, int flags) noexcept - int arb_fpwrap_double_acos(double * res, double x, int flags) noexcept int arb_fpwrap_cdouble_acos(complex_double * res, complex_double x, int flags) noexcept - int arb_fpwrap_double_atan(double * res, double x, int flags) noexcept int arb_fpwrap_cdouble_atan(complex_double * res, complex_double x, int flags) noexcept - int arb_fpwrap_double_atan2(double * res, double x1, double x2, int flags) noexcept - int arb_fpwrap_double_asinh(double * res, double x, int flags) noexcept int arb_fpwrap_cdouble_asinh(complex_double * res, complex_double x, int flags) noexcept - int arb_fpwrap_double_acosh(double * res, double x, int flags) noexcept int arb_fpwrap_cdouble_acosh(complex_double * res, complex_double x, int flags) noexcept - int arb_fpwrap_double_atanh(double * res, double x, int flags) noexcept int arb_fpwrap_cdouble_atanh(complex_double * res, complex_double x, int flags) noexcept - int arb_fpwrap_double_lambertw(double * res, double x, slong branch, int flags) noexcept int arb_fpwrap_cdouble_lambertw(complex_double * res, complex_double x, slong branch, int flags) noexcept - int arb_fpwrap_double_rising(double * res, double x, double n, int flags) noexcept int arb_fpwrap_cdouble_rising(complex_double * res, complex_double x, complex_double n, int flags) noexcept - # Rising factorial. - int arb_fpwrap_double_gamma(double * res, double x, int flags) noexcept int arb_fpwrap_cdouble_gamma(complex_double * res, complex_double x, int flags) noexcept - # Gamma function. - int arb_fpwrap_double_rgamma(double * res, double x, int flags) noexcept int arb_fpwrap_cdouble_rgamma(complex_double * res, complex_double x, int flags) noexcept - # Reciprocal gamma function. - int arb_fpwrap_double_lgamma(double * res, double x, int flags) noexcept int arb_fpwrap_cdouble_lgamma(complex_double * res, complex_double x, int flags) noexcept - # Log-gamma function. - int arb_fpwrap_double_digamma(double * res, double x, int flags) noexcept int arb_fpwrap_cdouble_digamma(complex_double * res, complex_double x, int flags) noexcept - # Digamma function. - int arb_fpwrap_double_zeta(double * res, double x, int flags) noexcept int arb_fpwrap_cdouble_zeta(complex_double * res, complex_double x, int flags) noexcept - # Riemann zeta function. - int arb_fpwrap_double_hurwitz_zeta(double * res, double s, double z, int flags) noexcept int arb_fpwrap_cdouble_hurwitz_zeta(complex_double * res, complex_double s, complex_double z, int flags) noexcept - # Hurwitz zeta function. - int arb_fpwrap_double_lerch_phi(double * res, double z, double s, double a, int flags) noexcept int arb_fpwrap_cdouble_lerch_phi(complex_double * res, complex_double z, complex_double s, complex_double a, int flags) noexcept - # Lerch transcendent. - int arb_fpwrap_double_barnes_g(double * res, double x, int flags) noexcept int arb_fpwrap_cdouble_barnes_g(complex_double * res, complex_double x, int flags) noexcept - # Barnes G-function. - int arb_fpwrap_double_log_barnes_g(double * res, double x, int flags) noexcept int arb_fpwrap_cdouble_log_barnes_g(complex_double * res, complex_double x, int flags) noexcept - # Logarithmic Barnes G-function. - int arb_fpwrap_double_polygamma(double * res, double s, double z, int flags) noexcept int arb_fpwrap_cdouble_polygamma(complex_double * res, complex_double s, complex_double z, int flags) noexcept - # Polygamma function. - int arb_fpwrap_double_polylog(double * res, double s, double z, int flags) noexcept int arb_fpwrap_cdouble_polylog(complex_double * res, complex_double s, complex_double z, int flags) noexcept - # Polylogarithm. - int arb_fpwrap_cdouble_dirichlet_eta(complex_double * res, complex_double s, int flags) noexcept - int arb_fpwrap_cdouble_riemann_xi(complex_double * res, complex_double s, int flags) noexcept - int arb_fpwrap_cdouble_hardy_theta(complex_double * res, complex_double z, int flags) noexcept - int arb_fpwrap_cdouble_hardy_z(complex_double * res, complex_double z, int flags) noexcept - int arb_fpwrap_cdouble_zeta_zero(complex_double * res, ulong n, int flags) noexcept - int arb_fpwrap_double_erf(double * res, double x, int flags) noexcept int arb_fpwrap_cdouble_erf(complex_double * res, complex_double x, int flags) noexcept - int arb_fpwrap_double_erfc(double * res, double x, int flags) noexcept int arb_fpwrap_cdouble_erfc(complex_double * res, complex_double x, int flags) noexcept - int arb_fpwrap_double_erfi(double * res, double x, int flags) noexcept int arb_fpwrap_cdouble_erfi(complex_double * res, complex_double x, int flags) noexcept - int arb_fpwrap_double_erfinv(double * res, double x, int flags) noexcept - int arb_fpwrap_double_erfcinv(double * res, double x, int flags) noexcept - int arb_fpwrap_double_fresnel_s(double * res, double x, int normalized, int flags) noexcept int arb_fpwrap_cdouble_fresnel_s(complex_double * res, complex_double x, int normalized, int flags) noexcept - int arb_fpwrap_double_fresnel_c(double * res, double x, int normalized, int flags) noexcept int arb_fpwrap_cdouble_fresnel_c(complex_double * res, complex_double x, int normalized, int flags) noexcept - int arb_fpwrap_double_gamma_upper(double * res, double s, double z, int regularized, int flags) noexcept int arb_fpwrap_cdouble_gamma_upper(complex_double * res, complex_double s, complex_double z, int regularized, int flags) noexcept - int arb_fpwrap_double_gamma_lower(double * res, double s, double z, int regularized, int flags) noexcept int arb_fpwrap_cdouble_gamma_lower(complex_double * res, complex_double s, complex_double z, int regularized, int flags) noexcept - int arb_fpwrap_double_beta_lower(double * res, double a, double b, double z, int regularized, int flags) noexcept int arb_fpwrap_cdouble_beta_lower(complex_double * res, complex_double a, complex_double b, complex_double z, int regularized, int flags) noexcept - int arb_fpwrap_double_exp_integral_e(double * res, double s, double z, int flags) noexcept int arb_fpwrap_cdouble_exp_integral_e(complex_double * res, complex_double s, complex_double z, int flags) noexcept - int arb_fpwrap_double_exp_integral_ei(double * res, double x, int flags) noexcept int arb_fpwrap_cdouble_exp_integral_ei(complex_double * res, complex_double x, int flags) noexcept - int arb_fpwrap_double_sin_integral(double * res, double x, int flags) noexcept int arb_fpwrap_cdouble_sin_integral(complex_double * res, complex_double x, int flags) noexcept - int arb_fpwrap_double_cos_integral(double * res, double x, int flags) noexcept int arb_fpwrap_cdouble_cos_integral(complex_double * res, complex_double x, int flags) noexcept - int arb_fpwrap_double_sinh_integral(double * res, double x, int flags) noexcept int arb_fpwrap_cdouble_sinh_integral(complex_double * res, complex_double x, int flags) noexcept - int arb_fpwrap_double_cosh_integral(double * res, double x, int flags) noexcept int arb_fpwrap_cdouble_cosh_integral(complex_double * res, complex_double x, int flags) noexcept - int arb_fpwrap_double_log_integral(double * res, double x, int offset, int flags) noexcept int arb_fpwrap_cdouble_log_integral(complex_double * res, complex_double x, int offset, int flags) noexcept - int arb_fpwrap_double_dilog(double * res, double x, int flags) noexcept int arb_fpwrap_cdouble_dilog(complex_double * res, complex_double x, int flags) noexcept - int arb_fpwrap_double_bessel_j(double * res, double nu, double x, int flags) noexcept int arb_fpwrap_cdouble_bessel_j(complex_double * res, complex_double nu, complex_double x, int flags) noexcept - int arb_fpwrap_double_bessel_y(double * res, double nu, double x, int flags) noexcept int arb_fpwrap_cdouble_bessel_y(complex_double * res, complex_double nu, complex_double x, int flags) noexcept - int arb_fpwrap_double_bessel_i(double * res, double nu, double x, int flags) noexcept int arb_fpwrap_cdouble_bessel_i(complex_double * res, complex_double nu, complex_double x, int flags) noexcept - int arb_fpwrap_double_bessel_k(double * res, double nu, double x, int flags) noexcept int arb_fpwrap_cdouble_bessel_k(complex_double * res, complex_double nu, complex_double x, int flags) noexcept - int arb_fpwrap_double_bessel_k_scaled(double * res, double nu, double x, int flags) noexcept int arb_fpwrap_cdouble_bessel_k_scaled(complex_double * res, complex_double nu, complex_double x, int flags) noexcept - int arb_fpwrap_double_airy_ai(double * res, double x, int flags) noexcept int arb_fpwrap_cdouble_airy_ai(complex_double * res, complex_double x, int flags) noexcept - int arb_fpwrap_double_airy_ai_prime(double * res, double x, int flags) noexcept int arb_fpwrap_cdouble_airy_ai_prime(complex_double * res, complex_double x, int flags) noexcept - int arb_fpwrap_double_airy_bi(double * res, double x, int flags) noexcept int arb_fpwrap_cdouble_airy_bi(complex_double * res, complex_double x, int flags) noexcept - int arb_fpwrap_double_airy_bi_prime(double * res, double x, int flags) noexcept int arb_fpwrap_cdouble_airy_bi_prime(complex_double * res, complex_double x, int flags) noexcept - int arb_fpwrap_double_airy_ai_zero(double * res, ulong n, int flags) noexcept - int arb_fpwrap_double_airy_ai_prime_zero(double * res, ulong n, int flags) noexcept - int arb_fpwrap_double_airy_bi_zero(double * res, ulong n, int flags) noexcept - int arb_fpwrap_double_airy_bi_prime_zero(double * res, ulong n, int flags) noexcept - int arb_fpwrap_double_coulomb_f(double * res, double l, double eta, double x, int flags) noexcept int arb_fpwrap_cdouble_coulomb_f(complex_double * res, complex_double l, complex_double eta, complex_double x, int flags) noexcept - int arb_fpwrap_double_coulomb_g(double * res, double l, double eta, double x, int flags) noexcept int arb_fpwrap_cdouble_coulomb_g(complex_double * res, complex_double l, complex_double eta, complex_double x, int flags) noexcept - int arb_fpwrap_cdouble_coulomb_hpos(complex_double * res, complex_double l, complex_double eta, complex_double x, int flags) noexcept int arb_fpwrap_cdouble_coulomb_hneg(complex_double * res, complex_double l, complex_double eta, complex_double x, int flags) noexcept - int arb_fpwrap_double_chebyshev_t(double * res, double n, double x, int flags) noexcept int arb_fpwrap_cdouble_chebyshev_t(complex_double * res, complex_double n, complex_double x, int flags) noexcept - int arb_fpwrap_double_chebyshev_u(double * res, double n, double x, int flags) noexcept int arb_fpwrap_cdouble_chebyshev_u(complex_double * res, complex_double n, complex_double x, int flags) noexcept - int arb_fpwrap_double_jacobi_p(double * res, double n, double a, double b, double x, int flags) noexcept int arb_fpwrap_cdouble_jacobi_p(complex_double * res, complex_double n, complex_double a, complex_double b, complex_double x, int flags) noexcept - int arb_fpwrap_double_gegenbauer_c(double * res, double n, double m, double x, int flags) noexcept int arb_fpwrap_cdouble_gegenbauer_c(complex_double * res, complex_double n, complex_double m, complex_double x, int flags) noexcept - int arb_fpwrap_double_laguerre_l(double * res, double n, double m, double x, int flags) noexcept int arb_fpwrap_cdouble_laguerre_l(complex_double * res, complex_double n, complex_double m, complex_double x, int flags) noexcept - int arb_fpwrap_double_hermite_h(double * res, double n, double x, int flags) noexcept int arb_fpwrap_cdouble_hermite_h(complex_double * res, complex_double n, complex_double x, int flags) noexcept - int arb_fpwrap_double_legendre_p(double * res, double n, double m, double x, int type, int flags) noexcept int arb_fpwrap_cdouble_legendre_p(complex_double * res, complex_double n, complex_double m, complex_double x, int type, int flags) noexcept - int arb_fpwrap_double_legendre_q(double * res, double n, double m, double x, int type, int flags) noexcept int arb_fpwrap_cdouble_legendre_q(complex_double * res, complex_double n, complex_double m, complex_double x, int type, int flags) noexcept - int arb_fpwrap_double_legendre_root(double * res1, double * res2, ulong n, ulong k, int flags) noexcept - # Sets *res1* to the index *k* root of the Legendre polynomial `P_n(x)`, - # and simultaneously sets *res2* to the corresponding weight for - # Gauss-Legendre quadrature. - int arb_fpwrap_cdouble_spherical_y(complex_double * res, slong n, slong m, complex_double x1, complex_double x2, int flags) noexcept - int arb_fpwrap_double_hypgeom_0f1(double * res, double a, double x, int regularized, int flags) noexcept int arb_fpwrap_cdouble_hypgeom_0f1(complex_double * res, complex_double a, complex_double x, int regularized, int flags) noexcept - int arb_fpwrap_double_hypgeom_1f1(double * res, double a, double b, double x, int regularized, int flags) noexcept int arb_fpwrap_cdouble_hypgeom_1f1(complex_double * res, complex_double a, complex_double b, complex_double x, int regularized, int flags) noexcept - int arb_fpwrap_double_hypgeom_u(double * res, double a, double b, double x, int flags) noexcept int arb_fpwrap_cdouble_hypgeom_u(complex_double * res, complex_double a, complex_double b, complex_double x, int flags) noexcept - int arb_fpwrap_double_hypgeom_2f1(double * res, double a, double b, double c, double x, int regularized, int flags) noexcept int arb_fpwrap_cdouble_hypgeom_2f1(complex_double * res, complex_double a, complex_double b, complex_double c, complex_double x, int regularized, int flags) noexcept - int arb_fpwrap_double_hypgeom_pfq(double * res, const double * a, slong p, const double * b, slong q, double z, int regularized, int flags) noexcept int arb_fpwrap_cdouble_hypgeom_pfq(complex_double * res, const complex_double * a, slong p, const complex_double * b, slong q, complex_double z, int regularized, int flags) noexcept - int arb_fpwrap_double_agm(double * res, double x, double y, int flags) noexcept int arb_fpwrap_cdouble_agm(complex_double * res, complex_double x, complex_double y, int flags) noexcept - # Arithmetic-geometric mean. - int arb_fpwrap_cdouble_elliptic_k(complex_double * res, complex_double m, int flags) noexcept - int arb_fpwrap_cdouble_elliptic_e(complex_double * res, complex_double m, int flags) noexcept - int arb_fpwrap_cdouble_elliptic_pi(complex_double * res, complex_double n, complex_double m, int flags) noexcept - int arb_fpwrap_cdouble_elliptic_f(complex_double * res, complex_double phi, complex_double m, int pi, int flags) noexcept - int arb_fpwrap_cdouble_elliptic_e_inc(complex_double * res, complex_double phi, complex_double m, int pi, int flags) noexcept - int arb_fpwrap_cdouble_elliptic_pi_inc(complex_double * res, complex_double n, complex_double phi, complex_double m, int pi, int flags) noexcept - # Complete and incomplete elliptic integrals. - int arb_fpwrap_cdouble_elliptic_rf(complex_double * res, complex_double x, complex_double y, complex_double z, int option, int flags) noexcept - int arb_fpwrap_cdouble_elliptic_rg(complex_double * res, complex_double x, complex_double y, complex_double z, int option, int flags) noexcept - int arb_fpwrap_cdouble_elliptic_rj(complex_double * res, complex_double x, complex_double y, complex_double z, complex_double w, int option, int flags) noexcept - # Carlson symmetric elliptic integrals. - int arb_fpwrap_cdouble_elliptic_p(complex_double * res, complex_double z, complex_double tau, int flags) noexcept - int arb_fpwrap_cdouble_elliptic_p_prime(complex_double * res, complex_double z, complex_double tau, int flags) noexcept - int arb_fpwrap_cdouble_elliptic_inv_p(complex_double * res, complex_double z, complex_double tau, int flags) noexcept - int arb_fpwrap_cdouble_elliptic_zeta(complex_double * res, complex_double z, complex_double tau, int flags) noexcept - int arb_fpwrap_cdouble_elliptic_sigma(complex_double * res, complex_double z, complex_double tau, int flags) noexcept - # Weierstrass elliptic functions. - int arb_fpwrap_cdouble_jacobi_theta_1(complex_double * res, complex_double z, complex_double tau, int flags) noexcept - int arb_fpwrap_cdouble_jacobi_theta_2(complex_double * res, complex_double z, complex_double tau, int flags) noexcept - int arb_fpwrap_cdouble_jacobi_theta_3(complex_double * res, complex_double z, complex_double tau, int flags) noexcept - int arb_fpwrap_cdouble_jacobi_theta_4(complex_double * res, complex_double z, complex_double tau, int flags) noexcept - # Jacobi theta functions. - int arb_fpwrap_cdouble_dedekind_eta(complex_double * res, complex_double tau, int flags) noexcept - int arb_fpwrap_cdouble_modular_j(complex_double * res, complex_double tau, int flags) noexcept - int arb_fpwrap_cdouble_modular_lambda(complex_double * res, complex_double tau, int flags) noexcept - int arb_fpwrap_cdouble_modular_delta(complex_double * res, complex_double tau, int flags) noexcept diff --git a/src/sage/libs/flint/arb_hypgeom.pxd b/src/sage/libs/flint/arb_hypgeom.pxd index 84c37c726de..1d82b859eac 100644 --- a/src/sage/libs/flint/arb_hypgeom.pxd +++ b/src/sage/libs/flint/arb_hypgeom.pxd @@ -2,7 +2,9 @@ # distutils: depends = flint/arb_hypgeom.h ################################################################################ -# This file is auto-generated. Do not modify by hand +# This file is auto-generated by the script +# SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py. +# Do not modify by hand! Fix and rerun the script instead. ################################################################################ from libc.stdio cimport FILE @@ -11,511 +13,133 @@ from sage.libs.mpfr.types cimport * from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void _arb_hypgeom_rising_coeffs_1(ulong * c, ulong k, slong n) noexcept void _arb_hypgeom_rising_coeffs_2(ulong * c, ulong k, slong n) noexcept void _arb_hypgeom_rising_coeffs_fmpz(fmpz * c, ulong k, slong n) noexcept - # Sets *c* to the coefficients of the rising factorial polynomial - # `(X+k)_n`. The *1* and *2* versions respectively - # compute single-word and double-word coefficients, without checking for - # overflow, while the *fmpz* version allows arbitrarily large coefficients. - # These functions are mostly intended for internal use; the *fmpz* version - # does not use an asymptotically fast algorithm. - # The degree *n* must be at least 2. - void arb_hypgeom_rising_ui_forward(arb_t res, const arb_t x, ulong n, slong prec) noexcept void arb_hypgeom_rising_ui_bs(arb_t res, const arb_t x, ulong n, slong prec) noexcept void arb_hypgeom_rising_ui_rs(arb_t res, const arb_t x, ulong n, ulong m, slong prec) noexcept void arb_hypgeom_rising_ui_rec(arb_t res, const arb_t x, ulong n, slong prec) noexcept void arb_hypgeom_rising_ui(arb_t res, const arb_t x, ulong n, slong prec) noexcept void arb_hypgeom_rising(arb_t res, const arb_t x, const arb_t n, slong prec) noexcept - # Computes the rising factorial `(x)_n`. - # The *forward* version uses the forward recurrence. - # The *bs* version uses binary splitting. - # The *rs* version uses rectangular splitting. It takes an extra tuning - # parameter *m* which can be set to zero to choose automatically. - # The *rec* version chooses an algorithm automatically, avoiding - # use of the gamma function (so that it can be used in the computation - # of the gamma function). - # The default versions (*rising_ui* and *rising_ui*) choose an algorithm - # automatically and may additionally fall back on the gamma function. - void arb_hypgeom_rising_ui_jet_powsum(arb_ptr res, const arb_t x, ulong n, slong len, slong prec) noexcept void arb_hypgeom_rising_ui_jet_bs(arb_ptr res, const arb_t x, ulong n, slong len, slong prec) noexcept void arb_hypgeom_rising_ui_jet_rs(arb_ptr res, const arb_t x, ulong n, ulong m, slong len, slong prec) noexcept void arb_hypgeom_rising_ui_jet(arb_ptr res, const arb_t x, ulong n, slong len, slong prec) noexcept - # Computes the jet of the rising factorial `(x)_n`, truncated to length *len*. - # In other words, constructs the polynomial `(X + x)_n \in \mathbb{R}[X]`, - # truncated if `\operatorname{len} < n + 1` (and zero-extended - # if `\operatorname{len} > n + 1`). - # The *powsum* version computes the sequence of powers of *x* and forms integral - # linear combinations of these. - # The *bs* version uses binary splitting. - # The *rs* version uses rectangular splitting. It takes an extra tuning - # parameter *m* which can be set to zero to choose automatically. - # The default version chooses an algorithm automatically. - void _arb_hypgeom_gamma_stirling_term_bounds(slong * bound, const mag_t zinv, slong N) noexcept - # For `1 \le n < N`, sets *bound* to an exponent bounding the *n*-th term - # in the Stirling series for the gamma function, given a precomputed upper - # bound for `|z|^{-1}`. This function is intended for internal use and - # does not check for underflow or underflow in the exponents. - void arb_hypgeom_gamma_stirling_sum_horner(arb_t res, const arb_t z, slong N, slong prec) noexcept void arb_hypgeom_gamma_stirling_sum_improved(arb_t res, const arb_t z, slong N, slong K, slong prec) noexcept - # Sets *res* to the final sum in the Stirling series for the gamma function - # truncated before the term with index *N*, i.e. computes - # `\sum_{n=1}^{N-1} B_{2n} / (2n(2n-1) z^{2n-1})`. - # The *horner* version uses Horner scheme with gradual precision adjustments. - # The *improved* version uses rectangular splitting for the low-index - # terms and reexpands the high-index terms as hypergeometric polynomials, - # using a splitting parameter *K* (which can be set to 0 to use a default - # value). - void arb_hypgeom_gamma_stirling(arb_t res, const arb_t x, int reciprocal, slong prec) noexcept - # Sets *res* to the gamma function of *x* computed using the Stirling - # series together with argument reduction. If *reciprocal* is set, - # the reciprocal gamma function is computed instead. - int arb_hypgeom_gamma_taylor(arb_t res, const arb_t x, int reciprocal, slong prec) noexcept - # Attempts to compute the gamma function of *x* using Taylor series - # together with argument reduction. This is only supported if *x* and *prec* - # are both small enough. If successful, returns 1; otherwise, does nothing - # and returns 0. If *reciprocal* is set, the reciprocal gamma function is - # computed instead. - void arb_hypgeom_gamma(arb_t res, const arb_t x, slong prec) noexcept void arb_hypgeom_gamma_fmpq(arb_t res, const fmpq_t x, slong prec) noexcept void arb_hypgeom_gamma_fmpz(arb_t res, const fmpz_t x, slong prec) noexcept - # Sets *res* to the gamma function of *x* computed using a default - # algorithm choice. - void arb_hypgeom_rgamma(arb_t res, const arb_t x, slong prec) noexcept - # Sets *res* to the reciprocal gamma function of *x* computed using a default - # algorithm choice. - void arb_hypgeom_lgamma(arb_t res, const arb_t x, slong prec) noexcept - # Sets *res* to the log-gamma function of *x* computed using a default - # algorithm choice. - void arb_hypgeom_central_bin_ui(arb_t res, ulong n, slong prec) noexcept - # Computes the central binomial coefficient `{2n choose n}`. - void arb_hypgeom_pfq(arb_t res, arb_srcptr a, slong p, arb_srcptr b, slong q, const arb_t z, int regularized, slong prec) noexcept - # Computes the generalized hypergeometric function `{}_pF_{q}(z)`, - # or the regularized version if *regularized* is set. - void arb_hypgeom_0f1(arb_t res, const arb_t a, const arb_t z, int regularized, slong prec) noexcept - # Computes the confluent hypergeometric limit function - # `{}_0F_1(a,z)`, or `\frac{1}{\Gamma(a)} {}_0F_1(a,z)` if *regularized* - # is set. - void arb_hypgeom_m(arb_t res, const arb_t a, const arb_t b, const arb_t z, int regularized, slong prec) noexcept - # Computes the confluent hypergeometric function - # `M(a,b,z) = {}_1F_1(a,b,z)`, or - # `\mathbf{M}(a,b,z) = \frac{1}{\Gamma(b)} {}_1F_1(a,b,z)` if *regularized* is set. - void arb_hypgeom_1f1(arb_t res, const arb_t a, const arb_t b, const arb_t z, int regularized, slong prec) noexcept - # Alias for :func:`arb_hypgeom_m`. - void arb_hypgeom_1f1_integration(arb_t res, const arb_t a, const arb_t b, const arb_t z, int regularized, slong prec) noexcept - # Computes the confluent hypergeometric function using numerical integration - # of the representation - # .. math :: - # {}_1F_1(a,b,z) = \frac{\Gamma(b)}{\Gamma(a) \Gamma(b-a)} \int_0^1 e^{zt} t^{a-1} (1-t)^{b-a-1} dt. - # This algorithm can be useful if the parameters are large. This will currently - # only return a finite enclosure if `a \ge 1` and `b - a \ge 1`. - void arb_hypgeom_u(arb_t res, const arb_t a, const arb_t b, const arb_t z, slong prec) noexcept - # Computes the confluent hypergeometric function `U(a,b,z)`. - void arb_hypgeom_u_integration(arb_t res, const arb_t a, const arb_t b, const arb_t z, slong prec) noexcept - # Computes the confluent hypergeometric function `U(a,b,z)` using numerical integration - # of the representation - # .. math :: - # U(a,b,z) = \frac{1}{\Gamma(a)} \int_0^{\infty} e^{-zt} t^{a-1} (1+t)^{b-a-1} dt. - # This algorithm can be useful if the parameters are large. This will currently - # only return a finite enclosure if `a \ge 1` and `z > 0`. - void arb_hypgeom_2f1(arb_t res, const arb_t a, const arb_t b, const arb_t c, const arb_t z, int regularized, slong prec) noexcept - # Computes the Gauss hypergeometric function - # `{}_2F_1(a,b,c,z)`, or - # `\mathbf{F}(a,b,c,z) = \frac{1}{\Gamma(c)} {}_2F_1(a,b,c,z)` - # if *regularized* is set. - # Additional evaluation flags can be passed via the *regularized* - # argument; see :func:`acb_hypgeom_2f1` for documentation. - void arb_hypgeom_2f1_integration(arb_t res, const arb_t a, const arb_t b, const arb_t c, const arb_t z, int regularized, slong prec) noexcept - # Computes the Gauss hypergeometric function using numerical integration - # of the representation - # .. math :: - # {}_2F_1(a,b,c,z) = \frac{\Gamma(a)}{\Gamma(b) \Gamma(c-b)} \int_0^1 t^{b-1} (1-t)^{c-b-1} (1-zt)^{-a} dt. - # This algorithm can be useful if the parameters are large. This will currently - # only return a finite enclosure if `b \ge 1` and `c - b \ge 1` and - # `z < 1`, possibly with *a* and *b* exchanged. - void arb_hypgeom_erf(arb_t res, const arb_t z, slong prec) noexcept - # Computes the error function `\operatorname{erf}(z)`. - void _arb_hypgeom_erf_series(arb_ptr res, arb_srcptr z, slong zlen, slong len, slong prec) noexcept void arb_hypgeom_erf_series(arb_poly_t res, const arb_poly_t z, slong len, slong prec) noexcept - # Computes the error function of the power series *z*, - # truncated to length *len*. - void arb_hypgeom_erfc(arb_t res, const arb_t z, slong prec) noexcept - # Computes the complementary error function - # `\operatorname{erfc}(z) = 1 - \operatorname{erf}(z)`. - # This function avoids catastrophic cancellation for large positive *z*. - void _arb_hypgeom_erfc_series(arb_ptr res, arb_srcptr z, slong zlen, slong len, slong prec) noexcept void arb_hypgeom_erfc_series(arb_poly_t res, const arb_poly_t z, slong len, slong prec) noexcept - # Computes the complementary error function of the power series *z*, - # truncated to length *len*. - void arb_hypgeom_erfi(arb_t res, const arb_t z, slong prec) noexcept - # Computes the imaginary error function - # `\operatorname{erfi}(z) = -i\operatorname{erf}(iz)`. - void _arb_hypgeom_erfi_series(arb_ptr res, arb_srcptr z, slong zlen, slong len, slong prec) noexcept void arb_hypgeom_erfi_series(arb_poly_t res, const arb_poly_t z, slong len, slong prec) noexcept - # Computes the imaginary error function of the power series *z*, - # truncated to length *len*. - void arb_hypgeom_erfinv(arb_t res, const arb_t z, slong prec) noexcept void arb_hypgeom_erfcinv(arb_t res, const arb_t z, slong prec) noexcept - # Computes the inverse error function `\operatorname{erf}^{-1}(z)` - # or inverse complementary error function `\operatorname{erfc}^{-1}(z)`. - void arb_hypgeom_fresnel(arb_t res1, arb_t res2, const arb_t z, int normalized, slong prec) noexcept - # Sets *res1* to the Fresnel sine integral `S(z)` and *res2* to - # the Fresnel cosine integral `C(z)`. Optionally, just a single function - # can be computed by passing *NULL* as the other output variable. - # The definition `S(z) = \int_0^z \sin(t^2) dt` is used if *normalized* is 0, - # and `S(z) = \int_0^z \sin(\tfrac{1}{2} \pi t^2) dt` is used if - # *normalized* is 1 (the latter is the Abramowitz & Stegun convention). - # `C(z)` is defined analogously. - void _arb_hypgeom_fresnel_series(arb_ptr res1, arb_ptr res2, arb_srcptr z, slong zlen, int normalized, slong len, slong prec) noexcept void arb_hypgeom_fresnel_series(arb_poly_t res1, arb_poly_t res2, const arb_poly_t z, int normalized, slong len, slong prec) noexcept - # Sets *res1* to the Fresnel sine integral and *res2* to the Fresnel - # cosine integral of the power series *z*, truncated to length *len*. - # Optionally, just a single function can be computed by passing *NULL* - # as the other output variable. - void arb_hypgeom_gamma_upper(arb_t res, const arb_t s, const arb_t z, int regularized, slong prec) noexcept - # If *regularized* is 0, computes the upper incomplete gamma function - # `\Gamma(s,z)`. - # If *regularized* is 1, computes the regularized upper incomplete - # gamma function `Q(s,z) = \Gamma(s,z) / \Gamma(s)`. - # If *regularized* is 2, computes the generalized exponential integral - # `z^{-s} \Gamma(s,z) = E_{1-s}(z)` instead (this option is mainly - # intended for internal use; :func:`arb_hypgeom_expint` is the intended - # interface for computing the exponential integral). - void arb_hypgeom_gamma_upper_integration(arb_t res, const arb_t s, const arb_t z, int regularized, slong prec) noexcept - # Computes the upper incomplete gamma function using numerical - # integration. - void _arb_hypgeom_gamma_upper_series(arb_ptr res, const arb_t s, arb_srcptr z, slong zlen, int regularized, slong n, slong prec) noexcept void arb_hypgeom_gamma_upper_series(arb_poly_t res, const arb_t s, const arb_poly_t z, int regularized, slong n, slong prec) noexcept - # Sets *res* to an upper incomplete gamma function where *s* is - # a constant and *z* is a power series, truncated to length *n*. - # The *regularized* argument has the same interpretation as in - # :func:`arb_hypgeom_gamma_upper`. - void arb_hypgeom_gamma_lower(arb_t res, const arb_t s, const arb_t z, int regularized, slong prec) noexcept - # If *regularized* is 0, computes the lower incomplete gamma function - # `\gamma(s,z) = \frac{z^s}{s} {}_1F_1(s, s+1, -z)`. - # If *regularized* is 1, computes the regularized lower incomplete - # gamma function `P(s,z) = \gamma(s,z) / \Gamma(s)`. - # If *regularized* is 2, computes a further regularized lower incomplete - # gamma function `\gamma^{*}(s,z) = z^{-s} P(s,z)`. - void _arb_hypgeom_gamma_lower_series(arb_ptr res, const arb_t s, arb_srcptr z, slong zlen, int regularized, slong n, slong prec) noexcept void arb_hypgeom_gamma_lower_series(arb_poly_t res, const arb_t s, const arb_poly_t z, int regularized, slong n, slong prec) noexcept - # Sets *res* to an lower incomplete gamma function where *s* is - # a constant and *z* is a power series, truncated to length *n*. - # The *regularized* argument has the same interpretation as in - # :func:`arb_hypgeom_gamma_lower`. - void arb_hypgeom_beta_lower(arb_t res, const arb_t a, const arb_t b, const arb_t z, int regularized, slong prec) noexcept - # Computes the (lower) incomplete beta function, defined by - # `B(a,b;z) = \int_0^z t^{a-1} (1-t)^{b-1}`, - # optionally the regularized incomplete beta function - # `I(a,b;z) = B(a,b;z) / B(a,b;1)`. - void _arb_hypgeom_beta_lower_series(arb_ptr res, const arb_t a, const arb_t b, arb_srcptr z, slong zlen, int regularized, slong n, slong prec) noexcept void arb_hypgeom_beta_lower_series(arb_poly_t res, const arb_t a, const arb_t b, const arb_poly_t z, int regularized, slong n, slong prec) noexcept - # Sets *res* to the lower incomplete beta function `B(a,b;z)` (optionally - # the regularized version `I(a,b;z)`) where *a* and *b* are constants - # and *z* is a power series, truncating the result to length *n*. - # The underscore method requires positive lengths and does not support - # aliasing. - void _arb_hypgeom_gamma_lower_sum_rs_1(arb_t res, ulong p, ulong q, const arb_t z, slong N, slong prec) noexcept - # Computes `\sum_{k=0}^{N-1} z^k / (a)_k` where `a = p/q` using - # rectangular splitting. It is assumed that `p + qN` fits in a limb. - void _arb_hypgeom_gamma_upper_sum_rs_1(arb_t res, ulong p, ulong q, const arb_t z, slong N, slong prec) noexcept - # Computes `\sum_{k=0}^{N-1} (a)_k / z^k` where `a = p/q` using - # rectangular splitting. It is assumed that `p + qN` fits in a limb. - slong _arb_hypgeom_gamma_upper_fmpq_inf_choose_N(mag_t err, const fmpq_t a, const arb_t z, const mag_t abs_tol) noexcept - # Returns number of terms *N* and sets *err* to the truncation error for evaluating - # `\Gamma(a,z)` using the asymptotic series at infinity, targeting an absolute - # tolerance of *abs_tol*. The error may be set to *err* if the tolerance - # cannot be achieved. Assumes that *z* is positive. - void _arb_hypgeom_gamma_upper_fmpq_inf_bsplit(arb_t res, const fmpq_t a, const arb_t z, slong N, slong prec) noexcept - # Sets *res* to the approximation of `\Gamma(a,z)` obtained by truncating - # the asymptotic series at infinity before term *N*. - # The truncation error bound has to be added separately. - slong _arb_hypgeom_gamma_lower_fmpq_0_choose_N(mag_t err, const fmpq_t a, const arb_t z, const mag_t abs_tol) noexcept - # Returns number of terms *N* and sets *err* to the truncation error for evaluating - # `\gamma(a,z)` using the Taylor series at zero, targeting an absolute - # tolerance of *abs_tol*. Assumes that *z* is positive. - void _arb_hypgeom_gamma_lower_fmpq_0_bsplit(arb_t res, const fmpq_t a, const arb_t z, slong N, slong prec) noexcept - # Sets *res* to the approximation of `\gamma(a,z)` obtained by truncating - # the Taylor series at zero before term *N*. - # The truncation error bound has to be added separately. - slong _arb_hypgeom_gamma_upper_singular_si_choose_N(mag_t err, slong n, const arb_t z, const mag_t abs_tol) noexcept - # Returns number of terms *N* and sets *err* to the truncation error for evaluating - # `\Gamma(-n,z)` using the Taylor series at zero, targeting an absolute - # tolerance of *abs_tol*. - void _arb_hypgeom_gamma_upper_singular_si_bsplit(arb_t res, slong n, const arb_t z, slong N, slong prec) noexcept - # Sets *res* to the approximation of `\Gamma(-n,z)` obtained by truncating - # the Taylor series at zero before term *N*. - # The truncation error bound has to be added separately. - void _arb_gamma_upper_fmpq_step_bsplit(arb_t Gz1, const fmpq_t a, const arb_t z0, const arb_t z1, const arb_t Gz0, const arb_t expmz0, const mag_t abs_tol, slong prec) noexcept - # Given *Gz0* and *expmz0* representing the values `\Gamma(a,z_0)` and `\exp(-z_0)`, - # computes `\Gamma(a,z_1)` using the Taylor series at `z_0` evaluated - # using binary splitting, - # targeting an absolute error of *abs_tol*. - # Assumes that `z_0` and `z_1` are positive. - void arb_hypgeom_expint(arb_t res, const arb_t s, const arb_t z, slong prec) noexcept - # Computes the generalized exponential integral `E_s(z)`. - void arb_hypgeom_ei(arb_t res, const arb_t z, slong prec) noexcept - # Computes the exponential integral `\operatorname{Ei}(z)`. - void _arb_hypgeom_ei_series(arb_ptr res, arb_srcptr z, slong zlen, slong len, slong prec) noexcept void arb_hypgeom_ei_series(arb_poly_t res, const arb_poly_t z, slong len, slong prec) noexcept - # Computes the exponential integral of the power series *z*, - # truncated to length *len*. - void _arb_hypgeom_si_asymp(arb_t res, const arb_t z, slong N, slong prec) noexcept void _arb_hypgeom_si_1f2(arb_t res, const arb_t z, slong N, slong wp, slong prec) noexcept void arb_hypgeom_si(arb_t res, const arb_t z, slong prec) noexcept - # Computes the sine integral `\operatorname{Si}(z)`. - void _arb_hypgeom_si_series(arb_ptr res, arb_srcptr z, slong zlen, slong len, slong prec) noexcept void arb_hypgeom_si_series(arb_poly_t res, const arb_poly_t z, slong len, slong prec) noexcept - # Computes the sine integral of the power series *z*, - # truncated to length *len*. - void _arb_hypgeom_ci_asymp(arb_t res, const arb_t z, slong N, slong prec) noexcept void _arb_hypgeom_ci_2f3(arb_t res, const arb_t z, slong N, slong wp, slong prec) noexcept void arb_hypgeom_ci(arb_t res, const arb_t z, slong prec) noexcept - # Computes the cosine integral `\operatorname{Ci}(z)`. - # The result is indeterminate if `z < 0` since the value of the function would be complex. - void _arb_hypgeom_ci_series(arb_ptr res, arb_srcptr z, slong zlen, slong len, slong prec) noexcept void arb_hypgeom_ci_series(arb_poly_t res, const arb_poly_t z, slong len, slong prec) noexcept - # Computes the cosine integral of the power series *z*, - # truncated to length *len*. - void arb_hypgeom_shi(arb_t res, const arb_t z, slong prec) noexcept - # Computes the hyperbolic sine integral `\operatorname{Shi}(z) = -i \operatorname{Si}(iz)`. - void _arb_hypgeom_shi_series(arb_ptr res, arb_srcptr z, slong zlen, slong len, slong prec) noexcept void arb_hypgeom_shi_series(arb_poly_t res, const arb_poly_t z, slong len, slong prec) noexcept - # Computes the hyperbolic sine integral of the power series *z*, - # truncated to length *len*. - void arb_hypgeom_chi(arb_t res, const arb_t z, slong prec) noexcept - # Computes the hyperbolic cosine integral `\operatorname{Chi}(z)`. - # The result is indeterminate if `z < 0` since the value of the function would be complex. - void _arb_hypgeom_chi_series(arb_ptr res, arb_srcptr z, slong zlen, slong len, slong prec) noexcept void arb_hypgeom_chi_series(arb_poly_t res, const arb_poly_t z, slong len, slong prec) noexcept - # Computes the hyperbolic cosine integral of the power series *z*, - # truncated to length *len*. - void arb_hypgeom_li(arb_t res, const arb_t z, int offset, slong prec) noexcept - # If *offset* is zero, computes the logarithmic integral - # `\operatorname{li}(z) = \operatorname{Ei}(\log(z))`. - # If *offset* is nonzero, computes the offset logarithmic integral - # `\operatorname{Li}(z) = \operatorname{li}(z) - \operatorname{li}(2)`. - # The result is indeterminate if `z < 0` since the value of the function would be complex. - void _arb_hypgeom_li_series(arb_ptr res, arb_srcptr z, slong zlen, int offset, slong len, slong prec) noexcept void arb_hypgeom_li_series(arb_poly_t res, const arb_poly_t z, int offset, slong len, slong prec) noexcept - # Computes the logarithmic integral (optionally the offset version) - # of the power series *z*, truncated to length *len*. - void arb_hypgeom_bessel_j(arb_t res, const arb_t nu, const arb_t z, slong prec) noexcept - # Computes the Bessel function of the first kind `J_{\nu}(z)`. - void arb_hypgeom_bessel_y(arb_t res, const arb_t nu, const arb_t z, slong prec) noexcept - # Computes the Bessel function of the second kind `Y_{\nu}(z)`. - void arb_hypgeom_bessel_jy(arb_t res1, arb_t res2, const arb_t nu, const arb_t z, slong prec) noexcept - # Sets *res1* to `J_{\nu}(z)` and *res2* to `Y_{\nu}(z)`, computed - # simultaneously. - void arb_hypgeom_bessel_i(arb_t res, const arb_t nu, const arb_t z, slong prec) noexcept - # Computes the modified Bessel function of the first kind - # `I_{\nu}(z) = z^{\nu} (iz)^{-\nu} J_{\nu}(iz)`. - void arb_hypgeom_bessel_i_scaled(arb_t res, const arb_t nu, const arb_t z, slong prec) noexcept - # Computes the function `e^{-z} I_{\nu}(z)`. - void arb_hypgeom_bessel_k(arb_t res, const arb_t nu, const arb_t z, slong prec) noexcept - # Computes the modified Bessel function of the second kind `K_{\nu}(z)`. - void arb_hypgeom_bessel_k_scaled(arb_t res, const arb_t nu, const arb_t z, slong prec) noexcept - # Computes the function `e^{z} K_{\nu}(z)`. - void arb_hypgeom_bessel_i_integration(arb_t res, const arb_t nu, const arb_t z, int scaled, slong prec) noexcept void arb_hypgeom_bessel_k_integration(arb_t res, const arb_t nu, const arb_t z, int scaled, slong prec) noexcept - # Computes the modified Bessel functions using numerical integration. - void arb_hypgeom_airy(arb_t ai, arb_t ai_prime, arb_t bi, arb_t bi_prime, const arb_t z, slong prec) noexcept - # Computes the Airy functions `(\operatorname{Ai}(z), \operatorname{Ai}'(z), \operatorname{Bi}(z), \operatorname{Bi}'(z))` - # simultaneously. Any of the four function values can be omitted by passing - # *NULL* for the unwanted output variables, speeding up the evaluation. - void arb_hypgeom_airy_jet(arb_ptr ai, arb_ptr bi, const arb_t z, slong len, slong prec) noexcept - # Writes to *ai* and *bi* the respective Taylor expansions of the Airy functions - # at the point *z*, truncated to length *len*. - # Either of the outputs can be *NULL* to avoid computing that function. - # The variable *z* is not allowed to be aliased with the outputs. - # To simplify the implementation, this method does not compute the - # series expansions of the primed versions directly; these are - # easily obtained by computing one extra coefficient and differentiating - # the output with :func:`_arb_poly_derivative`. - void _arb_hypgeom_airy_series(arb_ptr ai, arb_ptr ai_prime, arb_ptr bi, arb_ptr bi_prime, arb_srcptr z, slong zlen, slong len, slong prec) noexcept void arb_hypgeom_airy_series(arb_poly_t ai, arb_poly_t ai_prime, arb_poly_t bi, arb_poly_t bi_prime, const arb_poly_t z, slong len, slong prec) noexcept - # Computes the Airy functions evaluated at the power series *z*, - # truncated to length *len*. As with the other Airy methods, any of the - # outputs can be *NULL*. - void arb_hypgeom_airy_zero(arb_t a, arb_t a_prime, arb_t b, arb_t b_prime, const fmpz_t n, slong prec) noexcept - # Computes the *n*-th real zero `a_n`, `a'_n`, `b_n`, or `b'_n` - # for the respective Airy function or Airy function derivative. - # Any combination of the four output variables can be *NULL*. - # The zeros are indexed by increasing magnitude, starting with - # `n = 1` to follow the convention in the literature. - # An index *n* that is not positive is invalid input. - # The implementation uses asymptotic expansions for the zeros - # [PS1991]_ together with the interval Newton method for refinement. - void arb_hypgeom_coulomb(arb_t F, arb_t G, const arb_t l, const arb_t eta, const arb_t z, slong prec) noexcept - # Writes to *F*, *G* the values of the respective - # Coulomb wave functions `F_{\ell}(\eta,z)` and `G_{\ell}(\eta,z)`. - # Either of the outputs can be *NULL*. - void arb_hypgeom_coulomb_jet(arb_ptr F, arb_ptr G, const arb_t l, const arb_t eta, const arb_t z, slong len, slong prec) noexcept - # Writes to *F*, *G* the respective Taylor expansions of the - # Coulomb wave functions at the point *z*, truncated to length *len*. - # Either of the outputs can be *NULL*. - void _arb_hypgeom_coulomb_series(arb_ptr F, arb_ptr G, const arb_t l, const arb_t eta, arb_srcptr z, slong zlen, slong len, slong prec) noexcept void arb_hypgeom_coulomb_series(arb_poly_t F, arb_poly_t G, const arb_t l, const arb_t eta, const arb_poly_t z, slong len, slong prec) noexcept - # Computes the Coulomb wave functions evaluated at the power series *z*, - # truncated to length *len*. Either of the outputs can be *NULL*. - void arb_hypgeom_chebyshev_t(arb_t res, const arb_t nu, const arb_t z, slong prec) noexcept void arb_hypgeom_chebyshev_u(arb_t res, const arb_t nu, const arb_t z, slong prec) noexcept void arb_hypgeom_jacobi_p(arb_t res, const arb_t n, const arb_t a, const arb_t b, const arb_t z, slong prec) noexcept void arb_hypgeom_gegenbauer_c(arb_t res, const arb_t n, const arb_t m, const arb_t z, slong prec) noexcept void arb_hypgeom_laguerre_l(arb_t res, const arb_t n, const arb_t m, const arb_t z, slong prec) noexcept void arb_hypgeom_hermite_h(arb_t res, const arb_t nu, const arb_t z, slong prec) noexcept - # Computes Chebyshev, Jacobi, Gegenbauer, Laguerre or Hermite polynomials, - # or their extensions to non-integer orders. - void arb_hypgeom_legendre_p(arb_t res, const arb_t n, const arb_t m, const arb_t z, int type, slong prec) noexcept void arb_hypgeom_legendre_q(arb_t res, const arb_t n, const arb_t m, const arb_t z, int type, slong prec) noexcept - # Computes Legendre functions of the first and second kind. - # See :func:`acb_hypgeom_legendre_p` and :func:`acb_hypgeom_legendre_q` - # for definitions. - void arb_hypgeom_legendre_p_ui_deriv_bound(mag_t dp, mag_t dp2, ulong n, const arb_t x, const arb_t x2sub1) noexcept - # Sets *dp* to an upper bound for `P'_n(x)` and *dp2* to an upper - # bound for `P''_n(x)` given *x* assumed to represent a real - # number with `|x| \le 1`. The variable *x2sub1* must contain - # the precomputed value `1-x^2` (or `x^2-1`). This method is used - # internally to bound the propagated error for Legendre polynomials. - void arb_hypgeom_legendre_p_ui_zero(arb_t res, arb_t res_prime, ulong n, const arb_t x, slong K, slong prec) noexcept void arb_hypgeom_legendre_p_ui_one(arb_t res, arb_t res_prime, ulong n, const arb_t x, slong K, slong prec) noexcept void arb_hypgeom_legendre_p_ui_asymp(arb_t res, arb_t res_prime, ulong n, const arb_t x, slong K, slong prec) noexcept void arb_hypgeom_legendre_p_ui_rec(arb_t res, arb_t res_prime, ulong n, const arb_t x, slong prec) noexcept void arb_hypgeom_legendre_p_ui(arb_t res, arb_t res_prime, ulong n, const arb_t x, slong prec) noexcept - # Evaluates the ordinary Legendre polynomial `P_n(x)`. If *res_prime* is - # non-NULL, simultaneously evaluates the derivative `P'_n(x)`. - # The overall algorithm is described in [JM2018]_. - # The versions *zero*, *one* respectively use the hypergeometric series - # expansions at `x = 0` and `x = 1` while the *asymp* version uses an - # asymptotic series on `(-1,1)` intended for large *n*. The parameter *K* - # specifies the exact number of expansion terms to use (if the series - # expansion truncated at this point does not give the exact polynomial, - # an error bound is computed automatically). - # The asymptotic expansion with error bounds is given in [Bog2012]_. - # The *rec* version uses the forward recurrence implemented using - # fixed-point arithmetic; it is only intended for the interval `(-1,1)`, - # moderate *n* and modest precision. - # The default version attempts to choose the best algorithm automatically. - # It also estimates the amount of cancellation in the hypergeometric series - # and increases the working precision to compensate, bounding the - # propagated error using derivative bounds. - void arb_hypgeom_legendre_p_ui_root(arb_t res, arb_t weight, ulong n, ulong k, slong prec) noexcept - # Sets *res* to the *k*-th root of the Legendre polynomial `P_n(x)`. - # We index the roots in decreasing order - # .. math :: - # 1 > x_0 > x_1 > \ldots > x_{n-1} > -1 - # (which corresponds to ordering the roots of `P_n(\cos(\theta))` - # in order of increasing `\theta`). - # If *weight* is non-NULL, it is set to the weight corresponding - # to the node `x_k` for Gaussian quadrature on `[-1,1]`. - # Note that only `\lceil n / 2 \rceil` roots need to be computed, - # since the remaining roots are given by `x_k = -x_{n-1-k}`. - # We compute an enclosing interval using an asymptotic approximation followed - # by some number of Newton iterations, using the error bounds given - # in [Pet1999]_. If very high precision is requested, the root is - # subsequently refined using interval Newton steps with doubling working - # precision. - void arb_hypgeom_dilog(arb_t res, const arb_t z, slong prec) noexcept - # Computes the dilogarithm `\operatorname{Li}_2(z)`. - void arb_hypgeom_sum_fmpq_arb_forward(arb_t res, const fmpq * a, slong alen, const fmpq * b, slong blen, const arb_t z, int reciprocal, slong N, slong prec) noexcept void arb_hypgeom_sum_fmpq_arb_rs(arb_t res, const fmpq * a, slong alen, const fmpq * b, slong blen, const arb_t z, int reciprocal, slong N, slong prec) noexcept void arb_hypgeom_sum_fmpq_arb(arb_t res, const fmpq * a, slong alen, const fmpq * b, slong blen, const arb_t z, int reciprocal, slong N, slong prec) noexcept - # Sets *res* to the finite hypergeometric sum - # `\sum_{n=0}^{N-1} (\textbf{a})_n z^n / (\textbf{b})_n` - # where `\textbf{x}_n = (x_1)_n (x_2)_n \cdots`, - # given vectors of rational parameters *a* (of length *alen*) - # and *b* (of length *blen*). - # If *reciprocal* is set, replace `z` by `1 / z`. - # The *forward* version uses the forward recurrence, optimized by - # delaying divisions, the *rs* version - # uses rectangular splitting, and the default version uses - # an automatic algorithm choice. - void arb_hypgeom_sum_fmpq_imag_arb_forward(arb_t res1, arb_t res2, const fmpq * a, slong alen, const fmpq * b, slong blen, const arb_t z, int reciprocal, slong N, slong prec) noexcept void arb_hypgeom_sum_fmpq_imag_arb_rs(arb_t res1, arb_t res2, const fmpq * a, slong alen, const fmpq * b, slong blen, const arb_t z, int reciprocal, slong N, slong prec) noexcept void arb_hypgeom_sum_fmpq_imag_arb_bs(arb_t res1, arb_t res2, const fmpq * a, slong alen, const fmpq * b, slong blen, const arb_t z, int reciprocal, slong N, slong prec) noexcept void arb_hypgeom_sum_fmpq_imag_arb(arb_t res1, arb_t res2, const fmpq * a, slong alen, const fmpq * b, slong blen, const arb_t z, int reciprocal, slong N, slong prec) noexcept - # Sets *res1* and *res2* to the real and imaginary part of the - # finite hypergeometric sum - # `\sum_{n=0}^{N-1} (\textbf{a})_n (i z)^n / (\textbf{b})_n`. - # If *reciprocal* is set, replace `z` by `1 / z`. diff --git a/src/sage/libs/flint/arb_macros.pxd b/src/sage/libs/flint/arb_macros.pxd index 02495200356..46f9a516434 100644 --- a/src/sage/libs/flint/arb_macros.pxd +++ b/src/sage/libs/flint/arb_macros.pxd @@ -1,11 +1,8 @@ # Macros from arb.h -# See https://github.com/flintlib/flint/issues/152 +# See https://github.com/flintlib/flint/issues/1529 from .types cimport * cdef extern from "flint_wrap.h": arf_ptr arb_midref(arb_t x) - # Macro giving a pointer to the midpoint of x - mag_ptr arb_radref(arb_t x) - # Macro giving a pointer to the radius of x diff --git a/src/sage/libs/flint/arb_mat.pxd b/src/sage/libs/flint/arb_mat.pxd index fd13b5105a3..133a4bac57f 100644 --- a/src/sage/libs/flint/arb_mat.pxd +++ b/src/sage/libs/flint/arb_mat.pxd @@ -2,7 +2,9 @@ # distutils: depends = flint/arb_mat.h ################################################################################ -# This file is auto-generated. Do not modify by hand +# This file is auto-generated by the script +# SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py. +# Do not modify by hand! Fix and rerun the script instead. ################################################################################ from libc.stdio cimport FILE @@ -11,539 +13,126 @@ from sage.libs.mpfr.types cimport * from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void arb_mat_init(arb_mat_t mat, slong r, slong c) noexcept - # Initializes the matrix, setting it to the zero matrix with *r* rows - # and *c* columns. - void arb_mat_clear(arb_mat_t mat) noexcept - # Clears the matrix, deallocating all entries. - slong arb_mat_allocated_bytes(const arb_mat_t x) noexcept - # Returns the total number of bytes heap-allocated internally by this object. - # The count excludes the size of the structure itself. Add - # ``sizeof(arb_mat_struct)`` to get the size of the object as a whole. - void arb_mat_window_init(arb_mat_t window, const arb_mat_t mat, slong r1, slong c1, slong r2, slong c2) noexcept - # Initializes *window* to a window matrix into the submatrix of *mat* - # starting at the corner at row *r1* and column *c1* (inclusive) and ending - # at row *r2* and column *c2* (exclusive). - void arb_mat_window_clear(arb_mat_t window) noexcept - # Frees the window matrix. - void arb_mat_set(arb_mat_t dest, const arb_mat_t src) noexcept - void arb_mat_set_fmpz_mat(arb_mat_t dest, const fmpz_mat_t src) noexcept - void arb_mat_set_round_fmpz_mat(arb_mat_t dest, const fmpz_mat_t src, slong prec) noexcept - void arb_mat_set_fmpq_mat(arb_mat_t dest, const fmpq_mat_t src, slong prec) noexcept - # Sets *dest* to *src*. The operands must have identical dimensions. - void arb_mat_randtest(arb_mat_t mat, flint_rand_t state, slong prec, slong mag_bits) noexcept - # Sets *mat* to a random matrix with up to *prec* bits of precision - # and with exponents of width up to *mag_bits*. - + void arb_mat_randtest_cho(arb_mat_t mat, flint_rand_t state, slong prec, slong mag_bits) noexcept + void arb_mat_randtest_spd(arb_mat_t mat, flint_rand_t state, slong prec, slong mag_bits) noexcept void arb_mat_printd(const arb_mat_t mat, slong digits) noexcept - # Prints each entry in the matrix with the specified number of decimal digits. - void arb_mat_fprintd(FILE * file, const arb_mat_t mat, slong digits) noexcept - # Prints each entry in the matrix with the specified number of decimal - # digits to the stream *file*. - bint arb_mat_equal(const arb_mat_t mat1, const arb_mat_t mat2) noexcept - # Returns whether the matrices have the same dimensions - # and identical intervals as entries. - bint arb_mat_overlaps(const arb_mat_t mat1, const arb_mat_t mat2) noexcept - # Returns whether the matrices have the same dimensions - # and each entry in *mat1* overlaps with the corresponding entry in *mat2*. - bint arb_mat_contains(const arb_mat_t mat1, const arb_mat_t mat2) noexcept - bint arb_mat_contains_fmpz_mat(const arb_mat_t mat1, const fmpz_mat_t mat2) noexcept - bint arb_mat_contains_fmpq_mat(const arb_mat_t mat1, const fmpq_mat_t mat2) noexcept - # Returns whether the matrices have the same dimensions and each entry - # in *mat2* is contained in the corresponding entry in *mat1*. - bint arb_mat_eq(const arb_mat_t mat1, const arb_mat_t mat2) noexcept - # Returns whether *mat1* and *mat2* certainly represent the same matrix. - bint arb_mat_ne(const arb_mat_t mat1, const arb_mat_t mat2) noexcept - # Returns whether *mat1* and *mat2* certainly do not represent the same matrix. - bint arb_mat_is_empty(const arb_mat_t mat) noexcept - # Returns whether the number of rows or the number of columns in *mat* is zero. - bint arb_mat_is_square(const arb_mat_t mat) noexcept - # Returns whether the number of rows is equal to the number of columns in *mat*. - bint arb_mat_is_exact(const arb_mat_t mat) noexcept - # Returns whether all entries in *mat* have zero radius. - bint arb_mat_is_zero(const arb_mat_t mat) noexcept - # Returns whether all entries in *mat* are exactly zero. - bint arb_mat_is_finite(const arb_mat_t mat) noexcept - # Returns whether all entries in *mat* are finite. - bint arb_mat_is_triu(const arb_mat_t mat) noexcept - # Returns whether *mat* is upper triangular; that is, all entries - # below the main diagonal are exactly zero. - bint arb_mat_is_tril(const arb_mat_t mat) noexcept - # Returns whether *mat* is lower triangular; that is, all entries - # above the main diagonal are exactly zero. - bint arb_mat_is_diag(const arb_mat_t mat) noexcept - # Returns whether *mat* is a diagonal matrix; that is, all entries - # off the main diagonal are exactly zero. - void arb_mat_zero(arb_mat_t mat) noexcept - # Sets all entries in mat to zero. - void arb_mat_one(arb_mat_t mat) noexcept - # Sets the entries on the main diagonal to ones, - # and all other entries to zero. - void arb_mat_ones(arb_mat_t mat) noexcept - # Sets all entries in the matrix to ones. - void arb_mat_indeterminate(arb_mat_t mat) noexcept - # Sets all entries in the matrix to indeterminate (NaN). - void arb_mat_hilbert(arb_mat_t mat, slong prec) noexcept - # Sets *mat* to the Hilbert matrix, which has entries `A_{j,k} = 1/(j+k+1)`. - void arb_mat_pascal(arb_mat_t mat, int triangular, slong prec) noexcept - # Sets *mat* to a Pascal matrix, whose entries are binomial coefficients. - # If *triangular* is 0, constructs a full symmetric matrix - # with the rows of Pascal's triangle as successive antidiagonals. - # If *triangular* is 1, constructs the upper triangular matrix with - # the rows of Pascal's triangle as columns, and if *triangular* is -1, - # constructs the lower triangular matrix with the rows of Pascal's - # triangle as rows. - # The entries are computed using recurrence relations. - # When the dimensions get large, some precision loss is possible; in that - # case, the user may wish to create the matrix at slightly higher precision - # and then round it to the final precision. - void arb_mat_stirling(arb_mat_t mat, int kind, slong prec) noexcept - # Sets *mat* to a Stirling matrix, whose entries are Stirling numbers. - # If *kind* is 0, the entries are set to the unsigned Stirling numbers - # of the first kind. If *kind* is 1, the entries are set to the signed - # Stirling numbers of the first kind. If *kind* is 2, the entries are - # set to the Stirling numbers of the second kind. - # The entries are computed using recurrence relations. - # When the dimensions get large, some precision loss is possible; in that - # case, the user may wish to create the matrix at slightly higher precision - # and then round it to the final precision. - void arb_mat_dct(arb_mat_t mat, int type, slong prec) noexcept - # Sets *mat* to the DCT (discrete cosine transform) matrix of order *n* - # where *n* is the smallest dimension of *mat* (if *mat* is not square, - # the matrix is extended periodically along the larger dimension). - # There are many different conventions for defining DCT matrices; here, - # we use the normalized "DCT-II" transform matrix - # .. math :: - # A_{j,k} = \sqrt{\frac{2}{n}} \cos\left(\frac{\pi j}{n} \left(k+\frac{1}{2}\right)\right) - # which satisfies `A^{-1} = A^T`. - # The *type* parameter is currently ignored and should be set to 0. - # In the future, it might be used to select a different convention. - void arb_mat_transpose(arb_mat_t dest, const arb_mat_t src) noexcept - # Sets *dest* to the exact transpose *src*. The operands must have - # compatible dimensions. Aliasing is allowed. - void arb_mat_bound_inf_norm(mag_t b, const arb_mat_t A) noexcept - # Sets *b* to an upper bound for the infinity norm (i.e. the largest - # absolute value row sum) of *A*. - void arb_mat_frobenius_norm(arb_t res, const arb_mat_t A, slong prec) noexcept - # Sets *res* to the Frobenius norm (i.e. the square root of the sum - # of squares of entries) of *A*. - void arb_mat_bound_frobenius_norm(mag_t res, const arb_mat_t A) noexcept - # Sets *res* to an upper bound for the Frobenius norm of *A*. - void arb_mat_neg(arb_mat_t dest, const arb_mat_t src) noexcept - # Sets *dest* to the exact negation of *src*. The operands must have - # the same dimensions. - void arb_mat_add(arb_mat_t res, const arb_mat_t mat1, const arb_mat_t mat2, slong prec) noexcept - # Sets res to the sum of *mat1* and *mat2*. The operands must have the same dimensions. - void arb_mat_sub(arb_mat_t res, const arb_mat_t mat1, const arb_mat_t mat2, slong prec) noexcept - # Sets *res* to the difference of *mat1* and *mat2*. The operands must have - # the same dimensions. - void arb_mat_mul_classical(arb_mat_t C, const arb_mat_t A, const arb_mat_t B, slong prec) noexcept - void arb_mat_mul_threaded(arb_mat_t C, const arb_mat_t A, const arb_mat_t B, slong prec) noexcept - void arb_mat_mul_block(arb_mat_t C, const arb_mat_t A, const arb_mat_t B, slong prec) noexcept - void arb_mat_mul(arb_mat_t res, const arb_mat_t mat1, const arb_mat_t mat2, slong prec) noexcept - # Sets *res* to the matrix product of *mat1* and *mat2*. The operands must have - # compatible dimensions for matrix multiplication. - # The *classical* version performs matrix multiplication in the trivial way. - # The *block* version decomposes the input matrices into one or several - # blocks of uniformly scaled matrices and multiplies - # large blocks via *fmpz_mat_mul*. It also invokes - # :func:`_arb_mat_addmul_rad_mag_fast` for the radius matrix multiplications. - # The *threaded* version performs classical multiplication but splits the - # computation over the number of threads returned by *flint_get_num_threads()*. - # The default version chooses an algorithm automatically. - void arb_mat_mul_entrywise(arb_mat_t C, const arb_mat_t A, const arb_mat_t B, slong prec) noexcept - # Sets *C* to the entrywise product of *A* and *B*. - # The operands must have the same dimensions. - void arb_mat_sqr_classical(arb_mat_t B, const arb_mat_t A, slong prec) noexcept - void arb_mat_sqr(arb_mat_t res, const arb_mat_t mat, slong prec) noexcept - void arb_mat_pow_ui(arb_mat_t res, const arb_mat_t mat, ulong exp, slong prec) noexcept - # Sets *res* to *mat* raised to the power *exp*. Requires that *mat* - # is a square matrix. - void _arb_mat_addmul_rad_mag_fast(arb_mat_t C, mag_srcptr A, mag_srcptr B, slong ar, slong ac, slong bc) noexcept - # Helper function for matrix multiplication. - # Adds to the radii of *C* the matrix product of the matrices represented - # by *A* and *B*, where *A* is a linear array of coefficients in row-major - # order and *B* is a linear array of coefficients in column-major order. - # This function assumes that all exponents are small and is unsafe - # for general use. - void arb_mat_approx_mul(arb_mat_t res, const arb_mat_t mat1, const arb_mat_t mat2, slong prec) noexcept - # Approximate matrix multiplication. The input radii are ignored and - # the output matrix is set to an approximate floating-point result. - # The radii in the output matrix will *not* necessarily be zeroed. - void arb_mat_scalar_mul_2exp_si(arb_mat_t B, const arb_mat_t A, slong c) noexcept - # Sets *B* to *A* multiplied by `2^c`. - void arb_mat_scalar_addmul_si(arb_mat_t B, const arb_mat_t A, slong c, slong prec) noexcept - void arb_mat_scalar_addmul_fmpz(arb_mat_t B, const arb_mat_t A, const fmpz_t c, slong prec) noexcept - void arb_mat_scalar_addmul_arb(arb_mat_t B, const arb_mat_t A, const arb_t c, slong prec) noexcept - # Sets *B* to `B + A \times c`. - void arb_mat_scalar_mul_si(arb_mat_t B, const arb_mat_t A, slong c, slong prec) noexcept - void arb_mat_scalar_mul_fmpz(arb_mat_t B, const arb_mat_t A, const fmpz_t c, slong prec) noexcept - void arb_mat_scalar_mul_arb(arb_mat_t B, const arb_mat_t A, const arb_t c, slong prec) noexcept - # Sets *B* to `A \times c`. - void arb_mat_scalar_div_si(arb_mat_t B, const arb_mat_t A, slong c, slong prec) noexcept - void arb_mat_scalar_div_fmpz(arb_mat_t B, const arb_mat_t A, const fmpz_t c, slong prec) noexcept - void arb_mat_scalar_div_arb(arb_mat_t B, const arb_mat_t A, const arb_t c, slong prec) noexcept - # Sets *B* to `A / c`. - + void _arb_mat_vector_mul_row(arb_ptr res, arb_srcptr v, const arb_mat_t A, slong prec) noexcept + void _arb_mat_vector_mul_col(arb_ptr res, const arb_mat_t A, arb_srcptr v, slong prec) noexcept + void arb_mat_vector_mul_row(arb_ptr res, arb_srcptr v, const arb_mat_t A, slong prec) noexcept + void arb_mat_vector_mul_col(arb_ptr res, const arb_mat_t A, arb_srcptr v, slong prec) noexcept int arb_mat_lu_classical(slong * perm, arb_mat_t LU, const arb_mat_t A, slong prec) noexcept - int arb_mat_lu_recursive(slong * perm, arb_mat_t LU, const arb_mat_t A, slong prec) noexcept - int arb_mat_lu(slong * perm, arb_mat_t LU, const arb_mat_t A, slong prec) noexcept - # Given an `n \times n` matrix `A`, computes an LU decomposition `PLU = A` - # using Gaussian elimination with partial pivoting. - # The input and output matrices can be the same, performing the - # decomposition in-place. - # Entry `i` in the permutation vector perm is set to the row index in - # the input matrix corresponding to row `i` in the output matrix. - # The algorithm succeeds and returns nonzero if it can find `n` invertible - # (i.e. not containing zero) pivot entries. This guarantees that the matrix - # is invertible. - # The algorithm fails and returns zero, leaving the entries in `P` and `LU` - # undefined, if it cannot find `n` invertible pivot elements. - # In this case, either the matrix is singular, the input matrix was - # computed to insufficient precision, or the LU decomposition was - # attempted at insufficient precision. - # The *classical* version uses Gaussian elimination directly while - # the *recursive* version performs the computation in a block recursive - # way to benefit from fast matrix multiplication. The default version - # chooses an algorithm automatically. - void arb_mat_solve_tril_classical(arb_mat_t X, const arb_mat_t L, const arb_mat_t B, int unit, slong prec) noexcept - void arb_mat_solve_tril_recursive(arb_mat_t X, const arb_mat_t L, const arb_mat_t B, int unit, slong prec) noexcept - void arb_mat_solve_tril(arb_mat_t X, const arb_mat_t L, const arb_mat_t B, int unit, slong prec) noexcept - void arb_mat_solve_triu_classical(arb_mat_t X, const arb_mat_t U, const arb_mat_t B, int unit, slong prec) noexcept - void arb_mat_solve_triu_recursive(arb_mat_t X, const arb_mat_t U, const arb_mat_t B, int unit, slong prec) noexcept - void arb_mat_solve_triu(arb_mat_t X, const arb_mat_t U, const arb_mat_t B, int unit, slong prec) noexcept - # Solves the lower triangular system `LX = B` or the upper triangular system - # `UX = B`, respectively. If *unit* is set, the main diagonal of *L* or *U* - # is taken to consist of all ones, and in that case the actual entries on - # the diagonal are not read at all and can contain other data. - # The *classical* versions perform the computations iteratively while the - # *recursive* versions perform the computations in a block recursive - # way to benefit from fast matrix multiplication. The default versions - # choose an algorithm automatically. - void arb_mat_solve_lu_precomp(arb_mat_t X, const slong * perm, const arb_mat_t LU, const arb_mat_t B, slong prec) noexcept - # Solves `AX = B` given the precomputed nonsingular LU decomposition `A = PLU`. - # The matrices `X` and `B` are allowed to be aliased with each other, - # but `X` is not allowed to be aliased with `LU`. - int arb_mat_solve(arb_mat_t X, const arb_mat_t A, const arb_mat_t B, slong prec) noexcept - int arb_mat_solve_lu(arb_mat_t X, const arb_mat_t A, const arb_mat_t B, slong prec) noexcept - int arb_mat_solve_precond(arb_mat_t X, const arb_mat_t A, const arb_mat_t B, slong prec) noexcept - # Solves `AX = B` where `A` is a nonsingular `n \times n` matrix - # and `X` and `B` are `n \times m` matrices. - # If `m > 0` and `A` cannot be inverted numerically (indicating either that - # `A` is singular or that the precision is insufficient), the values in the - # output matrix are left undefined and zero is returned. A nonzero return - # value guarantees that `A` is invertible and that the exact solution - # matrix is contained in the output. - # Three algorithms are provided: - # * The *lu* version performs LU decomposition directly in ball arithmetic. - # This is fast, but the bounds typically blow up exponentially with *n*, - # even if the system is well-conditioned. This algorithm is usually - # the best choice at very high precision. - # * The *precond* version computes an approximate inverse to precondition - # the system [HS1967]_. This is usually several times slower than direct LU - # decomposition, but the bounds do not blow up with *n* if the system is - # well-conditioned. This algorithm is usually - # the best choice for large systems at low to moderate precision. - # * The default version selects between *lu* and *precomp* automatically. - # The automatic choice should be reasonable most of the time, but users - # may benefit from trying either *lu* or *precond* in specific applications. - # For example, the *lu* solver often performs better for ill-conditioned - # systems where use of very high precision is unavoidable. - int arb_mat_solve_preapprox(arb_mat_t X, const arb_mat_t A, const arb_mat_t B, const arb_mat_t R, const arb_mat_t T, slong prec) noexcept - # Solves `AX = B` where `A` is a nonsingular `n \times n` matrix - # and `X` and `B` are `n \times m` matrices, given an approximation - # `R` of the matrix inverse of `A`, and given the approximation `T` - # of the solution `X`. - # If `m > 0` and `A` cannot be inverted numerically (indicating either that - # `A` is singular or that the precision is insufficient, or that `R` is - # not a close enough approximation of the inverse of `A`), the values in the - # output matrix are left undefined and zero is returned. A nonzero return - # value guarantees that `A` is invertible and that the exact solution - # matrix is contained in the output. - int arb_mat_inv(arb_mat_t X, const arb_mat_t A, slong prec) noexcept - # Sets `X = A^{-1}` where `A` is a square matrix, computed by solving - # the system `AX = I`. - # If `A` cannot be inverted numerically (indicating either that - # `A` is singular or that the precision is insufficient), the values in the - # output matrix are left undefined and zero is returned. - # A nonzero return value guarantees that the matrix is invertible - # and that the exact inverse is contained in the output. - void arb_mat_det_lu(arb_t det, const arb_mat_t A, slong prec) noexcept - void arb_mat_det_precond(arb_t det, const arb_mat_t A, slong prec) noexcept - void arb_mat_det(arb_t det, const arb_mat_t A, slong prec) noexcept - # Sets *det* to the determinant of the matrix *A*. - # The *lu* version uses Gaussian elimination with partial pivoting. If at - # some point an invertible pivot element cannot be found, the elimination is - # stopped and the magnitude of the determinant of the remaining submatrix - # is bounded using Hadamard's inequality. - # The *precond* version computes an approximate LU factorization of *A* - # and multiplies by the inverse *L* and *U* martices as preconditioners - # to obtain a matrix close to the identity matrix [Rum2010]_. An enclosure - # for this determinant is computed using Gershgorin circles. This is about - # four times slower than direct Gaussian elimination, but much more - # numerically stable. - # The default version automatically selects between the *lu* and *precond* - # versions and additionally handles small or triangular matrices - # by direct formulas. - void arb_mat_approx_solve_triu(arb_mat_t X, const arb_mat_t U, const arb_mat_t B, int unit, slong prec) noexcept - void arb_mat_approx_solve_tril(arb_mat_t X, const arb_mat_t L, const arb_mat_t B, int unit, slong prec) noexcept - int arb_mat_approx_lu(slong * P, arb_mat_t LU, const arb_mat_t A, slong prec) noexcept - void arb_mat_approx_solve_lu_precomp(arb_mat_t X, const slong * perm, const arb_mat_t A, const arb_mat_t B, slong prec) noexcept - int arb_mat_approx_solve(arb_mat_t X, const arb_mat_t A, const arb_mat_t B, slong prec) noexcept - int arb_mat_approx_inv(arb_mat_t X, const arb_mat_t A, slong prec) noexcept - # These methods perform approximate solving *without any error control*. - # The radii in the input matrices are ignored, the computations are done - # numerically with floating-point arithmetic (using ordinary - # Gaussian elimination and triangular solving, accelerated through - # the use of block recursive strategies for large matrices), and the - # output matrices are set to the approximate floating-point results with - # zeroed error bounds. - # Approximate solutions are useful for computing preconditioning matrices - # for certified solutions. Some users may also find these methods useful - # for doing ordinary numerical linear algebra in applications where - # error bounds are not needed. - int _arb_mat_cholesky_banachiewicz(arb_mat_t A, slong prec) noexcept - int arb_mat_cho(arb_mat_t L, const arb_mat_t A, slong prec) noexcept - # Computes the Cholesky decomposition of *A*, returning nonzero iff - # the symmetric matrix defined by the lower triangular part of *A* - # is certainly positive definite. - # If a nonzero value is returned, then *L* is set to the lower triangular - # matrix such that `A = L * L^T`. - # If zero is returned, then either the matrix is not symmetric positive - # definite, the input matrix was computed to insufficient precision, - # or the decomposition was attempted at insufficient precision. - # The underscore method computes *L* from *A* in-place, leaving the - # strict upper triangular region undefined. - void arb_mat_solve_cho_precomp(arb_mat_t X, const arb_mat_t L, const arb_mat_t B, slong prec) noexcept - # Solves `AX = B` given the precomputed Cholesky decomposition `A = L L^T`. - # The matrices *X* and *B* are allowed to be aliased with each other, - # but *X* is not allowed to be aliased with *L*. - int arb_mat_spd_solve(arb_mat_t X, const arb_mat_t A, const arb_mat_t B, slong prec) noexcept - # Solves `AX = B` where *A* is a symmetric positive definite matrix - # and *X* and *B* are `n \times m` matrices, using Cholesky decomposition. - # If `m > 0` and *A* cannot be factored using Cholesky decomposition - # (indicating either that *A* is not symmetric positive definite or that - # the precision is insufficient), the values in the - # output matrix are left undefined and zero is returned. A nonzero return - # value guarantees that the symmetric matrix defined through the lower - # triangular part of *A* is invertible and that the exact solution matrix - # is contained in the output. - void arb_mat_inv_cho_precomp(arb_mat_t X, const arb_mat_t L, slong prec) noexcept - # Sets `X = A^{-1}` where `A` is a symmetric positive definite matrix - # whose Cholesky decomposition *L* has been computed with - # :func:`arb_mat_cho`. - # The inverse is calculated using the method of [Kri2013]_ which is more - # efficient than solving `AX = I` with :func:`arb_mat_solve_cho_precomp`. - int arb_mat_spd_inv(arb_mat_t X, const arb_mat_t A, slong prec) noexcept - # Sets `X = A^{-1}` where *A* is a symmetric positive definite matrix. - # It is calculated using the method of [Kri2013]_ which computes fewer - # intermediate results than solving `AX = I` with :func:`arb_mat_spd_solve`. - # If *A* cannot be factored using Cholesky decomposition - # (indicating either that *A* is not symmetric positive definite or that - # the precision is insufficient), the values in the - # output matrix are left undefined and zero is returned. A nonzero return - # value guarantees that the symmetric matrix defined through the lower - # triangular part of *A* is invertible and that the exact inverse - # is contained in the output. - int _arb_mat_ldl_inplace(arb_mat_t A, slong prec) noexcept - int _arb_mat_ldl_golub_and_van_loan(arb_mat_t A, slong prec) noexcept - int arb_mat_ldl(arb_mat_t res, const arb_mat_t A, slong prec) noexcept - # Computes the `LDL^T` decomposition of *A*, returning nonzero iff - # the symmetric matrix defined by the lower triangular part of *A* - # is certainly positive definite. - # If a nonzero value is returned, then *res* is set to a lower triangular - # matrix that encodes the `L * D * L^T` decomposition of *A*. - # In particular, `L` is a lower triangular matrix with ones on its diagonal - # and whose strictly lower triangular region is the same as that of *res*. - # `D` is a diagonal matrix with the same diagonal as that of *res*. - # If zero is returned, then either the matrix is not symmetric positive - # definite, the input matrix was computed to insufficient precision, - # or the decomposition was attempted at insufficient precision. - # The underscore methods compute *res* from *A* in-place, leaving the - # strict upper triangular region undefined. - # The default method uses algorithm 4.1.2 from [GVL1996]_. - void arb_mat_solve_ldl_precomp(arb_mat_t X, const arb_mat_t L, const arb_mat_t B, slong prec) noexcept - # Solves `AX = B` given the precomputed `A = LDL^T` decomposition - # encoded by *L*. The matrices *X* and *B* are allowed to be aliased - # with each other, but *X* is not allowed to be aliased with *L*. - void arb_mat_inv_ldl_precomp(arb_mat_t X, const arb_mat_t L, slong prec) noexcept - # Sets `X = A^{-1}` where `A` is a symmetric positive definite matrix - # whose `LDL^T` decomposition encoded by *L* has been computed with - # :func:`arb_mat_ldl`. - # The inverse is calculated using the method of [Kri2013]_ which is more - # efficient than solving `AX = I` with :func:`arb_mat_solve_ldl_precomp`. - void _arb_mat_charpoly(arb_ptr poly, const arb_mat_t mat, slong prec) noexcept - void arb_mat_charpoly(arb_poly_t poly, const arb_mat_t mat, slong prec) noexcept - # Sets *poly* to the characteristic polynomial of *mat* which must be - # a square matrix. If the matrix has *n* rows, the underscore method - # requires space for `n + 1` output coefficients. - # Employs a division-free algorithm using `O(n^4)` operations. - void _arb_mat_companion(arb_mat_t mat, arb_srcptr poly, slong prec) noexcept - void arb_mat_companion(arb_mat_t mat, const arb_poly_t poly, slong prec) noexcept - # Sets the *n* by *n* matrix *mat* to the companion matrix of the polynomial - # *poly* which must have degree *n*. - # The underscore method reads `n + 1` input coefficients. - void arb_mat_exp_taylor_sum(arb_mat_t S, const arb_mat_t A, slong N, slong prec) noexcept - # Sets *S* to the truncated exponential Taylor series `S = \sum_{k=0}^{N-1} A^k / k!`. - # Uses rectangular splitting to compute the sum using `O(\sqrt{N})` - # matrix multiplications. The recurrence relation for factorials - # is used to get scalars that are small integers instead of full - # factorials. As in [Joh2014b]_, all divisions are postponed to - # the end by computing partial factorials of length `O(\sqrt{N})`. - # The scalars could be reduced by doing more divisions, but this - # appears to be slower in most cases. - void arb_mat_exp(arb_mat_t B, const arb_mat_t A, slong prec) noexcept - # Sets *B* to the exponential of the matrix *A*, defined by the Taylor series - # .. math :: - # \exp(A) = \sum_{k=0}^{\infty} \frac{A^k}{k!}. - # The function is evaluated as `\exp(A/2^r)^{2^r}`, where `r` is chosen - # to give rapid convergence. - # The elementwise error when truncating the Taylor series after *N* - # terms is bounded by the error in the infinity norm, for which we have - # .. math :: - # \left\|\exp(2^{-r}A) - \sum_{k=0}^{N-1} - # \frac{\left(2^{-r} A\right)^k}{k!} \right\|_{\infty} = - # \left\|\sum_{k=N}^{\infty} \frac{\left(2^{-r} A\right)^k}{k!}\right\|_{\infty} \le - # \sum_{k=N}^{\infty} \frac{(2^{-r} \|A\|_{\infty})^k}{k!}. - # We bound the sum on the right using :func:`mag_exp_tail`. - # Truncation error is not added to entries whose values are determined - # by the sparsity structure of `A`. - void arb_mat_trace(arb_t trace, const arb_mat_t mat, slong prec) noexcept - # Sets *trace* to the trace of the matrix, i.e. the sum of entries on the - # main diagonal of *mat*. The matrix is required to be square. - void _arb_mat_diag_prod(arb_t res, const arb_mat_t mat, slong a, slong b, slong prec) noexcept - void arb_mat_diag_prod(arb_t res, const arb_mat_t mat, slong prec) noexcept - # Sets *res* to the product of the entries on the main diagonal of *mat*. - # The underscore method computes the product of the entries between - # index *a* inclusive and *b* exclusive (the indices must be in range). - void arb_mat_entrywise_is_zero(fmpz_mat_t dest, const arb_mat_t src) noexcept - # Sets each entry of *dest* to indicate whether the corresponding - # entry of *src* is certainly zero. - # If the entry of *src* at row `i` and column `j` is zero according to - # :func:`arb_is_zero` then the entry of *dest* at that row and column - # is set to one, otherwise that entry of *dest* is set to zero. - void arb_mat_entrywise_not_is_zero(fmpz_mat_t dest, const arb_mat_t src) noexcept - # Sets each entry of *dest* to indicate whether the corresponding - # entry of *src* is not certainly zero. - # This the complement of :func:`arb_mat_entrywise_is_zero`. - slong arb_mat_count_is_zero(const arb_mat_t mat) noexcept - # Returns the number of entries of *mat* that are certainly zero - # according to :func:`arb_is_zero`. - slong arb_mat_count_not_is_zero(const arb_mat_t mat) noexcept - # Returns the number of entries of *mat* that are not certainly zero. - void arb_mat_get_mid(arb_mat_t B, const arb_mat_t A) noexcept - # Sets the entries of *B* to the exact midpoints of the entries of *A*. - void arb_mat_add_error_mag(arb_mat_t mat, const mag_t err) noexcept - # Adds *err* in-place to the radii of the entries of *mat*. + int arb_mat_spd_get_fmpz_mat(fmpz_mat_t B, const arb_mat_t A, slong prec) noexcept + void arb_mat_spd_lll_reduce(fmpz_mat_t U, const arb_mat_t A, slong prec) noexcept + bint arb_mat_spd_is_lll_reduced(const arb_mat_t A, slong tol_exp, slong prec) noexcept from .arb_mat_macros cimport * diff --git a/src/sage/libs/flint/arb_mat_macros.pxd b/src/sage/libs/flint/arb_mat_macros.pxd index 99ba7bca0e4..c7bc5dfcad9 100644 --- a/src/sage/libs/flint/arb_mat_macros.pxd +++ b/src/sage/libs/flint/arb_mat_macros.pxd @@ -1,14 +1,9 @@ # Macros from arb_mat.h -# See https://github.com/flintlib/flint/issues/152 +# See https://github.com/flintlib/flint/issues/1529 from .types cimport * cdef extern from "flint_wrap.h": arb_ptr arb_mat_entry(arb_mat_t mat, slong i, slong j) - # Macro giving a pointer to the entry at row *i* and column *j*. - slong arb_mat_nrows(arb_mat_t) - # Returns the number of rows of the matrix. - slong arb_mat_ncols(arb_mat_t) - # Returns the number of columns of the matrix. diff --git a/src/sage/libs/flint/arb_poly.pxd b/src/sage/libs/flint/arb_poly.pxd index 20f4fdc0d80..754dec0bf72 100644 --- a/src/sage/libs/flint/arb_poly.pxd +++ b/src/sage/libs/flint/arb_poly.pxd @@ -2,7 +2,9 @@ # distutils: depends = flint/arb_poly.h ################################################################################ -# This file is auto-generated. Do not modify by hand +# This file is auto-generated by the script +# SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py. +# Do not modify by hand! Fix and rerun the script instead. ################################################################################ from libc.stdio cimport FILE @@ -11,864 +13,223 @@ from sage.libs.mpfr.types cimport * from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void arb_poly_init(arb_poly_t poly) noexcept - # Initializes the polynomial for use, setting it to the zero polynomial. - void arb_poly_clear(arb_poly_t poly) noexcept - # Clears the polynomial, deallocating all coefficients and the - # coefficient array. - void arb_poly_fit_length(arb_poly_t poly, slong len) noexcept - # Makes sure that the coefficient array of the polynomial contains at - # least *len* initialized coefficients. - void _arb_poly_set_length(arb_poly_t poly, slong len) noexcept - # Directly changes the length of the polynomial, without allocating or - # deallocating coefficients. The value should not exceed the allocation length. - void _arb_poly_normalise(arb_poly_t poly) noexcept - # Strips any trailing coefficients which are identical to zero. - slong arb_poly_allocated_bytes(const arb_poly_t x) noexcept - # Returns the total number of bytes heap-allocated internally by this object. - # The count excludes the size of the structure itself. Add - # ``sizeof(arb_poly_struct)`` to get the size of the object as a whole. - slong arb_poly_length(const arb_poly_t poly) noexcept - # Returns the length of *poly*, i.e. zero if *poly* is - # identically zero, and otherwise one more than the index - # of the highest term that is not identically zero. - slong arb_poly_degree(const arb_poly_t poly) noexcept - # Returns the degree of *poly*, defined as one less than its length. - # Note that if one or several leading coefficients are balls - # containing zero, this value can be larger than the true - # degree of the exact polynomial represented by *poly*, - # so the return value of this function is effectively - # an upper bound. - bint arb_poly_is_zero(const arb_poly_t poly) noexcept - bint arb_poly_is_one(const arb_poly_t poly) noexcept - bint arb_poly_is_x(const arb_poly_t poly) noexcept - # Returns 1 if *poly* is exactly the polynomial 0, 1 or *x* - # respectively. Returns 0 otherwise. - void arb_poly_zero(arb_poly_t poly) noexcept - void arb_poly_one(arb_poly_t poly) noexcept - # Sets *poly* to the constant 0 respectively 1. - void arb_poly_set(arb_poly_t dest, const arb_poly_t src) noexcept - # Sets *dest* to a copy of *src*. - void arb_poly_set_round(arb_poly_t dest, const arb_poly_t src, slong prec) noexcept - # Sets *dest* to a copy of *src*, rounded to *prec* bits. - void arb_poly_set_trunc(arb_poly_t dest, const arb_poly_t src, slong n) noexcept - void arb_poly_set_trunc_round(arb_poly_t dest, const arb_poly_t src, slong n, slong prec) noexcept - # Sets *dest* to a copy of *src*, truncated to length *n* and rounded to *prec* bits. - void arb_poly_set_coeff_si(arb_poly_t poly, slong n, slong c) noexcept - void arb_poly_set_coeff_arb(arb_poly_t poly, slong n, const arb_t c) noexcept - # Sets the coefficient with index *n* in *poly* to the value *c*. - # We require that *n* is nonnegative. - void arb_poly_get_coeff_arb(arb_t v, const arb_poly_t poly, slong n) noexcept - # Sets *v* to the value of the coefficient with index *n* in *poly*. - # We require that *n* is nonnegative. - void _arb_poly_shift_right(arb_ptr res, arb_srcptr poly, slong len, slong n) noexcept - void arb_poly_shift_right(arb_poly_t res, const arb_poly_t poly, slong n) noexcept - # Sets *res* to *poly* divided by `x^n`, throwing away the lower coefficients. - # We require that *n* is nonnegative. - void _arb_poly_shift_left(arb_ptr res, arb_srcptr poly, slong len, slong n) noexcept - void arb_poly_shift_left(arb_poly_t res, const arb_poly_t poly, slong n) noexcept - # Sets *res* to *poly* multiplied by `x^n`. - # We require that *n* is nonnegative. - void arb_poly_truncate(arb_poly_t poly, slong n) noexcept - # Truncates *poly* to have length at most *n*, i.e. degree - # strictly smaller than *n*. We require that *n* is nonnegative. - slong arb_poly_valuation(const arb_poly_t poly) noexcept - # Returns the degree of the lowest term that is not exactly zero in *poly*. - # Returns -1 if *poly* is the zero polynomial. - void arb_poly_set_fmpz_poly(arb_poly_t poly, const fmpz_poly_t src, slong prec) noexcept - void arb_poly_set_fmpq_poly(arb_poly_t poly, const fmpq_poly_t src, slong prec) noexcept - void arb_poly_set_si(arb_poly_t poly, slong src) noexcept - # Sets *poly* to *src*, rounding the coefficients to *prec* bits. - void arb_poly_printd(const arb_poly_t poly, slong digits) noexcept - # Prints the polynomial as an array of coefficients, printing each - # coefficient using *arb_printd*. - void arb_poly_fprintd(FILE * file, const arb_poly_t poly, slong digits) noexcept - # Prints the polynomial as an array of coefficients to the stream *file*, - # printing each coefficient using *arb_fprintd*. - void arb_poly_randtest(arb_poly_t poly, flint_rand_t state, slong len, slong prec, slong mag_bits) noexcept - # Creates a random polynomial with length at most *len*. - bint arb_poly_contains(const arb_poly_t poly1, const arb_poly_t poly2) noexcept - bint arb_poly_contains_fmpz_poly(const arb_poly_t poly1, const fmpz_poly_t poly2) noexcept - bint arb_poly_contains_fmpq_poly(const arb_poly_t poly1, const fmpq_poly_t poly2) noexcept - # Returns nonzero iff *poly1* contains *poly2*. - bint arb_poly_equal(const arb_poly_t A, const arb_poly_t B) noexcept - # Returns nonzero iff *A* and *B* are equal as polynomial balls, i.e. all - # coefficients have equal midpoint and radius. - bint _arb_poly_overlaps(arb_srcptr poly1, slong len1, arb_srcptr poly2, slong len2) noexcept - bint arb_poly_overlaps(const arb_poly_t poly1, const arb_poly_t poly2) noexcept - # Returns nonzero iff *poly1* overlaps with *poly2*. The underscore - # function requires that *len1* is at least as large as *len2*. - int arb_poly_get_unique_fmpz_poly(fmpz_poly_t z, const arb_poly_t x) noexcept - # If *x* contains a unique integer polynomial, sets *z* to that value and returns - # nonzero. Otherwise (if *x* represents no integers or more than one integer), - # returns zero, possibly partially modifying *z*. - void _arb_poly_majorant(arb_ptr res, arb_srcptr poly, slong len, slong prec) noexcept - void arb_poly_majorant(arb_poly_t res, const arb_poly_t poly, slong prec) noexcept - # Sets *res* to an exact real polynomial whose coefficients are - # upper bounds for the absolute values of the coefficients in *poly*, - # rounded to *prec* bits. - void _arb_poly_add(arb_ptr C, arb_srcptr A, slong lenA, arb_srcptr B, slong lenB, slong prec) noexcept - # Sets *{C, max(lenA, lenB)}* to the sum of *{A, lenA}* and *{B, lenB}*. - # Allows aliasing of the input and output operands. - void arb_poly_add(arb_poly_t C, const arb_poly_t A, const arb_poly_t B, slong prec) noexcept - void arb_poly_add_si(arb_poly_t C, const arb_poly_t A, slong B, slong prec) noexcept - # Sets *C* to the sum of *A* and *B*. - void _arb_poly_sub(arb_ptr C, arb_srcptr A, slong lenA, arb_srcptr B, slong lenB, slong prec) noexcept - # Sets *{C, max(lenA, lenB)}* to the difference of *{A, lenA}* and *{B, lenB}*. - # Allows aliasing of the input and output operands. - void arb_poly_sub(arb_poly_t C, const arb_poly_t A, const arb_poly_t B, slong prec) noexcept - # Sets *C* to the difference of *A* and *B*. - void arb_poly_add_series(arb_poly_t C, const arb_poly_t A, const arb_poly_t B, slong len, slong prec) noexcept - # Sets *C* to the sum of *A* and *B*, truncated to length *len*. - void arb_poly_sub_series(arb_poly_t C, const arb_poly_t A, const arb_poly_t B, slong len, slong prec) noexcept - # Sets *C* to the difference of *A* and *B*, truncated to length *len*. - void arb_poly_neg(arb_poly_t C, const arb_poly_t A) noexcept - # Sets *C* to the negation of *A*. - void arb_poly_scalar_mul_2exp_si(arb_poly_t C, const arb_poly_t A, slong c) noexcept - # Sets *C* to *A* multiplied by `2^c`. - void arb_poly_scalar_mul(arb_poly_t C, const arb_poly_t A, const arb_t c, slong prec) noexcept - # Sets *C* to *A* multiplied by *c*. - void arb_poly_scalar_div(arb_poly_t C, const arb_poly_t A, const arb_t c, slong prec) noexcept - # Sets *C* to *A* divided by *c*. - void _arb_poly_mullow_classical(arb_ptr C, arb_srcptr A, slong lenA, arb_srcptr B, slong lenB, slong n, slong prec) noexcept - void _arb_poly_mullow_block(arb_ptr C, arb_srcptr A, slong lenA, arb_srcptr B, slong lenB, slong n, slong prec) noexcept - void _arb_poly_mullow(arb_ptr C, arb_srcptr A, slong lenA, arb_srcptr B, slong lenB, slong n, slong prec) noexcept - # Sets *{C, n}* to the product of *{A, lenA}* and *{B, lenB}*, truncated to - # length *n*. The output is not allowed to be aliased with either of the - # inputs. We require `\mathrm{lenA} \ge \mathrm{lenB} > 0`, - # `n > 0`, `\mathrm{lenA} + \mathrm{lenB} - 1 \ge n`. - # The *classical* version uses a plain loop. This has good numerical - # stability but gets slow for large *n*. - # The *block* version decomposes the product into several - # subproducts which are computed exactly over the integers. - # It first attempts to find an integer `c` - # such that `A(2^c x)` and `B(2^c x)` have slowly varying - # coefficients, to reduce the number of blocks. - # The scaling factor `c` is chosen in a quick, heuristic way - # by picking the first and last nonzero terms in each polynomial. - # If the indices in `A` are `a_2, a_1` and the log-2 magnitudes - # are `e_2, e_1`, and the indices in `B` are `b_2, b_1` - # with corresponding magnitudes `f_2, f_1`, then we compute - # `c` as the weighted arithmetic mean of the slopes, - # rounded to the nearest integer: - # .. math :: - # c = \left\lfloor - # \frac{(e_2 - e_1) + (f_2 + f_1)}{(a_2 - a_1) + (b_2 - b_1)} - # + \frac{1}{2} - # \right \rfloor. - # This strategy is used because it is simple. It is not optimal - # in all cases, but will typically give good performance when - # multiplying two power series with a similar decay rate. - # The default algorithm chooses the *classical* algorithm for - # short polynomials and the *block* algorithm for long polynomials. - # If the input pointers are identical (and the lengths are the same), - # they are assumed to represent the same polynomial, and its - # square is computed. - void arb_poly_mullow_classical(arb_poly_t C, const arb_poly_t A, const arb_poly_t B, slong n, slong prec) noexcept - void arb_poly_mullow_ztrunc(arb_poly_t C, const arb_poly_t A, const arb_poly_t B, slong n, slong prec) noexcept - void arb_poly_mullow_block(arb_poly_t C, const arb_poly_t A, const arb_poly_t B, slong n, slong prec) noexcept - void arb_poly_mullow(arb_poly_t C, const arb_poly_t A, const arb_poly_t B, slong n, slong prec) noexcept - # Sets *C* to the product of *A* and *B*, truncated to length *n*. - # If the same variable is passed for *A* and *B*, sets *C* to the square - # of *A* truncated to length *n*. - void _arb_poly_mul(arb_ptr C, arb_srcptr A, slong lenA, arb_srcptr B, slong lenB, slong prec) noexcept - # Sets *{C, lenA + lenB - 1}* to the product of *{A, lenA}* and *{B, lenB}*. - # The output is not allowed to be aliased with either of the - # inputs. We require `\mathrm{lenA} \ge \mathrm{lenB} > 0`. - # This function is implemented as a simple wrapper for :func:`_arb_poly_mullow`. - # If the input pointers are identical (and the lengths are the same), - # they are assumed to represent the same polynomial, and its - # square is computed. - void arb_poly_mul(arb_poly_t C, const arb_poly_t A, const arb_poly_t B, slong prec) noexcept - # Sets *C* to the product of *A* and *B*. - # If the same variable is passed for *A* and *B*, sets *C* to the - # square of *A*. - void _arb_poly_inv_series(arb_ptr Q, arb_srcptr A, slong Alen, slong len, slong prec) noexcept - # Sets *{Q, len}* to the power series inverse of *{A, Alen}*. Uses Newton iteration. - void arb_poly_inv_series(arb_poly_t Q, const arb_poly_t A, slong n, slong prec) noexcept - # Sets *Q* to the power series inverse of *A*, truncated to length *n*. - void _arb_poly_div_series(arb_ptr Q, arb_srcptr A, slong Alen, arb_srcptr B, slong Blen, slong n, slong prec) noexcept - # Sets *{Q, n}* to the power series quotient of *{A, Alen}* by *{B, Blen}*. - # Uses Newton iteration followed by multiplication. - void arb_poly_div_series(arb_poly_t Q, const arb_poly_t A, const arb_poly_t B, slong n, slong prec) noexcept - # Sets *Q* to the power series quotient *A* divided by *B*, truncated to length *n*. - void _arb_poly_div(arb_ptr Q, arb_srcptr A, slong lenA, arb_srcptr B, slong lenB, slong prec) noexcept - void _arb_poly_rem(arb_ptr R, arb_srcptr A, slong lenA, arb_srcptr B, slong lenB, slong prec) noexcept - void _arb_poly_divrem(arb_ptr Q, arb_ptr R, arb_srcptr A, slong lenA, arb_srcptr B, slong lenB, slong prec) noexcept - int arb_poly_divrem(arb_poly_t Q, arb_poly_t R, const arb_poly_t A, const arb_poly_t B, slong prec) noexcept - # Performs polynomial division with remainder, computing a quotient `Q` and - # a remainder `R` such that `A = BQ + R`. The implementation reverses the - # inputs and performs power series division. - # If the leading coefficient of `B` contains zero (or if `B` is identically - # zero), returns 0 indicating failure without modifying the outputs. - # Otherwise returns nonzero. - void _arb_poly_div_root(arb_ptr Q, arb_t R, arb_srcptr A, slong len, const arb_t c, slong prec) noexcept - # Divides `A` by the polynomial `x - c`, computing the quotient `Q` as well - # as the remainder `R = f(c)`. - void _arb_poly_taylor_shift(arb_ptr g, const arb_t c, slong n, slong prec) noexcept void arb_poly_taylor_shift(arb_poly_t g, const arb_poly_t f, const arb_t c, slong prec) noexcept - # Sets *g* to the Taylor shift `f(x+c)`. - # The underscore methods act in-place on *g* = *f* which has length *n*. - void _arb_poly_compose(arb_ptr res, arb_srcptr poly1, slong len1, arb_srcptr poly2, slong len2, slong prec) noexcept void arb_poly_compose(arb_poly_t res, const arb_poly_t poly1, const arb_poly_t poly2, slong prec) noexcept - # Sets *res* to the composition `h(x) = f(g(x))` where `f` is given by - # *poly1* and `g` is given by *poly2*. - # The underscore method does not support aliasing of the output - # with either input polynomial. - void _arb_poly_compose_series(arb_ptr res, arb_srcptr poly1, slong len1, arb_srcptr poly2, slong len2, slong n, slong prec) noexcept void arb_poly_compose_series(arb_poly_t res, const arb_poly_t poly1, const arb_poly_t poly2, slong n, slong prec) noexcept - # Sets *res* to the power series composition `h(x) = f(g(x))` truncated - # to order `O(x^n)` where `f` is given by *poly1* and `g` is given by *poly2*. - # Wraps :func:`_gr_poly_compose_series` which chooses automatically - # between various algorithms. - # We require that the constant term in `g(x)` is exactly zero. - # The underscore method does not support aliasing of the output - # with either input polynomial. - - void _arb_poly_revert_series_lagrange(arb_ptr h, arb_srcptr f, slong flen, slong n, slong prec) noexcept - - void arb_poly_revert_series_lagrange(arb_poly_t h, const arb_poly_t f, slong n, slong prec) noexcept - - void _arb_poly_revert_series_newton(arb_ptr h, arb_srcptr f, slong flen, slong n, slong prec) noexcept - - void arb_poly_revert_series_newton(arb_poly_t h, const arb_poly_t f, slong n, slong prec) noexcept - - void _arb_poly_revert_series_lagrange_fast(arb_ptr h, arb_srcptr f, slong flen, slong n, slong prec) noexcept - - void arb_poly_revert_series_lagrange_fast(arb_poly_t h, const arb_poly_t f, slong n, slong prec) noexcept - void _arb_poly_revert_series(arb_ptr h, arb_srcptr f, slong flen, slong n, slong prec) noexcept - void arb_poly_revert_series(arb_poly_t h, const arb_poly_t f, slong n, slong prec) noexcept - # Sets `h` to the power series reversion of `f`, i.e. the expansion - # of the compositional inverse function `f^{-1}(x)`, - # truncated to order `O(x^n)`, using respectively - # Lagrange inversion, Newton iteration, fast Lagrange inversion, - # and a default algorithm choice. - # We require that the constant term in `f` is exactly zero and that the - # linear term is nonzero. The underscore methods assume that *flen* - # is at least 2, and do not support aliasing. - void _arb_poly_evaluate_horner(arb_t y, arb_srcptr f, slong len, const arb_t x, slong prec) noexcept - void arb_poly_evaluate_horner(arb_t y, const arb_poly_t f, const arb_t x, slong prec) noexcept - void _arb_poly_evaluate_rectangular(arb_t y, arb_srcptr f, slong len, const arb_t x, slong prec) noexcept - void arb_poly_evaluate_rectangular(arb_t y, const arb_poly_t f, const arb_t x, slong prec) noexcept - void _arb_poly_evaluate(arb_t y, arb_srcptr f, slong len, const arb_t x, slong prec) noexcept - void arb_poly_evaluate(arb_t y, const arb_poly_t f, const arb_t x, slong prec) noexcept - # Sets `y = f(x)`, evaluated respectively using Horner's rule, - # rectangular splitting, and an automatic algorithm choice. - void _arb_poly_evaluate_acb_horner(acb_t y, arb_srcptr f, slong len, const acb_t x, slong prec) noexcept - void arb_poly_evaluate_acb_horner(acb_t y, const arb_poly_t f, const acb_t x, slong prec) noexcept - void _arb_poly_evaluate_acb_rectangular(acb_t y, arb_srcptr f, slong len, const acb_t x, slong prec) noexcept - void arb_poly_evaluate_acb_rectangular(acb_t y, const arb_poly_t f, const acb_t x, slong prec) noexcept - void _arb_poly_evaluate_acb(acb_t y, arb_srcptr f, slong len, const acb_t x, slong prec) noexcept - void arb_poly_evaluate_acb(acb_t y, const arb_poly_t f, const acb_t x, slong prec) noexcept - # Sets `y = f(x)` where `x` is a complex number, evaluating the - # polynomial respectively using Horner's rule, - # rectangular splitting, and an automatic algorithm choice. - void _arb_poly_evaluate2_horner(arb_t y, arb_t z, arb_srcptr f, slong len, const arb_t x, slong prec) noexcept - void arb_poly_evaluate2_horner(arb_t y, arb_t z, const arb_poly_t f, const arb_t x, slong prec) noexcept - void _arb_poly_evaluate2_rectangular(arb_t y, arb_t z, arb_srcptr f, slong len, const arb_t x, slong prec) noexcept - void arb_poly_evaluate2_rectangular(arb_t y, arb_t z, const arb_poly_t f, const arb_t x, slong prec) noexcept - void _arb_poly_evaluate2(arb_t y, arb_t z, arb_srcptr f, slong len, const arb_t x, slong prec) noexcept - void arb_poly_evaluate2(arb_t y, arb_t z, const arb_poly_t f, const arb_t x, slong prec) noexcept - # Sets `y = f(x), z = f'(x)`, evaluated respectively using Horner's rule, - # rectangular splitting, and an automatic algorithm choice. - # When Horner's rule is used, the only advantage of evaluating the - # function and its derivative simultaneously is that one does not have - # to generate the derivative polynomial explicitly. - # With the rectangular splitting algorithm, the powers can be reused, - # making simultaneous evaluation slightly faster. - void _arb_poly_evaluate2_acb_horner(acb_t y, acb_t z, arb_srcptr f, slong len, const acb_t x, slong prec) noexcept - void arb_poly_evaluate2_acb_horner(acb_t y, acb_t z, const arb_poly_t f, const acb_t x, slong prec) noexcept - void _arb_poly_evaluate2_acb_rectangular(acb_t y, acb_t z, arb_srcptr f, slong len, const acb_t x, slong prec) noexcept - void arb_poly_evaluate2_acb_rectangular(acb_t y, acb_t z, const arb_poly_t f, const acb_t x, slong prec) noexcept - void _arb_poly_evaluate2_acb(acb_t y, acb_t z, arb_srcptr f, slong len, const acb_t x, slong prec) noexcept - void arb_poly_evaluate2_acb(acb_t y, acb_t z, const arb_poly_t f, const acb_t x, slong prec) noexcept - # Sets `y = f(x), z = f'(x)`, evaluated respectively using Horner's rule, - # rectangular splitting, and an automatic algorithm choice. - void _arb_poly_product_roots(arb_ptr poly, arb_srcptr xs, slong n, slong prec) noexcept - void arb_poly_product_roots(arb_poly_t poly, arb_srcptr xs, slong n, slong prec) noexcept - # Generates the polynomial `(x-x_0)(x-x_1)\cdots(x-x_{n-1})`. - void _arb_poly_product_roots_complex(arb_ptr poly, arb_srcptr r, slong rn, acb_srcptr c, slong cn, slong prec) noexcept - void arb_poly_product_roots_complex(arb_poly_t poly, arb_srcptr r, slong rn, acb_srcptr c, slong cn, slong prec) noexcept - # Generates the polynomial - # .. math :: - # \left(\prod_{i=0}^{rn-1} (x-r_i)\right) \left(\prod_{i=0}^{cn-1} (x-c_i)(x-\bar{c_i})\right) - # having *rn* real roots given by the array *r* and having `2cn` complex roots - # in conjugate pairs given by the length-*cn* array *c*. - # Either *rn* or *cn* or both may be zero. - # Note that only one representative from each complex conjugate pair - # is supplied (unless a pair is supposed to - # be repeated with higher multiplicity). - # To construct a polynomial from complex roots where the conjugate pairs - # have not been distinguished, use :func:`acb_poly_product_roots` instead. - arb_ptr * _arb_poly_tree_alloc(slong len) noexcept - # Returns an initialized data structured capable of representing a - # remainder tree (product tree) of *len* roots. - void _arb_poly_tree_free(arb_ptr * tree, slong len) noexcept - # Deallocates a tree structure as allocated using *_arb_poly_tree_alloc*. - void _arb_poly_tree_build(arb_ptr * tree, arb_srcptr roots, slong len, slong prec) noexcept - # Constructs a product tree from a given array of *len* roots. The tree - # structure must be pre-allocated to the specified length using - # :func:`_arb_poly_tree_alloc`. - void _arb_poly_evaluate_vec_iter(arb_ptr ys, arb_srcptr poly, slong plen, arb_srcptr xs, slong n, slong prec) noexcept - void arb_poly_evaluate_vec_iter(arb_ptr ys, const arb_poly_t poly, arb_srcptr xs, slong n, slong prec) noexcept - # Evaluates the polynomial simultaneously at *n* given points, calling - # :func:`_arb_poly_evaluate` repeatedly. - void _arb_poly_evaluate_vec_fast_precomp(arb_ptr vs, arb_srcptr poly, slong plen, arb_ptr * tree, slong len, slong prec) noexcept - void _arb_poly_evaluate_vec_fast(arb_ptr ys, arb_srcptr poly, slong plen, arb_srcptr xs, slong n, slong prec) noexcept - void arb_poly_evaluate_vec_fast(arb_ptr ys, const arb_poly_t poly, arb_srcptr xs, slong n, slong prec) noexcept - # Evaluates the polynomial simultaneously at *n* given points, using - # fast multipoint evaluation. - void _arb_poly_interpolate_newton(arb_ptr poly, arb_srcptr xs, arb_srcptr ys, slong n, slong prec) noexcept - void arb_poly_interpolate_newton(arb_poly_t poly, arb_srcptr xs, arb_srcptr ys, slong n, slong prec) noexcept - # Recovers the unique polynomial of length at most *n* that interpolates - # the given *x* and *y* values. This implementation first interpolates in the - # Newton basis and then converts back to the monomial basis. - void _arb_poly_interpolate_barycentric(arb_ptr poly, arb_srcptr xs, arb_srcptr ys, slong n, slong prec) noexcept - void arb_poly_interpolate_barycentric(arb_poly_t poly, arb_srcptr xs, arb_srcptr ys, slong n, slong prec) noexcept - # Recovers the unique polynomial of length at most *n* that interpolates - # the given *x* and *y* values. This implementation uses the barycentric - # form of Lagrange interpolation. - void _arb_poly_interpolation_weights(arb_ptr w, arb_ptr * tree, slong len, slong prec) noexcept - void _arb_poly_interpolate_fast_precomp(arb_ptr poly, arb_srcptr ys, arb_ptr * tree, arb_srcptr weights, slong len, slong prec) noexcept - void _arb_poly_interpolate_fast(arb_ptr poly, arb_srcptr xs, arb_srcptr ys, slong len, slong prec) noexcept - void arb_poly_interpolate_fast(arb_poly_t poly, arb_srcptr xs, arb_srcptr ys, slong n, slong prec) noexcept - # Recovers the unique polynomial of length at most *n* that interpolates - # the given *x* and *y* values, using fast Lagrange interpolation. - # The precomp function takes a precomputed product tree over the - # *x* values and a vector of interpolation weights as additional inputs. - void _arb_poly_derivative(arb_ptr res, arb_srcptr poly, slong len, slong prec) noexcept - # Sets *{res, len - 1}* to the derivative of *{poly, len}*. - # Allows aliasing of the input and output. - void arb_poly_derivative(arb_poly_t res, const arb_poly_t poly, slong prec) noexcept - # Sets *res* to the derivative of *poly*. - void _arb_poly_nth_derivative(arb_ptr res, arb_srcptr poly, ulong n, slong len, slong prec) noexcept - # Sets *{res, len - n}* to the nth derivative of *{poly, len}*. Does - # nothing if *len <= n*. Allows aliasing of the input and output. - void arb_poly_nth_derivative(arb_poly_t res, const arb_poly_t poly, ulong n, slong prec) noexcept - # Sets *res* to the nth derivative of *poly*. - void _arb_poly_integral(arb_ptr res, arb_srcptr poly, slong len, slong prec) noexcept - # Sets *{res, len}* to the integral of *{poly, len - 1}*. - # Allows aliasing of the input and output. - void arb_poly_integral(arb_poly_t res, const arb_poly_t poly, slong prec) noexcept - # Sets *res* to the integral of *poly*. - void _arb_poly_borel_transform(arb_ptr res, arb_srcptr poly, slong len, slong prec) noexcept - void arb_poly_borel_transform(arb_poly_t res, const arb_poly_t poly, slong prec) noexcept - # Computes the Borel transform of the input polynomial, mapping `\sum_k a_k x^k` - # to `\sum_k (a_k / k!) x^k`. The underscore method allows aliasing. - void _arb_poly_inv_borel_transform(arb_ptr res, arb_srcptr poly, slong len, slong prec) noexcept - void arb_poly_inv_borel_transform(arb_poly_t res, const arb_poly_t poly, slong prec) noexcept - # Computes the inverse Borel transform of the input polynomial, mapping `\sum_k a_k x^k` - # to `\sum_k a_k k! x^k`. The underscore method allows aliasing. - void _arb_poly_binomial_transform_basecase(arb_ptr b, arb_srcptr a, slong alen, slong len, slong prec) noexcept - void arb_poly_binomial_transform_basecase(arb_poly_t b, const arb_poly_t a, slong len, slong prec) noexcept - void _arb_poly_binomial_transform_convolution(arb_ptr b, arb_srcptr a, slong alen, slong len, slong prec) noexcept - void arb_poly_binomial_transform_convolution(arb_poly_t b, const arb_poly_t a, slong len, slong prec) noexcept - void _arb_poly_binomial_transform(arb_ptr b, arb_srcptr a, slong alen, slong len, slong prec) noexcept - void arb_poly_binomial_transform(arb_poly_t b, const arb_poly_t a, slong len, slong prec) noexcept - # Computes the binomial transform of the input polynomial, truncating - # the output to length *len*. - # The binomial transform maps the coefficients `a_k` in the input polynomial - # to the coefficients `b_k` in the output polynomial via - # `b_n = \sum_{k=0}^n (-1)^k {n choose k} a_k`. - # The binomial transform is equivalent to the power series composition - # `f(x) \to (1-x)^{-1} f(x/(x-1))`, and is its own inverse. - # The *basecase* version evaluates coefficients one by one from the - # definition, generating the binomial coefficients by a recurrence - # relation. - # The *convolution* version uses the identity - # `T(f(x)) = B^{-1}(e^x B(f(-x)))` where `T` denotes the binomial - # transform operator and `B` denotes the Borel transform operator. - # This only costs a single polynomial multiplication, plus some - # scalar operations. - # The default version automatically chooses an algorithm. - # The underscore methods do not support aliasing, and assume that - # the lengths are nonzero. - void _arb_poly_graeffe_transform(arb_ptr b, arb_srcptr a, slong len, slong prec) noexcept - void arb_poly_graeffe_transform(arb_poly_t b, const arb_poly_t a, slong prec) noexcept - # Computes the Graeffe transform of input polynomial. - # The Graeffe transform `G` of a polynomial `P` is defined through the - # equation `G(x^2) = \pm P(x)P(-x)`. - # The sign is given by `(-1)^d`, where `d = deg(P)`. - # The Graeffe transform has the property that its roots are exactly the - # squares of the roots of P. - # The underscore method assumes that *a* and *b* are initialized, - # *a* is of length *len*, and *b* is of length at least *len*. - # Both methods allow aliasing. - void _arb_poly_pow_ui_trunc_binexp(arb_ptr res, arb_srcptr f, slong flen, ulong exp, slong len, slong prec) noexcept - # Sets *{res, len}* to *{f, flen}* raised to the power *exp*, truncated - # to length *len*. Requires that *len* is no longer than the length - # of the power as computed without truncation (i.e. no zero-padding is performed). - # Does not support aliasing of the input and output, and requires - # that *flen* and *len* are positive. - # Uses binary exponentiation. - void arb_poly_pow_ui_trunc_binexp(arb_poly_t res, const arb_poly_t poly, ulong exp, slong len, slong prec) noexcept - # Sets *res* to *poly* raised to the power *exp*, truncated to length *len*. - # Uses binary exponentiation. - void _arb_poly_pow_ui(arb_ptr res, arb_srcptr f, slong flen, ulong exp, slong prec) noexcept - # Sets *res* to *{f, flen}* raised to the power *exp*. Does not - # support aliasing of the input and output, and requires that - # *flen* is positive. - void arb_poly_pow_ui(arb_poly_t res, const arb_poly_t poly, ulong exp, slong prec) noexcept - # Sets *res* to *poly* raised to the power *exp*. - void _arb_poly_pow_series(arb_ptr h, arb_srcptr f, slong flen, arb_srcptr g, slong glen, slong len, slong prec) noexcept - # Sets *{h, len}* to the power series `f(x)^{g(x)} = \exp(g(x) \log f(x))` truncated - # to length *len*. This function detects special cases such as *g* being an - # exact small integer or `\pm 1/2`, and computes such powers more - # efficiently. This function does not support aliasing of the output - # with either of the input operands. It requires that all lengths - # are positive, and assumes that *flen* and *glen* do not exceed *len*. - void arb_poly_pow_series(arb_poly_t h, const arb_poly_t f, const arb_poly_t g, slong len, slong prec) noexcept - # Sets *h* to the power series `f(x)^{g(x)} = \exp(g(x) \log f(x))` truncated - # to length *len*. This function detects special cases such as *g* being an - # exact small integer or `\pm 1/2`, and computes such powers more - # efficiently. - void _arb_poly_pow_arb_series(arb_ptr h, arb_srcptr f, slong flen, const arb_t g, slong len, slong prec) noexcept - # Sets *{h, len}* to the power series `f(x)^g = \exp(g \log f(x))` truncated - # to length *len*. This function detects special cases such as *g* being an - # exact small integer or `\pm 1/2`, and computes such powers more - # efficiently. This function does not support aliasing of the output - # with either of the input operands. It requires that all lengths - # are positive, and assumes that *flen* does not exceed *len*. - void arb_poly_pow_arb_series(arb_poly_t h, const arb_poly_t f, const arb_t g, slong len, slong prec) noexcept - # Sets *h* to the power series `f(x)^g = \exp(g \log f(x))` truncated - # to length *len*. - void _arb_poly_sqrt_series(arb_ptr g, arb_srcptr h, slong hlen, slong n, slong prec) noexcept - void arb_poly_sqrt_series(arb_poly_t g, const arb_poly_t h, slong n, slong prec) noexcept - # Sets *g* to the power series square root of *h*, truncated to length *n*. - # Uses division-free Newton iteration for the reciprocal square root, - # followed by a multiplication. - # The underscore method does not support aliasing of the input and output - # arrays. It requires that *hlen* and *n* are greater than zero. - void _arb_poly_rsqrt_series(arb_ptr g, arb_srcptr h, slong hlen, slong n, slong prec) noexcept - void arb_poly_rsqrt_series(arb_poly_t g, const arb_poly_t h, slong n, slong prec) noexcept - # Sets *g* to the reciprocal power series square root of *h*, truncated to length *n*. - # Uses division-free Newton iteration. - # The underscore method does not support aliasing of the input and output - # arrays. It requires that *hlen* and *n* are greater than zero. - void _arb_poly_log_series(arb_ptr res, arb_srcptr f, slong flen, slong n, slong prec) noexcept - void arb_poly_log_series(arb_poly_t res, const arb_poly_t f, slong n, slong prec) noexcept - # Sets *res* to the power series logarithm of *f*, truncated to length *n*. - # Uses the formula `\log(f(x)) = \int f'(x) / f(x) dx`, adding the logarithm of the - # constant term in *f* as the constant of integration. - # The underscore method supports aliasing of the input and output - # arrays. It requires that *flen* and *n* are greater than zero. - void _arb_poly_log1p_series(arb_ptr res, arb_srcptr f, slong flen, slong n, slong prec) noexcept - void arb_poly_log1p_series(arb_poly_t res, const arb_poly_t f, slong n, slong prec) noexcept - # Computes the power series `\log(1+f)`, with better accuracy when the constant term of *f* is small. - void _arb_poly_atan_series(arb_ptr res, arb_srcptr f, slong flen, slong n, slong prec) noexcept - void arb_poly_atan_series(arb_poly_t res, const arb_poly_t f, slong n, slong prec) noexcept - void _arb_poly_asin_series(arb_ptr res, arb_srcptr f, slong flen, slong n, slong prec) noexcept - void arb_poly_asin_series(arb_poly_t res, const arb_poly_t f, slong n, slong prec) noexcept - void _arb_poly_acos_series(arb_ptr res, arb_srcptr f, slong flen, slong n, slong prec) noexcept - void arb_poly_acos_series(arb_poly_t res, const arb_poly_t f, slong n, slong prec) noexcept - # Sets *res* respectively to the power series inverse tangent, - # inverse sine and inverse cosine of *f*, truncated to length *n*. - # Uses the formulas - # .. math :: - # \tan^{-1}(f(x)) = \int f'(x) / (1+f(x)^2) dx, - # \sin^{-1}(f(x)) = \int f'(x) / (1-f(x)^2)^{1/2} dx, - # \cos^{-1}(f(x)) = -\int f'(x) / (1-f(x)^2)^{1/2} dx, - # adding the inverse - # function of the constant term in *f* as the constant of integration. - # The underscore methods supports aliasing of the input and output - # arrays. They require that *flen* and *n* are greater than zero. - void _arb_poly_exp_series_basecase(arb_ptr f, arb_srcptr h, slong hlen, slong n, slong prec) noexcept - void arb_poly_exp_series_basecase(arb_poly_t f, const arb_poly_t h, slong n, slong prec) noexcept - void _arb_poly_exp_series(arb_ptr f, arb_srcptr h, slong hlen, slong n, slong prec) noexcept - void arb_poly_exp_series(arb_poly_t f, const arb_poly_t h, slong n, slong prec) noexcept - # Sets `f` to the power series exponential of `h`, truncated to length `n`. - # The basecase version uses a simple recurrence for the coefficients, - # requiring `O(nm)` operations where `m` is the length of `h`. - # The main implementation uses Newton iteration, starting from a small - # number of terms given by the basecase algorithm. The complexity - # is `O(M(n))`. Redundant operations in the Newton iteration are - # avoided by using the scheme described in [HZ2004]_. - # The underscore methods support aliasing and allow the input to be - # shorter than the output, but require the lengths to be nonzero. - void _arb_poly_sin_cos_series(arb_ptr s, arb_ptr c, arb_srcptr h, slong hlen, slong n, slong prec) noexcept void arb_poly_sin_cos_series(arb_poly_t s, arb_poly_t c, const arb_poly_t h, slong n, slong prec) noexcept - # Sets *s* and *c* to the power series sine and cosine of *h*, computed - # simultaneously. - # The underscore method supports aliasing and requires the lengths to be nonzero. - void _arb_poly_sin_series(arb_ptr s, arb_srcptr h, slong hlen, slong n, slong prec) noexcept - void arb_poly_sin_series(arb_poly_t s, const arb_poly_t h, slong n, slong prec) noexcept - void _arb_poly_cos_series(arb_ptr c, arb_srcptr h, slong hlen, slong n, slong prec) noexcept - void arb_poly_cos_series(arb_poly_t c, const arb_poly_t h, slong n, slong prec) noexcept - # Respectively evaluates the power series sine or cosine. These functions - # simply wrap :func:`_arb_poly_sin_cos_series`. The underscore methods - # support aliasing and require the lengths to be nonzero. - void _arb_poly_tan_series(arb_ptr g, arb_srcptr h, slong hlen, slong len, slong prec) noexcept - void arb_poly_tan_series(arb_poly_t g, const arb_poly_t h, slong n, slong prec) noexcept - # Sets *g* to the power series tangent of *h*. - # For small *n* takes the quotient of the sine and cosine as computed - # using the basecase algorithm. For large *n*, uses Newton iteration - # to invert the inverse tangent series. The complexity is `O(M(n))`. - # The underscore version does not support aliasing, and requires - # the lengths to be nonzero. - void _arb_poly_sin_cos_pi_series(arb_ptr s, arb_ptr c, arb_srcptr h, slong hlen, slong n, slong prec) noexcept - void arb_poly_sin_cos_pi_series(arb_poly_t s, arb_poly_t c, const arb_poly_t h, slong n, slong prec) noexcept - void _arb_poly_sin_pi_series(arb_ptr s, arb_srcptr h, slong hlen, slong n, slong prec) noexcept - void arb_poly_sin_pi_series(arb_poly_t s, const arb_poly_t h, slong n, slong prec) noexcept - void _arb_poly_cos_pi_series(arb_ptr c, arb_srcptr h, slong hlen, slong n, slong prec) noexcept - void arb_poly_cos_pi_series(arb_poly_t c, const arb_poly_t h, slong n, slong prec) noexcept - void _arb_poly_cot_pi_series(arb_ptr c, arb_srcptr h, slong hlen, slong n, slong prec) noexcept - void arb_poly_cot_pi_series(arb_poly_t c, const arb_poly_t h, slong n, slong prec) noexcept - # Compute the respective trigonometric functions of the input - # multiplied by `\pi`. - void _arb_poly_sinh_cosh_series_basecase(arb_ptr s, arb_ptr c, arb_srcptr h, slong hlen, slong n, slong prec) noexcept - void arb_poly_sinh_cosh_series_basecase(arb_poly_t s, arb_poly_t c, const arb_poly_t h, slong n, slong prec) noexcept - void _arb_poly_sinh_cosh_series_exponential(arb_ptr s, arb_ptr c, arb_srcptr h, slong hlen, slong n, slong prec) noexcept - void arb_poly_sinh_cosh_series_exponential(arb_poly_t s, arb_poly_t c, const arb_poly_t h, slong n, slong prec) noexcept - void _arb_poly_sinh_cosh_series(arb_ptr s, arb_ptr c, arb_srcptr h, slong hlen, slong n, slong prec) noexcept - void arb_poly_sinh_cosh_series(arb_poly_t s, arb_poly_t c, const arb_poly_t h, slong n, slong prec) noexcept - void _arb_poly_sinh_series(arb_ptr s, arb_srcptr h, slong hlen, slong n, slong prec) noexcept - void arb_poly_sinh_series(arb_poly_t s, const arb_poly_t h, slong n, slong prec) noexcept - void _arb_poly_cosh_series(arb_ptr c, arb_srcptr h, slong hlen, slong n, slong prec) noexcept - void arb_poly_cosh_series(arb_poly_t c, const arb_poly_t h, slong n, slong prec) noexcept - # Sets *s* and *c* respectively to the hyperbolic sine and cosine of the - # power series *h*, truncated to length *n*. - # The implementations mirror those for sine and cosine, except that - # the *exponential* version computes both functions using the exponential - # function instead of the hyperbolic tangent. - void _arb_poly_sinc_series(arb_ptr s, arb_srcptr h, slong hlen, slong n, slong prec) noexcept - void arb_poly_sinc_series(arb_poly_t s, const arb_poly_t h, slong n, slong prec) noexcept - # Sets *c* to the sinc function of the power series *h*, truncated - # to length *n*. - void _arb_poly_sinc_pi_series(arb_ptr s, arb_srcptr h, slong hlen, slong n, slong prec) noexcept - void arb_poly_sinc_pi_series(arb_poly_t s, const arb_poly_t h, slong n, slong prec) noexcept - # Compute the sinc function of the input multiplied by `\pi`. - void _arb_poly_lambertw_series(arb_ptr res, arb_srcptr z, slong zlen, int flags, slong len, slong prec) noexcept - void arb_poly_lambertw_series(arb_poly_t res, const arb_poly_t z, int flags, slong len, slong prec) noexcept - # Sets *res* to the Lambert W function of the power series *z*. - # If *flags* is 0, the principal branch is computed; if *flags* is 1, - # the second real branch `W_{-1}(z)` is computed. - # The underscore method allows aliasing, but assumes that the lengths are nonzero. - void _arb_poly_gamma_series(arb_ptr res, arb_srcptr h, slong hlen, slong n, slong prec) noexcept - void arb_poly_gamma_series(arb_poly_t res, const arb_poly_t h, slong n, slong prec) noexcept - void _arb_poly_rgamma_series(arb_ptr res, arb_srcptr h, slong hlen, slong n, slong prec) noexcept - void arb_poly_rgamma_series(arb_poly_t res, const arb_poly_t h, slong n, slong prec) noexcept - void _arb_poly_lgamma_series(arb_ptr res, arb_srcptr h, slong hlen, slong n, slong prec) noexcept - void arb_poly_lgamma_series(arb_poly_t res, const arb_poly_t h, slong n, slong prec) noexcept - void _arb_poly_digamma_series(arb_ptr res, arb_srcptr h, slong hlen, slong n, slong prec) noexcept - void arb_poly_digamma_series(arb_poly_t res, const arb_poly_t h, slong n, slong prec) noexcept - # Sets *res* to the series expansion of `\Gamma(h(x))`, `1/\Gamma(h(x))`, - # or `\log \Gamma(h(x))`, `\psi(h(x))`, truncated to length *n*. - # These functions first generate the Taylor series at the constant - # term of *h*, and then call :func:`_arb_poly_compose_series`. - # The Taylor coefficients are generated using the Riemann zeta function - # if the constant term of *h* is a small integer, - # and with Stirling's series otherwise. - # The underscore methods support aliasing of the input and output - # arrays, and require that *hlen* and *n* are greater than zero. - void _arb_poly_rising_ui_series(arb_ptr res, arb_srcptr f, slong flen, ulong r, slong trunc, slong prec) noexcept - void arb_poly_rising_ui_series(arb_poly_t res, const arb_poly_t f, ulong r, slong trunc, slong prec) noexcept - # Sets *res* to the rising factorial `(f) (f+1) (f+2) \cdots (f+r-1)`, truncated - # to length *trunc*. The underscore method assumes that *flen*, *r* and *trunc* - # are at least 1, and does not support aliasing. Uses binary splitting. - void arb_poly_zeta_series(arb_poly_t res, const arb_poly_t s, const arb_t a, int deflate, slong n, slong prec) noexcept - # Sets *res* to the Hurwitz zeta function `\zeta(s,a)` where `s` a power - # series and `a` is a constant, truncated to length *n*. - # To evaluate the usual Riemann zeta function, set `a = 1`. - # If *deflate* is nonzero, evaluates `\zeta(s,a) + 1/(1-s)`, which - # is well-defined as a limit when the constant term of `s` is 1. - # In particular, expanding `\zeta(s,a) + 1/(1-s)` with `s = 1+x` - # gives the Stieltjes constants - # .. math :: - # \sum_{k=0}^{n-1} \frac{(-1)^k}{k!} \gamma_k(a) x^k. - # If `a = 1`, this implementation uses the reflection formula if the midpoint - # of the constant term of `s` is negative. - void _arb_poly_riemann_siegel_theta_series(arb_ptr res, arb_srcptr h, slong hlen, slong n, slong prec) noexcept - void arb_poly_riemann_siegel_theta_series(arb_poly_t res, const arb_poly_t h, slong n, slong prec) noexcept - # Sets *res* to the series expansion of the Riemann-Siegel theta - # function - # .. math :: - # \theta(h) = \arg \left(\Gamma\left(\frac{2ih+1}{4}\right)\right) - \frac{\log \pi}{2} h - # where the argument of the gamma function is chosen continuously - # as the imaginary part of the log gamma function. - # The underscore method does not support aliasing of the input - # and output arrays, and requires that the lengths are greater - # than zero. - void _arb_poly_riemann_siegel_z_series(arb_ptr res, arb_srcptr h, slong hlen, slong n, slong prec) noexcept - void arb_poly_riemann_siegel_z_series(arb_poly_t res, const arb_poly_t h, slong n, slong prec) noexcept - # Sets *res* to the series expansion of the Riemann-Siegel Z-function - # .. math :: - # Z(h) = e^{i\theta(h)} \zeta(1/2+ih). - # The zeros of the Z-function on the real line precisely - # correspond to the imaginary parts of the zeros of - # the Riemann zeta function on the critical line. - # The underscore method supports aliasing of the input - # and output arrays, and requires that the lengths are greater - # than zero. - void _arb_poly_root_bound_fujiwara(mag_t bound, arb_srcptr poly, slong len) noexcept - void arb_poly_root_bound_fujiwara(mag_t bound, arb_poly_t poly) noexcept - # Sets *bound* to an upper bound for the magnitude of all the complex - # roots of *poly*. Uses Fujiwara's bound - # .. math :: - # 2 \max \left\{\left|\frac{a_{n-1}}{a_n}\right|, - # \left|\frac{a_{n-2}}{a_n}\right|^{1/2}, - # \cdots, - # \left|\frac{a_1}{a_n}\right|^{1/(n-1)}, - # \left|\frac{a_0}{2a_n}\right|^{1/n} - # \right\} - # where `a_0, \ldots, a_n` are the coefficients of *poly*. - void _arb_poly_newton_convergence_factor(arf_t convergence_factor, arb_srcptr poly, slong len, const arb_t convergence_interval, slong prec) noexcept - # Given an interval `I` specified by *convergence_interval*, evaluates a bound - # for `C = \sup_{t,u \in I} \frac{1}{2} |f''(t)| / |f'(u)|`, - # where `f` is the polynomial defined by the coefficients *{poly, len}*. - # The bound is obtained by evaluating `f'(I)` and `f''(I)` directly. - # If `f` has large coefficients, `I` must be extremely precise in order to - # get a finite factor. - int _arb_poly_newton_step(arb_t xnew, arb_srcptr poly, slong len, const arb_t x, const arb_t convergence_interval, const arf_t convergence_factor, slong prec) noexcept - # Performs a single step with Newton's method. - # The input consists of the polynomial `f` specified by the coefficients - # *{poly, len}*, an interval `x = [m-r, m+r]` known to contain a single root of `f`, - # an interval `I` (*convergence_interval*) containing `x` with an - # associated bound (*convergence_factor*) for - # `C = \sup_{t,u \in I} \frac{1}{2} |f''(t)| / |f'(u)|`, - # and a working precision *prec*. - # The Newton update consists of setting - # `x' = [m'-r', m'+r']` where `m' = m - f(m) / f'(m)` - # and `r' = C r^2`. The expression `m - f(m) / f'(m)` is evaluated - # using ball arithmetic at a working precision of *prec* bits, and the - # rounding error during this evaluation is accounted for in the output. - # We now check that `x' \in I` and `m' < m`. If both conditions are - # satisfied, we set *xnew* to `x'` and return nonzero. - # If either condition fails, we set *xnew* to `x` and return zero, - # indicating that no progress was made. - void _arb_poly_newton_refine_root(arb_t r, arb_srcptr poly, slong len, const arb_t start, const arb_t convergence_interval, const arf_t convergence_factor, slong eval_extra_prec, slong prec) noexcept - # Refines a precise estimate of a polynomial root to high precision - # by performing several Newton steps, using nearly optimally - # chosen doubling precision steps. - # The inputs are defined as for *_arb_poly_newton_step*, except for - # the precision parameters: *prec* is the target accuracy and - # *eval_extra_prec* is the estimated number of guard bits that need - # to be added to evaluate the polynomial accurately close to the root - # (typically, if the polynomial has large coefficients of alternating - # signs, this needs to be approximately the bit size of the coefficients). - void _arb_poly_swinnerton_dyer_ui(arb_ptr poly, ulong n, slong trunc, slong prec) noexcept - void arb_poly_swinnerton_dyer_ui(arb_poly_t poly, ulong n, slong prec) noexcept - # Computes the Swinnerton-Dyer polynomial `S_n`, which has degree `2^n` - # and is the rational minimal polynomial of the sum - # of the square roots of the first *n* prime numbers. - # If *prec* is set to zero, a precision is chosen automatically such - # that :func:`arb_poly_get_unique_fmpz_poly` should be successful. - # Otherwise a working precision of *prec* bits is used. - # The underscore version accepts an additional *trunc* parameter. Even - # when computing a truncated polynomial, the array *poly* must have room for - # `2^n + 1` coefficients, used as temporary space. diff --git a/src/sage/libs/flint/arf.pxd b/src/sage/libs/flint/arf.pxd index 0f0424ecd05..8e2218d7d8a 100644 --- a/src/sage/libs/flint/arf.pxd +++ b/src/sage/libs/flint/arf.pxd @@ -2,7 +2,9 @@ # distutils: depends = flint/arf.h ################################################################################ -# This file is auto-generated. Do not modify by hand +# This file is auto-generated by the script +# SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py. +# Do not modify by hand! Fix and rerun the script instead. ################################################################################ from libc.stdio cimport FILE @@ -11,525 +13,153 @@ from sage.libs.mpfr.types cimport * from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void arf_init(arf_t x) noexcept - # Initializes the variable *x* for use. Its value is set to zero. - void arf_clear(arf_t x) noexcept - # Clears the variable *x*, freeing or recycling its allocated memory. - slong arf_allocated_bytes(const arf_t x) noexcept - # Returns the total number of bytes heap-allocated internally by this object. - # The count excludes the size of the structure itself. Add - # ``sizeof(arf_struct)`` to get the size of the object as a whole. - void arf_zero(arf_t res) noexcept - void arf_one(arf_t res) noexcept - void arf_pos_inf(arf_t res) noexcept - void arf_neg_inf(arf_t res) noexcept - void arf_nan(arf_t res) noexcept - # Sets *res* respectively to 0, 1, `+\infty`, `-\infty`, NaN. - bint arf_is_zero(const arf_t x) noexcept - bint arf_is_one(const arf_t x) noexcept - bint arf_is_pos_inf(const arf_t x) noexcept - bint arf_is_neg_inf(const arf_t x) noexcept - bint arf_is_nan(const arf_t x) noexcept - # Returns nonzero iff *x* respectively equals 0, 1, `+\infty`, `-\infty`, NaN. - bint arf_is_inf(const arf_t x) noexcept - # Returns nonzero iff *x* equals either `+\infty` or `-\infty`. - bint arf_is_normal(const arf_t x) noexcept - # Returns nonzero iff *x* is a finite, nonzero floating-point value, i.e. - # not one of the special values 0, `+\infty`, `-\infty`, NaN. - bint arf_is_special(const arf_t x) noexcept - # Returns nonzero iff *x* is one of the special values - # 0, `+\infty`, `-\infty`, NaN, i.e. not a finite, nonzero - # floating-point value. - bint arf_is_finite(const arf_t x) noexcept - # Returns nonzero iff *x* is a finite floating-point value, - # i.e. not one of the values `+\infty`, `-\infty`, NaN. - # (Note that this is not equivalent to the negation of - # :func:`arf_is_inf`.) - void arf_set(arf_t res, const arf_t x) noexcept - void arf_set_mpz(arf_t res, const mpz_t x) noexcept - void arf_set_fmpz(arf_t res, const fmpz_t x) noexcept - void arf_set_ui(arf_t res, ulong x) noexcept - void arf_set_si(arf_t res, slong x) noexcept - void arf_set_mpfr(arf_t res, const mpfr_t x) noexcept - void arf_set_d(arf_t res, double x) noexcept - # Sets *res* to the exact value of *x*. - void arf_swap(arf_t x, arf_t y) noexcept - # Swaps *x* and *y* efficiently. - void arf_init_set_ui(arf_t res, ulong x) noexcept - void arf_init_set_si(arf_t res, slong x) noexcept - # Initializes *res* and sets it to *x* in a single operation. - int arf_set_round(arf_t res, const arf_t x, slong prec, arf_rnd_t rnd) noexcept - int arf_set_round_si(arf_t res, slong x, slong prec, arf_rnd_t rnd) noexcept - int arf_set_round_ui(arf_t res, ulong x, slong prec, arf_rnd_t rnd) noexcept - int arf_set_round_mpz(arf_t res, const mpz_t x, slong prec, arf_rnd_t rnd) noexcept - int arf_set_round_fmpz(arf_t res, const fmpz_t x, slong prec, arf_rnd_t rnd) noexcept - # Sets *res* to *x*, rounded to *prec* bits in the direction - # specified by *rnd*. - void arf_set_si_2exp_si(arf_t res, slong m, slong e) noexcept - void arf_set_ui_2exp_si(arf_t res, ulong m, slong e) noexcept - void arf_set_fmpz_2exp(arf_t res, const fmpz_t m, const fmpz_t e) noexcept - # Sets *res* to `m \cdot 2^e`. - int arf_set_round_fmpz_2exp(arf_t res, const fmpz_t x, const fmpz_t e, slong prec, arf_rnd_t rnd) noexcept - # Sets *res* to `x \cdot 2^e`, rounded to *prec* bits in the direction - # specified by *rnd*. - void arf_get_fmpz_2exp(fmpz_t m, fmpz_t e, const arf_t x) noexcept - # Sets *m* and *e* to the unique integers such that - # `x = m \cdot 2^e` and *m* is odd, - # provided that *x* is a nonzero finite fraction. - # If *x* is zero, both *m* and *e* are set to zero. If *x* is - # infinite or NaN, the result is undefined. - void arf_frexp(arf_t m, fmpz_t e, const arf_t x) noexcept - # Writes *x* as `m \cdot 2^e`, where `0.5 \le |m| < 1` if *x* is a normal - # value. If *x* is a special value, copies this to *m* and sets *e* to zero. - # Note: for the inverse operation (*ldexp*), use :func:`arf_mul_2exp_fmpz`. - double arf_get_d(const arf_t x, arf_rnd_t rnd) noexcept - # Returns *x* rounded to a double in the direction specified by *rnd*. - # This method rounds correctly when overflowing or underflowing - # the double exponent range (this was not the case in an earlier version). - int arf_get_mpfr(mpfr_t res, const arf_t x, mpfr_rnd_t rnd) noexcept - # Sets the MPFR variable *res* to the value of *x*. If the precision of *x* - # is too small to allow *res* to be represented exactly, it is rounded in - # the specified MPFR rounding mode. The return value (-1, 0 or 1) - # indicates the direction of rounding, following the convention - # of the MPFR library. - # If *x* has an exponent too large or small to fit in the MPFR type, the - # result overflows to an infinity or underflows to a (signed) zero, - # and the corresponding MPFR exception flags are set. - int arf_get_fmpz(fmpz_t res, const arf_t x, arf_rnd_t rnd) noexcept - # Sets *res* to *x* rounded to the nearest integer in the direction - # specified by *rnd*. If rnd is *ARF_RND_NEAR*, rounds to the nearest - # even integer in case of a tie. Returns inexact (beware: accordingly - # returns whether *x* is *not* an integer). - # This method aborts if *x* is infinite or NaN, or if the exponent of *x* - # is so large that allocating memory for the result fails. - # Warning: this method will allocate a huge amount of memory to store - # the result if the exponent of *x* is huge. Memory allocation could - # succeed even if the required space is far larger than the physical - # memory available on the machine, resulting in swapping. It is recommended - # to check that *x* is within a reasonable range before calling this method. - slong arf_get_si(const arf_t x, arf_rnd_t rnd) noexcept - # Returns *x* rounded to the nearest integer in the direction specified by - # *rnd*. If *rnd* is *ARF_RND_NEAR*, rounds to the nearest even integer - # in case of a tie. Aborts if *x* is infinite, NaN, or the value is - # too large to fit in a slong. - int arf_get_fmpz_fixed_fmpz(fmpz_t res, const arf_t x, const fmpz_t e) noexcept - int arf_get_fmpz_fixed_si(fmpz_t res, const arf_t x, slong e) noexcept - # Converts *x* to a mantissa with predetermined exponent, i.e. sets *res* to - # an integer *y* such that `y \times 2^e \approx x`, truncating if necessary. - # Returns 0 if exact and 1 if truncation occurred. - # The warnings for :func:`arf_get_fmpz` apply. - void arf_floor(arf_t res, const arf_t x) noexcept - void arf_ceil(arf_t res, const arf_t x) noexcept - # Sets *res* to `\lfloor x \rfloor` and `\lceil x \rceil` respectively. - # The result is always represented exactly, requiring no more bits to - # store than the input. To round the result to a floating-point number - # with a lower precision, call :func:`arf_set_round` afterwards. - void arf_get_fmpq(fmpq_t res, const arf_t x) noexcept - # Set *res* to the exact rational value of *x*. - # This method aborts if *x* is infinite or NaN, or if the exponent of *x* - # is so large that allocating memory for the result fails. - bint arf_equal(const arf_t x, const arf_t y) noexcept bint arf_equal_si(const arf_t x, slong y) noexcept bint arf_equal_ui(const arf_t x, ulong y) noexcept bint arf_equal_d(const arf_t x, double y) noexcept - # Returns nonzero iff *x* and *y* are exactly equal. NaN is not - # treated specially, i.e. NaN compares as equal to itself. - # For comparison with a *double*, the values -0 and +0 are - # both treated as zero, and all NaN values are treated as identical. - int arf_cmp(const arf_t x, const arf_t y) noexcept - int arf_cmp_si(const arf_t x, slong y) noexcept - int arf_cmp_ui(const arf_t x, ulong y) noexcept - int arf_cmp_d(const arf_t x, double y) noexcept - # Returns negative, zero, or positive, depending on whether *x* is - # respectively smaller, equal, or greater compared to *y*. - # Comparison with NaN is undefined. - int arf_cmpabs(const arf_t x, const arf_t y) noexcept - int arf_cmpabs_ui(const arf_t x, ulong y) noexcept - int arf_cmpabs_d(const arf_t x, double y) noexcept - int arf_cmpabs_mag(const arf_t x, const mag_t y) noexcept - # Compares the absolute values of *x* and *y*. - int arf_cmp_2exp_si(const arf_t x, slong e) noexcept - int arf_cmpabs_2exp_si(const arf_t x, slong e) noexcept - # Compares *x* (respectively its absolute value) with `2^e`. - int arf_sgn(const arf_t x) noexcept - # Returns `-1`, `0` or `+1` according to the sign of *x*. The sign - # of NaN is undefined. - void arf_min(arf_t res, const arf_t a, const arf_t b) noexcept - void arf_max(arf_t res, const arf_t a, const arf_t b) noexcept - # Sets *res* respectively to the minimum and the maximum of *a* and *b*. - slong arf_bits(const arf_t x) noexcept - # Returns the number of bits needed to represent the absolute value - # of the mantissa of *x*, i.e. the minimum precision sufficient to represent - # *x* exactly. Returns 0 if *x* is a special value. - bint arf_is_int(const arf_t x) noexcept - # Returns nonzero iff *x* is integer-valued. - bint arf_is_int_2exp_si(const arf_t x, slong e) noexcept - # Returns nonzero iff *x* equals `n 2^e` for some integer *n*. - void arf_abs_bound_lt_2exp_fmpz(fmpz_t res, const arf_t x) noexcept - # Sets *res* to the smallest integer *b* such that `|x| < 2^b`. - # If *x* is zero, infinity or NaN, the result is undefined. - void arf_abs_bound_le_2exp_fmpz(fmpz_t res, const arf_t x) noexcept - # Sets *res* to the smallest integer *b* such that `|x| \le 2^b`. - # If *x* is zero, infinity or NaN, the result is undefined. - slong arf_abs_bound_lt_2exp_si(const arf_t x) noexcept - # Returns the smallest integer *b* such that `|x| < 2^b`, clamping - # the result to lie between -*ARF_PREC_EXACT* and *ARF_PREC_EXACT* - # inclusive. If *x* is zero, -*ARF_PREC_EXACT* is returned, - # and if *x* is infinity or NaN, *ARF_PREC_EXACT* is returned. - void arf_get_mag(mag_t res, const arf_t x) noexcept - # Sets *res* to an upper bound for the absolute value of *x*. - void arf_get_mag_lower(mag_t res, const arf_t x) noexcept - # Sets *res* to a lower bound for the absolute value of *x*. - void arf_set_mag(arf_t res, const mag_t x) noexcept - # Sets *res* to *x*. This operation is exact. - void mag_init_set_arf(mag_t res, const arf_t x) noexcept - # Initializes *res* and sets it to an upper bound for *x*. - void mag_fast_init_set_arf(mag_t res, const arf_t x) noexcept - # Initializes *res* and sets it to an upper bound for *x*. - # Assumes that the exponent of *res* is small (this function is unsafe). - void arf_mag_set_ulp(mag_t res, const arf_t x, slong prec) noexcept - # Sets *res* to the magnitude of the unit in the last place (ulp) of *x* - # at precision *prec*. - void arf_mag_add_ulp(mag_t res, const mag_t x, const arf_t y, slong prec) noexcept - # Sets *res* to an upper bound for the sum of *x* and the - # magnitude of the unit in the last place (ulp) of *y* - # at precision *prec*. - void arf_mag_fast_add_ulp(mag_t res, const mag_t x, const arf_t y, slong prec) noexcept - # Sets *res* to an upper bound for the sum of *x* and the - # magnitude of the unit in the last place (ulp) of *y* - # at precision *prec*. Assumes that all exponents are small. - void arf_init_set_shallow(arf_t z, const arf_t x) noexcept - void arf_init_set_mag_shallow(arf_t z, const mag_t x) noexcept - # Initializes *z* to a shallow copy of *x*. A shallow copy just involves - # copying struct data (no heap allocation is performed). - # The target variable *z* may not be cleared or modified in any way (it can - # only be used as constant input to functions), and may not be used after - # *x* has been cleared. Moreover, after *x* has been assigned shallowly - # to *z*, no modification of *x* is permitted as slong as *z* is in use. - void arf_init_neg_shallow(arf_t z, const arf_t x) noexcept - void arf_init_neg_mag_shallow(arf_t z, const mag_t x) noexcept - # Initializes *z* shallowly to the negation of *x*. - void arf_randtest(arf_t res, flint_rand_t state, slong bits, slong mag_bits) noexcept - # Generates a finite random number whose mantissa has precision at most - # *bits* and whose exponent has at most *mag_bits* bits. The - # values are distributed non-uniformly: special bit patterns are generated - # with high probability in order to allow the test code to exercise corner - # cases. - void arf_randtest_not_zero(arf_t res, flint_rand_t state, slong bits, slong mag_bits) noexcept - # Identical to :func:`arf_randtest`, except that zero is never produced - # as an output. - void arf_randtest_special(arf_t res, flint_rand_t state, slong bits, slong mag_bits) noexcept - # Identical to :func:`arf_randtest`, except that the output occasionally - # is set to an infinity or NaN. - void arf_urandom(arf_t res, flint_rand_t state, slong bits, arf_rnd_t rnd) noexcept - # Sets *res* to a uniformly distributed random number in the interval - # `[0, 1]`. The method uses rounding from integers to floats based on the - # rounding mode *rnd*. - void arf_debug(const arf_t x) noexcept - # Prints information about the internal representation of *x*. - void arf_print(const arf_t x) noexcept - # Prints *x* as an integer mantissa and exponent. - void arf_printd(const arf_t x, slong d) noexcept - # Prints *x* as a decimal floating-point number, rounding to *d* digits. - # Rounding is faithful (at most 1 ulp error). - char * arf_get_str(const arf_t x, slong d) noexcept - # Returns *x* as a decimal floating-point number, rounding to *d* digits. - # Rounding is faithful (at most 1 ulp error). - void arf_fprint(FILE * file, const arf_t x) noexcept - # Prints *x* as an integer mantissa and exponent to the stream *file*. - void arf_fprintd(FILE * file, const arf_t y, slong d) noexcept - # Prints *x* as a decimal floating-point number to the stream *file*, - # rounding to *d* digits. - # Rounding is faithful (at most 1 ulp error). - char * arf_dump_str(const arf_t x) noexcept - # Allocates a string and writes a binary representation of *x* to it that can - # be read by :func:`arf_load_str`. The returned string needs to be - # deallocated with *flint_free*. - int arf_load_str(arf_t x, const char * str) noexcept - # Parses *str* into *x*. Returns a nonzero value if *str* is not formatted - # correctly. - int arf_dump_file(FILE * stream, const arf_t x) noexcept - # Writes a binary representation of *x* to *stream* that can be read by - # :func:`arf_load_file`. Returns a nonzero value if the data could not be - # written. - int arf_load_file(arf_t x, FILE * stream) noexcept - # Reads *x* from *stream*. Returns a nonzero value if the data is not - # formatted correctly or the read failed. Note that the data is assumed to be - # delimited by a whitespace or end-of-file, i.e., when writing multiple - # values with :func:`arf_dump_file` make sure to insert a whitespace to - # separate consecutive values. - void arf_abs(arf_t res, const arf_t x) noexcept - # Sets *res* to the absolute value of *x* exactly. - void arf_neg(arf_t res, const arf_t x) noexcept - # Sets *res* to `-x` exactly. - int arf_neg_round(arf_t res, const arf_t x, slong prec, arf_rnd_t rnd) noexcept - # Sets *res* to `-x`. - int arf_add(arf_t res, const arf_t x, const arf_t y, slong prec, arf_rnd_t rnd) noexcept - int arf_add_si(arf_t res, const arf_t x, slong y, slong prec, arf_rnd_t rnd) noexcept - int arf_add_ui(arf_t res, const arf_t x, ulong y, slong prec, arf_rnd_t rnd) noexcept - int arf_add_fmpz(arf_t res, const arf_t x, const fmpz_t y, slong prec, arf_rnd_t rnd) noexcept - # Sets *res* to `x + y`. - int arf_add_fmpz_2exp(arf_t res, const arf_t x, const fmpz_t y, const fmpz_t e, slong prec, arf_rnd_t rnd) noexcept - # Sets *res* to `x + y 2^e`. - int arf_sub(arf_t res, const arf_t x, const arf_t y, slong prec, arf_rnd_t rnd) noexcept - int arf_sub_si(arf_t res, const arf_t x, slong y, slong prec, arf_rnd_t rnd) noexcept - int arf_sub_ui(arf_t res, const arf_t x, ulong y, slong prec, arf_rnd_t rnd) noexcept - int arf_sub_fmpz(arf_t res, const arf_t x, const fmpz_t y, slong prec, arf_rnd_t rnd) noexcept - # Sets *res* to `x - y`. - void arf_mul_2exp_si(arf_t res, const arf_t x, slong e) noexcept - void arf_mul_2exp_fmpz(arf_t res, const arf_t x, const fmpz_t e) noexcept - # Sets *res* to `x 2^e` exactly. - int arf_mul(arf_t res, const arf_t x, const arf_t y, slong prec, arf_rnd_t rnd) noexcept - int arf_mul_ui(arf_t res, const arf_t x, ulong y, slong prec, arf_rnd_t rnd) noexcept - int arf_mul_si(arf_t res, const arf_t x, slong y, slong prec, arf_rnd_t rnd) noexcept - int arf_mul_mpz(arf_t res, const arf_t x, const mpz_t y, slong prec, arf_rnd_t rnd) noexcept - int arf_mul_fmpz(arf_t res, const arf_t x, const fmpz_t y, slong prec, arf_rnd_t rnd) noexcept - # Sets *res* to `x \cdot y`. - int arf_addmul(arf_t z, const arf_t x, const arf_t y, slong prec, arf_rnd_t rnd) noexcept - int arf_addmul_ui(arf_t z, const arf_t x, ulong y, slong prec, arf_rnd_t rnd) noexcept - int arf_addmul_si(arf_t z, const arf_t x, slong y, slong prec, arf_rnd_t rnd) noexcept - int arf_addmul_mpz(arf_t z, const arf_t x, const mpz_t y, slong prec, arf_rnd_t rnd) noexcept - int arf_addmul_fmpz(arf_t z, const arf_t x, const fmpz_t y, slong prec, arf_rnd_t rnd) noexcept - # Performs a fused multiply-add `z = z + x \cdot y`, updating *z* in-place. - int arf_submul(arf_t z, const arf_t x, const arf_t y, slong prec, arf_rnd_t rnd) noexcept - int arf_submul_ui(arf_t z, const arf_t x, ulong y, slong prec, arf_rnd_t rnd) noexcept - int arf_submul_si(arf_t z, const arf_t x, slong y, slong prec, arf_rnd_t rnd) noexcept - int arf_submul_mpz(arf_t z, const arf_t x, const mpz_t y, slong prec, arf_rnd_t rnd) noexcept - int arf_submul_fmpz(arf_t z, const arf_t x, const fmpz_t y, slong prec, arf_rnd_t rnd) noexcept - # Performs a fused multiply-subtract `z = z - x \cdot y`, updating *z* in-place. - int arf_fma(arf_t res, const arf_t x, const arf_t y, const arf_t z, slong prec, arf_rnd_t rnd) noexcept - # Sets *res* to `x \cdot y + z`. This is equivalent to an *addmul* except - # that *res* and *z* can be separate variables. - int arf_sosq(arf_t res, const arf_t x, const arf_t y, slong prec, arf_rnd_t rnd) noexcept - # Sets *res* to `x^2 + y^2`, rounded to *prec* bits in the direction specified by *rnd*. - int arf_sum(arf_t res, arf_srcptr terms, slong len, slong prec, arf_rnd_t rnd) noexcept - # Sets *res* to the sum of the array *terms* of length *len*, rounded to - # *prec* bits in the direction specified by *rnd*. The sum is computed as if - # done without any intermediate rounding error, with only a single rounding - # applied to the final result. Unlike repeated calls to :func:`arf_add` with - # infinite precision, this function does not overflow if the magnitudes of - # the terms are far apart. Warning: this function is implemented naively, - # and the running time is quadratic with respect to *len* in the worst case. - void arf_approx_dot(arf_t res, const arf_t initial, int subtract, arf_srcptr x, slong xstep, arf_srcptr y, slong ystep, slong len, slong prec, arf_rnd_t rnd) noexcept - # Computes an approximate dot product, with the same meaning of - # the parameters as :func:`arb_dot`. - # This operation is not correctly rounded: the final rounding is done - # in the direction ``rnd`` but intermediate roundings are - # implementation-defined. - int arf_div(arf_t res, const arf_t x, const arf_t y, slong prec, arf_rnd_t rnd) noexcept - int arf_div_ui(arf_t res, const arf_t x, ulong y, slong prec, arf_rnd_t rnd) noexcept - int arf_ui_div(arf_t res, ulong x, const arf_t y, slong prec, arf_rnd_t rnd) noexcept - int arf_div_si(arf_t res, const arf_t x, slong y, slong prec, arf_rnd_t rnd) noexcept - int arf_si_div(arf_t res, slong x, const arf_t y, slong prec, arf_rnd_t rnd) noexcept - int arf_div_fmpz(arf_t res, const arf_t x, const fmpz_t y, slong prec, arf_rnd_t rnd) noexcept - int arf_fmpz_div(arf_t res, const fmpz_t x, const arf_t y, slong prec, arf_rnd_t rnd) noexcept - int arf_fmpz_div_fmpz(arf_t res, const fmpz_t x, const fmpz_t y, slong prec, arf_rnd_t rnd) noexcept - # Sets *res* to `x / y`, rounded to *prec* bits in the direction specified by *rnd*, - # returning nonzero iff the operation is inexact. The result is NaN if *y* is zero. - int arf_sqrt(arf_t res, const arf_t x, slong prec, arf_rnd_t rnd) noexcept - int arf_sqrt_ui(arf_t res, ulong x, slong prec, arf_rnd_t rnd) noexcept - int arf_sqrt_fmpz(arf_t res, const fmpz_t x, slong prec, arf_rnd_t rnd) noexcept - # Sets *res* to `\sqrt{x}`. The result is NaN if *x* is negative. - int arf_rsqrt(arf_t res, const arf_t x, slong prec, arf_rnd_t rnd) noexcept - # Sets *res* to `1/\sqrt{x}`. The result is NaN if *x* is - # negative, and `+\infty` if *x* is zero. - int arf_root(arf_t res, const arf_t x, ulong k, slong prec, arf_rnd_t rnd) noexcept - # Sets *res* to `x^{1/k}`. The result is NaN if *x* is negative. - # Warning: this function is a wrapper around the MPFR root function. - # It gets slow and uses much memory for large *k*. - # Consider working with :func:`arb_root_ui` for large *k* instead of using this - # function directly. - 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) noexcept - 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) noexcept - # Computes the complex product `e + fi = (a + bi)(c + di)`, rounding both - # `e` and `f` correctly to *prec* bits in the direction specified by *rnd*. - # The first bit in the return code indicates inexactness of `e`, and the - # second bit indicates inexactness of `f`. - # If any of the components *a*, *b*, *c*, *d* is zero, two real - # multiplications and no additions are done. This convention is used even - # if any other part contains an infinity or NaN, and the behavior - # with infinite/NaN input is defined accordingly. - # The *fallback* version is implemented naively, for testing purposes. - # No squaring optimization is implemented. - int arf_complex_sqr(arf_t e, arf_t f, const arf_t a, const arf_t b, slong prec, arf_rnd_t rnd) noexcept - # Computes the complex square `e + fi = (a + bi)^2`. This function has - # identical semantics to :func:`arf_complex_mul` (with `c = a, b = d`), - # but is faster. - int _arf_get_integer_mpn(mp_ptr y, mp_srcptr xp, mp_size_t xn, slong exp) noexcept - # Given a floating-point number *x* represented by *xn* limbs at *xp* - # and an exponent *exp*, writes the integer part of *x* to - # *y*, returning whether the result is inexact. - # The correct number of limbs is written (no limbs are written - # if the integer part of *x* is zero). - # Assumes that ``xp[0]`` is nonzero and that the - # top bit of ``xp[xn-1]`` is set. - 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) noexcept - # Sets *z* to the fixed-point number having *xn* total limbs and *fixn* - # fractional limbs, negated if *negative* is set, rounding *z* to *prec* - # bits in the direction *rnd* and returning whether the result is inexact. - # Both *xn* and *fixn* must be nonnegative and not so large - # that the bit shift would overflow an *slong*, but otherwise no - # assumptions are made about the input. - int _arf_set_round_ui(arf_t z, ulong x, int sgnbit, slong prec, arf_rnd_t rnd) noexcept - # Sets *z* to the integer *x*, negated if *sgnbit* is 1, rounded to *prec* - # bits in the direction specified by *rnd*. There are no assumptions on *x*. - 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) noexcept - # Sets the mantissa of *z* to the two-limb mantissa given by *hi* and *lo*, - # negated if *sgnbit* is 1, rounded to *prec* bits in the direction specified - # by *rnd*. Requires that not both *hi* and *lo* are zero. - # Writes the exponent shift to *fix* without writing the exponent of *z* - # directly. - 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) noexcept - # Sets the mantissa of *z* to the mantissa given by the *xn* limbs in *x*, - # negated if *sgnbit* is 1, rounded to *prec* bits in the direction - # specified by *rnd*. Returns the inexact flag. Requires that *xn* is positive - # and that the top limb of *x* is nonzero. If *x* has leading zero bits, - # writes the shift to *exp_shift*. This method does not write the exponent of - # *z* directly. Requires that *x* does not point to the limbs of *z*. diff --git a/src/sage/libs/flint/arith.pxd b/src/sage/libs/flint/arith.pxd index 5a4b5f3d06d..70e7f5e5d29 100644 --- a/src/sage/libs/flint/arith.pxd +++ b/src/sage/libs/flint/arith.pxd @@ -2,7 +2,9 @@ # distutils: depends = flint/arith.h ################################################################################ -# This file is auto-generated. Do not modify by hand +# This file is auto-generated by the script +# SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py. +# Do not modify by hand! Fix and rerun the script instead. ################################################################################ from libc.stdio cimport FILE @@ -11,388 +13,62 @@ from sage.libs.mpfr.types cimport * from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void arith_primorial(fmpz_t res, slong n) noexcept - # Sets ``res`` to ``n`` primorial or `n \#`, the product of all prime - # numbers less than or equal to `n`. - void _arith_harmonic_number(fmpz_t num, fmpz_t den, slong n) noexcept void arith_harmonic_number(fmpq_t x, slong n) noexcept - # These are aliases for the functions in the fmpq module. - void arith_stirling_number_1u(fmpz_t s, ulong n, ulong k) noexcept - void arith_stirling_number_1(fmpz_t s, ulong n, ulong k) noexcept - void arith_stirling_number_2(fmpz_t s, ulong n, ulong k) noexcept - # Sets `s` to `S(n,k)` where `S(n,k)` denotes an unsigned Stirling - # number of the first kind `|S_1(n, k)|`, a signed Stirling number - # of the first kind `S_1(n, k)`, or a Stirling number of the second - # kind `S_2(n, k)`. The Stirling numbers are defined using the - # generating functions - # .. math :: - # x_{(n)} = \sum_{k=0}^n S_1(n,k) x^k - # x^{(n)} = \sum_{k=0}^n |S_1(n,k)| x^k - # x^n = \sum_{k=0}^n S_2(n,k) x_{(k)} - # where `x_{(n)} = x(x-1)(x-2) \dotsm (x-n+1)` is a falling factorial - # and `x^{(n)} = x(x+1)(x+2) \dotsm (x+n-1)` is a rising factorial. - # `S(n,k)` is taken to be zero if `n < 0` or `k < 0`. - # These three functions are useful for computing isolated Stirling - # numbers efficiently. To compute a range of numbers, the vector or - # matrix versions should generally be used. - void arith_stirling_number_1u_vec(fmpz * row, ulong n, slong klen) noexcept - void arith_stirling_number_1_vec(fmpz * row, ulong n, slong klen) noexcept - void arith_stirling_number_2_vec(fmpz * row, ulong n, slong klen) noexcept - # Computes the row of Stirling numbers - # ``S(n,0), S(n,1), S(n,2), ..., S(n,klen-1)``. - # To compute a full row, this function can be called with - # ``klen = n+1``. It is assumed that ``klen`` is at most `n + 1`. - void arith_stirling_number_1u_vec_next(fmpz * row, const fmpz * prev, slong n, slong klen) noexcept - void arith_stirling_number_1_vec_next(fmpz * row, const fmpz * prev, slong n, slong klen) noexcept - void arith_stirling_number_2_vec_next(fmpz * row, const fmpz * prev, slong n, slong klen) noexcept - # Given the vector ``prev`` containing a row of Stirling numbers - # ``S(n-1,0), S(n-1,1), S(n-1,2), ..., S(n-1,klen-1)``, computes - # and stores in the row argument - # ``S(n,0), S(n,1), S(n,2), ..., S(n,klen-1)``. - # If ``klen`` is greater than ``n``, the output ends with - # ``S(n,n) = 1`` followed by ``S(n,n+1) = S(n,n+2) = ... = 0``. - # In this case, the input only needs to have length ``n-1``; - # only the input entries up to ``S(n-1,n-2)`` are read. - # The ``row`` and ``prev`` arguments are permitted to be the - # same, meaning that the row will be updated in-place. - void arith_stirling_matrix_1u(fmpz_mat_t mat) noexcept - void arith_stirling_matrix_1(fmpz_mat_t mat) noexcept - void arith_stirling_matrix_2(fmpz_mat_t mat) noexcept - # For an arbitrary `m`-by-`n` matrix, writes the truncation of the - # infinite Stirling number matrix:: - # row 0 : S(0,0) - # row 1 : S(1,0), S(1,1) - # row 2 : S(2,0), S(2,1), S(2,2) - # row 3 : S(3,0), S(3,1), S(3,2), S(3,3) - # up to row `m-1` and column `n-1` inclusive. The upper triangular - # part of the matrix is zeroed. - # For any `n`, the `S_1` and `S_2` matrices thus obtained are - # inverses of each other. - void arith_bell_number(fmpz_t b, ulong n) noexcept void arith_bell_number_dobinski(fmpz_t res, ulong n) noexcept void arith_bell_number_multi_mod(fmpz_t res, ulong n) noexcept - # Sets `b` to the Bell number `B_n`, defined as the - # number of partitions of a set with `n` members. Equivalently, - # `B_n = \sum_{k=0}^n S_2(n,k)` where `S_2(n,k)` denotes a Stirling number - # of the second kind. - # The default version automatically selects between table lookup, - # Dobinski's formula, and the multimodular algorithm. - # The ``dobinski`` version evaluates a precise truncation of - # the series `B_n = e^{-1} \sum_{k=0}^{\infty} \frac{k^n}{k!}` - # (Dobinski's formula). In fact, we compute `P = N! \sum_{k=0}^N \frac{k^n}{k!}` - # and `Q = N! \sum_{k=0}^N \frac{1}{k!} \approx N! e` and - # evaluate `B_n = \lceil P / Q \rceil`, avoiding the use - # of floating-point arithmetic. - # The ``multi_mod`` version computes the result modulo several limb-size - # primes and reconstructs the integer value using the fast - # Chinese remainder algorithm. - # A bound for the number of needed primes is computed using - # ``arith_bell_number_size``. - void arith_bell_number_vec(fmpz * b, slong n) noexcept void arith_bell_number_vec_recursive(fmpz * b, slong n) noexcept void arith_bell_number_vec_multi_mod(fmpz * b, slong n) noexcept - # Sets `b` to the vector of Bell numbers `B_0, B_1, \ldots, B_{n-1}` - # inclusive. The ``recursive`` version uses the `O(n^3 \log n)` - # triangular recurrence, while the ``multi_mod`` version implements - # multimodular evaluation of the exponential generating function, - # running in time `O(n^2 \log^{O(1)} n)`. The default version - # chooses an algorithm automatically. - mp_limb_t arith_bell_number_nmod(ulong n, nmod_t mod) noexcept - # Computes the Bell number `B_n` modulo an integer given by ``mod``. - # After handling special cases, we use the formula - # .. math :: - # B_n = \sum_{k=0}^n \frac{(n-k)^n}{(n-k)!} - # \sum_{j=0}^k \frac{(-1)^j}{j!}. - # We arrange the operations in such a way that we only have to - # multiply (and not divide) in the main loop. As a further optimisation, - # we use sieving to reduce the number of powers that need to be - # evaluated. This results in `O(n)` memory usage. - # If the divisions by factorials are impossible, we fall back to - # calling ``arith_bell_number_nmod_vec`` and reading the last - # coefficient. - void arith_bell_number_nmod_vec(mp_ptr b, slong n, nmod_t mod) noexcept void arith_bell_number_nmod_vec_recursive(mp_ptr b, slong n, nmod_t mod) noexcept void arith_bell_number_nmod_vec_ogf(mp_ptr b, slong n, nmod_t mod) noexcept int arith_bell_number_nmod_vec_series(mp_ptr b, slong n, nmod_t mod) noexcept - # Sets `b` to the vector of Bell numbers `B_0, B_1, \ldots, B_{n-1}` - # inclusive modulo an integer given by ``mod``. - # The *recursive* version uses the `O(n^2)` triangular recurrence. - # The *ogf* version expands the ordinary generating function - # using binary splitting, which is `O(n \log^2 n)`. - # The *series* version uses the exponential generating function - # `\sum_{k=0}^{\infty} \frac{B_n}{n!} x^n = \exp(e^x-1)`, - # running in `O(n \log n)`. - # This only works if division by `n!` is possible, and the function - # returns whether it is successful. All other versions - # support any modulus. - # The default version of this function selects an algorithm - # automatically. - double arith_bell_number_size(ulong n) noexcept - # Returns `b` such that `B_n < 2^{\lfloor b \rfloor}`. A previous - # version of this function used the inequality - # `B_n < \left(\frac{0.792n}{\log(n+1)}\right)^n` which is given - # in [BerTas2010]_; we now use a slightly better bound - # based on an asymptotic expansion. - void _arith_bernoulli_number(fmpz_t num, fmpz_t den, ulong n) noexcept - # Sets ``(num, den)`` to the reduced numerator and denominator - # of the `n`-th Bernoulli number. - void arith_bernoulli_number(fmpq_t x, ulong n) noexcept - # Sets ``x`` to the `n`-th Bernoulli number. This function is - # equivalent to ``_arith_bernoulli_number`` apart from the output - # being a single ``fmpq_t`` variable. - void _arith_bernoulli_number_vec(fmpz * num, fmpz * den, slong n) noexcept - # Sets the elements of ``num`` and ``den`` to the reduced - # numerators and denominators of the Bernoulli numbers - # `B_0, B_1, B_2, \ldots, B_{n-1}` inclusive. This function automatically - # chooses between the ``recursive``, ``zeta`` and ``multi_mod`` - # algorithms according to the size of `n`. - void arith_bernoulli_number_vec(fmpq * x, slong n) noexcept - # Sets the ``x`` to the vector of Bernoulli numbers - # `B_0, B_1, B_2, \ldots, B_{n-1}` inclusive. This function is - # equivalent to ``_arith_bernoulli_number_vec`` apart - # from the output being a single ``fmpq`` vector. - void arith_bernoulli_number_denom(fmpz_t den, ulong n) noexcept - # Sets ``den`` to the reduced denominator of the `n`-th - # Bernoulli number `B_n`. For even `n`, the denominator is computed - # as the product of all primes `p` for which `p - 1` divides `n`; - # this property is a consequence of the von Staudt-Clausen theorem. - # For odd `n`, the denominator is trivial (``den`` is set to 1 whenever - # `B_n = 0`). The initial sequence of values smaller than `2^{32}` are - # looked up directly from a table. - double arith_bernoulli_number_size(ulong n) noexcept - # Returns `b` such that `|B_n| < 2^{\lfloor b \rfloor}`, using the inequality - # `|B_n| < \frac{4 n!}{(2\pi)^n}` and `n! \le (n+1)^{n+1} e^{-n}`. - # No special treatment is given to odd `n`. Accuracy is not guaranteed - # if `n > 10^{14}`. - void arith_bernoulli_polynomial(fmpq_poly_t poly, ulong n) noexcept - # Sets ``poly`` to the Bernoulli polynomial of degree `n`, - # `B_n(x) = \sum_{k=0}^n \binom{n}{k} B_k x^{n-k}` where `B_k` - # is a Bernoulli number. This function basically calls - # ``arith_bernoulli_number_vec`` and then rescales the coefficients - # efficiently. - void _arith_bernoulli_number_vec_recursive(fmpz * num, fmpz * den, slong n) noexcept - # Sets the elements of ``num`` and ``den`` to the reduced - # numerators and denominators of `B_0, B_1, B_2, \ldots, B_{n-1}` - # inclusive. - # The first few entries are computed using ``arith_bernoulli_number``, - # and then Ramanujan's recursive formula expressing `B_m` as a sum over - # `B_k` for `k` congruent to `m` modulo 6 is applied repeatedly. - # To avoid costly GCDs, the numerators are transformed internally - # to a common denominator and all operations are performed using - # integer arithmetic. This makes the algorithm fast for small `n`, - # say `n < 1000`. The common denominator is calculated directly - # as the primorial of `n + 1`. - # %[1] https://en.wikipedia.org/w/index.php?title=Bernoulli_number&oldid=405938876 - void _arith_bernoulli_number_vec_multi_mod(fmpz * num, fmpz * den, slong n) noexcept - # Sets the elements of ``num`` and ``den`` to the reduced - # numerators and denominators of `B_0, B_1, B_2, \ldots, B_{n-1}` - # inclusive. Uses the generating function - # .. math :: - # \frac{x^2}{\cosh(x)-1} = \sum_{k=0}^{\infty} - # \frac{(2-4k) B_{2k}}{(2k)!} x^{2k} - # which is evaluated modulo several limb-size primes using ``nmod_poly`` - # arithmetic to yield the numerators of the Bernoulli numbers after - # multiplication by the denominators and CRT reconstruction. This formula, - # given (incorrectly) in [BuhlerCrandallSompolski1992]_, saves about - # half of the time compared to the usual generating function `x/(e^x-1)` - # since the odd terms vanish. - void arith_euler_number(fmpz_t res, ulong n) noexcept - # Sets ``res`` to the Euler number `E_n`. - void arith_euler_number_vec(fmpz * res, slong n) noexcept - # Computes the Euler numbers `E_0, E_1, \dotsc, E_{n-1}` for `n \geq 0` - # and stores the result in ``res``, which must be an initialised - # ``fmpz`` vector of sufficient size. - # This function evaluates the even-index `E_k` modulo several limb-size - # primes using the generating function and ``nmod_poly`` arithmetic. - # A tight bound for the number of needed primes is computed using - # ``arith_euler_number_size``, and the final integer values are recovered - # using balanced CRT reconstruction. - double arith_euler_number_size(ulong n) noexcept - # Returns `b` such that `|E_n| < 2^{\lfloor b \rfloor}`, using the inequality - # ``|E_n| < \frac{2^{n+2} n!}{\pi^{n+1}}`` and `n! \le (n+1)^{n+1} e^{-n}`. - # No special treatment is given to odd `n`. - # Accuracy is not guaranteed if `n > 10^{14}`. - void arith_euler_polynomial(fmpq_poly_t poly, ulong n) noexcept - # Sets ``poly`` to the Euler polynomial `E_n(x)`. Uses the formula - # .. math :: - # E_n(x) = \frac{2}{n+1}\left(B_{n+1}(x) - - # 2^{n+1}B_{n+1}\left(\frac{x}{2}\right)\right), - # with the Bernoulli polynomial `B_{n+1}(x)` evaluated once - # using ``bernoulli_polynomial`` and then rescaled. - void arith_euler_phi(fmpz_t res, const fmpz_t n) noexcept int arith_moebius_mu(const fmpz_t n) noexcept void arith_divisor_sigma(fmpz_t res, ulong k, const fmpz_t n) noexcept - # These are aliases for the functions in the fmpz module. - void arith_divisors(fmpz_poly_t res, const fmpz_t n) noexcept - # Set the coefficients of the polynomial ``res`` to the divisors of `n`, - # including `1` and `n` itself, in ascending order. - void arith_ramanujan_tau(fmpz_t res, const fmpz_t n) noexcept - # Sets ``res`` to the Ramanujan tau function `\tau(n)` which is the - # coefficient of `q^n` in the series expansion of - # `f(q) = q \prod_{k \geq 1} \bigl(1 - q^k\bigr)^{24}`. - # We factor `n` and use the identity `\tau(pq) = \tau(p) \tau(q)` - # along with the recursion - # `\tau(p^{r+1}) = \tau(p) \tau(p^r) - p^{11} \tau(p^{r-1})` - # for prime powers. - # The base values `\tau(p)` are obtained using the function - # ``arith_ramanujan_tau_series()``. Thus the speed of - # ``arith_ramanujan_tau()`` depends on the largest prime factor of `n`. - # Future improvement: optimise this function for small `n`, which - # could be accomplished using a lookup table or by calling - # ``arith_ramanujan_tau_series()`` directly. - void arith_ramanujan_tau_series(fmpz_poly_t res, slong n) noexcept - # Sets ``res`` to the polynomial with coefficients - # `\tau(0),\tau(1), \dotsc, \tau(n-1)`, giving the initial `n` terms - # in the series expansion of - # `f(q) = q \prod_{k \geq 1} \bigl(1-q^k\bigr)^{24}`. - # We use the theta function identity - # .. math :: - # f(q) = q \Biggl( \sum_{k \geq 0} (-1)^k (2k+1) q^{k(k+1)/2} \Biggr)^8 - # which is evaluated using three squarings. The first squaring is done - # directly since the polynomial is very sparse at this point. - void arith_landau_function_vec(fmpz * res, slong len) noexcept - # Computes the first ``len`` values of Landau's function `g(n)` - # starting with `g(0)`. Landau's function gives the largest order - # of an element of the symmetric group `S_n`. - # Implements the "basic algorithm" given in - # [DelegliseNicolasZimmermann2009]_. The running time is - # `O(n^{3/2} / \sqrt{\log n})`. - void arith_dedekind_sum_naive(fmpq_t s, const fmpz_t h, const fmpz_t k) noexcept double arith_dedekind_sum_coprime_d(double h, double k) noexcept void arith_dedekind_sum_coprime_large(fmpq_t s, const fmpz_t h, const fmpz_t k) noexcept void arith_dedekind_sum_coprime(fmpq_t s, const fmpz_t h, const fmpz_t k) noexcept void arith_dedekind_sum(fmpq_t s, const fmpz_t h, const fmpz_t k) noexcept - # These are aliases for the functions in the fmpq module. - void arith_number_of_partitions_vec(fmpz * res, slong len) noexcept - # Computes first ``len`` values of the partition function `p(n)` - # starting with `p(0)`. Uses inversion of Euler's pentagonal series. - void arith_number_of_partitions_nmod_vec(mp_ptr res, slong len, nmod_t mod) noexcept - # Computes first ``len`` values of the partition function `p(n)` - # starting with `p(0)`, modulo the modulus defined by ``mod``. - # Uses inversion of Euler's pentagonal series. - void arith_hrr_expsum_factored(trig_prod_t prod, mp_limb_t k, mp_limb_t n) noexcept - # Symbolically evaluates the exponential sum - # .. math :: - # A_k(n) = \sum_{h=0}^{k-1} - # \exp\left(\pi i \left[ s(h,k) - \frac{2hn}{k}\right]\right) - # appearing in the Hardy-Ramanujan-Rademacher formula, where `s(h,k)` is a - # Dedekind sum. - # Rather than evaluating the sum naively, we factor `A_k(n)` into a - # product of cosines based on the prime factorisation of `k`. This - # process is based on the identities given in [Whiteman1956]_. - # The special ``trig_prod_t`` structure ``prod`` represents a - # product of cosines of rational arguments, multiplied by an algebraic - # prefactor. It must be pre-initialised with ``trig_prod_init``. - # This function assumes that `24k` and `24n` do not overflow a single limb. - # If `n` is larger, it can be pre-reduced modulo `k`, since `A_k(n)` - # only depends on the value of `n \bmod k`. - void arith_number_of_partitions_mpfr(mpfr_t x, ulong n) noexcept - # Sets the pre-initialised MPFR variable `x` to the exact value of `p(n)`. - # The value is computed using the Hardy-Ramanujan-Rademacher formula. - # The precision of `x` will be changed to allow `p(n)` to be represented - # exactly. The interface of this function may be updated in the future - # to allow computing an approximation of `p(n)` to smaller precision. - # The Hardy-Ramanujan-Rademacher formula is given with error bounds - # in [Rademacher1937]_. We evaluate it in the form - # .. math :: - # p(n) = \sum_{k=1}^N B_k(n) U(C/k) + R(n,N) - # where - # .. math :: - # U(x) = \cosh(x) + \frac{\sinh(x)}{x}, - # \quad C = \frac{\pi}{6} \sqrt{24n-1} - # B_k(n) = \sqrt{\frac{3}{k}} \frac{4}{24n-1} A_k(n) - # and where `A_k(n)` is a certain exponential sum. The remainder satisfies - # .. math :: - # |R(n,N)| < \frac{44 \pi^2}{225 \sqrt{3}} N^{-1/2} + - # \frac{\pi \sqrt{2}}{75} \left(\frac{N}{n-1}\right)^{1/2} - # \sinh\left(\pi \sqrt{\frac{2}{3}} \frac{\sqrt{n}}{N} \right). - # We choose `N` such that `|R(n,N)| < 0.25`, and a working precision - # at term `k` such that the absolute error of the term is expected to be - # less than `0.25 / N`. We also use a summation variable with increased - # precision, essentially making additions exact. Thus the sum of errors - # adds up to less than 0.5, giving the correct value of `p(n)` when - # rounding to the nearest integer. - # The remainder estimate at step `k` provides an upper bound for the size - # of the `k`-th term. We add `\log_2 N` bits to get low bits in the terms - # below `0.25 / N` in magnitude. - # Using ``arith_hrr_expsum_factored``, each `B_k(n)` evaluation - # is broken down to a product of cosines of exact rational multiples - # of `\pi`. We transform all angles to `(0, \pi/4)` for optimal accuracy. - # Since the evaluation of each term involves only `O(\log k)` multiplications - # and evaluations of trigonometric functions of small angles, the - # relative rounding error is at most a few bits. We therefore just add - # an additional `\log_2 (C/k)` bits for the `U(x)` when `x` is large. - # The cancellation of terms in `U(x)` is of no concern, since Rademacher's - # bound allows us to terminate before `x` becomes small. - # This analysis should be performed in more detail to give a rigorous - # error bound, but the precision currently implemented is almost - # certainly sufficient, not least considering that Rademacher's - # remainder bound significantly overshoots the actual values. - # To improve performance, we switch to doubles when the working precision - # becomes small enough. We also use a separate accumulator variable - # which gets added to the main sum periodically, in order to avoid - # costly updates of the full-precision result when `n` is large. - void arith_number_of_partitions(fmpz_t x, ulong n) noexcept - # Sets `x` to `p(n)`, the number of ways that `n` can be written - # as a sum of positive integers without regard to order. - # This function uses a lookup table for `n < 128` (where `p(n) < 2^{32}`), - # and otherwise calls ``arith_number_of_partitions_mpfr``. - void arith_sum_of_squares(fmpz_t r, ulong k, const fmpz_t n) noexcept - # Sets `r` to the number of ways `r_k(n)` in which `n` can be represented - # as a sum of `k` squares. - # If `k = 2` or `k = 4`, we write `r_k(n)` as a divisor sum. - # Otherwise, we either recurse on `k` or compute the theta function - # expansion up to `O(x^{n+1})` and read off the last coefficient. - # This is generally optimal. - void arith_sum_of_squares_vec(fmpz * r, ulong k, slong n) noexcept - # For `i = 0, 1, \ldots, n-1`, sets `r_i` to the number of - # representations of `i` a sum of `k` squares, `r_k(i)`. - # This effectively computes the `q`-expansion of `\vartheta_3(q)` - # raised to the `k`-th power, i.e. - # .. math :: - # \vartheta_3^k(q) = \left( \sum_{i=-\infty}^{\infty} q^{i^2} \right)^k. diff --git a/src/sage/libs/flint/bernoulli.pxd b/src/sage/libs/flint/bernoulli.pxd index fa07fb100e0..edbff6fb26e 100644 --- a/src/sage/libs/flint/bernoulli.pxd +++ b/src/sage/libs/flint/bernoulli.pxd @@ -2,7 +2,9 @@ # distutils: depends = flint/bernoulli.h ################################################################################ -# This file is auto-generated. Do not modify by hand +# This file is auto-generated by the script +# SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py. +# Do not modify by hand! Fix and rerun the script instead. ################################################################################ from libc.stdio cimport FILE @@ -11,71 +13,14 @@ from sage.libs.mpfr.types cimport * from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void bernoulli_rev_init(bernoulli_rev_t it, ulong n) noexcept - # Initializes the iterator *iter*. The first Bernoulli number to - # be generated by calling :func:`bernoulli_rev_next` is `B_n`. - # It is assumed that `n` is even. - void bernoulli_rev_next(fmpz_t numer, fmpz_t denom, bernoulli_rev_t it) noexcept - # Sets *numer* and *denom* to the exact, reduced numerator and denominator - # of the Bernoulli number `B_k` and advances the state of *iter* - # so that the next invocation generates `B_{k-2}`. - void bernoulli_rev_clear(bernoulli_rev_t it) noexcept - # Frees all memory allocated internally by *iter*. - void bernoulli_fmpq_vec_no_cache(fmpq * res, ulong a, slong num) noexcept - # Writes *num* consecutive Bernoulli numbers to *res* starting - # with `B_a`. This function is not currently optimized for a small - # count *num*. The entries are not read from or written - # to the Bernoulli number cache; if retrieving a vector of - # Bernoulli numbers is needed more than once, - # use :func:`bernoulli_cache_compute` - # followed by :func:`bernoulli_fmpq_ui` instead. - # This function is a wrapper for the *rev* iterators. It can use - # multiple threads internally. - void bernoulli_cache_compute(slong n) noexcept - # Makes sure that the Bernoulli numbers up to at least `B_{n-1}` are cached. - # Calling :func:`flint_cleanup()` frees the cache. - # The cache is extended by calling :func:`bernoulli_fmpq_vec_no_cache` - # internally. - slong bernoulli_bound_2exp_si(ulong n) noexcept - # Returns an integer `b` such that `|B_n| \le 2^b`. Uses a lookup table - # for small `n`, and for larger `n` uses the inequality - # `|B_n| < 4 n! / (2 \pi)^n < 4 (n+1)^{n+1} e^{-n} / (2 \pi)^n`. - # Uses integer arithmetic throughout, with the bound for the logarithm - # being looked up from a table. If `|B_n| = 0`, returns *LONG_MIN*. - # Otherwise, the returned exponent `b` is never more than one percent - # larger than the true magnitude. - # This function is intended for use when `n` small enough that one might - # comfortably compute `B_n` exactly. It aborts if `n` is so large that - # internal overflow occurs. - ulong bernoulli_mod_p_harvey(ulong n, ulong p) noexcept - # Returns the `B_n` modulo the prime number *p*, computed using - # Harvey's algorithm [Har2010]_. The running time is linear in *p*. - # If *p* divides the numerator of `B_n`, *UWORD_MAX* is returned - # as an error code. - void _bernoulli_fmpq_ui_zeta(fmpz_t num, fmpz_t den, ulong n) noexcept void _bernoulli_fmpq_ui_multi_mod(fmpz_t num, fmpz_t den, ulong n, double alpha) noexcept - # Sets *num* and *den* to the reduced numerator and denominator - # of the Bernoulli number `B_n`. - # The *zeta* version computes the denominator `d` using the von Staudt-Clausen - # theorem, numerically approximates `B_n` using :func:`arb_bernoulli_ui_zeta`, - # and then rounds `d B_n` to the correct numerator. - # The *multi_mod* version reconstructs `B_n` by computing the high bits - # via the Riemann zeta function and the low bits via Harvey's multimodular - # algorithm. The tuning parameter *alpha* should be a fraction between - # 0 and 1 controlling the number of bits to compute by the multimodular - # algorithm. If set to a negative number, a default value will be used. - void _bernoulli_fmpq_ui(fmpz_t num, fmpz_t den, ulong n) noexcept void bernoulli_fmpq_ui(fmpq_t b, ulong n) noexcept - # Computes the Bernoulli number `B_n` as an exact fraction, for an - # isolated integer `n`. This function reads `B_n` from the global cache - # if the number is already cached, but does not automatically extend - # the cache by itself. diff --git a/src/sage/libs/flint/bool_mat.pxd b/src/sage/libs/flint/bool_mat.pxd index 11ecdb2809d..0ef3b44feb8 100644 --- a/src/sage/libs/flint/bool_mat.pxd +++ b/src/sage/libs/flint/bool_mat.pxd @@ -2,7 +2,9 @@ # distutils: depends = flint/bool_mat.h ################################################################################ -# This file is auto-generated. Do not modify by hand +# This file is auto-generated by the script +# SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py. +# Do not modify by hand! Fix and rerun the script instead. ################################################################################ from libc.stdio cimport FILE @@ -11,152 +13,38 @@ from sage.libs.mpfr.types cimport * from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - int bool_mat_get_entry(const bool_mat_t mat, slong i, slong j) noexcept - # Returns the entry of matrix *mat* at row *i* and column *j*. - void bool_mat_set_entry(bool_mat_t mat, slong i, slong j, int x) noexcept - # Sets the entry of matrix *mat* at row *i* and column *j* to *x*. - void bool_mat_init(bool_mat_t mat, slong r, slong c) noexcept - # Initializes the matrix, setting it to the zero matrix with *r* rows - # and *c* columns. - void bool_mat_clear(bool_mat_t mat) noexcept - # Clears the matrix, deallocating all entries. - bint bool_mat_is_empty(const bool_mat_t mat) noexcept - # Returns nonzero iff the number of rows or the number of columns in *mat* - # is zero. Note that this does not depend on the entry values of *mat*. - bint bool_mat_is_square(const bool_mat_t mat) noexcept - # Returns nonzero iff the number of rows is equal to the number of columns in *mat*. - void bool_mat_set(bool_mat_t dest, const bool_mat_t src) noexcept - # Sets *dest* to *src*. The operands must have identical dimensions. - void bool_mat_print(const bool_mat_t mat) noexcept - # Prints each entry in the matrix. - void bool_mat_fprint(FILE * file, const bool_mat_t mat) noexcept - # Prints each entry in the matrix to the stream *file*. - bint bool_mat_equal(const bool_mat_t mat1, const bool_mat_t mat2) noexcept - # Returns nonzero iff the matrices have the same dimensions - # and identical entries. - int bool_mat_any(const bool_mat_t mat) noexcept - # Returns nonzero iff *mat* has a nonzero entry. - int bool_mat_all(const bool_mat_t mat) noexcept - # Returns nonzero iff all entries of *mat* are nonzero. - bint bool_mat_is_diagonal(const bool_mat_t A) noexcept - # Returns nonzero iff `i \ne j \implies \bar{A_{ij}}`. - bint bool_mat_is_lower_triangular(const bool_mat_t A) noexcept - # Returns nonzero iff `i < j \implies \bar{A_{ij}}`. - bint bool_mat_is_transitive(const bool_mat_t mat) noexcept - # Returns nonzero iff `A_{ij} \wedge A_{jk} \implies A_{ik}`. - bint bool_mat_is_nilpotent(const bool_mat_t A) noexcept - # Returns nonzero iff some positive matrix power of `A` is zero. - void bool_mat_randtest(bool_mat_t mat, flint_rand_t state) noexcept - # Sets *mat* to a random matrix. - void bool_mat_randtest_diagonal(bool_mat_t mat, flint_rand_t state) noexcept - # Sets *mat* to a random diagonal matrix. - void bool_mat_randtest_nilpotent(bool_mat_t mat, flint_rand_t state) noexcept - # Sets *mat* to a random nilpotent matrix. - void bool_mat_zero(bool_mat_t mat) noexcept - # Sets all entries in mat to zero. - void bool_mat_one(bool_mat_t mat) noexcept - # Sets the entries on the main diagonal to ones, - # and all other entries to zero. - void bool_mat_directed_path(bool_mat_t A) noexcept - # Sets `A_{ij}` to `j = i + 1`. - # Requires that `A` is a square matrix. - void bool_mat_directed_cycle(bool_mat_t A) noexcept - # Sets `A_{ij}` to `j = (i + 1) \mod n` - # where `n` is the order of the square matrix `A`. - void bool_mat_transpose(bool_mat_t dest, const bool_mat_t src) noexcept - # Sets *dest* to the transpose of *src*. The operands must have - # compatible dimensions. Aliasing is allowed. - void bool_mat_complement(bool_mat_t B, const bool_mat_t A) noexcept - # Sets *B* to the logical complement of *A*. - # That is `B_{ij}` is set to `\bar{A_{ij}}`. - # The operands must have the same dimensions. - void bool_mat_add(bool_mat_t res, const bool_mat_t mat1, const bool_mat_t mat2) noexcept - # Sets *res* to the sum of *mat1* and *mat2*. - # The operands must have the same dimensions. - void bool_mat_mul(bool_mat_t res, const bool_mat_t mat1, const bool_mat_t mat2) noexcept - # Sets *res* to the matrix product of *mat1* and *mat2*. - # The operands must have compatible dimensions for matrix multiplication. - void bool_mat_mul_entrywise(bool_mat_t res, const bool_mat_t mat1, const bool_mat_t mat2) noexcept - # Sets *res* to the entrywise product of *mat1* and *mat2*. - # The operands must have the same dimensions. - void bool_mat_sqr(bool_mat_t B, const bool_mat_t A) noexcept - void bool_mat_pow_ui(bool_mat_t B, const bool_mat_t A, ulong exp) noexcept - # Sets *B* to *A* raised to the power *exp*. - # Requires that *A* is a square matrix. - int bool_mat_trace(const bool_mat_t mat) noexcept - # Returns the trace of the matrix, i.e. the sum of entries on the - # main diagonal of *mat*. The matrix is required to be square. - # The sum is in the boolean semiring, so this function returns nonzero iff - # any entry on the diagonal of *mat* is nonzero. - slong bool_mat_nilpotency_degree(const bool_mat_t A) noexcept - # Returns the nilpotency degree of the `n \times n` matrix *A*. - # It returns the smallest positive `k` such that `A^k = 0`. - # If no such `k` exists then the function returns `-1` if `n` is positive, - # and otherwise it returns `0`. - void bool_mat_transitive_closure(bool_mat_t B, const bool_mat_t A) noexcept - # Sets *B* to the transitive closure `\sum_{k=1}^\infty A^k`. - # The matrix *A* is required to be square. - slong bool_mat_get_strongly_connected_components(slong * p, const bool_mat_t A) noexcept - # Partitions the `n` row and column indices of the `n \times n` matrix *A* - # according to the strongly connected components (SCC) of the graph - # for which *A* is the adjacency matrix. - # If the graph has `k` SCCs then the function returns `k`, - # and for each vertex `i \in [0, n-1]`, - # `p_i` is set to the index of the SCC to which the vertex belongs. - # The SCCs themselves can be considered as nodes in a directed acyclic - # graph (DAG), and the SCCs are indexed in postorder with respect to that DAG. - slong bool_mat_all_pairs_longest_walk(fmpz_mat_t B, const bool_mat_t A) noexcept - # Sets `B_{ij}` to the length of the longest walk with endpoint vertices - # `i` and `j` in the graph whose adjacency matrix is *A*. - # The matrix *A* must be square. Empty walks with zero length - # which begin and end at the same vertex are allowed. If `j` is not - # reachable from `i` then no walk from `i` to `j` exists and `B_{ij}` - # is set to the special value `-1`. - # If arbitrarily long walks from `i` to `j` exist then `B_{ij}` - # is set to the special value `-2`. - # The function returns `-2` if any entry of `B_{ij}` is `-2`, - # and otherwise it returns the maximum entry in `B`, except if `A` is empty - # in which case `-1` is returned. - # Note that the returned value is one less than - # that of :func:`nilpotency_degree`. - # This function can help quantify entrywise errors in a truncated evaluation - # of a matrix power series. If *A* is an indicator matrix with the same - # sparsity pattern as a matrix `M` over the real or complex numbers, - # and if `B_{ij}` does not take the special value `-2`, then the tail - # `\left[ \sum_{k=N}^\infty a_k M^k \right]_{ij}` - # vanishes when `N > B_{ij}`. diff --git a/src/sage/libs/flint/ca.pxd b/src/sage/libs/flint/ca.pxd index 743ffae3f76..121a90b2f94 100644 --- a/src/sage/libs/flint/ca.pxd +++ b/src/sage/libs/flint/ca.pxd @@ -2,7 +2,9 @@ # distutils: depends = flint/ca.h ################################################################################ -# This file is auto-generated. Do not modify by hand +# This file is auto-generated by the script +# SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py. +# Do not modify by hand! Fix and rerun the script instead. ################################################################################ from libc.stdio cimport FILE @@ -11,354 +13,96 @@ from sage.libs.mpfr.types cimport * from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void ca_ctx_init(ca_ctx_t ctx) noexcept - # Initializes the context object *ctx* for use. - # Any evaluation options stored in the context object - # are set to default values. - void ca_ctx_clear(ca_ctx_t ctx) noexcept - # Clears the context object *ctx*, freeing any memory allocated internally. - # This function should only be called after all :type:`ca_t` instances - # referring to this context have been cleared. - void ca_ctx_print(ca_ctx_t ctx) noexcept - # Prints a description of the context *ctx* to standard output. - # This will give a complete listing of the cached fields in *ctx*. - void ca_init(ca_t x, ca_ctx_t ctx) noexcept - # Initializes the variable *x* for use, associating it with the - # context object *ctx*. The value of *x* is set to the rational number 0. - void ca_clear(ca_t x, ca_ctx_t ctx) noexcept - # Clears the variable *x*. - void ca_swap(ca_t x, ca_t y, ca_ctx_t ctx) noexcept - # Efficiently swaps the variables *x* and *y*. - void ca_get_fexpr(fexpr_t res, const ca_t x, ulong flags, ca_ctx_t ctx) noexcept - # Sets *res* to a symbolic expression representing *x*. - int ca_set_fexpr(ca_t res, const fexpr_t expr, ca_ctx_t ctx) noexcept - # Sets *res* to the value represented by the symbolic expression *expr*. - # Returns 1 on success and 0 on failure. - # This function essentially just traverses the expression tree using - # ``ca`` arithmetic; it does not provide advanced symbolic evaluation. - # It is guaranteed to at least be able to parse the output of - # :func:`ca_get_fexpr`. - void ca_print(const ca_t x, ca_ctx_t ctx) noexcept - # Prints *x* to standard output. - void ca_fprint(FILE * fp, const ca_t x, ca_ctx_t ctx) noexcept - # Prints *x* to the file *fp*. - char * ca_get_str(const ca_t x, ca_ctx_t ctx) noexcept - # Prints *x* to a string which is returned. - # The user should free this string by calling ``flint_free``. - void ca_printn(const ca_t x, slong n, ca_ctx_t ctx) noexcept - # Prints an *n*-digit numerical representation of *x* to standard output. - void ca_zero(ca_t res, ca_ctx_t ctx) noexcept void ca_one(ca_t res, ca_ctx_t ctx) noexcept void ca_neg_one(ca_t res, ca_ctx_t ctx) noexcept - # Sets *res* to the integer 0, 1 or -1. This creates a canonical representation - # of this number as an element of the trivial field `\mathbb{Q}`. - void ca_i(ca_t res, ca_ctx_t ctx) noexcept void ca_neg_i(ca_t res, ca_ctx_t ctx) noexcept - # Sets *res* to the imaginary unit `i = \sqrt{-1}`, or its negation `-i`. - # This creates a canonical representation of `i` as the generator of the - # algebraic number field `\mathbb{Q}(i)`. - void ca_pi(ca_t res, ca_ctx_t ctx) noexcept - # Sets *res* to the constant `\pi`. This creates an element - # of the transcendental number field `\mathbb{Q}(\pi)`. - void ca_pi_i(ca_t res, ca_ctx_t ctx) noexcept - # Sets *res* to the constant `\pi i`. This creates an element of the - # composite field `\mathbb{Q}(i,\pi)` rather than representing `\pi i` - # (or even `2 \pi i`, which for some purposes would be more elegant) - # as an atomic quantity. - void ca_euler(ca_t res, ca_ctx_t ctx) noexcept - # Sets *res* to Euler's constant `\gamma`. This creates an element - # of the (transcendental?) number field `\mathbb{Q}(\gamma)`. - void ca_unknown(ca_t res, ca_ctx_t ctx) noexcept - # Sets *res* to the meta-value *Unknown*. - void ca_undefined(ca_t res, ca_ctx_t ctx) noexcept - # Sets *res* to *Undefined*. - void ca_uinf(ca_t res, ca_ctx_t ctx) noexcept - # Sets *res* to unsigned infinity `{\tilde \infty}`. - void ca_pos_inf(ca_t res, ca_ctx_t ctx) noexcept void ca_neg_inf(ca_t res, ca_ctx_t ctx) noexcept void ca_pos_i_inf(ca_t res, ca_ctx_t ctx) noexcept void ca_neg_i_inf(ca_t res, ca_ctx_t ctx) noexcept - # Sets *res* to the signed infinity `+\infty`, `-\infty`, `+i \infty` or `-i \infty`. - void ca_set(ca_t res, const ca_t x, ca_ctx_t ctx) noexcept - # Sets *res* to a copy of *x*. - void ca_set_si(ca_t res, slong v, ca_ctx_t ctx) noexcept void ca_set_ui(ca_t res, ulong v, ca_ctx_t ctx) noexcept void ca_set_fmpz(ca_t res, const fmpz_t v, ca_ctx_t ctx) noexcept void ca_set_fmpq(ca_t res, const fmpq_t v, ca_ctx_t ctx) noexcept - # Sets *res* to the integer or rational number *v*. This creates a canonical - # representation of this number as an element of the trivial field - # `\mathbb{Q}`. - void ca_set_d(ca_t res, double x, ca_ctx_t ctx) noexcept void ca_set_d_d(ca_t res, double x, double y, ca_ctx_t ctx) noexcept - # Sets *res* to the value of *x*, or the complex value `x + yi`. - # NaN is interpreted as *Unknown* (not *Undefined*). - void ca_transfer(ca_t res, ca_ctx_t res_ctx, const ca_t src, ca_ctx_t src_ctx) noexcept - # Sets *res* to *src* where the corresponding context objects *res_ctx* and - # *src_ctx* may be different. - # This operation preserves the mathematical value represented by *src*, - # but may result in a different internal representation depending on the - # settings of the context objects. - void ca_set_qqbar(ca_t res, const qqbar_t x, ca_ctx_t ctx) noexcept - # Sets *res* to the algebraic number *x*. - # If *x* is rational, *res* is set to the canonical representation as - # an element in the trivial field `\mathbb{Q}`. - # If *x* is irrational, this function always sets *res* to an element of - # a univariate number field `\mathbb{Q}(a)`. It will not, for example, - # identify `\sqrt{2} + \sqrt{3}` - # as an element of `\mathbb{Q}(\sqrt{2}, \sqrt{3})`. However, it may - # attempt to find a simpler number field than that generated by *x* - # itself. For example: - # * If *x* is quadratic, it will be expressed as an element of - # `\mathbb{Q}(\sqrt{N})` where *N* has no small repeated factors - # (obtained by performing a smooth factorization of the discriminant). - # * TODO: if possible, coerce *x* to a low-degree cyclotomic field. - int ca_get_fmpz(fmpz_t res, const ca_t x, ca_ctx_t ctx) noexcept int ca_get_fmpq(fmpq_t res, const ca_t x, ca_ctx_t ctx) noexcept int ca_get_qqbar(qqbar_t res, const ca_t x, ca_ctx_t ctx) noexcept - # Attempts to evaluate *x* to an explicit integer, rational or - # algebraic number. If successful, sets *res* to this number and - # returns 1. If unsuccessful, returns 0. - # The conversion certainly fails if *x* does not represent an integer, - # rational or algebraic number (respectively), but can also fail if *x* - # is too expensive to compute under - # the current evaluation limits. - # In particular, the evaluation will be aborted if an intermediate - # algebraic number (or more precisely, the resultant polynomial prior - # to factorization) exceeds ``CA_OPT_QQBAR_DEG_LIMIT`` - # or the coefficients exceed some multiple of ``CA_OPT_PREC_LIMIT``. - # Note that evaluation may hit those limits even if the minimal polynomial - # for *x* itself is small. The conversion can also fail if no algorithm - # has been implemented for the functions appearing in the construction - # of *x*. - int ca_can_evaluate_qqbar(const ca_t x, ca_ctx_t ctx) noexcept - # Checks if :func:`ca_get_qqbar` has a chance to succeed. In effect, - # this checks if all extension numbers are manifestly algebraic - # numbers (without doing any evaluation). - void ca_randtest_rational(ca_t res, flint_rand_t state, slong bits, ca_ctx_t ctx) noexcept - # Sets *res* to a random rational number with numerator and denominator - # up to *bits* bits in size. - void ca_randtest(ca_t res, flint_rand_t state, slong depth, slong bits, ca_ctx_t ctx) noexcept - # Sets *res* to a random number generated by evaluating a random expression. - # The algorithm randomly selects between generating a "simple" number - # (a random rational number or quadratic field element with coefficients - # up to *bits* in size, or a random builtin constant), - # or if *depth* is nonzero, applying a random arithmetic operation or - # function to operands produced through recursive calls with - # *depth* - 1. The output is guaranteed to be a number, not a special value. - void ca_randtest_special(ca_t res, flint_rand_t state, slong depth, slong bits, ca_ctx_t ctx) noexcept - # Randomly generates either a special value or a number. - void ca_randtest_same_nf(ca_t res, flint_rand_t state, const ca_t x, slong bits, slong den_bits, ca_ctx_t ctx) noexcept - # Sets *res* to a random element in the same number field as *x*, - # with numerator coefficients up to *bits* in size and denominator - # up to *den_bits* in size. This function requires that *x* is an - # element of an absolute number field. - bint ca_equal_repr(const ca_t x, const ca_t y, ca_ctx_t ctx) noexcept - # Returns whether *x* and *y* have identical representation. For field - # elements, this checks if *x* and *y* belong to the same formal field - # (with generators having identical representation) and are represented by - # the same rational function within that field. - # For special values, this tests - # equality of the special values, with *Unknown* handled as if it were - # a value rather than a meta-value: that is, *Unknown* = *Unknown* gives 1, - # and *Unknown* = *y* gives 0 for any other kind of value *y*. - # If neither *x* nor *y* is *Unknown*, then representation equality - # implies that *x* and *y* describe to the same mathematical value, but if - # either operand is *Unknown*, the result is meaningless for - # mathematical comparison. - int ca_cmp_repr(const ca_t x, const ca_t y, ca_ctx_t ctx) noexcept - # Compares the representations of *x* and *y* in a canonical sort order, - # returning -1, 0 or 1. This only performs a lexicographic comparison - # of the representations of *x* and *y*; the return value does not say - # anything meaningful about the numbers represented by *x* and *y*. - ulong ca_hash_repr(const ca_t x, ca_ctx_t ctx) noexcept - # Hashes the representation of *x*. - bint ca_is_unknown(const ca_t x, ca_ctx_t ctx) noexcept - # Returns whether *x* is Unknown. - bint ca_is_special(const ca_t x, ca_ctx_t ctx) noexcept - # Returns whether *x* is a special value or metavalue - # (not a field element). - bint ca_is_qq_elem(const ca_t x, ca_ctx_t ctx) noexcept - # Returns whether *x* is represented as an element of the - # rational field `\mathbb{Q}`. - bint ca_is_qq_elem_zero(const ca_t x, ca_ctx_t ctx) noexcept bint ca_is_qq_elem_one(const ca_t x, ca_ctx_t ctx) noexcept bint ca_is_qq_elem_integer(const ca_t x, ca_ctx_t ctx) noexcept - # Returns whether *x* is represented as the element 0, 1 or - # any integer in the rational field `\mathbb{Q}`. - bint ca_is_nf_elem(const ca_t x, ca_ctx_t ctx) noexcept - # Returns whether *x* is represented as an element of a univariate - # algebraic number field `\mathbb{Q}(a)`. - bint ca_is_cyclotomic_nf_elem(slong * p, ulong * q, const ca_t x, ca_ctx_t ctx) noexcept - # Returns whether *x* is represented as an element of a univariate - # cyclotomic field, i.e. `\mathbb{Q}(a)` where *a* is a root of unity. - # If *p* and *q* are not *NULL* and *x* is represented as an - # element of a cyclotomic field, this also sets *p* and *q* to the - # minimal integers with `0 \le p < q` such that the generating - # root of unity is `a = e^{2 \pi i p / q}`. - # Note that the answer 0 does not prove that *x* is not - # a cyclotomic number, - # and the order *q* is also not necessarily the generator of the - # *smallest* cyclotomic field containing *x*. - # For the purposes of this function, only nontrivial - # cyclotomic fields count; the return value is 0 if *x* - # is represented as a rational number. - bint ca_is_generic_elem(const ca_t x, ca_ctx_t ctx) noexcept - # Returns whether *x* is represented as a generic field element; - # i.e. it is not a special value, not represented as - # an element of the rational field, and not represented as - # an element of a univariate algebraic number field. - truth_t ca_check_is_number(const ca_t x, ca_ctx_t ctx) noexcept - # Tests if *x* is a number. The result is ``T_TRUE`` is *x* is - # a field element (and hence a complex number), ``T_FALSE`` if *x* is - # an infinity or *Undefined*, and ``T_UNKNOWN`` if *x* is *Unknown*. - truth_t ca_check_is_zero(const ca_t x, ca_ctx_t ctx) noexcept truth_t ca_check_is_one(const ca_t x, ca_ctx_t ctx) noexcept truth_t ca_check_is_neg_one(const ca_t x, ca_ctx_t ctx) noexcept truth_t ca_check_is_i(const ca_t x, ca_ctx_t ctx) noexcept truth_t ca_check_is_neg_i(const ca_t x, ca_ctx_t ctx) noexcept - # Tests if *x* is equal to the number `0`, `1`, `-1`, `i`, or `-i`. - truth_t ca_check_is_algebraic(const ca_t x, ca_ctx_t ctx) noexcept truth_t ca_check_is_rational(const ca_t x, ca_ctx_t ctx) noexcept truth_t ca_check_is_integer(const ca_t x, ca_ctx_t ctx) noexcept - # Tests if *x* is respectively an algebraic number, a rational number, - # or an integer. - truth_t ca_check_is_real(const ca_t x, ca_ctx_t ctx) noexcept - # Tests if *x* is a real number. Warning: this returns ``T_FALSE`` if *x* is an - # infinity with real sign. - truth_t ca_check_is_negative_real(const ca_t x, ca_ctx_t ctx) noexcept - # Tests if *x* is a negative real number. Warning: this returns ``T_FALSE`` - # if *x* is negative infinity. - truth_t ca_check_is_imaginary(const ca_t x, ca_ctx_t ctx) noexcept - # Tests if *x* is an imaginary number. Warning: this returns ``T_FALSE`` if - # *x* is an infinity with imaginary sign. - truth_t ca_check_is_undefined(const ca_t x, ca_ctx_t ctx) noexcept - # Tests if *x* is the special value *Undefined*. - truth_t ca_check_is_infinity(const ca_t x, ca_ctx_t ctx) noexcept - # Tests if *x* is any infinity (unsigned or signed). - truth_t ca_check_is_uinf(const ca_t x, ca_ctx_t ctx) noexcept - # Tests if *x* is unsigned infinity `{\tilde \infty}`. - truth_t ca_check_is_signed_inf(const ca_t x, ca_ctx_t ctx) noexcept - # Tests if *x* is any signed infinity. - truth_t ca_check_is_pos_inf(const ca_t x, ca_ctx_t ctx) noexcept truth_t ca_check_is_neg_inf(const ca_t x, ca_ctx_t ctx) noexcept truth_t ca_check_is_pos_i_inf(const ca_t x, ca_ctx_t ctx) noexcept truth_t ca_check_is_neg_i_inf(const ca_t x, ca_ctx_t ctx) noexcept - # Tests if *x* is equal to the signed infinity `+\infty`, `-\infty`, - # `+i \infty`, `-i \infty`, respectively. - truth_t ca_check_equal(const ca_t x, const ca_t y, ca_ctx_t ctx) noexcept - # Tests `x = y` as a mathematical equality. - # The result is ``T_UNKNOWN`` if either operand is *Unknown*. - # The result may also be ``T_UNKNOWN`` if *x* and *y* are numerically - # indistinguishable and cannot be proved equal or unequal by - # an exact computation. - truth_t ca_check_lt(const ca_t x, const ca_t y, ca_ctx_t ctx) noexcept truth_t ca_check_le(const ca_t x, const ca_t y, ca_ctx_t ctx) noexcept truth_t ca_check_gt(const ca_t x, const ca_t y, ca_ctx_t ctx) noexcept truth_t ca_check_ge(const ca_t x, const ca_t y, ca_ctx_t ctx) noexcept - # Compares *x* and *y*, implementing the respective operations - # `x < y`, `x \le y`, `x > y`, `x \ge y`. - # Only real numbers and `-\infty` and `+\infty` are considered comparable. - # The result is ``T_FALSE`` (not ``T_UNKNOWN``) if either operand is not - # comparable (being a nonreal complex number, unsigned infinity, or - # undefined). - void ca_merge_fields(ca_t resx, ca_t resy, const ca_t x, const ca_t y, ca_ctx_t ctx) noexcept - # Sets *resx* and *resy* to copies of *x* and *y* coerced to a common field. - # Both *x* and *y* must be field elements (not special values). - # In the present implementation, this simply merges the lists of generators, - # avoiding duplication. In the future, it will be able to eliminate - # generators satisfying algebraic relations. - void ca_condense_field(ca_t res, ca_ctx_t ctx) noexcept - # Attempts to demote the value of *res* to a trivial subfield of its - # current field by removing unused generators. In particular, this demotes - # any obviously rational value to the trivial field `\mathbb{Q}`. - # This function is applied automatically in most operations - # (arithmetic operations, etc.). - ca_ext_ptr ca_is_gen_as_ext(const ca_t x, ca_ctx_t ctx) noexcept - # If *x* is a generator of its formal field, `x = a_k \in \mathbb{Q}(a_1,\ldots,a_n)`, - # returns a pointer to the extension number defining `a_k`. If *x* is - # not a generator, returns *NULL*. - void ca_neg(ca_t res, const ca_t x, ca_ctx_t ctx) noexcept - # Sets *res* to the negation of *x*. - # For numbers, this operation amounts to a direct negation within the - # formal field. - # For a signed infinity `c \infty`, negation gives `(-c) \infty`; all other - # special values are unchanged. - void ca_add_fmpq(ca_t res, const ca_t x, const fmpq_t y, ca_ctx_t ctx) noexcept void ca_add_fmpz(ca_t res, const ca_t x, const fmpz_t y, ca_ctx_t ctx) noexcept void ca_add_ui(ca_t res, const ca_t x, ulong y, ca_ctx_t ctx) noexcept void ca_add_si(ca_t res, const ca_t x, slong y, ca_ctx_t ctx) noexcept void ca_add(ca_t res, const ca_t x, const ca_t y, ca_ctx_t ctx) noexcept - # Sets *res* to the sum of *x* and *y*. For special values, the following - # rules apply (`c \infty` denotes a signed infinity, `|c| = 1`): - # * `c \infty + d \infty = c \infty` if `c = d` - # * `c \infty + d \infty = \text{Undefined}` if `c \ne d` - # * `\tilde \infty + c \infty = \tilde \infty + \tilde \infty = \text{Undefined}` - # * `c \infty + z = c \infty` if `z \in \mathbb{C}` - # * `\tilde \infty + z = \tilde \infty` if `z \in \mathbb{C}` - # * `z + \text{Undefined} = \text{Undefined}` for any value *z* (including *Unknown*) - # In any other case involving special values, or if the specific case cannot - # be distinguished, the result is *Unknown*. - void ca_sub_fmpq(ca_t res, const ca_t x, const fmpq_t y, ca_ctx_t ctx) noexcept void ca_sub_fmpz(ca_t res, const ca_t x, const fmpz_t y, ca_ctx_t ctx) noexcept void ca_sub_ui(ca_t res, const ca_t x, ulong y, ca_ctx_t ctx) noexcept @@ -368,40 +112,12 @@ cdef extern from "flint_wrap.h": void ca_ui_sub(ca_t res, ulong x, const ca_t y, ca_ctx_t ctx) noexcept void ca_si_sub(ca_t res, slong x, const ca_t y, ca_ctx_t ctx) noexcept void ca_sub(ca_t res, const ca_t x, const ca_t y, ca_ctx_t ctx) noexcept - # Sets *res* to the difference of *x* and *y*. - # This is equivalent to computing `x + (-y)`. - void ca_mul_fmpq(ca_t res, const ca_t x, const fmpq_t y, ca_ctx_t ctx) noexcept void ca_mul_fmpz(ca_t res, const ca_t x, const fmpz_t y, ca_ctx_t ctx) noexcept void ca_mul_ui(ca_t res, const ca_t x, ulong y, ca_ctx_t ctx) noexcept void ca_mul_si(ca_t res, const ca_t x, slong y, ca_ctx_t ctx) noexcept void ca_mul(ca_t res, const ca_t x, const ca_t y, ca_ctx_t ctx) noexcept - # Sets *res* to the product of *x* and *y*. For special values, the following - # rules apply (`c \infty` denotes a signed infinity, `|c| = 1`): - # * `c \infty \cdot d \infty = c d \infty` - # * `c \infty \cdot \tilde \infty = \tilde \infty` - # * `\tilde \infty \cdot \tilde \infty = \tilde \infty` - # * `c \infty \cdot z = \operatorname{sgn}(z) c \infty` if `z \in \mathbb{C} \setminus \{0\}` - # * `c \infty \cdot 0 = \text{Undefined}` - # * `\tilde \infty \cdot 0 = \text{Undefined}` - # * `z \cdot \text{Undefined} = \text{Undefined}` for any value *z* (including *Unknown*) - # In any other case involving special values, or if the specific case cannot - # be distinguished, the result is *Unknown*. - void ca_inv(ca_t res, const ca_t x, ca_ctx_t ctx) noexcept - # Sets *res* to the multiplicative inverse of *x*. In a univariate algebraic - # number field, this always produces a rational denominator, but the - # denominator might not be rationalized in a multivariate - # field. - # For special values - # and zero, the following rules apply: - # * `1 / (c \infty) = 1 / \tilde \infty = 0` - # * `1 / 0 = \tilde \infty` - # * `1 / \text{Undefined} = \text{Undefined}` - # * `1 / \text{Unknown} = \text{Unknown}` - # If it cannot be determined whether *x* is zero or nonzero, - # the result is *Unknown*. - void ca_fmpq_div(ca_t res, const fmpq_t x, const ca_t y, ca_ctx_t ctx) noexcept void ca_fmpz_div(ca_t res, const fmpz_t x, const ca_t y, ca_ctx_t ctx) noexcept void ca_ui_div(ca_t res, ulong x, const ca_t y, ca_ctx_t ctx) noexcept @@ -411,402 +127,75 @@ cdef extern from "flint_wrap.h": void ca_div_ui(ca_t res, const ca_t x, ulong y, ca_ctx_t ctx) noexcept void ca_div_si(ca_t res, const ca_t x, slong y, ca_ctx_t ctx) noexcept void ca_div(ca_t res, const ca_t x, const ca_t y, ca_ctx_t ctx) noexcept - # Sets *res* to the quotient of *x* and *y*. This is equivalent - # to computing `x \cdot (1 / y)`. For special values and division - # by zero, this implies the following rules - # (`c \infty` denotes a signed infinity, `|c| = 1`): - # * `(c \infty) / (d \infty) = (c \infty) / \tilde \infty = \tilde \infty / (c \infty) = \tilde \infty / \tilde \infty = \text{Undefined}` - # * `c \infty / z = (c / \operatorname{sgn}(z)) \infty` if `z \in \mathbb{C} \setminus \{0\}` - # * `c \infty / 0 = \tilde \infty / 0 = \tilde \infty` - # * `z / (c \infty) = z / \tilde \infty = 0` if `z \in \mathbb{C}` - # * `z / 0 = \tilde \infty` if `z \in \mathbb{C} \setminus \{0\}` - # * `0 / 0 = \text{Undefined}` - # * `z / \text{Undefined} = \text{Undefined}` for any value *z* (including *Unknown*) - # * `\text{Undefined} / z = \text{Undefined}` for any value *z* (including *Unknown*) - # In any other case involving special values, or if the specific case cannot - # be distinguished, the result is *Unknown*. - void ca_dot(ca_t res, const ca_t initial, int subtract, ca_srcptr x, slong xstep, ca_srcptr y, slong ystep, slong len, ca_ctx_t ctx) noexcept - # Computes the dot product of the vectors *x* and *y*, setting - # *res* to `s + (-1)^{subtract} \sum_{i=0}^{len-1} x_i y_i`. - # The initial term *s* is optional and can be - # omitted by passing *NULL* (equivalently, `s = 0`). - # The parameter *subtract* must be 0 or 1. - # The length *len* is allowed to be negative, which is equivalent - # to a length of zero. - # The parameters *xstep* or *ystep* specify a step length for - # traversing subsequences of the vectors *x* and *y*; either can be - # negative to step in the reverse direction starting from - # the initial pointer. - # Aliasing is allowed between *res* and *s* but not between - # *res* and the entries of *x* and *y*. - void ca_fmpz_poly_evaluate(ca_t res, const fmpz_poly_t poly, const ca_t x, ca_ctx_t ctx) noexcept void ca_fmpq_poly_evaluate(ca_t res, const fmpq_poly_t poly, const ca_t x, ca_ctx_t ctx) noexcept - # Sets *res* to the polynomial *poly* evaluated at *x*. - void ca_fmpz_mpoly_evaluate_horner(ca_t res, const fmpz_mpoly_t f, ca_srcptr x, const fmpz_mpoly_ctx_t mctx, ca_ctx_t ctx) noexcept void ca_fmpz_mpoly_evaluate_iter(ca_t res, const fmpz_mpoly_t f, ca_srcptr x, const fmpz_mpoly_ctx_t mctx, ca_ctx_t ctx) noexcept void ca_fmpz_mpoly_evaluate(ca_t res, const fmpz_mpoly_t f, ca_srcptr x, const fmpz_mpoly_ctx_t mctx, ca_ctx_t ctx) noexcept - # Sets *res* to the multivariate polynomial *f* evaluated at the vector of arguments *x*. - void ca_fmpz_mpoly_q_evaluate(ca_t res, const fmpz_mpoly_q_t f, ca_srcptr x, const fmpz_mpoly_ctx_t mctx, ca_ctx_t ctx) noexcept - # Sets *res* to the multivariate rational function *f* evaluated at the vector of arguments *x*. - void ca_fmpz_mpoly_q_evaluate_no_division_by_zero(ca_t res, const fmpz_mpoly_q_t f, ca_srcptr x, const fmpz_mpoly_ctx_t mctx, ca_ctx_t ctx) noexcept void ca_inv_no_division_by_zero(ca_t res, const ca_t x, ca_ctx_t ctx) noexcept - # These functions behave like the normal arithmetic functions, - # but assume (and do not check) that division by zero cannot occur. - # Division by zero will result in undefined behavior. - void ca_sqr(ca_t res, const ca_t x, ca_ctx_t ctx) noexcept - # Sets *res* to the square of *x*. - void ca_pow_fmpq(ca_t res, const ca_t x, const fmpq_t y, ca_ctx_t ctx) noexcept void ca_pow_fmpz(ca_t res, const ca_t x, const fmpz_t y, ca_ctx_t ctx) noexcept void ca_pow_ui(ca_t res, const ca_t x, ulong y, ca_ctx_t ctx) noexcept void ca_pow_si(ca_t res, const ca_t x, slong y, ca_ctx_t ctx) noexcept void ca_pow(ca_t res, const ca_t x, const ca_t y, ca_ctx_t ctx) noexcept - # Sets *res* to *x* raised to the power *y*. - # Handling of special values is not yet implemented. - void ca_pow_si_arithmetic(ca_t res, const ca_t x, slong n, ca_ctx_t ctx) noexcept - # Sets *res* to *x* raised to the power *n*. Whereas :func:`ca_pow`, - # :func:`ca_pow_si` etc. may create `x^n` as an extension number - # if *n* is large, this function always perform the exponentiation - # using field arithmetic. - void ca_sqrt_inert(ca_t res, const ca_t x, ca_ctx_t ctx) noexcept void ca_sqrt_nofactor(ca_t res, const ca_t x, ca_ctx_t ctx) noexcept void ca_sqrt_factor(ca_t res, const ca_t x, ulong flags, ca_ctx_t ctx) noexcept void ca_sqrt(ca_t res, const ca_t x, ca_ctx_t ctx) noexcept - # Sets *res* to the principal square root of *x*. - # For special values, the following definitions apply: - # * `\sqrt{c \infty} = \sqrt{c} \infty` - # * `\sqrt{\tilde \infty} = \tilde \infty`. - # * Both *Undefined* and *Unknown* map to themselves. - # The *inert* version outputs the generator in the formal field - # `\mathbb{Q}(\sqrt{x})` without simplifying. - # The *factor* version writes `x = A^2 B` in `K` where `K` is - # the field of *x*, and outputs `A \sqrt{B}` or - # `-A \sqrt{B}` (whichever gives the correct sign) as an element of - # `K(\sqrt{B})` or some subfield thereof. - # This factorization is only a heuristic and is not guaranteed - # to make `B` minimal. - # Factorization options can be passed through to *flags*: see - # :func:`ca_factor` for details. - # The *nofactor* version will not perform a general factorization, but - # may still perform other simplifications. It may in particular attempt to - # simplify `\sqrt{x}` to a single element in `\overline{\mathbb{Q}}`. - void ca_sqrt_ui(ca_t res, ulong n, ca_ctx_t ctx) noexcept - # Sets *res* to the principal square root of *n*. - void ca_abs(ca_t res, const ca_t x, ca_ctx_t ctx) noexcept - # Sets *res* to the absolute value of *x*. - # For special values, the following definitions apply: - # * `|c \infty| = |\tilde \infty| = +\infty`. - # * Both *Undefined* and *Unknown* map to themselves. - # This function will attempt to simplify its argument through an exact - # computation. It may in particular attempt to simplify `|x|` to - # a single element in `\overline{\mathbb{Q}}`. - # In the generic case, this function outputs an element of the formal - # field `\mathbb{Q}(|x|)`. - void ca_sgn(ca_t res, const ca_t x, ca_ctx_t ctx) noexcept - # Sets *res* to the sign of *x*, defined by - # .. math :: - # \operatorname{sgn}(x) = \begin{cases} 0 & x = 0 \\ \frac{x}{|x|} & x \ne 0 \end{cases} - # for numbers. For special values, the following definitions apply: - # * `\operatorname{sgn}(c \infty) = c`. - # * `\operatorname{sgn}(\tilde \infty) = \operatorname{Undefined}`. - # * Both *Undefined* and *Unknown* map to themselves. - # This function will attempt to simplify its argument through an exact - # computation. It may in particular attempt to simplify `\operatorname{sgn}(x)` to - # a single element in `\overline{\mathbb{Q}}`. - # In the generic case, this function outputs an element of the formal - # field `\mathbb{Q}(\operatorname{sgn}(x))`. - void ca_csgn(ca_t res, const ca_t x, ca_ctx_t ctx) noexcept - # Sets *res* to the extension of the real sign function taking the - # value 1 for *z* strictly in the right half plane, -1 for *z* strictly - # in the left half plane, and the sign of the imaginary part when *z* is on - # the imaginary axis. Equivalently, `\operatorname{csgn}(z) = z / \sqrt{z^2}` - # except that the value is 0 when *z* is exactly zero. - # This function gives *Undefined* for unsigned infinity - # and `\operatorname{csgn}(\operatorname{sgn}(c \infty)) = \operatorname{csgn}(c)` for - # signed infinities. - void ca_arg(ca_t res, const ca_t x, ca_ctx_t ctx) noexcept - # Sets *res* to the complex argument (phase) of *x*, normalized - # to the range `(-\pi, +\pi]`. The argument of 0 is defined as 0. - # For special values, the following definitions apply: - # * `\operatorname{arg}(c \infty) = \operatorname{arg}(c)`. - # * `\operatorname{arg}(\tilde \infty) = \operatorname{Undefined}`. - # * Both *Undefined* and *Unknown* map to themselves. - void ca_re(ca_t res, const ca_t x, ca_ctx_t ctx) noexcept - # Sets *res* to the real part of *x*. The result is *Undefined* if *x* - # is any infinity (including a real infinity). - void ca_im(ca_t res, const ca_t x, ca_ctx_t ctx) noexcept - # Sets *res* to the imaginary part of *x*. The result is *Undefined* if *x* - # is any infinity (including an imaginary infinity). - void ca_conj_deep(ca_t res, const ca_t x, ca_ctx_t ctx) noexcept void ca_conj_shallow(ca_t res, const ca_t x, ca_ctx_t ctx) noexcept void ca_conj(ca_t res, const ca_t x, ca_ctx_t ctx) noexcept - # Sets *res* to the complex conjugate of *x*. - # The *shallow* version creates a new extension element - # `\overline{x}` unless *x* can be trivially conjugated in-place - # in the existing field. - # The *deep* version recursively conjugates the extension numbers - # in the field of *x*. - void ca_floor(ca_t res, const ca_t x, ca_ctx_t ctx) noexcept - # Sets *res* to the floor function of *x*. The result is *Undefined* if *x* - # is any infinity (including a real infinity). - # For complex numbers, this is presently defined to take the floor of the - # real part. - void ca_ceil(ca_t res, const ca_t x, ca_ctx_t ctx) noexcept - # Sets *res* to the ceiling function of *x*. The result is *Undefined* if *x* - # is any infinity (including a real infinity). - # For complex numbers, this is presently defined to take the ceiling of the - # real part. - void ca_exp(ca_t res, const ca_t x, ca_ctx_t ctx) noexcept - # Sets *res* to the exponential function of *x*. - # For special values, the following definitions apply: - # * `e^{+\infty} = +\infty` - # * `e^{c \infty} = \tilde \infty` if `0 < \operatorname{Re}(c) < 1`. - # * `e^{c \infty} = 0` if `\operatorname{Re}(c) < 0`. - # * `e^{c \infty} = \text{Undefined}` if `\operatorname{Re}(c) = 0`. - # * `e^{\tilde \infty} = \text{Undefined}`. - # * Both *Undefined* and *Unknown* map to themselves. - # The following symbolic simplifications are performed automatically: - # * `e^0 = 1` - # * `e^{\log(z)} = z` - # * `e^{(p/q) \log(z)} = z^{p/q}` (for rational `p/q`) - # * `e^{(p/q) \pi i}` = algebraic root of unity (for small rational `p/q`) - # In the generic case, this function outputs an element of the formal - # field `\mathbb{Q}(e^x)`. - void ca_log(ca_t res, const ca_t x, ca_ctx_t ctx) noexcept - # Sets *res* to the natural logarithm of *x*. - # For special values and at the origin, the following definitions apply: - # * For any infinity, `\log(c\infty) = \log(\tilde \infty) = +\infty`. - # * `\log(0) = -\infty`. The result is *Unknown* if deciding `x = 0` fails. - # * Both *Undefined* and *Unknown* map to themselves. - # The following symbolic simplifications are performed automatically: - # * `\log(1) = 0` - # * `\log\left(e^z\right) = z + 2 \pi i k` - # * `\log\left(\sqrt{z}\right) = \tfrac{1}{2} \log(z) + 2 \pi i k` - # * `\log\left(z^a\right) = a \log(z) + 2 \pi i k` - # * `\log(x) = \log(-x) + \pi i` for negative real *x* - # In the generic case, this function outputs an element of the formal - # field `\mathbb{Q}(\log(x))`. - void ca_sin_cos_exponential(ca_t res1, ca_t res2, const ca_t x, ca_ctx_t ctx) noexcept void ca_sin_cos_direct(ca_t res1, ca_t res2, const ca_t x, ca_ctx_t ctx) noexcept void ca_sin_cos_tangent(ca_t res1, ca_t res2, const ca_t x, ca_ctx_t ctx) noexcept void ca_sin_cos(ca_t res1, ca_t res2, const ca_t x, ca_ctx_t ctx) noexcept - # Sets *res1* to the sine of *x* and *res2* to the cosine of *x*. - # Either *res1* or *res2* can be *NULL* to compute only the other function. - # Various representations are implemented: - # * The *exponential* version expresses the sine and cosine in terms - # of complex exponentials. Simple algebraic values will simplify to - # rational numbers or elements of cyclotomic fields. - # * The *direct* method expresses the sine and cosine in terms of - # the original functions (perhaps after applying some symmetry - # transformations, which may interchange sin and cos). Extremely - # simple algebraic values will automatically simplify to elements - # of real algebraic number fields. - # * The *tangent* version expresses the sine and cosine in terms - # of `\tan(x/2)`, perhaps after applying some symmetry - # transformations. Extremely simple algebraic values will - # automatically simplify to elements of real algebraic number - # fields. - # By default, the standard function uses the *exponential* - # representation as this typically works best for field arithmetic - # and simplifications, although it has the disadvantage of - # introducing complex numbers where real numbers would be sufficient. - # The behavior of the standard function can be changed using the - # :macro:`CA_OPT_TRIG_FORM` context setting. - # For special values, the following definitions apply: - # * `\sin(\pm i \infty) = \pm i \infty` - # * `\cos(\pm i \infty) = +\infty` - # * All other infinities give `\operatorname{Undefined}` - void ca_sin(ca_t res, const ca_t x, ca_ctx_t ctx) noexcept void ca_cos(ca_t res, const ca_t x, ca_ctx_t ctx) noexcept - # Sets *res* to the sine or cosine of *x*. - # These functions are shortcuts for :func:`ca_sin_cos`. - void ca_tan_sine_cosine(ca_t res, const ca_t x, ca_ctx_t ctx) noexcept void ca_tan_exponential(ca_t res, const ca_t x, ca_ctx_t ctx) noexcept void ca_tan_direct(ca_t res, const ca_t x, ca_ctx_t ctx) noexcept void ca_tan(ca_t res, const ca_t x, ca_ctx_t ctx) noexcept - # Sets *res* to the tangent of *x*. - # The *sine_cosine* version evaluates the tangent as a quotient of - # a sine and cosine, the *direct* version evaluates it directly - # as a tangent (possibly after transforming the variable), - # and the *exponential* version evaluates it in terms of complex - # exponentials. - # Simple algebraic values will automatically simplify to elements - # of trigonometric or cyclotomic number fields. - # By default, the standard function uses the *exponential* - # representation as this typically works best for field arithmetic - # and simplifications, although it has the disadvantage of - # introducing complex numbers where real numbers would be sufficient. - # The behavior of the standard function can be changed using the - # :macro:`CA_OPT_TRIG_FORM` context setting. - # For special values, the following definitions apply: - # * At poles, `\tan((n+\tfrac{1}{2}) \pi) = \tilde \infty` - # * `\tan(e^{i \theta} \infty) = +i, \quad 0 < \theta < \pi` - # * `\tan(e^{i \theta} \infty) = -i, \quad -\pi < \theta < 0` - # * `\tan(\pm \infty) = \tan(\tilde \infty) = \operatorname{Undefined}` - void ca_cot(ca_t res, const ca_t x, ca_ctx_t ctx) noexcept - # Sets *res* to the cotangent *x*. This is equivalent to - # computing the reciprocal of the tangent. - void ca_atan_logarithm(ca_t res, const ca_t x, ca_ctx_t ctx) noexcept void ca_atan_direct(ca_t res, const ca_t x, ca_ctx_t ctx) noexcept void ca_atan(ca_t res, const ca_t x, ca_ctx_t ctx) noexcept - # Sets *res* to the inverse tangent of *x*. - # The *direct* version expresses the result as an inverse tangent - # (possibly after transforming the variable). The *logarithm* - # version expresses it in terms of complex logarithms. - # Simple algebraic inputs will automatically simplify to - # rational multiples of `\pi`. - # By default, the standard function uses the *logarithm* - # representation as this typically works best for field arithmetic - # and simplifications, although it has the disadvantage of - # introducing complex numbers where real numbers would be sufficient. - # The behavior of the standard function can be changed using the - # :macro:`CA_OPT_TRIG_FORM` context setting (exponential mode - # results in logarithmic forms). - # For special values, the following definitions apply: - # * `\operatorname{atan}(\pm i) = \pm i \infty` - # * `\operatorname{atan}(c \infty) = \operatorname{csgn}(c) \pi / 2` - # * `\operatorname{atan}(\tilde \infty) = \operatorname{Undefined}` - void ca_asin_logarithm(ca_t res, const ca_t x, ca_ctx_t ctx) noexcept void ca_acos_logarithm(ca_t res, const ca_t x, ca_ctx_t ctx) noexcept void ca_asin_direct(ca_t res, const ca_t x, ca_ctx_t ctx) noexcept void ca_acos_direct(ca_t res, const ca_t x, ca_ctx_t ctx) noexcept void ca_asin(ca_t res, const ca_t x, ca_ctx_t ctx) noexcept void ca_acos(ca_t res, const ca_t x, ca_ctx_t ctx) noexcept - # Sets *res* to the inverse sine (respectively, cosine) of *x*. - # The *direct* version expresses the result as an inverse sine or - # cosine (possibly after transforming the variable). The *logarithm* - # version expresses it in terms of complex logarithms. - # Simple algebraic inputs will automatically simplify to - # rational multiples of `\pi`. - # By default, the standard function uses the *logarithm* - # representation as this typically works best for field arithmetic - # and simplifications, although it has the disadvantage of - # introducing complex numbers where real numbers would be sufficient. - # The behavior of the standard function can be changed using the - # :macro:`CA_OPT_TRIG_FORM` context setting (exponential mode - # results in logarithmic forms). - # The inverse cosine is presently implemented as - # `\operatorname{acos}(x) = \pi/2 - \operatorname{asin}(x)`. - void ca_gamma(ca_t res, const ca_t x, ca_ctx_t ctx) noexcept - # Sets *res* to the gamma function of *x*. - void ca_erf(ca_t res, const ca_t x, ca_ctx_t ctx) noexcept - # Sets *res* to the error function of *x*. - void ca_erfc(ca_t res, const ca_t x, ca_ctx_t ctx) noexcept - # Sets *res* to the complementary error function of *x*. - void ca_erfi(ca_t res, const ca_t x, ca_ctx_t ctx) noexcept - # Sets *res* to the imaginary error function of *x*. - void ca_get_acb_raw(acb_t res, const ca_t x, slong prec, ca_ctx_t ctx) noexcept - # Sets *res* to an enclosure of the numerical value of *x*. - # A working precision of *prec* bits is used internally for the evaluation, - # without adaptive refinement. - # If *x* is any special value, *res* is set to *acb_indeterminate*. - void ca_get_acb(acb_t res, const ca_t x, slong prec, ca_ctx_t ctx) noexcept void ca_get_acb_accurate_parts(acb_t res, const ca_t x, slong prec, ca_ctx_t ctx) noexcept - # Sets *res* to an enclosure of the numerical value of *x*. - # The working precision is increased adaptively to try to ensure *prec* - # accurate bits in the output. The *accurate_parts* version tries to ensure - # *prec* accurate bits for both the real and imaginary part separately. - # The refinement is stopped if the working precision exceeds - # ``CA_OPT_PREC_LIMIT`` (or twice the initial precision, if this is larger). - # The user may call *acb_rel_accuracy_bits* to check is the calculation - # was successful. - # The output is not rounded down to *prec* bits (to avoid unnecessary - # double rounding); the user may call *acb_set_round* when rounding - # is desired. - char * ca_get_decimal_str(const ca_t x, slong digits, ulong flags, ca_ctx_t ctx) noexcept - # Returns a decimal approximation of *x* with precision up to - # *digits*. The output is guaranteed to be correct within 1 ulp - # in the returned digits, but the number of returned digits may - # be smaller than *digits* if the numerical evaluation does - # not succeed. - # If *flags* is set to 1, attempts to achieve full accuracy for - # both the real and imaginary parts separately. - # If *x* is not finite or a finite enclosure cannot be produced, - # returns the string "?". - # The user should free the returned string with ``flint_free``. - void ca_rewrite_complex_normal_form(ca_t res, const ca_t x, int deep, ca_ctx_t ctx) noexcept - # Sets *res* to *x* rewritten using standardizing transformations - # over the complex numbers: - # * Elementary functions are rewritten in terms of (complex) exponentials, roots and logarithms - # * Complex parts are rewritten using logarithms, square roots, and (deep) complex conjugates - # * Algebraic numbers are rewritten in terms of cyclotomic fields where applicable - # If *deep* is set, the rewriting is applied recursively to the tower - # of extension numbers; otherwise, the rewriting is only applied - # to the top-level extension numbers. - # The result is not a normal form in the strong sense (the same - # number can have many possible representations even after applying - # this transformation), but in practice this is a powerful heuristic - # for simplification. - void ca_factor_init(ca_factor_t fac, ca_ctx_t ctx) noexcept - # Initializes *fac* and sets it to the empty factorization - # (equivalent to the number 1). - void ca_factor_clear(ca_factor_t fac, ca_ctx_t ctx) noexcept - # Clears the factorization structure *fac*. - void ca_factor_one(ca_factor_t fac, ca_ctx_t ctx) noexcept - # Sets *fac* to the empty factorization (equivalent to the number 1). - void ca_factor_print(const ca_factor_t fac, ca_ctx_t ctx) noexcept - # Prints a description of *fac* to standard output. - void ca_factor_insert(ca_factor_t fac, const ca_t base, const ca_t exp, ca_ctx_t ctx) noexcept - # Inserts `b^e` into *fac* where *b* is given by *base* and *e* - # is given by *exp*. If a base element structurally identical to *base* - # already exists in *fac*, the corresponding exponent is incremented by *exp*; - # otherwise, this factor is appended. - void ca_factor_get_ca(ca_t res, const ca_factor_t fac, ca_ctx_t ctx) noexcept - # Expands *fac* back to a single :type:`ca_t` by evaluating the powers - # and multiplying out the result. - void ca_factor(ca_factor_t res, const ca_t x, ulong flags, ca_ctx_t ctx) noexcept - # Sets *res* to a factorization of *x* - # of the form `x = b_1^{e_1} b_2^{e_2} \cdots b_n^{e_n}`. - # Requires that *x* is not a special value. - # The type of factorization is controlled by *flags*, which can be set - # to a combination of constants in the following section. - void _ca_make_field_element(ca_t x, ca_field_srcptr new_index, ca_ctx_t ctx) noexcept - # Changes the internal representation of *x* to that of an element - # of the field with index *new_index* in the context object *ctx*. - # This may destroy the value of *x*. - void _ca_make_fmpq(ca_t x, ca_ctx_t ctx) noexcept - # Changes the internal representation of *x* to that of an element of - # the trivial field `\mathbb{Q}`. This may destroy the value of *x*. diff --git a/src/sage/libs/flint/ca_ext.pxd b/src/sage/libs/flint/ca_ext.pxd index 3748622e07b..62aa7309934 100644 --- a/src/sage/libs/flint/ca_ext.pxd +++ b/src/sage/libs/flint/ca_ext.pxd @@ -2,7 +2,9 @@ # distutils: depends = flint/ca_ext.h ################################################################################ -# This file is auto-generated. Do not modify by hand +# This file is auto-generated by the script +# SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py. +# Do not modify by hand! Fix and rerun the script instead. ################################################################################ from libc.stdio cimport FILE @@ -11,70 +13,20 @@ from sage.libs.mpfr.types cimport * from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void ca_ext_init_qqbar(ca_ext_t res, const qqbar_t x, ca_ctx_t ctx) noexcept - # Initializes *res* and sets it to the algebraic constant *x*. - void ca_ext_init_const(ca_ext_t res, calcium_func_code func, ca_ctx_t ctx) noexcept - # Initializes *res* and sets it to the constant defined by *func* - # (example: *func* = *CA_Pi* for `x = \pi`). - void ca_ext_init_fx(ca_ext_t res, calcium_func_code func, const ca_t x, ca_ctx_t ctx) noexcept - # Initializes *res* and sets it to the univariate function value `f(x)` - # where *f* is defined by *func* (example: *func* = *CA_Exp* for `e^x`). - void ca_ext_init_fxy(ca_ext_t res, calcium_func_code func, const ca_t x, const ca_t y, ca_ctx_t ctx) noexcept - # Initializes *res* and sets it to the bivariate function value `f(x, y)` - # where *f* is defined by *func* (example: *func* = *CA_Pow* for `x^y`). - void ca_ext_init_fxn(ca_ext_t res, calcium_func_code func, ca_srcptr x, slong nargs, ca_ctx_t ctx) noexcept - # Initializes *res* and sets it to the multivariate function value - # `f(x_1, \ldots, x_n)` where *f* is defined by *func* and *n* is - # given by *nargs*. - void ca_ext_init_set(ca_ext_t res, const ca_ext_t x, ca_ctx_t ctx) noexcept - # Initializes *res* and sets it to a copy of *x*. - void ca_ext_clear(ca_ext_t res, ca_ctx_t ctx) noexcept - # Clears *res*. - slong ca_ext_nargs(const ca_ext_t x, ca_ctx_t ctx) noexcept - # Returns the number of function arguments of *x*. - # The return value is 0 for any algebraic constant and for any built-in - # symbolic constant such as `\pi`. - void ca_ext_get_arg(ca_t res, const ca_ext_t x, slong i, ca_ctx_t ctx) noexcept - # Sets *res* to argument *i* (indexed from zero) of *x*. - # This calls *flint_abort* if *i* is out of range. - ulong ca_ext_hash(const ca_ext_t x, ca_ctx_t ctx) noexcept - # Returns a hash of the structural representation of *x*. - bint ca_ext_equal_repr(const ca_ext_t x, const ca_ext_t y, ca_ctx_t ctx) noexcept - # Tests *x* and *y* for structural equality, returning 0 (false) or 1 (true). - int ca_ext_cmp_repr(const ca_ext_t x, const ca_ext_t y, ca_ctx_t ctx) noexcept - # Compares the representations of *x* and *y* in a canonical sort order, - # returning -1, 0 or 1. This only performs a structural comparison - # of the symbolic representations; the return value does not say - # anything meaningful about the numbers represented by *x* and *y*. - void ca_ext_print(const ca_ext_t x, ca_ctx_t ctx) noexcept - # Prints a description of *x* to standard output. - void ca_ext_get_acb_raw(acb_t res, ca_ext_t x, slong prec, ca_ctx_t ctx) noexcept - # Sets *res* to an enclosure of the numerical value of *x*. - # A working precision of *prec* bits is used for the evaluation, - # without adaptive refinement. - void ca_ext_cache_init(ca_ext_cache_t cache, ca_ctx_t ctx) noexcept - # Initializes *cache* for use. - void ca_ext_cache_clear(ca_ext_cache_t cache, ca_ctx_t ctx) noexcept - # Clears *cache*, freeing the memory allocated internally. - ca_ext_ptr ca_ext_cache_insert(ca_ext_cache_t cache, const ca_ext_t x, ca_ctx_t ctx) noexcept - # Adds *x* to *cache* without duplication. If a structurally identical - # instance already exists in *cache*, a pointer to that instance is returned. - # Otherwise, a copy of *x* is inserted into *cache* and a pointer to that new - # instance is returned. diff --git a/src/sage/libs/flint/ca_field.pxd b/src/sage/libs/flint/ca_field.pxd index bd67f953468..3116540c419 100644 --- a/src/sage/libs/flint/ca_field.pxd +++ b/src/sage/libs/flint/ca_field.pxd @@ -2,7 +2,9 @@ # distutils: depends = flint/ca_field.h ################################################################################ -# This file is auto-generated. Do not modify by hand +# This file is auto-generated by the script +# SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py. +# Do not modify by hand! Fix and rerun the script instead. ################################################################################ from libc.stdio cimport FILE @@ -11,78 +13,18 @@ from sage.libs.mpfr.types cimport * from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void ca_field_init_qq(ca_field_t K, ca_ctx_t ctx) noexcept - # Initializes *K* to represent the trivial field `\mathbb{Q}`. - void ca_field_init_nf(ca_field_t K, const qqbar_t x, ca_ctx_t ctx) noexcept - # Initializes *K* to represent the algebraic number field `\mathbb{Q}(x)`. - void ca_field_init_const(ca_field_t K, calcium_func_code func, ca_ctx_t ctx) noexcept - # Initializes *K* to represent the field - # `\mathbb{Q}(x)` where *x* is a builtin constant defined by - # *func* (example: *func* = *CA_Pi* for `x = \pi`). - void ca_field_init_fx(ca_field_t K, calcium_func_code func, const ca_t x, ca_ctx_t ctx) noexcept - # Initializes *K* to represent the field - # `\mathbb{Q}(a)` where `a = f(x)`, given a number *x* and a builtin - # univariate function *func* (example: *func* = *CA_Exp* for `e^x`). - void ca_field_init_fxy(ca_field_t K, calcium_func_code func, const ca_t x, const ca_t y, ca_ctx_t ctx) noexcept - # Initializes *K* to represent the field - # `\mathbb{Q}(a,b)` where `a = f(x, y)`. - void ca_field_init_multi(ca_field_t K, slong len, ca_ctx_t ctx) noexcept - # Initializes *K* to represent a multivariate field - # `\mathbb{Q}(a_1, \ldots, a_n)` in *n* - # extension numbers. The extension numbers must subsequently be - # assigned one by one using :func:`ca_field_set_ext`. - void ca_field_set_ext(ca_field_t K, slong i, ca_ext_srcptr x_index, ca_ctx_t ctx) noexcept - # Sets the extension number at position *i* (here indexed from 0) of *K* - # to the generator of the field with index *x_index* in *ctx*. - # (It is assumed that the generating field is a univariate field.) - # This only inserts a shallow reference: the field at index *x_index* must - # be kept alive until *K* has been cleared. - void ca_field_clear(ca_field_t K, ca_ctx_t ctx) noexcept - # Clears the field *K*. This does not clear the individual extension - # numbers, which are only held as references. - void ca_field_print(const ca_field_t K, ca_ctx_t ctx) noexcept - # Prints a description of the field *K* to standard output. - void ca_field_build_ideal(ca_field_t K, ca_ctx_t ctx) noexcept - # Given *K* with assigned extension numbers, - # builds the reduction ideal in-place. - void ca_field_build_ideal_erf(ca_field_t K, ca_ctx_t ctx) noexcept - # Builds relations for error functions present among the extension - # numbers in *K*. This heuristic adds relations that are consequences - # of the functional equations - # `\operatorname{erf}(x) = -\operatorname{erf}(-x)`, - # `\operatorname{erfc}(x) = 1-\operatorname{erf}(x)`, - # `\operatorname{erfi}(x) = -i\operatorname{erf}(ix)`. - int ca_field_cmp(const ca_field_t K1, const ca_field_t K2, ca_ctx_t ctx) noexcept - # Compares the field objects *K1* and *K2* in a canonical sort order, - # returning -1, 0 or 1. This only performs a lexicographic comparison - # of the representations of *K1* and *K2*; the return value does not say - # anything meaningful about the relative structures of *K1* and *K2* - # as mathematical fields. - void ca_field_cache_init(ca_field_cache_t cache, ca_ctx_t ctx) noexcept - # Initializes *cache* for use. - void ca_field_cache_clear(ca_field_cache_t cache, ca_ctx_t ctx) noexcept - # Clears *cache*, freeing the memory allocated internally. - # This does not clear the individual extension - # numbers, which are only held as references. - ca_field_ptr ca_field_cache_insert_ext(ca_field_cache_t cache, ca_ext_struct ** x, slong len, ca_ctx_t ctx) noexcept - # Adds the field defined by the length-*len* list of extension numbers *x* - # to *cache* without duplication. If such a field already exists in *cache*, - # a pointer to that instance is returned. Otherwise, a field with - # extension numbers *x* is inserted into *cache* and a pointer to that - # new instance is returned. Upon insertion of a new field, the - # reduction ideal is constructed via :func:`ca_field_build_ideal`. diff --git a/src/sage/libs/flint/ca_mat.pxd b/src/sage/libs/flint/ca_mat.pxd index 243214f4397..600f5d50887 100644 --- a/src/sage/libs/flint/ca_mat.pxd +++ b/src/sage/libs/flint/ca_mat.pxd @@ -2,7 +2,9 @@ # distutils: depends = flint/ca_mat.h ################################################################################ -# This file is auto-generated. Do not modify by hand +# This file is auto-generated by the script +# SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py. +# Do not modify by hand! Fix and rerun the script instead. ################################################################################ from libc.stdio cimport FILE @@ -11,440 +13,103 @@ from sage.libs.mpfr.types cimport * from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - ca_ptr ca_mat_entry_ptr(ca_mat_t mat, slong i, slong j) noexcept - # Returns a pointer to the entry at row *i* and column *j*. - # Equivalent to :macro:`ca_mat_entry` but implemented as a function. - void ca_mat_init(ca_mat_t mat, slong r, slong c, ca_ctx_t ctx) noexcept - # Initializes the matrix, setting it to the zero matrix with *r* rows - # and *c* columns. - void ca_mat_clear(ca_mat_t mat, ca_ctx_t ctx) noexcept - # Clears the matrix, deallocating all entries. - void ca_mat_swap(ca_mat_t mat1, ca_mat_t mat2, ca_ctx_t ctx) noexcept - # Efficiently swaps *mat1* and *mat2*. - void ca_mat_window_init(ca_mat_t window, const ca_mat_t mat, slong r1, slong c1, slong r2, slong c2, ca_ctx_t ctx) noexcept - # Initializes *window* to a window matrix into the submatrix of *mat* - # starting at the corner at row *r1* and column *c1* (inclusive) and ending - # at row *r2* and column *c2* (exclusive). - void ca_mat_window_clear(ca_mat_t window, ca_ctx_t ctx) noexcept - # Frees the window matrix. - void ca_mat_set(ca_mat_t dest, const ca_mat_t src, ca_ctx_t ctx) noexcept void ca_mat_set_fmpz_mat(ca_mat_t dest, const fmpz_mat_t src, ca_ctx_t ctx) noexcept void ca_mat_set_fmpq_mat(ca_mat_t dest, const fmpq_mat_t src, ca_ctx_t ctx) noexcept - # Sets *dest* to *src*. The operands must have identical dimensions. - void ca_mat_set_ca(ca_mat_t mat, const ca_t c, ca_ctx_t ctx) noexcept - # Sets *mat* to the matrix with the scalar *c* on the main diagonal - # and zeros elsewhere. - void ca_mat_transfer(ca_mat_t res, ca_ctx_t res_ctx, const ca_mat_t src, ca_ctx_t src_ctx) noexcept - # Sets *res* to *src* where the corresponding context objects *res_ctx* and - # *src_ctx* may be different. - # This operation preserves the mathematical value represented by *src*, - # but may result in a different internal representation depending on the - # settings of the context objects. - void ca_mat_randtest(ca_mat_t mat, flint_rand_t state, slong depth, slong bits, ca_ctx_t ctx) noexcept - # Sets *mat* to a random matrix with entries having complexity up to - # *depth* and *bits* (see :func:`ca_randtest`). - void ca_mat_randtest_rational(ca_mat_t mat, flint_rand_t state, slong bits, ca_ctx_t ctx) noexcept - # Sets *mat* to a random rational matrix with entries up to *bits* bits in size. - void ca_mat_randops(ca_mat_t mat, flint_rand_t state, slong count, ca_ctx_t ctx) noexcept - # Randomizes *mat* in-place by performing elementary row or column operations. - # More precisely, at most count random additions or subtractions of distinct - # rows and columns will be performed. This leaves the rank (and for square matrices, - # the determinant) unchanged. - void ca_mat_print(const ca_mat_t mat, ca_ctx_t ctx) noexcept - # Prints *mat* to standard output. The entries are printed on separate lines. - void ca_mat_printn(const ca_mat_t mat, slong digits, ca_ctx_t ctx) noexcept - # Prints a decimal representation of *mat* with precision specified by *digits*. - # The entries are comma-separated with square brackets and comma separation - # for the rows. - void ca_mat_zero(ca_mat_t mat, ca_ctx_t ctx) noexcept - # Sets all entries in *mat* to zero. - void ca_mat_one(ca_mat_t mat, ca_ctx_t ctx) noexcept - # Sets the entries on the main diagonal of *mat* to one, and - # all other entries to zero. - void ca_mat_ones(ca_mat_t mat, ca_ctx_t ctx) noexcept - # Sets all entries in *mat* to one. - void ca_mat_pascal(ca_mat_t mat, int triangular, ca_ctx_t ctx) noexcept - # Sets *mat* to a Pascal matrix, whose entries are binomial coefficients. - # If *triangular* is 0, constructs a full symmetric matrix - # with the rows of Pascal's triangle as successive antidiagonals. - # If *triangular* is 1, constructs the upper triangular matrix with - # the rows of Pascal's triangle as columns, and if *triangular* is -1, - # constructs the lower triangular matrix with the rows of Pascal's - # triangle as rows. - void ca_mat_stirling(ca_mat_t mat, int kind, ca_ctx_t ctx) noexcept - # Sets *mat* to a Stirling matrix, whose entries are Stirling numbers. - # If *kind* is 0, the entries are set to the unsigned Stirling numbers - # of the first kind. If *kind* is 1, the entries are set to the signed - # Stirling numbers of the first kind. If *kind* is 2, the entries are - # set to the Stirling numbers of the second kind. - void ca_mat_hilbert(ca_mat_t mat, ca_ctx_t ctx) noexcept - # Sets *mat* to the Hilbert matrix, which has entries `A_{i,j} = 1/(i+j+1)`. - void ca_mat_dft(ca_mat_t mat, int type, ca_ctx_t ctx) noexcept - # Sets *mat* to the DFT (discrete Fourier transform) matrix of order *n* - # where *n* is the smallest dimension of *mat* (if *mat* is not square, - # the matrix is extended periodically along the larger dimension). - # The *type* parameter selects between four different versions - # of the DFT matrix (in which `\omega = e^{2\pi i/n}`): - # * Type 0 -- entries `A_{j,k} = \omega^{-jk}` - # * Type 1 -- entries `A_{j,k} = \omega^{jk} / n` - # * Type 2 -- entries `A_{j,k} = \omega^{-jk} / \sqrt{n}` - # * Type 3 -- entries `A_{j,k} = \omega^{jk} / \sqrt{n}` - # The type 0 and 1 matrices are inverse pairs, and similarly for the - # type 2 and 3 matrices. - truth_t ca_mat_check_equal(const ca_mat_t A, const ca_mat_t B, ca_ctx_t ctx) noexcept - # Compares *A* and *B* for equality. - truth_t ca_mat_check_is_zero(const ca_mat_t A, ca_ctx_t ctx) noexcept - # Tests if *A* is the zero matrix. - truth_t ca_mat_check_is_one(const ca_mat_t A, ca_ctx_t ctx) noexcept - # Tests if *A* has ones on the main diagonal and zeros elsewhere. - void ca_mat_transpose(ca_mat_t res, const ca_mat_t A, ca_ctx_t ctx) noexcept - # Sets *res* to the transpose of *A*. - void ca_mat_conj(ca_mat_t res, const ca_mat_t A, ca_ctx_t ctx) noexcept - # Sets *res* to the entrywise complex conjugate of *A*. - void ca_mat_conj_transpose(ca_mat_t res, const ca_mat_t A, ca_ctx_t ctx) noexcept - # Sets *res* to the conjugate transpose (Hermitian transpose) of *A*. - void ca_mat_neg(ca_mat_t res, const ca_mat_t A, ca_ctx_t ctx) noexcept - # Sets *res* to the negation of *A*. - void ca_mat_add(ca_mat_t res, const ca_mat_t A, const ca_mat_t B, ca_ctx_t ctx) noexcept - # Sets *res* to the sum of *A* and *B*. - void ca_mat_sub(ca_mat_t res, const ca_mat_t A, const ca_mat_t B, ca_ctx_t ctx) noexcept - # Sets *res* to the difference of *A* and *B*. - void ca_mat_mul_classical(ca_mat_t res, const ca_mat_t A, const ca_mat_t B, ca_ctx_t ctx) noexcept void ca_mat_mul_same_nf(ca_mat_t res, const ca_mat_t A, const ca_mat_t B, ca_field_t K, ca_ctx_t ctx) noexcept void ca_mat_mul(ca_mat_t res, const ca_mat_t A, const ca_mat_t B, ca_ctx_t ctx) noexcept - # Sets *res* to the matrix product of *A* and *B*. - # The *classical* version uses classical multiplication. - # The *same_nf* version assumes (not checked) that both *A* and *B* - # have coefficients in the same simple algebraic number field *K* - # or in `\mathbb{Q}`. - # The default version chooses an algorithm automatically. - void ca_mat_mul_si(ca_mat_t B, const ca_mat_t A, slong c, ca_ctx_t ctx) noexcept void ca_mat_mul_fmpz(ca_mat_t B, const ca_mat_t A, const fmpz_t c, ca_ctx_t ctx) noexcept void ca_mat_mul_fmpq(ca_mat_t B, const ca_mat_t A, const fmpq_t c, ca_ctx_t ctx) noexcept void ca_mat_mul_ca(ca_mat_t B, const ca_mat_t A, const ca_t c, ca_ctx_t ctx) noexcept - # Sets *B* to *A* multiplied by the scalar *c*. - void ca_mat_div_si(ca_mat_t B, const ca_mat_t A, slong c, ca_ctx_t ctx) noexcept void ca_mat_div_fmpz(ca_mat_t B, const ca_mat_t A, const fmpz_t c, ca_ctx_t ctx) noexcept void ca_mat_div_fmpq(ca_mat_t B, const ca_mat_t A, const fmpq_t c, ca_ctx_t ctx) noexcept void ca_mat_div_ca(ca_mat_t B, const ca_mat_t A, const ca_t c, ca_ctx_t ctx) noexcept - # Sets *B* to *A* divided by the scalar *c*. - void ca_mat_add_ca(ca_mat_t B, const ca_mat_t A, const ca_t c, ca_ctx_t ctx) noexcept void ca_mat_sub_ca(ca_mat_t B, const ca_mat_t A, const ca_t c, ca_ctx_t ctx) noexcept - # Sets *B* to *A* plus or minus the scalar *c* (interpreted as a diagonal matrix). - void ca_mat_addmul_ca(ca_mat_t B, const ca_mat_t A, const ca_t c, ca_ctx_t ctx) noexcept void ca_mat_submul_ca(ca_mat_t B, const ca_mat_t A, const ca_t c, ca_ctx_t ctx) noexcept - # Sets the matrix *B* to *B* plus (or minus) the matrix *A* multiplied by the scalar *c*. - void ca_mat_sqr(ca_mat_t B, const ca_mat_t A, ca_ctx_t ctx) noexcept - # Sets *B* to the square of *A*. - void ca_mat_pow_ui_binexp(ca_mat_t B, const ca_mat_t A, ulong exp, ca_ctx_t ctx) noexcept - # Sets *B* to *A* raised to the power *exp*, evaluated using - # binary exponentiation. - void _ca_mat_ca_poly_evaluate(ca_mat_t res, ca_srcptr poly, slong len, const ca_mat_t A, ca_ctx_t ctx) noexcept void ca_mat_ca_poly_evaluate(ca_mat_t res, const ca_poly_t poly, const ca_mat_t A, ca_ctx_t ctx) noexcept - # Sets *res* to `f(A)` where *f* is the polynomial given by *poly* - # and *A* is a square matrix. Uses the Paterson-Stockmeyer algorithm. - truth_t ca_mat_find_pivot(slong * pivot_row, ca_mat_t mat, slong start_row, slong end_row, slong column, ca_ctx_t ctx) noexcept - # Attempts to find a nonzero entry in *mat* with column index *column* - # and row index between *start_row* (inclusive) and *end_row* (exclusive). - # If the return value is ``T_TRUE``, such an element exists, - # and *pivot_row* is set to the row index. - # If the return value is ``T_FALSE``, no such element exists - # (all entries in this part of the column are zero). - # If the return value is ``T_UNKNOWN``, it is unknown whether such - # an element exists (zero certification failed). - # This function is destructive: any elements that are nontrivially - # zero but can be certified zero will be overwritten by exact zeros. - int ca_mat_lu_classical(slong * rank, slong * P, ca_mat_t LU, const ca_mat_t A, int rank_check, ca_ctx_t ctx) noexcept int ca_mat_lu_recursive(slong * rank, slong * P, ca_mat_t LU, const ca_mat_t A, int rank_check, ca_ctx_t ctx) noexcept int ca_mat_lu(slong * rank, slong * P, ca_mat_t LU, const ca_mat_t A, int rank_check, ca_ctx_t ctx) noexcept - # Computes a generalized LU decomposition `A = PLU` of a given - # matrix *A*, writing the rank of *A* to *rank*. - # If *A* is a nonsingular square matrix, *LU* will be set to - # a unit diagonal lower triangular matrix *L* and an upper - # triangular matrix *U* (the diagonal of *L* will not be stored - # explicitly). - # If *A* is an arbitrary matrix of rank *r*, *U* will be in row - # echelon form having *r* nonzero rows, and *L* will be lower - # triangular but truncated to *r* columns, having implicit ones on - # the *r* first entries of the main diagonal. All other entries will - # be zero. - # If a nonzero value for ``rank_check`` is passed, the function - # will abandon the output matrix in an undefined state and set - # the rank to 0 if *A* is detected to be rank-deficient. - # The algorithm can fail if it fails to certify that a pivot - # element is zero or nonzero, in which case the correct rank - # cannot be determined. - # The return value is 1 on success and 0 on failure. On failure, - # the data in the output variables - # ``rank``, ``P`` and ``LU`` will be meaningless. - # The *classical* version uses iterative Gaussian elimination. - # The *recursive* version uses a block recursive algorithm - # to take advantage of fast matrix multiplication. - int ca_mat_fflu(slong * rank, slong * P, ca_mat_t LU, ca_t den, const ca_mat_t A, int rank_check, ca_ctx_t ctx) noexcept - # Similar to :func:`ca_mat_lu`, but computes a fraction-free - # LU decomposition using the Bareiss algorithm. - # The denominator is written to *den*. - # Note that despite being "fraction-free", this algorithm may - # introduce fractions due to incomplete symbolic simplifications. - truth_t ca_mat_nonsingular_lu(slong * P, ca_mat_t LU, const ca_mat_t A, ca_ctx_t ctx) noexcept - # Wrapper for :func:`ca_mat_lu`. - # If *A* can be proved to be invertible/nonsingular, returns ``T_TRUE`` and sets *P* and *LU* to a LU decomposition `A = PLU`. - # If *A* can be proved to be singular, returns ``T_FALSE``. - # If *A* cannot be proved to be either singular or nonsingular, returns ``T_UNKNOWN``. - # When the return value is ``T_FALSE`` or ``T_UNKNOWN``, the - # LU factorization is not completed and the values of - # *P* and *LU* are arbitrary. - truth_t ca_mat_nonsingular_fflu(slong * P, ca_mat_t LU, ca_t den, const ca_mat_t A, ca_ctx_t ctx) noexcept - # Wrapper for :func:`ca_mat_fflu`. - # Similar to :func:`ca_mat_nonsingular_lu`, but computes a fraction-free - # LU decomposition using the Bareiss algorithm. - # The denominator is written to *den*. - # Note that despite being "fraction-free", this algorithm may - # introduce fractions due to incomplete symbolic simplifications. - truth_t ca_mat_inv(ca_mat_t X, const ca_mat_t A, ca_ctx_t ctx) noexcept - # Determines if the square matrix *A* is nonsingular, and if successful, - # sets `X = A^{-1}` and returns ``T_TRUE``. - # Returns ``T_FALSE`` if *A* is singular, and ``T_UNKNOWN`` if the - # rank of *A* cannot be determined. - truth_t ca_mat_nonsingular_solve_adjugate(ca_mat_t X, const ca_mat_t A, const ca_mat_t B, ca_ctx_t ctx) noexcept truth_t ca_mat_nonsingular_solve_fflu(ca_mat_t X, const ca_mat_t A, const ca_mat_t B, ca_ctx_t ctx) noexcept truth_t ca_mat_nonsingular_solve_lu(ca_mat_t X, const ca_mat_t A, const ca_mat_t B, ca_ctx_t ctx) noexcept truth_t ca_mat_nonsingular_solve(ca_mat_t X, const ca_mat_t A, const ca_mat_t B, ca_ctx_t ctx) noexcept - # Determines if the square matrix *A* is nonsingular, and if successful, - # solves `AX = B` and returns ``T_TRUE``. - # Returns ``T_FALSE`` if *A* is singular, and ``T_UNKNOWN`` if the - # rank of *A* cannot be determined. - void ca_mat_solve_tril_classical(ca_mat_t X, const ca_mat_t L, const ca_mat_t B, int unit, ca_ctx_t ctx) noexcept void ca_mat_solve_tril_recursive(ca_mat_t X, const ca_mat_t L, const ca_mat_t B, int unit, ca_ctx_t ctx) noexcept void ca_mat_solve_tril(ca_mat_t X, const ca_mat_t L, const ca_mat_t B, int unit, ca_ctx_t ctx) noexcept void ca_mat_solve_triu_classical(ca_mat_t X, const ca_mat_t U, const ca_mat_t B, int unit, ca_ctx_t ctx) noexcept void ca_mat_solve_triu_recursive(ca_mat_t X, const ca_mat_t U, const ca_mat_t B, int unit, ca_ctx_t ctx) noexcept void ca_mat_solve_triu(ca_mat_t X, const ca_mat_t U, const ca_mat_t B, int unit, ca_ctx_t ctx) noexcept - # Solves the lower triangular system `LX = B` or the upper triangular system - # `UX = B`, respectively. It is assumed (not checked) that the diagonal - # entries are nonzero. If *unit* is set, the main diagonal of *L* or *U* - # is taken to consist of all ones, and in that case the actual entries on - # the diagonal are not read at all and can contain other data. - # The *classical* versions perform the computations iteratively while the - # *recursive* versions perform the computations in a block recursive - # way to benefit from fast matrix multiplication. The default versions - # choose an algorithm automatically. - void ca_mat_solve_fflu_precomp(ca_mat_t X, const slong * perm, const ca_mat_t A, const ca_t den, const ca_mat_t B, ca_ctx_t ctx) noexcept void ca_mat_solve_lu_precomp(ca_mat_t X, const slong * P, const ca_mat_t LU, const ca_mat_t B, ca_ctx_t ctx) noexcept - # Solves `AX = B` given the precomputed nonsingular LU decomposition `A = PLU` - # or fraction-free LU decomposition with denominator *den*. - # The matrices `X` and `B` are allowed to be aliased with each other, - # but `X` is not allowed to be aliased with `LU`. - int ca_mat_rank(slong * rank, const ca_mat_t A, ca_ctx_t ctx) noexcept - # Computes the rank of the matrix *A*. If successful, returns 1 and - # writes the rank to ``rank``. If unsuccessful, returns 0. - int ca_mat_rref_fflu(slong * rank, ca_mat_t R, const ca_mat_t A, ca_ctx_t ctx) noexcept int ca_mat_rref_lu(slong * rank, ca_mat_t R, const ca_mat_t A, ca_ctx_t ctx) noexcept int ca_mat_rref(slong * rank, ca_mat_t R, const ca_mat_t A, ca_ctx_t ctx) noexcept - # Computes the reduced row echelon form (rref) of a given matrix. - # On success, sets *R* to the rref of *A*, writes the rank to - # *rank*, and returns 1. On failure to certify the correct rank, - # returns 0, leaving the data in *rank* and *R* meaningless. - # The *fflu* version computes a fraction-free LU decomposition and - # then converts the output ro rref form. The *lu* version computes a - # regular LU decomposition and then converts the output to rref form. - # The default version uses an automatic algorithm choice and may - # implement additional methods for special cases. - int ca_mat_right_kernel(ca_mat_t X, const ca_mat_t A, ca_ctx_t ctx) noexcept - # Sets *X* to a basis of the right kernel (nullspace) of *A*. - # The output matrix *X* will be resized in-place to have a number - # of columns equal to the nullity of *A*. - # Returns 1 on success. On failure, returns 0 and leaves the data - # in *X* meaningless. - void ca_mat_trace(ca_t trace, const ca_mat_t mat, ca_ctx_t ctx) noexcept - # Sets *trace* to the sum of the entries on the main diagonal of *mat*. - void ca_mat_det_berkowitz(ca_t det, const ca_mat_t A, ca_ctx_t ctx) noexcept int ca_mat_det_lu(ca_t det, const ca_mat_t A, ca_ctx_t ctx) noexcept int ca_mat_det_bareiss(ca_t det, const ca_mat_t A, ca_ctx_t ctx) noexcept void ca_mat_det_cofactor(ca_t det, const ca_mat_t A, ca_ctx_t ctx) noexcept void ca_mat_det(ca_t det, const ca_mat_t A, ca_ctx_t ctx) noexcept - # Sets *det* to the determinant of the square matrix *A*. - # Various algorithms are available: - # * The *berkowitz* version uses the division-free Berkowitz algorithm - # performing `O(n^4)` operations. Since no zero tests are required, it - # is guaranteed to succeed. - # * The *cofactor* version performs cofactor expansion. This is currently - # only supported for matrices up to size 4. - # * The *lu* and *bareiss* versions use rational LU decomposition - # and fraction-free LU decomposition (Bareiss algorithm) respectively, - # requiring `O(n^3)` operations. These algorithms can fail if zero - # certification fails (see :func:`ca_mat_nonsingular_lu`); they - # return 1 for success and 0 for failure. - # Note that the Bareiss algorithm, despite being "fraction-free", - # may introduce fractions due to incomplete symbolic simplifications. - # The default function chooses an algorithm automatically. - # It will, in addition, recognize trivially rational and integer - # matrices and evaluate those determinants using - # :type:`fmpq_mat_t` or :type:`fmpz_mat_t`. - # The various algorithms can produce different symbolic - # forms of the same determinant. Which algorithm performs better - # depends strongly and sometimes - # unpredictably on the structure of the matrix. - void ca_mat_adjugate_cofactor(ca_mat_t adj, ca_t det, const ca_mat_t A, ca_ctx_t ctx) noexcept void ca_mat_adjugate_charpoly(ca_mat_t adj, ca_t det, const ca_mat_t A, ca_ctx_t ctx) noexcept void ca_mat_adjugate(ca_mat_t adj, ca_t det, const ca_mat_t A, ca_ctx_t ctx) noexcept - # Sets *adj* to the adjuate matrix of *A* and *det* to the determinant - # of *A*, both computed simultaneously. - # The *cofactor* version uses cofactor expansion. - # The *charpoly* version computes and - # evaluates the characteristic polynomial. - # The default version uses an automatic algorithm choice. - void _ca_mat_charpoly_berkowitz(ca_ptr cp, const ca_mat_t mat, ca_ctx_t ctx) noexcept void ca_mat_charpoly_berkowitz(ca_poly_t cp, const ca_mat_t mat, ca_ctx_t ctx) noexcept int _ca_mat_charpoly_danilevsky(ca_ptr cp, const ca_mat_t mat, ca_ctx_t ctx) noexcept int ca_mat_charpoly_danilevsky(ca_poly_t cp, const ca_mat_t mat, ca_ctx_t ctx) noexcept void _ca_mat_charpoly(ca_ptr cp, const ca_mat_t mat, ca_ctx_t ctx) noexcept void ca_mat_charpoly(ca_poly_t cp, const ca_mat_t mat, ca_ctx_t ctx) noexcept - # Sets *poly* to the characteristic polynomial of *mat* which must be - # a square matrix. If the matrix has *n* rows, the underscore method - # requires space for `n + 1` output coefficients. - # The *berkowitz* version uses a division-free algorithm - # requiring `O(n^4)` operations. - # The *danilevsky* version only performs `O(n^3)` operations, but - # performs divisions and needs to check for zero which can fail. - # This version returns 1 on success and 0 on failure. - # The default version chooses an algorithm automatically. - int ca_mat_companion(ca_mat_t mat, const ca_poly_t poly, ca_ctx_t ctx) noexcept - # Sets *mat* to the companion matrix of *poly*. - # This function verifies that the leading coefficient of *poly* - # is provably nonzero and that the output matrix has the right size, - # returning 1 on success. - # It returns 0 if the leading coefficient of *poly* cannot be - # proved nonzero or if the size of the output matrix does not match. - int ca_mat_eigenvalues(ca_vec_t lmbda, ulong * exp, const ca_mat_t mat, ca_ctx_t ctx) noexcept - # Attempts to compute all complex eigenvalues of the given matrix *mat*. - # On success, returns 1 and sets *lambda* to the distinct eigenvalues - # with corresponding multiplicities in *exp*. - # The eigenvalues are returned in arbitrary order. - # On failure, returns 0 and leaves the values in *lambda* and *exp* - # arbitrary. - # This function effectively computes the characteristic polynomial - # and then calls :type:`ca_poly_roots`. - truth_t ca_mat_diagonalization(ca_mat_t D, ca_mat_t P, const ca_mat_t A, ca_ctx_t ctx) noexcept - # Matrix diagonalization: attempts to compute a diagonal matrix *D* - # and an invertible matrix *P* such that `A = PDP^{-1}`. - # Returns ``T_TRUE`` if *A* is diagonalizable and the computation - # succeeds, ``T_FALSE`` if *A* is provably not diagonalizable, - # and ``T_UNKNOWN`` if it is unknown whether *A* is diagonalizable. - # If the return value is not ``T_TRUE``, the values in *D* and *P* - # are arbitrary. - int ca_mat_jordan_blocks(ca_vec_t lmbda, slong * num_blocks, slong * block_lambda, slong * block_size, const ca_mat_t A, ca_ctx_t ctx) noexcept - # Computes the blocks of the Jordan canonical form of *A*. - # On success, returns 1 and sets *lambda* to the unique eigenvalues - # of *A*, sets *num_blocks* to the number of Jordan blocks, - # entry *i* of *block_lambda* to the index of the eigenvalue - # in Jordan block *i*, and entry *i* of *block_size* to the size - # of Jordan block *i*. On failure, returns 0, leaving arbitrary - # values in the output variables. - # The user should allocate space in *block_lambda* and *block_size* - # for up to *n* entries where *n* is the size of the matrix. - # The Jordan form is unique up to the ordering of blocks, which - # is arbitrary. - void ca_mat_set_jordan_blocks(ca_mat_t mat, const ca_vec_t lmbda, slong num_blocks, slong * block_lambda, slong * block_size, ca_ctx_t ctx) noexcept - # Sets *mat* to the concatenation of the Jordan blocks - # given in *lambda*, *num_blocks*, *block_lambda* and *block_size*. - # See :func:`ca_mat_jordan_blocks` for an explanation of these - # variables. - int ca_mat_jordan_transformation(ca_mat_t mat, const ca_vec_t lmbda, slong num_blocks, slong * block_lambda, slong * block_size, const ca_mat_t A, ca_ctx_t ctx) noexcept - # Given the precomputed Jordan block decomposition - # (*lambda*, *num_blocks*, *block_lambda*, *block_size*) of the - # square matrix *A*, computes the corresponding transformation - # matrix *P* such that `A = P J P^{-1}`. - # On success, writes *P* to *mat* and returns 1. On failure, - # returns 0, leaving the value of *mat* arbitrary. - int ca_mat_jordan_form(ca_mat_t J, ca_mat_t P, const ca_mat_t A, ca_ctx_t ctx) noexcept - # Computes the Jordan decomposition `A = P J P^{-1}` of the given - # square matrix *A*. The user can pass *NULL* for the output - # variable *P*, in which case only *J* is computed. - # On success, returns 1. On failure, returns 0, leaving the values - # of *J* and *P* arbitrary. - # This function is a convenience wrapper around - # :func:`ca_mat_jordan_blocks`, :func:`ca_mat_set_jordan_blocks` and - # :func:`ca_mat_jordan_transformation`. For computations with - # the Jordan decomposition, it is often better to use those - # methods directly since they give direct access to the - # spectrum and block structure. - int ca_mat_exp(ca_mat_t res, const ca_mat_t A, ca_ctx_t ctx) noexcept - # Matrix exponential: given a square matrix *A*, sets *res* to - # `e^A` and returns 1 on success. If unsuccessful, returns 0, - # leaving the values in *res* arbitrary. - # This function uses Jordan decomposition. The matrix exponential - # always exists, but computation can fail if computing the Jordan - # decomposition fails. - truth_t ca_mat_log(ca_mat_t res, const ca_mat_t A, ca_ctx_t ctx) noexcept - # Matrix logarithm: given a square matrix *A*, sets *res* to a - # logarithm `\log(A)` and returns ``T_TRUE`` on success. - # If *A* can be proved to have no logarithm, returns ``T_FALSE``. - # If the existence of a logarithm cannot be proved, returns - # ``T_UNKNOWN``. - # This function uses the Jordan decomposition, and the branch of - # the matrix logarithm is defined by taking the principal values - # of the logarithms of all eigenvalues. diff --git a/src/sage/libs/flint/ca_poly.pxd b/src/sage/libs/flint/ca_poly.pxd index 67ab0f8c8ab..a18a3cdfcd4 100644 --- a/src/sage/libs/flint/ca_poly.pxd +++ b/src/sage/libs/flint/ca_poly.pxd @@ -2,7 +2,9 @@ # distutils: depends = flint/ca_poly.h ################################################################################ -# This file is auto-generated. Do not modify by hand +# This file is auto-generated by the script +# SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py. +# Do not modify by hand! Fix and rerun the script instead. ################################################################################ from libc.stdio cimport FILE @@ -11,264 +13,90 @@ from sage.libs.mpfr.types cimport * from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void ca_poly_init(ca_poly_t poly, ca_ctx_t ctx) noexcept - # Initializes the polynomial for use, setting it to the zero polynomial. - void ca_poly_clear(ca_poly_t poly, ca_ctx_t ctx) noexcept - # Clears the polynomial, deallocating all coefficients and the - # coefficient array. - void ca_poly_fit_length(ca_poly_t poly, slong len, ca_ctx_t ctx) noexcept - # Makes sure that the coefficient array of the polynomial contains at - # least *len* initialized coefficients. - void _ca_poly_set_length(ca_poly_t poly, slong len, ca_ctx_t ctx) noexcept - # Directly changes the length of the polynomial, without allocating or - # deallocating coefficients. The value should not exceed the allocation length. - void _ca_poly_normalise(ca_poly_t poly, ca_ctx_t ctx) noexcept - # Strips any top coefficients which can be proved identical to zero. - void ca_poly_zero(ca_poly_t poly, ca_ctx_t ctx) noexcept - # Sets *poly* to the zero polynomial. - void ca_poly_one(ca_poly_t poly, ca_ctx_t ctx) noexcept - # Sets *poly* to the constant polynomial 1. - void ca_poly_x(ca_poly_t poly, ca_ctx_t ctx) noexcept - # Sets *poly* to the monomial *x*. - void ca_poly_set_ca(ca_poly_t poly, const ca_t c, ca_ctx_t ctx) noexcept void ca_poly_set_si(ca_poly_t poly, slong c, ca_ctx_t ctx) noexcept - # Sets *poly* to the constant polynomial *c*. - void ca_poly_set(ca_poly_t res, const ca_poly_t src, ca_ctx_t ctx) noexcept void ca_poly_set_fmpz_poly(ca_poly_t res, const fmpz_poly_t src, ca_ctx_t ctx) noexcept void ca_poly_set_fmpq_poly(ca_poly_t res, const fmpq_poly_t src, ca_ctx_t ctx) noexcept - # Sets *poly* the polynomial *src*. - void ca_poly_set_coeff_ca(ca_poly_t poly, slong n, const ca_t x, ca_ctx_t ctx) noexcept - # Sets the coefficient at position *n* in *poly* to *x*. - void ca_poly_transfer(ca_poly_t res, ca_ctx_t res_ctx, const ca_poly_t src, ca_ctx_t src_ctx) noexcept - # Sets *res* to *src* where the corresponding context objects *res_ctx* and - # *src_ctx* may be different. - # This operation preserves the mathematical value represented by *src*, - # but may result in a different internal representation depending on the - # settings of the context objects. - void ca_poly_randtest(ca_poly_t poly, flint_rand_t state, slong len, slong depth, slong bits, ca_ctx_t ctx) noexcept - # Sets *poly* to a random polynomial of length up to *len* and with entries having complexity up to - # *depth* and *bits* (see :func:`ca_randtest`). - void ca_poly_randtest_rational(ca_poly_t poly, flint_rand_t state, slong len, slong bits, ca_ctx_t ctx) noexcept - # Sets *poly* to a random rational polynomial of length up to *len* and with entries up to *bits* bits in size. - void ca_poly_print(const ca_poly_t poly, ca_ctx_t ctx) noexcept - # Prints *poly* to standard output. The coefficients are printed on separate lines. - void ca_poly_printn(const ca_poly_t poly, slong digits, ca_ctx_t ctx) noexcept - # Prints a decimal representation of *poly* with precision specified by *digits*. - # The coefficients are comma-separated and the whole list is enclosed in square brackets. - bint ca_poly_is_proper(const ca_poly_t poly, ca_ctx_t ctx) noexcept - # Checks that *poly* represents an element of `\mathbb{C}[X]` with - # well-defined degree. This returns 1 if the leading coefficient - # of *poly* is nonzero and all coefficients of *poly* are - # numbers (not special values). It returns 0 otherwise. - # It returns 1 when *poly* is precisely the zero polynomial (which - # does not have a leading coefficient). - int ca_poly_make_monic(ca_poly_t res, const ca_poly_t poly, ca_ctx_t ctx) noexcept - # Makes *poly* monic by dividing by the leading coefficient if possible - # and returns 1. Returns 0 if the leading coefficient cannot be - # certified to be nonzero, or if *poly* is the zero polynomial. - void _ca_poly_reverse(ca_ptr res, ca_srcptr poly, slong len, slong n, ca_ctx_t ctx) noexcept - void ca_poly_reverse(ca_poly_t res, const ca_poly_t poly, slong n, ca_ctx_t ctx) noexcept - # Sets *res* to the reversal of *poly* considered as a polynomial - # of length *n*, zero-padding if needed. The underscore method - # assumes that *len* is positive and less than or equal to *n*. - truth_t _ca_poly_check_equal(ca_srcptr poly1, slong len1, ca_srcptr poly2, slong len2, ca_ctx_t ctx) noexcept truth_t ca_poly_check_equal(const ca_poly_t poly1, const ca_poly_t poly2, ca_ctx_t ctx) noexcept - # Checks if *poly1* and *poly2* represent the same polynomial. - # The underscore method assumes that *len1* is at least as - # large as *len2*. - truth_t ca_poly_check_is_zero(const ca_poly_t poly, ca_ctx_t ctx) noexcept - # Checks if *poly* is the zero polynomial. - truth_t ca_poly_check_is_one(const ca_poly_t poly, ca_ctx_t ctx) noexcept - # Checks if *poly* is the constant polynomial 1. - void _ca_poly_shift_left(ca_ptr res, ca_srcptr poly, slong len, slong n, ca_ctx_t ctx) noexcept void ca_poly_shift_left(ca_poly_t res, const ca_poly_t poly, slong n, ca_ctx_t ctx) noexcept - # Sets *res* to *poly* shifted *n* coefficients to the left; that is, - # multiplied by `x^n`. - void _ca_poly_shift_right(ca_ptr res, ca_srcptr poly, slong len, slong n, ca_ctx_t ctx) noexcept void ca_poly_shift_right(ca_poly_t res, const ca_poly_t poly, slong n, ca_ctx_t ctx) noexcept - # Sets *res* to *poly* shifted *n* coefficients to the right; that is, - # divided by `x^n`. - void ca_poly_neg(ca_poly_t res, const ca_poly_t src, ca_ctx_t ctx) noexcept - # Sets *res* to the negation of *src*. - void _ca_poly_add(ca_ptr res, ca_srcptr poly1, slong len1, ca_srcptr poly2, slong len2, ca_ctx_t ctx) noexcept void ca_poly_add(ca_poly_t res, const ca_poly_t poly1, const ca_poly_t poly2, ca_ctx_t ctx) noexcept - # Sets *res* to the sum of *poly1* and *poly2*. - void _ca_poly_sub(ca_ptr res, ca_srcptr poly1, slong len1, ca_srcptr poly2, slong len2, ca_ctx_t ctx) noexcept void ca_poly_sub(ca_poly_t res, const ca_poly_t poly1, const ca_poly_t poly2, ca_ctx_t ctx) noexcept - # Sets *res* to the difference of *poly1* and *poly2*. - void _ca_poly_mul(ca_ptr res, ca_srcptr poly1, slong len1, ca_srcptr poly2, slong len2, ca_ctx_t ctx) noexcept void ca_poly_mul(ca_poly_t res, const ca_poly_t poly1, const ca_poly_t poly2, ca_ctx_t ctx) noexcept - # Sets *res* to the product of *poly1* and *poly2*. - void _ca_poly_mullow(ca_ptr C, ca_srcptr poly1, slong len1, ca_srcptr poly2, slong len2, slong n, ca_ctx_t ctx) noexcept void ca_poly_mullow(ca_poly_t res, const ca_poly_t poly1, const ca_poly_t poly2, slong n, ca_ctx_t ctx) noexcept - # Sets *res* to the product of *poly1* and *poly2* truncated to length *n*. - void ca_poly_mul_ca(ca_poly_t res, const ca_poly_t poly, const ca_t c, ca_ctx_t ctx) noexcept - # Sets *res* to *poly* multiplied by the scalar *c*. - void ca_poly_div_ca(ca_poly_t res, const ca_poly_t poly, const ca_t c, ca_ctx_t ctx) noexcept - # Sets *res* to *poly* divided by the scalar *c*. - void _ca_poly_divrem_basecase(ca_ptr Q, ca_ptr R, ca_srcptr A, slong lenA, ca_srcptr B, slong lenB, const ca_t invB, ca_ctx_t ctx) noexcept int ca_poly_divrem_basecase(ca_poly_t Q, ca_poly_t R, const ca_poly_t A, const ca_poly_t B, ca_ctx_t ctx) noexcept void _ca_poly_divrem(ca_ptr Q, ca_ptr R, ca_srcptr A, slong lenA, ca_srcptr B, slong lenB, const ca_t invB, ca_ctx_t ctx) noexcept int ca_poly_divrem(ca_poly_t Q, ca_poly_t R, const ca_poly_t A, const ca_poly_t B, ca_ctx_t ctx) noexcept int ca_poly_div(ca_poly_t Q, const ca_poly_t A, const ca_poly_t B, ca_ctx_t ctx) noexcept int ca_poly_rem(ca_poly_t R, const ca_poly_t A, const ca_poly_t B, ca_ctx_t ctx) noexcept - # If the leading coefficient of *B* can be proved invertible, sets *Q* and *R* - # to the quotient and remainder of polynomial division of *A* by *B* - # and returns 1. If the leading coefficient cannot be proved - # invertible, returns 0. - # The underscore method takes a precomputed inverse of the leading coefficient of *B*. - void _ca_poly_pow_ui_trunc(ca_ptr res, ca_srcptr f, slong flen, ulong exp, slong len, ca_ctx_t ctx) noexcept void ca_poly_pow_ui_trunc(ca_poly_t res, const ca_poly_t poly, ulong exp, slong len, ca_ctx_t ctx) noexcept - # Sets *res* to *poly* raised to the power *exp*, truncated to length *len*. - void _ca_poly_pow_ui(ca_ptr res, ca_srcptr f, slong flen, ulong exp, ca_ctx_t ctx) noexcept void ca_poly_pow_ui(ca_poly_t res, const ca_poly_t poly, ulong exp, ca_ctx_t ctx) noexcept - # Sets *res* to *poly* raised to the power *exp*. - void _ca_poly_evaluate_horner(ca_t res, ca_srcptr f, slong len, const ca_t x, ca_ctx_t ctx) noexcept void ca_poly_evaluate_horner(ca_t res, const ca_poly_t f, const ca_t a, ca_ctx_t ctx) noexcept void _ca_poly_evaluate(ca_t res, ca_srcptr f, slong len, const ca_t x, ca_ctx_t ctx) noexcept void ca_poly_evaluate(ca_t res, const ca_poly_t f, const ca_t a, ca_ctx_t ctx) noexcept - # Sets *res* to *f* evaluated at the point *a*. - void _ca_poly_compose(ca_ptr res, ca_srcptr poly1, slong len1, ca_srcptr poly2, slong len2, ca_ctx_t ctx) noexcept void ca_poly_compose(ca_poly_t res, const ca_poly_t poly1, const ca_poly_t poly2, ca_ctx_t ctx) noexcept - # Sets *res* to the composition of *poly1* with *poly2*. - void _ca_poly_derivative(ca_ptr res, ca_srcptr poly, slong len, ca_ctx_t ctx) noexcept void ca_poly_derivative(ca_poly_t res, const ca_poly_t poly, ca_ctx_t ctx) noexcept - # Sets *res* to the derivative of *poly*. The underscore method needs one less - # coefficient than *len* for the output array. - void _ca_poly_integral(ca_ptr res, ca_srcptr poly, slong len, ca_ctx_t ctx) noexcept void ca_poly_integral(ca_poly_t res, const ca_poly_t poly, ca_ctx_t ctx) noexcept - # Sets *res* to the integral of *poly*. The underscore method needs one more - # coefficient than *len* for the output array. - void _ca_poly_inv_series(ca_ptr res, ca_srcptr f, slong flen, slong len, ca_ctx_t ctx) noexcept void ca_poly_inv_series(ca_poly_t res, const ca_poly_t f, slong len, ca_ctx_t ctx) noexcept - # Sets *res* to the power series inverse of *f* truncated - # to length *len*. - void _ca_poly_div_series(ca_ptr res, ca_srcptr f, slong flen, ca_srcptr g, slong glen, slong len, ca_ctx_t ctx) noexcept void ca_poly_div_series(ca_poly_t res, const ca_poly_t f, const ca_poly_t g, slong len, ca_ctx_t ctx) noexcept - # Sets *res* to the power series quotient of *f* and *g* truncated - # to length *len*. - # This function divides by zero if *g* has constant term zero; - # the user should manually remove initial zeros when an - # exact cancellation is required. - void _ca_poly_exp_series(ca_ptr res, ca_srcptr f, slong flen, slong len, ca_ctx_t ctx) noexcept void ca_poly_exp_series(ca_poly_t res, const ca_poly_t f, slong len, ca_ctx_t ctx) noexcept - # Sets *res* to the power series exponential of *f* truncated - # to length *len*. - void _ca_poly_log_series(ca_ptr res, ca_srcptr f, slong flen, slong len, ca_ctx_t ctx) noexcept void ca_poly_log_series(ca_poly_t res, const ca_poly_t f, slong len, ca_ctx_t ctx) noexcept - # Sets *res* to the power series logarithm of *f* truncated - # to length *len*. - slong _ca_poly_gcd_euclidean(ca_ptr res, ca_srcptr A, slong lenA, ca_srcptr B, slong lenB, ca_ctx_t ctx) noexcept int ca_poly_gcd_euclidean(ca_poly_t res, const ca_poly_t A, const ca_poly_t B, ca_ctx_t ctx) noexcept slong _ca_poly_gcd(ca_ptr res, ca_srcptr A, slong lenA, ca_srcptr B, slong lenB, ca_ctx_t ctx) noexcept int ca_poly_gcd(ca_poly_t res, const ca_poly_t A, const ca_poly_t g, ca_ctx_t ctx) noexcept - # Sets *res* to the GCD of *A* and *B* and returns 1 on success. - # On failure, returns 0 leaving the value of *res* arbitrary. - # The computation can fail if testing a leading coefficient - # for zero fails in the execution of the GCD algorithm. - # The output is normalized to be monic if it is not the zero polynomial. - # The underscore methods assume `\text{lenA} \ge \text{lenB} \ge 1`, and that - # both *A* and *B* have nonzero leading coefficient. - # They return the length of the GCD, or 0 if the computation fails. - # The *euclidean* version implements the standard Euclidean algorithm. - # The default version first checks for rational polynomials or - # attempts to certify numerically that the polynomials are coprime - # and otherwise falls back to an automatic choice - # of algorithm (currently only the Euclidean algorithm). - int ca_poly_factor_squarefree(ca_t c, ca_poly_vec_t fac, ulong * exp, const ca_poly_t F, ca_ctx_t ctx) noexcept - # Computes the squarefree factorization of *F*, giving a product - # `F = c f_1 f_2^2 \ldots f_n^n` where all `f_i` with `f_i \ne 1` - # are squarefree and pairwise coprime. The nontrivial factors - # `f_i` are written to *fac* and the corresponding exponents - # are written to *exp*. This algorithm can fail if GCD computation - # fails internally. Returns 1 on success and 0 on failure. - int ca_poly_squarefree_part(ca_poly_t res, const ca_poly_t poly, ca_ctx_t ctx) noexcept - # Sets *res* to the squarefree part of *poly*, normalized to be monic. - # This algorithm can fail if GCD computation fails internally. - # Returns 1 on success and 0 on failure. - void _ca_poly_set_roots(ca_ptr poly, ca_srcptr roots, const ulong * exp, slong n, ca_ctx_t ctx) noexcept void ca_poly_set_roots(ca_poly_t poly, ca_vec_t roots, const ulong * exp, ca_ctx_t ctx) noexcept - # Sets *poly* to the monic polynomial with the *n* roots - # given in the vector *roots*, with multiplicities given - # in the vector *exp*. In other words, this constructs - # the polynomial - # `(x-r_0)^{e_0} (x-r_1)^{e_1} \cdots (x-r_{n-1})^{e_{n-1}}`. - # Uses binary splitting. - int _ca_poly_roots(ca_ptr roots, ca_srcptr poly, slong len, ca_ctx_t ctx) noexcept int ca_poly_roots(ca_vec_t roots, ulong * exp, const ca_poly_t poly, ca_ctx_t ctx) noexcept - # Attempts to compute all complex roots of the given polynomial *poly*. - # On success, returns 1 and sets *roots* to a vector containing all - # the distinct roots with corresponding multiplicities in *exp*. - # On failure, returns 0 and leaves the values in *roots* arbitrary. - # The roots are returned in arbitrary order. - # Failure will occur if the leading coefficient of *poly* cannot - # be proved to be nonzero, if determining the correct multiplicities - # fails, or if the builtin algorithms do not have a means to - # represent the roots symbolically. - # The underscore method assumes that the polynomial is squarefree. - # The non-underscore method performs a squarefree factorization. - ca_poly_struct * _ca_poly_vec_init(slong len, ca_ctx_t ctx) noexcept void ca_poly_vec_init(ca_poly_vec_t res, slong len, ca_ctx_t ctx) noexcept - # Initializes a vector with *len* polynomials. - void _ca_poly_vec_fit_length(ca_poly_vec_t vec, slong len, ca_ctx_t ctx) noexcept - # Allocates space for *len* polynomials in *vec*. - void ca_poly_vec_set_length(ca_poly_vec_t vec, slong len, ca_ctx_t ctx) noexcept - # Resizes *vec* to length *len*, zero-extending if needed. - void _ca_poly_vec_clear(ca_poly_struct * vec, slong len, ca_ctx_t ctx) noexcept void ca_poly_vec_clear(ca_poly_vec_t vec, ca_ctx_t ctx) noexcept - # Clears the vector *vec*. - void ca_poly_vec_append(ca_poly_vec_t vec, const ca_poly_t poly, ca_ctx_t ctx) noexcept - # Appends *poly* to the end of the vector *vec*. diff --git a/src/sage/libs/flint/ca_vec.pxd b/src/sage/libs/flint/ca_vec.pxd index 76c993b3365..3ed69ea9968 100644 --- a/src/sage/libs/flint/ca_vec.pxd +++ b/src/sage/libs/flint/ca_vec.pxd @@ -2,7 +2,9 @@ # distutils: depends = flint/ca_vec.h ################################################################################ -# This file is auto-generated. Do not modify by hand +# This file is auto-generated by the script +# SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py. +# Do not modify by hand! Fix and rerun the script instead. ################################################################################ from libc.stdio cimport FILE @@ -11,103 +13,32 @@ from sage.libs.mpfr.types cimport * from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - ca_ptr _ca_vec_init(slong len, ca_ctx_t ctx) noexcept - # Returns a pointer to an array of *len* coefficients - # initialized to zero. - void ca_vec_init(ca_vec_t vec, slong len, ca_ctx_t ctx) noexcept - # Initializes *vec* to a length *len* vector. All entries - # are set to zero. - void _ca_vec_clear(ca_ptr vec, slong len, ca_ctx_t ctx) noexcept - # Clears all *len* entries in *vec* and frees the pointer - # *vec* itself. - void ca_vec_clear(ca_vec_t vec, ca_ctx_t ctx) noexcept - # Clears the vector *vec*. - void _ca_vec_swap(ca_ptr vec1, ca_ptr vec2, slong len, ca_ctx_t ctx) noexcept - # Swaps the entries in *vec1* and *vec2* efficiently. - void ca_vec_swap(ca_vec_t vec1, ca_vec_t vec2, ca_ctx_t ctx) noexcept - # Swaps the vectors *vec1* and *vec2* efficiently. - slong ca_vec_length(const ca_vec_t vec, ca_ctx_t ctx) noexcept - # Returns the length of *vec*. - void _ca_vec_fit_length(ca_vec_t vec, slong len, ca_ctx_t ctx) noexcept - # Allocates space in *vec* for *len* elements. - void ca_vec_set_length(ca_vec_t vec, slong len, ca_ctx_t ctx) noexcept - # Sets the length of *vec* to *len*. - # If *vec* is shorter on input, it will be zero-extended. - # If *vec* is longer on input, it will be truncated. - void _ca_vec_set(ca_ptr res, ca_srcptr src, slong len, ca_ctx_t ctx) noexcept - # Sets *res* to a copy of *src* of length *len*. - void ca_vec_set(ca_vec_t res, const ca_vec_t src, ca_ctx_t ctx) noexcept - # Sets *res* to a copy of *src*. - void _ca_vec_zero(ca_ptr res, slong len, ca_ctx_t ctx) noexcept - # Sets the *len* entries in *res* to zeros. - void ca_vec_zero(ca_vec_t res, slong len, ca_ctx_t ctx) noexcept - # Sets *res* to the length *len* zero vector. - void ca_vec_print(const ca_vec_t vec, ca_ctx_t ctx) noexcept - # Prints *vec* to standard output. The coefficients are printed on separate lines. - void ca_vec_printn(const ca_vec_t poly, slong digits, ca_ctx_t ctx) noexcept - # Prints a decimal representation of *vec* with precision specified by *digits*. - # The coefficients are comma-separated and the whole list is enclosed in square brackets. - void ca_vec_append(ca_vec_t vec, const ca_t f, ca_ctx_t ctx) noexcept - # Appends *f* to the end of *vec*. - void _ca_vec_neg(ca_ptr res, ca_srcptr src, slong len, ca_ctx_t ctx) noexcept - void ca_vec_neg(ca_vec_t res, const ca_vec_t src, ca_ctx_t ctx) noexcept - # Sets *res* to the negation of *src*. - void _ca_vec_add(ca_ptr res, ca_srcptr vec1, ca_srcptr vec2, slong len, ca_ctx_t ctx) noexcept - void _ca_vec_sub(ca_ptr res, ca_srcptr vec1, ca_srcptr vec2, slong len, ca_ctx_t ctx) noexcept - # Sets *res* to the sum or difference of *vec1* and *vec2*, - # all vectors having length *len*. - void _ca_vec_scalar_mul_ca(ca_ptr res, ca_srcptr src, slong len, const ca_t c, ca_ctx_t ctx) noexcept - # Sets *res* to *src* multiplied by *c*, all vectors having - # length *len*. - void _ca_vec_scalar_div_ca(ca_ptr res, ca_srcptr src, slong len, const ca_t c, ca_ctx_t ctx) noexcept - # Sets *res* to *src* divided by *c*, all vectors having - # length *len*. - void _ca_vec_scalar_addmul_ca(ca_ptr res, ca_srcptr src, slong len, const ca_t c, ca_ctx_t ctx) noexcept - # Adds *src* multiplied by *c* to the vector *res*, all vectors having - # length *len*. - void _ca_vec_scalar_submul_ca(ca_ptr res, ca_srcptr src, slong len, const ca_t c, ca_ctx_t ctx) noexcept - # Subtracts *src* multiplied by *c* from the vector *res*, all vectors having - # length *len*. - truth_t _ca_vec_check_is_zero(ca_srcptr vec, slong len, ca_ctx_t ctx) noexcept - # Returns whether *vec* is the zero vector. - bint _ca_vec_is_fmpq_vec(ca_srcptr vec, slong len, ca_ctx_t ctx) noexcept - # Checks if all elements of *vec* are structurally rational numbers. - bint _ca_vec_fmpq_vec_is_fmpz_vec(ca_srcptr vec, slong len, ca_ctx_t ctx) noexcept - # Assuming that all elements of *vec* are structurally rational numbers, - # checks if all elements are integers. - void _ca_vec_fmpq_vec_get_fmpz_vec_den(fmpz * c, fmpz_t den, ca_srcptr vec, slong len, ca_ctx_t ctx) noexcept - # Assuming that all elements of *vec* are structurally rational numbers, - # converts them to a vector of integers *c* on a common denominator - # *den*. - void _ca_vec_set_fmpz_vec_div_fmpz(ca_ptr res, const fmpz * v, const fmpz_t den, slong len, ca_ctx_t ctx) noexcept - # Sets *res* to the rational vector given by numerators *v* - # and the common denominator *den*. diff --git a/src/sage/libs/flint/calcium.pxd b/src/sage/libs/flint/calcium.pxd index 18278abc5c5..60507d53ac6 100644 --- a/src/sage/libs/flint/calcium.pxd +++ b/src/sage/libs/flint/calcium.pxd @@ -2,7 +2,9 @@ # distutils: depends = flint/calcium.h ################################################################################ -# This file is auto-generated. Do not modify by hand +# This file is auto-generated by the script +# SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py. +# Do not modify by hand! Fix and rerun the script instead. ################################################################################ from libc.stdio cimport FILE @@ -11,36 +13,13 @@ from sage.libs.mpfr.types cimport * from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - const char * calcium_version() noexcept - # Returns a pointer to the version of the library as a string ``X.Y.Z``. - ulong calcium_fmpz_hash(const fmpz_t x) noexcept - # Hash function for integers. The algorithm may change; - # presently, this simply extracts the low word (with sign). - void calcium_stream_init_file(calcium_stream_t out, FILE * fp) noexcept - # Initializes the stream *out* for writing to the file *fp*. - # The file can be *stdout*, *stderr*, or any file opened for writing - # by the user. - void calcium_stream_init_str(calcium_stream_t out) noexcept - # Initializes the stream *out* for writing to a string in memory. - # When finished, the user should free the string (the *s* member - # of *out* with ``flint_free()``). - void calcium_write(calcium_stream_t out, const char * s) noexcept - # Writes the string *s* to *out*. - void calcium_write_free(calcium_stream_t out, char * s) noexcept - # Writes *s* to *out* and then frees *s* by calling ``flint_free()``. - void calcium_write_si(calcium_stream_t out, slong x) noexcept void calcium_write_fmpz(calcium_stream_t out, const fmpz_t x) noexcept - # Writes the integer *x* to *out*. - void calcium_write_arb(calcium_stream_t out, const arb_t z, slong digits, ulong flags) noexcept void calcium_write_acb(calcium_stream_t out, const acb_t z, slong digits, ulong flags) noexcept - # Writes the Arb number *z* to *out*, showing *digits* - # digits and with the display style specified by *flags* - # (``ARB_STR_NO_RADIUS``, etc.). diff --git a/src/sage/libs/flint/d_mat.pxd b/src/sage/libs/flint/d_mat.pxd index b9d9a2911ee..0f398f5ada0 100644 --- a/src/sage/libs/flint/d_mat.pxd +++ b/src/sage/libs/flint/d_mat.pxd @@ -2,7 +2,9 @@ # distutils: depends = flint/d_mat.h ################################################################################ -# This file is auto-generated. Do not modify by hand +# This file is auto-generated by the script +# SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py. +# Do not modify by hand! Fix and rerun the script instead. ################################################################################ from libc.stdio cimport FILE @@ -11,99 +13,25 @@ from sage.libs.mpfr.types cimport * from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void d_mat_init(d_mat_t mat, slong rows, slong cols) noexcept - # Initialises a matrix with the given number of rows and columns for use. - void d_mat_clear(d_mat_t mat) noexcept - # Clears the given matrix. - void d_mat_set(d_mat_t mat1, const d_mat_t mat2) noexcept - # Sets ``mat1`` to a copy of ``mat2``. The dimensions of - # ``mat1`` and ``mat2`` must be the same. - void d_mat_swap(d_mat_t mat1, d_mat_t mat2) noexcept - # Swaps two matrices. The dimensions of ``mat1`` and ``mat2`` - # are allowed to be different. - void d_mat_swap_entrywise(d_mat_t mat1, d_mat_t mat2) noexcept - # Swaps two matrices by swapping the individual entries rather than swapping - # the contents of the structs. - double d_mat_entry(d_mat_t mat, slong i, slong j) noexcept - # Returns the entry of ``mat`` at row `i` and column `j`. - # Both `i` and `j` must not exceed the dimensions of the matrix. - # This function is implemented as a macro. - double d_mat_get_entry(const d_mat_t mat, slong i, slong j) noexcept - # Returns the entry of ``mat`` at row `i` and column `j`. - # Both `i` and `j` must not exceed the dimensions of the matrix. - double * d_mat_entry_ptr(const d_mat_t mat, slong i, slong j) noexcept - # Returns a pointer to the entry of ``mat`` at row `i` and column - # `j`. Both `i` and `j` must not exceed the dimensions of the matrix. - void d_mat_zero(d_mat_t mat) noexcept - # Sets all entries of ``mat`` to 0. - void d_mat_one(d_mat_t mat) noexcept - # Sets ``mat`` to the unit matrix, having ones on the main diagonal - # and zeroes elsewhere. If ``mat`` is nonsquare, it is set to the - # truncation of a unit matrix. - void d_mat_randtest(d_mat_t mat, flint_rand_t state, slong minexp, slong maxexp) noexcept - # Sets the entries of ``mat`` to random signed numbers with exponents - # between ``minexp`` and ``maxexp`` or zero. - void d_mat_print(const d_mat_t mat) noexcept - # Prints the given matrix to the stream ``stdout``. - bint d_mat_equal(const d_mat_t mat1, const d_mat_t mat2) noexcept - # Returns a non-zero value if ``mat1`` and ``mat2`` have - # the same dimensions and entries, and zero otherwise. - bint d_mat_approx_equal(const d_mat_t mat1, const d_mat_t mat2, double eps) noexcept - # Returns a non-zero value if ``mat1`` and ``mat2`` have - # the same dimensions and entries within ``eps`` of each other, - # and zero otherwise. - bint d_mat_is_zero(const d_mat_t mat) noexcept - # Returns a non-zero value if all entries ``mat`` are zero, and - # otherwise returns zero. - bint d_mat_is_approx_zero(const d_mat_t mat, double eps) noexcept - # Returns a non-zero value if all entries ``mat`` are zero to within - # ``eps`` and otherwise returns zero. - bint d_mat_is_empty(const d_mat_t mat) noexcept - # Returns a non-zero value if the number of rows or the number of - # columns in ``mat`` is zero, and otherwise returns - # zero. - bint d_mat_is_square(const d_mat_t mat) noexcept - # Returns a non-zero value if the number of rows is equal to the - # number of columns in ``mat``, and otherwise returns zero. - void d_mat_transpose(d_mat_t B, const d_mat_t A) noexcept - # Sets `B` to `A^T`, the transpose of `A`. Dimensions must be compatible. - # `A` and `B` are allowed to be the same object if `A` is a square matrix. - void d_mat_mul_classical(d_mat_t C, const d_mat_t A, const d_mat_t B) noexcept - # Sets ``C`` to the matrix product `C = A B`. The matrices must have - # compatible dimensions for matrix multiplication (an exception is raised - # otherwise). Aliasing is allowed. - void d_mat_gso(d_mat_t B, const d_mat_t A) noexcept - # Takes a subset of `R^m` `S = {a_1, a_2, \ldots, a_n}` (as the columns of - # a `m \times n` matrix ``A``) and generates an orthonormal set - # `S' = {b_1, b_2, \ldots, b_n}` (as the columns of the `m \times n` matrix - # ``B``) that spans the same subspace of `R^m` as `S`. - # This uses an algorithm of Schwarz-Rutishauser. See pp. 9 of - # https://people.inf.ethz.ch/gander/papers/qrneu.pdf - void d_mat_qr(d_mat_t Q, d_mat_t R, const d_mat_t A) noexcept - # Computes the `QR` decomposition of a matrix ``A`` using the Gram-Schmidt - # process. (Sets ``Q`` and ``R`` such that `A = QR` where ``R`` is - # an upper triangular matrix and ``Q`` is an orthogonal matrix.) - # This uses an algorithm of Schwarz-Rutishauser. See pp. 9 of - # https://people.inf.ethz.ch/gander/papers/qrneu.pdf diff --git a/src/sage/libs/flint/d_vec.pxd b/src/sage/libs/flint/d_vec.pxd index c546e782abd..3ce55fde92a 100644 --- a/src/sage/libs/flint/d_vec.pxd +++ b/src/sage/libs/flint/d_vec.pxd @@ -2,7 +2,9 @@ # distutils: depends = flint/d_vec.h ################################################################################ -# This file is auto-generated. Do not modify by hand +# This file is auto-generated by the script +# SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py. +# Do not modify by hand! Fix and rerun the script instead. ################################################################################ from libc.stdio cimport FILE @@ -11,65 +13,18 @@ from sage.libs.mpfr.types cimport * from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - double * _d_vec_init(slong len) noexcept - # Returns an initialised vector of ``double``\s of given length. The - # entries are not zeroed. - void _d_vec_clear(double * vec) noexcept - # Frees the space allocated for ``vec``. - void _d_vec_randtest(double * f, flint_rand_t state, slong len, slong minexp, slong maxexp) noexcept - # Sets the entries of a vector of the given length to random signed numbers - # with exponents between ``minexp`` and ``maxexp`` or zero. - void _d_vec_set(double * vec1, const double * vec2, slong len2) noexcept - # Makes a copy of ``(vec2, len2)`` into ``vec1``. - void _d_vec_zero(double * vec, slong len) noexcept - # Zeros the entries of ``(vec, len)``. - bint _d_vec_equal(const double * vec1, const double * vec2, slong len) noexcept - # Compares two vectors of the given length and returns `1` if they are - # equal, otherwise returns `0`. - bint _d_vec_is_zero(const double * vec, slong len) noexcept - # Returns `1` if ``(vec, len)`` is zero, and `0` otherwise. - bint _d_vec_is_approx_zero(const double * vec, slong len, double eps) noexcept - # Returns `1` if the entries of ``(vec, len)`` are zero to within - # ``eps``, and `0` otherwise. - bint _d_vec_approx_equal(const double * vec1, const double * vec2, slong len, double eps) noexcept - # Compares two vectors of the given length and returns `1` if their entries - # are within ``eps`` of each other, otherwise returns `0`. - void _d_vec_add(double * res, const double * vec1, const double * vec2, slong len2) noexcept - # Sets ``(res, len2)`` to the sum of ``(vec1, len2)`` - # and ``(vec2, len2)``. - void _d_vec_sub(double * res, const double * vec1, const double * vec2, slong len2) noexcept - # Sets ``(res, len2)`` to ``(vec1, len2)`` minus ``(vec2, len2)``. - double _d_vec_dot(const double * vec1, const double * vec2, slong len2) noexcept - # Returns the dot product of ``(vec1, len2)`` - # and ``(vec2, len2)``. - double _d_vec_norm(const double * vec, slong len) noexcept - # Returns the square of the Euclidean norm of ``(vec, len)``. - double _d_vec_dot_heuristic(const double * vec1, const double * vec2, slong len2, double * err) noexcept - # Returns the dot product of ``(vec1, len2)`` - # and ``(vec2, len2)`` by adding up the positive and negative products, - # and doing a single subtraction of the two sums at the end. ``err`` is a - # pointer to a double in which an error bound for the operation will be - # stored. - double _d_vec_dot_thrice(const double * vec1, const double * vec2, slong len2, double * err) noexcept - # Returns the dot product of ``(vec1, len2)`` - # and ``(vec2, len2)`` using error-free floating point sums and products - # to compute the dot product with three times (thrice) the working precision. - # ``err`` is a pointer to a double in which an error bound for the - # operation will be stored. - # This implements the algorithm of Ogita-Rump-Oishi. See - # http://www.ti3.tuhh.de/paper/rump/OgRuOi05.pdf. diff --git a/src/sage/libs/flint/dirichlet.pxd b/src/sage/libs/flint/dirichlet.pxd index 11249bbcca0..79d9908fd9e 100644 --- a/src/sage/libs/flint/dirichlet.pxd +++ b/src/sage/libs/flint/dirichlet.pxd @@ -2,7 +2,9 @@ # distutils: depends = flint/dirichlet.h ################################################################################ -# This file is auto-generated. Do not modify by hand +# This file is auto-generated by the script +# SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py. +# Do not modify by hand! Fix and rerun the script instead. ################################################################################ from libc.stdio cimport FILE @@ -11,137 +13,43 @@ from sage.libs.mpfr.types cimport * from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - int dirichlet_group_init(dirichlet_group_t G, ulong q) noexcept - # Initializes *G* to the group of Dirichlet characters mod *q*. - # This method computes a canonical decomposition of *G* in terms of cyclic - # groups, which are the mod `p^e` subgroups for `p^e\|q`, plus - # the specific generator described by Conrey for each subgroup. - # In particular *G* contains: - # - the number *num* of components - # - the generators - # - the exponent *expo* of the group - # It does *not* automatically precompute lookup tables - # of discrete logarithms or numerical roots of unity, and can therefore - # safely be called even with large *q*. - # For implementation reasons, the largest prime factor of *q* must not - # exceed `10^{16}`. This restriction could - # be removed in the future. The function returns 1 on success and 0 - # if a factor is too large. - void dirichlet_subgroup_init(dirichlet_group_t H, const dirichlet_group_t G, ulong h) noexcept - void dirichlet_group_clear(dirichlet_group_t G) noexcept - # Clears *G*. Remark this function does *not* clear the discrete logarithm - # tables stored in *G* (which may be shared with another group). - ulong dirichlet_group_size(const dirichlet_group_t G) noexcept - ulong dirichlet_group_num_primitive(const dirichlet_group_t G) noexcept - void dirichlet_group_dlog_precompute(dirichlet_group_t G, ulong num) noexcept - # Precompute decomposition and tables for discrete log computations in *G*, - # so as to minimize the complexity of *num* calls to discrete logarithms. - # If *num* gets very large, the entire group may be indexed. - void dirichlet_group_dlog_clear(dirichlet_group_t G) noexcept - void dirichlet_char_init(dirichlet_char_t chi, const dirichlet_group_t G) noexcept - # Initializes *chi* to an element of the group *G* and sets its value - # to the principal character. - void dirichlet_char_clear(dirichlet_char_t chi) noexcept - # Clears *chi*. - void dirichlet_char_print(const dirichlet_group_t G, const dirichlet_char_t chi) noexcept - # Prints the array of exponents representing this character. - void dirichlet_char_log(dirichlet_char_t x, const dirichlet_group_t G, ulong m) noexcept - # Sets *x* to the character of number *m*, computing its log using discrete - # logarithm in *G*. - ulong dirichlet_char_exp(const dirichlet_group_t G, const dirichlet_char_t x) noexcept - # Returns the number *m* corresponding to exponents in *x*. - ulong _dirichlet_char_exp(dirichlet_char_t x, const dirichlet_group_t G) noexcept - # Computes and returns the number *m* corresponding to exponents in *x*. - # This function is for internal use. - void dirichlet_char_one(dirichlet_char_t x, const dirichlet_group_t G) noexcept - # Sets *x* to the principal character in *G*, having *log* `[0,\dots 0]`. - void dirichlet_char_first_primitive(dirichlet_char_t x, const dirichlet_group_t G) noexcept - # Sets *x* to the first primitive character of *G*, having *log* `[1,\dots 1]`, - # or `[0, 1, \dots 1]` if `8\mid q`. - void dirichlet_char_set(dirichlet_char_t x, const dirichlet_group_t G, const dirichlet_char_t y) noexcept - # Sets *x* to the element *y*. - int dirichlet_char_next(dirichlet_char_t x, const dirichlet_group_t G) noexcept - # Sets *x* to the next character in *G* according to lexicographic ordering - # of *log*. - # The return value - # is the index of the last updated exponent of *x*, or *-1* if the last - # element has been reached. - # This function allows to iterate on all elements of *G* looping on their *log*. - # Note that it produces elements in seemingly random *number* order. - # The following template can be used for such a loop:: - # dirichlet_char_one(chi, G); - # do { - # /* use character chi */ - # } while (dirichlet_char_next(chi, G) >= 0); - int dirichlet_char_next_primitive(dirichlet_char_t x, const dirichlet_group_t G) noexcept - # Same as :func:`dirichlet_char_next`, but jumps to the next primitive character of *G*. - ulong dirichlet_index_char(const dirichlet_group_t G, const dirichlet_char_t x) noexcept - # Returns the lexicographic index of the *log* of *x* as an integer in `0\dots \varphi(q)`. - void dirichlet_char_index(dirichlet_char_t x, const dirichlet_group_t G, ulong j) noexcept - # Sets *x* to the character whose *log* has lexicographic index *j*. - bint dirichlet_char_eq(const dirichlet_char_t x, const dirichlet_char_t y) noexcept - int dirichlet_char_eq_deep(const dirichlet_group_t G, const dirichlet_char_t x, const dirichlet_char_t y) noexcept - bint dirichlet_char_is_principal(const dirichlet_group_t G, const dirichlet_char_t chi) noexcept - ulong dirichlet_conductor_ui(const dirichlet_group_t G, ulong a) noexcept - ulong dirichlet_conductor_char(const dirichlet_group_t G, const dirichlet_char_t x) noexcept - int dirichlet_parity_ui(const dirichlet_group_t G, ulong a) noexcept - int dirichlet_parity_char(const dirichlet_group_t G, const dirichlet_char_t x) noexcept - ulong dirichlet_order_ui(const dirichlet_group_t G, ulong a) noexcept - ulong dirichlet_order_char(const dirichlet_group_t G, const dirichlet_char_t x) noexcept - bint dirichlet_char_is_real(const dirichlet_group_t G, const dirichlet_char_t chi) noexcept - bint dirichlet_char_is_primitive(const dirichlet_group_t G, const dirichlet_char_t chi) noexcept - ulong dirichlet_pairing(const dirichlet_group_t G, ulong m, ulong n) noexcept - ulong dirichlet_pairing_char(const dirichlet_group_t G, const dirichlet_char_t chi, const dirichlet_char_t psi) noexcept - ulong dirichlet_chi(const dirichlet_group_t G, const dirichlet_char_t chi, ulong n) noexcept - void dirichlet_chi_vec(ulong * v, const dirichlet_group_t G, const dirichlet_char_t chi, slong nv) noexcept - void dirichlet_chi_vec_order(ulong * v, const dirichlet_group_t G, const dirichlet_char_t chi, ulong order, slong nv) noexcept - void dirichlet_char_mul(dirichlet_char_t chi12, const dirichlet_group_t G, const dirichlet_char_t chi1, const dirichlet_char_t chi2) noexcept - void dirichlet_char_pow(dirichlet_char_t c, const dirichlet_group_t G, const dirichlet_char_t a, ulong n) noexcept - void dirichlet_char_lift(dirichlet_char_t chi_G, const dirichlet_group_t G, const dirichlet_char_t chi_H, const dirichlet_group_t H) noexcept - # If *H* is a subgroup of *G*, computes the character in *G* corresponding to - # *chi_H* in *H*. - void dirichlet_char_lower(dirichlet_char_t chi_H, const dirichlet_group_t H, const dirichlet_char_t chi_G, const dirichlet_group_t G) noexcept - # If *chi_G* is a character of *G* which factors through *H*, sets *chi_H* to - # the corresponding restriction in *H*. - # This requires `c(\chi_G)\mid q_H\mid q_G`, where `c(\chi_G)` is the - # conductor of `\chi_G` and `q_G, q_H` are the moduli of G and H. diff --git a/src/sage/libs/flint/dlog.pxd b/src/sage/libs/flint/dlog.pxd index cca9f7a886d..68bbaa2690a 100644 --- a/src/sage/libs/flint/dlog.pxd +++ b/src/sage/libs/flint/dlog.pxd @@ -2,7 +2,9 @@ # distutils: depends = flint/dlog.h ################################################################################ -# This file is auto-generated. Do not modify by hand +# This file is auto-generated by the script +# SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py. +# Do not modify by hand! Fix and rerun the script instead. ################################################################################ from libc.stdio cimport FILE @@ -11,75 +13,39 @@ from sage.libs.mpfr.types cimport * from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - ulong dlog_once(ulong b, ulong a, const nmod_t mod, ulong n) noexcept - void dlog_precomp_n_init(dlog_precomp_t pre, ulong a, ulong mod, ulong n, ulong num) noexcept - ulong dlog_precomp(const dlog_precomp_t pre, ulong b) noexcept - void dlog_precomp_clear(dlog_precomp_t pre) noexcept - void dlog_precomp_modpe_init(dlog_precomp_t pre, ulong a, ulong p, ulong e, ulong pe, ulong num) noexcept - void dlog_precomp_p_init(dlog_precomp_t pre, ulong a, ulong mod, ulong p, ulong num) noexcept - void dlog_precomp_pe_init(dlog_precomp_t pre, ulong a, ulong mod, ulong p, ulong e, ulong pe, ulong num) noexcept - void dlog_precomp_small_init(dlog_precomp_t pre, ulong a, ulong mod, ulong n, ulong num) noexcept - void dlog_vec_fill(ulong * v, ulong nv, ulong x) noexcept - void dlog_vec_set_not_found(ulong * v, ulong nv, nmod_t mod) noexcept - void dlog_vec(ulong * v, ulong nv, ulong a, ulong va, nmod_t mod, ulong na, nmod_t order) noexcept - void dlog_vec_add(ulong * v, ulong nv, ulong a, ulong va, nmod_t mod, ulong na, nmod_t order) noexcept - void dlog_vec_loop(ulong * v, ulong nv, ulong a, ulong va, nmod_t mod, ulong na, nmod_t order) noexcept - void dlog_vec_loop_add(ulong * v, ulong nv, ulong a, ulong va, nmod_t mod, ulong na, nmod_t order) noexcept - void dlog_vec_eratos(ulong * v, ulong nv, ulong a, ulong va, nmod_t mod, ulong na, nmod_t order) noexcept - void dlog_vec_eratos_add(ulong * v, ulong nv, ulong a, ulong va, nmod_t mod, ulong na, nmod_t order) noexcept - void dlog_vec_sieve_add(ulong * v, ulong nv, ulong a, ulong va, nmod_t mod, ulong na, nmod_t order) noexcept - void dlog_vec_sieve(ulong * v, ulong nv, ulong a, ulong va, nmod_t mod, ulong na, nmod_t order) noexcept - ulong dlog_table_init(dlog_table_t t, ulong a, ulong mod) noexcept - void dlog_table_clear(dlog_table_t t) noexcept - ulong dlog_table(const dlog_table_t t, ulong b) noexcept - ulong dlog_bsgs_init(dlog_bsgs_t t, ulong a, ulong mod, ulong n, ulong m) noexcept - void dlog_bsgs_clear(dlog_bsgs_t t) noexcept - ulong dlog_bsgs(const dlog_bsgs_t t, ulong b) noexcept - ulong dlog_modpe_init(dlog_modpe_t t, ulong a, ulong p, ulong e, ulong pe, ulong num) noexcept - void dlog_modpe_clear(dlog_modpe_t t) noexcept - ulong dlog_modpe(const dlog_modpe_t t, ulong b) noexcept - ulong dlog_crt_init(dlog_crt_t t, ulong a, ulong mod, ulong n, ulong num) noexcept - void dlog_crt_clear(dlog_crt_t t) noexcept - ulong dlog_crt(const dlog_crt_t t, ulong b) noexcept - ulong dlog_power_init(dlog_power_t t, ulong a, ulong mod, ulong p, ulong e, ulong num) noexcept - void dlog_power_clear(dlog_power_t t) noexcept - ulong dlog_power(const dlog_power_t t, ulong b) noexcept - void dlog_rho_init(dlog_rho_t t, ulong a, ulong mod, ulong n) noexcept - void dlog_rho_clear(dlog_rho_t t) noexcept - ulong dlog_rho(const dlog_rho_t t, ulong b) noexcept diff --git a/src/sage/libs/flint/double_extras.pxd b/src/sage/libs/flint/double_extras.pxd index ec6204b1b81..1019aca407d 100644 --- a/src/sage/libs/flint/double_extras.pxd +++ b/src/sage/libs/flint/double_extras.pxd @@ -2,7 +2,9 @@ # distutils: depends = flint/double_extras.h ################################################################################ -# This file is auto-generated. Do not modify by hand +# This file is auto-generated by the script +# SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py. +# Do not modify by hand! Fix and rerun the script instead. ################################################################################ from libc.stdio cimport FILE @@ -11,41 +13,10 @@ from sage.libs.mpfr.types cimport * from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - double d_randtest(flint_rand_t state) noexcept - # Returns a random number in the interval `[0.5, 1)`. - double d_randtest_signed(flint_rand_t state, slong minexp, slong maxexp) noexcept - # Returns a random signed number with exponent between ``minexp`` and - # ``maxexp`` or zero. - double d_randtest_special(flint_rand_t state, slong minexp, slong maxexp) noexcept - # Returns a random signed number with exponent between ``minexp`` and - # ``maxexp``, zero, ``D_NAN`` or `\pm`\ ``D_INF``. - double d_polyval(const double * poly, int len, double x) noexcept - # Uses Horner's rule to evaluate the polynomial defined by the given - # ``len`` coefficients. Requires that ``len`` is nonzero. - double d_lambertw(double x) noexcept - # Computes the principal branch of the Lambert W function, solving - # the equation `x = W(x) \exp(W(x))`. If `x < -1/e`, the solution is - # complex, and NaN is returned. - # Depending on the magnitude of `x`, we start from a piecewise rational - # approximation or a zeroth-order truncation of the asymptotic expansion - # at infinity, and perform 0, 1 or 2 iterations with Halley's - # method to obtain full accuracy. - # A test of `10^7` random inputs showed a maximum relative error smaller - # than 0.95 times ``DBL_EPSILON`` (`2^{-52}`) for positive `x`. - # Accuracy for negative `x` is slightly worse, and can grow to - # about 10 times ``DBL_EPSILON`` close to `-1/e`. - # However, accuracy may be worse depending on compiler flags and - # the accuracy of the system libm functions. - bint d_is_nan(double x) noexcept - # Returns a nonzero integral value if ``x`` is ``D_NAN``, and otherwise - # returns 0. - double d_log2(double x) noexcept - # Returns the base 2 logarithm of ``x`` provided ``x`` is positive. If - # a domain or pole error occurs, the appropriate error value is returned. diff --git a/src/sage/libs/flint/double_interval.pxd b/src/sage/libs/flint/double_interval.pxd index 58077fa48d1..72de28838b8 100644 --- a/src/sage/libs/flint/double_interval.pxd +++ b/src/sage/libs/flint/double_interval.pxd @@ -2,7 +2,9 @@ # distutils: depends = flint/double_interval.h ################################################################################ -# This file is auto-generated. Do not modify by hand +# This file is auto-generated by the script +# SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py. +# Do not modify by hand! Fix and rerun the script instead. ################################################################################ from libc.stdio cimport FILE @@ -11,56 +13,22 @@ from sage.libs.mpfr.types cimport * from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - di_t di_interval(double a, double b) noexcept - # Returns the interval `[a, b]`. We require that the endpoints - # are ordered and not NaN. - di_t arb_get_di(const arb_t x) noexcept - # Returns the ball *x* converted to a double-precision interval. - void arb_set_di(arb_t res, di_t x, slong prec) noexcept - # Sets the ball *res* to the double-precision interval *x*, - # rounded to *prec* bits. - void di_print(di_t x) noexcept - # Prints *x* to standard output. This simply prints decimal - # representations of the floating-point endpoints; the - # decimals are not guaranteed to be rounded outward. - double d_randtest2(flint_rand_t state) noexcept - # Returns a random non-NaN ``double`` with any exponent. - # The value can be infinite or subnormal. - di_t di_randtest(flint_rand_t state) noexcept - # Returns an interval with random endpoints. - di_t di_neg(di_t x) noexcept - # Returns the exact negation of *x*. - di_t di_fast_add(di_t x, di_t y) noexcept di_t di_fast_sub(di_t x, di_t y) noexcept di_t di_fast_mul(di_t x, di_t y) noexcept di_t di_fast_div(di_t x, di_t y) noexcept - # Returns the sum, difference, product or quotient of *x* and *y*. - # Division by zero is currently defined to return `[-\infty, +\infty]`. - di_t di_fast_sqr(di_t x) noexcept - # Returns the square of *x*. The output is clamped to - # be nonnegative. - di_t di_fast_add_d(di_t x, double y) noexcept di_t di_fast_sub_d(di_t x, double y) noexcept di_t di_fast_mul_d(di_t x, double y) noexcept di_t di_fast_div_d(di_t x, double y) noexcept - # Arithmetic with an exact ``double`` operand. - di_t di_fast_log_nonnegative(di_t x) noexcept - # Returns an enclosure of `\log(x)`. The lower endpoint of *x* - # is rounded up to 0 if it is negative. - di_t di_fast_mid(di_t x) noexcept - # Returns an enclosure of the midpoint of *x*. - double di_fast_ubound_radius(di_t x) noexcept - # Returns an upper bound for the radius of *x*. diff --git a/src/sage/libs/flint/fexpr.pxd b/src/sage/libs/flint/fexpr.pxd index dd2ac046e88..7a264b74639 100644 --- a/src/sage/libs/flint/fexpr.pxd +++ b/src/sage/libs/flint/fexpr.pxd @@ -2,7 +2,9 @@ # distutils: depends = flint/fexpr.h ################################################################################ -# This file is auto-generated. Do not modify by hand +# This file is auto-generated by the script +# SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py. +# Do not modify by hand! Fix and rerun the script instead. ################################################################################ from libc.stdio cimport FILE @@ -11,346 +13,90 @@ from sage.libs.mpfr.types cimport * from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void fexpr_init(fexpr_t expr) noexcept - # Initializes *expr* for use. Its value is set to the atomic - # integer 0. - void fexpr_clear(fexpr_t expr) noexcept - # Clears *expr*, freeing its allocated memory. - fexpr_ptr _fexpr_vec_init(slong len) noexcept - # Returns a heap-allocated vector of *len* initialized expressions. - void _fexpr_vec_clear(fexpr_ptr vec, slong len) noexcept - # Clears the *len* expressions in *vec* and frees *vec* itself. - void fexpr_fit_size(fexpr_t expr, slong size) noexcept - # Ensures that *expr* has room for *size* words. - void fexpr_set(fexpr_t res, const fexpr_t expr) noexcept - # Sets *res* to the a copy of *expr*. - void fexpr_swap(fexpr_t a, fexpr_t b) noexcept - # Swaps *a* and *b* efficiently. - slong fexpr_depth(const fexpr_t expr) noexcept - # Returns the depth of *expr* as a symbolic expression tree. - slong fexpr_num_leaves(const fexpr_t expr) noexcept - # Returns the number of leaves (atoms, counted with repetition) - # in the expression *expr*. - slong fexpr_size(const fexpr_t expr) noexcept - # Returns the number of words in the internal representation - # of *expr*. - slong fexpr_size_bytes(const fexpr_t expr) noexcept - # Returns the number of bytes in the internal representation - # of *expr*. The count excludes the size of the structure itself. - # Add ``sizeof(fexpr_struct)`` to get the size of the object as a - # whole. - slong fexpr_allocated_bytes(const fexpr_t expr) noexcept - # Returns the number of allocated bytes in the internal - # representation of *expr*. The count excludes the size of the - # structure itself. Add ``sizeof(fexpr_struct)`` to get the size of - # the object as a whole. - bint fexpr_equal(const fexpr_t a, const fexpr_t b) noexcept - # Checks if *a* and *b* are exactly equal as expressions. - bint fexpr_equal_si(const fexpr_t expr, slong c) noexcept - bint fexpr_equal_ui(const fexpr_t expr, ulong c) noexcept - # Checks if *expr* is an atomic integer exactly equal to *c*. - ulong fexpr_hash(const fexpr_t expr) noexcept - # Returns a hash of the expression *expr*. - int fexpr_cmp_fast(const fexpr_t a, const fexpr_t b) noexcept - # Compares *a* and *b* using an ordering based on the internal - # representation, returning -1, 0 or 1. This can be used, for - # instance, to maintain sorted arrays of expressions for binary - # search; the sort order has no mathematical significance. - bint fexpr_is_integer(const fexpr_t expr) noexcept - # Returns whether *expr* is an atomic integer - bint fexpr_is_symbol(const fexpr_t expr) noexcept - # Returns whether *expr* is an atomic symbol. - bint fexpr_is_string(const fexpr_t expr) noexcept - # Returns whether *expr* is an atomic string. - bint fexpr_is_atom(const fexpr_t expr) noexcept - # Returns whether *expr* is any atom. - void fexpr_zero(fexpr_t res) noexcept - # Sets *res* to the atomic integer 0. - bint fexpr_is_zero(const fexpr_t expr) noexcept - # Returns whether *expr* is the atomic integer 0. - bint fexpr_is_neg_integer(const fexpr_t expr) noexcept - # Returns whether *expr* is any negative atomic integer. - void fexpr_set_si(fexpr_t res, slong c) noexcept void fexpr_set_ui(fexpr_t res, ulong c) noexcept void fexpr_set_fmpz(fexpr_t res, const fmpz_t c) noexcept - # Sets *res* to the atomic integer *c*. - int fexpr_get_fmpz(fmpz_t res, const fexpr_t expr) noexcept - # Sets *res* to the atomic integer in *expr*. This aborts - # if *expr* is not an atomic integer. - void fexpr_set_symbol_builtin(fexpr_t res, slong id) noexcept - # Sets *res* to the builtin symbol with internal index *id* - # (see :ref:`fexpr-builtin`). - bint fexpr_is_builtin_symbol(const fexpr_t expr, slong id) noexcept - # Returns whether *expr* is the builtin symbol with index *id* - # (see :ref:`fexpr-builtin`). - bint fexpr_is_any_builtin_symbol(const fexpr_t expr) noexcept - # Returns whether *expr* is any builtin symbol - # (see :ref:`fexpr-builtin`). - void fexpr_set_symbol_str(fexpr_t res, const char * s) noexcept - # Sets *res* to the symbol given by *s*. - char * fexpr_get_symbol_str(const fexpr_t expr) noexcept - # Returns the symbol in *expr* as a string. The string must - # be freed with :func:`flint_free`. - # This aborts if *expr* is not an atomic symbol. - void fexpr_set_string(fexpr_t res, const char * s) noexcept - # Sets *res* to the atomic string *s*. - char * fexpr_get_string(const fexpr_t expr) noexcept - # Assuming that *expr* is an atomic string, returns a copy of this - # string. The string must be freed with :func:`flint_free`. - void fexpr_write(calcium_stream_t stream, const fexpr_t expr) noexcept - # Writes *expr* to *stream*. - void fexpr_print(const fexpr_t expr) noexcept - # Prints *expr* to standard output. - char * fexpr_get_str(const fexpr_t expr) noexcept - # Returns a string representation of *expr*. The string must - # be freed with :func:`flint_free`. - # Warning: string literals appearing in expressions - # are currently not escaped. - void fexpr_write_latex(calcium_stream_t stream, const fexpr_t expr, ulong flags) noexcept - # Writes the LaTeX representation of *expr* to *stream*. - void fexpr_print_latex(const fexpr_t expr, ulong flags) noexcept - # Prints the LaTeX representation of *expr* to standard output. - char * fexpr_get_str_latex(const fexpr_t expr, ulong flags) noexcept - # Returns a string of the LaTeX representation of *expr*. The string - # must be freed with :func:`flint_free`. - # Warning: string literals appearing in expressions - # are currently not escaped. - slong fexpr_nargs(const fexpr_t expr) noexcept - # Returns the number of arguments *n* in the function call - # `f(e_1,\ldots,e_n)` represented - # by *expr*. If *expr* is an atom, returns -1. - void fexpr_func(fexpr_t res, const fexpr_t expr) noexcept - # Assuming that *expr* represents a function call - # `f(e_1,\ldots,e_n)`, sets *res* to the function expression *f*. - void fexpr_view_func(fexpr_t view, const fexpr_t expr) noexcept - # As :func:`fexpr_func`, but sets *view* to a shallow view - # instead of copying the expression. - # The variable *view* must not be initialized before use or - # cleared after use, and *expr* must not be modified or cleared - # as long as *view* is in use. - void fexpr_arg(fexpr_t res, const fexpr_t expr, slong i) noexcept - # Assuming that *expr* represents a function call - # `f(e_1,\ldots,e_n)`, sets *res* to the argument `e_{i+1}`. - # Note that indexing starts from 0. - # The index must be in bounds, with `0 \le i < n`. - void fexpr_view_arg(fexpr_t view, const fexpr_t expr, slong i) noexcept - # As :func:`fexpr_arg`, but sets *view* to a shallow view - # instead of copying the expression. - # The variable *view* must not be initialized before use or - # cleared after use, and *expr* must not be modified or cleared - # as long as *view* is in use. - void fexpr_view_next(fexpr_t view) noexcept - # Assuming that *view* is a shallow view of a function argument `e_i` - # in a function call `f(e_1,\ldots,e_n)`, sets *view* to - # a view of the next argument `e_{i+1}`. - # This function can be called when *view* refers to the last argument - # `e_n`, provided that *view* is not used afterwards. - # This function can also be called when *view* refers to the function *f*, - # in which case it will make *view* point to `e_1`. - bint fexpr_is_builtin_call(const fexpr_t expr, slong id) noexcept - # Returns whether *expr* has the form `f(\ldots)` where *f* is - # a builtin function defined by *id* (see :ref:`fexpr-builtin`). - bint fexpr_is_any_builtin_call(const fexpr_t expr) noexcept - # Returns whether *expr* has the form `f(\ldots)` where *f* is - # any builtin function (see :ref:`fexpr-builtin`). - void fexpr_call0(fexpr_t res, const fexpr_t f) noexcept void fexpr_call1(fexpr_t res, const fexpr_t f, const fexpr_t x1) noexcept void fexpr_call2(fexpr_t res, const fexpr_t f, const fexpr_t x1, const fexpr_t x2) noexcept void fexpr_call3(fexpr_t res, const fexpr_t f, const fexpr_t x1, const fexpr_t x2, const fexpr_t x3) noexcept void fexpr_call4(fexpr_t res, const fexpr_t f, const fexpr_t x1, const fexpr_t x2, const fexpr_t x3, const fexpr_t x4) noexcept void fexpr_call_vec(fexpr_t res, const fexpr_t f, fexpr_srcptr args, slong len) noexcept - # Creates the function call `f(x_1,\ldots,x_n)`. - # The *vec* version takes the arguments as an array *args* - # and *n* is given by *len*. - # Warning: aliasing between inputs and outputs is not implemented. - void fexpr_call_builtin1(fexpr_t res, slong f, const fexpr_t x1) noexcept void fexpr_call_builtin2(fexpr_t res, slong f, const fexpr_t x1, const fexpr_t x2) noexcept - # Creates the function call `f(x_1,\ldots,x_n)`, where *f* defines - # a builtin symbol. - bint fexpr_contains(const fexpr_t expr, const fexpr_t x) noexcept - # Returns whether *expr* contains the expression *x* as a subexpression - # (this includes the case where *expr* and *x* are equal). - int fexpr_replace(fexpr_t res, const fexpr_t expr, const fexpr_t x, const fexpr_t y) noexcept - # Sets *res* to the expression *expr* with all occurrences of the subexpression - # *x* replaced by the expression *y*. Returns a boolean value indicating whether - # any replacements have been performed. - # Aliasing is allowed between *res* and *expr* but not between *res* - # and *x* or *y*. - int fexpr_replace2(fexpr_t res, const fexpr_t expr, const fexpr_t x1, const fexpr_t y1, const fexpr_t x2, const fexpr_t y2) noexcept - # Like :func:`fexpr_replace`, but simultaneously replaces *x1* by *y1* - # and *x2* by *y2*. - int fexpr_replace_vec(fexpr_t res, const fexpr_t expr, const fexpr_vec_t xs, const fexpr_vec_t ys) noexcept - # Sets *res* to the expression *expr* with all occurrences of the - # subexpressions given by entries in *xs* replaced by the corresponding - # expressions in *ys*. It is required that *xs* and *ys* have the same length. - # Returns a boolean value indicating whether any replacements - # have been performed. - # Aliasing is allowed between *res* and *expr* but not between *res* - # and the entries of *xs* or *ys*. - void fexpr_set_fmpq(fexpr_t res, const fmpq_t x) noexcept - # Sets *res* to the rational number *x*. This creates an atomic - # integer if the denominator of *x* is one, and otherwise creates a - # division expression. - void fexpr_set_arf(fexpr_t res, const arf_t x) noexcept void fexpr_set_d(fexpr_t res, double x) noexcept - # Sets *res* to an expression for the value of the - # floating-point number *x*. NaN is represented - # as ``Undefined``. For a regular value, this creates an atomic integer - # or a rational fraction if the exponent is small, and otherwise - # creates an expression of the form ``Mul(m, Pow(2, e))``. - void fexpr_set_re_im_d(fexpr_t res, double x, double y) noexcept - # Sets *res* to an expression for the complex number with real part - # *x* and imaginary part *y*. - void fexpr_neg(fexpr_t res, const fexpr_t a) noexcept void fexpr_add(fexpr_t res, const fexpr_t a, const fexpr_t b) noexcept void fexpr_sub(fexpr_t res, const fexpr_t a, const fexpr_t b) noexcept void fexpr_mul(fexpr_t res, const fexpr_t a, const fexpr_t b) noexcept void fexpr_div(fexpr_t res, const fexpr_t a, const fexpr_t b) noexcept void fexpr_pow(fexpr_t res, const fexpr_t a, const fexpr_t b) noexcept - # Constructs an arithmetic expression with given arguments. - # No simplifications whatsoever are performed. - bint fexpr_is_arithmetic_operation(const fexpr_t expr) noexcept - # Returns whether *expr* is of the form `f(e_1,\ldots,e_n)` - # where *f* is one of the arithmetic operators ``Pos``, ``Neg``, - # ``Add``, ``Sub``, ``Mul``, ``Div``. - void fexpr_arithmetic_nodes(fexpr_vec_t nodes, const fexpr_t expr) noexcept - # Sets *nodes* to a vector of subexpressions of *expr* such that *expr* - # is an arithmetic expression with *nodes* as leaves. - # More precisely, *expr* will be constructed out of nested application - # the arithmetic operators - # ``Pos``, ``Neg``, ``Add``, ``Sub``, ``Mul``, ``Div`` with - # integers and expressions in *nodes* as leaves. - # Powers ``Pow`` with an atomic integer exponent are also allowed. - # The nodes are output without repetition but are not automatically sorted in - # a canonical order. - int fexpr_get_fmpz_mpoly_q(fmpz_mpoly_q_t res, const fexpr_t expr, const fexpr_vec_t vars, const fmpz_mpoly_ctx_t ctx) noexcept - # Sets *res* to the expression *expr* as a formal rational - # function of the subexpressions in *vars*. - # The vector *vars* must have the same length as the number of - # variables specified in *ctx*. - # To build *vars* automatically for a given expression, - # :func:`fexpr_arithmetic_nodes` may be used. - # Returns 1 on success and 0 on failure. Failure can occur for the - # following reasons: - # * A subexpression is encountered that cannot be interpreted - # as an arithmetic operation and does not appear (exactly) in *vars*. - # * Overflow (too many terms or too large exponent). - # * Division by zero (a zero denominator is encountered). - # It is important to note that this function views *expr* as - # a formal rational function with *vars* as formal indeterminates. - # It does thus not check for algebraic relations between *vars* - # and can implicitly divide by zero if *vars* are not algebraically - # independent. - void fexpr_set_fmpz_mpoly(fexpr_t res, const fmpz_mpoly_t poly, const fexpr_vec_t vars, const fmpz_mpoly_ctx_t ctx) noexcept void fexpr_set_fmpz_mpoly_q(fexpr_t res, const fmpz_mpoly_q_t frac, const fexpr_vec_t vars, const fmpz_mpoly_ctx_t ctx) noexcept - # Sets *res* to an expression for the multivariate polynomial *poly* - # (or rational function *frac*), - # using the expressions in *vars* as the variables. The length - # of *vars* must agree with the number of variables in *ctx*. - # If *NULL* is passed for *vars*, a default choice of symbols - # is used. - int fexpr_expanded_normal_form(fexpr_t res, const fexpr_t expr, ulong flags) noexcept - # Sets *res* to *expr* converted to expanded normal form viewed - # as a formal rational function with its non-arithmetic subexpressions - # as terminal nodes. - # This function first computes nodes with :func:`fexpr_arithmetic_nodes`, - # sorts the nodes, evaluates to a rational function with - # :func:`fexpr_get_fmpz_mpoly_q`, and then converts back to an - # expression with :func:`fexpr_set_fmpz_mpoly_q`. - # Optional *flags* are reserved for future use. - void fexpr_vec_init(fexpr_vec_t vec, slong len) noexcept - # Initializes *vec* to a vector of length *len*. All entries - # are set to the atomic integer 0. - void fexpr_vec_clear(fexpr_vec_t vec) noexcept - # Clears the vector *vec*. - void fexpr_vec_print(const fexpr_vec_t vec) noexcept - # Prints *vec* to standard output. - void fexpr_vec_swap(fexpr_vec_t x, fexpr_vec_t y) noexcept - # Swaps *x* and *y* efficiently. - void fexpr_vec_fit_length(fexpr_vec_t vec, slong len) noexcept - # Ensures that *vec* has space for *len* entries. - void fexpr_vec_set(fexpr_vec_t dest, const fexpr_vec_t src) noexcept - # Sets *dest* to a copy of *src*. - void fexpr_vec_append(fexpr_vec_t vec, const fexpr_t expr) noexcept - # Appends *expr* to the end of the vector *vec*. - slong fexpr_vec_insert_unique(fexpr_vec_t vec, const fexpr_t expr) noexcept - # Inserts *expr* without duplication into vec, returning its - # position. If this expression already exists, *vec* is unchanged. - # If this expression does not exist in *vec*, it is appended. - void fexpr_vec_set_length(fexpr_vec_t vec, slong len) noexcept - # Sets the length of *vec* to *len*, truncating or zero-extending as needed. - void _fexpr_vec_sort_fast(fexpr_ptr vec, slong len) noexcept - # Sorts the *len* entries in *vec* using - # the comparison function :func:`fexpr_cmp_fast`. diff --git a/src/sage/libs/flint/fexpr_builtin.pxd b/src/sage/libs/flint/fexpr_builtin.pxd index 068a6feee89..d434d9c40d6 100644 --- a/src/sage/libs/flint/fexpr_builtin.pxd +++ b/src/sage/libs/flint/fexpr_builtin.pxd @@ -2,7 +2,9 @@ # distutils: depends = flint/fexpr_builtin.h ################################################################################ -# This file is auto-generated. Do not modify by hand +# This file is auto-generated by the script +# SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py. +# Do not modify by hand! Fix and rerun the script instead. ################################################################################ from libc.stdio cimport FILE @@ -11,15 +13,6 @@ from sage.libs.mpfr.types cimport * from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - slong fexpr_builtin_lookup(const char * s) noexcept - # Returns the internal index used to encode the builtin symbol - # with name *s* in expressions. If *s* is not the name of a builtin - # symbol, returns -1. - const char * fexpr_builtin_name(slong n) noexcept - # Returns a read-only pointer for a string giving the name of the - # builtin symbol with index *n*. - slong fexpr_builtin_length() noexcept - # Returns the number of builtin symbols. diff --git a/src/sage/libs/flint/fft.pxd b/src/sage/libs/flint/fft.pxd index 68d0dc09ae8..e5362f1b90b 100644 --- a/src/sage/libs/flint/fft.pxd +++ b/src/sage/libs/flint/fft.pxd @@ -2,7 +2,9 @@ # distutils: depends = flint/fft.h ################################################################################ -# This file is auto-generated. Do not modify by hand +# This file is auto-generated by the script +# SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py. +# Do not modify by hand! Fix and rerun the script instead. ################################################################################ from libc.stdio cimport FILE @@ -11,430 +13,52 @@ from sage.libs.mpfr.types cimport * from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - mp_size_t fft_split_limbs(mp_limb_t ** poly, mp_srcptr limbs, mp_size_t total_limbs, mp_size_t coeff_limbs, mp_size_t output_limbs) noexcept - # Split an integer ``(limbs, total_limbs)`` into coefficients of length - # ``coeff_limbs`` limbs and store as the coefficients of ``poly`` - # which are assumed to have space for ``output_limbs + 1`` limbs per - # coefficient. The coefficients of the polynomial do not need to be zeroed - # before calling this function, however the number of coefficients written - # is returned by the function and any coefficients beyond this point are - # not touched. - mp_size_t fft_split_bits(mp_limb_t ** poly, mp_srcptr limbs, mp_size_t total_limbs, flint_bitcnt_t bits, mp_size_t output_limbs) noexcept - # Split an integer ``(limbs, total_limbs)`` into coefficients of the - # given number of ``bits`` and store as the coefficients of ``poly`` - # which are assumed to have space for ``output_limbs + 1`` limbs per - # coefficient. The coefficients of the polynomial do not need to be zeroed - # before calling this function, however the number of coefficients written - # is returned by the function and any coefficients beyond this point are - # not touched. - void fft_combine_limbs(mp_limb_t * res, mp_limb_t ** poly, slong length, mp_size_t coeff_limbs, mp_size_t output_limbs, mp_size_t total_limbs) noexcept - # Evaluate the polynomial ``poly`` of the given ``length`` at - # ``B^coeff_limbs``, where ``B = 2^FLINT_BITS``, and add the - # result to the integer ``(res, total_limbs)`` throwing away any bits - # that exceed the given number of limbs. The polynomial coefficients are - # assumed to have at least ``output_limbs`` limbs each, however any - # additional limbs are ignored. - # If the integer is initially zero the result will just be the evaluation - # of the polynomial. - void fft_combine_bits(mp_limb_t * res, mp_limb_t ** poly, slong length, flint_bitcnt_t bits, mp_size_t output_limbs, mp_size_t total_limbs) noexcept - # Evaluate the polynomial ``poly`` of the given ``length`` at - # ``2^bits`` and add the result to the integer - # ``(res, total_limbs)`` throwing away any bits that exceed the given - # number of limbs. The polynomial coefficients are assumed to have at least - # ``output_limbs`` limbs each, however any additional limbs are ignored. - # If the integer is initially zero the result will just be the evaluation - # of the polynomial. - void fermat_to_mpz(mpz_t m, mp_limb_t * i, mp_size_t limbs) noexcept - # Convert the Fermat number ``(i, limbs)`` modulo ``B^limbs + 1`` to - # an ``mpz_t m``. Assumes ``m`` has been initialised. This function - # is used only in test code. - - void mpn_negmod_2expp1(mp_limb_t* z, const mp_limb_t* a, mp_size_t limbs) noexcept - # Set ``z`` to the negation of the Fermat number `a` modulo ``B^limbs + 1``. - # The input ``a`` is expected to be fully reduced, and the output is fully reduced. - # Aliasing is permitted. - + void mpn_negmod_2expp1(mp_limb_t * z, const mp_limb_t * a, mp_size_t limbs) noexcept void mpn_addmod_2expp1_1(mp_limb_t * r, mp_size_t limbs, mp_limb_signed_t c) noexcept - # Adds the signed limb ``c`` to the generalised Fermat number ``r`` - # modulo ``B^limbs + 1``. The compiler should be able to inline - # this for the case that there is no overflow from the first limb. - void mpn_normmod_2expp1(mp_limb_t * t, mp_size_t limbs) noexcept - # Given ``t`` a signed integer of ``limbs + 1`` limbs in two's - # complement format, reduce ``t`` to the corresponding value modulo the - # generalised Fermat number ``B^limbs + 1``, where - # ``B = 2^FLINT_BITS``. - void mpn_mul_2expmod_2expp1(mp_limb_t * t, mp_limb_t * i1, mp_size_t limbs, flint_bitcnt_t d) noexcept - # Given ``i1`` a signed integer of ``limbs + 1`` limbs in two's - # complement format reduced modulo ``B^limbs + 1`` up to some - # overflow, compute ``t = i1*2^d`` modulo `p`. The result will not - # necessarily be fully reduced. The number of bits ``d`` must be - # nonnegative and less than ``FLINT_BITS``. Aliasing is permitted. - void mpn_div_2expmod_2expp1(mp_limb_t * t, mp_limb_t * i1, mp_size_t limbs, flint_bitcnt_t d) noexcept - # Given ``i1`` a signed integer of ``limbs + 1`` limbs in two's - # complement format reduced modulo ``B^limbs + 1`` up to some - # overflow, compute ``t = i1/2^d`` modulo `p`. The result will not - # necessarily be fully reduced. The number of bits ``d`` must be - # nonnegative and less than ``FLINT_BITS``. Aliasing is permitted. - void fft_adjust(mp_limb_t * r, mp_limb_t * i1, mp_size_t i, mp_size_t limbs, flint_bitcnt_t w) noexcept - # Set ``r`` to ``i1`` times `z^i` modulo ``B^limbs + 1`` where - # `z` corresponds to multiplication by `2^w`. This can be thought of as part - # of a butterfly operation. We require `0 \leq i < n` where `nw =` - # ``limbs*FLINT_BITS``. Aliasing is not supported. - void fft_adjust_sqrt2(mp_limb_t * r, mp_limb_t * i1, mp_size_t i, mp_size_t limbs, flint_bitcnt_t w, mp_limb_t * temp) noexcept - # Set ``r`` to ``i1`` times `z^i` modulo ``B^limbs + 1`` where - # `z` corresponds to multiplication by `\sqrt{2}^w`. This can be thought of - # as part of a butterfly operation. We require `0 \leq i < 2\cdot n` and odd - # where `nw =` ``limbs*FLINT_BITS``. - void butterfly_lshB(mp_limb_t * t, mp_limb_t * u, mp_limb_t * i1, mp_limb_t * i2, mp_size_t limbs, mp_size_t x, mp_size_t y) noexcept - # We are given two integers ``i1`` and ``i2`` modulo - # ``B^limbs + 1`` which are not necessarily normalised. We compute - # ``t = (i1 + i2)*B^x`` and ``u = (i1 - i2)*B^y`` modulo `p`. Aliasing - # between inputs and outputs is not permitted. We require ``x`` and - # ``y`` to be less than ``limbs`` and nonnegative. - void butterfly_rshB(mp_limb_t * t, mp_limb_t * u, mp_limb_t * i1, mp_limb_t * i2, mp_size_t limbs, mp_size_t x, mp_size_t y) noexcept - # We are given two integers ``i1`` and ``i2`` modulo - # ``B^limbs + 1`` which are not necessarily normalised. We compute - # ``t = (i1 + i2)/B^x`` and ``u = (i1 - i2)/B^y`` modulo `p`. Aliasing - # between inputs and outputs is not permitted. We require ``x`` and - # ``y`` to be less than ``limbs`` and nonnegative. - void fft_butterfly(mp_limb_t * s, mp_limb_t * t, mp_limb_t * i1, mp_limb_t * i2, mp_size_t i, mp_size_t limbs, flint_bitcnt_t w) noexcept - # Set ``s = i1 + i2``, ``t = z1^i*(i1 - i2)`` modulo - # ``B^limbs + 1`` where ``z1 = exp(Pi*I/n)`` corresponds to - # multiplication by `2^w`. Requires `0 \leq i < n` where `nw =` - # ``limbs*FLINT_BITS``. - void ifft_butterfly(mp_limb_t * s, mp_limb_t * t, mp_limb_t * i1, mp_limb_t * i2, mp_size_t i, mp_size_t limbs, flint_bitcnt_t w) noexcept - # Set ``s = i1 + z1^i*i2``, ``t = i1 - z1^i*i2`` modulo - # ``B^limbs + 1`` where ``z1 = exp(-Pi*I/n)`` corresponds to - # division by `2^w`. Requires `0 \leq i < 2n` where `nw =` - # ``limbs*FLINT_BITS``. - void fft_radix2(mp_limb_t ** ii, mp_size_t n, flint_bitcnt_t w, mp_limb_t ** t1, mp_limb_t ** t2) noexcept - # The radix 2 DIF FFT works as follows: - # Input: ``[i0, i1, ..., i(m-1)]``, for `m = 2n` a power of `2`. - # Output: ``[r0, r1, ..., r(m-1)]`` ``= FFT[i0, i1, ..., i(m-1)]``. - # Algorithm: - # | `\bullet` Recursively compute ``[r0, r2, r4, ...., r(m-2)]`` - # | ``= FFT[i0+i(m/2), i1+i(m/2+1), ..., i(m/2-1)+i(m-1)]`` - # | - # | `\bullet` Let ``[t0, t1, ..., t(m/2-1)]`` - # | ``= [i0-i(m/2), i1-i(m/2+1), ..., i(m/2-1)-i(m-1)]`` - # | - # | `\bullet` Let ``[u0, u1, ..., u(m/2-1)]`` - # | ``= [z1^0*t0, z1^1*t1, ..., z1^(m/2-1)*t(m/2-1)]`` - # | where ``z1 = exp(2*Pi*I/m)`` corresponds to multiplication by `2^w`. - # | - # | `\bullet` Recursively compute ``[r1, r3, ..., r(m-1)]`` - # | ``= FFT[u0, u1, ..., u(m/2-1)]`` - # The parameters are as follows: - # `\bullet` ``2*n`` is the length of the input and output arrays - # `\bullet` `w` is such that `2^w` is an `2n`-th root of unity in the ring `\mathbf{Z}/p\mathbf{Z}` that we are working in, i.e. `p = 2^{wn} + 1` (here `n` is divisible by - # ``GMP_LIMB_BITS``) - # `\bullet` ``ii`` is the array of inputs (each input is an - # array of limbs of length ``wn/GMP_LIMB_BITS + 1`` (the - # extra limbs being a "carry limb"). Outputs are written - # in-place. - # We require `nw` to be at least 64 and the two temporary space pointers to - # point to blocks of size ``n*w + FLINT_BITS`` bits. - void fft_truncate(mp_limb_t ** ii, mp_size_t n, flint_bitcnt_t w, mp_limb_t ** t1, mp_limb_t ** t2, mp_size_t trunc) noexcept - # As for ``fft_radix2`` except that only the first ``trunc`` - # coefficients of the output are computed and the input is regarded as - # having (implied) zero coefficients from coefficient ``trunc`` onwards. - # The coefficients must exist as the algorithm needs to use this extra - # space, but their value is irrelevant. The value of ``trunc`` must be - # divisible by 2. - void fft_truncate1(mp_limb_t ** ii, mp_size_t n, flint_bitcnt_t w, mp_limb_t ** t1, mp_limb_t ** t2, mp_size_t trunc) noexcept - # As for ``fft_radix2`` except that only the first ``trunc`` - # coefficients of the output are computed. The transform still needs all - # `2n` input coefficients to be specified. - void ifft_radix2(mp_limb_t ** ii, mp_size_t n, flint_bitcnt_t w, mp_limb_t ** t1, mp_limb_t ** t2) noexcept - # The radix 2 DIF IFFT works as follows: - # Input: ``[i0, i1, ..., i(m-1)]``, for `m = 2n` a power of `2`. - # Output: ``[r0, r1, ..., r(m-1)]`` - # ``= IFFT[i0, i1, ..., i(m-1)]``. - # Algorithm: - # `\bullet` Recursively compute ``[s0, s1, ...., s(m/2-1)]`` - # ``= IFFT[i0, i2, ..., i(m-2)]`` - # `\bullet` Recursively compute ``[t(m/2), t(m/2+1), ..., t(m-1)]`` - # ``= IFFT[i1, i3, ..., i(m-1)]`` - # `\bullet` Let ``[r0, r1, ..., r(m/2-1)]`` - # ``= [s0+z1^0*t0, s1+z1^1*t1, ..., s(m/2-1)+z1^(m/2-1)*t(m/2-1)]`` where ``z1 = exp(-2*Pi*I/m)`` corresponds to division by `2^w`. - # `\bullet` Let ``[r(m/2), r(m/2+1), ..., r(m-1)]`` - # ``= [s0-z1^0*t0, s1-z1^1*t1, ..., s(m/2-1)-z1^(m/2-1)*t(m/2-1)]`` - # The parameters are as follows: - # `\bullet` ``2*n`` is the length of the input and output - # arrays - # `\bullet` `w` is such that `2^w` is an `2n`-th root of unity in the ring `\mathbf{Z}/p\mathbf{Z}` that we are working in, i.e. `p = 2^{wn} + 1` (here `n` is divisible by - # ``GMP_LIMB_BITS``) - # `\bullet` ``ii`` is the array of inputs (each input is an array of limbs of length ``wn/GMP_LIMB_BITS + 1`` (the extra limbs being a "carry limb"). Outputs are written in-place. - # We require `nw` to be at least 64 and the two temporary space pointers - # to point to blocks of size ``n*w + FLINT_BITS`` bits. - void ifft_truncate(mp_limb_t ** ii, mp_size_t n, flint_bitcnt_t w, mp_limb_t ** t1, mp_limb_t ** t2, mp_size_t trunc) noexcept - # As for ``ifft_radix2`` except that the output is assumed to have - # zeros from coefficient trunc onwards and only the first trunc - # coefficients of the input are specified. The remaining coefficients need - # to exist as the extra space is needed, but their value is irrelevant. - # The value of ``trunc`` must be divisible by 2. - # Although the implementation does not require it, we assume for simplicity - # that ``trunc`` is greater than `n`. The algorithm begins by computing - # the inverse transform of the first `n` coefficients of the input array. - # The unspecified coefficients of the second half of the array are then - # written: coefficient ``trunc + i`` is computed as a twist of - # coefficient ``i`` by a root of unity. The values of these coefficients - # are then equal to what they would have been if the inverse transform of - # the right hand side of the input array had been computed with full data - # from the start. The function ``ifft_truncate1`` is then called on the - # entire right half of the input array with this auxiliary data filled in. - # Finally a single layer of the IFFT is completed on all the coefficients - # up to ``trunc`` being careful to note that this involves doubling the - # coefficients from ``trunc - n`` up to ``n``. - void ifft_truncate1(mp_limb_t ** ii, mp_size_t n, flint_bitcnt_t w, mp_limb_t ** t1, mp_limb_t ** t2, mp_size_t trunc) noexcept - # Computes the first ``trunc`` coefficients of the radix 2 inverse - # transform assuming the first ``trunc`` coefficients are given and that - # the remaining coefficients have been set to the value they would have if - # an inverse transform had already been applied with full data. - # The algorithm is the same as for ``ifft_truncate`` except that the - # coefficients from ``trunc`` onwards after the inverse transform are - # not inferred to be zero but the supplied values. - void fft_butterfly_sqrt2(mp_limb_t * s, mp_limb_t * t, mp_limb_t * i1, mp_limb_t * i2, mp_size_t i, mp_size_t limbs, flint_bitcnt_t w, mp_limb_t * temp) noexcept - # Let `w = 2k + 1`, `i = 2j + 1`. Set ``s = i1 + i2``, - # ``t = z1^i*(i1 - i2)`` modulo ``B^limbs + 1`` where - # ``z1^2 = exp(Pi*I/n)`` corresponds to multiplication by `2^w`. Requires - # `0 \leq i < 2n` where `nw =` ``limbs*FLINT_BITS``. - # Here ``z1`` corresponds to multiplication by `2^k` then multiplication - # by ``(2^(3nw/4) - 2^(nw/4))``. We see ``z1^i`` corresponds to - # multiplication by ``(2^(3nw/4) - 2^(nw/4))*2^(j+ik)``. - # We first multiply by ``2^(j + ik + wn/4)`` then multiply by an - # additional ``2^(nw/2)`` and subtract. - void ifft_butterfly_sqrt2(mp_limb_t * s, mp_limb_t * t, mp_limb_t * i1, mp_limb_t * i2, mp_size_t i, mp_size_t limbs, flint_bitcnt_t w, mp_limb_t * temp) noexcept - # Let `w = 2k + 1`, `i = 2j + 1`. Set ``s = i1 + z1^i*i2``, - # ``t = i1 - z1^i*i2`` modulo ``B^limbs + 1`` where - # ``z1^2 = exp(-Pi*I/n)`` corresponds to division by `2^w`. Requires - # `0 \leq i < 2n` where `nw =` ``limbs*FLINT_BITS``. - # Here ``z1`` corresponds to division by `2^k` then division by - # ``(2^(3nw/4) - 2^(nw/4))``. We see ``z1^i`` corresponds to division - # by ``(2^(3nw/4) - 2^(nw/4))*2^(j+ik)`` which is the same as division - # by ``2^(j+ik + 1)`` then multiplication by - # ``(2^(3nw/4) - 2^(nw/4))``. - # Of course, division by ``2^(j+ik + 1)`` is the same as multiplication - # by ``2^(2*wn - j - ik - 1)``. The exponent is positive as - # `i \leq 2\cdot n`, `j < n`, `k < w/2`. - # We first multiply by ``2^(2*wn - j - ik - 1 + wn/4)`` then multiply by - # an additional ``2^(nw/2)`` and subtract. - void fft_truncate_sqrt2(mp_limb_t ** ii, mp_size_t n, flint_bitcnt_t w, mp_limb_t ** t1, mp_limb_t ** t2, mp_limb_t ** temp, mp_size_t trunc) noexcept - # As per ``fft_truncate`` except that the transform is twice the usual - # length, i.e. length `4n` rather than `2n`. This is achieved by making use - # of twiddles by powers of a square root of 2, not powers of 2 in the first - # layer of the transform. - # We require `nw` to be at least 64 and the three temporary space pointers - # to point to blocks of size ``n*w + FLINT_BITS`` bits. - void ifft_truncate_sqrt2(mp_limb_t ** ii, mp_size_t n, flint_bitcnt_t w, mp_limb_t ** t1, mp_limb_t ** t2, mp_limb_t ** temp, mp_size_t trunc) noexcept - # As per ``ifft_truncate`` except that the transform is twice the usual - # length, i.e. length `4n` instead of `2n`. This is achieved by making use - # of twiddles by powers of a square root of 2, not powers of 2 in the final - # layer of the transform. - # We require `nw` to be at least 64 and the three temporary space pointers - # to point to blocks of size ``n*w + FLINT_BITS`` bits. - void fft_butterfly_twiddle(mp_limb_t * u, mp_limb_t * v, mp_limb_t * s, mp_limb_t * t, mp_size_t limbs, flint_bitcnt_t b1, flint_bitcnt_t b2) noexcept - # Set ``u = 2^b1*(s + t)``, ``v = 2^b2*(s - t)`` modulo - # ``B^limbs + 1``. This is used to compute - # ``u = 2^(ws*tw1)*(s + t)``, ``v = 2^(w+ws*tw2)*(s - t)`` in the - # matrix Fourier algorithm, i.e. effectively computing an ordinary butterfly - # with additional twiddles by ``z1^rc`` for row `r` and column `c` of the - # matrix of coefficients. Aliasing is not allowed. - void ifft_butterfly_twiddle(mp_limb_t * u, mp_limb_t * v, mp_limb_t * s, mp_limb_t * t, mp_size_t limbs, flint_bitcnt_t b1, flint_bitcnt_t b2) noexcept - # Set ``u = s/2^b1 + t/2^b1)``, ``v = s/2^b1 - t/2^b1`` modulo - # ``B^limbs + 1``. This is used to compute - # ``u = 2^(-ws*tw1)*s + 2^(-ws*tw2)*t)``, - # ``v = 2^(-ws*tw1)*s + 2^(-ws*tw2)*t)`` in the matrix Fourier algorithm, - # i.e. effectively computing an ordinary butterfly with additional twiddles - # by ``z1^(-rc)`` for row `r` and column `c` of the matrix of - # coefficients. Aliasing is not allowed. - void fft_radix2_twiddle(mp_limb_t ** ii, mp_size_t iis, mp_size_t n, flint_bitcnt_t w, mp_limb_t ** t1, mp_limb_t ** t2, mp_size_t ws, mp_size_t r, mp_size_t c, mp_size_t rs) noexcept - # As for ``fft_radix2`` except that the coefficients are spaced by - # ``is`` in the array ``ii`` and an additional twist by ``z^c*i`` - # is applied to each coefficient where `i` starts at `r` and increases by - # ``rs`` as one moves from one coefficient to the next. Here ``z`` - # corresponds to multiplication by ``2^ws``. - void ifft_radix2_twiddle(mp_limb_t ** ii, mp_size_t iis, mp_size_t n, flint_bitcnt_t w, mp_limb_t ** t1, mp_limb_t ** t2, mp_size_t ws, mp_size_t r, mp_size_t c, mp_size_t rs) noexcept - # As for ``ifft_radix2`` except that the coefficients are spaced by - # ``is`` in the array ``ii`` and an additional twist by - # ``z^(-c*i)`` is applied to each coefficient where `i` starts at `r` - # and increases by ``rs`` as one moves from one coefficient to the next. - # Here ``z`` corresponds to multiplication by ``2^ws``. - void fft_truncate1_twiddle(mp_limb_t ** ii, mp_size_t iis, mp_size_t n, flint_bitcnt_t w, mp_limb_t ** t1, mp_limb_t ** t2, mp_size_t ws, mp_size_t r, mp_size_t c, mp_size_t rs, mp_size_t trunc) noexcept - # As per ``fft_radix2_twiddle`` except that the transform is truncated - # as per ``fft_truncate1``. - void ifft_truncate1_twiddle(mp_limb_t ** ii, mp_size_t iis, mp_size_t n, flint_bitcnt_t w, mp_limb_t ** t1, mp_limb_t ** t2, mp_size_t ws, mp_size_t r, mp_size_t c, mp_size_t rs, mp_size_t trunc) noexcept - # As per ``ifft_radix2_twiddle`` except that the transform is truncated - # as per ``ifft_truncate1``. - void fft_mfa_truncate_sqrt2(mp_limb_t ** ii, mp_size_t n, flint_bitcnt_t w, mp_limb_t ** t1, mp_limb_t ** t2, mp_limb_t ** temp, mp_size_t n1, mp_size_t trunc) noexcept - # This is as per the ``fft_truncate_sqrt2`` function except that the - # matrix Fourier algorithm is used for the left and right FFTs. The total - # transform length is `4n` where ``n = 2^depth`` so that the left and - # right transforms are both length `2n`. We require ``trunc > 2*n`` and - # that ``trunc`` is divisible by ``2*n1`` (explained below). The coefficients - # are produced in an order different from ``fft_truncate_sqrt2``. - # The matrix Fourier algorithm, which is applied to each transform of length - # `2n`, works as follows. We set ``n1`` to a power of 2 about the square - # root of `n`. The data is then thought of as a set of ``n2`` rows each - # with ``n1`` columns (so that ``n1*n2 = 2n``). - # The length `2n` transform is then computed using a whole pile of short - # transforms. These comprise ``n1`` column transforms of length ``n2`` - # followed by some twiddles by roots of unity (namely ``z^rc`` where `r` - # is the row and `c` the column within the data) followed by ``n2`` - # row transforms of length ``n1``. Along the way the data needs to be - # rearranged due to the fact that the short transforms output the data in - # binary reversed order compared with what is needed. - # The matrix Fourier algorithm provides better cache locality by decomposing - # the long length `2n` transforms into many transforms of about the square - # root of the original length. - # For better cache locality the sqrt2 layer of the full length `4n` - # transform is folded in with the column FFTs performed as part of the first - # matrix Fourier algorithm on the left half of the data. - # The second half of the data requires a truncated version of the matrix - # Fourier algorithm. This is achieved by truncating to an exact multiple of - # the row length so that the row transforms are full length. Moreover, the - # column transforms will then be truncated transforms and their truncated - # length needs to be a multiple of 2. This explains the condition on - # ``trunc`` given above. - # To improve performance, the extra twiddles by roots of unity are combined - # with the butterflies performed at the last layer of the column transforms. - # We require `nw` to be at least 64 and the three temporary space pointers - # to point to blocks of size ``n*w + FLINT_BITS`` bits. - void ifft_mfa_truncate_sqrt2(mp_limb_t ** ii, mp_size_t n, flint_bitcnt_t w, mp_limb_t ** t1, mp_limb_t ** t2, mp_limb_t ** temp, mp_size_t n1, mp_size_t trunc) noexcept - # This is as per the ``ifft_truncate_sqrt2`` function except that the - # matrix Fourier algorithm is used for the left and right IFFTs. The total - # transform length is `4n` where ``n = 2^depth`` so that the left and - # right transforms are both length `2n`. We require ``trunc > 2*n`` and - # that ``trunc`` is divisible by ``2*n1``. - # We set ``n1`` to a power of 2 about the square root of `n`. - # As per the matrix fourier FFT the sqrt2 layer is folded into the - # final column IFFTs for better cache locality and the extra twiddles that - # occur in the matrix Fourier algorithm are combined with the butterflied - # performed at the first layer of the final column transforms. - # We require `nw` to be at least 64 and the three temporary space pointers - # to point to blocks of size ``n*w + FLINT_BITS`` bits. - void fft_mfa_truncate_sqrt2_outer(mp_limb_t ** ii, mp_size_t n, flint_bitcnt_t w, mp_limb_t ** t1, mp_limb_t ** t2, mp_limb_t ** temp, mp_size_t n1, mp_size_t trunc) noexcept - # Just the outer layers of ``fft_mfa_truncate_sqrt2``. - void fft_mfa_truncate_sqrt2_inner(mp_limb_t ** ii, mp_limb_t ** jj, mp_size_t n, flint_bitcnt_t w, mp_limb_t ** t1, mp_limb_t ** t2, mp_limb_t ** temp, mp_size_t n1, mp_size_t trunc, mp_limb_t ** tt) noexcept - # The inner layers of ``fft_mfa_truncate_sqrt2`` and - # ``ifft_mfa_truncate_sqrt2`` combined with pointwise mults. - void ifft_mfa_truncate_sqrt2_outer(mp_limb_t ** ii, mp_size_t n, flint_bitcnt_t w, mp_limb_t ** t1, mp_limb_t ** t2, mp_limb_t ** temp, mp_size_t n1, mp_size_t trunc) noexcept - # The outer layers of ``ifft_mfa_truncate_sqrt2`` combined with - # normalisation. - void fft_negacyclic(mp_limb_t ** ii, mp_size_t n, flint_bitcnt_t w, mp_limb_t ** t1, mp_limb_t ** t2, mp_limb_t ** temp) noexcept - # As per ``fft_radix2`` except that it performs a sqrt2 negacyclic - # transform of length `2n`. This is the same as the radix 2 transform - # except that the `i`-th coefficient of the input is first multiplied by - # `\sqrt{2}^{iw}`. - # We require `nw` to be at least 64 and the two temporary space pointers to - # point to blocks of size ``n*w + FLINT_BITS`` bits. - void ifft_negacyclic(mp_limb_t ** ii, mp_size_t n, flint_bitcnt_t w, mp_limb_t ** t1, mp_limb_t ** t2, mp_limb_t ** temp) noexcept - # As per ``ifft_radix2`` except that it performs a sqrt2 negacyclic - # inverse transform of length `2n`. This is the same as the radix 2 inverse - # transform except that the `i`-th coefficient of the output is finally - # divided by `\sqrt{2}^{iw}`. - # We require `nw` to be at least 64 and the two temporary space pointers to - # point to blocks of size ``n*w + FLINT_BITS`` bits. - void fft_naive_convolution_1(mp_limb_t * r, mp_limb_t * ii, mp_limb_t * jj, mp_size_t m) noexcept - # Performs a naive negacyclic convolution of ``ii`` with ``jj``, - # both of length `m`, and sets `r` to the result. This is essentially - # multiplication of polynomials modulo `x^m + 1`. - void _fft_mulmod_2expp1(mp_limb_t * r1, mp_limb_t * i1, mp_limb_t * i2, mp_size_t r_limbs, flint_bitcnt_t depth, flint_bitcnt_t w) noexcept - # Multiply ``i1`` by ``i2`` modulo ``B^r_limbs + 1`` where - # ``r_limbs = nw/FLINT_BITS`` with ``n = 2^depth``. Uses the - # negacyclic FFT convolution CRT'd with a 1 limb naive convolution. We - # require that ``depth`` and ``w`` have been selected as per the - # wrapper ``fft_mulmod_2expp1`` below. - slong fft_adjust_limbs(mp_size_t limbs) noexcept - # Given a number of limbs, returns a new number of limbs (no more than - # the next power of 2) which will work with the Nussbaumer code. It is only - # necessary to make this adjustment if - # ``limbs > FFT_MULMOD_2EXPP1_CUTOFF``. - void fft_mulmod_2expp1(mp_limb_t * r, mp_limb_t * i1, mp_limb_t * i2, mp_size_t n, mp_size_t w, mp_limb_t * tt) noexcept - # As per ``_fft_mulmod_2expp1`` but with a tuned cutoff below which more - # classical methods are used for the convolution. The temporary space is - # required to fit ``n*w + FLINT_BITS`` bits. There are no restrictions - # on `n`, but if ``limbs = n*w/FLINT_BITS`` then if ``limbs`` exceeds - # ``FFT_MULMOD_2EXPP1_CUTOFF`` the function ``fft_adjust_limbs`` must - # be called to increase the number of limbs to an appropriate value. - void mul_truncate_sqrt2(mp_ptr r1, mp_srcptr i1, mp_size_t n1, mp_srcptr i2, mp_size_t n2, flint_bitcnt_t depth, flint_bitcnt_t w) noexcept - # Integer multiplication using the radix 2 truncated sqrt2 transforms. - # Set ``(r1, n1 + n2)`` to the product of ``(i1, n1)`` by - # ``(i2, n2)``. This is achieved through an FFT convolution of length at - # most ``2^(depth + 2)`` with coefficients of size `nw` bits where - # ``n = 2^depth``. We require ``depth >= 6``. The input data is - # broken into chunks of data not exceeding ``(nw - (depth + 1))/2`` - # bits. If breaking the first integer into chunks of this size results in - # ``j1`` coefficients and breaking the second integer results in - # ``j2`` chunks then ``j1 + j2 - 1 <= 2^(depth + 2)``. - # If ``n = 2^depth`` then we require `nw` to be at least 64. - void mul_mfa_truncate_sqrt2(mp_ptr r1, mp_srcptr i1, mp_size_t n1, mp_srcptr i2, mp_size_t n2, flint_bitcnt_t depth, flint_bitcnt_t w) noexcept - # As for ``mul_truncate_sqrt2`` except that the cache friendly matrix - # Fourier algorithm is used. - # If ``n = 2^depth`` then we require `nw` to be at least 64. Here we - # also require `w` to be `2^i` for some `i \geq 0`. - void flint_mpn_mul_fft_main(mp_ptr r1, mp_srcptr i1, mp_size_t n1, mp_srcptr i2, mp_size_t n2) noexcept - # The main integer multiplication routine. Sets ``(r1, n1 + n2)`` to - # ``(i1, n1)`` times ``(i2, n2)``. We require ``n1 >= n2 > 0``. - void fft_convolution(mp_limb_t ** ii, mp_limb_t ** jj, slong depth, slong limbs, slong trunc, mp_limb_t ** t1, mp_limb_t ** t2, mp_limb_t ** s1, mp_limb_t ** tt) noexcept - # Perform an FFT convolution of ``ii`` with ``jj``, both of length - # ``4*n`` where ``n = 2^depth``. Assume that all but the first - # ``trunc`` coefficients of the output (placed in ``ii``) are zero. - # Each coefficient is taken modulo ``B^limbs + 1``. The temporary - # spaces ``t1``, ``t2`` and ``s1`` must have ``limbs + 1`` - # limbs of space and ``tt`` must have ``2*(limbs + 1)`` of free - # space. - void fft_precache(mp_limb_t ** jj, slong depth, slong limbs, slong trunc, mp_limb_t ** t1, mp_limb_t ** t2, mp_limb_t ** s1) noexcept - # Precompute the FFT of ``jj`` for use with precache functions. The - # parameters are as for ``fft_convolution``. - void fft_convolution_precache(mp_limb_t ** ii, mp_limb_t ** jj, slong depth, slong limbs, slong trunc, mp_limb_t ** t1, mp_limb_t ** t2, mp_limb_t ** s1, mp_limb_t ** tt) noexcept - # As per ``fft_convolution`` except that it is assumed ``fft_precache`` has - # been called on ``jj`` with the same parameters. This will then run faster - # than if ``fft_convolution`` had been run with the original ``jj``. diff --git a/src/sage/libs/flint/flint.pxd b/src/sage/libs/flint/flint.pxd index 7794cbbf28e..33af77f9c16 100644 --- a/src/sage/libs/flint/flint.pxd +++ b/src/sage/libs/flint/flint.pxd @@ -2,7 +2,9 @@ # distutils: depends = flint/flint.h ################################################################################ -# This file is auto-generated. Do not modify by hand +# This file is auto-generated by the script +# SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py. +# Do not modify by hand! Fix and rerun the script instead. ################################################################################ from libc.stdio cimport FILE @@ -11,85 +13,22 @@ from sage.libs.mpfr.types cimport * from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - mp_limb_t FLINT_BIT_COUNT(mp_limb_t x) noexcept - # Returns the number of binary bits required to represent an ``ulong x``. If - # `x` is zero, returns `0`. - void * flint_malloc(size_t size) noexcept - void * flint_realloc(void * ptr, size_t size) noexcept - void * flint_calloc(size_t num, size_t size) noexcept - void flint_free(void * ptr) noexcept - flint_rand_s * flint_rand_alloc() noexcept - # Allocates a ``flint_rand_t`` object to be used like a heap-allocated - # ``flint_rand_t`` in external libraries. - # The random state is not initialised. - void flint_rand_free(flint_rand_s * state) noexcept - # Frees a random state object as allocated using :func:`flint_rand_alloc`. - void flint_randinit(flint_rand_t state) noexcept - # Initialize a :type:`flint_rand_t`. - void flint_randclear(flint_rand_t state) noexcept - # Free all memory allocated by :func:`flint_rand_init`. - void flint_set_num_threads(int num_threads) noexcept - # Set up a thread pool of ``num_threads - 1`` worker threads (in addition - # to the master thread) and set the maximum number of worker threads the - # master thread can start to ``num_threads - 1``. - # This function may only be called globally from the master thread. It can - # also be called at a global level to change the size of the thread pool, but - # an exception is raised if the thread pool is in use (threads have been - # woken but not given back). The function cannot be called from inside - # worker threads. - int flint_get_num_threads() noexcept - # When called at the global level, this function returns one more than the - # number of worker threads in the Flint thread pool, i.e. it returns the - # number of workers in the thread pool plus one for the master thread. - # In general, this function returns one more than the number of additional - # worker threads that can be started by the current thread. - # Use :func:`thread_pool_wake` to set this number for a given worker thread. - # See also: :func:`flint_get_num_available_threads`. - int flint_set_num_workers(int num_workers) noexcept - # Restricts the number of worker threads that can be started by the current - # thread to ``num_workers``. This function can be called from any thread. - # Assumes that the Flint thread pool is already set up. - # The function returns the old number of worker threads that can be started. - # The function can only be used to reduce the number of workers that can be - # started from a thread. It cannot be used to increase the number. If a - # higher number is passed, the function has no effect. - # The number of workers must be restored to the original value by a call to - # :func:`flint_reset_num_workers` before the thread is returned to the thread - # pool. - # The main use of this function and :func:`flint_reset_num_workers` is to cheaply - # and temporarily restrict the number of workers that can be started, e.g. by - # a function that one wishes to call from a thread, and cheaply restore the - # number of workers to its original value before exiting the current thread. - void flint_reset_num_workers(int num_workers) noexcept - # After a call to :func:`flint_set_num_workers` this function must be called to - # set the number of workers that may be started by the current thread back to - # its original value. - int flint_printf(const char * str, ...) noexcept int flint_fprintf(FILE * f, const char * str, ...) noexcept int flint_sprintf(char * s, const char * str, ...) noexcept - # These are equivalent to the standard library functions ``printf``, - # ``vprintf``, ``fprintf``, and ``sprintf`` with an additional length modifier - # "w" for use with an :type:`mp_limb_t` type. This modifier can be used with - # format specifiers "d", "x", or "u", thereby outputting the limb as a signed - # decimal, hexadecimal, or unsigned decimal integer. - int flint_scanf(const char * str, ...) noexcept int flint_fscanf(FILE * f, const char * str, ...) noexcept int flint_sscanf(const char * s, const char * str, ...) noexcept - # These are equivalent to the standard library functions ``scanf``, - # ``fscanf``, and ``sscanf`` with an additional length modifier "w" for - # reading an :type:`mp_limb_t` type. diff --git a/src/sage/libs/flint/flint_sage.pyx b/src/sage/libs/flint/flint_sage.pyx index 1c5d3f911a4..7ebbc1a7571 100644 --- a/src/sage/libs/flint/flint_sage.pyx +++ b/src/sage/libs/flint/flint_sage.pyx @@ -19,134 +19,134 @@ We verify that :trac:`6919` is correctly fixed:: """ # cimport all .pxd files to make sure they compile -from .fmpz_poly_mat cimport * -from .fmpq_mpoly cimport * -from .nmod_poly_mat cimport * -from .perm cimport * -from .nmod_vec cimport * -from .fmpzi cimport * -from .mpoly cimport * -from .mpfr_mat cimport * -from .nmod_poly cimport * -from .long_extras cimport * -from .partitions cimport * -from .fq_nmod_poly_factor cimport * -from .mpf_mat cimport * -from .fmpz_poly_q cimport * -from .ca_vec cimport * -from .double_extras cimport * -from .fq_nmod_mpoly_factor cimport * -from .fmpz_mpoly cimport * -from .fmpq_vec cimport * -from .fq_poly cimport * -from .fq_nmod_mat cimport * -from .calcium cimport * -from .fmpz_vec cimport * -from .fexpr_builtin cimport * -from .ca_poly cimport * -from .fq_embed cimport * -from .nmod_poly_factor cimport * -from .fmpz_extras cimport * +from .acb cimport * +from .acb_calc cimport * +from .acb_dft cimport * +from .acb_dirichlet cimport * +from .acb_elliptic cimport * +from .acb_hypgeom cimport * from .acb_mat cimport * -from .gr_generic cimport * -from .gr_poly cimport * -from .fq_zech_poly_factor cimport * -from .fmpz_mpoly_q cimport * -from .nmod cimport * -from .ca_mat cimport * -from .fq_zech_vec cimport * +from .acb_modular cimport * +from .acb_poly cimport * +from .acf cimport * +from .aprcl cimport * from .arb cimport * -from .nf_elem cimport * -from .fmpz_poly cimport * -from .fq_nmod_embed cimport * +from .arb_calc cimport * +from .arb_fmpz_poly cimport * +from .arb_fpwrap cimport * +from .arb_hypgeom cimport * +from .arb_mat cimport * from .arb_poly cimport * +from .arf cimport * +from .arith cimport * +from .bernoulli cimport * +from .bool_mat cimport * +from .ca cimport * +from .ca_ext cimport * +from .ca_field cimport * +from .ca_mat cimport * +from .ca_poly cimport * +from .ca_vec cimport * +from .calcium cimport * +from .d_mat cimport * +from .d_vec cimport * +from .dirichlet cimport * +from .dlog cimport * +from .double_extras cimport * +from .double_interval cimport * +from .fexpr cimport * +from .fexpr_builtin cimport * +from .fft cimport * +from .flint cimport * from .fmpq cimport * +from .fmpq_mat cimport * +from .fmpq_mpoly cimport * from .fmpq_mpoly_factor cimport * -from .acb_calc cimport * -from .fq_vec cimport * -from .padic_mat cimport * +from .fmpq_poly cimport * +from .fmpq_vec cimport * from .fmpz cimport * +from .fmpz_extras cimport * +from .fmpz_factor cimport * +from .fmpz_lll cimport * from .fmpz_mat cimport * +from .fmpz_mod cimport * from .fmpz_mod_mat cimport * -from .fq_zech cimport * -from .double_interval cimport * -from .fq_default_mat cimport * from .fmpz_mod_mpoly cimport * -from .qsieve cimport * -from .qfb cimport * -from .thread_pool cimport * from .fmpz_mod_mpoly_factor cimport * -from .acb_modular cimport * -from .fq_nmod_poly cimport * -from .profiler cimport * -from .acb_hypgeom cimport * -from .d_mat cimport * -from .fq_zech_poly cimport * -from .fmpz_mod cimport * -from .qqbar cimport * -from .hypgeom cimport * -from .acb_elliptic cimport * -from .acb_dft cimport * -from .d_vec cimport * -from .ulong_extras cimport * -from .dlog cimport * -from .bool_mat cimport * -from .fmpq_poly cimport * -from .fexpr cimport * -from .mag cimport * -from .fmpz_mpoly_factor cimport * -from .mpfr_vec cimport * -from .ca_ext cimport * -from .gr cimport * -from .acb_poly cimport * -from .fft cimport * -from .padic cimport * -from .dirichlet cimport * +from .fmpz_mod_poly cimport * from .fmpz_mod_poly_factor cimport * -from .fq_default cimport * +from .fmpz_mod_vec cimport * +from .fmpz_mpoly cimport * +from .fmpz_mpoly_factor cimport * +from .fmpz_mpoly_q cimport * +from .fmpz_poly cimport * +from .fmpz_poly_factor cimport * +from .fmpz_poly_mat cimport * +from .fmpz_poly_q cimport * +from .fmpz_vec cimport * +from .fmpzi cimport * from .fq cimport * -from .gr_vec cimport * +from .fq_default cimport * +from .fq_default_mat cimport * +from .fq_default_poly cimport * +from .fq_default_poly_factor cimport * +from .fq_embed cimport * +from .fq_mat cimport * from .fq_nmod cimport * +from .fq_nmod_embed cimport * +from .fq_nmod_mat cimport * +from .fq_nmod_mpoly cimport * +from .fq_nmod_mpoly_factor cimport * +from .fq_nmod_poly cimport * +from .fq_nmod_poly_factor cimport * +from .fq_nmod_vec cimport * +from .fq_poly cimport * +from .fq_poly_factor cimport * +from .fq_vec cimport * +from .fq_zech cimport * from .fq_zech_embed cimport * -from .nmod_mpoly_factor cimport * -from .flint cimport * -from .fmpz_factor cimport * -from .qadic cimport * -from .nf cimport * -from .gr_mpoly cimport * -from .arb_fpwrap cimport * -from .fq_default_poly cimport * -from .aprcl cimport * -from .acf cimport * -from .gr_special cimport * -from .arf cimport * from .fq_zech_mat cimport * +from .fq_zech_poly cimport * +from .fq_zech_poly_factor cimport * +from .fq_zech_vec cimport * +from .gr cimport * +from .gr_generic cimport * from .gr_mat cimport * -from .arb_fmpz_poly cimport * -from .fq_nmod_vec cimport * -from .fmpz_mod_poly cimport * -from .bernoulli cimport * -from .fq_default_poly_factor cimport * -from .arb_mat cimport * -from .arb_hypgeom cimport * -from .fq_poly_factor cimport * -from .nmod_mpoly cimport * -from .acb cimport * -from .fmpz_lll cimport * -from .fmpz_poly_factor cimport * -from .ca_field cimport * -from .acb_dirichlet cimport * -from .arith cimport * -from .fmpz_mod_vec cimport * -from .fmpq_mat cimport * -from .fq_mat cimport * -from .mpn_extras cimport * +from .gr_mpoly cimport * +from .gr_poly cimport * +from .gr_special cimport * +from .gr_vec cimport * +from .hypgeom cimport * +from .long_extras cimport * +from .mag cimport * +from .mpf_mat cimport * from .mpf_vec cimport * -from .ca cimport * -from .padic_poly cimport * +from .mpfr_mat cimport * +from .mpfr_vec cimport * +from .mpn_extras cimport * +from .mpoly cimport * +from .nf cimport * +from .nf_elem cimport * +from .nmod cimport * from .nmod_mat cimport * -from .fq_nmod_mpoly cimport * -from .arb_calc cimport * +from .nmod_mpoly cimport * +from .nmod_mpoly_factor cimport * +from .nmod_poly cimport * +from .nmod_poly_factor cimport * +from .nmod_poly_mat cimport * +from .nmod_vec cimport * +from .padic cimport * +from .padic_mat cimport * +from .padic_poly cimport * +from .partitions cimport * +from .perm cimport * +from .profiler cimport * +from .qadic cimport * +from .qfb cimport * +from .qqbar cimport * +from .qsieve cimport * +from .thread_pool cimport * +from .ulong_extras cimport * # Try to clean up after ourselves before sage terminates. This # probably doesn't do anything if your copy of flint is re-entrant diff --git a/src/sage/libs/flint/flint_wrap.h b/src/sage/libs/flint/flint_wrap.h index c3cd2b7760b..6e1655643ba 100644 --- a/src/sage/libs/flint/flint_wrap.h +++ b/src/sage/libs/flint/flint_wrap.h @@ -31,139 +31,135 @@ #define slong mp_limb_signed_t #endif -/* NOTE: calcium.h must be imported before gr.h as otherwise truth_t gets redefined - See https://github.com/flintlib/flint/issues/1653 */ -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include #include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include #include -#include -#include -#include +#include +#include +#include +#include +#include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include +#include +#include #include -#include -#include -#include +#include +#include #include +#include +#include +#include #include +#include #include -#include -#include -#include #include -#include -#include -#include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include #include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include -#include +#include +#include +#include +#include +#include +#include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include #include +#include +#include +#include +#include +#include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include #include -#include -#include +#include +#include +#include +#include +#include +#include +#include #include -#include -#include +#include +#include +#include +#include +#include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #undef ulong #undef slong diff --git a/src/sage/libs/flint/fmpq.pxd b/src/sage/libs/flint/fmpq.pxd index 89dd1058362..41f075326fe 100644 --- a/src/sage/libs/flint/fmpq.pxd +++ b/src/sage/libs/flint/fmpq.pxd @@ -2,7 +2,9 @@ # distutils: depends = flint/fmpq.h ################################################################################ -# This file is auto-generated. Do not modify by hand +# This file is auto-generated by the script +# SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py. +# Do not modify by hand! Fix and rerun the script instead. ################################################################################ from libc.stdio cimport FILE @@ -11,498 +13,125 @@ from sage.libs.mpfr.types cimport * from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - fmpz * fmpq_numref(const fmpq_t x) noexcept fmpz * fmpq_denref(const fmpq_t x) noexcept - # Returns respectively a pointer to the numerator and denominator of x. - void fmpq_init(fmpq_t x) noexcept - # Initialises the ``fmpq_t`` variable ``x`` for use. Its value - # is set to 0. - void fmpq_clear(fmpq_t x) noexcept - # Clears the ``fmpq_t`` variable ``x``. To use the variable again, - # it must be re-initialised with ``fmpq_init``. - void fmpq_canonicalise(fmpq_t res) noexcept - # Puts ``res`` in canonical form: the numerator and denominator are - # reduced to lowest terms, and the denominator is made positive. - # If the numerator is zero, the denominator is set to one. - # If the denominator is zero, the outcome of calling this function is - # undefined, regardless of the value of the numerator. - void _fmpq_canonicalise(fmpz_t num, fmpz_t den) noexcept - # Does the same thing as ``fmpq_canonicalise``, but for numerator - # and denominator given explicitly as ``fmpz_t`` variables. Aliasing - # of ``num`` and ``den`` is not allowed. - bint fmpq_is_canonical(const fmpq_t x) noexcept - # Returns nonzero if ``fmpq_t`` x is in canonical form - # (as produced by ``fmpq_canonicalise``), and zero otherwise. - bint _fmpq_is_canonical(const fmpz_t num, const fmpz_t den) noexcept - # Does the same thing as ``fmpq_is_canonical``, but for numerator - # and denominator given explicitly as ``fmpz_t`` variables. - void fmpq_set(fmpq_t dest, const fmpq_t src) noexcept - # Sets ``dest`` to a copy of ``src``. No canonicalisation - # is performed. - void fmpq_swap(fmpq_t op1, fmpq_t op2) noexcept - # Swaps the two rational numbers ``op1`` and ``op2``. - void fmpq_neg(fmpq_t dest, const fmpq_t src) noexcept - # Sets ``dest`` to the additive inverse of ``src``. - void fmpq_abs(fmpq_t dest, const fmpq_t src) noexcept - # Sets ``dest`` to the absolute value of ``src``. - void fmpq_zero(fmpq_t res) noexcept - # Sets the value of ``res`` to 0. - void fmpq_one(fmpq_t res) noexcept - # Sets the value of ``res`` to `1`. - bint fmpq_is_zero(const fmpq_t res) noexcept - # Returns nonzero if ``res`` has value 0, and returns zero otherwise. - bint fmpq_is_one(const fmpq_t res) noexcept - # Returns nonzero if ``res`` has value `1`, and returns zero otherwise. - bint fmpq_is_pm1(const fmpq_t res) noexcept - # Returns nonzero if ``res`` has value `\pm{1}` and zero otherwise. - bint fmpq_equal(const fmpq_t x, const fmpq_t y) noexcept - # Returns nonzero if ``x`` and ``y`` are equal, and zero otherwise. - # Assumes that ``x`` and ``y`` are both in canonical form. - int fmpq_sgn(const fmpq_t x) noexcept - # Returns the sign of the rational number `x`. - int fmpq_cmp(const fmpq_t x, const fmpq_t y) noexcept int fmpq_cmp_fmpz(const fmpq_t x, const fmpz_t y) noexcept int fmpq_cmp_ui(const fmpq_t x, ulong y) noexcept - # Returns negative if `x < y`, zero if `x = y`, and positive if `x > y`. - int fmpq_cmp_si(const fmpq_t x, slong y) noexcept - # Returns negative if `x < y`, zero if `x = y`, and positive if `x > y`. - bint fmpq_equal_ui(fmpq_t x, ulong y) noexcept - # Returns `1` if `x = y`, otherwise returns `0`. - bint fmpq_equal_si(fmpq_t x, slong y) noexcept - # Returns `1` if `x = y`, otherwise returns `0`. - void fmpq_height(fmpz_t height, const fmpq_t x) noexcept - # Sets ``height`` to the height of `x`, defined as the larger of - # the absolute values of the numerator and denominator of `x`. - flint_bitcnt_t fmpq_height_bits(const fmpq_t x) noexcept - # Returns the number of bits in the height of `x`. - void fmpq_set_fmpz_frac(fmpq_t res, const fmpz_t p, const fmpz_t q) noexcept - # Sets ``res`` to the canonical form of the fraction ``p / q``. - # This is equivalent to assigning the numerator and denominator - # separately and calling ``fmpq_canonicalise``. - void fmpq_get_mpz_frac(mpz_t a, mpz_t b, fmpq_t c) noexcept - # Sets ``a``, ``b`` to the numerator and denominator of ``c`` - # respectively. - void fmpq_set_si(fmpq_t res, slong p, ulong q) noexcept - # Sets ``res`` to the canonical form of the fraction ``p / q``. - void _fmpq_set_si(fmpz_t rnum, fmpz_t rden, slong p, ulong q) noexcept - # Sets ``(rnum, rden)`` to the canonical form of the fraction - # ``p / q``. ``rnum`` and ``rden`` may not be aliased. - void fmpq_set_ui(fmpq_t res, ulong p, ulong q) noexcept - # Sets ``res`` to the canonical form of the fraction ``p / q``. - void _fmpq_set_ui(fmpz_t rnum, fmpz_t rden, ulong p, ulong q) noexcept - # Sets ``(rnum, rden)`` to the canonical form of the fraction - # ``p / q``. ``rnum`` and ``rden`` may not be aliased. - void fmpq_set_mpq(fmpq_t dest, const mpq_t src) noexcept - # Sets the value of ``dest`` to that of the ``mpq_t`` variable - # ``src``. - int fmpq_set_str(fmpq_t dest, const char * s, int base) noexcept - # Sets the value of ``dest`` to the value represented in the string - # ``s`` in base ``base``. - # Returns 0 if no error occurs. Otherwise returns -1 and ``dest`` is - # set to zero. - void fmpq_init_set_mpz_frac_readonly(fmpq_t z, const mpz_t p, const mpz_t q) noexcept - # Assuming ``z`` is an ``fmpz_t`` which will not be cleaned up, - # this temporarily copies ``p`` and ``q`` into the numerator and - # denominator of ``z`` for read only operations only. The user must not - # run ``fmpq_clear`` on ``z``. - double fmpq_get_d(const fmpq_t f) noexcept - # Returns `f` as a ``double``, rounding towards zero if ``f`` cannot be represented exactly. The return is system dependent if ``f`` is too large or too small to fit in a ``double``. - void fmpq_get_mpq(mpq_t dest, const fmpq_t src) noexcept - # Sets the value of ``dest`` - int fmpq_get_mpfr(mpfr_t dest, const fmpq_t src, mpfr_rnd_t rnd) noexcept - # Sets the MPFR variable ``dest`` to the value of ``src``, - # rounded to the nearest representable binary floating-point value - # in direction ``rnd``. Returns the sign of the rounding, - # according to MPFR conventions. - # **Note:** Requires that ``mpfr.h`` has been included before any FLINT - # header is included. - char * _fmpq_get_str(char * str, int b, const fmpz_t num, const fmpz_t den) noexcept char * fmpq_get_str(char * str, int b, const fmpq_t x) noexcept - # Prints the string representation of `x` in base `b \in [2, 36]` - # to a suitable buffer. - # If ``str`` is not ``NULL``, this is used as the buffer and - # also the return value. If ``str`` is ``NULL``, allocates - # sufficient space and returns a pointer to the string. - void flint_mpq_init_set_readonly(mpq_t z, const fmpq_t f) noexcept - # Sets the uninitialised ``mpq_t`` `z` to the value of the - # readonly ``fmpq_t`` `f`. - # Note that it is assumed that `f` does not change during - # the lifetime of `z`. - # The rational `z` has to be cleared by a call to - # :func:`flint_mpq_clear_readonly`. - # The suggested use of the two functions is as follows:: - # fmpq_t f; - # ... - # { - # mpq_t z; - # flint_mpq_init_set_readonly(z, f); - # foo(..., z); - # flint_mpq_clear_readonly(z); - # } - # This provides a convenient function for user code, only - # requiring to work with the types ``fmpq_t`` and ``mpq_t``. - void flint_mpq_clear_readonly(mpq_t z) noexcept - # Clears the readonly ``mpq_t`` `z`. - void fmpq_init_set_readonly(fmpq_t f, const mpq_t z) noexcept - # Sets the uninitialised ``fmpq_t`` `f` to a readonly - # version of the rational `z`. - # Note that the value of `z` is assumed to remain constant - # throughout the lifetime of `f`. - # The ``fmpq_t`` `f` has to be cleared by calling the - # function :func:`fmpq_clear_readonly`. - # The suggested use of the two functions is as follows:: - # mpq_t z; - # ... - # { - # fmpq_t f; - # fmpq_init_set_readonly(f, z); - # foo(..., f); - # fmpq_clear_readonly(f); - # } - void fmpq_clear_readonly(fmpq_t f) noexcept - # Clears the readonly ``fmpq_t`` `f`. - int fmpq_fprint(FILE * file, const fmpq_t x) noexcept - # Prints ``x`` as a fraction to the stream ``file``. - # The numerator and denominator are printed verbatim as integers, - # with a forward slash (/) printed in between. - # In case of success, returns a positive number. In case of failure, - # returns a non-positive number. - int _fmpq_fprint(FILE * file, const fmpz_t num, const fmpz_t den) noexcept - # Does the same thing as ``fmpq_fprint``, but for numerator - # and denominator given explicitly as ``fmpz_t`` variables. - # In case of success, returns a positive number. In case of failure, - # returns a non-positive number. - int fmpq_print(const fmpq_t x) noexcept - # Prints ``x`` as a fraction. The numerator and denominator are - # printed verbatim as integers, with a forward slash (/) printed in - # between. - # In case of success, returns a positive number. In case of failure, - # returns a non-positive number. - int _fmpq_print(const fmpz_t num, const fmpz_t den) noexcept - # Does the same thing as ``fmpq_print``, but for numerator - # and denominator given explicitly as ``fmpz_t`` variables. - # In case of success, returns a positive number. In case of failure, - # returns a non-positive number. - void fmpq_randtest(fmpq_t res, flint_rand_t state, flint_bitcnt_t bits) noexcept - # Sets ``res`` to a random value, with numerator and denominator - # having up to ``bits`` bits. The fraction will be in canonical - # form. This function has an increased probability of generating - # special values which are likely to trigger corner cases. - void _fmpq_randtest(fmpz_t num, fmpz_t den, flint_rand_t state, flint_bitcnt_t bits) noexcept - # Does the same thing as ``fmpq_randtest``, but for numerator - # and denominator given explicitly as ``fmpz_t`` variables. Aliasing - # of ``num`` and ``den`` is not allowed. - void fmpq_randtest_not_zero(fmpq_t res, flint_rand_t state, flint_bitcnt_t bits) noexcept - # As per ``fmpq_randtest``, but the result will not be `0`. - # If ``bits`` is set to `0`, an exception will result. - void fmpq_randbits(fmpq_t res, flint_rand_t state, flint_bitcnt_t bits) noexcept - # Sets ``res`` to a random value, with numerator and denominator - # both having exactly ``bits`` bits before canonicalisation, - # and then puts ``res`` in canonical form. Note that as a result - # of the canonicalisation, the resulting numerator and denominator can - # be slightly smaller than ``bits`` bits. - void _fmpq_randbits(fmpz_t num, fmpz_t den, flint_rand_t state, flint_bitcnt_t bits) noexcept - # Does the same thing as ``fmpq_randbits``, but for numerator - # and denominator given explicitly as ``fmpz_t`` variables. Aliasing - # of ``num`` and ``den`` is not allowed. - void fmpq_add(fmpq_t res, const fmpq_t op1, const fmpq_t op2) noexcept void fmpq_sub(fmpq_t res, const fmpq_t op1, const fmpq_t op2) noexcept void fmpq_mul(fmpq_t res, const fmpq_t op1, const fmpq_t op2) noexcept void fmpq_div(fmpq_t res, const fmpq_t op1, const fmpq_t op2) noexcept - # Sets ``res`` respectively to ``op1 + op2``, ``op1 - op2``, - # ``op1 * op2``, or ``op1 / op2``. Assumes that the inputs - # are in canonical form, and produces output in canonical form. - # Division by zero results in an error. - # Aliasing between any combination of the variables is allowed. - void _fmpq_add(fmpz_t rnum, fmpz_t rden, const fmpz_t op1num, const fmpz_t op1den, const fmpz_t op2num, const fmpz_t op2den) noexcept void _fmpq_sub(fmpz_t rnum, fmpz_t rden, const fmpz_t op1num, const fmpz_t op1den, const fmpz_t op2num, const fmpz_t op2den) noexcept void _fmpq_mul(fmpz_t rnum, fmpz_t rden, const fmpz_t op1num, const fmpz_t op1den, const fmpz_t op2num, const fmpz_t op2den) noexcept void _fmpq_div(fmpz_t rnum, fmpz_t rden, const fmpz_t op1num, const fmpz_t op1den, const fmpz_t op2num, const fmpz_t op2den) noexcept - # Sets ``(rnum, rden)`` to the canonical form of the sum, - # difference, product or quotient respectively of the fractions - # represented by ``(op1num, op1den)`` and ``(op2num, op2den)``. - # Aliasing between any combination of the variables is allowed, - # whilst no numerator is aliased with a denominator. - void _fmpq_add_si(fmpz_t rnum, fmpz_t rden, const fmpz_t p, const fmpz_t q, slong r) noexcept void _fmpq_sub_si(fmpz_t rnum, fmpz_t rden, const fmpz_t p, const fmpz_t q, slong r) noexcept void _fmpq_add_ui(fmpz_t rnum, fmpz_t rden, const fmpz_t p, const fmpz_t q, ulong r) noexcept void _fmpq_sub_ui(fmpz_t rnum, fmpz_t rden, const fmpz_t p, const fmpz_t q, ulong r) noexcept void _fmpq_add_fmpz(fmpz_t rnum, fmpz_t rden, const fmpz_t p, const fmpz_t q, const fmpz_t r) noexcept void _fmpq_sub_fmpz(fmpz_t rnum, fmpz_t rden, const fmpz_t p, const fmpz_t q, const fmpz_t r) noexcept - # Sets ``(rnum, rden)`` to the canonical form of the sum or difference - # respectively of the fractions represented by ``(p, q)`` and - # ``(r, 1)``. Numerators may not be aliased with denominators. - void fmpq_add_si(fmpq_t res, const fmpq_t op1, slong c) noexcept void fmpq_sub_si(fmpq_t res, const fmpq_t op1, slong c) noexcept void fmpq_add_ui(fmpq_t res, const fmpq_t op1, ulong c) noexcept void fmpq_sub_ui(fmpq_t res, const fmpq_t op1, ulong c) noexcept void fmpq_add_fmpz(fmpq_t res, const fmpq_t op1, const fmpz_t c) noexcept void fmpq_sub_fmpz(fmpq_t res, const fmpq_t op1, const fmpz_t c) noexcept - void _fmpq_mul_si(fmpz_t rnum, fmpz_t rden, const fmpz_t p, const fmpz_t q, slong r) noexcept - void fmpq_mul_si(fmpq_t res, const fmpq_t op1, slong c) noexcept - void _fmpq_mul_ui(fmpz_t rnum, fmpz_t rden, const fmpz_t p, const fmpz_t q, ulong r) noexcept - void fmpq_mul_ui(fmpq_t res, const fmpq_t op1, ulong c) noexcept - void fmpq_addmul(fmpq_t res, const fmpq_t op1, const fmpq_t op2) noexcept void fmpq_submul(fmpq_t res, const fmpq_t op1, const fmpq_t op2) noexcept - # Sets ``res`` to ``res + op1 * op2`` or ``res - op1 * op2`` - # respectively, placing the result in canonical form. Aliasing - # between any combination of the variables is allowed. - void _fmpq_addmul(fmpz_t rnum, fmpz_t rden, const fmpz_t op1num, const fmpz_t op1den, const fmpz_t op2num, const fmpz_t op2den) noexcept void _fmpq_submul(fmpz_t rnum, fmpz_t rden, const fmpz_t op1num, const fmpz_t op1den, const fmpz_t op2num, const fmpz_t op2den) noexcept - # Sets ``(rnum, rden)`` to the canonical form of the fraction - # ``(rnum, rden)`` + ``(op1num, op1den)`` * ``(op2num, op2den)`` or - # ``(rnum, rden)`` - ``(op1num, op1den)`` * ``(op2num, op2den)`` - # respectively. Aliasing between any combination of the variables is allowed, - # whilst no numerator is aliased with a denominator. - void fmpq_inv(fmpq_t dest, const fmpq_t src) noexcept - # Sets ``dest`` to ``1 / src``. The result is placed in canonical - # form, assuming that ``src`` is already in canonical form. - void _fmpq_pow_si(fmpz_t rnum, fmpz_t rden, const fmpz_t opnum, const fmpz_t opden, slong e) noexcept void fmpq_pow_si(fmpq_t res, const fmpq_t op, slong e) noexcept - # Sets ``res`` to ``op`` raised to the power `e`, where `e` - # is a ``slong``. If `e` is `0` and ``op`` is `0`, then - # ``res`` will be set to `1`. - int fmpq_pow_fmpz(fmpq_t a, const fmpq_t b, const fmpz_t e) noexcept - # Set ``res`` to ``op`` raised to the power `e`. - # Return `1` for success and `0` for failure. - void fmpq_mul_fmpz(fmpq_t res, const fmpq_t op, const fmpz_t x) noexcept - # Sets ``res`` to the product of the rational number ``op`` - # and the integer ``x``. - void fmpq_div_fmpz(fmpq_t res, const fmpq_t op, const fmpz_t x) noexcept - # Sets ``res`` to the quotient of the rational number ``op`` - # and the integer ``x``. - void fmpq_mul_2exp(fmpq_t res, const fmpq_t x, flint_bitcnt_t exp) noexcept - # Sets ``res`` to ``x`` multiplied by ``2^exp``. - void fmpq_div_2exp(fmpq_t res, const fmpq_t x, flint_bitcnt_t exp) noexcept - # Sets ``res`` to ``x`` divided by ``2^exp``. - void _fmpq_gcd(fmpz_t rnum, fmpz_t rden, const fmpz_t p, const fmpz_t q, const fmpz_t r, const fmpz_t s) noexcept - # Set ``(rnum, rden)`` to the gcd of ``(p, q)`` and ``(r, s)`` - # which we define to be the canonicalisation of `\operatorname{gcd}(ps, qr)/(qs)`. - # (This is apparently Euclid's original definition and is stable under scaling of - # numerator and denominator. It also agrees with the gcd on the integers. - # Note that it does not agree with gcd as defined in ``fmpq_poly``.) - # This definition agrees with the result as output by Sage and Pari/GP. - void fmpq_gcd(fmpq_t res, const fmpq_t op1, const fmpq_t op2) noexcept - # Set ``res`` to the gcd of ``op1`` and ``op2``. See the low - # level function ``_fmpq_gcd`` for our definition of gcd. - void _fmpq_gcd_cofactors(fmpz_t gnum, fmpz_t gden, fmpz_t abar, fmpz_t bbar, const fmpz_t anum, const fmpz_t aden, const fmpz_t bnum, const fmpz_t bden) noexcept void fmpq_gcd_cofactors(fmpq_t g, fmpz_t abar, fmpz_t bbar, const fmpq_t a, const fmpq_t b) noexcept - # Set `g` to `\operatorname{gcd}(a,b)` as per :func:`fmpq_gcd` and also compute `\overline{a} = a/g` and `\overline{b} = b/g`. - # Unlike :func:`fmpq_gcd`, this function requires canonical inputs. - void _fmpq_add_small(fmpz_t rnum, fmpz_t rden, slong p1, ulong q1, slong p2, ulong q2) noexcept - # Sets ``(rnum, rden)`` to the sum of ``(p1, q1)`` and ``(p2, q2)``. - # Assumes that ``(p1, q1)`` and ``(p2, q2)`` are in canonical form - # and that all inputs are between ``COEFF_MIN`` and ``COEFF_MAX``. - void _fmpq_mul_small(fmpz_t rnum, fmpz_t rden, slong p1, ulong q1, slong p2, ulong q2) noexcept - # Sets ``(rnum, rden)`` to the product of ``(p1, q1)`` and ``(p2, q2)``. - # Assumes that ``(p1, q1)`` and ``(p2, q2)`` are in canonical form - # and that all inputs are between ``COEFF_MIN`` and ``COEFF_MAX``. - int _fmpq_mod_fmpz(fmpz_t res, const fmpz_t num, const fmpz_t den, const fmpz_t mod) noexcept int fmpq_mod_fmpz(fmpz_t res, const fmpq_t x, const fmpz_t mod) noexcept - # Sets the integer ``res`` to the residue `a` of - # `x = n/d` = ``(num, den)`` modulo the positive integer `m` = ``mod``, - # defined as the `0 \le a < m` satisfying `n \equiv a d \pmod m`. - # If such an `a` exists, 1 will be returned, otherwise 0 will - # be returned. - int _fmpq_reconstruct_fmpz_2_naive(fmpz_t n, fmpz_t d, const fmpz_t a, const fmpz_t m, const fmpz_t N, const fmpz_t D) noexcept int _fmpq_reconstruct_fmpz_2(fmpz_t n, fmpz_t d, const fmpz_t a, const fmpz_t m, const fmpz_t N, const fmpz_t D) noexcept int fmpq_reconstruct_fmpz_2(fmpq_t res, const fmpz_t a, const fmpz_t m, const fmpz_t N, const fmpz_t D) noexcept - # Reconstructs a rational number from its residue `a` modulo `m`. - # Given a modulus `m > 2`, a residue `0 \le a < m`, and positive `N, D` - # satisfying `2ND < m`, this function attempts to find a fraction `n/d` with - # `0 \le |n| \le N` and `0 < d \le D` such that `\gcd(n,d) = 1` and - # `n \equiv ad \pmod m`. If a solution exists, then it is also unique. - # The function returns 1 if successful, and 0 to indicate that no solution - # exists. - int _fmpq_reconstruct_fmpz(fmpz_t n, fmpz_t d, const fmpz_t a, const fmpz_t m) noexcept int fmpq_reconstruct_fmpz(fmpq_t res, const fmpz_t a, const fmpz_t m) noexcept - # Reconstructs a rational number from its residue `a` modulo `m`, - # returning 1 if successful and 0 if no solution exists. - # Uses the balanced bounds `N = D = \lfloor\sqrt{\frac{m-1}{2}}\rfloor`. - void _fmpq_next_minimal(fmpz_t rnum, fmpz_t rden, const fmpz_t num, const fmpz_t den) noexcept void fmpq_next_minimal(fmpq_t res, const fmpq_t x) noexcept - # Given `x` which is assumed to be nonnegative and in canonical form, sets - # ``res`` to the next rational number in the sequence obtained by - # enumerating all positive denominators `q`, for each `q` enumerating - # the numerators `1 \le p < q` in order and generating both `p/q` and `q/p`, - # but skipping all `\gcd(p,q) \ne 1`. Starting with zero, this generates - # every nonnegative rational number once and only once, with the first - # few entries being: - # `0, 1, 1/2, 2, 1/3, 3, 2/3, 3/2, 1/4, 4, 3/4, 4/3, 1/5, 5, 2/5, \ldots.` - # This enumeration produces the rational numbers in order of - # minimal height. It has the disadvantage of being somewhat slower to - # compute than the Calkin-Wilf enumeration. - void _fmpq_next_signed_minimal(fmpz_t rnum, fmpz_t rden, const fmpz_t num, const fmpz_t den) noexcept void fmpq_next_signed_minimal(fmpq_t res, const fmpq_t x) noexcept - # Given a signed rational number `x` assumed to be in canonical form, sets - # ``res`` to the next element in the minimal-height sequence - # generated by ``fmpq_next_minimal`` but with negative numbers - # interleaved: - # `0, 1, -1, 1/2, -1/2, 2, -2, 1/3, -1/3, \ldots.` - # Starting with zero, this generates every rational number once - # and only once, in order of minimal height. - void _fmpq_next_calkin_wilf(fmpz_t rnum, fmpz_t rden, const fmpz_t num, const fmpz_t den) noexcept void fmpq_next_calkin_wilf(fmpq_t res, const fmpq_t x) noexcept - # Given `x` which is assumed to be nonnegative and in canonical form, sets - # ``res`` to the next number in the breadth-first traversal of the - # Calkin-Wilf tree. Starting with zero, this generates every nonnegative - # rational number once and only once, with the first few entries being: - # `0, 1, 1/2, 2, 1/3, 3/2, 2/3, 3, 1/4, 4/3, 3/5, 5/2, 2/5, \ldots.` - # Despite the appearance of the initial entries, the Calkin-Wilf - # enumeration does not produce the rational numbers in order of height: - # some small fractions will appear late in the sequence. This order - # has the advantage of being faster to produce than the minimal-height - # order. - void _fmpq_next_signed_calkin_wilf(fmpz_t rnum, fmpz_t rden, const fmpz_t num, const fmpz_t den) noexcept void fmpq_next_signed_calkin_wilf(fmpq_t res, const fmpq_t x) noexcept - # Given a signed rational number `x` assumed to be in canonical form, sets - # ``res`` to the next element in the Calkin-Wilf sequence with - # negative numbers interleaved: - # `0, 1, -1, 1/2, -1/2, 2, -2, 1/3, -1/3, \ldots.` - # Starting with zero, this generates every rational number once - # and only once, but not in order of minimal height. - void fmpq_farey_neighbors(fmpq_t l, fmpq_t r, const fmpq_t x, const fmpz_t Q) noexcept - # Set `l` and `r` to the fractions directly below and above `x` in the Farey sequence of order `Q`. - # This function will throw if `x` is not canonical or `Q` is less than the denominator of `x`. - void fmpq_simplest_between(fmpq_t x, const fmpq_t l, const fmpq_t r) noexcept void _fmpq_simplest_between(fmpz_t x_num, fmpz_t x_den, const fmpz_t l_num, const fmpz_t l_den, const fmpz_t r_num, const fmpz_t r_den) noexcept - # Set `x` to the simplest fraction in the closed interval `[l, r]`. The underscore version makes the additional assumption that `l \le r`. - # The endpoints `l` and `r` do not need to be reduced, but their denominators do need to be positive. - # `x` will always be returned in canonical form. A canonical fraction `a_1/b_1` is defined to be simpler than `a_2/b_2` iff `b_1 0`), ``rem`` will finite and the return is `0 < k \le n`. - # Essentially, if this function is called with canonical `x` and `n > 0`, then ``rem`` will be canonical. - # Therefore, applications relying on canonical ``fmpq_t``'s should not call this function with `n \le 0`. - void fmpq_set_cfrac(fmpq_t x, const fmpz * c, slong n) noexcept - # Sets `x` to the value of the continued fraction - # .. math :: - # x = c_0 + \cfrac{1}{c_1 + \cfrac{1}{c_2 + - # \cfrac{1}{ \ddots + \cfrac{1}{c_{n-1}}}}} - # where all `c_i` except `c_0` should be nonnegative. - # It is assumed that `n > 0`. - # For large `n`, this function implements a subquadratic algorithm. - # The convergents are given by a chain product of 2 by 2 matrices. - # This product is split in half recursively to balance the size - # of the coefficients. - slong fmpq_cfrac_bound(const fmpq_t x) noexcept - # Returns an upper bound for the number of terms in the continued - # fraction expansion of `x`. The computed bound is not necessarily sharp. - # We use the fact that the smallest denominator - # that can give a continued fraction of length `n` is the Fibonacci - # number `F_{n+1}`. - void _fmpq_harmonic_ui(fmpz_t num, fmpz_t den, ulong n) noexcept void fmpq_harmonic_ui(fmpq_t x, ulong n) noexcept - # Computes the harmonic number `H_n = 1 + 1/2 + 1/3 + \dotsb + 1/n`. - # Table lookup is used for `H_n` whose numerator and denominator - # fit in single limb. For larger `n`, a divide and conquer strategy is used. - void fmpq_dedekind_sum(fmpq_t s, const fmpz_t h, const fmpz_t k) noexcept void fmpq_dedekind_sum_naive(fmpq_t s, const fmpz_t h, const fmpz_t k) noexcept - # Computes `s(h,k)` for arbitrary `h` and `k`. The naive version uses a straightforward - # implementation of the defining sum using ``fmpz`` arithmetic and is slow for large `k`. diff --git a/src/sage/libs/flint/fmpq_mat.pxd b/src/sage/libs/flint/fmpq_mat.pxd index 7d00c54b7b7..0227b8523a6 100644 --- a/src/sage/libs/flint/fmpq_mat.pxd +++ b/src/sage/libs/flint/fmpq_mat.pxd @@ -2,7 +2,9 @@ # distutils: depends = flint/fmpq_mat.h ################################################################################ -# This file is auto-generated. Do not modify by hand +# This file is auto-generated by the script +# SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py. +# Do not modify by hand! Fix and rerun the script instead. ################################################################################ from libc.stdio cimport FILE @@ -11,378 +13,91 @@ from sage.libs.mpfr.types cimport * from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void fmpq_mat_init(fmpq_mat_t mat, slong rows, slong cols) noexcept - # Initialises a matrix with the given number of rows and columns for use. - void fmpq_mat_init_set(fmpq_mat_t mat1, const fmpq_mat_t mat2) noexcept - # Initialises ``mat1`` and sets it equal to ``mat2``. - void fmpq_mat_clear(fmpq_mat_t mat) noexcept - # Frees all memory associated with the matrix. The matrix must be - # reinitialised if it is to be used again. - void fmpq_mat_swap(fmpq_mat_t mat1, fmpq_mat_t mat2) noexcept - # Swaps two matrices. The dimensions of ``mat1`` and ``mat2`` - # are allowed to be different. - void fmpq_mat_swap_entrywise(fmpq_mat_t mat1, fmpq_mat_t mat2) noexcept - # Swaps two matrices by swapping the individual entries rather than swapping - # the contents of the structs. - fmpq * fmpq_mat_entry(const fmpq_mat_t mat, slong i, slong j) noexcept - # Gives a reference to the entry at row ``i`` and column ``j``. - # The reference can be passed as an input or output variable to any - # ``fmpq`` function for direct manipulation of the matrix element. - # No bounds checking is performed. - fmpz * fmpq_mat_entry_num(const fmpq_mat_t mat, slong i, slong j) noexcept - # Gives a reference to the numerator of the entry at row ``i`` and - # column ``j``. The reference can be passed as an input or output - # variable to any ``fmpz`` function for direct manipulation of the - # matrix element. No bounds checking is performed. - fmpz * fmpq_mat_entry_den(const fmpq_mat_t mat, slong i, slong j) noexcept - # Gives a reference to the denominator of the entry at row ``i`` and - # column ``j``. The reference can be passed as an input or output - # variable to any ``fmpz`` function for direct manipulation of the - # matrix element. No bounds checking is performed. - slong fmpq_mat_nrows(const fmpq_mat_t mat) noexcept - # Return the number of rows of the matrix ``mat``. - slong fmpq_mat_ncols(const fmpq_mat_t mat) noexcept - # Return the number of columns of the matrix ``mat``. - void fmpq_mat_set(fmpq_mat_t dest, const fmpq_mat_t src) noexcept - # Sets the entries in ``dest`` to the same values as in ``src``, - # assuming the two matrices have the same dimensions. - void fmpq_mat_zero(fmpq_mat_t mat) noexcept - # Sets ``mat`` to the zero matrix. - void fmpq_mat_one(fmpq_mat_t mat) noexcept - # Let `m` be the minimum of the number of rows and columns - # in the matrix ``mat``. This function sets the first - # `m \times m` block to the identity matrix, and the remaining - # block to zero. - void fmpq_mat_transpose(fmpq_mat_t rop, const fmpq_mat_t op) noexcept - # Sets the matrix ``rop`` to the transpose of the matrix ``op``, - # assuming that their dimensions are compatible. - void fmpq_mat_swap_rows(fmpq_mat_t mat, slong * perm, slong r, slong s) noexcept - # Swaps rows ``r`` and ``s`` of ``mat``. If ``perm`` is non-``NULL``, the - # permutation of the rows will also be applied to ``perm``. - void fmpq_mat_swap_cols(fmpq_mat_t mat, slong * perm, slong r, slong s) noexcept - # Swaps columns ``r`` and ``s`` of ``mat``. If ``perm`` is non-``NULL``, the - # permutation of the columns will also be applied to ``perm``. - void fmpq_mat_invert_rows(fmpq_mat_t mat, slong * perm) noexcept - # Swaps rows ``i`` and ``r - i`` of ``mat`` for ``0 <= i < r/2``, where - # ``r`` is the number of rows of ``mat``. If ``perm`` is non-``NULL``, the - # permutation of the rows will also be applied to ``perm``. - void fmpq_mat_invert_cols(fmpq_mat_t mat, slong * perm) noexcept - # Swaps columns ``i`` and ``c - i`` of ``mat`` for ``0 <= i < c/2``, where - # ``c`` is the number of columns of ``mat``. If ``perm`` is non-``NULL``, the - # permutation of the columns will also be applied to ``perm``. - void fmpq_mat_add(fmpq_mat_t mat, const fmpq_mat_t mat1, const fmpq_mat_t mat2) noexcept - # Sets ``mat`` to the sum of ``mat1`` and ``mat2``, - # assuming that all three matrices have the same dimensions. - void fmpq_mat_sub(fmpq_mat_t mat, const fmpq_mat_t mat1, const fmpq_mat_t mat2) noexcept - # Sets ``mat`` to the difference of ``mat1`` and ``mat2``, - # assuming that all three matrices have the same dimensions. - void fmpq_mat_neg(fmpq_mat_t rop, const fmpq_mat_t op) noexcept - # Sets ``rop`` to the negative of ``op``, assuming that - # the two matrices have the same dimensions. - void fmpq_mat_scalar_mul_fmpq(fmpq_mat_t rop, const fmpq_mat_t op, const fmpq_t x) noexcept - # Sets ``rop`` to ``op`` multiplied by the rational `x`, - # assuming that the two matrices have the same dimensions. - # Note that the rational ``x`` may not be aliased with any part of the - # entries of ``rop``. - void fmpq_mat_scalar_mul_fmpz(fmpq_mat_t rop, const fmpq_mat_t op, const fmpz_t x) noexcept - # Sets ``rop`` to ``op`` multiplied by the integer `x`, - # assuming that the two matrices have the same dimensions. - # Note that the integer `x` may not be aliased with any part of - # the entries of ``rop``. - void fmpq_mat_scalar_div_fmpz(fmpq_mat_t rop, const fmpq_mat_t op, const fmpz_t x) noexcept - # Sets ``rop`` to ``op`` divided by the integer `x`, - # assuming that the two matrices have the same dimensions - # and that `x` is non-zero. - # Note that the integer `x` may not be aliased with any part of - # the entries of ``rop``. - void fmpq_mat_print(const fmpq_mat_t mat) noexcept - # Prints the matrix ``mat`` to standard output. - void fmpq_mat_randbits(fmpq_mat_t mat, flint_rand_t state, flint_bitcnt_t bits) noexcept - # This is equivalent to applying ``fmpq_randbits`` to all entries - # in the matrix. - void fmpq_mat_randtest(fmpq_mat_t mat, flint_rand_t state, flint_bitcnt_t bits) noexcept - # This is equivalent to applying ``fmpq_randtest`` to all entries - # in the matrix. - void fmpq_mat_window_init(fmpq_mat_t window, const fmpq_mat_t mat, slong r1, slong c1, slong r2, slong c2) noexcept - # Initializes the matrix ``window`` to be an ``r2 - r1`` by - # ``c2 - c1`` submatrix of ``mat`` whose ``(0,0)`` entry - # is the ``(r1, c1)`` entry of ``mat``. The memory for the - # elements of ``window`` is shared with ``mat``. - void fmpq_mat_window_clear(fmpq_mat_t window) noexcept - # Clears the matrix ``window`` and releases any memory that it - # uses. Note that the memory to the underlying matrix that - # ``window`` points to is not freed. - void fmpq_mat_concat_vertical(fmpq_mat_t res, const fmpq_mat_t mat1, const fmpq_mat_t mat2) noexcept - # Sets ``res`` to vertical concatenation of (``mat1``, ``mat2``) in that order. Matrix dimensions: ``mat1``: `m \times n`, ``mat2``: `k \times n`, ``res``: `(m + k) \times n`. - void fmpq_mat_concat_horizontal(fmpq_mat_t res, const fmpq_mat_t mat1, const fmpq_mat_t mat2) noexcept - # Sets ``res`` to horizontal concatenation of (``mat1``, ``mat2``) in that order. Matrix dimensions: ``mat1``: `m \times n`, ``mat2``: `m \times k`, ``res``: `m \times (n + k)`. - void fmpq_mat_hilbert_matrix(fmpq_mat_t mat) noexcept - # Sets ``mat`` to a Hilbert matrix of the given size. That is, - # the entry at row `i` and column `j` is set to `1/(i+j+1)`. - bint fmpq_mat_equal(const fmpq_mat_t mat1, const fmpq_mat_t mat2) noexcept - # Returns nonzero if ``mat1`` and ``mat2`` have the same shape and - # all their entries agree, and returns zero otherwise. Assumes the - # entries in both ``mat1`` and ``mat2`` are in canonical form. - bint fmpq_mat_is_integral(const fmpq_mat_t mat) noexcept - # Returns nonzero if all entries in ``mat`` are integer-valued, and - # returns zero otherwise. Assumes that the entries in ``mat`` - # are in canonical form. - bint fmpq_mat_is_zero(const fmpq_mat_t mat) noexcept - # Returns nonzero if all entries in ``mat`` are zero, and returns - # zero otherwise. - bint fmpq_mat_is_one(const fmpq_mat_t mat) noexcept - # Returns nonzero if ``mat`` ones along the diagonal and zeros elsewhere, - # and returns zero otherwise. - bint fmpq_mat_is_empty(const fmpq_mat_t mat) noexcept - # Returns a non-zero value if the number of rows or the number of - # columns in ``mat`` is zero, and otherwise returns - # zero. - bint fmpq_mat_is_square(const fmpq_mat_t mat) noexcept - # Returns a non-zero value if the number of rows is equal to the - # number of columns in ``mat``, and otherwise returns zero. - int fmpq_mat_get_fmpz_mat(fmpz_mat_t dest, const fmpq_mat_t mat) noexcept - # Sets ``dest`` to ``mat`` and returns nonzero if all entries - # in ``mat`` are integer-valued. If not all entries in ``mat`` - # are integer-valued, sets ``dest`` to an undefined matrix - # and returns zero. Assumes that the entries in ``mat`` are - # in canonical form. - void fmpq_mat_get_fmpz_mat_entrywise(fmpz_mat_t num, fmpz_mat_t den, const fmpq_mat_t mat) noexcept - # Sets the integer matrices ``num`` and ``den`` respectively - # to the numerators and denominators of the entries in ``mat``. - void fmpq_mat_get_fmpz_mat_matwise(fmpz_mat_t num, fmpz_t den, const fmpq_mat_t mat) noexcept - # Converts all entries in ``mat`` to a common denominator, - # storing the rescaled numerators in ``num`` and the - # denominator in ``den``. The denominator will be minimal - # if the entries in ``mat`` are in canonical form. - void fmpq_mat_get_fmpz_mat_rowwise(fmpz_mat_t num, fmpz * den, const fmpq_mat_t mat) noexcept - # Clears denominators in ``mat`` row by row. The rescaled - # numerators are written to ``num``, and the denominator - # of row ``i`` is written to position ``i`` in ``den`` - # which can be a preinitialised ``fmpz`` vector. Alternatively, - # ``NULL`` can be passed as the ``den`` variable, in which - # case the denominators will not be stored. - void fmpq_mat_get_fmpz_mat_rowwise_2(fmpz_mat_t num, fmpz_mat_t num2, fmpz * den, const fmpq_mat_t mat, const fmpq_mat_t mat2) noexcept - # Clears denominators row by row of both ``mat`` and ``mat2``, - # writing the respective numerators to ``num`` and ``num2``. - # This is equivalent to concatenating ``mat`` and ``mat2`` - # horizontally, calling ``fmpq_mat_get_fmpz_mat_rowwise``, - # and extracting the two submatrices in the result. - void fmpq_mat_get_fmpz_mat_colwise(fmpz_mat_t num, fmpz * den, const fmpq_mat_t mat) noexcept - # Clears denominators in ``mat`` column by column. The rescaled - # numerators are written to ``num``, and the denominator - # of column ``i`` is written to position ``i`` in ``den`` - # which can be a preinitialised ``fmpz`` vector. Alternatively, - # ``NULL`` can be passed as the ``den`` variable, in which - # case the denominators will not be stored. - void fmpq_mat_set_fmpz_mat(fmpq_mat_t dest, const fmpz_mat_t src) noexcept - # Sets ``dest`` to ``src``. - void fmpq_mat_set_fmpz_mat_div_fmpz(fmpq_mat_t mat, const fmpz_mat_t num, const fmpz_t den) noexcept - # Sets ``mat`` to the integer matrix ``num`` divided by the - # common denominator ``den``. - void fmpq_mat_get_fmpz_mat_mod_fmpz(fmpz_mat_t dest, const fmpq_mat_t mat, const fmpz_t mod) noexcept - # Sets each entry in ``dest`` to the corresponding entry in ``mat``, - # reduced modulo ``mod``. - int fmpq_mat_set_fmpz_mat_mod_fmpz(fmpq_mat_t X, const fmpz_mat_t Xmod, const fmpz_t mod) noexcept - # Sets ``X`` to the entrywise rational reconstruction integer matrix - # ``Xmod`` modulo ``mod``, and returns nonzero if the reconstruction - # is successful. If rational reconstruction fails for any element, - # returns zero and sets the entries in ``X`` to undefined values. - void fmpq_mat_mul_direct(fmpq_mat_t C, const fmpq_mat_t A, const fmpq_mat_t B) noexcept - # Sets ``C`` to the matrix product ``AB``, computed - # naively using rational arithmetic. This is typically very slow and - # should only be used in circumstances where clearing denominators - # would consume too much memory. - void fmpq_mat_mul_cleared(fmpq_mat_t C, const fmpq_mat_t A, const fmpq_mat_t B) noexcept - # Sets ``C`` to the matrix product ``AB``, computed - # by clearing denominators and multiplying over the integers. - void fmpq_mat_mul(fmpq_mat_t C, const fmpq_mat_t A, const fmpq_mat_t B) noexcept - # Sets ``C`` to the matrix product ``AB``. This - # simply calls ``fmpq_mat_mul_cleared``. - void fmpq_mat_mul_fmpz_mat(fmpq_mat_t C, const fmpq_mat_t A, const fmpz_mat_t B) noexcept - # Sets ``C`` to the matrix product ``AB``, with ``B`` - # an integer matrix. This function works efficiently by clearing - # denominators of ``A``. - void fmpq_mat_mul_r_fmpz_mat(fmpq_mat_t C, const fmpz_mat_t A, const fmpq_mat_t B) noexcept - # Sets ``C`` to the matrix product ``AB``, with ``A`` - # an integer matrix. This function works efficiently by clearing - # denominators of ``B``. - void fmpq_mat_mul_fmpq_vec(fmpq * c, const fmpq_mat_t A, const fmpq * b, slong blen) noexcept void fmpq_mat_mul_fmpz_vec(fmpq * c, const fmpq_mat_t A, const fmpz * b, slong blen) noexcept void fmpq_mat_mul_fmpq_vec_ptr(fmpq * const * c, const fmpq_mat_t A, const fmpq * const * b, slong blen) noexcept void fmpq_mat_mul_fmpz_vec_ptr(fmpq * const * c, const fmpq_mat_t A, const fmpz * const * b, slong blen) noexcept - # Compute a matrix-vector product of ``A`` and ``(b, blen)`` and store the result in ``c``. - # The vector ``(b, blen)`` is either truncated or zero-extended to the number of columns of ``A``. - # The number entries written to ``c`` is always equal to the number of rows of ``A``. - void fmpq_mat_fmpq_vec_mul(fmpq * c, const fmpq * a, slong alen, const fmpq_mat_t B) noexcept void fmpq_mat_fmpz_vec_mul(fmpq * c, const fmpz * a, slong alen, const fmpq_mat_t B) noexcept void fmpq_mat_fmpq_vec_mul_ptr(fmpq * const * c, const fmpq * const * a, slong alen, const fmpq_mat_t B) noexcept void fmpq_mat_fmpz_vec_mul_ptr(fmpq * const * c, const fmpz * const * a, slong alen, const fmpq_mat_t B) noexcept - # Compute a vector-matrix product of ``(a, alen)`` and ``B`` and and store the result in ``c``. - # The vector ``(a, alen)`` is either truncated or zero-extended to the number of rows of ``B``. - # The number entries written to ``c`` is always equal to the number of columns of ``B``. - void fmpq_mat_kronecker_product(fmpq_mat_t C, const fmpq_mat_t A, const fmpq_mat_t B) noexcept - # Sets ``C`` to the Kronecker product of ``A`` and ``B``. - void fmpq_mat_trace(fmpq_t trace, const fmpq_mat_t mat) noexcept - # Computes the trace of the matrix, i.e. the sum of the entries on - # the main diagonal. The matrix is required to be square. - void fmpq_mat_det(fmpq_t det, const fmpq_mat_t mat) noexcept - # Sets ``det`` to the determinant of ``mat``. In the general case, - # the determinant is computed by clearing denominators and computing a - # determinant over the integers. Matrices of size 0, 1 or 2 are handled - # directly. - int fmpq_mat_solve_fraction_free(fmpq_mat_t X, const fmpq_mat_t A, const fmpq_mat_t B) noexcept int fmpq_mat_solve_dixon(fmpq_mat_t X, const fmpq_mat_t A, const fmpq_mat_t B) noexcept int fmpq_mat_solve_multi_mod(fmpq_mat_t X, const fmpq_mat_t A, const fmpq_mat_t B) noexcept int fmpq_mat_solve(fmpq_mat_t X, const fmpq_mat_t A, const fmpq_mat_t B) noexcept - # Solves ``AX = B`` for nonsingular ``A``. - # Returns nonzero if ``A`` is nonsingular or if the right hand side - # is empty, and zero otherwise. - # All algorithms clear denominators to obtain a rescaled system over the integers. - # The *fraction_free* algorithm uses FFLU solving over the integers. - # The *dixon* and *multi_mod* algorithms use Dixon p-adic lifting - # or multimodular solving, followed by rational reconstruction - # with an adaptive stopping test. The *dixon* and *multi_mod* algorithms - # are generally the best choice for large systems. - # The default method chooses an algorithm automatically. - int fmpq_mat_solve_fmpz_mat_fraction_free(fmpq_mat_t X, const fmpz_mat_t A, const fmpz_mat_t B) noexcept int fmpq_mat_solve_fmpz_mat_dixon(fmpq_mat_t X, const fmpz_mat_t A, const fmpz_mat_t B) noexcept int fmpq_mat_solve_fmpz_mat_multi_mod(fmpq_mat_t X, const fmpz_mat_t A, const fmpz_mat_t B) noexcept int fmpq_mat_solve_fmpz_mat(fmpq_mat_t X, const fmpz_mat_t A, const fmpz_mat_t B) noexcept - # Solves ``AX = B`` for nonsingular ``A``, where *A* and *B* are integer - # matrices. Returns nonzero if ``A`` is nonsingular or if the right hand side - # is empty, and zero otherwise. - int fmpq_mat_can_solve_multi_mod(fmpq_mat_t X, const fmpq_mat_t A, const fmpq_mat_t B) noexcept - # Returns `1` if ``AX = B`` has a solution and if so, sets ``X`` to one such - # solution. The matrices can have any shape but must have the same number of - # rows. - int fmpq_mat_can_solve_fraction_free(fmpq_mat_t X, const fmpq_mat_t A, const fmpq_mat_t B) noexcept - # Returns `1` if ``AX = B`` has a solution and if so, sets ``X`` to one such - # solution. The matrices can have any shape but must have the same number of - # rows. - int fmpq_mat_can_solve(fmpq_mat_t X, const fmpq_mat_t A, const fmpq_mat_t B) noexcept - # Returns `1` if ``AX = B`` has a solution and if so, sets ``X`` to one such - # solution. The matrices can have any shape but must have the same number of - # rows. - int fmpq_mat_inv(fmpq_mat_t B, const fmpq_mat_t A) noexcept - # Sets ``B`` to the inverse matrix of ``A`` and returns nonzero. - # Returns zero if ``A`` is singular. ``A`` must be a square matrix. - int fmpq_mat_pivot(slong * perm, fmpq_mat_t mat, slong r, slong c) noexcept - # Helper function for row reduction. Returns 1 if the entry of ``mat`` - # at row `r` and column `c` is nonzero. Otherwise searches for a nonzero - # entry in the same column among rows `r+1, r+2, \ldots`. If a nonzero - # entry is found at row `s`, swaps rows `r` and `s` and the corresponding - # entries in ``perm`` (unless ``NULL``) and returns -1. If no - # nonzero pivot entry is found, leaves the inputs unchanged and returns 0. - slong fmpq_mat_rref_classical(fmpq_mat_t B, const fmpq_mat_t A) noexcept - # Sets ``B`` to the reduced row echelon form of ``A`` and returns - # the rank. Performs Gauss-Jordan elimination directly over the rational - # numbers. This algorithm is usually inefficient and is mainly intended - # to be used for testing purposes. - slong fmpq_mat_rref_fraction_free(fmpq_mat_t B, const fmpq_mat_t A) noexcept - # Sets ``B`` to the reduced row echelon form of ``A`` and returns - # the rank. Clears denominators and performs fraction-free Gauss-Jordan - # elimination using ``fmpz_mat`` functions. - slong fmpq_mat_rref(fmpq_mat_t B, const fmpq_mat_t A) noexcept - # Sets ``B`` to the reduced row echelon form of ``A`` and returns - # the rank. This function automatically chooses between the classical and - # fraction-free algorithms depending on the size of the matrix. - void fmpq_mat_gso(fmpq_mat_t B, const fmpq_mat_t A) noexcept - # Takes a subset of `\mathbb{Q}^m` `S = \{a_1, a_2, \ldots ,a_n\}` (as the - # columns of a `m \times n` matrix ``A``) and generates an orthogonal set - # `S' = \{b_1, b_2, \ldots ,b_n\}` (as the columns of the `m \times n` matrix - # ``B``) that spans the same subspace of `\mathbb{Q}^m` as `S`. - void fmpq_mat_similarity(fmpq_mat_t A, slong r, fmpq_t d) noexcept - # Applies a similarity transform to the `n\times n` matrix `M` in-place. - # If `P` is the `n\times n` identity matrix the zero entries of whose row - # `r` (`0`-indexed) have been replaced by `d`, this transform is equivalent - # to `M = P^{-1}MP`. - # Similarity transforms preserve the determinant, characteristic polynomial - # and minimal polynomial. - void _fmpq_mat_charpoly(fmpz * coeffs, fmpz_t den, const fmpq_mat_t mat) noexcept - # Set ``(coeffs, den)`` to the characteristic polynomial of the given - # `n\times n` matrix. - void fmpq_mat_charpoly(fmpq_poly_t pol, const fmpq_mat_t mat) noexcept - # Set ``pol`` to the characteristic polynomial of the given `n\times n` - # matrix. If ``mat`` is not square, an exception is raised. - slong _fmpq_mat_minpoly(fmpz * coeffs, fmpz_t den, const fmpq_mat_t mat) noexcept - # Set ``(coeffs, den)`` to the minimal polynomial of the given - # `n\times n` matrix and return the length of the polynomial. - void fmpq_mat_minpoly(fmpq_poly_t pol, const fmpq_mat_t mat) noexcept - # Set ``pol`` to the minimal polynomial of the given `n\times n` - # matrix. If ``mat`` is not square, an exception is raised. from .fmpq_mat_macros cimport * diff --git a/src/sage/libs/flint/fmpq_mat_macros.pxd b/src/sage/libs/flint/fmpq_mat_macros.pxd index 823941dadf8..45720b0511a 100644 --- a/src/sage/libs/flint/fmpq_mat_macros.pxd +++ b/src/sage/libs/flint/fmpq_mat_macros.pxd @@ -1,14 +1,9 @@ # Macros from fmpq_mat.h -# See https://github.com/flintlib/flint/issues/152 +# See https://github.com/flintlib/flint/issues/1529 from .types cimport * cdef extern from "flint_wrap.h": fmpq * fmpq_mat_entry(fmpq_mat_t mat, slong i, slong j) - # Macro giving a pointer to the entry at row *i* and column *j*. - slong fmpq_mat_nrows(fmpq_mat_t) - # Returns the number of rows of the matrix. - slong fmpq_mat_ncols(fmpq_mat_t) - # Returns the number of columns of the matrix. diff --git a/src/sage/libs/flint/fmpq_mpoly.pxd b/src/sage/libs/flint/fmpq_mpoly.pxd index ff9df250dc3..34caf4ba56f 100644 --- a/src/sage/libs/flint/fmpq_mpoly.pxd +++ b/src/sage/libs/flint/fmpq_mpoly.pxd @@ -2,7 +2,9 @@ # distutils: depends = flint/fmpq_mpoly.h ################################################################################ -# This file is auto-generated. Do not modify by hand +# This file is auto-generated by the script +# SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py. +# Do not modify by hand! Fix and rerun the script instead. ################################################################################ from libc.stdio cimport FILE @@ -11,213 +13,77 @@ from sage.libs.mpfr.types cimport * from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void fmpq_mpoly_ctx_init(fmpq_mpoly_ctx_t ctx, slong nvars, const ordering_t ord) noexcept - # Initialise a context object for a polynomial ring with the given number of variables and the given ordering. - # The possibilities for the ordering are ``ORD_LEX``, ``ORD_DEGLEX`` and ``ORD_DEGREVLEX``. - slong fmpq_mpoly_ctx_nvars(const fmpq_mpoly_ctx_t ctx) noexcept - # Return the number of variables used to initialize the context. - ordering_t fmpq_mpoly_ctx_ord(const fmpq_mpoly_ctx_t ctx) noexcept - # Return the ordering used to initialize the context. - void fmpq_mpoly_ctx_clear(fmpq_mpoly_ctx_t ctx) noexcept - # Release up any space allocated by *ctx*. - void fmpq_mpoly_init(fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx) noexcept - # Initialise *A* for use with the given and initialised context object. Its value is set to zero. - void fmpq_mpoly_init2(fmpq_mpoly_t A, slong alloc, const fmpq_mpoly_ctx_t ctx) noexcept - # Initialise *A* for use with the given and initialised context object. Its value is set to zero. - # It is allocated with space for *alloc* terms and at least ``MPOLY_MIN_BITS`` bits for the exponents. - void fmpq_mpoly_init3(fmpq_mpoly_t A, slong alloc, flint_bitcnt_t bits, const fmpq_mpoly_ctx_t ctx) noexcept - # Initialise *A* for use with the given and initialised context object. Its value is set to zero. - # It is allocated with space for *alloc* terms and *bits* bits for the exponents. - void fmpq_mpoly_fit_length(fmpq_mpoly_t A, slong len, const fmpq_mpoly_ctx_t ctx) noexcept - # Ensure that *A* has space for at least *len* terms. - void fmpq_mpoly_fit_bits(fmpq_mpoly_t A, flint_bitcnt_t bits, const fmpq_mpoly_ctx_t ctx) noexcept - # Ensure that the exponent fields of *A* have at least *bits* bits. - void fmpq_mpoly_realloc(fmpq_mpoly_t A, slong alloc, const fmpq_mpoly_ctx_t ctx) noexcept - # Reallocate *A* to have space for *alloc* terms. - # Assumes the current length of the polynomial is not greater than *alloc*. - void fmpq_mpoly_clear(fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx) noexcept - # Release any space allocated for *A*. - char * fmpq_mpoly_get_str_pretty(const fmpq_mpoly_t A, const char ** x, const fmpq_mpoly_ctx_t ctx) noexcept - # Return a string, which the user is responsible for cleaning up, representing *A*, given an array of variable strings ``x``. - int fmpq_mpoly_fprint_pretty(FILE * file, const fmpq_mpoly_t A, const char ** x, const fmpq_mpoly_ctx_t ctx) noexcept - # Print a string representing *A* to *file*. - int fmpq_mpoly_print_pretty(const fmpq_mpoly_t A, const char ** x, const fmpq_mpoly_ctx_t ctx) noexcept - # Print a string representing *A* to ``stdout``. - int fmpq_mpoly_set_str_pretty(fmpq_mpoly_t A, const char * str, const char ** x, const fmpq_mpoly_ctx_t ctx) noexcept - # Set *A* to the polynomial in the null-terminates string ``str`` given an array ``x`` of variable strings. - # If parsing ``str`` fails, *A* is set to zero, and `-1` is returned. Otherwise, `0` is returned. - # The operations ``+``, ``-``, ``*``, and ``/`` are permitted along with integers and the variables in ``x``. The character ``^`` must be immediately followed by the (integer) exponent. - # If any division is not exact, parsing fails. - void fmpq_mpoly_gen(fmpq_mpoly_t A, slong var, const fmpq_mpoly_ctx_t ctx) noexcept - # Set *A* to the variable of index *var*, where ``var = 0`` corresponds to the variable with the most significance with respect to the ordering. - bint fmpq_mpoly_is_gen(const fmpq_mpoly_t A, slong var, const fmpq_mpoly_ctx_t ctx) noexcept - # If `var \ge 0`, return `1` if *A* is equal to the `var`-th generator, otherwise return `0`. - # If `var < 0`, return `1` if the polynomial is equal to any generator, otherwise return `0`. - void fmpq_mpoly_set(fmpq_mpoly_t A, const fmpq_mpoly_t B, const fmpq_mpoly_ctx_t ctx) noexcept - # Set *A* to *B*. - bint fmpq_mpoly_equal(const fmpq_mpoly_t A, const fmpq_mpoly_t B, const fmpq_mpoly_ctx_t ctx) noexcept - # Return `1` if *A* is equal to *B*, else return `0`. - void fmpq_mpoly_swap(fmpq_mpoly_t A, fmpq_mpoly_t B, const fmpq_mpoly_ctx_t ctx) noexcept - # Efficiently swap *A* and *B*. - bint fmpq_mpoly_is_fmpq(const fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx) noexcept - # Return `1` if *A* is a constant, else return `0`. - void fmpq_mpoly_get_fmpq(fmpq_t c, const fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx) noexcept - # Assuming that *A* is a constant, set *c* to this constant. - # This function throws if *A* is not a constant. - void fmpq_mpoly_set_fmpq(fmpq_mpoly_t A, const fmpq_t c, const fmpq_mpoly_ctx_t ctx) noexcept void fmpq_mpoly_set_fmpz(fmpq_mpoly_t A, const fmpz_t c, const fmpq_mpoly_ctx_t ctx) noexcept void fmpq_mpoly_set_ui(fmpq_mpoly_t A, ulong c, const fmpq_mpoly_ctx_t ctx) noexcept void fmpq_mpoly_set_si(fmpq_mpoly_t A, slong c, const fmpq_mpoly_ctx_t ctx) noexcept - # Set *A* to the constant *c*. - void fmpq_mpoly_zero(fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx) noexcept - # Set *A* to the constant `0`. - void fmpq_mpoly_one(fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx) noexcept - # Set *A* to the constant `1`. - bint fmpq_mpoly_equal_fmpq(const fmpq_mpoly_t A, const fmpq_t c, const fmpq_mpoly_ctx_t ctx) noexcept bint fmpq_mpoly_equal_fmpz(const fmpq_mpoly_t A, const fmpz_t c, const fmpq_mpoly_ctx_t ctx) noexcept bint fmpq_mpoly_equal_ui(const fmpq_mpoly_t A, ulong c, const fmpq_mpoly_ctx_t ctx) noexcept bint fmpq_mpoly_equal_si(const fmpq_mpoly_t A, slong c, const fmpq_mpoly_ctx_t ctx) noexcept - # Return `1` if *A* is equal to the constant *c*, else return `0`. - bint fmpq_mpoly_is_zero(const fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx) noexcept - # Return `1` if *A* is equal to the constant `0`, else return `0`. - bint fmpq_mpoly_is_one(const fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx) noexcept - # Return `1` if *A* is equal to the constant `1`, else return `0`. - int fmpq_mpoly_degrees_fit_si(const fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx) noexcept - # Return `1` if the degrees of *A* with respect to each variable fit into an ``slong``, otherwise return `0`. - void fmpq_mpoly_degrees_fmpz(fmpz ** degs, const fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx) noexcept void fmpq_mpoly_degrees_si(slong * degs, const fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx) noexcept - # Set *degs* to the degrees of *A* with respect to each variable. - # If *A* is zero, all degrees are set to `-1`. - void fmpq_mpoly_degree_fmpz(fmpz_t deg, const fmpq_mpoly_t A, slong var, const fmpq_mpoly_ctx_t ctx) noexcept slong fmpq_mpoly_degree_si(const fmpq_mpoly_t A, slong var, const fmpq_mpoly_ctx_t ctx) noexcept - # Either return or set *deg* to the degree of *A* with respect to the variable of index *var*. - # If *A* is zero, the degree is defined to be `-1`. - int fmpq_mpoly_total_degree_fits_si(const fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx) noexcept - # Return `1` if the total degree of *A* fits into an ``slong``, otherwise return `0`. - void fmpq_mpoly_total_degree_fmpz(fmpz_t tdeg, const fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx) noexcept slong fmpq_mpoly_total_degree_si(const fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx) noexcept - # Either return or set *tdeg* to the total degree of *A*. - # If *A* is zero, the total degree is defined to be `-1`. - void fmpq_mpoly_used_vars(int * used, const fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx) noexcept - # For each variable index *i*, set ``used[i]`` to nonzero if the variable of index *i* appears in *A* and to zero otherwise. - void fmpq_mpoly_get_denominator(fmpz_t d, const fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx) noexcept - # Set *d* to the denominator of *A*, the smallest positive integer `d` such that `d \times A` has integer coefficients. - void fmpq_mpoly_get_coeff_fmpq_monomial(fmpq_t c, const fmpq_mpoly_t A, const fmpq_mpoly_t M, const fmpq_mpoly_ctx_t ctx) noexcept - # Assuming that *M* is a monomial, set *c* to the coefficient of the corresponding monomial in *A*. - # This function throws if *M* is not a monomial. - void fmpq_mpoly_set_coeff_fmpq_monomial(fmpq_mpoly_t A, const fmpq_t c, const fmpq_mpoly_t M, const fmpq_mpoly_ctx_t ctx) noexcept - # Assuming that *M* is a monomial, set the coefficient of the corresponding monomial in *A* to *c*. - # This function throws if *M* is not a monomial. - void fmpq_mpoly_get_coeff_fmpq_fmpz(fmpq_t c, const fmpq_mpoly_t A, fmpz * const * exp, const fmpq_mpoly_ctx_t ctx) noexcept void fmpq_mpoly_get_coeff_fmpq_ui(fmpq_t c, const fmpq_mpoly_t A, const ulong * exp, const fmpq_mpoly_ctx_t ctx) noexcept - # Set *c* to the coefficient of the monomial with exponent *exp*. - void fmpq_mpoly_set_coeff_fmpq_fmpz(fmpq_mpoly_t A, const fmpq_t c, fmpz * const * exp, const fmpq_mpoly_ctx_t ctx) noexcept void fmpq_mpoly_set_coeff_fmpq_ui(fmpq_mpoly_t A, const fmpq_t c, const ulong * exp, const fmpq_mpoly_ctx_t ctx) noexcept - # Set the coefficient of the monomial with exponent *exp* to *c*. - void fmpq_mpoly_get_coeff_vars_ui(fmpq_mpoly_t C, const fmpq_mpoly_t A, const slong * vars, const ulong * exps, slong length, const fmpq_mpoly_ctx_t ctx) noexcept - # Set *C* to the coefficient of *A* with respect to the variables in *vars* with powers in the corresponding array *exps*. - # Both *vars* and *exps* point to array of length *length*. It is assumed that `0 < length \le nvars(A)` and that the variables in *vars* are distinct. - int fmpq_mpoly_cmp(const fmpq_mpoly_t A, const fmpq_mpoly_t B, const fmpq_mpoly_ctx_t ctx) noexcept - # Return `1` (resp. `-1`, or `0`) if *A* is after (resp. before, same as) *B* in some arbitrary but fixed total ordering of the polynomials. - # This ordering agrees with the usual ordering of monomials when *A* and *B* are both monomials. - fmpq * fmpq_mpoly_content_ref(fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx) noexcept - # Return a reference to the content of *A*. - fmpz_mpoly_struct * fmpq_mpoly_zpoly_ref(fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx) noexcept - # Return a reference to the integer polynomial of *A*. - fmpz * fmpq_mpoly_zpoly_term_coeff_ref(fmpq_mpoly_t A, slong i, const fmpq_mpoly_ctx_t ctx) noexcept - # Return a reference to the coefficient of index *i* of the integer polynomial of *A*. - bint fmpq_mpoly_is_canonical(const fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx) noexcept - # Return `1` if *A* is in canonical form. Otherwise, return `0`. - # An ``fmpq_mpoly_t`` is represented as the product of an ``fmpq_t content`` and an ``fmpz_mpoly_t zpoly``. - # The representation is considered canonical when either - # (1) both ``content`` and ``zpoly`` are zero, or - # (2) both ``content`` and ``zpoly`` are nonzero and canonical and ``zpoly`` is reduced. - # A nonzero ``zpoly`` is considered reduced when the coefficients have GCD one and the leading coefficient is positive. - slong fmpq_mpoly_length(const fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx) noexcept - # Return the number of terms stored in *A*. - # If the polynomial is in canonical form, this will be the number of nonzero coefficients. - void fmpq_mpoly_resize(fmpq_mpoly_t A, slong new_length, const fmpq_mpoly_ctx_t ctx) noexcept - # Set the length of *A* to ``new_length``. - # Terms are either deleted from the end, or new zero terms are appended. - void fmpq_mpoly_get_term_coeff_fmpq(fmpq_t c, const fmpq_mpoly_t A, slong i, const fmpq_mpoly_ctx_t ctx) noexcept - # Set *c* to coefficient of index *i* - void fmpq_mpoly_set_term_coeff_fmpq(fmpq_mpoly_t A, slong i, const fmpq_t c, const fmpq_mpoly_ctx_t ctx) noexcept - # Set the coefficient of index *i* to *c*. - int fmpq_mpoly_term_exp_fits_si(const fmpq_mpoly_t A, slong i, const fmpq_mpoly_ctx_t ctx) noexcept int fmpq_mpoly_term_exp_fits_ui(const fmpq_mpoly_t A, slong i, const fmpq_mpoly_ctx_t ctx) noexcept - # Return `1` if all entries of the exponent vector of the term of index *i* fit into an ``slong`` (resp. a ``ulong``). Otherwise, return `0`. - void fmpq_mpoly_get_term_exp_fmpz(fmpz ** exps, const fmpq_mpoly_t A, slong i, const fmpq_mpoly_ctx_t ctx) noexcept void fmpq_mpoly_get_term_exp_ui(ulong * exps, const fmpq_mpoly_t A, slong i, const fmpq_mpoly_ctx_t ctx) noexcept void fmpq_mpoly_get_term_exp_si(slong * exps, const fmpq_mpoly_t A, slong i, const fmpq_mpoly_ctx_t ctx) noexcept - # Set *exp* to the exponent vector of the term of index *i*. - # The ``_ui`` (resp. ``_si``) version throws if any entry does not fit into a ``ulong`` (resp. ``slong``). - ulong fmpq_mpoly_get_term_var_exp_ui(const fmpq_mpoly_t A, slong i, slong var, const fmpq_mpoly_ctx_t ctx) noexcept slong fmpq_mpoly_get_term_var_exp_si(const fmpq_mpoly_t A, slong i, slong var, const fmpq_mpoly_ctx_t ctx) noexcept - # Return the exponent of the variable *var* of the term of index *i*. - # This function throws if the exponent does not fit into a ``ulong`` (resp. ``slong``). - void fmpq_mpoly_set_term_exp_fmpz(fmpq_mpoly_t A, slong i, fmpz * const * exps, const fmpq_mpoly_ctx_t ctx) noexcept void fmpq_mpoly_set_term_exp_ui(fmpq_mpoly_t A, slong i, const ulong * exps, const fmpq_mpoly_ctx_t ctx) noexcept - # Set the exponent vector of the term of index *i* to *exp*. - void fmpq_mpoly_get_term(fmpq_mpoly_t M, const fmpq_mpoly_t A, slong i, const fmpq_mpoly_ctx_t ctx) noexcept - # Set *M* to the term of index *i* in *A*. - void fmpq_mpoly_get_term_monomial(fmpq_mpoly_t M, const fmpq_mpoly_t A, slong i, const fmpq_mpoly_ctx_t ctx) noexcept - # Set *M* to the monomial of the term of index *i* in *A*. The coefficient of *M* will be one. - void fmpq_mpoly_push_term_fmpq_fmpz(fmpq_mpoly_t A, const fmpq_t c, fmpz * const * exp, const fmpq_mpoly_ctx_t ctx) noexcept void fmpq_mpoly_push_term_fmpq_ffmpz(fmpq_mpoly_t A, const fmpq_t c, const fmpz * exp, const fmpq_mpoly_ctx_t ctx) noexcept void fmpq_mpoly_push_term_fmpz_fmpz(fmpq_mpoly_t A, const fmpz_t c, fmpz * const * exp, const fmpq_mpoly_ctx_t ctx) noexcept @@ -230,193 +96,68 @@ cdef extern from "flint_wrap.h": void fmpq_mpoly_push_term_fmpz_ui(fmpq_mpoly_t A, const fmpz_t c, const ulong * exp, const fmpq_mpoly_ctx_t ctx) noexcept void fmpq_mpoly_push_term_ui_ui(fmpq_mpoly_t A, ulong c, const ulong * exp, const fmpq_mpoly_ctx_t ctx) noexcept void fmpq_mpoly_push_term_si_ui(fmpq_mpoly_t A, slong c, const ulong * exp, const fmpq_mpoly_ctx_t ctx) noexcept - # Append a term to *A* with coefficient *c* and exponent vector *exp*. - # This function should run in constant average time if the terms pushed have bounded denominator. - void fmpq_mpoly_reduce(fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx) noexcept - # Factor out necessary content from ``A->zpoly`` so that it is reduced. - # If the terms of *A* were nonzero and sorted with distinct exponents to begin with, the result will be in canonical form. - void fmpq_mpoly_sort_terms(fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx) noexcept - # Sort the internal ``A->zpoly`` into the canonical ordering dictated by the ordering in *ctx*. - # This function does not combine like terms, nor does it delete terms with coefficient zero, nor does it reduce. - void fmpq_mpoly_combine_like_terms(fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx) noexcept - # Combine adjacent like terms in the internal ``A->zpoly`` and then factor out content via a call to :func:`fmpq_mpoly_reduce`. - # If the terms of *A* were sorted to begin with, the result will be in canonical form. - void fmpq_mpoly_reverse(fmpq_mpoly_t A, const fmpq_mpoly_t B, const fmpq_mpoly_ctx_t ctx) noexcept - # Set *A* to the reversal of *B*. - 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) noexcept - # Generate a random polynomial with length up to *length* and exponents in the range ``[0, exp_bound - 1]``. - # The exponents of each variable are generated by calls to ``n_randint(state, exp_bound)``. - 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) noexcept - # Generate a random polynomial with length up to *length* and exponents in the range ``[0, exp_bounds[i] - 1]``. - # The exponents of the variable of index *i* are generated by calls to ``n_randint(state, exp_bounds[i])``. - 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) noexcept - # Generate a random polynomial with length up to *length* and exponents whose packed form does not exceed the given bit count. - # The parameter ``coeff_bits`` to the three functions ``fmpq_mpoly_randtest_{bound|bounds|bits}`` is merely a suggestion for the approximate bit count of the resulting coefficients. - void fmpq_mpoly_add_fmpq(fmpq_mpoly_t A, const fmpq_mpoly_t B, const fmpq_t c, const fmpq_mpoly_ctx_t ctx) noexcept void fmpq_mpoly_add_fmpz(fmpq_mpoly_t A, const fmpq_mpoly_t B, const fmpz_t c, const fmpq_mpoly_ctx_t ctx) noexcept void fmpq_mpoly_add_ui(fmpq_mpoly_t A, const fmpq_mpoly_t B, ulong c, const fmpq_mpoly_ctx_t ctx) noexcept void fmpq_mpoly_add_si(fmpq_mpoly_t A, const fmpq_mpoly_t B, slong c, const fmpq_mpoly_ctx_t ctx) noexcept - # Set *A* to `B + c`. - void fmpq_mpoly_sub_fmpq(fmpq_mpoly_t A, const fmpq_mpoly_t B, const fmpq_t c, const fmpq_mpoly_ctx_t ctx) noexcept void fmpq_mpoly_sub_fmpz(fmpq_mpoly_t A, const fmpq_mpoly_t B, const fmpz_t c, const fmpq_mpoly_ctx_t ctx) noexcept void fmpq_mpoly_sub_ui(fmpq_mpoly_t A, const fmpq_mpoly_t B, ulong c, const fmpq_mpoly_ctx_t ctx) noexcept void fmpq_mpoly_sub_si(fmpq_mpoly_t A, const fmpq_mpoly_t B, slong c, const fmpq_mpoly_ctx_t ctx) noexcept - # Set *A* to `B - c`. - void fmpq_mpoly_add(fmpq_mpoly_t A, const fmpq_mpoly_t B, const fmpq_mpoly_t C, const fmpq_mpoly_ctx_t ctx) noexcept - # Set *A* to `B + C`. - void fmpq_mpoly_sub(fmpq_mpoly_t A, const fmpq_mpoly_t B, const fmpq_mpoly_t C, const fmpq_mpoly_ctx_t ctx) noexcept - # Set *A* to `B - C`. - void fmpq_mpoly_neg(fmpq_mpoly_t A, const fmpq_mpoly_t B, const fmpq_mpoly_ctx_t ctx) noexcept - # Set *A* to `-B`. - void fmpq_mpoly_scalar_mul_fmpq(fmpq_mpoly_t A, const fmpq_mpoly_t B, const fmpq_t c, const fmpq_mpoly_ctx_t ctx) noexcept void fmpq_mpoly_scalar_mul_fmpz(fmpq_mpoly_t A, const fmpq_mpoly_t B, const fmpz_t c, const fmpq_mpoly_ctx_t ctx) noexcept void fmpq_mpoly_scalar_mul_ui(fmpq_mpoly_t A, const fmpq_mpoly_t B, ulong c, const fmpq_mpoly_ctx_t ctx) noexcept void fmpq_mpoly_scalar_mul_si(fmpq_mpoly_t A, const fmpq_mpoly_t B, slong c, const fmpq_mpoly_ctx_t ctx) noexcept - # Set *A* to `B \times c`. - void fmpq_mpoly_scalar_div_fmpq(fmpq_mpoly_t A, const fmpq_mpoly_t B, const fmpq_t c, const fmpq_mpoly_ctx_t ctx) noexcept void fmpq_mpoly_scalar_div_fmpz(fmpq_mpoly_t A, const fmpq_mpoly_t B, const fmpz_t c, const fmpq_mpoly_ctx_t ctx) noexcept void fmpq_mpoly_scalar_div_ui(fmpq_mpoly_t A, const fmpq_mpoly_t B, ulong c, const fmpq_mpoly_ctx_t ctx) noexcept void fmpq_mpoly_scalar_div_si(fmpq_mpoly_t A, const fmpq_mpoly_t B, slong c, const fmpq_mpoly_ctx_t ctx) noexcept - # Set *A* to `B/c`. - void fmpq_mpoly_make_monic(fmpq_mpoly_t A, const fmpq_mpoly_t B, const fmpq_mpoly_ctx_t ctx) noexcept - # Set *A* to *B* divided by the leading coefficient of *B*. - # This throws if *B* is zero. - # All of these functions run quickly if *A* and *B* are aliased. - void fmpq_mpoly_derivative(fmpq_mpoly_t A, const fmpq_mpoly_t B, slong var, const fmpq_mpoly_ctx_t ctx) noexcept - # Set *A* to the derivative of *B* with respect to the variable of index *var*. - void fmpq_mpoly_integral(fmpq_mpoly_t A, const fmpq_mpoly_t B, slong var, const fmpq_mpoly_ctx_t ctx) noexcept - # Set *A* to the integral with the fewest number of terms of *B* with respect to the variable of index *var*. - int fmpq_mpoly_evaluate_all_fmpq(fmpq_t ev, const fmpq_mpoly_t A, fmpq * const * vals, const fmpq_mpoly_ctx_t ctx) noexcept - # Set ``ev`` to the evaluation of *A* where the variables are replaced by the corresponding elements of the array ``vals``. - # Return `1` for success and `0` for failure. - int fmpq_mpoly_evaluate_one_fmpq(fmpq_mpoly_t A, const fmpq_mpoly_t B, slong var, const fmpq_t val, const fmpq_mpoly_ctx_t ctx) noexcept - # Set *A* to the evaluation of *B* where the variable of index *var* is replaced by ``val``. - # Return `1` for success and `0` for failure. - int fmpq_mpoly_compose_fmpq_poly(fmpq_poly_t A, const fmpq_mpoly_t B, fmpq_poly_struct * const * C, const fmpq_mpoly_ctx_t ctxB) noexcept - # Set *A* to the evaluation of *B* where the variables are replaced by the corresponding elements of the array *C*. - # The context object of *B* is *ctxB*. - # Return `1` for success and `0` for failure. - int fmpq_mpoly_compose_fmpq_mpoly(fmpq_mpoly_t A, const fmpq_mpoly_t B, fmpq_mpoly_struct * const * C, const fmpq_mpoly_ctx_t ctxB, const fmpq_mpoly_ctx_t ctxAC) noexcept - # Set *A* to the evaluation of *B* where the variables are replaced by the corresponding elements of the array *C*. - # Both *A* and the elements of *C* have context object *ctxAC*, while *B* has context object *ctxB*. - # Neither *A* nor *B* is allowed to alias any other polynomial. - # Return `1` for success and `0` for failure. - void fmpq_mpoly_compose_fmpq_mpoly_gen(fmpq_mpoly_t A, const fmpq_mpoly_t B, const slong * c, const fmpq_mpoly_ctx_t ctxB, const fmpq_mpoly_ctx_t ctxAC) noexcept - # Set *A* to the evaluation of *B* where the variable of index *i* in *ctxB* is replaced by the variable of index ``c[i]`` in *ctxAC*. - # The length of the array *C* is the number of variables in *ctxB*. - # If any ``c[i]`` is negative, the corresponding variable of *B* is replaced by zero. Otherwise, it is expected that ``c[i]`` is less than the number of variables in *ctxAC*. - void fmpq_mpoly_mul(fmpq_mpoly_t A, const fmpq_mpoly_t B, const fmpq_mpoly_t C, const fmpq_mpoly_ctx_t ctx) noexcept - # Set *A* to `B \times C`. - int fmpq_mpoly_pow_fmpz(fmpq_mpoly_t A, const fmpq_mpoly_t B, const fmpz_t k, const fmpq_mpoly_ctx_t ctx) noexcept - # Set *A* to *B* raised to the *k*-th power. - # Return `1` for success and `0` for failure. - int fmpq_mpoly_pow_ui(fmpq_mpoly_t A, const fmpq_mpoly_t B, ulong k, const fmpq_mpoly_ctx_t ctx) noexcept - # Set *A* to *B* raised to the *k*-th power. - # Return `1` for success and `0` for failure. - int fmpq_mpoly_divides(fmpq_mpoly_t Q, const fmpq_mpoly_t A, const fmpq_mpoly_t B, const fmpq_mpoly_ctx_t ctx) noexcept - # If *A* is divisible by *B*, set *Q* to the exact quotient and return `1`. Otherwise, set *Q* to zero and return `0`. - # Note that the function :func:`fmpq_mpoly_div` may be faster if the quotient is known to be exact. - void fmpq_mpoly_div(fmpq_mpoly_t Q, const fmpq_mpoly_t A, const fmpq_mpoly_t B, const fmpq_mpoly_ctx_t ctx) noexcept - # Set *Q* to the quotient of *A* by *B*, discarding the remainder. - void fmpq_mpoly_divrem(fmpq_mpoly_t Q, fmpq_mpoly_t R, const fmpq_mpoly_t A, const fmpq_mpoly_t B, const fmpq_mpoly_ctx_t ctx) noexcept - # Set *Q* and *R* to the quotient and remainder of *A* divided by *B*. - void fmpq_mpoly_divrem_ideal(fmpq_mpoly_struct ** Q, fmpq_mpoly_t R, const fmpq_mpoly_t A, fmpq_mpoly_struct * const * B, slong len, const fmpq_mpoly_ctx_t ctx) noexcept - # This function is as per :func:`fmpq_mpoly_divrem` except that it takes an array of divisor polynomials *B* and it returns an array of quotient polynomials *Q*. - # The number of divisor (and hence quotient) polynomials is given by *len*. - void fmpq_mpoly_content(fmpq_t g, const fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx) noexcept - # Set *g* to the (nonnegative) gcd of the coefficients of *A*. - void fmpq_mpoly_term_content(fmpq_mpoly_t M, const fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx) noexcept - # Set *M* to the GCD of the terms of *A*. - # If *A* is zero, *M* will be zero. Otherwise, *M* will be a monomial with coefficient one. - int fmpq_mpoly_content_vars(fmpq_mpoly_t g, const fmpq_mpoly_t A, slong * vars, slong vars_length, const fmpq_mpoly_ctx_t ctx) noexcept - # Set *g* to the GCD of the coefficients of *A* when viewed as a polynomial in the variables *vars*. - # Return `1` for success and `0` for failure. Upon success, *g* will be independent of the variables *vars*. - int fmpq_mpoly_gcd(fmpq_mpoly_t G, const fmpq_mpoly_t A, const fmpq_mpoly_t B, const fmpq_mpoly_ctx_t ctx) noexcept - # Try to set *G* to the monic GCD of *A* and *B*. The GCD of zero and zero is defined to be zero. - # If the return is `1` the function was successful. Otherwise the return is `0` and *G* is left untouched. - int fmpq_mpoly_gcd_cofactors(fmpq_mpoly_t G, fmpq_mpoly_t Abar, fmpq_mpoly_t Bbar, const fmpq_mpoly_t A, const fmpq_mpoly_t B, const fmpq_mpoly_ctx_t ctx) noexcept - # Do the operation of :func:`fmpq_mpoly_gcd` and also compute `Abar = A/G` and `Bbar = B/G` if successful. - int fmpq_mpoly_gcd_brown(fmpq_mpoly_t G, const fmpq_mpoly_t A, const fmpq_mpoly_t B, const fmpq_mpoly_ctx_t ctx) noexcept int fmpq_mpoly_gcd_hensel(fmpq_mpoly_t G, const fmpq_mpoly_t A, const fmpq_mpoly_t B, const fmpq_mpoly_ctx_t ctx) noexcept int fmpq_mpoly_gcd_subresultant(fmpq_mpoly_t G, const fmpq_mpoly_t A, const fmpq_mpoly_t B, const fmpq_mpoly_ctx_t ctx) noexcept int fmpq_mpoly_gcd_zippel(fmpq_mpoly_t G, const fmpq_mpoly_t A, const fmpq_mpoly_t B, const fmpq_mpoly_ctx_t ctx) noexcept int fmpq_mpoly_gcd_zippel2(fmpq_mpoly_t G, const fmpq_mpoly_t A, const fmpq_mpoly_t B, const fmpq_mpoly_ctx_t ctx) noexcept - # Try to set *G* to the GCD of *A* and *B* using various algorithms. - int fmpq_mpoly_resultant(fmpq_mpoly_t R, const fmpq_mpoly_t A, const fmpq_mpoly_t B, slong var, const fmpq_mpoly_ctx_t ctx) noexcept - # Try to set *R* to the resultant of *A* and *B* with respect to the variable of index *var*. - int fmpq_mpoly_discriminant(fmpq_mpoly_t D, const fmpq_mpoly_t A, slong var, const fmpq_mpoly_ctx_t ctx) noexcept - # Try to set *D* to the discriminant of *A* with respect to the variable of index *var*. - int fmpq_mpoly_sqrt(fmpq_mpoly_t Q, const fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx) noexcept - # If *A* is a perfect square return `1` and set *Q* to the square root - # with positive leading coefficient. Otherwise return `0` and set *Q* to zero. - bint fmpq_mpoly_is_square(const fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx) noexcept - # Return `1` if *A* is a perfect square, otherwise return `0`. - void fmpq_mpoly_univar_init(fmpq_mpoly_univar_t A, const fmpq_mpoly_ctx_t ctx) noexcept - # Initialize *A*. - void fmpq_mpoly_univar_clear(fmpq_mpoly_univar_t A, const fmpq_mpoly_ctx_t ctx) noexcept - # Clear *A*. - void fmpq_mpoly_univar_swap(fmpq_mpoly_univar_t A, fmpq_mpoly_univar_t B, const fmpq_mpoly_ctx_t ctx) noexcept - # Swap *A* and *B*. - void fmpq_mpoly_to_univar(fmpq_mpoly_univar_t A, const fmpq_mpoly_t B, slong var, const fmpq_mpoly_ctx_t ctx) noexcept - # Set *A* to a univariate form of *B* by pulling out the variable of index *var*. - # The coefficients of *A* will still belong to the content *ctx* but will not depend on the variable of index *var*. - void fmpq_mpoly_from_univar(fmpq_mpoly_t A, const fmpq_mpoly_univar_t B, slong var, const fmpq_mpoly_ctx_t ctx) noexcept - # Set *A* to the normal form of *B* by putting in the variable of index *var*. - # This function is undefined if the coefficients of *B* depend on the variable of index *var*. - int fmpq_mpoly_univar_degree_fits_si(const fmpq_mpoly_univar_t A, const fmpq_mpoly_ctx_t ctx) noexcept - # Return `1` if the degree of *A* with respect to the main variable fits an ``slong``. Otherwise, return `0`. - slong fmpq_mpoly_univar_length(const fmpq_mpoly_univar_t A, const fmpq_mpoly_ctx_t ctx) noexcept - # Return the number of terms in *A* with respect to the main variable. - slong fmpq_mpoly_univar_get_term_exp_si(fmpq_mpoly_univar_t A, slong i, const fmpq_mpoly_ctx_t ctx) noexcept - # Return the exponent of the term of index *i* of *A*. - void fmpq_mpoly_univar_get_term_coeff(fmpq_mpoly_t c, const fmpq_mpoly_univar_t A, slong i, const fmpq_mpoly_ctx_t ctx) noexcept void fmpq_mpoly_univar_swap_term_coeff(fmpq_mpoly_t c, fmpq_mpoly_univar_t A, slong i, const fmpq_mpoly_ctx_t ctx) noexcept - # Set (resp. swap) *c* to (resp. with) the coefficient of the term of index *i* of *A*. diff --git a/src/sage/libs/flint/fmpq_mpoly_factor.pxd b/src/sage/libs/flint/fmpq_mpoly_factor.pxd index b27bd701d81..c291de6946c 100644 --- a/src/sage/libs/flint/fmpq_mpoly_factor.pxd +++ b/src/sage/libs/flint/fmpq_mpoly_factor.pxd @@ -2,7 +2,9 @@ # distutils: depends = flint/fmpq_mpoly_factor.h ################################################################################ -# This file is auto-generated. Do not modify by hand +# This file is auto-generated by the script +# SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py. +# Do not modify by hand! Fix and rerun the script instead. ################################################################################ from libc.stdio cimport FILE @@ -11,42 +13,16 @@ from sage.libs.mpfr.types cimport * from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void fmpq_mpoly_factor_init(fmpq_mpoly_factor_t f, const fmpq_mpoly_ctx_t ctx) noexcept - # Initialise *f*. - void fmpq_mpoly_factor_clear(fmpq_mpoly_factor_t f, const fmpq_mpoly_ctx_t ctx) noexcept - # Clear *f*. - void fmpq_mpoly_factor_swap(fmpq_mpoly_factor_t f, fmpq_mpoly_factor_t g, const fmpq_mpoly_ctx_t ctx) noexcept - # Efficiently swap *f* and *g*. - slong fmpq_mpoly_factor_length(const fmpq_mpoly_factor_t f, const fmpq_mpoly_ctx_t ctx) noexcept - # Return the length of the product in *f*. - void fmpq_mpoly_factor_get_constant_fmpq(fmpq_t c, const fmpq_mpoly_factor_t f, const fmpq_mpoly_ctx_t ctx) noexcept - # Set *c* to the constant of *f*. - void fmpq_mpoly_factor_get_base(fmpq_mpoly_t B, const fmpq_mpoly_factor_t f, slong i, const fmpq_mpoly_ctx_t ctx) noexcept void fmpq_mpoly_factor_swap_base(fmpq_mpoly_t B, fmpq_mpoly_factor_t f, slong i, const fmpq_mpoly_ctx_t ctx) noexcept - # Set (resp. swap) *B* to (resp. with) the base of the term of index *i* in *A*. - slong fmpq_mpoly_factor_get_exp_si(fmpq_mpoly_factor_t f, slong i, const fmpq_mpoly_ctx_t ctx) noexcept - # Return the exponent of the term of index *i* in *A*. It is assumed to fit an ``slong``. - void fmpq_mpoly_factor_sort(fmpq_mpoly_factor_t f, const fmpq_mpoly_ctx_t ctx) noexcept - # Sort the product of *f* first by exponent and then by base. - int fmpq_mpoly_factor_make_monic(fmpq_mpoly_factor_t f, const fmpq_mpoly_ctx_t ctx) noexcept int fmpq_mpoly_factor_make_integral(fmpq_mpoly_factor_t f, const fmpq_mpoly_ctx_t ctx) noexcept - # Make the bases in *f* monic (resp. integral and primitive with positive leading coefficient). - # Return `1` for success, `0` for failure. - int fmpq_mpoly_factor_squarefree(fmpq_mpoly_factor_t f, const fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx) noexcept - # Set *f* to a factorization of *A* where the bases are primitive and - # pairwise relatively prime. If the product of all irreducible factors with - # a given exponent is desired, it is recommended to call :func:`fmpq_mpoly_factor_sort` - # and then multiply the bases with the desired exponent. - int fmpq_mpoly_factor(fmpq_mpoly_factor_t f, const fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx) noexcept - # Set *f* to a factorization of *A* where the bases are irreducible. diff --git a/src/sage/libs/flint/fmpq_poly.pxd b/src/sage/libs/flint/fmpq_poly.pxd index c1795aac611..f8622ebfd41 100644 --- a/src/sage/libs/flint/fmpq_poly.pxd +++ b/src/sage/libs/flint/fmpq_poly.pxd @@ -2,7 +2,9 @@ # distutils: depends = flint/fmpq_poly.h ################################################################################ -# This file is auto-generated. Do not modify by hand +# This file is auto-generated by the script +# SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py. +# Do not modify by hand! Fix and rerun the script instead. ################################################################################ from libc.stdio cimport FILE @@ -11,1232 +13,227 @@ from sage.libs.mpfr.types cimport * from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void fmpq_poly_init(fmpq_poly_t poly) noexcept - # Initialises the polynomial for use. The length is set to zero. - void fmpq_poly_init2(fmpq_poly_t poly, slong alloc) noexcept - # Initialises the polynomial with space for at least ``alloc`` - # coefficients and sets the length to zero. The ``alloc`` coefficients - # are all set to zero. - void fmpq_poly_realloc(fmpq_poly_t poly, slong alloc) noexcept - # Reallocates the given polynomial to have space for ``alloc`` - # coefficients. If ``alloc`` is zero then the polynomial is cleared - # and then reinitialised. If the current length is greater than - # ``alloc`` then ``poly`` is first truncated to length - # ``alloc``. Note that this might leave the rational polynomial in - # non-canonical form. - void fmpq_poly_fit_length(fmpq_poly_t poly, slong len) noexcept - # If ``len`` is greater than the number of coefficients currently - # allocated, then the polynomial is reallocated to have space for at - # least ``len`` coefficients. No data is lost when calling this - # function. The function efficiently deals with the case where - # :func:`fit_length` is called many times in small increments by at - # least doubling the number of allocated coefficients when ``len`` - # is larger than the number of coefficients currently allocated. - void _fmpq_poly_set_length(fmpq_poly_t poly, slong len) noexcept - # Sets the length of the numerator polynomial to ``len``, demoting - # coefficients beyond the new length. Note that this method does - # not guarantee that the rational polynomial is in canonical form. - void fmpq_poly_clear(fmpq_poly_t poly) noexcept - # Clears the given polynomial, releasing any memory used. The polynomial - # must be reinitialised in order to be used again. - void _fmpq_poly_normalise(fmpq_poly_t poly) noexcept - # Sets the length of ``poly`` so that the top coefficient is - # non-zero. If all coefficients are zero, the length is set to zero. - # Note that this function does not guarantee the coprimality of the - # numerator polynomial and the integer denominator. - void _fmpq_poly_canonicalise(fmpz * poly, fmpz_t den, slong len) noexcept - # Puts ``(poly, den)`` of length ``len`` into canonical form. - # It is assumed that the array ``poly`` contains a non-zero entry in - # position ``len - 1`` whenever ``len > 0``. Assumes that ``den`` - # is non-zero. - void fmpq_poly_canonicalise(fmpq_poly_t poly) noexcept - # Puts the polynomial ``poly`` into canonical form. Firstly, the length - # is set to the actual length of the numerator polynomial. For non-zero - # polynomials, it is then ensured that the numerator and denominator are - # coprime and that the denominator is positive. The canonical form of the - # zero polynomial is a zero numerator polynomial and a one denominator. - bint _fmpq_poly_is_canonical(const fmpz * poly, const fmpz_t den, slong len) noexcept - # Returns whether the polynomial is in canonical form. - bint fmpq_poly_is_canonical(const fmpq_poly_t poly) noexcept - # Returns whether the polynomial is in canonical form. - slong fmpq_poly_degree(const fmpq_poly_t poly) noexcept - # Returns the degree of ``poly``, which is one less than its length, as - # a ``slong``. - slong fmpq_poly_length(const fmpq_poly_t poly) noexcept - # Returns the length of ``poly``. - fmpz * fmpq_poly_numref(fmpq_poly_t poly) noexcept - # Returns a reference to the numerator polynomial as an array. - # Note that, because of a delayed initialisation approach, this might - # be ``NULL`` for zero polynomials. This situation can be salvaged - # by calling either :func:`fmpq_poly_fit_length` or - # :func:`fmpq_poly_realloc`. - # This function is implemented as a macro returning ``(poly)->coeffs``. - fmpz_t fmpq_poly_denref(fmpq_poly_t poly) noexcept - # Returns a reference to the denominator as a ``fmpz_t``. The integer - # is guaranteed to be properly initialised. - # This function is implemented as a macro returning ``(poly)->den``. - void fmpq_poly_get_numerator(fmpz_poly_t res, const fmpq_poly_t poly) noexcept - # Sets ``res`` to the numerator of ``poly``, e.g. the primitive part - # as an ``fmpz_poly_t`` if it is in canonical form. - void fmpq_poly_get_denominator(fmpz_t den, const fmpq_poly_t poly) noexcept - # Sets ``res`` to the denominator of ``poly``. - void fmpq_poly_randtest(fmpq_poly_t f, flint_rand_t state, slong len, flint_bitcnt_t bits) noexcept - # Sets `f` to a random polynomial with coefficients up to the given - # length and where each coefficient has up to the given number of bits. - # The coefficients are signed randomly. One must call - # :func:`flint_randinit` before calling this function. - void fmpq_poly_randtest_unsigned(fmpq_poly_t f, flint_rand_t state, slong len, flint_bitcnt_t bits) noexcept - # Sets `f` to a random polynomial with coefficients up to the given length - # and where each coefficient has up to the given number of bits. One must - # call :func:`flint_randinit` before calling this function. - void fmpq_poly_randtest_not_zero(fmpq_poly_t f, flint_rand_t state, slong len, flint_bitcnt_t bits) noexcept - # As for :func:`fmpq_poly_randtest` except that ``len`` and ``bits`` - # may not be zero and the polynomial generated is guaranteed not to be the - # zero polynomial. One must call :func:`flint_randinit` before calling - # this function. - void fmpq_poly_set(fmpq_poly_t poly1, const fmpq_poly_t poly2) noexcept - # Sets ``poly1`` to equal ``poly2``. - void fmpq_poly_set_si(fmpq_poly_t poly, slong x) noexcept - # Sets ``poly`` to the integer `x`. - void fmpq_poly_set_ui(fmpq_poly_t poly, ulong x) noexcept - # Sets ``poly`` to the integer `x`. - void fmpq_poly_set_fmpz(fmpq_poly_t poly, const fmpz_t x) noexcept - # Sets ``poly`` to the integer `x`. - void fmpq_poly_set_fmpq(fmpq_poly_t poly, const fmpq_t x) noexcept - # Sets ``poly`` to the rational `x`, which is assumed to be - # given in lowest terms. - void fmpq_poly_set_fmpz_poly(fmpq_poly_t rop, const fmpz_poly_t op) noexcept - # Sets the rational polynomial ``rop`` to the same value - # as the integer polynomial ``op``. - void fmpq_poly_set_nmod_poly(fmpq_poly_t rop, const nmod_poly_t op) noexcept - # Sets the coefficients of ``rop`` to the residues in ``op``, - # normalised to the interval `-m/2 \le r < m/2` where `m` is the modulus. - void fmpq_poly_get_nmod_poly(nmod_poly_t rop, const fmpq_poly_t op) noexcept - # Sets the coefficients of ``rop`` to the coefficients in the denominator of ``op``, - # reduced by the modulus of ``rop``. The result is multiplied by the inverse of the - # denominator of ``op``. It is assumed that the reduction of the denominator of ``op`` - # is invertible. - void fmpq_poly_get_nmod_poly_den(nmod_poly_t rop, const fmpq_poly_t op, int den) noexcept - # Sets the coefficients of ``rop`` to the coefficients in the denominator - # of ``op``, reduced by the modulus of ``rop``. If ``den == 1``, the result is - # multiplied by the inverse of the denominator of ``op``. In this case it is - # assumed that the reduction of the denominator of ``op`` is invertible. - int _fmpq_poly_set_str(fmpz * poly, fmpz_t den, const char * str, slong len) noexcept - # Sets ``(poly, den)`` to the polynomial specified by the - # null-terminated string ``str`` of ``len`` coefficients. The input - # format is a sequence of coefficients separated by one space. - # The result is only guaranteed to be in lowest terms if all - # coefficients in the input string are in lowest terms. - # Returns `0` if no error occurred. Otherwise, returns -1 - # in which case the resulting value of ``(poly, den)`` is undefined. - # If ``str`` is not null-terminated, calling this method might result - # in a segmentation fault. - int fmpq_poly_set_str(fmpq_poly_t poly, const char * str) noexcept - # Sets ``poly`` to the polynomial specified by the null-terminated - # string ``str``. The input format is the same as the output format - # of ``fmpq_poly_get_str``: the length given as a decimal integer, - # then two spaces, then the list of coefficients separated by one space. - # The result is only guaranteed to be in canonical form if all - # coefficients in the input string are in lowest terms. - # Returns `0` if no error occurred. Otherwise, returns -1 in which case - # the resulting value of ``poly`` is set to zero. If ``str`` is not - # null-terminated, calling this method might result in a segmentation fault. - char * fmpq_poly_get_str(const fmpq_poly_t poly) noexcept - # Returns the string representation of ``poly``. - char * fmpq_poly_get_str_pretty(const fmpq_poly_t poly, const char * var) noexcept - # Returns the pretty representation of ``poly``, using the - # null-terminated string ``var`` not equal to ``"\0"`` as - # the variable name. - void fmpq_poly_zero(fmpq_poly_t poly) noexcept - # Sets ``poly`` to zero. - void fmpq_poly_one(fmpq_poly_t poly) noexcept - # Sets ``poly`` to the constant polynomial `1`. - void fmpq_poly_neg(fmpq_poly_t poly1, const fmpq_poly_t poly2) noexcept - # Sets ``poly1`` to the additive inverse of ``poly2``. - void fmpq_poly_inv(fmpq_poly_t poly1, const fmpq_poly_t poly2) noexcept - # Sets ``poly1`` to the multiplicative inverse of ``poly2`` - # if possible. Otherwise, if ``poly2`` is not a unit, leaves - # ``poly1`` unmodified and calls :func:`abort`. - void fmpq_poly_swap(fmpq_poly_t poly1, fmpq_poly_t poly2) noexcept - # Efficiently swaps the polynomials ``poly1`` and ``poly2``. - void fmpq_poly_truncate(fmpq_poly_t poly, slong n) noexcept - # If the current length of ``poly`` is greater than `n`, it is - # truncated to the given length. Discarded coefficients are demoted, - # but they are not necessarily set to zero. - void fmpq_poly_set_trunc(fmpq_poly_t res, const fmpq_poly_t poly, slong n) noexcept - # Sets ``res`` to a copy of ``poly``, truncated to length ``n``. - void fmpq_poly_get_slice(fmpq_poly_t rop, const fmpq_poly_t op, slong i, slong j) noexcept - # Returns the slice with coefficients from `x^i` (including) to - # `x^j` (excluding). - void fmpq_poly_reverse(fmpq_poly_t res, const fmpq_poly_t poly, slong n) noexcept - # This function considers the polynomial ``poly`` to be of length `n`, - # notionally truncating and zero padding if required, and reverses - # the result. Since the function normalises its result ``res`` may be - # of length less than `n`. - void fmpq_poly_get_coeff_fmpz(fmpz_t x, const fmpq_poly_t poly, slong n) noexcept - # Retrieves the `n`\th coefficient of the numerator of ``poly``. - void fmpq_poly_get_coeff_fmpq(fmpq_t x, const fmpq_poly_t poly, slong n) noexcept - # Retrieves the `n`\th coefficient of ``poly``, in lowest terms. - void fmpq_poly_set_coeff_si(fmpq_poly_t poly, slong n, slong x) noexcept - # Sets the `n`\th coefficient in ``poly`` to the integer `x`. - void fmpq_poly_set_coeff_ui(fmpq_poly_t poly, slong n, ulong x) noexcept - # Sets the `n`\th coefficient in ``poly`` to the integer `x`. - void fmpq_poly_set_coeff_fmpz(fmpq_poly_t poly, slong n, const fmpz_t x) noexcept - # Sets the `n`\th coefficient in ``poly`` to the integer `x`. - void fmpq_poly_set_coeff_fmpq(fmpq_poly_t poly, slong n, const fmpq_t x) noexcept - # Sets the `n`\th coefficient in ``poly`` to the rational `x`. - bint fmpq_poly_equal(const fmpq_poly_t poly1, const fmpq_poly_t poly2) noexcept - # Returns `1` if ``poly1`` is equal to ``poly2``, - # otherwise returns `0`. - bint _fmpq_poly_equal_trunc(const fmpz * poly1, const fmpz_t den1, slong len1, const fmpz * poly2, const fmpz_t den2, slong len2, slong n) noexcept - # Returns `1` if ``poly1`` and ``poly2`` notionally truncated to length - # `n` are equal, otherwise returns `0`. - bint fmpq_poly_equal_trunc(const fmpq_poly_t poly1, const fmpq_poly_t poly2, slong n) noexcept - # Returns `1` if ``poly1`` and ``poly2`` notionally truncated to length - # `n` are equal, otherwise returns `0`. - int _fmpq_poly_cmp(const fmpz * lpoly, const fmpz_t lden, const fmpz * rpoly, const fmpz_t rden, slong len) noexcept - # Compares two non-zero polynomials, assuming they have the same length - # ``len > 0``. - # The polynomials are expected to be provided in canonical form. - int fmpq_poly_cmp(const fmpq_poly_t left, const fmpq_poly_t right) noexcept - # Compares the two polynomials ``left`` and ``right``. - # Compares the two polynomials ``left`` and ``right``, returning - # `-1`, `0`, or `1` as ``left`` is less than, equal to, or greater - # than ``right``. The comparison is first done by the degree, and - # then, in case of a tie, by the individual coefficients from highest - # to lowest. - bint fmpq_poly_is_one(const fmpq_poly_t poly) noexcept - # Returns `1` if ``poly`` is the constant polynomial `1`, otherwise - # returns `0`. - bint fmpq_poly_is_zero(const fmpq_poly_t poly) noexcept - # Returns `1` if ``poly`` is the zero polynomial, otherwise returns `0`. - bint fmpq_poly_is_gen(const fmpq_poly_t poly) noexcept - # Returns `1` if ``poly`` is the degree `1` polynomial `x`, otherwise returns - # `0`. - void _fmpq_poly_add(fmpz * rpoly, fmpz_t rden, const fmpz * poly1, const fmpz_t den1, slong len1, const fmpz * poly2, const fmpz_t den2, slong len2) noexcept - # Forms the sum ``(rpoly, rden)`` of ``(poly1, den1, len1)`` and - # ``(poly2, den2, len2)``, placing the result into canonical form. - # Assumes that ``rpoly`` is an array of length the maximum of - # ``len1`` and ``len2``. The input operands are assumed to - # be in canonical form and are also allowed to be of length `0`. - # ``(rpoly, rden)`` and ``(poly1, den1)`` may be aliased, - # but ``(rpoly, rden)`` and ``(poly2, den2)`` may *not* - # be aliased. - void _fmpq_poly_add_can(fmpz * rpoly, fmpz_t rden, const fmpz * poly1, const fmpz_t den1, slong len1, const fmpz * poly2, const fmpz_t den2, slong len2, int can) noexcept - # As per ``_fmpq_poly_add`` except that one can specify whether to - # canonicalise the output or not. This function is intended to be used with - # weak canonicalisation to prevent explosion in memory usage. It exists for - # performance reasons. - void fmpq_poly_add(fmpq_poly_t res, const fmpq_poly_t poly1, const fmpq_poly_t poly2) noexcept - # Sets ``res`` to the sum of ``poly1`` and ``poly2``, using - # Henrici's algorithm. - void fmpq_poly_add_can(fmpq_poly_t res, const fmpq_poly_t poly1, const fmpq_poly_t poly2, int can) noexcept - # As per ``mpq_poly_add`` except that one can specify whether to - # canonicalise the output or not. This function is intended to be used with - # weak canonicalisation to prevent explosion in memory usage. It exists for - # performance reasons. - void _fmpq_poly_add_series(fmpz * rpoly, fmpz_t rden, const fmpz * poly1, const fmpz_t den1, slong len1, const fmpz * poly2, const fmpz_t den2, slong len2, slong n) noexcept - # As per ``_fmpq_poly_add`` but the inputs are first notionally truncated - # to length `n`. If `n` is less than ``len1`` or ``len2`` then the - # output only needs space for `n` coefficients. We require `n \geq 0`. - void _fmpq_poly_add_series_can(fmpz * rpoly, fmpz_t rden, const fmpz * poly1, const fmpz_t den1, slong len1, const fmpz * poly2, const fmpz_t den2, slong len2, slong n, int can) noexcept - # As per ``_fmpq_poly_add_can`` but the inputs are first notionally - # truncated to length `n`. If `n` is less than ``len1`` or ``len2`` - # then the output only needs space for `n` coefficients. We require - # `n \geq 0`. - void fmpq_poly_add_series(fmpq_poly_t res, const fmpq_poly_t poly1, const fmpq_poly_t poly2, slong n) noexcept - # As per ``fmpq_poly_add`` but the inputs are first notionally - # truncated to length `n`. - void fmpq_poly_add_series_can(fmpq_poly_t res, const fmpq_poly_t poly1, const fmpq_poly_t poly2, slong n, int can) noexcept - # As per ``fmpq_poly_add_can`` but the inputs are first notionally - # truncated to length `n`. - void _fmpq_poly_sub(fmpz * rpoly, fmpz_t rden, const fmpz * poly1, const fmpz_t den1, slong len1, const fmpz * poly2, const fmpz_t den2, slong len2) noexcept - # Forms the difference ``(rpoly, rden)`` of ``(poly1, den1, len1)`` - # and ``(poly2, den2, len2)``, placing the result into canonical form. - # Assumes that ``rpoly`` is an array of length the maximum of - # ``len1`` and ``len2``. The input operands are assumed to be in - # canonical form and are also allowed to be of length `0`. - # ``(rpoly, rden)`` and ``(poly1, den1, len1)`` may be aliased, - # but ``(rpoly, rden)`` and ``(poly2, den2, len2)`` may *not* be - # aliased. - void _fmpq_poly_sub_can(fmpz * rpoly, fmpz_t rden, const fmpz * poly1, const fmpz_t den1, slong len1, const fmpz * poly2, const fmpz_t den2, slong len2, int can) noexcept - # As per ``_fmpq_poly_sub`` except that one can specify whether to - # canonicalise the output or not. This function is intended to be used with - # weak canonicalisation to prevent explosion in memory usage. It exists for - # performance reasons. - void fmpq_poly_sub(fmpq_poly_t res, const fmpq_poly_t poly1, const fmpq_poly_t poly2) noexcept - # Sets ``res`` to the difference of ``poly1`` and ``poly2``, - # using Henrici's algorithm. - void fmpq_poly_sub_can(fmpq_poly_t res, const fmpq_poly_t poly1, const fmpq_poly_t poly2, int can) noexcept - # As per ``_fmpq_poly_sub`` except that one can specify whether to - # canonicalise the output or not. This function is intended to be used with - # weak canonicalisation to prevent explosion in memory usage. It exists for - # performance reasons. - void _fmpq_poly_sub_series(fmpz * rpoly, fmpz_t rden, const fmpz * poly1, const fmpz_t den1, slong len1, const fmpz * poly2, const fmpz_t den2, slong len2, slong n) noexcept - # As per ``_fmpq_poly_sub`` but the inputs are first notionally truncated - # to length `n`. If `n` is less than ``len1`` or ``len2`` then the - # output only needs space for `n` coefficients. We require `n \geq 0`. - void _fmpq_poly_sub_series_can(fmpz * rpoly, fmpz_t rden, const fmpz * poly1, const fmpz_t den1, slong len1, const fmpz * poly2, const fmpz_t den2, slong len2, slong n, int can) noexcept - # As per ``_fmpq_poly_sub_can`` but the inputs are first notionally - # truncated to length `n`. If `n` is less than ``len1`` or ``len2`` - # then the output only needs space for `n` coefficients. We require - # `n \geq 0`. - void fmpq_poly_sub_series(fmpq_poly_t res, const fmpq_poly_t poly1, const fmpq_poly_t poly2, slong n) noexcept - # As per ``fmpq_poly_sub`` but the inputs are first notionally - # truncated to length `n`. - void fmpq_poly_sub_series_can(fmpq_poly_t res, const fmpq_poly_t poly1, const fmpq_poly_t poly2, slong n, int can) noexcept - # As per ``fmpq_poly_sub_can`` but the inputs are first notionally - # truncated to length `n`. - void _fmpq_poly_scalar_mul_si(fmpz * rpoly, fmpz_t rden, const fmpz * poly, const fmpz_t den, slong len, slong c) noexcept - # Sets ``(rpoly, rden, len)`` to the product of `c` of - # ``(poly, den, len)``. - # If the input is normalised, then so is the output, provided it is - # non-zero. If the input is in lowest terms, then so is the output. - # However, even if neither of these conditions are met, the result - # will be (mathematically) correct. - # Supports exact aliasing between ``(rpoly, den)`` - # and ``(poly, den)``. - void _fmpq_poly_scalar_mul_ui(fmpz * rpoly, fmpz_t rden, const fmpz * poly, const fmpz_t den, slong len, ulong c) noexcept - # Sets ``(rpoly, rden, len)`` to the product of `c` of - # ``(poly, den, len)``. - # If the input is normalised, then so is the output, provided it is - # non-zero. If the input is in lowest terms, then so is the output. - # However, even if neither of these conditions are met, the result - # will be (mathematically) correct. - # Supports exact aliasing between ``(rpoly, den)`` - # and ``(poly, den)``. - void _fmpq_poly_scalar_mul_fmpz(fmpz * rpoly, fmpz_t rden, const fmpz * poly, const fmpz_t den, slong len, const fmpz_t c) noexcept - # Sets ``(rpoly, rden, len)`` to the product of `c` of - # ``(poly, den, len)``. - # If the input is normalised, then so is the output, provided it is - # non-zero. If the input is in lowest terms, then so is the output. - # However, even if neither of these conditions are met, the result - # will be (mathematically) correct. - # Supports exact aliasing between ``(rpoly, den)`` - # and ``(poly, den)``. - void _fmpq_poly_scalar_mul_fmpq(fmpz * rpoly, fmpz_t rden, const fmpz * poly, const fmpz_t den, slong len, const fmpz_t r, const fmpz_t s) noexcept - # Sets ``(rpoly, rden)`` to the product of `r/s` and - # ``(poly, den, len)``, in lowest terms. - # Assumes that ``(poly, den, len)`` and `r/s` are provided in lowest - # terms. Assumes that ``rpoly`` is an array of length ``len``. - # Supports aliasing of ``(rpoly, den)`` and ``(poly, den)``. - # The ``fmpz_t``'s `r` and `s` may not be part of ``(rpoly, rden)``. - void fmpq_poly_scalar_mul_fmpq(fmpq_poly_t rop, const fmpq_poly_t op, const fmpq_t c) noexcept void fmpq_poly_scalar_mul_si(fmpq_poly_t rop, const fmpq_poly_t op, slong c) noexcept void fmpq_poly_scalar_mul_ui(fmpq_poly_t rop, const fmpq_poly_t op, ulong c) noexcept - # Sets ``rop`` to `c` times ``op``. - void fmpq_poly_scalar_mul_fmpz(fmpq_poly_t rop, const fmpq_poly_t op, const fmpz_t c) noexcept - # Sets ``rop`` to `c` times ``op``. Assumes that the ``fmpz_t c`` - # is not part of ``rop``. - void _fmpq_poly_scalar_div_fmpz(fmpz * rpoly, fmpz_t rden, const fmpz * poly, const fmpz_t den, slong len, const fmpz_t c) noexcept - # Sets ``(rpoly, rden, len)`` to ``(poly, den, len)`` divided by `c`, - # in lowest terms. - # Assumes that ``len`` is positive. Assumes that `c` is non-zero. - # Supports aliasing between ``(rpoly, rden)`` and ``(poly, den)``. - # Assumes that `c` is not part of ``(rpoly, rden)``. - void _fmpq_poly_scalar_div_si(fmpz * rpoly, fmpz_t rden, const fmpz * poly, const fmpz_t den, slong len, slong c) noexcept - # Sets ``(rpoly, rden, len)`` to ``(poly, den, len)`` divided by `c`, - # in lowest terms. - # Assumes that ``len`` is positive. Assumes that `c` is non-zero. - # Supports aliasing between ``(rpoly, rden)`` and ``(poly, den)``. - void _fmpq_poly_scalar_div_ui(fmpz * rpoly, fmpz_t rden, const fmpz * poly, const fmpz_t den, slong len, ulong c) noexcept - # Sets ``(rpoly, rden, len)`` to ``(poly, den, len)`` divided by `c`, - # in lowest terms. - # Assumes that ``len`` is positive. Assumes that `c` is non-zero. - # Supports aliasing between ``(rpoly, rden)`` and ``(poly, den)``. - void _fmpq_poly_scalar_div_fmpq(fmpz * rpoly, fmpz_t rden, const fmpz * poly, const fmpz_t den, slong len, const fmpz_t r, const fmpz_t s) noexcept - # Sets ``(rpoly, rden, len)`` to ``(poly, den, len)`` divided by `r/s`, - # in lowest terms. - # Assumes that ``len`` is positive. Assumes that `r/s` is non-zero and - # in lowest terms. Supports aliasing between ``(rpoly, rden)`` and - # ``(poly, den)``. The ``fmpz_t``'s `r` and `s` may not be part of - # ``(rpoly, poly)``. - void fmpq_poly_scalar_div_si(fmpq_poly_t rop, const fmpq_poly_t op, slong c) noexcept void fmpq_poly_scalar_div_ui(fmpq_poly_t rop, const fmpq_poly_t op, ulong c) noexcept void fmpq_poly_scalar_div_fmpz(fmpq_poly_t rop, const fmpq_poly_t op, const fmpz_t c) noexcept void fmpq_poly_scalar_div_fmpq(fmpq_poly_t rop, const fmpq_poly_t op, const fmpq_t c) noexcept - # Sets ``rop`` to ``op`` divided by the scalar ``c``. - void _fmpq_poly_mul(fmpz * rpoly, fmpz_t rden, const fmpz * poly1, const fmpz_t den1, slong len1, const fmpz * poly2, const fmpz_t den2, slong len2) noexcept - # Sets ``(rpoly, rden, len1 + len2 - 1)`` to the product of - # ``(poly1, den1, len1)`` and ``(poly2, den2, len2)``. If the - # input is provided in canonical form, then so is the output. - # Assumes ``len1 >= len2 > 0``. Allows zero-padding in the input. - # Does not allow aliasing between the inputs and outputs. - void fmpq_poly_mul(fmpq_poly_t res, const fmpq_poly_t poly1, const fmpq_poly_t poly2) noexcept - # Sets ``res`` to the product of ``poly1`` and ``poly2``. - void _fmpq_poly_mullow(fmpz * rpoly, fmpz_t rden, const fmpz * poly1, const fmpz_t den1, slong len1, const fmpz * poly2, const fmpz_t den2, slong len2, slong n) noexcept - # Sets ``(rpoly, rden, n)`` to the low `n` coefficients of - # ``(poly1, den1)`` and ``(poly2, den2)``. The output is - # not guaranteed to be in canonical form. - # Assumes ``len1 >= len2 > 0`` and ``0 < n <= len1 + len2 - 1``. - # Allows for zero-padding in the inputs. Does not allow aliasing between - # the inputs and outputs. - void fmpq_poly_mullow(fmpq_poly_t res, const fmpq_poly_t poly1, const fmpq_poly_t poly2, slong n) noexcept - # Sets ``res`` to the product of ``poly1`` and ``poly2``, - # truncated to length `n`. - void fmpq_poly_addmul(fmpq_poly_t rop, const fmpq_poly_t op1, const fmpq_poly_t op2) noexcept - # Adds the product of ``op1`` and ``op2`` to ``rop``. - void fmpq_poly_submul(fmpq_poly_t rop, const fmpq_poly_t op1, const fmpq_poly_t op2) noexcept - # Subtracts the product of ``op1`` and ``op2`` from ``rop``. - void _fmpq_poly_pow(fmpz * rpoly, fmpz_t rden, const fmpz * poly, const fmpz_t den, slong len, ulong e) noexcept - # Sets ``(rpoly, rden)`` to ``(poly, den)^e``, assuming - # ``e, len > 0``. Assumes that ``rpoly`` is an array of - # length at least ``e * (len - 1) + 1``. Supports aliasing - # of ``(rpoly, den)`` and ``(poly, den)``. - void fmpq_poly_pow(fmpq_poly_t res, const fmpq_poly_t poly, ulong e) noexcept - # Sets ``res`` to ``poly^e``, where the only special case `0^0` is - # defined as `1`. - void _fmpq_poly_pow_trunc(fmpz * res, fmpz_t rden, const fmpz * f, const fmpz_t fden, slong flen, ulong exp, slong len) noexcept - # Sets ``(rpoly, rden, len)`` to ``(poly, den)^e`` truncated to length ``len``, - # where ``len`` is at most ``e * (flen - 1) + 1``. - void fmpq_poly_pow_trunc(fmpq_poly_t res, const fmpq_poly_t poly, ulong e, slong n) noexcept - # Sets ``res`` to ``poly^e`` truncated to length ``n``. - void fmpq_poly_shift_left(fmpq_poly_t res, const fmpq_poly_t poly, slong n) noexcept - # Set ``res`` to ``poly`` shifted left by `n` coefficients. Zero - # coefficients are inserted. - void fmpq_poly_shift_right(fmpq_poly_t res, const fmpq_poly_t poly, slong n) noexcept - # Set ``res`` to ``poly`` shifted right by `n` coefficients. - # If `n` is equal to or greater than the current length of ``poly``, - # ``res`` is set to the zero polynomial. - void _fmpq_poly_divrem(fmpz * Q, fmpz_t q, fmpz * R, fmpz_t r, const fmpz * A, const fmpz_t a, slong lenA, const fmpz * B, const fmpz_t b, slong lenB, const fmpz_preinvn_t inv) noexcept - # Finds the quotient ``(Q, q)`` and remainder ``(R, r)`` of the - # Euclidean division of ``(A, a)`` by ``(B, b)``. - # Assumes that ``lenA >= lenB > 0``. Assumes that `R` has space for - # ``lenA`` coefficients, although only the bottom ``lenB - 1`` will - # carry meaningful data on exit. Supports no aliasing between the two - # outputs, or between the inputs and the outputs. - # An optional precomputed inverse of the leading coefficient of `B` from - # ``fmpz_preinvn_init`` can be supplied. Otherwise ``inv`` should be - # ``NULL``. - # Note: ``fmpz.h`` has to be included before ``fmpq_poly.h`` in order for the - # latter to declare this function. - void fmpq_poly_divrem(fmpq_poly_t Q, fmpq_poly_t R, const fmpq_poly_t poly1, const fmpq_poly_t poly2) noexcept - # Finds the quotient `Q` and remainder `R` of the Euclidean division of - # ``poly1`` by ``poly2``. - void _fmpq_poly_div(fmpz * Q, fmpz_t q, const fmpz * A, const fmpz_t a, slong lenA, const fmpz * B, const fmpz_t b, slong lenB, const fmpz_preinvn_t inv) noexcept - # Finds the quotient ``(Q, q)`` of the Euclidean division - # of ``(A, a)`` by ``(B, b)``. - # Assumes that ``lenA >= lenB > 0``. Supports no aliasing - # between the inputs and the outputs. - # An optional precomputed inverse of the leading coefficient of `B` from - # ``fmpz_preinvn_init`` can be supplied. Otherwise ``inv`` should be - # ``NULL``. - # Note: ``fmpz.h`` has to be included before ``fmpq_poly.h`` in order for the - # latter to declare this function. - void fmpq_poly_div(fmpq_poly_t Q, const fmpq_poly_t poly1, const fmpq_poly_t poly2) noexcept - # Finds the quotient `Q` and remainder `R` of the Euclidean division - # of ``poly1`` by ``poly2``. - void _fmpq_poly_rem(fmpz * R, fmpz_t r, const fmpz * A, const fmpz_t a, slong lenA, const fmpz * B, const fmpz_t b, slong lenB, const fmpz_preinvn_t inv) noexcept - # Finds the remainder ``(R, r)`` of the Euclidean division - # of ``(A, a)`` by ``(B, b)``. - # Assumes that ``lenA >= lenB > 0``. Supports no aliasing between - # the inputs and the outputs. - # An optional precomputed inverse of the leading coefficient of `B` from - # ``fmpz_preinvn_init`` can be supplied. Otherwise ``inv`` should be - # ``NULL``. - # Note: ``fmpz.h`` has to be included before ``fmpq_poly.h`` in order for the - # latter to declare this function. - void fmpq_poly_rem(fmpq_poly_t R, const fmpq_poly_t poly1, const fmpq_poly_t poly2) noexcept - # Finds the remainder `R` of the Euclidean division - # of ``poly1`` by ``poly2``. - fmpq_poly_struct * _fmpq_poly_powers_precompute(const fmpz * B, const fmpz_t denB, slong len) noexcept - # Computes ``2*len - 1`` powers of `x` modulo the polynomial `B` of - # the given length. This is used as a kind of precomputed inverse in - # the remainder routine below. - void fmpq_poly_powers_precompute(fmpq_poly_powers_precomp_t pinv, fmpq_poly_t poly) noexcept - # Computes ``2*len - 1`` powers of `x` modulo the polynomial `B` of the given length. This is used as a kind of precomputed inverse in the remainder routine below. - void _fmpq_poly_powers_clear(fmpq_poly_struct * powers, slong len) noexcept - # Clean up resources used by precomputed powers which have been computed - # by ``_fmpq_poly_powers_precompute``. - void fmpq_poly_powers_clear(fmpq_poly_powers_precomp_t pinv) noexcept - # Clean up resources used by precomputed powers which have been computed - # by ``fmpq_poly_powers_precompute``. - void _fmpq_poly_rem_powers_precomp(fmpz * A, fmpz_t denA, slong m, const fmpz * B, const fmpz_t denB, slong n, fmpq_poly_struct * const powers) noexcept - # Set `A` to the remainder of `A` divide `B` given precomputed powers mod `B` - # provided by ``_fmpq_poly_powers_precompute``. No aliasing is allowed. - # This function is only faster if `m \leq 2\cdot n - 1`. - # The output of this function is *not* canonicalised. - void fmpq_poly_rem_powers_precomp(fmpq_poly_t R, const fmpq_poly_t A, const fmpq_poly_t B, const fmpq_poly_powers_precomp_t B_inv) noexcept - # Set `R` to the remainder of `A` divide `B` given precomputed powers mod `B` - # provided by ``fmpq_poly_powers_precompute``. - # This function is only faster if ``A->length <= 2*B->length - 1``. - # The output of this function is *not* canonicalised. - int _fmpq_poly_divides(fmpz * qpoly, fmpz_t qden, const fmpz * poly1, const fmpz_t den1, slong len1, const fmpz * poly2, const fmpz_t den2, slong len2) noexcept - # Return `1` if ``(poly2, den2, len2)`` divides ``(poly1, den1, len1)`` and - # set ``(qpoly, qden, len1 - len2 + 1)`` to the quotient. Otherwise return - # `0`. Requires that ``qpoly`` has space for ``len1 - len2 + 1`` - # coefficients and that ``len1 >= len2 > 0``. - int fmpq_poly_divides(fmpq_poly_t q, const fmpq_poly_t poly1, const fmpq_poly_t poly2) noexcept - # Return `1` if ``poly2`` divides ``poly1`` and set ``q`` to the quotient. - # Otherwise return `0`. - slong fmpq_poly_remove(fmpq_poly_t q, const fmpq_poly_t poly1, const fmpq_poly_t poly2) noexcept - # Sets ``q`` to the quotient of ``poly1`` by the highest power of ``poly2`` - # which divides it, and returns the power. The divisor ``poly2`` must not be - # constant or an exception is raised. - void _fmpq_poly_inv_series_newton(fmpz * rpoly, fmpz_t rden, const fmpz * poly, const fmpz_t den, slong len, slong n) noexcept - # Computes the first `n` terms of the inverse power series of - # ``(poly, den, len)`` using Newton iteration. - # The result is produced in canonical form. - # Assumes that `n \geq 1` and that ``poly`` has non-zero constant term. - # Does not support aliasing. - void fmpq_poly_inv_series_newton(fmpq_poly_t res, const fmpq_poly_t poly, slong n) noexcept - # Computes the first `n` terms of the inverse power series - # of ``poly`` using Newton iteration, assuming that ``poly`` - # has non-zero constant term and `n \geq 1`. - void _fmpq_poly_inv_series(fmpz * rpoly, fmpz_t rden, const fmpz * poly, const fmpz_t den, slong den_len, slong n) noexcept - # Computes the first `n` terms of the inverse power series of - # ``(poly, den, len)``. - # The result is produced in canonical form. - # Assumes that `n \geq 1` and that ``poly`` has non-zero constant term. - # Does not support aliasing. - void fmpq_poly_inv_series(fmpq_poly_t res, const fmpq_poly_t poly, slong n) noexcept - # Computes the first `n` terms of the inverse power series of ``poly``, - # assuming that ``poly`` has non-zero constant term and `n \geq 1`. - void _fmpq_poly_div_series(fmpz * Q, fmpz_t denQ, const fmpz * A, const fmpz_t denA, slong lenA, const fmpz * B, const fmpz_t denB, slong lenB, slong n) noexcept - # Divides ``(A, denA, lenA)`` by ``(B, denB, lenB)`` as power series - # over `\mathbb{Q}`, assuming `B` has non-zero constant term and that - # all lengths are positive. - # Aliasing is not supported. - # This function ensures that the numerator and denominator - # are coprime on exit. - void fmpq_poly_div_series(fmpq_poly_t Q, const fmpq_poly_t A, const fmpq_poly_t B, slong n) noexcept - # Performs power series division in `\mathbb{Q}[[x]] / (x^n)`. The function - # considers the polynomials `A` and `B` as power series of length `n` - # starting with the constant terms. The function assumes that `B` has - # non-zero constant term and `n \geq 1`. - - void _fmpq_poly_gcd(fmpz *G, fmpz_t denG, const fmpz *A, slong lenA, const fmpz *B, slong lenB) noexcept - # Computes the monic greatest common divisor `G` of `A` and `B`. - # Assumes that `G` has space for `\operatorname{len}(B)` coefficients, - # where `\operatorname{len}(A) \geq \operatorname{len}(B) > 0`. - # Aliasing between the output and input arguments is not supported. - # Does not support zero-padding. - + void _fmpq_poly_gcd(fmpz * G, fmpz_t denG, const fmpz * A, slong lenA, const fmpz * B, slong lenB) noexcept void fmpq_poly_gcd(fmpq_poly_t G, const fmpq_poly_t A, const fmpq_poly_t B) noexcept - # Computes the monic greatest common divisor `G` of `A` and `B`. - # In the special case when `A = B = 0`, sets `G = 0`. - - void _fmpq_poly_xgcd(fmpz *G, fmpz_t denG, fmpz *S, fmpz_t denS, fmpz *T, fmpz_t denT, const fmpz *A, const fmpz_t denA, slong lenA, const fmpz *B, const fmpz_t denB, slong lenB) noexcept - # Computes polynomials `G`, `S`, and `T` such that - # `G = \gcd(A, B) = S A + T B`, where `G` is the monic - # greatest common divisor of `A` and `B`. - # Assumes that `G`, `S`, and `T` have space for `\operatorname{len}(B)`, - # `\operatorname{len}(B)`, and `\operatorname{len}(A)` coefficients, respectively, - # where it is also assumed that `\operatorname{len}(A) \geq \operatorname{len}(B) > 0`. - # Does not support zero padding of the input arguments. - + void _fmpq_poly_xgcd(fmpz * G, fmpz_t denG, fmpz * S, fmpz_t denS, fmpz * T, fmpz_t denT, const fmpz * A, const fmpz_t denA, slong lenA, const fmpz * B, const fmpz_t denB, slong lenB) noexcept void fmpq_poly_xgcd(fmpq_poly_t G, fmpq_poly_t S, fmpq_poly_t T, const fmpq_poly_t A, const fmpq_poly_t B) noexcept - # Computes polynomials `G`, `S`, and `T` such that - # `G = \gcd(A, B) = S A + T B`, where `G` is the monic - # greatest common divisor of `A` and `B`. - # Corner cases are handled as follows. If `A = B = 0`, returns - # `G = S = T = 0`. If `A \neq 0`, `B = 0`, returns the suitable - # scalar multiple of `G = A`, `S = 1`, and `T = 0`. The case - # when `A = 0`, `B \neq 0` is handled similarly. - - void _fmpq_poly_lcm(fmpz *L, fmpz_t denL, const fmpz *A, slong lenA, const fmpz *B, slong lenB) noexcept - # Computes the monic least common multiple `L` of `A` and `B`. - # Assumes that `L` has space for `\operatorname{len}(A) + \operatorname{len}(B) - 1` coefficients, - # where `\operatorname{len}(A) \geq \operatorname{len}(B) > 0`. - # Aliasing between the output and input arguments is not supported. - # Does not support zero-padding. - + void _fmpq_poly_lcm(fmpz * L, fmpz_t denL, const fmpz * A, slong lenA, const fmpz * B, slong lenB) noexcept void fmpq_poly_lcm(fmpq_poly_t L, const fmpq_poly_t A, const fmpq_poly_t B) noexcept - # Computes the monic least common multiple `L` of `A` and `B`. - # In the special case when `A = B = 0`, sets `L = 0`. - - void _fmpq_poly_resultant(fmpz_t rnum, fmpz_t rden, const fmpz *poly1, const fmpz_t den1, slong len1, const fmpz *poly2, const fmpz_t den2, slong len2) noexcept - # Sets ``(rnum, rden)`` to the resultant of the two input - # polynomials. - # Assumes that ``len1 >= len2 > 0``. Does not support zero-padding - # of the input polynomials. Does not support aliasing of the input and - # output arguments. - + void _fmpq_poly_resultant(fmpz_t rnum, fmpz_t rden, const fmpz * poly1, const fmpz_t den1, slong len1, const fmpz * poly2, const fmpz_t den2, slong len2) noexcept void fmpq_poly_resultant(fmpq_t r, const fmpq_poly_t f, const fmpq_poly_t g) noexcept - # Returns the resultant of `f` and `g`. - # Enumerating the roots of `f` and `g` over `\bar{\mathbf{Q}}` as - # `r_1, \dotsc, r_m` and `s_1, \dotsc, s_n`, respectively, and - # letting `x` and `y` denote the leading coefficients, the resultant - # is defined as - # .. math :: - # x^{\deg(f)} y^{\deg(g)} \prod_{1 \leq i, j \leq n} (r_i - s_j). - # We handle special cases as follows: if one of the polynomials is zero, - # the resultant is zero. Note that otherwise if one of the polynomials is - # constant, the last term in the above expression is the empty product. - void fmpq_poly_resultant_div(fmpq_t r, const fmpq_poly_t f, const fmpq_poly_t g, const fmpz_t div, slong nbits) noexcept - # Returns the resultant of `f` and `g` divided by ``div`` under the - # assumption that the result has at most ``nbits`` bits. The result must - # be an integer. - void _fmpq_poly_derivative(fmpz * rpoly, fmpz_t rden, const fmpz * poly, const fmpz_t den, slong len) noexcept - # Sets ``(rpoly, rden, len - 1)`` to the derivative of - # ``(poly, den, len)``. Does nothing if ``len <= 1``. - # Supports aliasing between the two polynomials. - void fmpq_poly_derivative(fmpq_poly_t res, const fmpq_poly_t poly) noexcept - # Sets ``res`` to the derivative of ``poly``. - void _fmpq_poly_nth_derivative(fmpz * rpoly, fmpz_t rden, const fmpz * poly, const fmpz_t den, ulong n, slong len) noexcept - # Sets ``(rpoly, rden, len - n)`` to the nth derivative of - # ``(poly, den, len)``. Does nothing if ``len <= n``. - # Supports aliasing between the two polynomials. - void fmpq_poly_nth_derivative(fmpq_poly_t res, const fmpq_poly_t poly, ulong n) noexcept - # Sets ``res`` to the nth derivative of ``poly``. - void _fmpq_poly_integral(fmpz * rpoly, fmpz_t rden, const fmpz * poly, const fmpz_t den, slong len) noexcept - # Sets ``(rpoly, rden, len)`` to the integral of - # ``(poly, den, len - 1)``. Assumes ``len >= 0``. - # Supports aliasing between the two polynomials. - # The output will be in canonical form if the input is - # in canonical form. - void fmpq_poly_integral(fmpq_poly_t res, const fmpq_poly_t poly) noexcept - # Sets ``res`` to the integral of ``poly``. The constant - # term is set to zero. In particular, the integral of the zero - # polynomial is the zero polynomial. - void _fmpq_poly_sqrt_series(fmpz * g, fmpz_t gden, const fmpz * f, const fmpz_t fden, slong flen, slong n) noexcept - # Sets ``(g, gden, n)`` to the series expansion of the - # square root of ``(f, fden, flen)``. Assumes ``n > 0`` and - # that ``(f, fden, flen)`` has constant term 1. - # Does not support aliasing between the input and output polynomials. - void fmpq_poly_sqrt_series(fmpq_poly_t res, const fmpq_poly_t f, slong n) noexcept - # Sets ``res`` to the series expansion of the square root of ``f`` - # to order ``n > 1``. Requires ``f`` to have constant term 1. - void _fmpq_poly_invsqrt_series(fmpz * g, fmpz_t gden, const fmpz * f, const fmpz_t fden, slong flen, slong n) noexcept - # Sets ``(g, gden, n)`` to the series expansion of the inverse - # square root of ``(f, fden, flen)``. Assumes ``n > 0`` and - # that ``(f, fden, flen)`` has constant term 1. - # Does not support aliasing between the input and output polynomials. - void fmpq_poly_invsqrt_series(fmpq_poly_t res, const fmpq_poly_t f, slong n) noexcept - # Sets ``res`` to the series expansion of the inverse square root of - # ``f`` to order ``n > 0``. Requires ``f`` to have constant term 1. - void _fmpq_poly_power_sums(fmpz * res, fmpz_t rden, const fmpz * poly, slong len, slong n) noexcept - # Compute the (truncated) power sums series of the polynomial - # ``(poly,len)`` up to length `n` using Newton identities. - void fmpq_poly_power_sums(fmpq_poly_t res, const fmpq_poly_t poly, slong n) noexcept - # Compute the (truncated) power sum series of the monic polynomial - # ``poly`` up to length `n` using Newton identities. That is the power - # series whose coefficient of degree `i` is the sum of the `i`-th power of - # all (complex) roots of the polynomial ``poly``. - void _fmpq_poly_power_sums_to_poly(fmpz * res, const fmpz * poly, const fmpz_t den, slong len) noexcept - # Compute an integer polynomial given by its power sums series ``(poly,den,len)``. - void fmpq_poly_power_sums_to_fmpz_poly(fmpz_poly_t res, const fmpq_poly_t Q) noexcept - # Compute the integer polynomial with content one and positive leading - # coefficient given by its power sums series ``Q``. - void fmpq_poly_power_sums_to_poly(fmpq_poly_t res, const fmpq_poly_t Q) noexcept - # Compute the monic polynomial from its power sums series ``Q``. - void _fmpq_poly_log_series(fmpz * g, fmpz_t gden, const fmpz * f, const fmpz_t fden, slong flen, slong n) noexcept - # Sets ``(g, gden, n)`` to the series expansion of the - # logarithm of ``(f, fden, flen)``. Assumes ``n > 0`` and - # that ``(f, fden, flen)`` has constant term 1. - # Supports aliasing between the input and output polynomials. - void fmpq_poly_log_series(fmpq_poly_t res, const fmpq_poly_t f, slong n) noexcept - # Sets ``res`` to the series expansion of the logarithm of ``f`` - # to order ``n > 0``. Requires ``f`` to have constant term 1. - void _fmpq_poly_exp_series(fmpz * g, fmpz_t gden, const fmpz * h, const fmpz_t hden, slong hlen, slong n) noexcept - # Sets ``(g, gden, n)`` to the series expansion of the - # exponential function of ``(h, hden, hlen)``. Assumes - # ``n > 0, hlen > 0`` and - # that ``(h, hden, hlen)`` has constant term 0. - # Supports aliasing between the input and output polynomials. - void fmpq_poly_exp_series(fmpq_poly_t res, const fmpq_poly_t h, slong n) noexcept - # Sets ``res`` to the series expansion of the exponential function - # of ``h`` to order ``n > 0``. Requires ``f`` to have - # constant term 0. - void _fmpq_poly_exp_expinv_series(fmpz * res1, fmpz_t res1den, fmpz * res2, fmpz_t res2den, const fmpz * h, const fmpz_t hden, slong hlen, slong n) noexcept - # The same as ``fmpq_poly_exp_series``, but simultaneously computes - # the exponential (in ``res1``, ``res1den``) and its multiplicative inverse - # (in ``res2``, ``res2den``). - # Supports aliasing between the input and output polynomials. - void fmpq_poly_exp_expinv_series(fmpq_poly_t res1, fmpq_poly_t res2, const fmpq_poly_t h, slong n) noexcept - # The same as ``fmpq_poly_exp_series``, but simultaneously computes - # the exponential (in ``res1``) and its multiplicative inverse - # (in ``res2``). - void _fmpq_poly_atan_series(fmpz * g, fmpz_t gden, const fmpz * f, const fmpz_t fden, slong flen, slong n) noexcept - # Sets ``(g, gden, n)`` to the series expansion of the - # inverse tangent of ``(f, fden, flen)``. Assumes ``n > 0`` and - # that ``(f, fden, flen)`` has constant term 0. - # Supports aliasing between the input and output polynomials. - void fmpq_poly_atan_series(fmpq_poly_t res, const fmpq_poly_t f, slong n) noexcept - # Sets ``res`` to the series expansion of the inverse tangent of ``f`` - # to order ``n > 0``. Requires ``f`` to have constant term 0. - void _fmpq_poly_atanh_series(fmpz * g, fmpz_t gden, const fmpz * f, const fmpz_t fden, slong flen, slong n) noexcept - # Sets ``(g, gden, n)`` to the series expansion of the inverse - # hyperbolic tangent of ``(f, fden, flen)``. Assumes ``n > 0`` and - # that ``(f, fden, flen)`` has constant term 0. - # Supports aliasing between the input and output polynomials. - void fmpq_poly_atanh_series(fmpq_poly_t res, const fmpq_poly_t f, slong n) noexcept - # Sets ``res`` to the series expansion of the inverse hyperbolic - # tangent of ``f`` to order ``n > 0``. Requires ``f`` to have - # constant term 0. - void _fmpq_poly_asin_series(fmpz * g, fmpz_t gden, const fmpz * f, const fmpz_t fden, slong flen, slong n) noexcept - # Sets ``(g, gden, n)`` to the series expansion of the - # inverse sine of ``(f, fden, flen)``. Assumes ``n > 0`` and - # that ``(f, fden, flen)`` has constant term 0. - # Supports aliasing between the input and output polynomials. - void fmpq_poly_asin_series(fmpq_poly_t res, const fmpq_poly_t f, slong n) noexcept - # Sets ``res`` to the series expansion of the inverse sine of ``f`` - # to order ``n > 0``. Requires ``f`` to have constant term 0. - void _fmpq_poly_asinh_series(fmpz * g, fmpz_t gden, const fmpz * f, const fmpz_t fden, slong flen, slong n) noexcept - # Sets ``(g, gden, n)`` to the series expansion of the inverse - # hyperbolic sine of ``(f, fden, flen)``. Assumes ``n > 0`` and - # that ``(f, fden, flen)`` has constant term 0. - # Supports aliasing between the input and output polynomials. - void fmpq_poly_asinh_series(fmpq_poly_t res, const fmpq_poly_t f, slong n) noexcept - # Sets ``res`` to the series expansion of the inverse hyperbolic - # sine of ``f`` to order ``n > 0``. Requires ``f`` to have - # constant term 0. - void _fmpq_poly_tan_series(fmpz * g, fmpz_t gden, const fmpz * f, const fmpz_t fden, slong flen, slong n) noexcept - # Sets ``(g, gden, n)`` to the series expansion of the - # tangent function of ``(f, fden, flen)``. Assumes ``n > 0`` and - # that ``(f, fden, flen)`` has constant term 0. - # Does not support aliasing between the input and output polynomials. - void fmpq_poly_tan_series(fmpq_poly_t res, const fmpq_poly_t f, slong n) noexcept - # Sets ``res`` to the series expansion of the tangent function - # of ``f`` to order ``n > 0``. Requires ``f`` to have - # constant term 0. - void _fmpq_poly_sin_series(fmpz * g, fmpz_t gden, const fmpz * f, const fmpz_t fden, slong flen, slong n) noexcept - # Sets ``(g, gden, n)`` to the series expansion of the - # sine of ``(f, fden, flen)``. Assumes ``n > 0`` and - # that ``(f, fden, flen)`` has constant term 0. - # Supports aliasing between the input and output polynomials. - void fmpq_poly_sin_series(fmpq_poly_t res, const fmpq_poly_t f, slong n) noexcept - # Sets ``res`` to the series expansion of the sine of ``f`` - # to order ``n > 0``. Requires ``f`` to have constant term 0. - void _fmpq_poly_cos_series(fmpz * g, fmpz_t gden, const fmpz * f, const fmpz_t fden, slong flen, slong n) noexcept - # Sets ``(g, gden, n)`` to the series expansion of the - # cosine of ``(f, fden, flen)``. Assumes ``n > 0`` and - # that ``(f, fden, flen)`` has constant term 0. - # Supports aliasing between the input and output polynomials. - void fmpq_poly_cos_series(fmpq_poly_t res, const fmpq_poly_t f, slong n) noexcept - # Sets ``res`` to the series expansion of the cosine of ``f`` - # to order ``n > 0``. Requires ``f`` to have constant term 0. - void _fmpq_poly_sin_cos_series(fmpz * s, fmpz_t sden, fmpz * c, fmpz_t cden, const fmpz * f, const fmpz_t fden, slong flen, slong n) noexcept - # Sets ``(s, sden, n)`` to the series expansion of the - # sine of ``(f, fden, flen)``, and ``(c, cden, n)`` to the series - # expansion of the cosine. Assumes ``n > 0`` and - # that ``(f, fden, flen)`` has constant term 0. - # Supports aliasing between the input and output polynomials. - void fmpq_poly_sin_cos_series(fmpq_poly_t res1, fmpq_poly_t res2, const fmpq_poly_t f, slong n) noexcept - # Sets ``res1`` to the series expansion of the sine of ``f`` - # to order ``n > 0``, and ``res2`` to the series expansion - # of the cosine. Requires ``f`` to have constant term 0. - void _fmpq_poly_sinh_series(fmpz * g, fmpz_t gden, const fmpz * f, const fmpz_t fden, slong flen, slong n) noexcept - # Sets ``(g, gden, n)`` to the series expansion of the - # hyperbolic sine of ``(f, fden, flen)``. Assumes ``n > 0`` and - # that ``(f, fden, flen)`` has constant term 0. - # Does not support aliasing between the input and output polynomials. - void fmpq_poly_sinh_series(fmpq_poly_t res, const fmpq_poly_t f, slong n) noexcept - # Sets ``res`` to the series expansion of the hyperbolic sine of ``f`` - # to order ``n > 0``. Requires ``f`` to have constant term 0. - void _fmpq_poly_cosh_series(fmpz * g, fmpz_t gden, const fmpz * f, const fmpz_t fden, slong flen, slong n) noexcept - # Sets ``(g, gden, n)`` to the series expansion of the hyperbolic - # cosine of ``(f, fden, flen)``. Assumes ``n > 0`` and - # that ``(f, fden, flen)`` has constant term 0. - # Does not support aliasing between the input and output polynomials. - void fmpq_poly_cosh_series(fmpq_poly_t res, const fmpq_poly_t f, slong n) noexcept - # Sets ``res`` to the series expansion of the hyperbolic cosine of - # ``f`` to order ``n > 0``. Requires ``f`` to have constant term 0. - void _fmpq_poly_sinh_cosh_series(fmpz * s, fmpz_t sden, fmpz * c, fmpz_t cden, const fmpz * f, const fmpz_t fden, slong flen, slong n) noexcept - # Sets ``(s, sden, n)`` to the series expansion of the hyperbolic - # sine of ``(f, fden, flen)``, and ``(c, cden, n)`` to the series - # expansion of the hyperbolic cosine. Assumes ``n > 0`` and - # that ``(f, fden, flen)`` has constant term 0. - # Supports aliasing between the input and output polynomials. - void fmpq_poly_sinh_cosh_series(fmpq_poly_t res1, fmpq_poly_t res2, const fmpq_poly_t f, slong n) noexcept - # Sets ``res1`` to the series expansion of the hyperbolic sine of ``f`` - # to order ``n > 0``, and ``res2`` to the series expansion - # of the hyperbolic cosine. Requires ``f`` to have constant term 0. - void _fmpq_poly_tanh_series(fmpz * g, fmpz_t gden, const fmpz * f, const fmpz_t fden, slong flen, slong n) noexcept - # Sets ``(g, gden, n)`` to the series expansion of the - # hyperbolic tangent of ``(f, fden, flen)``. Assumes ``n > 0`` and - # that ``(f, fden, flen)`` has constant term 0. - # Does not support aliasing between the input and output polynomials. - void fmpq_poly_tanh_series(fmpq_poly_t res, const fmpq_poly_t f, slong n) noexcept - # Sets ``res`` to the series expansion of the hyperbolic tangent of - # ``f`` to order ``n > 0``. Requires ``f`` to have constant term 0. - void _fmpq_poly_legendre_p(fmpz * coeffs, fmpz_t den, ulong n) noexcept - # Sets ``coeffs`` to the coefficient array of the Legendre polynomial - # `P_n(x)`, defined by `(n+1) P_{n+1}(x) = (2n+1) x P_n(x) - n P_{n-1}(x)`, - # for `n\ge0`. Sets ``den`` to the overall denominator. - # The coefficients are calculated using a hypergeometric recurrence. - # The length of the array will be ``n+1``. - # To improve performance, the common denominator is computed in one step - # and the coefficients are evaluated using integer arithmetic. The - # denominator is given by - # `\gcd(n!,2^n) = 2^{\lfloor n/2 \rfloor + \lfloor n/4 \rfloor + \ldots}.` - # See ``fmpz_poly`` for the shifted Legendre polynomials. - void fmpq_poly_legendre_p(fmpq_poly_t poly, ulong n) noexcept - # Sets ``poly`` to the Legendre polynomial `P_n(x)`, defined - # by `(n+1) P_{n+1}(x) = (2n+1) x P_n(x) - n P_{n-1}(x)`, for `n\ge0`. - # The coefficients are calculated using a hypergeometric recurrence. - # To improve performance, the common denominator is computed in one step - # and the coefficients are evaluated using integer arithmetic. The - # denominator is given by - # `\gcd(n!,2^n) = 2^{\lfloor n/2 \rfloor + \lfloor n/4 \rfloor + \ldots}.` - # See ``fmpz_poly`` for the shifted Legendre polynomials. - void _fmpq_poly_laguerre_l(fmpz * coeffs, fmpz_t den, ulong n) noexcept - # Sets ``coeffs`` to the coefficient array of the Laguerre polynomial - # `L_n(x)`, defined by `(n+1) L_{n+1}(x) = (2n+1-x) L_n(x) - n L_{n-1}(x)`, - # for `n\ge0`. Sets ``den`` to the overall denominator. - # The coefficients are calculated using a hypergeometric recurrence. - # The length of the array will be ``n+1``. - void fmpq_poly_laguerre_l(fmpq_poly_t poly, ulong n) noexcept - # Sets ``poly`` to the Laguerre polynomial `L_n(x)`, defined by - # `(n+1) L_{n+1}(x) = (2n+1-x) L_n(x) - n L_{n-1}(x)`, for `n\ge0`. - # The coefficients are calculated using a hypergeometric recurrence. - void _fmpq_poly_gegenbauer_c(fmpz * coeffs, fmpz_t den, ulong n, const fmpq_t a) noexcept - # Sets ``coeffs`` to the coefficient array of the Gegenbauer - # (ultraspherical) polynomial - # `C^{(\alpha)}_n(x) = \frac{(2\alpha)_n}{n!}{}_2F_1\left(-n,2\alpha+n; - # \alpha+\frac12;\frac{1-x}{2}\right)`, for integer `n\ge0` and rational - # `\alpha>0`. Sets ``den`` to the overall denominator. - # The coefficients are calculated using a hypergeometric recurrence. - void fmpq_poly_gegenbauer_c(fmpq_poly_t poly, ulong n, const fmpq_t a) noexcept - # Sets ``poly`` to the Gegenbauer (ultraspherical) polynomial - # `C^{(\alpha)}_n(x) = \frac{(2\alpha)_n}{n!}{}_2F_1\left(-n,2\alpha+n; - # \alpha+\frac12;\frac{1-x}{2}\right)`, for integer `n\ge0` and rational - # `\alpha>0`. - # The coefficients are calculated using a hypergeometric recurrence. - void _fmpq_poly_evaluate_fmpz(fmpz_t rnum, fmpz_t rden, const fmpz * poly, const fmpz_t den, slong len, const fmpz_t a) noexcept - # Evaluates the polynomial ``(poly, den, len)`` at the integer `a` and - # sets ``(rnum, rden)`` to the result in lowest terms. - void fmpq_poly_evaluate_fmpz(fmpq_t res, const fmpq_poly_t poly, const fmpz_t a) noexcept - # Evaluates the polynomial ``poly`` at the integer `a` and sets - # ``res`` to the result. - void _fmpq_poly_evaluate_fmpq(fmpz_t rnum, fmpz_t rden, const fmpz * poly, const fmpz_t den, slong len, const fmpz_t anum, const fmpz_t aden) noexcept - # Evaluates the polynomial ``(poly, den, len)`` at the rational - # ``(anum, aden)`` and sets ``(rnum, rden)`` to the result in - # lowest terms. Aliasing between ``(rnum, rden)`` and - # ``(anum, aden)`` is not supported. - void fmpq_poly_evaluate_fmpq(fmpq_t res, const fmpq_poly_t poly, const fmpq_t a) noexcept - # Evaluates the polynomial ``poly`` at the rational `a` and - # sets ``res`` to the result. - void _fmpq_poly_interpolate_fmpz_vec(fmpz * poly, fmpz_t den, const fmpz * xs, const fmpz * ys, slong n) noexcept - # Sets ``poly`` / ``den`` to the unique interpolating polynomial of - # degree at most `n - 1` satisfying `f(x_i) = y_i` for every pair `x_i, y_i` - # in ``xs`` and ``ys``. - # The vector ``poly`` must have room for ``n+1`` coefficients, - # even if the interpolating polynomial is shorter. - # Aliasing of ``poly`` or ``den`` with any other argument is not - # allowed. - # It is assumed that the `x` values are distinct. - # This function uses a simple `O(n^2)` implementation of Lagrange - # interpolation, clearing denominators to avoid working with fractions. - # It is currently not designed to be efficient for large `n`. - void fmpq_poly_interpolate_fmpz_vec(fmpq_poly_t poly, const fmpz * xs, const fmpz * ys, slong n) noexcept - # Sets ``poly`` to the unique interpolating polynomial of degree - # at most `n - 1` satisfying `f(x_i) = y_i` for every pair `x_i, y_i` - # in ``xs`` and ``ys``. It is assumed that the `x` values are distinct. - void _fmpq_poly_compose(fmpz * res, fmpz_t den, const fmpz * poly1, const fmpz_t den1, slong len1, const fmpz * poly2, const fmpz_t den2, slong len2) noexcept - # Sets ``(res, den)`` to the composition of ``(poly1, den1, len1)`` - # and ``(poly2, den2, len2)``, assuming ``len1, len2 > 0``. - # Assumes that ``res`` has space for ``(len1 - 1) * (len2 - 1) + 1`` - # coefficients. Does not support aliasing. - void fmpq_poly_compose(fmpq_poly_t res, const fmpq_poly_t poly1, const fmpq_poly_t poly2) noexcept - # Sets ``res`` to the composition of ``poly1`` and ``poly2``. - void _fmpq_poly_rescale(fmpz * res, fmpz_t denr, const fmpz * poly, const fmpz_t den, slong len, const fmpz_t anum, const fmpz_t aden) noexcept - # Sets ``(res, denr, len)`` to ``(poly, den, len)`` with the - # indeterminate rescaled by ``(anum, aden)``. - # Assumes that ``len > 0`` and that ``(anum, aden)`` is non-zero and - # in lowest terms. Supports aliasing between ``(res, denr, len)`` and - # ``(poly, den, len)``. - void fmpq_poly_rescale(fmpq_poly_t res, const fmpq_poly_t poly, const fmpq_t a) noexcept - # Sets ``res`` to ``poly`` with the indeterminate rescaled by `a`. - void _fmpq_poly_compose_series_horner(fmpz * res, fmpz_t den, const fmpz * poly1, const fmpz_t den1, slong len1, const fmpz * poly2, const fmpz_t den2, slong len2, slong n) noexcept - # Sets ``(res, den, n)`` to the composition of - # ``(poly1, den1, len1)`` and ``(poly2, den2, len2)`` modulo `x^n`, - # where the constant term of ``poly2`` is required to be zero. - # Assumes that ``len1, len2, n > 0``, that ``len1, len2 <= n``, - # that ``(len1-1) * (len2-1) + 1 <= n``, and that ``res`` has - # space for ``n`` coefficients. Does not support aliasing between any - # of the inputs and the output. - # This implementation uses the Horner scheme. - # The default ``fmpz_poly`` composition algorithm is automatically - # used when the composition can be performed over the integers. - void fmpq_poly_compose_series_horner(fmpq_poly_t res, const fmpq_poly_t poly1, const fmpq_poly_t poly2, slong n) noexcept - # Sets ``res`` to the composition of ``poly1`` and ``poly2`` - # modulo `x^n`, where the constant term of ``poly2`` is required - # to be zero. - # This implementation uses the Horner scheme. - # The default ``fmpz_poly`` composition algorithm is automatically - # used when the composition can be performed over the integers. - void _fmpq_poly_compose_series_brent_kung(fmpz * res, fmpz_t den, const fmpz * poly1, const fmpz_t den1, slong len1, const fmpz * poly2, const fmpz_t den2, slong len2, slong n) noexcept - # Sets ``(res, den, n)`` to the composition of - # ``(poly1, den1, len1)`` and ``(poly2, den2, len2)`` modulo `x^n`, - # where the constant term of ``poly2`` is required to be zero. - # Assumes that ``len1, len2, n > 0``, that ``len1, len2 <= n``, - # that ``(len1-1) * (len2-1) + 1 <= n``, and that ``res`` has - # space for ``n`` coefficients. Does not support aliasing between any - # of the inputs and the output. - # This implementation uses Brent-Kung algorithm 2.1 [BrentKung1978]_. - # The default ``fmpz_poly`` composition algorithm is automatically - # used when the composition can be performed over the integers. - void fmpq_poly_compose_series_brent_kung(fmpq_poly_t res, const fmpq_poly_t poly1, const fmpq_poly_t poly2, slong n) noexcept - # Sets ``res`` to the composition of ``poly1`` and ``poly2`` - # modulo `x^n`, where the constant term of ``poly2`` is required - # to be zero. - # This implementation uses Brent-Kung algorithm 2.1 [BrentKung1978]_. - # The default ``fmpz_poly`` composition algorithm is automatically - # used when the composition can be performed over the integers. - void _fmpq_poly_compose_series(fmpz * res, fmpz_t den, const fmpz * poly1, const fmpz_t den1, slong len1, const fmpz * poly2, const fmpz_t den2, slong len2, slong n) noexcept - # Sets ``(res, den, n)`` to the composition of - # ``(poly1, den1, len1)`` and ``(poly2, den2, len2)`` modulo `x^n`, - # where the constant term of ``poly2`` is required to be zero. - # Assumes that ``len1, len2, n > 0``, that ``len1, len2 <= n``, - # that ``(len1-1) * (len2-1) + 1 <= n``, and that ``res`` has - # space for ``n`` coefficients. Does not support aliasing between any - # of the inputs and the output. - # This implementation automatically switches between the Horner scheme - # and Brent-Kung algorithm 2.1 depending on the size of the inputs. - # The default ``fmpz_poly`` composition algorithm is automatically - # used when the composition can be performed over the integers. - void fmpq_poly_compose_series(fmpq_poly_t res, const fmpq_poly_t poly1, const fmpq_poly_t poly2, slong n) noexcept - # Sets ``res`` to the composition of ``poly1`` and ``poly2`` - # modulo `x^n`, where the constant term of ``poly2`` is required - # to be zero. - # This implementation automatically switches between the Horner scheme - # and Brent-Kung algorithm 2.1 depending on the size of the inputs. - # The default ``fmpz_poly`` composition algorithm is automatically - # used when the composition can be performed over the integers. - void _fmpq_poly_revert_series_lagrange(fmpz * res, fmpz_t den, const fmpz * poly1, const fmpz_t den1, slong len1, slong n) noexcept - # Sets ``(res, den)`` to the power series reversion of - # ``(poly1, den1, len1)`` modulo `x^n`. - # The constant term of ``poly2`` is required to be zero and - # the linear term is required to be nonzero. Assumes that `n > 0`. - # Does not support aliasing between any of the inputs and the output. - # This implementation uses the Lagrange inversion formula. - # The default ``fmpz_poly`` reversion algorithm is automatically - # used when the reversion can be performed over the integers. - void fmpq_poly_revert_series_lagrange(fmpq_poly_t res, const fmpq_poly_t poly, slong n) noexcept - # Sets ``res`` to the power series reversion of ``poly1`` modulo `x^n`. - # The constant term of ``poly2`` is required to be zero and - # the linear term is required to be nonzero. - # This implementation uses the Lagrange inversion formula. - # The default ``fmpz_poly`` reversion algorithm is automatically - # used when the reversion can be performed over the integers. - void _fmpq_poly_revert_series_lagrange_fast(fmpz * res, fmpz_t den, const fmpz * poly1, const fmpz_t den1, slong len1, slong n) noexcept - # Sets ``(res, den)`` to the power series reversion of - # ``(poly1, den1, len1)`` modulo `x^n`. - # The constant term of ``poly2`` is required to be zero and - # the linear term is required to be nonzero. Assumes that `n > 0`. - # Does not support aliasing between any of the inputs and the output. - # This implementation uses a reduced-complexity implementation - # of the Lagrange inversion formula. - # The default ``fmpz_poly`` reversion algorithm is automatically - # used when the reversion can be performed over the integers. - void fmpq_poly_revert_series_lagrange_fast(fmpq_poly_t res, const fmpq_poly_t poly, slong n) noexcept - # Sets ``res`` to the power series reversion of ``poly1`` modulo `x^n`. - # The constant term of ``poly2`` is required to be zero and - # the linear term is required to be nonzero. - # This implementation uses a reduced-complexity implementation - # of the Lagrange inversion formula. - # The default ``fmpz_poly`` reversion algorithm is automatically - # used when the reversion can be performed over the integers. - void _fmpq_poly_revert_series_newton(fmpz * res, fmpz_t den, const fmpz * poly1, const fmpz_t den1, slong len1, slong n) noexcept - # Sets ``(res, den)`` to the power series reversion of - # ``(poly1, den1, len1)`` modulo `x^n`. - # The constant term of ``poly2`` is required to be zero and - # the linear term is required to be nonzero. Assumes that `n > 0`. - # Does not support aliasing between any of the inputs and the output. - # This implementation uses Newton iteration. - # The default ``fmpz_poly`` reversion algorithm is automatically - # used when the reversion can be performed over the integers. - void fmpq_poly_revert_series_newton(fmpq_poly_t res, const fmpq_poly_t poly, slong n) noexcept - # Sets ``res`` to the power series reversion of ``poly1`` modulo `x^n`. - # The constant term of ``poly2`` is required to be zero and - # the linear term is required to be nonzero. - # This implementation uses Newton iteration. - # The default ``fmpz_poly`` reversion algorithm is automatically - # used when the reversion can be performed over the integers. - void _fmpq_poly_revert_series(fmpz * res, fmpz_t den, const fmpz * poly1, const fmpz_t den1, slong len1, slong n) noexcept - # Sets ``(res, den)`` to the power series reversion of - # ``(poly1, den1, len1)`` modulo `x^n`. - # The constant term of ``poly2`` is required to be zero and - # the linear term is required to be nonzero. Assumes that `n > 0`. - # Does not support aliasing between any of the inputs and the output. - # This implementation defaults to using Newton iteration. - # The default ``fmpz_poly`` reversion algorithm is automatically - # used when the reversion can be performed over the integers. - void fmpq_poly_revert_series(fmpq_poly_t res, const fmpq_poly_t poly, slong n) noexcept - # Sets ``res`` to the power series reversion of ``poly1`` modulo `x^n`. - # The constant term of ``poly2`` is required to be zero and - # the linear term is required to be nonzero. - # This implementation defaults to using Newton iteration. - # The default ``fmpz_poly`` reversion algorithm is automatically - # used when the reversion can be performed over the integers. - void _fmpq_poly_content(fmpq_t res, const fmpz * poly, const fmpz_t den, slong len) noexcept - # Sets ``res`` to the content of ``(poly, den, len)``. - # If ``len == 0``, sets ``res`` to zero. - void fmpq_poly_content(fmpq_t res, const fmpq_poly_t poly) noexcept - # Sets ``res`` to the content of ``poly``. The content of the zero - # polynomial is defined to be zero. - void _fmpq_poly_primitive_part(fmpz * rpoly, fmpz_t rden, const fmpz * poly, const fmpz_t den, slong len) noexcept - # Sets ``(rpoly, rden, len)`` to the primitive part, with non-negative - # leading coefficient, of ``(poly, den, len)``. Assumes that - # ``len > 0``. Supports aliasing between the two polynomials. - void fmpq_poly_primitive_part(fmpq_poly_t res, const fmpq_poly_t poly) noexcept - # Sets ``res`` to the primitive part, with non-negative leading - # coefficient, of ``poly``. - bint _fmpq_poly_is_monic(const fmpz * poly, const fmpz_t den, slong len) noexcept - # Returns whether the polynomial ``(poly, den, len)`` is monic. - # The zero polynomial is not monic by definition. - bint fmpq_poly_is_monic(const fmpq_poly_t poly) noexcept - # Returns whether the polynomial ``poly`` is monic. The zero - # polynomial is not monic by definition. - void _fmpq_poly_make_monic(fmpz * rpoly, fmpz_t rden, const fmpz * poly, const fmpz_t den, slong len) noexcept - # Sets ``(rpoly, rden, len)`` to the monic scalar multiple of - # ``(poly, den, len)``. Assumes that ``len > 0``. Supports - # aliasing between the two polynomials. - void fmpq_poly_make_monic(fmpq_poly_t res, const fmpq_poly_t poly) noexcept - # Sets ``res`` to the monic scalar multiple of ``poly`` whenever - # ``poly`` is non-zero. If ``poly`` is the zero polynomial, sets - # ``res`` to zero. - bint fmpq_poly_is_squarefree(const fmpq_poly_t poly) noexcept - # Returns whether the polynomial ``poly`` is square-free. A non-zero - # polynomial is defined to be square-free if it has no non-unit square - # factors. We also define the zero polynomial to be square-free. - int _fmpq_poly_print(const fmpz * poly, const fmpz_t den, slong len) noexcept - # Prints the polynomial ``(poly, den, len)`` to ``stdout``. - # In case of success, returns a positive value. In case of failure, - # returns a non-positive value. - int fmpq_poly_print(const fmpq_poly_t poly) noexcept - # Prints the polynomial to ``stdout``. - # In case of success, returns a positive value. In case of failure, - # returns a non-positive value. - - int _fmpq_poly_print_pretty(const fmpz *poly, const fmpz_t den, slong len, const char * x) noexcept - + int _fmpq_poly_print_pretty(const fmpz * poly, const fmpz_t den, slong len, const char * x) noexcept int fmpq_poly_print_pretty(const fmpq_poly_t poly, const char * var) noexcept - # Prints the pretty representation of ``poly`` to ``stdout``, using - # the null-terminated string ``var`` not equal to ``"\0"`` as the - # variable name. - # In the current implementation always returns `1`. - int _fmpq_poly_fprint(FILE * file, const fmpz * poly, const fmpz_t den, slong len) noexcept - # Prints the polynomial ``(poly, den, len)`` to the stream ``file``. - # In case of success, returns a positive value. In case of failure, - # returns a non-positive value. - int fmpq_poly_fprint(FILE * file, const fmpq_poly_t poly) noexcept - # Prints the polynomial to the stream ``file``. - # In case of success, returns a positive value. In case of failure, - # returns a non-positive value. - - int _fmpq_poly_fprint_pretty(FILE * file, const fmpz *poly, const fmpz_t den, slong len, const char * x) noexcept - + int _fmpq_poly_fprint_pretty(FILE * file, const fmpz * poly, const fmpz_t den, slong len, const char * x) noexcept int fmpq_poly_fprint_pretty(FILE * file, const fmpq_poly_t poly, const char * var) noexcept - # Prints the pretty representation of ``poly`` to ``stdout``, using - # the null-terminated string ``var`` not equal to ``"\0"`` as the - # variable name. - # In the current implementation, always returns `1`. - int fmpq_poly_read(fmpq_poly_t poly) noexcept - # Reads a polynomial from ``stdin``, storing the result - # in ``poly``. - # In case of success, returns a positive number. In case of failure, - # returns a non-positive value. - int fmpq_poly_fread(FILE * file, fmpq_poly_t poly) noexcept - # Reads a polynomial from the stream ``file``, storing the result - # in ``poly``. - # In case of success, returns a positive number. In case of failure, - # returns a non-positive value. diff --git a/src/sage/libs/flint/fmpq_vec.pxd b/src/sage/libs/flint/fmpq_vec.pxd index f3d7e367f1c..6606e041d58 100644 --- a/src/sage/libs/flint/fmpq_vec.pxd +++ b/src/sage/libs/flint/fmpq_vec.pxd @@ -2,7 +2,9 @@ # distutils: depends = flint/fmpq_vec.h ################################################################################ -# This file is auto-generated. Do not modify by hand +# This file is auto-generated by the script +# SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py. +# Do not modify by hand! Fix and rerun the script instead. ################################################################################ from libc.stdio cimport FILE @@ -11,45 +13,13 @@ from sage.libs.mpfr.types cimport * from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - fmpq * _fmpq_vec_init(slong n) noexcept - # Initialises a vector of ``fmpq`` values of length `n` and sets - # all values to 0. This is equivalent to generating a ``fmpz`` vector - # of length `2n` with ``_fmpz_vec_init`` and setting all denominators - # to 1. - void _fmpq_vec_clear(fmpq * vec, slong n) noexcept - # Frees an ``fmpq`` vector. - void _fmpq_vec_randtest(fmpq * f, flint_rand_t state, slong len, flint_bitcnt_t bits) noexcept - # Sets the entries of a vector of the given length to random rationals with - # numerator and denominator having up to the given number of bits per entry. - void _fmpq_vec_randtest_uniq_sorted(fmpq * vec, flint_rand_t state, slong len, flint_bitcnt_t bits) noexcept - # Sets the entries of a vector of the given length to random distinct - # rationals with numerator and denominator having up to the given number - # of bits per entry. The entries in the vector are sorted. - void _fmpq_vec_sort(fmpq * vec, slong len) noexcept - # Sorts the entries of ``(vec, len)``. - void _fmpq_vec_set_fmpz_vec(fmpq * res, const fmpz * vec, slong len) noexcept - # Sets ``(res, len)`` to ``(vec, len)``. - - void _fmpq_vec_get_fmpz_vec_fmpz(fmpz* num, fmpz_t den, const fmpq * a, slong len) noexcept - # Find a common denominator ``den`` of the entries of ``a`` and set ``(num, len)`` to the corresponding numerators. - + void _fmpq_vec_get_fmpz_vec_fmpz(fmpz * num, fmpz_t den, const fmpq * a, slong len) noexcept void _fmpq_vec_dot(fmpq_t res, const fmpq * vec1, const fmpq * vec2, slong len) noexcept - # Sets ``res`` to the dot product of the vectors ``(vec1, len)`` and - # ``(vec2, len)``. - int _fmpq_vec_fprint(FILE * file, const fmpq * vec, slong len) noexcept - # Prints the vector of given length to the stream ``file``. The - # format is the length followed by two spaces, then a space separated - # list of coefficients. If the length is zero, only `0` is printed. - # In case of success, returns a positive value. In case of failure, - # returns a non-positive value. - int _fmpq_vec_print(const fmpq * vec, slong len) noexcept - # Prints the vector of given length to ``stdout``. - # For further details, see :func:`_fmpq_vec_fprint()`. diff --git a/src/sage/libs/flint/fmpz.pxd b/src/sage/libs/flint/fmpz.pxd index 38c973e8f5c..237ac135cd9 100644 --- a/src/sage/libs/flint/fmpz.pxd +++ b/src/sage/libs/flint/fmpz.pxd @@ -2,7 +2,9 @@ # distutils: depends = flint/fmpz.h ################################################################################ -# This file is auto-generated. Do not modify by hand +# This file is auto-generated by the script +# SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py. +# Do not modify by hand! Fix and rerun the script instead. ################################################################################ from libc.stdio cimport FILE @@ -11,1116 +13,242 @@ from sage.libs.mpfr.types cimport * from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - fmpz PTR_TO_COEFF(__mpz_struct * ptr) noexcept - __mpz_struct * COEFF_TO_PTR(fmpz f) noexcept - - int COEFF_IS_MPZ(fmpz f) noexcept - __mpz_struct * _fmpz_new_mpz() noexcept - void _fmpz_clear_mpz(fmpz f) noexcept - void _fmpz_cleanup_mpz_content() noexcept - void _fmpz_cleanup() noexcept - __mpz_struct * _fmpz_promote(fmpz_t f) noexcept - __mpz_struct * _fmpz_promote_val(fmpz_t f) noexcept - void _fmpz_demote(fmpz_t f) noexcept - void _fmpz_demote_val(fmpz_t f) noexcept - + bint _fmpz_is_canonical(const fmpz_t f) noexcept void fmpz_init(fmpz_t f) noexcept - # A small ``fmpz_t`` is initialised, i.e. just a ``slong``. - # The value is set to zero. - void fmpz_init2(fmpz_t f, ulong limbs) noexcept - # Initialises the given ``fmpz_t`` to have space for the given - # number of limbs. - # If ``limbs`` is zero then a small ``fmpz_t`` is allocated, - # i.e. just a ``slong``. The value is also set to zero. It is - # not necessary to call this function except to save time. A call - # to ``fmpz_init`` will do just fine. - void fmpz_clear(fmpz_t f) noexcept - # Clears the given ``fmpz_t``, releasing any memory associated - # with it, either back to the stack or the OS, depending on - # whether the reentrant or non-reentrant version of FLINT is built. - void fmpz_init_set(fmpz_t f, const fmpz_t g) noexcept - void fmpz_init_set_ui(fmpz_t f, ulong g) noexcept - void fmpz_init_set_si(fmpz_t f, slong g) noexcept - # Initialises `f` and sets it to the value of `g`. - void fmpz_randbits(fmpz_t f, flint_rand_t state, flint_bitcnt_t bits) noexcept - # Generates a random signed integer whose absolute value has precisely - # the given number of bits. - void fmpz_randtest(fmpz_t f, flint_rand_t state, flint_bitcnt_t bits) noexcept - # Generates a random signed integer whose absolute value has a number - # of bits which is random from `0` up to ``bits`` inclusive. - void fmpz_randtest_unsigned(fmpz_t f, flint_rand_t state, flint_bitcnt_t bits) noexcept - # Generates a random unsigned integer whose value has a number - # of bits which is random from `0` up to ``bits`` inclusive. - void fmpz_randtest_not_zero(fmpz_t f, flint_rand_t state, flint_bitcnt_t bits) noexcept - # As per ``fmpz_randtest``, but the result will not be `0`. - # If ``bits`` is set to `0`, an exception will result. - void fmpz_randm(fmpz_t f, flint_rand_t state, const fmpz_t m) noexcept - # Generates a random integer in the range `0` to `m - 1` inclusive. - void fmpz_randtest_mod(fmpz_t f, flint_rand_t state, const fmpz_t m) noexcept - # Generates a random integer in the range `0` to `m - 1` inclusive, - # with an increased probability of generating values close to - # the endpoints. - void fmpz_randtest_mod_signed(fmpz_t f, flint_rand_t state, const fmpz_t m) noexcept - # Generates a random integer in the range `(-m/2, m/2]`, with an - # increased probability of generating values close to the - # endpoints or close to zero. - void fmpz_randprime(fmpz_t f, flint_rand_t state, flint_bitcnt_t bits, int proved) noexcept - # Generates a random prime number with the given number of bits. - # The generation is performed by choosing a random number and then - # finding the next largest prime, and therefore does not quite - # give a uniform distribution over the set of primes with that - # many bits. - # Random number generation is performed using the standard Flint - # random number generator, which is not suitable for cryptographic use. - # If ``proved`` is nonzero, then the integer returned is - # guaranteed to actually be prime. - slong fmpz_get_si(const fmpz_t f) noexcept - # Returns `f` as a ``slong``. The result is undefined - # if `f` does not fit into a ``slong``. - ulong fmpz_get_ui(const fmpz_t f) noexcept - # Returns `f` as an ``ulong``. The result is undefined - # if `f` does not fit into an ``ulong`` or is negative. - void fmpz_get_uiui(mp_limb_t * hi, mp_limb_t * low, const fmpz_t f) noexcept - # If `f` consists of two limbs, then ``*hi`` and ``*low`` are set to the high - # and low limbs, otherwise ``*low`` is set to the low limb and ``*hi`` is set - # to `0`. - mp_limb_t fmpz_get_nmod(const fmpz_t f, nmod_t mod) noexcept - # Returns `f \mod n`. - double fmpz_get_d(const fmpz_t f) noexcept - # Returns `f` as a ``double``, rounding down towards zero if - # `f` cannot be represented exactly. The outcome is undefined - # if `f` is too large to fit in the normal range of a double. - void fmpz_set_mpf(fmpz_t f, const mpf_t x) noexcept - # Sets `f` to the ``mpf_t`` `x`, rounding down towards zero if - # the value of `x` is fractional. - void fmpz_get_mpf(mpf_t x, const fmpz_t f) noexcept - # Sets the value of the ``mpf_t`` `x` to the value of `f`. - void fmpz_get_mpfr(mpfr_t x, const fmpz_t f, mpfr_rnd_t rnd) noexcept - # Sets the value of `x` from `f`, rounded toward the given - # direction ``rnd``. - # **Note:** Requires that ``mpfr.h`` has been included before any FLINT - # header is included. - double fmpz_get_d_2exp(slong * exp, const fmpz_t f) noexcept - # Returns `f` as a normalized ``double`` along with a `2`-exponent - # ``exp``, i.e. if `r` is the return value then `f = r 2^{exp}`, - # to within 1 ULP. - void fmpz_get_mpz(mpz_t x, const fmpz_t f) noexcept - # Sets the ``mpz_t`` `x` to the same value as `f`. - - int fmpz_get_mpn(mp_ptr *n, fmpz_t n_in) noexcept - # Sets the ``mp_ptr`` `n` to the same value as `n_{in}`. Returned - # integer is number of limbs allocated to `n`, minimum number of limbs - # required to hold the value stored in `n_{in}`. - + int fmpz_get_mpn(mp_ptr * n, fmpz_t n_in) noexcept char * fmpz_get_str(char * str, int b, const fmpz_t f) noexcept - # Returns the representation of `f` in base `b`, which can vary - # between `2` and `62`, inclusive. - # If ``str`` is ``NULL``, the result string is allocated by - # the function. Otherwise, it is up to the caller to ensure that - # the allocated block of memory is sufficiently large. - void fmpz_set_si(fmpz_t f, slong val) noexcept - # Sets `f` to the given ``slong`` value. - void fmpz_set_ui(fmpz_t f, ulong val) noexcept - # Sets `f` to the given ``ulong`` value. - void fmpz_set_d(fmpz_t f, double c) noexcept - # Sets `f` to the ``double`` `c`, rounding down towards zero if - # the value of `c` is fractional. The outcome is undefined if `c` is - # infinite, not-a-number, or subnormal. - void fmpz_set_d_2exp(fmpz_t f, double d, slong exp) noexcept - # Sets `f` to the nearest integer to `d 2^{exp}`. - void fmpz_neg_ui(fmpz_t f, ulong val) noexcept - # Sets `f` to the given ``ulong`` value, and then negates `f`. - void fmpz_set_uiui(fmpz_t f, mp_limb_t hi, mp_limb_t lo) noexcept - # Sets `f` to ``lo``, plus ``hi`` shifted to the left by - # ``FLINT_BITS``. - void fmpz_neg_uiui(fmpz_t f, mp_limb_t hi, mp_limb_t lo) noexcept - # Sets `f` to ``lo``, plus ``hi`` shifted to the left by - # ``FLINT_BITS``, and then negates `f`. - void fmpz_set_signed_uiui(fmpz_t f, ulong hi, ulong lo) noexcept - # Sets `f` to ``lo``, plus ``hi`` shifted to the left by - # ``FLINT_BITS``, interpreted as a signed two's complement - # integer with ``2 * FLINT_BITS`` bits. - void fmpz_set_signed_uiuiui(fmpz_t f, ulong hi, ulong mid, ulong lo) noexcept - # Sets `f` to ``lo``, plus ``mid`` shifted to the left by - # ``FLINT_BITS``, plus ``hi`` shifted to the left by - # ``2*FLINT_BITS`` bits, interpreted as a signed two's complement - # integer with ``3 * FLINT_BITS`` bits. - void fmpz_set_ui_array(fmpz_t out, const ulong * input, slong n) noexcept - # Sets ``out`` to the nonnegative integer - # ``in[0] + in[1]*X + ... + in[n - 1]*X^(n - 1)`` - # where ``X = 2^FLINT_BITS``. It is assumed that ``n > 0``. - void fmpz_set_signed_ui_array(fmpz_t out, const ulong * input, slong n) noexcept - # Sets ``out`` to the integer represented in ``in[0], ..., in[n - 1]`` - # as a signed two's complement integer with ``n * FLINT_BITS`` bits. - # It is assumed that ``n > 0``. The function operates as a call to - # :func:`fmpz_set_ui_array` followed by a symmetric remainder modulo - # `2^{n\cdot FLINT\_BITS}`. - void fmpz_get_ui_array(ulong * out, slong n, const fmpz_t input) noexcept - # Assuming that the nonnegative integer ``in`` can be represented in the - # form ``out[0] + out[1]*X + ... + out[n - 1]*X^(n - 1)``, - # where `X = 2^{FLINT\_BITS}`, sets the corresponding elements of ``out`` - # so that this is true. It is assumed that ``n > 0``. - void fmpz_get_signed_ui_array(ulong * out, slong n, const fmpz_t input) noexcept - # Retrieves the value of `in` modulo `2^{n * FLINT\_BITS}` and puts the `n` - # words of the result in ``out[0], ..., out[n-1]``. This will give a signed - # two's complement representation of `in` (assuming `in` doesn't overflow the array). - void fmpz_get_signed_uiui(ulong * hi, ulong * lo, const fmpz_t input) noexcept - # Retrieves the value of `in` modulo `2^{2 * FLINT\_BITS}` and puts the high - # and low words into ``*hi`` and ``*lo`` respectively. - void fmpz_set_mpz(fmpz_t f, const mpz_t x) noexcept - # Sets `f` to the given ``mpz_t`` value. - int fmpz_set_str(fmpz_t f, const char * str, int b) noexcept - # Sets `f` to the value given in the null-terminated string ``str``, - # in base `b`. The base `b` can vary between `2` and `62`, inclusive. - # Returns `0` if the string contains a valid input and `-1` otherwise. - void fmpz_set_ui_smod(fmpz_t f, mp_limb_t x, mp_limb_t m) noexcept - # Sets `f` to the signed remainder `y \equiv x \bmod m` satisfying - # `-m/2 < y \leq m/2`, given `x` which is assumed to satisfy - # `0 \leq x < m`. - void flint_mpz_init_set_readonly(mpz_t z, const fmpz_t f) noexcept - # Sets the uninitialised ``mpz_t`` `z` to the value of the - # readonly ``fmpz_t`` `f`. - # Note that it is assumed that `f` does not change during - # the lifetime of `z`. - # The integer `z` has to be cleared by a call to - # :func:`flint_mpz_clear_readonly`. - # The suggested use of the two functions is as follows:: - # fmpz_t f; - # ... - # { - # mpz_t z; - # flint_mpz_init_set_readonly(z, f); - # foo(..., z); - # flint_mpz_clear_readonly(z); - # } - # This provides a convenient function for user code, only - # requiring to work with the types ``fmpz_t`` and ``mpz_t``. - # In critical code, the following approach may be favourable:: - # fmpz_t f; - # ... - # { - # __mpz_struct *z; - # z = _fmpz_promote_val(f); - # foo(..., z); - # _fmpz_demote_val(f); - # } - void flint_mpz_clear_readonly(mpz_t z) noexcept - # Clears the readonly ``mpz_t`` `z`. - void fmpz_init_set_readonly(fmpz_t f, const mpz_t z) noexcept - # Sets the uninitialised ``fmpz_t`` `f` to a readonly - # version of the integer `z`. - # Note that the value of `z` is assumed to remain constant - # throughout the lifetime of `f`. - # The ``fmpz_t`` `f` has to be cleared by calling the - # function :func:`fmpz_clear_readonly`. - # The suggested use of the two functions is as follows:: - # mpz_t z; - # ... - # { - # fmpz_t f; - # fmpz_init_set_readonly(f, z); - # foo(..., f); - # fmpz_clear_readonly(f); - # } - void fmpz_clear_readonly(fmpz_t f) noexcept - # Clears the readonly ``fmpz_t`` `f`. - int fmpz_read(fmpz_t f) noexcept - # Reads a multiprecision integer from ``stdin``. The format is - # an optional minus sign, followed by one or more digits. The - # first digit should be non-zero unless it is the only digit. - # In case of success, returns a positive number. In case of failure, - # returns a non-positive number. - # This convention is adopted in light of the return values of - # ``scanf`` from the standard library and ``mpz_inp_str`` - # from MPIR. - int fmpz_fread(FILE * file, fmpz_t f) noexcept - # Reads a multiprecision integer from the stream ``file``. The - # format is an optional minus sign, followed by one or more digits. - # The first digit should be non-zero unless it is the only digit. - # In case of success, returns a positive number. In case of failure, - # returns a non-positive number. - # This convention is adopted in light of the return values of - # ``scanf`` from the standard library and ``mpz_inp_str`` - # from MPIR. - - size_t fmpz_inp_raw(fmpz_t x, FILE *fin ) noexcept - # Reads a multiprecision integer from the stream ``file``. The - # format is raw binary format write by :func:`fmpz_out_raw`. - # In case of success, return a positive number, indicating number of bytes read. - # In case of failure 0. - # This function calls the ``mpz_inp_raw`` function in library gmp. So that it - # can read the raw data written by ``mpz_inp_raw`` directly. - + size_t fmpz_inp_raw(fmpz_t x, FILE * fin) noexcept int fmpz_print(const fmpz_t x) noexcept - # Prints the value `x` to ``stdout``, without a carriage return (CR). - # The value is printed as either `0`, the decimal digits of a - # positive integer, or a minus sign followed by the digits of - # a negative integer. - # In case of success, returns a positive number. In case of failure, - # returns a non-positive number. - # This convention is adopted in light of the return values of - # ``flint_printf`` from the standard library and ``mpz_out_str`` - # from MPIR. - int fmpz_fprint(FILE * file, const fmpz_t x) noexcept - # Prints the value `x` to ``file``, without a carriage return (CR). - # The value is printed as either `0`, the decimal digits of a - # positive integer, or a minus sign followed by the digits of - # a negative integer. - # In case of success, returns a positive number. In case of failure, - # returns a non-positive number. - # This convention is adopted in light of the return values of - # ``flint_printf`` from the standard library and ``mpz_out_str`` - # from MPIR. - - size_t fmpz_out_raw(FILE *fout, const fmpz_t x ) noexcept - # Writes the value `x` to ``file``. - # The value is written in raw binary format. The integer is written in - # portable format, with 4 bytes of size information, and that many bytes - # of limbs. Both the size and the limbs are written in decreasing - # significance order (i.e., in big-endian). - # The output can be read with ``fmpz_inp_raw``. - # In case of success, return a positive number, indicating number of bytes written. - # In case of failure, return 0. - # The output of this can also be read by ``mpz_inp_raw`` from GMP >= 2, - # since this function calls the ``mpz_inp_raw`` function in library gmp. - + size_t fmpz_out_raw(FILE * fout, const fmpz_t x ) noexcept size_t fmpz_sizeinbase(const fmpz_t f, int b) noexcept - # Returns the size of the absolute value of `f` in base `b`, measured in - # numbers of digits. The base `b` can be between `2` and `62`, inclusive. - flint_bitcnt_t fmpz_bits(const fmpz_t f) noexcept - # Returns the number of bits required to store the absolute - # value of `f`. If `f` is `0` then `0` is returned. - mp_size_t fmpz_size(const fmpz_t f) noexcept - # Returns the number of limbs required to store the absolute - # value of `f`. If `f` is zero then `0` is returned. - int fmpz_sgn(const fmpz_t f) noexcept - # Returns `-1` if the sign of `f` is negative, `+1` if it is positive, - # otherwise returns `0`. - flint_bitcnt_t fmpz_val2(const fmpz_t f) noexcept - # Returns the exponent of the largest power of two dividing `f`, or - # equivalently the number of trailing zeros in the binary expansion of `f`. - # If `f` is zero then `0` is returned. - void fmpz_swap(fmpz_t f, fmpz_t g) noexcept - # Efficiently swaps `f` and `g`. No data is copied. - void fmpz_set(fmpz_t f, const fmpz_t g) noexcept - # Sets `f` to the same value as `g`. - void fmpz_zero(fmpz_t f) noexcept - # Sets `f` to zero. - void fmpz_one(fmpz_t f) noexcept - # Sets `f` to one. - int fmpz_abs_fits_ui(const fmpz_t f) noexcept - # Returns whether the absolute value of `f` - # fits into an ``ulong``. - int fmpz_fits_si(const fmpz_t f) noexcept - # Returns whether the value of `f` fits into a ``slong``. - void fmpz_setbit(fmpz_t f, ulong i) noexcept - # Sets bit index `i` of `f`. - int fmpz_tstbit(const fmpz_t f, ulong i) noexcept - # Test bit index `i` of `f` and return `0` or `1`, accordingly. - mp_limb_t fmpz_abs_lbound_ui_2exp(slong * exp, const fmpz_t x, int bits) noexcept - # For nonzero `x`, returns a mantissa `m` with exactly ``bits`` bits and - # sets ``exp`` to an exponent `e`, such that `|x| \ge m 2^e`. The number - # of bits must be between 1 and ``FLINT_BITS`` inclusive. - # The mantissa is guaranteed to be correctly rounded. - mp_limb_t fmpz_abs_ubound_ui_2exp(slong * exp, const fmpz_t x, int bits) noexcept - # For nonzero `x`, returns a mantissa `m` with exactly ``bits`` bits - # and sets ``exp`` to an exponent `e`, such that `|x| \le m 2^e`. - # The number of bits must be between 1 and ``FLINT_BITS`` inclusive. - # The mantissa is either correctly rounded or one unit too large - # (possibly meaning that the exponent is one too large, - # if the mantissa is a power of two). - int fmpz_cmp(const fmpz_t f, const fmpz_t g) noexcept - int fmpz_cmp_ui(const fmpz_t f, ulong g) noexcept - int fmpz_cmp_si(const fmpz_t f, slong g) noexcept - # Returns a negative value if `f < g`, positive value if `g < f`, - # otherwise returns `0`. - int fmpz_cmpabs(const fmpz_t f, const fmpz_t g) noexcept - # Returns a negative value if `\lvert f\rvert < \lvert g\rvert`, positive value if - # `\lvert g\rvert < \lvert f \rvert`, otherwise returns `0`. - int fmpz_cmp2abs(const fmpz_t f, const fmpz_t g) noexcept - # Returns a negative value if `\lvert f\rvert < \lvert 2g\rvert`, positive value if - # `\lvert 2g\rvert < \lvert f \rvert`, otherwise returns `0`. - bint fmpz_equal(const fmpz_t f, const fmpz_t g) noexcept - bint fmpz_equal_ui(const fmpz_t f, ulong g) noexcept - bint fmpz_equal_si(const fmpz_t f, slong g) noexcept - # Returns `1` if `f` is equal to `g`, otherwise returns `0`. - bint fmpz_is_zero(const fmpz_t f) noexcept - # Returns `1` if `f` is `0`, otherwise returns `0`. - bint fmpz_is_one(const fmpz_t f) noexcept - # Returns `1` if `f` is equal to one, otherwise returns `0`. - bint fmpz_is_pm1(const fmpz_t f) noexcept - # Returns `1` if `f` is equal to one or minus one, otherwise returns `0`. - bint fmpz_is_even(const fmpz_t f) noexcept - # Returns whether the integer `f` is even. - bint fmpz_is_odd(const fmpz_t f) noexcept - # Returns whether the integer `f` is odd. - void fmpz_neg(fmpz_t f1, const fmpz_t f2) noexcept - # Sets `f_1` to `-f_2`. - void fmpz_abs(fmpz_t f1, const fmpz_t f2) noexcept - # Sets `f_1` to the absolute value of `f_2`. - void fmpz_add(fmpz_t f, const fmpz_t g, const fmpz_t h) noexcept void fmpz_add_ui(fmpz_t f, const fmpz_t g, ulong h) noexcept void fmpz_add_si(fmpz_t f, const fmpz_t g, slong h) noexcept - # Sets `f` to `g + h`. - void fmpz_sub(fmpz_t f, const fmpz_t g, const fmpz_t h) noexcept void fmpz_sub_ui(fmpz_t f, const fmpz_t g, ulong h) noexcept void fmpz_sub_si(fmpz_t f, const fmpz_t g, slong h) noexcept - # Sets `f` to `g - h`. - void fmpz_mul(fmpz_t f, const fmpz_t g, const fmpz_t h) noexcept void fmpz_mul_ui(fmpz_t f, const fmpz_t g, ulong h) noexcept void fmpz_mul_si(fmpz_t f, const fmpz_t g, slong h) noexcept - # Sets `f` to `g \times h`. - void fmpz_mul2_uiui(fmpz_t f, const fmpz_t g, ulong x, ulong y) noexcept - # Sets `f` to `g \times x \times y` where `x` and `y` are of type ``ulong``. - void fmpz_mul_2exp(fmpz_t f, const fmpz_t g, ulong e) noexcept - # Sets `f` to `g \times 2^e`. - # Note: Assumes that ``e + FLINT_BITS`` does not overflow. - void fmpz_one_2exp(fmpz_t f, ulong e) noexcept - # Sets `f` to `2^e`. - void fmpz_addmul(fmpz_t f, const fmpz_t g, const fmpz_t h) noexcept void fmpz_addmul_ui(fmpz_t f, const fmpz_t g, ulong h) noexcept void fmpz_addmul_si(fmpz_t f, const fmpz_t g, slong h) noexcept - # Sets `f` to `f + g \times h`. - void fmpz_submul(fmpz_t f, const fmpz_t g, const fmpz_t h) noexcept void fmpz_submul_ui(fmpz_t f, const fmpz_t g, ulong h) noexcept void fmpz_submul_si(fmpz_t f, const fmpz_t g, slong h) noexcept - # Sets `f` to `f - g \times h`. - void fmpz_fmma(fmpz_t f, const fmpz_t a, const fmpz_t b, const fmpz_t c, const fmpz_t d) noexcept - # Sets `f` to `a \times b + c \times d`. - void fmpz_fmms(fmpz_t f, const fmpz_t a, const fmpz_t b, const fmpz_t c, const fmpz_t d) noexcept - # Sets `f` to `a \times b - c \times d`. - void fmpz_cdiv_qr(fmpz_t f, fmpz_t s, const fmpz_t g, const fmpz_t h) noexcept - void fmpz_fdiv_qr(fmpz_t f, fmpz_t s, const fmpz_t g, const fmpz_t h) noexcept - void fmpz_tdiv_qr(fmpz_t f, fmpz_t s, const fmpz_t g, const fmpz_t h) noexcept - void fmpz_ndiv_qr(fmpz_t f, fmpz_t s, const fmpz_t g, const fmpz_t h) noexcept - void fmpz_cdiv_q(fmpz_t f, const fmpz_t g, const fmpz_t h) noexcept - void fmpz_fdiv_q(fmpz_t f, const fmpz_t g, const fmpz_t h) noexcept - void fmpz_tdiv_q(fmpz_t f, const fmpz_t g, const fmpz_t h) noexcept - void fmpz_cdiv_q_si(fmpz_t f, const fmpz_t g, slong h) noexcept - void fmpz_fdiv_q_si(fmpz_t f, const fmpz_t g, slong h) noexcept - void fmpz_tdiv_q_si(fmpz_t f, const fmpz_t g, slong h) noexcept - void fmpz_cdiv_q_ui(fmpz_t f, const fmpz_t g, ulong h) noexcept - void fmpz_fdiv_q_ui(fmpz_t f, const fmpz_t g, ulong h) noexcept - void fmpz_tdiv_q_ui(fmpz_t f, const fmpz_t g, ulong h) noexcept - void fmpz_cdiv_q_2exp(fmpz_t f, const fmpz_t g, ulong exp) noexcept - void fmpz_fdiv_q_2exp(fmpz_t f, const fmpz_t g, ulong exp) noexcept - void fmpz_tdiv_q_2exp(fmpz_t f, const fmpz_t g, ulong exp) noexcept - void fmpz_fdiv_r(fmpz_t s, const fmpz_t g, const fmpz_t h) noexcept - void fmpz_cdiv_r_2exp(fmpz_t s, const fmpz_t g, ulong exp) noexcept - void fmpz_fdiv_r_2exp(fmpz_t s, const fmpz_t g, ulong exp) noexcept - void fmpz_tdiv_r_2exp(fmpz_t s, const fmpz_t g, ulong exp) noexcept - # Sets `f` to the quotient of `g` by `h` and/or `s` to the remainder. For the - # ``2exp`` functions, ``g = 2^exp``. `If `h` is `0` an exception is raised. - # Rounding is made in the following way: - # * ``fdiv`` rounds the quotient via floor rounding. - # * ``cdiv`` rounds the quotient via ceil rounding. - # * ``tdiv`` rounds the quotient via truncation, i.e. rounding towards zero. - # * ``ndiv`` rounds the quotient such that the remainder has the smallest - # absolute value. In case of ties, it rounds the quotient towards zero. - ulong fmpz_cdiv_ui(const fmpz_t g, ulong h) noexcept - ulong fmpz_fdiv_ui(const fmpz_t g, ulong h) noexcept - ulong fmpz_tdiv_ui(const fmpz_t g, ulong h) noexcept - void fmpz_divexact(fmpz_t f, const fmpz_t g, const fmpz_t h) noexcept - void fmpz_divexact_si(fmpz_t f, const fmpz_t g, slong h) noexcept - void fmpz_divexact_ui(fmpz_t f, const fmpz_t g, ulong h) noexcept - # Sets `f` to the quotient of `g` and `h`, assuming that the - # division is exact, i.e. `g` is a multiple of `h`. If `h` - # is `0` an exception is raised. - void fmpz_divexact2_uiui(fmpz_t f, const fmpz_t g, ulong x, ulong y) noexcept - # Sets `f` to the quotient of `g` and `h = x \times y`, assuming that - # the division is exact, i.e. `g` is a multiple of `h`. - # If `x` or `y` is `0` an exception is raised. - int fmpz_divisible(const fmpz_t f, const fmpz_t g) noexcept - int fmpz_divisible_si(const fmpz_t f, slong g) noexcept - # Returns `1` if there is an integer `q` with `f = q g` and `0` if there is - # none. - int fmpz_divides(fmpz_t q, const fmpz_t g, const fmpz_t h) noexcept - # Returns `1` if there is an integer `q` with `f = q g` and sets `q` to the - # quotient. Otherwise returns `0` and sets `q` to `0`. - void fmpz_mod(fmpz_t f, const fmpz_t g, const fmpz_t h) noexcept - # Sets `f` to the remainder of `g` divided by `h` such that the remainder is - # positive. Assumes that `h` is not zero. - ulong fmpz_mod_ui(fmpz_t f, const fmpz_t g, ulong h) noexcept - # Sets `f` to the remainder of `g` divided by `h` such that the remainder is - # positive and also returns this value. Raises an exception if `h` is zero. - void fmpz_smod(fmpz_t f, const fmpz_t g, const fmpz_t h) noexcept - # Sets `f` to the signed remainder `y \equiv g \bmod h` satisfying - # `-\lvert h \rvert/2 < y \leq \lvert h\rvert/2`. - void fmpz_preinvn_init(fmpz_preinvn_t inv, const fmpz_t f) noexcept - # Compute a precomputed inverse ``inv`` of ``f`` for use in the - # ``preinvn`` functions listed below. - void fmpz_preinvn_clear(fmpz_preinvn_t inv) noexcept - # Clean up the resources used by a precomputed inverse created with the - # :func:`fmpz_preinvn_init` function. - void fmpz_fdiv_qr_preinvn(fmpz_t f, fmpz_t s, const fmpz_t g, const fmpz_t h, const fmpz_preinvn_t hinv) noexcept - # As per :func:`fmpz_fdiv_qr`, but takes a precomputed inverse ``hinv`` - # of `h` constructed using :func:`fmpz_preinvn`. - # This function will be faster than :func:`fmpz_fdiv_qr_preinvn` when the - # number of limbs of `h` is at least ``PREINVN_CUTOFF``. - void fmpz_pow_ui(fmpz_t f, const fmpz_t g, ulong x) noexcept void fmpz_ui_pow_ui(fmpz_t f, ulong g, ulong x) noexcept - # Sets `f` to `g^x`. Defines `0^0 = 1`. - int fmpz_pow_fmpz(fmpz_t f, const fmpz_t g, const fmpz_t x) noexcept - # Sets `f` to `g^x`. Defines `0^0 = 1`. Return `1` for success and `0` for - # failure. The function throws only if `x` is negative. - void fmpz_powm_ui(fmpz_t f, const fmpz_t g, ulong e, const fmpz_t m) noexcept - void fmpz_powm(fmpz_t f, const fmpz_t g, const fmpz_t e, const fmpz_t m) noexcept - # Sets `f` to `g^e \bmod{m}`. If `e = 0`, sets `f` to `1`. - # Assumes that `m \neq 0`, raises an ``abort`` signal otherwise. - slong fmpz_clog(const fmpz_t x, const fmpz_t b) noexcept slong fmpz_clog_ui(const fmpz_t x, ulong b) noexcept - # Returns `\lceil\log_b x\rceil`. - # Assumes that `x \geq 1` and `b \geq 2` and that - # the return value fits into a signed ``slong``. - slong fmpz_flog(const fmpz_t x, const fmpz_t b) noexcept slong fmpz_flog_ui(const fmpz_t x, ulong b) noexcept - # Returns `\lfloor\log_b x\rfloor`. - # Assumes that `x \geq 1` and `b \geq 2` and that - # the return value fits into a signed ``slong``. - double fmpz_dlog(const fmpz_t x) noexcept - # Returns a double precision approximation of the - # natural logarithm of `x`. - # The accuracy depends on the implementation of the floating-point - # logarithm provided by the C standard library. The result can - # typically be expected to have a relative error no greater than 1-2 bits. - int fmpz_sqrtmod(fmpz_t b, const fmpz_t a, const fmpz_t p) noexcept - # If `p` is prime, set `b` to a square root of `a` modulo `p` if `a` is a - # quadratic residue modulo `p` and return `1`, otherwise return `0`. - # If `p` is not prime the return value is with high probability `0`, - # indicating that `p` is not prime, or `a` is not a square modulo `p`. - # If `p` is not prime and the return value is `1`, the value of `b` is - # meaningless. - void fmpz_sqrt(fmpz_t f, const fmpz_t g) noexcept - # Sets `f` to the integer part of the square root of `g`, where - # `g` is assumed to be non-negative. If `g` is negative, an exception - # is raised. - void fmpz_sqrtrem(fmpz_t f, fmpz_t r, const fmpz_t g) noexcept - # Sets `f` to the integer part of the square root of `g`, where `g` is - # assumed to be non-negative, and sets `r` to the remainder, that is, - # the difference `g - f^2`. If `g` is negative, an exception is raised. - # The behaviour is undefined if `f` and `r` are aliases. - bint fmpz_is_square(const fmpz_t f) noexcept - # Returns nonzero if `f` is a perfect square and zero otherwise. - int fmpz_root(fmpz_t r, const fmpz_t f, slong n) noexcept - # Set `r` to the integer part of the `n`-th root of `f`. Requires that - # `n > 0` and that if `n` is even then `f` be non-negative, otherwise an - # exception is raised. The function returns `1` if the root was exact, - # otherwise `0`. - bint fmpz_is_perfect_power(fmpz_t root, const fmpz_t f) noexcept - # If `f` is a perfect power `r^k` set ``root`` to `r` and return `k`, - # otherwise return `0`. Note that `-1, 0, 1` are all considered perfect - # powers. No guarantee is made about `r` or `k` being the smallest - # possible value. Negative values of `f` are permitted. - void fmpz_fac_ui(fmpz_t f, ulong n) noexcept - # Sets `f` to the factorial `n!` where `n` is an ``ulong``. - void fmpz_fib_ui(fmpz_t f, ulong n) noexcept - # Sets `f` to the Fibonacci number `F_n` where `n` is an - # ``ulong``. - void fmpz_bin_uiui(fmpz_t f, ulong n, ulong k) noexcept - # Sets `f` to the binomial coefficient `{n choose k}`. - void _fmpz_rfac_ui(fmpz_t r, const fmpz_t x, ulong a, ulong b) noexcept - # Sets `r` to the rising factorial `(x+a) (x+a+1) (x+a+2) \cdots (x+b-1)`. - # Assumes `b > a`. - void fmpz_rfac_ui(fmpz_t r, const fmpz_t x, ulong k) noexcept - # Sets `r` to the rising factorial `x (x+1) (x+2) \cdots (x+k-1)`. - void fmpz_rfac_uiui(fmpz_t r, ulong x, ulong k) noexcept - # Sets `r` to the rising factorial `x (x+1) (x+2) \cdots (x+k-1)`. - void fmpz_mul_tdiv_q_2exp(fmpz_t f, const fmpz_t g, const fmpz_t h, ulong exp) noexcept - # Sets `f` to the product of `g` and `h` divided by ``2^exp``, rounding - # down towards zero. - void fmpz_mul_si_tdiv_q_2exp(fmpz_t f, const fmpz_t g, slong x, ulong exp) noexcept - # Sets `f` to the product of `g` and `x` divided by ``2^exp``, rounding - # down towards zero. - void fmpz_gcd_ui(fmpz_t f, const fmpz_t g, ulong h) noexcept - void fmpz_gcd(fmpz_t f, const fmpz_t g, const fmpz_t h) noexcept - # Sets `f` to the greatest common divisor of `g` and `h`. The - # result is always positive, even if one of `g` and `h` is - # negative. - void fmpz_gcd3(fmpz_t f, const fmpz_t a, const fmpz_t b, const fmpz_t c) noexcept - # Sets `f` to the greatest common divisor of `a`, `b` and `c`. - # This is equivalent to calling ``fmpz_gcd`` twice, but may be faster. - void fmpz_lcm(fmpz_t f, const fmpz_t g, const fmpz_t h) noexcept - # Sets `f` to the least common multiple of `g` and `h`. The - # result is always nonnegative, even if one of `g` and `h` is - # negative. - void fmpz_gcdinv(fmpz_t d, fmpz_t a, const fmpz_t f, const fmpz_t g) noexcept - # Given integers `f, g` with `0 \leq f < g`, computes the - # greatest common divisor `d = \gcd(f, g)` and the modular - # inverse `a = f^{-1} \pmod{g}`, whenever `f \neq 0`. - # Assumes that `d` and `a` are not aliased. - void fmpz_xgcd(fmpz_t d, fmpz_t a, fmpz_t b, const fmpz_t f, const fmpz_t g) noexcept - # Computes the extended GCD of `f` and `g`, i.e. the values `a` and `b` such - # that `af + bg = d`, where `d = \gcd(f, g)`. Here `a` will be the same as - # calling ``fmpz_gcdinv`` when `f < g` (or vice versa for `b` when `g < f`). - # To obtain the canonical solution to Bézout's identity, call - # ``fmpz_xgcd_canonical_bezout`` instead. This is also faster. - # Assumes that there is no aliasing among the outputs. - void fmpz_xgcd_canonical_bezout(fmpz_t d, fmpz_t a, fmpz_t b, const fmpz_t f, const fmpz_t g) noexcept - # Computes the extended GCD `\operatorname{xgcd}(f, g) = (d, a, b)` such that - # the solution is the canonical solution to Bézout's identity. We define the - # canonical solution to satisfy one of the following if one of the given - # conditions apply: - # .. math :: - # \operatorname{xgcd}(\pm g, g) &= \bigl(|g|, 0, \operatorname{sgn}(g)\bigr) - # \operatorname{xgcd}(f, 0) &= \bigl(|f|, \operatorname{sgn}(f), 0\bigr) - # \operatorname{xgcd}(0, g) &= \bigl(|g|, 0, \operatorname{sgn}(g)\bigr) - # \operatorname{xgcd}(f, \mp 1) &= (1, 0, \mp 1) - # \operatorname{xgcd}(\mp 1, g) &= (1, \mp 1, 0)\quad g \neq 0, \pm 1 - # \operatorname{xgcd}(\mp 2 d, g) &= - # \bigl(d, {\textstyle\frac{d - |g|}{\mp 2 d}}, \operatorname{sgn}(g)\bigr) - # \operatorname{xgcd}(f, \mp 2 d) &= - # \bigl(d, \operatorname{sgn}(f), {\textstyle\frac{d - |g|}{\mp 2 d}}\bigr). - # If the pair `(f, g)` does not satisfy any of these conditions, the solution - # `(d, a, b)` will satisfy the following: - # .. math :: - # |a| < \Bigl| \frac{g}{2 d} \Bigr|, - # \qquad |b| < \Bigl| \frac{f}{2 d} \Bigr|. - # Assumes that there is no aliasing among the outputs. - void fmpz_xgcd_partial(fmpz_t co2, fmpz_t co1, fmpz_t r2, fmpz_t r1, const fmpz_t L) noexcept - # This function is an implementation of Lehmer extended GCD with early - # termination, as used in the ``qfb`` module. It terminates early when - # remainders fall below the specified bound. The initial values ``r1`` - # and ``r2`` are treated as successive remainders in the Euclidean - # algorithm and are replaced with the last two remainders computed. The - # values ``co1`` and ``co2`` are the last two cofactors and satisfy - # the identity ``co2*r1 - co1*r2 == +/- r2_orig`` upon termination, where - # ``r2_orig`` is the starting value of ``r2`` supplied, and ``r1`` - # and ``r2`` are the final values. - # Aliasing of inputs is not allowed. Similarly aliasing of inputs and outputs - # is not allowed. - slong _fmpz_remove(fmpz_t x, const fmpz_t f, double finv) noexcept - # Removes all factors `f` from `x` and returns the number of such. - # Assumes that `x` is non-zero, that `f > 1` and that ``finv`` - # is the precomputed ``double`` inverse of `f` whenever `f` is - # a small integer and `0` otherwise. - # Does not support aliasing. - slong fmpz_remove(fmpz_t rop, const fmpz_t op, const fmpz_t f) noexcept - # Remove all occurrences of the factor `f > 1` from the - # integer ``op`` and sets ``rop`` to the resulting - # integer. - # If ``op`` is zero, sets ``rop`` to ``op`` and - # returns `0`. - # Returns an ``abort`` signal if any of the assumptions - # are violated. - int fmpz_invmod(fmpz_t f, const fmpz_t g, const fmpz_t h) noexcept - # Sets `f` to the inverse of `g` modulo `h`. The value of `h` may - # not be `0` otherwise an exception results. If the inverse exists - # the return value will be non-zero, otherwise the return value will - # be `0` and the value of `f` undefined. As a special case, we - # consider any number invertible modulo `h = \pm 1`, with inverse 0. - void fmpz_negmod(fmpz_t f, const fmpz_t g, const fmpz_t h) noexcept - # Sets `f` to `-g \pmod{h}`, assuming `g` is reduced modulo `h`. - int fmpz_jacobi(const fmpz_t a, const fmpz_t n) noexcept - # Computes the Jacobi symbol `\left(\frac{a}{n}\right)` for any `a` and odd positive `n`. - int fmpz_kronecker(const fmpz_t a, const fmpz_t n) noexcept - # Computes the Kronecker symbol `\left(\frac{a}{n}\right)` for any `a` and any `n`. - void fmpz_divides_mod_list(fmpz_t xstart, fmpz_t xstride, fmpz_t xlength, const fmpz_t a, const fmpz_t b, const fmpz_t n) noexcept - # Set `xstart`, `xstride`, and `xlength` so that the solution set for `x` modulo `n` in `a x = b \bmod n` is exactly `\{xstart + xstride\,i \mid 0 \le i < xlength\}`. - # This function essentially gives a list of possibilities for the fraction `a/b` modulo `n`. - # The outputs may not be aliased, and `n` should be positive. - int fmpz_bit_pack(mp_limb_t * arr, flint_bitcnt_t shift, flint_bitcnt_t bits, const fmpz_t coeff, int negate, int borrow) noexcept - # Shifts the given coefficient to the left by ``shift`` bits and adds - # it to the integer in ``arr`` in a field of the given number of bits:: - # shift bits -------------- - # X X X C C C C 0 0 0 0 0 0 0 - # An optional borrow of `1` can be subtracted from ``coeff`` before - # it is packed. If ``coeff`` is negative after the borrow, then a - # borrow will be returned by the function. - # The value of ``shift`` is assumed to be less than ``FLINT_BITS``. - # All but the first ``shift`` bits of ``arr`` are assumed to be zero - # on entry to the function. - # The value of ``coeff`` may also be optionally (and notionally) negated - # before it is used, by setting the ``negate`` parameter to `-1`. - int fmpz_bit_unpack(fmpz_t coeff, mp_limb_t * arr, flint_bitcnt_t shift, flint_bitcnt_t bits, int negate, int borrow) noexcept - # A bit field of the given number of bits is extracted from ``arr``, - # starting after ``shift`` bits, and placed into ``coeff``. An - # optional borrow of `1` may be added to the coefficient. If the result - # is negative, a borrow of `1` is returned. Finally, the resulting - # ``coeff`` may be negated by setting the ``negate`` parameter to `-1`. - # The value of ``shift`` is expected to be less than ``FLINT_BITS``. - void fmpz_bit_unpack_unsigned(fmpz_t coeff, const mp_limb_t * arr, flint_bitcnt_t shift, flint_bitcnt_t bits) noexcept - # A bit field of the given number of bits is extracted from ``arr``, - # starting after ``shift`` bits, and placed into ``coeff``. - # The value of ``shift`` is expected to be less than ``FLINT_BITS``. - void fmpz_complement(fmpz_t r, const fmpz_t f) noexcept - # The variable ``r`` is set to the ones-complement of ``f``. - void fmpz_clrbit(fmpz_t f, ulong i) noexcept - # Sets the ``i``\th bit in ``f`` to zero. - void fmpz_combit(fmpz_t f, ulong i) noexcept - # Complements the ``i``\th bit in ``f``. - void fmpz_and(fmpz_t r, const fmpz_t a, const fmpz_t b) noexcept - # Sets ``r`` to the bit-wise logical ``and`` of ``a`` and ``b``. - void fmpz_or(fmpz_t r, const fmpz_t a, const fmpz_t b) noexcept - # Sets ``r`` to the bit-wise logical (inclusive) ``or`` of - # ``a`` and ``b``. - void fmpz_xor(fmpz_t r, const fmpz_t a, const fmpz_t b) noexcept - # Sets ``r`` to the bit-wise logical exclusive ``or`` of - # ``a`` and ``b``. - ulong fmpz_popcnt(const fmpz_t a) noexcept - # Returns the number of '1' bits in the given Z (aka Hamming weight or - # population count). - # The return value is undefined if the input is negative. - void fmpz_CRT_ui(fmpz_t out, const fmpz_t r1, const fmpz_t m1, ulong r2, ulong m2, int sign) noexcept - # Uses the Chinese Remainder Theorem to compute the unique integer - # `0 \le x < M` (if sign = 0) or `-M/2 < x \le M/2` (if sign = 1) - # congruent to `r_1` modulo `m_1` and `r_2` modulo `m_2`, - # where `M = m_1 \times m_2`. The result `x` is stored in ``out``. - # It is assumed that `m_1` and `m_2` are positive integers greater - # than `1` and coprime. - # If sign = 0, it is assumed that `0 \le r_1 < m_1` and `0 \le r_2 < m_2`. - # Otherwise, it is assumed that `-m_1 \le r_1 < m_1` and `0 \le r_2 < m_2`. - - void fmpz_CRT(fmpz_t out, const fmpz_t r1, const fmpz_t m1, fmpz_t r2, fmpz_t m2, int sign) noexcept - # Use the Chinese Remainder Theorem to set ``out`` to the unique value - # `0 \le x < M` (if sign = 0) or `-M/2 < x \le M/2` (if sign = 1) - # congruent to `r_1` modulo `m_1` and `r_2` modulo `m_2`, - # where `M = m_1 \times m_2`. - # It is assumed that `m_1` and `m_2` are positive integers greater - # than `1` and coprime. - # If sign = 0, it is assumed that `0 \le r_1 < m_1` and `0 \le r_2 < m_2`. - # Otherwise, it is assumed that `-m_1 \le r_1 < m_1` and `0 \le r_2 < m_2`. - + void fmpz_CRT(fmpz_t out, const fmpz_t r1, const fmpz_t m1, const fmpz_t r2, const fmpz_t m2, int sign) noexcept void fmpz_multi_mod_ui(mp_limb_t * out, const fmpz_t input, const fmpz_comb_t comb, fmpz_comb_temp_t temp) noexcept - # Reduces the multiprecision integer ``in`` modulo each of the primes - # stored in the ``comb`` structure. The array ``out`` will be filled - # with the residues modulo these primes. The structure ``temp`` is - # temporary space which must be provided by :func:`fmpz_comb_temp_init` and - # cleared by :func:`fmpz_comb_temp_clear`. - void fmpz_multi_CRT_ui(fmpz_t output, mp_srcptr residues, const fmpz_comb_t comb, fmpz_comb_temp_t ctemp, int sign) noexcept - # This function takes a set of residues modulo the list of primes - # contained in the ``comb`` structure and reconstructs a multiprecision - # integer modulo the product of the primes which has - # these residues modulo the corresponding primes. - # If `N` is the product of all the primes then ``out`` is normalised to - # be in the range `[0, N)` if sign = 0 and the range `[-(N-1)/2, N/2]` - # if sign = 1. The array ``temp`` is temporary - # space which must be provided by :func:`fmpz_comb_temp_init` and - # cleared by :func:`fmpz_comb_temp_clear`. - void fmpz_comb_init(fmpz_comb_t comb, mp_srcptr primes, slong num_primes) noexcept - # Initialises a ``comb`` structure for multimodular reduction and - # recombination. The array ``primes`` is assumed to contain - # ``num_primes`` primes each of ``FLINT_BITS - 1`` bits. Modular - # reductions and recombinations will be done modulo this list of primes. - # The ``primes`` array must not be ``free``'d until the ``comb`` - # structure is no longer required and must be cleared by the user. - void fmpz_comb_temp_init(fmpz_comb_temp_t temp, const fmpz_comb_t comb) noexcept - # Creates temporary space to be used by multimodular and CRT functions - # based on an initialised ``comb`` structure. - void fmpz_comb_clear(fmpz_comb_t comb) noexcept - # Clears the given ``comb`` structure, releasing any memory it uses. - void fmpz_comb_temp_clear(fmpz_comb_temp_t temp) noexcept - # Clears temporary space ``temp`` used by multimodular and CRT functions - # using the given ``comb`` structure. - void fmpz_multi_CRT_init(fmpz_multi_CRT_t CRT) noexcept - # Initialize ``CRT`` for Chinese remaindering. - int fmpz_multi_CRT_precompute(fmpz_multi_CRT_t CRT, const fmpz * moduli, slong len) noexcept - # Configure ``CRT`` for repeated Chinese remaindering of ``moduli``. The number of moduli, ``len``, should be positive. - # A return of ``0`` indicates that the compilation failed and future - # calls to :func:`fmpz_multi_CRT_precomp` will leave the output undefined. - # A return of ``1`` indicates that the compilation was successful, which occurs if and only - # if either (1) ``len == 1`` and ``modulus + 0`` is nonzero, or (2) no modulus is `0,1,-1` and all moduli are pairwise relatively prime. - void fmpz_multi_CRT_precomp(fmpz_t output, const fmpz_multi_CRT_t P, const fmpz * inputs, int sign) noexcept - # Set ``output`` to an integer of smallest absolute value that is congruent to ``values + i`` modulo the ``moduli + i`` - # in ``P``. - int fmpz_multi_CRT(fmpz_t output, const fmpz * moduli, const fmpz * values, slong len, int sign) noexcept - # Perform the same operation as :func:`fmpz_multi_CRT_precomp` while internally constructing and destroying the precomputed data. - # All of the remarks in :func:`fmpz_multi_CRT_precompute` apply. - void fmpz_multi_CRT_clear(fmpz_multi_CRT_t P) noexcept - # Free all space used by ``CRT``. - bint fmpz_is_strong_probabprime(const fmpz_t n, const fmpz_t a) noexcept - # Returns `1` if `n` is a strong probable prime to base `a`, otherwise it - # returns `0`. - bint fmpz_is_probabprime_lucas(const fmpz_t n) noexcept - # Performs a Lucas probable prime test with parameters chosen by Selfridge's - # method `A` as per [BaiWag1980]_. - # Return `1` if `n` is a Lucas probable prime, otherwise return `0`. This - # function declares some composites probably prime, but no primes composite. - bint fmpz_is_probabprime_BPSW(const fmpz_t n) noexcept - # Perform a Baillie-PSW probable prime test with parameters chosen by - # Selfridge's method `A` as per [BaiWag1980]_. - # Return `1` if `n` is a Lucas probable prime, otherwise return `0`. - # There are no known composites passed as prime by this test, though - # infinitely many probably exist. The test will declare no primes - # composite. - bint fmpz_is_probabprime(const fmpz_t p) noexcept - # Performs some trial division and then some probabilistic primality tests. - # If `p` is definitely composite, the function returns `0`, otherwise it - # is declared probably prime, i.e. prime for most practical purposes, and - # the function returns `1`. The chance of declaring a composite prime is - # very small. - # Subsequent calls to the same function do not increase the probability of - # the number being prime. - bint fmpz_is_prime_pseudosquare(const fmpz_t n) noexcept - # Return `0` is `n` is composite. If `n` is too large (greater than about - # `94` bits) the function fails silently and returns `-1`, otherwise, if - # `n` is proven prime by the pseudosquares method, return `1`. - # Tests if `n` is a prime according to [Theorem 2.7] [LukPatWil1996]_. - # We first factor `N` using trial division up to some limit `B`. - # In fact, the number of primes used in the trial factoring is at - # most ``FLINT_PSEUDOSQUARES_CUTOFF``. - # Next we compute `N/B` and find the next pseudosquare `L_p` above - # this value, using a static table as per - # https://oeis.org/A002189/b002189.txt. - # As noted in the text, if `p` is prime then Step 3 will pass. This - # test rejects many composites, and so by this time we suspect - # that `p` is prime. If `N` is `3` or `7` modulo `8`, we are done, - # and `N` is prime. - # We now run a probable prime test, for which no known - # counterexamples are known, to reject any composites. We then - # proceed to prove `N` prime by executing Step 4. In the case that - # `N` is `1` modulo `8`, if Step 4 fails, we extend the number of primes - # `p_i` at Step 3 and hope to find one which passes Step 4. We take - # the test one past the largest `p` for which we have pseudosquares - # `L_p` tabulated, as this already corresponds to the next `L_p` which - # is bigger than `2^{64}` and hence larger than any prime we might be - # testing. - # As explained in the text, Condition 4 cannot fail if `N` is prime. - # The possibility exists that the probable prime test declares a - # composite prime. However in that case an error is printed, as - # that would be of independent interest. - bint fmpz_is_prime_pocklington(fmpz_t F, fmpz_t R, const fmpz_t n, mp_ptr pm1, slong num_pm1) noexcept - # Applies the Pocklington primality test. The test computes a product - # `F` of prime powers which divide `n - 1`. - # The function then returns either `0` if `n` is definitely composite - # or it returns `1` if all factors of `n` are `1 \pmod{F}`. Also in - # that case, `R` is set to `(n - 1)/F`. - # NB: a return value of `1` only proves `n` prime if `F \ge \sqrt{n}`. - # The function does not compute which primes divide `n - 1`. Instead, - # these must be supplied as an array ``pm1`` of length ``num_pm1``. - # It does not matter how many prime factors are supplied, but the more - # that are supplied, the larger F will be. - # There is a balance between the amount of time spent looking for - # factors of `n - 1` and the usefulness of the output (`F` may be as low - # as `2` in some cases). - # A reasonable heuristic seems to be to choose ``limit`` to be some - # small multiple of `\log^3(n)/10` (e.g. `1, 2, 5` or `10`) depending - # on how long one is prepared to wait, then to trial factor up to the - # limit. (See ``_fmpz_nm1_trial_factors``.) - # Requires `n` to be odd. - void _fmpz_nm1_trial_factors(const fmpz_t n, mp_ptr pm1, slong * num_pm1, ulong limit) noexcept - # Trial factors `n - 1` up to the given limit (approximately) and stores - # the factors in an array ``pm1`` whose length is written out to - # ``num_pm1``. - # One can use `\log(n) + 2` as a bound on the number of factors which might - # be produced (and hence on the length of the array that needs to be - # supplied). - bint fmpz_is_prime_morrison(fmpz_t F, fmpz_t R, const fmpz_t n, mp_ptr pp1, slong num_pp1) noexcept - # Applies the Morrison `p + 1` primality test. The test computes a - # product `F` of primes which divide `n + 1`. - # The function then returns either `0` if `n` is definitely composite - # or it returns `1` if all factors of `n` are `\pm 1 \pmod{F}`. Also in - # that case, `R` is set to `(n + 1)/F`. - # NB: a return value of `1` only proves `n` prime if - # `F > \sqrt{n} + 1`. - # The function does not compute which primes divide `n + 1`. Instead, - # these must be supplied as an array ``pp1`` of length ``num_pp1``. - # It does not matter how many prime factors are supplied, but the more - # that are supplied, the larger `F` will be. - # There is a balance between the amount of time spent looking for - # factors of `n + 1` and the usefulness of the output (`F` may be as low - # as `2` in some cases). - # A reasonable heuristic seems to be to choose ``limit`` to be some - # small multiple of `\log^3(n)/10` (e.g. `1, 2, 5` or `10`) depending - # on how long one is prepared to wait, then to trial factor up to the - # limit. (See ``_fmpz_np1_trial_factors``.) - # Requires `n` to be odd and non-square. - void _fmpz_np1_trial_factors(const fmpz_t n, mp_ptr pp1, slong * num_pp1, ulong limit) noexcept - # Trial factors `n + 1` up to the given limit (approximately) and stores - # the factors in an array ``pp1`` whose length is written out to - # ``num_pp1``. - # One can use `\log(n) + 2` as a bound on the number of factors which might - # be produced (and hence on the length of the array that needs to be - # supplied). - bint fmpz_is_prime(const fmpz_t n) noexcept - # Attempts to prove `n` prime. If `n` is proven prime, the function - # returns `1`. If `n` is definitely composite, the function returns `0`. - # This function calls :func:`n_is_prime` for `n` that fits in a single word. - # For `n` larger than one word, it tests divisibility by a few small primes - # and whether `n` is a perfect square to rule out trivial composites. - # For `n` up to about 81 bits, it then uses a strong probable prime test - # (Miller-Rabin test) with the first 13 primes as witnesses. This has - # been shown to prove primality [SorWeb2016]_. - # For larger `n`, it does a single base-2 strong probable prime test - # to eliminate most composite numbers. If `n` passes, it does a - # combination of Pocklington, Morrison and Brillhart, Lehmer, Selfridge - # tests. If any of these tests fails to give a proof, it falls back to - # performing an APRCL test. - # The APRCL test could theoretically fail to prove that `n` is prime - # or composite. In that case, the program aborts. This is not expected to - # occur in practice. - void fmpz_lucas_chain(fmpz_t Vm, fmpz_t Vm1, const fmpz_t A, const fmpz_t m, const fmpz_t n) noexcept - # Given `V_0 = 2`, `V_1 = A` compute `V_m, V_{m + 1} \pmod{n}` from the - # recurrences `V_j = AV_{j - 1} - V_{j - 2} \pmod{n}`. - # This is computed efficiently using `V_{2j} = V_j^2 - 2 \pmod{n}` and - # `V_{2j + 1} = V_jV_{j + 1} - A \pmod{n}`. - # No aliasing is permitted. - void fmpz_lucas_chain_full(fmpz_t Vm, fmpz_t Vm1, const fmpz_t A, const fmpz_t B, const fmpz_t m, const fmpz_t n) noexcept - # Given `V_0 = 2`, `V_1 = A` compute `V_m, V_{m + 1} \pmod{n}` from the - # recurrences `V_j = AV_{j - 1} - BV_{j - 2} \pmod{n}`. - # This is computed efficiently using double and add formulas. - # No aliasing is permitted. - void fmpz_lucas_chain_double(fmpz_t U2m, fmpz_t U2m1, const fmpz_t Um, const fmpz_t Um1, const fmpz_t A, const fmpz_t B, const fmpz_t n) noexcept - # Given `U_m, U_{m + 1} \pmod{n}` compute `U_{2m}, U_{2m + 1} \pmod{n}`. - # Aliasing of `U_{2m}` and `U_m` and aliasing of `U_{2m + 1}` and `U_{m + 1}` - # is permitted. No other aliasing is allowed. - void fmpz_lucas_chain_add(fmpz_t Umn, fmpz_t Umn1, const fmpz_t Um, const fmpz_t Um1, const fmpz_t Un, const fmpz_t Un1, const fmpz_t A, const fmpz_t B, const fmpz_t n) noexcept - # Given `U_m, U_{m + 1} \pmod{n}` and `U_n, U_{n + 1} \pmod{n}` compute - # `U_{m + n}, U_{m + n + 1} \pmod{n}`. - # Aliasing of `U_{m + n}` with `U_m` or `U_n` and aliasing of `U_{m + n + 1}` - # with `U_{m + 1}` or `U_{n + 1}` is permitted. No other aliasing is allowed. - void fmpz_lucas_chain_mul(fmpz_t Ukm, fmpz_t Ukm1, const fmpz_t Um, const fmpz_t Um1, const fmpz_t A, const fmpz_t B, const fmpz_t k, const fmpz_t n) noexcept - # Given `U_m, U_{m + 1} \pmod{n}` compute `U_{km}, U_{km + 1} \pmod{n}`. - # Aliasing of `U_{km}` and `U_m` and aliasing of `U_{km + 1}` and `U_{m + 1}` - # is permitted. No other aliasing is allowed. - void fmpz_lucas_chain_VtoU(fmpz_t Um, fmpz_t Um1, const fmpz_t Vm, const fmpz_t Vm1, const fmpz_t A, const fmpz_t B, const fmpz_t Dinv, const fmpz_t n) noexcept - # Given `V_m, V_{m + 1} \pmod{n}` compute `U_m, U_{m + 1} \pmod{n}`. - # Aliasing of `V_m` and `U_m` and aliasing of `V_{m + 1}` and `U_{m + 1}` - # is permitted. No other aliasing is allowed. - int fmpz_divisor_in_residue_class_lenstra(fmpz_t fac, const fmpz_t n, const fmpz_t r, const fmpz_t s) noexcept - # If there exists a proper divisor of `n` which is `r \pmod{s}` for - # `0 < r < s < n`, this function returns `1` and sets ``fac`` to such a - # divisor. Otherwise the function returns `0` and the value of ``fac`` is - # undefined. - # We require `\gcd(r, s) = 1`. - # This is efficient if `s^3 > n`. - void fmpz_nextprime(fmpz_t res, const fmpz_t n, int proved) noexcept - # Finds the next prime number larger than `n`. - # If ``proved`` is nonzero, then the integer returned is - # guaranteed to actually be prime. Otherwise if `n` fits in - # ``FLINT_BITS - 3`` bits ``n_nextprime`` is called, and if not then - # the GMP ``mpz_nextprime`` function is called. Up to and including - # GMP 6.1.2 this used Miller-Rabin iterations, and thereafter uses - # a BPSW test. - void fmpz_primorial(fmpz_t res, ulong n) noexcept - # Sets ``res`` to ``n`` primorial or `n \#`, the product of all prime - # numbers less than or equal to `n`. - void fmpz_factor_euler_phi(fmpz_t res, const fmpz_factor_t fac) noexcept void fmpz_euler_phi(fmpz_t res, const fmpz_t n) noexcept - # Sets ``res`` to the Euler totient function `\phi(n)`, counting the - # number of positive integers less than or equal to `n` that are coprime - # to `n`. The factor version takes a precomputed - # factorisation of `n`. - int fmpz_factor_moebius_mu(const fmpz_factor_t fac) noexcept int fmpz_moebius_mu(const fmpz_t n) noexcept - # Computes the Moebius function `\mu(n)`, which is defined as `\mu(n) = 0` - # if `n` has a prime factor of multiplicity greater than `1`, `\mu(n) = -1` - # if `n` has an odd number of distinct prime factors, and `\mu(n) = 1` if - # `n` has an even number of distinct prime factors. By convention, - # `\mu(0) = 0`. The factor version takes a precomputed - # factorisation of `n`. - void fmpz_factor_divisor_sigma(fmpz_t res, ulong k, const fmpz_factor_t fac) noexcept void fmpz_divisor_sigma(fmpz_t res, ulong k, const fmpz_t n) noexcept - # Sets ``res`` to `\sigma_k(n)`, the sum of `k`\th powers of all - # divisors of `n`. The factor version takes a precomputed - # factorisation of `n`. + +from .fmpz_macros cimport * diff --git a/src/sage/libs/flint/fmpz_extras.pxd b/src/sage/libs/flint/fmpz_extras.pxd index 248fd0a04e1..940d1fdb766 100644 --- a/src/sage/libs/flint/fmpz_extras.pxd +++ b/src/sage/libs/flint/fmpz_extras.pxd @@ -2,7 +2,9 @@ # distutils: depends = flint/fmpz_extras.h ################################################################################ -# This file is auto-generated. Do not modify by hand +# This file is auto-generated by the script +# SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py. +# Do not modify by hand! Fix and rerun the script instead. ################################################################################ from libc.stdio cimport FILE @@ -11,56 +13,18 @@ from sage.libs.mpfr.types cimport * from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - slong fmpz_allocated_bytes(const fmpz_t x) noexcept - # Returns the total number of bytes heap-allocated internally by this object. - # The count excludes the size of the structure itself. Add - # ``sizeof(fmpz)`` to get the size of the object as a whole. - void fmpz_adiv_q_2exp(fmpz_t z, const fmpz_t x, flint_bitcnt_t exp) noexcept - # Sets *z* to `x / 2^{exp}`, rounded away from zero. - void fmpz_ui_mul_ui(fmpz_t x, ulong a, ulong b) noexcept - # Sets *x* to *a* times *b*. - void fmpz_max(fmpz_t z, const fmpz_t x, const fmpz_t y) noexcept - void fmpz_min(fmpz_t z, const fmpz_t x, const fmpz_t y) noexcept - # Sets *z* to the maximum (respectively minimum) of *x* and *y*. - void fmpz_add_inline(fmpz_t z, const fmpz_t x, const fmpz_t y) noexcept - void fmpz_add_si_inline(fmpz_t z, const fmpz_t x, slong y) noexcept - void fmpz_add_ui_inline(fmpz_t z, const fmpz_t x, ulong y) noexcept - # Sets *z* to the sum of *x* and *y*. - void fmpz_sub_si_inline(fmpz_t z, const fmpz_t x, slong y) noexcept - # Sets *z* to the difference of *x* and *y*. - void fmpz_add2_fmpz_si_inline(fmpz_t z, const fmpz_t x, const fmpz_t y, slong c) noexcept - # Sets *z* to the sum of *x*, *y*, and *c*. - mp_size_t _fmpz_size(const fmpz_t x) noexcept - # Returns the number of limbs required to represent *x*. - slong _fmpz_sub_small(const fmpz_t x, const fmpz_t y) noexcept - # Computes the difference of *x* and *y* and returns the result as - # an *slong*. The result is clamped between -*WORD_MAX* and *WORD_MAX*, - # i.e. between `\pm (2^{63}-1)` inclusive on a 64-bit machine. - void _fmpz_set_si_small(fmpz_t x, slong v) noexcept - # Sets *x* to the integer *v* which is required to be a value - # between *COEFF_MIN* and *COEFF_MAX* so that promotion to - # a bignum cannot occur. - void fmpz_set_mpn_large(fmpz_t z, mp_srcptr src, mp_size_t n, int negative) noexcept - # Sets *z* to the integer represented by the *n* limbs in the array *src*, - # or minus this value if *negative* is 1. - # Requires `n \ge 2` and that the top limb of *src* is nonzero. - # Note that *fmpz_set_ui*, *fmpz_neg_ui* can be used for single-limb integers. - void fmpz_lshift_mpn(fmpz_t z, mp_srcptr src, mp_size_t n, int negative, flint_bitcnt_t shift) noexcept - # Sets *z* to the integer represented by the *n* limbs in the array *src*, - # or minus this value if *negative* is 1, shifted left by *shift* bits. - # Requires `n \ge 1` and that the top limb of *src* is nonzero. diff --git a/src/sage/libs/flint/fmpz_factor.pxd b/src/sage/libs/flint/fmpz_factor.pxd index 75d29a50de1..1e93305c7f5 100644 --- a/src/sage/libs/flint/fmpz_factor.pxd +++ b/src/sage/libs/flint/fmpz_factor.pxd @@ -2,7 +2,9 @@ # distutils: depends = flint/fmpz_factor.h ################################################################################ -# This file is auto-generated. Do not modify by hand +# This file is auto-generated by the script +# SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py. +# Do not modify by hand! Fix and rerun the script instead. ################################################################################ from libc.stdio cimport FILE @@ -11,213 +13,28 @@ from sage.libs.mpfr.types cimport * from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void fmpz_factor_init(fmpz_factor_t factor) noexcept - # Initialises an ``fmpz_factor_t`` structure. - void fmpz_factor_clear(fmpz_factor_t factor) noexcept - # Clears an ``fmpz_factor_t`` structure. - void _fmpz_factor_append_ui(fmpz_factor_t factor, mp_limb_t p, ulong exp) noexcept - # Append a factor `p` to the given exponent to the - # ``fmpz_factor_t`` structure ``factor``. - void _fmpz_factor_append(fmpz_factor_t factor, const fmpz_t p, ulong exp) noexcept - # Append a factor `p` to the given exponent to the - # ``fmpz_factor_t`` structure ``factor``. - void fmpz_factor(fmpz_factor_t factor, const fmpz_t n) noexcept - # Factors `n` into prime numbers. If `n` is zero or negative, the - # sign field of the ``factor`` object will be set accordingly. - int fmpz_factor_smooth(fmpz_factor_t factor, const fmpz_t n, slong bits, int proved) noexcept - # Factors `n` into prime numbers up to approximately the given number of - # bits and possibly one additional cofactor, which may or may not be prime. - # If the number is definitely factored fully, the return value is `1`, - # otherwise the final factor (which may have exponent greater than `1`) - # is composite and needs to be factored further. - # If the number has a factor of around the given number of bits, there is - # at least a two-thirds chance of finding it. Smaller factors should be - # found with a much higher probability. - # The amount of time spent factoring can be controlled by lowering or - # increasing ``bits``. However, the quadratic sieve may be faster if - # ``bits`` is set to more than one third of the number of bits of `n`. - # The function uses trial factoring up to ``bits = 15``, followed by - # a primality test and a perfect power test to check if the factorisation - # is complete. If ``bits`` is at least 16, it proceeds to use the - # elliptic curve method to look for larger factors. - # The behavior of primality testing is determined by the ``proved`` - # parameter: - # If ``proved`` is set to `1` the function will prove all factors prime - # (other than the last factor, if the return value is `0`). - # If ``proved`` is set to `0`, the function will only check that factors are - # probable primes. - # If ``proved`` is set to `-1`, the function will not test primality - # after performing trial division. A perfect power test is still performed. - # As an exception to the rules stated above, this function will call - # ``n_factor`` internally if `n` or the remainder after trial division - # is smaller than one word, guaranteeing a complete factorisation. - void fmpz_factor_si(fmpz_factor_t factor, slong n) noexcept - # Like ``fmpz_factor``, but takes a machine integer `n` as input. - int fmpz_factor_trial_range(fmpz_factor_t factor, const fmpz_t n, ulong start, ulong num_primes) noexcept - # Factors `n` into prime factors using trial division. If `n` is - # zero or negative, the sign field of the ``factor`` object will be - # set accordingly. - # The algorithm starts with the given start index in the ``flint_primes`` - # table and uses at most ``num_primes`` primes from that point. - # The function returns 1 if `n` is completely factored, otherwise it returns - # `0`. - int fmpz_factor_trial(fmpz_factor_t factor, const fmpz_t n, slong num_primes) noexcept - # Factors `n` into prime factors using trial division. If `n` is - # zero or negative, the sign field of the ``factor`` object will be - # set accordingly. - # The algorithm uses the given number of primes, which must be in the range - # `[0, 3512]`. An exception is raised if a number outside this range is - # passed. - # The function returns 1 if `n` is completely factored, otherwise it returns - # `0`. - # The final entry in the factor struct is set to the cofactor after removing - # prime factors, if this is not `1`. - void fmpz_factor_refine(fmpz_factor_t res, const fmpz_factor_t f) noexcept - # Attempts to improve a partial factorization of an integer by "refining" - # the factorization ``f`` to a more complete factorization ``res`` - # whose bases are pairwise relatively prime. - # This function does not require its input to be in canonical form, - # nor does it guarantee that the resulting factorization will be canonical. - void fmpz_factor_expand_iterative(fmpz_t n, const fmpz_factor_t factor) noexcept - # Evaluates an integer in factored form back to an ``fmpz_t``. - # This currently exponentiates the bases separately and multiplies - # them together one by one, although much more efficient algorithms - # exist. - int fmpz_factor_pp1(fmpz_t factor, const fmpz_t n, ulong B1, ulong B2_sqrt, ulong c) noexcept - # Use Williams' `p + 1` method to factor `n`, using a prime bound in - # stage 1 of ``B1`` and a prime limit in stage 2 of at least the square - # of ``B2_sqrt``. If a factor is found, the function returns `1` and - # ``factor`` is set to the factor that is found. Otherwise, the function - # returns `0`. - # The value `c` should be a random value greater than `2`. Successive - # calls to the function with different values of `c` give additional - # chances to factor `n` with roughly exponentially decaying probability - # of finding a factor which has been missed (if `p+1` or `p-1` is not - # smooth for any prime factors `p` of `n` then the function will - # not ever succeed). - int fmpz_factor_pollard_brent_single(fmpz_t p_factor, fmpz_t n_in, fmpz_t yi, fmpz_t ai, mp_limb_t max_iters) noexcept - # Pollard Rho algorithm for integer factorization. Assumes that the `n` is - # not prime. ``factor`` is set as the factor if found. Takes as input the initial - # value `y`, to start polynomial evaluation, and `a`, the constant of the polynomial - # used. It is not assured that the factor found will be prime. Does not compute - # the complete factorization, just one factor. Returns the number of limbs of - # factor if factorization is successful (non trivial factor is found), else returns 0. - # ``max_iters`` is the number of iterations tried in process of finding the cycle. - # If the algorithm fails to find a non trivial factor in one call, it tries again - # (this time with a different set of random values). - int fmpz_factor_pollard_brent(fmpz_t factor, flint_rand_t state, fmpz_t n, mp_limb_t max_tries, mp_limb_t max_iters) noexcept - # Pollard Rho algorithm for integer factorization. Assumes that the `n` is - # not prime. ``factor`` is set as the factor if found. It is not assured that the - # factor found will be prime. Does not compute the complete factorization, - # just one factor. Returns the number of limbs of factor if factorization is - # successful (non trivial factor is found), else returns 0. - # ``max_iters`` is the number of iterations tried in process of finding the cycle. - # If the algorithm fails to find a non trivial factor in one call, it tries again - # (this time with a different set of random values). This process is repeated a - # maximum of ``max_tries`` times. - # The algorithm used is a modification of the original Pollard Rho algorithm, - # suggested by Richard Brent. It can be found in the paper available at - # https://maths-people.anu.edu.au/~brent/pd/rpb051i.pdf - void fmpz_factor_ecm_init(ecm_t ecm_inf, mp_limb_t sz) noexcept - # Initializes the ``ecm_t`` struct. This is needed in some functions - # and carries data between subsequent calls. - void fmpz_factor_ecm_clear(ecm_t ecm_inf) noexcept - # Clears the ``ecm_t`` struct. - void fmpz_factor_ecm_addmod(mp_ptr a, mp_ptr b, mp_ptr c, mp_ptr n, mp_limb_t n_size) noexcept - # Sets `a` to `(b + c)` ``%`` `n`. This is not a normal add mod function, - # it assumes `n` is normalized (highest bit set) and `b` and `c` are reduced - # modulo `n`. - # Used for arithmetic operations in ``fmpz_factor_ecm``. - void fmpz_factor_ecm_submod(mp_ptr x, mp_ptr a, mp_ptr b, mp_ptr n, mp_limb_t n_size) noexcept - # Sets `x` to `(a - b)` ``%`` `n`. This is not a normal subtract mod - # function, it assumes `n` is normalized (highest bit set) - # and `b` and `c` are reduced modulo `n`. - # Used for arithmetic operations in ``fmpz_factor_ecm``. - void fmpz_factor_ecm_double(mp_ptr x, mp_ptr z, mp_ptr x0, mp_ptr z0, mp_ptr n, ecm_t ecm_inf) noexcept - # Sets the point `(x : z)` to two times `(x_0 : z_0)` modulo `n` according - # to the formula - # .. math :: - # x = (x_0 + z_0)^2 \cdot (x_0 - z_0)^2 \mod n, - # .. math :: - # z = 4 x_0 z_0 \left((x_0 - z_0)^2 + 4a_{24}x_0z_0\right) \mod n. - # ``ecm_inf`` is used just to use temporary ``mp_ptr``'s in the - # structure. This group doubling is valid only for points expressed in - # Montgomery projective coordinates. - void fmpz_factor_ecm_add(mp_ptr x, mp_ptr z, mp_ptr x1, mp_ptr z1, mp_ptr x2, mp_ptr z2, mp_ptr x0, mp_ptr z0, mp_ptr n, ecm_t ecm_inf) noexcept - # Sets the point `(x : z)` to the sum of `(x_1 : z_1)` and `(x_2 : z_2)` - # modulo `n`, given the difference `(x_0 : z_0)` according to the formula - # .. math :: - # x = 4z_0(x_1x_2 - z_1z_2)^2 \mod n, \\ z = 4x_0(x_2z_1 - x_1z_2)^2 \mod n. - # ``ecm_inf`` is used just to use temporary ``mp_ptr``'s in the - # structure. This group addition is valid only for points expressed in - # Montgomery projective coordinates. - void fmpz_factor_ecm_mul_montgomery_ladder(mp_ptr x, mp_ptr z, mp_ptr x0, mp_ptr z0, mp_limb_t k, mp_ptr n, ecm_t ecm_inf) noexcept - # Montgomery ladder algorithm for scalar multiplication of elliptic points. - # Sets the point `(x : z)` to `k(x_0 : z_0)` modulo `n`. - # ``ecm_inf`` is used just to use temporary ``mp_ptr``'s in the - # structure. Valid only for points expressed in Montgomery projective - # coordinates. - int fmpz_factor_ecm_select_curve(mp_ptr f, mp_ptr sigma, mp_ptr n, ecm_t ecm_inf) noexcept - # Selects a random elliptic curve given a random integer ``sigma``, - # according to Suyama's parameterization. If the factor is found while - # selecting the curve, the number of limbs required to store the factor - # is returned, otherwise `0`. - # It could be possible that the selected curve is unsuitable for further - # computations, in such a case, `-1` is returned. - # Also selects the initial point `x_0`, and the value of `(a + 2)/4`, where `a` - # is a curve parameter. Sets `z_0` as `1`. All these are stored in the - # ``ecm_t`` struct. - # The curve selected is of Montgomery form, the points selected satisfy the - # curve and are projective coordinates. - - int fmpz_factor_ecm_stage_I(mp_ptr f, const mp_limb_t *prime_array, mp_limb_t num, mp_limb_t B1, mp_ptr n, ecm_t ecm_inf) noexcept - # Stage I implementation of the ECM algorithm. - # ``f`` is set as the factor if found. ``num`` is number of prime numbers - # `\le` the bound ``B1``. ``prime_array`` is an array of first ``B1`` - # primes. `n` is the number being factored. - # If the factor is found, number of words required to store the factor is - # returned, otherwise `0`. - + int fmpz_factor_ecm_stage_I(mp_ptr f, const mp_limb_t * prime_array, mp_limb_t num, mp_limb_t B1, mp_ptr n, ecm_t ecm_inf) noexcept int fmpz_factor_ecm_stage_II(mp_ptr f, mp_limb_t B1, mp_limb_t B2, mp_limb_t P, mp_ptr n, ecm_t ecm_inf) noexcept - # Stage II implementation of the ECM algorithm. - # ``f`` is set as the factor if found. ``B1``, ``B2`` are the two - # bounds. ``P`` is the primorial (approximately equal to `\sqrt{B2}`). - # `n` is the number being factored. - # If the factor is found, number of words required to store the factor is - # returned, otherwise `0`. - int fmpz_factor_ecm(fmpz_t f, mp_limb_t curves, mp_limb_t B1, mp_limb_t B2, flint_rand_t state, const fmpz_t n_in) noexcept - # Outer wrapper function for the ECM algorithm. In case ``f`` can fit - # in a single unsigned word, a call to ``n_factor_ecm`` is made. - # The function calls stage I and II, and - # the precomputations (builds ``prime_array`` for stage I, - # ``GCD_table`` and ``prime_table`` for stage II). - # ``f`` is set as the factor if found. ``curves`` is the number of - # random curves being tried. ``B1``, ``B2`` are the two bounds or - # stage I and stage II. `n` is the number being factored. - # If a factor is found in stage I, `1` is returned. - # If a factor is found in stage II, `2` is returned. - # If a factor is found while selecting the curve, `-1` is returned. - # Otherwise `0` is returned. diff --git a/src/sage/libs/flint/fmpz_factor_extra.pxd b/src/sage/libs/flint/fmpz_factor_sage.pxd similarity index 100% rename from src/sage/libs/flint/fmpz_factor_extra.pxd rename to src/sage/libs/flint/fmpz_factor_sage.pxd diff --git a/src/sage/libs/flint/fmpz_factor_extra.pyx b/src/sage/libs/flint/fmpz_factor_sage.pyx similarity index 100% rename from src/sage/libs/flint/fmpz_factor_extra.pyx rename to src/sage/libs/flint/fmpz_factor_sage.pyx diff --git a/src/sage/libs/flint/fmpz_lll.pxd b/src/sage/libs/flint/fmpz_lll.pxd index 71b55a38ed8..f673f775794 100644 --- a/src/sage/libs/flint/fmpz_lll.pxd +++ b/src/sage/libs/flint/fmpz_lll.pxd @@ -2,7 +2,9 @@ # distutils: depends = flint/fmpz_lll.h ################################################################################ -# This file is auto-generated. Do not modify by hand +# This file is auto-generated by the script +# SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py. +# Do not modify by hand! Fix and rerun the script instead. ################################################################################ from libc.stdio cimport FILE @@ -11,236 +13,35 @@ from sage.libs.mpfr.types cimport * from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void fmpz_lll_context_init_default(fmpz_lll_t fl) noexcept - # Sets ``fl->delta``, ``fl->eta``, ``fl->rt`` and ``fl->gt`` to - # their default values, 0.99, 0.51, `Z\_BASIS` and `APPROX` respectively. - void fmpz_lll_context_init(fmpz_lll_t fl, double delta, double eta, rep_type rt, gram_type gt) noexcept - # Sets ``fl->delta``, ``fl->eta``, ``fl->rt`` and ``fl->gt`` to - # ``delta``, ``eta``, ``rt`` and ``gt`` (given as input) - # respectively. ``delta`` and ``eta`` are the L^2 parameters. - # ``delta`` and ``eta`` must lie in the intervals `(0.25, 1)` and - # `(0.5, \sqrt{\mathtt{delta}})` respectively. The representation type is input - # using ``rt`` and can have the values `Z\_BASIS` for a lattice basis and - # `GRAM` for a Gram matrix. The Gram type to be used during computation can - # be specified using ``gt`` which can assume the values `APPROX` and - # `EXACT`. Note that ``gt`` has meaning only when ``rt`` is `Z\_BASIS`. - void fmpz_lll_randtest(fmpz_lll_t fl, flint_rand_t state) noexcept - # Sets ``fl->delta`` and ``fl->eta`` to random values in the interval - # `(0.25, 1)` and `(0.5, \sqrt{\mathtt{delta}})` respectively. ``fl->rt`` is - # set to `GRAM` or `Z\_BASIS` and ``fl->gt`` is set to `APPROX` or `EXACT` - # in a pseudo random way. - double fmpz_lll_heuristic_dot(const double * vec1, const double * vec2, slong len2, const fmpz_mat_t B, slong k, slong j, slong exp_adj) noexcept - # Computes the dot product of two vectors of doubles ``vec1`` and - # ``vec2``, which are respectively ``double`` approximations (up to - # scaling by a power of 2) to rows ``k`` and ``j`` in the exact integer - # matrix ``B``. If massive cancellation is detected an exact computation - # is made. - # The exact computation is scaled by `2^{-\mathtt{exp_adj}}`, where - # ``exp_adj = r2 + r1`` where `r2` is the exponent for row ``j`` and - # `r1` is the exponent for row ``k`` (i.e. row ``j`` is notionally - # thought of as being multiplied by `2^{r2}`, etc.). - # The final dot product computed by this function is then notionally the - # return value times `2^{\mathtt{exp_adj}}`. - - int fmpz_lll_check_babai(int kappa, fmpz_mat_t B, fmpz_mat_t U, d_mat_t mu, d_mat_t r, double *s, d_mat_t appB, int *expo, fmpz_gram_t A, int a, int zeros, int kappamax, int n, const fmpz_lll_t fl) noexcept - # Performs floating point size reductions of the ``kappa``-th row of - # ``B`` by all of the previous rows, uses d_mats ``mu`` and ``r`` - # for storing the GSO data. ``U`` is used to capture the unimodular - # transformations if it is not `NULL`. The ``double`` array ``s`` will - # contain the size of the ``kappa``-th row if it were moved into position - # `i`. The d_mat ``appB`` is an approximation of ``B`` with each row - # receiving an exponent stored in ``expo`` which gets populated only when - # needed. The d_mat ``A->appSP`` is an approximation of the Gram matrix - # whose entries are scalar products of the rows of ``B`` and is used when - # ``fl->gt`` == `APPROX`. When ``fl->gt`` == `EXACT` the fmpz_mat - # ``A->exactSP`` (the exact Gram matrix) is used. The index ``a`` is - # the smallest row index which will be reduced from the ``kappa``-th row. - # Index ``zeros`` is the number of zero rows in the matrix. - # ``kappamax`` is the highest index which has been size-reduced so far, - # and ``n`` is the number of columns you want to consider. ``fl`` is an - # LLL (L^2) context object. The output is the value -1 if the process fails - # (usually due to insufficient precision) or 0 if everything was successful. - # These descriptions will be true for the future Babai procedures as well. - - int fmpz_lll_check_babai_heuristic_d(int kappa, fmpz_mat_t B, fmpz_mat_t U, d_mat_t mu, d_mat_t r, double *s, d_mat_t appB, int *expo, fmpz_gram_t A, int a, int zeros, int kappamax, int n, const fmpz_lll_t fl) noexcept - # Same as :func:`fmpz_lll_check_babai` but using the heuristic inner product - # rather than a purely floating point inner product. The heuristic will - # compute at full precision when there is cancellation. - - int fmpz_lll_check_babai_heuristic(int kappa, fmpz_mat_t B, fmpz_mat_t U, mpf_mat_t mu, mpf_mat_t r, mpf *s, mpf_mat_t appB, fmpz_gram_t A, int a, int zeros, int kappamax, int n, mpf_t tmp, mpf_t rtmp, flint_bitcnt_t prec, const fmpz_lll_t fl) noexcept - # This function is like the ``mpf`` version of - # :func:`fmpz_lll_check_babai_heuristic_d`. However, it also inherits some - # temporary ``mpf_t`` variables ``tmp`` and ``rtmp``. - - int fmpz_lll_advance_check_babai(int cur_kappa, int kappa, fmpz_mat_t B, fmpz_mat_t U, d_mat_t mu, d_mat_t r, double *s, d_mat_t appB, int *expo, fmpz_gram_t A, int a, int zeros, int kappamax, int n, const fmpz_lll_t fl) noexcept - # This is a Babai procedure which is used when size reducing a vector beyond - # an index which LLL has reached. ``cur_kappa`` is the index behind which - # we can assume ``B`` is LLL reduced, while ``kappa`` is the vector to - # be reduced. This procedure only size reduces the ``kappa``-th row by - # vectors up to ``cur_kappa``, **not** ``kappa - 1``. - - int fmpz_lll_advance_check_babai_heuristic_d(int cur_kappa, int kappa, fmpz_mat_t B, fmpz_mat_t U, d_mat_t mu, d_mat_t r, double *s, d_mat_t appB, int *expo, fmpz_gram_t A, int a, int zeros, int kappamax, int n, const fmpz_lll_t fl) noexcept - # Same as :func:`fmpz_lll_advance_check_babai` but using the heuristic inner - # product rather than a purely floating point inner product. The heuristic - # will compute at full precision when there is cancellation. - + int fmpz_lll_check_babai(int kappa, fmpz_mat_t B, fmpz_mat_t U, d_mat_t mu, d_mat_t r, double * s, d_mat_t appB, int * expo, fmpz_gram_t A, int a, int zeros, int kappamax, int n, const fmpz_lll_t fl) noexcept + int fmpz_lll_check_babai_heuristic_d(int kappa, fmpz_mat_t B, fmpz_mat_t U, d_mat_t mu, d_mat_t r, double * s, d_mat_t appB, int * expo, fmpz_gram_t A, int a, int zeros, int kappamax, int n, const fmpz_lll_t fl) noexcept + int fmpz_lll_check_babai_heuristic(int kappa, fmpz_mat_t B, fmpz_mat_t U, mpf_mat_t mu, mpf_mat_t r, mpf * s, mpf_mat_t appB, fmpz_gram_t A, int a, int zeros, int kappamax, int n, mpf_t tmp, mpf_t rtmp, flint_bitcnt_t prec, const fmpz_lll_t fl) noexcept + int fmpz_lll_advance_check_babai(int cur_kappa, int kappa, fmpz_mat_t B, fmpz_mat_t U, d_mat_t mu, d_mat_t r, double * s, d_mat_t appB, int * expo, fmpz_gram_t A, int a, int zeros, int kappamax, int n, const fmpz_lll_t fl) noexcept + int fmpz_lll_advance_check_babai_heuristic_d(int cur_kappa, int kappa, fmpz_mat_t B, fmpz_mat_t U, d_mat_t mu, d_mat_t r, double * s, d_mat_t appB, int * expo, fmpz_gram_t A, int a, int zeros, int kappamax, int n, const fmpz_lll_t fl) noexcept int fmpz_lll_shift(const fmpz_mat_t B) noexcept - # Computes the largest number of non-zero entries after the diagonal in - # ``B``. - int fmpz_lll_d(fmpz_mat_t B, fmpz_mat_t U, const fmpz_lll_t fl) noexcept - # This is a mildly greedy version of floating point LLL using doubles only. - # It tries the fast version of the Babai algorithm - # (:func:`fmpz_lll_check_babai`). If that fails, then it switches to the - # heuristic version (:func:`fmpz_lll_check_babai_heuristic_d`) for only one - # loop and switches right back to the fast version. It reduces ``B`` in - # place. ``U`` is the matrix used to capture the unimodular - # transformations if it is not `NULL`. An exception is raised if `U` != `NULL` - # and ``U->r`` != `d`, where `d` is the lattice dimension. ``fl`` is the - # context object containing information containing the LLL parameters \delta - # and \eta. The function can perform reduction on both the lattice basis as - # well as its Gram matrix. The type of lattice representation can be - # specified via the parameter ``fl->rt``. The type of Gram matrix to be - # used in computation (approximate or exact) can also be specified through - # the variable ``fl->gt`` (applies only if ``fl->rt`` == `Z\_BASIS`). - int fmpz_lll_d_heuristic(fmpz_mat_t B, fmpz_mat_t U, const fmpz_lll_t fl) noexcept - # This LLL reduces ``B`` in place using doubles only. It is similar to - # :func:`fmpz_lll_d` but only uses the heuristic inner products which - # attempt to detect cancellations. - int fmpz_lll_mpf2(fmpz_mat_t B, fmpz_mat_t U, flint_bitcnt_t prec, const fmpz_lll_t fl) noexcept - # This is LLL using ``mpf`` with the given precision, ``prec`` for the - # underlying GSO. It reduces ``B`` in place like the other LLL functions. - # The `mpf2` in the function name refers to the way the ``mpf_t``'s are - # initialised. - int fmpz_lll_mpf(fmpz_mat_t B, fmpz_mat_t U, const fmpz_lll_t fl) noexcept - # A wrapper of :func:`fmpz_lll_mpf2`. This currently begins with - # `prec == D\_BITS`, then for the first 20 loops, increases the precision one - # limb at a time. After 20 loops, it doubles the precision each time. There - # is a proof that this will eventually work. The return value of this - # function is 0 if the LLL is successful or -1 if the precision maxes out - # before ``B`` is LLL-reduced. - int fmpz_lll_wrapper(fmpz_mat_t B, fmpz_mat_t U, const fmpz_lll_t fl) noexcept - # A wrapper of the above procedures. It begins with the greediest version - # (:func:`fmpz_lll_d`), then adapts to the version using heuristic inner - # products only (:func:`fmpz_lll_d_heuristic`) if ``fl->rt`` == `Z\_BASIS` and - # ``fl->gt`` == `APPROX`, and finally to the mpf version (:func:`fmpz_lll_mpf`) - # if needed. - # ``U`` is the matrix used to capture the unimodular - # transformations if it is not `NULL`. An exception is raised if `U` != `NULL` - # and ``U->r`` != `d`, where `d` is the lattice dimension. ``fl`` is the - # context object containing information containing the LLL parameters \delta - # and \eta. The function can perform reduction on both the lattice basis as - # well as its Gram matrix. The type of lattice representation can be - # specified via the parameter ``fl->rt``. The type of Gram matrix to be - # used in computation (approximate or exact) can also be specified through - # the variable ``fl->gt`` (applies only if ``fl->rt`` == `Z\_BASIS`). - int fmpz_lll_d_with_removal(fmpz_mat_t B, fmpz_mat_t U, const fmpz_t gs_B, const fmpz_lll_t fl) noexcept - # Same as :func:`fmpz_lll_d` but with a removal bound, ``gs_B``. The - # return value is the new dimension of ``B`` if removals are desired. - int fmpz_lll_d_heuristic_with_removal(fmpz_mat_t B, fmpz_mat_t U, const fmpz_t gs_B, const fmpz_lll_t fl) noexcept - # Same as :func:`fmpz_lll_d_heuristic` but with a removal bound, - # ``gs_B``. The return value is the new dimension of ``B`` if removals - # are desired. - int fmpz_lll_mpf2_with_removal(fmpz_mat_t B, fmpz_mat_t U, flint_bitcnt_t prec, const fmpz_t gs_B, const fmpz_lll_t fl) noexcept - # Same as :func:`fmpz_lll_mpf2` but with a removal bound, ``gs_B``. The - # return value is the new dimension of ``B`` if removals are desired. - int fmpz_lll_mpf_with_removal(fmpz_mat_t B, fmpz_mat_t U, const fmpz_t gs_B, const fmpz_lll_t fl) noexcept - # A wrapper of :func:`fmpz_lll_mpf2_with_removal`. This currently begins - # with `prec == D\_BITS`, then for the first 20 loops, increases the precision - # one limb at a time. After 20 loops, it doubles the precision each time. - # There is a proof that this will eventually work. The return value of this - # function is the new dimension of ``B`` if removals are desired or -1 if - # the precision maxes out before ``B`` is LLL-reduced. - int fmpz_lll_wrapper_with_removal(fmpz_mat_t B, fmpz_mat_t U, const fmpz_t gs_B, const fmpz_lll_t fl) noexcept - # A wrapper of the procedures implementing the base case LLL with the - # addition of the removal boundary. It begins with the greediest version - # (:func:`fmpz_lll_d_with_removal`), then adapts to the version using - # heuristic inner products only (:func:`fmpz_lll_d_heuristic_with_removal`) - # if ``fl->rt`` == `Z\_BASIS` and ``fl->gt`` == `APPROX`, and finally to the mpf - # version (:func:`fmpz_lll_mpf_with_removal`) if needed. - int fmpz_lll_d_with_removal_knapsack(fmpz_mat_t B, fmpz_mat_t U, const fmpz_t gs_B, const fmpz_lll_t fl) noexcept - # This is floating point LLL specialized to knapsack-type lattices. It - # performs early size reductions occasionally which makes things faster in - # the knapsack case. Otherwise, it is similar to - # ``fmpz_lll_d_with_removal``. - int fmpz_lll_wrapper_with_removal_knapsack(fmpz_mat_t B, fmpz_mat_t U, const fmpz_t gs_B, const fmpz_lll_t fl) noexcept - # A wrapper of the procedures implementing the LLL specialized to - # knapsack-type lattices. It begins with the greediest version and the engine - # of this version, (:func:`fmpz_lll_d_with_removal_knapsack`), then adapts - # to the version using heuristic inner products only - # (:func:`fmpz_lll_d_heuristic_with_removal`) if ``fl->rt`` == `Z\_BASIS` and - # ``fl->gt`` == `APPROX`, and finally to the mpf version - # (:func:`fmpz_lll_mpf_with_removal`) if needed. - int fmpz_lll_with_removal_ulll(fmpz_mat_t FM, fmpz_mat_t UM, slong new_size, const fmpz_t gs_B, const fmpz_lll_t fl) noexcept - # ULLL is a new style of LLL which adjoins an identity matrix to the - # input lattice ``FM``, then scales the lattice down to ``new_size`` - # bits and reduces this augmented lattice. This tends to be more stable - # numerically than traditional LLL which means higher dimensions can be - # attacked using doubles. In each iteration a new identity matrix is adjoined - # to the truncated lattice. ``UM`` is used to capture the unimodular - # transformations, while ``gs_B`` and ``fl`` have the same role as in - # the previous routines. The function is optimised for factoring polynomials. - bint fmpz_lll_is_reduced_d(const fmpz_mat_t B, const fmpz_lll_t fl) noexcept bint fmpz_lll_is_reduced_mpfr(const fmpz_mat_t B, const fmpz_lll_t fl, flint_bitcnt_t prec) noexcept bint fmpz_lll_is_reduced_d_with_removal(const fmpz_mat_t B, const fmpz_lll_t fl, const fmpz_t gs_B, int newd) noexcept bint fmpz_lll_is_reduced_mpfr_with_removal(const fmpz_mat_t B, const fmpz_lll_t fl, const fmpz_t gs_B, int newd, flint_bitcnt_t prec) noexcept - # A non-zero return indicates the matrix is definitely reduced, that is, that - # * :func:`fmpz_mat_is_reduced` or :func:`fmpz_mat_is_reduced_gram` (for the first two) - # * :func:`fmpz_mat_is_reduced_with_removal` or :func:`fmpz_mat_is_reduced_gram_with_removal` (for the last two) - # return non-zero. A zero return value is inconclusive. - # The `_d` variants are performed in machine precision, while the `_mpfr` uses a precision of `prec` bits. - bint fmpz_lll_is_reduced(const fmpz_mat_t B, const fmpz_lll_t fl, flint_bitcnt_t prec) noexcept bint fmpz_lll_is_reduced_with_removal(const fmpz_mat_t B, const fmpz_lll_t fl, const fmpz_t gs_B, int newd, flint_bitcnt_t prec) noexcept - # The return from these functions is always conclusive: the functions - # * :func:`fmpz_mat_is_reduced` or :func:`fmpz_mat_is_reduced_gram` - # * :func:`fmpz_mat_is_reduced_with_removal` or :func:`fmpz_mat_is_reduced_gram_with_removal` - # are optimzied by calling the above heuristics first and returning right away if they give a conclusive answer. - void fmpz_lll_storjohann_ulll(fmpz_mat_t FM, slong new_size, const fmpz_lll_t fl) noexcept - # Performs ULLL using :func:`fmpz_mat_lll_storjohann` as the LLL function. - void fmpz_lll(fmpz_mat_t B, fmpz_mat_t U, const fmpz_lll_t fl) noexcept - # Reduces ``B`` in place according to the parameters specified by the - # LLL context object ``fl``. - # This is the main LLL function which should be called by the user. It - # currently calls the ULLL algorithm (without removals). The ULLL function - # in turn calls a LLL wrapper which tries to choose an optimal LLL algorithm, - # starting with a version using just doubles (ULLL tries to maximise usage - # of this), then a heuristic LLL followed by a full precision floating point - # LLL if required. - # ``U`` is the matrix used to capture the unimodular - # transformations if it is not `NULL`. An exception is raised if `U` != `NULL` - # and ``U->r`` != `d`, where `d` is the lattice dimension. ``fl`` is the - # context object containing information containing the LLL parameters \delta - # and \eta. The function can perform reduction on both the lattice basis as - # well as its Gram matrix. The type of lattice representation can be - # specified via the parameter ``fl->rt``. The type of Gram matrix to be - # used in computation (approximate or exact) can also be specified through - # the variable ``fl->gt`` (applies only if ``fl->rt`` == `Z\_BASIS`). - int fmpz_lll_with_removal(fmpz_mat_t B, fmpz_mat_t U, const fmpz_t gs_B, const fmpz_lll_t fl) noexcept - # Reduces ``B`` in place according to the parameters specified by the - # LLL context object ``fl`` and removes vectors whose squared Gram-Schmidt - # length is greater than the bound ``gs_B``. The return value is the new - # dimension of ``B`` to be considered for further computation. - # This is the main LLL with removals function which should be called by - # the user. Like ``fmpz_lll`` it calls ULLL, but it also sets the - # Gram-Schmidt bound to that supplied and does removals. diff --git a/src/sage/libs/flint/fmpz_macros.pxd b/src/sage/libs/flint/fmpz_macros.pxd new file mode 100644 index 00000000000..4256a213c21 --- /dev/null +++ b/src/sage/libs/flint/fmpz_macros.pxd @@ -0,0 +1,7 @@ +# Macros from fmpz_poly.h +# See https://github.com/flintlib/flint/issues/1529 + +from .types cimport * + +cdef extern from "flint_wrap.h": + bint COEFF_IS_MPZ(fmpz f) diff --git a/src/sage/libs/flint/fmpz_mat.pxd b/src/sage/libs/flint/fmpz_mat.pxd index 7ac2e3ae909..abde570c32f 100644 --- a/src/sage/libs/flint/fmpz_mat.pxd +++ b/src/sage/libs/flint/fmpz_mat.pxd @@ -2,7 +2,9 @@ # distutils: depends = flint/fmpz_mat.h ################################################################################ -# This file is auto-generated. Do not modify by hand +# This file is auto-generated by the script +# SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py. +# Do not modify by hand! Fix and rerun the script instead. ################################################################################ from libc.stdio cimport FILE @@ -11,979 +13,170 @@ from sage.libs.mpfr.types cimport * from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void fmpz_mat_init(fmpz_mat_t mat, slong rows, slong cols) noexcept - # Initialises a matrix with the given number of rows and columns for use. - void fmpz_mat_clear(fmpz_mat_t mat) noexcept - # Clears the given matrix. - void fmpz_mat_set(fmpz_mat_t mat1, const fmpz_mat_t mat2) noexcept - # Sets ``mat1`` to a copy of ``mat2``. The dimensions of - # ``mat1`` and ``mat2`` must be the same. - void fmpz_mat_init_set(fmpz_mat_t mat, const fmpz_mat_t src) noexcept - # Initialises the matrix ``mat`` to the same size as ``src`` and - # sets it to a copy of ``src``. - slong fmpz_mat_nrows(const fmpz_mat_t mat) noexcept slong fmpz_mat_ncols(const fmpz_mat_t mat) noexcept - # Returns respectively the number of rows and columns of the matrix. - void fmpz_mat_swap(fmpz_mat_t mat1, fmpz_mat_t mat2) noexcept - # Swaps two matrices. The dimensions of ``mat1`` and ``mat2`` - # are allowed to be different. - void fmpz_mat_swap_entrywise(fmpz_mat_t mat1, fmpz_mat_t mat2) noexcept - # Swaps two matrices by swapping the individual entries rather than swapping - # the contents of the structs. - fmpz * fmpz_mat_entry(const fmpz_mat_t mat, slong i, slong j) noexcept - # Returns a reference to the entry of ``mat`` at row `i` and column `j`. - # This reference can be passed as an input or output variable to any - # function in the ``fmpz`` module for direct manipulation. - # Both `i` and `j` must not exceed the dimensions of the matrix. - # This function is implemented as a macro. - void fmpz_mat_zero(fmpz_mat_t mat) noexcept - # Sets all entries of ``mat`` to 0. - void fmpz_mat_one(fmpz_mat_t mat) noexcept - # Sets ``mat`` to the unit matrix, having ones on the main diagonal - # and zeroes elsewhere. If ``mat`` is nonsquare, it is set to the - # truncation of a unit matrix. - void fmpz_mat_swap_rows(fmpz_mat_t mat, slong * perm, slong r, slong s) noexcept - # Swaps rows ``r`` and ``s`` of ``mat``. If ``perm`` is non-``NULL``, the - # permutation of the rows will also be applied to ``perm``. - void fmpz_mat_swap_cols(fmpz_mat_t mat, slong * perm, slong r, slong s) noexcept - # Swaps columns ``r`` and ``s`` of ``mat``. If ``perm`` is non-``NULL``, the - # permutation of the columns will also be applied to ``perm``. - void fmpz_mat_invert_rows(fmpz_mat_t mat, slong * perm) noexcept - # Swaps rows ``i`` and ``r - i`` of ``mat`` for ``0 <= i < r/2``, where - # ``r`` is the number of rows of ``mat``. If ``perm`` is non-``NULL``, the - # permutation of the rows will also be applied to ``perm``. - void fmpz_mat_invert_cols(fmpz_mat_t mat, slong * perm) noexcept - # Swaps columns ``i`` and ``c - i`` of ``mat`` for ``0 <= i < c/2``, where - # ``c`` is the number of columns of ``mat``. If ``perm`` is non-``NULL``, the - # permutation of the columns will also be applied to ``perm``. - void fmpz_mat_window_init(fmpz_mat_t window, const fmpz_mat_t mat, slong r1, slong c1, slong r2, slong c2) noexcept - # Initializes the matrix ``window`` to be an ``r2 - r1`` by - # ``c2 - c1`` submatrix of ``mat`` whose ``(0,0)`` entry - # is the ``(r1, c1)`` entry of ``mat``. The memory for the - # elements of ``window`` is shared with ``mat``. - void fmpz_mat_window_clear(fmpz_mat_t window) noexcept - # Clears the matrix ``window`` and releases any memory that it - # uses. Note that the memory to the underlying matrix that - # ``window`` points to is not freed. - void fmpz_mat_randbits(fmpz_mat_t mat, flint_rand_t state, flint_bitcnt_t bits) noexcept - # Sets the entries of ``mat`` to random signed integers whose absolute - # values have the given number of binary bits. - void fmpz_mat_randtest(fmpz_mat_t mat, flint_rand_t state, flint_bitcnt_t bits) noexcept - # Sets the entries of ``mat`` to random signed integers whose - # absolute values have a random number of bits up to the given number - # of bits inclusive. - void fmpz_mat_randintrel(fmpz_mat_t mat, flint_rand_t state, flint_bitcnt_t bits) noexcept - # Sets ``mat`` to be a random *integer relations* matrix, with - # signed entries up to the given number of bits. - # The number of columns of ``mat`` must be equal to one more than - # the number of rows. The format of the matrix is a set of random integers - # in the left hand column and an identity matrix in the remaining square - # submatrix. - void fmpz_mat_randsimdioph(fmpz_mat_t mat, flint_rand_t state, flint_bitcnt_t bits, flint_bitcnt_t bits2) noexcept - # Sets ``mat`` to a random *simultaneous diophantine* matrix. - # The matrix must be square. The top left entry is set to ``2^bits2``. - # The remainder of that row is then set to signed random integers of the - # given number of binary bits. The remainder of the first column is zero. - # Running down the rest of the diagonal are the values ``2^bits`` with - # all remaining entries zero. - void fmpz_mat_randntrulike(fmpz_mat_t mat, flint_rand_t state, flint_bitcnt_t bits, ulong q) noexcept - # Sets a square matrix ``mat`` of even dimension to a random - # *NTRU like* matrix. - # The matrix is broken into four square submatrices. The top left submatrix - # is set to the identity. The bottom left submatrix is set to the zero - # matrix. The bottom right submatrix is set to `q` times the identity matrix. - # Finally the top right submatrix has the following format. A random vector - # `h` of length `r/2` is created, with random signed entries of the given - # number of bits. Then entry `(i, j)` of the submatrix is set to - # `h[i + j \bmod{r/2}]`. - void fmpz_mat_randntrulike2(fmpz_mat_t mat, flint_rand_t state, flint_bitcnt_t bits, ulong q) noexcept - # Sets a square matrix ``mat`` of even dimension to a random - # *NTRU like* matrix. - # The matrix is broken into four square submatrices. The top left submatrix - # is set to `q` times the identity matrix. The top right submatrix is set to - # the zero matrix. The bottom right submatrix is set to the identity matrix. - # Finally the bottom left submatrix has the following format. A random vector - # `h` of length `r/2` is created, with random signed entries of the given - # number of bits. Then entry `(i, j)` of the submatrix is set to - # `h[i + j \bmod{r/2}]`. - void fmpz_mat_randajtai(fmpz_mat_t mat, flint_rand_t state, double alpha) noexcept - # Sets a square matrix ``mat`` to a random *ajtai* matrix. - # The diagonal entries `(i, i)` are set to a random entry in the range - # `[1, 2^{b-1}]` inclusive where `b = \lfloor(2 r - i)^\alpha\rfloor` for some - # double parameter `\alpha`. The entries below the diagonal in column `i` - # are set to a random entry in the range `(-2^b + 1, 2^b - 1)` whilst the - # entries to the right of the diagonal in row `i` are set to zero. - int fmpz_mat_randpermdiag(fmpz_mat_t mat, flint_rand_t state, const fmpz * diag, slong n) noexcept - # Sets ``mat`` to a random permutation of the rows and columns of a - # given diagonal matrix. The diagonal matrix is specified in the form of - # an array of the `n` initial entries on the main diagonal. - # The return value is `0` or `1` depending on whether the permutation is - # even or odd. - void fmpz_mat_randrank(fmpz_mat_t mat, flint_rand_t state, slong rank, flint_bitcnt_t bits) noexcept - # Sets ``mat`` to a random sparse matrix with the given rank, - # having exactly as many non-zero elements as the rank, with the - # nonzero elements being random integers of the given bit size. - # The matrix can be transformed into a dense matrix with unchanged - # rank by subsequently calling :func:`fmpz_mat_randops`. - void fmpz_mat_randdet(fmpz_mat_t mat, flint_rand_t state, const fmpz_t det) noexcept - # Sets ``mat`` to a random sparse matrix with minimal number of - # nonzero entries such that its determinant has the given value. - # Note that the matrix will be zero if ``det`` is zero. - # In order to generate a non-zero singular matrix, the function - # :func:`fmpz_mat_randrank` can be used. - # The matrix can be transformed into a dense matrix with unchanged - # determinant by subsequently calling :func:`fmpz_mat_randops`. - void fmpz_mat_randops(fmpz_mat_t mat, flint_rand_t state, slong count) noexcept - # Randomises ``mat`` by performing elementary row or column operations. - # More precisely, at most ``count`` random additions or subtractions of - # distinct rows and columns will be performed. This leaves the rank - # (and for square matrices, the determinant) unchanged. - int fmpz_mat_fprint(FILE * file, const fmpz_mat_t mat) noexcept - # Prints the given matrix to the stream ``file``. The format is - # the number of rows, a space, the number of columns, two spaces, then - # a space separated list of coefficients, one row after the other. - # In case of success, returns a positive value; otherwise, returns - # a non-positive value. - int fmpz_mat_fprint_pretty(FILE * file, const fmpz_mat_t mat) noexcept - # Prints the given matrix to the stream ``file``. The format is an - # opening square bracket, then on each line a row of the matrix, followed - # by a closing square bracket. Each row is written as an opening square - # bracket followed by a space separated list of coefficients followed - # by a closing square bracket. - # In case of success, returns a positive value; otherwise, returns - # a non-positive value. - int fmpz_mat_print(const fmpz_mat_t mat) noexcept - # Prints the given matrix to the stream ``stdout``. For further - # details, see :func:`fmpz_mat_fprint`. - int fmpz_mat_print_pretty(const fmpz_mat_t mat) noexcept - # Prints the given matrix to ``stdout``. For further details, - # see :func:`fmpz_mat_fprint_pretty`. - - int fmpz_mat_fread(FILE* file, fmpz_mat_t mat) noexcept - # Reads a matrix from the stream ``file``, storing the result - # in ``mat``. The expected format is the number of rows, a - # space, the number of columns, two spaces, then a space separated - # list of coefficients, one row after the other. - # In case of success, returns a positive number. In case of failure, - # returns a non-positive value. - + int fmpz_mat_fread(FILE * file, fmpz_mat_t mat) noexcept int fmpz_mat_read(fmpz_mat_t mat) noexcept - # Reads a matrix from ``stdin``, storing the result - # in ``mat``. - # In case of success, returns a positive number. In case of failure, - # returns a non-positive value. - bint fmpz_mat_equal(const fmpz_mat_t mat1, const fmpz_mat_t mat2) noexcept - # Returns a non-zero value if ``mat1`` and ``mat2`` have - # the same dimensions and entries, and zero otherwise. - bint fmpz_mat_is_zero(const fmpz_mat_t mat) noexcept - # Returns a non-zero value if all entries ``mat`` are zero, and - # otherwise returns zero. - bint fmpz_mat_is_one(const fmpz_mat_t mat) noexcept - # Returns a non-zero value if ``mat`` is the unit matrix or the truncation - # of a unit matrix, and otherwise returns zero. - bint fmpz_mat_is_empty(const fmpz_mat_t mat) noexcept - # Returns a non-zero value if the number of rows or the number of - # columns in ``mat`` is zero, and otherwise returns - # zero. - bint fmpz_mat_is_square(const fmpz_mat_t mat) noexcept - # Returns a non-zero value if the number of rows is equal to the - # number of columns in ``mat``, and otherwise returns zero. - bint fmpz_mat_is_zero_row(const fmpz_mat_t mat, slong i) noexcept - # Returns a non-zero value if row `i` of ``mat`` is zero. - bint fmpz_mat_equal_col(fmpz_mat_t M, slong m, slong n) noexcept - # Returns `1` if columns `m` and `n` of the matrix `M` are equal, otherwise - # returns `0`. - bint fmpz_mat_equal_row(fmpz_mat_t M, slong m, slong n) noexcept - # Returns `1` if rows `m` and `n` of the matrix `M` are equal, otherwise - # returns `0`. - void fmpz_mat_transpose(fmpz_mat_t B, const fmpz_mat_t A) noexcept - # Sets `B` to `A^T`, the transpose of `A`. Dimensions must be compatible. - # `A` and `B` are allowed to be the same object if `A` is a square matrix. - void fmpz_mat_concat_vertical(fmpz_mat_t res, const fmpz_mat_t mat1, const fmpz_mat_t mat2) noexcept - # Sets ``res`` to vertical concatenation of (``mat1``, ``mat2``) - # in that order. Matrix dimensions: ``mat1``: `m \times n`, - # ``mat2``: `k \times n`, ``res``: `(m + k) \times n`. - void fmpz_mat_concat_horizontal(fmpz_mat_t res, const fmpz_mat_t mat1, const fmpz_mat_t mat2) noexcept - # Sets ``res`` to horizontal concatenation of (``mat1``, ``mat2``) - # in that order. Matrix dimensions: ``mat1``: `m \times n`, - # ``mat2``: `m \times k`, ``res``: `m \times (n + k)`. - void fmpz_mat_get_nmod_mat(nmod_mat_t Amod, const fmpz_mat_t A) noexcept - # Sets the entries of ``Amod`` to the entries of ``A`` reduced - # by the modulus of ``Amod``. - void fmpz_mat_set_nmod_mat(fmpz_mat_t A, const nmod_mat_t Amod) noexcept - # Sets the entries of ``Amod`` to the residues in ``Amod``, - # normalised to the interval `-m/2 <= r < m/2` where `m` is the modulus. - void fmpz_mat_set_nmod_mat_unsigned(fmpz_mat_t A, const nmod_mat_t Amod) noexcept - # Sets the entries of ``Amod`` to the residues in ``Amod``, - # normalised to the interval `0 <= r < m` where `m` is the modulus. - void fmpz_mat_CRT_ui(fmpz_mat_t res, const fmpz_mat_t mat1, const fmpz_t m1, const nmod_mat_t mat2, int sign) noexcept - # Given ``mat1`` with entries modulo ``m`` and ``mat2`` - # with modulus `n`, sets ``res`` to the CRT reconstruction modulo `mn` - # with entries satisfying `-mn/2 <= c < mn/2` (if sign = 1) - # or `0 <= c < mn` (if sign = 0). - void fmpz_mat_multi_mod_ui_precomp(nmod_mat_t * residues, slong nres, const fmpz_mat_t mat, const fmpz_comb_t comb, fmpz_comb_temp_t temp) noexcept - # Sets each of the ``nres`` matrices in ``residues`` to ``mat`` reduced modulo - # the modulus of the respective matrix, given precomputed ``comb`` and - # ``comb_temp`` structures. - # Note: ``fmpz.h`` must be included **before** ``fmpz_mat.h`` in order for - # this function to be declared. - void fmpz_mat_multi_mod_ui(nmod_mat_t * residues, slong nres, const fmpz_mat_t mat) noexcept - # Sets each of the ``nres`` matrices in ``residues`` to ``mat`` - # reduced modulo the modulus of the respective matrix. - # This function is provided for convenience purposes. - # For reducing or reconstructing multiple integer matrices over the same - # set of moduli, it is faster to use ``fmpz_mat_multi_mod_precomp``. - void fmpz_mat_multi_CRT_ui_precomp(fmpz_mat_t mat, nmod_mat_t * const residues, slong nres, const fmpz_comb_t comb, fmpz_comb_temp_t temp, int sign) noexcept - # Reconstructs ``mat`` from its images modulo the ``nres`` matrices in - # ``residues``, given precomputed ``comb`` and ``comb_temp`` structures. - # Note: ``fmpz.h`` must be included **before** ``fmpz_mat.h`` in order for - # this function to be declared. - void fmpz_mat_multi_CRT_ui(fmpz_mat_t mat, nmod_mat_t * const residues, slong nres, int sign) noexcept - # Reconstructs ``mat`` from its images modulo the ``nres`` matrices - # in ``residues``. - # This function is provided for convenience purposes. - # For reducing or reconstructing multiple integer matrices over the same - # set of moduli, it is faster to use :func:`fmpz_mat_multi_CRT_ui_precomp`. - void fmpz_mat_add(fmpz_mat_t C, const fmpz_mat_t A, const fmpz_mat_t B) noexcept - # Sets ``C`` to the elementwise sum `A + B`. All inputs must - # be of the same size. Aliasing is allowed. - void fmpz_mat_sub(fmpz_mat_t C, const fmpz_mat_t A, const fmpz_mat_t B) noexcept - # Sets ``C`` to the elementwise difference `A - B`. All inputs must - # be of the same size. Aliasing is allowed. - void fmpz_mat_neg(fmpz_mat_t B, const fmpz_mat_t A) noexcept - # Sets ``B`` to the elementwise negation of ``A``. Both inputs - # must be of the same size. Aliasing is allowed. - void fmpz_mat_scalar_mul_si(fmpz_mat_t B, const fmpz_mat_t A, slong c) noexcept void fmpz_mat_scalar_mul_ui(fmpz_mat_t B, const fmpz_mat_t A, ulong c) noexcept void fmpz_mat_scalar_mul_fmpz(fmpz_mat_t B, const fmpz_mat_t A, const fmpz_t c) noexcept - # Set ``B = A*c`` where ``A`` is an ``fmpz_mat_t`` and ``c`` - # is a scalar respectively of type ``slong``, ``ulong``, - # or ``fmpz_t``. The dimensions of ``A`` and ``B`` must - # be compatible. - void fmpz_mat_scalar_addmul_si(fmpz_mat_t B, const fmpz_mat_t A, slong c) noexcept void fmpz_mat_scalar_addmul_ui(fmpz_mat_t B, const fmpz_mat_t A, ulong c) noexcept void fmpz_mat_scalar_addmul_fmpz(fmpz_mat_t B, const fmpz_mat_t A, const fmpz_t c) noexcept - # Set ``B = B + A*c`` where ``A`` is an ``fmpz_mat_t`` and ``c`` - # is a scalar respectively of type ``slong``, ``ulong``, - # or ``fmpz_t``. The dimensions of ``A`` and ``B`` must - # be compatible. - void fmpz_mat_scalar_submul_si(fmpz_mat_t B, const fmpz_mat_t A, slong c) noexcept void fmpz_mat_scalar_submul_ui(fmpz_mat_t B, const fmpz_mat_t A, ulong c) noexcept void fmpz_mat_scalar_submul_fmpz(fmpz_mat_t B, const fmpz_mat_t A, const fmpz_t c) noexcept - # Set ``B = B - A*c`` where ``A`` is an ``fmpz_mat_t`` and ``c`` - # is a scalar respectively of type ``slong``, ``ulong``, - # or ``fmpz_t``. The dimensions of ``A`` and ``B`` must - # be compatible. - void fmpz_mat_scalar_addmul_nmod_mat_ui(fmpz_mat_t B, const nmod_mat_t A, ulong c) noexcept void fmpz_mat_scalar_addmul_nmod_mat_fmpz(fmpz_mat_t B, const nmod_mat_t A, const fmpz_t c) noexcept - # Set ``B = B + A*c`` where ``A`` is an ``nmod_mat_t`` and ``c`` - # is a scalar respectively of type ``ulong`` or ``fmpz_t``. - # The dimensions of ``A`` and ``B`` must be compatible. - void fmpz_mat_scalar_divexact_si(fmpz_mat_t B, const fmpz_mat_t A, slong c) noexcept void fmpz_mat_scalar_divexact_ui(fmpz_mat_t B, const fmpz_mat_t A, ulong c) noexcept void fmpz_mat_scalar_divexact_fmpz(fmpz_mat_t B, const fmpz_mat_t A, const fmpz_t c) noexcept - # Set ``A = B / c``, where ``B`` is an ``fmpz_mat_t`` and ``c`` - # is a scalar respectively of type ``slong``, ``ulong``, - # or ``fmpz_t``, which is assumed to divide all elements of - # ``B`` exactly. - void fmpz_mat_scalar_mul_2exp(fmpz_mat_t B, const fmpz_mat_t A, ulong exp) noexcept - # Set the matrix ``B`` to the matrix ``A``, of the same dimensions, - # multiplied by `2^{exp}`. - void fmpz_mat_scalar_tdiv_q_2exp(fmpz_mat_t B, const fmpz_mat_t A, ulong exp) noexcept - # Set the matrix ``B`` to the matrix ``A``, of the same dimensions, - # divided by `2^{exp}`, rounding down towards zero. - void fmpz_mat_scalar_smod(fmpz_mat_t B, const fmpz_mat_t A, const fmpz_t P) noexcept - # Set the matrix ``B`` to the matrix ``A``, of the same dimensions, - # with each entry reduced modulo `P` in the symmetric moduli system. We - # require `P > 0`. - void fmpz_mat_mul(fmpz_mat_t C, const fmpz_mat_t A, const fmpz_mat_t B) noexcept - # Sets ``C`` to the matrix product `C = A B`. The matrices must have - # compatible dimensions for matrix multiplication. Aliasing - # is allowed. - # This function automatically switches between classical and - # multimodular multiplication, based on a heuristic comparison of - # the dimensions and entry sizes. - void fmpz_mat_mul_classical(fmpz_mat_t C, const fmpz_mat_t A, const fmpz_mat_t B) noexcept - # Sets ``C`` to the matrix product `C = A B` computed using - # classical matrix algorithm. - # The matrices must have compatible dimensions for matrix multiplication. - # No aliasing is allowed. - void fmpz_mat_mul_strassen(fmpz_mat_t C, const fmpz_mat_t A, const fmpz_mat_t B) noexcept - # Sets `C = AB`. Dimensions must be compatible for matrix multiplication. - # `C` is not allowed to be aliased with `A` or `B`. Uses Strassen - # multiplication (the Strassen-Winograd variant). - void _fmpz_mat_mul_multi_mod(fmpz_mat_t C, const fmpz_mat_t A, const fmpz_mat_t B, int sign, flint_bitcnt_t bits) noexcept void fmpz_mat_mul_multi_mod(fmpz_mat_t C, const fmpz_mat_t A, const fmpz_mat_t B) noexcept - # Sets ``C`` to the matrix product `C = AB` computed using a multimodular - # algorithm. `C` is computed modulo several small prime numbers - # and reconstructed using the Chinese Remainder Theorem. This generally - # becomes more efficient than classical multiplication for large matrices. - # The absolute value of the elements of `C` should be `< 2^{\text{bits}}`, - # and ``sign`` should be `0` if the entries of `C` are known to be nonnegative - # and `1` otherwise. The function - # :func:`fmpz_mat_mul_multi_mod` calculates a rigorous bound automatically. - # If the default bound is too pessimistic, :func:`_fmpz_mat_mul_multi_mod` - # can be used with a custom bound. - # The matrices must have compatible dimensions for matrix multiplication. - # No aliasing is allowed. - int fmpz_mat_mul_blas(fmpz_mat_t C, const fmpz_mat_t A, const fmpz_mat_t B) noexcept - # Tries to set `C = AB` using BLAS and returns `1` for success and `0` for failure. - # Dimensions must be compatible for matrix multiplication. No aliasing is allowed. - # This function currently will fail if the matrices are empty, their dimensions are too large, or their max bits size is over one million bits. - void fmpz_mat_mul_fft(fmpz_mat_t C, const fmpz_mat_t A, const fmpz_mat_t B) noexcept - # Aliasing is allowed. - void fmpz_mat_sqr(fmpz_mat_t B, const fmpz_mat_t A) noexcept - # Sets ``B`` to the square of the matrix ``A``, which must be - # a square matrix. Aliasing is allowed. - # The function calls :func:`fmpz_mat_mul` for dimensions less than 12 and - # calls :func:`fmpz_mat_sqr_bodrato` for cases in which the latter is faster. - void fmpz_mat_sqr_bodrato(fmpz_mat_t B, const fmpz_mat_t A) noexcept - # Sets ``B`` to the square of the matrix ``A``, which must be - # a square matrix. Aliasing is allowed. - # The Bodrato algorithm is described in [Bodrato2010]_. - # It is highly efficient for squaring matrices which satisfy both the - # following conditions: (a) large elements, (b) dimensions less than 150. - void fmpz_mat_pow(fmpz_mat_t B, const fmpz_mat_t A, ulong e) noexcept - # Sets ``B`` to the matrix ``A`` raised to the power ``e``, - # where ``A`` must be a square matrix. Aliasing is allowed. - void _fmpz_mat_mul_small(fmpz_mat_t C, const fmpz_mat_t A, const fmpz_mat_t B) noexcept - # This internal function sets `C` to the matrix product `C = A B` computed - # using classical matrix algorithm assuming that all entries of `A` and `B` - # are small, that is, have bits `\le FLINT\_BITS - 2`. No aliasing is allowed. - void _fmpz_mat_mul_double_word(fmpz_mat_t C, const fmpz_mat_t A, const fmpz_mat_t B) noexcept - # This function is only for internal use and assumes that either: - # - the entries of `A` and `B` are all nonnegative and strictly less than `2^{2*FLINT\_BITS}`, or - # - the entries of `A` and `B` are all strictly less than `2^{2*FLINT\_BITS - 1}` in absolute value. - void fmpz_mat_mul_fmpz_vec(fmpz * c, const fmpz_mat_t A, const fmpz * b, slong blen) noexcept void fmpz_mat_mul_fmpz_vec_ptr(fmpz * const * c, const fmpz_mat_t A, const fmpz * const * b, slong blen) noexcept - # Compute a matrix-vector product of ``A`` and ``(b, blen)`` and store the result in ``c``. - # The vector ``(b, blen)`` is either truncated or zero-extended to the number of columns of ``A``. - # The number of entries written to ``c`` is always equal to the number of rows of ``A``. - void fmpz_mat_fmpz_vec_mul(fmpz * c, const fmpz * a, slong alen, const fmpz_mat_t B) noexcept void fmpz_mat_fmpz_vec_mul_ptr(fmpz * const * c, const fmpz * const * a, slong alen, const fmpz_mat_t B) noexcept - # Compute a vector-matrix product of ``(a, alen)`` and ``B`` and store the result in ``c``. - # The vector ``(a, alen)`` is either truncated or zero-extended to the number of rows of ``B``. - # The number of entries written to ``c`` is always equal to the number of columns of ``B``. - int fmpz_mat_inv(fmpz_mat_t Ainv, fmpz_t den, const fmpz_mat_t A) noexcept - # Sets (``Ainv``, ``den``) to the inverse matrix of ``A``. - # Returns 1 if ``A`` is nonsingular and 0 if ``A`` is singular. - # Aliasing of ``Ainv`` and ``A`` is allowed. - # The denominator is not guaranteed to be minimal, but is guaranteed - # to be a divisor of the determinant of ``A``. - # This function uses a direct formula for matrices of size two or less, - # and otherwise solves for the identity matrix using - # fraction-free LU decomposition. - void fmpz_mat_kronecker_product(fmpz_mat_t C, const fmpz_mat_t A, const fmpz_mat_t B) noexcept - # Sets ``C`` to the Kronecker product of ``A`` and ``B``. - void fmpz_mat_content(fmpz_t mat_gcd, const fmpz_mat_t A) noexcept - # Sets ``mat_gcd`` as the gcd of all the elements of the matrix ``A``. - # Returns 0 if the matrix is empty. - void fmpz_mat_trace(fmpz_t trace, const fmpz_mat_t mat) noexcept - # Computes the trace of the matrix, i.e. the sum of the entries on - # the main diagonal. The matrix is required to be square. - void fmpz_mat_det(fmpz_t det, const fmpz_mat_t A) noexcept - # Sets ``det`` to the determinant of the square matrix `A`. - # The matrix of dimension `0 \times 0` is defined to have determinant 1. - # This function automatically chooses between :func:`fmpz_mat_det_cofactor`, - # :func:`fmpz_mat_det_bareiss`, :func:`fmpz_mat_det_modular` and - # :func:`fmpz_mat_det_modular_accelerated` - # (with ``proved`` = 1), depending on the size of the matrix - # and its entries. - void fmpz_mat_det_cofactor(fmpz_t det, const fmpz_mat_t A) noexcept - # Sets ``det`` to the determinant of the square matrix `A` - # computed using direct cofactor expansion. This function only - # supports matrices up to size `4 \times 4`. - void fmpz_mat_det_bareiss(fmpz_t det, const fmpz_mat_t A) noexcept - # Sets ``det`` to the determinant of the square matrix `A` - # computed using the Bareiss algorithm. A copy of the input matrix is - # row reduced using fraction-free Gaussian elimination, and the - # determinant is read off from the last element on the main - # diagonal. - void fmpz_mat_det_modular(fmpz_t det, const fmpz_mat_t A, int proved) noexcept - # Sets ``det`` to the determinant of the square matrix `A` - # (if ``proved`` = 1), or a probabilistic value for the - # determinant (``proved`` = 0), computed using a multimodular - # algorithm. - # The determinant is computed modulo several small primes and - # reconstructed using the Chinese Remainder Theorem. - # With ``proved`` = 1, sufficiently many primes are chosen - # to satisfy the bound computed by ``fmpz_mat_det_bound``. - # With ``proved`` = 0, the determinant is considered determined - # if it remains unchanged modulo several consecutive primes - # (currently if their product exceeds `2^{100}`). - void fmpz_mat_det_modular_accelerated(fmpz_t det, const fmpz_mat_t A, int proved) noexcept - # Sets ``det`` to the determinant of the square matrix `A` - # (if ``proved`` = 1), or a probabilistic value for the - # determinant (``proved`` = 0), computed using a multimodular - # algorithm. - # This function uses the same basic algorithm as ``fmpz_mat_det_modular``, - # but instead of computing `\det(A)` directly, it generates a divisor `d` - # of `\det(A)` and then computes `x = \det(A) / d` modulo several - # small primes not dividing `d`. This typically accelerates the - # computation by requiring fewer primes for large matrices, since `d` - # with high probability will be nearly as large as the determinant. - # This trick is described in [AbbottBronsteinMulders1999]_. - void fmpz_mat_det_modular_given_divisor(fmpz_t det, const fmpz_mat_t A, const fmpz_t d, int proved) noexcept - # Given a positive divisor `d` of `\det(A)`, sets ``det`` to the - # determinant of the square matrix `A` (if ``proved`` = 1), or a - # probabilistic value for the determinant (``proved`` = 0), computed - # using a multimodular algorithm. - void fmpz_mat_det_bound(fmpz_t bound, const fmpz_mat_t A) noexcept - # Sets ``bound`` to a nonnegative integer `B` such that - # `|\det(A)| \le B`. Assumes `A` to be a square matrix. - # The bound is computed from the Hadamard inequality - # `|\det(A)| \le \prod \|a_i\|_2` where the product is taken - # over the rows `a_i` of `A`. - void fmpz_mat_det_bound_nonzero(fmpz_t bound, const fmpz_mat_t A) noexcept - # As per ``fmpz_mat_det_bound()`` but excludes zero columns. For use with - # non-square matrices. - void fmpz_mat_det_divisor(fmpz_t d, const fmpz_mat_t A) noexcept - # Sets `d` to some positive divisor of the determinant of the given - # square matrix `A`, if the determinant is nonzero. If `|\det(A)| = 0`, - # `d` will always be set to zero. - # A divisor is obtained by solving `Ax = b` for an arbitrarily chosen - # right-hand side `b` using Dixon's algorithm and computing the least - # common multiple of the denominators in `x`. This yields a divisor `d` - # such that `|\det(A)| / d` is tiny with very high probability. - void fmpz_mat_similarity(fmpz_mat_t A, slong r, fmpz_t d) noexcept - # Applies a similarity transform to the `n\times n` matrix `M` in-place. - # If `P` is the `n\times n` identity matrix the zero entries of whose row - # `r` (`0`-indexed) have been replaced by `d`, this transform is equivalent - # to `M = P^{-1}MP`. - # Similarity transforms preserve the determinant, characteristic polynomial - # and minimal polynomial. - void _fmpz_mat_charpoly_berkowitz(fmpz * cp, const fmpz_mat_t mat) noexcept - # Sets ``(cp, n+1)`` to the characteristic polynomial of - # an `n \times n` square matrix. - void fmpz_mat_charpoly_berkowitz(fmpz_poly_t cp, const fmpz_mat_t mat) noexcept - # Computes the characteristic polynomial of length `n + 1` of - # an `n \times n` square matrix. Uses an `O(n^4)` algorithm based on the - # method of Berkowitz. - void _fmpz_mat_charpoly_modular(fmpz * cp, const fmpz_mat_t mat) noexcept - # Sets ``(cp, n+1)`` to the characteristic polynomial of - # an `n \times n` square matrix. - void fmpz_mat_charpoly_modular(fmpz_poly_t cp, const fmpz_mat_t mat) noexcept - # Computes the characteristic polynomial of length `n + 1` of - # an `n \times n` square matrix. Uses a modular method based on an `O(n^3)` - # method over `\mathbb{Z}/n\mathbb{Z}`. - void _fmpz_mat_charpoly(fmpz * cp, const fmpz_mat_t mat) noexcept - # Sets ``(cp, n+1)`` to the characteristic polynomial of - # an `n \times n` square matrix. - void fmpz_mat_charpoly(fmpz_poly_t cp, const fmpz_mat_t mat) noexcept - # Computes the characteristic polynomial of length `n + 1` of - # an `n \times n` square matrix. - slong _fmpz_mat_minpoly_modular(fmpz * cp, const fmpz_mat_t mat) noexcept - # Sets ``(cp, n+1)`` to the modular polynomial of - # an `n \times n` square matrix and returns its length. - void fmpz_mat_minpoly_modular(fmpz_poly_t cp, const fmpz_mat_t mat) noexcept - # Computes the minimal polynomial of an `n \times n` square matrix. - # Uses a modular method based on an average time `O(n^3)`, worst case - # `O(n^4)` method over `\mathbb{Z}/n\mathbb{Z}`. - slong _fmpz_mat_minpoly(fmpz * cp, const fmpz_mat_t mat) noexcept - # Sets ``cp`` to the minimal polynomial of an `n \times n` square - # matrix and returns its length. - void fmpz_mat_minpoly(fmpz_poly_t cp, const fmpz_mat_t mat) noexcept - # Computes the minimal polynomial of an `n \times n` square matrix. - slong fmpz_mat_rank(const fmpz_mat_t A) noexcept - # Returns the rank, that is, the number of linearly independent columns - # (equivalently, rows), of `A`. The rank is computed by row reducing - # a copy of `A`. - int fmpz_mat_col_partition(slong * part, fmpz_mat_t M, int short_circuit) noexcept - # Returns the number `p` of distinct columns of `M` (or `0` if the flag - # ``short_circuit`` is set and this number is greater than the number - # of rows of `M`). The entries of array ``part`` are set to values in - # `[0, p)` such that two entries of part are equal iff the corresponding - # columns of `M` are equal. This function is used in van Hoeij polynomial - # factoring. - int fmpz_mat_solve(fmpz_mat_t X, fmpz_t den, const fmpz_mat_t A, const fmpz_mat_t B) noexcept - # Solves the equation `AX = B` for nonsingular `A`. More precisely, computes - # (``X``, ``den``) such that `AX = B \times \operatorname{den}`. - # Returns 1 if `A` is nonsingular and 0 if `A` is singular. - # The computed denominator will not generally be minimal. - # This function uses Cramer's rule for small systems and - # fraction-free LU decomposition followed by fraction-free forward - # and back substitution for larger systems. - # Note that for very large systems, it is faster to compute a modular - # solution using ``fmpz_mat_solve_dixon``. - int fmpz_mat_solve_fflu(fmpz_mat_t X, fmpz_t den, const fmpz_mat_t A, const fmpz_mat_t B) noexcept - # Solves the equation `AX = B` for nonsingular `A`. More precisely, computes - # (``X``, ``den``) such that `AX = B \times \operatorname{den}`. - # Returns 1 if `A` is nonsingular and 0 if `A` is singular. - # The computed denominator will not generally be minimal. - # Uses fraction-free LU decomposition followed by fraction-free - # forward and back substitution. - int fmpz_mat_solve_fflu_precomp(fmpz_mat_t X, const slong * perm, const fmpz_mat_t FFLU, const fmpz_mat_t B) noexcept - # Performs fraction-free forward and back substitution given a precomputed - # fraction-free LU decomposition and corresponding permutation. If no - # impossible division is encountered, the function returns `1`. This does not - # mean the system has a solution, however a return value of `0` can only - # occur if the system is insoluble. - # If the return value is `1` and `r` is the rank of the matrix `A` whose FFLU - # we have, then the first `r` rows of `p(A)y = p(b)d` hold, where `d` is the - # denominator of the FFLU. The remaining rows must be checked by the caller. - int fmpz_mat_solve_cramer(fmpz_mat_t X, fmpz_t den, const fmpz_mat_t A, const fmpz_mat_t B) noexcept - # Solves the equation `AX = B` for nonsingular `A`. More precisely, computes - # (``X``, ``den``) such that `AX = B \times \operatorname{den}`. - # Returns 1 if `A` is nonsingular and 0 if `A` is singular. - # Uses Cramer's rule. Only systems of size up to `3 \times 3` are allowed. - void fmpz_mat_solve_bound(fmpz_t N, fmpz_t D, const fmpz_mat_t A, const fmpz_mat_t B) noexcept - # Assuming that `A` is nonsingular, computes integers `N` and `D` - # such that the reduced numerators and denominators `n/d` in - # `A^{-1} B` satisfy the bounds `0 \le |n| \le N` and `0 \le d \le D`. - int fmpz_mat_solve_dixon(fmpz_mat_t X, fmpz_t M, const fmpz_mat_t A, const fmpz_mat_t B) noexcept - # Solves `AX = B` given a nonsingular square matrix `A` and a matrix `B` of - # compatible dimensions, using a modular algorithm. In particular, - # Dixon's p-adic lifting algorithm is used (currently a non-adaptive version). - # This is generally the preferred method for large dimensions. - # More precisely, this function computes an integer `M` and an integer - # matrix `X` such that `AX = B \bmod M` and such that all the reduced - # numerators and denominators of the elements `x = p/q` in the full - # solution satisfy `2|p|q < M`. As such, the explicit rational solution - # matrix can be recovered uniquely by passing the output of this - # function to ``fmpq_mat_set_fmpz_mat_mod``. - # A nonzero value is returned if `A` is nonsingular. If `A` is singular, - # zero is returned and the values of the output variables will be - # undefined. - # Aliasing between input and output matrices is allowed. - void _fmpz_mat_solve_dixon_den(fmpz_mat_t X, fmpz_t den, const fmpz_mat_t A, const fmpz_mat_t B, const nmod_mat_t Ainv, mp_limb_t p, const fmpz_t N, const fmpz_t D) noexcept - # Solves the equation `AX = B` for nonsingular `A`. More precisely, computes - # (``X``, ``den``) such that `AX = B \times \operatorname{den}` using a - # ``p``-adic algorithm for the supplied prime ``p``. The values ``N`` and - # ``D`` are absolute value bounds for the numerator and denominator of the - # solution. - # Uses the Dixon lifting algorithm with early termination once the lifting - # stabilises. - int fmpz_mat_solve_dixon_den(fmpz_mat_t X, fmpz_t den, const fmpz_mat_t A, const fmpz_mat_t B) noexcept - # Solves the equation `AX = B` for nonsingular `A`. More precisely, computes - # (``X``, ``den``) such that `AX = B \times \operatorname{den}`. - # Returns 1 if `A` is nonsingular and 0 if `A` is singular. - # The computed denominator will not generally be minimal. - # Uses the Dixon lifting algorithm with early termination once the lifting - # stabilises. - int fmpz_mat_solve_multi_mod_den(fmpz_mat_t X, fmpz_t den, const fmpz_mat_t A, const fmpz_mat_t B) noexcept - # Solves the equation `AX = B` for nonsingular `A`. More precisely, computes - # (``X``, ``den``) such that `AX = B \times \operatorname{den}`. - # Returns 1 if `A` is nonsingular and 0 if `A` is singular. - # The computed denominator will not generally be minimal. - # Uses a Chinese remainder algorithm with early termination once the lifting - # stabilises. - int fmpz_mat_can_solve_multi_mod_den(fmpz_mat_t X, fmpz_t den, const fmpz_mat_t A, const fmpz_mat_t B) noexcept - # Returns `1` if the system `AX = B` can be solved. If so it computes - # (``X``, ``den``) such that `AX = B \times \operatorname{den}`. The - # computed denominator will not generally be minimal. - # Uses a Chinese remainder algorithm. - # Note that the matrices `A` and `B` may have any shape as long as they have - # the same number of rows. - int fmpz_mat_can_solve_fflu(fmpz_mat_t X, fmpz_t den, const fmpz_mat_t A, const fmpz_mat_t B) noexcept - # Returns `1` if the system `AX = B` can be solved. If so it computes - # (``X``, ``den``) such that `AX = B \times \operatorname{den}`. The - # computed denominator will not generally be minimal. - # Uses a fraction free LU decomposition algorithm. - # Note that the matrices `A` and `B` may have any shape as long as they have - # the same number of rows. - int fmpz_mat_can_solve(fmpz_mat_t X, fmpz_t den, const fmpz_mat_t A, const fmpz_mat_t B) noexcept - # Returns `1` if the system `AX = B` can be solved. If so it computes - # (``X``, ``den``) such that `AX = B \times \operatorname{den}`. The - # computed denominator will not generally be minimal. - # Note that the matrices `A` and `B` may have any shape as long as they have - # the same number of rows. - slong fmpz_mat_find_pivot_any(const fmpz_mat_t mat, slong start_row, slong end_row, slong c) noexcept - # Attempts to find a pivot entry for row reduction. - # Returns a row index `r` between ``start_row`` (inclusive) and - # ``stop_row`` (exclusive) such that column `c` in ``mat`` has - # a nonzero entry on row `r`, or returns -1 if no such entry exists. - # This implementation simply chooses the first nonzero entry - # it encounters. This is likely to be a nearly optimal choice if all - # entries in the matrix have roughly the same size, but can lead to - # unnecessary coefficient growth if the entries vary in size. - slong fmpz_mat_fflu(fmpz_mat_t B, fmpz_t den, slong * perm, const fmpz_mat_t A, int rank_check) noexcept - # Uses fraction-free Gaussian elimination to set (``B``, ``den``) to a - # fraction-free LU decomposition of ``A`` and returns the - # rank of ``A``. Aliasing of ``A`` and ``B`` is allowed. - # Pivot elements are chosen with ``fmpz_mat_find_pivot_any``. - # If ``perm`` is non-``NULL``, the permutation of - # rows in the matrix will also be applied to ``perm``. - # If ``rank_check`` is set, the function aborts and returns 0 if the - # matrix is detected not to have full rank without completing the - # elimination. - # The denominator ``den`` is set to `\pm \operatorname{det}(S)` where - # `S` is an appropriate submatrix of `A` (`S = A` if `A` is square) - # and the sign is decided by the parity of the permutation. Note that the - # determinant is not generally the minimal denominator. - # The fraction-free LU decomposition is defined in [NakTurWil1997]_. - slong fmpz_mat_rref(fmpz_mat_t B, fmpz_t den, const fmpz_mat_t A) noexcept - # Sets (``B``, ``den``) to the reduced row echelon form of ``A`` - # and returns the rank of ``A``. Aliasing of ``A`` and ``B`` - # is allowed. - # The algorithm used chooses between ``fmpz_mat_rref_fflu`` and - # ``fmpz_mat_rref_mul`` based on the dimensions of the input matrix. - slong fmpz_mat_rref_fflu(fmpz_mat_t B, fmpz_t den, const fmpz_mat_t A) noexcept - # Sets (``B``, ``den``) to the reduced row echelon form of ``A`` - # and returns the rank of ``A``. Aliasing of ``A`` and ``B`` - # is allowed. - # The algorithm proceeds by first computing a row echelon form using - # ``fmpz_mat_fflu``. Letting the upper part of this matrix be - # `(U | V) P` where `U` is full rank upper triangular and `P` is a - # permutation matrix, we obtain the rref by setting `V` to `U^{-1} V` - # using back substitution. Scaling each completed row in the back - # substitution to the denominator ``den``, we avoid introducing - # new fractions. This strategy is equivalent to the fraction-free - # Gauss-Jordan elimination in [NakTurWil1997]_, but faster since - # only the part `V` corresponding to the null space has to be updated. - # The denominator ``den`` is set to `\pm \operatorname{det}(S)` where - # `S` is an appropriate submatrix of `A` (`S = A` if `A` is square). - # Note that the determinant is not generally the minimal denominator. - slong fmpz_mat_rref_mul(fmpz_mat_t B, fmpz_t den, const fmpz_mat_t A) noexcept - # Sets (``B``, ``den``) to the reduced row echelon form of ``A`` - # and returns the rank of ``A``. Aliasing of ``A`` and ``B`` - # is allowed. - # The algorithm works by computing the reduced row echelon form of ``A`` - # modulo a prime `p` using ``nmod_mat_rref``. The pivot columns and rows - # of this matrix will then define a non-singular submatrix of ``A``, - # nonsingular solving and matrix multiplication can then be used to determine - # the reduced row echelon form of the whole of ``A``. This procedure is - # described in [Stein2007]_. - bint fmpz_mat_is_in_rref_with_rank(const fmpz_mat_t A, const fmpz_t den, slong rank) noexcept - # Checks that the matrix `A/den` is in reduced row echelon form of rank - # ``rank``, returns 1 if so and 0 otherwise. - slong fmpz_mat_rref_mod(slong * perm, fmpz_mat_t A, const fmpz_t p) noexcept - # Uses fraction-free Gauss-Jordan elimination to set ``A`` - # to its reduced row echelon form and returns the rank of ``A``. - # All computations are done modulo p. - # Pivot elements are chosen with ``fmpz_mat_find_pivot_any``. - # If ``perm`` is non-``NULL``, the permutation of - # rows in the matrix will also be applied to ``perm``. - void fmpz_mat_strong_echelon_form_mod(fmpz_mat_t A, const fmpz_t mod) noexcept - # Transforms `A` such that `A` modulo ``mod`` is the strong echelon form - # of the input matrix modulo ``mod``. The Howell form and the strong - # echelon form are equal up to permutation of the rows, see [FieHof2014]_ - # for a definition of the strong echelon form and the algorithm used here. - # `A` must have at least as many rows as columns. - slong fmpz_mat_howell_form_mod(fmpz_mat_t A, const fmpz_t mod) noexcept - # Transforms `A` such that `A` modulo ``mod`` is the Howell form of the - # input matrix modulo ``mod``. - # For a definition of the Howell form see [StoMul1998]_. The Howell form - # is computed by first putting `A` into strong echelon form and then ordering - # the rows. - # `A` must have at least as many rows as columns. - slong fmpz_mat_nullspace(fmpz_mat_t B, const fmpz_mat_t A) noexcept - # Computes a basis for the right rational nullspace of `A` and returns - # the dimension of the nullspace (or nullity). `B` is set to a matrix with - # linearly independent columns and maximal rank such that `AB = 0` - # (i.e. `Ab = 0` for each column `b` in `B`), and the rank of `B` is - # returned. - # In general, the entries in `B` will not be minimal: in particular, - # the pivot entries in `B` will generally differ from unity. - # `B` must be allocated with sufficient space to represent the result - # (at most `n \times n` where `n` is the number of columns of `A`). - slong fmpz_mat_rref_fraction_free(slong * perm, fmpz_mat_t B, fmpz_t den, const fmpz_mat_t A) noexcept - # Computes an integer matrix ``B`` and an integer ``den`` such that - # ``B / den`` is the unique row reduced echelon form (RREF) of ``A`` - # and returns the rank, i.e. the number of nonzero rows in ``B``. - # Aliasing of ``B`` and ``A`` is allowed, with an in-place - # computation being more efficient. The size of ``B`` must be - # the same as that of ``A``. - # The permutation order will be written to ``perm`` unless this - # argument is ``NULL``. That is, row ``i`` of the output matrix will - # correspond to row ``perm[i]`` of the input matrix. - # The denominator will always be a divisor of the determinant of (some - # submatrix of) `A`, but is not guaranteed to be minimal or canonical in - # any other sense. - void fmpz_mat_hnf(fmpz_mat_t H, const fmpz_mat_t A) noexcept - # Computes an integer matrix ``H`` such that ``H`` is the unique (row) - # Hermite normal form of ``A``. The algorithm used is selected from the - # implementations in FLINT to be the one most likely to be optimal, based on - # the characteristics of the input matrix. - # Aliasing of ``H`` and ``A`` is allowed. The size of ``H`` must be - # the same as that of ``A``. - void fmpz_mat_hnf_transform(fmpz_mat_t H, fmpz_mat_t U, const fmpz_mat_t A) noexcept - # Computes an integer matrix ``H`` such that ``H`` is the unique (row) - # Hermite normal form of ``A`` along with the transformation matrix - # ``U`` such that `UA = H`. The algorithm used is selected from the - # implementations in FLINT as per ``fmpz_mat_hnf``. - # Aliasing of ``H`` and ``A`` is allowed. The size of ``H`` must be - # the same as that of ``A`` and ``U`` must be square of \compatible - # dimension (having the same number of rows as ``A``). - void fmpz_mat_hnf_classical(fmpz_mat_t H, const fmpz_mat_t A) noexcept - # Computes an integer matrix ``H`` such that ``H`` is the unique (row) - # Hermite normal form of ``A``. The algorithm used is straightforward and - # is described, for example, in [Algorithm 2.4.4] [Coh1996]_. - # Aliasing of ``H`` and ``A`` is allowed. The size of ``H`` must be - # the same as that of ``A``. - void fmpz_mat_hnf_xgcd(fmpz_mat_t H, const fmpz_mat_t A) noexcept - # Computes an integer matrix ``H`` such that ``H`` is the unique (row) - # Hermite normal form of ``A``. The algorithm used is an improvement on the - # basic algorithm and uses extended gcds to speed up computation, this method - # is described, for example, in [Algorithm 2.4.5] [Coh1996]_. - # Aliasing of ``H`` and ``A`` is allowed. The size of ``H`` must be - # the same as that of ``A``. - void fmpz_mat_hnf_modular(fmpz_mat_t H, const fmpz_mat_t A, const fmpz_t D) noexcept - # Computes an integer matrix ``H`` such that ``H`` is the unique (row) - # Hermite normal form of the `m\times n` matrix ``A``, where ``A`` is - # assumed to be of rank `n` and ``D`` is known to be a positive multiple of - # the determinant of the non-zero rows of ``H``. The algorithm used here is - # due to Domich, Kannan and Trotter [DomKanTro1987]_ and is also described - # in [Algorithm 2.4.8] [Coh1996]_. - # Aliasing of ``H`` and ``A`` is allowed. The size of ``H`` must be - # the same as that of ``A``. - void fmpz_mat_hnf_modular_eldiv(fmpz_mat_t A, const fmpz_t D) noexcept - # Transforms the `m\times n` matrix ``A`` into Hermite normal form, - # where ``A`` is assumed to be of rank `n` and ``D`` is known to be a - # positive multiple of the largest elementary divisor of ``A``. - # The algorithm used here is described in [FieHof2014]_. - void fmpz_mat_hnf_minors(fmpz_mat_t H, const fmpz_mat_t A) noexcept - # Computes an integer matrix ``H`` such that ``H`` is the unique (row) - # Hermite normal form of the `m\times n` matrix ``A``, where ``A`` is - # assumed to be of rank `n`. The algorithm used here is due to Kannan and - # Bachem [KanBac1979]_ and takes the principal minors to Hermite normal - # form in turn. - # Aliasing of ``H`` and ``A`` is allowed. The size of ``H`` must be - # the same as that of ``A``. - void fmpz_mat_hnf_pernet_stein(fmpz_mat_t H, const fmpz_mat_t A, flint_rand_t state) noexcept - # Computes an integer matrix ``H`` such that ``H`` is the unique (row) - # Hermite normal form of the `m\times n` matrix ``A``. The algorithm used - # here is due to Pernet and Stein [PernetStein2010]_. - # Aliasing of ``H`` and ``A`` is allowed. The size of ``H`` must be - # the same as that of ``A``. - bint fmpz_mat_is_in_hnf(const fmpz_mat_t A) noexcept - # Checks that the given matrix is in Hermite normal form, returns 1 if so and - # 0 otherwise. - void fmpz_mat_snf(fmpz_mat_t S, const fmpz_mat_t A) noexcept - # Computes an integer matrix ``S`` such that ``S`` is the unique Smith - # normal form of ``A``. The algorithm used is selected from the - # implementations in FLINT to be the one most likely to be optimal, based on - # the characteristics of the input matrix. - # Aliasing of ``S`` and ``A`` is allowed. The size of ``S`` must be - # the same as that of ``A``. - void fmpz_mat_snf_diagonal(fmpz_mat_t S, const fmpz_mat_t A) noexcept - # Computes an integer matrix ``S`` such that ``S`` is the unique Smith - # normal form of the diagonal matrix ``A``. The algorithm used simply takes - # gcds of pairs on the diagonal in turn until the Smith form is obtained. - # Aliasing of ``S`` and ``A`` is allowed. The size of ``S`` must be - # the same as that of ``A``. - void fmpz_mat_snf_kannan_bachem(fmpz_mat_t S, const fmpz_mat_t A) noexcept - # Computes an integer matrix ``S`` such that ``S`` is the unique Smith - # normal form of the diagonal matrix ``A``. The algorithm used here is due - # to Kannan and Bachem [KanBac1979]_ - # Aliasing of ``S`` and ``A`` is allowed. The size of ``S`` must be - # the same as that of ``A``. - void fmpz_mat_snf_iliopoulos(fmpz_mat_t S, const fmpz_mat_t A, const fmpz_t mod) noexcept - # Computes an integer matrix ``S`` such that ``S`` is the unique Smith - # normal form of the nonsingular `n\times n` matrix ``A``. The algorithm - # used is due to Iliopoulos [Iliopoulos1989]_. - # Aliasing of ``S`` and ``A`` is allowed. The size of ``S`` must be - # the same as that of ``A``. - bint fmpz_mat_is_in_snf(const fmpz_mat_t A) noexcept - # Checks that the given matrix is in Smith normal form, returns 1 if so and 0 - # otherwise. - void fmpz_mat_gram(fmpz_mat_t B, const fmpz_mat_t A) noexcept - # Sets ``B`` to the Gram matrix of the `m`-dimensional lattice ``L`` in - # `n`-dimensional Euclidean space `R^n` spanned by the rows of - # the `m \times n` matrix ``A``. Dimensions must be compatible. - # ``A`` and ``B`` are allowed to be the same object if ``A`` is a - # square matrix. - bint fmpz_mat_is_hadamard(const fmpz_mat_t H) noexcept - # Returns nonzero iff `H` is a Hadamard matrix, meaning - # that it is a square matrix, only has entries that are `\pm 1`, - # and satisfies `H^T = n H^{-1}` where `n` is the matrix size. - int fmpz_mat_hadamard(fmpz_mat_t H) noexcept - # Attempts to set the matrix `H` to a Hadamard matrix, returning 1 if - # successful and 0 if unsuccessful. - # A Hadamard matrix of size `n` can only exist if `n` is 1, 2, - # or a multiple of 4. It is not known whether a - # Hadamard matrix exists for every size that is a multiple of 4. - # This function uses the Paley construction, which - # succeeds for all `n` of the form `n = 2^e` or `n = 2^e (q + 1)` where - # `q` is an odd prime power. Orders `n` for which Hadamard matrices are - # known to exist but for which this construction fails are - # 92, 116, 156, ... (OEIS A046116). - int fmpz_mat_get_d_mat(d_mat_t B, const fmpz_mat_t A) noexcept - # Sets the entries of ``B`` as doubles corresponding to the entries of - # ``A``, rounding down towards zero if the latter cannot be represented - # exactly. The return value is -1 if any entry of ``A`` is too large to - # fit in the normal range of a double, and 0 otherwise. - int fmpz_mat_get_d_mat_transpose(d_mat_t B, const fmpz_mat_t A) noexcept - # Sets the entries of ``B`` as doubles corresponding to the entries of - # the transpose of ``A``, rounding down towards zero if the latter cannot - # be represented exactly. The return value is -1 if any entry of ``A`` is - # too large to fit in the normal range of a double, and 0 otherwise. - + void fmpz_mat_is_spd(const fmpz_mat_t A) noexcept void fmpz_mat_chol_d(d_mat_t R, const fmpz_mat_t A) noexcept - # Computes ``R``, the Cholesky factor of a symmetric, positive definite - # matrix ``A`` using the Cholesky decomposition process. (Sets ``R`` - # such that `A = RR^{T}` where ``R`` is a lower triangular matrix.) - bint fmpz_mat_is_reduced(const fmpz_mat_t A, double delta, double eta) noexcept bint fmpz_mat_is_reduced_gram(const fmpz_mat_t A, double delta, double eta) noexcept - # Returns a non-zero value if the basis ``A`` is LLL-reduced with factor - # (``delta``, ``eta``), and otherwise returns zero. - # The second version assumes ``A`` is the Gram matrix of the basis. - bint fmpz_mat_is_reduced_with_removal(const fmpz_mat_t A, double delta, double eta, const fmpz_t gs_B, int newd) noexcept bint fmpz_mat_is_reduced_gram_with_removal(const fmpz_mat_t A, double delta, double eta, const fmpz_t gs_B, int newd) noexcept - # Returns a non-zero value if the basis ``A`` is LLL-reduced with factor - # (``delta``, ``eta``) for each of the first ``newd`` vectors and the squared - # Gram-Schmidt length of each of the remaining `i`-th vectors - # (where `i \ge` ``newd``) is greater than ``gs_B``, and otherwise returns zero. - # The second version assumes ``A`` is the Gram matrix of the basis. - void fmpz_mat_lll_original(fmpz_mat_t A, const fmpq_t delta, const fmpq_t eta) noexcept - # Takes a basis `x_1, x_2, \ldots, x_m` of the lattice `L \subset R^n` (as - # the rows of a `m \times n` matrix ``A``). The output is a (``delta``, - # ``eta``)-reduced basis `y_1, y_2, \ldots, y_m` of the lattice `L` (as - # the rows of the same `m \times n` matrix ``A``). - void fmpz_mat_lll_storjohann(fmpz_mat_t A, const fmpq_t delta, const fmpq_t eta) noexcept - # Takes a basis `x_1, x_2, \ldots, x_m` of the lattice `L \subset R^n` (as - # the rows of a `m \times n` matrix ``A``). The output is an (``delta``, - # ``eta``)-reduced basis `y_1, y_2, \ldots, y_m` of the lattice `L` (as - # the rows of the same `m \times n` matrix ``A``). Uses a modified version of - # LLL, which has better complexity in terms of the lattice dimension, - # introduced by Storjohann. - # See "Faster Algorithms for Integer Lattice Basis Reduction." Technical - # Report 249. Zurich, Switzerland: Department Informatik, ETH. July 30, - # 1996. from .fmpz_mat_macros cimport * diff --git a/src/sage/libs/flint/fmpz_mat_macros.pxd b/src/sage/libs/flint/fmpz_mat_macros.pxd index 316117c3b4c..3aa4ef5ada0 100644 --- a/src/sage/libs/flint/fmpz_mat_macros.pxd +++ b/src/sage/libs/flint/fmpz_mat_macros.pxd @@ -1,14 +1,9 @@ # Macros from fmpz_mat.h -# See https://github.com/flintlib/flint/issues/152 +# See https://github.com/flintlib/flint/issues/1529 from .types cimport * cdef extern from "flint_wrap.h": fmpz * fmpz_mat_entry(fmpz_mat_t mat, slong i, slong j) - # Macro giving a pointer to the entry at row *i* and column *j*. - slong fmpz_mat_nrows(fmpz_mat_t) - # Returns the number of rows of the matrix. - slong fmpz_mat_ncols(fmpz_mat_t) - # Returns the number of columns of the matrix. diff --git a/src/sage/libs/flint/fmpz_mod.pxd b/src/sage/libs/flint/fmpz_mod.pxd index ac0eb02e303..4089589dd53 100644 --- a/src/sage/libs/flint/fmpz_mod.pxd +++ b/src/sage/libs/flint/fmpz_mod.pxd @@ -2,7 +2,9 @@ # distutils: depends = flint/fmpz_mod.h ################################################################################ -# This file is auto-generated. Do not modify by hand +# This file is auto-generated by the script +# SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py. +# Do not modify by hand! Fix and rerun the script instead. ################################################################################ from libc.stdio cimport FILE @@ -11,84 +13,32 @@ from sage.libs.mpfr.types cimport * from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void fmpz_mod_ctx_init(fmpz_mod_ctx_t ctx, const fmpz_t n) noexcept - # Initialise ``ctx`` for arithmetic modulo ``n``, which is expected to be positive. - void fmpz_mod_ctx_clear(fmpz_mod_ctx_t ctx) noexcept - # Free any memory used by ``ctx``. - void fmpz_mod_ctx_set_modulus(fmpz_mod_ctx_t ctx, const fmpz_t n) noexcept - # Reconfigure ``ctx`` for arithmetic modulo ``n``. - void fmpz_mod_set_fmpz(fmpz_t a, const fmpz_t b, const fmpz_mod_ctx_t ctx) noexcept - # Set ``a`` to ``b`` after reduction modulo the modulus. - bint fmpz_mod_is_canonical(const fmpz_t a, const fmpz_mod_ctx_t ctx) noexcept - # Return ``1`` if `a` is in the canonical range `[0,n)` and ``0`` otherwise. - bint fmpz_mod_is_one(const fmpz_t a, const fmpz_mod_ctx_t ctx) noexcept - # Return ``1`` if `a` is `1` modulo `n` and return ``0`` otherwise. - void fmpz_mod_add(fmpz_t a, const fmpz_t b, const fmpz_t c, const fmpz_mod_ctx_t ctx) noexcept - # Set `a` to `b+c` modulo `n`. - void fmpz_mod_add_fmpz(fmpz_t a, const fmpz_t b, const fmpz_t c, const fmpz_mod_ctx_t ctx) noexcept void fmpz_mod_add_ui(fmpz_t a, const fmpz_t b, ulong c, const fmpz_mod_ctx_t ctx) noexcept void fmpz_mod_add_si(fmpz_t a, const fmpz_t b, slong c, const fmpz_mod_ctx_t ctx) noexcept - # Set `a` to `b+c` modulo `n` where only `b` is assumed to be canonical. - void fmpz_mod_sub(fmpz_t a, const fmpz_t b, const fmpz_t c, const fmpz_mod_ctx_t ctx) noexcept - # Set `a` to `b-c` modulo `n`. - void fmpz_mod_sub_fmpz(fmpz_t a, const fmpz_t b, const fmpz_t c, const fmpz_mod_ctx_t ctx) noexcept void fmpz_mod_sub_ui(fmpz_t a, const fmpz_t b, ulong c, const fmpz_mod_ctx_t ctx) noexcept void fmpz_mod_sub_si(fmpz_t a, const fmpz_t b, slong c, const fmpz_mod_ctx_t ctx) noexcept - # Set `a` to `b-c` modulo `n` where only `b` is assumed to be canonical. - void fmpz_mod_fmpz_sub(fmpz_t a, const fmpz_t b, const fmpz_t c, const fmpz_mod_ctx_t ctx) noexcept void fmpz_mod_ui_sub(fmpz_t a, ulong b, const fmpz_t c, const fmpz_mod_ctx_t ctx) noexcept void fmpz_mod_si_sub(fmpz_t a, slong b, const fmpz_t c, const fmpz_mod_ctx_t ctx) noexcept - # Set `a` to `b-c` modulo `n` where only `c` is assumed to be canonical. - void fmpz_mod_neg(fmpz_t a, const fmpz_t b, const fmpz_mod_ctx_t ctx) noexcept - # Set `a` to `-b` modulo `n`. - void fmpz_mod_mul(fmpz_t a, const fmpz_t b, const fmpz_t c, const fmpz_mod_ctx_t ctx) noexcept - # Set `a` to `b\cdot c` modulo `n`. - void fmpz_mod_inv(fmpz_t a, const fmpz_t b, const fmpz_mod_ctx_t ctx) noexcept - # Set `a` to `b^{-1}` modulo `n`. - # This function expects that `b` is invertible modulo `n` and throws if this not the case. - # Invertibility may be tested with :func:`fmpz_mod_pow_fmpz` or :func:`fmpz_mod_divides`. - int fmpz_mod_divides(fmpz_t a, const fmpz_t b, const fmpz_t c, const fmpz_mod_ctx_t ctx) noexcept - # If `a\cdot c = b \mod n` has a solution for `a` return `1` and set `a` to such a solution. Otherwise return `0` and leave `a` undefined. - void fmpz_mod_pow_ui(fmpz_t a, const fmpz_t b, ulong e, const fmpz_mod_ctx_t ctx) noexcept - # Set `a` to `b^e` modulo `n`. - int fmpz_mod_pow_fmpz(fmpz_t a, const fmpz_t b, const fmpz_t e, const fmpz_mod_ctx_t ctx) noexcept - # Try to set `a` to `b^e` modulo `n`. - # If `e < 0` and `b` is not invertible modulo `n`, the return is `0`. Otherwise, the return is `1`. - void fmpz_mod_discrete_log_pohlig_hellman_init(fmpz_mod_discrete_log_pohlig_hellman_t L) noexcept - # Initialize ``L``. Upon initialization ``L`` is not ready for computation. - void fmpz_mod_discrete_log_pohlig_hellman_clear(fmpz_mod_discrete_log_pohlig_hellman_t L) noexcept - # Free any space used by ``L``. - double fmpz_mod_discrete_log_pohlig_hellman_precompute_prime(fmpz_mod_discrete_log_pohlig_hellman_t L, const fmpz_t p) noexcept - # Configure ``L`` for discrete logarithms modulo ``p`` to an internally chosen base. It is assumed that ``p`` is prime. - # The return is an estimate on the number of multiplications needed for one run. - const fmpz * fmpz_mod_discrete_log_pohlig_hellman_primitive_root(fmpz_mod_discrete_log_pohlig_hellman_t L) noexcept - # Return the internally stored base. - void fmpz_mod_discrete_log_pohlig_hellman_run(fmpz_t x, const fmpz_mod_discrete_log_pohlig_hellman_t L, const fmpz_t y) noexcept - # Set ``x`` to the logarithm of ``y`` with respect to the internally stored base. ``y`` is expected to be reduced modulo the ``p``. - # The function is undefined if the logarithm does not exist. - int fmpz_next_smooth_prime(fmpz_t a, const fmpz_t b) noexcept - # Either return `1` and set `a` to a smooth prime strictly greater than `b`, or return `0` and set `a` to `0`. - # The smooth primes returned by this function currently have no prime factor of `a-1` greater than `23`, but this should not be relied upon. diff --git a/src/sage/libs/flint/fmpz_mod_mat.pxd b/src/sage/libs/flint/fmpz_mod_mat.pxd index cf12ddc1d22..ce473497e3a 100644 --- a/src/sage/libs/flint/fmpz_mod_mat.pxd +++ b/src/sage/libs/flint/fmpz_mod_mat.pxd @@ -2,7 +2,9 @@ # distutils: depends = flint/fmpz_mod_mat.h ################################################################################ -# This file is auto-generated. Do not modify by hand +# This file is auto-generated by the script +# SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py. +# Do not modify by hand! Fix and rerun the script instead. ################################################################################ from libc.stdio cimport FILE @@ -11,242 +13,57 @@ from sage.libs.mpfr.types cimport * from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - fmpz * fmpz_mod_mat_entry(const fmpz_mod_mat_t mat, slong i, slong j) noexcept - # Return a reference to the element at row ``i`` and column ``j`` of ``mat``. - void fmpz_mod_mat_set_entry(fmpz_mod_mat_t mat, slong i, slong j, const fmpz_t val) noexcept - # Set the entry at row ``i`` and column ``j`` of ``mat`` to ``val``. - void fmpz_mod_mat_init(fmpz_mod_mat_t mat, slong rows, slong cols, const fmpz_t n) noexcept - # Initialise ``mat`` as a matrix with the given number of ``rows`` and - # ``cols`` and modulus ``n``. - void fmpz_mod_mat_init_set(fmpz_mod_mat_t mat, const fmpz_mod_mat_t src) noexcept - # Initialise ``mat`` and set it equal to the matrix ``src``, including the - # number of rows and columns and the modulus. - void fmpz_mod_mat_clear(fmpz_mod_mat_t mat) noexcept - # Clear ``mat`` and release any memory it used. - slong fmpz_mod_mat_nrows(const fmpz_mod_mat_t mat) noexcept - slong fmpz_mod_mat_ncols(const fmpz_mod_mat_t mat) noexcept - # Return the number of columns of ``mat``. - void _fmpz_mod_mat_set_mod(fmpz_mod_mat_t mat, const fmpz_t n) noexcept - # Set the modulus of the matrix ``mat`` to ``n``. - void fmpz_mod_mat_one(fmpz_mod_mat_t mat) noexcept - # Set ``mat`` to the identity matrix (ones down the diagonal). - void fmpz_mod_mat_zero(fmpz_mod_mat_t mat) noexcept - # Set ``mat`` to the zero matrix. - void fmpz_mod_mat_swap(fmpz_mod_mat_t mat1, fmpz_mod_mat_t mat2) noexcept - # Efficiently swap the matrices ``mat1`` and ``mat2``. - void fmpz_mod_mat_swap_entrywise(fmpz_mod_mat_t mat1, fmpz_mod_mat_t mat2) noexcept - # Swaps two matrices by swapping the individual entries rather than swapping - # the contents of the structs. - bint fmpz_mod_mat_is_empty(const fmpz_mod_mat_t mat) noexcept - # Return `1` if ``mat`` has either zero rows or columns. - bint fmpz_mod_mat_is_square(const fmpz_mod_mat_t mat) noexcept - # Return `1` if ``mat`` has the same number of rows and columns. - void _fmpz_mod_mat_reduce(fmpz_mod_mat_t mat) noexcept - # Reduce all the entries of ``mat`` by the modulus ``n``. This function is - # only needed internally. - void fmpz_mod_mat_randtest(fmpz_mod_mat_t mat, flint_rand_t state) noexcept - # Generate a random matrix with the existing dimensions and entries in - # `[0, n)` where ``n`` is the modulus. - void fmpz_mod_mat_window_init(fmpz_mod_mat_t window, const fmpz_mod_mat_t mat, slong r1, slong c1, slong r2, slong c2) noexcept - # Initializes the matrix ``window`` to be an ``r2 - r1`` by - # ``c2 - c1`` submatrix of ``mat`` whose ``(0, 0)`` entry - # is the ``(r1, c1)`` entry of ``mat``. The memory for the - # elements of ``window`` is shared with ``mat``. - void fmpz_mod_mat_window_clear(fmpz_mod_mat_t window) noexcept - # Clears the matrix ``window`` and releases any memory that it - # uses. Note that the memory to the underlying matrix that - # ``window`` points to is not freed. - void fmpz_mod_mat_concat_horizontal(fmpz_mod_mat_t res, const fmpz_mod_mat_t mat1, const fmpz_mod_mat_t mat2) noexcept - # Sets ``res`` to vertical concatenation of (``mat1``, ``mat2``) in that order. Matrix dimensions : ``mat1`` : `m \times n`, ``mat2`` : `k \times n`, ``res`` : `(m + k) \times n`. - void fmpz_mod_mat_concat_vertical(fmpz_mod_mat_t res, const fmpz_mod_mat_t mat1, const fmpz_mod_mat_t mat2) noexcept - # Sets ``res`` to horizontal concatenation of (``mat1``, ``mat2``) - # in that order. Matrix dimensions : ``mat1`` : `m \times n`, - # ``mat2`` : `m \times k`, ``res`` : `m \times (n + k)`. - void fmpz_mod_mat_print_pretty(const fmpz_mod_mat_t mat) noexcept - # Prints the given matrix to ``stdout``. The format is an - # opening square bracket then on each line a row of the matrix, followed - # by a closing square bracket. Each row is written as an opening square - # bracket followed by a space separated list of coefficients followed - # by a closing square bracket. - bint fmpz_mod_mat_is_zero(const fmpz_mod_mat_t mat) noexcept - # Return `1` if ``mat`` is the zero matrix. - void fmpz_mod_mat_set(fmpz_mod_mat_t B, const fmpz_mod_mat_t A) noexcept - # Set ``B`` to equal ``A``. - void fmpz_mod_mat_transpose(fmpz_mod_mat_t B, const fmpz_mod_mat_t A) noexcept - # Set ``B`` to the transpose of ``A``. - void fmpz_mod_mat_set_fmpz_mat(fmpz_mod_mat_t A, const fmpz_mat_t B) noexcept - # Set ``A`` to the matrix ``B`` reducing modulo the modulus of ``A``. - void fmpz_mod_mat_get_fmpz_mat(fmpz_mat_t A, const fmpz_mod_mat_t B) noexcept - # Set ``A`` to a lift of ``B``. - void fmpz_mod_mat_add(fmpz_mod_mat_t C, const fmpz_mod_mat_t A, const fmpz_mod_mat_t B) noexcept - # Set ``C`` to `A + B`. - void fmpz_mod_mat_sub(fmpz_mod_mat_t C, const fmpz_mod_mat_t A, const fmpz_mod_mat_t B) noexcept - # Set ``C`` to `A - B`. - void fmpz_mod_mat_neg(fmpz_mod_mat_t B, const fmpz_mod_mat_t A) noexcept - # Set ``B`` to `-A`. - void fmpz_mod_mat_scalar_mul_si(fmpz_mod_mat_t B, const fmpz_mod_mat_t A, slong c) noexcept - # Set ``B`` to `cA` where ``c`` is a constant. - void fmpz_mod_mat_scalar_mul_ui(fmpz_mod_mat_t B, const fmpz_mod_mat_t A, ulong c) noexcept - # Set ``B`` to `cA` where ``c`` is a constant. - void fmpz_mod_mat_scalar_mul_fmpz(fmpz_mod_mat_t B, const fmpz_mod_mat_t A, fmpz_t c) noexcept - # Set ``B`` to `cA` where ``c`` is a constant. - void fmpz_mod_mat_mul(fmpz_mod_mat_t C, const fmpz_mod_mat_t A, const fmpz_mod_mat_t B) noexcept - # Set ``C`` to ``A\times B``. The number of rows of ``B`` must match the - # number of columns of ``A``. - void _fmpz_mod_mat_mul_classical_threaded_pool_op(fmpz_mod_mat_t D, const fmpz_mod_mat_t C, const fmpz_mod_mat_t A, const fmpz_mod_mat_t B, int op, thread_pool_handle * threads, slong num_threads) noexcept - # Set ``D`` to ``A\times B + op*C`` where ``op`` is ``+1``, ``-1`` or ``0``. - void _fmpz_mod_mat_mul_classical_threaded_op(fmpz_mod_mat_t D, const fmpz_mod_mat_t C, const fmpz_mod_mat_t A, const fmpz_mod_mat_t B, int op) noexcept - # Set ``D`` to ``A\times B + op*C`` where ``op`` is ``+1``, ``-1`` or ``0``. - void fmpz_mod_mat_mul_classical_threaded(fmpz_mod_mat_t C, const fmpz_mod_mat_t A, const fmpz_mod_mat_t B) noexcept - # Set ``C`` to ``A\times B``. The number of rows of ``B`` must match the - # number of columns of ``A``. - void fmpz_mod_mat_sqr(fmpz_mod_mat_t B, const fmpz_mod_mat_t A) noexcept - # Set ``B`` to ``A^2``. The matrix ``A`` must be square. - void fmpz_mod_mat_mul_fmpz_vec(fmpz * c, const fmpz_mod_mat_t A, const fmpz * b, slong blen) noexcept void fmpz_mod_mat_mul_fmpz_vec_ptr(fmpz * const * c, const fmpz_mod_mat_t A, const fmpz * const * b, slong blen) noexcept - # Compute a matrix-vector product of ``A`` and ``(b, blen)`` and store the result in ``c``. - # The vector ``(b, blen)`` is either truncated or zero-extended to the number of columns of ``A``. - # The number entries written to ``c`` is always equal to the number of rows of ``A``. - void fmpz_mod_mat_fmpz_vec_mul(fmpz * c, const fmpz * a, slong alen, const fmpz_mod_mat_t B) noexcept void fmpz_mod_mat_fmpz_vec_mul_ptr(fmpz * const * c, const fmpz * const * a, slong alen, const fmpz_mod_mat_t B) noexcept - # Compute a vector-matrix product of ``(a, alen)`` and ``B`` and and store the result in ``c``. - # The vector ``(a, alen)`` is either truncated or zero-extended to the number of rows of ``B``. - # The number entries written to ``c`` is always equal to the number of columns of ``B``. - void fmpz_mod_mat_trace(fmpz_t trace, const fmpz_mod_mat_t mat) noexcept - # Set ``trace`` to the trace of the matrix ``mat``. - slong fmpz_mod_mat_rref(slong * perm, fmpz_mod_mat_t mat) noexcept - # Uses Gauss-Jordan elimination to set ``mat`` to its reduced row echelon - # form and returns the rank of ``mat``. - # If ``perm`` is non-``NULL``, the permutation of - # rows in the matrix will also be applied to ``perm``. - # The modulus is assumed to be prime. - void fmpz_mod_mat_strong_echelon_form(fmpz_mod_mat_t mat) noexcept - # Transforms `mat` into the strong echelon form of `mat`. The Howell form and the - # strong echelon form are equal up to permutation of the rows, see - # [FieHof2014]_ for a definition of the strong echelon form and the - # algorithm used here. - # `mat` must have at least as many rows as columns. - slong fmpz_mod_mat_howell_form(fmpz_mod_mat_t mat) noexcept - # Transforms `mat` into the Howell form of `mat`. For a definition of the - # Howell form see [StoMul1998]_. The Howell form is computed by first - # putting `mat` into strong echelon form and then ordering the rows. - # `mat` must have at least as many rows as columns. - int fmpz_mod_mat_inv(fmpz_mod_mat_t B, fmpz_mod_mat_t A) noexcept - # Sets `B = A^{-1}` and returns `1` if `A` is invertible. If `A` is singular, - # returns `0` and sets the elements of `B` to undefined values. - # `A` and `B` must be square matrices with the same dimensions. - # The modulus is assumed to be prime. - slong fmpz_mod_mat_lu(slong * P, fmpz_mod_mat_t A, int rank_check) noexcept - # Computes a generalised LU decomposition `LU = PA` of a given - # matrix `A`, returning the rank of `A`. - # If `A` is a nonsingular square matrix, it will be overwritten with - # a unit diagonal lower triangular matrix `L` and an upper - # triangular matrix `U` (the diagonal of `L` will not be stored - # explicitly). - # If `A` is an arbitrary matrix of rank `r`, `U` will be in row - # echelon form having `r` nonzero rows, and `L` will be lower - # triangular but truncated to `r` columns, having implicit ones on - # the `r` first entries of the main diagonal. All other entries will - # be zero. - # If a nonzero value for ``rank_check`` is passed, the function - # will abandon the output matrix in an undefined state and return 0 - # if `A` is detected to be rank-deficient. - # The modulus is assumed to be prime. - void fmpz_mod_mat_solve_tril(fmpz_mod_mat_t X, const fmpz_mod_mat_t L, const fmpz_mod_mat_t B, int unit) noexcept - # Sets `X = L^{-1} B` where `L` is a full rank lower triangular - # square matrix. If ``unit`` = 1, `L` is assumed to have ones on - # its main diagonal, and the main diagonal will not be read. `X` - # and `B` are allowed to be the same matrix, but no other aliasing - # is allowed. Automatically chooses between the classical and - # recursive algorithms. - # The modulus is assumed to be prime. - void fmpz_mod_mat_solve_triu(fmpz_mod_mat_t X, const fmpz_mod_mat_t U, const fmpz_mod_mat_t B, int unit) noexcept - # Sets `X = U^{-1} B` where `U` is a full rank upper triangular - # square matrix. If ``unit`` = 1, `U` is assumed to have ones on - # its main diagonal, and the main diagonal will not be read. `X` - # and `B` are allowed to be the same matrix, but no other aliasing - # is allowed. Automatically chooses between the classical and - # recursive algorithms. - # The modulus is assumed to be prime. - int fmpz_mod_mat_solve(fmpz_mod_mat_t X, const fmpz_mod_mat_t A, const fmpz_mod_mat_t B) noexcept - # Solves the matrix-matrix equation `AX = B`. - # Returns `1` if `A` has full rank; otherwise returns `0` and sets the - # elements of `X` to undefined values. - # The matrix `A` must be square. - # The modulus is assumed to be prime. - int fmpz_mod_mat_can_solve(fmpz_mod_mat_t X, const fmpz_mod_mat_t A, const fmpz_mod_mat_t B) noexcept - # Solves the matrix-matrix equation `AX = B` over `Fp`. - # Returns `1` if a solution exists; otherwise returns `0` and sets the - # elements of `X` to zero. If more than one solution exists, one of the - # valid solutions is given. - # There are no restrictions on the shape of `A` and it may be singular. - # The modulus is assumed to be prime. - void fmpz_mod_mat_similarity(fmpz_mod_mat_t M, slong r, fmpz_t d) noexcept - # Applies a similarity transform to the `n\times n` matrix `M` in-place. - # If `P` is the `n\times n` identity matrix the zero entries of whose row - # `r` (`0`-indexed) have been replaced by `d`, this transform is equivalent - # to `M = P^{-1}MP`. - # Similarity transforms preserve the determinant, characteristic polynomial - # and minimal polynomial. - # The value `d` is required to be reduced modulo the modulus of the entries - # in the matrix. - # The modulus is assumed to be prime. - void fmpz_mod_mat_charpoly(fmpz_mod_poly_t p, const fmpz_mod_mat_t M, const fmpz_mod_ctx_t ctx) noexcept - # Compute the characteristic polynomial `p` of the matrix `M`. The matrix - # is required to be square, otherwise an exception is raised. - void fmpz_mod_mat_minpoly(fmpz_mod_poly_t p, const fmpz_mod_mat_t M, const fmpz_mod_ctx_t ctx) noexcept - # Compute the minimal polynomial `p` of the matrix `M`. The matrix - # is required to be square, otherwise an exception is raised. - # The modulus is assumed to be prime. diff --git a/src/sage/libs/flint/fmpz_mod_mpoly.pxd b/src/sage/libs/flint/fmpz_mod_mpoly.pxd index 087392d781a..d0a32382809 100644 --- a/src/sage/libs/flint/fmpz_mod_mpoly.pxd +++ b/src/sage/libs/flint/fmpz_mod_mpoly.pxd @@ -2,7 +2,9 @@ # distutils: depends = flint/fmpz_mod_mpoly.h ################################################################################ -# This file is auto-generated. Do not modify by hand +# This file is auto-generated by the script +# SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py. +# Do not modify by hand! Fix and rerun the script instead. ################################################################################ from libc.stdio cimport FILE @@ -11,194 +13,75 @@ from sage.libs.mpfr.types cimport * from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void fmpz_mod_mpoly_ctx_init(fmpz_mod_mpoly_ctx_t ctx, slong nvars, const ordering_t ord, const fmpz_t p) noexcept - # Initialise a context object for a polynomial ring modulo *n* with *nvars* variables and ordering *ord*. - # The possibilities for the ordering are ``ORD_LEX``, ``ORD_DEGLEX`` and ``ORD_DEGREVLEX``. - slong fmpz_mod_mpoly_ctx_nvars(const fmpz_mod_mpoly_ctx_t ctx) noexcept - # Return the number of variables used to initialize the context. - ordering_t fmpz_mod_mpoly_ctx_ord(const fmpz_mod_mpoly_ctx_t ctx) noexcept - # Return the ordering used to initialize the context. - void fmpz_mod_mpoly_ctx_get_modulus(fmpz_t n, const fmpz_mod_mpoly_ctx_t ctx) noexcept - # Set *n* to the modulus used to initialize the context. - void fmpz_mod_mpoly_ctx_clear(fmpz_mod_mpoly_ctx_t ctx) noexcept - # Release up any space allocated by an *ctx*. - void fmpz_mod_mpoly_init(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_ctx_t ctx) noexcept - # Initialise *A* for use with the given an initialised context object. Its value is set to zero. - void fmpz_mod_mpoly_init2(fmpz_mod_mpoly_t A, slong alloc, const fmpz_mod_mpoly_ctx_t ctx) noexcept - # Initialise *A* for use with the given an initialised context object. Its value is set to zero. - # It is allocated with space for *alloc* terms and at least ``MPOLY_MIN_BITS`` bits for the exponents. - void fmpz_mod_mpoly_init3(fmpz_mod_mpoly_t A, slong alloc, flint_bitcnt_t bits, const fmpz_mod_mpoly_ctx_t ctx) noexcept - # Initialise *A* for use with the given an initialised context object. Its value is set to zero. - # It is allocated with space for *alloc* terms and *bits* bits for the exponents. - void fmpz_mod_mpoly_clear(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_ctx_t ctx) noexcept - # Release any space allocated for *A*. - char * fmpz_mod_mpoly_get_str_pretty(const fmpz_mod_mpoly_t A, const char ** x, const fmpz_mod_mpoly_ctx_t ctx) noexcept - # Return a string, which the user is responsible for cleaning up, representing *A*, given an array of variable strings *x*. - int fmpz_mod_mpoly_fprint_pretty(FILE * file, const fmpz_mod_mpoly_t A, const char ** x, const fmpz_mod_mpoly_ctx_t ctx) noexcept - # Print a string representing *A* to *file*. - int fmpz_mod_mpoly_print_pretty(const fmpz_mod_mpoly_t A, const char ** x, const fmpz_mod_mpoly_ctx_t ctx) noexcept - # Print a string representing *A* to ``stdout``. - int fmpz_mod_mpoly_set_str_pretty(fmpz_mod_mpoly_t A, const char * str, const char ** x, const fmpz_mod_mpoly_ctx_t ctx) noexcept - # Set *A* to the polynomial in the null-terminates string *str* given an array *x* of variable strings. - # If parsing *str* fails, *A* is set to zero, and `-1` is returned. Otherwise, `0` is returned. - # The operations ``+``, ``-``, ``*``, and ``/`` are permitted along with integers and the variables in *x*. The character ``^`` must be immediately followed by the (integer) exponent. - # If any division is not exact, parsing fails. - void fmpz_mod_mpoly_gen(fmpz_mod_mpoly_t A, slong var, const fmpz_mod_mpoly_ctx_t ctx) noexcept - # Set *A* to the variable of index *var*, where `var = 0` corresponds to the variable with the most significance with respect to the ordering. - bint fmpz_mod_mpoly_is_gen(const fmpz_mod_mpoly_t A, slong var, const fmpz_mod_mpoly_ctx_t ctx) noexcept - # If `var \ge 0`, return `1` if *A* is equal to the `var`-th generator, otherwise return `0`. - # If `var < 0`, return `1` if the polynomial is equal to any generator, otherwise return `0`. - void fmpz_mod_mpoly_set(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, const fmpz_mod_mpoly_ctx_t ctx) noexcept - # Set *A* to *B*. - bint fmpz_mod_mpoly_equal(const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, const fmpz_mod_mpoly_ctx_t ctx) noexcept - # Return `1` if *A* is equal to *B*, else return `0`. - void fmpz_mod_mpoly_swap(fmpz_mod_mpoly_t poly1, fmpz_mod_mpoly_t poly2, const fmpz_mod_mpoly_ctx_t ctx) noexcept - # Efficiently swap *A* and *B*. - bint fmpz_mod_mpoly_is_fmpz(const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_ctx_t ctx) noexcept - # Return `1` if *A* is a constant, else return `0`. - void fmpz_mod_mpoly_get_fmpz(fmpz_t c, const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_ctx_t ctx) noexcept - # Assuming that *A* is a constant, set *c* to this constant. - # This function throws if *A* is not a constant. - void fmpz_mod_mpoly_set_fmpz(fmpz_mod_mpoly_t A, const fmpz_t c, const fmpz_mod_mpoly_ctx_t ctx) noexcept void fmpz_mod_mpoly_set_ui(fmpz_mod_mpoly_t A, ulong c, const fmpz_mod_mpoly_ctx_t ctx) noexcept void fmpz_mod_mpoly_set_si(fmpz_mod_mpoly_t A, slong c, const fmpz_mod_mpoly_ctx_t ctx) noexcept - # Set *A* to the constant *c*. - void fmpz_mod_mpoly_zero(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_ctx_t ctx) noexcept - # Set *A* to the constant `0`. - void fmpz_mod_mpoly_one(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_ctx_t ctx) noexcept - # Set *A* to the constant `1`. - bint fmpz_mod_mpoly_equal_fmpz(const fmpz_mod_mpoly_t A, const fmpz_t c, const fmpz_mod_mpoly_ctx_t ctx) noexcept bint fmpz_mod_mpoly_equal_ui(const fmpz_mod_mpoly_t A, ulong c, const fmpz_mod_mpoly_ctx_t ctx) noexcept bint fmpz_mod_mpoly_equal_si(const fmpz_mod_mpoly_t A, slong c, const fmpz_mod_mpoly_ctx_t ctx) noexcept - # Return `1` if *A* is equal to the constant *c*, else return `0`. - bint fmpz_mod_mpoly_is_zero(const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_ctx_t ctx) noexcept - # Return `1` if *A* is the constant `0`, else return `0`. - bint fmpz_mod_mpoly_is_one(const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_ctx_t ctx) noexcept - # Return `1` if *A* is the constant `1`, else return `0`. - int fmpz_mod_mpoly_degrees_fit_si(const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_ctx_t ctx) noexcept - # Return `1` if the degrees of *A* with respect to each variable fit into an ``slong``, otherwise return `0`. - void fmpz_mod_mpoly_degrees_fmpz(fmpz ** degs, const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_ctx_t ctx) noexcept void fmpz_mod_mpoly_degrees_si(slong * degs, const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_ctx_t ctx) noexcept - # Set *degs* to the degrees of *A* with respect to each variable. - # If *A* is zero, all degrees are set to `-1`. - void fmpz_mod_mpoly_degree_fmpz(fmpz_t deg, const fmpz_mod_mpoly_t A, slong var, const fmpz_mod_mpoly_ctx_t ctx) noexcept slong fmpz_mod_mpoly_degree_si(const fmpz_mod_mpoly_t A, slong var, const fmpz_mod_mpoly_ctx_t ctx) noexcept - # Either return or set *deg* to the degree of *A* with respect to the variable of index *var*. - # If *A* is zero, the degree is defined to be `-1`. - int fmpz_mod_mpoly_total_degree_fits_si(const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_ctx_t ctx) noexcept - # Return `1` if the total degree of *A* fits into an ``slong``, otherwise return `0`. - void fmpz_mod_mpoly_total_degree_fmpz(fmpz_t tdeg, const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_ctx_t ctx) noexcept slong fmpz_mod_mpoly_total_degree_si(const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_ctx_t ctx) noexcept - # Either return or set *tdeg* to the total degree of *A*. - # If *A* is zero, the total degree is defined to be `-1`. - void fmpz_mod_mpoly_used_vars(int * used, const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_ctx_t ctx) noexcept - # For each variable index *i*, set ``used[i]`` to nonzero if the variable of index *i* appears in *A* and to zero otherwise. - void fmpz_mod_mpoly_get_coeff_fmpz_monomial(fmpz_t c, const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t M, const fmpz_mod_mpoly_ctx_t ctx) noexcept - # Assuming that *M* is a monomial, set *c* to the coefficient of the corresponding monomial in *A*. - # This function throws if *M* is not a monomial. - void fmpz_mod_mpoly_set_coeff_fmpz_monomial(fmpz_mod_mpoly_t A, const fmpz_t c, const fmpz_mod_mpoly_t M, const fmpz_mod_mpoly_ctx_t ctx) noexcept - # Assuming that *M* is a monomial, set the coefficient of the corresponding monomial in *A* to *c*. - # This function throws if *M* is not a monomial. - void fmpz_mod_mpoly_get_coeff_fmpz_fmpz(fmpz_t c, const fmpz_mod_mpoly_t A, fmpz * const * exp, const fmpz_mod_mpoly_ctx_t ctx) noexcept void fmpz_mod_mpoly_get_coeff_fmpz_ui(fmpz_t c, const fmpz_mod_mpoly_t A, const ulong * exp, const fmpz_mod_mpoly_ctx_t ctx) noexcept - # Set *c* to the coefficient of the monomial with exponent vector *exp*. - void fmpz_mod_mpoly_set_coeff_fmpz_fmpz(fmpz_mod_mpoly_t A, const fmpz_t c, fmpz * const * exp, const fmpz_mod_mpoly_ctx_t ctx) noexcept void fmpz_mod_mpoly_set_coeff_ui_fmpz(fmpz_mod_mpoly_t A, ulong c, fmpz * const * exp, const fmpz_mod_mpoly_ctx_t ctx) noexcept void fmpz_mod_mpoly_set_coeff_si_fmpz(fmpz_mod_mpoly_t A, slong c, fmpz * const * exp, const fmpz_mod_mpoly_ctx_t ctx) noexcept void fmpz_mod_mpoly_set_coeff_fmpz_ui(fmpz_mod_mpoly_t A, const fmpz_t c, const ulong * exp, const fmpz_mod_mpoly_ctx_t ctx) noexcept void fmpz_mod_mpoly_set_coeff_ui_ui(fmpz_mod_mpoly_t A, ulong c, const ulong * exp, const fmpz_mod_mpoly_ctx_t ctx) noexcept void fmpz_mod_mpoly_set_coeff_si_ui(fmpz_mod_mpoly_t A, slong c, const ulong * exp, const fmpz_mod_mpoly_ctx_t ctx) noexcept - # Set the coefficient of the monomial with exponent vector *exp* to *c*. - void fmpz_mod_mpoly_get_coeff_vars_ui(fmpz_mod_mpoly_t C, const fmpz_mod_mpoly_t A, const slong * vars, const ulong * exps, slong length, const fmpz_mod_mpoly_ctx_t ctx) noexcept - # Set *C* to the coefficient of *A* with respect to the variables in *vars* with powers in the corresponding array *exps*. - # Both *vars* and *exps* point to array of length *length*. It is assumed that `0 < length \le nvars(A)` and that the variables in *vars* are distinct. - int fmpz_mod_mpoly_cmp(const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, const fmpz_mod_mpoly_ctx_t ctx) noexcept - # Return `1` (resp. `-1`, or `0`) if *A* is after (resp. before, same as) *B* in some arbitrary but fixed total ordering of the polynomials. - # This ordering agrees with the usual ordering of monomials when *A* and *B* are both monomials. - bint fmpz_mod_mpoly_is_canonical(const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_ctx_t ctx) noexcept - # Return `1` if *A* is in canonical form. Otherwise, return `0`. - # To be in canonical form, all of the terms must have nonzero coefficient, and the terms must be sorted from greatest to least. - slong fmpz_mod_mpoly_length(const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_ctx_t ctx) noexcept - # Return the number of terms in *A*. - # If the polynomial is in canonical form, this will be the number of nonzero coefficients. - void fmpz_mod_mpoly_resize(fmpz_mod_mpoly_t A, slong new_length, const fmpz_mod_mpoly_ctx_t ctx) noexcept - # Set the length of *A* to ``new_length``. - # Terms are either deleted from the end, or new zero terms are appended. - void fmpz_mod_mpoly_get_term_coeff_fmpz(fmpz_t c, const fmpz_mod_mpoly_t A, slong i, const fmpz_mod_mpoly_ctx_t ctx) noexcept - # Set *c* to the coefficient of the term of index *i*. - void fmpz_mod_mpoly_set_term_coeff_fmpz(fmpz_mod_mpoly_t A, slong i, const fmpz_t c, const fmpz_mod_mpoly_ctx_t ctx) noexcept void fmpz_mod_mpoly_set_term_coeff_ui(fmpz_mod_mpoly_t A, slong i, ulong c, const fmpz_mod_mpoly_ctx_t ctx) noexcept void fmpz_mod_mpoly_set_term_coeff_si(fmpz_mod_mpoly_t A, slong i, slong c, const fmpz_mod_mpoly_ctx_t ctx) noexcept - # Set the coefficient of the term of index *i* to *c*. - int fmpz_mod_mpoly_term_exp_fits_si(const fmpz_mod_mpoly_t poly, slong i, const fmpz_mod_mpoly_ctx_t ctx) noexcept int fmpz_mod_mpoly_term_exp_fits_ui(const fmpz_mod_mpoly_t poly, slong i, const fmpz_mod_mpoly_ctx_t ctx) noexcept - # Return `1` if all entries of the exponent vector of the term of index *i* fit into an ``slong`` (resp. a ``ulong``). Otherwise, return `0`. - void fmpz_mod_mpoly_get_term_exp_fmpz(fmpz ** exp, const fmpz_mod_mpoly_t A, slong i, const fmpz_mod_mpoly_ctx_t ctx) noexcept void fmpz_mod_mpoly_get_term_exp_ui(ulong * exp, const fmpz_mod_mpoly_t A, slong i, const fmpz_mod_mpoly_ctx_t ctx) noexcept void fmpz_mod_mpoly_get_term_exp_si(slong * exp, const fmpz_mod_mpoly_t A, slong i, const fmpz_mod_mpoly_ctx_t ctx) noexcept - # Set *exp* to the exponent vector of the term of index *i*. - # The ``_ui`` (resp. ``_si``) version throws if any entry does not fit into a ``ulong`` (resp. ``slong``). - ulong fmpz_mod_mpoly_get_term_var_exp_ui(const fmpz_mod_mpoly_t A, slong i, slong var, const fmpz_mod_mpoly_ctx_t ctx) noexcept slong fmpz_mod_mpoly_get_term_var_exp_si(const fmpz_mod_mpoly_t A, slong i, slong var, const fmpz_mod_mpoly_ctx_t ctx) noexcept - # Return the exponent of the variable *var* of the term of index *i*. - # This function throws if the exponent does not fit into a ``ulong`` (resp. ``slong``). - void fmpz_mod_mpoly_set_term_exp_fmpz(fmpz_mod_mpoly_t A, slong i, fmpz * const * exp, const fmpz_mod_mpoly_ctx_t ctx) noexcept void fmpz_mod_mpoly_set_term_exp_ui(fmpz_mod_mpoly_t A, slong i, const ulong * exp, const fmpz_mod_mpoly_ctx_t ctx) noexcept - # Set the exponent vector of the term of index *i* to *exp*. - void fmpz_mod_mpoly_get_term(fmpz_mod_mpoly_t M, const fmpz_mod_mpoly_t A, slong i, const fmpz_mod_mpoly_ctx_t ctx) noexcept - # Set *M* to the term of index *i* in *A*. - void fmpz_mod_mpoly_get_term_monomial(fmpz_mod_mpoly_t M, const fmpz_mod_mpoly_t A, slong i, const fmpz_mod_mpoly_ctx_t ctx) noexcept - # Set *M* to the monomial of the term of index *i* in *A*. The coefficient of *M* will be one. - void fmpz_mod_mpoly_push_term_fmpz_fmpz(fmpz_mod_mpoly_t A, const fmpz_t c, fmpz * const * exp, const fmpz_mod_mpoly_ctx_t ctx) noexcept void fmpz_mod_mpoly_push_term_fmpz_ffmpz(fmpz_mod_mpoly_t A, const fmpz_t c, const fmpz * exp, const fmpz_mod_mpoly_ctx_t ctx) noexcept void fmpz_mod_mpoly_push_term_ui_fmpz(fmpz_mod_mpoly_t A, ulong c, fmpz * const * exp, const fmpz_mod_mpoly_ctx_t ctx) noexcept @@ -208,209 +91,69 @@ cdef extern from "flint_wrap.h": void fmpz_mod_mpoly_push_term_fmpz_ui(fmpz_mod_mpoly_t A, const fmpz_t c, const ulong * exp, const fmpz_mod_mpoly_ctx_t ctx) noexcept void fmpz_mod_mpoly_push_term_ui_ui(fmpz_mod_mpoly_t A, ulong c, const ulong * exp, const fmpz_mod_mpoly_ctx_t ctx) noexcept void fmpz_mod_mpoly_push_term_si_ui(fmpz_mod_mpoly_t A, slong c, const ulong * exp, const fmpz_mod_mpoly_ctx_t ctx) noexcept - # Append a term to *A* with coefficient *c* and exponent vector *exp*. - # This function runs in constant average time. - void fmpz_mod_mpoly_sort_terms(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_ctx_t ctx) noexcept - # Sort the terms of *A* into the canonical ordering dictated by the ordering in *ctx*. - # This function simply reorders the terms: It does not combine like terms, nor does it delete terms with coefficient zero. - # This function runs in linear time in the size of *A*. - void fmpz_mod_mpoly_combine_like_terms(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_ctx_t ctx) noexcept - # Combine adjacent like terms in *A* and delete terms with coefficient zero. - # If the terms of *A* were sorted to begin with, the result will be in canonical form. - # This function runs in linear time in the size of *A*. - void fmpz_mod_mpoly_reverse(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, const fmpz_mod_mpoly_ctx_t ctx) noexcept - # Set *A* to the reversal of *B*. - void fmpz_mod_mpoly_randtest_bound(fmpz_mod_mpoly_t A, flint_rand_t state, slong length, ulong exp_bound, const fmpz_mod_mpoly_ctx_t ctx) noexcept - # Generate a random polynomial with length up to *length* and exponents in the range ``[0, exp_bound - 1]``. - # The exponents of each variable are generated by calls to ``n_randint(state, exp_bound)``. - void fmpz_mod_mpoly_randtest_bounds(fmpz_mod_mpoly_t A, flint_rand_t state, slong length, ulong * exp_bounds, const fmpz_mod_mpoly_ctx_t ctx) noexcept - # Generate a random polynomial with length up to *length* and exponents in the range ``[0, exp_bounds[i] - 1]``. - # The exponents of the variable of index *i* are generated by calls to ``n_randint(state, exp_bounds[i])``. - void fmpz_mod_mpoly_randtest_bits(fmpz_mod_mpoly_t A, flint_rand_t state, slong length, mp_limb_t exp_bits, const fmpz_mod_mpoly_ctx_t ctx) noexcept - # Generate a random polynomial with length up to *length* and exponents whose packed form does not exceed the given bit count. - void fmpz_mod_mpoly_add_fmpz(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, const fmpz_t c, const fmpz_mod_mpoly_ctx_t ctx) noexcept void fmpz_mod_mpoly_add_ui(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, ulong c, const fmpz_mod_mpoly_ctx_t ctx) noexcept void fmpz_mod_mpoly_add_si(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, slong c, const fmpz_mod_mpoly_ctx_t ctx) noexcept - # Set *A* to `B + c`. - void fmpz_mod_mpoly_sub_fmpz(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, const fmpz_t c, const fmpz_mod_mpoly_ctx_t ctx) noexcept void fmpz_mod_mpoly_sub_ui(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, ulong c, const fmpz_mod_mpoly_ctx_t ctx) noexcept void fmpz_mod_mpoly_sub_si(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, slong c, const fmpz_mod_mpoly_ctx_t ctx) noexcept - # Set *A* to `B - c`. - void fmpz_mod_mpoly_add(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, const fmpz_mod_mpoly_t C, const fmpz_mod_mpoly_ctx_t ctx) noexcept - # Set *A* to `B + C`. - void fmpz_mod_mpoly_sub(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, const fmpz_mod_mpoly_t C, const fmpz_mod_mpoly_ctx_t ctx) noexcept - # Set *A* to `B - C`. - void fmpz_mod_mpoly_neg(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, const fmpz_mod_mpoly_ctx_t ctx) noexcept - # Set *A* to `-B`. - void fmpz_mod_mpoly_scalar_mul_fmpz(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, const fmpz_t c, const fmpz_mod_mpoly_ctx_t ctx) noexcept void fmpz_mod_mpoly_scalar_mul_ui(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, ulong c, const fmpz_mod_mpoly_ctx_t ctx) noexcept void fmpz_mod_mpoly_scalar_mul_si(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, slong c, const fmpz_mod_mpoly_ctx_t ctx) noexcept - # Set *A* to `B \times c`. - void fmpz_mod_mpoly_scalar_addmul_fmpz(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, const fmpz_mod_mpoly_t C, const fmpz_t d, const fmpz_mod_mpoly_ctx_t ctx) noexcept - # Sets *A* to `B + C \times d`. - void fmpz_mod_mpoly_make_monic(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, const fmpz_mod_mpoly_ctx_t ctx) noexcept - # Set *A* to *B* divided by the leading coefficient of *B*. This throws if *B* is zero or the leading coefficient is not invertible. - void fmpz_mod_mpoly_derivative(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, slong var, const fmpz_mod_mpoly_ctx_t ctx) noexcept - # Set *A* to the derivative of *B* with respect to the variable of index *var*. - void fmpz_mod_mpoly_evaluate_all_fmpz(fmpz_t eval, const fmpz_mod_mpoly_t A, fmpz * const * vals, const fmpz_mod_mpoly_ctx_t ctx) noexcept - # Set *ev* to the evaluation of *A* where the variables are replaced by the corresponding elements of the array *vals*. - void fmpz_mod_mpoly_evaluate_one_fmpz(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, slong var, const fmpz_t val, const fmpz_mod_mpoly_ctx_t ctx) noexcept - # Set *A* to the evaluation of *B* where the variable of index *var* is replaced by *val*. - # Return `1` for success and `0` for failure. - int fmpz_mod_mpoly_compose_fmpz_poly(fmpz_poly_t A, const fmpz_mod_mpoly_t B, fmpz_poly_struct * const * C, const fmpz_mod_mpoly_ctx_t ctxB) noexcept - # Set *A* to the evaluation of *B* where the variables are replaced by the corresponding elements of the array *C*. - # The context object of *B* is *ctxB*. - # Return `1` for success and `0` for failure. - int fmpz_mod_mpoly_compose_fmpz_mod_mpoly_geobucket(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, fmpz_mod_mpoly_struct * const * C, const fmpz_mod_mpoly_ctx_t ctxB, const fmpz_mod_mpoly_ctx_t ctxAC) noexcept int fmpz_mod_mpoly_compose_fmpz_mod_mpoly(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, fmpz_mod_mpoly_struct * const * C, const fmpz_mod_mpoly_ctx_t ctxB, const fmpz_mod_mpoly_ctx_t ctxAC) noexcept - # Set *A* to the evaluation of *B* where the variables are replaced by the corresponding elements of the array *C*. - # Both *A* and the elements of *C* have context object *ctxAC*, while *B* has context object *ctxB*. - # The length of the array *C* is the number of variables in *ctxB*. - # Neither *A* nor *B* is allowed to alias any other polynomial. - # Return `1` for success and `0` for failure. - # The main method attempts to perform the calculation using matrices and chooses heuristically between the ``geobucket`` and ``horner`` methods if needed. - void fmpz_mod_mpoly_compose_fmpz_mod_mpoly_gen(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, const slong * c, const fmpz_mod_mpoly_ctx_t ctxB, const fmpz_mod_mpoly_ctx_t ctxAC) noexcept - # Set *A* to the evaluation of *B* where the variable of index *i* in *ctxB* is replaced by the variable of index ``c[i]`` in *ctxAC*. - # The length of the array *C* is the number of variables in *ctxB*. - # If any ``c[i]`` is negative, the corresponding variable of *B* is replaced by zero. Otherwise, it is expected that ``c[i]`` is less than the number of variables in *ctxAC*. - void fmpz_mod_mpoly_mul(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, const fmpz_mod_mpoly_t C, const fmpz_mod_mpoly_ctx_t ctx) noexcept - # Set *A* to `B \times C`. - void fmpz_mod_mpoly_mul_johnson(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, const fmpz_mod_mpoly_t C, const fmpz_mod_mpoly_ctx_t ctx) noexcept - # Set *A* to `B \times C` using Johnson's heap-based method. - int fmpz_mod_mpoly_mul_dense(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, const fmpz_mod_mpoly_t C, const fmpz_mod_mpoly_ctx_t ctx) noexcept - # Try to set *A* to `B \times C` using dense arithmetic. - # If the return is `0`, the operation was unsuccessful. Otherwise, it was successful and the return is `1`. - int fmpz_mod_mpoly_pow_fmpz(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, const fmpz_t k, const fmpz_mod_mpoly_ctx_t ctx) noexcept - # Set *A* to *B* raised to the `k`-th power. - # Return `1` for success and `0` for failure. - int fmpz_mod_mpoly_pow_ui(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, ulong k, const fmpz_mod_mpoly_ctx_t ctx) noexcept - # Set *A* to *B* raised to the `k`-th power. - # Return `1` for success and `0` for failure. - int fmpz_mod_mpoly_divides(fmpz_mod_mpoly_t Q, const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, const fmpz_mod_mpoly_ctx_t ctx) noexcept - # If *A* is divisible by *B*, set *Q* to the exact quotient and return `1`. Otherwise, set *Q* to zero and return `0`. - void fmpz_mod_mpoly_div(fmpz_mod_mpoly_t Q, const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, const fmpz_mod_mpoly_ctx_t ctx) noexcept - # Set *Q* to the quotient of *A* by *B*, discarding the remainder. - void fmpz_mod_mpoly_divrem(fmpz_mod_mpoly_t Q, fmpz_mod_mpoly_t R, const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, const fmpz_mod_mpoly_ctx_t ctx) noexcept - # Set *Q* and *R* to the quotient and remainder of *A* divided by *B*. - void fmpz_mod_mpoly_divrem_ideal(fmpz_mod_mpoly_struct ** Q, fmpz_mod_mpoly_t R, const fmpz_mod_mpoly_t A, fmpz_mod_mpoly_struct * const * B, slong len, const fmpz_mod_mpoly_ctx_t ctx) noexcept - # This function is as per :func:`fmpz_mod_mpoly_divrem` except that it takes an array of divisor polynomials *B* and it returns an array of quotient polynomials *Q*. - # The number of divisor (and hence quotient) polynomials, is given by *len*. - void fmpz_mod_mpoly_term_content(fmpz_mod_mpoly_t M, const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_ctx_t ctx) noexcept - # Set *M* to the GCD of the terms of *A*. - # If *A* is zero, *M* will be zero. Otherwise, *M* will be a monomial with coefficient one. - int fmpz_mod_mpoly_content_vars(fmpz_mod_mpoly_t g, const fmpz_mod_mpoly_t A, slong * vars, slong vars_length, const fmpz_mod_mpoly_ctx_t ctx) noexcept - # Set *g* to the GCD of the coefficients of *A* when viewed as a polynomial in the variables *vars*. - # Return `1` for success and `0` for failure. Upon success, *g* will be independent of the variables *vars*. - int fmpz_mod_mpoly_gcd(fmpz_mod_mpoly_t G, const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, const fmpz_mod_mpoly_ctx_t ctx) noexcept - # Try to set *G* to the monic GCD of *A* and *B*. The GCD of zero and zero is defined to be zero. - # If the return is `1` the function was successful. Otherwise the return is `0` and *G* is left untouched. - int fmpz_mod_mpoly_gcd_cofactors(fmpz_mod_mpoly_t G, fmpz_mod_mpoly_t Abar, fmpz_mod_mpoly_t Bbar, const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, const fmpz_mod_mpoly_ctx_t ctx) noexcept - # Do the operation of :func:`fmpz_mod_mpoly_gcd` and also compute `Abar = A/G` and `Bbar = B/G` if successful. - int fmpz_mod_mpoly_gcd_brown(fmpz_mod_mpoly_t G, const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, const fmpz_mod_mpoly_ctx_t ctx) noexcept int fmpz_mod_mpoly_gcd_hensel(fmpz_mod_mpoly_t G, const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, const fmpz_mod_mpoly_ctx_t ctx) noexcept int fmpz_mod_mpoly_gcd_subresultant(fmpz_mod_mpoly_t G, const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, const fmpz_mod_mpoly_ctx_t ctx) noexcept int fmpz_mod_mpoly_gcd_zippel(fmpz_mod_mpoly_t G, const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, const fmpz_mod_mpoly_ctx_t ctx) noexcept int fmpz_mod_mpoly_gcd_zippel2(fmpz_mod_mpoly_t G, const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, const fmpz_mod_mpoly_ctx_t ctx) noexcept - # Try to set *G* to the GCD of *A* and *B* using various algorithms. - int fmpz_mod_mpoly_resultant(fmpz_mod_mpoly_t R, const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, slong var, const fmpz_mod_mpoly_ctx_t ctx) noexcept - # Try to set *R* to the resultant of *A* and *B* with respect to the variable of index *var*. - int fmpz_mod_mpoly_discriminant(fmpz_mod_mpoly_t D, const fmpz_mod_mpoly_t A, slong var, const fmpz_mod_mpoly_ctx_t ctx) noexcept - # Try to set *D* to the discriminant of *A* with respect to the variable of index *var*. - int fmpz_mod_mpoly_sqrt(fmpz_mod_mpoly_t Q, const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_ctx_t ctx) noexcept - # If `Q^2=A` has a solution, set *Q* to a solution and return `1`, otherwise return `0` and set *Q* to zero. - bint fmpz_mod_mpoly_is_square(const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_ctx_t ctx) noexcept - # Return `1` if *A* is a perfect square, otherwise return `0`. - int fmpz_mod_mpoly_quadratic_root(fmpz_mod_mpoly_t Q, const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, const fmpz_mod_mpoly_ctx_t ctx) noexcept - # If `Q^2+AQ=B` has a solution, set *Q* to a solution and return `1`, otherwise return `0`. - void fmpz_mod_mpoly_univar_init(fmpz_mod_mpoly_univar_t A, const fmpz_mod_mpoly_ctx_t ctx) noexcept - # Initialize *A*. - void fmpz_mod_mpoly_univar_clear(fmpz_mod_mpoly_univar_t A, const fmpz_mod_mpoly_ctx_t ctx) noexcept - # Clear *A*. - void fmpz_mod_mpoly_univar_swap(fmpz_mod_mpoly_univar_t A, fmpz_mod_mpoly_univar_t B, const fmpz_mod_mpoly_ctx_t ctx) noexcept - # Swap *A* and *B*. - void fmpz_mod_mpoly_to_univar(fmpz_mod_mpoly_univar_t A, const fmpz_mod_mpoly_t B, slong var, const fmpz_mod_mpoly_ctx_t ctx) noexcept - # Set *A* to a univariate form of *B* by pulling out the variable of index *var*. - # The coefficients of *A* will still belong to the content *ctx* but will not depend on the variable of index *var*. - void fmpz_mod_mpoly_from_univar(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_univar_t B, slong var, const fmpz_mod_mpoly_ctx_t ctx) noexcept - # Set *A* to the normal form of *B* by putting in the variable of index *var*. - # This function is undefined if the coefficients of *B* depend on the variable of index *var*. - int fmpz_mod_mpoly_univar_degree_fits_si(const fmpz_mod_mpoly_univar_t A, const fmpz_mod_mpoly_ctx_t ctx) noexcept - # Return `1` if the degree of *A* with respect to the main variable fits an ``slong``. Otherwise, return `0`. - slong fmpz_mod_mpoly_univar_length(const fmpz_mod_mpoly_univar_t A, const fmpz_mod_mpoly_ctx_t ctx) noexcept - # Return the number of terms in *A* with respect to the main variable. - slong fmpz_mod_mpoly_univar_get_term_exp_si(fmpz_mod_mpoly_univar_t A, slong i, const fmpz_mod_mpoly_ctx_t ctx) noexcept - # Return the exponent of the term of index *i* of *A*. - void fmpz_mod_mpoly_univar_get_term_coeff(fmpz_mod_mpoly_t c, const fmpz_mod_mpoly_univar_t A, slong i, const fmpz_mod_mpoly_ctx_t ctx) noexcept void fmpz_mod_mpoly_univar_swap_term_coeff(fmpz_mod_mpoly_t c, fmpz_mod_mpoly_univar_t A, slong i, const fmpz_mod_mpoly_ctx_t ctx) noexcept - # Set (resp. swap) *c* to (resp. with) the coefficient of the term of index *i* of *A*. - void fmpz_mod_mpoly_univar_set_coeff_ui(fmpz_mod_mpoly_univar_t Ax, ulong e, const fmpz_mod_mpoly_t c, const fmpz_mod_mpoly_ctx_t ctx) noexcept - # Set the coefficient of `X^e` in *Ax* to *c*. - int fmpz_mod_mpoly_univar_resultant(fmpz_mod_mpoly_t R, const fmpz_mod_mpoly_univar_t Ax, const fmpz_mod_mpoly_univar_t Bx, const fmpz_mod_mpoly_ctx_t ctx) noexcept - # Try to set *R* to the resultant of *Ax* and *Bx*. - int fmpz_mod_mpoly_univar_discriminant(fmpz_mod_mpoly_t D, const fmpz_mod_mpoly_univar_t Ax, const fmpz_mod_mpoly_ctx_t ctx) noexcept - # Try to set *D* to the discriminant of *Ax*. - void fmpz_mod_mpoly_inflate(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, const fmpz * shift, const fmpz * stride, const fmpz_mod_mpoly_ctx_t ctx) noexcept - # Apply the function ``e -> shift[v] + stride[v]*e`` to each exponent ``e`` corresponding to the variable ``v``. - # It is assumed that each shift and stride is not negative. - void fmpz_mod_mpoly_deflate(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, const fmpz * shift, const fmpz * stride, const fmpz_mod_mpoly_ctx_t ctx) noexcept - # Apply the function ``e -> (e - shift[v])/stride[v]`` to each exponent ``e`` corresponding to the variable ``v``. - # If any ``stride[v]`` is zero, the corresponding numerator ``e - shift[v]`` is assumed to be zero, and the quotient is defined as zero. - # This allows the function to undo the operation performed by :func:`fmpz_mod_mpoly_inflate` when possible. - void fmpz_mod_mpoly_deflation(fmpz * shift, fmpz * stride, const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_ctx_t ctx) noexcept - # For each variable `v` let `S_v` be the set of exponents appearing on `v`. - # Set ``shift[v]`` to `\operatorname{min}(S_v)` and set ``stride[v]`` to `\operatorname{gcd}(S-\operatorname{min}(S_v))`. - # If *A* is zero, all shifts and strides are set to zero. diff --git a/src/sage/libs/flint/fmpz_mod_mpoly_factor.pxd b/src/sage/libs/flint/fmpz_mod_mpoly_factor.pxd index 3e66286235b..c1c9657975e 100644 --- a/src/sage/libs/flint/fmpz_mod_mpoly_factor.pxd +++ b/src/sage/libs/flint/fmpz_mod_mpoly_factor.pxd @@ -2,7 +2,9 @@ # distutils: depends = flint/fmpz_mod_mpoly_factor.h ################################################################################ -# This file is auto-generated. Do not modify by hand +# This file is auto-generated by the script +# SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py. +# Do not modify by hand! Fix and rerun the script instead. ################################################################################ from libc.stdio cimport FILE @@ -11,37 +13,14 @@ from sage.libs.mpfr.types cimport * from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void fmpz_mod_mpoly_factor_init(fmpz_mod_mpoly_factor_t f, const fmpz_mod_mpoly_ctx_t ctx) noexcept - # Initialise *f*. - void fmpz_mod_mpoly_factor_clear(fmpz_mod_mpoly_factor_t f, const fmpz_mod_mpoly_ctx_t ctx) noexcept - # Clear *f*. - void fmpz_mod_mpoly_factor_swap(fmpz_mod_mpoly_factor_t f, fmpz_mod_mpoly_factor_t g, const fmpz_mod_mpoly_ctx_t ctx) noexcept - # Efficiently swap *f* and *g*. - slong fmpz_mod_mpoly_factor_length(const fmpz_mod_mpoly_factor_t f, const fmpz_mod_mpoly_ctx_t ctx) noexcept - # Return the length of the product in *f*. - void fmpz_mod_mpoly_factor_get_constant_fmpz(fmpz_t c, const fmpz_mod_mpoly_factor_t f, const fmpz_mod_mpoly_ctx_t ctx) noexcept - # Set *c* to the constant of *f*. - void fmpz_mod_mpoly_factor_get_base(fmpz_mod_mpoly_t B, const fmpz_mod_mpoly_factor_t f, slong i, const fmpz_mod_mpoly_ctx_t ctx) noexcept void fmpz_mod_mpoly_factor_swap_base(fmpz_mod_mpoly_t B, fmpz_mod_mpoly_factor_t f, slong i, const fmpz_mod_mpoly_ctx_t ctx) noexcept - # Set (resp. swap) *B* to (resp. with) the base of the term of index *i* in *f*. - slong fmpz_mod_mpoly_factor_get_exp_si(fmpz_mod_mpoly_factor_t f, slong i, const fmpz_mod_mpoly_ctx_t ctx) noexcept - # Return the exponent of the term of index *i* in *f*. It is assumed to fit an ``slong``. - void fmpz_mod_mpoly_factor_sort(fmpz_mod_mpoly_factor_t f, const fmpz_mod_mpoly_ctx_t ctx) noexcept - # Sort the product of *f* first by exponent and then by base. - int fmpz_mod_mpoly_factor_squarefree(fmpz_mod_mpoly_factor_t f, const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_ctx_t ctx) noexcept - # Set *f* to a factorization of *A* where the bases are primitive and - # pairwise relatively prime. If the product of all irreducible factors with - # a given exponent is desired, it is recommended to call :func:`fmpz_mod_mpoly_factor_sort` - # and then multiply the bases with the desired exponent. - int fmpz_mod_mpoly_factor(fmpz_mod_mpoly_factor_t f, const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_ctx_t ctx) noexcept - # Set *f* to a factorization of *A* where the bases are irreducible. diff --git a/src/sage/libs/flint/fmpz_mod_poly.pxd b/src/sage/libs/flint/fmpz_mod_poly.pxd index 17fe637a632..302113e191b 100644 --- a/src/sage/libs/flint/fmpz_mod_poly.pxd +++ b/src/sage/libs/flint/fmpz_mod_poly.pxd @@ -2,7 +2,9 @@ # distutils: depends = flint/fmpz_mod_poly.h ################################################################################ -# This file is auto-generated. Do not modify by hand +# This file is auto-generated by the script +# SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py. +# Do not modify by hand! Fix and rerun the script instead. ################################################################################ from libc.stdio cimport FILE @@ -11,1339 +13,235 @@ from sage.libs.mpfr.types cimport * from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void fmpz_mod_poly_init(fmpz_mod_poly_t poly, const fmpz_mod_ctx_t ctx) noexcept - # Initialises ``poly`` for use with context ``ctx`` and set it to zero. - # A corresponding call to :func:`fmpz_mod_poly_clear` must be made to free the memory used by the polynomial. - void fmpz_mod_poly_init2(fmpz_mod_poly_t poly, slong alloc, const fmpz_mod_ctx_t ctx) noexcept - # Initialises ``poly`` with space for at least ``alloc`` coefficients - # and sets the length to zero. The allocated coefficients are all set to - # zero. - void fmpz_mod_poly_clear(fmpz_mod_poly_t poly, const fmpz_mod_ctx_t ctx) noexcept - # Clears the given polynomial, releasing any memory used. It must - # be reinitialised in order to be used again. - void fmpz_mod_poly_realloc(fmpz_mod_poly_t poly, slong alloc, const fmpz_mod_ctx_t ctx) noexcept - # Reallocates the given polynomial to have space for ``alloc`` - # coefficients. If ``alloc`` is zero the polynomial is cleared - # and then reinitialised. If the current length is greater than - # ``alloc`` the polynomial is first truncated to length ``alloc``. - void fmpz_mod_poly_fit_length(fmpz_mod_poly_t poly, slong len, const fmpz_mod_ctx_t ctx) noexcept - # If ``len`` is greater than the number of coefficients currently - # allocated, then the polynomial is reallocated to have space for at - # least ``len`` coefficients. No data is lost when calling this - # function. - # The function efficiently deals with the case where it is called - # many times in small increments by at least doubling the number of - # allocated coefficients when length is larger than the number of - # coefficients currently allocated. - void _fmpz_mod_poly_normalise(fmpz_mod_poly_t poly) noexcept - # Sets the length of ``poly`` so that the top coefficient is non-zero. - # If all coefficients are zero, the length is set to zero. This function - # is mainly used internally, as all functions guarantee normalisation. - void _fmpz_mod_poly_set_length(fmpz_mod_poly_t poly, slong len) noexcept - # Demotes the coefficients of ``poly`` beyond ``len`` and sets - # the length of ``poly`` to ``len``. - void fmpz_mod_poly_truncate(fmpz_mod_poly_t poly, slong len, const fmpz_mod_ctx_t ctx) noexcept - # If the current length of ``poly`` is greater than ``len``, it - # is truncated to have the given length. Discarded coefficients are - # not necessarily set to zero. - void fmpz_mod_poly_set_trunc(fmpz_mod_poly_t res, const fmpz_mod_poly_t poly, slong n, const fmpz_mod_ctx_t ctx) noexcept - # Notionally truncate ``poly`` to length `n` and set ``res`` to the - # result. The result is normalised. - void fmpz_mod_poly_randtest(fmpz_mod_poly_t f, flint_rand_t state, slong len, const fmpz_mod_ctx_t ctx) noexcept - # Sets the polynomial~`f` to a random polynomial of length up~``len``. - void fmpz_mod_poly_randtest_irreducible(fmpz_mod_poly_t f, flint_rand_t state, slong len, const fmpz_mod_ctx_t ctx) noexcept - # Sets the polynomial~`f` to a random irreducible polynomial of length - # up~``len``, assuming ``len`` is positive. - void fmpz_mod_poly_randtest_not_zero(fmpz_mod_poly_t f, flint_rand_t state, slong len, const fmpz_mod_ctx_t ctx) noexcept - # Sets the polynomial~`f` to a random polynomial of length up~``len``, - # assuming ``len`` is positive. - void fmpz_mod_poly_randtest_monic(fmpz_mod_poly_t poly, flint_rand_t state, slong len, const fmpz_mod_ctx_t ctx) noexcept - # Generates a random monic polynomial with length ``len``. - void fmpz_mod_poly_randtest_monic_irreducible(fmpz_mod_poly_t poly, flint_rand_t state, slong len, const fmpz_mod_ctx_t ctx) noexcept - # Generates a random monic irreducible polynomial with length ``len``. - void fmpz_mod_poly_randtest_monic_primitive(fmpz_mod_poly_t poly, flint_rand_t state, slong len, const fmpz_mod_ctx_t ctx) noexcept - # Generates a random monic irreducible primitive polynomial with - # length ``len``. - void fmpz_mod_poly_randtest_trinomial(fmpz_mod_poly_t poly, flint_rand_t state, slong len, const fmpz_mod_ctx_t ctx) noexcept - # Generates a random monic trinomial of length ``len``. - int fmpz_mod_poly_randtest_trinomial_irreducible(fmpz_mod_poly_t poly, flint_rand_t state, slong len, slong max_attempts, const fmpz_mod_ctx_t ctx) noexcept - # Attempts to set ``poly`` to a monic irreducible trinomial of - # length ``len``. It will generate up to ``max_attempts`` - # trinomials in attempt to find an irreducible one. If - # ``max_attempts`` is ``0``, then it will keep generating - # trinomials until an irreducible one is found. Returns `1` if one - # is found and `0` otherwise. - void fmpz_mod_poly_randtest_pentomial(fmpz_mod_poly_t poly, flint_rand_t state, slong len, const fmpz_mod_ctx_t ctx) noexcept - # Generates a random monic pentomial of length ``len``. - int fmpz_mod_poly_randtest_pentomial_irreducible(fmpz_mod_poly_t poly, flint_rand_t state, slong len, slong max_attempts, const fmpz_mod_ctx_t ctx) noexcept - # Attempts to set ``poly`` to a monic irreducible pentomial of - # length ``len``. It will generate up to ``max_attempts`` - # pentomials in attempt to find an irreducible one. If - # ``max_attempts`` is ``0``, then it will keep generating - # pentomials until an irreducible one is found. Returns `1` if one - # is found and `0` otherwise. - void fmpz_mod_poly_randtest_sparse_irreducible(fmpz_mod_poly_t poly, flint_rand_t state, slong len, const fmpz_mod_ctx_t ctx) noexcept - # Attempts to set ``poly`` to a sparse, monic irreducible polynomial - # with length ``len``. It attempts to find an irreducible - # trinomial. If that does not succeed, it attempts to find a - # irreducible pentomial. If that fails, then ``poly`` is just - # set to a random monic irreducible polynomial. - slong fmpz_mod_poly_degree(const fmpz_mod_poly_t poly, const fmpz_mod_ctx_t ctx) noexcept - # Returns the degree of the polynomial. The degree of the zero - # polynomial is defined to be `-1`. - slong fmpz_mod_poly_length(const fmpz_mod_poly_t poly, const fmpz_mod_ctx_t ctx) noexcept - # Returns the length of the polynomial, which is one more than - # its degree. - fmpz * fmpz_mod_poly_lead(const fmpz_mod_poly_t poly, const fmpz_mod_ctx_t ctx) noexcept - # Returns a pointer to the first leading coefficient of ``poly`` - # if this is non-zero, otherwise returns ``NULL``. - void fmpz_mod_poly_set(fmpz_mod_poly_t poly1, const fmpz_mod_poly_t poly2, const fmpz_mod_ctx_t ctx) noexcept - # Sets the polynomial ``poly1`` to the value of ``poly2``. - void fmpz_mod_poly_swap(fmpz_mod_poly_t poly1, fmpz_mod_poly_t poly2, const fmpz_mod_ctx_t ctx) noexcept - # Swaps the two polynomials. This is done efficiently by swapping - # pointers rather than individual coefficients. - void fmpz_mod_poly_zero(fmpz_mod_poly_t poly, const fmpz_mod_ctx_t ctx) noexcept - # Sets ``poly`` to the zero polynomial. - void fmpz_mod_poly_one(fmpz_mod_poly_t poly, const fmpz_mod_ctx_t ctx) noexcept - # Sets ``poly`` to the constant polynomial `1`. - void fmpz_mod_poly_zero_coeffs(fmpz_mod_poly_t poly, slong i, slong j, const fmpz_mod_ctx_t ctx) noexcept - # Sets the coefficients of `X^k` for `k \in [i, j)` in the polynomial - # to zero. - void fmpz_mod_poly_reverse(fmpz_mod_poly_t res, const fmpz_mod_poly_t poly, slong n, const fmpz_mod_ctx_t ctx) noexcept - # This function considers the polynomial ``poly`` to be of length `n`, - # notionally truncating and zero padding if required, and reverses - # the result. Since the function normalises its result ``res`` may be - # of length less than `n`. - void fmpz_mod_poly_set_ui(fmpz_mod_poly_t f, ulong c, const fmpz_mod_ctx_t ctx) noexcept - # Sets the polynomial `f` to the constant `c` reduced modulo `p`. - void fmpz_mod_poly_set_fmpz(fmpz_mod_poly_t f, const fmpz_t c, const fmpz_mod_ctx_t ctx) noexcept - # Sets the polynomial `f` to the constant `c` reduced modulo `p`. - void fmpz_mod_poly_set_fmpz_poly(fmpz_mod_poly_t f, const fmpz_poly_t g, const fmpz_mod_ctx_t ctx) noexcept - # Sets `f` to `g` reduced modulo `p`, where `p` is the modulus that - # is part of the data structure of `f`. - void fmpz_mod_poly_get_fmpz_poly(fmpz_poly_t f, const fmpz_mod_poly_t g, const fmpz_mod_ctx_t ctx) noexcept - # Sets `f` to `g`. This is done simply by lifting the coefficients - # of `g` taking representatives `[0, p) \subset \mathbf{Z}`. - void fmpz_mod_poly_get_nmod_poly(nmod_poly_t f, const fmpz_mod_poly_t g) noexcept - void fmpz_mod_poly_set_nmod_poly(fmpz_mod_poly_t f, const nmod_poly_t g) noexcept - bint fmpz_mod_poly_equal(const fmpz_mod_poly_t poly1, const fmpz_mod_poly_t poly2, const fmpz_mod_ctx_t ctx) noexcept - # Returns non-zero if the two polynomials are equal, otherwise returns zero. - bint fmpz_mod_poly_equal_trunc(const fmpz_mod_poly_t poly1, const fmpz_mod_poly_t poly2, slong n, const fmpz_mod_ctx_t ctx) noexcept - # Notionally truncates the two polynomials to length `n` and returns non-zero - # if the two polynomials are equal, otherwise returns zero. - bint fmpz_mod_poly_is_zero(const fmpz_mod_poly_t poly, const fmpz_mod_ctx_t ctx) noexcept - # Returns non-zero if the polynomial is zero. - bint fmpz_mod_poly_is_one(const fmpz_mod_poly_t poly, const fmpz_mod_ctx_t ctx) noexcept - # Returns non-zero if the polynomial is the constant `1`. - bint fmpz_mod_poly_is_gen(const fmpz_mod_poly_t poly, const fmpz_mod_ctx_t ctx) noexcept - # Returns non-zero if the polynomial is the degree `1` polynomial `x`. - void fmpz_mod_poly_set_coeff_fmpz(fmpz_mod_poly_t poly, slong n, const fmpz_t x, const fmpz_mod_ctx_t ctx) noexcept - # Sets the coefficient of `X^n` in the polynomial to `x`, - # assuming `n \geq 0`. - void fmpz_mod_poly_set_coeff_ui(fmpz_mod_poly_t poly, slong n, ulong x, const fmpz_mod_ctx_t ctx) noexcept - # Sets the coefficient of `X^n` in the polynomial to `x`, - # assuming `n \geq 0`. - void fmpz_mod_poly_get_coeff_fmpz(fmpz_t x, const fmpz_mod_poly_t poly, slong n, const fmpz_mod_ctx_t ctx) noexcept - # Sets `x` to the coefficient of `X^n` in the polynomial, - # assuming `n \geq 0`. - void fmpz_mod_poly_set_coeff_mpz(fmpz_mod_poly_t poly, slong n, const mpz_t x, const fmpz_mod_ctx_t ctx) noexcept - # Sets the coefficient of `X^n` in the polynomial to `x`, - # assuming `n \geq 0`. - void fmpz_mod_poly_get_coeff_mpz(mpz_t x, const fmpz_mod_poly_t poly, slong n, const fmpz_mod_ctx_t ctx) noexcept - # Sets `x` to the coefficient of `X^n` in the polynomial, - # assuming `n \geq 0`. - void _fmpz_mod_poly_shift_left(fmpz * res, const fmpz * poly, slong len, slong n) noexcept - # Sets ``(res, len + n)`` to ``(poly, len)`` shifted left by - # `n` coefficients. - # Inserts zero coefficients at the lower end. Assumes that ``len`` - # and `n` are positive, and that ``res`` fits ``len + n`` elements. - # Supports aliasing between ``res`` and ``poly``. - void fmpz_mod_poly_shift_left(fmpz_mod_poly_t f, const fmpz_mod_poly_t g, slong n, const fmpz_mod_ctx_t ctx) noexcept - # Sets ``res`` to ``poly`` shifted left by `n` coeffs. Zero - # coefficients are inserted. - void _fmpz_mod_poly_shift_right(fmpz * res, const fmpz * poly, slong len, slong n) noexcept - # Sets ``(res, len - n)`` to ``(poly, len)`` shifted right by - # `n` coefficients. - # Assumes that ``len`` and `n` are positive, that ``len > n``, - # and that ``res`` fits ``len - n`` elements. Supports aliasing - # between ``res`` and ``poly``, although in this case the top - # coefficients of ``poly`` are not set to zero. - void fmpz_mod_poly_shift_right(fmpz_mod_poly_t f, const fmpz_mod_poly_t g, slong n, const fmpz_mod_ctx_t ctx) noexcept - # Sets ``res`` to ``poly`` shifted right by `n` coefficients. If `n` - # is equal to or greater than the current length of ``poly``, ``res`` - # is set to the zero polynomial. - - void _fmpz_mod_poly_add(fmpz *res, const fmpz *poly1, slong len1, const fmpz *poly2, slong len2, const fmpz_mod_ctx_t ctx) noexcept - # Sets ``res`` to the sum of ``(poly1, len1)`` and - # ``(poly2, len2)``. It is assumed that ``res`` has - # sufficient space for the longer of the two polynomials. - + void _fmpz_mod_poly_add(fmpz * res, const fmpz * poly1, slong len1, const fmpz * poly2, slong len2, const fmpz_mod_ctx_t ctx) noexcept void fmpz_mod_poly_add(fmpz_mod_poly_t res, const fmpz_mod_poly_t poly1, const fmpz_mod_poly_t poly2, const fmpz_mod_ctx_t ctx) noexcept - # Sets ``res`` to the sum of ``poly1`` and ``poly2``. - void fmpz_mod_poly_add_series(fmpz_mod_poly_t res, const fmpz_mod_poly_t poly1, const fmpz_mod_poly_t poly2, slong n, const fmpz_mod_ctx_t ctx) noexcept - # Notionally truncate ``poly1`` and ``poly2`` to length `n` and set - # ``res`` to the sum. - - void _fmpz_mod_poly_sub(fmpz *res, const fmpz *poly1, slong len1, const fmpz *poly2, slong len2, const fmpz_mod_ctx_t ctx) noexcept - # Sets ``res`` to ``(poly1, len1)`` minus ``(poly2, len2)``. It - # is assumed that ``res`` has sufficient space for the longer of the - # two polynomials. - + void _fmpz_mod_poly_sub(fmpz * res, const fmpz * poly1, slong len1, const fmpz * poly2, slong len2, const fmpz_mod_ctx_t ctx) noexcept void fmpz_mod_poly_sub(fmpz_mod_poly_t res, const fmpz_mod_poly_t poly1, const fmpz_mod_poly_t poly2, const fmpz_mod_ctx_t ctx) noexcept - # Sets ``res`` to ``poly1`` minus ``poly2``. - void fmpz_mod_poly_sub_series(fmpz_mod_poly_t res, const fmpz_mod_poly_t poly1, const fmpz_mod_poly_t poly2, slong n, const fmpz_mod_ctx_t ctx) noexcept - # Notionally truncate ``poly1`` and ``poly2`` to length `n` and set - # ``res`` to the difference. - - void _fmpz_mod_poly_neg(fmpz *res, const fmpz *poly, slong len, const fmpz_mod_ctx_t ctx) noexcept - # Sets ``(res, len)`` to the negative of ``(poly, len)`` - # modulo `p`. - + void _fmpz_mod_poly_neg(fmpz * res, const fmpz * poly, slong len, const fmpz_mod_ctx_t ctx) noexcept void fmpz_mod_poly_neg(fmpz_mod_poly_t res, const fmpz_mod_poly_t poly, const fmpz_mod_ctx_t ctx) noexcept - # Sets ``res`` to the negative of ``poly`` modulo `p`. - - void _fmpz_mod_poly_scalar_mul_fmpz(fmpz *res, const fmpz *poly, slong len, const fmpz_t x, const fmpz_mod_ctx_t ctx) noexcept - # Sets ``(res, len``) to ``(poly, len)`` multiplied by `x`, - # reduced modulo `p`. - + void _fmpz_mod_poly_scalar_mul_fmpz(fmpz * res, const fmpz * poly, slong len, const fmpz_t x, const fmpz_mod_ctx_t ctx) noexcept void fmpz_mod_poly_scalar_mul_fmpz(fmpz_mod_poly_t res, const fmpz_mod_poly_t poly, const fmpz_t x, const fmpz_mod_ctx_t ctx) noexcept - # Sets ``res`` to ``poly`` multiplied by `x`. - void fmpz_mod_poly_scalar_addmul_fmpz(fmpz_mod_poly_t rop, const fmpz_mod_poly_t op, const fmpz_t x, const fmpz_mod_ctx_t ctx) noexcept - # Adds to ``rop`` the product of ``op`` by the scalar ``x``. - - void _fmpz_mod_poly_scalar_div_fmpz(fmpz *res, const fmpz *poly, slong len, const fmpz_t x, const fmpz_mod_ctx_t ctx) noexcept - # Sets ``(res, len``) to ``(poly, len)`` divided by `x` (i.e. - # multiplied by the inverse of `x \pmod{p}`). The result is reduced modulo - # `p`. - + void _fmpz_mod_poly_scalar_div_fmpz(fmpz * res, const fmpz * poly, slong len, const fmpz_t x, const fmpz_mod_ctx_t ctx) noexcept void fmpz_mod_poly_scalar_div_fmpz(fmpz_mod_poly_t res, const fmpz_mod_poly_t poly, const fmpz_t x, const fmpz_mod_ctx_t ctx) noexcept - # Sets ``res`` to ``poly`` divided by `x`, (i.e. multiplied by the - # inverse of `x \pmod{p}`). The result is reduced modulo `p`. - - void _fmpz_mod_poly_mul(fmpz *res, const fmpz *poly1, slong len1, const fmpz *poly2, slong len2, const fmpz_mod_ctx_t ctx) noexcept - # Sets ``(res, len1 + len2 - 1)`` to the product of ``(poly1, len1)`` - # and ``(poly2, len2)``. Assumes ``len1 >= len2 > 0``. Allows - # zero-padding of the two input polynomials. - + void _fmpz_mod_poly_mul(fmpz * res, const fmpz * poly1, slong len1, const fmpz * poly2, slong len2, const fmpz_mod_ctx_t ctx) noexcept void fmpz_mod_poly_mul(fmpz_mod_poly_t res, const fmpz_mod_poly_t poly1, const fmpz_mod_poly_t poly2, const fmpz_mod_ctx_t ctx) noexcept - # Sets ``res`` to the product of ``poly1`` and ``poly2``. - - void _fmpz_mod_poly_mullow(fmpz *res, const fmpz *poly1, slong len1, const fmpz *poly2, slong len2, slong n, const fmpz_mod_ctx_t ctx) noexcept - # Sets ``(res, n)`` to the lowest `n` coefficients of the product of - # ``(poly1, len1)`` and ``(poly2, len2)``. - # Assumes ``len1 >= len2 > 0`` and ``0 < n <= len1 + len2 - 1``. - # Allows for zero-padding in the inputs. Does not support aliasing between - # the inputs and the output. - + void _fmpz_mod_poly_mullow(fmpz * res, const fmpz * poly1, slong len1, const fmpz * poly2, slong len2, slong n, const fmpz_mod_ctx_t ctx) noexcept void fmpz_mod_poly_mullow(fmpz_mod_poly_t res, const fmpz_mod_poly_t poly1, const fmpz_mod_poly_t poly2, slong n, const fmpz_mod_ctx_t ctx) noexcept - # Sets ``res`` to the lowest `n` coefficients of the product of - # ``poly1`` and ``poly2``. - - void _fmpz_mod_poly_sqr(fmpz *res, const fmpz *poly, slong len, const fmpz_mod_ctx_t ctx) noexcept - # Sets ``res`` to the square of ``poly``. - + void _fmpz_mod_poly_sqr(fmpz * res, const fmpz * poly, slong len, const fmpz_mod_ctx_t ctx) noexcept void fmpz_mod_poly_sqr(fmpz_mod_poly_t res, const fmpz_mod_poly_t poly, const fmpz_mod_ctx_t ctx) noexcept - # Computes ``res`` as the square of ``poly``. - void fmpz_mod_poly_mulhigh(fmpz_mod_poly_t res, const fmpz_mod_poly_t poly1, const fmpz_mod_poly_t poly2, slong start, const fmpz_mod_ctx_t ctx) noexcept - # Computes the product of ``poly1`` and ``poly2`` and writes the - # coefficients from ``start`` onwards into the high coefficients of - # ``res``, the remaining coefficients being arbitrary. - void _fmpz_mod_poly_mulmod(fmpz * res, const fmpz * poly1, slong len1, const fmpz * poly2, slong len2, const fmpz * f, slong lenf, const fmpz_mod_ctx_t ctx) noexcept - # Sets ``res, len1 + len2 - 1`` to the remainder of the product of - # ``poly1`` and ``poly2`` upon polynomial division by ``f``. - # It is required that ``len1 + len2 - lenf > 0``, which is equivalent - # to requiring that the result will actually be reduced. Otherwise, simply - # use ``_fmpz_mod_poly_mul`` instead. - # Aliasing of ``f`` and ``res`` is not permitted. - void fmpz_mod_poly_mulmod(fmpz_mod_poly_t res, const fmpz_mod_poly_t poly1, const fmpz_mod_poly_t poly2, const fmpz_mod_poly_t f, const fmpz_mod_ctx_t ctx) noexcept - # Sets ``res`` to the remainder of the product of ``poly1`` and - # ``poly2`` upon polynomial division by ``f``. - - void _fmpz_mod_poly_mulmod_preinv(fmpz * res, const fmpz * poly1, slong len1, const fmpz * poly2, slong len2, const fmpz * f, slong lenf, const fmpz* finv, slong lenfinv, const fmpz_mod_ctx_t ctx) noexcept - # Sets ``res, len1 + len2 - 1`` to the remainder of the product of - # ``poly1`` and ``poly2`` upon polynomial division by ``f``. - # It is required that ``finv`` is the inverse of the reverse of ``f`` - # mod ``x^lenf``. It is required that ``len1 + len2 - lenf > 0``, - # which is equivalent to requiring that the result will actually be reduced. - # It is required that ``len1 < lenf`` and ``len2 < lenf``. - # Otherwise, simply use ``_fmpz_mod_poly_mul`` instead. - # Aliasing of ``f`` or ``finv`` and ``res`` is not permitted. - + void _fmpz_mod_poly_mulmod_preinv(fmpz * res, const fmpz * poly1, slong len1, const fmpz * poly2, slong len2, const fmpz * f, slong lenf, const fmpz * finv, slong lenfinv, const fmpz_mod_ctx_t ctx) noexcept void fmpz_mod_poly_mulmod_preinv(fmpz_mod_poly_t res, const fmpz_mod_poly_t poly1, const fmpz_mod_poly_t poly2, const fmpz_mod_poly_t f, const fmpz_mod_poly_t finv, const fmpz_mod_ctx_t ctx) noexcept - # Sets ``res`` to the remainder of the product of ``poly1`` and - # ``poly2`` upon polynomial division by ``f``. ``finv`` is the - # inverse of the reverse of ``f``. It is required that ``poly1`` and - # ``poly2`` are reduced modulo ``f``. - void _fmpz_mod_poly_product_roots_fmpz_vec(fmpz * poly, const fmpz * xs, slong n, const fmpz_mod_ctx_t ctx) noexcept - # Sets ``(poly, n + 1)`` to the monic polynomial which is the product - # of `(x - x_0)(x - x_1) \cdots (x - x_{n-1})`, the roots `x_i` being - # given by ``xs``. It is required that the roots are canonical. - # Aliasing of the input and output is not allowed. - void fmpz_mod_poly_product_roots_fmpz_vec(fmpz_mod_poly_t poly, const fmpz * xs, slong n, const fmpz_mod_ctx_t ctx) noexcept - # Sets ``poly`` to the monic polynomial which is the product - # of `(x - x_0)(x - x_1) \cdots (x - x_{n-1})`, the roots `x_i` being - # given by ``xs``. It is required that the roots are canonical. - int fmpz_mod_poly_find_distinct_nonzero_roots(fmpz * roots, const fmpz_mod_poly_t A, const fmpz_mod_ctx_t ctx) noexcept - # If ``A`` has `\deg(A)` distinct nonzero roots in `\mathbb{F}_p`, write these roots out to ``roots[0]`` to ``roots[deg(A) - 1]`` and return ``1``. - # Otherwise, return ``0``. It is assumed that ``A`` is nonzero and that the modulus of ``A`` is prime. - # This function uses Rabin's probabilistic method via gcd's with `(x + \delta)^{\frac{p-1}{2}} - 1`. - - void _fmpz_mod_poly_pow(fmpz *rop, const fmpz *op, slong len, ulong e, const fmpz_mod_ctx_t ctx) noexcept - # Sets ``rop = poly^e``, assuming that `e > 1` and ``elen > 0``, - # and that ``res`` has space for ``e*(len - 1) + 1`` coefficients. - # Does not support aliasing. - + void _fmpz_mod_poly_pow(fmpz * rop, const fmpz * op, slong len, ulong e, const fmpz_mod_ctx_t ctx) noexcept void fmpz_mod_poly_pow(fmpz_mod_poly_t rop, const fmpz_mod_poly_t op, ulong e, const fmpz_mod_ctx_t ctx) noexcept - # Computes ``rop = poly^e``. If `e` is zero, returns one, - # so that in particular ``0^0 = 1``. - void _fmpz_mod_poly_pow_trunc(fmpz * res, const fmpz * poly, ulong e, slong trunc, const fmpz_mod_ctx_t ctx) noexcept - # Sets ``res`` to the low ``trunc`` coefficients of ``poly`` - # (assumed to be zero padded if necessary to length ``trunc``) to - # the power ``e``. This is equivalent to doing a powering followed - # by a truncation. We require that ``res`` has enough space for - # ``trunc`` coefficients, that ``trunc > 0`` and that - # ``e > 1``. Aliasing is not permitted. - void fmpz_mod_poly_pow_trunc(fmpz_mod_poly_t res, const fmpz_mod_poly_t poly, ulong e, slong trunc, const fmpz_mod_ctx_t ctx) noexcept - # Sets ``res`` to the low ``trunc`` coefficients of ``poly`` - # to the power ``e``. This is equivalent to doing a powering - # followed by a truncation. - void _fmpz_mod_poly_pow_trunc_binexp(fmpz * res, const fmpz * poly, ulong e, slong trunc, const fmpz_mod_ctx_t ctx) noexcept - # Sets ``res`` to the low ``trunc`` coefficients of ``poly`` - # (assumed to be zero padded if necessary to length ``trunc``) to - # the power ``e``. This is equivalent to doing a powering followed - # by a truncation. We require that ``res`` has enough space for - # ``trunc`` coefficients, that ``trunc > 0`` and that - # ``e > 1``. Aliasing is not permitted. Uses the binary - # exponentiation method. - void fmpz_mod_poly_pow_trunc_binexp(fmpz_mod_poly_t res, const fmpz_mod_poly_t poly, ulong e, slong trunc, const fmpz_mod_ctx_t ctx) noexcept - # Sets ``res`` to the low ``trunc`` coefficients of ``poly`` - # to the power ``e``. This is equivalent to doing a powering - # followed by a truncation. Uses the binary exponentiation method. - void _fmpz_mod_poly_powmod_ui_binexp(fmpz * res, const fmpz * poly, ulong e, const fmpz * f, slong lenf, const fmpz_mod_ctx_t ctx) noexcept - # Sets ``res`` to ``poly`` raised to the power ``e`` - # modulo ``f``, using binary exponentiation. We require ``e > 0``. - # We require ``lenf > 1``. It is assumed that ``poly`` is already - # reduced modulo ``f`` and zero-padded as necessary to have length - # exactly ``lenf - 1``. The output ``res`` must have room for - # ``lenf - 1`` coefficients. - void fmpz_mod_poly_powmod_ui_binexp(fmpz_mod_poly_t res, const fmpz_mod_poly_t poly, ulong e, const fmpz_mod_poly_t f, const fmpz_mod_ctx_t ctx) noexcept - # Sets ``res`` to ``poly`` raised to the power ``e`` - # modulo ``f``, using binary exponentiation. We require ``e >= 0``. - void _fmpz_mod_poly_powmod_ui_binexp_preinv(fmpz * res, const fmpz * poly, ulong e, const fmpz * f, slong lenf, const fmpz * finv, slong lenfinv, const fmpz_mod_ctx_t ctx) noexcept - # Sets ``res`` to ``poly`` raised to the power ``e`` - # modulo ``f``, using binary exponentiation. We require ``e > 0``. - # We require ``finv`` to be the inverse of the reverse of ``f``. - # We require ``lenf > 1``. It is assumed that ``poly`` is already - # reduced modulo ``f`` and zero-padded as necessary to have length - # exactly ``lenf - 1``. The output ``res`` must have room for - # ``lenf - 1`` coefficients. - void fmpz_mod_poly_powmod_ui_binexp_preinv(fmpz_mod_poly_t res, const fmpz_mod_poly_t poly, ulong e, const fmpz_mod_poly_t f, const fmpz_mod_poly_t finv, const fmpz_mod_ctx_t ctx) noexcept - # Sets ``res`` to ``poly`` raised to the power ``e`` - # modulo ``f``, using binary exponentiation. We require ``e >= 0``. - # We require ``finv`` to be the inverse of the reverse of ``f``. - void _fmpz_mod_poly_powmod_fmpz_binexp(fmpz * res, const fmpz * poly, const fmpz_t e, const fmpz * f, slong lenf, const fmpz_mod_ctx_t ctx) noexcept - # Sets ``res`` to ``poly`` raised to the power ``e`` - # modulo ``f``, using binary exponentiation. We require ``e > 0``. - # We require ``lenf > 1``. It is assumed that ``poly`` is already - # reduced modulo ``f`` and zero-padded as necessary to have length - # exactly ``lenf - 1``. The output ``res`` must have room for - # ``lenf - 1`` coefficients. - void fmpz_mod_poly_powmod_fmpz_binexp(fmpz_mod_poly_t res, const fmpz_mod_poly_t poly, const fmpz_t e, const fmpz_mod_poly_t f, const fmpz_mod_ctx_t ctx) noexcept - # Sets ``res`` to ``poly`` raised to the power ``e`` - # modulo ``f``, using binary exponentiation. We require ``e >= 0``. - - void _fmpz_mod_poly_powmod_fmpz_binexp_preinv(fmpz * res, const fmpz * poly, const fmpz_t e, const fmpz * f, slong lenf, const fmpz* finv, slong lenfinv, const fmpz_mod_ctx_t ctx) noexcept - # Sets ``res`` to ``poly`` raised to the power ``e`` - # modulo ``f``, using binary exponentiation. We require ``e > 0``. - # We require ``finv`` to be the inverse of the reverse of ``f``. - # We require ``lenf > 1``. It is assumed that ``poly`` is already - # reduced modulo ``f`` and zero-padded as necessary to have length - # exactly ``lenf - 1``. The output ``res`` must have room for - # ``lenf - 1`` coefficients. - + void _fmpz_mod_poly_powmod_fmpz_binexp_preinv(fmpz * res, const fmpz * poly, const fmpz_t e, const fmpz * f, slong lenf, const fmpz * finv, slong lenfinv, const fmpz_mod_ctx_t ctx) noexcept void fmpz_mod_poly_powmod_fmpz_binexp_preinv(fmpz_mod_poly_t res, const fmpz_mod_poly_t poly, const fmpz_t e, const fmpz_mod_poly_t f, const fmpz_mod_poly_t finv, const fmpz_mod_ctx_t ctx) noexcept - # Sets ``res`` to ``poly`` raised to the power ``e`` - # modulo ``f``, using binary exponentiation. We require ``e >= 0``. - # We require ``finv`` to be the inverse of the reverse of ``f``. - - void _fmpz_mod_poly_powmod_x_fmpz_preinv(fmpz * res, const fmpz_t e, const fmpz * f, slong lenf, const fmpz* finv, slong lenfinv, const fmpz_mod_ctx_t ctx) noexcept - # Sets ``res`` to ``x`` raised to the power ``e`` modulo ``f``, - # using sliding window exponentiation. We require ``e > 0``. - # We require ``finv`` to be the inverse of the reverse of ``f``. - # We require ``lenf > 2``. The output ``res`` must have room for - # ``lenf - 1`` coefficients. - + void _fmpz_mod_poly_powmod_x_fmpz_preinv(fmpz * res, const fmpz_t e, const fmpz * f, slong lenf, const fmpz * finv, slong lenfinv, const fmpz_mod_ctx_t ctx) noexcept void fmpz_mod_poly_powmod_x_fmpz_preinv(fmpz_mod_poly_t res, const fmpz_t e, const fmpz_mod_poly_t f, const fmpz_mod_poly_t finv, const fmpz_mod_ctx_t ctx) noexcept - # Sets ``res`` to ``x`` raised to the power ``e`` - # modulo ``f``, using sliding window exponentiation. We require - # ``e >= 0``. We require ``finv`` to be the inverse of the reverse of - # `` - void _fmpz_mod_poly_powers_mod_preinv_naive(fmpz ** res, const fmpz * f, slong flen, slong n, const fmpz * g, slong glen, const fmpz * ginv, slong ginvlen, const fmpz_mod_ctx_t ctx) noexcept - # Compute ``f^0, f^1, ..., f^(n-1) mod g``, where ``g`` has length ``glen`` - # and ``f`` is reduced mod ``g`` and has length ``flen`` (possibly zero - # spaced). Assumes ``res`` is an array of ``n`` arrays each with space for - # at least ``glen - 1`` coefficients and that ``flen > 0``. We require that - # ``ginv`` of length ``ginvlen`` is set to the power series inverse of the - # reverse of ``g``. - void fmpz_mod_poly_powers_mod_naive(fmpz_mod_poly_struct * res, const fmpz_mod_poly_t f, slong n, const fmpz_mod_poly_t g, const fmpz_mod_ctx_t ctx) noexcept - # Set the entries of the array ``res`` to ``f^0, f^1, ..., f^(n-1) mod g``. - # No aliasing is permitted between the entries of ``res`` and either of the - # inputs. - void _fmpz_mod_poly_powers_mod_preinv_threaded_pool(fmpz ** res, const fmpz * f, slong flen, slong n, const fmpz * g, slong glen, const fmpz * ginv, slong ginvlen, const fmpz_mod_ctx_t p, thread_pool_handle * threads, slong num_threads) noexcept - # Compute ``f^0, f^1, ..., f^(n-1) mod g``, where ``g`` has length ``glen`` - # and ``f`` is reduced mod ``g`` and has length ``flen`` (possibly zero - # spaced). Assumes ``res`` is an array of ``n`` arrays each with space for - # at least ``glen - 1`` coefficients and that ``flen > 0``. We require that - # ``ginv`` of length ``ginvlen`` is set to the power series inverse of the - # reverse of ``g``. - void fmpz_mod_poly_powers_mod_bsgs(fmpz_mod_poly_struct * res, const fmpz_mod_poly_t f, slong n, const fmpz_mod_poly_t g, const fmpz_mod_ctx_t ctx) noexcept - # Set the entries of the array ``res`` to ``f^0, f^1, ..., f^(n-1) mod g``. - # No aliasing is permitted between the entries of ``res`` and either of the - # inputs. - void fmpz_mod_poly_frobenius_powers_2exp_precomp(fmpz_mod_poly_frobenius_powers_2exp_t pow, const fmpz_mod_poly_t f, const fmpz_mod_poly_t finv, ulong m, const fmpz_mod_ctx_t ctx) noexcept - # If ``p = f->p``, compute `x^{(p^1)}`, `x^{(p^2)}`, `x^{(p^4)}`, ..., - # `x^{(p^{(2^l)})} \pmod{f}` where `2^l` is the greatest power of `2` less than - # or equal to `m`. - # Allows construction of `x^{(p^k)}` for `k = 0`, `1`, ..., `x^{(p^m)} \pmod{f}` - # using :func:`fmpz_mod_poly_frobenius_power`. - # Requires precomputed inverse of `f`, i.e. newton inverse. - void fmpz_mod_poly_frobenius_powers_2exp_clear(fmpz_mod_poly_frobenius_powers_2exp_t pow, const fmpz_mod_ctx_t ctx) noexcept - # Clear resources used by the ``fmpz_mod_poly_frobenius_powers_2exp_t`` - # struct. - void fmpz_mod_poly_frobenius_power(fmpz_mod_poly_t res, fmpz_mod_poly_frobenius_powers_2exp_t pow, const fmpz_mod_poly_t f, ulong m, const fmpz_mod_ctx_t ctx) noexcept - # If ``p = f->p``, compute `x^{(p^m)} \pmod{f}`. - # Requires precomputed frobenius powers supplied by - # ``fmpz_mod_poly_frobenius_powers_2exp_precomp``. - # If `m == 0` and `f` has degree `0` or `1`, this performs a division. - # However an impossible inverse by the leading coefficient of `f` will have - # been caught by ``fmpz_mod_poly_frobenius_powers_2exp_precomp``. - void fmpz_mod_poly_frobenius_powers_precomp(fmpz_mod_poly_frobenius_powers_t pow, const fmpz_mod_poly_t f, const fmpz_mod_poly_t finv, ulong m, const fmpz_mod_ctx_t ctx) noexcept - # If ``p = f->p``, compute `x^{(p^0)}`, `x^{(p^1)}`, `x^{(p^2)}`, `x^{(p^3)}`, - # ..., `x^{(p^m)} \pmod{f}`. - # Requires precomputed inverse of `f`, i.e. newton inverse. - void fmpz_mod_poly_frobenius_powers_clear(fmpz_mod_poly_frobenius_powers_t pow, const fmpz_mod_ctx_t ctx) noexcept - # Clear resources used by the ``fmpz_mod_poly_frobenius_powers_t`` - # struct. - void _fmpz_mod_poly_divrem_basecase(fmpz * Q, fmpz * R, const fmpz * A, slong lenA, const fmpz * B, slong lenB, const fmpz_t invB, const fmpz_mod_ctx_t ctx) noexcept - # Computes ``(Q, lenA - lenB + 1)``, ``(R, lenA)`` such that - # `A = B Q + R` with `0 \leq \operatorname{len}(R) < \operatorname{len}(B)`. - # Assumes that the leading coefficient of `B` is invertible - # modulo `p`, and that ``invB`` is the inverse. - # Assumes that `\operatorname{len}(A), \operatorname{len}(B) > 0`. Allows zero-padding in - # ``(A, lenA)``. `R` and `A` may be aliased, but apart from this no - # aliasing of input and output operands is allowed. - void fmpz_mod_poly_divrem_basecase(fmpz_mod_poly_t Q, fmpz_mod_poly_t R, const fmpz_mod_poly_t A, const fmpz_mod_poly_t B, const fmpz_mod_ctx_t ctx) noexcept - # Computes `Q`, `R` such that `A = B Q + R` with - # `0 \leq \operatorname{len}(R) < \operatorname{len}(B)`. - # Assumes that the leading coefficient of `B` is invertible - # modulo `p`. - - void _fmpz_mod_poly_divrem_newton_n_preinv (fmpz* Q, fmpz* R, const fmpz* A, slong lenA, const fmpz* B, slong lenB, const fmpz* Binv, slong lenBinv, const fmpz_mod_ctx_t ctx) noexcept - # Computes `Q` and `R` such that `A = BQ + R` with `\operatorname{len}(R)` less than - # ``lenB``, where `A` is of length ``lenA`` and `B` is of length - # ``lenB``. We require that `Q` have space for ``lenA - lenB + 1`` - # coefficients. Furthermore, we assume that `Binv` is the inverse of the - # reverse of `B` mod `x^{\operatorname{len}(B)}`. The algorithm used is to call - # :func:`div_newton_n_preinv` and then multiply out and compute - # the remainder. - + void _fmpz_mod_poly_divrem_newton_n_preinv (fmpz * Q, fmpz * R, const fmpz * A, slong lenA, const fmpz * B, slong lenB, const fmpz * Binv, slong lenBinv, const fmpz_mod_ctx_t ctx) noexcept void fmpz_mod_poly_divrem_newton_n_preinv(fmpz_mod_poly_t Q, fmpz_mod_poly_t R, const fmpz_mod_poly_t A, const fmpz_mod_poly_t B, const fmpz_mod_poly_t Binv, const fmpz_mod_ctx_t ctx) noexcept - # Computes `Q` and `R` such that `A = BQ + R` with `\operatorname{len}(R) < \operatorname{len}(B)`. - # We assume `Binv` is the inverse of the reverse of `B` mod `x^{\operatorname{len}(B)}`. - # It is required that the length of `A` is less than or equal to - # 2*the length of `B` - 2. - # The algorithm used is to call :func:`div_newton_n` and then multiply out - # and compute the remainder. - - void _fmpz_mod_poly_div_newton_n_preinv (fmpz* Q, const fmpz* A, slong lenA, const fmpz* B, slong lenB, const fmpz* Binv, slong lenBinv, const fmpz_mod_ctx_t ctx) noexcept - # Notionally computes polynomials `Q` and `R` such that `A = BQ + R` with - # `\operatorname{len}(R)` less than ``lenB``, where ``A`` is of length ``lenA`` - # and ``B`` is of length ``lenB``, but return only `Q`. - # We require that `Q` have space for ``lenA - lenB + 1`` coefficients - # and assume that the leading coefficient of `B` is a unit. Furthermore, we - # assume that `Binv` is the inverse of the reverse of `B` mod `x^{\operatorname{len}(B)}`. - # The algorithm used is to reverse the polynomials and divide the - # resulting power series, then reverse the result. - + void _fmpz_mod_poly_div_newton_n_preinv (fmpz * Q, const fmpz * A, slong lenA, const fmpz * B, slong lenB, const fmpz * Binv, slong lenBinv, const fmpz_mod_ctx_t ctx) noexcept void fmpz_mod_poly_div_newton_n_preinv(fmpz_mod_poly_t Q, const fmpz_mod_poly_t A, const fmpz_mod_poly_t B, const fmpz_mod_poly_t Binv, const fmpz_mod_ctx_t ctx) noexcept - # Notionally computes `Q` and `R` such that `A = BQ + R` with - # `\operatorname{len}(R) < \operatorname{len}(B)`, but returns only `Q`. - # We assume that the leading coefficient of `B` is a unit and that `Binv` is - # the inverse of the reverse of `B` mod `x^{\operatorname{len}(B)}`. - # It is required that the length of `A` is less than or equal to - # 2*the length of `B` - 2. - # The algorithm used is to reverse the polynomials and divide the - # resulting power series, then reverse the result. - ulong fmpz_mod_poly_remove(fmpz_mod_poly_t f, const fmpz_mod_poly_t g, const fmpz_mod_ctx_t ctx) noexcept - # Removes the highest possible power of ``g`` from ``f`` and - # returns the exponent. - void _fmpz_mod_poly_rem_basecase(fmpz * R, const fmpz * A, slong lenA, const fmpz * B, slong lenB, const fmpz_t invB, const fmpz_mod_ctx_t ctx) noexcept - # Notationally, computes `Q`, `R` such that `A = B Q + R` with - # `0 \leq \operatorname{len}(R) < \operatorname{len}(B)` but only sets ``(R, lenB - 1)``. - # Allows aliasing only between `A` and `R`. Allows zero-padding - # in `A` but not in `B`. Assumes that the leading coefficient - # of `B` is a unit modulo `p`. - void fmpz_mod_poly_rem_basecase(fmpz_mod_poly_t R, const fmpz_mod_poly_t A, const fmpz_mod_poly_t B, const fmpz_mod_ctx_t ctx) noexcept - # Notationally, computes `Q`, `R` such that `A = B Q + R` with - # `0 \leq \operatorname{len}(R) < \operatorname{len}(B)` assuming that the leading term - # of `B` is a unit. - void _fmpz_mod_poly_div(fmpz * Q, const fmpz * A, slong lenA, const fmpz * B, slong lenB, const fmpz_t invB, const fmpz_mod_ctx_t ctx) noexcept - # Notationally, computes `Q`, `R` such that `A = B Q + R` with - # `0 \leq \operatorname{len}(R) < \operatorname{len}(B)` but only sets ``(Q, lenA - lenB + 1)``. - # Assumes that the leading coefficient of `B` is a unit modulo `p`. - void fmpz_mod_poly_div(fmpz_mod_poly_t Q, const fmpz_mod_poly_t A, const fmpz_mod_poly_t B, const fmpz_mod_ctx_t ctx) noexcept - # Notationally, computes `Q`, `R` such that `A = B Q + R` with - # `0 \leq \operatorname{len}(R) < \operatorname{len}(B)` assuming that the leading term - # of `B` is a unit. - void _fmpz_mod_poly_divrem(fmpz * Q, fmpz * R, const fmpz * A, slong lenA, const fmpz * B, slong lenB, const fmpz_t invB, const fmpz_mod_ctx_t ctx) noexcept - # Computes ``(Q, lenA - lenB + 1)``, ``(R, lenB - 1)`` such that - # `A = B Q + R` and `0 \leq \operatorname{len}(R) < \operatorname{len}(B)`. - # Assumes that `B` is non-zero, that the leading coefficient - # of `B` is invertible modulo `p` and that ``invB`` is - # the inverse. - # Assumes `\operatorname{len}(A) \geq \operatorname{len}(B) > 0`. Allows zero-padding in - # ``(A, lenA)``. No aliasing of input and output operands is - # allowed. - void fmpz_mod_poly_divrem(fmpz_mod_poly_t Q, fmpz_mod_poly_t R, const fmpz_mod_poly_t A, const fmpz_mod_poly_t B, const fmpz_mod_ctx_t ctx) noexcept - # Computes `Q`, `R` such that `A = B Q + R` and - # `0 \leq \operatorname{len}(R) < \operatorname{len}(B)`. - # Assumes that `B` is non-zero and that the leading coefficient - # of `B` is invertible modulo `p`. - void fmpz_mod_poly_divrem_f(fmpz_t f, fmpz_mod_poly_t Q, fmpz_mod_poly_t R, const fmpz_mod_poly_t A, const fmpz_mod_poly_t B, const fmpz_mod_ctx_t ctx) noexcept - # Either finds a non-trivial factor~`f` of the modulus~`p`, or computes - # `Q`, `R` such that `A = B Q + R` and `0 \leq \operatorname{len}(R) < \operatorname{len}(B)`. - # If the leading coefficient of `B` is invertible in `\mathbf{Z}/(p)`, - # the division with remainder operation is carried out, `Q` and `R` are - # computed correctly, and `f` is set to `1`. Otherwise, `f` is set to - # a non-trivial factor of `p` and `Q` and `R` are not touched. - # Assumes that `B` is non-zero. - - void _fmpz_mod_poly_rem(fmpz *R, const fmpz *A, slong lenA, const fmpz *B, slong lenB, const fmpz_t invB, const fmpz_mod_ctx_t ctx) noexcept - # Notationally, computes ``(Q, lenA - lenB + 1)``, ``(R, lenB - 1)`` - # such that `A = B Q + R` and `0 \leq \operatorname{len}(R) < \operatorname{len}(B)`, returning - # only the remainder part. - # Assumes that `B` is non-zero, that the leading coefficient - # of `B` is invertible modulo `p` and that ``invB`` is - # the inverse. - # Assumes `\operatorname{len}(A) \geq \operatorname{len}(B) > 0`. Allows zero-padding in - # ``(A, lenA)``. No aliasing of input and output operands is - # allowed. - + void _fmpz_mod_poly_rem(fmpz * R, const fmpz * A, slong lenA, const fmpz * B, slong lenB, const fmpz_t invB, const fmpz_mod_ctx_t ctx) noexcept void fmpz_mod_poly_rem_f(fmpz_t f, fmpz_mod_poly_t R, const fmpz_mod_poly_t A, const fmpz_mod_poly_t B, const fmpz_mod_ctx_t ctx) noexcept - # If `f` returns with the value `1` then the function operates as - # ``_fmpz_mod_poly_rem``, otherwise `f` will be set to a nontrivial - # factor of `p`. - void fmpz_mod_poly_rem(fmpz_mod_poly_t R, const fmpz_mod_poly_t A, const fmpz_mod_poly_t B, const fmpz_mod_ctx_t ctx) noexcept - # Notationally, computes `Q`, `R` such that `A = B Q + R` - # and `0 \leq \operatorname{len}(R) < \operatorname{len}(B)`, returning only the remainder - # part. - # Assumes that `B` is non-zero and that the leading coefficient - # of `B` is invertible modulo `p`. - int _fmpz_mod_poly_divides_classical(fmpz * Q, const fmpz * A, slong lenA, const fmpz * B, slong lenB, const fmpz_mod_ctx_t ctx) noexcept - # Returns `1` if `(B, lenB)` divides `(A, lenA)` and sets - # `(Q, lenA - lenB + 1)` to the quotient. Otherwise, returns `0` and sets - # `(Q, lenA - lenB + 1)` to zero. We require that `lenA >= lenB > 0`. - int fmpz_mod_poly_divides_classical(fmpz_mod_poly_t Q, const fmpz_mod_poly_t A, const fmpz_mod_poly_t B, const fmpz_mod_ctx_t ctx) noexcept - # Returns `1` if `B` divides `A` and sets `Q` to the quotient. Otherwise - # returns `0` and sets `Q` to zero. - int _fmpz_mod_poly_divides(fmpz * Q, const fmpz * A, slong lenA, const fmpz * B, slong lenB, const fmpz_mod_ctx_t ctx) noexcept - # Returns `1` if `(B, lenB)` divides `(A, lenA)` and sets - # `(Q, lenA - lenB + 1)` to the quotient. Otherwise, returns `0` and sets - # `(Q, lenA - lenB + 1)` to zero. We require that `lenA >= lenB > 0`. - int fmpz_mod_poly_divides(fmpz_mod_poly_t Q, const fmpz_mod_poly_t A, const fmpz_mod_poly_t B, const fmpz_mod_ctx_t ctx) noexcept - # Returns `1` if `B` divides `A` and sets `Q` to the quotient. Otherwise - # returns `0` and sets `Q` to zero. - void _fmpz_mod_poly_inv_series(fmpz * Qinv, const fmpz * Q, slong Qlen, slong n, const fmpz_mod_ctx_t ctx) noexcept - # Sets ``(Qinv, n)`` to the inverse of ``(Q, n)`` modulo `x^n`, - # where `n \geq 1`, assuming that the bottom coefficient of `Q` is - # invertible modulo `p` and that its inverse is ``cinv``. - void fmpz_mod_poly_inv_series(fmpz_mod_poly_t Qinv, const fmpz_mod_poly_t Q, slong n, const fmpz_mod_ctx_t ctx) noexcept - # Sets ``Qinv`` to the inverse of ``Q`` modulo `x^n`, - # where `n \geq 1`, assuming that the bottom coefficient of - # `Q` is a unit. - void fmpz_mod_poly_inv_series_f(fmpz_t f, fmpz_mod_poly_t Qinv, const fmpz_mod_poly_t Q, slong n, const fmpz_mod_ctx_t ctx) noexcept - # Either sets `f` to a nontrivial factor of `p` with the value of - # ``Qinv`` undefined, or sets ``Qinv`` to the inverse of ``Q`` - # modulo `x^n`, where `n \geq 1`. - void _fmpz_mod_poly_div_series(fmpz * Q, const fmpz * A, slong Alen, const fmpz * B, slong Blen, slong n, const fmpz_mod_ctx_t ctx) noexcept - # Set ``(Q, n)`` to the quotient of the series ``(A, Alen``) and - # ``(B, Blen)`` assuming ``Alen, Blen <= n``. We assume the bottom - # coefficient of ``B`` is invertible modulo `p`. - void fmpz_mod_poly_div_series(fmpz_mod_poly_t Q, const fmpz_mod_poly_t A, const fmpz_mod_poly_t B, slong n, const fmpz_mod_ctx_t ctx) noexcept - # Set `Q` to the quotient of the series `A` by `B`, thinking of the series as - # though they were of length `n`. We assume that the bottom coefficient of - # `B` is a unit. - void fmpz_mod_poly_make_monic(fmpz_mod_poly_t res, const fmpz_mod_poly_t poly, const fmpz_mod_ctx_t ctx) noexcept - # If ``poly`` is non-zero, sets ``res`` to ``poly`` divided - # by its leading coefficient. This assumes that the leading coefficient - # of ``poly`` is invertible modulo `p`. - # Otherwise, if ``poly`` is zero, sets ``res`` to zero. - void fmpz_mod_poly_make_monic_f(fmpz_t f, fmpz_mod_poly_t res, const fmpz_mod_poly_t poly, const fmpz_mod_ctx_t ctx) noexcept - # Either set `f` to `1` and ``res`` to ``poly`` divided by its leading - # coefficient or set `f` to a nontrivial factor of `p` and leave ``res`` - # undefined. - - slong _fmpz_mod_poly_gcd(fmpz *G, const fmpz *A, slong lenA, const fmpz *B, slong lenB, const fmpz_mod_ctx_t ctx) noexcept - # Sets `G` to the greatest common divisor of `(A, \operatorname{len}(A))` - # and `(B, \operatorname{len}(B))` and returns its length. - # Assumes that `\operatorname{len}(A) \geq \operatorname{len}(B) > 0` and that the vector `G` has - # space for sufficiently many coefficients. - # Assumes that ``invB`` is the inverse of the leading coefficients - # of `B` modulo the prime number `p`. - + slong _fmpz_mod_poly_gcd(fmpz * G, const fmpz * A, slong lenA, const fmpz * B, slong lenB, const fmpz_mod_ctx_t ctx) noexcept void fmpz_mod_poly_gcd(fmpz_mod_poly_t G, const fmpz_mod_poly_t A, const fmpz_mod_poly_t B, const fmpz_mod_ctx_t ctx) noexcept - # Sets `G` to the greatest common divisor of `A` and `B`. - # In general, the greatest common divisor is defined in the polynomial - # ring `(\mathbf{Z}/(p \mathbf{Z}))[X]` if and only if `p` is a prime - # number. Thus, this function assumes that `p` is prime. - - slong _fmpz_mod_poly_gcd_euclidean_f(fmpz_t f, fmpz *G, const fmpz *A, slong lenA, const fmpz *B, slong lenB, const fmpz_mod_ctx_t ctx) noexcept - # Either sets `f = 1` and `G` to the greatest common divisor - # of `(A, \operatorname{len}(A))` and `(B, \operatorname{len}(B))` and returns its length, - # or sets `f \in (1,p)` to a non-trivial factor of `p` and - # leaves the contents of the vector `(G, lenB)` undefined. - # Assumes that `\operatorname{len}(A) \geq \operatorname{len}(B) > 0` and that the vector `G` has - # space for sufficiently many coefficients. - # Does not support aliasing of any of the input arguments - # with any of the output argument. - + slong _fmpz_mod_poly_gcd_euclidean_f(fmpz_t f, fmpz * G, const fmpz * A, slong lenA, const fmpz * B, slong lenB, const fmpz_mod_ctx_t ctx) noexcept void fmpz_mod_poly_gcd_euclidean_f(fmpz_t f, fmpz_mod_poly_t G, const fmpz_mod_poly_t A, const fmpz_mod_poly_t B, const fmpz_mod_ctx_t ctx) noexcept - # Either sets `f = 1` and `G` to the greatest common divisor - # of `A` and `B`, or ` \in (1,p)` to a non-trivial factor of `p`. - # In general, the greatest common divisor is defined in the polynomial - # ring `(\mathbf{Z}/(p \mathbf{Z}))[X]` if and only if `p` is a prime - # number. - - slong _fmpz_mod_poly_gcd_f(fmpz_t f, fmpz *G, const fmpz *A, slong lenA, const fmpz *B, slong lenB, const fmpz_mod_ctx_t ctx) noexcept - # Either sets `f = 1` and `G` to the greatest common divisor - # of `(A, \operatorname{len}(A))` and `(B, \operatorname{len}(B))` and returns its length, - # or sets `f \in (1,p)` to a non-trivial factor of `p` and - # leaves the contents of the vector `(G, lenB)` undefined. - # Assumes that `\operatorname{len}(A) \geq \operatorname{len}(B) > 0` and that the vector `G` has - # space for sufficiently many coefficients. - # Does not support aliasing of any of the input arguments - # with any of the output arguments. - + slong _fmpz_mod_poly_gcd_f(fmpz_t f, fmpz * G, const fmpz * A, slong lenA, const fmpz * B, slong lenB, const fmpz_mod_ctx_t ctx) noexcept void fmpz_mod_poly_gcd_f(fmpz_t f, fmpz_mod_poly_t G, const fmpz_mod_poly_t A, const fmpz_mod_poly_t B, const fmpz_mod_ctx_t ctx) noexcept - # Either sets `f = 1` and `G` to the greatest common divisor - # of `A` and `B`, or `f \in (1,p)` to a non-trivial factor of `p`. - # In general, the greatest common divisor is defined in the polynomial - # ring `(\mathbf{Z}/(p \mathbf{Z}))[X]` if and only if `p` is a prime - # number. - - slong _fmpz_mod_poly_hgcd(fmpz **M, slong *lenM, fmpz *A, slong *lenA, fmpz *B, slong *lenB, const fmpz *a, slong lena, const fmpz *b, slong lenb, const fmpz_mod_ctx_t ctx) noexcept - # Computes the HGCD of `a` and `b`, that is, a matrix~`M`, a sign~`\sigma` - # and two polynomials `A` and `B` such that - # .. math :: - # (A,B)^t = \sigma M^{-1} (a,b)^t. - # Assumes that `\operatorname{len}(a) > \operatorname{len}(b) > 0`. - # Assumes that `A` and `B` have space of size at least `\operatorname{len}(a)` - # and `\operatorname{len}(b)`, respectively. On exit, ``*lenA`` and ``*lenB`` - # will contain the correct lengths of `A` and `B`. - # Assumes that ``M[0]``, ``M[1]``, ``M[2]``, and ``M[3]`` - # each point to a vector of size at least `\operatorname{len}(a)`. - - slong _fmpz_mod_poly_xgcd_euclidean_f(fmpz_t f, fmpz *G, fmpz *S, fmpz *T, const fmpz *A, slong lenA, const fmpz *B, slong lenB, const fmpz_t invB, const fmpz_mod_ctx_t ctx) noexcept - # If `f` returns with the value `1` then the function operates as per - # ``_fmpz_mod_poly_xgcd_euclidean``, otherwise `f` is set to a nontrivial - # factor of `p`. - + slong _fmpz_mod_poly_hgcd(fmpz **M, slong * lenM, fmpz * A, slong * lenA, fmpz * B, slong * lenB, const fmpz * a, slong lena, const fmpz * b, slong lenb, const fmpz_mod_ctx_t ctx) noexcept + slong _fmpz_mod_poly_xgcd_euclidean_f(fmpz_t f, fmpz * G, fmpz * S, fmpz * T, const fmpz * A, slong lenA, const fmpz * B, slong lenB, const fmpz_t invB, const fmpz_mod_ctx_t ctx) noexcept void fmpz_mod_poly_xgcd_euclidean_f(fmpz_t f, fmpz_mod_poly_t G, fmpz_mod_poly_t S, fmpz_mod_poly_t T, const fmpz_mod_poly_t A, const fmpz_mod_poly_t B, const fmpz_mod_ctx_t ctx) noexcept - # If `f` returns with the value `1` then the function operates as per - # ``fmpz_mod_poly_xgcd_euclidean``, otherwise `f` is set to a nontrivial - # factor of `p`. - - slong _fmpz_mod_poly_xgcd(fmpz *G, fmpz *S, fmpz *T, const fmpz *A, slong lenA, const fmpz *B, slong lenB, const fmpz_t invB, const fmpz_mod_ctx_t ctx) noexcept - # Computes the GCD of `A` and `B` together with cofactors `S` and `T` - # such that `S A + T B = G`. Returns the length of `G`. - # Assumes that `\operatorname{len}(A) \geq \operatorname{len}(B) \geq 1` and - # `(\operatorname{len}(A),\operatorname{len}(B)) \neq (1,1)`. - # No attempt is made to make the GCD monic. - # Requires that `G` have space for `\operatorname{len}(B)` coefficients. Writes - # `\operatorname{len}(B)-1` and `\operatorname{len}(A)-1` coefficients to `S` and `T`, respectively. - # Note that, in fact, `\operatorname{len}(S) \leq \max(\operatorname{len}(B) - \operatorname{len}(G), 1)` and - # `\operatorname{len}(T) \leq \max(\operatorname{len}(A) - \operatorname{len}(G), 1)`. - # No aliasing of input and output operands is permitted. - + slong _fmpz_mod_poly_xgcd(fmpz * G, fmpz * S, fmpz * T, const fmpz * A, slong lenA, const fmpz * B, slong lenB, const fmpz_t invB, const fmpz_mod_ctx_t ctx) noexcept void fmpz_mod_poly_xgcd(fmpz_mod_poly_t G, fmpz_mod_poly_t S, fmpz_mod_poly_t T, const fmpz_mod_poly_t A, const fmpz_mod_poly_t B, const fmpz_mod_ctx_t ctx) noexcept - # Computes the GCD of `A` and `B`. The GCD of zero polynomials is - # defined to be zero, whereas the GCD of the zero polynomial and some other - # polynomial `P` is defined to be `P`. Except in the case where - # the GCD is zero, the GCD `G` is made monic. - # Polynomials ``S`` and ``T`` are computed such that - # ``S*A + T*B = G``. The length of ``S`` will be at most - # ``lenB`` and the length of ``T`` will be at most ``lenA``. - void fmpz_mod_poly_xgcd_f(fmpz_t f, fmpz_mod_poly_t G, fmpz_mod_poly_t S, fmpz_mod_poly_t T, const fmpz_mod_poly_t A, const fmpz_mod_poly_t B, const fmpz_mod_ctx_t ctx) noexcept - # If `f` returns with the value `1` then the function operates as per - # ``fmpz_mod_poly_xgcd``, otherwise `f` is set to a nontrivial - # factor of `p`. - - slong _fmpz_mod_poly_gcdinv_euclidean(fmpz *G, fmpz *S, const fmpz *A, slong lenA, const fmpz *B, slong lenB, const fmpz_t invA, const fmpz_mod_ctx_t ctx) noexcept - # Computes ``(G, lenA)``, ``(S, lenB-1)`` such that - # `G \cong S A \pmod{B}`, returning the actual length of `G`. - # Assumes that `0 < \operatorname{len}(A) < \operatorname{len}(B)`. - + slong _fmpz_mod_poly_gcdinv_euclidean(fmpz * G, fmpz * S, const fmpz * A, slong lenA, const fmpz * B, slong lenB, const fmpz_t invA, const fmpz_mod_ctx_t ctx) noexcept void fmpz_mod_poly_gcdinv_euclidean(fmpz_mod_poly_t G, fmpz_mod_poly_t S, const fmpz_mod_poly_t A, const fmpz_mod_poly_t B, const fmpz_mod_ctx_t ctx) noexcept - # Computes polynomials `G` and `S`, both reduced modulo~`B`, - # such that `G \cong S A \pmod{B}`, where `B` is assumed to - # have `\operatorname{len}(B) \geq 2`. - # In the case that `A = 0 \pmod{B}`, returns `G = S = 0`. - - slong _fmpz_mod_poly_gcdinv_euclidean_f(fmpz_t f, fmpz *G, fmpz *S, const fmpz *A, slong lenA, const fmpz *B, slong lenB, const fmpz_t invA, const fmpz_mod_ctx_t ctx) noexcept - # If `f` returns with value `1` then the function operates as per - # :func:`_fmpz_mod_poly_gcdinv_euclidean`, otherwise `f` is set to a - # nontrivial factor of `p`. - + slong _fmpz_mod_poly_gcdinv_euclidean_f(fmpz_t f, fmpz * G, fmpz * S, const fmpz * A, slong lenA, const fmpz * B, slong lenB, const fmpz_t invA, const fmpz_mod_ctx_t ctx) noexcept void fmpz_mod_poly_gcdinv_euclidean_f(fmpz_t f, fmpz_mod_poly_t G, fmpz_mod_poly_t S, const fmpz_mod_poly_t A, const fmpz_mod_poly_t B, const fmpz_mod_ctx_t ctx) noexcept - # If `f` returns with value `1` then the function operates as per - # :func:`fmpz_mod_poly_gcdinv_euclidean`, otherwise `f` is set to a - # nontrivial factor of the modulus of `A`. - - slong _fmpz_mod_poly_gcdinv(fmpz *G, fmpz *S, const fmpz *A, slong lenA, const fmpz *B, slong lenB, const fmpz_mod_ctx_t ctx) noexcept - # Computes ``(G, lenA)``, ``(S, lenB-1)`` such that - # `G \cong S A \pmod{B}`, returning the actual length of `G`. - # Assumes that `0 < \operatorname{len}(A) < \operatorname{len}(B)`. - - slong _fmpz_mod_poly_gcdinv_f(fmpz_t f, fmpz *G, fmpz *S, const fmpz *A, slong lenA, const fmpz *B, slong lenB, const fmpz_mod_ctx_t ctx) noexcept - # If `f` returns with value `1` then the function operates as per - # :func:`_fmpz_mod_poly_gcdinv`, otherwise `f` will be set to a nontrivial - # factor of `p`. - + slong _fmpz_mod_poly_gcdinv(fmpz * G, fmpz * S, const fmpz * A, slong lenA, const fmpz * B, slong lenB, const fmpz_mod_ctx_t ctx) noexcept + slong _fmpz_mod_poly_gcdinv_f(fmpz_t f, fmpz * G, fmpz * S, const fmpz * A, slong lenA, const fmpz * B, slong lenB, const fmpz_mod_ctx_t ctx) noexcept void fmpz_mod_poly_gcdinv(fmpz_mod_poly_t G, fmpz_mod_poly_t S, const fmpz_mod_poly_t A, const fmpz_mod_poly_t B, const fmpz_mod_ctx_t ctx) noexcept - # Computes polynomials `G` and `S`, both reduced modulo~`B`, - # such that `G \cong S A \pmod{B}`, where `B` is assumed to - # have `\operatorname{len}(B) \geq 2`. - # In the case that `A = 0 \pmod{B}`, returns `G = S = 0`. - void fmpz_mod_poly_gcdinv_f(fmpz_t f, fmpz_mod_poly_t G, fmpz_mod_poly_t S, const fmpz_mod_poly_t A, const fmpz_mod_poly_t B, const fmpz_mod_ctx_t ctx) noexcept - # If `f` returns with value `1` then the function operates as per - # :func:`fmpz_mod_poly_gcdinv`, otherwise `f` will be set to a nontrivial - # factor of `p`. - - int _fmpz_mod_poly_invmod(fmpz *A, const fmpz *B, slong lenB, const fmpz *P, slong lenP, const fmpz_mod_ctx_t ctx) noexcept - # Attempts to set ``(A, lenP-1)`` to the inverse of ``(B, lenB)`` - # modulo the polynomial ``(P, lenP)``. Returns `1` if ``(B, lenB)`` - # is invertible and `0` otherwise. - # Assumes that `0 < \operatorname{len}(B) < \operatorname{len}(P)`, and hence also `\operatorname{len}(P) \geq 2`, - # but supports zero-padding in ``(B, lenB)``. - # Does not support aliasing. - # Assumes that `p` is a prime number. - - int _fmpz_mod_poly_invmod_f(fmpz_t f, fmpz *A, const fmpz *B, slong lenB, const fmpz *P, slong lenP, const fmpz_mod_ctx_t ctx) noexcept - # If `f` returns with the value `1`, then the function operates as per - # :func:`_fmpz_mod_poly_invmod`. Otherwise `f` is set to a nontrivial - # factor of `p`. - + int _fmpz_mod_poly_invmod(fmpz * A, const fmpz * B, slong lenB, const fmpz * P, slong lenP, const fmpz_mod_ctx_t ctx) noexcept + int _fmpz_mod_poly_invmod_f(fmpz_t f, fmpz * A, const fmpz * B, slong lenB, const fmpz * P, slong lenP, const fmpz_mod_ctx_t ctx) noexcept int fmpz_mod_poly_invmod(fmpz_mod_poly_t A, const fmpz_mod_poly_t B, const fmpz_mod_poly_t P, const fmpz_mod_ctx_t ctx) noexcept - # Attempts to set `A` to the inverse of `B` modulo `P` in the polynomial - # ring `(\mathbf{Z}/p\mathbf{Z})[X]`, where we assume that `p` is a prime - # number. - # If `\deg(P) < 2`, raises an exception. - # If the greatest common divisor of `B` and `P` is~`1`, returns~`1` and - # sets `A` to the inverse of `B`. Otherwise, returns~`0` and the value - # of `A` on exit is undefined. - int fmpz_mod_poly_invmod_f(fmpz_t f, fmpz_mod_poly_t A, const fmpz_mod_poly_t B, const fmpz_mod_poly_t P, const fmpz_mod_ctx_t ctx) noexcept - # If `f` returns with the value `1`, then the function operates as per - # :func:`fmpz_mod_poly_invmod`. Otherwise `f` is set to a nontrivial - # factor of `p`. - - slong _fmpz_mod_poly_minpoly_bm(fmpz* poly, const fmpz* seq, slong len, const fmpz_mod_ctx_t ctx) noexcept - # Sets ``poly`` to the coefficients of a minimal generating - # polynomial for sequence ``(seq, len)`` modulo `p`. - # The return value equals the length of ``poly``. - # It is assumed that `p` is prime and ``poly`` has space for at least - # `len+1` coefficients. No aliasing between inputs and outputs is - # allowed. - - void fmpz_mod_poly_minpoly_bm(fmpz_mod_poly_t poly, const fmpz* seq, slong len, const fmpz_mod_ctx_t ctx) noexcept - # Sets ``poly`` to a minimal generating polynomial for sequence - # ``seq`` of length ``len``. - # Assumes that the modulus is prime. - # This version uses the Berlekamp-Massey algorithm, whose running time - # is proportional to ``len`` times the size of the minimal generator. - - slong _fmpz_mod_poly_minpoly_hgcd(fmpz* poly, const fmpz* seq, slong len, const fmpz_mod_ctx_t ctx) noexcept - # Sets ``poly`` to the coefficients of a minimal generating - # polynomial for sequence ``(seq, len)`` modulo `p`. - # The return value equals the length of ``poly``. - # It is assumed that `p` is prime and ``poly`` has space for at least - # `len+1` coefficients. No aliasing between inputs and outputs is - # allowed. - - void fmpz_mod_poly_minpoly_hgcd(fmpz_mod_poly_t poly, const fmpz* seq, slong len, const fmpz_mod_ctx_t ctx) noexcept - # Sets ``poly`` to a minimal generating polynomial for sequence - # ``seq`` of length ``len``. - # Assumes that the modulus is prime. - # This version uses the HGCD algorithm, whose running time is - # `O(n \log^2 n)` field operations, regardless of the actual size of - # the minimal generator. - - slong _fmpz_mod_poly_minpoly(fmpz* poly, const fmpz* seq, slong len, const fmpz_mod_ctx_t ctx) noexcept - # Sets ``poly`` to the coefficients of a minimal generating - # polynomial for sequence ``(seq, len)`` modulo `p`. - # The return value equals the length of ``poly``. - # It is assumed that `p` is prime and ``poly`` has space for at least - # `len+1` coefficients. No aliasing between inputs and outputs is - # allowed. - - void fmpz_mod_poly_minpoly(fmpz_mod_poly_t poly, const fmpz* seq, slong len, const fmpz_mod_ctx_t ctx) noexcept - # Sets ``poly`` to a minimal generating polynomial for sequence - # ``seq`` of length ``len``. - # A minimal generating polynomial is a monic polynomial - # `f = x^d + c_{d-1}x^{d-1} + \cdots + c_1 x + c_0`, - # of minimal degree `d`, that annihilates any consecutive `d+1` terms - # in ``seq``. That is, for any `i < len - d`, - # `seq_i = -\sum_{j=0}^{d-1} seq_{i+j}*f_j.` - # Assumes that the modulus is prime. - # This version automatically chooses the fastest underlying - # implementation based on ``len`` and the size of the modulus. - - void _fmpz_mod_poly_resultant_euclidean(fmpz_t res, const fmpz *poly1, slong len1, const fmpz *poly2, slong len2, const fmpz_mod_ctx_t ctx) noexcept - # Sets `r` to the resultant of ``(poly1, len1)`` and - # ``(poly2, len2)`` using the Euclidean algorithm. - # Assumes that ``len1 >= len2 > 0``. - # Assumes that the modulus is prime. - + slong _fmpz_mod_poly_minpoly_bm(fmpz * poly, const fmpz * seq, slong len, const fmpz_mod_ctx_t ctx) noexcept + void fmpz_mod_poly_minpoly_bm(fmpz_mod_poly_t poly, const fmpz * seq, slong len, const fmpz_mod_ctx_t ctx) noexcept + slong _fmpz_mod_poly_minpoly_hgcd(fmpz * poly, const fmpz * seq, slong len, const fmpz_mod_ctx_t ctx) noexcept + void fmpz_mod_poly_minpoly_hgcd(fmpz_mod_poly_t poly, const fmpz * seq, slong len, const fmpz_mod_ctx_t ctx) noexcept + slong _fmpz_mod_poly_minpoly(fmpz * poly, const fmpz * seq, slong len, const fmpz_mod_ctx_t ctx) noexcept + void fmpz_mod_poly_minpoly(fmpz_mod_poly_t poly, const fmpz * seq, slong len, const fmpz_mod_ctx_t ctx) noexcept + void _fmpz_mod_poly_resultant_euclidean(fmpz_t res, const fmpz * poly1, slong len1, const fmpz * poly2, slong len2, const fmpz_mod_ctx_t ctx) noexcept void fmpz_mod_poly_resultant_euclidean(fmpz_t r, const fmpz_mod_poly_t f, const fmpz_mod_poly_t g, const fmpz_mod_ctx_t ctx) noexcept - # Computes the resultant of `f` and `g` using the Euclidean algorithm. - # For two non-zero polynomials `f(x) = a_m x^m + \dotsb + a_0` and - # `g(x) = b_n x^n + \dotsb + b_0` of degrees `m` and `n`, the resultant - # is defined to be - # .. math :: - # a_m^n b_n^m \prod_{(x, y) : f(x) = g(y) = 0} (x - y). - # For convenience, we define the resultant to be equal to zero if either - # of the two polynomials is zero. - - void _fmpz_mod_poly_resultant_hgcd(fmpz_t res, const fmpz *A, slong lenA, const fmpz *B, slong lenB, const fmpz_mod_ctx_t ctx) noexcept - # Sets ``res`` to the resultant of ``(A, lenA)`` and - # ``(B, lenB)`` using the half-gcd algorithm. - # This algorithm computes the half-gcd as per - # :func:`_fmpz_mod_poly_gcd_hgcd` - # but additionally updates the resultant every time a division occurs. The - # half-gcd algorithm computes the GCD recursively. Given inputs `a` and `b` - # it lets ``m = len(a)/2`` and (recursively) performs all quotients in - # the Euclidean algorithm which do not require the low `m` coefficients of - # `a` and `b`. - # This performs quotients in exactly the same order as the ordinary - # Euclidean algorithm except that the low `m` coefficients of the polynomials - # in the remainder sequence are not computed. A correction step after hgcd - # has been called computes these low `m` coefficients (by matrix - # multiplication by a transformation matrix also computed by hgcd). - # This means that from the point of view of the resultant, all but the last - # quotient performed by a recursive call to hgcd is an ordinary quotient as - # per the usual Euclidean algorithm. However, the final quotient may give - # a remainder of less than `m + 1` coefficients, which won't be corrected - # until the hgcd correction step is performed afterwards. - # To compute the adjustments to the resultant coming from this corrected - # quotient, we save the relevant information in an ``nmod_poly_res_t`` - # struct at the time the quotient is performed so that when the correction - # step is performed later, the adjustments to the resultant can be computed - # at that time also. - # The only time an adjustment to the resultant is not required after a - # call to hgcd is if hgcd does nothing (the remainder may already have had - # less than `m + 1` coefficients when hgcd was called). - # Assumes that ``lenA >= lenB > 0``. - # Assumes that the modulus is prime. - + void _fmpz_mod_poly_resultant_hgcd(fmpz_t res, const fmpz * A, slong lenA, const fmpz * B, slong lenB, const fmpz_mod_ctx_t ctx) noexcept void fmpz_mod_poly_resultant_hgcd(fmpz_t res, const fmpz_mod_poly_t f, const fmpz_mod_poly_t g, const fmpz_mod_ctx_t ctx) noexcept - # Computes the resultant of `f` and `g` using the half-gcd algorithm. - # For two non-zero polynomials `f(x) = a_m x^m + \dotsb + a_0` and - # `g(x) = b_n x^n + \dotsb + b_0` of degrees `m` and `n`, the resultant - # is defined to be - # .. math :: - # a_m^n b_n^m \prod_{(x, y) : f(x) = g(y) = 0} (x - y). - # For convenience, we define the resultant to be equal to zero if either - # of the two polynomials is zero. - - void _fmpz_mod_poly_resultant(fmpz_t res, const fmpz *poly1, slong len1, const fmpz *poly2, slong len2, const fmpz_mod_ctx_t ctx) noexcept - # Returns the resultant of ``(poly1, len1)`` and - # ``(poly2, len2)``. - # Assumes that ``len1 >= len2 > 0``. - # Assumes that the modulus is prime. - + void _fmpz_mod_poly_resultant(fmpz_t res, const fmpz * poly1, slong len1, const fmpz * poly2, slong len2, const fmpz_mod_ctx_t ctx) noexcept void fmpz_mod_poly_resultant(fmpz_t res, const fmpz_mod_poly_t f, const fmpz_mod_poly_t g, const fmpz_mod_ctx_t ctx) noexcept - # Computes the resultant of $f$ and $g$. - # For two non-zero polynomials `f(x) = a_m x^m + \dotsb + a_0` and - # `g(x) = b_n x^n + \dotsb + b_0` of degrees `m` and `n`, the resultant - # is defined to be - # .. math :: - # a_m^n b_n^m \prod_{(x, y) : f(x) = g(y) = 0} (x - y). - # For convenience, we define the resultant to be equal to zero if either - # of the two polynomials is zero. - - void _fmpz_mod_poly_discriminant(fmpz_t d, const fmpz *poly, slong len, const fmpz_mod_ctx_t ctx) noexcept - # Set `d` to the discriminant of ``(poly, len)``. Assumes ``len > 1``. - + void _fmpz_mod_poly_discriminant(fmpz_t d, const fmpz * poly, slong len, const fmpz_mod_ctx_t ctx) noexcept void fmpz_mod_poly_discriminant(fmpz_t d, const fmpz_mod_poly_t f, const fmpz_mod_ctx_t ctx) noexcept - # Set `d` to the discriminant of `f`. - # We normalise the discriminant so that - # `\operatorname{disc}(f) = (-1)^(n(n-1)/2) \operatorname{res}(f, f') / - # \operatorname{lc}(f)^(n - m - 2)`, where ``n = len(f)`` and - # ``m = len(f')``. Thus `\operatorname{disc}(f) = - # \operatorname{lc}(f)^(2n - 2) \prod_{i < j} (r_i - r_j)^2`, where - # `\operatorname{lc}(f)` is the leading coefficient of `f` and `r_i` are the - # roots of `f`. - - void _fmpz_mod_poly_derivative(fmpz *res, const fmpz *poly, slong len, const fmpz_mod_ctx_t ctx) noexcept - # Sets ``(res, len - 1)`` to the derivative of ``(poly, len)``. - # Also handles the cases where ``len`` is `0` or `1` correctly. - # Supports aliasing of ``res`` and ``poly``. - + void _fmpz_mod_poly_derivative(fmpz * res, const fmpz * poly, slong len, const fmpz_mod_ctx_t ctx) noexcept void fmpz_mod_poly_derivative(fmpz_mod_poly_t res, const fmpz_mod_poly_t poly, const fmpz_mod_ctx_t ctx) noexcept - # Sets ``res`` to the derivative of ``poly``. - - void _fmpz_mod_poly_evaluate_fmpz(fmpz_t res, const fmpz *poly, slong len, const fmpz_t a, const fmpz_mod_ctx_t ctx) noexcept - # Evaluates the polynomial ``(poly, len)`` at the integer `a` and sets - # ``res`` to the result. Aliasing between ``res`` and `a` or any - # of the coefficients of ``poly`` is not supported. - + void _fmpz_mod_poly_evaluate_fmpz(fmpz_t res, const fmpz * poly, slong len, const fmpz_t a, const fmpz_mod_ctx_t ctx) noexcept void fmpz_mod_poly_evaluate_fmpz(fmpz_t res, const fmpz_mod_poly_t poly, const fmpz_t a, const fmpz_mod_ctx_t ctx) noexcept - # Evaluates the polynomial ``poly`` at the integer `a` and sets - # ``res`` to the result. - # As expected, aliasing between ``res`` and `a` is supported. However, - # ``res`` may not be aliased with a coefficient of ``poly``. - void _fmpz_mod_poly_evaluate_fmpz_vec_iter(fmpz * ys, const fmpz * coeffs, slong len, const fmpz * xs, slong n, const fmpz_mod_ctx_t ctx) noexcept - # Evaluates (``coeffs``, ``len``) at the ``n`` values - # given in the vector ``xs``, writing the output values - # to ``ys``. The values in ``xs`` should be reduced - # modulo the modulus. - # Uses Horner's method iteratively. - void fmpz_mod_poly_evaluate_fmpz_vec_iter(fmpz * ys, const fmpz_mod_poly_t poly, const fmpz * xs, slong n, const fmpz_mod_ctx_t ctx) noexcept - # Evaluates ``poly`` at the ``n`` values given in the vector - # ``xs``, writing the output values to ``ys``. The values in - # ``xs`` should be reduced modulo the modulus. - # Uses Horner's method iteratively. - void _fmpz_mod_poly_evaluate_fmpz_vec_fast_precomp(fmpz * vs, const fmpz * poly, slong plen, fmpz_poly_struct * const * tree, slong len, const fmpz_mod_ctx_t ctx) noexcept - # Evaluates (``poly``, ``plen``) at the ``len`` values given by the precomputed subproduct tree ``tree``. - void _fmpz_mod_poly_evaluate_fmpz_vec_fast(fmpz * ys, const fmpz * poly, slong plen, const fmpz * xs, slong n, const fmpz_mod_ctx_t ctx) noexcept - # Evaluates (``coeffs``, ``len``) at the ``n`` values - # given in the vector ``xs``, writing the output values - # to ``ys``. The values in ``xs`` should be reduced - # modulo the modulus. - # Uses fast multipoint evaluation, building a temporary subproduct tree. - void fmpz_mod_poly_evaluate_fmpz_vec_fast(fmpz * ys, const fmpz_mod_poly_t poly, const fmpz * xs, slong n, const fmpz_mod_ctx_t ctx) noexcept - # Evaluates ``poly`` at the ``n`` values given in the vector - # ``xs``, writing the output values to ``ys``. The values in - # ``xs`` should be reduced modulo the modulus. - # Uses fast multipoint evaluation, building a temporary subproduct tree. - void _fmpz_mod_poly_evaluate_fmpz_vec(fmpz * ys, const fmpz * coeffs, slong len, const fmpz * xs, slong n, const fmpz_mod_ctx_t ctx) noexcept - # Evaluates (``coeffs``, ``len``) at the ``n`` values - # given in the vector ``xs``, writing the output values - # to ``ys``. The values in ``xs`` should be reduced - # modulo the modulus. - void fmpz_mod_poly_evaluate_fmpz_vec(fmpz * ys, const fmpz_mod_poly_t poly, const fmpz * xs, slong n, const fmpz_mod_ctx_t ctx) noexcept - # Evaluates ``poly`` at the ``n`` values given in the vector - # ``xs``, writing the output values to ``ys``. The values in - # ``xs`` should be reduced modulo the modulus. - - void _fmpz_mod_poly_compose(fmpz *res, const fmpz *poly1, slong len1, const fmpz *poly2, slong len2, const fmpz_mod_ctx_t ctx) noexcept - # Sets ``res`` to the composition of ``(poly1, len1)`` and - # ``(poly2, len2)``. - # Assumes that ``res`` has space for ``(len1-1)*(len2-1) + 1`` - # coefficients, although in `\mathbf{Z}_p[X]` this might not actually - # be the length of the resulting polynomial when `p` is not a prime. - # Assumes that ``poly1`` and ``poly2`` are non-zero polynomials. - # Does not support aliasing between any of the inputs and the output. - + void _fmpz_mod_poly_compose(fmpz * res, const fmpz * poly1, slong len1, const fmpz * poly2, slong len2, const fmpz_mod_ctx_t ctx) noexcept void fmpz_mod_poly_compose(fmpz_mod_poly_t res, const fmpz_mod_poly_t poly1, const fmpz_mod_poly_t poly2, const fmpz_mod_ctx_t ctx) noexcept - # Sets ``res`` to the composition of ``poly1`` and ``poly2``. - # To be precise about the order of composition, denoting ``res``, - # ``poly1``, and ``poly2`` by `f`, `g`, and `h`, respectively, - # sets `f(t) = g(h(t))`. - void _fmpz_mod_poly_invsqrt_series(fmpz * g, const fmpz * h, slong hlen, slong n, const fmpz_mod_ctx_t ctx) noexcept - # Set the first `n` terms of `g` to the series expansion of `1/\sqrt{h}`. - # It is assumed that `n > 0` and `h > 0`. Aliasing is not permitted. - void fmpz_mod_poly_invsqrt_series(fmpz_mod_poly_t g, const fmpz_mod_poly_t h, slong n, const fmpz_mod_ctx_t ctx) noexcept - # Set `g` to the series expansion of `1/\sqrt{h}` to order `O(x^n)`. - # It is assumed that `h` has constant term 1. - void _fmpz_mod_poly_sqrt_series(fmpz * g, const fmpz * h, slong hlen, slong n, const fmpz_mod_ctx_t ctx) noexcept - # Set the first `n` terms of `g` to the series expansion of `\sqrt{h}`. - # It is assumed that `n > 0` and `h > 0`. Aliasing is not permitted. - void fmpz_mod_poly_sqrt_series(fmpz_mod_poly_t g, const fmpz_mod_poly_t h, slong n, const fmpz_mod_ctx_t ctx) noexcept - # Set `g` to the series expansion of `\sqrt{h}` to order `O(x^n)`. - # It is assumed that `h` has constant term 1. - int _fmpz_mod_poly_sqrt(fmpz * s, const fmpz * p, slong n, const fmpz_mod_ctx_t ctx) noexcept - # If ``(p, n)`` is a perfect square, sets ``(s, n / 2 + 1)`` - # to a square root of `p` and returns 1. Otherwise returns 0. - int fmpz_mod_poly_sqrt(fmpz_mod_poly_t s, const fmpz_mod_poly_t p, const fmpz_mod_ctx_t ctx) noexcept - # If `p` is a perfect square, sets `s` to a square root of `p` - # and returns 1. Otherwise returns 0. - void _fmpz_mod_poly_compose_mod(fmpz * res, const fmpz * f, slong lenf, const fmpz * g, const fmpz * h, slong lenh, const fmpz_mod_ctx_t ctx) noexcept - # Sets ``res`` to the composition `f(g)` modulo `h`. We require that - # `h` is nonzero and that the length of `g` is one less than the - # length of `h` (possibly with zero padding). The output is not allowed - # to be aliased with any of the inputs. - void fmpz_mod_poly_compose_mod(fmpz_mod_poly_t res, const fmpz_mod_poly_t f, const fmpz_mod_poly_t g, const fmpz_mod_poly_t h, const fmpz_mod_ctx_t ctx) noexcept - # Sets ``res`` to the composition `f(g)` modulo `h`. We require that - # `h` is nonzero. - void _fmpz_mod_poly_compose_mod_horner(fmpz * res, const fmpz * f, slong lenf, const fmpz * g, const fmpz * h, slong lenh, const fmpz_mod_ctx_t ctx) noexcept - # Sets ``res`` to the composition `f(g)` modulo `h`. We require that - # `h` is nonzero and that the length of `g` is one less than the - # length of `h` (possibly with zero padding). The output is not allowed - # to be aliased with any of the inputs. - # The algorithm used is Horner's rule. - void fmpz_mod_poly_compose_mod_horner(fmpz_mod_poly_t res, const fmpz_mod_poly_t f, const fmpz_mod_poly_t g, const fmpz_mod_poly_t h, const fmpz_mod_ctx_t ctx) noexcept - # Sets ``res`` to the composition `f(g)` modulo `h`. We require that - # `h` is nonzero. The algorithm used is Horner's rule. - void _fmpz_mod_poly_compose_mod_brent_kung(fmpz * res, const fmpz * f, slong len1, const fmpz * g, const fmpz * h, slong len3, const fmpz_mod_ctx_t ctx) noexcept - # Sets ``res`` to the composition `f(g)` modulo `h`. We require that - # `h` is nonzero and that the length of `g` is one less than the - # length of `h` (possibly with zero padding). We also require that - # the length of `f` is less than the length of `h`. The output is not - # allowed to be aliased with any of the inputs. - # The algorithm used is the Brent-Kung matrix algorithm. - void fmpz_mod_poly_compose_mod_brent_kung(fmpz_mod_poly_t res, const fmpz_mod_poly_t f, const fmpz_mod_poly_t g, const fmpz_mod_poly_t h, const fmpz_mod_ctx_t ctx) noexcept - # Sets ``res`` to the composition `f(g)` modulo `h`. We require that - # `h` is nonzero and that `f` has smaller degree than `h`. - # The algorithm used is the Brent-Kung matrix algorithm. - void _fmpz_mod_poly_reduce_matrix_mod_poly (fmpz_mat_t A, const fmpz_mat_t B, const fmpz_mod_poly_t f, const fmpz_mod_ctx_t ctx) noexcept - # Sets the ith row of ``A`` to the reduction of the ith row of `B` modulo - # `f` for `i=1,\ldots,\sqrt{\deg(f)}`. We require `B` to be at least - # a `\sqrt{\deg(f)}\times \deg(f)` matrix and `f` to be nonzero. - void _fmpz_mod_poly_precompute_matrix_worker(void * arg_ptr) noexcept - # Worker function version of ``_fmpz_mod_poly_precompute_matrix``. - # Input/output is stored in ``fmpz_mod_poly_matrix_precompute_arg_t``. - void _fmpz_mod_poly_precompute_matrix (fmpz_mat_t A, const fmpz * f, const fmpz * g, slong leng, const fmpz * ginv, slong lenginv, const fmpz_mod_ctx_t ctx) noexcept - # Sets the ith row of ``A`` to `f^i` modulo `g` for - # `i=1,\ldots,\sqrt{\deg(g)}`. We require `A` to be - # a `\sqrt{\deg(g)}\times \deg(g)` matrix. We require - # ``ginv`` to be the inverse of the reverse of ``g`` and `g` to be - # nonzero. ``f`` has to be reduced modulo ``g`` and of length one less - # than ``leng`` (possibly with zero padding). - void fmpz_mod_poly_precompute_matrix(fmpz_mat_t A, const fmpz_mod_poly_t f, const fmpz_mod_poly_t g, const fmpz_mod_poly_t ginv, const fmpz_mod_ctx_t ctx) noexcept - # Sets the ith row of ``A`` to `f^i` modulo `g` for - # `i=1,\ldots,\sqrt{\deg(g)}`. We require `A` to be - # a `\sqrt{\deg(g)}\times \deg(g)` matrix. We require - # ``ginv`` to be the inverse of the reverse of ``g``. - void _fmpz_mod_poly_compose_mod_brent_kung_precomp_preinv_worker(void * arg_ptr) noexcept - # Worker function version of - # :func:`_fmpz_mod_poly_compose_mod_brent_kung_precomp_preinv`. - # Input/output is stored in - # ``fmpz_mod_poly_compose_mod_precomp_preinv_arg_t``. - void _fmpz_mod_poly_compose_mod_brent_kung_precomp_preinv(fmpz * res, const fmpz * f, slong lenf, const fmpz_mat_t A, const fmpz * h, slong lenh, const fmpz * hinv, slong lenhinv, const fmpz_mod_ctx_t ctx) noexcept - # Sets ``res`` to the composition `f(g)` modulo `h`. We require that - # `h` is nonzero. We require that the ith row of `A` contains `g^i` for - # `i=1,\ldots,\sqrt{\deg(h)}`, i.e. `A` is a - # `\sqrt{\deg(h)}\times \deg(h)` matrix. We also require that - # the length of `f` is less than the length of `h`. Furthermore, we require - # ``hinv`` to be the inverse of the reverse of ``h``. - # The output is not allowed to be aliased with any of the inputs. - # The algorithm used is the Brent-Kung matrix algorithm. - void fmpz_mod_poly_compose_mod_brent_kung_precomp_preinv(fmpz_mod_poly_t res, const fmpz_mod_poly_t f, const fmpz_mat_t A, const fmpz_mod_poly_t h, const fmpz_mod_poly_t hinv, const fmpz_mod_ctx_t ctx) noexcept - # Sets ``res`` to the composition `f(g)` modulo `h`. We require that the - # ith row of `A` contains `g^i` for `i=1,\ldots,\sqrt{\deg(h)}`, i.e. `A` is - # a `\sqrt{\deg(h)}\times \deg(h)` matrix. We require that `h` is nonzero and - # that `f` has smaller degree than `h`. Furthermore, we require ``hinv`` - # to be the inverse of the reverse of ``h``. This version of Brent-Kung - # modular composition is particularly useful if one has to perform several - # modular composition of the form `f(g)` modulo `h` for fixed `g` and `h`. - void _fmpz_mod_poly_compose_mod_brent_kung_preinv(fmpz * res, const fmpz * f, slong lenf, const fmpz * g, const fmpz * h, slong lenh, const fmpz * hinv, slong lenhinv, const fmpz_mod_ctx_t ctx) noexcept - # Sets ``res`` to the composition `f(g)` modulo `h`. We require that - # `h` is nonzero and that the length of `g` is one less than the - # length of `h` (possibly with zero padding). We also require that - # the length of `f` is less than the length of `h`. Furthermore, we require - # ``hinv`` to be the inverse of the reverse of ``h``. - # The output is not allowed to be aliased with any of the inputs. - # The algorithm used is the Brent-Kung matrix algorithm. - void fmpz_mod_poly_compose_mod_brent_kung_preinv(fmpz_mod_poly_t res, const fmpz_mod_poly_t f, const fmpz_mod_poly_t g, const fmpz_mod_poly_t h, const fmpz_mod_poly_t hinv, const fmpz_mod_ctx_t ctx) noexcept - # Sets ``res`` to the composition `f(g)` modulo `h`. We require that - # `h` is nonzero and that `f` has smaller degree than `h`. Furthermore, - # we require ``hinv`` to be the inverse of the reverse of ``h``. - # The algorithm used is the Brent-Kung matrix algorithm. - void _fmpz_mod_poly_compose_mod_brent_kung_vec_preinv(fmpz_mod_poly_struct * res, const fmpz_mod_poly_struct * polys, slong len1, slong l, const fmpz * g, slong glen, const fmpz * h, slong lenh, const fmpz * hinv, slong lenhinv, const fmpz_mod_ctx_t ctx) noexcept - # Sets ``res`` to the composition `f_i(g)` modulo `h` for `1\leq i \leq l`, - # where `f_i` are the ``l`` elements of ``polys``. We require that `h` is - # nonzero and that the length of `g` is less than the length of `h`. We - # also require that the length of `f_i` is less than the length of `h`. We - # require ``res`` to have enough memory allocated to hold ``l`` - # ``fmpz_mod_poly_struct``'s. The entries of ``res`` need to be initialised - # and ``l`` needs to be less than ``len1`` Furthermore, we require ``hinv`` - # to be the inverse of the reverse of ``h``. The output is not allowed to be - # aliased with any of the inputs. - # The algorithm used is the Brent-Kung matrix algorithm. - void fmpz_mod_poly_compose_mod_brent_kung_vec_preinv(fmpz_mod_poly_struct * res, const fmpz_mod_poly_struct * polys, slong len1, slong n, const fmpz_mod_poly_t g, const fmpz_mod_poly_t h, const fmpz_mod_poly_t hinv, const fmpz_mod_ctx_t ctx) noexcept - # Sets ``res`` to the composition `f_i(g)` modulo `h` for `1\leq i \leq n` - # where `f_i` are the ``n`` elements of ``polys``. We require ``res`` to - # have enough memory allocated to hold ``n`` ``fmpz_mod_poly_struct``'s. - # The entries of ``res`` need to be initialised and ``n`` needs to be less - # than ``len1``. We require that `h` is nonzero and that `f_i` and `g` have - # smaller degree than `h`. Furthermore, we require ``hinv`` to be the - # inverse of the reverse of ``h``. No aliasing of ``res`` and - # ``polys`` is allowed. - # The algorithm used is the Brent-Kung matrix algorithm. - void _fmpz_mod_poly_compose_mod_brent_kung_vec_preinv_threaded_pool(fmpz_mod_poly_struct * res, const fmpz_mod_poly_struct * polys, slong lenpolys, slong l, const fmpz * g, slong glen, const fmpz * poly, slong len, const fmpz * polyinv, slong leninv, const fmpz_mod_ctx_t ctx, thread_pool_handle * threads, slong num_threads) noexcept - # Multithreaded version of - # :func:`_fmpz_mod_poly_compose_mod_brent_kung_vec_preinv`. Distributing the - # Horner evaluations across :func:`flint_get_num_threads` threads. - void fmpz_mod_poly_compose_mod_brent_kung_vec_preinv_threaded_pool(fmpz_mod_poly_struct * res, const fmpz_mod_poly_struct * polys, slong len1, slong n, const fmpz_mod_poly_t g, const fmpz_mod_poly_t poly, const fmpz_mod_poly_t polyinv, const fmpz_mod_ctx_t ctx, thread_pool_handle * threads, slong num_threads) noexcept - # Multithreaded version of - # :func:`fmpz_mod_poly_compose_mod_brent_kung_vec_preinv`. Distributing the - # Horner evaluations across :func:`flint_get_num_threads` threads. - void fmpz_mod_poly_compose_mod_brent_kung_vec_preinv_threaded(fmpz_mod_poly_struct * res, const fmpz_mod_poly_struct * polys, slong len1, slong n, const fmpz_mod_poly_t g, const fmpz_mod_poly_t poly, const fmpz_mod_poly_t polyinv, const fmpz_mod_ctx_t ctx) noexcept - # Multithreaded version of - # :func:`fmpz_mod_poly_compose_mod_brent_kung_vec_preinv`. Distributing the - # Horner evaluations across :func:`flint_get_num_threads` threads. - fmpz_poly_struct ** _fmpz_mod_poly_tree_alloc(slong len) noexcept - # Allocates space for a subproduct tree of the given length, having - # linear factors at the lowest level. - void _fmpz_mod_poly_tree_free(fmpz_poly_struct ** tree, slong len) noexcept - # Free the allocated space for the subproduct. - void _fmpz_mod_poly_tree_build(fmpz_poly_struct ** tree, const fmpz * roots, slong len, const fmpz_mod_ctx_t ctx) noexcept - # Builds a subproduct tree in the preallocated space from - # the ``len`` monic linear factors `(x-r_i)` where `r_i` are given by - # ``roots``. The top level product is not computed. - - void _fmpz_mod_poly_radix_init(fmpz **Rpow, fmpz **Rinv, const fmpz *R, slong lenR, slong k, const fmpz_t invL, const fmpz_mod_ctx_t ctx) noexcept - # Computes powers of `R` of the form `R^{2^i}` and their Newton inverses - # modulo `x^{2^{i} \deg(R)}` for `i = 0, \dotsc, k-1`. - # Assumes that the vectors ``Rpow[i]`` and ``Rinv[i]`` have space - # for `2^i \deg(R) + 1` and `2^i \deg(R)` coefficients, respectively. - # Assumes that the polynomial `R` is non-constant, i.e. `\deg(R) \geq 1`. - # Assumes that the leading coefficient of `R` is a unit and that the - # argument ``invL`` is the inverse of the coefficient modulo~`p`. - # The argument~`p` is the modulus, which in `p`-adic applications is - # typically a prime power, although this is not necessary. Here, we - # only assume that `p \geq 2`. - # Note that this precomputed data can be used for any `F` such that - # `\operatorname{len}(F) \leq 2^k \deg(R)`. - + void _fmpz_mod_poly_radix_init(fmpz **Rpow, fmpz **Rinv, const fmpz * R, slong lenR, slong k, const fmpz_t invL, const fmpz_mod_ctx_t ctx) noexcept void fmpz_mod_poly_radix_init(fmpz_mod_poly_radix_t D, const fmpz_mod_poly_t R, slong degF, const fmpz_mod_ctx_t ctx) noexcept - # Carries out the precomputation necessary to perform radix conversion - # to radix~`R` for polynomials~`F` of degree at most ``degF``. - # Assumes that `R` is non-constant, i.e. `\deg(R) \geq 1`, - # and that the leading coefficient is a unit. - - void _fmpz_mod_poly_radix(fmpz **B, const fmpz *F, fmpz **Rpow, fmpz **Rinv, slong degR, slong k, slong i, fmpz *W, const fmpz_mod_ctx_t ctx) noexcept - # This is the main recursive function used by the - # function :func:`fmpz_mod_poly_radix`. - # Assumes that, for all `i = 0, \dotsc, N`, the vector - # ``B[i]`` has space for `\deg(R)` coefficients. - # The variable `k` denotes the factors of `r` that have - # previously been counted for the polynomial `F`, which - # is assumed to have length `2^{i+1} \deg(R)`, possibly - # including zero-padding. - # Assumes that `W` is a vector providing temporary space - # of length `\operatorname{len}(F) = 2^{i+1} \deg(R)`. - # The entire computation takes place over `\mathbf{Z} / p \mathbf{Z}`, - # where `p \geq 2` is a natural number. - # Thus, the top level call will have `F` as in the original - # problem, and `k = 0`. - + void _fmpz_mod_poly_radix(fmpz **B, const fmpz * F, fmpz **Rpow, fmpz **Rinv, slong degR, slong k, slong i, fmpz * W, const fmpz_mod_ctx_t ctx) noexcept void fmpz_mod_poly_radix(fmpz_mod_poly_struct **B, const fmpz_mod_poly_t F, const fmpz_mod_poly_radix_t D, const fmpz_mod_ctx_t ctx) noexcept - # Given a polynomial `F` and the precomputed data `D` for the radix `R`, - # computes polynomials `B_0, \dotsc, B_N` of degree less than `\deg(R)` - # such that - # .. math :: - # F = B_0 + B_1 R + \dotsb + B_N R^N, - # where necessarily `N = \lfloor\deg(F) / \deg(R)\rfloor`. - # Assumes that `R` is non-constant, i.e.\ `\deg(R) \geq 1`, - # and that the leading coefficient is a unit. - - int _fmpz_mod_poly_fprint(FILE * file, const fmpz *poly, slong len, const fmpz_t p) noexcept - # Prints the polynomial ``(poly, len)`` to the stream ``file``. - # In case of success, returns a positive value. In case of failure, - # returns a non-positive value. - + int _fmpz_mod_poly_fprint(FILE * file, const fmpz * poly, slong len, const fmpz_t p) noexcept int fmpz_mod_poly_fprint(FILE * file, const fmpz_mod_poly_t poly, const fmpz_mod_ctx_t ctx) noexcept - # Prints the polynomial to the stream ``file``. - # In case of success, returns a positive value. In case of failure, - # returns a non-positive value. - int fmpz_mod_poly_fprint_pretty(FILE * file, const fmpz_mod_poly_t poly, const char * x, const fmpz_mod_ctx_t ctx) noexcept - # Prints the pretty representation of ``(poly, len)`` to the stream - # ``file``, using the string ``x`` to represent the indeterminate. - # In case of success, returns a positive value. In case of failure, - # returns a non-positive value. - int fmpz_mod_poly_print(const fmpz_mod_poly_t poly, const fmpz_mod_ctx_t ctx) noexcept - # Prints the polynomial to ``stdout``. - # In case of success, returns a positive value. In case of failure, - # returns a non-positive value. - int fmpz_mod_poly_print_pretty(const fmpz_mod_poly_t poly, const char * x, const fmpz_mod_ctx_t ctx) noexcept - # Prints the pretty representation of ``poly`` to ``stdout``, - # using the string ``x`` to represent the indeterminate. - # In case of success, returns a positive value. In case of failure, - # returns a non-positive value. - void fmpz_mod_poly_inflate(fmpz_mod_poly_t result, const fmpz_mod_poly_t input, ulong inflation, const fmpz_mod_ctx_t ctx) noexcept - # Sets ``result`` to the inflated polynomial `p(x^n)` where - # `p` is given by ``input`` and `n` is given by ``inflation``. - void fmpz_mod_poly_deflate(fmpz_mod_poly_t result, const fmpz_mod_poly_t input, ulong deflation, const fmpz_mod_ctx_t ctx) noexcept - # Sets ``result`` to the deflated polynomial `p(x^{1/n})` where - # `p` is given by ``input`` and `n` is given by ``deflation``. - # Requires `n > 0`. - ulong fmpz_mod_poly_deflation(const fmpz_mod_poly_t input, const fmpz_mod_ctx_t ctx) noexcept - # Returns the largest integer by which ``input`` can be deflated. - # As special cases, returns 0 if ``input`` is the zero polynomial - # and 1 of ``input`` is a constant polynomial. - void fmpz_mod_berlekamp_massey_init(fmpz_mod_berlekamp_massey_t B, const fmpz_mod_ctx_t ctx) noexcept - # Initialize ``B`` with an empty stream. - void fmpz_mod_berlekamp_massey_clear(fmpz_mod_berlekamp_massey_t B, const fmpz_mod_ctx_t ctx) noexcept - # Free any space used by ``B``. - void fmpz_mod_berlekamp_massey_start_over(fmpz_mod_berlekamp_massey_t B, const fmpz_mod_ctx_t ctx) noexcept - # Empty the stream of points in ``B``. - void fmpz_mod_berlekamp_massey_add_points(fmpz_mod_berlekamp_massey_t B, const fmpz * a, slong count, const fmpz_mod_ctx_t ctx) noexcept void fmpz_mod_berlekamp_massey_add_zeros(fmpz_mod_berlekamp_massey_t B, slong count, const fmpz_mod_ctx_t ctx) noexcept void fmpz_mod_berlekamp_massey_add_point(fmpz_mod_berlekamp_massey_t B, const fmpz_t a, const fmpz_mod_ctx_t ctx) noexcept - # Add point(s) to the stream processed by ``B``. The addition of any number of points will not update the `V` and `R` polynomial. - int fmpz_mod_berlekamp_massey_reduce(fmpz_mod_berlekamp_massey_t B, const fmpz_mod_ctx_t ctx) noexcept - # Ensure that the polynomials `V` and `R` are up to date. The return value is ``1`` if this function changed `V` and ``0`` otherwise. - # For example, if this function is called twice in a row without adding any points in between, the return of the second call should be ``0``. - # As another example, suppose the object is emptied, the points `1, 1, 2, 3` are added, then reduce is called. This reduce should return ``1`` with `\deg(R) < \deg(V) = 2` because the Fibonacci sequence has been recognized. The further addition of the two points `5, 8` and a reduce will result in a return value of ``0``. - slong fmpz_mod_berlekamp_massey_point_count(const fmpz_mod_berlekamp_massey_t B) noexcept - # Return the number of points stored in ``B``. - const fmpz * fmpz_mod_berlekamp_massey_points(const fmpz_mod_berlekamp_massey_t B) noexcept - # Return a pointer the array of points stored in ``B``. This may be ``NULL`` if func::fmpz_mod_berlekamp_massey_point_count returns ``0``. - const fmpz_mod_poly_struct * fmpz_mod_berlekamp_massey_V_poly(const fmpz_mod_berlekamp_massey_t B) noexcept - # Return the polynomial ``V`` in ``B``. - const fmpz_mod_poly_struct * fmpz_mod_berlekamp_massey_R_poly(const fmpz_mod_berlekamp_massey_t B) noexcept - # Return the polynomial ``R`` in ``B``. diff --git a/src/sage/libs/flint/fmpz_mod_poly_factor.pxd b/src/sage/libs/flint/fmpz_mod_poly_factor.pxd index ea31fd0424f..312ceb175c9 100644 --- a/src/sage/libs/flint/fmpz_mod_poly_factor.pxd +++ b/src/sage/libs/flint/fmpz_mod_poly_factor.pxd @@ -2,7 +2,9 @@ # distutils: depends = flint/fmpz_mod_poly_factor.h ################################################################################ -# This file is auto-generated. Do not modify by hand +# This file is auto-generated by the script +# SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py. +# Do not modify by hand! Fix and rerun the script instead. ################################################################################ from libc.stdio cimport FILE @@ -11,145 +13,32 @@ from sage.libs.mpfr.types cimport * from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void fmpz_mod_poly_factor_init(fmpz_mod_poly_factor_t fac, const fmpz_mod_ctx_t ctx) noexcept - # Initialises ``fac`` for use. - void fmpz_mod_poly_factor_clear(fmpz_mod_poly_factor_t fac, const fmpz_mod_ctx_t ctx) noexcept - # Frees all memory associated with ``fac``. - void fmpz_mod_poly_factor_realloc(fmpz_mod_poly_factor_t fac, slong alloc, const fmpz_mod_ctx_t ctx) noexcept - # Reallocates the factor structure to provide space for - # precisely ``alloc`` factors. - void fmpz_mod_poly_factor_fit_length(fmpz_mod_poly_factor_t fac, slong len, const fmpz_mod_ctx_t ctx) noexcept - # Ensures that the factor structure has space for at - # least ``len`` factors. This function takes care - # of the case of repeated calls by always at least - # doubling the number of factors the structure can hold. - void fmpz_mod_poly_factor_set(fmpz_mod_poly_factor_t res, const fmpz_mod_poly_factor_t fac, const fmpz_mod_ctx_t ctx) noexcept - # Sets ``res`` to the same factorisation as ``fac``. - void fmpz_mod_poly_factor_print(const fmpz_mod_poly_factor_t fac, const fmpz_mod_ctx_t ctx) noexcept - # Prints the entries of ``fac`` to standard output. - void fmpz_mod_poly_factor_insert(fmpz_mod_poly_factor_t fac, const fmpz_mod_poly_t poly, slong exp, const fmpz_mod_ctx_t ctx) noexcept - # Inserts the factor ``poly`` with multiplicity ``exp`` into - # the factorisation ``fac``. - # If ``fac`` already contains ``poly``, then ``exp`` simply - # gets added to the exponent of the existing entry. - void fmpz_mod_poly_factor_concat(fmpz_mod_poly_factor_t res, const fmpz_mod_poly_factor_t fac, const fmpz_mod_ctx_t ctx) noexcept - # Concatenates two factorisations. - # This is equivalent to calling :func:`fmpz_mod_poly_factor_insert` - # repeatedly with the individual factors of ``fac``. - # Does not support aliasing between ``res`` and ``fac``. - void fmpz_mod_poly_factor_pow(fmpz_mod_poly_factor_t fac, slong exp, const fmpz_mod_ctx_t ctx) noexcept - # Raises ``fac`` to the power ``exp``. - bint fmpz_mod_poly_is_irreducible(const fmpz_mod_poly_t f, const fmpz_mod_ctx_t ctx) noexcept - # Returns 1 if the polynomial ``f`` is irreducible, otherwise returns 0. - bint fmpz_mod_poly_is_irreducible_ddf(const fmpz_mod_poly_t f, const fmpz_mod_ctx_t ctx) noexcept - # Returns 1 if the polynomial ``f`` is irreducible, otherwise returns 0. - # Uses fast distinct-degree factorisation. - bint fmpz_mod_poly_is_irreducible_rabin(const fmpz_mod_poly_t f, const fmpz_mod_ctx_t ctx) noexcept - # Returns 1 if the polynomial ``f`` is irreducible, otherwise returns 0. - # Uses Rabin irreducibility test. - bint fmpz_mod_poly_is_irreducible_rabin_f(fmpz_t r, const fmpz_mod_poly_t f, const fmpz_mod_ctx_t ctx) noexcept - # Either sets `r` to `1` and returns 1 if the polynomial ``f`` is - # irreducible or `0` otherwise, or sets `r` to a nontrivial factor of - # `p`. - # This algorithm correctly determines whether `f` is irreducible over - # `\mathbb{Z}/p\mathbb{Z}`, even for composite `f`, or it finds a factor - # of `p`. - bint _fmpz_mod_poly_is_squarefree(const fmpz * f, slong len, const fmpz_mod_ctx_t ctx) noexcept - # Returns 1 if ``(f, len)`` is squarefree, and 0 otherwise. As a - # special case, the zero polynomial is not considered squarefree. - # There are no restrictions on the length. - bint _fmpz_mod_poly_is_squarefree_f(fmpz_t fac, const fmpz * f, slong len, const fmpz_mod_ctx_t ctx) noexcept - # If `fac` returns with the value `1` then the function operates as per - # :func:`_fmpz_mod_poly_is_squarefree`, otherwise `f` is set to a nontrivial - # factor of `p`. - bint fmpz_mod_poly_is_squarefree(const fmpz_mod_poly_t f, const fmpz_mod_ctx_t ctx) noexcept - # Returns 1 if ``f`` is squarefree, and 0 otherwise. As a special - # case, the zero polynomial is not considered squarefree. - bint fmpz_mod_poly_is_squarefree_f(fmpz_t fac, const fmpz_mod_poly_t f, const fmpz_mod_ctx_t ctx) noexcept - # If `fac` returns with the value `1` then the function operates as per - # :func:`fmpz_mod_poly_is_squarefree`, otherwise `f` is set to a nontrivial - # factor of `p`. - bint fmpz_mod_poly_factor_equal_deg_prob(fmpz_mod_poly_t factor, flint_rand_t state, const fmpz_mod_poly_t pol, slong d, const fmpz_mod_ctx_t ctx) noexcept - # Probabilistic equal degree factorisation of ``pol`` into - # irreducible factors of degree ``d``. If it passes, a factor is - # placed in ``factor`` and 1 is returned, otherwise 0 is returned and - # the value of factor is undetermined. - # Requires that ``pol`` be monic, non-constant and squarefree. - void fmpz_mod_poly_factor_equal_deg(fmpz_mod_poly_factor_t factors, const fmpz_mod_poly_t pol, slong d, const fmpz_mod_ctx_t ctx) noexcept - # Assuming ``pol`` is a product of irreducible factors all of - # degree ``d``, finds all those factors and places them in factors. - # Requires that ``pol`` be monic, non-constant and squarefree. - - void fmpz_mod_poly_factor_distinct_deg(fmpz_mod_poly_factor_t res, const fmpz_mod_poly_t poly, slong * const *degs, const fmpz_mod_ctx_t ctx) noexcept - # Factorises a monic non-constant squarefree polynomial ``poly`` - # of degree `n` into factors `f[d]` such that for `1 \leq d \leq n` - # `f[d]` is the product of the monic irreducible factors of ``poly`` - # of degree `d`. Factors `f[d]` are stored in ``res``, and the degree `d` - # of the irreducible factors is stored in ``degs`` in the same order - # as the factors. - # Requires that ``degs`` has enough space for `(n/2)+1 * sizeof(slong)`. - - void fmpz_mod_poly_factor_distinct_deg_threaded(fmpz_mod_poly_factor_t res, const fmpz_mod_poly_t poly, slong * const *degs, const fmpz_mod_ctx_t ctx) noexcept - # Multithreaded version of :func:`fmpz_mod_poly_factor_distinct_deg`. - + void fmpz_mod_poly_factor_distinct_deg(fmpz_mod_poly_factor_t res, const fmpz_mod_poly_t poly, slong * const * degs, const fmpz_mod_ctx_t ctx) noexcept + void fmpz_mod_poly_factor_distinct_deg_threaded(fmpz_mod_poly_factor_t res, const fmpz_mod_poly_t poly, slong * const * degs, const fmpz_mod_ctx_t ctx) noexcept void fmpz_mod_poly_factor_squarefree(fmpz_mod_poly_factor_t res, const fmpz_mod_poly_t f, const fmpz_mod_ctx_t ctx) noexcept - # Sets ``res`` to a squarefree factorization of ``f``. - void fmpz_mod_poly_factor(fmpz_mod_poly_factor_t res, const fmpz_mod_poly_t f, const fmpz_mod_ctx_t ctx) noexcept - # Factorises a non-constant polynomial ``f`` into monic irreducible - # factors choosing the best algorithm for given modulo and degree. - # Choice is based on heuristic measurements. - void fmpz_mod_poly_factor_cantor_zassenhaus(fmpz_mod_poly_factor_t res, const fmpz_mod_poly_t f, const fmpz_mod_ctx_t ctx) noexcept - # Factorises a non-constant polynomial ``f`` into monic irreducible - # factors using the Cantor-Zassenhaus algorithm. - void fmpz_mod_poly_factor_kaltofen_shoup(fmpz_mod_poly_factor_t res, const fmpz_mod_poly_t poly, const fmpz_mod_ctx_t ctx) noexcept - # Factorises a non-constant polynomial ``poly`` into monic irreducible - # factors using the fast version of Cantor-Zassenhaus algorithm proposed by - # Kaltofen and Shoup (1998). More precisely this algorithm uses a - # baby step/giant step strategy for the distinct-degree factorization - # step. If :func:`flint_get_num_threads` is greater than one - # :func:`fmpz_mod_poly_factor_distinct_deg_threaded` is used. - void fmpz_mod_poly_factor_berlekamp(fmpz_mod_poly_factor_t factors, const fmpz_mod_poly_t f, const fmpz_mod_ctx_t ctx) noexcept - # Factorises a non-constant polynomial ``f`` into monic irreducible - # factors using the Berlekamp algorithm. - - void _fmpz_mod_poly_interval_poly_worker(void* arg_ptr) noexcept - # Worker function to compute interval polynomials in distinct degree - # factorisation. Input/output is stored in - # :type:`fmpz_mod_poly_interval_poly_arg_t`. - + void _fmpz_mod_poly_interval_poly_worker(void * arg_ptr) noexcept void fmpz_mod_poly_roots(fmpz_mod_poly_factor_t r, const fmpz_mod_poly_t f, int with_multiplicity, const fmpz_mod_ctx_t ctx) noexcept - # Fill `r` with factors of the form `x - r_i` where the `r_i` are the distinct roots of a nonzero `f` in `Z/pZ`. - # It is expected and not checked that the modulus of `ctx` is prime. - # If `with\_multiplicity` is zero, the exponent `e_i` of the factor `x - r_i` is `1`. Otherwise, it is the largest `e_i` such that `(x-r_i)^e_i` divides `f`. - # This function throws if `f` is zero, but is otherwise always successful. - int fmpz_mod_poly_roots_factored(fmpz_mod_poly_factor_t r, const fmpz_mod_poly_t f, int with_multiplicity, const fmpz_factor_t n, const fmpz_mod_ctx_t ctx) noexcept - # Fill `r` with factors of the form `x - r_i` where the `r_i` are the distinct roots of a nonzero `f` in `Z/nZ`. - # It is expected and not checked that `n` is a prime factorization of the modulus of `ctx`. - # If `with\_multiplicity` is zero, the exponent `e_i` of the factor `x - r_i` is `1`. Otherwise, it is the largest `e_i` such that `(x-r_i)^e_i` divides `f`. - # The roots are first found modulo the primes in `n`, then lifted to the corresponding prime powers, then combined into roots of the original polynomial `f`. - # A return of `1` indicates the function was successful. A return of `0` indicates the function was not able to find the roots, possibly because there are too many of them. - # This function throws if `f` is zero. diff --git a/src/sage/libs/flint/fmpz_mod_vec.pxd b/src/sage/libs/flint/fmpz_mod_vec.pxd index 17c41e9d642..5b1bc0c4715 100644 --- a/src/sage/libs/flint/fmpz_mod_vec.pxd +++ b/src/sage/libs/flint/fmpz_mod_vec.pxd @@ -2,7 +2,9 @@ # distutils: depends = flint/fmpz_mod_vec.h ################################################################################ -# This file is auto-generated. Do not modify by hand +# This file is auto-generated by the script +# SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py. +# Do not modify by hand! Fix and rerun the script instead. ################################################################################ from libc.stdio cimport FILE @@ -11,34 +13,13 @@ from sage.libs.mpfr.types cimport * from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void _fmpz_mod_vec_set_fmpz_vec(fmpz * A, const fmpz * B, slong len, const fmpz_mod_ctx_t ctx) noexcept - # Set the `fmpz_mod_vec` `(A, len)` to the `fmpz_vec` `(B, len)` after - # reduction of each entry modulo the modulus.. - void _fmpz_mod_vec_neg(fmpz * A, const fmpz * B, slong len, const fmpz_mod_ctx_t ctx) noexcept - # Set `(A, len)` to `-(B, len)`. - void _fmpz_mod_vec_add(fmpz * a, const fmpz * b, const fmpz * c, slong n, const fmpz_mod_ctx_t ctx) noexcept - # Set (A, len)` to `(B, len) + (C, len)`. - void _fmpz_mod_vec_sub(fmpz * a, const fmpz * b, const fmpz * c, slong n, const fmpz_mod_ctx_t ctx) noexcept - # Set (A, len)` to `(B, len) - (C, len)`. - void _fmpz_mod_vec_scalar_mul_fmpz_mod(fmpz * A, const fmpz * B, slong len, const fmpz_t c, const fmpz_mod_ctx_t ctx) noexcept - # Set `(A, len)` to `(B, len)*c`. - void _fmpz_mod_vec_scalar_addmul_fmpz_mod(fmpz * A, const fmpz * B, slong len, const fmpz_t c, const fmpz_mod_ctx_t ctx) noexcept - # Set `(A, len)` to `(A, len) + (B, len)*c`. - void _fmpz_mod_vec_scalar_div_fmpz_mod(fmpz * A, const fmpz * B, slong len, const fmpz_t c, const fmpz_mod_ctx_t ctx) noexcept - # Set `(A, len)` to `(B, len)/c` assuming `c` is nonzero. - void _fmpz_mod_vec_dot(fmpz_t d, const fmpz * A, const fmpz * B, slong len, const fmpz_mod_ctx_t ctx) noexcept - # Set `d` to the dot product of `(A, len)` with `(B, len)`. - void _fmpz_mod_vec_dot_rev(fmpz_t d, const fmpz * A, const fmpz * B, slong len, const fmpz_mod_ctx_t ctx) noexcept - # Set `d` to the dot product of `(A, len)` with the reverse of the vector `(B, len)`. - void _fmpz_mod_vec_mul(fmpz * A, const fmpz * B, const fmpz * C, slong len, const fmpz_mod_ctx_t ctx) noexcept - # Set `(A, len)` the pointwise multiplication of `(B, len)` and `(C, len)`. diff --git a/src/sage/libs/flint/fmpz_mpoly.pxd b/src/sage/libs/flint/fmpz_mpoly.pxd index 6d69d64ab5f..0cc6dd108bd 100644 --- a/src/sage/libs/flint/fmpz_mpoly.pxd +++ b/src/sage/libs/flint/fmpz_mpoly.pxd @@ -2,7 +2,9 @@ # distutils: depends = flint/fmpz_mpoly.h ################################################################################ -# This file is auto-generated. Do not modify by hand +# This file is auto-generated by the script +# SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py. +# Do not modify by hand! Fix and rerun the script instead. ################################################################################ from libc.stdio cimport FILE @@ -11,231 +13,90 @@ from sage.libs.mpfr.types cimport * from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void fmpz_mpoly_ctx_init(fmpz_mpoly_ctx_t ctx, slong nvars, const ordering_t ord) noexcept - # Initialise a context object for a polynomial ring with the given number of variables and the given ordering. - # The possibilities for the ordering are ``ORD_LEX``, ``ORD_DEGLEX`` and ``ORD_DEGREVLEX``. - slong fmpz_mpoly_ctx_nvars(const fmpz_mpoly_ctx_t ctx) noexcept - # Return the number of variables used to initialize the context. - ordering_t fmpz_mpoly_ctx_ord(const fmpz_mpoly_ctx_t ctx) noexcept - # Return the ordering used to initialize the context. - void fmpz_mpoly_ctx_clear(fmpz_mpoly_ctx_t ctx) noexcept - # Release up any space allocated by *ctx*. - void fmpz_mpoly_init(fmpz_mpoly_t A, const fmpz_mpoly_ctx_t ctx) noexcept - # Initialise *A* for use with the given and initialised context object. Its value is set to zero. - void fmpz_mpoly_init2(fmpz_mpoly_t A, slong alloc, const fmpz_mpoly_ctx_t ctx) noexcept - # Initialise *A* for use with the given and initialised context object. Its value is set to zero. - # It is allocated with space for *alloc* terms and at least ``MPOLY_MIN_BITS`` bits for the exponents. - void fmpz_mpoly_init3(fmpz_mpoly_t A, slong alloc, flint_bitcnt_t bits, const fmpz_mpoly_ctx_t ctx) noexcept - # Initialise *A* for use with the given and initialised context object. Its value is set to zero. - # It is allocated with space for *alloc* terms and *bits* bits for the exponents. - void fmpz_mpoly_fit_length(fmpz_mpoly_t A, slong len, const fmpz_mpoly_ctx_t ctx) noexcept - # Ensure that *A* has space for at least *len* terms. - void fmpz_mpoly_fit_bits(fmpz_mpoly_t A, flint_bitcnt_t bits, const fmpz_mpoly_ctx_t ctx) noexcept - # Ensure that the exponent fields of *A* have at least *bits* bits. - void fmpz_mpoly_realloc(fmpz_mpoly_t A, slong alloc, const fmpz_mpoly_ctx_t ctx) noexcept - # Reallocate *A* to have space for *alloc* terms. - # Assumes the current length of the polynomial is not greater than *alloc*. - void fmpz_mpoly_clear(fmpz_mpoly_t A, const fmpz_mpoly_ctx_t ctx) noexcept - # Release any space allocated for *A*. - char * fmpz_mpoly_get_str_pretty(const fmpz_mpoly_t A, const char ** x, const fmpz_mpoly_ctx_t ctx) noexcept - # Return a string, which the user is responsible for cleaning up, representing *A*, given an array of variable strings *x*. - int fmpz_mpoly_fprint_pretty(FILE * file, const fmpz_mpoly_t A, const char ** x, const fmpz_mpoly_ctx_t ctx) noexcept - # Print a string representing *A* to *file*. - int fmpz_mpoly_print_pretty(const fmpz_mpoly_t A, const char ** x, const fmpz_mpoly_ctx_t ctx) noexcept - # Print a string representing *A* to ``stdout``. - int fmpz_mpoly_set_str_pretty(fmpz_mpoly_t A, const char * str, const char ** x, const fmpz_mpoly_ctx_t ctx) noexcept - # Set *A* to the polynomial in the null-terminates string *str* given an array *x* of variable strings. - # If parsing *str* fails, *A* is set to zero, and `-1` is returned. Otherwise, `0` is returned. - # The operations ``+``, ``-``, ``*``, and ``/`` are permitted along with integers and the variables in *x*. The character ``^`` must be immediately followed by the (integer) exponent. - # If any division is not exact, parsing fails. - void fmpz_mpoly_gen(fmpz_mpoly_t A, slong var, const fmpz_mpoly_ctx_t ctx) noexcept - # Set *A* to the variable of index *var*, where `var = 0` corresponds to the variable with the most significance with respect to the ordering. - bint fmpz_mpoly_is_gen(const fmpz_mpoly_t A, slong var, const fmpz_mpoly_ctx_t ctx) noexcept - # If `var \ge 0`, return `1` if *A* is equal to the `var`-th generator, otherwise return `0`. - # If `var < 0`, return `1` if the polynomial is equal to any generator, otherwise return `0`. - void fmpz_mpoly_set(fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_mpoly_ctx_t ctx) noexcept - # Set *A* to *B*. - bint fmpz_mpoly_equal(const fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_mpoly_ctx_t ctx) noexcept - # Return `1` if *A* is equal to *B*, else return `0`. - void fmpz_mpoly_swap(fmpz_mpoly_t poly1, fmpz_mpoly_t poly2, const fmpz_mpoly_ctx_t ctx) noexcept - # Efficiently swap *A* and *B*. - int _fmpz_mpoly_fits_small(const fmpz * poly, slong len) noexcept - # Return 1 if the array of coefficients of length *len* consists - # entirely of values that are small ``fmpz`` values, i.e. of at most - # ``FLINT_BITS - 2`` bits plus a sign bit. - slong fmpz_mpoly_max_bits(const fmpz_mpoly_t A) noexcept - # Computes the maximum number of bits `b` required to represent the absolute - # values of the coefficients of *A*. If all of the coefficients are - # positive, `b` is returned, otherwise `-b` is returned. - bint fmpz_mpoly_is_fmpz(const fmpz_mpoly_t A, const fmpz_mpoly_ctx_t ctx) noexcept - # Return `1` if *A* is a constant, else return `0`. - void fmpz_mpoly_get_fmpz(fmpz_t c, const fmpz_mpoly_t A, const fmpz_mpoly_ctx_t ctx) noexcept - # Assuming that *A* is a constant, set *c* to this constant. - # This function throws if *A* is not a constant. - void fmpz_mpoly_set_fmpz(fmpz_mpoly_t A, const fmpz_t c, const fmpz_mpoly_ctx_t ctx) noexcept void fmpz_mpoly_set_ui(fmpz_mpoly_t A, ulong c, const fmpz_mpoly_ctx_t ctx) noexcept void fmpz_mpoly_set_si(fmpz_mpoly_t A, slong c, const fmpz_mpoly_ctx_t ctx) noexcept - # Set *A* to the constant *c*. - void fmpz_mpoly_zero(fmpz_mpoly_t A, const fmpz_mpoly_ctx_t ctx) noexcept - # Set *A* to the constant `0`. - void fmpz_mpoly_one(fmpz_mpoly_t A, const fmpz_mpoly_ctx_t ctx) noexcept - # Set *A* to the constant `1`. - bint fmpz_mpoly_equal_fmpz(const fmpz_mpoly_t A, const fmpz_t c, const fmpz_mpoly_ctx_t ctx) noexcept bint fmpz_mpoly_equal_ui(const fmpz_mpoly_t A, ulong c, const fmpz_mpoly_ctx_t ctx) noexcept bint fmpz_mpoly_equal_si(const fmpz_mpoly_t A, slong c, const fmpz_mpoly_ctx_t ctx) noexcept - # Return `1` if *A* is equal to the constant *c*, else return `0`. - bint fmpz_mpoly_is_zero(const fmpz_mpoly_t A, const fmpz_mpoly_ctx_t ctx) noexcept - # Return `1` if *A* is the constant `0`, else return `0`. - bint fmpz_mpoly_is_one(const fmpz_mpoly_t A, const fmpz_mpoly_ctx_t ctx) noexcept - # Return `1` if *A* is the constant `1`, else return `0`. - int fmpz_mpoly_degrees_fit_si(const fmpz_mpoly_t A, const fmpz_mpoly_ctx_t ctx) noexcept - # Return `1` if the degrees of *A* with respect to each variable fit into an ``slong``, otherwise return `0`. - void fmpz_mpoly_degrees_fmpz(fmpz ** degs, const fmpz_mpoly_t A, const fmpz_mpoly_ctx_t ctx) noexcept void fmpz_mpoly_degrees_si(slong * degs, const fmpz_mpoly_t A, const fmpz_mpoly_ctx_t ctx) noexcept - # Set *degs* to the degrees of *A* with respect to each variable. - # If *A* is zero, all degrees are set to `-1`. - void fmpz_mpoly_degree_fmpz(fmpz_t deg, const fmpz_mpoly_t A, slong var, const fmpz_mpoly_ctx_t ctx) noexcept slong fmpz_mpoly_degree_si(const fmpz_mpoly_t A, slong var, const fmpz_mpoly_ctx_t ctx) noexcept - # Either return or set *deg* to the degree of *A* with respect to the variable of index *var*. - # If *A* is zero, the degree is defined to be `-1`. - int fmpz_mpoly_total_degree_fits_si(const fmpz_mpoly_t A, const fmpz_mpoly_ctx_t ctx) noexcept - # Return `1` if the total degree of *A* fits into an ``slong``, otherwise return `0`. - void fmpz_mpoly_total_degree_fmpz(fmpz_t tdeg, const fmpz_mpoly_t A, const fmpz_mpoly_ctx_t ctx) noexcept slong fmpz_mpoly_total_degree_si(const fmpz_mpoly_t A, const fmpz_mpoly_ctx_t ctx) noexcept - # Either return or set *tdeg* to the total degree of *A*. - # If *A* is zero, the total degree is defined to be `-1`. - void fmpz_mpoly_used_vars(int * used, const fmpz_mpoly_t A, const fmpz_mpoly_ctx_t ctx) noexcept - # For each variable index *i*, set ``used[i]`` to nonzero if the variable of index *i* appears in *A* and to zero otherwise. - void fmpz_mpoly_get_coeff_fmpz_monomial(fmpz_t c, const fmpz_mpoly_t A, const fmpz_mpoly_t M, const fmpz_mpoly_ctx_t ctx) noexcept - # Assuming that *M* is a monomial, set *c* to the coefficient of the corresponding monomial in *A*. - # This function throws if *M* is not a monomial. - void fmpz_mpoly_set_coeff_fmpz_monomial(fmpz_mpoly_t poly, const fmpz_t c, const fmpz_mpoly_t poly2, const fmpz_mpoly_ctx_t ctx) noexcept - # Assuming that *M* is a monomial, set the coefficient of the corresponding monomial in *A* to *c*. - # This function throws if *M* is not a monomial. - void fmpz_mpoly_get_coeff_fmpz_fmpz(fmpz_t c, const fmpz_mpoly_t A, fmpz * const * exp, const fmpz_mpoly_ctx_t ctx) noexcept ulong fmpz_mpoly_get_coeff_ui_fmpz(const fmpz_mpoly_t A, fmpz * const * exp, const fmpz_mpoly_ctx_t ctx) noexcept slong fmpz_mpoly_get_coeff_si_fmpz(const fmpz_mpoly_t A, fmpz * const * exp, const fmpz_mpoly_ctx_t ctx) noexcept void fmpz_mpoly_get_coeff_fmpz_ui(fmpz_t c, const fmpz_mpoly_t A, const ulong * exp, const fmpz_mpoly_ctx_t ctx) noexcept ulong fmpz_mpoly_get_coeff_ui_ui(const fmpz_mpoly_t A, const ulong * exp, const fmpz_mpoly_ctx_t ctx) noexcept slong fmpz_mpoly_get_coeff_si_ui(const fmpz_mpoly_t A, const ulong * exp, const fmpz_mpoly_ctx_t ctx) noexcept - # Either return or set *c* to the coefficient of the monomial with exponent vector *exp*. - void fmpz_mpoly_set_coeff_fmpz_fmpz(fmpz_mpoly_t A, const fmpz_t c, fmpz * const * exp, const fmpz_mpoly_ctx_t ctx) noexcept void fmpz_mpoly_set_coeff_ui_fmpz(fmpz_mpoly_t A, ulong c, fmpz * const * exp, const fmpz_mpoly_ctx_t ctx) noexcept void fmpz_mpoly_set_coeff_si_fmpz(fmpz_mpoly_t A, slong c, fmpz * const * exp, const fmpz_mpoly_ctx_t ctx) noexcept void fmpz_mpoly_set_coeff_fmpz_ui(fmpz_mpoly_t A, const fmpz_t c, const ulong * exp, const fmpz_mpoly_ctx_t ctx) noexcept void fmpz_mpoly_set_coeff_ui_ui(fmpz_mpoly_t A, ulong c, const ulong * exp, const fmpz_mpoly_ctx_t ctx) noexcept void fmpz_mpoly_set_coeff_si_ui(fmpz_mpoly_t A, slong c, const ulong * exp, const fmpz_mpoly_ctx_t ctx) noexcept - # Set the coefficient of the monomial with exponent vector *exp* to *c*. - void fmpz_mpoly_get_coeff_vars_ui(fmpz_mpoly_t C, const fmpz_mpoly_t A, const slong * vars, const ulong * exps, slong length, const fmpz_mpoly_ctx_t ctx) noexcept - # Set *C* to the coefficient of *A* with respect to the variables in *vars* with powers in the corresponding array *exps*. - # Both *vars* and *exps* point to array of length *length*. It is assumed that `0 < length \le nvars(A)` and that the variables in *vars* are distinct. - int fmpz_mpoly_cmp(const fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_mpoly_ctx_t ctx) noexcept - # Return `1` (resp. `-1`, or `0`) if *A* is after (resp. before, same as) *B* in some arbitrary but fixed total ordering of the polynomials. - # This ordering agrees with the usual ordering of monomials when *A* and *B* are both monomials. - bint fmpz_mpoly_is_fmpz_poly(const fmpz_mpoly_t A, slong var, const fmpz_mpoly_ctx_t ctx) noexcept - # Return whether *A* is a univariate polynomial in the variable with index *var*. - int fmpz_mpoly_get_fmpz_poly(fmpz_poly_t A, const fmpz_mpoly_t B, slong var, const fmpz_mpoly_ctx_t ctx) noexcept - # If *B* is a univariate polynomial in the variable with index *var*, - # set *A* to this polynomial and return 1; otherwise return 0. - void fmpz_mpoly_set_fmpz_poly(fmpz_mpoly_t A, const fmpz_poly_t B, slong var, const fmpz_mpoly_ctx_t ctx) noexcept void fmpz_mpoly_set_gen_fmpz_poly(fmpz_mpoly_t A, slong var, const fmpz_poly_t B, const fmpz_mpoly_ctx_t ctx) noexcept - # Set *A* to the univariate polynomial *B* in the variable with index *var*. - fmpz * fmpz_mpoly_term_coeff_ref(fmpz_mpoly_t A, slong i, const fmpz_mpoly_ctx_t ctx) noexcept - # Return a reference to the coefficient of index *i* of *A*. - bint fmpz_mpoly_is_canonical(const fmpz_mpoly_t A, const fmpz_mpoly_ctx_t ctx) noexcept - # Return `1` if *A* is in canonical form. Otherwise, return `0`. - # To be in canonical form, all of the terms must have nonzero coefficient, and the terms must be sorted from greatest to least. - slong fmpz_mpoly_length(const fmpz_mpoly_t A, const fmpz_mpoly_ctx_t ctx) noexcept - # Return the number of terms in *A*. - # If the polynomial is in canonical form, this will be the number of nonzero coefficients. - void fmpz_mpoly_resize(fmpz_mpoly_t A, slong new_length, const fmpz_mpoly_ctx_t ctx) noexcept - # Set the length of *A* to `new\_length`. - # Terms are either deleted from the end, or new zero terms are appended. - void fmpz_mpoly_get_term_coeff_fmpz(fmpz_t c, const fmpz_mpoly_t A, slong i, const fmpz_mpoly_ctx_t ctx) noexcept ulong fmpz_mpoly_get_term_coeff_ui(const fmpz_mpoly_t A, slong i, const fmpz_mpoly_ctx_t ctx) noexcept slong fmpz_mpoly_get_term_coeff_si(const fmpz_mpoly_t poly, slong i, const fmpz_mpoly_ctx_t ctx) noexcept - # Either return or set *c* to the coefficient of the term of index *i*. - void fmpz_mpoly_set_term_coeff_fmpz(fmpz_mpoly_t A, slong i, const fmpz_t c, const fmpz_mpoly_ctx_t ctx) noexcept void fmpz_mpoly_set_term_coeff_ui(fmpz_mpoly_t A, slong i, ulong c, const fmpz_mpoly_ctx_t ctx) noexcept void fmpz_mpoly_set_term_coeff_si(fmpz_mpoly_t A, slong i, slong c, const fmpz_mpoly_ctx_t ctx) noexcept - # Set the coefficient of the term of index *i* to *c*. - int fmpz_mpoly_term_exp_fits_si(const fmpz_mpoly_t poly, slong i, const fmpz_mpoly_ctx_t ctx) noexcept int fmpz_mpoly_term_exp_fits_ui(const fmpz_mpoly_t poly, slong i, const fmpz_mpoly_ctx_t ctx) noexcept - # Return `1` if all entries of the exponent vector of the term of index *i* fit into an ``slong`` (resp. a ``ulong``). Otherwise, return `0`. - void fmpz_mpoly_get_term_exp_fmpz(fmpz ** exp, const fmpz_mpoly_t A, slong i, const fmpz_mpoly_ctx_t ctx) noexcept void fmpz_mpoly_get_term_exp_ui(ulong * exp, const fmpz_mpoly_t A, slong i, const fmpz_mpoly_ctx_t ctx) noexcept void fmpz_mpoly_get_term_exp_si(slong * exp, const fmpz_mpoly_t A, slong i, const fmpz_mpoly_ctx_t ctx) noexcept - # Set *exp* to the exponent vector of the term of index *i*. - # The ``_ui`` (resp. ``_si``) version throws if any entry does not fit into a ``ulong`` (resp. ``slong``). - ulong fmpz_mpoly_get_term_var_exp_ui(const fmpz_mpoly_t A, slong i, slong var, const fmpz_mpoly_ctx_t ctx) noexcept slong fmpz_mpoly_get_term_var_exp_si(const fmpz_mpoly_t A, slong i, slong var, const fmpz_mpoly_ctx_t ctx) noexcept - # Return the exponent of the variable `var` of the term of index *i*. - # This function throws if the exponent does not fit into a ``ulong`` (resp. ``slong``). - void fmpz_mpoly_set_term_exp_fmpz(fmpz_mpoly_t A, slong i, fmpz * const * exp, const fmpz_mpoly_ctx_t ctx) noexcept void fmpz_mpoly_set_term_exp_ui(fmpz_mpoly_t A, slong i, const ulong * exp, const fmpz_mpoly_ctx_t ctx) noexcept - # Set the exponent vector of the term of index *i* to *exp*. - void fmpz_mpoly_get_term(fmpz_mpoly_t M, const fmpz_mpoly_t A, slong i, const fmpz_mpoly_ctx_t ctx) noexcept - # Set `M` to the term of index *i* in *A*. - void fmpz_mpoly_get_term_monomial(fmpz_mpoly_t M, const fmpz_mpoly_t A, slong i, const fmpz_mpoly_ctx_t ctx) noexcept - # Set `M` to the monomial of the term of index *i* in *A*. The coefficient of `M` will be one. - void fmpz_mpoly_push_term_fmpz_fmpz(fmpz_mpoly_t A, const fmpz_t c, fmpz * const * exp, const fmpz_mpoly_ctx_t ctx) noexcept void fmpz_mpoly_push_term_fmpz_ffmpz(fmpz_mpoly_t A, const fmpz_t c, const fmpz * exp, const fmpz_mpoly_ctx_t ctx) noexcept void fmpz_mpoly_push_term_ui_fmpz(fmpz_mpoly_t A, ulong c, fmpz * const * exp, const fmpz_mpoly_ctx_t ctx) noexcept @@ -245,466 +106,117 @@ cdef extern from "flint_wrap.h": void fmpz_mpoly_push_term_fmpz_ui(fmpz_mpoly_t A, const fmpz_t c, const ulong * exp, const fmpz_mpoly_ctx_t ctx) noexcept void fmpz_mpoly_push_term_ui_ui(fmpz_mpoly_t A, ulong c, const ulong * exp, const fmpz_mpoly_ctx_t ctx) noexcept void fmpz_mpoly_push_term_si_ui(fmpz_mpoly_t A, slong c, const ulong * exp, const fmpz_mpoly_ctx_t ctx) noexcept - # Append a term to *A* with coefficient *c* and exponent vector *exp*. - # This function runs in constant average time. - void fmpz_mpoly_sort_terms(fmpz_mpoly_t A, const fmpz_mpoly_ctx_t ctx) noexcept - # Sort the terms of *A* into the canonical ordering dictated by the ordering in *ctx*. - # This function simply reorders the terms: It does not combine like terms, nor does it delete terms with coefficient zero. - # This function runs in linear time in the size of *A*. - void fmpz_mpoly_combine_like_terms(fmpz_mpoly_t A, const fmpz_mpoly_ctx_t ctx) noexcept - # Combine adjacent like terms in *A* and delete terms with coefficient zero. - # If the terms of *A* were sorted to begin with, the result will be in canonical form. - # This function runs in linear time in the size of *A*. - void fmpz_mpoly_reverse(fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_mpoly_ctx_t ctx) noexcept - # Set *A* to the reversal of *B*. - void fmpz_mpoly_randtest_bound(fmpz_mpoly_t A, flint_rand_t state, slong length, mp_limb_t coeff_bits, ulong exp_bound, const fmpz_mpoly_ctx_t ctx) noexcept - # Generate a random polynomial with length up to *length* and exponents in the range ``[0, exp_bound - 1]``. - # The exponents of each variable are generated by calls to ``n_randint(state, exp_bound)``. - void fmpz_mpoly_randtest_bounds(fmpz_mpoly_t A, flint_rand_t state, slong length, mp_limb_t coeff_bits, ulong * exp_bounds, const fmpz_mpoly_ctx_t ctx) noexcept - # Generate a random polynomial with length up to *length* and exponents in the range ``[0, exp_bounds[i] - 1]``. - # The exponents of the variable of index *i* are generated by calls to ``n_randint(state, exp_bounds[i])``. - void fmpz_mpoly_randtest_bits(fmpz_mpoly_t A, flint_rand_t state, slong length, mp_limb_t coeff_bits, mp_limb_t exp_bits, const fmpz_mpoly_ctx_t ctx) noexcept - # Generate a random polynomial with length up to the given length and exponents whose packed form does not exceed the given bit count. - # The parameter ``coeff_bits`` to the three functions ``fmpz_mpoly_randtest_{bound|bounds|bits}`` is merely a suggestion for the approximate bit count of the resulting signed coefficients. - # The function :func:`fmpz_mpoly_max_bits` will give the exact bit count of the result. - void fmpz_mpoly_add_fmpz(fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_t c, const fmpz_mpoly_ctx_t ctx) noexcept void fmpz_mpoly_add_ui(fmpz_mpoly_t A, const fmpz_mpoly_t B, ulong c, const fmpz_mpoly_ctx_t ctx) noexcept void fmpz_mpoly_add_si(fmpz_mpoly_t A, const fmpz_mpoly_t B, slong c, const fmpz_mpoly_ctx_t ctx) noexcept - # Set *A* to `B + c`. - # If *A* and *B* are aliased, this function will probably run quickly. - void fmpz_mpoly_sub_fmpz(fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_t c, const fmpz_mpoly_ctx_t ctx) noexcept void fmpz_mpoly_sub_ui(fmpz_mpoly_t A, const fmpz_mpoly_t B, ulong c, const fmpz_mpoly_ctx_t ctx) noexcept void fmpz_mpoly_sub_si(fmpz_mpoly_t A, const fmpz_mpoly_t B, slong c, const fmpz_mpoly_ctx_t ctx) noexcept - # Set *A* to `B - c`. - # If *A* and *B* are aliased, this function will probably run quickly. - void fmpz_mpoly_add(fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_mpoly_t C, const fmpz_mpoly_ctx_t ctx) noexcept - # Set *A* to `B + C`. - # If *A* and *B* are aliased, this function might run in time proportional to the size of `C`. - void fmpz_mpoly_sub(fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_mpoly_t C, const fmpz_mpoly_ctx_t ctx) noexcept - # Set *A* to `B - C`. - # If *A* and *B* are aliased, this function might run in time proportional to the size of `C`. - void fmpz_mpoly_neg(fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_mpoly_ctx_t ctx) noexcept - # Set *A* to `-B`. - void fmpz_mpoly_scalar_mul_fmpz(fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_t c, const fmpz_mpoly_ctx_t ctx) noexcept void fmpz_mpoly_scalar_mul_ui(fmpz_mpoly_t A, const fmpz_mpoly_t B, ulong c, const fmpz_mpoly_ctx_t ctx) noexcept void fmpz_mpoly_scalar_mul_si(fmpz_mpoly_t A, const fmpz_mpoly_t B, slong c, const fmpz_mpoly_ctx_t ctx) noexcept - # Set *A* to `B \times c`. - void fmpz_mpoly_scalar_fmma(fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_t c, const fmpz_mpoly_t D, const fmpz_t e, const fmpz_mpoly_ctx_t ctx) noexcept - # Sets *A* to `B \times c + D \times e`. - void fmpz_mpoly_scalar_divexact_fmpz(fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_t c, const fmpz_mpoly_ctx_t ctx) noexcept void fmpz_mpoly_scalar_divexact_ui(fmpz_mpoly_t A, const fmpz_mpoly_t B, ulong c, const fmpz_mpoly_ctx_t ctx) noexcept void fmpz_mpoly_scalar_divexact_si(fmpz_mpoly_t A, const fmpz_mpoly_t B, slong c, const fmpz_mpoly_ctx_t ctx) noexcept - # Set *A* to *B* divided by *c*. The division is assumed to be exact. - int fmpz_mpoly_scalar_divides_fmpz(fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_t c, const fmpz_mpoly_ctx_t ctx) noexcept int fmpz_mpoly_scalar_divides_ui(fmpz_mpoly_t A, const fmpz_mpoly_t B, ulong c, const fmpz_mpoly_ctx_t ctx) noexcept int fmpz_mpoly_scalar_divides_si(fmpz_mpoly_t A, const fmpz_mpoly_t B, slong c, const fmpz_mpoly_ctx_t ctx) noexcept - # If *B* is divisible by *c*, set *A* to the exact quotient and return `1`, otherwise set *A* to zero and return `0`. - void fmpz_mpoly_derivative(fmpz_mpoly_t A, const fmpz_mpoly_t B, slong var, const fmpz_mpoly_ctx_t ctx) noexcept - # Set *A* to the derivative of *B* with respect to the variable of index `var`. - void fmpz_mpoly_integral(fmpz_mpoly_t A, fmpz_t scale, const fmpz_mpoly_t B, slong var, const fmpz_mpoly_ctx_t ctx) noexcept - # Set *A* and *scale* so that *A* is an integral of `scale \times B` with respect to the variable of index *var*, where *scale* is positive and as small as possible. - int fmpz_mpoly_evaluate_all_fmpz(fmpz_t ev, const fmpz_mpoly_t A, fmpz * const * vals, const fmpz_mpoly_ctx_t ctx) noexcept - # Set *ev* to the evaluation of *A* where the variables are replaced by the corresponding elements of the array *vals*. - # Return `1` for success and `0` for failure. - int fmpz_mpoly_evaluate_one_fmpz(fmpz_mpoly_t A, const fmpz_mpoly_t B, slong var, const fmpz_t val, const fmpz_mpoly_ctx_t ctx) noexcept - # Set *A* to the evaluation of *B* where the variable of index *var* is replaced by ``val``. - # Return `1` for success and `0` for failure. - int fmpz_mpoly_compose_fmpz_poly(fmpz_poly_t A, const fmpz_mpoly_t B, fmpz_poly_struct * const * C, const fmpz_mpoly_ctx_t ctxB) noexcept - # Set *A* to the evaluation of *B* where the variables are replaced by the corresponding elements of the array *C*. - # The context object of *B* is *ctxB*. - # Return `1` for success and `0` for failure. - int fmpz_mpoly_compose_fmpz_mpoly_geobucket(fmpz_mpoly_t A, const fmpz_mpoly_t B, fmpz_mpoly_struct * const * C, const fmpz_mpoly_ctx_t ctxB, const fmpz_mpoly_ctx_t ctxAC) noexcept int fmpz_mpoly_compose_fmpz_mpoly_horner(fmpz_mpoly_t A, const fmpz_mpoly_t B, fmpz_mpoly_struct * const * C, const fmpz_mpoly_ctx_t ctxB, const fmpz_mpoly_ctx_t ctxAC) noexcept int fmpz_mpoly_compose_fmpz_mpoly(fmpz_mpoly_t A, const fmpz_mpoly_t B, fmpz_mpoly_struct * const * C, const fmpz_mpoly_ctx_t ctxB, const fmpz_mpoly_ctx_t ctxAC) noexcept - # Set *A* to the evaluation of *B* where the variables are replaced by the corresponding elements of the array *C*. - # Both *A* and the elements of *C* have context object *ctxAC*, while *B* has context object *ctxB*. - # The length of the array *C* is the number of variables in *ctxB*. - # Neither *A* nor *B* is allowed to alias any other polynomial. - # Return `1` for success and `0` for failure. - # The main method attempts to perform the calculation using matrices and chooses heuristically between the ``geobucket`` and ``horner`` methods if needed. - void fmpz_mpoly_compose_fmpz_mpoly_gen(fmpz_mpoly_t A, const fmpz_mpoly_t B, const slong * c, const fmpz_mpoly_ctx_t ctxB, const fmpz_mpoly_ctx_t ctxAC) noexcept - # Set *A* to the evaluation of *B* where the variable of index *i* in *ctxB* is replaced by the variable of index ``c[i]`` in *ctxAC*. - # The length of the array *C* is the number of variables in *ctxB*. - # If any ``c[i]`` is negative, the corresponding variable of *B* is replaced by zero. Otherwise, it is expected that ``c[i]`` is less than the number of variables in *ctxAC*. - void fmpz_mpoly_mul(fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_mpoly_t C, const fmpz_mpoly_ctx_t ctx) noexcept void fmpz_mpoly_mul_threaded(fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_mpoly_t C, const fmpz_mpoly_ctx_t ctx, slong thread_limit) noexcept - # Set *A* to `B \times C`. - void fmpz_mpoly_mul_johnson(fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_mpoly_t C, const fmpz_mpoly_ctx_t ctx) noexcept void fmpz_mpoly_mul_heap_threaded(fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_mpoly_t C, const fmpz_mpoly_ctx_t ctx) noexcept - # Set *A* to `B \times C` using Johnson's heap-based method. - # The first version always uses one thread. - int fmpz_mpoly_mul_array(fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_mpoly_t C, const fmpz_mpoly_ctx_t ctx) noexcept int fmpz_mpoly_mul_array_threaded(fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_mpoly_t C, const fmpz_mpoly_ctx_t ctx) noexcept - # Try to set *A* to `B \times C` using arrays. - # If the return is `0`, the operation was unsuccessful. Otherwise, it was successful and the return is `1`. - # The first version always uses one thread. - int fmpz_mpoly_mul_dense(fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_mpoly_t C, const fmpz_mpoly_ctx_t ctx) noexcept - # Try to set *A* to `B \times C` using dense arithmetic. - # If the return is `0`, the operation was unsuccessful. Otherwise, it was successful and the return is `1`. - int fmpz_mpoly_pow_fmpz(fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_t k, const fmpz_mpoly_ctx_t ctx) noexcept - # Set *A* to *B* raised to the *k*-th power. - # Return `1` for success and `0` for failure. - int fmpz_mpoly_pow_ui(fmpz_mpoly_t A, const fmpz_mpoly_t B, ulong k, const fmpz_mpoly_ctx_t ctx) noexcept - # Set *A* to *B* raised to the *k*-th power. - # Return `1` for success and `0` for failure. - int fmpz_mpoly_divides(fmpz_mpoly_t Q, const fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_mpoly_ctx_t ctx) noexcept - # If *A* is divisible by *B*, set *Q* to the exact quotient and return `1`. Otherwise, set `Q` to zero and return `0`. - void fmpz_mpoly_divrem(fmpz_mpoly_t Q, fmpz_mpoly_t R, const fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_mpoly_ctx_t ctx) noexcept - # Set `Q` and `R` to the quotient and remainder of *A* divided by *B*. The monomials in *R* divisible by the leading monomial of *B* will have coefficients reduced modulo the absolute value of the leading coefficient of *B*. - # Note that this function is not very useful if the leading coefficient *B* is not a unit. - void fmpz_mpoly_quasidivrem(fmpz_t scale, fmpz_mpoly_t Q, fmpz_mpoly_t R, const fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_mpoly_ctx_t ctx) noexcept - # Set *scale*, *Q* and *R* so that *Q* and *R* are the quotient and remainder of `scale \times A` divided by *B*. No monomials in *R* will be divisible by the leading monomial of *B*. - void fmpz_mpoly_div(fmpz_mpoly_t Q, const fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_mpoly_ctx_t ctx) noexcept - # Perform the operation of :func:`fmpz_mpoly_divrem` and discard *R*. - # Note that this function is not very useful if the division is not exact and the leading coefficient *B* is not a unit. - void fmpz_mpoly_quasidiv(fmpz_t scale, fmpz_mpoly_t Q, const fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_mpoly_ctx_t ctx) noexcept - # Perform the operation of :func:`fmpz_mpoly_quasidivrem` and discard *R*. - void fmpz_mpoly_divrem_ideal(fmpz_mpoly_struct ** Q, fmpz_mpoly_t R, const fmpz_mpoly_t A, fmpz_mpoly_struct * const * B, slong len, const fmpz_mpoly_ctx_t ctx) noexcept - # This function is as per :func:`fmpz_mpoly_divrem` except that it takes an array of divisor polynomials *B* and it returns an array of quotient polynomials *Q*. - # The number of divisor (and hence quotient) polynomials is given by *len*. - # Note that this function is not very useful if there is no unit among the leading coefficients in the array *B*. - void fmpz_mpoly_quasidivrem_ideal(fmpz_t scale, fmpz_mpoly_struct ** Q, fmpz_mpoly_t R, const fmpz_mpoly_t A, fmpz_mpoly_struct * const * B, slong len, const fmpz_mpoly_ctx_t ctx) noexcept - # This function is as per :func:`fmpz_mpoly_quasidivrem` except that it takes an array of divisor polynomials *B* and it returns an array of quotient polynomials *Q*. - # The number of divisor (and hence quotient) polynomials is given by *len*. - void fmpz_mpoly_term_content(fmpz_mpoly_t M, const fmpz_mpoly_t A, const fmpz_mpoly_ctx_t ctx) noexcept - # Set *M* to the GCD of the terms of *A*. - # If *A* is zero, *M* will be zero. Otherwise, *M* will be a monomial with positive coefficient. - int fmpz_mpoly_content_vars(fmpz_mpoly_t g, const fmpz_mpoly_t A, slong * vars, slong vars_length, const fmpz_mpoly_ctx_t ctx) noexcept - # Set *g* to the GCD of the coefficients of *A* when viewed as a polynomial in the variables *vars*. - # Return `1` for success and `0` for failure. Upon success, *g* will be independent of the variables *vars*. - int fmpz_mpoly_gcd(fmpz_mpoly_t G, const fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_mpoly_ctx_t ctx) noexcept - # Try to set *G* to the GCD of *A* and *B* with positive leading coefficient. The GCD of zero and zero is defined to be zero. - # If the return is `1` the function was successful. Otherwise the return is `0` and *G* is left untouched. - int fmpz_mpoly_gcd_cofactors(fmpz_mpoly_t G, fmpz_mpoly_t Abar, fmpz_mpoly_t Bbar, const fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_mpoly_ctx_t ctx) noexcept - # Do the operation of :func:`fmpz_mpoly_gcd` and also compute `Abar = A/G` and `Bbar = B/G` if successful. - int fmpz_mpoly_gcd_brown(fmpz_mpoly_t G, const fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_mpoly_ctx_t ctx) noexcept int fmpz_mpoly_gcd_hensel(fmpz_mpoly_t G, const fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_mpoly_ctx_t ctx) noexcept int fmpz_mpoly_gcd_subresultant(fmpz_mpoly_t G, const fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_mpoly_ctx_t ctx) noexcept int fmpz_mpoly_gcd_zippel(fmpz_mpoly_t G, const fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_mpoly_ctx_t ctx) noexcept int fmpz_mpoly_gcd_zippel2(fmpz_mpoly_t G, const fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_mpoly_ctx_t ctx) noexcept - # Try to set *G* to the GCD of *A* and *B* using various algorithms. - int fmpz_mpoly_resultant(fmpz_mpoly_t R, const fmpz_mpoly_t A, const fmpz_mpoly_t B, slong var, const fmpz_mpoly_ctx_t ctx) noexcept - # Try to set *R* to the resultant of *A* and *B* with respect to the variable of index *var*. - int fmpz_mpoly_discriminant(fmpz_mpoly_t D, const fmpz_mpoly_t A, slong var, const fmpz_mpoly_ctx_t ctx) noexcept - # Try to set *D* to the discriminant of *A* with respect to the variable of index *var*. - void fmpz_mpoly_primitive_part(fmpz_mpoly_t res, const fmpz_mpoly_t f, const fmpz_mpoly_ctx_t ctx) noexcept - # Sets *res* to the primitive part of *f*, obtained by dividing - # out the content of all coefficients and normalizing the leading - # coefficient to be positive. The zero polynomial is unchanged. - int fmpz_mpoly_sqrt_heap(fmpz_mpoly_t Q, const fmpz_mpoly_t A, const fmpz_mpoly_ctx_t ctx, int check) noexcept - # If *A* is a perfect square return `1` and set *Q* to the square root - # with positive leading coefficient. Otherwise return `0` and set *Q* to the - # zero polynomial. If `check = 0` the polynomial is assumed to be a perfect - # square. This can be significantly faster, but it will not detect - # non-squares with any reliability, and in the event of being passed a - # non-square the result is meaningless. - int fmpz_mpoly_sqrt(fmpz_mpoly_t q, const fmpz_mpoly_t A, const fmpz_mpoly_ctx_t ctx) noexcept - # If *A* is a perfect square return `1` and set *Q* to the square root - # with positive leading coefficient. Otherwise return `0` and set *Q* to zero. - bint fmpz_mpoly_is_square(const fmpz_mpoly_t A, const fmpz_mpoly_ctx_t ctx) noexcept - # Return `1` if *A* is a perfect square, otherwise return `0`. - void fmpz_mpoly_univar_init(fmpz_mpoly_univar_t A, const fmpz_mpoly_ctx_t ctx) noexcept - # Initialize *A*. - void fmpz_mpoly_univar_clear(fmpz_mpoly_univar_t A, const fmpz_mpoly_ctx_t ctx) noexcept - # Clear *A*. - void fmpz_mpoly_univar_swap(fmpz_mpoly_univar_t A, fmpz_mpoly_univar_t B, const fmpz_mpoly_ctx_t ctx) noexcept - # Swap *A* and *B*. - void fmpz_mpoly_to_univar(fmpz_mpoly_univar_t A, const fmpz_mpoly_t B, slong var, const fmpz_mpoly_ctx_t ctx) noexcept - # Set *A* to a univariate form of *B* by pulling out the variable of index *var*. - # The coefficients of *A* will still belong to the content *ctx* but will not depend on the variable of index *var*. - void fmpz_mpoly_from_univar(fmpz_mpoly_t A, const fmpz_mpoly_univar_t B, slong var, const fmpz_mpoly_ctx_t ctx) noexcept - # Set *A* to the normal form of *B* by putting in the variable of index *var*. - # This function is undefined if the coefficients of *B* depend on the variable of index *var*. - int fmpz_mpoly_univar_degree_fits_si(const fmpz_mpoly_univar_t A, const fmpz_mpoly_ctx_t ctx) noexcept - # Return `1` if the degree of *A* with respect to the main variable fits an ``slong``. Otherwise, return `0`. - slong fmpz_mpoly_univar_length(const fmpz_mpoly_univar_t A, const fmpz_mpoly_ctx_t ctx) noexcept - # Return the number of terms in *A* with respect to the main variable. - slong fmpz_mpoly_univar_get_term_exp_si(fmpz_mpoly_univar_t A, slong i, const fmpz_mpoly_ctx_t ctx) noexcept - # Return the exponent of the term of index *i* of *A*. - void fmpz_mpoly_univar_get_term_coeff(fmpz_mpoly_t c, const fmpz_mpoly_univar_t A, slong i, const fmpz_mpoly_ctx_t ctx) noexcept void fmpz_mpoly_univar_swap_term_coeff(fmpz_mpoly_t c, fmpz_mpoly_univar_t A, slong i, const fmpz_mpoly_ctx_t ctx) noexcept - # Set (resp. swap) *c* to (resp. with) the coefficient of the term of index *i* of *A*. - void fmpz_mpoly_inflate(fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz * shift, const fmpz * stride, const fmpz_mpoly_ctx_t ctx) noexcept - # Apply the function ``e -> shift[v] + stride[v]*e`` to each exponent ``e`` corresponding to the variable ``v``. - # It is assumed that each shift and stride is not negative. - void fmpz_mpoly_deflate(fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz * shift, const fmpz * stride, const fmpz_mpoly_ctx_t ctx) noexcept - # Apply the function ``e -> (e - shift[v])/stride[v]`` to each exponent ``e`` corresponding to the variable ``v``. - # If any ``stride[v]`` is zero, the corresponding numerator ``e - shift[v]`` is assumed to be zero, and the quotient is defined as zero. - # This allows the function to undo the operation performed by :func:`fmpz_mpoly_inflate` when possible. - void fmpz_mpoly_deflation(fmpz * shift, fmpz * stride, const fmpz_mpoly_t A, const fmpz_mpoly_ctx_t ctx) noexcept - # For each variable `v` let `S_v` be the set of exponents appearing on `v`. - # Set ``shift[v]`` to `\operatorname{min}(S_v)` and set ``stride[v]`` to `\operatorname{gcd}(S-\operatorname{min}(S_v))`. - # If *A* is zero, all shifts and strides are set to zero. - void fmpz_mpoly_pow_fps(fmpz_mpoly_t A, const fmpz_mpoly_t B, ulong k, const fmpz_mpoly_ctx_t ctx) noexcept - # Set *A* to *B* raised to the *k*-th power, using the Monagan and Pearce FPS algorithm. - # It is assumed that *B* is not zero and `k \geq 2`. - slong _fmpz_mpoly_divides_array(fmpz ** poly1, ulong ** exp1, slong * alloc, const fmpz * poly2, const ulong * exp2, slong len2, const fmpz * poly3, const ulong * exp3, slong len3, slong * mults, slong num, slong bits) noexcept - # Use dense array exact division to set ``(poly1, exp1, alloc)`` to - # ``(poly2, exp3, len2)`` divided by ``(poly3, exp3, len3)`` in - # ``num`` variables, given a list of multipliers to tightly pack exponents - # and a number of bits for the fields of the exponents of the result. The - # array "mults" is a list of bases to be used in encoding the array indices - # from the exponents. The function reallocates its output, hence the double - # indirection, and returns the length of its output if the quotient is exact, - # or zero if not. It is assumed that ``poly2`` is not zero. No aliasing is - # allowed. - int fmpz_mpoly_divides_array(fmpz_mpoly_t poly1, const fmpz_mpoly_t poly2, const fmpz_mpoly_t poly3, const fmpz_mpoly_ctx_t ctx) noexcept - # Set ``poly1`` to ``poly2`` divided by ``poly3``, using a big dense - # array to accumulate coefficients, and return 1 if the quotient is exact. - # Otherwise, return 0 if the quotient is not exact. If the array will be - # larger than some internally set parameter, the function fails silently and - # returns `-1` so that some other method may be called. This function is most - # efficient on dense inputs. Note that the function - # ``fmpz_mpoly_div_monagan_pearce`` below may be much faster if the - # quotient is known to be exact. - - slong _fmpz_mpoly_divides_monagan_pearce(fmpz ** poly1, ulong ** exp1, slong * alloc, const fmpz * poly2, const ulong * exp2, slong len2, const fmpz * poly3, const ulong * exp3, slong len3, ulong bits, slong N, const mp_limb_t *cmpmask) noexcept - # Set ``(poly1, exp1, alloc)`` to ``(poly2, exp3, len2)`` divided by - # ``(poly3, exp3, len3)`` and return 1 if the quotient is exact. Otherwise - # return 0. The function assumes exponent vectors that each fit in `N` words, - # and are packed into fields of the given number of bits. Assumes input polys - # are nonzero. Implements "Polynomial division using dynamic arrays, heaps - # and packed exponents" by Michael Monagan and Roman Pearce. No aliasing is - # allowed. - + slong _fmpz_mpoly_divides_monagan_pearce(fmpz ** poly1, ulong ** exp1, slong * alloc, const fmpz * poly2, const ulong * exp2, slong len2, const fmpz * poly3, const ulong * exp3, slong len3, ulong bits, slong N, const mp_limb_t * cmpmask) noexcept int fmpz_mpoly_divides_monagan_pearce(fmpz_mpoly_t poly1, const fmpz_mpoly_t poly2, const fmpz_mpoly_t poly3, const fmpz_mpoly_ctx_t ctx) noexcept - int fmpz_mpoly_divides_heap_threaded(fmpz_mpoly_t Q, const fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_mpoly_ctx_t ctx) noexcept - # Set ``poly1`` to ``poly2`` divided by ``poly3`` and return 1 if - # the quotient is exact. Otherwise return 0. The function uses the algorithm - # of Michael Monagan and Roman Pearce. Note that the function - # ``fmpz_mpoly_div_monagan_pearce`` below may be much faster if the - # quotient is known to be exact. - # The threaded version takes an upper limit on the number of threads to use, while the first version always uses one thread. - - slong _fmpz_mpoly_div_monagan_pearce(fmpz ** polyq, ulong ** expq, slong * allocq, const fmpz * poly2, const ulong * exp2, slong len2, const fmpz * poly3, const ulong * exp3, slong len3, slong bits, slong N, const mp_limb_t *cmpmask) noexcept - # Set ``(polyq, expq, allocq)`` to the quotient of - # ``(poly2, exp2, len2)`` by ``(poly3, exp3, len3)`` discarding - # remainder (with notional remainder coefficients reduced modulo the leading - # coefficient of ``(poly3, exp3, len3)``), and return the length of the - # quotient. The function reallocates its output, hence the double - # indirection. The function assumes the exponent vectors all fit in `N` - # words. The exponent vectors are assumed to have fields with the given - # number of bits. Assumes input polynomials are nonzero. Implements - # "Polynomial division using dynamic arrays, heaps and packed exponents" by - # Michael Monagan and Roman Pearce. No aliasing is allowed. - + slong _fmpz_mpoly_div_monagan_pearce(fmpz ** polyq, ulong ** expq, slong * allocq, const fmpz * poly2, const ulong * exp2, slong len2, const fmpz * poly3, const ulong * exp3, slong len3, slong bits, slong N, const mp_limb_t * cmpmask) noexcept void fmpz_mpoly_div_monagan_pearce(fmpz_mpoly_t polyq, const fmpz_mpoly_t poly2, const fmpz_mpoly_t poly3, const fmpz_mpoly_ctx_t ctx) noexcept - # Set ``polyq`` to the quotient of ``poly2`` by ``poly3``, - # discarding the remainder (with notional remainder coefficients reduced - # modulo the leading coefficient of ``poly3``). Implements "Polynomial - # division using dynamic arrays, heaps and packed exponents" by Michael - # Monagan and Roman Pearce. This function is exceptionally efficient if the - # division is known to be exact. - - slong _fmpz_mpoly_divrem_monagan_pearce(slong * lenr, fmpz ** polyq, ulong ** expq, slong * allocq, fmpz ** polyr, ulong ** expr, slong * allocr, const fmpz * poly2, const ulong * exp2, slong len2, const fmpz * poly3, const ulong * exp3, slong len3, slong bits, slong N, const mp_limb_t *cmpmask) noexcept - # Set ``(polyq, expq, allocq)`` and ``(polyr, expr, allocr)`` to the - # quotient and remainder of ``(poly2, exp2, len2)`` by - # ``(poly3, exp3, len3)`` (with remainder coefficients reduced modulo the - # leading coefficient of ``(poly3, exp3, len3)``), and return the length - # of the quotient. The function reallocates its outputs, hence the double - # indirection. The function assumes the exponent vectors all fit in `N` - # words. The exponent vectors are assumed to have fields with the given - # number of bits. Assumes input polynomials are nonzero. Implements - # "Polynomial division using dynamic arrays, heaps and packed exponents" by - # Michael Monagan and Roman Pearce. No aliasing is allowed. - + slong _fmpz_mpoly_divrem_monagan_pearce(slong * lenr, fmpz ** polyq, ulong ** expq, slong * allocq, fmpz ** polyr, ulong ** expr, slong * allocr, const fmpz * poly2, const ulong * exp2, slong len2, const fmpz * poly3, const ulong * exp3, slong len3, slong bits, slong N, const mp_limb_t * cmpmask) noexcept void fmpz_mpoly_divrem_monagan_pearce(fmpz_mpoly_t q, fmpz_mpoly_t r, const fmpz_mpoly_t poly2, const fmpz_mpoly_t poly3, const fmpz_mpoly_ctx_t ctx) noexcept - # Set ``polyq`` and ``polyr`` to the quotient and remainder of - # ``poly2`` divided by ``poly3`` (with remainder coefficients reduced - # modulo the leading coefficient of ``poly3``). Implements "Polynomial - # division using dynamic arrays, heaps and packed exponents" by Michael - # Monagan and Roman Pearce. - slong _fmpz_mpoly_divrem_array(slong * lenr, fmpz ** polyq, ulong ** expq, slong * allocq, fmpz ** polyr, ulong ** expr, slong * allocr, const fmpz * poly2, const ulong * exp2, slong len2, const fmpz * poly3, const ulong * exp3, slong len3, slong * mults, slong num, slong bits) noexcept - # Use dense array division to set ``(polyq, expq, allocq)`` and - # ``(polyr, expr, allocr)`` to the quotient and remainder of - # ``(poly2, exp2, len2)`` divided by ``(poly3, exp3, len3)`` in - # ``num`` variables, given a list of multipliers to tightly pack - # exponents and a number of bits for the fields of the exponents of the - # result. The function reallocates its outputs, hence the double indirection. - # The array ``mults`` is a list of bases to be used in encoding the array - # indices from the exponents. The function returns the length of the - # quotient. It is assumed that the input polynomials are not zero. No - # aliasing is allowed. - int fmpz_mpoly_divrem_array(fmpz_mpoly_t q, fmpz_mpoly_t r, const fmpz_mpoly_t poly2, const fmpz_mpoly_t poly3, const fmpz_mpoly_ctx_t ctx) noexcept - # Set ``polyq`` and ``polyr`` to the quotient and remainder of - # ``poly2`` divided by ``poly3`` (with remainder coefficients reduced - # modulo the leading coefficient of ``poly3``). The function is - # implemented using dense arrays, and is efficient when the inputs are fairly - # dense. If the array will be larger than some internally set parameter, the - # function silently returns 0 so that another function can be called, - # otherwise it returns 1. - void fmpz_mpoly_quasidivrem_heap(fmpz_t scale, fmpz_mpoly_t q, fmpz_mpoly_t r, const fmpz_mpoly_t poly2, const fmpz_mpoly_t poly3, const fmpz_mpoly_ctx_t ctx) noexcept - # Set ``scale``, ``q`` and ``r`` so that - # ``scale*poly2 = q*poly3 + r`` and no monomial in ``r`` is divisible - # by the leading monomial of ``poly3``, where ``scale`` is positive - # and as small as possible. This function throws an exception if - # ``poly3`` is zero or if an exponent overflow occurs. - - slong _fmpz_mpoly_divrem_ideal_monagan_pearce(fmpz_mpoly_struct ** polyq, fmpz ** polyr, ulong ** expr, slong * allocr, const fmpz * poly2, const ulong * exp2, slong len2, fmpz_mpoly_struct * const * poly3, ulong * const * exp3, slong len, slong N, slong bits, const fmpz_mpoly_ctx_t ctx, const mp_limb_t *cmpmask) noexcept - # This function is as per ``_fmpz_mpoly_divrem_monagan_pearce`` except - # that it takes an array of divisor polynomials ``poly3`` and an array of - # repacked exponent arrays ``exp3``, which may alias the exponent arrays - # of ``poly3``, and it returns an array of quotient polynomials - # ``polyq``. The number of divisor (and hence quotient) polynomials is - # given by ``len``. The function computes polynomials `q_i` such that - # `r = a - \sum_{i=0}^{\mbox{len - 1}} q_ib_i`, where the `q_i` are the - # quotient polynomials and the `b_i` are the divisor polynomials. - + slong _fmpz_mpoly_divrem_ideal_monagan_pearce(fmpz_mpoly_struct ** polyq, fmpz ** polyr, ulong ** expr, slong * allocr, const fmpz * poly2, const ulong * exp2, slong len2, fmpz_mpoly_struct * const * poly3, ulong * const * exp3, slong len, slong N, slong bits, const fmpz_mpoly_ctx_t ctx, const mp_limb_t * cmpmask) noexcept void fmpz_mpoly_divrem_ideal_monagan_pearce(fmpz_mpoly_struct ** q, fmpz_mpoly_t r, const fmpz_mpoly_t poly2, fmpz_mpoly_struct * const * poly3, slong len, const fmpz_mpoly_ctx_t ctx) noexcept - # This function is as per ``fmpz_mpoly_divrem_monagan_pearce`` except - # that it takes an array of divisor polynomials ``poly3``, and it returns - # an array of quotient polynomials ``q``. The number of divisor (and hence - # quotient) polynomials is given by ``len``. The function computes - # polynomials `q_i = q[i]` such that ``poly2`` is - # `r + \sum_{i=0}^{\mbox{len - 1}} q_ib_i`, where `b_i =` ``poly3[i]``. - void fmpz_mpoly_vec_init(fmpz_mpoly_vec_t vec, slong len, const fmpz_mpoly_ctx_t ctx) noexcept - # Initializes *vec* to a vector of length *len*, setting all entries to the zero polynomial. - void fmpz_mpoly_vec_clear(fmpz_mpoly_vec_t vec, const fmpz_mpoly_ctx_t ctx) noexcept - # Clears *vec*, freeing its allocated memory. - void fmpz_mpoly_vec_print(const fmpz_mpoly_vec_t vec, const fmpz_mpoly_ctx_t ctx) noexcept - # Prints *vec* to standard output. - void fmpz_mpoly_vec_swap(fmpz_mpoly_vec_t x, fmpz_mpoly_vec_t y, const fmpz_mpoly_ctx_t ctx) noexcept - # Swaps *x* and *y* efficiently. - void fmpz_mpoly_vec_fit_length(fmpz_mpoly_vec_t vec, slong len, const fmpz_mpoly_ctx_t ctx) noexcept - # Allocates room for *len* entries in *vec*. - void fmpz_mpoly_vec_set(fmpz_mpoly_vec_t dest, const fmpz_mpoly_vec_t src, const fmpz_mpoly_ctx_t ctx) noexcept - # Sets *dest* to a copy of *src*. - void fmpz_mpoly_vec_append(fmpz_mpoly_vec_t vec, const fmpz_mpoly_t f, const fmpz_mpoly_ctx_t ctx) noexcept - # Appends *f* to the end of *vec*. - slong fmpz_mpoly_vec_insert_unique(fmpz_mpoly_vec_t vec, const fmpz_mpoly_t f, const fmpz_mpoly_ctx_t ctx) noexcept - # Inserts *f* without duplication into *vec* and returns its index. - # If this polynomial already exists, *vec* is unchanged. If this - # polynomial does not exist in *vec*, it is appended. - void fmpz_mpoly_vec_set_length(fmpz_mpoly_vec_t vec, slong len, const fmpz_mpoly_ctx_t ctx) noexcept - # Sets the length of *vec* to *len*, truncating or zero-extending - # as needed. - void fmpz_mpoly_vec_randtest_not_zero(fmpz_mpoly_vec_t vec, flint_rand_t state, slong len, slong poly_len, slong bits, ulong exp_bound, fmpz_mpoly_ctx_t ctx) noexcept - # Sets *vec* to a random vector with exactly *len* entries, all nonzero, - # with random parameters defined by *poly_len*, *bits* and *exp_bound*. - void fmpz_mpoly_vec_set_primitive_unique(fmpz_mpoly_vec_t res, const fmpz_mpoly_vec_t src, const fmpz_mpoly_ctx_t ctx) noexcept - # Sets *res* to a vector containing all polynomials in *src* reduced - # to their primitive parts, without duplication. The zero polynomial - # is skipped if present. The output order is arbitrary. - void fmpz_mpoly_spoly(fmpz_mpoly_t res, const fmpz_mpoly_t f, const fmpz_mpoly_t g, const fmpz_mpoly_ctx_t ctx) noexcept - # Sets *res* to the *S*-polynomial of *f* and *g*, scaled to - # an integer polynomial by computing the LCM of the leading coefficients. - void fmpz_mpoly_reduction_primitive_part(fmpz_mpoly_t res, const fmpz_mpoly_t f, const fmpz_mpoly_vec_t vec, const fmpz_mpoly_ctx_t ctx) noexcept - # Sets *res* to the primitive part of the reduction (remainder of multivariate - # quasidivision with remainder) with respect to the polynomials *vec*. - bint fmpz_mpoly_vec_is_groebner(const fmpz_mpoly_vec_t G, const fmpz_mpoly_vec_t F, const fmpz_mpoly_ctx_t ctx) noexcept - # If *F* is *NULL*, checks if *G* is a Gröbner basis. If *F* is not *NULL*, - # checks if *G* is a Gröbner basis for *F*. - bint fmpz_mpoly_vec_is_autoreduced(const fmpz_mpoly_vec_t F, const fmpz_mpoly_ctx_t ctx) noexcept - # Checks whether the vector *F* is autoreduced (or inter-reduced). - void fmpz_mpoly_vec_autoreduction(fmpz_mpoly_vec_t H, const fmpz_mpoly_vec_t F, const fmpz_mpoly_ctx_t ctx) noexcept - # Sets *H* to the autoreduction (inter-reduction) of *F*. - void fmpz_mpoly_vec_autoreduction_groebner(fmpz_mpoly_vec_t H, const fmpz_mpoly_vec_t G, const fmpz_mpoly_ctx_t ctx) noexcept - # Sets *H* to the autoreduction (inter-reduction) of *G*. - # Assumes that *G* is a Gröbner basis. - # This produces a reduced Gröbner basis, which is unique - # (up to the sort order of the entries in the vector). - void fmpz_mpoly_buchberger_naive(fmpz_mpoly_vec_t G, const fmpz_mpoly_vec_t F, const fmpz_mpoly_ctx_t ctx) noexcept - # Sets *G* to a Gröbner basis for *F*, computed using - # a naive implementation of Buchberger's algorithm. - int fmpz_mpoly_buchberger_naive_with_limits(fmpz_mpoly_vec_t G, const fmpz_mpoly_vec_t F, slong ideal_len_limit, slong poly_len_limit, slong poly_bits_limit, const fmpz_mpoly_ctx_t ctx) noexcept - # As :func:`fmpz_mpoly_buchberger_naive`, but halts if during the - # execution of Buchberger's algorithm the length of the - # ideal basis set exceeds *ideal_len_limit*, the length of any - # polynomial exceeds *poly_len_limit*, or the size of the - # coefficients of any polynomial exceeds *poly_bits_limit*. - # Returns 1 for success and 0 for failure. On failure, *G* is - # a valid basis for *F* but it might not be a Gröbner basis. - void fmpz_mpoly_symmetric_gens(fmpz_mpoly_t res, ulong k, slong * vars, slong n, const fmpz_mpoly_ctx_t ctx) noexcept - void fmpz_mpoly_symmetric(fmpz_mpoly_t res, ulong k, const fmpz_mpoly_ctx_t ctx) noexcept - # Sets *res* to the elementary symmetric polynomial - # `e_k(X_1,\ldots,X_n)`. - # The *gens* version takes `X_1,\ldots,X_n` to be the subset of - # generators given by *vars* and *n*. - # The indices in *vars* start from zero. - # Currently, the indices in *vars* must be distinct. diff --git a/src/sage/libs/flint/fmpz_mpoly_factor.pxd b/src/sage/libs/flint/fmpz_mpoly_factor.pxd index 8bdc2862453..a48f7052f42 100644 --- a/src/sage/libs/flint/fmpz_mpoly_factor.pxd +++ b/src/sage/libs/flint/fmpz_mpoly_factor.pxd @@ -2,7 +2,9 @@ # distutils: depends = flint/fmpz_mpoly_factor.h ################################################################################ -# This file is auto-generated. Do not modify by hand +# This file is auto-generated by the script +# SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py. +# Do not modify by hand! Fix and rerun the script instead. ################################################################################ from libc.stdio cimport FILE @@ -11,38 +13,15 @@ from sage.libs.mpfr.types cimport * from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void fmpz_mpoly_factor_init(fmpz_mpoly_factor_t f, const fmpz_mpoly_ctx_t ctx) noexcept - # Initialise *f*. - void fmpz_mpoly_factor_clear(fmpz_mpoly_factor_t f, const fmpz_mpoly_ctx_t ctx) noexcept - # Clear *f*. - void fmpz_mpoly_factor_swap(fmpz_mpoly_factor_t f, fmpz_mpoly_factor_t g, const fmpz_mpoly_ctx_t ctx) noexcept - # Efficiently swap *f* and *g*. - slong fmpz_mpoly_factor_length(const fmpz_mpoly_factor_t f, const fmpz_mpoly_ctx_t ctx) noexcept - # Return the length of the product in *f*. - void fmpz_mpoly_factor_get_constant_fmpz(fmpz_t c, const fmpz_mpoly_factor_t f, const fmpz_mpoly_ctx_t ctx) noexcept void fmpz_mpoly_factor_get_constant_fmpq(fmpq_t c, const fmpz_mpoly_factor_t f, const fmpz_mpoly_ctx_t ctx) noexcept - # Set `c` to the constant of *f*. - void fmpz_mpoly_factor_get_base(fmpz_mpoly_t B, const fmpz_mpoly_factor_t f, slong i, const fmpz_mpoly_ctx_t ctx) noexcept void fmpz_mpoly_factor_swap_base(fmpz_mpoly_t B, fmpz_mpoly_factor_t f, slong i, const fmpz_mpoly_ctx_t ctx) noexcept - # Set (resp. swap) *B* to (resp. with) the base of the term of index `i` in *A*. - slong fmpz_mpoly_factor_get_exp_si(fmpz_mpoly_factor_t f, slong i, const fmpz_mpoly_ctx_t ctx) noexcept - # Return the exponent of the term of index `i` in *A*. It is assumed to fit an ``slong``. - void fmpz_mpoly_factor_sort(fmpz_mpoly_factor_t f, const fmpz_mpoly_ctx_t ctx) noexcept - # Sort the product of *f* first by exponent and then by base. - int fmpz_mpoly_factor_squarefree(fmpz_mpoly_factor_t f, const fmpz_mpoly_t A, const fmpz_mpoly_ctx_t ctx) noexcept - # Set *f* to a factorization of *A* where the bases are primitive and - # pairwise relatively prime. If the product of all irreducible factors with - # a given exponent is desired, it is recommended to call :func:`fmpz_mpoly_factor_sort` - # and then multiply the bases with the desired exponent. - int fmpz_mpoly_factor(fmpz_mpoly_factor_t f, const fmpz_mpoly_t A, const fmpz_mpoly_ctx_t ctx) noexcept - # Set *f* to a factorization of *A* where the bases are irreducible. diff --git a/src/sage/libs/flint/fmpz_mpoly_q.pxd b/src/sage/libs/flint/fmpz_mpoly_q.pxd index 3f2ff4a5773..349902f74fb 100644 --- a/src/sage/libs/flint/fmpz_mpoly_q.pxd +++ b/src/sage/libs/flint/fmpz_mpoly_q.pxd @@ -2,7 +2,9 @@ # distutils: depends = flint/fmpz_mpoly_q.h ################################################################################ -# This file is auto-generated. Do not modify by hand +# This file is auto-generated by the script +# SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py. +# Do not modify by hand! Fix and rerun the script instead. ################################################################################ from libc.stdio cimport FILE @@ -11,102 +13,43 @@ from sage.libs.mpfr.types cimport * from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void fmpz_mpoly_q_init(fmpz_mpoly_q_t res, const fmpz_mpoly_ctx_t ctx) noexcept - # Initializes *res* for use, and sets its value to zero. - void fmpz_mpoly_q_clear(fmpz_mpoly_q_t res, const fmpz_mpoly_ctx_t ctx) noexcept - # Clears *res*, freeing or recycling its allocated memory. - void fmpz_mpoly_q_swap(fmpz_mpoly_q_t x, fmpz_mpoly_q_t y, const fmpz_mpoly_ctx_t ctx) noexcept - # Swaps the values of *x* and *y* efficiently. - void fmpz_mpoly_q_set(fmpz_mpoly_q_t res, const fmpz_mpoly_q_t x, const fmpz_mpoly_ctx_t ctx) noexcept void fmpz_mpoly_q_set_fmpq(fmpz_mpoly_q_t res, const fmpq_t x, const fmpz_mpoly_ctx_t ctx) noexcept void fmpz_mpoly_q_set_fmpz(fmpz_mpoly_q_t res, const fmpz_t x, const fmpz_mpoly_ctx_t ctx) noexcept void fmpz_mpoly_q_set_si(fmpz_mpoly_q_t res, slong x, const fmpz_mpoly_ctx_t ctx) noexcept - # Sets *res* to the value *x*. - void fmpz_mpoly_q_canonicalise(fmpz_mpoly_q_t x, const fmpz_mpoly_ctx_t ctx) noexcept - # Puts the numerator and denominator of *x* in canonical form by removing - # common content and making the leading term of the denominator positive. - bint fmpz_mpoly_q_is_canonical(const fmpz_mpoly_q_t x, const fmpz_mpoly_ctx_t ctx) noexcept - # Returns whether *x* is in canonical form. - # In addition to verifying that the numerator and denominator - # have no common content and that the leading term of the denominator - # is positive, this function checks that the denominator is nonzero and that - # the numerator and denominator have correctly sorted terms - # (these properties should normally hold; verifying them - # provides an extra consistency check for test code). - bint fmpz_mpoly_q_is_zero(const fmpz_mpoly_q_t x, const fmpz_mpoly_ctx_t ctx) noexcept - # Returns whether *x* is the constant 0. - bint fmpz_mpoly_q_is_one(const fmpz_mpoly_q_t x, const fmpz_mpoly_ctx_t ctx) noexcept - # Returns whether *x* is the constant 1. - void fmpz_mpoly_q_used_vars(int * used, const fmpz_mpoly_q_t f, const fmpz_mpoly_ctx_t ctx) noexcept void fmpz_mpoly_q_used_vars_num(int * used, const fmpz_mpoly_q_t f, const fmpz_mpoly_ctx_t ctx) noexcept void fmpz_mpoly_q_used_vars_den(int * used, const fmpz_mpoly_q_t f, const fmpz_mpoly_ctx_t ctx) noexcept - # For each variable, sets the corresponding entry in *used* to the - # boolean flag indicating whether that variable appears in the - # rational function (respectively its numerator or denominator). - void fmpz_mpoly_q_zero(fmpz_mpoly_q_t res, const fmpz_mpoly_ctx_t ctx) noexcept - # Sets *res* to the constant 0. - void fmpz_mpoly_q_one(fmpz_mpoly_q_t res, const fmpz_mpoly_ctx_t ctx) noexcept - # Sets *res* to the constant 1. - void fmpz_mpoly_q_gen(fmpz_mpoly_q_t res, slong i, const fmpz_mpoly_ctx_t ctx) noexcept - # Sets *res* to the generator `x_{i+1}`. - # Requires `0 \le i < n` where *n* is the number of variables of *ctx*. - void fmpz_mpoly_q_print_pretty(const fmpz_mpoly_q_t f, const char ** x, const fmpz_mpoly_ctx_t ctx) noexcept - # Prints *res* to standard output. If *x* is not *NULL*, the strings in - # *x* are used as the symbols for the variables. - void fmpz_mpoly_q_randtest(fmpz_mpoly_q_t res, flint_rand_t state, slong length, mp_limb_t coeff_bits, slong exp_bound, const fmpz_mpoly_ctx_t ctx) noexcept - # Sets *res* to a random rational function where both numerator and denominator - # have up to *length* terms, coefficients up to size *coeff_bits*, and - # exponents strictly smaller than *exp_bound*. - bint fmpz_mpoly_q_equal(const fmpz_mpoly_q_t x, const fmpz_mpoly_q_t y, const fmpz_mpoly_ctx_t ctx) noexcept - # Returns whether *x* and *y* are equal. - void fmpz_mpoly_q_neg(fmpz_mpoly_q_t res, const fmpz_mpoly_q_t x, const fmpz_mpoly_ctx_t ctx) noexcept - # Sets *res* to the negation of *x*. - void fmpz_mpoly_q_add(fmpz_mpoly_q_t res, const fmpz_mpoly_q_t x, const fmpz_mpoly_q_t y, const fmpz_mpoly_ctx_t ctx) noexcept void fmpz_mpoly_q_add_fmpq(fmpz_mpoly_q_t res, const fmpz_mpoly_q_t x, const fmpq_t y, const fmpz_mpoly_ctx_t ctx) noexcept void fmpz_mpoly_q_add_fmpz(fmpz_mpoly_q_t res, const fmpz_mpoly_q_t x, const fmpz_t y, const fmpz_mpoly_ctx_t ctx) noexcept void fmpz_mpoly_q_add_si(fmpz_mpoly_q_t res, const fmpz_mpoly_q_t x, slong y, const fmpz_mpoly_ctx_t ctx) noexcept - # Sets *res* to the sum of *x* and *y*. - void fmpz_mpoly_q_sub(fmpz_mpoly_q_t res, const fmpz_mpoly_q_t x, const fmpz_mpoly_q_t y, const fmpz_mpoly_ctx_t ctx) noexcept void fmpz_mpoly_q_sub_fmpq(fmpz_mpoly_q_t res, const fmpz_mpoly_q_t x, const fmpq_t y, const fmpz_mpoly_ctx_t ctx) noexcept void fmpz_mpoly_q_sub_fmpz(fmpz_mpoly_q_t res, const fmpz_mpoly_q_t x, const fmpz_t y, const fmpz_mpoly_ctx_t ctx) noexcept void fmpz_mpoly_q_sub_si(fmpz_mpoly_q_t res, const fmpz_mpoly_q_t x, slong y, const fmpz_mpoly_ctx_t ctx) noexcept - # Sets *res* to the difference of *x* and *y*. - void fmpz_mpoly_q_mul(fmpz_mpoly_q_t res, const fmpz_mpoly_q_t x, const fmpz_mpoly_q_t y, const fmpz_mpoly_ctx_t ctx) noexcept void fmpz_mpoly_q_mul_fmpq(fmpz_mpoly_q_t res, const fmpz_mpoly_q_t x, const fmpq_t y, const fmpz_mpoly_ctx_t ctx) noexcept void fmpz_mpoly_q_mul_fmpz(fmpz_mpoly_q_t res, const fmpz_mpoly_q_t x, const fmpz_t y, const fmpz_mpoly_ctx_t ctx) noexcept void fmpz_mpoly_q_mul_si(fmpz_mpoly_q_t res, const fmpz_mpoly_q_t x, slong y, const fmpz_mpoly_ctx_t ctx) noexcept - # Sets *res* to the product of *x* and *y*. - void fmpz_mpoly_q_div(fmpz_mpoly_q_t res, const fmpz_mpoly_q_t x, const fmpz_mpoly_q_t y, const fmpz_mpoly_ctx_t ctx) noexcept void fmpz_mpoly_q_div_fmpq(fmpz_mpoly_q_t res, const fmpz_mpoly_q_t x, const fmpq_t y, const fmpz_mpoly_ctx_t ctx) noexcept void fmpz_mpoly_q_div_fmpz(fmpz_mpoly_q_t res, const fmpz_mpoly_q_t x, const fmpz_t y, const fmpz_mpoly_ctx_t ctx) noexcept void fmpz_mpoly_q_div_si(fmpz_mpoly_q_t res, const fmpz_mpoly_q_t x, slong y, const fmpz_mpoly_ctx_t ctx) noexcept - # Sets *res* to the quotient of *x* and *y*. - # Division by zero calls *flint_abort*. - void fmpz_mpoly_q_inv(fmpz_mpoly_q_t res, const fmpz_mpoly_q_t x, const fmpz_mpoly_ctx_t ctx) noexcept - # Sets *res* to the inverse of *x*. Division by zero - # calls *flint_abort*. - void _fmpz_mpoly_q_content(fmpz_t num, fmpz_t den, const fmpz_mpoly_t xnum, const fmpz_mpoly_t xden, const fmpz_mpoly_ctx_t ctx) noexcept void fmpz_mpoly_q_content(fmpq_t res, const fmpz_mpoly_q_t x, const fmpz_mpoly_ctx_t ctx) noexcept - # Sets *res* to the content of the coefficients of *x*. diff --git a/src/sage/libs/flint/fmpz_poly.pxd b/src/sage/libs/flint/fmpz_poly.pxd index 2f865d837e0..59508fe6c19 100644 --- a/src/sage/libs/flint/fmpz_poly.pxd +++ b/src/sage/libs/flint/fmpz_poly.pxd @@ -2,7 +2,9 @@ # distutils: depends = flint/fmpz_poly.h ################################################################################ -# This file is auto-generated. Do not modify by hand +# This file is auto-generated by the script +# SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py. +# Do not modify by hand! Fix and rerun the script instead. ################################################################################ from libc.stdio cimport FILE @@ -11,2482 +13,393 @@ from sage.libs.mpfr.types cimport * from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void fmpz_poly_init(fmpz_poly_t poly) noexcept - # Initialises ``poly`` for use, setting its length to zero. - # A corresponding call to :func:`fmpz_poly_clear` must be made after - # finishing with the ``fmpz_poly_t`` to free the memory used by - # the polynomial. - void fmpz_poly_init2(fmpz_poly_t poly, slong alloc) noexcept - # Initialises ``poly`` with space for at least ``alloc`` coefficients - # and sets the length to zero. The allocated coefficients are all set to - # zero. - void fmpz_poly_realloc(fmpz_poly_t poly, slong alloc) noexcept - # Reallocates the given polynomial to have space for ``alloc`` - # coefficients. If ``alloc`` is zero the polynomial is cleared - # and then reinitialised. If the current length is greater than - # ``alloc`` the polynomial is first truncated to length ``alloc``. - void fmpz_poly_fit_length(fmpz_poly_t poly, slong len) noexcept - # If ``len`` is greater than the number of coefficients currently - # allocated, then the polynomial is reallocated to have space for at - # least ``len`` coefficients. No data is lost when calling this - # function. - # The function efficiently deals with the case where ``fit_length`` is - # called many times in small increments by at least doubling the number - # of allocated coefficients when length is larger than the number of - # coefficients currently allocated. - void fmpz_poly_clear(fmpz_poly_t poly) noexcept - # Clears the given polynomial, releasing any memory used. It must - # be reinitialised in order to be used again. - void _fmpz_poly_normalise(fmpz_poly_t poly) noexcept - # Sets the length of ``poly`` so that the top coefficient is non-zero. - # If all coefficients are zero, the length is set to zero. This function - # is mainly used internally, as all functions guarantee normalisation. - void _fmpz_poly_set_length(fmpz_poly_t poly, slong newlen) noexcept - # Demotes the coefficients of ``poly`` beyond ``newlen`` and sets - # the length of ``poly`` to ``newlen``. - void fmpz_poly_attach_truncate(fmpz_poly_t trunc, const fmpz_poly_t poly, slong n) noexcept - # This function sets the uninitialised polynomial ``trunc`` to the low - # `n` coefficients of ``poly``, or to ``poly`` if the latter doesn't - # have `n` coefficients. The polynomial ``trunc`` not be cleared or used - # as the output of any Flint functions. - void fmpz_poly_attach_shift(fmpz_poly_t trunc, const fmpz_poly_t poly, slong n) noexcept - # This function sets the uninitialised polynomial ``trunc`` to the - # high coefficients of ``poly``, i.e. the coefficients not among the low - # `n` coefficients of ``poly``. If the latter doesn't have `n` - # coefficients ``trunc`` is set to the zero polynomial. The polynomial - # ``trunc`` not be cleared or used as the output of any Flint functions. - slong fmpz_poly_length(const fmpz_poly_t poly) noexcept - # Returns the length of ``poly``. The zero polynomial has length zero. - slong fmpz_poly_degree(const fmpz_poly_t poly) noexcept - # Returns the degree of ``poly``, which is one less than its length. - void fmpz_poly_set(fmpz_poly_t poly1, const fmpz_poly_t poly2) noexcept - # Sets ``poly1`` to equal ``poly2``. - void fmpz_poly_set_si(fmpz_poly_t poly, slong c) noexcept - # Sets ``poly`` to the signed integer ``c``. - void fmpz_poly_set_ui(fmpz_poly_t poly, ulong c) noexcept - # Sets ``poly`` to the unsigned integer ``c``. - void fmpz_poly_set_fmpz(fmpz_poly_t poly, const fmpz_t c) noexcept - # Sets ``poly`` to the integer ``c``. - int _fmpz_poly_set_str(fmpz * poly, const char * str) noexcept - # Sets ``poly`` to the polynomial encoded in the null-terminated - # string ``str``. Assumes that ``poly`` is allocated as a - # sufficiently large array suitable for the number of coefficients - # present in ``str``. - # Returns `0` if no error occurred. Otherwise, returns a non-zero - # value, in which case the resulting value of ``poly`` is undefined. - # If ``str`` is not null-terminated, calling this method might result - # in a segmentation fault. - int fmpz_poly_set_str(fmpz_poly_t poly, const char * str) noexcept - # Imports a polynomial from a null-terminated string. If the string - # ``str`` represents a valid polynomial returns `0`, otherwise - # returns `1`. - # Returns `0` if no error occurred. Otherwise, returns a non-zero value, - # in which case the resulting value of ``poly`` is undefined. If - # ``str`` is not null-terminated, calling this method might result in - # a segmentation fault. - char * _fmpz_poly_get_str(const fmpz * poly, slong len) noexcept - # Returns the plain FLINT string representation of the polynomial - # ``(poly, len)``. - char * fmpz_poly_get_str(const fmpz_poly_t poly) noexcept - # Returns the plain FLINT string representation of the polynomial - # ``poly``. - char * _fmpz_poly_get_str_pretty(const fmpz * poly, slong len, const char * x) noexcept - # Returns a pretty representation of the polynomial - # ``(poly, len)`` using the null-terminated string ``x`` as the - # variable name. - char * fmpz_poly_get_str_pretty(const fmpz_poly_t poly, const char * x) noexcept - # Returns a pretty representation of the polynomial ``poly`` using the - # null-terminated string ``x`` as the variable name. - void fmpz_poly_zero(fmpz_poly_t poly) noexcept - # Sets ``poly`` to the zero polynomial. - void fmpz_poly_one(fmpz_poly_t poly) noexcept - # Sets ``poly`` to the constant polynomial one. - void fmpz_poly_zero_coeffs(fmpz_poly_t poly, slong i, slong j) noexcept - # Sets the coefficients of `x^i, \dotsc, x^{j-1}` to zero. - void fmpz_poly_swap(fmpz_poly_t poly1, fmpz_poly_t poly2) noexcept - # Swaps ``poly1`` and ``poly2``. This is done efficiently without - # copying data by swapping pointers, etc. - void _fmpz_poly_reverse(fmpz * res, const fmpz * poly, slong len, slong n) noexcept - # Sets ``(res, n)`` to the reverse of ``(poly, n)``, where - # ``poly`` is in fact an array of length ``len``. Assumes that - # ``0 < len <= n``. Supports aliasing of ``res`` and ``poly``, - # but the behaviour is undefined in case of partial overlap. - void fmpz_poly_reverse(fmpz_poly_t res, const fmpz_poly_t poly, slong n) noexcept - # This function considers the polynomial ``poly`` to be of length `n`, - # notionally truncating and zero padding if required, and reverses - # the result. Since the function normalises its result ``res`` may be - # of length less than `n`. - void fmpz_poly_truncate(fmpz_poly_t poly, slong newlen) noexcept - # If the current length of ``poly`` is greater than ``newlen``, it - # is truncated to have the given length. Discarded coefficients are not - # necessarily set to zero. - void fmpz_poly_set_trunc(fmpz_poly_t res, const fmpz_poly_t poly, slong n) noexcept - # Sets ``res`` to a copy of ``poly``, truncated to length ``n``. - void fmpz_poly_randtest(fmpz_poly_t f, flint_rand_t state, slong len, flint_bitcnt_t bits) noexcept - # Sets `f` to a random polynomial with up to the given length and where - # each coefficient has up to the given number of bits. The coefficients - # are signed randomly. - void fmpz_poly_randtest_unsigned(fmpz_poly_t f, flint_rand_t state, slong len, flint_bitcnt_t bits) noexcept - # Sets `f` to a random polynomial with up to the given length and where - # each coefficient has up to the given number of bits. - void fmpz_poly_randtest_not_zero(fmpz_poly_t f, flint_rand_t state, slong len, flint_bitcnt_t bits) noexcept - # As for :func:`fmpz_poly_randtest` except that ``len`` and bits may - # not be zero and the polynomial generated is guaranteed not to be the - # zero polynomial. - void fmpz_poly_randtest_no_real_root(fmpz_poly_t p, flint_rand_t state, slong len, flint_bitcnt_t bits) noexcept - # Sets ``p`` to a random polynomial without any real root, whose - # length is up to ``len`` and where each coefficient has up to the - # given number of bits. - void fmpz_poly_randtest_irreducible1(fmpz_poly_t pol, flint_rand_t state, slong len, mp_bitcnt_t bits) noexcept void fmpz_poly_randtest_irreducible2(fmpz_poly_t pol, flint_rand_t state, slong len, mp_bitcnt_t bits) noexcept void fmpz_poly_randtest_irreducible(fmpz_poly_t pol, flint_rand_t state, slong len, mp_bitcnt_t bits) noexcept - # Sets ``p`` to a random irreducible polynomial, whose - # length is up to ``len`` and where each coefficient has up to the - # given number of bits. There are two algorithms: *irreducible1* - # generates an irreducible polynomial modulo a random prime number - # and lifts it to the integers; *irreducible2* generates a random - # integer polynomial, factors it, and returns a random factor. - # The default function chooses randomly between these methods. - void fmpz_poly_get_coeff_fmpz(fmpz_t x, const fmpz_poly_t poly, slong n) noexcept - # Sets `x` to the `n`-th coefficient of ``poly``. Coefficient - # numbering is from zero and if `n` is set to a value beyond the end of - # the polynomial, zero is returned. - slong fmpz_poly_get_coeff_si(const fmpz_poly_t poly, slong n) noexcept - # Returns coefficient `n` of ``poly`` as a ``slong``. The result is - # undefined if the value does not fit into a ``slong``. Coefficient - # numbering is from zero and if `n` is set to a value beyond the end of - # the polynomial, zero is returned. - ulong fmpz_poly_get_coeff_ui(const fmpz_poly_t poly, slong n) noexcept - # Returns coefficient `n` of ``poly`` as a ``ulong``. The result is - # undefined if the value does not fit into a ``ulong``. Coefficient - # numbering is from zero and if `n` is set to a value beyond the end of the - # polynomial, zero is returned. - fmpz * fmpz_poly_get_coeff_ptr(const fmpz_poly_t poly, slong n) noexcept - # Returns a reference to the coefficient of `x^n` in the polynomial, - # as an ``fmpz *``. This function is provided so that individual - # coefficients can be accessed and operated on by functions in the - # ``fmpz`` module. This function does not make a copy of the - # data, but returns a reference to the actual coefficient. - # Returns ``NULL`` when `n` exceeds the degree of the polynomial. - # This function is implemented as a macro. - fmpz * fmpz_poly_lead(const fmpz_poly_t poly) noexcept - # Returns a reference to the leading coefficient of the polynomial, - # as an ``fmpz *``. This function is provided so that the leading - # coefficient can be easily accessed and operated on by functions in - # the ``fmpz`` module. This function does not make a copy of the - # data, but returns a reference to the actual coefficient. - # Returns ``NULL`` when the polynomial is zero. - # This function is implemented as a macro. - void fmpz_poly_set_coeff_fmpz(fmpz_poly_t poly, slong n, const fmpz_t x) noexcept - # Sets coefficient `n` of ``poly`` to the ``fmpz`` value ``x``. - # Coefficient numbering starts from zero and if `n` is beyond the current - # length of ``poly`` then the polynomial is extended and zero - # coefficients inserted if necessary. - void fmpz_poly_set_coeff_si(fmpz_poly_t poly, slong n, slong x) noexcept - # Sets coefficient `n` of ``poly`` to the ``slong`` value ``x``. - # Coefficient numbering starts from zero and if `n` is beyond the current - # length of ``poly`` then the polynomial is extended and zero - # coefficients inserted if necessary. - void fmpz_poly_set_coeff_ui(fmpz_poly_t poly, slong n, ulong x) noexcept - # Sets coefficient `n` of ``poly`` to the ``ulong`` value - # ``x``. Coefficient numbering starts from zero and if `n` is beyond - # the current length of ``poly`` then the polynomial is extended and - # zero coefficients inserted if necessary. - bint fmpz_poly_equal(const fmpz_poly_t poly1, const fmpz_poly_t poly2) noexcept - # Returns `1` if ``poly1`` is equal to ``poly2``, otherwise - # returns `0`. The polynomials are assumed to be normalised. - bint fmpz_poly_equal_trunc(const fmpz_poly_t poly1, const fmpz_poly_t poly2, slong n) noexcept - # Return `1` if ``poly1`` and ``poly2``, notionally truncated to - # length `n` are equal, otherwise return `0`. - bint fmpz_poly_is_zero(const fmpz_poly_t poly) noexcept - # Returns `1` if the polynomial is zero and `0` otherwise. - # This function is implemented as a macro. - bint fmpz_poly_is_one(const fmpz_poly_t poly) noexcept - # Returns `1` if the polynomial is one and `0` otherwise. - bint fmpz_poly_is_unit(const fmpz_poly_t poly) noexcept - # Returns `1` if the polynomial is the constant polynomial `\pm 1`, - # and `0` otherwise. - bint fmpz_poly_is_gen(const fmpz_poly_t poly) noexcept - # Returns `1` if the polynomial is the degree `1` polynomial `x`, and `0` - # otherwise. - void _fmpz_poly_add(fmpz * res, const fmpz * poly1, slong len1, const fmpz * poly2, slong len2) noexcept - # Sets ``res`` to the sum of ``(poly1, len1)`` and - # ``(poly2, len2)``. It is assumed that ``res`` has - # sufficient space for the longer of the two polynomials. - void fmpz_poly_add(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2) noexcept - # Sets ``res`` to the sum of ``poly1`` and ``poly2``. - void fmpz_poly_add_series(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2, slong n) noexcept - # Notionally truncate ``poly1`` and ``poly2`` to length `n` and then - # set ``res`` to the sum. - void _fmpz_poly_sub(fmpz * res, const fmpz * poly1, slong len1, const fmpz * poly2, slong len2) noexcept - # Sets ``res`` to ``(poly1, len1)`` minus ``(poly2, len2)``. It - # is assumed that ``res`` has sufficient space for the longer of the - # two polynomials. - void fmpz_poly_sub(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2) noexcept - # Sets ``res`` to ``poly1`` minus ``poly2``. - void fmpz_poly_sub_series(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2, slong n) noexcept - # Notionally truncate ``poly1`` and ``poly2`` to length `n` and then - # set ``res`` to the sum. - void fmpz_poly_neg(fmpz_poly_t res, const fmpz_poly_t poly) noexcept - # Sets ``res`` to ``-poly``. - void fmpz_poly_scalar_abs(fmpz_poly_t res, const fmpz_poly_t poly) noexcept - # Sets ``poly1`` to the polynomial whose coefficients are the absolute - # value of those of ``poly2``. - void fmpz_poly_scalar_mul_fmpz(fmpz_poly_t poly1, const fmpz_poly_t poly2, const fmpz_t x) noexcept - # Sets ``poly1`` to ``poly2`` times `x`. - void fmpz_poly_scalar_mul_si(fmpz_poly_t poly1, const fmpz_poly_t poly2, slong x) noexcept - # Sets ``poly1`` to ``poly2`` times the signed ``slong x``. - void fmpz_poly_scalar_mul_ui(fmpz_poly_t poly1, const fmpz_poly_t poly2, ulong x) noexcept - # Sets ``poly1`` to ``poly2`` times the ``ulong x``. - void fmpz_poly_scalar_mul_2exp(fmpz_poly_t poly1, const fmpz_poly_t poly2, ulong exp) noexcept - # Sets ``poly1`` to ``poly2`` times ``2^exp``. - void fmpz_poly_scalar_addmul_si(fmpz_poly_t poly1, const fmpz_poly_t poly2, slong x) noexcept - void fmpz_poly_scalar_addmul_ui(fmpz_poly_t poly1, const fmpz_poly_t poly2, ulong x) noexcept - void fmpz_poly_scalar_addmul_fmpz(fmpz_poly_t poly1, const fmpz_poly_t poly2, const fmpz_t x) noexcept - # Sets ``poly1`` to ``poly1 + x * poly2``. - void fmpz_poly_scalar_submul_fmpz(fmpz_poly_t poly1, const fmpz_poly_t poly2, const fmpz_t x) noexcept - # Sets ``poly1`` to ``poly1 - x * poly2``. - void fmpz_poly_scalar_fdiv_fmpz(fmpz_poly_t poly1, const fmpz_poly_t poly2, const fmpz_t x) noexcept - # Sets ``poly1`` to ``poly2`` divided by the ``fmpz_t x``, - # rounding coefficients down toward `- \infty`. - void fmpz_poly_scalar_fdiv_si(fmpz_poly_t poly1, const fmpz_poly_t poly2, slong x) noexcept - # Sets ``poly1`` to ``poly2`` divided by the ``slong x``, - # rounding coefficients down toward `- \infty`. - void fmpz_poly_scalar_fdiv_ui(fmpz_poly_t poly1, const fmpz_poly_t poly2, ulong x) noexcept - # Sets ``poly1`` to ``poly2`` divided by the ``ulong x``, - # rounding coefficients down toward `- \infty`. - void fmpz_poly_scalar_fdiv_2exp(fmpz_poly_t poly1, const fmpz_poly_t poly2, ulong x) noexcept - # Sets ``poly1`` to ``poly2`` divided by ``2^x``, - # rounding coefficients down toward `- \infty`. - void fmpz_poly_scalar_tdiv_fmpz(fmpz_poly_t poly1, const fmpz_poly_t poly2, const fmpz_t x) noexcept - # Sets ``poly1`` to ``poly2`` divided by the ``fmpz_t x``, - # rounding coefficients toward `0`. - void fmpz_poly_scalar_tdiv_si(fmpz_poly_t poly1, const fmpz_poly_t poly2, slong x) noexcept - # Sets ``poly1`` to ``poly2`` divided by the ``slong x``, - # rounding coefficients toward `0`. - void fmpz_poly_scalar_tdiv_ui(fmpz_poly_t poly1, const fmpz_poly_t poly2, ulong x) noexcept - # Sets ``poly1`` to ``poly2`` divided by the ``ulong x``, - # rounding coefficients toward `0`. - void fmpz_poly_scalar_tdiv_2exp(fmpz_poly_t poly1, const fmpz_poly_t poly2, ulong x) noexcept - # Sets ``poly1`` to ``poly2`` divided by ``2^x``, - # rounding coefficients toward `0`. - void fmpz_poly_scalar_divexact_fmpz(fmpz_poly_t poly1, const fmpz_poly_t poly2, const fmpz_t x) noexcept - # Sets ``poly1`` to ``poly2`` divided by the ``fmpz_t x``, - # assuming the division is exact for every coefficient. - void fmpz_poly_scalar_divexact_si(fmpz_poly_t poly1, const fmpz_poly_t poly2, slong x) noexcept - # Sets ``poly1`` to ``poly2`` divided by the ``slong x``, - # assuming the coefficient is exact for every coefficient. - void fmpz_poly_scalar_divexact_ui(fmpz_poly_t poly1, const fmpz_poly_t poly2, ulong x) noexcept - # Sets ``poly1`` to ``poly2`` divided by the ``ulong x``, - # assuming the coefficient is exact for every coefficient. - void fmpz_poly_scalar_mod_fmpz(fmpz_poly_t poly1, const fmpz_poly_t poly2, const fmpz_t p) noexcept - # Sets ``poly1`` to ``poly2``, reducing each coefficient - # modulo `p > 0`. - void fmpz_poly_scalar_smod_fmpz(fmpz_poly_t poly1, const fmpz_poly_t poly2, const fmpz_t p) noexcept - # Sets ``poly1`` to ``poly2``, symmetrically reducing - # each coefficient modulo `p > 0`, that is, choosing the unique - # representative in the interval `(-p/2, p/2]`. - slong _fmpz_poly_remove_content_2exp(fmpz * pol, slong len) noexcept - # Remove the 2-content of ``pol`` and return the number `k` - # that is the maximal non-negative integer so that `2^k` divides - # all coefficients of the polynomial. For the zero polynomial, - # `0` is returned. - void _fmpz_poly_scale_2exp(fmpz * pol, slong len, slong k) noexcept - # Scale ``(pol, len)`` to `p(2^k X)` in-place and divide by the - # 2-content (so that the gcd of coefficients is odd). If ``k`` - # is negative the polynomial is multiplied by `2^{kd}`. - void _fmpz_poly_bit_pack(mp_ptr arr, const fmpz * poly, slong len, flint_bitcnt_t bit_size, int negate) noexcept - # Packs the coefficients of ``poly`` into bitfields of the given - # ``bit_size``, negating the coefficients before packing - # if ``negate`` is set to `-1`. - int _fmpz_poly_bit_unpack(fmpz * poly, slong len, mp_srcptr arr, flint_bitcnt_t bit_size, int negate) noexcept - # Unpacks the polynomial of given length from the array as packed into - # fields of the given ``bit_size``, finally negating the coefficients - # if ``negate`` is set to `-1`. Returns borrow, which is nonzero if a - # leading term with coefficient `\pm1` should be added at - # position ``len`` of ``poly``. - void _fmpz_poly_bit_unpack_unsigned(fmpz * poly, slong len, mp_srcptr arr, flint_bitcnt_t bit_size) noexcept - # Unpacks the polynomial of given length from the array as packed into - # fields of the given ``bit_size``. The coefficients are assumed to - # be unsigned. - void fmpz_poly_bit_pack(fmpz_t f, const fmpz_poly_t poly, flint_bitcnt_t bit_size) noexcept - # Packs ``poly`` into bitfields of size ``bit_size``, writing the - # result to ``f``. The sign of ``f`` will be the same as that of - # the leading coefficient of ``poly``. - void fmpz_poly_bit_unpack(fmpz_poly_t poly, const fmpz_t f, flint_bitcnt_t bit_size) noexcept - # Unpacks the polynomial with signed coefficients packed into - # fields of size ``bit_size`` as represented by the integer ``f``. - void fmpz_poly_bit_unpack_unsigned(fmpz_poly_t poly, const fmpz_t f, flint_bitcnt_t bit_size) noexcept - # Unpacks the polynomial with unsigned coefficients packed into - # fields of size ``bit_size`` as represented by the integer ``f``. - # It is required that ``f`` is nonnegative. - void _fmpz_poly_mul_classical(fmpz * res, const fmpz * poly1, slong len1, const fmpz * poly2, slong len2) noexcept - # Sets ``(res, len1 + len2 - 1)`` to the product of ``(poly1, len1)`` - # and ``(poly2, len2)``. - # Assumes ``len1`` and ``len2`` are positive. Allows zero-padding - # of the two input polynomials. No aliasing of inputs with outputs is - # allowed. - void fmpz_poly_mul_classical(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2) noexcept - # Sets ``res`` to the product of ``poly1`` and ``poly2``, computed - # using the classical or schoolbook method. - void _fmpz_poly_mullow_classical(fmpz * res, const fmpz * poly1, slong len1, const fmpz * poly2, slong len2, slong n) noexcept - # Sets ``(res, n)`` to the first `n` coefficients of ``(poly1, len1)`` - # multiplied by ``(poly2, len2)``. - # Assumes ``0 < n <= len1 + len2 - 1``. Assumes neither ``len1`` nor - # ``len2`` is zero. - void fmpz_poly_mullow_classical(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2, slong n) noexcept - # Sets ``res`` to the first `n` coefficients of ``poly1 * poly2``. - void _fmpz_poly_mulhigh_classical(fmpz * res, const fmpz * poly1, slong len1, const fmpz * poly2, slong len2, slong start) noexcept - # Sets the first ``start`` coefficients of ``res`` to zero and the - # remainder to the corresponding coefficients of - # ``(poly1, len1) * (poly2, len2)``. - # Assumes ``start <= len1 + len2 - 1``. Assumes neither ``len1`` nor - # ``len2`` is zero. - void fmpz_poly_mulhigh_classical(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2, slong start) noexcept - # Sets the first ``start`` coefficients of ``res`` to zero and the - # remainder to the corresponding coefficients of the product of ``poly1`` - # and ``poly2``. - void _fmpz_poly_mulmid_classical(fmpz * res, const fmpz * poly1, slong len1, const fmpz * poly2, slong len2) noexcept - # Sets ``res`` to the middle ``len1 - len2 + 1`` coefficients of - # the product of ``(poly1, len1)`` and ``(poly2, len2)``, i.e. the - # coefficients from degree ``len2 - 1`` to ``len1 - 1`` inclusive. - # Assumes that ``len1 >= len2 > 0``. - void fmpz_poly_mulmid_classical(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2) noexcept - # Sets ``res`` to the middle ``len(poly1) - len(poly2) + 1`` - # coefficients of ``poly1 * poly2``, i.e. the coefficient from degree - # ``len2 - 1`` to ``len1 - 1`` inclusive. Assumes that - # ``len1 >= len2``. - void _fmpz_poly_mul_karatsuba(fmpz * res, const fmpz * poly1, slong len1, const fmpz * poly2, slong len2) noexcept - # Sets ``(res, len1 + len2 - 1)`` to the product of ``(poly1, len1)`` - # and ``(poly2, len2)``. Assumes ``len1 >= len2 > 0``. Allows - # zero-padding of the two input polynomials. No aliasing of inputs with - # outputs is allowed. - void fmpz_poly_mul_karatsuba(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2) noexcept - # Sets ``res`` to the product of ``poly1`` and ``poly2``. - void _fmpz_poly_mullow_karatsuba_n(fmpz * res, const fmpz * poly1, const fmpz * poly2, slong n) noexcept - # Sets ``res`` to the product of ``poly1`` and ``poly2`` and - # truncates to the given length. It is assumed that ``poly1`` and - # ``poly2`` are precisely the given length, possibly zero padded. - # Assumes `n` is not zero. - void fmpz_poly_mullow_karatsuba_n(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2, slong n) noexcept - # Sets ``res`` to the product of ``poly1`` and ``poly2`` and - # truncates to the given length. - void _fmpz_poly_mulhigh_karatsuba_n(fmpz * res, const fmpz * poly1, const fmpz * poly2, slong len) noexcept - # Sets ``res`` to the product of ``poly1`` and ``poly2`` and - # truncates at the top to the given length. The first ``len - 1`` - # coefficients are set to zero. It is assumed that ``poly1`` and - # ``poly2`` are precisely the given length, possibly zero padded. - # Assumes ``len`` is not zero. - void fmpz_poly_mulhigh_karatsuba_n(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2, slong len) noexcept - # Sets the first ``len - 1`` coefficients of the result to zero and the - # remaining coefficients to the corresponding coefficients of the product of - # ``poly1`` and ``poly2``. Assumes ``poly1`` and ``poly2`` are - # at most of the given length. - void _fmpz_poly_mul_KS(fmpz * res, const fmpz * poly1, slong len1, const fmpz * poly2, slong len2) noexcept - # Sets ``(res, len1 + len2 - 1)`` to the product of ``(poly1, len1)`` - # and ``(poly2, len2)``. - # Places no assumptions on ``len1`` and ``len2``. Allows zero-padding - # of the two input polynomials. Supports aliasing of inputs and outputs. - void fmpz_poly_mul_KS(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2) noexcept - # Sets ``res`` to the product of ``poly1`` and ``poly2``. - void _fmpz_poly_mullow_KS(fmpz * res, const fmpz * poly1, slong len1, const fmpz * poly2, slong len2, slong n) noexcept - # Sets ``(res, n)`` to the lowest `n` coefficients of the product of - # ``(poly1, len1)`` and ``(poly2, len2)``. - # Assumes that ``len1`` and ``len2`` are positive, but does allow - # for the polynomials to be zero-padded. The polynomials may be zero, - # too. Assumes `n` is positive. Supports aliasing between ``res``, - # ``poly1`` and ``poly2``. - void fmpz_poly_mullow_KS(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2, slong n) noexcept - # Sets ``res`` to the lowest `n` coefficients of the product of - # ``poly1`` and ``poly2``. - void _fmpz_poly_mul_SS(fmpz * output, const fmpz * input1, slong length1, const fmpz * input2, slong length2) noexcept - # Sets ``(output, length1 + length2 - 1)`` to the product of - # ``(input1, length1)`` and ``(input2, length2)``. - # We must have ``len1 > 1`` and ``len2 > 1``. Allows zero-padding - # of the two input polynomials. Supports aliasing of inputs and outputs. - void fmpz_poly_mul_SS(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2) noexcept - # Sets ``res`` to the product of ``poly1`` and ``poly2``. Uses the - # Schönhage-Strassen algorithm. - void _fmpz_poly_mullow_SS(fmpz * output, const fmpz * input1, slong length1, const fmpz * input2, slong length2, slong n) noexcept - # Sets ``(res, n)`` to the lowest `n` coefficients of the product of - # ``(poly1, len1)`` and ``(poly2, len2)``. - # Assumes that ``len1`` and ``len2`` are positive, but does allow - # for the polynomials to be zero-padded. We must have ``len1 > 1`` - # and ``len2 > 1``. Assumes `n` is positive. Supports aliasing between - # ``res``, ``poly1`` and ``poly2``. - void fmpz_poly_mullow_SS(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2, slong n) noexcept - # Sets ``res`` to the lowest `n` coefficients of the product of - # ``poly1`` and ``poly2``. - void _fmpz_poly_mul(fmpz * res, const fmpz * poly1, slong len1, const fmpz * poly2, slong len2) noexcept - # Sets ``(res, len1 + len2 - 1)`` to the product of ``(poly1, len1)`` - # and ``(poly2, len2)``. Assumes ``len1 >= len2 > 0``. Allows - # zero-padding of the two input polynomials. Does not support aliasing - # between the inputs and the output. - void fmpz_poly_mul(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2) noexcept - # Sets ``res`` to the product of ``poly1`` and ``poly2``. Chooses - # an optimal algorithm from the choices above. - void _fmpz_poly_mullow(fmpz * res, const fmpz * poly1, slong len1, const fmpz * poly2, slong len2, slong n) noexcept - # Sets ``(res, n)`` to the lowest `n` coefficients of the product of - # ``(poly1, len1)`` and ``(poly2, len2)``. - # Assumes ``len1 >= len2 > 0`` and ``0 < n <= len1 + len2 - 1``. - # Allows for zero-padding in the inputs. Does not support aliasing between - # the inputs and the output. - void fmpz_poly_mullow(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2, slong n) noexcept - # Sets ``res`` to the lowest `n` coefficients of the product of - # ``poly1`` and ``poly2``. - void fmpz_poly_mulhigh_n(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2, slong n) noexcept - # Sets the high `n` coefficients of ``res`` to the high `n` coefficients - # of the product of ``poly1`` and ``poly2``, assuming the latter are - # precisely `n` coefficients in length, zero padded if necessary. The - # remaining `n - 1` coefficients may be arbitrary. - void _fmpz_poly_mulhigh(fmpz * res, const fmpz * poly1, slong len1, const fmpz * poly2, slong len2, slong start) noexcept - # Sets all but the low `n` coefficients of `res` to the corresponding - # coefficients of the product of `poly1` of length `len1` and `poly2` of - # length `len2`, the remaining coefficients being arbitrary. It is assumed - # that `len1 >= len2 > 0` and that `0 < n < len1 + len2 - 1`. Aliasing of - # inputs is not permitted. - void fmpz_poly_mul_SS_precache_init(fmpz_poly_mul_precache_t pre, slong len1, slong bits1, const fmpz_poly_t poly2) noexcept - # Precompute the FFT of ``poly2`` to enable repeated multiplication of - # ``poly2`` by polynomials whose length does not exceed ``len1`` and - # whose number of bits per coefficient does not exceed ``bits1``. - # The value ``bits1`` may be negative, i.e. it may be the result of - # calling ``fmpz_poly_max_bits``. The function only considers the - # absolute value of ``bits1``. - # Suppose ``len2`` is the length of ``poly2`` and - # ``len = len1 + len2 - 1`` is the maximum output length of a polynomial - # multiplication using ``pre``. Then internally ``len`` is rounded up to - # a power of two, `2^n` say. The truncated FFT algorithm is used to smooth - # performance but note that it can only do this in the range - # `(2^{n-1}, 2^n]`. Therefore, it may be more efficient to recompute `pre` - # for cases where the output length will fall below `2^{n-1} + 1`. Otherwise - # the implementation will zero pad them up to that length. - # Note that the Schoenhage-Strassen algorithm is only efficient for - # polynomials with relatively large coefficients relative to the length of - # the polynomials. - # Also note that there are no restrictions on the polynomials. In particular - # the polynomial whose FFT is being precached does not have to be either - # longer or shorter than the polynomials it is to be multiplied by. - void fmpz_poly_mul_precache_clear(fmpz_poly_mul_precache_t pre) noexcept - # Clear the space allocated by ``fmpz_poly_mul_SS_precache_init``. - void _fmpz_poly_mullow_SS_precache(fmpz * output, const fmpz * input1, slong len1, fmpz_poly_mul_precache_t pre, slong trunc) noexcept - # Write into ``output`` the first ``trunc`` coefficients of - # the polynomial ``(input1, len1)`` by the polynomial whose FFT was precached - # by ``fmpz_poly_mul_SS_precache_init`` and stored in ``pre``. - # For performance reasons it is recommended that all polynomials be truncated - # to at most ``trunc`` coefficients if possible. - void fmpz_poly_mullow_SS_precache(fmpz_poly_t res, const fmpz_poly_t poly1, fmpz_poly_mul_precache_t pre, slong n) noexcept - # Set ``res`` to the product of ``poly1`` by the polynomial whose FFT was - # precached by ``fmpz_poly_mul_SS_precache_init`` (and stored in pre). The - # result is truncated to `n` coefficients (and normalised). - # There are no restrictions on the length of ``poly1`` other than those given - # in the call to ``fmpz_poly_mul_SS_precache_init``. - void fmpz_poly_mul_SS_precache(fmpz_poly_t res, const fmpz_poly_t poly1, fmpz_poly_mul_precache_t pre) noexcept - # Set ``res`` to the product of ``poly1`` by the polynomial whose FFT was - # precached by ``fmpz_poly_mul_SS_precache_init`` (and stored in pre). - # There are no restrictions on the length of ``poly1`` other than those given - # in the call to ``fmpz_poly_mul_SS_precache_init``. - void _fmpz_poly_sqr_KS(fmpz * rop, const fmpz * op, slong len) noexcept - # Sets ``(rop, 2*len - 1)`` to the square of ``(op, len)``, - # assuming that ``len > 0``. - # Supports zero-padding in ``(op, len)``. Does not support aliasing. - void fmpz_poly_sqr_KS(fmpz_poly_t rop, const fmpz_poly_t op) noexcept - # Sets ``rop`` to the square of the polynomial ``op`` using - # Kronecker segmentation. - void _fmpz_poly_sqr_karatsuba(fmpz * rop, const fmpz * op, slong len) noexcept - # Sets ``(rop, 2*len - 1)`` to the square of ``(op, len)``, - # assuming that ``len > 0``. - # Supports zero-padding in ``(op, len)``. Does not support aliasing. - void fmpz_poly_sqr_karatsuba(fmpz_poly_t rop, const fmpz_poly_t op) noexcept - # Sets ``rop`` to the square of the polynomial ``op`` using - # the Karatsuba multiplication algorithm. - void _fmpz_poly_sqr_classical(fmpz * rop, const fmpz * op, slong len) noexcept - # Sets ``(rop, 2*len - 1)`` to the square of ``(op, len)``, - # assuming that ``len > 0``. - # Supports zero-padding in ``(op, len)``. Does not support aliasing. - void fmpz_poly_sqr_classical(fmpz_poly_t rop, const fmpz_poly_t op) noexcept - # Sets ``rop`` to the square of the polynomial ``op`` using - # the classical or schoolbook method. - void _fmpz_poly_sqr(fmpz * rop, const fmpz * op, slong len) noexcept - # Sets ``(rop, 2*len - 1)`` to the square of ``(op, len)``, - # assuming that ``len > 0``. - # Supports zero-padding in ``(op, len)``. Does not support aliasing. - void fmpz_poly_sqr(fmpz_poly_t rop, const fmpz_poly_t op) noexcept - # Sets ``rop`` to the square of the polynomial ``op``. - void _fmpz_poly_sqrlow_KS(fmpz * res, const fmpz * poly, slong len, slong n) noexcept - # Sets ``(res, n)`` to the lowest `n` coefficients - # of the square of ``(poly, len)``. - # Assumes that ``len`` is positive, but does allow for the polynomial - # to be zero-padded. The polynomial may be zero, too. Assumes `n` is - # positive. Supports aliasing between ``res`` and ``poly``. - void fmpz_poly_sqrlow_KS(fmpz_poly_t res, const fmpz_poly_t poly, slong n) noexcept - # Sets ``res`` to the lowest `n` coefficients - # of the square of ``poly``. - void _fmpz_poly_sqrlow_karatsuba_n(fmpz * res, const fmpz * poly, slong n) noexcept - # Sets ``(res, n)`` to the square of ``(poly, n)`` truncated - # to length `n`, which is assumed to be positive. Allows for ``poly`` - # to be zero-padded. - void fmpz_poly_sqrlow_karatsuba_n(fmpz_poly_t res, const fmpz_poly_t poly, slong n) noexcept - # Sets ``res`` to the square of ``poly`` and - # truncates to the given length. - void _fmpz_poly_sqrlow_classical(fmpz * res, const fmpz * poly, slong len, slong n) noexcept - # Sets ``(res, n)`` to the first `n` coefficients of the square - # of ``(poly, len)``. - # Assumes that ``0 < n <= 2 * len - 1``. - void fmpz_poly_sqrlow_classical(fmpz_poly_t res, const fmpz_poly_t poly, slong n) noexcept - # Sets ``res`` to the first `n` coefficients of - # the square of ``poly``. - void _fmpz_poly_sqrlow(fmpz * res, const fmpz * poly, slong len, slong n) noexcept - # Sets ``(res, n)`` to the lowest `n` coefficients - # of the square of ``(poly, len)``. - # Assumes ``len1 >= len2 > 0`` and ``0 < n <= 2 * len - 1``. - # Allows for zero-padding in the input. Does not support aliasing - # between the input and the output. - void fmpz_poly_sqrlow(fmpz_poly_t res, const fmpz_poly_t poly, slong n) noexcept - # Sets ``res`` to the lowest `n` coefficients - # of the square of ``poly``. - void _fmpz_poly_pow_multinomial(fmpz * res, const fmpz * poly, slong len, ulong e) noexcept - # Computes ``res = poly^e``. This uses the J.C.P. Miller pure - # recurrence as follows: - # If `\ell` is the index of the lowest non-zero coefficient in ``poly``, - # as a first step this method zeros out the lowest `e \ell` coefficients of - # ``res``. The recurrence above is then used to compute the remaining - # coefficients. - # Assumes ``len > 0``, ``e > 0``. Does not support aliasing. - void fmpz_poly_pow_multinomial(fmpz_poly_t res, const fmpz_poly_t poly, ulong e) noexcept - # Computes ``res = poly^e`` using a generalisation of binomial expansion - # called the J.C.P. Miller pure recurrence [1], [2]. - # If `e` is zero, returns one, so that in particular ``0^0 = 1``. - # The formal statement of the recurrence is as follows. Write the input - # polynomial as `P(x) = p_0 + p_1 x + \dotsb + p_m x^m` with `p_0 \neq 0` - # and let - # .. math :: - # P(x)^n = a(n, 0) + a(n, 1) x + \dotsb + a(n, mn) x^{mn}. - # Then `a(n, 0) = p_0^n` and, for all `1 \leq k \leq mn`, - # .. math :: - # a(n, k) = - # (k p_0)^{-1} \sum_{i = 1}^m p_i \bigl( (n + 1) i - k \bigr) a(n, k-i). - # [1] D. Knuth, The Art of Computer Programming Vol. 2, Seminumerical - # Algorithms, Third Edition (Reading, Massachusetts: Addison-Wesley, 1997) - # [2] D. Zeilberger, The J.C.P. Miller Recurrence for Exponentiating a - # Polynomial, and its q-Analog, Journal of Difference Equations and - # Applications, 1995, Vol. 1, pp. 57--60 - void _fmpz_poly_pow_binomial(fmpz * res, const fmpz * poly, ulong e) noexcept - # Computes ``res = poly^e`` when poly is of length 2, using binomial - # expansion. - # Assumes `e > 0`. Does not support aliasing. - void fmpz_poly_pow_binomial(fmpz_poly_t res, const fmpz_poly_t poly, ulong e) noexcept - # Computes ``res = poly^e`` when ``poly`` is of length `2`, using - # binomial expansion. - # If the length of ``poly`` is not `2`, raises an exception and aborts. - void _fmpz_poly_pow_addchains(fmpz * res, const fmpz * poly, slong len, const int * a, int n) noexcept - # Given a star chain `1 = a_0 < a_1 < \dotsb < a_n = e` computes - # ``res = poly^e``. - # A star chain is an addition chain `1 = a_0 < a_1 < \dotsb < a_n` such - # that, for all `i > 0`, `a_i = a_{i-1} + a_j` for some `j < i`. - # Assumes that `e > 2`, or equivalently `n > 1`, and ``len > 0``. Does - # not support aliasing. - void fmpz_poly_pow_addchains(fmpz_poly_t res, const fmpz_poly_t poly, ulong e) noexcept - # Computes ``res = poly^e`` using addition chains whenever - # `0 \leq e \leq 148`. - # If `e > 148`, raises an exception and aborts. - void _fmpz_poly_pow_binexp(fmpz * res, const fmpz * poly, slong len, ulong e) noexcept - # Sets ``res = poly^e`` using left-to-right binary exponentiation as - # described on p. 461 of [Knu1997]_. - # Assumes that ``len > 0``, ``e > 1``. Assumes that ``res`` is - # an array of length at least ``e*(len - 1) + 1``. Does not support - # aliasing. - void fmpz_poly_pow_binexp(fmpz_poly_t res, const fmpz_poly_t poly, ulong e) noexcept - # Computes ``res = poly^e`` using the binary exponentiation algorithm. - # If `e` is zero, returns one, so that in particular ``0^0 = 1``. - void _fmpz_poly_pow_small(fmpz * res, const fmpz * poly, slong len, ulong e) noexcept - # Sets ``res = poly^e`` whenever `0 \leq e \leq 4`. - # Assumes that ``len > 0`` and that ``res`` is an array of length - # at least ``e*(len - 1) + 1``. Does not support aliasing. - void _fmpz_poly_pow(fmpz * res, const fmpz * poly, slong len, ulong e) noexcept - # Sets ``res = poly^e``, assuming that ``e, len > 0`` and that - # ``res`` has space for ``e*(len - 1) + 1`` coefficients. Does - # not support aliasing. - void fmpz_poly_pow(fmpz_poly_t res, const fmpz_poly_t poly, ulong e) noexcept - # Computes ``res = poly^e``. If `e` is zero, returns one, - # so that in particular ``0^0 = 1``. - void _fmpz_poly_pow_trunc(fmpz * res, const fmpz * poly, ulong e, slong n) noexcept - # Sets ``(res, n)`` to ``(poly, n)`` raised to the power `e` and - # truncated to length `n`. - # Assumes that `e, n > 0`. Allows zero-padding of ``(poly, n)``. - # Does not support aliasing of any inputs and outputs. - void fmpz_poly_pow_trunc(fmpz_poly_t res, const fmpz_poly_t poly, ulong e, slong n) noexcept - # Notationally raises ``poly`` to the power `e`, truncates the result - # to length `n` and writes the result in ``res``. This is computed - # much more efficiently than simply powering the polynomial and truncating. - # Thus, if `n = 0` the result is zero. Otherwise, whenever `e = 0` the - # result will be the constant polynomial equal to `1`. - # This function can be used to raise power series to a power in an - # efficient way. - void _fmpz_poly_shift_left(fmpz * res, const fmpz * poly, slong len, slong n) noexcept - # Sets ``(res, len + n)`` to ``(poly, len)`` shifted left by - # `n` coefficients. - # Inserts zero coefficients at the lower end. Assumes that ``len`` - # and `n` are positive, and that ``res`` fits ``len + n`` elements. - # Supports aliasing between ``res`` and ``poly``. - void fmpz_poly_shift_left(fmpz_poly_t res, const fmpz_poly_t poly, slong n) noexcept - # Sets ``res`` to ``poly`` shifted left by `n` coeffs. Zero - # coefficients are inserted. - void _fmpz_poly_shift_right(fmpz * res, const fmpz * poly, slong len, slong n) noexcept - # Sets ``(res, len - n)`` to ``(poly, len)`` shifted right by - # `n` coefficients. - # Assumes that ``len`` and `n` are positive, that ``len > n``, - # and that ``res`` fits ``len - n`` elements. Supports aliasing - # between ``res`` and ``poly``, although in this case the top - # coefficients of ``poly`` are not set to zero. - void fmpz_poly_shift_right(fmpz_poly_t res, const fmpz_poly_t poly, slong n) noexcept - # Sets ``res`` to ``poly`` shifted right by `n` coefficients. If `n` - # is equal to or greater than the current length of ``poly``, ``res`` - # is set to the zero polynomial. - ulong fmpz_poly_max_limbs(const fmpz_poly_t poly) noexcept - # Returns the maximum number of limbs required to store the absolute value - # of coefficients of ``poly``. If ``poly`` is zero, returns `0`. - slong fmpz_poly_max_bits(const fmpz_poly_t poly) noexcept - # Computes the maximum number of bits `b` required to store the absolute - # value of coefficients of ``poly``. If all the coefficients of - # ``poly`` are non-negative, `b` is returned, otherwise `-b` is returned. - void fmpz_poly_height(fmpz_t height, const fmpz_poly_t poly) noexcept - # Computes the height of ``poly``, defined as the largest of the - # absolute values of the coefficients of ``poly``. Equivalently, this - # gives the infinity norm of the coefficients. If ``poly`` is zero, - # the height is `0`. - void _fmpz_poly_2norm(fmpz_t res, const fmpz * poly, slong len) noexcept - # Sets ``res`` to the Euclidean norm of ``(poly, len)``, that is, - # the integer square root of the sum of the squares of the coefficients - # of ``poly``. - void fmpz_poly_2norm(fmpz_t res, const fmpz_poly_t poly) noexcept - # Sets ``res`` to the Euclidean norm of ``poly``, that is, the - # integer square root of the sum of the squares of the coefficients of - # ``poly``. - mp_limb_t _fmpz_poly_2norm_normalised_bits(const fmpz * poly, slong len) noexcept - # Returns an upper bound on the number of bits of the normalised - # Euclidean norm of ``(poly, len)``, i.e. the number of bits of - # the Euclidean norm divided by the absolute value of the leading - # coefficient. The returned value will be no more than 1 bit too - # large. - # This is used in the computation of the Landau-Mignotte bound. - # It is assumed that ``len > 0``. The result only makes sense - # if the leading coefficient is nonzero. - void _fmpz_poly_gcd_subresultant(fmpz * res, const fmpz * poly1, slong len1, const fmpz * poly2, slong len2) noexcept - # Computes the greatest common divisor ``(res, len2)`` of - # ``(poly1, len1)`` and ``(poly2, len2)``, assuming - # ``len1 >= len2 > 0``. The result is normalised to have - # positive leading coefficient. Aliasing between ``res``, - # ``poly1`` and ``poly2`` is supported. - void fmpz_poly_gcd_subresultant(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2) noexcept - # Computes the greatest common divisor ``res`` of ``poly1`` and - # ``poly2``, normalised to have non-negative leading coefficient. - # This function uses the subresultant algorithm as described - # in Algorithm 3.3.1 of [Coh1996]_. - int _fmpz_poly_gcd_heuristic(fmpz * res, const fmpz * poly1, slong len1, const fmpz * poly2, slong len2) noexcept - # Computes the greatest common divisor ``(res, len2)`` of - # ``(poly1, len1)`` and ``(poly2, len2)``, assuming - # ``len1 >= len2 > 0``. The result is normalised to have - # positive leading coefficient. Aliasing between ``res``, - # ``poly1`` and ``poly2`` is not supported. The function - # may not always succeed in finding the GCD. If it fails, the - # function returns 0, otherwise it returns 1. - int fmpz_poly_gcd_heuristic(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2) noexcept - # Computes the greatest common divisor ``res`` of ``poly1`` and - # ``poly2``, normalised to have non-negative leading coefficient. - # The function may not always succeed in finding the GCD. If it fails, - # the function returns 0, otherwise it returns 1. - # This function uses the heuristic GCD algorithm (GCDHEU). The basic - # strategy is to remove the content of the polynomials, pack them - # using Kronecker segmentation (given a bound on the size of the - # coefficients of the GCD) and take the integer GCD. Unpack the - # result and test divisibility. - void _fmpz_poly_gcd_modular(fmpz * res, const fmpz * poly1, slong len1, const fmpz * poly2, slong len2) noexcept - # Computes the greatest common divisor ``(res, len2)`` of - # ``(poly1, len1)`` and ``(poly2, len2)``, assuming - # ``len1 >= len2 > 0``. The result is normalised to have - # positive leading coefficient. Aliasing between ``res``, - # ``poly1`` and ``poly2`` is not supported. - void fmpz_poly_gcd_modular(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2) noexcept - # Computes the greatest common divisor ``res`` of ``poly1`` and - # ``poly2``, normalised to have non-negative leading coefficient. - # This function uses the modular GCD algorithm. The basic - # strategy is to remove the content of the polynomials, reduce them - # modulo sufficiently many primes and do CRT reconstruction until - # some bound is reached (or we can prove with trial division that - # we have the GCD). - void _fmpz_poly_gcd(fmpz * res, const fmpz * poly1, slong len1, const fmpz * poly2, slong len2) noexcept - # Computes the greatest common divisor ``res`` of ``(poly1, len1)`` - # and ``(poly2, len2)``, assuming ``len1 >= len2 > 0``. The result - # is normalised to have positive leading coefficient. - # Assumes that ``res`` has space for ``len2`` coefficients. - # Aliasing between ``res``, ``poly1`` and ``poly2`` is not - # supported. - void fmpz_poly_gcd(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2) noexcept - # Computes the greatest common divisor ``res`` of ``poly1`` and - # ``poly2``, normalised to have non-negative leading coefficient. - void _fmpz_poly_xgcd_modular(fmpz_t r, fmpz * s, fmpz * t, const fmpz * f, slong len1, const fmpz * g, slong len2) noexcept - # Set `r` to the resultant of ``(f, len1)`` and ``(g, len2)``. - # If the resultant is zero, the function returns immediately. Otherwise it - # finds polynomials `s` and `t` such that ``s*f + t*g = r``. The length - # of `s` will be no greater than ``len2`` and the length of `t` will be - # no greater than ``len1`` (both are zero padded if necessary). - # It is assumed that ``len1 >= len2 > 0``. No aliasing of inputs and - # outputs is permitted. - # The function assumes that `f` and `g` are primitive (have Gaussian content - # equal to 1). The result is undefined otherwise. - # Uses a multimodular algorithm. The resultant is first computed and - # extended GCDs modulo various primes `p` are computed and combined using - # CRT. When the CRT stabilises the resulting polynomials are simply reduced - # modulo further primes until a proven bound is reached. - void fmpz_poly_xgcd_modular(fmpz_t r, fmpz_poly_t s, fmpz_poly_t t, const fmpz_poly_t f, const fmpz_poly_t g) noexcept - # Set `r` to the resultant of `f` and `g`. If the resultant is zero, the - # function then returns immediately, otherwise `s` and `t` are found such - # that ``s*f + t*g = r``. - # The function assumes that `f` and `g` are primitive (have Gaussian content - # equal to 1). The result is undefined otherwise. - # Uses the multimodular algorithm. - void _fmpz_poly_xgcd(fmpz_t r, fmpz * s, fmpz * t, const fmpz * f, slong len1, const fmpz * g, slong len2) noexcept - # Set `r` to the resultant of ``(f, len1)`` and ``(g, len2)``. - # If the resultant is zero, the function returns immediately. Otherwise it - # finds polynomials `s` and `t` such that ``s*f + t*g = r``. The length - # of `s` will be no greater than ``len2`` and the length of `t` will be - # no greater than ``len1`` (both are zero padded if necessary). - # The function assumes that `f` and `g` are primitive (have Gaussian content - # equal to 1). The result is undefined otherwise. - # It is assumed that ``len1 >= len2 > 0``. No aliasing of inputs and - # outputs is permitted. - void fmpz_poly_xgcd(fmpz_t r, fmpz_poly_t s, fmpz_poly_t t, const fmpz_poly_t f, const fmpz_poly_t g) noexcept - # Set `r` to the resultant of `f` and `g`. If the resultant is zero, the - # function then returns immediately, otherwise `s` and `t` are found such - # that ``s*f + t*g = r``. - # The function assumes that `f` and `g` are primitive (have Gaussian content - # equal to 1). The result is undefined otherwise. - void _fmpz_poly_lcm(fmpz * res, const fmpz * poly1, slong len1, const fmpz * poly2, slong len2) noexcept - # Sets ``(res, len1 + len2 - 1)`` to the least common multiple - # of the two polynomials ``(poly1, len1)`` and ``(poly2, len2)``, - # normalised to have non-negative leading coefficient. - # Assumes that ``len1 >= len2 > 0``. - # Does not support aliasing. - void fmpz_poly_lcm(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2) noexcept - # Sets ``res`` to the least common multiple of the two - # polynomials ``poly1`` and ``poly2``, normalised to - # have non-negative leading coefficient. - # If either of the two polynomials is zero, sets ``res`` - # to zero. - # This ensures that the equality - # .. math :: - # f g = \gcd(f, g) \operatorname{lcm}(f, g) - # holds up to sign. - void _fmpz_poly_resultant_modular(fmpz_t res, const fmpz * poly1, slong len1, const fmpz * poly2, slong len2) noexcept - # Sets ``res`` to the resultant of ``(poly1, len1)`` and - # ``(poly2, len2)``, assuming that ``len1 >= len2 > 0``. - void fmpz_poly_resultant_modular(fmpz_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2) noexcept - # Computes the resultant of ``poly1`` and ``poly2``. - # For two non-zero polynomials `f(x) = a_m x^m + \dotsb + a_0` and - # `g(x) = b_n x^n + \dotsb + b_0` of degrees `m` and `n`, the resultant - # is defined to be - # .. math :: - # a_m^n b_n^m \prod_{(x, y) : f(x) = g(y) = 0} (x - y). - # For convenience, we define the resultant to be equal to zero if either - # of the two polynomials is zero. - # This function uses the modular algorithm described - # in [Col1971]_. - void fmpz_poly_resultant_modular_div(fmpz_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2, const fmpz_t div, slong nbits) noexcept - # Computes the resultant of ``poly1`` and ``poly2`` divided by - # ``div`` using a slight modification of the above function. It is assumed that - # the resultant is exactly divisible by ``div`` and the result ``res`` - # has at most ``nbits`` bits. - # This bypasses the computation of general bounds. - void _fmpz_poly_resultant_euclidean(fmpz_t res, const fmpz * poly1, slong len1, const fmpz * poly2, slong len2) noexcept - # Sets ``res`` to the resultant of ``(poly1, len1)`` and - # ``(poly2, len2)``, assuming that ``len1 >= len2 > 0``. - void fmpz_poly_resultant_euclidean(fmpz_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2) noexcept - # Computes the resultant of ``poly1`` and ``poly2``. - # For two non-zero polynomials `f(x) = a_m x^m + \dotsb + a_0` and - # `g(x) = b_n x^n + \dotsb + b_0` of degrees `m` and `n`, the resultant - # is defined to be - # .. math :: - # a_m^n b_n^m \prod_{(x, y) : f(x) = g(y) = 0} (x - y). - # For convenience, we define the resultant to be equal to zero if either - # of the two polynomials is zero. - # This function uses the algorithm described - # in Algorithm 3.3.7 of [Coh1996]_. - void _fmpz_poly_resultant(fmpz_t res, const fmpz * poly1, slong len1, const fmpz * poly2, slong len2) noexcept - # Sets ``res`` to the resultant of ``(poly1, len1)`` and - # ``(poly2, len2)``, assuming that ``len1 >= len2 > 0``. - void fmpz_poly_resultant(fmpz_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2) noexcept - # Computes the resultant of ``poly1`` and ``poly2``. - # For two non-zero polynomials `f(x) = a_m x^m + \dotsb + a_0` and - # `g(x) = b_n x^n + \dotsb + b_0` of degrees `m` and `n`, the resultant - # is defined to be - # .. math :: - # a_m^n b_n^m \prod_{(x, y) : f(x) = g(y) = 0} (x - y). - # For convenience, we define the resultant to be equal to zero if either - # of the two polynomials is zero. - void _fmpz_poly_discriminant(fmpz_t res, const fmpz * poly, slong len) noexcept - # Set ``res`` to the discriminant of ``(poly, len)``. Assumes - # ``len > 1``. - void fmpz_poly_discriminant(fmpz_t res, const fmpz_poly_t poly) noexcept - # Set ``res`` to the discriminant of ``poly``. We normalise the - # discriminant so that `\operatorname{disc}(f) = (-1)^{(n(n-1)/2)} - # \operatorname{res}(f, f')/\operatorname{lc}(f)`, thus - # `\operatorname{disc}(f) = \operatorname{lc}(f)^{(2n - 2)} \prod_{i < j} (r_i - # - r_j)^2`, where `\operatorname{lc}(f)` is the leading coefficient of `f`, - # `n` is the degree of `f` and `r_i` are the roots of `f`. - void _fmpz_poly_content(fmpz_t res, const fmpz * poly, slong len) noexcept - # Sets ``res`` to the non-negative content of ``(poly, len)``. - # Aliasing between ``res`` and the coefficients of ``poly`` is - # not supported. - void fmpz_poly_content(fmpz_t res, const fmpz_poly_t poly) noexcept - # Sets ``res`` to the non-negative content of ``poly``. The content - # of the zero polynomial is defined to be zero. Supports aliasing, that is, - # ``res`` is allowed to be one of the coefficients of ``poly``. - void _fmpz_poly_primitive_part(fmpz * res, const fmpz * poly, slong len) noexcept - # Sets ``(res, len)`` to ``(poly, len)`` divided by the content - # of ``(poly, len)``, and normalises the result to have non-negative - # leading coefficient. - # Assumes that ``(poly, len)`` is non-zero. Supports aliasing of - # ``res`` and ``poly``. - void fmpz_poly_primitive_part(fmpz_poly_t res, const fmpz_poly_t poly) noexcept - # Sets ``res`` to ``poly`` divided by the content of ``poly``, - # and normalises the result to have non-negative leading coefficient. - # If ``poly`` is zero, sets ``res`` to zero. - bint _fmpz_poly_is_squarefree(const fmpz * poly, slong len) noexcept - # Returns whether the polynomial ``(poly, len)`` is square-free. - bint fmpz_poly_is_squarefree(const fmpz_poly_t poly) noexcept - # Returns whether the polynomial ``poly`` is square-free. A non-zero - # polynomial is defined to be square-free if it has no non-unit square - # factors. We also define the zero polynomial to be square-free. - # Returns `1` if the length of ``poly`` is at most `2`. Returns whether - # the discriminant is zero for quadratic polynomials. Otherwise, returns - # whether the greatest common divisor of ``poly`` and its derivative has - # length `1`. - int _fmpz_poly_divrem_basecase(fmpz * Q, fmpz * R, const fmpz * A, slong lenA, const fmpz * B, slong lenB, int exact) noexcept - # Computes ``(Q, lenA - lenB + 1)``, ``(R, lenA)`` such that - # `A = B Q + R` and each coefficient of `R` beyond ``lenB`` is reduced - # modulo the leading coefficient of `B`. - # If the leading coefficient of `B` is `\pm 1` or the division is exact, - # this is the same thing as division over `\mathbb{Q}`. - # Assumes that `\operatorname{len}(A), \operatorname{len}(B) > 0`. Allows zero-padding in - # ``(A, lenA)``. `R` and `A` may be aliased, but apart from this no - # aliasing of input and output operands is allowed. - # If the flag ``exact`` is `1`, the function stops if an inexact division - # is encountered, upon which the function will return `0`. If no inexact - # division is encountered, the function returns `1`. Note that this does not - # guarantee the remainder of the polynomial division is zero, merely that - # its length is less than that of B. This feature is useful for series - # division and for divisibility testing (upon testing the remainder). - # For ordinary use set the flag ``exact`` to `0`. In this case, no checks - # or early aborts occur and the function always returns `1`. - void fmpz_poly_divrem_basecase(fmpz_poly_t Q, fmpz_poly_t R, const fmpz_poly_t A, const fmpz_poly_t B) noexcept - # Computes `Q`, `R` such that `A = B Q + R` and each coefficient of `R` - # beyond `\operatorname{len}(B) - 1` is reduced modulo the leading coefficient of `B`. - # If the leading coefficient of `B` is `\pm 1` or the division is exact, - # this is the same thing as division over `\mathbb{Q}`. An exception is raised - # if `B` is zero. - int _fmpz_poly_divrem_divconquer_recursive(fmpz * Q, fmpz * BQ, fmpz * W, const fmpz * A, const fmpz * B, slong lenB, int exact) noexcept - # Computes ``(Q, lenB)``, ``(BQ, 2 lenB - 1)`` such that - # `BQ = B \times Q` and `A = B Q + R` where each coefficient of `R` beyond - # `\operatorname{len}(B) - 1` is reduced modulo the leading coefficient of `B`. We - # assume that `\operatorname{len}(A) = 2 \operatorname{len}(B) - 1`. If the leading coefficient - # of `B` is `\pm 1` or the division is exact, this is the same as division - # over `\mathbb{Q}`. - # Assumes `\operatorname{len}(B) > 0`. Allows zero-padding in ``(A, lenA)``. Requires - # a temporary array ``(W, 2 lenB - 1)``. No aliasing of input and output - # operands is allowed. - # This function does not read the bottom `\operatorname{len}(B) - 1` coefficients from - # `A`, which means that they might not even need to exist in allocated - # memory. - # If the flag ``exact`` is `1`, the function stops if an inexact division - # is encountered, upon which the function will return `0`. If no inexact - # division is encountered, the function returns `1`. Note that this does not - # guarantee the remainder of the polynomial division is zero, merely that - # its length is less than that of B. This feature is useful for series - # division and for divisibility testing (upon testing the remainder). - # For ordinary use set the flag ``exact`` to `0`. In this case, no checks - # or early aborts occur and the function always returns `1`. - int _fmpz_poly_divrem_divconquer(fmpz * Q, fmpz * R, const fmpz * A, slong lenA, const fmpz * B, slong lenB, int exact) noexcept - # Computes ``(Q, lenA - lenB + 1)``, ``(R, lenA)`` such that - # `A = B Q + R` and each coefficient of `R` beyond `\operatorname{len}(B) - 1` is - # reduced modulo the leading coefficient of `B`. If the leading - # coefficient of `B` is `\pm 1` or the division is exact, this is - # the same as division over `\mathbb{Q}`. - # Assumes `\operatorname{len}(A) \geq \operatorname{len}(B) > 0`. Allows zero-padding in - # ``(A, lenA)``. No aliasing of input and output operands is - # allowed. - # If the flag ``exact`` is `1`, the function stops if an inexact division - # is encountered, upon which the function will return `0`. If no inexact - # division is encountered, the function returns `1`. Note that this does not - # guarantee the remainder of the polynomial division is zero, merely that - # its length is less than that of B. This feature is useful for series - # division and for divisibility testing (upon testing the remainder). - # For ordinary use set the flag ``exact`` to `0`. In this case, no checks - # or early aborts occur and the function always returns `1`. - void fmpz_poly_divrem_divconquer(fmpz_poly_t Q, fmpz_poly_t R, const fmpz_poly_t A, const fmpz_poly_t B) noexcept - # Computes `Q`, `R` such that `A = B Q + R` and each coefficient of `R` - # beyond `\operatorname{len}(B) - 1` is reduced modulo the leading coefficient of `B`. - # If the leading coefficient of `B` is `\pm 1` or the division is exact, - # this is the same as division over `\mathbb{Q}`. An exception is raised if `B` - # is zero. - int _fmpz_poly_divrem(fmpz * Q, fmpz * R, const fmpz * A, slong lenA, const fmpz * B, slong lenB, int exact) noexcept - # Computes ``(Q, lenA - lenB + 1)``, ``(R, lenA)`` such that - # `A = B Q + R` and each coefficient of `R` beyond `\operatorname{len}(B) - 1` is - # reduced modulo the leading coefficient of `B`. If the leading - # coefficient of `B` is `\pm 1` or the division is exact, this is - # the same thing as division over `\mathbb{Q}`. - # Assumes `\operatorname{len}(A) \geq \operatorname{len}(B) > 0`. Allows zero-padding in - # ``(A, lenA)``. No aliasing of input and output operands is - # allowed. - # If the flag ``exact`` is `1`, the function stops if an inexact division - # is encountered, upon which the function will return `0`. If no inexact - # division is encountered, the function returns `1`. Note that this does not - # guarantee the remainder of the polynomial division is zero, merely that - # its length is less than that of B. This feature is useful for series - # division and for divisibility testing (upon testing the remainder). - # For ordinary use set the flag ``exact`` to `0`. In this case, no checks - # or early aborts occur and the function always returns `1`. - void fmpz_poly_divrem(fmpz_poly_t Q, fmpz_poly_t R, const fmpz_poly_t A, const fmpz_poly_t B) noexcept - # Computes `Q`, `R` such that `A = B Q + R` and each coefficient of `R` - # beyond `\operatorname{len}(B) - 1` is reduced modulo the leading coefficient of `B`. - # If the leading coefficient of `B` is `\pm 1` or the division is exact, - # this is the same as division over `\mathbb{Q}`. An exception is raised if `B` - # is zero. - int _fmpz_poly_div_basecase(fmpz * Q, fmpz * R, const fmpz * A, slong lenA, const fmpz * B, slong lenB, int exact) noexcept - # Computes the quotient ``(Q, lenA - lenB + 1)`` of ``(A, lenA)`` - # divided by ``(B, lenB)``. - # Notationally, computes `Q`, `R` such that `A = B Q + R` and each - # coefficient of `R` beyond `\operatorname{len}(B) - 1` is reduced modulo the leading - # coefficient of `B`. - # If the leading coefficient of `B` is `\pm 1` or the division is exact, - # this is the same as division over `\mathbb{Q}`. - # Assumes `\operatorname{len}(A), \operatorname{len}(B) > 0`. Allows zero-padding in ``(A, lenA)``. - # Requires a temporary array `R` of size at least the (actual) length - # of `A`. For convenience, `R` may be ``NULL``. `R` and `A` may be - # aliased, but apart from this no aliasing of input and output operands - # is allowed. - # If the flag ``exact`` is `1`, the function stops if an inexact division - # is encountered, upon which the function will return `0`. If no inexact - # division is encountered, the function returns `1`. Note that this does not - # guarantee the remainder of the polynomial division is zero, merely that - # its length is less than that of B. This feature is useful for series - # division and for divisibility testing (upon testing the remainder). - # For ordinary use set the flag ``exact`` to `0`. In this case, no checks - # or early aborts occur and the function always returns `1`. - void fmpz_poly_div_basecase(fmpz_poly_t Q, const fmpz_poly_t A, const fmpz_poly_t B) noexcept - # Computes the quotient `Q` of `A` divided by `Q`. - # Notationally, computes `Q`, `R` such that `A = B Q + R` and each - # coefficient of `R` beyond `\operatorname{len}(B) - 1` is reduced modulo the leading - # coefficient of `B`. - # If the leading coefficient of `B` is `\pm 1` or the division is exact, - # this is the same as division over `\mathbb{Q}`. An exception is raised if `B` - # is zero. - int _fmpz_poly_divremlow_divconquer_recursive(fmpz * Q, fmpz * BQ, const fmpz * A, const fmpz * B, slong lenB, int exact) noexcept - # Divide and conquer division of ``(A, 2 lenB - 1)`` by ``(B, lenB)``, - # computing only the bottom `\operatorname{len}(B) - 1` coefficients of `B Q`. - # Assumes `\operatorname{len}(B) > 0`. Requires `B Q` to have length at least - # `2 \operatorname{len}(B) - 1`, although only the bottom `\operatorname{len}(B) - 1` coefficients will - # carry meaningful output. Does not support any aliasing. Allows - # zero-padding in `A`, but not in `B`. - # If the flag ``exact`` is `1`, the function stops if an inexact division - # is encountered, upon which the function will return `0`. If no inexact - # division is encountered, the function returns `1`. Note that this does not - # guarantee the remainder of the polynomial division is zero, merely that - # its length is less than that of B. This feature is useful for series - # division and for divisibility testing (upon testing the remainder). - # For ordinary use set the flag ``exact`` to `0`. In this case, no checks - # or early aborts occur and the function always returns `1`. - int _fmpz_poly_div_divconquer_recursive(fmpz * Q, fmpz * temp, const fmpz * A, const fmpz * B, slong lenB, int exact) noexcept - # Recursive short division in the balanced case. - # Computes the quotient ``(Q, lenB)`` of ``(A, 2 lenB - 1)`` upon - # division by ``(B, lenB)``. Requires `\operatorname{len}(B) > 0`. Needs a - # temporary array ``temp`` of length `2 \operatorname{len}(B) - 1`. Does not support - # any aliasing. - # For further details, see [Mul2000]_. - # If the flag ``exact`` is `1`, the function stops if an inexact division - # is encountered, upon which the function will return `0`. If no inexact - # division is encountered, the function returns `1`. Note that this does not - # guarantee the remainder of the polynomial division is zero, merely that - # its length is less than that of B. This feature is useful for series - # division and for divisibility testing (upon testing the remainder). - # For ordinary use set the flag ``exact`` to `0`. In this case, no checks - # or early aborts occur and the function always returns `1`. - int _fmpz_poly_div_divconquer(fmpz * Q, const fmpz * A, slong lenA, const fmpz * B, slong lenB, int exact) noexcept - # Computes the quotient ``(Q, lenA - lenB + 1)`` of ``(A, lenA)`` - # upon division by ``(B, lenB)``. Assumes that - # `\operatorname{len}(A) \geq \operatorname{len}(B) > 0`. Does not support aliasing. - # If the flag ``exact`` is `1`, the function stops if an inexact division - # is encountered, upon which the function will return `0`. If no inexact - # division is encountered, the function returns `1`. Note that this does not - # guarantee the remainder of the polynomial division is zero, merely that - # its length is less than that of B. This feature is useful for series - # division and for divisibility testing (upon testing the remainder). - # For ordinary use set the flag ``exact`` to `0`. In this case, no checks - # or early aborts occur and the function always returns `1`. - void fmpz_poly_div_divconquer(fmpz_poly_t Q, const fmpz_poly_t A, const fmpz_poly_t B) noexcept - # Computes the quotient `Q` of `A` divided by `B`. - # Notationally, computes `Q`, `R` such that `A = B Q + R` and each - # coefficient of `R` beyond `\operatorname{len}(B) - 1` is reduced modulo the leading - # coefficient of `B`. - # If the leading coefficient of `B` is `\pm 1` or the division is exact, - # this is the same as division over `\mathbb{Q}`. An exception is raised if `B` - # is zero. - int _fmpz_poly_div(fmpz * Q, const fmpz * A, slong lenA, const fmpz * B, slong lenB, int exact) noexcept - # Computes the quotient ``(Q, lenA - lenB + 1)`` of ``(A, lenA)`` - # divided by ``(B, lenB)``. - # Notationally, computes `Q`, `R` such that `A = B Q + R` and each - # coefficient of `R` beyond `\operatorname{len}(B) - 1` is reduced modulo the leading - # coefficient of `B`. If the leading coefficient of `B` is `\pm 1` or - # the division is exact, this is the same as division over `\mathbb{Q}`. - # Assumes `\operatorname{len}(A) \geq \operatorname{len}(B) > 0`. Allows zero-padding in - # ``(A, lenA)``. Aliasing of input and output operands is not - # allowed. - # If the flag ``exact`` is `1`, the function stops if an inexact division - # is encountered, upon which the function will return `0`. If no inexact - # division is encountered, the function returns `1`. Note that this does not - # guarantee the remainder of the polynomial division is zero, merely that - # its length is less than that of B. This feature is useful for series - # division and for divisibility testing (upon testing the remainder). - # For ordinary use set the flag ``exact`` to `0`. In this case, no checks - # or early aborts occur and the function always returns `1`. - void fmpz_poly_div(fmpz_poly_t Q, const fmpz_poly_t A, const fmpz_poly_t B) noexcept - # Computes the quotient `Q` of `A` divided by `B`. - # Notationally, computes `Q`, `R` such that `A = B Q + R` and each - # coefficient of `R` beyond `\operatorname{len}(B) - 1` is reduced modulo the leading - # coefficient of `B`. If the leading coefficient of `B` is `\pm 1` or - # the division is exact, this is the same as division over `Q`. An - # exception is raised if `B` is zero. - void _fmpz_poly_rem_basecase(fmpz * R, const fmpz * A, slong lenA, const fmpz * B, slong lenB) noexcept - # Computes the remainder ``(R, lenA)`` of ``(A, lenA)`` upon - # division by ``(B, lenB)``. - # Notationally, computes `Q`, `R` such that `A = B Q + R` and each - # coefficient of `R` beyond `\operatorname{len}(B) - 1` is reduced modulo the leading - # coefficient of `B`. If the leading coefficient of `B` is `\pm 1` or - # the division is exact, this is the same thing as division over `\mathbb{Q}`. - # Assumes that `\operatorname{len}(A), \operatorname{len}(B) > 0`. Allows zero-padding in - # ``(A, lenA)``. `R` and `A` may be aliased, but apart from this no - # aliasing of input and output operands is allowed. - void fmpz_poly_rem_basecase(fmpz_poly_t R, const fmpz_poly_t A, const fmpz_poly_t B) noexcept - # Computes the remainder `R` of `A` upon division by `B`. - # Notationally, computes `Q`, `R` such that `A = B Q + R` and each - # coefficient of `R` beyond `\operatorname{len}(B) - 1` is reduced modulo the leading - # coefficient of `B`. If the leading coefficient of `B` is `\pm 1` or - # the division is exact, this is the same as division over `\mathbb{Q}`. An - # exception is raised if `B` is zero. - void _fmpz_poly_rem(fmpz * R, const fmpz * A, slong lenA, const fmpz * B, slong lenB) noexcept - # Computes the remainder ``(R, lenA)`` of ``(A, lenA)`` upon division - # by ``(B, lenB)``. - # Notationally, computes `Q`, `R` such that `A = B Q + R` and each - # coefficient of `R` beyond `\operatorname{len}(B) - 1` is reduced modulo the leading - # coefficient of `B`. If the leading coefficient of `B` is `\pm 1` or - # the division is exact, this is the same thing as division over `\mathbb{Q}`. - # Assumes that `\operatorname{len}(A) \geq \operatorname{len}(B) > 0`. Allows zero-padding in - # ``(A, lenA)``. Aliasing of input and output operands is not allowed. - void fmpz_poly_rem(fmpz_poly_t R, const fmpz_poly_t A, const fmpz_poly_t B) noexcept - # Computes the remainder `R` of `A` upon division by `B`. - # Notationally, computes `Q`, `R` such that `A = B Q + R` and each - # coefficient of `R` beyond `\operatorname{len}(B) - 1` is reduced modulo the leading - # coefficient of `B`. If the leading coefficient of `B` is `\pm 1` or - # the division is exact, this is the same as division over `\mathbb{Q}`. An - # exception is raised if `B` is zero. - void _fmpz_poly_div_root(fmpz * Q, const fmpz * A, slong len, const fmpz_t c) noexcept - # Computes the quotient ``(Q, len-1)`` of ``(A, len)`` upon - # division by `x - c`. - # Supports aliasing of ``Q`` and ``A``, but the result is - # undefined in case of partial overlap. - void fmpz_poly_div_root(fmpz_poly_t Q, const fmpz_poly_t A, const fmpz_t c) noexcept - # Computes the quotient ``(Q, len-1)`` of ``(A, len)`` upon - # division by `x - c`. - void _fmpz_poly_preinvert(fmpz * B_inv, const fmpz * B, slong n) noexcept - # Given a monic polynomial ``B`` of length ``n``, compute a precomputed - # inverse ``B_inv`` of length ``n`` for use in the functions below. No - # aliasing of ``B`` and ``B_inv`` is permitted. We assume ``n`` is not zero. - void fmpz_poly_preinvert(fmpz_poly_t B_inv, const fmpz_poly_t B) noexcept - # Given a monic polynomial ``B``, compute a precomputed inverse - # ``B_inv`` for use in the functions below. An exception is raised if - # ``B`` is zero. - void _fmpz_poly_div_preinv(fmpz * Q, const fmpz * A, slong len1, const fmpz * B, const fmpz * B_inv, slong len2) noexcept - # Given a precomputed inverse ``B_inv`` of the polynomial ``B`` of - # length ``len2``, compute the quotient ``Q`` of ``A`` by ``B``. - # We assume the length ``len1`` of ``A`` is at least ``len2``. The - # polynomial ``Q`` must have space for ``len1 - len2 + 1`` - # coefficients. No aliasing of operands is permitted. - void fmpz_poly_div_preinv(fmpz_poly_t Q, const fmpz_poly_t A, const fmpz_poly_t B, const fmpz_poly_t B_inv) noexcept - # Given a precomputed inverse ``B_inv`` of the polynomial ``B``, - # compute the quotient ``Q`` of ``A`` by ``B``. Aliasing of ``B`` - # and ``B_inv`` is not permitted. - void _fmpz_poly_divrem_preinv(fmpz * Q, fmpz * A, slong len1, const fmpz * B, const fmpz * B_inv, slong len2) noexcept - # Given a precomputed inverse ``B_inv`` of the polynomial ``B`` of - # length ``len2``, compute the quotient ``Q`` of ``A`` by ``B``. - # The remainder is then placed in ``A``. We assume the length ``len1`` - # of ``A`` is at least ``len2``. The polynomial ``Q`` must have - # space for ``len1 - len2 + 1`` coefficients. No aliasing of operands is - # permitted. - void fmpz_poly_divrem_preinv(fmpz_poly_t Q, fmpz_poly_t R, const fmpz_poly_t A, const fmpz_poly_t B, const fmpz_poly_t B_inv) noexcept - # Given a precomputed inverse ``B_inv`` of the polynomial ``B``, - # compute the quotient ``Q`` of ``A`` by ``B`` and the remainder - # ``R``. Aliasing of ``B`` and ``B_inv`` is not permitted. - fmpz ** _fmpz_poly_powers_precompute(const fmpz * B, slong len) noexcept - # Computes ``2*len - 1`` powers of `x` modulo the polynomial `B` of - # the given length. This is used as a kind of precomputed inverse in - # the remainder routine below. - void fmpz_poly_powers_precompute(fmpz_poly_powers_precomp_t pinv, fmpz_poly_t poly) noexcept - # Computes ``2*len - 1`` powers of `x` modulo the polynomial `B` of - # the given length. This is used as a kind of precomputed inverse in - # the remainder routine below. - void _fmpz_poly_powers_clear(fmpz ** powers, slong len) noexcept - # Clean up resources used by precomputed powers which have been computed - # by ``_fmpz_poly_powers_precompute``. - void fmpz_poly_powers_clear(fmpz_poly_powers_precomp_t pinv) noexcept - # Clean up resources used by precomputed powers which have been computed - # by ``fmpz_poly_powers_precompute``. - void _fmpz_poly_rem_powers_precomp(fmpz * A, slong m, const fmpz * B, slong n, fmpz ** const powers) noexcept - # Set `A` to the remainder of `A` divide `B` given precomputed powers mod `B` - # provided by ``_fmpz_poly_powers_precompute``. No aliasing is allowed. - void fmpz_poly_rem_powers_precomp(fmpz_poly_t R, const fmpz_poly_t A, const fmpz_poly_t B, const fmpz_poly_powers_precomp_t B_inv) noexcept - # Set `R` to the remainder of `A` divide `B` given precomputed powers mod `B` - # provided by ``fmpz_poly_powers_precompute``. - int _fmpz_poly_divides(fmpz * Q, const fmpz * A, slong lenA, const fmpz * B, slong lenB) noexcept - # Returns 1 if ``(B, lenB)`` divides ``(A, lenA)`` exactly and - # sets `Q` to the quotient, otherwise returns 0. - # It is assumed that `\operatorname{len}(A) \geq \operatorname{len}(B) > 0` and that `Q` has space - # for `\operatorname{len}(A) - \operatorname{len}(B) + 1` coefficients. - # Aliasing of `Q` with either of the inputs is not permitted. - # This function is currently unoptimised and provided for convenience - # only. - int fmpz_poly_divides(fmpz_poly_t Q, const fmpz_poly_t A, const fmpz_poly_t B) noexcept - # Returns 1 if `B` divides `A` exactly and sets `Q` to the quotient, - # otherwise returns 0. - # This function is currently unoptimised and provided for convenience - # only. - slong fmpz_poly_remove(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2) noexcept - # Set ``res`` to ``poly1`` divided by the highest power of ``poly2`` that - # divides it and return the power. The divisor ``poly2`` must not be zero or - # `\pm 1`, otherwise an exception is raised. - void fmpz_poly_divlow_smodp(fmpz * res, const fmpz_poly_t f, const fmpz_poly_t g, const fmpz_t p, slong n) noexcept - # Compute the `n` lowest coefficients of `f` divided by `g`, assuming the - # division is exact modulo `p`. The computed coefficients are reduced modulo - # `p` using the symmetric remainder system. We require `f` to be at least `n` - # in length. The function can handle trailing zeroes, but the low nonzero - # coefficient of `g` must be coprime to `p`. This is a bespoke function used - # by factoring. - void fmpz_poly_divhigh_smodp(fmpz * res, const fmpz_poly_t f, const fmpz_poly_t g, const fmpz_t p, slong n) noexcept - # Compute the `n` highest coefficients of `f` divided by `g`, assuming the - # division is exact modulo `p`. The computed coefficients are reduced modulo - # `p` using the symmetric remainder system. We require `f` to be as output - # by ``fmpz_poly_mulhigh_n`` given polynomials `g` and a polynomial of - # length `n` as inputs. The leading coefficient of `g` must be coprime to - # `p`. This is a bespoke function used by factoring. - void _fmpz_poly_inv_series_basecase(fmpz * Qinv, const fmpz * Q, slong Qlen, slong n) noexcept - # Computes the first `n` terms of the inverse power series of - # ``(Q, lenQ)`` using a recurrence. - # Assumes that `n \geq 1` and that `Q` has constant term `\pm 1`. - # Does not support aliasing. - void fmpz_poly_inv_series_basecase(fmpz_poly_t Qinv, const fmpz_poly_t Q, slong n) noexcept - # Computes the first `n` terms of the inverse power series of `Q` - # using a recurrence, assuming that `Q` has constant term `\pm 1` - # and `n \geq 1`. - void _fmpz_poly_inv_series_newton(fmpz * Qinv, const fmpz * Q, slong Qlen, slong n) noexcept - # Computes the first `n` terms of the inverse power series of - # ``(Q, lenQ)`` using Newton iteration. - # Assumes that `n \geq 1` and that `Q` has constant term `\pm 1`. - # Does not support aliasing. - void fmpz_poly_inv_series_newton(fmpz_poly_t Qinv, const fmpz_poly_t Q, slong n) noexcept - # Computes the first `n` terms of the inverse power series of `Q` using - # Newton iteration, assuming `Q` has constant term `\pm 1` and `n \geq 1`. - void _fmpz_poly_inv_series(fmpz * Qinv, const fmpz * Q, slong Qlen, slong n) noexcept - # Computes the first `n` terms of the inverse power series of - # ``(Q, lenQ)``. - # Assumes that `n \geq 1` and that `Q` has constant term `\pm 1`. - # Does not support aliasing. - void fmpz_poly_inv_series(fmpz_poly_t Qinv, const fmpz_poly_t Q, slong n) noexcept - # Computes the first `n` terms of the inverse power series of `Q`, - # assuming `Q` has constant term `\pm 1` and `n \geq 1`. - void _fmpz_poly_div_series_basecase(fmpz * Q, const fmpz * A, slong Alen, const fmpz * B, slong Blen, slong n) noexcept - void _fmpz_poly_div_series_divconquer(fmpz * Q, const fmpz * A, slong Alen, const fmpz * B, slong Blen, slong n) noexcept - void _fmpz_poly_div_series(fmpz * Q, const fmpz * A, slong Alen, const fmpz * B, slong Blen, slong n) noexcept - # Divides ``(A, Alen)`` by ``(B, Blen)`` as power series over `\mathbb{Z}`, - # assuming `B` has constant term `\pm 1` and `n \geq 1`. - # Aliasing is not supported. - void fmpz_poly_div_series_basecase(fmpz_poly_t Q, const fmpz_poly_t A, const fmpz_poly_t B, slong n) noexcept - void fmpz_poly_div_series_divconquer(fmpz_poly_t Q, const fmpz_poly_t A, const fmpz_poly_t B, slong n) noexcept - void fmpz_poly_div_series(fmpz_poly_t Q, const fmpz_poly_t A, const fmpz_poly_t B, slong n) noexcept - # Performs power series division in `\mathbb{Z}[[x]] / (x^n)`. The function - # considers the polynomials `A` and `B` as power series of length `n` - # starting with the constant terms. The function assumes that `B` has - # constant term `\pm 1` and `n \geq 1`. - void _fmpz_poly_pseudo_divrem_basecase(fmpz * Q, fmpz * R, ulong * d, const fmpz * A, slong lenA, const fmpz * B, slong lenB, const fmpz_preinvn_t inv) noexcept - # If `\ell` is the leading coefficient of `B`, then computes `Q`, `R` such - # that `\ell^d A = Q B + R`. This function is used for simulating division - # over `\mathbb{Q}`. - # Assumes that `\operatorname{len}(A) \geq \operatorname{len}(B) > 0`. Assumes that `Q` can fit - # `\operatorname{len}(A) - \operatorname{len}(B) + 1` coefficients, and that `R` can fit `\operatorname{len}(A)` - # coefficients. Supports aliasing of ``(R, lenA)`` and ``(A, lenA)``. - # But other than this, no aliasing of the inputs and outputs is supported. - # An optional precomputed inverse of the leading coefficient of `B` from - # ``fmpz_preinvn_init`` can be supplied. Otherwise ``inv`` should be - # ``NULL``. - # Note: ``fmpz.h`` has to be included before ``fmpz_poly.h`` in order for - # ``fmpz_poly.h`` to declare this function. - void fmpz_poly_pseudo_divrem_basecase(fmpz_poly_t Q, fmpz_poly_t R, ulong * d, const fmpz_poly_t A, const fmpz_poly_t B) noexcept - # If `\ell` is the leading coefficient of `B`, then computes `Q`, `R` such - # that `\ell^d A = Q B + R`. This function is used for simulating division - # over `\mathbb{Q}`. - void _fmpz_poly_pseudo_divrem_divconquer(fmpz * Q, fmpz * R, ulong * d, const fmpz * A, slong lenA, const fmpz * B, slong lenB, const fmpz_preinvn_t inv) noexcept - # Computes ``(Q, lenA - lenB + 1)``, ``(R, lenA)`` such that - # `\ell^d A = B Q + R`, only setting the bottom `\operatorname{len}(B) - 1` coefficients - # of `R` to their correct values. The remaining top coefficients of - # ``(R, lenA)`` may be arbitrary. - # Assumes `\operatorname{len}(A) \geq \operatorname{len}(B) > 0`. Allows zero-padding in - # ``(A, lenA)``. No aliasing of input and output operands is allowed. - # An optional precomputed inverse of the leading coefficient of `B` from - # ``fmpz_preinvn_init`` can be supplied. Otherwise ``inv`` should be - # ``NULL``. - # Note: ``fmpz.h`` has to be included before ``fmpz_poly.h`` in order for - # ``fmpz_poly.h`` to declare this function. - void fmpz_poly_pseudo_divrem_divconquer(fmpz_poly_t Q, fmpz_poly_t R, ulong * d, const fmpz_poly_t A, const fmpz_poly_t B) noexcept - # Computes `Q`, `R`, and `d` such that `\ell^d A = B Q + R`, where `R` has - # length less than the length of `B` and `\ell` is the leading coefficient - # of `B`. An exception is raised if `B` is zero. - void _fmpz_poly_pseudo_divrem_cohen(fmpz * Q, fmpz * R, const fmpz * A, slong lenA, const fmpz * B, slong lenB) noexcept - # Assumes that `\operatorname{len}(A) \geq \operatorname{len}(B) > 0`. Assumes that `Q` can fit - # `\operatorname{len}(A) - \operatorname{len}(B) + 1` coefficients, and that `R` can fit `\operatorname{len}(A)` - # coefficients. Supports aliasing of ``(R, lenA)`` and ``(A, lenA)``. - # But other than this, no aliasing of the inputs and outputs is supported. - void fmpz_poly_pseudo_divrem_cohen(fmpz_poly_t Q, fmpz_poly_t R, const fmpz_poly_t A, const fmpz_poly_t B) noexcept - # This is a variant of ``fmpz_poly_pseudo_divrem`` which computes - # polynomials `Q` and `R` such that `\ell^d A = B Q + R`. However, the - # value of `d` is fixed at `\max{\{0, \operatorname{len}(A) - \operatorname{len}(B) + 1\}}`. - # This function is faster when the remainder is not well behaved, i.e. - # where it is not expected to be close to zero. Note that this function - # is not asymptotically fast. It is efficient only for short polynomials, - # e.g. when `\operatorname{len}(B) < 32`. - void _fmpz_poly_pseudo_rem_cohen(fmpz * R, const fmpz * A, slong lenA, const fmpz * B, slong lenB) noexcept - # Assumes that `\operatorname{len}(A) \geq \operatorname{len}(B) > 0`. Assumes that `R` can fit - # `\operatorname{len}(A)` coefficients. Supports aliasing of ``(R, lenA)`` and - # ``(A, lenA)``. But other than this, no aliasing of the inputs and - # outputs is supported. - void fmpz_poly_pseudo_rem_cohen(fmpz_poly_t R, const fmpz_poly_t A, const fmpz_poly_t B) noexcept - # This is a variant of :func:`fmpz_poly_pseudo_rem` which computes - # polynomials `Q` and `R` such that `\ell^d A = B Q + R`, but only - # returns `R`. However, the value of `d` is fixed at - # `\max{\{0, \operatorname{len}(A) - \operatorname{len}(B) + 1\}}`. - # This function is faster when the remainder is not well behaved, i.e. - # where it is not expected to be close to zero. Note that this function - # is not asymptotically fast. It is efficient only for short polynomials, - # e.g. when `\operatorname{len}(B) < 32`. - # This function uses the algorithm described - # in Algorithm 3.1.2 of [Coh1996]_. - void _fmpz_poly_pseudo_divrem(fmpz * Q, fmpz * R, ulong * d, const fmpz * A, slong lenA, const fmpz * B, slong lenB, const fmpz_preinvn_t inv) noexcept - # If `\ell` is the leading coefficient of `B`, then computes - # ``(Q, lenA - lenB + 1)``, ``(R, lenB - 1)`` and `d` such that - # `\ell^d A = B Q + R`. This function is used for simulating division - # over `\mathbb{Q}`. - # Assumes that `\operatorname{len}(A) \geq \operatorname{len}(B) > 0`. Assumes that `Q` can fit - # `\operatorname{len}(A) - \operatorname{len}(B) + 1` coefficients, and that `R` can fit `\operatorname{len}(A)` - # coefficients, although on exit only the bottom `\operatorname{len}(B)` coefficients - # will carry meaningful data. - # Supports aliasing of ``(R, lenA)`` and ``(A, lenA)``. But other - # than this, no aliasing of the inputs and outputs is supported. - # An optional precomputed inverse of the leading coefficient of `B` from - # ``fmpz_preinvn_init`` can be supplied. Otherwise ``inv`` should be - # ``NULL``. - # Note: ``fmpz.h`` has to be included before ``fmpz_poly.h`` in order for - # ``fmpz_poly.h`` to declare this function. - void fmpz_poly_pseudo_divrem(fmpz_poly_t Q, fmpz_poly_t R, ulong * d, const fmpz_poly_t A, const fmpz_poly_t B) noexcept - # Computes `Q`, `R`, and `d` such that `\ell^d A = B Q + R`. - void _fmpz_poly_pseudo_div(fmpz * Q, ulong * d, const fmpz * A, slong lenA, const fmpz * B, slong lenB, const fmpz_preinvn_t inv) noexcept - # Pseudo-division, only returning the quotient. - # Note: ``fmpz.h`` has to be included before ``fmpz_poly.h`` in order for - # ``fmpz_poly.h`` to declare this function. - void fmpz_poly_pseudo_div(fmpz_poly_t Q, ulong * d, const fmpz_poly_t A, const fmpz_poly_t B) noexcept - # Pseudo-division, only returning the quotient. - void _fmpz_poly_pseudo_rem(fmpz * R, ulong * d, const fmpz * A, slong lenA, const fmpz * B, slong lenB, const fmpz_preinvn_t inv) noexcept - # Pseudo-division, only returning the remainder. - # Note: ``fmpz.h`` has to be included before ``fmpz_poly.h`` in order for - # ``fmpz_poly.h`` to declare this function. - void fmpz_poly_pseudo_rem(fmpz_poly_t R, ulong * d, const fmpz_poly_t A, const fmpz_poly_t B) noexcept - # Pseudo-division, only returning the remainder. - void _fmpz_poly_derivative(fmpz * rpoly, const fmpz * poly, slong len) noexcept - # Sets ``(rpoly, len - 1)`` to the derivative of ``(poly, len)``. - # Also handles the cases where ``len`` is `0` or `1` correctly. - # Supports aliasing of ``rpoly`` and ``poly``. - void fmpz_poly_derivative(fmpz_poly_t res, const fmpz_poly_t poly) noexcept - # Sets ``res`` to the derivative of ``poly``. - void _fmpz_poly_nth_derivative(fmpz * rpoly, const fmpz * poly, ulong n, slong len) noexcept - # Sets ``(rpoly, len - n)`` to the nth derivative of ``(poly, len)``. - # Also handles the cases where ``len <= n`` correctly. - # Supports aliasing of ``rpoly`` and ``poly``. - void fmpz_poly_nth_derivative(fmpz_poly_t res, const fmpz_poly_t poly, ulong n) noexcept - # Sets ``res`` to the nth derivative of ``poly``. - void _fmpz_poly_evaluate_divconquer_fmpz(fmpz_t res, const fmpz * poly, slong len, const fmpz_t a) noexcept - # Evaluates the polynomial ``(poly, len)`` at the integer `a` using - # a divide and conquer approach. Assumes that the length of the polynomial - # is at least one. Allows zero padding. Does not allow aliasing between - # ``res`` and ``x``. - void fmpz_poly_evaluate_divconquer_fmpz(fmpz_t res, const fmpz_poly_t poly, const fmpz_t a) noexcept - # Evaluates the polynomial ``poly`` at the integer `a` using a divide - # and conquer approach. - # Aliasing between ``res`` and ``a`` is supported, however, - # ``res`` may not be part of ``poly``. - void _fmpz_poly_evaluate_horner_fmpz(fmpz_t res, const fmpz * f, slong len, const fmpz_t a) noexcept - # Evaluates the polynomial ``(f, len)`` at the integer `a` using - # Horner's rule, and sets ``res`` to the result. Aliasing between - # ``res`` and `a` or any of the coefficients of `f` is not supported. - void fmpz_poly_evaluate_horner_fmpz(fmpz_t res, const fmpz_poly_t f, const fmpz_t a) noexcept - # Evaluates the polynomial `f` at the integer `a` using Horner's rule, and - # sets ``res`` to the result. - # As expected, aliasing between ``res`` and ``a`` is supported. - # However, ``res`` may not be aliased with a coefficient of `f`. - void _fmpz_poly_evaluate_fmpz(fmpz_t res, const fmpz * f, slong len, const fmpz_t a) noexcept - # Evaluates the polynomial ``(f, len)`` at the integer `a` and sets - # ``res`` to the result. Aliasing between ``res`` and `a` or any - # of the coefficients of `f` is not supported. - void fmpz_poly_evaluate_fmpz(fmpz_t res, const fmpz_poly_t f, const fmpz_t a) noexcept - # Evaluates the polynomial `f` at the integer `a` and sets ``res`` - # to the result. - # As expected, aliasing between ``res`` and `a` is supported. However, - # ``res`` may not be aliased with a coefficient of `f`. - void _fmpz_poly_evaluate_divconquer_fmpq(fmpz_t rnum, fmpz_t rden, const fmpz * f, slong len, const fmpz_t anum, const fmpz_t aden) noexcept - # Evaluates the polynomial ``(f, len)`` at the rational - # ``(anum, aden)`` using a divide and conquer approach, and sets - # ``(rnum, rden)`` to the result in lowest terms. Assumes that - # the length of the polynomial is at least one. - # Aliasing between ``(rnum, rden)`` and ``(anum, aden)`` or any of - # the coefficients of `f` is not supported. - void fmpz_poly_evaluate_divconquer_fmpq(fmpq_t res, const fmpz_poly_t f, const fmpq_t a) noexcept - # Evaluates the polynomial `f` at the rational `a` using a divide - # and conquer approach, and sets ``res`` to the result. - void _fmpz_poly_evaluate_horner_fmpq(fmpz_t rnum, fmpz_t rden, const fmpz * f, slong len, const fmpz_t anum, const fmpz_t aden) noexcept - # Evaluates the polynomial ``(f, len)`` at the rational - # ``(anum, aden)`` using Horner's rule, and sets ``(rnum, rden)`` to - # the result in lowest terms. - # Aliasing between ``(rnum, rden)`` and ``(anum, aden)`` or any of - # the coefficients of `f` is not supported. - void fmpz_poly_evaluate_horner_fmpq(fmpq_t res, const fmpz_poly_t f, const fmpq_t a) noexcept - # Evaluates the polynomial `f` at the rational `a` using Horner's rule, and - # sets ``res`` to the result. - void _fmpz_poly_evaluate_fmpq(fmpz_t rnum, fmpz_t rden, const fmpz * f, slong len, const fmpz_t anum, const fmpz_t aden) noexcept - # Evaluates the polynomial ``(f, len)`` at the rational - # ``(anum, aden)`` and sets ``(rnum, rden)`` to the result in lowest - # terms. - # Aliasing between ``(rnum, rden)`` and ``(anum, aden)`` or any of - # the coefficients of `f` is not supported. - void fmpz_poly_evaluate_fmpq(fmpq_t res, const fmpz_poly_t f, const fmpq_t a) noexcept - # Evaluates the polynomial `f` at the rational `a`, and - # sets ``res`` to the result. - mp_limb_t _fmpz_poly_evaluate_mod(const fmpz * poly, slong len, mp_limb_t a, mp_limb_t n, mp_limb_t ninv) noexcept - # Evaluates ``(poly, len)`` at the value `a` modulo `n` and - # returns the result. The last argument ``ninv`` must be set - # to the precomputed inverse of `n`, which can be obtained using - # the function :func:`n_preinvert_limb`. - mp_limb_t fmpz_poly_evaluate_mod(const fmpz_poly_t poly, mp_limb_t a, mp_limb_t n) noexcept - # Evaluates ``poly`` at the value `a` modulo `n` and returns the result. - void fmpz_poly_evaluate_fmpz_vec(fmpz * res, const fmpz_poly_t f, const fmpz * a, slong n) noexcept - # Evaluates ``f`` at the `n` values given in the vector ``f``, - # writing the results to ``res``. - double _fmpz_poly_evaluate_horner_d(const fmpz * poly, slong n, double d) noexcept - # Evaluate ``(poly, n)`` at the double `d`. No attempt is made to do this - # efficiently or in a numerically stable way. It is currently only used in - # Flint for quick and dirty evaluations of polynomials with all coefficients - # positive. - double fmpz_poly_evaluate_horner_d(const fmpz_poly_t poly, double d) noexcept - # Evaluate ``poly`` at the double `d`. No attempt is made to do this - # efficiently or in a numerically stable way. It is currently only used in - # Flint for quick and dirty evaluations of polynomials with all coefficients - # positive. - double _fmpz_poly_evaluate_horner_d_2exp(slong * exp, const fmpz * poly, slong n, double d) noexcept - # Evaluate ``(poly, n)`` at the double `d`. Return the result as a double - # and an exponent ``exp`` combination. No attempt is made to do this - # efficiently or in a numerically stable way. It is currently only used in - # Flint for quick and dirty evaluations of polynomials with all coefficients - # positive. - double fmpz_poly_evaluate_horner_d_2exp(slong * exp, const fmpz_poly_t poly, double d) noexcept - # Evaluate ``poly`` at the double `d`. Return the result as a double - # and an exponent ``exp`` combination. No attempt is made to do this - # efficiently or in a numerically stable way. It is currently only used in - # Flint for quick and dirty evaluations of polynomials with all coefficients - # positive. - double _fmpz_poly_evaluate_horner_d_2exp2(slong * exp, const fmpz * poly, slong n, double d, slong dexp) noexcept - # Evaluate ``poly`` at ``d*2^dexp``. Return the result as a double - # and an exponent ``exp`` combination. No attempt is made to do this - # efficiently or in a numerically stable way. It is currently only used in - # Flint for quick and dirty evaluations of polynomials with all coefficients - # positive. - void _fmpz_poly_monomial_to_newton(fmpz * poly, const fmpz * roots, slong n) noexcept - # Converts ``(poly, n)`` in-place from its coefficients given - # in the standard monomial basis to the Newton basis - # for the roots `r_0, r_1, \ldots, r_{n-2}`. - # In other words, this determines output coefficients `c_i` such that - # `c_0 + c_1(x-r_0) + c_2(x-r_0)(x-r_1) + \ldots + c_{n-1}(x-r_0)(x-r_1)\cdots(x-r_{n-2})` - # is equal to the input polynomial. - # Uses repeated polynomial division. - void _fmpz_poly_newton_to_monomial(fmpz * poly, const fmpz * roots, slong n) noexcept - # Converts ``(poly, n)`` in-place from its coefficients given - # in the Newton basis for the roots `r_0, r_1, \ldots, r_{n-2}` - # to the standard monomial basis. In other words, this evaluates - # `c_0 + c_1(x-r_0) + c_2(x-r_0)(x-r_1) + \ldots + c_{n-1}(x-r_0)(x-r_1)\cdots(x-r_{n-2})` - # where `c_i` are the input coefficients for ``poly``. - # Uses Horner's rule. - void fmpz_poly_interpolate_fmpz_vec(fmpz_poly_t poly, const fmpz * xs, const fmpz * ys, slong n) noexcept - # Sets ``poly`` to the unique interpolating polynomial of degree at - # most `n - 1` satisfying `f(x_i) = y_i` for every pair `x_i, y_u` in - # ``xs`` and ``ys``, assuming that this polynomial has integer - # coefficients. - # If an interpolating polynomial with integer coefficients does not - # exist, a ``FLINT_INEXACT`` exception is thrown. - # It is assumed that the `x` values are distinct. - void _fmpz_poly_compose_horner(fmpz * res, const fmpz * poly1, slong len1, const fmpz * poly2, slong len2) noexcept - # Sets ``res`` to the composition of ``(poly1, len1)`` and - # ``(poly2, len2)``. - # Assumes that ``res`` has space for ``(len1-1)*(len2-1) + 1`` - # coefficients. Assumes that ``poly1`` and ``poly2`` are non-zero - # polynomials. Does not support aliasing between any of the inputs and - # the output. - void fmpz_poly_compose_horner(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2) noexcept - # Sets ``res`` to the composition of ``poly1`` and ``poly2``. - # To be more precise, denoting ``res``, ``poly1``, and ``poly2`` - # by `f`, `g`, and `h`, sets `f(t) = g(h(t))`. - # This implementation uses Horner's method. - void _fmpz_poly_compose_divconquer(fmpz * res, const fmpz * poly1, slong len1, const fmpz * poly2, slong len2) noexcept - # Computes the composition of ``(poly1, len1)`` and ``(poly2, len2)`` - # using a divide and conquer approach and places the result into ``res``, - # assuming ``res`` can hold the output of length - # ``(len1 - 1) * (len2 - 1) + 1``. - # Assumes ``len1, len2 > 0``. Does not support aliasing between - # ``res`` and any of ``(poly1, len1)`` and ``(poly2, len2)``. - void fmpz_poly_compose_divconquer(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2) noexcept - # Sets ``res`` to the composition of ``poly1`` and ``poly2``. - # To be precise about the order of composition, denoting ``res``, - # ``poly1``, and ``poly2`` by `f`, `g`, and `h`, respectively, - # sets `f(t) = g(h(t))`. - void _fmpz_poly_compose(fmpz * res, const fmpz * poly1, slong len1, const fmpz * poly2, slong len2) noexcept - # Sets ``res`` to the composition of ``(poly1, len1)`` and - # ``(poly2, len2)``. - # Assumes that ``res`` has space for ``(len1-1)*(len2-1) + 1`` - # coefficients. Assumes that ``poly1`` and ``poly2`` are non-zero - # polynomials. Does not support aliasing between any of the inputs and - # the output. - void fmpz_poly_compose(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2) noexcept - # Sets ``res`` to the composition of ``poly1`` and ``poly2``. - # To be precise about the order of composition, denoting ``res``, - # ``poly1``, and ``poly2`` by `f`, `g`, and `h`, respectively, - # sets `f(t) = g(h(t))`. - void fmpz_poly_inflate(fmpz_poly_t result, const fmpz_poly_t input, ulong inflation) noexcept - # Sets ``result`` to the inflated polynomial `p(x^n)` where - # `p` is given by ``input`` and `n` is given by ``inflation``. - void fmpz_poly_deflate(fmpz_poly_t result, const fmpz_poly_t input, ulong deflation) noexcept - # Sets ``result`` to the deflated polynomial `p(x^{1/n})` where - # `p` is given by ``input`` and `n` is given by ``deflation``. - # Requires `n > 0`. - ulong fmpz_poly_deflation(const fmpz_poly_t input) noexcept - # Returns the largest integer by which ``input`` can be deflated. - # As special cases, returns 0 if ``input`` is the zero polynomial - # and 1 if ``input`` is a constant polynomial. - void _fmpz_poly_taylor_shift_horner(fmpz * poly, const fmpz_t c, slong n) noexcept - # Performs the Taylor shift composing ``poly`` by `x+c` in-place. - # Uses an efficient version Horner's rule. - void fmpz_poly_taylor_shift_horner(fmpz_poly_t g, const fmpz_poly_t f, const fmpz_t c) noexcept - # Performs the Taylor shift composing ``f`` by `x+c`. - void _fmpz_poly_taylor_shift_divconquer(fmpz * poly, const fmpz_t c, slong n) noexcept - # Performs the Taylor shift composing ``poly`` by `x+c` in-place. - # Uses the divide-and-conquer polynomial composition algorithm. - void fmpz_poly_taylor_shift_divconquer(fmpz_poly_t g, const fmpz_poly_t f, const fmpz_t c) noexcept - # Performs the Taylor shift composing ``f`` by `x+c`. - # Uses the divide-and-conquer polynomial composition algorithm. - void _fmpz_poly_taylor_shift_multi_mod(fmpz * poly, const fmpz_t c, slong n) noexcept - # Performs the Taylor shift composing ``poly`` by `x+c` in-place. - # Uses a multimodular algorithm, distributing the computation - # across :func:`flint_get_num_threads` threads. - void fmpz_poly_taylor_shift_multi_mod(fmpz_poly_t g, const fmpz_poly_t f, const fmpz_t c) noexcept - # Performs the Taylor shift composing ``f`` by `x+c`. - # Uses a multimodular algorithm, distributing the computation - # across :func:`flint_get_num_threads` threads. - void _fmpz_poly_taylor_shift(fmpz * poly, const fmpz_t c, slong n) noexcept - # Performs the Taylor shift composing ``poly`` by `x+c` in-place. - void fmpz_poly_taylor_shift(fmpz_poly_t g, const fmpz_poly_t f, const fmpz_t c) noexcept - # Performs the Taylor shift composing ``f`` by `x+c`. - void _fmpz_poly_compose_series_horner(fmpz * res, const fmpz * poly1, slong len1, const fmpz * poly2, slong len2, slong n) noexcept - # Sets ``res`` to the composition of ``poly1`` and ``poly2`` - # modulo `x^n`, where the constant term of ``poly2`` is required - # to be zero. - # Assumes that ``len1, len2, n > 0``, that ``len1, len2 <= n``, - # and that ``(len1-1) * (len2-1) + 1 <= n``, and that ``res`` has - # space for ``n`` coefficients. Does not support aliasing between any - # of the inputs and the output. - # This implementation uses the Horner scheme. - void fmpz_poly_compose_series_horner(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2, slong n) noexcept - # Sets ``res`` to the composition of ``poly1`` and ``poly2`` - # modulo `x^n`, where the constant term of ``poly2`` is required - # to be zero. - # This implementation uses the Horner scheme. - void _fmpz_poly_compose_series_brent_kung(fmpz * res, const fmpz * poly1, slong len1, const fmpz * poly2, slong len2, slong n) noexcept - # Sets ``res`` to the composition of ``poly1`` and ``poly2`` - # modulo `x^n`, where the constant term of ``poly2`` is required - # to be zero. - # Assumes that ``len1, len2, n > 0``, that ``len1, len2 <= n``, - # and that ``(len1-1) * (len2-1) + 1 <= n``, and that ``res`` has - # space for ``n`` coefficients. Does not support aliasing between any - # of the inputs and the output. - # This implementation uses Brent-Kung algorithm 2.1 [BrentKung1978]_. - void fmpz_poly_compose_series_brent_kung(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2, slong n) noexcept - # Sets ``res`` to the composition of ``poly1`` and ``poly2`` - # modulo `x^n`, where the constant term of ``poly2`` is required - # to be zero. - # This implementation uses Brent-Kung algorithm 2.1 [BrentKung1978]_. - void _fmpz_poly_compose_series(fmpz * res, const fmpz * poly1, slong len1, const fmpz * poly2, slong len2, slong n) noexcept - # Sets ``res`` to the composition of ``poly1`` and ``poly2`` - # modulo `x^n`, where the constant term of ``poly2`` is required - # to be zero. - # Assumes that ``len1, len2, n > 0``, that ``len1, len2 <= n``, - # and that ``(len1-1) * (len2-1) + 1 <= n``, and that ``res`` has - # space for ``n`` coefficients. Does not support aliasing between any - # of the inputs and the output. - # This implementation automatically switches between the Horner scheme - # and Brent-Kung algorithm 2.1 depending on the size of the inputs. - void fmpz_poly_compose_series(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_poly_t poly2, slong n) noexcept - # Sets ``res`` to the composition of ``poly1`` and ``poly2`` - # modulo `x^n`, where the constant term of ``poly2`` is required - # to be zero. - # This implementation automatically switches between the Horner scheme - # and Brent-Kung algorithm 2.1 depending on the size of the inputs. - - void _fmpz_poly_revert_series_lagrange(fmpz * Qinv, const fmpz * Q, slong Qlen, slong n) noexcept - # Sets ``Qinv`` to the compositional inverse or reversion of - # ``(Q, Qlen)`` as a power series, i.e. computes `Q^{-1}` such that - # `Q(Q^{-1}(x)) = Q^{-1}(Q(x)) = x \bmod x^n`. The arguments may not be - # aliased, and ``Qlen`` must be at least 2. - # It is required that `Q_0 = 0` and `Q_1 = \pm 1`. - # This implementation uses the Lagrange inversion formula. - - void fmpz_poly_revert_series_lagrange(fmpz_poly_t Qinv, const fmpz_poly_t Q, slong n) noexcept - # Sets ``Qinv`` to the compositional inverse or reversion of ``Q`` - # as a power series, i.e. computes `Q^{-1}` such that - # `Q(Q^{-1}(x)) = Q^{-1}(Q(x)) = x \bmod x^n`. - # It is required that `Q_0 = 0` and `Q_1 = \pm 1`. - # This implementation uses the Lagrange inversion formula. - - void _fmpz_poly_revert_series_lagrange_fast(fmpz * Qinv, const fmpz * Q, slong Qlen, slong n) noexcept - # Sets ``Qinv`` to the compositional inverse or reversion of - # ``(Q, Qlen)`` - # as a power series, i.e. computes `Q^{-1}` such that - # `Q(Q^{-1}(x)) = Q^{-1}(Q(x)) = x \bmod x^n`. The arguments may not be - # aliased, and ``Qlen`` must be at least 2. - # It is required that `Q_0 = 0` and `Q_1 = \pm 1`. - # This implementation uses a reduced-complexity implementation - # of the Lagrange inversion formula. - - void fmpz_poly_revert_series_lagrange_fast(fmpz_poly_t Qinv, const fmpz_poly_t Q, slong n) noexcept - # Sets ``Qinv`` to the compositional inverse or reversion of ``Q`` - # as a power series, i.e. computes `Q^{-1}` such that - # `Q(Q^{-1}(x)) = Q^{-1}(Q(x)) = x \bmod x^n`. - # It is required that `Q_0 = 0` and `Q_1 = \pm 1`. - # This implementation uses a reduced-complexity implementation - # of the Lagrange inversion formula. - - void _fmpz_poly_revert_series_newton(fmpz * Qinv, const fmpz * Q, slong Qlen, slong n) noexcept - # Sets ``Qinv`` to the compositional inverse or reversion of ``Q`` - # as a power series, i.e. computes `Q^{-1}` such that - # `Q(Q^{-1}(x)) = Q^{-1}(Q(x)) = x \bmod x^n`. The arguments may not be - # aliased, and ``Qlen`` must be at least 2. - # It is required that `Q_0 = 0` and `Q_1 = \pm 1`. - # This implementation uses Newton iteration [BrentKung1978]_. - - void fmpz_poly_revert_series_newton(fmpz_poly_t Qinv, const fmpz_poly_t Q, slong n) noexcept - # Sets ``Qinv`` to the compositional inverse or reversion of ``Q`` - # as a power series, i.e. computes `Q^{-1}` such that - # `Q(Q^{-1}(x)) = Q^{-1}(Q(x)) = x \bmod x^n`. - # It is required that `Q_0 = 0` and `Q_1 = \pm 1`. - # This implementation uses Newton iteration [BrentKung1978]_. - void _fmpz_poly_revert_series(fmpz * Qinv, const fmpz * Q, slong Qlen, slong n) noexcept - # Sets ``Qinv`` to the compositional inverse or reversion of ``Q`` - # as a power series, i.e. computes `Q^{-1}` such that - # `Q(Q^{-1}(x)) = Q^{-1}(Q(x)) = x \bmod x^n`. The arguments may not be - # aliased, and ``Qlen`` must be at least 2. - # It is required that `Q_0 = 0` and `Q_1 = \pm 1`. - # This implementation defaults to the fast version of - # Lagrange interpolation. - void fmpz_poly_revert_series(fmpz_poly_t Qinv, const fmpz_poly_t Q, slong n) noexcept - # Sets ``Qinv`` to the compositional inverse or reversion of ``Q`` - # as a power series, i.e. computes `Q^{-1}` such that - # `Q(Q^{-1}(x)) = Q^{-1}(Q(x)) = x \bmod x^n`. - # It is required that `Q_0 = 0` and `Q_1 = \pm 1`. - # This implementation defaults to the fast version of - # Lagrange interpolation. - int _fmpz_poly_sqrtrem_classical(fmpz * res, fmpz * r, const fmpz * poly, slong len) noexcept - # Returns 1 if ``(poly, len)`` can be written in the form `A^2 + R` where - # deg(`R`) < deg(``poly``), otherwise returns `0`. If it can be so - # written, ``(res, m - 1)`` is set to `A` and ``(res, m)`` is set to - # `R`, where `m = \deg(\mathtt{poly})/2 + 1`. - # For efficiency reasons, ``r`` must have room for ``len`` - # coefficients, and may alias ``poly``. - int fmpz_poly_sqrtrem_classical(fmpz_poly_t b, fmpz_poly_t r, const fmpz_poly_t a) noexcept - # If `a` can be written as `b^2 + r` with `\deg(r) < \deg(a)/2`, return - # `1` and set `b` and `r` appropriately. Otherwise return `0`. - int _fmpz_poly_sqrtrem_divconquer(fmpz * res, fmpz * r, const fmpz * poly, slong len, fmpz * temp) noexcept - # Returns 1 if ``(poly, len)`` can be written in the form `A^2 + R` where - # deg(`R`) < deg(``poly``), otherwise returns `0`. If it can be so - # written, ``(res, m - 1)`` is set to `A` and ``(res, m)`` is set to - # `R`, where `m = \deg(\mathtt{poly})/2 + 1`. - # For efficiency reasons, ``r`` must have room for ``len`` - # coefficients, and may alias ``poly``. Temporary space of ``len`` - # coefficients is required. - int fmpz_poly_sqrtrem_divconquer(fmpz_poly_t b, fmpz_poly_t r, const fmpz_poly_t a) noexcept - # If `a` can be written as `b^2 + r` with `\deg(r) < \deg(a)/2`, return - # `1` and set `b` and `r` appropriately. Otherwise return `0`. - int _fmpz_poly_sqrt_classical(fmpz * res, const fmpz * poly, slong len, int exact) noexcept - # If ``exact`` is `1` and ``(poly, len)`` is a perfect square, sets - # ``(res, len / 2 + 1)`` to the square root of ``poly`` with positive - # leading coefficient and returns 1. Otherwise returns 0. - # If ``exact`` is `0`, allows a remainder after the square root, which is - # not computed. - # This function first uses various tests to detect nonsquares quickly. - # Then, it computes the square root iteratively from top to bottom, - # requiring `O(n^2)` coefficient operations. - int fmpz_poly_sqrt_classical(fmpz_poly_t b, const fmpz_poly_t a) noexcept - # If ``a`` is a perfect square, sets ``b`` to the square root of - # ``a`` with positive leading coefficient and returns 1. - # Otherwise returns 0. - int _fmpz_poly_sqrt_KS(fmpz * res, const fmpz * poly, slong len) noexcept - # Heuristic square root. If the return value is `-1`, the function failed, - # otherwise it succeeded and the following applies. - # If ``(poly, len)`` is a perfect square, sets - # ``(res, len / 2 + 1)`` to the square root of ``poly`` with positive - # leading coefficient and returns 1. Otherwise returns 0. - # This function first uses various tests to detect nonsquares quickly. - # Then, it computes the square root iteratively from top to bottom. - int fmpz_poly_sqrt_KS(fmpz_poly_t b, const fmpz_poly_t a) noexcept - # Heuristic square root. If the return value is `-1`, the function failed, - # otherwise it succeeded and the following applies. - # If ``a`` is a perfect square, sets ``b`` to the square root of - # ``a`` with positive leading coefficient and returns 1. - # Otherwise returns 0. - int _fmpz_poly_sqrt_divconquer(fmpz * res, const fmpz * poly, slong len, int exact) noexcept - # If ``exact`` is `1` and ``(poly, len)`` is a perfect square, sets - # ``(res, len / 2 + 1)`` to the square root of ``poly`` with positive - # leading coefficient and returns 1. Otherwise returns 0. - # If ``exact`` is `0`, allows a remainder after the square root, which is - # not computed. - # This function first uses various tests to detect nonsquares quickly. - # Then, it computes the square root iteratively from top to bottom. - int fmpz_poly_sqrt_divconquer(fmpz_poly_t b, const fmpz_poly_t a) noexcept - # If ``a`` is a perfect square, sets ``b`` to the square root of - # ``a`` with positive leading coefficient and returns 1. - # Otherwise returns 0. - int _fmpz_poly_sqrt(fmpz * res, const fmpz * poly, slong len) noexcept - # If ``(poly, len)`` is a perfect square, sets ``(res, len / 2 + 1)`` - # to the square root of ``poly`` with positive leading coefficient - # and returns 1. Otherwise returns 0. - int fmpz_poly_sqrt(fmpz_poly_t b, const fmpz_poly_t a) noexcept - # If ``a`` is a perfect square, sets ``b`` to the square root of - # ``a`` with positive leading coefficient and returns 1. - # Otherwise returns 0. - int _fmpz_poly_sqrt_series(fmpz * res, const fmpz * poly, slong len, slong n) noexcept - # Set ``(res, n)`` to the square root of the series ``(poly, n)``, if it - # exists, and return `1`, otherwise, return `0`. - # If the valuation of ``poly`` is not zero, ``res`` is zero padded - # to make up for the fact that the square root may not be known to precision - # `n`. - int fmpz_poly_sqrt_series(fmpz_poly_t b, const fmpz_poly_t a, slong n) noexcept - # Set ``b`` to the square root of the series ``a``, where the latter - # is taken to be a series of precision `n`. If such a square root exists, - # return `1`, otherwise, return `0`. - # Note that if the valuation of ``a`` is not zero, ``b`` will - # not have precision ``n``. It is given only to the precision to which - # the square root can be computed. - void _fmpz_poly_power_sums_naive(fmpz * res, const fmpz * poly, slong len, slong n) noexcept - # Compute the (truncated) power sums series of the monic polynomial - # ``(poly,len)`` up to length `n` using Newton identities. - void fmpz_poly_power_sums_naive(fmpz_poly_t res, const fmpz_poly_t poly, slong n) noexcept - # Compute the (truncated) power sum series of the monic polynomial - # ``poly`` up to length `n` using Newton identities. - void fmpz_poly_power_sums(fmpz_poly_t res, const fmpz_poly_t poly, slong n) noexcept - # Compute the (truncated) power sums series of the monic polynomial ``poly`` - # up to length `n`. That is the power series whose coefficient of degree `i` is - # the sum of the `i`-th power of all (complex) roots of the polynomial - # ``poly``. - void _fmpz_poly_power_sums_to_poly(fmpz * res, const fmpz * poly, slong len) noexcept - # Compute the (monic) polynomial given by its power sums series ``(poly,len)``. - void fmpz_poly_power_sums_to_poly(fmpz_poly_t res, const fmpz_poly_t Q) noexcept - # Compute the (monic) polynomial given its power sums series ``(Q)``. - void _fmpz_poly_signature(slong * r1, slong * r2, const fmpz * poly, slong len) noexcept - # Computes the signature `(r_1, r_2)` of the polynomial - # ``(poly, len)``. Assumes that the polynomial is squarefree over `\mathbb{Q}`. - void fmpz_poly_signature(slong * r1, slong * r2, const fmpz_poly_t poly) noexcept - # Computes the signature `(r_1, r_2)` of the polynomial ``poly``, - # which is assumed to be square-free over `\mathbb{Q}`. The values of `r_1` and - # `2 r_2` are the number of real and complex roots of the polynomial, - # respectively. For convenience, the zero polynomial is allowed, in which - # case the output is `(0, 0)`. - # If the polynomial is not square-free, the behaviour is undefined and an - # exception may be raised. - # This function uses the algorithm described - # in Algorithm 4.1.11 of [Coh1996]_. - - void fmpz_poly_hensel_build_tree(slong * link, fmpz_poly_t *v, fmpz_poly_t *w, const nmod_poly_factor_t fac) noexcept - # Initialises and builds a Hensel tree consisting of two arrays `v`, `w` - # of polynomials and an array of links, called ``link``. - # The caller supplies a set of `r` local factors (in the factor structure - # ``fac``) of some polynomial `F` over `\mathbf{Z}`. They also supply - # two arrays of initialised polynomials `v` and `w`, each of length - # `2r - 2` and an array ``link``, also of length `2r - 2`. - # We will have five arrays: a `v` of ``fmpz_poly_t``'s and a `V` of - # ``nmod_poly_t``'s and also a `w` and a `W` and ``link``. Here's - # the idea: we sort each leaf and node of a factor tree by degree, in - # fact choosing to multiply the two smallest factors, then the next two - # smallest (factors or products) etc. until a tree is made. The tree - # will be stored in the `v`'s. The first two elements of `v` will be the - # smallest modular factors, the last two elements of `v` will multiply to - # form `F` itself. Since `v` will be rearranging the original factors we - # will need to be able to recover the original order. For this we use the - # array ``link`` which has nonnegative even numbers and negative numbers. - # It is an array of ``slong``\s which aligns with `V` and `v` if - # ``link`` has a negative number in spot `j` that means `V_j` is an - # original modular factor which has been lifted, if ``link[j]`` is a - # nonnegative even number then `V_j` stores a product of the two entries - # at ``V[link[j]]`` and ``V[link[j]+1]``. - # `W` and `w` play the role of the extended GCD, at `V_0`, `V_2`, `V_4`, - # etc. we have a new product, `W_0`, `W_2`, `W_4`, etc. are the XGCD - # cofactors of the `V`'s. For example, - # `V_0 W_0 + V_1 W_1 \equiv 1 \pmod{p^{\ell}}` for some `\ell`. These - # will be lifted along with the entries in `V`. It is not enough to just - # lift each factor, we have to lift the entire tree and the tree of - # XGCD cofactors. - + void fmpz_poly_hensel_build_tree(slong * link, fmpz_poly_t * v, fmpz_poly_t * w, const nmod_poly_factor_t fac) noexcept void fmpz_poly_hensel_lift(fmpz_poly_t G, fmpz_poly_t H, fmpz_poly_t A, fmpz_poly_t B, const fmpz_poly_t f, const fmpz_poly_t g, const fmpz_poly_t h, const fmpz_poly_t a, const fmpz_poly_t b, const fmpz_t p, const fmpz_t p1) noexcept - # This is the main Hensel lifting routine, which performs a Hensel step - # from polynomials mod `p` to polynomials mod `P = p p_1`. One starts with - # polynomials `f`, `g`, `h` such that `f = gh \pmod p`. The polynomials - # `a`, `b` satisfy `ag + bh = 1 \pmod p`. - # The lifting formulae are - # .. math :: - # G = \biggl( \bigl( \frac{f-gh}{p} \bigr) b \bmod g \biggr) p + g - # H = \biggl( \bigl( \frac{f-gh}{p} \bigr) a \bmod h \biggr) p + h - # B = \biggl( \bigl( \frac{1-aG-bH}{p} \bigr) b \bmod g \biggr) p + b - # A = \biggl( \bigl( \frac{1-aG-bH}{p} \bigr) a \bmod h \biggr) p + a - # Upon return we have `A G + B H = 1 \pmod P` and `f = G H \pmod P`, - # where `G = g \pmod p` etc. - # We require that `1 < p_1 \leq p` and that the input polynomials `f, g, h` - # have degree at least `1` and that the input polynomials `a` and `b` are - # non-zero. - # The output arguments `G, H, A, B` may only be aliased with - # the input arguments `g, h, a, b`, respectively. - void fmpz_poly_hensel_lift_without_inverse(fmpz_poly_t Gout, fmpz_poly_t Hout, const fmpz_poly_t f, const fmpz_poly_t g, const fmpz_poly_t h, const fmpz_poly_t a, const fmpz_poly_t b, const fmpz_t p, const fmpz_t p1) noexcept - # Given polynomials such that `f = gh \pmod p` and `ag + bh = 1 \pmod p`, - # lifts only the factors `g` and `h` modulo `P = p p_1`. - # See :func:`fmpz_poly_hensel_lift`. - void fmpz_poly_hensel_lift_only_inverse(fmpz_poly_t Aout, fmpz_poly_t Bout, const fmpz_poly_t G, const fmpz_poly_t H, const fmpz_poly_t a, const fmpz_poly_t b, const fmpz_t p, const fmpz_t p1) noexcept - # Given polynomials such that `f = gh \pmod p` and `ag + bh = 1 \pmod p`, - # lifts only the cofactors `a` and `b` modulo `P = p p_1`. - # See :func:`fmpz_poly_hensel_lift`. - - void fmpz_poly_hensel_lift_tree_recursive(slong *link, fmpz_poly_t *v, fmpz_poly_t *w, fmpz_poly_t f, slong j, slong inv, const fmpz_t p0, const fmpz_t p1) noexcept - # Takes a current Hensel tree ``(link, v, w)`` and a pair `(j,j+1)` - # of entries in the tree and lifts the tree from mod `p_0` to - # mod `P = p_0 p_1`, where `1 < p_1 \leq p_0`. - # Set ``inv`` to `-1` if restarting Hensel lifting, `0` if stopping - # and `1` otherwise. - # Here `f = g h` is the polynomial whose factors we are trying to lift. - # We will have that ``v[j]`` is the product of ``v[link[j]]`` and - # ``v[link[j] + 1]`` as described above. - # Does support aliasing of `f` with one of the polynomials in - # the lists `v` and `w`. But the polynomials in these two lists - # are not allowed to be aliases of each other. - - void fmpz_poly_hensel_lift_tree(slong *link, fmpz_poly_t *v, fmpz_poly_t *w, fmpz_poly_t f, slong r, const fmpz_t p, slong e0, slong e1, slong inv) noexcept - # Computes `p_0 = p^{e_0}` and `p_1 = p^{e_1 - e_0}` for a small prime `p` - # and `P = p^{e_1}`. - # If we aim to lift to `p^b` then `f` is the polynomial whose factors we - # wish to lift, made monic mod `p^b`. As usual, ``(link, v, w)`` is an - # initialised tree. - # This starts the recursion on lifting the *product tree* for lifting - # from `p^{e_0}` to `p^{e_1}`. The value of ``inv`` corresponds to that - # given for the function :func:`fmpz_poly_hensel_lift_tree_recursive`. We - # set `r` to the number of local factors of `f`. - # In terms of the notation, above `P = p^{e_1}`, `p_0 = p^{e_0}` and - # `p_1 = p^{e_1-e_0}`. - # Assumes that `f` is monic. - # Assumes that `1 < p_1 \leq p_0`, that is, `0 < e_1 \leq e_0`. - - slong _fmpz_poly_hensel_start_lift(fmpz_poly_factor_t lifted_fac, slong *link, fmpz_poly_t *v, fmpz_poly_t *w, const fmpz_poly_t f, const nmod_poly_factor_t local_fac, slong N) noexcept - # This function takes the local factors in ``local_fac`` - # and Hensel lifts them until they are known mod `p^N`, where - # `N \geq 1`. - # These lifted factors will be stored (in the same ordering) in - # ``lifted_fac``. It is assumed that ``link``, ``v``, and - # ``w`` are initialized arrays of ``fmpz_poly_t``'s with at least - # `2*r - 2` entries and that `r \geq 2`. This is done outside of - # this function so that you can keep them for restarting Hensel lifting - # later. The product of local factors must be squarefree. - # The return value is an exponent which must be passed to the function - # :func:`_fmpz_poly_hensel_continue_lift` as ``prev_exp`` if the - # Hensel lifting is to be resumed. - # Currently, supports the case when `N = 1` for convenience, - # although it is preferable in this case to simply iterate - # over the local factors and convert them to polynomials over - # `\mathbf{Z}`. - - slong _fmpz_poly_hensel_continue_lift(fmpz_poly_factor_t lifted_fac, slong *link, fmpz_poly_t *v, fmpz_poly_t *w, const fmpz_poly_t f, slong prev, slong curr, slong N, const fmpz_t p) noexcept - # This function restarts a stopped Hensel lift. - # It lifts from ``curr`` to `N`. It also requires ``prev`` - # (to lift the cofactors) given as the return value of the function - # :func:`_fmpz_poly_hensel_start_lift` or the function - # :func:`_fmpz_poly_hensel_continue_lift`. The current lifted factors - # are supplied in ``lifted_fac`` and upon return are updated - # there. As usual ``link``, ``v``, and ``w`` describe the - # current Hensel tree, `r` is the number of local factors and `p` is - # the small prime modulo whose power we are lifting to. It is required - # that ``curr`` be at least `1` and that ``N > curr``. - # Currently, supports the case when ``prev`` and ``curr`` - # are equal. - + void fmpz_poly_hensel_lift_tree_recursive(slong * link, fmpz_poly_t * v, fmpz_poly_t * w, fmpz_poly_t f, slong j, slong inv, const fmpz_t p0, const fmpz_t p1) noexcept + void fmpz_poly_hensel_lift_tree(slong * link, fmpz_poly_t * v, fmpz_poly_t * w, fmpz_poly_t f, slong r, const fmpz_t p, slong e0, slong e1, slong inv) noexcept + slong _fmpz_poly_hensel_start_lift(fmpz_poly_factor_t lifted_fac, slong * link, fmpz_poly_t * v, fmpz_poly_t * w, const fmpz_poly_t f, const nmod_poly_factor_t local_fac, slong N) noexcept + slong _fmpz_poly_hensel_continue_lift(fmpz_poly_factor_t lifted_fac, slong * link, fmpz_poly_t * v, fmpz_poly_t * w, const fmpz_poly_t f, slong prev, slong curr, slong N, const fmpz_t p) noexcept void fmpz_poly_hensel_lift_once(fmpz_poly_factor_t lifted_fac, const fmpz_poly_t f, const nmod_poly_factor_t local_fac, slong N) noexcept - # This function does a Hensel lift. - # It lifts local factors stored in ``local_fac`` of `f` to `p^N`, - # where `N \geq 2`. The lifted factors will be stored in ``lifted_fac``. - # This lift cannot be restarted. This function is a convenience function - # intended for end users. The product of local factors must be squarefree. - int _fmpz_poly_print(const fmpz * poly, slong len) noexcept - # Prints the polynomial ``(poly, len)`` to ``stdout``. - # In case of success, returns a positive value. In case of failure, - # returns a non-positive value. - int fmpz_poly_print(const fmpz_poly_t poly) noexcept - # Prints the polynomial to ``stdout``. - # In case of success, returns a positive value. In case of failure, - # returns a non-positive value. - int _fmpz_poly_print_pretty(const fmpz * poly, slong len, const char * x) noexcept - # Prints the pretty representation of ``(poly, len)`` to ``stdout``, - # using the string ``x`` to represent the indeterminate. - # In case of success, returns a positive value. In case of failure, - # returns a non-positive value. - int fmpz_poly_print_pretty(const fmpz_poly_t poly, const char * x) noexcept - # Prints the pretty representation of ``poly`` to ``stdout``, - # using the string ``x`` to represent the indeterminate. - # In case of success, returns a positive value. In case of failure, - # returns a non-positive value. - int _fmpz_poly_fprint(FILE * file, const fmpz * poly, slong len) noexcept - # Prints the polynomial ``(poly, len)`` to the stream ``file``. - # In case of success, returns a positive value. In case of failure, - # returns a non-positive value. - int fmpz_poly_fprint(FILE * file, const fmpz_poly_t poly) noexcept - # Prints the polynomial to the stream ``file``. - # In case of success, returns a positive value. In case of failure, - # returns a non-positive value. - int _fmpz_poly_fprint_pretty(FILE * file, const fmpz * poly, slong len, const char * x) noexcept - # Prints the pretty representation of ``(poly, len)`` to the stream - # ``file``, using the string ``x`` to represent the indeterminate. - # In case of success, returns a positive value. In case of failure, - # returns a non-positive value. - int fmpz_poly_fprint_pretty(FILE * file, const fmpz_poly_t poly, const char * x) noexcept - # Prints the pretty representation of ``poly`` to the stream ``file``, - # using the string ``x`` to represent the indeterminate. - # In case of success, returns a positive value. In case of failure, - # returns a non-positive value. - int fmpz_poly_read(fmpz_poly_t poly) noexcept - # Reads a polynomial from ``stdin``, storing the result in ``poly``. - # In case of success, returns a positive number. In case of failure, - # returns a non-positive value. - int fmpz_poly_read_pretty(fmpz_poly_t poly, char **x) noexcept - # Reads a polynomial in pretty format from ``stdin``. - # For further details, see the documentation for the function - # :func:`fmpz_poly_fread_pretty`. - int fmpz_poly_fread(FILE * file, fmpz_poly_t poly) noexcept - # Reads a polynomial from the stream ``file``, storing the result - # in ``poly``. - # In case of success, returns a positive number. In case of failure, - # returns a non-positive value. - - int fmpz_poly_fread_pretty(FILE *file, fmpz_poly_t poly, char **x) noexcept - # Reads a polynomial from the file ``file`` and sets ``poly`` - # to this polynomial. The string ``*x`` is set to the variable - # name that is used in the input. - # Returns a positive value, equal to the number of characters read from - # the file, in case of success. Returns a non-positive value in case of - # failure, which could either be a read error or the indicator of a - # malformed input. - + int fmpz_poly_fread_pretty(FILE * file, fmpz_poly_t poly, char **x) noexcept void fmpz_poly_get_nmod_poly(nmod_poly_t Amod, const fmpz_poly_t A) noexcept - # Sets the coefficients of ``Amod`` to the coefficients in ``A``, - # reduced by the modulus of ``Amod``. - void fmpz_poly_set_nmod_poly(fmpz_poly_t A, const nmod_poly_t Amod) noexcept - # Sets the coefficients of ``A`` to the residues in ``Amod``, - # normalised to the interval `-m/2 \le r < m/2` where `m` is the modulus. - void fmpz_poly_set_nmod_poly_unsigned(fmpz_poly_t A, const nmod_poly_t Amod) noexcept - # Sets the coefficients of ``A`` to the residues in ``Amod``, - # normalised to the interval `0 \le r < m` where `m` is the modulus. - void _fmpz_poly_CRT_ui_precomp(fmpz * res, const fmpz * poly1, slong len1, const fmpz_t m1, mp_srcptr poly2, slong len2, mp_limb_t m2, mp_limb_t m2inv, fmpz_t m1m2, mp_limb_t c, int sign) noexcept - # Sets the coefficients in ``res`` to the CRT reconstruction modulo - # `m_1m_2` of the residues ``(poly1, len1)`` and ``(poly2, len2)`` - # which are images modulo `m_1` and `m_2` respectively. - # The caller must supply the precomputed product of the input moduli as - # `m_1m_2`, the inverse of `m_1` modulo `m_2` as `c`, and - # the precomputed inverse of `m_2` (in the form computed by - # ``n_preinvert_limb``) as ``m2inv``. - # If ``sign`` = 0, residues `0 \le r < m_1 m_2` are computed, while - # if ``sign`` = 1, residues `-m_1 m_2/2 \le r < m_1 m_2/2` are computed. - # Coefficients of ``res`` are written up to the maximum of - # ``len1`` and ``len2``. - void _fmpz_poly_CRT_ui(fmpz * res, const fmpz * poly1, slong len1, const fmpz_t m1, mp_srcptr poly2, slong len2, mp_limb_t m2, mp_limb_t m2inv, int sign) noexcept - # This function is identical to ``_fmpz_poly_CRT_ui_precomp``, - # apart from automatically computing `m_1m_2` and `c`. It also - # aborts if `c` cannot be computed. - void fmpz_poly_CRT_ui(fmpz_poly_t res, const fmpz_poly_t poly1, const fmpz_t m, const nmod_poly_t poly2, int sign) noexcept - # Given ``poly1`` with coefficients modulo ``m`` and ``poly2`` - # with modulus `n`, sets ``res`` to the CRT reconstruction modulo `mn` - # with coefficients satisfying `-mn/2 \le c < mn/2` (if sign = 1) - # or `0 \le c < mn` (if sign = 0). - void _fmpz_poly_product_roots_fmpz_vec(fmpz * poly, const fmpz * xs, slong n) noexcept - # Sets ``(poly, n + 1)`` to the monic polynomial which is the product - # of `(x - x_0)(x - x_1) \cdots (x - x_{n-1})`, the roots `x_i` being - # given by ``xs``. - # Aliasing of the input and output is not allowed. - void fmpz_poly_product_roots_fmpz_vec(fmpz_poly_t poly, const fmpz * xs, slong n) noexcept - # Sets ``poly`` to the monic polynomial which is the product - # of `(x - x_0)(x - x_1) \cdots (x - x_{n-1})`, the roots `x_i` being - # given by ``xs``. - void _fmpz_poly_product_roots_fmpq_vec(fmpz * poly, const fmpq * xs, slong n) noexcept - # Sets ``(poly, n + 1)`` to the product of - # `(q_0 x - p_0)(q_1 x - p_1) \cdots (q_{n-1} x - p_{n-1})`, the roots - # `p_i/q_i` being given by ``xs``. - void fmpz_poly_product_roots_fmpq_vec(fmpz_poly_t poly, const fmpq * xs, slong n) noexcept - # Sets ``poly`` to the polynomial which is the product - # of `(q_0 x - p_0)(q_1 x - p_1) \cdots (q_{n-1} x - p_{n-1})`, the roots - # `p_i/q_i` being given by ``xs``. - void _fmpz_poly_bound_roots(fmpz_t bound, const fmpz * poly, slong len) noexcept void fmpz_poly_bound_roots(fmpz_t bound, const fmpz_poly_t poly) noexcept - # Computes a nonnegative integer ``bound`` that bounds the absolute - # value of all complex roots of ``poly``. Uses Fujiwara's bound - # .. math :: - # 2 \max \left( - # \left|\frac{a_{n-1}}{a_n}\right|, - # \left|\frac{a_{n-2}}{a_n}\right|^{\frac{1}{2}}, \dotsc, - # \left|\frac{a_1}{a_n}\right|^{\frac{1}{n-1}}, - # \left|\frac{a_0}{2a_n}\right|^{\frac{1}{n}} - # \right) - # where the coefficients of the polynomial are `a_0, \ldots, a_n`. - void _fmpz_poly_num_real_roots_sturm(slong * n_neg, slong * n_pos, const fmpz * pol, slong len) noexcept - # Sets ``n_neg`` and ``n_pos`` to the number of negative and - # positive roots of the polynomial ``(pol, len)`` using Sturm - # sequence. The Sturm sequence is computed via subresultant - # remainders obtained by repeated call to the function - # ``_fmpz_poly_pseudo_rem_cohen``. - # The polynomial is assumed to be squarefree, of degree larger than 1 - # and with non-zero constant coefficient. - slong fmpz_poly_num_real_roots_sturm(const fmpz_poly_t pol) noexcept - # Returns the number of real roots of the squarefree polynomial ``pol`` - # using Sturm sequence. - # The polynomial is assumed to be squarefree. - slong _fmpz_poly_num_real_roots(const fmpz * pol, slong len) noexcept - # Returns the number of real roots of the squarefree polynomial - # ``(pol, len)``. - # The polynomial is assumed to be squarefree. - slong fmpz_poly_num_real_roots(const fmpz_poly_t pol) noexcept - # Returns the number of real roots of the squarefree polynomial ``pol``. - # The polynomial is assumed to be squarefree. - void _fmpz_poly_cyclotomic(fmpz * a, ulong n, mp_ptr factors, slong num_factors, ulong phi) noexcept - # Sets ``a`` to the lower half of the cyclotomic polynomial `\Phi_n(x)`, - # given `n \ge 3` which must be squarefree. - # A precomputed array containing the prime factors of `n` must be provided, - # as well as the value of the Euler totient function `\phi(n)` as ``phi``. - # If `n` is even, 2 must be the first factor in the list. - # The degree of `\Phi_n(x)` is exactly `\phi(n)`. Only the low - # `(\phi(n) + 1) / 2` coefficients are written; the high coefficients - # can be obtained afterwards by copying the low coefficients - # in reverse order, since `\Phi_n(x)` is a palindrome for `n \ne 1`. - # We use the sparse power series algorithm described as Algorithm 4 - # [ArnoldMonagan2011]_. The algorithm is based on the identity - # .. math :: - # \Phi_n(x) = \prod_{d|n} (x^d - 1)^{\mu(n/d)}. - # Treating the polynomial as a power series, the multiplications and - # divisions can be done very cheaply using repeated additions and - # subtractions. The complexity is `O(2^k \phi(n))` where `k` is the - # number of prime factors in `n`. - # To improve efficiency for small `n`, we treat the ``fmpz`` - # coefficients as machine integers when there is no risk of overflow. - # The following bounds are given in Table 6 of [ArnoldMonagan2011]_: - # For `n < 10163195`, the largest coefficient in any `\Phi_n(x)` - # has 27 bits, so machine arithmetic is safe on 32 bits. - # For `n < 169828113`, the largest coefficient in any `\Phi_n(x)` - # has 60 bits, so machine arithmetic is safe on 64 bits. - # Further, the coefficients are always `\pm 1` or 0 if there are - # exactly two prime factors, so in this case machine arithmetic can be - # used as well. - # Finally, we handle two special cases: if there is exactly one prime - # factor `n = p`, then `\Phi_n(x) = 1 + x + x^2 + \ldots + x^{n-1}`, - # and if `n = 2m`, we use `\Phi_n(x) = \Phi_m(-x)` to fall back - # to the case when `n` is odd. - void fmpz_poly_cyclotomic(fmpz_poly_t poly, ulong n) noexcept - # Sets ``poly`` to the `n`-th cyclotomic polynomial, defined as - # `\Phi_n(x) = \prod_{\omega} (x-\omega)` - # where `\omega` runs over all the `n`-th primitive roots of unity. - # We factor `n` into `n = qs` where `q` is squarefree, - # and compute `\Phi_q(x)`. Then `\Phi_n(x) = \Phi_q(x^s)`. - ulong _fmpz_poly_is_cyclotomic(const fmpz * poly, slong len) noexcept ulong fmpz_poly_is_cyclotomic(const fmpz_poly_t poly) noexcept - # If ``poly`` is a cyclotomic polynomial, returns the index `n` of this - # cyclotomic polynomial. If ``poly`` is not a cyclotomic polynomial, - # returns 0. - void _fmpz_poly_cos_minpoly(fmpz * coeffs, ulong n) noexcept void fmpz_poly_cos_minpoly(fmpz_poly_t poly, ulong n) noexcept - # Sets ``poly`` to the minimal polynomial of `2 \cos(2 \pi / n)`. - # For suitable choice of `n`, this gives the minimal polynomial - # of `2 \cos(a \pi)` or `2 \sin(a \pi)` for any rational `a`. - # The cosine is multiplied by a factor two since this gives - # a monic polynomial with integer coefficients. One can obtain - # the minimal polynomial for `\cos(2 \pi / n)` by making - # the substitution `x \to x / 2`. - # For `n > 2`, the degree of the polynomial is `\varphi(n) / 2`. - # For `n = 1, 2`, the degree is 1. For `n = 0`, we define - # the output to be the constant polynomial 1. - # See [WaktinsZeitlin1993]_. - void _fmpz_poly_swinnerton_dyer(fmpz * coeffs, ulong n) noexcept void fmpz_poly_swinnerton_dyer(fmpz_poly_t poly, ulong n) noexcept - # Sets ``poly`` to the Swinnerton-Dyer polynomial `S_n`, defined as - # the integer polynomial - # `S_n = \prod (x \pm \sqrt{2} \pm \sqrt{3} \pm \sqrt{5} \pm \ldots \pm \sqrt{p_n})` - # where `p_n` denotes the `n`-th prime number and all combinations - # of signs are taken. This polynomial has degree `2^n` and is - # irreducible over the integers (it is the minimal polynomial - # of `\sqrt{2} + \ldots + \sqrt{p_n}`). - void _fmpz_poly_chebyshev_t(fmpz * coeffs, ulong n) noexcept void fmpz_poly_chebyshev_t(fmpz_poly_t poly, ulong n) noexcept - # Sets ``poly`` to the Chebyshev polynomial of the first kind `T_n(x)`, - # defined by `T_n(x) = \cos(n \cos^{-1}(x))`, for `n\ge0`. The coefficients are - # calculated using a hypergeometric recurrence. - void _fmpz_poly_chebyshev_u(fmpz * coeffs, ulong n) noexcept void fmpz_poly_chebyshev_u(fmpz_poly_t poly, ulong n) noexcept - # Sets ``poly`` to the Chebyshev polynomial of the first kind `U_n(x)`, - # defined by `(n+1) U_n(x) = T'_{n+1}(x)`, for `n\ge0`. - # The coefficients are calculated using a hypergeometric recurrence. - void _fmpz_poly_legendre_pt(fmpz * coeffs, ulong n) noexcept - # Sets ``coeffs`` to the coefficient array of the shifted Legendre - # polynomial `\tilde{P_n}(x)`, defined by `\tilde{P_n}(x) = P_n(2x-1)`, for `n\ge0`. - # The coefficients are calculated using a hypergeometric recurrence. - # The length of the array will be ``n+1``. - # See ``fmpq_poly`` for the Legendre polynomials. - void fmpz_poly_legendre_pt(fmpz_poly_t poly, ulong n) noexcept - # Sets ``poly`` to the shifted Legendre polynomial `\tilde{P_n}(x)`, - # defined by `\tilde{P_n}(x) = P_n(2x-1)`, for `n\ge0`. The coefficients are - # calculated using a hypergeometric recurrence. See ``fmpq_poly`` - # for the Legendre polynomials. - void _fmpz_poly_hermite_h(fmpz * coeffs, ulong n) noexcept - # Sets ``coeffs`` to the coefficient array of the Hermite - # polynomial `H_n(x)`, defined by `H'_n(x) = 2nH_{n-1}(x)`, for `n\ge0`. - # The coefficients are calculated using a hypergeometric recurrence. - # The length of the array will be ``n+1``. - void fmpz_poly_hermite_h(fmpz_poly_t poly, ulong n) noexcept - # Sets ``poly`` to the Hermite polynomial `H_n(x)`, - # defined by `H'_n(x) = 2nH_{n-1}(x)`, for `n\ge0`. The coefficients are - # calculated using a hypergeometric recurrence. - void _fmpz_poly_hermite_he(fmpz * coeffs, ulong n) noexcept - # Sets ``coeffs`` to the coefficient array of the Hermite - # polynomial `He_n(x)`, defined by - # `He_n(x) = 2^{-\tfrac{n}{2}}H_n\left(\frac{x}{\sqrt2}\right)`, for `n\ge0`. - # The coefficients are calculated using a hypergeometric recurrence. - # The length of the array will be ``n+1``. - void fmpz_poly_hermite_he(fmpz_poly_t poly, ulong n) noexcept - # Sets ``poly`` to the Hermite polynomial `He_n(x)`, - # defined by `He_n(x) = 2^{-\tfrac{n}{2}}H_n\left(\frac{x}{\sqrt2}\right)`, for `n\ge0`. - # The coefficients are calculated using a hypergeometric recurrence. - void _fmpz_poly_fibonacci(fmpz * coeffs, ulong n) noexcept - # Sets ``coeffs`` to the coefficient array of the `n`-th Fibonacci polynomial. - # The coefficients are calculated using a hypergeometric recurrence. - void fmpz_poly_fibonacci(fmpz_poly_t poly, ulong n) noexcept - # Sets ``poly`` to the `n`-th Fibonacci polynomial. - # The coefficients are calculated using a hypergeometric recurrence. - void arith_eulerian_polynomial(fmpz_poly_t res, ulong n) noexcept - # Sets ``res`` to the Eulerian polynomial `A_n(x)`, where we define - # `A_0(x) = 1`. The polynomial is calculated via a recursive relation. - void _fmpz_poly_eta_qexp(fmpz * f, slong r, slong len) noexcept void fmpz_poly_eta_qexp(fmpz_poly_t f, slong r, slong n) noexcept - # Sets `f` to the `q`-expansion to length `n` of the - # Dedekind eta function (without the leading factor - # `q^{1/24}`) raised to the power `r`, i.e. - # `(q^{-1/24} \eta(q))^r = \prod_{k=1}^{\infty} (1 - q^k)^r`. - # In particular, `r = -1` gives the generating function - # of the partition function `p(k)`, and `r = 24` gives, - # after multiplication by `q`, - # the modular discriminant `\Delta(q)` which generates - # the Ramanujan tau function `\tau(k)`. - # This function uses sparse formulas for `r = 1, 2, 3, 4, 6` - # and otherwise reduces to one of those cases using power series arithmetic. - void _fmpz_poly_theta_qexp(fmpz * f, slong r, slong len) noexcept void fmpz_poly_theta_qexp(fmpz_poly_t f, slong r, slong n) noexcept - # Sets `f` to the `q`-expansion to length `n` of the - # Jacobi theta function raised to the power `r`, i.e. `\vartheta(q)^r` - # where `\vartheta(q) = 1 + 2 \sum_{k=1}^{\infty} q^{k^2}`. - # This function uses sparse formulas for `r = 1, 2` - # and otherwise reduces to those cases using power series arithmetic. - void fmpz_poly_CLD_bound(fmpz_t res, const fmpz_poly_t f, slong n) noexcept - # Compute a bound on the `n` coefficient of `fg'/g` where `g` is any - # factor of `f`. from .fmpz_poly_macros cimport * diff --git a/src/sage/libs/flint/fmpz_poly_factor.pxd b/src/sage/libs/flint/fmpz_poly_factor.pxd index 1bed31a327a..bca34daa554 100644 --- a/src/sage/libs/flint/fmpz_poly_factor.pxd +++ b/src/sage/libs/flint/fmpz_poly_factor.pxd @@ -2,7 +2,9 @@ # distutils: depends = flint/fmpz_poly_factor.h ################################################################################ -# This file is auto-generated. Do not modify by hand +# This file is auto-generated by the script +# SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py. +# Do not modify by hand! Fix and rerun the script instead. ################################################################################ from libc.stdio cimport FILE @@ -11,91 +13,19 @@ from sage.libs.mpfr.types cimport * from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void fmpz_poly_factor_init(fmpz_poly_factor_t fac) noexcept - # Initialises a new factor structure. - void fmpz_poly_factor_init2(fmpz_poly_factor_t fac, slong alloc) noexcept - # Initialises a new factor structure, providing space for - # at least ``alloc`` factors. - void fmpz_poly_factor_realloc(fmpz_poly_factor_t fac, slong alloc) noexcept - # Reallocates the factor structure to provide space for - # precisely ``alloc`` factors. - void fmpz_poly_factor_fit_length(fmpz_poly_factor_t fac, slong len) noexcept - # Ensures that the factor structure has space for at - # least ``len`` factors. This functions takes care - # of the case of repeated calls by always at least - # doubling the number of factors the structure can hold. - void fmpz_poly_factor_clear(fmpz_poly_factor_t fac) noexcept - # Releases all memory occupied by the factor structure. - void fmpz_poly_factor_set(fmpz_poly_factor_t res, const fmpz_poly_factor_t fac) noexcept - # Sets ``res`` to the same factorisation as ``fac``. - void fmpz_poly_factor_insert(fmpz_poly_factor_t fac, const fmpz_poly_t p, slong e) noexcept - # Adds the primitive polynomial `p^e` to the factorisation ``fac``. - # Assumes that `\deg(p) \geq 2` and `e \neq 0`. - void fmpz_poly_factor_concat(fmpz_poly_factor_t res, const fmpz_poly_factor_t fac) noexcept - # Concatenates two factorisations. - # This is equivalent to calling :func:`fmpz_poly_factor_insert` - # repeatedly with the individual factors of ``fac``. - # Does not support aliasing between ``res`` and ``fac``. - void fmpz_poly_factor_print(const fmpz_poly_factor_t fac) noexcept - # Prints the entries of ``fac`` to standard output. - void fmpz_poly_factor_squarefree(fmpz_poly_factor_t fac, const fmpz_poly_t F) noexcept - # Takes as input a polynomial `F` and a freshly initialized factor - # structure ``fac``. Updates ``fac`` to contain a factorization - # of `F` into (not necessarily irreducible) factors that themselves - # have no repeated factors. None of the returned factors will have - # the same exponent. That is we return `g_i` and unique `e_i` such that - # .. math :: - # F = c \prod_{i} g_i^{e_i} - # where `c` is the signed content of `F` and `\gcd(g_i, g_i') = 1`. - void fmpz_poly_factor_zassenhaus_recombination(fmpz_poly_factor_t final_fac, const fmpz_poly_factor_t lifted_fac, const fmpz_poly_t F, const fmpz_t P, slong exp) noexcept - # Takes as input a factor structure ``lifted_fac`` containing a - # squarefree factorization of the polynomial `F \bmod p`. The algorithm - # does a brute force search for irreducible factors of `F` over the - # integers, and each factor is raised to the power ``exp``. - # The impact of the algorithm is to augment a factorization of - # ``F^exp`` to the factor structure ``final_fac``. - void _fmpz_poly_factor_zassenhaus(fmpz_poly_factor_t final_fac, slong exp, const fmpz_poly_t f, slong cutoff, int use_van_hoeij) noexcept - # This is the internal wrapper of Zassenhaus. - # It will attempt to find a small prime such that `f` modulo `p` has - # a minimal number of factors. If it cannot find a prime giving less - # than ``cutoff`` factors it aborts. Then it decides a `p`-adic - # precision to lift the factors to, Hensel lifts, and finally calls - # Zassenhaus recombination. - # Assumes that `\operatorname{len}(f) \geq 2`. - # Assumes that `f` is primitive. - # Assumes that the constant coefficient of `f` is non-zero. Note that - # this can be easily achieved by taking out factors of the form `x^k` - # before calling this routine. - # If the final flag is set, the function will use the van Hoeij factorisation - # algorithm with gradual feeding and mod `2^k` data truncation to find - # factors when the number of local factors is large. - void fmpz_poly_factor_zassenhaus(fmpz_poly_factor_t final_fac, const fmpz_poly_t F) noexcept - # A wrapper of the Zassenhaus factoring algorithm, which takes as input - # any polynomial `F`, and stores a factorization in ``final_fac``. - # The complexity will be exponential in the number of local factors - # we find for the components of a squarefree factorization of `F`. - void _fmpz_poly_factor_quadratic(fmpz_poly_factor_t fac, const fmpz_poly_t f, slong exp) noexcept void _fmpz_poly_factor_cubic(fmpz_poly_factor_t fac, const fmpz_poly_t f, slong exp) noexcept - # Inserts the factorisation of the quadratic (resp. cubic) polynomial *f* into *fac* with - # multiplicity *exp*. This function requires that the content of *f* has - # been removed, and does not update the content of *fac*. - # The factorization is calculated over `\mathbb{R}` or `\mathbb{Q}_2` and then tested over `\mathbb{Z}`. - void fmpz_poly_factor(fmpz_poly_factor_t final_fac, const fmpz_poly_t F) noexcept - # A wrapper of the Zassenhaus and van Hoeij factoring algorithms, which takes - # as input any polynomial `F`, and stores a factorization in - # ``final_fac``. diff --git a/src/sage/libs/flint/fmpz_poly_macros.pxd b/src/sage/libs/flint/fmpz_poly_macros.pxd index dc744322da3..6690d8bd8bb 100644 --- a/src/sage/libs/flint/fmpz_poly_macros.pxd +++ b/src/sage/libs/flint/fmpz_poly_macros.pxd @@ -1,8 +1,7 @@ # Macros from fmpz_poly.h -# See https://github.com/flintlib/flint/issues/152 +# See https://github.com/flintlib/flint/issues/1529 from .types cimport * cdef extern from "flint_wrap.h": fmpz * fmpz_poly_get_coeff_ptr(fmpz_poly_t p, ulong n) - # Macro giving a pointer to the n-th coefficient of p (or NULL) diff --git a/src/sage/libs/flint/fmpz_poly_mat.pxd b/src/sage/libs/flint/fmpz_poly_mat.pxd index 92d5ae38a0d..83ed1d8bced 100644 --- a/src/sage/libs/flint/fmpz_poly_mat.pxd +++ b/src/sage/libs/flint/fmpz_poly_mat.pxd @@ -2,7 +2,9 @@ # distutils: depends = flint/fmpz_poly_mat.h ################################################################################ -# This file is auto-generated. Do not modify by hand +# This file is auto-generated by the script +# SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py. +# Do not modify by hand! Fix and rerun the script instead. ################################################################################ from libc.stdio cimport FILE @@ -11,281 +13,57 @@ from sage.libs.mpfr.types cimport * from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void fmpz_poly_mat_init(fmpz_poly_mat_t mat, slong rows, slong cols) noexcept - # Initialises a matrix with the given number of rows and columns for use. - void fmpz_poly_mat_init_set(fmpz_poly_mat_t mat, const fmpz_poly_mat_t src) noexcept - # Initialises a matrix ``mat`` of the same dimensions as ``src``, - # and sets it to a copy of ``src``. - void fmpz_poly_mat_clear(fmpz_poly_mat_t mat) noexcept - # Frees all memory associated with the matrix. The matrix must be - # reinitialised if it is to be used again. - slong fmpz_poly_mat_nrows(const fmpz_poly_mat_t mat) noexcept - # Returns the number of rows in ``mat``. - slong fmpz_poly_mat_ncols(const fmpz_poly_mat_t mat) noexcept - # Returns the number of columns in ``mat``. - fmpz_poly_struct * fmpz_poly_mat_entry(const fmpz_poly_mat_t mat, slong i, slong j) noexcept - # Gives a reference to the entry at row ``i`` and column ``j``. - # The reference can be passed as an input or output variable to any - # ``fmpz_poly`` function for direct manipulation of the matrix element. - # No bounds checking is performed. - void fmpz_poly_mat_set(fmpz_poly_mat_t mat1, const fmpz_poly_mat_t mat2) noexcept - # Sets ``mat1`` to a copy of ``mat2``. - void fmpz_poly_mat_swap(fmpz_poly_mat_t mat1, fmpz_poly_mat_t mat2) noexcept - # Swaps ``mat1`` and ``mat2`` efficiently. - void fmpz_poly_mat_swap_entrywise(fmpz_poly_mat_t mat1, fmpz_poly_mat_t mat2) noexcept - # Swaps two matrices by swapping the individual entries rather than swapping - # the contents of the structs. - void fmpz_poly_mat_print(const fmpz_poly_mat_t mat, const char * x) noexcept - # Prints the matrix ``mat`` to standard output, using the - # variable ``x``. - void fmpz_poly_mat_randtest(fmpz_poly_mat_t mat, flint_rand_t state, slong len, flint_bitcnt_t bits) noexcept - # This is equivalent to applying ``fmpz_poly_randtest`` to all entries - # in the matrix. - void fmpz_poly_mat_randtest_unsigned(fmpz_poly_mat_t mat, flint_rand_t state, slong len, flint_bitcnt_t bits) noexcept - # This is equivalent to applying ``fmpz_poly_randtest_unsigned`` to - # all entries in the matrix. - void fmpz_poly_mat_randtest_sparse(fmpz_poly_mat_t A, flint_rand_t state, slong len, flint_bitcnt_t bits, float density) noexcept - # Creates a random matrix with the amount of nonzero entries given - # approximately by the ``density`` variable, which should be a fraction - # between 0 (most sparse) and 1 (most dense). - # The nonzero entries will have random lengths between 1 and ``len``. - void fmpz_poly_mat_zero(fmpz_poly_mat_t mat) noexcept - # Sets ``mat`` to the zero matrix. - void fmpz_poly_mat_one(fmpz_poly_mat_t mat) noexcept - # Sets ``mat`` to the unit or identity matrix of given shape, - # having the element 1 on the main diagonal and zeros elsewhere. - # If ``mat`` is nonsquare, it is set to the truncation of a unit matrix. - bint fmpz_poly_mat_equal(const fmpz_poly_mat_t mat1, const fmpz_poly_mat_t mat2) noexcept - # Returns nonzero if ``mat1`` and ``mat2`` have the same shape and - # all their entries agree, and returns zero otherwise. - bint fmpz_poly_mat_is_zero(const fmpz_poly_mat_t mat) noexcept - # Returns nonzero if all entries in ``mat`` are zero, and returns - # zero otherwise. - bint fmpz_poly_mat_is_one(const fmpz_poly_mat_t mat) noexcept - # Returns nonzero if all entries of ``mat`` on the main diagonal - # are the constant polynomial 1 and all remaining entries are zero, - # and returns zero otherwise. The matrix need not be square. - bint fmpz_poly_mat_is_empty(const fmpz_poly_mat_t mat) noexcept - # Returns a non-zero value if the number of rows or the number of - # columns in ``mat`` is zero, and otherwise returns - # zero. - bint fmpz_poly_mat_is_square(const fmpz_poly_mat_t mat) noexcept - # Returns a non-zero value if the number of rows is equal to the - # number of columns in ``mat``, and otherwise returns zero. - slong fmpz_poly_mat_max_bits(const fmpz_poly_mat_t A) noexcept - # Returns the maximum number of bits among the coefficients of the - # entries in ``A``, or the negative of that value if any - # coefficient is negative. - slong fmpz_poly_mat_max_length(const fmpz_poly_mat_t A) noexcept - # Returns the maximum polynomial length among all the entries in ``A``. - void fmpz_poly_mat_transpose(fmpz_poly_mat_t B, const fmpz_poly_mat_t A) noexcept - # Sets `B` to `A^t`. - void fmpz_poly_mat_evaluate_fmpz(fmpz_mat_t B, const fmpz_poly_mat_t A, const fmpz_t x) noexcept - # Sets the ``fmpz_mat_t`` ``B`` to ``A`` evaluated entrywise - # at the point ``x``. - void fmpz_poly_mat_scalar_mul_fmpz_poly(fmpz_poly_mat_t B, const fmpz_poly_mat_t A, const fmpz_poly_t c) noexcept - # Sets ``B`` to ``A`` multiplied entrywise by the polynomial ``c``. - void fmpz_poly_mat_scalar_mul_fmpz(fmpz_poly_mat_t B, const fmpz_poly_mat_t A, const fmpz_t c) noexcept - # Sets ``B`` to ``A`` multiplied entrywise by the integer ``c``. - void fmpz_poly_mat_add(fmpz_poly_mat_t C, const fmpz_poly_mat_t A, const fmpz_poly_mat_t B) noexcept - # Sets ``C`` to the sum of ``A`` and ``B``. - # All matrices must have the same shape. Aliasing is allowed. - void fmpz_poly_mat_sub(fmpz_poly_mat_t C, const fmpz_poly_mat_t A, const fmpz_poly_mat_t B) noexcept - # Sets ``C`` to the sum of ``A`` and ``B``. - # All matrices must have the same shape. Aliasing is allowed. - void fmpz_poly_mat_neg(fmpz_poly_mat_t B, const fmpz_poly_mat_t A) noexcept - # Sets ``B`` to the negation of ``A``. - # The matrices must have the same shape. Aliasing is allowed. - void fmpz_poly_mat_mul(fmpz_poly_mat_t C, const fmpz_poly_mat_t A, const fmpz_poly_mat_t B) noexcept - # Sets ``C`` to the matrix product of ``A`` and ``B``. - # The matrices must have compatible dimensions for matrix multiplication. - # Aliasing is allowed. This function automatically chooses between - # classical and KS multiplication. - void fmpz_poly_mat_mul_classical(fmpz_poly_mat_t C, const fmpz_poly_mat_t A, const fmpz_poly_mat_t B) noexcept - # Sets ``C`` to the matrix product of ``A`` and ``B``, - # computed using the classical algorithm. The matrices must have - # compatible dimensions for matrix multiplication. Aliasing is allowed. - void fmpz_poly_mat_mul_KS(fmpz_poly_mat_t C, const fmpz_poly_mat_t A, const fmpz_poly_mat_t B) noexcept - # Sets ``C`` to the matrix product of ``A`` and ``B``, - # computed using Kronecker segmentation. The matrices must have - # compatible dimensions for matrix multiplication. Aliasing is allowed. - void fmpz_poly_mat_mullow(fmpz_poly_mat_t C, const fmpz_poly_mat_t A, const fmpz_poly_mat_t B, slong len) noexcept - # Sets ``C`` to the matrix product of ``A`` and ``B``, - # truncating each entry in the result to length ``len``. - # Uses classical matrix multiplication. The matrices must have - # compatible dimensions for matrix multiplication. Aliasing is allowed. - void fmpz_poly_mat_sqr(fmpz_poly_mat_t B, const fmpz_poly_mat_t A) noexcept - # Sets ``B`` to the square of ``A``, which must be a square matrix. - # Aliasing is allowed. This function automatically chooses between - # classical and KS squaring. - void fmpz_poly_mat_sqr_classical(fmpz_poly_mat_t B, const fmpz_poly_mat_t A) noexcept - # Sets ``B`` to the square of ``A``, which must be a square matrix. - # Aliasing is allowed. This function uses direct formulas for very small - # matrices, and otherwise classical matrix multiplication. - void fmpz_poly_mat_sqr_KS(fmpz_poly_mat_t B, const fmpz_poly_mat_t A) noexcept - # Sets ``B`` to the square of ``A``, which must be a square matrix. - # Aliasing is allowed. This function uses Kronecker segmentation. - void fmpz_poly_mat_sqrlow(fmpz_poly_mat_t B, const fmpz_poly_mat_t A, slong len) noexcept - # Sets ``B`` to the square of ``A``, which must be a square matrix, - # truncating all entries to length ``len``. - # Aliasing is allowed. This function uses direct formulas for very small - # matrices, and otherwise classical matrix multiplication. - void fmpz_poly_mat_pow(fmpz_poly_mat_t B, const fmpz_poly_mat_t A, ulong exp) noexcept - # Sets ``B`` to ``A`` raised to the power ``exp``, where ``A`` - # is a square matrix. Uses exponentiation by squaring. Aliasing is allowed. - void fmpz_poly_mat_pow_trunc(fmpz_poly_mat_t B, const fmpz_poly_mat_t A, ulong exp, slong len) noexcept - # Sets ``B`` to ``A`` raised to the power ``exp``, truncating - # all entries to length ``len``, where ``A`` is a square matrix. - # Uses exponentiation by squaring. Aliasing is allowed. - void fmpz_poly_mat_prod(fmpz_poly_mat_t res, fmpz_poly_mat_t * const factors, slong n) noexcept - # Sets ``res`` to the product of the ``n`` matrices given in - # the vector ``factors``, all of which must be square and of the - # same size. Uses binary splitting. - slong fmpz_poly_mat_find_pivot_any(const fmpz_poly_mat_t mat, slong start_row, slong end_row, slong c) noexcept - # Attempts to find a pivot entry for row reduction. - # Returns a row index `r` between ``start_row`` (inclusive) and - # ``stop_row`` (exclusive) such that column `c` in ``mat`` has - # a nonzero entry on row `r`, or returns -1 if no such entry exists. - # This implementation simply chooses the first nonzero entry - # it encounters. This is likely to be a nearly optimal choice if all - # entries in the matrix have roughly the same size, but can lead to - # unnecessary coefficient growth if the entries vary in size. - slong fmpz_poly_mat_find_pivot_partial(const fmpz_poly_mat_t mat, slong start_row, slong end_row, slong c) noexcept - # Attempts to find a pivot entry for row reduction. - # Returns a row index `r` between ``start_row`` (inclusive) and - # ``stop_row`` (exclusive) such that column `c` in ``mat`` has - # a nonzero entry on row `r`, or returns -1 if no such entry exists. - # This implementation searches all the rows in the column and - # chooses the nonzero entry of smallest degree. If there are several - # entries with the same minimal degree, it chooses the entry with - # the smallest coefficient bit bound. This heuristic typically reduces - # coefficient growth when the matrix entries vary in size. - slong fmpz_poly_mat_fflu(fmpz_poly_mat_t B, fmpz_poly_t den, slong * perm, const fmpz_poly_mat_t A, int rank_check) noexcept - # Uses fraction-free Gaussian elimination to set (``B``, ``den``) to a - # fraction-free LU decomposition of ``A`` and returns the - # rank of ``A``. Aliasing of ``A`` and ``B`` is allowed. - # Pivot elements are chosen with ``fmpz_poly_mat_find_pivot_partial``. - # If ``perm`` is non-``NULL``, the permutation of - # rows in the matrix will also be applied to ``perm``. - # If ``rank_check`` is set, the function aborts and returns 0 if the - # matrix is detected not to have full rank without completing the - # elimination. - # The denominator ``den`` is set to `\pm \operatorname{det}(A)`, where - # the sign is decided by the parity of the permutation. Note that the - # determinant is not generally the minimal denominator. - slong fmpz_poly_mat_rref(fmpz_poly_mat_t B, fmpz_poly_t den, const fmpz_poly_mat_t A) noexcept - # Sets (``B``, ``den``) to the reduced row echelon form of - # ``A`` and returns the rank of ``A``. Aliasing of ``A`` and - # ``B`` is allowed. - # The denominator ``den`` is set to `\pm \operatorname{det}(A)`. - # Note that the determinant is not generally the minimal denominator. - void fmpz_poly_mat_trace(fmpz_poly_t trace, const fmpz_poly_mat_t mat) noexcept - # Computes the trace of the matrix, i.e. the sum of the entries on - # the main diagonal. The matrix is required to be square. - void fmpz_poly_mat_det(fmpz_poly_t det, const fmpz_poly_mat_t A) noexcept - # Sets ``det`` to the determinant of the square matrix ``A``. Uses - # a direct formula, fraction-free LU decomposition, or interpolation, - # depending on the size of the matrix. - void fmpz_poly_mat_det_fflu(fmpz_poly_t det, const fmpz_poly_mat_t A) noexcept - # Sets ``det`` to the determinant of the square matrix ``A``. - # The determinant is computed by performing a fraction-free LU - # decomposition on a copy of ``A``. - void fmpz_poly_mat_det_interpolate(fmpz_poly_t det, const fmpz_poly_mat_t A) noexcept - # Sets ``det`` to the determinant of the square matrix ``A``. - # The determinant is computed by determining a bound `n` for its length, - # evaluating the matrix at `n` distinct points, computing the determinant - # of each integer matrix, and forming the interpolating polynomial. - slong fmpz_poly_mat_rank(const fmpz_poly_mat_t A) noexcept - # Returns the rank of ``A``. Performs fraction-free LU decomposition - # on a copy of ``A``. - int fmpz_poly_mat_inv(fmpz_poly_mat_t Ainv, fmpz_poly_t den, const fmpz_poly_mat_t A) noexcept - # Sets (``Ainv``, ``den``) to the inverse matrix of ``A``. - # Returns 1 if ``A`` is nonsingular and 0 if ``A`` is singular. - # Aliasing of ``Ainv`` and ``A`` is allowed. - # More precisely, ``det`` will be set to the determinant of ``A`` - # and ``Ainv`` will be set to the adjugate matrix of ``A``. - # Note that the determinant is not necessarily the minimal denominator. - # Uses fraction-free LU decomposition, followed by solving for - # the identity matrix. - slong fmpz_poly_mat_nullspace(fmpz_poly_mat_t res, const fmpz_poly_mat_t mat) noexcept - # Computes the right rational nullspace of the matrix ``mat`` and - # returns the nullity. - # More precisely, assume that ``mat`` has rank `r` and nullity `n`. - # Then this function sets the first `n` columns of ``res`` - # to linearly independent vectors spanning the nullspace of ``mat``. - # As a result, we always have rank(``res``) `= n`, and - # ``mat`` `\times` ``res`` is the zero matrix. - # The computed basis vectors will not generally be in a reduced form. - # In general, the polynomials in each column vector in the result - # will have a nontrivial common GCD. - int fmpz_poly_mat_solve(fmpz_poly_mat_t X, fmpz_poly_t den, const fmpz_poly_mat_t A, const fmpz_poly_mat_t B) noexcept - # Solves the equation `AX = B` for nonsingular `A`. More precisely, computes - # (``X``, ``den``) such that `AX = B \times \operatorname{den}`. - # Returns 1 if `A` is nonsingular and 0 if `A` is singular. - # The computed denominator will not generally be minimal. - # Uses fraction-free LU decomposition followed by fraction-free - # forward and back substitution. - int fmpz_poly_mat_solve_fflu(fmpz_poly_mat_t X, fmpz_poly_t den, const fmpz_poly_mat_t A, const fmpz_poly_mat_t B) noexcept - # Solves the equation `AX = B` for nonsingular `A`. More precisely, computes - # (``X``, ``den``) such that `AX = B \times \operatorname{den}`. - # Returns 1 if `A` is nonsingular and 0 if `A` is singular. - # The computed denominator will not generally be minimal. - # Uses fraction-free LU decomposition followed by fraction-free - # forward and back substitution. - void fmpz_poly_mat_solve_fflu_precomp(fmpz_poly_mat_t X, const slong * perm, const fmpz_poly_mat_t FFLU, const fmpz_poly_mat_t B) noexcept - # Performs fraction-free forward and back substitution given a precomputed - # fraction-free LU decomposition and corresponding permutation. diff --git a/src/sage/libs/flint/fmpz_poly_q.pxd b/src/sage/libs/flint/fmpz_poly_q.pxd index ee1a23bf5d5..26de673bb6c 100644 --- a/src/sage/libs/flint/fmpz_poly_q.pxd +++ b/src/sage/libs/flint/fmpz_poly_q.pxd @@ -2,7 +2,9 @@ # distutils: depends = flint/fmpz_poly_q.h ################################################################################ -# This file is auto-generated. Do not modify by hand +# This file is auto-generated by the script +# SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py. +# Do not modify by hand! Fix and rerun the script instead. ################################################################################ from libc.stdio cimport FILE @@ -11,139 +13,41 @@ from sage.libs.mpfr.types cimport * from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void fmpz_poly_q_init(fmpz_poly_q_t rop) noexcept - # Initialises ``rop``. - void fmpz_poly_q_clear(fmpz_poly_q_t rop) noexcept - # Clears the object ``rop``. - fmpz_poly_struct * fmpz_poly_q_numref(const fmpz_poly_q_t op) noexcept - # Returns a reference to the numerator of ``op``. - fmpz_poly_struct * fmpz_poly_q_denref(const fmpz_poly_q_t op) noexcept - # Returns a reference to the denominator of ``op``. - void fmpz_poly_q_canonicalise(fmpz_poly_q_t rop) noexcept - # Brings ``rop`` into canonical form, only assuming that - # the denominator is non-zero. - bint fmpz_poly_q_is_canonical(const fmpz_poly_q_t op) noexcept - # Checks whether the rational function ``op`` is in - # canonical form. - void fmpz_poly_q_randtest(fmpz_poly_q_t poly, flint_rand_t state, slong len1, flint_bitcnt_t bits1, slong len2, flint_bitcnt_t bits2) noexcept - # Sets ``poly`` to a random rational function. - void fmpz_poly_q_randtest_not_zero(fmpz_poly_q_t poly, flint_rand_t state, slong len1, flint_bitcnt_t bits1, slong len2, flint_bitcnt_t bits2) noexcept - # Sets ``poly`` to a random non-zero rational function. - void fmpz_poly_q_set(fmpz_poly_q_t rop, const fmpz_poly_q_t op) noexcept - # Sets the element ``rop`` to the same value as the element ``op``. - void fmpz_poly_q_set_si(fmpz_poly_q_t rop, slong op) noexcept - # Sets the element ``rop`` to the value given by the ``slong`` - # ``op``. - void fmpz_poly_q_swap(fmpz_poly_q_t op1, fmpz_poly_q_t op2) noexcept - # Swaps the elements ``op1`` and ``op2``. - # This is done efficiently by swapping pointers. - void fmpz_poly_q_zero(fmpz_poly_q_t rop) noexcept - # Sets ``rop`` to zero. - void fmpz_poly_q_one(fmpz_poly_q_t rop) noexcept - # Sets ``rop`` to one. - void fmpz_poly_q_neg(fmpz_poly_q_t rop, const fmpz_poly_q_t op) noexcept - # Sets the element ``rop`` to the additive inverse of ``op``. - void fmpz_poly_q_inv(fmpz_poly_q_t rop, const fmpz_poly_q_t op) noexcept - # Sets the element ``rop`` to the multiplicative inverse of ``op``. - # Assumes that the element ``op`` is non-zero. - bint fmpz_poly_q_is_zero(const fmpz_poly_q_t op) noexcept - # Returns whether the element ``op`` is zero. - bint fmpz_poly_q_is_one(const fmpz_poly_q_t op) noexcept - # Returns whether the element ``rop`` is equal to the constant - # polynomial `1`. - bint fmpz_poly_q_equal(const fmpz_poly_q_t op1, const fmpz_poly_q_t op2) noexcept - # Returns whether the two elements ``op1`` and ``op2`` are equal. - void fmpz_poly_q_add(fmpz_poly_q_t rop, const fmpz_poly_q_t op1, const fmpz_poly_q_t op2) noexcept - # Sets ``rop`` to the sum of ``op1`` and ``op2``. - void fmpz_poly_q_sub(fmpz_poly_q_t rop, const fmpz_poly_q_t op1, const fmpz_poly_q_t op2) noexcept - # Sets ``rop`` to the difference of ``op1`` and ``op2``. - void fmpz_poly_q_addmul(fmpz_poly_q_t rop, const fmpz_poly_q_t op1, const fmpz_poly_q_t op2) noexcept - # Adds the product of ``op1`` and ``op2`` to ``rop``. - void fmpz_poly_q_submul(fmpz_poly_q_t rop, const fmpz_poly_q_t op1, const fmpz_poly_q_t op2) noexcept - # Subtracts the product of ``op1`` and ``op2`` from ``rop``. - void fmpz_poly_q_scalar_mul_si(fmpz_poly_q_t rop, const fmpz_poly_q_t op, slong x) noexcept - # Sets ``rop`` to the product of the rational function ``op`` - # and the ``slong`` integer `x`. - void fmpz_poly_q_scalar_mul_fmpz(fmpz_poly_q_t rop, const fmpz_poly_q_t op, const fmpz_t x) noexcept - # Sets ``rop`` to the product of the rational function ``op`` - # and the ``fmpz_t`` integer `x`. - void fmpz_poly_q_scalar_mul_fmpq(fmpz_poly_q_t rop, const fmpz_poly_q_t op, const fmpq_t x) noexcept - # Sets ``rop`` to the product of the rational function ``op`` - # and the ``fmpq_t`` rational `x`. - void fmpz_poly_q_scalar_div_si(fmpz_poly_q_t rop, const fmpz_poly_q_t op, slong x) noexcept - # Sets ``rop`` to the quotient of the rational function ``op`` - # and the ``slong`` integer `x`. - void fmpz_poly_q_scalar_div_fmpz(fmpz_poly_q_t rop, const fmpz_poly_q_t op, const fmpz_t x) noexcept - # Sets ``rop`` to the quotient of the rational function ``op`` - # and the ``fmpz_t`` integer `x`. - void fmpz_poly_q_scalar_div_fmpq(fmpz_poly_q_t rop, const fmpz_poly_q_t op, const fmpq_t x) noexcept - # Sets ``rop`` to the quotient of the rational function ``op`` - # and the ``fmpq_t`` rational `x`. - void fmpz_poly_q_mul(fmpz_poly_q_t rop, const fmpz_poly_q_t op1, const fmpz_poly_q_t op2) noexcept - # Sets ``rop`` to the product of ``op1`` and ``op2``. - void fmpz_poly_q_div(fmpz_poly_q_t rop, const fmpz_poly_q_t op1, const fmpz_poly_q_t op2) noexcept - # Sets ``rop`` to the quotient of ``op1`` and ``op2``. - void fmpz_poly_q_pow(fmpz_poly_q_t rop, const fmpz_poly_q_t op, ulong exp) noexcept - # Sets ``rop`` to the ``exp``-th power of ``op``. - # The corner case of ``exp == 0`` is handled by setting ``rop`` to - # the constant function `1`. Note that this includes the case `0^0 = 1`. - void fmpz_poly_q_derivative(fmpz_poly_q_t rop, const fmpz_poly_q_t op) noexcept - # Sets ``rop`` to the derivative of ``op``. - int fmpz_poly_q_evaluate_fmpq(fmpq_t rop, const fmpz_poly_q_t f, const fmpq_t a) noexcept - # Sets ``rop`` to `f` evaluated at the rational `a`. - # If the denominator evaluates to zero at `a`, returns non-zero and - # does not modify any of the variables. Otherwise, returns `0` and - # sets ``rop`` to the rational `f(a)`. - - int fmpz_poly_q_set_str(fmpz_poly_q_t rop, const char *s) noexcept - # Sets ``rop`` to the rational function given - # by the string ``s``. - + int fmpz_poly_q_set_str(fmpz_poly_q_t rop, const char * s) noexcept char * fmpz_poly_q_get_str(const fmpz_poly_q_t op) noexcept - # Returns the string representation of - # the rational function ``op``. - - char * fmpz_poly_q_get_str_pretty(const fmpz_poly_q_t op, const char *x) noexcept - # Returns the pretty string representation of - # the rational function ``op``. - + char * fmpz_poly_q_get_str_pretty(const fmpz_poly_q_t op, const char * x) noexcept int fmpz_poly_q_print(const fmpz_poly_q_t op) noexcept - # Prints the representation of the rational - # function ``op`` to ``stdout``. - - int fmpz_poly_q_print_pretty(const fmpz_poly_q_t op, const char *x) noexcept - # Prints the pretty representation of the rational - # function ``op`` to ``stdout``. + int fmpz_poly_q_print_pretty(const fmpz_poly_q_t op, const char * x) noexcept diff --git a/src/sage/libs/flint/fmpz_vec.pxd b/src/sage/libs/flint/fmpz_vec.pxd index fb75eb2bf27..0418fbc6242 100644 --- a/src/sage/libs/flint/fmpz_vec.pxd +++ b/src/sage/libs/flint/fmpz_vec.pxd @@ -2,7 +2,9 @@ # distutils: depends = flint/fmpz_vec.h ################################################################################ -# This file is auto-generated. Do not modify by hand +# This file is auto-generated by the script +# SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py. +# Do not modify by hand! Fix and rerun the script instead. ################################################################################ from libc.stdio cimport FILE @@ -11,282 +13,66 @@ from sage.libs.mpfr.types cimport * from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - fmpz * _fmpz_vec_init(slong len) noexcept - # Returns an initialised vector of ``fmpz``'s of given length. - void _fmpz_vec_clear(fmpz * vec, slong len) noexcept - # Clears the entries of ``(vec, len)`` and frees the space allocated - # for ``vec``. - void _fmpz_vec_randtest(fmpz * f, flint_rand_t state, slong len, flint_bitcnt_t bits) noexcept - # Sets the entries of a vector of the given length to random integers with - # up to the given number of bits per entry. - void _fmpz_vec_randtest_unsigned(fmpz * f, flint_rand_t state, slong len, flint_bitcnt_t bits) noexcept - # Sets the entries of a vector of the given length to random unsigned - # integers with up to the given number of bits per entry. - slong _fmpz_vec_max_bits(const fmpz * vec, slong len) noexcept - # If `b` is the maximum number of bits of the absolute value of any - # coefficient of ``vec``, then if any coefficient of ``vec`` is - # negative, `-b` is returned, else `b` is returned. - slong _fmpz_vec_max_bits_ref(const fmpz * vec, slong len) noexcept - # If `b` is the maximum number of bits of the absolute value of any - # coefficient of ``vec``, then if any coefficient of ``vec`` is - # negative, `-b` is returned, else `b` is returned. - # This is a slower reference implementation of ``_fmpz_vec_max_bits``. - void _fmpz_vec_sum_max_bits(slong * sumabs, slong * maxabs, const fmpz * vec, slong len) noexcept - # Sets ``sumabs`` to the bit count of the sum of the absolute values of - # the elements of ``vec``. Sets ``maxabs`` to the bit count of the - # maximum of the absolute values of the elements of ``vec``. - mp_size_t _fmpz_vec_max_limbs(const fmpz * vec, slong len) noexcept - # Returns the maximum number of limbs needed to store the absolute value - # of any entry in ``(vec, len)``. If all entries are zero, returns - # zero. - void _fmpz_vec_height(fmpz_t height, const fmpz * vec, slong len) noexcept - # Computes the height of ``(vec, len)``, defined as the largest of the - # absolute values the coefficients. Equivalently, this gives the infinity - # norm of the vector. If ``len`` is zero, the height is `0`. - slong _fmpz_vec_height_index(const fmpz * vec, slong len) noexcept - # Returns the index of an entry of maximum absolute value in the vector. - # The length must be at least 1. - int _fmpz_vec_fread(FILE * file, fmpz ** vec, slong * len) noexcept - # Reads a vector from the stream ``file`` and stores it at - # ``*vec``. The format is the same as the output format of - # ``_fmpz_vec_fprint()``, followed by either any character - # or the end of the file. - # The interpretation of the various input arguments depends on whether - # or not ``*vec`` is ``NULL``: - # If ``*vec == NULL``, the value of ``*len`` on input is ignored. - # Once the length has been read from ``file``, ``*len`` is set - # to that value and a vector of this length is allocated at ``*vec``. - # Finally, ``*len`` coefficients are read from the input stream. In - # case of a file or parsing error, clears the vector and sets ``*vec`` - # and ``*len`` to ``NULL`` and ``0``, respectively. - # Otherwise, if ``*vec != NULL``, it is assumed that ``(*vec, *len)`` - # is a properly initialised vector. If the length on the input stream - # does not match ``*len``, a parsing error is raised. Attempts to read - # the right number of coefficients from the input stream. In case of a - # file or parsing error, leaves the vector ``(*vec, *len)`` in its - # current state. - # In case of success, returns a positive value. In case of failure, - # returns a non-positive value. - int _fmpz_vec_read(fmpz ** vec, slong * len) noexcept - # Reads a vector from ``stdin`` and stores it at ``*vec``. - # For further details, see ``_fmpz_vec_fread()``. - int _fmpz_vec_fprint(FILE * file, const fmpz * vec, slong len) noexcept - # Prints the vector of given length to the stream ``file``. The - # format is the length followed by two spaces, then a space separated - # list of coefficients. If the length is zero, only `0` is printed. - # In case of success, returns a positive value. In case of failure, - # returns a non-positive value. - int _fmpz_vec_print(const fmpz * vec, slong len) noexcept - # Prints the vector of given length to ``stdout``. - # For further details, see ``_fmpz_vec_fprint()``. - void _fmpz_vec_get_nmod_vec(mp_ptr res, const fmpz * poly, slong len, nmod_t mod) noexcept - # Reduce the coefficients of ``(poly, len)`` modulo the given - # modulus and set ``(res, len)`` to the result. - void _fmpz_vec_set_nmod_vec(fmpz * res, mp_srcptr poly, slong len, nmod_t mod) noexcept - # Set the coefficients of ``(res, len)`` to the symmetric modulus - # of the coefficients of ``(poly, len)``, i.e. convert the given - # coefficients modulo the given modulus `n` to their signed integer - # representatives in the range `[-n/2, n/2)`. - void _fmpz_vec_get_fft(mp_limb_t ** coeffs_f, const fmpz * coeffs_m, slong l, slong length) noexcept - # Convert the vector of coeffs ``coeffs_m`` to an fft vector - # ``coeffs_f`` of the given ``length`` with ``l`` limbs per - # coefficient with an additional limb for overflow. - void _fmpz_vec_set_fft(fmpz * coeffs_m, slong length, const mp_ptr * coeffs_f, slong limbs, slong sign) noexcept - # Convert an fft vector ``coeffs_f`` of fully reduced Fermat numbers of the - # given ``length`` to a vector of ``fmpz``'s. Each is assumed to be the given - # number of limbs in length with an additional limb for overflow. If the - # output coefficients are to be signed then set ``sign``, otherwise clear it. - # The resulting ``fmpz``s will be in the range `[-n,n]` in the signed case - # and in the range `[0,2n]` in the unsigned case where - # ``n = 2^(FLINT_BITS*limbs - 1)``. - slong _fmpz_vec_get_d_vec_2exp(double * appv, const fmpz * vec, slong len) noexcept - # Export the array of ``len`` entries starting at the pointer ``vec`` - # to an array of doubles ``appv``, each entry of which is notionally - # multiplied by a single returned exponent to give the original entry. The - # returned exponent is set to be the maximum exponent of all the original - # entries so that all the doubles in ``appv`` have a maximum absolute - # value of 1.0. - void _fmpz_vec_set(fmpz * vec1, const fmpz * vec2, slong len2) noexcept - # Makes a copy of ``(vec2, len2)`` into ``vec1``. - void _fmpz_vec_swap(fmpz * vec1, fmpz * vec2, slong len2) noexcept - # Swaps the integers in ``(vec1, len2)`` and ``(vec2, len2)``. - void _fmpz_vec_zero(fmpz * vec, slong len) noexcept - # Zeros the entries of ``(vec, len)``. - void _fmpz_vec_neg(fmpz * vec1, const fmpz * vec2, slong len2) noexcept - # Negates ``(vec2, len2)`` and places it into ``vec1``. - void _fmpz_vec_scalar_abs(fmpz * vec1, const fmpz * vec2, slong len2) noexcept - # Takes the absolute value of entries in ``(vec2, len2)`` and places the - # result into ``vec1``. - bint _fmpz_vec_equal(const fmpz * vec1, const fmpz * vec2, slong len) noexcept - # Compares two vectors of the given length and returns `1` if they are - # equal, otherwise returns `0`. - bint _fmpz_vec_is_zero(const fmpz * vec, slong len) noexcept - # Returns `1` if ``(vec, len)`` is zero, and `0` otherwise. - void _fmpz_vec_max(fmpz * vec1, const fmpz * vec2, const fmpz * vec3, slong len) noexcept - # Sets ``vec1`` to the pointwise maximum of ``vec2`` and ``vec3``. - void _fmpz_vec_max_inplace(fmpz * vec1, const fmpz * vec2, slong len) noexcept - # Sets ``vec1`` to the pointwise maximum of ``vec1`` and ``vec2``. - void _fmpz_vec_sort(fmpz * vec, slong len) noexcept - # Sorts the coefficients of ``vec`` in ascending order. - void _fmpz_vec_add(fmpz * res, const fmpz * vec1, const fmpz * vec2, slong len2) noexcept - # Sets ``(res, len2)`` to the sum of ``(vec1, len2)`` - # and ``(vec2, len2)``. - void _fmpz_vec_sub(fmpz * res, const fmpz * vec1, const fmpz * vec2, slong len2) noexcept - # Sets ``(res, len2)`` to ``(vec1, len2)`` minus ``(vec2, len2)``. - void _fmpz_vec_scalar_mul_fmpz(fmpz * vec1, const fmpz * vec2, slong len2, const fmpz_t x) noexcept - # Sets ``(vec1, len2)`` to ``(vec2, len2)`` multiplied by `c`, - # where `c` is an ``fmpz_t``. - void _fmpz_vec_scalar_mul_si(fmpz * vec1, const fmpz * vec2, slong len2, slong c) noexcept - # Sets ``(vec1, len2)`` to ``(vec2, len2)`` multiplied by `c`, - # where `c` is a ``slong``. - void _fmpz_vec_scalar_mul_ui(fmpz * vec1, const fmpz * vec2, slong len2, ulong c) noexcept - # Sets ``(vec1, len2)`` to ``(vec2, len2)`` multiplied by `c`, - # where `c` is an ``ulong``. - void _fmpz_vec_scalar_mul_2exp(fmpz * vec1, const fmpz * vec2, slong len2, ulong exp) noexcept - # Sets ``(vec1, len2)`` to ``(vec2, len2)`` multiplied by ``2^exp``. - void _fmpz_vec_scalar_divexact_fmpz(fmpz * vec1, const fmpz * vec2, slong len2, const fmpz_t x) noexcept - # Sets ``(vec1, len2)`` to ``(vec2, len2)`` divided by `x`, where the - # division is assumed to be exact for every entry in ``vec2``. - void _fmpz_vec_scalar_divexact_si(fmpz * vec1, const fmpz * vec2, slong len2, slong c) noexcept - # Sets ``(vec1, len2)`` to ``(vec2, len2)`` divided by `x`, where the - # division is assumed to be exact for every entry in ``vec2``. - void _fmpz_vec_scalar_divexact_ui(fmpz * vec1, const fmpz * vec2, slong len2, ulong c) noexcept - # Sets ``(vec1, len2)`` to ``(vec2, len2)`` divided by `x`, where the - # division is assumed to be exact for every entry in ``vec2``. - void _fmpz_vec_scalar_fdiv_q_fmpz(fmpz * vec1, const fmpz * vec2, slong len2, const fmpz_t c) noexcept - # Sets ``(vec1, len2)`` to ``(vec2, len2)`` divided by `c`, rounding - # down towards minus infinity whenever the division is not exact. - void _fmpz_vec_scalar_fdiv_q_si(fmpz * vec1, const fmpz * vec2, slong len2, slong c) noexcept - # Sets ``(vec1, len2)`` to ``(vec2, len2)`` divided by `c`, rounding - # down towards minus infinity whenever the division is not exact. - void _fmpz_vec_scalar_fdiv_q_ui(fmpz * vec1, const fmpz * vec2, slong len2, ulong c) noexcept - # Sets ``(vec1, len2)`` to ``(vec2, len2)`` divided by `c`, rounding - # down towards minus infinity whenever the division is not exact. - void _fmpz_vec_scalar_fdiv_q_2exp(fmpz * vec1, const fmpz * vec2, slong len2, ulong exp) noexcept - # Sets ``(vec1, len2)`` to ``(vec2, len2)`` divided by ``2^exp``, - # rounding down towards minus infinity whenever the division is not exact. - void _fmpz_vec_scalar_fdiv_r_2exp(fmpz * vec1, const fmpz * vec2, slong len2, ulong exp) noexcept - # Sets ``(vec1, len2)`` to the remainder of ``(vec2, len2)`` - # divided by ``2^exp``, rounding down the quotient towards minus - # infinity whenever the division is not exact. - void _fmpz_vec_scalar_tdiv_q_fmpz(fmpz * vec1, const fmpz * vec2, slong len2, const fmpz_t c) noexcept - # Sets ``(vec1, len2)`` to ``(vec2, len2)`` divided by `c`, rounding - # towards zero whenever the division is not exact. - void _fmpz_vec_scalar_tdiv_q_si(fmpz * vec1, const fmpz * vec2, slong len2, slong c) noexcept - # Sets ``(vec1, len2)`` to ``(vec2, len2)`` divided by `c`, rounding - # towards zero whenever the division is not exact. - void _fmpz_vec_scalar_tdiv_q_ui(fmpz * vec1, const fmpz * vec2, slong len2, ulong c) noexcept - # Sets ``(vec1, len2)`` to ``(vec2, len2)`` divided by `c`, rounding - # towards zero whenever the division is not exact. - void _fmpz_vec_scalar_tdiv_q_2exp(fmpz * vec1, const fmpz * vec2, slong len2, ulong exp) noexcept - # Sets ``(vec1, len2)`` to ``(vec2, len2)`` divided by ``2^exp``, - # rounding down towards zero whenever the division is not exact. - void _fmpz_vec_scalar_addmul_si(fmpz * vec1, const fmpz * vec2, slong len2, slong c) noexcept - void _fmpz_vec_scalar_addmul_ui(fmpz * vec1, const fmpz * vec2, slong len2, ulong c) noexcept - void _fmpz_vec_scalar_addmul_fmpz(fmpz * vec1, const fmpz * vec2, slong len2, const fmpz_t c) noexcept - # Adds ``(vec2, len2)`` times `c` to ``(vec1, len2)``. - void _fmpz_vec_scalar_addmul_si_2exp(fmpz * vec1, const fmpz * vec2, slong len2, slong c, ulong exp) noexcept - # Adds ``(vec2, len2)`` times ``c * 2^exp`` to ``(vec1, len2)``, - # where `c` is a ``slong``. - void _fmpz_vec_scalar_submul_fmpz(fmpz * vec1, const fmpz * vec2, slong len2, const fmpz_t x) noexcept - # Subtracts ``(vec2, len2)`` times `c` from ``(vec1, len2)``, - # where `c` is a ``fmpz_t``. - void _fmpz_vec_scalar_submul_si(fmpz * vec1, const fmpz * vec2, slong len2, slong c) noexcept - # Subtracts ``(vec2, len2)`` times `c` from ``(vec1, len2)``, - # where `c` is a ``slong``. - void _fmpz_vec_scalar_submul_si_2exp(fmpz * vec1, const fmpz * vec2, slong len2, slong c, ulong e) noexcept - # Subtracts ``(vec2, len2)`` times `c \times 2^e` - # from ``(vec1, len2)``, where `c` is a ``slong``. - void _fmpz_vec_sum(fmpz_t res, const fmpz * vec, slong len) noexcept - # Sets ``res`` to the sum of the entries in ``(vec, len)``. - # Aliasing of ``res`` with the entries in ``vec`` is not permitted. - void _fmpz_vec_prod(fmpz_t res, const fmpz * vec, slong len) noexcept - # Sets ``res`` to the product of the entries in ``(vec, len)``. - # Aliasing of ``res`` with the entries in ``vec`` is not permitted. - # Uses binary splitting. - - void _fmpz_vec_scalar_mod_fmpz(fmpz *res, const fmpz *vec, slong len, const fmpz_t p) noexcept - # Reduces all entries in ``(vec, len)`` modulo `p > 0`. - - void _fmpz_vec_scalar_smod_fmpz(fmpz *res, const fmpz *vec, slong len, const fmpz_t p) noexcept - # Reduces all entries in ``(vec, len)`` modulo `p > 0`, choosing - # the unique representative in `(-p/2, p/2]`. - + void _fmpz_vec_scalar_mod_fmpz(fmpz * res, const fmpz * vec, slong len, const fmpz_t p) noexcept + void _fmpz_vec_scalar_smod_fmpz(fmpz * res, const fmpz * vec, slong len, const fmpz_t p) noexcept void _fmpz_vec_content(fmpz_t res, const fmpz * vec, slong len) noexcept - # Sets ``res`` to the non-negative content of the entries in ``vec``. - # The content of a zero vector, including the case when the length is zero, - # is defined to be zero. - void _fmpz_vec_content_chained(fmpz_t res, const fmpz * vec, slong len, const fmpz_t input) noexcept - # Sets ``res`` to the non-negative content of ``input`` and the entries in ``vec``. - # This is useful for calculating the common content of several vectors. - void _fmpz_vec_lcm(fmpz_t res, const fmpz * vec, slong len) noexcept - # Sets ``res`` to the nonnegative least common multiple of the entries - # in ``vec``. The least common multiple is zero if any entry in - # the vector is zero. The least common multiple of a length zero vector is - # defined to be one. - void _fmpz_vec_dot(fmpz_t res, const fmpz * vec1, const fmpz * vec2, slong len2) noexcept - # Sets ``res`` to the dot product of ``(vec1, len2)`` and - # ``(vec2, len2)``. - void _fmpz_vec_dot_ptr(fmpz_t res, const fmpz * vec1, fmpz ** const vec2, slong offset, slong len) noexcept - # Sets ``res`` to the dot product of ``len`` values at ``vec1`` and the - # ``len`` values ``vec2[i] + offset`` for `0 \leq i < len`. diff --git a/src/sage/libs/flint/fmpzi.pxd b/src/sage/libs/flint/fmpzi.pxd index 8020b2408a3..885615314a5 100644 --- a/src/sage/libs/flint/fmpzi.pxd +++ b/src/sage/libs/flint/fmpzi.pxd @@ -2,7 +2,9 @@ # distutils: depends = flint/fmpzi.h ################################################################################ -# This file is auto-generated. Do not modify by hand +# This file is auto-generated by the script +# SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py. +# Do not modify by hand! Fix and rerun the script instead. ################################################################################ from libc.stdio cimport FILE @@ -11,84 +13,38 @@ from sage.libs.mpfr.types cimport * from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void fmpzi_init(fmpzi_t x) noexcept - void fmpzi_clear(fmpzi_t x) noexcept - void fmpzi_swap(fmpzi_t x, fmpzi_t y) noexcept - void fmpzi_zero(fmpzi_t x) noexcept - void fmpzi_one(fmpzi_t x) noexcept - void fmpzi_set(fmpzi_t res, const fmpzi_t x) noexcept - void fmpzi_set_si_si(fmpzi_t res, slong a, slong b) noexcept - void fmpzi_print(const fmpzi_t x) noexcept - void fmpzi_randtest(fmpzi_t res, flint_rand_t state, mp_bitcnt_t bits) noexcept - bint fmpzi_equal(const fmpzi_t x, const fmpzi_t y) noexcept - bint fmpzi_is_zero(const fmpzi_t x) noexcept - bint fmpzi_is_one(const fmpzi_t x) noexcept - bint fmpzi_is_unit(const fmpzi_t x) noexcept - slong fmpzi_canonical_unit_i_pow(const fmpzi_t x) noexcept - void fmpzi_canonicalise_unit(fmpzi_t res, const fmpzi_t x) noexcept - slong fmpzi_bits(const fmpzi_t x) noexcept - void fmpzi_norm(fmpz_t res, const fmpzi_t x) noexcept - void fmpzi_conj(fmpzi_t res, const fmpzi_t x) noexcept - void fmpzi_neg(fmpzi_t res, const fmpzi_t x) noexcept - void fmpzi_add(fmpzi_t res, const fmpzi_t x, const fmpzi_t y) noexcept - void fmpzi_sub(fmpzi_t res, const fmpzi_t x, const fmpzi_t y) noexcept - void fmpzi_sqr(fmpzi_t res, const fmpzi_t x) noexcept - void fmpzi_mul(fmpzi_t res, const fmpzi_t x, const fmpzi_t y) noexcept - void fmpzi_pow_ui(fmpzi_t res, const fmpzi_t x, ulong exp) noexcept - void fmpzi_divexact(fmpzi_t q, const fmpzi_t x, const fmpzi_t y) noexcept - # Sets *q* to the quotient of *x* and *y*, assuming that the - # division is exact. - void fmpzi_divrem(fmpzi_t q, fmpzi_t r, const fmpzi_t x, const fmpzi_t y) noexcept - # Computes a quotient and remainder satisfying - # `x = q y + r` with `N(r) \le N(y)/2`, with a canonical - # choice of remainder when breaking ties. - void fmpzi_divrem_approx(fmpzi_t q, fmpzi_t r, const fmpzi_t x, const fmpzi_t y) noexcept - # Computes a quotient and remainder satisfying - # `x = q y + r` with `N(r) < N(y)`, with an implementation-defined, - # non-canonical choice of remainder. - slong fmpzi_remove_one_plus_i(fmpzi_t res, const fmpzi_t x) noexcept - # Divide *x* exactly by the largest possible power `(1+i)^k` - # and return the exponent *k*. - void fmpzi_gcd_euclidean(fmpzi_t res, const fmpzi_t x, const fmpzi_t y) noexcept void fmpzi_gcd_euclidean_improved(fmpzi_t res, const fmpzi_t x, const fmpzi_t y) noexcept void fmpzi_gcd_binary(fmpzi_t res, const fmpzi_t x, const fmpzi_t y) noexcept void fmpzi_gcd_shortest(fmpzi_t res, const fmpzi_t x, const fmpzi_t y) noexcept void fmpzi_gcd(fmpzi_t res, const fmpzi_t x, const fmpzi_t y) noexcept - # Computes the GCD of *x* and *y*. The result is in canonical - # unit form. - # The *euclidean* version is a straightforward implementation - # of Euclid's algorithm. The *euclidean_improved* version is - # optimized by performing approximate divisions. - # The *binary* version uses a (1+i)-ary analog of the binary - # GCD algorithm for integers [Wei2000]_. - # The *shortest* version finds the GCD as the shortest vector in a lattice. - # The default version chooses an algorithm automatically. + bint fmpzi_is_prime(const fmpzi_t n) noexcept + bint fmpzi_is_probabprime(const fmpzi_t n) noexcept diff --git a/src/sage/libs/flint/fq.pxd b/src/sage/libs/flint/fq.pxd index 0d893d4565b..01c8f5887a2 100644 --- a/src/sage/libs/flint/fq.pxd +++ b/src/sage/libs/flint/fq.pxd @@ -2,7 +2,9 @@ # distutils: depends = flint/fq.h ################################################################################ -# This file is auto-generated. Do not modify by hand +# This file is auto-generated by the script +# SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py. +# Do not modify by hand! Fix and rerun the script instead. ################################################################################ from libc.stdio cimport FILE @@ -11,353 +13,83 @@ from sage.libs.mpfr.types cimport * from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - - void fq_ctx_init(fq_ctx_t ctx, const fmpz_t p, slong d, const char *var) noexcept - # Initialises the context for prime `p` and extension degree `d`, - # with name ``var`` for the generator. By default, it will try - # use a Conway polynomial; if one is not available, a random - # irreducible polynomial will be used. - # Assumes that `p` is a prime. - # Assumes that the string ``var`` is a null-terminated string - # of length at least one. - - int _fq_ctx_init_conway(fq_ctx_t ctx, const fmpz_t p, slong d, const char *var) noexcept - # Attempts to initialise the context for prime `p` and extension - # degree `d`, with name ``var`` for the generator using a Conway - # polynomial for the modulus. - # Returns `1` if the Conway polynomial is in the database for the - # given size and the initialization is successful; otherwise, - # returns `0`. - # Assumes that `p` is a prime. - # Assumes that the string ``var`` is a null-terminated string - # of length at least one. - - void fq_ctx_init_conway(fq_ctx_t ctx, const fmpz_t p, slong d, const char *var) noexcept - # Initialises the context for prime `p` and extension degree `d`, - # with name ``var`` for the generator using a Conway polynomial - # for the modulus. - # Assumes that `p` is a prime. - # Assumes that the string ``var`` is a null-terminated string - # of length at least one. - - void fq_ctx_init_modulus(fq_ctx_t ctx, const fmpz_mod_poly_t modulus, const fmpz_mod_ctx_t ctxp, const char *var) noexcept - # Initialises the context for given ``modulus`` with name - # ``var`` for the generator. - # Assumes that ``modulus`` is an irreducible polynomial over the finite field `\mathbf{F}_{p}` in ``ctxp``. - # Assumes that the string ``var`` is a null-terminated string - # of length at least one. - + void fq_ctx_init(fq_ctx_t ctx, const fmpz_t p, slong d, const char * var) noexcept + int _fq_ctx_init_conway(fq_ctx_t ctx, const fmpz_t p, slong d, const char * var) noexcept + void fq_ctx_init_conway(fq_ctx_t ctx, const fmpz_t p, slong d, const char * var) noexcept + void fq_ctx_init_modulus(fq_ctx_t ctx, const fmpz_mod_poly_t modulus, const fmpz_mod_ctx_t ctxp, const char * var) noexcept void fq_ctx_clear(fq_ctx_t ctx) noexcept - # Clears all memory that has been allocated as part of the context. - const fmpz_mod_poly_struct* fq_ctx_modulus(const fq_ctx_t ctx) noexcept - # Returns a pointer to the modulus in the context. - slong fq_ctx_degree(const fq_ctx_t ctx) noexcept - # Returns the degree of the field extension - # `[\mathbf{F}_{q} : \mathbf{F}_{p}]`, which - # is equal to `\log_{p} q`. - const fmpz * fq_ctx_prime(const fq_ctx_t ctx) noexcept - # Returns a pointer to the prime `p` in the context. - void fq_ctx_order(fmpz_t f, const fq_ctx_t ctx) noexcept - # Sets `f` to be the size of the finite field. - int fq_ctx_fprint(FILE * file, const fq_ctx_t ctx) noexcept - # Prints the context information to ``file``. Returns 1 for a - # success and a negative number for an error. - void fq_ctx_print(const fq_ctx_t ctx) noexcept - # Prints the context information to ``stdout``. - void fq_ctx_randtest(fq_ctx_t ctx, flint_rand_t state) noexcept - # Initializes ``ctx`` to a random finite field. Assumes that - # ``fq_ctx_init`` has not been called on ``ctx`` already. - void fq_ctx_randtest_reducible(fq_ctx_t ctx, flint_rand_t state) noexcept - # Initializes ``ctx`` to a random extension of a prime field. - # The modulus may or may not be irreducible. Assumes that - # ``fq_ctx_init`` has not been called on ``ctx`` already. - void fq_init(fq_t rop, const fq_ctx_t ctx) noexcept - # Initialises the element ``rop``, setting its value to `0`. - void fq_init2(fq_t rop, const fq_ctx_t ctx) noexcept - # Initialises ``poly`` with at least enough space for it to be an element - # of ``ctx`` and sets it to `0`. - void fq_clear(fq_t rop, const fq_ctx_t ctx) noexcept - # Clears the element ``rop``. - - void _fq_sparse_reduce(fmpz *R, slong lenR, const fq_ctx_t ctx) noexcept - # Reduces ``(R, lenR)`` modulo the polynomial `f` given by the - # modulus of ``ctx``. - - void _fq_dense_reduce(fmpz *R, slong lenR, const fq_ctx_t ctx) noexcept - # Reduces ``(R, lenR)`` modulo the polynomial `f` given by the - # modulus of ``ctx`` using Newton division. - - void _fq_reduce(fmpz *r, slong lenR, const fq_ctx_t ctx) noexcept - # Reduces ``(R, lenR)`` modulo the polynomial `f` given by the - # modulus of ``ctx``. Does either sparse or dense reduction - # based on ``ctx->sparse_modulus``. - + void _fq_sparse_reduce(fmpz * R, slong lenR, const fq_ctx_t ctx) noexcept + void _fq_dense_reduce(fmpz * R, slong lenR, const fq_ctx_t ctx) noexcept + void _fq_reduce(fmpz * r, slong lenR, const fq_ctx_t ctx) noexcept void fq_reduce(fq_t rop, const fq_ctx_t ctx) noexcept - # Reduces the polynomial ``rop`` as an element of - # `\mathbf{F}_p[X] / (f(X))`. - void fq_add(fq_t rop, const fq_t op1, const fq_t op2, const fq_ctx_t ctx) noexcept - # Sets ``rop`` to the sum of ``op1`` and ``op2``. - void fq_sub(fq_t rop, const fq_t op1, const fq_t op2, const fq_ctx_t ctx) noexcept - # Sets ``rop`` to the difference of ``op1`` and ``op2``. - void fq_sub_one(fq_t rop, const fq_t op1, const fq_ctx_t ctx) noexcept - # Sets ``rop`` to the difference of ``op1`` and `1`. - void fq_neg(fq_t rop, const fq_t op, const fq_ctx_t ctx) noexcept - # Sets ``rop`` to the negative of ``op``. - void fq_mul(fq_t rop, const fq_t op1, const fq_t op2, const fq_ctx_t ctx) noexcept - # Sets ``rop`` to the product of ``op1`` and ``op2``, - # reducing the output in the given context. - void fq_mul_fmpz(fq_t rop, const fq_t op, const fmpz_t x, const fq_ctx_t ctx) noexcept - # Sets ``rop`` to the product of ``op`` and `x`, - # reducing the output in the given context. - void fq_mul_si(fq_t rop, const fq_t op, slong x, const fq_ctx_t ctx) noexcept - # Sets ``rop`` to the product of ``op`` and `x`, - # reducing the output in the given context. - void fq_mul_ui(fq_t rop, const fq_t op, ulong x, const fq_ctx_t ctx) noexcept - # Sets ``rop`` to the product of ``op`` and `x`, - # reducing the output in the given context. - void fq_sqr(fq_t rop, const fq_t op, const fq_ctx_t ctx) noexcept - # Sets ``rop`` to the square of ``op``, - # reducing the output in the given context. - void fq_div(fq_t rop, const fq_t op1, const fq_t op2, const fq_ctx_t ctx) noexcept - # Sets ``rop`` to the quotient of ``op1`` and ``op2``, - # reducing the output in the given context. - - void _fq_inv(fmpz *rop, const fmpz *op, slong len, const fq_ctx_t ctx) noexcept - # Sets ``(rop, d)`` to the inverse of the non-zero element - # ``(op, len)``. - + void _fq_inv(fmpz * rop, const fmpz * op, slong len, const fq_ctx_t ctx) noexcept void fq_inv(fq_t rop, const fq_t op, const fq_ctx_t ctx) noexcept - # Sets ``rop`` to the inverse of the non-zero element ``op``. - void fq_gcdinv(fq_t f, fq_t inv, const fq_t op, const fq_ctx_t ctx) noexcept - # Sets ``inv`` to be the inverse of ``op`` modulo the modulus - # of ``ctx``. If ``op`` is not invertible, then ``f`` is - # set to a factor of the modulus; otherwise, it is set to one. - - void _fq_pow(fmpz *rop, const fmpz *op, slong len, const fmpz_t e, const fq_ctx_t ctx) noexcept - # Sets ``(rop, 2*d-1)`` to ``(op,len)`` raised to the power `e`, - # reduced modulo `f(X)`, the modulus of ``ctx``. - # Assumes that `e \geq 0` and that ``len`` is positive and at most `d`. - # Although we require that ``rop`` provides space for - # `2d - 1` coefficients, the output will be reduced modulo - # `f(X)`, which is a polynomial of degree `d`. - # Does not support aliasing. - + void _fq_pow(fmpz * rop, const fmpz * op, slong len, const fmpz_t e, const fq_ctx_t ctx) noexcept void fq_pow(fq_t rop, const fq_t op, const fmpz_t e, const fq_ctx_t ctx) noexcept - # Sets ``rop`` the ``op`` raised to the power `e`. - # Currently assumes that `e \geq 0`. - # Note that for any input ``op``, ``rop`` is set to `1` - # whenever `e = 0`. - void fq_pow_ui(fq_t rop, const fq_t op, const ulong e, const fq_ctx_t ctx) noexcept - # Sets ``rop`` the ``op`` raised to the power `e`. - # Currently assumes that `e \geq 0`. - # Note that for any input ``op``, ``rop`` is set to `1` - # whenever `e = 0`. - int fq_sqrt(fq_t rop, const fq_t op1, const fq_ctx_t ctx) noexcept - # Sets ``rop`` to the square root of ``op1`` if it is a square, and return - # `1`, otherwise return `0`. - void fq_pth_root(fq_t rop, const fq_t op1, const fq_ctx_t ctx) noexcept - # Sets ``rop`` to a `p^{th}` root root of ``op1``. Currently, - # this computes the root by raising ``op1`` to `p^{d-1}` where - # `d` is the degree of the extension. - bint fq_is_square(const fq_t op, const fq_ctx_t ctx) noexcept - # Return ``1`` if ``op`` is a square. - - int fq_fprint_pretty(FILE *file, const fq_t op, const fq_ctx_t ctx) noexcept - # Prints a pretty representation of ``op`` to ``file``. - # In the current implementation, always returns `1`. The return code is - # part of the function's signature to allow for a later implementation to - # return the number of characters printed or a non-positive error code. - + int fq_fprint_pretty(FILE * file, const fq_t op, const fq_ctx_t ctx) noexcept int fq_print_pretty(const fq_t op, const fq_ctx_t ctx) noexcept - # Prints a pretty representation of ``op`` to ``stdout``. - # In the current implementation, always returns `1`. The return code is - # part of the function's signature to allow for a later implementation to - # return the number of characters printed or a non-positive error code. - int fq_fprint(FILE * file, const fq_t op, const fq_ctx_t ctx) noexcept - # Prints a representation of ``op`` to ``file``. - # For further details on the representation used, see - # :func:`fmpz_mod_poly_fprint`. - void fq_print(const fq_t op, const fq_ctx_t ctx) noexcept - # Prints a representation of ``op`` to ``stdout``. - # For further details on the representation used, see - # :func:`fmpz_mod_poly_print`. - char * fq_get_str(const fq_t op, const fq_ctx_t ctx) noexcept - # Returns the plain FLINT string representation of the element - # ``op``. - char * fq_get_str_pretty(const fq_t op, const fq_ctx_t ctx) noexcept - # Returns a pretty representation of the element ``op`` using the - # null-terminated string ``x`` as the variable name. - void fq_randtest(fq_t rop, flint_rand_t state, const fq_ctx_t ctx) noexcept - # Generates a random element of `\mathbf{F}_q`. - void fq_randtest_not_zero(fq_t rop, flint_rand_t state, const fq_ctx_t ctx) noexcept - # Generates a random non-zero element of `\mathbf{F}_q`. - void fq_randtest_dense(fq_t rop, flint_rand_t state, const fq_ctx_t ctx) noexcept - # Generates a random element of `\mathbf{F}_q` which has an - # underlying polynomial with dense coefficients. - void fq_rand(fq_t rop, flint_rand_t state, const fq_ctx_t ctx) noexcept - # Generates a high quality random element of `\mathbf{F}_q`. - void fq_rand_not_zero(fq_t rop, flint_rand_t state, const fq_ctx_t ctx) noexcept - # Generates a high quality non-zero random element of `\mathbf{F}_q`. - void fq_set(fq_t rop, const fq_t op, const fq_ctx_t ctx) noexcept - # Sets ``rop`` to ``op``. - void fq_set_si(fq_t rop, const slong x, const fq_ctx_t ctx) noexcept - # Sets ``rop`` to ``x``, considered as an element of - # `\mathbf{F}_p`. - void fq_set_ui(fq_t rop, const ulong x, const fq_ctx_t ctx) noexcept - # Sets ``rop`` to ``x``, considered as an element of - # `\mathbf{F}_p`. - void fq_set_fmpz(fq_t rop, const fmpz_t x, const fq_ctx_t ctx) noexcept - # Sets ``rop`` to ``x``, considered as an element of - # `\mathbf{F}_p`. - void fq_swap(fq_t op1, fq_t op2, const fq_ctx_t ctx) noexcept - # Swaps the two elements ``op1`` and ``op2``. - void fq_zero(fq_t rop, const fq_ctx_t ctx) noexcept - # Sets ``rop`` to zero. - void fq_one(fq_t rop, const fq_ctx_t ctx) noexcept - # Sets ``rop`` to one, reduced in the given context. - void fq_gen(fq_t rop, const fq_ctx_t ctx) noexcept - # Sets ``rop`` to a generator for the finite field. - # There is no guarantee this is a multiplicative generator of - # the finite field. - int fq_get_fmpz(fmpz_t rop, const fq_t op, const fq_ctx_t ctx) noexcept - # If ``op`` has a lift to the integers, return `1` and set ``rop`` to the lift in `[0,p)`. - # Otherwise, return `0` and leave `rop` undefined. - void fq_get_fmpz_poly(fmpz_poly_t a, const fq_t b, const fq_ctx_t ctx) noexcept - void fq_get_fmpz_mod_poly(fmpz_mod_poly_t a, const fq_t b, const fq_ctx_t ctx) noexcept - # Set ``a`` to a representative of ``b`` in ``ctx``. - # The representatives are taken in `(\mathbb{Z}/p\mathbb{Z})[x]/h(x)` where `h(x)` is the defining polynomial in ``ctx``. - void fq_set_fmpz_poly(fq_t a, const fmpz_poly_t b, const fq_ctx_t ctx) noexcept - void fq_set_fmpz_mod_poly(fq_t a, const fmpz_mod_poly_t b, const fq_ctx_t ctx) noexcept - # Set ``a`` to the element in ``ctx`` with representative ``b``. - # The representatives are taken in `(\mathbb{Z}/p\mathbb{Z})[x]/h(x)` where `h(x)` is the defining polynomial in ``ctx``. - void fq_get_fmpz_mod_mat(fmpz_mod_mat_t col, const fq_t a, const fq_ctx_t ctx) noexcept - # Convert ``a`` to a column vector of length ``degree(ctx)``. - void fq_set_fmpz_mod_mat(fq_t a, const fmpz_mod_mat_t col, const fq_ctx_t ctx) noexcept - # Convert a column vector ``col`` of length ``degree(ctx)`` to an element of ``ctx``. - bint fq_is_zero(const fq_t op, const fq_ctx_t ctx) noexcept - # Returns whether ``op`` is equal to zero. - bint fq_is_one(const fq_t op, const fq_ctx_t ctx) noexcept - # Returns whether ``op`` is equal to one. - bint fq_equal(const fq_t op1, const fq_t op2, const fq_ctx_t ctx) noexcept - # Returns whether ``op1`` and ``op2`` are equal. - bint fq_is_invertible(const fq_t op, const fq_ctx_t ctx) noexcept - # Returns whether ``op`` is an invertible element. - bint fq_is_invertible_f(fq_t f, const fq_t op, const fq_ctx_t ctx) noexcept - # Returns whether ``op`` is an invertible element. If it is not, - # then ``f`` is set of a factor of the modulus. - - void _fq_trace(fmpz_t rop, const fmpz *op, slong len, const fq_ctx_t ctx) noexcept - # Sets ``rop`` to the trace of the non-zero element ``(op, len)`` - # in `\mathbf{F}_{q}`. - + void _fq_trace(fmpz_t rop, const fmpz * op, slong len, const fq_ctx_t ctx) noexcept void fq_trace(fmpz_t rop, const fq_t op, const fq_ctx_t ctx) noexcept - # Sets ``rop`` to the trace of ``op``. - # For an element `a \in \mathbf{F}_q`, multiplication by `a` defines - # a `\mathbf{F}_p`-linear map on `\mathbf{F}_q`. We define the - # trace of `a` as the trace of this map. Equivalently, if `\Sigma` - # generates `\operatorname{Gal}(\mathbf{F}_q / \mathbf{F}_p)` then the trace of - # `a` is equal to `\sum_{i=0}^{d-1} \Sigma^i (a)`, where `d = - # \log_{p} q`. - - void _fq_norm(fmpz_t rop, const fmpz *op, slong len, const fq_ctx_t ctx) noexcept - # Sets ``rop`` to the norm of the non-zero element ``(op, len)`` - # in `\mathbf{F}_{q}`. - + void _fq_norm(fmpz_t rop, const fmpz * op, slong len, const fq_ctx_t ctx) noexcept void fq_norm(fmpz_t rop, const fq_t op, const fq_ctx_t ctx) noexcept - # Computes the norm of ``op``. - # For an element `a \in \mathbf{F}_q`, multiplication by `a` defines - # a `\mathbf{F}_p`-linear map on `\mathbf{F}_q`. We define the norm - # of `a` as the determinant of this map. Equivalently, if `\Sigma` generates - # `\operatorname{Gal}(\mathbf{F}_q / \mathbf{F}_p)` then the trace of `a` is equal to - # `\prod_{i=0}^{d-1} \Sigma^i (a)`, where - # `d = \text{dim}_{\mathbf{F}_p}(\mathbf{F}_q)`. - # Algorithm selection is automatic depending on the input. - - void _fq_frobenius(fmpz *rop, const fmpz *op, slong len, slong e, const fq_ctx_t ctx) noexcept - # Sets ``(rop, 2d-1)`` to the image of ``(op, len)`` under the - # Frobenius operator raised to the e-th power, assuming that neither - # ``op`` nor ``e`` are zero. - + void _fq_frobenius(fmpz * rop, const fmpz * op, slong len, slong e, const fq_ctx_t ctx) noexcept void fq_frobenius(fq_t rop, const fq_t op, slong e, const fq_ctx_t ctx) noexcept - # Evaluates the homomorphism `\Sigma^e` at ``op``. - # Recall that `\mathbf{F}_q / \mathbf{F}_p` is Galois with Galois group - # `\langle \sigma \rangle`, which is also isomorphic to - # `\mathbf{Z}/d\mathbf{Z}`, where - # `\sigma \in \operatorname{Gal}(\mathbf{F}_q/\mathbf{F}_p)` is the Frobenius element - # `\sigma \colon x \mapsto x^p`. - int fq_multiplicative_order(fmpz * ord, const fq_t op, const fq_ctx_t ctx) noexcept - # Computes the order of ``op`` as an element of the - # multiplicative group of ``ctx``. - # Returns 0 if ``op`` is 0, otherwise it returns 1 if ``op`` - # is a generator of the multiplicative group, and -1 if it is not. - # This function can also be used to check primitivity of a generator of - # a finite field whose defining polynomial is not primitive. - bint fq_is_primitive(const fq_t op, const fq_ctx_t ctx) noexcept - # Returns whether ``op`` is primitive, i.e., whether it is a - # generator of the multiplicative group of ``ctx``. - void fq_bit_pack(fmpz_t f, const fq_t op, flint_bitcnt_t bit_size, const fq_ctx_t ctx) noexcept - # Packs ``op`` into bitfields of size ``bit_size``, writing the - # result to ``f``. - void fq_bit_unpack(fq_t rop, const fmpz_t f, flint_bitcnt_t bit_size, const fq_ctx_t ctx) noexcept - # Unpacks into ``rop`` the element with coefficients packed into - # fields of size ``bit_size`` as represented by the integer - # ``f``. diff --git a/src/sage/libs/flint/fq_default.pxd b/src/sage/libs/flint/fq_default.pxd index f24158f21d3..3d622002a0e 100644 --- a/src/sage/libs/flint/fq_default.pxd +++ b/src/sage/libs/flint/fq_default.pxd @@ -2,7 +2,9 @@ # distutils: depends = flint/fq_default.h ################################################################################ -# This file is auto-generated. Do not modify by hand +# This file is auto-generated by the script +# SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py. +# Do not modify by hand! Fix and rerun the script instead. ################################################################################ from libc.stdio cimport FILE @@ -11,295 +13,70 @@ from sage.libs.mpfr.types cimport * from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void fq_default_ctx_init(fq_default_ctx_t ctx, const fmpz_t p, slong d, const char * var) noexcept - # Initialises the context for prime `p` and extension degree `d`, - # with name ``var`` for the generator. By default, it will try - # use a Conway polynomial; if one is not available, a random - # irreducible polynomial will be used. - # Assumes that `p` is a prime. - # Assumes that the string ``var`` is a null-terminated string - # of length at least one. - void fq_default_ctx_init_type(fq_default_ctx_t ctx, const fmpz_t p, slong d, const char * var, int type) noexcept - # As per the previous function except that if ``type == 1`` an ``fq_zech`` - # context is created, if ``type == 2`` an ``fq_nmod`` and if ``type == 3`` - # an ``fq``. If ``type == 0`` the functionality is as per the previous - # function. - void fq_default_ctx_init_modulus(fq_default_ctx_t ctx, const fmpz_mod_poly_t modulus, fmpz_mod_ctx_t mod_ctx, const char * var) noexcept - # Initialises the context for the finite field defined by the given - # polynomial ``modulus``. The characteristic will be the modulus of - # the polynomial and the degree equal to its degree. - # Assumes that the characteristic is prime and the polynomial irreducible. - # Assumes that the string ``var`` is a null-terminated string - # of length at least one. - void fq_default_ctx_init_modulus_type(fq_default_ctx_t ctx, const fmpz_mod_poly_t modulus, fmpz_mod_ctx_t mod_ctx, const char * var, int type) noexcept - # As per the previous function except that if ``type == 1`` an ``fq_zech`` - # context is created, if ``type == 2`` an ``fq_nmod`` and if ``type == 3`` - # an ``fq``. If ``type == 0`` the functionality is as per the previous - # function. - void fq_default_ctx_init_modulus_nmod(fq_default_ctx_t ctx, const nmod_poly_t modulus, const char * var) noexcept - # Initialises the context for the finite field defined by the given - # polynomial ``modulus``. The characteristic will be the modulus of - # the polynomial and the degree equal to its degree. - # Assumes that the characteristic is prime and the polynomial irreducible. - # Assumes that the string ``var`` is a null-terminated string - # of length at least one. - void fq_default_ctx_init_modulus_nmod_type(fq_default_ctx_t ctx, const nmod_poly_t modulus, const char * var, int type) noexcept - # As per the previous function except that if ``type == 1`` an ``fq_zech`` - # context is created, if ``type == 2`` an ``fq_nmod`` and if ``type == 3`` - # an ``fq``. If ``type == 0`` the functionality is as per the previous - # function. - void fq_default_ctx_clear(fq_default_ctx_t ctx) noexcept - # Clears all memory that has been allocated as part of the context. - int fq_default_ctx_type(const fq_default_ctx_t ctx) noexcept - # Returns `1` if the context contains an ``fq_zech`` context, `2` if it - # contains an ``fq_mod`` context and `3` if it contains an ``fq`` context. - slong fq_default_ctx_degree(const fq_default_ctx_t ctx) noexcept - # Returns the degree of the field extension - # `[\mathbf{F}_{q} : \mathbf{F}_{p}]`, which - # is equal to `\log_{p} q`. - void fq_default_ctx_prime(fmpz_t prime, const fq_default_ctx_t ctx) noexcept - # Sets `prime` to the prime `p` in the context. - void fq_default_ctx_order(fmpz_t f, const fq_default_ctx_t ctx) noexcept - # Sets `f` to be the size of the finite field. - void fq_default_ctx_modulus(fmpz_mod_poly_t p, const fq_default_ctx_t ctx) noexcept - # Sets `p` to the defining polynomial of the finite field.. - int fq_default_ctx_fprint(FILE * file, const fq_default_ctx_t ctx) noexcept - # Prints the context information to ``file``. Returns 1 for a - # success and a negative number for an error. - void fq_default_ctx_print(const fq_default_ctx_t ctx) noexcept - # Prints the context information to ``stdout``. - void fq_default_ctx_randtest(fq_default_ctx_t ctx) noexcept - # Initializes ``ctx`` to a random finite field. Assumes that - # ``fq_default_ctx_init`` has not been called on ``ctx`` already. - void fq_default_get_coeff_fmpz(fmpz_t c, fq_default_t op, slong n, const fq_default_ctx_t ctx) noexcept - # Set `c` to the degree `n` coefficient of the polynomial representation of - # the finite field element ``op``. - void fq_default_init(fq_default_t rop, const fq_default_ctx_t ctx) noexcept - # Initialises the element ``rop``, setting its value to `0`. - void fq_default_init2(fq_default_t rop, const fq_default_ctx_t ctx) noexcept - # Initialises ``poly`` with at least enough space for it to be an element - # of ``ctx`` and sets it to `0`. - void fq_default_clear(fq_default_t rop, const fq_default_ctx_t ctx) noexcept - # Clears the element ``rop``. - bint fq_default_is_invertible(const fq_default_t op, const fq_default_ctx_t ctx) noexcept - # Return ``1`` if ``op`` is an invertible element. - void fq_default_add(fq_default_t rop, const fq_default_t op1, const fq_default_t op2, const fq_default_ctx_t ctx) noexcept - # Sets ``rop`` to the sum of ``op1`` and ``op2``. - void fq_default_sub(fq_default_t rop, const fq_default_t op1, const fq_default_t op2, const fq_default_ctx_t ctx) noexcept - # Sets ``rop`` to the difference of ``op1`` and ``op2``. - void fq_default_sub_one(fq_default_t rop, const fq_default_t op1, const fq_default_ctx_t ctx) noexcept - # Sets ``rop`` to the difference of ``op1`` and `1`. - void fq_default_neg(fq_default_t rop, const fq_default_t op, const fq_default_ctx_t ctx) noexcept - # Sets ``rop`` to the negative of ``op``. - void fq_default_mul(fq_default_t rop, const fq_default_t op1, const fq_default_t op2, const fq_default_ctx_t ctx) noexcept - # Sets ``rop`` to the product of ``op1`` and ``op2``, - # reducing the output in the given context. - void fq_default_mul_fmpz(fq_default_t rop, const fq_default_t op, const fmpz_t x, const fq_default_ctx_t ctx) noexcept - # Sets ``rop`` to the product of ``op`` and `x`, - # reducing the output in the given context. - void fq_default_mul_si(fq_default_t rop, const fq_default_t op, slong x, const fq_default_ctx_t ctx) noexcept - # Sets ``rop`` to the product of ``op`` and `x`, - # reducing the output in the given context. - void fq_default_mul_ui(fq_default_t rop, const fq_default_t op, ulong x, const fq_default_ctx_t ctx) noexcept - # Sets ``rop`` to the product of ``op`` and `x`, - # reducing the output in the given context. - void fq_default_sqr(fq_default_t rop, const fq_default_t op, const fq_default_ctx_t ctx) noexcept - # Sets ``rop`` to the square of ``op``, - # reducing the output in the given context. - void fq_default_div(fq_default_t rop, fq_default_t op1, fq_default_t op2, const fq_default_ctx_t ctx) noexcept - # Sets ``rop`` to the quotient of ``op1`` and ``op2``, - # reducing the output in the given context. - void fq_default_inv(fq_default_t rop, const fq_default_t op, const fq_default_ctx_t ctx) noexcept - # Sets ``rop`` to the inverse of the non-zero element ``op``. - void fq_default_pow(fq_default_t rop, const fq_default_t op, const fmpz_t e, const fq_default_ctx_t ctx) noexcept - # Sets ``rop`` the ``op`` raised to the power `e`. - # Currently assumes that `e \geq 0`. - # Note that for any input ``op``, ``rop`` is set to `1` - # whenever `e = 0`. - void fq_default_pow_ui(fq_default_t rop, const fq_default_t op, const ulong e, const fq_default_ctx_t ctx) noexcept - # Sets ``rop`` the ``op`` raised to the power `e`. - # Currently assumes that `e \geq 0`. - # Note that for any input ``op``, ``rop`` is set to `1` - # whenever `e = 0`. - int fq_default_sqrt(fq_default_t rop, const fq_default_t op1, const fq_default_ctx_t ctx) noexcept - # Sets ``rop`` to the square root of ``op1`` if it is a square, and return - # `1`, otherwise return `0`. - void fq_default_pth_root(fq_default_t rop, const fq_default_t op1, const fq_default_ctx_t ctx) noexcept - # Sets ``rop`` to a `p^{th}` root root of ``op1``. Currently, - # this computes the root by raising ``op1`` to `p^{d-1}` where - # `d` is the degree of the extension. - bint fq_default_is_square(const fq_default_t op, const fq_default_ctx_t ctx) noexcept - # Return ``1`` if ``op`` is a square. - - int fq_default_fprint_pretty(FILE *file, const fq_default_t op, const fq_default_ctx_t ctx) noexcept - # Prints a pretty representation of ``op`` to ``file``. - # In the current implementation, always returns `1`. The return code is - # part of the function's signature to allow for a later implementation to - # return the number of characters printed or a non-positive error code. - + int fq_default_fprint_pretty(FILE * file, const fq_default_t op, const fq_default_ctx_t ctx) noexcept void fq_default_print_pretty(const fq_default_t op, const fq_default_ctx_t ctx) noexcept - # Prints a pretty representation of ``op`` to ``stdout``. - # In the current implementation, always returns `1`. The return code is - # part of the function's signature to allow for a later implementation to - # return the number of characters printed or a non-positive error code. - int fq_default_fprint(FILE * file, const fq_default_t op, const fq_default_ctx_t ctx) noexcept - # Prints a representation of ``op`` to ``file``. - void fq_default_print(const fq_default_t op, const fq_default_ctx_t ctx) noexcept - # Prints a representation of ``op`` to ``stdout``. - char * fq_default_get_str(const fq_default_t op, const fq_default_ctx_t ctx) noexcept - # Returns the plain FLINT string representation of the element - # ``op``. - char * fq_default_get_str_pretty(const fq_default_t op, const fq_default_ctx_t ctx) noexcept - # Returns a pretty representation of the element ``op`` using the - # null-terminated string ``x`` as the variable name. - void fq_default_randtest(fq_default_t rop, flint_rand_t state, const fq_default_ctx_t ctx) noexcept - # Generates a random element of `\mathbf{F}_q`. - void fq_default_randtest_not_zero(fq_default_t rop, flint_rand_t state, const fq_default_ctx_t ctx) noexcept - # Generates a random non-zero element of `\mathbf{F}_q`. - void fq_default_rand(fq_default_t rop, flint_rand_t state, const fq_default_ctx_t ctx) noexcept - # Generates a high quality random element of `\mathbf{F}_q`. - void fq_default_rand_not_zero(fq_default_t rop, flint_rand_t state, const fq_default_ctx_t ctx) noexcept - # Generates a high quality non-zero random element of `\mathbf{F}_q`. - void fq_default_set(fq_default_t rop, const fq_default_t op, const fq_default_ctx_t ctx) noexcept - # Sets ``rop`` to ``op``. - void fq_default_set_si(fq_default_t rop, const slong x, const fq_default_ctx_t ctx) noexcept - # Sets ``rop`` to ``x``, considered as an element of - # `\mathbf{F}_p`. - void fq_default_set_ui(fq_default_t rop, const ulong x, const fq_default_ctx_t ctx) noexcept - # Sets ``rop`` to ``x``, considered as an element of - # `\mathbf{F}_p`. - void fq_default_set_fmpz(fq_default_t rop, const fmpz_t x, const fq_default_ctx_t ctx) noexcept - # Sets ``rop`` to ``x``, considered as an element of - # `\mathbf{F}_p`. - void fq_default_swap(fq_default_t op1, fq_default_t op2, const fq_default_ctx_t ctx) noexcept - # Swaps the two elements ``op1`` and ``op2``. - void fq_default_zero(fq_default_t rop, const fq_default_ctx_t ctx) noexcept - # Sets ``rop`` to zero. - void fq_default_one(fq_default_t rop, const fq_default_ctx_t ctx) noexcept - # Sets ``rop`` to one, reduced in the given context. - void fq_default_gen(fq_default_t rop, const fq_default_ctx_t ctx) noexcept - # Sets ``rop`` to a generator for the finite field. - # There is no guarantee this is a multiplicative generator of - # the finite field. - int fq_default_get_fmpz(fmpz_t rop, const fq_default_t op, const fq_default_ctx_t ctx) noexcept - # If ``op`` has a lift to the integers, return `1` and set ``rop`` to the lift in `[0,p)`. - # Otherwise, return `0` and leave `rop` undefined. - void fq_default_get_nmod_poly(nmod_poly_t poly, const fq_default_t op, const fq_default_ctx_t ctx) noexcept - # Sets ``poly`` to the polynomial representation of ``op``. Assumes the - # characteristic of the field and the modulus of the polynomial are the same. - # No checking of this occurs. - void fq_default_set_nmod_poly(fq_default_t op, const nmod_poly_t poly, const fq_default_ctx_t ctx) noexcept - # Sets ``op`` to the finite field element represented by the polynomial - # ``poly``. Assumes the characteristic of the field and the modulus of the - # polynomial are the same. No checking of this occurs. - void fq_default_get_fmpz_mod_poly(fmpz_mod_poly_t poly, const fq_default_t op, const fq_default_ctx_t ctx) noexcept - # Sets ``poly`` to the polynomial representation of ``op``. Assumes the - # characteristic of the field and the modulus of the polynomial are the same. - # No checking of this occurs. - void fq_default_set_fmpz_mod_poly(fq_default_t op, const fmpz_mod_poly_t poly, const fq_default_ctx_t ctx) noexcept - # Sets ``op`` to the finite field element represented by the polynomial - # ``poly``. Assumes the characteristic of the field and the modulus of the - # polynomial are the same. No checking of this occurs. - void fq_default_get_fmpz_poly(fmpz_poly_t a, const fq_default_t b, const fq_default_ctx_t ctx) noexcept - # Set ``a`` to a representative of ``b`` in ``ctx``. - # The representatives are taken in `(\mathbb{Z}/p\mathbb{Z})[x]/h(x)` where - # `h(x)` is the defining polynomial in ``ctx``. - void fq_default_set_fmpz_poly(fq_default_t a, const fmpz_poly_t b, const fq_default_ctx_t ctx) noexcept - # Set ``a`` to the element in ``ctx`` with representative ``b``. - # The representatives are taken in `(\mathbb{Z}/p\mathbb{Z})[x]/h(x)` where - # `h(x)` is the defining polynomial in ``ctx``. - bint fq_default_is_zero(const fq_default_t op, const fq_default_ctx_t ctx) noexcept - # Returns whether ``op`` is equal to zero. - bint fq_default_is_one(const fq_default_t op, const fq_default_ctx_t ctx) noexcept - # Returns whether ``op`` is equal to one. - bint fq_default_equal(const fq_default_t op1, const fq_default_t op2, const fq_default_ctx_t ctx) noexcept - # Returns whether ``op1`` and ``op2`` are equal. - void fq_default_trace(fmpz_t rop, const fq_default_t op, const fq_default_ctx_t ctx) noexcept - # Sets ``rop`` to the trace of ``op``. - # For an element `a \in \mathbf{F}_q`, multiplication by `a` defines - # a `\mathbf{F}_p`-linear map on `\mathbf{F}_q`. We define the - # trace of `a` as the trace of this map. Equivalently, if `\Sigma` - # generates `\operatorname{Gal}(\mathbf{F}_q / \mathbf{F}_p)` then the trace of - # `a` is equal to `\sum_{i=0}^{d-1} \Sigma^i (a)`, where `d = - # \log_{p} q`. - void fq_default_norm(fmpz_t rop, const fq_default_t op, const fq_default_ctx_t ctx) noexcept - # Computes the norm of ``op``. - # For an element `a \in \mathbf{F}_q`, multiplication by `a` defines - # a `\mathbf{F}_p`-linear map on `\mathbf{F}_q`. We define the norm - # of `a` as the determinant of this map. Equivalently, if `\Sigma` generates - # `\operatorname{Gal}(\mathbf{F}_q / \mathbf{F}_p)` then the trace of `a` is equal to - # `\prod_{i=0}^{d-1} \Sigma^i (a)`, where - # `d = \text{dim}_{\mathbf{F}_p}(\mathbf{F}_q)`. - # Algorithm selection is automatic depending on the input. - void fq_default_frobenius(fq_default_t rop, const fq_default_t op, slong e, const fq_default_ctx_t ctx) noexcept - # Evaluates the homomorphism `\Sigma^e` at ``op``. - # Recall that `\mathbf{F}_q / \mathbf{F}_p` is Galois with Galois group - # `\langle \sigma \rangle`, which is also isomorphic to - # `\mathbf{Z}/d\mathbf{Z}`, where - # `\sigma \in \operatorname{Gal}(\mathbf{F}_q/\mathbf{F}_p)` is the Frobenius element - # `\sigma \colon x \mapsto x^p`. diff --git a/src/sage/libs/flint/fq_default_mat.pxd b/src/sage/libs/flint/fq_default_mat.pxd index 9b0e60f1cc5..20601d54cac 100644 --- a/src/sage/libs/flint/fq_default_mat.pxd +++ b/src/sage/libs/flint/fq_default_mat.pxd @@ -2,7 +2,9 @@ # distutils: depends = flint/fq_default_mat.h ################################################################################ -# This file is auto-generated. Do not modify by hand +# This file is auto-generated by the script +# SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py. +# Do not modify by hand! Fix and rerun the script instead. ################################################################################ from libc.stdio cimport FILE @@ -11,265 +13,56 @@ from sage.libs.mpfr.types cimport * from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void fq_default_mat_init(fq_default_mat_t mat, slong rows, slong cols, const fq_default_ctx_t ctx) noexcept - # Initialises ``mat`` to a ``rows``-by-``cols`` matrix with - # coefficients in `\mathbf{F}_{q}` given by ``ctx``. All elements - # are set to zero. - void fq_default_mat_init_set(fq_default_mat_t mat, const fq_default_mat_t src, const fq_default_ctx_t ctx) noexcept - # Initialises ``mat`` and sets its dimensions and elements to - # those of ``src``. - void fq_default_mat_clear(fq_default_mat_t mat, const fq_default_ctx_t ctx) noexcept - # Clears the matrix and releases any memory it used. The matrix - # cannot be used again until it is initialised. This function must be - # called exactly once when finished using an ``fq_default_mat_t`` object. - void fq_default_mat_set(fq_default_mat_t mat, const fq_default_mat_t src, const fq_default_ctx_t ctx) noexcept - # Sets ``mat`` to a copy of ``src``. It is assumed - # that ``mat`` and ``src`` have identical dimensions. - void fq_default_mat_entry(fq_default_t val, const fq_default_mat_t mat, slong i, slong j, const fq_default_ctx_t ctx) noexcept - # Directly accesses the entry in ``mat`` in row `i` and column `j`, - # indexed from zero by setting ``val`` to the value of that entry. No bounds - # checking is performed. - void fq_default_mat_entry_set(fq_default_mat_t mat, slong i, slong j, const fq_default_t x, const fq_default_ctx_t ctx) noexcept - # Sets the entry in ``mat`` in row `i` and column `j` to ``x``. - void fq_default_mat_entry_set_fmpz(fq_default_mat_t mat, slong i, slong j, const fmpz_t x, const fq_default_ctx_t ctx) noexcept - # Sets the entry in ``mat`` in row `i` and column `j` to ``x``. - slong fq_default_mat_nrows(const fq_default_mat_t mat, const fq_default_ctx_t ctx) noexcept - # Returns the number of rows in ``mat``. - slong fq_default_mat_ncols(const fq_default_mat_t mat, const fq_default_ctx_t ctx) noexcept - # Returns the number of columns in ``mat``. - void fq_default_mat_swap(fq_default_mat_t mat1, fq_default_mat_t mat2, const fq_default_ctx_t ctx) noexcept - # Swaps two matrices. The dimensions of ``mat1`` and ``mat2`` - # are allowed to be different. - void fq_default_mat_zero(fq_default_mat_t mat, const fq_default_ctx_t ctx) noexcept - # Sets all entries of ``mat`` to 0. - void fq_default_mat_one(fq_default_mat_t mat, const fq_default_ctx_t ctx) noexcept - # Sets the diagonal entries of ``mat`` to 1 and all other entries to 0. - void fq_default_mat_swap_rows(fq_default_mat_t mat, slong * perm, slong r, slong s, const fq_default_ctx_t ctx) noexcept - # Swaps rows ``r`` and ``s`` of ``mat``. If ``perm`` is non-``NULL``, the - # permutation of the rows will also be applied to ``perm``. - void fq_default_mat_swap_cols(fq_default_mat_t mat, slong * perm, slong r, slong s, const fq_default_ctx_t ctx) noexcept - # Swaps columns ``r`` and ``s`` of ``mat``. If ``perm`` is non-``NULL``, the - # permutation of the columns will also be applied to ``perm``. - void fq_default_mat_invert_rows(fq_default_mat_t mat, slong * perm, const fq_default_ctx_t ctx) noexcept - # Swaps rows ``i`` and ``r - i`` of ``mat`` for ``0 <= i < r/2``, where - # ``r`` is the number of rows of ``mat``. If ``perm`` is non-``NULL``, the - # permutation of the rows will also be applied to ``perm``. - void fq_default_mat_invert_cols(fq_default_mat_t mat, slong * perm, const fq_default_ctx_t ctx) noexcept - # Swaps columns ``i`` and ``c - i`` of ``mat`` for ``0 <= i < c/2``, where - # ``c`` is the number of columns of ``mat``. If ``perm`` is non-``NULL``, the - # permutation of the columns will also be applied to ``perm``. - void fq_default_mat_set_nmod_mat(fq_default_mat_t mat1, const nmod_mat_t mat2, const fq_default_ctx_t ctx) noexcept - # Sets the matrix ``mat1`` to the matrix ``mat2``. - void fq_default_mat_set_fmpz_mod_mat(fq_default_mat_t mat1, const fmpz_mod_mat_t mat2, const fq_default_ctx_t ctx) noexcept - # Sets the matrix ``mat1`` to the matrix ``mat2``. - void fq_default_mat_set_fmpz_mat(fq_default_mat_t mat1, const fmpz_mat_t mat2, const fq_default_ctx_t ctx) noexcept - # Sets the matrix ``mat1`` to the matrix ``mat2``, reducing the entries - # modulo the characteristic of the finite field. - void fq_default_mat_concat_vertical(fq_default_mat_t res, const fq_default_mat_t mat1, const fq_default_mat_t mat2, const fq_default_ctx_t ctx) noexcept - # Sets ``res`` to vertical concatenation of (``mat1``, ``mat2``) in that order. Matrix dimensions : ``mat1`` : `m \times n`, ``mat2`` : `k \times n`, ``res`` : `(m + k) \times n`. - void fq_default_mat_concat_horizontal(fq_default_mat_t res, const fq_default_mat_t mat1, const fq_default_mat_t mat2, const fq_default_ctx_t ctx) noexcept - # Sets ``res`` to horizontal concatenation of (``mat1``, ``mat2``) in that order. Matrix dimensions : ``mat1`` : `m \times n`, ``mat2`` : `m \times k`, ``res`` : `m \times (n + k)`. - int fq_default_mat_print_pretty(const fq_default_mat_t mat, const fq_default_ctx_t ctx) noexcept - # Pretty-prints ``mat`` to ``stdout``. A header is printed - # followed by the rows enclosed in brackets. - int fq_default_mat_fprint_pretty(FILE * file, const fq_default_mat_t mat, const fq_default_ctx_t ctx) noexcept - # Pretty-prints ``mat`` to ``file``. A header is printed - # followed by the rows enclosed in brackets. - # In case of success, returns a positive value. In case of failure, - # returns a non-positive value. - int fq_default_mat_print(const fq_default_mat_t mat, const fq_default_ctx_t ctx) noexcept - # Prints ``mat`` to ``stdout``. A header is printed followed - # by the rows enclosed in brackets. - int fq_default_mat_fprint(FILE * file, const fq_default_mat_t mat, const fq_default_ctx_t ctx) noexcept - # Prints ``mat`` to ``file``. A header is printed followed by - # the rows enclosed in brackets. - # In case of success, returns a positive value. In case of failure, - # returns a non-positive value. - void fq_default_mat_window_init(fq_default_mat_t window, const fq_default_mat_t mat, slong r1, slong c1, slong r2, slong c2, const fq_default_ctx_t ctx) noexcept - # Initializes the matrix ``window`` to be an ``r2 - r1`` by - # ``c2 - c1`` submatrix of ``mat`` whose ``(0,0)`` entry - # is the ``(r1, c1)`` entry of ``mat``. The memory for the - # elements of ``window`` is shared with ``mat``. - void fq_default_mat_window_clear(fq_default_mat_t window, const fq_default_ctx_t ctx) noexcept - # Clears the matrix ``window`` and releases any memory that it - # uses. Note that the memory to the underlying matrix that - # ``window`` points to is not freed. - void fq_default_mat_randtest(fq_default_mat_t mat, flint_rand_t state, const fq_default_ctx_t ctx) noexcept - # Sets the elements of ``mat`` to random elements of - # `\mathbf{F}_{q}`, given by ``ctx``. - int fq_default_mat_randpermdiag(fq_mat_t mat, flint_rand_t state, fq_struct * diag, slong n, const fq_ctx_t ctx) noexcept - # Sets ``mat`` to a random permutation of the diagonal matrix - # with `n` leading entries given by the vector ``diag``. It is - # assumed that the main diagonal of ``mat`` has room for at - # least `n` entries. - # Returns `0` or `1`, depending on whether the permutation is even - # or odd respectively. - void fq_default_mat_randrank(fq_default_mat_t mat, flint_rand_t state, slong rank, const fq_default_ctx_t ctx) noexcept - # Sets ``mat`` to a random sparse matrix with the given rank, - # having exactly as many non-zero elements as the rank, with the - # non-zero elements being uniformly random elements of - # `\mathbf{F}_{q}`. - # The matrix can be transformed into a dense matrix with unchanged - # rank by subsequently calling :func:`fq_default_mat_randops`. - void fq_default_mat_randops(fq_default_mat_t mat, slong count, flint_rand_t state, const fq_default_ctx_t ctx) noexcept - # Randomises ``mat`` by performing elementary row or column - # operations. More precisely, at most ``count`` random additions - # or subtractions of distinct rows and columns will be performed. - # This leaves the rank (and for square matrices, determinant) - # unchanged. - void fq_default_mat_randtril(fq_default_mat_t mat, flint_rand_t state, int unit, const fq_default_ctx_t ctx) noexcept - # Sets ``mat`` to a random lower triangular matrix. If - # ``unit`` is 1, it will have ones on the main diagonal, - # otherwise it will have random nonzero entries on the main - # diagonal. - void fq_default_mat_randtriu(fq_default_mat_t mat, flint_rand_t state, int unit, const fq_default_ctx_t ctx) noexcept - # Sets ``mat`` to a random upper triangular matrix. If - # ``unit`` is 1, it will have ones on the main diagonal, - # otherwise it will have random nonzero entries on the main - # diagonal. - bint fq_default_mat_equal(const fq_default_mat_t mat1, const fq_default_mat_t mat2, const fq_default_ctx_t ctx) noexcept - # Returns nonzero if mat1 and mat2 have the same dimensions and elements, - # and zero otherwise. - bint fq_default_mat_is_zero(const fq_default_mat_t mat, const fq_default_ctx_t ctx) noexcept - # Returns a non-zero value if all entries of ``mat`` are zero, and - # otherwise returns zero. - bint fq_default_mat_is_one(const fq_default_mat_t mat, const fq_default_ctx_t ctx) noexcept - # Returns a non-zero value if all diagonal entries of ``mat`` are one and - # all other entries are zero, and otherwise returns zero. - bint fq_default_mat_is_empty(const fq_default_mat_t mat, const fq_default_ctx_t ctx) noexcept - # Returns a non-zero value if the number of rows or the number of - # columns in ``mat`` is zero, and otherwise returns zero. - bint fq_default_mat_is_square(const fq_default_mat_t mat, const fq_default_ctx_t ctx) noexcept - # Returns a non-zero value if the number of rows is equal to the - # number of columns in ``mat``, and otherwise returns zero. - void fq_default_mat_add(fq_default_mat_t C, const fq_default_mat_t A, const fq_default_mat_t B, const fq_default_ctx_t ctx) noexcept - # Computes `C = A + B`. Dimensions must be identical. - void fq_default_mat_sub(fq_default_mat_t C, const fq_default_mat_t A, const fq_default_mat_t B, const fq_default_ctx_t ctx) noexcept - # Computes `C = A - B`. Dimensions must be identical. - void fq_default_mat_neg(fq_default_mat_t A, const fq_default_mat_t B, const fq_default_ctx_t ctx) noexcept - # Sets `B = -A`. Dimensions must be identical. - void fq_default_mat_mul(fq_default_mat_t C, const fq_default_mat_t A, const fq_default_mat_t B, const fq_default_ctx_t ctx) noexcept - # Sets `C = AB`. Dimensions must be compatible for matrix - # multiplication. Aliasing is allowed. This function automatically chooses - # between classical and KS multiplication. - void fq_default_mat_submul(fq_default_mat_t D, const fq_default_mat_t C, const fq_default_mat_t A, const fq_default_mat_t B, const fq_default_ctx_t ctx) noexcept - # Sets `D = C + AB`. `C` and `D` may be aliased with each other but - # not with `A` or `B`. - int fq_default_mat_inv(fq_default_mat_t B, fq_default_mat_t A, const fq_default_ctx_t ctx) noexcept - # Sets `B = A^{-1}` and returns `1` if `A` is invertible. If `A` is singular, - # returns `0` and sets the elements of `B` to undefined values. - # `A` and `B` must be square matrices with the same dimensions. - slong fq_default_mat_lu(slong * P, fq_default_mat_t A, int rank_check, const fq_default_ctx_t ctx) noexcept - # Computes a generalised LU decomposition `LU = PA` of a given - # matrix `A`, returning the rank of `A`. - # If `A` is a nonsingular square matrix, it will be overwritten with - # a unit diagonal lower triangular matrix `L` and an upper - # triangular matrix `U` (the diagonal of `L` will not be stored - # explicitly). - # If `A` is an arbitrary matrix of rank `r`, `U` will be in row - # echelon form having `r` nonzero rows, and `L` will be lower - # triangular but truncated to `r` columns, having implicit ones on - # the `r` first entries of the main diagonal. All other entries will - # be zero. - # If a nonzero value for ``rank_check`` is passed, the function - # will abandon the output matrix in an undefined state and return 0 - # if `A` is detected to be rank-deficient. - # This function calls ``fq_default_mat_lu_recursive``. - slong fq_default_mat_rref(fq_default_mat_t A, const fq_default_ctx_t ctx) noexcept - # Puts `A` in reduced row echelon form and returns the rank of `A`. - # The rref is computed by first obtaining an unreduced row echelon - # form via LU decomposition and then solving an additional - # triangular system. - void fq_default_mat_solve_tril(fq_default_mat_t X, const fq_default_mat_t L, const fq_default_mat_t B, int unit, const fq_default_ctx_t ctx) noexcept - # Sets `X = L^{-1} B` where `L` is a full rank lower triangular - # square matrix. If ``unit`` = 1, `L` is assumed to have ones on - # its main diagonal, and the main diagonal will not be read. `X` - # and `B` are allowed to be the same matrix, but no other aliasing - # is allowed. Automatically chooses between the classical and - # recursive algorithms. - void fq_default_mat_solve_triu(fq_default_mat_t X, const fq_default_mat_t U, const fq_default_mat_t B, int unit, const fq_default_ctx_t ctx) noexcept - # Sets `X = U^{-1} B` where `U` is a full rank upper triangular - # square matrix. If ``unit`` = 1, `U` is assumed to have ones on - # its main diagonal, and the main diagonal will not be read. `X` - # and `B` are allowed to be the same matrix, but no other aliasing - # is allowed. Automatically chooses between the classical and - # recursive algorithms. - int fq_default_mat_solve(fq_default_mat_t X, const fq_default_mat_t A, const fq_default_mat_t B, const fq_default_ctx_t ctx) noexcept - # Solves the matrix-matrix equation `AX = B`. - # Returns `1` if `A` has full rank; otherwise returns `0` and sets the - # elements of `X` to undefined values. - # The matrix `A` must be square. - int fq_default_mat_can_solve(fq_default_mat_t X, const fq_default_mat_t A, const fq_default_mat_t B, const fq_default_ctx_t ctx) noexcept - # Solves the matrix-matrix equation `AX = B` over `Fq`. - # Returns `1` if a solution exists; otherwise returns `0` and sets the - # elements of `X` to zero. If more than one solution exists, one of the - # valid solutions is given. - # There are no restrictions on the shape of `A` and it may be singular. - void fq_default_mat_similarity(fq_default_mat_t M, slong r, fq_default_t d, const fq_default_ctx_t ctx) noexcept - # Applies a similarity transform to the `n\times n` matrix `M` in-place. - # If `P` is the `n\times n` identity matrix the zero entries of whose row - # `r` (`0`-indexed) have been replaced by `d`, this transform is equivalent - # to `M = P^{-1}MP`. - # Similarity transforms preserve the determinant, characteristic polynomial - # and minimal polynomial. - # The value `d` is required to be reduced modulo the modulus of the entries - # in the matrix. - void fq_default_mat_charpoly(fq_default_poly_t p, const fq_default_mat_t M, const fq_default_ctx_t ctx) noexcept - # Compute the characteristic polynomial `p` of the matrix `M`. The matrix - # is required to be square, otherwise an exception is raised. - void fq_default_mat_minpoly(fq_default_poly_t p, const fq_default_mat_t M, const fq_default_ctx_t ctx) noexcept - # Compute the minimal polynomial `p` of the matrix `M`. The matrix - # is required to be square, otherwise an exception is raised. diff --git a/src/sage/libs/flint/fq_default_poly.pxd b/src/sage/libs/flint/fq_default_poly.pxd index 21d20fbfd83..e1c93ca322f 100644 --- a/src/sage/libs/flint/fq_default_poly.pxd +++ b/src/sage/libs/flint/fq_default_poly.pxd @@ -2,7 +2,9 @@ # distutils: depends = flint/fq_default_poly.h ################################################################################ -# This file is auto-generated. Do not modify by hand +# This file is auto-generated by the script +# SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py. +# Do not modify by hand! Fix and rerun the script instead. ################################################################################ from libc.stdio cimport FILE @@ -11,348 +13,83 @@ from sage.libs.mpfr.types cimport * from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void fq_default_poly_init(fq_default_poly_t poly, const fq_default_ctx_t ctx) noexcept - # Initialises ``poly`` for use, with context ctx, and setting its - # length to zero. A corresponding call to :func:`fq_default_poly_clear` - # must be made after finishing with the ``fq_default_poly_t`` to free the - # memory used by the polynomial. - void fq_default_poly_init2(fq_default_poly_t poly, slong alloc, const fq_default_ctx_t ctx) noexcept - # Initialises ``poly`` with space for at least ``alloc`` - # coefficients and sets the length to zero. The allocated - # coefficients are all set to zero. A corresponding call to - # :func:`fq_default_poly_clear` must be made after finishing with the - # ``fq_default_poly_t`` to free the memory used by the polynomial. - void fq_default_poly_realloc(fq_default_poly_t poly, slong alloc, const fq_default_ctx_t ctx) noexcept - # Reallocates the given polynomial to have space for ``alloc`` - # coefficients. If ``alloc`` is zero the polynomial is cleared - # and then reinitialised. If the current length is greater than - # ``alloc`` the polynomial is first truncated to length - # ``alloc``. - void fq_default_poly_fit_length(fq_default_poly_t poly, slong len, const fq_default_ctx_t ctx) noexcept - # If ``len`` is greater than the number of coefficients currently - # allocated, then the polynomial is reallocated to have space for at - # least ``len`` coefficients. No data is lost when calling this - # function. - # The function efficiently deals with the case where - # ``fit_length`` is called many times in small increments by at - # least doubling the number of allocated coefficients when length is - # larger than the number of coefficients currently allocated. - void fq_default_poly_clear(fq_default_poly_t poly, const fq_default_ctx_t ctx) noexcept - # Clears the given polynomial, releasing any memory used. It must - # be reinitialised in order to be used again. - void _fq_default_poly_set_length(fq_default_poly_t poly, slong len, const fq_default_ctx_t ctx) noexcept - # Set the length of ``poly`` to ``len``. - void fq_default_poly_truncate(fq_default_poly_t poly, slong newlen, const fq_default_ctx_t ctx) noexcept - # Truncates the polynomial to length at most `n`. - void fq_default_poly_set_trunc(fq_default_poly_t poly1, fq_default_poly_t poly2, slong newlen, const fq_default_ctx_t ctx) noexcept - # Sets ``poly1`` to ``poly2`` truncated to length `n`. - void fq_default_poly_reverse(fq_default_poly_t output, const fq_default_poly_t input, slong m, const fq_default_ctx_t ctx) noexcept - # Sets ``output`` to the reverse of ``input``, thinking of it - # as a polynomial of length ``m``, notionally zero-padded if - # necessary). The length ``m`` must be non-negative, but there - # are no other restrictions. The output polynomial will be set to - # length ``m`` and then normalised. - slong fq_default_poly_degree(const fq_default_poly_t poly, const fq_default_ctx_t ctx) noexcept - # Returns the degree of the polynomial ``poly``. - slong fq_default_poly_length(const fq_default_poly_t poly, const fq_default_ctx_t ctx) noexcept - # Returns the length of the polynomial ``poly``. - void fq_default_poly_randtest(fq_default_poly_t f, flint_rand_t state, slong len, const fq_default_ctx_t ctx) noexcept - # Sets `f` to a random polynomial of length at most ``len`` - # with entries in the field described by ``ctx``. - void fq_default_poly_randtest_not_zero(fq_default_poly_t f, flint_rand_t state, slong len, const fq_default_ctx_t ctx) noexcept - # Same as ``fq_default_poly_randtest`` but guarantees that the polynomial - # is not zero. - void fq_default_poly_randtest_monic(fq_default_poly_t f, flint_rand_t state, slong len, const fq_default_ctx_t ctx) noexcept - # Sets `f` to a random monic polynomial of length ``len`` with - # entries in the field described by ``ctx``. - void fq_default_poly_randtest_irreducible(fq_default_poly_t f, flint_rand_t state, slong len, const fq_default_ctx_t ctx) noexcept - # Sets `f` to a random monic, irreducible polynomial of length - # ``len`` with entries in the field described by ``ctx``. - void fq_default_poly_set(fq_default_poly_t poly1, const fq_default_poly_t poly2, const fq_default_ctx_t ctx) noexcept - # Sets the polynomial ``poly1`` to the polynomial ``poly2``. - void fq_default_poly_set_fq_default(fq_default_poly_t poly, const fq_default_t c, const fq_default_ctx_t ctx) noexcept - # Sets the polynomial ``poly`` to ``c``. - void fq_default_poly_swap(fq_default_poly_t op1, fq_default_poly_t op2, const fq_default_ctx_t ctx) noexcept - # Swaps the two polynomials ``op1`` and ``op2``. - void fq_default_poly_zero(fq_default_poly_t poly, const fq_default_ctx_t ctx) noexcept - # Sets ``poly`` to the zero polynomial. - void fq_default_poly_one(fq_default_poly_t poly, const fq_default_ctx_t ctx) noexcept - # Sets ``poly`` to the constant polynomial `1`. - void fq_default_poly_gen(fq_default_poly_t poly, const fq_default_ctx_t ctx) noexcept - # Sets ``poly`` to the polynomial `x`. - void fq_default_poly_make_monic(fq_default_poly_t rop, const fq_default_poly_t op, const fq_default_ctx_t ctx) noexcept - # Sets ``rop`` to ``op``, normed to have leading coefficient 1. - void fq_default_poly_set_nmod_poly(fq_default_poly_t rop, const nmod_poly_t op, const fq_default_ctx_t ctx) noexcept - # Sets the polynomial ``rop`` to the polynomial ``op``. - void fq_default_poly_set_fmpz_mod_poly(fq_default_poly_t rop, const fmpz_mod_poly_t op, const fq_default_ctx_t ctx) noexcept - # Sets the polynomial ``rop`` to the polynomial ``op``. - void fq_default_poly_set_fmpz_poly(fq_default_poly_t rop, const fmpz_poly_t op, const fq_default_ctx_t ctx) noexcept - # Sets the polynomial ``rop`` to the polynomial ``op``. - void fq_default_poly_get_coeff(fq_default_t x, const fq_default_poly_t poly, slong n, const fq_default_ctx_t ctx) noexcept - # Sets `x` to the coefficient of `X^n` in ``poly``. - void fq_default_poly_set_coeff(fq_default_poly_t poly, slong n, const fq_default_t x, const fq_default_ctx_t ctx) noexcept - # Sets the coefficient of `X^n` in ``poly`` to `x`. - void fq_default_poly_set_coeff_fmpz(fq_default_poly_t poly, slong n, const fmpz_t x, const fq_default_ctx_t ctx) noexcept - # Sets the coefficient of `X^n` in the polynomial to `x`, - # assuming `n \geq 0`. - bint fq_default_poly_equal(const fq_default_poly_t poly1, const fq_default_poly_t poly2, const fq_default_ctx_t ctx) noexcept - # Returns nonzero if the two polynomials ``poly1`` and ``poly2`` - # are equal, otherwise returns zero. - bint fq_default_poly_equal_trunc(const fq_default_poly_t poly1, const fq_default_poly_t poly2, slong n, const fq_default_ctx_t ctx) noexcept - # Notionally truncate ``poly1`` and ``poly2`` to length `n` and - # return nonzero if they are equal, otherwise return zero. - bint fq_default_poly_is_zero(const fq_default_poly_t poly, const fq_default_ctx_t ctx) noexcept - # Returns whether the polynomial ``poly`` is the zero polynomial. - bint fq_default_poly_is_one(const fq_default_poly_t op, const fq_default_ctx_t ctx) noexcept - # Returns whether the polynomial ``poly`` is equal - # to the constant polynomial `1`. - bint fq_default_poly_is_gen(const fq_default_poly_t op, const fq_default_ctx_t ctx) noexcept - # Returns whether the polynomial ``poly`` is equal - # to the polynomial `x`. - bint fq_default_poly_is_unit(const fq_default_poly_t op, const fq_default_ctx_t ctx) noexcept - # Returns whether the polynomial ``poly`` is a unit in the polynomial - # ring `\mathbf{F}_q[X]`, i.e. if it has degree `0` and is non-zero. - bint fq_default_poly_equal_fq_default(const fq_default_poly_t poly, const fq_default_t c, const fq_default_ctx_t ctx) noexcept - # Returns whether the polynomial ``poly`` is equal the (constant) - # `\mathbf{F}_q` element ``c`` - void fq_default_poly_add(fq_default_poly_t res, const fq_default_poly_t poly1, const fq_default_poly_t poly2, const fq_default_ctx_t ctx) noexcept - # Sets ``res`` to the sum of ``poly1`` and ``poly2``. - void fq_default_poly_add_si(fq_default_poly_t res, const fq_default_poly_t poly1, slong c, const fq_default_ctx_t ctx) noexcept - # Sets ``res`` to the sum of ``poly1`` and ``c``. - void fq_default_poly_add_series(fq_default_poly_t res, const fq_default_poly_t poly1, const fq_default_poly_t poly2, slong n, const fq_default_ctx_t ctx) noexcept - # Notionally truncate ``poly1`` and ``poly2`` to length ``n`` and set - # ``res`` to the sum. - void fq_default_poly_sub(fq_default_poly_t res, const fq_default_poly_t poly1, const fq_default_poly_t poly2, const fq_default_ctx_t ctx) noexcept - # Sets ``res`` to the difference of ``poly1`` and ``poly2``. - void fq_default_poly_sub_series(fq_default_poly_t res, const fq_default_poly_t poly1, const fq_default_poly_t poly2, slong n, const fq_default_ctx_t ctx) noexcept - # Notionally truncate ``poly1`` and ``poly2`` to length ``n`` and set - # ``res`` to the difference. - void fq_default_poly_neg(fq_default_poly_t res, const fq_default_poly_t poly, const fq_default_ctx_t ctx) noexcept - # Sets ``res`` to the additive inverse of ``poly``. - void fq_default_poly_scalar_mul_fq_default(fq_default_poly_t rop, const fq_default_poly_t op, const fq_default_t x, const fq_default_ctx_t ctx) noexcept - # Sets ``rop`` to the product of ``op`` by the scalar ``x``, in the context - # defined by ``ctx``. - void fq_default_poly_scalar_addmul_fq_default(fq_default_poly_t rop, const fq_default_poly_t op, const fq_default_t x, const fq_default_ctx_t ctx) noexcept - # Adds to ``rop`` the product of ``op`` by the - # scalar ``x``, in the context defined by ``ctx``. - void fq_default_poly_scalar_submul_fq_default(fq_default_poly_t rop, const fq_default_poly_t op, const fq_default_t x, const fq_default_ctx_t ctx) noexcept - # Subtracts from ``rop`` the product of ``op`` by the - # scalar ``x``, in the context defined by ``ctx``. - void fq_default_poly_scalar_div_fq_default(fq_default_poly_t rop, const fq_default_poly_t op, const fq_default_t x, const fq_default_ctx_t ctx) noexcept - # Sets ``rop`` to the quotient of ``op`` by the scalar ``x``, in the context - # defined by ``ctx``. An exception is raised if ``x`` is zero. - void fq_default_poly_mul(fq_default_poly_t rop, const fq_default_poly_t op1, const fq_default_poly_t op2, const fq_default_ctx_t ctx) noexcept - # Sets ``rop`` to the product of ``op1`` and ``op2``, - # choosing an appropriate algorithm. - void fq_default_poly_mullow(fq_default_poly_t rop, const fq_default_poly_t op1, const fq_default_poly_t op2, slong n, const fq_default_ctx_t ctx) noexcept - # Sets ``rop`` to the lowest `n` coefficients of the product of - # ``op1`` and ``op2``. - void fq_default_poly_mulhigh(fq_default_poly_t res, const fq_default_poly_t poly1, const fq_default_poly_t poly2, slong start, const fq_default_ctx_t ctx) noexcept - # Computes the product of ``poly1`` and ``poly2`` and writes the - # coefficients from ``start`` onwards into the high coefficients of - # ``res``, the remaining coefficients being arbitrary but reduced. - void fq_default_poly_mulmod(fq_default_poly_t res, const fq_default_poly_t poly1, const fq_default_poly_t poly2, const fq_default_poly_t f, const fq_default_ctx_t ctx) noexcept - # Sets ``res`` to the remainder of the product of ``poly1`` - # and ``poly2`` upon polynomial division by ``f``. - void fq_default_poly_sqr(fq_default_poly_t rop, const fq_default_poly_t op, const fq_default_ctx_t ctx) noexcept - # Sets ``rop`` to the square of ``op``, - # choosing an appropriate algorithm. - void fq_default_poly_pow(fq_default_poly_t rop, const fq_default_poly_t op, ulong e, const fq_default_ctx_t ctx) noexcept - # Computes ``rop = op^e``. If `e` is zero, returns one, - # so that in particular ``0^0 = 1``. - void fq_default_poly_powmod_ui_binexp(fq_default_poly_t res, const fq_default_poly_t poly, ulong e, const fq_default_poly_t f, const fq_default_ctx_t ctx) noexcept - # Sets ``res`` to ``poly`` raised to the power ``e`` modulo - # ``f``, using binary exponentiation. We require ``e >= 0``. - void fq_default_poly_powmod_fmpz_binexp(fq_default_poly_t res, const fq_default_poly_t poly, const fmpz_t e, const fq_default_poly_t f, const fq_default_ctx_t ctx) noexcept - # Sets ``res`` to ``poly`` raised to the power ``e`` modulo - # ``f``, using binary exponentiation. We require ``e >= 0``. - void fq_default_poly_pow_trunc(fq_default_poly_t res, const fq_default_poly_t poly, ulong e, slong trunc, const fq_default_ctx_t ctx) noexcept - # Sets ``res`` to the low ``trunc`` coefficients of ``poly`` - # to the power ``e``. This is equivalent to doing a powering - # followed by a truncation. - void fq_default_poly_shift_left(fq_default_poly_t rop, const fq_default_poly_t op, slong n, const fq_default_ctx_t ctx) noexcept - # Sets ``rop`` to ``op`` shifted left by `n` coeffs. Zero - # coefficients are inserted. - void fq_default_poly_shift_right(fq_default_poly_t rop, const fq_default_poly_t op, slong n, const fq_default_ctx_t ctx) noexcept - # Sets ``rop`` to ``op`` shifted right by `n` coefficients. - # If `n` is equal to or greater than the current length of - # ``op``, ``rop`` is set to the zero polynomial. - slong fq_default_poly_hamming_weight(const fq_default_poly_t op, const fq_default_ctx_t ctx) noexcept - # Returns the number of non-zero entries in the polynomial ``op``. - void fq_default_poly_divrem(fq_default_poly_t Q, fq_default_poly_t R, const fq_default_poly_t A, const fq_default_poly_t B, const fq_default_ctx_t ctx) noexcept - # Computes `Q`, `R` such that `A = B Q + R` with - # `0 \leq \operatorname{len}(R) < \operatorname{len}(B)`. - # Assumes that the leading coefficient of `B` is invertible. This can - # be taken for granted the context is for a finite field, that is, when - # `p` is prime and `f(X)` is irreducible. - void fq_default_poly_rem(fq_default_poly_t R, const fq_default_poly_t A, const fq_default_poly_t B, const fq_default_ctx_t ctx) noexcept - # Sets ``R`` to the remainder of the division of ``A`` by - # ``B`` in the context described by ``ctx``. - void fq_default_poly_inv_series(fq_default_poly_t Qinv, const fq_default_poly_t Q, slong n, const fq_default_ctx_t ctx) noexcept - # Given ``Q`` find ``Qinv`` such that ``Q * Qinv`` is - # ``1`` modulo `x^n`. The constant coefficient of ``Q`` must - # be invertible modulo the modulus of ``Q``. An exception is - # raised if this is not the case or if ``n = 0``. - void fq_default_poly_div_series(fq_default_poly_t Q, const fq_default_poly_t A, const fq_default_poly_t B, slong n, const fq_default_ctx_t ctx) noexcept - # Set `Q` to the quotient of the series `A` by `B`, thinking of the series as - # though they were of length `n`. We assume that the bottom coefficient of - # `B` is invertible. - void fq_default_poly_gcd(fq_default_poly_t rop, const fq_default_poly_t op1, const fq_default_poly_t op2, const fq_default_ctx_t ctx) noexcept - # Sets ``rop`` to the greatest common divisor of ``op1`` and - # ``op2``, using the either the Euclidean or HGCD algorithm. The - # GCD of zero polynomials is defined to be zero, whereas the GCD of - # the zero polynomial and some other polynomial `P` is defined to be - # `P`. Except in the case where the GCD is zero, the GCD `G` is made - # monic. - void fq_default_poly_xgcd(fq_default_poly_t G, fq_default_poly_t S, fq_default_poly_t T, const fq_default_poly_t A, const fq_default_poly_t B, const fq_default_ctx_t ctx) noexcept - # Computes the GCD of `A` and `B`. The GCD of zero polynomials is - # defined to be zero, whereas the GCD of the zero polynomial and some other - # polynomial `P` is defined to be `P`. Except in the case where - # the GCD is zero, the GCD `G` is made monic. - # Polynomials ``S`` and ``T`` are computed such that - # ``S*A + T*B = G``. The length of ``S`` will be at most - # ``lenB`` and the length of ``T`` will be at most ``lenA``. - int fq_default_poly_divides(fq_default_poly_t Q, const fq_default_poly_t A, const fq_default_poly_t B, const fq_default_ctx_t ctx) noexcept - # Returns `1` if `B` divides `A` exactly and sets `Q` to the quotient, - # otherwise returns `0`. - # This function is currently unoptimised and provided for convenience - # only. - void fq_default_poly_derivative(fq_default_poly_t rop, const fq_default_poly_t op, const fq_default_ctx_t ctx) noexcept - # Sets ``rop`` to the derivative of ``op``. - void fq_default_poly_invsqrt_series(fq_default_poly_t g, const fq_default_poly_t h, slong n, fq_default_ctx_t ctx) noexcept - # Set `g` to the series expansion of `1/\sqrt{h}` to order `O(x^n)`. - # It is assumed that `h` has constant term 1. - void fq_default_poly_sqrt_series(fq_default_poly_t g, const fq_default_poly_t h, slong n, fq_default_ctx_t ctx) noexcept - # Set `g` to the series expansion of `\sqrt{h}` to order `O(x^n)`. - # It is assumed that `h` has constant term 1. - int fq_default_poly_sqrt(fq_default_poly_t s, const fq_default_poly_t p, fq_default_ctx_t mod) noexcept - # If `p` is a perfect square, sets `s` to a square root of `p` - # and returns 1. Otherwise returns 0. - void fq_default_poly_evaluate_fq_default(fq_default_t rop, const fq_default_poly_t f, const fq_default_t a, const fq_default_ctx_t ctx) noexcept - # Sets ``rop`` to the value of `f(a)`. - # As the coefficient ring `\mathbf{F}_q` is finite, Horner's method - # is sufficient. - void fq_default_poly_compose(fq_default_poly_t rop, const fq_default_poly_t op1, const fq_default_poly_t op2, const fq_default_ctx_t ctx) noexcept - # Sets ``rop`` to the composition of ``op1`` and ``op2``. - # To be precise about the order of composition, denoting ``rop``, - # ``op1``, and ``op2`` by `f`, `g`, and `h`, respectively, - # sets `f(t) = g(h(t))`. - void fq_default_poly_compose_mod(fq_default_poly_t res, const fq_default_poly_t f, const fq_default_poly_t g, const fq_default_poly_t h, const fq_default_ctx_t ctx) noexcept - # Sets ``res`` to the composition `f(g)` modulo `h`. We require - # that `h` is nonzero. - - int fq_default_poly_fprint_pretty(FILE * file, const fq_default_poly_t poly, const char *x, const fq_default_ctx_t ctx) noexcept - # Prints the pretty representation of ``poly`` to the stream - # ``file``, using the string ``x`` to represent the indeterminate. - # In case of success, returns a positive value. In case of failure, - # returns a non-positive value. - - int fq_default_poly_print_pretty(const fq_default_poly_t poly, const char *x, const fq_default_ctx_t ctx) noexcept - # Prints the pretty representation of ``poly`` to ``stdout``, - # using the string ``x`` to represent the indeterminate. - # In case of success, returns a positive value. In case of failure, - # returns a non-positive value. - + int fq_default_poly_fprint_pretty(FILE * file, const fq_default_poly_t poly, const char * x, const fq_default_ctx_t ctx) noexcept + int fq_default_poly_print_pretty(const fq_default_poly_t poly, const char * x, const fq_default_ctx_t ctx) noexcept int fq_default_poly_fprint(FILE * file, const fq_default_poly_t poly, const fq_default_ctx_t ctx) noexcept - # Prints the pretty representation of ``poly`` to the stream - # ``file``. - # In case of success, returns a positive value. In case of failure, - # returns a non-positive value. - int fq_default_poly_print(const fq_default_poly_t poly, const fq_default_ctx_t ctx) noexcept - # Prints the representation of ``poly`` to ``stdout``. - # In case of success, returns a positive value. In case of failure, - # returns a non-positive value. - char * fq_default_poly_get_str(const fq_default_poly_t poly, const fq_default_ctx_t ctx) noexcept - # Returns the plain FLINT string representation of the polynomial - # ``poly``. - char * fq_default_poly_get_str_pretty(const fq_default_poly_t poly, const char * x, const fq_default_ctx_t ctx) noexcept - # Returns a pretty representation of the polynomial ``poly`` using the - # null-terminated string ``x`` as the variable name - void fq_default_poly_inflate(fq_default_poly_t result, const fq_default_poly_t input, ulong inflation, const fq_default_ctx_t ctx) noexcept - # Sets ``result`` to the inflated polynomial `p(x^n)` where - # `p` is given by ``input`` and `n` is given by ``inflation``. - void fq_default_poly_deflate(fq_default_poly_t result, const fq_default_poly_t input, ulong deflation, const fq_default_ctx_t ctx) noexcept - # Sets ``result`` to the deflated polynomial `p(x^{1/n})` where - # `p` is given by ``input`` and `n` is given by ``deflation``. - # Requires `n > 0`. - ulong fq_default_poly_deflation(const fq_default_poly_t input, const fq_default_ctx_t ctx) noexcept - # Returns the largest integer by which ``input`` can be deflated. - # As special cases, returns 0 if ``input`` is the zero polynomial - # and 1 of ``input`` is a constant polynomial. diff --git a/src/sage/libs/flint/fq_default_poly_factor.pxd b/src/sage/libs/flint/fq_default_poly_factor.pxd index cc69e8a168c..aff2870099e 100644 --- a/src/sage/libs/flint/fq_default_poly_factor.pxd +++ b/src/sage/libs/flint/fq_default_poly_factor.pxd @@ -2,7 +2,9 @@ # distutils: depends = flint/fq_default_poly_factor.h ################################################################################ -# This file is auto-generated. Do not modify by hand +# This file is auto-generated by the script +# SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py. +# Do not modify by hand! Fix and rerun the script instead. ################################################################################ from libc.stdio cimport FILE @@ -11,100 +13,25 @@ from sage.libs.mpfr.types cimport * from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void fq_default_poly_factor_init(fq_default_poly_factor_t fac, const fq_default_ctx_t ctx) noexcept - # Initialises ``fac`` for use. An :type:`fq_default_poly_factor_t` - # represents a polynomial in factorised form as a product of - # polynomials with associated exponents. - void fq_default_poly_factor_clear(fq_default_poly_factor_t fac, const fq_default_ctx_t ctx) noexcept - # Frees all memory associated with ``fac``. - void fq_default_poly_factor_realloc(fq_default_poly_factor_t fac, slong alloc, const fq_default_ctx_t ctx) noexcept - # Reallocates the factor structure to provide space for - # precisely ``alloc`` factors. - void fq_default_poly_factor_fit_length(fq_default_poly_factor_t fac, slong len, const fq_default_ctx_t ctx) noexcept - # Ensures that the factor structure has space for at least - # ``len`` factors. This function takes care of the case of - # repeated calls by always at least doubling the number of factors - # the structure can hold. - void fq_default_poly_factor_set(fq_default_poly_factor_t res, const fq_default_poly_factor_t fac, const fq_default_ctx_t ctx) noexcept - # Sets ``res`` to the same factorisation as ``fac``. - void fq_default_poly_factor_print_pretty(const fq_default_poly_factor_t fac, const char * var, const fq_default_ctx_t ctx) noexcept - # Pretty-prints the entries of ``fac`` to standard output. - void fq_default_poly_factor_print(const fq_default_poly_factor_t fac, const fq_default_ctx_t ctx) noexcept - # Prints the entries of ``fac`` to standard output. - void fq_default_poly_factor_insert(fq_default_poly_factor_t fac, const fq_default_poly_t poly, slong exp, const fq_default_ctx_t ctx) noexcept - # Inserts the factor ``poly`` with multiplicity ``exp`` into - # the factorisation ``fac``. - # If ``fac`` already contains ``poly``, then ``exp`` simply - # gets added to the exponent of the existing entry. - void fq_default_poly_factor_concat(fq_default_poly_factor_t res, const fq_default_poly_factor_t fac, const fq_default_ctx_t ctx) noexcept - # Concatenates two factorisations. - # This is equivalent to calling :func:`fq_default_poly_factor_insert` - # repeatedly with the individual factors of ``fac``. - # Does not support aliasing between ``res`` and ``fac``. - void fq_default_poly_factor_pow(fq_default_poly_factor_t fac, slong exp, const fq_default_ctx_t ctx) noexcept - # Raises ``fac`` to the power ``exp``. - ulong fq_default_poly_remove(fq_default_poly_t f, const fq_default_poly_t p, const fq_default_ctx_t ctx) noexcept - # Removes the highest possible power of ``p`` from ``f`` and - # returns the exponent. - slong fq_default_poly_factor_length(fq_default_poly_factor_t fac, const fq_default_ctx_t ctx) noexcept - # Return the number of factors, not including the unit. - void fq_default_poly_factor_get_poly(fq_default_poly_t poly, const fq_default_poly_factor_t fac, slong i, const fq_default_ctx_t ctx) noexcept - # Set ``poly`` to factor ``i`` of ``fac`` (numbering starts at zero). - slong fq_default_poly_factor_exp(fq_default_poly_factor_t fac, slong i, const fq_default_ctx_t ctx) noexcept - # Return the exponent of factor ``i`` of ``fac``. - bint fq_default_poly_is_irreducible(const fq_default_poly_t f, const fq_default_ctx_t ctx) noexcept - # Returns 1 if the polynomial ``f`` is irreducible, otherwise returns 0. - bint fq_default_poly_is_squarefree(const fq_default_poly_t f, const fq_default_ctx_t ctx) noexcept - # Returns 1 if ``f`` is squarefree, and 0 otherwise. As a special - # case, the zero polynomial is not considered squarefree. - void fq_default_poly_factor_equal_deg(fq_default_poly_factor_t factors, const fq_default_poly_t pol, slong d, const fq_default_ctx_t ctx) noexcept - # Assuming ``pol`` is a product of irreducible factors all of - # degree ``d``, finds all those factors and places them in - # factors. Requires that ``pol`` be monic, non-constant and - # squarefree. - void fq_default_poly_factor_split_single(fq_default_poly_t linfactor, const fq_default_poly_t input, const fq_default_ctx_t ctx) noexcept - # Assuming ``input`` is a product of factors all of degree 1, finds a single - # linear factor of ``input`` and places it in ``linfactor``. - # Requires that ``input`` be monic and non-constant. - void fq_default_poly_factor_distinct_deg(fq_default_poly_factor_t res, const fq_default_poly_t poly, slong * const * degs, const fq_default_ctx_t ctx) noexcept - # Factorises a monic non-constant squarefree polynomial ``poly`` - # of degree `n` into factors `f[d]` such that for `1 \leq d \leq n` - # `f[d]` is the product of the monic irreducible factors of - # ``poly`` of degree `d`. Factors are stored in ``res``, - # associated powers of irreducible polynomials are stored in - # ``degs`` in the same order as factors. - # Requires that ``degs`` have enough space for irreducible polynomials' - # powers (maximum space required is ``n * sizeof(slong)``). - void fq_default_poly_factor_squarefree(fq_default_poly_factor_t res, const fq_default_poly_t f, const fq_default_ctx_t ctx) noexcept - # Sets ``res`` to a squarefree factorization of ``f``. - void fq_default_poly_factor(fq_default_poly_factor_t res, fq_default_t lead, const fq_default_poly_t f, const fq_default_ctx_t ctx) noexcept - # Factorises a non-constant polynomial ``f`` into monic - # irreducible factors choosing the best algorithm for given modulo - # and degree. The output ``lead`` is set to the leading coefficient of `f` - # upon return. Choice of algorithm is based on heuristic measurements. - void fq_default_poly_roots(fq_default_poly_factor_t r, const fq_default_poly_t f, int with_multiplicity, const fq_default_ctx_t ctx) noexcept - # Fill `r` with factors of the form `x - r_i` where the `r_i` are the distinct roots of a nonzero `f` in `F_q`. - # If `with\_multiplicity` is zero, the exponent `e_i` of the factor `x - r_i` is `1`. Otherwise, it is the largest `e_i` such that `(x-r_i)^e_i` divides `f`. - # This function throws if `f` is zero, but is otherwise always successful. diff --git a/src/sage/libs/flint/fq_embed.pxd b/src/sage/libs/flint/fq_embed.pxd index aa8a5b33015..4f14b164d02 100644 --- a/src/sage/libs/flint/fq_embed.pxd +++ b/src/sage/libs/flint/fq_embed.pxd @@ -2,7 +2,9 @@ # distutils: depends = flint/fq_embed.h ################################################################################ -# This file is auto-generated. Do not modify by hand +# This file is auto-generated by the script +# SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py. +# Do not modify by hand! Fix and rerun the script instead. ################################################################################ from libc.stdio cimport FILE @@ -11,87 +13,14 @@ from sage.libs.mpfr.types cimport * from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void fq_embed_gens(fq_t gen_sub, fq_t gen_sup, fmpz_mod_poly_t minpoly, const fq_ctx_t sub_ctx, const fq_ctx_t sup_ctx) noexcept - # Given two contexts ``sub_ctx`` and ``sup_ctx``, such that - # ``degree(sub_ctx)`` divides ``degree(sup_ctx)``, compute: - # * an element ``gen_sub`` in ``sub_ctx`` such that - # ``gen_sub`` generates the finite field defined by - # ``sub_ctx``, - # * its minimal polynomial ``minpoly``, - # * a root ``gen_sup`` of ``minpoly`` inside the field - # defined by ``sup_ctx``. - # These data uniquely define an embedding of ``sub_ctx`` into - # ``sup_ctx``. - void _fq_embed_gens_naive(fq_t gen_sub, fq_t gen_sup, fmpz_mod_poly_t minpoly, const fq_ctx_t sub_ctx, const fq_ctx_t sup_ctx) noexcept - # Given two contexts ``sub_ctx`` and ``sup_ctx``, such that - # ``degree(sub_ctx)`` divides ``degree(sup_ctx)``, compute an - # embedding of ``sub_ctx`` into ``sup_ctx`` defined as follows: - # * ``gen_sub`` is the canonical generator of ``sup_ctx`` - # (i.e., the class of `X`), - # * ``minpoly`` is the defining polynomial of ``sub_ctx``, - # * ``gen_sup`` is a root of ``minpoly`` inside the field - # defined by ``sup_ctx``. - void fq_embed_matrices(fmpz_mod_mat_t embed, fmpz_mod_mat_t project, const fq_t gen_sub, const fq_ctx_t sub_ctx, const fq_t gen_sup, const fq_ctx_t sup_ctx, const fmpz_mod_poly_t gen_minpoly) noexcept - # Given: - # * two contexts ``sub_ctx`` and ``sup_ctx``, of - # respective degrees `m` and `n`, such that `m` divides `n`; - # * a generator ``gen_sub`` of ``sub_ctx``, its minimal - # polynomial ``gen_minpoly``, and a root ``gen_sup`` of - # ``gen_minpoly`` in ``sup_ctx``, as returned by - # :func:`fq_embed_gens`; - # Compute: - # * the `n\times m` matrix ``embed`` mapping ``gen_sub`` - # to ``gen_sup``, and all their powers accordingly; - # * an `m\times n` matrix ``project`` such that - # ``project`` `\times` ``embed`` is the `m\times m` identity - # matrix. - void fq_embed_trace_matrix(fmpz_mod_mat_t res, const fmpz_mod_mat_t basis, const fq_ctx_t sub_ctx, const fq_ctx_t sup_ctx) noexcept - # Given: - # * two contexts ``sub_ctx`` and ``sup_ctx``, of degrees - # `m` and `n`, such that `m` divides `n`; - # * an `n\times m` matrix ``basis`` that maps ``sub_ctx`` - # to an isomorphic subfield in ``sup_ctx``; - # Compute the `m\times n` matrix of the trace from ``sup_ctx`` to - # ``sub_ctx``. - # This matrix is computed as - # ``embed_dual_to_mono_matrix(_, sub_ctx)`` - # `\times` ``basis``:sup:`t` `\times` - # ``embed_mono_to_dual_matrix(_, sup_ctx)``. - # **Note:** if - # `m=n`, ``basis`` represents a Frobenius, and the result is its - # inverse matrix. - void fq_embed_composition_matrix(fmpz_mod_mat_t matrix, const fq_t gen, const fq_ctx_t ctx) noexcept - # Compute the *composition matrix* of ``gen``. - # For an element `a\in\mathbf{F}_{p^n}`, its composition matrix is the - # matrix whose columns are `a^0, a^1, \ldots, a^{n-1}`. - void fq_embed_composition_matrix_sub(fmpz_mod_mat_t matrix, const fq_t gen, const fq_ctx_t ctx, slong trunc) noexcept - # Compute the *composition matrix* of ``gen``, truncated to - # ``trunc`` columns. - void fq_embed_mul_matrix(fmpz_mod_mat_t matrix, const fq_t gen, const fq_ctx_t ctx) noexcept - # Compute the *multiplication matrix* of ``gen``. - # For an element `a` in `\mathbf{F}_{p^n}=\mathbf{F}_p[x]`, its - # multiplication matrix is the matrix whose columns are `a, ax, - # \dots, ax^{n-1}`. - void fq_embed_mono_to_dual_matrix(fmpz_mod_mat_t res, const fq_ctx_t ctx) noexcept - # Compute the change of basis matrix from the monomial basis of - # ``ctx`` to its dual basis. - void fq_embed_dual_to_mono_matrix(fmpz_mod_mat_t res, const fq_ctx_t ctx) noexcept - # Compute the change of basis matrix from the dual basis of - # ``ctx`` to its monomial basis. - void fq_modulus_pow_series_inv(fmpz_mod_poly_t res, const fq_ctx_t ctx, slong trunc) noexcept - # Compute the power series inverse of the reverse of the modulus of - # ``ctx`` up to `O(x^\texttt{trunc})`. - void fq_modulus_derivative_inv(fq_t m_prime, fq_t m_prime_inv, const fq_ctx_t ctx) noexcept - # Compute the derivative ``m_prime`` of the modulus of ``ctx`` - # as an element of ``ctx``, and its inverse ``m_prime_inv``. diff --git a/src/sage/libs/flint/fq_mat.pxd b/src/sage/libs/flint/fq_mat.pxd index a0aba3868ff..72fa6c63e15 100644 --- a/src/sage/libs/flint/fq_mat.pxd +++ b/src/sage/libs/flint/fq_mat.pxd @@ -2,7 +2,9 @@ # distutils: depends = flint/fq_mat.h ################################################################################ -# This file is auto-generated. Do not modify by hand +# This file is auto-generated by the script +# SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py. +# Do not modify by hand! Fix and rerun the script instead. ################################################################################ from libc.stdio cimport FILE @@ -11,356 +13,69 @@ from sage.libs.mpfr.types cimport * from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void fq_mat_init(fq_mat_t mat, slong rows, slong cols, const fq_ctx_t ctx) noexcept - # Initialises ``mat`` to a ``rows``-by-``cols`` matrix with - # coefficients in `\mathbf{F}_{q}` given by ``ctx``. All elements - # are set to zero. - void fq_mat_init_set(fq_mat_t mat, const fq_mat_t src, const fq_ctx_t ctx) noexcept - # Initialises ``mat`` and sets its dimensions and elements to - # those of ``src``. - void fq_mat_clear(fq_mat_t mat, const fq_ctx_t ctx) noexcept - # Clears the matrix and releases any memory it used. The matrix - # cannot be used again until it is initialised. This function must be - # called exactly once when finished using an ``fq_mat_t`` object. - void fq_mat_set(fq_mat_t mat, const fq_mat_t src, const fq_ctx_t ctx) noexcept - # Sets ``mat`` to a copy of ``src``. It is assumed - # that ``mat`` and ``src`` have identical dimensions. - fq_struct * fq_mat_entry(const fq_mat_t mat, slong i, slong j) noexcept - # Directly accesses the entry in ``mat`` in row `i` and column `j`, - # indexed from zero. No bounds checking is performed. - void fq_mat_entry_set(fq_mat_t mat, slong i, slong j, const fq_t x, const fq_ctx_t ctx) noexcept - # Sets the entry in ``mat`` in row `i` and column `j` to ``x``. - slong fq_mat_nrows(const fq_mat_t mat, const fq_ctx_t ctx) noexcept - # Returns the number of rows in ``mat``. - slong fq_mat_ncols(const fq_mat_t mat, const fq_ctx_t ctx) noexcept - # Returns the number of columns in ``mat``. - void fq_mat_swap(fq_mat_t mat1, fq_mat_t mat2, const fq_ctx_t ctx) noexcept - # Swaps two matrices. The dimensions of ``mat1`` and ``mat2`` - # are allowed to be different. - void fq_mat_swap_entrywise(fq_mat_t mat1, fq_mat_t mat2, const fq_ctx_t ctx) noexcept - # Swaps two matrices by swapping the individual entries rather than swapping - # the contents of the structs. - void fq_mat_zero(fq_mat_t mat, const fq_ctx_t ctx) noexcept - # Sets all entries of ``mat`` to 0. - void fq_mat_one(fq_mat_t mat, const fq_ctx_t ctx) noexcept - # Sets all the diagonal entries of ``mat`` to 1 and all other entries to 0. - void fq_mat_swap_rows(fq_mat_t mat, slong * perm, slong r, slong s, const fq_ctx_t ctx) noexcept - # Swaps rows ``r`` and ``s`` of ``mat``. If ``perm`` is non-``NULL``, the - # permutation of the rows will also be applied to ``perm``. - void fq_mat_swap_cols(fq_mat_t mat, slong * perm, slong r, slong s, const fq_ctx_t ctx) noexcept - # Swaps columns ``r`` and ``s`` of ``mat``. If ``perm`` is non-``NULL``, the - # permutation of the columns will also be applied to ``perm``. - void fq_mat_invert_rows(fq_mat_t mat, slong * perm, const fq_ctx_t ctx) noexcept - # Swaps rows ``i`` and ``r - i`` of ``mat`` for ``0 <= i < r/2``, where - # ``r`` is the number of rows of ``mat``. If ``perm`` is non-``NULL``, the - # permutation of the rows will also be applied to ``perm``. - void fq_mat_invert_cols(fq_mat_t mat, slong * perm, const fq_ctx_t ctx) noexcept - # Swaps columns ``i`` and ``c - i`` of ``mat`` for ``0 <= i < c/2``, where - # ``c`` is the number of columns of ``mat``. If ``perm`` is non-``NULL``, the - # permutation of the columns will also be applied to ``perm``. - void fq_mat_set_nmod_mat(fq_mat_t mat1, const nmod_mat_t mat2, const fq_ctx_t ctx) noexcept - # Sets the matrix ``mat1`` to the matrix ``mat2``. - void fq_mat_set_fmpz_mod_mat(fq_mat_t mat1, const fmpz_mod_mat_t mat2, const fq_ctx_t ctx) noexcept - # Sets the matrix ``mat1`` to the matrix ``mat2``. - void fq_mat_concat_vertical(fq_mat_t res, const fq_mat_t mat1, const fq_mat_t mat2, const fq_ctx_t ctx) noexcept - # Sets ``res`` to vertical concatenation of (``mat1``, ``mat2``) in that order. Matrix dimensions : ``mat1`` : `m \times n`, ``mat2`` : `k \times n`, ``res`` : `(m + k) \times n`. - void fq_mat_concat_horizontal(fq_mat_t res, const fq_mat_t mat1, const fq_mat_t mat2, const fq_ctx_t ctx) noexcept - # Sets ``res`` to horizontal concatenation of (``mat1``, ``mat2``) in that order. Matrix dimensions : ``mat1`` : `m \times n`, ``mat2`` : `m \times k`, ``res`` : `m \times (n + k)`. - int fq_mat_print_pretty(const fq_mat_t mat, const fq_ctx_t ctx) noexcept - # Pretty-prints ``mat`` to ``stdout``. A header is printed - # followed by the rows enclosed in brackets. - int fq_mat_fprint_pretty(FILE * file, const fq_mat_t mat, const fq_ctx_t ctx) noexcept - # Pretty-prints ``mat`` to ``file``. A header is printed - # followed by the rows enclosed in brackets. - # In case of success, returns a positive value. In case of failure, - # returns a non-positive value. - int fq_mat_print(const fq_mat_t mat, const fq_ctx_t ctx) noexcept - # Prints ``mat`` to ``stdout``. A header is printed followed - # by the rows enclosed in brackets. - int fq_mat_fprint(FILE * file, const fq_mat_t mat, const fq_ctx_t ctx) noexcept - # Prints ``mat`` to ``file``. A header is printed followed by - # the rows enclosed in brackets. - # In case of success, returns a positive value. In case of failure, - # returns a non-positive value. - void fq_mat_window_init(fq_mat_t window, const fq_mat_t mat, slong r1, slong c1, slong r2, slong c2, const fq_ctx_t ctx) noexcept - # Initializes the matrix ``window`` to be an ``r2 - r1`` by - # ``c2 - c1`` submatrix of ``mat`` whose ``(0,0)`` entry - # is the ``(r1, c1)`` entry of ``mat``. The memory for the - # elements of ``window`` is shared with ``mat``. - void fq_mat_window_clear(fq_mat_t window, const fq_ctx_t ctx) noexcept - # Clears the matrix ``window`` and releases any memory that it - # uses. Note that the memory to the underlying matrix that - # ``window`` points to is not freed. - void fq_mat_randtest(fq_mat_t mat, flint_rand_t state, const fq_ctx_t ctx) noexcept - # Sets the elements of ``mat`` to random elements of - # `\mathbf{F}_{q}`, given by ``ctx``. - int fq_mat_randpermdiag(fq_mat_t mat, flint_rand_t state, fq_struct * diag, slong n, const fq_ctx_t ctx) noexcept - # Sets ``mat`` to a random permutation of the diagonal matrix - # with `n` leading entries given by the vector ``diag``. It is - # assumed that the main diagonal of ``mat`` has room for at - # least `n` entries. - # Returns `0` or `1`, depending on whether the permutation is even - # or odd respectively. - void fq_mat_randrank(fq_mat_t mat, flint_rand_t state, slong rank, const fq_ctx_t ctx) noexcept - # Sets ``mat`` to a random sparse matrix with the given rank, - # having exactly as many non-zero elements as the rank, with the - # non-zero elements being uniformly random elements of - # `\mathbf{F}_{q}`. - # The matrix can be transformed into a dense matrix with unchanged - # rank by subsequently calling :func:`fq_mat_randops`. - void fq_mat_randops(fq_mat_t mat, slong count, flint_rand_t state, const fq_ctx_t ctx) noexcept - # Randomises ``mat`` by performing elementary row or column - # operations. More precisely, at most ``count`` random additions - # or subtractions of distinct rows and columns will be performed. - # This leaves the rank (and for square matrices, determinant) - # unchanged. - void fq_mat_randtril(fq_mat_t mat, flint_rand_t state, int unit, const fq_ctx_t ctx) noexcept - # Sets ``mat`` to a random lower triangular matrix. If - # ``unit`` is 1, it will have ones on the main diagonal, - # otherwise it will have random nonzero entries on the main - # diagonal. - void fq_mat_randtriu(fq_mat_t mat, flint_rand_t state, int unit, const fq_ctx_t ctx) noexcept - # Sets ``mat`` to a random upper triangular matrix. If - # ``unit`` is 1, it will have ones on the main diagonal, - # otherwise it will have random nonzero entries on the main - # diagonal. - bint fq_mat_equal(const fq_mat_t mat1, const fq_mat_t mat2, const fq_ctx_t ctx) noexcept - # Returns nonzero if mat1 and mat2 have the same dimensions and elements, - # and zero otherwise. - bint fq_mat_is_zero(const fq_mat_t mat, const fq_ctx_t ctx) noexcept - # Returns a non-zero value if all entries of ``mat`` are zero, and - # otherwise returns zero. - bint fq_mat_is_one(const fq_mat_t mat, const fq_ctx_t ctx) noexcept - # Returns a non-zero value if all entries ``mat`` are zero except the - # diagonal entries which must be one, otherwise returns zero.. - bint fq_mat_is_empty(const fq_mat_t mat, const fq_ctx_t ctx) noexcept - # Returns a non-zero value if the number of rows or the number of - # columns in ``mat`` is zero, and otherwise returns zero. - bint fq_mat_is_square(const fq_mat_t mat, const fq_ctx_t ctx) noexcept - # Returns a non-zero value if the number of rows is equal to the - # number of columns in ``mat``, and otherwise returns zero. - void fq_mat_add(fq_mat_t C, const fq_mat_t A, const fq_mat_t B, const fq_ctx_t ctx) noexcept - # Computes `C = A + B`. Dimensions must be identical. - void fq_mat_sub(fq_mat_t C, const fq_mat_t A, const fq_mat_t B, const fq_ctx_t ctx) noexcept - # Computes `C = A - B`. Dimensions must be identical. - void fq_mat_neg(fq_mat_t A, const fq_mat_t B, const fq_ctx_t ctx) noexcept - # Sets `B = -A`. Dimensions must be identical. - void fq_mat_mul(fq_mat_t C, const fq_mat_t A, const fq_mat_t B, const fq_ctx_t ctx) noexcept - # Sets `C = AB`. Dimensions must be compatible for matrix - # multiplication. Aliasing is allowed. This function automatically chooses - # between classical and KS multiplication. - void fq_mat_mul_classical(fq_mat_t C, const fq_mat_t A, const fq_mat_t B, const fq_ctx_t ctx) noexcept - # Sets `C = AB`. Dimensions must be compatible for matrix multiplication. - # `C` is not allowed to be aliased with `A` or `B`. Uses classical - # matrix multiplication. - void fq_mat_mul_KS(fq_mat_t C, const fq_mat_t A, const fq_mat_t B, const fq_ctx_t ctx) noexcept - # Sets `C = AB`. Dimensions must be compatible for matrix - # multiplication. `C` is not allowed to be aliased with `A` or - # `B`. Uses Kronecker substitution to perform the multiplication - # over the integers. - void fq_mat_submul(fq_mat_t D, const fq_mat_t C, const fq_mat_t A, const fq_mat_t B, const fq_ctx_t ctx) noexcept - # Sets `D = C + AB`. `C` and `D` may be aliased with each other but - # not with `A` or `B`. - void fq_mat_mul_vec(fq_struct * c, const fq_mat_t A, const fq_struct * b, slong blen, const fq_ctx_t ctx) noexcept void fq_mat_mul_vec_ptr(fq_struct * const * c, const fq_mat_t A, const fq_struct * const * b, slong blen, const fq_ctx_t ctx) noexcept - # Compute a matrix-vector product of ``A`` and ``(b, blen)`` and store the result in ``c``. - # The vector ``(b, blen)`` is either truncated or zero-extended to the number of columns of ``A``. - # The number entries written to ``c`` is always equal to the number of rows of ``A``. - void fq_mat_vec_mul(fq_struct * c, const fq_struct * a, slong alen, const fq_mat_t B, const fq_ctx_t ctx) noexcept void fq_mat_vec_mul_ptr(fq_struct * const * c, const fq_struct * const * a, slong alen, const fq_mat_t B, const fq_ctx_t ctx) noexcept - # Compute a vector-matrix product of ``(a, alen)`` and ``B`` and and store the result in ``c``. - # The vector ``(a, alen)`` is either truncated or zero-extended to the number of rows of ``B``. - # The number entries written to ``c`` is always equal to the number of columns of ``B``. - int fq_mat_inv(fq_mat_t B, fq_mat_t A, const fq_ctx_t ctx) noexcept - # Sets `B = A^{-1}` and returns `1` if `A` is invertible. If `A` is singular, - # returns `0` and sets the elements of `B` to undefined values. - # `A` and `B` must be square matrices with the same dimensions. - slong fq_mat_lu(slong * P, fq_mat_t A, int rank_check, const fq_ctx_t ctx) noexcept - # Computes a generalised LU decomposition `LU = PA` of a given - # matrix `A`, returning the rank of `A`. - # If `A` is a nonsingular square matrix, it will be overwritten with - # a unit diagonal lower triangular matrix `L` and an upper - # triangular matrix `U` (the diagonal of `L` will not be stored - # explicitly). - # If `A` is an arbitrary matrix of rank `r`, `U` will be in row - # echelon form having `r` nonzero rows, and `L` will be lower - # triangular but truncated to `r` columns, having implicit ones on - # the `r` first entries of the main diagonal. All other entries will - # be zero. - # If a nonzero value for ``rank_check`` is passed, the function - # will abandon the output matrix in an undefined state and return 0 - # if `A` is detected to be rank-deficient. - # This function calls ``fq_mat_lu_recursive``. - slong fq_mat_lu_classical(slong * P, fq_mat_t A, int rank_check, const fq_ctx_t ctx) noexcept - # Computes a generalised LU decomposition `LU = PA` of a given - # matrix `A`, returning the rank of `A`. The behavior of this - # function is identical to that of ``fq_mat_lu``. Uses Gaussian - # elimination. - slong fq_mat_lu_recursive(slong * P, fq_mat_t A, int rank_check, const fq_ctx_t ctx) noexcept - # Computes a generalised LU decomposition `LU = PA` of a given - # matrix `A`, returning the rank of `A`. The behavior of this - # function is identical to that of ``fq_mat_lu``. Uses recursive - # block decomposition, switching to classical Gaussian elimination - # for sufficiently small blocks. - slong fq_mat_rref(fq_mat_t A, const fq_ctx_t ctx) noexcept - # Puts `A` in reduced row echelon form and returns the rank of `A`. - # The rref is computed by first obtaining an unreduced row echelon - # form via LU decomposition and then solving an additional - # triangular system. - slong fq_mat_reduce_row(fq_mat_t A, slong * P, slong * L, slong n, const fq_ctx_t ctx) noexcept - # Reduce row n of the matrix `A`, assuming the prior rows are in Gauss - # form. However those rows may not be in order. The entry `i` of the array - # `P` is the row of `A` which has a pivot in the `i`-th column. If no such - # row exists, the entry of `P` will be `-1`. The function returns the column - # in which the `n`-th row has a pivot after reduction. This will always be - # chosen to be the first available column for a pivot from the left. This - # information is also updated in `P`. Entry `i` of the array `L` contains the - # number of possibly nonzero columns of `A` row `i`. This speeds up reduction - # in the case that `A` is chambered on the right. Otherwise the entries of - # `L` can all be set to the number of columns of `A`. We require the entries - # of `L` to be monotonic increasing. - void fq_mat_solve_tril(fq_mat_t X, const fq_mat_t L, const fq_mat_t B, int unit, const fq_ctx_t ctx) noexcept - # Sets `X = L^{-1} B` where `L` is a full rank lower triangular - # square matrix. If ``unit`` = 1, `L` is assumed to have ones on - # its main diagonal, and the main diagonal will not be read. `X` - # and `B` are allowed to be the same matrix, but no other aliasing - # is allowed. Automatically chooses between the classical and - # recursive algorithms. - void fq_mat_solve_tril_classical(fq_mat_t X, const fq_mat_t L, const fq_mat_t B, int unit, const fq_ctx_t ctx) noexcept - # Sets `X = L^{-1} B` where `L` is a full rank lower triangular - # square matrix. If ``unit`` = 1, `L` is assumed to have ones on - # its main diagonal, and the main diagonal will not be read. `X` - # and `B` are allowed to be the same matrix, but no other aliasing - # is allowed. Uses forward substitution. - void fq_mat_solve_tril_recursive(fq_mat_t X, const fq_mat_t L, const fq_mat_t B, int unit, const fq_ctx_t ctx) noexcept - # Sets `X = L^{-1} B` where `L` is a full rank lower triangular - # square matrix. If ``unit`` = 1, `L` is assumed to have ones on - # its main diagonal, and the main diagonal will not be read. `X` - # and `B` are allowed to be the same matrix, but no other aliasing - # is allowed. - # Uses the block inversion formula - # .. math :: - # \begin{pmatrix} A & 0 \\ C & D \end{pmatrix}^{-1} - # \begin{pmatrix} X \\ Y \end{pmatrix} = - # \begin{pmatrix} A^{-1} X \\ D^{-1} ( Y - C A^{-1} X ) \end{pmatrix} - # to reduce the problem to matrix multiplication and triangular - # solving of smaller systems. - void fq_mat_solve_triu(fq_mat_t X, const fq_mat_t U, const fq_mat_t B, int unit, const fq_ctx_t ctx) noexcept - # Sets `X = U^{-1} B` where `U` is a full rank upper triangular - # square matrix. If ``unit`` = 1, `U` is assumed to have ones on - # its main diagonal, and the main diagonal will not be read. `X` - # and `B` are allowed to be the same matrix, but no other aliasing - # is allowed. Automatically chooses between the classical and - # recursive algorithms. - void fq_mat_solve_triu_classical(fq_mat_t X, const fq_mat_t U, const fq_mat_t B, int unit, const fq_ctx_t ctx) noexcept - # Sets `X = U^{-1} B` where `U` is a full rank upper triangular - # square matrix. If ``unit`` = 1, `U` is assumed to have ones on - # its main diagonal, and the main diagonal will not be read. `X` - # and `B` are allowed to be the same matrix, but no other aliasing - # is allowed. Uses forward substitution. - void fq_mat_solve_triu_recursive(fq_mat_t X, const fq_mat_t U, const fq_mat_t B, int unit, const fq_ctx_t ctx) noexcept - # Sets `X = U^{-1} B` where `U` is a full rank upper triangular - # square matrix. If ``unit`` = 1, `U` is assumed to have ones on - # its main diagonal, and the main diagonal will not be read. `X` - # and `B` are allowed to be the same matrix, but no other aliasing - # is allowed. - # Uses the block inversion formula - # .. math :: - # \begin{pmatrix} A & B \\ 0 & D \end{pmatrix}^{-1} - # \begin{pmatrix} X \\ Y \end{pmatrix} = - # \begin{pmatrix} A^{-1} (X - B D^{-1} Y) \\ D^{-1} Y \end{pmatrix} - # to reduce the problem to matrix multiplication and triangular - # solving of smaller systems. - int fq_mat_solve(fq_mat_t X, const fq_mat_t A, const fq_mat_t B, const fq_ctx_t ctx) noexcept - # Solves the matrix-matrix equation `AX = B`. - # Returns `1` if `A` has full rank; otherwise returns `0` and sets the - # elements of `X` to undefined values. - # The matrix `A` must be square. - int fq_mat_can_solve(fq_mat_t X, const fq_mat_t A, const fq_mat_t B, const fq_ctx_t ctx) noexcept - # Solves the matrix-matrix equation `AX = B` over `Fq`. - # Returns `1` if a solution exists; otherwise returns `0` and sets the - # elements of `X` to zero. If more than one solution exists, one of the - # valid solutions is given. - # There are no restrictions on the shape of `A` and it may be singular. - void fq_mat_similarity(fq_mat_t M, slong r, fq_t d, const fq_ctx_t ctx) noexcept - # Applies a similarity transform to the `n\times n` matrix `M` in-place. - # If `P` is the `n\times n` identity matrix the zero entries of whose row - # `r` (`0`-indexed) have been replaced by `d`, this transform is equivalent - # to `M = P^{-1}MP`. - # Similarity transforms preserve the determinant, characteristic polynomial - # and minimal polynomial. - # The value `d` is required to be reduced modulo the modulus of the entries - # in the matrix. - void fq_mat_charpoly_danilevsky(fq_poly_t p, const fq_mat_t M, const fq_ctx_t ctx) noexcept - # Compute the characteristic polynomial `p` of the matrix `M`. The matrix - # is assumed to be square. - void fq_mat_charpoly(fq_poly_t p, const fq_mat_t M, const fq_ctx_t ctx) noexcept - # Compute the characteristic polynomial `p` of the matrix `M`. The matrix - # is required to be square, otherwise an exception is raised. - void fq_mat_minpoly(fq_poly_t p, const fq_mat_t M, const fq_ctx_t ctx) noexcept - # Compute the minimal polynomial `p` of the matrix `M`. The matrix - # is required to be square, otherwise an exception is raised. diff --git a/src/sage/libs/flint/fq_nmod.pxd b/src/sage/libs/flint/fq_nmod.pxd index f87d0cb2b50..83085408d29 100644 --- a/src/sage/libs/flint/fq_nmod.pxd +++ b/src/sage/libs/flint/fq_nmod.pxd @@ -2,7 +2,9 @@ # distutils: depends = flint/fq_nmod.h ################################################################################ -# This file is auto-generated. Do not modify by hand +# This file is auto-generated by the script +# SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py. +# Do not modify by hand! Fix and rerun the script instead. ################################################################################ from libc.stdio cimport FILE @@ -11,347 +13,81 @@ from sage.libs.mpfr.types cimport * from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - - void fq_nmod_ctx_init(fq_nmod_ctx_t ctx, const fmpz_t p, slong d, const char *var) noexcept - # Initialises the context for prime `p` and extension degree `d`, - # with name ``var`` for the generator. By default, it will try - # use a Conway polynomial; if one is not available, a random - # irreducible polynomial will be used. - # Assumes that `p` is a prime. - # Assumes that the string ``var`` is a null-terminated string - # of length at least one. - - int _fq_nmod_ctx_init_conway(fq_nmod_ctx_t ctx, const fmpz_t p, slong d, const char *var) noexcept - # Attempts to initialise the context for prime `p` and extension - # degree `d`, with name ``var`` for the generator using a Conway - # polynomial for the modulus. - # Returns `1` if the Conway polynomial is in the database for the - # given size and the initialization is successful; otherwise, - # returns `0`. - # Assumes that `p` is a prime. - # Assumes that the string ``var`` is a null-terminated string - # of length at least one. - - void fq_nmod_ctx_init_conway(fq_nmod_ctx_t ctx, const fmpz_t p, slong d, const char *var) noexcept - # Initialises the context for prime `p` and extension degree `d`, - # with name ``var`` for the generator using a Conway polynomial - # for the modulus. - # Assumes that `p` is a prime. - # Assumes that the string ``var`` is a null-terminated string - # of length at least one. - - void fq_nmod_ctx_init_modulus(fq_nmod_ctx_t ctx, const nmod_poly_t modulus, const char *var) noexcept - # Initialises the context for given ``modulus`` with name - # ``var`` for the generator. - # Assumes that ``modulus`` is an irreducible polynomial over - # `\mathbf{F}_{p}`. - # Assumes that the string ``var`` is a null-terminated string - # of length at least one. - + void fq_nmod_ctx_init(fq_nmod_ctx_t ctx, const fmpz_t p, slong d, const char * var) noexcept + int _fq_nmod_ctx_init_conway(fq_nmod_ctx_t ctx, const fmpz_t p, slong d, const char * var) noexcept + void fq_nmod_ctx_init_conway(fq_nmod_ctx_t ctx, const fmpz_t p, slong d, const char * var) noexcept + void fq_nmod_ctx_init_modulus(fq_nmod_ctx_t ctx, const nmod_poly_t modulus, const char * var) noexcept void fq_nmod_ctx_clear(fq_nmod_ctx_t ctx) noexcept - # Clears all memory that has been allocated as part of the context. - const nmod_poly_struct* fq_nmod_ctx_modulus(const fq_nmod_ctx_t ctx) noexcept - # Returns a pointer to the modulus in the context. - slong fq_nmod_ctx_degree(const fq_nmod_ctx_t ctx) noexcept - # Returns the degree of the field extension - # `[\mathbf{F}_{q} : \mathbf{F}_{p}]`, which - # is equal to `\log_{p} q`. - fmpz * fq_nmod_ctx_prime(const fq_nmod_ctx_t ctx) noexcept - # Returns a pointer to the prime `p` in the context. - void fq_nmod_ctx_order(fmpz_t f, const fq_nmod_ctx_t ctx) noexcept - # Sets `f` to be the size of the finite field. - int fq_nmod_ctx_fprint(FILE * file, const fq_nmod_ctx_t ctx) noexcept - # Prints the context information to ``file``. Returns 1 for a - # success and a negative number for an error. - void fq_nmod_ctx_print(const fq_nmod_ctx_t ctx) noexcept - # Prints the context information to ``stdout``. - void fq_nmod_ctx_randtest(fq_nmod_ctx_t ctx, flint_rand_t state) noexcept - # Initializes ``ctx`` to a random finite field. Assumes that - # ``fq_nmod_ctx_init`` has not been called on ``ctx`` already. - void fq_nmod_ctx_randtest_reducible(fq_nmod_ctx_t ctx, flint_rand_t state) noexcept - # Initializes ``ctx`` to a random extension of a word-sized prime - # field. The modulus may or may not be irreducible. Assumes that - # ``fq_nmod_ctx_init`` has not been called on ``ctx`` already. - void fq_nmod_init(fq_nmod_t rop, const fq_nmod_ctx_t ctx) noexcept - # Initialises the element ``rop``, setting its value to `0`. Currently, the behaviour is identical to ``fq_nmod_init2``, as it also ensures ``rop`` has enough space for it to be an element of ``ctx``, this may change in the future. - void fq_nmod_init2(fq_nmod_t rop, const fq_nmod_ctx_t ctx) noexcept - # Initialises ``rop`` with at least enough space for it to be an element - # of ``ctx`` and sets it to `0`. - void fq_nmod_clear(fq_nmod_t rop, const fq_nmod_ctx_t ctx) noexcept - # Clears the element ``rop``. - void _fq_nmod_sparse_reduce(mp_limb_t * R, slong lenR, const fq_nmod_ctx_t ctx) noexcept - # Reduces ``(R, lenR)`` modulo the polynomial `f` given by the - # modulus of ``ctx``. - void _fq_nmod_dense_reduce(mp_limb_t * R, slong lenR, const fq_nmod_ctx_t ctx) noexcept - # Reduces ``(R, lenR)`` modulo the polynomial `f` given by the - # modulus of ``ctx`` using Newton division. - void _fq_nmod_reduce(mp_limb_t * r, slong lenR, const fq_nmod_ctx_t ctx) noexcept - # Reduces ``(R, lenR)`` modulo the polynomial `f` given by the - # modulus of ``ctx``. Does either sparse or dense reduction - # based on ``ctx->sparse_modulus``. - void fq_nmod_reduce(fq_nmod_t rop, const fq_nmod_ctx_t ctx) noexcept - # Reduces the polynomial ``rop`` as an element of - # `\mathbf{F}_p[X] / (f(X))`. - void fq_nmod_add(fq_nmod_t rop, const fq_nmod_t op1, const fq_nmod_t op2, const fq_nmod_ctx_t ctx) noexcept - # Sets ``rop`` to the sum of ``op1`` and ``op2``. - void fq_nmod_sub(fq_nmod_t rop, const fq_nmod_t op1, const fq_nmod_t op2, const fq_nmod_ctx_t ctx) noexcept - # Sets ``rop`` to the difference of ``op1`` and ``op2``. - void fq_nmod_sub_one(fq_nmod_t rop, const fq_nmod_t op1, const fq_nmod_ctx_t ctx) noexcept - # Sets ``rop`` to the difference of ``op1`` and `1`. - void fq_nmod_neg(fq_nmod_t rop, const fq_nmod_t op, const fq_nmod_ctx_t ctx) noexcept - # Sets ``rop`` to the negative of ``op``. - void fq_nmod_mul(fq_nmod_t rop, const fq_nmod_t op1, const fq_nmod_t op2, const fq_nmod_ctx_t ctx) noexcept - # Sets ``rop`` to the product of ``op1`` and ``op2``, - # reducing the output in the given context. - void fq_nmod_mul_fmpz(fq_nmod_t rop, const fq_nmod_t op, const fmpz_t x, const fq_nmod_ctx_t ctx) noexcept - # Sets ``rop`` to the product of ``op`` and `x`, - # reducing the output in the given context. - void fq_nmod_mul_si(fq_nmod_t rop, const fq_nmod_t op, slong x, const fq_nmod_ctx_t ctx) noexcept - # Sets ``rop`` to the product of ``op`` and `x`, - # reducing the output in the given context. - void fq_nmod_mul_ui(fq_nmod_t rop, const fq_nmod_t op, ulong x, const fq_nmod_ctx_t ctx) noexcept - # Sets ``rop`` to the product of ``op`` and `x`, - # reducing the output in the given context. - void fq_nmod_sqr(fq_nmod_t rop, const fq_nmod_t op, const fq_nmod_ctx_t ctx) noexcept - # Sets ``rop`` to the square of ``op``, - # reducing the output in the given context. - void _fq_nmod_inv(mp_ptr * rop, mp_srcptr * op, slong len, const fq_nmod_ctx_t ctx) noexcept - # Sets ``(rop, d)`` to the inverse of the non-zero element - # ``(op, len)``. - void fq_nmod_inv(fq_nmod_t rop, const fq_nmod_t op, const fq_nmod_ctx_t ctx) noexcept - # Sets ``rop`` to the inverse of the non-zero element ``op``. - void fq_nmod_gcdinv(fq_nmod_t f, fq_nmod_t inv, const fq_nmod_t op, const fq_nmod_ctx_t ctx) noexcept - # Sets ``inv`` to be the inverse of ``op`` modulo the modulus - # of ``ctx``. If ``op`` is not invertible, then ``f`` is - # set to a factor of the modulus; otherwise, it is set to one. - void _fq_nmod_pow(mp_limb_t * rop, const mp_limb_t * op, slong len, const fmpz_t e, const fq_nmod_ctx_t ctx) noexcept - # Sets ``(rop, 2*d-1)`` to ``(op,len)`` raised to the power `e`, - # reduced modulo `f(X)`, the modulus of ``ctx``. - # Assumes that `e \geq 0` and that ``len`` is positive and at most `d`. - # Although we require that ``rop`` provides space for - # `2d - 1` coefficients, the output will be reduced modulo - # `f(X)`, which is a polynomial of degree `d`. - # Does not support aliasing. - void fq_nmod_pow(fq_nmod_t rop, const fq_nmod_t op, const fmpz_t e, const fq_nmod_ctx_t ctx) noexcept - # Sets ``rop`` to ``op`` raised to the power `e`. - # Currently assumes that `e \geq 0`. - # Note that for any input ``op``, ``rop`` is set to `1` - # whenever `e = 0`. - void fq_nmod_pow_ui(fq_nmod_t rop, const fq_nmod_t op, const ulong e, const fq_nmod_ctx_t ctx) noexcept - # Sets ``rop`` to ``op`` raised to the power `e`. - # Currently assumes that `e \geq 0`. - # Note that for any input ``op``, ``rop`` is set to `1` - # whenever `e = 0`. - int fq_nmod_sqrt(fq_nmod_t rop, const fq_nmod_t op1, const fq_nmod_ctx_t ctx) noexcept - # Sets ``rop`` to the square root of ``op1`` if it is a square, and return - # `1`, otherwise return `0`. - void fq_nmod_pth_root(fq_nmod_t rop, const fq_nmod_t op1, const fq_nmod_ctx_t ctx) noexcept - # Sets ``rop`` to a `p^{\textrm{th}}` root of ``op1``. Currently, - # this computes the root by raising ``op1`` to `p^{d-1}` where - # `d` is the degree of the extension. - bint fq_nmod_is_square(const fq_nmod_t op, const fq_nmod_ctx_t ctx) noexcept - # Return ``1`` if ``op`` is a square. - int fq_nmod_fprint_pretty(FILE * file, const fq_nmod_t op, const fq_nmod_ctx_t ctx) noexcept - # Prints a pretty representation of ``op`` to ``file``. - # In case of success, returns a positive value. In case of failure, - # returns a non-positive value. - void fq_nmod_print_pretty(const fq_nmod_t op, const fq_nmod_ctx_t ctx) noexcept - # Prints a pretty representation of ``op`` to ``stdout``. - # In case of success, returns a positive value. In case of failure, - # returns a non-positive value. - int fq_nmod_fprint(FILE * file, const fq_nmod_t op, const fq_nmod_ctx_t ctx) noexcept - # Prints a representation of ``op`` to ``file``. - # For further details on the representation used, see - # ``nmod_poly_fprint()``. - void fq_nmod_print(const fq_nmod_t op, const fq_nmod_ctx_t ctx) noexcept - # Prints a representation of ``op`` to ``stdout``. - # For further details on the representation used, see - # ``nmod_poly_print()``. - char * fq_nmod_get_str(const fq_nmod_t op, const fq_nmod_ctx_t ctx) noexcept - # Returns the plain FLINT string representation of the element - # ``op``. - char * fq_nmod_get_str_pretty(const fq_nmod_t op, const fq_nmod_ctx_t ctx) noexcept - # Returns a pretty representation of the element ``op`` using the - # null-terminated string ``x`` as the variable name. - void fq_nmod_randtest(fq_nmod_t rop, flint_rand_t state, const fq_nmod_ctx_t ctx) noexcept - # Generates a random element of `\mathbf{F}_q`. - void fq_nmod_randtest_not_zero(fq_nmod_t rop, flint_rand_t state, const fq_nmod_ctx_t ctx) noexcept - # Generates a random non-zero element of `\mathbf{F}_q`. - void fq_nmod_randtest_dense(fq_nmod_t rop, flint_rand_t state, const fq_nmod_ctx_t ctx) noexcept - # Generates a random element of `\mathbf{F}_q` which has an - # underlying polynomial with dense coefficients. - void fq_nmod_rand(fq_nmod_t rop, flint_rand_t state, const fq_nmod_ctx_t ctx) noexcept - # Generates a high quality random element of `\mathbf{F}_q`. - void fq_nmod_rand_not_zero(fq_nmod_t rop, flint_rand_t state, const fq_nmod_ctx_t ctx) noexcept - # Generates a high quality non-zero random element of `\mathbf{F}_q`. - void fq_nmod_set(fq_nmod_t rop, const fq_nmod_t op, const fq_nmod_ctx_t ctx) noexcept - # Sets ``rop`` to ``op``. - void fq_nmod_set_si(fq_nmod_t rop, const slong x, const fq_nmod_ctx_t ctx) noexcept - # Sets ``rop`` to ``x``, considered as an element of - # `\mathbf{F}_p`. - void fq_nmod_set_ui(fq_nmod_t rop, const ulong x, const fq_nmod_ctx_t ctx) noexcept - # Sets ``rop`` to ``x``, considered as an element of - # `\mathbf{F}_p`. - void fq_nmod_set_fmpz(fq_nmod_t rop, const fmpz_t x, const fq_nmod_ctx_t ctx) noexcept - # Sets ``rop`` to ``x``, considered as an element of - # `\mathbf{F}_p`. - void fq_nmod_swap(fq_nmod_t op1, fq_nmod_t op2, const fq_nmod_ctx_t ctx) noexcept - # Swaps the two elements ``op1`` and ``op2``. - void fq_nmod_zero(fq_nmod_t rop, const fq_nmod_ctx_t ctx) noexcept - # Sets ``rop`` to zero. - void fq_nmod_one(fq_nmod_t rop, const fq_nmod_ctx_t ctx) noexcept - # Sets ``rop`` to one, reduced in the given context. - void fq_nmod_gen(fq_nmod_t rop, const fq_nmod_ctx_t ctx) noexcept - # Sets ``rop`` to a generator for the finite field. - # There is no guarantee this is a multiplicative generator of - # the finite field. - int fq_nmod_get_fmpz(fmpz_t rop, const fq_nmod_t op, const fq_nmod_ctx_t ctx) noexcept - # If ``op`` has a lift to the integers, return `1` and set ``rop`` to the lift in `[0,p)`. - # Otherwise, return `0` and leave `rop` undefined. - void fq_nmod_get_nmod_poly(nmod_poly_t a, const fq_nmod_t b, const fq_nmod_ctx_t ctx) noexcept - # Set ``a`` to a representative of ``b`` in ``ctx``. - # The representatives are taken in `(\mathbb{Z}/p\mathbb{Z})[x]/h(x)` where `h(x)` is the defining polynomial in ``ctx``. - void fq_nmod_set_nmod_poly(fq_nmod_t a, const nmod_poly_t b, const fq_nmod_ctx_t ctx) noexcept - # Set ``a`` to the element in ``ctx`` with representative ``b``. - # The representatives are taken in `(\mathbb{Z}/p\mathbb{Z})[x]/h(x)` where `h(x)` is the defining polynomial in ``ctx``. - void fq_nmod_get_nmod_mat(nmod_mat_t col, const fq_nmod_t a, const fq_nmod_ctx_t ctx) noexcept - # Convert ``a`` to a column vector of length ``degree(ctx)``. - void fq_nmod_set_nmod_mat(fq_nmod_t a, const nmod_mat_t col, const fq_nmod_ctx_t ctx) noexcept - # Convert a column vector ``col`` of length ``degree(ctx)`` to an element of ``ctx``. - bint fq_nmod_is_zero(const fq_nmod_t op, const fq_nmod_ctx_t ctx) noexcept - # Returns whether ``op`` is equal to zero. - bint fq_nmod_is_one(const fq_nmod_t op, const fq_nmod_ctx_t ctx) noexcept - # Returns whether ``op`` is equal to one. - bint fq_nmod_equal(const fq_nmod_t op1, const fq_nmod_t op2, const fq_nmod_ctx_t ctx) noexcept - # Returns whether ``op1`` and ``op2`` are equal. - bint fq_nmod_is_invertible(const fq_nmod_t op, const fq_nmod_ctx_t ctx) noexcept - # Returns whether ``op`` is an invertible element. - bint fq_nmod_is_invertible_f(fq_nmod_t f, const fq_nmod_t op, const fq_nmod_ctx_t ctx) noexcept - # Returns whether ``op`` is an invertible element. If it is not, - # then ``f`` is set to a factor of the modulus. - int fq_nmod_cmp(const fq_nmod_t a, const fq_nmod_t b, const fq_nmod_ctx_t ctx) noexcept - # Return ``1`` (resp. ``-1``, or ``0``) if ``a`` is after (resp. before, same as) ``b`` in some arbitrary but fixed total ordering of the elements. - void _fq_nmod_trace(fmpz_t rop, const mp_limb_t * op, slong len, const fq_nmod_ctx_t ctx) noexcept - # Sets ``rop`` to the trace of the non-zero element ``(op, len)`` - # in `\mathbf{F}_{q}`. - void fq_nmod_trace(fmpz_t rop, const fq_nmod_t op, const fq_nmod_ctx_t ctx) noexcept - # Sets ``rop`` to the trace of ``op``. - # For an element `a \in \mathbf{F}_q`, multiplication by `a` defines - # a `\mathbf{F}_p`-linear map on `\mathbf{F}_q`. We define the - # trace of `a` as the trace of this map. Equivalently, if `\Sigma` - # generates `\operatorname{Gal}(\mathbf{F}_q / \mathbf{F}_p)` then the trace of - # `a` is equal to `\sum_{i=0}^{d-1} \Sigma^i (a)`, where `d = - # \log_{p} q`. - void _fq_nmod_norm(fmpz_t rop, const mp_limb_t * op, slong len, const fq_nmod_ctx_t ctx) noexcept - # Sets ``rop`` to the norm of the non-zero element ``(op, len)`` - # in `\mathbf{F}_{q}`. - void fq_nmod_norm(fmpz_t rop, const fq_nmod_t op, const fq_nmod_ctx_t ctx) noexcept - # Computes the norm of ``op``. - # For an element `a \in \mathbf{F}_q`, multiplication by `a` defines - # a `\mathbf{F}_p`-linear map on `\mathbf{F}_q`. We define the norm - # of `a` as the determinant of this map. Equivalently, if `\Sigma` generates - # `\operatorname{Gal}(\mathbf{F}_q / \mathbf{F}_p)` then the trace of `a` is equal to - # `\prod_{i=0}^{d-1} \Sigma^i (a)`, where - # `d = \text{dim}_{\mathbf{F}_p}(\mathbf{F}_q)`. - # Algorithm selection is automatic depending on the input. - void _fq_nmod_frobenius(mp_limb_t * rop, const mp_limb_t * op, slong len, slong e, const fq_nmod_ctx_t ctx) noexcept - # Sets ``(rop, 2d-1)`` to the image of ``(op, len)`` under the - # Frobenius operator raised to the e-th power, assuming that neither - # ``op`` nor ``e`` are zero. - void fq_nmod_frobenius(fq_nmod_t rop, const fq_nmod_t op, slong e, const fq_nmod_ctx_t ctx) noexcept - # Evaluates the homomorphism `\Sigma^e` at ``op``. - # Recall that `\mathbf{F}_q / \mathbf{F}_p` is Galois with Galois group - # `\langle \sigma \rangle`, which is also isomorphic to - # `\mathbf{Z}/d\mathbf{Z}`, where - # `\sigma \in \operatorname{Gal}(\mathbf{F}_q/\mathbf{F}_p)` is the Frobenius element - # `\sigma \colon x \mapsto x^p`. - int fq_nmod_multiplicative_order(fmpz * ord, const fq_nmod_t op, const fq_nmod_ctx_t ctx) noexcept - # Computes the order of ``op`` as an element of the - # multiplicative group of ``ctx``. - # Returns 0 if ``op`` is 0, otherwise it returns 1 if ``op`` - # is a generator of the multiplicative group, and -1 if it is not. - # This function can also be used to check primitivity of a generator of - # a finite field whose defining polynomial is not primitive. - bint fq_nmod_is_primitive(const fq_nmod_t op, const fq_nmod_ctx_t ctx) noexcept - # Returns whether ``op`` is primitive, i.e., whether it is a - # generator of the multiplicative group of ``ctx``. - void fq_nmod_bit_pack(fmpz_t f, const fq_nmod_t op, flint_bitcnt_t bit_size, const fq_nmod_ctx_t ctx) noexcept - # Packs ``op`` into bitfields of size ``bit_size``, writing the - # result to ``f``. - void fq_nmod_bit_unpack(fq_nmod_t rop, const fmpz_t f, flint_bitcnt_t bit_size, const fq_nmod_ctx_t ctx) noexcept - # Unpacks into ``rop`` the element with coefficients packed into - # fields of size ``bit_size`` as represented by the integer - # ``f``. diff --git a/src/sage/libs/flint/fq_nmod_embed.pxd b/src/sage/libs/flint/fq_nmod_embed.pxd index 51c2e020343..6a7dbe52068 100644 --- a/src/sage/libs/flint/fq_nmod_embed.pxd +++ b/src/sage/libs/flint/fq_nmod_embed.pxd @@ -2,7 +2,9 @@ # distutils: depends = flint/fq_nmod_embed.h ################################################################################ -# This file is auto-generated. Do not modify by hand +# This file is auto-generated by the script +# SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py. +# Do not modify by hand! Fix and rerun the script instead. ################################################################################ from libc.stdio cimport FILE @@ -11,87 +13,14 @@ from sage.libs.mpfr.types cimport * from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void fq_nmod_embed_gens(fq_nmod_t gen_sub, fq_nmod_t gen_sup, nmod_poly_t minpoly, const fq_nmod_ctx_t sub_ctx, const fq_nmod_ctx_t sup_ctx) noexcept - # Given two contexts ``sub_ctx`` and ``sup_ctx``, such that - # ``degree(sub_ctx)`` divides ``degree(sup_ctx)``, compute: - # * an element ``gen_sub`` in ``sub_ctx`` such that - # ``gen_sub`` generates the finite field defined by - # ``sub_ctx``, - # * its minimal polynomial ``minpoly``, - # * a root ``gen_sup`` of ``minpoly`` inside the field - # defined by ``sup_ctx``. - # These data uniquely define an embedding of ``sub_ctx`` into - # ``sup_ctx``. - void _fq_nmod_embed_gens_naive(fq_nmod_t gen_sub, fq_nmod_t gen_sup, nmod_poly_t minpoly, const fq_nmod_ctx_t sub_ctx, const fq_nmod_ctx_t sup_ctx) noexcept - # Given two contexts ``sub_ctx`` and ``sup_ctx``, such that - # ``degree(sub_ctx)`` divides ``degree(sup_ctx)``, compute an - # embedding of ``sub_ctx`` into ``sup_ctx`` defined as follows: - # * ``gen_sub`` is the canonical generator of ``sup_ctx`` - # (i.e., the class of `X`), - # * ``minpoly`` is the defining polynomial of ``sub_ctx``, - # * ``gen_sup`` is a root of ``minpoly`` inside the field - # defined by ``sup_ctx``. - void fq_nmod_embed_matrices(nmod_mat_t embed, nmod_mat_t project, const fq_nmod_t gen_sub, const fq_nmod_ctx_t sub_ctx, const fq_nmod_t gen_sup, const fq_nmod_ctx_t sup_ctx, const nmod_poly_t gen_minpoly) noexcept - # Given: - # * two contexts ``sub_ctx`` and ``sup_ctx``, of - # respective degrees `m` and `n`, such that `m` divides `n`; - # * a generator ``gen_sub`` of ``sub_ctx``, its minimal - # polynomial ``gen_minpoly``, and a root ``gen_sup`` of - # ``gen_minpoly`` in ``sup_ctx``, as returned by - # ``fq_nmod_embed_gens``; - # Compute: - # * the `n\times m` matrix ``embed`` mapping ``gen_sub`` - # to ``gen_sup``, and all their powers accordingly; - # * an `m\times n` matrix ``project`` such that - # ``project`` `\times` ``embed`` is the `m\times m` identity - # matrix. - void fq_nmod_embed_trace_matrix(nmod_mat_t res, const nmod_mat_t basis, const fq_nmod_ctx_t sub_ctx, const fq_nmod_ctx_t sup_ctx) noexcept - # Given: - # * two contexts ``sub_ctx`` and ``sup_ctx``, of degrees - # `m` and `n`, such that `m` divides `n`; - # * an `n\times m` matrix ``basis`` that maps ``sub_ctx`` - # to an isomorphic subfield in ``sup_ctx``; - # Compute the `m\times n` matrix of the trace from ``sup_ctx`` to - # ``sub_ctx``. - # This matrix is computed as - # ``embed_dual_to_mono_matrix(_, sub_ctx)`` - # `\times` ``basis``:sup:`t` `\times` - # ``embed_mono_to_dual_matrix(_, sup_ctx)}``. - # **Note:** if - # `m=n`, ``basis`` represents a Frobenius, and the result is its - # inverse matrix. - void fq_nmod_embed_composition_matrix(nmod_mat_t matrix, const fq_nmod_t gen, const fq_nmod_ctx_t ctx) noexcept - # Compute the *composition matrix* of ``gen``. - # For an element `a\in\mathbf{F}_{p^n}`, its composition matrix is the - # matrix whose columns are `a^0, a^1, \ldots, a^{n-1}`. - void fq_nmod_embed_composition_matrix_sub(nmod_mat_t matrix, const fq_nmod_t gen, const fq_nmod_ctx_t ctx, slong trunc) noexcept - # Compute the *composition matrix* of ``gen``, truncated to - # ``trunc`` columns. - void fq_nmod_embed_mul_matrix(nmod_mat_t matrix, const fq_nmod_t gen, const fq_nmod_ctx_t ctx) noexcept - # Compute the *multiplication matrix* of ``gen``. - # For an element `a` in `\mathbf{F}_{p^n}=\mathbf{F}_p[x]`, its - # multiplication matrix is the matrix whose columns are `a, ax, - # \dots, ax^{n-1}`. - void fq_nmod_embed_mono_to_dual_matrix(nmod_mat_t res, const fq_nmod_ctx_t ctx) noexcept - # Compute the change of basis matrix from the monomial basis of - # ``ctx`` to its dual basis. - void fq_nmod_embed_dual_to_mono_matrix(nmod_mat_t res, const fq_nmod_ctx_t ctx) noexcept - # Compute the change of basis matrix from the dual basis of - # ``ctx`` to its monomial basis. - void fq_nmod_modulus_pow_series_inv(nmod_poly_t res, const fq_nmod_ctx_t ctx, slong trunc) noexcept - # Compute the power series inverse of the reverse of the modulus of - # ``ctx`` up to `O(x^\texttt{trunc})`. - void fq_nmod_modulus_derivative_inv(fq_nmod_t m_prime, fq_nmod_t m_prime_inv, const fq_nmod_ctx_t ctx) noexcept - # Compute the derivative ``m_prime`` of the modulus of ``ctx`` - # as an element of ``ctx``, and its inverse ``m_prime_inv``. diff --git a/src/sage/libs/flint/fq_nmod_mat.pxd b/src/sage/libs/flint/fq_nmod_mat.pxd index 41106b90431..7c9f8a92548 100644 --- a/src/sage/libs/flint/fq_nmod_mat.pxd +++ b/src/sage/libs/flint/fq_nmod_mat.pxd @@ -2,7 +2,9 @@ # distutils: depends = flint/fq_nmod_mat.h ################################################################################ -# This file is auto-generated. Do not modify by hand +# This file is auto-generated by the script +# SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py. +# Do not modify by hand! Fix and rerun the script instead. ################################################################################ from libc.stdio cimport FILE @@ -11,356 +13,69 @@ from sage.libs.mpfr.types cimport * from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void fq_nmod_mat_init(fq_nmod_mat_t mat, slong rows, slong cols, const fq_nmod_ctx_t ctx) noexcept - # Initialises ``mat`` to a ``rows``-by-``cols`` matrix with - # coefficients in `\mathbf{F}_{q}` given by ``ctx``. All elements - # are set to zero. - void fq_nmod_mat_init_set(fq_nmod_mat_t mat, const fq_nmod_mat_t src, const fq_nmod_ctx_t ctx) noexcept - # Initialises ``mat`` and sets its dimensions and elements to - # those of ``src``. - void fq_nmod_mat_clear(fq_nmod_mat_t mat, const fq_nmod_ctx_t ctx) noexcept - # Clears the matrix and releases any memory it used. The matrix - # cannot be used again until it is initialised. This function must be - # called exactly once when finished using an :type:`fq_nmod_mat_t` object. - void fq_nmod_mat_set(fq_nmod_mat_t mat, const fq_nmod_mat_t src, const fq_nmod_ctx_t ctx) noexcept - # Sets ``mat`` to a copy of ``src``. It is assumed - # that ``mat`` and ``src`` have identical dimensions. - fq_nmod_struct * fq_nmod_mat_entry(const fq_nmod_mat_t mat, slong i, slong j) noexcept - # Directly accesses the entry in ``mat`` in row `i` and column `j`, - # indexed from zero. No bounds checking is performed. - void fq_nmod_mat_entry_set(fq_nmod_mat_t mat, slong i, slong j, const fq_nmod_t x, const fq_nmod_ctx_t ctx) noexcept - # Sets the entry in ``mat`` in row `i` and column `j` to ``x``. - slong fq_nmod_mat_nrows(const fq_nmod_mat_t mat, const fq_nmod_ctx_t ctx) noexcept - # Returns the number of rows in ``mat``. - slong fq_nmod_mat_ncols(const fq_nmod_mat_t mat, const fq_nmod_ctx_t ctx) noexcept - # Returns the number of columns in ``mat``. - void fq_nmod_mat_swap(fq_nmod_mat_t mat1, fq_nmod_mat_t mat2, const fq_nmod_ctx_t ctx) noexcept - # Swaps two matrices. The dimensions of ``mat1`` and ``mat2`` - # are allowed to be different. - void fq_nmod_mat_swap_entrywise(fq_nmod_mat_t mat1, fq_nmod_mat_t mat2, const fq_nmod_ctx_t ctx) noexcept - # Swaps two matrices by swapping the individual entries rather than swapping - # the contents of the structs. - void fq_nmod_mat_zero(fq_nmod_mat_t mat, const fq_nmod_ctx_t ctx) noexcept - # Sets all entries of ``mat`` to 0. - void fq_nmod_mat_one(fq_nmod_mat_t mat, const fq_nmod_ctx_t ctx) noexcept - # Sets all diagonal entries of ``mat`` to 1 and all other entries to 0. - void fq_nmod_mat_swap_rows(fq_nmod_mat_t mat, slong * perm, slong r, slong s, const fq_nmod_ctx_t ctx) noexcept - # Swaps rows ``r`` and ``s`` of ``mat``. If ``perm`` is non-``NULL``, the - # permutation of the rows will also be applied to ``perm``. - void fq_nmod_mat_swap_cols(fq_nmod_mat_t mat, slong * perm, slong r, slong s, const fq_nmod_ctx_t ctx) noexcept - # Swaps columns ``r`` and ``s`` of ``mat``. If ``perm`` is non-``NULL``, the - # permutation of the columns will also be applied to ``perm``. - void fq_nmod_mat_invert_rows(fq_nmod_mat_t mat, slong * perm, const fq_nmod_ctx_t ctx) noexcept - # Swaps rows ``i`` and ``r - i`` of ``mat`` for ``0 <= i < r/2``, where - # ``r`` is the number of rows of ``mat``. If ``perm`` is non-``NULL``, the - # permutation of the rows will also be applied to ``perm``. - void fq_nmod_mat_invert_cols(fq_nmod_mat_t mat, slong * perm, const fq_nmod_ctx_t ctx) noexcept - # Swaps columns ``i`` and ``c - i`` of ``mat`` for ``0 <= i < c/2``, where - # ``c`` is the number of columns of ``mat``. If ``perm`` is non-``NULL``, the - # permutation of the columns will also be applied to ``perm``. - void fq_nmod_mat_set_nmod_mat(fq_nmod_mat_t mat1, const nmod_mat_t mat2, const fq_nmod_ctx_t ctx) noexcept - # Sets the matrix ``mat1`` to the matrix ``mat2``. - void fq_nmod_mat_set_fmpz_mod_mat(fq_nmod_mat_t mat1, const fmpz_mod_mat_t mat2, const fq_nmod_ctx_t ctx) noexcept - # Sets the matrix ``mat1`` to the matrix ``mat2``. - void fq_nmod_mat_concat_vertical(fq_nmod_mat_t res, const fq_nmod_mat_t mat1, const fq_nmod_mat_t mat2, const fq_nmod_ctx_t ctx) noexcept - # Sets ``res`` to vertical concatenation of (``mat1``, ``mat2``) in that order. Matrix dimensions : ``mat1`` : `m \times n`, ``mat2`` : `k \times n`, ``res`` : `(m + k) \times n`. - void fq_nmod_mat_concat_horizontal(fq_nmod_mat_t res, const fq_nmod_mat_t mat1, const fq_nmod_mat_t mat2, const fq_nmod_ctx_t ctx) noexcept - # Sets ``res`` to horizontal concatenation of (``mat1``, ``mat2``) in that order. Matrix dimensions : ``mat1`` : `m \times n`, ``mat2`` : `m \times k`, ``res`` : `m \times (n + k)`. - int fq_nmod_mat_print_pretty(const fq_nmod_mat_t mat, const fq_nmod_ctx_t ctx) noexcept - # Pretty-prints ``mat`` to ``stdout``. A header is printed - # followed by the rows enclosed in brackets. - int fq_nmod_mat_fprint_pretty(FILE * file, const fq_nmod_mat_t mat, const fq_nmod_ctx_t ctx) noexcept - # Pretty-prints ``mat`` to ``file``. A header is printed - # followed by the rows enclosed in brackets. - # In case of success, returns a positive value. In case of failure, - # returns a non-positive value. - int fq_nmod_mat_print(const fq_nmod_mat_t mat, const fq_nmod_ctx_t ctx) noexcept - # Prints ``mat`` to ``stdout``. A header is printed followed - # by the rows enclosed in brackets. - int fq_nmod_mat_fprint(FILE * file, const fq_nmod_mat_t mat, const fq_nmod_ctx_t ctx) noexcept - # Prints ``mat`` to ``file``. A header is printed followed by - # the rows enclosed in brackets. - # In case of success, returns a positive value. In case of failure, - # returns a non-positive value. - void fq_nmod_mat_window_init(fq_nmod_mat_t window, const fq_nmod_mat_t mat, slong r1, slong c1, slong r2, slong c2, const fq_nmod_ctx_t ctx) noexcept - # Initializes the matrix ``window`` to be an ``r2 - r1`` by - # ``c2 - c1`` submatrix of ``mat`` whose ``(0,0)`` entry - # is the ``(r1, c1)`` entry of ``mat``. The memory for the - # elements of ``window`` is shared with ``mat``. - void fq_nmod_mat_window_clear(fq_nmod_mat_t window, const fq_nmod_ctx_t ctx) noexcept - # Clears the matrix ``window`` and releases any memory that it - # uses. Note that the memory to the underlying matrix that - # ``window`` points to is not freed. - void fq_nmod_mat_randtest(fq_nmod_mat_t mat, flint_rand_t state, const fq_nmod_ctx_t ctx) noexcept - # Sets the elements of ``mat`` to random elements of - # `\mathbf{F}_{q}`, given by ``ctx``. - int fq_nmod_mat_randpermdiag(fq_nmod_mat_t mat, flint_rand_t state, fq_nmod_struct * diag, slong n, const fq_nmod_ctx_t ctx) noexcept - # Sets ``mat`` to a random permutation of the diagonal matrix - # with `n` leading entries given by the vector ``diag``. It is - # assumed that the main diagonal of ``mat`` has room for at - # least `n` entries. - # Returns `0` or `1`, depending on whether the permutation is even - # or odd respectively. - void fq_nmod_mat_randrank(fq_nmod_mat_t mat, flint_rand_t state, slong rank, const fq_nmod_ctx_t ctx) noexcept - # Sets ``mat`` to a random sparse matrix with the given rank, - # having exactly as many non-zero elements as the rank, with the - # non-zero elements being uniformly random elements of - # `\mathbf{F}_{q}`. - # The matrix can be transformed into a dense matrix with unchanged - # rank by subsequently calling :func:`fq_nmod_mat_randops`. - void fq_nmod_mat_randops(fq_nmod_mat_t mat, slong count, flint_rand_t state, const fq_nmod_ctx_t ctx) noexcept - # Randomises ``mat`` by performing elementary row or column - # operations. More precisely, at most ``count`` random additions - # or subtractions of distinct rows and columns will be performed. - # This leaves the rank (and for square matrices, determinant) - # unchanged. - void fq_nmod_mat_randtril(fq_nmod_mat_t mat, flint_rand_t state, int unit, const fq_nmod_ctx_t ctx) noexcept - # Sets ``mat`` to a random lower triangular matrix. If - # ``unit`` is 1, it will have ones on the main diagonal, - # otherwise it will have random nonzero entries on the main - # diagonal. - void fq_nmod_mat_randtriu(fq_nmod_mat_t mat, flint_rand_t state, int unit, const fq_nmod_ctx_t ctx) noexcept - # Sets ``mat`` to a random upper triangular matrix. If - # ``unit`` is 1, it will have ones on the main diagonal, - # otherwise it will have random nonzero entries on the main - # diagonal. - bint fq_nmod_mat_equal(const fq_nmod_mat_t mat1, const fq_nmod_mat_t mat2, const fq_nmod_ctx_t ctx) noexcept - # Returns nonzero if mat1 and mat2 have the same dimensions and elements, - # and zero otherwise. - bint fq_nmod_mat_is_zero(const fq_nmod_mat_t mat, const fq_nmod_ctx_t ctx) noexcept - # Returns a non-zero value if all entries ``mat`` are zero, and - # otherwise returns zero. - bint fq_nmod_mat_is_one(const fq_nmod_mat_t mat, const fq_nmod_ctx_t ctx) noexcept - # Returns a non-zero value if all entries ``mat`` are zero except the - # diagonal entries which must be one, otherwise returns zero. - bint fq_nmod_mat_is_empty(const fq_nmod_mat_t mat, const fq_nmod_ctx_t ctx) noexcept - # Returns a non-zero value if the number of rows or the number of - # columns in ``mat`` is zero, and otherwise returns zero. - bint fq_nmod_mat_is_square(const fq_nmod_mat_t mat, const fq_nmod_ctx_t ctx) noexcept - # Returns a non-zero value if the number of rows is equal to the - # number of columns in ``mat``, and otherwise returns zero. - void fq_nmod_mat_add(fq_nmod_mat_t C, const fq_nmod_mat_t A, const fq_nmod_mat_t B, const fq_nmod_ctx_t ctx) noexcept - # Computes `C = A + B`. Dimensions must be identical. - void fq_nmod_mat_sub(fq_nmod_mat_t C, const fq_nmod_mat_t A, const fq_nmod_mat_t B, const fq_nmod_ctx_t ctx) noexcept - # Computes `C = A - B`. Dimensions must be identical. - void fq_nmod_mat_neg(fq_nmod_mat_t A, const fq_nmod_mat_t B, const fq_nmod_ctx_t ctx) noexcept - # Sets `B = -A`. Dimensions must be identical. - void fq_nmod_mat_mul(fq_nmod_mat_t C, const fq_nmod_mat_t A, const fq_nmod_mat_t B, const fq_nmod_ctx_t ctx) noexcept - # Sets `C = AB`. Dimensions must be compatible for matrix - # multiplication. Aliasing is allowed. This function automatically chooses - # between classical and KS multiplication. - void fq_nmod_mat_mul_classical(fq_nmod_mat_t C, const fq_nmod_mat_t A, const fq_nmod_mat_t B, const fq_nmod_ctx_t ctx) noexcept - # Sets `C = AB`. Dimensions must be compatible for matrix multiplication. - # `C` is not allowed to be aliased with `A` or `B`. Uses classical - # matrix multiplication. - void fq_nmod_mat_mul_KS(fq_nmod_mat_t C, const fq_nmod_mat_t A, const fq_nmod_mat_t B, const fq_nmod_ctx_t ctx) noexcept - # Sets `C = AB`. Dimensions must be compatible for matrix - # multiplication. `C` is not allowed to be aliased with `A` or - # `B`. Uses Kronecker substitution to perform the multiplication - # over the integers. - void fq_nmod_mat_submul(fq_nmod_mat_t D, const fq_nmod_mat_t C, const fq_nmod_mat_t A, const fq_nmod_mat_t B, const fq_nmod_ctx_t ctx) noexcept - # Sets `D = C + AB`. `C` and `D` may be aliased with each other but - # not with `A` or `B`. - void fq_nmod_mat_mul_vec(fq_nmod_struct * c, const fq_nmod_mat_t A, const fq_nmod_struct * b, slong blen, const fq_nmod_ctx_t ctx) noexcept void fq_nmod_mat_mul_vec_ptr(fq_nmod_struct * const * c, const fq_nmod_mat_t A, const fq_nmod_struct * const * b, slong blen, const fq_nmod_ctx_t ctx) noexcept - # Compute a matrix-vector product of ``A`` and ``(b, blen)`` and store the result in ``c``. - # The vector ``(b, blen)`` is either truncated or zero-extended to the number of columns of ``A``. - # The number entries written to ``c`` is always equal to the number of rows of ``A``. - void fq_nmod_mat_vec_mul(fq_nmod_struct * c, const fq_nmod_struct * a, slong alen, const fq_nmod_mat_t B, const fq_nmod_ctx_t ctx) noexcept void fq_nmod_mat_vec_mul_ptr(fq_nmod_struct * const * c, const fq_nmod_struct * const * a, slong alen, const fq_nmod_mat_t B, const fq_nmod_ctx_t ctx) noexcept - # Compute a vector-matrix product of ``(a, alen)`` and ``B`` and and store the result in ``c``. - # The vector ``(a, alen)`` is either truncated or zero-extended to the number of rows of ``B``. - # The number entries written to ``c`` is always equal to the number of columns of ``B``. - int fq_nmod_mat_inv(fq_nmod_mat_t B, fq_nmod_mat_t A, const fq_nmod_ctx_t ctx) noexcept - # Sets `B = A^{-1}` and returns `1` if `A` is invertible. If `A` is singular, - # returns `0` and sets the elements of `B` to undefined values. - # `A` and `B` must be square matrices with the same dimensions. - slong fq_nmod_mat_lu(slong * P, fq_nmod_mat_t A, int rank_check, const fq_nmod_ctx_t ctx) noexcept - # Computes a generalised LU decomposition `LU = PA` of a given - # matrix `A`, returning the rank of `A`. - # If `A` is a nonsingular square matrix, it will be overwritten with - # a unit diagonal lower triangular matrix `L` and an upper - # triangular matrix `U` (the diagonal of `L` will not be stored - # explicitly). - # If `A` is an arbitrary matrix of rank `r`, `U` will be in row - # echelon form having `r` nonzero rows, and `L` will be lower - # triangular but truncated to `r` columns, having implicit ones on - # the `r` first entries of the main diagonal. All other entries will - # be zero. - # If a nonzero value for ``rank_check`` is passed, the function - # will abandon the output matrix in an undefined state and return 0 - # if `A` is detected to be rank-deficient. - # This function calls ``fq_nmod_mat_lu_recursive``. - slong fq_nmod_mat_lu_classical(slong * P, fq_nmod_mat_t A, int rank_check, const fq_nmod_ctx_t ctx) noexcept - # Computes a generalised LU decomposition `LU = PA` of a given - # matrix `A`, returning the rank of `A`. The behavior of this - # function is identical to that of ``fq_nmod_mat_lu``. Uses Gaussian - # elimination. - slong fq_nmod_mat_lu_recursive(slong * P, fq_nmod_mat_t A, int rank_check, const fq_nmod_ctx_t ctx) noexcept - # Computes a generalised LU decomposition `LU = PA` of a given - # matrix `A`, returning the rank of `A`. The behavior of this - # function is identical to that of ``fq_nmod_mat_lu``. Uses recursive - # block decomposition, switching to classical Gaussian elimination - # for sufficiently small blocks. - slong fq_nmod_mat_rref(fq_nmod_mat_t A, const fq_nmod_ctx_t ctx) noexcept - # Puts `A` in reduced row echelon form and returns the rank of `A`. - # The rref is computed by first obtaining an unreduced row echelon - # form via LU decomposition and then solving an additional - # triangular system. - slong fq_nmod_mat_reduce_row(fq_nmod_mat_t A, slong * P, slong * L, slong n, const fq_nmod_ctx_t ctx) noexcept - # Reduce row n of the matrix `A`, assuming the prior rows are in Gauss - # form. However those rows may not be in order. The entry `i` of the array - # `P` is the row of `A` which has a pivot in the `i`-th column. If no such - # row exists, the entry of `P` will be `-1`. The function returns the column - # in which the `n`-th row has a pivot after reduction. This will always be - # chosen to be the first available column for a pivot from the left. This - # information is also updated in `P`. Entry `i` of the array `L` contains the - # number of possibly nonzero columns of `A` row `i`. This speeds up reduction - # in the case that `A` is chambered on the right. Otherwise the entries of - # `L` can all be set to the number of columns of `A`. We require the entries - # of `L` to be monotonic increasing. - void fq_nmod_mat_solve_tril(fq_nmod_mat_t X, const fq_nmod_mat_t L, const fq_nmod_mat_t B, int unit, const fq_nmod_ctx_t ctx) noexcept - # Sets `X = L^{-1} B` where `L` is a full rank lower triangular - # square matrix. If ``unit`` = 1, `L` is assumed to have ones on - # its main diagonal, and the main diagonal will not be read. `X` - # and `B` are allowed to be the same matrix, but no other aliasing - # is allowed. Automatically chooses between the classical and - # recursive algorithms. - void fq_nmod_mat_solve_tril_classical(fq_nmod_mat_t X, const fq_nmod_mat_t L, const fq_nmod_mat_t B, int unit, const fq_nmod_ctx_t ctx) noexcept - # Sets `X = L^{-1} B` where `L` is a full rank lower triangular - # square matrix. If ``unit`` = 1, `L` is assumed to have ones on - # its main diagonal, and the main diagonal will not be read. `X` - # and `B` are allowed to be the same matrix, but no other aliasing - # is allowed. Uses forward substitution. - void fq_nmod_mat_solve_tril_recursive(fq_nmod_mat_t X, const fq_nmod_mat_t L, const fq_nmod_mat_t B, int unit, const fq_nmod_ctx_t ctx) noexcept - # Sets `X = L^{-1} B` where `L` is a full rank lower triangular - # square matrix. If ``unit`` = 1, `L` is assumed to have ones on - # its main diagonal, and the main diagonal will not be read. `X` - # and `B` are allowed to be the same matrix, but no other aliasing - # is allowed. - # Uses the block inversion formula - # .. math :: - # \begin{pmatrix} A & 0 \\ C & D \end{pmatrix}^{-1} - # \begin{pmatrix} X \\ Y \end{pmatrix} = - # \begin{pmatrix} A^{-1} X \\ D^{-1} ( Y - C A^{-1} X ) \end{pmatrix} - # to reduce the problem to matrix multiplication and triangular - # solving of smaller systems. - void fq_nmod_mat_solve_triu(fq_nmod_mat_t X, const fq_nmod_mat_t U, const fq_nmod_mat_t B, int unit, const fq_nmod_ctx_t ctx) noexcept - # Sets `X = U^{-1} B` where `U` is a full rank upper triangular - # square matrix. If ``unit`` = 1, `U` is assumed to have ones on - # its main diagonal, and the main diagonal will not be read. `X` - # and `B` are allowed to be the same matrix, but no other aliasing - # is allowed. Automatically chooses between the classical and - # recursive algorithms. - void fq_nmod_mat_solve_triu_classical(fq_nmod_mat_t X, const fq_nmod_mat_t U, const fq_nmod_mat_t B, int unit, const fq_nmod_ctx_t ctx) noexcept - # Sets `X = U^{-1} B` where `U` is a full rank upper triangular - # square matrix. If ``unit`` = 1, `U` is assumed to have ones on - # its main diagonal, and the main diagonal will not be read. `X` - # and `B` are allowed to be the same matrix, but no other aliasing - # is allowed. Uses forward substitution. - void fq_nmod_mat_solve_triu_recursive(fq_nmod_mat_t X, const fq_nmod_mat_t U, const fq_nmod_mat_t B, int unit, const fq_nmod_ctx_t ctx) noexcept - # Sets `X = U^{-1} B` where `U` is a full rank upper triangular - # square matrix. If ``unit`` = 1, `U` is assumed to have ones on - # its main diagonal, and the main diagonal will not be read. `X` - # and `B` are allowed to be the same matrix, but no other aliasing - # is allowed. - # Uses the block inversion formula - # .. math :: - # \begin{pmatrix} A & B \\ 0 & D \end{pmatrix}^{-1} - # \begin{pmatrix} X \\ Y \end{pmatrix} = - # \begin{pmatrix} A^{-1} (X - B D^{-1} Y) \\ D^{-1} Y \end{pmatrix} - # to reduce the problem to matrix multiplication and triangular - # solving of smaller systems. - int fq_nmod_mat_solve(fq_nmod_mat_t X, const fq_nmod_mat_t A, const fq_nmod_mat_t B, const fq_nmod_ctx_t ctx) noexcept - # Solves the matrix-matrix equation `AX = B`. - # Returns `1` if `A` has full rank; otherwise returns `0` and sets the - # elements of `X` to undefined values. - # The matrix `A` must be square. - int fq_nmod_mat_can_solve(fq_nmod_mat_t X, const fq_nmod_mat_t A, const fq_nmod_mat_t B, const fq_nmod_ctx_t ctx) noexcept - # Solves the matrix-matrix equation `AX = B` over `Fq`. - # Returns `1` if a solution exists; otherwise returns `0` and sets the - # elements of `X` to zero. If more than one solution exists, one of the - # valid solutions is given. - # There are no restrictions on the shape of `A` and it may be singular. - void fq_nmod_mat_similarity(fq_nmod_mat_t M, slong r, fq_nmod_t d, const fq_nmod_ctx_t ctx) noexcept - # Applies a similarity transform to the `n\times n` matrix `M` in-place. - # If `P` is the `n\times n` identity matrix the zero entries of whose row - # `r` (`0`-indexed) have been replaced by `d`, this transform is equivalent - # to `M = P^{-1}MP`. - # Similarity transforms preserve the determinant, characteristic polynomial - # and minimal polynomial. - # The value `d` is required to be reduced modulo the modulus of the entries - # in the matrix. - void fq_nmod_mat_charpoly_danilevsky(fq_nmod_poly_t p, const fq_nmod_mat_t M, const fq_nmod_ctx_t ctx) noexcept - # Compute the characteristic polynomial `p` of the matrix `M`. The matrix - # is assumed to be square. - void fq_nmod_mat_charpoly(fq_nmod_poly_t p, const fq_nmod_mat_t M, const fq_nmod_ctx_t ctx) noexcept - # Compute the characteristic polynomial `p` of the matrix `M`. The matrix - # is required to be square, otherwise an exception is raised. - void fq_nmod_mat_minpoly(fq_nmod_poly_t p, const fq_nmod_mat_t M, const fq_nmod_ctx_t ctx) noexcept - # Compute the minimal polynomial `p` of the matrix `M`. The matrix - # is required to be square, otherwise an exception is raised. diff --git a/src/sage/libs/flint/fq_nmod_mpoly.pxd b/src/sage/libs/flint/fq_nmod_mpoly.pxd index 4b90208edc6..eeddd4e9053 100644 --- a/src/sage/libs/flint/fq_nmod_mpoly.pxd +++ b/src/sage/libs/flint/fq_nmod_mpoly.pxd @@ -2,7 +2,9 @@ # distutils: depends = flint/fq_nmod_mpoly.h ################################################################################ -# This file is auto-generated. Do not modify by hand +# This file is auto-generated by the script +# SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py. +# Do not modify by hand! Fix and rerun the script instead. ################################################################################ from libc.stdio cimport FILE @@ -11,355 +13,116 @@ from sage.libs.mpfr.types cimport * from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void fq_nmod_mpoly_ctx_init(fq_nmod_mpoly_ctx_t ctx, slong nvars, const ordering_t ord, const fq_nmod_ctx_t fqctx) noexcept - # Initialise a context object for a polynomial ring with the given number of variables and the given ordering. - # It will have coefficients in the finite field *fqctx*. - # The possibilities for the ordering are ``ORD_LEX``, ``ORD_DEGLEX`` and ``ORD_DEGREVLEX``. - slong fq_nmod_mpoly_ctx_nvars(const fq_nmod_mpoly_ctx_t ctx) noexcept - # Return the number of variables used to initialize the context. - ordering_t fq_nmod_mpoly_ctx_ord(const fq_nmod_mpoly_ctx_t ctx) noexcept - # Return the ordering used to initialize the context. - void fq_nmod_mpoly_ctx_clear(fq_nmod_mpoly_ctx_t ctx) noexcept - # Release any space allocated by an *ctx*. - void fq_nmod_mpoly_init(fq_nmod_mpoly_t A, const fq_nmod_mpoly_ctx_t ctx) noexcept - # Initialise *A* for use with the given an initialised context object. Its value is set to zero. - void fq_nmod_mpoly_init2(fq_nmod_mpoly_t A, slong alloc, const fq_nmod_mpoly_ctx_t ctx) noexcept - # Initialise *A* for use with the given an initialised context object. Its value is set to zero. - # It is allocated with space for *alloc* terms and at least ``MPOLY_MIN_BITS`` bits for the exponents. - void fq_nmod_mpoly_init3(fq_nmod_mpoly_t A, slong alloc, flint_bitcnt_t bits, const fq_nmod_mpoly_ctx_t ctx) noexcept - # Initialise *A* for use with the given an initialised context object. Its value is set to zero. - # It is allocated with space for *alloc* terms and *bits* bits for the exponents. - void fq_nmod_mpoly_fit_length(fq_nmod_mpoly_t A, slong len, const fq_nmod_mpoly_ctx_t ctx) noexcept - # Ensure that *A* has space for at least *len* terms. - void fq_nmod_mpoly_realloc(fq_nmod_mpoly_t A, slong alloc, const fq_nmod_mpoly_ctx_t ctx) noexcept - # Reallocate *A* to have space for *alloc* terms. - # Assumes the current length of the polynomial is not greater than *alloc*. - void fq_nmod_mpoly_clear(fq_nmod_mpoly_t A, const fq_nmod_mpoly_ctx_t ctx) noexcept - # Release any space allocated for *A*. - char * fq_nmod_mpoly_get_str_pretty(const fq_nmod_mpoly_t A, const char ** x, const fq_nmod_mpoly_ctx_t ctx) noexcept - # Return a string, which the user is responsible for cleaning up, representing *A*, given an array of variable strings *x*. - int fq_nmod_mpoly_fprint_pretty(FILE * file, const fq_nmod_mpoly_t A, const char ** x, const fq_nmod_mpoly_ctx_t ctx) noexcept - # Print a string representing *A* to *file*. - int fq_nmod_mpoly_print_pretty(const fq_nmod_mpoly_t A, const char ** x, const fq_nmod_mpoly_ctx_t ctx) noexcept - # Print a string representing *A* to ``stdout``. - int fq_nmod_mpoly_set_str_pretty(fq_nmod_mpoly_t A, const char * str, const char ** x, const fq_nmod_mpoly_ctx_t ctx) noexcept - # Set *A* to the polynomial in the null-terminates string *str* given an array *x* of variable strings. - # If parsing *str* fails, *A* is set to zero, and `-1` is returned. Otherwise, `0` is returned. - # The operations ``+``, ``-``, ``*``, and ``/`` are permitted along with integers and the variables in *x*. The character ``^`` must be immediately followed by the (integer) exponent. - # If any division is not exact, parsing fails. - void fq_nmod_mpoly_gen(fq_nmod_mpoly_t A, slong var, const fq_nmod_mpoly_ctx_t ctx) noexcept - # Set *A* to the variable of index *var*, where `var = 0` corresponds to the variable with the most significance with respect to the ordering. - bint fq_nmod_mpoly_is_gen(const fq_nmod_mpoly_t A, slong var, const fq_nmod_mpoly_ctx_t ctx) noexcept - # If `var \ge 0`, return `1` if *A* is equal to the `var`-th generator, otherwise return `0`. - # If `var < 0`, return `1` if the polynomial is equal to any generator, otherwise return `0`. - void fq_nmod_mpoly_set(fq_nmod_mpoly_t A, const fq_nmod_mpoly_t B, const fq_nmod_mpoly_ctx_t ctx) noexcept - # Set *A* to *B*. - bint fq_nmod_mpoly_equal(const fq_nmod_mpoly_t A, const fq_nmod_mpoly_t B, const fq_nmod_mpoly_ctx_t ctx) noexcept - # Return `1` if *A* is equal to *B*, else return `0`. - void fq_nmod_mpoly_swap(fq_nmod_mpoly_t A, fq_nmod_mpoly_t B, const fq_nmod_mpoly_ctx_t ctx) noexcept - # Efficiently swap *A* and *B*. - bint fq_nmod_mpoly_is_fq_nmod(const fq_nmod_mpoly_t A, const fq_nmod_mpoly_ctx_t ctx) noexcept - # Return `1` if *A* is a constant, else return `0`. - void fq_nmod_mpoly_get_fq_nmod(fq_nmod_t c, const fq_nmod_mpoly_t A, const fq_nmod_mpoly_ctx_t ctx) noexcept - # Assuming that *A* is a constant, set *c* to this constant. - # This function throws if *A* is not a constant. - void fq_nmod_mpoly_set_fq_nmod(fq_nmod_mpoly_t A, const fq_nmod_t c, const fq_nmod_mpoly_ctx_t ctx) noexcept void fq_nmod_mpoly_set_ui(fq_nmod_mpoly_t A, ulong c, const fq_nmod_mpoly_ctx_t ctx) noexcept - # Set *A* to the constant *c*. - void fq_nmod_mpoly_set_fq_nmod_gen(fq_nmod_mpoly_t A, const fq_nmod_mpoly_ctx_t ctx) noexcept - # Set *A* to the constant given by :func:`fq_nmod_gen`. - void fq_nmod_mpoly_zero(fq_nmod_mpoly_t A, const fq_nmod_mpoly_ctx_t ctx) noexcept - # Set *A* to the constant `0`. - void fq_nmod_mpoly_one(fq_nmod_mpoly_t A, const fq_nmod_mpoly_ctx_t ctx) noexcept - # Set *A* to the constant `1`. - bint fq_nmod_mpoly_equal_fq_nmod(const fq_nmod_mpoly_t A, const fq_nmod_t c, const fq_nmod_mpoly_ctx_t ctx) noexcept - # Return `1` if *A* is equal to the constant *c*, else return `0`. - bint fq_nmod_mpoly_is_zero(const fq_nmod_mpoly_t A, const fq_nmod_mpoly_ctx_t ctx) noexcept - # Return `1` if *A* is the constant `0`, else return `0`. - bint fq_nmod_mpoly_is_one(const fq_nmod_mpoly_t A, const fq_nmod_mpoly_ctx_t ctx) noexcept - # Return `1` if *A* is the constant `1`, else return `0`. - int fq_nmod_mpoly_degrees_fit_si(const fq_nmod_mpoly_t A, const fq_nmod_mpoly_ctx_t ctx) noexcept - # Return `1` if the degrees of *A* with respect to each variable fit into an ``slong``, otherwise return `0`. - void fq_nmod_mpoly_degrees_fmpz(fmpz ** degs, const fq_nmod_mpoly_t A, const fq_nmod_mpoly_ctx_t ctx) noexcept void fq_nmod_mpoly_degrees_si(slong * degs, const fq_nmod_mpoly_t A, const fq_nmod_mpoly_ctx_t ctx) noexcept - # Set *degs* to the degrees of *A* with respect to each variable. - # If *A* is zero, all degrees are set to `-1`. - void fq_nmod_mpoly_degree_fmpz(fmpz_t deg, const fq_nmod_mpoly_t A, slong var, const fq_nmod_mpoly_ctx_t ctx) noexcept slong fq_nmod_mpoly_degree_si(const fq_nmod_mpoly_t A, slong var, const fq_nmod_mpoly_ctx_t ctx) noexcept - # Either return or set *deg* to the degree of *A* with respect to the variable of index *var*. - # If *A* is zero, the degree is defined to be `-1`. - int fq_nmod_mpoly_total_degree_fits_si(const fq_nmod_mpoly_t A, const fq_nmod_mpoly_ctx_t ctx) noexcept - # Return `1` if the total degree of *A* fits into an ``slong``, otherwise return `0`. - void fq_nmod_mpoly_total_degree_fmpz(fmpz_t tdeg, const fq_nmod_mpoly_t A, const fq_nmod_mpoly_ctx_t ctx) noexcept slong fq_nmod_mpoly_total_degree_si(const fq_nmod_mpoly_t A, const fq_nmod_mpoly_ctx_t ctx) noexcept - # Either return or set *tdeg* to the total degree of *A*. - # If *A* is zero, the total degree is defined to be `-1`. - void fq_nmod_mpoly_used_vars(int * used, const fq_nmod_mpoly_t A, const fq_nmod_mpoly_ctx_t ctx) noexcept - # For each variable index `i`, set ``used[i]`` to nonzero if the variable of index `i` appears in *A* and to zero otherwise. - void fq_nmod_mpoly_get_coeff_fq_nmod_monomial(fq_nmod_t c, const fq_nmod_mpoly_t A, const fq_nmod_mpoly_t M, const fq_nmod_mpoly_ctx_t ctx) noexcept - # Assuming that *M* is a monomial, set *c* to the coefficient of the corresponding monomial in *A*. - # This function throws if *M* is not a monomial. - void fq_nmod_mpoly_set_coeff_fq_nmod_monomial(fq_nmod_mpoly_t A, const fq_nmod_t c, const fq_nmod_mpoly_t M, const fq_nmod_mpoly_ctx_t ctx) noexcept - # Assuming that *M* is a monomial, set the coefficient of the corresponding monomial in *A* to *c*. - # This function throws if *M* is not a monomial. - void fq_nmod_mpoly_get_coeff_fq_nmod_fmpz(fq_nmod_t c, const fq_nmod_mpoly_t A, fmpz * const * exp, const fq_nmod_mpoly_ctx_t ctx) noexcept void fq_nmod_mpoly_get_coeff_fq_nmod_ui(fq_nmod_t c, const fq_nmod_mpoly_t A, const ulong * exp, const fq_nmod_mpoly_ctx_t ctx) noexcept - # Set *c* to the coefficient of the monomial with exponent vector *exp*. - void fq_nmod_mpoly_set_coeff_fq_nmod_fmpz(fq_nmod_mpoly_t A, const fq_nmod_t c, fmpz * const * exp, const fq_nmod_mpoly_ctx_t ctx) noexcept void fq_nmod_mpoly_set_coeff_fq_nmod_ui(fq_nmod_mpoly_t A, const fq_nmod_t c, const ulong * exp, const fq_nmod_mpoly_ctx_t ctx) noexcept - # Set the coefficient of the monomial with exponent *exp* to *c*. - void fq_nmod_mpoly_get_coeff_vars_ui(fq_nmod_mpoly_t C, const fq_nmod_mpoly_t A, const slong * vars, const ulong * exps, slong length, const fq_nmod_mpoly_ctx_t ctx) noexcept - # Set *C* to the coefficient of *A* with respect to the variables in *vars* with powers in the corresponding array *exps*. - # Both *vars* and *exps* point to array of length *length*. It is assumed that `0 < length \le nvars(A)` and that the variables in *vars* are distinct. - int fq_nmod_mpoly_cmp(const fq_nmod_mpoly_t A, const fq_nmod_mpoly_t B, const fq_nmod_mpoly_ctx_t ctx) noexcept - # Return `1` (resp. `-1`, or `0`) if *A* is after (resp. before, same as) *B* in some arbitrary but fixed total ordering of the polynomials. - # This ordering agrees with the usual ordering of monomials when *A* and *B* are both monomials. - bint fq_nmod_mpoly_is_canonical(const fq_nmod_mpoly_t A, const fq_nmod_mpoly_ctx_t ctx) noexcept - # Return `1` if *A* is in canonical form. Otherwise, return `0`. - # To be in canonical form, all of the terms must have nonzero coefficients, and the terms must be sorted from greatest to least. - slong fq_nmod_mpoly_length(const fq_nmod_mpoly_t A, const fq_nmod_mpoly_ctx_t ctx) noexcept - # Return the number of terms in *A*. - # If the polynomial is in canonical form, this will be the number of nonzero coefficients. - void fq_nmod_mpoly_resize(fq_nmod_mpoly_t A, slong new_length, const fq_nmod_mpoly_ctx_t ctx) noexcept - # Set the length of *A* to ``new_length``. - # Terms are either deleted from the end, or new zero terms are appended. - void fq_nmod_mpoly_get_term_coeff_fq_nmod(fq_nmod_t c, const fq_nmod_mpoly_t A, slong i, const fq_nmod_mpoly_ctx_t ctx) noexcept - # Set *c* to the coefficient of the term of index *i*. - void fq_nmod_mpoly_set_term_coeff_ui(fq_nmod_mpoly_t A, slong i, ulong c, const fq_nmod_mpoly_ctx_t ctx) noexcept - # Set the coefficient of the term of index *i* to *c*. - int fq_nmod_mpoly_term_exp_fits_si(const fq_nmod_mpoly_t A, slong i, const fq_nmod_mpoly_ctx_t ctx) noexcept int fq_nmod_mpoly_term_exp_fits_ui(const fq_nmod_mpoly_t A, slong i, const fq_nmod_mpoly_ctx_t ctx) noexcept - # Return `1` if all entries of the exponent vector of the term of index `i` fit into an ``slong`` (resp. a ``ulong``). Otherwise, return `0`. - void fq_nmod_mpoly_get_term_exp_fmpz(fmpz ** exp, const fq_nmod_mpoly_t A, slong i, const fq_nmod_mpoly_ctx_t ctx) noexcept void fq_nmod_mpoly_get_term_exp_ui(ulong * exp, const fq_nmod_mpoly_t A, slong i, const fq_nmod_mpoly_ctx_t ctx) noexcept void fq_nmod_mpoly_get_term_exp_si(slong * exp, const fq_nmod_mpoly_t A, slong i, const fq_nmod_mpoly_ctx_t ctx) noexcept - # Set *exp* to the exponent vector of the term of index *i*. - # The ``_ui`` (resp. ``_si``) version throws if any entry does not fit into a ``ulong`` (resp. ``slong``). - ulong fq_nmod_mpoly_get_term_var_exp_ui(const fq_nmod_mpoly_t A, slong i, slong var, const fq_nmod_mpoly_ctx_t ctx) noexcept slong fq_nmod_mpoly_get_term_var_exp_si(const fq_nmod_mpoly_t A, slong i, slong var, const fq_nmod_mpoly_ctx_t ctx) noexcept - # Return the exponent of the variable *var* of the term of index *i*. - # This function throws if the exponent does not fit into a ``ulong`` (resp. ``slong``). - void fq_nmod_mpoly_set_term_exp_fmpz(fq_nmod_mpoly_t A, slong i, fmpz * const * exp, const fq_nmod_mpoly_ctx_t ctx) noexcept void fq_nmod_mpoly_set_term_exp_ui(fq_nmod_mpoly_t A, slong i, const ulong * exp, const fq_nmod_mpoly_ctx_t ctx) noexcept - # Set the exponent of the term of index *i* to *exp*. - void fq_nmod_mpoly_get_term(fq_nmod_mpoly_t M, const fq_nmod_mpoly_t A, slong i, const fq_nmod_mpoly_ctx_t ctx) noexcept - # Set *M* to the term of index *i* in *A*. - void fq_nmod_mpoly_get_term_monomial(fq_nmod_mpoly_t M, const fq_nmod_mpoly_t A, slong i, const fq_nmod_mpoly_ctx_t ctx) noexcept - # Set *M* to the monomial of the term of index *i* in *A*. The coefficient of *M* will be one. - void fq_nmod_mpoly_push_term_fq_nmod_fmpz(fq_nmod_mpoly_t A, const fq_nmod_t c, fmpz * const * exp, const fq_nmod_mpoly_ctx_t ctx) noexcept void fq_nmod_mpoly_push_term_fq_nmod_ffmpz(fq_nmod_mpoly_t A, const fq_nmod_t c, const fmpz * exp, const fq_nmod_mpoly_ctx_t ctx) noexcept void fq_nmod_mpoly_push_term_fq_nmod_ui(fq_nmod_mpoly_t A, const fq_nmod_t c, const ulong * exp, const fq_nmod_mpoly_ctx_t ctx) noexcept - # Append a term to *A* with coefficient *c* and exponent vector *exp*. - # This function runs in constant average time. - void fq_nmod_mpoly_sort_terms(fq_nmod_mpoly_t A, const fq_nmod_mpoly_ctx_t ctx) noexcept - # Sort the terms of *A* into the canonical ordering dictated by the ordering in *ctx*. - # This function simply reorders the terms: It does not combine like terms, nor does it delete terms with coefficient zero. - # This function runs in linear time in the bit size of *A*. - void fq_nmod_mpoly_combine_like_terms(fq_nmod_mpoly_t A, const fq_nmod_mpoly_ctx_t ctx) noexcept - # Combine adjacent like terms in *A* and delete terms with coefficient zero. - # If the terms of *A* were sorted to begin with, the result will be in canonical form. - # This function runs in linear time in the bit size of *A*. - void fq_nmod_mpoly_reverse(fq_nmod_mpoly_t A, const fq_nmod_mpoly_t B, const fq_nmod_mpoly_ctx_t ctx) noexcept - # Set *A* to the reversal of *B*. - void fq_nmod_mpoly_randtest_bound(fq_nmod_mpoly_t A, flint_rand_t state, slong length, ulong exp_bound, const fq_nmod_mpoly_ctx_t ctx) noexcept - # Generate a random polynomial with length up to *length* and exponents in the range ``[0, exp_bound - 1]``. - # The exponents of each variable are generated by calls to ``n_randint(state, exp_bound)``. - - void fq_nmod_mpoly_randtest_bounds(fq_nmod_mpoly_t A, flint_rand_t state, slong length, ulong *exp_bounds, const fq_nmod_mpoly_ctx_t ctx) noexcept - # Generate a random polynomial with length up to *length* and exponents in the range ``[0, exp_bounds[i] - 1]``. - # The exponents of the variable of index *i* are generated by calls to ``n_randint(state, exp_bounds[i])``. - + void fq_nmod_mpoly_randtest_bounds(fq_nmod_mpoly_t A, flint_rand_t state, slong length, ulong * exp_bounds, const fq_nmod_mpoly_ctx_t ctx) noexcept void fq_nmod_mpoly_randtest_bits(fq_nmod_mpoly_t A, flint_rand_t state, slong length, mp_limb_t exp_bits, const fq_nmod_mpoly_ctx_t ctx) noexcept - # Generate a random polynomial with length up to *length* and exponents whose packed form does not exceed the given bit count. - void fq_nmod_mpoly_add_fq_nmod(fq_nmod_mpoly_t A, const fq_nmod_mpoly_t B, const fq_nmod_t C, const fq_nmod_mpoly_ctx_t ctx) noexcept - # Set *A* to `B + c`. - void fq_nmod_mpoly_sub_fq_nmod(fq_nmod_mpoly_t A, const fq_nmod_mpoly_t B, const fq_nmod_t C, const fq_nmod_mpoly_ctx_t ctx) noexcept - # Set *A* to `B - c`. - void fq_nmod_mpoly_add(fq_nmod_mpoly_t A, const fq_nmod_mpoly_t B, const fq_nmod_mpoly_t C, const fq_nmod_mpoly_ctx_t ctx) noexcept - # Set *A* to `B + C`. - void fq_nmod_mpoly_sub(fq_nmod_mpoly_t A, const fq_nmod_mpoly_t B, const fq_nmod_mpoly_t C, const fq_nmod_mpoly_ctx_t ctx) noexcept - # Set *A* to `B - C`. - void fq_nmod_mpoly_neg(fq_nmod_mpoly_t A, const fq_nmod_mpoly_t B, const fq_nmod_mpoly_ctx_t ctx) noexcept - # Set *A* to `-B`. - void fq_nmod_mpoly_scalar_mul_fq_nmod(fq_nmod_mpoly_t A, const fq_nmod_mpoly_t B, const fq_nmod_t c, const fq_nmod_mpoly_ctx_t ctx) noexcept - # Set *A* to `B \times c`. - void fq_nmod_mpoly_make_monic(fq_nmod_mpoly_t A, const fq_nmod_mpoly_t B, const fq_nmod_mpoly_ctx_t ctx) noexcept - # Set *A* to *B* divided by the leading coefficient of *B*. - # This throws if *B* is zero. - void fq_nmod_mpoly_derivative(fq_nmod_mpoly_t A, const fq_nmod_mpoly_t B, slong var, const fq_nmod_mpoly_ctx_t ctx) noexcept - # Set *A* to the derivative of *B* with respect to the variable of index *var*. - void fq_nmod_mpoly_evaluate_all_fq_nmod(fq_nmod_t ev, const fq_nmod_mpoly_t A, fq_nmod_struct * const * vals, const fq_nmod_mpoly_ctx_t ctx) noexcept - # Set *ev* the evaluation of *A* where the variables are replaced by the corresponding elements of the array *vals*. - void fq_nmod_mpoly_evaluate_one_fq_nmod(fq_nmod_mpoly_t A, const fq_nmod_mpoly_t B, slong var, const fq_nmod_t val, const fq_nmod_mpoly_ctx_t ctx) noexcept - # Set *A* to the evaluation of *B* where the variable of index *var* is replaced by *val*. - int fq_nmod_mpoly_compose_fq_nmod_poly(fq_nmod_poly_t A, const fq_nmod_mpoly_t B, fq_nmod_poly_struct * const * C, const fq_nmod_mpoly_ctx_t ctx) noexcept - # Set *A* to the evaluation of *B* where the variables are replaced by the corresponding elements of the array *C*. - # The context object of *B* is *ctxB*. - # Return `1` for success and `0` for failure. - int fq_nmod_mpoly_compose_fq_nmod_mpoly(fq_nmod_mpoly_t A, const fq_nmod_mpoly_t B, fq_nmod_mpoly_struct * const * C, const fq_nmod_mpoly_ctx_t ctxB, const fq_nmod_mpoly_ctx_t ctxAC) noexcept - # Set *A* to the evaluation of *B* where the variables are replaced by the corresponding elements of the array *C*. - # Both *A* and the elements of *C* have context object *ctxAC*, while *B* has context object *ctxB*. - # Neither *A* nor *B* is allowed to alias any other polynomial. - # Return `1` for success and `0` for failure. - void fq_nmod_mpoly_compose_fq_nmod_mpoly_gen(fq_nmod_mpoly_t A, const fq_nmod_mpoly_t B, const slong * c, const fq_nmod_mpoly_ctx_t ctxB, const fq_nmod_mpoly_ctx_t ctxAC) noexcept - # Set *A* to the evaluation of *B* where the variable of index *i* in *ctxB* is replaced by the variable of index ``c[i]`` in *ctxAC*. - # The length of the array *C* is the number of variables in *ctxB*. - # If any ``c[i]`` is negative, the corresponding variable of *B* is replaced by zero. Otherwise, it is expected that ``c[i]`` is less than the number of variables in *ctxAC*. - void fq_nmod_mpoly_mul(fq_nmod_mpoly_t A, const fq_nmod_mpoly_t B, const fq_nmod_mpoly_t C, const fq_nmod_mpoly_ctx_t ctx) noexcept - # Set *A* to *B* times *C*. - int fq_nmod_mpoly_pow_fmpz(fq_nmod_mpoly_t A, const fq_nmod_mpoly_t B, const fmpz_t k, const fq_nmod_mpoly_ctx_t ctx) noexcept - # Set *A* to `B` raised to the *k*-th power. - # Return `1` for success and `0` for failure. - int fq_nmod_mpoly_pow_ui(fq_nmod_mpoly_t A, const fq_nmod_mpoly_t B, ulong k, const fq_nmod_mpoly_ctx_t ctx) noexcept - # Set *A* to `B` raised to the *k*-th power. - # Return `1` for success and `0` for failure. - int fq_nmod_mpoly_divides(fq_nmod_mpoly_t Q, const fq_nmod_mpoly_t A, const fq_nmod_mpoly_t B, const fq_nmod_mpoly_ctx_t ctx) noexcept - # If *A* is divisible by *B*, set *Q* to the exact quotient and return `1`. Otherwise, set *Q* to zero and return `0`. - void fq_nmod_mpoly_div(fq_nmod_mpoly_t Q, const fq_nmod_mpoly_t A, const fq_nmod_mpoly_t B, const fq_nmod_mpoly_ctx_t ctx) noexcept - # Set *Q* to the quotient of *A* by *B*, discarding the remainder. - void fq_nmod_mpoly_divrem(fq_nmod_mpoly_t Q, fq_nmod_mpoly_t R, const fq_nmod_mpoly_t A, const fq_nmod_mpoly_t B, const fq_nmod_mpoly_ctx_t ctx) noexcept - # Set *Q* and *R* to the quotient and remainder of *A* divided by *B*. - void fq_nmod_mpoly_divrem_ideal(fq_nmod_mpoly_struct ** Q, fq_nmod_mpoly_t R, const fq_nmod_mpoly_t A, fq_nmod_mpoly_struct * const * B, slong len, const fq_nmod_mpoly_ctx_t ctx) noexcept - # This function is as per :func:`fq_nmod_mpoly_divrem` except that it takes an array of divisor polynomials *B* and it returns an array of quotient polynomials *Q*. - # The number of divisor (and hence quotient) polynomials, is given by *len*. - void fq_nmod_mpoly_term_content(fq_nmod_mpoly_t M, const fq_nmod_mpoly_t A, const fq_nmod_mpoly_ctx_t ctx) noexcept - # Set *M* to the GCD of the terms of *A*. - # If *A* is zero, *M* will be zero. Otherwise, *M* will be a monomial with coefficient one. - int fq_nmod_mpoly_content_vars(fq_nmod_mpoly_t g, const fq_nmod_mpoly_t A, slong * vars, slong vars_length, const fq_nmod_mpoly_ctx_t ctx) noexcept - # Set *g* to the GCD of the coefficients of *A* when viewed as a polynomial in the variables *vars*. - # Return `1` for success and `0` for failure. Upon success, *g* will be independent of the variables *vars*. - int fq_nmod_mpoly_gcd(fq_nmod_mpoly_t G, const fq_nmod_mpoly_t A, const fq_nmod_mpoly_t B, const fq_nmod_mpoly_ctx_t ctx) noexcept - # Try to set *G* to the monic GCD of *A* and *B*. The GCD of zero and zero is defined to be zero. - # If the return is `1` the function was successful. Otherwise the return is `0` and *G* is left untouched. - int fq_nmod_mpoly_gcd_cofactors(fq_nmod_mpoly_t G, fq_nmod_mpoly_t Abar, fq_nmod_mpoly_t Bbar, const fq_nmod_mpoly_t A, const fq_nmod_mpoly_t B, const fq_nmod_mpoly_ctx_t ctx) noexcept - # Do the operation of :func:`fq_nmod_mpoly_gcd` and also compute `Abar = A/G` and `Bbar = B/G` if successful. - int fq_nmod_mpoly_gcd_brown(fq_nmod_mpoly_t G, const fq_nmod_mpoly_t A, const fq_nmod_mpoly_t B, const fq_nmod_mpoly_ctx_t ctx) noexcept int fq_nmod_mpoly_gcd_hensel(fq_nmod_mpoly_t G, const fq_nmod_mpoly_t A, const fq_nmod_mpoly_t B, const fq_nmod_mpoly_ctx_t ctx) noexcept int fq_nmod_mpoly_gcd_zippel(fq_nmod_mpoly_t G, const fq_nmod_mpoly_t A, const fq_nmod_mpoly_t B, const fq_nmod_mpoly_ctx_t ctx) noexcept - # Try to set *G* to the GCD of *A* and *B* using various algorithms. - int fq_nmod_mpoly_resultant(fq_nmod_mpoly_t R, const fq_nmod_mpoly_t A, const fq_nmod_mpoly_t B, slong var, const fq_nmod_mpoly_ctx_t ctx) noexcept - # Try to set *R* to the resultant of *A* and *B* with respect to the variable of index *var*. - int fq_nmod_mpoly_discriminant(fq_nmod_mpoly_t D, const fq_nmod_mpoly_t A, slong var, const fq_nmod_mpoly_ctx_t ctx) noexcept - # Try to set *D* to the discriminant of *A* with respect to the variable of index *var*. - int fq_nmod_mpoly_sqrt(fq_nmod_mpoly_t Q, const fq_nmod_mpoly_t A, const fq_nmod_mpoly_ctx_t ctx) noexcept - # If `Q^2=A` has a solution, set `Q` to a solution and return `1`, otherwise return `0` and set `Q` to zero. - bint fq_nmod_mpoly_is_square(const fq_nmod_mpoly_t A, const fq_nmod_mpoly_ctx_t ctx) noexcept - # Return `1` if *A* is a perfect square, otherwise return `0`. - int fq_nmod_mpoly_quadratic_root(fq_nmod_mpoly_t Q, const fq_nmod_mpoly_t A, const fq_nmod_mpoly_t B, const fq_nmod_mpoly_ctx_t ctx) noexcept - # If `Q^2+AQ=B` has a solution, set `Q` to a solution and return `1`, otherwise return `0`. - void fq_nmod_mpoly_univar_init(fq_nmod_mpoly_univar_t A, const fq_nmod_mpoly_ctx_t ctx) noexcept - # Initialize *A*. - void fq_nmod_mpoly_univar_clear(fq_nmod_mpoly_univar_t A, const fq_nmod_mpoly_ctx_t ctx) noexcept - # Clear *A*. - void fq_nmod_mpoly_univar_swap(fq_nmod_mpoly_univar_t A, fq_nmod_mpoly_univar_t B, const fq_nmod_mpoly_ctx_t ctx) noexcept - # Swap *A* and `B`. - void fq_nmod_mpoly_to_univar(fq_nmod_mpoly_univar_t A, const fq_nmod_mpoly_t B, slong var, const fq_nmod_mpoly_ctx_t ctx) noexcept - # Set *A* to a univariate form of *B* by pulling out the variable of index *var*. - # The coefficients of *A* will still belong to the content *ctx* but will not depend on the variable of index *var*. - void fq_nmod_mpoly_from_univar(fq_nmod_mpoly_t A, const fq_nmod_mpoly_univar_t B, slong var, const fq_nmod_mpoly_ctx_t ctx) noexcept - # Set *A* to the normal form of *B* by putting in the variable of index *var*. - # This function is undefined if the coefficients of *B* depend on the variable of index *var*. - int fq_nmod_mpoly_univar_degree_fits_si(const fq_nmod_mpoly_univar_t A, const fq_nmod_mpoly_ctx_t ctx) noexcept - # Return `1` if the degree of *A* with respect to the main variable fits an ``slong``. Otherwise, return `0`. - slong fq_nmod_mpoly_univar_length(const fq_nmod_mpoly_univar_t A, const fq_nmod_mpoly_ctx_t ctx) noexcept - # Return the number of terms in *A* with respect to the main variable. - slong fq_nmod_mpoly_univar_get_term_exp_si(fq_nmod_mpoly_univar_t A, slong i, const fq_nmod_mpoly_ctx_t ctx) noexcept - # Return the exponent of the term of index *i* of *A*. - void fq_nmod_mpoly_univar_get_term_coeff(fq_nmod_mpoly_t c, const fq_nmod_mpoly_univar_t A, slong i, const fq_nmod_mpoly_ctx_t ctx) noexcept void fq_nmod_mpoly_univar_swap_term_coeff(fq_nmod_mpoly_t c, fq_nmod_mpoly_univar_t A, slong i, const fq_nmod_mpoly_ctx_t ctx) noexcept - # Set (resp. swap) *c* to (resp. with) the coefficient of the term of index *i* of *A*. diff --git a/src/sage/libs/flint/fq_nmod_mpoly_factor.pxd b/src/sage/libs/flint/fq_nmod_mpoly_factor.pxd index 624350934d2..a5419d1c4be 100644 --- a/src/sage/libs/flint/fq_nmod_mpoly_factor.pxd +++ b/src/sage/libs/flint/fq_nmod_mpoly_factor.pxd @@ -2,7 +2,9 @@ # distutils: depends = flint/fq_nmod_mpoly_factor.h ################################################################################ -# This file is auto-generated. Do not modify by hand +# This file is auto-generated by the script +# SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py. +# Do not modify by hand! Fix and rerun the script instead. ################################################################################ from libc.stdio cimport FILE @@ -11,37 +13,14 @@ from sage.libs.mpfr.types cimport * from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void fq_nmod_mpoly_factor_init(fq_nmod_mpoly_factor_t f, const fq_nmod_mpoly_ctx_t ctx) noexcept - # Initialise *f*. - void fq_nmod_mpoly_factor_clear(fq_nmod_mpoly_factor_t f, const fq_nmod_mpoly_ctx_t ctx) noexcept - # Clear *f*. - void fq_nmod_mpoly_factor_swap(fq_nmod_mpoly_factor_t f, fq_nmod_mpoly_factor_t g, const fq_nmod_mpoly_ctx_t ctx) noexcept - # Efficiently swap *f* and *g*. - slong fq_nmod_mpoly_factor_length(const fq_nmod_mpoly_factor_t f, const fq_nmod_mpoly_ctx_t ctx) noexcept - # Return the length of the product in *f*. - void fq_nmod_mpoly_factor_get_constant_fq_nmod(fq_nmod_t c, const fq_nmod_mpoly_factor_t f, const fq_nmod_mpoly_ctx_t ctx) noexcept - # Set `c` to the constant of *f*. - void fq_nmod_mpoly_factor_get_base(fq_nmod_mpoly_t p, const fq_nmod_mpoly_factor_t f, slong i, const fq_nmod_mpoly_ctx_t ctx) noexcept void fq_nmod_mpoly_factor_swap_base(fq_nmod_mpoly_t p, const fq_nmod_mpoly_factor_t f, slong i, const fq_nmod_mpoly_ctx_t ctx) noexcept - # Set (resp. swap) *B* to (resp. with) the base of the term of index *i* in *A*. - slong fq_nmod_mpoly_factor_get_exp_si(fq_nmod_mpoly_factor_t f, slong i, const fq_nmod_mpoly_ctx_t ctx) noexcept - # Return the exponent of the term of index *i* in *A*. It is assumed to fit an ``slong``. - void fq_nmod_mpoly_factor_sort(fq_nmod_mpoly_factor_t f, const fq_nmod_mpoly_ctx_t ctx) noexcept - # Sort the product of *f* first by exponent and then by base. - int fq_nmod_mpoly_factor_squarefree(fq_nmod_mpoly_factor_t f, const fq_nmod_mpoly_t A, const fq_nmod_mpoly_ctx_t ctx) noexcept - # Set *f* to a factorization of *A* where the bases are primitive and - # pairwise relatively prime. If the product of all irreducible factors with - # a given exponent is desired, it is recommended to call :func:`fq_nmod_mpoly_factor_sort` - # and then multiply the bases with the desired exponent. - int fq_nmod_mpoly_factor(fq_nmod_mpoly_factor_t f, const fq_nmod_mpoly_t A, const fq_nmod_mpoly_ctx_t ctx) noexcept - # Set *f* to a factorization of *A* where the bases are irreducible. diff --git a/src/sage/libs/flint/fq_nmod_poly.pxd b/src/sage/libs/flint/fq_nmod_poly.pxd index 995dcbed9a2..13440cd550f 100644 --- a/src/sage/libs/flint/fq_nmod_poly.pxd +++ b/src/sage/libs/flint/fq_nmod_poly.pxd @@ -2,7 +2,9 @@ # distutils: depends = flint/fq_nmod_poly.h ################################################################################ -# This file is auto-generated. Do not modify by hand +# This file is auto-generated by the script +# SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py. +# Do not modify by hand! Fix and rerun the script instead. ################################################################################ from libc.stdio cimport FILE @@ -11,1054 +13,188 @@ from sage.libs.mpfr.types cimport * from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void fq_nmod_poly_init(fq_nmod_poly_t poly, const fq_nmod_ctx_t ctx) noexcept - # Initialises ``poly`` for use, with context ctx, and setting its - # length to zero. A corresponding call to :func:`fq_nmod_poly_clear` - # must be made after finishing with the ``fq_nmod_poly_t`` to free the - # memory used by the polynomial. - void fq_nmod_poly_init2(fq_nmod_poly_t poly, slong alloc, const fq_nmod_ctx_t ctx) noexcept - # Initialises ``poly`` with space for at least ``alloc`` - # coefficients and sets the length to zero. The allocated - # coefficients are all set to zero. A corresponding call to - # :func:`fq_nmod_poly_clear` must be made after finishing with the - # ``fq_nmod_poly_t`` to free the memory used by the polynomial. - void fq_nmod_poly_realloc(fq_nmod_poly_t poly, slong alloc, const fq_nmod_ctx_t ctx) noexcept - # Reallocates the given polynomial to have space for ``alloc`` - # coefficients. If ``alloc`` is zero the polynomial is cleared - # and then reinitialised. If the current length is greater than - # ``alloc`` the polynomial is first truncated to length - # ``alloc``. - void fq_nmod_poly_fit_length(fq_nmod_poly_t poly, slong len, const fq_nmod_ctx_t ctx) noexcept - # If ``len`` is greater than the number of coefficients currently - # allocated, then the polynomial is reallocated to have space for at - # least ``len`` coefficients. No data is lost when calling this - # function. - # The function efficiently deals with the case where - # ``fit_length`` is called many times in small increments by at - # least doubling the number of allocated coefficients when length is - # larger than the number of coefficients currently allocated. - void _fq_nmod_poly_set_length(fq_nmod_poly_t poly, slong newlen, const fq_nmod_ctx_t ctx) noexcept - # Sets the coefficients of ``poly`` beyond ``len`` to zero and - # sets the length of ``poly`` to ``len``. - void fq_nmod_poly_clear(fq_nmod_poly_t poly, const fq_nmod_ctx_t ctx) noexcept - # Clears the given polynomial, releasing any memory used. It must - # be reinitialised in order to be used again. - void _fq_nmod_poly_normalise(fq_nmod_poly_t poly, const fq_nmod_ctx_t ctx) noexcept - # Sets the length of ``poly`` so that the top coefficient is - # non-zero. If all coefficients are zero, the length is set to - # zero. This function is mainly used internally, as all functions - # guarantee normalisation. - - void _fq_nmod_poly_normalise2(const fq_nmod_struct *poly, slong *length, const fq_nmod_ctx_t ctx) noexcept - # Sets the length ``length`` of ``(poly,length)`` so that the - # top coefficient is non-zero. If all coefficients are zero, the - # length is set to zero. This function is mainly used internally, as - # all functions guarantee normalisation. - + void _fq_nmod_poly_normalise2(const fq_nmod_struct * poly, slong * length, const fq_nmod_ctx_t ctx) noexcept void fq_nmod_poly_truncate(fq_nmod_poly_t poly, slong newlen, const fq_nmod_ctx_t ctx) noexcept - # Truncates the polynomial to length at most ``n``. - void fq_nmod_poly_set_trunc(fq_nmod_poly_t poly1, fq_nmod_poly_t poly2, slong newlen, const fq_nmod_ctx_t ctx) noexcept - # Sets ``poly1`` to ``poly2`` truncated to length `n`. - - void _fq_nmod_poly_reverse(fq_nmod_struct* output, const fq_nmod_struct* input, slong len, slong m, const fq_nmod_ctx_t ctx) noexcept - # Sets ``output`` to the reverse of ``input``, which is of - # length ``len``, but thinking of it as a polynomial of - # length ``m``, notionally zero-padded if necessary. The - # length ``m`` must be non-negative, but there are no other - # restrictions. The polynomial ``output`` must have space for - # ``m`` coefficients. - + void _fq_nmod_poly_reverse(fq_nmod_struct * output, const fq_nmod_struct * input, slong len, slong m, const fq_nmod_ctx_t ctx) noexcept void fq_nmod_poly_reverse(fq_nmod_poly_t output, const fq_nmod_poly_t input, slong m, const fq_nmod_ctx_t ctx) noexcept - # Sets ``output`` to the reverse of ``input``, thinking of it - # as a polynomial of length ``m``, notionally zero-padded if - # necessary). The length ``m`` must be non-negative, but there - # are no other restrictions. The output polynomial will be set to - # length ``m`` and then normalised. - slong fq_nmod_poly_degree(const fq_nmod_poly_t poly, const fq_nmod_ctx_t ctx) noexcept - # Returns the degree of the polynomial ``poly``. - slong fq_nmod_poly_length(const fq_nmod_poly_t poly, const fq_nmod_ctx_t ctx) noexcept - # Returns the length of the polynomial ``poly``. - fq_nmod_struct * fq_nmod_poly_lead(const fq_nmod_poly_t poly, const fq_nmod_ctx_t ctx) noexcept - # Returns a pointer to the leading coefficient of ``poly``, or - # ``NULL`` if ``poly`` is the zero polynomial. - void fq_nmod_poly_randtest(fq_nmod_poly_t f, flint_rand_t state, slong len, const fq_nmod_ctx_t ctx) noexcept - # Sets `f` to a random polynomial of length at most ``len`` - # with entries in the field described by ``ctx``. - void fq_nmod_poly_randtest_not_zero(fq_nmod_poly_t f, flint_rand_t state, slong len, const fq_nmod_ctx_t ctx) noexcept - # Same as ``fq_nmod_poly_randtest`` but guarantees that the polynomial - # is not zero. - void fq_nmod_poly_randtest_monic(fq_nmod_poly_t f, flint_rand_t state, slong len, const fq_nmod_ctx_t ctx) noexcept - # Sets `f` to a random monic polynomial of length ``len`` with - # entries in the field described by ``ctx``. - void fq_nmod_poly_randtest_irreducible(fq_nmod_poly_t f, flint_rand_t state, slong len, const fq_nmod_ctx_t ctx) noexcept - # Sets `f` to a random monic, irreducible polynomial of length - # ``len`` with entries in the field described by ``ctx``. - - void _fq_nmod_poly_set(fq_nmod_struct *rop, const fq_nmod_struct *op, slong len, const fq_nmod_ctx_t ctx) noexcept - # Sets ``(rop, len``) to ``(op, len)``. - + void _fq_nmod_poly_set(fq_nmod_struct * rop, const fq_nmod_struct * op, slong len, const fq_nmod_ctx_t ctx) noexcept void fq_nmod_poly_set(fq_nmod_poly_t poly1, const fq_nmod_poly_t poly2, const fq_nmod_ctx_t ctx) noexcept - # Sets the polynomial ``poly1`` to the polynomial ``poly2``. - void fq_nmod_poly_set_fq_nmod(fq_nmod_poly_t poly, const fq_nmod_t c, const fq_nmod_ctx_t ctx) noexcept - # Sets the polynomial ``poly`` to ``c``. - void fq_nmod_poly_set_fmpz_mod_poly(fq_nmod_poly_t rop, const fmpz_mod_poly_t op, const fq_nmod_ctx_t ctx) noexcept - # Sets the polynomial ``rop`` to the polynomial ``op`` - void fq_nmod_poly_set_nmod_poly(fq_nmod_poly_t rop, const nmod_poly_t op, const fq_nmod_ctx_t ctx) noexcept - # Sets the polynomial ``rop`` to the polynomial ``op`` - void fq_nmod_poly_swap(fq_nmod_poly_t op1, fq_nmod_poly_t op2, const fq_nmod_ctx_t ctx) noexcept - # Swaps the two polynomials ``op1`` and ``op2``. - - void _fq_nmod_poly_zero(fq_nmod_struct *rop, slong len, const fq_nmod_ctx_t ctx) noexcept - # Sets ``(rop, len)`` to the zero polynomial. - + void _fq_nmod_poly_zero(fq_nmod_struct * rop, slong len, const fq_nmod_ctx_t ctx) noexcept void fq_nmod_poly_zero(fq_nmod_poly_t poly, const fq_nmod_ctx_t ctx) noexcept - # Sets ``poly`` to the zero polynomial. - void fq_nmod_poly_one(fq_nmod_poly_t poly, const fq_nmod_ctx_t ctx) noexcept - # Sets ``poly`` to the constant polynomial `1`. - void fq_nmod_poly_gen(fq_nmod_poly_t poly, const fq_nmod_ctx_t ctx) noexcept - # Sets ``poly`` to the polynomial `x`. - void fq_nmod_poly_make_monic(fq_nmod_poly_t rop, const fq_nmod_poly_t op, const fq_nmod_ctx_t ctx) noexcept - # Sets ``rop`` to ``op``, normed to have leading coefficient 1. - - void _fq_nmod_poly_make_monic(fq_nmod_struct *rop, const fq_nmod_struct *op, slong length, const fq_nmod_ctx_t ctx) noexcept - # Sets ``rop`` to ``(op,length)``, normed to have leading coefficient 1. - # Assumes that ``rop`` has enough space for the polynomial, assumes that - # ``op`` is not zero (and thus has an invertible leading coefficient). - + void _fq_nmod_poly_make_monic(fq_nmod_struct * rop, const fq_nmod_struct * op, slong length, const fq_nmod_ctx_t ctx) noexcept void fq_nmod_poly_get_coeff(fq_nmod_t x, const fq_nmod_poly_t poly, slong n, const fq_nmod_ctx_t ctx) noexcept - # Sets `x` to the coefficient of `X^n` in ``poly``. - void fq_nmod_poly_set_coeff(fq_nmod_poly_t poly, slong n, const fq_nmod_t x, const fq_nmod_ctx_t ctx) noexcept - # Sets the coefficient of `X^n` in ``poly`` to `x`. - void fq_nmod_poly_set_coeff_fmpz(fq_nmod_poly_t poly, slong n, const fmpz_t x, const fq_nmod_ctx_t ctx) noexcept - # Sets the coefficient of `X^n` in the polynomial to `x`, - # assuming `n \geq 0`. - bint fq_nmod_poly_equal(const fq_nmod_poly_t poly1, const fq_nmod_poly_t poly2, const fq_nmod_ctx_t ctx) noexcept - # Returns nonzero if the two polynomials ``poly1`` and ``poly2`` - # are equal, otherwise return zero. - bint fq_nmod_poly_equal_trunc(const fq_nmod_poly_t poly1, const fq_nmod_poly_t poly2, slong n, const fq_nmod_ctx_t ctx) noexcept - # Notionally truncate ``poly1`` and ``poly2`` to length `n` and - # return nonzero if they are equal, otherwise return zero. - bint fq_nmod_poly_is_zero(const fq_nmod_poly_t poly, const fq_nmod_ctx_t ctx) noexcept - # Returns whether the polynomial ``poly`` is the zero polynomial. - bint fq_nmod_poly_is_one(const fq_nmod_poly_t op, const fq_nmod_ctx_t ctx) noexcept - # Returns whether the polynomial ``poly`` is equal - # to the constant polynomial `1`. - bint fq_nmod_poly_is_gen(const fq_nmod_poly_t op, const fq_nmod_ctx_t ctx) noexcept - # Returns whether the polynomial ``poly`` is equal - # to the polynomial `x`. - bint fq_nmod_poly_is_unit(const fq_nmod_poly_t op, const fq_nmod_ctx_t ctx) noexcept - # Returns whether the polynomial ``poly`` is a unit in the polynomial - # ring `\mathbf{F}_q[X]`, i.e. if it has degree `0` and is non-zero. - bint fq_nmod_poly_equal_fq_nmod(const fq_nmod_poly_t poly, const fq_nmod_t c, const fq_nmod_ctx_t ctx) noexcept - # Returns whether the polynomial ``poly`` is equal the (constant) - # `\mathbf{F}_q` element ``c`` - - void _fq_nmod_poly_add(fq_nmod_struct *res, const fq_nmod_struct *poly1, slong len1, const fq_nmod_struct *poly2, slong len2, const fq_nmod_ctx_t ctx) noexcept - # Sets ``res`` to the sum of ``(poly1,len1)`` and ``(poly2,len2)``. - + void _fq_nmod_poly_add(fq_nmod_struct * res, const fq_nmod_struct * poly1, slong len1, const fq_nmod_struct * poly2, slong len2, const fq_nmod_ctx_t ctx) noexcept void fq_nmod_poly_add(fq_nmod_poly_t res, const fq_nmod_poly_t poly1, const fq_nmod_poly_t poly2, const fq_nmod_ctx_t ctx) noexcept - # Sets ``res`` to the sum of ``poly1`` and ``poly2``. - void fq_nmod_poly_add_si(fq_nmod_poly_t res, const fq_nmod_poly_t poly1, slong c, const fq_nmod_ctx_t ctx) noexcept - # Sets ``res`` to the sum of ``poly1`` and ``c``. - void fq_nmod_poly_add_series(fq_nmod_poly_t res, const fq_nmod_poly_t poly1, const fq_nmod_poly_t poly2, slong n, const fq_nmod_ctx_t ctx) noexcept - # Notionally truncate ``poly1`` and ``poly2`` to length ``n`` and set - # ``res`` to the sum. - - void _fq_nmod_poly_sub(fq_nmod_struct *res, const fq_nmod_struct *poly1, slong len1, const fq_nmod_struct *poly2, slong len2, const fq_nmod_ctx_t ctx) noexcept - # Sets ``res`` to the difference of ``(poly1,len1)`` and - # ``(poly2,len2)``. - + void _fq_nmod_poly_sub(fq_nmod_struct * res, const fq_nmod_struct * poly1, slong len1, const fq_nmod_struct * poly2, slong len2, const fq_nmod_ctx_t ctx) noexcept void fq_nmod_poly_sub(fq_nmod_poly_t res, const fq_nmod_poly_t poly1, const fq_nmod_poly_t poly2, const fq_nmod_ctx_t ctx) noexcept - # Sets ``res`` to the difference of ``poly1`` and ``poly2``. - void fq_nmod_poly_sub_series(fq_nmod_poly_t res, const fq_nmod_poly_t poly1, const fq_nmod_poly_t poly2, slong n, const fq_nmod_ctx_t ctx) noexcept - # Notionally truncate ``poly1`` and ``poly2`` to length ``n`` and set - # ``res`` to the difference. - - void _fq_nmod_poly_neg(fq_nmod_struct *rop, const fq_nmod_struct *op, slong len, const fq_nmod_ctx_t ctx) noexcept - # Sets ``rop`` to the additive inverse of ``(poly,len)``. - + void _fq_nmod_poly_neg(fq_nmod_struct * rop, const fq_nmod_struct * op, slong len, const fq_nmod_ctx_t ctx) noexcept void fq_nmod_poly_neg(fq_nmod_poly_t res, const fq_nmod_poly_t poly, const fq_nmod_ctx_t ctx) noexcept - # Sets ``res`` to the additive inverse of ``poly``. - - void _fq_nmod_poly_scalar_mul_fq_nmod(fq_nmod_struct *rop, const fq_nmod_struct *op, slong len, const fq_nmod_t x, const fq_nmod_ctx_t ctx) noexcept - # Sets ``(rop,len)`` to the product of ``(op,len)`` by the - # scalar ``x``, in the context defined by ``ctx``. - + void _fq_nmod_poly_scalar_mul_fq_nmod(fq_nmod_struct * rop, const fq_nmod_struct * op, slong len, const fq_nmod_t x, const fq_nmod_ctx_t ctx) noexcept void fq_nmod_poly_scalar_mul_fq_nmod(fq_nmod_poly_t rop, const fq_nmod_poly_t op, const fq_nmod_t x, const fq_nmod_ctx_t ctx) noexcept - # Sets ``rop`` to the product of ``op`` by the scalar ``x``, in the context - # defined by ``ctx``. - - void _fq_nmod_poly_scalar_addmul_fq_nmod(fq_nmod_struct *rop, const fq_nmod_struct *op, slong len, const fq_nmod_t x, const fq_nmod_ctx_t ctx) noexcept - # Adds to ``(rop,len)`` the product of ``(op,len)`` by the - # scalar ``x``, in the context defined by ``ctx``. - # In particular, assumes the same length for ``op`` and - # ``rop``. - + void _fq_nmod_poly_scalar_addmul_fq_nmod(fq_nmod_struct * rop, const fq_nmod_struct * op, slong len, const fq_nmod_t x, const fq_nmod_ctx_t ctx) noexcept void fq_nmod_poly_scalar_addmul_fq_nmod(fq_nmod_poly_t rop, const fq_nmod_poly_t op, const fq_nmod_t x, const fq_nmod_ctx_t ctx) noexcept - # Adds to ``rop`` the product of ``op`` by the - # scalar ``x``, in the context defined by ``ctx``. - - void _fq_nmod_poly_scalar_submul_fq_nmod(fq_nmod_struct *rop, const fq_nmod_struct *op, slong len, const fq_nmod_t x, const fq_nmod_ctx_t ctx) noexcept - # Subtracts from ``(rop,len)`` the product of ``(op,len)`` by the - # scalar ``x``, in the context defined by ``ctx``. - # In particular, assumes the same length for ``op`` and - # ``rop``. - + void _fq_nmod_poly_scalar_submul_fq_nmod(fq_nmod_struct * rop, const fq_nmod_struct * op, slong len, const fq_nmod_t x, const fq_nmod_ctx_t ctx) noexcept void fq_nmod_poly_scalar_submul_fq_nmod(fq_nmod_poly_t rop, const fq_nmod_poly_t op, const fq_nmod_t x, const fq_nmod_ctx_t ctx) noexcept - # Subtracts from ``rop`` the product of ``op`` by the - # scalar ``x``, in the context defined by ``ctx``. - - void _fq_nmod_poly_scalar_div_fq(fq_nmod_struct *rop, const fq_nmod_struct *op, slong len, const fq_nmod_t x, const fq_nmod_ctx_t ctx) noexcept - # Sets ``(rop,len)`` to the quotient of ``(op,len)`` by the - # scalar ``x``, in the context defined by ``ctx``. An exception is raised - # if ``x`` is zero. - + void _fq_nmod_poly_scalar_div_fq(fq_nmod_struct * rop, const fq_nmod_struct * op, slong len, const fq_nmod_t x, const fq_nmod_ctx_t ctx) noexcept void fq_nmod_poly_scalar_div_fq(fq_nmod_poly_t rop, const fq_nmod_poly_t op, const fq_nmod_t x, const fq_nmod_ctx_t ctx) noexcept - # Sets ``rop`` to the quotient of ``op`` by the scalar ``x``, in the context - # defined by ``ctx``. An exception is raised if ``x`` is zero. - - void _fq_nmod_poly_mul_classical(fq_nmod_struct *rop, const fq_nmod_struct *op1, slong len1, const fq_nmod_struct *op2, slong len2, const fq_nmod_ctx_t ctx) noexcept - # Sets ``(rop, len1 + len2 - 1)`` to the product of ``(op1, len1)`` - # and ``(op2, len2)``, assuming that ``len1`` is at least ``len2`` - # and neither is zero. - # Permits zero padding. Does not support aliasing of ``rop`` - # with either ``op1`` or ``op2``. - + void _fq_nmod_poly_mul_classical(fq_nmod_struct * rop, const fq_nmod_struct * op1, slong len1, const fq_nmod_struct * op2, slong len2, const fq_nmod_ctx_t ctx) noexcept void fq_nmod_poly_mul_classical(fq_nmod_poly_t rop, const fq_nmod_poly_t op1, const fq_nmod_poly_t op2, const fq_nmod_ctx_t ctx) noexcept - # Sets ``rop`` to the product of ``op1`` and ``op2`` - # using classical polynomial multiplication. - - void _fq_nmod_poly_mul_reorder(fq_nmod_struct *rop, const fq_nmod_struct *op1, slong len1, const fq_nmod_struct *op2, slong len2, const fq_nmod_ctx_t ctx) noexcept - # Sets ``(rop, len1 + len2 - 1)`` to the product of ``(op1, len1)`` - # and ``(op2, len2)``, assuming that ``len1`` and ``len2`` are - # non-zero. - # Permits zero padding. Supports aliasing. - + void _fq_nmod_poly_mul_reorder(fq_nmod_struct * rop, const fq_nmod_struct * op1, slong len1, const fq_nmod_struct * op2, slong len2, const fq_nmod_ctx_t ctx) noexcept void fq_nmod_poly_mul_reorder(fq_nmod_poly_t rop, const fq_nmod_poly_t op1, const fq_nmod_poly_t op2, const fq_nmod_ctx_t ctx) noexcept - # Sets ``rop`` to the product of ``op1`` and ``op2``, - # reordering the two indeterminates `X` and `Y` when viewing - # the polynomials as elements of `\mathbf{F}_p[X,Y]`. - # Suppose `\mathbf{F}_q = \mathbf{F}_p[X]/ (f(X))` and recall - # that elements of `\mathbf{F}_q` are internally represented - # by elements of type ``fmpz_poly``. For small degree extensions - # but polynomials in `\mathbf{F}_q[Y]` of large degree `n`, we - # change the representation to - # .. math :: - # \begin{split} - # g(Y) & = \sum_{i=0}^{n} a_i(X) Y^i \\ - # & = \sum_{j=0}^{d} \sum_{i=0}^{n} \text{Coeff}(a_i(X), j) Y^i. - # \end{split} - # This allows us to use a poor algorithm (such as classical multiplication) - # in the `X`-direction and leverage the existing fast integer - # multiplication routines in the `Y`-direction where the polynomial - # degree `n` is large. - - void _fq_nmod_poly_mul_univariate(fq_nmod_struct *rop, const fq_nmod_struct *op1, slong len1, const fq_nmod_struct *op2, slong len2, const fq_nmod_ctx_t ctx) noexcept - # Sets ``(rop, len1 + len2 - 1)`` to the product of ``(op1, len1)`` - # and ``(op2, len2)``. - # Permits zero padding and makes no assumptions on ``len1`` and ``len2``. - # Supports aliasing. - + void _fq_nmod_poly_mul_univariate(fq_nmod_struct * rop, const fq_nmod_struct * op1, slong len1, const fq_nmod_struct * op2, slong len2, const fq_nmod_ctx_t ctx) noexcept void fq_nmod_poly_mul_univariate(fq_nmod_poly_t rop, const fq_nmod_poly_t op1, const fq_nmod_poly_t op2, const fq_nmod_ctx_t ctx) noexcept - # Sets ``rop`` to the product of ``op1`` and ``op2`` - # using a bivariate to univariate transformation and reducing - # this problem to multiplying two univariate polynomials. - - void _fq_nmod_poly_mul_KS(fq_nmod_struct *rop, const fq_nmod_struct *op1, slong len1, const fq_nmod_struct *op2, slong len2, const fq_nmod_ctx_t ctx) noexcept - # Sets ``(rop, len1 + len2 - 1)`` to the product of ``(op1, len1)`` - # and ``(op2, len2)``. - # Permits zero padding and places no assumptions on the - # lengths ``len1`` and ``len2``. Supports aliasing. - + void _fq_nmod_poly_mul_KS(fq_nmod_struct * rop, const fq_nmod_struct * op1, slong len1, const fq_nmod_struct * op2, slong len2, const fq_nmod_ctx_t ctx) noexcept void fq_nmod_poly_mul_KS(fq_nmod_poly_t rop, const fq_nmod_poly_t op1, const fq_nmod_poly_t op2, const fq_nmod_ctx_t ctx) noexcept - # Sets ``rop`` to the product of ``op1`` and ``op2`` - # using Kronecker substitution, that is, by encoding each - # coefficient in `\mathbf{F}_{q}` as an integer and reducing - # this problem to multiplying two polynomials over the integers. - - void _fq_nmod_poly_mul(fq_nmod_struct *rop, const fq_nmod_struct *op1, slong len1, const fq_nmod_struct *op2, slong len2, const fq_nmod_ctx_t ctx) noexcept - # Sets ``(rop, len1 + len2 - 1)`` to the product of ``(op1, len1)`` - # and ``(op2, len2)``, choosing an appropriate algorithm. - # Permits zero padding. Does not support aliasing. - + void _fq_nmod_poly_mul(fq_nmod_struct * rop, const fq_nmod_struct * op1, slong len1, const fq_nmod_struct * op2, slong len2, const fq_nmod_ctx_t ctx) noexcept void fq_nmod_poly_mul(fq_nmod_poly_t rop, const fq_nmod_poly_t op1, const fq_nmod_poly_t op2, const fq_nmod_ctx_t ctx) noexcept - # Sets ``rop`` to the product of ``op1`` and ``op2``, - # choosing an appropriate algorithm. - - void _fq_nmod_poly_mullow_classical(fq_nmod_struct *rop, const fq_nmod_struct *op1, slong len1, const fq_nmod_struct *op2, slong len2, slong n, const fq_nmod_ctx_t ctx) noexcept - # Sets ``(rop, n)`` to the first `n` coefficients of - # ``(op1, len1)`` multiplied by ``(op2, len2)``. - # Assumes ``0 < n <= len1 + len2 - 1``. Assumes neither - # ``len1`` nor ``len2`` is zero. - + void _fq_nmod_poly_mullow_classical(fq_nmod_struct * rop, const fq_nmod_struct * op1, slong len1, const fq_nmod_struct * op2, slong len2, slong n, const fq_nmod_ctx_t ctx) noexcept void fq_nmod_poly_mullow_classical(fq_nmod_poly_t rop, const fq_nmod_poly_t op1, const fq_nmod_poly_t op2, slong n, const fq_nmod_ctx_t ctx) noexcept - # Sets ``rop`` to the product of ``op1`` and ``op2``, - # computed using the classical or schoolbook method. - - void _fq_nmod_poly_mullow_univariate(fq_nmod_struct *rop, const fq_nmod_struct *op1, slong len1, const fq_nmod_struct *op2, slong len2, slong n, const fq_nmod_ctx_t ctx) noexcept - # Sets ``(rop, n)`` to the lowest `n` coefficients of the product of - # ``(op1, len1)`` and ``(op2, len2)``, computed using a - # bivariate to univariate transformation. - # Assumes that ``len1`` and ``len2`` are positive, but does allow - # for the polynomials to be zero-padded. The polynomials may be zero, - # too. Assumes `n` is positive. Supports aliasing between ``rop``, - # ``op1`` and ``op2``. - + void _fq_nmod_poly_mullow_univariate(fq_nmod_struct * rop, const fq_nmod_struct * op1, slong len1, const fq_nmod_struct * op2, slong len2, slong n, const fq_nmod_ctx_t ctx) noexcept void fq_nmod_poly_mullow_univariate(fq_nmod_poly_t rop, const fq_nmod_poly_t op1, const fq_nmod_poly_t op2, slong n, const fq_nmod_ctx_t ctx) noexcept - # Sets ``rop`` to the lowest `n` coefficients of the product of - # ``poly1`` and ``poly2``, computed using a bivariate to - # univariate transformation. - - void _fq_nmod_poly_mullow_KS(fq_nmod_struct *rop, const fq_nmod_struct *op1, slong len1, const fq_nmod_struct *op2, slong len2, slong n, const fq_nmod_ctx_t ctx) noexcept - # Sets ``(rop, n)`` to the lowest `n` coefficients of the product of - # ``(op1, len1)`` and ``(op2, len2)``. - # Assumes that ``len1`` and ``len2`` are positive, but does allow - # for the polynomials to be zero-padded. The polynomials may be zero, - # too. Assumes `n` is positive. Supports aliasing between ``rop``, - # ``op1`` and ``op2``. - + void _fq_nmod_poly_mullow_KS(fq_nmod_struct * rop, const fq_nmod_struct * op1, slong len1, const fq_nmod_struct * op2, slong len2, slong n, const fq_nmod_ctx_t ctx) noexcept void fq_nmod_poly_mullow_KS(fq_nmod_poly_t rop, const fq_nmod_poly_t op1, const fq_nmod_poly_t op2, slong n, const fq_nmod_ctx_t ctx) noexcept - # Sets ``rop`` to the product of ``op1`` and ``op2``. - - void _fq_nmod_poly_mullow(fq_nmod_struct *rop, const fq_nmod_struct *op1, slong len1, const fq_nmod_struct *op2, slong len2, slong n, const fq_nmod_ctx_t ctx) noexcept - # Sets ``(rop, n)`` to the lowest `n` coefficients of the product of - # ``(op1, len1)`` and ``(op2, len2)``. - # Assumes ``0 < n <= len1 + len2 - 1``. Allows for zero-padding in - # the inputs. Does not support aliasing between the inputs and the output. - + void _fq_nmod_poly_mullow(fq_nmod_struct * rop, const fq_nmod_struct * op1, slong len1, const fq_nmod_struct * op2, slong len2, slong n, const fq_nmod_ctx_t ctx) noexcept void fq_nmod_poly_mullow(fq_nmod_poly_t rop, const fq_nmod_poly_t op1, const fq_nmod_poly_t op2, slong n, const fq_nmod_ctx_t ctx) noexcept - # Sets ``rop`` to the lowest `n` coefficients of the product of - # ``op1`` and ``op2``. - - void _fq_nmod_poly_mulhigh_classical(fq_nmod_struct *res, const fq_nmod_struct *poly1, slong len1, const fq_nmod_struct *poly2, slong len2, slong start, const fq_nmod_ctx_t ctx) noexcept - # Computes the product of ``(poly1, len1)`` and ``(poly2, len2)`` - # and writes the coefficients from ``start`` onwards into the high - # coefficients of ``res``, the remaining coefficients being arbitrary - # but reduced. Assumes that ``len1 >= len2 > 0``. Aliasing of inputs - # and output is not permitted. Algorithm is classical multiplication. - + void _fq_nmod_poly_mulhigh_classical(fq_nmod_struct * res, const fq_nmod_struct * poly1, slong len1, const fq_nmod_struct * poly2, slong len2, slong start, const fq_nmod_ctx_t ctx) noexcept void fq_nmod_poly_mulhigh_classical(fq_nmod_poly_t res, const fq_nmod_poly_t poly1, const fq_nmod_poly_t poly2, slong start, const fq_nmod_ctx_t ctx) noexcept - # Computes the product of ``poly1`` and ``poly2`` and writes the - # coefficients from ``start`` onwards into the high coefficients of - # ``res``, the remaining coefficients being arbitrary but reduced. - # Algorithm is classical multiplication. - - void _fq_nmod_poly_mulhigh(fq_nmod_struct *res, const fq_nmod_struct *poly1, slong len1, const fq_nmod_struct *poly2, slong len2, slong start, fq_nmod_ctx_t ctx) noexcept - # Computes the product of ``(poly1, len1)`` and ``(poly2, len2)`` - # and writes the coefficients from ``start`` onwards into the high - # coefficients of ``res``, the remaining coefficients being arbitrary - # but reduced. Assumes that ``len1 >= len2 > 0``. Aliasing of inputs - # and output is not permitted. - + void _fq_nmod_poly_mulhigh(fq_nmod_struct * res, const fq_nmod_struct * poly1, slong len1, const fq_nmod_struct * poly2, slong len2, slong start, fq_nmod_ctx_t ctx) noexcept void fq_nmod_poly_mulhigh(fq_nmod_poly_t res, const fq_nmod_poly_t poly1, const fq_nmod_poly_t poly2, slong start, const fq_nmod_ctx_t ctx) noexcept - # Computes the product of ``poly1`` and ``poly2`` and writes the - # coefficients from ``start`` onwards into the high coefficients of - # ``res``, the remaining coefficients being arbitrary but reduced. - - void _fq_nmod_poly_mulmod(fq_nmod_struct* res, const fq_nmod_struct* poly1, slong len1, const fq_nmod_struct* poly2, slong len2, const fq_nmod_struct* f, slong lenf, const fq_nmod_ctx_t ctx) noexcept - # Sets ``res`` to the remainder of the product of ``poly1`` - # and ``poly2`` upon polynomial division by ``f``. - # It is required that ``len1 + len2 - lenf > 0``, which is - # equivalent to requiring that the result will actually be - # reduced. Otherwise, simply use ``_fq_nmod_poly_mul`` instead. - # Aliasing of ``f`` and ``res`` is not permitted. - + void _fq_nmod_poly_mulmod(fq_nmod_struct * res, const fq_nmod_struct * poly1, slong len1, const fq_nmod_struct * poly2, slong len2, const fq_nmod_struct * f, slong lenf, const fq_nmod_ctx_t ctx) noexcept void fq_nmod_poly_mulmod(fq_nmod_poly_t res, const fq_nmod_poly_t poly1, const fq_nmod_poly_t poly2, const fq_nmod_poly_t f, const fq_nmod_ctx_t ctx) noexcept - # Sets ``res`` to the remainder of the product of ``poly1`` - # and ``poly2`` upon polynomial division by ``f``. - - void _fq_nmod_poly_mulmod_preinv(fq_nmod_struct* res, const fq_nmod_struct* poly1, slong len1, const fq_nmod_struct* poly2, slong len2, const fq_nmod_struct* f, slong lenf, const fq_nmod_struct* finv, slong lenfinv, const fq_nmod_ctx_t ctx) noexcept - # Sets ``res`` to the remainder of the product of ``poly1`` - # and ``poly2`` upon polynomial division by ``f``. - # It is required that ``finv`` is the inverse of the reverse of - # ``f`` mod ``x^lenf``. - # Aliasing of ``res`` with any of the inputs is not permitted. - + void _fq_nmod_poly_mulmod_preinv(fq_nmod_struct * res, const fq_nmod_struct * poly1, slong len1, const fq_nmod_struct * poly2, slong len2, const fq_nmod_struct * f, slong lenf, const fq_nmod_struct * finv, slong lenfinv, const fq_nmod_ctx_t ctx) noexcept void fq_nmod_poly_mulmod_preinv(fq_nmod_poly_t res, const fq_nmod_poly_t poly1, const fq_nmod_poly_t poly2, const fq_nmod_poly_t f, const fq_nmod_poly_t finv, const fq_nmod_ctx_t ctx) noexcept - # Sets ``res`` to the remainder of the product of ``poly1`` - # and ``poly2`` upon polynomial division by ``f``. ``finv`` - # is the inverse of the reverse of ``f``. - - void _fq_nmod_poly_sqr_classical(fq_nmod_struct *rop, const fq_nmod_struct *op, slong len, const fq_nmod_ctx_t ctx) noexcept - # Sets ``(rop, 2*len - 1)`` to the square of ``(op, len)``, - # assuming that ``(op,len)`` is not zero and using classical - # polynomial multiplication. - # Permits zero padding. Does not support aliasing of ``rop`` - # with either ``op1`` or ``op2``. - + void _fq_nmod_poly_sqr_classical(fq_nmod_struct * rop, const fq_nmod_struct * op, slong len, const fq_nmod_ctx_t ctx) noexcept void fq_nmod_poly_sqr_classical(fq_nmod_poly_t rop, const fq_nmod_poly_t op, const fq_nmod_ctx_t ctx) noexcept - # Sets ``rop`` to the square of ``op`` using classical - # polynomial multiplication. - - void _fq_nmod_poly_sqr_KS(fq_nmod_struct *rop, const fq_nmod_struct *op, slong len, const fq_nmod_ctx_t ctx) noexcept - # Sets ``(rop, 2*len - 1)`` to the square of ``(op, len)``. - # Permits zero padding and places no assumptions on the - # lengths ``len1`` and ``len2``. Supports aliasing. - + void _fq_nmod_poly_sqr_KS(fq_nmod_struct * rop, const fq_nmod_struct * op, slong len, const fq_nmod_ctx_t ctx) noexcept void fq_nmod_poly_sqr_KS(fq_nmod_poly_t rop, const fq_nmod_poly_t op, const fq_nmod_ctx_t ctx) noexcept - # Sets ``rop`` to the square ``op`` using Kronecker substitution, - # that is, by encoding each coefficient in `\mathbf{F}_{q}` as an integer - # and reducing this problem to multiplying two polynomials over the integers. - - void _fq_nmod_poly_sqr(fq_nmod_struct *rop, const fq_nmod_struct *op, slong len, const fq_nmod_ctx_t ctx) noexcept - # Sets ``(rop, 2* len - 1)`` to the square of ``(op, len)``, - # choosing an appropriate algorithm. - # Permits zero padding. Does not support aliasing. - + void _fq_nmod_poly_sqr(fq_nmod_struct * rop, const fq_nmod_struct * op, slong len, const fq_nmod_ctx_t ctx) noexcept void fq_nmod_poly_sqr(fq_nmod_poly_t rop, const fq_nmod_poly_t op, const fq_nmod_ctx_t ctx) noexcept - # Sets ``rop`` to the square of ``op``, - # choosing an appropriate algorithm. - - void _fq_nmod_poly_pow(fq_nmod_struct *rop, const fq_nmod_struct *op, slong len, ulong e, const fq_nmod_ctx_t ctx) noexcept - # Sets ``rop = op^e``, assuming that ``e, len > 0`` and that - # ``rop`` has space for ``e*(len - 1) + 1`` coefficients. Does - # not support aliasing. - + void _fq_nmod_poly_pow(fq_nmod_struct * rop, const fq_nmod_struct * op, slong len, ulong e, const fq_nmod_ctx_t ctx) noexcept void fq_nmod_poly_pow(fq_nmod_poly_t rop, const fq_nmod_poly_t op, ulong e, const fq_nmod_ctx_t ctx) noexcept - # Computes ``rop = op^e``. If `e` is zero, returns one, - # so that in particular ``0^0 = 1``. - - void _fq_nmod_poly_powmod_ui_binexp(fq_nmod_struct* res, const fq_nmod_struct* poly, ulong e, const fq_nmod_struct* f, slong lenf, const fq_nmod_ctx_t ctx) noexcept - # Sets ``res`` to ``poly`` raised to the power ``e`` modulo - # ``f``, using binary exponentiation. We require ``e > 0``. - # We require ``lenf > 1``. It is assumed that ``poly`` is - # already reduced modulo ``f`` and zero-padded as necessary to - # have length exactly ``lenf - 1``. The output ``res`` must - # have room for ``lenf - 1`` coefficients. - + void _fq_nmod_poly_powmod_ui_binexp(fq_nmod_struct * res, const fq_nmod_struct * poly, ulong e, const fq_nmod_struct * f, slong lenf, const fq_nmod_ctx_t ctx) noexcept void fq_nmod_poly_powmod_ui_binexp(fq_nmod_poly_t res, const fq_nmod_poly_t poly, ulong e, const fq_nmod_poly_t f, const fq_nmod_ctx_t ctx) noexcept - # Sets ``res`` to ``poly`` raised to the power ``e`` modulo - # ``f``, using binary exponentiation. We require ``e >= 0``. - - void _fq_nmod_poly_powmod_ui_binexp_preinv(fq_nmod_struct* res, const fq_nmod_struct* poly, ulong e, const fq_nmod_struct* f, slong lenf, const fq_nmod_struct* finv, slong lenfinv, const fq_nmod_ctx_t ctx) noexcept - # Sets ``res`` to ``poly`` raised to the power ``e`` modulo - # ``f``, using binary exponentiation. We require ``e > 0``. - # We require ``finv`` to be the inverse of the reverse of - # ``f``. - # We require ``lenf > 1``. It is assumed that ``poly`` is - # already reduced modulo ``f`` and zero-padded as necessary to - # have length exactly ``lenf - 1``. The output ``res`` must - # have room for ``lenf - 1`` coefficients. - + void _fq_nmod_poly_powmod_ui_binexp_preinv(fq_nmod_struct * res, const fq_nmod_struct * poly, ulong e, const fq_nmod_struct * f, slong lenf, const fq_nmod_struct * finv, slong lenfinv, const fq_nmod_ctx_t ctx) noexcept void fq_nmod_poly_powmod_ui_binexp_preinv(fq_nmod_poly_t res, const fq_nmod_poly_t poly, ulong e, const fq_nmod_poly_t f, const fq_nmod_poly_t finv, const fq_nmod_ctx_t ctx) noexcept - # Sets ``res`` to ``poly`` raised to the power ``e`` modulo - # ``f``, using binary exponentiation. We require ``e >= 0``. - # We require ``finv`` to be the inverse of the reverse of - # ``f``. - - void _fq_nmod_poly_powmod_fmpz_binexp(fq_nmod_struct* res, const fq_nmod_struct* poly, const fmpz_t e, const fq_nmod_struct* f, slong lenf, const fq_nmod_ctx_t ctx) noexcept - # Sets ``res`` to ``poly`` raised to the power ``e`` modulo - # ``f``, using binary exponentiation. We require ``e > 0``. - # We require ``lenf > 1``. It is assumed that ``poly`` is - # already reduced modulo ``f`` and zero-padded as necessary to - # have length exactly ``lenf - 1``. The output ``res`` must - # have room for ``lenf - 1`` coefficients. - + void _fq_nmod_poly_powmod_fmpz_binexp(fq_nmod_struct * res, const fq_nmod_struct * poly, const fmpz_t e, const fq_nmod_struct * f, slong lenf, const fq_nmod_ctx_t ctx) noexcept void fq_nmod_poly_powmod_fmpz_binexp(fq_nmod_poly_t res, const fq_nmod_poly_t poly, const fmpz_t e, const fq_nmod_poly_t f, const fq_nmod_ctx_t ctx) noexcept - # Sets ``res`` to ``poly`` raised to the power ``e`` modulo - # ``f``, using binary exponentiation. We require ``e >= 0``. - - void _fq_nmod_poly_powmod_fmpz_binexp_preinv(fq_nmod_struct* res, const fq_nmod_struct* poly, const fmpz_t e, const fq_nmod_struct* f, slong lenf, const fq_nmod_struct* finv, slong lenfinv, const fq_nmod_ctx_t ctx) noexcept - # Sets ``res`` to ``poly`` raised to the power ``e`` modulo - # ``f``, using binary exponentiation. We require ``e > 0``. - # We require ``finv`` to be the inverse of the reverse of - # ``f``. - # We require ``lenf > 1``. It is assumed that ``poly`` is - # already reduced modulo ``f`` and zero-padded as necessary to - # have length exactly ``lenf - 1``. The output ``res`` must - # have room for ``lenf - 1`` coefficients. - + void _fq_nmod_poly_powmod_fmpz_binexp_preinv(fq_nmod_struct * res, const fq_nmod_struct * poly, const fmpz_t e, const fq_nmod_struct * f, slong lenf, const fq_nmod_struct * finv, slong lenfinv, const fq_nmod_ctx_t ctx) noexcept void fq_nmod_poly_powmod_fmpz_binexp_preinv(fq_nmod_poly_t res, const fq_nmod_poly_t poly, const fmpz_t e, const fq_nmod_poly_t f, const fq_nmod_poly_t finv, const fq_nmod_ctx_t ctx) noexcept - # Sets ``res`` to ``poly`` raised to the power ``e`` modulo - # ``f``, using binary exponentiation. We require ``e >= 0``. - # We require ``finv`` to be the inverse of the reverse of - # ``f``. - - void _fq_nmod_poly_powmod_fmpz_sliding_preinv(fq_nmod_struct* res, const fq_nmod_struct* poly, const fmpz_t e, ulong k, const fq_nmod_struct* f, slong lenf, const fq_nmod_struct* finv, slong lenfinv, const fq_nmod_ctx_t ctx) noexcept - # Sets ``res`` to ``poly`` raised to the power ``e`` modulo - # ``f``, using sliding-window exponentiation with window size - # ``k``. We require ``e > 0``. We require ``finv`` to be - # the inverse of the reverse of ``f``. If ``k`` is set to - # zero, then an "optimum" size will be selected automatically base - # on ``e``. - # We require ``lenf > 1``. It is assumed that ``poly`` is - # already reduced modulo ``f`` and zero-padded as necessary to - # have length exactly ``lenf - 1``. The output ``res`` must - # have room for ``lenf - 1`` coefficients. - + void _fq_nmod_poly_powmod_fmpz_sliding_preinv(fq_nmod_struct * res, const fq_nmod_struct * poly, const fmpz_t e, ulong k, const fq_nmod_struct * f, slong lenf, const fq_nmod_struct * finv, slong lenfinv, const fq_nmod_ctx_t ctx) noexcept void fq_nmod_poly_powmod_fmpz_sliding_preinv(fq_nmod_poly_t res, const fq_nmod_poly_t poly, const fmpz_t e, ulong k, const fq_nmod_poly_t f, const fq_nmod_poly_t finv, const fq_nmod_ctx_t ctx) noexcept - # Sets ``res`` to ``poly`` raised to the power ``e`` modulo - # ``f``, using sliding-window exponentiation with window size - # ``k``. We require ``e >= 0``. We require ``finv`` to be - # the inverse of the reverse of ``f``. If ``k`` is set to - # zero, then an "optimum" size will be selected automatically base - # on ``e``. - void _fq_nmod_poly_powmod_x_fmpz_preinv(fq_nmod_struct * res, const fmpz_t e, const fq_nmod_struct * f, slong lenf, const fq_nmod_struct * finv, slong lenfinv, const fq_nmod_ctx_t ctx) noexcept - # Sets ``res`` to ``x`` raised to the power ``e`` modulo ``f``, - # using sliding window exponentiation. We require ``e > 0``. - # We require ``finv`` to be the inverse of the reverse of ``f``. - # We require ``lenf > 2``. The output ``res`` must have room for - # ``lenf - 1`` coefficients. - void fq_nmod_poly_powmod_x_fmpz_preinv(fq_nmod_poly_t res, const fmpz_t e, const fq_nmod_poly_t f, const fq_nmod_poly_t finv, const fq_nmod_ctx_t ctx) noexcept - # Sets ``res`` to ``x`` raised to the power ``e`` - # modulo ``f``, using sliding window exponentiation. We require - # ``e >= 0``. We require ``finv`` to be the inverse of the reverse of - # ``f``. - void _fq_nmod_poly_pow_trunc_binexp(fq_nmod_struct * res, const fq_nmod_struct * poly, ulong e, slong trunc, const fq_nmod_ctx_t ctx) noexcept - # Sets ``res`` to the low ``trunc`` coefficients of ``poly`` - # (assumed to be zero padded if necessary to length ``trunc``) to - # the power ``e``. This is equivalent to doing a powering followed - # by a truncation. We require that ``res`` has enough space for - # ``trunc`` coefficients, that ``trunc > 0`` and that - # ``e > 1``. Aliasing is not permitted. Uses the binary - # exponentiation method. - void fq_nmod_poly_pow_trunc_binexp(fq_nmod_poly_t res, const fq_nmod_poly_t poly, ulong e, slong trunc, const fq_nmod_ctx_t ctx) noexcept - # Sets ``res`` to the low ``trunc`` coefficients of ``poly`` - # to the power ``e``. This is equivalent to doing a powering - # followed by a truncation. Uses the binary exponentiation method. - void _fq_nmod_poly_pow_trunc(fq_nmod_struct * res, const fq_nmod_struct * poly, ulong e, slong trunc, const fq_nmod_ctx_t mod) noexcept - # Sets ``res`` to the low ``trunc`` coefficients of ``poly`` - # (assumed to be zero padded if necessary to length ``trunc``) to - # the power ``e``. This is equivalent to doing a powering followed - # by a truncation. We require that ``res`` has enough space for - # ``trunc`` coefficients, that ``trunc > 0`` and that - # ``e > 1``. Aliasing is not permitted. - void fq_nmod_poly_pow_trunc(fq_nmod_poly_t res, const fq_nmod_poly_t poly, ulong e, slong trunc, const fq_nmod_ctx_t ctx) noexcept - # Sets ``res`` to the low ``trunc`` coefficients of ``poly`` - # to the power ``e``. This is equivalent to doing a powering - # followed by a truncation. - - void _fq_nmod_poly_shift_left(fq_nmod_struct *rop, const fq_nmod_struct *op, slong len, slong n, const fq_nmod_ctx_t ctx) noexcept - # Sets ``(rop, len + n)`` to ``(op, len)`` shifted left by - # `n` coefficients. - # Inserts zero coefficients at the lower end. Assumes that - # ``len`` and `n` are positive, and that ``rop`` fits - # ``len + n`` elements. Supports aliasing between ``rop`` and - # ``op``. - + void _fq_nmod_poly_shift_left(fq_nmod_struct * rop, const fq_nmod_struct * op, slong len, slong n, const fq_nmod_ctx_t ctx) noexcept void fq_nmod_poly_shift_left(fq_nmod_poly_t rop, const fq_nmod_poly_t op, slong n, const fq_nmod_ctx_t ctx) noexcept - # Sets ``rop`` to ``op`` shifted left by `n` coeffs. Zero - # coefficients are inserted. - - void _fq_nmod_poly_shift_right(fq_nmod_struct *rop, const fq_nmod_struct *op, slong len, slong n, const fq_nmod_ctx_t ctx) noexcept - # Sets ``(rop, len - n)`` to ``(op, len)`` shifted right by - # `n` coefficients. - # Assumes that ``len`` and `n` are positive, that ``len > n``, - # and that ``rop`` fits ``len - n`` elements. Supports - # aliasing between ``rop`` and ``op``, although in this case - # the top coefficients of ``op`` are not set to zero. - + void _fq_nmod_poly_shift_right(fq_nmod_struct * rop, const fq_nmod_struct * op, slong len, slong n, const fq_nmod_ctx_t ctx) noexcept void fq_nmod_poly_shift_right(fq_nmod_poly_t rop, const fq_nmod_poly_t op, slong n, const fq_nmod_ctx_t ctx) noexcept - # Sets ``rop`` to ``op`` shifted right by `n` coefficients. - # If `n` is equal to or greater than the current length of - # ``op``, ``rop`` is set to the zero polynomial. - - slong _fq_nmod_poly_hamming_weight(const fq_nmod_struct *op, slong len, const fq_nmod_ctx_t ctx) noexcept - # Returns the number of non-zero entries in ``(op, len)``. - + slong _fq_nmod_poly_hamming_weight(const fq_nmod_struct * op, slong len, const fq_nmod_ctx_t ctx) noexcept slong fq_nmod_poly_hamming_weight(const fq_nmod_poly_t op, const fq_nmod_ctx_t ctx) noexcept - # Returns the number of non-zero entries in the polynomial ``op``. - - void _fq_nmod_poly_divrem(fq_nmod_struct *Q, fq_nmod_struct *R, const fq_nmod_struct *A, slong lenA, const fq_nmod_struct *B, slong lenB, const fq_nmod_t invB, const fq_nmod_ctx_t ctx) noexcept - # Computes ``(Q, lenA - lenB + 1)``, ``(R, lenA)`` such that - # `A = B Q + R` with `0 \leq \operatorname{len}(R) < \operatorname{len}(B)`. - # Assumes that the leading coefficient of `B` is invertible - # and that ``invB`` is its inverse. - # Assumes that `\operatorname{len}(A), \operatorname{len}(B) > 0`. Allows zero-padding in - # ``(A, lenA)``. `R` and `A` may be aliased, but apart from - # this no aliasing of input and output operands is allowed. - + void _fq_nmod_poly_divrem(fq_nmod_struct * Q, fq_nmod_struct * R, const fq_nmod_struct * A, slong lenA, const fq_nmod_struct * B, slong lenB, const fq_nmod_t invB, const fq_nmod_ctx_t ctx) noexcept void fq_nmod_poly_divrem(fq_nmod_poly_t Q, fq_nmod_poly_t R, const fq_nmod_poly_t A, const fq_nmod_poly_t B, const fq_nmod_ctx_t ctx) noexcept - # Computes `Q`, `R` such that `A = B Q + R` with - # `0 \leq \operatorname{len}(R) < \operatorname{len}(B)`. - # Assumes that the leading coefficient of `B` is invertible. This can - # be taken for granted the context is for a finite field, that is, when - # `p` is prime and `f(X)` is irreducible. - void fq_nmod_poly_divrem_f(fq_nmod_t f, fq_nmod_poly_t Q, fq_nmod_poly_t R, const fq_nmod_poly_t A, const fq_nmod_poly_t B, const fq_nmod_ctx_t ctx) noexcept - # Either finds a non-trivial factor `f` of the modulus of - # ``ctx``, or computes `Q`, `R` such that `A = B Q + R` and - # `0 \leq \operatorname{len}(R) < \operatorname{len}(B)`. - # If the leading coefficient of `B` is invertible, the division with - # remainder operation is carried out, `Q` and `R` are computed - # correctly, and `f` is set to `1`. Otherwise, `f` is set to a - # non-trivial factor of the modulus and `Q` and `R` are not touched. - # Assumes that `B` is non-zero. - - void _fq_nmod_poly_rem(fq_nmod_struct *R, const fq_nmod_struct *A, slong lenA, const fq_nmod_struct *B, slong lenB, const fq_nmod_t invB, const fq_nmod_ctx_t ctx) noexcept - # Sets ``R`` to the remainder of the division of ``(A,lenA)`` by - # ``(B,lenB)``. Assumes that the leading coefficient of ``(B,lenB)`` - # is invertible and that ``invB`` is its inverse. - + void _fq_nmod_poly_rem(fq_nmod_struct * R, const fq_nmod_struct * A, slong lenA, const fq_nmod_struct * B, slong lenB, const fq_nmod_t invB, const fq_nmod_ctx_t ctx) noexcept void fq_nmod_poly_rem(fq_nmod_poly_t R, const fq_nmod_poly_t A, const fq_nmod_poly_t B, const fq_nmod_ctx_t ctx) noexcept - # Sets ``R`` to the remainder of the division of ``A`` by - # ``B`` in the context described by ``ctx``. - - void _fq_nmod_poly_div(fq_nmod_struct *Q, const fq_nmod_struct *A, slong lenA, const fq_nmod_struct *B, slong lenB, const fq_nmod_t invB, const fq_nmod_ctx_t ctx) noexcept - # Notationally, computes `Q`, `R` such that `A = B Q + R` with `0 - # \leq \operatorname{len}(R) < \operatorname{len}(B)` but only sets ``(Q, lenA - lenB + 1)``. - # Allows zero-padding in `A` but not in `B`. Assumes that the leading coefficient of `B` is a - # unit. - + void _fq_nmod_poly_div(fq_nmod_struct * Q, const fq_nmod_struct * A, slong lenA, const fq_nmod_struct * B, slong lenB, const fq_nmod_t invB, const fq_nmod_ctx_t ctx) noexcept void fq_nmod_poly_div(fq_nmod_poly_t Q, const fq_nmod_poly_t A, const fq_nmod_poly_t B, const fq_nmod_ctx_t ctx) noexcept - # Notionally finds polynomials `Q` and `R` such that `A = B Q + R` with - # `\operatorname{len}(R) < \operatorname{len}(B)`, but returns only ``Q``. If `\operatorname{len}(B) = 0` an - # exception is raised. - - void _fq_nmod_poly_div_newton_n_preinv(fq_nmod_struct* Q, const fq_nmod_struct* A, slong lenA, const fq_nmod_struct* B, slong lenB, const fq_nmod_struct* Binv, slong lenBinv, const fq_nmod_ctx_t ctx) noexcept - # Notionally computes polynomials `Q` and `R` such that `A = BQ + R` with - # `\operatorname{len}(R)` less than ``lenB``, where ``A`` is of length ``lenA`` - # and ``B`` is of length ``lenB``, but return only `Q`. - # We require that `Q` have space for ``lenA - lenB + 1`` coefficients - # and assume that the leading coefficient of `B` is a unit. Furthermore, we - # assume that `Binv` is the inverse of the reverse of `B` mod `x^{\operatorname{len}(B)}`. - # The algorithm used is to reverse the polynomials and divide the - # resulting power series, then reverse the result. - + void _fq_nmod_poly_div_newton_n_preinv(fq_nmod_struct * Q, const fq_nmod_struct * A, slong lenA, const fq_nmod_struct * B, slong lenB, const fq_nmod_struct * Binv, slong lenBinv, const fq_nmod_ctx_t ctx) noexcept void fq_nmod_poly_div_newton_n_preinv(fq_nmod_poly_t Q, const fq_nmod_poly_t A, const fq_nmod_poly_t B, const fq_nmod_poly_t Binv, const fq_nmod_ctx_t ctx) noexcept - # Notionally computes `Q` and `R` such that `A = BQ + R` with - # `\operatorname{len}(R) < \operatorname{len}(B)`, but returns only `Q`. - # We assume that the leading coefficient of `B` is a unit and that `Binv` is - # the inverse of the reverse of `B` mod `x^{\operatorname{len}(B)}`. - # It is required that the length of `A` is less than or equal to - # 2*the length of `B` - 2. - # The algorithm used is to reverse the polynomials and divide the - # resulting power series, then reverse the result. - - void _fq_nmod_poly_divrem_newton_n_preinv(fq_nmod_struct* Q, fq_nmod_struct* R, const fq_nmod_struct* A, slong lenA, const fq_nmod_struct* B, slong lenB, const fq_nmod_struct* Binv, slong lenBinv, const fq_nmod_ctx_t ctx) noexcept - # Computes `Q` and `R` such that `A = BQ + R` with `\operatorname{len}(R)` less - # than ``lenB``, where `A` is of length ``lenA`` and `B` is of - # length ``lenB``. We require that `Q` have space for - # ``lenA - lenB + 1`` coefficients. Furthermore, we assume that `Binv` is - # the inverse of the reverse of `B` mod `x^{\operatorname{len}(B)}`. The algorithm - # used is to call :func:`div_newton_preinv` and then multiply out - # and compute the remainder. - + void _fq_nmod_poly_divrem_newton_n_preinv(fq_nmod_struct * Q, fq_nmod_struct * R, const fq_nmod_struct * A, slong lenA, const fq_nmod_struct * B, slong lenB, const fq_nmod_struct * Binv, slong lenBinv, const fq_nmod_ctx_t ctx) noexcept void fq_nmod_poly_divrem_newton_n_preinv(fq_nmod_poly_t Q, fq_nmod_poly_t R, const fq_nmod_poly_t A, const fq_nmod_poly_t B, const fq_nmod_poly_t Binv, const fq_nmod_ctx_t ctx) noexcept - # Computes `Q` and `R` such that `A = BQ + R` with `\operatorname{len}(R) < - # \operatorname{len}(B)`. We assume `Binv` is the inverse of the reverse of `B` - # mod `x^{\operatorname{len}(B)}`. - # It is required that the length of `A` is less than or equal to - # 2*the length of `B` - 2. - # The algorithm used is to call :func:`div_newton` and then - # multiply out and compute the remainder. - - void _fq_nmod_poly_inv_series_newton(fq_nmod_struct* Qinv, const fq_nmod_struct* Q, slong n, const fq_nmod_t cinv, const fq_nmod_ctx_t ctx) noexcept - # Given ``Q`` of length ``n`` whose constant coefficient is - # invertible modulo the given modulus, find a polynomial ``Qinv`` - # of length ``n`` such that ``Q * Qinv`` is ``1`` modulo - # `x^n`. Requires ``n > 0``. This function can be viewed as - # inverting a power series via Newton iteration. - + void _fq_nmod_poly_inv_series_newton(fq_nmod_struct * Qinv, const fq_nmod_struct * Q, slong n, const fq_nmod_t cinv, const fq_nmod_ctx_t ctx) noexcept void fq_nmod_poly_inv_series_newton(fq_nmod_poly_t Qinv, const fq_nmod_poly_t Q, slong n, const fq_nmod_ctx_t ctx) noexcept - # Given ``Q`` find ``Qinv`` such that ``Q * Qinv`` is - # ``1`` modulo `x^n`. The constant coefficient of ``Q`` must - # be invertible modulo the modulus of ``Q``. An exception is - # raised if this is not the case or if ``n = 0``. This function - # can be viewed as inverting a power series via Newton iteration. - - void _fq_nmod_poly_inv_series(fq_nmod_struct* Qinv, const fq_nmod_struct* Q, slong n, const fq_nmod_t cinv, const fq_nmod_ctx_t ctx) noexcept - # Given ``Q`` of length ``n`` whose constant coefficient is - # invertible modulo the given modulus, find a polynomial ``Qinv`` - # of length ``n`` such that ``Q * Qinv`` is ``1`` modulo - # `x^n`. Requires ``n > 0``. - + void _fq_nmod_poly_inv_series(fq_nmod_struct * Qinv, const fq_nmod_struct * Q, slong n, const fq_nmod_t cinv, const fq_nmod_ctx_t ctx) noexcept void fq_nmod_poly_inv_series(fq_nmod_poly_t Qinv, const fq_nmod_poly_t Q, slong n, const fq_nmod_ctx_t ctx) noexcept - # Given ``Q`` find ``Qinv`` such that ``Q * Qinv`` is - # ``1`` modulo `x^n`. The constant coefficient of ``Q`` must - # be invertible modulo the modulus of ``Q``. An exception is - # raised if this is not the case or if ``n = 0``. - - void _fq_nmod_poly_div_series(fq_nmod_struct *Q, const fq_nmod_struct *A, mp_limb_signed_t Alen, const fq_nmod_struct *B, mp_limb_signed_t Blen, mp_limb_signed_t n, const fq_nmod_ctx_t ctx) noexcept - # Set ``(Q, n)`` to the quotient of the series ``(A, Alen``) and - # ``(B, Blen)`` assuming ``Alen, Blen <= n``. We assume the bottom - # coefficient of ``B`` is invertible. - + void _fq_nmod_poly_div_series(fq_nmod_struct * Q, const fq_nmod_struct * A, mp_limb_signed_t Alen, const fq_nmod_struct * B, mp_limb_signed_t Blen, mp_limb_signed_t n, const fq_nmod_ctx_t ctx) noexcept void fq_nmod_poly_div_series(fq_nmod_poly_t Q, const fq_nmod_poly_t A, const fq_nmod_poly_t B, slong n, fq_nmod_ctx_t ctx) noexcept - # Set `Q` to the quotient of the series `A` by `B`, thinking of the series as - # though they were of length `n`. We assume that the bottom coefficient of - # `B` is invertible. - void fq_nmod_poly_gcd(fq_nmod_poly_t rop, const fq_nmod_poly_t op1, const fq_nmod_poly_t op2, const fq_nmod_ctx_t ctx) noexcept - # Sets ``rop`` to the greatest common divisor of ``op1`` and - # ``op2``, using the either the Euclidean or HGCD algorithm. The - # GCD of zero polynomials is defined to be zero, whereas the GCD of - # the zero polynomial and some other polynomial `P` is defined to be - # `P`. Except in the case where the GCD is zero, the GCD `G` is made - # monic. - - slong _fq_nmod_poly_gcd(fq_nmod_struct* G, const fq_nmod_struct* A, slong lenA, const fq_nmod_struct* B, slong lenB, const fq_nmod_ctx_t ctx) noexcept - # Computes the GCD of `A` of length ``lenA`` and `B` of length - # ``lenB``, where ``lenA >= lenB > 0`` and sets `G` to it. The - # length of the GCD `G` is returned by the function. No attempt is - # made to make the GCD monic. It is required that `G` have space for - # ``lenB`` coefficients. - - slong _fq_nmod_poly_gcd_euclidean_f(fq_nmod_t f, fq_nmod_struct *G, const fq_nmod_struct *A, slong lenA, const fq_nmod_struct *B, slong lenB, const fq_nmod_ctx_t ctx) noexcept - # Either sets `f = 1` and `G` to the greatest common divisor of - # `(A,\operatorname{len}(A))` and `(B, \operatorname{len}(B))` and returns its length, or sets - # `f` to a non-trivial factor of the modulus of ``ctx`` and leaves - # the contents of the vector `(G, lenB)` undefined. - # Assumes that `\operatorname{len}(A) \geq \operatorname{len}(B) > 0` and that the vector `G` - # has space for sufficiently many coefficients. - + slong _fq_nmod_poly_gcd(fq_nmod_struct * G, const fq_nmod_struct * A, slong lenA, const fq_nmod_struct * B, slong lenB, const fq_nmod_ctx_t ctx) noexcept + slong _fq_nmod_poly_gcd_euclidean_f(fq_nmod_t f, fq_nmod_struct * G, const fq_nmod_struct * A, slong lenA, const fq_nmod_struct * B, slong lenB, const fq_nmod_ctx_t ctx) noexcept void fq_nmod_poly_gcd_euclidean_f(fq_nmod_t f, fq_nmod_poly_t G, const fq_nmod_poly_t A, const fq_nmod_poly_t B, const fq_nmod_ctx_t ctx) noexcept - # Either sets `f = 1` and `G` to the greatest common divisor of `A` - # and `B` or sets `f` to a factor of the modulus of ``ctx``. - - slong _fq_nmod_poly_xgcd(fq_nmod_struct *G, fq_nmod_struct *S, fq_nmod_struct *T, const fq_nmod_struct *A, slong lenA, const fq_nmod_struct *B, slong lenB, const fq_nmod_ctx_t ctx) noexcept - # Computes the GCD of `A` and `B` together with cofactors `S` and `T` - # such that `S A + T B = G`. Returns the length of `G`. - # Assumes that `\operatorname{len}(A) \geq \operatorname{len}(B) \geq 1` and - # `(\operatorname{len}(A),\operatorname{len}(B)) \neq (1,1)`. - # No attempt is made to make the GCD monic. - # Requires that `G` have space for `\operatorname{len}(B)` coefficients. Writes - # `\operatorname{len}(B)-1` and `\operatorname{len}(A)-1` coefficients to `S` and `T`, respectively. - # Note that, in fact, `\operatorname{len}(S) \leq \max(\operatorname{len}(B) - \operatorname{len}(G), 1)` and - # `\operatorname{len}(T) \leq \max(\operatorname{len}(A) - \operatorname{len}(G), 1)`. - # No aliasing of input and output operands is permitted. - + slong _fq_nmod_poly_xgcd(fq_nmod_struct * G, fq_nmod_struct * S, fq_nmod_struct * T, const fq_nmod_struct * A, slong lenA, const fq_nmod_struct * B, slong lenB, const fq_nmod_ctx_t ctx) noexcept void fq_nmod_poly_xgcd(fq_nmod_poly_t G, fq_nmod_poly_t S, fq_nmod_poly_t T, const fq_nmod_poly_t A, const fq_nmod_poly_t B, const fq_nmod_ctx_t ctx) noexcept - # Computes the GCD of `A` and `B`. The GCD of zero polynomials is - # defined to be zero, whereas the GCD of the zero polynomial and some other - # polynomial `P` is defined to be `P`. Except in the case where - # the GCD is zero, the GCD `G` is made monic. - # Polynomials ``S`` and ``T`` are computed such that - # ``S*A + T*B = G``. The length of ``S`` will be at most - # ``lenB`` and the length of ``T`` will be at most ``lenA``. - - slong _fq_nmod_poly_xgcd_euclidean_f(fq_nmod_t f, fq_nmod_struct *G, fq_nmod_struct *S, fq_nmod_struct *T, const fq_nmod_struct *A, slong lenA, const fq_nmod_struct *B, slong lenB, const fq_nmod_ctx_t ctx) noexcept - # Either sets `f = 1` and computes the GCD of `A` and `B` together - # with cofactors `S` and `T` such that `S A + T B = G`; otherwise, - # sets `f` to a non-trivial factor of the modulus of ``ctx`` and - # leaves `G`, `S`, and `T` undefined. Returns the length of `G`. - # Assumes that `\operatorname{len}(A) \geq \operatorname{len}(B) \geq 1` and - # `(\operatorname{len}(A),\operatorname{len}(B)) \neq (1,1)`. - # No attempt is made to make the GCD monic. - # Requires that `G` have space for `\operatorname{len}(B)` coefficients. Writes - # `\operatorname{len}(B)-1` and `\operatorname{len}(A)-1` coefficients to `S` and `T`, respectively. - # Note that, in fact, `\operatorname{len}(S) \leq \max(\operatorname{len}(B) - \operatorname{len}(G), 1)` and - # `\operatorname{len}(T) \leq \max(\operatorname{len}(A) - \operatorname{len}(G), 1)`. - # No aliasing of input and output operands is permitted. - + slong _fq_nmod_poly_xgcd_euclidean_f(fq_nmod_t f, fq_nmod_struct * G, fq_nmod_struct * S, fq_nmod_struct * T, const fq_nmod_struct * A, slong lenA, const fq_nmod_struct * B, slong lenB, const fq_nmod_ctx_t ctx) noexcept void fq_nmod_poly_xgcd_euclidean_f(fq_nmod_t f, fq_nmod_poly_t G, fq_nmod_poly_t S, fq_nmod_poly_t T, const fq_nmod_poly_t A, const fq_nmod_poly_t B, const fq_nmod_ctx_t ctx) noexcept - # Either sets `f = 1` and computes the GCD of `A` and `B` or sets - # `f` to a non-trivial factor of the modulus of ``ctx``. - # If the GCD is computed, polynomials ``S`` and ``T`` are - # computed such that ``S*A + T*B = G``; otherwise, they are - # undefined. The length of ``S`` will be at most ``lenB`` and - # the length of ``T`` will be at most ``lenA``. - # The GCD of zero polynomials is defined to be zero, whereas the GCD - # of the zero polynomial and some other polynomial `P` is defined to - # be `P`. Except in the case where the GCD is zero, the GCD `G` is - # made monic. - - int _fq_nmod_poly_divides(fq_nmod_struct *Q, const fq_nmod_struct *A, slong lenA, const fq_nmod_struct *B, slong lenB, const fq_nmod_t invB, const fq_nmod_ctx_t ctx) noexcept - # Returns `1` if ``(B, lenB)`` divides ``(A, lenA)`` exactly and - # sets `Q` to the quotient, otherwise returns `0`. - # It is assumed that `\operatorname{len}(A) \geq \operatorname{len}(B) > 0` and that `Q` has space - # for `\operatorname{len}(A) - \operatorname{len}(B) + 1` coefficients. - # Aliasing of `Q` with either of the inputs is not permitted. - # This function is currently unoptimised and provided for convenience - # only. - + int _fq_nmod_poly_divides(fq_nmod_struct * Q, const fq_nmod_struct * A, slong lenA, const fq_nmod_struct * B, slong lenB, const fq_nmod_t invB, const fq_nmod_ctx_t ctx) noexcept int fq_nmod_poly_divides(fq_nmod_poly_t Q, const fq_nmod_poly_t A, const fq_nmod_poly_t B, const fq_nmod_ctx_t ctx) noexcept - # Returns `1` if `B` divides `A` exactly and sets `Q` to the quotient, - # otherwise returns `0`. - # This function is currently unoptimised and provided for convenience - # only. - - void _fq_nmod_poly_derivative(fq_nmod_struct *rop, const fq_nmod_struct *op, slong len, const fq_nmod_ctx_t ctx) noexcept - # Sets ``(rop, len - 1)`` to the derivative of ``(op, len)``. - # Also handles the cases where ``len`` is `0` or `1` correctly. - # Supports aliasing of ``rop`` and ``op``. - + void _fq_nmod_poly_derivative(fq_nmod_struct * rop, const fq_nmod_struct * op, slong len, const fq_nmod_ctx_t ctx) noexcept void fq_nmod_poly_derivative(fq_nmod_poly_t rop, const fq_nmod_poly_t op, const fq_nmod_ctx_t ctx) noexcept - # Sets ``rop`` to the derivative of ``op``. - void _fq_nmod_poly_invsqrt_series(fq_nmod_struct * g, const fq_nmod_struct * h, slong n, fq_nmod_ctx_t mod) noexcept - # Set the first `n` terms of `g` to the series expansion of `1/\sqrt{h}`. - # It is assumed that `n > 0`, that `h` has constant term 1 and that `h` - # is zero-padded as necessary to length `n`. Aliasing is not permitted. - void fq_nmod_poly_invsqrt_series(fq_nmod_poly_t g, const fq_nmod_poly_t h, slong n, fq_nmod_ctx_t ctx) noexcept - # Set `g` to the series expansion of `1/\sqrt{h}` to order `O(x^n)`. - # It is assumed that `h` has constant term 1. - void _fq_nmod_poly_sqrt_series(fq_nmod_struct * g, const fq_nmod_struct * h, slong n, fq_nmod_ctx_t ctx) noexcept - # Set the first `n` terms of `g` to the series expansion of `\sqrt{h}`. - # It is assumed that `n > 0`, that `h` has constant term 1 and that `h` - # is zero-padded as necessary to length `n`. Aliasing is not permitted. - void fq_nmod_poly_sqrt_series(fq_nmod_poly_t g, const fq_nmod_poly_t h, slong n, fq_nmod_ctx_t ctx) noexcept - # Set `g` to the series expansion of `\sqrt{h}` to order `O(x^n)`. - # It is assumed that `h` has constant term 1. - int _fq_nmod_poly_sqrt(fq_nmod_struct * s, const fq_nmod_struct * p, slong n, fq_nmod_ctx_t mod) noexcept - # If ``(p, n)`` is a perfect square, sets ``(s, n / 2 + 1)`` - # to a square root of `p` and returns 1. Otherwise returns 0. - int fq_nmod_poly_sqrt(fq_nmod_poly_t s, const fq_nmod_poly_t p, fq_nmod_ctx_t mod) noexcept - # If `p` is a perfect square, sets `s` to a square root of `p` - # and returns 1. Otherwise returns 0. - - void _fq_nmod_poly_evaluate_fq_nmod(fq_nmod_t rop, const fq_nmod_struct *op, slong len, const fq_nmod_t a, const fq_nmod_ctx_t ctx) noexcept - # Sets ``rop`` to ``(op, len)`` evaluated at `a`. - # Supports zero padding. There are no restrictions on ``len``, that - # is, ``len`` is allowed to be zero, too. - + void _fq_nmod_poly_evaluate_fq_nmod(fq_nmod_t rop, const fq_nmod_struct * op, slong len, const fq_nmod_t a, const fq_nmod_ctx_t ctx) noexcept void fq_nmod_poly_evaluate_fq_nmod(fq_nmod_t rop, const fq_nmod_poly_t f, const fq_nmod_t a, const fq_nmod_ctx_t ctx) noexcept - # Sets ``rop`` to the value of `f(a)`. - # As the coefficient ring `\mathbf{F}_q` is finite, Horner's method - # is sufficient. - - void _fq_nmod_poly_compose(fq_nmod_struct *rop, const fq_nmod_struct *op1, slong len1, const fq_nmod_struct *op2, slong len2, const fq_nmod_ctx_t ctx) noexcept - # Sets ``rop`` to the composition of ``(op1, len1)`` and - # ``(op2, len2)``. - # Assumes that ``rop`` has space for ``(len1-1)*(len2-1) + 1`` - # coefficients. Assumes that ``op1`` and ``op2`` are non-zero - # polynomials. Does not support aliasing between any of the inputs and - # the output. - + void _fq_nmod_poly_compose(fq_nmod_struct * rop, const fq_nmod_struct * op1, slong len1, const fq_nmod_struct * op2, slong len2, const fq_nmod_ctx_t ctx) noexcept void fq_nmod_poly_compose(fq_nmod_poly_t rop, const fq_nmod_poly_t op1, const fq_nmod_poly_t op2, const fq_nmod_ctx_t ctx) noexcept - # Sets ``rop`` to the composition of ``op1`` and ``op2``. - # To be precise about the order of composition, denoting ``rop``, - # ``op1``, and ``op2`` by `f`, `g`, and `h`, respectively, - # sets `f(t) = g(h(t))`. - void _fq_nmod_poly_compose_mod_horner(fq_nmod_struct * res, const fq_nmod_struct * f, slong lenf, const fq_nmod_struct * g, const fq_nmod_struct * h, slong lenh, const fq_nmod_ctx_t ctx) noexcept - # Sets ``res`` to the composition `f(g)` modulo `h`. We require that - # `h` is nonzero and that the length of `g` is one less than the - # length of `h` (possibly with zero padding). The output is not allowed - # to be aliased with any of the inputs. - # The algorithm used is Horner's rule. - void fq_nmod_poly_compose_mod_horner(fq_nmod_poly_t res, const fq_nmod_poly_t f, const fq_nmod_poly_t g, const fq_nmod_poly_t h, const fq_nmod_ctx_t ctx) noexcept - # Sets ``res`` to the composition `f(g)` modulo `h`. We require that - # `h` is nonzero. The algorithm used is Horner's rule. - void _fq_nmod_poly_compose_mod_horner_preinv(fq_nmod_struct * res, const fq_nmod_struct * f, slong lenf, const fq_nmod_struct * g, const fq_nmod_struct * h, slong lenh, const fq_nmod_struct * hinv, slong lenhiv, const fq_nmod_ctx_t ctx) noexcept - # Sets ``res`` to the composition `f(g)` modulo `h`. We require - # that `h` is nonzero and that the length of `g` is one less than - # the length of `h` (possibly with zero padding). We also require - # that the length of `f` is less than the length of - # `h`. Furthermore, we require ``hinv`` to be the inverse of the - # reverse of ``h``. The output is not allowed to be aliased with - # any of the inputs. - # The algorithm used is Horner's rule. - void fq_nmod_poly_compose_mod_horner_preinv(fq_nmod_poly_t res, const fq_nmod_poly_t f, const fq_nmod_poly_t g, const fq_nmod_poly_t h, const fq_nmod_poly_t hinv, const fq_nmod_ctx_t ctx) noexcept - # Sets ``res`` to the composition `f(g)` modulo `h`. We require - # that `h` is nonzero and that `f` has smaller degree than - # `h`. Furthermore, we require ``hinv`` to be the inverse of the - # reverse of ``h``. The algorithm used is Horner's rule. - void _fq_nmod_poly_compose_mod_brent_kung(fq_nmod_struct * res, const fq_nmod_struct * f, slong lenf, const fq_nmod_struct * g, const fq_nmod_struct * h, slong lenh, const fq_nmod_ctx_t ctx) noexcept - # Sets ``res`` to the composition `f(g)` modulo `h`. We require - # that `h` is nonzero and that the length of `g` is one less than - # the length of `h` (possibly with zero padding). We also require - # that the length of `f` is less than the length of `h`. The output - # is not allowed to be aliased with any of the inputs. - # The algorithm used is the Brent-Kung matrix algorithm. - void fq_nmod_poly_compose_mod_brent_kung(fq_nmod_poly_t res, const fq_nmod_poly_t f, const fq_nmod_poly_t g, const fq_nmod_poly_t h, const fq_nmod_ctx_t ctx) noexcept - # Sets ``res`` to the composition `f(g)` modulo `h`. We require - # that `h` is nonzero and that `f` has smaller degree than `h`. The - # algorithm used is the Brent-Kung matrix algorithm. - void _fq_nmod_poly_compose_mod_brent_kung_preinv(fq_nmod_struct * res, const fq_nmod_struct * f, slong lenf, const fq_nmod_struct * g, const fq_nmod_struct * h, slong lenh, const fq_nmod_struct * hinv, slong lenhiv, const fq_nmod_ctx_t ctx) noexcept - # Sets ``res`` to the composition `f(g)` modulo `h`. We require - # that `h` is nonzero and that the length of `g` is one less than - # the length of `h` (possibly with zero padding). We also require - # that the length of `f` is less than the length of - # `h`. Furthermore, we require ``hinv`` to be the inverse of the - # reverse of ``h``. The output is not allowed to be aliased with - # any of the inputs. - # The algorithm used is the Brent-Kung matrix algorithm. - void fq_nmod_poly_compose_mod_brent_kung_preinv(fq_nmod_poly_t res, const fq_nmod_poly_t f, const fq_nmod_poly_t g, const fq_nmod_poly_t h, const fq_nmod_poly_t hinv, const fq_nmod_ctx_t ctx) noexcept - # Sets ``res`` to the composition `f(g)` modulo `h`. We require - # that `h` is nonzero and that `f` has smaller degree than - # `h`. Furthermore, we require ``hinv`` to be the inverse of the - # reverse of ``h``. The algorithm used is the Brent-Kung matrix - # algorithm. - void _fq_nmod_poly_compose_mod(fq_nmod_struct * res, const fq_nmod_struct * f, slong lenf, const fq_nmod_struct * g, const fq_nmod_struct * h, slong lenh, const fq_nmod_ctx_t ctx) noexcept - # Sets ``res`` to the composition `f(g)` modulo `h`. We require - # that `h` is nonzero and that the length of `g` is one less than - # the length of `h` (possibly with zero padding). The output is not - # allowed to be aliased with any of the inputs. - void fq_nmod_poly_compose_mod(fq_nmod_poly_t res, const fq_nmod_poly_t f, const fq_nmod_poly_t g, const fq_nmod_poly_t h, const fq_nmod_ctx_t ctx) noexcept - # Sets ``res`` to the composition `f(g)` modulo `h`. We require - # that `h` is nonzero. - void _fq_nmod_poly_compose_mod_preinv(fq_nmod_struct * res, const fq_nmod_struct * f, slong lenf, const fq_nmod_struct * g, const fq_nmod_struct * h, slong lenh, const fq_nmod_struct * hinv, slong lenhiv, const fq_nmod_ctx_t ctx) noexcept - # Sets ``res`` to the composition `f(g)` modulo `h`. We require - # that `h` is nonzero and that the length of `g` is one less than - # the length of `h` (possibly with zero padding). We also require - # that the length of `f` is less than the length of - # `h`. Furthermore, we require ``hinv`` to be the inverse of the - # reverse of ``h``. The output is not allowed to be aliased with - # any of the inputs. - void fq_nmod_poly_compose_mod_preinv(fq_nmod_poly_t res, const fq_nmod_poly_t f, const fq_nmod_poly_t g, const fq_nmod_poly_t h, const fq_nmod_poly_t hinv, const fq_nmod_ctx_t ctx) noexcept - # Sets ``res`` to the composition `f(g)` modulo `h`. We require - # that `h` is nonzero and that `f` has smaller degree than - # `h`. Furthermore, we require ``hinv`` to be the inverse of the - # reverse of ``h``. - void _fq_nmod_poly_reduce_matrix_mod_poly (fq_nmod_mat_t A, const fq_nmod_mat_t B, const fq_nmod_poly_t f, const fq_nmod_ctx_t ctx) noexcept - # Sets the ith row of ``A`` to the reduction of the ith row of `B` modulo - # `f` for `i=1,\ldots,\sqrt{\deg(f)}`. We require `B` to be at least - # a `\sqrt{\deg(f)}\times \deg(f)` matrix and `f` to be nonzero. - - void _fq_nmod_poly_precompute_matrix (fq_nmod_mat_t A, const fq_nmod_struct* f, const fq_nmod_struct* g, slong leng, const fq_nmod_struct* ginv, slong lenginv, const fq_nmod_ctx_t ctx) noexcept - # Sets the ith row of ``A`` to `f^i` modulo `g` for - # `i=1,\ldots,\sqrt{\deg(g)}`. We require `A` to be a - # `\sqrt{\deg(g)}\times \deg(g)` matrix. We require ``ginv`` to - # be the inverse of the reverse of ``g`` and `g` to be nonzero. - + void _fq_nmod_poly_precompute_matrix (fq_nmod_mat_t A, const fq_nmod_struct * f, const fq_nmod_struct * g, slong leng, const fq_nmod_struct * ginv, slong lenginv, const fq_nmod_ctx_t ctx) noexcept void fq_nmod_poly_precompute_matrix (fq_nmod_mat_t A, const fq_nmod_poly_t f, const fq_nmod_poly_t g, const fq_nmod_poly_t ginv, const fq_nmod_ctx_t ctx) noexcept - # Sets the ith row of ``A`` to `f^i` modulo `g` for - # `i=1,\ldots,\sqrt{\deg(g)}`. We require `A` to be a - # `\sqrt{\deg(g)}\times \deg(g)` matrix. We require ``ginv`` to - # be the inverse of the reverse of ``g``. - - void _fq_nmod_poly_compose_mod_brent_kung_precomp_preinv(fq_nmod_struct* res, const fq_nmod_struct* f, slong lenf, const fq_nmod_mat_t A, const fq_nmod_struct* h, slong lenh, const fq_nmod_struct* hinv, slong lenhinv, const fq_nmod_ctx_t ctx) noexcept - # Sets ``res`` to the composition `f(g)` modulo `h`. We require - # that `h` is nonzero. We require that the ith row of `A` contains - # `g^i` for `i=1,\ldots,\sqrt{\deg(h)}`, i.e. `A` is a - # `\sqrt{\deg(h)}\times \deg(h)` matrix. We also require that the - # length of `f` is less than the length of `h`. Furthermore, we - # require ``hinv`` to be the inverse of the reverse of ``h``. - # The output is not allowed to be aliased with any of the inputs. - # The algorithm used is the Brent-Kung matrix algorithm. - + void _fq_nmod_poly_compose_mod_brent_kung_precomp_preinv(fq_nmod_struct * res, const fq_nmod_struct * f, slong lenf, const fq_nmod_mat_t A, const fq_nmod_struct * h, slong lenh, const fq_nmod_struct * hinv, slong lenhinv, const fq_nmod_ctx_t ctx) noexcept void fq_nmod_poly_compose_mod_brent_kung_precomp_preinv(fq_nmod_poly_t res, const fq_nmod_poly_t f, const fq_nmod_mat_t A, const fq_nmod_poly_t h, const fq_nmod_poly_t hinv, const fq_nmod_ctx_t ctx) noexcept - # Sets ``res`` to the composition `f(g)` modulo `h`. We require - # that the ith row of `A` contains `g^i` for - # `i=1,\ldots,\sqrt{\deg(h)}`, i.e. `A` is a `\sqrt{\deg(h)}\times - # \deg(h)` matrix. We require that `h` is nonzero and that `f` has - # smaller degree than `h`. Furthermore, we require ``hinv`` to be - # the inverse of the reverse of ``h``. This version of Brent-Kung - # modular composition is particularly useful if one has to perform - # several modular composition of the form `f(g)` modulo `h` for - # fixed `g` and `h`. - - int _fq_nmod_poly_fprint_pretty(FILE *file, const fq_nmod_struct *poly, slong len, const char *x, const fq_nmod_ctx_t ctx) noexcept - # Prints the pretty representation of ``(poly, len)`` to the stream - # ``file``, using the string ``x`` to represent the indeterminate. - # In case of success, returns a positive value. In case of failure, - # returns a non-positive value. - - int fq_nmod_poly_fprint_pretty(FILE * file, const fq_nmod_poly_t poly, const char *x, const fq_nmod_ctx_t ctx) noexcept - # Prints the pretty representation of ``poly`` to the stream - # ``file``, using the string ``x`` to represent the indeterminate. - # In case of success, returns a positive value. In case of failure, - # returns a non-positive value. - - int _fq_nmod_poly_print_pretty(const fq_nmod_struct *poly, slong len, const char *x, const fq_nmod_ctx_t ctx) noexcept - # Prints the pretty representation of ``(poly, len)`` to ``stdout``, - # using the string ``x`` to represent the indeterminate. - # In case of success, returns a positive value. In case of failure, - # returns a non-positive value. - - int fq_nmod_poly_print_pretty(const fq_nmod_poly_t poly, const char *x, const fq_nmod_ctx_t ctx) noexcept - # Prints the pretty representation of ``poly`` to ``stdout``, - # using the string ``x`` to represent the indeterminate. - # In case of success, returns a positive value. In case of failure, - # returns a non-positive value. - - int _fq_nmod_poly_fprint(FILE *file, const fq_nmod_struct *poly, slong len, const fq_nmod_ctx_t ctx) noexcept - # Prints the pretty representation of ``(poly, len)`` to the stream - # ``file``. - # In case of success, returns a positive value. In case of failure, - # returns a non-positive value. - + int _fq_nmod_poly_fprint_pretty(FILE * file, const fq_nmod_struct * poly, slong len, const char * x, const fq_nmod_ctx_t ctx) noexcept + int fq_nmod_poly_fprint_pretty(FILE * file, const fq_nmod_poly_t poly, const char * x, const fq_nmod_ctx_t ctx) noexcept + int _fq_nmod_poly_print_pretty(const fq_nmod_struct * poly, slong len, const char * x, const fq_nmod_ctx_t ctx) noexcept + int fq_nmod_poly_print_pretty(const fq_nmod_poly_t poly, const char * x, const fq_nmod_ctx_t ctx) noexcept + int _fq_nmod_poly_fprint(FILE * file, const fq_nmod_struct * poly, slong len, const fq_nmod_ctx_t ctx) noexcept int fq_nmod_poly_fprint(FILE * file, const fq_nmod_poly_t poly, const fq_nmod_ctx_t ctx) noexcept - # Prints the pretty representation of ``poly`` to the stream - # ``file``. - # In case of success, returns a positive value. In case of failure, - # returns a non-positive value. - - int _fq_nmod_poly_print(const fq_nmod_struct *poly, slong len, const fq_nmod_ctx_t ctx) noexcept - # Prints the pretty representation of ``(poly, len)`` to ``stdout``. - # In case of success, returns a positive value. In case of failure, - # returns a non-positive value. - + int _fq_nmod_poly_print(const fq_nmod_struct * poly, slong len, const fq_nmod_ctx_t ctx) noexcept int fq_nmod_poly_print(const fq_nmod_poly_t poly, const fq_nmod_ctx_t ctx) noexcept - # Prints the representation of ``poly`` to ``stdout``. - # In case of success, returns a positive value. In case of failure, - # returns a non-positive value. - char * _fq_nmod_poly_get_str(const fq_nmod_struct * poly, slong len, const fq_nmod_ctx_t ctx) noexcept - # Returns the plain FLINT string representation of the polynomial - # ``(poly, len)``. - char * fq_nmod_poly_get_str(const fq_nmod_poly_t poly, const fq_nmod_ctx_t ctx) noexcept - # Returns the plain FLINT string representation of the polynomial - # ``poly``. - char * _fq_nmod_poly_get_str_pretty(const fq_nmod_struct * poly, slong len, const char * x, const fq_nmod_ctx_t ctx) noexcept - # Returns a pretty representation of the polynomial - # ``(poly, len)`` using the null-terminated string ``x`` as the - # variable name. - char * fq_nmod_poly_get_str_pretty(const fq_nmod_poly_t poly, const char * x, const fq_nmod_ctx_t ctx) noexcept - # Returns a pretty representation of the polynomial ``poly`` using the - # null-terminated string ``x`` as the variable name - void fq_nmod_poly_inflate(fq_nmod_poly_t result, const fq_nmod_poly_t input, ulong inflation, const fq_nmod_ctx_t ctx) noexcept - # Sets ``result`` to the inflated polynomial `p(x^n)` where - # `p` is given by ``input`` and `n` is given by ``inflation``. - void fq_nmod_poly_deflate(fq_nmod_poly_t result, const fq_nmod_poly_t input, ulong deflation, const fq_nmod_ctx_t ctx) noexcept - # Sets ``result`` to the deflated polynomial `p(x^{1/n})` where - # `p` is given by ``input`` and `n` is given by ``deflation``. - # Requires `n > 0`. - ulong fq_nmod_poly_deflation(const fq_nmod_poly_t input, const fq_nmod_ctx_t ctx) noexcept - # Returns the largest integer by which ``input`` can be deflated. - # As special cases, returns 0 if ``input`` is the zero polynomial - # and 1 of ``input`` is a constant polynomial. diff --git a/src/sage/libs/flint/fq_nmod_poly_factor.pxd b/src/sage/libs/flint/fq_nmod_poly_factor.pxd index 304d1a4f1a9..da8dd3686a0 100644 --- a/src/sage/libs/flint/fq_nmod_poly_factor.pxd +++ b/src/sage/libs/flint/fq_nmod_poly_factor.pxd @@ -2,7 +2,9 @@ # distutils: depends = flint/fq_nmod_poly_factor.h ################################################################################ -# This file is auto-generated. Do not modify by hand +# This file is auto-generated by the script +# SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py. +# Do not modify by hand! Fix and rerun the script instead. ################################################################################ from libc.stdio cimport FILE @@ -11,158 +13,33 @@ from sage.libs.mpfr.types cimport * from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void fq_nmod_poly_factor_init(fq_nmod_poly_factor_t fac, const fq_nmod_ctx_t ctx) noexcept - # Initialises ``fac`` for use. An :type:`fq_nmod_poly_factor_t` - # represents a polynomial in factorised form as a product of - # polynomials with associated exponents. - void fq_nmod_poly_factor_clear(fq_nmod_poly_factor_t fac, const fq_nmod_ctx_t ctx) noexcept - # Frees all memory associated with ``fac``. - void fq_nmod_poly_factor_realloc(fq_nmod_poly_factor_t fac, slong alloc, const fq_nmod_ctx_t ctx) noexcept - # Reallocates the factor structure to provide space for - # precisely ``alloc`` factors. - void fq_nmod_poly_factor_fit_length(fq_nmod_poly_factor_t fac, slong len, const fq_nmod_ctx_t ctx) noexcept - # Ensures that the factor structure has space for at least - # ``len`` factors. This function takes care of the case of - # repeated calls by always at least doubling the number of factors - # the structure can hold. - void fq_nmod_poly_factor_set(fq_nmod_poly_factor_t res, const fq_nmod_poly_factor_t fac, const fq_nmod_ctx_t ctx) noexcept - # Sets ``res`` to the same factorisation as ``fac``. - void fq_nmod_poly_factor_print_pretty(const fq_nmod_poly_factor_t fac, const char * var, const fq_nmod_ctx_t ctx) noexcept - # Pretty-prints the entries of ``fac`` to standard output. - void fq_nmod_poly_factor_print(const fq_nmod_poly_factor_t fac, const fq_nmod_ctx_t ctx) noexcept - # Prints the entries of ``fac`` to standard output. - void fq_nmod_poly_factor_insert(fq_nmod_poly_factor_t fac, const fq_nmod_poly_t poly, slong exp, const fq_nmod_ctx_t ctx) noexcept - # Inserts the factor ``poly`` with multiplicity ``exp`` into - # the factorisation ``fac``. - # If ``fac`` already contains ``poly``, then ``exp`` simply - # gets added to the exponent of the existing entry. - void fq_nmod_poly_factor_concat(fq_nmod_poly_factor_t res, const fq_nmod_poly_factor_t fac, const fq_nmod_ctx_t ctx) noexcept - # Concatenates two factorisations. - # This is equivalent to calling :func:`fq_nmod_poly_factor_insert` - # repeatedly with the individual factors of ``fac``. - # Does not support aliasing between ``res`` and ``fac``. - void fq_nmod_poly_factor_pow(fq_nmod_poly_factor_t fac, slong exp, const fq_nmod_ctx_t ctx) noexcept - # Raises ``fac`` to the power ``exp``. - ulong fq_nmod_poly_remove(fq_nmod_poly_t f, const fq_nmod_poly_t p, const fq_nmod_ctx_t ctx) noexcept - # Removes the highest possible power of ``p`` from ``f`` and - # returns the exponent. - bint fq_nmod_poly_is_irreducible(const fq_nmod_poly_t f, const fq_nmod_ctx_t ctx) noexcept - # Returns 1 if the polynomial ``f`` is irreducible, otherwise returns 0. - bint fq_nmod_poly_is_irreducible_ddf(const fq_nmod_poly_t f, const fq_nmod_ctx_t ctx) noexcept - # Returns 1 if the polynomial ``f`` is irreducible, otherwise returns 0. - # Uses fast distinct-degree factorisation. - bint fq_nmod_poly_is_irreducible_ben_or(const fq_nmod_poly_t f, const fq_nmod_ctx_t ctx) noexcept - # Returns 1 if the polynomial ``f`` is irreducible, otherwise returns 0. - # Uses Ben-Or's irreducibility test. - bint _fq_nmod_poly_is_squarefree(const fq_nmod_struct * f, slong len, const fq_nmod_ctx_t ctx) noexcept - # Returns 1 if ``(f, len)`` is squarefree, and 0 otherwise. As a - # special case, the zero polynomial is not considered squarefree. - # There are no restrictions on the length. - bint fq_nmod_poly_is_squarefree(const fq_nmod_poly_t f, const fq_nmod_ctx_t ctx) noexcept - # Returns 1 if ``f`` is squarefree, and 0 otherwise. As a special - # case, the zero polynomial is not considered squarefree. - bint fq_nmod_poly_factor_equal_deg_prob(fq_nmod_poly_t factor, flint_rand_t state, const fq_nmod_poly_t pol, slong d, const fq_nmod_ctx_t ctx) noexcept - # Probabilistic equal degree factorisation of ``pol`` into - # irreducible factors of degree ``d``. If it passes, a factor is - # placed in factor and 1 is returned, otherwise 0 is returned and - # the value of factor is undetermined. - # Requires that ``pol`` be monic, non-constant and squarefree. - void fq_nmod_poly_factor_equal_deg(fq_nmod_poly_factor_t factors, const fq_nmod_poly_t pol, slong d, const fq_nmod_ctx_t ctx) noexcept - # Assuming ``pol`` is a product of irreducible factors all of - # degree ``d``, finds all those factors and places them in - # factors. Requires that ``pol`` be monic, non-constant and - # squarefree. - void fq_nmod_poly_factor_split_single(fq_nmod_poly_t linfactor, const fq_nmod_poly_t input, const fq_nmod_ctx_t ctx) noexcept - # Assuming ``input`` is a product of factors all of degree 1, finds a single - # linear factor of ``input`` and places it in ``linfactor``. - # Requires that ``input`` be monic and non-constant. - - void fq_nmod_poly_factor_distinct_deg(fq_nmod_poly_factor_t res, const fq_nmod_poly_t poly, slong * const *degs, const fq_nmod_ctx_t ctx) noexcept - # Factorises a monic non-constant squarefree polynomial ``poly`` - # of degree `n` into factors `f[d]` such that for `1 \leq d \leq n` - # `f[d]` is the product of the monic irreducible factors of - # ``poly`` of degree `d`. Factors are stored in ``res``, - # associated powers of irreducible polynomials are stored in - # ``degs`` in the same order as factors. - # Requires that ``degs`` have enough space for irreducible polynomials' - # powers (maximum space required is `n * sizeof(slong)`). - + void fq_nmod_poly_factor_distinct_deg(fq_nmod_poly_factor_t res, const fq_nmod_poly_t poly, slong * const * degs, const fq_nmod_ctx_t ctx) noexcept void fq_nmod_poly_factor_squarefree(fq_nmod_poly_factor_t res, const fq_nmod_poly_t f, const fq_nmod_ctx_t ctx) noexcept - # Sets ``res`` to a squarefree factorization of ``f``. - void fq_nmod_poly_factor(fq_nmod_poly_factor_t res, fq_nmod_t lead, const fq_nmod_poly_t f, const fq_nmod_ctx_t ctx) noexcept - # Factorises a non-constant polynomial ``f`` into monic - # irreducible factors choosing the best algorithm for given modulo - # and degree. The output ``lead`` is set to the leading coefficient of `f` - # upon return. Choice of algorithm is based on heuristic measurements. - void fq_nmod_poly_factor_cantor_zassenhaus(fq_nmod_poly_factor_t res, const fq_nmod_poly_t f, const fq_nmod_ctx_t ctx) noexcept - # Factorises a non-constant polynomial ``f`` into monic - # irreducible factors using the Cantor-Zassenhaus algorithm. - void fq_nmod_poly_factor_kaltofen_shoup(fq_nmod_poly_factor_t res, const fq_nmod_poly_t poly, const fq_nmod_ctx_t ctx) noexcept - # Factorises a non-constant polynomial ``f`` into monic - # irreducible factors using the fast version of Cantor-Zassenhaus - # algorithm proposed by Kaltofen and Shoup (1998). More precisely - # this algorithm uses a “baby step/giant step” strategy for the - # distinct-degree factorization step. - void fq_nmod_poly_factor_berlekamp(fq_nmod_poly_factor_t factors, const fq_nmod_poly_t f, const fq_nmod_ctx_t ctx) noexcept - # Factorises a non-constant polynomial ``f`` into monic - # irreducible factors using the Berlekamp algorithm. - void fq_nmod_poly_factor_with_berlekamp(fq_nmod_poly_factor_t res, fq_nmod_t leading_coeff, const fq_nmod_poly_t f, const fq_nmod_ctx_t ctx) noexcept - # Factorises a general polynomial ``f`` into monic irreducible - # factors and sets ``leading_coeff`` to the leading coefficient - # of ``f``, or 0 if ``f`` is the zero polynomial. - # This function first checks for small special cases, deflates - # ``f`` if it is of the form `p(x^m)` for some `m > 1`, then - # performs a square-free factorisation, and finally runs Berlekamp - # on all the individual square-free factors. - void fq_nmod_poly_factor_with_cantor_zassenhaus(fq_nmod_poly_factor_t res, fq_nmod_t leading_coeff, const fq_nmod_poly_t f, const fq_nmod_ctx_t ctx) noexcept - # Factorises a general polynomial ``f`` into monic irreducible - # factors and sets ``leading_coeff`` to the leading coefficient - # of ``f``, or 0 if ``f`` is the zero polynomial. - # This function first checks for small special cases, deflates - # ``f`` if it is of the form `p(x^m)` for some `m > 1`, then - # performs a square-free factorisation, and finally runs - # Cantor-Zassenhaus on all the individual square-free factors. - void fq_nmod_poly_factor_with_kaltofen_shoup(fq_nmod_poly_factor_t res, fq_nmod_t leading_coeff, const fq_nmod_poly_t f, const fq_nmod_ctx_t ctx) noexcept - # Factorises a general polynomial ``f`` into monic irreducible - # factors and sets ``leading_coeff`` to the leading coefficient - # of ``f``, or 0 if ``f`` is the zero polynomial. - # This function first checks for small special cases, deflates - # ``f`` if it is of the form `p(x^m)` for some `m > 1`, then - # performs a square-free factorisation, and finally runs - # Kaltofen-Shoup on all the individual square-free factors. - - void fq_nmod_poly_iterated_frobenius_preinv(fq_nmod_poly_t *rop, slong n, const fq_nmod_poly_t v, const fq_nmod_poly_t vinv, const fq_nmod_ctx_t ctx) noexcept - # Sets ``rop[i]`` to be `x^{q^i} \bmod v` for `0 \le i < n`. - # It is required that ``vinv`` is the inverse of the reverse of - # ``v`` mod ``x^lenv``. - + void fq_nmod_poly_iterated_frobenius_preinv(fq_nmod_poly_t * rop, slong n, const fq_nmod_poly_t v, const fq_nmod_poly_t vinv, const fq_nmod_ctx_t ctx) noexcept void fq_nmod_poly_roots(fq_nmod_poly_factor_t r, const fq_nmod_poly_t f, int with_multiplicity, const fq_nmod_ctx_t ctx) noexcept - # Fill `r` with factors of the form `x - r_i` where the `r_i` are the distinct roots of a nonzero `f` in `F_q`. - # If `with\_multiplicity` is zero, the exponent `e_i` of the factor `x - r_i` is `1`. Otherwise, it is the largest `e_i` such that `(x-r_i)^e_i` divides `f`. - # This function throws if `f` is zero, but is otherwise always successful. diff --git a/src/sage/libs/flint/fq_nmod_vec.pxd b/src/sage/libs/flint/fq_nmod_vec.pxd index 3901d06488e..6c68e8e169f 100644 --- a/src/sage/libs/flint/fq_nmod_vec.pxd +++ b/src/sage/libs/flint/fq_nmod_vec.pxd @@ -2,7 +2,9 @@ # distutils: depends = flint/fq_nmod_vec.h ################################################################################ -# This file is auto-generated. Do not modify by hand +# This file is auto-generated by the script +# SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py. +# Do not modify by hand! Fix and rerun the script instead. ################################################################################ from libc.stdio cimport FILE @@ -11,63 +13,19 @@ from sage.libs.mpfr.types cimport * from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - fq_nmod_struct * _fq_nmod_vec_init(slong len, const fq_nmod_ctx_t ctx) noexcept - # Returns an initialised vector of ``fq_nmod``'s of given length. - void _fq_nmod_vec_clear(fq_nmod_struct * vec, slong len, const fq_nmod_ctx_t ctx) noexcept - # Clears the entries of ``(vec, len)`` and frees the space allocated - # for ``vec``. - void _fq_nmod_vec_randtest(fq_nmod_struct * f, flint_rand_t state, slong len, const fq_nmod_ctx_t ctx) noexcept - # Sets the entries of a vector of the given length to elements of - # the finite field. - int _fq_nmod_vec_fprint(FILE * file, const fq_nmod_struct * vec, slong len, const fq_nmod_ctx_t ctx) noexcept - # Prints the vector of given length to the stream ``file``. The - # format is the length followed by two spaces, then a space separated - # list of coefficients. If the length is zero, only `0` is printed. - # In case of success, returns a positive value. In case of failure, - # returns a non-positive value. - int _fq_nmod_vec_print(const fq_nmod_struct * vec, slong len, const fq_nmod_ctx_t ctx) noexcept - # Prints the vector of given length to ``stdout``. - # For further details, see ``_fq_nmod_vec_fprint()``. - void _fq_nmod_vec_set(fq_nmod_struct * vec1, const fq_nmod_struct * vec2, slong len2, const fq_nmod_ctx_t ctx) noexcept - # Makes a copy of ``(vec2, len2)`` into ``vec1``. - void _fq_nmod_vec_swap(fq_nmod_struct * vec1, fq_nmod_struct * vec2, slong len2, const fq_nmod_ctx_t ctx) noexcept - # Swaps the elements in ``(vec1, len2)`` and ``(vec2, len2)``. - void _fq_nmod_vec_zero(fq_nmod_struct * vec, slong len, const fq_nmod_ctx_t ctx) noexcept - # Zeros the entries of ``(vec, len)``. - void _fq_nmod_vec_neg(fq_nmod_struct * vec1, const fq_nmod_struct * vec2, slong len2, const fq_nmod_ctx_t ctx) noexcept - # Negates ``(vec2, len2)`` and places it into ``vec1``. - bint _fq_nmod_vec_equal(const fq_nmod_struct * vec1, const fq_nmod_struct * vec2, slong len, const fq_nmod_ctx_t ctx) noexcept - # Compares two vectors of the given length and returns `1` if they are - # equal, otherwise returns `0`. - bint _fq_nmod_vec_is_zero(const fq_nmod_struct * vec, slong len, const fq_nmod_ctx_t ctx) noexcept - # Returns `1` if ``(vec, len)`` is zero, and `0` otherwise. - void _fq_nmod_vec_add(fq_nmod_struct * res, const fq_nmod_struct * vec1, const fq_nmod_struct * vec2, slong len2, const fq_nmod_ctx_t ctx) noexcept - # Sets ``(res, len2)`` to the sum of ``(vec1, len2)`` - # and ``(vec2, len2)``. - void _fq_nmod_vec_sub(fq_nmod_struct * res, const fq_nmod_struct * vec1, const fq_nmod_struct * vec2, slong len2, const fq_nmod_ctx_t ctx) noexcept - # Sets ``(res, len2)`` to ``(vec1, len2)`` minus ``(vec2, len2)``. - void _fq_nmod_vec_scalar_addmul_fq_nmod(fq_nmod_struct * vec1, const fq_nmod_struct * vec2, slong len2, const fq_nmod_t c, const fq_nmod_ctx_t ctx) noexcept - # Adds ``(vec2, len2)`` times `c` to ``(vec1, len2)``, where - # `c` is a ``fq_nmod_t``. - void _fq_nmod_vec_scalar_submul_fq_nmod(fq_nmod_struct * vec1, const fq_nmod_struct * vec2, slong len2, const fq_nmod_t c, const fq_nmod_ctx_t ctx) noexcept - # Subtracts ``(vec2, len2)`` times `c` from ``(vec1, len2)``, - # where `c` is a ``fq_nmod_t``. - void _fq_nmod_vec_dot(fq_nmod_t res, const fq_nmod_struct * vec1, const fq_nmod_struct * vec2, slong len2, const fq_nmod_ctx_t ctx) noexcept - # Sets ``res`` to the dot product of (``vec1``, ``len``) - # and (``vec2``, ``len``). diff --git a/src/sage/libs/flint/fq_poly.pxd b/src/sage/libs/flint/fq_poly.pxd index 8b9efb8b8c8..2010796af67 100644 --- a/src/sage/libs/flint/fq_poly.pxd +++ b/src/sage/libs/flint/fq_poly.pxd @@ -2,7 +2,9 @@ # distutils: depends = flint/fq_poly.h ################################################################################ -# This file is auto-generated. Do not modify by hand +# This file is auto-generated by the script +# SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py. +# Do not modify by hand! Fix and rerun the script instead. ################################################################################ from libc.stdio cimport FILE @@ -11,1065 +13,190 @@ from sage.libs.mpfr.types cimport * from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void fq_poly_init(fq_poly_t poly, const fq_ctx_t ctx) noexcept - # Initialises ``poly`` for use, with context ctx, and setting its - # length to zero. A corresponding call to :func:`fq_poly_clear` - # must be made after finishing with the ``fq_poly_t`` to free the - # memory used by the polynomial. - void fq_poly_init2(fq_poly_t poly, slong alloc, const fq_ctx_t ctx) noexcept - # Initialises ``poly`` with space for at least ``alloc`` - # coefficients and sets the length to zero. The allocated - # coefficients are all set to zero. A corresponding call to - # :func:`fq_poly_clear` must be made after finishing with the - # ``fq_poly_t`` to free the memory used by the polynomial. - void fq_poly_realloc(fq_poly_t poly, slong alloc, const fq_ctx_t ctx) noexcept - # Reallocates the given polynomial to have space for ``alloc`` - # coefficients. If ``alloc`` is zero the polynomial is cleared - # and then reinitialised. If the current length is greater than - # ``alloc`` the polynomial is first truncated to length - # ``alloc``. - void fq_poly_fit_length(fq_poly_t poly, slong len, const fq_ctx_t ctx) noexcept - # If ``len`` is greater than the number of coefficients currently - # allocated, then the polynomial is reallocated to have space for at - # least ``len`` coefficients. No data is lost when calling this - # function. - # The function efficiently deals with the case where - # ``fit_length`` is called many times in small increments by at - # least doubling the number of allocated coefficients when length is - # larger than the number of coefficients currently allocated. - void _fq_poly_set_length(fq_poly_t poly, slong newlen, const fq_ctx_t ctx) noexcept - # Sets the coefficients of ``poly`` beyond ``len`` to zero and - # sets the length of ``poly`` to ``len``. - void fq_poly_clear(fq_poly_t poly, const fq_ctx_t ctx) noexcept - # Clears the given polynomial, releasing any memory used. It must - # be reinitialised in order to be used again. - void _fq_poly_normalise(fq_poly_t poly, const fq_ctx_t ctx) noexcept - # Sets the length of ``poly`` so that the top coefficient is - # non-zero. If all coefficients are zero, the length is set to - # zero. This function is mainly used internally, as all functions - # guarantee normalisation. - - void _fq_poly_normalise2(const fq_struct *poly, slong *length, const fq_ctx_t ctx) noexcept - # Sets the length ``length`` of ``(poly,length)`` so that the - # top coefficient is non-zero. If all coefficients are zero, the - # length is set to zero. This function is mainly used internally, as - # all functions guarantee normalisation. - + void _fq_poly_normalise2(const fq_struct * poly, slong * length, const fq_ctx_t ctx) noexcept void fq_poly_truncate(fq_poly_t poly, slong newlen, const fq_ctx_t ctx) noexcept - # Truncates the polynomial to length at most `n`. - void fq_poly_set_trunc(fq_poly_t poly1, fq_poly_t poly2, slong newlen, const fq_ctx_t ctx) noexcept - # Sets ``poly1`` to ``poly2`` truncated to length `n`. - - void _fq_poly_reverse(fq_struct* output, const fq_struct* input, slong len, slong m, const fq_ctx_t ctx) noexcept - # Sets ``output`` to the reverse of ``input``, which is of - # length ``len``, but thinking of it as a polynomial of - # length ``m``, notionally zero-padded if necessary. The - # length ``m`` must be non-negative, but there are no other - # restrictions. The polynomial ``output`` must have space for - # ``m`` coefficients. - + void _fq_poly_reverse(fq_struct * output, const fq_struct * input, slong len, slong m, const fq_ctx_t ctx) noexcept void fq_poly_reverse(fq_poly_t output, const fq_poly_t input, slong m, const fq_ctx_t ctx) noexcept - # Sets ``output`` to the reverse of ``input``, thinking of it - # as a polynomial of length ``m``, notionally zero-padded if - # necessary). The length ``m`` must be non-negative, but there - # are no other restrictions. The output polynomial will be set to - # length ``m`` and then normalised. - slong fq_poly_degree(const fq_poly_t poly, const fq_ctx_t ctx) noexcept - # Returns the degree of the polynomial ``poly``. - slong fq_poly_length(const fq_poly_t poly, const fq_ctx_t ctx) noexcept - # Returns the length of the polynomial ``poly``. - fq_struct * fq_poly_lead(const fq_poly_t poly, const fq_ctx_t ctx) noexcept - # Returns a pointer to the leading coefficient of ``poly``, or - # ``NULL`` if ``poly`` is the zero polynomial. - void fq_poly_randtest(fq_poly_t f, flint_rand_t state, slong len, const fq_ctx_t ctx) noexcept - # Sets `f` to a random polynomial of length at most ``len`` - # with entries in the field described by ``ctx``. - void fq_poly_randtest_not_zero(fq_poly_t f, flint_rand_t state, slong len, const fq_ctx_t ctx) noexcept - # Same as ``fq_poly_randtest`` but guarantees that the polynomial - # is not zero. - void fq_poly_randtest_monic(fq_poly_t f, flint_rand_t state, slong len, const fq_ctx_t ctx) noexcept - # Sets `f` to a random monic polynomial of length ``len`` with - # entries in the field described by ``ctx``. - void fq_poly_randtest_irreducible(fq_poly_t f, flint_rand_t state, slong len, const fq_ctx_t ctx) noexcept - # Sets `f` to a random monic, irreducible polynomial of length - # ``len`` with entries in the field described by ``ctx``. - - void _fq_poly_set(fq_struct *rop, const fq_struct *op, slong len, const fq_ctx_t ctx) noexcept - # Sets ``(rop, len``) to ``(op, len)``. - + void _fq_poly_set(fq_struct * rop, const fq_struct * op, slong len, const fq_ctx_t ctx) noexcept void fq_poly_set(fq_poly_t poly1, const fq_poly_t poly2, const fq_ctx_t ctx) noexcept - # Sets the polynomial ``poly1`` to the polynomial ``poly2``. - void fq_poly_set_fq(fq_poly_t poly, const fq_t c, const fq_ctx_t ctx) noexcept - # Sets the polynomial ``poly`` to ``c``. - void fq_poly_set_fmpz_mod_poly(fq_poly_t rop, const fmpz_mod_poly_t op, const fq_ctx_t ctx) noexcept - # Sets the polynomial ``rop`` to the polynomial ``op`` - void fq_poly_set_nmod_poly(fq_poly_t rop, const nmod_poly_t op, const fq_ctx_t ctx) noexcept - # Sets the polynomial ``rop`` to the polynomial ``op`` - void fq_poly_swap(fq_poly_t op1, fq_poly_t op2, const fq_ctx_t ctx) noexcept - # Swaps the two polynomials ``op1`` and ``op2``. - - void _fq_poly_zero(fq_struct *rop, slong len, const fq_ctx_t ctx) noexcept - # Sets ``(rop, len)`` to the zero polynomial. - + void _fq_poly_zero(fq_struct * rop, slong len, const fq_ctx_t ctx) noexcept void fq_poly_zero(fq_poly_t poly, const fq_ctx_t ctx) noexcept - # Sets ``poly`` to the zero polynomial. - void fq_poly_one(fq_poly_t poly, const fq_ctx_t ctx) noexcept - # Sets ``poly`` to the constant polynomial `1`. - void fq_poly_gen(fq_poly_t poly, const fq_ctx_t ctx) noexcept - # Sets ``poly`` to the polynomial `x`. - void fq_poly_make_monic(fq_poly_t rop, const fq_poly_t op, const fq_ctx_t ctx) noexcept - # Sets ``rop`` to ``op``, normed to have leading coefficient 1. - - void _fq_poly_make_monic(fq_struct *rop, const fq_struct *op, slong length, const fq_ctx_t ctx) noexcept - # Sets ``rop`` to ``(op,length)``, normed to have leading coefficient 1. - # Assumes that ``rop`` has enough space for the polynomial, assumes that - # ``op`` is not zero (and thus has an invertible leading coefficient). - + void _fq_poly_make_monic(fq_struct * rop, const fq_struct * op, slong length, const fq_ctx_t ctx) noexcept void fq_poly_get_coeff(fq_t x, const fq_poly_t poly, slong n, const fq_ctx_t ctx) noexcept - # Sets `x` to the coefficient of `X^n` in ``poly``. - void fq_poly_set_coeff(fq_poly_t poly, slong n, const fq_t x, const fq_ctx_t ctx) noexcept - # Sets the coefficient of `X^n` in ``poly`` to `x`. - void fq_poly_set_coeff_fmpz(fq_poly_t poly, slong n, const fmpz_t x, const fq_ctx_t ctx) noexcept - # Sets the coefficient of `X^n` in the polynomial to `x`, - # assuming `n \geq 0`. - bint fq_poly_equal(const fq_poly_t poly1, const fq_poly_t poly2, const fq_ctx_t ctx) noexcept - # Returns nonzero if the two polynomials ``poly1`` and ``poly2`` - # are equal, otherwise returns zero. - bint fq_poly_equal_trunc(const fq_poly_t poly1, const fq_poly_t poly2, slong n, const fq_ctx_t ctx) noexcept - # Notionally truncate ``poly1`` and ``poly2`` to length `n` and - # return nonzero if they are equal, otherwise return zero. - bint fq_poly_is_zero(const fq_poly_t poly, const fq_ctx_t ctx) noexcept - # Returns whether the polynomial ``poly`` is the zero polynomial. - bint fq_poly_is_one(const fq_poly_t op, const fq_ctx_t ctx) noexcept - # Returns whether the polynomial ``poly`` is equal - # to the constant polynomial `1`. - bint fq_poly_is_gen(const fq_poly_t op, const fq_ctx_t ctx) noexcept - # Returns whether the polynomial ``poly`` is equal - # to the polynomial `x`. - bint fq_poly_is_unit(const fq_poly_t op, const fq_ctx_t ctx) noexcept - # Returns whether the polynomial ``poly`` is a unit in the polynomial - # ring `\mathbf{F}_q[X]`, i.e. if it has degree `0` and is non-zero. - bint fq_poly_equal_fq(const fq_poly_t poly, const fq_t c, const fq_ctx_t ctx) noexcept - # Returns whether the polynomial ``poly`` is equal the (constant) - # `\mathbf{F}_q` element ``c`` - - void _fq_poly_add(fq_struct *res, const fq_struct *poly1, slong len1, const fq_struct *poly2, slong len2, const fq_ctx_t ctx) noexcept - # Sets ``res`` to the sum of ``(poly1,len1)`` and ``(poly2,len2)``. - + void _fq_poly_add(fq_struct * res, const fq_struct * poly1, slong len1, const fq_struct * poly2, slong len2, const fq_ctx_t ctx) noexcept void fq_poly_add(fq_poly_t res, const fq_poly_t poly1, const fq_poly_t poly2, const fq_ctx_t ctx) noexcept - # Sets ``res`` to the sum of ``poly1`` and ``poly2``. - void fq_poly_add_si(fq_poly_t res, const fq_poly_t poly1, slong c, const fq_ctx_t ctx) noexcept - # Sets ``res`` to the sum of ``poly1`` and ``c``. - void fq_poly_add_series(fq_poly_t res, const fq_poly_t poly1, const fq_poly_t poly2, slong n, const fq_ctx_t ctx) noexcept - # Notionally truncate ``poly1`` and ``poly2`` to length ``n`` and set - # ``res`` to the sum. - - void _fq_poly_sub(fq_struct *res, const fq_struct *poly1, slong len1, const fq_struct *poly2, slong len2, const fq_ctx_t ctx) noexcept - # Sets ``res`` to the difference of ``(poly1,len1)`` and ``(poly2,len2)``. - + void _fq_poly_sub(fq_struct * res, const fq_struct * poly1, slong len1, const fq_struct * poly2, slong len2, const fq_ctx_t ctx) noexcept void fq_poly_sub(fq_poly_t res, const fq_poly_t poly1, const fq_poly_t poly2, const fq_ctx_t ctx) noexcept - # Sets ``res`` to the difference of ``poly1`` and ``poly2``. - void fq_poly_sub_series(fq_poly_t res, const fq_poly_t poly1, const fq_poly_t poly2, slong n, const fq_ctx_t ctx) noexcept - # Notionally truncate ``poly1`` and ``poly2`` to length ``n`` and set - # ``res`` to the difference. - - void _fq_poly_neg(fq_struct *rop, const fq_struct *op, slong len, const fq_ctx_t ctx) noexcept - # Sets ``rop`` to the additive inverse of ``(poly,len)``. - + void _fq_poly_neg(fq_struct * rop, const fq_struct * op, slong len, const fq_ctx_t ctx) noexcept void fq_poly_neg(fq_poly_t res, const fq_poly_t poly, const fq_ctx_t ctx) noexcept - # Sets ``res`` to the additive inverse of ``poly``. - - void _fq_poly_scalar_mul_fq(fq_struct *rop, const fq_struct *op, slong len, const fq_t x, const fq_ctx_t ctx) noexcept - # Sets ``(rop,len)`` to the product of ``(op,len)`` by the - # scalar ``x``, in the context defined by ``ctx``. - + void _fq_poly_scalar_mul_fq(fq_struct * rop, const fq_struct * op, slong len, const fq_t x, const fq_ctx_t ctx) noexcept void fq_poly_scalar_mul_fq(fq_poly_t rop, const fq_poly_t op, const fq_t x, const fq_ctx_t ctx) noexcept - # Sets ``rop`` to the product of ``op`` by the scalar ``x``, in the context - # defined by ``ctx``. - - void _fq_poly_scalar_addmul_fq(fq_struct *rop, const fq_struct *op, slong len, const fq_t x, const fq_ctx_t ctx) noexcept - # Adds to ``(rop,len)`` the product of ``(op,len)`` by the - # scalar ``x``, in the context defined by ``ctx``. - # In particular, assumes the same length for ``op`` and - # ``rop``. - + void _fq_poly_scalar_addmul_fq(fq_struct * rop, const fq_struct * op, slong len, const fq_t x, const fq_ctx_t ctx) noexcept void fq_poly_scalar_addmul_fq(fq_poly_t rop, const fq_poly_t op, const fq_t x, const fq_ctx_t ctx) noexcept - # Adds to ``rop`` the product of ``op`` by the - # scalar ``x``, in the context defined by ``ctx``. - - void _fq_poly_scalar_submul_fq(fq_struct *rop, const fq_struct *op, slong len, const fq_t x, const fq_ctx_t ctx) noexcept - # Subtracts from ``(rop,len)`` the product of ``(op,len)`` by the - # scalar ``x``, in the context defined by ``ctx``. - # In particular, assumes the same length for ``op`` and - # ``rop``. - + void _fq_poly_scalar_submul_fq(fq_struct * rop, const fq_struct * op, slong len, const fq_t x, const fq_ctx_t ctx) noexcept void fq_poly_scalar_submul_fq(fq_poly_t rop, const fq_poly_t op, const fq_t x, const fq_ctx_t ctx) noexcept - # Subtracts from ``rop`` the product of ``op`` by the - # scalar ``x``, in the context defined by ``ctx``. - - void _fq_poly_scalar_div_fq(fq_struct *rop, const fq_struct *op, slong len, const fq_t x, const fq_ctx_t ctx) noexcept - # Sets ``(rop,len)`` to the quotient of ``(op,len)`` by the - # scalar ``x``, in the context defined by ``ctx``. An exception is raised - # if ``x`` is zero. - + void _fq_poly_scalar_div_fq(fq_struct * rop, const fq_struct * op, slong len, const fq_t x, const fq_ctx_t ctx) noexcept void fq_poly_scalar_div_fq(fq_poly_t rop, const fq_poly_t op, const fq_t x, const fq_ctx_t ctx) noexcept - # Sets ``rop`` to the quotient of ``op`` by the scalar ``x``, in the context - # defined by ``ctx``. An exception is raised if ``x`` is zero. - - void _fq_poly_mul_classical(fq_struct *rop, const fq_struct *op1, slong len1, const fq_struct *op2, slong len2, const fq_ctx_t ctx) noexcept - # Sets ``(rop, len1 + len2 - 1)`` to the product of ``(op1, len1)`` - # and ``(op2, len2)``, assuming that ``len1`` is at least ``len2`` - # and neither is zero. - # Permits zero padding. Does not support aliasing of ``rop`` - # with either ``op1`` or ``op2``. - + void _fq_poly_mul_classical(fq_struct * rop, const fq_struct * op1, slong len1, const fq_struct * op2, slong len2, const fq_ctx_t ctx) noexcept void fq_poly_mul_classical(fq_poly_t rop, const fq_poly_t op1, const fq_poly_t op2, const fq_ctx_t ctx) noexcept - # Sets ``rop`` to the product of ``op1`` and ``op2`` - # using classical polynomial multiplication. - - void _fq_poly_mul_reorder(fq_struct *rop, const fq_struct *op1, slong len1, const fq_struct *op2, slong len2, const fq_ctx_t ctx) noexcept - # Sets ``(rop, len1 + len2 - 1)`` to the product of ``(op1, len1)`` - # and ``(op2, len2)``, assuming that ``len1`` and ``len2`` are - # non-zero. - # Permits zero padding. Supports aliasing. - + void _fq_poly_mul_reorder(fq_struct * rop, const fq_struct * op1, slong len1, const fq_struct * op2, slong len2, const fq_ctx_t ctx) noexcept void fq_poly_mul_reorder(fq_poly_t rop, const fq_poly_t op1, const fq_poly_t op2, const fq_ctx_t ctx) noexcept - # Sets ``rop`` to the product of ``op1`` and ``op2``, - # reordering the two indeterminates `X` and `Y` when viewing - # the polynomials as elements of `\mathbf{F}_p[X,Y]`. - # Suppose `\mathbf{F}_q = \mathbf{F}_p[X]/ (f(X))` and recall - # that elements of `\mathbf{F}_q` are internally represented - # by elements of type ``fmpz_poly``. For small degree extensions - # but polynomials in `\mathbf{F}_q[Y]` of large degree `n`, we - # change the representation to - # .. math :: - # \begin{split} - # g(Y) & = \sum_{i=0}^{n} a_i(X) Y^i \\ - # & = \sum_{j=0}^{d} \sum_{i=0}^{n} \text{Coeff}(a_i(X), j) Y^i. - # \end{split} - # This allows us to use a poor algorithm (such as classical multiplication) - # in the `X`-direction and leverage the existing fast integer - # multiplication routines in the `Y`-direction where the polynomial - # degree `n` is large. - - void _fq_poly_mul_univariate(fq_struct *rop, const fq_struct *op1, slong len1, const fq_struct *op2, slong len2, const fq_ctx_t ctx) noexcept - # Sets ``(rop, len1 + len2 - 1)`` to the product of ``(op1, len1)`` - # and ``(op2, len2)``. - # Permits zero padding and places no assumptions on the - # lengths ``len1`` and ``len2``. Supports aliasing. - + void _fq_poly_mul_univariate(fq_struct * rop, const fq_struct * op1, slong len1, const fq_struct * op2, slong len2, const fq_ctx_t ctx) noexcept void fq_poly_mul_univariate(fq_poly_t rop, const fq_poly_t op1, const fq_poly_t op2, const fq_ctx_t ctx) noexcept - # Sets ``rop`` to the product of ``op1`` and ``op2`` - # using a bivariate to univariate transformation and reducing - # this problem to multiplying two univariate polynomials. - - void _fq_poly_mul_KS(fq_struct *rop, const fq_struct *op1, slong len1, const fq_struct *op2, slong len2, const fq_ctx_t ctx) noexcept - # Sets ``(rop, len1 + len2 - 1)`` to the product of ``(op1, len1)`` - # and ``(op2, len2)``. - # Permits zero padding and places no assumptions on the - # lengths ``len1`` and ``len2``. Supports aliasing. - + void _fq_poly_mul_KS(fq_struct * rop, const fq_struct * op1, slong len1, const fq_struct * op2, slong len2, const fq_ctx_t ctx) noexcept void fq_poly_mul_KS(fq_poly_t rop, const fq_poly_t op1, const fq_poly_t op2, const fq_ctx_t ctx) noexcept - # Sets ``rop`` to the product of ``op1`` and ``op2`` - # using Kronecker substitution, that is, by encoding each - # coefficient in `\mathbf{F}_{q}` as an integer and reducing - # this problem to multiplying two polynomials over the integers. - - void _fq_poly_mul(fq_struct *rop, const fq_struct *op1, slong len1, const fq_struct *op2, slong len2, const fq_ctx_t ctx) noexcept - # Sets ``(rop, len1 + len2 - 1)`` to the product of ``(op1, len1)`` - # and ``(op2, len2)``, choosing an appropriate algorithm. - # Permits zero padding. Does not support aliasing. - + void _fq_poly_mul(fq_struct * rop, const fq_struct * op1, slong len1, const fq_struct * op2, slong len2, const fq_ctx_t ctx) noexcept void fq_poly_mul(fq_poly_t rop, const fq_poly_t op1, const fq_poly_t op2, const fq_ctx_t ctx) noexcept - # Sets ``rop`` to the product of ``op1`` and ``op2``, - # choosing an appropriate algorithm. - - void _fq_poly_mullow_classical(fq_struct *rop, const fq_struct *op1, slong len1, const fq_struct *op2, slong len2, slong n, const fq_ctx_t ctx) noexcept - # Sets ``(rop, n)`` to the first `n` coefficients of ``(op1, len1)`` - # multiplied by ``(op2, len2)``. - # Assumes ``0 < n <= len1 + len2 - 1``. Assumes neither ``len1`` nor - # ``len2`` is zero. - + void _fq_poly_mullow_classical(fq_struct * rop, const fq_struct * op1, slong len1, const fq_struct * op2, slong len2, slong n, const fq_ctx_t ctx) noexcept void fq_poly_mullow_classical(fq_poly_t rop, const fq_poly_t op1, const fq_poly_t op2, slong n, const fq_ctx_t ctx) noexcept - # Sets ``rop`` to the product of ``poly1`` and ``poly2``, computed - # using the classical or schoolbook method. - - void _fq_poly_mullow_univariate(fq_struct *rop, const fq_struct *op1, slong len1, const fq_struct *op2, slong len2, slong n, const fq_ctx_t ctx) noexcept - # Sets ``(rop, n)`` to the lowest `n` coefficients of the product of - # ``(op1, len1)`` and ``(op2, len2)``, computed using a - # bivariate to univariate transformation. - # Assumes that ``len1`` and ``len2`` are positive, but does allow - # for the polynomials to be zero-padded. The polynomials may be zero, - # too. Assumes `n` is positive. Supports aliasing between ``res``, - # ``poly1`` and ``poly2``. - + void _fq_poly_mullow_univariate(fq_struct * rop, const fq_struct * op1, slong len1, const fq_struct * op2, slong len2, slong n, const fq_ctx_t ctx) noexcept void fq_poly_mullow_univariate(fq_poly_t rop, const fq_poly_t op1, const fq_poly_t op2, slong n, const fq_ctx_t ctx) noexcept - # Sets ``rop`` to the lowest `n` coefficients of the product of - # ``op1`` and ``op2``, computed using a bivariate to univariate - # transformation. - - void _fq_poly_mullow_KS(fq_struct *rop, const fq_struct *op1, slong len1, const fq_struct *op2, slong len2, slong n, const fq_ctx_t ctx) noexcept - # Sets ``(rop, n)`` to the lowest `n` coefficients of the product of - # ``(op1, len1)`` and ``(op2, len2)``. - # Assumes that ``len1`` and ``len2`` are positive, but does allow - # for the polynomials to be zero-padded. The polynomials may be zero, - # too. Assumes `n` is positive. Supports aliasing between ``rop``, - # ``op1`` and ``op2``. - + void _fq_poly_mullow_KS(fq_struct * rop, const fq_struct * op1, slong len1, const fq_struct * op2, slong len2, slong n, const fq_ctx_t ctx) noexcept void fq_poly_mullow_KS(fq_poly_t rop, const fq_poly_t op1, const fq_poly_t op2, slong n, const fq_ctx_t ctx) noexcept - # Sets ``rop`` to the lowest `n` coefficients of the product of - # ``op1`` and ``op2``. - - void _fq_poly_mullow(fq_struct *rop, const fq_struct *op1, slong len1, const fq_struct *op2, slong len2, slong n, const fq_ctx_t ctx) noexcept - # Sets ``(rop, n)`` to the lowest `n` coefficients of the product of - # ``(op1, len1)`` and ``(op2, len2)``. - # Assumes ``0 < n <= len1 + len2 - 1``. Allows for zero-padding in - # the inputs. Does not support aliasing between the inputs and the output. - + void _fq_poly_mullow(fq_struct * rop, const fq_struct * op1, slong len1, const fq_struct * op2, slong len2, slong n, const fq_ctx_t ctx) noexcept void fq_poly_mullow(fq_poly_t rop, const fq_poly_t op1, const fq_poly_t op2, slong n, const fq_ctx_t ctx) noexcept - # Sets ``rop`` to the lowest `n` coefficients of the product of - # ``op1`` and ``op2``. - - void _fq_poly_mulhigh_classical(fq_struct *res, const fq_struct *poly1, slong len1, const fq_struct *poly2, slong len2, slong start, const fq_ctx_t ctx) noexcept - # Computes the product of ``(poly1, len1)`` and ``(poly2, len2)`` - # and writes the coefficients from ``start`` onwards into the high - # coefficients of ``res``, the remaining coefficients being arbitrary - # but reduced. Assumes that ``len1 >= len2 > 0``. Aliasing of inputs - # and output is not permitted. Algorithm is classical multiplication. - + void _fq_poly_mulhigh_classical(fq_struct * res, const fq_struct * poly1, slong len1, const fq_struct * poly2, slong len2, slong start, const fq_ctx_t ctx) noexcept void fq_poly_mulhigh_classical(fq_poly_t res, const fq_poly_t poly1, const fq_poly_t poly2, slong start, const fq_ctx_t ctx) noexcept - # Computes the product of ``poly1`` and ``poly2`` and writes the - # coefficients from ``start`` onwards into the high coefficients of - # ``res``, the remaining coefficients being arbitrary but reduced. - # Algorithm is classical multiplication. - - void _fq_poly_mulhigh(fq_struct *res, const fq_struct *poly1, slong len1, const fq_struct *poly2, slong len2, slong start, fq_ctx_t ctx) noexcept - # Computes the product of ``(poly1, len1)`` and ``(poly2, len2)`` - # and writes the coefficients from ``start`` onwards into the high - # coefficients of ``res``, the remaining coefficients being arbitrary - # but reduced. Assumes that ``len1 >= len2 > 0``. Aliasing of inputs - # and output is not permitted. - + void _fq_poly_mulhigh(fq_struct * res, const fq_struct * poly1, slong len1, const fq_struct * poly2, slong len2, slong start, fq_ctx_t ctx) noexcept void fq_poly_mulhigh(fq_poly_t res, const fq_poly_t poly1, const fq_poly_t poly2, slong start, const fq_ctx_t ctx) noexcept - # Computes the product of ``poly1`` and ``poly2`` and writes the - # coefficients from ``start`` onwards into the high coefficients of - # ``res``, the remaining coefficients being arbitrary but reduced. - - void _fq_poly_mulmod(fq_struct* res, const fq_struct* poly1, slong len1, const fq_struct* poly2, slong len2, const fq_struct* f, slong lenf, const fq_ctx_t ctx) noexcept - # Sets ``res`` to the remainder of the product of ``poly1`` - # and ``poly2`` upon polynomial division by ``f``. - # It is required that ``len1 + len2 - lenf > 0``, which is - # equivalent to requiring that the result will actually be - # reduced. Otherwise, simply use ``_fq_poly_mul`` instead. - # Aliasing of ``f`` and ``res`` is not permitted. - + void _fq_poly_mulmod(fq_struct * res, const fq_struct * poly1, slong len1, const fq_struct * poly2, slong len2, const fq_struct * f, slong lenf, const fq_ctx_t ctx) noexcept void fq_poly_mulmod(fq_poly_t res, const fq_poly_t poly1, const fq_poly_t poly2, const fq_poly_t f, const fq_ctx_t ctx) noexcept - # Sets ``res`` to the remainder of the product of ``poly1`` - # and ``poly2`` upon polynomial division by ``f``. - - void _fq_poly_mulmod_preinv(fq_struct* res, const fq_struct* poly1, slong len1, const fq_struct* poly2, slong len2, const fq_struct* f, slong lenf, const fq_struct* finv, slong lenfinv, const fq_ctx_t ctx) noexcept - # Sets ``res`` to the remainder of the product of ``poly1`` - # and ``poly2`` upon polynomial division by ``f``. - # It is required that ``finv`` is the inverse of the reverse of - # ``f`` mod ``x^lenf``. - # Aliasing of ``res`` with any of the inputs is not permitted. - + void _fq_poly_mulmod_preinv(fq_struct * res, const fq_struct * poly1, slong len1, const fq_struct * poly2, slong len2, const fq_struct * f, slong lenf, const fq_struct * finv, slong lenfinv, const fq_ctx_t ctx) noexcept void fq_poly_mulmod_preinv(fq_poly_t res, const fq_poly_t poly1, const fq_poly_t poly2, const fq_poly_t f, const fq_poly_t finv, const fq_ctx_t ctx) noexcept - # Sets ``res`` to the remainder of the product of ``poly1`` - # and ``poly2`` upon polynomial division by ``f``. ``finv`` - # is the inverse of the reverse of ``f``. - - void _fq_poly_sqr_classical(fq_struct *rop, const fq_struct *op, slong len, const fq_ctx_t ctx) noexcept - # Sets ``(rop, 2*len - 1)`` to the square of ``(op, len)``, - # assuming that ``(op,len)`` is not zero and using classical - # polynomial multiplication. - # Permits zero padding. Does not support aliasing of ``rop`` - # with either ``op1`` or ``op2``. - + void _fq_poly_sqr_classical(fq_struct * rop, const fq_struct * op, slong len, const fq_ctx_t ctx) noexcept void fq_poly_sqr_classical(fq_poly_t rop, const fq_poly_t op, const fq_ctx_t ctx) noexcept - # Sets ``rop`` to the square of ``op`` using classical - # polynomial multiplication. - - void _fq_poly_sqr_reorder(fq_struct *rop, const fq_struct *op, slong len, const fq_ctx_t ctx) noexcept - # Sets ``(rop, 2*len- 1)`` to the square of ``(op, len)``, - # assuming that ``len`` is not zero reordering the two indeterminates - # `X` and `Y` when viewing the polynomials as elements of `\mathbf{F}_p[X,Y]`. - # Permits zero padding. Supports aliasing. - + void _fq_poly_sqr_reorder(fq_struct * rop, const fq_struct * op, slong len, const fq_ctx_t ctx) noexcept void fq_poly_sqr_reorder(fq_poly_t rop, const fq_poly_t op, const fq_ctx_t ctx) noexcept - # Sets ``rop`` to the square of ``op``, - # assuming that ``len`` is not zero reordering the two indeterminates - # `X` and `Y` when viewing the polynomials as elements of `\mathbf{F}_p[X,Y]`. - # See ``fq_poly_mul_reorder``. - - void _fq_poly_sqr_KS(fq_struct *rop, const fq_struct *op, slong len, const fq_ctx_t ctx) noexcept - # Sets ``(rop, 2*len - 1)`` to the square of ``(op, len)``. - # Permits zero padding and places no assumptions on the - # lengths ``len1`` and ``len2``. Supports aliasing. - + void _fq_poly_sqr_KS(fq_struct * rop, const fq_struct * op, slong len, const fq_ctx_t ctx) noexcept void fq_poly_sqr_KS(fq_poly_t rop, const fq_poly_t op, const fq_ctx_t ctx) noexcept - # Sets ``rop`` to the square ``op`` using Kronecker substitution, - # that is, by encoding each coefficient in `\mathbf{F}_{q}` as an integer - # and reducing this problem to multiplying two polynomials over the integers. - - void _fq_poly_sqr(fq_struct *rop, const fq_struct *op, slong len, const fq_ctx_t ctx) noexcept - # Sets ``(rop, 2* len - 1)`` to the square of ``(op, len)``, - # choosing an appropriate algorithm. - # Permits zero padding. Does not support aliasing. - + void _fq_poly_sqr(fq_struct * rop, const fq_struct * op, slong len, const fq_ctx_t ctx) noexcept void fq_poly_sqr(fq_poly_t rop, const fq_poly_t op, const fq_ctx_t ctx) noexcept - # Sets ``rop`` to the square of ``op``, - # choosing an appropriate algorithm. - - void _fq_poly_pow(fq_struct *rop, const fq_struct *op, slong len, ulong e, const fq_ctx_t ctx) noexcept - # Sets ``rop = op^e``, assuming that ``e, len > 0`` and that - # ``rop`` has space for ``e*(len - 1) + 1`` coefficients. Does - # not support aliasing. - + void _fq_poly_pow(fq_struct * rop, const fq_struct * op, slong len, ulong e, const fq_ctx_t ctx) noexcept void fq_poly_pow(fq_poly_t rop, const fq_poly_t op, ulong e, const fq_ctx_t ctx) noexcept - # Computes ``rop = op^e``. If `e` is zero, returns one, - # so that in particular ``0^0 = 1``. - - void _fq_poly_powmod_ui_binexp(fq_struct* res, const fq_struct* poly, ulong e, const fq_struct* f, slong lenf, const fq_ctx_t ctx) noexcept - # Sets ``res`` to ``poly`` raised to the power ``e`` modulo - # ``f``, using binary exponentiation. We require ``e > 0``. - # We require ``lenf > 1``. It is assumed that ``poly`` is - # already reduced modulo ``f`` and zero-padded as necessary to - # have length exactly ``lenf - 1``. The output ``res`` must - # have room for ``lenf - 1`` coefficients. - + void _fq_poly_powmod_ui_binexp(fq_struct * res, const fq_struct * poly, ulong e, const fq_struct * f, slong lenf, const fq_ctx_t ctx) noexcept void fq_poly_powmod_ui_binexp(fq_poly_t res, const fq_poly_t poly, ulong e, const fq_poly_t f, const fq_ctx_t ctx) noexcept - # Sets ``res`` to ``poly`` raised to the power ``e`` modulo - # ``f``, using binary exponentiation. We require ``e >= 0``. - - void _fq_poly_powmod_ui_binexp_preinv(fq_struct* res, const fq_struct* poly, ulong e, const fq_struct* f, slong lenf, const fq_struct* finv, slong lenfinv, const fq_ctx_t ctx) noexcept - # Sets ``res`` to ``poly`` raised to the power ``e`` modulo - # ``f``, using binary exponentiation. We require ``e > 0``. - # We require ``finv`` to be the inverse of the reverse of - # ``f``. - # We require ``lenf > 1``. It is assumed that ``poly`` is - # already reduced modulo ``f`` and zero-padded as necessary to - # have length exactly ``lenf - 1``. The output ``res`` must - # have room for ``lenf - 1`` coefficients. - + void _fq_poly_powmod_ui_binexp_preinv(fq_struct * res, const fq_struct * poly, ulong e, const fq_struct * f, slong lenf, const fq_struct * finv, slong lenfinv, const fq_ctx_t ctx) noexcept void fq_poly_powmod_ui_binexp_preinv(fq_poly_t res, const fq_poly_t poly, ulong e, const fq_poly_t f, const fq_poly_t finv, const fq_ctx_t ctx) noexcept - # Sets ``res`` to ``poly`` raised to the power ``e`` modulo - # ``f``, using binary exponentiation. We require ``e >= 0``. - # We require ``finv`` to be the inverse of the reverse of - # ``f``. - - void _fq_poly_powmod_fmpz_binexp(fq_struct* res, const fq_struct* poly, const fmpz_t e, const fq_struct* f, slong lenf, const fq_ctx_t ctx) noexcept - # Sets ``res`` to ``poly`` raised to the power ``e`` modulo - # ``f``, using binary exponentiation. We require ``e > 0``. - # We require ``lenf > 1``. It is assumed that ``poly`` is - # already reduced modulo ``f`` and zero-padded as necessary to - # have length exactly ``lenf - 1``. The output ``res`` must - # have room for ``lenf - 1`` coefficients. - + void _fq_poly_powmod_fmpz_binexp(fq_struct * res, const fq_struct * poly, const fmpz_t e, const fq_struct * f, slong lenf, const fq_ctx_t ctx) noexcept void fq_poly_powmod_fmpz_binexp(fq_poly_t res, const fq_poly_t poly, const fmpz_t e, const fq_poly_t f, const fq_ctx_t ctx) noexcept - # Sets ``res`` to ``poly`` raised to the power ``e`` modulo - # ``f``, using binary exponentiation. We require ``e >= 0``. - - void _fq_poly_powmod_fmpz_binexp_preinv(fq_struct* res, const fq_struct* poly, const fmpz_t e, const fq_struct* f, slong lenf, const fq_struct* finv, slong lenfinv, const fq_ctx_t ctx) noexcept - # Sets ``res`` to ``poly`` raised to the power ``e`` modulo - # ``f``, using binary exponentiation. We require ``e > 0``. - # We require ``finv`` to be the inverse of the reverse of - # ``f``. - # We require ``lenf > 1``. It is assumed that ``poly`` is - # already reduced modulo ``f`` and zero-padded as necessary to - # have length exactly ``lenf - 1``. The output ``res`` must - # have room for ``lenf - 1`` coefficients. - + void _fq_poly_powmod_fmpz_binexp_preinv(fq_struct * res, const fq_struct * poly, const fmpz_t e, const fq_struct * f, slong lenf, const fq_struct * finv, slong lenfinv, const fq_ctx_t ctx) noexcept void fq_poly_powmod_fmpz_binexp_preinv(fq_poly_t res, const fq_poly_t poly, const fmpz_t e, const fq_poly_t f, const fq_poly_t finv, const fq_ctx_t ctx) noexcept - # Sets ``res`` to ``poly`` raised to the power ``e`` modulo - # ``f``, using binary exponentiation. We require ``e >= 0``. - # We require ``finv`` to be the inverse of the reverse of - # ``f``. - - void _fq_poly_powmod_fmpz_sliding_preinv(fq_struct* res, const fq_struct* poly, const fmpz_t e, ulong k, const fq_struct* f, slong lenf, const fq_struct* finv, slong lenfinv, const fq_ctx_t ctx) noexcept - # Sets ``res`` to ``poly`` raised to the power ``e`` modulo - # ``f``, using sliding-window exponentiation with window size - # ``k``. We require ``e > 0``. We require ``finv`` to be - # the inverse of the reverse of ``f``. If ``k`` is set to - # zero, then an "optimum" size will be selected automatically base - # on ``e``. - # We require ``lenf > 1``. It is assumed that ``poly`` is - # already reduced modulo ``f`` and zero-padded as necessary to - # have length exactly ``lenf - 1``. The output ``res`` must - # have room for ``lenf - 1`` coefficients. - + void _fq_poly_powmod_fmpz_sliding_preinv(fq_struct * res, const fq_struct * poly, const fmpz_t e, ulong k, const fq_struct * f, slong lenf, const fq_struct * finv, slong lenfinv, const fq_ctx_t ctx) noexcept void fq_poly_powmod_fmpz_sliding_preinv(fq_poly_t res, const fq_poly_t poly, const fmpz_t e, ulong k, const fq_poly_t f, const fq_poly_t finv, const fq_ctx_t ctx) noexcept - # Sets ``res`` to ``poly`` raised to the power ``e`` modulo - # ``f``, using sliding-window exponentiation with window size - # ``k``. We require ``e >= 0``. We require ``finv`` to be - # the inverse of the reverse of ``f``. If ``k`` is set to - # zero, then an "optimum" size will be selected automatically base - # on ``e``. - void _fq_poly_powmod_x_fmpz_preinv(fq_struct * res, const fmpz_t e, const fq_struct * f, slong lenf, const fq_struct * finv, slong lenfinv, const fq_ctx_t ctx) noexcept - # Sets ``res`` to ``x`` raised to the power ``e`` modulo ``f``, - # using sliding window exponentiation. We require ``e > 0``. - # We require ``finv`` to be the inverse of the reverse of ``f``. - # We require ``lenf > 2``. The output ``res`` must have room for - # ``lenf - 1`` coefficients. - void fq_poly_powmod_x_fmpz_preinv(fq_poly_t res, const fmpz_t e, const fq_poly_t f, const fq_poly_t finv, const fq_ctx_t ctx) noexcept - # Sets ``res`` to ``x`` raised to the power ``e`` - # modulo ``f``, using sliding window exponentiation. We require - # ``e >= 0``. We require ``finv`` to be the inverse of the reverse of - # ``f``. - void _fq_poly_pow_trunc_binexp(fq_struct * res, const fq_struct * poly, ulong e, slong trunc, const fq_ctx_t ctx) noexcept - # Sets ``res`` to the low ``trunc`` coefficients of ``poly`` - # (assumed to be zero padded if necessary to length ``trunc``) to - # the power ``e``. This is equivalent to doing a powering followed - # by a truncation. We require that ``res`` has enough space for - # ``trunc`` coefficients, that ``trunc > 0`` and that - # ``e > 1``. Aliasing is not permitted. Uses the binary - # exponentiation method. - void fq_poly_pow_trunc_binexp(fq_poly_t res, const fq_poly_t poly, ulong e, slong trunc, const fq_ctx_t ctx) noexcept - # Sets ``res`` to the low ``trunc`` coefficients of ``poly`` - # to the power ``e``. This is equivalent to doing a powering - # followed by a truncation. Uses the binary exponentiation method. - void _fq_poly_pow_trunc(fq_struct * res, const fq_struct * poly, ulong e, slong trunc, const fq_ctx_t mod) noexcept - # Sets ``res`` to the low ``trunc`` coefficients of ``poly`` - # (assumed to be zero padded if necessary to length ``trunc``) to - # the power ``e``. This is equivalent to doing a powering followed - # by a truncation. We require that ``res`` has enough space for - # ``trunc`` coefficients, that ``trunc > 0`` and that - # ``e > 1``. Aliasing is not permitted. - void fq_poly_pow_trunc(fq_poly_t res, const fq_poly_t poly, ulong e, slong trunc, const fq_ctx_t ctx) noexcept - # Sets ``res`` to the low ``trunc`` coefficients of ``poly`` - # to the power ``e``. This is equivalent to doing a powering - # followed by a truncation. - - void _fq_poly_shift_left(fq_struct *rop, const fq_struct *op, slong len, slong n, const fq_ctx_t ctx) noexcept - # Sets ``(rop, len + n)`` to ``(op, len)`` shifted left by - # `n` coefficients. - # Inserts zero coefficients at the lower end. Assumes that - # ``len`` and `n` are positive, and that ``rop`` fits - # ``len + n`` elements. Supports aliasing between ``rop`` and - # ``op``. - + void _fq_poly_shift_left(fq_struct * rop, const fq_struct * op, slong len, slong n, const fq_ctx_t ctx) noexcept void fq_poly_shift_left(fq_poly_t rop, const fq_poly_t op, slong n, const fq_ctx_t ctx) noexcept - # Sets ``rop`` to ``op`` shifted left by `n` coeffs. Zero - # coefficients are inserted. - - void _fq_poly_shift_right(fq_struct *rop, const fq_struct *op, slong len, slong n, const fq_ctx_t ctx) noexcept - # Sets ``(rop, len - n)`` to ``(op, len)`` shifted right by - # `n` coefficients. - # Assumes that ``len`` and `n` are positive, that ``len > n``, - # and that ``rop`` fits ``len - n`` elements. Supports - # aliasing between ``rop`` and ``op``, although in this case - # the top coefficients of ``op`` are not set to zero. - + void _fq_poly_shift_right(fq_struct * rop, const fq_struct * op, slong len, slong n, const fq_ctx_t ctx) noexcept void fq_poly_shift_right(fq_poly_t rop, const fq_poly_t op, slong n, const fq_ctx_t ctx) noexcept - # Sets ``rop`` to ``op`` shifted right by `n` coefficients. - # If `n` is equal to or greater than the current length of - # ``op``, ``rop`` is set to the zero polynomial. - - slong _fq_poly_hamming_weight(const fq_struct *op, slong len, const fq_ctx_t ctx) noexcept - # Returns the number of non-zero entries in ``(op, len)``. - + slong _fq_poly_hamming_weight(const fq_struct * op, slong len, const fq_ctx_t ctx) noexcept slong fq_poly_hamming_weight(const fq_poly_t op, const fq_ctx_t ctx) noexcept - # Returns the number of non-zero entries in the polynomial ``op``. - - void _fq_poly_divrem(fq_struct *Q, fq_struct *R, const fq_struct *A, slong lenA, const fq_struct *B, slong lenB, const fq_t invB, const fq_ctx_t ctx) noexcept - # Computes ``(Q, lenA - lenB + 1)``, ``(R, lenA)`` such that - # `A = B Q + R` with `0 \leq \operatorname{len}(R) < \operatorname{len}(B)`. - # Assumes that the leading coefficient of `B` is invertible - # and that ``invB`` is its inverse. - # Assumes that `\operatorname{len}(A), \operatorname{len}(B) > 0`. Allows zero-padding in - # ``(A, lenA)``. `R` and `A` may be aliased, but apart from - # this no aliasing of input and output operands is allowed. - + void _fq_poly_divrem(fq_struct * Q, fq_struct * R, const fq_struct * A, slong lenA, const fq_struct * B, slong lenB, const fq_t invB, const fq_ctx_t ctx) noexcept void fq_poly_divrem(fq_poly_t Q, fq_poly_t R, const fq_poly_t A, const fq_poly_t B, const fq_ctx_t ctx) noexcept - # Computes `Q`, `R` such that `A = B Q + R` with - # `0 \leq \operatorname{len}(R) < \operatorname{len}(B)`. - # Assumes that the leading coefficient of `B` is invertible. This can - # be taken for granted the context is for a finite field, that is, when - # `p` is prime and `f(X)` is irreducible. - void fq_poly_divrem_f(fq_t f, fq_poly_t Q, fq_poly_t R, const fq_poly_t A, const fq_poly_t B, const fq_ctx_t ctx) noexcept - # Either finds a non-trivial factor `f` of the modulus of - # ``ctx``, or computes `Q`, `R` such that `A = B Q + R` and - # `0 \leq \operatorname{len}(R) < \operatorname{len}(B)`. - # If the leading coefficient of `B` is invertible, the division with - # remainder operation is carried out, `Q` and `R` are computed - # correctly, and `f` is set to `1`. Otherwise, `f` is set to a - # non-trivial factor of the modulus and `Q` and `R` are not touched. - # Assumes that `B` is non-zero. - - void _fq_poly_rem(fq_struct *R, const fq_struct *A, slong lenA, const fq_struct *B, slong lenB, const fq_t invB, const fq_ctx_t ctx) noexcept - # Sets ``R`` to the remainder of the division of ``(A,lenA)`` by - # ``(B,lenB)``. Assumes that the leading coefficient of ``(B,lenB)`` - # is invertible and that ``invB`` is its inverse. - + void _fq_poly_rem(fq_struct * R, const fq_struct * A, slong lenA, const fq_struct * B, slong lenB, const fq_t invB, const fq_ctx_t ctx) noexcept void fq_poly_rem(fq_poly_t R, const fq_poly_t A, const fq_poly_t B, const fq_ctx_t ctx) noexcept - # Sets ``R`` to the remainder of the division of ``A`` by - # ``B`` in the context described by ``ctx``. - - void _fq_poly_div(fq_struct *Q, const fq_struct *A, slong lenA, const fq_struct *B, slong lenB, const fq_t invB, const fq_ctx_t ctx) noexcept - # Notationally, computes `Q`, `R` such that `A = B Q + R` with `0 - # \leq \operatorname{len}(R) < \operatorname{len}(B)` but only sets ``(Q, lenA - lenB + 1)``. - # Allows zero-padding in `A` but not in `B`. Assumes that the leading coefficient of `B` is a unit. - + void _fq_poly_div(fq_struct * Q, const fq_struct * A, slong lenA, const fq_struct * B, slong lenB, const fq_t invB, const fq_ctx_t ctx) noexcept void fq_poly_div(fq_poly_t Q, const fq_poly_t A, const fq_poly_t B, const fq_ctx_t ctx) noexcept - # Notionally finds polynomials `Q` and `R` such that `A = B Q + R` with - # `\operatorname{len}(R) < \operatorname{len}(B)`, but returns only ``Q``. If `\operatorname{len}(B) = 0` an - # exception is raised. - - void _fq_poly_div_newton_n_preinv(fq_struct* Q, const fq_struct* A, slong lenA, const fq_struct* B, slong lenB, const fq_struct* Binv, slong lenBinv, const fq_ctx_t ctx) noexcept - # Notionally computes polynomials `Q` and `R` such that `A = BQ + R` with - # `\operatorname{len}(R)` less than ``lenB``, where ``A`` is of length ``lenA`` - # and ``B`` is of length ``lenB``, but return only `Q`. - # We require that `Q` have space for ``lenA - lenB + 1`` coefficients - # and assume that the leading coefficient of `B` is a unit. Furthermore, we - # assume that `Binv` is the inverse of the reverse of `B` mod `x^{\operatorname{len}(B)}`. - # The algorithm used is to reverse the polynomials and divide the - # resulting power series, then reverse the result. - + void _fq_poly_div_newton_n_preinv(fq_struct * Q, const fq_struct * A, slong lenA, const fq_struct * B, slong lenB, const fq_struct * Binv, slong lenBinv, const fq_ctx_t ctx) noexcept void fq_poly_div_newton_n_preinv(fq_poly_t Q, const fq_poly_t A, const fq_poly_t B, const fq_poly_t Binv, const fq_ctx_t ctx) noexcept - # Notionally computes `Q` and `R` such that `A = BQ + R` with - # `\operatorname{len}(R) < \operatorname{len}(B)`, but returns only `Q`. - # We assume that the leading coefficient of `B` is a unit and that `Binv` is - # the inverse of the reverse of `B` mod `x^{\operatorname{len}(B)}`. - # It is required that the length of `A` is less than or equal to - # 2*the length of `B` - 2. - # The algorithm used is to reverse the polynomials and divide the - # resulting power series, then reverse the result. - - void _fq_poly_divrem_newton_n_preinv(fq_struct* Q, fq_struct* R, const fq_struct* A, slong lenA, const fq_struct* B, slong lenB, const fq_struct* Binv, slong lenBinv, const fq_ctx_t ctx) noexcept - # Computes `Q` and `R` such that `A = BQ + R` with `\operatorname{len}(R)` less - # than ``lenB``, where `A` is of length ``lenA`` and `B` is of - # length ``lenB``. We require that `Q` have space for - # ``lenA - lenB + 1`` coefficients. Furthermore, we assume that `Binv` is - # the inverse of the reverse of `B` mod `x^{\operatorname{len}(B)}`. The algorithm - # used is to call :func:`div_newton_n_preinv` and then multiply out - # and compute the remainder. - + void _fq_poly_divrem_newton_n_preinv(fq_struct * Q, fq_struct * R, const fq_struct * A, slong lenA, const fq_struct * B, slong lenB, const fq_struct * Binv, slong lenBinv, const fq_ctx_t ctx) noexcept void fq_poly_divrem_newton_n_preinv(fq_poly_t Q, fq_poly_t R, const fq_poly_t A, const fq_poly_t B, const fq_poly_t Binv, const fq_ctx_t ctx) noexcept - # Computes `Q` and `R` such that `A = BQ + R` with `\operatorname{len}(R) < - # \operatorname{len}(B)`. We assume `Binv` is the inverse of the reverse of `B` - # mod `x^{\operatorname{len}(B)}`. - # It is required that the length of `A` is less than or equal to - # 2*the length of `B` - 2. - # The algorithm used is to call :func:`div_newton_n` and then - # multiply out and compute the remainder. - - void _fq_poly_inv_series_newton(fq_struct* Qinv, const fq_struct* Q, slong n, const fq_t cinv, const fq_ctx_t ctx) noexcept - # Given ``Q`` of length ``n`` whose constant coefficient is - # invertible modulo the given modulus, find a polynomial ``Qinv`` - # of length ``n`` such that ``Q * Qinv`` is ``1`` modulo - # `x^n`. Requires ``n > 0``. This function can be viewed as - # inverting a power series via Newton iteration. - + void _fq_poly_inv_series_newton(fq_struct * Qinv, const fq_struct * Q, slong n, const fq_t cinv, const fq_ctx_t ctx) noexcept void fq_poly_inv_series_newton(fq_poly_t Qinv, const fq_poly_t Q, slong n, const fq_ctx_t ctx) noexcept - # Given ``Q`` find ``Qinv`` such that ``Q * Qinv`` is - # ``1`` modulo `x^n`. The constant coefficient of ``Q`` must - # be invertible modulo the modulus of ``Q``. An exception is - # raised if this is not the case or if ``n = 0``. This function - # can be viewed as inverting a power series via Newton iteration. - - void _fq_poly_inv_series(fq_struct* Qinv, const fq_struct* Q, slong n, const fq_t cinv, const fq_ctx_t ctx) noexcept - # Given ``Q`` of length ``n`` whose constant coefficient is - # invertible modulo the given modulus, find a polynomial ``Qinv`` - # of length ``n`` such that ``Q * Qinv`` is ``1`` modulo - # `x^n`. Requires ``n > 0``. - + void _fq_poly_inv_series(fq_struct * Qinv, const fq_struct * Q, slong n, const fq_t cinv, const fq_ctx_t ctx) noexcept void fq_poly_inv_series(fq_poly_t Qinv, const fq_poly_t Q, slong n, const fq_ctx_t ctx) noexcept - # Given ``Q`` find ``Qinv`` such that ``Q * Qinv`` is - # ``1`` modulo `x^n`. The constant coefficient of ``Q`` must - # be invertible modulo the modulus of ``Q``. An exception is - # raised if this is not the case or if ``n = 0``. - void _fq_poly_div_series(fq_struct * Q, const fq_struct * A, slong Alen, const fq_struct * B, slong Blen, slong n, const fq_ctx_t ctx) noexcept - # Set ``(Q, n)`` to the quotient of the series ``(A, Alen``) and - # ``(B, Blen)`` assuming ``Alen, Blen <= n``. We assume the bottom - # coefficient of ``B`` is invertible. - void fq_poly_div_series(fq_poly_t Q, const fq_poly_t A, const fq_poly_t B, slong n, const fq_ctx_t ctx) noexcept - # Set `Q` to the quotient of the series `A` by `B`, thinking of the series as - # though they were of length `n`. We assume that the bottom coefficient of - # `B` is invertible. - void fq_poly_gcd(fq_poly_t rop, const fq_poly_t op1, const fq_poly_t op2, const fq_ctx_t ctx) noexcept - # Sets ``rop`` to the greatest common divisor of ``op1`` and - # ``op2``, using the either the Euclidean or HGCD algorithm. The - # GCD of zero polynomials is defined to be zero, whereas the GCD of - # the zero polynomial and some other polynomial `P` is defined to be - # `P`. Except in the case where the GCD is zero, the GCD `G` is made - # monic. - - slong _fq_poly_gcd(fq_struct* G, const fq_struct* A, slong lenA, const fq_struct* B, slong lenB, const fq_ctx_t ctx) noexcept - # Computes the GCD of `A` of length ``lenA`` and `B` of length - # ``lenB``, where ``lenA >= lenB > 0`` and sets `G` to it. The - # length of the GCD `G` is returned by the function. No attempt is - # made to make the GCD monic. It is required that `G` have space for - # ``lenB`` coefficients. - - slong _fq_poly_gcd_euclidean_f(fq_t f, fq_struct *G, const fq_struct *A, slong lenA, const fq_struct *B, slong lenB, const fq_ctx_t ctx) noexcept - # Either sets `f = 1` and `G` to the greatest common divisor of - # `(A,\operatorname{len}(A))` and `(B, \operatorname{len}(B))` and returns its length, or sets - # `f` to a non-trivial factor of the modulus of ``ctx`` and leaves - # the contents of the vector `(G, lenB)` undefined. - # Assumes that `\operatorname{len}(A) \geq \operatorname{len}(B) > 0` and that the vector `G` - # has space for sufficiently many coefficients. - + slong _fq_poly_gcd(fq_struct * G, const fq_struct * A, slong lenA, const fq_struct * B, slong lenB, const fq_ctx_t ctx) noexcept + slong _fq_poly_gcd_euclidean_f(fq_t f, fq_struct * G, const fq_struct * A, slong lenA, const fq_struct * B, slong lenB, const fq_ctx_t ctx) noexcept void fq_poly_gcd_euclidean_f(fq_t f, fq_poly_t G, const fq_poly_t A, const fq_poly_t B, const fq_ctx_t ctx) noexcept - # Either sets `f = 1` and `G` to the greatest common divisor of `A` - # and `B` or sets `f` to a factor of the modulus of ``ctx``. - - slong _fq_poly_xgcd(fq_struct *G, fq_struct *S, fq_struct *T, const fq_struct *A, slong lenA, const fq_struct *B, slong lenB, const fq_ctx_t ctx) noexcept - # Computes the GCD of `A` and `B` together with cofactors `S` and `T` - # such that `S A + T B = G`. Returns the length of `G`. - # Assumes that `\operatorname{len}(A) \geq \operatorname{len}(B) \geq 1` and - # `(\operatorname{len}(A),\operatorname{len}(B)) \neq (1,1)`. - # No attempt is made to make the GCD monic. - # Requires that `G` have space for `\operatorname{len}(B)` coefficients. Writes - # `\operatorname{len}(B)-1` and `\operatorname{len}(A)-1` coefficients to `S` and `T`, respectively. - # Note that, in fact, `\operatorname{len}(S) \leq \max(\operatorname{len}(B) - \operatorname{len}(G), 1)` and - # `\operatorname{len}(T) \leq \max(\operatorname{len}(A) - \operatorname{len}(G), 1)`. - # No aliasing of input and output operands is permitted. - + slong _fq_poly_xgcd(fq_struct * G, fq_struct * S, fq_struct * T, const fq_struct * A, slong lenA, const fq_struct * B, slong lenB, const fq_ctx_t ctx) noexcept void fq_poly_xgcd(fq_poly_t G, fq_poly_t S, fq_poly_t T, const fq_poly_t A, const fq_poly_t B, const fq_ctx_t ctx) noexcept - # Computes the GCD of `A` and `B`. The GCD of zero polynomials is - # defined to be zero, whereas the GCD of the zero polynomial and some other - # polynomial `P` is defined to be `P`. Except in the case where - # the GCD is zero, the GCD `G` is made monic. - # Polynomials ``S`` and ``T`` are computed such that - # ``S*A + T*B = G``. The length of ``S`` will be at most - # ``lenB`` and the length of ``T`` will be at most ``lenA``. - - slong _fq_poly_xgcd_euclidean_f(fq_t f, fq_struct *G, fq_struct *S, fq_struct *T, const fq_struct *A, slong lenA, const fq_struct *B, slong lenB, const fq_ctx_t ctx) noexcept - # Either sets `f = 1` and computes the GCD of `A` and `B` together - # with cofactors `S` and `T` such that `S A + T B = G`; otherwise, - # sets `f` to a non-trivial factor of the modulus of ``ctx`` and - # leaves `G`, `S`, and `T` undefined. Returns the length of `G`. - # Assumes that `\operatorname{len}(A) \geq \operatorname{len}(B) \geq 1` and - # `(\operatorname{len}(A),\operatorname{len}(B)) \neq (1,1)`. - # No attempt is made to make the GCD monic. - # Requires that `G` have space for `\operatorname{len}(B)` coefficients. Writes - # `\operatorname{len}(B)-1` and `\operatorname{len}(A)-1` coefficients to `S` and `T`, respectively. - # Note that, in fact, `\operatorname{len}(S) \leq \max(\operatorname{len}(B) - \operatorname{len}(G), 1)` and - # `\operatorname{len}(T) \leq \max(\operatorname{len}(A) - \operatorname{len}(G), 1)`. - # No aliasing of input and output operands is permitted. - + slong _fq_poly_xgcd_euclidean_f(fq_t f, fq_struct * G, fq_struct * S, fq_struct * T, const fq_struct * A, slong lenA, const fq_struct * B, slong lenB, const fq_ctx_t ctx) noexcept void fq_poly_xgcd_euclidean_f(fq_t f, fq_poly_t G, fq_poly_t S, fq_poly_t T, const fq_poly_t A, const fq_poly_t B, const fq_ctx_t ctx) noexcept - # Either sets `f = 1` and computes the GCD of `A` and `B` or sets - # `f` to a non-trivial factor of the modulus of ``ctx``. - # If the GCD is computed, polynomials ``S`` and ``T`` are - # computed such that ``S*A + T*B = G``; otherwise, they are - # undefined. The length of ``S`` will be at most ``lenB`` and - # the length of ``T`` will be at most ``lenA``. - # The GCD of zero polynomials is defined to be zero, whereas the GCD - # of the zero polynomial and some other polynomial `P` is defined to - # be `P`. Except in the case where the GCD is zero, the GCD `G` is - # made monic. - - int _fq_poly_divides(fq_struct *Q, const fq_struct *A, slong lenA, const fq_struct *B, slong lenB, const fq_t invB, const fq_ctx_t ctx) noexcept - # Returns `1` if ``(B, lenB)`` divides ``(A, lenA)`` exactly and - # sets `Q` to the quotient, otherwise returns `0`. - # It is assumed that `\operatorname{len}(A) \geq \operatorname{len}(B) > 0` and that `Q` has space - # for `\operatorname{len}(A) - \operatorname{len}(B) + 1` coefficients. - # Aliasing of `Q` with either of the inputs is not permitted. - # This function is currently unoptimised and provided for convenience - # only. - + int _fq_poly_divides(fq_struct * Q, const fq_struct * A, slong lenA, const fq_struct * B, slong lenB, const fq_t invB, const fq_ctx_t ctx) noexcept int fq_poly_divides(fq_poly_t Q, const fq_poly_t A, const fq_poly_t B, const fq_ctx_t ctx) noexcept - # Returns `1` if `B` divides `A` exactly and sets `Q` to the quotient, - # otherwise returns `0`. - # This function is currently unoptimised and provided for convenience - # only. - - void _fq_poly_derivative(fq_struct *rop, const fq_struct *op, slong len, const fq_ctx_t ctx) noexcept - # Sets ``(rop, len - 1)`` to the derivative of ``(op, len)``. - # Also handles the cases where ``len`` is `0` or `1` correctly. - # Supports aliasing of ``rop`` and ``op``. - + void _fq_poly_derivative(fq_struct * rop, const fq_struct * op, slong len, const fq_ctx_t ctx) noexcept void fq_poly_derivative(fq_poly_t rop, const fq_poly_t op, const fq_ctx_t ctx) noexcept - # Sets ``rop`` to the derivative of ``op``. - void _fq_poly_invsqrt_series(fq_struct * g, const fq_struct * h, slong n, fq_ctx_t mod) noexcept - # Set the first `n` terms of `g` to the series expansion of `1/\sqrt{h}`. - # It is assumed that `n > 0`, that `h` has constant term 1 and that `h` - # is zero-padded as necessary to length `n`. Aliasing is not permitted. - void fq_poly_invsqrt_series(fq_poly_t g, const fq_poly_t h, slong n, fq_ctx_t ctx) noexcept - # Set `g` to the series expansion of `1/\sqrt{h}` to order `O(x^n)`. - # It is assumed that `h` has constant term 1. - void _fq_poly_sqrt_series(fq_struct * g, const fq_struct * h, slong n, fq_ctx_t ctx) noexcept - # Set the first `n` terms of `g` to the series expansion of `\sqrt{h}`. - # It is assumed that `n > 0`, that `h` has constant term 1 and that `h` - # is zero-padded as necessary to length `n`. Aliasing is not permitted. - void fq_poly_sqrt_series(fq_poly_t g, const fq_poly_t h, slong n, fq_ctx_t ctx) noexcept - # Set `g` to the series expansion of `\sqrt{h}` to order `O(x^n)`. - # It is assumed that `h` has constant term 1. - int _fq_poly_sqrt(fq_struct * s, const fq_struct * p, slong n, fq_ctx_t mod) noexcept - # If ``(p, n)`` is a perfect square, sets ``(s, n / 2 + 1)`` - # to a square root of `p` and returns 1. Otherwise returns 0. - int fq_poly_sqrt(fq_poly_t s, const fq_poly_t p, fq_ctx_t mod) noexcept - # If `p` is a perfect square, sets `s` to a square root of `p` - # and returns 1. Otherwise returns 0. - - void _fq_poly_evaluate_fq(fq_t rop, const fq_struct *op, slong len, const fq_t a, const fq_ctx_t ctx) noexcept - # Sets ``rop`` to ``(op, len)`` evaluated at `a`. - # Supports zero padding. There are no restrictions on ``len``, that - # is, ``len`` is allowed to be zero, too. - + void _fq_poly_evaluate_fq(fq_t rop, const fq_struct * op, slong len, const fq_t a, const fq_ctx_t ctx) noexcept void fq_poly_evaluate_fq(fq_t rop, const fq_poly_t f, const fq_t a, const fq_ctx_t ctx) noexcept - # Sets ``rop`` to the value of `f(a)`. - # As the coefficient ring `\mathbf{F}_q` is finite, Horner's method - # is sufficient. - - void _fq_poly_compose(fq_struct *rop, const fq_struct *op1, slong len1, const fq_struct *op2, slong len2, const fq_ctx_t ctx) noexcept - # Sets ``rop`` to the composition of ``(op1, len1)`` and - # ``(op2, len2)``. - # Assumes that ``rop`` has space for ``(len1-1)*(len2-1) + 1`` - # coefficients. Assumes that ``op1`` and ``op2`` are non-zero - # polynomials. Does not support aliasing between any of the inputs and - # the output. - + void _fq_poly_compose(fq_struct * rop, const fq_struct * op1, slong len1, const fq_struct * op2, slong len2, const fq_ctx_t ctx) noexcept void fq_poly_compose(fq_poly_t rop, const fq_poly_t op1, const fq_poly_t op2, const fq_ctx_t ctx) noexcept - # Sets ``rop`` to the composition of ``op1`` and ``op2``. - # To be precise about the order of composition, denoting ``rop``, - # ``op1``, and ``op2`` by `f`, `g`, and `h`, respectively, - # sets `f(t) = g(h(t))`. - void _fq_poly_compose_mod_horner(fq_struct * res, const fq_struct * f, slong lenf, const fq_struct * g, const fq_struct * h, slong lenh, const fq_ctx_t ctx) noexcept - # Sets ``res`` to the composition `f(g)` modulo `h`. We require that - # `h` is nonzero and that the length of `g` is one less than the - # length of `h` (possibly with zero padding). The output is not allowed - # to be aliased with any of the inputs. - # The algorithm used is Horner's rule. - void fq_poly_compose_mod_horner(fq_poly_t res, const fq_poly_t f, const fq_poly_t g, const fq_poly_t h, const fq_ctx_t ctx) noexcept - # Sets ``res`` to the composition `f(g)` modulo `h`. We require that - # `h` is nonzero. The algorithm used is Horner's rule. - void _fq_poly_compose_mod_horner_preinv(fq_struct * res, const fq_struct * f, slong lenf, const fq_struct * g, const fq_struct * h, slong lenh, const fq_struct * hinv, slong lenhiv, const fq_ctx_t ctx) noexcept - # Sets ``res`` to the composition `f(g)` modulo `h`. We require - # that `h` is nonzero and that the length of `g` is one less than - # the length of `h` (possibly with zero padding). We also require - # that the length of `f` is less than the length of - # `h`. Furthermore, we require ``hinv`` to be the inverse of the - # reverse of ``h``. The output is not allowed to be aliased with - # any of the inputs. - # The algorithm used is Horner's rule. - void fq_poly_compose_mod_horner_preinv(fq_poly_t res, const fq_poly_t f, const fq_poly_t g, const fq_poly_t h, const fq_poly_t hinv, const fq_ctx_t ctx) noexcept - # Sets ``res`` to the composition `f(g)` modulo `h`. We require - # that `h` is nonzero and that `f` has smaller degree than - # `h`. Furthermore, we require ``hinv`` to be the inverse of the - # reverse of ``h``. The algorithm used is Horner's rule. - void _fq_poly_compose_mod_brent_kung(fq_struct * res, const fq_struct * f, slong lenf, const fq_struct * g, const fq_struct * h, slong lenh, const fq_ctx_t ctx) noexcept - # Sets ``res`` to the composition `f(g)` modulo `h`. We require - # that `h` is nonzero and that the length of `g` is one less than - # the length of `h` (possibly with zero padding). We also require - # that the length of `f` is less than the length of `h`. The output - # is not allowed to be aliased with any of the inputs. - # The algorithm used is the Brent-Kung matrix algorithm. - void fq_poly_compose_mod_brent_kung(fq_poly_t res, const fq_poly_t f, const fq_poly_t g, const fq_poly_t h, const fq_ctx_t ctx) noexcept - # Sets ``res`` to the composition `f(g)` modulo `h`. We require - # that `h` is nonzero and that `f` has smaller degree than `h`. The - # algorithm used is the Brent-Kung matrix algorithm. - void _fq_poly_compose_mod_brent_kung_preinv(fq_struct * res, const fq_struct * f, slong lenf, const fq_struct * g, const fq_struct * h, slong lenh, const fq_struct * hinv, slong lenhiv, const fq_ctx_t ctx) noexcept - # Sets ``res`` to the composition `f(g)` modulo `h`. We require - # that `h` is nonzero and that the length of `g` is one less than - # the length of `h` (possibly with zero padding). We also require - # that the length of `f` is less than the length of - # `h`. Furthermore, we require ``hinv`` to be the inverse of the - # reverse of ``h``. The output is not allowed to be aliased with - # any of the inputs. - # The algorithm used is the Brent-Kung matrix algorithm. - void fq_poly_compose_mod_brent_kung_preinv(fq_poly_t res, const fq_poly_t f, const fq_poly_t g, const fq_poly_t h, const fq_poly_t hinv, const fq_ctx_t ctx) noexcept - # Sets ``res`` to the composition `f(g)` modulo `h`. We require - # that `h` is nonzero and that `f` has smaller degree than - # `h`. Furthermore, we require ``hinv`` to be the inverse of the - # reverse of ``h``. The algorithm used is the Brent-Kung matrix - # algorithm. - void _fq_poly_compose_mod(fq_struct * res, const fq_struct * f, slong lenf, const fq_struct * g, const fq_struct * h, slong lenh, const fq_ctx_t ctx) noexcept - # Sets ``res`` to the composition `f(g)` modulo `h`. We require - # that `h` is nonzero and that the length of `g` is one less than - # the length of `h` (possibly with zero padding). The output is not - # allowed to be aliased with any of the inputs. - void fq_poly_compose_mod(fq_poly_t res, const fq_poly_t f, const fq_poly_t g, const fq_poly_t h, const fq_ctx_t ctx) noexcept - # Sets ``res`` to the composition `f(g)` modulo `h`. We require - # that `h` is nonzero. - void _fq_poly_compose_mod_preinv(fq_struct * res, const fq_struct * f, slong lenf, const fq_struct * g, const fq_struct * h, slong lenh, const fq_struct * hinv, slong lenhiv, const fq_ctx_t ctx) noexcept - # Sets ``res`` to the composition `f(g)` modulo `h`. We require - # that `h` is nonzero and that the length of `g` is one less than - # the length of `h` (possibly with zero padding). We also require - # that the length of `f` is less than the length of - # `h`. Furthermore, we require ``hinv`` to be the inverse of the - # reverse of ``h``. The output is not allowed to be aliased with - # any of the inputs. - void fq_poly_compose_mod_preinv(fq_poly_t res, const fq_poly_t f, const fq_poly_t g, const fq_poly_t h, const fq_poly_t hinv, const fq_ctx_t ctx) noexcept - # Sets ``res`` to the composition `f(g)` modulo `h`. We require - # that `h` is nonzero and that `f` has smaller degree than - # `h`. Furthermore, we require ``hinv`` to be the inverse of the - # reverse of ``h``. - void _fq_poly_reduce_matrix_mod_poly (fq_mat_t A, const fq_mat_t B, const fq_poly_t f, const fq_ctx_t ctx) noexcept - # Sets the ith row of ``A`` to the reduction of the ith row of `B` modulo - # `f` for `i=1,\ldots,\sqrt{\deg(f)}`. We require `B` to be at least - # a `\sqrt{\deg(f)}\times \deg(f)` matrix and `f` to be nonzero. - - void _fq_poly_precompute_matrix (fq_mat_t A, const fq_struct* f, const fq_struct* g, slong leng, const fq_struct* ginv, slong lenginv, const fq_ctx_t ctx) noexcept - # Sets the ith row of ``A`` to `f^i` modulo `g` for - # `i=1,\ldots,\sqrt{\deg(g)}`. We require `A` to be a - # `\sqrt{\deg(g)}\times \deg(g)` matrix. We require ``ginv`` to - # be the inverse of the reverse of ``g`` and `g` to be nonzero. - + void _fq_poly_precompute_matrix (fq_mat_t A, const fq_struct * f, const fq_struct * g, slong leng, const fq_struct * ginv, slong lenginv, const fq_ctx_t ctx) noexcept void fq_poly_precompute_matrix (fq_mat_t A, const fq_poly_t f, const fq_poly_t g, const fq_poly_t ginv, const fq_ctx_t ctx) noexcept - # Sets the ith row of ``A`` to `f^i` modulo `g` for - # `i=1,\ldots,\sqrt{\deg(g)}`. We require `A` to be a - # `\sqrt{\deg(g)}\times \deg(g)` matrix. We require ``ginv`` to - # be the inverse of the reverse of ``g``. - - void _fq_poly_compose_mod_brent_kung_precomp_preinv(fq_struct* res, const fq_struct* f, slong lenf, const fq_mat_t A, const fq_struct* h, slong lenh, const fq_struct* hinv, slong lenhinv, const fq_ctx_t ctx) noexcept - # Sets ``res`` to the composition `f(g)` modulo `h`. We require - # that `h` is nonzero. We require that the ith row of `A` contains - # `g^i` for `i=1,\ldots,\sqrt{\deg(h)}`, i.e. `A` is a - # `\sqrt{\deg(h)}\times \deg(h)` matrix. We also require that the - # length of `f` is less than the length of `h`. Furthermore, we - # require ``hinv`` to be the inverse of the reverse of ``h``. - # The output is not allowed to be aliased with any of the inputs. - # The algorithm used is the Brent-Kung matrix algorithm. - + void _fq_poly_compose_mod_brent_kung_precomp_preinv(fq_struct * res, const fq_struct * f, slong lenf, const fq_mat_t A, const fq_struct * h, slong lenh, const fq_struct * hinv, slong lenhinv, const fq_ctx_t ctx) noexcept void fq_poly_compose_mod_brent_kung_precomp_preinv(fq_poly_t res, const fq_poly_t f, const fq_mat_t A, const fq_poly_t h, const fq_poly_t hinv, const fq_ctx_t ctx) noexcept - # Sets ``res`` to the composition `f(g)` modulo `h`. We require - # that the ith row of `A` contains `g^i` for - # `i=1,\ldots,\sqrt{\deg(h)}`, i.e. `A` is a `\sqrt{\deg(h)}\times - # \deg(h)` matrix. We require that `h` is nonzero and that `f` has - # smaller degree than `h`. Furthermore, we require ``hinv`` to be - # the inverse of the reverse of ``h``. This version of Brent-Kung - # modular composition is particularly useful if one has to perform - # several modular composition of the form `f(g)` modulo `h` for - # fixed `g` and `h`. - - int _fq_poly_fprint_pretty(FILE *file, const fq_struct *poly, slong len, const char *x, const fq_ctx_t ctx) noexcept - # Prints the pretty representation of ``(poly, len)`` to the stream - # ``file``, using the string ``x`` to represent the indeterminate. - # In case of success, returns a positive value. In case of failure, - # returns a non-positive value. - - int fq_poly_fprint_pretty(FILE * file, const fq_poly_t poly, const char *x, const fq_ctx_t ctx) noexcept - # Prints the pretty representation of ``poly`` to the stream - # ``file``, using the string ``x`` to represent the indeterminate. - # In case of success, returns a positive value. In case of failure, - # returns a non-positive value. - - int _fq_poly_print_pretty(const fq_struct *poly, slong len, const char *x, const fq_ctx_t ctx) noexcept - # Prints the pretty representation of ``(poly, len)`` to ``stdout``, - # using the string ``x`` to represent the indeterminate. - # In case of success, returns a positive value. In case of failure, - # returns a non-positive value. - - int fq_poly_print_pretty(const fq_poly_t poly, const char *x, const fq_ctx_t ctx) noexcept - # Prints the pretty representation of ``poly`` to ``stdout``, - # using the string ``x`` to represent the indeterminate. - # In case of success, returns a positive value. In case of failure, - # returns a non-positive value. - - int _fq_poly_fprint(FILE *file, const fq_struct *poly, slong len, const fq_ctx_t ctx) noexcept - # Prints the pretty representation of ``(poly, len)`` to the stream - # ``file``. - # In case of success, returns a positive value. In case of failure, - # returns a non-positive value. - + int _fq_poly_fprint_pretty(FILE * file, const fq_struct * poly, slong len, const char * x, const fq_ctx_t ctx) noexcept + int fq_poly_fprint_pretty(FILE * file, const fq_poly_t poly, const char * x, const fq_ctx_t ctx) noexcept + int _fq_poly_print_pretty(const fq_struct * poly, slong len, const char * x, const fq_ctx_t ctx) noexcept + int fq_poly_print_pretty(const fq_poly_t poly, const char * x, const fq_ctx_t ctx) noexcept + int _fq_poly_fprint(FILE * file, const fq_struct * poly, slong len, const fq_ctx_t ctx) noexcept int fq_poly_fprint(FILE * file, const fq_poly_t poly, const fq_ctx_t ctx) noexcept - # Prints the pretty representation of ``poly`` to the stream - # ``file``. - # In case of success, returns a positive value. In case of failure, - # returns a non-positive value. - - int _fq_poly_print(const fq_struct *poly, slong len, const fq_ctx_t ctx) noexcept - # Prints the pretty representation of ``(poly, len)`` to ``stdout``. - # In case of success, returns a positive value. In case of failure, - # returns a non-positive value. - + int _fq_poly_print(const fq_struct * poly, slong len, const fq_ctx_t ctx) noexcept int fq_poly_print(const fq_poly_t poly, const fq_ctx_t ctx) noexcept - # Prints the representation of ``poly`` to ``stdout``. - # In case of success, returns a positive value. In case of failure, - # returns a non-positive value. - char * _fq_poly_get_str(const fq_struct * poly, slong len, const fq_ctx_t ctx) noexcept - # Returns the plain FLINT string representation of the polynomial - # ``(poly, len)``. - char * fq_poly_get_str(const fq_poly_t poly, const fq_ctx_t ctx) noexcept - # Returns the plain FLINT string representation of the polynomial - # ``poly``. - char * _fq_poly_get_str_pretty(const fq_struct * poly, slong len, const char * x, const fq_ctx_t ctx) noexcept - # Returns a pretty representation of the polynomial - # ``(poly, len)`` using the null-terminated string ``x`` as the - # variable name. - char * fq_poly_get_str_pretty(const fq_poly_t poly, const char * x, const fq_ctx_t ctx) noexcept - # Returns a pretty representation of the polynomial ``poly`` using the - # null-terminated string ``x`` as the variable name - void fq_poly_inflate(fq_poly_t result, const fq_poly_t input, ulong inflation, const fq_ctx_t ctx) noexcept - # Sets ``result`` to the inflated polynomial `p(x^n)` where - # `p` is given by ``input`` and `n` is given by ``inflation``. - void fq_poly_deflate(fq_poly_t result, const fq_poly_t input, ulong deflation, const fq_ctx_t ctx) noexcept - # Sets ``result`` to the deflated polynomial `p(x^{1/n})` where - # `p` is given by ``input`` and `n` is given by ``deflation``. - # Requires `n > 0`. - ulong fq_poly_deflation(const fq_poly_t input, const fq_ctx_t ctx) noexcept - # Returns the largest integer by which ``input`` can be deflated. - # As special cases, returns 0 if ``input`` is the zero polynomial - # and 1 of ``input`` is a constant polynomial. diff --git a/src/sage/libs/flint/fq_poly_factor.pxd b/src/sage/libs/flint/fq_poly_factor.pxd index 4a5dedcc73c..d7e1a8b0e60 100644 --- a/src/sage/libs/flint/fq_poly_factor.pxd +++ b/src/sage/libs/flint/fq_poly_factor.pxd @@ -2,7 +2,9 @@ # distutils: depends = flint/fq_poly_factor.h ################################################################################ -# This file is auto-generated. Do not modify by hand +# This file is auto-generated by the script +# SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py. +# Do not modify by hand! Fix and rerun the script instead. ################################################################################ from libc.stdio cimport FILE @@ -11,158 +13,33 @@ from sage.libs.mpfr.types cimport * from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void fq_poly_factor_init(fq_poly_factor_t fac, const fq_ctx_t ctx) noexcept - # Initialises ``fac`` for use. An :type:`fq_poly_factor_t` - # represents a polynomial in factorised form as a product of - # polynomials with associated exponents. - void fq_poly_factor_clear(fq_poly_factor_t fac, const fq_ctx_t ctx) noexcept - # Frees all memory associated with ``fac``. - void fq_poly_factor_realloc(fq_poly_factor_t fac, slong alloc, const fq_ctx_t ctx) noexcept - # Reallocates the factor structure to provide space for - # precisely ``alloc`` factors. - void fq_poly_factor_fit_length(fq_poly_factor_t fac, slong len, const fq_ctx_t ctx) noexcept - # Ensures that the factor structure has space for at least - # ``len`` factors. This function takes care of the case of - # repeated calls by always at least doubling the number of factors - # the structure can hold. - void fq_poly_factor_set(fq_poly_factor_t res, const fq_poly_factor_t fac, const fq_ctx_t ctx) noexcept - # Sets ``res`` to the same factorisation as ``fac``. - void fq_poly_factor_print_pretty(const fq_poly_factor_t fac, const char * var, const fq_ctx_t ctx) noexcept - # Pretty-prints the entries of ``fac`` to standard output. - void fq_poly_factor_print(const fq_poly_factor_t fac, const fq_ctx_t ctx) noexcept - # Prints the entries of ``fac`` to standard output. - void fq_poly_factor_insert(fq_poly_factor_t fac, const fq_poly_t poly, slong exp, const fq_ctx_t ctx) noexcept - # Inserts the factor ``poly`` with multiplicity ``exp`` into - # the factorisation ``fac``. - # If ``fac`` already contains ``poly``, then ``exp`` simply - # gets added to the exponent of the existing entry. - void fq_poly_factor_concat(fq_poly_factor_t res, const fq_poly_factor_t fac, const fq_ctx_t ctx) noexcept - # Concatenates two factorisations. - # This is equivalent to calling :func:`fq_poly_factor_insert` - # repeatedly with the individual factors of ``fac``. - # Does not support aliasing between ``res`` and ``fac``. - void fq_poly_factor_pow(fq_poly_factor_t fac, slong exp, const fq_ctx_t ctx) noexcept - # Raises ``fac`` to the power ``exp``. - ulong fq_poly_remove(fq_poly_t f, const fq_poly_t p, const fq_ctx_t ctx) noexcept - # Removes the highest possible power of ``p`` from ``f`` and - # returns the exponent. - bint fq_poly_is_irreducible(const fq_poly_t f, const fq_ctx_t ctx) noexcept - # Returns 1 if the polynomial ``f`` is irreducible, otherwise returns 0. - bint fq_poly_is_irreducible_ddf(const fq_poly_t f, const fq_ctx_t ctx) noexcept - # Returns 1 if the polynomial ``f`` is irreducible, otherwise returns 0. - # Uses fast distinct-degree factorisation. - bint fq_poly_is_irreducible_ben_or(const fq_poly_t f, const fq_ctx_t ctx) noexcept - # Returns 1 if the polynomial ``f`` is irreducible, otherwise returns 0. - # Uses Ben-Or's irreducibility test. - bint _fq_poly_is_squarefree(const fq_struct * f, slong len, const fq_ctx_t ctx) noexcept - # Returns 1 if ``(f, len)`` is squarefree, and 0 otherwise. As a - # special case, the zero polynomial is not considered squarefree. - # There are no restrictions on the length. - bint fq_poly_is_squarefree(const fq_poly_t f, const fq_ctx_t ctx) noexcept - # Returns 1 if ``f`` is squarefree, and 0 otherwise. As a special - # case, the zero polynomial is not considered squarefree. - bint fq_poly_factor_equal_deg_prob(fq_poly_t factor, flint_rand_t state, const fq_poly_t pol, slong d, const fq_ctx_t ctx) noexcept - # Probabilistic equal degree factorisation of ``pol`` into - # irreducible factors of degree ``d``. If it passes, a factor is - # placed in factor and 1 is returned, otherwise 0 is returned and - # the value of factor is undetermined. - # Requires that ``pol`` be monic, non-constant and squarefree. - void fq_poly_factor_equal_deg(fq_poly_factor_t factors, const fq_poly_t pol, slong d, const fq_ctx_t ctx) noexcept - # Assuming ``pol`` is a product of irreducible factors all of - # degree ``d``, finds all those factors and places them in - # factors. Requires that ``pol`` be monic, non-constant and - # squarefree. - void fq_poly_factor_split_single(fq_poly_t linfactor, const fq_poly_t input, const fq_ctx_t ctx) noexcept - # Assuming ``input`` is a product of factors all of degree 1, finds a single - # linear factor of ``input`` and places it in ``linfactor``. - # Requires that ``input`` be monic and non-constant. - - void fq_poly_factor_distinct_deg(fq_poly_factor_t res, const fq_poly_t poly, slong * const *degs, const fq_ctx_t ctx) noexcept - # Factorises a monic non-constant squarefree polynomial ``poly`` - # of degree `n` into factors `f[d]` such that for `1 \leq d \leq n` - # `f[d]` is the product of the monic irreducible factors of - # ``poly`` of degree `d`. Factors are stored in ``res``, - # associated powers of irreducible polynomials are stored in - # ``degs`` in the same order as factors. - # Requires that ``degs`` have enough space for irreducible polynomials' - # powers (maximum space required is ``n * sizeof(slong)``). - + void fq_poly_factor_distinct_deg(fq_poly_factor_t res, const fq_poly_t poly, slong * const * degs, const fq_ctx_t ctx) noexcept void fq_poly_factor_squarefree(fq_poly_factor_t res, const fq_poly_t f, const fq_ctx_t ctx) noexcept - # Sets ``res`` to a squarefree factorization of ``f``. - void fq_poly_factor(fq_poly_factor_t res, fq_t lead, const fq_poly_t f, const fq_ctx_t ctx) noexcept - # Factorises a non-constant polynomial ``f`` into monic - # irreducible factors choosing the best algorithm for given modulo - # and degree. The output ``lead`` is set to the leading coefficient of `f` - # upon return. Choice of algorithm is based on heuristic measurements. - void fq_poly_factor_cantor_zassenhaus(fq_poly_factor_t res, const fq_poly_t f, const fq_ctx_t ctx) noexcept - # Factorises a non-constant polynomial ``f`` into monic - # irreducible factors using the Cantor-Zassenhaus algorithm. - void fq_poly_factor_kaltofen_shoup(fq_poly_factor_t res, const fq_poly_t poly, const fq_ctx_t ctx) noexcept - # Factorises a non-constant polynomial ``f`` into monic - # irreducible factors using the fast version of Cantor-Zassenhaus - # algorithm proposed by Kaltofen and Shoup (1998). More precisely - # this algorithm uses a “baby step/giant step” strategy for the - # distinct-degree factorization step. - void fq_poly_factor_berlekamp(fq_poly_factor_t factors, const fq_poly_t f, const fq_ctx_t ctx) noexcept - # Factorises a non-constant polynomial ``f`` into monic - # irreducible factors using the Berlekamp algorithm. - void fq_poly_factor_with_berlekamp(fq_poly_factor_t res, fq_t leading_coeff, const fq_poly_t f, const fq_ctx_t ctx) noexcept - # Factorises a general polynomial ``f`` into monic irreducible - # factors and sets ``leading_coeff`` to the leading coefficient - # of ``f``, or 0 if ``f`` is the zero polynomial. - # This function first checks for small special cases, deflates - # ``f`` if it is of the form `p(x^m)` for some `m > 1`, then - # performs a square-free factorisation, and finally runs Berlekamp - # factorisation on all the individual square-free factors. - void fq_poly_factor_with_cantor_zassenhaus(fq_poly_factor_t res, fq_t leading_coeff, const fq_poly_t f, const fq_ctx_t ctx) noexcept - # Factorises a general polynomial ``f`` into monic irreducible - # factors and sets ``leading_coeff`` to the leading coefficient - # of ``f``, or 0 if ``f`` is the zero polynomial. - # This function first checks for small special cases, deflates - # ``f`` if it is of the form `p(x^m)` for some `m > 1`, then - # performs a square-free factorisation, and finally runs - # Cantor-Zassenhaus on all the individual square-free factors. - void fq_poly_factor_with_kaltofen_shoup(fq_poly_factor_t res, fq_t leading_coeff, const fq_poly_t f, const fq_ctx_t ctx) noexcept - # Factorises a general polynomial ``f`` into monic irreducible - # factors and sets ``leading_coeff`` to the leading coefficient - # of ``f``, or 0 if ``f`` is the zero polynomial. - # This function first checks for small special cases, deflates - # ``f`` if it is of the form `p(x^m)` for some `m > 1`, then - # performs a square-free factorisation, and finally runs - # Kaltofen-Shoup on all the individual square-free factors. - - void fq_poly_iterated_frobenius_preinv(fq_poly_t *rop, slong n, const fq_poly_t v, const fq_poly_t vinv, const fq_ctx_t ctx) noexcept - # Sets ``rop[i]`` to be `x^{q^i}\bmod v` for `0 \le i < n`. - # It is required that ``vinv`` is the inverse of the reverse of - # ``v`` mod ``x^lenv``. - + void fq_poly_iterated_frobenius_preinv(fq_poly_t * rop, slong n, const fq_poly_t v, const fq_poly_t vinv, const fq_ctx_t ctx) noexcept void fq_poly_roots(fq_poly_factor_t r, const fq_poly_t f, int with_multiplicity, const fq_ctx_t ctx) noexcept - # Fill `r` with factors of the form `x - r_i` where the `r_i` are the distinct roots of a nonzero `f` in `F_q`. - # If `with\_multiplicity` is zero, the exponent `e_i` of the factor `x - r_i` is `1`. Otherwise, it is the largest `e_i` such that `(x-r_i)^e_i` divides `f`. - # This function throws if `f` is zero, but is otherwise always successful. diff --git a/src/sage/libs/flint/fq_vec.pxd b/src/sage/libs/flint/fq_vec.pxd index 506f4133404..ec5d5bdf6a2 100644 --- a/src/sage/libs/flint/fq_vec.pxd +++ b/src/sage/libs/flint/fq_vec.pxd @@ -2,7 +2,9 @@ # distutils: depends = flint/fq_vec.h ################################################################################ -# This file is auto-generated. Do not modify by hand +# This file is auto-generated by the script +# SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py. +# Do not modify by hand! Fix and rerun the script instead. ################################################################################ from libc.stdio cimport FILE @@ -11,63 +13,19 @@ from sage.libs.mpfr.types cimport * from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - fq_struct * _fq_vec_init(slong len, const fq_ctx_t ctx) noexcept - # Returns an initialised vector of ``fq``'s of given length. - void _fq_vec_clear(fq_struct * vec, slong len, const fq_ctx_t ctx) noexcept - # Clears the entries of ``(vec, len)`` and frees the space allocated - # for ``vec``. - void _fq_vec_randtest(fq_struct * f, flint_rand_t state, slong len, const fq_ctx_t ctx) noexcept - # Sets the entries of a vector of the given length to elements of - # the finite field. - int _fq_vec_fprint(FILE * file, const fq_struct * vec, slong len, const fq_ctx_t ctx) noexcept - # Prints the vector of given length to the stream ``file``. The - # format is the length followed by two spaces, then a space separated - # list of coefficients. If the length is zero, only `0` is printed. - # In case of success, returns a positive value. In case of failure, - # returns a non-positive value. - int _fq_vec_print(const fq_struct * vec, slong len, const fq_ctx_t ctx) noexcept - # Prints the vector of given length to ``stdout``. - # For further details, see ``_fq_vec_fprint()``. - void _fq_vec_set(fq_struct * vec1, const fq_struct * vec2, slong len2, const fq_ctx_t ctx) noexcept - # Makes a copy of ``(vec2, len2)`` into ``vec1``. - void _fq_vec_swap(fq_struct * vec1, fq_struct * vec2, slong len2, const fq_ctx_t ctx) noexcept - # Swaps the elements in ``(vec1, len2)`` and ``(vec2, len2)``. - void _fq_vec_zero(fq_struct * vec, slong len, const fq_ctx_t ctx) noexcept - # Zeros the entries of ``(vec, len)``. - void _fq_vec_neg(fq_struct * vec1, const fq_struct * vec2, slong len2, const fq_ctx_t ctx) noexcept - # Negates ``(vec2, len2)`` and places it into ``vec1``. - bint _fq_vec_equal(const fq_struct * vec1, const fq_struct * vec2, slong len, const fq_ctx_t ctx) noexcept - # Compares two vectors of the given length and returns `1` if they are - # equal, otherwise returns `0`. - bint _fq_vec_is_zero(const fq_struct * vec, slong len, const fq_ctx_t ctx) noexcept - # Returns `1` if ``(vec, len)`` is zero, and `0` otherwise. - void _fq_vec_add(fq_struct * res, const fq_struct * vec1, const fq_struct * vec2, slong len2, const fq_ctx_t ctx) noexcept - # Sets ``(res, len2)`` to the sum of ``(vec1, len2)`` - # and ``(vec2, len2)``. - void _fq_vec_sub(fq_struct * res, const fq_struct * vec1, const fq_struct * vec2, slong len2, const fq_ctx_t ctx) noexcept - # Sets ``(res, len2)`` to ``(vec1, len2)`` minus ``(vec2, len2)``. - void _fq_vec_scalar_addmul_fq(fq_struct * vec1, const fq_struct * vec2, slong len2, const fq_t c, const fq_ctx_t ctx) noexcept - # Adds ``(vec2, len2)`` times `c` to ``(vec1, len2)``, where - # `c` is a ``fq_t``. - void _fq_vec_scalar_submul_fq(fq_struct * vec1, const fq_struct * vec2, slong len2, const fq_t c, const fq_ctx_t ctx) noexcept - # Subtracts ``(vec2, len2)`` times `c` from ``(vec1, len2)``, - # where `c` is a ``fq_t``. - void _fq_vec_dot(fq_t res, const fq_struct * vec1, const fq_struct * vec2, slong len2, const fq_ctx_t ctx) noexcept - # Sets ``res`` to the dot product of (``vec1``, ``len``) - # and (``vec2``, ``len``). diff --git a/src/sage/libs/flint/fq_zech.pxd b/src/sage/libs/flint/fq_zech.pxd index b0cf8c2f0c6..1fa779ae88b 100644 --- a/src/sage/libs/flint/fq_zech.pxd +++ b/src/sage/libs/flint/fq_zech.pxd @@ -2,7 +2,9 @@ # distutils: depends = flint/fq_zech.h ################################################################################ -# This file is auto-generated. Do not modify by hand +# This file is auto-generated by the script +# SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py. +# Do not modify by hand! Fix and rerun the script instead. ################################################################################ from libc.stdio cimport FILE @@ -11,370 +13,85 @@ from sage.libs.mpfr.types cimport * from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - - void fq_zech_ctx_init(fq_zech_ctx_t ctx, const fmpz_t p, slong d, const char *var) noexcept - # Initialises the context for prime `p` and extension degree `d`, - # with name ``var`` for the generator. By default, it will try - # use a Conway polynomial; if one is not available, a random - # primitive polynomial will be used. - # Assumes that `p` is a prime and :math:`p^d < 2^{\mathtt{FLINT\_BITS}}`. - # Assumes that the string ``var`` is a null-terminated string - # of length at least one. - - int _fq_zech_ctx_init_conway(fq_zech_ctx_t ctx, const fmpz_t p, slong d, const char *var) noexcept - # Attempts to initialise the context for prime `p` and extension - # degree `d`, with name ``var`` for the generator using a Conway - # polynomial for the modulus. - # Returns `1` if the Conway polynomial is in the database for the - # given size and the initialization is successful; otherwise, - # returns `0`. - # Assumes that `p` is a prime and `p^d < 2^\mathtt{FLINT\_BITS}`. - # Assumes that the string ``var`` is a null-terminated string - # of length at least one. - - void fq_zech_ctx_init_conway(fq_zech_ctx_t ctx, const fmpz_t p, slong d, const char *var) noexcept - # Initialises the context for prime `p` and extension degree `d`, - # with name ``var`` for the generator using a Conway polynomial - # for the modulus. - # Assumes that `p` is a prime and `p^d < 2^\mathtt{FLINT\_BITS}`. - # Assumes that the string ``var`` is a null-terminated string - # of length at least one. - - void fq_zech_ctx_init_random(fq_zech_ctx_t ctx, const fmpz_t p, slong d, const char *var) noexcept - # Initialises the context for prime `p` and extension degree `d`, - # with name ``var`` for the generator using a random primitive - # polynomial. - # Assumes that `p` is a prime and `p^d < 2^\mathtt{FLINT\_BITS}`. - # Assumes that the string ``var`` is a null-terminated string - # of length at least one. - - void fq_zech_ctx_init_modulus(fq_zech_ctx_t ctx, const nmod_poly_t modulus, const char *var) noexcept - # Initialises the context for given ``modulus`` with name - # ``var`` for the generator. - # Assumes that ``modulus`` is an primitive polynomial over - # `\mathbf{F}_{p}`. An exception is raised if a non-primitive modulus is - # detected. - # Assumes that the string ``var`` is a null-terminated string - # of length at least one. - - int fq_zech_ctx_init_modulus_check(fq_zech_ctx_t ctx, const nmod_poly_t modulus, const char *var) noexcept - # As per the previous function, but returns `0` if the modulus was not - # primitive and `1` if the context was successfully initialised with the - # given modulus. No exception is raised. - + void fq_zech_ctx_init(fq_zech_ctx_t ctx, const fmpz_t p, slong d, const char * var) noexcept + int _fq_zech_ctx_init_conway(fq_zech_ctx_t ctx, const fmpz_t p, slong d, const char * var) noexcept + void fq_zech_ctx_init_conway(fq_zech_ctx_t ctx, const fmpz_t p, slong d, const char * var) noexcept + void fq_zech_ctx_init_random(fq_zech_ctx_t ctx, const fmpz_t p, slong d, const char * var) noexcept + void fq_zech_ctx_init_modulus(fq_zech_ctx_t ctx, const nmod_poly_t modulus, const char * var) noexcept + int fq_zech_ctx_init_modulus_check(fq_zech_ctx_t ctx, const nmod_poly_t modulus, const char * var) noexcept void fq_zech_ctx_init_fq_nmod_ctx(fq_zech_ctx_t ctx, fq_nmod_ctx_t ctxn) noexcept - # Initializes the context ``ctx`` to be the Zech representation - # for the finite field given by ``ctxn``. - int fq_zech_ctx_init_fq_nmod_ctx_check(fq_zech_ctx_t ctx, fq_nmod_ctx_t ctxn) noexcept - # As per the previous function but returns `0` if a non-primitive modulus is - # detected. Returns `0` if the Zech representation was successfully - # initialised. - void fq_zech_ctx_clear(fq_zech_ctx_t ctx) noexcept - # Clears all memory that has been allocated as part of the context. - const nmod_poly_struct* fq_zech_ctx_modulus(const fq_zech_ctx_t ctx) noexcept - # Returns a pointer to the modulus in the context. - slong fq_zech_ctx_degree(const fq_zech_ctx_t ctx) noexcept - # Returns the degree of the field extension - # `[\mathbf{F}_{q} : \mathbf{F}_{p}]`, which - # is equal to `\log_{p} q`. - fmpz * fq_zech_ctx_prime(const fq_zech_ctx_t ctx) noexcept - # Returns a pointer to the prime `p` in the context. - void fq_zech_ctx_order(fmpz_t f, const fq_zech_ctx_t ctx) noexcept - # Sets `f` to be the size of the finite field. - mp_limb_t fq_zech_ctx_order_ui(const fq_zech_ctx_t ctx) noexcept - # Returns the size of the finite field. - int fq_zech_ctx_fprint(FILE * file, const fq_zech_ctx_t ctx) noexcept - # Prints the context information to {\tt{file}}. Returns 1 for a - # success and a negative number for an error. - void fq_zech_ctx_print(const fq_zech_ctx_t ctx) noexcept - # Prints the context information to {\tt{stdout}}. - void fq_zech_ctx_randtest(fq_zech_ctx_t ctx, flint_rand_t state) noexcept - # Initializes ``ctx`` to a random finite field. Assumes that - # ``fq_zech_ctx_init`` has not been called on ``ctx`` already. - void fq_zech_ctx_randtest_reducible(fq_zech_ctx_t ctx, flint_rand_t state) noexcept - # Since the Zech logarithm representation does not work with a - # non-irreducible modulus, does the same as - # ``fq_zech_ctx_randtest``. - void fq_zech_init(fq_zech_t rop, const fq_zech_ctx_t ctx) noexcept - # Initialises the element ``rop``, setting its value to `0`. - void fq_zech_init2(fq_zech_t rop, const fq_zech_ctx_t ctx) noexcept - # Initialises ``poly`` with at least enough space for it to be an element - # of ``ctx`` and sets it to `0`. - void fq_zech_clear(fq_zech_t rop, const fq_zech_ctx_t ctx) noexcept - # Clears the element ``rop``. - void _fq_zech_sparse_reduce(mp_ptr R, slong lenR, const fq_zech_ctx_t ctx) noexcept - # Reduces ``(R, lenR)`` modulo the polynomial `f` given by the - # modulus of ``ctx``. - void _fq_zech_dense_reduce(mp_ptr R, slong lenR, const fq_zech_ctx_t ctx) noexcept - # Reduces ``(R, lenR)`` modulo the polynomial `f` given by the - # modulus of ``ctx`` using Newton division. - void _fq_zech_reduce(mp_ptr r, slong lenR, const fq_zech_ctx_t ctx) noexcept - # Reduces ``(R, lenR)`` modulo the polynomial `f` given by the - # modulus of ``ctx``. Does either sparse or dense reduction - # based on ``ctx->sparse_modulus``. - void fq_zech_reduce(fq_zech_t rop, const fq_zech_ctx_t ctx) noexcept - # Reduces the polynomial ``rop`` as an element of - # `\mathbf{F}_p[X] / (f(X))`. - void fq_zech_add(fq_zech_t rop, const fq_zech_t op1, const fq_zech_t op2, const fq_zech_ctx_t ctx) noexcept - # Sets ``rop`` to the sum of ``op1`` and ``op2``. - void fq_zech_sub(fq_zech_t rop, const fq_zech_t op1, const fq_zech_t op2, const fq_zech_ctx_t ctx) noexcept - # Sets ``rop`` to the difference of ``op1`` and ``op2``. - void fq_zech_sub_one(fq_zech_t rop, const fq_zech_t op1, const fq_zech_ctx_t ctx) noexcept - # Sets ``rop`` to the difference of ``op1`` and `1`. - void fq_zech_neg(fq_zech_t rop, const fq_zech_t op, const fq_zech_ctx_t ctx) noexcept - # Sets ``rop`` to the negative of ``op``. - void fq_zech_mul(fq_zech_t rop, const fq_zech_t op1, const fq_zech_t op2, const fq_zech_ctx_t ctx) noexcept - # Sets ``rop`` to the product of ``op1`` and ``op2``, - # reducing the output in the given context. - void fq_zech_mul_fmpz(fq_zech_t rop, const fq_zech_t op, const fmpz_t x, const fq_zech_ctx_t ctx) noexcept - # Sets ``rop`` to the product of ``op`` and `x`, - # reducing the output in the given context. - void fq_zech_mul_si(fq_zech_t rop, const fq_zech_t op, slong x, const fq_zech_ctx_t ctx) noexcept - # Sets ``rop`` to the product of ``op`` and `x`, - # reducing the output in the given context. - void fq_zech_mul_ui(fq_zech_t rop, const fq_zech_t op, ulong x, const fq_zech_ctx_t ctx) noexcept - # Sets ``rop`` to the product of ``op`` and `x`, - # reducing the output in the given context. - void fq_zech_sqr(fq_zech_t rop, const fq_zech_t op, const fq_zech_ctx_t ctx) noexcept - # Sets ``rop`` to the square of ``op``, - # reducing the output in the given context. - void fq_zech_div(fq_zech_t rop, const fq_zech_t op1, const fq_zech_t op2, const fq_zech_ctx_t ctx) noexcept - # Sets ``rop`` to the quotient of ``op1`` and ``op2``, - # reducing the output in the given context. - - void _fq_zech_inv(mp_ptr *rop, mp_srcptr *op, slong len, const fq_zech_ctx_t ctx) noexcept - # Sets ``(rop, d)`` to the inverse of the non-zero element - # ``(op, len)``. - + void _fq_zech_inv(mp_ptr * rop, mp_srcptr * op, slong len, const fq_zech_ctx_t ctx) noexcept void fq_zech_inv(fq_zech_t rop, const fq_zech_t op, const fq_zech_ctx_t ctx) noexcept - # Sets ``rop`` to the inverse of the non-zero element ``op``. - void fq_zech_gcdinv(fq_zech_t f, fq_zech_t inv, const fq_zech_t op, const fq_zech_ctx_t ctx) noexcept - # Sets ``inv`` to be the inverse of ``op`` modulo the modulus - # of ``ctx`` and sets ``f`` to one. Since the modulus for - # ``ctx`` is always irreducible, ``op`` is always invertible. - - void _fq_zech_pow(fmpz *rop, const fmpz *op, slong len, const fmpz_t e, const fmpz * a, const slong *j, slong lena, const fmpz_t p) noexcept - # Sets ``(rop, 2*d-1)`` to ``(op,len)`` raised to the power `e`, - # reduced modulo `f(X)`, the modulus of ``ctx``. - # Assumes that `e \geq 0` and that ``len`` is positive and at most `d`. - # Although we require that ``rop`` provides space for - # `2d - 1` coefficients, the output will be reduced modulo - # `f(X)`, which is a polynomial of degree `d`. - # Does not support aliasing. - + void _fq_zech_pow(fmpz * rop, const fmpz * op, slong len, const fmpz_t e, const fmpz * a, const slong * j, slong lena, const fmpz_t p) noexcept void fq_zech_pow(fq_zech_t rop, const fq_zech_t op, const fmpz_t e, const fq_zech_ctx_t ctx) noexcept - # Sets ``rop`` the ``op`` raised to the power `e`. - # Currently assumes that `e \geq 0`. - # Note that for any input ``op``, ``rop`` is set to `1` - # whenever `e = 0`. - void fq_zech_pow_ui(fq_zech_t rop, const fq_zech_t op, const ulong e, const fq_zech_ctx_t ctx) noexcept - # Sets ``rop`` the ``op`` raised to the power `e`. - # Currently assumes that `e \geq 0`. - # Note that for any input ``op``, ``rop`` is set to `1` - # whenever `e = 0`. - int fq_zech_sqrt(fq_zech_t rop, const fq_zech_t op1, const fq_zech_ctx_t ctx) noexcept - # Sets ``rop`` to the square root of ``op1`` if it is a square, and return - # `1`, otherwise return `0`. - void fq_zech_pth_root(fq_zech_t rop, const fq_zech_t op1, const fq_zech_ctx_t ctx) noexcept - # Sets ``rop`` to a `p^{th}` root root of ``op1``. Currently, - # this computes the root by raising ``op1`` to `p^{d-1}` where - # `d` is the degree of the extension. - bint fq_zech_is_square(const fq_zech_t op, const fq_zech_ctx_t ctx) noexcept - # Return ``1`` if ``op`` is a square. - - int fq_zech_fprint_pretty(FILE *file, const fq_zech_t op, const fq_zech_ctx_t ctx) noexcept - # Prints a pretty representation of ``op`` to ``file``. - # In the current implementation, always returns `1`. The return code is - # part of the function's signature to allow for a later implementation to - # return the number of characters printed or a non-positive error code. - + int fq_zech_fprint_pretty(FILE * file, const fq_zech_t op, const fq_zech_ctx_t ctx) noexcept void fq_zech_print_pretty(const fq_zech_t op, const fq_zech_ctx_t ctx) noexcept - # Prints a pretty representation of ``op`` to ``stdout``. - # In the current implementation, always returns `1`. The return code is - # part of the function's signature to allow for a later implementation to - # return the number of characters printed or a non-positive error code. - int fq_zech_fprint(FILE * file, const fq_zech_t op, const fq_zech_ctx_t ctx) noexcept - # Prints a representation of ``op`` to ``file``. - void fq_zech_print(const fq_zech_t op, const fq_zech_ctx_t ctx) noexcept - # Prints a representation of ``op`` to ``stdout``. - char * fq_zech_get_str(const fq_zech_t op, const fq_zech_ctx_t ctx) noexcept - # Returns the plain FLINT string representation of the element - # ``op``. - char * fq_zech_get_str_pretty(const fq_zech_t op, const fq_zech_ctx_t ctx) noexcept - # Returns a pretty representation of the element ``op`` using the - # null-terminated string ``x`` as the variable name. - void fq_zech_randtest(fq_zech_t rop, flint_rand_t state, const fq_zech_ctx_t ctx) noexcept - # Generates a random element of `\mathbf{F}_q`. - void fq_zech_randtest_not_zero(fq_zech_t rop, flint_rand_t state, const fq_zech_ctx_t ctx) noexcept - # Generates a random non-zero element of `\mathbf{F}_q`. - void fq_zech_randtest_dense(fq_zech_t rop, flint_rand_t state, const fq_zech_ctx_t ctx) noexcept - # Generates a random element of `\mathbf{F}_q` which has an - # underlying polynomial with dense coefficients. - void fq_zech_rand(fq_zech_t rop, flint_rand_t state, const fq_zech_ctx_t ctx) noexcept - # Generates a high quality random element of `\mathbf{F}_q`. - void fq_zech_rand_not_zero(fq_zech_t rop, flint_rand_t state, const fq_zech_ctx_t ctx) noexcept - # Generates a high quality non-zero random element of `\mathbf{F}_q`. - void fq_zech_set(fq_zech_t rop, const fq_zech_t op, const fq_zech_ctx_t ctx) noexcept - # Sets ``rop`` to ``op``. - void fq_zech_set_si(fq_zech_t rop, const slong x, const fq_zech_ctx_t ctx) noexcept - # Sets ``rop`` to ``x``, considered as an element of - # `\mathbf{F}_p`. - void fq_zech_set_ui(fq_zech_t rop, const ulong x, const fq_zech_ctx_t ctx) noexcept - # Sets ``rop`` to ``x``, considered as an element of - # `\mathbf{F}_p`. - void fq_zech_set_fmpz(fq_zech_t rop, const fmpz_t x, const fq_zech_ctx_t ctx) noexcept - # Sets ``rop`` to ``x``, considered as an element of - # `\mathbf{F}_p`. - void fq_zech_swap(fq_zech_t op1, fq_zech_t op2, const fq_zech_ctx_t ctx) noexcept - # Swaps the two elements ``op1`` and ``op2``. - void fq_zech_zero(fq_zech_t rop, const fq_zech_ctx_t ctx) noexcept - # Sets ``rop`` to zero. - void fq_zech_one(fq_zech_t rop, const fq_zech_ctx_t ctx) noexcept - # Sets ``rop`` to one, reduced in the given context. - void fq_zech_gen(fq_zech_t rop, const fq_zech_ctx_t ctx) noexcept - # Sets ``rop`` to a generator for the finite field. - # There is no guarantee this is a multiplicative generator of - # the finite field. - int fq_zech_get_fmpz(fmpz_t rop, const fq_zech_t op, const fq_zech_ctx_t ctx) noexcept - # If ``op`` has a lift to the integers, return `1` and set ``rop`` to the lift in `[0,p)`. - # Otherwise, return `0` and leave `rop` undefined. - void fq_zech_get_fq_nmod(fq_nmod_t rop, const fq_zech_t op, const fq_zech_ctx_t ctx) noexcept - # Sets ``rop`` to the ``fq_nmod_t`` element corresponding to ``op``. - void fq_zech_set_fq_nmod(fq_zech_t rop, const fq_nmod_t op, const fq_zech_ctx_t ctx) noexcept - # Sets ``rop`` to the ``fq_zech_t`` element corresponding to ``op``. - void fq_zech_get_nmod_poly(nmod_poly_t a, const fq_zech_t b, const fq_zech_ctx_t ctx) noexcept - # Set ``a`` to a representative of ``b`` in ``ctx``. - # The representatives are taken in `(\mathbb{Z}/p\mathbb{Z})[x]/h(x)` where `h(x)` is the defining polynomial in ``ctx``. - void fq_zech_set_nmod_poly(fq_zech_t a, const nmod_poly_t b, const fq_zech_ctx_t ctx) noexcept - # Set ``a`` to the element in ``ctx`` with representative ``b``. - # The representatives are taken in `(\mathbb{Z}/p\mathbb{Z})[x]/h(x)` where `h(x)` is the defining polynomial in ``ctx``. - void fq_zech_get_nmod_mat(nmod_mat_t col, const fq_zech_t a, const fq_zech_ctx_t ctx) noexcept - # Convert ``a`` to a column vector of length ``degree(ctx)``. - void fq_zech_set_nmod_mat(fq_zech_t a, const nmod_mat_t col, const fq_zech_ctx_t ctx) noexcept - # Convert a column vector ``col`` of length ``degree(ctx)`` to - # an element of ``ctx``. - bint fq_zech_is_zero(const fq_zech_t op, const fq_zech_ctx_t ctx) noexcept - # Returns whether ``op`` is equal to zero. - bint fq_zech_is_one(const fq_zech_t op, const fq_zech_ctx_t ctx) noexcept - # Returns whether ``op`` is equal to one. - bint fq_zech_equal(const fq_zech_t op1, const fq_zech_t op2, const fq_zech_ctx_t ctx) noexcept - # Returns whether ``op1`` and ``op2`` are equal. - bint fq_zech_is_invertible(const fq_zech_t op, const fq_zech_ctx_t ctx) noexcept - # Returns whether ``op`` is an invertible element. - bint fq_zech_is_invertible_f(fq_zech_t f, const fq_zech_t op, const fq_zech_ctx_t ctx) noexcept - # Returns whether ``op`` is an invertible element. If it is not, - # then ``f`` is set of a factor of the modulus. Since the - # modulus for an ``fq_zech_ctx_t`` is always irreducible, then - # any non-zero ``op`` will be invertible. - void fq_zech_trace(fmpz_t rop, const fq_zech_t op, const fq_zech_ctx_t ctx) noexcept - # Sets ``rop`` to the trace of ``op``. - # For an element `a \in \mathbf{F}_q`, multiplication by `a` defines - # a `\mathbf{F}_p`-linear map on `\mathbf{F}_q`. We define the - # trace of `a` as the trace of this map. Equivalently, if `\Sigma` - # generates `\operatorname{Gal}(\mathbf{F}_q / \mathbf{F}_p)` then the trace of - # `a` is equal to `\sum_{i=0}^{d-1} \Sigma^i (a)`, where `d = - # \log_{p} q`. - void fq_zech_norm(fmpz_t rop, const fq_zech_t op, const fq_zech_ctx_t ctx) noexcept - # Computes the norm of ``op``. - # For an element `a \in \mathbf{F}_q`, multiplication by `a` defines - # a `\mathbf{F}_p`-linear map on `\mathbf{F}_q`. We define the norm - # of `a` as the determinant of this map. Equivalently, if `\Sigma` generates - # `\operatorname{Gal}(\mathbf{F}_q / \mathbf{F}_p)` then the trace of `a` is equal to - # `\prod_{i=0}^{d-1} \Sigma^i (a)`, where - # `d = \text{dim}_{\mathbf{F}_p}(\mathbf{F}_q)`. - # Algorithm selection is automatic depending on the input. - void fq_zech_frobenius(fq_zech_t rop, const fq_zech_t op, slong e, const fq_zech_ctx_t ctx) noexcept - # Evaluates the homomorphism `\Sigma^e` at ``op``. - # Recall that `\mathbf{F}_q / \mathbf{F}_p` is Galois with Galois group - # `\langle \sigma \rangle`, which is also isomorphic to - # `\mathbf{Z}/d\mathbf{Z}`, where - # `\sigma \in \operatorname{Gal}(\mathbf{F}_q/\mathbf{F}_p)` is the Frobenius element - # `\sigma \colon x \mapsto x^p`. - int fq_zech_multiplicative_order(fmpz * ord, const fq_zech_t op, const fq_zech_ctx_t ctx) noexcept - # Computes the order of ``op`` as an element of the - # multiplicative group of ``ctx``. - # Returns 0 if ``op`` is 0, otherwise it returns 1 if ``op`` - # is a generator of the multiplicative group, and -1 if it is not. - # Note that ``ctx`` must already correspond to a finite field defined by - # a primitive polynomial and so this function cannot be used to check - # primitivity of the generator, but can be used to check that other elements - # are primitive. - bint fq_zech_is_primitive(const fq_zech_t op, const fq_zech_ctx_t ctx) noexcept - # Returns whether ``op`` is primitive, i.e., whether it is a - # generator of the multiplicative group of ``ctx``. - void fq_zech_bit_pack(fmpz_t f, const fq_zech_t op, flint_bitcnt_t bit_size, const fq_zech_ctx_t ctx) noexcept - # Packs ``op`` into bitfields of size ``bit_size``, writing the - # result to ``f``. - void fq_zech_bit_unpack(fq_zech_t rop, const fmpz_t f, flint_bitcnt_t bit_size, const fq_zech_ctx_t ctx) noexcept - # Unpacks into ``rop`` the element with coefficients packed into - # fields of size ``bit_size`` as represented by the integer - # ``f``. diff --git a/src/sage/libs/flint/fq_zech_embed.pxd b/src/sage/libs/flint/fq_zech_embed.pxd index 3b80717a548..59f66f7f5ae 100644 --- a/src/sage/libs/flint/fq_zech_embed.pxd +++ b/src/sage/libs/flint/fq_zech_embed.pxd @@ -2,7 +2,9 @@ # distutils: depends = flint/fq_zech_embed.h ################################################################################ -# This file is auto-generated. Do not modify by hand +# This file is auto-generated by the script +# SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py. +# Do not modify by hand! Fix and rerun the script instead. ################################################################################ from libc.stdio cimport FILE @@ -11,87 +13,14 @@ from sage.libs.mpfr.types cimport * from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void fq_zech_embed_gens(fq_zech_t gen_sub, fq_zech_t gen_sup, nmod_poly_t minpoly, const fq_zech_ctx_t sub_ctx, const fq_zech_ctx_t sup_ctx) noexcept - # Given two contexts ``sub_ctx`` and ``sup_ctx``, such that - # ``degree(sub_ctx)`` divides ``degree(sup_ctx)``, compute: - # * an element ``gen_sub`` in ``sub_ctx`` such that - # ``gen_sub`` generates the finite field defined by - # ``sub_ctx``, - # * its minimal polynomial ``minpoly``, - # * a root ``gen_sup`` of ``minpoly`` inside the field - # defined by ``sup_ctx``. - # These data uniquely define an embedding of ``sub_ctx`` into - # ``sup_ctx``. - void _fq_zech_embed_gens_naive(fq_zech_t gen_sub, fq_zech_t gen_sup, nmod_poly_t minpoly, const fq_zech_ctx_t sub_ctx, const fq_zech_ctx_t sup_ctx) noexcept - # Given two contexts ``sub_ctx`` and ``sup_ctx``, such that - # ``degree(sub_ctx)`` divides ``degree(sup_ctx)``, compute an - # embedding of ``sub_ctx`` into ``sup_ctx`` defined as follows: - # * ``gen_sub`` is the canonical generator of ``sup_ctx`` - # (i.e., the class of `X`), - # * ``minpoly`` is the defining polynomial of ``sub_ctx``, - # * ``gen_sup`` is a root of ``minpoly`` inside the field - # defined by ``sup_ctx``. - void fq_zech_embed_matrices(nmod_mat_t embed, nmod_mat_t project, const fq_zech_t gen_sub, const fq_zech_ctx_t sub_ctx, const fq_zech_t gen_sup, const fq_zech_ctx_t sup_ctx, const nmod_poly_t gen_minpoly) noexcept - # Given: - # * two contexts ``sub_ctx`` and ``sup_ctx``, of - # respective degrees `m` and `n`, such that `m` divides `n`; - # * a generator ``gen_sub`` of ``sub_ctx``, its minimal - # polynomial ``gen_minpoly``, and a root ``gen_sup`` of - # ``gen_minpoly`` in ``sup_ctx``, as returned by - # ``fq_zech_embed_gens``; - # Compute: - # * the `n\times m` matrix ``embed`` mapping ``gen_sub`` - # to ``gen_sup``, and all their powers accordingly; - # * an `m\times n` matrix ``project`` such that - # ``project`` `\times` ``embed`` is the `m\times m` identity - # matrix. - void fq_zech_embed_trace_matrix(nmod_mat_t res, const nmod_mat_t basis, const fq_zech_ctx_t sub_ctx, const fq_zech_ctx_t sup_ctx) noexcept - # Given: - # * two contexts ``sub_ctx`` and ``sup_ctx``, of degrees - # `m` and `n`, such that `m` divides `n`; - # * an `n\times m` matrix ``basis`` that maps ``sub_ctx`` - # to an isomorphic subfield in ``sup_ctx``; - # Compute the `m\times n` matrix of the trace from ``sup_ctx`` to - # ``sub_ctx``. - # This matrix is computed as - # ``embed_dual_to_mono_matrix(_, sub_ctx)`` - # `\times` ``basis``:sup:`t` `\times` - # ``embed_mono_to_dual_matrix(_, sup_ctx)}``. - # **Note:** if - # `m=n`, ``basis`` represents a Frobenius, and the result is its - # inverse matrix. - void fq_zech_embed_composition_matrix(nmod_mat_t matrix, const fq_zech_t gen, const fq_zech_ctx_t ctx) noexcept - # Compute the *composition matrix* of ``gen``. - # For an element `a\in\mathbf{F}_{p^n}`, its composition matrix is the - # matrix whose columns are `a^0, a^1, \ldots, a^{n-1}`. - void fq_zech_embed_composition_matrix_sub(nmod_mat_t matrix, const fq_zech_t gen, const fq_zech_ctx_t ctx, slong trunc) noexcept - # Compute the *composition matrix* of ``gen``, truncated to - # ``trunc`` columns. - void fq_zech_embed_mul_matrix(nmod_mat_t matrix, const fq_zech_t gen, const fq_zech_ctx_t ctx) noexcept - # Compute the *multiplication matrix* of ``gen``. - # For an element `a` in `\mathbf{F}_{p^n}=\mathbf{F}_p[x]`, its - # multiplication matrix is the matrix whose columns are `a, ax, - # \dots, ax^{n-1}`. - void fq_zech_embed_mono_to_dual_matrix(nmod_mat_t res, const fq_zech_ctx_t ctx) noexcept - # Compute the change of basis matrix from the monomial basis of - # ``ctx`` to its dual basis. - void fq_zech_embed_dual_to_mono_matrix(nmod_mat_t res, const fq_zech_ctx_t ctx) noexcept - # Compute the change of basis matrix from the dual basis of - # ``ctx`` to its monomial basis. - void fq_zech_modulus_pow_series_inv(nmod_poly_t res, const fq_zech_ctx_t ctx, slong trunc) noexcept - # Compute the power series inverse of the reverse of the modulus of - # ``ctx`` up to `O(x^\texttt{trunc})`. - void fq_zech_modulus_derivative_inv(fq_zech_t m_prime, fq_zech_t m_prime_inv, const fq_zech_ctx_t ctx) noexcept - # Compute the derivative ``m_prime`` of the modulus of ``ctx`` - # as an element of ``ctx``, and its inverse ``m_prime_inv``. diff --git a/src/sage/libs/flint/fq_zech_mat.pxd b/src/sage/libs/flint/fq_zech_mat.pxd index 174f6968daa..c4ee5d2fb59 100644 --- a/src/sage/libs/flint/fq_zech_mat.pxd +++ b/src/sage/libs/flint/fq_zech_mat.pxd @@ -2,7 +2,9 @@ # distutils: depends = flint/fq_zech_mat.h ################################################################################ -# This file is auto-generated. Do not modify by hand +# This file is auto-generated by the script +# SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py. +# Do not modify by hand! Fix and rerun the script instead. ################################################################################ from libc.stdio cimport FILE @@ -11,334 +13,64 @@ from sage.libs.mpfr.types cimport * from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void fq_zech_mat_init(fq_zech_mat_t mat, slong rows, slong cols, const fq_zech_ctx_t ctx) noexcept - # Initialises ``mat`` to a ``rows``-by-``cols`` matrix with - # coefficients in `\mathbf{F}_{q}` given by ``ctx``. All elements - # are set to zero. - void fq_zech_mat_init_set(fq_zech_mat_t mat, const fq_zech_mat_t src, const fq_zech_ctx_t ctx) noexcept - # Initialises ``mat`` and sets its dimensions and elements to - # those of ``src``. - void fq_zech_mat_clear(fq_zech_mat_t mat, const fq_zech_ctx_t ctx) noexcept - # Clears the matrix and releases any memory it used. The matrix - # cannot be used again until it is initialised. This function must be - # called exactly once when finished using an ``fq_zech_mat_t`` object. - void fq_zech_mat_set(fq_zech_mat_t mat, const fq_zech_mat_t src, const fq_zech_ctx_t ctx) noexcept - # Sets ``mat`` to a copy of ``src``. It is assumed - # that ``mat`` and ``src`` have identical dimensions. - fq_zech_struct * fq_zech_mat_entry(const fq_zech_mat_t mat, slong i, slong j) noexcept - # Directly accesses the entry in ``mat`` in row `i` and column `j`, - # indexed from zero. No bounds checking is performed. - void fq_zech_mat_entry_set(fq_zech_mat_t mat, slong i, slong j, const fq_zech_t x, const fq_zech_ctx_t ctx) noexcept - # Sets the entry in ``mat`` in row `i` and column `j` to ``x``. - slong fq_zech_mat_nrows(const fq_zech_mat_t mat, const fq_zech_ctx_t ctx) noexcept - # Returns the number of rows in ``mat``. - slong fq_zech_mat_ncols(const fq_zech_mat_t mat, const fq_zech_ctx_t ctx) noexcept - # Returns the number of columns in ``mat``. - void fq_zech_mat_swap(fq_zech_mat_t mat1, fq_zech_mat_t mat2, const fq_zech_ctx_t ctx) noexcept - # Swaps two matrices. The dimensions of ``mat1`` and ``mat2`` - # are allowed to be different. - void fq_zech_mat_swap_entrywise(fq_zech_mat_t mat1, fq_zech_mat_t mat2, const fq_zech_ctx_t ctx) noexcept - # Swaps two matrices by swapping the individual entries rather than swapping - # the contents of the structs. - void fq_zech_mat_zero(fq_zech_mat_t mat, const fq_zech_ctx_t ctx) noexcept - # Sets all entries of ``mat`` to 0. - void fq_zech_mat_one(fq_zech_mat_t mat, const fq_zech_ctx_t ctx) noexcept - # Sets all diagonal entries of ``mat`` to 1 and all other entries to 0. - void fq_zech_mat_set_nmod_mat(fq_zech_mat_t mat1, const nmod_mat_t mat2, const fq_zech_ctx_t ctx) noexcept - # Sets the matrix ``mat1`` to the matrix ``mat2``. - void fq_zech_mat_set_fmpz_mod_mat(fq_zech_mat_t mat1, const fmpz_mod_mat_t mat2, const fq_zech_ctx_t ctx) noexcept - # Sets the matrix ``mat1`` to the matrix ``mat2``. - void fq_zech_mat_concat_vertical(fq_zech_mat_t res, const fq_zech_mat_t mat1, const fq_zech_mat_t mat2, const fq_zech_ctx_t ctx) noexcept - # Sets ``res`` to vertical concatenation of (``mat1``, ``mat2``) in that order. Matrix dimensions : ``mat1`` : `m \times n`, ``mat2`` : `k \times n`, ``res`` : `(m + k) \times n`. - void fq_zech_mat_concat_horizontal(fq_zech_mat_t res, const fq_zech_mat_t mat1, const fq_zech_mat_t mat2, const fq_zech_ctx_t ctx) noexcept - # Sets ``res`` to horizontal concatenation of (``mat1``, ``mat2``) in that order. Matrix dimensions : ``mat1`` : `m \times n`, ``mat2`` : `m \times k`, ``res`` : `m \times (n + k)`. - int fq_zech_mat_print_pretty(const fq_zech_mat_t mat, const fq_zech_ctx_t ctx) noexcept - # Pretty-prints ``mat`` to ``stdout``. A header is printed - # followed by the rows enclosed in brackets. - int fq_zech_mat_fprint_pretty(FILE * file, const fq_zech_mat_t mat, const fq_zech_ctx_t ctx) noexcept - # Pretty-prints ``mat`` to ``file``. A header is printed - # followed by the rows enclosed in brackets. - # In case of success, returns a positive value. In case of failure, - # returns a non-positive value. - int fq_zech_mat_print(const fq_zech_mat_t mat, const fq_zech_ctx_t ctx) noexcept - # Prints ``mat`` to ``stdout``. A header is printed followed - # by the rows enclosed in brackets. - int fq_zech_mat_fprint(FILE * file, const fq_zech_mat_t mat, const fq_zech_ctx_t ctx) noexcept - # Prints ``mat`` to ``file``. A header is printed followed by - # the rows enclosed in brackets. - # In case of success, returns a positive value. In case of failure, - # returns a non-positive value. - void fq_zech_mat_window_init(fq_zech_mat_t window, const fq_zech_mat_t mat, slong r1, slong c1, slong r2, slong c2, const fq_zech_ctx_t ctx) noexcept - # Initializes the matrix ``window`` to be an ``r2 - r1`` by - # ``c2 - c1`` submatrix of ``mat`` whose ``(0,0)`` entry - # is the ``(r1, c1)`` entry of ``mat``. The memory for the - # elements of ``window`` is shared with ``mat``. - void fq_zech_mat_window_clear(fq_zech_mat_t window, const fq_zech_ctx_t ctx) noexcept - # Clears the matrix ``window`` and releases any memory that it - # uses. Note that the memory to the underlying matrix that - # ``window`` points to is not freed. - void fq_zech_mat_randtest(fq_zech_mat_t mat, flint_rand_t state, const fq_zech_ctx_t ctx) noexcept - # Sets the elements of ``mat`` to random elements of - # `\mathbf{F}_{q}`, given by ``ctx``. - int fq_zech_mat_randpermdiag(fq_zech_mat_t mat, flint_rand_t state, fq_zech_struct * diag, slong n, const fq_zech_ctx_t ctx) noexcept - # Sets ``mat`` to a random permutation of the diagonal matrix - # with `n` leading entries given by the vector ``diag``. It is - # assumed that the main diagonal of ``mat`` has room for at - # least `n` entries. - # Returns `0` or `1`, depending on whether the permutation is even - # or odd respectively. - void fq_zech_mat_randrank(fq_zech_mat_t mat, flint_rand_t state, slong rank, const fq_zech_ctx_t ctx) noexcept - # Sets ``mat`` to a random sparse matrix with the given rank, - # having exactly as many non-zero elements as the rank, with the - # non-zero elements being uniformly random elements of - # `\mathbf{F}_{q}`. - # The matrix can be transformed into a dense matrix with unchanged - # rank by subsequently calling :func:`fq_zech_mat_randops`. - void fq_zech_mat_randops(fq_zech_mat_t mat, slong count, flint_rand_t state, const fq_zech_ctx_t ctx) noexcept - # Randomises ``mat`` by performing elementary row or column - # operations. More precisely, at most ``count`` random additions - # or subtractions of distinct rows and columns will be performed. - # This leaves the rank (and for square matrices, determinant) - # unchanged. - void fq_zech_mat_randtril(fq_zech_mat_t mat, flint_rand_t state, int unit, const fq_zech_ctx_t ctx) noexcept - # Sets ``mat`` to a random lower triangular matrix. If - # ``unit`` is 1, it will have ones on the main diagonal, - # otherwise it will have random nonzero entries on the main - # diagonal. - void fq_zech_mat_randtriu(fq_zech_mat_t mat, flint_rand_t state, int unit, const fq_zech_ctx_t ctx) noexcept - # Sets ``mat`` to a random upper triangular matrix. If - # ``unit`` is 1, it will have ones on the main diagonal, - # otherwise it will have random nonzero entries on the main - # diagonal. - bint fq_zech_mat_equal(const fq_zech_mat_t mat1, const fq_zech_mat_t mat2, const fq_zech_ctx_t ctx) noexcept - # Returns nonzero if mat1 and mat2 have the same dimensions and elements, - # and zero otherwise. - bint fq_zech_mat_is_zero(const fq_zech_mat_t mat, const fq_zech_ctx_t ctx) noexcept - # Returns a non-zero value if all entries ``mat`` are zero, and - # otherwise returns zero. - bint fq_zech_mat_is_one(const fq_zech_mat_t mat, const fq_zech_ctx_t ctx) noexcept - # Returns a non-zero value if all entries ``mat`` are zero except the - # diagonal entries which must be one, otherwise returns zero. - bint fq_zech_mat_is_empty(const fq_zech_mat_t mat, const fq_zech_ctx_t ctx) noexcept - # Returns a non-zero value if the number of rows or the number of - # columns in ``mat`` is zero, and otherwise returns zero. - bint fq_zech_mat_is_square(const fq_zech_mat_t mat, const fq_zech_ctx_t ctx) noexcept - # Returns a non-zero value if the number of rows is equal to the - # number of columns in ``mat``, and otherwise returns zero. - void fq_zech_mat_add(fq_zech_mat_t C, const fq_zech_mat_t A, const fq_zech_mat_t B, const fq_zech_ctx_t ctx) noexcept - # Computes `C = A + B`. Dimensions must be identical. - void fq_zech_mat_sub(fq_zech_mat_t C, const fq_zech_mat_t A, const fq_zech_mat_t B, const fq_zech_ctx_t ctx) noexcept - # Computes `C = A - B`. Dimensions must be identical. - void fq_zech_mat_neg(fq_zech_mat_t A, const fq_zech_mat_t B, const fq_zech_ctx_t ctx) noexcept - # Sets `B = -A`. Dimensions must be identical. - void fq_zech_mat_mul(fq_zech_mat_t C, const fq_zech_mat_t A, const fq_zech_mat_t B, const fq_zech_ctx_t ctx) noexcept - # Sets `C = AB`. Dimensions must be compatible for matrix - # multiplication. `C` is not allowed to be aliased with `A` or - # `B`. This function automatically chooses between classical and - # KS multiplication. - void fq_zech_mat_mul_classical(fq_zech_mat_t C, const fq_zech_mat_t A, const fq_zech_mat_t B, const fq_zech_ctx_t ctx) noexcept - # Sets `C = AB`. Dimensions must be compatible for matrix multiplication. - # `C` is not allowed to be aliased with `A` or `B`. Uses classical - # matrix multiplication. - void fq_zech_mat_mul_KS(fq_zech_mat_t C, const fq_zech_mat_t A, const fq_zech_mat_t B, const fq_zech_ctx_t ctx) noexcept - # Sets `C = AB`. Dimensions must be compatible for matrix - # multiplication. `C` is not allowed to be aliased with `A` or - # `B`. Uses Kronecker substitution to perform the multiplication - # over the integers. - void fq_zech_mat_submul(fq_zech_mat_t D, const fq_zech_mat_t C, const fq_zech_mat_t A, const fq_zech_mat_t B, const fq_zech_ctx_t ctx) noexcept - # Sets `D = C + AB`. `C` and `D` may be aliased with each other but - # not with `A` or `B`. - void fq_zech_mat_mul_vec(fq_zech_struct * c, const fq_zech_mat_t A, const fq_zech_struct * b, slong blen, const fq_zech_ctx_t ctx) noexcept void fq_zech_mat_mul_vec_ptr(fq_zech_struct * const * c, const fq_zech_mat_t A, const fq_zech_struct * const * b, slong blen, const fq_zech_ctx_t ctx) noexcept - # Compute a matrix-vector product of ``A`` and ``(b, blen)`` and store the result in ``c``. - # The vector ``(b, blen)`` is either truncated or zero-extended to the number of columns of ``A``. - # The number entries written to ``c`` is always equal to the number of rows of ``A``. - void fq_zech_mat_vec_mul(fq_zech_struct * c, const fq_zech_struct * a, slong alen, const fq_zech_mat_t B, const fq_zech_ctx_t ctx) noexcept void fq_zech_mat_vec_mul_ptr(fq_zech_struct * const * c, const fq_zech_struct * const * a, slong alen, const fq_zech_mat_t B, const fq_zech_ctx_t ctx) noexcept - # Compute a vector-matrix product of ``(a, alen)`` and ``B`` and and store the result in ``c``. - # The vector ``(a, alen)`` is either truncated or zero-extended to the number of rows of ``B``. - # The number entries written to ``c`` is always equal to the number of columns of ``B``. - slong fq_zech_mat_lu(slong * P, fq_zech_mat_t A, int rank_check, const fq_zech_ctx_t ctx) noexcept - # Computes a generalised LU decomposition `LU = PA` of a given - # matrix `A`, returning the rank of `A`. - # If `A` is a nonsingular square matrix, it will be overwritten with - # a unit diagonal lower triangular matrix `L` and an upper - # triangular matrix `U` (the diagonal of `L` will not be stored - # explicitly). - # If `A` is an arbitrary matrix of rank `r`, `U` will be in row - # echelon form having `r` nonzero rows, and `L` will be lower - # triangular but truncated to `r` columns, having implicit ones on - # the `r` first entries of the main diagonal. All other entries will - # be zero. - # If a nonzero value for ``rank_check`` is passed, the function - # will abandon the output matrix in an undefined state and return 0 - # if `A` is detected to be rank-deficient. - # This function calls ``fq_zech_mat_lu_recursive``. - slong fq_zech_mat_lu_classical(slong * P, fq_zech_mat_t A, int rank_check, const fq_zech_ctx_t ctx) noexcept - # Computes a generalised LU decomposition `LU = PA` of a given - # matrix `A`, returning the rank of `A`. The behavior of this - # function is identical to that of ``fq_zech_mat_lu``. Uses Gaussian - # elimination. - slong fq_zech_mat_lu_recursive(slong * P, fq_zech_mat_t A, int rank_check, const fq_zech_ctx_t ctx) noexcept - # Computes a generalised LU decomposition `LU = PA` of a given - # matrix `A`, returning the rank of `A`. The behavior of this - # function is identical to that of ``fq_zech_mat_lu``. Uses recursive - # block decomposition, switching to classical Gaussian elimination - # for sufficiently small blocks. - slong fq_zech_mat_rref(fq_zech_mat_t A, const fq_zech_ctx_t ctx) noexcept - # Puts `A` in reduced row echelon form and returns the rank of `A`. - # The rref is computed by first obtaining an unreduced row echelon - # form via LU decomposition and then solving an additional - # triangular system. - slong fq_zech_mat_reduce_row(fq_zech_mat_t A, slong * P, slong * L, slong n, const fq_zech_ctx_t ctx) noexcept - # Reduce row n of the matrix `A`, assuming the prior rows are in Gauss - # form. However those rows may not be in order. The entry `i` of the array - # `P` is the row of `A` which has a pivot in the `i`-th column. If no such - # row exists, the entry of `P` will be `-1`. The function returns the column - # in which the `n`-th row has a pivot after reduction. This will always be - # chosen to be the first available column for a pivot from the left. This - # information is also updated in `P`. Entry `i` of the array `L` contains the - # number of possibly nonzero columns of `A` row `i`. This speeds up reduction - # in the case that `A` is chambered on the right. Otherwise the entries of - # `L` can all be set to the number of columns of `A`. We require the entries - # of `L` to be monotonic increasing. - void fq_zech_mat_solve_tril(fq_zech_mat_t X, const fq_zech_mat_t L, const fq_zech_mat_t B, int unit, const fq_zech_ctx_t ctx) noexcept - # Sets `X = L^{-1} B` where `L` is a full rank lower triangular - # square matrix. If ``unit`` = 1, `L` is assumed to have ones on - # its main diagonal, and the main diagonal will not be read. `X` - # and `B` are allowed to be the same matrix, but no other aliasing - # is allowed. Automatically chooses between the classical and - # recursive algorithms. - void fq_zech_mat_solve_tril_classical(fq_zech_mat_t X, const fq_zech_mat_t L, const fq_zech_mat_t B, int unit, const fq_zech_ctx_t ctx) noexcept - # Sets `X = L^{-1} B` where `L` is a full rank lower triangular - # square matrix. If ``unit`` = 1, `L` is assumed to have ones on - # its main diagonal, and the main diagonal will not be read. `X` - # and `B` are allowed to be the same matrix, but no other aliasing - # is allowed. Uses forward substitution. - void fq_zech_mat_solve_tril_recursive(fq_zech_mat_t X, const fq_zech_mat_t L, const fq_zech_mat_t B, int unit, const fq_zech_ctx_t ctx) noexcept - # Sets `X = L^{-1} B` where `L` is a full rank lower triangular - # square matrix. If ``unit`` = 1, `L` is assumed to have ones on - # its main diagonal, and the main diagonal will not be read. `X` - # and `B` are allowed to be the same matrix, but no other aliasing - # is allowed. - # Uses the block inversion formula - # .. math :: - # \begin{pmatrix} A & 0 \\ C & D \end{pmatrix}^{-1} - # \begin{pmatrix} X \\ Y \end{pmatrix} = - # \begin{pmatrix} A^{-1} X \\ D^{-1} ( Y - C A^{-1} X ) \end{pmatrix} - # to reduce the problem to matrix multiplication and triangular - # solving of smaller systems. - void fq_zech_mat_solve_triu(fq_zech_mat_t X, const fq_zech_mat_t U, const fq_zech_mat_t B, int unit, const fq_zech_ctx_t ctx) noexcept - # Sets `X = U^{-1} B` where `U` is a full rank upper triangular - # square matrix. If ``unit`` = 1, `U` is assumed to have ones on - # its main diagonal, and the main diagonal will not be read. `X` - # and `B` are allowed to be the same matrix, but no other aliasing - # is allowed. Automatically chooses between the classical and - # recursive algorithms. - void fq_zech_mat_solve_triu_classical(fq_zech_mat_t X, const fq_zech_mat_t U, const fq_zech_mat_t B, int unit, const fq_zech_ctx_t ctx) noexcept - # Sets `X = U^{-1} B` where `U` is a full rank upper triangular - # square matrix. If ``unit`` = 1, `U` is assumed to have ones on - # its main diagonal, and the main diagonal will not be read. `X` - # and `B` are allowed to be the same matrix, but no other aliasing - # is allowed. Uses forward substitution. - void fq_zech_mat_solve_triu_recursive(fq_zech_mat_t X, const fq_zech_mat_t U, const fq_zech_mat_t B, int unit, const fq_zech_ctx_t ctx) noexcept - # Sets `X = U^{-1} B` where `U` is a full rank upper triangular - # square matrix. If ``unit`` = 1, `U` is assumed to have ones on - # its main diagonal, and the main diagonal will not be read. `X` - # and `B` are allowed to be the same matrix, but no other aliasing - # is allowed. - # Uses the block inversion formula - # .. math :: - # \begin{pmatrix} A & B \\ 0 & D \end{pmatrix}^{-1} - # \begin{pmatrix} X \\ Y \end{pmatrix} = - # \begin{pmatrix} A^{-1} (X - B D^{-1} Y) \\ D^{-1} Y \end{pmatrix} - # to reduce the problem to matrix multiplication and triangular - # solving of smaller systems. - int fq_zech_mat_solve(fq_zech_mat_t X, const fq_zech_mat_t A, const fq_zech_mat_t B, const fq_zech_ctx_t ctx) noexcept - # Solves the matrix-matrix equation `AX = B`. - # Returns `1` if `A` has full rank; otherwise returns `0` and sets the - # elements of `X` to undefined values. - # The matrix `A` must be square. - int fq_zech_mat_can_solve(fq_zech_mat_t X, const fq_zech_mat_t A, const fq_zech_mat_t B, const fq_zech_ctx_t ctx) noexcept - # Solves the matrix-matrix equation `AX = B` over `Fq`. - # Returns `1` if a solution exists; otherwise returns `0` and sets the - # elements of `X` to zero. If more than one solution exists, one of the - # valid solutions is given. - # There are no restrictions on the shape of `A` and it may be singular. - void fq_zech_mat_similarity(fq_zech_mat_t M, slong r, fq_zech_t d, const fq_zech_ctx_t ctx) noexcept - # Applies a similarity transform to the `n\times n` matrix `M` in-place. - # If `P` is the `n\times n` identity matrix the zero entries of whose row - # `r` (`0`-indexed) have been replaced by `d`, this transform is equivalent - # to `M = P^{-1}MP`. - # Similarity transforms preserve the determinant, characteristic polynomial - # and minimal polynomial. - # The value `d` is required to be reduced modulo the modulus of the entries - # in the matrix. - void fq_zech_mat_charpoly_danilevsky(fq_zech_poly_t p, const fq_zech_mat_t M, const fq_zech_ctx_t ctx) noexcept - # Compute the characteristic polynomial `p` of the matrix `M`. The matrix - # is assumed to be square. - void fq_zech_mat_charpoly(fq_zech_poly_t p, const fq_zech_mat_t M, const fq_zech_ctx_t ctx) noexcept - # Compute the characteristic polynomial `p` of the matrix `M`. The matrix - # is required to be square, otherwise an exception is raised. - void fq_zech_mat_minpoly(fq_zech_poly_t p, const fq_zech_mat_t M, const fq_zech_ctx_t ctx) noexcept - # Compute the minimal polynomial `p` of the matrix `M`. The matrix - # is required to be square, otherwise an exception is raised. diff --git a/src/sage/libs/flint/fq_zech_poly.pxd b/src/sage/libs/flint/fq_zech_poly.pxd index 05d4ed18768..21cefa1c67f 100644 --- a/src/sage/libs/flint/fq_zech_poly.pxd +++ b/src/sage/libs/flint/fq_zech_poly.pxd @@ -2,7 +2,9 @@ # distutils: depends = flint/fq_zech_poly.h ################################################################################ -# This file is auto-generated. Do not modify by hand +# This file is auto-generated by the script +# SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py. +# Do not modify by hand! Fix and rerun the script instead. ################################################################################ from libc.stdio cimport FILE @@ -11,1026 +13,184 @@ from sage.libs.mpfr.types cimport * from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void fq_zech_poly_init(fq_zech_poly_t poly, const fq_zech_ctx_t ctx) noexcept - # Initialises ``poly`` for use, with context ctx, and setting its - # length to zero. A corresponding call to :func:`fq_zech_poly_clear` - # must be made after finishing with the ``fq_zech_poly_t`` to free the - # memory used by the polynomial. - void fq_zech_poly_init2(fq_zech_poly_t poly, slong alloc, const fq_zech_ctx_t ctx) noexcept - # Initialises ``poly`` with space for at least ``alloc`` - # coefficients and sets the length to zero. The allocated - # coefficients are all set to zero. A corresponding call to - # :func:`fq_zech_poly_clear` must be made after finishing with the - # ``fq_zech_poly_t`` to free the memory used by the polynomial. - void fq_zech_poly_realloc(fq_zech_poly_t poly, slong alloc, const fq_zech_ctx_t ctx) noexcept - # Reallocates the given polynomial to have space for ``alloc`` - # coefficients. If ``alloc`` is zero the polynomial is cleared - # and then reinitialised. If the current length is greater than - # ``alloc`` the polynomial is first truncated to length - # ``alloc``. - void fq_zech_poly_fit_length(fq_zech_poly_t poly, slong len, const fq_zech_ctx_t ctx) noexcept - # If ``len`` is greater than the number of coefficients currently - # allocated, then the polynomial is reallocated to have space for at - # least ``len`` coefficients. No data is lost when calling this - # function. - # The function efficiently deals with the case where - # ``fit_length`` is called many times in small increments by at - # least doubling the number of allocated coefficients when length is - # larger than the number of coefficients currently allocated. - void _fq_zech_poly_set_length(fq_zech_poly_t poly, slong newlen, const fq_zech_ctx_t ctx) noexcept - # Sets the coefficients of ``poly`` beyond ``len`` to zero and - # sets the length of ``poly`` to ``len``. - void fq_zech_poly_clear(fq_zech_poly_t poly, const fq_zech_ctx_t ctx) noexcept - # Clears the given polynomial, releasing any memory used. It must - # be reinitialised in order to be used again. - void _fq_zech_poly_normalise(fq_zech_poly_t poly, const fq_zech_ctx_t ctx) noexcept - # Sets the length of ``poly`` so that the top coefficient is - # non-zero. If all coefficients are zero, the length is set to - # zero. This function is mainly used internally, as all functions - # guarantee normalisation. - - void _fq_zech_poly_normalise2(const fq_zech_struct *poly, slong *length, const fq_zech_ctx_t ctx) noexcept - # Sets the length ``length`` of ``(poly,length)`` so that the - # top coefficient is non-zero. If all coefficients are zero, the - # length is set to zero. This function is mainly used internally, as - # all functions guarantee normalisation. - + void _fq_zech_poly_normalise2(const fq_zech_struct * poly, slong * length, const fq_zech_ctx_t ctx) noexcept void fq_zech_poly_truncate(fq_zech_poly_t poly, slong newlen, const fq_zech_ctx_t ctx) noexcept - # Truncates the polynomial to length at most `n`. - void fq_zech_poly_set_trunc(fq_zech_poly_t poly1, fq_zech_poly_t poly2, slong newlen, const fq_zech_ctx_t ctx) noexcept - # Sets ``poly1`` to ``poly2`` truncated to length `n`. - - void _fq_zech_poly_reverse(fq_zech_struct* output, const fq_zech_struct* input, slong len, slong m, const fq_zech_ctx_t ctx) noexcept - # Sets ``output`` to the reverse of ``input``, which is of - # length ``len``, but thinking of it as a polynomial of - # length ``m``, notionally zero-padded if necessary. The - # length ``m`` must be non-negative, but there are no other - # restrictions. The polynomial ``output`` must have space for - # ``m`` coefficients. - + void _fq_zech_poly_reverse(fq_zech_struct * output, const fq_zech_struct * input, slong len, slong m, const fq_zech_ctx_t ctx) noexcept void fq_zech_poly_reverse(fq_zech_poly_t output, const fq_zech_poly_t input, slong m, const fq_zech_ctx_t ctx) noexcept - # Sets ``output`` to the reverse of ``input``, thinking of it - # as a polynomial of length ``m``, notionally zero-padded if - # necessary). The length ``m`` must be non-negative, but there - # are no other restrictions. The output polynomial will be set to - # length ``m`` and then normalised. - slong fq_zech_poly_degree(const fq_zech_poly_t poly, const fq_zech_ctx_t ctx) noexcept - # Returns the degree of the polynomial ``poly``. - slong fq_zech_poly_length(const fq_zech_poly_t poly, const fq_zech_ctx_t ctx) noexcept - # Returns the length of the polynomial ``poly``. - fq_zech_struct * fq_zech_poly_lead(const fq_zech_poly_t poly, const fq_zech_ctx_t ctx) noexcept - # Returns a pointer to the leading coefficient of ``poly``, or - # ``NULL`` if ``poly`` is the zero polynomial. - void fq_zech_poly_randtest(fq_zech_poly_t f, flint_rand_t state, slong len, const fq_zech_ctx_t ctx) noexcept - # Sets `f` to a random polynomial of length at most ``len`` - # with entries in the field described by ``ctx``. - void fq_zech_poly_randtest_not_zero(fq_zech_poly_t f, flint_rand_t state, slong len, const fq_zech_ctx_t ctx) noexcept - # Same as ``fq_zech_poly_randtest`` but guarantees that the polynomial - # is not zero. - void fq_zech_poly_randtest_monic(fq_zech_poly_t f, flint_rand_t state, slong len, const fq_zech_ctx_t ctx) noexcept - # Sets `f` to a random monic polynomial of length ``len`` with - # entries in the field described by ``ctx``. - void fq_zech_poly_randtest_irreducible(fq_zech_poly_t f, flint_rand_t state, slong len, const fq_zech_ctx_t ctx) noexcept - # Sets `f` to a random monic, irreducible polynomial of length - # ``len`` with entries in the field described by ``ctx``. - - void _fq_zech_poly_set(fq_zech_struct *rop, const fq_zech_struct *op, slong len, const fq_zech_ctx_t ctx) noexcept - # Sets ``(rop, len``) to ``(op, len)``. - + void _fq_zech_poly_set(fq_zech_struct * rop, const fq_zech_struct * op, slong len, const fq_zech_ctx_t ctx) noexcept void fq_zech_poly_set(fq_zech_poly_t poly1, const fq_zech_poly_t poly2, const fq_zech_ctx_t ctx) noexcept - # Sets the polynomial ``poly1`` to the polynomial ``poly2``. - void fq_zech_poly_set_fq_zech(fq_zech_poly_t poly, const fq_zech_t c, const fq_zech_ctx_t ctx) noexcept - # Sets the polynomial ``poly`` to ``c``. - void fq_zech_poly_set_fmpz_mod_poly(fq_zech_poly_t rop, const fmpz_mod_poly_t op, const fq_zech_ctx_t ctx) noexcept - # Sets the polynomial ``rop`` to the polynomial ``op`` - void fq_zech_poly_set_nmod_poly(fq_zech_poly_t rop, const nmod_poly_t op, const fq_zech_ctx_t ctx) noexcept - # Sets the polynomial ``rop`` to the polynomial ``op`` - void fq_zech_poly_swap(fq_zech_poly_t op1, fq_zech_poly_t op2, const fq_zech_ctx_t ctx) noexcept - # Swaps the two polynomials ``op1`` and ``op2``. - - void _fq_zech_poly_zero(fq_zech_struct *rop, slong len, const fq_zech_ctx_t ctx) noexcept - # Sets ``(rop, len)`` to the zero polynomial. - + void _fq_zech_poly_zero(fq_zech_struct * rop, slong len, const fq_zech_ctx_t ctx) noexcept void fq_zech_poly_zero(fq_zech_poly_t poly, const fq_zech_ctx_t ctx) noexcept - # Sets ``poly`` to the zero polynomial. - void fq_zech_poly_one(fq_zech_poly_t poly, const fq_zech_ctx_t ctx) noexcept - # Sets ``poly`` to the constant polynomial `1`. - void fq_zech_poly_gen(fq_zech_poly_t poly, const fq_zech_ctx_t ctx) noexcept - # Sets ``poly`` to the polynomial `x`. - void fq_zech_poly_make_monic(fq_zech_poly_t rop, const fq_zech_poly_t op, const fq_zech_ctx_t ctx) noexcept - # Sets ``rop`` to ``op``, normed to have leading coefficient 1. - - void _fq_zech_poly_make_monic(fq_zech_struct *rop, const fq_zech_struct *op, slong length, const fq_zech_ctx_t ctx) noexcept - # Sets ``rop`` to ``(op,length)``, normed to have leading coefficient 1. - # Assumes that ``rop`` has enough space for the polynomial, assumes that - # ``op`` is not zero (and thus has an invertible leading coefficient). - + void _fq_zech_poly_make_monic(fq_zech_struct * rop, const fq_zech_struct * op, slong length, const fq_zech_ctx_t ctx) noexcept void fq_zech_poly_get_coeff(fq_zech_t x, const fq_zech_poly_t poly, slong n, const fq_zech_ctx_t ctx) noexcept - # Sets `x` to the coefficient of `X^n` in ``poly``. - void fq_zech_poly_set_coeff(fq_zech_poly_t poly, slong n, const fq_zech_t x, const fq_zech_ctx_t ctx) noexcept - # Sets the coefficient of `X^n` in ``poly`` to `x`. - void fq_zech_poly_set_coeff_fmpz(fq_zech_poly_t poly, slong n, const fmpz_t x, const fq_zech_ctx_t ctx) noexcept - # Sets the coefficient of `X^n` in the polynomial to `x`, - # assuming `n \geq 0`. - bint fq_zech_poly_equal(const fq_zech_poly_t poly1, const fq_zech_poly_t poly2, const fq_zech_ctx_t ctx) noexcept - # Returns nonzero if the two polynomials ``poly1`` and ``poly2`` - # are equal, otherwise return zero. - bint fq_zech_poly_equal_trunc(const fq_zech_poly_t poly1, const fq_zech_poly_t poly2, slong n, const fq_zech_ctx_t ctx) noexcept - # Notionally truncate ``poly1`` and ``poly2`` to length `n` and - # return nonzero if they are equal, otherwise return zero. - bint fq_zech_poly_is_zero(const fq_zech_poly_t poly, const fq_zech_ctx_t ctx) noexcept - # Returns whether the polynomial ``poly`` is the zero polynomial. - bint fq_zech_poly_is_one(const fq_zech_poly_t op, const fq_zech_ctx_t ctx) noexcept - # Returns whether the polynomial ``poly`` is equal - # to the constant polynomial `1`. - bint fq_zech_poly_is_gen(const fq_zech_poly_t op, const fq_zech_ctx_t ctx) noexcept - # Returns whether the polynomial ``poly`` is equal - # to the polynomial `x`. - bint fq_zech_poly_is_unit(const fq_zech_poly_t op, const fq_zech_ctx_t ctx) noexcept - # Returns whether the polynomial ``poly`` is a unit in the polynomial - # ring `\mathbf{F}_q[X]`, i.e. if it has degree `0` and is non-zero. - bint fq_zech_poly_equal_fq_zech(const fq_zech_poly_t poly, const fq_zech_t c, const fq_zech_ctx_t ctx) noexcept - # Returns whether the polynomial ``poly`` is equal the (constant) - # `\mathbf{F}_q` element ``c`` - - void _fq_zech_poly_add(fq_zech_struct *res, const fq_zech_struct *poly1, slong len1, const fq_zech_struct *poly2, slong len2, const fq_zech_ctx_t ctx) noexcept - # Sets ``res`` to the sum of ``(poly1,len1)`` and ``(poly2,len2)``. - + void _fq_zech_poly_add(fq_zech_struct * res, const fq_zech_struct * poly1, slong len1, const fq_zech_struct * poly2, slong len2, const fq_zech_ctx_t ctx) noexcept void fq_zech_poly_add(fq_zech_poly_t res, const fq_zech_poly_t poly1, const fq_zech_poly_t poly2, const fq_zech_ctx_t ctx) noexcept - # Sets ``res`` to the sum of ``poly1`` and ``poly2``. - void fq_zech_poly_add_si(fq_zech_poly_t res, const fq_zech_poly_t poly1, slong c, const fq_zech_ctx_t ctx) noexcept - # Sets ``res`` to the sum of ``poly1`` and ``c``. - void fq_zech_poly_add_series(fq_zech_poly_t res, const fq_zech_poly_t poly1, const fq_zech_poly_t poly2, slong n, const fq_zech_ctx_t ctx) noexcept - # Notionally truncate ``poly1`` and ``poly2`` to length ``n`` and set - # ``res`` to the sum. - - void _fq_zech_poly_sub(fq_zech_struct *res, const fq_zech_struct *poly1, slong len1, const fq_zech_struct *poly2, slong len2, const fq_zech_ctx_t ctx) noexcept - # Sets ``res`` to the difference of ``(poly1,len1)`` and - # ``(poly2,len2)``. - + void _fq_zech_poly_sub(fq_zech_struct * res, const fq_zech_struct * poly1, slong len1, const fq_zech_struct * poly2, slong len2, const fq_zech_ctx_t ctx) noexcept void fq_zech_poly_sub(fq_zech_poly_t res, const fq_zech_poly_t poly1, const fq_zech_poly_t poly2, const fq_zech_ctx_t ctx) noexcept - # Sets ``res`` to the difference of ``poly1`` and ``poly2``. - void fq_zech_poly_sub_series(fq_zech_poly_t res, const fq_zech_poly_t poly1, const fq_zech_poly_t poly2, slong n, const fq_zech_ctx_t ctx) noexcept - # Notionally truncate ``poly1`` and ``poly2`` to length ``n`` and set - # ``res`` to the difference. - - void _fq_zech_poly_neg(fq_zech_struct *rop, const fq_zech_struct *op, slong len, const fq_zech_ctx_t ctx) noexcept - # Sets ``rop`` to the additive inverse of ``(op,len)``. - + void _fq_zech_poly_neg(fq_zech_struct * rop, const fq_zech_struct * op, slong len, const fq_zech_ctx_t ctx) noexcept void fq_zech_poly_neg(fq_zech_poly_t res, const fq_zech_poly_t poly, const fq_zech_ctx_t ctx) noexcept - # Sets ``res`` to the additive inverse of ``poly``. - - void _fq_zech_poly_scalar_mul_fq_zech(fq_zech_struct *rop, const fq_zech_struct *op, slong len, const fq_zech_t x, const fq_zech_ctx_t ctx) noexcept - # Sets ``(rop,len)`` to the product of ``(op,len)`` by the - # scalar ``x``, in the context defined by ``ctx``. - + void _fq_zech_poly_scalar_mul_fq_zech(fq_zech_struct * rop, const fq_zech_struct * op, slong len, const fq_zech_t x, const fq_zech_ctx_t ctx) noexcept void fq_zech_poly_scalar_mul_fq_zech(fq_zech_poly_t rop, const fq_zech_poly_t op, const fq_zech_t x, const fq_zech_ctx_t ctx) noexcept - # Sets ``rop`` to the product of ``op`` by the scalar ``x``, in the context - # defined by ``ctx``. - - void _fq_zech_poly_scalar_addmul_fq_zech(fq_zech_struct *rop, const fq_zech_struct *op, slong len, const fq_zech_t x, const fq_zech_ctx_t ctx) noexcept - # Adds to ``(rop,len)`` the product of ``(op,len)`` by the - # scalar ``x``, in the context defined by ``ctx``. - # In particular, assumes the same length for ``op`` and - # ``rop``. - + void _fq_zech_poly_scalar_addmul_fq_zech(fq_zech_struct * rop, const fq_zech_struct * op, slong len, const fq_zech_t x, const fq_zech_ctx_t ctx) noexcept void fq_zech_poly_scalar_addmul_fq_zech(fq_zech_poly_t rop, const fq_zech_poly_t op, const fq_zech_t x, const fq_zech_ctx_t ctx) noexcept - # Adds to ``rop`` the product of ``op`` by the - # scalar ``x``, in the context defined by ``ctx``. - - void _fq_zech_poly_scalar_submul_fq_zech(fq_zech_struct *rop, const fq_zech_struct *op, slong len, const fq_zech_t x, const fq_zech_ctx_t ctx) noexcept - # Subtracts from ``(rop,len)`` the product of ``(op,len)`` by the - # scalar ``x``, in the context defined by ``ctx``. - # In particular, assumes the same length for ``op`` and - # ``rop``. - + void _fq_zech_poly_scalar_submul_fq_zech(fq_zech_struct * rop, const fq_zech_struct * op, slong len, const fq_zech_t x, const fq_zech_ctx_t ctx) noexcept void fq_zech_poly_scalar_submul_fq_zech(fq_zech_poly_t rop, const fq_zech_poly_t op, const fq_zech_t x, const fq_zech_ctx_t ctx) noexcept - # Subtracts from ``rop`` the product of ``op`` by the - # scalar ``x``, in the context defined by ``ctx``. - - void _fq_zech_poly_scalar_div_fq_zech(fq_zech_struct *rop, const fq_zech_struct *op, slong len, const fq_zech_t x, const fq_zech_ctx_t ctx) noexcept - # Sets ``(rop,len)`` to the quotient of ``(op,len)`` by the - # scalar ``x``, in the context defined by ``ctx``. An exception is raised - # if ``x`` is zero. - + void _fq_zech_poly_scalar_div_fq_zech(fq_zech_struct * rop, const fq_zech_struct * op, slong len, const fq_zech_t x, const fq_zech_ctx_t ctx) noexcept void fq_zech_poly_scalar_div_fq_zech(fq_zech_poly_t rop, const fq_zech_poly_t op, const fq_zech_t x, const fq_zech_ctx_t ctx) noexcept - # Sets ``rop`` to the quotient of ``op`` by the scalar ``x``, in the context - # defined by ``ctx``. An exception is raised if ``x`` is zero. - - void _fq_zech_poly_mul_classical(fq_zech_struct *rop, const fq_zech_struct *op1, slong len1, const fq_zech_struct *op2, slong len2, const fq_zech_ctx_t ctx) noexcept - # Sets ``(rop, len1 + len2 - 1)`` to the product of ``(op1, len1)`` - # and ``(op2, len2)``, assuming that ``len1`` is at least ``len2`` - # and neither is zero. - # Permits zero padding. Does not support aliasing of ``rop`` - # with either ``op1`` or ``op2``. - + void _fq_zech_poly_mul_classical(fq_zech_struct * rop, const fq_zech_struct * op1, slong len1, const fq_zech_struct * op2, slong len2, const fq_zech_ctx_t ctx) noexcept void fq_zech_poly_mul_classical(fq_zech_poly_t rop, const fq_zech_poly_t op1, const fq_zech_poly_t op2, const fq_zech_ctx_t ctx) noexcept - # Sets ``rop`` to the product of ``op1`` and ``op2`` - # using classical polynomial multiplication. - - void _fq_zech_poly_mul_reorder(fq_zech_struct *rop, const fq_zech_struct *op1, slong len1, const fq_zech_struct *op2, slong len2, const fq_zech_ctx_t ctx) noexcept - # Sets ``(rop, len1 + len2 - 1)`` to the product of ``(op1, len1)`` - # and ``(op2, len2)``, assuming that ``len1`` and ``len2`` are - # non-zero. - # Permits zero padding. Supports aliasing. - + void _fq_zech_poly_mul_reorder(fq_zech_struct * rop, const fq_zech_struct * op1, slong len1, const fq_zech_struct * op2, slong len2, const fq_zech_ctx_t ctx) noexcept void fq_zech_poly_mul_reorder(fq_zech_poly_t rop, const fq_zech_poly_t op1, const fq_zech_poly_t op2, const fq_zech_ctx_t ctx) noexcept - # Sets ``rop`` to the product of ``op1`` and ``op2``, - # reordering the two indeterminates `X` and `Y` when viewing - # the polynomials as elements of `\mathbf{F}_p[X,Y]`. - # Suppose `\mathbf{F}_q = \mathbf{F}_p[X]/ (f(X))` and recall - # that elements of `\mathbf{F}_q` are internally represented - # by elements of type ``fmpz_poly``. For small degree extensions - # but polynomials in `\mathbf{F}_q[Y]` of large degree `n`, we - # change the representation to - # .. math :: - # \begin{split} - # g(Y) & = \sum_{i=0}^{n} a_i(X) Y^i \\ - # & = \sum_{j=0}^{d} \sum_{i=0}^{n} \text{Coeff}(a_i(X), j) Y^i. - # \end{split} - # This allows us to use a poor algorithm (such as classical multiplication) - # in the `X`-direction and leverage the existing fast integer - # multiplication routines in the `Y`-direction where the polynomial - # degree `n` is large. - - void _fq_zech_poly_mul_KS(fq_zech_struct *rop, const fq_zech_struct *op1, slong len1, const fq_zech_struct *op2, slong len2, const fq_zech_ctx_t ctx) noexcept - # Sets ``(rop, len1 + len2 - 1)`` to the product of ``(op1, len1)`` - # and ``(op2, len2)``. - # Permits zero padding and places no assumptions on the - # lengths ``len1`` and ``len2``. Supports aliasing. - + void _fq_zech_poly_mul_KS(fq_zech_struct * rop, const fq_zech_struct * op1, slong len1, const fq_zech_struct * op2, slong len2, const fq_zech_ctx_t ctx) noexcept void fq_zech_poly_mul_KS(fq_zech_poly_t rop, const fq_zech_poly_t op1, const fq_zech_poly_t op2, const fq_zech_ctx_t ctx) noexcept - # Sets ``rop`` to the product of ``op1`` and ``op2`` - # using Kronecker substitution, that is, by encoding each - # coefficient in `\mathbf{F}_{q}` as an integer and reducing - # this problem to multiplying two polynomials over the integers. - - void _fq_zech_poly_mul(fq_zech_struct *rop, const fq_zech_struct *op1, slong len1, const fq_zech_struct *op2, slong len2, const fq_zech_ctx_t ctx) noexcept - # Sets ``(rop, len1 + len2 - 1)`` to the product of ``(op1, len1)`` - # and ``(op2, len2)``, choosing an appropriate algorithm. - # Permits zero padding. Does not support aliasing. - + void _fq_zech_poly_mul(fq_zech_struct * rop, const fq_zech_struct * op1, slong len1, const fq_zech_struct * op2, slong len2, const fq_zech_ctx_t ctx) noexcept void fq_zech_poly_mul(fq_zech_poly_t rop, const fq_zech_poly_t op1, const fq_zech_poly_t op2, const fq_zech_ctx_t ctx) noexcept - # Sets ``rop`` to the product of ``op1`` and ``op2``, - # choosing an appropriate algorithm. - - void _fq_zech_poly_mullow_classical(fq_zech_struct *rop, const fq_zech_struct *op1, slong len1, const fq_zech_struct *op2, slong len2, slong n, const fq_zech_ctx_t ctx) noexcept - # Sets ``(rop, n)`` to the first `n` coefficients of - # ``(op1, len1)`` multiplied by ``(op2, len2)``. - # Assumes ``0 < n <= len1 + len2 - 1``. Assumes neither - # ``len1`` nor ``len2`` is zero. - + void _fq_zech_poly_mullow_classical(fq_zech_struct * rop, const fq_zech_struct * op1, slong len1, const fq_zech_struct * op2, slong len2, slong n, const fq_zech_ctx_t ctx) noexcept void fq_zech_poly_mullow_classical(fq_zech_poly_t rop, const fq_zech_poly_t op1, const fq_zech_poly_t op2, slong n, const fq_zech_ctx_t ctx) noexcept - # Sets ``rop`` to the product of ``op1`` and ``op2``, - # computed using the classical or schoolbook method. - - void _fq_zech_poly_mullow_KS(fq_zech_struct *rop, const fq_zech_struct *op1, slong len1, const fq_zech_struct *op2, slong len2, slong n, const fq_zech_ctx_t ctx) noexcept - # Sets ``(rop, n)`` to the lowest `n` coefficients of the product of - # ``(op1, len1)`` and ``(op2, len2)``. - # Assumes that ``len1`` and ``len2`` are positive, but does allow - # for the polynomials to be zero-padded. The polynomials may be zero, - # too. Assumes `n` is positive. Supports aliasing between ``rop``, - # ``op1`` and ``op2``. - + void _fq_zech_poly_mullow_KS(fq_zech_struct * rop, const fq_zech_struct * op1, slong len1, const fq_zech_struct * op2, slong len2, slong n, const fq_zech_ctx_t ctx) noexcept void fq_zech_poly_mullow_KS(fq_zech_poly_t rop, const fq_zech_poly_t op1, const fq_zech_poly_t op2, slong n, const fq_zech_ctx_t ctx) noexcept - # Sets ``rop`` to the product of ``op1`` and ``op2``. - - void _fq_zech_poly_mullow(fq_zech_struct *rop, const fq_zech_struct *op1, slong len1, const fq_zech_struct *op2, slong len2, slong n, const fq_zech_ctx_t ctx) noexcept - # Sets ``(rop, n)`` to the lowest `n` coefficients of the product of - # ``(op1, len1)`` and ``(op2, len2)``. - # Assumes ``0 < n <= len1 + len2 - 1``. Allows for zero-padding in - # the inputs. Does not support aliasing between the inputs and the output. - + void _fq_zech_poly_mullow(fq_zech_struct * rop, const fq_zech_struct * op1, slong len1, const fq_zech_struct * op2, slong len2, slong n, const fq_zech_ctx_t ctx) noexcept void fq_zech_poly_mullow(fq_zech_poly_t rop, const fq_zech_poly_t op1, const fq_zech_poly_t op2, slong n, const fq_zech_ctx_t ctx) noexcept - # Sets ``rop`` to the lowest `n` coefficients of the product of - # ``op1`` and ``op2``. - - void _fq_zech_poly_mulhigh_classical(fq_zech_struct *res, const fq_zech_struct *poly1, slong len1, const fq_zech_struct *poly2, slong len2, slong start, const fq_zech_ctx_t ctx) noexcept - # Computes the product of ``(poly1, len1)`` and ``(poly2, len2)`` - # and writes the coefficients from ``start`` onwards into the high - # coefficients of ``res``, the remaining coefficients being arbitrary - # but reduced. Assumes that ``len1 >= len2 > 0``. Aliasing of inputs - # and output is not permitted. Algorithm is classical multiplication. - + void _fq_zech_poly_mulhigh_classical(fq_zech_struct * res, const fq_zech_struct * poly1, slong len1, const fq_zech_struct * poly2, slong len2, slong start, const fq_zech_ctx_t ctx) noexcept void fq_zech_poly_mulhigh_classical(fq_zech_poly_t res, const fq_zech_poly_t poly1, const fq_zech_poly_t poly2, slong start, const fq_zech_ctx_t ctx) noexcept - # Computes the product of ``poly1`` and ``poly2`` and writes the - # coefficients from ``start`` onwards into the high coefficients of - # ``res``, the remaining coefficients being arbitrary but reduced. - # Algorithm is classical multiplication. - - void _fq_zech_poly_mulhigh(fq_zech_struct *res, const fq_zech_struct *poly1, slong len1, const fq_zech_struct *poly2, slong len2, slong start, fq_zech_ctx_t ctx) noexcept - # Computes the product of ``(poly1, len1)`` and ``(poly2, len2)`` - # and writes the coefficients from ``start`` onwards into the high - # coefficients of ``res``, the remaining coefficients being arbitrary - # but reduced. Assumes that ``len1 >= len2 > 0``. Aliasing of inputs - # and output is not permitted. - + void _fq_zech_poly_mulhigh(fq_zech_struct * res, const fq_zech_struct * poly1, slong len1, const fq_zech_struct * poly2, slong len2, slong start, fq_zech_ctx_t ctx) noexcept void fq_zech_poly_mulhigh(fq_zech_poly_t res, const fq_zech_poly_t poly1, const fq_zech_poly_t poly2, slong start, const fq_zech_ctx_t ctx) noexcept - # Computes the product of ``poly1`` and ``poly2`` and writes the - # coefficients from ``start`` onwards into the high coefficients of - # ``res``, the remaining coefficients being arbitrary but reduced. - - void _fq_zech_poly_mulmod(fq_zech_struct* res, const fq_zech_struct* poly1, slong len1, const fq_zech_struct* poly2, slong len2, const fq_zech_struct* f, slong lenf, const fq_zech_ctx_t ctx) noexcept - # Sets ``res`` to the remainder of the product of ``poly1`` - # and ``poly2`` upon polynomial division by ``f``. - # It is required that ``len1 + len2 - lenf > 0``, which is - # equivalent to requiring that the result will actually be - # reduced. Otherwise, simply use ``_fq_zech_poly_mul`` instead. - # Aliasing of ``f`` and ``res`` is not permitted. - + void _fq_zech_poly_mulmod(fq_zech_struct * res, const fq_zech_struct * poly1, slong len1, const fq_zech_struct * poly2, slong len2, const fq_zech_struct * f, slong lenf, const fq_zech_ctx_t ctx) noexcept void fq_zech_poly_mulmod(fq_zech_poly_t res, const fq_zech_poly_t poly1, const fq_zech_poly_t poly2, const fq_zech_poly_t f, const fq_zech_ctx_t ctx) noexcept - # Sets ``res`` to the remainder of the product of ``poly1`` - # and ``poly2`` upon polynomial division by ``f``. - - void _fq_zech_poly_mulmod_preinv(fq_zech_struct* res, const fq_zech_struct* poly1, slong len1, const fq_zech_struct* poly2, slong len2, const fq_zech_struct* f, slong lenf, const fq_zech_struct* finv, slong lenfinv, const fq_zech_ctx_t ctx) noexcept - # Sets ``res`` to the remainder of the product of ``poly1`` - # and ``poly2`` upon polynomial division by ``f``. - # It is required that ``finv`` is the inverse of the reverse of - # ``f`` mod ``x^lenf``. - # Aliasing of ``res`` with any of the inputs is not permitted. - + void _fq_zech_poly_mulmod_preinv(fq_zech_struct * res, const fq_zech_struct * poly1, slong len1, const fq_zech_struct * poly2, slong len2, const fq_zech_struct * f, slong lenf, const fq_zech_struct * finv, slong lenfinv, const fq_zech_ctx_t ctx) noexcept void fq_zech_poly_mulmod_preinv(fq_zech_poly_t res, const fq_zech_poly_t poly1, const fq_zech_poly_t poly2, const fq_zech_poly_t f, const fq_zech_poly_t finv, const fq_zech_ctx_t ctx) noexcept - # Sets ``res`` to the remainder of the product of ``poly1`` - # and ``poly2`` upon polynomial division by ``f``. ``finv`` - # is the inverse of the reverse of ``f``. - - void _fq_zech_poly_sqr_classical(fq_zech_struct *rop, const fq_zech_struct *op, slong len, const fq_zech_ctx_t ctx) noexcept - # Sets ``(rop, 2*len - 1)`` to the square of ``(op, len)``, - # assuming that ``(op,len)`` is not zero and using classical - # polynomial multiplication. - # Permits zero padding. Does not support aliasing of ``rop`` - # with either ``op1`` or ``op2``. - + void _fq_zech_poly_sqr_classical(fq_zech_struct * rop, const fq_zech_struct * op, slong len, const fq_zech_ctx_t ctx) noexcept void fq_zech_poly_sqr_classical(fq_zech_poly_t rop, const fq_zech_poly_t op, const fq_zech_ctx_t ctx) noexcept - # Sets ``rop`` to the square of ``op`` using classical - # polynomial multiplication. - - void _fq_zech_poly_sqr_KS(fq_zech_struct *rop, const fq_zech_struct *op, slong len, const fq_zech_ctx_t ctx) noexcept - # Sets ``(rop, 2*len - 1)`` to the square of ``(op, len)``. - # Permits zero padding and places no assumptions on the - # lengths ``len1`` and ``len2``. Supports aliasing. - + void _fq_zech_poly_sqr_KS(fq_zech_struct * rop, const fq_zech_struct * op, slong len, const fq_zech_ctx_t ctx) noexcept void fq_zech_poly_sqr_KS(fq_zech_poly_t rop, const fq_zech_poly_t op, const fq_zech_ctx_t ctx) noexcept - # Sets ``rop`` to the square ``op`` using Kronecker substitution, - # that is, by encoding each coefficient in `\mathbf{F}_{q}` as an integer - # and reducing this problem to multiplying two polynomials over the integers. - - void _fq_zech_poly_sqr(fq_zech_struct *rop, const fq_zech_struct *op, slong len, const fq_zech_ctx_t ctx) noexcept - # Sets ``(rop, 2* len - 1)`` to the square of ``(op, len)``, - # choosing an appropriate algorithm. - # Permits zero padding. Does not support aliasing. - + void _fq_zech_poly_sqr(fq_zech_struct * rop, const fq_zech_struct * op, slong len, const fq_zech_ctx_t ctx) noexcept void fq_zech_poly_sqr(fq_zech_poly_t rop, const fq_zech_poly_t op, const fq_zech_ctx_t ctx) noexcept - # Sets ``rop`` to the square of ``op``, - # choosing an appropriate algorithm. - - void _fq_zech_poly_pow(fq_zech_struct *rop, const fq_zech_struct *op, slong len, ulong e, const fq_zech_ctx_t ctx) noexcept - # Sets ``rop = op^e``, assuming that ``e, len > 0`` and that - # ``res`` has space for ``e*(len - 1) + 1`` coefficients. Does - # not support aliasing. - + void _fq_zech_poly_pow(fq_zech_struct * rop, const fq_zech_struct * op, slong len, ulong e, const fq_zech_ctx_t ctx) noexcept void fq_zech_poly_pow(fq_zech_poly_t rop, const fq_zech_poly_t op, ulong e, const fq_zech_ctx_t ctx) noexcept - # Computes ``rop = op^e``. If `e` is zero, returns one, - # so that in particular ``0^0 = 1``. - - void _fq_zech_poly_powmod_ui_binexp(fq_zech_struct* res, const fq_zech_struct* poly, ulong e, const fq_zech_struct* f, slong lenf, const fq_zech_ctx_t ctx) noexcept - # Sets ``res`` to ``poly`` raised to the power ``e`` modulo - # ``f``, using binary exponentiation. We require ``e > 0``. - # We require ``lenf > 1``. It is assumed that ``poly`` is - # already reduced modulo ``f`` and zero-padded as necessary to - # have length exactly ``lenf - 1``. The output ``res`` must - # have room for ``lenf - 1`` coefficients. - + void _fq_zech_poly_powmod_ui_binexp(fq_zech_struct * res, const fq_zech_struct * poly, ulong e, const fq_zech_struct * f, slong lenf, const fq_zech_ctx_t ctx) noexcept void fq_zech_poly_powmod_ui_binexp(fq_zech_poly_t res, const fq_zech_poly_t poly, ulong e, const fq_zech_poly_t f, const fq_zech_ctx_t ctx) noexcept - # Sets ``res`` to ``poly`` raised to the power ``e`` modulo - # ``f``, using binary exponentiation. We require ``e >= 0``. - - void _fq_zech_poly_powmod_ui_binexp_preinv(fq_zech_struct* res, const fq_zech_struct* poly, ulong e, const fq_zech_struct* f, slong lenf, const fq_zech_struct* finv, slong lenfinv, const fq_zech_ctx_t ctx) noexcept - # Sets ``res`` to ``poly`` raised to the power ``e`` modulo - # ``f``, using binary exponentiation. We require ``e > 0``. - # We require ``finv`` to be the inverse of the reverse of - # ``f``. - # We require ``lenf > 1``. It is assumed that ``poly`` is - # already reduced modulo ``f`` and zero-padded as necessary to - # have length exactly ``lenf - 1``. The output ``res`` must - # have room for ``lenf - 1`` coefficients. - + void _fq_zech_poly_powmod_ui_binexp_preinv(fq_zech_struct * res, const fq_zech_struct * poly, ulong e, const fq_zech_struct * f, slong lenf, const fq_zech_struct * finv, slong lenfinv, const fq_zech_ctx_t ctx) noexcept void fq_zech_poly_powmod_ui_binexp_preinv(fq_zech_poly_t res, const fq_zech_poly_t poly, ulong e, const fq_zech_poly_t f, const fq_zech_poly_t finv, const fq_zech_ctx_t ctx) noexcept - # Sets ``res`` to ``poly`` raised to the power ``e`` modulo - # ``f``, using binary exponentiation. We require ``e >= 0``. - # We require ``finv`` to be the inverse of the reverse of - # ``f``. - - void _fq_zech_poly_powmod_fmpz_binexp(fq_zech_struct* res, const fq_zech_struct* poly, const fmpz_t e, const fq_zech_struct* f, slong lenf, const fq_zech_ctx_t ctx) noexcept - # Sets ``res`` to ``poly`` raised to the power ``e`` modulo - # ``f``, using binary exponentiation. We require ``e > 0``. - # We require ``lenf > 1``. It is assumed that ``poly`` is - # already reduced modulo ``f`` and zero-padded as necessary to - # have length exactly ``lenf - 1``. The output ``res`` must - # have room for ``lenf - 1`` coefficients. - + void _fq_zech_poly_powmod_fmpz_binexp(fq_zech_struct * res, const fq_zech_struct * poly, const fmpz_t e, const fq_zech_struct * f, slong lenf, const fq_zech_ctx_t ctx) noexcept void fq_zech_poly_powmod_fmpz_binexp(fq_zech_poly_t res, const fq_zech_poly_t poly, const fmpz_t e, const fq_zech_poly_t f, const fq_zech_ctx_t ctx) noexcept - # Sets ``res`` to ``poly`` raised to the power ``e`` modulo - # ``f``, using binary exponentiation. We require ``e >= 0``. - - void _fq_zech_poly_powmod_fmpz_binexp_preinv(fq_zech_struct* res, const fq_zech_struct* poly, const fmpz_t e, const fq_zech_struct* f, slong lenf, const fq_zech_struct* finv, slong lenfinv, const fq_zech_ctx_t ctx) noexcept - # Sets ``res`` to ``poly`` raised to the power ``e`` modulo - # ``f``, using binary exponentiation. We require ``e > 0``. - # We require ``finv`` to be the inverse of the reverse of - # ``f``. - # We require ``lenf > 1``. It is assumed that ``poly`` is - # already reduced modulo ``f`` and zero-padded as necessary to - # have length exactly ``lenf - 1``. The output ``res`` must - # have room for ``lenf - 1`` coefficients. - + void _fq_zech_poly_powmod_fmpz_binexp_preinv(fq_zech_struct * res, const fq_zech_struct * poly, const fmpz_t e, const fq_zech_struct * f, slong lenf, const fq_zech_struct * finv, slong lenfinv, const fq_zech_ctx_t ctx) noexcept void fq_zech_poly_powmod_fmpz_binexp_preinv(fq_zech_poly_t res, const fq_zech_poly_t poly, const fmpz_t e, const fq_zech_poly_t f, const fq_zech_poly_t finv, const fq_zech_ctx_t ctx) noexcept - # Sets ``res`` to ``poly`` raised to the power ``e`` modulo - # ``f``, using binary exponentiation. We require ``e >= 0``. - # We require ``finv`` to be the inverse of the reverse of - # ``f``. - - void _fq_zech_poly_powmod_fmpz_sliding_preinv(fq_zech_struct* res, const fq_zech_struct* poly, const fmpz_t e, ulong k, const fq_zech_struct* f, slong lenf, const fq_zech_struct* finv, slong lenfinv, const fq_zech_ctx_t ctx) noexcept - # Sets ``res`` to ``poly`` raised to the power ``e`` modulo - # ``f``, using sliding-window exponentiation with window size - # ``k``. We require ``e > 0``. We require ``finv`` to be - # the inverse of the reverse of ``f``. If ``k`` is set to - # zero, then an "optimum" size will be selected automatically base - # on ``e``. - # We require ``lenf > 1``. It is assumed that ``poly`` is - # already reduced modulo ``f`` and zero-padded as necessary to - # have length exactly ``lenf - 1``. The output ``res`` must - # have room for ``lenf - 1`` coefficients. - + void _fq_zech_poly_powmod_fmpz_sliding_preinv(fq_zech_struct * res, const fq_zech_struct * poly, const fmpz_t e, ulong k, const fq_zech_struct * f, slong lenf, const fq_zech_struct * finv, slong lenfinv, const fq_zech_ctx_t ctx) noexcept void fq_zech_poly_powmod_fmpz_sliding_preinv(fq_zech_poly_t res, const fq_zech_poly_t poly, const fmpz_t e, ulong k, const fq_zech_poly_t f, const fq_zech_poly_t finv, const fq_zech_ctx_t ctx) noexcept - # Sets ``res`` to ``poly`` raised to the power ``e`` modulo - # ``f``, using sliding-window exponentiation with window size - # ``k``. We require ``e >= 0``. We require ``finv`` to be - # the inverse of the reverse of ``f``. If ``k`` is set to - # zero, then an "optimum" size will be selected automatically base - # on ``e``. - void _fq_zech_poly_powmod_x_fmpz_preinv(fq_zech_struct * res, const fmpz_t e, const fq_zech_struct * f, slong lenf, const fq_zech_struct * finv, slong lenfinv, const fq_zech_ctx_t ctx) noexcept - # Sets ``res`` to ``x`` raised to the power ``e`` modulo ``f``, - # using sliding window exponentiation. We require ``e > 0``. - # We require ``finv`` to be the inverse of the reverse of ``f``. - # We require ``lenf > 2``. The output ``res`` must have room for - # ``lenf - 1`` coefficients. - void fq_zech_poly_powmod_x_fmpz_preinv(fq_zech_poly_t res, const fmpz_t e, const fq_zech_poly_t f, const fq_zech_poly_t finv, const fq_zech_ctx_t ctx) noexcept - # Sets ``res`` to ``x`` raised to the power ``e`` - # modulo ``f``, using sliding window exponentiation. We require - # ``e >= 0``. We require ``finv`` to be the inverse of the reverse of - # ``f``. - void _fq_zech_poly_pow_trunc_binexp(fq_zech_struct * res, const fq_zech_struct * poly, ulong e, slong trunc, const fq_zech_ctx_t ctx) noexcept - # Sets ``res`` to the low ``trunc`` coefficients of ``poly`` - # (assumed to be zero padded if necessary to length ``trunc``) to the power ``e``. This is equivalent to doing a powering followed - # by a truncation. We require that ``res`` has enough space for - # ``trunc`` coefficients, that ``trunc > 0`` and that ``e > 1``. Aliasing is not permitted. Uses the binary exponentiation method. - void fq_zech_poly_pow_trunc_binexp(fq_zech_poly_t res, const fq_zech_poly_t poly, ulong e, slong trunc, const fq_zech_ctx_t ctx) noexcept - # Sets ``res`` to the low ``trunc`` coefficients of ``poly`` - # to the power ``e``. This is equivalent to doing a powering - # followed by a truncation. Uses the binary exponentiation method. - void _fq_zech_poly_pow_trunc(fq_zech_struct * res, const fq_zech_struct * poly, ulong e, slong trunc, const fq_zech_ctx_t mod) noexcept - # Sets ``res`` to the low ``trunc`` coefficients of ``poly`` - # (assumed to be zero padded if necessary to length ``trunc``) to - # the power ``e``. This is equivalent to doing a powering followed - # by a truncation. We require that ``res`` has enough space for - # ``trunc`` coefficients, that ``trunc > 0`` and that - # ``e > 1``. Aliasing is not permitted. - void fq_zech_poly_pow_trunc(fq_zech_poly_t res, const fq_zech_poly_t poly, ulong e, slong trunc, const fq_zech_ctx_t ctx) noexcept - # Sets ``res`` to the low ``trunc`` coefficients of ``poly`` - # to the power ``e``. This is equivalent to doing a powering - # followed by a truncation. - - void _fq_zech_poly_shift_left(fq_zech_struct *rop, const fq_zech_struct *op, slong len, slong n, const fq_zech_ctx_t ctx) noexcept - # Sets ``(rop, len + n)`` to ``(op, len)`` shifted left by - # `n` coefficients. - # Inserts zero coefficients at the lower end. Assumes that - # ``len`` and `n` are positive, and that ``rop`` fits - # ``len + n`` elements. Supports aliasing between ``rop`` and - # ``op``. - + void _fq_zech_poly_shift_left(fq_zech_struct * rop, const fq_zech_struct * op, slong len, slong n, const fq_zech_ctx_t ctx) noexcept void fq_zech_poly_shift_left(fq_zech_poly_t rop, const fq_zech_poly_t op, slong n, const fq_zech_ctx_t ctx) noexcept - # Sets ``rop`` to ``op`` shifted left by `n` coeffs. Zero - # coefficients are inserted. - - void _fq_zech_poly_shift_right(fq_zech_struct *rop, const fq_zech_struct *op, slong len, slong n, const fq_zech_ctx_t ctx) noexcept - # Sets ``(rop, len - n)`` to ``(op, len)`` shifted right by - # `n` coefficients. - # Assumes that ``len`` and `n` are positive, that ``len > n``, - # and that ``rop`` fits ``len - n`` elements. Supports - # aliasing between ``rop`` and ``op``, although in this case - # the top coefficients of ``op`` are not set to zero. - + void _fq_zech_poly_shift_right(fq_zech_struct * rop, const fq_zech_struct * op, slong len, slong n, const fq_zech_ctx_t ctx) noexcept void fq_zech_poly_shift_right(fq_zech_poly_t rop, const fq_zech_poly_t op, slong n, const fq_zech_ctx_t ctx) noexcept - # Sets ``rop`` to ``op`` shifted right by `n` coefficients. - # If `n` is equal to or greater than the current length of - # ``op``, ``rop`` is set to the zero polynomial. - - slong _fq_zech_poly_hamming_weight(const fq_zech_struct *op, slong len, const fq_zech_ctx_t ctx) noexcept - # Returns the number of non-zero entries in ``(op, len)``. - + slong _fq_zech_poly_hamming_weight(const fq_zech_struct * op, slong len, const fq_zech_ctx_t ctx) noexcept slong fq_zech_poly_hamming_weight(const fq_zech_poly_t op, const fq_zech_ctx_t ctx) noexcept - # Returns the number of non-zero entries in the polynomial ``op``. - - void _fq_zech_poly_divrem(fq_zech_struct *Q, fq_zech_struct *R, const fq_zech_struct *A, slong lenA, const fq_zech_struct *B, slong lenB, const fq_zech_t invB, const fq_zech_ctx_t ctx) noexcept - # Computes ``(Q, lenA - lenB + 1)``, ``(R, lenA)`` such that - # `A = B Q + R` with `0 \leq \operatorname{len}(R) < \operatorname{len}(B)`. - # Assumes that the leading coefficient of `B` is invertible - # and that ``invB`` is its inverse. - # Assumes that `\operatorname{len}(A), \operatorname{len}(B) > 0`. Allows zero-padding in - # ``(A, lenA)``. `R` and `A` may be aliased, but apart from - # this no aliasing of input and output operands is allowed. - + void _fq_zech_poly_divrem(fq_zech_struct * Q, fq_zech_struct * R, const fq_zech_struct * A, slong lenA, const fq_zech_struct * B, slong lenB, const fq_zech_t invB, const fq_zech_ctx_t ctx) noexcept void fq_zech_poly_divrem(fq_zech_poly_t Q, fq_zech_poly_t R, const fq_zech_poly_t A, const fq_zech_poly_t B, const fq_zech_ctx_t ctx) noexcept - # Computes `Q`, `R` such that `A = B Q + R` with - # `0 \leq \operatorname{len}(R) < \operatorname{len}(B)`. - # Assumes that the leading coefficient of `B` is invertible. This can - # be taken for granted the context is for a finite field, that is, when - # `p` is prime and `f(X)` is irreducible. - void fq_zech_poly_divrem_f(fq_zech_t f, fq_zech_poly_t Q, fq_zech_poly_t R, const fq_zech_poly_t A, const fq_zech_poly_t B, const fq_zech_ctx_t ctx) noexcept - # Either finds a non-trivial factor `f` of the modulus of - # ``ctx``, or computes `Q`, `R` such that `A = B Q + R` and - # `0 \leq \operatorname{len}(R) < \operatorname{len}(B)`. - # If the leading coefficient of `B` is invertible, the division with - # remainder operation is carried out, `Q` and `R` are computed - # correctly, and `f` is set to `1`. Otherwise, `f` is set to a - # non-trivial factor of the modulus and `Q` and `R` are not touched. - # Assumes that `B` is non-zero. - - void _fq_zech_poly_rem(fq_zech_struct *R, const fq_zech_struct *A, slong lenA, const fq_zech_struct *B, slong lenB, const fq_zech_t invB, const fq_zech_ctx_t ctx) noexcept - # Sets ``R`` to the remainder of the division of ``(A,lenA)`` by - # ``(B,lenB)``. Assumes that the leading coefficient of ``(B,lenB)`` - # is invertible and that ``invB`` is its inverse. - + void _fq_zech_poly_rem(fq_zech_struct * R, const fq_zech_struct * A, slong lenA, const fq_zech_struct * B, slong lenB, const fq_zech_t invB, const fq_zech_ctx_t ctx) noexcept void fq_zech_poly_rem(fq_zech_poly_t R, const fq_zech_poly_t A, const fq_zech_poly_t B, const fq_zech_ctx_t ctx) noexcept - # Sets ``R`` to the remainder of the division of ``A`` by - # ``B`` in the context described by ``ctx``. - - void _fq_zech_poly_div(fq_zech_struct *Q, const fq_zech_struct *A, slong lenA, const fq_zech_struct *B, slong lenB, const fq_zech_t invB, const fq_zech_ctx_t ctx) noexcept - # Notationally, computes `Q`, `R` such that `A = B Q + R` with `0 - # \leq \operatorname{len}(R) < \operatorname{len}(B)` but only sets ``(Q, lenA - lenB + 1)``. - # Allows zero-padding in `A` but not in `B`. Assumes that the leading coefficient of `B` is a - # unit. - + void _fq_zech_poly_div(fq_zech_struct * Q, const fq_zech_struct * A, slong lenA, const fq_zech_struct * B, slong lenB, const fq_zech_t invB, const fq_zech_ctx_t ctx) noexcept void fq_zech_poly_div(fq_zech_poly_t Q, const fq_zech_poly_t A, const fq_zech_poly_t B, const fq_zech_ctx_t ctx) noexcept - # Notionally finds polynomials `Q` and `R` such that `A = B Q + R` with - # `\operatorname{len}(R) < \operatorname{len}(B)`, but returns only ``Q``. If `\operatorname{len}(B) = 0` an - # exception is raised. - - void _fq_zech_poly_div_newton_n_preinv(fq_zech_struct* Q, const fq_zech_struct* A, slong lenA, const fq_zech_struct* B, slong lenB, const fq_zech_struct* Binv, slong lenBinv, const fq_zech_ctx_t ctx) noexcept - # Notionally computes polynomials `Q` and `R` such that `A = BQ + R` with - # `\operatorname{len}(R)` less than ``lenB``, where ``A`` is of length ``lenA`` - # and ``B`` is of length ``lenB``, but return only `Q`. - # We require that `Q` have space for ``lenA - lenB + 1`` coefficients - # and assume that the leading coefficient of `B` is a unit. Furthermore, we - # assume that `Binv` is the inverse of the reverse of `B` mod `x^{\operatorname{len}(B)}`. - # The algorithm used is to reverse the polynomials and divide the - # resulting power series, then reverse the result. - + void _fq_zech_poly_div_newton_n_preinv(fq_zech_struct * Q, const fq_zech_struct * A, slong lenA, const fq_zech_struct * B, slong lenB, const fq_zech_struct * Binv, slong lenBinv, const fq_zech_ctx_t ctx) noexcept void fq_zech_poly_div_newton_n_preinv(fq_zech_poly_t Q, const fq_zech_poly_t A, const fq_zech_poly_t B, const fq_zech_poly_t Binv, const fq_zech_ctx_t ctx) noexcept - # Notionally computes `Q` and `R` such that `A = BQ + R` with - # `\operatorname{len}(R) < \operatorname{len}(B)`, but returns only `Q`. - # We assume that the leading coefficient of `B` is a unit and that `Binv` is - # the inverse of the reverse of `B` mod `x^{\operatorname{len}(B)}`. - # It is required that the length of `A` is less than or equal to - # 2*the length of `B` - 2. - # The algorithm used is to reverse the polynomials and divide the - # resulting power series, then reverse the result. - - void _fq_zech_poly_divrem_newton_n_preinv(fq_zech_struct* Q, fq_zech_struct* R, const fq_zech_struct* A, slong lenA, const fq_zech_struct* B, slong lenB, const fq_zech_struct* Binv, slong lenBinv, const fq_zech_ctx_t ctx) noexcept - # Computes `Q` and `R` such that `A = BQ + R` with `\operatorname{len}(R)` less - # than ``lenB``, where `A` is of length ``lenA`` and `B` is of - # length ``lenB``. We require that `Q` have space for - # ``lenA - lenB + 1`` coefficients. Furthermore, we assume that `Binv` is - # the inverse of the reverse of `B` mod `x^{\operatorname{len}(B)}`. The algorithm - # used is to call :func:`div_newton_preinv` and then multiply out - # and compute the remainder. - + void _fq_zech_poly_divrem_newton_n_preinv(fq_zech_struct * Q, fq_zech_struct * R, const fq_zech_struct * A, slong lenA, const fq_zech_struct * B, slong lenB, const fq_zech_struct * Binv, slong lenBinv, const fq_zech_ctx_t ctx) noexcept void fq_zech_poly_divrem_newton_n_preinv(fq_zech_poly_t Q, fq_zech_poly_t R, const fq_zech_poly_t A, const fq_zech_poly_t B, const fq_zech_poly_t Binv, const fq_zech_ctx_t ctx) noexcept - # Computes `Q` and `R` such that `A = BQ + R` with `\operatorname{len}(R) < - # \operatorname{len}(B)`. We assume `Binv` is the inverse of the reverse of `B` - # mod `x^{\operatorname{len}(B)}`. - # It is required that the length of `A` is less than or equal to - # 2*the length of `B` - 2. - # The algorithm used is to call :func:`div_newton` and then - # multiply out and compute the remainder. - - void _fq_zech_poly_inv_series_newton(fq_zech_struct* Qinv, const fq_zech_struct* Q, slong n, const fq_zech_t cinv, const fq_zech_ctx_t ctx) noexcept - # Given ``Q`` of length ``n`` whose constant coefficient is - # invertible modulo the given modulus, find a polynomial ``Qinv`` - # of length ``n`` such that ``Q * Qinv`` is ``1`` modulo - # `x^n`. Requires ``n > 0``. This function can be viewed as - # inverting a power series via Newton iteration. - + void _fq_zech_poly_inv_series_newton(fq_zech_struct * Qinv, const fq_zech_struct * Q, slong n, const fq_zech_t cinv, const fq_zech_ctx_t ctx) noexcept void fq_zech_poly_inv_series_newton(fq_zech_poly_t Qinv, const fq_zech_poly_t Q, slong n, const fq_zech_ctx_t ctx) noexcept - # Given ``Q`` find ``Qinv`` such that ``Q * Qinv`` is - # ``1`` modulo `x^n`. The constant coefficient of ``Q`` must - # be invertible modulo the modulus of ``Q``. An exception is - # raised if this is not the case or if ``n = 0``. This function - # can be viewed as inverting a power series via Newton iteration. - - void _fq_zech_poly_inv_series(fq_zech_struct* Qinv, const fq_zech_struct* Q, slong n, const fq_zech_t cinv, const fq_zech_ctx_t ctx) noexcept - # Given ``Q`` of length ``n`` whose constant coefficient is - # invertible modulo the given modulus, find a polynomial ``Qinv`` - # of length ``n`` such that ``Q * Qinv`` is ``1`` modulo - # `x^n`. Requires ``n > 0``. - + void _fq_zech_poly_inv_series(fq_zech_struct * Qinv, const fq_zech_struct * Q, slong n, const fq_zech_t cinv, const fq_zech_ctx_t ctx) noexcept void fq_zech_poly_inv_series(fq_zech_poly_t Qinv, const fq_zech_poly_t Q, slong n, const fq_zech_ctx_t ctx) noexcept - # Given ``Q`` find ``Qinv`` such that ``Q * Qinv`` is - # ``1`` modulo `x^n`. The constant coefficient of ``Q`` must - # be invertible modulo the modulus of ``Q``. An exception is - # raised if this is not the case or if ``n = 0``. - void _fq_zech_poly_div_series(fq_zech_struct * Q, const fq_zech_struct * A, slong Alen, const fq_zech_struct * B, slong Blen, slong n, const fq_zech_ctx_t ctx) noexcept - # Set ``(Q, n)`` to the quotient of the series ``(A, Alen``) and - # ``(B, Blen)`` assuming ``Alen, Blen <= n``. We assume the bottom - # coefficient of ``B`` is invertible. - void fq_zech_poly_div_series(fq_zech_poly_t Q, const fq_zech_poly_t A, const fq_zech_poly_t B, slong n, const fq_zech_ctx_t ctx) noexcept - # Set `Q` to the quotient of the series `A` by `B`, thinking of the series as - # though they were of length `n`. We assume that the bottom coefficient of - # `B` is invertible. - void fq_zech_poly_gcd(fq_zech_poly_t rop, const fq_zech_poly_t op1, const fq_zech_poly_t op2, const fq_zech_ctx_t ctx) noexcept - # Sets ``rop`` to the greatest common divisor of ``op1`` and - # ``op2``, using the either the Euclidean or HGCD algorithm. The - # GCD of zero polynomials is defined to be zero, whereas the GCD of - # the zero polynomial and some other polynomial `P` is defined to be - # `P`. Except in the case where the GCD is zero, the GCD `G` is made - # monic. - - slong _fq_zech_poly_gcd(fq_zech_struct* G, const fq_zech_struct* A, slong lenA, const fq_zech_struct* B, slong lenB, const fq_zech_ctx_t ctx) noexcept - # Computes the GCD of `A` of length ``lenA`` and `B` of length - # ``lenB``, where ``lenA >= lenB > 0`` and sets `G` to it. The - # length of the GCD `G` is returned by the function. No attempt is - # made to make the GCD monic. It is required that `G` have space for - # ``lenB`` coefficients. - - slong _fq_zech_poly_gcd_euclidean_f(fq_zech_t f, fq_zech_struct *G, const fq_zech_struct *A, slong lenA, const fq_zech_struct *B, slong lenB, const fq_zech_ctx_t ctx) noexcept - # Either sets `f = 1` and `G` to the greatest common divisor of - # `(A,\operatorname{len}(A))` and `(B, \operatorname{len}(B))` and returns its length, or sets - # `f` to a non-trivial factor of the modulus of ``ctx`` and leaves - # the contents of the vector `(G, lenB)` undefined. - # Assumes that `\operatorname{len}(A) \geq \operatorname{len}(B) > 0` and that the vector `G` - # has space for sufficiently many coefficients. - + slong _fq_zech_poly_gcd(fq_zech_struct * G, const fq_zech_struct * A, slong lenA, const fq_zech_struct * B, slong lenB, const fq_zech_ctx_t ctx) noexcept + slong _fq_zech_poly_gcd_euclidean_f(fq_zech_t f, fq_zech_struct * G, const fq_zech_struct * A, slong lenA, const fq_zech_struct * B, slong lenB, const fq_zech_ctx_t ctx) noexcept void fq_zech_poly_gcd_euclidean_f(fq_zech_t f, fq_zech_poly_t G, const fq_zech_poly_t A, const fq_zech_poly_t B, const fq_zech_ctx_t ctx) noexcept - # Either sets `f = 1` and `G` to the greatest common divisor of `A` - # and `B` or sets `f` to a factor of the modulus of ``ctx``. - - slong _fq_zech_poly_xgcd(fq_zech_struct *G, fq_zech_struct *S, fq_zech_struct *T, const fq_zech_struct *A, slong lenA, const fq_zech_struct *B, slong lenB, const fq_zech_ctx_t ctx) noexcept - # Computes the GCD of `A` and `B` together with cofactors `S` and `T` - # such that `S A + T B = G`. Returns the length of `G`. - # Assumes that `\operatorname{len}(A) \geq \operatorname{len}(B) \geq 1` and - # `(\operatorname{len}(A),\operatorname{len}(B)) \neq (1,1)`. - # No attempt is made to make the GCD monic. - # Requires that `G` have space for `\operatorname{len}(B)` coefficients. Writes - # `\operatorname{len}(B)-1` and `\operatorname{len}(A)-1` coefficients to `S` and `T`, respectively. - # Note that, in fact, `\operatorname{len}(S) \leq \max(\operatorname{len}(B) - \operatorname{len}(G), 1)` and - # `\operatorname{len}(T) \leq \max(\operatorname{len}(A) - \operatorname{len}(G), 1)`. - # No aliasing of input and output operands is permitted. - + slong _fq_zech_poly_xgcd(fq_zech_struct * G, fq_zech_struct * S, fq_zech_struct * T, const fq_zech_struct * A, slong lenA, const fq_zech_struct * B, slong lenB, const fq_zech_ctx_t ctx) noexcept void fq_zech_poly_xgcd(fq_zech_poly_t G, fq_zech_poly_t S, fq_zech_poly_t T, const fq_zech_poly_t A, const fq_zech_poly_t B, const fq_zech_ctx_t ctx) noexcept - # Computes the GCD of `A` and `B`. The GCD of zero polynomials is - # defined to be zero, whereas the GCD of the zero polynomial and some other - # polynomial `P` is defined to be `P`. Except in the case where - # the GCD is zero, the GCD `G` is made monic. - # Polynomials ``S`` and ``T`` are computed such that - # ``S*A + T*B = G``. The length of ``S`` will be at most - # ``lenB`` and the length of ``T`` will be at most ``lenA``. - - slong _fq_zech_poly_xgcd_euclidean_f(fq_zech_t f, fq_zech_struct *G, fq_zech_struct *S, fq_zech_struct *T, const fq_zech_struct *A, slong lenA, const fq_zech_struct *B, slong lenB, const fq_zech_ctx_t ctx) noexcept - # Either sets `f = 1` and computes the GCD of `A` and `B` together - # with cofactors `S` and `T` such that `S A + T B = G`; otherwise, - # sets `f` to a non-trivial factor of the modulus of ``ctx`` and - # leaves `G`, `S`, and `T` undefined. Returns the length of `G`. - # Assumes that `\operatorname{len}(A) \geq \operatorname{len}(B) \geq 1` and - # `(\operatorname{len}(A),\operatorname{len}(B)) \neq (1,1)`. - # No attempt is made to make the GCD monic. - # Requires that `G` have space for `\operatorname{len}(B)` coefficients. Writes - # `\operatorname{len}(B)-1` and `\operatorname{len}(A)-1` coefficients to `S` and `T`, respectively. - # Note that, in fact, `\operatorname{len}(S) \leq \max(\operatorname{len}(B) - \operatorname{len}(G), 1)` and - # `\operatorname{len}(T) \leq \max(\operatorname{len}(A) - \operatorname{len}(G), 1)`. - # No aliasing of input and output operands is permitted. - + slong _fq_zech_poly_xgcd_euclidean_f(fq_zech_t f, fq_zech_struct * G, fq_zech_struct * S, fq_zech_struct * T, const fq_zech_struct * A, slong lenA, const fq_zech_struct * B, slong lenB, const fq_zech_ctx_t ctx) noexcept void fq_zech_poly_xgcd_euclidean_f(fq_zech_t f, fq_zech_poly_t G, fq_zech_poly_t S, fq_zech_poly_t T, const fq_zech_poly_t A, const fq_zech_poly_t B, const fq_zech_ctx_t ctx) noexcept - # Either sets `f = 1` and computes the GCD of `A` and `B` or sets - # `f` to a non-trivial factor of the modulus of ``ctx``. - # If the GCD is computed, polynomials ``S`` and ``T`` are - # computed such that ``S*A + T*B = G``; otherwise, they are - # undefined. The length of ``S`` will be at most ``lenB`` and - # the length of ``T`` will be at most ``lenA``. - # The GCD of zero polynomials is defined to be zero, whereas the GCD - # of the zero polynomial and some other polynomial `P` is defined to - # be `P`. Except in the case where the GCD is zero, the GCD `G` is - # made monic. - - int _fq_zech_poly_divides(fq_zech_struct *Q, const fq_zech_struct *A, slong lenA, const fq_zech_struct *B, slong lenB, const fq_zech_t invB, const fq_zech_ctx_t ctx) noexcept - # Returns `1` if ``(B, lenB)`` divides ``(A, lenA)`` exactly and - # sets `Q` to the quotient, otherwise returns `0`. - # It is assumed that `\operatorname{len}(A) \geq \operatorname{len}(B) > 0` and that `Q` has space - # for `\operatorname{len}(A) - \operatorname{len}(B) + 1` coefficients. - # Aliasing of `Q` with either of the inputs is not permitted. - # This function is currently unoptimised and provided for convenience - # only. - + int _fq_zech_poly_divides(fq_zech_struct * Q, const fq_zech_struct * A, slong lenA, const fq_zech_struct * B, slong lenB, const fq_zech_t invB, const fq_zech_ctx_t ctx) noexcept int fq_zech_poly_divides(fq_zech_poly_t Q, const fq_zech_poly_t A, const fq_zech_poly_t B, const fq_zech_ctx_t ctx) noexcept - # Returns `1` if `B` divides `A` exactly and sets `Q` to the quotient, - # otherwise returns `0`. - # This function is currently unoptimised and provided for convenience - # only. - - void _fq_zech_poly_derivative(fq_zech_struct *rop, const fq_zech_struct *op, slong len, const fq_zech_ctx_t ctx) noexcept - # Sets ``(rop, len - 1)`` to the derivative of ``(op, len)``. - # Also handles the cases where ``len`` is `0` or `1` correctly. - # Supports aliasing of ``rop`` and ``op``. - + void _fq_zech_poly_derivative(fq_zech_struct * rop, const fq_zech_struct * op, slong len, const fq_zech_ctx_t ctx) noexcept void fq_zech_poly_derivative(fq_zech_poly_t rop, const fq_zech_poly_t op, const fq_zech_ctx_t ctx) noexcept - # Sets ``rop`` to the derivative of ``op``. - void _fq_zech_poly_invsqrt_series(fq_zech_struct * g, const fq_zech_struct * h, slong n, fq_zech_ctx_t mod) noexcept - # Set the first `n` terms of `g` to the series expansion of `1/\sqrt{h}`. - # It is assumed that `n > 0`, that `h` has constant term 1 and that `h` - # is zero-padded as necessary to length `n`. Aliasing is not permitted. - void fq_zech_poly_invsqrt_series(fq_zech_poly_t g, const fq_zech_poly_t h, slong n, fq_zech_ctx_t ctx) noexcept - # Set `g` to the series expansion of `1/\sqrt{h}` to order `O(x^n)`. - # It is assumed that `h` has constant term 1. - void _fq_zech_poly_sqrt_series(fq_zech_struct * g, const fq_zech_struct * h, slong n, fq_zech_ctx_t ctx) noexcept - # Set the first `n` terms of `g` to the series expansion of `\sqrt{h}`. - # It is assumed that `n > 0`, that `h` has constant term 1 and that `h` - # is zero-padded as necessary to length `n`. Aliasing is not permitted. - void fq_zech_poly_sqrt_series(fq_zech_poly_t g, const fq_zech_poly_t h, slong n, fq_zech_ctx_t ctx) noexcept - # Set `g` to the series expansion of `\sqrt{h}` to order `O(x^n)`. - # It is assumed that `h` has constant term 1. - int _fq_zech_poly_sqrt(fq_zech_struct * s, const fq_zech_struct * p, slong n, fq_zech_ctx_t mod) noexcept - # If ``(p, n)`` is a perfect square, sets ``(s, n / 2 + 1)`` - # to a square root of `p` and returns 1. Otherwise returns 0. - int fq_zech_poly_sqrt(fq_zech_poly_t s, const fq_zech_poly_t p, fq_zech_ctx_t mod) noexcept - # If `p` is a perfect square, sets `s` to a square root of `p` - # and returns 1. Otherwise returns 0. - - void _fq_zech_poly_evaluate_fq_zech(fq_zech_t rop, const fq_zech_struct *op, slong len, const fq_zech_t a, const fq_zech_ctx_t ctx) noexcept - # Sets ``rop`` to ``(op, len)`` evaluated at `a`. - # Supports zero padding. There are no restrictions on ``len``, that - # is, ``len`` is allowed to be zero, too. - + void _fq_zech_poly_evaluate_fq_zech(fq_zech_t rop, const fq_zech_struct * op, slong len, const fq_zech_t a, const fq_zech_ctx_t ctx) noexcept void fq_zech_poly_evaluate_fq_zech(fq_zech_t rop, const fq_zech_poly_t f, const fq_zech_t a, const fq_zech_ctx_t ctx) noexcept - # Sets ``rop`` to the value of `f(a)`. - # As the coefficient ring `\mathbf{F}_q` is finite, Horner's method - # is sufficient. - - void _fq_zech_poly_compose(fq_zech_struct *rop, const fq_zech_struct *op1, slong len1, const fq_zech_struct *op2, slong len2, const fq_zech_ctx_t ctx) noexcept - # Sets ``rop`` to the composition of ``(op1, len1)`` and - # ``(op2, len2)``. - # Assumes that ``rop`` has space for ``(len1-1)*(len2-1) + 1`` - # coefficients. Assumes that ``op1`` and ``op2`` are non-zero - # polynomials. Does not support aliasing between any of the inputs and - # the output. - + void _fq_zech_poly_compose(fq_zech_struct * rop, const fq_zech_struct * op1, slong len1, const fq_zech_struct * op2, slong len2, const fq_zech_ctx_t ctx) noexcept void fq_zech_poly_compose(fq_zech_poly_t rop, const fq_zech_poly_t op1, const fq_zech_poly_t op2, const fq_zech_ctx_t ctx) noexcept - # Sets ``rop`` to the composition of ``op1`` and ``op2``. - # To be precise about the order of composition, denoting ``rop``, - # ``op1``, and ``op2`` by `f`, `g`, and `h`, respectively, - # sets `f(t) = g(h(t))`. - void _fq_zech_poly_compose_mod_horner(fq_zech_struct * res, const fq_zech_struct * f, slong lenf, const fq_zech_struct * g, const fq_zech_struct * h, slong lenh, const fq_zech_ctx_t ctx) noexcept - # Sets ``res`` to the composition `f(g)` modulo `h`. We require that - # `h` is nonzero and that the length of `g` is one less than the - # length of `h` (possibly with zero padding). The output is not allowed - # to be aliased with any of the inputs. - # The algorithm used is Horner's rule. - void fq_zech_poly_compose_mod_horner(fq_zech_poly_t res, const fq_zech_poly_t f, const fq_zech_poly_t g, const fq_zech_poly_t h, const fq_zech_ctx_t ctx) noexcept - # Sets ``res`` to the composition `f(g)` modulo `h`. We require that - # `h` is nonzero. The algorithm used is Horner's rule. - void _fq_zech_poly_compose_mod_horner_preinv(fq_zech_struct * res, const fq_zech_struct * f, slong lenf, const fq_zech_struct * g, const fq_zech_struct * h, slong lenh, const fq_zech_struct * hinv, slong lenhiv, const fq_zech_ctx_t ctx) noexcept - # Sets ``res`` to the composition `f(g)` modulo `h`. We require - # that `h` is nonzero and that the length of `g` is one less than - # the length of `h` (possibly with zero padding). We also require - # that the length of `f` is less than the length of - # `h`. Furthermore, we require ``hinv`` to be the inverse of the - # reverse of ``h``. The output is not allowed to be aliased with - # any of the inputs. - # The algorithm used is Horner's rule. - void fq_zech_poly_compose_mod_horner_preinv(fq_zech_poly_t res, const fq_zech_poly_t f, const fq_zech_poly_t g, const fq_zech_poly_t h, const fq_zech_poly_t hinv, const fq_zech_ctx_t ctx) noexcept - # Sets ``res`` to the composition `f(g)` modulo `h`. We require - # that `h` is nonzero and that `f` has smaller degree than - # `h`. Furthermore, we require ``hinv`` to be the inverse of the - # reverse of ``h``. The algorithm used is Horner's rule. - void _fq_zech_poly_compose_mod_brent_kung(fq_zech_struct * res, const fq_zech_struct * f, slong lenf, const fq_zech_struct * g, const fq_zech_struct * h, slong lenh, const fq_zech_ctx_t ctx) noexcept - # Sets ``res`` to the composition `f(g)` modulo `h`. We require - # that `h` is nonzero and that the length of `g` is one less than - # the length of `h` (possibly with zero padding). We also require - # that the length of `f` is less than the length of `h`. The output - # is not allowed to be aliased with any of the inputs. - # The algorithm used is the Brent-Kung matrix algorithm. - void fq_zech_poly_compose_mod_brent_kung(fq_zech_poly_t res, const fq_zech_poly_t f, const fq_zech_poly_t g, const fq_zech_poly_t h, const fq_zech_ctx_t ctx) noexcept - # Sets ``res`` to the composition `f(g)` modulo `h`. We require - # that `h` is nonzero and that `f` has smaller degree than `h`. The - # algorithm used is the Brent-Kung matrix algorithm. - void _fq_zech_poly_compose_mod_brent_kung_preinv(fq_zech_struct * res, const fq_zech_struct * f, slong lenf, const fq_zech_struct * g, const fq_zech_struct * h, slong lenh, const fq_zech_struct * hinv, slong lenhiv, const fq_zech_ctx_t ctx) noexcept - # Sets ``res`` to the composition `f(g)` modulo `h`. We require - # that `h` is nonzero and that the length of `g` is one less than - # the length of `h` (possibly with zero padding). We also require - # that the length of `f` is less than the length of - # `h`. Furthermore, we require ``hinv`` to be the inverse of the - # reverse of ``h``. The output is not allowed to be aliased with - # any of the inputs. - # The algorithm used is the Brent-Kung matrix algorithm. - void fq_zech_poly_compose_mod_brent_kung_preinv(fq_zech_poly_t res, const fq_zech_poly_t f, const fq_zech_poly_t g, const fq_zech_poly_t h, const fq_zech_poly_t hinv, const fq_zech_ctx_t ctx) noexcept - # Sets ``res`` to the composition `f(g)` modulo `h`. We require - # that `h` is nonzero and that `f` has smaller degree than - # `h`. Furthermore, we require ``hinv`` to be the inverse of the - # reverse of ``h``. The algorithm used is the Brent-Kung matrix - # algorithm. - void _fq_zech_poly_compose_mod(fq_zech_struct * res, const fq_zech_struct * f, slong lenf, const fq_zech_struct * g, const fq_zech_struct * h, slong lenh, const fq_zech_ctx_t ctx) noexcept - # Sets ``res`` to the composition `f(g)` modulo `h`. We require - # that `h` is nonzero and that the length of `g` is one less than - # the length of `h` (possibly with zero padding). The output is not - # allowed to be aliased with any of the inputs. - void fq_zech_poly_compose_mod(fq_zech_poly_t res, const fq_zech_poly_t f, const fq_zech_poly_t g, const fq_zech_poly_t h, const fq_zech_ctx_t ctx) noexcept - # Sets ``res`` to the composition `f(g)` modulo `h`. We require - # that `h` is nonzero. - void _fq_zech_poly_compose_mod_preinv(fq_zech_struct * res, const fq_zech_struct * f, slong lenf, const fq_zech_struct * g, const fq_zech_struct * h, slong lenh, const fq_zech_struct * hinv, slong lenhiv, const fq_zech_ctx_t ctx) noexcept - # Sets ``res`` to the composition `f(g)` modulo `h`. We require - # that `h` is nonzero and that the length of `g` is one less than - # the length of `h` (possibly with zero padding). We also require - # that the length of `f` is less than the length of - # `h`. Furthermore, we require ``hinv`` to be the inverse of the - # reverse of ``h``. The output is not allowed to be aliased with - # any of the inputs. - void fq_zech_poly_compose_mod_preinv(fq_zech_poly_t res, const fq_zech_poly_t f, const fq_zech_poly_t g, const fq_zech_poly_t h, const fq_zech_poly_t hinv, const fq_zech_ctx_t ctx) noexcept - # Sets ``res`` to the composition `f(g)` modulo `h`. We require - # that `h` is nonzero and that `f` has smaller degree than - # `h`. Furthermore, we require ``hinv`` to be the inverse of the - # reverse of ``h``. - void _fq_zech_poly_reduce_matrix_mod_poly (fq_zech_mat_t A, const fq_zech_mat_t B, const fq_zech_poly_t f, const fq_zech_ctx_t ctx) noexcept - # Sets the ith row of ``A`` to the reduction of the ith row of `B` modulo - # `f` for `i=1,\ldots,\sqrt{\deg(f)}`. We require `B` to be at least - # a `\sqrt{\deg(f)}\times \deg(f)` matrix and `f` to be nonzero. - - void _fq_zech_poly_precompute_matrix (fq_zech_mat_t A, const fq_zech_struct* f, const fq_zech_struct* g, slong leng, const fq_zech_struct* ginv, slong lenginv, const fq_zech_ctx_t ctx) noexcept - # Sets the ith row of ``A`` to `f^i` modulo `g` for - # `i=1,\ldots,\sqrt{\deg(g)}`. We require `A` to be a - # `\sqrt{\deg(g)}\times \deg(g)` matrix. We require ``ginv`` to - # be the inverse of the reverse of ``g`` and `g` to be nonzero. - + void _fq_zech_poly_precompute_matrix (fq_zech_mat_t A, const fq_zech_struct * f, const fq_zech_struct * g, slong leng, const fq_zech_struct * ginv, slong lenginv, const fq_zech_ctx_t ctx) noexcept void fq_zech_poly_precompute_matrix (fq_zech_mat_t A, const fq_zech_poly_t f, const fq_zech_poly_t g, const fq_zech_poly_t ginv, const fq_zech_ctx_t ctx) noexcept - # Sets the ith row of ``A`` to `f^i` modulo `g` for - # `i=1,\ldots,\sqrt{\deg(g)}`. We require `A` to be a - # `\sqrt{\deg(g)}\times \deg(g)` matrix. We require ``ginv`` to - # be the inverse of the reverse of ``g``. - - void _fq_zech_poly_compose_mod_brent_kung_precomp_preinv(fq_zech_struct* res, const fq_zech_struct* f, slong lenf, const fq_zech_mat_t A, const fq_zech_struct* h, slong lenh, const fq_zech_struct* hinv, slong lenhinv, const fq_zech_ctx_t ctx) noexcept - # Sets ``res`` to the composition `f(g)` modulo `h`. We require - # that `h` is nonzero. We require that the ith row of `A` contains - # `g^i` for `i=1,\ldots,\sqrt{\deg(h)}`, i.e. `A` is a - # `\sqrt{\deg(h)}\times \deg(h)` matrix. We also require that the - # length of `f` is less than the length of `h`. Furthermore, we - # require ``hinv`` to be the inverse of the reverse of ``h``. - # The output is not allowed to be aliased with any of the inputs. - # The algorithm used is the Brent-Kung matrix algorithm. - + void _fq_zech_poly_compose_mod_brent_kung_precomp_preinv(fq_zech_struct * res, const fq_zech_struct * f, slong lenf, const fq_zech_mat_t A, const fq_zech_struct * h, slong lenh, const fq_zech_struct * hinv, slong lenhinv, const fq_zech_ctx_t ctx) noexcept void fq_zech_poly_compose_mod_brent_kung_precomp_preinv(fq_zech_poly_t res, const fq_zech_poly_t f, const fq_zech_mat_t A, const fq_zech_poly_t h, const fq_zech_poly_t hinv, const fq_zech_ctx_t ctx) noexcept - # Sets ``res`` to the composition `f(g)` modulo `h`. We require - # that the ith row of `A` contains `g^i` for - # `i=1,\ldots,\sqrt{\deg(h)}`, i.e. `A` is a `\sqrt{\deg(h)}\times - # \deg(h)` matrix. We require that `h` is nonzero and that `f` has - # smaller degree than `h`. Furthermore, we require ``hinv`` to be - # the inverse of the reverse of ``h``. This version of Brent-Kung - # modular composition is particularly useful if one has to perform - # several modular composition of the form `f(g)` modulo `h` for - # fixed `g` and `h`. - - int _fq_zech_poly_fprint_pretty(FILE *file, const fq_zech_struct *poly, slong len, const char *x, const fq_zech_ctx_t ctx) noexcept - # Prints the pretty representation of ``(poly, len)`` to the stream - # ``file``, using the string ``x`` to represent the indeterminate. - # In case of success, returns a positive value. In case of failure, - # returns a non-positive value. - - int fq_zech_poly_fprint_pretty(FILE * file, const fq_zech_poly_t poly, const char *x, const fq_zech_ctx_t ctx) noexcept - # Prints the pretty representation of ``poly`` to the stream - # ``file``, using the string ``x`` to represent the indeterminate. - # In case of success, returns a positive value. In case of failure, - # returns a non-positive value. - - int _fq_zech_poly_print_pretty(const fq_zech_struct *poly, slong len, const char *x, const fq_zech_ctx_t ctx) noexcept - # Prints the pretty representation of ``(poly, len)`` to ``stdout``, - # using the string ``x`` to represent the indeterminate. - # In case of success, returns a positive value. In case of failure, - # returns a non-positive value. - - int fq_zech_poly_print_pretty(const fq_zech_poly_t poly, const char *x, const fq_zech_ctx_t ctx) noexcept - # Prints the pretty representation of ``poly`` to ``stdout``, - # using the string ``x`` to represent the indeterminate. - # In case of success, returns a positive value. In case of failure, - # returns a non-positive value. - - int _fq_zech_poly_fprint(FILE *file, const fq_zech_struct *poly, slong len, const fq_zech_ctx_t ctx) noexcept - # Prints the pretty representation of ``(poly, len)`` to the stream - # ``file``. - # In case of success, returns a positive value. In case of failure, - # returns a non-positive value. - + int _fq_zech_poly_fprint_pretty(FILE * file, const fq_zech_struct * poly, slong len, const char * x, const fq_zech_ctx_t ctx) noexcept + int fq_zech_poly_fprint_pretty(FILE * file, const fq_zech_poly_t poly, const char * x, const fq_zech_ctx_t ctx) noexcept + int _fq_zech_poly_print_pretty(const fq_zech_struct * poly, slong len, const char * x, const fq_zech_ctx_t ctx) noexcept + int fq_zech_poly_print_pretty(const fq_zech_poly_t poly, const char * x, const fq_zech_ctx_t ctx) noexcept + int _fq_zech_poly_fprint(FILE * file, const fq_zech_struct * poly, slong len, const fq_zech_ctx_t ctx) noexcept int fq_zech_poly_fprint(FILE * file, const fq_zech_poly_t poly, const fq_zech_ctx_t ctx) noexcept - # Prints the pretty representation of ``poly`` to the stream - # ``file``. - # In case of success, returns a positive value. In case of failure, - # returns a non-positive value. - - int _fq_zech_poly_print(const fq_zech_struct *poly, slong len, const fq_zech_ctx_t ctx) noexcept - # Prints the pretty representation of ``(poly, len)`` to ``stdout``. - # In case of success, returns a positive value. In case of failure, - # returns a non-positive value. - + int _fq_zech_poly_print(const fq_zech_struct * poly, slong len, const fq_zech_ctx_t ctx) noexcept int fq_zech_poly_print(const fq_zech_poly_t poly, const fq_zech_ctx_t ctx) noexcept - # Prints the representation of ``poly`` to ``stdout``. - # In case of success, returns a positive value. In case of failure, - # returns a non-positive value. - char * _fq_zech_poly_get_str(const fq_zech_struct * poly, slong len, const fq_zech_ctx_t ctx) noexcept - # Returns the plain FLINT string representation of the polynomial - # ``(poly, len)``. - char * fq_zech_poly_get_str(const fq_zech_poly_t poly, const fq_zech_ctx_t ctx) noexcept - # Returns the plain FLINT string representation of the polynomial - # ``poly``. - char * _fq_zech_poly_get_str_pretty(const fq_zech_struct * poly, slong len, const char * x, const fq_zech_ctx_t ctx) noexcept - # Returns a pretty representation of the polynomial - # ``(poly, len)`` using the null-terminated string ``x`` as the - # variable name. - char * fq_zech_poly_get_str_pretty(const fq_zech_poly_t poly, const char * x, const fq_zech_ctx_t ctx) noexcept - # Returns a pretty representation of the polynomial ``poly`` using the - # null-terminated string ``x`` as the variable name - void fq_zech_poly_inflate(fq_zech_poly_t result, const fq_zech_poly_t input, ulong inflation, const fq_zech_ctx_t ctx) noexcept - # Sets ``result`` to the inflated polynomial `p(x^n)` where - # `p` is given by ``input`` and `n` is given by ``inflation``. - void fq_zech_poly_deflate(fq_zech_poly_t result, const fq_zech_poly_t input, ulong deflation, const fq_zech_ctx_t ctx) noexcept - # Sets ``result`` to the deflated polynomial `p(x^{1/n})` where - # `p` is given by ``input`` and `n` is given by ``deflation``. - # Requires `n > 0`. - ulong fq_zech_poly_deflation(const fq_zech_poly_t input, const fq_zech_ctx_t ctx) noexcept - # Returns the largest integer by which ``input`` can be deflated. - # As special cases, returns 0 if ``input`` is the zero polynomial - # and 1 of ``input`` is a constant polynomial. diff --git a/src/sage/libs/flint/fq_zech_poly_factor.pxd b/src/sage/libs/flint/fq_zech_poly_factor.pxd index 8258c7ad359..111ec01ac9f 100644 --- a/src/sage/libs/flint/fq_zech_poly_factor.pxd +++ b/src/sage/libs/flint/fq_zech_poly_factor.pxd @@ -2,7 +2,9 @@ # distutils: depends = flint/fq_zech_poly_factor.h ################################################################################ -# This file is auto-generated. Do not modify by hand +# This file is auto-generated by the script +# SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py. +# Do not modify by hand! Fix and rerun the script instead. ################################################################################ from libc.stdio cimport FILE @@ -11,158 +13,33 @@ from sage.libs.mpfr.types cimport * from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void fq_zech_poly_factor_init(fq_zech_poly_factor_t fac, const fq_zech_ctx_t ctx) noexcept - # Initialises ``fac`` for use. An ``fq_zech_poly_factor_t`` - # represents a polynomial in factorised form as a product of - # polynomials with associated exponents. - void fq_zech_poly_factor_clear(fq_zech_poly_factor_t fac, const fq_zech_ctx_t ctx) noexcept - # Frees all memory associated with ``fac``. - void fq_zech_poly_factor_realloc(fq_zech_poly_factor_t fac, slong alloc, const fq_zech_ctx_t ctx) noexcept - # Reallocates the factor structure to provide space for - # precisely ``alloc`` factors. - void fq_zech_poly_factor_fit_length(fq_zech_poly_factor_t fac, slong len, const fq_zech_ctx_t ctx) noexcept - # Ensures that the factor structure has space for at least - # ``len`` factors. This function takes care of the case of - # repeated calls by always at least doubling the number of factors - # the structure can hold. - void fq_zech_poly_factor_set(fq_zech_poly_factor_t res, const fq_zech_poly_factor_t fac, const fq_zech_ctx_t ctx) noexcept - # Sets ``res`` to the same factorisation as ``fac``. - - void fq_zech_poly_factor_print_pretty(const fq_zech_poly_factor_t fac, const char *var, const fq_zech_ctx_t ctx) noexcept - # Pretty-prints the entries of ``fac`` to standard output. - + void fq_zech_poly_factor_print_pretty(const fq_zech_poly_factor_t fac, const char * var, const fq_zech_ctx_t ctx) noexcept void fq_zech_poly_factor_print(const fq_zech_poly_factor_t fac, const fq_zech_ctx_t ctx) noexcept - # Prints the entries of ``fac`` to standard output. - void fq_zech_poly_factor_insert(fq_zech_poly_factor_t fac, const fq_zech_poly_t poly, slong exp, const fq_zech_ctx_t ctx) noexcept - # Inserts the factor ``poly`` with multiplicity ``exp`` into - # the factorisation ``fac``. - # If ``fac`` already contains ``poly``, then ``exp`` simply - # gets added to the exponent of the existing entry. - void fq_zech_poly_factor_concat(fq_zech_poly_factor_t res, const fq_zech_poly_factor_t fac, const fq_zech_ctx_t ctx) noexcept - # Concatenates two factorisations. - # This is equivalent to calling ``fq_zech_poly_factor_insert()`` - # repeatedly with the individual factors of ``fac``. - # Does not support aliasing between ``res`` and ``fac``. - void fq_zech_poly_factor_pow(fq_zech_poly_factor_t fac, slong exp, const fq_zech_ctx_t ctx) noexcept - # Raises ``fac`` to the power ``exp``. - ulong fq_zech_poly_remove(fq_zech_poly_t f, const fq_zech_poly_t p, const fq_zech_ctx_t ctx) noexcept - # Removes the highest possible power of ``p`` from ``f`` and - # returns the exponent. - bint fq_zech_poly_is_irreducible(const fq_zech_poly_t f, const fq_zech_ctx_t ctx) noexcept - # Returns 1 if the polynomial ``f`` is irreducible, otherwise returns 0. - bint fq_zech_poly_is_irreducible_ddf(const fq_zech_poly_t f, const fq_zech_ctx_t ctx) noexcept - # Returns 1 if the polynomial ``f`` is irreducible, otherwise returns 0. - # Uses fast distinct-degree factorisation. - bint fq_zech_poly_is_irreducible_ben_or(const fq_zech_poly_t f, const fq_zech_ctx_t ctx) noexcept - # Returns 1 if the polynomial ``f`` is irreducible, otherwise returns 0. - # Uses Ben-Or's irreducibility test. - bint _fq_zech_poly_is_squarefree(const fq_zech_struct * f, slong len, const fq_zech_ctx_t ctx) noexcept - # Returns 1 if ``(f, len)`` is squarefree, and 0 otherwise. As a - # special case, the zero polynomial is not considered squarefree. - # There are no restrictions on the length. - bint fq_zech_poly_is_squarefree(const fq_zech_poly_t f, const fq_zech_ctx_t ctx) noexcept - # Returns 1 if ``f`` is squarefree, and 0 otherwise. As a special - # case, the zero polynomial is not considered squarefree. - bint fq_zech_poly_factor_equal_deg_prob(fq_zech_poly_t factor, flint_rand_t state, const fq_zech_poly_t pol, slong d, const fq_zech_ctx_t ctx) noexcept - # Probabilistic equal degree factorisation of ``pol`` into - # irreducible factors of degree ``d``. If it passes, a factor is - # placed in factor and 1 is returned, otherwise 0 is returned and - # the value of factor is undetermined. - # Requires that ``pol`` be monic, non-constant and squarefree. - void fq_zech_poly_factor_equal_deg(fq_zech_poly_factor_t factors, const fq_zech_poly_t pol, slong d, const fq_zech_ctx_t ctx) noexcept - # Assuming ``pol`` is a product of irreducible factors all of - # degree ``d``, finds all those factors and places them in - # factors. Requires that ``pol`` be monic, non-constant and - # squarefree. - void fq_zech_poly_factor_split_single(fq_zech_poly_t linfactor, const fq_zech_poly_t input, const fq_zech_ctx_t ctx) noexcept - # Assuming ``input`` is a product of factors all of degree 1, finds a single - # linear factor of ``input`` and places it in ``linfactor``. - # Requires that ``input`` be monic and non-constant. - - void fq_zech_poly_factor_distinct_deg(fq_zech_poly_factor_t res, const fq_zech_poly_t poly, slong * const *degs, const fq_zech_ctx_t ctx) noexcept - # Factorises a monic non-constant squarefree polynomial ``poly`` - # of degree `n` into factors `f[d]` such that for `1 \leq d \leq n` - # `f[d]` is the product of the monic irreducible factors of - # ``poly`` of degree `d`. Factors are stored in ``res``, - # associated powers of irreducible polynomials are stored in - # ``degs`` in the same order as factors. - # Requires that ``degs`` have enough space for irreducible polynomials' - # powers (maximum space required is `n * sizeof(slong)`). - + void fq_zech_poly_factor_distinct_deg(fq_zech_poly_factor_t res, const fq_zech_poly_t poly, slong * const * degs, const fq_zech_ctx_t ctx) noexcept void fq_zech_poly_factor_squarefree(fq_zech_poly_factor_t res, const fq_zech_poly_t f, const fq_zech_ctx_t ctx) noexcept - # Sets ``res`` to a squarefree factorization of ``f``. - void fq_zech_poly_factor(fq_zech_poly_factor_t res, fq_zech_t lead, const fq_zech_poly_t f, const fq_zech_ctx_t ctx) noexcept - # Factorises a non-constant polynomial ``f`` into monic - # irreducible factors choosing the best algorithm for given modulo - # and degree. The output ``lead`` is set to the leading coefficient of `f` - # upon return. Choice of algorithm is based on heuristic measurements. - void fq_zech_poly_factor_cantor_zassenhaus(fq_zech_poly_factor_t res, const fq_zech_poly_t f, const fq_zech_ctx_t ctx) noexcept - # Factorises a non-constant polynomial ``f`` into monic - # irreducible factors using the Cantor-Zassenhaus algorithm. - void fq_zech_poly_factor_kaltofen_shoup(fq_zech_poly_factor_t res, const fq_zech_poly_t poly, const fq_zech_ctx_t ctx) noexcept - # Factorises a non-constant polynomial ``f`` into monic - # irreducible factors using the fast version of Cantor-Zassenhaus - # algorithm proposed by Kaltofen and Shoup (1998). More precisely - # this algorithm uses a “baby step/giant step” strategy for the - # distinct-degree factorization step. - void fq_zech_poly_factor_berlekamp(fq_zech_poly_factor_t factors, const fq_zech_poly_t f, const fq_zech_ctx_t ctx) noexcept - # Factorises a non-constant polynomial ``f`` into monic - # irreducible factors using the Berlekamp algorithm. - void fq_zech_poly_factor_with_berlekamp(fq_zech_poly_factor_t res, fq_zech_t leading_coeff, const fq_zech_poly_t f, const fq_zech_ctx_t ctx) noexcept - # Factorises a general polynomial ``f`` into monic irreducible - # factors and sets ``leading_coeff`` to the leading coefficient - # of ``f``, or 0 if ``f`` is the zero polynomial. - # This function first checks for small special cases, deflates - # ``f`` if it is of the form `p(x^m)` for some `m > 1`, then - # performs a square-free factorisation, and finally runs Berlekamp - # on all the individual square-free factors. - void fq_zech_poly_factor_with_cantor_zassenhaus(fq_zech_poly_factor_t res, fq_zech_t leading_coeff, const fq_zech_poly_t f, const fq_zech_ctx_t ctx) noexcept - # Factorises a general polynomial ``f`` into monic irreducible - # factors and sets ``leading_coeff`` to the leading coefficient - # of ``f``, or 0 if ``f`` is the zero polynomial. - # This function first checks for small special cases, deflates - # ``f`` if it is of the form `p(x^m)` for some `m > 1`, then - # performs a square-free factorisation, and finally runs - # Cantor-Zassenhaus on all the individual square-free factors. - void fq_zech_poly_factor_with_kaltofen_shoup(fq_zech_poly_factor_t res, fq_zech_t leading_coeff, const fq_zech_poly_t f, const fq_zech_ctx_t ctx) noexcept - # Factorises a general polynomial ``f`` into monic irreducible - # factors and sets ``leading_coeff`` to the leading coefficient - # of ``f``, or 0 if ``f`` is the zero polynomial. - # This function first checks for small special cases, deflates - # ``f`` if it is of the form `p(x^m)` for some `m > 1`, then - # performs a square-free factorisation, and finally runs - # Kaltofen-Shoup on all the individual square-free factors. - - void fq_zech_poly_iterated_frobenius_preinv(fq_zech_poly_t *rop, slong n, const fq_zech_poly_t v, const fq_zech_poly_t vinv, const fq_zech_ctx_t ctx) noexcept - # Sets ``rop[i]`` to be `x^{q^i} \bmod v` for `0 \le i < n`. - # It is required that ``vinv`` is the inverse of the reverse of - # ``v`` mod ``x^lenv``. - + void fq_zech_poly_iterated_frobenius_preinv(fq_zech_poly_t * rop, slong n, const fq_zech_poly_t v, const fq_zech_poly_t vinv, const fq_zech_ctx_t ctx) noexcept void fq_zech_poly_roots(fq_zech_poly_factor_t r, const fq_zech_poly_t f, int with_multiplicity, const fq_zech_ctx_t ctx) noexcept - # Fill `r` with factors of the form `x - r_i` where the `r_i` are the distinct roots of a nonzero `f` in `F_q`. - # If `with\_multiplicity` is zero, the exponent `e_i` of the factor `x - r_i` is `1`. Otherwise, it is the largest `e_i` such that `(x-r_i)^e_i` divides `f`. - # This function throws if `f` is zero, but is otherwise always successful. diff --git a/src/sage/libs/flint/fq_zech_vec.pxd b/src/sage/libs/flint/fq_zech_vec.pxd index 447a626e6ec..02c71129d70 100644 --- a/src/sage/libs/flint/fq_zech_vec.pxd +++ b/src/sage/libs/flint/fq_zech_vec.pxd @@ -2,7 +2,9 @@ # distutils: depends = flint/fq_zech_vec.h ################################################################################ -# This file is auto-generated. Do not modify by hand +# This file is auto-generated by the script +# SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py. +# Do not modify by hand! Fix and rerun the script instead. ################################################################################ from libc.stdio cimport FILE @@ -11,63 +13,19 @@ from sage.libs.mpfr.types cimport * from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - fq_zech_struct * _fq_zech_vec_init(slong len, const fq_zech_ctx_t ctx) noexcept - # Returns an initialised vector of ``fq_zech``'s of given length. - void _fq_zech_vec_clear(fq_zech_struct * vec, slong len, const fq_zech_ctx_t ctx) noexcept - # Clears the entries of ``(vec, len)`` and frees the space allocated - # for ``vec``. - void _fq_zech_vec_randtest(fq_zech_struct * f, flint_rand_t state, slong len, const fq_zech_ctx_t ctx) noexcept - # Sets the entries of a vector of the given length to elements of - # the finite field. - int _fq_zech_vec_fprint(FILE * file, const fq_zech_struct * vec, slong len, const fq_zech_ctx_t ctx) noexcept - # Prints the vector of given length to the stream ``file``. The - # format is the length followed by two spaces, then a space separated - # list of coefficients. If the length is zero, only `0` is printed. - # In case of success, returns a positive value. In case of failure, - # returns a non-positive value. - int _fq_zech_vec_print(const fq_zech_struct * vec, slong len, const fq_zech_ctx_t ctx) noexcept - # Prints the vector of given length to ``stdout``. - # For further details, see ``_fq_zech_vec_fprint()``. - void _fq_zech_vec_set(fq_zech_struct * vec1, const fq_zech_struct * vec2, slong len2, const fq_zech_ctx_t ctx) noexcept - # Makes a copy of ``(vec2, len2)`` into ``vec1``. - void _fq_zech_vec_swap(fq_zech_struct * vec1, fq_zech_struct * vec2, slong len2, const fq_zech_ctx_t ctx) noexcept - # Swaps the elements in ``(vec1, len2)`` and ``(vec2, len2)``. - void _fq_zech_vec_zero(fq_zech_struct * vec, slong len, const fq_zech_ctx_t ctx) noexcept - # Zeros the entries of ``(vec, len)``. - void _fq_zech_vec_neg(fq_zech_struct * vec1, const fq_zech_struct * vec2, slong len2, const fq_zech_ctx_t ctx) noexcept - # Negates ``(vec2, len2)`` and places it into ``vec1``. - bint _fq_zech_vec_equal(const fq_zech_struct * vec1, const fq_zech_struct * vec2, slong len, const fq_zech_ctx_t ctx) noexcept - # Compares two vectors of the given length and returns `1` if they are - # equal, otherwise returns `0`. - bint _fq_zech_vec_is_zero(const fq_zech_struct * vec, slong len, const fq_zech_ctx_t ctx) noexcept - # Returns `1` if ``(vec, len)`` is zero, and `0` otherwise. - void _fq_zech_vec_add(fq_zech_struct * res, const fq_zech_struct * vec1, const fq_zech_struct * vec2, slong len2, const fq_zech_ctx_t ctx) noexcept - # Sets ``(res, len2)`` to the sum of ``(vec1, len2)`` - # and ``(vec2, len2)``. - void _fq_zech_vec_sub(fq_zech_struct * res, const fq_zech_struct * vec1, const fq_zech_struct * vec2, slong len2, const fq_zech_ctx_t ctx) noexcept - # Sets ``(res, len2)`` to ``(vec1, len2)`` minus ``(vec2, len2)``. - void _fq_zech_vec_scalar_addmul_fq_zech(fq_zech_struct * vec1, const fq_zech_struct * vec2, slong len2, const fq_zech_t c, const fq_zech_ctx_t ctx) noexcept - # Adds ``(vec2, len2)`` times `c` to ``(vec1, len2)``, where - # `c` is a ``fq_zech_t``. - void _fq_zech_vec_scalar_submul_fq_zech(fq_zech_struct * vec1, const fq_zech_struct * vec2, slong len2, const fq_zech_t c, const fq_zech_ctx_t ctx) noexcept - # Subtracts ``(vec2, len2)`` times `c` from ``(vec1, len2)``, - # where `c` is a ``fq_zech_t``. - void _fq_zech_vec_dot(fq_zech_t res, const fq_zech_struct * vec1, const fq_zech_struct * vec2, slong len2, const fq_zech_ctx_t ctx) noexcept - # Sets ``res`` to the dot product of (``vec1``, ``len``) - # and (``vec2``, ``len``). diff --git a/src/sage/libs/flint/gr.pxd b/src/sage/libs/flint/gr.pxd index 894f0d121c1..2d15538d94d 100644 --- a/src/sage/libs/flint/gr.pxd +++ b/src/sage/libs/flint/gr.pxd @@ -2,7 +2,9 @@ # distutils: depends = flint/gr.h ################################################################################ -# This file is auto-generated. Do not modify by hand +# This file is auto-generated by the script +# SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py. +# Do not modify by hand! Fix and rerun the script instead. ################################################################################ from libc.stdio cimport FILE @@ -11,177 +13,61 @@ from sage.libs.mpfr.types cimport * from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - slong gr_ctx_sizeof_elem(gr_ctx_t ctx) noexcept - # Return ``sizeof(type)`` where ``type`` is the underlying C - # type for elements of *ctx*. - int gr_ctx_clear(gr_ctx_t ctx) noexcept - # Clears the context object *ctx*, freeing any memory - # allocated by this object. - # Some context objects may require that no elements are cleared after calling - # this method, and may leak memory if not all elements have - # been cleared when calling this method. - # If *ctx* is derived from a base ring, the base ring context - # may also be required to stay alive until after this - # method is called. - int gr_ctx_write(gr_stream_t out, gr_ctx_t ctx) noexcept int gr_ctx_print(gr_ctx_t ctx) noexcept int gr_ctx_println(gr_ctx_t ctx) noexcept int gr_ctx_get_str(char ** s, gr_ctx_t ctx) noexcept - # Writes a description of the structure *ctx* to the stream *out*, - # prints it to *stdout*, or sets *s* to a pointer to - # a heap-allocated string of the description (the user must free - # the string with ``flint_free``). - # The *println* version prints a trailing newline. - int gr_ctx_set_gen_name(gr_ctx_t ctx, const char * s) noexcept int gr_ctx_set_gen_names(gr_ctx_t ctx, const char ** s) noexcept - # Set the name of the generator (univariate polynomial ring, - # finite field, etc.) or generators (multivariate). - # The name is used when printing and may be used to choose - # coercions. - void gr_init(gr_ptr res, gr_ctx_t ctx) noexcept - # Initializes *res* to a valid variable and sets it to the - # zero element of the ring *ctx*. - void gr_clear(gr_ptr res, gr_ctx_t ctx) noexcept - # Clears *res*, freeing any memory allocated by this object. - void gr_swap(gr_ptr x, gr_ptr y, gr_ctx_t ctx) noexcept - # Swaps *x* and *y* efficiently. - void gr_set_shallow(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept - # Sets *res* to a shallow copy of *x*, copying the struct data. - gr_ptr gr_heap_init(gr_ctx_t ctx) noexcept - # Return a pointer to a single new heap-allocated element of *ctx* - # set to 0. - void gr_heap_clear(gr_ptr x, gr_ctx_t ctx) noexcept - # Free the single heap-allocated element *x* of *ctx* which should - # have been created with :func:`gr_heap_init`. - gr_ptr gr_heap_init_vec(slong len, gr_ctx_t ctx) noexcept - # Return a pointer to a new heap-allocated vector of *len* - # initialized elements. - void gr_heap_clear_vec(gr_ptr x, slong len, gr_ctx_t ctx) noexcept - # Clear the *len* elements in the heap-allocated vector *len* and - # free the vector itself. - int gr_randtest(gr_ptr res, flint_rand_t state, gr_ctx_t ctx) noexcept - # Sets *res* to a random element of the domain *ctx*. - # The distribution is determined by the implementation. - # Typically the distribution is non-uniform in order to - # find corner cases more easily in test code. - int gr_randtest_not_zero(gr_ptr res, flint_rand_t state, gr_ctx_t ctx) noexcept - # Sets *res* to a random nonzero element of the domain *ctx*. - # This operation will fail and return ``GR_DOMAIN`` in the zero ring. - int gr_randtest_small(gr_ptr res, flint_rand_t state, gr_ctx_t ctx) noexcept - # Sets *res* to a "small" element of the domain *ctx*. - # This is suitable for randomized testing where a "large" argument - # could result in excessive computation time. - int gr_write(gr_stream_t out, gr_srcptr x, gr_ctx_t ctx) noexcept int gr_print(gr_srcptr x, gr_ctx_t ctx) noexcept int gr_println(gr_srcptr x, gr_ctx_t ctx) noexcept int gr_get_str(char ** s, gr_srcptr x, gr_ctx_t ctx) noexcept - # Writes a description of the element *x* to the stream *out*, - # or prints it to *stdout*, or sets *s* to a pointer to - # a heap-allocated string of the description (the user must free - # the string with ``flint_free``). The *println* version prints a - # trailing newline. - int gr_set_str(gr_ptr res, const char * x, gr_ctx_t ctx) noexcept - # Sets *res* to the string description in *x*. - int gr_write_n(gr_stream_t out, gr_srcptr x, slong n, gr_ctx_t ctx) noexcept int gr_get_str_n(char ** s, gr_srcptr x, slong n, gr_ctx_t ctx) noexcept - # String conversion where real and complex numbers may be rounded - # to *n* digits. - int gr_set(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept - # Sets *res* to a copy of the element *x*. - int gr_set_other(gr_ptr res, gr_srcptr x, gr_ctx_t x_ctx, gr_ctx_t ctx) noexcept - # Sets *res* to the element *x* of the structure *x_ctx* which - # may be different from *ctx*. This returns the ``GR_DOMAIN`` flag - # if *x* is not an element of *ctx* or cannot be converted - # unambiguously to *ctx*. The ``GR_UNABLE`` flag is returned - # if the conversion is not implemented. - int gr_set_ui(gr_ptr res, ulong x, gr_ctx_t ctx) noexcept int gr_set_si(gr_ptr res, slong x, gr_ctx_t ctx) noexcept int gr_set_fmpz(gr_ptr res, const fmpz_t x, gr_ctx_t ctx) noexcept int gr_set_fmpq(gr_ptr res, const fmpq_t x, gr_ctx_t ctx) noexcept int gr_set_d(gr_ptr res, double x, gr_ctx_t ctx) noexcept - # Sets *res* to the value *x*. If no reasonable conversion to the - # domain *ctx* is possible, returns ``GR_DOMAIN``. - int gr_get_si(slong * res, gr_srcptr x, gr_ctx_t ctx) noexcept int gr_get_ui(ulong * res, gr_srcptr x, gr_ctx_t ctx) noexcept int gr_get_fmpz(fmpz_t res, gr_srcptr x, gr_ctx_t ctx) noexcept int gr_get_fmpq(fmpq_t res, gr_srcptr x, gr_ctx_t ctx) noexcept int gr_get_d(double * res, gr_srcptr x, gr_ctx_t ctx) noexcept - # Sets *res* to the value *x*. This returns the ``GR_DOMAIN`` flag - # if *x* cannot be converted to the target type. - # For floating-point output types, the output may be rounded. - int gr_set_fmpz_2exp_fmpz(gr_ptr res, const fmpz_t x, const fmpz_t y, gr_ctx_t ctx) noexcept int gr_get_fmpz_2exp_fmpz(fmpz_t res1, fmpz_t res2, gr_srcptr x, gr_ctx_t ctx) noexcept - # Set or retrieve a dyadic number. - int gr_get_fexpr(fexpr_t res, gr_srcptr x, gr_ctx_t ctx) noexcept int gr_get_fexpr_serialize(fexpr_t res, gr_srcptr x, gr_ctx_t ctx) noexcept - # Sets *res* to a symbolic expression representing *x*. - # The *serialize* version may generate a representation of the - # internal representation which is not intended to be human-readable. - int gr_set_fexpr(gr_ptr res, fexpr_vec_t inputs, gr_vec_t outputs, const fexpr_t x, gr_ctx_t ctx) noexcept - # Sets *res* to the evaluation of the expression *x* in the - # given ring or structure. - # The user must provide vectors *inputs* and *outputs* which - # may be empty initially and which may be used as scratch space - # during evaluation. Non-empty vectors may be given to map symbols - # to predefined values. - int gr_zero(gr_ptr res, gr_ctx_t ctx) noexcept int gr_one(gr_ptr res, gr_ctx_t ctx) noexcept int gr_neg_one(gr_ptr res, gr_ctx_t ctx) noexcept - # Sets *res* to the ring element 0, 1 or -1. - int gr_gen(gr_ptr res, gr_ctx_t ctx) noexcept - # Sets *res* to a generator of this domain. The meaning of - # "generator" depends on the domain. - int gr_gens(gr_vec_t res, gr_ctx_t ctx) noexcept - # Sets *res* to a vector containing the generators of this domain - # where this makes sense, for example in a multivariate polynomial - # ring. - truth_t gr_is_zero(gr_srcptr x, gr_ctx_t ctx) noexcept truth_t gr_is_one(gr_srcptr x, gr_ctx_t ctx) noexcept truth_t gr_is_neg_one(gr_srcptr x, gr_ctx_t ctx) noexcept - # Returns whether *x* is equal to the ring element 0, 1 or -1, - # respectively. - truth_t gr_equal(gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) noexcept - # Returns whether the elements *x* and *y* are equal. - truth_t gr_is_integer(gr_srcptr x, gr_ctx_t ctx) noexcept - # Returns whether *x* represents an integer. - truth_t gr_is_rational(gr_srcptr x, gr_ctx_t ctx) noexcept - # Returns whether *x* represents a rational number. - int gr_neg(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept - # Sets *res* to `-x`. - int gr_add(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) noexcept int gr_add_ui(gr_ptr res, gr_srcptr x, ulong y, gr_ctx_t ctx) noexcept int gr_add_si(gr_ptr res, gr_srcptr x, slong y, gr_ctx_t ctx) noexcept @@ -189,8 +75,6 @@ cdef extern from "flint_wrap.h": int gr_add_fmpq(gr_ptr res, gr_srcptr x, const fmpq_t y, gr_ctx_t ctx) noexcept int gr_add_other(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t y_ctx, gr_ctx_t ctx) noexcept int gr_other_add(gr_ptr res, gr_srcptr x, gr_ctx_t x_ctx, gr_srcptr y, gr_ctx_t ctx) noexcept - # Sets *res* to `x + y`. - int gr_sub(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) noexcept int gr_sub_ui(gr_ptr res, gr_srcptr x, ulong y, gr_ctx_t ctx) noexcept int gr_sub_si(gr_ptr res, gr_srcptr x, slong y, gr_ctx_t ctx) noexcept @@ -198,8 +82,6 @@ cdef extern from "flint_wrap.h": int gr_sub_fmpq(gr_ptr res, gr_srcptr x, const fmpq_t y, gr_ctx_t ctx) noexcept int gr_sub_other(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t y_ctx, gr_ctx_t ctx) noexcept int gr_other_sub(gr_ptr res, gr_srcptr x, gr_ctx_t x_ctx, gr_srcptr y, gr_ctx_t ctx) noexcept - # Sets *res* to `x - y`. - int gr_mul(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) noexcept int gr_mul_ui(gr_ptr res, gr_srcptr x, ulong y, gr_ctx_t ctx) noexcept int gr_mul_si(gr_ptr res, gr_srcptr x, slong y, gr_ctx_t ctx) noexcept @@ -207,44 +89,24 @@ cdef extern from "flint_wrap.h": int gr_mul_fmpq(gr_ptr res, gr_srcptr x, const fmpq_t y, gr_ctx_t ctx) noexcept int gr_mul_other(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t y_ctx, gr_ctx_t ctx) noexcept int gr_other_mul(gr_ptr res, gr_srcptr x, gr_ctx_t x_ctx, gr_srcptr y, gr_ctx_t ctx) noexcept - # Sets *res* to `x \cdot y`. - int gr_addmul(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) noexcept int gr_addmul_ui(gr_ptr res, gr_srcptr x, ulong y, gr_ctx_t ctx) noexcept int gr_addmul_si(gr_ptr res, gr_srcptr x, slong y, gr_ctx_t ctx) noexcept int gr_addmul_fmpz(gr_ptr res, gr_srcptr x, const fmpz_t y, gr_ctx_t ctx) noexcept int gr_addmul_fmpq(gr_ptr res, gr_srcptr x, const fmpq_t y, gr_ctx_t ctx) noexcept int gr_addmul_other(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t y_ctx, gr_ctx_t ctx) noexcept - # Sets *res* to `\mathrm{res } + x \cdot y`. - # Rings may override the default - # implementation to perform this operation in one step without - # allocating a temporary variable, without intermediate rounding, etc. - int gr_submul(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) noexcept int gr_submul_ui(gr_ptr res, gr_srcptr x, ulong y, gr_ctx_t ctx) noexcept int gr_submul_si(gr_ptr res, gr_srcptr x, slong y, gr_ctx_t ctx) noexcept int gr_submul_fmpz(gr_ptr res, gr_srcptr x, const fmpz_t y, gr_ctx_t ctx) noexcept int gr_submul_fmpq(gr_ptr res, gr_srcptr x, const fmpq_t y, gr_ctx_t ctx) noexcept int gr_submul_other(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t y_ctx, gr_ctx_t ctx) noexcept - # Sets *res* to `\mathrm{res } - x \cdot y`. - # Rings may override the default - # implementation to perform this operation in one step without - # allocating a temporary variable, without intermediate rounding, etc. - int gr_mul_two(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept - # Sets *res* to `2x`. The default implementation adds *x* - # to itself. - int gr_sqr(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept - # Sets *res* to `x ^ 2`. The default implementation multiplies *x* - # with itself. - int gr_mul_2exp_si(gr_ptr res, gr_srcptr x, slong y, gr_ctx_t ctx) noexcept int gr_mul_2exp_fmpz(gr_ptr res, gr_srcptr x, const fmpz_t y, gr_ctx_t ctx) noexcept - # Sets *res* to `x \cdot 2^y`. This may perform `x \cdot 2^{-y}` - # when *y* is negative, allowing exact division by powers of two - # even if `2^{y}` is not representable. - + truth_t gr_is_invertible(gr_srcptr x, gr_ctx_t ctx) noexcept + int gr_inv(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept int gr_div(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) noexcept int gr_div_ui(gr_ptr res, gr_srcptr x, ulong y, gr_ctx_t ctx) noexcept int gr_div_si(gr_ptr res, gr_srcptr x, slong y, gr_ctx_t ctx) noexcept @@ -252,55 +114,17 @@ cdef extern from "flint_wrap.h": int gr_div_fmpq(gr_ptr res, gr_srcptr x, const fmpq_t y, gr_ctx_t ctx) noexcept int gr_div_other(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t y_ctx, gr_ctx_t ctx) noexcept int gr_other_div(gr_ptr res, gr_srcptr x, gr_ctx_t x_ctx, gr_srcptr y, gr_ctx_t ctx) noexcept - # Sets *res* to the quotient `x / y` if such an element exists - # in the present ring. Returns the flag ``GR_DOMAIN`` if no such - # quotient exists. - # Returns the flag ``GR_UNABLE`` if the implementation is unable - # to perform the computation. - # When the ring is not a field, the definition of division may - # vary depending on the ring. A ring implementation may define - # `x / y = x y^{-1}` and return ``GR_DOMAIN`` when `y^{-1}` does not - # exist; alternatively, it may attempt to solve the equation - # `q y = x` (which, for example, gives the usual exact - # division in `\mathbb{Z}`). - - truth_t gr_is_invertible(gr_srcptr x, gr_ctx_t ctx) noexcept - # Returns whether *x* has a multiplicative inverse in the present ring, - # i.e. whether *x* is a unit. - - int gr_inv(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept - # Sets *res* to the multiplicative inverse of *x* in the present ring, - # if such an element exists. - # Returns the flag ``GR_DOMAIN`` if *x* is not invertible, or - # ``GR_UNABLE`` if the implementation is unable to perform - # the computation. - - truth_t gr_divides(gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) noexcept - # Returns whether *x* divides *y*. - + int gr_div_nonunique(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) noexcept + truth_t gr_divides(gr_srcptr d, gr_srcptr x, gr_ctx_t ctx) noexcept int gr_divexact(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) noexcept int gr_divexact_ui(gr_ptr res, gr_srcptr x, ulong y, gr_ctx_t ctx) noexcept int gr_divexact_si(gr_ptr res, gr_srcptr x, slong y, gr_ctx_t ctx) noexcept int gr_divexact_fmpz(gr_ptr res, gr_srcptr x, const fmpz_t y, gr_ctx_t ctx) noexcept int gr_divexact_other(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t y_ctx, gr_ctx_t ctx) noexcept int gr_other_divexact(gr_ptr res, gr_srcptr x, gr_ctx_t x_ctx, gr_srcptr y, gr_ctx_t ctx) noexcept - # Sets *res* to the quotient `x / y`, assuming that this quotient - # is exact in the present ring. - # Rings may optimize this operation by not verifying that the - # division is possible. If the division is not actually exact, the - # implementation may set *res* to a nonsense value and still - # return the ``GR_SUCCESS`` flag. - int gr_euclidean_div(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) noexcept int gr_euclidean_rem(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) noexcept int gr_euclidean_divrem(gr_ptr res1, gr_ptr res2, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) noexcept - # In a Euclidean ring, these functions perform some version of Euclidean - # division with remainder, where the choice of quotient is - # implementation-defined. For example, it is standard to use - # the round-to-floor quotient in `\mathbb{Z}` and a round-to-nearest quotient in `\mathbb{Z}[i]`. - # In non-Euclidean rings, these functions may implement some generalization of - # Euclidean division with remainder. - int gr_pow(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) noexcept int gr_pow_ui(gr_ptr res, gr_srcptr x, ulong y, gr_ctx_t ctx) noexcept int gr_pow_si(gr_ptr res, gr_srcptr x, slong y, gr_ctx_t ctx) noexcept @@ -308,122 +132,41 @@ cdef extern from "flint_wrap.h": int gr_pow_fmpq(gr_ptr res, gr_srcptr x, const fmpq_t y, gr_ctx_t ctx) noexcept int gr_pow_other(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t y_ctx, gr_ctx_t ctx) noexcept int gr_other_pow(gr_ptr res, gr_srcptr x, gr_ctx_t x_ctx, gr_srcptr y, gr_ctx_t ctx) noexcept - # Sets *res* to the power `x ^ y`, the interpretation of which - # depends on the ring when `y \not \in \mathbb{Z}`. - # Returns the flag ``GR_DOMAIN`` if this power cannot be assigned - # a meaningful value in the present ring, or ``GR_UNABLE`` if - # the implementation is unable to perform the computation. - # For subrings of `\mathbb{C}`, it is implied that the principal - # power `x^y = \exp(y \log(x))` is computed for `x \ne 0`. - # Default implementations of the powering methods support raising - # elements to integer powers using a generic implementation of - # exponentiation by squaring. Particular rings - # should override these methods with faster versions or - # to support more general notions of exponentiation when possible. - truth_t gr_is_square(gr_srcptr x, gr_ctx_t ctx) noexcept - # Returns whether *x* is a perfect square in the present ring. - int gr_sqrt(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept int gr_rsqrt(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept - # Sets *res* to a square root of *x* (respectively reciprocal - # square root) in the present ring, if such an element exists. - # Returns the flag ``GR_DOMAIN`` if *x* is not a perfect square - # (also for zero, when computing the reciprocal square root), or - # ``GR_UNABLE`` if the implementation is unable to perform - # the computation. - int gr_gcd(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) noexcept - # Sets *res* to a greatest common divisor (GCD) of *x* and *y*. - # Since the GCD is unique only up to multiplication by a unit, - # an implementation-defined representative is chosen. - int gr_lcm(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) noexcept - # Sets *res* to a least common multiple (LCM) of *x* and *y*. - # Since the LCM is unique only up to multiplication by a unit, - # an implementation-defined representative is chosen. - int gr_factor(gr_ptr c, gr_vec_t factors, gr_vec_t exponents, gr_srcptr x, int flags, gr_ctx_t ctx) noexcept - # Given `x \in R`, computes a factorization - # `x = c {f_1}^{e_1} \ldots {f_n}^{e_n}` - # where `f_k` will be irreducible or prime (depending on `R`). - # The prefactor `c` stores a unit, sign, or coefficient, e.g.\ the - # sign `-1`, `0` or `+1` in `\mathbb{Z}`, or a sign multiplied - # by the coefficient content in `\mathbb{Z}[x]`. - # Note that this function outputs `c` as an element of the - # same ring as the input: for example, in `\mathbb{Z}[x]`, - # `c` will be a constant polynomial rather than an - # element of the coefficient ring. - # The exponents `e_k` are output as a vector of ``fmpz`` elements. - # The factors `f_k` are guaranteed to be distinct, - # but they are not guaranteed to be sorted in any particular - # order. - int gr_numerator(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept int gr_denominator(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept - # Return a numerator `p` and denominator `q` such that `x = p/q`. - # For typical fraction fields, the denominator will be minimal - # and canonical. - # However, some rings may return an arbitrary denominator as long - # as the numerator matches. - # The default implementations simply return `p = x` and `q = 1`. - int gr_floor(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept int gr_ceil(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept int gr_trunc(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept int gr_nint(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept - # In the real and complex numbers, sets *res* to the integer closest - # to *x*, respectively rounding towards minus infinity, plus infinity, - # zero, or the nearest integer (with tie-to-even). - int gr_abs(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept - # Sets *res* to the absolute value of *x*, which maybe defined - # both in complex rings and in any ordered ring. - int gr_i(gr_ptr res, gr_ctx_t ctx) noexcept - # Sets *res* to the imaginary unit. - int gr_conj(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept int gr_re(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept int gr_im(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept int gr_sgn(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept int gr_csgn(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept int gr_arg(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept - # These methods may return the flag ``GR_DOMAIN`` (or ``GR_UNABLE``) - # when the ring is not a subring of the real or complex numbers. - int gr_pos_inf(gr_ptr res, gr_ctx_t ctx) noexcept int gr_neg_inf(gr_ptr res, gr_ctx_t ctx) noexcept int gr_uinf(gr_ptr res, gr_ctx_t ctx) noexcept int gr_undefined(gr_ptr res, gr_ctx_t ctx) noexcept int gr_unknown(gr_ptr res, gr_ctx_t ctx) noexcept - int gr_cmp(int * res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) noexcept int gr_cmp_other(int * res, gr_srcptr x, gr_srcptr y, gr_ctx_t y_ctx, gr_ctx_t ctx) noexcept - # Sets *res* to -1, 0 or 1 according to whether *x* is less than, - # equal or greater than the absolute value of *y*. - # This may return ``GR_DOMAIN`` if the ring is not an ordered ring. - int gr_cmpabs(int * res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) noexcept int gr_cmpabs_other(int * res, gr_srcptr x, gr_srcptr y, gr_ctx_t y_ctx, gr_ctx_t ctx) noexcept - # Sets *res* to -1, 0 or 1 according to whether the absolute value - # of *x* is less than, equal or greater than the absolute value of *y*. - # This may return ``GR_DOMAIN`` if the ring is not an ordered ring. - int gr_ctx_fq_prime(fmpz_t p, gr_ctx_t ctx) noexcept - int gr_ctx_fq_degree(slong * deg, gr_ctx_t ctx) noexcept - int gr_ctx_fq_order(fmpz_t q, gr_ctx_t ctx) noexcept - int gr_fq_frobenius(gr_ptr res, gr_srcptr x, slong e, gr_ctx_t ctx) noexcept - int gr_fq_multiplicative_order(fmpz_t res, gr_srcptr x, gr_ctx_t ctx) noexcept - int gr_fq_norm(fmpz_t res, gr_srcptr x, gr_ctx_t ctx) noexcept - int gr_fq_trace(fmpz_t res, gr_srcptr x, gr_ctx_t ctx) noexcept - truth_t gr_fq_is_primitive(gr_srcptr x, gr_ctx_t ctx) noexcept - int gr_fq_pth_root(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept diff --git a/src/sage/libs/flint/gr_generic.pxd b/src/sage/libs/flint/gr_generic.pxd index 1065194c445..9bdf9a80232 100644 --- a/src/sage/libs/flint/gr_generic.pxd +++ b/src/sage/libs/flint/gr_generic.pxd @@ -2,7 +2,9 @@ # distutils: depends = flint/gr_generic.h ################################################################################ -# This file is auto-generated. Do not modify by hand +# This file is auto-generated by the script +# SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py. +# Do not modify by hand! Fix and rerun the script instead. ################################################################################ from libc.stdio cimport FILE @@ -11,7 +13,6 @@ from sage.libs.mpfr.types cimport * from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void gr_generic_init() noexcept void gr_generic_clear() noexcept void gr_generic_swap() noexcept @@ -28,124 +29,88 @@ cdef extern from "flint_wrap.h": void gr_generic_add() noexcept void gr_generic_sub() noexcept void gr_generic_mul() noexcept - int gr_generic_ctx_clear(gr_ctx_t ctx) noexcept - void gr_generic_set_shallow(gr_ptr res, gr_srcptr x, const gr_ctx_t ctx) noexcept - int gr_generic_write_n(gr_stream_t out, gr_srcptr x, slong n, gr_ctx_t ctx) noexcept - int gr_generic_randtest_not_zero(gr_ptr x, flint_rand_t state, gr_ctx_t ctx) noexcept - int gr_generic_randtest_small(gr_ptr x, flint_rand_t state, gr_ctx_t ctx) noexcept - truth_t gr_generic_is_zero(gr_srcptr x, gr_ctx_t ctx) noexcept truth_t gr_generic_is_one(gr_srcptr x, gr_ctx_t ctx) noexcept truth_t gr_generic_is_neg_one(gr_srcptr x, gr_ctx_t ctx) noexcept - int gr_generic_neg_one(gr_ptr res, gr_ctx_t ctx) noexcept - int gr_generic_set_other(gr_ptr res, gr_srcptr x, gr_ctx_t xctx, gr_ctx_t ctx) noexcept int gr_generic_set_fmpq(gr_ptr res, const fmpq_t y, gr_ctx_t ctx) noexcept - int gr_generic_add_fmpz(gr_ptr res, gr_srcptr x, const fmpz_t y, gr_ctx_t ctx) noexcept int gr_generic_add_ui(gr_ptr res, gr_srcptr x, ulong y, gr_ctx_t ctx) noexcept int gr_generic_add_si(gr_ptr res, gr_srcptr x, slong y, gr_ctx_t ctx) noexcept int gr_generic_add_fmpq(gr_ptr res, gr_srcptr x, const fmpq_t y, gr_ctx_t ctx) noexcept int gr_generic_add_other(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t y_ctx, gr_ctx_t ctx) noexcept int gr_generic_other_add(gr_ptr res, gr_srcptr x, gr_ctx_t x_ctx, gr_srcptr y, gr_ctx_t ctx) noexcept - int gr_generic_sub_ui(gr_ptr res, gr_srcptr x, ulong y, gr_ctx_t ctx) noexcept int gr_generic_sub_si(gr_ptr res, gr_srcptr x, slong y, gr_ctx_t ctx) noexcept int gr_generic_sub_fmpz(gr_ptr res, gr_srcptr x, const fmpz_t y, gr_ctx_t ctx) noexcept int gr_generic_sub_fmpq(gr_ptr res, gr_srcptr x, const fmpq_t y, gr_ctx_t ctx) noexcept int gr_generic_sub_other(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t y_ctx, gr_ctx_t ctx) noexcept int gr_generic_other_sub(gr_ptr res, gr_srcptr x, gr_ctx_t x_ctx, gr_srcptr y, gr_ctx_t ctx) noexcept - int gr_generic_mul_fmpz(gr_ptr res, gr_srcptr x, const fmpz_t y, gr_ctx_t ctx) noexcept int gr_generic_mul_ui(gr_ptr res, gr_srcptr x, ulong y, gr_ctx_t ctx) noexcept int gr_generic_mul_si(gr_ptr res, gr_srcptr x, slong y, gr_ctx_t ctx) noexcept int gr_generic_mul_fmpq(gr_ptr res, gr_srcptr x, const fmpq_t y, gr_ctx_t ctx) noexcept int gr_generic_mul_other(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t y_ctx, gr_ctx_t ctx) noexcept int gr_generic_other_mul(gr_ptr res, gr_srcptr x, gr_ctx_t x_ctx, gr_srcptr y, gr_ctx_t ctx) noexcept - int gr_generic_addmul(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) noexcept int gr_generic_addmul_ui(gr_ptr res, gr_srcptr x, ulong y, gr_ctx_t ctx) noexcept int gr_generic_addmul_si(gr_ptr res, gr_srcptr x, slong y, gr_ctx_t ctx) noexcept int gr_generic_addmul_fmpz(gr_ptr res, gr_srcptr x, const fmpz_t y, gr_ctx_t ctx) noexcept int gr_generic_addmul_fmpq(gr_ptr res, gr_srcptr x, const fmpq_t y, gr_ctx_t ctx) noexcept int gr_generic_addmul_other(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t y_ctx, gr_ctx_t ctx) noexcept - int gr_generic_submul(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) noexcept int gr_generic_submul_ui(gr_ptr res, gr_srcptr x, ulong y, gr_ctx_t ctx) noexcept int gr_generic_submul_si(gr_ptr res, gr_srcptr x, slong y, gr_ctx_t ctx) noexcept int gr_generic_submul_fmpz(gr_ptr res, gr_srcptr x, const fmpz_t y, gr_ctx_t ctx) noexcept int gr_generic_submul_fmpq(gr_ptr res, gr_srcptr x, const fmpq_t y, gr_ctx_t ctx) noexcept int gr_generic_submul_other(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t y_ctx, gr_ctx_t ctx) noexcept - int gr_generic_mul_two(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept - int gr_generic_sqr(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept - int gr_generic_mul_2exp_si(gr_ptr res, gr_srcptr x, slong y, gr_ctx_t ctx) noexcept int gr_generic_mul_2exp_fmpz(gr_ptr res, gr_srcptr x, const fmpz_t y, gr_ctx_t ctx) noexcept - int gr_generic_set_fmpz_2exp_fmpz(gr_ptr res, const fmpz_t x, const fmpz_t y, gr_ctx_t ctx) noexcept - int gr_generic_get_fmpz_2exp_fmpz(fmpz_t res1, fmpz_t res2, gr_ptr x, gr_ctx_t ctx) noexcept - int gr_generic_inv(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept - truth_t gr_generic_is_invertible(gr_srcptr x, gr_ctx_t ctx) noexcept - int gr_generic_div_fmpz(gr_ptr res, gr_srcptr x, const fmpz_t y, gr_ctx_t ctx) noexcept int gr_generic_div_ui(gr_ptr res, gr_srcptr x, ulong y, gr_ctx_t ctx) noexcept int gr_generic_div_si(gr_ptr res, gr_srcptr x, slong y, gr_ctx_t ctx) noexcept int gr_generic_div_fmpq(gr_ptr res, gr_srcptr x, const fmpq_t y, gr_ctx_t ctx) noexcept int gr_generic_div_other(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t y_ctx, gr_ctx_t ctx) noexcept int gr_generic_other_div(gr_ptr res, gr_srcptr x, gr_ctx_t x_ctx, gr_srcptr y, gr_ctx_t ctx) noexcept - int gr_generic_divexact(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) noexcept - int gr_generic_pow_fmpz_sliding(gr_ptr f, gr_srcptr g, const fmpz_t pow, gr_ctx_t ctx) noexcept int gr_generic_pow_ui_sliding(gr_ptr f, gr_srcptr g, ulong pow, gr_ctx_t ctx) noexcept int gr_generic_pow_fmpz_binexp(gr_ptr res, gr_srcptr x, const fmpz_t exp, gr_ctx_t ctx) noexcept int gr_generic_pow_ui_binexp(gr_ptr res, gr_srcptr x, ulong e, gr_ctx_t ctx) noexcept - int gr_generic_pow_fmpz(gr_ptr res, gr_srcptr x, const fmpz_t e, gr_ctx_t ctx) noexcept int gr_generic_pow_si(gr_ptr res, gr_srcptr x, slong e, gr_ctx_t ctx) noexcept int gr_generic_pow_ui(gr_ptr res, gr_srcptr x, ulong e, gr_ctx_t ctx) noexcept int gr_generic_pow_fmpq(gr_ptr res, gr_srcptr x, const fmpq_t y, gr_ctx_t ctx) noexcept int gr_generic_pow_other(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t y_ctx, gr_ctx_t ctx) noexcept int gr_generic_other_pow(gr_ptr res, gr_srcptr x, gr_ctx_t x_ctx, gr_srcptr y, gr_ctx_t ctx) noexcept - int _gr_fmpz_poly_evaluate_horner(gr_ptr res, const fmpz * f, slong len, gr_srcptr x, gr_ctx_t ctx) noexcept int gr_fmpz_poly_evaluate_horner(gr_ptr res, const fmpz_poly_t f, gr_srcptr x, gr_ctx_t ctx) noexcept int _gr_fmpz_poly_evaluate_rectangular(gr_ptr res, const fmpz * f, slong len, gr_srcptr x, gr_ctx_t ctx) noexcept int gr_fmpz_poly_evaluate_rectangular(gr_ptr res, const fmpz_poly_t f, gr_srcptr x, gr_ctx_t ctx) noexcept int _gr_fmpz_poly_evaluate(gr_ptr res, const fmpz * f, slong len, gr_srcptr x, gr_ctx_t ctx) noexcept int gr_fmpz_poly_evaluate(gr_ptr res, const fmpz_poly_t f, gr_srcptr x, gr_ctx_t ctx) noexcept - # Sets *res* to the value of the integer polynomial *f* evaluated - # at the argument *x*. - int gr_fmpz_mpoly_evaluate(gr_ptr res, const fmpz_mpoly_t f, gr_srcptr x, const fmpz_mpoly_ctx_t mctx, gr_ctx_t ctx) noexcept - # Sets *res* to value of the multivariate polynomial *f* (with - # corresponding context object *mctx*) evaluated at the vector - # of arguments in *x*. - truth_t gr_generic_is_square(gr_srcptr x, gr_ctx_t ctx) noexcept int gr_generic_sqrt(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept int gr_generic_rsqrt(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept - # Currently these methods check for the special values 0 and 1. - int gr_generic_numerator(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept int gr_generic_denominator(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept - int gr_generic_cmp(int * res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) noexcept int gr_generic_cmpabs(int * res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) noexcept int gr_generic_cmp_other(int * res, gr_srcptr x, gr_srcptr y, gr_ctx_t y_ctx, gr_ctx_t ctx) noexcept int gr_generic_cmpabs_other(int * res, gr_srcptr x, gr_srcptr y, gr_ctx_t y_ctx, gr_ctx_t ctx) noexcept - int gr_generic_bernoulli_ui(gr_ptr res, ulong n, gr_ctx_t ctx) noexcept int gr_generic_bernoulli_fmpz(gr_ptr res, const fmpz_t n, gr_ctx_t ctx) noexcept int gr_generic_bernoulli_vec(gr_ptr res, slong len, gr_ctx_t ctx) noexcept @@ -158,51 +123,28 @@ cdef extern from "flint_wrap.h": int gr_generic_stirling_s1u_ui_vec(gr_ptr res, ulong x, slong len, gr_ctx_t ctx) noexcept int gr_generic_stirling_s1_ui_vec(gr_ptr res, ulong x, slong len, gr_ctx_t ctx) noexcept int gr_generic_stirling_s2_ui_vec(gr_ptr res, ulong x, slong len, gr_ctx_t ctx) noexcept - void gr_generic_vec_init(gr_ptr vec, slong len, gr_ctx_t ctx) noexcept - void gr_generic_vec_clear(gr_ptr vec, slong len, gr_ctx_t ctx) noexcept - void gr_generic_vec_swap(gr_ptr vec1, gr_ptr vec2, slong len, gr_ctx_t ctx) noexcept - int gr_generic_vec_zero(gr_ptr vec, slong len, gr_ctx_t ctx) noexcept - int gr_generic_vec_set(gr_ptr res, gr_srcptr src, slong len, gr_ctx_t ctx) noexcept - int gr_generic_vec_neg(gr_ptr res, gr_srcptr src, slong len, gr_ctx_t ctx) noexcept - int gr_generic_vec_normalise(slong * res, gr_srcptr vec, slong len, gr_ctx_t ctx) noexcept - slong gr_generic_vec_normalise_weak(gr_srcptr vec, slong len, gr_ctx_t ctx) noexcept - int gr_generic_vec_mul_scalar_2exp_si(gr_ptr vec1, gr_srcptr vec2, slong len, slong c, gr_ctx_t ctx) noexcept - int gr_generic_vec_scalar_addmul(gr_ptr vec1, gr_srcptr vec2, slong len, gr_srcptr c, gr_ctx_t ctx) noexcept - int gr_generic_vec_scalar_submul(gr_ptr vec1, gr_srcptr vec2, slong len, gr_srcptr c, gr_ctx_t ctx) noexcept - int gr_generic_vec_scalar_addmul_si(gr_ptr vec1, gr_srcptr vec2, slong len, slong c, gr_ctx_t ctx) noexcept - int gr_generic_vec_scalar_submul_si(gr_ptr vec1, gr_srcptr vec2, slong len, slong c, gr_ctx_t ctx) noexcept - truth_t gr_generic_vec_equal(gr_srcptr vec1, gr_srcptr vec2, slong len, gr_ctx_t ctx) noexcept - bint gr_generic_vec_is_zero(gr_srcptr vec, slong len, gr_ctx_t ctx) noexcept - int gr_generic_vec_dot(gr_ptr res, gr_srcptr initial, int subtract, gr_srcptr vec1, gr_srcptr vec2, slong len, gr_ctx_t ctx) noexcept - int gr_generic_vec_dot_rev(gr_ptr res, gr_srcptr initial, int subtract, gr_srcptr vec1, gr_srcptr vec2, slong len, gr_ctx_t ctx) noexcept - int gr_generic_vec_dot_ui(gr_ptr res, gr_srcptr initial, int subtract, gr_srcptr vec1, const ulong * vec2, slong len, gr_ctx_t ctx) noexcept - int gr_generic_vec_dot_si(gr_ptr res, gr_srcptr initial, int subtract, gr_srcptr vec1, const slong * vec2, slong len, gr_ctx_t ctx) noexcept - int gr_generic_vec_dot_fmpz(gr_ptr res, gr_srcptr initial, int subtract, gr_srcptr vec1, const fmpz * vec2, slong len, gr_ctx_t ctx) noexcept - int gr_generic_vec_set_powers(gr_ptr res, gr_srcptr x, slong len, gr_ctx_t ctx) noexcept - int gr_generic_vec_reciprocals(gr_ptr res, slong len, gr_ctx_t ctx) noexcept - int gr_generic_vec_add(gr_ptr res, gr_srcptr src1, gr_srcptr src2, slong len, gr_ctx_t ctx) noexcept int gr_generic_vec_sub(gr_ptr res, gr_srcptr src1, gr_srcptr src2, slong len, gr_ctx_t ctx) noexcept int gr_generic_vec_mul(gr_ptr res, gr_srcptr src1, gr_srcptr src2, slong len, gr_ctx_t ctx) noexcept diff --git a/src/sage/libs/flint/gr_mat.pxd b/src/sage/libs/flint/gr_mat.pxd index 02b2570fabd..501be55b79e 100644 --- a/src/sage/libs/flint/gr_mat.pxd +++ b/src/sage/libs/flint/gr_mat.pxd @@ -2,7 +2,9 @@ # distutils: depends = flint/gr_mat.h ################################################################################ -# This file is auto-generated. Do not modify by hand +# This file is auto-generated by the script +# SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py. +# Do not modify by hand! Fix and rerun the script instead. ################################################################################ from libc.stdio cimport FILE @@ -11,246 +13,82 @@ from sage.libs.mpfr.types cimport * from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - gr_ptr gr_mat_entry_ptr(gr_mat_t mat, slong i, slong j, gr_ctx_t ctx) noexcept - # Function returning a pointer to the entry at row *i* and column - # *j* of the matrix *mat*. The indices must be in bounds. - void gr_mat_init(gr_mat_t mat, slong rows, slong cols, gr_ctx_t ctx) noexcept - # Initializes *mat* to a matrix with the given number of rows and - # columns. - int gr_mat_init_set(gr_mat_t res, const gr_mat_t mat, gr_ctx_t ctx) noexcept - # Initializes *res* to a copy of the matrix *mat*. - void gr_mat_clear(gr_mat_t mat, gr_ctx_t ctx) noexcept - # Clears the matrix. - void gr_mat_swap(gr_mat_t mat1, gr_mat_t mat2, gr_ctx_t ctx) noexcept - # Swaps *mat1* and *mat12* efficiently. - int gr_mat_swap_entrywise(gr_mat_t mat1, const gr_mat_t mat2, gr_ctx_t ctx) noexcept - # Performs a deep swap of *mat1* and *mat2*, swapping the individual - # entries rather than the top-level structures. - void gr_mat_window_init(gr_mat_t window, const gr_mat_t mat, slong r1, slong c1, slong r2, slong c2, gr_ctx_t ctx) noexcept - # Initializes *window* to a window matrix into the submatrix of *mat* - # starting at the corner at row *r1* and column *c1* (inclusive) and ending - # at row *r2* and column *c2* (exclusive). - # The indices must be within bounds. - void gr_mat_window_clear(gr_mat_t window, gr_ctx_t ctx) noexcept - # Frees the window matrix. - int gr_mat_write(gr_stream_t out, const gr_mat_t mat, gr_ctx_t ctx) noexcept - # Write *mat* to the stream *out*. - int gr_mat_print(const gr_mat_t mat, gr_ctx_t ctx) noexcept - # Prints *mat* to standard output. - truth_t gr_mat_equal(const gr_mat_t mat1, const gr_mat_t mat2, gr_ctx_t ctx) noexcept - # Returns whether *mat1* and *mat2* are equal. - truth_t gr_mat_is_zero(const gr_mat_t mat, gr_ctx_t ctx) noexcept truth_t gr_mat_is_one(const gr_mat_t mat, gr_ctx_t ctx) noexcept truth_t gr_mat_is_neg_one(const gr_mat_t mat, gr_ctx_t ctx) noexcept - # Returns whether *mat* respectively is the zero matrix or - # the scalar matrix with 1 or -1 on the main diagonal. - truth_t gr_mat_is_scalar(const gr_mat_t mat, gr_ctx_t ctx) noexcept - # Returns whether *mat* is a scalar matrix, being a diagonal matrix - # with identical elements on the main diagonal. - int gr_mat_zero(gr_mat_t res, gr_ctx_t ctx) noexcept - # Sets *res* to the zero matrix. - int gr_mat_one(gr_mat_t res, gr_ctx_t ctx) noexcept - # Sets *res* to the scalar matrix with 1 on the main diagonal - # and zero elsewhere. - int gr_mat_set(gr_mat_t res, const gr_mat_t mat, gr_ctx_t ctx) noexcept int gr_mat_set_fmpz_mat(gr_mat_t res, const fmpz_mat_t mat, gr_ctx_t ctx) noexcept int gr_mat_set_fmpq_mat(gr_mat_t res, const fmpq_mat_t mat, gr_ctx_t ctx) noexcept - # Sets *res* to the value of *mat*. - int gr_mat_set_scalar(gr_mat_t res, gr_srcptr c, gr_ctx_t ctx) noexcept int gr_mat_set_ui(gr_mat_t res, ulong c, gr_ctx_t ctx) noexcept int gr_mat_set_si(gr_mat_t res, slong c, gr_ctx_t ctx) noexcept int gr_mat_set_fmpz(gr_mat_t res, const fmpz_t c, gr_ctx_t ctx) noexcept int gr_mat_set_fmpq(gr_mat_t res, const fmpq_t c, gr_ctx_t ctx) noexcept - # Set *res* to the scalar matrix with *c* on the main diagonal - # and zero elsewhere. - int gr_mat_concat_horizontal(gr_mat_t res, const gr_mat_t mat1, const gr_mat_t mat2, gr_ctx_t ctx) noexcept - int gr_mat_concat_vertical(gr_mat_t res, const gr_mat_t mat1, const gr_mat_t mat2, gr_ctx_t ctx) noexcept - int gr_mat_transpose(gr_mat_t B, const gr_mat_t A, gr_ctx_t ctx) noexcept - # Sets *B* to the transpose of *A*. - int gr_mat_swap_rows(gr_mat_t mat, slong * perm, slong r, slong s, gr_ctx_t ctx) noexcept - # Swaps rows ``r`` and ``s`` of ``mat``. If ``perm`` is non-``NULL``, the - # permutation of the rows will also be applied to ``perm``. - int gr_mat_swap_cols(gr_mat_t mat, slong * perm, slong r, slong s, gr_ctx_t ctx) noexcept - # Swaps columns ``r`` and ``s`` of ``mat``. If ``perm`` is non-``NULL``, the - # permutation of the columns will also be applied to ``perm``. - int gr_mat_invert_rows(gr_mat_t mat, slong * perm, gr_ctx_t ctx) noexcept - # Swaps rows ``i`` and ``r - i`` of ``mat`` for ``0 <= i < r/2``, where - # ``r`` is the number of rows of ``mat``. If ``perm`` is non-``NULL``, the - # permutation of the rows will also be applied to ``perm``. - int gr_mat_invert_cols(gr_mat_t mat, slong * perm, gr_ctx_t ctx) noexcept - # Swaps columns ``i`` and ``c - i`` of ``mat`` for ``0 <= i < c/2``, where - # ``c`` is the number of columns of ``mat``. If ``perm`` is non-``NULL``, the - # permutation of the columns will also be applied to ``perm``. - truth_t gr_mat_is_empty(const gr_mat_t mat, gr_ctx_t ctx) noexcept - # Returns whether *mat* is an empty matrix, having either zero - # rows or zero column. This predicate is always decidable (even if - # the underlying ring is not computable), returning - # ``T_TRUE`` or ``T_FALSE``. - truth_t gr_mat_is_square(const gr_mat_t mat, gr_ctx_t ctx) noexcept - # Returns whether *mat* is a square matrix, having the same number - # of rows as columns (not the same thing as being a perfect square!). - # This predicate is always decidable (even if the underlying ring - # is not computable), returning ``T_TRUE`` or ``T_FALSE``. - int gr_mat_neg(gr_mat_t res, const gr_mat_t mat, gr_ctx_t ctx) noexcept - int gr_mat_add(gr_mat_t res, const gr_mat_t mat1, const gr_mat_t mat2, gr_ctx_t ctx) noexcept - int gr_mat_sub(gr_mat_t res, const gr_mat_t mat1, const gr_mat_t mat2, gr_ctx_t ctx) noexcept - int gr_mat_mul_classical(gr_mat_t res, const gr_mat_t mat1, const gr_mat_t mat2, gr_ctx_t ctx) noexcept int gr_mat_mul_strassen(gr_mat_t C, const gr_mat_t A, const gr_mat_t B, gr_ctx_t ctx) noexcept int gr_mat_mul_generic(gr_mat_t C, const gr_mat_t A, const gr_mat_t B, gr_ctx_t ctx) noexcept int gr_mat_mul(gr_mat_t res, const gr_mat_t mat1, const gr_mat_t mat2, gr_ctx_t ctx) noexcept - # Matrix multiplication. The default function can be overloaded by specific rings; - # otherwise, it falls back to :func:`gr_mat_mul_generic` which currently - # only performs classical multiplication. - int gr_mat_sqr(gr_mat_t res, const gr_mat_t mat, gr_ctx_t ctx) noexcept - int gr_mat_add_scalar(gr_mat_t res, const gr_mat_t mat, gr_srcptr c, gr_ctx_t ctx) noexcept int gr_mat_sub_scalar(gr_mat_t res, const gr_mat_t mat, gr_srcptr c, gr_ctx_t ctx) noexcept int gr_mat_mul_scalar(gr_mat_t res, const gr_mat_t mat, gr_srcptr c, gr_ctx_t ctx) noexcept int gr_mat_addmul_scalar(gr_mat_t res, const gr_mat_t mat, gr_srcptr c, gr_ctx_t ctx) noexcept int gr_mat_submul_scalar(gr_mat_t res, const gr_mat_t mat, gr_srcptr c, gr_ctx_t ctx) noexcept int gr_mat_div_scalar(gr_mat_t res, const gr_mat_t mat, gr_srcptr c, gr_ctx_t ctx) noexcept - int _gr_mat_gr_poly_evaluate(gr_mat_t res, gr_srcptr poly, slong len, const gr_mat_t mat, gr_ctx_t ctx) noexcept int gr_mat_gr_poly_evaluate(gr_mat_t res, const gr_poly_t poly, const gr_mat_t mat, gr_ctx_t ctx) noexcept - # Sets *res* to the matrix obtained by evaluating the - # scalar polynomial *poly* with matrix argument *mat*. - truth_t gr_mat_is_upper_triangular(const gr_mat_t mat, gr_ctx_t ctx) noexcept truth_t gr_mat_is_lower_triangular(const gr_mat_t mat, gr_ctx_t ctx) noexcept - # Returns whether *mat* is upper (respectively lower) triangular, having - # zeros everywhere below (respectively above) the main diagonal. - # The matrix need not be square. - truth_t gr_mat_is_diagonal(const gr_mat_t mat, gr_ctx_t ctx) noexcept - # Returns whether *mat* is a diagonal matrix, having zeros everywhere - # except on the main diagonal. - # The matrix need not be square. - int gr_mat_mul_diag(gr_mat_t res, const gr_mat_t A, const gr_vec_t D, gr_ctx_t ctx) noexcept int gr_mat_diag_mul(gr_mat_t res, const gr_vec_t D, const gr_mat_t A, gr_ctx_t ctx) noexcept - # Set *res* to the product `AD` or `DA` respectively, where `D` is - # a diagonal matrix represented as a vector of entries. - int gr_mat_find_nonzero_pivot_large_abs(slong * pivot_row, gr_mat_t mat, slong start_row, slong end_row, slong column, gr_ctx_t ctx) noexcept int gr_mat_find_nonzero_pivot_generic(slong * pivot_row, gr_mat_t mat, slong start_row, slong end_row, slong column, gr_ctx_t ctx) noexcept int gr_mat_find_nonzero_pivot(slong * pivot_row, gr_mat_t mat, slong start_row, slong end_row, slong column, gr_ctx_t ctx) noexcept - # Attempts to find a nonzero element in column number *column* - # of the matrix *mat* in a row between *start_row* (inclusive) - # and *end_row* (exclusive). - # On success, sets ``pivot_row`` to the row index and returns - # ``GR_SUCCESS``. If no nonzero pivot element exists, returns ``GR_DOMAIN``. - # If no nonzero pivot element exists and zero-testing fails for some - # element, returns the flag ``GR_UNABLE``. - # This function may be destructive: any elements that are nontrivially - # zero but can be certified zero may be overwritten by exact zeros. - int gr_mat_lu_classical(slong * rank, slong * P, gr_mat_t LU, const gr_mat_t A, int rank_check, gr_ctx_t ctx) noexcept int gr_mat_lu_recursive(slong * rank, slong * P, gr_mat_t LU, const gr_mat_t A, int rank_check, gr_ctx_t ctx) noexcept int gr_mat_lu(slong * rank, slong * P, gr_mat_t LU, const gr_mat_t A, int rank_check, gr_ctx_t ctx) noexcept - # Computes a generalized LU decomposition `A = PLU` of a given - # matrix *A*, writing the rank of *A* to *rank*. - # If *A* is a nonsingular square matrix, *LU* will be set to - # a unit diagonal lower triangular matrix *L* and an upper - # triangular matrix *U* (the diagonal of *L* will not be stored - # explicitly). - # If *A* is an arbitrary matrix of rank *r*, *U* will be in row - # echelon form having *r* nonzero rows, and *L* will be lower - # triangular but truncated to *r* columns, having implicit ones on - # the *r* first entries of the main diagonal. All other entries will - # be zero. - # If a nonzero value for ``rank_check`` is passed, the function - # will abandon the output matrix in an undefined state and set - # the rank to 0 if *A* is detected to be rank-deficient. - # This currently only works as expected for square matrices. - # The algorithm can fail if it fails to certify that a pivot - # element is zero or nonzero, in which case the correct rank - # cannot be determined. It can also fail if a pivot element - # is not invertible. In these cases the ``GR_UNABLE`` and/or - # ``GR_DOMAIN`` flags will be returned. On failure, - # the data in the output variables - # ``rank``, ``P`` and ``LU`` will be meaningless. - # The *classical* version uses iterative Gaussian elimination. - # The *recursive* version uses a block recursive algorithm - # to take advantage of fast matrix multiplication. - int gr_mat_fflu(slong * rank, slong * P, gr_mat_t LU, gr_ptr den, const gr_mat_t A, int rank_check, gr_ctx_t ctx) noexcept - # Similar to :func:`gr_mat_lu`, but computes a fraction-free - # LU decomposition using the Bareiss algorithm. - # The denominator is written to *den*. - int gr_mat_nonsingular_solve_tril_classical(gr_mat_t X, const gr_mat_t L, const gr_mat_t B, int unit, gr_ctx_t ctx) noexcept int gr_mat_nonsingular_solve_tril_recursive(gr_mat_t X, const gr_mat_t L, const gr_mat_t B, int unit, gr_ctx_t ctx) noexcept int gr_mat_nonsingular_solve_tril(gr_mat_t X, const gr_mat_t L, const gr_mat_t B, int unit, gr_ctx_t ctx) noexcept int gr_mat_nonsingular_solve_triu_classical(gr_mat_t X, const gr_mat_t U, const gr_mat_t B, int unit, gr_ctx_t ctx) noexcept int gr_mat_nonsingular_solve_triu_recursive(gr_mat_t X, const gr_mat_t U, const gr_mat_t B, int unit, gr_ctx_t ctx) noexcept int gr_mat_nonsingular_solve_triu(gr_mat_t X, const gr_mat_t U, const gr_mat_t B, int unit, gr_ctx_t ctx) noexcept - # Solves the lower triangular system `LX = B` or the upper triangular system - # `UX = B`, respectively. Division by the the diagonal entries must - # be possible; if not a division fails, ``GR_DOMAIN`` is returned - # even if the system is solvable. - # If *unit* is set, the main diagonal of *L* or *U* - # is taken to consist of all ones, and in that case the actual entries on - # the diagonal are not read at all and can contain other data. - # The *classical* versions perform the computations iteratively while the - # *recursive* versions perform the computations in a block recursive - # way to benefit from fast matrix multiplication. The default versions - # choose an algorithm automatically. - int gr_mat_nonsingular_solve_fflu(gr_mat_t X, const gr_mat_t A, const gr_mat_t B, gr_ctx_t ctx) noexcept int gr_mat_nonsingular_solve_lu(gr_mat_t X, const gr_mat_t A, const gr_mat_t B, gr_ctx_t ctx) noexcept int gr_mat_nonsingular_solve(gr_mat_t X, const gr_mat_t A, const gr_mat_t B, gr_ctx_t ctx) noexcept - # Solves `AX = B`. If *A* is not invertible, - # returns ``GR_DOMAIN`` even if the system has a solution. - int gr_mat_nonsingular_solve_fflu_precomp(gr_mat_t X, const slong * perm, const gr_mat_t LU, const gr_mat_t B, gr_ctx_t ctx) noexcept int gr_mat_nonsingular_solve_lu_precomp(gr_mat_t X, const slong * perm, const gr_mat_t LU, const gr_mat_t B, gr_ctx_t ctx) noexcept - # Solves `AX = B` given a precomputed FFLU or LU factorization of *A*. - int gr_mat_nonsingular_solve_den_fflu(gr_mat_t X, gr_ptr den, const gr_mat_t A, const gr_mat_t B, gr_ctx_t ctx) noexcept int gr_mat_nonsingular_solve_den(gr_mat_t X, gr_ptr den, const gr_mat_t A, const gr_mat_t B, gr_ctx_t ctx) noexcept - # Solves `AX = B` over the fraction field of the present ring - # (assumed to be an integral domain), returning `X` with - # an implied denominator *den*. - # If *A* is not invertible over the fraction field, returns - # ``GR_DOMAIN`` even if the system has a solution. - int gr_mat_solve_field(gr_mat_t X, const gr_mat_t A, const gr_mat_t B, gr_ctx_t ctx) noexcept - # Solves `AX = B` where *A* is not necessarily square and not necessarily - # invertible. Assuming that the ring is a field, a return value of - # ``GR_DOMAIN`` indicates that the system has no solution. - # If there are multiple solutions, an arbitrary solution is returned. - int gr_mat_det_fflu(gr_ptr res, const gr_mat_t mat, gr_ctx_t ctx) noexcept int gr_mat_det_berkowitz(gr_ptr res, const gr_mat_t mat, gr_ctx_t ctx) noexcept int gr_mat_det_lu(gr_ptr res, const gr_mat_t mat, gr_ctx_t ctx) noexcept @@ -259,104 +97,24 @@ cdef extern from "flint_wrap.h": int gr_mat_det_generic_integral_domain(gr_ptr res, const gr_mat_t A, gr_ctx_t ctx) noexcept int gr_mat_det_generic(gr_ptr res, const gr_mat_t A, gr_ctx_t ctx) noexcept int gr_mat_det(gr_ptr res, const gr_mat_t mat, gr_ctx_t ctx) noexcept - # Sets *res* to the determinant of the square matrix *mat*. - # Various algorithms are available: - # * The *berkowitz* version uses the division-free Berkowitz algorithm - # performing `O(n^4)` operations. Since no zero tests are required, it - # is guaranteed to succeed if the ring arithmetic succeeds. - # * The *cofactor* version performs cofactor expansion. This is currently - # only supported for matrices up to size 4, and for larger - # matrices returns the ``GR_UNABLE`` flag. - # * The *lu* and *fflu* versions use rational LU decomposition - # and fraction-free LU decomposition (Bareiss algorithm) respectively, - # requiring `O(n^3)` operations. These algorithms can fail if zero - # certification or inversion fails, in which case the ``GR_UNABLE`` - # flag is returned. - # * The *generic*, *generic_field* and *generic_integral_domain* - # versions choose an appropriate algorithm for a generic ring - # depending on the availability of division. - # * The *default* method can be overloaded. - # If the matrix is not square, ``GR_DOMAIN`` is returned. - int gr_mat_trace(gr_ptr res, const gr_mat_t mat, gr_ctx_t ctx) noexcept - # Sets *res* to the trace (sum of entries on the main diagonal) of - # the square matrix *mat*. - # If the matrix is not square, ``GR_DOMAIN`` is returned. - int gr_mat_rank_fflu(slong * rank, const gr_mat_t mat, gr_ctx_t ctx) noexcept int gr_mat_rank_lu(slong * rank, const gr_mat_t mat, gr_ctx_t ctx) noexcept int gr_mat_rank(slong * rank, const gr_mat_t mat, gr_ctx_t ctx) noexcept - # Sets *res* to the rank of *mat*. - # The default method returns ``GR_DOMAIN`` if the element ring - # is not an integral domain, in which case the usual rank is - # not well-defined. The *fflu* and *lu* variants currently do - # not check the element domain, and simply return this flag if they - # encounter an impossible inverse in the execution of the - # respective algorithms. - int gr_mat_rref_lu(slong * rank, gr_mat_t R, const gr_mat_t A, gr_ctx_t ctx) noexcept int gr_mat_rref_fflu(slong * rank, gr_mat_t R, const gr_mat_t A, gr_ctx_t ctx) noexcept int gr_mat_rref(slong * rank, gr_mat_t R, const gr_mat_t A, gr_ctx_t ctx) noexcept - # Sets *R* to the reduced row echelon form of *A*, also setting - # *rank* to its rank. - int gr_mat_rref_den_fflu(slong * rank, gr_mat_t R, gr_ptr den, const gr_mat_t A, gr_ctx_t ctx) noexcept int gr_mat_rref_den(slong * rank, gr_mat_t R, gr_ptr den, const gr_mat_t A, gr_ctx_t ctx) noexcept - # Like *rref*, but computes the reduced row echelon multiplied - # by a common (not necessarily minimal) denominator which is written - # to *den*. This can be used to compute the rref over an integral - # domain which is not a field. - int gr_mat_nullspace(gr_mat_t X, const gr_mat_t A, gr_ctx_t ctx) noexcept - # Sets *X* to a basis for the (right) nullspace of *A*. - # On success, the output matrix will be resized to the correct - # number of columns. - # The basis is not guaranteed to be presented in a - # canonical or minimal form. - # If the ring is not a field, this is implied to compute a nullspace - # basis over the fraction field. The result may be meaningless - # if the ring is not an integral domain. - int gr_mat_inv(gr_mat_t res, const gr_mat_t mat, gr_ctx_t ctx) noexcept - # Sets *res* to the inverse of *mat*, computed by solving - # `A A^{-1} = I`. - # Returns ``GR_DOMAIN`` if it can be determined that *mat* is not - # invertible over the present ring (warning: this may not work - # over non-integral domains). If invertibility cannot be proved, - # returns ``GR_UNABLE``. - # To compute the inverse over the fraction field, one may use - # :func:`gr_mat_nonsingular_solve_den` or :func:`gr_mat_adjugate`. - int gr_mat_adjugate_charpoly(gr_mat_t adj, gr_ptr det, const gr_mat_t mat, gr_ctx_t ctx) noexcept int gr_mat_adjugate_cofactor(gr_mat_t adj, gr_ptr det, const gr_mat_t mat, gr_ctx_t ctx) noexcept int gr_mat_adjugate(gr_mat_t adj, gr_ptr det, const gr_mat_t mat, gr_ctx_t ctx) noexcept - # Sets *adj* to the adjugate matrix of *mat*, simultaneously - # setting *det* to the determinant of *mat*. We have - # `\operatorname{adj}(A) A = A \operatorname{adj}(A) = \det(A) I`, - # and `A^{-1} = \operatorname{adj}(A) / \det(A)` when *A* - # is invertible. - # The *cofactor* version uses cofactor expansion, requiring the - # evaluation of `n^2` determinants. - # The *charpoly* version computes and then evaluates the - # characteristic polynomial, requiring `O(n^{1/2})` - # matrix multiplications plus `O(n^3)` or `O(n^4)` operations - # for the characteristic polynomial itself depending on the - # algorithm used. - int _gr_mat_charpoly(gr_ptr res, const gr_mat_t mat, gr_ctx_t ctx) noexcept int gr_mat_charpoly(gr_poly_t res, const gr_mat_t mat, gr_ctx_t ctx) noexcept - # Computes the characteristic polynomial using a default - # algorithm choice. The - # underscore method assumes that *res* is a preallocated - # array of `n + 1` coefficients. - int _gr_mat_charpoly_berkowitz(gr_ptr res, const gr_mat_t mat, gr_ctx_t ctx) noexcept int gr_mat_charpoly_berkowitz(gr_poly_t res, const gr_mat_t mat, gr_ctx_t ctx) noexcept - # Sets *res* to the characteristic polynomial of the square matrix - # *mat*, computed using the division-free Berkowitz algorithm. - # The number of operations is `O(n^4)` where *n* is the - # size of the matrix. - int _gr_mat_charpoly_danilevsky_inplace(gr_ptr res, gr_mat_t mat, gr_ctx_t ctx) noexcept int _gr_mat_charpoly_danilevsky(gr_ptr res, const gr_mat_t mat, gr_ctx_t ctx) noexcept int gr_mat_charpoly_danilevsky(gr_poly_t res, const gr_mat_t mat, gr_ctx_t ctx) noexcept @@ -364,178 +122,38 @@ cdef extern from "flint_wrap.h": int gr_mat_charpoly_gauss(gr_poly_t res, const gr_mat_t mat, gr_ctx_t ctx) noexcept int _gr_mat_charpoly_householder(gr_ptr res, const gr_mat_t mat, gr_ctx_t ctx) noexcept int gr_mat_charpoly_householder(gr_poly_t res, const gr_mat_t mat, gr_ctx_t ctx) noexcept - # Sets *res* to the characteristic polynomial of the square matrix - # *mat*, computed using the Danilevsky algorithm, - # Hessenberg reduction using Gaussian elimination, - # and Hessenberg reduction using Householder reflections. - # The number of operations of each method is `O(n^3)` where *n* is the - # size of the matrix. The *inplace* version overwrites the input matrix. - # These methods require divisions and can therefore fail when the - # ring is not a field. They also require zero tests. - # The *householder* version also requires square roots. - # The flags ``GR_UNABLE`` or ``GR_DOMAIN`` are returned when - # an impossible division or square root - # is encountered or when a comparison cannot be performed. - int _gr_mat_charpoly_faddeev(gr_ptr res, gr_mat_t adj, const gr_mat_t mat, gr_ctx_t ctx) noexcept int gr_mat_charpoly_faddeev(gr_poly_t res, gr_mat_t adj, const gr_mat_t mat, gr_ctx_t ctx) noexcept int _gr_mat_charpoly_faddeev_bsgs(gr_ptr res, gr_mat_t adj, const gr_mat_t mat, gr_ctx_t ctx) noexcept int gr_mat_charpoly_faddeev_bsgs(gr_poly_t res, gr_mat_t adj, const gr_mat_t mat, gr_ctx_t ctx) noexcept - # Sets *res* to the characteristic polynomial of the square matrix - # *mat*, computed using the Faddeev-LeVerrier algorithm. - # If the optional output argument *adj* is not *NULL*, it is - # set to the adjugate matrix, which is computed free of charge. - # The *bsgs* version uses a baby-step giant-step strategy, - # also known as the Preparata-Sarwate algorithm. - # This reduces the complexity from `O(n^4)` to `O(n^{3.5})` operations - # at the cost of requiring `n^{0.5}` temporary matrices to be - # stored. - # This method requires divisions by small integers and can - # therefore fail (returning the ``GR_UNABLE`` or ``GR_DOMAIN`` flags) - # in finite characteristic or when the underlying ring does - # not implement a division algorithm. - int _gr_mat_charpoly_from_hessenberg(gr_ptr res, const gr_mat_t mat, gr_ctx_t ctx) noexcept int gr_mat_charpoly_from_hessenberg(gr_poly_t res, const gr_mat_t mat, gr_ctx_t ctx) noexcept - # Sets *res* to the characteristic polynomial of the square matrix - # *mat*, which is assumed to be in Hessenberg form (this is - # currently not checked). - int gr_mat_minpoly_field(gr_poly_t res, const gr_mat_t mat, gr_ctx_t ctx) noexcept - # Compute the minimal polynomial of the matrix *mat*. - # The algorithm assumes that the coefficient ring is a field. - int gr_mat_apply_row_similarity(gr_mat_t M, slong r, gr_ptr d, gr_ctx_t ctx) noexcept - # Applies an elementary similarity transform to the `n\times n` matrix `M` - # in-place. - # If `P` is the `n\times n` identity matrix the zero entries of whose row - # `r` (`0`-indexed) have been replaced by `d`, this transform is equivalent - # to `M = P^{-1}MP`. - # Similarity transforms preserve the determinant, characteristic polynomial - # and minimal polynomial. - int gr_mat_eigenvalues(gr_vec_t lmbda, gr_vec_t mult, const gr_mat_t mat, int flags, gr_ctx_t ctx) noexcept int gr_mat_eigenvalues_other(gr_vec_t lmbda, gr_vec_t mult, const gr_mat_t mat, gr_ctx_t mat_ctx, int flags, gr_ctx_t ctx) noexcept - # Finds all eigenvalues of the given matrix in the ring defined by *ctx*, - # storing the eigenvalues without duplication in *lambda* (a vector with - # elements of type ``ctx``) and the corresponding multiplicities in - # *mult* (a vector with elements of type ``fmpz``). - # The interface is essentially the same as that of - # :func:`gr_poly_roots`; see its documentation for details. - int gr_mat_diagonalization_precomp(gr_vec_t D, gr_mat_t L, gr_mat_t R, const gr_mat_t A, const gr_vec_t eigenvalues, const gr_vec_t mult, gr_ctx_t ctx) noexcept int gr_mat_diagonalization_generic(gr_vec_t D, gr_mat_t L, gr_mat_t R, const gr_mat_t A, int flags, gr_ctx_t ctx) noexcept int gr_mat_diagonalization(gr_vec_t D, gr_mat_t L, gr_mat_t R, const gr_mat_t A, int flags, gr_ctx_t ctx) noexcept - # Computes a diagonalization `LAR = D` given a square matrix `A`, - # where `D` is a diagonal matrix (returned as a vector) of the eigenvalues - # repeated according to their multiplicities, - # `L` is a matrix of left eigenvectors, - # and `R` is a matrix of right eigenvectors, - # normalized such that `L = R^{-1}`. - # This implies that `A = RDL = RDR^{-1}`. - # Either `L` or `R` (or both) can be set to ``NULL`` to omit computing - # the respective matrix. - # If the matrix has entries in a field then a return flag - # of ``GR_DOMAIN`` indicates that the matrix is non-diagonalizable - # over this field. - # The *precomp* version requires as input a precomputed set of eigenvalues - # with corresponding multiplicities, which can be computed - # with :func:`gr_mat_eigenvalues`. - int gr_mat_set_jordan_blocks(gr_mat_t mat, const gr_vec_t lmbda, slong num_blocks, slong * block_lambda, slong * block_size, gr_ctx_t ctx) noexcept int gr_mat_jordan_blocks(gr_vec_t lmbda, slong * num_blocks, slong * block_lambda, slong * block_size, const gr_mat_t A, gr_ctx_t ctx) noexcept int gr_mat_jordan_transformation(gr_mat_t mat, const gr_vec_t lmbda, slong num_blocks, slong * block_lambda, slong * block_size, const gr_mat_t A, gr_ctx_t ctx) noexcept int gr_mat_jordan_form(gr_mat_t J, gr_mat_t P, const gr_mat_t A, gr_ctx_t ctx) noexcept - int gr_mat_exp_jordan(gr_mat_t res, const gr_mat_t A, gr_ctx_t ctx) noexcept int gr_mat_exp(gr_mat_t res, const gr_mat_t A, gr_ctx_t ctx) noexcept - int gr_mat_log_jordan(gr_mat_t res, const gr_mat_t A, gr_ctx_t ctx) noexcept int gr_mat_log(gr_mat_t res, const gr_mat_t A, gr_ctx_t ctx) noexcept - truth_t gr_mat_is_hessenberg(const gr_mat_t mat, gr_ctx_t ctx) noexcept - # Returns whether *mat* is in upper Hessenberg form. - int gr_mat_hessenberg_gauss(gr_mat_t res, const gr_mat_t mat, gr_ctx_t ctx) noexcept int gr_mat_hessenberg_householder(gr_mat_t res, const gr_mat_t mat, gr_ctx_t ctx) noexcept int gr_mat_hessenberg(gr_mat_t res, const gr_mat_t mat, gr_ctx_t ctx) noexcept - # Sets *res* to an upper Hessenberg form of *mat*. - # The *gauss* version uses Gaussian elimination. - # The *householder* version uses Householder reflections. - # These methods require divisions and zero testing - # and can therefore fail (returning ``GR_UNABLE`` or ``GR_DOMAIN``) - # when the ring is not a field. - # The *householder* version additionally requires complex - # conjugation and the ability to compute square roots. - int gr_mat_randtest(gr_mat_t res, flint_rand_t state, gr_ctx_t ctx) noexcept - # Sets *res* to a random matrix. The distribution is nonuniform. - int gr_mat_randops(gr_mat_t mat, flint_rand_t state, slong count, gr_ctx_t ctx) noexcept - # Randomises *mat* in-place by performing elementary row or column - # operations. More precisely, at most *count* random additions or - # subtractions of distinct rows and columns will be performed. - int gr_mat_randpermdiag(int * parity, gr_mat_t mat, flint_rand_t state, gr_ptr diag, slong n, gr_ctx_t ctx) noexcept - # Sets mat to a random permutation of the diagonal matrix with *n* leading entries given by - # the vector ``diag``. Returns ``GR_DOMAIN`` if the main diagonal of ``mat`` - # does not have room for at least *n* entries. - # The parity (0 or 1) of the permutation is written to ``parity``. - int gr_mat_randrank(gr_mat_t mat, flint_rand_t state, slong rank, gr_ctx_t ctx) noexcept - # Sets ``mat`` to a random sparse matrix with the given rank, having exactly as many - # non-zero elements as the rank. The matrix can be transformed into a dense matrix - # with unchanged rank by subsequently calling :func:`gr_mat_randops`. - # This operation only makes sense over integral domains (currently not checked). - int gr_mat_ones(gr_mat_t res, gr_ctx_t ctx) noexcept - # Sets all entries in *res* to one. - int gr_mat_pascal(gr_mat_t res, int triangular, gr_ctx_t ctx) noexcept - # Sets *res* to a Pascal matrix, whose entries are binomial coefficients. - # If *triangular* is 0, constructs a full symmetric matrix - # with the rows of Pascal's triangle as successive antidiagonals. - # If *triangular* is 1, constructs the upper triangular matrix with - # the rows of Pascal's triangle as columns, and if *triangular* is -1, - # constructs the lower triangular matrix with the rows of Pascal's - # triangle as rows. - int gr_mat_stirling(gr_mat_t res, int kind, gr_ctx_t ctx) noexcept - # Sets *res* to a Stirling matrix, whose entries are Stirling numbers. - # If *kind* is 0, the entries are set to the unsigned Stirling numbers - # of the first kind. If *kind* is 1, the entries are set to the signed - # Stirling numbers of the first kind. If *kind* is 2, the entries are - # set to the Stirling numbers of the second kind. - int gr_mat_hilbert(gr_mat_t res, gr_ctx_t ctx) noexcept - # Sets *res* to the Hilbert matrix, which has entries `1/(i+j+1)` - # for `i, j \ge 0`. - int gr_mat_hadamard(gr_mat_t res, gr_ctx_t ctx) noexcept - # If possible, sets *res* to a Hadamard matrix of the provided size - # and returns ``GR_SUCCESS``. Returns ``GR_DOMAIN`` - # if no Hadamard matrix of the given size exists, - # and ``GR_UNABLE`` if the implementation does - # not know how to construct a Hadamard matrix of the given - # size. - # A Hadamard matrix of size *n* can only exist if *n* is 0, 1, 2, - # or a multiple of 4. It is not known whether a - # Hadamard matrix exists for every size that is a multiple of 4. - # This function uses the Paley construction, which - # succeeds for all *n* of the form `n = 2^e` or `n = 2^e (q + 1)` where - # *q* is an odd prime power. Orders *n* for which Hadamard matrices are - # known to exist but for which this construction fails are - # 92, 116, 156, ... (OEIS A046116). - int gr_mat_reduce_row(slong * column, gr_mat_t A, slong * P, slong * L, slong m, gr_ctx_t ctx) noexcept - # Reduce row n of the matrix `A`, assuming the prior rows are in Gauss - # form. However those rows may not be in order. The entry `i` of the array - # `P` is the row of `A` which has a pivot in the `i`-th column. If no such - # row exists, the entry of `P` will be `-1`. The function sets *column* to the column - # in which the `n`-th row has a pivot after reduction. This will always be - # chosen to be the first available column for a pivot from the left. This - # information is also updated in `P`. Entry `i` of the array `L` contains the - # number of possibly nonzero columns of `A` row `i`. This speeds up reduction - # in the case that `A` is chambered on the right. Otherwise the entries of - # `L` can all be set to the number of columns of `A`. We require the entries - # of `L` to be monotonic increasing. diff --git a/src/sage/libs/flint/gr_mpoly.pxd b/src/sage/libs/flint/gr_mpoly.pxd index 8d482d403e0..c587f378017 100644 --- a/src/sage/libs/flint/gr_mpoly.pxd +++ b/src/sage/libs/flint/gr_mpoly.pxd @@ -2,7 +2,9 @@ # distutils: depends = flint/gr_mpoly.h ################################################################################ -# This file is auto-generated. Do not modify by hand +# This file is auto-generated by the script +# SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py. +# Do not modify by hand! Fix and rerun the script instead. ################################################################################ from libc.stdio cimport FILE @@ -11,114 +13,54 @@ from sage.libs.mpfr.types cimport * from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void gr_mpoly_init(gr_mpoly_t A, const mpoly_ctx_t mctx, gr_ctx_t cctx) noexcept - # Initializes and sets *A* to the zero polynomial. - void gr_mpoly_init3(gr_mpoly_t A, slong alloc, flint_bitcnt_t bits, const mpoly_ctx_t mctx, gr_ctx_t cctx) noexcept void gr_mpoly_init2(gr_mpoly_t A, slong alloc, const mpoly_ctx_t mctx, gr_ctx_t cctx) noexcept - # Initializes *A* with space allocated for the given number - # of coefficients and exponents with the given number of bits. - void gr_mpoly_clear(gr_mpoly_t A, const mpoly_ctx_t mctx, gr_ctx_t cctx) noexcept - # Clears *A*, freeing all allocated data. - void gr_mpoly_swap(gr_mpoly_t A, gr_mpoly_t B, const mpoly_ctx_t mctx, gr_ctx_t cctx) noexcept - # Swaps *A* and *B* efficiently. - int gr_mpoly_set(gr_mpoly_t A, const gr_mpoly_t B, const mpoly_ctx_t mctx, gr_ctx_t cctx) noexcept - # Sets *A* to *B*. - int gr_mpoly_zero(gr_mpoly_t A, const mpoly_ctx_t mctx, gr_ctx_t cctx) noexcept - # Sets *A* to the zero polynomial. - truth_t gr_mpoly_is_zero(const gr_mpoly_t A, const mpoly_ctx_t mctx, gr_ctx_t cctx) noexcept - # Returns whether *A* is the zero polynomial. - int gr_mpoly_gen(gr_mpoly_t A, slong var, const mpoly_ctx_t mctx, gr_ctx_t cctx) noexcept - # Sets *A* to the generator with index *var* (indexed from zero). - truth_t gr_mpoly_is_gen(const gr_mpoly_t A, slong var, const mpoly_ctx_t mctx, gr_ctx_t cctx) noexcept - # Returns whether *A* is the generator with index *var* (indexed from zero). - truth_t gr_mpoly_equal(const gr_mpoly_t A, const gr_mpoly_t B, const mpoly_ctx_t mctx, gr_ctx_t cctx) noexcept - # Returns whether *A* and *B* are equal. - int gr_mpoly_randtest_bits(gr_mpoly_t A, flint_rand_t state, slong length, flint_bitcnt_t exp_bits, const mpoly_ctx_t mctx, gr_ctx_t cctx) noexcept - # Sets *A* to a random polynomial with up to *length* terms - # and up to *exp_bits* bits in the exponents. - int gr_mpoly_write_pretty(gr_stream_t out, const gr_mpoly_t A, const char ** x, const mpoly_ctx_t mctx, gr_ctx_t cctx) noexcept int gr_mpoly_print_pretty(const gr_mpoly_t A, const char ** x, const mpoly_ctx_t mctx, gr_ctx_t cctx) noexcept - # Prints *A* using the strings in *x* for the variables. - # If *x* is *NULL*, defaults are used. - int gr_mpoly_get_coeff_scalar_fmpz(gr_ptr c, const gr_mpoly_t A, const fmpz * exp, const mpoly_ctx_t mctx, gr_ctx_t cctx) noexcept int gr_mpoly_get_coeff_scalar_ui(gr_ptr c, const gr_mpoly_t A, const ulong * exp, const mpoly_ctx_t mctx, gr_ctx_t cctx) noexcept - # Sets *c* to the coefficient in *A* with exponents *exp*. - int gr_mpoly_set_coeff_scalar_fmpz(gr_mpoly_t A, gr_srcptr c, const fmpz * exp, const mpoly_ctx_t mctx, gr_ctx_t cctx) noexcept int gr_mpoly_set_coeff_ui_fmpz(gr_mpoly_t A, ulong c, const fmpz * exp, const mpoly_ctx_t mctx, gr_ctx_t cctx) noexcept int gr_mpoly_set_coeff_si_fmpz(gr_mpoly_t A, slong c, const fmpz * exp, const mpoly_ctx_t mctx, gr_ctx_t cctx) noexcept int gr_mpoly_set_coeff_fmpz_fmpz(gr_mpoly_t A, const fmpz_t c, const fmpz * exp, const mpoly_ctx_t mctx, gr_ctx_t cctx) noexcept int gr_mpoly_set_coeff_fmpq_fmpz(gr_mpoly_t A, const fmpq_t c, const fmpz * exp, const mpoly_ctx_t mctx, gr_ctx_t cctx) noexcept - int gr_mpoly_set_coeff_scalar_ui(gr_mpoly_t poly, gr_srcptr c, const ulong * exp, const mpoly_ctx_t mctx, gr_ctx_t cctx) noexcept int gr_mpoly_set_coeff_ui_ui(gr_mpoly_t A, ulong c, const ulong * exp, const mpoly_ctx_t mctx, gr_ctx_t cctx) noexcept int gr_mpoly_set_coeff_si_ui(gr_mpoly_t A, slong c, const ulong * exp, const mpoly_ctx_t mctx, gr_ctx_t cctx) noexcept int gr_mpoly_set_coeff_fmpz_ui(gr_mpoly_t A, const fmpz_t c, const ulong * exp, const mpoly_ctx_t mctx, gr_ctx_t cctx) noexcept int gr_mpoly_set_coeff_fmpq_ui(gr_mpoly_t A, const fmpq_t c, const ulong * exp, const mpoly_ctx_t mctx, gr_ctx_t cctx) noexcept - # Sets the coefficient with exponents *exp* in *A* to the scalar *c* - # which must be an element of or coercible to the coefficient ring. - int gr_mpoly_neg(gr_mpoly_t A, const gr_mpoly_t B, const mpoly_ctx_t mctx, gr_ctx_t cctx) noexcept - # Sets *A* to the negation of *B*. - int gr_mpoly_add(gr_mpoly_t A, const gr_mpoly_t B, const gr_mpoly_t C, const mpoly_ctx_t mctx, gr_ctx_t cctx) noexcept - # Sets *A* to the difference of *B* and *C*. - int gr_mpoly_sub(gr_mpoly_t A, const gr_mpoly_t B, const gr_mpoly_t C, const mpoly_ctx_t mctx, gr_ctx_t cctx) noexcept - # Sets *A* to the difference of *B* and *C*. - int gr_mpoly_mul(gr_mpoly_t A, const gr_mpoly_t B, const gr_mpoly_t C, const mpoly_ctx_t mctx, gr_ctx_t cctx) noexcept int gr_mpoly_mul_johnson(gr_mpoly_t A, const gr_mpoly_t B, const gr_mpoly_t C, const mpoly_ctx_t mctx, gr_ctx_t cctx) noexcept int gr_mpoly_mul_monomial(gr_mpoly_t A, const gr_mpoly_t B, const gr_mpoly_t C, const mpoly_ctx_t mctx, gr_ctx_t cctx) noexcept - # Sets *A* to the product of *B* and *C*. - # The *monomial* version assumes that *C* is a monomial. - int gr_mpoly_mul_scalar(gr_mpoly_t A, const gr_mpoly_t B, gr_srcptr c, const mpoly_ctx_t mctx, gr_ctx_t cctx) noexcept int gr_mpoly_mul_si(gr_mpoly_t A, const gr_mpoly_t B, slong c, const mpoly_ctx_t mctx, gr_ctx_t cctx) noexcept int gr_mpoly_mul_ui(gr_mpoly_t A, const gr_mpoly_t B, ulong c, const mpoly_ctx_t mctx, gr_ctx_t cctx) noexcept int gr_mpoly_mul_fmpz(gr_mpoly_t A, const gr_mpoly_t B, const fmpz_t c, const mpoly_ctx_t mctx, gr_ctx_t cctx) noexcept int gr_mpoly_mul_fmpq(gr_mpoly_t A, const gr_mpoly_t B, const fmpq_t c, const mpoly_ctx_t mctx, gr_ctx_t cctx) noexcept - # Sets *A* to *B* multiplied by the scalar *c* which must be - # an element of or coercible to the coefficient ring. - void _gr_mpoly_fit_length(gr_ptr * coeffs, slong * coeffs_alloc, ulong ** exps, slong * exps_alloc, slong N, slong length, gr_ctx_t cctx) noexcept - void gr_mpoly_fit_length(gr_mpoly_t A, slong len, const mpoly_ctx_t mctx, gr_ctx_t cctx) noexcept - # Ensures that *A* has space for *len* coefficients and exponents. - void gr_mpoly_fit_bits(gr_mpoly_t A, flint_bitcnt_t bits, const mpoly_ctx_t mctx, gr_ctx_t cctx) noexcept - void gr_mpoly_fit_length_fit_bits(gr_mpoly_t A, slong len, flint_bitcnt_t bits, const mpoly_ctx_t mctx, gr_ctx_t cctx) noexcept - void gr_mpoly_fit_length_reset_bits(gr_mpoly_t A, slong len, flint_bitcnt_t bits, const mpoly_ctx_t mctx, gr_ctx_t cctx) noexcept - void _gr_mpoly_set_length(gr_mpoly_t A, slong newlen, const mpoly_ctx_t mctx, gr_ctx_t cctx) noexcept - void _gr_mpoly_push_exp_ui(gr_mpoly_t A, const ulong * exp, const mpoly_ctx_t mctx, gr_ctx_t cctx) noexcept - int gr_mpoly_push_term_scalar_ui(gr_mpoly_t A, gr_srcptr c, const ulong * exp, const mpoly_ctx_t mctx, gr_ctx_t cctx) noexcept - void _gr_mpoly_push_exp_fmpz(gr_mpoly_t A, const fmpz * exp, const mpoly_ctx_t mctx, gr_ctx_t cctx) noexcept - int gr_mpoly_push_term_scalar_fmpz(gr_mpoly_t A, gr_srcptr c, const fmpz * exp, const mpoly_ctx_t mctx, gr_ctx_t cctx) noexcept - void gr_mpoly_sort_terms(gr_mpoly_t A, const mpoly_ctx_t mctx, gr_ctx_t cctx) noexcept - int gr_mpoly_combine_like_terms(gr_mpoly_t A, const mpoly_ctx_t mctx, gr_ctx_t cctx) noexcept - truth_t gr_mpoly_is_canonical(const gr_mpoly_t A, const mpoly_ctx_t mctx, gr_ctx_t cctx) noexcept - void gr_mpoly_assert_canonical(const gr_mpoly_t A, const mpoly_ctx_t mctx, gr_ctx_t cctx) noexcept diff --git a/src/sage/libs/flint/gr_poly.pxd b/src/sage/libs/flint/gr_poly.pxd index 2fb3da86b14..c6e11462a1c 100644 --- a/src/sage/libs/flint/gr_poly.pxd +++ b/src/sage/libs/flint/gr_poly.pxd @@ -2,7 +2,9 @@ # distutils: depends = flint/gr_poly.h ################################################################################ -# This file is auto-generated. Do not modify by hand +# This file is auto-generated by the script +# SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py. +# Do not modify by hand! Fix and rerun the script instead. ################################################################################ from libc.stdio cimport FILE @@ -11,107 +13,72 @@ from sage.libs.mpfr.types cimport * from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void gr_poly_init(gr_poly_t poly, gr_ctx_t ctx) noexcept - void gr_poly_init2(gr_poly_t poly, slong len, gr_ctx_t ctx) noexcept - void gr_poly_clear(gr_poly_t poly, gr_ctx_t ctx) noexcept - gr_ptr gr_poly_entry_ptr(gr_poly_t poly, slong i, gr_ctx_t ctx) noexcept - slong gr_poly_length(const gr_poly_t poly, gr_ctx_t ctx) noexcept - void gr_poly_swap(gr_poly_t poly1, gr_poly_t poly2, gr_ctx_t ctx) noexcept - void gr_poly_fit_length(gr_poly_t poly, slong len, gr_ctx_t ctx) noexcept - void _gr_poly_set_length(gr_poly_t poly, slong len, gr_ctx_t ctx) noexcept - void _gr_poly_normalise(gr_poly_t poly, gr_ctx_t ctx) noexcept - int gr_poly_set(gr_poly_t res, const gr_poly_t src, gr_ctx_t ctx) noexcept int gr_poly_get_fmpz_poly(gr_poly_t res, const fmpz_poly_t src, gr_ctx_t ctx) noexcept int gr_poly_set_fmpq_poly(gr_poly_t res, const fmpq_poly_t src, gr_ctx_t ctx) noexcept int gr_poly_set_gr_poly_other(gr_poly_t res, const gr_poly_t x, gr_ctx_t x_ctx, gr_ctx_t ctx) noexcept - int _gr_poly_reverse(gr_ptr res, gr_srcptr poly, slong len, slong n, gr_ctx_t ctx) noexcept int gr_poly_reverse(gr_poly_t res, const gr_poly_t poly, slong n, gr_ctx_t ctx) noexcept - int gr_poly_truncate(gr_poly_t res, const gr_poly_t poly, slong newlen, gr_ctx_t ctx) noexcept - int gr_poly_zero(gr_poly_t poly, gr_ctx_t ctx) noexcept int gr_poly_one(gr_poly_t poly, gr_ctx_t ctx) noexcept int gr_poly_neg_one(gr_poly_t poly, gr_ctx_t ctx) noexcept int gr_poly_gen(gr_poly_t poly, gr_ctx_t ctx) noexcept - int gr_poly_write(gr_stream_t out, const gr_poly_t poly, const char * x, gr_ctx_t ctx) noexcept int gr_poly_print(const gr_poly_t poly, gr_ctx_t ctx) noexcept - int gr_poly_randtest(gr_poly_t poly, flint_rand_t state, slong len, gr_ctx_t ctx) noexcept - truth_t _gr_poly_equal(gr_srcptr poly1, slong len1, gr_srcptr poly2, slong len2, gr_ctx_t ctx) noexcept truth_t gr_poly_equal(const gr_poly_t poly1, const gr_poly_t poly2, gr_ctx_t ctx) noexcept - truth_t gr_poly_is_zero(const gr_poly_t poly, gr_ctx_t ctx) noexcept truth_t gr_poly_is_one(const gr_poly_t poly, gr_ctx_t ctx) noexcept truth_t gr_poly_is_gen(const gr_poly_t poly, gr_ctx_t ctx) noexcept truth_t gr_poly_is_scalar(const gr_poly_t poly, gr_ctx_t ctx) noexcept - int gr_poly_set_scalar(gr_poly_t poly, gr_srcptr c, gr_ctx_t ctx) noexcept int gr_poly_set_si(gr_poly_t poly, slong c, gr_ctx_t ctx) noexcept int gr_poly_set_ui(gr_poly_t poly, ulong c, gr_ctx_t ctx) noexcept int gr_poly_set_fmpz(gr_poly_t poly, const fmpz_t c, gr_ctx_t ctx) noexcept int gr_poly_set_fmpq(gr_poly_t poly, const fmpq_t c, gr_ctx_t ctx) noexcept - int gr_poly_set_coeff_scalar(gr_poly_t poly, slong n, gr_srcptr c, gr_ctx_t ctx) noexcept int gr_poly_set_coeff_si(gr_poly_t poly, slong n, slong c, gr_ctx_t ctx) noexcept int gr_poly_set_coeff_ui(gr_poly_t poly, slong n, ulong c, gr_ctx_t ctx) noexcept int gr_poly_set_coeff_fmpz(gr_poly_t poly, slong n, const fmpz_t c, gr_ctx_t ctx) noexcept int gr_poly_set_coeff_fmpq(gr_poly_t poly, slong n, const fmpq_t c, gr_ctx_t ctx) noexcept - int gr_poly_get_coeff_scalar(gr_ptr res, const gr_poly_t poly, slong n, gr_ctx_t ctx) noexcept - int gr_poly_neg(gr_poly_t res, const gr_poly_t src, gr_ctx_t ctx) noexcept - int _gr_poly_add(gr_ptr res, gr_srcptr poly1, slong len1, gr_srcptr poly2, slong len2, gr_ctx_t ctx) noexcept int gr_poly_add(gr_poly_t res, const gr_poly_t poly1, const gr_poly_t poly2, gr_ctx_t ctx) noexcept - int _gr_poly_sub(gr_ptr res, gr_srcptr poly1, slong len1, gr_srcptr poly2, slong len2, gr_ctx_t ctx) noexcept int gr_poly_sub(gr_poly_t res, const gr_poly_t poly1, const gr_poly_t poly2, gr_ctx_t ctx) noexcept - int _gr_poly_mul(gr_ptr res, gr_srcptr poly1, slong len1, gr_srcptr poly2, slong len2, gr_ctx_t ctx) noexcept int gr_poly_mul(gr_poly_t res, const gr_poly_t poly1, const gr_poly_t poly2, gr_ctx_t ctx) noexcept - int _gr_poly_mullow_generic(gr_ptr res, gr_srcptr poly1, slong len1, gr_srcptr poly2, slong len2, slong len, gr_ctx_t ctx) noexcept int _gr_poly_mullow(gr_ptr res, gr_srcptr poly1, slong len1, gr_srcptr poly2, slong len2, slong len, gr_ctx_t ctx) noexcept int gr_poly_mullow(gr_poly_t res, const gr_poly_t poly1, const gr_poly_t poly2, slong len, gr_ctx_t ctx) noexcept - int gr_poly_mul_scalar(gr_poly_t res, const gr_poly_t poly, gr_srcptr c, gr_ctx_t ctx) noexcept - int _gr_poly_pow_series_ui_binexp(gr_ptr res, gr_srcptr f, slong flen, ulong exp, slong len, gr_ctx_t ctx) noexcept int gr_poly_pow_series_ui_binexp(gr_poly_t res, const gr_poly_t poly, ulong exp, slong len, gr_ctx_t ctx) noexcept - int _gr_poly_pow_series_ui(gr_ptr res, gr_srcptr f, slong flen, ulong exp, slong len, gr_ctx_t ctx) noexcept int gr_poly_pow_series_ui(gr_poly_t res, const gr_poly_t poly, ulong exp, slong len, gr_ctx_t ctx) noexcept - int _gr_poly_pow_ui_binexp(gr_ptr res, gr_srcptr f, slong flen, ulong exp, gr_ctx_t ctx) noexcept int gr_poly_pow_ui_binexp(gr_poly_t res, const gr_poly_t poly, ulong exp, gr_ctx_t ctx) noexcept - int _gr_poly_pow_ui(gr_ptr res, gr_srcptr f, slong flen, ulong exp, gr_ctx_t ctx) noexcept int gr_poly_pow_ui(gr_poly_t res, const gr_poly_t poly, ulong exp, gr_ctx_t ctx) noexcept - int gr_poly_pow_fmpz(gr_poly_t res, const gr_poly_t poly, const fmpz_t exp, gr_ctx_t ctx) noexcept - int _gr_poly_pow_series_fmpq_recurrence(gr_ptr h, gr_srcptr f, slong flen, const fmpq_t exp, slong len, int precomp, gr_ctx_t ctx) noexcept int gr_poly_pow_series_fmpq_recurrence(gr_poly_t res, const gr_poly_t poly, const fmpq_t exp, slong len, gr_ctx_t ctx) noexcept - int _gr_poly_shift_left(gr_ptr res, gr_srcptr poly, slong len, slong n, gr_ctx_t ctx) noexcept int gr_poly_shift_left(gr_poly_t res, const gr_poly_t poly, slong n, gr_ctx_t ctx) noexcept - int _gr_poly_shift_right(gr_ptr res, gr_srcptr poly, slong len, slong n, gr_ctx_t ctx) noexcept int gr_poly_shift_right(gr_poly_t res, const gr_poly_t poly, slong n, gr_ctx_t ctx) noexcept - int _gr_poly_divrem_divconquer_preinv1(gr_ptr Q, gr_ptr R, gr_srcptr A, slong lenA, gr_srcptr B, slong lenB, gr_srcptr invB, slong cutoff, gr_ctx_t ctx) noexcept int _gr_poly_divrem_divconquer_noinv(gr_ptr Q, gr_ptr R, gr_srcptr A, slong lenA, gr_srcptr B, slong lenB, slong cutoff, gr_ctx_t ctx) noexcept int _gr_poly_divrem_divconquer(gr_ptr Q, gr_ptr R, gr_srcptr A, slong lenA, gr_srcptr B, slong lenB, slong cutoff, gr_ctx_t ctx) noexcept @@ -124,40 +91,6 @@ cdef extern from "flint_wrap.h": int gr_poly_divrem_newton(gr_poly_t Q, gr_poly_t R, const gr_poly_t A, const gr_poly_t B, gr_ctx_t ctx) noexcept int _gr_poly_divrem(gr_ptr Q, gr_ptr R, gr_srcptr A, slong lenA, gr_srcptr B, slong lenB, gr_ctx_t ctx) noexcept int gr_poly_divrem(gr_poly_t Q, gr_poly_t R, const gr_poly_t A, const gr_poly_t B, gr_ctx_t ctx) noexcept - # These functions implement Euclidean division with remainder: - # given polynomials `A, B \in K[x]` where `K` is a field, with `B \ne 0`, - # there is a unique quotient `Q` and remainder `R` such that `A = BQ + R` - # and either `R = 0` or `\deg(R) < \deg(B)`. - # If *B* is provably zero, ``GR_DOMAIN`` is returned. - # When `K` is a commutative ring and `\operatorname{lc}(B)` is a unit in `K`, - # the situation is the same as over fields. In particular, Euclidean division - # with remainder always makes sense over commutative rings when `B` is monic. - # If `\operatorname{lc}(B)` is not a unit, the division still makes sense if - # the coefficient quotient `\operatorname{lc}(r)` / `\operatorname{lc}(B)` - # exists for each partial remainder `r`. Indeed, - # the *basecase* and *divconquer* algorithms return ``GR_DOMAIN`` precisely when - # encountering a leading quotient `\operatorname{lc}(r)` / `\operatorname{lc}(B) \not \in K`. - # However, the *newton* algorithm as currently implemented - # returns ``GR_DOMAIN`` when `\operatorname{lc}(B)^{-1} \not \in K`. - # The underscore methods make the following assumptions: - # * *Q* has room for ``lenA - lenB + 1`` coefficients. - # * *R* has room for ``lenB - 1`` coefficients. - # * ``lenA >= lenB >= 1``. - # * *Q* is not aliased with either *A* or *B*. - # * *R* is not aliased with *B*. - # * *R* may be aliased with *A*, in which case all ``lenA`` - # entries may be used as scratch space. Note that in this case, - # only the low ``lenB - 1`` coefficients of *R* actually represent - # valid coefficients on output: the higher scratch coefficients will not - # necessarily be zeroed. - # * The divisor *B* is normalized to have nonzero leading coefficient. - # (The non-underscore methods check for leading coefficients that - # are not provably nonzero and return ``GR_UNABLE``.) - # The *preinv1* functions take a precomputed inverse of the - # leading coefficient as input. - # The *noinv* versions perform repeated checked divisions - # by the leading coefficient. - int _gr_poly_div_divconquer_preinv1(gr_ptr Q, gr_srcptr A, slong lenA, gr_srcptr B, slong lenB, gr_srcptr invB, slong cutoff, gr_ctx_t ctx) noexcept int _gr_poly_div_divconquer_noinv(gr_ptr Q, gr_srcptr A, slong lenA, gr_srcptr B, slong lenB, slong cutoff, gr_ctx_t ctx) noexcept int _gr_poly_div_divconquer(gr_ptr Q, gr_srcptr A, slong lenA, gr_srcptr B, slong lenB, slong cutoff, gr_ctx_t ctx) noexcept @@ -170,13 +103,8 @@ cdef extern from "flint_wrap.h": int gr_poly_div_newton(gr_poly_t Q, const gr_poly_t A, const gr_poly_t B, gr_ctx_t ctx) noexcept int _gr_poly_div(gr_ptr Q, gr_srcptr A, slong lenA, gr_srcptr B, slong lenB, gr_ctx_t ctx) noexcept int gr_poly_div(gr_poly_t Q, const gr_poly_t A, const gr_poly_t B, gr_ctx_t ctx) noexcept - # Versions of the *divrem* functions which output only the quotient. - # These are generally faster. - int _gr_poly_rem(gr_ptr R, gr_srcptr A, slong lenA, gr_srcptr B, slong lenB, gr_ctx_t ctx) noexcept int gr_poly_rem(gr_poly_t R, const gr_poly_t A, const gr_poly_t B, gr_ctx_t ctx) noexcept - # Versions of the *divrem* functions which output only the remainder. - int _gr_poly_inv_series_newton(gr_ptr res, gr_srcptr A, slong Alen, slong len, slong cutoff, gr_ctx_t ctx) noexcept int gr_poly_inv_series_newton(gr_poly_t res, const gr_poly_t A, slong len, slong cutoff, gr_ctx_t ctx) noexcept int _gr_poly_inv_series_basecase_preinv1(gr_ptr res, gr_srcptr A, slong Alen, gr_srcptr Ainv, slong len, gr_ctx_t ctx) noexcept @@ -184,7 +112,6 @@ cdef extern from "flint_wrap.h": int gr_poly_inv_series_basecase(gr_poly_t res, const gr_poly_t A, slong len, gr_ctx_t ctx) noexcept int _gr_poly_inv_series(gr_ptr res, gr_srcptr A, slong Alen, slong len, gr_ctx_t ctx) noexcept int gr_poly_inv_series(gr_poly_t res, const gr_poly_t A, slong len, gr_ctx_t ctx) noexcept - int _gr_poly_div_series_newton(gr_ptr res, gr_srcptr A, slong Alen, gr_srcptr B, slong Blen, slong len, slong cutoff, gr_ctx_t ctx) noexcept int gr_poly_div_series_newton(gr_poly_t res, const gr_poly_t A, const gr_poly_t B, slong len, slong cutoff, gr_ctx_t ctx) noexcept int _gr_poly_div_series_divconquer(gr_ptr res, gr_srcptr B, slong Blen, gr_srcptr A, slong Alen, slong len, slong cutoff, gr_ctx_t ctx) noexcept @@ -197,7 +124,6 @@ cdef extern from "flint_wrap.h": int gr_poly_div_series_basecase(gr_poly_t res, const gr_poly_t A, const gr_poly_t B, slong len, gr_ctx_t ctx) noexcept int _gr_poly_div_series(gr_ptr res, gr_srcptr A, slong Alen, gr_srcptr B, slong Blen, slong len, gr_ctx_t ctx) noexcept int gr_poly_div_series(gr_poly_t res, const gr_poly_t A, const gr_poly_t B, slong len, gr_ctx_t ctx) noexcept - int _gr_poly_divexact_basecase_bidirectional(gr_ptr Q, gr_srcptr A, slong Alen, gr_srcptr B, slong Blen, gr_ctx_t ctx) noexcept int gr_poly_divexact_basecase_bidirectional(gr_poly_t Q, const gr_poly_t A, const gr_poly_t B, gr_ctx_t ctx) noexcept int _gr_poly_divexact_bidirectional(gr_ptr Q, gr_srcptr A, slong Alen, gr_srcptr B, slong Blen, gr_ctx_t ctx) noexcept @@ -205,11 +131,9 @@ cdef extern from "flint_wrap.h": int _gr_poly_divexact_basecase_noinv(gr_ptr Q, gr_srcptr A, slong Alen, gr_srcptr B, slong Blen, gr_ctx_t ctx) noexcept int _gr_poly_divexact_basecase(gr_ptr Q, gr_srcptr A, slong Alen, gr_srcptr B, slong Blen, gr_ctx_t ctx) noexcept int gr_poly_divexact_basecase(gr_poly_t Q, const gr_poly_t A, const gr_poly_t B, gr_ctx_t ctx) noexcept - int _gr_poly_divexact_series_basecase_noinv(gr_ptr Q, gr_srcptr A, slong Alen, gr_srcptr B, slong Blen, slong len, gr_ctx_t ctx) noexcept int _gr_poly_divexact_series_basecase(gr_ptr Q, gr_srcptr A, slong Alen, gr_srcptr B, slong Blen, slong len, gr_ctx_t ctx) noexcept int gr_poly_divexact_series_basecase(gr_poly_t Q, const gr_poly_t A, const gr_poly_t B, slong len, gr_ctx_t ctx) noexcept - int _gr_poly_sqrt_series_newton(gr_ptr res, gr_srcptr f, slong flen, slong len, slong cutoff, gr_ctx_t ctx) noexcept int gr_poly_sqrt_series_newton(gr_poly_t res, const gr_poly_t f, slong len, slong cutoff, gr_ctx_t ctx) noexcept int _gr_poly_sqrt_series_basecase(gr_ptr res, gr_srcptr f, slong flen, slong len, gr_ctx_t ctx) noexcept @@ -218,7 +142,6 @@ cdef extern from "flint_wrap.h": int gr_poly_sqrt_series_miller(gr_poly_t res, const gr_poly_t f, slong len, gr_ctx_t ctx) noexcept int _gr_poly_sqrt_series(gr_ptr res, gr_srcptr f, slong flen, slong len, gr_ctx_t ctx) noexcept int gr_poly_sqrt_series(gr_poly_t res, const gr_poly_t f, slong len, gr_ctx_t ctx) noexcept - int _gr_poly_rsqrt_series_newton(gr_ptr res, gr_srcptr f, slong flen, slong len, slong cutoff, gr_ctx_t ctx) noexcept int gr_poly_rsqrt_series_newton(gr_poly_t res, const gr_poly_t f, slong len, slong cutoff, gr_ctx_t ctx) noexcept int _gr_poly_rsqrt_series_basecase(gr_ptr res, gr_srcptr f, slong flen, slong len, gr_ctx_t ctx) noexcept @@ -227,42 +150,28 @@ cdef extern from "flint_wrap.h": int gr_poly_rsqrt_series_miller(gr_poly_t res, const gr_poly_t f, slong len, gr_ctx_t ctx) noexcept int _gr_poly_rsqrt_series(gr_ptr res, gr_srcptr f, slong flen, slong len, gr_ctx_t ctx) noexcept int gr_poly_rsqrt_series(gr_poly_t res, const gr_poly_t f, slong len, gr_ctx_t ctx) noexcept - int _gr_poly_evaluate_rectangular(gr_ptr res, gr_srcptr poly, slong len, gr_srcptr x, gr_ctx_t ctx) noexcept int gr_poly_evaluate_rectangular(gr_ptr res, const gr_poly_t poly, gr_srcptr x, gr_ctx_t ctx) noexcept - + int _gr_poly_evaluate_modular(gr_ptr res, gr_srcptr poly, slong len, gr_srcptr x, gr_ctx_t ctx) noexcept + int gr_poly_evaluate_modular(gr_ptr res, const gr_poly_t poly, gr_srcptr x, gr_ctx_t ctx) noexcept int _gr_poly_evaluate_horner(gr_ptr res, gr_srcptr poly, slong len, gr_srcptr x, gr_ctx_t ctx) noexcept int gr_poly_evaluate_horner(gr_ptr res, const gr_poly_t poly, gr_srcptr x, gr_ctx_t ctx) noexcept - int _gr_poly_evaluate(gr_ptr res, gr_srcptr poly, slong len, gr_srcptr x, gr_ctx_t ctx) noexcept int gr_poly_evaluate(gr_ptr res, const gr_poly_t poly, gr_srcptr x, gr_ctx_t ctx) noexcept - # Set *res* to *poly* evaluated at *x*. - int _gr_poly_evaluate_other_horner(gr_ptr res, gr_srcptr f, slong len, const gr_srcptr x, gr_ctx_t x_ctx, gr_ctx_t ctx) noexcept int gr_poly_evaluate_other_horner(gr_ptr res, const gr_poly_t f, gr_srcptr x, gr_ctx_t x_ctx, gr_ctx_t ctx) noexcept int _gr_poly_evaluate_other_rectangular(gr_ptr res, gr_srcptr f, slong len, const gr_srcptr x, gr_ctx_t x_ctx, gr_ctx_t ctx) noexcept int gr_poly_evaluate_other_rectangular(gr_ptr res, const gr_poly_t f, gr_srcptr x, gr_ctx_t x_ctx, gr_ctx_t ctx) noexcept int _gr_poly_evaluate_other(gr_ptr res, gr_srcptr f, slong len, const gr_srcptr x, gr_ctx_t x_ctx, gr_ctx_t ctx) noexcept int gr_poly_evaluate_other(gr_ptr res, const gr_poly_t f, gr_srcptr x, gr_ctx_t x_ctx, gr_ctx_t ctx) noexcept - # Set *res* to *poly* evaluated at *x*, where the coefficients of *f* - # belong to *ctx* while both *x* and *res* belong to *x_ctx*. - gr_ptr * _gr_poly_tree_alloc(slong len, gr_ctx_t ctx) noexcept - void _gr_poly_tree_free(gr_ptr * tree, slong len, gr_ctx_t ctx) noexcept - int _gr_poly_tree_build(gr_ptr * tree, gr_srcptr roots, slong len, gr_ctx_t ctx) noexcept - int _gr_poly_evaluate_vec_fast_precomp(gr_ptr vs, gr_srcptr poly, slong plen, gr_ptr * tree, slong len, gr_ctx_t ctx) noexcept - int _gr_poly_evaluate_vec_fast(gr_ptr ys, gr_srcptr poly, slong plen, gr_srcptr xs, slong n, gr_ctx_t ctx) noexcept - int gr_poly_evaluate_vec_fast(gr_vec_t ys, const gr_poly_t poly, const gr_vec_t xs, gr_ctx_t ctx) noexcept - int _gr_poly_evaluate_vec_iter(gr_ptr ys, gr_srcptr poly, slong plen, gr_srcptr xs, slong n, gr_ctx_t ctx) noexcept - int gr_poly_evaluate_vec_iter(gr_vec_t ys, const gr_poly_t poly, const gr_vec_t xs, gr_ctx_t ctx) noexcept - int _gr_poly_taylor_shift_horner(gr_ptr res, gr_srcptr poly, slong len, gr_srcptr c, gr_ctx_t ctx) noexcept int gr_poly_taylor_shift_horner(gr_poly_t res, const gr_poly_t poly, gr_srcptr c, gr_ctx_t ctx) noexcept int _gr_poly_taylor_shift_divconquer(gr_ptr res, gr_srcptr poly, slong len, gr_srcptr c, gr_ctx_t ctx) noexcept @@ -271,26 +180,12 @@ cdef extern from "flint_wrap.h": int gr_poly_taylor_shift_convolution(gr_poly_t res, const gr_poly_t poly, gr_srcptr c, gr_ctx_t ctx) noexcept int _gr_poly_taylor_shift(gr_ptr res, gr_srcptr poly, slong len, gr_srcptr c, gr_ctx_t ctx) noexcept int gr_poly_taylor_shift(gr_poly_t res, const gr_poly_t poly, gr_srcptr c, gr_ctx_t ctx) noexcept - # Sets *res* to the Taylor shift `f(x+c)`, where *f* is given by - # *poly*, computed respectively using - # an optimized form of Horner's rule, divide-and-conquer, a single - # convolution, and an automatic choice between the three algorithms. - # The underscore methods support aliasing. - int _gr_poly_compose_horner(gr_ptr res, gr_srcptr poly1, slong len1, gr_srcptr poly2, slong len2, gr_ctx_t ctx) noexcept int gr_poly_compose_horner(gr_poly_t res, const gr_poly_t poly1, const gr_poly_t poly2, gr_ctx_t ctx) noexcept int _gr_poly_compose_divconquer(gr_ptr res, gr_srcptr poly1, slong len1, gr_srcptr poly2, slong len2, gr_ctx_t ctx) noexcept int gr_poly_compose_divconquer(gr_poly_t res, const gr_poly_t poly1, const gr_poly_t poly2, gr_ctx_t ctx) noexcept int _gr_poly_compose(gr_ptr res, gr_srcptr poly1, slong len1, gr_srcptr poly2, slong len2, gr_ctx_t ctx) noexcept int gr_poly_compose(gr_poly_t res, const gr_poly_t poly1, const gr_poly_t poly2, gr_ctx_t ctx) noexcept - # Sets *res* to the composition `f(g(x))` where *f* is given by *poly1* - # and *g* is given by *poly2*, respectively using Horner's rule, - # divide-and-conquer, and an automatic choice between the two algorithms. - # The default algorithm also handles special-form input `g = ax^n + c` - # efficiently by performing a Taylor shift followed by a rescaling. - # The underscore methods do not support aliasing of the output - # with either input polynomial. - int _gr_poly_compose_series_horner(gr_ptr res, gr_srcptr poly1, slong len1, gr_srcptr poly2, slong len2, slong n, gr_ctx_t ctx) noexcept int gr_poly_compose_series_horner(gr_poly_t res, const gr_poly_t poly1, const gr_poly_t poly2, slong n, gr_ctx_t ctx) noexcept int _gr_poly_compose_series_brent_kung(gr_ptr res, gr_srcptr poly1, slong len1, gr_srcptr poly2, slong len2, slong n, gr_ctx_t ctx) noexcept @@ -299,64 +194,35 @@ cdef extern from "flint_wrap.h": int gr_poly_compose_series_divconquer(gr_poly_t res, const gr_poly_t poly1, const gr_poly_t poly2, slong n, gr_ctx_t ctx) noexcept int _gr_poly_compose_series(gr_ptr res, gr_srcptr poly1, slong len1, gr_srcptr poly2, slong len2, slong n, gr_ctx_t ctx) noexcept int gr_poly_compose_series(gr_poly_t res, const gr_poly_t poly1, const gr_poly_t poly2, slong n, gr_ctx_t ctx) noexcept - # Sets *res* to the power series composition `h(x) = f(g(x))` truncated - # to order `O(x^n)` where `f` is given by *poly1* and `g` is given by *poly2*, - # respectively using Horner's rule, the Brent-Kung baby step-giant step - # algorithm [BrentKung1978]_, divide-and-conquer, and an automatic choice between the algorithms. - # The default algorithm also handles short input and - # special-form input `g = ax^n` efficiently. - # We require that the constant term in `g(x)` is exactly zero. - # The underscore methods do not support aliasing of the output - # with either input polynomial, and do not zero-pad the result. - + int _gr_poly_revert_series_lagrange(gr_ptr res, gr_srcptr f, slong flen, slong n, gr_ctx_t ctx) noexcept + int gr_poly_revert_series_lagrange(gr_poly_t res, const gr_poly_t f, slong n, gr_ctx_t ctx) noexcept + int _gr_poly_revert_series_lagrange_fast(gr_ptr res, gr_srcptr f, slong flen, slong n, gr_ctx_t ctx) noexcept + int gr_poly_revert_series_lagrange_fast(gr_poly_t res, const gr_poly_t f, slong n, gr_ctx_t ctx) noexcept + int _gr_poly_revert_series_newton(gr_ptr res, gr_srcptr f, slong flen, slong n, gr_ctx_t ctx) noexcept + int gr_poly_revert_series_newton(gr_poly_t res, const gr_poly_t f, slong n, gr_ctx_t ctx) noexcept + int _gr_poly_revert_series(gr_ptr res, gr_srcptr f, slong flen, slong n, gr_ctx_t ctx) noexcept + int gr_poly_revert_series(gr_poly_t res, const gr_poly_t f, slong n, gr_ctx_t ctx) noexcept int _gr_poly_derivative(gr_ptr res, gr_srcptr poly, slong len, gr_ctx_t ctx) noexcept int gr_poly_derivative(gr_poly_t res, const gr_poly_t poly, gr_ctx_t ctx) noexcept - int _gr_poly_nth_derivative(gr_ptr res, gr_srcptr poly, ulong n, slong len, gr_ctx_t ctx) noexcept int gr_poly_nth_derivative(gr_poly_t res, const gr_poly_t poly, ulong n, gr_ctx_t ctx) noexcept - int _gr_poly_integral(gr_ptr res, gr_srcptr poly, slong len, gr_ctx_t ctx) noexcept int gr_poly_integral(gr_poly_t res, const gr_poly_t poly, gr_ctx_t ctx) noexcept - int _gr_poly_make_monic(gr_ptr res, gr_srcptr poly, slong len, gr_ctx_t ctx) noexcept int gr_poly_make_monic(gr_poly_t res, const gr_poly_t src, gr_ctx_t ctx) noexcept - truth_t _gr_poly_is_monic(gr_srcptr poly, slong len, gr_ctx_t ctx) noexcept truth_t gr_poly_is_monic(const gr_poly_t res, gr_ctx_t ctx) noexcept - int _gr_poly_hgcd(gr_ptr r, slong * sgn, gr_ptr * M, slong * lenM, gr_ptr A, slong * lenA, gr_ptr B, slong * lenB, gr_srcptr a, slong lena, gr_srcptr b, slong lenb, slong cutoff, gr_ctx_t ctx) noexcept - # Computes the HGCD of `a` and `b`, that is, a matrix `M`, a sign `\sigma` - # and two polynomials `A` and `B` such that - # .. math :: - # (A,B)^t = \sigma M^{-1} (a,b)^t. - # Assumes that `\operatorname{len}(a) > \operatorname{len}(b) > 0`. - # Assumes that `A` and `B` have space of size at least `\operatorname{len}(a)` - # and `\operatorname{len}(b)`, respectively. On exit, ``*lenA`` and ``*lenB`` - # will contain the correct lengths of `A` and `B`. - # Assumes that ``M[0]``, ``M[1]``, ``M[2]``, and ``M[3]`` - # each point to a vector of size at least `\operatorname{len}(a)`. - # If `r` is not ``NULL``, writes to that variable the corresponding value - # for computing resultants using the HGCD algorithm. - int _gr_poly_gcd_hgcd(gr_ptr G, slong * _lenG, gr_srcptr A, slong lenA, gr_srcptr B, slong lenB, slong inner_cutoff, slong cutoff, gr_ctx_t ctx) noexcept int gr_poly_gcd_hgcd(gr_poly_t G, const gr_poly_t A, const gr_poly_t B, slong inner_cutoff, slong cutoff, gr_ctx_t ctx) noexcept int _gr_poly_gcd_euclidean(gr_ptr G, slong * lenG, gr_srcptr A, slong lenA, gr_srcptr B, slong lenB, gr_ctx_t ctx) noexcept int gr_poly_gcd_euclidean(gr_poly_t G, const gr_poly_t A, const gr_poly_t B, gr_ctx_t ctx) noexcept int _gr_poly_gcd(gr_ptr G, slong * lenG, gr_srcptr A, slong lenA, gr_srcptr B, slong lenB, gr_ctx_t ctx) noexcept int gr_poly_gcd(gr_poly_t G, const gr_poly_t A, const gr_poly_t B, gr_ctx_t ctx) noexcept - # Polynomial GCD. Currently only useful over fields. - # The underscore methods assume ``lenA >= lenB >= 1`` and that both - # *A* and *B* have nonzero leading coefficient. - # The underscore methods do not attempt to make the result monic. - # The time complexity of the half-GCD algorithm is `\mathcal{O}(n \log^2 n)` - # ring operations. For further details, see [ThullYap1990]_. - int _gr_poly_xgcd_euclidean(slong * lenG, gr_ptr G, gr_ptr S, gr_ptr T, gr_srcptr A, slong lenA, gr_srcptr B, slong lenB, gr_ctx_t ctx) noexcept int gr_poly_xgcd_euclidean(gr_poly_t G, gr_poly_t S, gr_poly_t T, const gr_poly_t A, const gr_poly_t B, gr_ctx_t ctx) noexcept - int _gr_poly_xgcd_hgcd(slong * Glen, gr_ptr G, gr_ptr S, gr_ptr T, gr_srcptr A, slong lenA, gr_srcptr B, slong lenB, slong hgcd_cutoff, slong cutoff, gr_ctx_t ctx) noexcept int gr_poly_xgcd_hgcd(gr_poly_t G, gr_poly_t S, gr_poly_t T, const gr_poly_t A, const gr_poly_t B, slong hgcd_cutoff, slong cutoff, gr_ctx_t ctx) noexcept - int _gr_poly_resultant_euclidean(gr_ptr res, gr_srcptr poly1, slong len1, gr_srcptr poly2, slong len2, gr_ctx_t ctx) noexcept int gr_poly_resultant_euclidean(gr_ptr res, const gr_poly_t f, const gr_poly_t g, gr_ctx_t ctx) noexcept int _gr_poly_resultant_hgcd(gr_ptr res, gr_srcptr A, slong lenA, gr_srcptr B, slong lenB, slong inner_cutoff, slong cutoff, gr_ctx_t ctx) noexcept @@ -367,59 +233,10 @@ cdef extern from "flint_wrap.h": int gr_poly_resultant_small(gr_ptr res, const gr_poly_t f, const gr_poly_t g, gr_ctx_t ctx) noexcept int _gr_poly_resultant(gr_ptr res, gr_srcptr poly1, slong len1, gr_srcptr poly2, slong len2, gr_ctx_t ctx) noexcept int gr_poly_resultant(gr_ptr res, const gr_poly_t f, const gr_poly_t g, gr_ctx_t ctx) noexcept - # Sets *res* to the resultant of *poly1* and *poly2*. - # The underscore methods assume that `len1 \ge len2 \ge 1` - # and that the leading coefficients are nonzero. - # The *euclidean* algorithm is the ordinary Euclidean algorithm. - # The *hgcd* version uses the quasilinear half-GCD algorithm. - # It requires two extra tuning parameters ``inner_cutoff`` - # (recursion threshold passed forward to the HGCD algorithm) - # and ``cutoff``. Both algorithms can fail when run over - # non-fields; they will return ``GR_DOMAIN`` - # when encountering an impossible inverse. - # The *small* version uses division-free straight-line programs - # optimized for short polynomials. - # It returns ``GR_UNABLE`` if the polynomials are too large. - # Currently this function handles the cases where `len1 \le 2` - # or `len2 \le 3`. - # The *sylvester* version constructs the Sylvester matrix - # and computes its determinant. This is useful over inexact rings - # and as a fallback for rings without division. - # The default version attempts to choose an appropriate - # algorithm automatically. - # Currently no algorithm has been implemented that is appropriate for - # integral domains. - int gr_poly_factor_squarefree(gr_ptr c, gr_vec_t fac, gr_vec_t exp, const gr_poly_t poly, gr_ctx_t ctx) noexcept - # Computes a squarefree factorization of *poly*. - # The constant *c* is set to an element of the scalar ring. - # The factors in *fac* are set to polynomials; the user must thus - # initialize it to a vector of polynomials of the same type as - # *poly* (and *not* to the parent *ctx*). - # The exponent vector *exp* must be initialized to the *fmpz* type. - int gr_poly_squarefree_part(gr_poly_t res, const gr_poly_t poly, gr_ctx_t ctx) noexcept - # Sets *res* to the squarefreepart of *poly*. - int gr_poly_roots(gr_vec_t roots, gr_vec_t mult, const gr_poly_t poly, int flags, gr_ctx_t ctx) noexcept int gr_poly_roots_other(gr_vec_t roots, gr_vec_t mult, const gr_poly_t poly, gr_ctx_t poly_ctx, int flags, gr_ctx_t ctx) noexcept - # Finds all roots of the given polynomial in the ring defined by *ctx*, - # storing the roots without duplication in *roots* (a vector with - # elements of type ``ctx``) and the corresponding multiplicities in - # *mult* (a vector with elements of type ``fmpz``). - # If the target ring is not an algebraically closed field, then - # the sum of multiplicities can be smaller than the degree of the - # polynomial. For example, with ``fmpz`` coefficients, we only - # find integer roots. - # The *other* version of this function takes as input a polynomial - # with entries in a different ring ``poly_ctx``. For example, - # we can compute ``qqbar`` or ``arb`` roots for a polynomial - # with ``fmpz`` coefficients. - # Whether the roots are sorted in any particular order is - # ring-dependent. - # We consider roots of the zero polynomial to be ill-defined and return - # ``GR_DOMAIN`` in that case. - int _gr_poly_asin_series(gr_ptr res, gr_srcptr f, slong flen, slong len, gr_ctx_t ctx) noexcept int gr_poly_asin_series(gr_poly_t res, const gr_poly_t f, slong len, gr_ctx_t ctx) noexcept int _gr_poly_asinh_series(gr_ptr res, gr_srcptr f, slong flen, slong len, gr_ctx_t ctx) noexcept @@ -432,12 +249,10 @@ cdef extern from "flint_wrap.h": int gr_poly_atan_series(gr_poly_t res, const gr_poly_t f, slong len, gr_ctx_t ctx) noexcept int _gr_poly_atanh_series(gr_ptr res, gr_srcptr f, slong flen, slong len, gr_ctx_t ctx) noexcept int gr_poly_atanh_series(gr_poly_t res, const gr_poly_t f, slong len, gr_ctx_t ctx) noexcept - int _gr_poly_log_series(gr_ptr res, gr_srcptr f, slong flen, slong len, gr_ctx_t ctx) noexcept int gr_poly_log_series(gr_poly_t res, const gr_poly_t f, slong len, gr_ctx_t ctx) noexcept int _gr_poly_log1p_series(gr_ptr res, gr_srcptr f, slong flen, slong len, gr_ctx_t ctx) noexcept int gr_poly_log1p_series(gr_poly_t res, const gr_poly_t f, slong len, gr_ctx_t ctx) noexcept - int _gr_poly_exp_series_basecase(gr_ptr f, gr_srcptr h, slong hlen, slong n, gr_ctx_t ctx) noexcept int gr_poly_exp_series_basecase(gr_poly_t f, const gr_poly_t h, slong n, gr_ctx_t ctx) noexcept int _gr_poly_exp_series_basecase_mul(gr_ptr f, gr_srcptr h, slong hlen, slong n, gr_ctx_t ctx) noexcept @@ -447,23 +262,10 @@ cdef extern from "flint_wrap.h": int _gr_poly_exp_series_generic(gr_ptr f, gr_srcptr h, slong hlen, slong n, gr_ctx_t ctx) noexcept int _gr_poly_exp_series(gr_ptr res, gr_srcptr f, slong flen, slong len, gr_ctx_t ctx) noexcept int gr_poly_exp_series(gr_poly_t f, const gr_poly_t h, slong n, gr_ctx_t ctx) noexcept - int _gr_poly_sin_cos_series_basecase(gr_ptr s, gr_ptr c, gr_srcptr h, slong hlen, slong n, int times_pi, gr_ctx_t ctx) noexcept int gr_poly_sin_cos_series_basecase(gr_poly_t s, gr_poly_t c, const gr_poly_t h, slong n, int times_pi, gr_ctx_t ctx) noexcept int _gr_poly_sin_cos_series_tangent(gr_ptr s, gr_ptr c, gr_srcptr h, slong hlen, slong n, int times_pi, gr_ctx_t ctx) noexcept int gr_poly_sin_cos_series_tangent(gr_poly_t s, gr_poly_t c, const gr_poly_t h, slong n, int times_pi, gr_ctx_t ctx) noexcept - # The *basecase* version uses a simple recurrence for the coefficients, - # requiring `O(nm)` operations where `m` is the length of `h`. - # The *tangent* version uses the tangent half-angle formulas to compute - # the sine and cosine via :func:`_acb_poly_tan_series`. This - # requires `O(M(n))` operations. - # When `h = h_0 + h_1` where the constant term `h_0` is nonzero, - # the evaluation is done as - # `\sin(h_0 + h_1) = \cos(h_0) \sin(h_1) + \sin(h_0) \cos(h_1)`, - # `\cos(h_0 + h_1) = \cos(h_0) \cos(h_1) - \sin(h_0) \sin(h_1)`. - # The *basecase* and *tangent* versions take a flag *times_pi* - # specifying that the input is to be multiplied by `\pi`. - int _gr_poly_tan_series_basecase(gr_ptr f, gr_srcptr h, slong hlen, slong n, gr_ctx_t ctx) noexcept int gr_poly_tan_series_basecase(gr_poly_t f, const gr_poly_t h, slong n, gr_ctx_t ctx) noexcept int _gr_poly_tan_series_newton(gr_ptr f, gr_srcptr h, slong hlen, slong n, slong cutoff, gr_ctx_t ctx) noexcept diff --git a/src/sage/libs/flint/gr_special.pxd b/src/sage/libs/flint/gr_special.pxd index 568fbd98581..adf199366fe 100644 --- a/src/sage/libs/flint/gr_special.pxd +++ b/src/sage/libs/flint/gr_special.pxd @@ -2,7 +2,9 @@ # distutils: depends = flint/gr_special.h ################################################################################ -# This file is auto-generated. Do not modify by hand +# This file is auto-generated by the script +# SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py. +# Do not modify by hand! Fix and rerun the script instead. ################################################################################ from libc.stdio cimport FILE @@ -11,15 +13,11 @@ from sage.libs.mpfr.types cimport * from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - int gr_pi(gr_ptr res, gr_ctx_t ctx) noexcept int gr_euler(gr_ptr res, gr_ctx_t ctx) noexcept int gr_catalan(gr_ptr res, gr_ctx_t ctx) noexcept int gr_khinchin(gr_ptr res, gr_ctx_t ctx) noexcept int gr_glaisher(gr_ptr res, gr_ctx_t ctx) noexcept - # Standard real constants: `\pi`, Euler's constant `\gamma`, - # Catalan's constant, Khinchin's constant, Glaisher's constant. - int gr_exp(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept int gr_expm1(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept int gr_exp2(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept @@ -30,7 +28,6 @@ cdef extern from "flint_wrap.h": int gr_log2(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept int gr_log10(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept int gr_log_pi_i(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept - int gr_sin(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept int gr_cos(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept int gr_sin_cos(gr_ptr res1, gr_ptr res2, gr_srcptr x, gr_ctx_t ctx) noexcept @@ -38,7 +35,6 @@ cdef extern from "flint_wrap.h": int gr_cot(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept int gr_sec(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept int gr_csc(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept - int gr_sin_pi(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept int gr_cos_pi(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept int gr_sin_cos_pi(gr_ptr res1, gr_ptr res2, gr_srcptr x, gr_ctx_t ctx) noexcept @@ -46,10 +42,8 @@ cdef extern from "flint_wrap.h": int gr_cot_pi(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept int gr_sec_pi(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept int gr_csc_pi(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept - int gr_sinc(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept int gr_sinc_pi(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept - int gr_sinh(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept int gr_cosh(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept int gr_sinh_cosh(gr_ptr res1, gr_ptr res2, gr_srcptr x, gr_ctx_t ctx) noexcept @@ -57,7 +51,6 @@ cdef extern from "flint_wrap.h": int gr_coth(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept int gr_sech(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept int gr_csch(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept - int gr_asin(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept int gr_acos(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept int gr_atan(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept @@ -65,139 +58,83 @@ cdef extern from "flint_wrap.h": int gr_acot(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept int gr_asec(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept int gr_acsc(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept - int gr_asin_pi(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept int gr_acos_pi(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept int gr_atan_pi(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept int gr_acot_pi(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept int gr_asec_pi(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept int gr_acsc_pi(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept - int gr_asinh(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept int gr_acosh(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept int gr_atanh(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept int gr_acoth(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept int gr_asech(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept int gr_acsch(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept - int gr_lambertw(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept int gr_lambertw_fmpz(gr_ptr res, gr_srcptr x, const fmpz_t k, gr_ctx_t ctx) noexcept - int gr_fac(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept int gr_fac_ui(gr_ptr res, ulong x, gr_ctx_t ctx) noexcept int gr_fac_fmpz(gr_ptr res, const fmpz_t x, gr_ctx_t ctx) noexcept int gr_fac_vec(gr_ptr res, slong len, gr_ctx_t ctx) noexcept - # Factorial `x!`. The *vec* version writes the first *len* - # consecutive values `1, 1, 2, 6, \ldots, (len-1)!` - # to the preallocated vector *res*. - int gr_rfac(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept int gr_rfac_ui(gr_ptr res, ulong x, gr_ctx_t ctx) noexcept int gr_rfac_fmpz(gr_ptr res, const fmpz_t x, gr_ctx_t ctx) noexcept int gr_rfac_vec(gr_ptr res, slong len, gr_ctx_t ctx) noexcept - # Reciprocal factorial. The *vec* version writes the first *len* - # consecutive values `1, 1, 1/2, 1/6, \ldots, 1/(len-1)!` - # to the preallocated vector *res*. - int gr_bin(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) noexcept int gr_bin_ui(gr_ptr res, gr_srcptr x, ulong y, gr_ctx_t ctx) noexcept int gr_bin_uiui(gr_ptr res, ulong x, ulong y, gr_ctx_t ctx) noexcept int gr_bin_vec(gr_ptr res, gr_srcptr x, slong len, gr_ctx_t ctx) noexcept int gr_bin_ui_vec(gr_ptr res, ulong x, slong len, gr_ctx_t ctx) noexcept - # Binomial coefficient `{x choose y}`. The *vec* versions write the - # first *len* consecutive values `{x choose 0}, {x choose 1}, \ldots, {x choose len-1}` - # to the preallocated vector *res*. - # For constructing a two-dimensional array of binomial - # coefficients (Pascal's triangle), it is more efficient to - # call :func:`gr_mat_pascal` than to call these functions repeatedly. - int gr_rising(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) noexcept int gr_rising_ui(gr_ptr res, gr_srcptr x, ulong y, gr_ctx_t ctx) noexcept int gr_falling(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) noexcept int gr_falling_ui(gr_ptr res, gr_srcptr x, ulong y, gr_ctx_t ctx) noexcept - # Rising and falling factorials `x (x+1) \cdots (x+y-1)` - # and `x (x-1) \cdots (x-y+1)`, or their generalizations - # to non-integer `y` via the gamma function. - int gr_gamma(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept int gr_gamma_fmpz(gr_ptr res, const fmpz_t x, gr_ctx_t ctx) noexcept int gr_gamma_fmpq(gr_ptr res, const fmpq_t x, gr_ctx_t ctx) noexcept int gr_rgamma(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept int gr_lgamma(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept int gr_digamma(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept - # Gamma function `\Gamma(x)`, its reciprocal `1 / \Gamma(x)`, - # the log-gamma function `\log \Gamma(x)`, and the digamma function - # `\psi(x)`. - int gr_barnes_g(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept int gr_log_barnes_g(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept - # Barnes G-function. - int gr_beta(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) noexcept - # Beta function `B(x,y)`. - int gr_doublefac(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept int gr_doublefac_ui(gr_ptr res, ulong x, gr_ctx_t ctx) noexcept - # Double factorial `x!!`. - int gr_harmonic(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept int gr_harmonic_ui(gr_ptr res, ulong x, gr_ctx_t ctx) noexcept - # Harmonic number `H_x`. - int gr_bernoulli_ui(gr_ptr res, ulong n, gr_ctx_t ctx) noexcept int gr_bernoulli_fmpz(gr_ptr res, const fmpz_t n, gr_ctx_t ctx) noexcept int gr_bernoulli_vec(gr_ptr res, slong len, gr_ctx_t ctx) noexcept - # Bernoulli numbers `B_n`. - int gr_eulernum_ui(gr_ptr res, ulong x, gr_ctx_t ctx) noexcept int gr_eulernum_fmpz(gr_ptr res, const fmpz_t x, gr_ctx_t ctx) noexcept int gr_eulernum_vec(gr_ptr res, slong len, gr_ctx_t ctx) noexcept - # Euler numbers `E_n`. - int gr_fib_ui(gr_ptr res, ulong n, gr_ctx_t ctx) noexcept int gr_fib_fmpz(gr_ptr res, const fmpz_t n, gr_ctx_t ctx) noexcept int gr_fib_vec(gr_ptr res, slong len, gr_ctx_t ctx) noexcept - # Fibonacci numbers `F_n`. - int gr_stirling_s1u_uiui(gr_ptr res, ulong x, ulong y, gr_ctx_t ctx) noexcept int gr_stirling_s1_uiui(gr_ptr res, ulong x, ulong y, gr_ctx_t ctx) noexcept int gr_stirling_s2_uiui(gr_ptr res, ulong x, ulong y, gr_ctx_t ctx) noexcept int gr_stirling_s1u_ui_vec(gr_ptr res, ulong x, slong len, gr_ctx_t ctx) noexcept int gr_stirling_s1_ui_vec(gr_ptr res, ulong x, slong len, gr_ctx_t ctx) noexcept int gr_stirling_s2_ui_vec(gr_ptr res, ulong x, slong len, gr_ctx_t ctx) noexcept - # Stirling numbers `S(x,y)`: unsigned of the first kind, - # signed of the first kind, and second kind. The *vec* versions - # write the *len* consecutive values `S(x,0), S(x,1), \ldots, S(x, len-1)` - # to the preallocated vector *res*. - # For constructing a two-dimensional array of Stirling numbers, - # it is more efficient to - # call :func:`gr_mat_stirling` than to call these functions repeatedly. - int gr_bellnum_ui(gr_ptr res, ulong x, gr_ctx_t ctx) noexcept int gr_bellnum_fmpz(gr_ptr res, const fmpz_t x, gr_ctx_t ctx) noexcept int gr_bellnum_vec(gr_ptr res, slong len, gr_ctx_t ctx) noexcept - # Bell numbers `B_n`. - int gr_partitions_ui(gr_ptr res, ulong x, gr_ctx_t ctx) noexcept int gr_partitions_fmpz(gr_ptr res, const fmpz_t x, gr_ctx_t ctx) noexcept int gr_partitions_vec(gr_ptr res, slong len, gr_ctx_t ctx) noexcept - # Partition numbers `p(n)`. - int gr_erf(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept int gr_erfc(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept int gr_erfcx(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept int gr_erfi(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept int gr_erfinv(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept int gr_erfcinv(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept - int gr_fresnel_s(gr_ptr res, gr_srcptr x, int normalized, gr_ctx_t ctx) noexcept int gr_fresnel_c(gr_ptr res, gr_srcptr x, int normalized, gr_ctx_t ctx) noexcept int gr_fresnel(gr_ptr res1, gr_ptr res2, gr_srcptr x, int normalized, gr_ctx_t ctx) noexcept - int gr_gamma_upper(gr_ptr res, gr_srcptr x, gr_srcptr y, int regularized, gr_ctx_t ctx) noexcept int gr_gamma_lower(gr_ptr res, gr_srcptr x, gr_srcptr y, int regularized, gr_ctx_t ctx) noexcept int gr_beta_lower(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_srcptr z, int regularized, gr_ctx_t ctx) noexcept - int gr_exp_integral(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) noexcept int gr_exp_integral_ei(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept int gr_sin_integral(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept @@ -206,12 +143,10 @@ cdef extern from "flint_wrap.h": int gr_cosh_integral(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept int gr_log_integral(gr_ptr res, gr_srcptr x, int offset, gr_ctx_t ctx) noexcept int gr_dilog(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept - int gr_chebyshev_t_fmpz(gr_ptr res, const fmpz_t n, gr_srcptr x, gr_ctx_t ctx) noexcept int gr_chebyshev_t(gr_ptr res, gr_srcptr n, gr_srcptr x, gr_ctx_t ctx) noexcept int gr_chebyshev_u_fmpz(gr_ptr res, const fmpz_t n, gr_srcptr x, gr_ctx_t ctx) noexcept int gr_chebyshev_u(gr_ptr res, gr_srcptr n, gr_srcptr x, gr_ctx_t ctx) noexcept - int gr_jacobi_p(gr_ptr res, gr_srcptr n, gr_srcptr a, gr_srcptr b, gr_srcptr z, gr_ctx_t ctx) noexcept int gr_gegenbauer_c(gr_ptr res, gr_srcptr n, gr_srcptr m, gr_srcptr z, gr_ctx_t ctx) noexcept int gr_laguerre_l(gr_ptr res, gr_srcptr n, gr_srcptr m, gr_srcptr z, gr_ctx_t ctx) noexcept @@ -220,7 +155,6 @@ cdef extern from "flint_wrap.h": int gr_legendre_q(gr_ptr res, gr_srcptr n, gr_srcptr m, gr_srcptr z, int type, gr_ctx_t ctx) noexcept int gr_spherical_y_si(gr_ptr res, slong n, slong m, gr_srcptr theta, gr_srcptr phi, gr_ctx_t ctx) noexcept int gr_legendre_p_root_ui(gr_ptr root, gr_ptr weight, ulong n, ulong k, gr_ctx_t ctx) noexcept - int gr_bessel_j(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) noexcept int gr_bessel_y(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) noexcept int gr_bessel_i(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) noexcept @@ -228,30 +162,25 @@ cdef extern from "flint_wrap.h": int gr_bessel_j_y(gr_ptr res1, gr_ptr res2, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) noexcept int gr_bessel_i_scaled(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) noexcept int gr_bessel_k_scaled(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) noexcept - int gr_airy(gr_ptr res1, gr_ptr res2, gr_ptr res3, gr_ptr res4, gr_srcptr x, gr_ctx_t ctx) noexcept int gr_airy_ai(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept int gr_airy_bi(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept int gr_airy_ai_prime(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept int gr_airy_bi_prime(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept - int gr_airy_ai_zero(gr_ptr res, const fmpz_t n, gr_ctx_t ctx) noexcept int gr_airy_bi_zero(gr_ptr res, const fmpz_t n, gr_ctx_t ctx) noexcept int gr_airy_ai_prime_zero(gr_ptr res, const fmpz_t n, gr_ctx_t ctx) noexcept int gr_airy_bi_prime_zero(gr_ptr res, const fmpz_t n, gr_ctx_t ctx) noexcept - int gr_coulomb(gr_ptr res1, gr_ptr res2, gr_ptr res3, gr_ptr res4, gr_srcptr x, gr_srcptr y, gr_srcptr z, gr_ctx_t ctx) noexcept int gr_coulomb_f(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_srcptr z, gr_ctx_t ctx) noexcept int gr_coulomb_g(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_srcptr z, gr_ctx_t ctx) noexcept int gr_coulomb_hpos(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_srcptr z, gr_ctx_t ctx) noexcept int gr_coulomb_hneg(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_srcptr z, gr_ctx_t ctx) noexcept - int gr_hypgeom_0f1(gr_ptr res, gr_srcptr a, gr_srcptr z, int flags, gr_ctx_t ctx) noexcept int gr_hypgeom_1f1(gr_ptr res, gr_srcptr a, gr_srcptr b, gr_srcptr z, int flags, gr_ctx_t ctx) noexcept int gr_hypgeom_u(gr_ptr res, gr_srcptr a, gr_srcptr b, gr_srcptr z, int flags, gr_ctx_t ctx) noexcept int gr_hypgeom_2f1(gr_ptr res, gr_srcptr a, gr_srcptr b, gr_srcptr c, gr_srcptr z, int flags, gr_ctx_t ctx) noexcept int gr_hypgeom_pfq(gr_ptr res, const gr_vec_t a, const gr_vec_t b, gr_srcptr z, int flags, gr_ctx_t ctx) noexcept - int gr_zeta(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept int gr_zeta_ui(gr_ptr res, ulong x, gr_ctx_t ctx) noexcept int gr_hurwitz_zeta(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) noexcept @@ -259,58 +188,46 @@ cdef extern from "flint_wrap.h": int gr_polylog(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) noexcept int gr_lerch_phi(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_srcptr z, gr_ctx_t ctx) noexcept int gr_stieltjes(gr_ptr res, const fmpz_t x, gr_srcptr y, gr_ctx_t ctx) noexcept - int gr_dirichlet_eta(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept int gr_riemann_xi(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept int gr_zeta_zero(gr_ptr res, const fmpz_t n, gr_ctx_t ctx) noexcept int gr_zeta_zero_vec(gr_ptr res, const fmpz_t n, slong len, gr_ctx_t ctx) noexcept int gr_zeta_nzeros(gr_ptr res, gr_srcptr t, gr_ctx_t ctx) noexcept - int gr_dirichlet_chi_fmpz(gr_ptr res, const dirichlet_group_t G, const dirichlet_char_t chi, const fmpz_t n, gr_ctx_t ctx) noexcept int gr_dirichlet_chi_vec(gr_ptr res, const dirichlet_group_t G, const dirichlet_char_t chi, slong len, gr_ctx_t ctx) noexcept int gr_dirichlet_l(gr_ptr res, const dirichlet_group_t G, const dirichlet_char_t chi, gr_srcptr s, gr_ctx_t ctx) noexcept int gr_dirichlet_l_all(gr_vec_t res, const dirichlet_group_t G, gr_srcptr s, gr_ctx_t ctx) noexcept int gr_dirichlet_hardy_theta(gr_ptr res, const dirichlet_group_t G, const dirichlet_char_t chi, gr_srcptr t, gr_ctx_t ctx) noexcept int gr_dirichlet_hardy_z(gr_ptr res, const dirichlet_group_t G, const dirichlet_char_t chi, gr_srcptr t, gr_ctx_t ctx) noexcept - int gr_agm1(gr_ptr res, gr_srcptr x, gr_ctx_t ctx) noexcept int gr_agm(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_ctx_t ctx) noexcept - int gr_elliptic_k(gr_ptr res, gr_srcptr m, gr_ctx_t ctx) noexcept int gr_elliptic_e(gr_ptr res, gr_srcptr m, gr_ctx_t ctx) noexcept int gr_elliptic_pi(gr_ptr res, gr_srcptr n, gr_srcptr m, gr_ctx_t ctx) noexcept int gr_elliptic_f(gr_ptr res, gr_srcptr phi, gr_srcptr m, int pi, gr_ctx_t ctx) noexcept int gr_elliptic_e_inc(gr_ptr res, gr_srcptr phi, gr_srcptr m, int pi, gr_ctx_t ctx) noexcept int gr_elliptic_pi_inc(gr_ptr res, gr_srcptr n, gr_srcptr phi, gr_srcptr m, int pi, gr_ctx_t ctx) noexcept - int gr_carlson_rc(gr_ptr res, gr_srcptr x, gr_srcptr y, int flags, gr_ctx_t ctx) noexcept int gr_carlson_rf(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_srcptr z, int flags, gr_ctx_t ctx) noexcept int gr_carlson_rd(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_srcptr z, int flags, gr_ctx_t ctx) noexcept int gr_carlson_rg(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_srcptr z, int flags, gr_ctx_t ctx) noexcept int gr_carlson_rj(gr_ptr res, gr_srcptr x, gr_srcptr y, gr_srcptr z, gr_srcptr w, int flags, gr_ctx_t ctx) noexcept - int gr_jacobi_theta(gr_ptr res1, gr_ptr res2, gr_ptr res3, gr_ptr res4, gr_srcptr z, gr_srcptr tau, gr_ctx_t ctx) noexcept int gr_jacobi_theta_1(gr_ptr res, gr_srcptr z, gr_srcptr tau, gr_ctx_t ctx) noexcept int gr_jacobi_theta_2(gr_ptr res, gr_srcptr z, gr_srcptr tau, gr_ctx_t ctx) noexcept int gr_jacobi_theta_3(gr_ptr res, gr_srcptr z, gr_srcptr tau, gr_ctx_t ctx) noexcept int gr_jacobi_theta_4(gr_ptr res, gr_srcptr z, gr_srcptr tau, gr_ctx_t ctx) noexcept - int gr_dedekind_eta(gr_ptr res, gr_srcptr tau, gr_ctx_t ctx) noexcept int gr_dedekind_eta_q(gr_ptr res, gr_srcptr tau, gr_ctx_t ctx) noexcept - int gr_modular_j(gr_ptr res, gr_srcptr tau, gr_ctx_t ctx) noexcept int gr_modular_lambda(gr_ptr res, gr_srcptr tau, gr_ctx_t ctx) noexcept int gr_modular_delta(gr_ptr res, gr_srcptr tau, gr_ctx_t ctx) noexcept - int gr_hilbert_class_poly(gr_ptr res, slong D, gr_srcptr x, gr_ctx_t ctx) noexcept - int gr_eisenstein_e(gr_ptr res, ulong n, gr_srcptr tau, gr_ctx_t ctx) noexcept int gr_eisenstein_g(gr_ptr res, ulong n, gr_srcptr tau, gr_ctx_t ctx) noexcept int gr_eisenstein_g_vec(gr_ptr res, gr_srcptr tau, slong len, gr_ctx_t ctx) noexcept - int gr_elliptic_invariants(gr_ptr res1, gr_ptr res2, gr_srcptr tau, gr_ctx_t ctx) noexcept int gr_elliptic_roots(gr_ptr res1, gr_ptr res2, gr_ptr res3, gr_srcptr tau, gr_ctx_t ctx) noexcept - int gr_weierstrass_p(gr_ptr res, gr_srcptr z, gr_srcptr tau, gr_ctx_t ctx) noexcept int gr_weierstrass_p_prime(gr_ptr res, gr_srcptr z, gr_srcptr tau, gr_ctx_t ctx) noexcept int gr_weierstrass_p_inv(gr_ptr res, gr_srcptr z, gr_srcptr tau, gr_ctx_t ctx) noexcept diff --git a/src/sage/libs/flint/gr_vec.pxd b/src/sage/libs/flint/gr_vec.pxd index a5dbd3ba96f..bc7c81f7960 100644 --- a/src/sage/libs/flint/gr_vec.pxd +++ b/src/sage/libs/flint/gr_vec.pxd @@ -2,7 +2,9 @@ # distutils: depends = flint/gr_vec.h ################################################################################ -# This file is auto-generated. Do not modify by hand +# This file is auto-generated by the script +# SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py. +# Do not modify by hand! Fix and rerun the script instead. ################################################################################ from libc.stdio cimport FILE @@ -11,76 +13,34 @@ from sage.libs.mpfr.types cimport * from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void gr_vec_init(gr_vec_t vec, slong len, gr_ctx_t ctx) noexcept - # Initializes *vec* to a vector of length *len* with elements - # in the ring *ctx*. The length must be nonnegative. - # All entries are set to zero. - void gr_vec_clear(gr_vec_t vec, gr_ctx_t ctx) noexcept - # Clears the vector *vec*. - gr_ptr gr_vec_entry_ptr(gr_vec_t vec, slong i, gr_ctx_t ctx) noexcept - # Returns a pointer to the *i*-th element in the vector *vec*, - # indexed from zero. The index must be in bounds. - slong gr_vec_length(const gr_vec_t vec, gr_ctx_t ctx) noexcept - # Returns the length of the vector *vec*. - void gr_vec_fit_length(gr_vec_t vec, slong len, gr_ctx_t ctx) noexcept - # Allocates space for at least *len* elements in the vector *vec*. - # This does not change the size of the vector. - void gr_vec_set_length(gr_vec_t vec, slong len, gr_ctx_t ctx) noexcept - # Resizes the vector to length *len*, which must be nonnegative. - # The vector will be extended with zeros. - int gr_vec_set(gr_vec_t res, const gr_vec_t src, gr_ctx_t ctx) noexcept - # Sets *res* to a copy of the vector *src*. - int gr_vec_append(gr_vec_t vec, gr_srcptr x, gr_ctx_t ctx) noexcept - # Appends the element *x* to the end of vector *vec*. - int _gr_vec_write(gr_stream_t out, gr_srcptr vec, slong len, gr_ctx_t ctx) noexcept int gr_vec_write(gr_stream_t out, const gr_vec_t vec, gr_ctx_t ctx) noexcept int gr_vec_print(const gr_vec_t vec, gr_ctx_t ctx) noexcept - void _gr_vec_init(gr_ptr vec, slong len, gr_ctx_t ctx) noexcept - # Initialize *len* elements of *vec* to the value 0. - # The pointer *vec* must already refer to allocated memory. - void _gr_vec_clear(gr_ptr vec, slong len, gr_ctx_t ctx) noexcept - # Clears *len* elements of *vec*. - # This frees memory allocated by individual elements, but - # does not free the memory allocated by *vec* itself. - void _gr_vec_swap(gr_ptr vec1, gr_ptr vec2, slong len, gr_ctx_t ctx) noexcept - # Swap the entries of *vec1* and *vec2*. - int _gr_vec_randtest(gr_ptr res, flint_rand_t state, slong len, gr_ctx_t ctx) noexcept - int _gr_vec_set(gr_ptr res, gr_srcptr src, slong len, gr_ctx_t ctx) noexcept - truth_t _gr_vec_equal(gr_srcptr vec1, gr_srcptr vec2, slong len, gr_ctx_t ctx) noexcept - int _gr_vec_zero(gr_ptr vec, slong len, gr_ctx_t ctx) noexcept - truth_t _gr_vec_is_zero(gr_srcptr vec, slong len, gr_ctx_t ctx) noexcept - int _gr_vec_normalise(slong * res, gr_srcptr vec, slong len, gr_ctx_t ctx) noexcept - slong _gr_vec_normalise_weak(gr_srcptr vec, slong len, gr_ctx_t ctx) noexcept - int _gr_vec_neg(gr_ptr res, gr_srcptr src, slong len, gr_ctx_t ctx) noexcept - int _gr_vec_add(gr_ptr res, gr_srcptr src1, gr_srcptr src2, slong len, gr_ctx_t ctx) noexcept int _gr_vec_sub(gr_ptr res, gr_srcptr src1, gr_srcptr src2, slong len, gr_ctx_t ctx) noexcept int _gr_vec_mul(gr_ptr res, gr_srcptr src1, gr_srcptr src2, slong len, gr_ctx_t ctx) noexcept int _gr_vec_div(gr_ptr res, gr_srcptr src1, gr_srcptr src2, slong len, gr_ctx_t ctx) noexcept int _gr_vec_divexact(gr_ptr res, gr_srcptr src1, gr_srcptr src2, slong len, gr_ctx_t ctx) noexcept int _gr_vec_pow(gr_ptr res, gr_srcptr src1, gr_srcptr src2, slong len, gr_ctx_t ctx) noexcept - # Binary operations applied elementwise. - int _gr_vec_add_scalar(gr_ptr vec1, gr_srcptr vec2, slong len, gr_srcptr c, gr_ctx_t ctx) noexcept int _gr_vec_sub_scalar(gr_ptr vec1, gr_srcptr vec2, slong len, gr_srcptr c, gr_ctx_t ctx) noexcept int _gr_vec_mul_scalar(gr_ptr vec1, gr_srcptr vec2, slong len, gr_srcptr c, gr_ctx_t ctx) noexcept @@ -93,8 +53,6 @@ cdef extern from "flint_wrap.h": int _gr_scalar_div_vec(gr_ptr vec1, gr_srcptr c, gr_srcptr vec2, slong len, gr_ctx_t ctx) noexcept int _gr_scalar_divexact_vec(gr_ptr vec1, gr_srcptr c, gr_srcptr vec2, slong len, gr_ctx_t ctx) noexcept int _gr_scalar_pow_vec(gr_ptr vec1, gr_srcptr c, gr_srcptr vec2, slong len, gr_ctx_t ctx) noexcept - # Binary operations applied elementwise with a fixed scalar operand. - int _gr_vec_add_other(gr_ptr vec1, gr_srcptr vec2, gr_srcptr vec3, gr_ctx_t ctx3, slong len, gr_ctx_t ctx) noexcept int _gr_vec_sub_other(gr_ptr vec1, gr_srcptr vec2, gr_srcptr vec3, gr_ctx_t ctx3, slong len, gr_ctx_t ctx) noexcept int _gr_vec_mul_other(gr_ptr vec1, gr_srcptr vec2, gr_srcptr vec3, gr_ctx_t ctx3, slong len, gr_ctx_t ctx) noexcept @@ -107,8 +65,6 @@ cdef extern from "flint_wrap.h": int _gr_other_div_vec(gr_ptr vec1, gr_srcptr vec2, gr_ctx_t ctx2, gr_srcptr vec3, slong len, gr_ctx_t ctx) noexcept int _gr_other_divexact_vec(gr_ptr vec1, gr_srcptr vec2, gr_ctx_t ctx2, gr_srcptr vec3, slong len, gr_ctx_t ctx) noexcept int _gr_other_pow_vec(gr_ptr vec1, gr_srcptr vec2, gr_ctx_t ctx2, gr_srcptr vec3, slong len, gr_ctx_t ctx) noexcept - # Binary operations applied elementwise, allowing a different type for one of the vectors. - int _gr_vec_add_scalar_other(gr_ptr vec1, gr_srcptr vec2, slong len, gr_srcptr c, gr_ctx_t cctx, gr_ctx_t ctx) noexcept int _gr_vec_sub_scalar_other(gr_ptr vec1, gr_srcptr vec2, slong len, gr_srcptr c, gr_ctx_t cctx, gr_ctx_t ctx) noexcept int _gr_vec_mul_scalar_other(gr_ptr vec1, gr_srcptr vec2, slong len, gr_srcptr c, gr_ctx_t cctx, gr_ctx_t ctx) noexcept @@ -145,32 +101,18 @@ cdef extern from "flint_wrap.h": int _gr_vec_div_scalar_fmpq(gr_ptr vec1, gr_srcptr vec2, slong len, const fmpq_t c, gr_ctx_t ctx) noexcept int _gr_vec_divexact_scalar_fmpq(gr_ptr vec1, gr_srcptr vec2, slong len, const fmpq_t c, gr_ctx_t ctx) noexcept int _gr_vec_pow_scalar_fmpq(gr_ptr vec1, gr_srcptr vec2, slong len, const fmpq_t c, gr_ctx_t ctx) noexcept - # Binary operations applied elementwise with a fixed scalar operand, allowing a different type - # for the scalar. - int _gr_vec_addmul_scalar(gr_ptr vec1, gr_srcptr vec2, slong len, gr_srcptr c, gr_ctx_t ctx) noexcept int _gr_vec_submul_scalar(gr_ptr vec1, gr_srcptr vec2, slong len, gr_srcptr c, gr_ctx_t ctx) noexcept int _gr_vec_addmul_scalar_si(gr_ptr vec1, gr_srcptr vec2, slong len, slong c, gr_ctx_t ctx) noexcept int _gr_vec_submul_scalar_si(gr_ptr vec1, gr_srcptr vec2, slong len, slong c, gr_ctx_t ctx) noexcept - int _gr_vec_mul_scalar_2exp_si(gr_ptr res, gr_srcptr vec, slong len, slong c, gr_ctx_t ctx) noexcept - int _gr_vec_sum(gr_ptr res, gr_srcptr vec, slong len, gr_ctx_t ctx) noexcept - int _gr_vec_product(gr_ptr res, gr_srcptr vec, slong len, gr_ctx_t ctx) noexcept - int _gr_vec_dot(gr_ptr res, gr_srcptr initial, int subtract, gr_srcptr vec1, gr_srcptr vec2, slong len, gr_ctx_t ctx) noexcept int _gr_vec_dot_si(gr_ptr res, gr_srcptr initial, int subtract, gr_srcptr vec1, const slong * vec2, slong len, gr_ctx_t ctx) noexcept int _gr_vec_dot_ui(gr_ptr res, gr_srcptr initial, int subtract, gr_srcptr vec1, const ulong * vec2, slong len, gr_ctx_t ctx) noexcept int _gr_vec_dot_fmpz(gr_ptr res, gr_srcptr initial, int subtract, gr_srcptr vec1, const fmpz * vec2, slong len, gr_ctx_t ctx) noexcept - # Sets *res* to `c \pm \sum_{i=0}^{n-1} a_i b_i`. - int _gr_vec_dot_rev(gr_ptr res, gr_srcptr initial, int subtract, gr_srcptr vec1, gr_srcptr vec2, slong len, gr_ctx_t ctx) noexcept - # Sets *res* to `c \pm \sum_{i=0}^{n-1} a_i b_{n-1-i}`. - int _gr_vec_step(gr_ptr vec, gr_srcptr start, gr_srcptr step, slong len, gr_ctx_t ctx) noexcept - int _gr_vec_reciprocals(gr_ptr res, slong len, gr_ctx_t ctx) noexcept - # Sets *res* to the vector of reciprocals of the positive integers 1, 2, ... up to *len* inclusive. - int _gr_vec_set_powers(gr_ptr res, gr_srcptr x, slong len, gr_ctx_t ctx) noexcept diff --git a/src/sage/libs/flint/hypgeom.pxd b/src/sage/libs/flint/hypgeom.pxd index e1dc128deda..9eaa171d3b4 100644 --- a/src/sage/libs/flint/hypgeom.pxd +++ b/src/sage/libs/flint/hypgeom.pxd @@ -2,7 +2,9 @@ # distutils: depends = flint/hypgeom.h ################################################################################ -# This file is auto-generated. Do not modify by hand +# This file is auto-generated by the script +# SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py. +# Do not modify by hand! Fix and rerun the script instead. ################################################################################ from libc.stdio cimport FILE @@ -11,53 +13,10 @@ from sage.libs.mpfr.types cimport * from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void hypgeom_init(hypgeom_t hyp) noexcept - void hypgeom_clear(hypgeom_t hyp) noexcept - slong hypgeom_estimate_terms(const mag_t z, int r, slong d) noexcept - # Computes an approximation of the largest `n` such - # that `|z|^n/(n!)^r = 2^{-d}`, giving a first-order estimate of the - # number of terms needed to approximate the sum of a hypergeometric - # series of weight `r \ge 0` and argument `z` to an absolute - # precision of `d \ge 0` bits. If `r = 0`, the direct solution of the - # equation is given by `n = (\log(1-z) - d \log 2) / \log z`. - # If `r > 0`, using `\log n! \approx n \log n - n` gives an equation - # that can be solved in terms of the Lambert *W*-function as - # `n = (d \log 2) / (r\,W\!(t))` where - # `t = (d \log 2) / (e r z^{1/r})`. - # The evaluation is done using double precision arithmetic. - # The function aborts if the computed value of `n` is greater - # than or equal to LONG_MAX / 2. - slong hypgeom_bound(mag_t error, int r, slong C, slong D, slong K, const mag_t TK, const mag_t z, slong prec) noexcept - # Computes a truncation parameter sufficient to achieve *prec* bits - # of absolute accuracy, according to the strategy described above. - # The input consists of `r`, `C`, `D`, `K`, precomputed bound for `T(K)`, - # and `\tilde z = z (a_p / b_q)`, such that for `k > K`, the hypergeometric - # term ratio is bounded by - # .. math :: - # \frac{\tilde z}{k^r} \frac{k(k-D)}{(k-C)(k-2D)}. - # Given this information, we compute a `\varepsilon` and an - # integer `n` such that - # `\left| \sum_{k=n}^{\infty} T(k) \right| \le \varepsilon \le 2^{-\mathrm{prec}}`. - # The output variable *error* is set to the value of `\varepsilon`, - # and `n` is returned. - void hypgeom_precompute(hypgeom_t hyp) noexcept - # Precomputes the bounds data `C`, `D`, `K` and an upper bound for `T(K)`. - void arb_hypgeom_sum(arb_t P, arb_t Q, const hypgeom_t hyp, slong n, slong prec) noexcept - # Computes `P, Q` such that `P / Q = \sum_{k=0}^{n-1} T(k)` where `T(k)` - # is defined by *hyp*, - # using binary splitting and a working precision of *prec* bits. - void arb_hypgeom_infsum(arb_t P, arb_t Q, hypgeom_t hyp, slong tol, slong prec) noexcept - # Computes `P, Q` such that `P / Q = \sum_{k=0}^{\infty} T(k)` where `T(k)` - # is defined by *hyp*, using binary splitting and - # working precision of *prec* bits. - # The number of terms is chosen automatically to bound the - # truncation error by at most `2^{-\mathrm{tol}}`. - # The bound for the truncation error is included in the output - # as part of *P*. diff --git a/src/sage/libs/flint/long_extras.pxd b/src/sage/libs/flint/long_extras.pxd index 258aaabf3eb..e578cac1e83 100644 --- a/src/sage/libs/flint/long_extras.pxd +++ b/src/sage/libs/flint/long_extras.pxd @@ -2,7 +2,9 @@ # distutils: depends = flint/long_extras.h ################################################################################ -# This file is auto-generated. Do not modify by hand +# This file is auto-generated by the script +# SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py. +# Do not modify by hand! Fix and rerun the script instead. ################################################################################ from libc.stdio cimport FILE @@ -11,29 +13,9 @@ from sage.libs.mpfr.types cimport * from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - size_t z_sizeinbase(slong n, int b) noexcept - # Returns the number of digits in the base `b` representation - # of the absolute value of the integer `n`. - # Assumes that `b \geq 2`. - int z_mul_checked(slong * a, slong b, slong c) noexcept - # Set `*a` to `b` times `c` and return `1` if the product overflowed. Otherwise, return `0`. - mp_limb_signed_t z_randtest(flint_rand_t state) noexcept - # Returns a pseudo random number with a random number of bits, from - # `0` to ``FLINT_BITS``. The probability of the special values `0`, - # `\pm 1`, ``COEFF_MAX``, ``COEFF_MIN``, ``WORD_MAX`` and - # ``WORD_MIN`` is increased. - # This random function is mainly used for testing purposes. - mp_limb_signed_t z_randtest_not_zero(flint_rand_t state) noexcept - # As for ``z_randtest(state)``, but does not return `0`. - mp_limb_signed_t z_randint(flint_rand_t state, mp_limb_t limit) noexcept - # Returns a pseudo random number of absolute value less than - # ``limit``. If ``limit`` is zero or exceeds ``WORD_MAX``, - # it is interpreted as ``WORD_MAX``. - int z_kronecker(slong a, slong n) noexcept - # Return the Kronecker symbol `\left(\frac{a}{n}\right)` for any `a` and any `n`. diff --git a/src/sage/libs/flint/mag.pxd b/src/sage/libs/flint/mag.pxd index 0a1a16736e4..738fd8a9a30 100644 --- a/src/sage/libs/flint/mag.pxd +++ b/src/sage/libs/flint/mag.pxd @@ -2,7 +2,9 @@ # distutils: depends = flint/mag.h ################################################################################ -# This file is auto-generated. Do not modify by hand +# This file is auto-generated by the script +# SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py. +# Do not modify by hand! Fix and rerun the script instead. ################################################################################ from libc.stdio cimport FILE @@ -11,355 +13,117 @@ from sage.libs.mpfr.types cimport * from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void mag_init(mag_t x) noexcept - # Initializes the variable *x* for use. Its value is set to zero. - void mag_clear(mag_t x) noexcept - # Clears the variable *x*, freeing or recycling its allocated memory. - void mag_swap(mag_t x, mag_t y) noexcept - # Swaps *x* and *y* efficiently. - mag_ptr _mag_vec_init(slong n) noexcept - # Allocates a vector of length *n*. All entries are set to zero. - void _mag_vec_clear(mag_ptr v, slong n) noexcept - # Clears a vector of length *n*. - slong mag_allocated_bytes(const mag_t x) noexcept - # Returns the total number of bytes heap-allocated internally by this object. - # The count excludes the size of the structure itself. Add - # ``sizeof(mag_struct)`` to get the size of the object as a whole. - void mag_zero(mag_t res) noexcept - # Sets *res* to zero. - void mag_one(mag_t res) noexcept - # Sets *res* to one. - void mag_inf(mag_t res) noexcept - # Sets *res* to positive infinity. - bint mag_is_special(const mag_t x) noexcept - # Returns nonzero iff *x* is zero or positive infinity. - bint mag_is_zero(const mag_t x) noexcept - # Returns nonzero iff *x* is zero. - bint mag_is_inf(const mag_t x) noexcept - # Returns nonzero iff *x* is positive infinity. - bint mag_is_finite(const mag_t x) noexcept - # Returns nonzero iff *x* is not positive infinity (since there is no - # NaN value, this function is exactly the logical negation of :func:`mag_is_inf`). - void mag_init_set(mag_t res, const mag_t x) noexcept - # Initializes *res* and sets it to the value of *x*. This operation is always exact. - void mag_set(mag_t res, const mag_t x) noexcept - # Sets *res* to the value of *x*. This operation is always exact. - void mag_set_d(mag_t res, double x) noexcept - void mag_set_ui(mag_t res, ulong x) noexcept - void mag_set_fmpz(mag_t res, const fmpz_t x) noexcept - # Sets *res* to an upper bound for `|x|`. The operation may be inexact - # even if *x* is exactly representable. - void mag_set_d_lower(mag_t res, double x) noexcept - void mag_set_ui_lower(mag_t res, ulong x) noexcept - void mag_set_fmpz_lower(mag_t res, const fmpz_t x) noexcept - # Sets *res* to a lower bound for `|x|`. - # The operation may be inexact even if *x* is exactly representable. - void mag_set_d_2exp_fmpz(mag_t res, double x, const fmpz_t y) noexcept - void mag_set_fmpz_2exp_fmpz(mag_t res, const fmpz_t x, const fmpz_t y) noexcept - void mag_set_ui_2exp_si(mag_t res, ulong x, slong y) noexcept - # Sets *res* to an upper bound for `|x| \cdot 2^y`. - void mag_set_d_2exp_fmpz_lower(mag_t res, double x, const fmpz_t y) noexcept - void mag_set_fmpz_2exp_fmpz_lower(mag_t res, const fmpz_t x, const fmpz_t y) noexcept - # Sets *res* to a lower bound for `|x| \cdot 2^y`. - double mag_get_d(const mag_t x) noexcept - # Returns a *double* giving an upper bound for *x*. - double mag_get_d_log2_approx(const mag_t x) noexcept - # Returns a *double* approximating `\log_2(x)`, suitable for estimating - # magnitudes (warning: not a rigorous bound). - # The value is clamped between *COEFF_MIN* and *COEFF_MAX*. - void mag_get_fmpq(fmpq_t res, const mag_t x) noexcept - void mag_get_fmpz(fmpz_t res, const mag_t x) noexcept - void mag_get_fmpz_lower(fmpz_t res, const mag_t x) noexcept - # Sets *res*, respectively, to the exact rational number represented by *x*, - # the integer exactly representing the ceiling function of *x*, or the - # integer exactly representing the floor function of *x*. - # These functions are unsafe: the user must check in advance that *x* is of - # reasonable magnitude. If *x* is infinite or has a bignum exponent, an - # abort will be raised. If the exponent otherwise is too large or too small, - # the available memory could be exhausted resulting in undefined behavior. - bint mag_equal(const mag_t x, const mag_t y) noexcept - # Returns nonzero iff *x* and *y* have the same value. - int mag_cmp(const mag_t x, const mag_t y) noexcept - # Returns negative, zero, or positive, depending on whether *x* - # is smaller, equal, or larger than *y*. - int mag_cmp_2exp_si(const mag_t x, slong y) noexcept - # Returns negative, zero, or positive, depending on whether *x* - # is smaller, equal, or larger than `2^y`. - void mag_min(mag_t res, const mag_t x, const mag_t y) noexcept - void mag_max(mag_t res, const mag_t x, const mag_t y) noexcept - # Sets *res* respectively to the smaller or the larger of *x* and *y*. - void mag_print(const mag_t x) noexcept - # Prints *x* to standard output. - void mag_fprint(FILE * file, const mag_t x) noexcept - # Prints *x* to the stream *file*. - char * mag_dump_str(const mag_t x) noexcept - # Allocates a string and writes a binary representation of *x* to it that can - # be read by :func:`mag_load_str`. The returned string needs to be - # deallocated with *flint_free*. - int mag_load_str(mag_t x, const char * str) noexcept - # Parses *str* into *x*. Returns a nonzero value if *str* is not formatted - # correctly. - int mag_dump_file(FILE * stream, const mag_t x) noexcept - # Writes a binary representation of *x* to *stream* that can be read by - # :func:`mag_load_file`. Returns a nonzero value if the data could not be - # written. - int mag_load_file(mag_t x, FILE * stream) noexcept - # Reads *x* from *stream*. Returns a nonzero value if the data is not - # formatted correctly or the read failed. Note that the data is assumed to be - # delimited by a whitespace or end-of-file, i.e., when writing multiple - # values with :func:`mag_dump_file` make sure to insert a whitespace to - # separate consecutive values. - void mag_randtest(mag_t res, flint_rand_t state, slong expbits) noexcept - # Sets *res* to a random finite value, with an exponent up to *expbits* bits large. - void mag_randtest_special(mag_t res, flint_rand_t state, slong expbits) noexcept - # Like :func:`mag_randtest`, but also sometimes sets *res* to infinity. - void mag_add(mag_t res, const mag_t x, const mag_t y) noexcept - void mag_add_ui(mag_t res, const mag_t x, ulong y) noexcept - # Sets *res* to an upper bound for `x + y`. - void mag_add_lower(mag_t res, const mag_t x, const mag_t y) noexcept - void mag_add_ui_lower(mag_t res, const mag_t x, ulong y) noexcept - # Sets *res* to a lower bound for `x + y`. - void mag_add_2exp_fmpz(mag_t res, const mag_t x, const fmpz_t e) noexcept - # Sets *res* to an upper bound for `x + 2^e`. - void mag_add_ui_2exp_si(mag_t res, const mag_t x, ulong y, slong e) noexcept - # Sets *res* to an upper bound for `x + y 2^e`. - void mag_sub(mag_t res, const mag_t x, const mag_t y) noexcept - # Sets *res* to an upper bound for `\max(x-y, 0)`. - void mag_sub_lower(mag_t res, const mag_t x, const mag_t y) noexcept - # Sets *res* to a lower bound for `\max(x-y, 0)`. - void mag_mul_2exp_si(mag_t res, const mag_t x, slong y) noexcept - void mag_mul_2exp_fmpz(mag_t res, const mag_t x, const fmpz_t y) noexcept - # Sets *res* to `x \cdot 2^y`. This operation is exact. - void mag_mul(mag_t res, const mag_t x, const mag_t y) noexcept - void mag_mul_ui(mag_t res, const mag_t x, ulong y) noexcept - void mag_mul_fmpz(mag_t res, const mag_t x, const fmpz_t y) noexcept - # Sets *res* to an upper bound for `xy`. - void mag_mul_lower(mag_t res, const mag_t x, const mag_t y) noexcept - void mag_mul_ui_lower(mag_t res, const mag_t x, ulong y) noexcept - void mag_mul_fmpz_lower(mag_t res, const mag_t x, const fmpz_t y) noexcept - # Sets *res* to a lower bound for `xy`. - void mag_addmul(mag_t z, const mag_t x, const mag_t y) noexcept - # Sets *z* to an upper bound for `z + xy`. - void mag_div(mag_t res, const mag_t x, const mag_t y) noexcept - void mag_div_ui(mag_t res, const mag_t x, ulong y) noexcept - void mag_div_fmpz(mag_t res, const mag_t x, const fmpz_t y) noexcept - # Sets *res* to an upper bound for `x / y`. - void mag_div_lower(mag_t res, const mag_t x, const mag_t y) noexcept - # Sets *res* to a lower bound for `x / y`. - void mag_inv(mag_t res, const mag_t x) noexcept - # Sets *res* to an upper bound for `1 / x`. - void mag_inv_lower(mag_t res, const mag_t x) noexcept - # Sets *res* to a lower bound for `1 / x`. - void mag_fast_init_set(mag_t x, const mag_t y) noexcept - # Initialises *x* and sets it to the value of *y*. - void mag_fast_zero(mag_t res) noexcept - # Sets *res* to zero. - bint mag_fast_is_zero(const mag_t x) noexcept - # Returns nonzero iff *x* to zero. - void mag_fast_mul(mag_t res, const mag_t x, const mag_t y) noexcept - # Sets *res* to an upper bound for `xy`. - void mag_fast_addmul(mag_t z, const mag_t x, const mag_t y) noexcept - # Sets *z* to an upper bound for `z + xy`. - void mag_fast_add_2exp_si(mag_t res, const mag_t x, slong e) noexcept - # Sets *res* to an upper bound for `x + 2^e`. - void mag_fast_mul_2exp_si(mag_t res, const mag_t x, slong e) noexcept - # Sets *res* to an upper bound for `x 2^e`. - void mag_pow_ui(mag_t res, const mag_t x, ulong e) noexcept - void mag_pow_fmpz(mag_t res, const mag_t x, const fmpz_t e) noexcept - # Sets *res* to an upper bound for `x^e`. - void mag_pow_ui_lower(mag_t res, const mag_t x, ulong e) noexcept - void mag_pow_fmpz_lower(mag_t res, const mag_t x, const fmpz_t e) noexcept - # Sets *res* to a lower bound for `x^e`. - void mag_sqrt(mag_t res, const mag_t x) noexcept - # Sets *res* to an upper bound for `\sqrt{x}`. - void mag_sqrt_lower(mag_t res, const mag_t x) noexcept - # Sets *res* to a lower bound for `\sqrt{x}`. - void mag_rsqrt(mag_t res, const mag_t x) noexcept - # Sets *res* to an upper bound for `1/\sqrt{x}`. - void mag_rsqrt_lower(mag_t res, const mag_t x) noexcept - # Sets *res* to an lower bound for `1/\sqrt{x}`. - void mag_hypot(mag_t res, const mag_t x, const mag_t y) noexcept - # Sets *res* to an upper bound for `\sqrt{x^2 + y^2}`. - void mag_root(mag_t res, const mag_t x, ulong n) noexcept - # Sets *res* to an upper bound for `x^{1/n}`. - void mag_log(mag_t res, const mag_t x) noexcept - # Sets *res* to an upper bound for `\log(\max(1,x))`. - void mag_log_lower(mag_t res, const mag_t x) noexcept - # Sets *res* to a lower bound for `\log(\max(1,x))`. - void mag_neg_log(mag_t res, const mag_t x) noexcept - # Sets *res* to an upper bound for `-\log(\min(1,x))`, i.e. an upper - # bound for `|\log(x)|` for `x \le 1`. - void mag_neg_log_lower(mag_t res, const mag_t x) noexcept - # Sets *res* to a lower bound for `-\log(\min(1,x))`, i.e. a lower - # bound for `|\log(x)|` for `x \le 1`. - void mag_log_ui(mag_t res, ulong n) noexcept - # Sets *res* to an upper bound for `\log(n)`. - void mag_log1p(mag_t res, const mag_t x) noexcept - # Sets *res* to an upper bound for `\log(1+x)`. The bound is computed - # accurately for small *x*. - void mag_exp(mag_t res, const mag_t x) noexcept - # Sets *res* to an upper bound for `\exp(x)`. - void mag_exp_lower(mag_t res, const mag_t x) noexcept - # Sets *res* to a lower bound for `\exp(x)`. - void mag_expinv(mag_t res, const mag_t x) noexcept - # Sets *res* to an upper bound for `\exp(-x)`. - void mag_expinv_lower(mag_t res, const mag_t x) noexcept - # Sets *res* to a lower bound for `\exp(-x)`. - void mag_expm1(mag_t res, const mag_t x) noexcept - # Sets *res* to an upper bound for `\exp(x) - 1`. The bound is computed - # accurately for small *x*. - void mag_exp_tail(mag_t res, const mag_t x, ulong N) noexcept - # Sets *res* to an upper bound for `\sum_{k=N}^{\infty} x^k / k!`. - void mag_binpow_uiui(mag_t res, ulong m, ulong n) noexcept - # Sets *res* to an upper bound for `(1 + 1/m)^n`. - void mag_geom_series(mag_t res, const mag_t x, ulong N) noexcept - # Sets *res* to an upper bound for `\sum_{k=N}^{\infty} x^k`. - void mag_const_pi(mag_t res) noexcept - void mag_const_pi_lower(mag_t res) noexcept - # Sets *res* to an upper (respectively lower) bound for `\pi`. - void mag_atan(mag_t res, const mag_t x) noexcept - void mag_atan_lower(mag_t res, const mag_t x) noexcept - # Sets *res* to an upper (respectively lower) bound for `\operatorname{atan}(x)`. - void mag_cosh(mag_t res, const mag_t x) noexcept - void mag_cosh_lower(mag_t res, const mag_t x) noexcept - void mag_sinh(mag_t res, const mag_t x) noexcept - void mag_sinh_lower(mag_t res, const mag_t x) noexcept - # Sets *res* to an upper or lower bound for `\cosh(x)` or `\sinh(x)`. - void mag_fac_ui(mag_t res, ulong n) noexcept - # Sets *res* to an upper bound for `n!`. - void mag_rfac_ui(mag_t res, ulong n) noexcept - # Sets *res* to an upper bound for `1/n!`. - void mag_bin_uiui(mag_t res, ulong n, ulong k) noexcept - # Sets *res* to an upper bound for the binomial coefficient `{n choose k}`. - void mag_bernoulli_div_fac_ui(mag_t res, ulong n) noexcept - # Sets *res* to an upper bound for `|B_n| / n!` where `B_n` denotes - # a Bernoulli number. - void mag_polylog_tail(mag_t res, const mag_t z, slong s, ulong d, ulong N) noexcept - # Sets *res* to an upper bound for - # .. math :: - # \sum_{k=N}^{\infty} \frac{z^k \log^d(k)}{k^s}. - # The bounding strategy is described in :ref:`algorithms_polylogarithms`. - # Note: in applications where `s` in this formula may be - # real or complex, the user can simply - # substitute any convenient integer `s'` such that `s' \le \operatorname{Re}(s)`. - void mag_hurwitz_zeta_uiui(mag_t res, ulong s, ulong a) noexcept - # Sets *res* to an upper bound for `\zeta(s,a) = \sum_{k=0}^{\infty} (k+a)^{-s}`. - # We use the formula - # .. math :: - # \zeta(s,a) \le \frac{1}{a^s} + \frac{1}{(s-1) a^{s-1}} - # which is obtained by estimating the sum by an integral. - # If `s \le 1` or `a = 0`, the bound is infinite. from .mag_macros cimport * diff --git a/src/sage/libs/flint/mag_macros.pxd b/src/sage/libs/flint/mag_macros.pxd index 52bd50a906a..836fc681fd1 100644 --- a/src/sage/libs/flint/mag_macros.pxd +++ b/src/sage/libs/flint/mag_macros.pxd @@ -1,8 +1,7 @@ # Macros from mag.h -# See https://github.com/flintlib/flint/issues/152 +# See https://github.com/flintlib/flint/issues/1529 from .types cimport * cdef extern from "flint_wrap.h": long MAG_BITS - diff --git a/src/sage/libs/flint/mpf_mat.pxd b/src/sage/libs/flint/mpf_mat.pxd index 27013710381..b4524a336cf 100644 --- a/src/sage/libs/flint/mpf_mat.pxd +++ b/src/sage/libs/flint/mpf_mat.pxd @@ -2,7 +2,9 @@ # distutils: depends = flint/mpf_mat.h ################################################################################ -# This file is auto-generated. Do not modify by hand +# This file is auto-generated by the script +# SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py. +# Do not modify by hand! Fix and rerun the script instead. ################################################################################ from libc.stdio cimport FILE @@ -11,90 +13,22 @@ from sage.libs.mpfr.types cimport * from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void mpf_mat_init(mpf_mat_t mat, slong rows, slong cols, flint_bitcnt_t prec) noexcept - # Initialises a matrix with the given number of rows and columns and the - # given precision for use. The precision is at least the precision of the - # entries. - void mpf_mat_clear(mpf_mat_t mat) noexcept - # Clears the given matrix. - void mpf_mat_set(mpf_mat_t mat1, const mpf_mat_t mat2) noexcept - # Sets ``mat1`` to a copy of ``mat2``. The dimensions of - # ``mat1`` and ``mat2`` must be the same. - void mpf_mat_swap(mpf_mat_t mat1, mpf_mat_t mat2) noexcept - # Swaps two matrices. The dimensions of ``mat1`` and ``mat2`` - # are allowed to be different. - void mpf_mat_swap_entrywise(mpf_mat_t mat1, mpf_mat_t mat2) noexcept - # Swaps two matrices by swapping the individual entries rather than swapping - # the contents of the structs. - mpf * mpf_mat_entry(const mpf_mat_t mat, slong i, slong j) noexcept - # Returns a reference to the entry of ``mat`` at row `i` and column `j`. - # Both `i` and `j` must not exceed the dimensions of the matrix. - # The return value can be used to either retrieve or set the given entry. - void mpf_mat_zero(mpf_mat_t mat) noexcept - # Sets all entries of ``mat`` to 0. - void mpf_mat_one(mpf_mat_t mat) noexcept - # Sets ``mat`` to the unit matrix, having ones on the main diagonal - # and zeroes elsewhere. If ``mat`` is nonsquare, it is set to the - # truncation of a unit matrix. - void mpf_mat_set_fmpz_mat(mpf_mat_t B, const fmpz_mat_t A) noexcept - # Sets the entries of ``B`` as mpfs corresponding to the entries of - # ``A``. - void mpf_mat_randtest(mpf_mat_t mat, flint_rand_t state, flint_bitcnt_t bits) noexcept - # Sets the entries of ``mat`` to random numbers in the - # interval `[0, 1)` with ``bits`` significant bits in the mantissa or less if - # their precision is smaller. - void mpf_mat_print(const mpf_mat_t mat) noexcept - # Prints the given matrix to the stream ``stdout``. - bint mpf_mat_equal(const mpf_mat_t mat1, const mpf_mat_t mat2) noexcept - # Returns a non-zero value if ``mat1`` and ``mat2`` have - # the same dimensions and entries, and zero otherwise. - bint mpf_mat_approx_equal(const mpf_mat_t mat1, const mpf_mat_t mat2, flint_bitcnt_t bits) noexcept - # Returns a non-zero value if ``mat1`` and ``mat2`` have - # the same dimensions and the first ``bits`` bits of their entries - # are equal, and zero otherwise. - bint mpf_mat_is_zero(const mpf_mat_t mat) noexcept - # Returns a non-zero value if all entries ``mat`` are zero, and - # otherwise returns zero. - bint mpf_mat_is_empty(const mpf_mat_t mat) noexcept - # Returns a non-zero value if the number of rows or the number of - # columns in ``mat`` is zero, and otherwise returns - # zero. - bint mpf_mat_is_square(const mpf_mat_t mat) noexcept - # Returns a non-zero value if the number of rows is equal to the - # number of columns in ``mat``, and otherwise returns zero. - void mpf_mat_mul(mpf_mat_t C, const mpf_mat_t A, const mpf_mat_t B) noexcept - # Sets ``C`` to the matrix product `C = A B`. The matrices must have - # compatible dimensions for matrix multiplication (an exception is raised - # otherwise). Aliasing is allowed. - void mpf_mat_gso(mpf_mat_t B, const mpf_mat_t A) noexcept - # Takes a subset of `R^m` `S = {a_1, a_2, \ldots ,a_n}` (as the columns of - # a `m \times n` matrix ``A``) and generates an orthonormal set - # `S' = {b_1, b_2, \ldots ,b_n}` (as the columns of the `m \times n` matrix - # ``B``) that spans the same subspace of `R^m` as `S`. - # This uses an algorithm of Schwarz-Rutishauser. See pp. 9 of - # https://people.inf.ethz.ch/gander/papers/qrneu.pdf - void mpf_mat_qr(mpf_mat_t Q, mpf_mat_t R, const mpf_mat_t A) noexcept - # Computes the `QR` decomposition of a matrix ``A`` using the Gram-Schmidt - # process. (Sets ``Q`` and ``R`` such that `A = QR` where ``R`` is - # an upper triangular matrix and ``Q`` is an orthogonal matrix.) - # This uses an algorithm of Schwarz-Rutishauser. See pp. 9 of - # https://people.inf.ethz.ch/gander/papers/qrneu.pdf diff --git a/src/sage/libs/flint/mpf_vec.pxd b/src/sage/libs/flint/mpf_vec.pxd index 782de46c450..4fc582675f5 100644 --- a/src/sage/libs/flint/mpf_vec.pxd +++ b/src/sage/libs/flint/mpf_vec.pxd @@ -2,7 +2,9 @@ # distutils: depends = flint/mpf_vec.h ################################################################################ -# This file is auto-generated. Do not modify by hand +# This file is auto-generated by the script +# SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py. +# Do not modify by hand! Fix and rerun the script instead. ################################################################################ from libc.stdio cimport FILE @@ -11,70 +13,20 @@ from sage.libs.mpfr.types cimport * from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - mpf * _mpf_vec_init(slong len, mp_limb_t prec) noexcept - # Returns a vector of the given length of initialised ``mpf``'s - # with at least the given precision. - void _mpf_vec_clear(mpf * vec, slong len) noexcept - # Clears the given vector. - void _mpf_vec_randtest(mpf * f, flint_rand_t state, slong len, flint_bitcnt_t bits) noexcept - # Sets the entries of a vector of the given length to random numbers in the - # interval `[0, 1)` with ``bits`` significant bits in the mantissa or less if - # their precision is smaller. - void _mpf_vec_zero(mpf * vec, slong len) noexcept - # Zeros the vector ``(vec, len)``. - void _mpf_vec_set(mpf * vec1, const mpf * vec2, slong len2) noexcept - # Copies the vector ``vec2`` of the given length into ``vec1``. - # A check is made to ensure ``vec1`` and ``vec2`` are different. - void _mpf_vec_set_fmpz_vec(mpf * appv, const fmpz * vec, slong len) noexcept - # Export the array of ``len`` entries starting at the pointer ``vec`` - # to an array of mpfs ``appv``. - bint _mpf_vec_equal(const mpf * vec1, const mpf * vec2, slong len) noexcept - # Compares two vectors of the given length and returns `1` if they are - # equal, otherwise returns `0`. - bint _mpf_vec_is_zero(const mpf * vec, slong len) noexcept - # Returns `1` if ``(vec, len)`` is zero, and `0` otherwise. - bint _mpf_vec_approx_equal(const mpf * vec1, const mpf * vec2, slong len, flint_bitcnt_t bits) noexcept - # Compares two vectors of the given length and returns `1` if the first - # ``bits`` bits of their entries are equal, otherwise returns `0`. - void _mpf_vec_add(mpf * res, const mpf * vec1, const mpf * vec2, slong len2) noexcept - # Adds the given vectors of the given length together and stores the - # result in ``res``. - void _mpf_vec_sub(mpf * res, const mpf * vec1, const mpf * vec2, slong len2) noexcept - # Sets ``(res, len2)`` to ``(vec1, len2)`` minus ``(vec2, len2)``. - void _mpf_vec_scalar_mul_mpf(mpf * res, const mpf * vec, slong len, mpf_t c) noexcept - # Multiplies the vector with given length by the scalar `c` and - # sets ``res`` to the result. - void _mpf_vec_scalar_mul_2exp(mpf * res, const mpf * vec, slong len, flint_bitcnt_t exp) noexcept - # Multiplies the given vector of the given length by ``2^exp``. - void _mpf_vec_dot(mpf_t res, const mpf * vec1, const mpf * vec2, slong len2) noexcept - # Sets ``res`` to the dot product of ``(vec1, len2)`` with - # ``(vec2, len2)``. - void _mpf_vec_norm(mpf_t res, const mpf * vec, slong len) noexcept - # Sets ``res`` to the square of the Euclidean norm of - # ``(vec, len)``. - int _mpf_vec_dot2(mpf_t res, const mpf * vec1, const mpf * vec2, slong len2, flint_bitcnt_t prec) noexcept - # Sets ``res`` to the dot product of ``(vec1, len2)`` with - # ``(vec2, len2)``. The temporary variable used has its precision - # set to be at least ``prec`` bits. Returns 0 if a probable - # cancellation is detected, and otherwise returns a non-zero value. - void _mpf_vec_norm2(mpf_t res, const mpf * vec, slong len, flint_bitcnt_t prec) noexcept - # Sets ``res`` to the square of the Euclidean norm of - # ``(vec, len)``. The temporary variable used has its precision - # set to be at least ``prec`` bits. diff --git a/src/sage/libs/flint/mpfr_mat.pxd b/src/sage/libs/flint/mpfr_mat.pxd index 170a3be851e..ffb91d684d7 100644 --- a/src/sage/libs/flint/mpfr_mat.pxd +++ b/src/sage/libs/flint/mpfr_mat.pxd @@ -2,7 +2,9 @@ # distutils: depends = flint/mpfr_mat.h ################################################################################ -# This file is auto-generated. Do not modify by hand +# This file is auto-generated by the script +# SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py. +# Do not modify by hand! Fix and rerun the script instead. ################################################################################ from libc.stdio cimport FILE @@ -11,40 +13,13 @@ from sage.libs.mpfr.types cimport * from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void mpfr_mat_init(mpfr_mat_t mat, slong rows, slong cols, mpfr_prec_t prec) noexcept - # Initialises a matrix with the given number of rows and columns and the - # given precision for use. The precision is the exact precision of the - # entries. - void mpfr_mat_clear(mpfr_mat_t mat) noexcept - # Clears the given matrix. - __mpfr_struct * mpfr_mat_entry(const mpfr_mat_t mat, slong i, slong j) noexcept - # Return a reference to the entry at row `i` and column `j` of the given - # matrix. The values `i` and `j` must be within the bounds for the matrix. - # The reference can be used to either return or set the given entry. - void mpfr_mat_swap(mpfr_mat_t mat1, mpfr_mat_t mat2) noexcept - # Efficiently swap matrices ``mat1`` and ``mat2``. - void mpfr_mat_swap_entrywise(mpfr_mat_t mat1, mpfr_mat_t mat2) noexcept - # Swaps two matrices by swapping the individual entries rather than swapping - # the contents of the structs. - void mpfr_mat_set(mpfr_mat_t mat1, const mpfr_mat_t mat2) noexcept - # Set ``mat1`` to the value of ``mat2``. - void mpfr_mat_zero(mpfr_mat_t mat) noexcept - # Set ``mat`` to the zero matrix. - bint mpfr_mat_equal(const mpfr_mat_t mat1, const mpfr_mat_t mat2) noexcept - # Return `1` if the two given matrices are equal, otherwise return `0`. - void mpfr_mat_randtest(mpfr_mat_t mat, flint_rand_t state) noexcept - # Generate a random matrix with random number of rows and columns and random - # entries for use in test code. - void mpfr_mat_mul_classical(mpfr_mat_t C, const mpfr_mat_t A, const mpfr_mat_t B, mpfr_rnd_t rnd) noexcept - # Set `C` to the product of `A` and `B` with the given rounding mode, using - # the classical algorithm. diff --git a/src/sage/libs/flint/mpfr_vec.pxd b/src/sage/libs/flint/mpfr_vec.pxd index cc6e8f2499a..5c3fec6f735 100644 --- a/src/sage/libs/flint/mpfr_vec.pxd +++ b/src/sage/libs/flint/mpfr_vec.pxd @@ -2,7 +2,9 @@ # distutils: depends = flint/mpfr_vec.h ################################################################################ -# This file is auto-generated. Do not modify by hand +# This file is auto-generated by the script +# SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py. +# Do not modify by hand! Fix and rerun the script instead. ################################################################################ from libc.stdio cimport FILE @@ -11,30 +13,11 @@ from sage.libs.mpfr.types cimport * from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - mpfr_ptr _mpfr_vec_init(slong len, flint_bitcnt_t prec) noexcept - # Returns a vector of the given length of initialised ``mpfr``'s - # with the given exact precision. - void _mpfr_vec_clear(mpfr_ptr vec, slong len) noexcept - # Clears the given vector. - void _mpfr_vec_zero(mpfr_ptr vec, slong len) noexcept - # Zeros the vector ``(vec, len)``. - void _mpfr_vec_set(mpfr_ptr vec1, mpfr_srcptr vec2, slong len) noexcept - # Copies the vector ``vec2`` of the given length into ``vec1``. - # No check is made to ensure ``vec1`` and ``vec2`` are different. - void _mpfr_vec_add(mpfr_ptr res, mpfr_srcptr vec1, mpfr_srcptr vec2, slong len) noexcept - # Adds the given vectors of the given length together and stores the - # result in ``res``. - void _mpfr_vec_scalar_mul_mpfr(mpfr_ptr res, mpfr_srcptr vec, slong len, mpfr_t c) noexcept - # Multiplies the vector with given length by the scalar `c` and - # sets ``res`` to the result. - void _mpfr_vec_scalar_mul_2exp(mpfr_ptr res, mpfr_srcptr vec, slong len, flint_bitcnt_t exp) noexcept - # Multiplies the given vector of the given length by ``2^exp``. - void _mpfr_vec_scalar_product(mpfr_t res, mpfr_srcptr vec1, mpfr_srcptr vec2, slong len) noexcept diff --git a/src/sage/libs/flint/mpn_extras.pxd b/src/sage/libs/flint/mpn_extras.pxd index 3cf2facfb78..cd029b2d9ad 100644 --- a/src/sage/libs/flint/mpn_extras.pxd +++ b/src/sage/libs/flint/mpn_extras.pxd @@ -2,7 +2,9 @@ # distutils: depends = flint/mpn_extras.h ################################################################################ -# This file is auto-generated. Do not modify by hand +# This file is auto-generated by the script +# SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py. +# Do not modify by hand! Fix and rerun the script instead. ################################################################################ from libc.stdio cimport FILE @@ -11,172 +13,27 @@ from sage.libs.mpfr.types cimport * from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void flint_mpn_debug(mp_srcptr x, mp_size_t xsize) noexcept - # Prints debug information about ``(x, xsize)`` to ``stdout``. - # In particular, this will print binary representations of all the limbs. - int flint_mpn_zero_p(mp_srcptr x, mp_size_t xsize) noexcept - # Returns `1` if all limbs of ``(x, xsize)`` are zero, otherwise `0`. - mp_limb_t flint_mpn_mul(mp_ptr z, mp_srcptr x, mp_size_t xn, mp_srcptr y, mp_size_t yn) noexcept - # Sets ``(z, xn+yn)`` to the product of ``(x, xn)`` and ``(y, yn)`` - # and returns the top limb of the result. - # We require `xn \ge yn \ge 1` - # and that ``z`` is not aliased with either input operand. - # This function uses FFT multiplication if the operands are large enough - # and otherwise calls ``mpn_mul``. - void flint_mpn_mul_n(mp_ptr z, mp_srcptr x, mp_srcptr y, mp_size_t n) noexcept - # Sets ``z`` to the product of ``(x, n)`` and ``(y, n)``. - # We require `n \ge 1` - # and that ``z`` is not aliased with either input operand. - # This function uses FFT multiplication if the operands are large enough - # and otherwise calls ``mpn_mul_n``. - void flint_mpn_sqr(mp_ptr z, mp_srcptr x, mp_size_t n) noexcept - # Sets ``z`` to the square of ``(x, n)``. - # We require `n \ge 1` - # and that ``z`` is not aliased with either input operand. - # This function uses FFT multiplication if the operands are large enough - # and otherwise calls ``mpn_sqr``. - mp_size_t flint_mpn_fmms1(mp_ptr y, mp_limb_t a1, mp_srcptr x1, mp_limb_t a2, mp_srcptr x2, mp_size_t n) noexcept - # Given not-necessarily-normalized `x_1` and `x_2` of length `n > 0` and output `y` of length `n`, try to compute `y = a_1\cdot x_1 - a_2\cdot x_2`. - # Return the normalized length of `y` if `y \ge 0` and `y` fits into `n` limbs. Otherwise, return `-1`. - # `y` may alias `x_1` but is not allowed to alias `x_2`. - int flint_mpn_divisible_1_odd(mp_srcptr x, mp_size_t xsize, mp_limb_t d) noexcept - # Expression determining whether ``(x, xsize)`` is divisible by the - # ``mp_limb_t d`` which is assumed to be odd-valued and at least `3`. - # This function is implemented as a macro. - mp_size_t flint_mpn_divexact_1(mp_ptr x, mp_size_t xsize, mp_limb_t d) noexcept - # Divides `x` once by a known single-limb divisor, returns the new size. - - mp_size_t flint_mpn_remove_2exp(mp_ptr x, mp_size_t xsize, flint_bitcnt_t *bits) noexcept - # Divides ``(x, xsize)`` by `2^n` where `n` is the number of trailing - # zero bits in `x`. The new size of `x` is returned, and `n` is stored in - # the bits argument. `x` may not be zero. - - mp_size_t flint_mpn_remove_power_ascending(mp_ptr x, mp_size_t xsize, mp_ptr p, mp_size_t psize, ulong *exp) noexcept - # Divides ``(x, xsize)`` by the largest power `n` of ``(p, psize)`` - # that is an exact divisor of `x`. The new size of `x` is returned, and - # `n` is stored in the ``exp`` argument. `x` may not be zero, and `p` - # must be greater than `2`. - # This function works by testing divisibility by ascending squares - # `p, p^2, p^4, p^8, \dotsc`, making it efficient for removing potentially - # large powers. Because of its high overhead, it should not be used as - # the first stage of trial division. - + mp_size_t flint_mpn_remove_2exp(mp_ptr x, mp_size_t xsize, flint_bitcnt_t * bits) noexcept + mp_size_t flint_mpn_remove_power_ascending(mp_ptr x, mp_size_t xsize, mp_ptr p, mp_size_t psize, ulong * exp) noexcept int flint_mpn_factor_trial(mp_srcptr x, mp_size_t xsize, slong start, slong stop) noexcept - # Searches for a factor of ``(x, xsize)`` among the primes in positions - # ``start, ..., stop-1`` of ``flint_primes``. Returns `i` if - # ``flint_primes[i]`` is a factor, otherwise returns `0` if no factor - # is found. It is assumed that ``start >= 1``. - int flint_mpn_factor_trial_tree(slong * factors, mp_srcptr x, mp_size_t xsize, slong num_primes) noexcept - # Searches for a factor of ``(x, xsize)`` among the primes in positions - # approximately in the range ``0, ..., num_primes - 1`` of ``flint_primes``. - # Returns the number of prime factors found and fills ``factors`` with their - # indices in ``flint_primes``. It is assumed that ``num_primes`` is in the - # range ``0, ..., 3512``. - # If the input fits in a small ``fmpz`` the number is fully factored instead. - # The algorithm used is a tree based gcd with a product of primes, the tree - # for which is cached globally (it is threadsafe). - int flint_mpn_divides(mp_ptr q, mp_srcptr array1, mp_size_t limbs1, mp_srcptr arrayg, mp_size_t limbsg, mp_ptr temp) noexcept - # If ``(arrayg, limbsg)`` divides ``(array1, limbs1)`` then - # ``(q, limbs1 - limbsg + 1)`` is set to the quotient and 1 is - # returned, otherwise 0 is returned. The temporary space ``temp`` - # must have space for ``limbsg`` limbs. - # Assumes ``limbs1 >= limbsg > 0``. - mp_limb_t flint_mpn_preinv1(mp_limb_t d, mp_limb_t d2) noexcept - # Computes a precomputed inverse from the leading two limbs of the - # divisor ``b, n`` to be used with the ``preinv1`` functions. - # We require the most significant bit of ``b, n`` to be 1. - mp_limb_t flint_mpn_divrem_preinv1(mp_ptr q, mp_ptr a, mp_size_t m, mp_srcptr b, mp_size_t n, mp_limb_t dinv) noexcept - # Divide ``a, m`` by ``b, n``, returning the high limb of the - # quotient (which will either be 0 or 1), storing the remainder in-place - # in ``a, n`` and the rest of the quotient in ``q, m - n``. - # We require the most significant bit of ``b, n`` to be 1. - # ``dinv`` must be computed from ``b[n - 1]``, ``b[n - 2]`` by - # ``flint_mpn_preinv1``. We also require ``m >= n >= 2``. - void flint_mpn_mulmod_preinv1(mp_ptr r, mp_srcptr a, mp_srcptr b, mp_size_t n, mp_srcptr d, mp_limb_t dinv, ulong norm) noexcept - # Given a normalised integer `d` with precomputed inverse ``dinv`` - # provided by ``flint_mpn_preinv1``, computes `ab \pmod{d}` and - # stores the result in `r`. Each of `a`, `b` and `r` is expected to - # have `n` limbs of space, with zero padding if necessary. - # The value ``norm`` is provided for convenience. If `a`, `b` and - # `d` have been shifted left by ``norm`` bits so that `d` is - # normalised, then `r` will be shifted right by ``norm`` bits - # so that it has the same shift as all the inputs. - # We require `a` and `b` to be reduced modulo `n` before calling the - # function. - void flint_mpn_preinvn(mp_ptr dinv, mp_srcptr d, mp_size_t n) noexcept - # Compute an `n` limb precomputed inverse ``dinv`` of the `n` limb - # integer `d`. - # We require that `d` is normalised, i.e. with the most significant - # bit of the most significant limb set. - void flint_mpn_mod_preinvn(mp_ptr r, mp_srcptr a, mp_size_t m, mp_srcptr d, mp_size_t n, mp_srcptr dinv) noexcept - # Given a normalised integer `d` of `n` limbs, with precomputed inverse - # ``dinv`` provided by ``flint_mpn_preinvn`` and integer `a` of `m` - # limbs, computes `a \pmod{d}` and stores the result in-place in the lower - # `n` limbs of `a`. The remaining limbs of `a` are destroyed. - # We require `m \geq n`. No aliasing of `a` with any of the other operands - # is permitted. - # Note that this function is not always as fast as ordinary division. - mp_limb_t flint_mpn_divrem_preinvn(mp_ptr q, mp_ptr r, mp_srcptr a, mp_size_t m, mp_srcptr d, mp_size_t n, mp_srcptr dinv) noexcept - # Given a normalised integer `d` with precomputed inverse ``dinv`` - # provided by ``flint_mpn_preinvn``, computes the quotient of `a` by `d` - # and stores the result in `q` and the remainder in the lower `n` limbs of - # `a`. The remaining limbs of `a` are destroyed. - # The value `q` is expected to have space for `m - n` limbs and we require - # `m \ge n`. No aliasing is permitted between `q` and `a` or between these - # and any of the other operands. - # Note that this function is not always as fast as ordinary division. - void flint_mpn_mulmod_preinvn(mp_ptr r, mp_srcptr a, mp_srcptr b, mp_size_t n, mp_srcptr d, mp_srcptr dinv, ulong norm) noexcept - # Given a normalised integer `d` with precomputed inverse ``dinv`` - # provided by ``flint_mpn_preinvn``, computes `ab \pmod{d}` and - # stores the result in `r`. Each of `a`, `b` and `r` is expected to - # have `n` limbs of space, with zero padding if necessary. - # The value ``norm`` is provided for convenience. If `a`, `b` and - # `d` have been shifted left by ``norm`` bits so that `d` is - # normalised, then `r` will be shifted right by ``norm`` bits - # so that it has the same shift as all the inputs. - # We require `a` and `b` to be reduced modulo `n` before calling the - # function. - # Note that this function is not always as fast as ordinary division. - mp_size_t flint_mpn_gcd_full2(mp_ptr arrayg, mp_srcptr array1, mp_size_t limbs1, mp_srcptr array2, mp_size_t limbs2, mp_ptr temp) noexcept - # Sets ``(arrayg, retvalue)`` to the gcd of ``(array1, limbs1)`` and - # ``(array2, limbs2)``. - # The only assumption is that neither ``limbs1`` nor ``limbs2`` is - # zero. - # The function must be supplied with ``limbs1 + limbs2`` limbs of temporary - # space, or ``NULL`` must be passed to ``temp`` if the function should - # allocate its own space. - mp_size_t flint_mpn_gcd_full(mp_ptr arrayg, mp_srcptr array1, mp_size_t limbs1, mp_srcptr array2, mp_size_t limbs2) noexcept - # Sets ``(arrayg, retvalue)`` to the gcd of ``(array1, limbs1)`` and - # ``(array2, limbs2)``. - # The only assumption is that neither ``limbs1`` nor ``limbs2`` is - # zero. - - void flint_mpn_rrandom(mp_limb_t *rp, gmp_randstate_t state, mp_size_t n) noexcept - # Generates a random number with ``n`` limbs and stores - # it on ``rp``. The number it generates will tend to have - # long strings of zeros and ones in the binary representation. - # Useful for testing functions and algorithms, since this kind of random - # numbers have proven to be more likely to trigger corner-case bugs. - - void flint_mpn_urandomb(mp_limb_t *rp, gmp_randstate_t state, flint_bitcnt_t n) noexcept - # Generates a uniform random number of ``n`` bits and stores - # it on ``rp``. + void flint_mpn_rrandom(mp_limb_t * rp, gmp_randstate_t state, mp_size_t n) noexcept + void flint_mpn_urandomb(mp_limb_t * rp, gmp_randstate_t state, flint_bitcnt_t n) noexcept diff --git a/src/sage/libs/flint/mpoly.pxd b/src/sage/libs/flint/mpoly.pxd index 9204bbaa0c4..2b9f5393227 100644 --- a/src/sage/libs/flint/mpoly.pxd +++ b/src/sage/libs/flint/mpoly.pxd @@ -2,7 +2,9 @@ # distutils: depends = flint/mpoly.h ################################################################################ -# This file is auto-generated. Do not modify by hand +# This file is auto-generated by the script +# SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py. +# Do not modify by hand! Fix and rerun the script instead. ################################################################################ from libc.stdio cimport FILE @@ -11,271 +13,58 @@ from sage.libs.mpfr.types cimport * from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void mpoly_ctx_init(mpoly_ctx_t ctx, slong nvars, const ordering_t ord) noexcept - # Initialize a context for specified number of variables and ordering. - void mpoly_ctx_clear(mpoly_ctx_t mctx) noexcept - # Clean up any space used by a context object. - ordering_t mpoly_ordering_randtest(flint_rand_t state) noexcept - # Return a random ordering. The possibilities are ``ORD_LEX``, - # ``ORD_DEGLEX`` and ``ORD_DEGREVLEX``. - void mpoly_ctx_init_rand(mpoly_ctx_t mctx, flint_rand_t state, slong max_nvars) noexcept - # Initialize a context with a random choice for the ordering. - int mpoly_ordering_isdeg(const mpoly_ctx_t ctx) noexcept - # Return 1 if the ordering of the given context is a degree ordering (deglex or degrevlex). - int mpoly_ordering_isrev(const mpoly_ctx_t cth) noexcept - # Return 1 if the ordering of the given context is a reverse ordering (currently only - # degrevlex). - void mpoly_ordering_print(ordering_t ord) noexcept - # Print a string (either "lex", "deglex" or "degrevlex") to standard - # output, corresponding to the given ordering. - void mpoly_monomial_add(ulong * exp_ptr, const ulong * exp2, const ulong * exp3, slong N) noexcept - # Set ``(exp_ptr, N)`` to the sum of the monomials ``(exp2, N)`` and - # ``(exp3, N)``, assuming ``bits <= FLINT_BITS`` - void mpoly_monomial_add_mp(ulong * exp_ptr, const ulong * exp2, const ulong * exp3, slong N) noexcept - # Set ``(exp_ptr, N)`` to the sum of the monomials ``(exp2, N)`` and - # ``(exp3, N)``. - void mpoly_monomial_sub(ulong * exp_ptr, const ulong * exp2, const ulong * exp3, slong N) noexcept - # Set ``(exp_ptr, N)`` to the difference of the monomials ``(exp2, N)`` and ``(exp3, N)``, assuming ``bits <= FLINT_BITS`` - void mpoly_monomial_sub_mp(ulong * exp_ptr, const ulong * exp2, const ulong * exp3, slong N) noexcept - # Set ``(exp_ptr, N)`` to the difference of the monomials ``(exp2, N)`` and ``(exp3, N)``. - int mpoly_monomial_overflows(ulong * exp2, slong N, ulong mask) noexcept - # Return true if any of the fields of the given monomial ``(exp2, N)`` has - # overflowed (or is negative). The ``mask`` is a word with the high bit of - # each field set to 1. In other words, the function returns 1 if any word of - # ``exp2`` has any of the nonzero bits in ``mask`` set. Assumes that - # ``bits <= FLINT_BITS``. - int mpoly_monomial_overflows_mp(ulong * exp_ptr, slong N, flint_bitcnt_t bits) noexcept - # Return true if any of the fields of the given monomial ``(exp_ptr, N)`` - # has overflowed. Assumes that ``bits >= FLINT_BITS``. - int mpoly_monomial_overflows1(ulong exp, ulong mask) noexcept - # As per ``mpoly_monomial_overflows`` with ``N = 1``. - void mpoly_monomial_set(ulong * exp2, const ulong * exp3, slong N) noexcept - # Set the monomial ``(exp2, N)`` to ``(exp3, N)``. - void mpoly_monomial_swap(ulong * exp2, ulong * exp3, slong N) noexcept - # Swap the words in ``(exp2, N)`` and ``(exp3, N)``. - void mpoly_monomial_mul_ui(ulong * exp2, const ulong * exp3, slong N, ulong c) noexcept - # Set the words of ``(exp2, N)`` to the words of ``(exp3, N)`` - # multiplied by ``c``. - bint mpoly_monomial_is_zero(const ulong * exp, slong N) noexcept - # Return 1 if ``(exp, N)`` is zero. - bint mpoly_monomial_equal(const ulong * exp2, const ulong * exp3, slong N) noexcept - # Return 1 if the monomials ``(exp2, N)`` and ``(exp3, N)`` are equal. - void mpoly_get_cmpmask(ulong * cmpmask, slong N, ulong bits, const mpoly_ctx_t mctx) noexcept - # Get the mask ``(cmpmask, N)`` for comparisons. - # ``bits`` should be set to the number of bits in the exponents - # to be compared. Any function that compares monomials should use this - # comparison mask. - bint mpoly_monomial_lt(const ulong * exp2, const ulong * exp3, slong N, const ulong * cmpmask) noexcept - # Return 1 if ``(exp2, N)`` is less than ``(exp3, N)``. - bint mpoly_monomial_gt(const ulong * exp2, const ulong * exp3, slong N, const ulong * cmpmask) noexcept - # Return 1 if ``(exp2, N)`` is greater than ``(exp3, N)``. - int mpoly_monomial_cmp(const ulong * exp2, const ulong * exp3, slong N, const ulong * cmpmask) noexcept - # Return `1` if ``(exp2, N)`` is greater than, `0` if it is equal to and - # `-1` if it is less than ``(exp3, N)``. - int mpoly_monomial_divides(ulong * exp_ptr, const ulong * exp2, const ulong * exp3, slong N, ulong mask) noexcept - # Return 1 if the monomial ``(exp3, N)`` divides ``(exp2, N)``. If so - # set ``(exp_ptr, N)`` to the quotient monomial. The ``mask`` is a word - # with the high bit of each bit field set to 1. Assumes that - # ``bits <= FLINT_BITS``. - int mpoly_monomial_divides_mp(ulong * exp_ptr, const ulong * exp2, const ulong * exp3, slong N, flint_bitcnt_t bits) noexcept - # Return 1 if the monomial ``(exp3, N)`` divides ``(exp2, N)``. If so - # set ``(exp_ptr, N)`` to the quotient monomial. Assumes that - # ``bits >= FLINT_BITS``. - int mpoly_monomial_divides1(ulong * exp_ptr, const ulong exp2, const ulong exp3, ulong mask) noexcept - # As per ``mpoly_monomial_divides`` with ``N = 1``. - int mpoly_monomial_divides_tight(slong e1, slong e2, slong * prods, slong num) noexcept - # Return 1 if the monomial ``e2`` divides the monomial ``e1``, where - # the monomials are stored using factorial representation. The array - # ``(prods, num)`` should consist of `1`, `b_1, b_1\times b_2, \ldots`, - # where the `b_i` are the bases of the factorial number representation. - flint_bitcnt_t mpoly_exp_bits_required_ui(const ulong * user_exp, const mpoly_ctx_t mctx) noexcept - # Returns the number of bits required to store ``user_exp`` in packed - # format. The returned number of bits includes space for a zeroed signed bit. - flint_bitcnt_t mpoly_exp_bits_required_ffmpz(const fmpz * user_exp, const mpoly_ctx_t mctx) noexcept - # Returns the number of bits required to store ``user_exp`` in packed - # format. The returned number of bits includes space for a zeroed signed bit. - flint_bitcnt_t mpoly_exp_bits_required_pfmpz(fmpz * const * user_exp, const mpoly_ctx_t mctx) noexcept - # Returns the number of bits required to store ``user_exp`` in packed - # format. The returned number of bits includes space for a zeroed signed bit. - void mpoly_max_fields_ui_sp(ulong * max_fields, const ulong * poly_exps, slong len, ulong bits, const mpoly_ctx_t mctx) noexcept - # Compute the field-wise maximum of packed exponents from ``poly_exps`` - # of length ``len`` and unpack the result into ``max_fields``. - # The maximums are assumed to fit a ulong. - void mpoly_max_fields_fmpz(fmpz * max_fields, const ulong * poly_exps, slong len, ulong bits, const mpoly_ctx_t mctx) noexcept - # Compute the field-wise maximum of packed exponents from ``poly_exps`` - # of length ``len`` and unpack the result into ``max_fields``. - void mpoly_max_degrees_tight(slong * max_exp, ulong * exps, slong len, slong * prods, slong num) noexcept - # Return an array of ``num`` integers corresponding to the maximum degrees - # of the exponents in the array of exponent vectors ``(exps, len)``, - # assuming that the exponent are packed in a factorial representation. The - # array ``(prods, num)`` should consist of `1`, `b_1`, - # `b_1\times b_2, \ldots`, where the `b_i` are the bases of the factorial - # number representation. The results are stored in the array ``max_exp``, - # with the entry corresponding to the most significant base of the factorial - # representation first in the array. - int mpoly_monomial_exists(slong * index, const ulong * poly_exps, const ulong * exp, slong len, slong N, const ulong * cmpmask) noexcept - # Returns true if the given exponent vector ``exp`` exists in the array of - # exponent vectors ``(poly_exps, len)``, otherwise, returns false. If the - # exponent vector is found, its index into the array of exponent vectors is - # returned. Otherwise, ``index`` is set to the index where this exponent - # could be inserted to preserve the ordering. The index can be in the range - # ``[0, len]``. - - void mpoly_search_monomials(slong ** e_ind, ulong * e, slong * e_score, slong * t1, slong * t2, slong *t3, slong lower, slong upper, const ulong * a, slong a_len, const ulong * b, slong b_len, slong N, const ulong * cmpmask) noexcept - # Given packed exponent vectors ``a`` and ``b``, compute a packed - # exponent ``e`` such that the number of monomials in the cross product - # ``a`` X ``b`` that are less than or equal to ``e`` is between - # ``lower`` and ``upper``. This number is stored in ``e_store``. If - # no such monomial exists, one is chosen so that the number of monomials is as - # close as possible. This function assumes that ``1`` is the smallest - # monomial and needs three arrays ``t1``, ``t2``, and ``t3`` of the - # size as ``a`` for workspace. The parameter ``e_ind`` is set to one - # of ``t1``, ``t2``, and ``t3`` and gives the locations of the - # monomials in ``a`` X ``b``. - + void mpoly_search_monomials(slong ** e_ind, ulong * e, slong * e_score, slong * t1, slong * t2, slong * t3, slong lower, slong upper, const ulong * a, slong a_len, const ulong * b, slong b_len, slong N, const ulong * cmpmask) noexcept int mpoly_term_exp_fits_ui(ulong * exps, ulong bits, slong n, const mpoly_ctx_t mctx) noexcept - # Return whether every entry of the exponent vector of index `n` in - # ``exps`` fits into a ``ulong``. - int mpoly_term_exp_fits_si(ulong * exps, ulong bits, slong n, const mpoly_ctx_t mctx) noexcept - # Return whether every entry of the exponent vector of index `n` in - # ``exps`` fits into a ``slong``. - void mpoly_get_monomial_ui(ulong * exps, const ulong * poly_exps, ulong bits, const mpoly_ctx_t mctx) noexcept - # Convert the packed exponent ``poly_exps`` of bit count ``bits`` to a - # monomial from the user's perspective. The exponents are assumed to fit - # a ulong. - void mpoly_get_monomial_ffmpz(fmpz * exps, const ulong * poly_exps, flint_bitcnt_t bits, const mpoly_ctx_t mctx) noexcept - # Convert the packed exponent ``poly_exps`` of bit count ``bits`` to a - # monomial from the user's perspective. - void mpoly_get_monomial_pfmpz(fmpz ** exps, const ulong * poly_exps, flint_bitcnt_t bits, const mpoly_ctx_t mctx) noexcept - # Convert the packed exponent ``poly_exps`` of bit count ``bits`` to a - # monomial from the user's perspective. - void mpoly_set_monomial_ui(ulong * exp1, const ulong * exp2, ulong bits, const mpoly_ctx_t mctx) noexcept - # Convert the user monomial ``exp2`` to packed format using ``bits``. - void mpoly_set_monomial_ffmpz(ulong * exp1, const fmpz * exp2, flint_bitcnt_t bits, const mpoly_ctx_t mctx) noexcept - # Convert the user monomial ``exp2`` to packed format using ``bits``. - void mpoly_set_monomial_pfmpz(ulong * exp1, fmpz * const * exp2, flint_bitcnt_t bits, const mpoly_ctx_t mctx) noexcept - # Convert the user monomial ``exp2`` to packed format using ``bits``. - void mpoly_pack_vec_ui(ulong * exp1, const ulong * exp2, ulong bits, slong nfields, slong len) noexcept - # Packs a vector ``exp2`` into \{exp1} using a bit count of ``bits``. - # No checking is done to ensure that the vector actually fits - # into ``bits`` bits. The number of fields in each vector is - # ``nfields`` and the total number of vectors to unpack is ``len``. - void mpoly_pack_vec_fmpz(ulong * exp1, const fmpz * exp2, flint_bitcnt_t bits, slong nfields, slong len) noexcept - # Packs a vector ``exp2`` into \{exp1} using a bit count of ``bits``. - # No checking is done to ensure that the vector actually fits - # into ``bits`` bits. The number of fields in each vector is - # ``nfields`` and the total number of vectors to unpack is ``len``. - void mpoly_unpack_vec_ui(ulong * exp1, const ulong * exp2, ulong bits, slong nfields, slong len) noexcept - # Unpacks vector ``exp2`` of bit count ``bits`` into ``exp1``. - # The number of fields in each vector is - # ``nfields`` and the total number of vectors to unpack is ``len``. - void mpoly_unpack_vec_fmpz(fmpz * exp1, const ulong * exp2, flint_bitcnt_t bits, slong nfields, slong len) noexcept - # Unpacks vector ``exp2`` of bit count ``bits`` into ``exp1``. - # The number of fields in each vector is - # ``nfields`` and the total number of vectors to unpack is ``len``. - int mpoly_repack_monomials(ulong * exps1, ulong bits1, const ulong * exps2, ulong bits2, slong len, const mpoly_ctx_t mctx) noexcept - # Convert an array of length ``len`` of exponents ``exps2`` packed - # using bits ``bits2`` into an array ``exps1`` using bits ``bits1``. - # No checking is done to ensure that the result fits into bits ``bits1``. - void mpoly_pack_monomials_tight(ulong * exp1, const ulong * exp2, slong len, const slong * mults, slong num, slong bits) noexcept - # Given an array of possibly packed exponent vectors ``exp2`` of length - # ``len``, where each field of each exponent vector is packed into the - # given number of bits, return the corresponding array of monomial vectors - # packed using a factorial numbering scheme. The "bases" for the factorial - # numbering scheme are given as an array of integers ``mults``, the first - # entry of which corresponds to the field of least significance in each - # input exponent vector. Obviously the maximum exponent to be packed must be - # less than the corresponding base in ``mults``. - # The number of multipliers is given by ``num``. The code only considers - # least significant ``num`` fields of each exponent vectors and ignores - # the rest. The number of ignored fields should be passed in ``extras``. - void mpoly_unpack_monomials_tight(ulong * e1, ulong * e2, slong len, slong * mults, slong num, slong bits) noexcept - # Given an array of exponent vectors ``e2`` of length ``len`` packed - # using a factorial numbering scheme, unpack the monomials into an array - # ``e1`` of exponent vectors in standard packed format, where each field - # has the given number of bits. The "bases" for the factorial - # numbering scheme are given as an array of integers ``mults``, the first - # entry of which corresponds to the field of least significance in each - # exponent vector. - void mpoly_main_variable_terms1(slong * i1, slong * n1, const ulong * exp1, slong l1, slong len1, slong k, slong num, slong bits) noexcept - # Given an array of exponent vectors ``(exp1, len1)``, each exponent - # vector taking one word of space, with each exponent being packed into the - # given number of bits, compute ``l1`` starting offsets ``i1`` and - # lengths ``n1`` (which may be zero) to break the exponents into chunks. - # Each chunk consists of exponents have the same degree in the main variable. - # The index of the main variable is given by `k`. The variables are indexed - # from the variable of least significance, starting from `0`. The value - # ``l1`` should be the degree in the main variable, plus one. - int _mpoly_heap_insert(mpoly_heap_s * heap, ulong * exp, void * x, slong * next_loc, slong * heap_len, slong N, const ulong * cmpmask) noexcept - # Given a heap, insert a new node `x` corresponding to the given exponent - # into the heap. Heap elements are ordered by the exponent ``(exp, N)``, - # with the largest element at the head of the heap. A pointer to the current - # heap length must be passed in via ``heap_len``. This will be updated by - # the function. Note that the index 0 position in the heap is not used, so - # the length is always one greater than the number of elements. - void _mpoly_heap_insert1(mpoly_heap1_s * heap, ulong exp, void * x, slong * next_loc, slong * heap_len, ulong maskhi) noexcept - # As per ``_mpoly_heap_insert`` except that ``N = 1``, and - # ``maskhi = cmpmask[0]``. - void * _mpoly_heap_pop(mpoly_heap_s * heap, slong * heap_len, slong N, const ulong * cmpmask) noexcept - # Pop the head of the heap. It is cast to a ``void *``. A pointer to the - # current heap length must be passed in via ``heap_len``. This will be - # updated by the function. Note that the index 0 position in the heap is not - # used, so the length is always one greater than the number of elements. The - # ``maskhi`` and ``masklo`` values are zero except for degrevlex - # ordering, where they are as per the monomial comparison operations above. - void * _mpoly_heap_pop1(mpoly_heap1_s * heap, slong * heap_len, ulong maskhi) noexcept - # As per ``_mpoly_heap_pop1`` except that ``N = 1``, and - # ``maskhi = cmpmask[0]``. diff --git a/src/sage/libs/flint/nf.pxd b/src/sage/libs/flint/nf.pxd index c9200ea1056..73fb2aeb7c2 100644 --- a/src/sage/libs/flint/nf.pxd +++ b/src/sage/libs/flint/nf.pxd @@ -2,7 +2,9 @@ # distutils: depends = flint/nf.h ################################################################################ -# This file is auto-generated. Do not modify by hand +# This file is auto-generated by the script +# SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py. +# Do not modify by hand! Fix and rerun the script instead. ################################################################################ from libc.stdio cimport FILE @@ -11,11 +13,5 @@ from sage.libs.mpfr.types cimport * from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void nf_init(nf_t nf, const fmpq_poly_t pol) noexcept - # Perform basic initialisation of a number field (for element arithmetic) - # given a defining polynomial over `\mathbb{Q}`. - void nf_clear(nf_t nf) noexcept - # Release resources used by a number field object. The object will need - # initialisation again before it can be used. diff --git a/src/sage/libs/flint/nf_elem.pxd b/src/sage/libs/flint/nf_elem.pxd index a78a48946c7..7ec811389d9 100644 --- a/src/sage/libs/flint/nf_elem.pxd +++ b/src/sage/libs/flint/nf_elem.pxd @@ -2,7 +2,9 @@ # distutils: depends = flint/nf_elem.h ################################################################################ -# This file is auto-generated. Do not modify by hand +# This file is auto-generated by the script +# SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py. +# Do not modify by hand! Fix and rerun the script instead. ################################################################################ from libc.stdio cimport FILE @@ -11,264 +13,60 @@ from sage.libs.mpfr.types cimport * from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void nf_elem_init(nf_elem_t a, const nf_t nf) noexcept - # Initialise a number field element to belong to the given number field - # ``nf``. The element is set to zero. - void nf_elem_clear(nf_elem_t a, const nf_t nf) noexcept - # Clear resources allocated by the given number field element in the given - # number field. - void nf_elem_randtest(nf_elem_t a, flint_rand_t state, mp_bitcnt_t bits, const nf_t nf) noexcept - # Generate a random number field element `a` in the number field ``nf`` - # whose coefficients have up to the given number of bits. - void nf_elem_canonicalise(nf_elem_t a, const nf_t nf) noexcept - # Canonicalise a number field element, i.e. reduce numerator and denominator - # to lowest terms. If the numerator is `0`, set the denominator to `1`. - void _nf_elem_reduce(nf_elem_t a, const nf_t nf) noexcept - # Reduce a number field element modulo the defining polynomial. This is used - # with functions such as ``nf_elem_mul_red`` which allow reduction to be - # delayed. Does not canonicalise. - void nf_elem_reduce(nf_elem_t a, const nf_t nf) noexcept - # Reduce a number field element modulo the defining polynomial. This is used - # with functions such as ``nf_elem_mul_red`` which allow reduction to be - # delayed. - int _nf_elem_invertible_check(nf_elem_t a, const nf_t nf) noexcept - # Whilst the defining polynomial for a number field should by definition be - # irreducible, it is not enforced. Thus in test code, it is convenient to be - # able to check that a given number field element is invertible modulo the - # defining polynomial of the number field. This function does precisely this. - # If `a` is invertible modulo the defining polynomial of ``nf`` the value - # `1` is returned, otherwise `0` is returned. - # The function is only intended to be used in test code. - void nf_elem_set_fmpz_mat_row(nf_elem_t b, const fmpz_mat_t M, const slong i, fmpz_t den, const nf_t nf) noexcept - # Set `b` to the element specified by row `i` of the matrix `M` and with the - # given denominator `d`. Column `0` of the matrix corresponds to the constant - # coefficient of the number field element. - void nf_elem_get_fmpz_mat_row(fmpz_mat_t M, const slong i, fmpz_t den, const nf_elem_t b, const nf_t nf) noexcept - # Set the row `i` of the matrix `M` to the coefficients of the numerator of - # the element `b` and `d` to the denominator of `b`. Column `0` of the matrix - # corresponds to the constant coefficient of the number field element. - void nf_elem_set_fmpq_poly(nf_elem_t a, const fmpq_poly_t pol, const nf_t nf) noexcept - # Set `a` to the element corresponding to the polynomial ``pol``. - void nf_elem_get_fmpq_poly(fmpq_poly_t pol, const nf_elem_t a, const nf_t nf) noexcept - # Set ``pol`` to a polynomial corresponding to `a`, reduced modulo the - # defining polynomial of ``nf``. - void nf_elem_get_nmod_poly_den(nmod_poly_t pol, const nf_elem_t a, const nf_t nf, int den) noexcept - # Set ``pol`` to the reduction of the polynomial corresponding to the - # numerator of `a`. If ``den == 1``, the result is multiplied by the - # inverse of the denominator of `a`. In this case it is assumed that the - # reduction of the denominator of `a` is invertible. - void nf_elem_get_nmod_poly(nmod_poly_t pol, const nf_elem_t a, const nf_t nf) noexcept - # Set ``pol`` to the reduction of the polynomial corresponding to the - # numerator of `a`. The result is multiplied by the inverse of the - # denominator of `a`. It is assumed that the reduction of the denominator of - # `a` is invertible. - void nf_elem_get_fmpz_mod_poly_den(fmpz_mod_poly_t pol, const nf_elem_t a, const nf_t nf, int den, const fmpz_mod_ctx_t ctx) noexcept - # Set ``pol`` to the reduction of the polynomial corresponding to the - # numerator of `a`. If ``den == 1``, the result is multiplied by the - # inverse of the denominator of `a`. In this case it is assumed that the - # reduction of the denominator of `a` is invertible. - void nf_elem_get_fmpz_mod_poly(fmpz_mod_poly_t pol, const nf_elem_t a, const nf_t nf, const fmpz_mod_ctx_t ctx) noexcept - # Set ``pol`` to the reduction of the polynomial corresponding to the - # numerator of `a`. The result is multiplied by the inverse of the - # denominator of `a`. It is assumed that the reduction of the denominator of - # `a` is invertible. - void nf_elem_set_den(nf_elem_t b, fmpz_t d, const nf_t nf) noexcept - # Set the denominator of the ``nf_elem_t b`` to the given integer `d`. - # Assumes `d > 0`. - void nf_elem_get_den(fmpz_t d, const nf_elem_t b, const nf_t nf) noexcept - # Set `d` to the denominator of the ``nf_elem_t b``. - void _nf_elem_set_coeff_num_fmpz(nf_elem_t a, slong i, const fmpz_t d, const nf_t nf) noexcept - # Set the `i`-th coefficient of the denominator of `a` to the given integer - # `d`. - bint _nf_elem_equal(const nf_elem_t a, const nf_elem_t b, const nf_t nf) noexcept - # Return `1` if the given number field elements are equal in the given - # number field ``nf``. This function does \emph{not} assume `a` and `b` - # are canonicalised. - bint nf_elem_equal(const nf_elem_t a, const nf_elem_t b, const nf_t nf) noexcept - # Return `1` if the given number field elements are equal in the given - # number field ``nf``. This function assumes `a` and `b` \emph{are} - # canonicalised. - bint nf_elem_is_zero(const nf_elem_t a, const nf_t nf) noexcept - # Return `1` if the given number field element is equal to zero, - # otherwise return `0`. - bint nf_elem_is_one(const nf_elem_t a, const nf_t nf) noexcept - # Return `1` if the given number field element is equal to one, - # otherwise return `0`. - void nf_elem_print_pretty(const nf_elem_t a, const nf_t nf, const char * var) noexcept - # Print the given number field element to ``stdout`` using the - # null-terminated string ``var`` not equal to ``"\0"`` as the - # name of the primitive element. - void nf_elem_zero(nf_elem_t a, const nf_t nf) noexcept - void nf_elem_one(nf_elem_t a, const nf_t nf) noexcept - void nf_elem_set(nf_elem_t a, const nf_elem_t b, const nf_t nf) noexcept - # Set the number field element `a` to equal the number field element `b`, - # i.e. set `a = b`. - void nf_elem_neg(nf_elem_t a, const nf_elem_t b, const nf_t nf) noexcept - # Set the number field element `a` to minus the number field element `b`, - # i.e. set `a = -b`. - void nf_elem_swap(nf_elem_t a, nf_elem_t b, const nf_t nf) noexcept - # Efficiently swap the two number field elements `a` and `b`. - void nf_elem_mul_gen(nf_elem_t a, const nf_elem_t b, const nf_t nf) noexcept - # Multiply the element `b` with the generator of the number field. - void _nf_elem_add(nf_elem_t r, const nf_elem_t a, const nf_elem_t b, const nf_t nf) noexcept - # Add two elements of a number field ``nf``, i.e. set `r = a + b`. - # Canonicalisation is not performed. - void nf_elem_add(nf_elem_t r, const nf_elem_t a, const nf_elem_t b, const nf_t nf) noexcept - # Add two elements of a number field ``nf``, i.e. set `r = a + b`. - void _nf_elem_sub(nf_elem_t r, const nf_elem_t a, const nf_elem_t b, const nf_t nf) noexcept - # Subtract two elements of a number field ``nf``, i.e. set `r = a - b`. - # Canonicalisation is not performed. - void nf_elem_sub(nf_elem_t r, const nf_elem_t a, const nf_elem_t b, const nf_t nf) noexcept - # Subtract two elements of a number field ``nf``, i.e. set `r = a - b`. - void _nf_elem_mul(nf_elem_t a, const nf_elem_t b, const nf_elem_t c, const nf_t nf) noexcept - # Multiply two elements of a number field ``nf``, i.e. set `r = a * b`. - # Does not canonicalise. Aliasing of inputs with output is not supported. - void _nf_elem_mul_red(nf_elem_t a, const nf_elem_t b, const nf_elem_t c, const nf_t nf, int red) noexcept - # As per ``_nf_elem_mul``, but reduction modulo the defining polynomial - # of the number field is only carried out if ``red == 1``. Assumes both - # inputs are reduced. - void nf_elem_mul(nf_elem_t a, const nf_elem_t b, const nf_elem_t c, const nf_t nf) noexcept - # Multiply two elements of a number field ``nf``, i.e. set `r = a * b`. - void nf_elem_mul_red(nf_elem_t a, const nf_elem_t b, const nf_elem_t c, const nf_t nf, int red) noexcept - # As per ``nf_elem_mul``, but reduction modulo the defining polynomial - # of the number field is only carried out if ``red == 1``. Assumes both - # inputs are reduced. - void _nf_elem_inv(nf_elem_t r, const nf_elem_t a, const nf_t nf) noexcept - # Invert an element of a number field ``nf``, i.e. set `r = a^{-1}`. - # Aliasing of the input with the output is not supported. - void nf_elem_inv(nf_elem_t r, const nf_elem_t a, const nf_t nf) noexcept - # Invert an element of a number field ``nf``, i.e. set `r = a^{-1}`. - void _nf_elem_div(nf_elem_t a, const nf_elem_t b, const nf_elem_t c, const nf_t nf) noexcept - # Set `a` to `b/c` in the given number field. Aliasing of `a` and `b` is not - # permitted. - void nf_elem_div(nf_elem_t a, const nf_elem_t b, const nf_elem_t c, const nf_t nf) noexcept - # Set `a` to `b/c` in the given number field. - void _nf_elem_pow(nf_elem_t res, const nf_elem_t a, ulong e, const nf_t nf) noexcept - # Set ``res`` to `a^e` using left-to-right binary exponentiation as - # described on p. 461 of [Knu1997]_. - # Assumes that `a \neq 0` and `e > 1`. Does not support aliasing. - void nf_elem_pow(nf_elem_t res, const nf_elem_t a, ulong e, const nf_t nf) noexcept - # Set ``res`` = ``a^e`` using the binary exponentiation algorithm. - # If `e` is zero, returns one, so that in particular ``0^0 = 1``. - void _nf_elem_norm(fmpz_t rnum, fmpz_t rden, const nf_elem_t a, const nf_t nf) noexcept - # Set ``rnum, rden`` to the absolute norm of the given number field - # element `a`. - void nf_elem_norm(fmpq_t res, const nf_elem_t a, const nf_t nf) noexcept - # Set ``res`` to the absolute norm of the given number field - # element `a`. - void nf_elem_norm_div(fmpq_t res, const nf_elem_t a, const nf_t nf, const fmpz_t div, slong nbits) noexcept - # Set ``res`` to the absolute norm of the given number field element `a`, - # divided by ``div`` . Assumes the result to be an integer and having - # at most ``nbits`` bits. - void _nf_elem_norm_div(fmpz_t rnum, fmpz_t rden, const nf_elem_t a, const nf_t nf, const fmpz_t divisor, slong nbits) noexcept - # Set ``rnum, rden`` to the absolute norm of the given number field element `a`, - # divided by ``div`` . Assumes the result to be an integer and having - # at most ``nbits`` bits. - void _nf_elem_trace(fmpz_t rnum, fmpz_t rden, const nf_elem_t a, const nf_t nf) noexcept - # Set ``rnum, rden`` to the absolute trace of the given number field - # element `a`. - void nf_elem_trace(fmpq_t res, const nf_elem_t a, const nf_t nf) noexcept - # Set ``res`` to the absolute trace of the given number field - # element `a`. - void nf_elem_rep_mat(fmpq_mat_t res, const nf_elem_t a, const nf_t nf) noexcept - # Set ``res`` to the matrix representing the multiplication with `a` with - # respect to the basis `1, a, \dotsc, a^{d - 1}`, where `a` is the generator - # of the number field of `d` is its degree. - void nf_elem_rep_mat_fmpz_mat_den(fmpz_mat_t res, fmpz_t den, const nf_elem_t a, const nf_t nf) noexcept - # Return a tuple `M, d` such that `M/d` is the matrix representing the - # multiplication with `a` with respect to the basis `1, a, \dotsc, a^{d - 1}`, - # where `a` is the generator of the number field of `d` is its degree. - # The integral matrix `M` is primitive. - void nf_elem_mod_fmpz_den(nf_elem_t z, const nf_elem_t a, const fmpz_t mod, const nf_t nf, int den) noexcept - # If ``den == 0``, return an element `z` with denominator `1`, such that - # the coefficients of `z - da` are divisble by ``mod``, where `d` is the - # denominator of `a`. The coefficients of `z` are reduced modulo ``mod``. - # If ``den == 1``, return an element `z`, such that `z - a` has - # denominator `1` and the coefficients of `z - a` are divisible by ``mod``. - # The coefficients of `z` are reduced modulo `\mathtt{mod} \cdot d`, where `d` is the - # denominator of `a`. - # Reduction takes place with respect to the positive residue system. - void nf_elem_smod_fmpz_den(nf_elem_t z, const nf_elem_t a, const fmpz_t mod, const nf_t nf, int den) noexcept - # If ``den == 0``, return an element `z` with denominator `1`, such that - # the coefficients of `z - da` are divisble by ``mod``, where `d` is the - # denominator of `a`. The coefficients of `z` are reduced modulo ``mod``. - # If ``den == 1``, return an element `z`, such that `z - a` has - # denominator `1` and the coefficients of `z - a` are divisible by ``mod``. - # The coefficients of `z` are reduced modulo `\mathtt{mod} \cdot d`, where `d` is the - # denominator of `a`. - # Reduction takes place with respect to the symmetric residue system. - void nf_elem_mod_fmpz(nf_elem_t res, const nf_elem_t a, const fmpz_t mod, const nf_t nf) noexcept - # Return an element `z` such that `z - a` has denominator `1` and the - # coefficients of `z - a` are divisible by ``mod``. The coefficients of - # `z` are reduced modulo `\mathtt{mod} \cdot d`, where `d` is the denominator of `b`. - # Reduction takes place with respect to the positive residue system. - void nf_elem_smod_fmpz(nf_elem_t res, const nf_elem_t a, const fmpz_t mod, const nf_t nf) noexcept - # Return an element `z` such that `z - a` has denominator `1` and the - # coefficients of `z - a` are divisible by ``mod``. The coefficients of - # `z` are reduced modulo `\mathtt{mod} \cdot d`, where `d` is the denominator of `b`. - # Reduction takes place with respect to the symmetric residue system. - void nf_elem_coprime_den(nf_elem_t res, const nf_elem_t a, const fmpz_t mod, const nf_t nf) noexcept - # Return an element `z` such that the denominator of `z - a` is coprime to - # ``mod``. - # Reduction takes place with respect to the positive residue system. - void nf_elem_coprime_den_signed(nf_elem_t res, const nf_elem_t a, const fmpz_t mod, const nf_t nf) noexcept - # Return an element `z` such that the denominator of `z - a` is coprime to - # ``mod``. - # Reduction takes place with respect to the symmetric residue system. diff --git a/src/sage/libs/flint/nmod.pxd b/src/sage/libs/flint/nmod.pxd index 8fdfe4a5096..1330498f255 100644 --- a/src/sage/libs/flint/nmod.pxd +++ b/src/sage/libs/flint/nmod.pxd @@ -2,7 +2,9 @@ # distutils: depends = flint/nmod.h ################################################################################ -# This file is auto-generated. Do not modify by hand +# This file is auto-generated by the script +# SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py. +# Do not modify by hand! Fix and rerun the script instead. ################################################################################ from libc.stdio cimport FILE @@ -11,76 +13,21 @@ from sage.libs.mpfr.types cimport * from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void nmod_init(nmod_t * mod, mp_limb_t n) noexcept - # Initialises the given ``nmod_t`` structure for reduction modulo `n` - # with a precomputed inverse. - mp_limb_t _nmod_add(mp_limb_t a, mp_limb_t b, nmod_t mod) noexcept - # Returns `a + b` modulo ``mod.n``. It is assumed that ``mod`` is - # no more than ``FLINT_BITS - 1`` bits. It is assumed that `a` and `b` - # are already reduced modulo ``mod.n``. - mp_limb_t nmod_add(mp_limb_t a, mp_limb_t b, nmod_t mod) noexcept - # Returns `a + b` modulo ``mod.n``. No assumptions are made about - # ``mod.n``. It is assumed that `a` and `b` are already reduced - # modulo ``mod.n``. - mp_limb_t _nmod_sub(mp_limb_t a, mp_limb_t b, nmod_t mod) noexcept - # Returns `a - b` modulo ``mod.n``. It is assumed that ``mod`` - # is no more than ``FLINT_BITS - 1`` bits. It is assumed that - # `a` and `b` are already reduced modulo ``mod.n``. - mp_limb_t nmod_sub(mp_limb_t a, mp_limb_t b, nmod_t mod) noexcept - # Returns `a - b` modulo ``mod.n``. No assumptions are made about - # ``mod.n``. It is assumed that `a` and `b` are already reduced - # modulo ``mod.n``. - mp_limb_t nmod_neg(mp_limb_t a, nmod_t mod) noexcept - # Returns `-a` modulo ``mod.n``. It is assumed that `a` is already - # reduced modulo ``mod.n``, but no assumptions are made about the - # latter. - mp_limb_t nmod_mul(mp_limb_t a, mp_limb_t b, nmod_t mod) noexcept - # Returns `ab` modulo ``mod.n``. No assumptions are made about - # ``mod.n``. It is assumed that `a` and `b` are already reduced - # modulo ``mod.n``. - mp_limb_t _nmod_mul_fullword(mp_limb_t a, mp_limb_t b, nmod_t mod) noexcept - # Returns `ab` modulo ``mod.n``. Requires that ``mod.n`` is exactly - # ``FLINT_BITS`` large. It is assumed that `a` and `b` are already - # reduced modulo ``mod.n``. - mp_limb_t nmod_inv(mp_limb_t a, nmod_t mod) noexcept - # Returns `a^{-1}` modulo ``mod.n``. The inverse is assumed to exist. - mp_limb_t nmod_div(mp_limb_t a, mp_limb_t b, nmod_t mod) noexcept - # Returns `ab^{-1}` modulo ``mod.n``. The inverse of `b` is assumed to - # exist. It is assumed that `a` is already reduced modulo ``mod.n``. - + int nmod_divides(mp_limb_t * a, mp_limb_t b, mp_limb_t c, nmod_t mod) noexcept mp_limb_t nmod_pow_ui(mp_limb_t a, ulong e, nmod_t mod) noexcept - # Returns `a^e` modulo ``mod.n``. No assumptions are made about - # ``mod.n``. It is assumed that `a` is already reduced - # modulo ``mod.n``. - mp_limb_t nmod_pow_fmpz(mp_limb_t a, const fmpz_t e, nmod_t mod) noexcept - # Returns `a^e` modulo ``mod.n``. No assumptions are made about - # ``mod.n``. It is assumed that `a` is already reduced - # modulo ``mod.n`` and that `e` is not negative. - void nmod_discrete_log_pohlig_hellman_init(nmod_discrete_log_pohlig_hellman_t L) noexcept - # Initialize ``L``. Upon initialization ``L`` is not ready for computation. - void nmod_discrete_log_pohlig_hellman_clear(nmod_discrete_log_pohlig_hellman_t L) noexcept - # Free any space used by ``L``. - double nmod_discrete_log_pohlig_hellman_precompute_prime(nmod_discrete_log_pohlig_hellman_t L, mp_limb_t p) noexcept - # Configure ``L`` for discrete logarithms modulo ``p`` to an internally chosen base. It is assumed that ``p`` is prime. - # The return is an estimate on the number of multiplications needed for one run. - mp_limb_t nmod_discrete_log_pohlig_hellman_primitive_root(const nmod_discrete_log_pohlig_hellman_t L) noexcept - # Return the internally stored base. - ulong nmod_discrete_log_pohlig_hellman_run(const nmod_discrete_log_pohlig_hellman_t L, mp_limb_t y) noexcept - # Return the logarithm of ``y`` with respect to the internally stored base. ``y`` is expected to be reduced modulo the ``p``. - # The function is undefined if the logarithm does not exist. diff --git a/src/sage/libs/flint/nmod_mat.pxd b/src/sage/libs/flint/nmod_mat.pxd index 85981e1ed05..bf33d0837b6 100644 --- a/src/sage/libs/flint/nmod_mat.pxd +++ b/src/sage/libs/flint/nmod_mat.pxd @@ -2,7 +2,9 @@ # distutils: depends = flint/nmod_mat.h ################################################################################ -# This file is auto-generated. Do not modify by hand +# This file is auto-generated by the script +# SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py. +# Do not modify by hand! Fix and rerun the script instead. ################################################################################ from libc.stdio cimport FILE @@ -11,441 +13,90 @@ from sage.libs.mpfr.types cimport * from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void nmod_mat_init(nmod_mat_t mat, slong rows, slong cols, mp_limb_t n) noexcept - # Initialises ``mat`` to a ``rows``-by-``cols`` matrix with - # coefficients modulo `n`, where `n` can be any nonzero integer that - # fits in a limb. All elements are set to zero. - void nmod_mat_init_set(nmod_mat_t mat, const nmod_mat_t src) noexcept - # Initialises ``mat`` and sets its dimensions, modulus and elements - # to those of ``src``. - void nmod_mat_clear(nmod_mat_t mat) noexcept - # Clears the matrix and releases any memory it used. The matrix - # cannot be used again until it is initialised. This function must be - # called exactly once when finished using an ``nmod_mat_t`` object. - void nmod_mat_set(nmod_mat_t mat, const nmod_mat_t src) noexcept - # Sets ``mat`` to a copy of ``src``. It is assumed - # that ``mat`` and ``src`` have identical dimensions. - void nmod_mat_swap(nmod_mat_t mat1, nmod_mat_t mat2) noexcept - # Exchanges ``mat1`` and ``mat2``. - void nmod_mat_swap_entrywise(nmod_mat_t mat1, nmod_mat_t mat2) noexcept - # Swaps two matrices by swapping the individual entries rather than swapping - # the contents of the structs. - mp_limb_t nmod_mat_get_entry(const nmod_mat_t mat, slong i, slong j) noexcept - # Get the entry at row `i` and column `j` of the matrix ``mat``. - mp_limb_t * nmod_mat_entry_ptr(const nmod_mat_t mat, slong i, slong j) noexcept - # Return a pointer to the entry at row `i` and column `j` of the matrix - # ``mat``. - void nmod_mat_set_entry(nmod_mat_t mat, slong i, slong j, mp_limb_t x) noexcept - # Set the entry at row `i` and column `j` of the matrix ``mat`` to - # ``x``. - slong nmod_mat_nrows(const nmod_mat_t mat) noexcept - # Returns the number of rows in ``mat``. - slong nmod_mat_ncols(const nmod_mat_t mat) noexcept - # Returns the number of columns in ``mat``. - void nmod_mat_zero(nmod_mat_t mat) noexcept - # Sets all entries of the matrix ``mat`` to zero. - bint nmod_mat_is_zero(const nmod_mat_t mat) noexcept - # Returns `1` if all entries of the matrix ``mat`` are zero. - void nmod_mat_window_init(nmod_mat_t window, const nmod_mat_t mat, slong r1, slong c1, slong r2, slong c2) noexcept - # Initializes the matrix ``window`` to be an ``r2 - r1`` by - # ``c2 - c1`` submatrix of ``mat`` whose ``(0,0)`` entry - # is the ``(r1, c1)`` entry of ``mat``. The memory for the - # elements of ``window`` is shared with ``mat``. - void nmod_mat_window_clear(nmod_mat_t window) noexcept - # Clears the matrix ``window`` and releases any memory that it - # uses. Note that the memory to the underlying matrix that - # ``window`` points to is not freed. - void nmod_mat_concat_vertical(nmod_mat_t res, const nmod_mat_t mat1, const nmod_mat_t mat2) noexcept - # Sets ``res`` to vertical concatenation of (`mat1`, ``mat2``) in that order. Matrix dimensions : ``mat1`` : `m \times n`, ``mat2`` : `k \times n`, ``res`` : `(m + k) \times n`. - void nmod_mat_concat_horizontal(nmod_mat_t res, const nmod_mat_t mat1, const nmod_mat_t mat2) noexcept - # Sets ``res`` to horizontal concatenation of (``mat1``, ``mat2``) in that order. Matrix dimensions : ``mat1`` : `m \times n`, ``mat2`` : `m \times k`, ``res`` : `m \times (n + k)`. - void nmod_mat_print_pretty(const nmod_mat_t mat) noexcept - # Pretty-prints ``mat`` to ``stdout``. A header is printed followed - # by the rows enclosed in brackets. Each column is right-aligned to the - # width of the modulus written in decimal, and the columns are separated by - # spaces. - # For example:: - # <2 x 3 integer matrix mod 2903> - # [ 0 0 2607] - # [ 622 0 0] - int nmod_mat_fprint_pretty(FILE * file, const nmod_mat_t mat) noexcept - # Same as ``nmod_mat_print_pretty`` but printing to ``file``. - int nmod_mat_print(const nmod_mat_t mat) noexcept - # Currently, same as ``nmod_mat_print_pretty``. - int nmod_mat_fprint(FILE * f, const nmod_mat_t mat) noexcept - # Currently, same as ``nmod_mat_fprint_pretty``. - void nmod_mat_randtest(nmod_mat_t mat, flint_rand_t state) noexcept - # Sets the elements to a random matrix with entries between `0` and `m-1` - # inclusive, where `m` is the modulus of ``mat``. A sparse matrix is - # generated with increased probability. - void nmod_mat_randfull(nmod_mat_t mat, flint_rand_t state) noexcept - # Sets the element to random numbers likely to be close to the modulus - # of the matrix. This is used to test potential overflow-related bugs. - int nmod_mat_randpermdiag(nmod_mat_t mat, flint_rand_t state, mp_srcptr diag, slong n) noexcept - # Sets ``mat`` to a random permutation of the diagonal matrix - # with `n` leading entries given by the vector ``diag``. It is - # assumed that the main diagonal of ``mat`` has room for at - # least `n` entries. - # Returns `0` or `1`, depending on whether the permutation is even - # or odd respectively. - void nmod_mat_randrank(nmod_mat_t mat, flint_rand_t state, slong rank) noexcept - # Sets ``mat`` to a random sparse matrix with the given rank, - # having exactly as many non-zero elements as the rank, with the - # non-zero elements being uniformly random integers between `0` - # and `m-1` inclusive, where `m` is the modulus of ``mat``. - # The matrix can be transformed into a dense matrix with unchanged - # rank by subsequently calling :func:`nmod_mat_randops`. - void nmod_mat_randops(nmod_mat_t mat, slong count, flint_rand_t state) noexcept - # Randomises ``mat`` by performing elementary row or column - # operations. More precisely, at most ``count`` random additions - # or subtractions of distinct rows and columns will be performed. - # This leaves the rank (and for square matrices, determinant) - # unchanged. - void nmod_mat_randtril(nmod_mat_t mat, flint_rand_t state, int unit) noexcept - # Sets ``mat`` to a random lower triangular matrix. If ``unit`` is 1, - # it will have ones on the main diagonal, otherwise it will have random - # nonzero entries on the main diagonal. - void nmod_mat_randtriu(nmod_mat_t mat, flint_rand_t state, int unit) noexcept - # Sets ``mat`` to a random upper triangular matrix. If ``unit`` is 1, - # it will have ones on the main diagonal, otherwise it will have random - # nonzero entries on the main diagonal. - bint nmod_mat_equal(const nmod_mat_t mat1, const nmod_mat_t mat2) noexcept - # Returns nonzero if ``mat1`` and ``mat2`` have the same dimensions and elements, - # and zero otherwise. The moduli are ignored. - bint nmod_mat_is_zero_row(const nmod_mat_t mat, slong i) noexcept - # Returns a non-zero value if row `i` of ``mat`` is zero. - void nmod_mat_transpose(nmod_mat_t B, const nmod_mat_t A) noexcept - # Sets `B` to the transpose of `A`. Dimensions must be compatible. - # `B` and `A` may be the same object if and only if the matrix is square. - void nmod_mat_swap_rows(nmod_mat_t mat, slong * perm, slong r, slong s) noexcept - # Swaps rows ``r`` and ``s`` of ``mat``. If ``perm`` is non-``NULL``, the - # permutation of the rows will also be applied to ``perm``. - void nmod_mat_swap_cols(nmod_mat_t mat, slong * perm, slong r, slong s) noexcept - # Swaps columns ``r`` and ``s`` of ``mat``. If ``perm`` is non-``NULL``, the - # permutation of the columns will also be applied to ``perm``. - void nmod_mat_invert_rows(nmod_mat_t mat, slong * perm) noexcept - # Swaps rows ``i`` and ``r - i`` of ``mat`` for ``0 <= i < r/2``, where - # ``r`` is the number of rows of ``mat``. If ``perm`` is non-``NULL``, the - # permutation of the rows will also be applied to ``perm``. - void nmod_mat_invert_cols(nmod_mat_t mat, slong * perm) noexcept - # Swaps columns ``i`` and ``c - i`` of ``mat`` for ``0 <= i < c/2``, where - # ``c`` is the number of columns of ``mat``. If ``perm`` is non-``NULL``, the - # permutation of the columns will also be applied to ``perm``. - void nmod_mat_permute_rows(nmod_mat_t mat, const slong * perm_act, slong * perm_store) noexcept - # Permutes rows of the matrix ``mat`` according to permutation ``perm_act`` - # and, if ``perm_store`` is not ``NULL``, apply the same permutation to it. - void nmod_mat_add(nmod_mat_t C, const nmod_mat_t A, const nmod_mat_t B) noexcept - # Computes `C = A + B`. Dimensions must be identical. - void nmod_mat_sub(nmod_mat_t C, const nmod_mat_t A, const nmod_mat_t B) noexcept - # Computes `C = A - B`. Dimensions must be identical. - void nmod_mat_neg(nmod_mat_t A, const nmod_mat_t B) noexcept - # Sets `B = -A`. Dimensions must be identical. - void nmod_mat_scalar_mul(nmod_mat_t B, const nmod_mat_t A, mp_limb_t c) noexcept - # Sets `B = cA`, where the scalar `c` is assumed to be reduced - # modulo the modulus. Dimensions of `A` and `B` must be identical. - void nmod_mat_scalar_addmul_ui(nmod_mat_t dest, const nmod_mat_t X, const nmod_mat_t Y, const mp_limb_t b) noexcept - # Sets `dest = X + bY`, where the scalar `b` is assumed to be reduced - # modulo the modulus. Dimensions of dest, X and Y must be identical. - # dest can be aliased with X or Y. - void nmod_mat_scalar_mul_fmpz(nmod_mat_t res, const nmod_mat_t M, const fmpz_t c) noexcept - # Sets `B = cA`, where the scalar `c` is of type ``fmpz_t``. Dimensions of `A` - # and `B` must be identical. - void nmod_mat_mul(nmod_mat_t C, const nmod_mat_t A, const nmod_mat_t B) noexcept - # Sets `C = AB`. Dimensions must be compatible for matrix multiplication. - # Aliasing is allowed. This function automatically chooses between classical - # and Strassen multiplication. - void _nmod_mat_mul_classical_op(nmod_mat_t D, const nmod_mat_t C, const nmod_mat_t A, const nmod_mat_t B, int op) noexcept - void nmod_mat_mul_classical(nmod_mat_t C, const nmod_mat_t A, const nmod_mat_t B) noexcept - # Sets `C = AB`. Dimensions must be compatible for matrix multiplication. - # `C` is not allowed to be aliased with `A` or `B`. Uses classical - # matrix multiplication, creating a temporary transposed copy of `B` - # to improve memory locality if the matrices are large enough, - # and packing several entries of `B` into each word if the modulus - # is very small. - void _nmod_mat_mul_classical_threaded_pool_op(nmod_mat_t D, const nmod_mat_t C, const nmod_mat_t A, const nmod_mat_t B, int op, thread_pool_handle * threads, slong num_threads) noexcept - # Multithreaded version of ``_nmod_mat_mul_classical``. - void _nmod_mat_mul_classical_threaded_op(nmod_mat_t D, const nmod_mat_t C, const nmod_mat_t A, const nmod_mat_t B, int op) noexcept - # Multithreaded version of ``_nmod_mat_mul_classical``. - void nmod_mat_mul_classical_threaded(nmod_mat_t C, const nmod_mat_t A, const nmod_mat_t B) noexcept - # Multithreaded version of ``nmod_mat_mul_classical``. - void nmod_mat_mul_strassen(nmod_mat_t C, const nmod_mat_t A, const nmod_mat_t B) noexcept - # Sets `C = AB`. Dimensions must be compatible for matrix multiplication. - # `C` is not allowed to be aliased with `A` or `B`. Uses Strassen - # multiplication (the Strassen-Winograd variant). - int nmod_mat_mul_blas(nmod_mat_t C, const nmod_mat_t A, const nmod_mat_t B) noexcept - # Tries to set `C = AB` using BLAS and returns `1` for success and `0` for failure. Dimensions must be compatible for matrix multiplication. - void nmod_mat_addmul(nmod_mat_t D, const nmod_mat_t C, const nmod_mat_t A, const nmod_mat_t B) noexcept - # Sets `D = C + AB`. `C` and `D` may be aliased with each other but - # not with `A` or `B`. Automatically selects between classical - # and Strassen multiplication. - void nmod_mat_submul(nmod_mat_t D, const nmod_mat_t C, const nmod_mat_t A, const nmod_mat_t B) noexcept - # Sets `D = C + AB`. `C` and `D` may be aliased with each other but - # not with `A` or `B`. - void nmod_mat_mul_nmod_vec(mp_limb_t * c, const nmod_mat_t A, const mp_limb_t * b, slong blen) noexcept void nmod_mat_mul_nmod_vec_ptr(mp_limb_t * const * c, const nmod_mat_t A, const mp_limb_t * const * b, slong blen) noexcept - # Compute a matrix-vector product of ``A`` and ``(b, blen)`` and store the result in ``c``. - # The vector ``(b, blen)`` is either truncated or zero-extended to the number of columns of ``A``. - # The number entries written to ``c`` is always equal to the number of rows of ``A``. - void nmod_mat_nmod_vec_mul(mp_limb_t * c, const mp_limb_t * a, slong alen, const nmod_mat_t B) noexcept void nmod_mat_nmod_vec_mul_ptr(mp_limb_t * const * c, const mp_limb_t * const * a, slong alen, const nmod_mat_t B) noexcept - # Compute a vector-matrix product of ``(a, alen)`` and ``B`` and and store the result in ``c``. - # The vector ``(a, alen)`` is either truncated or zero-extended to the number of rows of ``B``. - # The number entries written to ``c`` is always equal to the number of columns of ``B``. - void _nmod_mat_pow(nmod_mat_t dest, const nmod_mat_t mat, ulong pow) noexcept - void nmod_mat_pow(nmod_mat_t dest, const nmod_mat_t mat, ulong pow) noexcept - # Sets `dest = mat^{pow}`. ``dest`` and ``mat`` may be aliased. Implements - mp_limb_t nmod_mat_trace(const nmod_mat_t mat) noexcept - # Computes the trace of the matrix, i.e. the sum of the entries on - # the main diagonal. The matrix is required to be square. - mp_limb_t nmod_mat_det_howell(const nmod_mat_t A) noexcept - # Returns the determinant of `A`. - mp_limb_t nmod_mat_det(const nmod_mat_t A) noexcept - # Returns the determinant of `A`. - slong nmod_mat_rank(const nmod_mat_t A) noexcept - # Returns the rank of `A`. The modulus of `A` must be a prime number. - int nmod_mat_inv(nmod_mat_t B, const nmod_mat_t A) noexcept - # Sets `B = A^{-1}` and returns `1` if `A` is invertible. - # If `A` is singular, returns `0` and sets the elements of - # `B` to undefined values. - # `A` and `B` must be square matrices with the same dimensions - # and modulus. The modulus must be prime. - void nmod_mat_solve_tril(nmod_mat_t X, const nmod_mat_t L, const nmod_mat_t B, int unit) noexcept - # Sets `X = L^{-1} B` where `L` is a full rank lower triangular square - # matrix. If ``unit`` = 1, `L` is assumed to have ones on its - # main diagonal, and the main diagonal will not be read. - # `X` and `B` are allowed to be the same matrix, but no other - # aliasing is allowed. Automatically chooses between the classical and - # recursive algorithms. - void nmod_mat_solve_tril_classical(nmod_mat_t X, const nmod_mat_t L, const nmod_mat_t B, int unit) noexcept - # Sets `X = L^{-1} B` where `L` is a full rank lower triangular square - # matrix. If ``unit`` = 1, `L` is assumed to have ones on its - # main diagonal, and the main diagonal will not be read. - # `X` and `B` are allowed to be the same matrix, but no other - # aliasing is allowed. Uses forward substitution. - void nmod_mat_solve_tril_recursive(nmod_mat_t X, const nmod_mat_t L, const nmod_mat_t B, int unit) noexcept - # Sets `X = L^{-1} B` where `L` is a full rank lower triangular square - # matrix. If ``unit`` = 1, `L` is assumed to have ones on its - # main diagonal, and the main diagonal will not be read. - # `X` and `B` are allowed to be the same matrix, but no other - # aliasing is allowed. - # Uses the block inversion formula - # .. math :: - # \begin{pmatrix} A & 0 \\ C & D \end{pmatrix}^{-1} - # \begin{pmatrix} X \\ Y \end{pmatrix} = - # \begin{pmatrix} A^{-1} X \\ D^{-1} ( Y - C A^{-1} X ) \end{pmatrix} - # to reduce the problem to matrix multiplication and triangular solving - # of smaller systems. - void nmod_mat_solve_triu(nmod_mat_t X, const nmod_mat_t U, const nmod_mat_t B, int unit) noexcept - # Sets `X = U^{-1} B` where `U` is a full rank upper triangular square - # matrix. If ``unit`` = 1, `U` is assumed to have ones on its - # main diagonal, and the main diagonal will not be read. - # `X` and `B` are allowed to be the same matrix, but no other - # aliasing is allowed. Automatically chooses between the classical and - # recursive algorithms. - void nmod_mat_solve_triu_classical(nmod_mat_t X, const nmod_mat_t U, const nmod_mat_t B, int unit) noexcept - # Sets `X = U^{-1} B` where `U` is a full rank upper triangular square - # matrix. If ``unit`` = 1, `U` is assumed to have ones on its - # main diagonal, and the main diagonal will not be read. - # `X` and `B` are allowed to be the same matrix, but no other - # aliasing is allowed. Uses forward substitution. - void nmod_mat_solve_triu_recursive(nmod_mat_t X, const nmod_mat_t U, const nmod_mat_t B, int unit) noexcept - # Sets `X = U^{-1} B` where `U` is a full rank upper triangular square - # matrix. If ``unit`` = 1, `U` is assumed to have ones on its - # main diagonal, and the main diagonal will not be read. - # `X` and `B` are allowed to be the same matrix, but no other - # aliasing is allowed. - # Uses the block inversion formula - # .. math :: - # \begin{pmatrix} A & B \\ 0 & D \end{pmatrix}^{-1} - # \begin{pmatrix} X \\ Y \end{pmatrix} = - # \begin{pmatrix} A^{-1} (X - B D^{-1} Y) \\ D^{-1} Y \end{pmatrix} - # to reduce the problem to matrix multiplication and triangular solving - # of smaller systems. - int nmod_mat_solve(nmod_mat_t X, const nmod_mat_t A, const nmod_mat_t B) noexcept - # Solves the matrix-matrix equation `AX = B` over `\mathbb{Z} / p \mathbb{Z}` where `p` - # is the modulus of `X` which must be a prime number. `X`, `A`, and `B` - # should have the same moduli. - # Returns `1` if `A` has full rank; otherwise returns `0` and sets the - # elements of `X` to undefined values. - # The matrix `A` must be square. - int nmod_mat_can_solve_inner(slong * rank, slong * perm, slong * pivots, nmod_mat_t X, const nmod_mat_t A, const nmod_mat_t B) noexcept - # As for :func:`nmod_mat_can_solve` except that if `rank` is not `NULL` the - # value it points to will be set to the rank of `A`. If `perm` is not `NULL` - # then it must be a valid initialised permutation whose length is the number - # of rows of `A`. After the function call it will be set to the row - # permutation given by LU decomposition of `A`. If `pivots` is not `NULL` - # then it must an initialised vector. Only the first `*rank` of these will be - # set by the function call. They are set to the columns of the pivots chosen - # by the LU decomposition of `A`. - int nmod_mat_can_solve(nmod_mat_t X, const nmod_mat_t A, const nmod_mat_t B) noexcept - # Solves the matrix-matrix equation `AX = B` over `\mathbb{Z} / p \mathbb{Z}` where `p` - # is the modulus of `X` which must be a prime number. `X`, `A`, and `B` - # should have the same moduli. - # Returns `1` if a solution exists; otherwise returns `0` and sets the - # elements of `X` to zero. If more than one solution exists, one of the - # valid solutions is given. - # There are no restrictions on the shape of `A` and it may be singular. - int nmod_mat_solve_vec(mp_ptr x, const nmod_mat_t A, mp_srcptr b) noexcept - # Solves the matrix-vector equation `Ax = b` over `\mathbb{Z} / p \mathbb{Z}` where `p` - # is the modulus of `A` which must be a prime number. - # Returns `1` if `A` has full rank; otherwise returns `0` and sets the - # elements of `x` to undefined values. - slong nmod_mat_lu(slong * P, nmod_mat_t A, int rank_check) noexcept slong nmod_mat_lu_classical(slong * P, nmod_mat_t A, int rank_check) noexcept slong nmod_mat_lu_classical_delayed(slong * P, nmod_mat_t A, int rank_check) noexcept slong nmod_mat_lu_recursive(slong * P, nmod_mat_t A, int rank_check) noexcept - # Computes a generalised LU decomposition `LU = PA` of a given - # matrix `A`, returning the rank of `A`. - # If `A` is a nonsingular square matrix, it will be overwritten with - # a unit diagonal lower triangular matrix `L` and an upper triangular - # matrix `U` (the diagonal of `L` will not be stored explicitly). - # If `A` is an arbitrary matrix of rank `r`, `U` will be in row echelon - # form having `r` nonzero rows, and `L` will be lower triangular - # but truncated to `r` columns, having implicit ones on the `r` first - # entries of the main diagonal. All other entries will be zero. - # If a nonzero value for ``rank_check`` is passed, the - # function will abandon the output matrix in an undefined state and - # return 0 if `A` is detected to be rank-deficient. - # The *classical* version uses direct Gaussian elimination. - # The *classical_delayed* version also uses Gaussian elimination, - # but performs delayed modular reductions. - # The *recursive* version uses block recursive decomposition. - # The default function chooses an algorithm automatically. - slong nmod_mat_rref(nmod_mat_t A) noexcept - # Puts `A` in reduced row echelon form and returns the rank of `A`. - # The rref is computed by first obtaining an unreduced row echelon - # form via LU decomposition and then solving an additional - # triangular system. - slong nmod_mat_reduce_row(nmod_mat_t A, slong * P, slong * L, slong n) noexcept - # Reduce row n of the matrix `A`, assuming the prior rows are in Gauss - # form. However those rows may not be in order. The entry `i` of the array - # `P` is the row of `A` which has a pivot in the `i`-th column. If no such - # row exists, the entry of `P` will be `-1`. The function returns the column - # in which the `n`-th row has a pivot after reduction. This will always be - # chosen to be the first available column for a pivot from the left. This - # information is also updated in `P`. Entry `i` of the array `L` contains the - # number of possibly nonzero columns of `A` row `i`. This speeds up reduction - # in the case that `A` is chambered on the right. Otherwise the entries of `L` - # can all be set to the number of columns of `A`. We require the entries of - # `L` to be monotonic increasing. - slong nmod_mat_nullspace(nmod_mat_t X, const nmod_mat_t A) noexcept - # Computes the nullspace of `A` and returns the nullity. - # More precisely, this function sets `X` to a maximum rank matrix - # such that `AX = 0` and returns the rank of `X`. The columns of - # `X` will form a basis for the nullspace of `A`. - # `X` must have sufficient space to store all basis vectors - # in the nullspace. - # This function computes the reduced row echelon form and then reads - # off the basis vectors. - void nmod_mat_similarity(nmod_mat_t M, slong r, ulong d) noexcept - # Applies a similarity transform to the `n\times n` matrix `M` in-place. - # If `P` is the `n\times n` identity matrix the zero entries of whose row - # `r` (`0`-indexed) have been replaced by `d`, this transform is equivalent - # to `M = P^{-1}MP`. - # Similarity transforms preserve the determinant, characteristic polynomial - # and minimal polynomial. - # The value `d` is required to be reduced modulo the modulus of the entries - # in the matrix. - void nmod_mat_charpoly_berkowitz(nmod_poly_t p, const nmod_mat_t M) noexcept void nmod_mat_charpoly_danilevsky(nmod_poly_t p, const nmod_mat_t M) noexcept void nmod_mat_charpoly(nmod_poly_t p, const nmod_mat_t M) noexcept - # Compute the characteristic polynomial `p` of the matrix `M`. The matrix - # is required to be square, otherwise an exception is raised. - # The *danilevsky* algorithm assumes that the modulus is prime. - void nmod_mat_minpoly(nmod_poly_t p, const nmod_mat_t M) noexcept - # Compute the minimal polynomial `p` of the matrix `M`. The matrix - # is required to be square, otherwise an exception is raised. - void nmod_mat_strong_echelon_form(nmod_mat_t A) noexcept - # Puts `A` into strong echelon form. The Howell form and the strong echelon - # form are equal up to permutation of the rows, see [FieHof2014]_ for a - # definition of the strong echelon form and the algorithm used here. - # Note that [FieHof2014]_ defines strong echelon form as a lower left normal form, - # while the implemented version returns an upper right normal form, - # agreeing with the definition of Howell form in [StoMul1998]_. - # `A` must have at least as many rows as columns. - slong nmod_mat_howell_form(nmod_mat_t A) noexcept - # Puts `A` into Howell form and returns the number of non-zero rows. - # For a definition of the Howell form see [StoMul1998]_. The Howell form - # is computed by first putting `A` into strong echelon form and then ordering - # the rows. - # `A` must have at least as many rows as columns. diff --git a/src/sage/libs/flint/nmod_mpoly.pxd b/src/sage/libs/flint/nmod_mpoly.pxd index 3083e39d480..0730f6db650 100644 --- a/src/sage/libs/flint/nmod_mpoly.pxd +++ b/src/sage/libs/flint/nmod_mpoly.pxd @@ -2,7 +2,9 @@ # distutils: depends = flint/nmod_mpoly.h ################################################################################ -# This file is auto-generated. Do not modify by hand +# This file is auto-generated by the script +# SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py. +# Do not modify by hand! Fix and rerun the script instead. ################################################################################ from libc.stdio cimport FILE @@ -11,414 +13,130 @@ from sage.libs.mpfr.types cimport * from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void nmod_mpoly_ctx_init(nmod_mpoly_ctx_t ctx, slong nvars, const ordering_t ord, mp_limb_t n) noexcept - # Initialise a context object for a polynomial ring with the given number of variables and the given ordering. - # It will have coefficients modulo *n*. Setting `n = 0` will give undefined behavior. - # The possibilities for the ordering are ``ORD_LEX``, ``ORD_DEGLEX`` and ``ORD_DEGREVLEX``. - slong nmod_mpoly_ctx_nvars(const nmod_mpoly_ctx_t ctx) noexcept - # Return the number of variables used to initialize the context. - ordering_t nmod_mpoly_ctx_ord(const nmod_mpoly_ctx_t ctx) noexcept - # Return the ordering used to initialize the context. - mp_limb_t nmod_mpoly_ctx_modulus(const nmod_mpoly_ctx_t ctx) noexcept - # Return the modulus used to initialize the context. - void nmod_mpoly_ctx_clear(nmod_mpoly_ctx_t ctx) noexcept - # Release any space allocated by *ctx*. - void nmod_mpoly_init(nmod_mpoly_t A, const nmod_mpoly_ctx_t ctx) noexcept - # Initialise *A* for use with the given an initialised context object. Its value is set to zero. - void nmod_mpoly_init2(nmod_mpoly_t A, slong alloc, const nmod_mpoly_ctx_t ctx) noexcept - # Initialise *A* for use with the given an initialised context object. Its value is set to zero. - # It is allocated with space for *alloc* terms and at least ``MPOLY_MIN_BITS`` bits for the exponent widths. - void nmod_mpoly_init3(nmod_mpoly_t A, slong alloc, flint_bitcnt_t bits, const nmod_mpoly_ctx_t ctx) noexcept - # Initialise *A* for use with the given an initialised context object. Its value is set to zero. - # It is allocated with space for *alloc* terms and *bits* bits for the exponents. - void nmod_mpoly_fit_length(nmod_mpoly_t A, slong len, const nmod_mpoly_ctx_t ctx) noexcept - # Ensure that *A* has space for at least *len* terms. - void nmod_mpoly_realloc(nmod_mpoly_t A, slong alloc, const nmod_mpoly_ctx_t ctx) noexcept - # Reallocate *A* to have space for *alloc* terms. - # Assumes the current length of the polynomial is not greater than *alloc*. - void nmod_mpoly_clear(nmod_mpoly_t A, const nmod_mpoly_ctx_t ctx) noexcept - # Release any space allocated for *A*. - char * nmod_mpoly_get_str_pretty(const nmod_mpoly_t A, const char ** x, const nmod_mpoly_ctx_t ctx) noexcept - # Return a string, which the user is responsible for cleaning up, representing *A*, given an array of variable strings *x*. - int nmod_mpoly_fprint_pretty(FILE * file, const nmod_mpoly_t A, const char ** x, const nmod_mpoly_ctx_t ctx) noexcept - # Print a string representing *A* to *file*. - int nmod_mpoly_print_pretty(const nmod_mpoly_t A, const char ** x, const nmod_mpoly_ctx_t ctx) noexcept - # Print a string representing *A* to ``stdout``. - int nmod_mpoly_set_str_pretty(nmod_mpoly_t A, const char * str, const char ** x, const nmod_mpoly_ctx_t ctx) noexcept - # Set *A* to the polynomial in the null-terminates string *str* given an array *x* of variable strings. - # If parsing *str* fails, *A* is set to zero, and `-1` is returned. Otherwise, `0` is returned. - # The operations ``+``, ``-``, ``*``, and ``/`` are permitted along with integers and the variables in *x*. The character ``^`` must be immediately followed by the (integer) exponent. - # If any division is not exact, parsing fails. - void nmod_mpoly_gen(nmod_mpoly_t A, slong var, const nmod_mpoly_ctx_t ctx) noexcept - # Set *A* to the variable of index *var*, where `var = 0` corresponds to the variable with the most significance with respect to the ordering. - bint nmod_mpoly_is_gen(const nmod_mpoly_t A, slong var, const nmod_mpoly_ctx_t ctx) noexcept - # If `var \ge 0`, return `1` if *A* is equal to the `var`-th generator, otherwise return `0`. - # If `var < 0`, return `1` if the polynomial is equal to any generator, otherwise return `0`. - void nmod_mpoly_set(nmod_mpoly_t A, const nmod_mpoly_t B, const nmod_mpoly_ctx_t ctx) noexcept - # Set *A* to *B*. - bint nmod_mpoly_equal(const nmod_mpoly_t A, const nmod_mpoly_t B, const nmod_mpoly_ctx_t ctx) noexcept - # Return `1` if *A* is equal to *B*, else return `0`. - void nmod_mpoly_swap(nmod_mpoly_t A, nmod_mpoly_t B, const nmod_mpoly_ctx_t ctx) noexcept - # Efficiently swap *A* and *B*. - bint nmod_mpoly_is_ui(const nmod_mpoly_t A, const nmod_mpoly_ctx_t ctx) noexcept - # Return `1` if *A* is a constant, else return `0`. - ulong nmod_mpoly_get_ui(const nmod_mpoly_t A, const nmod_mpoly_ctx_t ctx) noexcept - # Assuming that *A* is a constant, return this constant. - # This function throws if *A* is not a constant. - void nmod_mpoly_set_ui(nmod_mpoly_t A, ulong c, const nmod_mpoly_ctx_t ctx) noexcept - # Set *A* to the constant *c*. - void nmod_mpoly_zero(nmod_mpoly_t A, const nmod_mpoly_ctx_t ctx) noexcept - # Set *A* to the constant `0`. - void nmod_mpoly_one(nmod_mpoly_t A, const nmod_mpoly_ctx_t ctx) noexcept - # Set *A* to the constant `1`. - bint nmod_mpoly_equal_ui(const nmod_mpoly_t A, ulong c, const nmod_mpoly_ctx_t ctx) noexcept - # Return `1` if *A* is equal to the constant *c*, else return `0`. - bint nmod_mpoly_is_zero(const nmod_mpoly_t A, const nmod_mpoly_ctx_t ctx) noexcept - # Return `1` if *A* is the constant `0`, else return `0`. - bint nmod_mpoly_is_one(const nmod_mpoly_t A, const nmod_mpoly_ctx_t ctx) noexcept - # Return `1` if *A* is the constant `1`, else return `0`. - int nmod_mpoly_degrees_fit_si(const nmod_mpoly_t A, const nmod_mpoly_ctx_t ctx) noexcept - # Return `1` if the degrees of *A* with respect to each variable fit into an ``slong``, otherwise return `0`. - void nmod_mpoly_degrees_fmpz(fmpz ** degs, const nmod_mpoly_t A, const nmod_mpoly_ctx_t ctx) noexcept void nmod_mpoly_degrees_si(slong * degs, const nmod_mpoly_t A, const nmod_mpoly_ctx_t ctx) noexcept - # Set *degs* to the degrees of *A* with respect to each variable. - # If *A* is zero, all degrees are set to `-1`. - void nmod_mpoly_degree_fmpz(fmpz_t deg, const nmod_mpoly_t A, slong var, const nmod_mpoly_ctx_t ctx) noexcept slong nmod_mpoly_degree_si(const nmod_mpoly_t A, slong var, const nmod_mpoly_ctx_t ctx) noexcept - # Either return or set *deg* to the degree of *A* with respect to the variable of index *var*. - # If *A* is zero, the degree is defined to be `-1`. - int nmod_mpoly_total_degree_fits_si(const nmod_mpoly_t A, const nmod_mpoly_ctx_t ctx) noexcept - # Return `1` if the total degree of *A* fits into an ``slong``, otherwise return `0`. - void nmod_mpoly_total_degree_fmpz(fmpz_t tdeg, const nmod_mpoly_t A, const nmod_mpoly_ctx_t ctx) noexcept slong nmod_mpoly_total_degree_si(const nmod_mpoly_t A, const nmod_mpoly_ctx_t ctx) noexcept - # Either return or set *tdeg* to the total degree of *A*. - # If *A* is zero, the total degree is defined to be `-1`. - void nmod_mpoly_used_vars(int * used, const nmod_mpoly_t A, const nmod_mpoly_ctx_t ctx) noexcept - # For each variable index *i*, set ``used[i]`` to nonzero if the variable of index *i* appears in *A* and to zero otherwise. - ulong nmod_mpoly_get_coeff_ui_monomial(const nmod_mpoly_t A, const nmod_mpoly_t M, const nmod_mpoly_ctx_t ctx) noexcept - # Assuming that *M* is a monomial, return the coefficient of the corresponding monomial in *A*. - # This function throws if *M* is not a monomial. - void nmod_mpoly_set_coeff_ui_monomial(nmod_mpoly_t A, ulong c, const nmod_mpoly_t M, const nmod_mpoly_ctx_t ctx) noexcept - # Assuming that *M* is a monomial, set the coefficient of the corresponding monomial in *A* to *c*. - # This function throws if *M* is not a monomial. - ulong nmod_mpoly_get_coeff_ui_fmpz(const nmod_mpoly_t A, fmpz * const * exp, const nmod_mpoly_ctx_t ctx) noexcept ulong nmod_mpoly_get_coeff_ui_ui(const nmod_mpoly_t A, const ulong * exp, const nmod_mpoly_ctx_t ctx) noexcept - # Return the coefficient of the monomial with exponent *exp*. - void nmod_mpoly_set_coeff_ui_fmpz(nmod_mpoly_t A, ulong c, fmpz * const * exp, const nmod_mpoly_ctx_t ctx) noexcept void nmod_mpoly_set_coeff_ui_ui(nmod_mpoly_t A, ulong c, const ulong * exp, const nmod_mpoly_ctx_t ctx) noexcept - # Set the coefficient of the monomial with exponent *exp* to `c`. - void nmod_mpoly_get_coeff_vars_ui(nmod_mpoly_t C, const nmod_mpoly_t A, const slong * vars, const ulong * exps, slong length, const nmod_mpoly_ctx_t ctx) noexcept - # Set *C* to the coefficient of *A* with respect to the variables in *vars* with powers in the corresponding array *exps*. - # Both *vars* and *exps* point to array of length *length*. It is assumed that ``0 < length \le nvars(A)`` and that the variables in *vars* are distinct. - int nmod_mpoly_cmp(const nmod_mpoly_t A, const nmod_mpoly_t B, const nmod_mpoly_ctx_t ctx) noexcept - # Return `1` (resp. `-1`, or `0`) if *A* is after (resp. before, same as) *B* in some arbitrary but fixed total ordering of the polynomials. - # This ordering agrees with the usual ordering of monomials when *A* and *B* are both monomials. - mp_limb_t * nmod_mpoly_term_coeff_ref(nmod_mpoly_t A, slong i, const nmod_mpoly_ctx_t ctx) noexcept - # Return a reference to the coefficient of index *i* of *A*. - bint nmod_mpoly_is_canonical(const nmod_mpoly_t A, const nmod_mpoly_ctx_t ctx) noexcept - # Return `1` if *A* is in canonical form. Otherwise, return `0`. - # To be in canonical form, all of the terms must have nonzero coefficients, and the terms must be sorted from greatest to least. - slong nmod_mpoly_length(const nmod_mpoly_t A, const nmod_mpoly_ctx_t ctx) noexcept - # Return the number of terms in *A*. - # If the polynomial is in canonical form, this will be the number of nonzero coefficients. - void nmod_mpoly_resize(nmod_mpoly_t A, slong new_length, const nmod_mpoly_ctx_t ctx) noexcept - # Set the length of *A* to ``new_length``. - # Terms are either deleted from the end, or new zero terms are appended. - ulong nmod_mpoly_get_term_coeff_ui(const nmod_mpoly_t A, slong i, const nmod_mpoly_ctx_t ctx) noexcept - # Return the coefficient of the term of index *i*. - void nmod_mpoly_set_term_coeff_ui(nmod_mpoly_t A, slong i, ulong c, const nmod_mpoly_ctx_t ctx) noexcept - # Set the coefficient of the term of index *i* to *c*. - int nmod_mpoly_term_exp_fits_si(const nmod_mpoly_t A, slong i, const nmod_mpoly_ctx_t ctx) noexcept int nmod_mpoly_term_exp_fits_ui(const nmod_mpoly_t A, slong i, const nmod_mpoly_ctx_t ctx) noexcept - # Return `1` if all entries of the exponent vector of the term of index *i* fit into an ``slong`` (resp. a ``ulong``). Otherwise, return `0`. - void nmod_mpoly_get_term_exp_fmpz(fmpz ** exp, const nmod_mpoly_t A, slong i, const nmod_mpoly_ctx_t ctx) noexcept void nmod_mpoly_get_term_exp_ui(ulong * exp, const nmod_mpoly_t A, slong i, const nmod_mpoly_ctx_t ctx) noexcept - void nmod_mpoly_get_term_exp_si(slong * exp, const nmod_mpoly_t A, slong i, const nmod_mpoly_ctx_t ctx) noexcept - # Set *exp* to the exponent vector of the term of index *i*. - # The ``_ui`` (resp. ``_si``) version throws if any entry does not fit into a ``ulong`` (resp. ``slong``). - ulong nmod_mpoly_get_term_var_exp_ui(const nmod_mpoly_t A, slong i, slong var, const nmod_mpoly_ctx_t ctx) noexcept slong nmod_mpoly_get_term_var_exp_si(const nmod_mpoly_t A, slong i, slong var, const nmod_mpoly_ctx_t ctx) noexcept - # Return the exponent of the variable *var* of the term of index *i*. - # This function throws if the exponent does not fit into a ``ulong`` (resp. ``slong``). - void nmod_mpoly_set_term_exp_fmpz(nmod_mpoly_t A, slong i, fmpz * const * exp, const nmod_mpoly_ctx_t ctx) noexcept void nmod_mpoly_set_term_exp_ui(nmod_mpoly_t A, slong i, const ulong * exp, const nmod_mpoly_ctx_t ctx) noexcept - # Set the exponent of the term of index *i* to *exp*. - void nmod_mpoly_get_term(nmod_mpoly_t M, const nmod_mpoly_t A, slong i, const nmod_mpoly_ctx_t ctx) noexcept - # Set *M* to the term of index *i* in *A*. - void nmod_mpoly_get_term_monomial(nmod_mpoly_t M, const nmod_mpoly_t A, slong i, const nmod_mpoly_ctx_t ctx) noexcept - # Set *M* to the monomial of the term of index *i* in *A*. The coefficient of *M* will be one. - void nmod_mpoly_push_term_ui_fmpz(nmod_mpoly_t A, ulong c, fmpz * const * exp, const nmod_mpoly_ctx_t ctx) noexcept void nmod_mpoly_push_term_ui_ffmpz(nmod_mpoly_t A, ulong c, const fmpz * exp, const nmod_mpoly_ctx_t ctx) noexcept void nmod_mpoly_push_term_ui_ui(nmod_mpoly_t A, ulong c, const ulong * exp, const nmod_mpoly_ctx_t ctx) noexcept - # Append a term to *A* with coefficient *c* and exponent vector *exp*. - # This function runs in constant average time. - void nmod_mpoly_sort_terms(nmod_mpoly_t A, const nmod_mpoly_ctx_t ctx) noexcept - # Sort the terms of *A* into the canonical ordering dictated by the ordering in *ctx*. - # This function simply reorders the terms: It does not combine like terms, nor does it delete terms with coefficient zero. - # This function runs in linear time in the bit size of *A*. - void nmod_mpoly_combine_like_terms(nmod_mpoly_t A, const nmod_mpoly_ctx_t ctx) noexcept - # Combine adjacent like terms in *A* and delete terms with coefficient zero. - # If the terms of *A* were sorted to begin with, the result will be in canonical form. - # This function runs in linear time in the bit size of *A*. - void nmod_mpoly_reverse(nmod_mpoly_t A, const nmod_mpoly_t B, const nmod_mpoly_ctx_t ctx) noexcept - # Set *A* to the reversal of *B*. - void nmod_mpoly_randtest_bound(nmod_mpoly_t A, flint_rand_t state, slong length, ulong exp_bound, const nmod_mpoly_ctx_t ctx) noexcept - # Generate a random polynomial with length up to *length* and exponents in the range ``[0, exp_bound - 1]``. - # The exponents of each variable are generated by calls to ``n_randint(state, exp_bound)``. - void nmod_mpoly_randtest_bounds(nmod_mpoly_t A, flint_rand_t state, slong length, ulong * exp_bounds, const nmod_mpoly_ctx_t ctx) noexcept - # Generate a random polynomial with length up to *length* and exponents in the range ``[0, exp_bounds[i] - 1]``. - # The exponents of the variable of index *i* are generated by calls to ``n_randint(state, exp_bounds[i])``. - void nmod_mpoly_randtest_bits(nmod_mpoly_t A, flint_rand_t state, slong length, mp_limb_t exp_bits, const nmod_mpoly_ctx_t ctx) noexcept - # Generate a random polynomial with length up to *length* and exponents whose packed form does not exceed the given bit count. - void nmod_mpoly_add_ui(nmod_mpoly_t A, const nmod_mpoly_t B, ulong c, const nmod_mpoly_ctx_t ctx) noexcept - # Set *A* to `B + c`. - void nmod_mpoly_sub_ui(nmod_mpoly_t A, const nmod_mpoly_t B, ulong c, const nmod_mpoly_ctx_t ctx) noexcept - # Set *A* to `B - c`. - void nmod_mpoly_add(nmod_mpoly_t A, const nmod_mpoly_t B, const nmod_mpoly_t C, const nmod_mpoly_ctx_t ctx) noexcept - # Set *A* to `B + C`. - void nmod_mpoly_sub(nmod_mpoly_t A, const nmod_mpoly_t B, const nmod_mpoly_t C, const nmod_mpoly_ctx_t ctx) noexcept - # Set *A* to `B - C`. - void nmod_mpoly_neg(nmod_mpoly_t A, const nmod_mpoly_t B, const nmod_mpoly_ctx_t ctx) noexcept - # Set *A* to `-B`. - void nmod_mpoly_scalar_mul_ui(nmod_mpoly_t A, const nmod_mpoly_t B, ulong c, const nmod_mpoly_ctx_t ctx) noexcept - # Set *A* to `B \times c`. - void nmod_mpoly_make_monic(nmod_mpoly_t A, const nmod_mpoly_t B, const nmod_mpoly_ctx_t ctx) noexcept - # Set *A* to *B* divided by the leading coefficient of *B*. - # This throws if *B* is zero or the leading coefficient is not invertible. - void nmod_mpoly_derivative(nmod_mpoly_t A, const nmod_mpoly_t B, slong var, const nmod_mpoly_ctx_t ctx) noexcept - # Set *A* to the derivative of *B* with respect to the variable of index *var*. - ulong nmod_mpoly_evaluate_all_ui(const nmod_mpoly_t A, const ulong * vals, const nmod_mpoly_ctx_t ctx) noexcept - # Return the evaluation of *A* where the variables are replaced by the corresponding elements of the array *vals*. - void nmod_mpoly_evaluate_one_ui(nmod_mpoly_t A, const nmod_mpoly_t B, slong var, ulong val, const nmod_mpoly_ctx_t ctx) noexcept - # Set *A* to the evaluation of *B* where the variable of index *var* is replaced by *val*. - int nmod_mpoly_compose_nmod_poly(nmod_poly_t A, const nmod_mpoly_t B, nmod_poly_struct * const * C, const nmod_mpoly_ctx_t ctx) noexcept - # Set *A* to the evaluation of *B* where the variables are replaced by the corresponding elements of the array *C*. - # The context object of *B* is *ctxB*. - # Return `1` for success and `0` for failure. - int nmod_mpoly_compose_nmod_mpoly_geobucket(nmod_mpoly_t A, const nmod_mpoly_t B, nmod_mpoly_struct * const * C, const nmod_mpoly_ctx_t ctxB, const nmod_mpoly_ctx_t ctxAC) noexcept int nmod_mpoly_compose_nmod_mpoly_horner(nmod_mpoly_t A, const nmod_mpoly_t B, nmod_mpoly_struct * const * C, const nmod_mpoly_ctx_t ctxB, const nmod_mpoly_ctx_t ctxAC) noexcept int nmod_mpoly_compose_nmod_mpoly(nmod_mpoly_t A, const nmod_mpoly_t B, nmod_mpoly_struct * const * C, const nmod_mpoly_ctx_t ctxB, const nmod_mpoly_ctx_t ctxAC) noexcept - # Set *A* to the evaluation of *B* where the variables are replaced by the corresponding elements of the array *C*. - # Both *A* and the elements of *C* have context object *ctxAC*, while *B* has context object *ctxB*. - # Neither of *A* and *B* is allowed to alias any other polynomial. - # Return `1` for success and `0` for failure. - # The main method attempts to perform the calculation using matrices and chooses heuristically between the ``geobucket`` and ``horner`` methods if needed. - void nmod_mpoly_compose_nmod_mpoly_gen(nmod_mpoly_t A, const nmod_mpoly_t B, const slong * c, const nmod_mpoly_ctx_t ctxB, const nmod_mpoly_ctx_t ctxAC) noexcept - # Set *A* to the evaluation of *B* where the variable of index *i* in *ctxB* is replaced by the variable of index ``c[i]`` in *ctxAC*. - # The length of the array *C* is the number of variables in *ctxB*. - # If any ``c[i]`` is negative, the corresponding variable of *B* is replaced by zero. Otherwise, it is expected that ``c[i]`` is less than the number of variables in *ctxAC*. - void nmod_mpoly_mul(nmod_mpoly_t A, const nmod_mpoly_t B, const nmod_mpoly_t C, const nmod_mpoly_ctx_t ctx) noexcept - # Set *A* to `B \times C`. - void nmod_mpoly_mul_johnson(nmod_mpoly_t A, const nmod_mpoly_t B, const nmod_mpoly_t C, const nmod_mpoly_ctx_t ctx) noexcept void nmod_mpoly_mul_heap_threaded(nmod_mpoly_t A, const nmod_mpoly_t B, const nmod_mpoly_t C, const nmod_mpoly_ctx_t ctx) noexcept - # Set *A* to `B \times C` using Johnson's heap-based method. - # The first version always uses one thread. - int nmod_mpoly_mul_array(nmod_mpoly_t A, const nmod_mpoly_t B, const nmod_mpoly_t C, const nmod_mpoly_ctx_t ctx) noexcept int nmod_mpoly_mul_array_threaded(nmod_mpoly_t A, const nmod_mpoly_t B, const nmod_mpoly_t C, const nmod_mpoly_ctx_t ctx) noexcept - # Try to set *A* to `B \times C` using arrays. - # If the return is `0`, the operation was unsuccessful. Otherwise, it was successful, and the return is `1`. - # The first version always uses one thread. - int nmod_mpoly_mul_dense(nmod_mpoly_t A, const nmod_mpoly_t B, const nmod_mpoly_t C, const nmod_mpoly_ctx_t ctx) noexcept - # Try to set *A* to `B \times C` using univariate arithmetic. - # If the return is `0`, the operation was unsuccessful. Otherwise, it was successful and the return is `1`. - int nmod_mpoly_pow_fmpz(nmod_mpoly_t A, const nmod_mpoly_t B, const fmpz_t k, const nmod_mpoly_ctx_t ctx) noexcept - # Set *A* to *B* raised to the *k*-th power. - # Return `1` for success and `0` for failure. - int nmod_mpoly_pow_ui(nmod_mpoly_t A, const nmod_mpoly_t B, ulong k, const nmod_mpoly_ctx_t ctx) noexcept - # Set *A* to *B* raised to the *k*-th power. - # Return `1` for success and `0` for failure. - int nmod_mpoly_divides(nmod_mpoly_t Q, const nmod_mpoly_t A, const nmod_mpoly_t B, const nmod_mpoly_ctx_t ctx) noexcept - # If *A* is divisible by *B*, set *Q* to the exact quotient and return `1`. Otherwise, set *Q* to zero and return `0`. - # Note that the function ``nmod_mpoly_div`` below may be faster if the quotient is known to be exact. - void nmod_mpoly_div(nmod_mpoly_t Q, const nmod_mpoly_t A, const nmod_mpoly_t B, const nmod_mpoly_ctx_t ctx) noexcept - # Set *Q* to the quotient of *A* by *B*, discarding the remainder. - void nmod_mpoly_divrem(nmod_mpoly_t Q, nmod_mpoly_t R, const nmod_mpoly_t A, const nmod_mpoly_t B, const nmod_mpoly_ctx_t ctx) noexcept - # Set *Q* and *R* to the quotient and remainder of *A* divided by *B*. - void nmod_mpoly_divrem_ideal(nmod_mpoly_struct ** Q, nmod_mpoly_t R, const nmod_mpoly_t A, nmod_mpoly_struct * const * B, slong len, const nmod_mpoly_ctx_t ctx) noexcept - # This function is as per :func:`nmod_mpoly_divrem` except that it takes an array of divisor polynomials *B* and it returns an array of quotient polynomials *Q*. - # The number of divisor (and hence quotient) polynomials, is given by *len*. - int nmod_mpoly_divides_dense(nmod_mpoly_t Q, const nmod_mpoly_t A, const nmod_mpoly_t B, const nmod_mpoly_ctx_t ctx) noexcept - # Try to do the operation of ``nmod_mpoly_divides`` using univariate arithmetic. - # If the return is `-1`, the operation was unsuccessful. Otherwise, it was successful and the return is `0` or `1`. - int nmod_mpoly_divides_monagan_pearce(nmod_mpoly_t Q, const nmod_mpoly_t A, const nmod_mpoly_t B, const nmod_mpoly_ctx_t ctx) noexcept - # Do the operation of ``nmod_mpoly_divides`` using the algorithm of Michael Monagan and Roman Pearce. - int nmod_mpoly_divides_heap_threaded(nmod_mpoly_t Q, const nmod_mpoly_t A, const nmod_mpoly_t B, const nmod_mpoly_ctx_t ctx) noexcept - # Do the operation of ``nmod_mpoly_divides`` using a heap and multiple threads. - # This function should only be called once ``global_thread_pool`` has been initialized. - void nmod_mpoly_term_content(nmod_mpoly_t M, const nmod_mpoly_t A, const nmod_mpoly_ctx_t ctx) noexcept - # Set *M* to the GCD of the terms of *A*. - # If *A* is zero, *M* will be zero. Otherwise, *M* will be a monomial with coefficient one. - int nmod_mpoly_content_vars(nmod_mpoly_t g, const nmod_mpoly_t A, slong * vars, slong vars_length, const nmod_mpoly_ctx_t ctx) noexcept - # Set *g* to the GCD of the coefficients of *A* when viewed as a polynomial in the variables *vars*. - # Return `1` for success and `0` for failure. Upon success, *g* will be independent of the variables *vars*. - int nmod_mpoly_gcd(nmod_mpoly_t G, const nmod_mpoly_t A, const nmod_mpoly_t B, const nmod_mpoly_ctx_t ctx) noexcept - # Try to set *G* to the monic GCD of *A* and *B*. The GCD of zero and zero is defined to be zero. - # If the return is `1` the function was successful. Otherwise the return is `0` and *G* is left untouched. - int nmod_mpoly_gcd_cofactors(nmod_mpoly_t G, nmod_mpoly_t Abar, nmod_mpoly_t Bbar, const nmod_mpoly_t A, const nmod_mpoly_t B, const nmod_mpoly_ctx_t ctx) noexcept - # Do the operation of :func:`nmod_mpoly_gcd` and also compute `Abar = A/G` and `Bbar = B/G` if successful. - int nmod_mpoly_gcd_brown(nmod_mpoly_t G, const nmod_mpoly_t A, const nmod_mpoly_t B, const nmod_mpoly_ctx_t ctx) noexcept int nmod_mpoly_gcd_hensel(nmod_mpoly_t G, const nmod_mpoly_t A, const nmod_mpoly_t B, const nmod_mpoly_ctx_t ctx) noexcept int nmod_mpoly_gcd_zippel(nmod_mpoly_t G, const nmod_mpoly_t A, const nmod_mpoly_t B, const nmod_mpoly_ctx_t ctx) noexcept - # Try to set *G* to the GCD of *A* and *B* using various algorithms. - int nmod_mpoly_resultant(nmod_mpoly_t R, const nmod_mpoly_t A, const nmod_mpoly_t B, slong var, const nmod_mpoly_ctx_t ctx) noexcept - # Try to set *R* to the resultant of *A* and *B* with respect to the variable of index *var*. - int nmod_mpoly_discriminant(nmod_mpoly_t D, const nmod_mpoly_t A, slong var, const nmod_mpoly_ctx_t ctx) noexcept - # Try to set *D* to the discriminant of *A* with respect to the variable of index *var*. - int nmod_mpoly_sqrt(nmod_mpoly_t Q, const nmod_mpoly_t A, const nmod_mpoly_ctx_t ctx) noexcept - # If `Q^2=A` has a solution, set *Q* to a solution and return `1`, otherwise return `0` and set *Q* to zero. - bint nmod_mpoly_is_square(const nmod_mpoly_t A, const nmod_mpoly_ctx_t ctx) noexcept - # Return `1` if *A* is a perfect square, otherwise return `0`. - int nmod_mpoly_quadratic_root(nmod_mpoly_t Q, const nmod_mpoly_t A, const nmod_mpoly_t B, const nmod_mpoly_ctx_t ctx) noexcept - # If `Q^2+AQ=B` has a solution, set *Q* to a solution and return `1`, otherwise return `0`. - void nmod_mpoly_univar_init(nmod_mpoly_univar_t A, const nmod_mpoly_ctx_t ctx) noexcept - # Initialize *A*. - void nmod_mpoly_univar_clear(nmod_mpoly_univar_t A, const nmod_mpoly_ctx_t ctx) noexcept - # Clear *A*. - void nmod_mpoly_univar_swap(nmod_mpoly_univar_t A, nmod_mpoly_univar_t B, const nmod_mpoly_ctx_t ctx) noexcept - # Swap *A* and *B*. - void nmod_mpoly_to_univar(nmod_mpoly_univar_t A, const nmod_mpoly_t B, slong var, const nmod_mpoly_ctx_t ctx) noexcept - # Set *A* to a univariate form of *B* by pulling out the variable of index *var*. - # The coefficients of *A* will still belong to the content *ctx* but will not depend on the variable of index *var*. - void nmod_mpoly_from_univar(nmod_mpoly_t A, const nmod_mpoly_univar_t B, slong var, const nmod_mpoly_ctx_t ctx) noexcept - # Set *A* to the normal form of *B* by putting in the variable of index *var*. - # This function is undefined if the coefficients of *B* depend on the variable of index *var*. - int nmod_mpoly_univar_degree_fits_si(const nmod_mpoly_univar_t A, const nmod_mpoly_ctx_t ctx) noexcept - # Return `1` if the degree of *A* with respect to the main variable fits an ``slong``. Otherwise, return `0`. - slong nmod_mpoly_univar_length(const nmod_mpoly_univar_t A, const nmod_mpoly_ctx_t ctx) noexcept - # Return the number of terms in *A* with respect to the main variable. - slong nmod_mpoly_univar_get_term_exp_si(nmod_mpoly_univar_t A, slong i, const nmod_mpoly_ctx_t ctx) noexcept - # Return the exponent of the term of index *i* of *A*. - void nmod_mpoly_univar_get_term_coeff(nmod_mpoly_t c, const nmod_mpoly_univar_t A, slong i, const nmod_mpoly_ctx_t ctx) noexcept void nmod_mpoly_univar_swap_term_coeff(nmod_mpoly_t c, nmod_mpoly_univar_t A, slong i, const nmod_mpoly_ctx_t ctx) noexcept - # Set (resp. swap) *c* to (resp. with) the coefficient of the term of index *i* of *A*. - void nmod_mpoly_pow_rmul(nmod_mpoly_t A, const nmod_mpoly_t B, ulong k, const nmod_mpoly_ctx_t ctx) noexcept - # Set *A* to *B* raised to the *k*-th power using repeated multiplications. - void nmod_mpoly_div_monagan_pearce(nmod_mpoly_t polyq, const nmod_mpoly_t poly2, const nmod_mpoly_t poly3, const nmod_mpoly_ctx_t ctx) noexcept - # Set ``polyq`` to the quotient of ``poly2`` by ``poly3``, - # discarding the remainder (with notional remainder coefficients reduced - # modulo the leading coefficient of ``poly3``). Implements "Polynomial - # division using dynamic arrays, heaps and packed exponents" by Michael - # Monagan and Roman Pearce. This function is exceptionally efficient if the - # division is known to be exact. - void nmod_mpoly_divrem_monagan_pearce(nmod_mpoly_t q, nmod_mpoly_t r, const nmod_mpoly_t poly2, const nmod_mpoly_t poly3, const nmod_mpoly_ctx_t ctx) noexcept - # Set ``polyq`` and ``polyr`` to the quotient and remainder of - # ``poly2`` divided by ``poly3``, (with remainder coefficients reduced - # modulo the leading coefficient of ``poly3``). Implements "Polynomial - # division using dynamic arrays, heaps and packed exponents" by Michael - # Monagan and Roman Pearce. - void nmod_mpoly_divrem_ideal_monagan_pearce(nmod_mpoly_struct ** q, nmod_mpoly_t r, const nmod_mpoly_t poly2, nmod_mpoly_struct * const * poly3, slong len, const nmod_mpoly_ctx_t ctx) noexcept - # This function is as per ``nmod_mpoly_divrem_monagan_pearce`` except - # that it takes an array of divisor polynomials ``poly3``, and it returns - # an array of quotient polynomials ``q``. The number of divisor (and hence - # quotient) polynomials, is given by *len*. The function computes - # polynomials `q_i = q[i]` such that ``poly2`` is - # `r + \sum_{i=0}^{\mbox{len - 1}} q_ib_i`, where `b_i =` ``poly3[i]``. diff --git a/src/sage/libs/flint/nmod_mpoly_factor.pxd b/src/sage/libs/flint/nmod_mpoly_factor.pxd index e30e6f70c1e..23c6b47384f 100644 --- a/src/sage/libs/flint/nmod_mpoly_factor.pxd +++ b/src/sage/libs/flint/nmod_mpoly_factor.pxd @@ -2,7 +2,9 @@ # distutils: depends = flint/nmod_mpoly_factor.h ################################################################################ -# This file is auto-generated. Do not modify by hand +# This file is auto-generated by the script +# SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py. +# Do not modify by hand! Fix and rerun the script instead. ################################################################################ from libc.stdio cimport FILE @@ -11,37 +13,14 @@ from sage.libs.mpfr.types cimport * from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void nmod_mpoly_factor_init(nmod_mpoly_factor_t f, const nmod_mpoly_ctx_t ctx) noexcept - # Initialise *f*. - void nmod_mpoly_factor_clear(nmod_mpoly_factor_t f, const nmod_mpoly_ctx_t ctx) noexcept - # Clear *f*. - void nmod_mpoly_factor_swap(nmod_mpoly_factor_t f, nmod_mpoly_factor_t g, const nmod_mpoly_ctx_t ctx) noexcept - # Efficiently swap *f* and *g*. - slong nmod_mpoly_factor_length(const nmod_mpoly_factor_t f, const nmod_mpoly_ctx_t ctx) noexcept - # Return the length of the product in *f*. - ulong nmod_mpoly_factor_get_constant_ui(const nmod_mpoly_factor_t f, const nmod_mpoly_ctx_t ctx) noexcept - # Return the constant of *f*. - void nmod_mpoly_factor_get_base(nmod_mpoly_t p, const nmod_mpoly_factor_t f, slong i, const nmod_mpoly_ctx_t ctx) noexcept void nmod_mpoly_factor_swap_base(nmod_mpoly_t p, nmod_mpoly_factor_t f, slong i, const nmod_mpoly_ctx_t ctx) noexcept - # Set (resp. swap) *B* to (resp. with) the base of the term of index `i` in *A*. - slong nmod_mpoly_factor_get_exp_si(nmod_mpoly_factor_t f, slong i, const nmod_mpoly_ctx_t ctx) noexcept - # Return the exponent of the term of index `i` in *A*. It is assumed to fit an ``slong``. - void nmod_mpoly_factor_sort(nmod_mpoly_factor_t f, const nmod_mpoly_ctx_t ctx) noexcept - # Sort the product of *f* first by exponent and then by base. - int nmod_mpoly_factor_squarefree(nmod_mpoly_factor_t f, const nmod_mpoly_t A, const nmod_mpoly_ctx_t ctx) noexcept - # Set *f* to a factorization of *A* where the bases are primitive and - # pairwise relatively prime. If the product of all irreducible factors with - # a given exponent is desired, it is recommended to call :func:`nmod_mpoly_factor_sort` - # and then multiply the bases with the desired exponent. - int nmod_mpoly_factor(nmod_mpoly_factor_t f, const nmod_mpoly_t A, const nmod_mpoly_ctx_t ctx) noexcept - # Set *f* to a factorization of *A* where the bases are irreducible. diff --git a/src/sage/libs/flint/nmod_poly.pxd b/src/sage/libs/flint/nmod_poly.pxd index 9c24f3bf831..eb5cd984fd6 100644 --- a/src/sage/libs/flint/nmod_poly.pxd +++ b/src/sage/libs/flint/nmod_poly.pxd @@ -2,7 +2,9 @@ # distutils: depends = flint/nmod_poly.h ################################################################################ -# This file is auto-generated. Do not modify by hand +# This file is auto-generated by the script +# SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py. +# Do not modify by hand! Fix and rerun the script instead. ################################################################################ from libc.stdio cimport FILE @@ -11,1801 +13,325 @@ from sage.libs.mpfr.types cimport * from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - int signed_mpn_sub_n(mp_ptr res, mp_srcptr op1, mp_srcptr op2, slong n) noexcept - # If ``op1 >= op2`` return 0 and set ``res`` to ``op1 - op2`` - # else return 1 and set ``res`` to ``op2 - op1``. - void nmod_poly_init(nmod_poly_t poly, mp_limb_t n) noexcept - # Initialises ``poly``. It will have coefficients modulo `n`. - void nmod_poly_init_preinv(nmod_poly_t poly, mp_limb_t n, mp_limb_t ninv) noexcept - # Initialises ``poly``. It will have coefficients modulo `n`. - # The caller supplies a precomputed inverse limb generated by - # :func:`n_preinvert_limb`. - void nmod_poly_init_mod(nmod_poly_t poly, const nmod_t mod) noexcept - # Initialises ``poly`` using an already initialised modulus ``mod``. - void nmod_poly_init2(nmod_poly_t poly, mp_limb_t n, slong alloc) noexcept - # Initialises ``poly``. It will have coefficients modulo `n`. - # Up to ``alloc`` coefficients may be stored in ``poly``. - void nmod_poly_init2_preinv(nmod_poly_t poly, mp_limb_t n, mp_limb_t ninv, slong alloc) noexcept - # Initialises ``poly``. It will have coefficients modulo `n`. - # The caller supplies a precomputed inverse limb generated by - # :func:`n_preinvert_limb`. Up to ``alloc`` coefficients may - # be stored in ``poly``. - void nmod_poly_realloc(nmod_poly_t poly, slong alloc) noexcept - # Reallocates ``poly`` to the given length. If the current - # length is less than ``alloc``, the polynomial is truncated - # and normalised. If ``alloc`` is zero, the polynomial is - # cleared. - void nmod_poly_clear(nmod_poly_t poly) noexcept - # Clears the polynomial and releases any memory it used. The polynomial - # cannot be used again until it is initialised. - void nmod_poly_fit_length(nmod_poly_t poly, slong alloc) noexcept - # Ensures ``poly`` has space for at least ``alloc`` coefficients. - # This function only ever grows the allocated space, so no data loss can - # occur. - void _nmod_poly_normalise(nmod_poly_t poly) noexcept - # Internal function for normalising a polynomial so that the top - # coefficient, if there is one at all, is not zero. - slong nmod_poly_length(const nmod_poly_t poly) noexcept - # Returns the length of the polynomial ``poly``. The zero polynomial - # has length zero. - slong nmod_poly_degree(const nmod_poly_t poly) noexcept - # Returns the degree of the polynomial ``poly``. The zero polynomial - # is deemed to have degree `-1`. - mp_limb_t nmod_poly_modulus(const nmod_poly_t poly) noexcept - # Returns the modulus of the polynomial ``poly``. This will be a - # positive integer. - flint_bitcnt_t nmod_poly_max_bits(const nmod_poly_t poly) noexcept - # Returns the maximum number of bits of any coefficient of ``poly``. - bint nmod_poly_is_unit(const nmod_poly_t poly) noexcept - bint nmod_poly_is_monic(const nmod_poly_t poly) noexcept - void nmod_poly_set(nmod_poly_t a, const nmod_poly_t b) noexcept - # Sets ``a`` to a copy of ``b``. - void nmod_poly_swap(nmod_poly_t poly1, nmod_poly_t poly2) noexcept - # Efficiently swaps ``poly1`` and ``poly2`` by swapping pointers - # internally. - void nmod_poly_zero(nmod_poly_t res) noexcept - # Sets ``res`` to the zero polynomial. - void nmod_poly_truncate(nmod_poly_t poly, slong len) noexcept - # Truncates ``poly`` to the given length and normalises it. - # If ``len`` is greater than the current length of ``poly``, - # then nothing happens. - void nmod_poly_set_trunc(nmod_poly_t res, const nmod_poly_t poly, slong len) noexcept - # Notionally truncate ``poly`` to length ``len`` and set ``res`` to the - # result. The result is normalised. - void _nmod_poly_reverse(mp_ptr output, mp_srcptr input, slong len, slong m) noexcept - # Sets ``output`` to the reverse of ``input``, which is of length - # ``len``, but thinking of it as a polynomial of length ``m``, - # notionally zero-padded if necessary. The length ``m`` must be - # non-negative, but there are no other restrictions. The polynomial - # ``output`` must have space for ``m`` coefficients. Supports - # aliasing of ``output`` and ``input``, but the behaviour is - # undefined in case of partial overlap. - void nmod_poly_reverse(nmod_poly_t output, const nmod_poly_t input, slong m) noexcept - # Sets ``output`` to the reverse of ``input``, thinking of it as - # a polynomial of length ``m``, notionally zero-padded if necessary). - # The length ``m`` must be non-negative, but there are no other - # restrictions. The output polynomial will be set to length ``m`` - # and then normalised. - void nmod_poly_randtest(nmod_poly_t poly, flint_rand_t state, slong len) noexcept - # Generates a random polynomial with length up to ``len``. - void nmod_poly_randtest_irreducible(nmod_poly_t poly, flint_rand_t state, slong len) noexcept - # Generates a random irreducible polynomial with length up to ``len``. - void nmod_poly_randtest_monic(nmod_poly_t poly, flint_rand_t state, slong len) noexcept - # Generates a random monic polynomial with length ``len``. - void nmod_poly_randtest_monic_irreducible(nmod_poly_t poly, flint_rand_t state, slong len) noexcept - # Generates a random monic irreducible polynomial with length ``len``. - void nmod_poly_randtest_monic_primitive(nmod_poly_t poly, flint_rand_t state, slong len) noexcept - # Generates a random monic irreducible primitive polynomial with - # length ``len``. - void nmod_poly_randtest_trinomial(nmod_poly_t poly, flint_rand_t state, slong len) noexcept - # Generates a random monic trinomial of length ``len``. - int nmod_poly_randtest_trinomial_irreducible(nmod_poly_t poly, flint_rand_t state, slong len, slong max_attempts) noexcept - # Attempts to set ``poly`` to a monic irreducible trinomial of - # length ``len``. It will generate up to ``max_attempts`` - # trinomials in attempt to find an irreducible one. If - # ``max_attempts`` is ``0``, then it will keep generating - # trinomials until an irreducible one is found. Returns `1` if one - # is found and `0` otherwise. - void nmod_poly_randtest_pentomial(nmod_poly_t poly, flint_rand_t state, slong len) noexcept - # Generates a random monic pentomial of length ``len``. - int nmod_poly_randtest_pentomial_irreducible(nmod_poly_t poly, flint_rand_t state, slong len, slong max_attempts) noexcept - # Attempts to set ``poly`` to a monic irreducible pentomial of - # length ``len``. It will generate up to ``max_attempts`` - # pentomials in attempt to find an irreducible one. If - # ``max_attempts`` is ``0``, then it will keep generating - # pentomials until an irreducible one is found. Returns `1` if one - # is found and `0` otherwise. - void nmod_poly_randtest_sparse_irreducible(nmod_poly_t poly, flint_rand_t state, slong len) noexcept - # Attempts to set ``poly`` to a sparse, monic irreducible polynomial - # with length ``len``. It attempts to find an irreducible - # trinomial. If that does not succeed, it attempts to find a - # irreducible pentomial. If that fails, then ``poly`` is just - # set to a random monic irreducible polynomial. - ulong nmod_poly_get_coeff_ui(const nmod_poly_t poly, slong j) noexcept - # Returns the coefficient of ``poly`` at index ``j``, where - # coefficients are numbered with zero being the constant coefficient, - # and returns it as an ``ulong``. If ``j`` refers to a - # coefficient beyond the end of ``poly``, zero is returned. - void nmod_poly_set_coeff_ui(nmod_poly_t poly, slong j, ulong c) noexcept - # Sets the coefficient of ``poly`` at index ``j``, where - # coefficients are numbered with zero being the constant coefficient, - # to the value ``c`` reduced modulo the modulus of ``poly``. - # If ``j`` refers to a coefficient beyond the current end of ``poly``, - # the polynomial is first resized, with intervening coefficients being - # set to zero. - char * nmod_poly_get_str(const nmod_poly_t poly) noexcept - # Writes ``poly`` to a string representation. The format is as - # described for :func:`nmod_poly_print`. The string must be freed by the - # user when finished. For this it is sufficient to call :func:`flint_free`. - char * nmod_poly_get_str_pretty(const nmod_poly_t poly, const char * x) noexcept - # Writes ``poly`` to a pretty string representation. The format is as - # described for :func:`nmod_poly_print_pretty`. The string must be freed - # by the user when finished. For this it is sufficient to call - # :func:`flint_free`. - # It is assumed that the top coefficient is non-zero. - int nmod_poly_set_str(nmod_poly_t poly, const char * s) noexcept - # Reads ``poly`` from a string ``s``. The format is as described - # for :func:`nmod_poly_print`. If a polynomial in the correct format - # is read, a positive value is returned, otherwise a non-positive value - # is returned. - int nmod_poly_print(const nmod_poly_t a) noexcept - # Prints the polynomial to ``stdout``. The length is printed, - # followed by a space, then the modulus. If the length is zero this is - # all that is printed, otherwise two spaces followed by a space - # separated list of coefficients is printed, beginning with the constant - # coefficient. - # In case of success, returns a positive value. In case of failure, - # returns a non-positive value. - int nmod_poly_print_pretty(const nmod_poly_t a, const char * x) noexcept - # Prints the polynomial to ``stdout`` using the string ``x`` to - # represent the indeterminate. - # It is assumed that the top coefficient is non-zero. - # In case of success, returns a positive value. In case of failure, - # returns a non-positive value. - int nmod_poly_fread(FILE * f, nmod_poly_t poly) noexcept - # Reads ``poly`` from the file stream ``f``. If this is a file - # that has just been written, the file should be closed then opened - # again. The format is as described for :func:`nmod_poly_print`. If a - # polynomial in the correct format is read, a positive value is returned, - # otherwise a non-positive value is returned. - int nmod_poly_fprint(FILE * f, const nmod_poly_t poly) noexcept - # Writes a polynomial to the file stream ``f``. If this is a file - # then the file should be closed and reopened before being read. - # The format is as described for :func:`nmod_poly_print`. If the - # polynomial is written correctly, a positive value is returned, - # otherwise a non-positive value is returned. - # In case of success, returns a positive value. In case of failure, - # returns a non-positive value. - int nmod_poly_fprint_pretty(FILE * f, const nmod_poly_t poly, const char * x) noexcept - # Writes a polynomial to the file stream ``f``. If this is a file - # then the file should be closed and reopened before being read. - # The format is as described for :func:`nmod_poly_print_pretty`. If the - # polynomial is written correctly, a positive value is returned, - # otherwise a non-positive value is returned. - # It is assumed that the top coefficient is non-zero. - # In case of success, returns a positive value. In case of failure, - # returns a non-positive value. - int nmod_poly_read(nmod_poly_t poly) noexcept - # Read ``poly`` from ``stdin``. The format is as described for - # :func:`nmod_poly_print`. If a polynomial in the correct format is read, a - # positive value is returned, otherwise a non-positive value is returned. - bint nmod_poly_equal(const nmod_poly_t a, const nmod_poly_t b) noexcept - # Returns `1` if the polynomials are equal, otherwise `0`. - bint nmod_poly_equal_nmod(const nmod_poly_t poly, ulong cst) noexcept - # Returns `1` if the polynomial ``poly`` is constant, equal to ``cst``, - # otherwise `0`. - # ``cst`` is assumed to be already reduced, i.e. less than the modulus of - # ``poly``. - bint nmod_poly_equal_ui(const nmod_poly_t poly, ulong cst) noexcept - # Returns `1` if the polynomial ``poly`` is constant and equal to ``cst`` up to - # reduction modulo the modulus of ``poly``, otherwise returns `0`. - bint nmod_poly_equal_trunc(const nmod_poly_t poly1, const nmod_poly_t poly2, slong n) noexcept - # Notionally truncate ``poly1`` and ``poly2`` to length `n` and return - # `1` if the truncations are equal, otherwise return `0`. - bint nmod_poly_is_zero(const nmod_poly_t poly) noexcept - # Returns `1` if the polynomial ``poly`` is the zero polynomial, - # otherwise returns `0`. - bint nmod_poly_is_one(const nmod_poly_t poly) noexcept - # Returns `1` if the polynomial ``poly`` is the constant polynomial 1, - # otherwise returns `0`. - bint nmod_poly_is_gen(const nmod_poly_t poly) noexcept - void _nmod_poly_shift_left(mp_ptr res, mp_srcptr poly, slong len, slong k) noexcept - # Sets ``(res, len + k)`` to ``(poly, len)`` shifted left by - # ``k`` coefficients. Assumes that ``res`` has space for - # ``len + k`` coefficients. - void nmod_poly_shift_left(nmod_poly_t res, const nmod_poly_t poly, slong k) noexcept - # Sets ``res`` to ``poly`` shifted left by ``k`` coefficients, - # i.e. multiplied by `x^k`. - void _nmod_poly_shift_right(mp_ptr res, mp_srcptr poly, slong len, slong k) noexcept - # Sets ``(res, len - k)`` to ``(poly, len)`` shifted left by - # ``k`` coefficients. It is assumed that ``k <= len`` and that - # ``res`` has space for at least ``len - k`` coefficients. - void nmod_poly_shift_right(nmod_poly_t res, const nmod_poly_t poly, slong k) noexcept - # Sets ``res`` to ``poly`` shifted right by ``k`` coefficients, - # i.e. divide by `x^k` and throw away the remainder. If ``k`` is - # greater than or equal to the length of ``poly``, the result is the - # zero polynomial. - void _nmod_poly_add(mp_ptr res, mp_srcptr poly1, slong len1, mp_srcptr poly2, slong len2, nmod_t mod) noexcept - # Sets ``res`` to the sum of ``(poly1, len1)`` and - # ``(poly2, len2)``. There are no restrictions on the lengths. - void nmod_poly_add(nmod_poly_t res, const nmod_poly_t poly1, const nmod_poly_t poly2) noexcept - # Sets ``res`` to the sum of ``poly1`` and ``poly2``. - void nmod_poly_add_series(nmod_poly_t res, const nmod_poly_t poly1, const nmod_poly_t poly2, slong n) noexcept - # Notionally truncate ``poly1`` and ``poly2`` to length `n` and set - # ``res`` to the sum. - void _nmod_poly_sub(mp_ptr res, mp_srcptr poly1, slong len1, mp_srcptr poly2, slong len2, nmod_t mod) noexcept - # Sets ``res`` to the difference of ``(poly1, len1)`` and - # ``(poly2, len2)``. There are no restrictions on the lengths. - void nmod_poly_sub(nmod_poly_t res, const nmod_poly_t poly1, const nmod_poly_t poly2) noexcept - # Sets ``res`` to the difference of ``poly1`` and ``poly2``. - void nmod_poly_sub_series(nmod_poly_t res, const nmod_poly_t poly1, const nmod_poly_t poly2, slong n) noexcept - # Notionally truncate ``poly1`` and ``poly2`` to length `n` and set - # ``res`` to the difference. - void nmod_poly_neg(nmod_poly_t res, const nmod_poly_t poly) noexcept - # Sets ``res`` to the negation of ``poly``. - void nmod_poly_scalar_mul_nmod(nmod_poly_t res, const nmod_poly_t poly, ulong c) noexcept - # Sets ``res`` to ``(poly, len)`` multiplied by `c`, - # where `c` is reduced modulo the modulus of ``poly``. - + void nmod_poly_scalar_addmul_nmod(nmod_poly_t res, const nmod_poly_t poly, ulong c) noexcept void _nmod_poly_make_monic(mp_ptr output, mp_srcptr input, slong len, nmod_t mod) noexcept - # Sets ``output`` to be the scalar multiple of ``input`` of - # length ``len > 0`` that has leading coefficient one, if such a - # polynomial exists. If the leading coefficient of ``input`` is not - # invertible, ``output`` is set to the multiple of ``input`` whose - # leading coefficient is the greatest common divisor of the leading - # coefficient and the modulus of ``input``. - void nmod_poly_make_monic(nmod_poly_t output, const nmod_poly_t input) noexcept - # Sets ``output`` to be the scalar multiple of ``input`` with leading - # coefficient one, if such a polynomial exists. If ``input`` is zero - # an exception is raised. If the leading coefficient of ``input`` is not - # invertible, ``output`` is set to the multiple of ``input`` whose - # leading coefficient is the greatest common divisor of the leading - # coefficient and the modulus of ``input``. - void _nmod_poly_bit_pack(mp_ptr res, mp_srcptr poly, slong len, flint_bitcnt_t bits) noexcept - # Packs ``len`` coefficients of ``poly`` into fields of the given - # number of bits in the large integer ``res``, i.e. evaluates - # ``poly`` at ``2^bits`` and store the result in ``res``. - # Assumes ``len > 0`` and ``bits > 0``. Also assumes that no - # coefficient of ``poly`` is bigger than ``bits/2`` bits. We - # also assume ``bits < 3 * FLINT_BITS``. - void _nmod_poly_bit_unpack(mp_ptr res, slong len, mp_srcptr mpn, ulong bits, nmod_t mod) noexcept - # Unpacks ``len`` coefficients stored in the big integer ``mpn`` - # in bit fields of the given number of bits, reduces them modulo the - # given modulus, then stores them in the polynomial ``res``. - # We assume ``len > 0`` and ``3 * FLINT_BITS > bits > 0``. - # There are no restrictions on the size of the actual coefficients as - # stored within the bitfields. - void nmod_poly_bit_pack(fmpz_t f, const nmod_poly_t poly, flint_bitcnt_t bit_size) noexcept - # Packs ``poly`` into bitfields of size ``bit_size``, writing the - # result to ``f``. - void nmod_poly_bit_unpack(nmod_poly_t poly, const fmpz_t f, flint_bitcnt_t bit_size) noexcept - # Unpacks the polynomial from fields of size ``bit_size`` as - # represented by the integer ``f``. - void _nmod_poly_KS2_pack1(mp_ptr res, mp_srcptr op, slong n, slong s, ulong b, ulong k, slong r) noexcept - # Same as ``_nmod_poly_KS2_pack``, but requires ``b <= FLINT_BITS``. - void _nmod_poly_KS2_pack(mp_ptr res, mp_srcptr op, slong n, slong s, ulong b, ulong k, slong r) noexcept - # Bit packing routine used by KS2 and KS4 multiplication. - void _nmod_poly_KS2_unpack1(mp_ptr res, mp_srcptr op, slong n, ulong b, ulong k) noexcept - # Same as ``_nmod_poly_KS2_unpack``, but requires ``b <= FLINT_BITS`` - # (i.e. writes one word per coefficient). - void _nmod_poly_KS2_unpack2(mp_ptr res, mp_srcptr op, slong n, ulong b, ulong k) noexcept - # Same as ``_nmod_poly_KS2_unpack``, but requires - # ``FLINT_BITS < b <= 2 * FLINT_BITS`` (i.e. writes two words per - # coefficient). - void _nmod_poly_KS2_unpack3(mp_ptr res, mp_srcptr op, slong n, ulong b, ulong k) noexcept - # Same as ``_nmod_poly_KS2_unpack``, but requires - # ``2 * FLINT_BITS < b < 3 * FLINT_BITS`` (i.e. writes three words per - # coefficient). - void _nmod_poly_KS2_unpack(mp_ptr res, mp_srcptr op, slong n, ulong b, ulong k) noexcept - # Bit unpacking code used by KS2 and KS4 multiplication. - void _nmod_poly_KS2_reduce(mp_ptr res, slong s, mp_srcptr op, slong n, ulong w, nmod_t mod) noexcept - # Reduction code used by KS2 and KS4 multiplication. - void _nmod_poly_KS2_recover_reduce1(mp_ptr res, slong s, mp_srcptr op1, mp_srcptr op2, slong n, ulong b, nmod_t mod) noexcept - # Same as ``_nmod_poly_KS2_recover_reduce``, but requires - # ``0 < 2 * b <= FLINT_BITS``. - void _nmod_poly_KS2_recover_reduce2(mp_ptr res, slong s, mp_srcptr op1, mp_srcptr op2, slong n, ulong b, nmod_t mod) noexcept - # Same as ``_nmod_poly_KS2_recover_reduce``, but requires - # ``FLINT_BITS < 2 * b < 2*FLINT_BITS``. - void _nmod_poly_KS2_recover_reduce2b(mp_ptr res, slong s, mp_srcptr op1, mp_srcptr op2, slong n, ulong b, nmod_t mod) noexcept - # Same as ``_nmod_poly_KS2_recover_reduce``, but requires - # ``b == FLINT_BITS``. - void _nmod_poly_KS2_recover_reduce3(mp_ptr res, slong s, mp_srcptr op1, mp_srcptr op2, slong n, ulong b, nmod_t mod) noexcept - # Same as ``_nmod_poly_KS2_recover_reduce``, but requires - # ``2 * FLINT_BITS < 2 * b <= 3 * FLINT_BITS``. - void _nmod_poly_KS2_recover_reduce(mp_ptr res, slong s, mp_srcptr op1, mp_srcptr op2, slong n, ulong b, nmod_t mod) noexcept - # Reduction code used by KS4 multiplication. - void _nmod_poly_mul_classical(mp_ptr res, mp_srcptr poly1, slong len1, mp_srcptr poly2, slong len2, nmod_t mod) noexcept - # Sets ``(res, len1 + len2 - 1)`` to the product of ``(poly1, len1)`` - # and ``(poly2, len2)``. Assumes ``len1 >= len2 > 0``. Aliasing of - # inputs and output is not permitted. - void nmod_poly_mul_classical(nmod_poly_t res, const nmod_poly_t poly1, const nmod_poly_t poly2) noexcept - # Sets ``res`` to the product of ``poly1`` and ``poly2``. - void _nmod_poly_mullow_classical(mp_ptr res, mp_srcptr poly1, slong len1, mp_srcptr poly2, slong len2, slong trunc, nmod_t mod) noexcept - # Sets ``res`` to the lower ``trunc`` coefficients of the product of - # ``(poly1, len1)`` and ``(poly2, len2)``. Assumes that - # ``len1 >= len2 > 0`` and ``trunc > 0``. Aliasing of inputs and - # output is not permitted. - void nmod_poly_mullow_classical(nmod_poly_t res, const nmod_poly_t poly1, const nmod_poly_t poly2, slong trunc) noexcept - # Sets ``res`` to the lower ``trunc`` coefficients of the product - # of ``poly1`` and ``poly2``. - void _nmod_poly_mulhigh_classical(mp_ptr res, mp_srcptr poly1, slong len1, mp_srcptr poly2, slong len2, slong start, nmod_t mod) noexcept - # Computes the product of ``(poly1, len1)`` and ``(poly2, len2)`` - # and writes the coefficients from ``start`` onwards into the high - # coefficients of ``res``, the remaining coefficients being arbitrary - # but reduced. Assumes that ``len1 >= len2 > 0``. Aliasing of inputs - # and output is not permitted. - void nmod_poly_mulhigh_classical(nmod_poly_t res, const nmod_poly_t poly1, const nmod_poly_t poly2, slong start) noexcept - # Computes the product of ``poly1`` and ``poly2`` and writes the - # coefficients from ``start`` onwards into the high coefficients of - # ``res``, the remaining coefficients being arbitrary but reduced. - void _nmod_poly_mul_KS(mp_ptr out, mp_srcptr in1, slong len1, mp_srcptr in2, slong len2, flint_bitcnt_t bits, nmod_t mod) noexcept - # Sets ``res`` to the product of ``in1`` and ``in2`` - # assuming the output coefficients are at most the given number of - # bits wide. If ``bits`` is set to `0` an appropriate value is - # computed automatically. Assumes that ``len1 >= len2 > 0``. - void nmod_poly_mul_KS(nmod_poly_t res, const nmod_poly_t poly1, const nmod_poly_t poly2, flint_bitcnt_t bits) noexcept - # Sets ``res`` to the product of ``poly1`` and ``poly2`` - # assuming the output coefficients are at most the given number of - # bits wide. If ``bits`` is set to `0` an appropriate value - # is computed automatically. - void _nmod_poly_mul_KS2(mp_ptr res, mp_srcptr op1, slong n1, mp_srcptr op2, slong n2, nmod_t mod) noexcept - # Sets ``res`` to the product of ``op1`` and ``op2``. - # Assumes that ``len1 >= len2 > 0``. - void nmod_poly_mul_KS2(nmod_poly_t res, const nmod_poly_t poly1, const nmod_poly_t poly2) noexcept - # Sets ``res`` to the product of ``poly1`` and ``poly2``. - void _nmod_poly_mul_KS4(mp_ptr res, mp_srcptr op1, slong n1, mp_srcptr op2, slong n2, nmod_t mod) noexcept - # Sets ``res`` to the product of ``op1`` and ``op2``. - # Assumes that ``len1 >= len2 > 0``. - void nmod_poly_mul_KS4(nmod_poly_t res, const nmod_poly_t poly1, const nmod_poly_t poly2) noexcept - # Sets ``res`` to the product of ``poly1`` and ``poly2``. - void _nmod_poly_mullow_KS(mp_ptr out, mp_srcptr in1, slong len1, mp_srcptr in2, slong len2, flint_bitcnt_t bits, slong n, nmod_t mod) noexcept - # Sets ``out`` to the low `n` coefficients of ``in1`` of length - # ``len1`` times ``in2`` of length ``len2``. The output must have - # space for ``n`` coefficients. We assume that ``len1 >= len2 > 0`` - # and that ``0 < n <= len1 + len2 - 1``. - void nmod_poly_mullow_KS(nmod_poly_t res, const nmod_poly_t poly1, const nmod_poly_t poly2, flint_bitcnt_t bits, slong n) noexcept - # Set ``res`` to the low `n` coefficients of ``in1`` of length - # ``len1`` times ``in2`` of length ``len2``. - void _nmod_poly_mul(mp_ptr res, mp_srcptr poly1, slong len1, mp_srcptr poly2, slong len2, nmod_t mod) noexcept - # Sets ``res`` to the product of ``poly1`` of length ``len1`` - # and ``poly2`` of length ``len2``. Assumes ``len1 >= len2 > 0``. - # No aliasing is permitted between the inputs and the output. - void nmod_poly_mul(nmod_poly_t res, const nmod_poly_t poly, const nmod_poly_t poly2) noexcept - # Sets ``res`` to the product of ``poly1`` and ``poly2``. - void _nmod_poly_mullow(mp_ptr res, mp_srcptr poly1, slong len1, mp_srcptr poly2, slong len2, slong n, nmod_t mod) noexcept - # Sets ``res`` to the first ``n`` coefficients of the - # product of ``poly1`` of length ``len1`` and ``poly2`` of - # length ``len2``. It is assumed that ``0 < n <= len1 + len2 - 1`` - # and that ``len1 >= len2 > 0``. No aliasing of inputs and output - # is permitted. - void nmod_poly_mullow(nmod_poly_t res, const nmod_poly_t poly1, const nmod_poly_t poly2, slong trunc) noexcept - # Sets ``res`` to the first ``trunc`` coefficients of the - # product of ``poly1`` and ``poly2``. - void _nmod_poly_mulhigh(mp_ptr res, mp_srcptr poly1, slong len1, mp_srcptr poly2, slong len2, slong n, nmod_t mod) noexcept - # Sets all but the low `n` coefficients of ``res`` to the - # corresponding coefficients of the product of ``poly1`` of length - # ``len1`` and ``poly2`` of length ``len2``, the other - # coefficients being arbitrary. It is assumed that - # ``len1 >= len2 > 0`` and that ``0 < n <= len1 + len2 - 1``. - # Aliasing of inputs and output is not permitted. - void nmod_poly_mulhigh(nmod_poly_t res, const nmod_poly_t poly1, const nmod_poly_t poly2, slong n) noexcept - # Sets all but the low `n` coefficients of ``res`` to the - # corresponding coefficients of the product of ``poly1`` and - # ``poly2``, the remaining coefficients being arbitrary. - void _nmod_poly_mulmod(mp_ptr res, mp_srcptr poly1, slong len1, mp_srcptr poly2, slong len2, mp_srcptr f, slong lenf, nmod_t mod) noexcept - # Sets ``res`` to the remainder of the product of ``poly1`` and - # ``poly2`` upon polynomial division by ``f``. - # It is required that ``len1 + len2 - lenf > 0``, which is equivalent - # to requiring that the result will actually be reduced. Otherwise, simply - # use ``_nmod_poly_mul`` instead. - # Aliasing of ``f`` and ``res`` is not permitted. - void nmod_poly_mulmod(nmod_poly_t res, const nmod_poly_t poly1, const nmod_poly_t poly2, const nmod_poly_t f) noexcept - # Sets ``res`` to the remainder of the product of ``poly1`` and - # ``poly2`` upon polynomial division by ``f``. - void _nmod_poly_mulmod_preinv(mp_ptr res, mp_srcptr poly1, slong len1, mp_srcptr poly2, slong len2, mp_srcptr f, slong lenf, mp_srcptr finv, slong lenfinv, nmod_t mod) noexcept - # Sets ``res`` to the remainder of the product of ``poly1`` and - # ``poly2`` upon polynomial division by ``f``. - # It is required that ``finv`` is the inverse of the reverse of ``f`` - # mod ``x^lenf``. It is required that ``len1 + len2 - lenf > 0``, - # which is equivalent to requiring that the result will actually be reduced. - # It is required that ``len1 < lenf`` and ``len2 < lenf``. - # Otherwise, simply use ``_nmod_poly_mul`` instead. - # Aliasing of ```res`` with any of the inputs is not permitted. - void nmod_poly_mulmod_preinv(nmod_poly_t res, const nmod_poly_t poly1, const nmod_poly_t poly2, const nmod_poly_t f, const nmod_poly_t finv) noexcept - # Sets ``res`` to the remainder of the product of ``poly1`` and - # ``poly2`` upon polynomial division by ``f``. ``finv`` is the - # inverse of the reverse of ``f``. It is required that ``poly1`` and - # ``poly2`` are reduced modulo ``f``. - void _nmod_poly_pow_binexp(mp_ptr res, mp_srcptr poly, slong len, ulong e, nmod_t mod) noexcept - # Raises ``poly`` of length ``len`` to the power ``e`` and sets - # ``res`` to the result. We require that ``res`` has enough space - # for ``(len - 1)*e + 1`` coefficients. Assumes that ``len > 0``, - # ``e > 1``. Aliasing is not permitted. Uses the binary exponentiation - # method. - void nmod_poly_pow_binexp(nmod_poly_t res, const nmod_poly_t poly, ulong e) noexcept - # Raises ``poly`` to the power ``e`` and sets ``res`` to the - # result. Uses the binary exponentiation method. - void _nmod_poly_pow(mp_ptr res, mp_srcptr poly, slong len, ulong e, nmod_t mod) noexcept - # Raises ``poly`` of length ``len`` to the power ``e`` and sets - # ``res`` to the result. We require that ``res`` has enough space - # for ``(len - 1)*e + 1`` coefficients. Assumes that ``len > 0``, - # ``e > 1``. Aliasing is not permitted. - void nmod_poly_pow(nmod_poly_t res, const nmod_poly_t poly, ulong e) noexcept - # Raises ``poly`` to the power ``e`` and sets ``res`` to the - # result. - void _nmod_poly_pow_trunc_binexp(mp_ptr res, mp_srcptr poly, ulong e, slong trunc, nmod_t mod) noexcept - # Sets ``res`` to the low ``trunc`` coefficients of ``poly`` - # (assumed to be zero padded if necessary to length ``trunc``) to - # the power ``e``. This is equivalent to doing a powering followed - # by a truncation. We require that ``res`` has enough space for - # ``trunc`` coefficients, that ``trunc > 0`` and that - # ``e > 1``. Aliasing is not permitted. Uses the binary - # exponentiation method. - void nmod_poly_pow_trunc_binexp(nmod_poly_t res, const nmod_poly_t poly, ulong e, slong trunc) noexcept - # Sets ``res`` to the low ``trunc`` coefficients of ``poly`` - # to the power ``e``. This is equivalent to doing a powering - # followed by a truncation. Uses the binary exponentiation method. - void _nmod_poly_pow_trunc(mp_ptr res, mp_srcptr poly, ulong e, slong trunc, nmod_t mod) noexcept - # Sets ``res`` to the low ``trunc`` coefficients of ``poly`` - # (assumed to be zero padded if necessary to length ``trunc``) to - # the power ``e``. This is equivalent to doing a powering followed - # by a truncation. We require that ``res`` has enough space for - # ``trunc`` coefficients, that ``trunc > 0`` and that - # ``e > 1``. Aliasing is not permitted. - void nmod_poly_pow_trunc(nmod_poly_t res, const nmod_poly_t poly, ulong e, slong trunc) noexcept - # Sets ``res`` to the low ``trunc`` coefficients of ``poly`` - # to the power ``e``. This is equivalent to doing a powering - # followed by a truncation. - void _nmod_poly_powmod_ui_binexp(mp_ptr res, mp_srcptr poly, ulong e, mp_srcptr f, slong lenf, nmod_t mod) noexcept - # Sets ``res`` to ``poly`` raised to the power ``e`` - # modulo ``f``, using binary exponentiation. We require ``e > 0``. - # We require ``lenf > 1``. It is assumed that ``poly`` is already - # reduced modulo ``f`` and zero-padded as necessary to have length - # exactly ``lenf - 1``. The output ``res`` must have room for - # ``lenf - 1`` coefficients. - void nmod_poly_powmod_ui_binexp(nmod_poly_t res, const nmod_poly_t poly, ulong e, const nmod_poly_t f) noexcept - # Sets ``res`` to ``poly`` raised to the power ``e`` - # modulo ``f``, using binary exponentiation. We require ``e >= 0``. - void _nmod_poly_powmod_fmpz_binexp(mp_ptr res, mp_srcptr poly, fmpz_t e, mp_srcptr f, slong lenf, nmod_t mod) noexcept - # Sets ``res`` to ``poly`` raised to the power ``e`` - # modulo ``f``, using binary exponentiation. We require ``e > 0``. - # We require ``lenf > 1``. It is assumed that ``poly`` is already - # reduced modulo ``f`` and zero-padded as necessary to have length - # exactly ``lenf - 1``. The output ``res`` must have room for ``lenf - 1`` coefficients. - void nmod_poly_powmod_fmpz_binexp(nmod_poly_t res, const nmod_poly_t poly, fmpz_t e, const nmod_poly_t f) noexcept - # Sets ``res`` to ``poly`` raised to the power ``e`` - # modulo ``f``, using binary exponentiation. We require ``e >= 0``. - void _nmod_poly_powmod_ui_binexp_preinv (mp_ptr res, mp_srcptr poly, ulong e, mp_srcptr f, slong lenf, mp_srcptr finv, slong lenfinv, nmod_t mod) noexcept - # Sets ``res`` to ``poly`` raised to the power ``e`` - # modulo ``f``, using binary exponentiation. We require ``e > 0``. - # We require ``finv`` to be the inverse of the reverse of ``f``. - # We require ``lenf > 1``. It is assumed that ``poly`` is already - # reduced modulo ``f`` and zero-padded as necessary to have length - # exactly ``lenf - 1``. The output ``res`` must have room for - # ``lenf - 1`` coefficients. - void nmod_poly_powmod_ui_binexp_preinv(nmod_poly_t res, const nmod_poly_t poly, ulong e, const nmod_poly_t f, const nmod_poly_t finv) noexcept - # Sets ``res`` to ``poly`` raised to the power ``e`` - # modulo ``f``, using binary exponentiation. We require ``e >= 0``. - # We require ``finv`` to be the inverse of the reverse of ``f``. - void _nmod_poly_powmod_fmpz_binexp_preinv (mp_ptr res, mp_srcptr poly, fmpz_t e, mp_srcptr f, slong lenf, mp_srcptr finv, slong lenfinv, nmod_t mod) noexcept - # Sets ``res`` to ``poly`` raised to the power ``e`` - # modulo ``f``, using binary exponentiation. We require ``e > 0``. - # We require ``finv`` to be the inverse of the reverse of ``f``. - # We require ``lenf > 1``. It is assumed that ``poly`` is already - # reduced modulo ``f`` and zero-padded as necessary to have length - # exactly ``lenf - 1``. The output ``res`` must have room for - # ``lenf - 1`` coefficients. - void nmod_poly_powmod_fmpz_binexp_preinv(nmod_poly_t res, const nmod_poly_t poly, fmpz_t e, const nmod_poly_t f, const nmod_poly_t finv) noexcept - # Sets ``res`` to ``poly`` raised to the power ``e`` - # modulo ``f``, using binary exponentiation. We require ``e >= 0``. - # We require ``finv`` to be the inverse of the reverse of ``f``. - void _nmod_poly_powmod_x_ui_preinv (mp_ptr res, ulong e, mp_srcptr f, slong lenf, mp_srcptr finv, slong lenfinv, nmod_t mod) noexcept - # Sets ``res`` to ``x`` raised to the power ``e`` modulo ``f``, - # using sliding window exponentiation. We require ``e > 0``. - # We require ``finv`` to be the inverse of the reverse of ``f``. - # We require ``lenf > 2``. The output ``res`` must have room for - # ``lenf - 1`` coefficients. - void nmod_poly_powmod_x_ui_preinv(nmod_poly_t res, ulong e, const nmod_poly_t f, const nmod_poly_t finv) noexcept - # Sets ``res`` to ``x`` raised to the power ``e`` - # modulo ``f``, using sliding window exponentiation. We require - # ``e >= 0``. We require ``finv`` to be the inverse of the reverse of - # ``f``. - void _nmod_poly_powmod_x_fmpz_preinv (mp_ptr res, fmpz_t e, mp_srcptr f, slong lenf, mp_srcptr finv, slong lenfinv, nmod_t mod) noexcept - # Sets ``res`` to ``x`` raised to the power ``e`` modulo ``f``, - # using sliding window exponentiation. We require ``e > 0``. - # We require ``finv`` to be the inverse of the reverse of ``f``. - # We require ``lenf > 2``. The output ``res`` must have room for - # ``lenf - 1`` coefficients. - void nmod_poly_powmod_x_fmpz_preinv(nmod_poly_t res, fmpz_t e, const nmod_poly_t f, const nmod_poly_t finv) noexcept - # Sets ``res`` to ``x`` raised to the power ``e`` - # modulo ``f``, using sliding window exponentiation. We require - # ``e >= 0``. We require ``finv`` to be the inverse of the reverse of - # ``f``. - void _nmod_poly_powers_mod_preinv_naive(mp_ptr * res, mp_srcptr f, slong flen, slong n, mp_srcptr g, slong glen, mp_srcptr ginv, slong ginvlen, const nmod_t mod) noexcept - # Compute ``f^0, f^1, ..., f^(n-1) mod g``, where ``g`` has length ``glen`` - # and ``f`` is reduced mod ``g`` and has length ``flen`` (possibly zero - # spaced). Assumes ``res`` is an array of ``n`` arrays each with space for - # at least ``glen - 1`` coefficients and that ``flen > 0``. We require that - # ``ginv`` of length ``ginvlen`` is set to the power series inverse of the - # reverse of ``g``. - void nmod_poly_powers_mod_naive(nmod_poly_struct * res, const nmod_poly_t f, slong n, const nmod_poly_t g) noexcept - # Set the entries of the array ``res`` to ``f^0, f^1, ..., f^(n-1) mod g``. - # No aliasing is permitted between the entries of ``res`` and either of the - # inputs. - void _nmod_poly_powers_mod_preinv_threaded_pool(mp_ptr * res, mp_srcptr f, slong flen, slong n, mp_srcptr g, slong glen, mp_srcptr ginv, slong ginvlen, const nmod_t mod, thread_pool_handle * threads, slong num_threads) noexcept - # Compute ``f^0, f^1, ..., f^(n-1) mod g``, where ``g`` has length ``glen`` - # and ``f`` is reduced mod ``g`` and has length ``flen`` (possibly zero - # spaced). Assumes ``res`` is an array of ``n`` arrays each with space for - # at least ``glen - 1`` coefficients and that ``flen > 0``. We require that - # ``ginv`` of length ``ginvlen`` is set to the power series inverse of the - # reverse of ``g``. - void _nmod_poly_powers_mod_preinv_threaded(mp_ptr * res, mp_srcptr f, slong flen, slong n, mp_srcptr g, slong glen, mp_srcptr ginv, slong ginvlen, const nmod_t mod) noexcept - # Compute ``f^0, f^1, ..., f^(n-1) mod g``, where ``g`` has length ``glen`` - # and ``f`` is reduced mod ``g`` and has length ``flen`` (possibly zero - # spaced). Assumes ``res`` is an array of ``n`` arrays each with space for - # at least ``glen - 1`` coefficients and that ``flen > 0``. We require that - # ``ginv`` of length ``ginvlen`` is set to the power series inverse of the - # reverse of ``g``. - void nmod_poly_powers_mod_bsgs(nmod_poly_struct * res, const nmod_poly_t f, slong n, const nmod_poly_t g) noexcept - # Set the entries of the array ``res`` to ``f^0, f^1, ..., f^(n-1) mod g``. - # No aliasing is permitted between the entries of ``res`` and either of the - # inputs. - void _nmod_poly_divrem_basecase(mp_ptr Q, mp_ptr R, mp_srcptr A, slong A_len, mp_srcptr B, slong B_len, nmod_t mod) noexcept - # Finds `Q` and `R` such that `A = B Q + R` with `\operatorname{len}(R) < \operatorname{len}(B)`. - # If `\operatorname{len}(B) = 0` an exception is raised. We require that ``W`` - # is temporary space of ``NMOD_DIVREM_BC_ITCH(A_len, B_len, mod)`` - # coefficients. - void nmod_poly_divrem_basecase(nmod_poly_t Q, nmod_poly_t R, const nmod_poly_t A, const nmod_poly_t B) noexcept - # Finds `Q` and `R` such that `A = B Q + R` with `\operatorname{len}(R) < \operatorname{len}(B)`. - # If `\operatorname{len}(B) = 0` an exception is raised. - void _nmod_poly_divrem(mp_ptr Q, mp_ptr R, mp_srcptr A, slong lenA, mp_srcptr B, slong lenB, nmod_t mod) noexcept - # Computes `Q` and `R` such that `A = BQ + R` with `\operatorname{len}(R)` less than - # ``lenB``, where ``A`` is of length ``lenA`` and ``B`` is of - # length ``lenB``. We require that ``Q`` have space for - # ``lenA - lenB + 1`` coefficients. - void nmod_poly_divrem(nmod_poly_t Q, nmod_poly_t R, const nmod_poly_t A, const nmod_poly_t B) noexcept - # Computes `Q` and `R` such that `A = BQ + R` with `\operatorname{len}(R) < \operatorname{len}(B)`. - void _nmod_poly_div(mp_ptr Q, mp_srcptr A, slong lenA, mp_srcptr B, slong lenB, nmod_t mod) noexcept - # Notionally computes polynomials `Q` and `R` such that `A = BQ + R` with - # `\operatorname{len}(R)` less than ``lenB``, where ``A`` is of length ``lenA`` - # and ``B`` is of length ``lenB``, but returns only ``Q``. We - # require that ``Q`` have space for ``lenA - lenB + 1`` coefficients. - void nmod_poly_div(nmod_poly_t Q, const nmod_poly_t A, const nmod_poly_t B) noexcept - # Computes the quotient `Q` on polynomial division of `A` and `B`. - void _nmod_poly_rem_q1(mp_ptr R, mp_srcptr A, slong lenA, mp_srcptr B, slong lenB, nmod_t mod) noexcept - void _nmod_poly_rem(mp_ptr R, mp_srcptr A, slong lenA, mp_srcptr B, slong lenB, nmod_t mod) noexcept - # Computes the remainder `R` on polynomial division of `A` by `B`. - void nmod_poly_rem(nmod_poly_t R, const nmod_poly_t A, const nmod_poly_t B) noexcept - # Computes the remainder `R` on polynomial division of `A` by `B`. - void _nmod_poly_inv_series_basecase(mp_ptr Qinv, mp_srcptr Q, slong Qlen, slong n, nmod_t mod) noexcept - # Given ``Q`` of length ``Qlen`` whose leading coefficient is invertible - # modulo the given modulus, finds a polynomial ``Qinv`` of length ``n`` - # such that the top ``n`` coefficients of the product ``Q * Qinv`` is - # `x^{n - 1}`. Requires that ``n > 0``. This function can be viewed as - # inverting a power series. - void nmod_poly_inv_series_basecase(nmod_poly_t Qinv, const nmod_poly_t Q, slong n) noexcept - # Given ``Q`` of length at least ``n`` find ``Qinv`` of length - # ``n`` such that the top ``n`` coefficients of the product - # ``Q * Qinv`` is `x^{n - 1}`. An exception is raised if ``n = 0`` - # or if the length of ``Q`` is less than ``n``. The leading - # coefficient of ``Q`` must be invertible modulo the modulus of - # ``Q``. This function can be viewed as inverting a power series. - void _nmod_poly_inv_series_newton(mp_ptr Qinv, mp_srcptr Q, slong Qlen, slong n, nmod_t mod) noexcept - # Given ``Q`` of length ``Qlen`` whose constant coefficient is invertible - # modulo the given modulus, find a polynomial ``Qinv`` of length ``n`` - # such that ``Q * Qinv`` is ``1`` modulo `x^n`. Requires ``n > 0``. - # This function can be viewed as inverting a power series via Newton - # iteration. - void nmod_poly_inv_series_newton(nmod_poly_t Qinv, const nmod_poly_t Q, slong n) noexcept - # Given ``Q`` find ``Qinv`` such that ``Q * Qinv`` is ``1`` - # modulo `x^n`. The constant coefficient of ``Q`` must be invertible - # modulo the modulus of ``Q``. An exception is raised if this is not - # the case or if ``n = 0``. This function can be viewed as inverting - # a power series via Newton iteration. - void _nmod_poly_inv_series(mp_ptr Qinv, mp_srcptr Q, slong Qlen, slong n, nmod_t mod) noexcept - # Given ``Q`` of length ``Qlenn`` whose constant coefficient is invertible - # modulo the given modulus, find a polynomial ``Qinv`` of length ``n`` - # such that ``Q * Qinv`` is ``1`` modulo `x^n`. Requires ``n > 0``. - # This function can be viewed as inverting a power series. - void nmod_poly_inv_series(nmod_poly_t Qinv, const nmod_poly_t Q, slong n) noexcept - # Given ``Q`` find ``Qinv`` such that ``Q * Qinv`` is ``1`` - # modulo `x^n`. The constant coefficient of ``Q`` must be invertible - # modulo the modulus of ``Q``. An exception is raised if this is not - # the case or if ``n = 0``. This function can be viewed as inverting - # a power series. - void _nmod_poly_div_series_basecase(mp_ptr Q, mp_srcptr A, slong Alen, mp_srcptr B, slong Blen, slong n, nmod_t mod) noexcept - # Given polynomials ``A`` and ``B`` of length ``Alen`` and - # ``Blen``, finds the - # polynomial ``Q`` of length ``n`` such that ``Q * B = A`` - # modulo `x^n`. We assume ``n > 0`` and that the constant coefficient - # of ``B`` is invertible modulo the given modulus. The polynomial - # ``Q`` must have space for ``n`` coefficients. - void nmod_poly_div_series_basecase(nmod_poly_t Q, const nmod_poly_t A, const nmod_poly_t B, slong n) noexcept - # Given polynomials ``A`` and ``B`` considered modulo ``n``, - # finds the polynomial ``Q`` of length at most ``n`` such that - # ``Q * B = A`` modulo `x^n`. We assume ``n > 0`` and that the - # constant coefficient of ``B`` is invertible modulo the modulus. - # An exception is raised if ``n == 0`` or the constant coefficient - # of ``B`` is zero. - void _nmod_poly_div_series(mp_ptr Q, mp_srcptr A, slong Alen, mp_srcptr B, slong Blen, slong n, nmod_t mod) noexcept - # Given polynomials ``A`` and ``B`` of length ``Alen`` and - # ``Blen``, finds the - # polynomial ``Q`` of length ``n`` such that ``Q * B = A`` - # modulo `x^n`. We assume ``n > 0`` and that the constant coefficient - # of ``B`` is invertible modulo the given modulus. The polynomial - # ``Q`` must have space for ``n`` coefficients. - void nmod_poly_div_series(nmod_poly_t Q, const nmod_poly_t A, const nmod_poly_t B, slong n) noexcept - # Given polynomials ``A`` and ``B`` considered modulo ``n``, - # finds the polynomial ``Q`` of length at most ``n`` such that - # ``Q * B = A`` modulo `x^n`. We assume ``n > 0`` and that the - # constant coefficient of ``B`` is invertible modulo the modulus. - # An exception is raised if ``n == 0`` or the constant coefficient - # of ``B`` is zero. - void _nmod_poly_div_newton_n_preinv (mp_ptr Q, mp_srcptr A, slong lenA, mp_srcptr B, slong lenB, mp_srcptr Binv, slong lenBinv, nmod_t mod) noexcept - # Notionally computes polynomials `Q` and `R` such that `A = BQ + R` with - # `\operatorname{len}(R)` less than ``lenB``, where ``A`` is of length ``lenA`` - # and ``B`` is of length ``lenB``, but return only `Q`. - # We require that `Q` have space for ``lenA - lenB + 1`` coefficients - # and assume that the leading coefficient of `B` is a unit. Furthermore, we - # assume that `Binv` is the inverse of the reverse of `B` mod `x^{\operatorname{len}(B)}`. - # The algorithm used is to reverse the polynomials and divide the - # resulting power series, then reverse the result. - void nmod_poly_div_newton_n_preinv (nmod_poly_t Q, const nmod_poly_t A, const nmod_poly_t B, const nmod_poly_t Binv) noexcept - # Notionally computes `Q` and `R` such that `A = BQ + R` with - # `\operatorname{len}(R) < \operatorname{len}(B)`, but returns only `Q`. - # We assume that the leading coefficient of `B` is a unit and that `Binv` is - # the inverse of the reverse of `B` mod `x^{\operatorname{len}(B)}`. - # It is required that the length of `A` is less than or equal to - # 2*the length of `B` - 2. - # The algorithm used is to reverse the polynomials and divide the - # resulting power series, then reverse the result. - void _nmod_poly_divrem_newton_n_preinv (mp_ptr Q, mp_ptr R, mp_srcptr A, slong lenA, mp_srcptr B, slong lenB, mp_srcptr Binv, slong lenBinv, nmod_t mod) noexcept - # Computes `Q` and `R` such that `A = BQ + R` with `\operatorname{len}(R)` less than - # ``lenB``, where `A` is of length ``lenA`` and `B` is of length - # ``lenB``. We require that `Q` have space for ``lenA - lenB + 1`` - # coefficients. Furthermore, we assume that `Binv` is the inverse of the - # reverse of `B` mod `x^{\operatorname{len}(B)}`. The algorithm used is to call - # :func:`div_newton_n_preinv` and then multiply out and compute - # the remainder. - void nmod_poly_divrem_newton_n_preinv(nmod_poly_t Q, nmod_poly_t R, const nmod_poly_t A, const nmod_poly_t B, const nmod_poly_t Binv) noexcept - # Computes `Q` and `R` such that `A = BQ + R` with `\operatorname{len}(R) < \operatorname{len}(B)`. - # We assume `Binv` is the inverse of the reverse of `B` mod `x^{\operatorname{len}(B)}`. - # It is required that the length of `A` is less than or equal to - # 2*the length of `B` - 2. - # The algorithm used is to call :func:`div_newton_n` and then multiply out - # and compute the remainder. - mp_limb_t _nmod_poly_div_root(mp_ptr Q, mp_srcptr A, slong len, mp_limb_t c, nmod_t mod) noexcept - # Sets ``(Q, len-1)`` to the quotient of ``(A, len)`` on division - # by `(x - c)`, and returns the remainder, equal to the value of `A` - # evaluated at `c`. `A` and `Q` are allowed to be the same, but may - # not overlap partially in any other way. - mp_limb_t nmod_poly_div_root(nmod_poly_t Q, const nmod_poly_t A, mp_limb_t c) noexcept - # Sets `Q` to the quotient of `A` on division by `(x - c)`, and returns - # the remainder, equal to the value of `A` evaluated at `c`. - int _nmod_poly_divides_classical(mp_ptr Q, mp_srcptr A, slong lenA, mp_srcptr B, slong lenB, nmod_t mod) noexcept - # Returns `1` if `(B, lenB)` divides `(A, lenA)` and sets - # `(Q, lenA - lenB + 1)` to the quotient. Otherwise, returns `0` and sets - # `(Q, lenA - lenB + 1)` to zero. We require that `lenA >= lenB > 0`. - int nmod_poly_divides_classical(nmod_poly_t Q, const nmod_poly_t A, const nmod_poly_t B) noexcept - # Returns `1` if `B` divides `A` and sets `Q` to the quotient. Otherwise - # returns `0` and sets `Q` to zero. - int _nmod_poly_divides(mp_ptr Q, mp_srcptr A, slong lenA, mp_srcptr B, slong lenB, nmod_t mod) noexcept - # Returns `1` if `(B, lenB)` divides `(A, lenA)` and sets - # `(Q, lenA - lenB + 1)` to the quotient. Otherwise, returns `0` and sets - # `(Q, lenA - lenB + 1)` to zero. We require that `lenA >= lenB > 0`. - int nmod_poly_divides(nmod_poly_t Q, const nmod_poly_t A, const nmod_poly_t B) noexcept - # Returns `1` if `B` divides `A` and sets `Q` to the quotient. Otherwise - # returns `0` and sets `Q` to zero. - + ulong nmod_poly_remove(nmod_poly_t f, const nmod_poly_t p) noexcept void _nmod_poly_derivative(mp_ptr x_prime, mp_srcptr x, slong len, nmod_t mod) noexcept - # Sets the first ``len - 1`` coefficients of ``x_prime`` to the - # derivative of ``x`` which is assumed to be of length ``len``. - # It is assumed that ``len > 0``. - void nmod_poly_derivative(nmod_poly_t x_prime, const nmod_poly_t x) noexcept - # Sets ``x_prime`` to the derivative of ``x``. - void _nmod_poly_integral(mp_ptr x_int, mp_srcptr x, slong len, nmod_t mod) noexcept - # Set the first ``len`` coefficients of ``x_int`` to the - # integral of ``x`` which is assumed to be of length ``len - 1``. - # The constant term of ``x_int`` is set to zero. - # It is assumed that ``len > 0``. The result is only well-defined - # if the modulus is a prime number strictly larger than the degree of - # ``x``. Supports aliasing between the two polynomials. - void nmod_poly_integral(nmod_poly_t x_int, const nmod_poly_t x) noexcept - # Set ``x_int`` to the indefinite integral of ``x`` with constant - # term zero. The result is only well-defined if the modulus - # is a prime number strictly larger than the degree of ``x``. - mp_limb_t _nmod_poly_evaluate_nmod(mp_srcptr poly, slong len, mp_limb_t c, nmod_t mod) noexcept - # Evaluates ``poly`` at the value ``c`` and reduces modulo the - # given modulus of ``poly``. The value ``c`` should be reduced - # modulo the modulus. The algorithm used is Horner's method. - mp_limb_t nmod_poly_evaluate_nmod(const nmod_poly_t poly, mp_limb_t c) noexcept - # Evaluates ``poly`` at the value ``c`` and reduces modulo the - # modulus of ``poly``. The value ``c`` should be reduced modulo - # the modulus. The algorithm used is Horner's method. - void nmod_poly_evaluate_mat_horner(nmod_mat_t dest, const nmod_poly_t poly, const nmod_mat_t c) noexcept - # Evaluates ``poly`` with matrix as an argument at the value ``c`` - # and stores the result in ``dest``. The dimension and modulus of - # ``dest`` is assumed to be same as that of ``c``. ``dest`` and - # ``c`` may be aliased. Horner's Method is used to compute the result. - void nmod_poly_evaluate_mat_paterson_stockmeyer(nmod_mat_t dest, const nmod_poly_t poly, const nmod_mat_t c) noexcept - # Evaluates ``poly`` with matrix as an argument at the value ``c`` - # and stores the result in ``dest``. The dimension and modulus of - # ``dest`` is assumed to be same as that of ``c``. ``dest`` and - # ``c`` may be aliased. Paterson-Stockmeyer algorithm is used to compute - # the result. The algorithm is described in [Paterson1973]_. - void nmod_poly_evaluate_mat(nmod_mat_t dest, const nmod_poly_t poly, const nmod_mat_t c) noexcept - # Evaluates ``poly`` with matrix as an argument at the value ``c`` - # and stores the result in ``dest``. The dimension and modulus of - # ``dest`` is assumed to be same as that of ``c``. ``dest`` and - # ``c`` may be aliased. This function automatically switches between - # Horner's method and the Paterson-Stockmeyer algorithm. - void _nmod_poly_evaluate_nmod_vec_iter(mp_ptr ys, mp_srcptr poly, slong len, mp_srcptr xs, slong n, nmod_t mod) noexcept - # Evaluates (``coeffs``, ``len``) at the ``n`` values - # given in the vector ``xs``, writing the output values - # to ``ys``. The values in ``xs`` should be reduced - # modulo the modulus. - # Uses Horner's method iteratively. - void nmod_poly_evaluate_nmod_vec_iter(mp_ptr ys, const nmod_poly_t poly, mp_srcptr xs, slong n) noexcept - # Evaluates ``poly`` at the ``n`` values given in the vector - # ``xs``, writing the output values to ``ys``. The values in - # ``xs`` should be reduced modulo the modulus. - # Uses Horner's method iteratively. - void _nmod_poly_evaluate_nmod_vec_fast_precomp(mp_ptr vs, mp_srcptr poly, slong plen, const mp_ptr * tree, slong len, nmod_t mod) noexcept - # Evaluates (``poly``, ``plen``) at the ``len`` values given - # by the precomputed subproduct tree ``tree``. - void _nmod_poly_evaluate_nmod_vec_fast(mp_ptr ys, mp_srcptr poly, slong len, mp_srcptr xs, slong n, nmod_t mod) noexcept - # Evaluates (``coeffs``, ``len``) at the ``n`` values - # given in the vector ``xs``, writing the output values - # to ``ys``. The values in ``xs`` should be reduced - # modulo the modulus. - # Uses fast multipoint evaluation, building a temporary subproduct tree. - void nmod_poly_evaluate_nmod_vec_fast(mp_ptr ys, const nmod_poly_t poly, mp_srcptr xs, slong n) noexcept - # Evaluates ``poly`` at the ``n`` values given in the vector - # ``xs``, writing the output values to ``ys``. The values in - # ``xs`` should be reduced modulo the modulus. - # Uses fast multipoint evaluation, building a temporary subproduct tree. - void _nmod_poly_evaluate_nmod_vec(mp_ptr ys, mp_srcptr poly, slong len, mp_srcptr xs, slong n, nmod_t mod) noexcept - # Evaluates (``poly``, ``len``) at the ``n`` values - # given in the vector ``xs``, writing the output values - # to ``ys``. The values in ``xs`` should be reduced - # modulo the modulus. - void nmod_poly_evaluate_nmod_vec(mp_ptr ys, const nmod_poly_t poly, mp_srcptr xs, slong n) noexcept - # Evaluates ``poly`` at the ``n`` values given in the vector - # ``xs``, writing the output values to ``ys``. The values in - # ``xs`` should be reduced modulo the modulus. - void _nmod_poly_interpolate_nmod_vec(mp_ptr poly, mp_srcptr xs, mp_srcptr ys, slong n, nmod_t mod) noexcept - # Sets ``poly`` to the unique polynomial of length at most ``n`` - # that interpolates the ``n`` given evaluation points ``xs`` and - # values ``ys``. If the interpolating polynomial is shorter than - # length ``n``, the leading coefficients are set to zero. - # The values in ``xs`` and ``ys`` should be reduced modulo the - # modulus, and all ``xs`` must be distinct. Aliasing between - # ``poly`` and ``xs`` or ``ys`` is not allowed. - void nmod_poly_interpolate_nmod_vec(nmod_poly_t poly, mp_srcptr xs, mp_srcptr ys, slong n) noexcept - # Sets ``poly`` to the unique polynomial of length ``n`` that - # interpolates the ``n`` given evaluation points ``xs`` and - # values ``ys``. The values in ``xs`` and ``ys`` should be - # reduced modulo the modulus, and all ``xs`` must be distinct. - void _nmod_poly_interpolation_weights(mp_ptr w, const mp_ptr * tree, slong len, nmod_t mod) noexcept - # Sets ``w`` to the barycentric interpolation weights for fast - # Lagrange interpolation with respect to a given subproduct tree. - void _nmod_poly_interpolate_nmod_vec_fast_precomp(mp_ptr poly, mp_srcptr ys, const mp_ptr * tree, mp_srcptr weights, slong len, nmod_t mod) noexcept - # Performs interpolation using the fast Lagrange interpolation - # algorithm, generating a temporary subproduct tree. - # The function values are given as ``ys``. The function takes - # a precomputed subproduct tree ``tree`` and barycentric - # interpolation weights ``weights`` corresponding to the - # roots. - void _nmod_poly_interpolate_nmod_vec_fast(mp_ptr poly, mp_srcptr xs, mp_srcptr ys, slong n, nmod_t mod) noexcept - # Performs interpolation using the fast Lagrange interpolation - # algorithm, generating a temporary subproduct tree. - void nmod_poly_interpolate_nmod_vec_fast(nmod_poly_t poly, mp_srcptr xs, mp_srcptr ys, slong n) noexcept - # Performs interpolation using the fast Lagrange interpolation algorithm, - # generating a temporary subproduct tree. - void _nmod_poly_interpolate_nmod_vec_newton(mp_ptr poly, mp_srcptr xs, mp_srcptr ys, slong n, nmod_t mod) noexcept - # Forms the interpolating polynomial in the Newton basis using - # the method of divided differences and then converts it to - # monomial form. - void nmod_poly_interpolate_nmod_vec_newton(nmod_poly_t poly, mp_srcptr xs, mp_srcptr ys, slong n) noexcept - # Forms the interpolating polynomial in the Newton basis using - # the method of divided differences and then converts it to - # monomial form. - void _nmod_poly_interpolate_nmod_vec_barycentric(mp_ptr poly, mp_srcptr xs, mp_srcptr ys, slong n, nmod_t mod) noexcept - # Forms the interpolating polynomial using a naive implementation - # of the barycentric form of Lagrange interpolation. - void nmod_poly_interpolate_nmod_vec_barycentric(nmod_poly_t poly, mp_srcptr xs, mp_srcptr ys, slong n) noexcept - # Forms the interpolating polynomial using a naive implementation - # of the barycentric form of Lagrange interpolation. - void _nmod_poly_compose_horner(mp_ptr res, mp_srcptr poly1, slong len1, mp_srcptr poly2, slong len2, nmod_t mod) noexcept - # Composes ``poly1`` of length ``len1`` with ``poly2`` of length - # ``len2`` and sets ``res`` to the result, i.e. evaluates - # ``poly1`` at ``poly2``. The algorithm used is Horner's algorithm. - # We require that ``res`` have space for ``(len1 - 1)*(len2 - 1) + 1`` - # coefficients. It is assumed that ``len1 > 0`` and ``len2 > 0``. - void nmod_poly_compose_horner(nmod_poly_t res, const nmod_poly_t poly1, const nmod_poly_t poly2) noexcept - # Composes ``poly1`` with ``poly2`` and sets ``res`` to the result, - # i.e. evaluates ``poly1`` at ``poly2``. The algorithm used is - # Horner's algorithm. - void _nmod_poly_compose_divconquer(mp_ptr res, mp_srcptr poly1, slong len1, mp_srcptr poly2, slong len2, nmod_t mod) noexcept - # Composes ``poly1`` of length ``len1`` with ``poly2`` of length - # ``len2`` and sets ``res`` to the result, i.e. evaluates - # ``poly1`` at ``poly2``. The algorithm used is the divide and - # conquer algorithm. We require that ``res`` have space for - # ``(len1 - 1)*(len2 - 1) + 1`` coefficients. It is assumed that - # ``len1 > 0`` and ``len2 > 0``. - void nmod_poly_compose_divconquer(nmod_poly_t res, const nmod_poly_t poly1, const nmod_poly_t poly2) noexcept - # Composes ``poly1`` with ``poly2`` and sets ``res`` to the result, - # i.e. evaluates ``poly1`` at ``poly2``. The algorithm used is - # the divide and conquer algorithm. - void _nmod_poly_compose(mp_ptr res, mp_srcptr poly1, slong len1, mp_srcptr poly2, slong len2, nmod_t mod) noexcept - # Composes ``poly1`` of length ``len1`` with ``poly2`` of length - # ``len2`` and sets ``res`` to the result, i.e. evaluates ``poly1`` - # at ``poly2``. We require that ``res`` have space for - # ``(len1 - 1)*(len2 - 1) + 1`` coefficients. It is assumed that - # ``len1 > 0`` and ``len2 > 0``. - void nmod_poly_compose(nmod_poly_t res, const nmod_poly_t poly1, const nmod_poly_t poly2) noexcept - # Composes ``poly1`` with ``poly2`` and sets ``res`` to the result, - # that is, evaluates ``poly1`` at ``poly2``. - void _nmod_poly_taylor_shift_horner(mp_ptr poly, mp_limb_t c, slong len, nmod_t mod) noexcept - # Performs the Taylor shift composing ``poly`` by `x+c` in-place. - # Uses an efficient version Horner's rule. - void nmod_poly_taylor_shift_horner(nmod_poly_t g, const nmod_poly_t f, mp_limb_t c) noexcept - # Performs the Taylor shift composing ``f`` by `x+c`. - void _nmod_poly_taylor_shift_convolution(mp_ptr poly, mp_limb_t c, slong len, nmod_t mod) noexcept - # Performs the Taylor shift composing ``poly`` by `x+c` in-place. - # Writes the composition as a single convolution with cost `O(M(n))`. - # We require that the modulus is a prime at least as large as the length. - void nmod_poly_taylor_shift_convolution(nmod_poly_t g, const nmod_poly_t f, mp_limb_t c) noexcept - # Performs the Taylor shift composing ``f`` by `x+c`. - # Writes the composition as a single convolution with cost `O(M(n))`. - # We require that the modulus is a prime at least as large as the length. - void _nmod_poly_taylor_shift(mp_ptr poly, mp_limb_t c, slong len, nmod_t mod) noexcept - # Performs the Taylor shift composing ``poly`` by `x+c` in-place. - # We require that the modulus is a prime. - void nmod_poly_taylor_shift(nmod_poly_t g, const nmod_poly_t f, mp_limb_t c) noexcept - # Performs the Taylor shift composing ``f`` by `x+c`. - # We require that the modulus is a prime. - void _nmod_poly_compose_mod_horner(mp_ptr res, mp_srcptr f, slong lenf, mp_srcptr g, mp_srcptr h, slong lenh, nmod_t mod) noexcept - # Sets ``res`` to the composition `f(g)` modulo `h`. We require that - # `h` is nonzero and that the length of `g` is one less than the - # length of `h` (possibly with zero padding). The output is not allowed - # to be aliased with any of the inputs. - # The algorithm used is Horner's rule. - void nmod_poly_compose_mod_horner(nmod_poly_t res, const nmod_poly_t f, const nmod_poly_t g, const nmod_poly_t h) noexcept - # Sets ``res`` to the composition `f(g)` modulo `h`. We require that - # `h` is nonzero. The algorithm used is Horner's rule. - void _nmod_poly_compose_mod_brent_kung(mp_ptr res, mp_srcptr f, slong lenf, mp_srcptr g, mp_srcptr h, slong lenh, nmod_t mod) noexcept - # Sets ``res`` to the composition `f(g)` modulo `h`. We require that - # `h` is nonzero and that the length of `g` is one less than the - # length of `h` (possibly with zero padding). We also require that - # the length of `f` is less than the length of `h`. The output is not allowed - # to be aliased with any of the inputs. - # The algorithm used is the Brent-Kung matrix algorithm. - void nmod_poly_compose_mod_brent_kung(nmod_poly_t res, const nmod_poly_t f, const nmod_poly_t g, const nmod_poly_t h) noexcept - # Sets ``res`` to the composition `f(g)` modulo `h`. We require that - # `h` is nonzero and that `f` has smaller degree than `h`. - # The algorithm used is the Brent-Kung matrix algorithm. - void _nmod_poly_compose_mod_brent_kung_preinv(mp_ptr res, mp_srcptr f, slong lenf, mp_srcptr g, mp_srcptr h, slong lenh, mp_srcptr hinv, slong lenhinv, nmod_t mod) noexcept - # Sets ``res`` to the composition `f(g)` modulo `h`. We require that - # `h` is nonzero and that the length of `g` is one less than the - # length of `h` (possibly with zero padding). We also require that - # the length of `f` is less than the length of `h`. Furthermore, we require - # ``hinv`` to be the inverse of the reverse of ``h``. - # The output is not allowed to be aliased with any of the inputs. - # The algorithm used is the Brent-Kung matrix algorithm. - void nmod_poly_compose_mod_brent_kung_preinv(nmod_poly_t res, const nmod_poly_t f, const nmod_poly_t g, const nmod_poly_t h, const nmod_poly_t hinv) noexcept - # Sets ``res`` to the composition `f(g)` modulo `h`. We require that - # `h` is nonzero and that `f` has smaller degree than `h`. Furthermore, - # we require ``hinv`` to be the inverse of the reverse of ``h``. - # The algorithm used is the Brent-Kung matrix algorithm. - void _nmod_poly_reduce_matrix_mod_poly (nmod_mat_t A, const nmod_mat_t B, const nmod_poly_t f) noexcept - # Sets the ith row of ``A`` to the reduction of the ith row of `B` modulo - # `f` for `i=1,\ldots,\sqrt{\deg(f)}`. We require `B` to be at least - # a `\sqrt{\deg(f)}\times \deg(f)` matrix and `f` to be nonzero. - void _nmod_poly_precompute_matrix_worker (void * arg_ptr) noexcept - # Worker function version of ``_nmod_poly_precompute_matrix``. - # Input/output is stored in ``nmod_poly_matrix_precompute_arg_t``. - void _nmod_poly_precompute_matrix (nmod_mat_t A, mp_srcptr f, mp_srcptr g, slong leng, mp_srcptr ginv, slong lenginv, nmod_t mod) noexcept - # Sets the ith row of ``A`` to `f^i` modulo `g` for - # `i=1,\ldots,\sqrt{\deg(g)}`. We require `A` to be - # a `\sqrt{\deg(g)}\times \deg(g)` matrix. We require - # ``ginv`` to be the inverse of the reverse of ``g`` and `g` to be - # nonzero. ``f`` has to be reduced modulo ``g`` and of length one less - # than ``leng`` (possibly with zero padding). - void nmod_poly_precompute_matrix (nmod_mat_t A, const nmod_poly_t f, const nmod_poly_t g, const nmod_poly_t ginv) noexcept - # Sets the ith row of ``A`` to `f^i` modulo `g` for - # `i=1,\ldots,\sqrt{\deg(g)}`. We require `A` to be - # a `\sqrt{\deg(g)}\times \deg(g)` matrix. We require - # ``ginv`` to be the inverse of the reverse of ``g``. - void _nmod_poly_compose_mod_brent_kung_precomp_preinv_worker(void * arg_ptr) noexcept - # Worker function version of - # ``_nmod_poly_compose_mod_brent_kung_precomp_preinv``. - # Input/output is stored in - # ``nmod_poly_compose_mod_precomp_preinv_arg_t``. - void _nmod_poly_compose_mod_brent_kung_precomp_preinv(mp_ptr res, mp_srcptr f, slong lenf, const nmod_mat_t A, mp_srcptr h, slong lenh, mp_srcptr hinv, slong lenhinv, nmod_t mod) noexcept - # Sets ``res`` to the composition `f(g)` modulo `h`. We require that - # `h` is nonzero. We require that the ith row of `A` contains `g^i` for - # `i=1,\ldots,\sqrt{\deg(h)}`, i.e. `A` is a - # `\sqrt{\deg(h)}\times \deg(h)` matrix. We also require that - # the length of `f` is less than the length of `h`. Furthermore, we require - # ``hinv`` to be the inverse of the reverse of ``h``. - # The output is not allowed to be aliased with any of the inputs. - # The algorithm used is the Brent-Kung matrix algorithm. - void nmod_poly_compose_mod_brent_kung_precomp_preinv(nmod_poly_t res, const nmod_poly_t f, const nmod_mat_t A, const nmod_poly_t h, const nmod_poly_t hinv) noexcept - # Sets ``res`` to the composition `f(g)` modulo `h`. We require that the - # ith row of `A` contains `g^i` for `i=1,\ldots,\sqrt{\deg(h)}`, i.e. `A` is a - # `\sqrt{\deg(h)}\times \deg(h)` matrix. We require that `h` is nonzero and - # that `f` has smaller degree than `h`. Furthermore, we require ``hinv`` to - # be the inverse of the reverse of ``h``. This version of Brent-Kung - # modular composition is particularly useful if one has to perform several - # modular composition of the form `f(g)` modulo `h` for fixed `g` and `h`. - void _nmod_poly_compose_mod_brent_kung_vec_preinv(nmod_poly_struct * res, const nmod_poly_struct * polys, slong len1, slong l, mp_srcptr g, slong leng, mp_srcptr h, slong lenh, mp_srcptr hinv, slong lenhinv, nmod_t mod) noexcept - # Sets ``res`` to the composition `f_i(g)` modulo `h` for `1\leq i \leq l`, - # where `f_i` are the first ``l`` elements of ``polys``. We require that `h` - # is nonzero and that the length of `g` is less than the length of `h`. We - # also require that the length of `f_i` is less than the length of `h`. We - # require ``res`` to have enough memory allocated to hold ``l`` - # ``nmod_poly_struct``'s. The entries of ``res`` need to be initialised and - # ``l`` needs to be less than ``len1`` Furthermore, we require ``hinv`` to - # be the inverse of the reverse of ``h``. The output is not allowed to be - # aliased with any of the inputs. - # The algorithm used is the Brent-Kung matrix algorithm. - void nmod_poly_compose_mod_brent_kung_vec_preinv(nmod_poly_struct * res, const nmod_poly_struct * polys, slong len1, slong n, const nmod_poly_t g, const nmod_poly_t h, const nmod_poly_t hinv) noexcept - # Sets ``res`` to the composition `f_i(g)` modulo `h` for `1\leq i \leq n` - # where `f_i` are the first ``n`` elements of ``polys``. We require ``res`` - # to have enough memory allocated to hold ``n`` ``nmod_poly_struct``. The - # entries of ``res`` need to be initialised and ``n`` needs to be less than - # ``len1``. We require that `h` is nonzero and that `f_i` and `g` have - # smaller degree than `h`. Furthermore, we require ``hinv`` to be the inverse - # of the reverse of ``h``. No aliasing of ``res`` and ``polys`` is allowed. - # The algorithm used is the Brent-Kung matrix algorithm. - void _nmod_poly_compose_mod_brent_kung_vec_preinv_threaded_pool(nmod_poly_struct * res, const nmod_poly_struct * polys, slong lenpolys, slong l, mp_srcptr g, slong glen, mp_srcptr poly, slong len, mp_srcptr polyinv, slong leninv, nmod_t mod, thread_pool_handle * threads, slong num_threads) noexcept - # Multithreaded version of - # :func:`_nmod_poly_compose_mod_brent_kung_vec_preinv`. Distributing the - # Horner evaluations across :func:`flint_get_num_threads` threads. - void nmod_poly_compose_mod_brent_kung_vec_preinv_threaded_pool(nmod_poly_struct * res, const nmod_poly_struct * polys, slong len1, slong n, const nmod_poly_t g, const nmod_poly_t poly, const nmod_poly_t polyinv, thread_pool_handle * threads, slong num_threads) noexcept - # Multithreaded version of - # :func:`nmod_poly_compose_mod_brent_kung_vec_preinv`. Distributing the - # Horner evaluations across :func:`flint_get_num_threads` threads. - void nmod_poly_compose_mod_brent_kung_vec_preinv_threaded(nmod_poly_struct * res, const nmod_poly_struct * polys, slong len1, slong n, const nmod_poly_t g, const nmod_poly_t poly, const nmod_poly_t polyinv) noexcept - # Multithreaded version of - # :func:`nmod_poly_compose_mod_brent_kung_vec_preinv`. Distributing the - # Horner evaluations across :func:`flint_get_num_threads` threads. - void _nmod_poly_compose_mod(mp_ptr res, mp_srcptr f, slong lenf, mp_srcptr g, mp_srcptr h, slong lenh, nmod_t mod) noexcept - # Sets ``res`` to the composition `f(g)` modulo `h`. We require that - # `h` is nonzero and that the length of `g` is one less than the - # length of `h` (possibly with zero padding). The output is not allowed - # to be aliased with any of the inputs. - void nmod_poly_compose_mod(nmod_poly_t res, const nmod_poly_t f, const nmod_poly_t g, const nmod_poly_t h) noexcept - # Sets ``res`` to the composition `f(g)` modulo `h`. We require that - # `h` is nonzero. - slong _nmod_poly_gcd_euclidean(mp_ptr G, mp_srcptr A, slong lenA, mp_srcptr B, slong lenB, nmod_t mod) noexcept - # Computes the GCD of `A` of length ``lenA`` and `B` of length - # ``lenB``, where ``lenA >= lenB > 0``. The length of the GCD `G` - # is returned by the function. No attempt is made to make the GCD monic. It - # is required that `G` have space for ``lenB`` coefficients. - void nmod_poly_gcd_euclidean(nmod_poly_t G, const nmod_poly_t A, const nmod_poly_t B) noexcept - # Computes the GCD of `A` and `B`. The GCD of zero polynomials is - # defined to be zero, whereas the GCD of the zero polynomial and some other - # polynomial `P` is defined to be `P`. Except in the case where - # the GCD is zero, the GCD `G` is made monic. - - slong _nmod_poly_hgcd(mp_ptr *M, slong *lenM, mp_ptr A, slong *lenA, mp_ptr B, slong *lenB, mp_srcptr a, slong lena, mp_srcptr b, slong lenb, nmod_t mod) noexcept - # Computes the HGCD of `a` and `b`, that is, a matrix `M`, a sign `\sigma` - # and two polynomials `A` and `B` such that - # .. math :: - # (A,B)^t = M^{-1} (a,b)^t, \sigma = \det(M), - # and `A` and `B` are consecutive remainders in the Euclidean remainder - # sequence for the division of `a` by `b` satisfying \deg(A) \ge \frac{\deg(a)}{2} > \deg(B). - # Furthermore, `M` will be the product of ``[[q 1][1 0]]`` for the quotients ``q`` generated by such a remainder sequence. - # Assumes that `\operatorname{len}(a) > \operatorname{len}(b) > 0`, i.e. `\deg(a) > `deg(b) > 1`. - # Assumes that `A` and `B` have space of size at least `\operatorname{len}(a)` - # and `\operatorname{len}(b)`, respectively. On exit, ``*lenA`` and ``*lenB`` - # will contain the correct lengths of `A` and `B`. - # Assumes that ``M[0]``, ``M[1]``, ``M[2]``, and ``M[3]`` - # each point to a vector of size at least `\operatorname{len}(a)`. - + slong _nmod_poly_hgcd(mp_ptr * M, slong * lenM, mp_ptr A, slong * lenA, mp_ptr B, slong * lenB, mp_srcptr a, slong lena, mp_srcptr b, slong lenb, nmod_t mod) noexcept slong _nmod_poly_gcd_hgcd(mp_ptr G, mp_srcptr A, slong lenA, mp_srcptr B, slong lenB, nmod_t mod) noexcept - # Computes the monic GCD of `A` and `B`, assuming that - # `\operatorname{len}(A) \geq \operatorname{len}(B) > 0`. - # Assumes that `G` has space for `\operatorname{len}(B)` coefficients and - # returns the length of `G` on output. - void nmod_poly_gcd_hgcd(nmod_poly_t G, const nmod_poly_t A, const nmod_poly_t B) noexcept - # Computes the monic GCD of `A` and `B` using the HGCD algorithm. - # As a special case, the GCD of two zero polynomials is defined to be - # the zero polynomial. - # The time complexity of the algorithm is `\mathcal{O}(n \log^2 n)`. - # For further details, see [ThullYap1990]_. - slong _nmod_poly_gcd(mp_ptr G, mp_srcptr A, slong lenA, mp_srcptr B, slong lenB, nmod_t mod) noexcept - # Computes the GCD of `A` of length ``lenA`` and `B` of length - # ``lenB``, where ``lenA >= lenB > 0``. The length of the GCD `G` - # is returned by the function. No attempt is made to make the GCD monic. It - # is required that `G` have space for ``lenB`` coefficients. - void nmod_poly_gcd(nmod_poly_t G, const nmod_poly_t A, const nmod_poly_t B) noexcept - # Computes the GCD of `A` and `B`. The GCD of zero polynomials is - # defined to be zero, whereas the GCD of the zero polynomial and some other - # polynomial `P` is defined to be `P`. Except in the case where - # the GCD is zero, the GCD `G` is made monic. - slong _nmod_poly_xgcd_euclidean(mp_ptr G, mp_ptr S, mp_ptr T, mp_srcptr A, slong A_len, mp_srcptr B, slong B_len, nmod_t mod) noexcept - # Computes the GCD of `A` and `B` together with cofactors `S` and `T` - # such that `S A + T B = G`. Returns the length of `G`. - # Assumes that `\operatorname{len}(A) \geq \operatorname{len}(B) \geq 1` and - # `(\operatorname{len}(A),\operatorname{len}(B)) \neq (1,1)`. - # No attempt is made to make the GCD monic. - # Requires that `G` have space for `\operatorname{len}(B)` coefficients. Writes - # `\operatorname{len}(B)-1` and `\operatorname{len}(A)-1` coefficients to `S` and `T`, respectively. - # Note that, in fact, `\operatorname{len}(S) \leq \max(\operatorname{len}(B) - \operatorname{len}(G), 1)` and - # `\operatorname{len}(T) \leq \max(\operatorname{len}(A) - \operatorname{len}(G), 1)`. - # No aliasing of input and output operands is permitted. - void nmod_poly_xgcd_euclidean(nmod_poly_t G, nmod_poly_t S, nmod_poly_t T, const nmod_poly_t A, const nmod_poly_t B) noexcept - # Computes the GCD of `A` and `B`. The GCD of zero polynomials is - # defined to be zero, whereas the GCD of the zero polynomial and some other - # polynomial `P` is defined to be `P`. Except in the case where - # the GCD is zero, the GCD `G` is made monic. - # Polynomials ``S`` and ``T`` are computed such that - # ``S*A + T*B = G``. The length of ``S`` will be at most - # ``lenB`` and the length of ``T`` will be at most ``lenA``. - slong _nmod_poly_xgcd_hgcd(mp_ptr G, mp_ptr S, mp_ptr T, mp_srcptr A, slong A_len, mp_srcptr B, slong B_len, nmod_t mod) noexcept - # Computes the GCD of `A` and `B`, where `\operatorname{len}(A) \geq \operatorname{len}(B) > 0`, - # together with cofactors `S` and `T` such that `S A + T B = G`. Returns - # the length of `G`. - # No attempt is made to make the GCD monic. - # Requires that `G` have space for `\operatorname{len}(B)` coefficients. Writes - # `\operatorname{len}(B) - 1` and `\operatorname{len}(A) - 1` coefficients to `S` and `T`, - # respectively. Note that, in fact, `\operatorname{len}(S) \leq \operatorname{len}(B) - \operatorname{len}(G)` - # and `\operatorname{len}(T) \leq \operatorname{len}(A) - \operatorname{len}(G)`. - # Both `S` and `T` must have space for at least `2` coefficients. - # No aliasing of input and output operands is permitted. - void nmod_poly_xgcd_hgcd(nmod_poly_t G, nmod_poly_t S, nmod_poly_t T, const nmod_poly_t A, const nmod_poly_t B) noexcept - # Computes the GCD of `A` and `B`. The GCD of zero polynomials is - # defined to be zero, whereas the GCD of the zero polynomial and some other - # polynomial `P` is defined to be `P`. Except in the case where - # the GCD is zero, the GCD `G` is made monic. - # Polynomials ``S`` and ``T`` are computed such that - # ``S*A + T*B = G``. The length of ``S`` will be at most - # ``lenB`` and the length of ``T`` will be at most ``lenA``. - slong _nmod_poly_xgcd(mp_ptr G, mp_ptr S, mp_ptr T, mp_srcptr A, slong lenA, mp_srcptr B, slong lenB, nmod_t mod) noexcept - # Computes the GCD of `A` and `B`, where `\operatorname{len}(A) \geq \operatorname{len}(B) > 0`, - # together with cofactors `S` and `T` such that `S A + T B = G`. Returns - # the length of `G`. - # No attempt is made to make the GCD monic. - # Requires that `G` have space for `\operatorname{len}(B)` coefficients. Writes - # `\operatorname{len}(B) - 1` and `\operatorname{len}(A) - 1` coefficients to `S` and `T`, - # respectively. Note that, in fact, `\operatorname{len}(S) \leq \operatorname{len}(B) - \operatorname{len}(G)` - # and `\operatorname{len}(T) \leq \operatorname{len}(A) - \operatorname{len}(G)`. - # No aliasing of input and output operands is permitted. - void nmod_poly_xgcd(nmod_poly_t G, nmod_poly_t S, nmod_poly_t T, const nmod_poly_t A, const nmod_poly_t B) noexcept - # Computes the GCD of `A` and `B`. The GCD of zero polynomials is - # defined to be zero, whereas the GCD of the zero polynomial and some other - # polynomial `P` is defined to be `P`. Except in the case where - # the GCD is zero, the GCD `G` is made monic. - # The polynomials ``S`` and ``T`` are set such that - # ``S*A + T*B = G``. The length of ``S`` will be at most - # ``lenB`` and the length of ``T`` will be at most ``lenA``. - mp_limb_t _nmod_poly_resultant_euclidean(mp_srcptr poly1, slong len1, mp_srcptr poly2, slong len2, nmod_t mod) noexcept - # Returns the resultant of ``(poly1, len1)`` and - # ``(poly2, len2)`` using the Euclidean algorithm. - # Assumes that ``len1 >= len2 > 0``. - # Assumes that the modulus is prime. - mp_limb_t nmod_poly_resultant_euclidean(const nmod_poly_t f, const nmod_poly_t g) noexcept - # Computes the resultant of `f` and `g` using the Euclidean algorithm. - # For two non-zero polynomials `f(x) = a_m x^m + \dotsb + a_0` and - # `g(x) = b_n x^n + \dotsb + b_0` of degrees `m` and `n`, the resultant - # is defined to be - # .. math :: - # a_m^n b_n^m \prod_{(x, y) : f(x) = g(y) = 0} (x - y). - # For convenience, we define the resultant to be equal to zero if either - # of the two polynomials is zero. - mp_limb_t _nmod_poly_resultant_hgcd(mp_srcptr poly1, slong len1, mp_srcptr poly2, slong len2, nmod_t mod) noexcept - # Returns the resultant of ``(poly1, len1)`` and - # ``(poly2, len2)`` using the half-gcd algorithm. - # This algorithm computes the half-gcd as per :func:`_nmod_poly_gcd_hgcd` - # but additionally updates the resultant every time a division occurs. The - # half-gcd algorithm computes the GCD recursively. Given inputs `a` and `b` - # it lets ``m = len(a)/2`` and (recursively) performs all quotients in - # the Euclidean algorithm which do not require the low `m` coefficients of - # `a` and `b`. - # This performs quotients in exactly the same order as the ordinary - # Euclidean algorithm except that the low `m` coefficients of the polynomials - # in the remainder sequence are not computed. A correction step after hgcd - # has been called computes these low `m` coefficients (by matrix - # multiplication by a transformation matrix also computed by hgcd). - # This means that from the point of view of the resultant, all but the last - # quotient performed by a recursive call to hgcd is an ordinary quotient as - # per the usual Euclidean algorithm. However, the final quotient may give - # a remainder of less than `m + 1` coefficients, which won't be corrected - # until the hgcd correction step is performed afterwards. - # To compute the adjustments to the resultant coming from this corrected - # quotient, we save the relevant information in an :type:`nmod_poly_res_t` - # struct at the time the quotient is performed so that when the correction - # step is performed later, the adjustments to the resultant can be computed - # at that time also. - # The only time an adjustment to the resultant is not required after a - # call to hgcd is if hgcd does nothing (the remainder may already have had - # less than `m + 1` coefficients when hgcd was called). - # Assumes that ``len1 >= len2 > 0``. - # Assumes that the modulus is prime. - mp_limb_t nmod_poly_resultant_hgcd(const nmod_poly_t f, const nmod_poly_t g) noexcept - # Computes the resultant of `f` and `g` using the half-gcd algorithm. - # For two non-zero polynomials `f(x) = a_m x^m + \dotsb + a_0` and - # `g(x) = b_n x^n + \dotsb + b_0` of degrees `m` and `n`, the resultant - # is defined to be - # .. math :: - # a_m^n b_n^m \prod_{(x, y) : f(x) = g(y) = 0} (x - y). - # For convenience, we define the resultant to be equal to zero if either - # of the two polynomials is zero. - mp_limb_t _nmod_poly_resultant(mp_srcptr poly1, slong len1, mp_srcptr poly2, slong len2, nmod_t mod) noexcept - # Returns the resultant of ``(poly1, len1)`` and - # ``(poly2, len2)``. - # Assumes that ``len1 >= len2 > 0``. - # Assumes that the modulus is prime. - mp_limb_t nmod_poly_resultant(const nmod_poly_t f, const nmod_poly_t g) noexcept - # Computes the resultant of `f` and `g`. - # For two non-zero polynomials `f(x) = a_m x^m + \dotsb + a_0` and - # `g(x) = b_n x^n + \dotsb + b_0` of degrees `m` and `n`, the resultant - # is defined to be - # .. math :: - # a_m^n b_n^m \prod_{(x, y) : f(x) = g(y) = 0} (x - y). - # For convenience, we define the resultant to be equal to zero if either - # of the two polynomials is zero. - - slong _nmod_poly_gcdinv(mp_limb_t *G, mp_limb_t *S, const mp_limb_t *A, slong lenA, const mp_limb_t *B, slong lenB, const nmod_t mod) noexcept - # Computes ``(G, lenA)``, ``(S, lenB-1)`` such that - # `G \cong S A \pmod{B}`, returning the actual length of `G`. - # Assumes that `0 < \operatorname{len}(A) < \operatorname{len}(B)`. - + slong _nmod_poly_gcdinv(mp_limb_t * G, mp_limb_t * S, const mp_limb_t * A, slong lenA, const mp_limb_t * B, slong lenB, const nmod_t mod) noexcept void nmod_poly_gcdinv(nmod_poly_t G, nmod_poly_t S, const nmod_poly_t A, const nmod_poly_t B) noexcept - # Computes polynomials `G` and `S`, both reduced modulo `B`, - # such that `G \cong S A \pmod{B}`, where `B` is assumed to - # have `\operatorname{len}(B) \geq 2`. - # In the case that `A = 0 \pmod{B}`, returns `G = S = 0`. - - int _nmod_poly_invmod(mp_limb_t *A, const mp_limb_t *B, slong lenB, const mp_limb_t *P, slong lenP, const nmod_t mod) noexcept - # Attempts to set ``(A, lenP-1)`` to the inverse of ``(B, lenB)`` - # modulo the polynomial ``(P, lenP)``. Returns `1` if ``(B, lenB)`` - # is invertible and `0` otherwise. - # Assumes that `0 < \operatorname{len}(B) < \operatorname{len}(P)`, and hence also `\operatorname{len}(P) \geq 2`, - # but supports zero-padding in ``(B, lenB)``. - # Does not support aliasing. - # Assumes that `mod` is a prime number. - + int _nmod_poly_invmod(mp_limb_t * A, const mp_limb_t * B, slong lenB, const mp_limb_t * P, slong lenP, const nmod_t mod) noexcept int nmod_poly_invmod(nmod_poly_t A, const nmod_poly_t B, const nmod_poly_t P) noexcept - # Attempts to set `A` to the inverse of `B` modulo `P` in the polynomial - # ring `(\mathbf{Z}/p\mathbf{Z})[X]`, where we assume that `p` is a prime - # number. - # If `\operatorname{len}(P) < 2`, raises an exception. - # If the greatest common divisor of `B` and `P` is `1`, returns `1` and - # sets `A` to the inverse of `B`. Otherwise, returns `0` and the value - # of `A` on exit is undefined. - mp_limb_t _nmod_poly_discriminant(mp_srcptr poly, slong len, nmod_t mod) noexcept - # Return the discriminant of ``(poly, len)``. Assumes ``len > 1``. - mp_limb_t nmod_poly_discriminant(const nmod_poly_t f) noexcept - # Return the discriminant of `f`. - # We normalise the discriminant so that - # `\operatorname{disc}(f) = (-1)^{n(n-1)/2} \operatorname{res}(f, f') / - # \operatorname{lc}(f)^{n - m - 2}`, where ``n = len(f)`` and - # ``m = len(f')``. Thus `\operatorname{disc}(f) = - # \operatorname{lc}(f)^{2n - 2} \prod_{i < j} (r_i - r_j)^2`, where - # `\operatorname{lc}(f)` is the leading coefficient of `f` and `r_i` are the - # roots of `f`. - void _nmod_poly_compose_series(mp_ptr res, mp_srcptr poly1, slong len1, mp_srcptr poly2, slong len2, slong n, nmod_t mod) noexcept - # Sets ``res`` to the composition of ``poly1`` and ``poly2`` - # modulo `x^n`, where the constant term of ``poly2`` is required - # to be zero. - # Assumes that ``len1, len2, n > 0``, that ``len1, len2 <= n``, - # and that ``(len1-1) * (len2-1) + 1 <= n``, and that ``res`` has - # space for ``n`` coefficients. Does not support aliasing between any - # of the inputs and the output. - # Wraps :func:`_gr_poly_compose_series` which chooses automatically - # between various algorithms. - void nmod_poly_compose_series(nmod_poly_t res, const nmod_poly_t poly1, const nmod_poly_t poly2, slong n) noexcept - # Sets ``res`` to the composition of ``poly1`` and ``poly2`` - # modulo `x^n`, where the constant term of ``poly2`` is required - # to be zero. - - void _nmod_poly_revert_series_lagrange(mp_ptr Qinv, mp_srcptr Q, slong n, nmod_t mod) noexcept - # Sets ``Qinv`` to the compositional inverse or reversion of ``Q`` - # as a power series, i.e. computes `Q^{-1}` such that - # `Q(Q^{-1}(x)) = Q^{-1}(Q(x)) = x \bmod x^n`. The arguments must - # both have length ``n`` and may not be aliased. - # It is required that `Q_0 = 0` and that `Q_1` as well as the integers - # `1, 2, \ldots, n-1` are invertible modulo the modulus. - # This implementation uses the Lagrange inversion formula. - - void nmod_poly_revert_series_lagrange(nmod_poly_t Qinv, const nmod_poly_t Q, slong n) noexcept - # Sets ``Qinv`` to the compositional inverse or reversion of ``Q`` - # as a power series, i.e. computes `Q^{-1}` such that - # `Q(Q^{-1}(x)) = Q^{-1}(Q(x)) = x \bmod x^n`. - # It is required that `Q_0 = 0` and that `Q_1` as well as the integers - # `1, 2, \ldots, n-1` are invertible modulo the modulus. - # This implementation uses the Lagrange inversion formula. - - void _nmod_poly_revert_series_lagrange_fast(mp_ptr Qinv, mp_srcptr Q, slong n, nmod_t mod) noexcept - # Sets ``Qinv`` to the compositional inverse or reversion of ``Q`` - # as a power series, i.e. computes `Q^{-1}` such that - # `Q(Q^{-1}(x)) = Q^{-1}(Q(x)) = x \bmod x^n`. The arguments must - # both have length ``n`` and may not be aliased. - # It is required that `Q_0 = 0` and that `Q_1` as well as the integers - # `1, 2, \ldots, n-1` are invertible modulo the modulus. - # This implementation uses a reduced-complexity implementation - # of the Lagrange inversion formula. - - void nmod_poly_revert_series_lagrange_fast(nmod_poly_t Qinv, const nmod_poly_t Q, slong n) noexcept - # Sets ``Qinv`` to the compositional inverse or reversion of ``Q`` - # as a power series, i.e. computes `Q^{-1}` such that - # `Q(Q^{-1}(x)) = Q^{-1}(Q(x)) = x \bmod x^n`. - # It is required that `Q_0 = 0` and that `Q_1` as well as the integers - # `1, 2, \ldots, n-1` are invertible modulo the modulus. - # This implementation uses a reduced-complexity implementation - # of the Lagrange inversion formula. - - void _nmod_poly_revert_series_newton(mp_ptr Qinv, mp_srcptr Q, slong n, nmod_t mod) noexcept - # Sets ``Qinv`` to the compositional inverse or reversion of ``Q`` - # as a power series, i.e. computes `Q^{-1}` such that - # `Q(Q^{-1}(x)) = Q^{-1}(Q(x)) = x \bmod x^n`. The arguments must - # both have length ``n`` and may not be aliased. - # It is required that `Q_0 = 0` and that `Q_1` as well as the integers - # `1, 2, \ldots, n-1` are invertible modulo the modulus. - # This implementation uses Newton iteration [BrentKung1978]_. - - void nmod_poly_revert_series_newton(nmod_poly_t Qinv, const nmod_poly_t Q, slong n) noexcept - # Sets ``Qinv`` to the compositional inverse or reversion of ``Q`` - # as a power series, i.e. computes `Q^{-1}` such that - # `Q(Q^{-1}(x)) = Q^{-1}(Q(x)) = x \bmod x^n`. - # It is required that `Q_0 = 0` and that `Q_1` as well as the integers - # `1, 2, \ldots, n-1` are invertible modulo the modulus. - # This implementation uses Newton iteration [BrentKung1978]_. - - void _nmod_poly_revert_series(mp_ptr Qinv, mp_srcptr Q, slong n, nmod_t mod) noexcept - # Sets ``Qinv`` to the compositional inverse or reversion of ``Q`` - # as a power series, i.e. computes `Q^{-1}` such that - # `Q(Q^{-1}(x)) = Q^{-1}(Q(x)) = x \bmod x^n`. The arguments must - # both have length ``n`` and may not be aliased. - # It is required that `Q_0 = 0` and that `Q_1` as well as the integers - # `1, 2, \ldots, n-1` are invertible modulo the modulus. - # This implementation automatically chooses between the Lagrange - # inversion formula and Newton iteration based on the size of the - # input. - + void _nmod_poly_revert_series(mp_ptr Qinv, mp_srcptr Q, slong Qlen, slong n, nmod_t mod) noexcept void nmod_poly_revert_series(nmod_poly_t Qinv, const nmod_poly_t Q, slong n) noexcept - # Sets ``Qinv`` to the compositional inverse or reversion of ``Q`` - # as a power series, i.e. computes `Q^{-1}` such that - # `Q(Q^{-1}(x)) = Q^{-1}(Q(x)) = x \bmod x^n`. - # It is required that `Q_0 = 0` and that `Q_1` as well as the integers - # `1, 2, \ldots, n-1` are invertible modulo the modulus. - # This implementation automatically chooses between the Lagrange - # inversion formula and Newton iteration based on the size of the - # input. - void _nmod_poly_invsqrt_series(mp_ptr g, mp_srcptr h, slong hlen, slong n, nmod_t mod) noexcept - # Set the first `n` terms of `g` to the series expansion of `1/\sqrt{h}`. - # It is assumed that `n > 0`, that `h` has constant term 1. Aliasing is not permitted. - void nmod_poly_invsqrt_series(nmod_poly_t g, const nmod_poly_t h, slong n) noexcept - # Set `g` to the series expansion of `1/\sqrt{h}` to order `O(x^n)`. - # It is assumed that `h` has constant term 1. - void _nmod_poly_sqrt_series(mp_ptr g, mp_srcptr h, slong hlen, slong n, nmod_t mod) noexcept - # Set the first `n` terms of `g` to the series expansion of `\sqrt{h}`. - # It is assumed that `n > 0`, that `h` has constant term 1. Aliasing is not permitted. - void nmod_poly_sqrt_series(nmod_poly_t g, const nmod_poly_t h, slong n) noexcept - # Set `g` to the series expansion of `\sqrt{h}` to order `O(x^n)`. - # It is assumed that `h` has constant term 1. - int _nmod_poly_sqrt(mp_ptr s, mp_srcptr p, slong n, nmod_t mod) noexcept - # If ``(p, n)`` is a perfect square, sets ``(s, n / 2 + 1)`` - # to a square root of `p` and returns 1. Otherwise returns 0. - int nmod_poly_sqrt(nmod_poly_t s, const nmod_poly_t p) noexcept - # If `p` is a perfect square, sets `s` to a square root of `p` - # and returns 1. Otherwise returns 0. - void _nmod_poly_power_sums_naive(mp_ptr res, mp_srcptr poly, slong len, slong n, nmod_t mod) noexcept - # Compute the (truncated) power sums series of the polynomial - # ``(poly,len)`` up to length `n` using Newton identities. - void nmod_poly_power_sums_naive(nmod_poly_t res, const nmod_poly_t poly, slong n) noexcept - # Compute the (truncated) power sum series of the polynomial - # ``poly`` up to length `n` using Newton identities. - void _nmod_poly_power_sums_schoenhage(mp_ptr res, mp_srcptr poly, slong len, slong n, nmod_t mod) noexcept - # Compute the (truncated) power sums series of the polynomial - # ``(poly,len)`` up to length `n` using a series expansion - # (a formula due to Schoenhage). - void nmod_poly_power_sums_schoenhage(nmod_poly_t res, const nmod_poly_t poly, slong n) noexcept - # Compute the (truncated) power sums series of the polynomial - # ``poly`` up to length `n` using a series expansion - # (a formula due to Schoenhage). - void _nmod_poly_power_sums(mp_ptr res, mp_srcptr poly, slong len, slong n, nmod_t mod) noexcept - # Compute the (truncated) power sums series of the polynomial - # ``(poly,len)`` up to length `n`. - void nmod_poly_power_sums(nmod_poly_t res, const nmod_poly_t poly, slong n) noexcept - # Compute the (truncated) power sums series of the polynomial - # ``poly`` up to length `n`. - void _nmod_poly_power_sums_to_poly_naive(mp_ptr res, mp_srcptr poly, slong len, nmod_t mod) noexcept - # Compute the (monic) polynomial given by its power sums series - # ``(poly,len)`` using Newton identities. - void nmod_poly_power_sums_to_poly_naive(nmod_poly_t res, const nmod_poly_t Q) noexcept - # Compute the (monic) polynomial given by its power sums series - # ``Q`` using Newton identities. - void _nmod_poly_power_sums_to_poly_schoenhage(mp_ptr res, mp_srcptr poly, slong len, nmod_t mod) noexcept - # Compute the (monic) polynomial given by its power sums series - # ``(poly,len)`` using series expansion (a formula due to Schoenhage). - void nmod_poly_power_sums_to_poly_schoenhage(nmod_poly_t res, const nmod_poly_t Q) noexcept - # Compute the (monic) polynomial given by its power sums series - # ``Q`` using series expansion (a formula due to Schoenhage). - void _nmod_poly_power_sums_to_poly(mp_ptr res, mp_srcptr poly, slong len, nmod_t mod) noexcept - # Compute the (monic) polynomial given by its power sums series - # ``(poly,len)``. - void nmod_poly_power_sums_to_poly(nmod_poly_t res, const nmod_poly_t Q) noexcept - # Compute the (monic) polynomial given by its power sums series ``Q``. - void _nmod_poly_log_series(mp_ptr g, mp_srcptr h, slong hlen, slong n, nmod_t mod) noexcept - # Set `g = \log(h) + O(x^n)`. Assumes `n > 0` and ``hlen > 0``. - # Aliasing of `g` and `h` is allowed. - void nmod_poly_log_series(nmod_poly_t g, const nmod_poly_t h, slong n) noexcept - # Set `g = \log(h) + O(x^n)`. The case `h = 1+cx^r` is automatically - # detected and handled efficiently. - void _nmod_poly_exp_series(mp_ptr f, mp_srcptr h, slong hlen, slong n, nmod_t mod) noexcept - # Set `f = \exp(h) + O(x^n)` where ``h`` is a polynomial. Assume - # `n > 0`. Aliasing of `g` and `h` is not allowed. - # Uses Newton iteration (an improved version of the - # algorithm in [HanZim2004]_). - # For small `n`, falls back to the basecase algorithm. - void _nmod_poly_exp_expinv_series(mp_ptr f, mp_ptr g, mp_srcptr h, slong hlen, slong n, nmod_t mod) noexcept - # Set `f = \exp(h) + O(x^n)` and `g = \exp(-h) + O(x^n)`, more efficiently - # for large `n` than performing a separate inversion to obtain `g`. - # Assumes `n > 0` and that `h` is zero-padded - # as necessary to length `n`. Aliasing is not allowed. - # Uses Newton iteration (the version given in [HanZim2004]_). - # For small `n`, falls back to the basecase algorithm. - void nmod_poly_exp_series(nmod_poly_t g, const nmod_poly_t h, slong n) noexcept - # Set `g = \exp(h) + O(x^n)`. The case `h = cx^r` is automatically - # detected and handled efficiently. Otherwise this function automatically - # uses the basecase algorithm for small `n` and Newton iteration otherwise. - void _nmod_poly_atan_series(mp_ptr g, mp_srcptr h, slong hlen, slong n, nmod_t mod) noexcept - # Set `g = \operatorname{atan}(h) + O(x^n)`. Assumes `n > 0`. - # Aliasing of `g` and `h` is allowed. - void nmod_poly_atan_series(nmod_poly_t g, const nmod_poly_t h, slong n) noexcept - # Set `g = \operatorname{atan}(h) + O(x^n)`. - void _nmod_poly_atanh_series(mp_ptr g, mp_srcptr h, slong hlen, slong n, nmod_t mod) noexcept - # Set `g = \operatorname{atanh}(h) + O(x^n)`. Assumes `n > 0`. - # Aliasing of `g` and `h` is allowed. - void nmod_poly_atanh_series(nmod_poly_t g, const nmod_poly_t h, slong n) noexcept - # Set `g = \operatorname{atanh}(h) + O(x^n)`. - void _nmod_poly_asin_series(mp_ptr g, mp_srcptr h, slong hlen, slong n, nmod_t mod) noexcept - # Set `g = \operatorname{asin}(h) + O(x^n)`. Assumes `n > 0`. - # Aliasing of `g` and `h` is allowed. - void nmod_poly_asin_series(nmod_poly_t g, const nmod_poly_t h, slong n) noexcept - # Set `g = \operatorname{asin}(h) + O(x^n)`. - void _nmod_poly_asinh_series(mp_ptr g, mp_srcptr h, slong hlen, slong n, nmod_t mod) noexcept - # Set `g = \operatorname{asinh}(h) + O(x^n)`. Assumes `n > 0`. - # Aliasing of `g` and `h` is allowed. - void nmod_poly_asinh_series(nmod_poly_t g, const nmod_poly_t h, slong n) noexcept - # Set `g = \operatorname{asinh}(h) + O(x^n)`. - void _nmod_poly_sin_series(mp_ptr g, mp_srcptr h, slong n, nmod_t mod) noexcept - # Set `g = \operatorname{sin}(h) + O(x^n)`. Assumes `n > 0` and that `h` - # is zero-padded as necessary to length `n`. Aliasing of `g` and `h` is - # allowed. The value is computed using the identity - # `\sin(x) = 2 \tan(x/2)) / (1 + \tan^2(x/2)).` - void nmod_poly_sin_series(nmod_poly_t g, const nmod_poly_t h, slong n) noexcept - # Set `g = \operatorname{sin}(h) + O(x^n)`. - void _nmod_poly_cos_series(mp_ptr g, mp_srcptr h, slong n, nmod_t mod) noexcept - # Set `g = \operatorname{cos}(h) + O(x^n)`. Assumes `n > 0` and that `h` - # is zero-padded as necessary to length `n`. Aliasing of `g` and `h` is - # allowed. The value is computed using the identity - # `\cos(x) = (1-\tan^2(x/2)) / (1 + \tan^2(x/2)).` - void nmod_poly_cos_series(nmod_poly_t g, const nmod_poly_t h, slong n) noexcept - # Set `g = \operatorname{cos}(h) + O(x^n)`. - void _nmod_poly_tan_series(mp_ptr g, mp_srcptr h, slong hlen, slong n, nmod_t mod) noexcept - # Set `g = \operatorname{tan}(h) + O(x^n)`. Assumes `n > 0` and that `h` - # is zero-padded as necessary to length `n`. Aliasing of `g` and `h` is - # not allowed. Uses Newton iteration to invert the atan function. - void nmod_poly_tan_series(nmod_poly_t g, const nmod_poly_t h, slong n) noexcept - # Set `g = \operatorname{tan}(h) + O(x^n)`. - void _nmod_poly_sinh_series(mp_ptr g, mp_srcptr h, slong n, nmod_t mod) noexcept - # Set `g = \operatorname{sinh}(h) + O(x^n)`. Assumes `n > 0` and that `h` - # is zero-padded as necessary to length `n`. Aliasing of `g` and `h` is - # not allowed. Uses the identity `\sinh(x) = (e^x - e^{-x})/2`. - void nmod_poly_sinh_series(nmod_poly_t g, const nmod_poly_t h, slong n) noexcept - # Set `g = \operatorname{sinh}(h) + O(x^n)`. - void _nmod_poly_cosh_series(mp_ptr g, mp_srcptr h, slong n, nmod_t mod) noexcept - # Set `g = \operatorname{cos}(h) + O(x^n)`. Assumes `n > 0` and that `h` - # is zero-padded as necessary to length `n`. Aliasing of `g` and `h` is - # not allowed. - # Uses the identity `\cosh(x) = (e^x + e^{-x})/2`. - void nmod_poly_cosh_series(nmod_poly_t g, const nmod_poly_t h, slong n) noexcept - # Set `g = \operatorname{cosh}(h) + O(x^n)`. - void _nmod_poly_tanh_series(mp_ptr g, mp_srcptr h, slong n, nmod_t mod) noexcept - # Set `g = \operatorname{tanh}(h) + O(x^n)`. Assumes `n > 0` and that `h` - # is zero-padded as necessary to length `n`. Uses the identity - # `\tanh(x) = (e^{2x}-1)/(e^{2x}+1)`. - void nmod_poly_tanh_series(nmod_poly_t g, const nmod_poly_t h, slong n) noexcept - # Set `g = \operatorname{tanh}(h) + O(x^n)`. - void _nmod_poly_product_roots_nmod_vec(mp_ptr poly, mp_srcptr xs, slong n, nmod_t mod) noexcept - # Sets ``(poly, n + 1)`` to the monic polynomial which is the product - # of `(x - x_0)(x - x_1) \cdots (x - x_{n-1})`, the roots `x_i` being - # given by ``xs``. - # Aliasing of the input and output is not allowed. - void nmod_poly_product_roots_nmod_vec(nmod_poly_t poly, mp_srcptr xs, slong n) noexcept - # Sets ``poly`` to the monic polynomial which is the product - # of `(x - x_0)(x - x_1) \cdots (x - x_{n-1})`, the roots `x_i` being - # given by ``xs``. - int nmod_poly_find_distinct_nonzero_roots(mp_limb_t * roots, const nmod_poly_t A) noexcept - # If ``A`` has `\deg(A)` distinct nonzero roots in `\mathbb{F}_p`, write these roots out to ``roots[0]`` to ``roots[deg(A) - 1]`` and return ``1``. - # Otherwise, return ``0``. It is assumed that ``A`` is nonzero and that the modulus of ``A`` is prime. - # This function uses Rabin's probabilistic method via gcd's with `(x + \delta)^{\frac{p-1}{2}} - 1`. - mp_ptr * _nmod_poly_tree_alloc(slong len) noexcept - # Allocates space for a subproduct tree of the given length, having - # linear factors at the lowest level. - # Entry `i` in the tree is a pointer to a single array of limbs, - # capable of storing `\lfloor n / 2^i \rfloor` subproducts of - # degree `2^i` adjacently, plus a trailing entry if `n / 2^i` is - # not an integer. - # For example, a tree of length 7 built from monic linear factors has - # the following structure, where spaces have been inserted - # for illustrative purposes:: - # X1 X1 X1 X1 X1 X1 X1 - # XX1 XX1 XX1 X1 - # XXXX1 XX1 X1 - # XXXXXXX1 - void _nmod_poly_tree_free(mp_ptr * tree, slong len) noexcept - # Free the allocated space for the subproduct. - void _nmod_poly_tree_build(mp_ptr * tree, mp_srcptr roots, slong len, nmod_t mod) noexcept - # Builds a subproduct tree in the preallocated space from - # the ``len`` monic linear factors `(x-r_i)`. The top level - # product is not computed. - void nmod_poly_inflate(nmod_poly_t result, const nmod_poly_t input, ulong inflation) noexcept - # Sets ``result`` to the inflated polynomial `p(x^n)` where - # `p` is given by ``input`` and `n` is given by ``deflation``. - void nmod_poly_deflate(nmod_poly_t result, const nmod_poly_t input, ulong deflation) noexcept - # Sets ``result`` to the deflated polynomial `p(x^{1/n})` where - # `p` is given by ``input`` and `n` is given by ``deflation``. - # Requires `n > 0`. - ulong nmod_poly_deflation(const nmod_poly_t input) noexcept - # Returns the largest integer by which ``input`` can be deflated. - # As special cases, returns 0 if ``input`` is the zero polynomial - # and 1 of ``input`` is a constant polynomial. - void nmod_poly_multi_crt_init(nmod_poly_multi_crt_t CRT) noexcept - # Initialize ``CRT`` for Chinese remaindering. - int nmod_poly_multi_crt_precompute(nmod_poly_multi_crt_t CRT, const nmod_poly_struct * moduli, slong len) noexcept int nmod_poly_multi_crt_precompute_p(nmod_poly_multi_crt_t CRT, const nmod_poly_struct * const * moduli, slong len) noexcept - # Configure ``CRT`` for repeated Chinese remaindering of ``moduli``. The number of moduli, ``len``, should be positive. - # A return of ``0`` indicates that the compilation failed and future calls to :func:`nmod_poly_multi_crt_precomp` will leave the output undefined. - # A return of ``1`` indicates that the compilation was successful, which occurs if and only if either (1) ``len == 1`` and ``modulus + 0`` is nonzero, or (2) all of the moduli have positive degree and are pairwise relatively prime. - void nmod_poly_multi_crt_precomp(nmod_poly_t output, const nmod_poly_multi_crt_t CRT, const nmod_poly_struct * values) noexcept void nmod_poly_multi_crt_precomp_p(nmod_poly_t output, const nmod_poly_multi_crt_t CRT, const nmod_poly_struct * const * values) noexcept - # Set ``output`` to the polynomial of lowest possible degree that is congruent to ``values + i`` modulo the ``moduli + i`` in :func:`nmod_poly_multi_crt_precompute`. - # The inputs ``values + 0, ..., values + len - 1`` where ``len`` was used in :func:`nmod_poly_multi_crt_precompute` are expected to be valid and have modulus matching the modulus of the moduli used in :func:`nmod_poly_multi_crt_precompute`. - int nmod_poly_multi_crt(nmod_poly_t output, const nmod_poly_struct * moduli, const nmod_poly_struct * values, slong len) noexcept - # Perform the same operation as :func:`nmod_poly_multi_crt_precomp` while internally constructing and destroying the precomputed data. - # All of the remarks in :func:`nmod_poly_multi_crt_precompute` apply. - void nmod_poly_multi_crt_clear(nmod_poly_multi_crt_t CRT) noexcept - # Free all space used by ``CRT``. - slong _nmod_poly_multi_crt_local_size(const nmod_poly_multi_crt_t CRT) noexcept - # Return the required length of the output for :func:`_nmod_poly_multi_crt_run`. - void _nmod_poly_multi_crt_run(nmod_poly_struct * outputs, const nmod_poly_multi_crt_t CRT, const nmod_poly_struct * inputs) noexcept void _nmod_poly_multi_crt_run_p(nmod_poly_struct * outputs, const nmod_poly_multi_crt_t CRT, const nmod_poly_struct * const * inputs) noexcept - # Perform the same operation as :func:`nmod_poly_multi_crt_precomp` using supplied temporary space. - # The actual output is placed in ``outputs + 0``, and ``outputs`` should contain space for all temporaries and should be at least as long as ``_nmod_poly_multi_crt_local_size(CRT)``. - # Of course the moduli of these temporaries should match the modulus of the inputs. - void nmod_berlekamp_massey_init(nmod_berlekamp_massey_t B, mp_limb_t p) noexcept - # Initialize ``B`` in characteristic ``p`` with an empty stream. - void nmod_berlekamp_massey_clear(nmod_berlekamp_massey_t B) noexcept - # Free any space used by ``B``. - void nmod_berlekamp_massey_start_over(nmod_berlekamp_massey_t B) noexcept - # Empty the stream of points in ``B``. - void nmod_berlekamp_massey_set_prime(nmod_berlekamp_massey_t B, mp_limb_t p) noexcept - # Set the characteristic of the field and empty the stream of points in ``B``. - void nmod_berlekamp_massey_add_points(nmod_berlekamp_massey_t B, const mp_limb_t * a, slong count) noexcept void nmod_berlekamp_massey_add_zeros(nmod_berlekamp_massey_t B, slong count) noexcept void nmod_berlekamp_massey_add_point(nmod_berlekamp_massey_t B, mp_limb_t a) noexcept - # Add point(s) to the stream processed by ``B``. The addition of any number of points will not update the `V` and `R` polynomial. - int nmod_berlekamp_massey_reduce(nmod_berlekamp_massey_t B) noexcept - # Ensure that the polynomials `V` and `R` are up to date. The return value is ``1`` if this function changed `V` and ``0`` otherwise. - # For example, if this function is called twice in a row without adding any points in between, the return of the second call should be ``0``. - # As another example, suppose the object is emptied, the points `1, 1, 2, 3` are added, then reduce is called. This reduce should return ``1`` with `\deg(R) < \deg(V) = 2` because the Fibonacci sequence has been recognized. The further addition of the two points `5, 8` and a reduce will result in a return value of ``0``. - slong nmod_berlekamp_massey_point_count(const nmod_berlekamp_massey_t B) noexcept - # Return the number of points stored in ``B``. - const mp_limb_t * nmod_berlekamp_massey_points(const nmod_berlekamp_massey_t B) noexcept - # Return a pointer to the array of points stored in ``B``. This may be ``NULL`` if :func:`nmod_berlekamp_massey_point_count` returns ``0``. - const nmod_poly_struct * nmod_berlekamp_massey_V_poly(const nmod_berlekamp_massey_t B) noexcept - # Return the polynomial `V` in ``B``. - const nmod_poly_struct * nmod_berlekamp_massey_R_poly(const nmod_berlekamp_massey_t B) noexcept - # Return the polynomial `R` in ``B``. diff --git a/src/sage/libs/flint/nmod_poly_factor.pxd b/src/sage/libs/flint/nmod_poly_factor.pxd index a0964a4a80e..f885c202785 100644 --- a/src/sage/libs/flint/nmod_poly_factor.pxd +++ b/src/sage/libs/flint/nmod_poly_factor.pxd @@ -2,7 +2,9 @@ # distutils: depends = flint/nmod_poly_factor.h ################################################################################ -# This file is auto-generated. Do not modify by hand +# This file is auto-generated by the script +# SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py. +# Do not modify by hand! Fix and rerun the script instead. ################################################################################ from libc.stdio cimport FILE @@ -11,152 +13,30 @@ from sage.libs.mpfr.types cimport * from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void nmod_poly_factor_init(nmod_poly_factor_t fac) noexcept - # Initialises ``fac`` for use. An ``nmod_poly_factor_t`` - # represents a polynomial in factorised form as a product of - # polynomials with associated exponents. - void nmod_poly_factor_clear(nmod_poly_factor_t fac) noexcept - # Frees all memory associated with ``fac``. - void nmod_poly_factor_realloc(nmod_poly_factor_t fac, slong alloc) noexcept - # Reallocates the factor structure to provide space for - # precisely ``alloc`` factors. - void nmod_poly_factor_fit_length(nmod_poly_factor_t fac, slong len) noexcept - # Ensures that the factor structure has space for at - # least ``len`` factors. This function takes care - # of the case of repeated calls by always at least - # doubling the number of factors the structure can hold. - void nmod_poly_factor_set(nmod_poly_factor_t res, const nmod_poly_factor_t fac) noexcept - # Sets ``res`` to the same factorisation as ``fac``. - void nmod_poly_factor_print(const nmod_poly_factor_t fac) noexcept - # Prints the entries of ``fac`` to standard output. - void nmod_poly_factor_insert(nmod_poly_factor_t fac, const nmod_poly_t poly, slong exp) noexcept - # Inserts the factor ``poly`` with multiplicity ``exp`` into - # the factorisation ``fac``. - # If ``fac`` already contains ``poly``, then ``exp`` simply - # gets added to the exponent of the existing entry. - void nmod_poly_factor_concat(nmod_poly_factor_t res, const nmod_poly_factor_t fac) noexcept - # Concatenates two factorisations. - # This is equivalent to calling :func:`nmod_poly_factor_insert` - # repeatedly with the individual factors of ``fac``. - # Does not support aliasing between ``res`` and ``fac``. - void nmod_poly_factor_pow(nmod_poly_factor_t fac, slong exp) noexcept - # Raises ``fac`` to the power ``exp``. - - ulong nmod_poly_remove(nmod_poly_t f, const nmod_poly_t p) noexcept - # Removes the highest possible power of ``p`` from ``f`` and - # returns the exponent. - bint nmod_poly_is_irreducible(const nmod_poly_t f) noexcept - # Returns 1 if the polynomial ``f`` is irreducible, otherwise returns 0. - bint nmod_poly_is_irreducible_ddf(const nmod_poly_t f) noexcept - # Returns 1 if the polynomial ``f`` is irreducible, otherwise returns 0. - # Uses fast distinct-degree factorisation. - bint nmod_poly_is_irreducible_rabin(const nmod_poly_t f) noexcept - # Returns 1 if the polynomial ``f`` is irreducible, otherwise returns 0. - # Uses Rabin irreducibility test. - bint _nmod_poly_is_squarefree(mp_srcptr f, slong len, nmod_t mod) noexcept - # Returns 1 if ``(f, len)`` is squarefree, and 0 otherwise. As a - # special case, the zero polynomial is not considered squarefree. - # There are no restrictions on the length. - bint nmod_poly_is_squarefree(const nmod_poly_t f) noexcept - # Returns 1 if ``f`` is squarefree, and 0 otherwise. As a special - # case, the zero polynomial is not considered squarefree. - void nmod_poly_factor_squarefree(nmod_poly_factor_t res, const nmod_poly_t f) noexcept - # Sets ``res`` to a square-free factorization of ``f``. - bint nmod_poly_factor_equal_deg_prob(nmod_poly_t factor, flint_rand_t state, const nmod_poly_t pol, slong d) noexcept - # Probabilistic equal degree factorisation of ``pol`` into - # irreducible factors of degree ``d``. If it passes, a factor is - # placed in factor and 1 is returned, otherwise 0 is returned and - # the value of factor is undetermined. - # Requires that ``pol`` be monic, non-constant and squarefree. - void nmod_poly_factor_equal_deg(nmod_poly_factor_t factors, const nmod_poly_t pol, slong d) noexcept - # Assuming ``pol`` is a product of irreducible factors all of - # degree ``d``, finds all those factors and places them in factors. - # Requires that ``pol`` be monic, non-constant and squarefree. - - void nmod_poly_factor_distinct_deg(nmod_poly_factor_t res, const nmod_poly_t poly, slong * const *degs) noexcept - # Factorises a monic non-constant squarefree polynomial ``poly`` - # of degree n into factors `f[d]` such that for `1 \leq d \leq n` - # `f[d]` is the product of the monic irreducible factors of ``poly`` - # of degree `d`. Factors `f[d]` are stored in ``res``, and the degree `d` - # of the irreducible factors is stored in ``degs`` in the same order - # as the factors. - # Requires that ``degs`` has enough space for ``(n/2)+1 * sizeof(slong)``. - - void nmod_poly_factor_distinct_deg_threaded(nmod_poly_factor_t res, const nmod_poly_t poly, slong * const *degs) noexcept - # Multithreaded version of :func:`nmod_poly_factor_distinct_deg`. - + void nmod_poly_factor_distinct_deg(nmod_poly_factor_t res, const nmod_poly_t poly, slong * const * degs) noexcept + void nmod_poly_factor_distinct_deg_threaded(nmod_poly_factor_t res, const nmod_poly_t poly, slong * const * degs) noexcept void nmod_poly_factor_cantor_zassenhaus(nmod_poly_factor_t res, const nmod_poly_t f) noexcept - # Factorises a non-constant polynomial ``f`` into monic irreducible - # factors using the Cantor-Zassenhaus algorithm. - void nmod_poly_factor_berlekamp(nmod_poly_factor_t res, const nmod_poly_t f) noexcept - # Factorises a non-constant, squarefree polynomial ``f`` into monic - # irreducible factors using the Berlekamp algorithm. - void nmod_poly_factor_kaltofen_shoup(nmod_poly_factor_t res, const nmod_poly_t poly) noexcept - # Factorises a non-constant polynomial ``f`` into monic irreducible - # factors using the fast version of Cantor-Zassenhaus algorithm proposed by - # Kaltofen and Shoup (1998). More precisely this algorithm uses a - # “baby step/giant step” strategy for the distinct-degree factorization - # step. If :func:`flint_get_num_threads` is greater than one - # :func:`nmod_poly_factor_distinct_deg_threaded` is used. - mp_limb_t nmod_poly_factor_with_berlekamp(nmod_poly_factor_t res, const nmod_poly_t f) noexcept - # Factorises a general polynomial ``f`` into monic irreducible factors - # and returns the leading coefficient of ``f``, or 0 if ``f`` - # is the zero polynomial. - # This function first checks for small special cases, deflates ``f`` - # if it is of the form `p(x^m)` for some `m > 1`, then performs a - # square-free factorisation, and finally runs Berlekamp on all the - # individual square-free factors. - mp_limb_t nmod_poly_factor_with_cantor_zassenhaus(nmod_poly_factor_t res, const nmod_poly_t f) noexcept - # Factorises a general polynomial ``f`` into monic irreducible factors - # and returns the leading coefficient of ``f``, or 0 if ``f`` - # is the zero polynomial. - # This function first checks for small special cases, deflates ``f`` - # if it is of the form `p(x^m)` for some `m > 1`, then performs a - # square-free factorisation, and finally runs Cantor-Zassenhaus on all the - # individual square-free factors. - mp_limb_t nmod_poly_factor_with_kaltofen_shoup(nmod_poly_factor_t res, const nmod_poly_t f) noexcept - # Factorises a general polynomial ``f`` into monic irreducible factors - # and returns the leading coefficient of ``f``, or 0 if ``f`` - # is the zero polynomial. - # This function first checks for small special cases, deflates ``f`` - # if it is of the form `p(x^m)` for some `m > 1`, then performs a - # square-free factorisation, and finally runs Kaltofen-Shoup on all the - # individual square-free factors. - mp_limb_t nmod_poly_factor(nmod_poly_factor_t res, const nmod_poly_t f) noexcept - # Factorises a general polynomial ``f`` into monic irreducible factors - # and returns the leading coefficient of ``f``, or 0 if ``f`` - # is the zero polynomial. - # This function first checks for small special cases, deflates ``f`` - # if it is of the form `p(x^m)` for some `m > 1`, then performs a - # square-free factorisation, and finally runs either Cantor-Zassenhaus - # or Berlekamp on all the individual square-free factors. - # Currently Cantor-Zassenhaus is used by default unless the modulus is 2, in - # which case Berlekamp is used. - - void _nmod_poly_interval_poly_worker(void* arg_ptr) noexcept - # Worker function to compute interval polynomials in distinct degree - # factorisation. Input/output is stored in - # ``nmod_poly_interval_poly_arg_t``. + void _nmod_poly_interval_poly_worker(void * arg_ptr) noexcept diff --git a/src/sage/libs/flint/nmod_poly_mat.pxd b/src/sage/libs/flint/nmod_poly_mat.pxd index 2047bf1761c..7156ddd97ea 100644 --- a/src/sage/libs/flint/nmod_poly_mat.pxd +++ b/src/sage/libs/flint/nmod_poly_mat.pxd @@ -2,7 +2,9 @@ # distutils: depends = flint/nmod_poly_mat.h ################################################################################ -# This file is auto-generated. Do not modify by hand +# This file is auto-generated by the script +# SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py. +# Do not modify by hand! Fix and rerun the script instead. ################################################################################ from libc.stdio cimport FILE @@ -11,314 +13,62 @@ from sage.libs.mpfr.types cimport * from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void nmod_poly_mat_init(nmod_poly_mat_t mat, slong rows, slong cols, mp_limb_t n) noexcept - # Initialises a matrix with the given number of rows and columns for use. - # The modulus is set to `n`. - void nmod_poly_mat_init_set(nmod_poly_mat_t mat, const nmod_poly_mat_t src) noexcept - # Initialises a matrix ``mat`` of the same dimensions and modulus - # as ``src``, and sets it to a copy of ``src``. - void nmod_poly_mat_clear(nmod_poly_mat_t mat) noexcept - # Frees all memory associated with the matrix. The matrix must be - # reinitialised if it is to be used again. - void nmod_poly_mat_set_trunc(nmod_poly_mat_t res, const nmod_poly_mat_t pmat, long len) noexcept - # Set ``res`` to the truncation of ``pmat`` to length ``len``. Entries of - # ``res`` are normalized. - void nmod_poly_mat_truncate(nmod_poly_mat_t pmat, long len) noexcept - # Truncates ``pmat`` to the given length ``len``, and normalize its entries. - # If ``len`` is greater than the maximum length of the entries of ``pmat``, - # then nothing happens. - void nmod_poly_mat_shift_left(nmod_poly_mat_t res, const nmod_poly_mat_t pmat, slong k) noexcept - # Sets ``res`` to ``pmat`` shifted left by ``k`` coefficients, that is, - # multiplied by `x^k`. - void nmod_poly_mat_shift_right(nmod_poly_mat_t res, const nmod_poly_mat_t pmat, slong k) noexcept - # Sets ``res`` to ``pmat`` shifted right by ``k`` coefficients, that is, - # divide by `x^k` and throw away the remainder. If ``k`` is greater than or - # equal to the length of ``pmat``, the result is the zero polynomial matrix. - slong nmod_poly_mat_nrows(const nmod_poly_mat_t mat) noexcept - # Returns the number of rows in ``mat``. - slong nmod_poly_mat_ncols(const nmod_poly_mat_t mat) noexcept - # Returns the number of columns in ``mat``. - mp_limb_t nmod_poly_mat_modulus(const nmod_poly_mat_t mat) noexcept - # Returns the modulus of ``mat``. - nmod_poly_struct * nmod_poly_mat_entry(const nmod_poly_mat_t mat, slong i, slong j) noexcept - # Gives a reference to the entry at row ``i`` and column ``j``. - # The reference can be passed as an input or output variable to any - # ``nmod_poly`` function for direct manipulation of the matrix element. - # No bounds checking is performed. - void nmod_poly_mat_set(nmod_poly_mat_t mat1, const nmod_poly_mat_t mat2) noexcept - # Sets ``mat1`` to a copy of ``mat2``. - void nmod_poly_mat_set_nmod_mat(nmod_poly_mat_t pmat, const nmod_mat_t cmat) noexcept - # Sets the already-initialized polynomial matrix ``pmat`` to a constant - # matrix with the same entries as ``cmat``. Both input matrices must have the - # same dimensions and modulus. - void nmod_poly_mat_swap(nmod_poly_mat_t mat1, nmod_poly_mat_t mat2) noexcept - # Swaps ``mat1`` and ``mat2`` efficiently. - void nmod_poly_mat_swap_entrywise(nmod_poly_mat_t mat1, nmod_poly_mat_t mat2) noexcept - # Swaps two matrices by swapping the individual entries rather than swapping - # the contents of the structs. - void nmod_poly_mat_print(const nmod_poly_mat_t mat, const char * x) noexcept - # Prints the matrix ``mat`` to standard output, using the - # variable ``x``. - void nmod_poly_mat_randtest(nmod_poly_mat_t mat, flint_rand_t state, slong len) noexcept - # This is equivalent to applying ``nmod_poly_randtest`` to all entries - # in the matrix. - void nmod_poly_mat_randtest_sparse(nmod_poly_mat_t A, flint_rand_t state, slong len, float density) noexcept - # Creates a random matrix with the amount of nonzero entries given - # approximately by the ``density`` variable, which should be a fraction - # between 0 (most sparse) and 1 (most dense). - # The nonzero entries will have random lengths between 1 and ``len``. - void nmod_poly_mat_zero(nmod_poly_mat_t mat) noexcept - # Sets ``mat`` to the zero matrix. - void nmod_poly_mat_one(nmod_poly_mat_t mat) noexcept - # Sets ``mat`` to the unit or identity matrix of given shape, - # having the element 1 on the main diagonal and zeros elsewhere. - # If ``mat`` is nonsquare, it is set to the truncation of a unit matrix. - bint nmod_poly_mat_equal(const nmod_poly_mat_t mat1, const nmod_poly_mat_t mat2) noexcept - # Returns nonzero if ``mat1`` and ``mat2`` have the same shape and - # all their entries agree, and returns zero otherwise. - bint nmod_poly_mat_equal_nmod_mat(const nmod_poly_mat_t pmat, const nmod_mat_t cmat) noexcept - # Returns nonzero if ``pmat`` is a constant matrix with the same dimensions - # and entries as ``cmat``; returns zero otherwise. - bint nmod_poly_mat_is_zero(const nmod_poly_mat_t mat) noexcept - # Returns nonzero if all entries in ``mat`` are zero, and returns - # zero otherwise. - bint nmod_poly_mat_is_one(const nmod_poly_mat_t mat) noexcept - # Returns nonzero if all entry of ``mat`` on the main diagonal - # are the constant polynomial 1 and all remaining entries are zero, - # and returns zero otherwise. The matrix need not be square. - bint nmod_poly_mat_is_empty(const nmod_poly_mat_t mat) noexcept - # Returns a non-zero value if the number of rows or the number of - # columns in ``mat`` is zero, and otherwise returns - # zero. - bint nmod_poly_mat_is_square(const nmod_poly_mat_t mat) noexcept - # Returns a non-zero value if the number of rows is equal to the - # number of columns in ``mat``, and otherwise returns zero. - void nmod_poly_mat_get_coeff_mat(nmod_mat_t coeff, const nmod_poly_mat_t pmat, slong deg) noexcept - # Sets ``coeff`` to be the coefficient of ``pmat`` of degree ``deg``, where - # ``pmat`` is seen as a polynomial with matrix coefficients and coefficients - # are numbered from zero. ``coeff`` must be already initialized with the - # right dimensions and modulus. For entries of ``pmat`` of degree less than - # ``deg``, the corresponding entry of ``coeff`` is zero. - void nmod_poly_mat_set_coeff_mat(nmod_poly_mat_t pmat, const nmod_mat_t coeff, slong deg) noexcept - # Sets the coefficient of ``pmat`` of degree ``deg`` to ``coeff``, where - # ``pmat`` is seen as a polynomial with matrix coefficients and coefficients - # are numbered from zero. For each entry of ``pmat``, if ``deg`` is larger - # than its degree, this entry is first resized to the appropriate length, - # with intervening coefficients being set to zero. - slong nmod_poly_mat_max_length(const nmod_poly_mat_t A) noexcept - # Returns the maximum polynomial length among all the entries in ``A``. - slong nmod_poly_mat_degree(const nmod_poly_mat_t pmat) noexcept - # Returns the degree of the polynomial matrix ``pmat``. The zero matrix is - # deemed to have degree `-1`. - void nmod_poly_mat_evaluate_nmod(nmod_mat_t B, const nmod_poly_mat_t A, mp_limb_t x) noexcept - # Sets the ``nmod_mat_t`` ``B`` to ``A`` evaluated entrywise - # at the point ``x``. - void nmod_poly_mat_scalar_mul_nmod_poly(nmod_poly_mat_t B, const nmod_poly_mat_t A, const nmod_poly_t c) noexcept - # Sets ``B`` to ``A`` multiplied entrywise by the polynomial ``c``. - void nmod_poly_mat_scalar_mul_nmod(nmod_poly_mat_t B, const nmod_poly_mat_t A, mp_limb_t c) noexcept - # Sets ``B`` to ``A`` multiplied entrywise by the coefficient - # ``c``, which is assumed to be reduced modulo the modulus. - void nmod_poly_mat_add(nmod_poly_mat_t C, const nmod_poly_mat_t A, const nmod_poly_mat_t B) noexcept - # Sets ``C`` to the sum of ``A`` and ``B``. - # All matrices must have the same shape. Aliasing is allowed. - void nmod_poly_mat_sub(nmod_poly_mat_t C, const nmod_poly_mat_t A, const nmod_poly_mat_t B) noexcept - # Sets ``C`` to the sum of ``A`` and ``B``. - # All matrices must have the same shape. Aliasing is allowed. - void nmod_poly_mat_neg(nmod_poly_mat_t B, const nmod_poly_mat_t A) noexcept - # Sets ``B`` to the negation of ``A``. - # The matrices must have the same shape. Aliasing is allowed. - void nmod_poly_mat_mul(nmod_poly_mat_t C, const nmod_poly_mat_t A, const nmod_poly_mat_t B) noexcept - # Sets ``C`` to the matrix product of ``A`` and ``B``. - # The matrices must have compatible dimensions for matrix multiplication. - # Aliasing is allowed. This function automatically chooses between - # classical, KS and evaluation-interpolation multiplication. - void nmod_poly_mat_mul_classical(nmod_poly_mat_t C, const nmod_poly_mat_t A, const nmod_poly_mat_t B) noexcept - # Sets ``C`` to the matrix product of ``A`` and ``B``, - # computed using the classical algorithm. The matrices must have - # compatible dimensions for matrix multiplication. Aliasing is allowed. - void nmod_poly_mat_mul_KS(nmod_poly_mat_t C, const nmod_poly_mat_t A, const nmod_poly_mat_t B) noexcept - # Sets ``C`` to the matrix product of ``A`` and ``B``, - # computed using Kronecker segmentation. The matrices must have - # compatible dimensions for matrix multiplication. Aliasing is allowed. - void nmod_poly_mat_mul_interpolate(nmod_poly_mat_t C, const nmod_poly_mat_t A, const nmod_poly_mat_t B) noexcept - # Sets ``C`` to the matrix product of ``A`` and ``B``, - # computed through evaluation and interpolation. The matrices must have - # compatible dimensions for matrix multiplication. For interpolation - # to be well-defined, we require that the modulus is a prime at least as - # large as `m + n - 1` where `m` and `n` are the maximum lengths of - # polynomials in the input matrices. Aliasing is allowed. - void nmod_poly_mat_sqr(nmod_poly_mat_t B, const nmod_poly_mat_t A) noexcept - # Sets ``B`` to the square of ``A``, which must be a square matrix. - # Aliasing is allowed. This function automatically chooses between - # classical and KS squaring. - void nmod_poly_mat_sqr_classical(nmod_poly_mat_t B, const nmod_poly_mat_t A) noexcept - # Sets ``B`` to the square of ``A``, which must be a square matrix. - # Aliasing is allowed. This function uses direct formulas for very small - # matrices, and otherwise classical matrix multiplication. - void nmod_poly_mat_sqr_KS(nmod_poly_mat_t B, const nmod_poly_mat_t A) noexcept - # Sets ``B`` to the square of ``A``, which must be a square matrix. - # Aliasing is allowed. This function uses Kronecker segmentation. - void nmod_poly_mat_sqr_interpolate(nmod_poly_mat_t B, const nmod_poly_mat_t A) noexcept - # Sets ``B`` to the square of ``A``, which must be a square matrix, - # computed through evaluation and interpolation. For interpolation - # to be well-defined, we require that the modulus is a prime at least as - # large as `2n - 1` where `n` is the maximum length of - # polynomials in the input matrix. Aliasing is allowed. - void nmod_poly_mat_pow(nmod_poly_mat_t B, const nmod_poly_mat_t A, ulong exp) noexcept - # Sets ``B`` to ``A`` raised to the power ``exp``, where ``A`` - # is a square matrix. Uses exponentiation by squaring. Aliasing is allowed. - slong nmod_poly_mat_find_pivot_any(const nmod_poly_mat_t mat, slong start_row, slong end_row, slong c) noexcept - # Attempts to find a pivot entry for row reduction. - # Returns a row index `r` between ``start_row`` (inclusive) and - # ``stop_row`` (exclusive) such that column `c` in ``mat`` has - # a nonzero entry on row `r`, or returns -1 if no such entry exists. - # This implementation simply chooses the first nonzero entry from - # it encounters. This is likely to be a nearly optimal choice if all - # entries in the matrix have roughly the same size, but can lead to - # unnecessary coefficient growth if the entries vary in size. - slong nmod_poly_mat_find_pivot_partial(const nmod_poly_mat_t mat, slong start_row, slong end_row, slong c) noexcept - # Attempts to find a pivot entry for row reduction. - # Returns a row index `r` between ``start_row`` (inclusive) and - # ``stop_row`` (exclusive) such that column `c` in ``mat`` has - # a nonzero entry on row `r`, or returns -1 if no such entry exists. - # This implementation searches all the rows in the column and - # chooses the nonzero entry of smallest degree. This heuristic - # typically reduces coefficient growth when the matrix entries - # vary in size. - slong nmod_poly_mat_fflu(nmod_poly_mat_t B, nmod_poly_t den, slong * perm, const nmod_poly_mat_t A, int rank_check) noexcept - # Uses fraction-free Gaussian elimination to set (``B``, ``den``) to a - # fraction-free LU decomposition of ``A`` and returns the - # rank of ``A``. Aliasing of ``A`` and ``B`` is allowed. - # Pivot elements are chosen with ``nmod_poly_mat_find_pivot_partial``. - # If ``perm`` is non-``NULL``, the permutation of - # rows in the matrix will also be applied to ``perm``. - # If ``rank_check`` is set, the function aborts and returns 0 if the - # matrix is detected not to have full rank without completing the - # elimination. - # The denominator ``den`` is set to `\pm \operatorname{det}(A)`, where - # the sign is decided by the parity of the permutation. Note that the - # determinant is not generally the minimal denominator. - slong nmod_poly_mat_rref(nmod_poly_mat_t B, nmod_poly_t den, const nmod_poly_mat_t A) noexcept - # Sets (``B``, ``den``) to the reduced row echelon form of ``A`` - # and returns the rank of ``A``. - # Aliasing of ``A`` and ``B`` is allowed. - # The denominator ``den`` is set to `\pm \operatorname{det}(A)`. - # Note that the determinant is not generally the minimal denominator. - void nmod_poly_mat_trace(nmod_poly_t trace, const nmod_poly_mat_t mat) noexcept - # Computes the trace of the matrix, i.e. the sum of the entries on - # the main diagonal. The matrix is required to be square. - void nmod_poly_mat_det(nmod_poly_t det, const nmod_poly_mat_t A) noexcept - # Sets ``det`` to the determinant of the square matrix ``A``. Uses - # a direct formula, fraction-free LU decomposition, or interpolation, - # depending on the size of the matrix. - void nmod_poly_mat_det_fflu(nmod_poly_t det, const nmod_poly_mat_t A) noexcept - # Sets ``det`` to the determinant of the square matrix ``A``. - # The determinant is computed by performing a fraction-free LU - # decomposition on a copy of ``A``. - void nmod_poly_mat_det_interpolate(nmod_poly_t det, const nmod_poly_mat_t A) noexcept - # Sets ``det`` to the determinant of the square matrix ``A``. - # The determinant is computed by determining a bound `n` for its length, - # evaluating the matrix at `n` distinct points, computing the determinant - # of each coefficient matrix, and forming the interpolating polynomial. - # If the coefficient ring does not contain `n` distinct points (that is, - # if working over `\mathbf{Z}/p\mathbf{Z}` where `p < n`), - # this function automatically falls back to ``nmod_poly_mat_det_fflu``. - slong nmod_poly_mat_rank(const nmod_poly_mat_t A) noexcept - # Returns the rank of ``A``. Performs fraction-free LU decomposition - # on a copy of ``A``. - int nmod_poly_mat_inv(nmod_poly_mat_t Ainv, nmod_poly_t den, const nmod_poly_mat_t A) noexcept - # Sets (``Ainv``, ``den``) to the inverse matrix of ``A``. - # Returns 1 if ``A`` is nonsingular and 0 if ``A`` is singular. - # Aliasing of ``Ainv`` and ``A`` is allowed. - # More precisely, ``det`` will be set to the determinant of ``A`` - # and ``Ainv`` will be set to the adjugate matrix of ``A``. - # Note that the determinant is not necessarily the minimal denominator. - # Uses fraction-free LU decomposition, followed by solving for - # the identity matrix. - slong nmod_poly_mat_nullspace(nmod_poly_mat_t res, const nmod_poly_mat_t mat) noexcept - # Computes the right rational nullspace of the matrix ``mat`` and - # returns the nullity. - # More precisely, assume that ``mat`` has rank `r` and nullity `n`. - # Then this function sets the first `n` columns of ``res`` - # to linearly independent vectors spanning the nullspace of ``mat``. - # As a result, we always have rank(``res``) `= n`, and - # ``mat`` `\times` ``res`` is the zero matrix. - # The computed basis vectors will not generally be in a reduced form. - # In general, the polynomials in each column vector in the result - # will have a nontrivial common GCD. - int nmod_poly_mat_solve(nmod_poly_mat_t X, nmod_poly_t den, const nmod_poly_mat_t A, const nmod_poly_mat_t B) noexcept - # Solves the equation `AX = B` for nonsingular `A`. More precisely, computes - # (``X``, ``den``) such that `AX = B \times \operatorname{den}`. - # Returns 1 if `A` is nonsingular and 0 if `A` is singular. - # The computed denominator will not generally be minimal. - # Uses fraction-free LU decomposition followed by fraction-free - # forward and back substitution. - int nmod_poly_mat_solve_fflu(nmod_poly_mat_t X, nmod_poly_t den, const nmod_poly_mat_t A, const nmod_poly_mat_t B) noexcept - # Solves the equation `AX = B` for nonsingular `A`. More precisely, computes - # (``X``, ``den``) such that `AX = B \times \operatorname{den}`. - # Returns 1 if `A` is nonsingular and 0 if `A` is singular. - # The computed denominator will not generally be minimal. - # Uses fraction-free LU decomposition followed by fraction-free - # forward and back substitution. - void nmod_poly_mat_solve_fflu_precomp(nmod_poly_mat_t X, const slong * perm, const nmod_poly_mat_t FFLU, const nmod_poly_mat_t B) noexcept - # Performs fraction-free forward and back substitution given a precomputed - # fraction-free LU decomposition and corresponding permutation. diff --git a/src/sage/libs/flint/nmod_vec.pxd b/src/sage/libs/flint/nmod_vec.pxd index 9bb2a6839e3..326ea21b98a 100644 --- a/src/sage/libs/flint/nmod_vec.pxd +++ b/src/sage/libs/flint/nmod_vec.pxd @@ -2,7 +2,9 @@ # distutils: depends = flint/nmod_vec.h ################################################################################ -# This file is auto-generated. Do not modify by hand +# This file is auto-generated by the script +# SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py. +# Do not modify by hand! Fix and rerun the script instead. ################################################################################ from libc.stdio cimport FILE @@ -11,99 +13,26 @@ from sage.libs.mpfr.types cimport * from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - mp_ptr _nmod_vec_init(slong len) noexcept - # Returns a vector of the given length. The entries are not necessarily - # zero. - void _nmod_vec_clear(mp_ptr vec) noexcept - # Frees the memory used by the given vector. - void _nmod_vec_randtest(mp_ptr vec, flint_rand_t state, slong len, nmod_t mod) noexcept - # Sets ``vec`` to a random vector of the given length with entries - # reduced modulo ``mod.n``. - void _nmod_vec_set(mp_ptr res, mp_srcptr vec, slong len) noexcept - # Copies ``len`` entries from the vector ``vec`` to ``res``. - void _nmod_vec_zero(mp_ptr vec, slong len) noexcept - # Zeros the given vector of the given length. - void _nmod_vec_swap(mp_ptr a, mp_ptr b, slong length) noexcept - # Swaps the vectors ``a`` and ``b`` of length `n` by actually - # swapping the entries. - void _nmod_vec_reduce(mp_ptr res, mp_srcptr vec, slong len, nmod_t mod) noexcept - # Reduces the entries of ``(vec, len)`` modulo ``mod.n`` and set - # ``res`` to the result. - flint_bitcnt_t _nmod_vec_max_bits(mp_srcptr vec, slong len) noexcept - # Returns the maximum number of bits of any entry in the vector. - bint _nmod_vec_equal(mp_srcptr vec, mp_srcptr vec2, slong len) noexcept - # Returns~`1` if ``(vec, len)`` is equal to ``(vec2, len)``, - # otherwise returns~`0`. - void _nmod_vec_print_pretty(mp_srcptr vec, slong len, nmod_t mod) noexcept - # Pretty-prints ``vec`` to ``stdout``. A header is printed followed by the - # vector enclosed in brackets. Each entry is right-aligned to the width of - # the modulus written in decimal, and the entries are separated by spaces. - # For example:: - # - # [ 33 181 107 61 32 11 80 138 34 171 86 156] - int _nmod_vec_fprint_pretty(FILE * file, mp_srcptr vec, slong len, nmod_t mod) noexcept - # Same as ``_nmod_vec_print_pretty`` but printing to ``file``. - int _nmod_vec_print(mp_srcptr vec, slong len, nmod_t mod) noexcept - # Currently, same as ``_nmod_vec_print_pretty``. - int _nmod_vec_fprint(FILE * f, mp_srcptr vec, slong len, nmod_t mod) noexcept - # Currently, same as ``_nmod_vec_fprint_pretty``. - void _nmod_vec_add(mp_ptr res, mp_srcptr vec1, mp_srcptr vec2, slong len, nmod_t mod) noexcept - # Sets ``(res, len)`` to the sum of ``(vec1, len)`` - # and ``(vec2, len)``. - void _nmod_vec_sub(mp_ptr res, mp_srcptr vec1, mp_srcptr vec2, slong len, nmod_t mod) noexcept - # Sets ``(res, len)`` to the difference of ``(vec1, len)`` - # and ``(vec2, len)``. - void _nmod_vec_neg(mp_ptr res, mp_srcptr vec, slong len, nmod_t mod) noexcept - # Sets ``(res, len)`` to the negation of ``(vec, len)``. - void _nmod_vec_scalar_mul_nmod(mp_ptr res, mp_srcptr vec, slong len, mp_limb_t c, nmod_t mod) noexcept - # Sets ``(res, len)`` to ``(vec, len)`` multiplied by `c`. The element - # `c` and all elements of `vec` are assumed to be less than `mod.n`. - void _nmod_vec_scalar_mul_nmod_shoup(mp_ptr res, mp_srcptr vec, slong len, mp_limb_t c, nmod_t mod) noexcept - # Sets ``(res, len)`` to ``(vec, len)`` multiplied by `c` using - # :func:`n_mulmod_shoup`. `mod.n` should be less than `2^{\mathtt{FLINT\_BITS} - 1}`. `c` - # and all elements of `vec` should be less than `mod.n`. - void _nmod_vec_scalar_addmul_nmod(mp_ptr res, mp_srcptr vec, slong len, mp_limb_t c, nmod_t mod) noexcept - # Adds ``(vec, len)`` times `c` to the vector ``(res, len)``. The element - # `c` and all elements of `vec` are assumed to be less than `mod.n`. - int _nmod_vec_dot_bound_limbs(slong len, nmod_t mod) noexcept - # Returns the number of limbs (0, 1, 2 or 3) needed to represent the - # unreduced dot product of two vectors of length ``len`` having entries - # modulo ``mod.n``, assuming that ``len`` is nonnegative and that - # ``mod.n`` is nonzero. The computed bound is tight. In other words, - # this function returns the precise limb size of ``len`` times - # ``(mod.n - 1) ^ 2``. - mp_limb_t _nmod_vec_dot(mp_srcptr vec1, mp_srcptr vec2, slong len, nmod_t mod, int nlimbs) noexcept - # Returns the dot product of (``vec1``, ``len``) and - # (``vec2``, ``len``). The ``nlimbs`` parameter should be - # 0, 1, 2 or 3, specifying the number of limbs needed to represent the - # unreduced result. - mp_limb_t _nmod_vec_dot_rev(mp_srcptr vec1, mp_srcptr vec2, slong len, nmod_t mod, int nlimbs) noexcept - # The same as ``_nmod_vec_dot``, but reverses ``vec2``. - mp_limb_t _nmod_vec_dot_ptr(mp_srcptr vec1, const mp_ptr * vec2, slong offset, slong len, nmod_t mod, int nlimbs) noexcept - # Returns the dot product of (``vec1``, ``len``) and the values at - # ``vec2[i][offset]``. The ``nlimbs`` parameter should be - # 0, 1, 2 or 3, specifying the number of limbs needed to represent the - # unreduced result. diff --git a/src/sage/libs/flint/padic.pxd b/src/sage/libs/flint/padic.pxd index c88cf07dc3f..ef190a51a9e 100644 --- a/src/sage/libs/flint/padic.pxd +++ b/src/sage/libs/flint/padic.pxd @@ -2,7 +2,9 @@ # distutils: depends = flint/padic.h ################################################################################ -# This file is auto-generated. Do not modify by hand +# This file is auto-generated by the script +# SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py. +# Do not modify by hand! Fix and rerun the script instead. ################################################################################ from libc.stdio cimport FILE @@ -11,385 +13,79 @@ from sage.libs.mpfr.types cimport * from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - fmpz * padic_unit(const padic_t op) noexcept - # Returns the unit part of the `p`-adic number as a FLINT integer, which - # can be used as an operand for the ``fmpz`` functions. - slong padic_val(const padic_t op) noexcept - # Returns the valuation part of the `p`-adic number. - # Note that this function is implemented as a macro and that - # the expression ``padic_val(op)`` can be used as both an - # *lvalue* and an *rvalue*. - slong padic_get_val(const padic_t op) noexcept - # Returns the valuation part of the `p`-adic number. - slong padic_prec(const padic_t op) noexcept - # Returns the precision of the `p`-adic number. - # Note that this function is implemented as a macro and that - # the expression ``padic_prec(op)`` can be used as both an - # *lvalue* and an *rvalue*. - slong padic_get_prec(const padic_t op) noexcept - # Returns the precision of the `p`-adic number. - void padic_ctx_init(padic_ctx_t ctx, const fmpz_t p, slong min, slong max, padic_print_mode mode) noexcept - # Initialises the context ``ctx`` with the given data. - # Assumes that `p` is a prime. This is not verified but the subsequent - # behaviour is undefined if `p` is a composite number. - # Assumes that ``min`` and ``max`` are non-negative and that - # ``min`` is at most ``max``, raising an ``abort`` signal - # otherwise. - # Assumes that the printing mode is one of ``PADIC_TERSE``, - # ``PADIC_SERIES``, or ``PADIC_VAL_UNIT``. Using the example - # `x = 7^{-1} 12` in `\mathbf{Q}_7`, these behave as follows: - # In ``PADIC_TERSE`` mode, a `p`-adic number is printed - # in the same way as a rational number, e.g. ``12/7``. - # In ``PADIC_SERIES`` mode, a `p`-adic number is printed - # digit by digit, e.g. ``5*7^-1 + 1``. - # In ``PADIC_VAL_UNIT`` mode, a `p`-adic number is - # printed showing the valuation and unit parts separately, - # e.g. ``12*7^-1``. - void padic_ctx_clear(padic_ctx_t ctx) noexcept - # Clears all memory that has been allocated as part of the context. - int _padic_ctx_pow_ui(fmpz_t rop, ulong e, const padic_ctx_t ctx) noexcept - # Sets ``rop`` to `p^e` as efficiently as possible, where - # ``rop`` is expected to be an uninitialised ``fmpz_t``. - # If the return value is non-zero, it is the responsibility of - # the caller to clear the returned integer. - void padic_init(padic_t rop) noexcept - # Initialises the `p`-adic number with the precision set to - # ``PADIC_DEFAULT_PREC``, which is defined as `20`. - void padic_init2(padic_t rop, slong N) noexcept - # Initialises the `p`-adic number ``rop`` with precision `N`. - void padic_clear(padic_t rop) noexcept - # Clears all memory used by the `p`-adic number ``rop``. - void _padic_canonicalise(padic_t rop, const padic_ctx_t ctx) noexcept - # Brings the `p`-adic number ``rop`` into canonical form. - # That is to say, ensures that either `u = v = 0` or - # `p \nmid u`. There is no reduction modulo a power - # of `p`. - void _padic_reduce(padic_t rop, const padic_ctx_t ctx) noexcept - # Given a `p`-adic number ``rop`` in canonical form, - # reduces it modulo `p^N`. - void padic_reduce(padic_t rop, const padic_ctx_t ctx) noexcept - # Ensures that the `p`-adic number ``rop`` is reduced. - void padic_randtest(padic_t rop, flint_rand_t state, const padic_ctx_t ctx) noexcept - # Sets ``rop`` to a random `p`-adic number modulo `p^N` with valuation - # in the range `[- \lceil N/10\rceil, N)`, `[N - \lceil -N/10\rceil, N)`, or `[-10, 0)` - # as `N` is positive, negative or zero, whenever ``rop`` is non-zero. - void padic_randtest_not_zero(padic_t rop, flint_rand_t state, const padic_ctx_t ctx) noexcept - # Sets ``rop`` to a random non-zero `p`-adic number modulo `p^N`, - # where the range of the valuation is as for the function - # :func:`padic_randtest`. - void padic_randtest_int(padic_t rop, flint_rand_t state, const padic_ctx_t ctx) noexcept - # Sets ``rop`` to a random `p`-adic integer modulo `p^N`. - # Note that whenever `N \leq 0`, ``rop`` is set to zero. - void padic_set(padic_t rop, const padic_t op, const padic_ctx_t ctx) noexcept - # Sets ``rop`` to the `p`-adic number ``op``. - void padic_set_si(padic_t rop, slong op, const padic_ctx_t ctx) noexcept - # Sets the `p`-adic number ``rop`` to the - # ``slong`` integer ``op``. - void padic_set_ui(padic_t rop, ulong op, const padic_ctx_t ctx) noexcept - # Sets the `p`-adic number ``rop`` to the ``ulong`` - # integer ``op``. - void padic_set_fmpz(padic_t rop, const fmpz_t op, const padic_ctx_t ctx) noexcept - # Sets the `p`-adic number ``rop`` to the integer ``op``. - void padic_set_fmpq(padic_t rop, const fmpq_t op, const padic_ctx_t ctx) noexcept - # Sets ``rop`` to the rational ``op``. - void padic_set_mpz(padic_t rop, const mpz_t op, const padic_ctx_t ctx) noexcept - # Sets the `p`-adic number ``rop`` to the MPIR integer ``op``. - void padic_set_mpq(padic_t rop, const mpq_t op, const padic_ctx_t ctx) noexcept - # Sets ``rop`` to the MPIR rational ``op``. - void padic_get_fmpz(fmpz_t rop, const padic_t op, const padic_ctx_t ctx) noexcept - # Sets the integer ``rop`` to the exact `p`-adic integer ``op``. - # If ``op`` is not a `p`-adic integer, raises an ``abort`` signal. - void padic_get_fmpq(fmpq_t rop, const padic_t op, const padic_ctx_t ctx) noexcept - # Sets the rational ``rop`` to the `p`-adic number ``op``. - void padic_get_mpz(mpz_t rop, const padic_t op, const padic_ctx_t ctx) noexcept - # Sets the MPIR integer ``rop`` to the `p`-adic integer ``op``. - # If ``op`` is not a `p`-adic integer, raises an ``abort`` signal. - void padic_get_mpq(mpq_t rop, const padic_t op, const padic_ctx_t ctx) noexcept - # Sets the MPIR rational ``rop`` to the value of ``op``. - void padic_swap(padic_t op1, padic_t op2) noexcept - # Swaps the two `p`-adic numbers ``op1`` and ``op2``. - # Note that this includes swapping the precisions. In particular, this - # operation is not equivalent to swapping ``op1`` and ``op2`` - # using :func:`padic_set` and an auxiliary variable whenever the - # precisions of the two elements are different. - void padic_zero(padic_t rop) noexcept - # Sets the `p`-adic number ``rop`` to zero. - void padic_one(padic_t rop) noexcept - # Sets the `p`-adic number ``rop`` to one, reduced modulo the - # precision of ``rop``. - bint padic_is_zero(const padic_t op) noexcept - # Returns whether ``op`` is equal to zero. - bint padic_is_one(const padic_t op) noexcept - # Returns whether ``op`` is equal to one, that is, whether - # `u = 1` and `v = 0`. - bint padic_equal(const padic_t op1, const padic_t op2) noexcept - # Returns whether ``op1`` and ``op2`` are equal, that is, - # whether `u_1 = u_2` and `v_1 = v_2`. - - slong * _padic_lifts_exps(slong *n, slong N) noexcept - # Given a positive integer `N` define the sequence - # `a_0 = N, a_1 = \lceil a_0/2\rceil, \dotsc, a_{n-1} = \lceil a_{n-2}/2\rceil = 1`. - # Then `n = \lceil\log_2 N\rceil + 1`. - # This function sets `n` and allocates and returns the array `a`. - - void _padic_lifts_pows(fmpz *pow, const slong *a, slong n, const fmpz_t p) noexcept - # Given an array `a` as computed above, this function - # computes the corresponding powers of `p`, that is, - # ``pow[i]`` is equal to `p^{a_i}`. - + slong * _padic_lifts_exps(slong * n, slong N) noexcept + void _padic_lifts_pows(fmpz * pow, const slong * a, slong n, const fmpz_t p) noexcept void padic_add(padic_t rop, const padic_t op1, const padic_t op2, const padic_ctx_t ctx) noexcept - # Sets ``rop`` to the sum of ``op1`` and ``op2``. - void padic_sub(padic_t rop, const padic_t op1, const padic_t op2, const padic_ctx_t ctx) noexcept - # Sets ``rop`` to the difference of ``op1`` and ``op2``. - void padic_neg(padic_t rop, const padic_t op, const padic_ctx_t ctx) noexcept - # Sets ``rop`` to the additive inverse of ``op``. - void padic_mul(padic_t rop, const padic_t op1, const padic_t op2, const padic_ctx_t ctx) noexcept - # Sets ``rop`` to the product of ``op1`` and ``op2``. - void padic_shift(padic_t rop, const padic_t op, slong v, const padic_ctx_t ctx) noexcept - # Sets ``rop`` to the product of ``op`` and `p^v`. - void padic_div(padic_t rop, const padic_t op1, const padic_t op2, const padic_ctx_t ctx) noexcept - # Sets ``rop`` to the quotient of ``op1`` and ``op2``. - void _padic_inv_precompute(padic_inv_t S, const fmpz_t p, slong N) noexcept - # Pre-computes some data and allocates temporary space for - # `p`-adic inversion using Hensel lifting. - void _padic_inv_clear(padic_inv_t S) noexcept - # Frees the memory used by `S`. - void _padic_inv_precomp(fmpz_t rop, const fmpz_t op, const padic_inv_t S) noexcept - # Sets ``rop`` to the inverse of ``op`` modulo `p^N`, - # assuming that ``op`` is a unit and `N \geq 1`. - # In the current implementation, allows aliasing, but this might - # change in future versions. - # Uses some data `S` precomputed by calling the function - # :func:`_padic_inv_precompute`. Note that this object - # is not declared ``const`` and in fact it carries a field - # providing temporary work space. This allows repeated calls of - # this function to avoid repeated memory allocations, as used - # e.g. by the function :func:`padic_log`. - void _padic_inv(fmpz_t rop, const fmpz_t op, const fmpz_t p, slong N) noexcept - # Sets ``rop`` to the inverse of ``op`` modulo `p^N`, - # assuming that ``op`` is a unit and `N \geq 1`. - # In the current implementation, allows aliasing, but this might - # change in future versions. - void padic_inv(padic_t rop, const padic_t op, const padic_ctx_t ctx) noexcept - # Computes the inverse of ``op`` modulo `p^N`. - # Suppose that ``op`` is given as `x = u p^v`. - # Raises an ``abort`` signal if `v < -N`. Otherwise, - # computes the inverse of `u` modulo `p^{N+v}`. - # This function employs Hensel lifting of an inverse modulo `p`. - int padic_sqrt(padic_t rop, const padic_t op, const padic_ctx_t ctx) noexcept - # Returns whether ``op`` is a `p`-adic square. If this is - # the case, sets ``rop`` to one of the square roots; otherwise, - # the value of ``rop`` is undefined. - # We have the following theorem: - # Let `u \in \mathbf{Z}^{\times}`. Then `u` is a - # square if and only if `u \bmod p` is a square in - # `\mathbf{Z} / p \mathbf{Z}`, for `p > 2`, or if - # `u \bmod 8` is a square in `\mathbf{Z} / 8 \mathbf{Z}`, - # for `p = 2`. - void padic_pow_si(padic_t rop, const padic_t op, slong e, const padic_ctx_t ctx) noexcept - # Sets ``rop`` to ``op`` raised to the power `e`, - # which is defined as one whenever `e = 0`. - # Assumes that some computations involving `e` and the - # valuation of ``op`` do not overflow in the ``slong`` - # range. - # Note that if the input `x = p^v u` is defined modulo `p^N` - # then `x^e = p^{ev} u^e` is defined modulo `p^{N + (e - 1) v}`, - # which is a precision loss in case `v < 0`. - slong _padic_exp_bound(slong v, slong N, const fmpz_t p) noexcept - # Returns an integer `i` such that for all `j \geq i` we have - # `\operatorname{ord}_p(x^j / j!) \geq N`, where `\operatorname{ord}_p(x) = v`. - # When `p` is a word-sized prime, - # returns `\left\lceil \frac{(p-1)N - 1}{(p-1)v - 1}\right\rceil`. - # Otherwise, returns `\lceil N/v\rceil`. - # Assumes that `v < N`. Moreover, `v` has to be at least `2` or `1`, - # depending on whether `p` is `2` or odd. - void _padic_exp_rectangular(fmpz_t rop, const fmpz_t u, slong v, const fmpz_t p, slong N) noexcept void _padic_exp_balanced(fmpz_t rop, const fmpz_t u, slong v, const fmpz_t p, slong N) noexcept void _padic_exp(fmpz_t rop, const fmpz_t u, slong v, const fmpz_t p, slong N) noexcept - # Sets ``rop`` to the `p`-exponential function evaluated at - # `x = p^v u`, reduced modulo `p^N`. - # Assumes that `x \neq 0`, that `\operatorname{ord}_p(x) < N` and that - # `\exp(x)` converges, that is, that `\operatorname{ord}_p(x)` is at least - # `2` or `1` depending on whether the prime `p` is `2` or odd. - # Supports aliasing between ``rop`` and `u`. - int padic_exp(padic_t y, const padic_t x, const padic_ctx_t ctx) noexcept - # Returns whether the `p`-adic exponential function converges at - # the `p`-adic number `x`, and if so sets `y` to its value. - # The `p`-adic exponential function is defined by the usual series - # .. math :: - # \exp_p(x) = \sum_{i = 0}^{\infty} \frac{x^i}{i!} - # but this only converges only when `\operatorname{ord}_p(x) > 1 / (p - 1)`. For - # elements `x \in \mathbf{Q}_p`, this means that `\operatorname{ord}_p(x) \geq 1` - # when `p \geq 3` and `\operatorname{ord}_2(x) \geq 2` when `p = 2`. - int padic_exp_rectangular(padic_t y, const padic_t x, const padic_ctx_t ctx) noexcept - # Returns whether the `p`-adic exponential function converges at - # the `p`-adic number `x`, and if so sets `y` to its value. - # Uses a rectangular splitting algorithm to evaluate the series - # expression of `\exp(x) \bmod{p^N}`. - int padic_exp_balanced(padic_t y, const padic_t x, const padic_ctx_t ctx) noexcept - # Returns whether the `p`-adic exponential function converges at - # the `p`-adic number `x`, and if so sets `y` to its value. - # Uses a balanced approach, balancing the size of chunks of `x` - # with the valuation and hence the rate of convergence, which - # results in a quasi-linear algorithm in `N`, for fixed `p`. - slong _padic_log_bound(slong v, slong N, const fmpz_t p) noexcept - # Returns `b` such that for all `i \geq b` we have - # .. math :: - # i v - \operatorname{ord}_p(i) \geq N - # where `v \geq 1`. - # Assumes that `1 \leq v < N` or `2 \leq v < N` when `p` is - # odd or `p = 2`, respectively, and also that `N < 2^{f-2}` - # where `f` is ``FLINT_BITS``. - void _padic_log(fmpz_t z, const fmpz_t y, slong v, const fmpz_t p, slong N) noexcept void _padic_log_rectangular(fmpz_t z, const fmpz_t y, slong v, const fmpz_t p, slong N) noexcept void _padic_log_satoh(fmpz_t z, const fmpz_t y, slong v, const fmpz_t p, slong N) noexcept void _padic_log_balanced(fmpz_t z, const fmpz_t y, slong v, const fmpz_t p, slong N) noexcept - # Computes - # .. math :: - # z = - \sum_{i = 1}^{\infty} \frac{y^i}{i} \pmod{p^N}, - # reduced modulo `p^N`. - # Note that this can be used to compute the `p`-adic logarithm - # via the equation - # .. math :: - # \log(x) & = \sum_{i=1}^{\infty} (-1)^{i-1} \frac{(x-1)^i}{i} \\ - # & = - \sum_{i=1}^{\infty} \frac{(1-x)^i}{i}. - # Assumes that `y = 1 - x` is non-zero and that `v = \operatorname{ord}_p(y)` - # is at least `1` when `p` is odd and at least `2` when `p = 2` - # so that the series converges. - # Assumes that `v < N`, and hence in particular `N \geq 2`. - # Does not support aliasing between `y` and `z`. - int padic_log(padic_t rop, const padic_t op, const padic_ctx_t ctx) noexcept - # Returns whether the `p`-adic logarithm function converges at - # the `p`-adic number ``op``, and if so sets ``rop`` to its - # value. - # The `p`-adic logarithm function is defined by the usual series - # .. math :: - # \log_p(x) = \sum_{i=1}^{\infty} (-1)^{i-1} \frac{(x-1)^i}{i} - # but this only converges when `\operatorname{ord}_p(x - 1)` is at least `2` - # or `1` when `p = 2` or `p > 2`, respectively. - int padic_log_rectangular(padic_t rop, const padic_t op, const padic_ctx_t ctx) noexcept - # Returns whether the `p`-adic logarithm function converges at - # the `p`-adic number ``op``, and if so sets ``rop`` to its - # value. - # Uses a rectangular splitting algorithm to evaluate the series - # expression of `\log(x) \bmod{p^N}`. - int padic_log_satoh(padic_t rop, const padic_t op, const padic_ctx_t ctx) noexcept - # Returns whether the `p`-adic logarithm function converges at - # the `p`-adic number ``op``, and if so sets ``rop`` to its - # value. - # Uses an algorithm based on a result of Satoh, Skjernaa and Taguchi - # that `\operatorname{ord}_p\bigl(a^{p^k} - 1\bigr) > k`, which implies that - # .. math :: - # \log(a) \equiv p^{-k} \Bigl( \log\bigl(a^{p^k}\bigr) \pmod{p^{N+k}} - # \Bigr) \pmod{p^N}. - int padic_log_balanced(padic_t rop, const padic_t op, const padic_ctx_t ctx) noexcept - # Returns whether the `p`-adic logarithm function converges at - # the `p`-adic number ``op``, and if so sets ``rop`` to its - # value. - void _padic_teichmuller(fmpz_t rop, const fmpz_t op, const fmpz_t p, slong N) noexcept - # Computes the Teichm\"uller lift of the `p`-adic unit ``op``, - # assuming that `N \geq 1`. - # Supports aliasing between ``rop`` and ``op``. - void padic_teichmuller(padic_t rop, const padic_t op, const padic_ctx_t ctx) noexcept - # Computes the Teichm\"uller lift of the `p`-adic unit ``op``. - # If ``op`` is a `p`-adic integer divisible by `p`, sets ``rop`` - # to zero, which satisfies `t^p - t = 0`, although it is clearly not - # a `(p-1)`-st root of unity. - # If ``op`` has negative valuation, raises an ``abort`` signal. - ulong padic_val_fac_ui_2(ulong n) noexcept - # Computes the `2`-adic valuation of `n!`. - # Note that since `n` fits into an ``ulong``, so does - # `\operatorname{ord}_2(n!)` since `\operatorname{ord}_2(n!) \leq (n - 1) / (p - 1) = n - 1`. - ulong padic_val_fac_ui(ulong n, const fmpz_t p) noexcept - # Computes the `p`-adic valuation of `n!`. - # Note that since `n` fits into an ``ulong``, so does - # `\operatorname{ord}_p(n!)` since `\operatorname{ord}_p(n!) \leq (n - 1) / (p - 1)`. - void padic_val_fac(fmpz_t rop, const fmpz_t op, const fmpz_t p) noexcept - # Sets ``rop`` to the `p`-adic valuation of the factorial - # of ``op``, assuming that ``op`` is non-negative. - char * padic_get_str(char * str, const padic_t op, const padic_ctx_t ctx) noexcept - # Returns the string representation of the `p`-adic number ``op`` - # according to the printing mode set in the context. - # If ``str`` is ``NULL`` then a new block of memory is allocated - # and a pointer to this is returned. Otherwise, it is assumed that - # the string ``str`` is large enough to hold the representation and - # it is also the return value. - int _padic_fprint(FILE * file, const fmpz_t u, slong v, const padic_ctx_t ctx) noexcept int padic_fprint(FILE * file, const padic_t op, const padic_ctx_t ctx) noexcept - # Prints the string representation of the `p`-adic number ``op`` - # to the stream ``file``. - # In the current implementation, always returns `1`. - int _padic_print(const fmpz_t u, slong v, const padic_ctx_t ctx) noexcept int padic_print(const padic_t op, const padic_ctx_t ctx) noexcept - # Prints the string representation of the `p`-adic number ``op`` - # to the stream ``stdout``. - # In the current implementation, always returns `1`. - void padic_debug(const padic_t op) noexcept - # Prints debug information about ``op`` to the stream ``stdout``, - # in the format ``"(u v N)"``. diff --git a/src/sage/libs/flint/padic_mat.pxd b/src/sage/libs/flint/padic_mat.pxd index 1d5e8ea44ac..4a64baa9b1f 100644 --- a/src/sage/libs/flint/padic_mat.pxd +++ b/src/sage/libs/flint/padic_mat.pxd @@ -2,7 +2,9 @@ # distutils: depends = flint/padic_mat.h ################################################################################ -# This file is auto-generated. Do not modify by hand +# This file is auto-generated by the script +# SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py. +# Do not modify by hand! Fix and rerun the script instead. ################################################################################ from libc.stdio cimport FILE @@ -11,173 +13,50 @@ from sage.libs.mpfr.types cimport * from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - fmpz_mat_struct * padic_mat(const padic_mat_t A) noexcept - # Returns a pointer to the unit part of the matrix, which - # is a matrix over `\mathbf{Z}`. - # The return value can be used as an argument to - # the functions in the ``fmpz_mat`` module. - fmpz * padic_mat_entry(const padic_mat_t A, slong i, slong j) noexcept - # Returns a pointer to unit part of the entry in position `(i, j)`. - # Note that this is not necessarily a unit. - # The return value can be used as an argument to - # the functions in the ``fmpz`` module. - slong padic_mat_val(const padic_mat_t A) noexcept - # Allow access (as L-value or R-value) to ``val`` field of `A`. - # This function is implemented as a macro. - slong padic_mat_prec(const padic_mat_t A) noexcept - # Allow access (as L-value or R-value) to ``prec`` field of `A`. - # This function is implemented as a macro. - slong padic_mat_get_val(const padic_mat_t A) noexcept - # Returns the valuation of the matrix. - slong padic_mat_get_prec(const padic_mat_t A) noexcept - # Returns the `p`-adic precision of the matrix. - slong padic_mat_nrows(const padic_mat_t A) noexcept - # Returns the number of rows of the matrix `A`. - slong padic_mat_ncols(const padic_mat_t A) noexcept - # Returns the number of columns of the matrix `A`. - void padic_mat_init(padic_mat_t A, slong r, slong c) noexcept - # Initialises the matrix `A` as a zero matrix with the specified numbers - # of rows and columns and precision ``PADIC_DEFAULT_PREC``. - void padic_mat_init2(padic_mat_t A, slong r, slong c, slong prec) noexcept - # Initialises the matrix `A` as a zero matrix with the specified numbers - # of rows and columns and the given precision. - void padic_mat_clear(padic_mat_t A) noexcept - # Clears the matrix `A`. - void _padic_mat_canonicalise(padic_mat_t A, const padic_ctx_t ctx) noexcept - # Ensures that the matrix `A` is in canonical form. - void _padic_mat_reduce(padic_mat_t A, const padic_ctx_t ctx) noexcept - # Ensures that the matrix `A` is reduced modulo `p^N`, - # assuming that it is in canonical form already. - void padic_mat_reduce(padic_mat_t A, const padic_ctx_t ctx) noexcept - # Ensures that the matrix `A` is reduced modulo `p^N`, - # without assuming that it is necessarily in canonical form. - bint padic_mat_is_empty(const padic_mat_t A) noexcept - # Returns whether the matrix `A` is empty, that is, - # whether it has zero rows or zero columns. - bint padic_mat_is_square(const padic_mat_t A) noexcept - # Returns whether the matrix `A` is square. - bint padic_mat_is_canonical(const padic_mat_t A, const padic_ctx_t p) noexcept - # Returns whether the matrix `A` is in canonical form. - void padic_mat_set(padic_mat_t B, const padic_mat_t A, const padic_ctx_t p) noexcept - # Sets `B` to a copy of `A`, respecting the precision of `B`. - void padic_mat_swap(padic_mat_t A, padic_mat_t B) noexcept - # Swaps the two matrices `A` and `B`. This is done efficiently by - # swapping pointers. - void padic_mat_swap_entrywise(padic_mat_t mat1, padic_mat_t mat2) noexcept - # Swaps two matrices by swapping the individual entries rather than swapping - # the contents of the structs. - void padic_mat_zero(padic_mat_t A) noexcept - # Sets the matrix `A` to zero. - void padic_mat_one(padic_mat_t A) noexcept - # Sets the matrix `A` to the identity matrix. If the precision - # is negative then the matrix will be the zero matrix. - void padic_mat_set_fmpq_mat(padic_mat_t B, const fmpq_mat_t A, const padic_ctx_t ctx) noexcept - # Sets the `p`-adic matrix `B` to the rational matrix `A`, reduced - # according to the given context. - void padic_mat_get_fmpq_mat(fmpq_mat_t B, const padic_mat_t A, const padic_ctx_t ctx) noexcept - # Sets the rational matrix `B` to the `p`-adic matrices `A`; - # no reduction takes place. - void padic_mat_get_entry_padic(padic_t rop, const padic_mat_t op, slong i, slong j, const padic_ctx_t ctx) noexcept - # Sets ``rop`` to the entry in position `(i, j)` in the matrix ``op``. - void padic_mat_set_entry_padic(padic_mat_t rop, slong i, slong j, const padic_t op, const padic_ctx_t ctx) noexcept - # Sets the entry in position `(i, j)` in the matrix to ``rop``. - bint padic_mat_equal(const padic_mat_t A, const padic_mat_t B) noexcept - # Returns whether the two matrices `A` and `B` are equal. - bint padic_mat_is_zero(const padic_mat_t A) noexcept - # Returns whether the matrix `A` is zero. - int padic_mat_fprint(FILE * file, const padic_mat_t A, const padic_ctx_t ctx) noexcept - # Prints a simple representation of the matrix `A` to the - # output stream ``file``. The format is the number of rows, - # a space, the number of columns, two spaces, followed by a list - # of all the entries, one row after the other. - # In the current implementation, always returns `1`. - int padic_mat_fprint_pretty(FILE * file, const padic_mat_t A, const padic_ctx_t ctx) noexcept - # Prints a *pretty* representation of the matrix `A` - # to the output stream ``file``. - # In the current implementation, always returns `1`. - int padic_mat_print(const padic_mat_t A, const padic_ctx_t ctx) noexcept int padic_mat_print_pretty(const padic_mat_t A, const padic_ctx_t ctx) noexcept - void padic_mat_randtest(padic_mat_t A, flint_rand_t state, const padic_ctx_t ctx) noexcept - # Sets `A` to a random matrix. - # The valuation will be in the range `[- \lceil N/10\rceil, N)`, - # `[N - \lceil -N/10\rceil, N)`, or `[-10, 0)` as `N` is positive, - # negative or zero. - void padic_mat_transpose(padic_mat_t B, const padic_mat_t A) noexcept - # Sets `B` to `A^t`. - void _padic_mat_add(padic_mat_t C, const padic_mat_t A, const padic_mat_t B, const padic_ctx_t ctx) noexcept - # Sets `C` to the exact sum `A + B`, ensuring that the result is in - # canonical form. - void padic_mat_add(padic_mat_t C, const padic_mat_t A, const padic_mat_t B, const padic_ctx_t ctx) noexcept - # Sets `C` to the sum `A + B` modulo `p^N`. - void _padic_mat_sub(padic_mat_t C, const padic_mat_t A, const padic_mat_t B, const padic_ctx_t ctx) noexcept - # Sets `C` to the exact difference `A - B`, ensuring that the result is in - # canonical form. - void padic_mat_sub(padic_mat_t C, const padic_mat_t A, const padic_mat_t B, const padic_ctx_t ctx) noexcept - # Sets `C` to `A - B`, ensuring that the result is reduced. - void _padic_mat_neg(padic_mat_t B, const padic_mat_t A) noexcept - # Sets `B` to `-A` in canonical form. - void padic_mat_neg(padic_mat_t B, const padic_mat_t A, const padic_ctx_t ctx) noexcept - # Sets `B` to `-A`, ensuring the result is reduced. - void _padic_mat_scalar_mul_padic(padic_mat_t B, const padic_mat_t A, const padic_t c, const padic_ctx_t ctx) noexcept - # Sets `B` to `c A`, ensuring that the result is in canonical form. - void padic_mat_scalar_mul_padic(padic_mat_t B, const padic_mat_t A, const padic_t c, const padic_ctx_t ctx) noexcept - # Sets `B` to `c A`, ensuring that the result is reduced. - void _padic_mat_scalar_mul_fmpz(padic_mat_t B, const padic_mat_t A, const fmpz_t c, const padic_ctx_t ctx) noexcept - # Sets `B` to `c A`, ensuring that the result is in canonical form. - void padic_mat_scalar_mul_fmpz(padic_mat_t B, const padic_mat_t A, const fmpz_t c, const padic_ctx_t ctx) noexcept - # Sets `B` to `c A`, ensuring that the result is reduced. - void padic_mat_scalar_div_fmpz(padic_mat_t B, const padic_mat_t A, const fmpz_t c, const padic_ctx_t ctx) noexcept - # Sets `B` to `c^{-1} A`, assuming that `c \neq 0`. - # Ensures that the result `B` is reduced. - void _padic_mat_mul(padic_mat_t C, const padic_mat_t A, const padic_mat_t B, const padic_ctx_t ctx) noexcept - # Sets `C` to the product `A B` of the two matrices `A` and `B`, - # ensuring that `C` is in canonical form. - void padic_mat_mul(padic_mat_t C, const padic_mat_t A, const padic_mat_t B, const padic_ctx_t ctx) noexcept - # Sets `C` to the product `A B` of the two matrices `A` and `B`, - # ensuring that `C` is reduced. diff --git a/src/sage/libs/flint/padic_poly.pxd b/src/sage/libs/flint/padic_poly.pxd index b50b49c9ddf..caca76b79db 100644 --- a/src/sage/libs/flint/padic_poly.pxd +++ b/src/sage/libs/flint/padic_poly.pxd @@ -2,7 +2,9 @@ # distutils: depends = flint/padic_poly.h ################################################################################ -# This file is auto-generated. Do not modify by hand +# This file is auto-generated by the script +# SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py. +# Do not modify by hand! Fix and rerun the script instead. ################################################################################ from libc.stdio cimport FILE @@ -11,342 +13,74 @@ from sage.libs.mpfr.types cimport * from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void padic_poly_init(padic_poly_t poly) noexcept - # Initialises ``poly`` for use, setting its length to zero. - # The precision of the polynomial is set to ``PADIC_DEFAULT_PREC``. - # A corresponding call to :func:`padic_poly_clear` must be made - # after finishing with the :type:`padic_poly_t` to free the memory - # used by the polynomial. - void padic_poly_init2(padic_poly_t poly, slong alloc, slong prec) noexcept - # Initialises ``poly`` with space for at least ``alloc`` coefficients - # and sets the length to zero. The allocated coefficients are all set to - # zero. The precision is set to ``prec``. - void padic_poly_realloc(padic_poly_t poly, slong alloc, const fmpz_t p) noexcept - # Reallocates the given polynomial to have space for ``alloc`` - # coefficients. If ``alloc`` is zero the polynomial is cleared - # and then reinitialised. If the current length is greater than - # ``alloc`` the polynomial is first truncated to length ``alloc``. - void padic_poly_fit_length(padic_poly_t poly, slong len) noexcept - # If ``len`` is greater than the number of coefficients currently - # allocated, then the polynomial is reallocated to have space for at - # least ``len`` coefficients. No data is lost when calling this - # function. - # The function efficiently deals with the case where ``fit_length`` is - # called many times in small increments by at least doubling the number - # of allocated coefficients when length is larger than the number of - # coefficients currently allocated. - void _padic_poly_set_length(padic_poly_t poly, slong len) noexcept - # Demotes the coefficients of ``poly`` beyond ``len`` and sets - # the length of ``poly`` to ``len``. - # Note that if the current length is greater than ``len`` the - # polynomial may no slonger be in canonical form. - void padic_poly_clear(padic_poly_t poly) noexcept - # Clears the given polynomial, releasing any memory used. It must - # be reinitialised in order to be used again. - void _padic_poly_normalise(padic_poly_t poly) noexcept - # Sets the length of ``poly`` so that the top coefficient is non-zero. - # If all coefficients are zero, the length is set to zero. This function - # is mainly used internally, as all functions guarantee normalisation. - - void _padic_poly_canonicalise(fmpz *poly, slong *v, slong len, const fmpz_t p) noexcept + void _padic_poly_canonicalise(fmpz * poly, slong * v, slong len, const fmpz_t p) noexcept void padic_poly_canonicalise(padic_poly_t poly, const fmpz_t p) noexcept - # Brings the polynomial ``poly`` into canonical form, - # assuming that it is normalised already. Does *not* - # carry out any reduction. - void padic_poly_reduce(padic_poly_t poly, const padic_ctx_t ctx) noexcept - # Reduces the polynomial ``poly`` modulo `p^N`, assuming - # that it is in canonical form already. - void padic_poly_truncate(padic_poly_t poly, slong n, const fmpz_t p) noexcept - # Truncates the polynomial to length at most~`n`. - slong padic_poly_degree(const padic_poly_t poly) noexcept - # Returns the degree of the polynomial ``poly``. - slong padic_poly_length(const padic_poly_t poly) noexcept - # Returns the length of the polynomial ``poly``. - slong padic_poly_val(const padic_poly_t poly) noexcept - # Returns the valuation of the polynomial ``poly``, - # which is defined to be the minimum valuation of all - # its coefficients. - # The valuation of the zero polynomial is~`0`. - # Note that this is implemented as a macro and can be - # used as either a ``lvalue`` or a ``rvalue``. - slong padic_poly_prec(padic_poly_t poly) noexcept - # Returns the precision of the polynomial ``poly``. - # Note that this is implemented as a macro and can be - # used as either a ``lvalue`` or a ``rvalue``. - # Note that increasing the precision might require - # a call to :func:`padic_poly_reduce`. - void padic_poly_randtest(padic_poly_t f, flint_rand_t state, slong len, const padic_ctx_t ctx) noexcept - # Sets `f` to a random polynomial of length at most ``len`` - # with entries reduced modulo `p^N`. - void padic_poly_randtest_not_zero(padic_poly_t f, flint_rand_t state, slong len, const padic_ctx_t ctx) noexcept - # Sets `f` to a non-zero random polynomial of length at most ``len`` - # with entries reduced modulo `p^N`. - void padic_poly_randtest_val(padic_poly_t f, flint_rand_t state, slong val, slong len, const padic_ctx_t ctx) noexcept - # Sets `f` to a random polynomial of length at most ``len`` - # with at most the prescribed valuation ``val`` and entries - # reduced modulo `p^N`. - # Specifically, we aim to set the valuation to be exactly equal - # to ``val``, but do not check for additional cancellation - # when creating the coefficients. - void padic_poly_set_padic(padic_poly_t poly, const padic_t x, const padic_ctx_t ctx) noexcept - # Sets the polynomial ``poly`` to the `p`-adic number `x`, - # reduced to the precision of the polynomial. - void padic_poly_set(padic_poly_t poly1, const padic_poly_t poly2, const padic_ctx_t ctx) noexcept - # Sets the polynomial ``poly1`` to the polynomial ``poly2``, - # reduced to the precision of ``poly1``. - void padic_poly_set_si(padic_poly_t poly, slong x, const padic_ctx_t ctx) noexcept - # Sets the polynomial ``poly`` to the ``signed slong`` - # integer `x` reduced to the precision of the polynomial. - void padic_poly_set_ui(padic_poly_t poly, ulong x, const padic_ctx_t ctx) noexcept - # Sets the polynomial ``poly`` to the ``unsigned slong`` - # integer `x` reduced to the precision of the polynomial. - void padic_poly_set_fmpz(padic_poly_t poly, const fmpz_t x, const padic_ctx_t ctx) noexcept - # Sets the polynomial ``poly`` to the integer `x` - # reduced to the precision of the polynomial. - void padic_poly_set_fmpq(padic_poly_t poly, const fmpq_t x, const padic_ctx_t ctx) noexcept - # Sets the polynomial ``poly`` to the value of the rational `x`, - # reduced to the precision of the polynomial. - void padic_poly_set_fmpz_poly(padic_poly_t rop, const fmpz_poly_t op, const padic_ctx_t ctx) noexcept - # Sets the polynomial ``rop`` to the integer polynomial ``op`` - # reduced to the precision of the polynomial. - void padic_poly_set_fmpq_poly(padic_poly_t rop, const fmpq_poly_t op, const padic_ctx_t ctx) noexcept - # Sets the polynomial ``rop`` to the value of the rational - # polynomial ``op``, reduced to the precision of the polynomial. - int padic_poly_get_fmpz_poly(fmpz_poly_t rop, const padic_poly_t op, const padic_ctx_t ctx) noexcept - # Sets the integer polynomial ``rop`` to the value of the `p`-adic - # polynomial ``op`` and returns `1` if the polynomial is `p`-adically - # integral. Otherwise, returns `0`. - void padic_poly_get_fmpq_poly(fmpq_poly_t rop, const padic_poly_t op, const padic_ctx_t ctx) noexcept - # Sets ``rop`` to the rational polynomial corresponding to - # the `p`-adic polynomial ``op``. - void padic_poly_zero(padic_poly_t poly) noexcept - # Sets ``poly`` to the zero polynomial. - void padic_poly_one(padic_poly_t poly) noexcept - # Sets ``poly`` to the constant polynomial `1`, - # reduced to the precision of the polynomial. - void padic_poly_swap(padic_poly_t poly1, padic_poly_t poly2) noexcept - # Swaps the two polynomials ``poly1`` and ``poly2``, - # including their precisions. - # This is done efficiently by swapping pointers. - void padic_poly_get_coeff_padic(padic_t c, const padic_poly_t poly, slong n, const padic_ctx_t ctx) noexcept - # Sets `c` to the coefficient of `x^n` in the polynomial, - # reduced modulo the precision of `c`. - void padic_poly_set_coeff_padic(padic_poly_t f, slong n, const padic_t c, const padic_ctx_t ctx) noexcept - # Sets the coefficient of `x^n` in the polynomial `f` to `c`, - # reduced to the precision of the polynomial `f`. - # Note that this operation can take linear time in the length - # of the polynomial. - bint padic_poly_equal(const padic_poly_t poly1, const padic_poly_t poly2) noexcept - # Returns whether the two polynomials ``poly1`` and ``poly2`` - # are equal. - bint padic_poly_is_zero(const padic_poly_t poly) noexcept - # Returns whether the polynomial ``poly`` is the zero polynomial. - bint padic_poly_is_one(const padic_poly_t poly) noexcept - # Returns whether the polynomial ``poly`` is equal - # to the constant polynomial~`1`, taking the precision - # of the polynomial into account. - - void _padic_poly_add(fmpz *rop, slong *rval, slong N, const fmpz *op1, slong val1, slong len1, slong N1, const fmpz *op2, slong val2, slong len2, slong N2, const padic_ctx_t ctx) noexcept - # Sets ``(rop, *val, FLINT_MAX(len1, len2)`` to the sum of - # ``(op1, val1, len1)`` and ``(op2, val2, len2)``. - # Assumes that the input is reduced and guarantees that this is - # also the case for the output. - # Assumes that `\min\{v_1, v_2\} < N`. - # Supports aliasing between the output and input arguments. - + void _padic_poly_add(fmpz * rop, slong * rval, slong N, const fmpz * op1, slong val1, slong len1, slong N1, const fmpz * op2, slong val2, slong len2, slong N2, const padic_ctx_t ctx) noexcept void padic_poly_add(padic_poly_t f, const padic_poly_t g, const padic_poly_t h, const padic_ctx_t ctx) noexcept - # Sets `f` to the sum `g + h`. - - void _padic_poly_sub(fmpz *rop, slong *rval, slong N, const fmpz *op1, slong val1, slong len1, slong N1, const fmpz *op2, slong val2, slong len2, slong N2, const padic_ctx_t ctx) noexcept - # Sets ``(rop, *val, FLINT_MAX(len1, len2)`` to the difference of - # ``(op1, val1, len1)`` and ``(op2, val2, len2)``. - # Assumes that the input is reduced and guarantees that this is - # also the case for the output. - # Assumes that `\min\{v_1, v_2\} < N`. - # Support aliasing between the output and input arguments. - + void _padic_poly_sub(fmpz * rop, slong * rval, slong N, const fmpz * op1, slong val1, slong len1, slong N1, const fmpz * op2, slong val2, slong len2, slong N2, const padic_ctx_t ctx) noexcept void padic_poly_sub(padic_poly_t f, const padic_poly_t g, const padic_poly_t h, const padic_ctx_t ctx) noexcept - # Sets `f` to the difference `g - h`. - void padic_poly_neg(padic_poly_t f, const padic_poly_t g, const padic_ctx_t ctx) noexcept - # Sets `f` to `-g`. - - void _padic_poly_scalar_mul_padic(fmpz *rop, slong *rval, slong N, const fmpz *op, slong val, slong len, const padic_t c, const padic_ctx_t ctx) noexcept - # Sets ``(rop, *rval, len)`` to ``(op, val, len)`` multiplied - # by the scalar `c`. - # The result will only be correctly reduced if the polynomial - # is non-zero. Otherwise, the array ``(rop, len)`` will be - # set to zero but the valuation ``*rval`` might be wrong. - + void _padic_poly_scalar_mul_padic(fmpz * rop, slong * rval, slong N, const fmpz * op, slong val, slong len, const padic_t c, const padic_ctx_t ctx) noexcept void padic_poly_scalar_mul_padic(padic_poly_t rop, const padic_poly_t op, const padic_t c, const padic_ctx_t ctx) noexcept - # Sets the polynomial ``rop`` to the product of the - # polynomial ``op`` and the `p`-adic number `c`, - # reducing the result modulo `p^N`. - - void _padic_poly_mul(fmpz *rop, slong *rval, slong N, const fmpz *op1, slong val1, slong len1, const fmpz *op2, slong val2, slong len2, const padic_ctx_t ctx) noexcept - # Sets ``(rop, *rval, len1 + len2 - 1)`` to the product of - # ``(op1, val1, len1)`` and ``(op2, val2, len2)``. - # Assumes that the resulting valuation ``*rval``, which is - # the sum of the valuations ``val1`` and ``val2``, is less - # than the precision~`N` of the context. - # Assumes that ``len1 >= len2 > 0``. - + void _padic_poly_mul(fmpz * rop, slong * rval, slong N, const fmpz * op1, slong val1, slong len1, const fmpz * op2, slong val2, slong len2, const padic_ctx_t ctx) noexcept void padic_poly_mul(padic_poly_t res, const padic_poly_t poly1, const padic_poly_t poly2, const padic_ctx_t ctx) noexcept - # Sets the polynomial ``res`` to the product of the two polynomials - # ``poly1`` and ``poly2``, reduced modulo `p^N`. - - void _padic_poly_pow(fmpz *rop, slong *rval, slong N, const fmpz *op, slong val, slong len, ulong e, const padic_ctx_t ctx) noexcept - # Sets the polynomial ``(rop, *rval, e (len - 1) + 1)`` to the - # polynomial ``(op, val, len)`` raised to the power~`e`. - # Assumes that `e > 1` and ``len > 0``. - # Does not support aliasing between the input and output arguments. - + void _padic_poly_pow(fmpz * rop, slong * rval, slong N, const fmpz * op, slong val, slong len, ulong e, const padic_ctx_t ctx) noexcept void padic_poly_pow(padic_poly_t rop, const padic_poly_t op, ulong e, const padic_ctx_t ctx) noexcept - # Sets the polynomial ``rop`` to the polynomial ``op`` raised - # to the power~`e`, reduced to the precision in ``rop``. - # In the special case `e = 0`, sets ``rop`` to the constant - # polynomial one reduced to the precision of ``rop``. - # Also note that when `e = 1`, this operation sets ``rop`` to - # ``op`` and then reduces ``rop``. - # When the valuation of the input polynomial is negative, - # this results in a loss of `p`-adic precision. Suppose - # that the input polynomial is given to precision~`N` and - # has valuation~`v < 0`. The result then has valuation - # `e v < 0` but is only correct to precision `N + (e - 1) v`. - void padic_poly_inv_series(padic_poly_t g, const padic_poly_t f, slong n, const padic_ctx_t ctx) noexcept - # Computes the power series inverse `g` of `f` modulo `X^n`, - # where `n \geq 1`. - # Given the polynomial `f \in \mathbf{Q}[X] \subset \mathbf{Q}_p[X]`, - # there exists a unique polynomial `f^{-1} \in \mathbf{Q}[X]` such that - # `f f^{-1} = 1` modulo `X^n`. This function sets `g` to `f^{-1}` - # reduced modulo `p^N`. - # Assumes that the constant coefficient of `f` is non-zero. - # Moreover, assumes that the valuation of the constant coefficient - # of `f` is minimal among the coefficients of `f`. - # Note that the result `g` is zero if and only if `- \operatorname{ord}_p(f) \geq N`. - - void _padic_poly_derivative(fmpz *rop, slong *rval, slong N, const fmpz *op, slong val, slong len, const padic_ctx_t ctx) noexcept - # Sets ``(rop, rval)`` to the derivative of ``(op, val)`` reduced - # modulo `p^N`. - # Supports aliasing of the input and the output parameters. - + void _padic_poly_derivative(fmpz * rop, slong * rval, slong N, const fmpz * op, slong val, slong len, const padic_ctx_t ctx) noexcept void padic_poly_derivative(padic_poly_t rop, const padic_poly_t op, const padic_ctx_t ctx) noexcept - # Sets ``rop`` to the derivative of ``op``, reducing the - # result modulo the precision of ``rop``. - void padic_poly_shift_left(padic_poly_t rop, const padic_poly_t op, slong n, const padic_ctx_t ctx) noexcept - # Notationally, sets the polynomial ``rop`` to the polynomial ``op`` - # multiplied by `x^n`, where `n \geq 0`, and reduces the result. - void padic_poly_shift_right(padic_poly_t rop, const padic_poly_t op, slong n, const padic_ctx_t ctx) noexcept - # Notationally, sets the polynomial ``rop`` to the polynomial - # ``op`` after floor division by `x^n`, where `n \geq 0`, ensuring - # the result is reduced. - - void _padic_poly_evaluate_padic(fmpz_t u, slong *v, slong N, const fmpz *poly, slong val, slong len, const fmpz_t a, slong b, const padic_ctx_t ctx) noexcept + void _padic_poly_evaluate_padic(fmpz_t u, slong * v, slong N, const fmpz * poly, slong val, slong len, const fmpz_t a, slong b, const padic_ctx_t ctx) noexcept void padic_poly_evaluate_padic(padic_t y, const padic_poly_t poly, const padic_t a, const padic_ctx_t ctx) noexcept - # Sets the `p`-adic number ``y`` to ``poly`` evaluated at `a`, - # reduced in the given context. - # Suppose that the polynomial can be written as `F(X) = p^w f(X)` - # with `\operatorname{ord}_p(f) = 1`, that `\operatorname{ord}_p(a) = b` and that both are - # defined to precision~`N`. Then `f` is defined to precision - # `N-w` and so `f(a)` is defined to precision `N-w` when `a` is - # integral and `N-w+(n-1)b` when `b < 0`, where `n = \deg(f)`. Thus, - # `y = F(a)` is defined to precision `N` when `a` is integral and - # `N+(n-1)b` when `b < 0`. - - void _padic_poly_compose(fmpz *rop, slong *rval, slong N, const fmpz *op1, slong val1, slong len1, const fmpz *op2, slong val2, slong len2, const padic_ctx_t ctx) noexcept - # Sets ``(rop, *rval, (len1-1)*(len2-1)+1)`` to the composition - # of the two input polynomials, reducing the result modulo `p^N`. - # Assumes that ``len1`` is non-zero. - # Does not support aliasing. - + void _padic_poly_compose(fmpz * rop, slong * rval, slong N, const fmpz * op1, slong val1, slong len1, const fmpz * op2, slong val2, slong len2, const padic_ctx_t ctx) noexcept void padic_poly_compose(padic_poly_t rop, const padic_poly_t op1, const padic_poly_t op2, const padic_ctx_t ctx) noexcept - # Sets ``rop`` to the composition of ``op1`` and ``op2``, - # reducing the result in the given context. - # To be clear about the order of composition, let `f(X)` and `g(X)` - # denote the polynomials ``op1`` and ``op2``, respectively. - # Then ``rop`` is set to `f(g(X))`. - - void _padic_poly_compose_pow(fmpz *rop, slong *rval, slong N, const fmpz *op, slong val, slong len, slong k, const padic_ctx_t ctx) noexcept - # Sets ``(rop, *rval, (len - 1)*k + 1)`` to the composition of - # ``(op, val, len)`` and the monomial `x^k`, where `k \geq 1`. - # Assumes that ``len`` is positive. - # Supports aliasing between the input and output polynomials. - + void _padic_poly_compose_pow(fmpz * rop, slong * rval, slong N, const fmpz * op, slong val, slong len, slong k, const padic_ctx_t ctx) noexcept void padic_poly_compose_pow(padic_poly_t rop, const padic_poly_t op, slong k, const padic_ctx_t ctx) noexcept - # Sets ``rop`` to the composition of ``op`` and the monomial `x^k`, - # where `k \geq 1`. - # Note that no reduction takes place. - int padic_poly_debug(const padic_poly_t poly) noexcept - # Prints the data defining the `p`-adic polynomial ``poly`` - # in a simple format useful for debugging purposes. - # In the current implementation, always returns `1`. - - int _padic_poly_fprint(FILE *file, const fmpz *poly, slong val, slong len, const padic_ctx_t ctx) noexcept - int padic_poly_fprint(FILE *file, const padic_poly_t poly, const padic_ctx_t ctx) noexcept - # Prints a simple representation of the polynomial ``poly`` - # to the stream ``file``. - # A non-zero polynomial is represented by the number of coefficients, - # two spaces, followed by a list of the coefficients, which are printed - # in a way depending on the print mode, - # In the ``PADIC_TERSE`` mode, the coefficients are printed as - # rational numbers. - # The ``PADIC_SERIES`` mode is currently not supported and will - # raise an abort signal. - # In the ``PADIC_VAL_UNIT`` mode, the coefficients are printed - # in the form `p^v u`. - # The zero polynomial is represented by ``"0"``. - # In the current implementation, always returns `1`. - - int _padic_poly_print(const fmpz *poly, slong val, slong len, const padic_ctx_t ctx) noexcept + int _padic_poly_fprint(FILE * file, const fmpz * poly, slong val, slong len, const padic_ctx_t ctx) noexcept + int padic_poly_fprint(FILE * file, const padic_poly_t poly, const padic_ctx_t ctx) noexcept + int _padic_poly_print(const fmpz * poly, slong val, slong len, const padic_ctx_t ctx) noexcept int padic_poly_print(const padic_poly_t poly, const padic_ctx_t ctx) noexcept - # Prints a simple representation of the polynomial ``poly`` - # to ``stdout``. - # In the current implementation, always returns `1`. - - int _padic_poly_fprint_pretty(FILE *file, const fmpz *poly, slong val, slong len, const char *var, const padic_ctx_t ctx) noexcept - int padic_poly_fprint_pretty(FILE *file, const padic_poly_t poly, const char *var, const padic_ctx_t ctx) noexcept - int _padic_poly_print_pretty(const fmpz *poly, slong val, slong len, const char *var, const padic_ctx_t ctx) noexcept - int padic_poly_print_pretty(const padic_poly_t poly, const char *var, const padic_ctx_t ctx) noexcept - - bint _padic_poly_is_canonical(const fmpz *op, slong val, slong len, const padic_ctx_t ctx) noexcept + int _padic_poly_fprint_pretty(FILE * file, const fmpz * poly, slong val, slong len, const char * var, const padic_ctx_t ctx) noexcept + int padic_poly_fprint_pretty(FILE * file, const padic_poly_t poly, const char * var, const padic_ctx_t ctx) noexcept + int _padic_poly_print_pretty(const fmpz * poly, slong val, slong len, const char * var, const padic_ctx_t ctx) noexcept + int padic_poly_print_pretty(const padic_poly_t poly, const char * var, const padic_ctx_t ctx) noexcept + bint _padic_poly_is_canonical(const fmpz * op, slong val, slong len, const padic_ctx_t ctx) noexcept bint padic_poly_is_canonical(const padic_poly_t op, const padic_ctx_t ctx) noexcept - bint _padic_poly_is_reduced(const fmpz *op, slong val, slong len, slong N, const padic_ctx_t ctx) noexcept + bint _padic_poly_is_reduced(const fmpz * op, slong val, slong len, slong N, const padic_ctx_t ctx) noexcept bint padic_poly_is_reduced(const padic_poly_t op, const padic_ctx_t ctx) noexcept diff --git a/src/sage/libs/flint/partitions.pxd b/src/sage/libs/flint/partitions.pxd index b930b5da26a..9b76ea11b68 100644 --- a/src/sage/libs/flint/partitions.pxd +++ b/src/sage/libs/flint/partitions.pxd @@ -2,7 +2,9 @@ # distutils: depends = flint/partitions.h ################################################################################ -# This file is auto-generated. Do not modify by hand +# This file is auto-generated by the script +# SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py. +# Do not modify by hand! Fix and rerun the script instead. ################################################################################ from libc.stdio cimport FILE @@ -11,52 +13,9 @@ from sage.libs.mpfr.types cimport * from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void partitions_rademacher_bound(arf_t b, const fmpz_t n, ulong N) noexcept - # Sets `b` to an upper bound for - # .. math :: - # M(n,N) = \frac{44 \pi^2}{225 \sqrt 3} N^{-1/2} - # + \frac{\pi \sqrt{2}}{75} \left( \frac{N}{n-1} \right)^{1/2} - # \sinh\left(\frac{\pi}{N} \sqrt{\frac{2n}{3}}\right). - # This formula gives an upper bound for the truncation error in the - # Hardy-Ramanujan-Rademacher formula when the series is taken up - # to the term `t(n,N)` inclusive. - void partitions_hrr_sum_arb(arb_t x, const fmpz_t n, slong N0, slong N, int use_doubles) noexcept - # Evaluates the partial sum `\sum_{k=N_0}^N t(n,k)` of the - # Hardy-Ramanujan-Rademacher series. - # If *use_doubles* is nonzero, doubles and the system's standard library math - # functions are used to evaluate the smallest terms. This significantly - # speeds up evaluation for small `n` (e.g. `n < 10^6`), and gives a small speed - # improvement for larger `n`, but the result is not guaranteed to be correct. - # In practice, the error is estimated very conservatively, and unless - # the system's standard library is broken, use of doubles can be considered - # safe. Setting *use_doubles* to zero gives a fully guaranteed - # bound. - void partitions_fmpz_fmpz(fmpz_t p, const fmpz_t n, int use_doubles) noexcept - # Computes the partition function `p(n)` using the Hardy-Ramanujan-Rademacher - # formula. This function computes a numerical ball containing `p(n)` - # and verifies that the ball contains a unique integer. - # If *n* is sufficiently large and a number of threads greater than 1 - # has been selected with :func:`flint_set_num_threads()`, the computation - # time will be reduced by using two threads. - # See :func:`partitions_hrr_sum_arb` for an explanation of the - # *use_doubles* option. - void partitions_fmpz_ui(fmpz_t p, ulong n) noexcept - # Computes the partition function `p(n)` using the Hardy-Ramanujan-Rademacher - # formula. This function computes a numerical ball containing `p(n)` - # and verifies that the ball contains a unique integer. - void partitions_fmpz_ui_using_doubles(fmpz_t p, ulong n) noexcept - # Computes the partition function `p(n)`, enabling the use of doubles - # internally. This significantly speeds up evaluation for small `n` - # (e.g. `n < 10^6`), but the error bounds are not certified - # (see remarks for :func:`partitions_hrr_sum_arb`). - void partitions_leading_fmpz(arb_t res, const fmpz_t n, slong prec) noexcept - # Sets *res* to the leading term in the Hardy-Ramanujan series - # for `p(n)` (without Rademacher's correction of this term, which is - # vanishingly small when `n` is large), that is, - # `\sqrt{12} (1-1/t) e^t / (24n-1)` where `t = \pi \sqrt{24n-1} / 6`. diff --git a/src/sage/libs/flint/perm.pxd b/src/sage/libs/flint/perm.pxd index a6c8a986a24..3e2f935d591 100644 --- a/src/sage/libs/flint/perm.pxd +++ b/src/sage/libs/flint/perm.pxd @@ -2,7 +2,9 @@ # distutils: depends = flint/perm.h ################################################################################ -# This file is auto-generated. Do not modify by hand +# This file is auto-generated by the script +# SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py. +# Do not modify by hand! Fix and rerun the script instead. ################################################################################ from libc.stdio cimport FILE @@ -11,38 +13,12 @@ from sage.libs.mpfr.types cimport * from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - slong * _perm_init(slong n) noexcept - # Initialises the permutation for use. - - void _perm_clear(slong *vec) noexcept - # Clears the permutation. - - void _perm_set(slong *res, const slong *vec, slong n) noexcept - # Sets the permutation ``res`` to the same as the permutation ``vec``. - - void _perm_set_one(slong *vec, slong n) noexcept - # Sets the permutation to the identity permutation. - - void _perm_inv(slong *res, const slong *vec, slong n) noexcept - # Sets ``res`` to the inverse permutation of ``vec``. - # Allows aliasing of ``res`` and ``vec``. - - void _perm_compose(slong *res, const slong *vec1, const slong *vec2, slong n) noexcept - # Forms the composition `\pi_1 \circ \pi_2` of two permutations - # `\pi_1` and `\pi_2`. Here, `\pi_2` is applied first, that is, - # `(\pi_1 \circ \pi_2)(i) = \pi_1(\pi_2(i))`. - # Allows aliasing of ``res``, ``vec1`` and ``vec2``. - - int _perm_parity(const slong *vec, slong n) noexcept - # Returns the parity of ``vec``, 0 if the permutation is even and 1 if - # the permutation is odd. - - int _perm_randtest(slong *vec, slong n, flint_rand_t state) noexcept - # Generates a random permutation vector of length `n` and returns - # its parity, 0 or 1. - # This function uses the Knuth shuffle algorithm to generate a uniformly - # random permutation without retries. - + void _perm_clear(slong * vec) noexcept + void _perm_set(slong * res, const slong * vec, slong n) noexcept + void _perm_one(slong * vec, slong n) noexcept + void _perm_inv(slong * res, const slong * vec, slong n) noexcept + void _perm_compose(slong * res, const slong * vec1, const slong * vec2, slong n) noexcept + int _perm_parity(const slong * vec, slong n) noexcept + int _perm_randtest(slong * vec, slong n, flint_rand_t state) noexcept int _perm_print(const slong * vec, slong n) noexcept - # Prints the permutation vector of length `n` to ``stdout``. diff --git a/src/sage/libs/flint/profiler.pxd b/src/sage/libs/flint/profiler.pxd index 31824150e64..87c2c4684fd 100644 --- a/src/sage/libs/flint/profiler.pxd +++ b/src/sage/libs/flint/profiler.pxd @@ -2,7 +2,9 @@ # distutils: depends = flint/profiler.h ################################################################################ -# This file is auto-generated. Do not modify by hand +# This file is auto-generated by the script +# SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py. +# Do not modify by hand! Fix and rerun the script instead. ################################################################################ from libc.stdio cimport FILE @@ -11,77 +13,10 @@ from sage.libs.mpfr.types cimport * from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void timeit_start(timeit_t t) noexcept void timeit_stop(timeit_t t) noexcept - # Gives wall and user time - useful for parallel programming. - # Example usage:: - # timeit_t t0; - # // ... - # timeit_start(t0); - # // do stuff, take some time - # timeit_stop(t0); - # flint_printf("cpu = %wd ms wall = %wd ms\n", t0->cpu, t0->wall); - void start_clock(int n) noexcept - void stop_clock(int n) noexcept - double get_clock(int n) noexcept - # Gives time based on cycle counter. - # First one must ensure the processor speed in cycles per second - # is set correctly in ``profiler.h``, in the macro definition - # ``#define FLINT_CLOCKSPEED``. - # One can access the cycle counter directly by :func:`get_cycle_counter` - # which returns the current cycle counter as a ``double``. - # A sample usage of clocks is:: - # init_all_clocks(); - # start_clock(n); - # // do something - # stop_clock(n); - # flint_printf("Time in seconds is %f.3\n", get_clock(n)); - # where ``n`` is a clock number (from 0-19 by default). The number of - # clocks can be changed by altering ``FLINT_NUM_CLOCKS``. One can also - # initialise an individual clock with ``init_clock(n)``. - - void prof_repeat(double *min, double *max, profile_target_t target, void *arg) noexcept - # Allows one to automatically time a given function. Here is a sample usage: - # Suppose one has a function one wishes to profile:: - # void myfunc(ulong a, ulong b); - # One creates a struct for passing arguments to our function:: - # typedef struct - # { - # ulong a, b; - # } myfunc_t; - # a sample function:: - # void sample_myfunc(void * arg, ulong count) - # { - # myfunc_t * params = (myfunc_t *) arg; - # ulong a = params->a; - # ulong b = params->b; - # for (ulong i = 0; i < count; i++) - # { - # prof_start(); - # myfunc(a, b); - # prof_stop(); - # } - # } - # Then we do the profile:: - # double min, max; - # myfunc_t params; - # params.a = 3; - # params.b = 4; - # prof_repeat(&min, &max, sample_myfunc, ¶ms); - # flint_printf("Min time is %lf.3s, max time is %lf.3s\n", min, max); - # If either of the first two parameters to ``prof_repeat`` is - # ``NULL``, that value is not stored. - # One may set the minimum time in microseconds for a timing run by - # adjusting ``DURATION_THRESHOLD`` and one may set a target duration - # in microseconds by adjusting ``DURATION_TARGET`` in ``profiler.h``. - + void prof_repeat(double * min, double * max, profile_target_t target, void * arg) noexcept void get_memory_usage(meminfo_t meminfo) noexcept - # Obtains information about the memory usage of the current process. - # The meminfo object contains the slots ``size`` (virtual memory size), - # ``peak`` (peak virtual memory size), ``rss`` (resident set size), - # ``hwm`` (peak resident set size). The values are stored in kilobytes - # (1024 bytes). This function currently only works on Linux. diff --git a/src/sage/libs/flint/qadic.pxd b/src/sage/libs/flint/qadic.pxd index 6f11a693009..86db643ec2a 100644 --- a/src/sage/libs/flint/qadic.pxd +++ b/src/sage/libs/flint/qadic.pxd @@ -2,7 +2,9 @@ # distutils: depends = flint/qadic.h ################################################################################ -# This file is auto-generated. Do not modify by hand +# This file is auto-generated by the script +# SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py. +# Do not modify by hand! Fix and rerun the script instead. ################################################################################ from libc.stdio cimport FILE @@ -11,365 +13,63 @@ from sage.libs.mpfr.types cimport * from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - - void qadic_ctx_init(qadic_ctx_t ctx, const fmpz_t p, slong d, slong min, slong max, const char *var, padic_print_mode mode) noexcept - # Initialises the context ``ctx`` with prime `p`, extension degree `d`, - # variable name ``var`` and printing mode ``mode``. The defining polynomial - # is chosen as a Conway polynomial if possible and otherwise as a random - # sparse polynomial. - # Stores powers of `p` with exponents between ``min`` (inclusive) and - # ``max`` exclusive. Assumes that ``min`` is at most ``max``. - # Assumes that `p` is a prime. - # Assumes that the string ``var`` is a null-terminated string - # of length at least one. - # Assumes that the printing mode is one of ``PADIC_TERSE``, - # ``PADIC_SERIES``, or ``PADIC_VAL_UNIT``. - # This function also carries out some relevant precomputation for - # arithmetic in `\mathbf{Q}_p / (p^N)` such as powers of `p` close - # to `p^N`. - - void qadic_ctx_init_conway(qadic_ctx_t ctx, const fmpz_t p, slong d, slong min, slong max, const char *var, padic_print_mode mode) noexcept - # Initialises the context ``ctx`` with prime `p`, extension degree `d`, - # variable name ``var`` and printing mode ``mode``. The defining polynomial - # is chosen as a Conway polynomial, hence has restrictions on the - # prime and the degree. - # Stores powers of `p` with exponents between ``min`` (inclusive) and - # ``max`` exclusive. Assumes that ``min`` is at most ``max``. - # Assumes that `p` is a prime. - # Assumes that the string ``var`` is a null-terminated string - # of length at least one. - # Assumes that the printing mode is one of ``PADIC_TERSE``, - # ``PADIC_SERIES``, or ``PADIC_VAL_UNIT``. - # This function also carries out some relevant precomputation for - # arithmetic in `\mathbf{Q}_p / (p^N)` such as powers of `p` close - # to `p^N`. - + void qadic_ctx_init(qadic_ctx_t ctx, const fmpz_t p, slong d, slong min, slong max, const char * var, padic_print_mode mode) noexcept + void qadic_ctx_init_conway(qadic_ctx_t ctx, const fmpz_t p, slong d, slong min, slong max, const char * var, padic_print_mode mode) noexcept void qadic_ctx_clear(qadic_ctx_t ctx) noexcept - # Clears all memory that has been allocated as part of the context. - slong qadic_ctx_degree(const qadic_ctx_t ctx) noexcept - # Returns the extension degree. - void qadic_ctx_print(const qadic_ctx_t ctx) noexcept - # Prints the data from the given context. - void qadic_init(qadic_t rop) noexcept - # Initialises the element ``rop``, setting its value to `0`. - void qadic_init2(qadic_t rop, slong prec) noexcept - # Initialises the element ``rop`` with the given output precision, - # setting the value to `0`. - void qadic_clear(qadic_t rop) noexcept - # Clears the element ``rop``. - - void _fmpz_poly_reduce(fmpz *R, slong lenR, const fmpz *a, const slong *j, slong len) noexcept - # Reduces a polynomial ``(R, lenR)`` modulo a sparse monic - # polynomial `f(X) = \sum_{i} a_{i} X^{j_{i}}` of degree at - # least `2`. - # Assumes that the array `j` of positive length ``len`` is - # sorted in ascending order. - # Allows zero-padding in ``(R, lenR)``. - - void _fmpz_mod_poly_reduce(fmpz *R, slong lenR, const fmpz *a, const slong *j, slong len, const fmpz_t p) noexcept - # Reduces a polynomial ``(R, lenR)`` modulo a sparse monic - # polynomial `f(X) = \sum_{i} a_{i} X^{j_{i}}` of degree at - # least `2` in `\mathbf{Z}/(p)`, where `p` is typically a prime - # power. - # Assumes that the array `j` of positive length ``len`` is - # sorted in ascending order. - # Allows zero-padding in ``(R, lenR)``. - + void _fmpz_poly_reduce(fmpz * R, slong lenR, const fmpz * a, const slong * j, slong len) noexcept + void _fmpz_mod_poly_reduce(fmpz * R, slong lenR, const fmpz * a, const slong * j, slong len, const fmpz_t p) noexcept void qadic_reduce(qadic_t rop, const qadic_ctx_t ctx) noexcept - # Reduces ``rop`` modulo `f(X)` and `p^N`. - slong qadic_val(const qadic_t op) noexcept - # Returns the valuation of ``op``. - slong qadic_prec(const qadic_t op) noexcept - # Returns the precision of ``op``. - void qadic_randtest(qadic_t rop, flint_rand_t state, const qadic_ctx_t ctx) noexcept - # Generates a random element of `\mathbf{Q}_q`. - void qadic_randtest_not_zero(qadic_t rop, flint_rand_t state, const qadic_ctx_t ctx) noexcept - # Generates a random non-zero element of `\mathbf{Q}_q`. - void qadic_randtest_val(qadic_t rop, flint_rand_t state, slong v, const qadic_ctx_t ctx) noexcept - # Generates a random element of `\mathbf{Q}_q` with prescribed - # valuation ``val``. - # Note that if `v \geq N` then the element is necessarily zero. - void qadic_randtest_int(qadic_t rop, flint_rand_t state, const qadic_ctx_t ctx) noexcept - # Generates a random element of `\mathbf{Q}_q` with non-negative valuation. - void qadic_set(qadic_t rop, const qadic_t op, const qadic_ctx_t ctx) noexcept - # Sets ``rop`` to ``op``. - void qadic_zero(qadic_t rop) noexcept - # Sets ``rop`` to zero. - void qadic_one(qadic_t rop) noexcept - # Sets ``rop`` to one, reduced in the given context. - # Note that if the precision `N` is non-positive then ``rop`` - # is actually set to zero. - void qadic_gen(qadic_t rop, const qadic_ctx_t ctx) noexcept - # Sets ``rop`` to the generator `X` for the extension - # when `N > 0`, and zero otherwise. If the extension degree - # is one, raises an abort signal. - void qadic_set_ui(qadic_t rop, ulong op, const qadic_ctx_t ctx) noexcept - # Sets ``rop`` to the integer ``op``, reduced in the - # context. - int qadic_get_padic(padic_t rop, const qadic_t op, const qadic_ctx_t ctx) noexcept - # If the element ``op`` lies in `\mathbf{Q}_p`, sets ``rop`` - # to its value and returns `1`; otherwise, returns `0`. - bint qadic_is_zero(const qadic_t op) noexcept - # Returns whether ``op`` is equal to zero. - bint qadic_is_one(const qadic_t op) noexcept - # Returns whether ``op`` is equal to one in the given - # context. - bint qadic_equal(const qadic_t op1, const qadic_t op2) noexcept - # Returns whether ``op1`` and ``op2`` are equal. - void qadic_add(qadic_t rop, const qadic_t op1, const qadic_t op2, const qadic_ctx_t ctx) noexcept - # Sets ``rop`` to the sum of ``op1`` and ``op2``. - # Assumes that both ``op1`` and ``op2`` are reduced in the - # given context and ensures that ``rop`` is, too. - void qadic_sub(qadic_t rop, const qadic_t op1, const qadic_t op2, const qadic_ctx_t ctx) noexcept - # Sets ``rop`` to the difference of ``op1`` and ``op2``. - # Assumes that both ``op1`` and ``op2`` are reduced in the - # given context and ensures that ``rop`` is, too. - void qadic_neg(qadic_t rop, const qadic_t op, const qadic_ctx_t ctx) noexcept - # Sets ``rop`` to the negative of ``op``. - # Assumes that ``op`` is reduced in the given context and - # ensures that ``rop`` is, too. - void qadic_mul(qadic_t rop, const qadic_t op1, const qadic_t op2, const qadic_ctx_t ctx) noexcept - # Sets ``rop`` to the product of ``op1`` and ``op2``, - # reducing the output in the given context. - - void _qadic_inv(fmpz *rop, const fmpz *op, slong len, const fmpz *a, const slong *j, slong lena, const fmpz_t p, slong N) noexcept - # Sets ``(rop, d)`` to the inverse of ``(op, len)`` - # modulo `f(X)` given by ``(a,j,lena)`` and `p^N`. - # Assumes that ``(op,len)`` has valuation `0`, that is, - # that it represents a `p`-adic unit. - # Assumes that ``len`` is at most `d`. - # Does not support aliasing. - + void _qadic_inv(fmpz * rop, const fmpz * op, slong len, const fmpz * a, const slong * j, slong lena, const fmpz_t p, slong N) noexcept void qadic_inv(qadic_t rop, const qadic_t op, const qadic_ctx_t ctx) noexcept - # Sets ``rop`` to the inverse of ``op``, reduced in the given context. - - void _qadic_pow(fmpz *rop, const fmpz *op, slong len, const fmpz_t e, const fmpz *a, const slong *j, slong lena, const fmpz_t p) noexcept - # Sets ``(rop, 2*d-1)`` to ``(op,len)`` raised to the power `e`, - # reduced modulo `f(X)` given by ``(a, j, lena)`` and `p`, which - # is expected to be a prime power. - # Assumes that `e \geq 0` and that ``len`` is positive and at most `d`. - # Although we require that ``rop`` provides space for - # `2d - 1` coefficients, the output will be reduced modulo - # `f(X)`, which is a polynomial of degree `d`. - # Does not support aliasing. - + void _qadic_pow(fmpz * rop, const fmpz * op, slong len, const fmpz_t e, const fmpz * a, const slong * j, slong lena, const fmpz_t p) noexcept void qadic_pow(qadic_t rop, const qadic_t op, const fmpz_t e, const qadic_ctx_t ctx) noexcept - # Sets ``rop`` the ``op`` raised to the power `e`. - # Currently assumes that `e \geq 0`. - # Note that for any input ``op``, ``rop`` is set to one in the - # given context whenever `e = 0`. - int qadic_sqrt(qadic_t rop, const qadic_t op, const qadic_ctx_t ctx) noexcept - # Return ``1`` if the input is a square (to input precision). If so, set - # ``rop`` to a square root (truncated to output precision). - - void _qadic_exp_rectangular(fmpz *rop, const fmpz *op, slong v, slong len, const fmpz *a, const slong *j, slong lena, const fmpz_t p, slong N, const fmpz_t pN) noexcept - # Sets ``(rop, 2*d - 1)`` to the exponential of ``(op, v, len)`` - # reduced modulo `p^N`, assuming that the series converges. - # Assumes that ``(op, v, len)`` is non-zero. - # Does not support aliasing. - + void _qadic_exp_rectangular(fmpz * rop, const fmpz * op, slong v, slong len, const fmpz * a, const slong * j, slong lena, const fmpz_t p, slong N, const fmpz_t pN) noexcept int qadic_exp_rectangular(qadic_t rop, const qadic_t op, const qadic_ctx_t ctx) noexcept - # Returns whether the exponential series converges at ``op`` - # and sets ``rop`` to its value reduced modulo in the given - # context. - - void _qadic_exp_balanced(fmpz *rop, const fmpz *x, slong v, slong len, const fmpz *a, const slong *j, slong lena, const fmpz_t p, slong N, const fmpz_t pN) noexcept - # Sets ``(rop, d)`` to the exponential of ``(op, v, len)`` - # reduced modulo `p^N`, assuming that the series converges. - # Assumes that ``len`` is in `[1,d)` but supports zero padding, - # including the special case when ``(op, len)`` is zero. - # Supports aliasing between ``rop`` and ``op``. - + void _qadic_exp_balanced(fmpz * rop, const fmpz * x, slong v, slong len, const fmpz * a, const slong * j, slong lena, const fmpz_t p, slong N, const fmpz_t pN) noexcept int qadic_exp_balanced(qadic_t rop, const qadic_t op, const qadic_ctx_t ctx) noexcept - # Returns whether the exponential series converges at ``op`` - # and sets ``rop`` to its value reduced modulo in the given - # context. - - void _qadic_exp(fmpz *rop, const fmpz *op, slong v, slong len, const fmpz *a, const slong *j, slong lena, const fmpz_t p, slong N, const fmpz_t pN) noexcept - # Sets ``(rop, 2*d - 1)`` to the exponential of ``(op, v, len)`` - # reduced modulo `p^N`, assuming that the series converges. - # Assumes that ``(op, v, len)`` is non-zero. - # Does not support aliasing. - + void _qadic_exp(fmpz * rop, const fmpz * op, slong v, slong len, const fmpz * a, const slong * j, slong lena, const fmpz_t p, slong N, const fmpz_t pN) noexcept int qadic_exp(qadic_t rop, const qadic_t op, const qadic_ctx_t ctx) noexcept - # Returns whether the exponential series converges at ``op`` - # and sets ``rop`` to its value reduced modulo in the given - # context. - # The exponential series converges if the valuation of ``op`` - # is at least `2` or `1` when `p` is even or odd, respectively. - - void _qadic_log_rectangular(fmpz *z, const fmpz *y, slong v, slong len, const fmpz *a, const slong *j, slong lena, const fmpz_t p, slong N, const fmpz_t pN) noexcept - # Computes - # .. math :: - # z = - \sum_{i = 1}^{\infty} \frac{y^i}{i} \pmod{p^N}. - # Note that this can be used to compute the `p`-adic logarithm - # via the equation - # .. math :: - # \log(x) & = \sum_{i=1}^{\infty} (-1)^{i-1} \frac{(x-1)^i}{i} \\ - # & = - \sum_{i=1}^{\infty} \frac{(1-x)^i}{i}. - # Assumes that `y = 1 - x` is non-zero and that `v = \operatorname{ord}_p(y)` - # is at least `1` when `p` is odd and at least `2` when `p = 2` - # so that the series converges. - # Assumes that `y` is reduced modulo `p^N`. - # Assumes that `v < N`, and in particular `N \geq 2`. - # Supports aliasing between `y` and `z`. - + void _qadic_log_rectangular(fmpz * z, const fmpz * y, slong v, slong len, const fmpz * a, const slong * j, slong lena, const fmpz_t p, slong N, const fmpz_t pN) noexcept int qadic_log_rectangular(qadic_t rop, const qadic_t op, const qadic_ctx_t ctx) noexcept - # Returns whether the `p`-adic logarithm function converges at - # ``op``, and if so sets ``rop`` to its value. - - void _qadic_log_balanced(fmpz *z, const fmpz *y, slong len, const fmpz *a, const slong *j, slong lena, const fmpz_t p, slong N, const fmpz_t pN) noexcept - # Computes `(z, d)` as - # .. math :: - # z = - \sum_{i = 1}^{\infty} \frac{y^i}{i} \pmod{p^N}. - # Assumes that `v = \operatorname{ord}_p(y)` is at least `1` when `p` is odd and - # at least `2` when `p = 2` so that the series converges. - # Supports aliasing between `z` and `y`. - + void _qadic_log_balanced(fmpz * z, const fmpz * y, slong len, const fmpz * a, const slong * j, slong lena, const fmpz_t p, slong N, const fmpz_t pN) noexcept int qadic_log_balanced(qadic_t rop, const qadic_t op, const qadic_ctx_t ctx) noexcept - # Returns whether the `p`-adic logarithm function converges at - # ``op``, and if so sets ``rop`` to its value. - - void _qadic_log(fmpz *z, const fmpz *y, slong v, slong len, const fmpz *a, const slong *j, slong lena, const fmpz_t p, slong N, const fmpz_t pN) noexcept - # Computes `(z, d)` as - # .. math :: - # z = - \sum_{i = 1}^{\infty} \frac{y^i}{i} \pmod{p^N}. - # Note that this can be used to compute the `p`-adic logarithm - # via the equation - # .. math :: - # \log(x) & = \sum_{i=1}^{\infty} (-1)^{i-1} \frac{(x-1)^i}{i} \\ - # & = - \sum_{i=1}^{\infty} \frac{(1-x)^i}{i}. - # Assumes that `y = 1 - x` is non-zero and that `v = \operatorname{ord}_p(y)` - # is at least `1` when `p` is odd and at least `2` when `p = 2` - # so that the series converges. - # Assumes that `(y, d)` is reduced modulo `p^N`. - # Assumes that `v < N`, and hence in particular `N \geq 2`. - # Supports aliasing between `z` and `y`. - + void _qadic_log(fmpz * z, const fmpz * y, slong v, slong len, const fmpz * a, const slong * j, slong lena, const fmpz_t p, slong N, const fmpz_t pN) noexcept int qadic_log(qadic_t rop, const qadic_t op, const qadic_ctx_t ctx) noexcept - # Returns whether the `p`-adic logarithm function converges at - # ``op``, and if so sets ``rop`` to its value. - # The `p`-adic logarithm function is defined by the usual series - # .. math :: - # \log_p(x) = \sum_{i=1}^{\infty} (-1)^{i-1} \frac{(x-1)^i}{i} - # but this only converges when `\operatorname{ord}_p(x)` is at least `2` or `1` - # when `p = 2` or `p > 2`, respectively. - - void _qadic_frobenius_a(fmpz *rop, slong e, const fmpz *a, const slong *j, slong lena, const fmpz_t p, slong N) noexcept - # Computes `\sigma^e(X) \bmod{p^N}` where `X` is such that - # `\mathbf{Q}_q \cong \mathbf{Q}_p[X]/(f(X))`. - # Assumes that the precision `N` is at least `2` and that the - # extension is non-trivial, i.e. `d \geq 2`. - # Assumes that `0 < e < d`. - # Sets ``(rop, 2*d-1)``, although the actual length of the - # output will be at most `d`. - - void _qadic_frobenius(fmpz *rop, const fmpz *op, slong len, slong e, const fmpz *a, const slong *j, slong lena, const fmpz_t p, slong N) noexcept - # Sets ``(rop, 2*d-1)`` to `\Sigma` evaluated at ``(op, len)``. - # Assumes that ``len`` is positive but at most `d`. - # Assumes that `0 < e < d`. - # Does not support aliasing. - + void _qadic_frobenius_a(fmpz * rop, slong e, const fmpz * a, const slong * j, slong lena, const fmpz_t p, slong N) noexcept + void _qadic_frobenius(fmpz * rop, const fmpz * op, slong len, slong e, const fmpz * a, const slong * j, slong lena, const fmpz_t p, slong N) noexcept void qadic_frobenius(qadic_t rop, const qadic_t op, slong e, const qadic_ctx_t ctx) noexcept - # Evaluates the homomorphism `\Sigma^e` at ``op``. - # Recall that `\mathbf{Q}_q / \mathbf{Q}_p` is Galois with Galois group - # `\langle \Sigma \rangle \cong \langle \sigma \rangle`, which is also - # isomorphic to `\mathbf{Z}/d\mathbf{Z}`, where - # `\sigma \in \operatorname{Gal}(\mathbf{F}_q/\mathbf{F}_p)` is the Frobenius element - # `\sigma \colon x \mapsto x^p` and `\Sigma` is its lift to - # `\operatorname{Gal}(\mathbf{Q}_q/\mathbf{Q}_p)`. - # This functionality is implemented as ``GaloisImage()`` in Magma. - - void _qadic_teichmuller(fmpz *rop, const fmpz *op, slong len, const fmpz *a, const slong *j, slong lena, const fmpz_t p, slong N) noexcept - # Sets ``(rop, d)`` to the Teichmüller lift of ``(op, len)`` - # modulo `p^N`. - # Does not support aliasing. - + void _qadic_teichmuller(fmpz * rop, const fmpz * op, slong len, const fmpz * a, const slong * j, slong lena, const fmpz_t p, slong N) noexcept void qadic_teichmuller(qadic_t rop, const qadic_t op, const qadic_ctx_t ctx) noexcept - # Sets ``rop`` to the Teichmüller lift of ``op`` to the - # precision given in the context. - # For a unit ``op``, this is the unique `(q-1)`\th root of unity - # which is congruent to ``op`` modulo `p`. - # Sets ``rop`` to zero if ``op`` is zero in the given context. - # Raises an exception if the valuation of ``op`` is negative. - - void _qadic_trace(fmpz_t rop, const fmpz *op, slong len, const fmpz *a, const slong *j, slong lena, const fmpz_t pN) noexcept + void _qadic_trace(fmpz_t rop, const fmpz * op, slong len, const fmpz * a, const slong * j, slong lena, const fmpz_t pN) noexcept void qadic_trace(padic_t rop, const qadic_t op, const qadic_ctx_t ctx) noexcept - # Sets ``rop`` to the trace of ``op``. - # For an element `a \in \mathbf{Q}_q`, multiplication by `a` defines - # a `\mathbf{Q}_p`-linear map on `\mathbf{Q}_q`. We define the trace - # of `a` as the trace of this map. Equivalently, if `\Sigma` generates - # `\operatorname{Gal}(\mathbf{Q}_q / \mathbf{Q}_p)` then the trace of `a` is equal to - # `\sum_{i=0}^{d-1} \Sigma^i (a)`. - - void _qadic_norm(fmpz_t rop, const fmpz *op, slong len, const fmpz *a, const slong *j, slong lena, const fmpz_t p, slong N) noexcept - # Sets ``rop`` to the norm of the element ``(op,len)`` - # in `\mathbf{Z}_q` to precision `N`, where ``len`` is at - # least one. - # The result will be reduced modulo `p^N`. - # Note that whenever ``(op,len)`` is a unit, so is its norm. - # Thus, the output ``rop`` of this function will typically - # not have to be canonicalised or reduced by the caller. - + void _qadic_norm(fmpz_t rop, const fmpz * op, slong len, const fmpz * a, const slong * j, slong lena, const fmpz_t p, slong N) noexcept void qadic_norm(padic_t rop, const qadic_t op, const qadic_ctx_t ctx) noexcept - # Computes the norm of ``op`` to the given precision. - # Algorithm selection is automatic depending on the input. - void qadic_norm_analytic(padic_t rop, const qadic_t op, const qadic_ctx_t ctx) noexcept - # Whenever ``op`` has valuation greater than `(p-1)^{-1}`, this - # routine computes its norm ``rop`` via - # .. math :: - # \operatorname{Norm} (x) = \exp \Bigl( \bigl( \operatorname{Trace} \log (x) \bigr) \Bigr). - # In the special case that ``op`` lies in `\mathbf{Q}_p`, returns - # its norm as `\operatorname{Norm}(x) = x^d`, where `d` is the extension degree. - # Otherwise, raises an ``abort`` signal. - # The complexity of this implementation is quasi-linear in `d` and `N`, - # and polynomial in `\log p`. - void qadic_norm_resultant(padic_t rop, const qadic_t op, const qadic_ctx_t ctx) noexcept - # Sets ``rop`` to the norm of ``op``, using the formula - # .. math :: - # \operatorname{Norm}(x) = \ell(f)^{-\deg(a)} \operatorname{Res}(f(X), a(X)), - # where `\mathbf{Q}_q \cong \mathbf{Q}_p[X] / (f(X))`, `\ell(f)` is the - # leading coefficient of `f(X)`, and `a(X) \in \mathbf{Q}_p[X]` denotes - # the same polynomial as `x`. - # The complexity of the current implementation is given by - # `\mathcal{O}(d^4 M(N \log p))`, where `M(n)` denotes the - # complexity of multiplying to `n`-bit integers. - - int qadic_fprint_pretty(FILE *file, const qadic_t op, const qadic_ctx_t ctx) noexcept - # Prints a pretty representation of ``op`` to ``file``. - # In the current implementation, always returns `1`. The return code is - # part of the function's signature to allow for a later implementation to - # return the number of characters printed or a non-positive error code. - + int qadic_fprint_pretty(FILE * file, const qadic_t op, const qadic_ctx_t ctx) noexcept int qadic_print_pretty(const qadic_t op, const qadic_ctx_t ctx) noexcept - # Prints a pretty representation of ``op`` to ``stdout``. - # In the current implementation, always returns `1`. The return code is - # part of the function's signature to allow for a later implementation to - # return the number of characters printed or a non-positive error code. diff --git a/src/sage/libs/flint/qfb.pxd b/src/sage/libs/flint/qfb.pxd index 1b89c40755d..d881ababd29 100644 --- a/src/sage/libs/flint/qfb.pxd +++ b/src/sage/libs/flint/qfb.pxd @@ -2,7 +2,9 @@ # distutils: depends = flint/qfb.h ################################################################################ -# This file is auto-generated. Do not modify by hand +# This file is auto-generated by the script +# SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py. +# Do not modify by hand! Fix and rerun the script instead. ################################################################################ from libc.stdio cimport FILE @@ -11,148 +13,30 @@ from sage.libs.mpfr.types cimport * from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void qfb_init(qfb_t q) noexcept - # Initialise a ``qfb_t`` `q` for use. - void qfb_clear(qfb_t q) noexcept - # Clear a ``qfb_t`` after use. This releases any memory allocated for - # `q` back to flint. - void qfb_array_clear(qfb ** forms, slong num) noexcept - # Clean up an array of ``qfb`` structs allocated by a qfb function. - # The parameter ``num`` must be set to the length of the array. - qfb_hash_t * qfb_hash_init(slong depth) noexcept - # Initialises a hash table of size `2^{depth}`. - void qfb_hash_clear(qfb_hash_t * qhash, slong depth) noexcept - # Frees all memory used by a hash table of size `2^{depth}`. - void qfb_hash_insert(qfb_hash_t * qhash, qfb_t q, qfb_t q2, slong it, slong depth) noexcept - # Insert the binary quadratic form ``q`` into the given hash table - # of size `2^{depth}` in the field ``q`` of the hash structure. - # Also store the second binary quadratic form ``q2`` (if not - # ``NULL``) in the similarly named field and ``iter`` in the - # similarly named field of the hash structure. - slong qfb_hash_find(qfb_hash_t * qhash, qfb_t q, slong depth) noexcept - # Search for the given binary quadratic form or its inverse in the - # given hash table of size `2^{depth}`. If it is found, return - # the index in the table (which is an array of ``qfb_hash_t`` - # structs), otherwise return ``-1``. - void qfb_set(qfb_t f, qfb_t g) noexcept - # Set the binary quadratic form `f` to be equal to `g`. - bint qfb_equal(qfb_t f, qfb_t g) noexcept - # Returns `1` if `f` and `g` are identical binary quadratic forms, - # otherwise returns `0`. - void qfb_print(qfb_t q) noexcept - # Print a binary quadratic form `q` in the format `(a, b, c)` where - # `a`, `b`, `c` are the entries of `q`. - void qfb_discriminant(fmpz_t D, qfb_t f) noexcept - # Set `D` to the discriminant of the binary quadratic form `f`, i.e. to - # `b^2 - 4ac`, where `f = (a, b, c)`. - void qfb_reduce(qfb_t r, qfb_t f, fmpz_t D) noexcept - # Set `r` to a reduced form equivalent to the binary quadratic form `f` - # of discriminant `D`. - bint qfb_is_reduced(qfb_t r) noexcept - # Returns `1` if `q` is a reduced binary quadratic form, otherwise - # returns `0`. Note that this only tests for definite quadratic - # forms, so a form `r = (a,b,c)` is reduced if and only if `|b| \le a \le - # c` and if either inequality is an equality, then `b \ge 0`. - slong qfb_reduced_forms(qfb ** forms, slong d) noexcept - # Given a discriminant `d` (negative for negative definite forms), compute - # all the reduced binary quadratic forms of that discriminant. The function - # allocates space for these and returns it in the variable ``forms`` - # (the user is responsible for cleaning this up by a single call to - # ``qfb_array_clear`` on ``forms``, after use.) The function returns - # the number of forms generated (the form class number). The forms are - # stored in an array of ``qfb`` structs, which contain fields - # ``a, b, c`` corresponding to forms `(a, b, c)`. - slong qfb_reduced_forms_large(qfb ** forms, slong d) noexcept - # As for ``qfb_reduced_forms``. However, for small `|d|` it requires - # fewer primes to be computed at a small cost in speed. It is called - # automatically by ``qfb_reduced_forms`` for large `|d|` so that - # ``flint_primes`` is not exhausted. - void qfb_nucomp(qfb_t r, const qfb_t f, const qfb_t g, fmpz_t D, fmpz_t L) noexcept - # Shanks' NUCOMP as described in [JvdP2002]_. - # Computes the near reduced composition of forms `f` and `g` given - # `L = \lfloor |D|^{1/4} \rfloor` where `D` is the common discriminant of - # `f` and `g`. The result is returned in `r`. - # We require that `f` is a primitive form. - void qfb_nudupl(qfb_t r, const qfb_t f, fmpz_t D, fmpz_t L) noexcept - # As for ``nucomp`` except that the form `f` is composed with itself. - # We require that `f` is a primitive form. - void qfb_pow_ui(qfb_t r, qfb_t f, fmpz_t D, ulong exp) noexcept - # Compute the near reduced form `r` which is the result of composing the - # principal form (identity) with `f` ``exp`` times. - # We require `D` to be set to the discriminant of `f` and that `f` is a - # primitive form. - void qfb_pow(qfb_t r, qfb_t f, fmpz_t D, fmpz_t exp) noexcept - # As per ``qfb_pow_ui``. - void qfb_inverse(qfb_t r, qfb_t f) noexcept - # Set `r` to the inverse of the binary quadratic form `f`. - bint qfb_is_principal_form(qfb_t f, fmpz_t D) noexcept - # Return `1` if `f` is the reduced principal form of discriminant `D`, - # i.e. the identity in the form class group, else `0`. - void qfb_principal_form(qfb_t f, fmpz_t D) noexcept - # Set `f` to the principal form of discriminant `D`, i.e. the identity in - # the form class group. - bint qfb_is_primitive(qfb_t f) noexcept - # Return `1` if `f` is primitive, i.e. the greatest common divisor of its - # three coefficients is `1`. Otherwise the function returns `0`. - void qfb_prime_form(qfb_t r, fmpz_t D, fmpz_t p) noexcept - # Sets `r` to the unique prime `(p, b, c)` of discriminant `D`, i.e. with - # `0 < b \leq p`. We require that `p` is a prime. - int qfb_exponent_element(fmpz_t exponent, qfb_t f, fmpz_t n, ulong B1, ulong B2_sqrt) noexcept - # Find the exponent of the element `f` in the form class group of forms of - # discriminant `n`, doing a stage `1` with primes up to at least ``B1`` - # and a stage `2` for a single large prime up to at least the square of - # ``B2_sqrt``. If the function fails to find the exponent it returns `0`, - # otherwise the function returns `1` and ``exponent`` is set to the - # exponent of `f`, i.e. the minimum power of `f` which gives the identity. - # It is assumed that the form `f` is reduced. We require that ``iters`` - # is a power of `2` and that ``iters`` `\ge 1024`. - # The function performs a stage `2` which stores up to `4\times` - # ``iters`` binary quadratic forms, and `12\times` ``iters`` - # additional limbs of data in a hash table, where ``iters`` is the - # square root of ``B2``. - int qfb_exponent(fmpz_t exponent, fmpz_t n, ulong B1, ulong B2_sqrt, slong c) noexcept - # Compute the exponent of the class group of discriminant `n`, doing - # a stage `1` with primes up to at least ``B1`` and a stage `2` for - # a single large prime up to at least the square of ``B2_sqrt``, and - # with probability at least `1 - 2^{-c}`. If the prime limits are - # exhausted without finding the exponent, the function returns `0`, - # otherwise it returns `1` and ``exponent`` is set to the computed - # exponent, i.e. the minimum power to which every element of the - # class group has to be raised in order to get the identity. - # The function performs a stage `2` which stores up to `4\times` - # ``iters`` binary quadratic forms, and `12\times` ``iters`` - # additional limbs of data in a hash table, where ``iters`` is the - # square root of ``B2``. - # We use algorithm 8.1 of [Sut2007]_. - int qfb_exponent_grh(fmpz_t exponent, fmpz_t n, ulong B1, ulong B2_sqrt) noexcept - # Similar to ``qfb_exponent`` except that the bound ``c`` is - # automatically generated such that the exponent is guaranteed to be - # correct, if found, assuming the GRH, namely that the class group is - # generated by primes less than `6\log^2(|n|)` as described in [BD1992]_. diff --git a/src/sage/libs/flint/qqbar.pxd b/src/sage/libs/flint/qqbar.pxd index b49a764bb0a..aafe994212f 100644 --- a/src/sage/libs/flint/qqbar.pxd +++ b/src/sage/libs/flint/qqbar.pxd @@ -2,7 +2,9 @@ # distutils: depends = flint/qqbar.h ################################################################################ -# This file is auto-generated. Do not modify by hand +# This file is auto-generated by the script +# SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py. +# Do not modify by hand! Fix and rerun the script instead. ################################################################################ from libc.stdio cimport FILE @@ -11,233 +13,73 @@ from sage.libs.mpfr.types cimport * from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void qqbar_init(qqbar_t res) noexcept - # Initializes the variable *res* for use, and sets its value to zero. - void qqbar_clear(qqbar_t res) noexcept - # Clears the variable *res*, freeing or recycling its allocated memory. - qqbar_ptr _qqbar_vec_init(slong len) noexcept - # Returns a pointer to an array of *len* initialized *qqbar_struct*:s. - void _qqbar_vec_clear(qqbar_ptr vec, slong len) noexcept - # Clears all *len* entries in the vector *vec* and frees the - # vector itself. - void qqbar_swap(qqbar_t x, qqbar_t y) noexcept - # Swaps the values of *x* and *y* efficiently. - void qqbar_set(qqbar_t res, const qqbar_t x) noexcept void qqbar_set_si(qqbar_t res, slong x) noexcept void qqbar_set_ui(qqbar_t res, ulong x) noexcept void qqbar_set_fmpz(qqbar_t res, const fmpz_t x) noexcept void qqbar_set_fmpq(qqbar_t res, const fmpq_t x) noexcept - # Sets *res* to the value *x*. - void qqbar_set_re_im(qqbar_t res, const qqbar_t x, const qqbar_t y) noexcept - # Sets *res* to the value `x + yi`. - int qqbar_set_d(qqbar_t res, double x) noexcept int qqbar_set_re_im_d(qqbar_t res, double x, double y) noexcept - # Sets *res* to the value *x* or `x + yi` respectively. These functions - # performs error handling: if *x* and *y* are finite, the conversion succeeds - # and the return flag is 1. If *x* or *y* is non-finite (infinity or NaN), - # the conversion fails and the return flag is 0. - slong qqbar_degree(const qqbar_t x) noexcept - # Returns the degree of *x*, i.e. the degree of the minimal polynomial. - bint qqbar_is_rational(const qqbar_t x) noexcept - # Returns whether *x* is a rational number. - bint qqbar_is_integer(const qqbar_t x) noexcept - # Returns whether *x* is an integer (an element of `\mathbb{Z}`). - bint qqbar_is_algebraic_integer(const qqbar_t x) noexcept - # Returns whether *x* is an algebraic integer, i.e. whether its minimal - # polynomial has leading coefficient 1. - bint qqbar_is_zero(const qqbar_t x) noexcept bint qqbar_is_one(const qqbar_t x) noexcept bint qqbar_is_neg_one(const qqbar_t x) noexcept - # Returns whether *x* is the number `0`, `1`, `-1`. - bint qqbar_is_i(const qqbar_t x) noexcept bint qqbar_is_neg_i(const qqbar_t x) noexcept - # Returns whether *x* is the imaginary unit `i` (respectively `-i`). - bint qqbar_is_real(const qqbar_t x) noexcept - # Returns whether *x* is a real number. - void qqbar_height(fmpz_t res, const qqbar_t x) noexcept - # Sets *res* to the height of *x* (the largest absolute value of the - # coefficients of the minimal polynomial of *x*). - slong qqbar_height_bits(const qqbar_t x) noexcept - # Returns the height of *x* (the largest absolute value of the - # coefficients of the minimal polynomial of *x*) measured in bits. - int qqbar_within_limits(const qqbar_t x, slong deg_limit, slong bits_limit) noexcept - # Checks if *x* has degree bounded by *deg_limit* and height - # bounded by *bits_limit* bits, returning 0 (false) or 1 (true). - # If *deg_limit* is set to 0, the degree check is skipped, - # and similarly for *bits_limit*. - int qqbar_binop_within_limits(const qqbar_t x, const qqbar_t y, slong deg_limit, slong bits_limit) noexcept - # Checks if `x + y`, `x - y`, `x \cdot y` and `x / y` certainly have - # degree bounded by *deg_limit* (by multiplying the degrees for *x* and *y* - # to obtain a trivial bound). For *bits_limits*, the sum of the bit heights - # of *x* and *y* is checked against the bound (this is only a heuristic). - # If *deg_limit* is set to 0, the degree check is skipped, - # and similarly for *bits_limit*. - void _qqbar_get_fmpq(fmpz_t num, fmpz_t den, const qqbar_t x) noexcept - # Sets *num* and *den* to the numerator and denominator of *x*. - # Aborts if *x* is not a rational number. - void qqbar_get_fmpq(fmpq_t res, const qqbar_t x) noexcept - # Sets *res* to *x*. Aborts if *x* is not a rational number. - void qqbar_get_fmpz(fmpz_t res, const qqbar_t x) noexcept - # Sets *res* to *x*. Aborts if *x* is not an integer. - void qqbar_zero(qqbar_t res) noexcept - # Sets *res* to the number 0. - void qqbar_one(qqbar_t res) noexcept - # Sets *res* to the number 1. - void qqbar_i(qqbar_t res) noexcept - # Sets *res* to the imaginary unit `i`. - void qqbar_phi(qqbar_t res) noexcept - # Sets *res* to the golden ratio `\varphi = \tfrac{1}{2}(\sqrt{5} + 1)`. - void qqbar_print(const qqbar_t x) noexcept - # Prints *res* to standard output. The output shows the degree - # and the list of coefficients - # of the minimal polynomial followed by a decimal representation of - # the enclosing interval. This function is mainly intended for debugging. - void qqbar_printn(const qqbar_t x, slong n) noexcept - # Prints *res* to standard output. The output shows a decimal - # approximation to *n* digits. - void qqbar_printnd(const qqbar_t x, slong n) noexcept - # Prints *res* to standard output. The output shows a decimal - # approximation to *n* digits, followed by the degree of the number. - void qqbar_randtest(qqbar_t res, flint_rand_t state, slong deg, slong bits) noexcept - # Sets *res* to a random algebraic number with degree up to *deg* and - # with height (measured in bits) up to *bits*. - void qqbar_randtest_real(qqbar_t res, flint_rand_t state, slong deg, slong bits) noexcept - # Sets *res* to a random real algebraic number with degree up to *deg* and - # with height (measured in bits) up to *bits*. - void qqbar_randtest_nonreal(qqbar_t res, flint_rand_t state, slong deg, slong bits) noexcept - # Sets *res* to a random nonreal algebraic number with degree up to *deg* and - # with height (measured in bits) up to *bits*. Since all algebraic numbers - # of degree 1 are real, *deg* must be at least 2. - bint qqbar_equal(const qqbar_t x, const qqbar_t y) noexcept - # Returns whether *x* and *y* are equal. - bint qqbar_equal_fmpq_poly_val(const qqbar_t x, const fmpq_poly_t f, const qqbar_t y) noexcept - # Returns whether *x* is equal to `f(y)`. This function is more efficient - # than evaluating `f(y)` and comparing the results. - int qqbar_cmp_re(const qqbar_t x, const qqbar_t y) noexcept - # Compares the real parts of *x* and *y*, returning -1, 0 or +1. - int qqbar_cmp_im(const qqbar_t x, const qqbar_t y) noexcept - # Compares the imaginary parts of *x* and *y*, returning -1, 0 or +1. - int qqbar_cmpabs_re(const qqbar_t x, const qqbar_t y) noexcept - # Compares the absolute values of the real parts of *x* and *y*, returning -1, 0 or +1. - int qqbar_cmpabs_im(const qqbar_t x, const qqbar_t y) noexcept - # Compares the absolute values of the imaginary parts of *x* and *y*, returning -1, 0 or +1. - int qqbar_cmpabs(const qqbar_t x, const qqbar_t y) noexcept - # Compares the absolute values of *x* and *y*, returning -1, 0 or +1. - int qqbar_cmp_root_order(const qqbar_t x, const qqbar_t y) noexcept - # Compares *x* and *y* using an arbitrary but convenient ordering - # defined on the complex numbers. This is useful for sorting the - # roots of a polynomial in a canonical order. - # We define the root order as follows: real roots come first, in - # descending order. Nonreal roots are subsequently ordered first by - # real part in descending order, then in ascending order by the - # absolute value of the imaginary part, and then in descending - # order of the sign. This implies that complex conjugate roots - # are adjacent, with the root in the upper half plane first. - ulong qqbar_hash(const qqbar_t x) noexcept - # Returns a hash of *x*. As currently implemented, this function - # only hashes the minimal polynomial of *x*. The user should - # mix in some bits based on the numerical value if it is critical - # to distinguish between conjugates of the same minimal polynomial. - # This function is also likely to produce serial runs of values for - # lexicographically close minimal polynomials. This is not - # necessarily a problem for use in hash tables, but if it is - # important that all bits in the output are random, - # the user should apply an integer hash function to the output. - void qqbar_conj(qqbar_t res, const qqbar_t x) noexcept - # Sets *res* to the complex conjugate of *x*. - void qqbar_re(qqbar_t res, const qqbar_t x) noexcept - # Sets *res* to the real part of *x*. - void qqbar_im(qqbar_t res, const qqbar_t x) noexcept - # Sets *res* to the imaginary part of *x*. - void qqbar_re_im(qqbar_t res1, qqbar_t res2, const qqbar_t x) noexcept - # Sets *res1* to the real part of *x* and *res2* to the imaginary part of *x*. - void qqbar_abs(qqbar_t res, const qqbar_t x) noexcept - # Sets *res* to the absolute value of *x*: - void qqbar_abs2(qqbar_t res, const qqbar_t x) noexcept - # Sets *res* to the square of the absolute value of *x*. - void qqbar_sgn(qqbar_t res, const qqbar_t x) noexcept - # Sets *res* to the complex sign of *x*, defined as 0 if *x* is zero - # and as `x / |x|` otherwise. - int qqbar_sgn_re(const qqbar_t x) noexcept - # Returns the sign of the real part of *x* (-1, 0 or +1). - int qqbar_sgn_im(const qqbar_t x) noexcept - # Returns the sign of the imaginary part of *x* (-1, 0 or +1). - int qqbar_csgn(const qqbar_t x) noexcept - # Returns the extension of the real sign function taking the - # value 1 for *x* strictly in the right half plane, -1 for *x* strictly - # in the left half plane, and the sign of the imaginary part when *x* is on - # the imaginary axis. Equivalently, `\operatorname{csgn}(x) = x / \sqrt{x^2}` - # except that the value is 0 when *x* is zero. - void qqbar_floor(fmpz_t res, const qqbar_t x) noexcept - # Sets *res* to the floor function of *x*. If *x* is not real, the - # value is defined as the floor function of the real part of *x*. - void qqbar_ceil(fmpz_t res, const qqbar_t x) noexcept - # Sets *res* to the ceiling function of *x*. If *x* is not real, the - # value is defined as the ceiling function of the real part of *x*. - void qqbar_neg(qqbar_t res, const qqbar_t x) noexcept - # Sets *res* to the negation of *x*. - void qqbar_add(qqbar_t res, const qqbar_t x, const qqbar_t y) noexcept void qqbar_add_fmpq(qqbar_t res, const qqbar_t x, const fmpq_t y) noexcept void qqbar_add_fmpz(qqbar_t res, const qqbar_t x, const fmpz_t y) noexcept void qqbar_add_ui(qqbar_t res, const qqbar_t x, ulong y) noexcept void qqbar_add_si(qqbar_t res, const qqbar_t x, slong y) noexcept - # Sets *res* to the sum of *x* and *y*. - void qqbar_sub(qqbar_t res, const qqbar_t x, const qqbar_t y) noexcept void qqbar_sub_fmpq(qqbar_t res, const qqbar_t x, const fmpq_t y) noexcept void qqbar_sub_fmpz(qqbar_t res, const qqbar_t x, const fmpz_t y) noexcept @@ -247,25 +89,14 @@ cdef extern from "flint_wrap.h": void qqbar_fmpz_sub(qqbar_t res, const fmpz_t x, const qqbar_t y) noexcept void qqbar_ui_sub(qqbar_t res, ulong x, const qqbar_t y) noexcept void qqbar_si_sub(qqbar_t res, slong x, const qqbar_t y) noexcept - # Sets *res* to the difference of *x* and *y*. - void qqbar_mul(qqbar_t res, const qqbar_t x, const qqbar_t y) noexcept void qqbar_mul_fmpq(qqbar_t res, const qqbar_t x, const fmpq_t y) noexcept void qqbar_mul_fmpz(qqbar_t res, const qqbar_t x, const fmpz_t y) noexcept void qqbar_mul_ui(qqbar_t res, const qqbar_t x, ulong y) noexcept void qqbar_mul_si(qqbar_t res, const qqbar_t x, slong y) noexcept - # Sets *res* to the product of *x* and *y*. - void qqbar_mul_2exp_si(qqbar_t res, const qqbar_t x, slong e) noexcept - # Sets *res* to *x* multiplied by `2^e`. - void qqbar_sqr(qqbar_t res, const qqbar_t x) noexcept - # Sets *res* to the square of *x*. - void qqbar_inv(qqbar_t res, const qqbar_t x) noexcept - # Sets *res* to the multiplicative inverse of *y*. - # Division by zero calls *flint_abort*. - void qqbar_div(qqbar_t res, const qqbar_t x, const qqbar_t y) noexcept void qqbar_div_fmpq(qqbar_t res, const qqbar_t x, const fmpq_t y) noexcept void qqbar_div_fmpz(qqbar_t res, const qqbar_t x, const fmpz_t y) noexcept @@ -275,430 +106,65 @@ cdef extern from "flint_wrap.h": void qqbar_fmpz_div(qqbar_t res, const fmpz_t x, const qqbar_t y) noexcept void qqbar_ui_div(qqbar_t res, ulong x, const qqbar_t y) noexcept void qqbar_si_div(qqbar_t res, slong x, const qqbar_t y) noexcept - # Sets *res* to the quotient of *x* and *y*. - # Division by zero calls *flint_abort*. - void qqbar_scalar_op(qqbar_t res, const qqbar_t x, const fmpz_t a, const fmpz_t b, const fmpz_t c) noexcept - # Sets *res* to the rational affine transformation `(ax+b)/c`, performed as - # a single operation. There are no restrictions on *a*, *b* and *c* - # except that *c* must be nonzero. Division by zero calls *flint_abort*. - void qqbar_sqrt(qqbar_t res, const qqbar_t x) noexcept void qqbar_sqrt_ui(qqbar_t res, ulong x) noexcept - # Sets *res* to the principal square root of *x*. - void qqbar_rsqrt(qqbar_t res, const qqbar_t x) noexcept - # Sets *res* to the reciprocal of the principal square root of *x*. - # Division by zero calls *flint_abort*. - void qqbar_pow_ui(qqbar_t res, const qqbar_t x, ulong n) noexcept void qqbar_pow_si(qqbar_t res, const qqbar_t x, slong n) noexcept void qqbar_pow_fmpz(qqbar_t res, const qqbar_t x, const fmpz_t n) noexcept void qqbar_pow_fmpq(qqbar_t res, const qqbar_t x, const fmpq_t n) noexcept - # Sets *res* to *x* raised to the *n*-th power. - # Raising zero to a negative power aborts. - void qqbar_root_ui(qqbar_t res, const qqbar_t x, ulong n) noexcept void qqbar_fmpq_root_ui(qqbar_t res, const fmpq_t x, ulong n) noexcept - # Sets *res* to the principal *n*-th root of *x*. The order *n* - # must be positive. - void qqbar_fmpq_pow_si_ui(qqbar_t res, const fmpq_t x, slong m, ulong n) noexcept - # Sets *res* to the principal branch of `x^{m/n}`. The order *n* - # must be positive. Division by zero calls *flint_abort*. - int qqbar_pow(qqbar_t res, const qqbar_t x, const qqbar_t y) noexcept - # General exponentiation: if `x^y` is an algebraic number, sets *res* - # to this value and returns 1. If `x^y` is transcendental or - # undefined, returns 0. Note that this function returns 0 instead of - # aborting on division zero. - void qqbar_get_acb(acb_t res, const qqbar_t x, slong prec) noexcept - # Sets *res* to an enclosure of *x* rounded to *prec* bits. - void qqbar_get_arb(arb_t res, const qqbar_t x, slong prec) noexcept - # Sets *res* to an enclosure of *x* rounded to *prec* bits, assuming that - # *x* is a real number. If *x* is not real, *res* is set to - # `[\operatorname{NaN} \pm \infty]`. - void qqbar_get_arb_re(arb_t res, const qqbar_t x, slong prec) noexcept - # Sets *res* to an enclosure of the real part of *x* rounded to *prec* bits. - void qqbar_get_arb_im(arb_t res, const qqbar_t x, slong prec) noexcept - # Sets *res* to an enclosure of the imaginary part of *x* rounded to *prec* bits. - void qqbar_cache_enclosure(qqbar_t res, slong prec) noexcept - # Polishes the internal enclosure of *res* to at least *prec* bits - # of precision in-place. Normally, *qqbar* operations that need - # high-precision enclosures compute them on the fly without caching the results; - # if *res* will be used as an invariant operand for many operations, - # calling this function as a precomputation step can improve performance. - void qqbar_denominator(fmpz_t res, const qqbar_t y) noexcept - # Sets *res* to the denominator of *y*, i.e. the leading coefficient - # of the minimal polynomial of *y*. - void qqbar_numerator(qqbar_t res, const qqbar_t y) noexcept - # Sets *res* to the numerator of *y*, i.e. *y* multiplied by - # its denominator. - void qqbar_conjugates(qqbar_ptr res, const qqbar_t x) noexcept - # Sets the entries of the vector *res* to the *d* algebraic conjugates of - # *x*, including *x* itself, where *d* is the degree of *x*. The output - # is sorted in a canonical order (as defined by :func:`qqbar_cmp_root_order`). - void _qqbar_evaluate_fmpq_poly(qqbar_t res, const fmpz * poly, const fmpz_t den, slong len, const qqbar_t x) noexcept void qqbar_evaluate_fmpq_poly(qqbar_t res, const fmpq_poly_t poly, const qqbar_t x) noexcept void _qqbar_evaluate_fmpz_poly(qqbar_t res, const fmpz * poly, slong len, const qqbar_t x) noexcept void qqbar_evaluate_fmpz_poly(qqbar_t res, const fmpz_poly_t poly, const qqbar_t x) noexcept - # Sets *res* to the value of the given polynomial *poly* evaluated at - # the algebraic number *x*. These methods detect simple special cases and - # automatically reduce *poly* if its degree is greater or equal - # to that of the minimal polynomial of *x*. In the generic case, evaluation - # is done by computing minimal polynomials of representation matrices. - int qqbar_evaluate_fmpz_mpoly_iter(qqbar_t res, const fmpz_mpoly_t poly, qqbar_srcptr x, slong deg_limit, slong bits_limit, const fmpz_mpoly_ctx_t ctx) noexcept int qqbar_evaluate_fmpz_mpoly_horner(qqbar_t res, const fmpz_mpoly_t poly, qqbar_srcptr x, slong deg_limit, slong bits_limit, const fmpz_mpoly_ctx_t ctx) noexcept int qqbar_evaluate_fmpz_mpoly(qqbar_t res, const fmpz_mpoly_t poly, qqbar_srcptr x, slong deg_limit, slong bits_limit, const fmpz_mpoly_ctx_t ctx) noexcept - # Sets *res* to the value of *poly* evaluated at the algebraic numbers - # given in the vector *x*. The number of variables is defined by - # the context object *ctx*. - # The parameters *deg_limit* and *bits_limit* - # define evaluation limits: if any temporary result exceeds these limits - # (not necessarily the final value, in case of cancellation), the - # evaluation is aborted and 0 (failure) is returned. If evaluation - # succeeds, 1 is returned. - # The *iter* version iterates over all terms in succession and computes - # the powers that appear. The *horner* version uses a multivariate - # implementation of the Horner scheme. The default algorithm currently - # uses the Horner scheme. - void qqbar_roots_fmpz_poly(qqbar_ptr res, const fmpz_poly_t poly, int flags) noexcept void qqbar_roots_fmpq_poly(qqbar_ptr res, const fmpq_poly_t poly, int flags) noexcept - # Sets the entries of the vector *res* to the *d* roots of the polynomial - # *poly*. Roots with multiplicity appear with repetition in the - # output array. By default, the roots will be sorted in a - # convenient canonical order (as defined by :func:`qqbar_cmp_root_order`). - # Instances of a repeated root always appear consecutively. - # The following *flags* are supported: - # - QQBAR_ROOTS_IRREDUCIBLE - if set, *poly* is assumed to be - # irreducible (it may still have constant content), and no polynomial - # factorization is performed internally. - # - QQBAR_ROOTS_UNSORTED - if set, the roots will not be guaranteed - # to be sorted (except for repeated roots being listed - # consecutively). - void qqbar_eigenvalues_fmpz_mat(qqbar_ptr res, const fmpz_mat_t mat, int flags) noexcept void qqbar_eigenvalues_fmpq_mat(qqbar_ptr res, const fmpq_mat_t mat, int flags) noexcept - # Sets the entries of the vector *res* to the eigenvalues of the - # square matrix *mat*. These functions compute the characteristic polynomial - # of *mat* and then call :func:`qqbar_roots_fmpz_poly` with the same - # flags. - void qqbar_root_of_unity(qqbar_t res, slong p, ulong q) noexcept - # Sets *res* to the root of unity `e^{2 \pi i p / q}`. - bint qqbar_is_root_of_unity(slong * p, ulong * q, const qqbar_t x) noexcept - # If *x* is not a root of unity, returns 0. - # If *x* is a root of unity, returns 1. - # If *p* and *q* are not *NULL* and *x* is a root of unity, - # this also sets *p* and *q* to the minimal integers with `0 \le p < q` - # such that `x = e^{2 \pi i p / q}`. - void qqbar_exp_pi_i(qqbar_t res, slong p, ulong q) noexcept - # Sets *res* to the root of unity `e^{\pi i p / q}`. - void qqbar_cos_pi(qqbar_t res, slong p, ulong q) noexcept void qqbar_sin_pi(qqbar_t res, slong p, ulong q) noexcept int qqbar_tan_pi(qqbar_t res, slong p, ulong q) noexcept int qqbar_cot_pi(qqbar_t res, slong p, ulong q) noexcept int qqbar_sec_pi(qqbar_t res, slong p, ulong q) noexcept int qqbar_csc_pi(qqbar_t res, slong p, ulong q) noexcept - # Sets *res* to the trigonometric function `\cos(\pi x)`, - # `\sin(\pi x)`, etc., with `x = \tfrac{p}{q}`. - # The functions tan, cot, sec and csc return the flag 1 if the value exists, - # and return 0 if the evaluation point is a pole of the function. - int qqbar_log_pi_i(slong * p, ulong * q, const qqbar_t x) noexcept - # If `y = \operatorname{log}(x) / (\pi i)` is algebraic, and hence - # necessarily rational, sets `y = p / q` to the reduced such - # fraction with `-1 < y \le 1` and returns 1. - # If *y* is not algebraic, returns 0. - int qqbar_atan_pi(slong * p, ulong * q, const qqbar_t x) noexcept - # If `y = \operatorname{atan}(x) / \pi` is algebraic, and hence - # necessarily rational, sets `y = p / q` to the reduced such - # fraction with `|y| < \tfrac{1}{2}` and returns 1. - # If *y* is not algebraic, returns 0. - int qqbar_asin_pi(slong * p, ulong * q, const qqbar_t x) noexcept - # If `y = \operatorname{asin}(x) / \pi` is algebraic, and hence - # necessarily rational, sets `y = p / q` to the reduced such - # fraction with `|y| \le \tfrac{1}{2}` and returns 1. - # If *y* is not algebraic, returns 0. - int qqbar_acos_pi(slong * p, ulong * q, const qqbar_t x) noexcept - # If `y = \operatorname{acos}(x) / \pi` is algebraic, and hence - # necessarily rational, sets `y = p / q` to the reduced such - # fraction with `0 \le y \le 1` and returns 1. - # If *y* is not algebraic, returns 0. - int qqbar_acot_pi(slong * p, ulong * q, const qqbar_t x) noexcept - # If `y = \operatorname{acot}(x) / \pi` is algebraic, and hence - # necessarily rational, sets `y = p / q` to the reduced such - # fraction with `-\tfrac{1}{2} < y \le \tfrac{1}{2}` and returns 1. - # If *y* is not algebraic, returns 0. - int qqbar_asec_pi(slong * p, ulong * q, const qqbar_t x) noexcept - # If `y = \operatorname{asec}(x) / \pi` is algebraic, and hence - # necessarily rational, sets `y = p / q` to the reduced such - # fraction with `0 \le y \le 1` and returns 1. - # If *y* is not algebraic, returns 0. - int qqbar_acsc_pi(slong * p, ulong * q, const qqbar_t x) noexcept - # If `y = \operatorname{acsc}(x) / \pi` is algebraic, and hence - # necessarily rational, sets `y = p / q` to the reduced such - # fraction with `-\tfrac{1}{2} \le y \le \tfrac{1}{2}` and returns 1. - # If *y* is not algebraic, returns 0. - int qqbar_guess(qqbar_t res, const acb_t z, slong max_deg, slong max_bits, int flags, slong prec) noexcept - # Attempts to find an algebraic number *res* of degree at most *max_deg* and - # height at most *max_bits* bits matching the numerical enclosure *z*. - # The return flag indicates success. - # This is only a heuristic method, and the return flag neither implies a - # rigorous proof that *res* is the correct result, nor a rigorous proof - # that no suitable algebraic number with the given *max_deg* and *max_bits* - # exists. (Proof of nonexistence could in principle be computed, - # but this is not yet implemented.) - # The working precision *prec* should normally be the same as the precision - # used to compute *z*. It does not make much sense to run this algorithm - # with precision smaller than O(*max_deg* · *max_bits*). - # This function does a single iteration at the target *max_deg*, *max_bits*, - # and *prec*. For best performance, one should invoke this function - # repeatedly with successively larger parameters when the size of the - # intended solution is unknown or may be much smaller than a worst-case bound. - int qqbar_express_in_field(fmpq_poly_t res, const qqbar_t alpha, const qqbar_t x, slong max_bits, int flags, slong prec) noexcept - # Attempts to express *x* in the number field generated by *alpha*, returning - # success (0 or 1). On success, *res* is set to a polynomial *f* of degree - # less than the degree of *alpha* and with height (counting both the numerator - # and the denominator, when the coefficients of *g* are - # put on a common denominator) bounded by *max_bits* bits, such that - # `f(\alpha) = x`. - # (Exception: the *max_bits* parameter is currently ignored if *x* is - # rational, in which case *res* is just set to the value of *x*.) - # This function looks for a linear relation heuristically using a working - # precision of *prec* bits. If *x* is expressible in terms of *alpha*, - # then this function is guaranteed to succeed when *prec* is taken - # large enough. The identity `f(\alpha) = x` is checked - # rigorously, i.e. a return value of 1 implies a proof of correctness. - # In principle, choosing a sufficiently large *prec* can be used to - # prove that *x* does not lie in the field generated by *alpha*, - # but the present implementation does not support doing so automatically. - # This function does a single iteration at the target *max_bits* and - # and *prec*. For best performance, one should invoke this function - # repeatedly with successively larger parameters when the size of the - # intended solution is unknown or may be much smaller than a worst-case bound. - void qqbar_get_quadratic(fmpz_t a, fmpz_t b, fmpz_t c, fmpz_t q, const qqbar_t x, int factoring) noexcept - # Assuming that *x* has degree 1 or 2, computes integers *a*, *b*, *c* - # and *q* such that - # .. math :: - # x = \frac{a + b \sqrt{c}}{q} - # and such that *c* is not a perfect square, *q* is positive, and - # *q* has no content in common with both *a* and *b*. In other words, - # this determines a quadratic field `\mathbb{Q}(\sqrt{c})` containing - # *x*, and then finds the canonical reduced coefficients *a*, *b* and - # *q* expressing *x* in this field. - # For convenience, this function supports rational *x*, - # for which *b* and *c* will both be set to zero. - # The following remarks apply to irrationals. - # The radicand *c* will not be a perfect square, but will not - # automatically be squarefree since this would require factoring the - # discriminant. As a special case, *c* will be set to `-1` if *x* - # is a Gaussian rational number. Otherwise, behavior is controlled - # by the *factoring* parameter. - # * If *factoring* is 0, no factorization is performed apart from - # removing powers of two. - # * If *factoring* is 1, a complete factorization is performed (*c* - # will be minimal). This can be very expensive if the discriminant - # is large. - # * If *factoring* is 2, a smooth factorization is performed to remove - # small factors from *c*. This is a tradeoff that provides pretty - # output in most cases while avoiding extreme worst-case slowdown. - # The smooth factorization guarantees finding all small factors - # (up to some trial division limit determined internally by Flint), - # but large factors are only found heuristically. - int qqbar_set_fexpr(qqbar_t res, const fexpr_t expr) noexcept - # Sets *res* to the algebraic number represented by the symbolic - # expression *expr*, returning 1 on success and 0 on failure. - # This function performs a "static" evaluation using *qqbar* arithmetic, - # supporting only closed-form expressions with explicitly algebraic - # subexpressions. It can be used to recover values generated by - # :func:`qqbar_get_expr_formula` and variants. - # For evaluating more complex expressions involving other - # types of values or requiring symbolic simplifications, - # the user should preprocess *expr* so that it is in a form - # which can be parsed by :func:`qqbar_set_fexpr`. - # The following expressions are supported: - # * Integer constants - # * Arithmetic operations with algebraic operands - # * Square roots of algebraic numbers - # * Powers with algebraic base and exponent an explicit rational number - # * NumberI, GoldenRatio, RootOfUnity - # * Floor, Ceil, Abs, Sign, Csgn, Conjugate, Re, Im, Max, Min - # * Trigonometric functions with argument an explicit rational number times Pi - # * Exponentials with argument an explicit rational number times Pi * NumberI - # * The Decimal() constructor - # * AlgebraicNumberSerialized() (assuming valid data, which is not checked) - # * PolynomialRootIndexed() - # * PolynomialRootNearest() - # Examples of formulas that are not supported, despite the value being - # an algebraic number: - # * ``Pi - Pi`` (general transcendental simplifications are not performed) - # * ``1 / Infinity`` (only numbers are handled) - # * ``Sum(n, For(n, 1, 10))`` (only static evaluation is performed) - void qqbar_get_fexpr_repr(fexpr_t res, const qqbar_t x) noexcept - # Sets *res* to a symbolic expression reflecting the exact internal - # representation of *x*. The output will have the form - # ``AlgebraicNumberSerialized(List(coeffs), enclosure)``. - # The output can be converted back to a ``qqbar_t`` value using - # :func:`qqbar_set_fexpr`. This is the recommended format for - # serializing algebraic numbers as it requires minimal computation, - # but it has the disadvantage of not being human-readable. - void qqbar_get_fexpr_root_nearest(fexpr_t res, const qqbar_t x) noexcept - # Sets *res* to a symbolic expression unambiguously describing *x* - # in the form ``PolynomialRootNearest(List(coeffs), point)`` - # where *point* is an approximation of *x* guaranteed to be closer - # to *x* than any conjugate root. - # The output can be converted back to a ``qqbar_t`` value using - # :func:`qqbar_set_fexpr`. This is a useful format for human-readable - # presentation, but serialization and deserialization can be expensive. - void qqbar_get_fexpr_root_indexed(fexpr_t res, const qqbar_t x) noexcept - # Sets *res* to a symbolic expression unambiguously describing *x* - # in the form ``PolynomialRootIndexed(List(coeffs), index)`` - # where *index* is the index of *x* among its conjugate roots - # in the builtin root sort order. - # The output can be converted back to a ``qqbar_t`` value using - # :func:`qqbar_set_fexpr`. This is a useful format for human-readable - # presentation when the numerical value is important, but serialization - # and deserialization can be expensive. - int qqbar_get_fexpr_formula(fexpr_t res, const qqbar_t x, ulong flags) noexcept - # Attempts to express the algebraic number *x* as a closed-form expression - # using arithmetic operations, radicals, and possibly exponentials - # or trigonometric functions, but without using ``PolynomialRootNearest`` - # or ``PolynomialRootIndexed``. - # Returns 0 on failure and 1 on success. - # The *flags* parameter toggles different methods for generating formulas. - # It can be set to any combination of the following. If *flags* is 0, - # only rational numbers will be handled. - # .. macro:: QQBAR_FORMULA_ALL - # Toggles all methods (potentially expensive). - # .. macro:: QQBAR_FORMULA_GAUSSIANS - # Detect Gaussian rational numbers `a + bi`. - # .. macro:: QQBAR_FORMULA_QUADRATICS - # Solve quadratics in the form `a + b \sqrt{d}`. - # .. macro:: QQBAR_FORMULA_CYCLOTOMICS - # Detect elements of cyclotomic fields. This works by trying plausible - # cyclotomic fields (based on the degree of the input), using LLL - # to find candidate number field elements, and certifying candidates - # through an exact computation. Detection is heuristic and - # is not guaranteed to find all cyclotomic numbers. - # .. macro:: QQBAR_FORMULA_CUBICS - # QQBAR_FORMULA_QUARTICS - # QQBAR_FORMULA_QUINTICS - # Solve polynomials of degree 3, 4 and (where applicable) 5 using - # cubic, quartic and quintic formulas (not yet implemented). - # .. macro:: QQBAR_FORMULA_DEPRESSION - # Use depression to try to generate simpler numbers. - # .. macro:: QQBAR_FORMULA_DEFLATION - # Use deflation to try to generate simpler numbers. - # This allows handling number of the form `a^{1/n}` where *a* can - # be represented in closed form. - # .. macro:: QQBAR_FORMULA_SEPARATION - # Try separating real and imaginary parts or sign and magnitude of - # complex numbers. This allows handling numbers of the form `a + bi` - # or `m \cdot s` (with `m > 0, |s| = 1`) where *a* and *b* or *m* and *s* can be - # represented in closed form. This is only attempted as a fallback after - # other methods fail: if an explicit Cartesian or magnitude-sign - # represented is desired, the user should manually separate the number - # into complex parts before calling :func:`qqbar_get_fexpr_formula`. - # .. macro:: QQBAR_FORMULA_EXP_FORM - # QQBAR_FORMULA_TRIG_FORM - # QQBAR_FORMULA_RADICAL_FORM - # QQBAR_FORMULA_AUTO_FORM - # Select output form for cyclotomic numbers. The *auto* form (equivalent - # to no flags being set) results in radicals for numbers of low degree, - # trigonometric functions for real numbers, and complex exponentials - # for nonreal numbers. The other flags (not fully implemented) can be - # used to force exponential form, trigonometric form, or radical form. - void qqbar_fmpz_poly_composed_op(fmpz_poly_t res, const fmpz_poly_t A, const fmpz_poly_t B, int op) noexcept - # Given nonconstant polynomials *A* and *B*, sets *res* to a polynomial - # whose roots are `a+b`, `a-b`, `ab` or `a/b` for all roots *a* of *A* - # and all roots *b* of *B*. The parameter *op* selects the arithmetic - # operation: 0 for addition, 1 for subtraction, 2 for multiplication - # and 3 for division. If *op* is 3, *B* must not have zero as a root. - void qqbar_binary_op(qqbar_t res, const qqbar_t x, const qqbar_t y, int op) noexcept - # Performs a binary operation using a generic algorithm. This does not - # check for special cases. - int _qqbar_validate_uniqueness(acb_t res, const fmpz_poly_t poly, const acb_t z, slong max_prec) noexcept - # Given *z* known to be an enclosure of at least one root of *poly*, - # certifies that the enclosure contains a unique root, and in that - # case sets *res* to a new (possibly improved) enclosure for the same - # root, returning 1. Returns 0 if uniqueness cannot be certified. - # The enclosure is validated by performing a single step with the - # interval Newton method. The working precision is determined from the - # accuracy of *z*, but limited by *max_prec* bits. - # This method slightly inflates the enclosure *z* to improve the chances - # that the interval Newton step will succeed. Uniqueness on this larger - # interval implies uniqueness of the original interval, but not - # existence; when existence has not been ensured a priori, - # :func:`_qqbar_validate_existence_uniqueness` should be used instead. - int _qqbar_validate_existence_uniqueness(acb_t res, const fmpz_poly_t poly, const acb_t z, slong max_prec) noexcept - # Given any complex interval *z*, certifies that the enclosure contains a - # unique root of *poly*, and in that case sets *res* to a new (possibly - # improved) enclosure for the same root, returning 1. Returns 0 if - # existence and uniqueness cannot be certified. - # The enclosure is validated by performing a single step with the - # interval Newton method. The working precision is determined from the - # accuracy of *z*, but limited by *max_prec* bits. - void _qqbar_enclosure_raw(acb_t res, const fmpz_poly_t poly, const acb_t z, slong prec) noexcept void qqbar_enclosure_raw(acb_t res, const qqbar_t x, slong prec) noexcept - # Sets *res* to an enclosure of *x* accurate to about *prec* bits - # (the actual accuracy can be slightly lower, or higher). - # This function uses repeated interval Newton steps to polish the initial - # enclosure *z*, doubling the working precision each time. If any step - # fails to improve the accuracy significantly, the root is recomputed - # from scratch to higher precision. - # If the initial enclosure is accurate enough, *res* is set to this value - # without rounding and without further computation. - int _qqbar_acb_lindep(fmpz * rel, acb_srcptr vec, slong len, int check, slong prec) noexcept - # Attempts to find an integer vector *rel* giving a linear relation between - # the elements of the real or complex vector *vec*, using the LLL algorithm. - # The working precision is set to the minimum of *prec* and the relative - # accuracy of *vec* (that is, the difference between the largest magnitude - # and the largest error magnitude within *vec*). 95% of the bits within the - # working precision are used for the LLL matrix, and the remaining 5% bits - # are used to validate the linear relation by evaluating the linear - # combination and checking that the resulting interval contains zero. - # This validation does not prove the existence or nonexistence - # of a linear relation, but it provides a quick heuristic way to eliminate - # spurious relations. - # If *check* is set, the return value indicates whether the validation - # was successful; otherwise, the return value simply indicates whether - # the algorithm was executed normally (failure may occur, for example, - # if the input vector is non-finite). - # In principle, this method can be used to produce a proof that no linear - # relation exists with coefficients up to a specified bit size, but this has - # not yet been implemented. diff --git a/src/sage/libs/flint/qsieve.pxd b/src/sage/libs/flint/qsieve.pxd index a8ffecc5e13..fe25087758c 100644 --- a/src/sage/libs/flint/qsieve.pxd +++ b/src/sage/libs/flint/qsieve.pxd @@ -2,7 +2,9 @@ # distutils: depends = flint/qsieve.h ################################################################################ -# This file is auto-generated. Do not modify by hand +# This file is auto-generated by the script +# SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py. +# Do not modify by hand! Fix and rerun the script instead. ################################################################################ from libc.stdio cimport FILE @@ -11,120 +13,27 @@ from sage.libs.mpfr.types cimport * from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - mp_limb_t qsieve_knuth_schroeppel(qs_t qs_inf) noexcept - # Return the Knuth-Schroeppel multiplier for the `n`, integer to be factored - # based upon the Knuth-Schroeppel function. - mp_limb_t qsieve_primes_init(qs_t qs_inf) noexcept - # Compute the factor base prime along with there inverse for `kn`, where `k` - # is Knuth-Schroeppel multiplier and `n` is the integer to be factored. It - # also computes the square root of `kn` modulo factor base primes. - mp_limb_t qsieve_primes_increment(qs_t qs_inf, mp_limb_t delta) noexcept - # It increase the number of factor base primes by amount 'delta' and - # calculate inverse of those primes along with the square root of `kn` modulo - # those primes. - void qsieve_init_A0(qs_t qs_inf) noexcept - # First it chooses the possible range of factor of `A _0`, based on the number - # of bits in optimal value of `A _0`. It tries to select range such that we have - # plenty of primes to choose from as well as number of factor in `A _0` are - # sufficient. For input of size less than 130 bit, this selection method doesn't - # work therefore we randomly generate 2 or 3-subset of all the factor base prime - # as the factor of `A _0`. - # Otherwise, if we have to select `s` factor for `A _0`, we generate `s - 1`- - # subset from odd indices of the possible range of factor and then search last - # factor using binary search from the even indices of possible range of factor - # such that value of `A _0` is close to it's optimal value. - void qsieve_next_A0(qs_t qs_inf) noexcept - # Find next candidate for `A _0` as follows: - # generate next lexicographic `s - 1`-subset from the odd indices of possible - # range of factor base and choose the last factor from even indices using binary - # search so that value `A _0` is close to it's optimal value. - void qsieve_compute_pre_data(qs_t qs_inf) noexcept - # Precompute all the data associated with factor's of `A _0`, since `A _0` is going - # to be fixed for several `A`. - void qsieve_init_poly_first(qs_t qs_inf) noexcept - # Initializes the value of `A = q _0 * A _0`, where `q _0` is non-factor base prime. - # precompute the data necessary for generating different `B` value using grey code - # formula. Combine the data calculated for the factor of `A _0` along with the - # parameter `q _0` to obtain data as for factor of `A`. It also calculates the sieve - # offset for all the factor base prime, for first polynomial. - void qsieve_init_poly_next(qs_t qs_inf, slong i) noexcept - # Generate next polynomial or next `B` value for particular `A` and also updates the - # sieve offsets for all the factor base prime, for this `B` value. - void qsieve_compute_C(fmpz_t C, qs_t qs_inf, qs_poly_t poly) noexcept - # Given `A` and `B`, calculate `C = (B ^2 - A) / N`. - void qsieve_do_sieving(qs_t qs_inf, unsigned char * sieve, qs_poly_t poly) noexcept - # First initialize the sieve array to zero, then for each `p \in` ``factor base``, add - # `\log_2(p)` to the locations `\operatorname{soln1} _p + i * p` and `\operatorname{soln2} _p + i * p` for - # `i = 0, 1, 2,\dots`, where `\operatorname{soln1} _p` and `\operatorname{soln2} _p` are the sieve offsets calculated - # for `p`. - void qsieve_do_sieving2(qs_t qs_inf, unsigned char * seive, qs_poly_t poly) noexcept - # Perform the same task as above but instead of sieving over whole array at once divide - # the array in blocks and then sieve over each block for all the primes in factor base. - slong qsieve_evaluate_candidate(qs_t qs_inf, ulong i, unsigned char * sieve, qs_poly_t poly) noexcept - # For location `i` in sieve array value at which, is greater than sieve threshold, check - # the value of `Q(x)` at position `i` for smoothness. If value is found to be smooth then - # store it for later processing, else check the residue for the partial if it is found to - # be partial then store it for late processing. - slong qsieve_evaluate_sieve(qs_t qs_inf, unsigned char * sieve, qs_poly_t poly) noexcept - # Scan the sieve array for location at, which accumulated value is greater than sieve - # threshold. - slong qsieve_collect_relations(qs_t qs_inf, unsigned char * sieve) noexcept - # Call for initialization of polynomial, sieving, and scanning of sieve - # for all the possible polynomials for particular hypercube i.e. `A`. - - void qsieve_write_to_file(qs_t qs_inf, mp_limb_t prime, fmpz_t Y, qs_poly_t poly) noexcept - # Write a relation to the file. Format is as follows, - # first write large prime, in case of full relation it is 1, then write exponent - # of small primes, then write number of factor followed by offset of factor in - # factor base and their exponent and at last value of `Q(x)` for particular relation. - # each relation is written in new line. - + void qsieve_write_to_file(qs_t qs_inf, mp_limb_t prime, const fmpz_t Y, const qs_poly_t poly) noexcept hash_t * qsieve_get_table_entry(qs_t qs_inf, mp_limb_t prime) noexcept - # Return the pointer to the location of 'prime' is hash table if it exist, else - # create and entry for it in hash table and return pointer to that. - void qsieve_add_to_hashtable(qs_t qs_inf, mp_limb_t prime) noexcept - # Add 'prime' to the hast table. - relation_t qsieve_parse_relation(qs_t qs_inf, char * str) noexcept - # Given a string representation of relation from the file, parse it to obtain - # all the parameters of relation. - relation_t qsieve_merge_relation(qs_t qs_inf, relation_t a, relation_t b) noexcept - # Given two partial relation having same large prime, merge them to obtain a full - # relation. - int qsieve_compare_relation(const void * a, const void * b) noexcept - # Compare two relation based on, first large prime, then number of factor and then - # offsets of factor in factor base. - int qsieve_remove_duplicates(relation_t * rel_list, slong num_relations) noexcept - # Remove duplicate from given list of relations by sorting relations in the list. - void qsieve_insert_relation2(qs_t qs_inf, relation_t * rel_list, slong num_relations) noexcept - # Given a list of relations, insert each relation from the list into the matrix for - # further processing. - int qsieve_process_relation(qs_t qs_inf) noexcept - # After we have accumulated required number of relations, first process the file by - # reading all the relations, removes singleton. Then merge all the possible partial - # to obtain full relations. - void qsieve_factor(fmpz_factor_t factors, const fmpz_t n) noexcept - # Factor `n` using the quadratic sieve method. It is required that `n` is not a - # prime and not a perfect power. There is no guarantee that the factors found will - # be prime, or distinct. diff --git a/src/sage/libs/flint/qsieve_sage.pyx b/src/sage/libs/flint/qsieve_sage.pyx index 6f8fb58fe52..93c2ce6b7ed 100644 --- a/src/sage/libs/flint/qsieve_sage.pyx +++ b/src/sage/libs/flint/qsieve_sage.pyx @@ -8,7 +8,7 @@ from cysignals.signals cimport sig_on, sig_off from .types cimport fmpz_t, fmpz_factor_t from .fmpz cimport fmpz_init, fmpz_set_mpz from .fmpz_factor cimport fmpz_factor_init, fmpz_factor_clear -from .fmpz_factor_extra cimport fmpz_factor_to_pairlist +from .fmpz_factor_sage cimport fmpz_factor_to_pairlist from .qsieve cimport qsieve_factor from sage.rings.integer cimport Integer diff --git a/src/sage/libs/flint/thread_pool.pxd b/src/sage/libs/flint/thread_pool.pxd index 05f70383ef5..137eae2b7a6 100644 --- a/src/sage/libs/flint/thread_pool.pxd +++ b/src/sage/libs/flint/thread_pool.pxd @@ -2,7 +2,9 @@ # distutils: depends = flint/thread_pool.h ################################################################################ -# This file is auto-generated. Do not modify by hand +# This file is auto-generated by the script +# SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py. +# Do not modify by hand! Fix and rerun the script instead. ################################################################################ from libc.stdio cimport FILE @@ -11,39 +13,11 @@ from sage.libs.mpfr.types cimport * from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - void thread_pool_init(thread_pool_t T, slong size) noexcept - # Initialise ``T`` and create ``size`` sleeping - # threads that are available to work. - # If `size \le 0` no threads are created and future calls to - # :func:`thread_pool_request` will return `0` (unless - # :func:`thread_pool_set_size` has been called). - slong thread_pool_get_size(thread_pool_t T) noexcept - # Return the number of threads in ``T``. - int thread_pool_set_size(thread_pool_t T, slong new_size) noexcept - # If all threads in ``T`` are in the available state, resize ``T`` and return 1. - # Otherwise, return ``0``. - slong thread_pool_request(thread_pool_t T, thread_pool_handle * out, slong requested) noexcept - # Put at most ``requested`` threads in the unavailable state and return - # their handles. The handles are written to ``out`` and the number of - # handles written is returned. These threads must be released by a call to - # ``thread_pool_give_back``. - void thread_pool_wake(thread_pool_t T, thread_pool_handle i, int max_workers, void (*f)(void*), void * a) noexcept - # Wake up a sleeping thread ``i`` and have it work on ``f(a)``. The thread - # being woken will be allowed to start ``max_workers`` additional worker - # threads. Usually this value should be set to ``0``. - void thread_pool_wait(thread_pool_t T, thread_pool_handle i) noexcept - # Wait for thread ``i`` to finish working and go back to sleep. - void thread_pool_give_back(thread_pool_t T, thread_pool_handle i) noexcept - # Put thread ``i`` back in the available state. This thread should be sleeping - # when this function is called. - void thread_pool_clear(thread_pool_t T) noexcept - # Release any resources used by ``T``. All threads should be given back before - # this function is called. diff --git a/src/sage/libs/flint/types.pxd b/src/sage/libs/flint/types.pxd index 4ef65f1d3a7..8d23a1d480d 100644 --- a/src/sage/libs/flint/types.pxd +++ b/src/sage/libs/flint/types.pxd @@ -1,4 +1,4 @@ -# distutils: depends = flint/fmpz_poly_mat.h flint/fmpq_mpoly.h flint/nmod_poly_mat.h flint/perm.h flint/nmod_vec.h flint/fmpzi.h flint/mpoly.h flint/mpfr_mat.h flint/nmod_poly.h flint/long_extras.h flint/partitions.h flint/fq_nmod_poly_factor.h flint/mpf_mat.h flint/fmpz_poly_q.h flint/ca_vec.h flint/double_extras.h flint/fq_nmod_mpoly_factor.h flint/fmpz_mpoly.h flint/fmpq_vec.h flint/fq_poly.h flint/fq_nmod_mat.h flint/calcium.h flint/fmpz_vec.h flint/fexpr_builtin.h flint/ca_poly.h flint/fq_embed.h flint/nmod_poly_factor.h flint/fmpz_extras.h flint/acb_mat.h flint/gr_generic.h flint/gr_poly.h flint/fq_zech_poly_factor.h flint/fmpz_mpoly_q.h flint/nmod.h flint/ca_mat.h flint/fq_zech_vec.h flint/arb.h flint/nf_elem.h flint/fmpz_poly.h flint/fq_nmod_embed.h flint/arb_poly.h flint/fmpq.h flint/fmpq_mpoly_factor.h flint/acb_calc.h flint/fq_vec.h flint/padic_mat.h flint/fmpz.h flint/fmpz_mat.h flint/fmpz_mod_mat.h flint/fq_zech.h flint/double_interval.h flint/fq_default_mat.h flint/fmpz_mod_mpoly.h flint/qsieve.h flint/qfb.h flint/thread_pool.h flint/fmpz_mod_mpoly_factor.h flint/acb_modular.h flint/fq_nmod_poly.h flint/profiler.h flint/acb_hypgeom.h flint/d_mat.h flint/fq_zech_poly.h flint/fmpz_mod.h flint/qqbar.h flint/hypgeom.h flint/acb_elliptic.h flint/acb_dft.h flint/d_vec.h flint/ulong_extras.h flint/dlog.h flint/bool_mat.h flint/fmpq_poly.h flint/fexpr.h flint/mag.h flint/fmpz_mpoly_factor.h flint/mpfr_vec.h flint/ca_ext.h flint/gr.h flint/acb_poly.h flint/fft.h flint/padic.h flint/dirichlet.h flint/fmpz_mod_poly_factor.h flint/fq_default.h flint/fq.h flint/gr_vec.h flint/fq_nmod.h flint/fq_zech_embed.h flint/nmod_mpoly_factor.h flint/flint.h flint/fmpz_factor.h flint/qadic.h flint/nf.h flint/gr_mpoly.h flint/arb_fpwrap.h flint/fq_default_poly.h flint/aprcl.h flint/acf.h flint/gr_special.h flint/arf.h flint/fq_zech_mat.h flint/gr_mat.h flint/arb_fmpz_poly.h flint/fq_nmod_vec.h flint/fmpz_mod_poly.h flint/bernoulli.h flint/fq_default_poly_factor.h flint/arb_mat.h flint/arb_hypgeom.h flint/fq_poly_factor.h flint/nmod_mpoly.h flint/acb.h flint/fmpz_lll.h flint/fmpz_poly_factor.h flint/ca_field.h flint/acb_dirichlet.h flint/arith.h flint/fmpz_mod_vec.h flint/fmpq_mat.h flint/fq_mat.h flint/mpn_extras.h flint/mpf_vec.h flint/ca.h flint/padic_poly.h flint/nmod_mat.h flint/fq_nmod_mpoly.h flint/arb_calc.h flint/nmod_types.h +# distutils: depends = flint/acb.h flint/acb_calc.h flint/acb_dft.h flint/acb_dirichlet.h flint/acb_elliptic.h flint/acb_hypgeom.h flint/acb_mat.h flint/acb_modular.h flint/acb_poly.h flint/acf.h flint/aprcl.h flint/arb.h flint/arb_calc.h flint/arb_fmpz_poly.h flint/arb_fpwrap.h flint/arb_hypgeom.h flint/arb_mat.h flint/arb_poly.h flint/arf.h flint/arith.h flint/bernoulli.h flint/bool_mat.h flint/ca.h flint/ca_ext.h flint/ca_field.h flint/ca_mat.h flint/ca_poly.h flint/ca_vec.h flint/calcium.h flint/d_mat.h flint/d_vec.h flint/dirichlet.h flint/dlog.h flint/double_extras.h flint/double_interval.h flint/fexpr.h flint/fexpr_builtin.h flint/fft.h flint/flint.h flint/fmpq.h flint/fmpq_mat.h flint/fmpq_mpoly.h flint/fmpq_mpoly_factor.h flint/fmpq_poly.h flint/fmpq_vec.h flint/fmpz.h flint/fmpz_extras.h flint/fmpz_factor.h flint/fmpz_lll.h flint/fmpz_mat.h flint/fmpz_mod.h flint/fmpz_mod_mat.h flint/fmpz_mod_mpoly.h flint/fmpz_mod_mpoly_factor.h flint/fmpz_mod_poly.h flint/fmpz_mod_poly_factor.h flint/fmpz_mod_vec.h flint/fmpz_mpoly.h flint/fmpz_mpoly_factor.h flint/fmpz_mpoly_q.h flint/fmpz_poly.h flint/fmpz_poly_factor.h flint/fmpz_poly_mat.h flint/fmpz_poly_q.h flint/fmpz_vec.h flint/fmpzi.h flint/fq.h flint/fq_default.h flint/fq_default_mat.h flint/fq_default_poly.h flint/fq_default_poly_factor.h flint/fq_embed.h flint/fq_mat.h flint/fq_nmod.h flint/fq_nmod_embed.h flint/fq_nmod_mat.h flint/fq_nmod_mpoly.h flint/fq_nmod_mpoly_factor.h flint/fq_nmod_poly.h flint/fq_nmod_poly_factor.h flint/fq_nmod_vec.h flint/fq_poly.h flint/fq_poly_factor.h flint/fq_vec.h flint/fq_zech.h flint/fq_zech_embed.h flint/fq_zech_mat.h flint/fq_zech_poly.h flint/fq_zech_poly_factor.h flint/fq_zech_vec.h flint/gr.h flint/gr_generic.h flint/gr_mat.h flint/gr_mpoly.h flint/gr_poly.h flint/gr_special.h flint/gr_vec.h flint/hypgeom.h flint/long_extras.h flint/mag.h flint/mpf_mat.h flint/mpf_vec.h flint/mpfr_mat.h flint/mpfr_vec.h flint/mpn_extras.h flint/mpoly.h flint/nf.h flint/nf_elem.h flint/nmod.h flint/nmod_mat.h flint/nmod_mpoly.h flint/nmod_mpoly_factor.h flint/nmod_poly.h flint/nmod_poly_factor.h flint/nmod_poly_mat.h flint/nmod_types.h flint/nmod_vec.h flint/padic.h flint/padic_mat.h flint/padic_poly.h flint/partitions.h flint/perm.h flint/profiler.h flint/qadic.h flint/qfb.h flint/qqbar.h flint/qsieve.h flint/thread_pool.h flint/ulong_extras.h """ Declarations for FLINT types @@ -27,7 +27,6 @@ cdef extern from "flint_wrap.h": ctypedef slong fmpz ctypedef fmpz fmpz_t[1] - bint COEFF_IS_MPZ(fmpz) mpz_ptr COEFF_TO_PTR(fmpz) ctypedef struct fmpz_preinvn_struct: @@ -149,7 +148,6 @@ cdef extern from "flint_wrap.h": ctypedef const acb_struct * acb_srcptr - # flint/acb_mat.h ctypedef struct acb_mat_struct: pass @@ -244,6 +242,16 @@ cdef extern from "flint_wrap.h": ctypedef acb_dirichlet_platt_ws_precomp_struct acb_dirichlet_platt_ws_precomp_t[1] + # flint/acb_theta.h + cdef struct acb_theta_eld_struct: + pass + ctypedef acb_theta_eld_struct acb_theta_eld_t[1] + + ctypedef void (*acb_theta_naive_worker_t)(acb_ptr, acb_srcptr, acb_srcptr, const slong *, + slong, const acb_t, const slong *, slong, slong, slong, slong) + ctypedef int (*acb_theta_ql_worker_t)(acb_ptr, acb_srcptr, acb_srcptr, + arb_srcptr, arb_srcptr, const acb_mat_t, slong, slong) + # flint/d_mat.h ctypedef struct d_mat_struct: double * entries @@ -921,6 +929,18 @@ cdef extern from "flint_wrap.h": ctypedef fmpq_mpoly_univar_struct fmpq_mpoly_univar_t[1] + # flint/fft_small.h + ctypedef struct mpn_ctx_struct: + pass + ctypedef mpn_ctx_struct mpn_ctx_t[1] + + ctypedef struct mul_precomp_struct: + pass + + ctypedef struct nmod_poly_divrem_precomp_struct: + pass + + # flint/nf.h ctypedef struct nf_struct: pass @@ -943,6 +963,26 @@ cdef extern from "flint_wrap.h": ctypedef nf_elem_struct nf_elem_t[1] + # flint/machine_vectors.h + ctypedef struct vec1n: + pass + ctypedef struct vec2n: + pass + ctypedef struct vec4n: + pass + ctypedef struct vec8n: + pass + + ctypedef struct vec1d: + pass + ctypedef struct vec2d: + pass + ctypedef struct vec4d: + pass + ctypedef struct vec8d: + pass + + # flint/calcium.h ctypedef struct calcium_stream_struct: pass @@ -1706,7 +1746,7 @@ cdef extern from "flint_wrap.h": ctypedef void ((*gr_method_init_clear_op)(gr_ptr, gr_ctx_ptr)) ctypedef void ((*gr_method_swap_op)(gr_ptr, gr_ptr, gr_ctx_ptr)) ctypedef int ((*gr_method_ctx)(gr_ctx_ptr)) - # NOTE: we removed an extra paranthesis so that Cython is less confused + # NOTE: we removed an extra parenthesis so that Cython is less confused # see https://github.com/cython/cython/issues/5779 ctypedef truth_t (*gr_method_ctx_predicate)(gr_ctx_ptr) ctypedef int ((*gr_method_ctx_set_si)(gr_ctx_ptr, slong)) @@ -1767,7 +1807,7 @@ cdef extern from "flint_wrap.h": ctypedef int ((*gr_method_quaternary_binary_op)(gr_ptr, gr_ptr, gr_ptr, gr_ptr, gr_srcptr, gr_srcptr, gr_ctx_ptr)) ctypedef int ((*gr_method_quaternary_ternary_op)(gr_ptr, gr_ptr, gr_ptr, gr_ptr, gr_srcptr, gr_srcptr, gr_srcptr, gr_ctx_ptr)) ctypedef int ((*gr_method_si_si_quaternary_op)(gr_ptr, slong, slong, gr_srcptr, gr_srcptr, gr_ctx_ptr)) - # NOTE: we removed an extra paranthesis so that Cython is less confused + # NOTE: we removed an extra parenthesis so that Cython is less confused # see https://github.com/cython/cython/issues/5779 ctypedef truth_t (*gr_method_unary_predicate)(gr_srcptr, gr_ctx_ptr) ctypedef truth_t (*gr_method_binary_predicate)(gr_srcptr, gr_srcptr, gr_ctx_ptr) @@ -1786,7 +1826,7 @@ cdef extern from "flint_wrap.h": ctypedef int ((*gr_method_vec_scalar_op_ui)(gr_ptr, gr_srcptr, slong, ulong, gr_ctx_ptr)) ctypedef int ((*gr_method_vec_scalar_op_fmpz)(gr_ptr, gr_srcptr, slong, const fmpz_t, gr_ctx_ptr)) ctypedef int ((*gr_method_vec_scalar_op_fmpq)(gr_ptr, gr_srcptr, slong, const fmpq_t, gr_ctx_ptr)) - # NOTE: we removed an extra paranthesis so that Cython is less confused + # NOTE: we removed an extra parenthesis so that Cython is less confused # see https://github.com/cython/cython/issues/5779 ctypedef truth_t (*gr_method_vec_predicate)(gr_srcptr, slong, gr_ctx_ptr) ctypedef truth_t (*gr_method_vec_vec_predicate)(gr_srcptr, gr_srcptr, slong, gr_ctx_ptr) diff --git a/src/sage/libs/flint/ulong_extras.pxd b/src/sage/libs/flint/ulong_extras.pxd index cce0a3bdffc..8593c3725f2 100644 --- a/src/sage/libs/flint/ulong_extras.pxd +++ b/src/sage/libs/flint/ulong_extras.pxd @@ -2,7 +2,9 @@ # distutils: depends = flint/ulong_extras.h ################################################################################ -# This file is auto-generated. Do not modify by hand +# This file is auto-generated by the script +# SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py. +# Do not modify by hand! Fix and rerun the script instead. ################################################################################ from libc.stdio cimport FILE @@ -11,1097 +13,127 @@ from sage.libs.mpfr.types cimport * from sage.libs.flint.types cimport * cdef extern from "flint_wrap.h": - ulong n_randlimb(flint_rand_t state) noexcept - # Returns a uniformly pseudo random limb. - # The algorithm generates two random half limbs `s_j`, `j = 0, 1`, - # by iterating respectively `v_{i+1} = (v_i a + b) \bmod{p_j}` for - # some initial seed `v_0`, randomly chosen values `a` and `b` and - # ``p_0 = 4294967311 = nextprime(2^32)`` on a 64-bit machine - # and ``p_0 = nextprime(2^16)`` on a 32-bit machine and - # ``p_1 = nextprime(p_0)``. - ulong n_randbits(flint_rand_t state, unsigned int bits) noexcept - # Returns a uniformly pseudo random number with the given number of - # bits. The most significant bit is always set, unless zero is passed, - # in which case zero is returned. - ulong n_randtest_bits(flint_rand_t state, int bits) noexcept - # Returns a uniformly pseudo random number with the given number of - # bits. The most significant bit is always set, unless zero is passed, - # in which case zero is returned. The probability of a value with a - # sparse binary representation being returned is increased. This - # function is intended for use in test code. - ulong n_randint(flint_rand_t state, ulong limit) noexcept - # Returns a uniformly pseudo random number up to but not including - # the given limit. If zero is passed as a parameter, an entire random - # limb is returned. - ulong n_urandint(flint_rand_t state, ulong limit) noexcept - # Returns a uniformly pseudo random number up to but not including - # the given limit. If zero is passed as a parameter, an entire - # random limb is returned. This function provides somewhat better - # randomness as compared to :func:`n_randint`, especially for larger - # values of limit. - ulong n_randtest(flint_rand_t state) noexcept - # Returns a pseudo random number with a random number of bits, - # from `0` to ``FLINT_BITS``. The probability of the special - # values `0`, `1`, ``COEFF_MAX`` and ``WORD_MAX`` is increased - # as is the probability of a value with sparse binary representation. - # This random function is mainly used for testing purposes. - # This function is intended for use in test code. - ulong n_randtest_not_zero(flint_rand_t state) noexcept - # As for :func:`n_randtest`, but does not return `0`. - # This function is intended for use in test code. - ulong n_randprime(flint_rand_t state, ulong bits, int proved) noexcept - # Returns a random prime number ``(proved = 1)`` or probable prime - # ``(proved = 0)`` - # with ``bits`` bits, where ``bits`` must be at least 2 and - # at most ``FLINT_BITS``. - ulong n_randtest_prime(flint_rand_t state, int proved) noexcept - # Returns a random prime number ``(proved = 1)`` or probable - # prime ``(proved = 0)`` - # with size randomly chosen between 2 and ``FLINT_BITS`` bits. - # This function is intended for use in test code. - ulong n_pow(ulong n, ulong exp) noexcept - # Returns ``n^exp``. No checking is done for overflow. The exponent - # may be zero. We define `0^0 = 1`. - # The algorithm simply uses a for loop. Repeated squaring is - # unlikely to speed up this algorithm. - ulong n_flog(ulong n, ulong b) noexcept - # Returns `\lfloor\log_b n\rfloor`. - # Assumes that `n \geq 1` and `b \geq 2`. - ulong n_clog(ulong n, ulong b) noexcept - # Returns `\lceil\log_b n\rceil`. - # Assumes that `n \geq 1` and `b \geq 2`. - ulong n_clog_2exp(ulong n, ulong b) noexcept - # Returns `\lceil\log_b 2^n\rceil`. - # Assumes that `b \geq 2`. - ulong n_revbin(ulong n, ulong b) noexcept - # Returns the binary reverse of `n`, assuming it is `b` bits in length, - # e.g. ``n_revbin(10110, 6)`` will return ``110100``. - int n_sizeinbase(ulong n, int base) noexcept - # Returns the exact number of digits needed to represent `n` as a - # string in base ``base`` assumed to be between 2 and 36. - # Returns 1 when `n = 0`. - ulong n_preinvert_limb_prenorm(ulong n) noexcept - # Computes an approximate inverse ``invxl`` of the limb ``xl``, - # with an implicit leading~`1`. More formally it computes:: - # invxl = (B^2 - B*x - 1)/x = (B^2 - 1)/x - B - # Note that `x` must be normalised, i.e. with msb set. This inverse - # makes use of the following theorem of Torbjorn Granlund and Peter - # Montgomery~[Lemma~8.1][GraMon1994]_: - # Let `d` be normalised, `d < B`, i.e. it fits in a word, and suppose - # that `m d < B^2 \leq (m+1) d`. Let `0 \leq n \leq B d - 1`. Write - # `n = n_2 B + n_1 B/2 + n_0` with `n_1 = 0` or `1` and `n_0 < B/2`. - # Suppose `q_1 B + q_0 = n_2 B + (n_2 + n_1) (m - B) + n_1 (d-B/2) + n_0` - # and `0 \leq q_0 < B`. Then `0 \leq q_1 < B` and `0 \leq n - q_1 d < 2 d`. - # In the theorem, `m` is the inverse of `d`. If we let - # ``m = invxl + B`` and `d = x` we have `m d = B^2 - 1 < B^2` and - # `(m+1) x = B^2 + d - 1 \geq B^2`. - # The theorem is often applied as follows: note that `n_0` and `n_1 (d-B/2)` - # are both less than `B/2`. Also note that `n_1 (m-B) < B`. Thus the sum of - # all these terms contributes at most `1` to `q_1`. We are left with - # `n_2 B + n_2 (m-B)`. But note that `(m-B)` is precisely our precomputed - # inverse ``invxl``. If we write `q_1 B + q_0 = n_2 B + n_2 (m-B)`, - # then from the theorem, we have `0 \leq n - q_1 d < 3 d`, i.e. the - # quotient is out by at most `2` and is always either correct or too small. - ulong n_preinvert_limb(ulong n) noexcept - # Returns a precomputed inverse of `n`, as defined in [GraMol2010]_. - # This precomputed inverse can be used with all of the functions that - # take a precomputed inverse whose names are suffixed by ``_preinv``. - # We require `n > 0`. - double n_precompute_inverse(ulong n) noexcept - # Returns a precomputed inverse of `n` with double precision value `1/n`. - # This precomputed inverse can be used with all of the functions that - # take a precomputed inverse whose names are suffixed by ``_precomp``. - # We require `n > 0`. - ulong n_mod_precomp(ulong a, ulong n, double ninv) noexcept - # Returns `a \bmod{n}` given a precomputed inverse of `n` computed - # by :func:`n_precompute_inverse`. We require ``n < 2^FLINT_D_BITS`` - # and ``a < 2^(FLINT_BITS-1)`` and `0 \leq a < n^2`. - # We assume the processor is in the standard round to nearest - # mode. Thus ``ninv`` is correct to `53` binary bits, the least - # significant bit of which we shall call a place, and can be at most - # half a place out. When `a` is multiplied by `ninv`, the binary - # representation of `a` is exact and the mantissa is less than `2`, thus we - # see that ``a * ninv`` can be at most one out in the mantissa. We now - # truncate ``a * ninv`` to the nearest integer, which is always a round - # down. Either we already have an integer, or we need to make a change down - # of at least `1` in the last place. In the latter case we either get - # precisely the exact quotient or below it as when we rounded the - # product to the nearest place we changed by at most half a place. - # In the case that truncating to an integer takes us below the - # exact quotient, we have rounded down by less than `1` plus half a - # place. But as the product is less than `n` and `n` is less than `2^{53}`, - # half a place is less than `1`, thus we are out by less than `2` from - # the exact quotient, i.e. the quotient we have computed is the - # quotient we are after or one too small. That leaves only the case - # where we had to round up to the nearest place which happened to - # be an integer, so that truncating to an integer didn't change - # anything. But this implies that the exact quotient `a/n` is less - # than `2^{-54}` from an integer. We deal with this rare case by - # subtracting 1 from the quotient. Then the quotient we have computed is - # either exactly what we are after, or one too small. - ulong n_mod2_precomp(ulong a, ulong n, double ninv) noexcept - # Returns `a \bmod{n}` given a precomputed inverse of `n` computed by - # :func:`n_precompute_inverse`. There are no restrictions on `a` or - # on `n`. - # As for :func:`n_mod_precomp` for `n < 2^{53}` and `a < n^2` the - # computed quotient is either what we are after or one too large or small. - # We deal with these cases. Otherwise we can be sure that the - # top `52` bits of the quotient are computed correctly. We take - # the remainder and adjust the quotient by multiplying the - # remainder by ``ninv`` to compute another approximate quotient as - # per :func:`mod_precomp`. Now the remainder may be either - # negative or positive, so the quotient we compute may be one - # out in either direction. - ulong n_divrem2_preinv(ulong * q, ulong a, ulong n, ulong ninv) noexcept - # Returns `a \bmod{n}` and sets `q` to the quotient of `a` by `n`, given a - # precomputed inverse of `n` computed by :func:`n_preinvert_limb()`. There are - # no restrictions on `a` and the only restriction on `n` is that it be - # nonzero. - # This uses the algorithm of Granlund and Möller [GraMol2010]_. First - # `n` is normalised and `a` is shifted into two limbs to compensate. Then - # their algorithm is applied verbatim and the remainder shifted back. - ulong n_div2_preinv(ulong a, ulong n, ulong ninv) noexcept - # Returns the Euclidean quotient of `a` by `n` given a precomputed inverse of - # `n` computed by :func:`n_preinvert_limb`. There are no restrictions on `a` - # and the only restriction on `n` is that it be nonzero. - # This uses the algorithm of Granlund and Möller [GraMol2010]_. First - # `n` is normalised and `a` is shifted into two limbs to compensate. Then - # their algorithm is applied verbatim. - ulong n_mod2_preinv(ulong a, ulong n, ulong ninv) noexcept - # Returns `a \bmod{n}` given a precomputed inverse of `n` computed by - # :func:`n_preinvert_limb()`. There are no restrictions on `a` and the only - # restriction on `n` is that it be nonzero. - # This uses the algorithm of Granlund and Möller [GraMol2010]_. First - # `n` is normalised and `a` is shifted into two limbs to compensate. Then - # their algorithm is applied verbatim and the result shifted back. - ulong n_divrem2_precomp(ulong * q, ulong a, ulong n, double npre) noexcept - # Returns `a \bmod{n}` given a precomputed inverse of `n` computed by - # :func:`n_precompute_inverse` and sets `q` to the quotient. There - # are no restrictions on `a` or on `n`. - # This is as for :func:`n_mod2_precomp` with some additional care taken - # to retain the quotient information. There are also special - # cases to deal with the case where `a` is already reduced modulo - # `n` and where `n` is `64` bits and `a` is not reduced modulo `n`. - ulong n_ll_mod_preinv(ulong a_hi, ulong a_lo, ulong n, ulong ninv) noexcept - # Returns `a \bmod{n}` given a precomputed inverse of `n` computed by - # :func:`n_preinvert_limb`. There are no restrictions on `a`, which - # will be two limbs ``(a_hi, a_lo)``, or on `n`. - # The old version of this function merely reduced the top limb - # ``a_hi`` modulo `n` so that :func:`udiv_qrnnd_preinv()` could - # be used. - # The new version reduces the top limb modulo `n` as per - # :func:`n_mod2_preinv` and then the algorithm of Granlund and - # Möller [GraMol2010]_ is used again to reduce modulo `n`. - ulong n_lll_mod_preinv(ulong a_hi, ulong a_mi, ulong a_lo, ulong n, ulong ninv) noexcept - # Returns `a \bmod{n}`, where `a` has three limbs ``(a_hi, a_mi, a_lo)``, - # given a precomputed inverse of `n` computed by :func:`n_preinvert_limb`. - # It is assumed that ``a_hi`` is reduced modulo `n`. There are no - # restrictions on `n`. - # This function uses the algorithm of Granlund and - # Möller [GraMol2010]_ to first reduce the top two limbs - # modulo `n`, then does the same on the bottom two limbs. - ulong n_mulmod_precomp(ulong a, ulong b, ulong n, double ninv) noexcept - # Returns `a b \bmod{n}` given a precomputed inverse of `n` - # computed by :func:`n_precompute_inverse`. We require - # ``n < 2^FLINT_D_BITS`` and `0 \leq a, b < n`. - # We assume the processor is in the standard round to nearest - # mode. Thus ``ninv`` is correct to `53` binary bits, the least - # significant bit of which we shall call a place, and can be at most half - # a place out. The product of `a` and `b` is computed with error at most - # half a place. When ``a * b`` is multiplied by `ninv` we find that the - # exact quotient and computed quotient differ by less than two places. As - # the quotient is less than `n` this means that the exact quotient is at - # most `1` away from the computed quotient. We truncate this quotient to - # an integer which reduces the value by less than `1`. We end up with a - # value which can be no more than two above the quotient we are after and - # no less than two below. However an argument similar to that for - # :func:`n_mod_precomp` shows that the truncated computed quotient cannot - # be two smaller than the truncated exact quotient. In other words the - # computed integer quotient is at most two above and one below the quotient - # we are after. - ulong n_mulmod2_preinv(ulong a, ulong b, ulong n, ulong ninv) noexcept - # Returns `a b \bmod{n}` given a precomputed inverse of `n` computed by - # :func:`n_preinvert_limb`. There are no restrictions on `a`, `b` or - # on `n`. This is implemented by multiplying using :func:`umul_ppmm` and - # then reducing using :func:`n_ll_mod_preinv`. - ulong n_mulmod2(ulong a, ulong b, ulong n) noexcept - # Returns `a b \bmod{n}`. There are no restrictions on `a`, `b` or - # on `n`. This is implemented by multiplying using :func:`umul_ppmm` and - # then reducing using :func:`n_ll_mod_preinv` after computing a precomputed - # inverse. - ulong n_mulmod_preinv(ulong a, ulong b, ulong n, ulong ninv, ulong norm) noexcept - # Returns `a b \pmod{n}` given a precomputed inverse of `n` computed by - # :func:`n_preinvert_limb`, assuming `a` and `b` are reduced modulo `n` - # and `n` is normalised, i.e. with most significant bit set. There are - # no other restrictions on `a`, `b` or `n`. - # The value ``norm`` is provided for convenience. As `n` is required - # to be normalised, it may be that `a` and `b` have been shifted to the - # left by ``norm`` bits before calling the function. Their product - # then has an extra factor of `2^\text{norm}`. Specifying a nonzero - # ``norm`` will shift the product right by this many bits before - # reducing it. - # The algorithm used is that of Granlund and Möller [GraMol2010]_. - ulong n_gcd(ulong x, ulong y) noexcept - # Returns the greatest common divisor `g` of `x` and `y`. No assumptions - # are made about the values `x` and `y`. - # This function wraps GMP's ``mpn_gcd_1``. - ulong n_gcdinv(ulong * a, ulong x, ulong y) noexcept - # Returns the greatest common divisor `g` of `x` and `y` and computes - # `a` such that `0 \leq a < y` and `a x = \gcd(x, y) \bmod{y}`, when - # this is defined. We require `x < y`. - # When `y = 1` the greatest common divisor is set to `1` and `a` is - # set to `0`. - # This is merely an adaption of the extended Euclidean algorithm - # computing just one cofactor and reducing it modulo `y`. - ulong n_xgcd(ulong * a, ulong * b, ulong x, ulong y) noexcept - # Returns the greatest common divisor `g` of `x` and `y` and unsigned - # values `a` and `b` such that `a x - b y = g`. We require `x \geq y`. - # We claim that computing the extended greatest common divisor via the - # Euclidean algorithm always results in cofactor `\lvert a \rvert < x/2`, - # `\lvert b\rvert < x/2`, with perhaps some small degenerate exceptions. - # We proceed by induction. - # Suppose we are at some step of the algorithm, with `x_n = q y_n + r` - # with `r \geq 1`, and suppose `1 = s y_n - t r` with - # `s < y_n / 2`, `t < y_n / 2` by hypothesis. - # Write `1 = s y_n - t (x_n - q y_n) = (s + t q) y_n - t x_n`. - # It suffices to show that `(s + t q) < x_n / 2` as `t < y_n / 2 < x_n / 2`, - # which will complete the induction step. - # But at the previous step in the backsubstitution we would have had - # `1 = s r - c d` with `s < r/2` and `c < r/2`. - # Then `s + t q < r/2 + y_n / 2 q = (r + q y_n)/2 = x_n / 2`. - # See the documentation of :func:`n_gcd` for a description of the - # branching in the algorithm, which is faster than using division. - int n_jacobi(mp_limb_signed_t x, ulong y) noexcept - # Computes the Jacobi symbol `\left(\frac{x}{y}\right)` for any `x` and odd `y`. - int n_jacobi_unsigned(ulong x, ulong y) noexcept - # Computes the Jacobi symbol, allowing `x` to go up to a full limb. - ulong n_addmod(ulong a, ulong b, ulong n) noexcept - # Returns `(a + b) \bmod{n}`. - ulong n_submod(ulong a, ulong b, ulong n) noexcept - # Returns `(a - b) \bmod{n}`. - ulong n_invmod(ulong x, ulong y) noexcept - # Returns the inverse of `x` modulo `y`, if it exists. Otherwise an exception - # is thrown. - # This is merely an adaption of the extended Euclidean algorithm - # with appropriate normalisation. - ulong n_powmod_precomp(ulong a, mp_limb_signed_t exp, ulong n, double npre) noexcept - # Returns ``a^exp`` modulo `n` given a precomputed inverse of `n` - # computed by :func:`n_precompute_inverse`. We require `n < 2^{53}` - # and `0 \leq a < n`. There are no restrictions on ``exp``, i.e. - # it can be negative. - # This is implemented as a standard binary powering algorithm using - # repeated squaring and reducing modulo `n` at each step. - ulong n_powmod_ui_precomp(ulong a, ulong exp, ulong n, double npre) noexcept - # Returns ``a^exp`` modulo `n` given a precomputed inverse of `n` - # computed by :func:`n_precompute_inverse`. We require `n < 2^{53}` - # and `0 \leq a < n`. The exponent ``exp`` is unsigned and so - # can be larger than allowed by :func:`n_powmod_precomp`. - # This is implemented as a standard binary powering algorithm using - # repeated squaring and reducing modulo `n` at each step. - ulong n_powmod(ulong a, mp_limb_signed_t exp, ulong n) noexcept - # Returns ``a^exp`` modulo `n`. We require ``n < 2^FLINT_D_BITS`` - # and `0 \leq a < n`. There are no restrictions on ``exp``, i.e. - # it can be negative. - # This is implemented by precomputing an inverse and calling the - # ``precomp`` version of this function. - ulong n_powmod2_preinv(ulong a, mp_limb_signed_t exp, ulong n, ulong ninv) noexcept - # Returns ``(a^exp) % n`` given a precomputed inverse of `n` computed - # by :func:`n_preinvert_limb`. We require `0 \leq a < n`, but there are no - # restrictions on `n` or on ``exp``, i.e. it can be negative. - # This is implemented as a standard binary powering algorithm using - # repeated squaring and reducing modulo `n` at each step. - # If ``exp`` is negative but `a` is not invertible modulo `n`, an - # exception is raised. - ulong n_powmod2(ulong a, mp_limb_signed_t exp, ulong n) noexcept - # Returns ``(a^exp) % n``. We require `0 \leq a < n`, but there are - # no restrictions on `n` or on ``exp``, i.e. it can be negative. - # This is implemented by precomputing an inverse limb and calling the - # ``preinv`` version of this function. - # If ``exp`` is negative but `a` is not invertible modulo `n`, an - # exception is raised. - ulong n_powmod2_ui_preinv(ulong a, ulong exp, ulong n, ulong ninv) noexcept - # Returns ``(a^exp) % n`` given a precomputed inverse of `n` computed - # by :func:`n_preinvert_limb`. We require `0 \leq a < n`, but there are no - # restrictions on `n`. The exponent ``exp`` is unsigned and so can be - # larger than allowed by :func:`n_powmod2_preinv`. - # This is implemented as a standard binary powering algorithm using - # repeated squaring and reducing modulo `n` at each step. - ulong n_powmod2_fmpz_preinv(ulong a, const fmpz_t exp, ulong n, ulong ninv) noexcept - # Returns ``(a^exp) % n`` given a precomputed inverse of `n` computed - # by :func:`n_preinvert_limb`. We require `0 \leq a < n`, but there are no - # restrictions on `n`. The exponent ``exp`` must not be negative. - # This is implemented as a standard binary powering algorithm using - # repeated squaring and reducing modulo `n` at each step. - ulong n_sqrtmod(ulong a, ulong p) noexcept - # If `p` is prime, compute a square root of `a` modulo `p` if `a` is a - # quadratic residue modulo `p`, otherwise return `0`. - # If `p` is not prime the result is with high probability `0`, indicating - # that `p` is not prime, or `a` is not a square modulo `p`. Otherwise the - # result is meaningless. - # Assumes that `a` is reduced modulo `p`. - slong n_sqrtmod_2pow(ulong ** sqrt, ulong a, slong exp) noexcept - # Computes all the square roots of ``a`` modulo ``2^exp``. The roots - # are stored in an array which is created and whose address is stored in - # the location pointed to by ``sqrt``. The array of roots is allocated - # by the function but must be cleaned up by the user by calling - # ``flint_free``. The number of roots is returned by the function. If - # ``a`` is not a quadratic residue modulo ``2^exp`` then 0 is - # returned by the function and the location ``sqrt`` points to is set to - # NULL. - slong n_sqrtmod_primepow(ulong ** sqrt, ulong a, ulong p, slong exp) noexcept - # Computes all the square roots of ``a`` modulo ``p^exp``. The roots - # are stored in an array which is created and whose address is stored in - # the location pointed to by ``sqrt``. The array of roots is allocated - # by the function but must be cleaned up by the user by calling - # ``flint_free``. The number of roots is returned by the function. If - # ``a`` is not a quadratic residue modulo ``p^exp`` then 0 is - # returned by the function and the location ``sqrt`` points to is set to - # NULL. - slong n_sqrtmodn(ulong ** sqrt, ulong a, n_factor_t * fac) noexcept - # Computes all the square roots of ``a`` modulo ``m`` given the - # factorisation of ``m`` in ``fac``. The roots are stored in an array - # which is created and whose address is stored in the location pointed to by - # ``sqrt``. The array of roots is allocated by the function but must be - # cleaned up by the user by calling :func:`flint_free`. The number of roots - # is returned by the function. If ``a`` is not a quadratic residue modulo - # ``m`` then 0 is returned by the function and the location ``sqrt`` - # points to is set to NULL. - mp_limb_t n_mulmod_shoup(mp_limb_t w, mp_limb_t t, mp_limb_t w_precomp, mp_limb_t p) noexcept - # Returns `w t \bmod{p}` given a precomputed scaled approximation of `w / p` - # computed by :func:`n_mulmod_precomp_shoup`. The value of `p` should be - # less than `2^{\mathtt{FLINT\_BITS} - 1}`. `w` and `t` should be less than `p`. - # Works faster than :func:`n_mulmod2_preinv` if `w` fixed and `t` from array - # (for example, scalar multiplication of vector). - mp_limb_t n_mulmod_precomp_shoup(mp_limb_t w, mp_limb_t p) noexcept - # Returns `w'`, scaled approximation of `w / p`. `w'` is equal to the integer - # part of `w \cdot 2^{\mathtt{FLINT\_BITS}} / p`. - int n_divides(mp_limb_t * q, mp_limb_t n, mp_limb_t p) noexcept - void n_primes_init(n_primes_t it) noexcept - # Initialises the prime number iterator ``iter`` for use. - void n_primes_clear(n_primes_t it) noexcept - # Clears memory allocated by the prime number iterator ``iter``. - ulong n_primes_next(n_primes_t it) noexcept - # Returns the next prime number and advances the state of ``iter``. - # The first call returns 2. - # Small primes are looked up from ``flint_small_primes``. - # When this table is exhausted, primes are generated in blocks - # by calling :func:`n_primes_sieve_range`. - void n_primes_jump_after(n_primes_t it, ulong n) noexcept - # Changes the state of ``iter`` to start generating primes - # after `n` (excluding `n` itself). - void n_primes_extend_small(n_primes_t it, ulong bound) noexcept - # Extends the table of small primes in ``iter`` to contain - # at least two primes larger than or equal to ``bound``. - void n_primes_sieve_range(n_primes_t it, ulong a, ulong b) noexcept - # Sets the block endpoints of ``iter`` to the smallest and - # largest odd numbers between `a` and `b` inclusive, and - # sieves to mark all odd primes in this range. - # The iterator state is changed to point to the first - # number in the sieved range. - void n_compute_primes(ulong num_primes) noexcept - # Precomputes at least ``num_primes`` primes and their ``double`` - # precomputed inverses and stores them in an internal cache. - # Assuming that FLINT has been built with support for thread-local storage, - # each thread has its own cache. - const ulong * n_primes_arr_readonly(ulong num_primes) noexcept - # Returns a pointer to a read-only array of the first ``num_primes`` - # prime numbers. The computed primes are cached for repeated calls. - # The pointer is valid until the user calls :func:`n_cleanup_primes` - # in the same thread. - const double * n_prime_inverses_arr_readonly(ulong n) noexcept - # Returns a pointer to a read-only array of inverses of the first - # ``num_primes`` prime numbers. The computed primes are cached for - # repeated calls. The pointer is valid until the user calls - # :func:`n_cleanup_primes` in the same thread. - void n_cleanup_primes() noexcept - # Frees the internal cache of prime numbers used by the current thread. - # This will invalidate any pointers returned by - # :func:`n_primes_arr_readonly` or :func:`n_prime_inverses_arr_readonly`. - ulong n_nextprime(ulong n, int proved) noexcept - # Returns the next prime after `n`. Assumes the result will fit in an - # ``ulong``. If proved is `0`, i.e. false, the prime is not - # proven prime, otherwise it is. - ulong n_prime_pi(ulong n) noexcept - # Returns the value of the prime counting function `\pi(n)`, i.e. the - # number of primes less than or equal to `n`. The invariant - # ``n_prime_pi(n_nth_prime(n)) == n``. - # Currently, this function simply extends the table of cached primes up to - # an upper limit and then performs a binary search. - - void n_prime_pi_bounds(ulong *lo, ulong *hi, ulong n) noexcept - # Calculates lower and upper bounds for the value of the prime counting - # function ``lo <= pi(n) <= hi``. If ``lo`` and ``hi`` point to - # the same location, the high value will be stored. - # This does a table lookup for small values, then switches over to some - # proven bounds. - # The upper approximation is `1.25506 n / \ln n`, and the - # lower is `n / \ln n`. These bounds are due to Rosser and - # Schoenfeld [RosSch1962]_ and valid for `n \geq 17`. - # We use the number of bits in `n` (or one less) to form an - # approximation to `\ln n`, taking care to use a value too - # small or too large to maintain the inequality. - + void n_prime_pi_bounds(ulong * lo, ulong * hi, ulong n) noexcept ulong n_nth_prime(ulong n) noexcept - # Returns the `n`\th prime number `p_n`, using the mathematical indexing - # convention `p_1 = 2, p_2 = 3, \dotsc`. - # This function simply ensures that the table of cached primes is large - # enough and then looks up the entry. - - void n_nth_prime_bounds(ulong *lo, ulong *hi, ulong n) noexcept - # Calculates lower and upper bounds for the `n`\th prime number `p_n` , - # ``lo <= p_n <= hi``. If ``lo`` and ``hi`` point to the same - # location, the high value will be stored. Note that this function will - # overflow for sufficiently large `n`. - # We use the following estimates, valid for `n > 5` : - # .. math :: - # p_n & > n (\ln n + \ln \ln n - 1) \\ - # p_n & < n (\ln n + \ln \ln n) \\ - # p_n & < n (\ln n + \ln \ln n - 0.9427) \quad (n \geq 15985) - # The first inequality was proved by Dusart [Dus1999]_, and the last - # is due to Massias and Robin [MasRob1996]_. For a further overview, - # see http://primes.utm.edu/howmany.shtml . - # We bound `\ln n` using the number of bits in `n` as in - # ``n_prime_pi_bounds()``, and estimate `\ln \ln n` to the nearest - # integer; this function is nearly constant. - + void n_nth_prime_bounds(ulong * lo, ulong * hi, ulong n) noexcept bint n_is_oddprime_small(ulong n) noexcept - # Returns `1` if `n` is an odd prime smaller than - # ``FLINT_ODDPRIME_SMALL_CUTOFF``. Expects `n` - # to be odd and smaller than the cutoff. - # This function merely uses a lookup table with one bit allocated for each - # odd number up to the cutoff. - bint n_is_oddprime_binary(ulong n) noexcept - # This function performs a simple binary search through - # the table of cached primes for `n`. If it exists in the array it returns - # `1`, otherwise `0`. For the algorithm to operate correctly - # `n` should be odd and at least `17`. - # Lower and upper bounds are computed with :func:`n_prime_pi_bounds`. - # Once we have bounds on where to look in the table, we - # refine our search with a simple binary algorithm, taking - # the top or bottom of the current interval as necessary. - bint n_is_prime_pocklington(ulong n, ulong iterations) noexcept - # Tests if `n` is a prime using the Pocklington--Lehmer primality - # test. If `1` is returned `n` has been proved prime. If `0` is returned - # `n` is composite. However `-1` may be returned if nothing was proved - # either way due to the number of iterations being too small. - # The most time consuming part of the algorithm is factoring - # `n - 1`. For this reason :func:`n_factor_partial` is used, - # which uses a combination of trial factoring and Hart's one - # line factor algorithm [Har2012]_ to try to quickly factor `n - 1`. - # Additionally if the cofactor is less than the square root of - # `n - 1` the algorithm can still proceed. - # One can also specify a number of iterations if less time - # should be taken. Simply set this to ``WORD(0)`` if this is irrelevant. - # In most cases a greater number of iterations will not - # significantly affect timings as most of the time is spent - # factoring. - # See - # https://mathworld.wolfram.com/PocklingtonsTheorem.html - # for a description of the algorithm. - bint n_is_prime_pseudosquare(ulong n) noexcept - # Tests if `n` is a prime according to Theorem 2.7 [LukPatWil1996]_. - # We first factor `N` using trial division up to some limit `B`. - # In fact, the number of primes used in the trial factoring is at - # most ``FLINT_PSEUDOSQUARES_CUTOFF``. - # Next we compute `N/B` and find the next pseudosquare `L_p` above - # this value, using a static table as per - # https://oeis.org/A002189/b002189.txt . - # As noted in the text, if `p` is prime then Step 3 will pass. This - # test rejects many composites, and so by this time we suspect - # that `p` is prime. If `N` is `3` or `7` modulo `8`, we are done, - # and `N` is prime. - # We now run a probable prime test, for which no known - # counterexamples are known, to reject any composites. We then - # proceed to prove `N` prime by executing Step 4. In the case that - # `N` is `1` modulo `8`, if Step 4 fails, we extend the number of primes - # `p_i` at Step 3 and hope to find one which passes Step 4. We take - # the test one past the largest `p` for which we have pseudosquares - # `L_p` tabulated, as this already corresponds to the next `L_p` which - # is bigger than `2^{64}` and hence larger than any prime we might be - # testing. - # As explained in the text, Condition 4 cannot fail if `N` is prime. - # The possibility exists that the probable prime test declares a - # composite prime. However in that case an error is printed, as - # that would be of independent interest. - bint n_is_prime(ulong n) noexcept - # Tests if `n` is a prime. This first sieves for small prime factors, - # then simply calls :func:`n_is_probabprime`. This has been checked - # against the tables of Feitsma and Galway - # http://www.cecm.sfu.ca/Pseudoprimes/index-2-to-64.html and thus - # constitutes a check for primality (rather than just pseudoprimality) - # up to `2^{64}`. - # In future, this test may produce and check a certificate of - # primality. This is likely to be significantly slower for prime - # inputs. - bint n_is_strong_probabprime_precomp(ulong n, double npre, ulong a, ulong d) noexcept - # Tests if `n` is a strong probable prime to the base `a`. We - # require that `d` is set to the largest odd factor of `n - 1` and - # ``npre`` is a precomputed inverse of `n` computed with - # :func:`n_precompute_inverse`. We also require that `n < 2^{53}`, - # `a` to be reduced modulo `n` and not `0` and `n` to be odd. - # If we write `n - 1 = 2^s d` where `d` is odd then `n` is a strong - # probable prime to the base `a`, i.e. an `a`-SPRP, if either - # `a^d = 1 \pmod n` or `(a^d)^{2^r} = -1 \pmod n` for some `r` less - # than `s`. - # A description of strong probable primes is given here: - # https://mathworld.wolfram.com/StrongPseudoprime.html - bint n_is_strong_probabprime2_preinv(ulong n, ulong ninv, ulong a, ulong d) noexcept - # Tests if `n` is a strong probable prime to the base `a`. We require - # that `d` is set to the largest odd factor of `n - 1` and ``npre`` - # is a precomputed inverse of `n` computed with :func:`n_preinvert_limb`. - # We require a to be reduced modulo `n` and not `0` and `n` to be odd. - # If we write `n - 1 = 2^s d` where `d` is odd then `n` is a strong - # probable prime to the base `a` (an `a`-SPRP) if either `a^d = 1 \pmod n` - # or `(a^d)^{2^r} = -1 \pmod n` for some `r` less than `s`. - # A description of strong probable primes is given here: - # https://mathworld.wolfram.com/StrongPseudoprime.html - bint n_is_probabprime_fermat(ulong n, ulong i) noexcept - # Returns `1` if `n` is a base `i` Fermat probable prime. Requires - # `1 < i < n` and that `i` does not divide `n`. - # By Fermat's Little Theorem if `i^{n-1}` is not congruent to `1` - # then `n` is not prime. - bint n_is_probabprime_fibonacci(ulong n) noexcept - # Let `F_j` be the `j`\th element of the Fibonacci sequence - # `0, 1, 1, 2, 3, 5, \dotsc`, starting at `j = 0`. Then if `n` is prime - # we have `F_{n - (n/5)} = 0 \pmod n`, where `(n/5)` is the Jacobi - # symbol. - # For further details, see pp. 142 [CraPom2005]_. - # We require that `n` is not divisible by `2` or `5`. - bint n_is_probabprime_BPSW(ulong n) noexcept - # Implements a Baillie--Pomerance--Selfridge--Wagstaff probable primality - # test. This is a variant of the usual BPSW test (which only uses strong - # base-2 probable prime and Lucas-Selfridge tests, see Baillie and - # Wagstaff [BaiWag1980]_). - # This implementation makes use of a weakening of the usual Baillie-PSW - # test given in [Chen2003]_, namely replacing the Lucas test with a - # Fibonacci test when `n \equiv 2, 3 \pmod{5}` (see also the comment on - # page 143 of [CraPom2005]_), regarding Fibonacci pseudoprimes. - # There are no known counterexamples to this being a primality test. - # Up to `2^{64}` the test we use has been checked against tables of - # pseudoprimes. Thus it is a primality test up to this limit. - bint n_is_probabprime_lucas(ulong n) noexcept - # For details on Lucas pseudoprimes, see [pp. 143] [CraPom2005]_. - # We implement a variant of the Lucas pseudoprime test similar to that - # described by Baillie and Wagstaff [BaiWag1980]_. - bint n_is_probabprime(ulong n) noexcept - # Tests if `n` is a probable prime. Up to ``FLINT_ODDPRIME_SMALL_CUTOFF`` - # this algorithm uses :func:`n_is_oddprime_small` which uses a lookup table. - # Next it calls :func:`n_compute_primes` with the maximum table size and - # uses this table to perform a binary search for `n` up to the table limit. - # Then up to `1050535501` it uses a number of strong probable prime tests, - # :func:`n_is_strong_probabprime_preinv`, etc., for various bases. The - # output of the algorithm is guaranteed to be correct up to this bound due - # to exhaustive tables, described at - # http://uucode.com/obf/dalbec/alg.html . - # Beyond that point the BPSW probabilistic primality test is used, by - # calling the function :func:`n_is_probabprime_BPSW`. There are no known - # counterexamples, and it has been checked against the tables of Feitsma - # and Galway and up to the accuracy of those tables, this is an exhaustive - # check up to `2^{64}`, i.e. there are no counterexamples. - ulong n_CRT(ulong r1, ulong m1, ulong r2, ulong m2) noexcept - # Use the Chinese Remainder Theorem to return the unique value - # `0 \le x < M` congruent to `r_1` modulo `m_1` and `r_2` modulo `m_2`, - # where `M = m_1 \times m_2` is assumed to fit a ulong. - # It is assumed that `m_1` and `m_2` are positive integers greater - # than `1` and coprime. It is assumed that `0 \le r_1 < m_1` and `0 \le r_2 < m_2`. - ulong n_sqrt(ulong a) noexcept - # Computes the integer truncation of the square root of `a`. - # The implementation uses a call to the IEEE floating point sqrt function. - # The integer itself is represented by the nearest double and its square - # root is computed to the nearest place. If `a` is one below a square, the - # rounding may be up, whereas if it is one above a square, the rounding - # will be down. Thus the square root may be one too large in some - # instances which we then adjust by checking if we have the right value. - # We also have to be careful when the square of this too large - # value causes an overflow. The same assumptions hold for a single - # precision float provided the square root itself can be represented - # in a single float, i.e. for `a < 281474976710656 = 2^{46}`. - ulong n_sqrtrem(ulong * r, ulong a) noexcept - # Computes the integer truncation of the square root of `a`. - # The integer itself is represented by the nearest double and its square - # root is computed to the nearest place. If `a` is one below a square, the - # rounding may be up, whereas if it is one above a square, the rounding - # will be down. Thus the square root may be one too large in some - # instances which we then adjust by checking if we have the right value. - # We also have to be careful when the square of this too - # large value causes an overflow. The same assumptions hold for a - # single precision float provided the square root itself can be - # represented in a single float, i.e. for \ - # `a < 281474976710656 = 2^{46}`. - # The remainder is computed by subtracting the square of the computed square - # root from `a`. - bint n_is_square(ulong x) noexcept - # Returns `1` if `x` is a square, otherwise `0`. - # This code first checks if `x` is a square modulo `64`, - # `63 = 3 \times 3 \times 7` and `65 = 5 \times 13`, using lookup tables, - # and if so it then takes a square root and checks that the square of this - # equals the original value. - bint n_is_perfect_power235(ulong n) noexcept - # Returns `1` if `n` is a perfect square, cube or fifth power. - # This function uses a series of modular tests to reject most - # non 235-powers. Each modular test returns a value from 0 to 7 - # whose bits respectively indicate whether the value is a square, - # cube or fifth power modulo the given modulus. When these are - # logically ``AND``-ed together, this gives a powerful test which will - # reject most non-235 powers. - # If a bit remains set indicating it may be a square, a standard - # square root test is performed. Similarly a cube root or fifth - # root can be taken, if indicated, to determine whether the power - # of that root is exactly equal to `n`. - bint n_is_perfect_power(ulong * root, ulong n) noexcept - # If `n = r^k`, return `k` and set ``root`` to `r`. Note that `0` and - # `1` are considered squares. No guarantees are made about `r` or `k` - # being the minimum possible value. - - ulong n_rootrem(ulong* remainder, ulong n, ulong root) noexcept - # This function uses the Newton iteration method to calculate the nth root of - # a number. - # First approximation is calculated by an algorithm mentioned in this - # article: https://en.wikipedia.org/wiki/Fast_inverse_square_root . - # Instead of the inverse square root, the nth root is calculated. - # Returns the integer part of ``n ^ 1/root``. Remainder is set as - # ``n - base^root``. In case `n < 1` or ``root < 1``, `0` is returned. - + ulong n_rootrem(ulong * remainder, ulong n, ulong root) noexcept ulong n_cbrt(ulong n) noexcept - # This function returns the integer truncation of the cube root of `n`. - # First approximation is calculated by an algorithm mentioned in this - # article: https://en.wikipedia.org/wiki/Fast_inverse_square_root . - # Instead of the inverse square root, the cube root is calculated. - # This functions uses different algorithms to calculate the cube root, - # depending upon the size of `n`. For numbers greater than `2^{46}`, it uses - # :func:`n_cbrt_chebyshev_approx`. Otherwise, it makes use of the iteration, - # `x \leftarrow x - (x\cdot x\cdot x - a)\cdot x/(2\cdot x\cdot x\cdot x + a)` for getting a good estimate, - # as mentioned in the paper by W. Kahan [Kahan1991]_ . - ulong n_cbrt_newton_iteration(ulong n) noexcept - # This function returns the integer truncation of the cube root of `n`. - # Makes use of Newton iterations to get a close value, and then adjusts the - # estimate so as to get the correct value. - ulong n_cbrt_binary_search(ulong n) noexcept - # This function returns the integer truncation of the cube root of `n`. - # Uses binary search to get the correct value. - ulong n_cbrt_chebyshev_approx(ulong n) noexcept - # This function returns the integer truncation of the cube root of `n`. - # The number is first expressed in the form ``x * 2^exp``. This ensures - # `x` is in the range [0.5, 1]. Cube root of x is calculated using - # Chebyshev's approximation polynomial for the function `y = x^{1/3}`. The - # values of the coefficient are calculated from the Python module mpmath, - # https://mpmath.org, using the function chebyfit. x is multiplied - # by ``2^exp`` and the cube root of 1, 2 or 4 (according to ``exp%3``). - - ulong n_cbrtrem(ulong* remainder, ulong n) noexcept - # This function returns the integer truncation of the cube root of `n`. - # Remainder is set as `n` minus the cube of the value returned. - + ulong n_cbrtrem(ulong * remainder, ulong n) noexcept void n_factor_init(n_factor_t * factors) noexcept - # Initializes factors. - int n_remove(ulong * n, ulong p) noexcept - # Removes the highest possible power of `p` from `n`, replacing - # `n` with the quotient. The return value is the highest - # power of `p` that divided `n`. Assumes `n` is not `0`. - # For `p = 2` trailing zeroes are counted. For other primes - # `p` is repeatedly squared and stored in a table of powers - # with the current highest power of `p` removed at each step - # until no higher power can be removed. The algorithm then - # proceeds down the power tree again removing powers of `p` - # until none remain. - int n_remove2_precomp(ulong * n, ulong p, double ppre) noexcept - # Removes the highest possible power of `p` from `n`, replacing - # `n` with the quotient. The return value is the highest - # power of `p` that divided `n`. Assumes `n` is not `0`. We require - # ``ppre`` to be set to a precomputed inverse of `p` computed - # with :func:`n_precompute_inverse`. - # For `p = 2` trailing zeroes are counted. For other primes - # `p` we make repeated use of :func:`n_divrem2_precomp` until division - # by `p` is no longer possible. - void n_factor_insert(n_factor_t * factors, ulong p, ulong exp) noexcept - # Inserts the given prime power factor ``p^exp`` into - # the ``n_factor_t`` ``factors``. See the documentation for - # :func:`n_factor_trial` for a description of the ``n_factor_t`` type. - # The algorithm performs a simple search to see if `p` already - # exists as a prime factor in the structure. If so the exponent - # there is increased by the supplied exponent. Otherwise a new - # factor ``p^exp`` is added to the end of the structure. - # There is no test code for this function other than its use by - # the various factoring functions, which have test code. - ulong n_factor_trial_range(n_factor_t * factors, ulong n, ulong start, ulong num_primes) noexcept - # Trial factor `n` with the first ``num_primes`` primes, but - # starting at the prime with index start (counting from zero). - # One requires an initialised ``n_factor_t`` structure, but factors - # will be added by default to an already used ``n_factor_t``. Use - # the function :func:`n_factor_init` defined in ``ulong_extras`` if - # initialisation has not already been completed on factors. - # Once completed, ``num`` will contain the number of distinct - # prime factors found. The field `p` is an array of ``ulong``\s - # containing the distinct prime factors, ``exp`` an array - # containing the corresponding exponents. - # The return value is the unfactored cofactor after trial - # factoring is done. - # The function calls :func:`n_compute_primes` automatically. See - # the documentation for that function regarding limits. - # The algorithm stops when the current prime has a square - # exceeding `n`, as no prime factor of `n` can exceed this - # unless `n` is prime. - # The precomputed inverses of all the primes computed by - # :func:`n_compute_primes` are utilised with the :func:`n_remove2_precomp` - # function. - ulong n_factor_trial(n_factor_t * factors, ulong n, ulong num_primes) noexcept - # This function calls :func:`n_factor_trial_range`, with the value of - # `0` for ``start``. By default this adds factors to an already existing - # ``n_factor_t`` or to a newly initialised one. - - ulong n_factor_power235(ulong *exp, ulong n) noexcept - # Returns `0` if `n` is not a perfect square, cube or fifth power. - # Otherwise it returns the root and sets ``exp`` to either `2`, - # `3` or `5` appropriately. - # This function uses a series of modular tests to reject most - # non 235-powers. Each modular test returns a value from 0 to 7 - # whose bits respectively indicate whether the value is a square, - # cube or fifth power modulo the given modulus. When these are - # logically ``AND``-ed together, this gives a powerful test which will - # reject most non-235 powers. - # If a bit remains set indicating it may be a square, a standard - # square root test is performed. Similarly a cube root or fifth - # root can be taken, if indicated, to determine whether the power - # of that root is exactly equal to `n`. - + ulong n_factor_power235(ulong * exp, ulong n) noexcept ulong n_factor_one_line(ulong n, ulong iters) noexcept - # This implements Bill Hart's one line factoring algorithm [Har2012]_. - # It is a variant of Fermat's algorithm which cycles through a large number - # of multipliers instead of incrementing the square root. It is faster than - # SQUFOF for `n` less than about `2^{40}`. - ulong n_factor_lehman(ulong n) noexcept - # Lehman's factoring algorithm. Currently works up to `10^{16}`, but is - # not particularly efficient and so is not used in the general factor - # function. Always returns a factor of `n`. - ulong n_factor_SQUFOF(ulong n, ulong iters) noexcept - # Attempts to split `n` using the given number of iterations - # of SQUFOF. Simply set ``iters`` to ``WORD(0)`` for maximum - # persistence. - # The version of SQUFOF implemented here is as described by Gower - # and Wagstaff [GowWag2008]_. - # We start by trying SQUFOF directly on `n`. If that fails we - # multiply it by each of the primes in ``flint_primes_small`` in - # turn. As this multiplication may result in a two limb value - # we allow this in our implementation of SQUFOF. As SQUFOF - # works with values about half the size of `n` it only needs - # single limb arithmetic internally. - # If SQUFOF fails to factor `n` we return `0`, however with - # ``iters`` large enough this should never happen. - void n_factor(n_factor_t * factors, ulong n, int proved) noexcept - # Factors `n` with no restrictions on `n`. If the prime factors are - # required to be checked with a primality test, one may set - # ``proved`` to `1`, otherwise set it to `0`, and they will only be - # probable primes. NB: at the present there is no difference because - # the probable prime tests have been exhaustively tested up to `2^{64}`. - # However, in future, this flag may produce and separately check - # a primality certificate. This may be quite slow (and probably no - # less reliable in practice). - # For details on the ``n_factor_t`` structure, see - # :func:`n_factor_trial`. - # This function first tries trial factoring with a number of primes - # specified by the constant ``FLINT_FACTOR_TRIAL_PRIMES``. If the - # cofactor is `1` or prime the function returns with all the factors. - # Otherwise, the cofactor is placed in the array ``factor_arr``. Whilst - # there are factors remaining in there which have not been split, the - # algorithm continues. At each step each factor is first checked to - # determine if it is a perfect power. If so it is replaced by the power - # that has been found. Next if the factor is small enough and composite, - # in particular, less than ``FLINT_FACTOR_ONE_LINE_MAX`` then - # :func:`n_factor_one_line` is called with - # ``FLINT_FACTOR_ONE_LINE_ITERS`` to try and split the factor. If - # that fails or the factor is too large for :func:`n_factor_one_line` - # then :func:`n_factor_SQUFOF` is called, with - # ``FLINT_FACTOR_SQUFOF_ITERS``. If that fails an error results and - # the program aborts. However this should not happen in practice. - ulong n_factor_trial_partial(n_factor_t * factors, ulong n, ulong * prod, ulong num_primes, ulong limit) noexcept - # Attempts trial factoring of `n` with the first ``num_primes primes``, - # but stops when the product of prime factors so far exceeds ``limit``. - # One requires an initialised ``n_factor_t`` structure, but factors - # will be added by default to an already used ``n_factor_t``. Use - # the function :func:`n_factor_init` defined in ``ulong_extras`` if - # initialisation has not already been completed on ``factors``. - # Once completed, ``num`` will contain the number of distinct - # prime factors found. The field `p` is an array of ``ulong``\s - # containing the distinct prime factors, ``exp`` an array - # containing the corresponding exponents. - # The return value is the unfactored cofactor after trial - # factoring is done. The value ``prod`` will be set to the product - # of the factors found. - # The function calls :func:`n_compute_primes` automatically. See - # the documentation for that function regarding limits. - # The algorithm stops when the current prime has a square - # exceeding `n`, as no prime factor of `n` can exceed this - # unless `n` is prime. - # The precomputed inverses of all the primes computed by - # :func:`n_compute_primes` are utilised with the :func:`n_remove2_precomp` - # function. - ulong n_factor_partial(n_factor_t * factors, ulong n, ulong limit, int proved) noexcept - # Factors `n`, but stops when the product of prime factors so far - # exceeds ``limit``. - # One requires an initialised ``n_factor_t`` structure, but factors - # will be added by default to an already used ``n_factor_t``. Use - # the function ``n_factor_init()`` defined in ``ulong_extras`` if - # initialisation has not already been completed on ``factors``. - # On exit, ``num`` will contain the number of distinct prime factors - # found. The field `p` is an array of ``ulong``\s containing the - # distinct prime factors, ``exp`` an array containing the corresponding - # exponents. - # The return value is the unfactored cofactor after factoring is done. - # The factors are proved prime if ``proved`` is `1`, otherwise - # they are merely probably prime. - ulong n_factor_pp1(ulong n, ulong B1, ulong c) noexcept - # Factors `n` using Williams' `p + 1` factoring algorithm, with prime - # limit set to `B1`. We require `c` to be set to a random value. Each - # trial of the algorithm with a different value of `c` gives another - # chance to factor `n`, with roughly exponentially decreasing chance - # of finding a missing factor. If `p + 1` (or `p - 1`) is not smooth - # for any factor `p` of `n`, the algorithm will never succeed. The - # value `c` should be less than `n` and greater than `2`. - # If the algorithm succeeds, it returns the factor, otherwise it - # returns `0` or `1` (the trivial factors modulo `n`). - ulong n_factor_pp1_wrapper(ulong n) noexcept - # A simple wrapper around ``n_factor_pp1`` which works in the range - # `31`-`64` bits. Below this point, trial factoring will always succeed. - # This function mainly exists for ``n_factor`` and is tuned to minimise - # the time for ``n_factor`` on numbers that reach the ``n_factor_pp1`` - # stage, i.e. after trial factoring and one line factoring. - - int n_factor_pollard_brent_single(mp_limb_t *factor, mp_limb_t n, mp_limb_t ninv, mp_limb_t ai, mp_limb_t xi, mp_limb_t normbits, mp_limb_t max_iters) noexcept - # Pollard Rho algorithm (with Brent modification) for integer factorization. - # Assumes that the `n` is not prime. `factor` is set as the factor if found. - # It is not assured that the factor found will be prime. Does not compute the complete - # factorization, just one factor. Returns 1 if factorization is successful - # (non trivial factor is found), else returns 0. Assumes `n` is normalized - # (shifted by normbits bits), and takes as input a precomputed inverse of `n` as - # computed by :func:`n_preinvert_limb`. `ai` and `xi` should also be shifted - # left by `normbits`. - # `ai` is the constant of the polynomial used, `xi` is the initial value. - # `max\_iters` is the number of iterations tried in process of finding the - # cycle. - # The algorithm used is a modification of the original Pollard Rho algorithm, - # suggested by Richard Brent in the paper, available at - # https://maths-people.anu.edu.au/~brent/pd/rpb051i.pdf - - int n_factor_pollard_brent(mp_limb_t *factor, flint_rand_t state, mp_limb_t n_in, mp_limb_t max_tries, mp_limb_t max_iters) noexcept - # Pollard Rho algorithm, modified as suggested by Richard Brent. Makes a call to - # :func:`n_factor_pollard_brent_single`. The input parameters ai and xi for - # :func:`n_factor_pollard_brent_single` are selected at random. - # If the algorithm fails to find a non trivial factor in one call, it tries again - # (this time with a different set of random values). This process is repeated a - # maximum of `max\_tries` times. - # Assumes `n` is not prime. `factor` is set as the factor found, if factorization - # is successful. In such a case, 1 is returned. Otherwise, 0 is returned. Factor - # discovered is not necessarily prime. - + int n_factor_pollard_brent_single(mp_limb_t * factor, mp_limb_t n, mp_limb_t ninv, mp_limb_t ai, mp_limb_t xi, mp_limb_t normbits, mp_limb_t max_iters) noexcept + int n_factor_pollard_brent(mp_limb_t * factor, flint_rand_t state, mp_limb_t n_in, mp_limb_t max_tries, mp_limb_t max_iters) noexcept int n_moebius_mu(ulong n) noexcept - # Computes the Moebius function `\mu(n)`, which is defined as `\mu(n) = 0` - # if `n` has a prime factor of multiplicity greater than `1`, `\mu(n) = -1` - # if `n` has an odd number of distinct prime factors, and `\mu(n) = 1` if - # `n` has an even number of distinct prime factors. By convention, - # `\mu(0) = 0`. - # For even numbers, we use the identities `\mu(4n) = 0` and - # `\mu(2n) = - \mu(n)`. Odd numbers up to a cutoff are then looked up from - # a precomputed table storing `\mu(n) + 1` in groups of two bits. - # For larger `n`, we first check if `n` is divisible by a small odd square - # and otherwise call ``n_factor()`` and count the factors. - void n_moebius_mu_vec(int * mu, ulong len) noexcept - # Computes `\mu(n)` for ``n = 0, 1, ..., len - 1``. This - # is done by sieving over each prime in the range, flipping the sign - # of `\mu(n)` for every multiple of a prime `p` and setting `\mu(n) = 0` - # for every multiple of `p^2`. - bint n_is_squarefree(ulong n) noexcept - # Returns `0` if `n` is divisible by some perfect square, and `1` otherwise. - # This simply amounts to testing whether `\mu(n) \neq 0`. As special - # cases, `1` is considered squarefree and `0` is not considered squarefree. - ulong n_euler_phi(ulong n) noexcept - # Computes the Euler totient function `\phi(n)`, counting the number of - # positive integers less than or equal to `n` that are coprime to `n`. - ulong n_factorial_fast_mod2_preinv(ulong n, ulong p, ulong pinv) noexcept - # Returns `n! \bmod p` given a precomputed inverse of `p` as computed - # by :func:`n_preinvert_limb`. `p` is not required to be a prime, but - # no special optimisations are made for composite `p`. - # Uses fast multipoint evaluation, running in about `O(n^{1/2})` time. - ulong n_factorial_mod2_preinv(ulong n, ulong p, ulong pinv) noexcept - # Returns `n! \bmod p` given a precomputed inverse of `p` as computed - # by :func:`n_preinvert_limb`. `p` is not required to be a prime, but - # no special optimisations are made for composite `p`. - # Uses a lookup table for small `n`, otherwise computes the product - # if `n` is not too large, and calls the fast algorithm for extremely - # large `n`. - ulong n_primitive_root_prime_prefactor(ulong p, n_factor_t * factors) noexcept - # Returns a primitive root for the multiplicative subgroup of `\mathbb{Z}/p\mathbb{Z}` - # where `p` is prime given the factorisation (``factors``) of `p - 1`. - ulong n_primitive_root_prime(ulong p) noexcept - # Returns a primitive root for the multiplicative subgroup of `\mathbb{Z}/p\mathbb{Z}` - # where `p` is prime. - ulong n_discrete_log_bsgs(ulong b, ulong a, ulong n) noexcept - # Returns the discrete logarithm of `b` with respect to `a` in the - # multiplicative subgroup of `\mathbb{Z}/n\mathbb{Z}` when `\mathbb{Z}/n\mathbb{Z}` - # is cyclic. That is, - # it returns a number `x` such that `a^x = b \bmod n`. The - # multiplicative subgroup is only cyclic when `n` is `2`, `4`, - # `p^k`, or `2p^k` where `p` is an odd prime and `k` is a positive - # integer. - - void n_factor_ecm_double(mp_limb_t *x, mp_limb_t *z, mp_limb_t x0, mp_limb_t z0, mp_limb_t n, n_ecm_t n_ecm_inf) noexcept - # Sets the point `(x : z)` to two times `(x_0 : z_0)` modulo `n` according - # to the formula - # `x = (x_0 + z_0)^2 \cdot (x_0 - z_0)^2 \mod n,` - # `z = 4 x_0 z_0 \left((x_0 - z_0)^2 + 4a_{24}x_0z_0\right) \mod n.` - # This group doubling is valid only for points expressed in - # Montgomery projective coordinates. - - void n_factor_ecm_add(mp_limb_t *x, mp_limb_t *z, mp_limb_t x1, mp_limb_t z1, mp_limb_t x2, mp_limb_t z2, mp_limb_t x0, mp_limb_t z0, mp_limb_t n, n_ecm_t n_ecm_inf) noexcept - # Sets the point `(x : z)` to the sum of `(x_1 : z_1)` and `(x_2 : z_2)` - # modulo `n`, given the difference `(x_0 : z_0)` according to the formula - # This group doubling is valid only for points expressed in - # Montgomery projective coordinates. - - void n_factor_ecm_mul_montgomery_ladder(mp_limb_t *x, mp_limb_t *z, mp_limb_t x0, mp_limb_t z0, mp_limb_t k, mp_limb_t n, n_ecm_t n_ecm_inf) noexcept - # Montgomery ladder algorithm for scalar multiplication of elliptic points. - # Sets the point `(x : z)` to `k(x_0 : z_0)` modulo `n`. - # Valid only for points expressed in Montgomery projective coordinates. - - int n_factor_ecm_select_curve(mp_limb_t *f, mp_limb_t sigma, mp_limb_t n, n_ecm_t n_ecm_inf) noexcept - # Selects a random elliptic curve given a random integer ``sigma``, - # according to Suyama's parameterization. If the factor is found while - # selecting the curve, `1` is returned. In case the curve found is not - # suitable, `0` is returned. - # Also selects the initial point `x_0`, and the value of `(a + 2)/4`, where `a` - # is a curve parameter. Sets `z_0` as `1` (shifted left by - # ``n_ecm_inf->normbits``). All these are stored in the - # ``n_ecm_t`` struct. - # The curve selected is of Montgomery form, the points selected satisfy the - # curve and are projective coordinates. - - int n_factor_ecm_stage_I(mp_limb_t *f, const mp_limb_t *prime_array, mp_limb_t num, mp_limb_t B1, mp_limb_t n, n_ecm_t n_ecm_inf) noexcept - # Stage I implementation of the ECM algorithm. - # ``f`` is set as the factor if found. ``num`` is number of prime numbers - # `<=` the bound ``B1``. ``prime_array`` is an array of first ``B1`` - # primes. `n` is the number being factored. - # If the factor is found, `1` is returned, otherwise `0`. - - int n_factor_ecm_stage_II(mp_limb_t *f, mp_limb_t B1, mp_limb_t B2, mp_limb_t P, mp_limb_t n, n_ecm_t n_ecm_inf) noexcept - # Stage II implementation of the ECM algorithm. - # ``f`` is set as the factor if found. ``B1``, ``B2`` are the two - # bounds. ``P`` is the primorial (approximately equal to `\sqrt{B2}`). - # `n` is the number being factored. - # If the factor is found, `1` is returned, otherwise `0`. - - int n_factor_ecm(mp_limb_t *f, mp_limb_t curves, mp_limb_t B1, mp_limb_t B2, flint_rand_t state, mp_limb_t n) noexcept - # Outer wrapper function for the ECM algorithm. It factors `n` which - # must fit into a ``mp_limb_t``. - # The function calls stage I and II, and - # the precomputations (builds ``prime_array`` for stage I, - # ``GCD_table`` and ``prime_table`` for stage II). - # ``f`` is set as the factor if found. ``curves`` is the number of - # random curves being tried. ``B1``, ``B2`` are the two bounds or - # stage I and stage II. `n` is the number being factored. - # If a factor is found in stage I, `1` is returned. - # If a factor is found in stage II, `2` is returned. - # If a factor is found while selecting the curve, `-1` is returned. - # Otherwise `0` is returned. + void n_factor_ecm_double(mp_limb_t * x, mp_limb_t * z, mp_limb_t x0, mp_limb_t z0, mp_limb_t n, n_ecm_t n_ecm_inf) noexcept + void n_factor_ecm_add(mp_limb_t * x, mp_limb_t * z, mp_limb_t x1, mp_limb_t z1, mp_limb_t x2, mp_limb_t z2, mp_limb_t x0, mp_limb_t z0, mp_limb_t n, n_ecm_t n_ecm_inf) noexcept + void n_factor_ecm_mul_montgomery_ladder(mp_limb_t * x, mp_limb_t * z, mp_limb_t x0, mp_limb_t z0, mp_limb_t k, mp_limb_t n, n_ecm_t n_ecm_inf) noexcept + int n_factor_ecm_select_curve(mp_limb_t * f, mp_limb_t sigma, mp_limb_t n, n_ecm_t n_ecm_inf) noexcept + int n_factor_ecm_stage_I(mp_limb_t * f, const mp_limb_t * prime_array, mp_limb_t num, mp_limb_t B1, mp_limb_t n, n_ecm_t n_ecm_inf) noexcept + int n_factor_ecm_stage_II(mp_limb_t * f, mp_limb_t B1, mp_limb_t B2, mp_limb_t P, mp_limb_t n, n_ecm_t n_ecm_inf) noexcept + int n_factor_ecm(mp_limb_t * f, mp_limb_t curves, mp_limb_t B1, mp_limb_t B2, flint_rand_t state, mp_limb_t n) noexcept From 0abbb01a5158ba9110059f590ef15ca9b3851608 Mon Sep 17 00:00:00 2001 From: Vincent Delecroix <20100.delecroix@gmail.com> Date: Tue, 12 Dec 2023 18:02:05 +0100 Subject: [PATCH 36/41] linting --- src/sage_setup/autogen/flint/reader.py | 3 --- src/sage_setup/autogen/flint/writer.py | 3 ++- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/sage_setup/autogen/flint/reader.py b/src/sage_setup/autogen/flint/reader.py index c8d44298066..671fe5c491d 100644 --- a/src/sage_setup/autogen/flint/reader.py +++ b/src/sage_setup/autogen/flint/reader.py @@ -252,6 +252,3 @@ def extract_functions(filename): e = Extractor(filename) e.run() return e.content - - - diff --git a/src/sage_setup/autogen/flint/writer.py b/src/sage_setup/autogen/flint/writer.py index 18b6802ead7..e63d3c9bcf9 100644 --- a/src/sage_setup/autogen/flint/writer.py +++ b/src/sage_setup/autogen/flint/writer.py @@ -11,7 +11,8 @@ # http://www.gnu.org/licenses/ #***************************************************************************** -import os, shutil +import os +import shutil from .env import AUTOGEN_DIR, FLINT_DOC_DIR, FLINT_INCLUDE_DIR from .reader import extract_functions From fcaceaf52f4f722ca557052a0d8a7a25a1836816 Mon Sep 17 00:00:00 2001 From: Vincent Delecroix <20100.delecroix@gmail.com> Date: Tue, 12 Dec 2023 22:23:05 +0100 Subject: [PATCH 37/41] fix README --- src/sage_setup/autogen/flint/README.md | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/src/sage_setup/autogen/flint/README.md b/src/sage_setup/autogen/flint/README.md index 6fe45febad2..cd693904a53 100644 --- a/src/sage_setup/autogen/flint/README.md +++ b/src/sage_setup/autogen/flint/README.md @@ -1,25 +1,30 @@ Autogeneration of flint header files for SageMath ================================================= -The scripts in this folder are responsible for the automatic generation of the Cython header files -in `sage/libs/flint/`. To make the autogeneration +The scripts in this folder are responsible for the automatic generation of the +Cython header files in `$SAGE_ROOT/src/sage/libs/flint/`. To make the +autogeneration -1. Obtain a clone of the flint repo, eg `git clone https://github.com/flintlib/flint2` +1. Obtain a clone of the flint repo, eg `git clone + https://github.com/flintlib/flint2` 2. Checkout to the appropriate commit, eg `git checkout v2.9.0` -3. Possibly adjust the content of `types.pxd.template` (which will be used to generate - types.pxd) +3. Possibly adjust the content of `types.pxd.template` (which will be used to + generate types.pxd) 4. Set the environment variable `FLINT_GIT_DIR` -5. Run the `run.py` script, eg `python autogen.py` - (that automatically write down the headers in the sage source tree `SAGE_SRC/sage/libs/flint`) +5. Run the `flint_autogen.py` script eg `python + $SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py`. The script writes down + the headers in the sage source tree `$SAGE_ROOT/src/sage/libs/flint/`. Additional notes ---------------- -- macros in flint documentation are not converted into cython declarations (because they lack - a signature). The cython signature of flint macros must be manually written down in the - files contained `SAGE_SRC/sage/src/sage_setup/autogen/flint/macros` +- macros in flint documentation are not converted into cython declarations + (because they lack a signature). The cython signature of flint macros must be + manually written down in the files contained + `SAGE_SRC/sage/src/sage_setup/autogen/flint/macros` + See https://github.com/flintlib/flint/issues/1529. From 56e081adbf23e951b6fc4739bfda2cb751169e6e Mon Sep 17 00:00:00 2001 From: Vincent Delecroix <20100.delecroix@gmail.com> Date: Mon, 18 Dec 2023 21:20:54 +0100 Subject: [PATCH 38/41] make sage.libs.flint.*.py a cython modules again Otherwise, a non cleaned installation would still use the "old" cython version rather than the python one. --- src/sage/libs/flint/{arith.py => arith.pyx} | 16 +++++++++------- .../libs/flint/{fmpz_poly.py => fmpz_poly.pyx} | 6 ++---- src/sage/libs/flint/{qsieve.py => qsieve.pyx} | 6 ++---- .../flint/{ulong_extras.py => ulong_extras.pyx} | 6 ++---- 4 files changed, 15 insertions(+), 19 deletions(-) rename src/sage/libs/flint/{arith.py => arith.pyx} (75%) rename src/sage/libs/flint/{fmpz_poly.py => fmpz_poly.pyx} (72%) rename src/sage/libs/flint/{qsieve.py => qsieve.pyx} (75%) rename src/sage/libs/flint/{ulong_extras.py => ulong_extras.pyx} (76%) diff --git a/src/sage/libs/flint/arith.py b/src/sage/libs/flint/arith.pyx similarity index 75% rename from src/sage/libs/flint/arith.py rename to src/sage/libs/flint/arith.pyx index 2b8436f3321..fe599af4dfc 100644 --- a/src/sage/libs/flint/arith.py +++ b/src/sage/libs/flint/arith.pyx @@ -64,11 +64,13 @@ 25/12 """ -from sage.misc.lazy_import import lazy_import +from sage.misc.lazy_import import LazyImport -lazy_import('sage.libs.flint.arith_sage', ['bell_number', 'bernoulli_number', - 'euler_number', 'stirling_number_1', 'stirling_number_2', - 'number_of_partitions', 'dedekind_sum', 'harmonic_number'], - deprecation=36449) - -del lazy_import +bell_number = LazyImport('sage.libs.flint.arith_sage', 'bell_number', deprecation=36449) +bernoulli_number = LazyImport('sage.libs.flint.arith_sage', 'bernoulli_number', deprecation=36449) +euler_number = LazyImport('sage.libs.flint.arith_sage', 'euler_number', deprecation=36449) +stirling_number_1 = LazyImport('sage.libs.flint.arith_sage', 'stirling_number_1', deprecation=36449) +stirling_number_2 = LazyImport('sage.libs.flint.arith_sage', 'stirling_number_2', deprecation=36449) +number_of_partitions = LazyImport('sage.libs.flint.arith_sage', 'number_of_partitions', deprecation=36449) +dedekind_sum = LazyImport('sage.libs.flint.arith_sage', 'dedekind_sum', deprecation=36449) +harmonic_number = LazyImport('sage.libs.flint.arith_sage', 'harmonic_number', deprecation=36449) diff --git a/src/sage/libs/flint/fmpz_poly.py b/src/sage/libs/flint/fmpz_poly.pyx similarity index 72% rename from src/sage/libs/flint/fmpz_poly.py rename to src/sage/libs/flint/fmpz_poly.pyx index 7d9455f6f33..ca3997316e7 100644 --- a/src/sage/libs/flint/fmpz_poly.py +++ b/src/sage/libs/flint/fmpz_poly.pyx @@ -13,8 +13,6 @@ 2 1 1 """ -from sage.misc.lazy_import import lazy_import +from sage.misc.lazy_import import LazyImport -lazy_import('sage.libs.flint.fmpz_poly_sage', 'Fmpz_poly', deprecation=36449) - -del lazy_import +Fmpz_poly = LazyImport('sage.libs.flint.fmpz_poly_sage', 'Fmpz_poly', deprecation=36449) diff --git a/src/sage/libs/flint/qsieve.py b/src/sage/libs/flint/qsieve.pyx similarity index 75% rename from src/sage/libs/flint/qsieve.py rename to src/sage/libs/flint/qsieve.pyx index 7fc32bebf96..7168a3beac8 100644 --- a/src/sage/libs/flint/qsieve.py +++ b/src/sage/libs/flint/qsieve.pyx @@ -15,8 +15,6 @@ [(2, 3), (5, 3)] """ -from sage.misc.lazy_import import lazy_import +from sage.misc.lazy_import import LazyImport -lazy_import('sage.libs.flint.qsieve_sage', 'qsieve', deprecation=36449) - -del lazy_import +qsieve = LazyImport('sage.libs.flint.qsieve_sage', 'qsieve', deprecation=36449) diff --git a/src/sage/libs/flint/ulong_extras.py b/src/sage/libs/flint/ulong_extras.pyx similarity index 76% rename from src/sage/libs/flint/ulong_extras.py rename to src/sage/libs/flint/ulong_extras.pyx index a3fcbf59f5e..e4eee95b119 100644 --- a/src/sage/libs/flint/ulong_extras.py +++ b/src/sage/libs/flint/ulong_extras.pyx @@ -15,8 +15,6 @@ [(2, 2), (3, 1), (5, 1)] """ -from sage.misc.lazy_import import lazy_import +from sage.misc.lazy_import import LazyImport -lazy_import('sage.libs.flint.ulong_extras_sage', 'n_factor_to_list', deprecation=36449) - -del lazy_import +n_factor_to_list = LazyImport('sage.libs.flint.ulong_extras_sage', 'n_factor_to_list', deprecation=36449) From dc4cc1be08a57e5a7124a2dd38d612604dcc5496 Mon Sep 17 00:00:00 2001 From: Vincent Delecroix <20100.delecroix@gmail.com> Date: Wed, 20 Dec 2023 09:54:12 +0100 Subject: [PATCH 39/41] fix import in combinat.py --- src/sage/combinat/combinat.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/sage/combinat/combinat.py b/src/sage/combinat/combinat.py index 8eebda8244a..e87a44ad662 100644 --- a/src/sage/combinat/combinat.py +++ b/src/sage/combinat/combinat.py @@ -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) @@ -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) From 1f06da4b7a30426da8ed9674d24f1fae6a1cdd24 Mon Sep 17 00:00:00 2001 From: Vincent Delecroix <20100.delecroix@gmail.com> Date: Fri, 22 Dec 2023 08:46:13 +0100 Subject: [PATCH 40/41] fix sage_flint feature --- src/sage/features/sagemath.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sage/features/sagemath.py b/src/sage/features/sagemath.py index dd48c55ee6b..d78c95e38b2 100644 --- a/src/sage/features/sagemath.py +++ b/src/sage/features/sagemath.py @@ -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') From 2082c34390c880385a596f54f29fc6e3bdf28124 Mon Sep 17 00:00:00 2001 From: Vincent Delecroix <20100.delecroix@gmail.com> Date: Fri, 22 Dec 2023 16:35:35 +0100 Subject: [PATCH 41/41] fix import of dedekind_sum --- src/sage/arith/misc.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sage/arith/misc.py b/src/sage/arith/misc.py index 3307de93458..6ec10197e6e 100644 --- a/src/sage/arith/misc.py +++ b/src/sage/arith/misc.py @@ -6203,7 +6203,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':